Context
stringlengths
57
85k
file_name
stringlengths
21
79
start
int64
14
2.42k
end
int64
18
2.43k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
import Mathlib.Algebra.Homology.ImageToKernel #align_import algebra.homology.exact from "leanprover-community/mathlib"@"3feb151caefe53df080ca6ca67a0c6685cfd1b82" universe v v₂ u u₂ open CategoryTheory CategoryTheory.Limits variable {V : Type u} [Category.{v} V] variable [HasImages V] namespace CategoryTheory -- One nice feature of this definition is that we have -- `Epi f → Exact g h → Exact (f ≫ g) h` and `Exact f g → Mono h → Exact f (g ≫ h)`, -- which do not necessarily hold in a non-abelian category with the usual definition of `Exact`. structure Exact [HasZeroMorphisms V] [HasKernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop where w : f ≫ g = 0 epi : Epi (imageToKernel f g w) #align category_theory.exact CategoryTheory.Exact -- Porting note: it seems it no longer works in Lean4, so that some `haveI` have been added below -- This works as an instance even though `Exact` itself is not a class, as long as the goal is -- literally of the form `Epi (imageToKernel f g h.w)` (where `h : Exact f g`). If the proof of -- `f ≫ g = 0` looks different, we are out of luck and have to add the instance by hand. attribute [instance] Exact.epi attribute [reassoc] Exact.w section variable [HasZeroObject V] [Preadditive V] [HasKernels V] [HasCokernels V] open ZeroObject theorem Preadditive.exact_iff_homology'_zero {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Exact f g ↔ ∃ w : f ≫ g = 0, Nonempty (homology' f g w ≅ 0) := ⟨fun h => ⟨h.w, ⟨by haveI := h.epi exact cokernel.ofEpi _⟩⟩, fun h => by obtain ⟨w, ⟨i⟩⟩ := h exact ⟨w, Preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))⟩⟩ #align category_theory.preadditive.exact_iff_homology_zero CategoryTheory.Preadditive.exact_iff_homology'_zero theorem Preadditive.exact_of_iso_of_exact {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) (h : Exact f₁ g₁) : Exact f₂ g₂ := by rw [Preadditive.exact_iff_homology'_zero] at h ⊢ rcases h with ⟨w₁, ⟨i⟩⟩ suffices w₂ : f₂ ≫ g₂ = 0 from ⟨w₂, ⟨(homology'.mapIso w₁ w₂ α β p).symm.trans i⟩⟩ rw [← cancel_epi α.hom.left, ← cancel_mono β.inv.right, comp_zero, zero_comp, ← w₁] have eq₁ := β.inv.w have eq₂ := α.hom.w dsimp at eq₁ eq₂ simp only [Category.assoc, Category.assoc, ← eq₁, reassoc_of% eq₂, p, ← reassoc_of% (Arrow.comp_left β.hom β.inv), β.hom_inv_id, Arrow.id_left, Category.id_comp] #align category_theory.preadditive.exact_of_iso_of_exact CategoryTheory.Preadditive.exact_of_iso_of_exact theorem Preadditive.exact_of_iso_of_exact' {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : A₁ ≅ A₂) (β : B₁ ≅ B₂) (γ : C₁ ≅ C₂) (hsq₁ : α.hom ≫ f₂ = f₁ ≫ β.hom) (hsq₂ : β.hom ≫ g₂ = g₁ ≫ γ.hom) (h : Exact f₁ g₁) : Exact f₂ g₂ := Preadditive.exact_of_iso_of_exact f₁ g₁ f₂ g₂ (Arrow.isoMk α β hsq₁) (Arrow.isoMk β γ hsq₂) rfl h #align category_theory.preadditive.exact_of_iso_of_exact' CategoryTheory.Preadditive.exact_of_iso_of_exact' theorem Preadditive.exact_iff_exact_of_iso {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) : Exact f₁ g₁ ↔ Exact f₂ g₂ := ⟨Preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p, Preadditive.exact_of_iso_of_exact _ _ _ _ α.symm β.symm (by rw [← cancel_mono α.hom.right] simp only [Iso.symm_hom, ← Arrow.comp_right, α.inv_hom_id] simp only [p, ← Arrow.comp_left, Arrow.id_right, Arrow.id_left, Iso.inv_hom_id] rfl)⟩ #align category_theory.preadditive.exact_iff_exact_of_iso CategoryTheory.Preadditive.exact_iff_exact_of_iso end section variable [HasZeroMorphisms V] [HasKernels V] theorem comp_eq_zero_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : f ≫ g = 0 := by suffices Subobject.arrow (imageSubobject f) ≫ g = 0 by rw [← imageSubobject_arrow_comp f, Category.assoc, this, comp_zero] rw [p, kernelSubobject_arrow_comp] #align category_theory.comp_eq_zero_of_image_eq_kernel CategoryTheory.comp_eq_zero_of_image_eq_kernel theorem imageToKernel_isIso_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : IsIso (imageToKernel f g (comp_eq_zero_of_image_eq_kernel f g p)) := by refine ⟨⟨Subobject.ofLE _ _ p.ge, ?_⟩⟩ dsimp [imageToKernel] simp only [Subobject.ofLE_comp_ofLE, Subobject.ofLE_refl, and_self] #align category_theory.image_to_kernel_is_iso_of_image_eq_kernel CategoryTheory.imageToKernel_isIso_of_image_eq_kernel -- We'll prove the converse later, when `V` is abelian. theorem exact_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : Exact f g := { w := comp_eq_zero_of_image_eq_kernel f g p epi := by haveI := imageToKernel_isIso_of_image_eq_kernel f g p infer_instance } #align category_theory.exact_of_image_eq_kernel CategoryTheory.exact_of_image_eq_kernel end variable {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D} attribute [local instance] epi_comp section variable [HasZeroMorphisms V] [HasEqualizers V]
Mathlib/Algebra/Homology/Exact.lean
174
178
theorem exact_comp_hom_inv_comp (i : B ≅ D) (h : Exact f g) : Exact (f ≫ i.hom) (i.inv ≫ g) := by
refine ⟨by simp [h.w], ?_⟩ rw [imageToKernel_comp_hom_inv_comp] haveI := h.epi infer_instance
import Mathlib.Data.ZMod.Quotient #align_import group_theory.complement from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" open Set open scoped Pointwise namespace Subgroup variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G) @[to_additive "`S` and `T` are complements if `(+) : S × T → G` is a bijection"] def IsComplement : Prop := Function.Bijective fun x : S × T => x.1.1 * x.2.1 #align subgroup.is_complement Subgroup.IsComplement #align add_subgroup.is_complement AddSubgroup.IsComplement @[to_additive "`H` and `K` are complements if `(+) : H × K → G` is a bijection"] abbrev IsComplement' := IsComplement (H : Set G) (K : Set G) #align subgroup.is_complement' Subgroup.IsComplement' #align add_subgroup.is_complement' AddSubgroup.IsComplement' @[to_additive "The set of left-complements of `T : Set G`"] def leftTransversals : Set (Set G) := { S : Set G | IsComplement S T } #align subgroup.left_transversals Subgroup.leftTransversals #align add_subgroup.left_transversals AddSubgroup.leftTransversals @[to_additive "The set of right-complements of `S : Set G`"] def rightTransversals : Set (Set G) := { T : Set G | IsComplement S T } #align subgroup.right_transversals Subgroup.rightTransversals #align add_subgroup.right_transversals AddSubgroup.rightTransversals variable {H K S T} @[to_additive] theorem isComplement'_def : IsComplement' H K ↔ IsComplement (H : Set G) (K : Set G) := Iff.rfl #align subgroup.is_complement'_def Subgroup.isComplement'_def #align add_subgroup.is_complement'_def AddSubgroup.isComplement'_def @[to_additive] theorem isComplement_iff_existsUnique : IsComplement S T ↔ ∀ g : G, ∃! x : S × T, x.1.1 * x.2.1 = g := Function.bijective_iff_existsUnique _ #align subgroup.is_complement_iff_exists_unique Subgroup.isComplement_iff_existsUnique #align add_subgroup.is_complement_iff_exists_unique AddSubgroup.isComplement_iff_existsUnique @[to_additive] theorem IsComplement.existsUnique (h : IsComplement S T) (g : G) : ∃! x : S × T, x.1.1 * x.2.1 = g := isComplement_iff_existsUnique.mp h g #align subgroup.is_complement.exists_unique Subgroup.IsComplement.existsUnique #align add_subgroup.is_complement.exists_unique AddSubgroup.IsComplement.existsUnique @[to_additive] theorem IsComplement'.symm (h : IsComplement' H K) : IsComplement' K H := by let ϕ : H × K ≃ K × H := Equiv.mk (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => Prod.ext (inv_inv _) (inv_inv _)) fun x => Prod.ext (inv_inv _) (inv_inv _) let ψ : G ≃ G := Equiv.mk (fun g : G => g⁻¹) (fun g : G => g⁻¹) inv_inv inv_inv suffices hf : (ψ ∘ fun x : H × K => x.1.1 * x.2.1) = (fun x : K × H => x.1.1 * x.2.1) ∘ ϕ by rw [isComplement'_def, IsComplement, ← Equiv.bijective_comp ϕ] apply (congr_arg Function.Bijective hf).mp -- Porting note: This was a `rw` in mathlib3 rwa [ψ.comp_bijective] exact funext fun x => mul_inv_rev _ _ #align subgroup.is_complement'.symm Subgroup.IsComplement'.symm #align add_subgroup.is_complement'.symm AddSubgroup.IsComplement'.symm @[to_additive] theorem isComplement'_comm : IsComplement' H K ↔ IsComplement' K H := ⟨IsComplement'.symm, IsComplement'.symm⟩ #align subgroup.is_complement'_comm Subgroup.isComplement'_comm #align add_subgroup.is_complement'_comm AddSubgroup.isComplement'_comm @[to_additive] theorem isComplement_univ_singleton {g : G} : IsComplement (univ : Set G) {g} := ⟨fun ⟨_, _, rfl⟩ ⟨_, _, rfl⟩ h => Prod.ext (Subtype.ext (mul_right_cancel h)) rfl, fun x => ⟨⟨⟨x * g⁻¹, ⟨⟩⟩, g, rfl⟩, inv_mul_cancel_right x g⟩⟩ #align subgroup.is_complement_top_singleton Subgroup.isComplement_univ_singleton #align add_subgroup.is_complement_top_singleton AddSubgroup.isComplement_univ_singleton @[to_additive] theorem isComplement_singleton_univ {g : G} : IsComplement ({g} : Set G) univ := ⟨fun ⟨⟨_, rfl⟩, _⟩ ⟨⟨_, rfl⟩, _⟩ h => Prod.ext rfl (Subtype.ext (mul_left_cancel h)), fun x => ⟨⟨⟨g, rfl⟩, g⁻¹ * x, ⟨⟩⟩, mul_inv_cancel_left g x⟩⟩ #align subgroup.is_complement_singleton_top Subgroup.isComplement_singleton_univ #align add_subgroup.is_complement_singleton_top AddSubgroup.isComplement_singleton_univ @[to_additive] theorem isComplement_singleton_left {g : G} : IsComplement {g} S ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => (congr_arg _ h).mpr isComplement_singleton_univ⟩ obtain ⟨⟨⟨z, rfl : z = g⟩, y, _⟩, hy⟩ := h.2 (g * x) rwa [← mul_left_cancel hy] #align subgroup.is_complement_singleton_left Subgroup.isComplement_singleton_left #align add_subgroup.is_complement_singleton_left AddSubgroup.isComplement_singleton_left @[to_additive] theorem isComplement_singleton_right {g : G} : IsComplement S {g} ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => h ▸ isComplement_univ_singleton⟩ obtain ⟨y, hy⟩ := h.2 (x * g) conv_rhs at hy => rw [← show y.2.1 = g from y.2.2] rw [← mul_right_cancel hy] exact y.1.2 #align subgroup.is_complement_singleton_right Subgroup.isComplement_singleton_right #align add_subgroup.is_complement_singleton_right AddSubgroup.isComplement_singleton_right @[to_additive] theorem isComplement_univ_left : IsComplement univ S ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.2.1, a.2.2⟩ · have : (⟨⟨_, mem_top a⁻¹⟩, ⟨a, ha⟩⟩ : (⊤ : Set G) × S) = ⟨⟨_, mem_top b⁻¹⟩, ⟨b, hb⟩⟩ := h.1 ((inv_mul_self a).trans (inv_mul_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).2 · rintro ⟨g, rfl⟩ exact isComplement_univ_singleton #align subgroup.is_complement_top_left Subgroup.isComplement_univ_left #align add_subgroup.is_complement_top_left AddSubgroup.isComplement_univ_left @[to_additive] theorem isComplement_univ_right : IsComplement S univ ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.1.1, a.1.2⟩ · have : (⟨⟨a, ha⟩, ⟨_, mem_top a⁻¹⟩⟩ : S × (⊤ : Set G)) = ⟨⟨b, hb⟩, ⟨_, mem_top b⁻¹⟩⟩ := h.1 ((mul_inv_self a).trans (mul_inv_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).1 · rintro ⟨g, rfl⟩ exact isComplement_singleton_univ #align subgroup.is_complement_top_right Subgroup.isComplement_univ_right #align add_subgroup.is_complement_top_right AddSubgroup.isComplement_univ_right @[to_additive] lemma IsComplement.mul_eq (h : IsComplement S T) : S * T = univ := eq_univ_of_forall fun x ↦ by simpa [mem_mul] using (h.existsUnique x).exists @[to_additive AddSubgroup.IsComplement.card_mul_card] lemma IsComplement.card_mul_card (h : IsComplement S T) : Nat.card S * Nat.card T = Nat.card G := (Nat.card_prod _ _).symm.trans <| Nat.card_congr <| Equiv.ofBijective _ h @[to_additive] theorem isComplement'_top_bot : IsComplement' (⊤ : Subgroup G) ⊥ := isComplement_univ_singleton #align subgroup.is_complement'_top_bot Subgroup.isComplement'_top_bot #align add_subgroup.is_complement'_top_bot AddSubgroup.isComplement'_top_bot @[to_additive] theorem isComplement'_bot_top : IsComplement' (⊥ : Subgroup G) ⊤ := isComplement_singleton_univ #align subgroup.is_complement'_bot_top Subgroup.isComplement'_bot_top #align add_subgroup.is_complement'_bot_top AddSubgroup.isComplement'_bot_top @[to_additive (attr := simp)] theorem isComplement'_bot_left : IsComplement' ⊥ H ↔ H = ⊤ := isComplement_singleton_left.trans coe_eq_univ #align subgroup.is_complement'_bot_left Subgroup.isComplement'_bot_left #align add_subgroup.is_complement'_bot_left AddSubgroup.isComplement'_bot_left @[to_additive (attr := simp)] theorem isComplement'_bot_right : IsComplement' H ⊥ ↔ H = ⊤ := isComplement_singleton_right.trans coe_eq_univ #align subgroup.is_complement'_bot_right Subgroup.isComplement'_bot_right #align add_subgroup.is_complement'_bot_right AddSubgroup.isComplement'_bot_right @[to_additive (attr := simp)] theorem isComplement'_top_left : IsComplement' ⊤ H ↔ H = ⊥ := isComplement_univ_left.trans coe_eq_singleton #align subgroup.is_complement'_top_left Subgroup.isComplement'_top_left #align add_subgroup.is_complement'_top_left AddSubgroup.isComplement'_top_left @[to_additive (attr := simp)] theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ := isComplement_univ_right.trans coe_eq_singleton #align subgroup.is_complement'_top_right Subgroup.isComplement'_top_right #align add_subgroup.is_complement'_top_right AddSubgroup.isComplement'_top_right @[to_additive] theorem mem_leftTransversals_iff_existsUnique_inv_mul_mem : S ∈ leftTransversals T ↔ ∀ g : G, ∃! s : S, (s : G)⁻¹ * g ∈ T := by rw [leftTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.1, (congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq h1)).mp x.2.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨y, (↑y)⁻¹ * g, hy⟩ (mul_inv_cancel_left ↑y g))).1⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨x, (↑x)⁻¹ * g, h1⟩, mul_inv_cancel_left (↑x) g, fun y hy => ?_⟩ have hf := h2 y.1 ((congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq hy)).mp y.2.2) exact Prod.ext hf (Subtype.ext (eq_inv_mul_of_mul_eq (hf ▸ hy))) #align subgroup.mem_left_transversals_iff_exists_unique_inv_mul_mem Subgroup.mem_leftTransversals_iff_existsUnique_inv_mul_mem #align add_subgroup.mem_left_transversals_iff_exists_unique_neg_add_mem AddSubgroup.mem_leftTransversals_iff_existsUnique_neg_add_mem @[to_additive] theorem mem_rightTransversals_iff_existsUnique_mul_inv_mem : S ∈ rightTransversals T ↔ ∀ g : G, ∃! s : S, g * (s : G)⁻¹ ∈ T := by rw [rightTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.2, (congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq h1)).mp x.1.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨⟨g * (↑y)⁻¹, hy⟩, y⟩ (inv_mul_cancel_right g y))).2⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨⟨g * (↑x)⁻¹, h1⟩, x⟩, inv_mul_cancel_right g x, fun y hy => ?_⟩ have hf := h2 y.2 ((congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq hy)).mp y.1.2) exact Prod.ext (Subtype.ext (eq_mul_inv_of_mul_eq (hf ▸ hy))) hf #align subgroup.mem_right_transversals_iff_exists_unique_mul_inv_mem Subgroup.mem_rightTransversals_iff_existsUnique_mul_inv_mem #align add_subgroup.mem_right_transversals_iff_exists_unique_add_neg_mem AddSubgroup.mem_rightTransversals_iff_existsUnique_add_neg_mem @[to_additive] theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ leftTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ← QuotientGroup.eq'] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩ #align subgroup.mem_left_transversals_iff_exists_unique_quotient_mk'_eq Subgroup.mem_leftTransversals_iff_existsUnique_quotient_mk''_eq #align add_subgroup.mem_left_transversals_iff_exists_unique_quotient_mk'_eq AddSubgroup.mem_leftTransversals_iff_existsUnique_quotient_mk''_eq @[to_additive] theorem mem_rightTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ rightTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.rightRel H), ∃! s : S, Quotient.mk'' s.1 = q := by simp_rw [mem_rightTransversals_iff_existsUnique_mul_inv_mem, SetLike.mem_coe, ← QuotientGroup.rightRel_apply, ← Quotient.eq''] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩ #align subgroup.mem_right_transversals_iff_exists_unique_quotient_mk'_eq Subgroup.mem_rightTransversals_iff_existsUnique_quotient_mk''_eq #align add_subgroup.mem_right_transversals_iff_exists_unique_quotient_mk'_eq AddSubgroup.mem_rightTransversals_iff_existsUnique_quotient_mk''_eq @[to_additive] theorem mem_leftTransversals_iff_bijective : S ∈ leftTransversals (H : Set G) ↔ Function.Bijective (S.restrict (Quotient.mk'' : G → Quotient (QuotientGroup.leftRel H))) := mem_leftTransversals_iff_existsUnique_quotient_mk''_eq.trans (Function.bijective_iff_existsUnique (S.restrict Quotient.mk'')).symm #align subgroup.mem_left_transversals_iff_bijective Subgroup.mem_leftTransversals_iff_bijective #align add_subgroup.mem_left_transversals_iff_bijective AddSubgroup.mem_leftTransversals_iff_bijective @[to_additive] theorem mem_rightTransversals_iff_bijective : S ∈ rightTransversals (H : Set G) ↔ Function.Bijective (S.restrict (Quotient.mk'' : G → Quotient (QuotientGroup.rightRel H))) := mem_rightTransversals_iff_existsUnique_quotient_mk''_eq.trans (Function.bijective_iff_existsUnique (S.restrict Quotient.mk'')).symm #align subgroup.mem_right_transversals_iff_bijective Subgroup.mem_rightTransversals_iff_bijective #align add_subgroup.mem_right_transversals_iff_bijective AddSubgroup.mem_rightTransversals_iff_bijective @[to_additive] theorem card_left_transversal (h : S ∈ leftTransversals (H : Set G)) : Nat.card S = H.index := Nat.card_congr <| Equiv.ofBijective _ <| mem_leftTransversals_iff_bijective.mp h #align subgroup.card_left_transversal Subgroup.card_left_transversal #align add_subgroup.card_left_transversal AddSubgroup.card_left_transversal @[to_additive] theorem card_right_transversal (h : S ∈ rightTransversals (H : Set G)) : Nat.card S = H.index := Nat.card_congr <| (Equiv.ofBijective _ <| mem_rightTransversals_iff_bijective.mp h).trans <| QuotientGroup.quotientRightRelEquivQuotientLeftRel H #align subgroup.card_right_transversal Subgroup.card_right_transversal #align add_subgroup.card_right_transversal AddSubgroup.card_right_transversal @[to_additive] theorem range_mem_leftTransversals {f : G ⧸ H → G} (hf : ∀ q, ↑(f q) = q) : Set.range f ∈ leftTransversals (H : Set G) := mem_leftTransversals_iff_bijective.mpr ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂), fun q => ⟨⟨f q, q, rfl⟩, hf q⟩⟩ #align subgroup.range_mem_left_transversals Subgroup.range_mem_leftTransversals #align add_subgroup.range_mem_left_transversals AddSubgroup.range_mem_leftTransversals @[to_additive] theorem range_mem_rightTransversals {f : Quotient (QuotientGroup.rightRel H) → G} (hf : ∀ q, Quotient.mk'' (f q) = q) : Set.range f ∈ rightTransversals (H : Set G) := mem_rightTransversals_iff_bijective.mpr ⟨by rintro ⟨-, q₁, rfl⟩ ⟨-, q₂, rfl⟩ h exact Subtype.ext <| congr_arg f <| ((hf q₁).symm.trans h).trans (hf q₂), fun q => ⟨⟨f q, q, rfl⟩, hf q⟩⟩ #align subgroup.range_mem_right_transversals Subgroup.range_mem_rightTransversals #align add_subgroup.range_mem_right_transversals AddSubgroup.range_mem_rightTransversals @[to_additive] lemma exists_left_transversal (H : Subgroup G) (g : G) : ∃ S ∈ leftTransversals (H : Set G), g ∈ S := by classical refine ⟨Set.range (Function.update Quotient.out' _ g), range_mem_leftTransversals fun q => ?_, Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩ by_cases hq : q = Quotient.mk'' g · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out') · refine (Function.update_noteq ?_ g Quotient.out') ▸ q.out_eq' exact hq #align subgroup.exists_left_transversal Subgroup.exists_left_transversal #align add_subgroup.exists_left_transversal AddSubgroup.exists_left_transversal @[to_additive] lemma exists_right_transversal (H : Subgroup G) (g : G) : ∃ S ∈ rightTransversals (H : Set G), g ∈ S := by classical refine ⟨Set.range (Function.update Quotient.out' _ g), range_mem_rightTransversals fun q => ?_, Quotient.mk'' g, Function.update_same (Quotient.mk'' g) g Quotient.out'⟩ by_cases hq : q = Quotient.mk'' g · exact hq.symm ▸ congr_arg _ (Function.update_same (Quotient.mk'' g) g Quotient.out') · exact Eq.trans (congr_arg _ (Function.update_noteq hq g Quotient.out')) q.out_eq' #align subgroup.exists_right_transversal Subgroup.exists_right_transversal #align add_subgroup.exists_right_transversal AddSubgroup.exists_right_transversal @[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"] lemma exists_left_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) : ∃ S : Set G, S * H' = H ∧ Nat.card S * Nat.card H' = Nat.card H := by let H'' : Subgroup H := H'.comap H.subtype have : H' = H''.map H.subtype := by simp [H'', h] rw [this] obtain ⟨S, cmem, -⟩ := H''.exists_left_transversal 1 refine ⟨H.subtype '' S, ?_, ?_⟩ · have : H.subtype '' (S * H'') = H.subtype '' S * H''.map H.subtype := image_mul H.subtype rw [← this, cmem.mul_eq] simp [Set.ext_iff] · rw [← cmem.card_mul_card] refine congr_arg₂ (· * ·) ?_ ?_ <;> exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm @[to_additive "Given two subgroups `H' ⊆ H`, there exists a transversal to `H'` inside `H`"] lemma exists_right_transversal_of_le {H' H : Subgroup G} (h : H' ≤ H) : ∃ S : Set G, H' * S = H ∧ Nat.card H' * Nat.card S = Nat.card H := by let H'' : Subgroup H := H'.comap H.subtype have : H' = H''.map H.subtype := by simp [H'', h] rw [this] obtain ⟨S, cmem, -⟩ := H''.exists_right_transversal 1 refine ⟨H.subtype '' S, ?_, ?_⟩ · have : H.subtype '' (H'' * S) = H''.map H.subtype * H.subtype '' S := image_mul H.subtype rw [← this, cmem.mul_eq] simp [Set.ext_iff] · have : Nat.card H'' * Nat.card S = Nat.card H := cmem.card_mul_card rw [← this] refine congr_arg₂ (· * ·) ?_ ?_ <;> exact Nat.card_congr (Equiv.Set.image _ _ <| subtype_injective H).symm namespace IsComplement noncomputable def equiv {S T : Set G} (hST : IsComplement S T) : G ≃ S × T := (Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).symm variable (hST : IsComplement S T) (hHT : IsComplement H T) (hSK : IsComplement S K) @[simp] theorem equiv_symm_apply (x : S × T) : (hST.equiv.symm x : G) = x.1.1 * x.2.1 := rfl @[simp] theorem equiv_fst_mul_equiv_snd (g : G) : ↑(hST.equiv g).fst * (hST.equiv g).snd = g := (Equiv.ofBijective (fun x : S × T => x.1.1 * x.2.1) hST).right_inv g theorem equiv_fst_eq_mul_inv (g : G) : ↑(hST.equiv g).fst = g * ((hST.equiv g).snd : G)⁻¹ := eq_mul_inv_of_mul_eq (hST.equiv_fst_mul_equiv_snd g) theorem equiv_snd_eq_inv_mul (g : G) : ↑(hST.equiv g).snd = ((hST.equiv g).fst : G)⁻¹ * g := eq_inv_mul_of_mul_eq (hST.equiv_fst_mul_equiv_snd g) theorem equiv_fst_eq_iff_leftCosetEquivalence {g₁ g₂ : G} : (hSK.equiv g₁).fst = (hSK.equiv g₂).fst ↔ LeftCosetEquivalence K g₁ g₂ := by rw [LeftCosetEquivalence, leftCoset_eq_iff] constructor · intro h rw [← hSK.equiv_fst_mul_equiv_snd g₂, ← hSK.equiv_fst_mul_equiv_snd g₁, ← h, mul_inv_rev, ← mul_assoc, inv_mul_cancel_right, ← coe_inv, ← coe_mul] exact Subtype.property _ · intro h apply (mem_leftTransversals_iff_existsUnique_inv_mul_mem.1 hSK g₁).unique · -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp · rw [SetLike.mem_coe, ← mul_mem_cancel_right h] -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp [equiv_fst_eq_mul_inv, ← mul_assoc] theorem equiv_snd_eq_iff_rightCosetEquivalence {g₁ g₂ : G} : (hHT.equiv g₁).snd = (hHT.equiv g₂).snd ↔ RightCosetEquivalence H g₁ g₂ := by rw [RightCosetEquivalence, rightCoset_eq_iff] constructor · intro h rw [← hHT.equiv_fst_mul_equiv_snd g₂, ← hHT.equiv_fst_mul_equiv_snd g₁, ← h, mul_inv_rev, mul_assoc, mul_inv_cancel_left, ← coe_inv, ← coe_mul] exact Subtype.property _ · intro h apply (mem_rightTransversals_iff_existsUnique_mul_inv_mem.1 hHT g₁).unique · -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_snd_eq_inv_mul]; simp · rw [SetLike.mem_coe, ← mul_mem_cancel_left h] -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_snd_eq_inv_mul, mul_assoc]; simp theorem leftCosetEquivalence_equiv_fst (g : G) : LeftCosetEquivalence K g ((hSK.equiv g).fst : G) := by -- This used to be `simp [...]` before leanprover/lean4#2644 rw [equiv_fst_eq_mul_inv]; simp [LeftCosetEquivalence, leftCoset_eq_iff] theorem rightCosetEquivalence_equiv_snd (g : G) : RightCosetEquivalence H g ((hHT.equiv g).snd : G) := by -- This used to be `simp [...]` before leanprover/lean4#2644 rw [RightCosetEquivalence, rightCoset_eq_iff, equiv_snd_eq_inv_mul]; simp theorem equiv_fst_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) : (hST.equiv g).fst = ⟨g, hg⟩ := by have : hST.equiv.symm (⟨g, hg⟩, ⟨1, h1⟩) = g := by rw [equiv, Equiv.ofBijective]; simp conv_lhs => rw [← this, Equiv.apply_symm_apply] theorem equiv_snd_eq_self_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) : (hST.equiv g).snd = ⟨g, hg⟩ := by have : hST.equiv.symm (⟨1, h1⟩, ⟨g, hg⟩) = g := by rw [equiv, Equiv.ofBijective]; simp conv_lhs => rw [← this, Equiv.apply_symm_apply] theorem equiv_snd_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ T) (hg : g ∈ S) : (hST.equiv g).snd = ⟨1, h1⟩ := by ext rw [equiv_snd_eq_inv_mul, equiv_fst_eq_self_of_mem_of_one_mem _ h1 hg, inv_mul_self] theorem equiv_fst_eq_one_of_mem_of_one_mem {g : G} (h1 : 1 ∈ S) (hg : g ∈ T) : (hST.equiv g).fst = ⟨1, h1⟩ := by ext rw [equiv_fst_eq_mul_inv, equiv_snd_eq_self_of_mem_of_one_mem _ h1 hg, mul_inv_self] -- This lemma has always been bad, but the linter only noticed after lean4#2644. @[simp, nolint simpNF] theorem equiv_mul_right (g : G) (k : K) : hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * k) := by have : (hSK.equiv (g * k)).fst = (hSK.equiv g).fst := hSK.equiv_fst_eq_iff_leftCosetEquivalence.2 (by simp [LeftCosetEquivalence, leftCoset_eq_iff]) ext · rw [this] · rw [coe_mul, equiv_snd_eq_inv_mul, this, equiv_snd_eq_inv_mul, mul_assoc] theorem equiv_mul_right_of_mem {g k : G} (h : k ∈ K) : hSK.equiv (g * k) = ((hSK.equiv g).fst, (hSK.equiv g).snd * ⟨k, h⟩) := equiv_mul_right _ g ⟨k, h⟩ -- This lemma has always been bad, but the linter only noticed after lean4#2644. @[simp, nolint simpNF] theorem equiv_mul_left (h : H) (g : G) : hHT.equiv (h * g) = (h * (hHT.equiv g).fst, (hHT.equiv g).snd) := by have : (hHT.equiv (h * g)).2 = (hHT.equiv g).2 := hHT.equiv_snd_eq_iff_rightCosetEquivalence.2 ?_ · ext · rw [coe_mul, equiv_fst_eq_mul_inv, this, equiv_fst_eq_mul_inv, mul_assoc] · rw [this] · simp [RightCosetEquivalence, ← smul_smul] theorem equiv_mul_left_of_mem {h g : G} (hh : h ∈ H) : hHT.equiv (h * g) = (⟨h, hh⟩ * (hHT.equiv g).fst, (hHT.equiv g).snd) := equiv_mul_left _ ⟨h, hh⟩ g theorem equiv_one (hs1 : 1 ∈ S) (ht1 : 1 ∈ T) : hST.equiv 1 = (⟨1, hs1⟩, ⟨1, ht1⟩) := by rw [Equiv.apply_eq_iff_eq_symm_apply]; simp [equiv] theorem equiv_fst_eq_self_iff_mem {g : G} (h1 : 1 ∈ T) : ((hST.equiv g).fst : G) = g ↔ g ∈ S := by constructor · intro h rw [← h] exact Subtype.prop _ · intro h rw [hST.equiv_fst_eq_self_of_mem_of_one_mem h1 h]
Mathlib/GroupTheory/Complement.lean
505
512
theorem equiv_snd_eq_self_iff_mem {g : G} (h1 : 1 ∈ S) : ((hST.equiv g).snd : G) = g ↔ g ∈ T := by
constructor · intro h rw [← h] exact Subtype.prop _ · intro h rw [hST.equiv_snd_eq_self_of_mem_of_one_mem h1 h]
import Mathlib.RingTheory.Polynomial.Cyclotomic.Roots import Mathlib.Tactic.ByContra import Mathlib.Topology.Algebra.Polynomial import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Analysis.Complex.Arg #align_import ring_theory.polynomial.cyclotomic.eval from "leanprover-community/mathlib"@"5bfbcca0a7ffdd21cf1682e59106d6c942434a32" namespace Polynomial open Finset Nat @[simp]
Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
29
32
theorem eval_one_cyclotomic_prime {R : Type*} [CommRing R] {p : ℕ} [hn : Fact p.Prime] : eval 1 (cyclotomic p R) = p := by
simp only [cyclotomic_prime, eval_X, one_pow, Finset.sum_const, eval_pow, eval_finset_sum, Finset.card_range, smul_one_eq_cast]
import Mathlib.Analysis.Normed.Group.Basic #align_import information_theory.hamming from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" section HammingDistNorm open Finset Function variable {α ι : Type*} {β : ι → Type*} [Fintype ι] [∀ i, DecidableEq (β i)] variable {γ : ι → Type*} [∀ i, DecidableEq (γ i)] def hammingDist (x y : ∀ i, β i) : ℕ := (univ.filter fun i => x i ≠ y i).card #align hamming_dist hammingDist @[simp] theorem hammingDist_self (x : ∀ i, β i) : hammingDist x x = 0 := by rw [hammingDist, card_eq_zero, filter_eq_empty_iff] exact fun _ _ H => H rfl #align hamming_dist_self hammingDist_self theorem hammingDist_nonneg {x y : ∀ i, β i} : 0 ≤ hammingDist x y := zero_le _ #align hamming_dist_nonneg hammingDist_nonneg theorem hammingDist_comm (x y : ∀ i, β i) : hammingDist x y = hammingDist y x := by simp_rw [hammingDist, ne_comm] #align hamming_dist_comm hammingDist_comm theorem hammingDist_triangle (x y z : ∀ i, β i) : hammingDist x z ≤ hammingDist x y + hammingDist y z := by classical unfold hammingDist refine le_trans (card_mono ?_) (card_union_le _ _) rw [← filter_or] exact monotone_filter_right _ fun i h ↦ (h.ne_or_ne _).imp_right Ne.symm #align hamming_dist_triangle hammingDist_triangle theorem hammingDist_triangle_left (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist z x + hammingDist z y := by rw [hammingDist_comm z] exact hammingDist_triangle _ _ _ #align hamming_dist_triangle_left hammingDist_triangle_left
Mathlib/InformationTheory/Hamming.lean
78
81
theorem hammingDist_triangle_right (x y z : ∀ i, β i) : hammingDist x y ≤ hammingDist x z + hammingDist y z := by
rw [hammingDist_comm y] exact hammingDist_triangle _ _ _
import Mathlib.Topology.Sheaves.PUnit import Mathlib.Topology.Sheaves.Stalks import Mathlib.Topology.Sheaves.Functors #align_import topology.sheaves.skyscraper from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" noncomputable section open TopologicalSpace TopCat CategoryTheory CategoryTheory.Limits Opposite universe u v w variable {X : TopCat.{u}} (p₀ : X) [∀ U : Opens X, Decidable (p₀ ∈ U)] section variable {C : Type v} [Category.{w} C] [HasTerminal C] (A : C) @[simps] def skyscraperPresheaf : Presheaf C X where obj U := if p₀ ∈ unop U then A else terminal C map {U V} i := if h : p₀ ∈ unop V then eqToHom <| by dsimp; erw [if_pos h, if_pos (leOfHom i.unop h)] else ((if_neg h).symm.ndrec terminalIsTerminal).from _ map_id U := (em (p₀ ∈ U.unop)).elim (fun h => dif_pos h) fun h => ((if_neg h).symm.ndrec terminalIsTerminal).hom_ext _ _ map_comp {U V W} iVU iWV := by by_cases hW : p₀ ∈ unop W · have hV : p₀ ∈ unop V := leOfHom iWV.unop hW simp only [dif_pos hW, dif_pos hV, eqToHom_trans] · dsimp; rw [dif_neg hW]; apply ((if_neg hW).symm.ndrec terminalIsTerminal).hom_ext #align skyscraper_presheaf skyscraperPresheaf theorem skyscraperPresheaf_eq_pushforward [hd : ∀ U : Opens (TopCat.of PUnit.{u + 1}), Decidable (PUnit.unit ∈ U)] : skyscraperPresheaf p₀ A = ContinuousMap.const (TopCat.of PUnit) p₀ _* skyscraperPresheaf (X := TopCat.of PUnit) PUnit.unit A := by convert_to @skyscraperPresheaf X p₀ (fun U => hd <| (Opens.map <| ContinuousMap.const _ p₀).obj U) C _ _ A = _ <;> congr #align skyscraper_presheaf_eq_pushforward skyscraperPresheaf_eq_pushforward @[simps] def SkyscraperPresheafFunctor.map' {a b : C} (f : a ⟶ b) : skyscraperPresheaf p₀ a ⟶ skyscraperPresheaf p₀ b where app U := if h : p₀ ∈ U.unop then eqToHom (if_pos h) ≫ f ≫ eqToHom (if_pos h).symm else ((if_neg h).symm.ndrec terminalIsTerminal).from _ naturality U V i := by simp only [skyscraperPresheaf_map]; by_cases hV : p₀ ∈ V.unop · have hU : p₀ ∈ U.unop := leOfHom i.unop hV; split_ifs <;> simp only [eqToHom_trans_assoc, Category.assoc, eqToHom_trans] · apply ((if_neg hV).symm.ndrec terminalIsTerminal).hom_ext #align skyscraper_presheaf_functor.map' SkyscraperPresheafFunctor.map' theorem SkyscraperPresheafFunctor.map'_id {a : C} : SkyscraperPresheafFunctor.map' p₀ (𝟙 a) = 𝟙 _ := by ext U simp only [SkyscraperPresheafFunctor.map'_app, NatTrans.id_app]; split_ifs <;> aesop_cat #align skyscraper_presheaf_functor.map'_id SkyscraperPresheafFunctor.map'_id theorem SkyscraperPresheafFunctor.map'_comp {a b c : C} (f : a ⟶ b) (g : b ⟶ c) : SkyscraperPresheafFunctor.map' p₀ (f ≫ g) = SkyscraperPresheafFunctor.map' p₀ f ≫ SkyscraperPresheafFunctor.map' p₀ g := by ext U -- Porting note: change `simp` to `rw` rw [NatTrans.comp_app] simp only [SkyscraperPresheafFunctor.map'_app] split_ifs with h <;> aesop_cat #align skyscraper_presheaf_functor.map'_comp SkyscraperPresheafFunctor.map'_comp @[simps] def skyscraperPresheafFunctor : C ⥤ Presheaf C X where obj := skyscraperPresheaf p₀ map := SkyscraperPresheafFunctor.map' p₀ map_id _ := SkyscraperPresheafFunctor.map'_id p₀ map_comp := SkyscraperPresheafFunctor.map'_comp p₀ #align skyscraper_presheaf_functor skyscraperPresheafFunctor end section -- In this section, we calculate the stalks for skyscraper presheaves. -- We need to restrict universe level. variable {C : Type v} [Category.{u} C] (A : C) [HasTerminal C] @[simps] def skyscraperPresheafCoconeOfSpecializes {y : X} (h : p₀ ⤳ y) : Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where pt := A ι := { app := fun U => eqToHom <| if_pos <| h.mem_open U.unop.1.2 U.unop.2 naturality := fun U V inc => by change dite _ _ _ ≫ _ = _; rw [dif_pos] swap -- Porting note: swap goal to prevent proving same thing twice · exact h.mem_open V.unop.1.2 V.unop.2 · simp only [Functor.comp_obj, Functor.op_obj, skyscraperPresheaf_obj, unop_op, Functor.const_obj_obj, eqToHom_trans, Functor.const_obj_map, Category.comp_id] } #align skyscraper_presheaf_cocone_of_specializes skyscraperPresheafCoconeOfSpecializes noncomputable def skyscraperPresheafCoconeIsColimitOfSpecializes {y : X} (h : p₀ ⤳ y) : IsColimit (skyscraperPresheafCoconeOfSpecializes p₀ A h) where desc c := eqToHom (if_pos trivial).symm ≫ c.ι.app (op ⊤) fac c U := by dsimp -- Porting note (#11227):added a `dsimp` rw [← c.w (homOfLE <| (le_top : unop U ≤ _)).op] change _ ≫ _ ≫ dite _ _ _ ≫ _ = _ rw [dif_pos] · simp only [skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp, unop_op, op_unop] · exact h.mem_open U.unop.1.2 U.unop.2 uniq c f h := by dsimp -- Porting note (#11227):added a `dsimp` rw [← h, skyscraperPresheafCoconeOfSpecializes_ι_app, eqToHom_trans_assoc, eqToHom_refl, Category.id_comp] #align skyscraper_presheaf_cocone_is_colimit_of_specializes skyscraperPresheafCoconeIsColimitOfSpecializes noncomputable def skyscraperPresheafStalkOfSpecializes [HasColimits C] {y : X} (h : p₀ ⤳ y) : (skyscraperPresheaf p₀ A).stalk y ≅ A := colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfSpecializes p₀ A h⟩ #align skyscraper_presheaf_stalk_of_specializes skyscraperPresheafStalkOfSpecializes @[simps] def skyscraperPresheafCocone (y : X) : Cocone ((OpenNhds.inclusion y).op ⋙ skyscraperPresheaf p₀ A) where pt := terminal C ι := { app := fun _ => terminal.from _ naturality := fun _ _ _ => terminalIsTerminal.hom_ext _ _ } #align skyscraper_presheaf_cocone skyscraperPresheafCocone noncomputable def skyscraperPresheafCoconeIsColimitOfNotSpecializes {y : X} (h : ¬p₀ ⤳ y) : IsColimit (skyscraperPresheafCocone p₀ A y) := let h1 : ∃ U : OpenNhds y, p₀ ∉ U.1 := let ⟨U, ho, h₀, hy⟩ := not_specializes_iff_exists_open.mp h ⟨⟨⟨U, ho⟩, h₀⟩, hy⟩ { desc := fun c => eqToHom (if_neg h1.choose_spec).symm ≫ c.ι.app (op h1.choose) fac := fun c U => by change _ = c.ι.app (op U.unop) simp only [← c.w (homOfLE <| @inf_le_left _ _ h1.choose U.unop).op, ← c.w (homOfLE <| @inf_le_right _ _ h1.choose U.unop).op, ← Category.assoc] congr 1 refine ((if_neg ?_).symm.ndrec terminalIsTerminal).hom_ext _ _ exact fun h => h1.choose_spec h.1 uniq := fun c f H => by dsimp -- Porting note (#11227):added a `dsimp` rw [← Category.id_comp f, ← H, ← Category.assoc] congr 1; apply terminalIsTerminal.hom_ext } #align skyscraper_presheaf_cocone_is_colimit_of_not_specializes skyscraperPresheafCoconeIsColimitOfNotSpecializes noncomputable def skyscraperPresheafStalkOfNotSpecializes [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) : (skyscraperPresheaf p₀ A).stalk y ≅ terminal C := colimit.isoColimitCocone ⟨_, skyscraperPresheafCoconeIsColimitOfNotSpecializes _ A h⟩ #align skyscraper_presheaf_stalk_of_not_specializes skyscraperPresheafStalkOfNotSpecializes def skyscraperPresheafStalkOfNotSpecializesIsTerminal [HasColimits C] {y : X} (h : ¬p₀ ⤳ y) : IsTerminal ((skyscraperPresheaf p₀ A).stalk y) := IsTerminal.ofIso terminalIsTerminal <| (skyscraperPresheafStalkOfNotSpecializes _ _ h).symm #align skyscraper_presheaf_stalk_of_not_specializes_is_terminal skyscraperPresheafStalkOfNotSpecializesIsTerminal
Mathlib/Topology/Sheaves/Skyscraper.lean
223
233
theorem skyscraperPresheaf_isSheaf : (skyscraperPresheaf p₀ A).IsSheaf := by
classical exact (Presheaf.isSheaf_iso_iff (eqToIso <| skyscraperPresheaf_eq_pushforward p₀ A)).mpr <| (Sheaf.pushforward_sheaf_of_sheaf _ (Presheaf.isSheaf_on_punit_of_isTerminal _ (by dsimp [skyscraperPresheaf] rw [if_neg] · exact terminalIsTerminal · #adaptation_note /-- 2024-03-24 Previously the universe annotation was not needed here. -/ exact Set.not_mem_empty PUnit.unit.{u+1})))
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals import Mathlib.Analysis.Calculus.ParametricIntegral import Mathlib.MeasureTheory.Measure.Haar.NormedSpace #align_import analysis.mellin_transform from "leanprover-community/mathlib"@"917c3c072e487b3cccdbfeff17e75b40e45f66cb" open MeasureTheory Set Filter Asymptotics TopologicalSpace open Real open Complex hiding exp log abs_of_nonneg open scoped Topology noncomputable section section Defs variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop := IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0) #align mellin_convergent MellinConvergent
Mathlib/Analysis/MellinTransform.lean
47
50
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) : MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α} (h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) : Tendsto (fun _ : β => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [TopologicalSpace β] {s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = (⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓ ⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)] (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : 𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : (𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := h₀.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) : map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι) (s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)} (I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} : f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β} (hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α} (f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α} {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (¬ P ·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt
Mathlib/Topology/ContinuousOn.lean
528
530
theorem continuousWithinAt_univ (f : α → β) (x : α) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by
rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
import Mathlib.MeasureTheory.Function.ConditionalExpectation.Basic #align_import measure_theory.function.conditional_expectation.indicator from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open TopologicalSpace MeasureTheory.Lp Filter ContinuousLinearMap open scoped NNReal ENNReal Topology MeasureTheory namespace MeasureTheory variable {α 𝕜 E : Type*} {m m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] {μ : Measure α} {f : α → E} {s : Set α} theorem condexp_ae_eq_restrict_zero (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict s] 0) : μ[f|m] =ᵐ[μ.restrict s] 0 := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm]; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm]; rfl haveI : SigmaFinite (μ.trim hm) := hμm have : SigmaFinite ((μ.restrict s).trim hm) := by rw [← restrict_trim hm _ hs] exact Restrict.sigmaFinite _ s by_cases hf_int : Integrable f μ swap; · rw [condexp_undef hf_int] refine ae_eq_of_forall_setIntegral_eq_of_sigmaFinite' hm ?_ ?_ ?_ ?_ ?_ · exact fun t _ _ => integrable_condexp.integrableOn.integrableOn · exact fun t _ _ => (integrable_zero _ _ _).integrableOn · intro t ht _ rw [Measure.restrict_restrict (hm _ ht), setIntegral_condexp hm hf_int (ht.inter hs), ← Measure.restrict_restrict (hm _ ht)] refine setIntegral_congr_ae (hm _ ht) ?_ filter_upwards [hf] with x hx _ using hx · exact stronglyMeasurable_condexp.aeStronglyMeasurable' · exact stronglyMeasurable_zero.aeStronglyMeasurable' #align measure_theory.condexp_ae_eq_restrict_zero MeasureTheory.condexp_ae_eq_restrict_zero theorem condexp_indicator_aux (hs : MeasurableSet[m] s) (hf : f =ᵐ[μ.restrict sᶜ] 0) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm, Set.indicator_zero']; rfl have hsf_zero : ∀ g : α → E, g =ᵐ[μ.restrict sᶜ] 0 → s.indicator g =ᵐ[μ] g := fun g => indicator_ae_eq_of_restrict_compl_ae_eq_zero (hm _ hs) refine ((hsf_zero (μ[f|m]) (condexp_ae_eq_restrict_zero hs.compl hf)).trans ?_).symm exact condexp_congr_ae (hsf_zero f hf).symm #align measure_theory.condexp_indicator_aux MeasureTheory.condexp_indicator_aux
Mathlib/MeasureTheory/Function/ConditionalExpectation/Indicator.lean
75
112
theorem condexp_indicator (hf_int : Integrable f μ) (hs : MeasurableSet[m] s) : μ[s.indicator f|m] =ᵐ[μ] s.indicator (μ[f|m]) := by
by_cases hm : m ≤ m0 swap; · simp_rw [condexp_of_not_le hm, Set.indicator_zero']; rfl by_cases hμm : SigmaFinite (μ.trim hm) swap; · simp_rw [condexp_of_not_sigmaFinite hm hμm, Set.indicator_zero']; rfl haveI : SigmaFinite (μ.trim hm) := hμm -- use `have` to perform what should be the first calc step because of an error I don't -- understand have : s.indicator (μ[f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) := by rw [Set.indicator_self_add_compl s f] refine (this.trans ?_).symm calc s.indicator (μ[s.indicator f + sᶜ.indicator f|m]) =ᵐ[μ] s.indicator (μ[s.indicator f|m] + μ[sᶜ.indicator f|m]) := by have : μ[s.indicator f + sᶜ.indicator f|m] =ᵐ[μ] μ[s.indicator f|m] + μ[sᶜ.indicator f|m] := condexp_add (hf_int.indicator (hm _ hs)) (hf_int.indicator (hm _ hs.compl)) filter_upwards [this] with x hx classical rw [Set.indicator_apply, Set.indicator_apply, hx] _ = s.indicator (μ[s.indicator f|m]) + s.indicator (μ[sᶜ.indicator f|m]) := (s.indicator_add' _ _) _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) + s.indicator (sᶜ.indicator (μ[sᶜ.indicator f|m])) := by refine Filter.EventuallyEq.rfl.add ?_ have : sᶜ.indicator (μ[sᶜ.indicator f|m]) =ᵐ[μ] μ[sᶜ.indicator f|m] := by refine (condexp_indicator_aux hs.compl ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs.compl) · rw [Set.indicator_indicator, Set.inter_self] filter_upwards [this] with x hx by_cases hxs : x ∈ s · simp only [hx, hxs, Set.indicator_of_mem] · simp only [hxs, Set.indicator_of_not_mem, not_false_iff] _ =ᵐ[μ] s.indicator (μ[s.indicator f|m]) := by rw [Set.indicator_indicator, Set.inter_compl_self, Set.indicator_empty', add_zero] _ =ᵐ[μ] μ[s.indicator f|m] := by refine (condexp_indicator_aux hs ?_).symm.trans ?_ · exact indicator_ae_eq_restrict_compl (hm _ hs) · rw [Set.indicator_indicator, Set.inter_self]
import Mathlib.Algebra.Field.Basic import Mathlib.Algebra.GroupWithZero.Units.Equiv import Mathlib.Algebra.Order.Field.Defs import Mathlib.Algebra.Order.Ring.Abs import Mathlib.Order.Bounds.OrderIso import Mathlib.Tactic.Positivity.Core #align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd" open Function OrderDual variable {ι α β : Type*} section LinearOrderedSemifield variable [LinearOrderedSemifield α] {a b c d e : α} {m n : ℤ} @[simps! (config := { simpRhs := true })] def OrderIso.mulLeft₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulLeft₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_left ha } #align order_iso.mul_left₀ OrderIso.mulLeft₀ #align order_iso.mul_left₀_symm_apply OrderIso.mulLeft₀_symm_apply #align order_iso.mul_left₀_apply OrderIso.mulLeft₀_apply @[simps! (config := { simpRhs := true })] def OrderIso.mulRight₀ (a : α) (ha : 0 < a) : α ≃o α := { Equiv.mulRight₀ a ha.ne' with map_rel_iff' := @fun _ _ => mul_le_mul_right ha } #align order_iso.mul_right₀ OrderIso.mulRight₀ #align order_iso.mul_right₀_symm_apply OrderIso.mulRight₀_symm_apply #align order_iso.mul_right₀_apply OrderIso.mulRight₀_apply theorem le_div_iff (hc : 0 < c) : a ≤ b / c ↔ a * c ≤ b := ⟨fun h => div_mul_cancel₀ b (ne_of_lt hc).symm ▸ mul_le_mul_of_nonneg_right h hc.le, fun h => calc a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc).symm _ ≤ b * (1 / c) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hc).le _ = b / c := (div_eq_mul_one_div b c).symm ⟩ #align le_div_iff le_div_iff theorem le_div_iff' (hc : 0 < c) : a ≤ b / c ↔ c * a ≤ b := by rw [mul_comm, le_div_iff hc] #align le_div_iff' le_div_iff' theorem div_le_iff (hb : 0 < b) : a / b ≤ c ↔ a ≤ c * b := ⟨fun h => calc a = a / b * b := by rw [div_mul_cancel₀ _ (ne_of_lt hb).symm] _ ≤ c * b := mul_le_mul_of_nonneg_right h hb.le , fun h => calc a / b = a * (1 / b) := div_eq_mul_one_div a b _ ≤ c * b * (1 / b) := mul_le_mul_of_nonneg_right h (one_div_pos.2 hb).le _ = c * b / b := (div_eq_mul_one_div (c * b) b).symm _ = c := by refine (div_eq_iff (ne_of_gt hb)).mpr rfl ⟩ #align div_le_iff div_le_iff theorem div_le_iff' (hb : 0 < b) : a / b ≤ c ↔ a ≤ b * c := by rw [mul_comm, div_le_iff hb] #align div_le_iff' div_le_iff' lemma div_le_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b ≤ c ↔ a / c ≤ b := by rw [div_le_iff hb, div_le_iff' hc] theorem lt_div_iff (hc : 0 < c) : a < b / c ↔ a * c < b := lt_iff_lt_of_le_iff_le <| div_le_iff hc #align lt_div_iff lt_div_iff theorem lt_div_iff' (hc : 0 < c) : a < b / c ↔ c * a < b := by rw [mul_comm, lt_div_iff hc] #align lt_div_iff' lt_div_iff' theorem div_lt_iff (hc : 0 < c) : b / c < a ↔ b < a * c := lt_iff_lt_of_le_iff_le (le_div_iff hc) #align div_lt_iff div_lt_iff theorem div_lt_iff' (hc : 0 < c) : b / c < a ↔ b < c * a := by rw [mul_comm, div_lt_iff hc] #align div_lt_iff' div_lt_iff' lemma div_lt_comm₀ (hb : 0 < b) (hc : 0 < c) : a / b < c ↔ a / c < b := by rw [div_lt_iff hb, div_lt_iff' hc] theorem inv_mul_le_iff (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_le_iff' h #align inv_mul_le_iff inv_mul_le_iff theorem inv_mul_le_iff' (h : 0 < b) : b⁻¹ * a ≤ c ↔ a ≤ c * b := by rw [inv_mul_le_iff h, mul_comm] #align inv_mul_le_iff' inv_mul_le_iff' theorem mul_inv_le_iff (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ b * c := by rw [mul_comm, inv_mul_le_iff h] #align mul_inv_le_iff mul_inv_le_iff theorem mul_inv_le_iff' (h : 0 < b) : a * b⁻¹ ≤ c ↔ a ≤ c * b := by rw [mul_comm, inv_mul_le_iff' h] #align mul_inv_le_iff' mul_inv_le_iff' theorem div_self_le_one (a : α) : a / a ≤ 1 := if h : a = 0 then by simp [h] else by simp [h] #align div_self_le_one div_self_le_one theorem inv_mul_lt_iff (h : 0 < b) : b⁻¹ * a < c ↔ a < b * c := by rw [inv_eq_one_div, mul_comm, ← div_eq_mul_one_div] exact div_lt_iff' h #align inv_mul_lt_iff inv_mul_lt_iff theorem inv_mul_lt_iff' (h : 0 < b) : b⁻¹ * a < c ↔ a < c * b := by rw [inv_mul_lt_iff h, mul_comm] #align inv_mul_lt_iff' inv_mul_lt_iff' theorem mul_inv_lt_iff (h : 0 < b) : a * b⁻¹ < c ↔ a < b * c := by rw [mul_comm, inv_mul_lt_iff h] #align mul_inv_lt_iff mul_inv_lt_iff theorem mul_inv_lt_iff' (h : 0 < b) : a * b⁻¹ < c ↔ a < c * b := by rw [mul_comm, inv_mul_lt_iff' h] #align mul_inv_lt_iff' mul_inv_lt_iff' theorem inv_pos_le_iff_one_le_mul (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ b * a := by rw [inv_eq_one_div] exact div_le_iff ha #align inv_pos_le_iff_one_le_mul inv_pos_le_iff_one_le_mul theorem inv_pos_le_iff_one_le_mul' (ha : 0 < a) : a⁻¹ ≤ b ↔ 1 ≤ a * b := by rw [inv_eq_one_div] exact div_le_iff' ha #align inv_pos_le_iff_one_le_mul' inv_pos_le_iff_one_le_mul' theorem inv_pos_lt_iff_one_lt_mul (ha : 0 < a) : a⁻¹ < b ↔ 1 < b * a := by rw [inv_eq_one_div] exact div_lt_iff ha #align inv_pos_lt_iff_one_lt_mul inv_pos_lt_iff_one_lt_mul theorem inv_pos_lt_iff_one_lt_mul' (ha : 0 < a) : a⁻¹ < b ↔ 1 < a * b := by rw [inv_eq_one_div] exact div_lt_iff' ha #align inv_pos_lt_iff_one_lt_mul' inv_pos_lt_iff_one_lt_mul' theorem div_le_of_nonneg_of_le_mul (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ c * b) : a / b ≤ c := by rcases eq_or_lt_of_le hb with (rfl | hb') · simp only [div_zero, hc] · rwa [div_le_iff hb'] #align div_le_of_nonneg_of_le_mul div_le_of_nonneg_of_le_mul lemma mul_le_of_nonneg_of_le_div (hb : 0 ≤ b) (hc : 0 ≤ c) (h : a ≤ b / c) : a * c ≤ b := by obtain rfl | hc := hc.eq_or_lt · simpa using hb · rwa [le_div_iff hc] at h #align mul_le_of_nonneg_of_le_div mul_le_of_nonneg_of_le_div theorem div_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a / b ≤ 1 := div_le_of_nonneg_of_le_mul hb zero_le_one <| by rwa [one_mul] #align div_le_one_of_le div_le_one_of_le lemma mul_inv_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : a * b⁻¹ ≤ 1 := by simpa only [← div_eq_mul_inv] using div_le_one_of_le h hb lemma inv_mul_le_one_of_le (h : a ≤ b) (hb : 0 ≤ b) : b⁻¹ * a ≤ 1 := by simpa only [← div_eq_inv_mul] using div_le_one_of_le h hb @[gcongr] theorem inv_le_inv_of_le (ha : 0 < a) (h : a ≤ b) : b⁻¹ ≤ a⁻¹ := by rwa [← one_div a, le_div_iff' ha, ← div_eq_mul_inv, div_le_iff (ha.trans_le h), one_mul] #align inv_le_inv_of_le inv_le_inv_of_le theorem inv_le_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by rw [← one_div, div_le_iff ha, ← div_eq_inv_mul, le_div_iff hb, one_mul] #align inv_le_inv inv_le_inv theorem inv_le (ha : 0 < a) (hb : 0 < b) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by rw [← inv_le_inv hb (inv_pos.2 ha), inv_inv] #align inv_le inv_le theorem inv_le_of_inv_le (ha : 0 < a) (h : a⁻¹ ≤ b) : b⁻¹ ≤ a := (inv_le ha ((inv_pos.2 ha).trans_le h)).1 h #align inv_le_of_inv_le inv_le_of_inv_le theorem le_inv (ha : 0 < a) (hb : 0 < b) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by rw [← inv_le_inv (inv_pos.2 hb) ha, inv_inv] #align le_inv le_inv theorem inv_lt_inv (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b⁻¹ ↔ b < a := lt_iff_lt_of_le_iff_le (inv_le_inv hb ha) #align inv_lt_inv inv_lt_inv @[gcongr] theorem inv_lt_inv_of_lt (hb : 0 < b) (h : b < a) : a⁻¹ < b⁻¹ := (inv_lt_inv (hb.trans h) hb).2 h #align inv_lt_inv_of_lt inv_lt_inv_of_lt theorem inv_lt (ha : 0 < a) (hb : 0 < b) : a⁻¹ < b ↔ b⁻¹ < a := lt_iff_lt_of_le_iff_le (le_inv hb ha) #align inv_lt inv_lt theorem inv_lt_of_inv_lt (ha : 0 < a) (h : a⁻¹ < b) : b⁻¹ < a := (inv_lt ha ((inv_pos.2 ha).trans h)).1 h #align inv_lt_of_inv_lt inv_lt_of_inv_lt theorem lt_inv (ha : 0 < a) (hb : 0 < b) : a < b⁻¹ ↔ b < a⁻¹ := lt_iff_lt_of_le_iff_le (inv_le hb ha) #align lt_inv lt_inv theorem inv_lt_one (ha : 1 < a) : a⁻¹ < 1 := by rwa [inv_lt (zero_lt_one.trans ha) zero_lt_one, inv_one] #align inv_lt_one inv_lt_one
Mathlib/Algebra/Order/Field/Basic.lean
231
232
theorem one_lt_inv (h₁ : 0 < a) (h₂ : a < 1) : 1 < a⁻¹ := by
rwa [lt_inv (@zero_lt_one α _ _ _ _ _) h₁, inv_one]
import Mathlib.Algebra.CharP.ExpChar import Mathlib.Algebra.GeomSum import Mathlib.Algebra.MvPolynomial.CommRing import Mathlib.Algebra.MvPolynomial.Equiv import Mathlib.RingTheory.Polynomial.Content import Mathlib.RingTheory.UniqueFactorizationDomain #align_import ring_theory.polynomial.basic from "leanprover-community/mathlib"@"da420a8c6dd5bdfb85c4ced85c34388f633bc6ff" noncomputable section open Polynomial open Finset universe u v w variable {R : Type u} {S : Type*} namespace Polynomial section Semiring variable [Semiring R] instance instCharP (p : ℕ) [h : CharP R p] : CharP R[X] p := let ⟨h⟩ := h ⟨fun n => by rw [← map_natCast C, ← C_0, C_inj, h]⟩ instance instExpChar (p : ℕ) [h : ExpChar R p] : ExpChar R[X] p := by cases h; exacts [ExpChar.zero, ExpChar.prime ‹_›] variable (R) def degreeLE (n : WithBot ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ _ : ↑k > n, LinearMap.ker (lcoeff R k) #align polynomial.degree_le Polynomial.degreeLE def degreeLT (n : ℕ) : Submodule R R[X] := ⨅ k : ℕ, ⨅ (_ : k ≥ n), LinearMap.ker (lcoeff R k) #align polynomial.degree_lt Polynomial.degreeLT variable {R} theorem mem_degreeLE {n : WithBot ℕ} {f : R[X]} : f ∈ degreeLE R n ↔ degree f ≤ n := by simp only [degreeLE, Submodule.mem_iInf, degree_le_iff_coeff_zero, LinearMap.mem_ker]; rfl #align polynomial.mem_degree_le Polynomial.mem_degreeLE @[mono] theorem degreeLE_mono {m n : WithBot ℕ} (H : m ≤ n) : degreeLE R m ≤ degreeLE R n := fun _ hf => mem_degreeLE.2 (le_trans (mem_degreeLE.1 hf) H) #align polynomial.degree_le_mono Polynomial.degreeLE_mono theorem degreeLE_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLE R n = Submodule.span R ↑((Finset.range (n + 1)).image fun n => (X : R[X]) ^ n) := by apply le_antisymm · intro p hp replace hp := mem_degreeLE.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_le_coe.1 (Finset.sup_le_iff.1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 (Nat.lt_succ_of_le this), rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLE.2 exact (degree_X_pow_le _).trans (WithBot.coe_le_coe.2 <| Nat.le_of_lt_succ <| Finset.mem_range.1 hk) set_option linter.uppercaseLean3 false in #align polynomial.degree_le_eq_span_X_pow Polynomial.degreeLE_eq_span_X_pow theorem mem_degreeLT {n : ℕ} {f : R[X]} : f ∈ degreeLT R n ↔ degree f < n := by rw [degreeLT, Submodule.mem_iInf] conv_lhs => intro i; rw [Submodule.mem_iInf] rw [degree, Finset.max_eq_sup_coe] rw [Finset.sup_lt_iff ?_] rotate_left · apply WithBot.bot_lt_coe conv_rhs => simp only [mem_support_iff] intro b rw [Nat.cast_withBot, WithBot.coe_lt_coe, lt_iff_not_le, Ne, not_imp_not] rfl #align polynomial.mem_degree_lt Polynomial.mem_degreeLT @[mono] theorem degreeLT_mono {m n : ℕ} (H : m ≤ n) : degreeLT R m ≤ degreeLT R n := fun _ hf => mem_degreeLT.2 (lt_of_lt_of_le (mem_degreeLT.1 hf) <| WithBot.coe_le_coe.2 H) #align polynomial.degree_lt_mono Polynomial.degreeLT_mono theorem degreeLT_eq_span_X_pow [DecidableEq R] {n : ℕ} : degreeLT R n = Submodule.span R ↑((Finset.range n).image fun n => X ^ n : Finset R[X]) := by apply le_antisymm · intro p hp replace hp := mem_degreeLT.1 hp rw [← Polynomial.sum_monomial_eq p, Polynomial.sum] refine Submodule.sum_mem _ fun k hk => ?_ have := WithBot.coe_lt_coe.1 ((Finset.sup_lt_iff <| WithBot.bot_lt_coe n).1 hp k hk) rw [← C_mul_X_pow_eq_monomial, C_mul'] refine Submodule.smul_mem _ _ (Submodule.subset_span <| Finset.mem_coe.2 <| Finset.mem_image.2 ⟨_, Finset.mem_range.2 this, rfl⟩) rw [Submodule.span_le, Finset.coe_image, Set.image_subset_iff] intro k hk apply mem_degreeLT.2 exact lt_of_le_of_lt (degree_X_pow_le _) (WithBot.coe_lt_coe.2 <| Finset.mem_range.1 hk) set_option linter.uppercaseLean3 false in #align polynomial.degree_lt_eq_span_X_pow Polynomial.degreeLT_eq_span_X_pow def degreeLTEquiv (R) [Semiring R] (n : ℕ) : degreeLT R n ≃ₗ[R] Fin n → R where toFun p n := (↑p : R[X]).coeff n invFun f := ⟨∑ i : Fin n, monomial i (f i), (degreeLT R n).sum_mem fun i _ => mem_degreeLT.mpr (lt_of_le_of_lt (degree_monomial_le i (f i)) (WithBot.coe_lt_coe.mpr i.is_lt))⟩ map_add' p q := by ext dsimp rw [coeff_add] map_smul' x p := by ext dsimp rw [coeff_smul] rfl left_inv := by rintro ⟨p, hp⟩ ext1 simp only [Submodule.coe_mk] by_cases hp0 : p = 0 · subst hp0 simp only [coeff_zero, LinearMap.map_zero, Finset.sum_const_zero] rw [mem_degreeLT, degree_eq_natDegree hp0, Nat.cast_lt] at hp conv_rhs => rw [p.as_sum_range' n hp, ← Fin.sum_univ_eq_sum_range] right_inv f := by ext i simp only [finset_sum_coeff, Submodule.coe_mk] rw [Finset.sum_eq_single i, coeff_monomial, if_pos rfl] · rintro j - hji rw [coeff_monomial, if_neg] rwa [← Fin.ext_iff] · intro h exact (h (Finset.mem_univ _)).elim #align polynomial.degree_lt_equiv Polynomial.degreeLTEquiv -- Porting note: removed @[simp] as simp can prove this theorem degreeLTEquiv_eq_zero_iff_eq_zero {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) : degreeLTEquiv _ _ ⟨p, hp⟩ = 0 ↔ p = 0 := by rw [LinearEquiv.map_eq_zero_iff, Submodule.mk_eq_zero] #align polynomial.degree_lt_equiv_eq_zero_iff_eq_zero Polynomial.degreeLTEquiv_eq_zero_iff_eq_zero theorem eval_eq_sum_degreeLTEquiv {n : ℕ} {p : R[X]} (hp : p ∈ degreeLT R n) (x : R) : p.eval x = ∑ i, degreeLTEquiv _ _ ⟨p, hp⟩ i * x ^ (i : ℕ) := by simp_rw [eval_eq_sum] exact (sum_fin _ (by simp_rw [zero_mul, forall_const]) (mem_degreeLT.mp hp)).symm #align polynomial.eval_eq_sum_degree_lt_equiv Polynomial.eval_eq_sum_degreeLTEquiv theorem degreeLT_succ_eq_degreeLE {n : ℕ} : degreeLT R (n + 1) = degreeLE R n := by ext x by_cases x_zero : x = 0 · simp_rw [x_zero, Submodule.zero_mem] · rw [mem_degreeLT, mem_degreeLE, ← natDegree_lt_iff_degree_lt (by rwa [ne_eq]), ← natDegree_le_iff_degree_le, Nat.lt_succ] theorem exists_degree_le_of_mem_span {s : Set R[X]} {p : R[X]} (hs : s.Nonempty) (hp : p ∈ Submodule.span R s) : ∃ p' ∈ s, degree p ≤ degree p' := by by_contra! h by_cases hp_zero : p = 0 · rw [hp_zero, degree_zero] at h rcases hs with ⟨x, hx⟩ exact not_lt_bot (h x hx) · have : p ∈ degreeLT R (natDegree p) := by refine (Submodule.span_le.mpr fun p' p'_mem => ?_) hp rw [SetLike.mem_coe, mem_degreeLT, Nat.cast_withBot] exact lt_of_lt_of_le (h p' p'_mem) degree_le_natDegree rwa [mem_degreeLT, Nat.cast_withBot, degree_eq_natDegree hp_zero, Nat.cast_withBot, lt_self_iff_false] at this theorem exists_degree_le_of_mem_span_of_finite {s : Set R[X]} (s_fin : s.Finite) (hs : s.Nonempty) : ∃ p' ∈ s, ∀ (p : R[X]), p ∈ Submodule.span R s → degree p ≤ degree p' := by rcases Set.Finite.exists_maximal_wrt degree s s_fin hs with ⟨a, has, hmax⟩ refine ⟨a, has, fun p hp => ?_⟩ rcases exists_degree_le_of_mem_span hs hp with ⟨p', hp'⟩ by_cases h : degree a ≤ degree p' · rw [← hmax p' hp'.left h] at hp'; exact hp'.right · exact le_trans hp'.right (not_le.mp h).le theorem span_le_degreeLE_of_finite {s : Set R[X]} (s_fin : s.Finite) : ∃ n : ℕ, Submodule.span R s ≤ degreeLE R n := by by_cases s_emp : s.Nonempty · rcases exists_degree_le_of_mem_span_of_finite s_fin s_emp with ⟨p', _, hp'max⟩ exact ⟨natDegree p', fun p hp => mem_degreeLE.mpr ((hp'max _ hp).trans degree_le_natDegree)⟩ · rw [Set.not_nonempty_iff_eq_empty] at s_emp rw [s_emp, Submodule.span_empty] exact ⟨0, bot_le⟩ theorem span_of_finite_le_degreeLT {s : Set R[X]} (s_fin : s.Finite) : ∃ n : ℕ, Submodule.span R s ≤ degreeLT R n := by rcases span_le_degreeLE_of_finite s_fin with ⟨n, _⟩ exact ⟨n + 1, by rwa [degreeLT_succ_eq_degreeLE]⟩ theorem not_finite [Nontrivial R] : ¬ Module.Finite R R[X] := by rw [Module.finite_def, Submodule.fg_def] push_neg intro s hs contra rcases span_le_degreeLE_of_finite hs with ⟨n,hn⟩ have : ((X : R[X]) ^ (n + 1)) ∈ Polynomial.degreeLE R ↑n := by rw [contra] at hn exact hn Submodule.mem_top rw [mem_degreeLE, degree_X_pow, Nat.cast_le, add_le_iff_nonpos_right, nonpos_iff_eq_zero] at this exact one_ne_zero this def coeffs (p : R[X]) : Finset R := letI := Classical.decEq R Finset.image (fun n => p.coeff n) p.support #align polynomial.frange Polynomial.coeffs @[deprecated (since := "2024-05-17")] noncomputable alias frange := coeffs theorem coeffs_zero : coeffs (0 : R[X]) = ∅ := rfl #align polynomial.frange_zero Polynomial.coeffs_zero @[deprecated (since := "2024-05-17")] alias frange_zero := coeffs_zero
Mathlib/RingTheory/Polynomial/Basic.lean
265
266
theorem mem_coeffs_iff {p : R[X]} {c : R} : c ∈ p.coeffs ↔ ∃ n ∈ p.support, c = p.coeff n := by
simp [coeffs, eq_comm, (Finset.mem_image)]
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Rat.Denumerable import Mathlib.Data.Set.Pointwise.Interval import Mathlib.SetTheory.Cardinal.Continuum #align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d" open Nat Set open Cardinal noncomputable section namespace Cardinal variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ} def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ := cond (f n) (c ^ n) 0 #align cardinal.cantor_function_aux Cardinal.cantorFunctionAux @[simp] theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true @[simp] theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by cases h' : f n <;> simp [h'] apply pow_nonneg h #align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg theorem cantorFunctionAux_eq (h : f n = g n) : cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h] #align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by cases h : f 0 <;> simp [h] #align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero theorem cantorFunctionAux_succ (f : ℕ → Bool) : (fun n => cantorFunctionAux c f (n + 1)) = fun n => c * cantorFunctionAux c (fun n => f (n + 1)) n := by ext n cases h : f (n + 1) <;> simp [h, _root_.pow_succ'] #align cardinal.cantor_function_aux_succ Cardinal.cantorFunctionAux_succ theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : Summable (cantorFunctionAux c f) := by apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self intro n; cases h : f n <;> simp [h] #align cardinal.summable_cantor_function Cardinal.summable_cantor_function def cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ := ∑' n, cantorFunctionAux c f n #align cardinal.cantor_function Cardinal.cantorFunction theorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) : cantorFunction c f ≤ cantorFunction c g := by apply tsum_le_tsum _ (summable_cantor_function f h1 h2) (summable_cantor_function g h1 h2) intro n; cases h : f n · simp [h, cantorFunctionAux_nonneg h1] replace h3 : g n = true := h3 n h; simp [h, h3] #align cardinal.cantor_function_le Cardinal.cantorFunction_le theorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) : cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by rw [cantorFunction, tsum_eq_zero_add (summable_cantor_function f h1 h2)] rw [cantorFunctionAux_succ, tsum_mul_left, cantorFunctionAux, _root_.pow_zero] rfl #align cardinal.cantor_function_succ Cardinal.cantorFunction_succ theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool} (hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) : cantorFunction c f < cantorFunction c g := by have h3 : c < 1 := by apply h2.trans norm_num induction' n with n ih generalizing f g · let f_max : ℕ → Bool := fun n => Nat.rec false (fun _ _ => true) n have hf_max : ∀ n, f n → f_max n := by intro n hn cases n · rw [fn] at hn contradiction apply rfl let g_min : ℕ → Bool := fun n => Nat.rec true (fun _ _ => false) n have hg_min : ∀ n, g_min n → g n := by intro n hn cases n · rw [gn] simp at hn apply (cantorFunction_le (le_of_lt h1) h3 hf_max).trans_lt refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min) have : c / (1 - c) < 1 := by rw [div_lt_one, lt_sub_iff_add_lt] · convert _root_.add_lt_add h2 h2 norm_num rwa [sub_pos] convert this · rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ← tsum_geometric_of_lt_one (le_of_lt h1) h3] apply zero_add · refine (tsum_eq_single 0 ?_).trans ?_ · intro n hn cases n · contradiction rfl · exact cantorFunctionAux_zero _ rw [cantorFunction_succ f (le_of_lt h1) h3, cantorFunction_succ g (le_of_lt h1) h3] rw [hn 0 <| zero_lt_succ n] apply add_lt_add_left rw [mul_lt_mul_left h1] exact ih (fun k hk => hn _ <| Nat.succ_lt_succ hk) fn gn #align cardinal.increasing_cantor_function Cardinal.increasing_cantorFunction theorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) : Function.Injective (cantorFunction c) := by intro f g hfg classical by_contra h revert hfg have : ∃ n, f n ≠ g n := by rw [← not_forall] intro h' apply h ext apply h' let n := Nat.find this have hn : ∀ k : ℕ, k < n → f k = g k := by intro k hk apply of_not_not exact Nat.find_min this hk cases fn : f n · apply _root_.ne_of_lt refine increasing_cantorFunction h1 h2 hn fn ?_ apply Bool.eq_true_of_not_eq_false rw [← fn] apply Ne.symm exact Nat.find_spec this · apply _root_.ne_of_gt refine increasing_cantorFunction h1 h2 (fun k hk => (hn k hk).symm) ?_ fn apply Bool.eq_false_of_not_eq_true rw [← fn] apply Ne.symm exact Nat.find_spec this #align cardinal.cantor_function_injective Cardinal.cantorFunction_injective theorem mk_real : #ℝ = 𝔠 := by apply le_antisymm · rw [Real.equivCauchy.cardinal_eq] apply mk_quotient_le.trans apply (mk_subtype_le _).trans_eq rw [← power_def, mk_nat, mkRat, aleph0_power_aleph0] · convert mk_le_of_injective (cantorFunction_injective _ _) · rw [← power_def, mk_bool, mk_nat, two_power_aleph0] · exact 1 / 3 · norm_num · norm_num #align cardinal.mk_real Cardinal.mk_real theorem mk_univ_real : #(Set.univ : Set ℝ) = 𝔠 := by rw [mk_univ, mk_real] #align cardinal.mk_univ_real Cardinal.mk_univ_real theorem not_countable_real : ¬(Set.univ : Set ℝ).Countable := by rw [← le_aleph0_iff_set_countable, not_le, mk_univ_real] apply cantor #align cardinal.not_countable_real Cardinal.not_countable_real theorem mk_Ioi_real (a : ℝ) : #(Ioi a) = 𝔠 := by refine le_antisymm (mk_real ▸ mk_set_le _) ?_ rw [← not_lt] intro h refine _root_.ne_of_lt ?_ mk_univ_real have hu : Iio a ∪ {a} ∪ Ioi a = Set.univ := by convert @Iic_union_Ioi ℝ _ _ exact Iio_union_right rw [← hu] refine lt_of_le_of_lt (mk_union_le _ _) ?_ refine lt_of_le_of_lt (add_le_add_right (mk_union_le _ _) _) ?_ have h2 : (fun x => a + a - x) '' Ioi a = Iio a := by convert @image_const_sub_Ioi ℝ _ _ _ simp rw [← h2] refine add_lt_of_lt (cantor _).le ?_ h refine add_lt_of_lt (cantor _).le (mk_image_le.trans_lt h) ?_ rw [mk_singleton] exact one_lt_aleph0.trans (cantor _) #align cardinal.mk_Ioi_real Cardinal.mk_Ioi_real theorem mk_Ici_real (a : ℝ) : #(Ici a) = 𝔠 := le_antisymm (mk_real ▸ mk_set_le _) (mk_Ioi_real a ▸ mk_le_mk_of_subset Ioi_subset_Ici_self) #align cardinal.mk_Ici_real Cardinal.mk_Ici_real
Mathlib/Data/Real/Cardinality.lean
252
256
theorem mk_Iio_real (a : ℝ) : #(Iio a) = 𝔠 := by
refine le_antisymm (mk_real ▸ mk_set_le _) ?_ have h2 : (fun x => a + a - x) '' Iio a = Ioi a := by simp only [image_const_sub_Iio, add_sub_cancel_right] exact mk_Ioi_real a ▸ h2 ▸ mk_image_le
import Mathlib.Algebra.Polynomial.RingDivision import Mathlib.RingTheory.Localization.FractionRing #align_import data.polynomial.ring_division from "leanprover-community/mathlib"@"8efcf8022aac8e01df8d302dcebdbc25d6a886c8" noncomputable section namespace Polynomial universe u v w z variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : ℕ} section CommRing variable [CommRing R] [IsDomain R] {p q : R[X]} section Roots open Multiset Finset noncomputable def roots (p : R[X]) : Multiset R := haveI := Classical.decEq R haveI := Classical.dec (p = 0) if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) #align polynomial.roots Polynomial.roots theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] : p.roots = if h : p = 0 then ∅ else Classical.choose (exists_multiset_roots h) := by -- porting noteL `‹_›` doesn't work for instance arguments rename_i iR ip0 obtain rfl := Subsingleton.elim iR (Classical.decEq R) obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0)) rfl #align polynomial.roots_def Polynomial.roots_def @[simp] theorem roots_zero : (0 : R[X]).roots = 0 := dif_pos rfl #align polynomial.roots_zero Polynomial.roots_zero theorem card_roots (hp0 : p ≠ 0) : (Multiset.card (roots p) : WithBot ℕ) ≤ degree p := by classical unfold roots rw [dif_neg hp0] exact (Classical.choose_spec (exists_multiset_roots hp0)).1 #align polynomial.card_roots Polynomial.card_roots theorem card_roots' (p : R[X]) : Multiset.card p.roots ≤ natDegree p := by by_cases hp0 : p = 0 · simp [hp0] exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0)) #align polynomial.card_roots' Polynomial.card_roots' theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) : (Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree p := calc (Multiset.card (p - C a).roots : WithBot ℕ) ≤ degree (p - C a) := card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm ▸ degree_C_le _ = degree p := by rw [sub_eq_add_neg, ← C_neg]; exact degree_add_C hp0 set_option linter.uppercaseLean3 false in #align polynomial.card_roots_sub_C Polynomial.card_roots_sub_C theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) : Multiset.card (p - C a).roots ≤ natDegree p := WithBot.coe_le_coe.1 (le_trans (card_roots_sub_C hp0) (le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl])) set_option linter.uppercaseLean3 false in #align polynomial.card_roots_sub_C' Polynomial.card_roots_sub_C' @[simp] theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by classical by_cases hp : p = 0 · simp [hp] rw [roots_def, dif_neg hp] exact (Classical.choose_spec (exists_multiset_roots hp)).2 a #align polynomial.count_roots Polynomial.count_roots @[simp] theorem mem_roots' : a ∈ p.roots ↔ p ≠ 0 ∧ IsRoot p a := by classical rw [← count_pos, count_roots p, rootMultiplicity_pos'] #align polynomial.mem_roots' Polynomial.mem_roots' theorem mem_roots (hp : p ≠ 0) : a ∈ p.roots ↔ IsRoot p a := mem_roots'.trans <| and_iff_right hp #align polynomial.mem_roots Polynomial.mem_roots theorem ne_zero_of_mem_roots (h : a ∈ p.roots) : p ≠ 0 := (mem_roots'.1 h).1 #align polynomial.ne_zero_of_mem_roots Polynomial.ne_zero_of_mem_roots theorem isRoot_of_mem_roots (h : a ∈ p.roots) : IsRoot p a := (mem_roots'.1 h).2 #align polynomial.is_root_of_mem_roots Polynomial.isRoot_of_mem_roots -- Porting note: added during port. lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p ≠ 0) : x ∈ roots p ↔ aeval x p = 0 := by rw [mem_roots w, IsRoot.def, aeval_def, eval₂_eq_eval_map] simp theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val ⊆ p.roots) : Z.card ≤ p.natDegree := (Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p) #align polynomial.card_le_degree_of_subset_roots Polynomial.card_le_degree_of_subset_roots theorem finite_setOf_isRoot {p : R[X]} (hp : p ≠ 0) : Set.Finite { x | IsRoot p x } := by classical simpa only [← Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp] using p.roots.toFinset.finite_toSet #align polynomial.finite_set_of_is_root Polynomial.finite_setOf_isRoot theorem eq_zero_of_infinite_isRoot (p : R[X]) (h : Set.Infinite { x | IsRoot p x }) : p = 0 := not_imp_comm.mp finite_setOf_isRoot h #align polynomial.eq_zero_of_infinite_is_root Polynomial.eq_zero_of_infinite_isRoot theorem exists_max_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x ≤ x₀ := Set.exists_upper_bound_image _ _ <| finite_setOf_isRoot hp #align polynomial.exists_max_root Polynomial.exists_max_root theorem exists_min_root [LinearOrder R] (p : R[X]) (hp : p ≠ 0) : ∃ x₀, ∀ x, p.IsRoot x → x₀ ≤ x := Set.exists_lower_bound_image _ _ <| finite_setOf_isRoot hp #align polynomial.exists_min_root Polynomial.exists_min_root
Mathlib/Algebra/Polynomial/Roots.lean
154
158
theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = eval x q }) : p = q := by
rw [← sub_eq_zero] apply eq_zero_of_infinite_isRoot simpa only [IsRoot, eval_sub, sub_eq_zero]
import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Combinatorics.Additive.AP.Three.Defs import Mathlib.Combinatorics.Pigeonhole import Mathlib.Data.Complex.ExponentialBounds #align_import combinatorics.additive.behrend from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" open Nat hiding log open Finset Metric Real open scoped Pointwise lemma threeAPFree_frontier {𝕜 E : Type*} [LinearOrderedField 𝕜] [TopologicalSpace E] [AddCommMonoid E] [Module 𝕜 E] {s : Set E} (hs₀ : IsClosed s) (hs₁ : StrictConvex 𝕜 s) : ThreeAPFree (frontier s) := by intro a ha b hb c hc habc obtain rfl : (1 / 2 : 𝕜) • a + (1 / 2 : 𝕜) • c = b := by rwa [← smul_add, one_div, inv_smul_eq_iff₀ (show (2 : 𝕜) ≠ 0 by norm_num), two_smul] have := hs₁.eq (hs₀.frontier_subset ha) (hs₀.frontier_subset hc) one_half_pos one_half_pos (add_halves _) hb.2 simp [this, ← add_smul] ring_nf simp #align add_salem_spencer_frontier threeAPFree_frontier lemma threeAPFree_sphere {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [StrictConvexSpace ℝ E] (x : E) (r : ℝ) : ThreeAPFree (sphere x r) := by obtain rfl | hr := eq_or_ne r 0 · rw [sphere_zero] exact threeAPFree_singleton _ · convert threeAPFree_frontier isClosed_ball (strictConvex_closedBall ℝ x r) exact (frontier_closedBall _ hr).symm #align add_salem_spencer_sphere threeAPFree_sphere namespace Behrend variable {α β : Type*} {n d k N : ℕ} {x : Fin n → ℕ} def box (n d : ℕ) : Finset (Fin n → ℕ) := Fintype.piFinset fun _ => range d #align behrend.box Behrend.box theorem mem_box : x ∈ box n d ↔ ∀ i, x i < d := by simp only [box, Fintype.mem_piFinset, mem_range] #align behrend.mem_box Behrend.mem_box @[simp] theorem card_box : (box n d).card = d ^ n := by simp [box] #align behrend.card_box Behrend.card_box @[simp] theorem box_zero : box (n + 1) 0 = ∅ := by simp [box] #align behrend.box_zero Behrend.box_zero def sphere (n d k : ℕ) : Finset (Fin n → ℕ) := (box n d).filter fun x => ∑ i, x i ^ 2 = k #align behrend.sphere Behrend.sphere theorem sphere_zero_subset : sphere n d 0 ⊆ 0 := fun x => by simp [sphere, Function.funext_iff] #align behrend.sphere_zero_subset Behrend.sphere_zero_subset @[simp] theorem sphere_zero_right (n k : ℕ) : sphere (n + 1) 0 k = ∅ := by simp [sphere] #align behrend.sphere_zero_right Behrend.sphere_zero_right theorem sphere_subset_box : sphere n d k ⊆ box n d := filter_subset _ _ #align behrend.sphere_subset_box Behrend.sphere_subset_box theorem norm_of_mem_sphere {x : Fin n → ℕ} (hx : x ∈ sphere n d k) : ‖(WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)‖ = √↑k := by rw [EuclideanSpace.norm_eq] dsimp simp_rw [abs_cast, ← cast_pow, ← cast_sum, (mem_filter.1 hx).2] #align behrend.norm_of_mem_sphere Behrend.norm_of_mem_sphere theorem sphere_subset_preimage_metric_sphere : (sphere n d k : Set (Fin n → ℕ)) ⊆ (fun x : Fin n → ℕ => (WithLp.equiv 2 _).symm ((↑) ∘ x : Fin n → ℝ)) ⁻¹' Metric.sphere (0 : PiLp 2 fun _ : Fin n => ℝ) (√↑k) := fun x hx => by rw [Set.mem_preimage, mem_sphere_zero_iff_norm, norm_of_mem_sphere hx] #align behrend.sphere_subset_preimage_metric_sphere Behrend.sphere_subset_preimage_metric_sphere @[simps] def map (d : ℕ) : (Fin n → ℕ) →+ ℕ where toFun a := ∑ i, a i * d ^ (i : ℕ) map_zero' := by simp_rw [Pi.zero_apply, zero_mul, sum_const_zero] map_add' a b := by simp_rw [Pi.add_apply, add_mul, sum_add_distrib] #align behrend.map Behrend.map -- @[simp] -- Porting note (#10618): simp can prove this theorem map_zero (d : ℕ) (a : Fin 0 → ℕ) : map d a = 0 := by simp [map] #align behrend.map_zero Behrend.map_zero theorem map_succ (a : Fin (n + 1) → ℕ) : map d a = a 0 + (∑ x : Fin n, a x.succ * d ^ (x : ℕ)) * d := by simp [map, Fin.sum_univ_succ, _root_.pow_succ, ← mul_assoc, ← sum_mul] #align behrend.map_succ Behrend.map_succ theorem map_succ' (a : Fin (n + 1) → ℕ) : map d a = a 0 + map d (a ∘ Fin.succ) * d := map_succ _ #align behrend.map_succ' Behrend.map_succ' theorem map_monotone (d : ℕ) : Monotone (map d : (Fin n → ℕ) → ℕ) := fun x y h => by dsimp; exact sum_le_sum fun i _ => Nat.mul_le_mul_right _ <| h i #align behrend.map_monotone Behrend.map_monotone theorem map_mod (a : Fin n.succ → ℕ) : map d a % d = a 0 % d := by rw [map_succ, Nat.add_mul_mod_self_right] #align behrend.map_mod Behrend.map_mod theorem map_eq_iff {x₁ x₂ : Fin n.succ → ℕ} (hx₁ : ∀ i, x₁ i < d) (hx₂ : ∀ i, x₂ i < d) : map d x₁ = map d x₂ ↔ x₁ 0 = x₂ 0 ∧ map d (x₁ ∘ Fin.succ) = map d (x₂ ∘ Fin.succ) := by refine ⟨fun h => ?_, fun h => by rw [map_succ', map_succ', h.1, h.2]⟩ have : x₁ 0 = x₂ 0 := by rw [← mod_eq_of_lt (hx₁ _), ← map_mod, ← mod_eq_of_lt (hx₂ _), ← map_mod, h] rw [map_succ, map_succ, this, add_right_inj, mul_eq_mul_right_iff] at h exact ⟨this, h.resolve_right (pos_of_gt (hx₁ 0)).ne'⟩ #align behrend.map_eq_iff Behrend.map_eq_iff theorem map_injOn : {x : Fin n → ℕ | ∀ i, x i < d}.InjOn (map d) := by intro x₁ hx₁ x₂ hx₂ h induction' n with n ih · simp [eq_iff_true_of_subsingleton] rw [forall_const] at ih ext i have x := (map_eq_iff hx₁ hx₂).1 h refine Fin.cases x.1 (congr_fun <| ih (fun _ => ?_) (fun _ => ?_) x.2) i · exact hx₁ _ · exact hx₂ _ #align behrend.map_inj_on Behrend.map_injOn theorem map_le_of_mem_box (hx : x ∈ box n d) : map (2 * d - 1) x ≤ ∑ i : Fin n, (d - 1) * (2 * d - 1) ^ (i : ℕ) := map_monotone (2 * d - 1) fun _ => Nat.le_sub_one_of_lt <| mem_box.1 hx _ #align behrend.map_le_of_mem_box Behrend.map_le_of_mem_box nonrec theorem threeAPFree_sphere : ThreeAPFree (sphere n d k : Set (Fin n → ℕ)) := by set f : (Fin n → ℕ) →+ EuclideanSpace ℝ (Fin n) := { toFun := fun f => ((↑) : ℕ → ℝ) ∘ f map_zero' := funext fun _ => cast_zero map_add' := fun _ _ => funext fun _ => cast_add _ _ } refine ThreeAPFree.of_image (AddMonoidHomClass.isAddFreimanHom f (Set.mapsTo_image _ _)) cast_injective.comp_left.injOn (Set.subset_univ _) ?_ refine (threeAPFree_sphere 0 (√↑k)).mono (Set.image_subset_iff.2 fun x => ?_) rw [Set.mem_preimage, mem_sphere_zero_iff_norm] exact norm_of_mem_sphere #align behrend.add_salem_spencer_sphere Behrend.threeAPFree_sphere theorem threeAPFree_image_sphere : ThreeAPFree ((sphere n d k).image (map (2 * d - 1)) : Set ℕ) := by rw [coe_image] apply ThreeAPFree.image' (α := Fin n → ℕ) (β := ℕ) (s := sphere n d k) (map (2 * d - 1)) (map_injOn.mono _) threeAPFree_sphere · rw [Set.add_subset_iff] rintro a ha b hb i have hai := mem_box.1 (sphere_subset_box ha) i have hbi := mem_box.1 (sphere_subset_box hb) i rw [lt_tsub_iff_right, ← succ_le_iff, two_mul] exact (add_add_add_comm _ _ 1 1).trans_le (_root_.add_le_add hai hbi) · exact x #align behrend.add_salem_spencer_image_sphere Behrend.threeAPFree_image_sphere theorem sum_sq_le_of_mem_box (hx : x ∈ box n d) : ∑ i : Fin n, x i ^ 2 ≤ n * (d - 1) ^ 2 := by rw [mem_box] at hx have : ∀ i, x i ^ 2 ≤ (d - 1) ^ 2 := fun i => Nat.pow_le_pow_left (Nat.le_sub_one_of_lt (hx i)) _ exact (sum_le_card_nsmul univ _ _ fun i _ => this i).trans (by rw [card_fin, smul_eq_mul]) #align behrend.sum_sq_le_of_mem_box Behrend.sum_sq_le_of_mem_box theorem sum_eq : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) = ((2 * d + 1) ^ n - 1) / 2 := by refine (Nat.div_eq_of_eq_mul_left zero_lt_two ?_).symm rw [← sum_range fun i => d * (2 * d + 1) ^ (i : ℕ), ← mul_sum, mul_right_comm, mul_comm d, ← geom_sum_mul_add, add_tsub_cancel_right, mul_comm] #align behrend.sum_eq Behrend.sum_eq theorem sum_lt : (∑ i : Fin n, d * (2 * d + 1) ^ (i : ℕ)) < (2 * d + 1) ^ n := sum_eq.trans_lt <| (Nat.div_le_self _ 2).trans_lt <| pred_lt (pow_pos (succ_pos _) _).ne' #align behrend.sum_lt Behrend.sum_lt theorem card_sphere_le_rothNumberNat (n d k : ℕ) : (sphere n d k).card ≤ rothNumberNat ((2 * d - 1) ^ n) := by cases n · dsimp; refine (card_le_univ _).trans_eq ?_; rfl cases d · simp apply threeAPFree_image_sphere.le_rothNumberNat _ _ (card_image_of_injOn _) · intro; assumption · simp only [subset_iff, mem_image, and_imp, forall_exists_index, mem_range, forall_apply_eq_imp_iff₂, sphere, mem_filter] rintro _ x hx _ rfl exact (map_le_of_mem_box hx).trans_lt sum_lt apply map_injOn.mono fun x => ?_ · intro; assumption simp only [mem_coe, sphere, mem_filter, mem_box, and_imp, two_mul] exact fun h _ i => (h i).trans_le le_self_add #align behrend.card_sphere_le_roth_number_nat Behrend.card_sphere_le_rothNumberNat
Mathlib/Combinatorics/Additive/AP/Three/Behrend.lean
264
271
theorem exists_large_sphere_aux (n d : ℕ) : ∃ k ∈ range (n * (d - 1) ^ 2 + 1), (↑(d ^ n) / ((n * (d - 1) ^ 2 :) + 1) : ℝ) ≤ (sphere n d k).card := by
refine exists_le_card_fiber_of_nsmul_le_card_of_maps_to (fun x hx => ?_) nonempty_range_succ ?_ · rw [mem_range, Nat.lt_succ_iff] exact sum_sq_le_of_mem_box hx · rw [card_range, _root_.nsmul_eq_mul, mul_div_assoc', cast_add_one, mul_div_cancel_left₀, card_box] exact (cast_add_one_pos _).ne'
import Mathlib.Algebra.Module.Card import Mathlib.SetTheory.Cardinal.CountableCover import Mathlib.SetTheory.Cardinal.Continuum import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Topology.MetricSpace.Perfect universe u v open Filter Pointwise Set Function Cardinal open scoped Cardinal Topology theorem continuum_le_cardinal_of_nontriviallyNormedField (𝕜 : Type*) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] : 𝔠 ≤ #𝕜 := by suffices ∃ f : (ℕ → Bool) → 𝕜, range f ⊆ univ ∧ Continuous f ∧ Injective f by rcases this with ⟨f, -, -, f_inj⟩ simpa using lift_mk_le_lift_mk_of_injective f_inj apply Perfect.exists_nat_bool_injection _ univ_nonempty refine ⟨isClosed_univ, preperfect_iff_nhds.2 (fun x _ U hU ↦ ?_)⟩ rcases NormedField.exists_norm_lt_one 𝕜 with ⟨c, c_pos, hc⟩ have A : Tendsto (fun n ↦ x + c^n) atTop (𝓝 (x + 0)) := tendsto_const_nhds.add (tendsto_pow_atTop_nhds_zero_of_norm_lt_one hc) rw [add_zero] at A have B : ∀ᶠ n in atTop, x + c^n ∈ U := tendsto_def.1 A U hU rcases B.exists with ⟨n, hn⟩ refine ⟨x + c^n, by simpa using hn, ?_⟩ simp only [ne_eq, add_right_eq_self] apply pow_ne_zero simpa using c_pos theorem continuum_le_cardinal_of_module (𝕜 : Type u) (E : Type v) [NontriviallyNormedField 𝕜] [CompleteSpace 𝕜] [AddCommGroup E] [Module 𝕜 E] [Nontrivial E] : 𝔠 ≤ #E := by have A : lift.{v} (𝔠 : Cardinal.{u}) ≤ lift.{v} (#𝕜) := by simpa using continuum_le_cardinal_of_nontriviallyNormedField 𝕜 simpa using A.trans (Cardinal.mk_le_of_module 𝕜 E) lemma cardinal_eq_of_mem_nhds_zero {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousSMul 𝕜 E] {s : Set E} (hs : s ∈ 𝓝 (0 : E)) : #s = #E := by obtain ⟨c, hc⟩ : ∃ x : 𝕜 , 1 < ‖x‖ := NormedField.exists_lt_norm 𝕜 1 have cn_ne : ∀ n, c^n ≠ 0 := by intro n apply pow_ne_zero rintro rfl simp only [norm_zero] at hc exact lt_irrefl _ (hc.trans zero_lt_one) have A : ∀ (x : E), ∀ᶠ n in (atTop : Filter ℕ), x ∈ c^n • s := by intro x have : Tendsto (fun n ↦ (c^n) ⁻¹ • x) atTop (𝓝 ((0 : 𝕜) • x)) := by have : Tendsto (fun n ↦ (c^n)⁻¹) atTop (𝓝 0) := by simp_rw [← inv_pow] apply tendsto_pow_atTop_nhds_zero_of_norm_lt_one rw [norm_inv] exact inv_lt_one hc exact Tendsto.smul_const this x rw [zero_smul] at this filter_upwards [this hs] with n (hn : (c ^ n)⁻¹ • x ∈ s) exact (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).2 hn have B : ∀ n, #(c^n • s :) = #s := by intro n have : (c^n • s :) ≃ s := { toFun := fun x ↦ ⟨(c^n)⁻¹ • x.1, (mem_smul_set_iff_inv_smul_mem₀ (cn_ne n) _ _).1 x.2⟩ invFun := fun x ↦ ⟨(c^n) • x.1, smul_mem_smul_set x.2⟩ left_inv := fun x ↦ by simp [smul_smul, mul_inv_cancel (cn_ne n)] right_inv := fun x ↦ by simp [smul_smul, inv_mul_cancel (cn_ne n)] } exact Cardinal.mk_congr this apply (Cardinal.mk_of_countable_eventually_mem A B).symm theorem cardinal_eq_of_mem_nhds {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul 𝕜 E] {s : Set E} {x : E} (hs : s ∈ 𝓝 x) : #s = #E := by let g := Homeomorph.addLeft x let t := g ⁻¹' s have : t ∈ 𝓝 0 := g.continuous.continuousAt.preimage_mem_nhds (by simpa [g] using hs) have A : #t = #E := cardinal_eq_of_mem_nhds_zero 𝕜 this have B : #t = #s := Cardinal.mk_subtype_of_equiv s g.toEquiv rwa [B] at A
Mathlib/Topology/Algebra/Module/Cardinality.lean
110
115
theorem cardinal_eq_of_isOpen {E : Type*} (𝕜 : Type*) [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] [TopologicalSpace E] [ContinuousAdd E] [ContinuousSMul 𝕜 E] {s : Set E} (hs : IsOpen s) (h's : s.Nonempty) : #s = #E := by
rcases h's with ⟨x, hx⟩ exact cardinal_eq_of_mem_nhds 𝕜 (hs.mem_nhds hx)
import Mathlib.Data.Set.Pointwise.SMul #align_import algebra.add_torsor from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" class AddTorsor (G : outParam Type*) (P : Type*) [AddGroup G] extends AddAction G P, VSub G P where [nonempty : Nonempty P] vsub_vadd' : ∀ p₁ p₂ : P, (p₁ -ᵥ p₂ : G) +ᵥ p₂ = p₁ vadd_vsub' : ∀ (g : G) (p : P), g +ᵥ p -ᵥ p = g #align add_torsor AddTorsor -- Porting note(#12096): removed `nolint instance_priority`; lint not ported yet attribute [instance 100] AddTorsor.nonempty -- Porting note(#12094): removed nolint; dangerous_instance linter not ported yet --attribute [nolint dangerous_instance] AddTorsor.toVSub -- Porting note(#12096): linter not ported yet --@[nolint instance_priority] instance addGroupIsAddTorsor (G : Type*) [AddGroup G] : AddTorsor G G where vsub := Sub.sub vsub_vadd' := sub_add_cancel vadd_vsub' := add_sub_cancel_right #align add_group_is_add_torsor addGroupIsAddTorsor @[simp] theorem vsub_eq_sub {G : Type*} [AddGroup G] (g₁ g₂ : G) : g₁ -ᵥ g₂ = g₁ - g₂ := rfl #align vsub_eq_sub vsub_eq_sub section General variable {G : Type*} {P : Type*} [AddGroup G] [T : AddTorsor G P] @[simp] theorem vsub_vadd (p₁ p₂ : P) : p₁ -ᵥ p₂ +ᵥ p₂ = p₁ := AddTorsor.vsub_vadd' p₁ p₂ #align vsub_vadd vsub_vadd @[simp] theorem vadd_vsub (g : G) (p : P) : g +ᵥ p -ᵥ p = g := AddTorsor.vadd_vsub' g p #align vadd_vsub vadd_vsub theorem vadd_right_cancel {g₁ g₂ : G} (p : P) (h : g₁ +ᵥ p = g₂ +ᵥ p) : g₁ = g₂ := by -- Porting note: vadd_vsub g₁ → vadd_vsub g₁ p rw [← vadd_vsub g₁ p, h, vadd_vsub] #align vadd_right_cancel vadd_right_cancel @[simp] theorem vadd_right_cancel_iff {g₁ g₂ : G} (p : P) : g₁ +ᵥ p = g₂ +ᵥ p ↔ g₁ = g₂ := ⟨vadd_right_cancel p, fun h => h ▸ rfl⟩ #align vadd_right_cancel_iff vadd_right_cancel_iff theorem vadd_right_injective (p : P) : Function.Injective ((· +ᵥ p) : G → P) := fun _ _ => vadd_right_cancel p #align vadd_right_injective vadd_right_injective theorem vadd_vsub_assoc (g : G) (p₁ p₂ : P) : g +ᵥ p₁ -ᵥ p₂ = g + (p₁ -ᵥ p₂) := by apply vadd_right_cancel p₂ rw [vsub_vadd, add_vadd, vsub_vadd] #align vadd_vsub_assoc vadd_vsub_assoc @[simp] theorem vsub_self (p : P) : p -ᵥ p = (0 : G) := by rw [← zero_add (p -ᵥ p), ← vadd_vsub_assoc, vadd_vsub] #align vsub_self vsub_self theorem eq_of_vsub_eq_zero {p₁ p₂ : P} (h : p₁ -ᵥ p₂ = (0 : G)) : p₁ = p₂ := by rw [← vsub_vadd p₁ p₂, h, zero_vadd] #align eq_of_vsub_eq_zero eq_of_vsub_eq_zero @[simp] theorem vsub_eq_zero_iff_eq {p₁ p₂ : P} : p₁ -ᵥ p₂ = (0 : G) ↔ p₁ = p₂ := Iff.intro eq_of_vsub_eq_zero fun h => h ▸ vsub_self _ #align vsub_eq_zero_iff_eq vsub_eq_zero_iff_eq theorem vsub_ne_zero {p q : P} : p -ᵥ q ≠ (0 : G) ↔ p ≠ q := not_congr vsub_eq_zero_iff_eq #align vsub_ne_zero vsub_ne_zero @[simp] theorem vsub_add_vsub_cancel (p₁ p₂ p₃ : P) : p₁ -ᵥ p₂ + (p₂ -ᵥ p₃) = p₁ -ᵥ p₃ := by apply vadd_right_cancel p₃ rw [add_vadd, vsub_vadd, vsub_vadd, vsub_vadd] #align vsub_add_vsub_cancel vsub_add_vsub_cancel @[simp] theorem neg_vsub_eq_vsub_rev (p₁ p₂ : P) : -(p₁ -ᵥ p₂) = p₂ -ᵥ p₁ := by refine neg_eq_of_add_eq_zero_right (vadd_right_cancel p₁ ?_) rw [vsub_add_vsub_cancel, vsub_self] #align neg_vsub_eq_vsub_rev neg_vsub_eq_vsub_rev theorem vadd_vsub_eq_sub_vsub (g : G) (p q : P) : g +ᵥ p -ᵥ q = g - (q -ᵥ p) := by rw [vadd_vsub_assoc, sub_eq_add_neg, neg_vsub_eq_vsub_rev] #align vadd_vsub_eq_sub_vsub vadd_vsub_eq_sub_vsub
Mathlib/Algebra/AddTorsor.lean
165
167
theorem vsub_vadd_eq_vsub_sub (p₁ p₂ : P) (g : G) : p₁ -ᵥ (g +ᵥ p₂) = p₁ -ᵥ p₂ - g := by
rw [← add_right_inj (p₂ -ᵥ p₁ : G), vsub_add_vsub_cancel, ← neg_vsub_eq_vsub_rev, vadd_vsub, ← add_sub_assoc, ← neg_vsub_eq_vsub_rev, neg_add_self, zero_sub]
import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) #align with_zero_topology.topological_space WithZeroTopology.topologicalSpace theorem nhds_eq_update : (𝓝 : Γ₀ → Filter Γ₀) = update pure 0 (⨅ γ ≠ 0, 𝓟 (Iio γ)) := by rw [nhds_nhdsAdjoint, sup_of_le_right] exact le_iInf₂ fun γ hγ ↦ le_principal_iff.2 <| zero_lt_iff.2 hγ #align with_zero_topology.nhds_eq_update WithZeroTopology.nhds_eq_update theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by rw [nhds_eq_update, update_same] #align with_zero_topology.nhds_zero WithZeroTopology.nhds_zero theorem hasBasis_nhds_zero : (𝓝 (0 : Γ₀)).HasBasis (fun γ : Γ₀ => γ ≠ 0) Iio := by rw [nhds_zero] refine hasBasis_biInf_principal ?_ ⟨1, one_ne_zero⟩ exact directedOn_iff_directed.2 (Monotone.directed_ge fun a b hab => Iio_subset_Iio hab) #align with_zero_topology.has_basis_nhds_zero WithZeroTopology.hasBasis_nhds_zero theorem Iio_mem_nhds_zero (hγ : γ ≠ 0) : Iio γ ∈ 𝓝 (0 : Γ₀) := hasBasis_nhds_zero.mem_of_mem hγ #align with_zero_topology.Iio_mem_nhds_zero WithZeroTopology.Iio_mem_nhds_zero theorem nhds_zero_of_units (γ : Γ₀ˣ) : Iio ↑γ ∈ 𝓝 (0 : Γ₀) := Iio_mem_nhds_zero γ.ne_zero #align with_zero_topology.nhds_zero_of_units WithZeroTopology.nhds_zero_of_units theorem tendsto_zero : Tendsto f l (𝓝 (0 : Γ₀)) ↔ ∀ (γ₀) (_ : γ₀ ≠ 0), ∀ᶠ x in l, f x < γ₀ := by simp [nhds_zero] #align with_zero_topology.tendsto_zero WithZeroTopology.tendsto_zero @[simp] theorem nhds_of_ne_zero {γ : Γ₀} (h₀ : γ ≠ 0) : 𝓝 γ = pure γ := nhds_nhdsAdjoint_of_ne _ h₀ #align with_zero_topology.nhds_of_ne_zero WithZeroTopology.nhds_of_ne_zero theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) := nhds_of_ne_zero γ.ne_zero #align with_zero_topology.nhds_coe_units WithZeroTopology.nhds_coe_units
Mathlib/Topology/Algebra/WithZeroTopology.lean
101
101
theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by
simp
import Mathlib.Data.Option.NAry import Mathlib.Data.Seq.Computation #align_import data.seq.seq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' universe u v w def IsSeq {α : Type u} (s : Stream' (Option α)) : Prop := ∀ {n : ℕ}, s n = none → s (n + 1) = none #align stream.is_seq Stream'.IsSeq def Seq (α : Type u) : Type u := { f : Stream' (Option α) // f.IsSeq } #align stream.seq Stream'.Seq def Seq1 (α) := α × Seq α #align stream.seq1 Stream'.Seq1 namespace Seq variable {α : Type u} {β : Type v} {γ : Type w} def nil : Seq α := ⟨Stream'.const none, fun {_} _ => rfl⟩ #align stream.seq.nil Stream'.Seq.nil instance : Inhabited (Seq α) := ⟨nil⟩ def cons (a : α) (s : Seq α) : Seq α := ⟨some a::s.1, by rintro (n | _) h · contradiction · exact s.2 h⟩ #align stream.seq.cons Stream'.Seq.cons @[simp] theorem val_cons (s : Seq α) (x : α) : (cons x s).val = some x::s.val := rfl #align stream.seq.val_cons Stream'.Seq.val_cons def get? : Seq α → ℕ → Option α := Subtype.val #align stream.seq.nth Stream'.Seq.get? @[simp] theorem get?_mk (f hf) : @get? α ⟨f, hf⟩ = f := rfl #align stream.seq.nth_mk Stream'.Seq.get?_mk @[simp] theorem get?_nil (n : ℕ) : (@nil α).get? n = none := rfl #align stream.seq.nth_nil Stream'.Seq.get?_nil @[simp] theorem get?_cons_zero (a : α) (s : Seq α) : (cons a s).get? 0 = some a := rfl #align stream.seq.nth_cons_zero Stream'.Seq.get?_cons_zero @[simp] theorem get?_cons_succ (a : α) (s : Seq α) (n : ℕ) : (cons a s).get? (n + 1) = s.get? n := rfl #align stream.seq.nth_cons_succ Stream'.Seq.get?_cons_succ @[ext] protected theorem ext {s t : Seq α} (h : ∀ n : ℕ, s.get? n = t.get? n) : s = t := Subtype.eq <| funext h #align stream.seq.ext Stream'.Seq.ext theorem cons_injective2 : Function.Injective2 (cons : α → Seq α → Seq α) := fun x y s t h => ⟨by rw [← Option.some_inj, ← get?_cons_zero, h, get?_cons_zero], Seq.ext fun n => by simp_rw [← get?_cons_succ x s n, h, get?_cons_succ]⟩ #align stream.seq.cons_injective2 Stream'.Seq.cons_injective2 theorem cons_left_injective (s : Seq α) : Function.Injective fun x => cons x s := cons_injective2.left _ #align stream.seq.cons_left_injective Stream'.Seq.cons_left_injective theorem cons_right_injective (x : α) : Function.Injective (cons x) := cons_injective2.right _ #align stream.seq.cons_right_injective Stream'.Seq.cons_right_injective def TerminatedAt (s : Seq α) (n : ℕ) : Prop := s.get? n = none #align stream.seq.terminated_at Stream'.Seq.TerminatedAt instance terminatedAtDecidable (s : Seq α) (n : ℕ) : Decidable (s.TerminatedAt n) := decidable_of_iff' (s.get? n).isNone <| by unfold TerminatedAt; cases s.get? n <;> simp #align stream.seq.terminated_at_decidable Stream'.Seq.terminatedAtDecidable def Terminates (s : Seq α) : Prop := ∃ n : ℕ, s.TerminatedAt n #align stream.seq.terminates Stream'.Seq.Terminates theorem not_terminates_iff {s : Seq α} : ¬s.Terminates ↔ ∀ n, (s.get? n).isSome := by simp only [Terminates, TerminatedAt, ← Ne.eq_def, Option.ne_none_iff_isSome, not_exists, iff_self] #align stream.seq.not_terminates_iff Stream'.Seq.not_terminates_iff @[simp] def omap (f : β → γ) : Option (α × β) → Option (α × γ) | none => none | some (a, b) => some (a, f b) #align stream.seq.omap Stream'.Seq.omap def head (s : Seq α) : Option α := get? s 0 #align stream.seq.head Stream'.Seq.head def tail (s : Seq α) : Seq α := ⟨s.1.tail, fun n' => by cases' s with f al exact al n'⟩ #align stream.seq.tail Stream'.Seq.tail protected def Mem (a : α) (s : Seq α) := some a ∈ s.1 #align stream.seq.mem Stream'.Seq.Mem instance : Membership α (Seq α) := ⟨Seq.Mem⟩ theorem le_stable (s : Seq α) {m n} (h : m ≤ n) : s.get? m = none → s.get? n = none := by cases' s with f al induction' h with n _ IH exacts [id, fun h2 => al (IH h2)] #align stream.seq.le_stable Stream'.Seq.le_stable theorem terminated_stable : ∀ (s : Seq α) {m n : ℕ}, m ≤ n → s.TerminatedAt m → s.TerminatedAt n := le_stable #align stream.seq.terminated_stable Stream'.Seq.terminated_stable theorem ge_stable (s : Seq α) {aₙ : α} {n m : ℕ} (m_le_n : m ≤ n) (s_nth_eq_some : s.get? n = some aₙ) : ∃ aₘ : α, s.get? m = some aₘ := have : s.get? n ≠ none := by simp [s_nth_eq_some] have : s.get? m ≠ none := mt (s.le_stable m_le_n) this Option.ne_none_iff_exists'.mp this #align stream.seq.ge_stable Stream'.Seq.ge_stable theorem not_mem_nil (a : α) : a ∉ @nil α := fun ⟨_, (h : some a = none)⟩ => by injection h #align stream.seq.not_mem_nil Stream'.Seq.not_mem_nil theorem mem_cons (a : α) : ∀ s : Seq α, a ∈ cons a s | ⟨_, _⟩ => Stream'.mem_cons (some a) _ #align stream.seq.mem_cons Stream'.Seq.mem_cons theorem mem_cons_of_mem (y : α) {a : α} : ∀ {s : Seq α}, a ∈ s → a ∈ cons y s | ⟨_, _⟩ => Stream'.mem_cons_of_mem (some y) #align stream.seq.mem_cons_of_mem Stream'.Seq.mem_cons_of_mem theorem eq_or_mem_of_mem_cons {a b : α} : ∀ {s : Seq α}, a ∈ cons b s → a = b ∨ a ∈ s | ⟨f, al⟩, h => (Stream'.eq_or_mem_of_mem_cons h).imp_left fun h => by injection h #align stream.seq.eq_or_mem_of_mem_cons Stream'.Seq.eq_or_mem_of_mem_cons @[simp] theorem mem_cons_iff {a b : α} {s : Seq α} : a ∈ cons b s ↔ a = b ∨ a ∈ s := ⟨eq_or_mem_of_mem_cons, by rintro (rfl | m) <;> [apply mem_cons; exact mem_cons_of_mem _ m]⟩ #align stream.seq.mem_cons_iff Stream'.Seq.mem_cons_iff def destruct (s : Seq α) : Option (Seq1 α) := (fun a' => (a', s.tail)) <$> get? s 0 #align stream.seq.destruct Stream'.Seq.destruct theorem destruct_eq_nil {s : Seq α} : destruct s = none → s = nil := by dsimp [destruct] induction' f0 : get? s 0 <;> intro h · apply Subtype.eq funext n induction' n with n IH exacts [f0, s.2 IH] · contradiction #align stream.seq.destruct_eq_nil Stream'.Seq.destruct_eq_nil theorem destruct_eq_cons {s : Seq α} {a s'} : destruct s = some (a, s') → s = cons a s' := by dsimp [destruct] induction' f0 : get? s 0 with a' <;> intro h · contradiction · cases' s with f al injections _ h1 h2 rw [← h2] apply Subtype.eq dsimp [tail, cons] rw [h1] at f0 rw [← f0] exact (Stream'.eta f).symm #align stream.seq.destruct_eq_cons Stream'.Seq.destruct_eq_cons @[simp] theorem destruct_nil : destruct (nil : Seq α) = none := rfl #align stream.seq.destruct_nil Stream'.Seq.destruct_nil @[simp] theorem destruct_cons (a : α) : ∀ s, destruct (cons a s) = some (a, s) | ⟨f, al⟩ => by unfold cons destruct Functor.map apply congr_arg fun s => some (a, s) apply Subtype.eq; dsimp [tail] #align stream.seq.destruct_cons Stream'.Seq.destruct_cons -- Porting note: needed universe annotation to avoid universe issues theorem head_eq_destruct (s : Seq α) : head.{u} s = Prod.fst.{u} <$> destruct.{u} s := by unfold destruct head; cases get? s 0 <;> rfl #align stream.seq.head_eq_destruct Stream'.Seq.head_eq_destruct @[simp] theorem head_nil : head (nil : Seq α) = none := rfl #align stream.seq.head_nil Stream'.Seq.head_nil @[simp] theorem head_cons (a : α) (s) : head (cons a s) = some a := by rw [head_eq_destruct, destruct_cons, Option.map_eq_map, Option.map_some'] #align stream.seq.head_cons Stream'.Seq.head_cons @[simp] theorem tail_nil : tail (nil : Seq α) = nil := rfl #align stream.seq.tail_nil Stream'.Seq.tail_nil @[simp] theorem tail_cons (a : α) (s) : tail (cons a s) = s := by cases' s with f al apply Subtype.eq dsimp [tail, cons] #align stream.seq.tail_cons Stream'.Seq.tail_cons @[simp] theorem get?_tail (s : Seq α) (n) : get? (tail s) n = get? s (n + 1) := rfl #align stream.seq.nth_tail Stream'.Seq.get?_tail def recOn {C : Seq α → Sort v} (s : Seq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) : C s := by cases' H : destruct s with v · rw [destruct_eq_nil H] apply h1 · cases' v with a s' rw [destruct_eq_cons H] apply h2 #align stream.seq.rec_on Stream'.Seq.recOn theorem mem_rec_on {C : Seq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) : C s := by cases' M with k e; unfold Stream'.get at e induction' k with k IH generalizing s · have TH : s = cons a (tail s) := by apply destruct_eq_cons unfold destruct get? Functor.map rw [← e] rfl rw [TH] apply h1 _ _ (Or.inl rfl) -- Porting note: had to reshuffle `intro` revert e; apply s.recOn _ fun b s' => _ · intro e; injection e · intro b s' e have h_eq : (cons b s').val (Nat.succ k) = s'.val k := by cases s'; rfl rw [h_eq] at e apply h1 _ _ (Or.inr (IH e)) #align stream.seq.mem_rec_on Stream'.Seq.mem_rec_on def Corec.f (f : β → Option (α × β)) : Option β → Option α × Option β | none => (none, none) | some b => match f b with | none => (none, none) | some (a, b') => (some a, some b') set_option linter.uppercaseLean3 false in #align stream.seq.corec.F Stream'.Seq.Corec.f def corec (f : β → Option (α × β)) (b : β) : Seq α := by refine ⟨Stream'.corec' (Corec.f f) (some b), fun {n} h => ?_⟩ rw [Stream'.corec'_eq] change Stream'.corec' (Corec.f f) (Corec.f f (some b)).2 n = none revert h; generalize some b = o; revert o induction' n with n IH <;> intro o · change (Corec.f f o).1 = none → (Corec.f f (Corec.f f o).2).1 = none cases' o with b <;> intro h · rfl dsimp [Corec.f] at h dsimp [Corec.f] revert h; cases' h₁: f b with s <;> intro h · rfl · cases' s with a b' contradiction · rw [Stream'.corec'_eq (Corec.f f) (Corec.f f o).2, Stream'.corec'_eq (Corec.f f) o] exact IH (Corec.f f o).2 #align stream.seq.corec Stream'.Seq.corec @[simp] theorem corec_eq (f : β → Option (α × β)) (b : β) : destruct (corec f b) = omap (corec f) (f b) := by dsimp [corec, destruct, get] -- Porting note: next two lines were `change`...`with`... have h: Stream'.corec' (Corec.f f) (some b) 0 = (Corec.f f (some b)).1 := rfl rw [h] dsimp [Corec.f] induction' h : f b with s; · rfl cases' s with a b'; dsimp [Corec.f] apply congr_arg fun b' => some (a, b') apply Subtype.eq dsimp [corec, tail] rw [Stream'.corec'_eq, Stream'.tail_cons] dsimp [Corec.f]; rw [h] #align stream.seq.corec_eq Stream'.Seq.corec_eq section Bisim variable (R : Seq α → Seq α → Prop) local infixl:50 " ~ " => R def BisimO : Option (Seq1 α) → Option (Seq1 α) → Prop | none, none => True | some (a, s), some (a', s') => a = a' ∧ R s s' | _, _ => False #align stream.seq.bisim_o Stream'.Seq.BisimO attribute [simp] BisimO def IsBisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂) #align stream.seq.is_bisimulation Stream'.Seq.IsBisimulation -- If two streams are bisimilar, then they are equal
Mathlib/Data/Seq/Seq.lean
376
405
theorem eq_of_bisim (bisim : IsBisimulation R) {s₁ s₂} (r : s₁ ~ s₂) : s₁ = s₂ := by
apply Subtype.eq apply Stream'.eq_of_bisim fun x y => ∃ s s' : Seq α, s.1 = x ∧ s'.1 = y ∧ R s s' · dsimp [Stream'.IsBisimulation] intro t₁ t₂ e exact match t₁, t₂, e with | _, _, ⟨s, s', rfl, rfl, r⟩ => by suffices head s = head s' ∧ R (tail s) (tail s') from And.imp id (fun r => ⟨tail s, tail s', by cases s; rfl, by cases s'; rfl, r⟩) this have := bisim r; revert r this apply recOn s _ _ <;> apply recOn s' _ _ · intro r _ constructor · rfl · assumption · intro x s _ this rw [destruct_nil, destruct_cons] at this exact False.elim this · intro x s _ this rw [destruct_nil, destruct_cons] at this exact False.elim this · intro x s x' s' _ this rw [destruct_cons, destruct_cons] at this rw [head_cons, head_cons, tail_cons, tail_cons] cases' this with h1 h2 constructor · rw [h1] · exact h2 · exact ⟨s₁, s₂, rfl, rfl, r⟩
import Mathlib.Algebra.ModEq import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Periodic import Mathlib.Data.Int.SuccPred import Mathlib.GroupTheory.QuotientGroup import Mathlib.Order.Circular import Mathlib.Data.List.TFAE import Mathlib.Data.Set.Lattice #align_import algebra.order.to_interval_mod from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" noncomputable section section LinearOrderedAddCommGroup variable {α : Type*} [LinearOrderedAddCommGroup α] [hα : Archimedean α] {p : α} (hp : 0 < p) {a b c : α} {n : ℤ} def toIcoDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ico hp b a).choose #align to_Ico_div toIcoDiv theorem sub_toIcoDiv_zsmul_mem_Ico (a b : α) : b - toIcoDiv hp a b • p ∈ Set.Ico a (a + p) := (existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.1 #align sub_to_Ico_div_zsmul_mem_Ico sub_toIcoDiv_zsmul_mem_Ico theorem toIcoDiv_eq_of_sub_zsmul_mem_Ico (h : b - n • p ∈ Set.Ico a (a + p)) : toIcoDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ico hp b a).choose_spec.2 _ h).symm #align to_Ico_div_eq_of_sub_zsmul_mem_Ico toIcoDiv_eq_of_sub_zsmul_mem_Ico def toIocDiv (a b : α) : ℤ := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose #align to_Ioc_div toIocDiv theorem sub_toIocDiv_zsmul_mem_Ioc (a b : α) : b - toIocDiv hp a b • p ∈ Set.Ioc a (a + p) := (existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.1 #align sub_to_Ioc_div_zsmul_mem_Ioc sub_toIocDiv_zsmul_mem_Ioc theorem toIocDiv_eq_of_sub_zsmul_mem_Ioc (h : b - n • p ∈ Set.Ioc a (a + p)) : toIocDiv hp a b = n := ((existsUnique_sub_zsmul_mem_Ioc hp b a).choose_spec.2 _ h).symm #align to_Ioc_div_eq_of_sub_zsmul_mem_Ioc toIocDiv_eq_of_sub_zsmul_mem_Ioc def toIcoMod (a b : α) : α := b - toIcoDiv hp a b • p #align to_Ico_mod toIcoMod def toIocMod (a b : α) : α := b - toIocDiv hp a b • p #align to_Ioc_mod toIocMod theorem toIcoMod_mem_Ico (a b : α) : toIcoMod hp a b ∈ Set.Ico a (a + p) := sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_mod_mem_Ico toIcoMod_mem_Ico theorem toIcoMod_mem_Ico' (b : α) : toIcoMod hp 0 b ∈ Set.Ico 0 p := by convert toIcoMod_mem_Ico hp 0 b exact (zero_add p).symm #align to_Ico_mod_mem_Ico' toIcoMod_mem_Ico' theorem toIocMod_mem_Ioc (a b : α) : toIocMod hp a b ∈ Set.Ioc a (a + p) := sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_mod_mem_Ioc toIocMod_mem_Ioc theorem left_le_toIcoMod (a b : α) : a ≤ toIcoMod hp a b := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).1 #align left_le_to_Ico_mod left_le_toIcoMod theorem left_lt_toIocMod (a b : α) : a < toIocMod hp a b := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).1 #align left_lt_to_Ioc_mod left_lt_toIocMod theorem toIcoMod_lt_right (a b : α) : toIcoMod hp a b < a + p := (Set.mem_Ico.1 (toIcoMod_mem_Ico hp a b)).2 #align to_Ico_mod_lt_right toIcoMod_lt_right theorem toIocMod_le_right (a b : α) : toIocMod hp a b ≤ a + p := (Set.mem_Ioc.1 (toIocMod_mem_Ioc hp a b)).2 #align to_Ioc_mod_le_right toIocMod_le_right @[simp] theorem self_sub_toIcoDiv_zsmul (a b : α) : b - toIcoDiv hp a b • p = toIcoMod hp a b := rfl #align self_sub_to_Ico_div_zsmul self_sub_toIcoDiv_zsmul @[simp] theorem self_sub_toIocDiv_zsmul (a b : α) : b - toIocDiv hp a b • p = toIocMod hp a b := rfl #align self_sub_to_Ioc_div_zsmul self_sub_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_self (a b : α) : toIcoDiv hp a b • p - b = -toIcoMod hp a b := by rw [toIcoMod, neg_sub] #align to_Ico_div_zsmul_sub_self toIcoDiv_zsmul_sub_self @[simp] theorem toIocDiv_zsmul_sub_self (a b : α) : toIocDiv hp a b • p - b = -toIocMod hp a b := by rw [toIocMod, neg_sub] #align to_Ioc_div_zsmul_sub_self toIocDiv_zsmul_sub_self @[simp] theorem toIcoMod_sub_self (a b : α) : toIcoMod hp a b - b = -toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel_left, neg_smul] #align to_Ico_mod_sub_self toIcoMod_sub_self @[simp] theorem toIocMod_sub_self (a b : α) : toIocMod hp a b - b = -toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel_left, neg_smul] #align to_Ioc_mod_sub_self toIocMod_sub_self @[simp] theorem self_sub_toIcoMod (a b : α) : b - toIcoMod hp a b = toIcoDiv hp a b • p := by rw [toIcoMod, sub_sub_cancel] #align self_sub_to_Ico_mod self_sub_toIcoMod @[simp] theorem self_sub_toIocMod (a b : α) : b - toIocMod hp a b = toIocDiv hp a b • p := by rw [toIocMod, sub_sub_cancel] #align self_sub_to_Ioc_mod self_sub_toIocMod @[simp] theorem toIcoMod_add_toIcoDiv_zsmul (a b : α) : toIcoMod hp a b + toIcoDiv hp a b • p = b := by rw [toIcoMod, sub_add_cancel] #align to_Ico_mod_add_to_Ico_div_zsmul toIcoMod_add_toIcoDiv_zsmul @[simp] theorem toIocMod_add_toIocDiv_zsmul (a b : α) : toIocMod hp a b + toIocDiv hp a b • p = b := by rw [toIocMod, sub_add_cancel] #align to_Ioc_mod_add_to_Ioc_div_zsmul toIocMod_add_toIocDiv_zsmul @[simp] theorem toIcoDiv_zsmul_sub_toIcoMod (a b : α) : toIcoDiv hp a b • p + toIcoMod hp a b = b := by rw [add_comm, toIcoMod_add_toIcoDiv_zsmul] #align to_Ico_div_zsmul_sub_to_Ico_mod toIcoDiv_zsmul_sub_toIcoMod @[simp] theorem toIocDiv_zsmul_sub_toIocMod (a b : α) : toIocDiv hp a b • p + toIocMod hp a b = b := by rw [add_comm, toIocMod_add_toIocDiv_zsmul] #align to_Ioc_div_zsmul_sub_to_Ioc_mod toIocDiv_zsmul_sub_toIocMod theorem toIcoMod_eq_iff : toIcoMod hp a b = c ↔ c ∈ Set.Ico a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIcoMod_mem_Ico hp a b, toIcoDiv hp a b, h ▸ (toIcoMod_add_toIcoDiv_zsmul _ _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIcoDiv_eq_of_sub_zsmul_mem_Ico hp hc, toIcoMod] #align to_Ico_mod_eq_iff toIcoMod_eq_iff theorem toIocMod_eq_iff : toIocMod hp a b = c ↔ c ∈ Set.Ioc a (a + p) ∧ ∃ z : ℤ, b = c + z • p := by refine ⟨fun h => ⟨h ▸ toIocMod_mem_Ioc hp a b, toIocDiv hp a b, h ▸ (toIocMod_add_toIocDiv_zsmul hp _ _).symm⟩, ?_⟩ simp_rw [← @sub_eq_iff_eq_add] rintro ⟨hc, n, rfl⟩ rw [← toIocDiv_eq_of_sub_zsmul_mem_Ioc hp hc, toIocMod] #align to_Ioc_mod_eq_iff toIocMod_eq_iff @[simp] theorem toIcoDiv_apply_left (a : α) : toIcoDiv hp a a = 0 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_left toIcoDiv_apply_left @[simp] theorem toIocDiv_apply_left (a : α) : toIocDiv hp a a = -1 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_left toIocDiv_apply_left @[simp] theorem toIcoMod_apply_left (a : α) : toIcoMod hp a a = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ico_mod_apply_left toIcoMod_apply_left @[simp] theorem toIocMod_apply_left (a : α) : toIocMod hp a a = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, -1, by simp⟩ #align to_Ioc_mod_apply_left toIocMod_apply_left theorem toIcoDiv_apply_right (a : α) : toIcoDiv hp a (a + p) = 1 := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simp [hp] #align to_Ico_div_apply_right toIcoDiv_apply_right theorem toIocDiv_apply_right (a : α) : toIocDiv hp a (a + p) = 0 := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simp [hp] #align to_Ioc_div_apply_right toIocDiv_apply_right theorem toIcoMod_apply_right (a : α) : toIcoMod hp a (a + p) = a := by rw [toIcoMod_eq_iff hp, Set.left_mem_Ico] exact ⟨lt_add_of_pos_right _ hp, 1, by simp⟩ #align to_Ico_mod_apply_right toIcoMod_apply_right theorem toIocMod_apply_right (a : α) : toIocMod hp a (a + p) = a + p := by rw [toIocMod_eq_iff hp, Set.right_mem_Ioc] exact ⟨lt_add_of_pos_right _ hp, 0, by simp⟩ #align to_Ioc_mod_apply_right toIocMod_apply_right @[simp] theorem toIcoDiv_add_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b + m • p) = toIcoDiv hp a b + m := toIcoDiv_eq_of_sub_zsmul_mem_Ico hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul toIcoDiv_add_zsmul @[simp] theorem toIcoDiv_add_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a + m • p) b = toIcoDiv hp a b - m := by refine toIcoDiv_eq_of_sub_zsmul_mem_Ico _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIcoDiv_zsmul_mem_Ico hp a b #align to_Ico_div_add_zsmul' toIcoDiv_add_zsmul' @[simp] theorem toIocDiv_add_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b + m • p) = toIocDiv hp a b + m := toIocDiv_eq_of_sub_zsmul_mem_Ioc hp <| by simpa only [add_smul, add_sub_add_right_eq_sub] using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul toIocDiv_add_zsmul @[simp] theorem toIocDiv_add_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a + m • p) b = toIocDiv hp a b - m := by refine toIocDiv_eq_of_sub_zsmul_mem_Ioc _ ?_ rw [sub_smul, ← sub_add, add_right_comm] simpa using sub_toIocDiv_zsmul_mem_Ioc hp a b #align to_Ioc_div_add_zsmul' toIocDiv_add_zsmul' @[simp] theorem toIcoDiv_zsmul_add (a b : α) (m : ℤ) : toIcoDiv hp a (m • p + b) = m + toIcoDiv hp a b := by rw [add_comm, toIcoDiv_add_zsmul, add_comm] #align to_Ico_div_zsmul_add toIcoDiv_zsmul_add @[simp] theorem toIocDiv_zsmul_add (a b : α) (m : ℤ) : toIocDiv hp a (m • p + b) = m + toIocDiv hp a b := by rw [add_comm, toIocDiv_add_zsmul, add_comm] #align to_Ioc_div_zsmul_add toIocDiv_zsmul_add @[simp] theorem toIcoDiv_sub_zsmul (a b : α) (m : ℤ) : toIcoDiv hp a (b - m • p) = toIcoDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul, sub_eq_add_neg] #align to_Ico_div_sub_zsmul toIcoDiv_sub_zsmul @[simp] theorem toIcoDiv_sub_zsmul' (a b : α) (m : ℤ) : toIcoDiv hp (a - m • p) b = toIcoDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIcoDiv_add_zsmul', sub_neg_eq_add] #align to_Ico_div_sub_zsmul' toIcoDiv_sub_zsmul' @[simp] theorem toIocDiv_sub_zsmul (a b : α) (m : ℤ) : toIocDiv hp a (b - m • p) = toIocDiv hp a b - m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul, sub_eq_add_neg] #align to_Ioc_div_sub_zsmul toIocDiv_sub_zsmul @[simp] theorem toIocDiv_sub_zsmul' (a b : α) (m : ℤ) : toIocDiv hp (a - m • p) b = toIocDiv hp a b + m := by rw [sub_eq_add_neg, ← neg_smul, toIocDiv_add_zsmul', sub_neg_eq_add] #align to_Ioc_div_sub_zsmul' toIocDiv_sub_zsmul' @[simp] theorem toIcoDiv_add_right (a b : α) : toIcoDiv hp a (b + p) = toIcoDiv hp a b + 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul hp a b 1 #align to_Ico_div_add_right toIcoDiv_add_right @[simp] theorem toIcoDiv_add_right' (a b : α) : toIcoDiv hp (a + p) b = toIcoDiv hp a b - 1 := by simpa only [one_zsmul] using toIcoDiv_add_zsmul' hp a b 1 #align to_Ico_div_add_right' toIcoDiv_add_right' @[simp] theorem toIocDiv_add_right (a b : α) : toIocDiv hp a (b + p) = toIocDiv hp a b + 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul hp a b 1 #align to_Ioc_div_add_right toIocDiv_add_right @[simp] theorem toIocDiv_add_right' (a b : α) : toIocDiv hp (a + p) b = toIocDiv hp a b - 1 := by simpa only [one_zsmul] using toIocDiv_add_zsmul' hp a b 1 #align to_Ioc_div_add_right' toIocDiv_add_right' @[simp] theorem toIcoDiv_add_left (a b : α) : toIcoDiv hp a (p + b) = toIcoDiv hp a b + 1 := by rw [add_comm, toIcoDiv_add_right] #align to_Ico_div_add_left toIcoDiv_add_left @[simp]
Mathlib/Algebra/Order/ToIntervalMod.lean
324
325
theorem toIcoDiv_add_left' (a b : α) : toIcoDiv hp (p + a) b = toIcoDiv hp a b - 1 := by
rw [add_comm, toIcoDiv_add_right']
import Mathlib.Algebra.Field.Opposite import Mathlib.Algebra.Group.Subgroup.ZPowers import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Ring.NegOnePow import Mathlib.Algebra.Order.Archimedean import Mathlib.GroupTheory.Coset #align_import algebra.periodic from "leanprover-community/mathlib"@"30413fc89f202a090a54d78e540963ed3de0056e" variable {α β γ : Type*} {f g : α → β} {c c₁ c₂ x : α} open Set namespace Function @[simp] def Periodic [Add α] (f : α → β) (c : α) : Prop := ∀ x : α, f (x + c) = f x #align function.periodic Function.Periodic protected theorem Periodic.funext [Add α] (h : Periodic f c) : (fun x => f (x + c)) = f := funext h #align function.periodic.funext Function.Periodic.funext protected theorem Periodic.comp [Add α] (h : Periodic f c) (g : β → γ) : Periodic (g ∘ f) c := by simp_all #align function.periodic.comp Function.Periodic.comp theorem Periodic.comp_addHom [Add α] [Add γ] (h : Periodic f c) (g : AddHom γ α) (g_inv : α → γ) (hg : RightInverse g_inv g) : Periodic (f ∘ g) (g_inv c) := fun x => by simp only [hg c, h (g x), map_add, comp_apply] #align function.periodic.comp_add_hom Function.Periodic.comp_addHom @[to_additive] protected theorem Periodic.mul [Add α] [Mul β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f * g) c := by simp_all #align function.periodic.mul Function.Periodic.mul #align function.periodic.add Function.Periodic.add @[to_additive] protected theorem Periodic.div [Add α] [Div β] (hf : Periodic f c) (hg : Periodic g c) : Periodic (f / g) c := by simp_all #align function.periodic.div Function.Periodic.div #align function.periodic.sub Function.Periodic.sub @[to_additive] theorem _root_.List.periodic_prod [Add α] [Monoid β] (l : List (α → β)) (hl : ∀ f ∈ l, Periodic f c) : Periodic l.prod c := by induction' l with g l ih hl · simp · rw [List.forall_mem_cons] at hl simpa only [List.prod_cons] using hl.1.mul (ih hl.2) #align list.periodic_prod List.periodic_prod #align list.periodic_sum List.periodic_sum @[to_additive] theorem _root_.Multiset.periodic_prod [Add α] [CommMonoid β] (s : Multiset (α → β)) (hs : ∀ f ∈ s, Periodic f c) : Periodic s.prod c := (s.prod_toList ▸ s.toList.periodic_prod) fun f hf => hs f <| Multiset.mem_toList.mp hf #align multiset.periodic_prod Multiset.periodic_prod #align multiset.periodic_sum Multiset.periodic_sum @[to_additive] theorem _root_.Finset.periodic_prod [Add α] [CommMonoid β] {ι : Type*} {f : ι → α → β} (s : Finset ι) (hs : ∀ i ∈ s, Periodic (f i) c) : Periodic (∏ i ∈ s, f i) c := s.prod_to_list f ▸ (s.toList.map f).periodic_prod (by simpa [-Periodic] ) #align finset.periodic_prod Finset.periodic_prod #align finset.periodic_sum Finset.periodic_sum @[to_additive] protected theorem Periodic.smul [Add α] [SMul γ β] (h : Periodic f c) (a : γ) : Periodic (a • f) c := by simp_all #align function.periodic.smul Function.Periodic.smul #align function.periodic.vadd Function.Periodic.vadd protected theorem Periodic.const_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by simpa only [smul_add, smul_inv_smul] using h (a • x) #align function.periodic.const_smul Function.Periodic.const_smul protected theorem Periodic.const_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a • x)) (a⁻¹ • c) := fun x => by by_cases ha : a = 0 · simp only [ha, zero_smul] · simpa only [smul_add, smul_inv_smul₀ ha] using h (a • x) #align function.periodic.const_smul₀ Function.Periodic.const_smul₀ protected theorem Periodic.const_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a * x)) (a⁻¹ * c) := Periodic.const_smul₀ h a #align function.periodic.const_mul Function.Periodic.const_mul theorem Periodic.const_inv_smul [AddMonoid α] [Group γ] [DistribMulAction γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul a⁻¹ #align function.periodic.const_inv_smul Function.Periodic.const_inv_smul theorem Periodic.const_inv_smul₀ [AddCommMonoid α] [DivisionSemiring γ] [Module γ α] (h : Periodic f c) (a : γ) : Periodic (fun x => f (a⁻¹ • x)) (a • c) := by simpa only [inv_inv] using h.const_smul₀ a⁻¹ #align function.periodic.const_inv_smul₀ Function.Periodic.const_inv_smul₀ theorem Periodic.const_inv_mul [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (a⁻¹ * x)) (a * c) := h.const_inv_smul₀ a #align function.periodic.const_inv_mul Function.Periodic.const_inv_mul theorem Periodic.mul_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c * a⁻¹) := h.const_smul₀ (MulOpposite.op a) #align function.periodic.mul_const Function.Periodic.mul_const theorem Periodic.mul_const' [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a)) (c / a) := by simpa only [div_eq_mul_inv] using h.mul_const a #align function.periodic.mul_const' Function.Periodic.mul_const' theorem Periodic.mul_const_inv [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x * a⁻¹)) (c * a) := h.const_inv_smul₀ (MulOpposite.op a) #align function.periodic.mul_const_inv Function.Periodic.mul_const_inv
Mathlib/Algebra/Periodic.lean
152
153
theorem Periodic.div_const [DivisionSemiring α] (h : Periodic f c) (a : α) : Periodic (fun x => f (x / a)) (c * a) := by
simpa only [div_eq_mul_inv] using h.mul_const_inv a
import Mathlib.Data.ZMod.Quotient #align_import group_theory.complement from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" open Set open scoped Pointwise namespace Subgroup variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G) @[to_additive "`S` and `T` are complements if `(+) : S × T → G` is a bijection"] def IsComplement : Prop := Function.Bijective fun x : S × T => x.1.1 * x.2.1 #align subgroup.is_complement Subgroup.IsComplement #align add_subgroup.is_complement AddSubgroup.IsComplement @[to_additive "`H` and `K` are complements if `(+) : H × K → G` is a bijection"] abbrev IsComplement' := IsComplement (H : Set G) (K : Set G) #align subgroup.is_complement' Subgroup.IsComplement' #align add_subgroup.is_complement' AddSubgroup.IsComplement' @[to_additive "The set of left-complements of `T : Set G`"] def leftTransversals : Set (Set G) := { S : Set G | IsComplement S T } #align subgroup.left_transversals Subgroup.leftTransversals #align add_subgroup.left_transversals AddSubgroup.leftTransversals @[to_additive "The set of right-complements of `S : Set G`"] def rightTransversals : Set (Set G) := { T : Set G | IsComplement S T } #align subgroup.right_transversals Subgroup.rightTransversals #align add_subgroup.right_transversals AddSubgroup.rightTransversals variable {H K S T} @[to_additive] theorem isComplement'_def : IsComplement' H K ↔ IsComplement (H : Set G) (K : Set G) := Iff.rfl #align subgroup.is_complement'_def Subgroup.isComplement'_def #align add_subgroup.is_complement'_def AddSubgroup.isComplement'_def @[to_additive] theorem isComplement_iff_existsUnique : IsComplement S T ↔ ∀ g : G, ∃! x : S × T, x.1.1 * x.2.1 = g := Function.bijective_iff_existsUnique _ #align subgroup.is_complement_iff_exists_unique Subgroup.isComplement_iff_existsUnique #align add_subgroup.is_complement_iff_exists_unique AddSubgroup.isComplement_iff_existsUnique @[to_additive] theorem IsComplement.existsUnique (h : IsComplement S T) (g : G) : ∃! x : S × T, x.1.1 * x.2.1 = g := isComplement_iff_existsUnique.mp h g #align subgroup.is_complement.exists_unique Subgroup.IsComplement.existsUnique #align add_subgroup.is_complement.exists_unique AddSubgroup.IsComplement.existsUnique @[to_additive] theorem IsComplement'.symm (h : IsComplement' H K) : IsComplement' K H := by let ϕ : H × K ≃ K × H := Equiv.mk (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => ⟨x.2⁻¹, x.1⁻¹⟩) (fun x => Prod.ext (inv_inv _) (inv_inv _)) fun x => Prod.ext (inv_inv _) (inv_inv _) let ψ : G ≃ G := Equiv.mk (fun g : G => g⁻¹) (fun g : G => g⁻¹) inv_inv inv_inv suffices hf : (ψ ∘ fun x : H × K => x.1.1 * x.2.1) = (fun x : K × H => x.1.1 * x.2.1) ∘ ϕ by rw [isComplement'_def, IsComplement, ← Equiv.bijective_comp ϕ] apply (congr_arg Function.Bijective hf).mp -- Porting note: This was a `rw` in mathlib3 rwa [ψ.comp_bijective] exact funext fun x => mul_inv_rev _ _ #align subgroup.is_complement'.symm Subgroup.IsComplement'.symm #align add_subgroup.is_complement'.symm AddSubgroup.IsComplement'.symm @[to_additive] theorem isComplement'_comm : IsComplement' H K ↔ IsComplement' K H := ⟨IsComplement'.symm, IsComplement'.symm⟩ #align subgroup.is_complement'_comm Subgroup.isComplement'_comm #align add_subgroup.is_complement'_comm AddSubgroup.isComplement'_comm @[to_additive] theorem isComplement_univ_singleton {g : G} : IsComplement (univ : Set G) {g} := ⟨fun ⟨_, _, rfl⟩ ⟨_, _, rfl⟩ h => Prod.ext (Subtype.ext (mul_right_cancel h)) rfl, fun x => ⟨⟨⟨x * g⁻¹, ⟨⟩⟩, g, rfl⟩, inv_mul_cancel_right x g⟩⟩ #align subgroup.is_complement_top_singleton Subgroup.isComplement_univ_singleton #align add_subgroup.is_complement_top_singleton AddSubgroup.isComplement_univ_singleton @[to_additive] theorem isComplement_singleton_univ {g : G} : IsComplement ({g} : Set G) univ := ⟨fun ⟨⟨_, rfl⟩, _⟩ ⟨⟨_, rfl⟩, _⟩ h => Prod.ext rfl (Subtype.ext (mul_left_cancel h)), fun x => ⟨⟨⟨g, rfl⟩, g⁻¹ * x, ⟨⟩⟩, mul_inv_cancel_left g x⟩⟩ #align subgroup.is_complement_singleton_top Subgroup.isComplement_singleton_univ #align add_subgroup.is_complement_singleton_top AddSubgroup.isComplement_singleton_univ @[to_additive] theorem isComplement_singleton_left {g : G} : IsComplement {g} S ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => (congr_arg _ h).mpr isComplement_singleton_univ⟩ obtain ⟨⟨⟨z, rfl : z = g⟩, y, _⟩, hy⟩ := h.2 (g * x) rwa [← mul_left_cancel hy] #align subgroup.is_complement_singleton_left Subgroup.isComplement_singleton_left #align add_subgroup.is_complement_singleton_left AddSubgroup.isComplement_singleton_left @[to_additive] theorem isComplement_singleton_right {g : G} : IsComplement S {g} ↔ S = univ := by refine ⟨fun h => top_le_iff.mp fun x _ => ?_, fun h => h ▸ isComplement_univ_singleton⟩ obtain ⟨y, hy⟩ := h.2 (x * g) conv_rhs at hy => rw [← show y.2.1 = g from y.2.2] rw [← mul_right_cancel hy] exact y.1.2 #align subgroup.is_complement_singleton_right Subgroup.isComplement_singleton_right #align add_subgroup.is_complement_singleton_right AddSubgroup.isComplement_singleton_right @[to_additive] theorem isComplement_univ_left : IsComplement univ S ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.2.1, a.2.2⟩ · have : (⟨⟨_, mem_top a⁻¹⟩, ⟨a, ha⟩⟩ : (⊤ : Set G) × S) = ⟨⟨_, mem_top b⁻¹⟩, ⟨b, hb⟩⟩ := h.1 ((inv_mul_self a).trans (inv_mul_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).2 · rintro ⟨g, rfl⟩ exact isComplement_univ_singleton #align subgroup.is_complement_top_left Subgroup.isComplement_univ_left #align add_subgroup.is_complement_top_left AddSubgroup.isComplement_univ_left @[to_additive] theorem isComplement_univ_right : IsComplement S univ ↔ ∃ g : G, S = {g} := by refine ⟨fun h => Set.exists_eq_singleton_iff_nonempty_subsingleton.mpr ⟨?_, fun a ha b hb => ?_⟩, ?_⟩ · obtain ⟨a, _⟩ := h.2 1 exact ⟨a.1.1, a.1.2⟩ · have : (⟨⟨a, ha⟩, ⟨_, mem_top a⁻¹⟩⟩ : S × (⊤ : Set G)) = ⟨⟨b, hb⟩, ⟨_, mem_top b⁻¹⟩⟩ := h.1 ((mul_inv_self a).trans (mul_inv_self b).symm) exact Subtype.ext_iff.mp (Prod.ext_iff.mp this).1 · rintro ⟨g, rfl⟩ exact isComplement_singleton_univ #align subgroup.is_complement_top_right Subgroup.isComplement_univ_right #align add_subgroup.is_complement_top_right AddSubgroup.isComplement_univ_right @[to_additive] lemma IsComplement.mul_eq (h : IsComplement S T) : S * T = univ := eq_univ_of_forall fun x ↦ by simpa [mem_mul] using (h.existsUnique x).exists @[to_additive AddSubgroup.IsComplement.card_mul_card] lemma IsComplement.card_mul_card (h : IsComplement S T) : Nat.card S * Nat.card T = Nat.card G := (Nat.card_prod _ _).symm.trans <| Nat.card_congr <| Equiv.ofBijective _ h @[to_additive] theorem isComplement'_top_bot : IsComplement' (⊤ : Subgroup G) ⊥ := isComplement_univ_singleton #align subgroup.is_complement'_top_bot Subgroup.isComplement'_top_bot #align add_subgroup.is_complement'_top_bot AddSubgroup.isComplement'_top_bot @[to_additive] theorem isComplement'_bot_top : IsComplement' (⊥ : Subgroup G) ⊤ := isComplement_singleton_univ #align subgroup.is_complement'_bot_top Subgroup.isComplement'_bot_top #align add_subgroup.is_complement'_bot_top AddSubgroup.isComplement'_bot_top @[to_additive (attr := simp)] theorem isComplement'_bot_left : IsComplement' ⊥ H ↔ H = ⊤ := isComplement_singleton_left.trans coe_eq_univ #align subgroup.is_complement'_bot_left Subgroup.isComplement'_bot_left #align add_subgroup.is_complement'_bot_left AddSubgroup.isComplement'_bot_left @[to_additive (attr := simp)] theorem isComplement'_bot_right : IsComplement' H ⊥ ↔ H = ⊤ := isComplement_singleton_right.trans coe_eq_univ #align subgroup.is_complement'_bot_right Subgroup.isComplement'_bot_right #align add_subgroup.is_complement'_bot_right AddSubgroup.isComplement'_bot_right @[to_additive (attr := simp)] theorem isComplement'_top_left : IsComplement' ⊤ H ↔ H = ⊥ := isComplement_univ_left.trans coe_eq_singleton #align subgroup.is_complement'_top_left Subgroup.isComplement'_top_left #align add_subgroup.is_complement'_top_left AddSubgroup.isComplement'_top_left @[to_additive (attr := simp)] theorem isComplement'_top_right : IsComplement' H ⊤ ↔ H = ⊥ := isComplement_univ_right.trans coe_eq_singleton #align subgroup.is_complement'_top_right Subgroup.isComplement'_top_right #align add_subgroup.is_complement'_top_right AddSubgroup.isComplement'_top_right @[to_additive] theorem mem_leftTransversals_iff_existsUnique_inv_mul_mem : S ∈ leftTransversals T ↔ ∀ g : G, ∃! s : S, (s : G)⁻¹ * g ∈ T := by rw [leftTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.1, (congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq h1)).mp x.2.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨y, (↑y)⁻¹ * g, hy⟩ (mul_inv_cancel_left ↑y g))).1⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨x, (↑x)⁻¹ * g, h1⟩, mul_inv_cancel_left (↑x) g, fun y hy => ?_⟩ have hf := h2 y.1 ((congr_arg (· ∈ T) (eq_inv_mul_of_mul_eq hy)).mp y.2.2) exact Prod.ext hf (Subtype.ext (eq_inv_mul_of_mul_eq (hf ▸ hy))) #align subgroup.mem_left_transversals_iff_exists_unique_inv_mul_mem Subgroup.mem_leftTransversals_iff_existsUnique_inv_mul_mem #align add_subgroup.mem_left_transversals_iff_exists_unique_neg_add_mem AddSubgroup.mem_leftTransversals_iff_existsUnique_neg_add_mem @[to_additive] theorem mem_rightTransversals_iff_existsUnique_mul_inv_mem : S ∈ rightTransversals T ↔ ∀ g : G, ∃! s : S, g * (s : G)⁻¹ ∈ T := by rw [rightTransversals, Set.mem_setOf_eq, isComplement_iff_existsUnique] refine ⟨fun h g => ?_, fun h g => ?_⟩ · obtain ⟨x, h1, h2⟩ := h g exact ⟨x.2, (congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq h1)).mp x.1.2, fun y hy => (Prod.ext_iff.mp (h2 ⟨⟨g * (↑y)⁻¹, hy⟩, y⟩ (inv_mul_cancel_right g y))).2⟩ · obtain ⟨x, h1, h2⟩ := h g refine ⟨⟨⟨g * (↑x)⁻¹, h1⟩, x⟩, inv_mul_cancel_right g x, fun y hy => ?_⟩ have hf := h2 y.2 ((congr_arg (· ∈ T) (eq_mul_inv_of_mul_eq hy)).mp y.1.2) exact Prod.ext (Subtype.ext (eq_mul_inv_of_mul_eq (hf ▸ hy))) hf #align subgroup.mem_right_transversals_iff_exists_unique_mul_inv_mem Subgroup.mem_rightTransversals_iff_existsUnique_mul_inv_mem #align add_subgroup.mem_right_transversals_iff_exists_unique_add_neg_mem AddSubgroup.mem_rightTransversals_iff_existsUnique_add_neg_mem @[to_additive]
Mathlib/GroupTheory/Complement.lean
248
253
theorem mem_leftTransversals_iff_existsUnique_quotient_mk''_eq : S ∈ leftTransversals (H : Set G) ↔ ∀ q : Quotient (QuotientGroup.leftRel H), ∃! s : S, Quotient.mk'' s.1 = q := by
simp_rw [mem_leftTransversals_iff_existsUnique_inv_mul_mem, SetLike.mem_coe, ← QuotientGroup.eq'] exact ⟨fun h q => Quotient.inductionOn' q h, fun h g => h (Quotient.mk'' g)⟩
import Mathlib.RingTheory.IntegralClosure import Mathlib.RingTheory.FractionalIdeal.Basic #align_import ring_theory.fractional_ideal from "leanprover-community/mathlib"@"ed90a7d327c3a5caf65a6faf7e8a0d63c4605df7" open IsLocalization Pointwise nonZeroDivisors namespace FractionalIdeal open Set Submodule variable {R : Type*} [CommRing R] {S : Submonoid R} {P : Type*} [CommRing P] variable [Algebra R P] [loc : IsLocalization S P] section variable {P' : Type*} [CommRing P'] [Algebra R P'] [loc' : IsLocalization S P'] variable {P'' : Type*} [CommRing P''] [Algebra R P''] [loc'' : IsLocalization S P''] theorem _root_.IsFractional.map (g : P →ₐ[R] P') {I : Submodule R P} : IsFractional S I → IsFractional S (Submodule.map g.toLinearMap I) | ⟨a, a_nonzero, hI⟩ => ⟨a, a_nonzero, fun b hb => by obtain ⟨b', b'_mem, hb'⟩ := Submodule.mem_map.mp hb rw [AlgHom.toLinearMap_apply] at hb' obtain ⟨x, hx⟩ := hI b' b'_mem use x rw [← g.commutes, hx, g.map_smul, hb']⟩ #align is_fractional.map IsFractional.map def map (g : P →ₐ[R] P') : FractionalIdeal S P → FractionalIdeal S P' := fun I => ⟨Submodule.map g.toLinearMap I, I.isFractional.map g⟩ #align fractional_ideal.map FractionalIdeal.map @[simp, norm_cast] theorem coe_map (g : P →ₐ[R] P') (I : FractionalIdeal S P) : ↑(map g I) = Submodule.map g.toLinearMap I := rfl #align fractional_ideal.coe_map FractionalIdeal.coe_map @[simp] theorem mem_map {I : FractionalIdeal S P} {g : P →ₐ[R] P'} {y : P'} : y ∈ I.map g ↔ ∃ x, x ∈ I ∧ g x = y := Submodule.mem_map #align fractional_ideal.mem_map FractionalIdeal.mem_map variable (I J : FractionalIdeal S P) (g : P →ₐ[R] P') @[simp] theorem map_id : I.map (AlgHom.id _ _) = I := coeToSubmodule_injective (Submodule.map_id (I : Submodule R P)) #align fractional_ideal.map_id FractionalIdeal.map_id @[simp] theorem map_comp (g' : P' →ₐ[R] P'') : I.map (g'.comp g) = (I.map g).map g' := coeToSubmodule_injective (Submodule.map_comp g.toLinearMap g'.toLinearMap I) #align fractional_ideal.map_comp FractionalIdeal.map_comp @[simp, norm_cast] theorem map_coeIdeal (I : Ideal R) : (I : FractionalIdeal S P).map g = I := by ext x simp only [mem_coeIdeal] constructor · rintro ⟨_, ⟨y, hy, rfl⟩, rfl⟩ exact ⟨y, hy, (g.commutes y).symm⟩ · rintro ⟨y, hy, rfl⟩ exact ⟨_, ⟨y, hy, rfl⟩, g.commutes y⟩ #align fractional_ideal.map_coe_ideal FractionalIdeal.map_coeIdeal @[simp] theorem map_one : (1 : FractionalIdeal S P).map g = 1 := map_coeIdeal g ⊤ #align fractional_ideal.map_one FractionalIdeal.map_one @[simp] theorem map_zero : (0 : FractionalIdeal S P).map g = 0 := map_coeIdeal g 0 #align fractional_ideal.map_zero FractionalIdeal.map_zero @[simp] theorem map_add : (I + J).map g = I.map g + J.map g := coeToSubmodule_injective (Submodule.map_sup _ _ _) #align fractional_ideal.map_add FractionalIdeal.map_add @[simp] theorem map_mul : (I * J).map g = I.map g * J.map g := by simp only [mul_def] exact coeToSubmodule_injective (Submodule.map_mul _ _ _) #align fractional_ideal.map_mul FractionalIdeal.map_mul @[simp] theorem map_map_symm (g : P ≃ₐ[R] P') : (I.map (g : P →ₐ[R] P')).map (g.symm : P' →ₐ[R] P) = I := by rw [← map_comp, g.symm_comp, map_id] #align fractional_ideal.map_map_symm FractionalIdeal.map_map_symm @[simp] theorem map_symm_map (I : FractionalIdeal S P') (g : P ≃ₐ[R] P') : (I.map (g.symm : P' →ₐ[R] P)).map (g : P →ₐ[R] P') = I := by rw [← map_comp, g.comp_symm, map_id] #align fractional_ideal.map_symm_map FractionalIdeal.map_symm_map theorem map_mem_map {f : P →ₐ[R] P'} (h : Function.Injective f) {x : P} {I : FractionalIdeal S P} : f x ∈ map f I ↔ x ∈ I := mem_map.trans ⟨fun ⟨_, hx', x'_eq⟩ => h x'_eq ▸ hx', fun h => ⟨x, h, rfl⟩⟩ #align fractional_ideal.map_mem_map FractionalIdeal.map_mem_map theorem map_injective (f : P →ₐ[R] P') (h : Function.Injective f) : Function.Injective (map f : FractionalIdeal S P → FractionalIdeal S P') := fun _ _ hIJ => ext fun _ => (map_mem_map h).symm.trans (hIJ.symm ▸ map_mem_map h) #align fractional_ideal.map_injective FractionalIdeal.map_injective def mapEquiv (g : P ≃ₐ[R] P') : FractionalIdeal S P ≃+* FractionalIdeal S P' where toFun := map g invFun := map g.symm map_add' I J := map_add I J _ map_mul' I J := map_mul I J _ left_inv I := by rw [← map_comp, AlgEquiv.symm_comp, map_id] right_inv I := by rw [← map_comp, AlgEquiv.comp_symm, map_id] #align fractional_ideal.map_equiv FractionalIdeal.mapEquiv @[simp] theorem coeFun_mapEquiv (g : P ≃ₐ[R] P') : (mapEquiv g : FractionalIdeal S P → FractionalIdeal S P') = map g := rfl #align fractional_ideal.coe_fun_map_equiv FractionalIdeal.coeFun_mapEquiv @[simp] theorem mapEquiv_apply (g : P ≃ₐ[R] P') (I : FractionalIdeal S P) : mapEquiv g I = map (↑g) I := rfl #align fractional_ideal.map_equiv_apply FractionalIdeal.mapEquiv_apply @[simp] theorem mapEquiv_symm (g : P ≃ₐ[R] P') : ((mapEquiv g).symm : FractionalIdeal S P' ≃+* _) = mapEquiv g.symm := rfl #align fractional_ideal.map_equiv_symm FractionalIdeal.mapEquiv_symm @[simp] theorem mapEquiv_refl : mapEquiv AlgEquiv.refl = RingEquiv.refl (FractionalIdeal S P) := RingEquiv.ext fun x => by simp #align fractional_ideal.map_equiv_refl FractionalIdeal.mapEquiv_refl theorem isFractional_span_iff {s : Set P} : IsFractional S (span R s) ↔ ∃ a ∈ S, ∀ b : P, b ∈ s → IsInteger R (a • b) := ⟨fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => h b (subset_span hb)⟩, fun ⟨a, a_mem, h⟩ => ⟨a, a_mem, fun b hb => span_induction hb h (by rw [smul_zero] exact isInteger_zero) (fun x y hx hy => by rw [smul_add] exact isInteger_add hx hy) fun s x hx => by rw [smul_comm] exact isInteger_smul hx⟩⟩ #align fractional_ideal.is_fractional_span_iff FractionalIdeal.isFractional_span_iff theorem isFractional_of_fg {I : Submodule R P} (hI : I.FG) : IsFractional S I := by rcases hI with ⟨I, rfl⟩ rcases exist_integer_multiples_of_finset S I with ⟨⟨s, hs1⟩, hs⟩ rw [isFractional_span_iff] exact ⟨s, hs1, hs⟩ #align fractional_ideal.is_fractional_of_fg FractionalIdeal.isFractional_of_fg theorem mem_span_mul_finite_of_mem_mul {I J : FractionalIdeal S P} {x : P} (hx : x ∈ I * J) : ∃ T T' : Finset P, (T : Set P) ⊆ I ∧ (T' : Set P) ⊆ J ∧ x ∈ span R (T * T' : Set P) := Submodule.mem_span_mul_finite_of_mem_mul (by simpa using mem_coe.mpr hx) #align fractional_ideal.mem_span_mul_finite_of_mem_mul FractionalIdeal.mem_span_mul_finite_of_mem_mul variable (S) theorem coeIdeal_fg (inj : Function.Injective (algebraMap R P)) (I : Ideal R) : FG ((I : FractionalIdeal S P) : Submodule R P) ↔ I.FG := coeSubmodule_fg _ inj _ #align fractional_ideal.coe_ideal_fg FractionalIdeal.coeIdeal_fg variable {S} theorem fg_unit (I : (FractionalIdeal S P)ˣ) : FG (I : Submodule R P) := Submodule.fg_unit <| Units.map (coeSubmoduleHom S P).toMonoidHom I #align fractional_ideal.fg_unit FractionalIdeal.fg_unit theorem fg_of_isUnit (I : FractionalIdeal S P) (h : IsUnit I) : FG (I : Submodule R P) := fg_unit h.unit #align fractional_ideal.fg_of_is_unit FractionalIdeal.fg_of_isUnit theorem _root_.Ideal.fg_of_isUnit (inj : Function.Injective (algebraMap R P)) (I : Ideal R) (h : IsUnit (I : FractionalIdeal S P)) : I.FG := by rw [← coeIdeal_fg S inj I] exact FractionalIdeal.fg_of_isUnit I h #align ideal.fg_of_is_unit Ideal.fg_of_isUnit variable (S P P') noncomputable irreducible_def canonicalEquiv : FractionalIdeal S P ≃+* FractionalIdeal S P' := mapEquiv { ringEquivOfRingEquiv P P' (RingEquiv.refl R) (show S.map _ = S by rw [RingEquiv.toMonoidHom_refl, Submonoid.map_id]) with commutes' := fun r => ringEquivOfRingEquiv_eq _ _ } #align fractional_ideal.canonical_equiv FractionalIdeal.canonicalEquiv @[simp] theorem mem_canonicalEquiv_apply {I : FractionalIdeal S P} {x : P'} : x ∈ canonicalEquiv S P P' I ↔ ∃ y ∈ I, IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) (y : P) = x := by rw [canonicalEquiv, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.mem_canonical_equiv_apply FractionalIdeal.mem_canonicalEquiv_apply @[simp] theorem canonicalEquiv_symm : (canonicalEquiv S P P').symm = canonicalEquiv S P' P := RingEquiv.ext fun I => SetLike.ext_iff.mpr fun x => by rw [mem_canonicalEquiv_apply, canonicalEquiv, mapEquiv_symm, mapEquiv_apply, mem_map] exact ⟨fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩, fun ⟨y, mem, Eq⟩ => ⟨y, mem, Eq⟩⟩ #align fractional_ideal.canonical_equiv_symm FractionalIdeal.canonicalEquiv_symm theorem canonicalEquiv_flip (I) : canonicalEquiv S P P' (canonicalEquiv S P' P I) = I := by rw [← canonicalEquiv_symm]; erw [RingEquiv.apply_symm_apply] #align fractional_ideal.canonical_equiv_flip FractionalIdeal.canonicalEquiv_flip @[simp] theorem canonicalEquiv_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] (I : FractionalIdeal S P) : canonicalEquiv S P' P'' (canonicalEquiv S P P' I) = canonicalEquiv S P P'' I := by ext simp only [IsLocalization.map_map, RingHomInvPair.comp_eq₂, mem_canonicalEquiv_apply, exists_prop, exists_exists_and_eq_and] #align fractional_ideal.canonical_equiv_canonical_equiv FractionalIdeal.canonicalEquiv_canonicalEquiv theorem canonicalEquiv_trans_canonicalEquiv (P'' : Type*) [CommRing P''] [Algebra R P''] [IsLocalization S P''] : (canonicalEquiv S P P').trans (canonicalEquiv S P' P'') = canonicalEquiv S P P'' := RingEquiv.ext (canonicalEquiv_canonicalEquiv S P P' P'') #align fractional_ideal.canonical_equiv_trans_canonical_equiv FractionalIdeal.canonicalEquiv_trans_canonicalEquiv @[simp] theorem canonicalEquiv_coeIdeal (I : Ideal R) : canonicalEquiv S P P' I = I := by ext simp [IsLocalization.map_eq] #align fractional_ideal.canonical_equiv_coe_ideal FractionalIdeal.canonicalEquiv_coeIdeal @[simp] theorem canonicalEquiv_self : canonicalEquiv S P P = RingEquiv.refl _ := by rw [← canonicalEquiv_trans_canonicalEquiv S P P] convert (canonicalEquiv S P P).symm_trans_self exact (canonicalEquiv_symm S P P).symm #align fractional_ideal.canonical_equiv_self FractionalIdeal.canonicalEquiv_self end section PrincipalIdeal variable {R₁ : Type*} [CommRing R₁] {K : Type*} [Field K] variable [Algebra R₁ K] [IsFractionRing R₁ K] open scoped Classical variable (R₁) -- Porting note: `@[simps]` generated a `Subtype.val` coercion instead of a -- `FractionalIdeal.coeToSubmodule` coercion def spanFinset {ι : Type*} (s : Finset ι) (f : ι → K) : FractionalIdeal R₁⁰ K := ⟨Submodule.span R₁ (f '' s), by obtain ⟨a', ha'⟩ := IsLocalization.exist_integer_multiples R₁⁰ s f refine ⟨a', a'.2, fun x hx => Submodule.span_induction hx ?_ ?_ ?_ ?_⟩ · rintro _ ⟨i, hi, rfl⟩ exact ha' i hi · rw [smul_zero] exact IsLocalization.isInteger_zero · intro x y hx hy rw [smul_add] exact IsLocalization.isInteger_add hx hy · intro c x hx rw [smul_comm] exact IsLocalization.isInteger_smul hx⟩ #align fractional_ideal.span_finset FractionalIdeal.spanFinset @[simp] lemma spanFinset_coe {ι : Type*} (s : Finset ι) (f : ι → K) : (spanFinset R₁ s f : Submodule R₁ K) = Submodule.span R₁ (f '' s) := rfl variable {R₁} @[simp] theorem spanFinset_eq_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f = 0 ↔ ∀ j ∈ s, f j = 0 := by simp only [← coeToSubmodule_inj, spanFinset_coe, coe_zero, Submodule.span_eq_bot, Set.mem_image, Finset.mem_coe, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] #align fractional_ideal.span_finset_eq_zero FractionalIdeal.spanFinset_eq_zero theorem spanFinset_ne_zero {ι : Type*} {s : Finset ι} {f : ι → K} : spanFinset R₁ s f ≠ 0 ↔ ∃ j ∈ s, f j ≠ 0 := by simp #align fractional_ideal.span_finset_ne_zero FractionalIdeal.spanFinset_ne_zero open Submodule.IsPrincipal theorem isFractional_span_singleton (x : P) : IsFractional S (span R {x} : Submodule R P) := let ⟨a, ha⟩ := exists_integer_multiple S x isFractional_span_iff.mpr ⟨a, a.2, fun _ hx' => (Set.mem_singleton_iff.mp hx').symm ▸ ha⟩ #align fractional_ideal.is_fractional_span_singleton FractionalIdeal.isFractional_span_singleton variable (S) irreducible_def spanSingleton (x : P) : FractionalIdeal S P := ⟨span R {x}, isFractional_span_singleton x⟩ #align fractional_ideal.span_singleton FractionalIdeal.spanSingleton -- local attribute [semireducible] span_singleton @[simp] theorem coe_spanSingleton (x : P) : (spanSingleton S x : Submodule R P) = span R {x} := by rw [spanSingleton] rfl #align fractional_ideal.coe_span_singleton FractionalIdeal.coe_spanSingleton @[simp] theorem mem_spanSingleton {x y : P} : x ∈ spanSingleton S y ↔ ∃ z : R, z • y = x := by rw [spanSingleton] exact Submodule.mem_span_singleton #align fractional_ideal.mem_span_singleton FractionalIdeal.mem_spanSingleton theorem mem_spanSingleton_self (x : P) : x ∈ spanSingleton S x := (mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩ #align fractional_ideal.mem_span_singleton_self FractionalIdeal.mem_spanSingleton_self variable (P) in theorem den_mul_self_eq_num' (I : FractionalIdeal S P) : spanSingleton S (algebraMap R P I.den) * I = I.num := by apply coeToSubmodule_injective dsimp only rw [coe_mul, ← smul_eq_mul, coe_spanSingleton, smul_eq_mul, Submodule.span_singleton_mul] convert I.den_mul_self_eq_num using 1 ext erw [Set.mem_smul_set, Set.mem_smul_set] simp [Algebra.smul_def] variable {S} @[simp] theorem spanSingleton_le_iff_mem {x : P} {I : FractionalIdeal S P} : spanSingleton S x ≤ I ↔ x ∈ I := by rw [← coe_le_coe, coe_spanSingleton, Submodule.span_singleton_le_iff_mem, mem_coe] #align fractional_ideal.span_singleton_le_iff_mem FractionalIdeal.spanSingleton_le_iff_mem theorem spanSingleton_eq_spanSingleton [NoZeroSMulDivisors R P] {x y : P} : spanSingleton S x = spanSingleton S y ↔ ∃ z : Rˣ, z • x = y := by rw [← Submodule.span_singleton_eq_span_singleton, spanSingleton, spanSingleton] exact Subtype.mk_eq_mk #align fractional_ideal.span_singleton_eq_span_singleton FractionalIdeal.spanSingleton_eq_spanSingleton theorem eq_spanSingleton_of_principal (I : FractionalIdeal S P) [IsPrincipal (I : Submodule R P)] : I = spanSingleton S (generator (I : Submodule R P)) := by -- Porting note: this used to be `coeToSubmodule_injective (span_singleton_generator ↑I).symm` -- but Lean 4 struggled to unify everything. Turned it into an explicit `rw`. rw [spanSingleton, ← coeToSubmodule_inj, coe_mk, span_singleton_generator] #align fractional_ideal.eq_span_singleton_of_principal FractionalIdeal.eq_spanSingleton_of_principal theorem isPrincipal_iff (I : FractionalIdeal S P) : IsPrincipal (I : Submodule R P) ↔ ∃ x, I = spanSingleton S x := ⟨fun h => ⟨@generator _ _ _ _ _ (↑I) h, @eq_spanSingleton_of_principal _ _ _ _ _ _ _ I h⟩, fun ⟨x, hx⟩ => { principal' := ⟨x, Eq.trans (congr_arg _ hx) (coe_spanSingleton _ x)⟩ }⟩ #align fractional_ideal.is_principal_iff FractionalIdeal.isPrincipal_iff @[simp] theorem spanSingleton_zero : spanSingleton S (0 : P) = 0 := by ext simp [Submodule.mem_span_singleton, eq_comm] #align fractional_ideal.span_singleton_zero FractionalIdeal.spanSingleton_zero theorem spanSingleton_eq_zero_iff {y : P} : spanSingleton S y = 0 ↔ y = 0 := ⟨fun h => span_eq_bot.mp (by simpa using congr_arg Subtype.val h : span R {y} = ⊥) y (mem_singleton y), fun h => by simp [h]⟩ #align fractional_ideal.span_singleton_eq_zero_iff FractionalIdeal.spanSingleton_eq_zero_iff theorem spanSingleton_ne_zero_iff {y : P} : spanSingleton S y ≠ 0 ↔ y ≠ 0 := not_congr spanSingleton_eq_zero_iff #align fractional_ideal.span_singleton_ne_zero_iff FractionalIdeal.spanSingleton_ne_zero_iff @[simp] theorem spanSingleton_one : spanSingleton S (1 : P) = 1 := by ext refine (mem_spanSingleton S).trans ((exists_congr ?_).trans (mem_one_iff S).symm) intro x' rw [Algebra.smul_def, mul_one] #align fractional_ideal.span_singleton_one FractionalIdeal.spanSingleton_one @[simp] theorem spanSingleton_mul_spanSingleton (x y : P) : spanSingleton S x * spanSingleton S y = spanSingleton S (x * y) := by apply coeToSubmodule_injective simp only [coe_mul, coe_spanSingleton, span_mul_span, singleton_mul_singleton] #align fractional_ideal.span_singleton_mul_span_singleton FractionalIdeal.spanSingleton_mul_spanSingleton @[simp] theorem spanSingleton_pow (x : P) (n : ℕ) : spanSingleton S x ^ n = spanSingleton S (x ^ n) := by induction' n with n hn · rw [pow_zero, pow_zero, spanSingleton_one] · rw [pow_succ, hn, spanSingleton_mul_spanSingleton, pow_succ] #align fractional_ideal.span_singleton_pow FractionalIdeal.spanSingleton_pow @[simp] theorem coeIdeal_span_singleton (x : R) : (↑(Ideal.span {x} : Ideal R) : FractionalIdeal S P) = spanSingleton S (algebraMap R P x) := by ext y refine (mem_coeIdeal S).trans (Iff.trans ?_ (mem_spanSingleton S).symm) constructor · rintro ⟨y', hy', rfl⟩ obtain ⟨x', rfl⟩ := Submodule.mem_span_singleton.mp hy' use x' rw [smul_eq_mul, RingHom.map_mul, Algebra.smul_def] · rintro ⟨y', rfl⟩ refine ⟨y' * x, Submodule.mem_span_singleton.mpr ⟨y', rfl⟩, ?_⟩ rw [RingHom.map_mul, Algebra.smul_def] #align fractional_ideal.coe_ideal_span_singleton FractionalIdeal.coeIdeal_span_singleton @[simp] theorem canonicalEquiv_spanSingleton {P'} [CommRing P'] [Algebra R P'] [IsLocalization S P'] (x : P) : canonicalEquiv S P P' (spanSingleton S x) = spanSingleton S (IsLocalization.map P' (RingHom.id R) (fun y (hy : y ∈ S) => show RingHom.id R y ∈ S from hy) x) := by apply SetLike.ext_iff.mpr intro y constructor <;> intro h · rw [mem_spanSingleton] obtain ⟨x', hx', rfl⟩ := (mem_canonicalEquiv_apply _ _ _).mp h obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp hx' use z rw [IsLocalization.map_smul, RingHom.id_apply] · rw [mem_canonicalEquiv_apply] obtain ⟨z, rfl⟩ := (mem_spanSingleton _).mp h use z • x use (mem_spanSingleton _).mpr ⟨z, rfl⟩ simp [IsLocalization.map_smul] #align fractional_ideal.canonical_equiv_span_singleton FractionalIdeal.canonicalEquiv_spanSingleton
Mathlib/RingTheory/FractionalIdeal/Operations.lean
758
770
theorem mem_singleton_mul {x y : P} {I : FractionalIdeal S P} : y ∈ spanSingleton S x * I ↔ ∃ y' ∈ I, y = x * y' := by
constructor · intro h refine FractionalIdeal.mul_induction_on h ?_ ?_ · intro x' hx' y' hy' obtain ⟨a, ha⟩ := (mem_spanSingleton S).mp hx' use a • y', Submodule.smul_mem (I : Submodule R P) a hy' rw [← ha, Algebra.mul_smul_comm, Algebra.smul_mul_assoc] · rintro _ _ ⟨y, hy, rfl⟩ ⟨y', hy', rfl⟩ exact ⟨y + y', Submodule.add_mem (I : Submodule R P) hy hy', (mul_add _ _ _).symm⟩ · rintro ⟨y', hy', rfl⟩ exact mul_mem_mul ((mem_spanSingleton S).mpr ⟨1, one_smul _ _⟩) hy'
import Mathlib.MeasureTheory.OuterMeasure.Basic open Filter Set open scoped ENNReal namespace MeasureTheory variable {α β F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} def ae (μ : F) : Filter α := .ofCountableUnion (μ · = 0) (fun _S hSc ↦ (measure_sUnion_null_iff hSc).2) fun _t ht _s hs ↦ measure_mono_null hs ht #align measure_theory.measure.ae MeasureTheory.ae notation3 "∀ᵐ "(...)" ∂"μ", "r:(scoped p => Filter.Eventually p <| MeasureTheory.ae μ) => r notation3 "∃ᵐ "(...)" ∂"μ", "r:(scoped P => Filter.Frequently P <| MeasureTheory.ae μ) => r notation:50 f " =ᵐ[" μ:50 "] " g:50 => Filter.EventuallyEq (MeasureTheory.ae μ) f g notation:50 f " ≤ᵐ[" μ:50 "] " g:50 => Filter.EventuallyLE (MeasureTheory.ae μ) f g theorem mem_ae_iff {s : Set α} : s ∈ ae μ ↔ μ sᶜ = 0 := Iff.rfl #align measure_theory.mem_ae_iff MeasureTheory.mem_ae_iff theorem ae_iff {p : α → Prop} : (∀ᵐ a ∂μ, p a) ↔ μ { a | ¬p a } = 0 := Iff.rfl #align measure_theory.ae_iff MeasureTheory.ae_iff theorem compl_mem_ae_iff {s : Set α} : sᶜ ∈ ae μ ↔ μ s = 0 := by simp only [mem_ae_iff, compl_compl] #align measure_theory.compl_mem_ae_iff MeasureTheory.compl_mem_ae_iff theorem frequently_ae_iff {p : α → Prop} : (∃ᵐ a ∂μ, p a) ↔ μ { a | p a } ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_iff MeasureTheory.frequently_ae_iff theorem frequently_ae_mem_iff {s : Set α} : (∃ᵐ a ∂μ, a ∈ s) ↔ μ s ≠ 0 := not_congr compl_mem_ae_iff #align measure_theory.frequently_ae_mem_iff MeasureTheory.frequently_ae_mem_iff theorem measure_zero_iff_ae_nmem {s : Set α} : μ s = 0 ↔ ∀ᵐ a ∂μ, a ∉ s := compl_mem_ae_iff.symm #align measure_theory.measure_zero_iff_ae_nmem MeasureTheory.measure_zero_iff_ae_nmem theorem ae_of_all {p : α → Prop} (μ : F) : (∀ a, p a) → ∀ᵐ a ∂μ, p a := eventually_of_forall #align measure_theory.ae_of_all MeasureTheory.ae_of_all instance instCountableInterFilter : CountableInterFilter (ae μ) := by unfold ae; infer_instance #align measure_theory.measure.ae.countable_Inter_filter MeasureTheory.instCountableInterFilter theorem ae_all_iff {ι : Sort*} [Countable ι] {p : α → ι → Prop} : (∀ᵐ a ∂μ, ∀ i, p a i) ↔ ∀ i, ∀ᵐ a ∂μ, p a i := eventually_countable_forall #align measure_theory.ae_all_iff MeasureTheory.ae_all_iff theorem all_ae_of {ι : Sort*} {p : α → ι → Prop} (hp : ∀ᵐ a ∂μ, ∀ i, p a i) (i : ι) : ∀ᵐ a ∂μ, p a i := by filter_upwards [hp] with a ha using ha i lemma ae_iff_of_countable [Countable α] {p : α → Prop} : (∀ᵐ x ∂μ, p x) ↔ ∀ x, μ {x} ≠ 0 → p x := by rw [ae_iff, measure_null_iff_singleton] exacts [forall_congr' fun _ ↦ not_imp_comm, Set.to_countable _] theorem ae_ball_iff {ι : Type*} {S : Set ι} (hS : S.Countable) {p : α → ∀ i ∈ S, Prop} : (∀ᵐ x ∂μ, ∀ i (hi : i ∈ S), p x i hi) ↔ ∀ i (hi : i ∈ S), ∀ᵐ x ∂μ, p x i hi := eventually_countable_ball hS #align measure_theory.ae_ball_iff MeasureTheory.ae_ball_iff theorem ae_eq_refl (f : α → β) : f =ᵐ[μ] f := EventuallyEq.rfl #align measure_theory.ae_eq_refl MeasureTheory.ae_eq_refl theorem ae_eq_symm {f g : α → β} (h : f =ᵐ[μ] g) : g =ᵐ[μ] f := h.symm #align measure_theory.ae_eq_symm MeasureTheory.ae_eq_symm theorem ae_eq_trans {f g h : α → β} (h₁ : f =ᵐ[μ] g) (h₂ : g =ᵐ[μ] h) : f =ᵐ[μ] h := h₁.trans h₂ #align measure_theory.ae_eq_trans MeasureTheory.ae_eq_trans theorem ae_le_of_ae_lt {β : Type*} [Preorder β] {f g : α → β} (h : ∀ᵐ x ∂μ, f x < g x) : f ≤ᵐ[μ] g := h.mono fun _ ↦ le_of_lt #align measure_theory.ae_le_of_ae_lt MeasureTheory.ae_le_of_ae_lt @[simp] theorem ae_eq_empty : s =ᵐ[μ] (∅ : Set α) ↔ μ s = 0 := eventuallyEq_empty.trans <| by simp only [ae_iff, Classical.not_not, setOf_mem_eq] #align measure_theory.ae_eq_empty MeasureTheory.ae_eq_empty -- Porting note: The priority should be higher than `eventuallyEq_univ`. @[simp high] theorem ae_eq_univ : s =ᵐ[μ] (univ : Set α) ↔ μ sᶜ = 0 := eventuallyEq_univ #align measure_theory.ae_eq_univ MeasureTheory.ae_eq_univ theorem ae_le_set : s ≤ᵐ[μ] t ↔ μ (s \ t) = 0 := calc s ≤ᵐ[μ] t ↔ ∀ᵐ x ∂μ, x ∈ s → x ∈ t := Iff.rfl _ ↔ μ (s \ t) = 0 := by simp [ae_iff]; rfl #align measure_theory.ae_le_set MeasureTheory.ae_le_set theorem ae_le_set_inter {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') : (s ∩ s' : Set α) ≤ᵐ[μ] (t ∩ t' : Set α) := h.inter h' #align measure_theory.ae_le_set_inter MeasureTheory.ae_le_set_inter theorem ae_le_set_union {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') : (s ∪ s' : Set α) ≤ᵐ[μ] (t ∪ t' : Set α) := h.union h' #align measure_theory.ae_le_set_union MeasureTheory.ae_le_set_union theorem union_ae_eq_right : (s ∪ t : Set α) =ᵐ[μ] t ↔ μ (s \ t) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set, union_diff_right, diff_eq_empty.2 Set.subset_union_right] #align measure_theory.union_ae_eq_right MeasureTheory.union_ae_eq_right theorem diff_ae_eq_self : (s \ t : Set α) =ᵐ[μ] s ↔ μ (s ∩ t) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set, diff_diff_right, diff_diff, diff_eq_empty.2 Set.subset_union_right] #align measure_theory.diff_ae_eq_self MeasureTheory.diff_ae_eq_self theorem diff_null_ae_eq_self (ht : μ t = 0) : (s \ t : Set α) =ᵐ[μ] s := diff_ae_eq_self.mpr (measure_mono_null inter_subset_right ht) #align measure_theory.diff_null_ae_eq_self MeasureTheory.diff_null_ae_eq_self theorem ae_eq_set {s t : Set α} : s =ᵐ[μ] t ↔ μ (s \ t) = 0 ∧ μ (t \ s) = 0 := by simp [eventuallyLE_antisymm_iff, ae_le_set] #align measure_theory.ae_eq_set MeasureTheory.ae_eq_set open scoped symmDiff in @[simp] theorem measure_symmDiff_eq_zero_iff {s t : Set α} : μ (s ∆ t) = 0 ↔ s =ᵐ[μ] t := by simp [ae_eq_set, symmDiff_def] #align measure_theory.measure_symm_diff_eq_zero_iff MeasureTheory.measure_symmDiff_eq_zero_iff @[simp] theorem ae_eq_set_compl_compl {s t : Set α} : sᶜ =ᵐ[μ] tᶜ ↔ s =ᵐ[μ] t := by simp only [← measure_symmDiff_eq_zero_iff, compl_symmDiff_compl] #align measure_theory.ae_eq_set_compl_compl MeasureTheory.ae_eq_set_compl_compl theorem ae_eq_set_compl {s t : Set α} : sᶜ =ᵐ[μ] t ↔ s =ᵐ[μ] tᶜ := by rw [← ae_eq_set_compl_compl, compl_compl] #align measure_theory.ae_eq_set_compl MeasureTheory.ae_eq_set_compl theorem ae_eq_set_inter {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') : (s ∩ s' : Set α) =ᵐ[μ] (t ∩ t' : Set α) := h.inter h' #align measure_theory.ae_eq_set_inter MeasureTheory.ae_eq_set_inter theorem ae_eq_set_union {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') : (s ∪ s' : Set α) =ᵐ[μ] (t ∪ t' : Set α) := h.union h' #align measure_theory.ae_eq_set_union MeasureTheory.ae_eq_set_union theorem union_ae_eq_univ_of_ae_eq_univ_left (h : s =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := (ae_eq_set_union h (ae_eq_refl t)).trans <| by rw [univ_union] #align measure_theory.union_ae_eq_univ_of_ae_eq_univ_left MeasureTheory.union_ae_eq_univ_of_ae_eq_univ_left theorem union_ae_eq_univ_of_ae_eq_univ_right (h : t =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := by convert ae_eq_set_union (ae_eq_refl s) h rw [union_univ] #align measure_theory.union_ae_eq_univ_of_ae_eq_univ_right MeasureTheory.union_ae_eq_univ_of_ae_eq_univ_right theorem union_ae_eq_right_of_ae_eq_empty (h : s =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] t := by convert ae_eq_set_union h (ae_eq_refl t) rw [empty_union] #align measure_theory.union_ae_eq_right_of_ae_eq_empty MeasureTheory.union_ae_eq_right_of_ae_eq_empty theorem union_ae_eq_left_of_ae_eq_empty (h : t =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] s := by convert ae_eq_set_union (ae_eq_refl s) h rw [union_empty] #align measure_theory.union_ae_eq_left_of_ae_eq_empty MeasureTheory.union_ae_eq_left_of_ae_eq_empty theorem inter_ae_eq_right_of_ae_eq_univ (h : s =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] t := by convert ae_eq_set_inter h (ae_eq_refl t) rw [univ_inter] #align measure_theory.inter_ae_eq_right_of_ae_eq_univ MeasureTheory.inter_ae_eq_right_of_ae_eq_univ theorem inter_ae_eq_left_of_ae_eq_univ (h : t =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] s := by convert ae_eq_set_inter (ae_eq_refl s) h rw [inter_univ] #align measure_theory.inter_ae_eq_left_of_ae_eq_univ MeasureTheory.inter_ae_eq_left_of_ae_eq_univ theorem inter_ae_eq_empty_of_ae_eq_empty_left (h : s =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by convert ae_eq_set_inter h (ae_eq_refl t) rw [empty_inter] #align measure_theory.inter_ae_eq_empty_of_ae_eq_empty_left MeasureTheory.inter_ae_eq_empty_of_ae_eq_empty_left theorem inter_ae_eq_empty_of_ae_eq_empty_right (h : t =ᵐ[μ] (∅ : Set α)) : (s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by convert ae_eq_set_inter (ae_eq_refl s) h rw [inter_empty] #align measure_theory.inter_ae_eq_empty_of_ae_eq_empty_right MeasureTheory.inter_ae_eq_empty_of_ae_eq_empty_right @[to_additive]
Mathlib/MeasureTheory/OuterMeasure/AE.lean
249
251
theorem _root_.Set.mulIndicator_ae_eq_one {M : Type*} [One M] {f : α → M} {s : Set α} : s.mulIndicator f =ᵐ[μ] 1 ↔ μ (s ∩ f.mulSupport) = 0 := by
simp [EventuallyEq, eventually_iff, ae, compl_setOf]; rfl
import Mathlib.FieldTheory.Galois #align_import field_theory.polynomial_galois_group from "leanprover-community/mathlib"@"e3f4be1fcb5376c4948d7f095bec45350bfb9d1a" noncomputable section open scoped Polynomial open FiniteDimensional namespace Polynomial variable {F : Type*} [Field F] (p q : F[X]) (E : Type*) [Field E] [Algebra F E] def Gal := p.SplittingField ≃ₐ[F] p.SplittingField -- Porting note(https://github.com/leanprover-community/mathlib4/issues/5020): -- deriving Group, Fintype #align polynomial.gal Polynomial.Gal namespace Gal instance instGroup : Group (Gal p) := inferInstanceAs (Group (p.SplittingField ≃ₐ[F] p.SplittingField)) instance instFintype : Fintype (Gal p) := inferInstanceAs (Fintype (p.SplittingField ≃ₐ[F] p.SplittingField)) instance : CoeFun p.Gal fun _ => p.SplittingField → p.SplittingField := -- Porting note: was AlgEquiv.hasCoeToFun inferInstanceAs (CoeFun (p.SplittingField ≃ₐ[F] p.SplittingField) _) instance applyMulSemiringAction : MulSemiringAction p.Gal p.SplittingField := AlgEquiv.applyMulSemiringAction #align polynomial.gal.apply_mul_semiring_action Polynomial.Gal.applyMulSemiringAction @[ext] theorem ext {σ τ : p.Gal} (h : ∀ x ∈ p.rootSet p.SplittingField, σ x = τ x) : σ = τ := by refine AlgEquiv.ext fun x => (AlgHom.mem_equalizer σ.toAlgHom τ.toAlgHom x).mp ((SetLike.ext_iff.mp ?_ x).mpr Algebra.mem_top) rwa [eq_top_iff, ← SplittingField.adjoin_rootSet, Algebra.adjoin_le_iff] #align polynomial.gal.ext Polynomial.Gal.ext def uniqueGalOfSplits (h : p.Splits (RingHom.id F)) : Unique p.Gal where default := 1 uniq f := AlgEquiv.ext fun x => by obtain ⟨y, rfl⟩ := Algebra.mem_bot.mp ((SetLike.ext_iff.mp ((IsSplittingField.splits_iff _ p).mp h) x).mp Algebra.mem_top) rw [AlgEquiv.commutes, AlgEquiv.commutes] #align polynomial.gal.unique_gal_of_splits Polynomial.Gal.uniqueGalOfSplits instance [h : Fact (p.Splits (RingHom.id F))] : Unique p.Gal := uniqueGalOfSplits _ h.1 instance uniqueGalZero : Unique (0 : F[X]).Gal := uniqueGalOfSplits _ (splits_zero _) #align polynomial.gal.unique_gal_zero Polynomial.Gal.uniqueGalZero instance uniqueGalOne : Unique (1 : F[X]).Gal := uniqueGalOfSplits _ (splits_one _) #align polynomial.gal.unique_gal_one Polynomial.Gal.uniqueGalOne instance uniqueGalC (x : F) : Unique (C x).Gal := uniqueGalOfSplits _ (splits_C _ _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_C Polynomial.Gal.uniqueGalC instance uniqueGalX : Unique (X : F[X]).Gal := uniqueGalOfSplits _ (splits_X _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X Polynomial.Gal.uniqueGalX instance uniqueGalXSubC (x : F) : Unique (X - C x).Gal := uniqueGalOfSplits _ (splits_X_sub_C _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X_sub_C Polynomial.Gal.uniqueGalXSubC instance uniqueGalXPow (n : ℕ) : Unique (X ^ n : F[X]).Gal := uniqueGalOfSplits _ (splits_X_pow _ _) set_option linter.uppercaseLean3 false in #align polynomial.gal.unique_gal_X_pow Polynomial.Gal.uniqueGalXPow instance [h : Fact (p.Splits (algebraMap F E))] : Algebra p.SplittingField E := (IsSplittingField.lift p.SplittingField p h.1).toRingHom.toAlgebra instance [h : Fact (p.Splits (algebraMap F E))] : IsScalarTower F p.SplittingField E := IsScalarTower.of_algebraMap_eq fun x => ((IsSplittingField.lift p.SplittingField p h.1).commutes x).symm -- The `Algebra p.SplittingField E` instance above behaves badly when -- `E := p.SplittingField`, since it may result in a unification problem -- `IsSplittingField.lift.toRingHom.toAlgebra =?= Algebra.id`, -- which takes an extremely long time to resolve, causing timeouts. -- Since we don't really care about this definition, marking it as irreducible -- causes that unification to error out early. def restrict [Fact (p.Splits (algebraMap F E))] : (E ≃ₐ[F] E) →* p.Gal := AlgEquiv.restrictNormalHom p.SplittingField #align polynomial.gal.restrict Polynomial.Gal.restrict theorem restrict_surjective [Fact (p.Splits (algebraMap F E))] [Normal F E] : Function.Surjective (restrict p E) := AlgEquiv.restrictNormalHom_surjective E #align polynomial.gal.restrict_surjective Polynomial.Gal.restrict_surjective section RootsAction def mapRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField → rootSet p E := Set.MapsTo.restrict (IsScalarTower.toAlgHom F p.SplittingField E) _ _ <| rootSet_mapsTo _ #align polynomial.gal.map_roots Polynomial.Gal.mapRoots theorem mapRoots_bijective [h : Fact (p.Splits (algebraMap F E))] : Function.Bijective (mapRoots p E) := by constructor · exact fun _ _ h => Subtype.ext (RingHom.injective _ (Subtype.ext_iff.mp h)) · intro y -- this is just an equality of two different ways to write the roots of `p` as an `E`-polynomial have key := roots_map (IsScalarTower.toAlgHom F p.SplittingField E : p.SplittingField →+* E) ((splits_id_iff_splits _).mpr (IsSplittingField.splits p.SplittingField p)) rw [map_map, AlgHom.comp_algebraMap] at key have hy := Subtype.mem y simp only [rootSet, Finset.mem_coe, Multiset.mem_toFinset, key, Multiset.mem_map] at hy rcases hy with ⟨x, hx1, hx2⟩ exact ⟨⟨x, (@Multiset.mem_toFinset _ (Classical.decEq _) _ _).mpr hx1⟩, Subtype.ext hx2⟩ #align polynomial.gal.map_roots_bijective Polynomial.Gal.mapRoots_bijective def rootsEquivRoots [Fact (p.Splits (algebraMap F E))] : rootSet p p.SplittingField ≃ rootSet p E := Equiv.ofBijective (mapRoots p E) (mapRoots_bijective p E) #align polynomial.gal.roots_equiv_roots Polynomial.Gal.rootsEquivRoots instance galActionAux : MulAction p.Gal (rootSet p p.SplittingField) where smul ϕ := Set.MapsTo.restrict ϕ _ _ <| rootSet_mapsTo ϕ.toAlgHom one_smul _ := by ext; rfl mul_smul _ _ _ := by ext; rfl #align polynomial.gal.gal_action_aux Polynomial.Gal.galActionAux -- Porting note: split out from `galAction` below to allow using `smul_def` there. instance smul [Fact (p.Splits (algebraMap F E))] : SMul p.Gal (rootSet p E) where smul ϕ x := rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) -- Porting note (#10756): new theorem theorem smul_def [Fact (p.Splits (algebraMap F E))] (ϕ : p.Gal) (x : rootSet p E) : ϕ • x = rootsEquivRoots p E (ϕ • (rootsEquivRoots p E).symm x) := rfl instance galAction [Fact (p.Splits (algebraMap F E))] : MulAction p.Gal (rootSet p E) where one_smul _ := by simp only [smul_def, Equiv.apply_symm_apply, one_smul] mul_smul _ _ _ := by simp only [smul_def, Equiv.apply_symm_apply, Equiv.symm_apply_apply, mul_smul] #align polynomial.gal.gal_action Polynomial.Gal.galAction lemma galAction_isPretransitive [Fact (p.Splits (algebraMap F E))] (hp : Irreducible p) : MulAction.IsPretransitive p.Gal (p.rootSet E) := by refine ⟨fun x y ↦ ?_⟩ have hx := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm x).2).2 have hy := minpoly.eq_of_irreducible hp (mem_rootSet.mp ((rootsEquivRoots p E).symm y).2).2 obtain ⟨g, hg⟩ := (Normal.minpoly_eq_iff_mem_orbit p.SplittingField).mp (hy.symm.trans hx) exact ⟨g, (rootsEquivRoots p E).apply_eq_iff_eq_symm_apply.mpr (Subtype.ext hg)⟩ variable {p E} @[simp]
Mathlib/FieldTheory/PolynomialGaloisGroup.lean
210
216
theorem restrict_smul [Fact (p.Splits (algebraMap F E))] (ϕ : E ≃ₐ[F] E) (x : rootSet p E) : ↑(restrict p E ϕ • x) = ϕ x := by
let ψ := AlgEquiv.ofInjectiveField (IsScalarTower.toAlgHom F p.SplittingField E) change ↑(ψ (ψ.symm _)) = ϕ x rw [AlgEquiv.apply_symm_apply ψ] change ϕ (rootsEquivRoots p E ((rootsEquivRoots p E).symm x)) = ϕ x rw [Equiv.apply_symm_apply (rootsEquivRoots p E)]
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
96
99
theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by
rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one]
import Mathlib.MeasureTheory.Group.Measure import Mathlib.MeasureTheory.Integral.IntegrableOn import Mathlib.MeasureTheory.Function.LocallyIntegrable open Asymptotics MeasureTheory Set Filter variable {α E F : Type*} [MeasurableSpace α] [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : α → F} {a b : α} {μ : Measure α} {l : Filter α} theorem _root_.Asymptotics.IsBigO.integrableAtFilter [IsMeasurablyGenerated l] (hf : f =O[l] g) (hfm : StronglyMeasurableAtFilter f l μ) (hg : IntegrableAtFilter g l μ) : IntegrableAtFilter f l μ := by obtain ⟨C, hC⟩ := hf.bound obtain ⟨s, hsl, hsm, hfg, hf, hg⟩ := (hC.smallSets.and <| hfm.eventually.and hg.eventually).exists_measurable_mem_of_smallSets refine ⟨s, hsl, (hg.norm.const_mul C).mono hf ?_⟩ refine (ae_restrict_mem hsm).mono fun x hx ↦ ?_ exact (hfg x hx).trans (le_abs_self _) theorem _root_.Asymptotics.IsBigO.integrable (hfm : AEStronglyMeasurable f μ) (hf : f =O[⊤] g) (hg : Integrable g μ) : Integrable f μ := by rewrite [← integrableAtFilter_top] at * exact hf.integrableAtFilter ⟨univ, univ_mem, hfm.restrict⟩ hg variable [TopologicalSpace α] [SecondCountableTopology α] namespace MeasureTheory theorem LocallyIntegrable.integrable_of_isBigO_cocompact [IsMeasurablyGenerated (cocompact α)] (hf : LocallyIntegrable f μ) (ho : f =O[cocompact α] g) (hg : IntegrableAtFilter g (cocompact α) μ) : Integrable f μ := by refine integrable_iff_integrableAtFilter_cocompact.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter section LinearOrder variable [LinearOrder α] [CompactIccSpace α] {g' : α → F} theorem LocallyIntegrable.integrable_of_isBigO_atBot_atTop [IsMeasurablyGenerated (atBot (α := α))] [IsMeasurablyGenerated (atTop (α := α))] (hf : LocallyIntegrable f μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) (ho' : f =O[atTop] g') (hg' : IntegrableAtFilter g' atTop μ) : Integrable f μ := by refine integrable_iff_integrableAtFilter_atBot_atTop.mpr ⟨⟨ho.integrableAtFilter ?_ hg, ho'.integrableAtFilter ?_ hg'⟩, hf⟩ all_goals exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter theorem LocallyIntegrableOn.integrableOn_of_isBigO_atBot [IsMeasurablyGenerated (atBot (α := α))] (hf : LocallyIntegrableOn f (Iic a) μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) : IntegrableOn f (Iic a) μ := by refine integrableOn_Iic_iff_integrableAtFilter_atBot.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact ⟨Iic a, Iic_mem_atBot a, hf.aestronglyMeasurable⟩ theorem LocallyIntegrableOn.integrableOn_of_isBigO_atTop [IsMeasurablyGenerated (atTop (α := α))] (hf : LocallyIntegrableOn f (Ici a) μ) (ho : f =O[atTop] g) (hg : IntegrableAtFilter g atTop μ) : IntegrableOn f (Ici a) μ := by refine integrableOn_Ici_iff_integrableAtFilter_atTop.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact ⟨Ici a, Ici_mem_atTop a, hf.aestronglyMeasurable⟩
Mathlib/MeasureTheory/Integral/Asymptotics.lean
97
101
theorem LocallyIntegrable.integrable_of_isBigO_atBot [IsMeasurablyGenerated (atBot (α := α))] [OrderTop α] (hf : LocallyIntegrable f μ) (ho : f =O[atBot] g) (hg : IntegrableAtFilter g atBot μ) : Integrable f μ := by
refine integrable_iff_integrableAtFilter_atBot.mpr ⟨ho.integrableAtFilter ?_ hg, hf⟩ exact hf.aestronglyMeasurable.stronglyMeasurableAtFilter
import Mathlib.LinearAlgebra.CliffordAlgebra.Basic import Mathlib.Data.ZMod.Basic import Mathlib.RingTheory.GradedAlgebra.Basic #align_import linear_algebra.clifford_algebra.grading from "leanprover-community/mathlib"@"34020e531ebc4e8aac6d449d9eecbcd1508ea8d0" namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) def evenOdd (i : ZMod 2) : Submodule R (CliffordAlgebra Q) := ⨆ j : { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (j : ℕ) #align clifford_algebra.even_odd CliffordAlgebra.evenOdd theorem one_le_evenOdd_zero : 1 ≤ evenOdd Q 0 := by refine le_trans ?_ (le_iSup _ ⟨0, Nat.cast_zero⟩) exact (pow_zero _).ge #align clifford_algebra.one_le_even_odd_zero CliffordAlgebra.one_le_evenOdd_zero theorem range_ι_le_evenOdd_one : LinearMap.range (ι Q) ≤ evenOdd Q 1 := by refine le_trans ?_ (le_iSup _ ⟨1, Nat.cast_one⟩) exact (pow_one _).ge #align clifford_algebra.range_ι_le_even_odd_one CliffordAlgebra.range_ι_le_evenOdd_one theorem ι_mem_evenOdd_one (m : M) : ι Q m ∈ evenOdd Q 1 := range_ι_le_evenOdd_one Q <| LinearMap.mem_range_self _ m #align clifford_algebra.ι_mem_even_odd_one CliffordAlgebra.ι_mem_evenOdd_one theorem ι_mul_ι_mem_evenOdd_zero (m₁ m₂ : M) : ι Q m₁ * ι Q m₂ ∈ evenOdd Q 0 := Submodule.mem_iSup_of_mem ⟨2, rfl⟩ (by rw [Subtype.coe_mk, pow_two] exact Submodule.mul_mem_mul (LinearMap.mem_range_self (ι Q) m₁) (LinearMap.mem_range_self (ι Q) m₂)) #align clifford_algebra.ι_mul_ι_mem_even_odd_zero CliffordAlgebra.ι_mul_ι_mem_evenOdd_zero
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
58
65
theorem evenOdd_mul_le (i j : ZMod 2) : evenOdd Q i * evenOdd Q j ≤ evenOdd Q (i + j) := by
simp_rw [evenOdd, Submodule.iSup_eq_span, Submodule.span_mul_span] apply Submodule.span_mono simp_rw [Set.iUnion_mul, Set.mul_iUnion, Set.iUnion_subset_iff, Set.mul_subset_iff] rintro ⟨xi, rfl⟩ ⟨yi, rfl⟩ x hx y hy refine Set.mem_iUnion.mpr ⟨⟨xi + yi, Nat.cast_add _ _⟩, ?_⟩ simp only [Subtype.coe_mk, Nat.cast_add, pow_add] exact Submodule.mul_mem_mul hx hy
import Mathlib.Analysis.NormedSpace.PiLp import Mathlib.Analysis.InnerProductSpace.PiL2 #align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open scoped NNReal Matrix namespace Matrix variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n] section LinfLinf section SeminormedAddCommGroup variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β] protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) := Pi.seminormedAddCommGroup #align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup attribute [local instance] Matrix.seminormedAddCommGroup -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) : ‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def] -- Porting note (#10756): new theorem (along with all the uses of this lemma below) theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr] #align matrix.norm_le_iff Matrix.norm_le_iff theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by simp_rw [nnnorm_def, pi_nnnorm_le_iff] #align matrix.nnnorm_le_iff Matrix.nnnorm_le_iff theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by simp_rw [norm_def, pi_norm_lt_iff hr] #align matrix.norm_lt_iff Matrix.norm_lt_iff theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} : ‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr] #align matrix.nnnorm_lt_iff Matrix.nnnorm_lt_iff theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ := (norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i) #align matrix.norm_entry_le_entrywise_sup_norm Matrix.norm_entry_le_entrywise_sup_norm theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ := (nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i) #align matrix.nnnorm_entry_le_entrywise_sup_nnnorm Matrix.nnnorm_entry_le_entrywise_sup_nnnorm @[simp]
Mathlib/Analysis/Matrix.lean
116
118
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) : ‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
import Mathlib.Algebra.Homology.ImageToKernel #align_import algebra.homology.exact from "leanprover-community/mathlib"@"3feb151caefe53df080ca6ca67a0c6685cfd1b82" universe v v₂ u u₂ open CategoryTheory CategoryTheory.Limits variable {V : Type u} [Category.{v} V] variable [HasImages V] namespace CategoryTheory -- One nice feature of this definition is that we have -- `Epi f → Exact g h → Exact (f ≫ g) h` and `Exact f g → Mono h → Exact f (g ≫ h)`, -- which do not necessarily hold in a non-abelian category with the usual definition of `Exact`. structure Exact [HasZeroMorphisms V] [HasKernels V] {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Prop where w : f ≫ g = 0 epi : Epi (imageToKernel f g w) #align category_theory.exact CategoryTheory.Exact -- Porting note: it seems it no longer works in Lean4, so that some `haveI` have been added below -- This works as an instance even though `Exact` itself is not a class, as long as the goal is -- literally of the form `Epi (imageToKernel f g h.w)` (where `h : Exact f g`). If the proof of -- `f ≫ g = 0` looks different, we are out of luck and have to add the instance by hand. attribute [instance] Exact.epi attribute [reassoc] Exact.w section variable [HasZeroObject V] [Preadditive V] [HasKernels V] [HasCokernels V] open ZeroObject theorem Preadditive.exact_iff_homology'_zero {A B C : V} (f : A ⟶ B) (g : B ⟶ C) : Exact f g ↔ ∃ w : f ≫ g = 0, Nonempty (homology' f g w ≅ 0) := ⟨fun h => ⟨h.w, ⟨by haveI := h.epi exact cokernel.ofEpi _⟩⟩, fun h => by obtain ⟨w, ⟨i⟩⟩ := h exact ⟨w, Preadditive.epi_of_cokernel_zero ((cancel_mono i.hom).mp (by ext))⟩⟩ #align category_theory.preadditive.exact_iff_homology_zero CategoryTheory.Preadditive.exact_iff_homology'_zero theorem Preadditive.exact_of_iso_of_exact {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) (h : Exact f₁ g₁) : Exact f₂ g₂ := by rw [Preadditive.exact_iff_homology'_zero] at h ⊢ rcases h with ⟨w₁, ⟨i⟩⟩ suffices w₂ : f₂ ≫ g₂ = 0 from ⟨w₂, ⟨(homology'.mapIso w₁ w₂ α β p).symm.trans i⟩⟩ rw [← cancel_epi α.hom.left, ← cancel_mono β.inv.right, comp_zero, zero_comp, ← w₁] have eq₁ := β.inv.w have eq₂ := α.hom.w dsimp at eq₁ eq₂ simp only [Category.assoc, Category.assoc, ← eq₁, reassoc_of% eq₂, p, ← reassoc_of% (Arrow.comp_left β.hom β.inv), β.hom_inv_id, Arrow.id_left, Category.id_comp] #align category_theory.preadditive.exact_of_iso_of_exact CategoryTheory.Preadditive.exact_of_iso_of_exact theorem Preadditive.exact_of_iso_of_exact' {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : A₁ ≅ A₂) (β : B₁ ≅ B₂) (γ : C₁ ≅ C₂) (hsq₁ : α.hom ≫ f₂ = f₁ ≫ β.hom) (hsq₂ : β.hom ≫ g₂ = g₁ ≫ γ.hom) (h : Exact f₁ g₁) : Exact f₂ g₂ := Preadditive.exact_of_iso_of_exact f₁ g₁ f₂ g₂ (Arrow.isoMk α β hsq₁) (Arrow.isoMk β γ hsq₂) rfl h #align category_theory.preadditive.exact_of_iso_of_exact' CategoryTheory.Preadditive.exact_of_iso_of_exact' theorem Preadditive.exact_iff_exact_of_iso {A₁ B₁ C₁ A₂ B₂ C₂ : V} (f₁ : A₁ ⟶ B₁) (g₁ : B₁ ⟶ C₁) (f₂ : A₂ ⟶ B₂) (g₂ : B₂ ⟶ C₂) (α : Arrow.mk f₁ ≅ Arrow.mk f₂) (β : Arrow.mk g₁ ≅ Arrow.mk g₂) (p : α.hom.right = β.hom.left) : Exact f₁ g₁ ↔ Exact f₂ g₂ := ⟨Preadditive.exact_of_iso_of_exact _ _ _ _ _ _ p, Preadditive.exact_of_iso_of_exact _ _ _ _ α.symm β.symm (by rw [← cancel_mono α.hom.right] simp only [Iso.symm_hom, ← Arrow.comp_right, α.inv_hom_id] simp only [p, ← Arrow.comp_left, Arrow.id_right, Arrow.id_left, Iso.inv_hom_id] rfl)⟩ #align category_theory.preadditive.exact_iff_exact_of_iso CategoryTheory.Preadditive.exact_iff_exact_of_iso end section variable [HasZeroMorphisms V] [HasKernels V] theorem comp_eq_zero_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : f ≫ g = 0 := by suffices Subobject.arrow (imageSubobject f) ≫ g = 0 by rw [← imageSubobject_arrow_comp f, Category.assoc, this, comp_zero] rw [p, kernelSubobject_arrow_comp] #align category_theory.comp_eq_zero_of_image_eq_kernel CategoryTheory.comp_eq_zero_of_image_eq_kernel theorem imageToKernel_isIso_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : IsIso (imageToKernel f g (comp_eq_zero_of_image_eq_kernel f g p)) := by refine ⟨⟨Subobject.ofLE _ _ p.ge, ?_⟩⟩ dsimp [imageToKernel] simp only [Subobject.ofLE_comp_ofLE, Subobject.ofLE_refl, and_self] #align category_theory.image_to_kernel_is_iso_of_image_eq_kernel CategoryTheory.imageToKernel_isIso_of_image_eq_kernel -- We'll prove the converse later, when `V` is abelian. theorem exact_of_image_eq_kernel {A B C : V} (f : A ⟶ B) (g : B ⟶ C) (p : imageSubobject f = kernelSubobject g) : Exact f g := { w := comp_eq_zero_of_image_eq_kernel f g p epi := by haveI := imageToKernel_isIso_of_image_eq_kernel f g p infer_instance } #align category_theory.exact_of_image_eq_kernel CategoryTheory.exact_of_image_eq_kernel end variable {A B C D : V} {f : A ⟶ B} {g : B ⟶ C} {h : C ⟶ D} attribute [local instance] epi_comp section variable [HasZeroMorphisms V] [HasEqualizers V] theorem exact_comp_hom_inv_comp (i : B ≅ D) (h : Exact f g) : Exact (f ≫ i.hom) (i.inv ≫ g) := by refine ⟨by simp [h.w], ?_⟩ rw [imageToKernel_comp_hom_inv_comp] haveI := h.epi infer_instance #align category_theory.exact_comp_hom_inv_comp CategoryTheory.exact_comp_hom_inv_comp theorem exact_comp_inv_hom_comp (i : D ≅ B) (h : Exact f g) : Exact (f ≫ i.inv) (i.hom ≫ g) := exact_comp_hom_inv_comp i.symm h #align category_theory.exact_comp_inv_hom_comp CategoryTheory.exact_comp_inv_hom_comp theorem exact_comp_hom_inv_comp_iff (i : B ≅ D) : Exact (f ≫ i.hom) (i.inv ≫ g) ↔ Exact f g := ⟨fun h => by simpa using exact_comp_inv_hom_comp i h, exact_comp_hom_inv_comp i⟩ #align category_theory.exact_comp_hom_inv_comp_iff CategoryTheory.exact_comp_hom_inv_comp_iff theorem exact_epi_comp (hgh : Exact g h) [Epi f] : Exact (f ≫ g) h := by refine ⟨by simp [hgh.w], ?_⟩ rw [imageToKernel_comp_left] · haveI := hgh.epi infer_instance #align category_theory.exact_epi_comp CategoryTheory.exact_epi_comp @[simp] theorem exact_iso_comp [IsIso f] : Exact (f ≫ g) h ↔ Exact g h := ⟨fun w => by rw [← IsIso.inv_hom_id_assoc f g] exact exact_epi_comp w, fun w => exact_epi_comp w⟩ #align category_theory.exact_iso_comp CategoryTheory.exact_iso_comp
Mathlib/Algebra/Homology/Exact.lean
203
207
theorem exact_comp_mono (hfg : Exact f g) [Mono h] : Exact f (g ≫ h) := by
refine ⟨by simp [hfg.w_assoc], ?_⟩ rw [imageToKernel_comp_right f g h hfg.w] haveI := hfg.epi infer_instance
import Mathlib.RingTheory.Derivation.ToSquareZero import Mathlib.RingTheory.Ideal.Cotangent import Mathlib.RingTheory.IsTensorProduct import Mathlib.Algebra.Exact import Mathlib.Algebra.MvPolynomial.PDeriv import Mathlib.Algebra.Polynomial.Derivation #align_import ring_theory.kaehler from "leanprover-community/mathlib"@"4b92a463033b5587bb011657e25e4710bfca7364" suppress_compilation section KaehlerDifferential open scoped TensorProduct open Algebra universe u v variable (R : Type u) (S : Type v) [CommRing R] [CommRing S] [Algebra R S] abbrev KaehlerDifferential.ideal : Ideal (S ⊗[R] S) := RingHom.ker (TensorProduct.lmul' R : S ⊗[R] S →ₐ[R] S) #align kaehler_differential.ideal KaehlerDifferential.ideal variable {S} theorem KaehlerDifferential.one_smul_sub_smul_one_mem_ideal (a : S) : (1 : S) ⊗ₜ[R] a - a ⊗ₜ[R] (1 : S) ∈ KaehlerDifferential.ideal R S := by simp [RingHom.mem_ker] #align kaehler_differential.one_smul_sub_smul_one_mem_ideal KaehlerDifferential.one_smul_sub_smul_one_mem_ideal variable {R} variable {M : Type*} [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower R S M] def Derivation.tensorProductTo (D : Derivation R S M) : S ⊗[R] S →ₗ[S] M := TensorProduct.AlgebraTensorModule.lift ((LinearMap.lsmul S (S →ₗ[R] M)).flip D.toLinearMap) #align derivation.tensor_product_to Derivation.tensorProductTo theorem Derivation.tensorProductTo_tmul (D : Derivation R S M) (s t : S) : D.tensorProductTo (s ⊗ₜ t) = s • D t := rfl #align derivation.tensor_product_to_tmul Derivation.tensorProductTo_tmul
Mathlib/RingTheory/Kaehler.lean
78
99
theorem Derivation.tensorProductTo_mul (D : Derivation R S M) (x y : S ⊗[R] S) : D.tensorProductTo (x * y) = TensorProduct.lmul' (S := S) R x • D.tensorProductTo y + TensorProduct.lmul' (S := S) R y • D.tensorProductTo x := by
refine TensorProduct.induction_on x ?_ ?_ ?_ · rw [zero_mul, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [add_mul, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x₁ x₂ refine TensorProduct.induction_on y ?_ ?_ ?_ · rw [mul_zero, map_zero, map_zero, zero_smul, smul_zero, add_zero] swap · intro x₁ y₁ h₁ h₂ rw [mul_add, map_add, map_add, map_add, add_smul, smul_add, h₁, h₂, add_add_add_comm] intro x y simp only [TensorProduct.tmul_mul_tmul, Derivation.tensorProductTo, TensorProduct.AlgebraTensorModule.lift_apply, TensorProduct.lift.tmul', TensorProduct.lmul'_apply_tmul] dsimp rw [D.leibniz] simp only [smul_smul, smul_add, mul_comm (x * y) x₁, mul_right_comm x₁ x₂, ← mul_assoc]
import Mathlib.Logic.Function.Basic import Mathlib.Logic.Relator import Mathlib.Init.Data.Quot import Mathlib.Tactic.Cases import Mathlib.Tactic.Use import Mathlib.Tactic.MkIffOfInductiveProp import Mathlib.Tactic.SimpRw #align_import logic.relation from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe" open Function variable {α β γ δ ε ζ : Type*} namespace Relation variable {r : α → α → Prop} {a b c d : α} @[mk_iff ReflTransGen.cases_tail_iff] inductive ReflTransGen (r : α → α → Prop) (a : α) : α → Prop | refl : ReflTransGen r a a | tail {b c} : ReflTransGen r a b → r b c → ReflTransGen r a c #align relation.refl_trans_gen Relation.ReflTransGen #align relation.refl_trans_gen.cases_tail_iff Relation.ReflTransGen.cases_tail_iff attribute [refl] ReflTransGen.refl @[mk_iff] inductive ReflGen (r : α → α → Prop) (a : α) : α → Prop | refl : ReflGen r a a | single {b} : r a b → ReflGen r a b #align relation.refl_gen Relation.ReflGen #align relation.refl_gen_iff Relation.reflGen_iff @[mk_iff] inductive TransGen (r : α → α → Prop) (a : α) : α → Prop | single {b} : r a b → TransGen r a b | tail {b c} : TransGen r a b → r b c → TransGen r a c #align relation.trans_gen Relation.TransGen #align relation.trans_gen_iff Relation.transGen_iff attribute [refl] ReflGen.refl namespace ReflTransGen @[trans] theorem trans (hab : ReflTransGen r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by induction hbc with | refl => assumption | tail _ hcd hac => exact hac.tail hcd #align relation.refl_trans_gen.trans Relation.ReflTransGen.trans theorem single (hab : r a b) : ReflTransGen r a b := refl.tail hab #align relation.refl_trans_gen.single Relation.ReflTransGen.single theorem head (hab : r a b) (hbc : ReflTransGen r b c) : ReflTransGen r a c := by induction hbc with | refl => exact refl.tail hab | tail _ hcd hac => exact hac.tail hcd #align relation.refl_trans_gen.head Relation.ReflTransGen.head
Mathlib/Logic/Relation.lean
312
316
theorem symmetric (h : Symmetric r) : Symmetric (ReflTransGen r) := by
intro x y h induction' h with z w _ b c · rfl · apply Relation.ReflTransGen.head (h b) c
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv #align_import linear_algebra.affine_space.midpoint from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" open AffineMap AffineEquiv section variable (R : Type*) {V V' P P' : Type*} [Ring R] [Invertible (2 : R)] [AddCommGroup V] [Module R V] [AddTorsor V P] [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] def midpoint (x y : P) : P := lineMap x y (⅟ 2 : R) #align midpoint midpoint variable {R} {x y z : P} @[simp] theorem AffineMap.map_midpoint (f : P →ᵃ[R] P') (a b : P) : f (midpoint R a b) = midpoint R (f a) (f b) := f.apply_lineMap a b _ #align affine_map.map_midpoint AffineMap.map_midpoint @[simp] theorem AffineEquiv.map_midpoint (f : P ≃ᵃ[R] P') (a b : P) : f (midpoint R a b) = midpoint R (f a) (f b) := f.apply_lineMap a b _ #align affine_equiv.map_midpoint AffineEquiv.map_midpoint theorem AffineEquiv.pointReflection_midpoint_left (x y : P) : pointReflection R (midpoint R x y) x = y := by rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul, mul_invOf_self, one_smul, vsub_vadd] #align affine_equiv.point_reflection_midpoint_left AffineEquiv.pointReflection_midpoint_left @[simp] -- Porting note: added variant with `Equiv.pointReflection` for `simp` theorem Equiv.pointReflection_midpoint_left (x y : P) : (Equiv.pointReflection (midpoint R x y)) x = y := by rw [midpoint, pointReflection_apply, lineMap_apply, vadd_vsub, vadd_vadd, ← add_smul, ← two_mul, mul_invOf_self, one_smul, vsub_vadd] theorem midpoint_comm (x y : P) : midpoint R x y = midpoint R y x := by rw [midpoint, ← lineMap_apply_one_sub, one_sub_invOf_two, midpoint] #align midpoint_comm midpoint_comm theorem AffineEquiv.pointReflection_midpoint_right (x y : P) : pointReflection R (midpoint R x y) y = x := by rw [midpoint_comm, AffineEquiv.pointReflection_midpoint_left] #align affine_equiv.point_reflection_midpoint_right AffineEquiv.pointReflection_midpoint_right @[simp] -- Porting note: added variant with `Equiv.pointReflection` for `simp` theorem Equiv.pointReflection_midpoint_right (x y : P) : (Equiv.pointReflection (midpoint R x y)) y = x := by rw [midpoint_comm, Equiv.pointReflection_midpoint_left] theorem midpoint_vsub_midpoint (p₁ p₂ p₃ p₄ : P) : midpoint R p₁ p₂ -ᵥ midpoint R p₃ p₄ = midpoint R (p₁ -ᵥ p₃) (p₂ -ᵥ p₄) := lineMap_vsub_lineMap _ _ _ _ _ #align midpoint_vsub_midpoint midpoint_vsub_midpoint theorem midpoint_vadd_midpoint (v v' : V) (p p' : P) : midpoint R v v' +ᵥ midpoint R p p' = midpoint R (v +ᵥ p) (v' +ᵥ p') := lineMap_vadd_lineMap _ _ _ _ _ #align midpoint_vadd_midpoint midpoint_vadd_midpoint theorem midpoint_eq_iff {x y z : P} : midpoint R x y = z ↔ pointReflection R z x = y := eq_comm.trans ((injective_pointReflection_left_of_module R x).eq_iff' (AffineEquiv.pointReflection_midpoint_left x y)).symm #align midpoint_eq_iff midpoint_eq_iff @[simp] theorem midpoint_pointReflection_left (x y : P) : midpoint R (Equiv.pointReflection x y) y = x := midpoint_eq_iff.2 <| Equiv.pointReflection_involutive _ _ @[simp] theorem midpoint_pointReflection_right (x y : P) : midpoint R y (Equiv.pointReflection x y) = x := midpoint_eq_iff.2 rfl @[simp] theorem midpoint_vsub_left (p₁ p₂ : P) : midpoint R p₁ p₂ -ᵥ p₁ = (⅟ 2 : R) • (p₂ -ᵥ p₁) := lineMap_vsub_left _ _ _ #align midpoint_vsub_left midpoint_vsub_left @[simp] theorem midpoint_vsub_right (p₁ p₂ : P) : midpoint R p₁ p₂ -ᵥ p₂ = (⅟ 2 : R) • (p₁ -ᵥ p₂) := by rw [midpoint_comm, midpoint_vsub_left] #align midpoint_vsub_right midpoint_vsub_right @[simp] theorem left_vsub_midpoint (p₁ p₂ : P) : p₁ -ᵥ midpoint R p₁ p₂ = (⅟ 2 : R) • (p₁ -ᵥ p₂) := left_vsub_lineMap _ _ _ #align left_vsub_midpoint left_vsub_midpoint @[simp] theorem right_vsub_midpoint (p₁ p₂ : P) : p₂ -ᵥ midpoint R p₁ p₂ = (⅟ 2 : R) • (p₂ -ᵥ p₁) := by rw [midpoint_comm, left_vsub_midpoint] #align right_vsub_midpoint right_vsub_midpoint
Mathlib/LinearAlgebra/AffineSpace/Midpoint.lean
133
137
theorem midpoint_vsub (p₁ p₂ p : P) : midpoint R p₁ p₂ -ᵥ p = (⅟ 2 : R) • (p₁ -ᵥ p) + (⅟ 2 : R) • (p₂ -ᵥ p) := by
rw [← vsub_sub_vsub_cancel_right p₁ p p₂, smul_sub, sub_eq_add_neg, ← smul_neg, neg_vsub_eq_vsub_rev, add_assoc, invOf_two_smul_add_invOf_two_smul, ← vadd_vsub_assoc, midpoint_comm, midpoint, lineMap_apply]
import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.Multiset.Dedup #align_import data.multiset.bind from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" assert_not_exists MonoidWithZero assert_not_exists MulAction universe v variable {α : Type*} {β : Type v} {γ δ : Type*} namespace Multiset def join : Multiset (Multiset α) → Multiset α := sum #align multiset.join Multiset.join theorem coe_join : ∀ L : List (List α), join (L.map ((↑) : List α → Multiset α) : Multiset (Multiset α)) = L.join | [] => rfl | l :: L => by exact congr_arg (fun s : Multiset α => ↑l + s) (coe_join L) #align multiset.coe_join Multiset.coe_join @[simp] theorem join_zero : @join α 0 = 0 := rfl #align multiset.join_zero Multiset.join_zero @[simp] theorem join_cons (s S) : @join α (s ::ₘ S) = s + join S := sum_cons _ _ #align multiset.join_cons Multiset.join_cons @[simp] theorem join_add (S T) : @join α (S + T) = join S + join T := sum_add _ _ #align multiset.join_add Multiset.join_add @[simp] theorem singleton_join (a) : join ({a} : Multiset (Multiset α)) = a := sum_singleton _ #align multiset.singleton_join Multiset.singleton_join @[simp] theorem mem_join {a S} : a ∈ @join α S ↔ ∃ s ∈ S, a ∈ s := Multiset.induction_on S (by simp) <| by simp (config := { contextual := true }) [or_and_right, exists_or] #align multiset.mem_join Multiset.mem_join @[simp] theorem card_join (S) : card (@join α S) = sum (map card S) := Multiset.induction_on S (by simp) (by simp) #align multiset.card_join Multiset.card_join @[simp] theorem map_join (f : α → β) (S : Multiset (Multiset α)) : map f (join S) = join (map (map f) S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] @[to_additive (attr := simp)] theorem prod_join [CommMonoid α] {S : Multiset (Multiset α)} : prod (join S) = prod (map prod S) := by induction S using Multiset.induction with | empty => simp | cons _ _ ih => simp [ih] theorem rel_join {r : α → β → Prop} {s t} (h : Rel (Rel r) s t) : Rel r s.join t.join := by induction h with | zero => simp | cons hab hst ih => simpa using hab.add ih #align multiset.rel_join Multiset.rel_join section Bind variable (a : α) (s t : Multiset α) (f g : α → Multiset β) def bind (s : Multiset α) (f : α → Multiset β) : Multiset β := (s.map f).join #align multiset.bind Multiset.bind @[simp]
Mathlib/Data/Multiset/Bind.lean
115
117
theorem coe_bind (l : List α) (f : α → List β) : (@bind α β l fun a => f a) = l.bind f := by
rw [List.bind, ← coe_join, List.map_map] rfl
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Basic #align_import measure_theory.function.egorov from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" noncomputable section open scoped Classical open MeasureTheory NNReal ENNReal Topology namespace MeasureTheory open Set Filter TopologicalSpace variable {α β ι : Type*} {m : MeasurableSpace α} [MetricSpace β] {μ : Measure α} namespace Egorov def notConvergentSeq [Preorder ι] (f : ι → α → β) (g : α → β) (n : ℕ) (j : ι) : Set α := ⋃ (k) (_ : j ≤ k), { x | 1 / (n + 1 : ℝ) < dist (f k x) (g x) } #align measure_theory.egorov.not_convergent_seq MeasureTheory.Egorov.notConvergentSeq variable {n : ℕ} {i j : ι} {s : Set α} {ε : ℝ} {f : ι → α → β} {g : α → β} theorem mem_notConvergentSeq_iff [Preorder ι] {x : α} : x ∈ notConvergentSeq f g n j ↔ ∃ k ≥ j, 1 / (n + 1 : ℝ) < dist (f k x) (g x) := by simp_rw [notConvergentSeq, Set.mem_iUnion, exists_prop, mem_setOf] #align measure_theory.egorov.mem_not_convergent_seq_iff MeasureTheory.Egorov.mem_notConvergentSeq_iff theorem notConvergentSeq_antitone [Preorder ι] : Antitone (notConvergentSeq f g n) := fun _ _ hjk => Set.iUnion₂_mono' fun l hl => ⟨l, le_trans hjk hl, Set.Subset.rfl⟩ #align measure_theory.egorov.not_convergent_seq_antitone MeasureTheory.Egorov.notConvergentSeq_antitone theorem measure_inter_notConvergentSeq_eq_zero [SemilatticeSup ι] [Nonempty ι] (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ ⋂ j, notConvergentSeq f g n j) = 0 := by simp_rw [Metric.tendsto_atTop, ae_iff] at hfg rw [← nonpos_iff_eq_zero, ← hfg] refine measure_mono fun x => ?_ simp only [Set.mem_inter_iff, Set.mem_iInter, ge_iff_le, mem_notConvergentSeq_iff] push_neg rintro ⟨hmem, hx⟩ refine ⟨hmem, 1 / (n + 1 : ℝ), Nat.one_div_pos_of_nat, fun N => ?_⟩ obtain ⟨n, hn₁, hn₂⟩ := hx N exact ⟨n, hn₁, hn₂.le⟩ #align measure_theory.egorov.measure_inter_not_convergent_seq_eq_zero MeasureTheory.Egorov.measure_inter_notConvergentSeq_eq_zero theorem notConvergentSeq_measurableSet [Preorder ι] [Countable ι] (hf : ∀ n, StronglyMeasurable[m] (f n)) (hg : StronglyMeasurable g) : MeasurableSet (notConvergentSeq f g n j) := MeasurableSet.iUnion fun k => MeasurableSet.iUnion fun _ => StronglyMeasurable.measurableSet_lt stronglyMeasurable_const <| (hf k).dist hg #align measure_theory.egorov.not_convergent_seq_measurable_set MeasureTheory.Egorov.notConvergentSeq_measurableSet theorem measure_notConvergentSeq_tendsto_zero [SemilatticeSup ι] [Countable ι] (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : Tendsto (fun j => μ (s ∩ notConvergentSeq f g n j)) atTop (𝓝 0) := by cases' isEmpty_or_nonempty ι with h h · have : (fun j => μ (s ∩ notConvergentSeq f g n j)) = fun j => 0 := by simp only [eq_iff_true_of_subsingleton] rw [this] exact tendsto_const_nhds rw [← measure_inter_notConvergentSeq_eq_zero hfg n, Set.inter_iInter] refine tendsto_measure_iInter (fun n => hsm.inter <| notConvergentSeq_measurableSet hf hg) (fun k l hkl => Set.inter_subset_inter_right _ <| notConvergentSeq_antitone hkl) ⟨h.some, ne_top_of_le_ne_top hs (measure_mono Set.inter_subset_left)⟩ #align measure_theory.egorov.measure_not_convergent_seq_tendsto_zero MeasureTheory.Egorov.measure_notConvergentSeq_tendsto_zero variable [SemilatticeSup ι] [Nonempty ι] [Countable ι] theorem exists_notConvergentSeq_lt (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ∃ j : ι, μ (s ∩ notConvergentSeq f g n j) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := by have ⟨N, hN⟩ := (ENNReal.tendsto_atTop ENNReal.zero_ne_top).1 (measure_notConvergentSeq_tendsto_zero hf hg hsm hs hfg n) (ENNReal.ofReal (ε * 2⁻¹ ^ n)) (by rw [gt_iff_lt, ENNReal.ofReal_pos] exact mul_pos hε (pow_pos (by norm_num) n)) rw [zero_add] at hN exact ⟨N, (hN N le_rfl).2⟩ #align measure_theory.egorov.exists_not_convergent_seq_lt MeasureTheory.Egorov.exists_notConvergentSeq_lt def notConvergentSeqLTIndex (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : ι := Classical.choose <| exists_notConvergentSeq_lt hε hf hg hsm hs hfg n #align measure_theory.egorov.not_convergent_seq_lt_index MeasureTheory.Egorov.notConvergentSeqLTIndex theorem notConvergentSeqLTIndex_spec (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) (n : ℕ) : μ (s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex hε hf hg hsm hs hfg n)) ≤ ENNReal.ofReal (ε * 2⁻¹ ^ n) := Classical.choose_spec <| exists_notConvergentSeq_lt hε hf hg hsm hs hfg n #align measure_theory.egorov.not_convergent_seq_lt_index_spec MeasureTheory.Egorov.notConvergentSeqLTIndex_spec def iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : Set α := ⋃ n, s ∩ notConvergentSeq f g n (notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg n) #align measure_theory.egorov.Union_not_convergent_seq MeasureTheory.Egorov.iUnionNotConvergentSeq theorem iUnionNotConvergentSeq_measurableSet (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : MeasurableSet <| iUnionNotConvergentSeq hε hf hg hsm hs hfg := MeasurableSet.iUnion fun _ => hsm.inter <| notConvergentSeq_measurableSet hf hg #align measure_theory.egorov.Union_not_convergent_seq_measurable_set MeasureTheory.Egorov.iUnionNotConvergentSeq_measurableSet theorem measure_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : μ (iUnionNotConvergentSeq hε hf hg hsm hs hfg) ≤ ENNReal.ofReal ε := by refine le_trans (measure_iUnion_le _) (le_trans (ENNReal.tsum_le_tsum <| notConvergentSeqLTIndex_spec (half_pos hε) hf hg hsm hs hfg) ?_) simp_rw [ENNReal.ofReal_mul (half_pos hε).le] rw [ENNReal.tsum_mul_left, ← ENNReal.ofReal_tsum_of_nonneg, inv_eq_one_div, tsum_geometric_two, ← ENNReal.ofReal_mul (half_pos hε).le, div_mul_cancel₀ ε two_ne_zero] · intro n; positivity · rw [inv_eq_one_div] exact summable_geometric_two #align measure_theory.egorov.measure_Union_not_convergent_seq MeasureTheory.Egorov.measure_iUnionNotConvergentSeq theorem iUnionNotConvergentSeq_subset (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : iUnionNotConvergentSeq hε hf hg hsm hs hfg ⊆ s := by rw [iUnionNotConvergentSeq, ← Set.inter_iUnion] exact Set.inter_subset_left #align measure_theory.egorov.Union_not_convergent_seq_subset MeasureTheory.Egorov.iUnionNotConvergentSeq_subset
Mathlib/MeasureTheory/Function/Egorov.lean
168
184
theorem tendstoUniformlyOn_diff_iUnionNotConvergentSeq (hε : 0 < ε) (hf : ∀ n, StronglyMeasurable (f n)) (hg : StronglyMeasurable g) (hsm : MeasurableSet s) (hs : μ s ≠ ∞) (hfg : ∀ᵐ x ∂μ, x ∈ s → Tendsto (fun n => f n x) atTop (𝓝 (g x))) : TendstoUniformlyOn f g atTop (s \ Egorov.iUnionNotConvergentSeq hε hf hg hsm hs hfg) := by
rw [Metric.tendstoUniformlyOn_iff] intro δ hδ obtain ⟨N, hN⟩ := exists_nat_one_div_lt hδ rw [eventually_atTop] refine ⟨Egorov.notConvergentSeqLTIndex (half_pos hε) hf hg hsm hs hfg N, fun n hn x hx => ?_⟩ simp only [Set.mem_diff, Egorov.iUnionNotConvergentSeq, not_exists, Set.mem_iUnion, Set.mem_inter_iff, not_and, exists_and_left] at hx obtain ⟨hxs, hx⟩ := hx specialize hx hxs N rw [Egorov.mem_notConvergentSeq_iff] at hx push_neg at hx rw [dist_comm] exact lt_of_le_of_lt (hx n hn) hN
import Mathlib.LinearAlgebra.TensorProduct.RightExactness import Mathlib.LinearAlgebra.TensorProduct.Finiteness universe u variable (R : Type u) [CommRing R] variable {M : Type u} [AddCommGroup M] [Module R M] variable {N : Type u} [AddCommGroup N] [Module R N] open Classical DirectSum LinearMap Function Submodule namespace TensorProduct variable {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N} variable (m n) in abbrev VanishesTrivially : Prop := ∃ (κ : Type u) (_ : Fintype κ) (a : ι → κ → R) (y : κ → N), (∀ i, n i = ∑ j, a i j • y j) ∧ ∀ j, ∑ i, a i j • m i = 0 theorem sum_tmul_eq_zero_of_vanishesTrivially (hmn : VanishesTrivially R m n) : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := by obtain ⟨κ, _, a, y, h₁, h₂⟩ := hmn simp_rw [h₁, tmul_sum, tmul_smul] rw [Finset.sum_comm] simp_rw [← tmul_smul, ← smul_tmul, ← sum_tmul, h₂, zero_tmul, Finset.sum_const_zero] theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Define a map $G \colon R^\iota \to M$ whose matrix entries are the $m_i$. It is surjective. set G : (ι →₀ R) →ₗ[R] M := Finsupp.total ι M R m with hG have G_basis_eq (i : ι) : G (Finsupp.single i 1) = m i := by simp [hG, toModule_lof] have G_surjective : Surjective G := by apply LinearMap.range_eq_top.mp apply top_le_iff.mp rw [← hm] apply Submodule.span_le.mpr rintro _ ⟨i, rfl⟩ use Finsupp.single i 1, G_basis_eq i set en : (ι →₀ R) ⊗[R] N := ∑ i, Finsupp.single i 1 ⊗ₜ n i with hen have en_mem_ker : en ∈ ker (rTensor N G) := by simp [hen, G_basis_eq, hmn] -- We have an exact sequence $\ker G \to R^\iota \to M \to 0$. have exact_ker_subtype : Exact (ker G).subtype G := G.exact_subtype_ker_map -- Tensor the exact sequence with $N$. have exact_rTensor_ker_subtype : Exact (rTensor N (ker G).subtype) (rTensor N G) := rTensor_exact (M := ↥(ker G)) N exact_ker_subtype G_surjective have en_mem_range : en ∈ range (rTensor N (ker G).subtype) := exact_rTensor_ker_subtype.linearMap_ker_eq ▸ en_mem_ker obtain ⟨kn, hkn⟩ := en_mem_range obtain ⟨ma, rfl : kn = ∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2⟩ := exists_finset kn use ↑↑ma, FinsetCoe.fintype ma use fun i ⟨⟨kj, _⟩, _⟩ ↦ (kj : ι →₀ R) i use fun ⟨⟨_, yj⟩, _⟩ ↦ yj constructor · intro i apply_fun finsuppScalarLeft R N ι at hkn apply_fun (· i) at hkn symm at hkn simp only [map_sum, finsuppScalarLeft_apply_tmul, zero_smul, Finsupp.single_zero, Finsupp.sum_single_index, one_smul, Finsupp.finset_sum_apply, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, rTensor_tmul, coeSubtype, Finsupp.sum_apply, Finsupp.sum_ite_eq', Finsupp.mem_support_iff, ne_eq, ite_not, en] at hkn simp only [Finset.univ_eq_attach, Finset.sum_attach ma (fun x ↦ (x.1 : ι →₀ R) i • x.2)] convert hkn using 2 with x _ split · next h'x => rw [h'x, zero_smul] · rfl · rintro ⟨⟨⟨k, hk⟩, _⟩, _⟩ simpa only [hG, Finsupp.total_apply, zero_smul, implies_true, Finsupp.sum_fintype] using mem_ker.mp hk theorem vanishesTrivially_iff_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero R hm⟩ theorem vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Restrict `m` on the codomain to $M'$, then apply `vanishesTrivially_of_sum_tmul_eq_zero`. have mem_M' i : m i ∈ span R (Set.range m) := subset_span ⟨i, rfl⟩ set m' : ι → span R (Set.range m) := Subtype.coind m mem_M' with m'_eq have hm' : span R (Set.range m') = ⊤ := by apply map_injective_of_injective (injective_subtype (span R (Set.range m))) rw [Submodule.map_span, Submodule.map_top, range_subtype, coeSubtype, ← Set.range_comp] rfl have hm'n : ∑ i, m' i ⊗ₜ n i = (0 : span R (Set.range m) ⊗[R] N) := by apply hm simp only [m'_eq, map_sum, rTensor_tmul, coeSubtype, Subtype.coind_coe, _root_.map_zero, hmn] have : VanishesTrivially R m' n := vanishesTrivially_of_sum_tmul_eq_zero R hm' hm'n unfold VanishesTrivially at this ⊢ convert this with κ _ a y j convert (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ simp [m'_eq] theorem vanishesTrivially_iff_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R hm⟩
Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean
211
226
theorem rTensor_injective_of_forall_vanishesTrivially (hMN : ∀ {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) (M' : Submodule R M) : Injective (rTensor N M'.subtype) := by
apply (injective_iff_map_eq_zero _).mpr rintro x hx obtain ⟨s, rfl⟩ := exists_finset x rw [← Finset.sum_attach] apply sum_tmul_eq_zero_of_vanishesTrivially simp only [map_sum, rTensor_tmul, coeSubtype] at hx have := hMN ((Finset.sum_attach s _).trans hx) unfold VanishesTrivially at this ⊢ convert this with κ _ a y j symm convert (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ simp
import Mathlib.Data.Finset.Lattice import Mathlib.Data.Multiset.Powerset #align_import data.finset.powerset from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" namespace Finset open Function Multiset variable {α : Type*} {s t : Finset α} section powersetCard variable {n} {s t : Finset α} def powersetCard (n : ℕ) (s : Finset α) : Finset (Finset α) := ⟨((s.1.powersetCard n).pmap Finset.mk) fun _t h => nodup_of_le (mem_powersetCard.1 h).1 s.2, s.2.powersetCard.pmap fun _a _ha _b _hb => congr_arg Finset.val⟩ #align finset.powerset_len Finset.powersetCard @[simp] lemma mem_powersetCard : s ∈ powersetCard n t ↔ s ⊆ t ∧ card s = n := by cases s; simp [powersetCard, val_le_iff.symm] #align finset.mem_powerset_len Finset.mem_powersetCard @[simp] theorem powersetCard_mono {n} {s t : Finset α} (h : s ⊆ t) : powersetCard n s ⊆ powersetCard n t := fun _u h' => mem_powersetCard.2 <| And.imp (fun h₂ => Subset.trans h₂ h) id (mem_powersetCard.1 h') #align finset.powerset_len_mono Finset.powersetCard_mono @[simp] theorem card_powersetCard (n : ℕ) (s : Finset α) : card (powersetCard n s) = Nat.choose (card s) n := (card_pmap _ _ _).trans (Multiset.card_powersetCard n s.1) #align finset.card_powerset_len Finset.card_powersetCard @[simp]
Mathlib/Data/Finset/Powerset.lean
220
225
theorem powersetCard_zero (s : Finset α) : s.powersetCard 0 = {∅} := by
ext; rw [mem_powersetCard, mem_singleton, card_eq_zero] refine ⟨fun h => h.2, fun h => by rw [h] exact ⟨empty_subset s, rfl⟩⟩
import Mathlib.Topology.Connected.Basic open Set Topology universe u v variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α] {s t u v : Set α} section LocallyConnectedSpace class LocallyConnectedSpace (α : Type*) [TopologicalSpace α] : Prop where open_connected_basis : ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id #align locally_connected_space LocallyConnectedSpace theorem locallyConnectedSpace_iff_open_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => IsOpen s ∧ x ∈ s ∧ IsConnected s) id := ⟨@LocallyConnectedSpace.open_connected_basis _ _, LocallyConnectedSpace.mk⟩ #align locally_connected_space_iff_open_connected_basis locallyConnectedSpace_iff_open_connected_basis theorem locallyConnectedSpace_iff_open_connected_subsets : LocallyConnectedSpace α ↔ ∀ x, ∀ U ∈ 𝓝 x, ∃ V : Set α, V ⊆ U ∧ IsOpen V ∧ x ∈ V ∧ IsConnected V := by simp_rw [locallyConnectedSpace_iff_open_connected_basis] refine forall_congr' fun _ => ?_ constructor · intro h U hU rcases h.mem_iff.mp hU with ⟨V, hV, hVU⟩ exact ⟨V, hVU, hV⟩ · exact fun h => ⟨fun U => ⟨fun hU => let ⟨V, hVU, hV⟩ := h U hU ⟨V, hV, hVU⟩, fun ⟨V, ⟨hV, hxV, _⟩, hVU⟩ => mem_nhds_iff.mpr ⟨V, hVU, hV, hxV⟩⟩⟩ #align locally_connected_space_iff_open_connected_subsets locallyConnectedSpace_iff_open_connected_subsets instance (priority := 100) DiscreteTopology.toLocallyConnectedSpace (α) [TopologicalSpace α] [DiscreteTopology α] : LocallyConnectedSpace α := locallyConnectedSpace_iff_open_connected_subsets.2 fun x _U hU => ⟨{x}, singleton_subset_iff.2 <| mem_of_mem_nhds hU, isOpen_discrete _, rfl, isConnected_singleton⟩ #align discrete_topology.to_locally_connected_space DiscreteTopology.toLocallyConnectedSpace theorem connectedComponentIn_mem_nhds [LocallyConnectedSpace α] {F : Set α} {x : α} (h : F ∈ 𝓝 x) : connectedComponentIn F x ∈ 𝓝 x := by rw [(LocallyConnectedSpace.open_connected_basis x).mem_iff] at h rcases h with ⟨s, ⟨h1s, hxs, h2s⟩, hsF⟩ exact mem_nhds_iff.mpr ⟨s, h2s.isPreconnected.subset_connectedComponentIn hxs hsF, h1s, hxs⟩ #align connected_component_in_mem_nhds connectedComponentIn_mem_nhds protected theorem IsOpen.connectedComponentIn [LocallyConnectedSpace α] {F : Set α} {x : α} (hF : IsOpen F) : IsOpen (connectedComponentIn F x) := by rw [isOpen_iff_mem_nhds] intro y hy rw [connectedComponentIn_eq hy] exact connectedComponentIn_mem_nhds (hF.mem_nhds <| connectedComponentIn_subset F x hy) #align is_open.connected_component_in IsOpen.connectedComponentIn theorem isOpen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsOpen (connectedComponent x) := by rw [← connectedComponentIn_univ] exact isOpen_univ.connectedComponentIn #align is_open_connected_component isOpen_connectedComponent theorem isClopen_connectedComponent [LocallyConnectedSpace α] {x : α} : IsClopen (connectedComponent x) := ⟨isClosed_connectedComponent, isOpen_connectedComponent⟩ #align is_clopen_connected_component isClopen_connectedComponent theorem locallyConnectedSpace_iff_connectedComponentIn_open : LocallyConnectedSpace α ↔ ∀ F : Set α, IsOpen F → ∀ x ∈ F, IsOpen (connectedComponentIn F x) := by constructor · intro h exact fun F hF x _ => hF.connectedComponentIn · intro h rw [locallyConnectedSpace_iff_open_connected_subsets] refine fun x U hU => ⟨connectedComponentIn (interior U) x, (connectedComponentIn_subset _ _).trans interior_subset, h _ isOpen_interior x ?_, mem_connectedComponentIn ?_, isConnected_connectedComponentIn_iff.mpr ?_⟩ <;> exact mem_interior_iff_mem_nhds.mpr hU #align locally_connected_space_iff_connected_component_in_open locallyConnectedSpace_iff_connectedComponentIn_open theorem locallyConnectedSpace_iff_connected_subsets : LocallyConnectedSpace α ↔ ∀ (x : α), ∀ U ∈ 𝓝 x, ∃ V ∈ 𝓝 x, IsPreconnected V ∧ V ⊆ U := by constructor · rw [locallyConnectedSpace_iff_open_connected_subsets] intro h x U hxU rcases h x U hxU with ⟨V, hVU, hV₁, hxV, hV₂⟩ exact ⟨V, hV₁.mem_nhds hxV, hV₂.isPreconnected, hVU⟩ · rw [locallyConnectedSpace_iff_connectedComponentIn_open] refine fun h U hU x _ => isOpen_iff_mem_nhds.mpr fun y hy => ?_ rw [connectedComponentIn_eq hy] rcases h y U (hU.mem_nhds <| (connectedComponentIn_subset _ _) hy) with ⟨V, hVy, hV, hVU⟩ exact Filter.mem_of_superset hVy (hV.subset_connectedComponentIn (mem_of_mem_nhds hVy) hVU) #align locally_connected_space_iff_connected_subsets locallyConnectedSpace_iff_connected_subsets theorem locallyConnectedSpace_iff_connected_basis : LocallyConnectedSpace α ↔ ∀ x, (𝓝 x).HasBasis (fun s : Set α => s ∈ 𝓝 x ∧ IsPreconnected s) id := by rw [locallyConnectedSpace_iff_connected_subsets] exact forall_congr' fun x => Filter.hasBasis_self.symm #align locally_connected_space_iff_connected_basis locallyConnectedSpace_iff_connected_basis
Mathlib/Topology/Connected/LocallyConnected.lean
125
132
theorem locallyConnectedSpace_of_connected_bases {ι : Type*} (b : α → ι → Set α) (p : α → ι → Prop) (hbasis : ∀ x, (𝓝 x).HasBasis (p x) (b x)) (hconnected : ∀ x i, p x i → IsPreconnected (b x i)) : LocallyConnectedSpace α := by
rw [locallyConnectedSpace_iff_connected_basis] exact fun x => (hbasis x).to_hasBasis (fun i hi => ⟨b x i, ⟨(hbasis x).mem_of_mem hi, hconnected x i hi⟩, subset_rfl⟩) fun s hs => ⟨(hbasis x).index s hs.1, ⟨(hbasis x).property_index hs.1, (hbasis x).set_index_subset hs.1⟩⟩
import Mathlib.Analysis.PSeries import Mathlib.Data.Real.Pi.Wallis import Mathlib.Tactic.AdaptationNote #align_import analysis.special_functions.stirling from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" open scoped Topology Real Nat Asymptotics open Finset Filter Nat Real namespace Stirling noncomputable def stirlingSeq (n : ℕ) : ℝ := n ! / (√(2 * n : ℝ) * (n / exp 1) ^ n) #align stirling.stirling_seq Stirling.stirlingSeq @[simp] theorem stirlingSeq_zero : stirlingSeq 0 = 0 := by rw [stirlingSeq, cast_zero, mul_zero, Real.sqrt_zero, zero_mul, div_zero] #align stirling.stirling_seq_zero Stirling.stirlingSeq_zero @[simp] theorem stirlingSeq_one : stirlingSeq 1 = exp 1 / √2 := by rw [stirlingSeq, pow_one, factorial_one, cast_one, mul_one, mul_one_div, one_div_div] #align stirling.stirling_seq_one Stirling.stirlingSeq_one theorem log_stirlingSeq_formula (n : ℕ) : log (stirlingSeq n) = Real.log n ! - 1 / 2 * Real.log (2 * n) - n * log (n / exp 1) := by cases n · simp · rw [stirlingSeq, log_div, log_mul, sqrt_eq_rpow, log_rpow, Real.log_pow, tsub_tsub] <;> positivity -- Porting note: generalized from `n.succ` to `n` #align stirling.log_stirling_seq_formula Stirling.log_stirlingSeq_formulaₓ
Mathlib/Analysis/SpecialFunctions/Stirling.lean
77
93
theorem log_stirlingSeq_diff_hasSum (m : ℕ) : HasSum (fun k : ℕ => (1 : ℝ) / (2 * ↑(k + 1) + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ ↑(k + 1)) (log (stirlingSeq (m + 1)) - log (stirlingSeq (m + 2))) := by
let f (k : ℕ) := (1 : ℝ) / (2 * k + 1) * ((1 / (2 * ↑(m + 1) + 1)) ^ 2) ^ k change HasSum (fun k => f (k + 1)) _ rw [hasSum_nat_add_iff] convert (hasSum_log_one_add_inv m.cast_add_one_pos).mul_left ((↑(m + 1) : ℝ) + 1 / 2) using 1 · ext k dsimp only [f] rw [← pow_mul, pow_add] push_cast field_simp ring · have h : ∀ x ≠ (0 : ℝ), 1 + x⁻¹ = (x + 1) / x := fun x hx ↦ by field_simp [hx] simp (disch := positivity) only [log_stirlingSeq_formula, log_div, log_mul, log_exp, factorial_succ, cast_mul, cast_succ, cast_zero, range_one, sum_singleton, h] ring
import Mathlib.Topology.Separation import Mathlib.Topology.UniformSpace.Basic import Mathlib.Topology.UniformSpace.Cauchy #align_import topology.uniform_space.uniform_convergence from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" noncomputable section open Topology Uniformity Filter Set universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x} [UniformSpace β] variable {F : ι → α → β} {f : α → β} {s s' : Set α} {x : α} {p : Filter ι} {p' : Filter α} {g : ι → α} def TendstoUniformlyOnFilter (F : ι → α → β) (f : α → β) (p : Filter ι) (p' : Filter α) := ∀ u ∈ 𝓤 β, ∀ᶠ n : ι × α in p ×ˢ p', (f n.snd, F n.fst n.snd) ∈ u #align tendsto_uniformly_on_filter TendstoUniformlyOnFilter theorem tendstoUniformlyOnFilter_iff_tendsto : TendstoUniformlyOnFilter F f p p' ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ p') (𝓤 β) := Iff.rfl #align tendsto_uniformly_on_filter_iff_tendsto tendstoUniformlyOnFilter_iff_tendsto def TendstoUniformlyOn (F : ι → α → β) (f : α → β) (p : Filter ι) (s : Set α) := ∀ u ∈ 𝓤 β, ∀ᶠ n in p, ∀ x : α, x ∈ s → (f x, F n x) ∈ u #align tendsto_uniformly_on TendstoUniformlyOn theorem tendstoUniformlyOn_iff_tendstoUniformlyOnFilter : TendstoUniformlyOn F f p s ↔ TendstoUniformlyOnFilter F f p (𝓟 s) := by simp only [TendstoUniformlyOn, TendstoUniformlyOnFilter] apply forall₂_congr simp_rw [eventually_prod_principal_iff] simp #align tendsto_uniformly_on_iff_tendsto_uniformly_on_filter tendstoUniformlyOn_iff_tendstoUniformlyOnFilter alias ⟨TendstoUniformlyOn.tendstoUniformlyOnFilter, TendstoUniformlyOnFilter.tendstoUniformlyOn⟩ := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter #align tendsto_uniformly_on.tendsto_uniformly_on_filter TendstoUniformlyOn.tendstoUniformlyOnFilter #align tendsto_uniformly_on_filter.tendsto_uniformly_on TendstoUniformlyOnFilter.tendstoUniformlyOn theorem tendstoUniformlyOn_iff_tendsto {F : ι → α → β} {f : α → β} {p : Filter ι} {s : Set α} : TendstoUniformlyOn F f p s ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ 𝓟 s) (𝓤 β) := by simp [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_on_iff_tendsto tendstoUniformlyOn_iff_tendsto def TendstoUniformly (F : ι → α → β) (f : α → β) (p : Filter ι) := ∀ u ∈ 𝓤 β, ∀ᶠ n in p, ∀ x : α, (f x, F n x) ∈ u #align tendsto_uniformly TendstoUniformly -- Porting note: moved from below theorem tendstoUniformlyOn_univ : TendstoUniformlyOn F f p univ ↔ TendstoUniformly F f p := by simp [TendstoUniformlyOn, TendstoUniformly] #align tendsto_uniformly_on_univ tendstoUniformlyOn_univ theorem tendstoUniformly_iff_tendstoUniformlyOnFilter : TendstoUniformly F f p ↔ TendstoUniformlyOnFilter F f p ⊤ := by rw [← tendstoUniformlyOn_univ, tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, principal_univ] #align tendsto_uniformly_iff_tendsto_uniformly_on_filter tendstoUniformly_iff_tendstoUniformlyOnFilter theorem TendstoUniformly.tendstoUniformlyOnFilter (h : TendstoUniformly F f p) : TendstoUniformlyOnFilter F f p ⊤ := by rwa [← tendstoUniformly_iff_tendstoUniformlyOnFilter] #align tendsto_uniformly.tendsto_uniformly_on_filter TendstoUniformly.tendstoUniformlyOnFilter theorem tendstoUniformlyOn_iff_tendstoUniformly_comp_coe : TendstoUniformlyOn F f p s ↔ TendstoUniformly (fun i (x : s) => F i x) (f ∘ (↑)) p := forall₂_congr fun u _ => by simp #align tendsto_uniformly_on_iff_tendsto_uniformly_comp_coe tendstoUniformlyOn_iff_tendstoUniformly_comp_coe theorem tendstoUniformly_iff_tendsto {F : ι → α → β} {f : α → β} {p : Filter ι} : TendstoUniformly F f p ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ ⊤) (𝓤 β) := by simp [tendstoUniformly_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_iff_tendsto tendstoUniformly_iff_tendsto theorem TendstoUniformlyOnFilter.tendsto_at (h : TendstoUniformlyOnFilter F f p p') (hx : 𝓟 {x} ≤ p') : Tendsto (fun n => F n x) p <| 𝓝 (f x) := by refine Uniform.tendsto_nhds_right.mpr fun u hu => mem_map.mpr ?_ filter_upwards [(h u hu).curry] intro i h simpa using h.filter_mono hx #align tendsto_uniformly_on_filter.tendsto_at TendstoUniformlyOnFilter.tendsto_at theorem TendstoUniformlyOn.tendsto_at (h : TendstoUniformlyOn F f p s) {x : α} (hx : x ∈ s) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.tendstoUniformlyOnFilter.tendsto_at (le_principal_iff.mpr <| mem_principal.mpr <| singleton_subset_iff.mpr <| hx) #align tendsto_uniformly_on.tendsto_at TendstoUniformlyOn.tendsto_at theorem TendstoUniformly.tendsto_at (h : TendstoUniformly F f p) (x : α) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.tendstoUniformlyOnFilter.tendsto_at le_top #align tendsto_uniformly.tendsto_at TendstoUniformly.tendsto_at -- Porting note: tendstoUniformlyOn_univ moved up theorem TendstoUniformlyOnFilter.mono_left {p'' : Filter ι} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≤ p) : TendstoUniformlyOnFilter F f p'' p' := fun u hu => (h u hu).filter_mono (p'.prod_mono_left hp) #align tendsto_uniformly_on_filter.mono_left TendstoUniformlyOnFilter.mono_left theorem TendstoUniformlyOnFilter.mono_right {p'' : Filter α} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≤ p') : TendstoUniformlyOnFilter F f p p'' := fun u hu => (h u hu).filter_mono (p.prod_mono_right hp) #align tendsto_uniformly_on_filter.mono_right TendstoUniformlyOnFilter.mono_right theorem TendstoUniformlyOn.mono {s' : Set α} (h : TendstoUniformlyOn F f p s) (h' : s' ⊆ s) : TendstoUniformlyOn F f p s' := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (h.tendstoUniformlyOnFilter.mono_right (le_principal_iff.mpr <| mem_principal.mpr h')) #align tendsto_uniformly_on.mono TendstoUniformlyOn.mono theorem TendstoUniformlyOnFilter.congr {F' : ι → α → β} (hf : TendstoUniformlyOnFilter F f p p') (hff' : ∀ᶠ n : ι × α in p ×ˢ p', F n.fst n.snd = F' n.fst n.snd) : TendstoUniformlyOnFilter F' f p p' := by refine fun u hu => ((hf u hu).and hff').mono fun n h => ?_ rw [← h.right] exact h.left #align tendsto_uniformly_on_filter.congr TendstoUniformlyOnFilter.congr theorem TendstoUniformlyOn.congr {F' : ι → α → β} (hf : TendstoUniformlyOn F f p s) (hff' : ∀ᶠ n in p, Set.EqOn (F n) (F' n) s) : TendstoUniformlyOn F' f p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at hf ⊢ refine hf.congr ?_ rw [eventually_iff] at hff' ⊢ simp only [Set.EqOn] at hff' simp only [mem_prod_principal, hff', mem_setOf_eq] #align tendsto_uniformly_on.congr TendstoUniformlyOn.congr theorem TendstoUniformlyOn.congr_right {g : α → β} (hf : TendstoUniformlyOn F f p s) (hfg : EqOn f g s) : TendstoUniformlyOn F g p s := fun u hu => by filter_upwards [hf u hu] with i hi a ha using hfg ha ▸ hi a ha #align tendsto_uniformly_on.congr_right TendstoUniformlyOn.congr_right protected theorem TendstoUniformly.tendstoUniformlyOn (h : TendstoUniformly F f p) : TendstoUniformlyOn F f p s := (tendstoUniformlyOn_univ.2 h).mono (subset_univ s) #align tendsto_uniformly.tendsto_uniformly_on TendstoUniformly.tendstoUniformlyOn theorem TendstoUniformlyOnFilter.comp (h : TendstoUniformlyOnFilter F f p p') (g : γ → α) : TendstoUniformlyOnFilter (fun n => F n ∘ g) (f ∘ g) p (p'.comap g) := by rw [tendstoUniformlyOnFilter_iff_tendsto] at h ⊢ exact h.comp (tendsto_id.prod_map tendsto_comap) #align tendsto_uniformly_on_filter.comp TendstoUniformlyOnFilter.comp theorem TendstoUniformlyOn.comp (h : TendstoUniformlyOn F f p s) (g : γ → α) : TendstoUniformlyOn (fun n => F n ∘ g) (f ∘ g) p (g ⁻¹' s) := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h ⊢ simpa [TendstoUniformlyOn, comap_principal] using TendstoUniformlyOnFilter.comp h g #align tendsto_uniformly_on.comp TendstoUniformlyOn.comp theorem TendstoUniformly.comp (h : TendstoUniformly F f p) (g : γ → α) : TendstoUniformly (fun n => F n ∘ g) (f ∘ g) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] at h ⊢ simpa [principal_univ, comap_principal] using h.comp g #align tendsto_uniformly.comp TendstoUniformly.comp theorem UniformContinuous.comp_tendstoUniformlyOnFilter [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformlyOnFilter F f p p') : TendstoUniformlyOnFilter (fun i => g ∘ F i) (g ∘ f) p p' := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on_filter UniformContinuous.comp_tendstoUniformlyOnFilter theorem UniformContinuous.comp_tendstoUniformlyOn [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformlyOn F f p s) : TendstoUniformlyOn (fun i => g ∘ F i) (g ∘ f) p s := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on UniformContinuous.comp_tendstoUniformlyOn theorem UniformContinuous.comp_tendstoUniformly [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformly F f p) : TendstoUniformly (fun i => g ∘ F i) (g ∘ f) p := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly UniformContinuous.comp_tendstoUniformly theorem TendstoUniformlyOnFilter.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {q : Filter ι'} {q' : Filter α'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q q') : TendstoUniformlyOnFilter (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ q) (p' ×ˢ q') := by rw [tendstoUniformlyOnFilter_iff_tendsto] at h h' ⊢ rw [uniformity_prod_eq_comap_prod, tendsto_comap_iff, ← map_swap4_prod, tendsto_map'_iff] convert h.prod_map h' -- seems to be faster than `exact` here #align tendsto_uniformly_on_filter.prod_map TendstoUniformlyOnFilter.prod_map theorem TendstoUniformlyOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {p' : Filter ι'} {s' : Set α'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s') : TendstoUniformlyOn (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ p') (s ×ˢ s') := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h h' ⊢ simpa only [prod_principal_principal] using h.prod_map h' #align tendsto_uniformly_on.prod_map TendstoUniformlyOn.prod_map theorem TendstoUniformly.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ p') := by rw [← tendstoUniformlyOn_univ, ← univ_prod_univ] at * exact h.prod_map h' #align tendsto_uniformly.prod_map TendstoUniformly.prod_map theorem TendstoUniformlyOnFilter.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {q : Filter ι'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q p') : TendstoUniformlyOnFilter (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p ×ˢ q) p' := fun u hu => ((h.prod_map h') u hu).diag_of_prod_right #align tendsto_uniformly_on_filter.prod TendstoUniformlyOnFilter.prod theorem TendstoUniformlyOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {p' : Filter ι'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s) : TendstoUniformlyOn (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p.prod p') s := (congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a)) #align tendsto_uniformly_on.prod TendstoUniformlyOn.prod theorem TendstoUniformly.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p ×ˢ p') := (h.prod_map h').comp fun a => (a, a) #align tendsto_uniformly.prod TendstoUniformly.prod theorem tendsto_prod_filter_iff {c : β} : Tendsto (↿F) (p ×ˢ p') (𝓝 c) ↔ TendstoUniformlyOnFilter F (fun _ => c) p p' := by simp_rw [nhds_eq_comap_uniformity, tendsto_comap_iff] rfl #align tendsto_prod_filter_iff tendsto_prod_filter_iff theorem tendsto_prod_principal_iff {c : β} : Tendsto (↿F) (p ×ˢ 𝓟 s) (𝓝 c) ↔ TendstoUniformlyOn F (fun _ => c) p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_principal_iff tendsto_prod_principal_iff theorem tendsto_prod_top_iff {c : β} : Tendsto (↿F) (p ×ˢ ⊤) (𝓝 c) ↔ TendstoUniformly F (fun _ => c) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_top_iff tendsto_prod_top_iff theorem tendstoUniformlyOn_empty : TendstoUniformlyOn F f p ∅ := fun u _ => by simp #align tendsto_uniformly_on_empty tendstoUniformlyOn_empty theorem tendstoUniformlyOn_singleton_iff_tendsto : TendstoUniformlyOn F f p {x} ↔ Tendsto (fun n : ι => F n x) p (𝓝 (f x)) := by simp_rw [tendstoUniformlyOn_iff_tendsto, Uniform.tendsto_nhds_right, tendsto_def] exact forall₂_congr fun u _ => by simp [mem_prod_principal, preimage] #align tendsto_uniformly_on_singleton_iff_tendsto tendstoUniformlyOn_singleton_iff_tendsto theorem Filter.Tendsto.tendstoUniformlyOnFilter_const {g : ι → β} {b : β} (hg : Tendsto g p (𝓝 b)) (p' : Filter α) : TendstoUniformlyOnFilter (fun n : ι => fun _ : α => g n) (fun _ : α => b) p p' := by simpa only [nhds_eq_comap_uniformity, tendsto_comap_iff] using hg.comp (tendsto_fst (g := p')) #align filter.tendsto.tendsto_uniformly_on_filter_const Filter.Tendsto.tendstoUniformlyOnFilter_const theorem Filter.Tendsto.tendstoUniformlyOn_const {g : ι → β} {b : β} (hg : Tendsto g p (𝓝 b)) (s : Set α) : TendstoUniformlyOn (fun n : ι => fun _ : α => g n) (fun _ : α => b) p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hg.tendstoUniformlyOnFilter_const (𝓟 s)) #align filter.tendsto.tendsto_uniformly_on_const Filter.Tendsto.tendstoUniformlyOn_const -- Porting note (#10756): new lemma theorem UniformContinuousOn.tendstoUniformlyOn [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α} {V : Set β} {F : α → β → γ} (hF : UniformContinuousOn (↿F) (U ×ˢ V)) (hU : x ∈ U) : TendstoUniformlyOn F (F x) (𝓝[U] x) V := by set φ := fun q : α × β => ((x, q.2), q) rw [tendstoUniformlyOn_iff_tendsto] change Tendsto (Prod.map (↿F) ↿F ∘ φ) (𝓝[U] x ×ˢ 𝓟 V) (𝓤 γ) simp only [nhdsWithin, SProd.sprod, Filter.prod, comap_inf, inf_assoc, comap_principal, inf_principal] refine hF.comp (Tendsto.inf ?_ <| tendsto_principal_principal.2 fun x hx => ⟨⟨hU, hx.2⟩, hx⟩) simp only [uniformity_prod_eq_comap_prod, tendsto_comap_iff, (· ∘ ·), nhds_eq_comap_uniformity, comap_comap] exact tendsto_comap.prod_mk (tendsto_diag_uniformity _ _) theorem UniformContinuousOn.tendstoUniformly [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α} (hU : U ∈ 𝓝 x) {F : α → β → γ} (hF : UniformContinuousOn (↿F) (U ×ˢ (univ : Set β))) : TendstoUniformly F (F x) (𝓝 x) := by simpa only [tendstoUniformlyOn_univ, nhdsWithin_eq_nhds.2 hU] using hF.tendstoUniformlyOn (mem_of_mem_nhds hU) #align uniform_continuous_on.tendsto_uniformly UniformContinuousOn.tendstoUniformly theorem UniformContinuous₂.tendstoUniformly [UniformSpace α] [UniformSpace γ] {f : α → β → γ} (h : UniformContinuous₂ f) {x : α} : TendstoUniformly f (f x) (𝓝 x) := UniformContinuousOn.tendstoUniformly univ_mem <| by rwa [univ_prod_univ, uniformContinuousOn_univ] #align uniform_continuous₂.tendsto_uniformly UniformContinuous₂.tendstoUniformly def UniformCauchySeqOnFilter (F : ι → α → β) (p : Filter ι) (p' : Filter α) : Prop := ∀ u ∈ 𝓤 β, ∀ᶠ m : (ι × ι) × α in (p ×ˢ p) ×ˢ p', (F m.fst.fst m.snd, F m.fst.snd m.snd) ∈ u #align uniform_cauchy_seq_on_filter UniformCauchySeqOnFilter def UniformCauchySeqOn (F : ι → α → β) (p : Filter ι) (s : Set α) : Prop := ∀ u ∈ 𝓤 β, ∀ᶠ m : ι × ι in p ×ˢ p, ∀ x : α, x ∈ s → (F m.fst x, F m.snd x) ∈ u #align uniform_cauchy_seq_on UniformCauchySeqOn theorem uniformCauchySeqOn_iff_uniformCauchySeqOnFilter : UniformCauchySeqOn F p s ↔ UniformCauchySeqOnFilter F p (𝓟 s) := by simp only [UniformCauchySeqOn, UniformCauchySeqOnFilter] refine forall₂_congr fun u hu => ?_ rw [eventually_prod_principal_iff] #align uniform_cauchy_seq_on_iff_uniform_cauchy_seq_on_filter uniformCauchySeqOn_iff_uniformCauchySeqOnFilter theorem UniformCauchySeqOn.uniformCauchySeqOnFilter (hF : UniformCauchySeqOn F p s) : UniformCauchySeqOnFilter F p (𝓟 s) := by rwa [← uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] #align uniform_cauchy_seq_on.uniform_cauchy_seq_on_filter UniformCauchySeqOn.uniformCauchySeqOnFilter theorem TendstoUniformlyOnFilter.uniformCauchySeqOnFilter (hF : TendstoUniformlyOnFilter F f p p') : UniformCauchySeqOnFilter F p p' := by intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ have := tendsto_swap4_prod.eventually ((hF t ht).prod_mk (hF t ht)) apply this.diag_of_prod_right.mono simp only [and_imp, Prod.forall] intro n1 n2 x hl hr exact Set.mem_of_mem_of_subset (prod_mk_mem_compRel (htsymm hl) hr) htmem #align tendsto_uniformly_on_filter.uniform_cauchy_seq_on_filter TendstoUniformlyOnFilter.uniformCauchySeqOnFilter theorem TendstoUniformlyOn.uniformCauchySeqOn (hF : TendstoUniformlyOn F f p s) : UniformCauchySeqOn F p s := uniformCauchySeqOn_iff_uniformCauchySeqOnFilter.mpr hF.tendstoUniformlyOnFilter.uniformCauchySeqOnFilter #align tendsto_uniformly_on.uniform_cauchy_seq_on TendstoUniformlyOn.uniformCauchySeqOn theorem UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto [NeBot p] (hF : UniformCauchySeqOnFilter F p p') (hF' : ∀ᶠ x : α in p', Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOnFilter F f p p' := by -- Proof idea: |f_n(x) - f(x)| ≤ |f_n(x) - f_m(x)| + |f_m(x) - f(x)|. We choose `n` -- so that |f_n(x) - f_m(x)| is uniformly small across `s` whenever `m ≥ n`. Then for -- a fixed `x`, we choose `m` sufficiently large such that |f_m(x) - f(x)| is small. intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ -- We will choose n, x, and m simultaneously. n and x come from hF. m comes from hF' -- But we need to promote hF' to the full product filter to use it have hmc : ∀ᶠ x in (p ×ˢ p) ×ˢ p', Tendsto (fun n : ι => F n x.snd) p (𝓝 (f x.snd)) := by rw [eventually_prod_iff] exact ⟨fun _ => True, by simp, _, hF', by simp⟩ -- To apply filter operations we'll need to do some order manipulation rw [Filter.eventually_swap_iff] have := tendsto_prodAssoc.eventually (tendsto_prod_swap.eventually ((hF t ht).and hmc)) apply this.curry.mono simp only [Equiv.prodAssoc_apply, eventually_and, eventually_const, Prod.snd_swap, Prod.fst_swap, and_imp, Prod.forall] -- Complete the proof intro x n hx hm' refine Set.mem_of_mem_of_subset (mem_compRel.mpr ?_) htmem rw [Uniform.tendsto_nhds_right] at hm' have := hx.and (hm' ht) obtain ⟨m, hm⟩ := this.exists exact ⟨F m x, ⟨hm.2, htsymm hm.1⟩⟩ #align uniform_cauchy_seq_on_filter.tendsto_uniformly_on_filter_of_tendsto UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto theorem UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto [NeBot p] (hF : UniformCauchySeqOn F p s) (hF' : ∀ x : α, x ∈ s → Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOn F f p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hF.uniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto hF') #align uniform_cauchy_seq_on.tendsto_uniformly_on_of_tendsto UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto theorem UniformCauchySeqOnFilter.mono_left {p'' : Filter ι} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≤ p) : UniformCauchySeqOnFilter F p'' p' := by intro u hu have := (hf u hu).filter_mono (p'.prod_mono_left (Filter.prod_mono hp hp)) exact this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_left UniformCauchySeqOnFilter.mono_left theorem UniformCauchySeqOnFilter.mono_right {p'' : Filter α} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≤ p') : UniformCauchySeqOnFilter F p p'' := fun u hu => have := (hf u hu).filter_mono ((p ×ˢ p).prod_mono_right hp) this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_right UniformCauchySeqOnFilter.mono_right theorem UniformCauchySeqOn.mono {s' : Set α} (hf : UniformCauchySeqOn F p s) (hss' : s' ⊆ s) : UniformCauchySeqOn F p s' := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ⊢ exact hf.mono_right (le_principal_iff.mpr <| mem_principal.mpr hss') #align uniform_cauchy_seq_on.mono UniformCauchySeqOn.mono theorem UniformCauchySeqOnFilter.comp {γ : Type*} (hf : UniformCauchySeqOnFilter F p p') (g : γ → α) : UniformCauchySeqOnFilter (fun n => F n ∘ g) p (p'.comap g) := fun u hu => by obtain ⟨pa, hpa, pb, hpb, hpapb⟩ := eventually_prod_iff.mp (hf u hu) rw [eventually_prod_iff] refine ⟨pa, hpa, pb ∘ g, ?_, fun hx _ hy => hpapb hx hy⟩ exact eventually_comap.mpr (hpb.mono fun x hx y hy => by simp only [hx, hy, Function.comp_apply]) #align uniform_cauchy_seq_on_filter.comp UniformCauchySeqOnFilter.comp theorem UniformCauchySeqOn.comp {γ : Type*} (hf : UniformCauchySeqOn F p s) (g : γ → α) : UniformCauchySeqOn (fun n => F n ∘ g) p (g ⁻¹' s) := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ⊢ simpa only [UniformCauchySeqOn, comap_principal] using hf.comp g #align uniform_cauchy_seq_on.comp UniformCauchySeqOn.comp theorem UniformContinuous.comp_uniformCauchySeqOn [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (hf : UniformCauchySeqOn F p s) : UniformCauchySeqOn (fun n => g ∘ F n) p s := fun _u hu => hf _ (hg hu) #align uniform_continuous.comp_uniform_cauchy_seq_on UniformContinuous.comp_uniformCauchySeqOn theorem UniformCauchySeqOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {p' : Filter ι'} {s' : Set α'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s') : UniformCauchySeqOn (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (p ×ˢ p') (s ×ˢ s') := by intro u hu rw [uniformity_prod_eq_prod, mem_map, mem_prod_iff] at hu obtain ⟨v, hv, w, hw, hvw⟩ := hu simp_rw [mem_prod, Prod.map_apply, and_imp, Prod.forall] rw [← Set.image_subset_iff] at hvw apply (tendsto_swap4_prod.eventually ((h v hv).prod_mk (h' w hw))).mono intro x hx a b ha hb exact hvw ⟨_, mk_mem_prod (hx.1 a ha) (hx.2 b hb), rfl⟩ #align uniform_cauchy_seq_on.prod_map UniformCauchySeqOn.prod_map theorem UniformCauchySeqOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {p' : Filter ι'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s) : UniformCauchySeqOn (fun (i : ι × ι') a => (F i.fst a, F' i.snd a)) (p ×ˢ p') s := (congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a)) #align uniform_cauchy_seq_on.prod UniformCauchySeqOn.prod theorem UniformCauchySeqOn.prod' {β' : Type*} [UniformSpace β'] {F' : ι → α → β'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p s) : UniformCauchySeqOn (fun (i : ι) a => (F i a, F' i a)) p s := fun u hu => have hh : Tendsto (fun x : ι => (x, x)) p (p ×ˢ p) := tendsto_diag (hh.prod_map hh).eventually ((h.prod h') u hu) #align uniform_cauchy_seq_on.prod' UniformCauchySeqOn.prod' theorem UniformCauchySeqOn.cauchy_map [hp : NeBot p] (hf : UniformCauchySeqOn F p s) (hx : x ∈ s) : Cauchy (map (fun i => F i x) p) := by simp only [cauchy_map_iff, hp, true_and_iff] intro u hu rw [mem_map] filter_upwards [hf u hu] with p hp using hp x hx #align uniform_cauchy_seq_on.cauchy_map UniformCauchySeqOn.cauchy_map theorem UniformCauchySeqOn.cauchySeq [Nonempty ι] [SemilatticeSup ι] (hf : UniformCauchySeqOn F atTop s) (hx : x ∈ s) : CauchySeq fun i ↦ F i x := hf.cauchy_map (hp := atTop_neBot) hx variable [TopologicalSpace α] def TendstoLocallyUniformlyOn (F : ι → α → β) (f : α → β) (p : Filter ι) (s : Set α) := ∀ u ∈ 𝓤 β, ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, ∀ᶠ n in p, ∀ y ∈ t, (f y, F n y) ∈ u #align tendsto_locally_uniformly_on TendstoLocallyUniformlyOn def TendstoLocallyUniformly (F : ι → α → β) (f : α → β) (p : Filter ι) := ∀ u ∈ 𝓤 β, ∀ x : α, ∃ t ∈ 𝓝 x, ∀ᶠ n in p, ∀ y ∈ t, (f y, F n y) ∈ u #align tendsto_locally_uniformly TendstoLocallyUniformly theorem tendstoLocallyUniformlyOn_univ : TendstoLocallyUniformlyOn F f p univ ↔ TendstoLocallyUniformly F f p := by simp [TendstoLocallyUniformlyOn, TendstoLocallyUniformly, nhdsWithin_univ] #align tendsto_locally_uniformly_on_univ tendstoLocallyUniformlyOn_univ -- Porting note (#10756): new lemma theorem tendstoLocallyUniformlyOn_iff_forall_tendsto : TendstoLocallyUniformlyOn F f p s ↔ ∀ x ∈ s, Tendsto (fun y : ι × α => (f y.2, F y.1 y.2)) (p ×ˢ 𝓝[s] x) (𝓤 β) := forall₂_swap.trans <| forall₄_congr fun _ _ _ _ => by rw [mem_map, mem_prod_iff_right]; rfl nonrec theorem IsOpen.tendstoLocallyUniformlyOn_iff_forall_tendsto (hs : IsOpen s) : TendstoLocallyUniformlyOn F f p s ↔ ∀ x ∈ s, Tendsto (fun y : ι × α => (f y.2, F y.1 y.2)) (p ×ˢ 𝓝 x) (𝓤 β) := tendstoLocallyUniformlyOn_iff_forall_tendsto.trans <| forall₂_congr fun x hx => by rw [hs.nhdsWithin_eq hx] theorem tendstoLocallyUniformly_iff_forall_tendsto : TendstoLocallyUniformly F f p ↔ ∀ x, Tendsto (fun y : ι × α => (f y.2, F y.1 y.2)) (p ×ˢ 𝓝 x) (𝓤 β) := by simp [← tendstoLocallyUniformlyOn_univ, isOpen_univ.tendstoLocallyUniformlyOn_iff_forall_tendsto] #align tendsto_locally_uniformly_iff_forall_tendsto tendstoLocallyUniformly_iff_forall_tendsto theorem tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe : TendstoLocallyUniformlyOn F f p s ↔ TendstoLocallyUniformly (fun i (x : s) => F i x) (f ∘ (↑)) p := by simp only [tendstoLocallyUniformly_iff_forall_tendsto, Subtype.forall', tendsto_map'_iff, tendstoLocallyUniformlyOn_iff_forall_tendsto, ← map_nhds_subtype_val, prod_map_right]; rfl #align tendsto_locally_uniformly_on_iff_tendsto_locally_uniformly_comp_coe tendstoLocallyUniformlyOn_iff_tendstoLocallyUniformly_comp_coe protected theorem TendstoUniformlyOn.tendstoLocallyUniformlyOn (h : TendstoUniformlyOn F f p s) : TendstoLocallyUniformlyOn F f p s := fun u hu x _ => ⟨s, self_mem_nhdsWithin, by simpa using h u hu⟩ #align tendsto_uniformly_on.tendsto_locally_uniformly_on TendstoUniformlyOn.tendstoLocallyUniformlyOn protected theorem TendstoUniformly.tendstoLocallyUniformly (h : TendstoUniformly F f p) : TendstoLocallyUniformly F f p := fun u hu x => ⟨univ, univ_mem, by simpa using h u hu⟩ #align tendsto_uniformly.tendsto_locally_uniformly TendstoUniformly.tendstoLocallyUniformly theorem TendstoLocallyUniformlyOn.mono (h : TendstoLocallyUniformlyOn F f p s) (h' : s' ⊆ s) : TendstoLocallyUniformlyOn F f p s' := by intro u hu x hx rcases h u hu x (h' hx) with ⟨t, ht, H⟩ exact ⟨t, nhdsWithin_mono x h' ht, H.mono fun n => id⟩ #align tendsto_locally_uniformly_on.mono TendstoLocallyUniformlyOn.mono -- Porting note: generalized from `Type` to `Sort` theorem tendstoLocallyUniformlyOn_iUnion {ι' : Sort*} {S : ι' → Set α} (hS : ∀ i, IsOpen (S i)) (h : ∀ i, TendstoLocallyUniformlyOn F f p (S i)) : TendstoLocallyUniformlyOn F f p (⋃ i, S i) := (isOpen_iUnion hS).tendstoLocallyUniformlyOn_iff_forall_tendsto.2 fun _x hx => let ⟨i, hi⟩ := mem_iUnion.1 hx (hS i).tendstoLocallyUniformlyOn_iff_forall_tendsto.1 (h i) _ hi #align tendsto_locally_uniformly_on_Union tendstoLocallyUniformlyOn_iUnion theorem tendstoLocallyUniformlyOn_biUnion {s : Set γ} {S : γ → Set α} (hS : ∀ i ∈ s, IsOpen (S i)) (h : ∀ i ∈ s, TendstoLocallyUniformlyOn F f p (S i)) : TendstoLocallyUniformlyOn F f p (⋃ i ∈ s, S i) := tendstoLocallyUniformlyOn_iUnion (fun i => isOpen_iUnion (hS i)) fun i => tendstoLocallyUniformlyOn_iUnion (hS i) (h i) #align tendsto_locally_uniformly_on_bUnion tendstoLocallyUniformlyOn_biUnion theorem tendstoLocallyUniformlyOn_sUnion (S : Set (Set α)) (hS : ∀ s ∈ S, IsOpen s) (h : ∀ s ∈ S, TendstoLocallyUniformlyOn F f p s) : TendstoLocallyUniformlyOn F f p (⋃₀ S) := by rw [sUnion_eq_biUnion] exact tendstoLocallyUniformlyOn_biUnion hS h #align tendsto_locally_uniformly_on_sUnion tendstoLocallyUniformlyOn_sUnion theorem TendstoLocallyUniformlyOn.union {s₁ s₂ : Set α} (hs₁ : IsOpen s₁) (hs₂ : IsOpen s₂) (h₁ : TendstoLocallyUniformlyOn F f p s₁) (h₂ : TendstoLocallyUniformlyOn F f p s₂) : TendstoLocallyUniformlyOn F f p (s₁ ∪ s₂) := by rw [← sUnion_pair] refine tendstoLocallyUniformlyOn_sUnion _ ?_ ?_ <;> simp [*] #align tendsto_locally_uniformly_on.union TendstoLocallyUniformlyOn.union -- Porting note: tendstoLocallyUniformlyOn_univ moved up protected theorem TendstoLocallyUniformly.tendstoLocallyUniformlyOn (h : TendstoLocallyUniformly F f p) : TendstoLocallyUniformlyOn F f p s := (tendstoLocallyUniformlyOn_univ.mpr h).mono (subset_univ _) #align tendsto_locally_uniformly.tendsto_locally_uniformly_on TendstoLocallyUniformly.tendstoLocallyUniformlyOn
Mathlib/Topology/UniformSpace/UniformConvergence.lean
695
706
theorem tendstoLocallyUniformly_iff_tendstoUniformly_of_compactSpace [CompactSpace α] : TendstoLocallyUniformly F f p ↔ TendstoUniformly F f p := by
refine ⟨fun h V hV => ?_, TendstoUniformly.tendstoLocallyUniformly⟩ choose U hU using h V hV obtain ⟨t, ht⟩ := isCompact_univ.elim_nhds_subcover' (fun k _ => U k) fun k _ => (hU k).1 replace hU := fun x : t => (hU x).2 rw [← eventually_all] at hU refine hU.mono fun i hi x => ?_ specialize ht (mem_univ x) simp only [exists_prop, mem_iUnion, SetCoe.exists, exists_and_right, Subtype.coe_mk] at ht obtain ⟨y, ⟨hy₁, hy₂⟩, hy₃⟩ := ht exact hi ⟨⟨y, hy₁⟩, hy₂⟩ x hy₃
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.Normed.Group.AddCircle import Mathlib.Algebra.CharZero.Quotient import Mathlib.Topology.Instances.Sign #align_import analysis.special_functions.trigonometric.angle from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec" open Real noncomputable section namespace Real -- Porting note: can't derive `NormedAddCommGroup, Inhabited` def Angle : Type := AddCircle (2 * π) #align real.angle Real.Angle namespace Angle -- Porting note (#10754): added due to missing instances due to no deriving instance : NormedAddCommGroup Angle := inferInstanceAs (NormedAddCommGroup (AddCircle (2 * π))) -- Porting note (#10754): added due to missing instances due to no deriving instance : Inhabited Angle := inferInstanceAs (Inhabited (AddCircle (2 * π))) -- Porting note (#10754): added due to missing instances due to no deriving -- also, without this, a plain `QuotientAddGroup.mk` -- causes coerced terms to be of type `ℝ ⧸ AddSubgroup.zmultiples (2 * π)` @[coe] protected def coe (r : ℝ) : Angle := QuotientAddGroup.mk r instance : Coe ℝ Angle := ⟨Angle.coe⟩ instance : CircularOrder Real.Angle := QuotientAddGroup.circularOrder (hp' := ⟨by norm_num [pi_pos]⟩) @[continuity] theorem continuous_coe : Continuous ((↑) : ℝ → Angle) := continuous_quotient_mk' #align real.angle.continuous_coe Real.Angle.continuous_coe def coeHom : ℝ →+ Angle := QuotientAddGroup.mk' _ #align real.angle.coe_hom Real.Angle.coeHom @[simp] theorem coe_coeHom : (coeHom : ℝ → Angle) = ((↑) : ℝ → Angle) := rfl #align real.angle.coe_coe_hom Real.Angle.coe_coeHom @[elab_as_elim] protected theorem induction_on {p : Angle → Prop} (θ : Angle) (h : ∀ x : ℝ, p x) : p θ := Quotient.inductionOn' θ h #align real.angle.induction_on Real.Angle.induction_on @[simp] theorem coe_zero : ↑(0 : ℝ) = (0 : Angle) := rfl #align real.angle.coe_zero Real.Angle.coe_zero @[simp] theorem coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : Angle) := rfl #align real.angle.coe_add Real.Angle.coe_add @[simp] theorem coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : Angle) := rfl #align real.angle.coe_neg Real.Angle.coe_neg @[simp] theorem coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : Angle) := rfl #align real.angle.coe_sub Real.Angle.coe_sub theorem coe_nsmul (n : ℕ) (x : ℝ) : ↑(n • x : ℝ) = n • (↑x : Angle) := rfl #align real.angle.coe_nsmul Real.Angle.coe_nsmul theorem coe_zsmul (z : ℤ) (x : ℝ) : ↑(z • x : ℝ) = z • (↑x : Angle) := rfl #align real.angle.coe_zsmul Real.Angle.coe_zsmul @[simp, norm_cast] theorem natCast_mul_eq_nsmul (x : ℝ) (n : ℕ) : ↑((n : ℝ) * x) = n • (↑x : Angle) := by simpa only [nsmul_eq_mul] using coeHom.map_nsmul x n #align real.angle.coe_nat_mul_eq_nsmul Real.Angle.natCast_mul_eq_nsmul @[simp, norm_cast] theorem intCast_mul_eq_zsmul (x : ℝ) (n : ℤ) : ↑((n : ℝ) * x : ℝ) = n • (↑x : Angle) := by simpa only [zsmul_eq_mul] using coeHom.map_zsmul x n #align real.angle.coe_int_mul_eq_zsmul Real.Angle.intCast_mul_eq_zsmul @[deprecated (since := "2024-05-25")] alias coe_nat_mul_eq_nsmul := natCast_mul_eq_nsmul @[deprecated (since := "2024-05-25")] alias coe_int_mul_eq_zsmul := intCast_mul_eq_zsmul theorem angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : Angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k := by simp only [QuotientAddGroup.eq, AddSubgroup.zmultiples_eq_closure, AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm] -- Porting note: added `rw`, `simp [Angle.coe, QuotientAddGroup.eq]` doesn't fire otherwise rw [Angle.coe, Angle.coe, QuotientAddGroup.eq] simp only [AddSubgroup.zmultiples_eq_closure, AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm] #align real.angle.angle_eq_iff_two_pi_dvd_sub Real.Angle.angle_eq_iff_two_pi_dvd_sub @[simp] theorem coe_two_pi : ↑(2 * π : ℝ) = (0 : Angle) := angle_eq_iff_two_pi_dvd_sub.2 ⟨1, by rw [sub_zero, Int.cast_one, mul_one]⟩ #align real.angle.coe_two_pi Real.Angle.coe_two_pi @[simp] theorem neg_coe_pi : -(π : Angle) = π := by rw [← coe_neg, angle_eq_iff_two_pi_dvd_sub] use -1 simp [two_mul, sub_eq_add_neg] #align real.angle.neg_coe_pi Real.Angle.neg_coe_pi @[simp] theorem two_nsmul_coe_div_two (θ : ℝ) : (2 : ℕ) • (↑(θ / 2) : Angle) = θ := by rw [← coe_nsmul, two_nsmul, add_halves] #align real.angle.two_nsmul_coe_div_two Real.Angle.two_nsmul_coe_div_two @[simp] theorem two_zsmul_coe_div_two (θ : ℝ) : (2 : ℤ) • (↑(θ / 2) : Angle) = θ := by rw [← coe_zsmul, two_zsmul, add_halves] #align real.angle.two_zsmul_coe_div_two Real.Angle.two_zsmul_coe_div_two -- Porting note (#10618): @[simp] can prove it theorem two_nsmul_neg_pi_div_two : (2 : ℕ) • (↑(-π / 2) : Angle) = π := by rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi] #align real.angle.two_nsmul_neg_pi_div_two Real.Angle.two_nsmul_neg_pi_div_two -- Porting note (#10618): @[simp] can prove it theorem two_zsmul_neg_pi_div_two : (2 : ℤ) • (↑(-π / 2) : Angle) = π := by rw [two_zsmul, ← two_nsmul, two_nsmul_neg_pi_div_two] #align real.angle.two_zsmul_neg_pi_div_two Real.Angle.two_zsmul_neg_pi_div_two theorem sub_coe_pi_eq_add_coe_pi (θ : Angle) : θ - π = θ + π := by rw [sub_eq_add_neg, neg_coe_pi] #align real.angle.sub_coe_pi_eq_add_coe_pi Real.Angle.sub_coe_pi_eq_add_coe_pi @[simp] theorem two_nsmul_coe_pi : (2 : ℕ) • (π : Angle) = 0 := by simp [← natCast_mul_eq_nsmul] #align real.angle.two_nsmul_coe_pi Real.Angle.two_nsmul_coe_pi @[simp] theorem two_zsmul_coe_pi : (2 : ℤ) • (π : Angle) = 0 := by simp [← intCast_mul_eq_zsmul] #align real.angle.two_zsmul_coe_pi Real.Angle.two_zsmul_coe_pi @[simp] theorem coe_pi_add_coe_pi : (π : Real.Angle) + π = 0 := by rw [← two_nsmul, two_nsmul_coe_pi] #align real.angle.coe_pi_add_coe_pi Real.Angle.coe_pi_add_coe_pi theorem zsmul_eq_iff {ψ θ : Angle} {z : ℤ} (hz : z ≠ 0) : z • ψ = z • θ ↔ ∃ k : Fin z.natAbs, ψ = θ + (k : ℕ) • (2 * π / z : ℝ) := QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz #align real.angle.zsmul_eq_iff Real.Angle.zsmul_eq_iff theorem nsmul_eq_iff {ψ θ : Angle} {n : ℕ} (hz : n ≠ 0) : n • ψ = n • θ ↔ ∃ k : Fin n, ψ = θ + (k : ℕ) • (2 * π / n : ℝ) := QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz #align real.angle.nsmul_eq_iff Real.Angle.nsmul_eq_iff theorem two_zsmul_eq_iff {ψ θ : Angle} : (2 : ℤ) • ψ = (2 : ℤ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by -- Porting note: no `Int.natAbs_bit0` anymore have : Int.natAbs 2 = 2 := rfl rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero, Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two, mul_div_cancel_left₀ (_ : ℝ) two_ne_zero] #align real.angle.two_zsmul_eq_iff Real.Angle.two_zsmul_eq_iff theorem two_nsmul_eq_iff {ψ θ : Angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by simp_rw [← natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff] #align real.angle.two_nsmul_eq_iff Real.Angle.two_nsmul_eq_iff theorem two_nsmul_eq_zero_iff {θ : Angle} : (2 : ℕ) • θ = 0 ↔ θ = 0 ∨ θ = π := by convert two_nsmul_eq_iff <;> simp #align real.angle.two_nsmul_eq_zero_iff Real.Angle.two_nsmul_eq_zero_iff theorem two_nsmul_ne_zero_iff {θ : Angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← two_nsmul_eq_zero_iff] #align real.angle.two_nsmul_ne_zero_iff Real.Angle.two_nsmul_ne_zero_iff theorem two_zsmul_eq_zero_iff {θ : Angle} : (2 : ℤ) • θ = 0 ↔ θ = 0 ∨ θ = π := by simp_rw [two_zsmul, ← two_nsmul, two_nsmul_eq_zero_iff] #align real.angle.two_zsmul_eq_zero_iff Real.Angle.two_zsmul_eq_zero_iff theorem two_zsmul_ne_zero_iff {θ : Angle} : (2 : ℤ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← two_zsmul_eq_zero_iff] #align real.angle.two_zsmul_ne_zero_iff Real.Angle.two_zsmul_ne_zero_iff theorem eq_neg_self_iff {θ : Angle} : θ = -θ ↔ θ = 0 ∨ θ = π := by rw [← add_eq_zero_iff_eq_neg, ← two_nsmul, two_nsmul_eq_zero_iff] #align real.angle.eq_neg_self_iff Real.Angle.eq_neg_self_iff theorem ne_neg_self_iff {θ : Angle} : θ ≠ -θ ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← eq_neg_self_iff.not] #align real.angle.ne_neg_self_iff Real.Angle.ne_neg_self_iff theorem neg_eq_self_iff {θ : Angle} : -θ = θ ↔ θ = 0 ∨ θ = π := by rw [eq_comm, eq_neg_self_iff] #align real.angle.neg_eq_self_iff Real.Angle.neg_eq_self_iff theorem neg_ne_self_iff {θ : Angle} : -θ ≠ θ ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← neg_eq_self_iff.not] #align real.angle.neg_ne_self_iff Real.Angle.neg_ne_self_iff theorem two_nsmul_eq_pi_iff {θ : Angle} : (2 : ℕ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by have h : (π : Angle) = ((2 : ℕ) • (π / 2 : ℝ) :) := by rw [two_nsmul, add_halves] nth_rw 1 [h] rw [coe_nsmul, two_nsmul_eq_iff] -- Porting note: `congr` didn't simplify the goal of iff of `Or`s convert Iff.rfl rw [add_comm, ← coe_add, ← sub_eq_zero, ← coe_sub, neg_div, ← neg_sub, sub_neg_eq_add, add_assoc, add_halves, ← two_mul, coe_neg, coe_two_pi, neg_zero] #align real.angle.two_nsmul_eq_pi_iff Real.Angle.two_nsmul_eq_pi_iff theorem two_zsmul_eq_pi_iff {θ : Angle} : (2 : ℤ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by rw [two_zsmul, ← two_nsmul, two_nsmul_eq_pi_iff] #align real.angle.two_zsmul_eq_pi_iff Real.Angle.two_zsmul_eq_pi_iff theorem cos_eq_iff_coe_eq_or_eq_neg {θ ψ : ℝ} : cos θ = cos ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) = -ψ := by constructor · intro Hcos rw [← sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero, eq_false (two_ne_zero' ℝ), false_or_iff, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos rcases Hcos with (⟨n, hn⟩ | ⟨n, hn⟩) · right rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), ← sub_eq_iff_eq_add] at hn rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero] · left rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), eq_sub_iff_add_eq] at hn rw [← hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero, zero_add] · rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub] rintro (⟨k, H⟩ | ⟨k, H⟩) · rw [← sub_eq_zero, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero] rw [← sub_eq_zero, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] #align real.angle.cos_eq_iff_coe_eq_or_eq_neg Real.Angle.cos_eq_iff_coe_eq_or_eq_neg theorem sin_eq_iff_coe_eq_or_add_eq_pi {θ ψ : ℝ} : sin θ = sin ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) + ψ = π := by constructor · intro Hsin rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h h · left rw [coe_sub, coe_sub] at h exact sub_right_inj.1 h right rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, ← coe_add, add_halves, sub_sub, sub_eq_zero] at h exact h.symm · rw [angle_eq_iff_two_pi_dvd_sub, ← eq_sub_iff_add_eq, ← coe_sub, angle_eq_iff_two_pi_dvd_sub] rintro (⟨k, H⟩ | ⟨k, H⟩) · rw [← sub_eq_zero, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul] have H' : θ + ψ = 2 * k * π + π := by rwa [← sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm π _, ← mul_assoc] at H rw [← sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ π, mul_div_cancel_left₀ _ (two_ne_zero' ℝ), cos_add_pi_div_two, sin_int_mul_pi, neg_zero, mul_zero] #align real.angle.sin_eq_iff_coe_eq_or_add_eq_pi Real.Angle.sin_eq_iff_coe_eq_or_add_eq_pi theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : Angle) = ψ := by cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc hc; · exact hc cases' sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs hs; · exact hs rw [eq_neg_iff_add_eq_zero, hs] at hc obtain ⟨n, hn⟩ : ∃ n, n • _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc) rw [← neg_one_mul, add_zero, ← sub_eq_zero, zsmul_eq_mul, ← mul_assoc, ← sub_mul, mul_eq_zero, eq_false (ne_of_gt pi_pos), or_false_iff, sub_neg_eq_add, ← Int.cast_zero, ← Int.cast_one, ← Int.cast_ofNat, ← Int.cast_mul, ← Int.cast_add, Int.cast_inj] at hn have : (n * 2 + 1) % (2 : ℤ) = 0 % (2 : ℤ) := congr_arg (· % (2 : ℤ)) hn rw [add_comm, Int.add_mul_emod_self] at this exact absurd this one_ne_zero #align real.angle.cos_sin_inj Real.Angle.cos_sin_inj def sin (θ : Angle) : ℝ := sin_periodic.lift θ #align real.angle.sin Real.Angle.sin @[simp] theorem sin_coe (x : ℝ) : sin (x : Angle) = Real.sin x := rfl #align real.angle.sin_coe Real.Angle.sin_coe @[continuity] theorem continuous_sin : Continuous sin := Real.continuous_sin.quotient_liftOn' _ #align real.angle.continuous_sin Real.Angle.continuous_sin def cos (θ : Angle) : ℝ := cos_periodic.lift θ #align real.angle.cos Real.Angle.cos @[simp] theorem cos_coe (x : ℝ) : cos (x : Angle) = Real.cos x := rfl #align real.angle.cos_coe Real.Angle.cos_coe @[continuity] theorem continuous_cos : Continuous cos := Real.continuous_cos.quotient_liftOn' _ #align real.angle.continuous_cos Real.Angle.continuous_cos theorem cos_eq_real_cos_iff_eq_or_eq_neg {θ : Angle} {ψ : ℝ} : cos θ = Real.cos ψ ↔ θ = ψ ∨ θ = -ψ := by induction θ using Real.Angle.induction_on exact cos_eq_iff_coe_eq_or_eq_neg #align real.angle.cos_eq_real_cos_iff_eq_or_eq_neg Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg theorem cos_eq_iff_eq_or_eq_neg {θ ψ : Angle} : cos θ = cos ψ ↔ θ = ψ ∨ θ = -ψ := by induction ψ using Real.Angle.induction_on exact cos_eq_real_cos_iff_eq_or_eq_neg #align real.angle.cos_eq_iff_eq_or_eq_neg Real.Angle.cos_eq_iff_eq_or_eq_neg theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {θ : Angle} {ψ : ℝ} : sin θ = Real.sin ψ ↔ θ = ψ ∨ θ + ψ = π := by induction θ using Real.Angle.induction_on exact sin_eq_iff_coe_eq_or_add_eq_pi #align real.angle.sin_eq_real_sin_iff_eq_or_add_eq_pi Real.Angle.sin_eq_real_sin_iff_eq_or_add_eq_pi theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : Angle} : sin θ = sin ψ ↔ θ = ψ ∨ θ + ψ = π := by induction ψ using Real.Angle.induction_on exact sin_eq_real_sin_iff_eq_or_add_eq_pi #align real.angle.sin_eq_iff_eq_or_add_eq_pi Real.Angle.sin_eq_iff_eq_or_add_eq_pi @[simp] theorem sin_zero : sin (0 : Angle) = 0 := by rw [← coe_zero, sin_coe, Real.sin_zero] #align real.angle.sin_zero Real.Angle.sin_zero -- Porting note (#10618): @[simp] can prove it theorem sin_coe_pi : sin (π : Angle) = 0 := by rw [sin_coe, Real.sin_pi] #align real.angle.sin_coe_pi Real.Angle.sin_coe_pi theorem sin_eq_zero_iff {θ : Angle} : sin θ = 0 ↔ θ = 0 ∨ θ = π := by nth_rw 1 [← sin_zero] rw [sin_eq_iff_eq_or_add_eq_pi] simp #align real.angle.sin_eq_zero_iff Real.Angle.sin_eq_zero_iff theorem sin_ne_zero_iff {θ : Angle} : sin θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by rw [← not_or, ← sin_eq_zero_iff] #align real.angle.sin_ne_zero_iff Real.Angle.sin_ne_zero_iff @[simp] theorem sin_neg (θ : Angle) : sin (-θ) = -sin θ := by induction θ using Real.Angle.induction_on exact Real.sin_neg _ #align real.angle.sin_neg Real.Angle.sin_neg theorem sin_antiperiodic : Function.Antiperiodic sin (π : Angle) := by intro θ induction θ using Real.Angle.induction_on exact Real.sin_antiperiodic _ #align real.angle.sin_antiperiodic Real.Angle.sin_antiperiodic @[simp] theorem sin_add_pi (θ : Angle) : sin (θ + π) = -sin θ := sin_antiperiodic θ #align real.angle.sin_add_pi Real.Angle.sin_add_pi @[simp] theorem sin_sub_pi (θ : Angle) : sin (θ - π) = -sin θ := sin_antiperiodic.sub_eq θ #align real.angle.sin_sub_pi Real.Angle.sin_sub_pi @[simp] theorem cos_zero : cos (0 : Angle) = 1 := by rw [← coe_zero, cos_coe, Real.cos_zero] #align real.angle.cos_zero Real.Angle.cos_zero -- Porting note (#10618): @[simp] can prove it theorem cos_coe_pi : cos (π : Angle) = -1 := by rw [cos_coe, Real.cos_pi] #align real.angle.cos_coe_pi Real.Angle.cos_coe_pi @[simp] theorem cos_neg (θ : Angle) : cos (-θ) = cos θ := by induction θ using Real.Angle.induction_on exact Real.cos_neg _ #align real.angle.cos_neg Real.Angle.cos_neg theorem cos_antiperiodic : Function.Antiperiodic cos (π : Angle) := by intro θ induction θ using Real.Angle.induction_on exact Real.cos_antiperiodic _ #align real.angle.cos_antiperiodic Real.Angle.cos_antiperiodic @[simp] theorem cos_add_pi (θ : Angle) : cos (θ + π) = -cos θ := cos_antiperiodic θ #align real.angle.cos_add_pi Real.Angle.cos_add_pi @[simp] theorem cos_sub_pi (θ : Angle) : cos (θ - π) = -cos θ := cos_antiperiodic.sub_eq θ #align real.angle.cos_sub_pi Real.Angle.cos_sub_pi theorem cos_eq_zero_iff {θ : Angle} : cos θ = 0 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by rw [← cos_pi_div_two, ← cos_coe, cos_eq_iff_eq_or_eq_neg, ← coe_neg, ← neg_div] #align real.angle.cos_eq_zero_iff Real.Angle.cos_eq_zero_iff theorem sin_add (θ₁ θ₂ : Real.Angle) : sin (θ₁ + θ₂) = sin θ₁ * cos θ₂ + cos θ₁ * sin θ₂ := by induction θ₁ using Real.Angle.induction_on induction θ₂ using Real.Angle.induction_on exact Real.sin_add _ _ #align real.angle.sin_add Real.Angle.sin_add theorem cos_add (θ₁ θ₂ : Real.Angle) : cos (θ₁ + θ₂) = cos θ₁ * cos θ₂ - sin θ₁ * sin θ₂ := by induction θ₂ using Real.Angle.induction_on induction θ₁ using Real.Angle.induction_on exact Real.cos_add _ _ #align real.angle.cos_add Real.Angle.cos_add @[simp] theorem cos_sq_add_sin_sq (θ : Real.Angle) : cos θ ^ 2 + sin θ ^ 2 = 1 := by induction θ using Real.Angle.induction_on exact Real.cos_sq_add_sin_sq _ #align real.angle.cos_sq_add_sin_sq Real.Angle.cos_sq_add_sin_sq theorem sin_add_pi_div_two (θ : Angle) : sin (θ + ↑(π / 2)) = cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_add_pi_div_two _ #align real.angle.sin_add_pi_div_two Real.Angle.sin_add_pi_div_two theorem sin_sub_pi_div_two (θ : Angle) : sin (θ - ↑(π / 2)) = -cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_sub_pi_div_two _ #align real.angle.sin_sub_pi_div_two Real.Angle.sin_sub_pi_div_two theorem sin_pi_div_two_sub (θ : Angle) : sin (↑(π / 2) - θ) = cos θ := by induction θ using Real.Angle.induction_on exact Real.sin_pi_div_two_sub _ #align real.angle.sin_pi_div_two_sub Real.Angle.sin_pi_div_two_sub
Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean
464
466
theorem cos_add_pi_div_two (θ : Angle) : cos (θ + ↑(π / 2)) = -sin θ := by
induction θ using Real.Angle.induction_on exact Real.cos_add_pi_div_two _
import Mathlib.LinearAlgebra.CliffordAlgebra.Fold import Mathlib.LinearAlgebra.ExteriorAlgebra.Basic #align_import linear_algebra.exterior_algebra.of_alternating from "leanprover-community/mathlib"@"ce11c3c2a285bbe6937e26d9792fda4e51f3fe1a" variable {R M N N' : Type*} variable [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup N'] variable [Module R M] [Module R N] [Module R N'] -- This instance can't be found where it's needed if we don't remind lean that it exists. instance AlternatingMap.instModuleAddCommGroup {ι : Type*} : Module R (M [⋀^ι]→ₗ[R] N) := by infer_instance #align alternating_map.module_add_comm_group AlternatingMap.instModuleAddCommGroup namespace ExteriorAlgebra open CliffordAlgebra hiding ι def liftAlternating : (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] N := by suffices (∀ i, M [⋀^Fin i]→ₗ[R] N) →ₗ[R] ExteriorAlgebra R M →ₗ[R] ∀ i, M [⋀^Fin i]→ₗ[R] N by refine LinearMap.compr₂ this ?_ refine (LinearEquiv.toLinearMap ?_).comp (LinearMap.proj 0) exact AlternatingMap.constLinearEquivOfIsEmpty.symm refine CliffordAlgebra.foldl _ ?_ ?_ · refine LinearMap.mk₂ R (fun m f i => (f i.succ).curryLeft m) (fun m₁ m₂ f => ?_) (fun c m f => ?_) (fun m f₁ f₂ => ?_) fun c m f => ?_ all_goals ext i : 1 simp only [map_smul, map_add, Pi.add_apply, Pi.smul_apply, AlternatingMap.curryLeft_add, AlternatingMap.curryLeft_smul, map_add, map_smul, LinearMap.add_apply, LinearMap.smul_apply] · -- when applied twice with the same `m`, this recursive step produces 0 intro m x dsimp only [LinearMap.mk₂_apply, QuadraticForm.coeFn_zero, Pi.zero_apply] simp_rw [zero_smul] ext i : 1 exact AlternatingMap.curryLeft_same _ _ #align exterior_algebra.lift_alternating ExteriorAlgebra.liftAlternating @[simp] theorem liftAlternating_ι (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m) = f 1 ![m] := by dsimp [liftAlternating] rw [foldl_ι, LinearMap.mk₂_apply, AlternatingMap.curryLeft_apply_apply] congr -- Porting note: In Lean 3, `congr` could use the `[Subsingleton (Fin 0 → M)]` instance to finish -- the proof. Here, the instance can be synthesized but `congr` does not use it so the following -- line is provided. rw [Matrix.zero_empty] #align exterior_algebra.lift_alternating_ι ExteriorAlgebra.liftAlternating_ι theorem liftAlternating_ι_mul (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (m : M) (x : ExteriorAlgebra R M) : liftAlternating (R := R) (M := M) (N := N) f (ι R m * x) = liftAlternating (R := R) (M := M) (N := N) (fun i => (f i.succ).curryLeft m) x := by dsimp [liftAlternating] rw [foldl_mul, foldl_ι] rfl #align exterior_algebra.lift_alternating_ι_mul ExteriorAlgebra.liftAlternating_ι_mul @[simp] theorem liftAlternating_one (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : liftAlternating (R := R) (M := M) (N := N) f (1 : ExteriorAlgebra R M) = f 0 0 := by dsimp [liftAlternating] rw [foldl_one] #align exterior_algebra.lift_alternating_one ExteriorAlgebra.liftAlternating_one @[simp] theorem liftAlternating_algebraMap (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (r : R) : liftAlternating (R := R) (M := M) (N := N) f (algebraMap _ (ExteriorAlgebra R M) r) = r • f 0 0 := by rw [Algebra.algebraMap_eq_smul_one, map_smul, liftAlternating_one] #align exterior_algebra.lift_alternating_algebra_map ExteriorAlgebra.liftAlternating_algebraMap @[simp] theorem liftAlternating_apply_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) (v : Fin n → M) : liftAlternating (R := R) (M := M) (N := N) f (ιMulti R n v) = f n v := by rw [ιMulti_apply] -- Porting note: `v` is generalized automatically so it was removed from the next line induction' n with n ih generalizing f · -- Porting note: Lean does not automatically synthesize the instance -- `[Subsingleton (Fin 0 → M)]` which is needed for `Subsingleton.elim 0 v` on line 114. letI : Subsingleton (Fin 0 → M) := by infer_instance rw [List.ofFn_zero, List.prod_nil, liftAlternating_one, Subsingleton.elim 0 v] · rw [List.ofFn_succ, List.prod_cons, liftAlternating_ι_mul, ih, AlternatingMap.curryLeft_apply_apply] congr exact Matrix.cons_head_tail _ #align exterior_algebra.lift_alternating_apply_ι_multi ExteriorAlgebra.liftAlternating_apply_ιMulti @[simp] theorem liftAlternating_comp_ιMulti {n : ℕ} (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : (liftAlternating (R := R) (M := M) (N := N) f).compAlternatingMap (ιMulti R n) = f n := AlternatingMap.ext <| liftAlternating_apply_ιMulti f #align exterior_algebra.lift_alternating_comp_ι_multi ExteriorAlgebra.liftAlternating_comp_ιMulti @[simp]
Mathlib/LinearAlgebra/ExteriorAlgebra/OfAlternating.lean
125
135
theorem liftAlternating_comp (g : N →ₗ[R] N') (f : ∀ i, M [⋀^Fin i]→ₗ[R] N) : (liftAlternating (R := R) (M := M) (N := N') fun i => g.compAlternatingMap (f i)) = g ∘ₗ liftAlternating (R := R) (M := M) (N := N) f := by
ext v rw [LinearMap.comp_apply] induction' v using CliffordAlgebra.left_induction with r x y hx hy x m hx generalizing f · rw [liftAlternating_algebraMap, liftAlternating_algebraMap, map_smul, LinearMap.compAlternatingMap_apply] · rw [map_add, map_add, map_add, hx, hy] · rw [liftAlternating_ι_mul, liftAlternating_ι_mul, ← hx] simp_rw [AlternatingMap.curryLeft_compAlternatingMap]
import Mathlib.Algebra.MvPolynomial.Rename import Mathlib.Algebra.MvPolynomial.Variables #align_import data.mv_polynomial.monad from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" noncomputable section namespace MvPolynomial open Finsupp variable {σ : Type*} {τ : Type*} variable {R S T : Type*} [CommSemiring R] [CommSemiring S] [CommSemiring T] def bind₁ (f : σ → MvPolynomial τ R) : MvPolynomial σ R →ₐ[R] MvPolynomial τ R := aeval f #align mv_polynomial.bind₁ MvPolynomial.bind₁ def bind₂ (f : R →+* MvPolynomial σ S) : MvPolynomial σ R →+* MvPolynomial σ S := eval₂Hom f X #align mv_polynomial.bind₂ MvPolynomial.bind₂ def join₁ : MvPolynomial (MvPolynomial σ R) R →ₐ[R] MvPolynomial σ R := aeval id #align mv_polynomial.join₁ MvPolynomial.join₁ def join₂ : MvPolynomial σ (MvPolynomial σ R) →+* MvPolynomial σ R := eval₂Hom (RingHom.id _) X #align mv_polynomial.join₂ MvPolynomial.join₂ @[simp] theorem aeval_eq_bind₁ (f : σ → MvPolynomial τ R) : aeval f = bind₁ f := rfl #align mv_polynomial.aeval_eq_bind₁ MvPolynomial.aeval_eq_bind₁ @[simp] theorem eval₂Hom_C_eq_bind₁ (f : σ → MvPolynomial τ R) : eval₂Hom C f = bind₁ f := rfl set_option linter.uppercaseLean3 false in #align mv_polynomial.eval₂_hom_C_eq_bind₁ MvPolynomial.eval₂Hom_C_eq_bind₁ @[simp] theorem eval₂Hom_eq_bind₂ (f : R →+* MvPolynomial σ S) : eval₂Hom f X = bind₂ f := rfl #align mv_polynomial.eval₂_hom_eq_bind₂ MvPolynomial.eval₂Hom_eq_bind₂ section variable (σ R) @[simp] theorem aeval_id_eq_join₁ : aeval id = @join₁ σ R _ := rfl #align mv_polynomial.aeval_id_eq_join₁ MvPolynomial.aeval_id_eq_join₁ theorem eval₂Hom_C_id_eq_join₁ (φ : MvPolynomial (MvPolynomial σ R) R) : eval₂Hom C id φ = join₁ φ := rfl set_option linter.uppercaseLean3 false in #align mv_polynomial.eval₂_hom_C_id_eq_join₁ MvPolynomial.eval₂Hom_C_id_eq_join₁ @[simp] theorem eval₂Hom_id_X_eq_join₂ : eval₂Hom (RingHom.id _) X = @join₂ σ R _ := rfl set_option linter.uppercaseLean3 false in #align mv_polynomial.eval₂_hom_id_X_eq_join₂ MvPolynomial.eval₂Hom_id_X_eq_join₂ end -- In this file, we don't want to use these simp lemmas, -- because we first need to show how these new definitions interact -- and the proofs fall back on unfolding the definitions and call simp afterwards attribute [-simp] aeval_eq_bind₁ eval₂Hom_C_eq_bind₁ eval₂Hom_eq_bind₂ aeval_id_eq_join₁ eval₂Hom_id_X_eq_join₂ @[simp] theorem bind₁_X_right (f : σ → MvPolynomial τ R) (i : σ) : bind₁ f (X i) = f i := aeval_X f i set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₁_X_right MvPolynomial.bind₁_X_right @[simp] theorem bind₂_X_right (f : R →+* MvPolynomial σ S) (i : σ) : bind₂ f (X i) = X i := eval₂Hom_X' f X i set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₂_X_right MvPolynomial.bind₂_X_right @[simp] theorem bind₁_X_left : bind₁ (X : σ → MvPolynomial σ R) = AlgHom.id R _ := by ext1 i simp set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₁_X_left MvPolynomial.bind₁_X_left variable (f : σ → MvPolynomial τ R) theorem bind₁_C_right (f : σ → MvPolynomial τ R) (x) : bind₁ f (C x) = C x := algHom_C _ _ set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₁_C_right MvPolynomial.bind₁_C_right @[simp] theorem bind₂_C_right (f : R →+* MvPolynomial σ S) (r : R) : bind₂ f (C r) = f r := eval₂Hom_C f X r set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₂_C_right MvPolynomial.bind₂_C_right @[simp] theorem bind₂_C_left : bind₂ (C : R →+* MvPolynomial σ R) = RingHom.id _ := by ext : 2 <;> simp set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₂_C_left MvPolynomial.bind₂_C_left @[simp] theorem bind₂_comp_C (f : R →+* MvPolynomial σ S) : (bind₂ f).comp C = f := RingHom.ext <| bind₂_C_right _ set_option linter.uppercaseLean3 false in #align mv_polynomial.bind₂_comp_C MvPolynomial.bind₂_comp_C @[simp] theorem join₂_map (f : R →+* MvPolynomial σ S) (φ : MvPolynomial σ R) : join₂ (map f φ) = bind₂ f φ := by simp only [join₂, bind₂, eval₂Hom_map_hom, RingHom.id_comp] #align mv_polynomial.join₂_map MvPolynomial.join₂_map @[simp] theorem join₂_comp_map (f : R →+* MvPolynomial σ S) : join₂.comp (map f) = bind₂ f := RingHom.ext <| join₂_map _ #align mv_polynomial.join₂_comp_map MvPolynomial.join₂_comp_map theorem aeval_id_rename (f : σ → MvPolynomial τ R) (p : MvPolynomial σ R) : aeval id (rename f p) = aeval f p := by rw [aeval_rename, Function.id_comp] #align mv_polynomial.aeval_id_rename MvPolynomial.aeval_id_rename @[simp] theorem join₁_rename (f : σ → MvPolynomial τ R) (φ : MvPolynomial σ R) : join₁ (rename f φ) = bind₁ f φ := aeval_id_rename _ _ #align mv_polynomial.join₁_rename MvPolynomial.join₁_rename @[simp] theorem bind₁_id : bind₁ (@id (MvPolynomial σ R)) = join₁ := rfl #align mv_polynomial.bind₁_id MvPolynomial.bind₁_id @[simp] theorem bind₂_id : bind₂ (RingHom.id (MvPolynomial σ R)) = join₂ := rfl #align mv_polynomial.bind₂_id MvPolynomial.bind₂_id theorem bind₁_bind₁ {υ : Type*} (f : σ → MvPolynomial τ R) (g : τ → MvPolynomial υ R) (φ : MvPolynomial σ R) : (bind₁ g) (bind₁ f φ) = bind₁ (fun i => bind₁ g (f i)) φ := by simp [bind₁, ← comp_aeval] #align mv_polynomial.bind₁_bind₁ MvPolynomial.bind₁_bind₁ theorem bind₁_comp_bind₁ {υ : Type*} (f : σ → MvPolynomial τ R) (g : τ → MvPolynomial υ R) : (bind₁ g).comp (bind₁ f) = bind₁ fun i => bind₁ g (f i) := by ext1 apply bind₁_bind₁ #align mv_polynomial.bind₁_comp_bind₁ MvPolynomial.bind₁_comp_bind₁ theorem bind₂_comp_bind₂ (f : R →+* MvPolynomial σ S) (g : S →+* MvPolynomial σ T) : (bind₂ g).comp (bind₂ f) = bind₂ ((bind₂ g).comp f) := by ext : 2 <;> simp #align mv_polynomial.bind₂_comp_bind₂ MvPolynomial.bind₂_comp_bind₂ theorem bind₂_bind₂ (f : R →+* MvPolynomial σ S) (g : S →+* MvPolynomial σ T) (φ : MvPolynomial σ R) : (bind₂ g) (bind₂ f φ) = bind₂ ((bind₂ g).comp f) φ := RingHom.congr_fun (bind₂_comp_bind₂ f g) φ #align mv_polynomial.bind₂_bind₂ MvPolynomial.bind₂_bind₂ theorem rename_comp_bind₁ {υ : Type*} (f : σ → MvPolynomial τ R) (g : τ → υ) : (rename g).comp (bind₁ f) = bind₁ fun i => rename g <| f i := by ext1 i simp #align mv_polynomial.rename_comp_bind₁ MvPolynomial.rename_comp_bind₁ theorem rename_bind₁ {υ : Type*} (f : σ → MvPolynomial τ R) (g : τ → υ) (φ : MvPolynomial σ R) : rename g (bind₁ f φ) = bind₁ (fun i => rename g <| f i) φ := AlgHom.congr_fun (rename_comp_bind₁ f g) φ #align mv_polynomial.rename_bind₁ MvPolynomial.rename_bind₁ theorem map_bind₂ (f : R →+* MvPolynomial σ S) (g : S →+* T) (φ : MvPolynomial σ R) : map g (bind₂ f φ) = bind₂ ((map g).comp f) φ := by simp only [bind₂, eval₂_comp_right, coe_eval₂Hom, eval₂_map] congr 1 with : 1 simp only [Function.comp_apply, map_X] #align mv_polynomial.map_bind₂ MvPolynomial.map_bind₂ theorem bind₁_comp_rename {υ : Type*} (f : τ → MvPolynomial υ R) (g : σ → τ) : (bind₁ f).comp (rename g) = bind₁ (f ∘ g) := by ext1 i simp #align mv_polynomial.bind₁_comp_rename MvPolynomial.bind₁_comp_rename theorem bind₁_rename {υ : Type*} (f : τ → MvPolynomial υ R) (g : σ → τ) (φ : MvPolynomial σ R) : bind₁ f (rename g φ) = bind₁ (f ∘ g) φ := AlgHom.congr_fun (bind₁_comp_rename f g) φ #align mv_polynomial.bind₁_rename MvPolynomial.bind₁_rename theorem bind₂_map (f : S →+* MvPolynomial σ T) (g : R →+* S) (φ : MvPolynomial σ R) : bind₂ f (map g φ) = bind₂ (f.comp g) φ := by simp [bind₂] #align mv_polynomial.bind₂_map MvPolynomial.bind₂_map @[simp] theorem map_comp_C (f : R →+* S) : (map f).comp (C : R →+* MvPolynomial σ R) = C.comp f := by ext1 apply map_C set_option linter.uppercaseLean3 false in #align mv_polynomial.map_comp_C MvPolynomial.map_comp_C -- mixing the two monad structures theorem hom_bind₁ (f : MvPolynomial τ R →+* S) (g : σ → MvPolynomial τ R) (φ : MvPolynomial σ R) : f (bind₁ g φ) = eval₂Hom (f.comp C) (fun i => f (g i)) φ := by rw [bind₁, map_aeval, algebraMap_eq] #align mv_polynomial.hom_bind₁ MvPolynomial.hom_bind₁ theorem map_bind₁ (f : R →+* S) (g : σ → MvPolynomial τ R) (φ : MvPolynomial σ R) : map f (bind₁ g φ) = bind₁ (fun i : σ => (map f) (g i)) (map f φ) := by rw [hom_bind₁, map_comp_C, ← eval₂Hom_map_hom] rfl #align mv_polynomial.map_bind₁ MvPolynomial.map_bind₁ @[simp] theorem eval₂Hom_comp_C (f : R →+* S) (g : σ → S) : (eval₂Hom f g).comp C = f := by ext1 r exact eval₂_C f g r set_option linter.uppercaseLean3 false in #align mv_polynomial.eval₂_hom_comp_C MvPolynomial.eval₂Hom_comp_C theorem eval₂Hom_bind₁ (f : R →+* S) (g : τ → S) (h : σ → MvPolynomial τ R) (φ : MvPolynomial σ R) : eval₂Hom f g (bind₁ h φ) = eval₂Hom f (fun i => eval₂Hom f g (h i)) φ := by rw [hom_bind₁, eval₂Hom_comp_C] #align mv_polynomial.eval₂_hom_bind₁ MvPolynomial.eval₂Hom_bind₁ theorem aeval_bind₁ [Algebra R S] (f : τ → S) (g : σ → MvPolynomial τ R) (φ : MvPolynomial σ R) : aeval f (bind₁ g φ) = aeval (fun i => aeval f (g i)) φ := eval₂Hom_bind₁ _ _ _ _ #align mv_polynomial.aeval_bind₁ MvPolynomial.aeval_bind₁ theorem aeval_comp_bind₁ [Algebra R S] (f : τ → S) (g : σ → MvPolynomial τ R) : (aeval f).comp (bind₁ g) = aeval fun i => aeval f (g i) := by ext1 apply aeval_bind₁ #align mv_polynomial.aeval_comp_bind₁ MvPolynomial.aeval_comp_bind₁
Mathlib/Algebra/MvPolynomial/Monad.lean
314
315
theorem eval₂Hom_comp_bind₂ (f : S →+* T) (g : σ → T) (h : R →+* MvPolynomial σ S) : (eval₂Hom f g).comp (bind₂ h) = eval₂Hom ((eval₂Hom f g).comp h) g := by
ext : 2 <;> simp
import Mathlib.Data.Matrix.Basic import Mathlib.Data.PEquiv #align_import data.matrix.pequiv from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1" namespace PEquiv open Matrix universe u v variable {k l m n : Type*} variable {α : Type v} open Matrix def toMatrix [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : Matrix m n α := of fun i j => if j ∈ f i then (1 : α) else 0 #align pequiv.to_matrix PEquiv.toMatrix -- TODO: set as an equation lemma for `toMatrix`, see mathlib4#3024 @[simp] theorem toMatrix_apply [DecidableEq n] [Zero α] [One α] (f : m ≃. n) (i j) : toMatrix f i j = if j ∈ f i then (1 : α) else 0 := rfl #align pequiv.to_matrix_apply PEquiv.toMatrix_apply theorem mul_matrix_apply [Fintype m] [DecidableEq m] [Semiring α] (f : l ≃. m) (M : Matrix m n α) (i j) : (f.toMatrix * M :) i j = Option.casesOn (f i) 0 fun fi => M fi j := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f i with fi · simp [h] · rw [Finset.sum_eq_single fi] <;> simp (config := { contextual := true }) [h, eq_comm] #align pequiv.mul_matrix_apply PEquiv.mul_matrix_apply theorem toMatrix_symm [DecidableEq m] [DecidableEq n] [Zero α] [One α] (f : m ≃. n) : (f.symm.toMatrix : Matrix n m α) = f.toMatrixᵀ := by ext simp only [transpose, mem_iff_mem f, toMatrix_apply] congr #align pequiv.to_matrix_symm PEquiv.toMatrix_symm @[simp] theorem toMatrix_refl [DecidableEq n] [Zero α] [One α] : ((PEquiv.refl n).toMatrix : Matrix n n α) = 1 := by ext simp [toMatrix_apply, one_apply] #align pequiv.to_matrix_refl PEquiv.toMatrix_refl theorem matrix_mul_apply [Fintype m] [Semiring α] [DecidableEq n] (M : Matrix l m α) (f : m ≃. n) (i j) : (M * f.toMatrix :) i j = Option.casesOn (f.symm j) 0 fun fj => M i fj := by dsimp [toMatrix, Matrix.mul_apply] cases' h : f.symm j with fj · simp [h, ← f.eq_some_iff] · rw [Finset.sum_eq_single fj] · simp [h, ← f.eq_some_iff] · rintro b - n simp [h, ← f.eq_some_iff, n.symm] · simp #align pequiv.matrix_mul_apply PEquiv.matrix_mul_apply
Mathlib/Data/Matrix/PEquiv.lean
96
99
theorem toPEquiv_mul_matrix [Fintype m] [DecidableEq m] [Semiring α] (f : m ≃ m) (M : Matrix m n α) : f.toPEquiv.toMatrix * M = M.submatrix f id := by
ext i j rw [mul_matrix_apply, Equiv.toPEquiv_apply, submatrix_apply, id]
import Mathlib.Data.ZMod.Basic import Mathlib.GroupTheory.Coxeter.Basic namespace CoxeterSystem open List Matrix Function Classical variable {B : Type*} variable {W : Type*} [Group W] variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W) local prefix:100 "s" => cs.simple local prefix:100 "π" => cs.wordProd private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by rcases cs.wordProd_surjective w with ⟨ω, rfl⟩ use ω.length, ω noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w) local prefix:100 "ℓ" => cs.length theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by have := Nat.find_spec (cs.exists_word_with_prod w) tauto theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length := Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩ @[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le []) @[simp] theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by constructor · intro h rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h) rw [this, wordProd_nil] · rintro rfl exact cs.length_one @[simp]
Mathlib/GroupTheory/Coxeter/Length.lean
91
98
theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by
apply Nat.le_antisymm · rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, hω] at this · rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩ have := cs.length_wordProd_le (List.reverse ω) rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Convex.Normed import Mathlib.Analysis.Normed.Group.AddTorsor #align_import analysis.convex.side from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f" variable {R V V' P P' : Type*} open AffineEquiv AffineMap namespace AffineSubspace section StrictOrderedCommRing variable [StrictOrderedCommRing R] [AddCommGroup V] [Module R V] [AddTorsor V P] variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P'] def WSameSide (s : AffineSubspace R P) (x y : P) : Prop := ∃ᵉ (p₁ ∈ s) (p₂ ∈ s), SameRay R (x -ᵥ p₁) (y -ᵥ p₂) #align affine_subspace.w_same_side AffineSubspace.WSameSide def SSameSide (s : AffineSubspace R P) (x y : P) : Prop := s.WSameSide x y ∧ x ∉ s ∧ y ∉ s #align affine_subspace.s_same_side AffineSubspace.SSameSide def WOppSide (s : AffineSubspace R P) (x y : P) : Prop := ∃ᵉ (p₁ ∈ s) (p₂ ∈ s), SameRay R (x -ᵥ p₁) (p₂ -ᵥ y) #align affine_subspace.w_opp_side AffineSubspace.WOppSide def SOppSide (s : AffineSubspace R P) (x y : P) : Prop := s.WOppSide x y ∧ x ∉ s ∧ y ∉ s #align affine_subspace.s_opp_side AffineSubspace.SOppSide theorem WSameSide.map {s : AffineSubspace R P} {x y : P} (h : s.WSameSide x y) (f : P →ᵃ[R] P') : (s.map f).WSameSide (f x) (f y) := by rcases h with ⟨p₁, hp₁, p₂, hp₂, h⟩ refine ⟨f p₁, mem_map_of_mem f hp₁, f p₂, mem_map_of_mem f hp₂, ?_⟩ simp_rw [← linearMap_vsub] exact h.map f.linear #align affine_subspace.w_same_side.map AffineSubspace.WSameSide.map theorem _root_.Function.Injective.wSameSide_map_iff {s : AffineSubspace R P} {x y : P} {f : P →ᵃ[R] P'} (hf : Function.Injective f) : (s.map f).WSameSide (f x) (f y) ↔ s.WSameSide x y := by refine ⟨fun h => ?_, fun h => h.map _⟩ rcases h with ⟨fp₁, hfp₁, fp₂, hfp₂, h⟩ rw [mem_map] at hfp₁ hfp₂ rcases hfp₁ with ⟨p₁, hp₁, rfl⟩ rcases hfp₂ with ⟨p₂, hp₂, rfl⟩ refine ⟨p₁, hp₁, p₂, hp₂, ?_⟩ simp_rw [← linearMap_vsub, (f.linear_injective_iff.2 hf).sameRay_map_iff] at h exact h #align function.injective.w_same_side_map_iff Function.Injective.wSameSide_map_iff theorem _root_.Function.Injective.sSameSide_map_iff {s : AffineSubspace R P} {x y : P} {f : P →ᵃ[R] P'} (hf : Function.Injective f) : (s.map f).SSameSide (f x) (f y) ↔ s.SSameSide x y := by simp_rw [SSameSide, hf.wSameSide_map_iff, mem_map_iff_mem_of_injective hf] #align function.injective.s_same_side_map_iff Function.Injective.sSameSide_map_iff @[simp] theorem _root_.AffineEquiv.wSameSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P ≃ᵃ[R] P') : (s.map ↑f).WSameSide (f x) (f y) ↔ s.WSameSide x y := (show Function.Injective f.toAffineMap from f.injective).wSameSide_map_iff #align affine_equiv.w_same_side_map_iff AffineEquiv.wSameSide_map_iff @[simp] theorem _root_.AffineEquiv.sSameSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P ≃ᵃ[R] P') : (s.map ↑f).SSameSide (f x) (f y) ↔ s.SSameSide x y := (show Function.Injective f.toAffineMap from f.injective).sSameSide_map_iff #align affine_equiv.s_same_side_map_iff AffineEquiv.sSameSide_map_iff theorem WOppSide.map {s : AffineSubspace R P} {x y : P} (h : s.WOppSide x y) (f : P →ᵃ[R] P') : (s.map f).WOppSide (f x) (f y) := by rcases h with ⟨p₁, hp₁, p₂, hp₂, h⟩ refine ⟨f p₁, mem_map_of_mem f hp₁, f p₂, mem_map_of_mem f hp₂, ?_⟩ simp_rw [← linearMap_vsub] exact h.map f.linear #align affine_subspace.w_opp_side.map AffineSubspace.WOppSide.map
Mathlib/Analysis/Convex/Side.lean
109
119
theorem _root_.Function.Injective.wOppSide_map_iff {s : AffineSubspace R P} {x y : P} {f : P →ᵃ[R] P'} (hf : Function.Injective f) : (s.map f).WOppSide (f x) (f y) ↔ s.WOppSide x y := by
refine ⟨fun h => ?_, fun h => h.map _⟩ rcases h with ⟨fp₁, hfp₁, fp₂, hfp₂, h⟩ rw [mem_map] at hfp₁ hfp₂ rcases hfp₁ with ⟨p₁, hp₁, rfl⟩ rcases hfp₂ with ⟨p₂, hp₂, rfl⟩ refine ⟨p₁, hp₁, p₂, hp₂, ?_⟩ simp_rw [← linearMap_vsub, (f.linear_injective_iff.2 hf).sameRay_map_iff] at h exact h
import Mathlib.Control.Functor import Mathlib.Tactic.Common #align_import control.bifunctor from "leanprover-community/mathlib"@"dc1525fb3ef6eb4348fb1749c302d8abc303d34a" universe u₀ u₁ u₂ v₀ v₁ v₂ open Function class Bifunctor (F : Type u₀ → Type u₁ → Type u₂) where bimap : ∀ {α α' β β'}, (α → α') → (β → β') → F α β → F α' β' #align bifunctor Bifunctor export Bifunctor (bimap) class LawfulBifunctor (F : Type u₀ → Type u₁ → Type u₂) [Bifunctor F] : Prop where id_bimap : ∀ {α β} (x : F α β), bimap id id x = x bimap_bimap : ∀ {α₀ α₁ α₂ β₀ β₁ β₂} (f : α₀ → α₁) (f' : α₁ → α₂) (g : β₀ → β₁) (g' : β₁ → β₂) (x : F α₀ β₀), bimap f' g' (bimap f g x) = bimap (f' ∘ f) (g' ∘ g) x #align is_lawful_bifunctor LawfulBifunctor export LawfulBifunctor (id_bimap bimap_bimap) attribute [higher_order bimap_id_id] id_bimap #align is_lawful_bifunctor.bimap_id_id LawfulBifunctor.bimap_id_id attribute [higher_order bimap_comp_bimap] bimap_bimap #align is_lawful_bifunctor.bimap_comp_bimap LawfulBifunctor.bimap_comp_bimap export LawfulBifunctor (bimap_id_id bimap_comp_bimap) variable {F : Type u₀ → Type u₁ → Type u₂} [Bifunctor F] namespace Bifunctor abbrev fst {α α' β} (f : α → α') : F α β → F α' β := bimap f id #align bifunctor.fst Bifunctor.fst abbrev snd {α β β'} (f : β → β') : F α β → F α β' := bimap id f #align bifunctor.snd Bifunctor.snd variable [LawfulBifunctor F] @[higher_order fst_id] theorem id_fst : ∀ {α β} (x : F α β), fst id x = x := @id_bimap _ _ _ #align bifunctor.id_fst Bifunctor.id_fst #align bifunctor.fst_id Bifunctor.fst_id @[higher_order snd_id] theorem id_snd : ∀ {α β} (x : F α β), snd id x = x := @id_bimap _ _ _ #align bifunctor.id_snd Bifunctor.id_snd #align bifunctor.snd_id Bifunctor.snd_id @[higher_order fst_comp_fst]
Mathlib/Control/Bifunctor.lean
86
87
theorem comp_fst {α₀ α₁ α₂ β} (f : α₀ → α₁) (f' : α₁ → α₂) (x : F α₀ β) : fst f' (fst f x) = fst (f' ∘ f) x := by
simp [fst, bimap_bimap]
import Mathlib.Algebra.MvPolynomial.Rename #align_import data.mv_polynomial.comap from "leanprover-community/mathlib"@"aba31c938d3243cc671be7091b28a1e0814647ee" namespace MvPolynomial variable {σ : Type*} {τ : Type*} {υ : Type*} {R : Type*} [CommSemiring R] noncomputable def comap (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) : (τ → R) → σ → R := fun x i => aeval x (f (X i)) #align mv_polynomial.comap MvPolynomial.comap @[simp] theorem comap_apply (f : MvPolynomial σ R →ₐ[R] MvPolynomial τ R) (x : τ → R) (i : σ) : comap f x i = aeval x (f (X i)) := rfl #align mv_polynomial.comap_apply MvPolynomial.comap_apply @[simp]
Mathlib/Algebra/MvPolynomial/Comap.lean
48
50
theorem comap_id_apply (x : σ → R) : comap (AlgHom.id R (MvPolynomial σ R)) x = x := by
funext i simp only [comap, AlgHom.id_apply, id, aeval_X]
import Mathlib.Algebra.Quaternion import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.InnerProductSpace.PiL2 import Mathlib.Topology.Algebra.Algebra #align_import analysis.quaternion from "leanprover-community/mathlib"@"07992a1d1f7a4176c6d3f160209608be4e198566" @[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ open scoped RealInnerProductSpace namespace Quaternion instance : Inner ℝ ℍ := ⟨fun a b => (a * star b).re⟩ theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a := rfl #align quaternion.inner_self Quaternion.inner_self theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re := rfl #align quaternion.inner_def Quaternion.inner_def noncomputable instance : NormedAddCommGroup ℍ := @InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _ { toInner := inferInstance conj_symm := fun x y => by simp [inner_def, mul_comm] nonneg_re := fun x => normSq_nonneg definite := fun x => normSq_eq_zero.1 add_left := fun x y z => by simp only [inner_def, add_mul, add_re] smul_left := fun x y r => by simp [inner_def] } noncomputable instance : InnerProductSpace ℝ ℍ := InnerProductSpace.ofCore _
Mathlib/Analysis/Quaternion.lean
65
66
theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by
rw [← inner_self, real_inner_self_eq_norm_mul_norm]
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Angle import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import analysis.special_functions.complex.arg from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" open Filter Metric Set open scoped ComplexConjugate Real Topology namespace Complex variable {a x z : ℂ} noncomputable def arg (x : ℂ) : ℝ := if 0 ≤ x.re then Real.arcsin (x.im / abs x) else if 0 ≤ x.im then Real.arcsin ((-x).im / abs x) + π else Real.arcsin ((-x).im / abs x) - π #align complex.arg Complex.arg theorem sin_arg (x : ℂ) : Real.sin (arg x) = x.im / abs x := by unfold arg; split_ifs <;> simp [sub_eq_add_neg, arg, Real.sin_arcsin (abs_le.1 (abs_im_div_abs_le_one x)).1 (abs_le.1 (abs_im_div_abs_le_one x)).2, Real.sin_add, neg_div, Real.arcsin_neg, Real.sin_neg] #align complex.sin_arg Complex.sin_arg theorem cos_arg {x : ℂ} (hx : x ≠ 0) : Real.cos (arg x) = x.re / abs x := by rw [arg] split_ifs with h₁ h₂ · rw [Real.cos_arcsin] field_simp [Real.sqrt_sq, (abs.pos hx).le, *] · rw [Real.cos_add_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] · rw [Real.cos_sub_pi, Real.cos_arcsin] field_simp [Real.sqrt_div (sq_nonneg _), Real.sqrt_sq_eq_abs, _root_.abs_of_neg (not_le.1 h₁), *] #align complex.cos_arg Complex.cos_arg @[simp] theorem abs_mul_exp_arg_mul_I (x : ℂ) : ↑(abs x) * exp (arg x * I) = x := by rcases eq_or_ne x 0 with (rfl | hx) · simp · have : abs x ≠ 0 := abs.ne_zero hx apply Complex.ext <;> field_simp [sin_arg, cos_arg hx, this, mul_comm (abs x)] set_option linter.uppercaseLean3 false in #align complex.abs_mul_exp_arg_mul_I Complex.abs_mul_exp_arg_mul_I @[simp]
Mathlib/Analysis/SpecialFunctions/Complex/Arg.lean
63
64
theorem abs_mul_cos_add_sin_mul_I (x : ℂ) : (abs x * (cos (arg x) + sin (arg x) * I) : ℂ) = x := by
rw [← exp_mul_I, abs_mul_exp_arg_mul_I]
import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Polynomial.Eval import Mathlib.GroupTheory.GroupAction.Ring #align_import data.polynomial.derivative from "leanprover-community/mathlib"@"bbeb185db4ccee8ed07dc48449414ebfa39cb821" noncomputable section open Finset open Polynomial namespace Polynomial universe u v w y z variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {A : Type z} {a b : R} {n : ℕ} section Derivative section Semiring variable [Semiring R] def derivative : R[X] →ₗ[R] R[X] where toFun p := p.sum fun n a => C (a * n) * X ^ (n - 1) map_add' p q := by dsimp only rw [sum_add_index] <;> simp only [add_mul, forall_const, RingHom.map_add, eq_self_iff_true, zero_mul, RingHom.map_zero] map_smul' a p := by dsimp; rw [sum_smul_index] <;> simp only [mul_sum, ← C_mul', mul_assoc, coeff_C_mul, RingHom.map_mul, forall_const, zero_mul, RingHom.map_zero, sum] #align polynomial.derivative Polynomial.derivative theorem derivative_apply (p : R[X]) : derivative p = p.sum fun n a => C (a * n) * X ^ (n - 1) := rfl #align polynomial.derivative_apply Polynomial.derivative_apply theorem coeff_derivative (p : R[X]) (n : ℕ) : coeff (derivative p) n = coeff p (n + 1) * (n + 1) := by rw [derivative_apply] simp only [coeff_X_pow, coeff_sum, coeff_C_mul] rw [sum, Finset.sum_eq_single (n + 1)] · simp only [Nat.add_succ_sub_one, add_zero, mul_one, if_true, eq_self_iff_true]; norm_cast · intro b cases b · intros rw [Nat.cast_zero, mul_zero, zero_mul] · intro _ H rw [Nat.add_one_sub_one, if_neg (mt (congr_arg Nat.succ) H.symm), mul_zero] · rw [if_pos (add_tsub_cancel_right n 1).symm, mul_one, Nat.cast_add, Nat.cast_one, mem_support_iff] intro h push_neg at h simp [h] #align polynomial.coeff_derivative Polynomial.coeff_derivative -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_zero : derivative (0 : R[X]) = 0 := derivative.map_zero #align polynomial.derivative_zero Polynomial.derivative_zero theorem iterate_derivative_zero {k : ℕ} : derivative^[k] (0 : R[X]) = 0 := iterate_map_zero derivative k #align polynomial.iterate_derivative_zero Polynomial.iterate_derivative_zero @[simp] theorem derivative_monomial (a : R) (n : ℕ) : derivative (monomial n a) = monomial (n - 1) (a * n) := by rw [derivative_apply, sum_monomial_index, C_mul_X_pow_eq_monomial] simp #align polynomial.derivative_monomial Polynomial.derivative_monomial theorem derivative_C_mul_X (a : R) : derivative (C a * X) = C a := by simp [C_mul_X_eq_monomial, derivative_monomial, Nat.cast_one, mul_one] set_option linter.uppercaseLean3 false in #align polynomial.derivative_C_mul_X Polynomial.derivative_C_mul_X theorem derivative_C_mul_X_pow (a : R) (n : ℕ) : derivative (C a * X ^ n) = C (a * n) * X ^ (n - 1) := by rw [C_mul_X_pow_eq_monomial, C_mul_X_pow_eq_monomial, derivative_monomial] set_option linter.uppercaseLean3 false in #align polynomial.derivative_C_mul_X_pow Polynomial.derivative_C_mul_X_pow theorem derivative_C_mul_X_sq (a : R) : derivative (C a * X ^ 2) = C (a * 2) * X := by rw [derivative_C_mul_X_pow, Nat.cast_two, pow_one] set_option linter.uppercaseLean3 false in #align polynomial.derivative_C_mul_X_sq Polynomial.derivative_C_mul_X_sq @[simp] theorem derivative_X_pow (n : ℕ) : derivative (X ^ n : R[X]) = C (n : R) * X ^ (n - 1) := by convert derivative_C_mul_X_pow (1 : R) n <;> simp set_option linter.uppercaseLean3 false in #align polynomial.derivative_X_pow Polynomial.derivative_X_pow -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_X_sq : derivative (X ^ 2 : R[X]) = C 2 * X := by rw [derivative_X_pow, Nat.cast_two, pow_one] set_option linter.uppercaseLean3 false in #align polynomial.derivative_X_sq Polynomial.derivative_X_sq @[simp] theorem derivative_C {a : R} : derivative (C a) = 0 := by simp [derivative_apply] set_option linter.uppercaseLean3 false in #align polynomial.derivative_C Polynomial.derivative_C theorem derivative_of_natDegree_zero {p : R[X]} (hp : p.natDegree = 0) : derivative p = 0 := by rw [eq_C_of_natDegree_eq_zero hp, derivative_C] #align polynomial.derivative_of_nat_degree_zero Polynomial.derivative_of_natDegree_zero @[simp] theorem derivative_X : derivative (X : R[X]) = 1 := (derivative_monomial _ _).trans <| by simp set_option linter.uppercaseLean3 false in #align polynomial.derivative_X Polynomial.derivative_X @[simp] theorem derivative_one : derivative (1 : R[X]) = 0 := derivative_C #align polynomial.derivative_one Polynomial.derivative_one #noalign polynomial.derivative_bit0 #noalign polynomial.derivative_bit1 -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_add {f g : R[X]} : derivative (f + g) = derivative f + derivative g := derivative.map_add f g #align polynomial.derivative_add Polynomial.derivative_add -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_X_add_C (c : R) : derivative (X + C c) = 1 := by rw [derivative_add, derivative_X, derivative_C, add_zero] set_option linter.uppercaseLean3 false in #align polynomial.derivative_X_add_C Polynomial.derivative_X_add_C -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_sum {s : Finset ι} {f : ι → R[X]} : derivative (∑ b ∈ s, f b) = ∑ b ∈ s, derivative (f b) := map_sum .. #align polynomial.derivative_sum Polynomial.derivative_sum -- Porting note (#10618): removed `simp`: `simp` can prove it. theorem derivative_smul {S : Type*} [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (s : S) (p : R[X]) : derivative (s • p) = s • derivative p := derivative.map_smul_of_tower s p #align polynomial.derivative_smul Polynomial.derivative_smul @[simp] theorem iterate_derivative_smul {S : Type*} [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (s : S) (p : R[X]) (k : ℕ) : derivative^[k] (s • p) = s • derivative^[k] p := by induction' k with k ih generalizing p · simp · simp [ih] #align polynomial.iterate_derivative_smul Polynomial.iterate_derivative_smul @[simp]
Mathlib/Algebra/Polynomial/Derivative.lean
175
177
theorem iterate_derivative_C_mul (a : R) (p : R[X]) (k : ℕ) : derivative^[k] (C a * p) = C a * derivative^[k] p := by
simp_rw [← smul_eq_C_mul, iterate_derivative_smul]
import Mathlib.AlgebraicTopology.DoldKan.FunctorGamma import Mathlib.AlgebraicTopology.DoldKan.SplitSimplicialObject import Mathlib.CategoryTheory.Idempotents.HomologicalComplex #align_import algebraic_topology.dold_kan.gamma_comp_n from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504" noncomputable section open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents Opposite SimplicialObject Simplicial namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C] @[simps!] def Γ₀NondegComplexIso (K : ChainComplex C ℕ) : (Γ₀.splitting K).nondegComplex ≅ K := HomologicalComplex.Hom.isoOfComponents (fun n => Iso.refl _) (by rintro _ n (rfl : n + 1 = _) dsimp simp only [id_comp, comp_id, AlternatingFaceMapComplex.obj_d_eq, Preadditive.sum_comp, Preadditive.comp_sum] rw [Fintype.sum_eq_single (0 : Fin (n + 2))] · simp only [Fin.val_zero, pow_zero, one_zsmul] erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_δ₀, Splitting.cofan_inj_πSummand_eq_id, comp_id] · intro i hi dsimp simp only [Preadditive.zsmul_comp, Preadditive.comp_zsmul, assoc] erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_eq_zero, zero_comp, zsmul_zero] · intro h replace h := congr_arg SimplexCategory.len h change n + 1 = n at h omega · simpa only [Isδ₀.iff] using hi) #align algebraic_topology.dold_kan.Γ₀_nondeg_complex_iso AlgebraicTopology.DoldKan.Γ₀NondegComplexIso def Γ₀'CompNondegComplexFunctor : Γ₀' ⋙ Split.nondegComplexFunctor ≅ 𝟭 (ChainComplex C ℕ) := NatIso.ofComponents Γ₀NondegComplexIso #align algebraic_topology.dold_kan.Γ₀'_comp_nondeg_complex_functor AlgebraicTopology.DoldKan.Γ₀'CompNondegComplexFunctor def N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ) := calc Γ₀ ⋙ N₁ ≅ Γ₀' ⋙ Split.forget C ⋙ N₁ := Functor.associator _ _ _ _ ≅ Γ₀' ⋙ Split.nondegComplexFunctor ⋙ toKaroubi _ := (isoWhiskerLeft Γ₀' Split.toKaroubiNondegComplexFunctorIsoN₁.symm) _ ≅ (Γ₀' ⋙ Split.nondegComplexFunctor) ⋙ toKaroubi _ := (Functor.associator _ _ _).symm _ ≅ 𝟭 _ ⋙ toKaroubi (ChainComplex C ℕ) := isoWhiskerRight Γ₀'CompNondegComplexFunctor _ _ ≅ toKaroubi (ChainComplex C ℕ) := Functor.leftUnitor _ set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀ AlgebraicTopology.DoldKan.N₁Γ₀ theorem N₁Γ₀_app (K : ChainComplex C ℕ) : N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫ (toKaroubi _).mapIso (Γ₀NondegComplexIso K) := by ext1 dsimp [N₁Γ₀] erw [id_comp, comp_id, comp_id] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_app AlgebraicTopology.DoldKan.N₁Γ₀_app theorem N₁Γ₀_hom_app (K : ChainComplex C ℕ) : N₁Γ₀.hom.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv ≫ (toKaroubi _).map (Γ₀NondegComplexIso K).hom := by change (N₁Γ₀.app K).hom = _ simp only [N₁Γ₀_app] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_hom_app AlgebraicTopology.DoldKan.N₁Γ₀_hom_app theorem N₁Γ₀_inv_app (K : ChainComplex C ℕ) : N₁Γ₀.inv.app K = (toKaroubi _).map (Γ₀NondegComplexIso K).inv ≫ (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom := by change (N₁Γ₀.app K).inv = _ simp only [N₁Γ₀_app] rfl set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_inv_app AlgebraicTopology.DoldKan.N₁Γ₀_inv_app @[simp] theorem N₁Γ₀_hom_app_f_f (K : ChainComplex C ℕ) (n : ℕ) : (N₁Γ₀.hom.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv.f.f n := by rw [N₁Γ₀_hom_app] apply comp_id set_option linter.uppercaseLean3 false in #align algebraic_topology.dold_kan.N₁Γ₀_hom_app_f_f AlgebraicTopology.DoldKan.N₁Γ₀_hom_app_f_f @[simp]
Mathlib/AlgebraicTopology/DoldKan/GammaCompN.lean
113
116
theorem N₁Γ₀_inv_app_f_f (K : ChainComplex C ℕ) (n : ℕ) : (N₁Γ₀.inv.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom.f.f n := by
rw [N₁Γ₀_inv_app] apply id_comp
import Mathlib.CategoryTheory.CofilteredSystem import Mathlib.Combinatorics.SimpleGraph.Connectivity import Mathlib.Data.Finite.Set #align_import combinatorics.simple_graph.ends.defs from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4" universe u variable {V : Type u} (G : SimpleGraph V) (K L L' M : Set V) namespace SimpleGraph abbrev ComponentCompl := (G.induce Kᶜ).ConnectedComponent #align simple_graph.component_compl SimpleGraph.ComponentCompl variable {G} {K L M} abbrev componentComplMk (G : SimpleGraph V) {v : V} (vK : v ∉ K) : G.ComponentCompl K := connectedComponentMk (G.induce Kᶜ) ⟨v, vK⟩ #align simple_graph.component_compl_mk SimpleGraph.componentComplMk def ComponentCompl.supp (C : G.ComponentCompl K) : Set V := { v : V | ∃ h : v ∉ K, G.componentComplMk h = C } #align simple_graph.component_compl.supp SimpleGraph.ComponentCompl.supp @[ext]
Mathlib/Combinatorics/SimpleGraph/Ends/Defs.lean
44
49
theorem ComponentCompl.supp_injective : Function.Injective (ComponentCompl.supp : G.ComponentCompl K → Set V) := by
refine ConnectedComponent.ind₂ ?_ rintro ⟨v, hv⟩ ⟨w, hw⟩ h simp only [Set.ext_iff, ConnectedComponent.eq, Set.mem_setOf_eq, ComponentCompl.supp] at h ⊢ exact ((h v).mp ⟨hv, Reachable.refl _⟩).choose_spec
import Mathlib.Algebra.Group.Support import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Nat.Cast.Field #align_import algebra.char_zero.lemmas from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829" open Function Set section AddMonoidWithOne variable {α M : Type*} [AddMonoidWithOne M] [CharZero M] {n : ℕ} instance CharZero.NeZero.two : NeZero (2 : M) := ⟨by have : ((2 : ℕ) : M) ≠ 0 := Nat.cast_ne_zero.2 (by decide) rwa [Nat.cast_two] at this⟩ #align char_zero.ne_zero.two CharZero.NeZero.two section variable {R : Type*} [NonAssocSemiring R] [NoZeroDivisors R] [CharZero R] {a : R} @[simp]
Mathlib/Algebra/CharZero/Lemmas.lean
88
89
theorem add_self_eq_zero {a : R} : a + a = 0 ↔ a = 0 := by
simp only [(two_mul a).symm, mul_eq_zero, two_ne_zero, false_or_iff]
import Mathlib.Probability.Kernel.MeasurableIntegral #align_import probability.kernel.composition from "leanprover-community/mathlib"@"3b92d54a05ee592aa2c6181a4e76b1bb7cc45d0b" open MeasureTheory open scoped ENNReal namespace ProbabilityTheory namespace kernel variable {α β ι : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β} section CompositionProduct variable {γ : Type*} {mγ : MeasurableSpace γ} {s : Set (β × γ)} noncomputable def compProdFun (κ : kernel α β) (η : kernel (α × β) γ) (a : α) (s : Set (β × γ)) : ℝ≥0∞ := ∫⁻ b, η (a, b) {c | (b, c) ∈ s} ∂κ a #align probability_theory.kernel.comp_prod_fun ProbabilityTheory.kernel.compProdFun theorem compProdFun_empty (κ : kernel α β) (η : kernel (α × β) γ) (a : α) : compProdFun κ η a ∅ = 0 := by simp only [compProdFun, Set.mem_empty_iff_false, Set.setOf_false, measure_empty, MeasureTheory.lintegral_const, zero_mul] #align probability_theory.kernel.comp_prod_fun_empty ProbabilityTheory.kernel.compProdFun_empty theorem compProdFun_iUnion (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel η] (a : α) (f : ℕ → Set (β × γ)) (hf_meas : ∀ i, MeasurableSet (f i)) (hf_disj : Pairwise (Disjoint on f)) : compProdFun κ η a (⋃ i, f i) = ∑' i, compProdFun κ η a (f i) := by have h_Union : (fun b => η (a, b) {c : γ | (b, c) ∈ ⋃ i, f i}) = fun b => η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i}) := by ext1 b congr with c simp only [Set.mem_iUnion, Set.iSup_eq_iUnion, Set.mem_setOf_eq] rw [compProdFun, h_Union] have h_tsum : (fun b => η (a, b) (⋃ i, {c : γ | (b, c) ∈ f i})) = fun b => ∑' i, η (a, b) {c : γ | (b, c) ∈ f i} := by ext1 b rw [measure_iUnion] · intro i j hij s hsi hsj c hcs have hbci : {(b, c)} ⊆ f i := by rw [Set.singleton_subset_iff]; exact hsi hcs have hbcj : {(b, c)} ⊆ f j := by rw [Set.singleton_subset_iff]; exact hsj hcs simpa only [Set.bot_eq_empty, Set.le_eq_subset, Set.singleton_subset_iff, Set.mem_empty_iff_false] using hf_disj hij hbci hbcj · -- Porting note: behavior of `@` changed relative to lean 3, was -- exact fun i => (@measurable_prod_mk_left β γ _ _ b) _ (hf_meas i) exact fun i => (@measurable_prod_mk_left β γ _ _ b) (hf_meas i) rw [h_tsum, lintegral_tsum] · rfl · intro i have hm : MeasurableSet {p : (α × β) × γ | (p.1.2, p.2) ∈ f i} := measurable_fst.snd.prod_mk measurable_snd (hf_meas i) exact ((measurable_kernel_prod_mk_left hm).comp measurable_prod_mk_left).aemeasurable #align probability_theory.kernel.comp_prod_fun_Union ProbabilityTheory.kernel.compProdFun_iUnion theorem compProdFun_tsum_right (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) : compProdFun κ η a s = ∑' n, compProdFun κ (seq η n) a s := by simp_rw [compProdFun, (measure_sum_seq η _).symm] have : ∫⁻ b, Measure.sum (fun n => seq η n (a, b)) {c : γ | (b, c) ∈ s} ∂κ a = ∫⁻ b, ∑' n, seq η n (a, b) {c : γ | (b, c) ∈ s} ∂κ a := by congr ext1 b rw [Measure.sum_apply] exact measurable_prod_mk_left hs rw [this, lintegral_tsum] exact fun n => ((measurable_kernel_prod_mk_left (κ := (seq η n)) ((measurable_fst.snd.prod_mk measurable_snd) hs)).comp measurable_prod_mk_left).aemeasurable #align probability_theory.kernel.comp_prod_fun_tsum_right ProbabilityTheory.kernel.compProdFun_tsum_right theorem compProdFun_tsum_left (κ : kernel α β) (η : kernel (α × β) γ) [IsSFiniteKernel κ] (a : α) (s : Set (β × γ)) : compProdFun κ η a s = ∑' n, compProdFun (seq κ n) η a s := by simp_rw [compProdFun, (measure_sum_seq κ _).symm, lintegral_sum_measure] #align probability_theory.kernel.comp_prod_fun_tsum_left ProbabilityTheory.kernel.compProdFun_tsum_left theorem compProdFun_eq_tsum (κ : kernel α β) [IsSFiniteKernel κ] (η : kernel (α × β) γ) [IsSFiniteKernel η] (a : α) (hs : MeasurableSet s) : compProdFun κ η a s = ∑' (n) (m), compProdFun (seq κ n) (seq η m) a s := by simp_rw [compProdFun_tsum_left κ η a s, compProdFun_tsum_right _ η a hs] #align probability_theory.kernel.comp_prod_fun_eq_tsum ProbabilityTheory.kernel.compProdFun_eq_tsum theorem measurable_compProdFun_of_finite (κ : kernel α β) [IsFiniteKernel κ] (η : kernel (α × β) γ) [IsFiniteKernel η] (hs : MeasurableSet s) : Measurable fun a => compProdFun κ η a s := by simp only [compProdFun] have h_meas : Measurable (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) := by have : (Function.uncurry fun a b => η (a, b) {c : γ | (b, c) ∈ s}) = fun p => η p {c : γ | (p.2, c) ∈ s} := by ext1 p rw [Function.uncurry_apply_pair] rw [this] exact measurable_kernel_prod_mk_left (measurable_fst.snd.prod_mk measurable_snd hs) exact h_meas.lintegral_kernel_prod_right #align probability_theory.kernel.measurable_comp_prod_fun_of_finite ProbabilityTheory.kernel.measurable_compProdFun_of_finite
Mathlib/Probability/Kernel/Composition.lean
172
185
theorem measurable_compProdFun (κ : kernel α β) [IsSFiniteKernel κ] (η : kernel (α × β) γ) [IsSFiniteKernel η] (hs : MeasurableSet s) : Measurable fun a => compProdFun κ η a s := by
simp_rw [compProdFun_tsum_right κ η _ hs] refine Measurable.ennreal_tsum fun n => ?_ simp only [compProdFun] have h_meas : Measurable (Function.uncurry fun a b => seq η n (a, b) {c : γ | (b, c) ∈ s}) := by have : (Function.uncurry fun a b => seq η n (a, b) {c : γ | (b, c) ∈ s}) = fun p => seq η n p {c : γ | (p.2, c) ∈ s} := by ext1 p rw [Function.uncurry_apply_pair] rw [this] exact measurable_kernel_prod_mk_left (measurable_fst.snd.prod_mk measurable_snd hs) exact h_meas.lintegral_kernel_prod_right
import Mathlib.Data.Fintype.Order import Mathlib.Data.Set.Finite import Mathlib.Order.Category.FinPartOrd import Mathlib.Order.Category.LinOrd import Mathlib.CategoryTheory.Limits.Shapes.Images import Mathlib.CategoryTheory.Limits.Shapes.RegularMono import Mathlib.Data.Set.Subsingleton #align_import order.category.NonemptyFinLinOrd from "leanprover-community/mathlib"@"fa4a805d16a9cd9c96e0f8edeb57dc5a07af1a19" universe u v open CategoryTheory CategoryTheory.Limits class NonemptyFiniteLinearOrder (α : Type*) extends Fintype α, LinearOrder α where Nonempty : Nonempty α := by infer_instance #align nonempty_fin_lin_ord NonemptyFiniteLinearOrder attribute [instance] NonemptyFiniteLinearOrder.Nonempty instance (priority := 100) NonemptyFiniteLinearOrder.toBoundedOrder (α : Type*) [NonemptyFiniteLinearOrder α] : BoundedOrder α := Fintype.toBoundedOrder α #align nonempty_fin_lin_ord.to_bounded_order NonemptyFiniteLinearOrder.toBoundedOrder instance PUnit.nonemptyFiniteLinearOrder : NonemptyFiniteLinearOrder PUnit where #align punit.nonempty_fin_lin_ord PUnit.nonemptyFiniteLinearOrder instance Fin.nonemptyFiniteLinearOrder (n : ℕ) : NonemptyFiniteLinearOrder (Fin (n + 1)) where #align fin.nonempty_fin_lin_ord Fin.nonemptyFiniteLinearOrder instance ULift.nonemptyFiniteLinearOrder (α : Type u) [NonemptyFiniteLinearOrder α] : NonemptyFiniteLinearOrder (ULift.{v} α) := { LinearOrder.lift' Equiv.ulift (Equiv.injective _) with } #align ulift.nonempty_fin_lin_ord ULift.nonemptyFiniteLinearOrder instance (α : Type*) [NonemptyFiniteLinearOrder α] : NonemptyFiniteLinearOrder αᵒᵈ := { OrderDual.fintype α with } def NonemptyFinLinOrd := Bundled NonemptyFiniteLinearOrder set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd NonemptyFinLinOrd namespace NonemptyFinLinOrd instance : BundledHom.ParentProjection @NonemptyFiniteLinearOrder.toLinearOrder := ⟨⟩ deriving instance LargeCategory for NonemptyFinLinOrd -- Porting note: probably see https://github.com/leanprover-community/mathlib4/issues/5020 instance : ConcreteCategory NonemptyFinLinOrd := BundledHom.concreteCategory _ instance : CoeSort NonemptyFinLinOrd Type* := Bundled.coeSort def of (α : Type*) [NonemptyFiniteLinearOrder α] : NonemptyFinLinOrd := Bundled.of α set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.of NonemptyFinLinOrd.of @[simp] theorem coe_of (α : Type*) [NonemptyFiniteLinearOrder α] : ↥(of α) = α := rfl set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.coe_of NonemptyFinLinOrd.coe_of instance : Inhabited NonemptyFinLinOrd := ⟨of PUnit⟩ instance (α : NonemptyFinLinOrd) : NonemptyFiniteLinearOrder α := α.str instance hasForgetToLinOrd : HasForget₂ NonemptyFinLinOrd LinOrd := BundledHom.forget₂ _ _ set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.has_forget_to_LinOrd NonemptyFinLinOrd.hasForgetToLinOrd instance hasForgetToFinPartOrd : HasForget₂ NonemptyFinLinOrd FinPartOrd where forget₂ := { obj := fun X => FinPartOrd.of X map := @fun X Y => id } set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.has_forget_to_FinPartOrd NonemptyFinLinOrd.hasForgetToFinPartOrd @[simps] def Iso.mk {α β : NonemptyFinLinOrd.{u}} (e : α ≃o β) : α ≅ β where hom := (e : OrderHom _ _) inv := (e.symm : OrderHom _ _) hom_inv_id := by ext x exact e.symm_apply_apply x inv_hom_id := by ext x exact e.apply_symm_apply x set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.iso.mk NonemptyFinLinOrd.Iso.mk @[simps] def dual : NonemptyFinLinOrd ⥤ NonemptyFinLinOrd where obj X := of Xᵒᵈ map := OrderHom.dual set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.dual NonemptyFinLinOrd.dual @[simps functor inverse] def dualEquiv : NonemptyFinLinOrd ≌ NonemptyFinLinOrd where functor := dual inverse := dual unitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X counitIso := NatIso.ofComponents fun X => Iso.mk <| OrderIso.dualDual X set_option linter.uppercaseLean3 false in #align NonemptyFinLinOrd.dual_equiv NonemptyFinLinOrd.dualEquiv instance {A B : NonemptyFinLinOrd.{u}} : FunLike (A ⟶ B) A B where coe f := ⇑(show OrderHom A B from f) coe_injective' _ _ h := by ext x exact congr_fun h x -- porting note (#10670): this instance was not necessary in mathlib instance {A B : NonemptyFinLinOrd.{u}} : OrderHomClass (A ⟶ B) A B where map_rel f _ _ h := f.monotone h
Mathlib/Order/Category/NonemptyFinLinOrd.lean
150
163
theorem mono_iff_injective {A B : NonemptyFinLinOrd.{u}} (f : A ⟶ B) : Mono f ↔ Function.Injective f := by
refine ⟨?_, ConcreteCategory.mono_of_injective f⟩ intro intro a₁ a₂ h let X := NonemptyFinLinOrd.of (ULift (Fin 1)) let g₁ : X ⟶ A := ⟨fun _ => a₁, fun _ _ _ => by rfl⟩ let g₂ : X ⟶ A := ⟨fun _ => a₂, fun _ _ _ => by rfl⟩ change g₁ (ULift.up (0 : Fin 1)) = g₂ (ULift.up (0 : Fin 1)) have eq : g₁ ≫ f = g₂ ≫ f := by ext exact h rw [cancel_mono] at eq rw [eq]
import Mathlib.Data.SetLike.Basic import Mathlib.Data.Finset.Preimage import Mathlib.ModelTheory.Semantics #align_import model_theory.definability from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" universe u v w u₁ namespace Set variable {M : Type w} (A : Set M) (L : FirstOrder.Language.{u, v}) [L.Structure M] open FirstOrder FirstOrder.Language FirstOrder.Language.Structure variable {α : Type u₁} {β : Type*} def Definable (s : Set (α → M)) : Prop := ∃ φ : L[[A]].Formula α, s = setOf φ.Realize #align set.definable Set.Definable variable {L} {A} {B : Set M} {s : Set (α → M)} theorem Definable.map_expansion {L' : FirstOrder.Language} [L'.Structure M] (h : A.Definable L s) (φ : L →ᴸ L') [φ.IsExpansionOn M] : A.Definable L' s := by obtain ⟨ψ, rfl⟩ := h refine ⟨(φ.addConstants A).onFormula ψ, ?_⟩ ext x simp only [mem_setOf_eq, LHom.realize_onFormula] #align set.definable.map_expansion Set.Definable.map_expansion theorem definable_iff_exists_formula_sum : A.Definable L s ↔ ∃ φ : L.Formula (A ⊕ α), s = {v | φ.Realize (Sum.elim (↑) v)} := by rw [Definable, Equiv.exists_congr_left (BoundedFormula.constantsVarsEquiv)] refine exists_congr (fun φ => iff_iff_eq.2 (congr_arg (s = ·) ?_)) ext simp only [Formula.Realize, BoundedFormula.constantsVarsEquiv, constantsOn, mk₂_Relations, BoundedFormula.mapTermRelEquiv_symm_apply, mem_setOf_eq] refine BoundedFormula.realize_mapTermRel_id ?_ (fun _ _ _ => rfl) intros simp only [Term.constantsVarsEquivLeft_symm_apply, Term.realize_varsToConstants, coe_con, Term.realize_relabel] congr ext a rcases a with (_ | _) | _ <;> rfl theorem empty_definable_iff : (∅ : Set M).Definable L s ↔ ∃ φ : L.Formula α, s = setOf φ.Realize := by rw [Definable, Equiv.exists_congr_left (LEquiv.addEmptyConstants L (∅ : Set M)).onFormula] simp [-constantsOn] #align set.empty_definable_iff Set.empty_definable_iff theorem definable_iff_empty_definable_with_params : A.Definable L s ↔ (∅ : Set M).Definable (L[[A]]) s := empty_definable_iff.symm #align set.definable_iff_empty_definable_with_params Set.definable_iff_empty_definable_with_params theorem Definable.mono (hAs : A.Definable L s) (hAB : A ⊆ B) : B.Definable L s := by rw [definable_iff_empty_definable_with_params] at * exact hAs.map_expansion (L.lhomWithConstantsMap (Set.inclusion hAB)) #align set.definable.mono Set.Definable.mono @[simp] theorem definable_empty : A.Definable L (∅ : Set (α → M)) := ⟨⊥, by ext simp⟩ #align set.definable_empty Set.definable_empty @[simp] theorem definable_univ : A.Definable L (univ : Set (α → M)) := ⟨⊤, by ext simp⟩ #align set.definable_univ Set.definable_univ @[simp] theorem Definable.inter {f g : Set (α → M)} (hf : A.Definable L f) (hg : A.Definable L g) : A.Definable L (f ∩ g) := by rcases hf with ⟨φ, rfl⟩ rcases hg with ⟨θ, rfl⟩ refine ⟨φ ⊓ θ, ?_⟩ ext simp #align set.definable.inter Set.Definable.inter @[simp] theorem Definable.union {f g : Set (α → M)} (hf : A.Definable L f) (hg : A.Definable L g) : A.Definable L (f ∪ g) := by rcases hf with ⟨φ, hφ⟩ rcases hg with ⟨θ, hθ⟩ refine ⟨φ ⊔ θ, ?_⟩ ext rw [hφ, hθ, mem_setOf_eq, Formula.realize_sup, mem_union, mem_setOf_eq, mem_setOf_eq] #align set.definable.union Set.Definable.union theorem definable_finset_inf {ι : Type*} {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) (s : Finset ι) : A.Definable L (s.inf f) := by classical refine Finset.induction definable_univ (fun i s _ h => ?_) s rw [Finset.inf_insert] exact (hf i).inter h #align set.definable_finset_inf Set.definable_finset_inf theorem definable_finset_sup {ι : Type*} {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) (s : Finset ι) : A.Definable L (s.sup f) := by classical refine Finset.induction definable_empty (fun i s _ h => ?_) s rw [Finset.sup_insert] exact (hf i).union h #align set.definable_finset_sup Set.definable_finset_sup theorem definable_finset_biInter {ι : Type*} {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) (s : Finset ι) : A.Definable L (⋂ i ∈ s, f i) := by rw [← Finset.inf_set_eq_iInter] exact definable_finset_inf hf s #align set.definable_finset_bInter Set.definable_finset_biInter theorem definable_finset_biUnion {ι : Type*} {f : ι → Set (α → M)} (hf : ∀ i, A.Definable L (f i)) (s : Finset ι) : A.Definable L (⋃ i ∈ s, f i) := by rw [← Finset.sup_set_eq_biUnion] exact definable_finset_sup hf s #align set.definable_finset_bUnion Set.definable_finset_biUnion @[simp] theorem Definable.compl {s : Set (α → M)} (hf : A.Definable L s) : A.Definable L sᶜ := by rcases hf with ⟨φ, hφ⟩ refine ⟨φ.not, ?_⟩ ext v rw [hφ, compl_setOf, mem_setOf, mem_setOf, Formula.realize_not] #align set.definable.compl Set.Definable.compl @[simp] theorem Definable.sdiff {s t : Set (α → M)} (hs : A.Definable L s) (ht : A.Definable L t) : A.Definable L (s \ t) := hs.inter ht.compl #align set.definable.sdiff Set.Definable.sdiff theorem Definable.preimage_comp (f : α → β) {s : Set (α → M)} (h : A.Definable L s) : A.Definable L ((fun g : β → M => g ∘ f) ⁻¹' s) := by obtain ⟨φ, rfl⟩ := h refine ⟨φ.relabel f, ?_⟩ ext simp only [Set.preimage_setOf_eq, mem_setOf_eq, Formula.realize_relabel] #align set.definable.preimage_comp Set.Definable.preimage_comp theorem Definable.image_comp_equiv {s : Set (β → M)} (h : A.Definable L s) (f : α ≃ β) : A.Definable L ((fun g : β → M => g ∘ f) '' s) := by refine (congr rfl ?_).mp (h.preimage_comp f.symm) rw [image_eq_preimage_of_inverse] · intro i ext b simp only [Function.comp_apply, Equiv.apply_symm_apply] · intro i ext a simp #align set.definable.image_comp_equiv Set.Definable.image_comp_equiv theorem definable_iff_finitely_definable : A.Definable L s ↔ ∃ (A0 : Finset M), (A0 : Set M) ⊆ A ∧ (A0 : Set M).Definable L s := by letI := Classical.decEq M letI := Classical.decEq α constructor · simp only [definable_iff_exists_formula_sum] rintro ⟨φ, rfl⟩ let A0 := (φ.freeVarFinset.preimage Sum.inl (Function.Injective.injOn Sum.inl_injective)).image Subtype.val have hA0 : (A0 : Set M) ⊆ A := by simp [A0] refine ⟨A0, hA0, (φ.restrictFreeVar (Set.inclusion (Set.Subset.refl _))).relabel ?_, ?_⟩ · rintro ⟨a | a, ha⟩ · exact Sum.inl (Sum.inl ⟨a, by simpa [A0] using ha⟩) · exact Sum.inl (Sum.inr a) · ext v simp only [Formula.Realize, BoundedFormula.realize_relabel, Set.mem_setOf_eq] apply Iff.symm convert BoundedFormula.realize_restrictFreeVar _ ext a rcases a with ⟨_ | _, _⟩ <;> simp · rintro ⟨A0, hA0, hd⟩ exact Definable.mono hd hA0 theorem Definable.image_comp_sum_inl_fin (m : ℕ) {s : Set (Sum α (Fin m) → M)} (h : A.Definable L s) : A.Definable L ((fun g : Sum α (Fin m) → M => g ∘ Sum.inl) '' s) := by obtain ⟨φ, rfl⟩ := h refine ⟨(BoundedFormula.relabel id φ).exs, ?_⟩ ext x simp only [Set.mem_image, mem_setOf_eq, BoundedFormula.realize_exs, BoundedFormula.realize_relabel, Function.comp_id, Fin.castAdd_zero, Fin.cast_refl] constructor · rintro ⟨y, hy, rfl⟩ exact ⟨y ∘ Sum.inr, (congr (congr rfl (Sum.elim_comp_inl_inr y).symm) (funext finZeroElim)).mp hy⟩ · rintro ⟨y, hy⟩ exact ⟨Sum.elim x y, (congr rfl (funext finZeroElim)).mp hy, Sum.elim_comp_inl _ _⟩ #align set.definable.image_comp_sum_inl_fin Set.Definable.image_comp_sum_inl_fin
Mathlib/ModelTheory/Definability.lean
230
242
theorem Definable.image_comp_embedding {s : Set (β → M)} (h : A.Definable L s) (f : α ↪ β) [Finite β] : A.Definable L ((fun g : β → M => g ∘ f) '' s) := by
classical cases nonempty_fintype β refine (congr rfl (ext fun x => ?_)).mp (((h.image_comp_equiv (Equiv.Set.sumCompl (range f))).image_comp_equiv (Equiv.sumCongr (Equiv.ofInjective f f.injective) (Fintype.equivFin (↥(range f)ᶜ)).symm)).image_comp_sum_inl_fin _) simp only [mem_preimage, mem_image, exists_exists_and_eq_and] refine exists_congr fun y => and_congr_right fun _ => Eq.congr_left (funext fun a => ?_) simp
import Mathlib.Algebra.Algebra.Tower import Mathlib.Algebra.MvPolynomial.Basic #align_import ring_theory.mv_polynomial.tower from "leanprover-community/mathlib"@"bb168510ef455e9280a152e7f31673cabd3d7496" variable (R A B : Type*) {σ : Type*} namespace MvPolynomial section CommSemiring variable [CommSemiring R] [CommSemiring A] [CommSemiring B] variable [Algebra R A] [Algebra A B] [Algebra R B] [IsScalarTower R A B] variable {R A}
Mathlib/RingTheory/MvPolynomial/Tower.lean
48
53
theorem aeval_algebraMap_apply (x : σ → A) (p : MvPolynomial σ R) : aeval (algebraMap A B ∘ x) p = algebraMap A B (MvPolynomial.aeval x p) := by
rw [aeval_def, aeval_def, ← coe_eval₂Hom, ← coe_eval₂Hom, map_eval₂Hom, ← IsScalarTower.algebraMap_eq] -- Porting note: added simp only [Function.comp]
import Mathlib.Algebra.Polynomial.Degree.TrailingDegree import Mathlib.Algebra.Polynomial.EraseLead import Mathlib.Algebra.Polynomial.Eval #align_import data.polynomial.reverse from "leanprover-community/mathlib"@"44de64f183393284a16016dfb2a48ac97382f2bd" namespace Polynomial open Polynomial Finsupp Finset open Polynomial section Semiring variable {R : Type*} [Semiring R] {f : R[X]} def revAtFun (N i : ℕ) : ℕ := ite (i ≤ N) (N - i) i #align polynomial.rev_at_fun Polynomial.revAtFun theorem revAtFun_invol {N i : ℕ} : revAtFun N (revAtFun N i) = i := by unfold revAtFun split_ifs with h j · exact tsub_tsub_cancel_of_le h · exfalso apply j exact Nat.sub_le N i · rfl #align polynomial.rev_at_fun_invol Polynomial.revAtFun_invol theorem revAtFun_inj {N : ℕ} : Function.Injective (revAtFun N) := by intro a b hab rw [← @revAtFun_invol N a, hab, revAtFun_invol] #align polynomial.rev_at_fun_inj Polynomial.revAtFun_inj def revAt (N : ℕ) : Function.Embedding ℕ ℕ where toFun i := ite (i ≤ N) (N - i) i inj' := revAtFun_inj #align polynomial.rev_at Polynomial.revAt @[simp] theorem revAtFun_eq (N i : ℕ) : revAtFun N i = revAt N i := rfl #align polynomial.rev_at_fun_eq Polynomial.revAtFun_eq @[simp] theorem revAt_invol {N i : ℕ} : (revAt N) (revAt N i) = i := revAtFun_invol #align polynomial.rev_at_invol Polynomial.revAt_invol @[simp] theorem revAt_le {N i : ℕ} (H : i ≤ N) : revAt N i = N - i := if_pos H #align polynomial.rev_at_le Polynomial.revAt_le lemma revAt_eq_self_of_lt {N i : ℕ} (h : N < i) : revAt N i = i := by simp [revAt, Nat.not_le.mpr h]
Mathlib/Algebra/Polynomial/Reverse.lean
82
88
theorem revAt_add {N O n o : ℕ} (hn : n ≤ N) (ho : o ≤ O) : revAt (N + O) (n + o) = revAt N n + revAt O o := by
rcases Nat.le.dest hn with ⟨n', rfl⟩ rcases Nat.le.dest ho with ⟨o', rfl⟩ repeat' rw [revAt_le (le_add_right rfl.le)] rw [add_assoc, add_left_comm n' o, ← add_assoc, revAt_le (le_add_right rfl.le)] repeat' rw [add_tsub_cancel_left]
import Mathlib.Data.Real.Basic import Mathlib.Combinatorics.Pigeonhole import Mathlib.Algebra.Order.EuclideanAbsoluteValue #align_import number_theory.class_number.admissible_absolute_value from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c" local infixl:50 " ≺ " => EuclideanDomain.r namespace AbsoluteValue variable {R : Type*} [EuclideanDomain R] variable (abv : AbsoluteValue R ℤ) structure IsAdmissible extends IsEuclidean abv where protected card : ℝ → ℕ exists_partition' : ∀ (n : ℕ) {ε : ℝ} (_ : 0 < ε) {b : R} (_ : b ≠ 0) (A : Fin n → R), ∃ t : Fin n → Fin (card ε), ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ % b - A i₀ % b) : ℝ) < abv b • ε #align absolute_value.is_admissible AbsoluteValue.IsAdmissible -- Porting note: no docstrings for IsAdmissible attribute [nolint docBlame] IsAdmissible.card namespace IsAdmissible variable {abv} theorem exists_partition {ι : Type*} [Finite ι] {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0) (A : ι → R) (h : abv.IsAdmissible) : ∃ t : ι → Fin (h.card ε), ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ % b - A i₀ % b) : ℝ) < abv b • ε := by rcases Finite.exists_equiv_fin ι with ⟨n, ⟨e⟩⟩ obtain ⟨t, ht⟩ := h.exists_partition' n hε hb (A ∘ e.symm) refine ⟨t ∘ e, fun i₀ i₁ h ↦ ?_⟩ convert (config := {transparency := .default}) ht (e i₀) (e i₁) h <;> simp only [e.symm_apply_apply] #align absolute_value.is_admissible.exists_partition AbsoluteValue.IsAdmissible.exists_partition theorem exists_approx_aux (n : ℕ) (h : abv.IsAdmissible) : ∀ {ε : ℝ} (_hε : 0 < ε) {b : R} (_hb : b ≠ 0) (A : Fin (h.card ε ^ n).succ → Fin n → R), ∃ i₀ i₁, i₀ ≠ i₁ ∧ ∀ k, (abv (A i₁ k % b - A i₀ k % b) : ℝ) < abv b • ε := by haveI := Classical.decEq R induction' n with n ih · intro ε _hε b _hb A refine ⟨0, 1, ?_, ?_⟩ · simp rintro ⟨i, ⟨⟩⟩ intro ε hε b hb A let M := h.card ε -- By the "nicer" pigeonhole principle, we can find a collection `s` -- of more than `M^n` remainders where the first components lie close together: obtain ⟨s, s_inj, hs⟩ : ∃ s : Fin (M ^ n).succ → Fin (M ^ n.succ).succ, Function.Injective s ∧ ∀ i₀ i₁, (abv (A (s i₁) 0 % b - A (s i₀) 0 % b) : ℝ) < abv b • ε := by -- We can partition the `A`s into `M` subsets where -- the first components lie close together: obtain ⟨t, ht⟩ : ∃ t : Fin (M ^ n.succ).succ → Fin M, ∀ i₀ i₁, t i₀ = t i₁ → (abv (A i₁ 0 % b - A i₀ 0 % b) : ℝ) < abv b • ε := h.exists_partition hε hb fun x ↦ A x 0 -- Since the `M` subsets contain more than `M * M^n` elements total, -- there must be a subset that contains more than `M^n` elements. obtain ⟨s, hs⟩ := Fintype.exists_lt_card_fiber_of_mul_lt_card (f := t) (by simpa only [Fintype.card_fin, pow_succ'] using Nat.lt_succ_self (M ^ n.succ)) refine ⟨fun i ↦ (Finset.univ.filter fun x ↦ t x = s).toList.get <| i.castLE ?_, fun i j h ↦ ?_, fun i₀ i₁ ↦ ht _ _ ?_⟩ · rwa [Finset.length_toList] · simpa [(Finset.nodup_toList _).get_inj_iff] using h · have : ∀ i, t ((Finset.univ.filter fun x ↦ t x = s).toList.get i) = s := fun i ↦ (Finset.mem_filter.mp (Finset.mem_toList.mp (List.get_mem _ i i.2))).2 simp [this] -- Since `s` is large enough, there are two elements of `A ∘ s` -- where the second components lie close together. obtain ⟨k₀, k₁, hk, h⟩ := ih hε hb fun x ↦ Fin.tail (A (s x)) refine ⟨s k₀, s k₁, fun h ↦ hk (s_inj h), fun i ↦ Fin.cases ?_ (fun i ↦ ?_) i⟩ · exact hs k₀ k₁ · exact h i #align absolute_value.is_admissible.exists_approx_aux AbsoluteValue.IsAdmissible.exists_approx_aux
Mathlib/NumberTheory/ClassNumber/AdmissibleAbsoluteValue.lean
117
123
theorem exists_approx {ι : Type*} [Fintype ι] {ε : ℝ} (hε : 0 < ε) {b : R} (hb : b ≠ 0) (h : abv.IsAdmissible) (A : Fin (h.card ε ^ Fintype.card ι).succ → ι → R) : ∃ i₀ i₁, i₀ ≠ i₁ ∧ ∀ k, (abv (A i₁ k % b - A i₀ k % b) : ℝ) < abv b • ε := by
let e := Fintype.equivFin ι obtain ⟨i₀, i₁, ne, h⟩ := h.exists_approx_aux (Fintype.card ι) hε hb fun x y ↦ A x (e.symm y) refine ⟨i₀, i₁, ne, fun k ↦ ?_⟩ convert h (e k) <;> simp only [e.symm_apply_apply]
import Mathlib.Analysis.Calculus.FDeriv.Basic #align_import analysis.calculus.fderiv.restrict_scalars from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee" open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section RestrictScalars variable (𝕜 : Type*) [NontriviallyNormedField 𝕜] variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedSpace 𝕜' E] variable [IsScalarTower 𝕜 𝕜' E] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedSpace 𝕜' F] variable [IsScalarTower 𝕜 𝕜' F] variable {f : E → F} {f' : E →L[𝕜'] F} {s : Set E} {x : E} @[fun_prop] theorem HasStrictFDerivAt.restrictScalars (h : HasStrictFDerivAt f f' x) : HasStrictFDerivAt f (f'.restrictScalars 𝕜) x := h #align has_strict_fderiv_at.restrict_scalars HasStrictFDerivAt.restrictScalars theorem HasFDerivAtFilter.restrictScalars {L} (h : HasFDerivAtFilter f f' x L) : HasFDerivAtFilter f (f'.restrictScalars 𝕜) x L := .of_isLittleO h.1 #align has_fderiv_at_filter.restrict_scalars HasFDerivAtFilter.restrictScalars @[fun_prop] theorem HasFDerivAt.restrictScalars (h : HasFDerivAt f f' x) : HasFDerivAt f (f'.restrictScalars 𝕜) x := .of_isLittleO h.1 #align has_fderiv_at.restrict_scalars HasFDerivAt.restrictScalars @[fun_prop] theorem HasFDerivWithinAt.restrictScalars (h : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt f (f'.restrictScalars 𝕜) s x := .of_isLittleO h.1 #align has_fderiv_within_at.restrict_scalars HasFDerivWithinAt.restrictScalars @[fun_prop] theorem DifferentiableAt.restrictScalars (h : DifferentiableAt 𝕜' f x) : DifferentiableAt 𝕜 f x := (h.hasFDerivAt.restrictScalars 𝕜).differentiableAt #align differentiable_at.restrict_scalars DifferentiableAt.restrictScalars @[fun_prop] theorem DifferentiableWithinAt.restrictScalars (h : DifferentiableWithinAt 𝕜' f s x) : DifferentiableWithinAt 𝕜 f s x := (h.hasFDerivWithinAt.restrictScalars 𝕜).differentiableWithinAt #align differentiable_within_at.restrict_scalars DifferentiableWithinAt.restrictScalars @[fun_prop] theorem DifferentiableOn.restrictScalars (h : DifferentiableOn 𝕜' f s) : DifferentiableOn 𝕜 f s := fun x hx => (h x hx).restrictScalars 𝕜 #align differentiable_on.restrict_scalars DifferentiableOn.restrictScalars @[fun_prop] theorem Differentiable.restrictScalars (h : Differentiable 𝕜' f) : Differentiable 𝕜 f := fun x => (h x).restrictScalars 𝕜 #align differentiable.restrict_scalars Differentiable.restrictScalars @[fun_prop] theorem HasFDerivWithinAt.of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivWithinAt f g' s x) (H : f'.restrictScalars 𝕜 = g') : HasFDerivWithinAt f f' s x := by rw [← H] at h exact .of_isLittleO h.1 #align has_fderiv_within_at_of_restrict_scalars HasFDerivWithinAt.of_restrictScalars @[fun_prop]
Mathlib/Analysis/Calculus/FDeriv/RestrictScalars.lean
99
102
theorem hasFDerivAt_of_restrictScalars {g' : E →L[𝕜] F} (h : HasFDerivAt f g' x) (H : f'.restrictScalars 𝕜 = g') : HasFDerivAt f f' x := by
rw [← H] at h exact .of_isLittleO h.1
import Mathlib.LinearAlgebra.TensorProduct.Tower import Mathlib.Algebra.DirectSum.Module #align_import linear_algebra.direct_sum.tensor_product from "leanprover-community/mathlib"@"9b9d125b7be0930f564a68f1d73ace10cf46064d" suppress_compilation universe u v₁ v₂ w₁ w₁' w₂ w₂' section Ring namespace TensorProduct open TensorProduct open DirectSum open LinearMap attribute [local ext] TensorProduct.ext variable (R : Type u) [CommSemiring R] (S) [Semiring S] [Algebra R S] variable {ι₁ : Type v₁} {ι₂ : Type v₂} variable [DecidableEq ι₁] [DecidableEq ι₂] variable (M₁ : ι₁ → Type w₁) (M₁' : Type w₁') (M₂ : ι₂ → Type w₂) (M₂' : Type w₂') variable [∀ i₁, AddCommMonoid (M₁ i₁)] [AddCommMonoid M₁'] variable [∀ i₂, AddCommMonoid (M₂ i₂)] [AddCommMonoid M₂'] variable [∀ i₁, Module R (M₁ i₁)] [Module R M₁'] [∀ i₂, Module R (M₂ i₂)] [Module R M₂'] variable [∀ i₁, Module S (M₁ i₁)] [∀ i₁, IsScalarTower R S (M₁ i₁)] protected def directSum : ((⨁ i₁, M₁ i₁) ⊗[R] ⨁ i₂, M₂ i₂) ≃ₗ[S] ⨁ i : ι₁ × ι₂, M₁ i.1 ⊗[R] M₂ i.2 := by -- Porting note: entirely rewritten to allow unification to happen one step at a time refine LinearEquiv.ofLinear (R := S) (R₂ := S) ?toFun ?invFun ?left ?right · refine AlgebraTensorModule.lift ?_ refine DirectSum.toModule S _ _ fun i₁ => ?_ refine LinearMap.flip ?_ refine DirectSum.toModule R _ _ fun i₂ => LinearMap.flip <| ?_ refine AlgebraTensorModule.curry ?_ exact DirectSum.lof S (ι₁ × ι₂) (fun i => M₁ i.1 ⊗[R] M₂ i.2) (i₁, i₂) · refine DirectSum.toModule S _ _ fun i => ?_ exact AlgebraTensorModule.map (DirectSum.lof S _ M₁ i.1) (DirectSum.lof R _ M₂ i.2) · refine DirectSum.linearMap_ext S fun ⟨i₁, i₂⟩ => ?_ refine TensorProduct.AlgebraTensorModule.ext fun m₁ m₂ => ?_ -- Porting note: seems much nicer than the `repeat` lean 3 proof. simp only [coe_comp, Function.comp_apply, toModule_lof, AlgebraTensorModule.map_tmul, AlgebraTensorModule.lift_apply, lift.tmul, coe_restrictScalars, flip_apply, AlgebraTensorModule.curry_apply, curry_apply, id_comp] · -- `(_)` prevents typeclass search timing out on problems that can be solved immediately by -- unification apply TensorProduct.AlgebraTensorModule.curry_injective refine DirectSum.linearMap_ext _ fun i₁ => ?_ refine LinearMap.ext fun x₁ => ?_ refine DirectSum.linearMap_ext _ fun i₂ => ?_ refine LinearMap.ext fun x₂ => ?_ -- Porting note: seems much nicer than the `repeat` lean 3 proof. simp only [coe_comp, Function.comp_apply, AlgebraTensorModule.curry_apply, curry_apply, coe_restrictScalars, AlgebraTensorModule.lift_apply, lift.tmul, toModule_lof, flip_apply, AlgebraTensorModule.map_tmul, id_coe, id_eq] #align tensor_product.direct_sum TensorProduct.directSum def directSumLeft : (⨁ i₁, M₁ i₁) ⊗[R] M₂' ≃ₗ[R] ⨁ i, M₁ i ⊗[R] M₂' := LinearEquiv.ofLinear (lift <| DirectSum.toModule R _ _ fun i => (mk R _ _).compr₂ <| DirectSum.lof R ι₁ (fun i => M₁ i ⊗[R] M₂') _) (DirectSum.toModule R _ _ fun i => rTensor _ (DirectSum.lof R ι₁ _ _)) (DirectSum.linearMap_ext R fun i => TensorProduct.ext <| LinearMap.ext₂ fun m₁ m₂ => by dsimp only [comp_apply, compr₂_apply, id_apply, mk_apply] simp_rw [DirectSum.toModule_lof, rTensor_tmul, lift.tmul, DirectSum.toModule_lof, compr₂_apply, mk_apply]) (TensorProduct.ext <| DirectSum.linearMap_ext R fun i => LinearMap.ext₂ fun m₁ m₂ => by dsimp only [comp_apply, compr₂_apply, id_apply, mk_apply] simp_rw [lift.tmul, DirectSum.toModule_lof, compr₂_apply, mk_apply, DirectSum.toModule_lof, rTensor_tmul]) #align tensor_product.direct_sum_left TensorProduct.directSumLeft def directSumRight : (M₁' ⊗[R] ⨁ i, M₂ i) ≃ₗ[R] ⨁ i, M₁' ⊗[R] M₂ i := TensorProduct.comm R _ _ ≪≫ₗ directSumLeft R M₂ M₁' ≪≫ₗ DFinsupp.mapRange.linearEquiv fun _ => TensorProduct.comm R _ _ #align tensor_product.direct_sum_right TensorProduct.directSumRight variable {M₁ M₁' M₂ M₂'} @[simp]
Mathlib/LinearAlgebra/DirectSum/TensorProduct.lean
150
153
theorem directSum_lof_tmul_lof (i₁ : ι₁) (m₁ : M₁ i₁) (i₂ : ι₂) (m₂ : M₂ i₂) : TensorProduct.directSum R S M₁ M₂ (DirectSum.lof S ι₁ M₁ i₁ m₁ ⊗ₜ DirectSum.lof R ι₂ M₂ i₂ m₂) = DirectSum.lof S (ι₁ × ι₂) (fun i => M₁ i.1 ⊗[R] M₂ i.2) (i₁, i₂) (m₁ ⊗ₜ m₂) := by
simp [TensorProduct.directSum]
import Mathlib.Algebra.Polynomial.Degree.Definitions import Mathlib.Algebra.Polynomial.Induction #align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f" set_option linter.uppercaseLean3 false noncomputable section open Finset AddMonoidAlgebra open Polynomial namespace Polynomial universe u v w y variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} section variable [Semiring S] variable (f : R →+* S) (x : S) irreducible_def eval₂ (p : R[X]) : S := p.sum fun e a => f a * x ^ e #align polynomial.eval₂ Polynomial.eval₂ theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by rw [eval₂_def] #align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S} {φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by rintro rfl rfl rfl; rfl #align polynomial.eval₂_congr Polynomial.eval₂_congr @[simp] theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero, mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff, RingHom.map_zero, imp_true_iff, eq_self_iff_true] #align polynomial.eval₂_at_zero Polynomial.eval₂_at_zero @[simp] theorem eval₂_zero : (0 : R[X]).eval₂ f x = 0 := by simp [eval₂_eq_sum] #align polynomial.eval₂_zero Polynomial.eval₂_zero @[simp] theorem eval₂_C : (C a).eval₂ f x = f a := by simp [eval₂_eq_sum] #align polynomial.eval₂_C Polynomial.eval₂_C @[simp] theorem eval₂_X : X.eval₂ f x = x := by simp [eval₂_eq_sum] #align polynomial.eval₂_X Polynomial.eval₂_X @[simp] theorem eval₂_monomial {n : ℕ} {r : R} : (monomial n r).eval₂ f x = f r * x ^ n := by simp [eval₂_eq_sum] #align polynomial.eval₂_monomial Polynomial.eval₂_monomial @[simp] theorem eval₂_X_pow {n : ℕ} : (X ^ n).eval₂ f x = x ^ n := by rw [X_pow_eq_monomial] convert eval₂_monomial f x (n := n) (r := 1) simp #align polynomial.eval₂_X_pow Polynomial.eval₂_X_pow @[simp] theorem eval₂_add : (p + q).eval₂ f x = p.eval₂ f x + q.eval₂ f x := by simp only [eval₂_eq_sum] apply sum_add_index <;> simp [add_mul] #align polynomial.eval₂_add Polynomial.eval₂_add @[simp] theorem eval₂_one : (1 : R[X]).eval₂ f x = 1 := by rw [← C_1, eval₂_C, f.map_one] #align polynomial.eval₂_one Polynomial.eval₂_one set_option linter.deprecated false in @[simp] theorem eval₂_bit0 : (bit0 p).eval₂ f x = bit0 (p.eval₂ f x) := by rw [bit0, eval₂_add, bit0] #align polynomial.eval₂_bit0 Polynomial.eval₂_bit0 set_option linter.deprecated false in @[simp] theorem eval₂_bit1 : (bit1 p).eval₂ f x = bit1 (p.eval₂ f x) := by rw [bit1, eval₂_add, eval₂_bit0, eval₂_one, bit1] #align polynomial.eval₂_bit1 Polynomial.eval₂_bit1 @[simp] theorem eval₂_smul (g : R →+* S) (p : R[X]) (x : S) {s : R} : eval₂ g x (s • p) = g s * eval₂ g x p := by have A : p.natDegree < p.natDegree.succ := Nat.lt_succ_self _ have B : (s • p).natDegree < p.natDegree.succ := (natDegree_smul_le _ _).trans_lt A rw [eval₂_eq_sum, eval₂_eq_sum, sum_over_range' _ _ _ A, sum_over_range' _ _ _ B] <;> simp [mul_sum, mul_assoc] #align polynomial.eval₂_smul Polynomial.eval₂_smul @[simp] theorem eval₂_C_X : eval₂ C X p = p := Polynomial.induction_on' p (fun p q hp hq => by simp [hp, hq]) fun n x => by rw [eval₂_monomial, ← smul_X_eq_monomial, C_mul'] #align polynomial.eval₂_C_X Polynomial.eval₂_C_X @[simps] def eval₂AddMonoidHom : R[X] →+ S where toFun := eval₂ f x map_zero' := eval₂_zero _ _ map_add' _ _ := eval₂_add _ _ #align polynomial.eval₂_add_monoid_hom Polynomial.eval₂AddMonoidHom #align polynomial.eval₂_add_monoid_hom_apply Polynomial.eval₂AddMonoidHom_apply @[simp] theorem eval₂_natCast (n : ℕ) : (n : R[X]).eval₂ f x = n := by induction' n with n ih -- Porting note: `Nat.zero_eq` is required. · simp only [eval₂_zero, Nat.cast_zero, Nat.zero_eq] · rw [n.cast_succ, eval₂_add, ih, eval₂_one, n.cast_succ] #align polynomial.eval₂_nat_cast Polynomial.eval₂_natCast @[deprecated (since := "2024-04-17")] alias eval₂_nat_cast := eval₂_natCast -- See note [no_index around OfNat.ofNat] @[simp] lemma eval₂_ofNat {S : Type*} [Semiring S] (n : ℕ) [n.AtLeastTwo] (f : R →+* S) (a : S) : (no_index (OfNat.ofNat n : R[X])).eval₂ f a = OfNat.ofNat n := by simp [OfNat.ofNat] variable [Semiring T] theorem eval₂_sum (p : T[X]) (g : ℕ → T → R[X]) (x : S) : (p.sum g).eval₂ f x = p.sum fun n a => (g n a).eval₂ f x := by let T : R[X] →+ S := { toFun := eval₂ f x map_zero' := eval₂_zero _ _ map_add' := fun p q => eval₂_add _ _ } have A : ∀ y, eval₂ f x y = T y := fun y => rfl simp only [A] rw [sum, map_sum, sum] #align polynomial.eval₂_sum Polynomial.eval₂_sum theorem eval₂_list_sum (l : List R[X]) (x : S) : eval₂ f x l.sum = (l.map (eval₂ f x)).sum := map_list_sum (eval₂AddMonoidHom f x) l #align polynomial.eval₂_list_sum Polynomial.eval₂_list_sum theorem eval₂_multiset_sum (s : Multiset R[X]) (x : S) : eval₂ f x s.sum = (s.map (eval₂ f x)).sum := map_multiset_sum (eval₂AddMonoidHom f x) s #align polynomial.eval₂_multiset_sum Polynomial.eval₂_multiset_sum theorem eval₂_finset_sum (s : Finset ι) (g : ι → R[X]) (x : S) : (∑ i ∈ s, g i).eval₂ f x = ∑ i ∈ s, (g i).eval₂ f x := map_sum (eval₂AddMonoidHom f x) _ _ #align polynomial.eval₂_finset_sum Polynomial.eval₂_finset_sum theorem eval₂_ofFinsupp {f : R →+* S} {x : S} {p : R[ℕ]} : eval₂ f x (⟨p⟩ : R[X]) = liftNC (↑f) (powersHom S x) p := by simp only [eval₂_eq_sum, sum, toFinsupp_sum, support, coeff] rfl #align polynomial.eval₂_of_finsupp Polynomial.eval₂_ofFinsupp theorem eval₂_mul_noncomm (hf : ∀ k, Commute (f <| q.coeff k) x) : eval₂ f x (p * q) = eval₂ f x p * eval₂ f x q := by rcases p with ⟨p⟩; rcases q with ⟨q⟩ simp only [coeff] at hf simp only [← ofFinsupp_mul, eval₂_ofFinsupp] exact liftNC_mul _ _ p q fun {k n} _hn => (hf k).pow_right n #align polynomial.eval₂_mul_noncomm Polynomial.eval₂_mul_noncomm @[simp] theorem eval₂_mul_X : eval₂ f x (p * X) = eval₂ f x p * x := by refine _root_.trans (eval₂_mul_noncomm _ _ fun k => ?_) (by rw [eval₂_X]) rcases em (k = 1) with (rfl | hk) · simp · simp [coeff_X_of_ne_one hk] #align polynomial.eval₂_mul_X Polynomial.eval₂_mul_X @[simp] theorem eval₂_X_mul : eval₂ f x (X * p) = eval₂ f x p * x := by rw [X_mul, eval₂_mul_X] #align polynomial.eval₂_X_mul Polynomial.eval₂_X_mul theorem eval₂_mul_C' (h : Commute (f a) x) : eval₂ f x (p * C a) = eval₂ f x p * f a := by rw [eval₂_mul_noncomm, eval₂_C] intro k by_cases hk : k = 0 · simp only [hk, h, coeff_C_zero, coeff_C_ne_zero] · simp only [coeff_C_ne_zero hk, RingHom.map_zero, Commute.zero_left] #align polynomial.eval₂_mul_C' Polynomial.eval₂_mul_C' theorem eval₂_list_prod_noncomm (ps : List R[X]) (hf : ∀ p ∈ ps, ∀ (k), Commute (f <| coeff p k) x) : eval₂ f x ps.prod = (ps.map (Polynomial.eval₂ f x)).prod := by induction' ps using List.reverseRecOn with ps p ihp · simp · simp only [List.forall_mem_append, List.forall_mem_singleton] at hf simp [eval₂_mul_noncomm _ _ hf.2, ihp hf.1] #align polynomial.eval₂_list_prod_noncomm Polynomial.eval₂_list_prod_noncomm @[simps] def eval₂RingHom' (f : R →+* S) (x : S) (hf : ∀ a, Commute (f a) x) : R[X] →+* S where toFun := eval₂ f x map_add' _ _ := eval₂_add _ _ map_zero' := eval₂_zero _ _ map_mul' _p q := eval₂_mul_noncomm f x fun k => hf <| coeff q k map_one' := eval₂_one _ _ #align polynomial.eval₂_ring_hom' Polynomial.eval₂RingHom' end section Eval variable {x : R} def eval : R → R[X] → R := eval₂ (RingHom.id _) #align polynomial.eval Polynomial.eval theorem eval_eq_sum : p.eval x = p.sum fun e a => a * x ^ e := by rw [eval, eval₂_eq_sum] rfl #align polynomial.eval_eq_sum Polynomial.eval_eq_sum theorem eval_eq_sum_range {p : R[X]} (x : R) : p.eval x = ∑ i ∈ Finset.range (p.natDegree + 1), p.coeff i * x ^ i := by rw [eval_eq_sum, sum_over_range]; simp #align polynomial.eval_eq_sum_range Polynomial.eval_eq_sum_range theorem eval_eq_sum_range' {p : R[X]} {n : ℕ} (hn : p.natDegree < n) (x : R) : p.eval x = ∑ i ∈ Finset.range n, p.coeff i * x ^ i := by rw [eval_eq_sum, p.sum_over_range' _ _ hn]; simp #align polynomial.eval_eq_sum_range' Polynomial.eval_eq_sum_range' @[simp] theorem eval₂_at_apply {S : Type*} [Semiring S] (f : R →+* S) (r : R) : p.eval₂ f (f r) = f (p.eval r) := by rw [eval₂_eq_sum, eval_eq_sum, sum, sum, map_sum f] simp only [f.map_mul, f.map_pow] #align polynomial.eval₂_at_apply Polynomial.eval₂_at_apply @[simp] theorem eval₂_at_one {S : Type*} [Semiring S] (f : R →+* S) : p.eval₂ f 1 = f (p.eval 1) := by convert eval₂_at_apply (p := p) f 1 simp #align polynomial.eval₂_at_one Polynomial.eval₂_at_one @[simp] theorem eval₂_at_natCast {S : Type*} [Semiring S] (f : R →+* S) (n : ℕ) : p.eval₂ f n = f (p.eval n) := by convert eval₂_at_apply (p := p) f n simp #align polynomial.eval₂_at_nat_cast Polynomial.eval₂_at_natCast @[deprecated (since := "2024-04-17")] alias eval₂_at_nat_cast := eval₂_at_natCast -- See note [no_index around OfNat.ofNat] @[simp] theorem eval₂_at_ofNat {S : Type*} [Semiring S] (f : R →+* S) (n : ℕ) [n.AtLeastTwo] : p.eval₂ f (no_index (OfNat.ofNat n)) = f (p.eval (OfNat.ofNat n)) := by simp [OfNat.ofNat] @[simp] theorem eval_C : (C a).eval x = a := eval₂_C _ _ #align polynomial.eval_C Polynomial.eval_C @[simp] theorem eval_natCast {n : ℕ} : (n : R[X]).eval x = n := by simp only [← C_eq_natCast, eval_C] #align polynomial.eval_nat_cast Polynomial.eval_natCast @[deprecated (since := "2024-04-17")] alias eval_nat_cast := eval_natCast -- See note [no_index around OfNat.ofNat] @[simp] lemma eval_ofNat (n : ℕ) [n.AtLeastTwo] (a : R) : (no_index (OfNat.ofNat n : R[X])).eval a = OfNat.ofNat n := by simp only [OfNat.ofNat, eval_natCast] @[simp] theorem eval_X : X.eval x = x := eval₂_X _ _ #align polynomial.eval_X Polynomial.eval_X @[simp] theorem eval_monomial {n a} : (monomial n a).eval x = a * x ^ n := eval₂_monomial _ _ #align polynomial.eval_monomial Polynomial.eval_monomial @[simp] theorem eval_zero : (0 : R[X]).eval x = 0 := eval₂_zero _ _ #align polynomial.eval_zero Polynomial.eval_zero @[simp] theorem eval_add : (p + q).eval x = p.eval x + q.eval x := eval₂_add _ _ #align polynomial.eval_add Polynomial.eval_add @[simp] theorem eval_one : (1 : R[X]).eval x = 1 := eval₂_one _ _ #align polynomial.eval_one Polynomial.eval_one set_option linter.deprecated false in @[simp] theorem eval_bit0 : (bit0 p).eval x = bit0 (p.eval x) := eval₂_bit0 _ _ #align polynomial.eval_bit0 Polynomial.eval_bit0 set_option linter.deprecated false in @[simp] theorem eval_bit1 : (bit1 p).eval x = bit1 (p.eval x) := eval₂_bit1 _ _ #align polynomial.eval_bit1 Polynomial.eval_bit1 @[simp] theorem eval_smul [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (s : S) (p : R[X]) (x : R) : (s • p).eval x = s • p.eval x := by rw [← smul_one_smul R s p, eval, eval₂_smul, RingHom.id_apply, smul_one_mul] #align polynomial.eval_smul Polynomial.eval_smul @[simp] theorem eval_C_mul : (C a * p).eval x = a * p.eval x := by induction p using Polynomial.induction_on' with | h_add p q ph qh => simp only [mul_add, eval_add, ph, qh] | h_monomial n b => simp only [mul_assoc, C_mul_monomial, eval_monomial] #align polynomial.eval_C_mul Polynomial.eval_C_mul theorem eval_monomial_one_add_sub [CommRing S] (d : ℕ) (y : S) : eval (1 + y) (monomial d (d + 1 : S)) - eval y (monomial d (d + 1 : S)) = ∑ x_1 ∈ range (d + 1), ↑((d + 1).choose x_1) * (↑x_1 * y ^ (x_1 - 1)) := by have cast_succ : (d + 1 : S) = ((d.succ : ℕ) : S) := by simp only [Nat.cast_succ] rw [cast_succ, eval_monomial, eval_monomial, add_comm, add_pow] -- Porting note: `apply_congr` hadn't been ported yet, so `congr` & `ext` is used. conv_lhs => congr · congr · skip · congr · skip · ext rw [one_pow, mul_one, mul_comm] rw [sum_range_succ, mul_add, Nat.choose_self, Nat.cast_one, one_mul, add_sub_cancel_right, mul_sum, sum_range_succ', Nat.cast_zero, zero_mul, mul_zero, add_zero] refine sum_congr rfl fun y _hy => ?_ rw [← mul_assoc, ← mul_assoc, ← Nat.cast_mul, Nat.succ_mul_choose_eq, Nat.cast_mul, Nat.add_sub_cancel] #align polynomial.eval_monomial_one_add_sub Polynomial.eval_monomial_one_add_sub @[simps] def leval {R : Type*} [Semiring R] (r : R) : R[X] →ₗ[R] R where toFun f := f.eval r map_add' _f _g := eval_add map_smul' c f := eval_smul c f r #align polynomial.leval Polynomial.leval #align polynomial.leval_apply Polynomial.leval_apply @[simp] theorem eval_natCast_mul {n : ℕ} : ((n : R[X]) * p).eval x = n * p.eval x := by rw [← C_eq_natCast, eval_C_mul] #align polynomial.eval_nat_cast_mul Polynomial.eval_natCast_mul @[deprecated (since := "2024-04-17")] alias eval_nat_cast_mul := eval_natCast_mul @[simp]
Mathlib/Algebra/Polynomial/Eval.lean
478
484
theorem eval_mul_X : (p * X).eval x = p.eval x * x := by
induction p using Polynomial.induction_on' with | h_add p q ph qh => simp only [add_mul, eval_add, ph, qh] | h_monomial n a => simp only [← monomial_one_one_eq_X, monomial_mul_monomial, eval_monomial, mul_one, pow_succ, mul_assoc]
import Mathlib.Algebra.Module.Submodule.EqLocus import Mathlib.Algebra.Module.Submodule.RestrictScalars import Mathlib.Algebra.Ring.Idempotents import Mathlib.Data.Set.Pointwise.SMul import Mathlib.LinearAlgebra.Basic import Mathlib.Order.CompactlyGenerated.Basic import Mathlib.Order.OmegaCompletePartialOrder #align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0" variable {R R₂ K M M₂ V S : Type*} namespace Submodule open Function Set open Pointwise section AddCommMonoid variable [Semiring R] [AddCommMonoid M] [Module R M] variable {x : M} (p p' : Submodule R M) variable [Semiring R₂] {σ₁₂ : R →+* R₂} variable [AddCommMonoid M₂] [Module R₂ M₂] variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂] section variable (R) def span (s : Set M) : Submodule R M := sInf { p | s ⊆ p } #align submodule.span Submodule.span variable {R} -- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument @[mk_iff] class IsPrincipal (S : Submodule R M) : Prop where principal' : ∃ a, S = span R {a} #align submodule.is_principal Submodule.IsPrincipal theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] : ∃ a, S = span R {a} := Submodule.IsPrincipal.principal' #align submodule.is_principal.principal Submodule.IsPrincipal.principal end variable {s t : Set M} theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p := mem_iInter₂ #align submodule.mem_span Submodule.mem_span @[aesop safe 20 apply (rule_sets := [SetLike])] theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h #align submodule.subset_span Submodule.subset_span theorem span_le {p} : span R s ≤ p ↔ s ⊆ p := ⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩ #align submodule.span_le Submodule.span_le theorem span_mono (h : s ⊆ t) : span R s ≤ span R t := span_le.2 <| Subset.trans h subset_span #align submodule.span_mono Submodule.span_mono theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono #align submodule.span_monotone Submodule.span_monotone theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p := le_antisymm (span_le.2 h₁) h₂ #align submodule.span_eq_of_le Submodule.span_eq_of_le theorem span_eq : span R (p : Set M) = p := span_eq_of_le _ (Subset.refl _) subset_span #align submodule.span_eq Submodule.span_eq theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t := le_antisymm (span_le.2 hs) (span_le.2 ht) #align submodule.span_eq_span Submodule.span_eq_span lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) : (span R (s : Set M) : Set M) = s := by refine le_antisymm ?_ subset_span let s' : Submodule R M := { carrier := s add_mem' := add_mem zero_mem' := zero_mem _ smul_mem' := SMulMemClass.smul_mem } exact span_le (p := s') |>.mpr le_rfl @[simp] theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] : span S (p : Set M) = p.restrictScalars S := span_eq (p.restrictScalars S) #align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) : f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f) theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) := (image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩ theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) : (span R s).map f = span R₂ (f '' s) := Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s) #align submodule.map_span Submodule.map_span alias _root_.LinearMap.map_span := Submodule.map_span #align linear_map.map_span LinearMap.map_span theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) : map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N #align submodule.map_span_le Submodule.map_span_le alias _root_.LinearMap.map_span_le := Submodule.map_span_le #align linear_map.map_span_le LinearMap.map_span_le @[simp] theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s)) rw [span_le, Set.insert_subset_iff] exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩ #align submodule.span_insert_zero Submodule.span_insert_zero -- See also `span_preimage_eq` below. theorem span_preimage_le (f : F) (s : Set M₂) : span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by rw [span_le, comap_coe] exact preimage_mono subset_span #align submodule.span_preimage_le Submodule.span_preimage_le alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le #align linear_map.span_preimage_le LinearMap.span_preimage_le theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s := (@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span #align submodule.closure_subset_span Submodule.closure_subset_span theorem closure_le_toAddSubmonoid_span {s : Set M} : AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid := closure_subset_span #align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span @[simp] theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s := le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure) #align submodule.span_closure Submodule.span_closure @[elab_as_elim] theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x := ((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h #align submodule.span_induction Submodule.span_induction theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s) (hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y) (zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0) (add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y) (add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂)) (smul_left : ∀ (r : R) x y, p x y → p (r • x) y) (smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b := Submodule.span_induction ha (fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r => smul_right r x) (zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b @[elab_as_elim] theorem span_induction' {p : ∀ x, x ∈ span R s → Prop} (mem : ∀ (x) (h : x ∈ s), p x (subset_span h)) (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc refine span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩ (fun x y hx hy => Exists.elim hx fun hx' hx => Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩ #align submodule.span_induction' Submodule.span_induction' open AddSubmonoid in theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by refine le_antisymm (fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩) (zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_) (closure_le.2 ?_) · rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm) · rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩ · rw [smul_zero]; apply zero_mem · rw [smul_add]; exact add_mem h h' @[elab_as_elim] theorem closure_induction {p : M → Prop} (h : x ∈ span R s) (zero : p 0) (add : ∀ x y, p x → p y → p (x + y)) (smul_mem : ∀ r : R, ∀ x ∈ s, p (r • x)) : p x := by rw [← mem_toAddSubmonoid, span_eq_closure] at h refine AddSubmonoid.closure_induction h ?_ zero add rintro _ ⟨r, -, m, hm, rfl⟩ exact smul_mem r m hm @[elab_as_elim] theorem closure_induction' {p : ∀ x, x ∈ span R s → Prop} (zero : p 0 (Submodule.zero_mem _)) (add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›)) (smul_mem : ∀ (r x) (h : x ∈ s), p (r • x) (Submodule.smul_mem _ _ <| subset_span h)) {x} (hx : x ∈ span R s) : p x hx := by refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) ↦ hc refine closure_induction hx ⟨zero_mem _, zero⟩ (fun x y hx hy ↦ Exists.elim hx fun hx' hx ↦ Exists.elim hy fun hy' hy ↦ ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩) fun r x hx ↦ ⟨Submodule.smul_mem _ _ (subset_span hx), smul_mem r x hx⟩ @[simp] theorem span_span_coe_preimage : span R (((↑) : span R s → M) ⁻¹' s) = ⊤ := eq_top_iff.2 fun x ↦ Subtype.recOn x fun x hx _ ↦ by refine span_induction' (p := fun x hx ↦ (⟨x, hx⟩ : span R s) ∈ span R (Subtype.val ⁻¹' s)) (fun x' hx' ↦ subset_span hx') ?_ (fun x _ y _ ↦ ?_) (fun r x _ ↦ ?_) hx · exact zero_mem _ · exact add_mem · exact smul_mem _ _ #align submodule.span_span_coe_preimage Submodule.span_span_coe_preimage @[simp] lemma span_setOf_mem_eq_top : span R {x : span R s | (x : M) ∈ s} = ⊤ := span_span_coe_preimage theorem span_nat_eq_addSubmonoid_closure (s : Set M) : (span ℕ s).toAddSubmonoid = AddSubmonoid.closure s := by refine Eq.symm (AddSubmonoid.closure_eq_of_le subset_span ?_) apply (OrderIso.to_galoisConnection (AddSubmonoid.toNatSubmodule (M := M)).symm).l_le (a := span ℕ s) (b := AddSubmonoid.closure s) rw [span_le] exact AddSubmonoid.subset_closure #align submodule.span_nat_eq_add_submonoid_closure Submodule.span_nat_eq_addSubmonoid_closure @[simp] theorem span_nat_eq (s : AddSubmonoid M) : (span ℕ (s : Set M)).toAddSubmonoid = s := by rw [span_nat_eq_addSubmonoid_closure, s.closure_eq] #align submodule.span_nat_eq Submodule.span_nat_eq theorem span_int_eq_addSubgroup_closure {M : Type*} [AddCommGroup M] (s : Set M) : (span ℤ s).toAddSubgroup = AddSubgroup.closure s := Eq.symm <| AddSubgroup.closure_eq_of_le _ subset_span fun x hx => span_induction hx (fun x hx => AddSubgroup.subset_closure hx) (AddSubgroup.zero_mem _) (fun _ _ => AddSubgroup.add_mem _) fun _ _ _ => AddSubgroup.zsmul_mem _ ‹_› _ #align submodule.span_int_eq_add_subgroup_closure Submodule.span_int_eq_addSubgroup_closure @[simp] theorem span_int_eq {M : Type*} [AddCommGroup M] (s : AddSubgroup M) : (span ℤ (s : Set M)).toAddSubgroup = s := by rw [span_int_eq_addSubgroup_closure, s.closure_eq] #align submodule.span_int_eq Submodule.span_int_eq section variable (R M) protected def gi : GaloisInsertion (@span R M _ _ _) (↑) where choice s _ := span R s gc _ _ := span_le le_l_u _ := subset_span choice_eq _ _ := rfl #align submodule.gi Submodule.gi end @[simp] theorem span_empty : span R (∅ : Set M) = ⊥ := (Submodule.gi R M).gc.l_bot #align submodule.span_empty Submodule.span_empty @[simp] theorem span_univ : span R (univ : Set M) = ⊤ := eq_top_iff.2 <| SetLike.le_def.2 <| subset_span #align submodule.span_univ Submodule.span_univ theorem span_union (s t : Set M) : span R (s ∪ t) = span R s ⊔ span R t := (Submodule.gi R M).gc.l_sup #align submodule.span_union Submodule.span_union theorem span_iUnion {ι} (s : ι → Set M) : span R (⋃ i, s i) = ⨆ i, span R (s i) := (Submodule.gi R M).gc.l_iSup #align submodule.span_Union Submodule.span_iUnion theorem span_iUnion₂ {ι} {κ : ι → Sort*} (s : ∀ i, κ i → Set M) : span R (⋃ (i) (j), s i j) = ⨆ (i) (j), span R (s i j) := (Submodule.gi R M).gc.l_iSup₂ #align submodule.span_Union₂ Submodule.span_iUnion₂ theorem span_attach_biUnion [DecidableEq M] {α : Type*} (s : Finset α) (f : s → Finset M) : span R (s.attach.biUnion f : Set M) = ⨆ x, span R (f x) := by simp [span_iUnion] #align submodule.span_attach_bUnion Submodule.span_attach_biUnion theorem sup_span : p ⊔ span R s = span R (p ∪ s) := by rw [Submodule.span_union, p.span_eq] #align submodule.sup_span Submodule.sup_span theorem span_sup : span R s ⊔ p = span R (s ∪ p) := by rw [Submodule.span_union, p.span_eq] #align submodule.span_sup Submodule.span_sup notation:1000 R " ∙ " x => span R (singleton x) theorem span_eq_iSup_of_singleton_spans (s : Set M) : span R s = ⨆ x ∈ s, R ∙ x := by simp only [← span_iUnion, Set.biUnion_of_singleton s] #align submodule.span_eq_supr_of_singleton_spans Submodule.span_eq_iSup_of_singleton_spans theorem span_range_eq_iSup {ι : Sort*} {v : ι → M} : span R (range v) = ⨆ i, R ∙ v i := by rw [span_eq_iSup_of_singleton_spans, iSup_range] #align submodule.span_range_eq_supr Submodule.span_range_eq_iSup theorem span_smul_le (s : Set M) (r : R) : span R (r • s) ≤ span R s := by rw [span_le] rintro _ ⟨x, hx, rfl⟩ exact smul_mem (span R s) r (subset_span hx) #align submodule.span_smul_le Submodule.span_smul_le theorem subset_span_trans {U V W : Set M} (hUV : U ⊆ Submodule.span R V) (hVW : V ⊆ Submodule.span R W) : U ⊆ Submodule.span R W := (Submodule.gi R M).gc.le_u_l_trans hUV hVW #align submodule.subset_span_trans Submodule.subset_span_trans theorem span_smul_eq_of_isUnit (s : Set M) (r : R) (hr : IsUnit r) : span R (r • s) = span R s := by apply le_antisymm · apply span_smul_le · convert span_smul_le (r • s) ((hr.unit⁻¹ : _) : R) rw [smul_smul] erw [hr.unit.inv_val] rw [one_smul] #align submodule.span_smul_eq_of_is_unit Submodule.span_smul_eq_of_isUnit @[simp] theorem coe_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) : ((iSup S: Submodule R M) : Set M) = ⋃ i, S i := let s : Submodule R M := { __ := AddSubmonoid.copy _ _ (AddSubmonoid.coe_iSup_of_directed H).symm smul_mem' := fun r _ hx ↦ have ⟨i, hi⟩ := Set.mem_iUnion.mp hx Set.mem_iUnion.mpr ⟨i, (S i).smul_mem' r hi⟩ } have : iSup S = s := le_antisymm (iSup_le fun i ↦ le_iSup (fun i ↦ (S i : Set M)) i) (Set.iUnion_subset fun _ ↦ le_iSup S _) this.symm ▸ rfl #align submodule.coe_supr_of_directed Submodule.coe_iSup_of_directed @[simp] theorem mem_iSup_of_directed {ι} [Nonempty ι] (S : ι → Submodule R M) (H : Directed (· ≤ ·) S) {x} : x ∈ iSup S ↔ ∃ i, x ∈ S i := by rw [← SetLike.mem_coe, coe_iSup_of_directed S H, mem_iUnion] rfl #align submodule.mem_supr_of_directed Submodule.mem_iSup_of_directed theorem mem_sSup_of_directed {s : Set (Submodule R M)} {z} (hs : s.Nonempty) (hdir : DirectedOn (· ≤ ·) s) : z ∈ sSup s ↔ ∃ y ∈ s, z ∈ y := by have : Nonempty s := hs.to_subtype simp only [sSup_eq_iSup', mem_iSup_of_directed _ hdir.directed_val, SetCoe.exists, Subtype.coe_mk, exists_prop] #align submodule.mem_Sup_of_directed Submodule.mem_sSup_of_directed @[norm_cast, simp] theorem coe_iSup_of_chain (a : ℕ →o Submodule R M) : (↑(⨆ k, a k) : Set M) = ⋃ k, (a k : Set M) := coe_iSup_of_directed a a.monotone.directed_le #align submodule.coe_supr_of_chain Submodule.coe_iSup_of_chain theorem coe_scott_continuous : OmegaCompletePartialOrder.Continuous' ((↑) : Submodule R M → Set M) := ⟨SetLike.coe_mono, coe_iSup_of_chain⟩ #align submodule.coe_scott_continuous Submodule.coe_scott_continuous @[simp] theorem mem_iSup_of_chain (a : ℕ →o Submodule R M) (m : M) : (m ∈ ⨆ k, a k) ↔ ∃ k, m ∈ a k := mem_iSup_of_directed a a.monotone.directed_le #align submodule.mem_supr_of_chain Submodule.mem_iSup_of_chain section variable {p p'} theorem mem_sup : x ∈ p ⊔ p' ↔ ∃ y ∈ p, ∃ z ∈ p', y + z = x := ⟨fun h => by rw [← span_eq p, ← span_eq p', ← span_union] at h refine span_induction h ?_ ?_ ?_ ?_ · rintro y (h | h) · exact ⟨y, h, 0, by simp, by simp⟩ · exact ⟨0, by simp, y, h, by simp⟩ · exact ⟨0, by simp, 0, by simp⟩ · rintro _ _ ⟨y₁, hy₁, z₁, hz₁, rfl⟩ ⟨y₂, hy₂, z₂, hz₂, rfl⟩ exact ⟨_, add_mem hy₁ hy₂, _, add_mem hz₁ hz₂, by rw [add_assoc, add_assoc, ← add_assoc y₂, ← add_assoc z₁, add_comm y₂]⟩ · rintro a _ ⟨y, hy, z, hz, rfl⟩ exact ⟨_, smul_mem _ a hy, _, smul_mem _ a hz, by simp [smul_add]⟩, by rintro ⟨y, hy, z, hz, rfl⟩ exact add_mem ((le_sup_left : p ≤ p ⊔ p') hy) ((le_sup_right : p' ≤ p ⊔ p') hz)⟩ #align submodule.mem_sup Submodule.mem_sup theorem mem_sup' : x ∈ p ⊔ p' ↔ ∃ (y : p) (z : p'), (y : M) + z = x := mem_sup.trans <| by simp only [Subtype.exists, exists_prop] #align submodule.mem_sup' Submodule.mem_sup' lemma exists_add_eq_of_codisjoint (h : Codisjoint p p') (x : M) : ∃ y ∈ p, ∃ z ∈ p', y + z = x := by suffices x ∈ p ⊔ p' by exact Submodule.mem_sup.mp this simpa only [h.eq_top] using Submodule.mem_top variable (p p') theorem coe_sup : ↑(p ⊔ p') = (p + p' : Set M) := by ext rw [SetLike.mem_coe, mem_sup, Set.mem_add] simp #align submodule.coe_sup Submodule.coe_sup theorem sup_toAddSubmonoid : (p ⊔ p').toAddSubmonoid = p.toAddSubmonoid ⊔ p'.toAddSubmonoid := by ext x rw [mem_toAddSubmonoid, mem_sup, AddSubmonoid.mem_sup] rfl #align submodule.sup_to_add_submonoid Submodule.sup_toAddSubmonoid
Mathlib/LinearAlgebra/Span.lean
464
468
theorem sup_toAddSubgroup {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] (p p' : Submodule R M) : (p ⊔ p').toAddSubgroup = p.toAddSubgroup ⊔ p'.toAddSubgroup := by
ext x rw [mem_toAddSubgroup, mem_sup, AddSubgroup.mem_sup] rfl
import Mathlib.Analysis.BoxIntegral.Partition.Additive import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import analysis.box_integral.partition.measure from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" open Set noncomputable section open scoped ENNReal Classical BoxIntegral variable {ι : Type*} namespace BoxIntegral open MeasureTheory namespace Box variable (I : Box ι) theorem measure_Icc_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ (Box.Icc I) < ∞ := show μ (Icc I.lower I.upper) < ∞ from I.isCompact_Icc.measure_lt_top #align box_integral.box.measure_Icc_lt_top BoxIntegral.Box.measure_Icc_lt_top theorem measure_coe_lt_top (μ : Measure (ι → ℝ)) [IsLocallyFiniteMeasure μ] : μ I < ∞ := (measure_mono <| coe_subset_Icc).trans_lt (I.measure_Icc_lt_top μ) #align box_integral.box.measure_coe_lt_top BoxIntegral.Box.measure_coe_lt_top variable [Fintype ι]
Mathlib/Analysis/BoxIntegral/Partition/Measure.lean
74
76
theorem coe_ae_eq_Icc : (I : Set (ι → ℝ)) =ᵐ[volume] Box.Icc I := by
rw [coe_eq_pi] exact Measure.univ_pi_Ioc_ae_eq_Icc
import Mathlib.Algebra.CharP.Invertible import Mathlib.Algebra.Order.Invertible import Mathlib.Algebra.Order.Module.OrderedSMul import Mathlib.Algebra.Order.Group.Instances import Mathlib.LinearAlgebra.AffineSpace.Slope import Mathlib.LinearAlgebra.AffineSpace.Midpoint import Mathlib.Tactic.FieldSimp #align_import linear_algebra.affine_space.ordered from "leanprover-community/mathlib"@"78261225eb5cedc61c5c74ecb44e5b385d13b733" open AffineMap variable {k E PE : Type*} section OrderedRing variable [OrderedRing k] [OrderedAddCommGroup E] [Module k E] [OrderedSMul k E] variable {a a' b b' : E} {r r' : k} theorem lineMap_mono_left (ha : a ≤ a') (hr : r ≤ 1) : lineMap a b r ≤ lineMap a' b r := by simp only [lineMap_apply_module] exact add_le_add_right (smul_le_smul_of_nonneg_left ha (sub_nonneg.2 hr)) _ #align line_map_mono_left lineMap_mono_left
Mathlib/LinearAlgebra/AffineSpace/Ordered.lean
57
59
theorem lineMap_strict_mono_left (ha : a < a') (hr : r < 1) : lineMap a b r < lineMap a' b r := by
simp only [lineMap_apply_module] exact add_lt_add_right (smul_lt_smul_of_pos_left ha (sub_pos.2 hr)) _
import Mathlib.Analysis.Convex.Side import Mathlib.Geometry.Euclidean.Angle.Oriented.Rotation import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine #align_import geometry.euclidean.angle.oriented.affine from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open FiniteDimensional Complex open scoped Affine EuclideanGeometry Real RealInnerProductSpace ComplexConjugate namespace EuclideanGeometry variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P] [NormedAddTorsor V P] [hd2 : Fact (finrank ℝ V = 2)] [Module.Oriented ℝ V (Fin 2)] abbrev o := @Module.Oriented.positiveOrientation def oangle (p₁ p₂ p₃ : P) : Real.Angle := o.oangle (p₁ -ᵥ p₂) (p₃ -ᵥ p₂) #align euclidean_geometry.oangle EuclideanGeometry.oangle @[inherit_doc] scoped notation "∡" => EuclideanGeometry.oangle theorem continuousAt_oangle {x : P × P × P} (hx12 : x.1 ≠ x.2.1) (hx32 : x.2.2 ≠ x.2.1) : ContinuousAt (fun y : P × P × P => ∡ y.1 y.2.1 y.2.2) x := by let f : P × P × P → V × V := fun y => (y.1 -ᵥ y.2.1, y.2.2 -ᵥ y.2.1) have hf1 : (f x).1 ≠ 0 := by simp [hx12] have hf2 : (f x).2 ≠ 0 := by simp [hx32] exact (o.continuousAt_oangle hf1 hf2).comp ((continuous_fst.vsub continuous_snd.fst).prod_mk (continuous_snd.snd.vsub continuous_snd.fst)).continuousAt #align euclidean_geometry.continuous_at_oangle EuclideanGeometry.continuousAt_oangle @[simp] theorem oangle_self_left (p₁ p₂ : P) : ∡ p₁ p₁ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_left EuclideanGeometry.oangle_self_left @[simp] theorem oangle_self_right (p₁ p₂ : P) : ∡ p₁ p₂ p₂ = 0 := by simp [oangle] #align euclidean_geometry.oangle_self_right EuclideanGeometry.oangle_self_right @[simp] theorem oangle_self_left_right (p₁ p₂ : P) : ∡ p₁ p₂ p₁ = 0 := o.oangle_self _ #align euclidean_geometry.oangle_self_left_right EuclideanGeometry.oangle_self_left_right theorem left_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.left_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.left_ne_of_oangle_ne_zero EuclideanGeometry.left_ne_of_oangle_ne_zero theorem right_ne_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₃ ≠ p₂ := by rw [← @vsub_ne_zero V]; exact o.right_ne_zero_of_oangle_ne_zero h #align euclidean_geometry.right_ne_of_oangle_ne_zero EuclideanGeometry.right_ne_of_oangle_ne_zero theorem left_ne_right_of_oangle_ne_zero {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ ≠ 0) : p₁ ≠ p₃ := by rw [← (vsub_left_injective p₂).ne_iff]; exact o.ne_of_oangle_ne_zero h #align euclidean_geometry.left_ne_right_of_oangle_ne_zero EuclideanGeometry.left_ne_right_of_oangle_ne_zero theorem left_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi EuclideanGeometry.left_ne_of_oangle_eq_pi theorem right_ne_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi EuclideanGeometry.right_ne_of_oangle_eq_pi theorem left_ne_right_of_oangle_eq_pi {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = π) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi EuclideanGeometry.left_ne_right_of_oangle_eq_pi theorem left_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_pi_div_two theorem right_ne_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_pi_div_two theorem left_ne_right_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_pi_div_two theorem left_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_of_oangle_eq_neg_pi_div_two theorem right_ne_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.right_ne_of_oangle_eq_neg_pi_div_two EuclideanGeometry.right_ne_of_oangle_eq_neg_pi_div_two theorem left_ne_right_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = (-π / 2 : ℝ)) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : ∡ p₁ p₂ p₃ ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_eq_neg_pi_div_two EuclideanGeometry.left_ne_right_of_oangle_eq_neg_pi_div_two theorem left_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₂ := left_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_of_oangle_sign_ne_zero theorem right_ne_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₃ ≠ p₂ := right_ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.right_ne_of_oangle_sign_ne_zero EuclideanGeometry.right_ne_of_oangle_sign_ne_zero theorem left_ne_right_of_oangle_sign_ne_zero {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign ≠ 0) : p₁ ≠ p₃ := left_ne_right_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align euclidean_geometry.left_ne_right_of_oangle_sign_ne_zero EuclideanGeometry.left_ne_right_of_oangle_sign_ne_zero theorem left_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_one EuclideanGeometry.left_ne_of_oangle_sign_eq_one theorem right_ne_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_one EuclideanGeometry.right_ne_of_oangle_sign_eq_one theorem left_ne_right_of_oangle_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_one theorem left_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₂ := left_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_of_oangle_sign_eq_neg_one theorem right_ne_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₃ ≠ p₂ := right_ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.right_ne_of_oangle_sign_eq_neg_one EuclideanGeometry.right_ne_of_oangle_sign_eq_neg_one theorem left_ne_right_of_oangle_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : p₁ ≠ p₃ := left_ne_right_of_oangle_sign_ne_zero (h.symm ▸ by decide : (∡ p₁ p₂ p₃).sign ≠ 0) #align euclidean_geometry.left_ne_right_of_oangle_sign_eq_neg_one EuclideanGeometry.left_ne_right_of_oangle_sign_eq_neg_one theorem oangle_rev (p₁ p₂ p₃ : P) : ∡ p₃ p₂ p₁ = -∡ p₁ p₂ p₃ := o.oangle_rev _ _ #align euclidean_geometry.oangle_rev EuclideanGeometry.oangle_rev @[simp] theorem oangle_add_oangle_rev (p₁ p₂ p₃ : P) : ∡ p₁ p₂ p₃ + ∡ p₃ p₂ p₁ = 0 := o.oangle_add_oangle_rev _ _ #align euclidean_geometry.oangle_add_oangle_rev EuclideanGeometry.oangle_add_oangle_rev theorem oangle_eq_zero_iff_oangle_rev_eq_zero {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ↔ ∡ p₃ p₂ p₁ = 0 := o.oangle_eq_zero_iff_oangle_rev_eq_zero #align euclidean_geometry.oangle_eq_zero_iff_oangle_rev_eq_zero EuclideanGeometry.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_pi_iff_oangle_rev_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∡ p₃ p₂ p₁ = π := o.oangle_eq_pi_iff_oangle_rev_eq_pi #align euclidean_geometry.oangle_eq_pi_iff_oangle_rev_eq_pi EuclideanGeometry.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_ne_zero_and_ne_pi_iff_affineIndependent {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ ≠ 0 ∧ ∡ p₁ p₂ p₃ ≠ π ↔ AffineIndependent ℝ ![p₁, p₂, p₃] := by rw [oangle, o.oangle_ne_zero_and_ne_pi_iff_linearIndependent, affineIndependent_iff_linearIndependent_vsub ℝ _ (1 : Fin 3), ← linearIndependent_equiv (finSuccAboveEquiv (1 : Fin 3)).toEquiv] convert Iff.rfl ext i fin_cases i <;> rfl #align euclidean_geometry.oangle_ne_zero_and_ne_pi_iff_affine_independent EuclideanGeometry.oangle_ne_zero_and_ne_pi_iff_affineIndependent theorem oangle_eq_zero_or_eq_pi_iff_collinear {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = 0 ∨ ∡ p₁ p₂ p₃ = π ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [← not_iff_not, not_or, oangle_ne_zero_and_ne_pi_iff_affineIndependent, affineIndependent_iff_not_collinear_set] #align euclidean_geometry.oangle_eq_zero_or_eq_pi_iff_collinear EuclideanGeometry.oangle_eq_zero_or_eq_pi_iff_collinear theorem oangle_sign_eq_zero_iff_collinear {p₁ p₂ p₃ : P} : (∡ p₁ p₂ p₃).sign = 0 ↔ Collinear ℝ ({p₁, p₂, p₃} : Set P) := by rw [Real.Angle.sign_eq_zero_iff, oangle_eq_zero_or_eq_pi_iff_collinear] theorem affineIndependent_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : AffineIndependent ℝ ![p₁, p₂, p₃] ↔ AffineIndependent ℝ ![p₄, p₅, p₆] := by simp_rw [← oangle_ne_zero_and_ne_pi_iff_affineIndependent, ← Real.Angle.two_zsmul_ne_zero_iff, h] #align euclidean_geometry.affine_independent_iff_of_two_zsmul_oangle_eq EuclideanGeometry.affineIndependent_iff_of_two_zsmul_oangle_eq theorem collinear_iff_of_two_zsmul_oangle_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆) : Collinear ℝ ({p₁, p₂, p₃} : Set P) ↔ Collinear ℝ ({p₄, p₅, p₆} : Set P) := by simp_rw [← oangle_eq_zero_or_eq_pi_iff_collinear, ← Real.Angle.two_zsmul_eq_zero_iff, h] #align euclidean_geometry.collinear_iff_of_two_zsmul_oangle_eq EuclideanGeometry.collinear_iff_of_two_zsmul_oangle_eq theorem two_zsmul_oangle_of_vectorSpan_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h₁₂₄₅ : vectorSpan ℝ ({p₁, p₂} : Set P) = vectorSpan ℝ ({p₄, p₅} : Set P)) (h₃₂₆₅ : vectorSpan ℝ ({p₃, p₂} : Set P) = vectorSpan ℝ ({p₆, p₅} : Set P)) : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by simp_rw [vectorSpan_pair] at h₁₂₄₅ h₃₂₆₅ exact o.two_zsmul_oangle_of_span_eq_of_span_eq h₁₂₄₅ h₃₂₆₅ #align euclidean_geometry.two_zsmul_oangle_of_vector_span_eq EuclideanGeometry.two_zsmul_oangle_of_vectorSpan_eq theorem two_zsmul_oangle_of_parallel {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h₁₂₄₅ : line[ℝ, p₁, p₂] ∥ line[ℝ, p₄, p₅]) (h₃₂₆₅ : line[ℝ, p₃, p₂] ∥ line[ℝ, p₆, p₅]) : (2 : ℤ) • ∡ p₁ p₂ p₃ = (2 : ℤ) • ∡ p₄ p₅ p₆ := by rw [AffineSubspace.affineSpan_pair_parallel_iff_vectorSpan_eq] at h₁₂₄₅ h₃₂₆₅ exact two_zsmul_oangle_of_vectorSpan_eq h₁₂₄₅ h₃₂₆₅ #align euclidean_geometry.two_zsmul_oangle_of_parallel EuclideanGeometry.two_zsmul_oangle_of_parallel @[simp] theorem oangle_add {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₂ + ∡ p₂ p p₃ = ∡ p₁ p p₃ := o.oangle_add (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add EuclideanGeometry.oangle_add @[simp] theorem oangle_add_swap {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₂ p p₃ + ∡ p₁ p p₂ = ∡ p₁ p p₃ := o.oangle_add_swap (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add_swap EuclideanGeometry.oangle_add_swap @[simp] theorem oangle_sub_left {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₃ - ∡ p₁ p p₂ = ∡ p₂ p p₃ := o.oangle_sub_left (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_sub_left EuclideanGeometry.oangle_sub_left @[simp] theorem oangle_sub_right {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₃ - ∡ p₂ p p₃ = ∡ p₁ p p₂ := o.oangle_sub_right (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_sub_right EuclideanGeometry.oangle_sub_right @[simp] theorem oangle_add_cyc3 {p p₁ p₂ p₃ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) (hp₃ : p₃ ≠ p) : ∡ p₁ p p₂ + ∡ p₂ p p₃ + ∡ p₃ p p₁ = 0 := o.oangle_add_cyc3 (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) (vsub_ne_zero.2 hp₃) #align euclidean_geometry.oangle_add_cyc3 EuclideanGeometry.oangle_add_cyc3 theorem oangle_eq_oangle_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₁ p₂ p₃ = ∡ p₂ p₃ p₁ := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁, ← vsub_sub_vsub_cancel_left p₂ p₃ p₁, o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h] #align euclidean_geometry.oangle_eq_oangle_of_dist_eq EuclideanGeometry.oangle_eq_oangle_of_dist_eq theorem oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq {p₁ p₂ p₃ : P} (hn : p₂ ≠ p₃) (h : dist p₁ p₂ = dist p₁ p₃) : ∡ p₃ p₁ p₂ = π - (2 : ℤ) • ∡ p₁ p₂ p₃ := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, oangle] convert o.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq _ h using 1 · rw [← neg_vsub_eq_vsub_rev p₁ p₃, ← neg_vsub_eq_vsub_rev p₁ p₂, o.oangle_neg_neg] · rw [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h]; simp · simpa using hn #align euclidean_geometry.oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq EuclideanGeometry.oangle_eq_pi_sub_two_zsmul_oangle_of_dist_eq theorem abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₁ p₂ p₃).toReal| < π / 2 := by simp_rw [dist_eq_norm_vsub V] at h rw [oangle, ← vsub_sub_vsub_cancel_left p₃ p₂ p₁] exact o.abs_oangle_sub_right_toReal_lt_pi_div_two h #align euclidean_geometry.abs_oangle_right_to_real_lt_pi_div_two_of_dist_eq EuclideanGeometry.abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq theorem abs_oangle_left_toReal_lt_pi_div_two_of_dist_eq {p₁ p₂ p₃ : P} (h : dist p₁ p₂ = dist p₁ p₃) : |(∡ p₂ p₃ p₁).toReal| < π / 2 := oangle_eq_oangle_of_dist_eq h ▸ abs_oangle_right_toReal_lt_pi_div_two_of_dist_eq h #align euclidean_geometry.abs_oangle_left_to_real_lt_pi_div_two_of_dist_eq EuclideanGeometry.abs_oangle_left_toReal_lt_pi_div_two_of_dist_eq theorem cos_oangle_eq_cos_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : Real.Angle.cos (∡ p₁ p p₂) = Real.cos (∠ p₁ p p₂) := o.cos_oangle_eq_cos_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.cos_oangle_eq_cos_angle EuclideanGeometry.cos_oangle_eq_cos_angle theorem oangle_eq_angle_or_eq_neg_angle {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∡ p₁ p p₂ = ∠ p₁ p p₂ ∨ ∡ p₁ p p₂ = -∠ p₁ p p₂ := o.oangle_eq_angle_or_eq_neg_angle (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.oangle_eq_angle_or_eq_neg_angle EuclideanGeometry.oangle_eq_angle_or_eq_neg_angle theorem angle_eq_abs_oangle_toReal {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∠ p₁ p p₂ = |(∡ p₁ p p₂).toReal| := o.angle_eq_abs_oangle_toReal (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.angle_eq_abs_oangle_to_real EuclideanGeometry.angle_eq_abs_oangle_toReal theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {p p₁ p₂ : P} (h : (∡ p₁ p p₂).sign = 0) : p₁ = p ∨ p₂ = p ∨ ∠ p₁ p p₂ = 0 ∨ ∠ p₁ p p₂ = π := by convert o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero h <;> simp #align euclidean_geometry.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero EuclideanGeometry.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero theorem oangle_eq_of_angle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (h : ∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆) (hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) : ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ := o.oangle_eq_of_angle_eq_of_sign_eq h hs #align euclidean_geometry.oangle_eq_of_angle_eq_of_sign_eq EuclideanGeometry.oangle_eq_of_angle_eq_of_sign_eq theorem angle_eq_iff_oangle_eq_of_sign_eq {p₁ p₂ p₃ p₄ p₅ p₆ : P} (hp₁ : p₁ ≠ p₂) (hp₃ : p₃ ≠ p₂) (hp₄ : p₄ ≠ p₅) (hp₆ : p₆ ≠ p₅) (hs : (∡ p₁ p₂ p₃).sign = (∡ p₄ p₅ p₆).sign) : ∠ p₁ p₂ p₃ = ∠ p₄ p₅ p₆ ↔ ∡ p₁ p₂ p₃ = ∡ p₄ p₅ p₆ := o.angle_eq_iff_oangle_eq_of_sign_eq (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₃) (vsub_ne_zero.2 hp₄) (vsub_ne_zero.2 hp₆) hs #align euclidean_geometry.angle_eq_iff_oangle_eq_of_sign_eq EuclideanGeometry.angle_eq_iff_oangle_eq_of_sign_eq theorem oangle_eq_angle_of_sign_eq_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = 1) : ∡ p₁ p₂ p₃ = ∠ p₁ p₂ p₃ := o.oangle_eq_angle_of_sign_eq_one h #align euclidean_geometry.oangle_eq_angle_of_sign_eq_one EuclideanGeometry.oangle_eq_angle_of_sign_eq_one theorem oangle_eq_neg_angle_of_sign_eq_neg_one {p₁ p₂ p₃ : P} (h : (∡ p₁ p₂ p₃).sign = -1) : ∡ p₁ p₂ p₃ = -∠ p₁ p₂ p₃ := o.oangle_eq_neg_angle_of_sign_eq_neg_one h #align euclidean_geometry.oangle_eq_neg_angle_of_sign_eq_neg_one EuclideanGeometry.oangle_eq_neg_angle_of_sign_eq_neg_one theorem oangle_eq_zero_iff_angle_eq_zero {p p₁ p₂ : P} (hp₁ : p₁ ≠ p) (hp₂ : p₂ ≠ p) : ∡ p₁ p p₂ = 0 ↔ ∠ p₁ p p₂ = 0 := o.oangle_eq_zero_iff_angle_eq_zero (vsub_ne_zero.2 hp₁) (vsub_ne_zero.2 hp₂) #align euclidean_geometry.oangle_eq_zero_iff_angle_eq_zero EuclideanGeometry.oangle_eq_zero_iff_angle_eq_zero theorem oangle_eq_pi_iff_angle_eq_pi {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ ∠ p₁ p₂ p₃ = π := o.oangle_eq_pi_iff_angle_eq_pi #align euclidean_geometry.oangle_eq_pi_iff_angle_eq_pi EuclideanGeometry.oangle_eq_pi_iff_angle_eq_pi theorem angle_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : ∠ p₁ p₂ p₃ = π / 2 := by rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two] exact o.inner_eq_zero_of_oangle_eq_pi_div_two h #align euclidean_geometry.angle_eq_pi_div_two_of_oangle_eq_pi_div_two EuclideanGeometry.angle_eq_pi_div_two_of_oangle_eq_pi_div_two theorem angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(π / 2)) : ∠ p₃ p₂ p₁ = π / 2 := by rw [angle_comm] exact angle_eq_pi_div_two_of_oangle_eq_pi_div_two h #align euclidean_geometry.angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two EuclideanGeometry.angle_rev_eq_pi_div_two_of_oangle_eq_pi_div_two theorem angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₁ p₂ p₃ = π / 2 := by rw [angle, ← InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two] exact o.inner_eq_zero_of_oangle_eq_neg_pi_div_two h #align euclidean_geometry.angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two EuclideanGeometry.angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two theorem angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two {p₁ p₂ p₃ : P} (h : ∡ p₁ p₂ p₃ = ↑(-π / 2)) : ∠ p₃ p₂ p₁ = π / 2 := by rw [angle_comm] exact angle_eq_pi_div_two_of_oangle_eq_neg_pi_div_two h #align euclidean_geometry.angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two EuclideanGeometry.angle_rev_eq_pi_div_two_of_oangle_eq_neg_pi_div_two theorem oangle_swap₁₂_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₂ p₁ p₃).sign := by rw [eq_comm, oangle, oangle, ← o.oangle_neg_neg, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev, ← vsub_sub_vsub_cancel_left p₁ p₃ p₂, ← neg_vsub_eq_vsub_rev p₃ p₂, sub_eq_add_neg, neg_vsub_eq_vsub_rev p₂ p₁, add_comm, ← @neg_one_smul ℝ] nth_rw 2 [← one_smul ℝ (p₁ -ᵥ p₂)] rw [o.oangle_sign_smul_add_smul_right] simp #align euclidean_geometry.oangle_swap₁₂_sign EuclideanGeometry.oangle_swap₁₂_sign theorem oangle_swap₁₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₃ p₂ p₁).sign := by rw [oangle_rev, Real.Angle.sign_neg, neg_neg] #align euclidean_geometry.oangle_swap₁₃_sign EuclideanGeometry.oangle_swap₁₃_sign
Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean
465
466
theorem oangle_swap₂₃_sign (p₁ p₂ p₃ : P) : -(∡ p₁ p₂ p₃).sign = (∡ p₁ p₃ p₂).sign := by
rw [oangle_swap₁₃_sign, ← oangle_swap₁₂_sign, oangle_swap₁₃_sign]
import Mathlib.Algebra.Category.GroupCat.Abelian import Mathlib.CategoryTheory.Limits.Shapes.Images #align_import algebra.category.Group.images from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" open CategoryTheory open CategoryTheory.Limits universe u namespace AddCommGroupCat set_option linter.uppercaseLean3 false -- Note that because `injective_of_mono` is currently only proved in `Type 0`, -- we restrict to the lowest universe here for now. variable {G H : AddCommGroupCat.{0}} (f : G ⟶ H) attribute [local ext] Subtype.ext_val section -- implementation details of `IsImage` for `AddCommGroupCat`; use the API, not these def image : AddCommGroupCat := AddCommGroupCat.of (AddMonoidHom.range f) #align AddCommGroup.image AddCommGroupCat.image def image.ι : image f ⟶ H := f.range.subtype #align AddCommGroup.image.ι AddCommGroupCat.image.ι instance : Mono (image.ι f) := ConcreteCategory.mono_of_injective (image.ι f) Subtype.val_injective def factorThruImage : G ⟶ image f := f.rangeRestrict #align AddCommGroup.factor_thru_image AddCommGroupCat.factorThruImage theorem image.fac : factorThruImage f ≫ image.ι f = f := by ext rfl #align AddCommGroup.image.fac AddCommGroupCat.image.fac attribute [local simp] image.fac variable {f} noncomputable def image.lift (F' : MonoFactorisation f) : image f ⟶ F'.I where toFun := (fun x => F'.e (Classical.indefiniteDescription _ x.2).1 : image f → F'.I) map_zero' := by haveI := F'.m_mono apply injective_of_mono F'.m change (F'.e ≫ F'.m) _ = _ rw [F'.fac, AddMonoidHom.map_zero] exact (Classical.indefiniteDescription (fun y => f y = 0) _).2 map_add' := by intro x y haveI := F'.m_mono apply injective_of_mono F'.m rw [AddMonoidHom.map_add] change (F'.e ≫ F'.m) _ = (F'.e ≫ F'.m) _ + (F'.e ≫ F'.m) _ rw [F'.fac] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rw [(Classical.indefiniteDescription (fun z => f z = _) _).2] rfl #align AddCommGroup.image.lift AddCommGroupCat.image.lift
Mathlib/Algebra/Category/GroupCat/Images.lean
87
91
theorem image.lift_fac (F' : MonoFactorisation f) : image.lift F' ≫ F'.m = image.ι f := by
ext x change (F'.e ≫ F'.m) _ = _ rw [F'.fac, (Classical.indefiniteDescription _ x.2).2] rfl
import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.GCD.BigOperators import Mathlib.Data.Nat.PrimeFin import Mathlib.NumberTheory.Padics.PadicVal import Mathlib.Order.Interval.Finset.Nat #align_import data.nat.factorization.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" -- Workaround for lean4#2038 attribute [-instance] instBEqNat open Nat Finset List Finsupp namespace Nat variable {a b m n p : ℕ} def factorization (n : ℕ) : ℕ →₀ ℕ where support := n.primeFactors toFun p := if p.Prime then padicValNat p n else 0 mem_support_toFun := by simp [not_or]; aesop #align nat.factorization Nat.factorization @[simp] lemma support_factorization (n : ℕ) : (factorization n).support = n.primeFactors := rfl theorem factorization_def (n : ℕ) {p : ℕ} (pp : p.Prime) : n.factorization p = padicValNat p n := by simpa [factorization] using absurd pp #align nat.factorization_def Nat.factorization_def @[simp] theorem factors_count_eq {n p : ℕ} : n.factors.count p = n.factorization p := by rcases n.eq_zero_or_pos with (rfl | hn0) · simp [factorization, count] if pp : p.Prime then ?_ else rw [count_eq_zero_of_not_mem (mt prime_of_mem_factors pp)] simp [factorization, pp] simp only [factorization_def _ pp] apply _root_.le_antisymm · rw [le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] exact List.le_count_iff_replicate_sublist.mp le_rfl |>.subperm · rw [← lt_add_one_iff, lt_iff_not_ge, ge_iff_le, le_padicValNat_iff_replicate_subperm_factors pp hn0.ne'] intro h have := h.count_le p simp at this #align nat.factors_count_eq Nat.factors_count_eq theorem factorization_eq_factors_multiset (n : ℕ) : n.factorization = Multiset.toFinsupp (n.factors : Multiset ℕ) := by ext p simp #align nat.factorization_eq_factors_multiset Nat.factorization_eq_factors_multiset theorem multiplicity_eq_factorization {n p : ℕ} (pp : p.Prime) (hn : n ≠ 0) : multiplicity p n = n.factorization p := by simp [factorization, pp, padicValNat_def' pp.ne_one hn.bot_lt] #align nat.multiplicity_eq_factorization Nat.multiplicity_eq_factorization @[simp] theorem factorization_prod_pow_eq_self {n : ℕ} (hn : n ≠ 0) : n.factorization.prod (· ^ ·) = n := by rw [factorization_eq_factors_multiset n] simp only [← prod_toMultiset, factorization, Multiset.prod_coe, Multiset.toFinsupp_toMultiset] exact prod_factors hn #align nat.factorization_prod_pow_eq_self Nat.factorization_prod_pow_eq_self theorem eq_of_factorization_eq {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) (h : ∀ p : ℕ, a.factorization p = b.factorization p) : a = b := eq_of_perm_factors ha hb (by simpa only [List.perm_iff_count, factors_count_eq] using h) #align nat.eq_of_factorization_eq Nat.eq_of_factorization_eq theorem factorization_inj : Set.InjOn factorization { x : ℕ | x ≠ 0 } := fun a ha b hb h => eq_of_factorization_eq ha hb fun p => by simp [h] #align nat.factorization_inj Nat.factorization_inj @[simp] theorem factorization_zero : factorization 0 = 0 := by ext; simp [factorization] #align nat.factorization_zero Nat.factorization_zero @[simp] theorem factorization_one : factorization 1 = 0 := by ext; simp [factorization] #align nat.factorization_one Nat.factorization_one #noalign nat.support_factorization #align nat.factor_iff_mem_factorization Nat.mem_primeFactors_iff_mem_factors #align nat.prime_of_mem_factorization Nat.prime_of_mem_primeFactors #align nat.pos_of_mem_factorization Nat.pos_of_mem_primeFactors #align nat.le_of_mem_factorization Nat.le_of_mem_primeFactors theorem factorization_eq_zero_iff (n p : ℕ) : n.factorization p = 0 ↔ ¬p.Prime ∨ ¬p ∣ n ∨ n = 0 := by simp_rw [← not_mem_support_iff, support_factorization, mem_primeFactors, not_and_or, not_ne_iff] #align nat.factorization_eq_zero_iff Nat.factorization_eq_zero_iff @[simp] theorem factorization_eq_zero_of_non_prime (n : ℕ) {p : ℕ} (hp : ¬p.Prime) : n.factorization p = 0 := by simp [factorization_eq_zero_iff, hp] #align nat.factorization_eq_zero_of_non_prime Nat.factorization_eq_zero_of_non_prime theorem factorization_eq_zero_of_not_dvd {n p : ℕ} (h : ¬p ∣ n) : n.factorization p = 0 := by simp [factorization_eq_zero_iff, h] #align nat.factorization_eq_zero_of_not_dvd Nat.factorization_eq_zero_of_not_dvd theorem factorization_eq_zero_of_lt {n p : ℕ} (h : n < p) : n.factorization p = 0 := Finsupp.not_mem_support_iff.mp (mt le_of_mem_primeFactors (not_le_of_lt h)) #align nat.factorization_eq_zero_of_lt Nat.factorization_eq_zero_of_lt @[simp] theorem factorization_zero_right (n : ℕ) : n.factorization 0 = 0 := factorization_eq_zero_of_non_prime _ not_prime_zero #align nat.factorization_zero_right Nat.factorization_zero_right @[simp] theorem factorization_one_right (n : ℕ) : n.factorization 1 = 0 := factorization_eq_zero_of_non_prime _ not_prime_one #align nat.factorization_one_right Nat.factorization_one_right theorem dvd_of_factorization_pos {n p : ℕ} (hn : n.factorization p ≠ 0) : p ∣ n := dvd_of_mem_factors <| mem_primeFactors_iff_mem_factors.1 <| mem_support_iff.2 hn #align nat.dvd_of_factorization_pos Nat.dvd_of_factorization_pos theorem Prime.factorization_pos_of_dvd {n p : ℕ} (hp : p.Prime) (hn : n ≠ 0) (h : p ∣ n) : 0 < n.factorization p := by rwa [← factors_count_eq, count_pos_iff_mem, mem_factors_iff_dvd hn hp] #align nat.prime.factorization_pos_of_dvd Nat.Prime.factorization_pos_of_dvd theorem factorization_eq_zero_of_remainder {p r : ℕ} (i : ℕ) (hr : ¬p ∣ r) : (p * i + r).factorization p = 0 := by apply factorization_eq_zero_of_not_dvd rwa [← Nat.dvd_add_iff_right (Dvd.intro i rfl)] #align nat.factorization_eq_zero_of_remainder Nat.factorization_eq_zero_of_remainder theorem factorization_eq_zero_iff_remainder {p r : ℕ} (i : ℕ) (pp : p.Prime) (hr0 : r ≠ 0) : ¬p ∣ r ↔ (p * i + r).factorization p = 0 := by refine ⟨factorization_eq_zero_of_remainder i, fun h => ?_⟩ rw [factorization_eq_zero_iff] at h contrapose! h refine ⟨pp, ?_, ?_⟩ · rwa [← Nat.dvd_add_iff_right (dvd_mul_right p i)] · contrapose! hr0 exact (add_eq_zero_iff.mp hr0).2 #align nat.factorization_eq_zero_iff_remainder Nat.factorization_eq_zero_iff_remainder theorem factorization_eq_zero_iff' (n : ℕ) : n.factorization = 0 ↔ n = 0 ∨ n = 1 := by rw [factorization_eq_factors_multiset n] simp [factorization, AddEquiv.map_eq_zero_iff, Multiset.coe_eq_zero] #align nat.factorization_eq_zero_iff' Nat.factorization_eq_zero_iff' @[simp] theorem factorization_mul {a b : ℕ} (ha : a ≠ 0) (hb : b ≠ 0) : (a * b).factorization = a.factorization + b.factorization := by ext p simp only [add_apply, ← factors_count_eq, perm_iff_count.mp (perm_factors_mul ha hb) p, count_append] #align nat.factorization_mul Nat.factorization_mul #align nat.factorization_mul_support Nat.primeFactors_mul lemma prod_factorization_eq_prod_primeFactors {β : Type*} [CommMonoid β] (f : ℕ → ℕ → β) : n.factorization.prod f = ∏ p ∈ n.primeFactors, f p (n.factorization p) := rfl #align nat.prod_factorization_eq_prod_factors Nat.prod_factorization_eq_prod_primeFactors lemma prod_primeFactors_prod_factorization {β : Type*} [CommMonoid β] (f : ℕ → β) : ∏ p ∈ n.primeFactors, f p = n.factorization.prod (fun p _ ↦ f p) := rfl theorem factorization_prod {α : Type*} {S : Finset α} {g : α → ℕ} (hS : ∀ x ∈ S, g x ≠ 0) : (S.prod g).factorization = S.sum fun x => (g x).factorization := by classical ext p refine Finset.induction_on' S ?_ ?_ · simp · intro x T hxS hTS hxT IH have hT : T.prod g ≠ 0 := prod_ne_zero_iff.mpr fun x hx => hS x (hTS hx) simp [prod_insert hxT, sum_insert hxT, ← IH, factorization_mul (hS x hxS) hT] #align nat.factorization_prod Nat.factorization_prod @[simp] theorem factorization_pow (n k : ℕ) : factorization (n ^ k) = k • n.factorization := by induction' k with k ih; · simp rcases eq_or_ne n 0 with (rfl | hn) · simp rw [Nat.pow_succ, mul_comm, factorization_mul hn (pow_ne_zero _ hn), ih, add_smul, one_smul, add_comm] #align nat.factorization_pow Nat.factorization_pow @[simp] protected theorem Prime.factorization {p : ℕ} (hp : Prime p) : p.factorization = single p 1 := by ext q rw [← factors_count_eq, factors_prime hp, single_apply, count_singleton', if_congr eq_comm] <;> rfl #align nat.prime.factorization Nat.Prime.factorization @[simp] theorem Prime.factorization_self {p : ℕ} (hp : Prime p) : p.factorization p = 1 := by simp [hp] #align nat.prime.factorization_self Nat.Prime.factorization_self theorem Prime.factorization_pow {p k : ℕ} (hp : Prime p) : (p ^ k).factorization = single p k := by simp [hp] #align nat.prime.factorization_pow Nat.Prime.factorization_pow theorem eq_pow_of_factorization_eq_single {n p k : ℕ} (hn : n ≠ 0) (h : n.factorization = Finsupp.single p k) : n = p ^ k := by -- Porting note: explicitly added `Finsupp.prod_single_index` rw [← Nat.factorization_prod_pow_eq_self hn, h, Finsupp.prod_single_index] simp #align nat.eq_pow_of_factorization_eq_single Nat.eq_pow_of_factorization_eq_single theorem Prime.eq_of_factorization_pos {p q : ℕ} (hp : Prime p) (h : p.factorization q ≠ 0) : p = q := by simpa [hp.factorization, single_apply] using h #align nat.prime.eq_of_factorization_pos Nat.Prime.eq_of_factorization_pos
Mathlib/Data/Nat/Factorization/Basic.lean
279
287
theorem prod_pow_factorization_eq_self {f : ℕ →₀ ℕ} (hf : ∀ p : ℕ, p ∈ f.support → Prime p) : (f.prod (· ^ ·)).factorization = f := by
have h : ∀ x : ℕ, x ∈ f.support → x ^ f x ≠ 0 := fun p hp => pow_ne_zero _ (Prime.ne_zero (hf p hp)) simp only [Finsupp.prod, factorization_prod h] conv => rhs rw [(sum_single f).symm] exact sum_congr rfl fun p hp => Prime.factorization_pow (hf p hp)
import Mathlib.Topology.ContinuousOn import Mathlib.Order.Filter.SmallSets #align_import topology.locally_finite from "leanprover-community/mathlib"@"55d771df074d0dd020139ee1cd4b95521422df9f" -- locally finite family [General Topology (Bourbaki, 1995)] open Set Function Filter Topology variable {ι ι' α X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] {f g : ι → Set X} def LocallyFinite (f : ι → Set X) := ∀ x : X, ∃ t ∈ 𝓝 x, { i | (f i ∩ t).Nonempty }.Finite #align locally_finite LocallyFinite theorem locallyFinite_of_finite [Finite ι] (f : ι → Set X) : LocallyFinite f := fun _ => ⟨univ, univ_mem, toFinite _⟩ #align locally_finite_of_finite locallyFinite_of_finite namespace LocallyFinite theorem point_finite (hf : LocallyFinite f) (x : X) : { b | x ∈ f b }.Finite := let ⟨_t, hxt, ht⟩ := hf x ht.subset fun _b hb => ⟨x, hb, mem_of_mem_nhds hxt⟩ #align locally_finite.point_finite LocallyFinite.point_finite protected theorem subset (hf : LocallyFinite f) (hg : ∀ i, g i ⊆ f i) : LocallyFinite g := fun a => let ⟨t, ht₁, ht₂⟩ := hf a ⟨t, ht₁, ht₂.subset fun i hi => hi.mono <| inter_subset_inter (hg i) Subset.rfl⟩ #align locally_finite.subset LocallyFinite.subset theorem comp_injOn {g : ι' → ι} (hf : LocallyFinite f) (hg : InjOn g { i | (f (g i)).Nonempty }) : LocallyFinite (f ∘ g) := fun x => by let ⟨t, htx, htf⟩ := hf x refine ⟨t, htx, htf.preimage <| ?_⟩ exact hg.mono fun i (hi : Set.Nonempty _) => hi.left #align locally_finite.comp_inj_on LocallyFinite.comp_injOn theorem comp_injective {g : ι' → ι} (hf : LocallyFinite f) (hg : Injective g) : LocallyFinite (f ∘ g) := hf.comp_injOn hg.injOn #align locally_finite.comp_injective LocallyFinite.comp_injective theorem _root_.locallyFinite_iff_smallSets : LocallyFinite f ↔ ∀ x, ∀ᶠ s in (𝓝 x).smallSets, { i | (f i ∩ s).Nonempty }.Finite := forall_congr' fun _ => Iff.symm <| eventually_smallSets' fun _s _t hst ht => ht.subset fun _i hi => hi.mono <| inter_subset_inter_right _ hst #align locally_finite_iff_small_sets locallyFinite_iff_smallSets protected theorem eventually_smallSets (hf : LocallyFinite f) (x : X) : ∀ᶠ s in (𝓝 x).smallSets, { i | (f i ∩ s).Nonempty }.Finite := locallyFinite_iff_smallSets.mp hf x #align locally_finite.eventually_small_sets LocallyFinite.eventually_smallSets theorem exists_mem_basis {ι' : Sort*} (hf : LocallyFinite f) {p : ι' → Prop} {s : ι' → Set X} {x : X} (hb : (𝓝 x).HasBasis p s) : ∃ i, p i ∧ { j | (f j ∩ s i).Nonempty }.Finite := let ⟨i, hpi, hi⟩ := hb.smallSets.eventually_iff.mp (hf.eventually_smallSets x) ⟨i, hpi, hi Subset.rfl⟩ #align locally_finite.exists_mem_basis LocallyFinite.exists_mem_basis protected theorem nhdsWithin_iUnion (hf : LocallyFinite f) (a : X) : 𝓝[⋃ i, f i] a = ⨆ i, 𝓝[f i] a := by rcases hf a with ⟨U, haU, hfin⟩ refine le_antisymm ?_ (Monotone.le_map_iSup fun _ _ ↦ nhdsWithin_mono _) calc 𝓝[⋃ i, f i] a = 𝓝[⋃ i, f i ∩ U] a := by rw [← iUnion_inter, ← nhdsWithin_inter_of_mem' (nhdsWithin_le_nhds haU)] _ = 𝓝[⋃ i ∈ {j | (f j ∩ U).Nonempty}, (f i ∩ U)] a := by simp only [mem_setOf_eq, iUnion_nonempty_self] _ = ⨆ i ∈ {j | (f j ∩ U).Nonempty}, 𝓝[f i ∩ U] a := nhdsWithin_biUnion hfin _ _ _ ≤ ⨆ i, 𝓝[f i ∩ U] a := iSup₂_le_iSup _ _ _ ≤ ⨆ i, 𝓝[f i] a := iSup_mono fun i ↦ nhdsWithin_mono _ inter_subset_left #align locally_finite.nhds_within_Union LocallyFinite.nhdsWithin_iUnion theorem continuousOn_iUnion' {g : X → Y} (hf : LocallyFinite f) (hc : ∀ i x, x ∈ closure (f i) → ContinuousWithinAt g (f i) x) : ContinuousOn g (⋃ i, f i) := by rintro x - rw [ContinuousWithinAt, hf.nhdsWithin_iUnion, tendsto_iSup] intro i by_cases hx : x ∈ closure (f i) · exact hc i _ hx · rw [mem_closure_iff_nhdsWithin_neBot, not_neBot] at hx rw [hx] exact tendsto_bot #align locally_finite.continuous_on_Union' LocallyFinite.continuousOn_iUnion' theorem continuousOn_iUnion {g : X → Y} (hf : LocallyFinite f) (h_cl : ∀ i, IsClosed (f i)) (h_cont : ∀ i, ContinuousOn g (f i)) : ContinuousOn g (⋃ i, f i) := hf.continuousOn_iUnion' fun i x hx ↦ h_cont i x <| (h_cl i).closure_subset hx #align locally_finite.continuous_on_Union LocallyFinite.continuousOn_iUnion protected theorem continuous' {g : X → Y} (hf : LocallyFinite f) (h_cov : ⋃ i, f i = univ) (hc : ∀ i x, x ∈ closure (f i) → ContinuousWithinAt g (f i) x) : Continuous g := continuous_iff_continuousOn_univ.2 <| h_cov ▸ hf.continuousOn_iUnion' hc #align locally_finite.continuous' LocallyFinite.continuous' protected theorem continuous {g : X → Y} (hf : LocallyFinite f) (h_cov : ⋃ i, f i = univ) (h_cl : ∀ i, IsClosed (f i)) (h_cont : ∀ i, ContinuousOn g (f i)) : Continuous g := continuous_iff_continuousOn_univ.2 <| h_cov ▸ hf.continuousOn_iUnion h_cl h_cont #align locally_finite.continuous LocallyFinite.continuous protected theorem closure (hf : LocallyFinite f) : LocallyFinite fun i => closure (f i) := by intro x rcases hf x with ⟨s, hsx, hsf⟩ refine ⟨interior s, interior_mem_nhds.2 hsx, hsf.subset fun i hi => ?_⟩ exact (hi.mono isOpen_interior.closure_inter).of_closure.mono (inter_subset_inter_right _ interior_subset) #align locally_finite.closure LocallyFinite.closure theorem closure_iUnion (h : LocallyFinite f) : closure (⋃ i, f i) = ⋃ i, closure (f i) := by ext x simp only [mem_closure_iff_nhdsWithin_neBot, h.nhdsWithin_iUnion, iSup_neBot, mem_iUnion] #align locally_finite.closure_Union LocallyFinite.closure_iUnion theorem isClosed_iUnion (hf : LocallyFinite f) (hc : ∀ i, IsClosed (f i)) : IsClosed (⋃ i, f i) := by simp only [← closure_eq_iff_isClosed, hf.closure_iUnion, (hc _).closure_eq] #align locally_finite.is_closed_Union LocallyFinite.isClosed_iUnion theorem iInter_compl_mem_nhds (hf : LocallyFinite f) (hc : ∀ i, IsClosed (f i)) (x : X) : (⋂ (i) (_ : x ∉ f i), (f i)ᶜ) ∈ 𝓝 x := by refine IsOpen.mem_nhds ?_ (mem_iInter₂.2 fun i => id) suffices IsClosed (⋃ i : { i // x ∉ f i }, f i) by rwa [← isOpen_compl_iff, compl_iUnion, iInter_subtype] at this exact (hf.comp_injective Subtype.val_injective).isClosed_iUnion fun i => hc _ #align locally_finite.Inter_compl_mem_nhds LocallyFinite.iInter_compl_mem_nhds
Mathlib/Topology/LocallyFinite.lean
155
170
theorem exists_forall_eventually_eq_prod {π : X → Sort*} {f : ℕ → ∀ x : X, π x} (hf : LocallyFinite fun n => { x | f (n + 1) x ≠ f n x }) : ∃ F : ∀ x : X, π x, ∀ x, ∀ᶠ p : ℕ × X in atTop ×ˢ 𝓝 x, f p.1 p.2 = F p.2 := by
choose U hUx hU using hf choose N hN using fun x => (hU x).bddAbove replace hN : ∀ (x), ∀ n > N x, ∀ y ∈ U x, f (n + 1) y = f n y := fun x n hn y hy => by_contra fun hne => hn.lt.not_le <| hN x ⟨y, hne, hy⟩ replace hN : ∀ (x), ∀ n ≥ N x + 1, ∀ y ∈ U x, f n y = f (N x + 1) y := fun x n hn y hy => Nat.le_induction rfl (fun k hle => (hN x _ hle _ hy).trans) n hn refine ⟨fun x => f (N x + 1) x, fun x => ?_⟩ filter_upwards [Filter.prod_mem_prod (eventually_gt_atTop (N x)) (hUx x)] rintro ⟨n, y⟩ ⟨hn : N x < n, hy : y ∈ U x⟩ calc f n y = f (N x + 1) y := hN _ _ hn _ hy _ = f (max (N x + 1) (N y + 1)) y := (hN _ _ (le_max_left _ _) _ hy).symm _ = f (N y + 1) y := hN _ _ (le_max_right _ _) _ (mem_of_mem_nhds <| hUx y)
import Mathlib.Order.Filter.EventuallyConst import Mathlib.Order.PartialSups import Mathlib.Algebra.Module.Submodule.IterateMapComap import Mathlib.RingTheory.OrzechProperty import Mathlib.RingTheory.Nilpotent.Lemmas #align_import ring_theory.noetherian from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90" open Set Filter Pointwise -- Porting note: should this be renamed to `Noetherian`? class IsNoetherian (R M) [Semiring R] [AddCommMonoid M] [Module R M] : Prop where noetherian : ∀ s : Submodule R M, s.FG #align is_noetherian IsNoetherian attribute [inherit_doc IsNoetherian] IsNoetherian.noetherian section variable {R : Type*} {M : Type*} {P : Type*} variable [Semiring R] [AddCommMonoid M] [AddCommMonoid P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_def : IsNoetherian R M ↔ ∀ s : Submodule R M, s.FG := ⟨fun h => h.noetherian, IsNoetherian.mk⟩ #align is_noetherian_def isNoetherian_def theorem isNoetherian_submodule {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, s ≤ N → s.FG := by refine ⟨fun ⟨hn⟩ => fun s hs => have : s ≤ LinearMap.range N.subtype := N.range_subtype.symm ▸ hs Submodule.map_comap_eq_self this ▸ (hn _).map _, fun h => ⟨fun s => ?_⟩⟩ have f := (Submodule.equivMapOfInjective N.subtype Subtype.val_injective s).symm have h₁ := h (s.map N.subtype) (Submodule.map_subtype_le N s) have h₂ : (⊤ : Submodule R (s.map N.subtype)).map f = ⊤ := by simp have h₃ := ((Submodule.fg_top _).2 h₁).map (↑f : _ →ₗ[R] s) exact (Submodule.fg_top _).1 (h₂ ▸ h₃) #align is_noetherian_submodule isNoetherian_submodule theorem isNoetherian_submodule_left {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (N ⊓ s).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_left, fun H _ hs => inf_of_le_right hs ▸ H _⟩ #align is_noetherian_submodule_left isNoetherian_submodule_left theorem isNoetherian_submodule_right {N : Submodule R M} : IsNoetherian R N ↔ ∀ s : Submodule R M, (s ⊓ N).FG := isNoetherian_submodule.trans ⟨fun H _ => H _ inf_le_right, fun H _ hs => inf_of_le_left hs ▸ H _⟩ #align is_noetherian_submodule_right isNoetherian_submodule_right instance isNoetherian_submodule' [IsNoetherian R M] (N : Submodule R M) : IsNoetherian R N := isNoetherian_submodule.2 fun _ _ => IsNoetherian.noetherian _ #align is_noetherian_submodule' isNoetherian_submodule' theorem isNoetherian_of_le {s t : Submodule R M} [ht : IsNoetherian R t] (h : s ≤ t) : IsNoetherian R s := isNoetherian_submodule.mpr fun _ hs' => isNoetherian_submodule.mp ht _ (le_trans hs' h) #align is_noetherian_of_le isNoetherian_of_le variable (M) theorem isNoetherian_of_surjective (f : M →ₗ[R] P) (hf : LinearMap.range f = ⊤) [IsNoetherian R M] : IsNoetherian R P := ⟨fun s => have : (s.comap f).map f = s := Submodule.map_comap_eq_self <| hf.symm ▸ le_top this ▸ (noetherian _).map _⟩ #align is_noetherian_of_surjective isNoetherian_of_surjective variable {M} instance isNoetherian_quotient {R} [Ring R] {M} [AddCommGroup M] [Module R M] (N : Submodule R M) [IsNoetherian R M] : IsNoetherian R (M ⧸ N) := isNoetherian_of_surjective _ _ (LinearMap.range_eq_top.mpr N.mkQ_surjective) #align submodule.quotient.is_noetherian isNoetherian_quotient @[deprecated (since := "2024-04-27"), nolint defLemma] alias Submodule.Quotient.isNoetherian := isNoetherian_quotient theorem isNoetherian_of_linearEquiv (f : M ≃ₗ[R] P) [IsNoetherian R M] : IsNoetherian R P := isNoetherian_of_surjective _ f.toLinearMap f.range #align is_noetherian_of_linear_equiv isNoetherian_of_linearEquiv theorem isNoetherian_top_iff : IsNoetherian R (⊤ : Submodule R M) ↔ IsNoetherian R M := by constructor <;> intro h · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl) · exact isNoetherian_of_linearEquiv (LinearEquiv.ofTop (⊤ : Submodule R M) rfl).symm #align is_noetherian_top_iff isNoetherian_top_iff theorem isNoetherian_of_injective [IsNoetherian R P] (f : M →ₗ[R] P) (hf : Function.Injective f) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f hf).symm #align is_noetherian_of_injective isNoetherian_of_injective theorem fg_of_injective [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : Function.Injective f) : N.FG := haveI := isNoetherian_of_injective f hf IsNoetherian.noetherian N #align fg_of_injective fg_of_injective end section variable {R : Type*} {M : Type*} {P : Type*} variable [Ring R] [AddCommGroup M] [AddCommGroup P] variable [Module R M] [Module R P] open IsNoetherian theorem isNoetherian_of_ker_bot [IsNoetherian R P] (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : IsNoetherian R M := isNoetherian_of_linearEquiv (LinearEquiv.ofInjective f <| LinearMap.ker_eq_bot.mp hf).symm #align is_noetherian_of_ker_bot isNoetherian_of_ker_bot theorem fg_of_ker_bot [IsNoetherian R P] {N : Submodule R M} (f : M →ₗ[R] P) (hf : LinearMap.ker f = ⊥) : N.FG := haveI := isNoetherian_of_ker_bot f hf IsNoetherian.noetherian N #align fg_of_ker_bot fg_of_ker_bot instance isNoetherian_prod [IsNoetherian R M] [IsNoetherian R P] : IsNoetherian R (M × P) := ⟨fun s => Submodule.fg_of_fg_map_of_fg_inf_ker (LinearMap.snd R M P) (noetherian _) <| have : s ⊓ LinearMap.ker (LinearMap.snd R M P) ≤ LinearMap.range (LinearMap.inl R M P) := fun x ⟨_, hx2⟩ => ⟨x.1, Prod.ext rfl <| Eq.symm <| LinearMap.mem_ker.1 hx2⟩ Submodule.map_comap_eq_self this ▸ (noetherian _).map _⟩ #align is_noetherian_prod isNoetherian_prod instance isNoetherian_pi {R ι : Type*} {M : ι → Type*} [Ring R] [∀ i, AddCommGroup (M i)] [∀ i, Module R (M i)] [Finite ι] [∀ i, IsNoetherian R (M i)] : IsNoetherian R (∀ i, M i) := by cases nonempty_fintype ι haveI := Classical.decEq ι suffices on_finset : ∀ s : Finset ι, IsNoetherian R (∀ i : s, M i) by let coe_e := Equiv.subtypeUnivEquiv <| @Finset.mem_univ ι _ letI : IsNoetherian R (∀ i : Finset.univ, M (coe_e i)) := on_finset Finset.univ exact isNoetherian_of_linearEquiv (LinearEquiv.piCongrLeft R M coe_e) intro s induction' s using Finset.induction with a s has ih · exact ⟨fun s => by have : s = ⊥ := by simp only [eq_iff_true_of_subsingleton] rw [this] apply Submodule.fg_bot⟩ refine @isNoetherian_of_linearEquiv R (M a × ((i : s) → M i)) _ _ _ _ _ _ ?_ <| @isNoetherian_prod R (M a) _ _ _ _ _ _ _ ih refine { toFun := fun f i => (Finset.mem_insert.1 i.2).by_cases (fun h : i.1 = a => show M i.1 from Eq.recOn h.symm f.1) (fun h : i.1 ∈ s => show M i.1 from f.2 ⟨i.1, h⟩), invFun := fun f => (f ⟨a, Finset.mem_insert_self _ _⟩, fun i => f ⟨i.1, Finset.mem_insert_of_mem i.2⟩), map_add' := ?_, map_smul' := ?_ left_inv := ?_, right_inv := ?_ } · intro f g ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · change _ = _ + _ simp only [dif_pos] rfl · change _ = _ + _ have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] rfl · intro c f ext i unfold Or.by_cases cases' i with i hi rcases Finset.mem_insert.1 hi with (rfl | h) · dsimp simp only [dif_pos] · dsimp have : ¬i = a := by rintro rfl exact has h simp only [dif_neg this, dif_pos h] · intro f apply Prod.ext · simp only [Or.by_cases, dif_pos] · ext ⟨i, his⟩ have : ¬i = a := by rintro rfl exact has his simp only [Or.by_cases, this, not_false_iff, dif_neg] · intro f ext ⟨i, hi⟩ rcases Finset.mem_insert.1 hi with (rfl | h) · simp only [Or.by_cases, dif_pos] · have : ¬i = a := by rintro rfl exact has h simp only [Or.by_cases, dif_neg this, dif_pos h] #align is_noetherian_pi isNoetherian_pi instance isNoetherian_pi' {R ι M : Type*} [Ring R] [AddCommGroup M] [Module R M] [Finite ι] [IsNoetherian R M] : IsNoetherian R (ι → M) := isNoetherian_pi #align is_noetherian_pi' isNoetherian_pi' end open IsNoetherian Submodule Function section universe w variable {R M P : Type*} {N : Type w} [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid N] [Module R N] [AddCommMonoid P] [Module R P] theorem isNoetherian_iff_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := by have := (CompleteLattice.wellFounded_characterisations <| Submodule R M).out 0 3 -- Porting note: inlining this makes rw complain about it being a metavariable rw [this] exact ⟨fun ⟨h⟩ => fun k => (fg_iff_compact k).mp (h k), fun h => ⟨fun k => (fg_iff_compact k).mpr (h k)⟩⟩ #align is_noetherian_iff_well_founded isNoetherian_iff_wellFounded theorem isNoetherian_iff_fg_wellFounded : IsNoetherian R M ↔ WellFounded ((· > ·) : { N : Submodule R M // N.FG } → { N : Submodule R M // N.FG } → Prop) := by let α := { N : Submodule R M // N.FG } constructor · intro H let f : α ↪o Submodule R M := OrderEmbedding.subtype _ exact OrderEmbedding.wellFounded f.dual (isNoetherian_iff_wellFounded.mp H) · intro H constructor intro N obtain ⟨⟨N₀, h₁⟩, e : N₀ ≤ N, h₂⟩ := WellFounded.has_min H { N' : α | N'.1 ≤ N } ⟨⟨⊥, Submodule.fg_bot⟩, @bot_le _ _ _ N⟩ convert h₁ refine (e.antisymm ?_).symm by_contra h₃ obtain ⟨x, hx₁ : x ∈ N, hx₂ : x ∉ N₀⟩ := Set.not_subset.mp h₃ apply hx₂ rw [eq_of_le_of_not_lt (le_sup_right : N₀ ≤ _) (h₂ ⟨_, Submodule.FG.sup ⟨{x}, by rw [Finset.coe_singleton]⟩ h₁⟩ <| sup_le ((Submodule.span_singleton_le_iff_mem _ _).mpr hx₁) e)] exact (le_sup_left : (R ∙ x) ≤ _) (Submodule.mem_span_singleton_self _) #align is_noetherian_iff_fg_well_founded isNoetherian_iff_fg_wellFounded variable (R M) theorem wellFounded_submodule_gt (R M) [Semiring R] [AddCommMonoid M] [Module R M] : ∀ [IsNoetherian R M], WellFounded ((· > ·) : Submodule R M → Submodule R M → Prop) := isNoetherian_iff_wellFounded.mp ‹_› #align well_founded_submodule_gt wellFounded_submodule_gt variable {R M} theorem set_has_maximal_iff_noetherian : (∀ a : Set <| Submodule R M, a.Nonempty → ∃ M' ∈ a, ∀ I ∈ a, ¬M' < I) ↔ IsNoetherian R M := by rw [isNoetherian_iff_wellFounded, WellFounded.wellFounded_iff_has_min] #align set_has_maximal_iff_noetherian set_has_maximal_iff_noetherian theorem monotone_stabilizes_iff_noetherian : (∀ f : ℕ →o Submodule R M, ∃ n, ∀ m, n ≤ m → f n = f m) ↔ IsNoetherian R M := by rw [isNoetherian_iff_wellFounded, WellFounded.monotone_chain_condition] #align monotone_stabilizes_iff_noetherian monotone_stabilizes_iff_noetherian theorem eventuallyConst_of_isNoetherian [IsNoetherian R M] (f : ℕ →o Submodule R M) : atTop.EventuallyConst f := by simp_rw [eventuallyConst_atTop, eq_comm] exact (monotone_stabilizes_iff_noetherian.mpr inferInstance) f theorem IsNoetherian.induction [IsNoetherian R M] {P : Submodule R M → Prop} (hgt : ∀ I, (∀ J > I, P J) → P I) (I : Submodule R M) : P I := WellFounded.recursion (wellFounded_submodule_gt R M) I hgt #align is_noetherian.induction IsNoetherian.induction end section universe w variable {R M P : Type*} {N : Type w} [Ring R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N] [AddCommGroup P] [Module R P] [IsNoetherian R M] lemma Submodule.finite_ne_bot_of_independent {ι : Type*} {N : ι → Submodule R M} (h : CompleteLattice.Independent N) : Set.Finite {i | N i ≠ ⊥} := CompleteLattice.WellFounded.finite_ne_bot_of_independent (isNoetherian_iff_wellFounded.mp inferInstance) h theorem LinearIndependent.finite_of_isNoetherian [Nontrivial R] {ι} {v : ι → M} (hv : LinearIndependent R v) : Finite ι := by have hwf := isNoetherian_iff_wellFounded.mp (by infer_instance : IsNoetherian R M) refine CompleteLattice.WellFounded.finite_of_independent hwf hv.independent_span_singleton fun i contra => ?_ apply hv.ne_zero i have : v i ∈ R ∙ v i := Submodule.mem_span_singleton_self (v i) rwa [contra, Submodule.mem_bot] at this #align linear_independent.finite_of_is_noetherian LinearIndependent.finite_of_isNoetherian theorem LinearIndependent.set_finite_of_isNoetherian [Nontrivial R] {s : Set M} (hi : LinearIndependent R ((↑) : s → M)) : s.Finite := @Set.toFinite _ _ hi.finite_of_isNoetherian #align linear_independent.set_finite_of_is_noetherian LinearIndependent.set_finite_of_isNoetherian @[deprecated] alias finite_of_linearIndependent := LinearIndependent.set_finite_of_isNoetherian #align finite_of_linear_independent LinearIndependent.set_finite_of_isNoetherian theorem isNoetherian_of_range_eq_ker [IsNoetherian R P] (f : M →ₗ[R] N) (g : N →ₗ[R] P) (h : LinearMap.range f = LinearMap.ker g) : IsNoetherian R N := isNoetherian_iff_wellFounded.2 <| wellFounded_gt_exact_sequence (wellFounded_submodule_gt R _) (wellFounded_submodule_gt R _) (LinearMap.range f) (Submodule.map (f.ker.liftQ f <| le_rfl)) (Submodule.comap (f.ker.liftQ f <| le_rfl)) (Submodule.comap g.rangeRestrict) (Submodule.map g.rangeRestrict) (Submodule.gciMapComap <| LinearMap.ker_eq_bot.mp <| Submodule.ker_liftQ_eq_bot _ _ _ (le_refl _)) (Submodule.giMapComap g.surjective_rangeRestrict) (by simp [Submodule.map_comap_eq, inf_comm, Submodule.range_liftQ]) (by simp [Submodule.comap_map_eq, h]) #align is_noetherian_of_range_eq_ker isNoetherian_of_range_eq_ker theorem LinearMap.eventually_disjoint_ker_pow_range_pow (f : M →ₗ[R] M) : ∀ᶠ n in atTop, Disjoint (LinearMap.ker (f ^ n)) (LinearMap.range (f ^ n)) := by obtain ⟨n, hn : ∀ m, n ≤ m → LinearMap.ker (f ^ n) = LinearMap.ker (f ^ m)⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance f.iterateKer refine eventually_atTop.mpr ⟨n, fun m hm ↦ disjoint_iff.mpr ?_⟩ rw [← hn _ hm, Submodule.eq_bot_iff] rintro - ⟨hx, ⟨x, rfl⟩⟩ apply LinearMap.pow_map_zero_of_le hm replace hx : x ∈ LinearMap.ker (f ^ (n + m)) := by simpa [f.pow_apply n, f.pow_apply m, ← f.pow_apply (n + m), ← iterate_add_apply] using hx rwa [← hn _ (n.le_add_right m)] at hx #align is_noetherian.exists_endomorphism_iterate_ker_inf_range_eq_bot LinearMap.eventually_disjoint_ker_pow_range_pow lemma LinearMap.eventually_iSup_ker_pow_eq (f : M →ₗ[R] M) : ∀ᶠ n in atTop, ⨆ m, LinearMap.ker (f ^ m) = LinearMap.ker (f ^ n) := by obtain ⟨n, hn : ∀ m, n ≤ m → ker (f ^ n) = ker (f ^ m)⟩ := monotone_stabilizes_iff_noetherian.mpr inferInstance f.iterateKer refine eventually_atTop.mpr ⟨n, fun m hm ↦ ?_⟩ refine le_antisymm (iSup_le fun l ↦ ?_) (le_iSup (fun i ↦ LinearMap.ker (f ^ i)) m) rcases le_or_lt m l with h | h · rw [← hn _ (hm.trans h), hn _ hm] · exact f.iterateKer.monotone h.le
Mathlib/RingTheory/Noetherian.lean
467
473
theorem IsNoetherian.injective_of_surjective_of_injective (i f : N →ₗ[R] M) (hi : Injective i) (hf : Surjective f) : Injective f := by
haveI := isNoetherian_of_injective i hi obtain ⟨n, H⟩ := monotone_stabilizes_iff_noetherian.2 ‹_› ⟨_, monotone_nat_of_le_succ <| f.iterateMapComap_le_succ i ⊥ (by simp)⟩ exact LinearMap.ker_eq_bot.1 <| bot_unique <| f.ker_le_of_iterateMapComap_eq_succ i ⊥ n (H _ (Nat.le_succ _)) hf hi
import Mathlib.LinearAlgebra.Ray import Mathlib.Analysis.NormedSpace.Real #align_import analysis.normed_space.ray from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" open Real variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F] [NormedSpace ℝ F] variable {x y : F}
Mathlib/Analysis/NormedSpace/Ray.lean
59
65
theorem norm_injOn_ray_left (hx : x ≠ 0) : { y | SameRay ℝ x y }.InjOn norm := by
rintro y hy z hz h rcases hy.exists_nonneg_left hx with ⟨r, hr, rfl⟩ rcases hz.exists_nonneg_left hx with ⟨s, hs, rfl⟩ rw [norm_smul, norm_smul, mul_left_inj' (norm_ne_zero_iff.2 hx), norm_of_nonneg hr, norm_of_nonneg hs] at h rw [h]
import Mathlib.Geometry.Euclidean.Angle.Oriented.Affine import Mathlib.Geometry.Euclidean.Angle.Unoriented.RightAngle #align_import geometry.euclidean.angle.oriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" noncomputable section open scoped EuclideanGeometry open scoped Real open scoped RealInnerProductSpace namespace Orientation open FiniteDimensional variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] variable [hd2 : Fact (finrank ℝ V = 2)] (o : Orientation ℝ V (Fin 2)) theorem oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arccos (‖y‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arccos_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arccos_of_oangle_eq_pi_div_two theorem oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arcsin (‖x‖ / ‖x + y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arcsin_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arcsin_of_oangle_eq_pi_div_two theorem oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (o.left_ne_zero_of_oangle_eq_pi_div_two h)] #align orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two theorem oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : o.oangle (x + y) y = Real.arctan (‖x‖ / ‖y‖) := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).oangle_add_right_eq_arctan_of_oangle_eq_pi_div_two h #align orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two Orientation.oangle_add_left_eq_arctan_of_oangle_eq_pi_div_two theorem cos_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) = ‖x‖ / ‖x + y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe, InnerProductGeometry.cos_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_of_oangle_eq_pi_div_two theorem cos_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) = ‖y‖ / ‖x + y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).cos_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_of_oangle_eq_pi_div_two theorem sin_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) = ‖y‖ / ‖x + y‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe, InnerProductGeometry.sin_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h) (Or.inl (o.left_ne_zero_of_oangle_eq_pi_div_two h))] #align orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_right_of_oangle_eq_pi_div_two theorem sin_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle (x + y) y) = ‖x‖ / ‖x + y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).sin_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two Orientation.sin_oangle_add_left_of_oangle_eq_pi_div_two theorem tan_oangle_add_right_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle x (x + y)) = ‖y‖ / ‖x‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.tan_coe, InnerProductGeometry.tan_angle_add_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_right_of_oangle_eq_pi_div_two theorem tan_oangle_add_left_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.tan (o.oangle (x + y) y) = ‖x‖ / ‖y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).tan_oangle_add_right_of_oangle_eq_pi_div_two h #align orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two Orientation.tan_oangle_add_left_of_oangle_eq_pi_div_two theorem cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle x (x + y)) * ‖x + y‖ = ‖x‖ := by have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.cos_coe, InnerProductGeometry.cos_angle_add_mul_norm_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)] #align orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two theorem cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.cos (o.oangle (x + y) y) * ‖x + y‖ = ‖y‖ := by rw [← neg_inj, oangle_rev, ← oangle_neg_orientation_eq_neg, neg_inj] at h ⊢ rw [add_comm] exact (-o).cos_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two h #align orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two Orientation.cos_oangle_add_left_mul_norm_of_oangle_eq_pi_div_two
Mathlib/Geometry/Euclidean/Angle/Oriented/RightAngle.lean
164
170
theorem sin_oangle_add_right_mul_norm_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = ↑(π / 2)) : Real.Angle.sin (o.oangle x (x + y)) * ‖x + y‖ = ‖y‖ := by
have hs : (o.oangle x (x + y)).sign = 1 := by rw [oangle_sign_add_right, h, Real.Angle.sign_coe_pi_div_two] rw [o.oangle_eq_angle_of_sign_eq_one hs, Real.Angle.sin_coe, InnerProductGeometry.sin_angle_add_mul_norm_of_inner_eq_zero (o.inner_eq_zero_of_oangle_eq_pi_div_two h)]
import Mathlib.Order.Interval.Set.OrdConnectedComponent import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.t5 from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" open Filter Set Function OrderDual Topology Interval variable {X : Type*} [LinearOrder X] [TopologicalSpace X] [OrderTopology X] {a b c : X} {s t : Set X} namespace Set @[simp]
Mathlib/Topology/Order/T5.lean
27
30
theorem ordConnectedComponent_mem_nhds : ordConnectedComponent s a ∈ 𝓝 a ↔ s ∈ 𝓝 a := by
refine ⟨fun h => mem_of_superset h ordConnectedComponent_subset, fun h => ?_⟩ rcases exists_Icc_mem_subset_of_mem_nhds h with ⟨b, c, ha, ha', hs⟩ exact mem_of_superset ha' (subset_ordConnectedComponent ha hs)
import Mathlib.SetTheory.Ordinal.Basic import Mathlib.Data.Nat.SuccPred #align_import set_theory.ordinal.arithmetic from "leanprover-community/mathlib"@"31b269b60935483943542d547a6dd83a66b37dc7" assert_not_exists Field assert_not_exists Module noncomputable section open Function Cardinal Set Equiv Order open scoped Classical open Cardinal Ordinal universe u v w namespace Ordinal variable {α : Type*} {β : Type*} {γ : Type*} {r : α → α → Prop} {s : β → β → Prop} {t : γ → γ → Prop} @[simp] theorem lift_add (a b : Ordinal.{v}) : lift.{u} (a + b) = lift.{u} a + lift.{u} b := Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ => Quotient.sound ⟨(RelIso.preimage Equiv.ulift _).trans (RelIso.sumLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩ #align ordinal.lift_add Ordinal.lift_add @[simp] theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by rw [← add_one_eq_succ, lift_add, lift_one] rfl #align ordinal.lift_succ Ordinal.lift_succ instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) := ⟨fun a b c => inductionOn a fun α r hr => inductionOn b fun β₁ s₁ hs₁ => inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ => ⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using @InitialSeg.eq _ _ _ _ _ ((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by intro b; cases e : f (Sum.inr b) · rw [← fl] at e have := f.inj' e contradiction · exact ⟨_, rfl⟩ let g (b) := (this b).1 have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2 ⟨⟨⟨g, fun x y h => by injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩, @fun a b => by -- Porting note: -- `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding` -- → `InitialSeg.coe_coe_fn` simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using @RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩, fun a b H => by rcases f.init (by rw [fr] <;> exact Sum.lex_inr_inr.2 H) with ⟨a' | a', h⟩ · rw [fl] at h cases h · rw [fr] at h exact ⟨a', Sum.inr.inj h⟩⟩⟩⟩ #align ordinal.add_contravariant_class_le Ordinal.add_contravariantClass_le theorem add_left_cancel (a) {b c : Ordinal} : a + b = a + c ↔ b = c := by simp only [le_antisymm_iff, add_le_add_iff_left] #align ordinal.add_left_cancel Ordinal.add_left_cancel private theorem add_lt_add_iff_left' (a) {b c : Ordinal} : a + b < a + c ↔ b < c := by rw [← not_le, ← not_le, add_le_add_iff_left] instance add_covariantClass_lt : CovariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).2⟩ #align ordinal.add_covariant_class_lt Ordinal.add_covariantClass_lt instance add_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) := ⟨fun a _b _c => (add_lt_add_iff_left' a).1⟩ #align ordinal.add_contravariant_class_lt Ordinal.add_contravariantClass_lt instance add_swap_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (swap (· + ·)) (· < ·) := ⟨fun _a _b _c => lt_imp_lt_of_le_imp_le fun h => add_le_add_right h _⟩ #align ordinal.add_swap_contravariant_class_lt Ordinal.add_swap_contravariantClass_lt theorem add_le_add_iff_right {a b : Ordinal} : ∀ n : ℕ, a + n ≤ b + n ↔ a ≤ b | 0 => by simp | n + 1 => by simp only [natCast_succ, add_succ, add_succ, succ_le_succ_iff, add_le_add_iff_right] #align ordinal.add_le_add_iff_right Ordinal.add_le_add_iff_right theorem add_right_cancel {a b : Ordinal} (n : ℕ) : a + n = b + n ↔ a = b := by simp only [le_antisymm_iff, add_le_add_iff_right] #align ordinal.add_right_cancel Ordinal.add_right_cancel theorem add_eq_zero_iff {a b : Ordinal} : a + b = 0 ↔ a = 0 ∧ b = 0 := inductionOn a fun α r _ => inductionOn b fun β s _ => by simp_rw [← type_sum_lex, type_eq_zero_iff_isEmpty] exact isEmpty_sum #align ordinal.add_eq_zero_iff Ordinal.add_eq_zero_iff theorem left_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : a = 0 := (add_eq_zero_iff.1 h).1 #align ordinal.left_eq_zero_of_add_eq_zero Ordinal.left_eq_zero_of_add_eq_zero theorem right_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : b = 0 := (add_eq_zero_iff.1 h).2 #align ordinal.right_eq_zero_of_add_eq_zero Ordinal.right_eq_zero_of_add_eq_zero def pred (o : Ordinal) : Ordinal := if h : ∃ a, o = succ a then Classical.choose h else o #align ordinal.pred Ordinal.pred @[simp] theorem pred_succ (o) : pred (succ o) = o := by have h : ∃ a, succ o = succ a := ⟨_, rfl⟩; simpa only [pred, dif_pos h] using (succ_injective <| Classical.choose_spec h).symm #align ordinal.pred_succ Ordinal.pred_succ theorem pred_le_self (o) : pred o ≤ o := if h : ∃ a, o = succ a then by let ⟨a, e⟩ := h rw [e, pred_succ]; exact le_succ a else by rw [pred, dif_neg h] #align ordinal.pred_le_self Ordinal.pred_le_self theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬∃ a, o = succ a := ⟨fun e ⟨a, e'⟩ => by rw [e', pred_succ] at e; exact (lt_succ a).ne e, fun h => dif_neg h⟩ #align ordinal.pred_eq_iff_not_succ Ordinal.pred_eq_iff_not_succ theorem pred_eq_iff_not_succ' {o} : pred o = o ↔ ∀ a, o ≠ succ a := by simpa using pred_eq_iff_not_succ #align ordinal.pred_eq_iff_not_succ' Ordinal.pred_eq_iff_not_succ' theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a := Iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and_iff, not_le]) (iff_not_comm.1 pred_eq_iff_not_succ).symm #align ordinal.pred_lt_iff_is_succ Ordinal.pred_lt_iff_is_succ @[simp] theorem pred_zero : pred 0 = 0 := pred_eq_iff_not_succ'.2 fun a => (succ_ne_zero a).symm #align ordinal.pred_zero Ordinal.pred_zero theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a := ⟨fun e => ⟨_, e.symm⟩, fun ⟨a, e⟩ => by simp only [e, pred_succ]⟩ #align ordinal.succ_pred_iff_is_succ Ordinal.succ_pred_iff_is_succ theorem succ_lt_of_not_succ {o b : Ordinal} (h : ¬∃ a, o = succ a) : succ b < o ↔ b < o := ⟨(lt_succ b).trans, fun l => lt_of_le_of_ne (succ_le_of_lt l) fun e => h ⟨_, e.symm⟩⟩ #align ordinal.succ_lt_of_not_succ Ordinal.succ_lt_of_not_succ theorem lt_pred {a b} : a < pred b ↔ succ a < b := if h : ∃ a, b = succ a then by let ⟨c, e⟩ := h rw [e, pred_succ, succ_lt_succ_iff] else by simp only [pred, dif_neg h, succ_lt_of_not_succ h] #align ordinal.lt_pred Ordinal.lt_pred theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b := le_iff_le_iff_lt_iff_lt.2 lt_pred #align ordinal.pred_le Ordinal.pred_le @[simp] theorem lift_is_succ {o : Ordinal.{v}} : (∃ a, lift.{u} o = succ a) ↔ ∃ a, o = succ a := ⟨fun ⟨a, h⟩ => let ⟨b, e⟩ := lift_down <| show a ≤ lift.{u} o from le_of_lt <| h.symm ▸ lt_succ a ⟨b, lift_inj.1 <| by rw [h, ← e, lift_succ]⟩, fun ⟨a, h⟩ => ⟨lift.{u} a, by simp only [h, lift_succ]⟩⟩ #align ordinal.lift_is_succ Ordinal.lift_is_succ @[simp] theorem lift_pred (o : Ordinal.{v}) : lift.{u} (pred o) = pred (lift.{u} o) := if h : ∃ a, o = succ a then by cases' h with a e; simp only [e, pred_succ, lift_succ] else by rw [pred_eq_iff_not_succ.2 h, pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)] #align ordinal.lift_pred Ordinal.lift_pred def IsLimit (o : Ordinal) : Prop := o ≠ 0 ∧ ∀ a < o, succ a < o #align ordinal.is_limit Ordinal.IsLimit theorem IsLimit.isSuccLimit {o} (h : IsLimit o) : IsSuccLimit o := isSuccLimit_iff_succ_lt.mpr h.2 theorem IsLimit.succ_lt {o a : Ordinal} (h : IsLimit o) : a < o → succ a < o := h.2 a #align ordinal.is_limit.succ_lt Ordinal.IsLimit.succ_lt theorem isSuccLimit_zero : IsSuccLimit (0 : Ordinal) := isSuccLimit_bot theorem not_zero_isLimit : ¬IsLimit 0 | ⟨h, _⟩ => h rfl #align ordinal.not_zero_is_limit Ordinal.not_zero_isLimit theorem not_succ_isLimit (o) : ¬IsLimit (succ o) | ⟨_, h⟩ => lt_irrefl _ (h _ (lt_succ o)) #align ordinal.not_succ_is_limit Ordinal.not_succ_isLimit theorem not_succ_of_isLimit {o} (h : IsLimit o) : ¬∃ a, o = succ a | ⟨a, e⟩ => not_succ_isLimit a (e ▸ h) #align ordinal.not_succ_of_is_limit Ordinal.not_succ_of_isLimit theorem succ_lt_of_isLimit {o a : Ordinal} (h : IsLimit o) : succ a < o ↔ a < o := ⟨(lt_succ a).trans, h.2 _⟩ #align ordinal.succ_lt_of_is_limit Ordinal.succ_lt_of_isLimit theorem le_succ_of_isLimit {o} (h : IsLimit o) {a} : o ≤ succ a ↔ o ≤ a := le_iff_le_iff_lt_iff_lt.2 <| succ_lt_of_isLimit h #align ordinal.le_succ_of_is_limit Ordinal.le_succ_of_isLimit theorem limit_le {o} (h : IsLimit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a := ⟨fun h _x l => l.le.trans h, fun H => (le_succ_of_isLimit h).1 <| le_of_not_lt fun hn => not_lt_of_le (H _ hn) (lt_succ a)⟩ #align ordinal.limit_le Ordinal.limit_le theorem lt_limit {o} (h : IsLimit o) {a} : a < o ↔ ∃ x < o, a < x := by -- Porting note: `bex_def` is required. simpa only [not_forall₂, not_le, bex_def] using not_congr (@limit_le _ h a) #align ordinal.lt_limit Ordinal.lt_limit @[simp] theorem lift_isLimit (o) : IsLimit (lift o) ↔ IsLimit o := and_congr (not_congr <| by simpa only [lift_zero] using @lift_inj o 0) ⟨fun H a h => lift_lt.1 <| by simpa only [lift_succ] using H _ (lift_lt.2 h), fun H a h => by obtain ⟨a', rfl⟩ := lift_down h.le rw [← lift_succ, lift_lt] exact H a' (lift_lt.1 h)⟩ #align ordinal.lift_is_limit Ordinal.lift_isLimit theorem IsLimit.pos {o : Ordinal} (h : IsLimit o) : 0 < o := lt_of_le_of_ne (Ordinal.zero_le _) h.1.symm #align ordinal.is_limit.pos Ordinal.IsLimit.pos theorem IsLimit.one_lt {o : Ordinal} (h : IsLimit o) : 1 < o := by simpa only [succ_zero] using h.2 _ h.pos #align ordinal.is_limit.one_lt Ordinal.IsLimit.one_lt theorem IsLimit.nat_lt {o : Ordinal} (h : IsLimit o) : ∀ n : ℕ, (n : Ordinal) < o | 0 => h.pos | n + 1 => h.2 _ (IsLimit.nat_lt h n) #align ordinal.is_limit.nat_lt Ordinal.IsLimit.nat_lt theorem zero_or_succ_or_limit (o : Ordinal) : o = 0 ∨ (∃ a, o = succ a) ∨ IsLimit o := if o0 : o = 0 then Or.inl o0 else if h : ∃ a, o = succ a then Or.inr (Or.inl h) else Or.inr <| Or.inr ⟨o0, fun _a => (succ_lt_of_not_succ h).2⟩ #align ordinal.zero_or_succ_or_limit Ordinal.zero_or_succ_or_limit @[elab_as_elim] def limitRecOn {C : Ordinal → Sort*} (o : Ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o)) (H₃ : ∀ o, IsLimit o → (∀ o' < o, C o') → C o) : C o := SuccOrder.limitRecOn o (fun o _ ↦ H₂ o) fun o hl ↦ if h : o = 0 then fun _ ↦ h ▸ H₁ else H₃ o ⟨h, fun _ ↦ hl.succ_lt⟩ #align ordinal.limit_rec_on Ordinal.limitRecOn @[simp] theorem limitRecOn_zero {C} (H₁ H₂ H₃) : @limitRecOn C 0 H₁ H₂ H₃ = H₁ := by rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ isSuccLimit_zero, dif_pos rfl] #align ordinal.limit_rec_on_zero Ordinal.limitRecOn_zero @[simp] theorem limitRecOn_succ {C} (o H₁ H₂ H₃) : @limitRecOn C (succ o) H₁ H₂ H₃ = H₂ o (@limitRecOn C o H₁ H₂ H₃) := by simp_rw [limitRecOn, SuccOrder.limitRecOn_succ _ _ (not_isMax _)] #align ordinal.limit_rec_on_succ Ordinal.limitRecOn_succ @[simp] theorem limitRecOn_limit {C} (o H₁ H₂ H₃ h) : @limitRecOn C o H₁ H₂ H₃ = H₃ o h fun x _h => @limitRecOn C x H₁ H₂ H₃ := by simp_rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ h.isSuccLimit, dif_neg h.1] #align ordinal.limit_rec_on_limit Ordinal.limitRecOn_limit instance orderTopOutSucc (o : Ordinal) : OrderTop (succ o).out.α := @OrderTop.mk _ _ (Top.mk _) le_enum_succ #align ordinal.order_top_out_succ Ordinal.orderTopOutSucc theorem enum_succ_eq_top {o : Ordinal} : enum (· < ·) o (by rw [type_lt] exact lt_succ o) = (⊤ : (succ o).out.α) := rfl #align ordinal.enum_succ_eq_top Ordinal.enum_succ_eq_top theorem has_succ_of_type_succ_lt {α} {r : α → α → Prop} [wo : IsWellOrder α r] (h : ∀ a < type r, succ a < type r) (x : α) : ∃ y, r x y := by use enum r (succ (typein r x)) (h _ (typein_lt_type r x)) convert (enum_lt_enum (typein_lt_type r x) (h _ (typein_lt_type r x))).mpr (lt_succ _); rw [enum_typein] #align ordinal.has_succ_of_type_succ_lt Ordinal.has_succ_of_type_succ_lt theorem out_no_max_of_succ_lt {o : Ordinal} (ho : ∀ a < o, succ a < o) : NoMaxOrder o.out.α := ⟨has_succ_of_type_succ_lt (by rwa [type_lt])⟩ #align ordinal.out_no_max_of_succ_lt Ordinal.out_no_max_of_succ_lt theorem bounded_singleton {r : α → α → Prop} [IsWellOrder α r] (hr : (type r).IsLimit) (x) : Bounded r {x} := by refine ⟨enum r (succ (typein r x)) (hr.2 _ (typein_lt_type r x)), ?_⟩ intro b hb rw [mem_singleton_iff.1 hb] nth_rw 1 [← enum_typein r x] rw [@enum_lt_enum _ r] apply lt_succ #align ordinal.bounded_singleton Ordinal.bounded_singleton -- Porting note: `· < ·` requires a type ascription for an `IsWellOrder` instance. theorem type_subrel_lt (o : Ordinal.{u}) : type (Subrel ((· < ·) : Ordinal → Ordinal → Prop) { o' : Ordinal | o' < o }) = Ordinal.lift.{u + 1} o := by refine Quotient.inductionOn o ?_ rintro ⟨α, r, wo⟩; apply Quotient.sound -- Porting note: `symm; refine' [term]` → `refine' [term].symm` constructor; refine ((RelIso.preimage Equiv.ulift r).trans (enumIso r).symm).symm #align ordinal.type_subrel_lt Ordinal.type_subrel_lt theorem mk_initialSeg (o : Ordinal.{u}) : #{ o' : Ordinal | o' < o } = Cardinal.lift.{u + 1} o.card := by rw [lift_card, ← type_subrel_lt, card_type] #align ordinal.mk_initial_seg Ordinal.mk_initialSeg def IsNormal (f : Ordinal → Ordinal) : Prop := (∀ o, f o < f (succ o)) ∧ ∀ o, IsLimit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a #align ordinal.is_normal Ordinal.IsNormal theorem IsNormal.limit_le {f} (H : IsNormal f) : ∀ {o}, IsLimit o → ∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a := @H.2 #align ordinal.is_normal.limit_le Ordinal.IsNormal.limit_le theorem IsNormal.limit_lt {f} (H : IsNormal f) {o} (h : IsLimit o) {a} : a < f o ↔ ∃ b < o, a < f b := not_iff_not.1 <| by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a #align ordinal.is_normal.limit_lt Ordinal.IsNormal.limit_lt theorem IsNormal.strictMono {f} (H : IsNormal f) : StrictMono f := fun a b => limitRecOn b (Not.elim (not_lt_of_le <| Ordinal.zero_le _)) (fun _b IH h => (lt_or_eq_of_le (le_of_lt_succ h)).elim (fun h => (IH h).trans (H.1 _)) fun e => e ▸ H.1 _) fun _b l _IH h => lt_of_lt_of_le (H.1 a) ((H.2 _ l _).1 le_rfl _ (l.2 _ h)) #align ordinal.is_normal.strict_mono Ordinal.IsNormal.strictMono theorem IsNormal.monotone {f} (H : IsNormal f) : Monotone f := H.strictMono.monotone #align ordinal.is_normal.monotone Ordinal.IsNormal.monotone theorem isNormal_iff_strictMono_limit (f : Ordinal → Ordinal) : IsNormal f ↔ StrictMono f ∧ ∀ o, IsLimit o → ∀ a, (∀ b < o, f b ≤ a) → f o ≤ a := ⟨fun hf => ⟨hf.strictMono, fun a ha c => (hf.2 a ha c).2⟩, fun ⟨hs, hl⟩ => ⟨fun a => hs (lt_succ a), fun a ha c => ⟨fun hac _b hba => ((hs hba).trans_le hac).le, hl a ha c⟩⟩⟩ #align ordinal.is_normal_iff_strict_mono_limit Ordinal.isNormal_iff_strictMono_limit theorem IsNormal.lt_iff {f} (H : IsNormal f) {a b} : f a < f b ↔ a < b := StrictMono.lt_iff_lt <| H.strictMono #align ordinal.is_normal.lt_iff Ordinal.IsNormal.lt_iff theorem IsNormal.le_iff {f} (H : IsNormal f) {a b} : f a ≤ f b ↔ a ≤ b := le_iff_le_iff_lt_iff_lt.2 H.lt_iff #align ordinal.is_normal.le_iff Ordinal.IsNormal.le_iff theorem IsNormal.inj {f} (H : IsNormal f) {a b} : f a = f b ↔ a = b := by simp only [le_antisymm_iff, H.le_iff] #align ordinal.is_normal.inj Ordinal.IsNormal.inj theorem IsNormal.self_le {f} (H : IsNormal f) (a) : a ≤ f a := lt_wf.self_le_of_strictMono H.strictMono a #align ordinal.is_normal.self_le Ordinal.IsNormal.self_le theorem IsNormal.le_set {f o} (H : IsNormal f) (p : Set Ordinal) (p0 : p.Nonempty) (b) (H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f a ≤ o := ⟨fun h a pa => (H.le_iff.2 ((H₂ _).1 le_rfl _ pa)).trans h, fun h => by -- Porting note: `refine'` didn't work well so `induction` is used induction b using limitRecOn with | H₁ => cases' p0 with x px have := Ordinal.le_zero.1 ((H₂ _).1 (Ordinal.zero_le _) _ px) rw [this] at px exact h _ px | H₂ S _ => rcases not_forall₂.1 (mt (H₂ S).2 <| (lt_succ S).not_le) with ⟨a, h₁, h₂⟩ exact (H.le_iff.2 <| succ_le_of_lt <| not_le.1 h₂).trans (h _ h₁) | H₃ S L _ => refine (H.2 _ L _).2 fun a h' => ?_ rcases not_forall₂.1 (mt (H₂ a).2 h'.not_le) with ⟨b, h₁, h₂⟩ exact (H.le_iff.2 <| (not_le.1 h₂).le).trans (h _ h₁)⟩ #align ordinal.is_normal.le_set Ordinal.IsNormal.le_set theorem IsNormal.le_set' {f o} (H : IsNormal f) (p : Set α) (p0 : p.Nonempty) (g : α → Ordinal) (b) (H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, g a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f (g a) ≤ o := by simpa [H₂] using H.le_set (g '' p) (p0.image g) b #align ordinal.is_normal.le_set' Ordinal.IsNormal.le_set' theorem IsNormal.refl : IsNormal id := ⟨lt_succ, fun _o l _a => Ordinal.limit_le l⟩ #align ordinal.is_normal.refl Ordinal.IsNormal.refl theorem IsNormal.trans {f g} (H₁ : IsNormal f) (H₂ : IsNormal g) : IsNormal (f ∘ g) := ⟨fun _x => H₁.lt_iff.2 (H₂.1 _), fun o l _a => H₁.le_set' (· < o) ⟨0, l.pos⟩ g _ fun _c => H₂.2 _ l _⟩ #align ordinal.is_normal.trans Ordinal.IsNormal.trans theorem IsNormal.isLimit {f} (H : IsNormal f) {o} (l : IsLimit o) : IsLimit (f o) := ⟨ne_of_gt <| (Ordinal.zero_le _).trans_lt <| H.lt_iff.2 l.pos, fun _ h => let ⟨_b, h₁, h₂⟩ := (H.limit_lt l).1 h (succ_le_of_lt h₂).trans_lt (H.lt_iff.2 h₁)⟩ #align ordinal.is_normal.is_limit Ordinal.IsNormal.isLimit theorem IsNormal.le_iff_eq {f} (H : IsNormal f) {a} : f a ≤ a ↔ f a = a := (H.self_le a).le_iff_eq #align ordinal.is_normal.le_iff_eq Ordinal.IsNormal.le_iff_eq theorem add_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c := ⟨fun h b' l => (add_le_add_left l.le _).trans h, fun H => le_of_not_lt <| by -- Porting note: `induction` tactics are required because of the parser bug. induction a using inductionOn with | H α r => induction b using inductionOn with | H β s => intro l suffices ∀ x : β, Sum.Lex r s (Sum.inr x) (enum _ _ l) by -- Porting note: `revert` & `intro` is required because `cases'` doesn't replace -- `enum _ _ l` in `this`. revert this; cases' enum _ _ l with x x <;> intro this · cases this (enum s 0 h.pos) · exact irrefl _ (this _) intro x rw [← typein_lt_typein (Sum.Lex r s), typein_enum] have := H _ (h.2 _ (typein_lt_type s x)) rw [add_succ, succ_le_iff] at this refine (RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this · rcases a with ⟨a | b, h⟩ · exact Sum.inl a · exact Sum.inr ⟨b, by cases h; assumption⟩ · rcases a with ⟨a | a, h₁⟩ <;> rcases b with ⟨b | b, h₂⟩ <;> cases h₁ <;> cases h₂ <;> rintro ⟨⟩ <;> constructor <;> assumption⟩ #align ordinal.add_le_of_limit Ordinal.add_le_of_limit theorem add_isNormal (a : Ordinal) : IsNormal (a + ·) := ⟨fun b => (add_lt_add_iff_left a).2 (lt_succ b), fun _b l _c => add_le_of_limit l⟩ #align ordinal.add_is_normal Ordinal.add_isNormal theorem add_isLimit (a) {b} : IsLimit b → IsLimit (a + b) := (add_isNormal a).isLimit #align ordinal.add_is_limit Ordinal.add_isLimit alias IsLimit.add := add_isLimit #align ordinal.is_limit.add Ordinal.IsLimit.add theorem sub_nonempty {a b : Ordinal} : { o | a ≤ b + o }.Nonempty := ⟨a, le_add_left _ _⟩ #align ordinal.sub_nonempty Ordinal.sub_nonempty instance sub : Sub Ordinal := ⟨fun a b => sInf { o | a ≤ b + o }⟩ theorem le_add_sub (a b : Ordinal) : a ≤ b + (a - b) := csInf_mem sub_nonempty #align ordinal.le_add_sub Ordinal.le_add_sub theorem sub_le {a b c : Ordinal} : a - b ≤ c ↔ a ≤ b + c := ⟨fun h => (le_add_sub a b).trans (add_le_add_left h _), fun h => csInf_le' h⟩ #align ordinal.sub_le Ordinal.sub_le theorem lt_sub {a b c : Ordinal} : a < b - c ↔ c + a < b := lt_iff_lt_of_le_iff_le sub_le #align ordinal.lt_sub Ordinal.lt_sub theorem add_sub_cancel (a b : Ordinal) : a + b - a = b := le_antisymm (sub_le.2 <| le_rfl) ((add_le_add_iff_left a).1 <| le_add_sub _ _) #align ordinal.add_sub_cancel Ordinal.add_sub_cancel theorem sub_eq_of_add_eq {a b c : Ordinal} (h : a + b = c) : c - a = b := h ▸ add_sub_cancel _ _ #align ordinal.sub_eq_of_add_eq Ordinal.sub_eq_of_add_eq theorem sub_le_self (a b : Ordinal) : a - b ≤ a := sub_le.2 <| le_add_left _ _ #align ordinal.sub_le_self Ordinal.sub_le_self protected theorem add_sub_cancel_of_le {a b : Ordinal} (h : b ≤ a) : b + (a - b) = a := (le_add_sub a b).antisymm' (by rcases zero_or_succ_or_limit (a - b) with (e | ⟨c, e⟩ | l) · simp only [e, add_zero, h] · rw [e, add_succ, succ_le_iff, ← lt_sub, e] exact lt_succ c · exact (add_le_of_limit l).2 fun c l => (lt_sub.1 l).le) #align ordinal.add_sub_cancel_of_le Ordinal.add_sub_cancel_of_le theorem le_sub_of_le {a b c : Ordinal} (h : b ≤ a) : c ≤ a - b ↔ b + c ≤ a := by rw [← add_le_add_iff_left b, Ordinal.add_sub_cancel_of_le h] #align ordinal.le_sub_of_le Ordinal.le_sub_of_le theorem sub_lt_of_le {a b c : Ordinal} (h : b ≤ a) : a - b < c ↔ a < b + c := lt_iff_lt_of_le_iff_le (le_sub_of_le h) #align ordinal.sub_lt_of_le Ordinal.sub_lt_of_le instance existsAddOfLE : ExistsAddOfLE Ordinal := ⟨fun h => ⟨_, (Ordinal.add_sub_cancel_of_le h).symm⟩⟩ @[simp] theorem sub_zero (a : Ordinal) : a - 0 = a := by simpa only [zero_add] using add_sub_cancel 0 a #align ordinal.sub_zero Ordinal.sub_zero @[simp] theorem zero_sub (a : Ordinal) : 0 - a = 0 := by rw [← Ordinal.le_zero]; apply sub_le_self #align ordinal.zero_sub Ordinal.zero_sub @[simp] theorem sub_self (a : Ordinal) : a - a = 0 := by simpa only [add_zero] using add_sub_cancel a 0 #align ordinal.sub_self Ordinal.sub_self protected theorem sub_eq_zero_iff_le {a b : Ordinal} : a - b = 0 ↔ a ≤ b := ⟨fun h => by simpa only [h, add_zero] using le_add_sub a b, fun h => by rwa [← Ordinal.le_zero, sub_le, add_zero]⟩ #align ordinal.sub_eq_zero_iff_le Ordinal.sub_eq_zero_iff_le theorem sub_sub (a b c : Ordinal) : a - b - c = a - (b + c) := eq_of_forall_ge_iff fun d => by rw [sub_le, sub_le, sub_le, add_assoc] #align ordinal.sub_sub Ordinal.sub_sub @[simp] theorem add_sub_add_cancel (a b c : Ordinal) : a + b - (a + c) = b - c := by rw [← sub_sub, add_sub_cancel] #align ordinal.add_sub_add_cancel Ordinal.add_sub_add_cancel theorem sub_isLimit {a b} (l : IsLimit a) (h : b < a) : IsLimit (a - b) := ⟨ne_of_gt <| lt_sub.2 <| by rwa [add_zero], fun c h => by rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩ #align ordinal.sub_is_limit Ordinal.sub_isLimit -- @[simp] -- Porting note (#10618): simp can prove this theorem one_add_omega : 1 + ω = ω := by refine le_antisymm ?_ (le_add_left _ _) rw [omega, ← lift_one.{_, 0}, ← lift_add, lift_le, ← type_unit, ← type_sum_lex] refine ⟨RelEmbedding.collapse (RelEmbedding.ofMonotone ?_ ?_)⟩ · apply Sum.rec · exact fun _ => 0 · exact Nat.succ · intro a b cases a <;> cases b <;> intro H <;> cases' H with _ _ H _ _ H <;> [exact H.elim; exact Nat.succ_pos _; exact Nat.succ_lt_succ H] #align ordinal.one_add_omega Ordinal.one_add_omega @[simp] theorem one_add_of_omega_le {o} (h : ω ≤ o) : 1 + o = o := by rw [← Ordinal.add_sub_cancel_of_le h, ← add_assoc, one_add_omega] #align ordinal.one_add_of_omega_le Ordinal.one_add_of_omega_le instance monoid : Monoid Ordinal.{u} where mul a b := Quotient.liftOn₂ a b (fun ⟨α, r, wo⟩ ⟨β, s, wo'⟩ => ⟦⟨β × α, Prod.Lex s r, inferInstance⟩⟧ : WellOrder → WellOrder → Ordinal) fun ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩ => Quot.sound ⟨RelIso.prodLexCongr g f⟩ one := 1 mul_assoc a b c := Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ => Eq.symm <| Quotient.sound ⟨⟨prodAssoc _ _ _, @fun a b => by rcases a with ⟨⟨a₁, a₂⟩, a₃⟩ rcases b with ⟨⟨b₁, b₂⟩, b₃⟩ simp [Prod.lex_def, and_or_left, or_assoc, and_assoc]⟩⟩ mul_one a := inductionOn a fun α r _ => Quotient.sound ⟨⟨punitProd _, @fun a b => by rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩ simp only [Prod.lex_def, EmptyRelation, false_or_iff] simp only [eq_self_iff_true, true_and_iff] rfl⟩⟩ one_mul a := inductionOn a fun α r _ => Quotient.sound ⟨⟨prodPUnit _, @fun a b => by rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩ simp only [Prod.lex_def, EmptyRelation, and_false_iff, or_false_iff] rfl⟩⟩ @[simp] theorem type_prod_lex {α β : Type u} (r : α → α → Prop) (s : β → β → Prop) [IsWellOrder α r] [IsWellOrder β s] : type (Prod.Lex s r) = type r * type s := rfl #align ordinal.type_prod_lex Ordinal.type_prod_lex private theorem mul_eq_zero' {a b : Ordinal} : a * b = 0 ↔ a = 0 ∨ b = 0 := inductionOn a fun α _ _ => inductionOn b fun β _ _ => by simp_rw [← type_prod_lex, type_eq_zero_iff_isEmpty] rw [or_comm] exact isEmpty_prod instance monoidWithZero : MonoidWithZero Ordinal := { Ordinal.monoid with zero := 0 mul_zero := fun _a => mul_eq_zero'.2 <| Or.inr rfl zero_mul := fun _a => mul_eq_zero'.2 <| Or.inl rfl } instance noZeroDivisors : NoZeroDivisors Ordinal := ⟨fun {_ _} => mul_eq_zero'.1⟩ @[simp] theorem lift_mul (a b : Ordinal.{v}) : lift.{u} (a * b) = lift.{u} a * lift.{u} b := Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ => Quotient.sound ⟨(RelIso.preimage Equiv.ulift _).trans (RelIso.prodLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩ #align ordinal.lift_mul Ordinal.lift_mul @[simp] theorem card_mul (a b) : card (a * b) = card a * card b := Quotient.inductionOn₂ a b fun ⟨α, _r, _⟩ ⟨β, _s, _⟩ => mul_comm #β #α #align ordinal.card_mul Ordinal.card_mul instance leftDistribClass : LeftDistribClass Ordinal.{u} := ⟨fun a b c => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ => Quotient.sound ⟨⟨sumProdDistrib _ _ _, by rintro ⟨a₁ | a₁, a₂⟩ ⟨b₁ | b₁, b₂⟩ <;> simp only [Prod.lex_def, Sum.lex_inl_inl, Sum.Lex.sep, Sum.lex_inr_inl, Sum.lex_inr_inr, sumProdDistrib_apply_left, sumProdDistrib_apply_right] <;> -- Porting note: `Sum.inr.inj_iff` is required. simp only [Sum.inl.inj_iff, Sum.inr.inj_iff, true_or_iff, false_and_iff, false_or_iff]⟩⟩⟩ theorem mul_succ (a b : Ordinal) : a * succ b = a * b + a := mul_add_one a b #align ordinal.mul_succ Ordinal.mul_succ instance mul_covariantClass_le : CovariantClass Ordinal.{u} Ordinal.{u} (· * ·) (· ≤ ·) := ⟨fun c a b => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by refine (RelEmbedding.ofMonotone (fun a : α × γ => (f a.1, a.2)) fun a b h => ?_).ordinal_type_le cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h' · exact Prod.Lex.left _ _ (f.toRelEmbedding.map_rel_iff.2 h') · exact Prod.Lex.right _ h'⟩ #align ordinal.mul_covariant_class_le Ordinal.mul_covariantClass_le instance mul_swap_covariantClass_le : CovariantClass Ordinal.{u} Ordinal.{u} (swap (· * ·)) (· ≤ ·) := ⟨fun c a b => Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by refine (RelEmbedding.ofMonotone (fun a : γ × α => (a.1, f a.2)) fun a b h => ?_).ordinal_type_le cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h' · exact Prod.Lex.left _ _ h' · exact Prod.Lex.right _ (f.toRelEmbedding.map_rel_iff.2 h')⟩ #align ordinal.mul_swap_covariant_class_le Ordinal.mul_swap_covariantClass_le theorem le_mul_left (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ a * b := by convert mul_le_mul_left' (one_le_iff_pos.2 hb) a rw [mul_one a] #align ordinal.le_mul_left Ordinal.le_mul_left theorem le_mul_right (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ b * a := by convert mul_le_mul_right' (one_le_iff_pos.2 hb) a rw [one_mul a] #align ordinal.le_mul_right Ordinal.le_mul_right private theorem mul_le_of_limit_aux {α β r s} [IsWellOrder α r] [IsWellOrder β s] {c} (h : IsLimit (type s)) (H : ∀ b' < type s, type r * b' ≤ c) (l : c < type r * type s) : False := by suffices ∀ a b, Prod.Lex s r (b, a) (enum _ _ l) by cases' enum _ _ l with b a exact irrefl _ (this _ _) intro a b rw [← typein_lt_typein (Prod.Lex s r), typein_enum] have := H _ (h.2 _ (typein_lt_type s b)) rw [mul_succ] at this have := ((add_lt_add_iff_left _).2 (typein_lt_type _ a)).trans_le this refine (RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this · rcases a with ⟨⟨b', a'⟩, h⟩ by_cases e : b = b' · refine Sum.inr ⟨a', ?_⟩ subst e cases' h with _ _ _ _ h _ _ _ h · exact (irrefl _ h).elim · exact h · refine Sum.inl (⟨b', ?_⟩, a') cases' h with _ _ _ _ h _ _ _ h · exact h · exact (e rfl).elim · rcases a with ⟨⟨b₁, a₁⟩, h₁⟩ rcases b with ⟨⟨b₂, a₂⟩, h₂⟩ intro h by_cases e₁ : b = b₁ <;> by_cases e₂ : b = b₂ · substs b₁ b₂ simpa only [subrel_val, Prod.lex_def, @irrefl _ s _ b, true_and_iff, false_or_iff, eq_self_iff_true, dif_pos, Sum.lex_inr_inr] using h · subst b₁ simp only [subrel_val, Prod.lex_def, e₂, Prod.lex_def, dif_pos, subrel_val, eq_self_iff_true, or_false_iff, dif_neg, not_false_iff, Sum.lex_inr_inl, false_and_iff] at h ⊢ cases' h₂ with _ _ _ _ h₂_h h₂_h <;> [exact asymm h h₂_h; exact e₂ rfl] -- Porting note: `cc` hadn't ported yet. · simp [e₂, dif_neg e₁, show b₂ ≠ b₁ from e₂ ▸ e₁] · simpa only [dif_neg e₁, dif_neg e₂, Prod.lex_def, subrel_val, Subtype.mk_eq_mk, Sum.lex_inl_inl] using h theorem mul_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c := ⟨fun h b' l => (mul_le_mul_left' l.le _).trans h, fun H => -- Porting note: `induction` tactics are required because of the parser bug. le_of_not_lt <| by induction a using inductionOn with | H α r => induction b using inductionOn with | H β s => exact mul_le_of_limit_aux h H⟩ #align ordinal.mul_le_of_limit Ordinal.mul_le_of_limit theorem mul_isNormal {a : Ordinal} (h : 0 < a) : IsNormal (a * ·) := -- Porting note(#12129): additional beta reduction needed ⟨fun b => by beta_reduce rw [mul_succ] simpa only [add_zero] using (add_lt_add_iff_left (a * b)).2 h, fun b l c => mul_le_of_limit l⟩ #align ordinal.mul_is_normal Ordinal.mul_isNormal theorem lt_mul_of_limit {a b c : Ordinal} (h : IsLimit c) : a < b * c ↔ ∃ c' < c, a < b * c' := by -- Porting note: `bex_def` is required. simpa only [not_forall₂, not_le, bex_def] using not_congr (@mul_le_of_limit b c a h) #align ordinal.lt_mul_of_limit Ordinal.lt_mul_of_limit theorem mul_lt_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c := (mul_isNormal a0).lt_iff #align ordinal.mul_lt_mul_iff_left Ordinal.mul_lt_mul_iff_left theorem mul_le_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c := (mul_isNormal a0).le_iff #align ordinal.mul_le_mul_iff_left Ordinal.mul_le_mul_iff_left theorem mul_lt_mul_of_pos_left {a b c : Ordinal} (h : a < b) (c0 : 0 < c) : c * a < c * b := (mul_lt_mul_iff_left c0).2 h #align ordinal.mul_lt_mul_of_pos_left Ordinal.mul_lt_mul_of_pos_left theorem mul_pos {a b : Ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b := by simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁ #align ordinal.mul_pos Ordinal.mul_pos theorem mul_ne_zero {a b : Ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 := by simpa only [Ordinal.pos_iff_ne_zero] using mul_pos #align ordinal.mul_ne_zero Ordinal.mul_ne_zero theorem le_of_mul_le_mul_left {a b c : Ordinal} (h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b := le_imp_le_of_lt_imp_lt (fun h' => mul_lt_mul_of_pos_left h' h0) h #align ordinal.le_of_mul_le_mul_left Ordinal.le_of_mul_le_mul_left theorem mul_right_inj {a b c : Ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c := (mul_isNormal a0).inj #align ordinal.mul_right_inj Ordinal.mul_right_inj theorem mul_isLimit {a b : Ordinal} (a0 : 0 < a) : IsLimit b → IsLimit (a * b) := (mul_isNormal a0).isLimit #align ordinal.mul_is_limit Ordinal.mul_isLimit theorem mul_isLimit_left {a b : Ordinal} (l : IsLimit a) (b0 : 0 < b) : IsLimit (a * b) := by rcases zero_or_succ_or_limit b with (rfl | ⟨b, rfl⟩ | lb) · exact b0.false.elim · rw [mul_succ] exact add_isLimit _ l · exact mul_isLimit l.pos lb #align ordinal.mul_is_limit_left Ordinal.mul_isLimit_left theorem smul_eq_mul : ∀ (n : ℕ) (a : Ordinal), n • a = a * n | 0, a => by rw [zero_nsmul, Nat.cast_zero, mul_zero] | n + 1, a => by rw [succ_nsmul, Nat.cast_add, mul_add, Nat.cast_one, mul_one, smul_eq_mul n] #align ordinal.smul_eq_mul Ordinal.smul_eq_mul theorem div_nonempty {a b : Ordinal} (h : b ≠ 0) : { o | a < b * succ o }.Nonempty := ⟨a, (succ_le_iff (a := a) (b := b * succ a)).1 <| by simpa only [succ_zero, one_mul] using mul_le_mul_right' (succ_le_of_lt (Ordinal.pos_iff_ne_zero.2 h)) (succ a)⟩ #align ordinal.div_nonempty Ordinal.div_nonempty instance div : Div Ordinal := ⟨fun a b => if _h : b = 0 then 0 else sInf { o | a < b * succ o }⟩ @[simp] theorem div_zero (a : Ordinal) : a / 0 = 0 := dif_pos rfl #align ordinal.div_zero Ordinal.div_zero theorem div_def (a) {b : Ordinal} (h : b ≠ 0) : a / b = sInf { o | a < b * succ o } := dif_neg h #align ordinal.div_def Ordinal.div_def theorem lt_mul_succ_div (a) {b : Ordinal} (h : b ≠ 0) : a < b * succ (a / b) := by rw [div_def a h]; exact csInf_mem (div_nonempty h) #align ordinal.lt_mul_succ_div Ordinal.lt_mul_succ_div theorem lt_mul_div_add (a) {b : Ordinal} (h : b ≠ 0) : a < b * (a / b) + b := by simpa only [mul_succ] using lt_mul_succ_div a h #align ordinal.lt_mul_div_add Ordinal.lt_mul_div_add theorem div_le {a b c : Ordinal} (b0 : b ≠ 0) : a / b ≤ c ↔ a < b * succ c := ⟨fun h => (lt_mul_succ_div a b0).trans_le (mul_le_mul_left' (succ_le_succ_iff.2 h) _), fun h => by rw [div_def a b0]; exact csInf_le' h⟩ #align ordinal.div_le Ordinal.div_le theorem lt_div {a b c : Ordinal} (h : c ≠ 0) : a < b / c ↔ c * succ a ≤ b := by rw [← not_le, div_le h, not_lt] #align ordinal.lt_div Ordinal.lt_div theorem div_pos {b c : Ordinal} (h : c ≠ 0) : 0 < b / c ↔ c ≤ b := by simp [lt_div h] #align ordinal.div_pos Ordinal.div_pos theorem le_div {a b c : Ordinal} (c0 : c ≠ 0) : a ≤ b / c ↔ c * a ≤ b := by induction a using limitRecOn with | H₁ => simp only [mul_zero, Ordinal.zero_le] | H₂ _ _ => rw [succ_le_iff, lt_div c0] | H₃ _ h₁ h₂ => revert h₁ h₂ simp (config := { contextual := true }) only [mul_le_of_limit, limit_le, iff_self_iff, forall_true_iff] #align ordinal.le_div Ordinal.le_div theorem div_lt {a b c : Ordinal} (b0 : b ≠ 0) : a / b < c ↔ a < b * c := lt_iff_lt_of_le_iff_le <| le_div b0 #align ordinal.div_lt Ordinal.div_lt theorem div_le_of_le_mul {a b c : Ordinal} (h : a ≤ b * c) : a / b ≤ c := if b0 : b = 0 then by simp only [b0, div_zero, Ordinal.zero_le] else (div_le b0).2 <| h.trans_lt <| mul_lt_mul_of_pos_left (lt_succ c) (Ordinal.pos_iff_ne_zero.2 b0) #align ordinal.div_le_of_le_mul Ordinal.div_le_of_le_mul theorem mul_lt_of_lt_div {a b c : Ordinal} : a < b / c → c * a < b := lt_imp_lt_of_le_imp_le div_le_of_le_mul #align ordinal.mul_lt_of_lt_div Ordinal.mul_lt_of_lt_div @[simp] theorem zero_div (a : Ordinal) : 0 / a = 0 := Ordinal.le_zero.1 <| div_le_of_le_mul <| Ordinal.zero_le _ #align ordinal.zero_div Ordinal.zero_div theorem mul_div_le (a b : Ordinal) : b * (a / b) ≤ a := if b0 : b = 0 then by simp only [b0, zero_mul, Ordinal.zero_le] else (le_div b0).1 le_rfl #align ordinal.mul_div_le Ordinal.mul_div_le theorem mul_add_div (a) {b : Ordinal} (b0 : b ≠ 0) (c) : (b * a + c) / b = a + c / b := by apply le_antisymm · apply (div_le b0).2 rw [mul_succ, mul_add, add_assoc, add_lt_add_iff_left] apply lt_mul_div_add _ b0 · rw [le_div b0, mul_add, add_le_add_iff_left] apply mul_div_le #align ordinal.mul_add_div Ordinal.mul_add_div theorem div_eq_zero_of_lt {a b : Ordinal} (h : a < b) : a / b = 0 := by rw [← Ordinal.le_zero, div_le <| Ordinal.pos_iff_ne_zero.1 <| (Ordinal.zero_le _).trans_lt h] simpa only [succ_zero, mul_one] using h #align ordinal.div_eq_zero_of_lt Ordinal.div_eq_zero_of_lt @[simp] theorem mul_div_cancel (a) {b : Ordinal} (b0 : b ≠ 0) : b * a / b = a := by simpa only [add_zero, zero_div] using mul_add_div a b0 0 #align ordinal.mul_div_cancel Ordinal.mul_div_cancel @[simp] theorem div_one (a : Ordinal) : a / 1 = a := by simpa only [one_mul] using mul_div_cancel a Ordinal.one_ne_zero #align ordinal.div_one Ordinal.div_one @[simp] theorem div_self {a : Ordinal} (h : a ≠ 0) : a / a = 1 := by simpa only [mul_one] using mul_div_cancel 1 h #align ordinal.div_self Ordinal.div_self theorem mul_sub (a b c : Ordinal) : a * (b - c) = a * b - a * c := if a0 : a = 0 then by simp only [a0, zero_mul, sub_self] else eq_of_forall_ge_iff fun d => by rw [sub_le, ← le_div a0, sub_le, ← le_div a0, mul_add_div _ a0] #align ordinal.mul_sub Ordinal.mul_sub theorem isLimit_add_iff {a b} : IsLimit (a + b) ↔ IsLimit b ∨ b = 0 ∧ IsLimit a := by constructor <;> intro h · by_cases h' : b = 0 · rw [h', add_zero] at h right exact ⟨h', h⟩ left rw [← add_sub_cancel a b] apply sub_isLimit h suffices a + 0 < a + b by simpa only [add_zero] using this rwa [add_lt_add_iff_left, Ordinal.pos_iff_ne_zero] rcases h with (h | ⟨rfl, h⟩) · exact add_isLimit a h · simpa only [add_zero] #align ordinal.is_limit_add_iff Ordinal.isLimit_add_iff theorem dvd_add_iff : ∀ {a b c : Ordinal}, a ∣ b → (a ∣ b + c ↔ a ∣ c) | a, _, c, ⟨b, rfl⟩ => ⟨fun ⟨d, e⟩ => ⟨d - b, by rw [mul_sub, ← e, add_sub_cancel]⟩, fun ⟨d, e⟩ => by rw [e, ← mul_add] apply dvd_mul_right⟩ #align ordinal.dvd_add_iff Ordinal.dvd_add_iff theorem div_mul_cancel : ∀ {a b : Ordinal}, a ≠ 0 → a ∣ b → a * (b / a) = b | a, _, a0, ⟨b, rfl⟩ => by rw [mul_div_cancel _ a0] #align ordinal.div_mul_cancel Ordinal.div_mul_cancel theorem le_of_dvd : ∀ {a b : Ordinal}, b ≠ 0 → a ∣ b → a ≤ b -- Porting note: `⟨b, rfl⟩ => by` → `⟨b, e⟩ => by subst e` | a, _, b0, ⟨b, e⟩ => by subst e -- Porting note: `Ne` is required. simpa only [mul_one] using mul_le_mul_left' (one_le_iff_ne_zero.2 fun h : b = 0 => by simp only [h, mul_zero, Ne, not_true_eq_false] at b0) a #align ordinal.le_of_dvd Ordinal.le_of_dvd theorem dvd_antisymm {a b : Ordinal} (h₁ : a ∣ b) (h₂ : b ∣ a) : a = b := if a0 : a = 0 then by subst a; exact (eq_zero_of_zero_dvd h₁).symm else if b0 : b = 0 then by subst b; exact eq_zero_of_zero_dvd h₂ else (le_of_dvd b0 h₁).antisymm (le_of_dvd a0 h₂) #align ordinal.dvd_antisymm Ordinal.dvd_antisymm instance isAntisymm : IsAntisymm Ordinal (· ∣ ·) := ⟨@dvd_antisymm⟩ instance mod : Mod Ordinal := ⟨fun a b => a - b * (a / b)⟩ theorem mod_def (a b : Ordinal) : a % b = a - b * (a / b) := rfl #align ordinal.mod_def Ordinal.mod_def theorem mod_le (a b : Ordinal) : a % b ≤ a := sub_le_self a _ #align ordinal.mod_le Ordinal.mod_le @[simp] theorem mod_zero (a : Ordinal) : a % 0 = a := by simp only [mod_def, div_zero, zero_mul, sub_zero] #align ordinal.mod_zero Ordinal.mod_zero theorem mod_eq_of_lt {a b : Ordinal} (h : a < b) : a % b = a := by simp only [mod_def, div_eq_zero_of_lt h, mul_zero, sub_zero] #align ordinal.mod_eq_of_lt Ordinal.mod_eq_of_lt @[simp] theorem zero_mod (b : Ordinal) : 0 % b = 0 := by simp only [mod_def, zero_div, mul_zero, sub_self] #align ordinal.zero_mod Ordinal.zero_mod theorem div_add_mod (a b : Ordinal) : b * (a / b) + a % b = a := Ordinal.add_sub_cancel_of_le <| mul_div_le _ _ #align ordinal.div_add_mod Ordinal.div_add_mod theorem mod_lt (a) {b : Ordinal} (h : b ≠ 0) : a % b < b := (add_lt_add_iff_left (b * (a / b))).1 <| by rw [div_add_mod]; exact lt_mul_div_add a h #align ordinal.mod_lt Ordinal.mod_lt @[simp] theorem mod_self (a : Ordinal) : a % a = 0 := if a0 : a = 0 then by simp only [a0, zero_mod] else by simp only [mod_def, div_self a0, mul_one, sub_self] #align ordinal.mod_self Ordinal.mod_self @[simp] theorem mod_one (a : Ordinal) : a % 1 = 0 := by simp only [mod_def, div_one, one_mul, sub_self] #align ordinal.mod_one Ordinal.mod_one theorem dvd_of_mod_eq_zero {a b : Ordinal} (H : a % b = 0) : b ∣ a := ⟨a / b, by simpa [H] using (div_add_mod a b).symm⟩ #align ordinal.dvd_of_mod_eq_zero Ordinal.dvd_of_mod_eq_zero theorem mod_eq_zero_of_dvd {a b : Ordinal} (H : b ∣ a) : a % b = 0 := by rcases H with ⟨c, rfl⟩ rcases eq_or_ne b 0 with (rfl | hb) · simp · simp [mod_def, hb] #align ordinal.mod_eq_zero_of_dvd Ordinal.mod_eq_zero_of_dvd theorem dvd_iff_mod_eq_zero {a b : Ordinal} : b ∣ a ↔ a % b = 0 := ⟨mod_eq_zero_of_dvd, dvd_of_mod_eq_zero⟩ #align ordinal.dvd_iff_mod_eq_zero Ordinal.dvd_iff_mod_eq_zero @[simp] theorem mul_add_mod_self (x y z : Ordinal) : (x * y + z) % x = z % x := by rcases eq_or_ne x 0 with rfl | hx · simp · rwa [mod_def, mul_add_div, mul_add, ← sub_sub, add_sub_cancel, mod_def] #align ordinal.mul_add_mod_self Ordinal.mul_add_mod_self @[simp] theorem mul_mod (x y : Ordinal) : x * y % x = 0 := by simpa using mul_add_mod_self x y 0 #align ordinal.mul_mod Ordinal.mul_mod theorem mod_mod_of_dvd (a : Ordinal) {b c : Ordinal} (h : c ∣ b) : a % b % c = a % c := by nth_rw 2 [← div_add_mod a b] rcases h with ⟨d, rfl⟩ rw [mul_assoc, mul_add_mod_self] #align ordinal.mod_mod_of_dvd Ordinal.mod_mod_of_dvd @[simp] theorem mod_mod (a b : Ordinal) : a % b % b = a % b := mod_mod_of_dvd a dvd_rfl #align ordinal.mod_mod Ordinal.mod_mod def bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) : ∀ a < type r, α := fun a ha => f (enum r a ha) #align ordinal.bfamily_of_family' Ordinal.bfamilyOfFamily' def bfamilyOfFamily {ι : Type u} : (ι → α) → ∀ a < type (@WellOrderingRel ι), α := bfamilyOfFamily' WellOrderingRel #align ordinal.bfamily_of_family Ordinal.bfamilyOfFamily def familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) : ι → α := fun i => f (typein r i) (by rw [← ho] exact typein_lt_type r i) #align ordinal.family_of_bfamily' Ordinal.familyOfBFamily' def familyOfBFamily (o : Ordinal) (f : ∀ a < o, α) : o.out.α → α := familyOfBFamily' (· < ·) (type_lt o) f #align ordinal.family_of_bfamily Ordinal.familyOfBFamily @[simp] theorem bfamilyOfFamily'_typein {ι} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) (i) : bfamilyOfFamily' r f (typein r i) (typein_lt_type r i) = f i := by simp only [bfamilyOfFamily', enum_typein] #align ordinal.bfamily_of_family'_typein Ordinal.bfamilyOfFamily'_typein @[simp] theorem bfamilyOfFamily_typein {ι} (f : ι → α) (i) : bfamilyOfFamily f (typein _ i) (typein_lt_type _ i) = f i := bfamilyOfFamily'_typein _ f i #align ordinal.bfamily_of_family_typein Ordinal.bfamilyOfFamily_typein @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this theorem familyOfBFamily'_enum {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) (i hi) : familyOfBFamily' r ho f (enum r i (by rwa [ho])) = f i hi := by simp only [familyOfBFamily', typein_enum] #align ordinal.family_of_bfamily'_enum Ordinal.familyOfBFamily'_enum @[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this theorem familyOfBFamily_enum (o : Ordinal) (f : ∀ a < o, α) (i hi) : familyOfBFamily o f (enum (· < ·) i (by convert hi exact type_lt _)) = f i hi := familyOfBFamily'_enum _ (type_lt o) f _ _ #align ordinal.family_of_bfamily_enum Ordinal.familyOfBFamily_enum def brange (o : Ordinal) (f : ∀ a < o, α) : Set α := { a | ∃ i hi, f i hi = a } #align ordinal.brange Ordinal.brange theorem mem_brange {o : Ordinal} {f : ∀ a < o, α} {a} : a ∈ brange o f ↔ ∃ i hi, f i hi = a := Iff.rfl #align ordinal.mem_brange Ordinal.mem_brange theorem mem_brange_self {o} (f : ∀ a < o, α) (i hi) : f i hi ∈ brange o f := ⟨i, hi, rfl⟩ #align ordinal.mem_brange_self Ordinal.mem_brange_self @[simp] theorem range_familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) : range (familyOfBFamily' r ho f) = brange o f := by refine Set.ext fun a => ⟨?_, ?_⟩ · rintro ⟨b, rfl⟩ apply mem_brange_self · rintro ⟨i, hi, rfl⟩ exact ⟨_, familyOfBFamily'_enum _ _ _ _ _⟩ #align ordinal.range_family_of_bfamily' Ordinal.range_familyOfBFamily' @[simp] theorem range_familyOfBFamily {o} (f : ∀ a < o, α) : range (familyOfBFamily o f) = brange o f := range_familyOfBFamily' _ _ f #align ordinal.range_family_of_bfamily Ordinal.range_familyOfBFamily @[simp] theorem brange_bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) : brange _ (bfamilyOfFamily' r f) = range f := by refine Set.ext fun a => ⟨?_, ?_⟩ · rintro ⟨i, hi, rfl⟩ apply mem_range_self · rintro ⟨b, rfl⟩ exact ⟨_, _, bfamilyOfFamily'_typein _ _ _⟩ #align ordinal.brange_bfamily_of_family' Ordinal.brange_bfamilyOfFamily' @[simp] theorem brange_bfamilyOfFamily {ι : Type u} (f : ι → α) : brange _ (bfamilyOfFamily f) = range f := brange_bfamilyOfFamily' _ _ #align ordinal.brange_bfamily_of_family Ordinal.brange_bfamilyOfFamily @[simp] theorem brange_const {o : Ordinal} (ho : o ≠ 0) {c : α} : (brange o fun _ _ => c) = {c} := by rw [← range_familyOfBFamily] exact @Set.range_const _ o.out.α (out_nonempty_iff_ne_zero.2 ho) c #align ordinal.brange_const Ordinal.brange_const theorem comp_bfamilyOfFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] (f : ι → α) (g : α → β) : (fun i hi => g (bfamilyOfFamily' r f i hi)) = bfamilyOfFamily' r (g ∘ f) := rfl #align ordinal.comp_bfamily_of_family' Ordinal.comp_bfamilyOfFamily' theorem comp_bfamilyOfFamily {ι : Type u} (f : ι → α) (g : α → β) : (fun i hi => g (bfamilyOfFamily f i hi)) = bfamilyOfFamily (g ∘ f) := rfl #align ordinal.comp_bfamily_of_family Ordinal.comp_bfamilyOfFamily theorem comp_familyOfBFamily' {ι : Type u} (r : ι → ι → Prop) [IsWellOrder ι r] {o} (ho : type r = o) (f : ∀ a < o, α) (g : α → β) : g ∘ familyOfBFamily' r ho f = familyOfBFamily' r ho fun i hi => g (f i hi) := rfl #align ordinal.comp_family_of_bfamily' Ordinal.comp_familyOfBFamily' theorem comp_familyOfBFamily {o} (f : ∀ a < o, α) (g : α → β) : g ∘ familyOfBFamily o f = familyOfBFamily o fun i hi => g (f i hi) := rfl #align ordinal.comp_family_of_bfamily Ordinal.comp_familyOfBFamily -- Porting note: Universes should be specified in `sup`s. def sup {ι : Type u} (f : ι → Ordinal.{max u v}) : Ordinal.{max u v} := iSup f #align ordinal.sup Ordinal.sup @[simp] theorem sSup_eq_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : sSup (Set.range f) = sup.{_, v} f := rfl #align ordinal.Sup_eq_sup Ordinal.sSup_eq_sup theorem bddAbove_range {ι : Type u} (f : ι → Ordinal.{max u v}) : BddAbove (Set.range f) := ⟨(iSup (succ ∘ card ∘ f)).ord, by rintro a ⟨i, rfl⟩ exact le_of_lt (Cardinal.lt_ord.2 ((lt_succ _).trans_le (le_ciSup (Cardinal.bddAbove_range.{_, v} _) _)))⟩ #align ordinal.bdd_above_range Ordinal.bddAbove_range theorem le_sup {ι : Type u} (f : ι → Ordinal.{max u v}) : ∀ i, f i ≤ sup.{_, v} f := fun i => le_csSup (bddAbove_range.{_, v} f) (mem_range_self i) #align ordinal.le_sup Ordinal.le_sup theorem sup_le_iff {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : sup.{_, v} f ≤ a ↔ ∀ i, f i ≤ a := (csSup_le_iff' (bddAbove_range.{_, v} f)).trans (by simp) #align ordinal.sup_le_iff Ordinal.sup_le_iff theorem sup_le {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : (∀ i, f i ≤ a) → sup.{_, v} f ≤ a := sup_le_iff.2 #align ordinal.sup_le Ordinal.sup_le theorem lt_sup {ι : Type u} {f : ι → Ordinal.{max u v}} {a} : a < sup.{_, v} f ↔ ∃ i, a < f i := by simpa only [not_forall, not_le] using not_congr (@sup_le_iff.{_, v} _ f a) #align ordinal.lt_sup Ordinal.lt_sup theorem ne_sup_iff_lt_sup {ι : Type u} {f : ι → Ordinal.{max u v}} : (∀ i, f i ≠ sup.{_, v} f) ↔ ∀ i, f i < sup.{_, v} f := ⟨fun hf _ => lt_of_le_of_ne (le_sup _ _) (hf _), fun hf _ => ne_of_lt (hf _)⟩ #align ordinal.ne_sup_iff_lt_sup Ordinal.ne_sup_iff_lt_sup theorem sup_not_succ_of_ne_sup {ι : Type u} {f : ι → Ordinal.{max u v}} (hf : ∀ i, f i ≠ sup.{_, v} f) {a} (hao : a < sup.{_, v} f) : succ a < sup.{_, v} f := by by_contra! hoa exact hao.not_le (sup_le fun i => le_of_lt_succ <| (lt_of_le_of_ne (le_sup _ _) (hf i)).trans_le hoa) #align ordinal.sup_not_succ_of_ne_sup Ordinal.sup_not_succ_of_ne_sup @[simp] theorem sup_eq_zero_iff {ι : Type u} {f : ι → Ordinal.{max u v}} : sup.{_, v} f = 0 ↔ ∀ i, f i = 0 := by refine ⟨fun h i => ?_, fun h => le_antisymm (sup_le fun i => Ordinal.le_zero.2 (h i)) (Ordinal.zero_le _)⟩ rw [← Ordinal.le_zero, ← h] exact le_sup f i #align ordinal.sup_eq_zero_iff Ordinal.sup_eq_zero_iff theorem IsNormal.sup {f : Ordinal.{max u v} → Ordinal.{max u w}} (H : IsNormal f) {ι : Type u} (g : ι → Ordinal.{max u v}) [Nonempty ι] : f (sup.{_, v} g) = sup.{_, w} (f ∘ g) := eq_of_forall_ge_iff fun a => by rw [sup_le_iff]; simp only [comp]; rw [H.le_set' Set.univ Set.univ_nonempty g] <;> simp [sup_le_iff] #align ordinal.is_normal.sup Ordinal.IsNormal.sup @[simp] theorem sup_empty {ι} [IsEmpty ι] (f : ι → Ordinal) : sup f = 0 := ciSup_of_empty f #align ordinal.sup_empty Ordinal.sup_empty @[simp] theorem sup_const {ι} [_hι : Nonempty ι] (o : Ordinal) : (sup fun _ : ι => o) = o := ciSup_const #align ordinal.sup_const Ordinal.sup_const @[simp] theorem sup_unique {ι} [Unique ι] (f : ι → Ordinal) : sup f = f default := ciSup_unique #align ordinal.sup_unique Ordinal.sup_unique theorem sup_le_of_range_subset {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f ⊆ Set.range g) : sup.{u, max v w} f ≤ sup.{v, max u w} g := sup_le fun i => match h (mem_range_self i) with | ⟨_j, hj⟩ => hj ▸ le_sup _ _ #align ordinal.sup_le_of_range_subset Ordinal.sup_le_of_range_subset theorem sup_eq_of_range_eq {ι ι'} {f : ι → Ordinal} {g : ι' → Ordinal} (h : Set.range f = Set.range g) : sup.{u, max v w} f = sup.{v, max u w} g := (sup_le_of_range_subset.{u, v, w} h.le).antisymm (sup_le_of_range_subset.{v, u, w} h.ge) #align ordinal.sup_eq_of_range_eq Ordinal.sup_eq_of_range_eq @[simp]
Mathlib/SetTheory/Ordinal/Arithmetic.lean
1,332
1,342
theorem sup_sum {α : Type u} {β : Type v} (f : Sum α β → Ordinal) : sup.{max u v, w} f = max (sup.{u, max v w} fun a => f (Sum.inl a)) (sup.{v, max u w} fun b => f (Sum.inr b)) := by
apply (sup_le_iff.2 _).antisymm (max_le_iff.2 ⟨_, _⟩) · rintro (i | i) · exact le_max_of_le_left (le_sup _ i) · exact le_max_of_le_right (le_sup _ i) all_goals apply sup_le_of_range_subset.{_, max u v, w} rintro i ⟨a, rfl⟩ apply mem_range_self
import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Data.Setoid.Basic import Mathlib.Dynamics.FixedPoints.Topology import Mathlib.Topology.MetricSpace.Lipschitz #align_import topology.metric_space.contracting from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" open scoped Classical open NNReal Topology ENNReal Filter Function variable {α : Type*} def ContractingWith [EMetricSpace α] (K : ℝ≥0) (f : α → α) := K < 1 ∧ LipschitzWith K f #align contracting_with ContractingWith namespace ContractingWith variable [EMetricSpace α] [cs : CompleteSpace α] {K : ℝ≥0} {f : α → α} open EMetric Set theorem toLipschitzWith (hf : ContractingWith K f) : LipschitzWith K f := hf.2 #align contracting_with.to_lipschitz_with ContractingWith.toLipschitzWith theorem one_sub_K_pos' (hf : ContractingWith K f) : (0 : ℝ≥0∞) < 1 - K := by simp [hf.1] set_option linter.uppercaseLean3 false in #align contracting_with.one_sub_K_pos' ContractingWith.one_sub_K_pos' theorem one_sub_K_ne_zero (hf : ContractingWith K f) : (1 : ℝ≥0∞) - K ≠ 0 := ne_of_gt hf.one_sub_K_pos' set_option linter.uppercaseLean3 false in #align contracting_with.one_sub_K_ne_zero ContractingWith.one_sub_K_ne_zero theorem one_sub_K_ne_top : (1 : ℝ≥0∞) - K ≠ ∞ := by norm_cast exact ENNReal.coe_ne_top set_option linter.uppercaseLean3 false in #align contracting_with.one_sub_K_ne_top ContractingWith.one_sub_K_ne_top theorem edist_inequality (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞) : edist x y ≤ (edist x (f x) + edist y (f y)) / (1 - K) := suffices edist x y ≤ edist x (f x) + edist y (f y) + K * edist x y by rwa [ENNReal.le_div_iff_mul_le (Or.inl hf.one_sub_K_ne_zero) (Or.inl one_sub_K_ne_top), mul_comm, ENNReal.sub_mul fun _ _ ↦ h, one_mul, tsub_le_iff_right] calc edist x y ≤ edist x (f x) + edist (f x) (f y) + edist (f y) y := edist_triangle4 _ _ _ _ _ = edist x (f x) + edist y (f y) + edist (f x) (f y) := by rw [edist_comm y, add_right_comm] _ ≤ edist x (f x) + edist y (f y) + K * edist x y := add_le_add le_rfl (hf.2 _ _) #align contracting_with.edist_inequality ContractingWith.edist_inequality theorem edist_le_of_fixedPoint (hf : ContractingWith K f) {x y} (h : edist x y ≠ ∞) (hy : IsFixedPt f y) : edist x y ≤ edist x (f x) / (1 - K) := by simpa only [hy.eq, edist_self, add_zero] using hf.edist_inequality h #align contracting_with.edist_le_of_fixed_point ContractingWith.edist_le_of_fixedPoint theorem eq_or_edist_eq_top_of_fixedPoints (hf : ContractingWith K f) {x y} (hx : IsFixedPt f x) (hy : IsFixedPt f y) : x = y ∨ edist x y = ∞ := by refine or_iff_not_imp_right.2 fun h ↦ edist_le_zero.1 ?_ simpa only [hx.eq, edist_self, add_zero, ENNReal.zero_div] using hf.edist_le_of_fixedPoint h hy #align contracting_with.eq_or_edist_eq_top_of_fixed_points ContractingWith.eq_or_edist_eq_top_of_fixedPoints theorem restrict (hf : ContractingWith K f) {s : Set α} (hs : MapsTo f s s) : ContractingWith K (hs.restrict f s s) := ⟨hf.1, fun x y ↦ hf.2 x y⟩ #align contracting_with.restrict ContractingWith.restrict theorem exists_fixedPoint (hf : ContractingWith K f) (x : α) (hx : edist x (f x) ≠ ∞) : ∃ y, IsFixedPt f y ∧ Tendsto (fun n ↦ f^[n] x) atTop (𝓝 y) ∧ ∀ n : ℕ, edist (f^[n] x) y ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) := have : CauchySeq fun n ↦ f^[n] x := cauchySeq_of_edist_le_geometric K (edist x (f x)) (ENNReal.coe_lt_one_iff.2 hf.1) hx (hf.toLipschitzWith.edist_iterate_succ_le_geometric x) let ⟨y, hy⟩ := cauchySeq_tendsto_of_complete this ⟨y, isFixedPt_of_tendsto_iterate hy hf.2.continuous.continuousAt, hy, edist_le_of_edist_le_geometric_of_tendsto K (edist x (f x)) (hf.toLipschitzWith.edist_iterate_succ_le_geometric x) hy⟩ #align contracting_with.exists_fixed_point ContractingWith.exists_fixedPoint variable (f) -- avoid `efixedPoint _` in pretty printer noncomputable def efixedPoint (hf : ContractingWith K f) (x : α) (hx : edist x (f x) ≠ ∞) : α := Classical.choose <| hf.exists_fixedPoint x hx #align contracting_with.efixed_point ContractingWith.efixedPoint variable {f} theorem efixedPoint_isFixedPt (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : IsFixedPt f (efixedPoint f hf x hx) := (Classical.choose_spec <| hf.exists_fixedPoint x hx).1 #align contracting_with.efixed_point_is_fixed_pt ContractingWith.efixedPoint_isFixedPt theorem tendsto_iterate_efixedPoint (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| efixedPoint f hf x hx) := (Classical.choose_spec <| hf.exists_fixedPoint x hx).2.1 #align contracting_with.tendsto_iterate_efixed_point ContractingWith.tendsto_iterate_efixedPoint theorem apriori_edist_iterate_efixedPoint_le (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) (n : ℕ) : edist (f^[n] x) (efixedPoint f hf x hx) ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) := (Classical.choose_spec <| hf.exists_fixedPoint x hx).2.2 n #align contracting_with.apriori_edist_iterate_efixed_point_le ContractingWith.apriori_edist_iterate_efixedPoint_le theorem edist_efixedPoint_le (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint f hf x hx) ≤ edist x (f x) / (1 - K) := by convert hf.apriori_edist_iterate_efixedPoint_le hx 0 simp only [pow_zero, mul_one] #align contracting_with.edist_efixed_point_le ContractingWith.edist_efixedPoint_le theorem edist_efixedPoint_lt_top (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint f hf x hx) < ∞ := (hf.edist_efixedPoint_le hx).trans_lt (ENNReal.mul_lt_top hx <| ENNReal.inv_ne_top.2 hf.one_sub_K_ne_zero) #align contracting_with.edist_efixed_point_lt_top ContractingWith.edist_efixedPoint_lt_top theorem efixedPoint_eq_of_edist_lt_top (hf : ContractingWith K f) {x : α} (hx : edist x (f x) ≠ ∞) {y : α} (hy : edist y (f y) ≠ ∞) (h : edist x y ≠ ∞) : efixedPoint f hf x hx = efixedPoint f hf y hy := by refine (hf.eq_or_edist_eq_top_of_fixedPoints ?_ ?_).elim id fun h' ↦ False.elim (ne_of_lt ?_ h') <;> try apply efixedPoint_isFixedPt change edistLtTopSetoid.Rel _ _ trans x · apply Setoid.symm' -- Porting note: Originally `symm` exact hf.edist_efixedPoint_lt_top hx trans y exacts [lt_top_iff_ne_top.2 h, hf.edist_efixedPoint_lt_top hy] #align contracting_with.efixed_point_eq_of_edist_lt_top ContractingWith.efixedPoint_eq_of_edist_lt_top theorem exists_fixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : ∃ y ∈ s, IsFixedPt f y ∧ Tendsto (fun n ↦ f^[n] x) atTop (𝓝 y) ∧ ∀ n : ℕ, edist (f^[n] x) y ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) := by haveI := hsc.completeSpace_coe rcases hf.exists_fixedPoint ⟨x, hxs⟩ hx with ⟨y, hfy, h_tendsto, hle⟩ refine ⟨y, y.2, Subtype.ext_iff_val.1 hfy, ?_, fun n ↦ ?_⟩ · convert (continuous_subtype_val.tendsto _).comp h_tendsto simp only [(· ∘ ·), MapsTo.iterate_restrict, MapsTo.val_restrict_apply] · convert hle n rw [MapsTo.iterate_restrict] rfl #align contracting_with.exists_fixed_point' ContractingWith.exists_fixedPoint' variable (f) -- avoid `efixedPoint _` in pretty printer noncomputable def efixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) (x : α) (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : α := Classical.choose <| hf.exists_fixedPoint' hsc hsf hxs hx #align contracting_with.efixed_point' ContractingWith.efixedPoint' variable {f} theorem efixedPoint_mem' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : efixedPoint' f hsc hsf hf x hxs hx ∈ s := (Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).1 #align contracting_with.efixed_point_mem' ContractingWith.efixedPoint_mem' theorem efixedPoint_isFixedPt' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : IsFixedPt f (efixedPoint' f hsc hsf hf x hxs hx) := (Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.1 #align contracting_with.efixed_point_is_fixed_pt' ContractingWith.efixedPoint_isFixedPt' theorem tendsto_iterate_efixedPoint' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : Tendsto (fun n ↦ f^[n] x) atTop (𝓝 <| efixedPoint' f hsc hsf hf x hxs hx) := (Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.2.1 #align contracting_with.tendsto_iterate_efixed_point' ContractingWith.tendsto_iterate_efixedPoint' theorem apriori_edist_iterate_efixedPoint_le' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) (n : ℕ) : edist (f^[n] x) (efixedPoint' f hsc hsf hf x hxs hx) ≤ edist x (f x) * (K : ℝ≥0∞) ^ n / (1 - K) := (Classical.choose_spec <| hf.exists_fixedPoint' hsc hsf hxs hx).2.2.2 n #align contracting_with.apriori_edist_iterate_efixed_point_le' ContractingWith.apriori_edist_iterate_efixedPoint_le' theorem edist_efixedPoint_le' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint' f hsc hsf hf x hxs hx) ≤ edist x (f x) / (1 - K) := by convert hf.apriori_edist_iterate_efixedPoint_le' hsc hsf hxs hx 0 rw [pow_zero, mul_one] #align contracting_with.edist_efixed_point_le' ContractingWith.edist_efixedPoint_le' theorem edist_efixedPoint_lt_top' {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hf : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) : edist x (efixedPoint' f hsc hsf hf x hxs hx) < ∞ := (hf.edist_efixedPoint_le' hsc hsf hxs hx).trans_lt (ENNReal.mul_lt_top hx <| ENNReal.inv_ne_top.2 hf.one_sub_K_ne_zero) #align contracting_with.edist_efixed_point_lt_top' ContractingWith.edist_efixedPoint_lt_top'
Mathlib/Topology/MetricSpace/Contracting.lean
243
257
theorem efixedPoint_eq_of_edist_lt_top' (hf : ContractingWith K f) {s : Set α} (hsc : IsComplete s) (hsf : MapsTo f s s) (hfs : ContractingWith K <| hsf.restrict f s s) {x : α} (hxs : x ∈ s) (hx : edist x (f x) ≠ ∞) {t : Set α} (htc : IsComplete t) (htf : MapsTo f t t) (hft : ContractingWith K <| htf.restrict f t t) {y : α} (hyt : y ∈ t) (hy : edist y (f y) ≠ ∞) (hxy : edist x y ≠ ∞) : efixedPoint' f hsc hsf hfs x hxs hx = efixedPoint' f htc htf hft y hyt hy := by
refine (hf.eq_or_edist_eq_top_of_fixedPoints ?_ ?_).elim id fun h' ↦ False.elim (ne_of_lt ?_ h') <;> try apply efixedPoint_isFixedPt' change edistLtTopSetoid.Rel _ _ trans x · apply Setoid.symm' -- Porting note: Originally `symm` apply edist_efixedPoint_lt_top' trans y · exact lt_top_iff_ne_top.2 hxy · apply edist_efixedPoint_lt_top'
import Mathlib.LinearAlgebra.QuadraticForm.TensorProduct import Mathlib.LinearAlgebra.CliffordAlgebra.Conjugation import Mathlib.LinearAlgebra.TensorProduct.Opposite import Mathlib.RingTheory.TensorProduct.Basic variable {R A V : Type*} variable [CommRing R] [CommRing A] [AddCommGroup V] variable [Algebra R A] [Module R V] [Module A V] [IsScalarTower R A V] variable [Invertible (2 : R)] open scoped TensorProduct namespace CliffordAlgebra variable (A) -- `noncomputable` is a performance workaround for mathlib4#7103 noncomputable def ofBaseChangeAux (Q : QuadraticForm R V) : CliffordAlgebra Q →ₐ[R] CliffordAlgebra (Q.baseChange A) := CliffordAlgebra.lift Q <| by refine ⟨(ι (Q.baseChange A)).restrictScalars R ∘ₗ TensorProduct.mk R A V 1, fun v => ?_⟩ refine (CliffordAlgebra.ι_sq_scalar (Q.baseChange A) (1 ⊗ₜ v)).trans ?_ rw [QuadraticForm.baseChange_tmul, one_mul, ← Algebra.algebraMap_eq_smul_one, ← IsScalarTower.algebraMap_apply] @[simp] theorem ofBaseChangeAux_ι (Q : QuadraticForm R V) (v : V) : ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (1 ⊗ₜ v) := CliffordAlgebra.lift_ι_apply _ _ v -- `noncomputable` is a performance workaround for mathlib4#7103 noncomputable def ofBaseChange (Q : QuadraticForm R V) : A ⊗[R] CliffordAlgebra Q →ₐ[A] CliffordAlgebra (Q.baseChange A) := Algebra.TensorProduct.lift (Algebra.ofId _ _) (ofBaseChangeAux A Q) fun _a _x => Algebra.commutes _ _ @[simp] theorem ofBaseChange_tmul_ι (Q : QuadraticForm R V) (z : A) (v : V) : ofBaseChange A Q (z ⊗ₜ ι Q v) = ι (Q.baseChange A) (z ⊗ₜ v) := by show algebraMap _ _ z * ofBaseChangeAux A Q (ι Q v) = ι (Q.baseChange A) (z ⊗ₜ[R] v) rw [ofBaseChangeAux_ι, ← Algebra.smul_def, ← map_smul, TensorProduct.smul_tmul', smul_eq_mul, mul_one] @[simp] theorem ofBaseChange_tmul_one (Q : QuadraticForm R V) (z : A) : ofBaseChange A Q (z ⊗ₜ 1) = algebraMap _ _ z := by show algebraMap _ _ z * ofBaseChangeAux A Q 1 = _ rw [map_one, mul_one] -- `noncomputable` is a performance workaround for mathlib4#7103 noncomputable def toBaseChange (Q : QuadraticForm R V) : CliffordAlgebra (Q.baseChange A) →ₐ[A] A ⊗[R] CliffordAlgebra Q := CliffordAlgebra.lift _ <| by refine ⟨TensorProduct.AlgebraTensorModule.map (LinearMap.id : A →ₗ[A] A) (ι Q), ?_⟩ letI : Invertible (2 : A) := (Invertible.map (algebraMap R A) 2).copy 2 (map_ofNat _ _).symm letI : Invertible (2 : A ⊗[R] CliffordAlgebra Q) := (Invertible.map (algebraMap R _) 2).copy 2 (map_ofNat _ _).symm suffices hpure_tensor : ∀ v w, (1 * 1) ⊗ₜ[R] (ι Q v * ι Q w) + (1 * 1) ⊗ₜ[R] (ι Q w * ι Q v) = QuadraticForm.polarBilin (Q.baseChange A) (1 ⊗ₜ[R] v) (1 ⊗ₜ[R] w) ⊗ₜ[R] 1 by -- the crux is that by converting to a statement about linear maps instead of quadratic forms, -- we then have access to all the partially-applied `ext` lemmas. rw [CliffordAlgebra.forall_mul_self_eq_iff (isUnit_of_invertible _)] refine TensorProduct.AlgebraTensorModule.curry_injective ?_ ext v w exact hpure_tensor v w intros v w rw [← TensorProduct.tmul_add, CliffordAlgebra.ι_mul_ι_add_swap, QuadraticForm.polarBilin_baseChange, LinearMap.BilinForm.baseChange_tmul, one_mul, TensorProduct.smul_tmul, Algebra.algebraMap_eq_smul_one, QuadraticForm.polarBilin_apply_apply] @[simp] theorem toBaseChange_ι (Q : QuadraticForm R V) (z : A) (v : V) : toBaseChange A Q (ι (Q.baseChange A) (z ⊗ₜ v)) = z ⊗ₜ ι Q v := CliffordAlgebra.lift_ι_apply _ _ _ theorem toBaseChange_comp_involute (Q : QuadraticForm R V) : (toBaseChange A Q).comp (involute : CliffordAlgebra (Q.baseChange A) →ₐ[A] _) = (Algebra.TensorProduct.map (AlgHom.id _ _) involute).comp (toBaseChange A Q) := by ext v show toBaseChange A Q (involute (ι (Q.baseChange A) (1 ⊗ₜ[R] v))) = (Algebra.TensorProduct.map (AlgHom.id _ _) involute : A ⊗[R] CliffordAlgebra Q →ₐ[A] _) (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v))) rw [toBaseChange_ι, involute_ι, map_neg (toBaseChange A Q), toBaseChange_ι, Algebra.TensorProduct.map_tmul, AlgHom.id_apply, involute_ι, TensorProduct.tmul_neg] theorem toBaseChange_involute (Q : QuadraticForm R V) (x : CliffordAlgebra (Q.baseChange A)) : toBaseChange A Q (involute x) = TensorProduct.map LinearMap.id (involute.toLinearMap) (toBaseChange A Q x) := DFunLike.congr_fun (toBaseChange_comp_involute A Q) x open MulOpposite
Mathlib/LinearAlgebra/CliffordAlgebra/BaseChange.lean
124
137
theorem toBaseChange_comp_reverseOp (Q : QuadraticForm R V) : (toBaseChange A Q).op.comp reverseOp = ((Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q)).toAlgHom.comp <| (Algebra.TensorProduct.map (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q))).comp (toBaseChange A Q)) := by
ext v show op (toBaseChange A Q (reverse (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))) = Algebra.TensorProduct.opAlgEquiv R A A (CliffordAlgebra Q) (Algebra.TensorProduct.map (AlgEquiv.toOpposite A A).toAlgHom (reverseOp (Q := Q)) (toBaseChange A Q (ι (Q.baseChange A) (1 ⊗ₜ[R] v)))) rw [toBaseChange_ι, reverse_ι, toBaseChange_ι, Algebra.TensorProduct.map_tmul, Algebra.TensorProduct.opAlgEquiv_tmul, reverseOp_ι] rfl
import Mathlib.SetTheory.Game.Basic import Mathlib.Tactic.NthRewrite #align_import set_theory.game.impartial from "leanprover-community/mathlib"@"2e0975f6a25dd3fbfb9e41556a77f075f6269748" universe u namespace SetTheory open scoped PGame namespace PGame def ImpartialAux : PGame → Prop | G => (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) termination_by G => G -- Porting note: Added `termination_by` #align pgame.impartial_aux SetTheory.PGame.ImpartialAux theorem impartialAux_def {G : PGame} : G.ImpartialAux ↔ (G ≈ -G) ∧ (∀ i, ImpartialAux (G.moveLeft i)) ∧ ∀ j, ImpartialAux (G.moveRight j) := by rw [ImpartialAux] #align pgame.impartial_aux_def SetTheory.PGame.impartialAux_def class Impartial (G : PGame) : Prop where out : ImpartialAux G #align pgame.impartial SetTheory.PGame.Impartial theorem impartial_iff_aux {G : PGame} : G.Impartial ↔ G.ImpartialAux := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align pgame.impartial_iff_aux SetTheory.PGame.impartial_iff_aux theorem impartial_def {G : PGame} : G.Impartial ↔ (G ≈ -G) ∧ (∀ i, Impartial (G.moveLeft i)) ∧ ∀ j, Impartial (G.moveRight j) := by simpa only [impartial_iff_aux] using impartialAux_def #align pgame.impartial_def SetTheory.PGame.impartial_def namespace Impartial instance impartial_zero : Impartial 0 := by rw [impartial_def]; dsimp; simp #align pgame.impartial.impartial_zero SetTheory.PGame.Impartial.impartial_zero instance impartial_star : Impartial star := by rw [impartial_def]; simpa using Impartial.impartial_zero #align pgame.impartial.impartial_star SetTheory.PGame.Impartial.impartial_star theorem neg_equiv_self (G : PGame) [h : G.Impartial] : G ≈ -G := (impartial_def.1 h).1 #align pgame.impartial.neg_equiv_self SetTheory.PGame.Impartial.neg_equiv_self -- Porting note: Changed `-⟦G⟧` to `-(⟦G⟧ : Quotient setoid)` @[simp] theorem mk'_neg_equiv_self (G : PGame) [G.Impartial] : -(⟦G⟧ : Quotient setoid) = ⟦G⟧ := Quot.sound (Equiv.symm (neg_equiv_self G)) #align pgame.impartial.mk_neg_equiv_self SetTheory.PGame.Impartial.mk'_neg_equiv_self instance moveLeft_impartial {G : PGame} [h : G.Impartial] (i : G.LeftMoves) : (G.moveLeft i).Impartial := (impartial_def.1 h).2.1 i #align pgame.impartial.move_left_impartial SetTheory.PGame.Impartial.moveLeft_impartial instance moveRight_impartial {G : PGame} [h : G.Impartial] (j : G.RightMoves) : (G.moveRight j).Impartial := (impartial_def.1 h).2.2 j #align pgame.impartial.move_right_impartial SetTheory.PGame.Impartial.moveRight_impartial theorem impartial_congr : ∀ {G H : PGame} (_ : G ≡r H) [G.Impartial], H.Impartial | G, H => fun e => by intro h exact impartial_def.2 ⟨Equiv.trans e.symm.equiv (Equiv.trans (neg_equiv_self G) (neg_equiv_neg_iff.2 e.equiv)), fun i => impartial_congr (e.moveLeftSymm i), fun j => impartial_congr (e.moveRightSymm j)⟩ termination_by G H => (G, H) #align pgame.impartial.impartial_congr SetTheory.PGame.Impartial.impartial_congr instance impartial_add : ∀ (G H : PGame) [G.Impartial] [H.Impartial], (G + H).Impartial | G, H, _, _ => by rw [impartial_def] refine ⟨Equiv.trans (add_congr (neg_equiv_self G) (neg_equiv_self _)) (Equiv.symm (negAddRelabelling _ _).equiv), fun k => ?_, fun k => ?_⟩ · apply leftMoves_add_cases k all_goals intro i; simp only [add_moveLeft_inl, add_moveLeft_inr] apply impartial_add · apply rightMoves_add_cases k all_goals intro i; simp only [add_moveRight_inl, add_moveRight_inr] apply impartial_add termination_by G H => (G, H) #align pgame.impartial.impartial_add SetTheory.PGame.Impartial.impartial_add instance impartial_neg : ∀ (G : PGame) [G.Impartial], (-G).Impartial | G, _ => by rw [impartial_def] refine ⟨?_, fun i => ?_, fun i => ?_⟩ · rw [neg_neg] exact Equiv.symm (neg_equiv_self G) · rw [moveLeft_neg'] apply impartial_neg · rw [moveRight_neg'] apply impartial_neg termination_by G => G #align pgame.impartial.impartial_neg SetTheory.PGame.Impartial.impartial_neg variable (G : PGame) [Impartial G] theorem nonpos : ¬0 < G := fun h => by have h' := neg_lt_neg_iff.2 h rw [neg_zero, lt_congr_left (Equiv.symm (neg_equiv_self G))] at h' exact (h.trans h').false #align pgame.impartial.nonpos SetTheory.PGame.Impartial.nonpos theorem nonneg : ¬G < 0 := fun h => by have h' := neg_lt_neg_iff.2 h rw [neg_zero, lt_congr_right (Equiv.symm (neg_equiv_self G))] at h' exact (h.trans h').false #align pgame.impartial.nonneg SetTheory.PGame.Impartial.nonneg
Mathlib/SetTheory/Game/Impartial.lean
137
142
theorem equiv_or_fuzzy_zero : (G ≈ 0) ∨ G ‖ 0 := by
rcases lt_or_equiv_or_gt_or_fuzzy G 0 with (h | h | h | h) · exact ((nonneg G) h).elim · exact Or.inl h · exact ((nonpos G) h).elim · exact Or.inr h
import Mathlib.Topology.Constructions #align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494" open Set Filter Function Topology Filter variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*} variable [TopologicalSpace α] @[simp] theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a := bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl #align nhds_bind_nhds_within nhds_bind_nhdsWithin @[simp] theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x } #align eventually_nhds_nhds_within eventually_nhds_nhdsWithin theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x := eventually_inf_principal #align eventually_nhds_within_iff eventually_nhdsWithin_iff theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} : (∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s := frequently_inf_principal.trans <| by simp only [and_comm] #align frequently_nhds_within_iff frequently_nhdsWithin_iff theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} : z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff] #align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within @[simp] theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} : (∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩ simp only [eventually_nhdsWithin_iff] at h ⊢ exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs #align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin theorem nhdsWithin_eq (a : α) (s : Set α) : 𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) := ((nhds_basis_opens a).inf_principal s).eq_biInf #align nhds_within_eq nhdsWithin_eq theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by rw [nhdsWithin, principal_univ, inf_top_eq] #align nhds_within_univ nhdsWithin_univ theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s) (t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t := h.inf_principal t #align nhds_within_has_basis nhdsWithin_hasBasis theorem nhdsWithin_basis_open (a : α) (t : Set α) : (𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t := nhdsWithin_hasBasis (nhds_basis_opens a) t #align nhds_within_basis_open nhdsWithin_basis_open theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff #align mem_nhds_within mem_nhdsWithin theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} : t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t := (nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff #align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) : s \ t ∈ 𝓝[tᶜ] x := diff_mem_inf_principal_compl hs t #align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) : s \ t' ∈ 𝓝[t \ t'] x := by rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc] exact inter_mem_inf hs (mem_principal_self _) #align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) : t ∈ 𝓝 a := by rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩ exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw #align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t := eventually_inf_principal #align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} : t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and] #align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t := set_eventuallyEq_iff_inf_principal.symm #align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x := set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal #align nhds_within_le_iff nhdsWithin_le_iff -- Porting note: golfed, dropped an unneeded assumption theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝[t] a := by lift a to t using h replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs rwa [← map_nhds_subtype_val, mem_map] #align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a := mem_inf_of_left h #align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a := mem_inf_of_right (mem_principal_self s) #align self_mem_nhds_within self_mem_nhdsWithin theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s := self_mem_nhdsWithin #align eventually_mem_nhds_within eventually_mem_nhdsWithin theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a := inter_mem self_mem_nhdsWithin (mem_inf_of_left h) #align inter_mem_nhds_within inter_mem_nhdsWithin theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a := inf_le_inf_left _ (principal_mono.mpr h) #align nhds_within_mono nhdsWithin_mono theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a := le_inf (pure_le_nhds a) (le_principal_iff.2 ha) #align pure_le_nhds_within pure_le_nhdsWithin theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t := pure_le_nhdsWithin ha ht #align mem_of_mem_nhds_within mem_of_mem_nhdsWithin theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α} (h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x := mem_of_mem_nhdsWithin hx h #align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) : Tendsto (fun _ : β => a) l (𝓝[s] a) := tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha #align tendsto_const_nhds_within tendsto_const_nhdsWithin theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s] a = 𝓝[s ∩ t] a := le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h))) (inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left)) #align nhds_within_restrict'' nhdsWithin_restrict'' theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict'' s <| mem_inf_of_left h #align nhds_within_restrict' nhdsWithin_restrict' theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) : 𝓝[s] a = 𝓝[s ∩ t] a := nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀) #align nhds_within_restrict nhdsWithin_restrict theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a := nhdsWithin_le_iff.mpr h #align nhds_within_le_of_mem nhdsWithin_le_of_mem theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by rw [← nhdsWithin_univ] apply nhdsWithin_le_of_mem exact univ_mem #align nhds_within_le_nhds nhdsWithin_le_nhds theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂] #align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin' theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s) (h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂] #align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin @[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a := inf_eq_left.trans le_principal_iff #align nhds_within_eq_nhds nhdsWithin_eq_nhds theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a := nhdsWithin_eq_nhds.2 <| h.mem_nhds ha #align is_open.nhds_within_eq IsOpen.nhdsWithin_eq theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t) (ht : IsOpen t) (hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) : π ⁻¹' s ∈ 𝓝 a := by rw [← ht.nhdsWithin_eq h] exact preimage_nhdsWithin_coinduced' h hs #align preimage_nhds_within_coinduced preimage_nhds_within_coinduced @[simp] theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq] #align nhds_within_empty nhdsWithin_empty theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by delta nhdsWithin rw [← inf_sup_left, sup_principal] #align nhds_within_union nhdsWithin_union theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) : 𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a := Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert] #align nhds_within_bUnion nhdsWithin_biUnion theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) : 𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS] #align nhds_within_sUnion nhdsWithin_sUnion theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) : 𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range] #align nhds_within_Union nhdsWithin_iUnion theorem nhdsWithin_inter (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓝[t] a := by delta nhdsWithin rw [inf_left_comm, inf_assoc, inf_principal, ← inf_assoc, inf_idem] #align nhds_within_inter nhdsWithin_inter theorem nhdsWithin_inter' (a : α) (s t : Set α) : 𝓝[s ∩ t] a = 𝓝[s] a ⊓ 𝓟 t := by delta nhdsWithin rw [← inf_principal, inf_assoc] #align nhds_within_inter' nhdsWithin_inter' theorem nhdsWithin_inter_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[s ∩ t] a = 𝓝[t] a := by rw [nhdsWithin_inter, inf_eq_right] exact nhdsWithin_le_of_mem h #align nhds_within_inter_of_mem nhdsWithin_inter_of_mem theorem nhdsWithin_inter_of_mem' {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : 𝓝[s ∩ t] a = 𝓝[s] a := by rw [inter_comm, nhdsWithin_inter_of_mem h] #align nhds_within_inter_of_mem' nhdsWithin_inter_of_mem' @[simp] theorem nhdsWithin_singleton (a : α) : 𝓝[{a}] a = pure a := by rw [nhdsWithin, principal_singleton, inf_eq_right.2 (pure_le_nhds a)] #align nhds_within_singleton nhdsWithin_singleton @[simp] theorem nhdsWithin_insert (a : α) (s : Set α) : 𝓝[insert a s] a = pure a ⊔ 𝓝[s] a := by rw [← singleton_union, nhdsWithin_union, nhdsWithin_singleton] #align nhds_within_insert nhdsWithin_insert theorem mem_nhdsWithin_insert {a : α} {s t : Set α} : t ∈ 𝓝[insert a s] a ↔ a ∈ t ∧ t ∈ 𝓝[s] a := by simp #align mem_nhds_within_insert mem_nhdsWithin_insert theorem insert_mem_nhdsWithin_insert {a : α} {s t : Set α} (h : t ∈ 𝓝[s] a) : insert a t ∈ 𝓝[insert a s] a := by simp [mem_of_superset h] #align insert_mem_nhds_within_insert insert_mem_nhdsWithin_insert theorem insert_mem_nhds_iff {a : α} {s : Set α} : insert a s ∈ 𝓝 a ↔ s ∈ 𝓝[≠] a := by simp only [nhdsWithin, mem_inf_principal, mem_compl_iff, mem_singleton_iff, or_iff_not_imp_left, insert_def] #align insert_mem_nhds_iff insert_mem_nhds_iff @[simp] theorem nhdsWithin_compl_singleton_sup_pure (a : α) : 𝓝[≠] a ⊔ pure a = 𝓝 a := by rw [← nhdsWithin_singleton, ← nhdsWithin_union, compl_union_self, nhdsWithin_univ] #align nhds_within_compl_singleton_sup_pure nhdsWithin_compl_singleton_sup_pure theorem nhdsWithin_prod {α : Type*} [TopologicalSpace α] {β : Type*} [TopologicalSpace β] {s u : Set α} {t v : Set β} {a : α} {b : β} (hu : u ∈ 𝓝[s] a) (hv : v ∈ 𝓝[t] b) : u ×ˢ v ∈ 𝓝[s ×ˢ t] (a, b) := by rw [nhdsWithin_prod_eq] exact prod_mem_prod hu hv #align nhds_within_prod nhdsWithin_prod theorem nhdsWithin_pi_eq' {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = ⨅ i, comap (fun x => x i) (𝓝 (x i) ⊓ ⨅ (_ : i ∈ I), 𝓟 (s i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, comap_inf, comap_iInf, pi_def, comap_principal, ← iInf_principal_finite hI, ← iInf_inf_eq] #align nhds_within_pi_eq' nhdsWithin_pi_eq' theorem nhdsWithin_pi_eq {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} (hI : I.Finite) (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi I s] x = (⨅ i ∈ I, comap (fun x => x i) (𝓝[s i] x i)) ⊓ ⨅ (i) (_ : i ∉ I), comap (fun x => x i) (𝓝 (x i)) := by simp only [nhdsWithin, nhds_pi, Filter.pi, pi_def, ← iInf_principal_finite hI, comap_inf, comap_principal, eval] rw [iInf_split _ fun i => i ∈ I, inf_right_comm] simp only [iInf_inf_eq] #align nhds_within_pi_eq nhdsWithin_pi_eq theorem nhdsWithin_pi_univ_eq {ι : Type*} {α : ι → Type*} [Finite ι] [∀ i, TopologicalSpace (α i)] (s : ∀ i, Set (α i)) (x : ∀ i, α i) : 𝓝[pi univ s] x = ⨅ i, comap (fun x => x i) (𝓝[s i] x i) := by simpa [nhdsWithin] using nhdsWithin_pi_eq finite_univ s x #align nhds_within_pi_univ_eq nhdsWithin_pi_univ_eq theorem nhdsWithin_pi_eq_bot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : 𝓝[pi I s] x = ⊥ ↔ ∃ i ∈ I, 𝓝[s i] x i = ⊥ := by simp only [nhdsWithin, nhds_pi, pi_inf_principal_pi_eq_bot] #align nhds_within_pi_eq_bot nhdsWithin_pi_eq_bot theorem nhdsWithin_pi_neBot {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : (𝓝[pi I s] x).NeBot ↔ ∀ i ∈ I, (𝓝[s i] x i).NeBot := by simp [neBot_iff, nhdsWithin_pi_eq_bot] #align nhds_within_pi_ne_bot nhdsWithin_pi_neBot theorem Filter.Tendsto.piecewise_nhdsWithin {f g : α → β} {t : Set α} [∀ x, Decidable (x ∈ t)] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ t] a) l) (h₁ : Tendsto g (𝓝[s ∩ tᶜ] a) l) : Tendsto (piecewise t f g) (𝓝[s] a) l := by apply Tendsto.piecewise <;> rwa [← nhdsWithin_inter'] #align filter.tendsto.piecewise_nhds_within Filter.Tendsto.piecewise_nhdsWithin theorem Filter.Tendsto.if_nhdsWithin {f g : α → β} {p : α → Prop} [DecidablePred p] {a : α} {s : Set α} {l : Filter β} (h₀ : Tendsto f (𝓝[s ∩ { x | p x }] a) l) (h₁ : Tendsto g (𝓝[s ∩ { x | ¬p x }] a) l) : Tendsto (fun x => if p x then f x else g x) (𝓝[s] a) l := h₀.piecewise_nhdsWithin h₁ #align filter.tendsto.if_nhds_within Filter.Tendsto.if_nhdsWithin theorem map_nhdsWithin (f : α → β) (a : α) (s : Set α) : map f (𝓝[s] a) = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (f '' (t ∩ s)) := ((nhdsWithin_basis_open a s).map f).eq_biInf #align map_nhds_within map_nhdsWithin theorem tendsto_nhdsWithin_mono_left {f : α → β} {a : α} {s t : Set α} {l : Filter β} (hst : s ⊆ t) (h : Tendsto f (𝓝[t] a) l) : Tendsto f (𝓝[s] a) l := h.mono_left <| nhdsWithin_mono a hst #align tendsto_nhds_within_mono_left tendsto_nhdsWithin_mono_left theorem tendsto_nhdsWithin_mono_right {f : β → α} {l : Filter β} {a : α} {s t : Set α} (hst : s ⊆ t) (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝[t] a) := h.mono_right (nhdsWithin_mono a hst) #align tendsto_nhds_within_mono_right tendsto_nhdsWithin_mono_right theorem tendsto_nhdsWithin_of_tendsto_nhds {f : α → β} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f (𝓝 a) l) : Tendsto f (𝓝[s] a) l := h.mono_left inf_le_left #align tendsto_nhds_within_of_tendsto_nhds tendsto_nhdsWithin_of_tendsto_nhds theorem eventually_mem_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : ∀ᶠ i in l, f i ∈ s := by simp_rw [nhdsWithin_eq, tendsto_iInf, mem_setOf_eq, tendsto_principal, mem_inter_iff, eventually_and] at h exact (h univ ⟨mem_univ a, isOpen_univ⟩).2 #align eventually_mem_of_tendsto_nhds_within eventually_mem_of_tendsto_nhdsWithin theorem tendsto_nhds_of_tendsto_nhdsWithin {f : β → α} {a : α} {s : Set α} {l : Filter β} (h : Tendsto f l (𝓝[s] a)) : Tendsto f l (𝓝 a) := h.mono_right nhdsWithin_le_nhds #align tendsto_nhds_of_tendsto_nhds_within tendsto_nhds_of_tendsto_nhdsWithin theorem nhdsWithin_neBot_of_mem {s : Set α} {x : α} (hx : x ∈ s) : NeBot (𝓝[s] x) := mem_closure_iff_nhdsWithin_neBot.1 <| subset_closure hx #align nhds_within_ne_bot_of_mem nhdsWithin_neBot_of_mem theorem IsClosed.mem_of_nhdsWithin_neBot {s : Set α} (hs : IsClosed s) {x : α} (hx : NeBot <| 𝓝[s] x) : x ∈ s := hs.closure_eq ▸ mem_closure_iff_nhdsWithin_neBot.2 hx #align is_closed.mem_of_nhds_within_ne_bot IsClosed.mem_of_nhdsWithin_neBot theorem DenseRange.nhdsWithin_neBot {ι : Type*} {f : ι → α} (h : DenseRange f) (x : α) : NeBot (𝓝[range f] x) := mem_closure_iff_clusterPt.1 (h x) #align dense_range.nhds_within_ne_bot DenseRange.nhdsWithin_neBot theorem mem_closure_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {I : Set ι} {s : ∀ i, Set (α i)} {x : ∀ i, α i} : x ∈ closure (pi I s) ↔ ∀ i ∈ I, x i ∈ closure (s i) := by simp only [mem_closure_iff_nhdsWithin_neBot, nhdsWithin_pi_neBot] #align mem_closure_pi mem_closure_pi theorem closure_pi_set {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] (I : Set ι) (s : ∀ i, Set (α i)) : closure (pi I s) = pi I fun i => closure (s i) := Set.ext fun _ => mem_closure_pi #align closure_pi_set closure_pi_set theorem dense_pi {ι : Type*} {α : ι → Type*} [∀ i, TopologicalSpace (α i)] {s : ∀ i, Set (α i)} (I : Set ι) (hs : ∀ i ∈ I, Dense (s i)) : Dense (pi I s) := by simp only [dense_iff_closure_eq, closure_pi_set, pi_congr rfl fun i hi => (hs i hi).closure_eq, pi_univ] #align dense_pi dense_pi theorem eventuallyEq_nhdsWithin_iff {f g : α → β} {s : Set α} {a : α} : f =ᶠ[𝓝[s] a] g ↔ ∀ᶠ x in 𝓝 a, x ∈ s → f x = g x := mem_inf_principal #align eventually_eq_nhds_within_iff eventuallyEq_nhdsWithin_iff theorem eventuallyEq_nhdsWithin_of_eqOn {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := mem_inf_of_right h #align eventually_eq_nhds_within_of_eq_on eventuallyEq_nhdsWithin_of_eqOn theorem Set.EqOn.eventuallyEq_nhdsWithin {f g : α → β} {s : Set α} {a : α} (h : EqOn f g s) : f =ᶠ[𝓝[s] a] g := eventuallyEq_nhdsWithin_of_eqOn h #align set.eq_on.eventually_eq_nhds_within Set.EqOn.eventuallyEq_nhdsWithin theorem tendsto_nhdsWithin_congr {f g : α → β} {s : Set α} {a : α} {l : Filter β} (hfg : ∀ x ∈ s, f x = g x) (hf : Tendsto f (𝓝[s] a) l) : Tendsto g (𝓝[s] a) l := (tendsto_congr' <| eventuallyEq_nhdsWithin_of_eqOn hfg).1 hf #align tendsto_nhds_within_congr tendsto_nhdsWithin_congr theorem eventually_nhdsWithin_of_forall {s : Set α} {a : α} {p : α → Prop} (h : ∀ x ∈ s, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_inf_of_right h #align eventually_nhds_within_of_forall eventually_nhdsWithin_of_forall theorem tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within {a : α} {l : Filter β} {s : Set α} (f : β → α) (h1 : Tendsto f l (𝓝 a)) (h2 : ∀ᶠ x in l, f x ∈ s) : Tendsto f l (𝓝[s] a) := tendsto_inf.2 ⟨h1, tendsto_principal.2 h2⟩ #align tendsto_nhds_within_of_tendsto_nhds_of_eventually_within tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within theorem tendsto_nhdsWithin_iff {a : α} {l : Filter β} {s : Set α} {f : β → α} : Tendsto f l (𝓝[s] a) ↔ Tendsto f l (𝓝 a) ∧ ∀ᶠ n in l, f n ∈ s := ⟨fun h => ⟨tendsto_nhds_of_tendsto_nhdsWithin h, eventually_mem_of_tendsto_nhdsWithin h⟩, fun h => tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _ h.1 h.2⟩ #align tendsto_nhds_within_iff tendsto_nhdsWithin_iff @[simp] theorem tendsto_nhdsWithin_range {a : α} {l : Filter β} {f : β → α} : Tendsto f l (𝓝[range f] a) ↔ Tendsto f l (𝓝 a) := ⟨fun h => h.mono_right inf_le_left, fun h => tendsto_inf.2 ⟨h, tendsto_principal.2 <| eventually_of_forall mem_range_self⟩⟩ #align tendsto_nhds_within_range tendsto_nhdsWithin_range theorem Filter.EventuallyEq.eq_of_nhdsWithin {s : Set α} {f g : α → β} {a : α} (h : f =ᶠ[𝓝[s] a] g) (hmem : a ∈ s) : f a = g a := h.self_of_nhdsWithin hmem #align filter.eventually_eq.eq_of_nhds_within Filter.EventuallyEq.eq_of_nhdsWithin theorem eventually_nhdsWithin_of_eventually_nhds {α : Type*} [TopologicalSpace α] {s : Set α} {a : α} {p : α → Prop} (h : ∀ᶠ x in 𝓝 a, p x) : ∀ᶠ x in 𝓝[s] a, p x := mem_nhdsWithin_of_mem_nhds h #align eventually_nhds_within_of_eventually_nhds eventually_nhdsWithin_of_eventually_nhds theorem mem_nhdsWithin_subtype {s : Set α} {a : { x // x ∈ s }} {t u : Set { x // x ∈ s }} : t ∈ 𝓝[u] a ↔ t ∈ comap ((↑) : s → α) (𝓝[(↑) '' u] a) := by rw [nhdsWithin, nhds_subtype, principal_subtype, ← comap_inf, ← nhdsWithin] #align mem_nhds_within_subtype mem_nhdsWithin_subtype theorem nhdsWithin_subtype (s : Set α) (a : { x // x ∈ s }) (t : Set { x // x ∈ s }) : 𝓝[t] a = comap ((↑) : s → α) (𝓝[(↑) '' t] a) := Filter.ext fun _ => mem_nhdsWithin_subtype #align nhds_within_subtype nhdsWithin_subtype theorem nhdsWithin_eq_map_subtype_coe {s : Set α} {a : α} (h : a ∈ s) : 𝓝[s] a = map ((↑) : s → α) (𝓝 ⟨a, h⟩) := (map_nhds_subtype_val ⟨a, h⟩).symm #align nhds_within_eq_map_subtype_coe nhdsWithin_eq_map_subtype_coe theorem mem_nhds_subtype_iff_nhdsWithin {s : Set α} {a : s} {t : Set s} : t ∈ 𝓝 a ↔ (↑) '' t ∈ 𝓝[s] (a : α) := by rw [← map_nhds_subtype_val, image_mem_map_iff Subtype.val_injective] #align mem_nhds_subtype_iff_nhds_within mem_nhds_subtype_iff_nhdsWithin theorem preimage_coe_mem_nhds_subtype {s t : Set α} {a : s} : (↑) ⁻¹' t ∈ 𝓝 a ↔ t ∈ 𝓝[s] ↑a := by rw [← map_nhds_subtype_val, mem_map] #align preimage_coe_mem_nhds_subtype preimage_coe_mem_nhds_subtype theorem eventually_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∀ᶠ x : s in 𝓝 a, P x) ↔ ∀ᶠ x in 𝓝[s] a, P x := preimage_coe_mem_nhds_subtype theorem frequently_nhds_subtype_iff (s : Set α) (a : s) (P : α → Prop) : (∃ᶠ x : s in 𝓝 a, P x) ↔ ∃ᶠ x in 𝓝[s] a, P x := eventually_nhds_subtype_iff s a (¬ P ·) |>.not theorem tendsto_nhdsWithin_iff_subtype {s : Set α} {a : α} (h : a ∈ s) (f : α → β) (l : Filter β) : Tendsto f (𝓝[s] a) l ↔ Tendsto (s.restrict f) (𝓝 ⟨a, h⟩) l := by rw [nhdsWithin_eq_map_subtype_coe h, tendsto_map'_iff]; rfl #align tendsto_nhds_within_iff_subtype tendsto_nhdsWithin_iff_subtype variable [TopologicalSpace β] [TopologicalSpace γ] [TopologicalSpace δ] theorem ContinuousWithinAt.tendsto {f : α → β} {s : Set α} {x : α} (h : ContinuousWithinAt f s x) : Tendsto f (𝓝[s] x) (𝓝 (f x)) := h #align continuous_within_at.tendsto ContinuousWithinAt.tendsto theorem ContinuousOn.continuousWithinAt {f : α → β} {s : Set α} {x : α} (hf : ContinuousOn f s) (hx : x ∈ s) : ContinuousWithinAt f s x := hf x hx #align continuous_on.continuous_within_at ContinuousOn.continuousWithinAt theorem continuousWithinAt_univ (f : α → β) (x : α) : ContinuousWithinAt f Set.univ x ↔ ContinuousAt f x := by rw [ContinuousAt, ContinuousWithinAt, nhdsWithin_univ] #align continuous_within_at_univ continuousWithinAt_univ
Mathlib/Topology/ContinuousOn.lean
533
535
theorem continuous_iff_continuousOn_univ {f : α → β} : Continuous f ↔ ContinuousOn f univ := by
simp [continuous_iff_continuousAt, ContinuousOn, ContinuousAt, ContinuousWithinAt, nhdsWithin_univ]
import Mathlib.Data.Int.Bitwise import Mathlib.Data.Int.Order.Lemmas import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.Basic #align_import data.int.lemmas from "leanprover-community/mathlib"@"09597669f02422ed388036273d8848119699c22f" open Nat namespace Int theorem le_natCast_sub (m n : ℕ) : (m - n : ℤ) ≤ ↑(m - n : ℕ) := by by_cases h : m ≥ n · exact le_of_eq (Int.ofNat_sub h).symm · simp [le_of_not_ge h, ofNat_le] #align int.le_coe_nat_sub Int.le_natCast_sub -- Porting note (#10618): simp can prove this @[simp] theorem succ_natCast_pos (n : ℕ) : 0 < (n : ℤ) + 1 := lt_add_one_iff.mpr (by simp) #align int.succ_coe_nat_pos Int.succ_natCast_pos variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_sq_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a ^ 2 = b ^ 2 := by rw [sq, sq] exact natAbs_eq_iff_mul_self_eq #align int.nat_abs_eq_iff_sq_eq Int.natAbs_eq_iff_sq_eq theorem natAbs_lt_iff_sq_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a ^ 2 < b ^ 2 := by rw [sq, sq] exact natAbs_lt_iff_mul_self_lt #align int.nat_abs_lt_iff_sq_lt Int.natAbs_lt_iff_sq_lt theorem natAbs_le_iff_sq_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a ^ 2 ≤ b ^ 2 := by rw [sq, sq] exact natAbs_le_iff_mul_self_le #align int.nat_abs_le_iff_sq_le Int.natAbs_le_iff_sq_le theorem natAbs_inj_of_nonneg_of_nonneg {a b : ℤ} (ha : 0 ≤ a) (hb : 0 ≤ b) : natAbs a = natAbs b ↔ a = b := by rw [← sq_eq_sq ha hb, ← natAbs_eq_iff_sq_eq] #align int.nat_abs_inj_of_nonneg_of_nonneg Int.natAbs_inj_of_nonneg_of_nonneg theorem natAbs_inj_of_nonpos_of_nonpos {a b : ℤ} (ha : a ≤ 0) (hb : b ≤ 0) : natAbs a = natAbs b ↔ a = b := by simpa only [Int.natAbs_neg, neg_inj] using natAbs_inj_of_nonneg_of_nonneg (neg_nonneg_of_nonpos ha) (neg_nonneg_of_nonpos hb) #align int.nat_abs_inj_of_nonpos_of_nonpos Int.natAbs_inj_of_nonpos_of_nonpos theorem natAbs_inj_of_nonneg_of_nonpos {a b : ℤ} (ha : 0 ≤ a) (hb : b ≤ 0) : natAbs a = natAbs b ↔ a = -b := by simpa only [Int.natAbs_neg] using natAbs_inj_of_nonneg_of_nonneg ha (neg_nonneg_of_nonpos hb) #align int.nat_abs_inj_of_nonneg_of_nonpos Int.natAbs_inj_of_nonneg_of_nonpos theorem natAbs_inj_of_nonpos_of_nonneg {a b : ℤ} (ha : a ≤ 0) (hb : 0 ≤ b) : natAbs a = natAbs b ↔ -a = b := by simpa only [Int.natAbs_neg] using natAbs_inj_of_nonneg_of_nonneg (neg_nonneg_of_nonpos ha) hb #align int.nat_abs_inj_of_nonpos_of_nonneg Int.natAbs_inj_of_nonpos_of_nonneg
Mathlib/Data/Int/Lemmas.lean
82
86
theorem natAbs_coe_sub_coe_le_of_le {a b n : ℕ} (a_le_n : a ≤ n) (b_le_n : b ≤ n) : natAbs (a - b : ℤ) ≤ n := by
rw [← Nat.cast_le (α := ℤ), natCast_natAbs] exact abs_sub_le_of_nonneg_of_le (ofNat_nonneg a) (ofNat_le.mpr a_le_n) (ofNat_nonneg b) (ofNat_le.mpr b_le_n)
import Mathlib.Order.Cover import Mathlib.Order.Interval.Finset.Defs #align_import data.finset.locally_finite from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d" assert_not_exists MonoidWithZero assert_not_exists Finset.sum open Function OrderDual open FinsetInterval variable {ι α : Type*} namespace Finset section Preorder variable [Preorder α] section LocallyFiniteOrder variable [LocallyFiniteOrder α] {a a₁ a₂ b b₁ b₂ c x : α} @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc] #align finset.nonempty_Icc Finset.nonempty_Icc @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ico, Set.nonempty_Ico] #align finset.nonempty_Ico Finset.nonempty_Ico @[simp, aesop safe apply (rule_sets := [finsetNonempty])] theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ioc, Set.nonempty_Ioc] #align finset.nonempty_Ioc Finset.nonempty_Ioc -- TODO: This is nonsense. A locally finite order is never densely ordered @[simp] theorem nonempty_Ioo [DenselyOrdered α] : (Ioo a b).Nonempty ↔ a < b := by rw [← coe_nonempty, coe_Ioo, Set.nonempty_Ioo] #align finset.nonempty_Ioo Finset.nonempty_Ioo @[simp] theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by rw [← coe_eq_empty, coe_Icc, Set.Icc_eq_empty_iff] #align finset.Icc_eq_empty_iff Finset.Icc_eq_empty_iff @[simp] theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ico, Set.Ico_eq_empty_iff] #align finset.Ico_eq_empty_iff Finset.Ico_eq_empty_iff @[simp] theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ioc, Set.Ioc_eq_empty_iff] #align finset.Ioc_eq_empty_iff Finset.Ioc_eq_empty_iff -- TODO: This is nonsense. A locally finite order is never densely ordered @[simp] theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by rw [← coe_eq_empty, coe_Ioo, Set.Ioo_eq_empty_iff] #align finset.Ioo_eq_empty_iff Finset.Ioo_eq_empty_iff alias ⟨_, Icc_eq_empty⟩ := Icc_eq_empty_iff #align finset.Icc_eq_empty Finset.Icc_eq_empty alias ⟨_, Ico_eq_empty⟩ := Ico_eq_empty_iff #align finset.Ico_eq_empty Finset.Ico_eq_empty alias ⟨_, Ioc_eq_empty⟩ := Ioc_eq_empty_iff #align finset.Ioc_eq_empty Finset.Ioc_eq_empty @[simp] theorem Ioo_eq_empty (h : ¬a < b) : Ioo a b = ∅ := eq_empty_iff_forall_not_mem.2 fun _ hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2) #align finset.Ioo_eq_empty Finset.Ioo_eq_empty @[simp] theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = ∅ := Icc_eq_empty h.not_le #align finset.Icc_eq_empty_of_lt Finset.Icc_eq_empty_of_lt @[simp] theorem Ico_eq_empty_of_le (h : b ≤ a) : Ico a b = ∅ := Ico_eq_empty h.not_lt #align finset.Ico_eq_empty_of_le Finset.Ico_eq_empty_of_le @[simp] theorem Ioc_eq_empty_of_le (h : b ≤ a) : Ioc a b = ∅ := Ioc_eq_empty h.not_lt #align finset.Ioc_eq_empty_of_le Finset.Ioc_eq_empty_of_le @[simp] theorem Ioo_eq_empty_of_le (h : b ≤ a) : Ioo a b = ∅ := Ioo_eq_empty h.not_lt #align finset.Ioo_eq_empty_of_le Finset.Ioo_eq_empty_of_le -- porting note (#10618): simp can prove this -- @[simp] theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, true_and_iff, le_rfl] #align finset.left_mem_Icc Finset.left_mem_Icc -- porting note (#10618): simp can prove this -- @[simp] theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp only [mem_Ico, true_and_iff, le_refl] #align finset.left_mem_Ico Finset.left_mem_Ico -- porting note (#10618): simp can prove this -- @[simp] theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, and_true_iff, le_rfl] #align finset.right_mem_Icc Finset.right_mem_Icc -- porting note (#10618): simp can prove this -- @[simp] theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by simp only [mem_Ioc, and_true_iff, le_rfl] #align finset.right_mem_Ioc Finset.right_mem_Ioc -- porting note (#10618): simp can prove this -- @[simp] theorem left_not_mem_Ioc : a ∉ Ioc a b := fun h => lt_irrefl _ (mem_Ioc.1 h).1 #align finset.left_not_mem_Ioc Finset.left_not_mem_Ioc -- porting note (#10618): simp can prove this -- @[simp] theorem left_not_mem_Ioo : a ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).1 #align finset.left_not_mem_Ioo Finset.left_not_mem_Ioo -- porting note (#10618): simp can prove this -- @[simp] theorem right_not_mem_Ico : b ∉ Ico a b := fun h => lt_irrefl _ (mem_Ico.1 h).2 #align finset.right_not_mem_Ico Finset.right_not_mem_Ico -- porting note (#10618): simp can prove this -- @[simp] theorem right_not_mem_Ioo : b ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).2 #align finset.right_not_mem_Ioo Finset.right_not_mem_Ioo theorem Icc_subset_Icc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Icc a₁ b₁ ⊆ Icc a₂ b₂ := by simpa [← coe_subset] using Set.Icc_subset_Icc ha hb #align finset.Icc_subset_Icc Finset.Icc_subset_Icc theorem Ico_subset_Ico (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ico a₁ b₁ ⊆ Ico a₂ b₂ := by simpa [← coe_subset] using Set.Ico_subset_Ico ha hb #align finset.Ico_subset_Ico Finset.Ico_subset_Ico theorem Ioc_subset_Ioc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ := by simpa [← coe_subset] using Set.Ioc_subset_Ioc ha hb #align finset.Ioc_subset_Ioc Finset.Ioc_subset_Ioc theorem Ioo_subset_Ioo (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioo a₁ b₁ ⊆ Ioo a₂ b₂ := by simpa [← coe_subset] using Set.Ioo_subset_Ioo ha hb #align finset.Ioo_subset_Ioo Finset.Ioo_subset_Ioo theorem Icc_subset_Icc_left (h : a₁ ≤ a₂) : Icc a₂ b ⊆ Icc a₁ b := Icc_subset_Icc h le_rfl #align finset.Icc_subset_Icc_left Finset.Icc_subset_Icc_left theorem Ico_subset_Ico_left (h : a₁ ≤ a₂) : Ico a₂ b ⊆ Ico a₁ b := Ico_subset_Ico h le_rfl #align finset.Ico_subset_Ico_left Finset.Ico_subset_Ico_left theorem Ioc_subset_Ioc_left (h : a₁ ≤ a₂) : Ioc a₂ b ⊆ Ioc a₁ b := Ioc_subset_Ioc h le_rfl #align finset.Ioc_subset_Ioc_left Finset.Ioc_subset_Ioc_left theorem Ioo_subset_Ioo_left (h : a₁ ≤ a₂) : Ioo a₂ b ⊆ Ioo a₁ b := Ioo_subset_Ioo h le_rfl #align finset.Ioo_subset_Ioo_left Finset.Ioo_subset_Ioo_left theorem Icc_subset_Icc_right (h : b₁ ≤ b₂) : Icc a b₁ ⊆ Icc a b₂ := Icc_subset_Icc le_rfl h #align finset.Icc_subset_Icc_right Finset.Icc_subset_Icc_right theorem Ico_subset_Ico_right (h : b₁ ≤ b₂) : Ico a b₁ ⊆ Ico a b₂ := Ico_subset_Ico le_rfl h #align finset.Ico_subset_Ico_right Finset.Ico_subset_Ico_right theorem Ioc_subset_Ioc_right (h : b₁ ≤ b₂) : Ioc a b₁ ⊆ Ioc a b₂ := Ioc_subset_Ioc le_rfl h #align finset.Ioc_subset_Ioc_right Finset.Ioc_subset_Ioc_right theorem Ioo_subset_Ioo_right (h : b₁ ≤ b₂) : Ioo a b₁ ⊆ Ioo a b₂ := Ioo_subset_Ioo le_rfl h #align finset.Ioo_subset_Ioo_right Finset.Ioo_subset_Ioo_right theorem Ico_subset_Ioo_left (h : a₁ < a₂) : Ico a₂ b ⊆ Ioo a₁ b := by rw [← coe_subset, coe_Ico, coe_Ioo] exact Set.Ico_subset_Ioo_left h #align finset.Ico_subset_Ioo_left Finset.Ico_subset_Ioo_left theorem Ioc_subset_Ioo_right (h : b₁ < b₂) : Ioc a b₁ ⊆ Ioo a b₂ := by rw [← coe_subset, coe_Ioc, coe_Ioo] exact Set.Ioc_subset_Ioo_right h #align finset.Ioc_subset_Ioo_right Finset.Ioc_subset_Ioo_right
Mathlib/Order/Interval/Finset/Basic.lean
230
232
theorem Icc_subset_Ico_right (h : b₁ < b₂) : Icc a b₁ ⊆ Ico a b₂ := by
rw [← coe_subset, coe_Icc, coe_Ico] exact Set.Icc_subset_Ico_right h
import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" noncomputable section open FiniteDimensional Complex open scoped Real RealInnerProductSpace ComplexConjugate namespace Orientation attribute [local instance] Complex.finrank_real_complex_fact variable {V V' : Type*} variable [NormedAddCommGroup V] [NormedAddCommGroup V'] variable [InnerProductSpace ℝ V] [InnerProductSpace ℝ V'] variable [Fact (finrank ℝ V = 2)] [Fact (finrank ℝ V' = 2)] (o : Orientation ℝ V (Fin 2)) local notation "ω" => o.areaForm def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle theorem continuousAt_oangle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => o.oangle y.1 y.2) x := by refine (Complex.continuousAt_arg_coe_angle ?_).comp ?_ · exact o.kahler_ne_zero hx1 hx2 exact ((continuous_ofReal.comp continuous_inner).add ((continuous_ofReal.comp o.areaForm'.continuous₂).mul continuous_const)).continuousAt #align orientation.continuous_at_oangle Orientation.continuousAt_oangle @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right @[simp] theorem oangle_self (x : V) : o.oangle x x = 0 := by rw [oangle, kahler_apply_self, ← ofReal_pow] convert QuotientAddGroup.mk_zero (AddSubgroup.zmultiples (2 * π)) apply arg_ofReal_of_nonneg positivity #align orientation.oangle_self Orientation.oangle_self theorem left_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ 0 := by rintro rfl; simp at h #align orientation.left_ne_zero_of_oangle_ne_zero Orientation.left_ne_zero_of_oangle_ne_zero theorem right_ne_zero_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : y ≠ 0 := by rintro rfl; simp at h #align orientation.right_ne_zero_of_oangle_ne_zero Orientation.right_ne_zero_of_oangle_ne_zero theorem ne_of_oangle_ne_zero {x y : V} (h : o.oangle x y ≠ 0) : x ≠ y := by rintro rfl; simp at h #align orientation.ne_of_oangle_ne_zero Orientation.ne_of_oangle_ne_zero theorem left_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi Orientation.left_ne_zero_of_oangle_eq_pi theorem right_ne_zero_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi Orientation.right_ne_zero_of_oangle_eq_pi theorem ne_of_oangle_eq_pi {x y : V} (h : o.oangle x y = π) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi Orientation.ne_of_oangle_eq_pi theorem left_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_pi_div_two Orientation.left_ne_zero_of_oangle_eq_pi_div_two theorem right_ne_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_pi_div_two Orientation.right_ne_zero_of_oangle_eq_pi_div_two theorem ne_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_pi_div_two Orientation.ne_of_oangle_eq_pi_div_two theorem left_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.left_ne_zero_of_oangle_eq_neg_pi_div_two theorem right_ne_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two Orientation.right_ne_zero_of_oangle_eq_neg_pi_div_two theorem ne_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : x ≠ y := o.ne_of_oangle_ne_zero (h.symm ▸ Real.Angle.neg_pi_div_two_ne_zero : o.oangle x y ≠ 0) #align orientation.ne_of_oangle_eq_neg_pi_div_two Orientation.ne_of_oangle_eq_neg_pi_div_two theorem left_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ 0 := o.left_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.left_ne_zero_of_oangle_sign_ne_zero Orientation.left_ne_zero_of_oangle_sign_ne_zero theorem right_ne_zero_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : y ≠ 0 := o.right_ne_zero_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.right_ne_zero_of_oangle_sign_ne_zero Orientation.right_ne_zero_of_oangle_sign_ne_zero theorem ne_of_oangle_sign_ne_zero {x y : V} (h : (o.oangle x y).sign ≠ 0) : x ≠ y := o.ne_of_oangle_ne_zero (Real.Angle.sign_ne_zero_iff.1 h).1 #align orientation.ne_of_oangle_sign_ne_zero Orientation.ne_of_oangle_sign_ne_zero theorem left_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_one Orientation.left_ne_zero_of_oangle_sign_eq_one theorem right_ne_zero_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_one Orientation.right_ne_zero_of_oangle_sign_eq_one theorem ne_of_oangle_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_one Orientation.ne_of_oangle_sign_eq_one theorem left_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ 0 := o.left_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.left_ne_zero_of_oangle_sign_eq_neg_one Orientation.left_ne_zero_of_oangle_sign_eq_neg_one theorem right_ne_zero_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : y ≠ 0 := o.right_ne_zero_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.right_ne_zero_of_oangle_sign_eq_neg_one Orientation.right_ne_zero_of_oangle_sign_eq_neg_one theorem ne_of_oangle_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : x ≠ y := o.ne_of_oangle_sign_ne_zero (h.symm ▸ by decide : (o.oangle x y).sign ≠ 0) #align orientation.ne_of_oangle_sign_eq_neg_one Orientation.ne_of_oangle_sign_eq_neg_one theorem oangle_rev (x y : V) : o.oangle y x = -o.oangle x y := by simp only [oangle, o.kahler_swap y x, Complex.arg_conj_coe_angle] #align orientation.oangle_rev Orientation.oangle_rev @[simp] theorem oangle_add_oangle_rev (x y : V) : o.oangle x y + o.oangle y x = 0 := by simp [o.oangle_rev y x] #align orientation.oangle_add_oangle_rev Orientation.oangle_add_oangle_rev theorem oangle_neg_left {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle (-x) y = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_left Orientation.oangle_neg_left theorem oangle_neg_right {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x (-y) = o.oangle x y + π := by simp only [oangle, map_neg] convert Complex.arg_neg_coe_angle _ exact o.kahler_ne_zero hx hy #align orientation.oangle_neg_right Orientation.oangle_neg_right @[simp] theorem two_zsmul_oangle_neg_left (x y : V) : (2 : ℤ) • o.oangle (-x) y = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_left hx hy] #align orientation.two_zsmul_oangle_neg_left Orientation.two_zsmul_oangle_neg_left @[simp] theorem two_zsmul_oangle_neg_right (x y : V) : (2 : ℤ) • o.oangle x (-y) = (2 : ℤ) • o.oangle x y := by by_cases hx : x = 0 · simp [hx] · by_cases hy : y = 0 · simp [hy] · simp [o.oangle_neg_right hx hy] #align orientation.two_zsmul_oangle_neg_right Orientation.two_zsmul_oangle_neg_right @[simp] theorem oangle_neg_neg (x y : V) : o.oangle (-x) (-y) = o.oangle x y := by simp [oangle] #align orientation.oangle_neg_neg Orientation.oangle_neg_neg theorem oangle_neg_left_eq_neg_right (x y : V) : o.oangle (-x) y = o.oangle x (-y) := by rw [← neg_neg y, oangle_neg_neg, neg_neg] #align orientation.oangle_neg_left_eq_neg_right Orientation.oangle_neg_left_eq_neg_right @[simp] theorem oangle_neg_self_left {x : V} (hx : x ≠ 0) : o.oangle (-x) x = π := by simp [oangle_neg_left, hx] #align orientation.oangle_neg_self_left Orientation.oangle_neg_self_left @[simp] theorem oangle_neg_self_right {x : V} (hx : x ≠ 0) : o.oangle x (-x) = π := by simp [oangle_neg_right, hx] #align orientation.oangle_neg_self_right Orientation.oangle_neg_self_right -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_left (x : V) : (2 : ℤ) • o.oangle (-x) x = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_left Orientation.two_zsmul_oangle_neg_self_left -- @[simp] -- Porting note (#10618): simp can prove this theorem two_zsmul_oangle_neg_self_right (x : V) : (2 : ℤ) • o.oangle x (-x) = 0 := by by_cases hx : x = 0 <;> simp [hx] #align orientation.two_zsmul_oangle_neg_self_right Orientation.two_zsmul_oangle_neg_self_right @[simp] theorem oangle_add_oangle_rev_neg_left (x y : V) : o.oangle (-x) y + o.oangle (-y) x = 0 := by rw [oangle_neg_left_eq_neg_right, oangle_rev, add_left_neg] #align orientation.oangle_add_oangle_rev_neg_left Orientation.oangle_add_oangle_rev_neg_left @[simp] theorem oangle_add_oangle_rev_neg_right (x y : V) : o.oangle x (-y) + o.oangle y (-x) = 0 := by rw [o.oangle_rev (-x), oangle_neg_left_eq_neg_right, add_neg_self] #align orientation.oangle_add_oangle_rev_neg_right Orientation.oangle_add_oangle_rev_neg_right @[simp] theorem oangle_smul_left_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle (r • x) y = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_left_of_pos Orientation.oangle_smul_left_of_pos @[simp] theorem oangle_smul_right_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : o.oangle x (r • y) = o.oangle x y := by simp [oangle, Complex.arg_real_mul _ hr] #align orientation.oangle_smul_right_of_pos Orientation.oangle_smul_right_of_pos @[simp] theorem oangle_smul_left_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle (r • x) y = o.oangle (-x) y := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_left_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_left_of_neg Orientation.oangle_smul_left_of_neg @[simp] theorem oangle_smul_right_of_neg (x y : V) {r : ℝ} (hr : r < 0) : o.oangle x (r • y) = o.oangle x (-y) := by rw [← neg_neg r, neg_smul, ← smul_neg, o.oangle_smul_right_of_pos _ _ (neg_pos_of_neg hr)] #align orientation.oangle_smul_right_of_neg Orientation.oangle_smul_right_of_neg @[simp] theorem oangle_smul_left_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle (r • x) x = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_left_self_of_nonneg Orientation.oangle_smul_left_self_of_nonneg @[simp] theorem oangle_smul_right_self_of_nonneg (x : V) {r : ℝ} (hr : 0 ≤ r) : o.oangle x (r • x) = 0 := by rcases hr.lt_or_eq with (h | h) · simp [h] · simp [h.symm] #align orientation.oangle_smul_right_self_of_nonneg Orientation.oangle_smul_right_self_of_nonneg @[simp] theorem oangle_smul_smul_self_of_nonneg (x : V) {r₁ r₂ : ℝ} (hr₁ : 0 ≤ r₁) (hr₂ : 0 ≤ r₂) : o.oangle (r₁ • x) (r₂ • x) = 0 := by rcases hr₁.lt_or_eq with (h | h) · simp [h, hr₂] · simp [h.symm] #align orientation.oangle_smul_smul_self_of_nonneg Orientation.oangle_smul_smul_self_of_nonneg @[simp] theorem two_zsmul_oangle_smul_left_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle (r • x) y = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_of_ne_zero Orientation.two_zsmul_oangle_smul_left_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_right_of_ne_zero (x y : V) {r : ℝ} (hr : r ≠ 0) : (2 : ℤ) • o.oangle x (r • y) = (2 : ℤ) • o.oangle x y := by rcases hr.lt_or_lt with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_of_ne_zero Orientation.two_zsmul_oangle_smul_right_of_ne_zero @[simp] theorem two_zsmul_oangle_smul_left_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle (r • x) x = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_left_self Orientation.two_zsmul_oangle_smul_left_self @[simp] theorem two_zsmul_oangle_smul_right_self (x : V) {r : ℝ} : (2 : ℤ) • o.oangle x (r • x) = 0 := by rcases lt_or_le r 0 with (h | h) <;> simp [h] #align orientation.two_zsmul_oangle_smul_right_self Orientation.two_zsmul_oangle_smul_right_self @[simp] theorem two_zsmul_oangle_smul_smul_self (x : V) {r₁ r₂ : ℝ} : (2 : ℤ) • o.oangle (r₁ • x) (r₂ • x) = 0 := by by_cases h : r₁ = 0 <;> simp [h] #align orientation.two_zsmul_oangle_smul_smul_self Orientation.two_zsmul_oangle_smul_smul_self theorem two_zsmul_oangle_left_of_span_eq {x y : V} (z : V) (h : (ℝ ∙ x) = ℝ ∙ y) : (2 : ℤ) • o.oangle x z = (2 : ℤ) • o.oangle y z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_left_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_left_of_span_eq Orientation.two_zsmul_oangle_left_of_span_eq theorem two_zsmul_oangle_right_of_span_eq (x : V) {y z : V} (h : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle x y = (2 : ℤ) • o.oangle x z := by rw [Submodule.span_singleton_eq_span_singleton] at h rcases h with ⟨r, rfl⟩ exact (o.two_zsmul_oangle_smul_right_of_ne_zero _ _ (Units.ne_zero _)).symm #align orientation.two_zsmul_oangle_right_of_span_eq Orientation.two_zsmul_oangle_right_of_span_eq theorem two_zsmul_oangle_of_span_eq_of_span_eq {w x y z : V} (hwx : (ℝ ∙ w) = ℝ ∙ x) (hyz : (ℝ ∙ y) = ℝ ∙ z) : (2 : ℤ) • o.oangle w y = (2 : ℤ) • o.oangle x z := by rw [o.two_zsmul_oangle_left_of_span_eq y hwx, o.two_zsmul_oangle_right_of_span_eq x hyz] #align orientation.two_zsmul_oangle_of_span_eq_of_span_eq Orientation.two_zsmul_oangle_of_span_eq_of_span_eq theorem oangle_eq_zero_iff_oangle_rev_eq_zero {x y : V} : o.oangle x y = 0 ↔ o.oangle y x = 0 := by rw [oangle_rev, neg_eq_zero] #align orientation.oangle_eq_zero_iff_oangle_rev_eq_zero Orientation.oangle_eq_zero_iff_oangle_rev_eq_zero theorem oangle_eq_zero_iff_sameRay {x y : V} : o.oangle x y = 0 ↔ SameRay ℝ x y := by rw [oangle, kahler_apply_apply, Complex.arg_coe_angle_eq_iff_eq_toReal, Real.Angle.toReal_zero, Complex.arg_eq_zero_iff] simpa using o.nonneg_inner_and_areaForm_eq_zero_iff_sameRay x y #align orientation.oangle_eq_zero_iff_same_ray Orientation.oangle_eq_zero_iff_sameRay theorem oangle_eq_pi_iff_oangle_rev_eq_pi {x y : V} : o.oangle x y = π ↔ o.oangle y x = π := by rw [oangle_rev, neg_eq_iff_eq_neg, Real.Angle.neg_coe_pi] #align orientation.oangle_eq_pi_iff_oangle_rev_eq_pi Orientation.oangle_eq_pi_iff_oangle_rev_eq_pi theorem oangle_eq_pi_iff_sameRay_neg {x y : V} : o.oangle x y = π ↔ x ≠ 0 ∧ y ≠ 0 ∧ SameRay ℝ x (-y) := by rw [← o.oangle_eq_zero_iff_sameRay] constructor · intro h by_cases hx : x = 0; · simp [hx, Real.Angle.pi_ne_zero.symm] at h by_cases hy : y = 0; · simp [hy, Real.Angle.pi_ne_zero.symm] at h refine ⟨hx, hy, ?_⟩ rw [o.oangle_neg_right hx hy, h, Real.Angle.coe_pi_add_coe_pi] · rintro ⟨hx, hy, h⟩ rwa [o.oangle_neg_right hx hy, ← Real.Angle.sub_coe_pi_eq_add_coe_pi, sub_eq_zero] at h #align orientation.oangle_eq_pi_iff_same_ray_neg Orientation.oangle_eq_pi_iff_sameRay_neg theorem oangle_eq_zero_or_eq_pi_iff_not_linearIndependent {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ ¬LinearIndependent ℝ ![x, y] := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg, sameRay_or_ne_zero_and_sameRay_neg_iff_not_linearIndependent] #align orientation.oangle_eq_zero_or_eq_pi_iff_not_linear_independent Orientation.oangle_eq_zero_or_eq_pi_iff_not_linearIndependent theorem oangle_eq_zero_or_eq_pi_iff_right_eq_smul {x y : V} : o.oangle x y = 0 ∨ o.oangle x y = π ↔ x = 0 ∨ ∃ r : ℝ, y = r • x := by rw [oangle_eq_zero_iff_sameRay, oangle_eq_pi_iff_sameRay_neg] refine ⟨fun h => ?_, fun h => ?_⟩ · rcases h with (h | ⟨-, -, h⟩) · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, rfl⟩ := h.exists_nonneg_left hx exact Or.inr ⟨r, rfl⟩ · by_cases hx : x = 0; · simp [hx] obtain ⟨r, -, hy⟩ := h.exists_nonneg_left hx refine Or.inr ⟨-r, ?_⟩ simp [hy] · rcases h with (rfl | ⟨r, rfl⟩); · simp by_cases hx : x = 0; · simp [hx] rcases lt_trichotomy r 0 with (hr | hr | hr) · rw [← neg_smul] exact Or.inr ⟨hx, smul_ne_zero hr.ne hx, SameRay.sameRay_pos_smul_right x (Left.neg_pos_iff.2 hr)⟩ · simp [hr] · exact Or.inl (SameRay.sameRay_pos_smul_right x hr) #align orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul Orientation.oangle_eq_zero_or_eq_pi_iff_right_eq_smul theorem oangle_ne_zero_and_ne_pi_iff_linearIndependent {x y : V} : o.oangle x y ≠ 0 ∧ o.oangle x y ≠ π ↔ LinearIndependent ℝ ![x, y] := by rw [← not_or, ← not_iff_not, Classical.not_not, oangle_eq_zero_or_eq_pi_iff_not_linearIndependent] #align orientation.oangle_ne_zero_and_ne_pi_iff_linear_independent Orientation.oangle_ne_zero_and_ne_pi_iff_linearIndependent theorem eq_iff_norm_eq_and_oangle_eq_zero (x y : V) : x = y ↔ ‖x‖ = ‖y‖ ∧ o.oangle x y = 0 := by rw [oangle_eq_zero_iff_sameRay] constructor · rintro rfl simp; rfl · rcases eq_or_ne y 0 with (rfl | hy) · simp rintro ⟨h₁, h₂⟩ obtain ⟨r, hr, rfl⟩ := h₂.exists_nonneg_right hy have : ‖y‖ ≠ 0 := by simpa using hy obtain rfl : r = 1 := by apply mul_right_cancel₀ this simpa [norm_smul, _root_.abs_of_nonneg hr] using h₁ simp #align orientation.eq_iff_norm_eq_and_oangle_eq_zero Orientation.eq_iff_norm_eq_and_oangle_eq_zero theorem eq_iff_oangle_eq_zero_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : x = y ↔ o.oangle x y = 0 := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).2, fun ha => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨h, ha⟩⟩ #align orientation.eq_iff_oangle_eq_zero_of_norm_eq Orientation.eq_iff_oangle_eq_zero_of_norm_eq theorem eq_iff_norm_eq_of_oangle_eq_zero {x y : V} (h : o.oangle x y = 0) : x = y ↔ ‖x‖ = ‖y‖ := ⟨fun he => ((o.eq_iff_norm_eq_and_oangle_eq_zero x y).1 he).1, fun hn => (o.eq_iff_norm_eq_and_oangle_eq_zero x y).2 ⟨hn, h⟩⟩ #align orientation.eq_iff_norm_eq_of_oangle_eq_zero Orientation.eq_iff_norm_eq_of_oangle_eq_zero @[simp] theorem oangle_add {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z = o.oangle x z := by simp_rw [oangle] rw [← Complex.arg_mul_coe_angle, o.kahler_mul y x z] · congr 1 convert Complex.arg_real_mul _ (_ : 0 < ‖y‖ ^ 2) using 2 · norm_cast · have : 0 < ‖y‖ := by simpa using hy positivity · exact o.kahler_ne_zero hx hy · exact o.kahler_ne_zero hy hz #align orientation.oangle_add Orientation.oangle_add @[simp] theorem oangle_add_swap {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle y z + o.oangle x y = o.oangle x z := by rw [add_comm, o.oangle_add hx hy hz] #align orientation.oangle_add_swap Orientation.oangle_add_swap @[simp] theorem oangle_sub_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle x y = o.oangle y z := by rw [sub_eq_iff_eq_add, o.oangle_add_swap hx hy hz] #align orientation.oangle_sub_left Orientation.oangle_sub_left @[simp] theorem oangle_sub_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x z - o.oangle y z = o.oangle x y := by rw [sub_eq_iff_eq_add, o.oangle_add hx hy hz] #align orientation.oangle_sub_right Orientation.oangle_sub_right @[simp] theorem oangle_add_cyc3 {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x y + o.oangle y z + o.oangle z x = 0 := by simp [hx, hy, hz] #align orientation.oangle_add_cyc3 Orientation.oangle_add_cyc3 @[simp] theorem oangle_add_cyc3_neg_left {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle (-x) y + o.oangle (-y) z + o.oangle (-z) x = π := by rw [o.oangle_neg_left hx hy, o.oangle_neg_left hy hz, o.oangle_neg_left hz hx, show o.oangle x y + π + (o.oangle y z + π) + (o.oangle z x + π) = o.oangle x y + o.oangle y z + o.oangle z x + (π + π + π : Real.Angle) by abel, o.oangle_add_cyc3 hx hy hz, Real.Angle.coe_pi_add_coe_pi, zero_add, zero_add] #align orientation.oangle_add_cyc3_neg_left Orientation.oangle_add_cyc3_neg_left @[simp] theorem oangle_add_cyc3_neg_right {x y z : V} (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) : o.oangle x (-y) + o.oangle y (-z) + o.oangle z (-x) = π := by simp_rw [← oangle_neg_left_eq_neg_right, o.oangle_add_cyc3_neg_left hx hy hz] #align orientation.oangle_add_cyc3_neg_right Orientation.oangle_add_cyc3_neg_right theorem oangle_sub_eq_oangle_sub_rev_of_norm_eq {x y : V} (h : ‖x‖ = ‖y‖) : o.oangle x (x - y) = o.oangle (y - x) y := by simp [oangle, h] #align orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq Orientation.oangle_sub_eq_oangle_sub_rev_of_norm_eq theorem oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq {x y : V} (hn : x ≠ y) (h : ‖x‖ = ‖y‖) : o.oangle y x = π - (2 : ℤ) • o.oangle (y - x) y := by rw [two_zsmul] nth_rw 1 [← o.oangle_sub_eq_oangle_sub_rev_of_norm_eq h] rw [eq_sub_iff_add_eq, ← oangle_neg_neg, ← add_assoc] have hy : y ≠ 0 := by rintro rfl rw [norm_zero, norm_eq_zero] at h exact hn h have hx : x ≠ 0 := norm_ne_zero_iff.1 (h.symm ▸ norm_ne_zero_iff.2 hy) convert o.oangle_add_cyc3_neg_right (neg_ne_zero.2 hy) hx (sub_ne_zero_of_ne hn.symm) using 1 simp #align orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq Orientation.oangle_eq_pi_sub_two_zsmul_oangle_sub_of_norm_eq @[simp] theorem oangle_map (x y : V') (f : V ≃ₗᵢ[ℝ] V') : (Orientation.map (Fin 2) f.toLinearEquiv o).oangle x y = o.oangle (f.symm x) (f.symm y) := by simp [oangle, o.kahler_map] #align orientation.oangle_map Orientation.oangle_map @[simp] protected theorem _root_.Complex.oangle (w z : ℂ) : Complex.orientation.oangle w z = Complex.arg (conj w * z) := by simp [oangle] #align complex.oangle Complex.oangle theorem oangle_map_complex (f : V ≃ₗᵢ[ℝ] ℂ) (hf : Orientation.map (Fin 2) f.toLinearEquiv o = Complex.orientation) (x y : V) : o.oangle x y = Complex.arg (conj (f x) * f y) := by rw [← Complex.oangle, ← hf, o.oangle_map] iterate 2 rw [LinearIsometryEquiv.symm_apply_apply] #align orientation.oangle_map_complex Orientation.oangle_map_complex theorem oangle_neg_orientation_eq_neg (x y : V) : (-o).oangle x y = -o.oangle x y := by simp [oangle] #align orientation.oangle_neg_orientation_eq_neg Orientation.oangle_neg_orientation_eq_neg theorem inner_eq_norm_mul_norm_mul_cos_oangle (x y : V) : ⟪x, y⟫ = ‖x‖ * ‖y‖ * Real.Angle.cos (o.oangle x y) := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] have : ‖x‖ ≠ 0 := by simpa using hx have : ‖y‖ ≠ 0 := by simpa using hy rw [oangle, Real.Angle.cos_coe, Complex.cos_arg, o.abs_kahler] · simp only [kahler_apply_apply, real_smul, add_re, ofReal_re, mul_re, I_re, ofReal_im] field_simp · exact o.kahler_ne_zero hx hy #align orientation.inner_eq_norm_mul_norm_mul_cos_oangle Orientation.inner_eq_norm_mul_norm_mul_cos_oangle theorem cos_oangle_eq_inner_div_norm_mul_norm {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : Real.Angle.cos (o.oangle x y) = ⟪x, y⟫ / (‖x‖ * ‖y‖) := by rw [o.inner_eq_norm_mul_norm_mul_cos_oangle] field_simp [norm_ne_zero_iff.2 hx, norm_ne_zero_iff.2 hy] #align orientation.cos_oangle_eq_inner_div_norm_mul_norm Orientation.cos_oangle_eq_inner_div_norm_mul_norm theorem cos_oangle_eq_cos_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : Real.Angle.cos (o.oangle x y) = Real.cos (InnerProductGeometry.angle x y) := by rw [o.cos_oangle_eq_inner_div_norm_mul_norm hx hy, InnerProductGeometry.cos_angle] #align orientation.cos_oangle_eq_cos_angle Orientation.cos_oangle_eq_cos_angle theorem oangle_eq_angle_or_eq_neg_angle {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x y = InnerProductGeometry.angle x y ∨ o.oangle x y = -InnerProductGeometry.angle x y := Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg.1 <| o.cos_oangle_eq_cos_angle hx hy #align orientation.oangle_eq_angle_or_eq_neg_angle Orientation.oangle_eq_angle_or_eq_neg_angle theorem angle_eq_abs_oangle_toReal {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : InnerProductGeometry.angle x y = |(o.oangle x y).toReal| := by have h0 := InnerProductGeometry.angle_nonneg x y have hpi := InnerProductGeometry.angle_le_pi x y rcases o.oangle_eq_angle_or_eq_neg_angle hx hy with (h | h) · rw [h, eq_comm, Real.Angle.abs_toReal_coe_eq_self_iff] exact ⟨h0, hpi⟩ · rw [h, eq_comm, Real.Angle.abs_toReal_neg_coe_eq_self_iff] exact ⟨h0, hpi⟩ #align orientation.angle_eq_abs_oangle_to_real Orientation.angle_eq_abs_oangle_toReal theorem eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero {x y : V} (h : (o.oangle x y).sign = 0) : x = 0 ∨ y = 0 ∨ InnerProductGeometry.angle x y = 0 ∨ InnerProductGeometry.angle x y = π := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.angle_eq_abs_oangle_toReal hx hy] rw [Real.Angle.sign_eq_zero_iff] at h rcases h with (h | h) <;> simp [h, Real.pi_pos.le] #align orientation.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero Orientation.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero theorem oangle_eq_of_angle_eq_of_sign_eq {w x y z : V} (h : InnerProductGeometry.angle w x = InnerProductGeometry.angle y z) (hs : (o.oangle w x).sign = (o.oangle y z).sign) : o.oangle w x = o.oangle y z := by by_cases h0 : (w = 0 ∨ x = 0) ∨ y = 0 ∨ z = 0 · have hs' : (o.oangle w x).sign = 0 ∧ (o.oangle y z).sign = 0 := by rcases h0 with ((rfl | rfl) | rfl | rfl) · simpa using hs.symm · simpa using hs.symm · simpa using hs · simpa using hs rcases hs' with ⟨hswx, hsyz⟩ have h' : InnerProductGeometry.angle w x = π / 2 ∧ InnerProductGeometry.angle y z = π / 2 := by rcases h0 with ((rfl | rfl) | rfl | rfl) · simpa using h.symm · simpa using h.symm · simpa using h · simpa using h rcases h' with ⟨hwx, hyz⟩ have hpi : π / 2 ≠ π := by intro hpi rw [div_eq_iff, eq_comm, ← sub_eq_zero, mul_two, add_sub_cancel_right] at hpi · exact Real.pi_pos.ne.symm hpi · exact two_ne_zero have h0wx : w = 0 ∨ x = 0 := by have h0' := o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero hswx simpa [hwx, Real.pi_pos.ne.symm, hpi] using h0' have h0yz : y = 0 ∨ z = 0 := by have h0' := o.eq_zero_or_angle_eq_zero_or_pi_of_sign_oangle_eq_zero hsyz simpa [hyz, Real.pi_pos.ne.symm, hpi] using h0' rcases h0wx with (h0wx | h0wx) <;> rcases h0yz with (h0yz | h0yz) <;> simp [h0wx, h0yz] · push_neg at h0 rw [Real.Angle.eq_iff_abs_toReal_eq_of_sign_eq hs] rwa [o.angle_eq_abs_oangle_toReal h0.1.1 h0.1.2, o.angle_eq_abs_oangle_toReal h0.2.1 h0.2.2] at h #align orientation.oangle_eq_of_angle_eq_of_sign_eq Orientation.oangle_eq_of_angle_eq_of_sign_eq theorem angle_eq_iff_oangle_eq_of_sign_eq {w x y z : V} (hw : w ≠ 0) (hx : x ≠ 0) (hy : y ≠ 0) (hz : z ≠ 0) (hs : (o.oangle w x).sign = (o.oangle y z).sign) : InnerProductGeometry.angle w x = InnerProductGeometry.angle y z ↔ o.oangle w x = o.oangle y z := by refine ⟨fun h => o.oangle_eq_of_angle_eq_of_sign_eq h hs, fun h => ?_⟩ rw [o.angle_eq_abs_oangle_toReal hw hx, o.angle_eq_abs_oangle_toReal hy hz, h] #align orientation.angle_eq_iff_oangle_eq_of_sign_eq Orientation.angle_eq_iff_oangle_eq_of_sign_eq theorem oangle_eq_angle_of_sign_eq_one {x y : V} (h : (o.oangle x y).sign = 1) : o.oangle x y = InnerProductGeometry.angle x y := by by_cases hx : x = 0; · exfalso; simp [hx] at h by_cases hy : y = 0; · exfalso; simp [hy] at h refine (o.oangle_eq_angle_or_eq_neg_angle hx hy).resolve_right ?_ intro hxy rw [hxy, Real.Angle.sign_neg, neg_eq_iff_eq_neg, ← SignType.neg_iff, ← not_le] at h exact h (Real.Angle.sign_coe_nonneg_of_nonneg_of_le_pi (InnerProductGeometry.angle_nonneg _ _) (InnerProductGeometry.angle_le_pi _ _)) #align orientation.oangle_eq_angle_of_sign_eq_one Orientation.oangle_eq_angle_of_sign_eq_one theorem oangle_eq_neg_angle_of_sign_eq_neg_one {x y : V} (h : (o.oangle x y).sign = -1) : o.oangle x y = -InnerProductGeometry.angle x y := by by_cases hx : x = 0; · exfalso; simp [hx] at h by_cases hy : y = 0; · exfalso; simp [hy] at h refine (o.oangle_eq_angle_or_eq_neg_angle hx hy).resolve_left ?_ intro hxy rw [hxy, ← SignType.neg_iff, ← not_le] at h exact h (Real.Angle.sign_coe_nonneg_of_nonneg_of_le_pi (InnerProductGeometry.angle_nonneg _ _) (InnerProductGeometry.angle_le_pi _ _)) #align orientation.oangle_eq_neg_angle_of_sign_eq_neg_one Orientation.oangle_eq_neg_angle_of_sign_eq_neg_one theorem oangle_eq_zero_iff_angle_eq_zero {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : o.oangle x y = 0 ↔ InnerProductGeometry.angle x y = 0 := by refine ⟨fun h => ?_, fun h => ?_⟩ · simpa [o.angle_eq_abs_oangle_toReal hx hy] · have ha := o.oangle_eq_angle_or_eq_neg_angle hx hy rw [h] at ha simpa using ha #align orientation.oangle_eq_zero_iff_angle_eq_zero Orientation.oangle_eq_zero_iff_angle_eq_zero theorem oangle_eq_pi_iff_angle_eq_pi {x y : V} : o.oangle x y = π ↔ InnerProductGeometry.angle x y = π := by by_cases hx : x = 0 · simp [hx, Real.Angle.pi_ne_zero.symm, div_eq_mul_inv, mul_right_eq_self₀, not_or, Real.pi_ne_zero] by_cases hy : y = 0 · simp [hy, Real.Angle.pi_ne_zero.symm, div_eq_mul_inv, mul_right_eq_self₀, not_or, Real.pi_ne_zero] refine ⟨fun h => ?_, fun h => ?_⟩ · rw [o.angle_eq_abs_oangle_toReal hx hy, h] simp [Real.pi_pos.le] · have ha := o.oangle_eq_angle_or_eq_neg_angle hx hy rw [h] at ha simpa using ha #align orientation.oangle_eq_pi_iff_angle_eq_pi Orientation.oangle_eq_pi_iff_angle_eq_pi theorem eq_zero_or_oangle_eq_iff_inner_eq_zero {x y : V} : x = 0 ∨ y = 0 ∨ o.oangle x y = (π / 2 : ℝ) ∨ o.oangle x y = (-π / 2 : ℝ) ↔ ⟪x, y⟫ = 0 := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two, or_iff_right hx, or_iff_right hy] refine ⟨fun h => ?_, fun h => ?_⟩ · rwa [o.angle_eq_abs_oangle_toReal hx hy, Real.Angle.abs_toReal_eq_pi_div_two_iff] · convert o.oangle_eq_angle_or_eq_neg_angle hx hy using 2 <;> rw [h] simp only [neg_div, Real.Angle.coe_neg] #align orientation.eq_zero_or_oangle_eq_iff_inner_eq_zero Orientation.eq_zero_or_oangle_eq_iff_inner_eq_zero theorem inner_eq_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : ⟪x, y⟫ = 0 := o.eq_zero_or_oangle_eq_iff_inner_eq_zero.1 <| Or.inr <| Or.inr <| Or.inl h #align orientation.inner_eq_zero_of_oangle_eq_pi_div_two Orientation.inner_eq_zero_of_oangle_eq_pi_div_two theorem inner_rev_eq_zero_of_oangle_eq_pi_div_two {x y : V} (h : o.oangle x y = (π / 2 : ℝ)) : ⟪y, x⟫ = 0 := by rw [real_inner_comm, o.inner_eq_zero_of_oangle_eq_pi_div_two h] #align orientation.inner_rev_eq_zero_of_oangle_eq_pi_div_two Orientation.inner_rev_eq_zero_of_oangle_eq_pi_div_two theorem inner_eq_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : ⟪x, y⟫ = 0 := o.eq_zero_or_oangle_eq_iff_inner_eq_zero.1 <| Or.inr <| Or.inr <| Or.inr h #align orientation.inner_eq_zero_of_oangle_eq_neg_pi_div_two Orientation.inner_eq_zero_of_oangle_eq_neg_pi_div_two theorem inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two {x y : V} (h : o.oangle x y = (-π / 2 : ℝ)) : ⟪y, x⟫ = 0 := by rw [real_inner_comm, o.inner_eq_zero_of_oangle_eq_neg_pi_div_two h] #align orientation.inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two Orientation.inner_rev_eq_zero_of_oangle_eq_neg_pi_div_two @[simp] theorem oangle_sign_neg_left (x y : V) : (o.oangle (-x) y).sign = -(o.oangle x y).sign := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.oangle_neg_left hx hy, Real.Angle.sign_add_pi] #align orientation.oangle_sign_neg_left Orientation.oangle_sign_neg_left @[simp] theorem oangle_sign_neg_right (x y : V) : (o.oangle x (-y)).sign = -(o.oangle x y).sign := by by_cases hx : x = 0; · simp [hx] by_cases hy : y = 0; · simp [hy] rw [o.oangle_neg_right hx hy, Real.Angle.sign_add_pi] #align orientation.oangle_sign_neg_right Orientation.oangle_sign_neg_right @[simp] theorem oangle_sign_smul_left (x y : V) (r : ℝ) : (o.oangle (r • x) y).sign = SignType.sign r * (o.oangle x y).sign := by rcases lt_trichotomy r 0 with (h | h | h) <;> simp [h] #align orientation.oangle_sign_smul_left Orientation.oangle_sign_smul_left @[simp] theorem oangle_sign_smul_right (x y : V) (r : ℝ) : (o.oangle x (r • y)).sign = SignType.sign r * (o.oangle x y).sign := by rcases lt_trichotomy r 0 with (h | h | h) <;> simp [h] #align orientation.oangle_sign_smul_right Orientation.oangle_sign_smul_right theorem oangle_smul_add_right_eq_zero_or_eq_pi_iff {x y : V} (r : ℝ) : o.oangle x (r • x + y) = 0 ∨ o.oangle x (r • x + y) = π ↔ o.oangle x y = 0 ∨ o.oangle x y = π := by simp_rw [oangle_eq_zero_or_eq_pi_iff_not_linearIndependent, Fintype.not_linearIndependent_iff] -- Porting note: at this point all occurences of the bound variable `i` are of type -- `Fin (Nat.succ (Nat.succ 0))`, but `Fin.sum_univ_two` and `Fin.exists_fin_two` expect it to be -- `Fin 2` instead. Hence all the `conv`s. -- Was `simp_rw [Fin.sum_univ_two, Fin.exists_fin_two]` conv_lhs => enter [1, g, 1, 1, 2, i]; tactic => change Fin 2 at i conv_lhs => enter [1, g]; rw [Fin.sum_univ_two] conv_rhs => enter [1, g, 1, 1, 2, i]; tactic => change Fin 2 at i conv_rhs => enter [1, g]; rw [Fin.sum_univ_two] conv_lhs => enter [1, g, 2, 1, i]; tactic => change Fin 2 at i conv_lhs => enter [1, g]; rw [Fin.exists_fin_two] conv_rhs => enter [1, g, 2, 1, i]; tactic => change Fin 2 at i conv_rhs => enter [1, g]; rw [Fin.exists_fin_two] refine ⟨fun h => ?_, fun h => ?_⟩ · rcases h with ⟨m, h, hm⟩ change m 0 • x + m 1 • (r • x + y) = 0 at h refine ⟨![m 0 + m 1 * r, m 1], ?_⟩ change (m 0 + m 1 * r) • x + m 1 • y = 0 ∧ (m 0 + m 1 * r ≠ 0 ∨ m 1 ≠ 0) rw [smul_add, smul_smul, ← add_assoc, ← add_smul] at h refine ⟨h, not_and_or.1 fun h0 => ?_⟩ obtain ⟨h0, h1⟩ := h0 rw [h1] at h0 hm rw [zero_mul, add_zero] at h0 simp [h0] at hm · rcases h with ⟨m, h, hm⟩ change m 0 • x + m 1 • y = 0 at h refine ⟨![m 0 - m 1 * r, m 1], ?_⟩ change (m 0 - m 1 * r) • x + m 1 • (r • x + y) = 0 ∧ (m 0 - m 1 * r ≠ 0 ∨ m 1 ≠ 0) rw [sub_smul, smul_add, smul_smul, ← add_assoc, sub_add_cancel] refine ⟨h, not_and_or.1 fun h0 => ?_⟩ obtain ⟨h0, h1⟩ := h0 rw [h1] at h0 hm rw [zero_mul, sub_zero] at h0 simp [h0] at hm #align orientation.oangle_smul_add_right_eq_zero_or_eq_pi_iff Orientation.oangle_smul_add_right_eq_zero_or_eq_pi_iff @[simp] theorem oangle_sign_smul_add_right (x y : V) (r : ℝ) : (o.oangle x (r • x + y)).sign = (o.oangle x y).sign := by by_cases h : o.oangle x y = 0 ∨ o.oangle x y = π · rwa [Real.Angle.sign_eq_zero_iff.2 h, Real.Angle.sign_eq_zero_iff, oangle_smul_add_right_eq_zero_or_eq_pi_iff] have h' : ∀ r' : ℝ, o.oangle x (r' • x + y) ≠ 0 ∧ o.oangle x (r' • x + y) ≠ π := by intro r' rwa [← o.oangle_smul_add_right_eq_zero_or_eq_pi_iff r', not_or] at h let s : Set (V × V) := (fun r' : ℝ => (x, r' • x + y)) '' Set.univ have hc : IsConnected s := isConnected_univ.image _ (continuous_const.prod_mk ((continuous_id.smul continuous_const).add continuous_const)).continuousOn have hf : ContinuousOn (fun z : V × V => o.oangle z.1 z.2) s := by refine ContinuousAt.continuousOn fun z hz => o.continuousAt_oangle ?_ ?_ all_goals simp_rw [s, Set.mem_image] at hz obtain ⟨r', -, rfl⟩ := hz simp only [Prod.fst, Prod.snd] intro hz · simpa [hz] using (h' 0).1 · simpa [hz] using (h' r').1 have hs : ∀ z : V × V, z ∈ s → o.oangle z.1 z.2 ≠ 0 ∧ o.oangle z.1 z.2 ≠ π := by intro z hz simp_rw [s, Set.mem_image] at hz obtain ⟨r', -, rfl⟩ := hz exact h' r' have hx : (x, y) ∈ s := by convert Set.mem_image_of_mem (fun r' : ℝ => (x, r' • x + y)) (Set.mem_univ 0) simp have hy : (x, r • x + y) ∈ s := Set.mem_image_of_mem _ (Set.mem_univ _) convert Real.Angle.sign_eq_of_continuousOn hc hf hs hx hy #align orientation.oangle_sign_smul_add_right Orientation.oangle_sign_smul_add_right @[simp] theorem oangle_sign_add_smul_left (x y : V) (r : ℝ) : (o.oangle (x + r • y) y).sign = (o.oangle x y).sign := by simp_rw [o.oangle_rev y, Real.Angle.sign_neg, add_comm x, oangle_sign_smul_add_right] #align orientation.oangle_sign_add_smul_left Orientation.oangle_sign_add_smul_left @[simp] theorem oangle_sign_sub_smul_right (x y : V) (r : ℝ) : (o.oangle x (y - r • x)).sign = (o.oangle x y).sign := by rw [sub_eq_add_neg, ← neg_smul, add_comm, oangle_sign_smul_add_right] #align orientation.oangle_sign_sub_smul_right Orientation.oangle_sign_sub_smul_right @[simp] theorem oangle_sign_sub_smul_left (x y : V) (r : ℝ) : (o.oangle (x - r • y) y).sign = (o.oangle x y).sign := by rw [sub_eq_add_neg, ← neg_smul, oangle_sign_add_smul_left] #align orientation.oangle_sign_sub_smul_left Orientation.oangle_sign_sub_smul_left @[simp] theorem oangle_sign_add_right (x y : V) : (o.oangle x (x + y)).sign = (o.oangle x y).sign := by rw [← o.oangle_sign_smul_add_right x y 1, one_smul] #align orientation.oangle_sign_add_right Orientation.oangle_sign_add_right @[simp] theorem oangle_sign_add_left (x y : V) : (o.oangle (x + y) y).sign = (o.oangle x y).sign := by rw [← o.oangle_sign_add_smul_left x y 1, one_smul] #align orientation.oangle_sign_add_left Orientation.oangle_sign_add_left @[simp] theorem oangle_sign_sub_right (x y : V) : (o.oangle x (y - x)).sign = (o.oangle x y).sign := by rw [← o.oangle_sign_sub_smul_right x y 1, one_smul] #align orientation.oangle_sign_sub_right Orientation.oangle_sign_sub_right @[simp] theorem oangle_sign_sub_left (x y : V) : (o.oangle (x - y) y).sign = (o.oangle x y).sign := by rw [← o.oangle_sign_sub_smul_left x y 1, one_smul] #align orientation.oangle_sign_sub_left Orientation.oangle_sign_sub_left @[simp] theorem oangle_sign_smul_sub_right (x y : V) (r : ℝ) : (o.oangle x (r • x - y)).sign = -(o.oangle x y).sign := by rw [← oangle_sign_neg_right, sub_eq_add_neg, oangle_sign_smul_add_right] #align orientation.oangle_sign_smul_sub_right Orientation.oangle_sign_smul_sub_right @[simp] theorem oangle_sign_smul_sub_left (x y : V) (r : ℝ) : (o.oangle (r • y - x) y).sign = -(o.oangle x y).sign := by rw [← oangle_sign_neg_left, sub_eq_neg_add, oangle_sign_add_smul_left] #align orientation.oangle_sign_smul_sub_left Orientation.oangle_sign_smul_sub_left
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
999
1,001
theorem oangle_sign_sub_right_eq_neg (x y : V) : (o.oangle x (x - y)).sign = -(o.oangle x y).sign := by
rw [← o.oangle_sign_smul_sub_right x y 1, one_smul]
import Mathlib.Order.Filter.AtTopBot import Mathlib.Order.Filter.Pi #align_import order.filter.cofinite from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1" open Set Function variable {ι α β : Type*} {l : Filter α} namespace Filter def cofinite : Filter α := comk Set.Finite finite_empty (fun _t ht _s hsub ↦ ht.subset hsub) fun _ h _ ↦ h.union #align filter.cofinite Filter.cofinite @[simp] theorem mem_cofinite {s : Set α} : s ∈ @cofinite α ↔ sᶜ.Finite := Iff.rfl #align filter.mem_cofinite Filter.mem_cofinite @[simp] theorem eventually_cofinite {p : α → Prop} : (∀ᶠ x in cofinite, p x) ↔ { x | ¬p x }.Finite := Iff.rfl #align filter.eventually_cofinite Filter.eventually_cofinite theorem hasBasis_cofinite : HasBasis cofinite (fun s : Set α => s.Finite) compl := ⟨fun s => ⟨fun h => ⟨sᶜ, h, (compl_compl s).subset⟩, fun ⟨_t, htf, hts⟩ => htf.subset <| compl_subset_comm.2 hts⟩⟩ #align filter.has_basis_cofinite Filter.hasBasis_cofinite instance cofinite_neBot [Infinite α] : NeBot (@cofinite α) := hasBasis_cofinite.neBot_iff.2 fun hs => hs.infinite_compl.nonempty #align filter.cofinite_ne_bot Filter.cofinite_neBot @[simp] theorem cofinite_eq_bot_iff : @cofinite α = ⊥ ↔ Finite α := by simp [← empty_mem_iff_bot, finite_univ_iff] @[simp] theorem cofinite_eq_bot [Finite α] : @cofinite α = ⊥ := cofinite_eq_bot_iff.2 ‹_› theorem frequently_cofinite_iff_infinite {p : α → Prop} : (∃ᶠ x in cofinite, p x) ↔ Set.Infinite { x | p x } := by simp only [Filter.Frequently, eventually_cofinite, not_not, Set.Infinite] #align filter.frequently_cofinite_iff_infinite Filter.frequently_cofinite_iff_infinite lemma frequently_cofinite_mem_iff_infinite {s : Set α} : (∃ᶠ x in cofinite, x ∈ s) ↔ s.Infinite := frequently_cofinite_iff_infinite alias ⟨_, _root_.Set.Infinite.frequently_cofinite⟩ := frequently_cofinite_mem_iff_infinite @[simp] lemma cofinite_inf_principal_neBot_iff {s : Set α} : (cofinite ⊓ 𝓟 s).NeBot ↔ s.Infinite := frequently_mem_iff_neBot.symm.trans frequently_cofinite_mem_iff_infinite alias ⟨_, _root_.Set.Infinite.cofinite_inf_principal_neBot⟩ := cofinite_inf_principal_neBot_iff theorem _root_.Set.Finite.compl_mem_cofinite {s : Set α} (hs : s.Finite) : sᶜ ∈ @cofinite α := mem_cofinite.2 <| (compl_compl s).symm ▸ hs #align set.finite.compl_mem_cofinite Set.Finite.compl_mem_cofinite theorem _root_.Set.Finite.eventually_cofinite_nmem {s : Set α} (hs : s.Finite) : ∀ᶠ x in cofinite, x ∉ s := hs.compl_mem_cofinite #align set.finite.eventually_cofinite_nmem Set.Finite.eventually_cofinite_nmem theorem _root_.Finset.eventually_cofinite_nmem (s : Finset α) : ∀ᶠ x in cofinite, x ∉ s := s.finite_toSet.eventually_cofinite_nmem #align finset.eventually_cofinite_nmem Finset.eventually_cofinite_nmem theorem _root_.Set.infinite_iff_frequently_cofinite {s : Set α} : Set.Infinite s ↔ ∃ᶠ x in cofinite, x ∈ s := frequently_cofinite_iff_infinite.symm #align set.infinite_iff_frequently_cofinite Set.infinite_iff_frequently_cofinite theorem eventually_cofinite_ne (x : α) : ∀ᶠ a in cofinite, a ≠ x := (Set.finite_singleton x).eventually_cofinite_nmem #align filter.eventually_cofinite_ne Filter.eventually_cofinite_ne
Mathlib/Order/Filter/Cofinite.lean
101
104
theorem le_cofinite_iff_compl_singleton_mem : l ≤ cofinite ↔ ∀ x, {x}ᶜ ∈ l := by
refine ⟨fun h x => h (finite_singleton x).compl_mem_cofinite, fun h s (hs : sᶜ.Finite) => ?_⟩ rw [← compl_compl s, ← biUnion_of_singleton sᶜ, compl_iUnion₂, Filter.biInter_mem hs] exact fun x _ => h x
import Mathlib.Data.Finset.Lattice import Mathlib.Order.Hom.Basic import Mathlib.Data.Set.Finite import Mathlib.Order.ConditionallyCompleteLattice.Basic #align_import order.partial_sups from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" variable {α : Type*} section SemilatticeSup variable [SemilatticeSup α] def partialSups (f : ℕ → α) : ℕ →o α := ⟨@Nat.rec (fun _ => α) (f 0) fun (n : ℕ) (a : α) => a ⊔ f (n + 1), monotone_nat_of_le_succ fun _ => le_sup_left⟩ #align partial_sups partialSups @[simp] theorem partialSups_zero (f : ℕ → α) : partialSups f 0 = f 0 := rfl #align partial_sups_zero partialSups_zero @[simp] theorem partialSups_succ (f : ℕ → α) (n : ℕ) : partialSups f (n + 1) = partialSups f n ⊔ f (n + 1) := rfl #align partial_sups_succ partialSups_succ lemma partialSups_iff_forall {f : ℕ → α} (p : α → Prop) (hp : ∀ {a b}, p (a ⊔ b) ↔ p a ∧ p b) : ∀ {n : ℕ}, p (partialSups f n) ↔ ∀ k ≤ n, p (f k) | 0 => by simp | (n + 1) => by simp [hp, partialSups_iff_forall, ← Nat.lt_succ_iff, ← Nat.forall_lt_succ] @[simp] lemma partialSups_le_iff {f : ℕ → α} {n : ℕ} {a : α} : partialSups f n ≤ a ↔ ∀ k ≤ n, f k ≤ a := partialSups_iff_forall (· ≤ a) sup_le_iff theorem le_partialSups_of_le (f : ℕ → α) {m n : ℕ} (h : m ≤ n) : f m ≤ partialSups f n := partialSups_le_iff.1 le_rfl m h #align le_partial_sups_of_le le_partialSups_of_le theorem le_partialSups (f : ℕ → α) : f ≤ partialSups f := fun _n => le_partialSups_of_le f le_rfl #align le_partial_sups le_partialSups theorem partialSups_le (f : ℕ → α) (n : ℕ) (a : α) (w : ∀ m, m ≤ n → f m ≤ a) : partialSups f n ≤ a := partialSups_le_iff.2 w #align partial_sups_le partialSups_le @[simp] lemma upperBounds_range_partialSups (f : ℕ → α) : upperBounds (Set.range (partialSups f)) = upperBounds (Set.range f) := by ext a simp only [mem_upperBounds, Set.forall_mem_range, partialSups_le_iff] exact ⟨fun h _ ↦ h _ _ le_rfl, fun h _ _ _ ↦ h _⟩ @[simp] theorem bddAbove_range_partialSups {f : ℕ → α} : BddAbove (Set.range (partialSups f)) ↔ BddAbove (Set.range f) := .of_eq <| congr_arg Set.Nonempty <| upperBounds_range_partialSups f #align bdd_above_range_partial_sups bddAbove_range_partialSups
Mathlib/Order/PartialSups.lean
97
101
theorem Monotone.partialSups_eq {f : ℕ → α} (hf : Monotone f) : (partialSups f : ℕ → α) = f := by
ext n induction' n with n ih · rfl · rw [partialSups_succ, ih, sup_eq_right.2 (hf (Nat.le_succ _))]
import Mathlib.Algebra.MonoidAlgebra.Degree import Mathlib.Algebra.Polynomial.Coeff import Mathlib.Algebra.Polynomial.Monomial import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Nat.WithBot import Mathlib.Data.Nat.Cast.WithTop import Mathlib.Data.Nat.SuccPred #align_import data.polynomial.degree.definitions from "leanprover-community/mathlib"@"808ea4ebfabeb599f21ec4ae87d6dc969597887f" -- Porting note: `Mathlib.Data.Nat.Cast.WithTop` should be imported for `Nat.cast_withBot`. set_option linter.uppercaseLean3 false noncomputable section open Finsupp Finset open Polynomial namespace Polynomial universe u v variable {R : Type u} {S : Type v} {a b c d : R} {n m : ℕ} section Semiring variable [Semiring R] {p q r : R[X]} def degree (p : R[X]) : WithBot ℕ := p.support.max #align polynomial.degree Polynomial.degree theorem supDegree_eq_degree (p : R[X]) : p.toFinsupp.supDegree WithBot.some = p.degree := max_eq_sup_coe theorem degree_lt_wf : WellFounded fun p q : R[X] => degree p < degree q := InvImage.wf degree wellFounded_lt #align polynomial.degree_lt_wf Polynomial.degree_lt_wf instance : WellFoundedRelation R[X] := ⟨_, degree_lt_wf⟩ def natDegree (p : R[X]) : ℕ := (degree p).unbot' 0 #align polynomial.nat_degree Polynomial.natDegree def leadingCoeff (p : R[X]) : R := coeff p (natDegree p) #align polynomial.leading_coeff Polynomial.leadingCoeff def Monic (p : R[X]) := leadingCoeff p = (1 : R) #align polynomial.monic Polynomial.Monic @[nontriviality] theorem monic_of_subsingleton [Subsingleton R] (p : R[X]) : Monic p := Subsingleton.elim _ _ #align polynomial.monic_of_subsingleton Polynomial.monic_of_subsingleton theorem Monic.def : Monic p ↔ leadingCoeff p = 1 := Iff.rfl #align polynomial.monic.def Polynomial.Monic.def instance Monic.decidable [DecidableEq R] : Decidable (Monic p) := by unfold Monic; infer_instance #align polynomial.monic.decidable Polynomial.Monic.decidable @[simp] theorem Monic.leadingCoeff {p : R[X]} (hp : p.Monic) : leadingCoeff p = 1 := hp #align polynomial.monic.leading_coeff Polynomial.Monic.leadingCoeff theorem Monic.coeff_natDegree {p : R[X]} (hp : p.Monic) : p.coeff p.natDegree = 1 := hp #align polynomial.monic.coeff_nat_degree Polynomial.Monic.coeff_natDegree @[simp] theorem degree_zero : degree (0 : R[X]) = ⊥ := rfl #align polynomial.degree_zero Polynomial.degree_zero @[simp] theorem natDegree_zero : natDegree (0 : R[X]) = 0 := rfl #align polynomial.nat_degree_zero Polynomial.natDegree_zero @[simp] theorem coeff_natDegree : coeff p (natDegree p) = leadingCoeff p := rfl #align polynomial.coeff_nat_degree Polynomial.coeff_natDegree @[simp] theorem degree_eq_bot : degree p = ⊥ ↔ p = 0 := ⟨fun h => support_eq_empty.1 (Finset.max_eq_bot.1 h), fun h => h.symm ▸ rfl⟩ #align polynomial.degree_eq_bot Polynomial.degree_eq_bot @[nontriviality] theorem degree_of_subsingleton [Subsingleton R] : degree p = ⊥ := by rw [Subsingleton.elim p 0, degree_zero] #align polynomial.degree_of_subsingleton Polynomial.degree_of_subsingleton @[nontriviality] theorem natDegree_of_subsingleton [Subsingleton R] : natDegree p = 0 := by rw [Subsingleton.elim p 0, natDegree_zero] #align polynomial.nat_degree_of_subsingleton Polynomial.natDegree_of_subsingleton theorem degree_eq_natDegree (hp : p ≠ 0) : degree p = (natDegree p : WithBot ℕ) := by let ⟨n, hn⟩ := not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt degree_eq_bot.1 hp)) have hn : degree p = some n := Classical.not_not.1 hn rw [natDegree, hn]; rfl #align polynomial.degree_eq_nat_degree Polynomial.degree_eq_natDegree theorem supDegree_eq_natDegree (p : R[X]) : p.toFinsupp.supDegree id = p.natDegree := by obtain rfl|h := eq_or_ne p 0 · simp apply WithBot.coe_injective rw [← AddMonoidAlgebra.supDegree_withBot_some_comp, Function.comp_id, supDegree_eq_degree, degree_eq_natDegree h, Nat.cast_withBot] rwa [support_toFinsupp, nonempty_iff_ne_empty, Ne, support_eq_empty]
Mathlib/Algebra/Polynomial/Degree/Definitions.lean
146
147
theorem degree_eq_iff_natDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) : p.degree = n ↔ p.natDegree = n := by
rw [degree_eq_natDegree hp]; exact WithBot.coe_eq_coe
import Batteries.Classes.Order namespace Batteries.PairingHeapImp inductive Heap (α : Type u) where | nil : Heap α | node (a : α) (child sibling : Heap α) : Heap α deriving Repr def Heap.size : Heap α → Nat | .nil => 0 | .node _ c s => c.size + 1 + s.size def Heap.singleton (a : α) : Heap α := .node a .nil .nil def Heap.isEmpty : Heap α → Bool | .nil => true | _ => false @[specialize] def Heap.merge (le : α → α → Bool) : Heap α → Heap α → Heap α | .nil, .nil => .nil | .nil, .node a₂ c₂ _ => .node a₂ c₂ .nil | .node a₁ c₁ _, .nil => .node a₁ c₁ .nil | .node a₁ c₁ _, .node a₂ c₂ _ => if le a₁ a₂ then .node a₁ (.node a₂ c₂ c₁) .nil else .node a₂ (.node a₁ c₁ c₂) .nil @[specialize] def Heap.combine (le : α → α → Bool) : Heap α → Heap α | h₁@(.node _ _ h₂@(.node _ _ s)) => merge le (merge le h₁ h₂) (s.combine le) | h => h @[inline] def Heap.headD (a : α) : Heap α → α | .nil => a | .node a _ _ => a @[inline] def Heap.head? : Heap α → Option α | .nil => none | .node a _ _ => some a @[inline] def Heap.deleteMin (le : α → α → Bool) : Heap α → Option (α × Heap α) | .nil => none | .node a c _ => (a, combine le c) @[inline] def Heap.tail? (le : α → α → Bool) (h : Heap α) : Option (Heap α) := deleteMin le h |>.map (·.snd) @[inline] def Heap.tail (le : α → α → Bool) (h : Heap α) : Heap α := tail? le h |>.getD .nil inductive Heap.NoSibling : Heap α → Prop | nil : NoSibling .nil | node (a c) : NoSibling (.node a c .nil) instance : Decidable (Heap.NoSibling s) := match s with | .nil => isTrue .nil | .node a c .nil => isTrue (.node a c) | .node _ _ (.node _ _ _) => isFalse nofun theorem Heap.noSibling_merge (le) (s₁ s₂ : Heap α) : (s₁.merge le s₂).NoSibling := by unfold merge (split <;> try split) <;> constructor theorem Heap.noSibling_combine (le) (s : Heap α) : (s.combine le).NoSibling := by unfold combine; split · exact noSibling_merge _ _ _ · match s with | nil | node _ _ nil => constructor | node _ _ (node _ _ s) => rename_i h; exact (h _ _ _ _ _ rfl).elim theorem Heap.noSibling_deleteMin {s : Heap α} (eq : s.deleteMin le = some (a, s')) : s'.NoSibling := by cases s with cases eq | node a c => exact noSibling_combine _ _ theorem Heap.noSibling_tail? {s : Heap α} : s.tail? le = some s' → s'.NoSibling := by simp only [Heap.tail?]; intro eq match eq₂ : s.deleteMin le, eq with | some (a, tl), rfl => exact noSibling_deleteMin eq₂ theorem Heap.noSibling_tail (le) (s : Heap α) : (s.tail le).NoSibling := by simp only [Heap.tail] match eq : s.tail? le with | none => cases s with cases eq | nil => constructor | some tl => exact Heap.noSibling_tail? eq theorem Heap.size_merge_node (le) (a₁ : α) (c₁ s₁ : Heap α) (a₂ : α) (c₂ s₂ : Heap α) : (merge le (.node a₁ c₁ s₁) (.node a₂ c₂ s₂)).size = c₁.size + c₂.size + 2 := by unfold merge; dsimp; split <;> simp_arith [size] theorem Heap.size_merge (le) {s₁ s₂ : Heap α} (h₁ : s₁.NoSibling) (h₂ : s₂.NoSibling) : (merge le s₁ s₂).size = s₁.size + s₂.size := by match h₁, h₂ with | .nil, .nil | .nil, .node _ _ | .node _ _, .nil => simp [size] | .node _ _, .node _ _ => unfold merge; dsimp; split <;> simp_arith [size] theorem Heap.size_combine (le) (s : Heap α) : (s.combine le).size = s.size := by unfold combine; split · rename_i a₁ c₁ a₂ c₂ s rw [size_merge le (noSibling_merge _ _ _) (noSibling_combine _ _), size_merge_node, size_combine le s] simp_arith [size] · rfl theorem Heap.size_deleteMin {s : Heap α} (h : s.NoSibling) (eq : s.deleteMin le = some (a, s')) : s.size = s'.size + 1 := by cases h with cases eq | node a c => rw [size_combine, size, size] theorem Heap.size_tail? {s : Heap α} (h : s.NoSibling) : s.tail? le = some s' → s.size = s'.size + 1 := by simp only [Heap.tail?]; intro eq match eq₂ : s.deleteMin le, eq with | some (a, tl), rfl => exact size_deleteMin h eq₂ theorem Heap.size_tail (le) {s : Heap α} (h : s.NoSibling) : (s.tail le).size = s.size - 1 := by simp only [Heap.tail] match eq : s.tail? le with | none => cases s with cases eq | nil => rfl | some tl => simp [Heap.size_tail? h eq] theorem Heap.size_deleteMin_lt {s : Heap α} (eq : s.deleteMin le = some (a, s')) : s'.size < s.size := by cases s with cases eq | node a c => simp_arith [size_combine, size] theorem Heap.size_tail?_lt {s : Heap α} : s.tail? le = some s' → s'.size < s.size := by simp only [Heap.tail?]; intro eq match eq₂ : s.deleteMin le, eq with | some (a, tl), rfl => exact size_deleteMin_lt eq₂ @[specialize] def Heap.foldM [Monad m] (le : α → α → Bool) (s : Heap α) (init : β) (f : β → α → m β) : m β := match eq : s.deleteMin le with | none => pure init | some (hd, tl) => have : tl.size < s.size := by simp_arith [Heap.size_deleteMin_lt eq] do foldM le tl (← f init hd) f termination_by s.size @[inline] def Heap.fold (le : α → α → Bool) (s : Heap α) (init : β) (f : β → α → β) : β := Id.run <| s.foldM le init f @[inline] def Heap.toArray (le : α → α → Bool) (s : Heap α) : Array α := fold le s #[] Array.push @[inline] def Heap.toList (le : α → α → Bool) (s : Heap α) : List α := (s.toArray le).toList @[specialize] def Heap.foldTreeM [Monad m] (nil : β) (join : α → β → β → m β) : Heap α → m β | .nil => pure nil | .node a c s => do join a (← c.foldTreeM nil join) (← s.foldTreeM nil join) @[inline] def Heap.foldTree (nil : β) (join : α → β → β → β) (s : Heap α) : β := Id.run <| s.foldTreeM nil join def Heap.toListUnordered (s : Heap α) : List α := s.foldTree id (fun a c s l => a :: c (s l)) [] def Heap.toArrayUnordered (s : Heap α) : Array α := s.foldTree id (fun a c s r => s (c (r.push a))) #[] def Heap.NodeWF (le : α → α → Bool) (a : α) : Heap α → Prop | .nil => True | .node b c s => (∀ [TotalBLE le], le a b) ∧ c.NodeWF le b ∧ s.NodeWF le a inductive Heap.WF (le : α → α → Bool) : Heap α → Prop | nil : WF le .nil | node (h : c.NodeWF le a) : WF le (.node a c .nil) theorem Heap.WF.singleton : (Heap.singleton a).WF le := node trivial theorem Heap.WF.merge_node (h₁ : NodeWF le a₁ c₁) (h₂ : NodeWF le a₂ c₂) : (merge le (.node a₁ c₁ s₁) (.node a₂ c₂ s₂)).WF le := by unfold merge; dsimp split <;> rename_i h · exact node ⟨fun [_] => h, h₂, h₁⟩ · exact node ⟨fun [_] => TotalBLE.total.resolve_left h, h₁, h₂⟩ theorem Heap.WF.merge (h₁ : s₁.WF le) (h₂ : s₂.WF le) : (merge le s₁ s₂).WF le := match h₁, h₂ with | .nil, .nil => nil | .nil, .node h₂ => node h₂ | .node h₁, .nil => node h₁ | .node h₁, .node h₂ => merge_node h₁ h₂ theorem Heap.WF.combine (h : s.NodeWF le a) : (combine le s).WF le := match s with | .nil => nil | .node _b _c .nil => node h.2.1 | .node _b₁ _c₁ (.node _b₂ _c₂ _s) => merge (merge_node h.2.1 h.2.2.2.1) (combine h.2.2.2.2)
.lake/packages/batteries/Batteries/Data/PairingHeap.lean
252
254
theorem Heap.WF.deleteMin {s : Heap α} (h : s.WF le) (eq : s.deleteMin le = some (a, s')) : s'.WF le := by
cases h with cases eq | node h => exact Heap.WF.combine h
import Mathlib.LinearAlgebra.TensorProduct.RightExactness import Mathlib.LinearAlgebra.TensorProduct.Finiteness universe u variable (R : Type u) [CommRing R] variable {M : Type u} [AddCommGroup M] [Module R M] variable {N : Type u} [AddCommGroup N] [Module R N] open Classical DirectSum LinearMap Function Submodule namespace TensorProduct variable {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N} variable (m n) in abbrev VanishesTrivially : Prop := ∃ (κ : Type u) (_ : Fintype κ) (a : ι → κ → R) (y : κ → N), (∀ i, n i = ∑ j, a i j • y j) ∧ ∀ j, ∑ i, a i j • m i = 0 theorem sum_tmul_eq_zero_of_vanishesTrivially (hmn : VanishesTrivially R m n) : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := by obtain ⟨κ, _, a, y, h₁, h₂⟩ := hmn simp_rw [h₁, tmul_sum, tmul_smul] rw [Finset.sum_comm] simp_rw [← tmul_smul, ← smul_tmul, ← sum_tmul, h₂, zero_tmul, Finset.sum_const_zero] theorem vanishesTrivially_of_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Define a map $G \colon R^\iota \to M$ whose matrix entries are the $m_i$. It is surjective. set G : (ι →₀ R) →ₗ[R] M := Finsupp.total ι M R m with hG have G_basis_eq (i : ι) : G (Finsupp.single i 1) = m i := by simp [hG, toModule_lof] have G_surjective : Surjective G := by apply LinearMap.range_eq_top.mp apply top_le_iff.mp rw [← hm] apply Submodule.span_le.mpr rintro _ ⟨i, rfl⟩ use Finsupp.single i 1, G_basis_eq i set en : (ι →₀ R) ⊗[R] N := ∑ i, Finsupp.single i 1 ⊗ₜ n i with hen have en_mem_ker : en ∈ ker (rTensor N G) := by simp [hen, G_basis_eq, hmn] -- We have an exact sequence $\ker G \to R^\iota \to M \to 0$. have exact_ker_subtype : Exact (ker G).subtype G := G.exact_subtype_ker_map -- Tensor the exact sequence with $N$. have exact_rTensor_ker_subtype : Exact (rTensor N (ker G).subtype) (rTensor N G) := rTensor_exact (M := ↥(ker G)) N exact_ker_subtype G_surjective have en_mem_range : en ∈ range (rTensor N (ker G).subtype) := exact_rTensor_ker_subtype.linearMap_ker_eq ▸ en_mem_ker obtain ⟨kn, hkn⟩ := en_mem_range obtain ⟨ma, rfl : kn = ∑ kj ∈ ma, kj.1 ⊗ₜ[R] kj.2⟩ := exists_finset kn use ↑↑ma, FinsetCoe.fintype ma use fun i ⟨⟨kj, _⟩, _⟩ ↦ (kj : ι →₀ R) i use fun ⟨⟨_, yj⟩, _⟩ ↦ yj constructor · intro i apply_fun finsuppScalarLeft R N ι at hkn apply_fun (· i) at hkn symm at hkn simp only [map_sum, finsuppScalarLeft_apply_tmul, zero_smul, Finsupp.single_zero, Finsupp.sum_single_index, one_smul, Finsupp.finset_sum_apply, Finsupp.single_apply, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, rTensor_tmul, coeSubtype, Finsupp.sum_apply, Finsupp.sum_ite_eq', Finsupp.mem_support_iff, ne_eq, ite_not, en] at hkn simp only [Finset.univ_eq_attach, Finset.sum_attach ma (fun x ↦ (x.1 : ι →₀ R) i • x.2)] convert hkn using 2 with x _ split · next h'x => rw [h'x, zero_smul] · rfl · rintro ⟨⟨⟨k, hk⟩, _⟩, _⟩ simpa only [hG, Finsupp.total_apply, zero_smul, implies_true, Finsupp.sum_fintype] using mem_ker.mp hk theorem vanishesTrivially_iff_sum_tmul_eq_zero (hm : Submodule.span R (Set.range m) = ⊤) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero R hm⟩ theorem vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) (hmn : ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N)) : VanishesTrivially R m n := by -- Restrict `m` on the codomain to $M'$, then apply `vanishesTrivially_of_sum_tmul_eq_zero`. have mem_M' i : m i ∈ span R (Set.range m) := subset_span ⟨i, rfl⟩ set m' : ι → span R (Set.range m) := Subtype.coind m mem_M' with m'_eq have hm' : span R (Set.range m') = ⊤ := by apply map_injective_of_injective (injective_subtype (span R (Set.range m))) rw [Submodule.map_span, Submodule.map_top, range_subtype, coeSubtype, ← Set.range_comp] rfl have hm'n : ∑ i, m' i ⊗ₜ n i = (0 : span R (Set.range m) ⊗[R] N) := by apply hm simp only [m'_eq, map_sum, rTensor_tmul, coeSubtype, Subtype.coind_coe, _root_.map_zero, hmn] have : VanishesTrivially R m' n := vanishesTrivially_of_sum_tmul_eq_zero R hm' hm'n unfold VanishesTrivially at this ⊢ convert this with κ _ a y j convert (injective_iff_map_eq_zero' _).mp (injective_subtype (span R (Set.range m))) _ simp [m'_eq] theorem vanishesTrivially_iff_sum_tmul_eq_zero_of_rTensor_injective (hm : Injective (rTensor N (span R (Set.range m)).subtype)) : VanishesTrivially R m n ↔ ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) := ⟨sum_tmul_eq_zero_of_vanishesTrivially R, vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R hm⟩ theorem rTensor_injective_of_forall_vanishesTrivially (hMN : ∀ {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) (M' : Submodule R M) : Injective (rTensor N M'.subtype) := by apply (injective_iff_map_eq_zero _).mpr rintro x hx obtain ⟨s, rfl⟩ := exists_finset x rw [← Finset.sum_attach] apply sum_tmul_eq_zero_of_vanishesTrivially simp only [map_sum, rTensor_tmul, coeSubtype] at hx have := hMN ((Finset.sum_attach s _).trans hx) unfold VanishesTrivially at this ⊢ convert this with κ _ a y j symm convert (injective_iff_map_eq_zero' _).mp (injective_subtype M') _ simp theorem forall_vanishesTrivially_iff_forall_rTensor_injective : (∀ {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) ↔ ∀ M' : Submodule R M, Injective (rTensor N M'.subtype) := by constructor · intro h exact rTensor_injective_of_forall_vanishesTrivially R h · intro h ι _ m n hmn exact vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R (h _) hmn
Mathlib/LinearAlgebra/TensorProduct/Vanishing.lean
243
252
theorem forall_vanishesTrivially_iff_forall_FG_rTensor_injective : (∀ {ι : Type u} [Fintype ι] {m : ι → M} {n : ι → N}, ∑ i, m i ⊗ₜ n i = (0 : M ⊗[R] N) → VanishesTrivially R m n) ↔ ∀ (M' : Submodule R M) (_ : M'.FG), Injective (rTensor N M'.subtype) := by
constructor · intro h M' _ exact rTensor_injective_of_forall_vanishesTrivially R h M' · intro h ι _ m n hmn exact vanishesTrivially_of_sum_tmul_eq_zero_of_rTensor_injective R (h _ (fg_span (Set.finite_range _))) hmn
import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.Archimedean import Mathlib.Algebra.Order.Group.Instances import Mathlib.GroupTheory.GroupAction.Pi open Function Set structure AddConstMap (G H : Type*) [Add G] [Add H] (a : G) (b : H) where protected toFun : G → H map_add_const' (x : G) : toFun (x + a) = toFun x + b @[inherit_doc] scoped [AddConstMap] notation:25 G " →+c[" a ", " b "] " H => AddConstMap G H a b class AddConstMapClass (F : Type*) (G H : outParam Type*) [Add G] [Add H] (a : outParam G) (b : outParam H) extends DFunLike F G fun _ ↦ H where map_add_const (f : F) (x : G) : f (x + a) = f x + b namespace AddConstMapClass attribute [simp] map_add_const variable {F G H : Type*} {a : G} {b : H} protected theorem semiconj [Add G] [Add H] [AddConstMapClass F G H a b] (f : F) : Semiconj f (· + a) (· + b) := map_add_const f @[simp] theorem map_add_nsmul [AddMonoid G] [AddMonoid H] [AddConstMapClass F G H a b] (f : F) (x : G) (n : ℕ) : f (x + n • a) = f x + n • b := by simpa using (AddConstMapClass.semiconj f).iterate_right n x @[simp]
Mathlib/Algebra/AddConstMap/Basic.lean
78
79
theorem map_add_nat' [AddMonoidWithOne G] [AddMonoid H] [AddConstMapClass F G H 1 b] (f : F) (x : G) (n : ℕ) : f (x + n) = f x + n • b := by
simp [← map_add_nsmul]
import Mathlib.MeasureTheory.Integral.Lebesgue import Mathlib.Analysis.MeanInequalities import Mathlib.Analysis.MeanInequalitiesPow import Mathlib.MeasureTheory.Function.SpecialFunctions.Basic #align_import measure_theory.integral.mean_inequalities from "leanprover-community/mathlib"@"13bf7613c96a9fd66a81b9020a82cad9a6ea1fcf" section LIntegral noncomputable section open scoped Classical open NNReal ENNReal MeasureTheory Finset set_option linter.uppercaseLean3 false variable {α : Type*} [MeasurableSpace α] {μ : Measure α} namespace ENNReal theorem lintegral_mul_le_one_of_lintegral_rpow_eq_one {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_norm : ∫⁻ a, f a ^ p ∂μ = 1) (hg_norm : ∫⁻ a, g a ^ q ∂μ = 1) : (∫⁻ a, (f * g) a ∂μ) ≤ 1 := by calc (∫⁻ a : α, (f * g) a ∂μ) ≤ ∫⁻ a : α, f a ^ p / ENNReal.ofReal p + g a ^ q / ENNReal.ofReal q ∂μ := lintegral_mono fun a => young_inequality (f a) (g a) hpq _ = 1 := by simp only [div_eq_mul_inv] rw [lintegral_add_left'] · rw [lintegral_mul_const'' _ (hf.pow_const p), lintegral_mul_const', hf_norm, hg_norm, one_mul, one_mul, hpq.inv_add_inv_conj_ennreal] simp [hpq.symm.pos] · exact (hf.pow_const _).mul_const _ #align ennreal.lintegral_mul_le_one_of_lintegral_rpow_eq_one ENNReal.lintegral_mul_le_one_of_lintegral_rpow_eq_one def funMulInvSnorm (f : α → ℝ≥0∞) (p : ℝ) (μ : Measure α) : α → ℝ≥0∞ := fun a => f a * ((∫⁻ c, f c ^ p ∂μ) ^ (1 / p))⁻¹ #align ennreal.fun_mul_inv_snorm ENNReal.funMulInvSnorm theorem fun_eq_funMulInvSnorm_mul_snorm {p : ℝ} (f : α → ℝ≥0∞) (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) {a : α} : f a = funMulInvSnorm f p μ a * (∫⁻ c, f c ^ p ∂μ) ^ (1 / p) := by simp [funMulInvSnorm, mul_assoc, ENNReal.inv_mul_cancel, hf_nonzero, hf_top] #align ennreal.fun_eq_fun_mul_inv_snorm_mul_snorm ENNReal.fun_eq_funMulInvSnorm_mul_snorm theorem funMulInvSnorm_rpow {p : ℝ} (hp0 : 0 < p) {f : α → ℝ≥0∞} {a : α} : funMulInvSnorm f p μ a ^ p = f a ^ p * (∫⁻ c, f c ^ p ∂μ)⁻¹ := by rw [funMulInvSnorm, mul_rpow_of_nonneg _ _ (le_of_lt hp0)] suffices h_inv_rpow : ((∫⁻ c : α, f c ^ p ∂μ) ^ (1 / p))⁻¹ ^ p = (∫⁻ c : α, f c ^ p ∂μ)⁻¹ by rw [h_inv_rpow] rw [inv_rpow, ← rpow_mul, one_div_mul_cancel hp0.ne', rpow_one] #align ennreal.fun_mul_inv_snorm_rpow ENNReal.funMulInvSnorm_rpow theorem lintegral_rpow_funMulInvSnorm_eq_one {p : ℝ} (hp0_lt : 0 < p) {f : α → ℝ≥0∞} (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) : ∫⁻ c, funMulInvSnorm f p μ c ^ p ∂μ = 1 := by simp_rw [funMulInvSnorm_rpow hp0_lt] rw [lintegral_mul_const', ENNReal.mul_inv_cancel hf_nonzero hf_top] rwa [inv_ne_top] #align ennreal.lintegral_rpow_fun_mul_inv_snorm_eq_one ENNReal.lintegral_rpow_funMulInvSnorm_eq_one theorem lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_nontop : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) (hg_nontop : (∫⁻ a, g a ^ q ∂μ) ≠ ⊤) (hf_nonzero : (∫⁻ a, f a ^ p ∂μ) ≠ 0) (hg_nonzero : (∫⁻ a, g a ^ q ∂μ) ≠ 0) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by let npf := (∫⁻ c : α, f c ^ p ∂μ) ^ (1 / p) let nqg := (∫⁻ c : α, g c ^ q ∂μ) ^ (1 / q) calc (∫⁻ a : α, (f * g) a ∂μ) = ∫⁻ a : α, (funMulInvSnorm f p μ * funMulInvSnorm g q μ) a * (npf * nqg) ∂μ := by refine lintegral_congr fun a => ?_ rw [Pi.mul_apply, fun_eq_funMulInvSnorm_mul_snorm f hf_nonzero hf_nontop, fun_eq_funMulInvSnorm_mul_snorm g hg_nonzero hg_nontop, Pi.mul_apply] ring _ ≤ npf * nqg := by rw [lintegral_mul_const' (npf * nqg) _ (by simp [npf, nqg, hf_nontop, hg_nontop, hf_nonzero, hg_nonzero, ENNReal.mul_eq_top])] refine mul_le_of_le_one_left' ?_ have hf1 := lintegral_rpow_funMulInvSnorm_eq_one hpq.pos hf_nonzero hf_nontop have hg1 := lintegral_rpow_funMulInvSnorm_eq_one hpq.symm.pos hg_nonzero hg_nontop exact lintegral_mul_le_one_of_lintegral_rpow_eq_one hpq (hf.mul_const _) hf1 hg1 #align ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top theorem ae_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0 : 0 ≤ p) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_zero : ∫⁻ a, f a ^ p ∂μ = 0) : f =ᵐ[μ] 0 := by rw [lintegral_eq_zero_iff' (hf.pow_const p)] at hf_zero filter_upwards [hf_zero] with x rw [Pi.zero_apply, ← not_imp_not] exact fun hx => (rpow_pos_of_nonneg (pos_iff_ne_zero.2 hx) hp0).ne' #align ennreal.ae_eq_zero_of_lintegral_rpow_eq_zero ENNReal.ae_eq_zero_of_lintegral_rpow_eq_zero theorem lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero {p : ℝ} (hp0 : 0 ≤ p) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_zero : ∫⁻ a, f a ^ p ∂μ = 0) : (∫⁻ a, (f * g) a ∂μ) = 0 := by rw [← @lintegral_zero_fun α _ μ] refine lintegral_congr_ae ?_ suffices h_mul_zero : f * g =ᵐ[μ] 0 * g by rwa [zero_mul] at h_mul_zero have hf_eq_zero : f =ᵐ[μ] 0 := ae_eq_zero_of_lintegral_rpow_eq_zero hp0 hf hf_zero exact hf_eq_zero.mul (ae_eq_refl g) #align ennreal.lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero ENNReal.lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero theorem lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top {p q : ℝ} (hp0_lt : 0 < p) (hq0 : 0 ≤ q) {f g : α → ℝ≥0∞} (hf_top : ∫⁻ a, f a ^ p ∂μ = ⊤) (hg_nonzero : (∫⁻ a, g a ^ q ∂μ) ≠ 0) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by refine le_trans le_top (le_of_eq ?_) have hp0_inv_lt : 0 < 1 / p := by simp [hp0_lt] rw [hf_top, ENNReal.top_rpow_of_pos hp0_inv_lt] simp [hq0, hg_nonzero] #align ennreal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top theorem lintegral_mul_le_Lp_mul_Lq (μ : Measure α) {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : (∫⁻ a, (f * g) a ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ q ∂μ) ^ (1 / q) := by by_cases hf_zero : ∫⁻ a, f a ^ p ∂μ = 0 · refine Eq.trans_le ?_ (zero_le _) exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.nonneg hf hf_zero by_cases hg_zero : ∫⁻ a, g a ^ q ∂μ = 0 · refine Eq.trans_le ?_ (zero_le _) rw [mul_comm] exact lintegral_mul_eq_zero_of_lintegral_rpow_eq_zero hpq.symm.nonneg hg hg_zero by_cases hf_top : ∫⁻ a, f a ^ p ∂μ = ⊤ · exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.pos hpq.symm.nonneg hf_top hg_zero by_cases hg_top : ∫⁻ a, g a ^ q ∂μ = ⊤ · rw [mul_comm, mul_comm ((∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p))] exact lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_eq_top hpq.symm.pos hpq.nonneg hg_top hf_zero -- non-⊤ non-zero case exact ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top hpq hf hf_top hg_top hf_zero hg_zero #align ennreal.lintegral_mul_le_Lp_mul_Lq ENNReal.lintegral_mul_le_Lp_mul_Lq theorem lintegral_mul_norm_pow_le {α} [MeasurableSpace α] {μ : Measure α} {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) {p q : ℝ} (hp : 0 ≤ p) (hq : 0 ≤ q) (hpq : p + q = 1) : ∫⁻ a, f a ^ p * g a ^ q ∂μ ≤ (∫⁻ a, f a ∂μ) ^ p * (∫⁻ a, g a ∂μ) ^ q := by rcases hp.eq_or_lt with rfl|hp · rw [zero_add] at hpq simp [hpq] rcases hq.eq_or_lt with rfl|hq · rw [add_zero] at hpq simp [hpq] have h2p : 1 < 1 / p := by rw [one_div] apply one_lt_inv hp linarith have h2pq : (1 / p)⁻¹ + (1 / q)⁻¹ = 1 := by simp [hp.ne', hq.ne', hpq] have := ENNReal.lintegral_mul_le_Lp_mul_Lq μ ⟨h2p, h2pq⟩ (hf.pow_const p) (hg.pow_const q) simpa [← ENNReal.rpow_mul, hp.ne', hq.ne'] using this theorem lintegral_prod_norm_pow_le {α ι : Type*} [MeasurableSpace α] {μ : Measure α} (s : Finset ι) {f : ι → α → ℝ≥0∞} (hf : ∀ i ∈ s, AEMeasurable (f i) μ) {p : ι → ℝ} (hp : ∑ i ∈ s, p i = 1) (h2p : ∀ i ∈ s, 0 ≤ p i) : ∫⁻ a, ∏ i ∈ s, f i a ^ p i ∂μ ≤ ∏ i ∈ s, (∫⁻ a, f i a ∂μ) ^ p i := by induction s using Finset.induction generalizing p with | empty => simp at hp | @insert i₀ s hi₀ ih => rcases eq_or_ne (p i₀) 1 with h2i₀|h2i₀ · simp [hi₀] have h2p : ∀ i ∈ s, p i = 0 := by simpa [hi₀, h2i₀, sum_eq_zero_iff_of_nonneg (fun i hi ↦ h2p i <| mem_insert_of_mem hi)] using hp calc ∫⁻ a, f i₀ a ^ p i₀ * ∏ i ∈ s, f i a ^ p i ∂μ = ∫⁻ a, f i₀ a ^ p i₀ * ∏ i ∈ s, 1 ∂μ := by congr! 3 with x apply prod_congr rfl fun i hi ↦ by rw [h2p i hi, ENNReal.rpow_zero] _ ≤ (∫⁻ a, f i₀ a ∂μ) ^ p i₀ * ∏ i ∈ s, 1 := by simp [h2i₀] _ = (∫⁻ a, f i₀ a ∂μ) ^ p i₀ * ∏ i ∈ s, (∫⁻ a, f i a ∂μ) ^ p i := by congr 1 apply prod_congr rfl fun i hi ↦ by rw [h2p i hi, ENNReal.rpow_zero] · have hpi₀ : 0 ≤ 1 - p i₀ := by simp_rw [sub_nonneg, ← hp, single_le_sum h2p (mem_insert_self ..)] have h2pi₀ : 1 - p i₀ ≠ 0 := by rwa [sub_ne_zero, ne_comm] let q := fun i ↦ p i / (1 - p i₀) have hq : ∑ i ∈ s, q i = 1 := by rw [← Finset.sum_div, ← sum_insert_sub hi₀, hp, div_self h2pi₀] have h2q : ∀ i ∈ s, 0 ≤ q i := fun i hi ↦ div_nonneg (h2p i <| mem_insert_of_mem hi) hpi₀ calc ∫⁻ a, ∏ i ∈ insert i₀ s, f i a ^ p i ∂μ = ∫⁻ a, f i₀ a ^ p i₀ * ∏ i ∈ s, f i a ^ p i ∂μ := by simp [hi₀] _ = ∫⁻ a, f i₀ a ^ p i₀ * (∏ i ∈ s, f i a ^ q i) ^ (1 - p i₀) ∂μ := by simp [← ENNReal.prod_rpow_of_nonneg hpi₀, ← ENNReal.rpow_mul, div_mul_cancel₀ (h := h2pi₀)] _ ≤ (∫⁻ a, f i₀ a ∂μ) ^ p i₀ * (∫⁻ a, ∏ i ∈ s, f i a ^ q i ∂μ) ^ (1 - p i₀) := by apply ENNReal.lintegral_mul_norm_pow_le · exact hf i₀ <| mem_insert_self .. · exact s.aemeasurable_prod fun i hi ↦ (hf i <| mem_insert_of_mem hi).pow_const _ · exact h2p i₀ <| mem_insert_self .. · exact hpi₀ · apply add_sub_cancel _ ≤ (∫⁻ a, f i₀ a ∂μ) ^ p i₀ * (∏ i ∈ s, (∫⁻ a, f i a ∂μ) ^ q i) ^ (1 - p i₀) := by gcongr -- behavior of gcongr is heartbeat-dependent, which makes code really fragile... exact ih (fun i hi ↦ hf i <| mem_insert_of_mem hi) hq h2q _ = (∫⁻ a, f i₀ a ∂μ) ^ p i₀ * ∏ i ∈ s, (∫⁻ a, f i a ∂μ) ^ p i := by simp [← ENNReal.prod_rpow_of_nonneg hpi₀, ← ENNReal.rpow_mul, div_mul_cancel₀ (h := h2pi₀)] _ = ∏ i ∈ insert i₀ s, (∫⁻ a, f i a ∂μ) ^ p i := by simp [hi₀] theorem lintegral_mul_prod_norm_pow_le {α ι : Type*} [MeasurableSpace α] {μ : Measure α} (s : Finset ι) {g : α → ℝ≥0∞} {f : ι → α → ℝ≥0∞} (hg : AEMeasurable g μ) (hf : ∀ i ∈ s, AEMeasurable (f i) μ) (q : ℝ) {p : ι → ℝ} (hpq : q + ∑ i ∈ s, p i = 1) (hq : 0 ≤ q) (hp : ∀ i ∈ s, 0 ≤ p i) : ∫⁻ a, g a ^ q * ∏ i ∈ s, f i a ^ p i ∂μ ≤ (∫⁻ a, g a ∂μ) ^ q * ∏ i ∈ s, (∫⁻ a, f i a ∂μ) ^ p i := by suffices ∫⁻ t, ∏ j ∈ insertNone s, Option.elim j (g t) (fun j ↦ f j t) ^ Option.elim j q p ∂μ ≤ ∏ j ∈ insertNone s, (∫⁻ t, Option.elim j (g t) (fun j ↦ f j t) ∂μ) ^ Option.elim j q p by simpa using this refine ENNReal.lintegral_prod_norm_pow_le _ ?_ ?_ ?_ · rintro (_|i) hi · exact hg · refine hf i ?_ simpa using hi · simp_rw [sum_insertNone, Option.elim] exact hpq · rintro (_|i) hi · exact hq · refine hp i ?_ simpa using hi theorem lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top {p : ℝ} {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_top : (∫⁻ a, f a ^ p ∂μ) < ⊤) (hg_top : (∫⁻ a, g a ^ p ∂μ) < ⊤) (hp1 : 1 ≤ p) : (∫⁻ a, (f + g) a ^ p ∂μ) < ⊤ := by have hp0_lt : 0 < p := lt_of_lt_of_le zero_lt_one hp1 have hp0 : 0 ≤ p := le_of_lt hp0_lt calc (∫⁻ a : α, (f a + g a) ^ p ∂μ) ≤ ∫⁻ a, (2 : ℝ≥0∞) ^ (p - 1) * f a ^ p + (2 : ℝ≥0∞) ^ (p - 1) * g a ^ p ∂μ := by refine lintegral_mono fun a => ?_ dsimp only have h_zero_lt_half_rpow : (0 : ℝ≥0∞) < (1 / 2 : ℝ≥0∞) ^ p := by rw [← ENNReal.zero_rpow_of_pos hp0_lt] exact ENNReal.rpow_lt_rpow (by simp [zero_lt_one]) hp0_lt have h_rw : (1 / 2 : ℝ≥0∞) ^ p * (2 : ℝ≥0∞) ^ (p - 1) = 1 / 2 := by rw [sub_eq_add_neg, ENNReal.rpow_add _ _ two_ne_zero ENNReal.coe_ne_top, ← mul_assoc, ← ENNReal.mul_rpow_of_nonneg _ _ hp0, one_div, ENNReal.inv_mul_cancel two_ne_zero ENNReal.coe_ne_top, ENNReal.one_rpow, one_mul, ENNReal.rpow_neg_one] rw [← ENNReal.mul_le_mul_left (ne_of_lt h_zero_lt_half_rpow).symm _] · rw [mul_add, ← mul_assoc, ← mul_assoc, h_rw, ← ENNReal.mul_rpow_of_nonneg _ _ hp0, mul_add] refine ENNReal.rpow_arith_mean_le_arith_mean2_rpow (1 / 2 : ℝ≥0∞) (1 / 2 : ℝ≥0∞) (f a) (g a) ?_ hp1 rw [ENNReal.div_add_div_same, one_add_one_eq_two, ENNReal.div_self two_ne_zero ENNReal.coe_ne_top] · rw [← lt_top_iff_ne_top] refine ENNReal.rpow_lt_top_of_nonneg hp0 ?_ rw [one_div, ENNReal.inv_ne_top] exact two_ne_zero _ < ⊤ := by have h_two : (2 : ℝ≥0∞) ^ (p - 1) ≠ ⊤ := ENNReal.rpow_ne_top_of_nonneg (by simp [hp1]) ENNReal.coe_ne_top rw [lintegral_add_left', lintegral_const_mul'' _ (hf.pow_const p), lintegral_const_mul' _ _ h_two, ENNReal.add_lt_top] · exact ⟨ENNReal.mul_lt_top h_two hf_top.ne, ENNReal.mul_lt_top h_two hg_top.ne⟩ · exact (hf.pow_const p).const_mul _ #align ennreal.lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top ENNReal.lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top theorem lintegral_Lp_mul_le_Lq_mul_Lr {α} [MeasurableSpace α] {p q r : ℝ} (hp0_lt : 0 < p) (hpq : p < q) (hpqr : 1 / p = 1 / q + 1 / r) (μ : Measure α) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) : (∫⁻ a, (f * g) a ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a, f a ^ q ∂μ) ^ (1 / q) * (∫⁻ a, g a ^ r ∂μ) ^ (1 / r) := by have hp0_ne : p ≠ 0 := (ne_of_lt hp0_lt).symm have hp0 : 0 ≤ p := le_of_lt hp0_lt have hq0_lt : 0 < q := lt_of_le_of_lt hp0 hpq have hq0_ne : q ≠ 0 := (ne_of_lt hq0_lt).symm have h_one_div_r : 1 / r = 1 / p - 1 / q := by rw [hpqr]; simp let p2 := q / p let q2 := p2.conjExponent have hp2q2 : p2.IsConjExponent q2 := .conjExponent (by simp [p2, q2, _root_.lt_div_iff, hpq, hp0_lt]) calc (∫⁻ a : α, (f * g) a ^ p ∂μ) ^ (1 / p) = (∫⁻ a : α, f a ^ p * g a ^ p ∂μ) ^ (1 / p) := by simp_rw [Pi.mul_apply, ENNReal.mul_rpow_of_nonneg _ _ hp0] _ ≤ ((∫⁻ a, f a ^ (p * p2) ∂μ) ^ (1 / p2) * (∫⁻ a, g a ^ (p * q2) ∂μ) ^ (1 / q2)) ^ (1 / p) := by gcongr simp_rw [ENNReal.rpow_mul] exact ENNReal.lintegral_mul_le_Lp_mul_Lq μ hp2q2 (hf.pow_const _) (hg.pow_const _) _ = (∫⁻ a : α, f a ^ q ∂μ) ^ (1 / q) * (∫⁻ a : α, g a ^ r ∂μ) ^ (1 / r) := by rw [@ENNReal.mul_rpow_of_nonneg _ _ (1 / p) (by simp [hp0]), ← ENNReal.rpow_mul, ← ENNReal.rpow_mul] have hpp2 : p * p2 = q := by symm rw [mul_comm, ← div_eq_iff hp0_ne] have hpq2 : p * q2 = r := by rw [← inv_inv r, ← one_div, ← one_div, h_one_div_r] field_simp [p2, q2, Real.conjExponent, hp0_ne, hq0_ne] simp_rw [div_mul_div_comm, mul_one, mul_comm p2, mul_comm q2, hpp2, hpq2] #align ennreal.lintegral_Lp_mul_le_Lq_mul_Lr ENNReal.lintegral_Lp_mul_le_Lq_mul_Lr theorem lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) : (∫⁻ a, f a * g a ^ (p - 1) ∂μ) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) * (∫⁻ a, g a ^ p ∂μ) ^ (1 / q) := by refine le_trans (ENNReal.lintegral_mul_le_Lp_mul_Lq μ hpq hf (hg.pow_const _)) ?_ by_cases hf_zero_rpow : (∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p) = 0 · rw [hf_zero_rpow, zero_mul] exact zero_le _ have hf_top_rpow : (∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p) ≠ ⊤ := by by_contra h refine hf_top ?_ have hp_not_neg : ¬p < 0 := by simp [hpq.nonneg] simpa [hpq.pos, hp_not_neg] using h refine (ENNReal.mul_le_mul_left hf_zero_rpow hf_top_rpow).mpr (le_of_eq ?_) congr ext1 a rw [← ENNReal.rpow_mul, hpq.sub_one_mul_conj] #align ennreal.lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow ENNReal.lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow theorem lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) (hg : AEMeasurable g μ) (hg_top : (∫⁻ a, g a ^ p ∂μ) ≠ ⊤) : (∫⁻ a, (f + g) a ^ p ∂μ) ≤ ((∫⁻ a, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a, g a ^ p ∂μ) ^ (1 / p)) * (∫⁻ a, (f a + g a) ^ p ∂μ) ^ (1 / q) := by calc (∫⁻ a, (f + g) a ^ p ∂μ) ≤ ∫⁻ a, (f + g) a * (f + g) a ^ (p - 1) ∂μ := by gcongr with a by_cases h_zero : (f + g) a = 0 · rw [h_zero, ENNReal.zero_rpow_of_pos hpq.pos] exact zero_le _ by_cases h_top : (f + g) a = ⊤ · rw [h_top, ENNReal.top_rpow_of_pos hpq.sub_one_pos, ENNReal.top_mul_top] exact le_top refine le_of_eq ?_ nth_rw 2 [← ENNReal.rpow_one ((f + g) a)] rw [← ENNReal.rpow_add _ _ h_zero h_top, add_sub_cancel] _ = (∫⁻ a : α, f a * (f + g) a ^ (p - 1) ∂μ) + ∫⁻ a : α, g a * (f + g) a ^ (p - 1) ∂μ := by have h_add_m : AEMeasurable (fun a : α => (f + g) a ^ (p - 1 : ℝ)) μ := (hf.add hg).pow_const _ have h_add_apply : (∫⁻ a : α, (f + g) a * (f + g) a ^ (p - 1) ∂μ) = ∫⁻ a : α, (f a + g a) * (f + g) a ^ (p - 1) ∂μ := rfl simp_rw [h_add_apply, add_mul] rw [lintegral_add_left' (hf.mul h_add_m)] _ ≤ ((∫⁻ a, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a, g a ^ p ∂μ) ^ (1 / p)) * (∫⁻ a, (f a + g a) ^ p ∂μ) ^ (1 / q) := by rw [add_mul] gcongr · exact lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow hpq hf (hf.add hg) hf_top · exact lintegral_mul_rpow_le_lintegral_rpow_mul_lintegral_rpow hpq hg (hf.add hg) hg_top #align ennreal.lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add ENNReal.lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add private theorem lintegral_Lp_add_le_aux {p q : ℝ} (hpq : p.IsConjExponent q) {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hf_top : (∫⁻ a, f a ^ p ∂μ) ≠ ⊤) (hg : AEMeasurable g μ) (hg_top : (∫⁻ a, g a ^ p ∂μ) ≠ ⊤) (h_add_zero : (∫⁻ a, (f + g) a ^ p ∂μ) ≠ 0) (h_add_top : (∫⁻ a, (f + g) a ^ p ∂μ) ≠ ⊤) : (∫⁻ a, (f + g) a ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a, g a ^ p ∂μ) ^ (1 / p) := by have hp_not_nonpos : ¬p ≤ 0 := by simp [hpq.pos] have htop_rpow : (∫⁻ a, (f + g) a ^ p ∂μ) ^ (1 / p) ≠ ⊤ := by by_contra h exact h_add_top (@ENNReal.rpow_eq_top_of_nonneg _ (1 / p) (by simp [hpq.nonneg]) h) have h0_rpow : (∫⁻ a, (f + g) a ^ p ∂μ) ^ (1 / p) ≠ 0 := by simp [h_add_zero, h_add_top, hpq.nonneg, hp_not_nonpos, -Pi.add_apply] suffices h : 1 ≤ (∫⁻ a : α, (f + g) a ^ p ∂μ) ^ (-(1 / p)) * ((∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a : α, g a ^ p ∂μ) ^ (1 / p)) by rwa [← mul_le_mul_left h0_rpow htop_rpow, ← mul_assoc, ← rpow_add _ _ h_add_zero h_add_top, ← sub_eq_add_neg, _root_.sub_self, rpow_zero, one_mul, mul_one] at h have h : (∫⁻ a : α, (f + g) a ^ p ∂μ) ≤ ((∫⁻ a : α, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a : α, g a ^ p ∂μ) ^ (1 / p)) * (∫⁻ a : α, (f + g) a ^ p ∂μ) ^ (1 / q) := lintegral_rpow_add_le_add_snorm_mul_lintegral_rpow_add hpq hf hf_top hg hg_top have h_one_div_q : 1 / q = 1 - 1 / p := by nth_rw 2 [← hpq.inv_add_inv_conj] ring simp_rw [h_one_div_q, sub_eq_add_neg 1 (1 / p), ENNReal.rpow_add _ _ h_add_zero h_add_top, rpow_one] at h conv_rhs at h => enter [2]; rw [mul_comm] conv_lhs at h => rw [← one_mul (∫⁻ a : α, (f + g) a ^ p ∂μ)] rwa [← mul_assoc, ENNReal.mul_le_mul_right h_add_zero h_add_top, mul_comm] at h
Mathlib/MeasureTheory/Integral/MeanInequalities.lean
437
462
theorem lintegral_Lp_add_le {p : ℝ} {f g : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) (hp1 : 1 ≤ p) : (∫⁻ a, (f + g) a ^ p ∂μ) ^ (1 / p) ≤ (∫⁻ a, f a ^ p ∂μ) ^ (1 / p) + (∫⁻ a, g a ^ p ∂μ) ^ (1 / p) := by
have hp_pos : 0 < p := lt_of_lt_of_le zero_lt_one hp1 by_cases hf_top : ∫⁻ a, f a ^ p ∂μ = ⊤ · simp [hf_top, hp_pos] by_cases hg_top : ∫⁻ a, g a ^ p ∂μ = ⊤ · simp [hg_top, hp_pos] by_cases h1 : p = 1 · refine le_of_eq ?_ simp_rw [h1, one_div_one, ENNReal.rpow_one] exact lintegral_add_left' hf _ have hp1_lt : 1 < p := by refine lt_of_le_of_ne hp1 ?_ symm exact h1 have hpq := Real.IsConjExponent.conjExponent hp1_lt by_cases h0 : (∫⁻ a, (f + g) a ^ p ∂μ) = 0 · rw [h0, @ENNReal.zero_rpow_of_pos (1 / p) (by simp [lt_of_lt_of_le zero_lt_one hp1])] exact zero_le _ have htop : (∫⁻ a, (f + g) a ^ p ∂μ) ≠ ⊤ := by rw [← Ne] at hf_top hg_top rw [← lt_top_iff_ne_top] at hf_top hg_top ⊢ exact lintegral_rpow_add_lt_top_of_lintegral_rpow_lt_top hf hf_top hg_top hp1 exact lintegral_Lp_add_le_aux hpq hf hf_top hg hg_top h0 htop
import Mathlib.Topology.Separation import Mathlib.Topology.UniformSpace.Basic import Mathlib.Topology.UniformSpace.Cauchy #align_import topology.uniform_space.uniform_convergence from "leanprover-community/mathlib"@"2705404e701abc6b3127da906f40bae062a169c9" noncomputable section open Topology Uniformity Filter Set universe u v w x variable {α : Type u} {β : Type v} {γ : Type w} {ι : Type x} [UniformSpace β] variable {F : ι → α → β} {f : α → β} {s s' : Set α} {x : α} {p : Filter ι} {p' : Filter α} {g : ι → α} def TendstoUniformlyOnFilter (F : ι → α → β) (f : α → β) (p : Filter ι) (p' : Filter α) := ∀ u ∈ 𝓤 β, ∀ᶠ n : ι × α in p ×ˢ p', (f n.snd, F n.fst n.snd) ∈ u #align tendsto_uniformly_on_filter TendstoUniformlyOnFilter theorem tendstoUniformlyOnFilter_iff_tendsto : TendstoUniformlyOnFilter F f p p' ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ p') (𝓤 β) := Iff.rfl #align tendsto_uniformly_on_filter_iff_tendsto tendstoUniformlyOnFilter_iff_tendsto def TendstoUniformlyOn (F : ι → α → β) (f : α → β) (p : Filter ι) (s : Set α) := ∀ u ∈ 𝓤 β, ∀ᶠ n in p, ∀ x : α, x ∈ s → (f x, F n x) ∈ u #align tendsto_uniformly_on TendstoUniformlyOn theorem tendstoUniformlyOn_iff_tendstoUniformlyOnFilter : TendstoUniformlyOn F f p s ↔ TendstoUniformlyOnFilter F f p (𝓟 s) := by simp only [TendstoUniformlyOn, TendstoUniformlyOnFilter] apply forall₂_congr simp_rw [eventually_prod_principal_iff] simp #align tendsto_uniformly_on_iff_tendsto_uniformly_on_filter tendstoUniformlyOn_iff_tendstoUniformlyOnFilter alias ⟨TendstoUniformlyOn.tendstoUniformlyOnFilter, TendstoUniformlyOnFilter.tendstoUniformlyOn⟩ := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter #align tendsto_uniformly_on.tendsto_uniformly_on_filter TendstoUniformlyOn.tendstoUniformlyOnFilter #align tendsto_uniformly_on_filter.tendsto_uniformly_on TendstoUniformlyOnFilter.tendstoUniformlyOn theorem tendstoUniformlyOn_iff_tendsto {F : ι → α → β} {f : α → β} {p : Filter ι} {s : Set α} : TendstoUniformlyOn F f p s ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ 𝓟 s) (𝓤 β) := by simp [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_on_iff_tendsto tendstoUniformlyOn_iff_tendsto def TendstoUniformly (F : ι → α → β) (f : α → β) (p : Filter ι) := ∀ u ∈ 𝓤 β, ∀ᶠ n in p, ∀ x : α, (f x, F n x) ∈ u #align tendsto_uniformly TendstoUniformly -- Porting note: moved from below theorem tendstoUniformlyOn_univ : TendstoUniformlyOn F f p univ ↔ TendstoUniformly F f p := by simp [TendstoUniformlyOn, TendstoUniformly] #align tendsto_uniformly_on_univ tendstoUniformlyOn_univ theorem tendstoUniformly_iff_tendstoUniformlyOnFilter : TendstoUniformly F f p ↔ TendstoUniformlyOnFilter F f p ⊤ := by rw [← tendstoUniformlyOn_univ, tendstoUniformlyOn_iff_tendstoUniformlyOnFilter, principal_univ] #align tendsto_uniformly_iff_tendsto_uniformly_on_filter tendstoUniformly_iff_tendstoUniformlyOnFilter theorem TendstoUniformly.tendstoUniformlyOnFilter (h : TendstoUniformly F f p) : TendstoUniformlyOnFilter F f p ⊤ := by rwa [← tendstoUniformly_iff_tendstoUniformlyOnFilter] #align tendsto_uniformly.tendsto_uniformly_on_filter TendstoUniformly.tendstoUniformlyOnFilter theorem tendstoUniformlyOn_iff_tendstoUniformly_comp_coe : TendstoUniformlyOn F f p s ↔ TendstoUniformly (fun i (x : s) => F i x) (f ∘ (↑)) p := forall₂_congr fun u _ => by simp #align tendsto_uniformly_on_iff_tendsto_uniformly_comp_coe tendstoUniformlyOn_iff_tendstoUniformly_comp_coe theorem tendstoUniformly_iff_tendsto {F : ι → α → β} {f : α → β} {p : Filter ι} : TendstoUniformly F f p ↔ Tendsto (fun q : ι × α => (f q.2, F q.1 q.2)) (p ×ˢ ⊤) (𝓤 β) := by simp [tendstoUniformly_iff_tendstoUniformlyOnFilter, tendstoUniformlyOnFilter_iff_tendsto] #align tendsto_uniformly_iff_tendsto tendstoUniformly_iff_tendsto theorem TendstoUniformlyOnFilter.tendsto_at (h : TendstoUniformlyOnFilter F f p p') (hx : 𝓟 {x} ≤ p') : Tendsto (fun n => F n x) p <| 𝓝 (f x) := by refine Uniform.tendsto_nhds_right.mpr fun u hu => mem_map.mpr ?_ filter_upwards [(h u hu).curry] intro i h simpa using h.filter_mono hx #align tendsto_uniformly_on_filter.tendsto_at TendstoUniformlyOnFilter.tendsto_at theorem TendstoUniformlyOn.tendsto_at (h : TendstoUniformlyOn F f p s) {x : α} (hx : x ∈ s) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.tendstoUniformlyOnFilter.tendsto_at (le_principal_iff.mpr <| mem_principal.mpr <| singleton_subset_iff.mpr <| hx) #align tendsto_uniformly_on.tendsto_at TendstoUniformlyOn.tendsto_at theorem TendstoUniformly.tendsto_at (h : TendstoUniformly F f p) (x : α) : Tendsto (fun n => F n x) p <| 𝓝 (f x) := h.tendstoUniformlyOnFilter.tendsto_at le_top #align tendsto_uniformly.tendsto_at TendstoUniformly.tendsto_at -- Porting note: tendstoUniformlyOn_univ moved up theorem TendstoUniformlyOnFilter.mono_left {p'' : Filter ι} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≤ p) : TendstoUniformlyOnFilter F f p'' p' := fun u hu => (h u hu).filter_mono (p'.prod_mono_left hp) #align tendsto_uniformly_on_filter.mono_left TendstoUniformlyOnFilter.mono_left theorem TendstoUniformlyOnFilter.mono_right {p'' : Filter α} (h : TendstoUniformlyOnFilter F f p p') (hp : p'' ≤ p') : TendstoUniformlyOnFilter F f p p'' := fun u hu => (h u hu).filter_mono (p.prod_mono_right hp) #align tendsto_uniformly_on_filter.mono_right TendstoUniformlyOnFilter.mono_right theorem TendstoUniformlyOn.mono {s' : Set α} (h : TendstoUniformlyOn F f p s) (h' : s' ⊆ s) : TendstoUniformlyOn F f p s' := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (h.tendstoUniformlyOnFilter.mono_right (le_principal_iff.mpr <| mem_principal.mpr h')) #align tendsto_uniformly_on.mono TendstoUniformlyOn.mono theorem TendstoUniformlyOnFilter.congr {F' : ι → α → β} (hf : TendstoUniformlyOnFilter F f p p') (hff' : ∀ᶠ n : ι × α in p ×ˢ p', F n.fst n.snd = F' n.fst n.snd) : TendstoUniformlyOnFilter F' f p p' := by refine fun u hu => ((hf u hu).and hff').mono fun n h => ?_ rw [← h.right] exact h.left #align tendsto_uniformly_on_filter.congr TendstoUniformlyOnFilter.congr theorem TendstoUniformlyOn.congr {F' : ι → α → β} (hf : TendstoUniformlyOn F f p s) (hff' : ∀ᶠ n in p, Set.EqOn (F n) (F' n) s) : TendstoUniformlyOn F' f p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at hf ⊢ refine hf.congr ?_ rw [eventually_iff] at hff' ⊢ simp only [Set.EqOn] at hff' simp only [mem_prod_principal, hff', mem_setOf_eq] #align tendsto_uniformly_on.congr TendstoUniformlyOn.congr theorem TendstoUniformlyOn.congr_right {g : α → β} (hf : TendstoUniformlyOn F f p s) (hfg : EqOn f g s) : TendstoUniformlyOn F g p s := fun u hu => by filter_upwards [hf u hu] with i hi a ha using hfg ha ▸ hi a ha #align tendsto_uniformly_on.congr_right TendstoUniformlyOn.congr_right protected theorem TendstoUniformly.tendstoUniformlyOn (h : TendstoUniformly F f p) : TendstoUniformlyOn F f p s := (tendstoUniformlyOn_univ.2 h).mono (subset_univ s) #align tendsto_uniformly.tendsto_uniformly_on TendstoUniformly.tendstoUniformlyOn theorem TendstoUniformlyOnFilter.comp (h : TendstoUniformlyOnFilter F f p p') (g : γ → α) : TendstoUniformlyOnFilter (fun n => F n ∘ g) (f ∘ g) p (p'.comap g) := by rw [tendstoUniformlyOnFilter_iff_tendsto] at h ⊢ exact h.comp (tendsto_id.prod_map tendsto_comap) #align tendsto_uniformly_on_filter.comp TendstoUniformlyOnFilter.comp theorem TendstoUniformlyOn.comp (h : TendstoUniformlyOn F f p s) (g : γ → α) : TendstoUniformlyOn (fun n => F n ∘ g) (f ∘ g) p (g ⁻¹' s) := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h ⊢ simpa [TendstoUniformlyOn, comap_principal] using TendstoUniformlyOnFilter.comp h g #align tendsto_uniformly_on.comp TendstoUniformlyOn.comp theorem TendstoUniformly.comp (h : TendstoUniformly F f p) (g : γ → α) : TendstoUniformly (fun n => F n ∘ g) (f ∘ g) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] at h ⊢ simpa [principal_univ, comap_principal] using h.comp g #align tendsto_uniformly.comp TendstoUniformly.comp theorem UniformContinuous.comp_tendstoUniformlyOnFilter [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformlyOnFilter F f p p') : TendstoUniformlyOnFilter (fun i => g ∘ F i) (g ∘ f) p p' := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on_filter UniformContinuous.comp_tendstoUniformlyOnFilter theorem UniformContinuous.comp_tendstoUniformlyOn [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformlyOn F f p s) : TendstoUniformlyOn (fun i => g ∘ F i) (g ∘ f) p s := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly_on UniformContinuous.comp_tendstoUniformlyOn theorem UniformContinuous.comp_tendstoUniformly [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (h : TendstoUniformly F f p) : TendstoUniformly (fun i => g ∘ F i) (g ∘ f) p := fun _u hu => h _ (hg hu) #align uniform_continuous.comp_tendsto_uniformly UniformContinuous.comp_tendstoUniformly theorem TendstoUniformlyOnFilter.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {q : Filter ι'} {q' : Filter α'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q q') : TendstoUniformlyOnFilter (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ q) (p' ×ˢ q') := by rw [tendstoUniformlyOnFilter_iff_tendsto] at h h' ⊢ rw [uniformity_prod_eq_comap_prod, tendsto_comap_iff, ← map_swap4_prod, tendsto_map'_iff] convert h.prod_map h' -- seems to be faster than `exact` here #align tendsto_uniformly_on_filter.prod_map TendstoUniformlyOnFilter.prod_map theorem TendstoUniformlyOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {p' : Filter ι'} {s' : Set α'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s') : TendstoUniformlyOn (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ p') (s ×ˢ s') := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] at h h' ⊢ simpa only [prod_principal_principal] using h.prod_map h' #align tendsto_uniformly_on.prod_map TendstoUniformlyOn.prod_map theorem TendstoUniformly.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {f' : α' → β'} {p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (Prod.map f f') (p ×ˢ p') := by rw [← tendstoUniformlyOn_univ, ← univ_prod_univ] at * exact h.prod_map h' #align tendsto_uniformly.prod_map TendstoUniformly.prod_map theorem TendstoUniformlyOnFilter.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {q : Filter ι'} (h : TendstoUniformlyOnFilter F f p p') (h' : TendstoUniformlyOnFilter F' f' q p') : TendstoUniformlyOnFilter (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p ×ˢ q) p' := fun u hu => ((h.prod_map h') u hu).diag_of_prod_right #align tendsto_uniformly_on_filter.prod TendstoUniformlyOnFilter.prod theorem TendstoUniformlyOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {p' : Filter ι'} (h : TendstoUniformlyOn F f p s) (h' : TendstoUniformlyOn F' f' p' s) : TendstoUniformlyOn (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p.prod p') s := (congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a)) #align tendsto_uniformly_on.prod TendstoUniformlyOn.prod theorem TendstoUniformly.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {f' : α → β'} {p' : Filter ι'} (h : TendstoUniformly F f p) (h' : TendstoUniformly F' f' p') : TendstoUniformly (fun (i : ι × ι') a => (F i.1 a, F' i.2 a)) (fun a => (f a, f' a)) (p ×ˢ p') := (h.prod_map h').comp fun a => (a, a) #align tendsto_uniformly.prod TendstoUniformly.prod theorem tendsto_prod_filter_iff {c : β} : Tendsto (↿F) (p ×ˢ p') (𝓝 c) ↔ TendstoUniformlyOnFilter F (fun _ => c) p p' := by simp_rw [nhds_eq_comap_uniformity, tendsto_comap_iff] rfl #align tendsto_prod_filter_iff tendsto_prod_filter_iff theorem tendsto_prod_principal_iff {c : β} : Tendsto (↿F) (p ×ˢ 𝓟 s) (𝓝 c) ↔ TendstoUniformlyOn F (fun _ => c) p s := by rw [tendstoUniformlyOn_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_principal_iff tendsto_prod_principal_iff theorem tendsto_prod_top_iff {c : β} : Tendsto (↿F) (p ×ˢ ⊤) (𝓝 c) ↔ TendstoUniformly F (fun _ => c) p := by rw [tendstoUniformly_iff_tendstoUniformlyOnFilter] exact tendsto_prod_filter_iff #align tendsto_prod_top_iff tendsto_prod_top_iff theorem tendstoUniformlyOn_empty : TendstoUniformlyOn F f p ∅ := fun u _ => by simp #align tendsto_uniformly_on_empty tendstoUniformlyOn_empty theorem tendstoUniformlyOn_singleton_iff_tendsto : TendstoUniformlyOn F f p {x} ↔ Tendsto (fun n : ι => F n x) p (𝓝 (f x)) := by simp_rw [tendstoUniformlyOn_iff_tendsto, Uniform.tendsto_nhds_right, tendsto_def] exact forall₂_congr fun u _ => by simp [mem_prod_principal, preimage] #align tendsto_uniformly_on_singleton_iff_tendsto tendstoUniformlyOn_singleton_iff_tendsto theorem Filter.Tendsto.tendstoUniformlyOnFilter_const {g : ι → β} {b : β} (hg : Tendsto g p (𝓝 b)) (p' : Filter α) : TendstoUniformlyOnFilter (fun n : ι => fun _ : α => g n) (fun _ : α => b) p p' := by simpa only [nhds_eq_comap_uniformity, tendsto_comap_iff] using hg.comp (tendsto_fst (g := p')) #align filter.tendsto.tendsto_uniformly_on_filter_const Filter.Tendsto.tendstoUniformlyOnFilter_const theorem Filter.Tendsto.tendstoUniformlyOn_const {g : ι → β} {b : β} (hg : Tendsto g p (𝓝 b)) (s : Set α) : TendstoUniformlyOn (fun n : ι => fun _ : α => g n) (fun _ : α => b) p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hg.tendstoUniformlyOnFilter_const (𝓟 s)) #align filter.tendsto.tendsto_uniformly_on_const Filter.Tendsto.tendstoUniformlyOn_const -- Porting note (#10756): new lemma theorem UniformContinuousOn.tendstoUniformlyOn [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α} {V : Set β} {F : α → β → γ} (hF : UniformContinuousOn (↿F) (U ×ˢ V)) (hU : x ∈ U) : TendstoUniformlyOn F (F x) (𝓝[U] x) V := by set φ := fun q : α × β => ((x, q.2), q) rw [tendstoUniformlyOn_iff_tendsto] change Tendsto (Prod.map (↿F) ↿F ∘ φ) (𝓝[U] x ×ˢ 𝓟 V) (𝓤 γ) simp only [nhdsWithin, SProd.sprod, Filter.prod, comap_inf, inf_assoc, comap_principal, inf_principal] refine hF.comp (Tendsto.inf ?_ <| tendsto_principal_principal.2 fun x hx => ⟨⟨hU, hx.2⟩, hx⟩) simp only [uniformity_prod_eq_comap_prod, tendsto_comap_iff, (· ∘ ·), nhds_eq_comap_uniformity, comap_comap] exact tendsto_comap.prod_mk (tendsto_diag_uniformity _ _) theorem UniformContinuousOn.tendstoUniformly [UniformSpace α] [UniformSpace γ] {x : α} {U : Set α} (hU : U ∈ 𝓝 x) {F : α → β → γ} (hF : UniformContinuousOn (↿F) (U ×ˢ (univ : Set β))) : TendstoUniformly F (F x) (𝓝 x) := by simpa only [tendstoUniformlyOn_univ, nhdsWithin_eq_nhds.2 hU] using hF.tendstoUniformlyOn (mem_of_mem_nhds hU) #align uniform_continuous_on.tendsto_uniformly UniformContinuousOn.tendstoUniformly theorem UniformContinuous₂.tendstoUniformly [UniformSpace α] [UniformSpace γ] {f : α → β → γ} (h : UniformContinuous₂ f) {x : α} : TendstoUniformly f (f x) (𝓝 x) := UniformContinuousOn.tendstoUniformly univ_mem <| by rwa [univ_prod_univ, uniformContinuousOn_univ] #align uniform_continuous₂.tendsto_uniformly UniformContinuous₂.tendstoUniformly def UniformCauchySeqOnFilter (F : ι → α → β) (p : Filter ι) (p' : Filter α) : Prop := ∀ u ∈ 𝓤 β, ∀ᶠ m : (ι × ι) × α in (p ×ˢ p) ×ˢ p', (F m.fst.fst m.snd, F m.fst.snd m.snd) ∈ u #align uniform_cauchy_seq_on_filter UniformCauchySeqOnFilter def UniformCauchySeqOn (F : ι → α → β) (p : Filter ι) (s : Set α) : Prop := ∀ u ∈ 𝓤 β, ∀ᶠ m : ι × ι in p ×ˢ p, ∀ x : α, x ∈ s → (F m.fst x, F m.snd x) ∈ u #align uniform_cauchy_seq_on UniformCauchySeqOn theorem uniformCauchySeqOn_iff_uniformCauchySeqOnFilter : UniformCauchySeqOn F p s ↔ UniformCauchySeqOnFilter F p (𝓟 s) := by simp only [UniformCauchySeqOn, UniformCauchySeqOnFilter] refine forall₂_congr fun u hu => ?_ rw [eventually_prod_principal_iff] #align uniform_cauchy_seq_on_iff_uniform_cauchy_seq_on_filter uniformCauchySeqOn_iff_uniformCauchySeqOnFilter theorem UniformCauchySeqOn.uniformCauchySeqOnFilter (hF : UniformCauchySeqOn F p s) : UniformCauchySeqOnFilter F p (𝓟 s) := by rwa [← uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] #align uniform_cauchy_seq_on.uniform_cauchy_seq_on_filter UniformCauchySeqOn.uniformCauchySeqOnFilter theorem TendstoUniformlyOnFilter.uniformCauchySeqOnFilter (hF : TendstoUniformlyOnFilter F f p p') : UniformCauchySeqOnFilter F p p' := by intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ have := tendsto_swap4_prod.eventually ((hF t ht).prod_mk (hF t ht)) apply this.diag_of_prod_right.mono simp only [and_imp, Prod.forall] intro n1 n2 x hl hr exact Set.mem_of_mem_of_subset (prod_mk_mem_compRel (htsymm hl) hr) htmem #align tendsto_uniformly_on_filter.uniform_cauchy_seq_on_filter TendstoUniformlyOnFilter.uniformCauchySeqOnFilter theorem TendstoUniformlyOn.uniformCauchySeqOn (hF : TendstoUniformlyOn F f p s) : UniformCauchySeqOn F p s := uniformCauchySeqOn_iff_uniformCauchySeqOnFilter.mpr hF.tendstoUniformlyOnFilter.uniformCauchySeqOnFilter #align tendsto_uniformly_on.uniform_cauchy_seq_on TendstoUniformlyOn.uniformCauchySeqOn theorem UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto [NeBot p] (hF : UniformCauchySeqOnFilter F p p') (hF' : ∀ᶠ x : α in p', Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOnFilter F f p p' := by -- Proof idea: |f_n(x) - f(x)| ≤ |f_n(x) - f_m(x)| + |f_m(x) - f(x)|. We choose `n` -- so that |f_n(x) - f_m(x)| is uniformly small across `s` whenever `m ≥ n`. Then for -- a fixed `x`, we choose `m` sufficiently large such that |f_m(x) - f(x)| is small. intro u hu rcases comp_symm_of_uniformity hu with ⟨t, ht, htsymm, htmem⟩ -- We will choose n, x, and m simultaneously. n and x come from hF. m comes from hF' -- But we need to promote hF' to the full product filter to use it have hmc : ∀ᶠ x in (p ×ˢ p) ×ˢ p', Tendsto (fun n : ι => F n x.snd) p (𝓝 (f x.snd)) := by rw [eventually_prod_iff] exact ⟨fun _ => True, by simp, _, hF', by simp⟩ -- To apply filter operations we'll need to do some order manipulation rw [Filter.eventually_swap_iff] have := tendsto_prodAssoc.eventually (tendsto_prod_swap.eventually ((hF t ht).and hmc)) apply this.curry.mono simp only [Equiv.prodAssoc_apply, eventually_and, eventually_const, Prod.snd_swap, Prod.fst_swap, and_imp, Prod.forall] -- Complete the proof intro x n hx hm' refine Set.mem_of_mem_of_subset (mem_compRel.mpr ?_) htmem rw [Uniform.tendsto_nhds_right] at hm' have := hx.and (hm' ht) obtain ⟨m, hm⟩ := this.exists exact ⟨F m x, ⟨hm.2, htsymm hm.1⟩⟩ #align uniform_cauchy_seq_on_filter.tendsto_uniformly_on_filter_of_tendsto UniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto theorem UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto [NeBot p] (hF : UniformCauchySeqOn F p s) (hF' : ∀ x : α, x ∈ s → Tendsto (fun n => F n x) p (𝓝 (f x))) : TendstoUniformlyOn F f p s := tendstoUniformlyOn_iff_tendstoUniformlyOnFilter.mpr (hF.uniformCauchySeqOnFilter.tendstoUniformlyOnFilter_of_tendsto hF') #align uniform_cauchy_seq_on.tendsto_uniformly_on_of_tendsto UniformCauchySeqOn.tendstoUniformlyOn_of_tendsto theorem UniformCauchySeqOnFilter.mono_left {p'' : Filter ι} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≤ p) : UniformCauchySeqOnFilter F p'' p' := by intro u hu have := (hf u hu).filter_mono (p'.prod_mono_left (Filter.prod_mono hp hp)) exact this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_left UniformCauchySeqOnFilter.mono_left theorem UniformCauchySeqOnFilter.mono_right {p'' : Filter α} (hf : UniformCauchySeqOnFilter F p p') (hp : p'' ≤ p') : UniformCauchySeqOnFilter F p p'' := fun u hu => have := (hf u hu).filter_mono ((p ×ˢ p).prod_mono_right hp) this.mono (by simp) #align uniform_cauchy_seq_on_filter.mono_right UniformCauchySeqOnFilter.mono_right theorem UniformCauchySeqOn.mono {s' : Set α} (hf : UniformCauchySeqOn F p s) (hss' : s' ⊆ s) : UniformCauchySeqOn F p s' := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ⊢ exact hf.mono_right (le_principal_iff.mpr <| mem_principal.mpr hss') #align uniform_cauchy_seq_on.mono UniformCauchySeqOn.mono theorem UniformCauchySeqOnFilter.comp {γ : Type*} (hf : UniformCauchySeqOnFilter F p p') (g : γ → α) : UniformCauchySeqOnFilter (fun n => F n ∘ g) p (p'.comap g) := fun u hu => by obtain ⟨pa, hpa, pb, hpb, hpapb⟩ := eventually_prod_iff.mp (hf u hu) rw [eventually_prod_iff] refine ⟨pa, hpa, pb ∘ g, ?_, fun hx _ hy => hpapb hx hy⟩ exact eventually_comap.mpr (hpb.mono fun x hx y hy => by simp only [hx, hy, Function.comp_apply]) #align uniform_cauchy_seq_on_filter.comp UniformCauchySeqOnFilter.comp theorem UniformCauchySeqOn.comp {γ : Type*} (hf : UniformCauchySeqOn F p s) (g : γ → α) : UniformCauchySeqOn (fun n => F n ∘ g) p (g ⁻¹' s) := by rw [uniformCauchySeqOn_iff_uniformCauchySeqOnFilter] at hf ⊢ simpa only [UniformCauchySeqOn, comap_principal] using hf.comp g #align uniform_cauchy_seq_on.comp UniformCauchySeqOn.comp theorem UniformContinuous.comp_uniformCauchySeqOn [UniformSpace γ] {g : β → γ} (hg : UniformContinuous g) (hf : UniformCauchySeqOn F p s) : UniformCauchySeqOn (fun n => g ∘ F n) p s := fun _u hu => hf _ (hg hu) #align uniform_continuous.comp_uniform_cauchy_seq_on UniformContinuous.comp_uniformCauchySeqOn theorem UniformCauchySeqOn.prod_map {ι' α' β' : Type*} [UniformSpace β'] {F' : ι' → α' → β'} {p' : Filter ι'} {s' : Set α'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s') : UniformCauchySeqOn (fun i : ι × ι' => Prod.map (F i.1) (F' i.2)) (p ×ˢ p') (s ×ˢ s') := by intro u hu rw [uniformity_prod_eq_prod, mem_map, mem_prod_iff] at hu obtain ⟨v, hv, w, hw, hvw⟩ := hu simp_rw [mem_prod, Prod.map_apply, and_imp, Prod.forall] rw [← Set.image_subset_iff] at hvw apply (tendsto_swap4_prod.eventually ((h v hv).prod_mk (h' w hw))).mono intro x hx a b ha hb exact hvw ⟨_, mk_mem_prod (hx.1 a ha) (hx.2 b hb), rfl⟩ #align uniform_cauchy_seq_on.prod_map UniformCauchySeqOn.prod_map theorem UniformCauchySeqOn.prod {ι' β' : Type*} [UniformSpace β'] {F' : ι' → α → β'} {p' : Filter ι'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p' s) : UniformCauchySeqOn (fun (i : ι × ι') a => (F i.fst a, F' i.snd a)) (p ×ˢ p') s := (congr_arg _ s.inter_self).mp ((h.prod_map h').comp fun a => (a, a)) #align uniform_cauchy_seq_on.prod UniformCauchySeqOn.prod theorem UniformCauchySeqOn.prod' {β' : Type*} [UniformSpace β'] {F' : ι → α → β'} (h : UniformCauchySeqOn F p s) (h' : UniformCauchySeqOn F' p s) : UniformCauchySeqOn (fun (i : ι) a => (F i a, F' i a)) p s := fun u hu => have hh : Tendsto (fun x : ι => (x, x)) p (p ×ˢ p) := tendsto_diag (hh.prod_map hh).eventually ((h.prod h') u hu) #align uniform_cauchy_seq_on.prod' UniformCauchySeqOn.prod'
Mathlib/Topology/UniformSpace/UniformConvergence.lean
546
551
theorem UniformCauchySeqOn.cauchy_map [hp : NeBot p] (hf : UniformCauchySeqOn F p s) (hx : x ∈ s) : Cauchy (map (fun i => F i x) p) := by
simp only [cauchy_map_iff, hp, true_and_iff] intro u hu rw [mem_map] filter_upwards [hf u hu] with p hp using hp x hx
import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Order.Monotone.Basic #align_import data.nat.choose.basic from "leanprover-community/mathlib"@"2f3994e1b117b1e1da49bcfb67334f33460c3ce4" open Nat namespace Nat def choose : ℕ → ℕ → ℕ | _, 0 => 1 | 0, _ + 1 => 0 | n + 1, k + 1 => choose n k + choose n (k + 1) #align nat.choose Nat.choose @[simp] theorem choose_zero_right (n : ℕ) : choose n 0 = 1 := by cases n <;> rfl #align nat.choose_zero_right Nat.choose_zero_right @[simp] theorem choose_zero_succ (k : ℕ) : choose 0 (succ k) = 0 := rfl #align nat.choose_zero_succ Nat.choose_zero_succ theorem choose_succ_succ (n k : ℕ) : choose (succ n) (succ k) = choose n k + choose n (succ k) := rfl #align nat.choose_succ_succ Nat.choose_succ_succ theorem choose_succ_succ' (n k : ℕ) : choose (n + 1) (k + 1) = choose n k + choose n (k + 1) := rfl theorem choose_eq_zero_of_lt : ∀ {n k}, n < k → choose n k = 0 | _, 0, hk => absurd hk (Nat.not_lt_zero _) | 0, k + 1, _ => choose_zero_succ _ | n + 1, k + 1, hk => by have hnk : n < k := lt_of_succ_lt_succ hk have hnk1 : n < k + 1 := lt_of_succ_lt hk rw [choose_succ_succ, choose_eq_zero_of_lt hnk, choose_eq_zero_of_lt hnk1] #align nat.choose_eq_zero_of_lt Nat.choose_eq_zero_of_lt @[simp] theorem choose_self (n : ℕ) : choose n n = 1 := by induction n <;> simp [*, choose, choose_eq_zero_of_lt (lt_succ_self _)] #align nat.choose_self Nat.choose_self @[simp] theorem choose_succ_self (n : ℕ) : choose n (succ n) = 0 := choose_eq_zero_of_lt (lt_succ_self _) #align nat.choose_succ_self Nat.choose_succ_self @[simp] lemma choose_one_right (n : ℕ) : choose n 1 = n := by induction n <;> simp [*, choose, Nat.add_comm] #align nat.choose_one_right Nat.choose_one_right -- The `n+1`-st triangle number is `n` more than the `n`-th triangle number theorem triangle_succ (n : ℕ) : (n + 1) * (n + 1 - 1) / 2 = n * (n - 1) / 2 + n := by rw [← add_mul_div_left, Nat.mul_comm 2 n, ← Nat.mul_add, Nat.add_sub_cancel, Nat.mul_comm] cases n <;> rfl; apply zero_lt_succ #align nat.triangle_succ Nat.triangle_succ theorem choose_two_right (n : ℕ) : choose n 2 = n * (n - 1) / 2 := by induction' n with n ih · simp · rw [triangle_succ n, choose, ih] simp [Nat.add_comm] #align nat.choose_two_right Nat.choose_two_right theorem choose_pos : ∀ {n k}, k ≤ n → 0 < choose n k | 0, _, hk => by rw [Nat.eq_zero_of_le_zero hk]; decide | n + 1, 0, _ => by simp | n + 1, k + 1, hk => Nat.add_pos_left (choose_pos (le_of_succ_le_succ hk)) _ #align nat.choose_pos Nat.choose_pos theorem choose_eq_zero_iff {n k : ℕ} : n.choose k = 0 ↔ n < k := ⟨fun h => lt_of_not_ge (mt Nat.choose_pos h.symm.not_lt), Nat.choose_eq_zero_of_lt⟩ #align nat.choose_eq_zero_iff Nat.choose_eq_zero_iff theorem succ_mul_choose_eq : ∀ n k, succ n * choose n k = choose (succ n) (succ k) * succ k | 0, 0 => by decide | 0, k + 1 => by simp [choose] | n + 1, 0 => by simp [choose, mul_succ, succ_eq_add_one, Nat.add_comm] | n + 1, k + 1 => by rw [choose_succ_succ (succ n) (succ k), Nat.add_mul, ← succ_mul_choose_eq n, mul_succ, ← succ_mul_choose_eq n, Nat.add_right_comm, ← Nat.mul_add, ← choose_succ_succ, ← succ_mul] #align nat.succ_mul_choose_eq Nat.succ_mul_choose_eq theorem choose_mul_factorial_mul_factorial : ∀ {n k}, k ≤ n → choose n k * k ! * (n - k)! = n ! | 0, _, hk => by simp [Nat.eq_zero_of_le_zero hk] | n + 1, 0, _ => by simp | n + 1, succ k, hk => by rcases lt_or_eq_of_le hk with hk₁ | hk₁ · have h : choose n k * k.succ ! * (n - k)! = (k + 1) * n ! := by rw [← choose_mul_factorial_mul_factorial (le_of_succ_le_succ hk)] simp [factorial_succ, Nat.mul_comm, Nat.mul_left_comm, Nat.mul_assoc] have h₁ : (n - k)! = (n - k) * (n - k.succ)! := by rw [← succ_sub_succ, succ_sub (le_of_lt_succ hk₁), factorial_succ] have h₂ : choose n (succ k) * k.succ ! * ((n - k) * (n - k.succ)!) = (n - k) * n ! := by rw [← choose_mul_factorial_mul_factorial (le_of_lt_succ hk₁)] simp [factorial_succ, Nat.mul_comm, Nat.mul_left_comm, Nat.mul_assoc] have h₃ : k * n ! ≤ n * n ! := Nat.mul_le_mul_right _ (le_of_succ_le_succ hk) rw [choose_succ_succ, Nat.add_mul, Nat.add_mul, succ_sub_succ, h, h₁, h₂, Nat.add_mul, Nat.mul_sub_right_distrib, factorial_succ, ← Nat.add_sub_assoc h₃, Nat.add_assoc, ← Nat.add_mul, Nat.add_sub_cancel_left, Nat.add_comm] · rw [hk₁]; simp [hk₁, Nat.mul_comm, choose, Nat.sub_self] #align nat.choose_mul_factorial_mul_factorial Nat.choose_mul_factorial_mul_factorial theorem choose_mul {n k s : ℕ} (hkn : k ≤ n) (hsk : s ≤ k) : n.choose k * k.choose s = n.choose s * (n - s).choose (k - s) := have h : 0 < (n - k)! * (k - s)! * s ! := by apply_rules [factorial_pos, Nat.mul_pos] Nat.mul_right_cancel h <| calc n.choose k * k.choose s * ((n - k)! * (k - s)! * s !) = n.choose k * (k.choose s * s ! * (k - s)!) * (n - k)! := by rw [Nat.mul_assoc, Nat.mul_assoc, Nat.mul_assoc, Nat.mul_assoc _ s !, Nat.mul_assoc, Nat.mul_comm (n - k)!, Nat.mul_comm s !] _ = n ! := by rw [choose_mul_factorial_mul_factorial hsk, choose_mul_factorial_mul_factorial hkn] _ = n.choose s * s ! * ((n - s).choose (k - s) * (k - s)! * (n - s - (k - s))!) := by rw [choose_mul_factorial_mul_factorial (Nat.sub_le_sub_right hkn _), choose_mul_factorial_mul_factorial (hsk.trans hkn)] _ = n.choose s * (n - s).choose (k - s) * ((n - k)! * (k - s)! * s !) := by rw [Nat.sub_sub_sub_cancel_right hsk, Nat.mul_assoc, Nat.mul_left_comm s !, Nat.mul_assoc, Nat.mul_comm (k - s)!, Nat.mul_comm s !, Nat.mul_right_comm, ← Nat.mul_assoc] #align nat.choose_mul Nat.choose_mul theorem choose_eq_factorial_div_factorial {n k : ℕ} (hk : k ≤ n) : choose n k = n ! / (k ! * (n - k)!) := by rw [← choose_mul_factorial_mul_factorial hk, Nat.mul_assoc] exact (mul_div_left _ (Nat.mul_pos (factorial_pos _) (factorial_pos _))).symm #align nat.choose_eq_factorial_div_factorial Nat.choose_eq_factorial_div_factorial theorem add_choose (i j : ℕ) : (i + j).choose j = (i + j)! / (i ! * j !) := by rw [choose_eq_factorial_div_factorial (Nat.le_add_left j i), Nat.add_sub_cancel_right, Nat.mul_comm] #align nat.add_choose Nat.add_choose theorem add_choose_mul_factorial_mul_factorial (i j : ℕ) : (i + j).choose j * i ! * j ! = (i + j)! := by rw [← choose_mul_factorial_mul_factorial (Nat.le_add_left _ _), Nat.add_sub_cancel_right, Nat.mul_right_comm] #align nat.add_choose_mul_factorial_mul_factorial Nat.add_choose_mul_factorial_mul_factorial theorem factorial_mul_factorial_dvd_factorial {n k : ℕ} (hk : k ≤ n) : k ! * (n - k)! ∣ n ! := by rw [← choose_mul_factorial_mul_factorial hk, Nat.mul_assoc]; exact Nat.dvd_mul_left _ _ #align nat.factorial_mul_factorial_dvd_factorial Nat.factorial_mul_factorial_dvd_factorial theorem factorial_mul_factorial_dvd_factorial_add (i j : ℕ) : i ! * j ! ∣ (i + j)! := by suffices i ! * (i + j - i) ! ∣ (i + j)! by rwa [Nat.add_sub_cancel_left i j] at this exact factorial_mul_factorial_dvd_factorial (Nat.le_add_right _ _) #align nat.factorial_mul_factorial_dvd_factorial_add Nat.factorial_mul_factorial_dvd_factorial_add @[simp] theorem choose_symm {n k : ℕ} (hk : k ≤ n) : choose n (n - k) = choose n k := by rw [choose_eq_factorial_div_factorial hk, choose_eq_factorial_div_factorial (Nat.sub_le _ _), Nat.sub_sub_self hk, Nat.mul_comm] #align nat.choose_symm Nat.choose_symm theorem choose_symm_of_eq_add {n a b : ℕ} (h : n = a + b) : Nat.choose n a = Nat.choose n b := by suffices choose n (n - b) = choose n b by rw [h, Nat.add_sub_cancel_right] at this; rwa [h] exact choose_symm (h ▸ le_add_left _ _) #align nat.choose_symm_of_eq_add Nat.choose_symm_of_eq_add theorem choose_symm_add {a b : ℕ} : choose (a + b) a = choose (a + b) b := choose_symm_of_eq_add rfl #align nat.choose_symm_add Nat.choose_symm_add theorem choose_symm_half (m : ℕ) : choose (2 * m + 1) (m + 1) = choose (2 * m + 1) m := by apply choose_symm_of_eq_add rw [Nat.add_comm m 1, Nat.add_assoc 1 m m, Nat.add_comm (2 * m) 1, Nat.two_mul m] #align nat.choose_symm_half Nat.choose_symm_half theorem choose_succ_right_eq (n k : ℕ) : choose n (k + 1) * (k + 1) = choose n k * (n - k) := by have e : (n + 1) * choose n k = choose n (k + 1) * (k + 1) + choose n k * (k + 1) := by rw [← Nat.add_mul, Nat.add_comm (choose _ _), ← choose_succ_succ, succ_mul_choose_eq] rw [← Nat.sub_eq_of_eq_add e, Nat.mul_comm, ← Nat.mul_sub_left_distrib, Nat.add_sub_add_right] #align nat.choose_succ_right_eq Nat.choose_succ_right_eq @[simp] theorem choose_succ_self_right : ∀ n : ℕ, (n + 1).choose n = n + 1 | 0 => rfl | n + 1 => by rw [choose_succ_succ, choose_succ_self_right n, choose_self] #align nat.choose_succ_self_right Nat.choose_succ_self_right theorem choose_mul_succ_eq (n k : ℕ) : n.choose k * (n + 1) = (n + 1).choose k * (n + 1 - k) := by cases k with | zero => simp | succ k => obtain hk | hk := le_or_lt (k + 1) (n + 1) · rw [choose_succ_succ, Nat.add_mul, succ_sub_succ, ← choose_succ_right_eq, ← succ_sub_succ, Nat.mul_sub_left_distrib, Nat.add_sub_cancel' (Nat.mul_le_mul_left _ hk)] · rw [choose_eq_zero_of_lt hk, choose_eq_zero_of_lt (n.lt_succ_self.trans hk), Nat.zero_mul, Nat.zero_mul] #align nat.choose_mul_succ_eq Nat.choose_mul_succ_eq theorem ascFactorial_eq_factorial_mul_choose (n k : ℕ) : (n + 1).ascFactorial k = k ! * (n + k).choose k := by rw [Nat.mul_comm] apply Nat.mul_right_cancel (n + k - k).factorial_pos rw [choose_mul_factorial_mul_factorial <| Nat.le_add_left k n, Nat.add_sub_cancel_right, ← factorial_mul_ascFactorial, Nat.mul_comm] #align nat.asc_factorial_eq_factorial_mul_choose Nat.ascFactorial_eq_factorial_mul_choose theorem ascFactorial_eq_factorial_mul_choose' (n k : ℕ) : n.ascFactorial k = k ! * (n + k - 1).choose k := by cases n · cases k · rw [ascFactorial_zero, choose_zero_right, factorial_zero, Nat.mul_one] · simp only [zero_ascFactorial, zero_eq, Nat.zero_add, succ_sub_succ_eq_sub, Nat.le_zero_eq, Nat.sub_zero, choose_succ_self, Nat.mul_zero] rw [ascFactorial_eq_factorial_mul_choose] simp only [succ_add_sub_one] theorem factorial_dvd_ascFactorial (n k : ℕ) : k ! ∣ n.ascFactorial k := ⟨(n + k - 1).choose k, ascFactorial_eq_factorial_mul_choose' _ _⟩ #align nat.factorial_dvd_asc_factorial Nat.factorial_dvd_ascFactorial theorem choose_eq_asc_factorial_div_factorial (n k : ℕ) : (n + k).choose k = (n + 1).ascFactorial k / k ! := by apply Nat.mul_left_cancel k.factorial_pos rw [← ascFactorial_eq_factorial_mul_choose] exact (Nat.mul_div_cancel' <| factorial_dvd_ascFactorial _ _).symm #align nat.choose_eq_asc_factorial_div_factorial Nat.choose_eq_asc_factorial_div_factorial theorem choose_eq_asc_factorial_div_factorial' (n k : ℕ) : (n + k - 1).choose k = n.ascFactorial k / k ! := Nat.eq_div_of_mul_eq_right k.factorial_ne_zero (ascFactorial_eq_factorial_mul_choose' _ _).symm theorem descFactorial_eq_factorial_mul_choose (n k : ℕ) : n.descFactorial k = k ! * n.choose k := by obtain h | h := Nat.lt_or_ge n k · rw [descFactorial_eq_zero_iff_lt.2 h, choose_eq_zero_of_lt h, Nat.mul_zero] rw [Nat.mul_comm] apply Nat.mul_right_cancel (n - k).factorial_pos rw [choose_mul_factorial_mul_factorial h, ← factorial_mul_descFactorial h, Nat.mul_comm] #align nat.desc_factorial_eq_factorial_mul_choose Nat.descFactorial_eq_factorial_mul_choose theorem factorial_dvd_descFactorial (n k : ℕ) : k ! ∣ n.descFactorial k := ⟨n.choose k, descFactorial_eq_factorial_mul_choose _ _⟩ #align nat.factorial_dvd_desc_factorial Nat.factorial_dvd_descFactorial theorem choose_eq_descFactorial_div_factorial (n k : ℕ) : n.choose k = n.descFactorial k / k ! := Nat.eq_div_of_mul_eq_right k.factorial_ne_zero (descFactorial_eq_factorial_mul_choose _ _).symm #align nat.choose_eq_desc_factorial_div_factorial Nat.choose_eq_descFactorial_div_factorial def fast_choose n k := Nat.descFactorial n k / Nat.factorial k @[csimp] lemma choose_eq_fast_choose : Nat.choose = fast_choose := funext (fun _ => funext (Nat.choose_eq_descFactorial_div_factorial _)) theorem choose_le_succ_of_lt_half_left {r n : ℕ} (h : r < n / 2) : choose n r ≤ choose n (r + 1) := by refine Nat.le_of_mul_le_mul_right ?_ (Nat.sub_pos_of_lt (h.trans_le (n.div_le_self 2))) rw [← choose_succ_right_eq] apply Nat.mul_le_mul_left rw [← Nat.lt_iff_add_one_le, Nat.lt_sub_iff_add_lt, ← Nat.mul_two] exact lt_of_lt_of_le (Nat.mul_lt_mul_of_pos_right h Nat.zero_lt_two) (n.div_mul_le_self 2) #align nat.choose_le_succ_of_lt_half_left Nat.choose_le_succ_of_lt_half_left private theorem choose_le_middle_of_le_half_left {n r : ℕ} (hr : r ≤ n / 2) : choose n r ≤ choose n (n / 2) := decreasingInduction (fun _ k a => (eq_or_lt_of_le a).elim (fun t => t.symm ▸ le_rfl) fun h => (choose_le_succ_of_lt_half_left h).trans (k h)) hr (fun _ => le_rfl) hr
Mathlib/Data/Nat/Choose/Basic.lean
315
326
theorem choose_le_middle (r n : ℕ) : choose n r ≤ choose n (n / 2) := by
cases' le_or_gt r n with b b · rcases le_or_lt r (n / 2) with a | h · apply choose_le_middle_of_le_half_left a · rw [← choose_symm b] apply choose_le_middle_of_le_half_left rw [div_lt_iff_lt_mul' Nat.zero_lt_two] at h rw [le_div_iff_mul_le' Nat.zero_lt_two, Nat.mul_sub_right_distrib, Nat.sub_le_iff_le_add, ← Nat.sub_le_iff_le_add', Nat.mul_two, Nat.add_sub_cancel] exact le_of_lt h · rw [choose_eq_zero_of_lt b] apply zero_le
import Mathlib.Logic.Relation import Mathlib.Data.Option.Basic import Mathlib.Data.Seq.Seq #align_import data.seq.wseq from "leanprover-community/mathlib"@"a7e36e48519ab281320c4d192da6a7b348ce40ad" namespace Stream' open Function universe u v w def WSeq (α) := Seq (Option α) #align stream.wseq Stream'.WSeq namespace WSeq variable {α : Type u} {β : Type v} {γ : Type w} @[coe] def ofSeq : Seq α → WSeq α := (· <$> ·) some #align stream.wseq.of_seq Stream'.WSeq.ofSeq @[coe] def ofList (l : List α) : WSeq α := ofSeq l #align stream.wseq.of_list Stream'.WSeq.ofList @[coe] def ofStream (l : Stream' α) : WSeq α := ofSeq l #align stream.wseq.of_stream Stream'.WSeq.ofStream instance coeSeq : Coe (Seq α) (WSeq α) := ⟨ofSeq⟩ #align stream.wseq.coe_seq Stream'.WSeq.coeSeq instance coeList : Coe (List α) (WSeq α) := ⟨ofList⟩ #align stream.wseq.coe_list Stream'.WSeq.coeList instance coeStream : Coe (Stream' α) (WSeq α) := ⟨ofStream⟩ #align stream.wseq.coe_stream Stream'.WSeq.coeStream def nil : WSeq α := Seq.nil #align stream.wseq.nil Stream'.WSeq.nil instance inhabited : Inhabited (WSeq α) := ⟨nil⟩ #align stream.wseq.inhabited Stream'.WSeq.inhabited def cons (a : α) : WSeq α → WSeq α := Seq.cons (some a) #align stream.wseq.cons Stream'.WSeq.cons def think : WSeq α → WSeq α := Seq.cons none #align stream.wseq.think Stream'.WSeq.think def destruct : WSeq α → Computation (Option (α × WSeq α)) := Computation.corec fun s => match Seq.destruct s with | none => Sum.inl none | some (none, s') => Sum.inr s' | some (some a, s') => Sum.inl (some (a, s')) #align stream.wseq.destruct Stream'.WSeq.destruct def recOn {C : WSeq α → Sort v} (s : WSeq α) (h1 : C nil) (h2 : ∀ x s, C (cons x s)) (h3 : ∀ s, C (think s)) : C s := Seq.recOn s h1 fun o => Option.recOn o h3 h2 #align stream.wseq.rec_on Stream'.WSeq.recOn protected def Mem (a : α) (s : WSeq α) := Seq.Mem (some a) s #align stream.wseq.mem Stream'.WSeq.Mem instance membership : Membership α (WSeq α) := ⟨WSeq.Mem⟩ #align stream.wseq.has_mem Stream'.WSeq.membership theorem not_mem_nil (a : α) : a ∉ @nil α := Seq.not_mem_nil (some a) #align stream.wseq.not_mem_nil Stream'.WSeq.not_mem_nil def head (s : WSeq α) : Computation (Option α) := Computation.map (Prod.fst <$> ·) (destruct s) #align stream.wseq.head Stream'.WSeq.head def flatten : Computation (WSeq α) → WSeq α := Seq.corec fun c => match Computation.destruct c with | Sum.inl s => Seq.omap (return ·) (Seq.destruct s) | Sum.inr c' => some (none, c') #align stream.wseq.flatten Stream'.WSeq.flatten def tail (s : WSeq α) : WSeq α := flatten <| (fun o => Option.recOn o nil Prod.snd) <$> destruct s #align stream.wseq.tail Stream'.WSeq.tail def drop (s : WSeq α) : ℕ → WSeq α | 0 => s | n + 1 => tail (drop s n) #align stream.wseq.drop Stream'.WSeq.drop def get? (s : WSeq α) (n : ℕ) : Computation (Option α) := head (drop s n) #align stream.wseq.nth Stream'.WSeq.get? def toList (s : WSeq α) : Computation (List α) := @Computation.corec (List α) (List α × WSeq α) (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) ([], s) #align stream.wseq.to_list Stream'.WSeq.toList def length (s : WSeq α) : Computation ℕ := @Computation.corec ℕ (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s with | none => Sum.inl n | some (none, s') => Sum.inr (n, s') | some (some _, s') => Sum.inr (n + 1, s')) (0, s) #align stream.wseq.length Stream'.WSeq.length class IsFinite (s : WSeq α) : Prop where out : (toList s).Terminates #align stream.wseq.is_finite Stream'.WSeq.IsFinite instance toList_terminates (s : WSeq α) [h : IsFinite s] : (toList s).Terminates := h.out #align stream.wseq.to_list_terminates Stream'.WSeq.toList_terminates def get (s : WSeq α) [IsFinite s] : List α := (toList s).get #align stream.wseq.get Stream'.WSeq.get class Productive (s : WSeq α) : Prop where get?_terminates : ∀ n, (get? s n).Terminates #align stream.wseq.productive Stream'.WSeq.Productive #align stream.wseq.productive.nth_terminates Stream'.WSeq.Productive.get?_terminates theorem productive_iff (s : WSeq α) : Productive s ↔ ∀ n, (get? s n).Terminates := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align stream.wseq.productive_iff Stream'.WSeq.productive_iff instance get?_terminates (s : WSeq α) [h : Productive s] : ∀ n, (get? s n).Terminates := h.get?_terminates #align stream.wseq.nth_terminates Stream'.WSeq.get?_terminates instance head_terminates (s : WSeq α) [Productive s] : (head s).Terminates := s.get?_terminates 0 #align stream.wseq.head_terminates Stream'.WSeq.head_terminates def updateNth (s : WSeq α) (n : ℕ) (a : α) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s, n with | none, _ => none | some (none, s'), n => some (none, n, s') | some (some a', s'), 0 => some (some a', 0, s') | some (some _, s'), 1 => some (some a, 0, s') | some (some a', s'), n + 2 => some (some a', n + 1, s')) (n + 1, s) #align stream.wseq.update_nth Stream'.WSeq.updateNth def removeNth (s : WSeq α) (n : ℕ) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match Seq.destruct s, n with | none, _ => none | some (none, s'), n => some (none, n, s') | some (some a', s'), 0 => some (some a', 0, s') | some (some _, s'), 1 => some (none, 0, s') | some (some a', s'), n + 2 => some (some a', n + 1, s')) (n + 1, s) #align stream.wseq.remove_nth Stream'.WSeq.removeNth def filterMap (f : α → Option β) : WSeq α → WSeq β := Seq.corec fun s => match Seq.destruct s with | none => none | some (none, s') => some (none, s') | some (some a, s') => some (f a, s') #align stream.wseq.filter_map Stream'.WSeq.filterMap def filter (p : α → Prop) [DecidablePred p] : WSeq α → WSeq α := filterMap fun a => if p a then some a else none #align stream.wseq.filter Stream'.WSeq.filter -- example of infinite list manipulations def find (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation (Option α) := head <| filter p s #align stream.wseq.find Stream'.WSeq.find def zipWith (f : α → β → γ) (s1 : WSeq α) (s2 : WSeq β) : WSeq γ := @Seq.corec (Option γ) (WSeq α × WSeq β) (fun ⟨s1, s2⟩ => match Seq.destruct s1, Seq.destruct s2 with | some (none, s1'), some (none, s2') => some (none, s1', s2') | some (some _, _), some (none, s2') => some (none, s1, s2') | some (none, s1'), some (some _, _) => some (none, s1', s2) | some (some a1, s1'), some (some a2, s2') => some (some (f a1 a2), s1', s2') | _, _ => none) (s1, s2) #align stream.wseq.zip_with Stream'.WSeq.zipWith def zip : WSeq α → WSeq β → WSeq (α × β) := zipWith Prod.mk #align stream.wseq.zip Stream'.WSeq.zip def findIndexes (p : α → Prop) [DecidablePred p] (s : WSeq α) : WSeq ℕ := (zip s (Stream'.nats : WSeq ℕ)).filterMap fun ⟨a, n⟩ => if p a then some n else none #align stream.wseq.find_indexes Stream'.WSeq.findIndexes def findIndex (p : α → Prop) [DecidablePred p] (s : WSeq α) : Computation ℕ := (fun o => Option.getD o 0) <$> head (findIndexes p s) #align stream.wseq.find_index Stream'.WSeq.findIndex def indexOf [DecidableEq α] (a : α) : WSeq α → Computation ℕ := findIndex (Eq a) #align stream.wseq.index_of Stream'.WSeq.indexOf def indexesOf [DecidableEq α] (a : α) : WSeq α → WSeq ℕ := findIndexes (Eq a) #align stream.wseq.indexes_of Stream'.WSeq.indexesOf def union (s1 s2 : WSeq α) : WSeq α := @Seq.corec (Option α) (WSeq α × WSeq α) (fun ⟨s1, s2⟩ => match Seq.destruct s1, Seq.destruct s2 with | none, none => none | some (a1, s1'), none => some (a1, s1', nil) | none, some (a2, s2') => some (a2, nil, s2') | some (none, s1'), some (none, s2') => some (none, s1', s2') | some (some a1, s1'), some (none, s2') => some (some a1, s1', s2') | some (none, s1'), some (some a2, s2') => some (some a2, s1', s2') | some (some a1, s1'), some (some a2, s2') => some (some a1, cons a2 s1', s2')) (s1, s2) #align stream.wseq.union Stream'.WSeq.union def isEmpty (s : WSeq α) : Computation Bool := Computation.map Option.isNone <| head s #align stream.wseq.is_empty Stream'.WSeq.isEmpty def compute (s : WSeq α) : WSeq α := match Seq.destruct s with | some (none, s') => s' | _ => s #align stream.wseq.compute Stream'.WSeq.compute def take (s : WSeq α) (n : ℕ) : WSeq α := @Seq.corec (Option α) (ℕ × WSeq α) (fun ⟨n, s⟩ => match n, Seq.destruct s with | 0, _ => none | _ + 1, none => none | m + 1, some (none, s') => some (none, m + 1, s') | m + 1, some (some a, s') => some (some a, m, s')) (n, s) #align stream.wseq.take Stream'.WSeq.take def splitAt (s : WSeq α) (n : ℕ) : Computation (List α × WSeq α) := @Computation.corec (List α × WSeq α) (ℕ × List α × WSeq α) (fun ⟨n, l, s⟩ => match n, Seq.destruct s with | 0, _ => Sum.inl (l.reverse, s) | _ + 1, none => Sum.inl (l.reverse, s) | _ + 1, some (none, s') => Sum.inr (n, l, s') | m + 1, some (some a, s') => Sum.inr (m, a::l, s')) (n, [], s) #align stream.wseq.split_at Stream'.WSeq.splitAt def any (s : WSeq α) (p : α → Bool) : Computation Bool := Computation.corec (fun s : WSeq α => match Seq.destruct s with | none => Sum.inl false | some (none, s') => Sum.inr s' | some (some a, s') => if p a then Sum.inl true else Sum.inr s') s #align stream.wseq.any Stream'.WSeq.any def all (s : WSeq α) (p : α → Bool) : Computation Bool := Computation.corec (fun s : WSeq α => match Seq.destruct s with | none => Sum.inl true | some (none, s') => Sum.inr s' | some (some a, s') => if p a then Sum.inr s' else Sum.inl false) s #align stream.wseq.all Stream'.WSeq.all def scanl (f : α → β → α) (a : α) (s : WSeq β) : WSeq α := cons a <| @Seq.corec (Option α) (α × WSeq β) (fun ⟨a, s⟩ => match Seq.destruct s with | none => none | some (none, s') => some (none, a, s') | some (some b, s') => let a' := f a b some (some a', a', s')) (a, s) #align stream.wseq.scanl Stream'.WSeq.scanl def inits (s : WSeq α) : WSeq (List α) := cons [] <| @Seq.corec (Option (List α)) (Batteries.DList α × WSeq α) (fun ⟨l, s⟩ => match Seq.destruct s with | none => none | some (none, s') => some (none, l, s') | some (some a, s') => let l' := l.push a some (some l'.toList, l', s')) (Batteries.DList.empty, s) #align stream.wseq.inits Stream'.WSeq.inits def collect (s : WSeq α) (n : ℕ) : List α := (Seq.take n s).filterMap id #align stream.wseq.collect Stream'.WSeq.collect def append : WSeq α → WSeq α → WSeq α := Seq.append #align stream.wseq.append Stream'.WSeq.append def map (f : α → β) : WSeq α → WSeq β := Seq.map (Option.map f) #align stream.wseq.map Stream'.WSeq.map def join (S : WSeq (WSeq α)) : WSeq α := Seq.join ((fun o : Option (WSeq α) => match o with | none => Seq1.ret none | some s => (none, s)) <$> S) #align stream.wseq.join Stream'.WSeq.join def bind (s : WSeq α) (f : α → WSeq β) : WSeq β := join (map f s) #align stream.wseq.bind Stream'.WSeq.bind @[simp] def LiftRelO (R : α → β → Prop) (C : WSeq α → WSeq β → Prop) : Option (α × WSeq α) → Option (β × WSeq β) → Prop | none, none => True | some (a, s), some (b, t) => R a b ∧ C s t | _, _ => False #align stream.wseq.lift_rel_o Stream'.WSeq.LiftRelO theorem LiftRelO.imp {R S : α → β → Prop} {C D : WSeq α → WSeq β → Prop} (H1 : ∀ a b, R a b → S a b) (H2 : ∀ s t, C s t → D s t) : ∀ {o p}, LiftRelO R C o p → LiftRelO S D o p | none, none, _ => trivial | some (_, _), some (_, _), h => And.imp (H1 _ _) (H2 _ _) h | none, some _, h => False.elim h | some (_, _), none, h => False.elim h #align stream.wseq.lift_rel_o.imp Stream'.WSeq.LiftRelO.imp theorem LiftRelO.imp_right (R : α → β → Prop) {C D : WSeq α → WSeq β → Prop} (H : ∀ s t, C s t → D s t) {o p} : LiftRelO R C o p → LiftRelO R D o p := LiftRelO.imp (fun _ _ => id) H #align stream.wseq.lift_rel_o.imp_right Stream'.WSeq.LiftRelO.imp_right @[simp] def BisimO (R : WSeq α → WSeq α → Prop) : Option (α × WSeq α) → Option (α × WSeq α) → Prop := LiftRelO (· = ·) R #align stream.wseq.bisim_o Stream'.WSeq.BisimO theorem BisimO.imp {R S : WSeq α → WSeq α → Prop} (H : ∀ s t, R s t → S s t) {o p} : BisimO R o p → BisimO S o p := LiftRelO.imp_right _ H #align stream.wseq.bisim_o.imp Stream'.WSeq.BisimO.imp def LiftRel (R : α → β → Prop) (s : WSeq α) (t : WSeq β) : Prop := ∃ C : WSeq α → WSeq β → Prop, C s t ∧ ∀ {s t}, C s t → Computation.LiftRel (LiftRelO R C) (destruct s) (destruct t) #align stream.wseq.lift_rel Stream'.WSeq.LiftRel def Equiv : WSeq α → WSeq α → Prop := LiftRel (· = ·) #align stream.wseq.equiv Stream'.WSeq.Equiv theorem liftRel_destruct {R : α → β → Prop} {s : WSeq α} {t : WSeq β} : LiftRel R s t → Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) | ⟨R, h1, h2⟩ => by refine Computation.LiftRel.imp ?_ _ _ (h2 h1) apply LiftRelO.imp_right exact fun s' t' h' => ⟨R, h', @h2⟩ #align stream.wseq.lift_rel_destruct Stream'.WSeq.liftRel_destruct theorem liftRel_destruct_iff {R : α → β → Prop} {s : WSeq α} {t : WSeq β} : LiftRel R s t ↔ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := ⟨liftRel_destruct, fun h => ⟨fun s t => LiftRel R s t ∨ Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t), Or.inr h, fun {s t} h => by have h : Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct s) (destruct t) := by cases' h with h h · exact liftRel_destruct h · assumption apply Computation.LiftRel.imp _ _ _ h intro a b apply LiftRelO.imp_right intro s t apply Or.inl⟩⟩ #align stream.wseq.lift_rel_destruct_iff Stream'.WSeq.liftRel_destruct_iff -- Porting note: To avoid ambiguous notation, `~` became `~ʷ`. infixl:50 " ~ʷ " => Equiv theorem destruct_congr {s t : WSeq α} : s ~ʷ t → Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) := liftRel_destruct #align stream.wseq.destruct_congr Stream'.WSeq.destruct_congr theorem destruct_congr_iff {s t : WSeq α} : s ~ʷ t ↔ Computation.LiftRel (BisimO (· ~ʷ ·)) (destruct s) (destruct t) := liftRel_destruct_iff #align stream.wseq.destruct_congr_iff Stream'.WSeq.destruct_congr_iff theorem LiftRel.refl (R : α → α → Prop) (H : Reflexive R) : Reflexive (LiftRel R) := fun s => by refine ⟨(· = ·), rfl, fun {s t} (h : s = t) => ?_⟩ rw [← h] apply Computation.LiftRel.refl intro a cases' a with a · simp · cases a simp only [LiftRelO, and_true] apply H #align stream.wseq.lift_rel.refl Stream'.WSeq.LiftRel.refl theorem LiftRelO.swap (R : α → β → Prop) (C) : swap (LiftRelO R C) = LiftRelO (swap R) (swap C) := by funext x y rcases x with ⟨⟩ | ⟨hx, jx⟩ <;> rcases y with ⟨⟩ | ⟨hy, jy⟩ <;> rfl #align stream.wseq.lift_rel_o.swap Stream'.WSeq.LiftRelO.swap theorem LiftRel.swap_lem {R : α → β → Prop} {s1 s2} (h : LiftRel R s1 s2) : LiftRel (swap R) s2 s1 := by refine ⟨swap (LiftRel R), h, fun {s t} (h : LiftRel R t s) => ?_⟩ rw [← LiftRelO.swap, Computation.LiftRel.swap] apply liftRel_destruct h #align stream.wseq.lift_rel.swap_lem Stream'.WSeq.LiftRel.swap_lem theorem LiftRel.swap (R : α → β → Prop) : swap (LiftRel R) = LiftRel (swap R) := funext fun _ => funext fun _ => propext ⟨LiftRel.swap_lem, LiftRel.swap_lem⟩ #align stream.wseq.lift_rel.swap Stream'.WSeq.LiftRel.swap theorem LiftRel.symm (R : α → α → Prop) (H : Symmetric R) : Symmetric (LiftRel R) := fun s1 s2 (h : Function.swap (LiftRel R) s2 s1) => by rwa [LiftRel.swap, H.swap_eq] at h #align stream.wseq.lift_rel.symm Stream'.WSeq.LiftRel.symm theorem LiftRel.trans (R : α → α → Prop) (H : Transitive R) : Transitive (LiftRel R) := fun s t u h1 h2 => by refine ⟨fun s u => ∃ t, LiftRel R s t ∧ LiftRel R t u, ⟨t, h1, h2⟩, fun {s u} h => ?_⟩ rcases h with ⟨t, h1, h2⟩ have h1 := liftRel_destruct h1 have h2 := liftRel_destruct h2 refine Computation.liftRel_def.2 ⟨(Computation.terminates_of_liftRel h1).trans (Computation.terminates_of_liftRel h2), fun {a c} ha hc => ?_⟩ rcases h1.left ha with ⟨b, hb, t1⟩ have t2 := Computation.rel_of_liftRel h2 hb hc cases' a with a <;> cases' c with c · trivial · cases b · cases t2 · cases t1 · cases a cases' b with b · cases t1 · cases b cases t2 · cases' a with a s cases' b with b · cases t1 cases' b with b t cases' c with c u cases' t1 with ab st cases' t2 with bc tu exact ⟨H ab bc, t, st, tu⟩ #align stream.wseq.lift_rel.trans Stream'.WSeq.LiftRel.trans theorem LiftRel.equiv (R : α → α → Prop) : Equivalence R → Equivalence (LiftRel R) | ⟨refl, symm, trans⟩ => ⟨LiftRel.refl R refl, @(LiftRel.symm R @symm), @(LiftRel.trans R @trans)⟩ #align stream.wseq.lift_rel.equiv Stream'.WSeq.LiftRel.equiv @[refl] theorem Equiv.refl : ∀ s : WSeq α, s ~ʷ s := LiftRel.refl (· = ·) Eq.refl #align stream.wseq.equiv.refl Stream'.WSeq.Equiv.refl @[symm] theorem Equiv.symm : ∀ {s t : WSeq α}, s ~ʷ t → t ~ʷ s := @(LiftRel.symm (· = ·) (@Eq.symm _)) #align stream.wseq.equiv.symm Stream'.WSeq.Equiv.symm @[trans] theorem Equiv.trans : ∀ {s t u : WSeq α}, s ~ʷ t → t ~ʷ u → s ~ʷ u := @(LiftRel.trans (· = ·) (@Eq.trans _)) #align stream.wseq.equiv.trans Stream'.WSeq.Equiv.trans theorem Equiv.equivalence : Equivalence (@Equiv α) := ⟨@Equiv.refl _, @Equiv.symm _, @Equiv.trans _⟩ #align stream.wseq.equiv.equivalence Stream'.WSeq.Equiv.equivalence open Computation @[simp] theorem destruct_nil : destruct (nil : WSeq α) = Computation.pure none := Computation.destruct_eq_pure rfl #align stream.wseq.destruct_nil Stream'.WSeq.destruct_nil @[simp] theorem destruct_cons (a : α) (s) : destruct (cons a s) = Computation.pure (some (a, s)) := Computation.destruct_eq_pure <| by simp [destruct, cons, Computation.rmap] #align stream.wseq.destruct_cons Stream'.WSeq.destruct_cons @[simp] theorem destruct_think (s : WSeq α) : destruct (think s) = (destruct s).think := Computation.destruct_eq_think <| by simp [destruct, think, Computation.rmap] #align stream.wseq.destruct_think Stream'.WSeq.destruct_think @[simp] theorem seq_destruct_nil : Seq.destruct (nil : WSeq α) = none := Seq.destruct_nil #align stream.wseq.seq_destruct_nil Stream'.WSeq.seq_destruct_nil @[simp] theorem seq_destruct_cons (a : α) (s) : Seq.destruct (cons a s) = some (some a, s) := Seq.destruct_cons _ _ #align stream.wseq.seq_destruct_cons Stream'.WSeq.seq_destruct_cons @[simp] theorem seq_destruct_think (s : WSeq α) : Seq.destruct (think s) = some (none, s) := Seq.destruct_cons _ _ #align stream.wseq.seq_destruct_think Stream'.WSeq.seq_destruct_think @[simp] theorem head_nil : head (nil : WSeq α) = Computation.pure none := by simp [head] #align stream.wseq.head_nil Stream'.WSeq.head_nil @[simp] theorem head_cons (a : α) (s) : head (cons a s) = Computation.pure (some a) := by simp [head] #align stream.wseq.head_cons Stream'.WSeq.head_cons @[simp] theorem head_think (s : WSeq α) : head (think s) = (head s).think := by simp [head] #align stream.wseq.head_think Stream'.WSeq.head_think @[simp] theorem flatten_pure (s : WSeq α) : flatten (Computation.pure s) = s := by refine Seq.eq_of_bisim (fun s1 s2 => flatten (Computation.pure s2) = s1) ?_ rfl intro s' s h rw [← h] simp only [Seq.BisimO, flatten, Seq.omap, pure_def, Seq.corec_eq, destruct_pure] cases Seq.destruct s with | none => simp | some val => cases' val with o s' simp #align stream.wseq.flatten_ret Stream'.WSeq.flatten_pure @[simp] theorem flatten_think (c : Computation (WSeq α)) : flatten c.think = think (flatten c) := Seq.destruct_eq_cons <| by simp [flatten, think] #align stream.wseq.flatten_think Stream'.WSeq.flatten_think @[simp] theorem destruct_flatten (c : Computation (WSeq α)) : destruct (flatten c) = c >>= destruct := by refine Computation.eq_of_bisim (fun c1 c2 => c1 = c2 ∨ ∃ c, c1 = destruct (flatten c) ∧ c2 = Computation.bind c destruct) ?_ (Or.inr ⟨c, rfl, rfl⟩) intro c1 c2 h exact match c1, c2, h with | c, _, Or.inl rfl => by cases c.destruct <;> simp | _, _, Or.inr ⟨c, rfl, rfl⟩ => by induction' c using Computation.recOn with a c' <;> simp · cases (destruct a).destruct <;> simp · exact Or.inr ⟨c', rfl, rfl⟩ #align stream.wseq.destruct_flatten Stream'.WSeq.destruct_flatten theorem head_terminates_iff (s : WSeq α) : Terminates (head s) ↔ Terminates (destruct s) := terminates_map_iff _ (destruct s) #align stream.wseq.head_terminates_iff Stream'.WSeq.head_terminates_iff @[simp] theorem tail_nil : tail (nil : WSeq α) = nil := by simp [tail] #align stream.wseq.tail_nil Stream'.WSeq.tail_nil @[simp] theorem tail_cons (a : α) (s) : tail (cons a s) = s := by simp [tail] #align stream.wseq.tail_cons Stream'.WSeq.tail_cons @[simp] theorem tail_think (s : WSeq α) : tail (think s) = (tail s).think := by simp [tail] #align stream.wseq.tail_think Stream'.WSeq.tail_think @[simp] theorem dropn_nil (n) : drop (nil : WSeq α) n = nil := by induction n <;> simp [*, drop] #align stream.wseq.dropn_nil Stream'.WSeq.dropn_nil @[simp] theorem dropn_cons (a : α) (s) (n) : drop (cons a s) (n + 1) = drop s n := by induction n with | zero => simp [drop] | succ n n_ih => -- porting note (#10745): was `simp [*, drop]`. simp [drop, ← n_ih] #align stream.wseq.dropn_cons Stream'.WSeq.dropn_cons @[simp] theorem dropn_think (s : WSeq α) (n) : drop (think s) n = (drop s n).think := by induction n <;> simp [*, drop] #align stream.wseq.dropn_think Stream'.WSeq.dropn_think theorem dropn_add (s : WSeq α) (m) : ∀ n, drop s (m + n) = drop (drop s m) n | 0 => rfl | n + 1 => congr_arg tail (dropn_add s m n) #align stream.wseq.dropn_add Stream'.WSeq.dropn_add theorem dropn_tail (s : WSeq α) (n) : drop (tail s) n = drop s (n + 1) := by rw [Nat.add_comm] symm apply dropn_add #align stream.wseq.dropn_tail Stream'.WSeq.dropn_tail theorem get?_add (s : WSeq α) (m n) : get? s (m + n) = get? (drop s m) n := congr_arg head (dropn_add _ _ _) #align stream.wseq.nth_add Stream'.WSeq.get?_add theorem get?_tail (s : WSeq α) (n) : get? (tail s) n = get? s (n + 1) := congr_arg head (dropn_tail _ _) #align stream.wseq.nth_tail Stream'.WSeq.get?_tail @[simp] theorem join_nil : join nil = (nil : WSeq α) := Seq.join_nil #align stream.wseq.join_nil Stream'.WSeq.join_nil @[simp] theorem join_think (S : WSeq (WSeq α)) : join (think S) = think (join S) := by simp only [join, think] dsimp only [(· <$> ·)] simp [join, Seq1.ret] #align stream.wseq.join_think Stream'.WSeq.join_think @[simp] theorem join_cons (s : WSeq α) (S) : join (cons s S) = think (append s (join S)) := by simp only [join, think] dsimp only [(· <$> ·)] simp [join, cons, append] #align stream.wseq.join_cons Stream'.WSeq.join_cons @[simp] theorem nil_append (s : WSeq α) : append nil s = s := Seq.nil_append _ #align stream.wseq.nil_append Stream'.WSeq.nil_append @[simp] theorem cons_append (a : α) (s t) : append (cons a s) t = cons a (append s t) := Seq.cons_append _ _ _ #align stream.wseq.cons_append Stream'.WSeq.cons_append @[simp] theorem think_append (s t : WSeq α) : append (think s) t = think (append s t) := Seq.cons_append _ _ _ #align stream.wseq.think_append Stream'.WSeq.think_append @[simp] theorem append_nil (s : WSeq α) : append s nil = s := Seq.append_nil _ #align stream.wseq.append_nil Stream'.WSeq.append_nil @[simp] theorem append_assoc (s t u : WSeq α) : append (append s t) u = append s (append t u) := Seq.append_assoc _ _ _ #align stream.wseq.append_assoc Stream'.WSeq.append_assoc @[simp] def tail.aux : Option (α × WSeq α) → Computation (Option (α × WSeq α)) | none => Computation.pure none | some (_, s) => destruct s #align stream.wseq.tail.aux Stream'.WSeq.tail.aux theorem destruct_tail (s : WSeq α) : destruct (tail s) = destruct s >>= tail.aux := by simp only [tail, destruct_flatten, tail.aux]; rw [← bind_pure_comp, LawfulMonad.bind_assoc] apply congr_arg; ext1 (_ | ⟨a, s⟩) <;> apply (@pure_bind Computation _ _ _ _ _ _).trans _ <;> simp #align stream.wseq.destruct_tail Stream'.WSeq.destruct_tail @[simp] def drop.aux : ℕ → Option (α × WSeq α) → Computation (Option (α × WSeq α)) | 0 => Computation.pure | n + 1 => fun a => tail.aux a >>= drop.aux n #align stream.wseq.drop.aux Stream'.WSeq.drop.aux theorem drop.aux_none : ∀ n, @drop.aux α n none = Computation.pure none | 0 => rfl | n + 1 => show Computation.bind (Computation.pure none) (drop.aux n) = Computation.pure none by rw [ret_bind, drop.aux_none n] #align stream.wseq.drop.aux_none Stream'.WSeq.drop.aux_none theorem destruct_dropn : ∀ (s : WSeq α) (n), destruct (drop s n) = destruct s >>= drop.aux n | s, 0 => (bind_pure' _).symm | s, n + 1 => by rw [← dropn_tail, destruct_dropn _ n, destruct_tail, LawfulMonad.bind_assoc] rfl #align stream.wseq.destruct_dropn Stream'.WSeq.destruct_dropn theorem head_terminates_of_head_tail_terminates (s : WSeq α) [T : Terminates (head (tail s))] : Terminates (head s) := (head_terminates_iff _).2 <| by rcases (head_terminates_iff _).1 T with ⟨⟨a, h⟩⟩ simp? [tail] at h says simp only [tail, destruct_flatten] at h rcases exists_of_mem_bind h with ⟨s', h1, _⟩ unfold Functor.map at h1 exact let ⟨t, h3, _⟩ := Computation.exists_of_mem_map h1 Computation.terminates_of_mem h3 #align stream.wseq.head_terminates_of_head_tail_terminates Stream'.WSeq.head_terminates_of_head_tail_terminates theorem destruct_some_of_destruct_tail_some {s : WSeq α} {a} (h : some a ∈ destruct (tail s)) : ∃ a', some a' ∈ destruct s := by unfold tail Functor.map at h; simp only [destruct_flatten] at h rcases exists_of_mem_bind h with ⟨t, tm, td⟩; clear h rcases Computation.exists_of_mem_map tm with ⟨t', ht', ht2⟩; clear tm cases' t' with t' <;> rw [← ht2] at td <;> simp only [destruct_nil] at td · have := mem_unique td (ret_mem _) contradiction · exact ⟨_, ht'⟩ #align stream.wseq.destruct_some_of_destruct_tail_some Stream'.WSeq.destruct_some_of_destruct_tail_some theorem head_some_of_head_tail_some {s : WSeq α} {a} (h : some a ∈ head (tail s)) : ∃ a', some a' ∈ head s := by unfold head at h rcases Computation.exists_of_mem_map h with ⟨o, md, e⟩; clear h cases' o with o <;> [injection e; injection e with h']; clear h' cases' destruct_some_of_destruct_tail_some md with a am exact ⟨_, Computation.mem_map (@Prod.fst α (WSeq α) <$> ·) am⟩ #align stream.wseq.head_some_of_head_tail_some Stream'.WSeq.head_some_of_head_tail_some theorem head_some_of_get?_some {s : WSeq α} {a n} (h : some a ∈ get? s n) : ∃ a', some a' ∈ head s := by induction n generalizing a with | zero => exact ⟨_, h⟩ | succ n IH => let ⟨a', h'⟩ := head_some_of_head_tail_some h exact IH h' #align stream.wseq.head_some_of_nth_some Stream'.WSeq.head_some_of_get?_some instance productive_tail (s : WSeq α) [Productive s] : Productive (tail s) := ⟨fun n => by rw [get?_tail]; infer_instance⟩ #align stream.wseq.productive_tail Stream'.WSeq.productive_tail instance productive_dropn (s : WSeq α) [Productive s] (n) : Productive (drop s n) := ⟨fun m => by rw [← get?_add]; infer_instance⟩ #align stream.wseq.productive_dropn Stream'.WSeq.productive_dropn def toSeq (s : WSeq α) [Productive s] : Seq α := ⟨fun n => (get? s n).get, fun {n} h => by cases e : Computation.get (get? s (n + 1)) · assumption have := Computation.mem_of_get_eq _ e simp? [get?] at this h says simp only [get?] at this h cases' head_some_of_head_tail_some this with a' h' have := mem_unique h' (@Computation.mem_of_get_eq _ _ _ _ h) contradiction⟩ #align stream.wseq.to_seq Stream'.WSeq.toSeq theorem get?_terminates_le {s : WSeq α} {m n} (h : m ≤ n) : Terminates (get? s n) → Terminates (get? s m) := by induction' h with m' _ IH exacts [id, fun T => IH (@head_terminates_of_head_tail_terminates _ _ T)] #align stream.wseq.nth_terminates_le Stream'.WSeq.get?_terminates_le theorem head_terminates_of_get?_terminates {s : WSeq α} {n} : Terminates (get? s n) → Terminates (head s) := get?_terminates_le (Nat.zero_le n) #align stream.wseq.head_terminates_of_nth_terminates Stream'.WSeq.head_terminates_of_get?_terminates theorem destruct_terminates_of_get?_terminates {s : WSeq α} {n} (T : Terminates (get? s n)) : Terminates (destruct s) := (head_terminates_iff _).1 <| head_terminates_of_get?_terminates T #align stream.wseq.destruct_terminates_of_nth_terminates Stream'.WSeq.destruct_terminates_of_get?_terminates theorem mem_rec_on {C : WSeq α → Prop} {a s} (M : a ∈ s) (h1 : ∀ b s', a = b ∨ C s' → C (cons b s')) (h2 : ∀ s, C s → C (think s)) : C s := by apply Seq.mem_rec_on M intro o s' h; cases' o with b · apply h2 cases h · contradiction · assumption · apply h1 apply Or.imp_left _ h intro h injection h #align stream.wseq.mem_rec_on Stream'.WSeq.mem_rec_on @[simp] theorem mem_think (s : WSeq α) (a) : a ∈ think s ↔ a ∈ s := by cases' s with f al change (some (some a) ∈ some none::f) ↔ some (some a) ∈ f constructor <;> intro h · apply (Stream'.eq_or_mem_of_mem_cons h).resolve_left intro injections · apply Stream'.mem_cons_of_mem _ h #align stream.wseq.mem_think Stream'.WSeq.mem_think theorem eq_or_mem_iff_mem {s : WSeq α} {a a' s'} : some (a', s') ∈ destruct s → (a ∈ s ↔ a = a' ∨ a ∈ s') := by generalize e : destruct s = c; intro h revert s apply Computation.memRecOn h <;> [skip; intro c IH] <;> intro s <;> induction' s using WSeq.recOn with x s s <;> intro m <;> have := congr_arg Computation.destruct m <;> simp at this · cases' this with i1 i2 rw [i1, i2] cases' s' with f al dsimp only [cons, (· ∈ ·), WSeq.Mem, Seq.Mem, Seq.cons] have h_a_eq_a' : a = a' ↔ some (some a) = some (some a') := by simp rw [h_a_eq_a'] refine ⟨Stream'.eq_or_mem_of_mem_cons, fun o => ?_⟩ · cases' o with e m · rw [e] apply Stream'.mem_cons · exact Stream'.mem_cons_of_mem _ m · simp [IH this] #align stream.wseq.eq_or_mem_iff_mem Stream'.WSeq.eq_or_mem_iff_mem @[simp] theorem mem_cons_iff (s : WSeq α) (b) {a} : a ∈ cons b s ↔ a = b ∨ a ∈ s := eq_or_mem_iff_mem <| by simp [ret_mem] #align stream.wseq.mem_cons_iff Stream'.WSeq.mem_cons_iff theorem mem_cons_of_mem {s : WSeq α} (b) {a} (h : a ∈ s) : a ∈ cons b s := (mem_cons_iff _ _).2 (Or.inr h) #align stream.wseq.mem_cons_of_mem Stream'.WSeq.mem_cons_of_mem theorem mem_cons (s : WSeq α) (a) : a ∈ cons a s := (mem_cons_iff _ _).2 (Or.inl rfl) #align stream.wseq.mem_cons Stream'.WSeq.mem_cons theorem mem_of_mem_tail {s : WSeq α} {a} : a ∈ tail s → a ∈ s := by intro h; have := h; cases' h with n e; revert s; simp only [Stream'.get] induction' n with n IH <;> intro s <;> induction' s using WSeq.recOn with x s s <;> simp <;> intro m e <;> injections · exact Or.inr m · exact Or.inr m · apply IH m rw [e] cases tail s rfl #align stream.wseq.mem_of_mem_tail Stream'.WSeq.mem_of_mem_tail theorem mem_of_mem_dropn {s : WSeq α} {a} : ∀ {n}, a ∈ drop s n → a ∈ s | 0, h => h | n + 1, h => @mem_of_mem_dropn s a n (mem_of_mem_tail h) #align stream.wseq.mem_of_mem_dropn Stream'.WSeq.mem_of_mem_dropn theorem get?_mem {s : WSeq α} {a n} : some a ∈ get? s n → a ∈ s := by revert s; induction' n with n IH <;> intro s h · -- Porting note: This line is required to infer metavariables in -- `Computation.exists_of_mem_map`. dsimp only [get?, head] at h rcases Computation.exists_of_mem_map h with ⟨o, h1, h2⟩ cases' o with o · injection h2 injection h2 with h' cases' o with a' s' exact (eq_or_mem_iff_mem h1).2 (Or.inl h'.symm) · have := @IH (tail s) rw [get?_tail] at this exact mem_of_mem_tail (this h) #align stream.wseq.nth_mem Stream'.WSeq.get?_mem theorem exists_get?_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n, some a ∈ get? s n := by apply mem_rec_on h · intro a' s' h cases' h with h h · exists 0 simp only [get?, drop, head_cons] rw [h] apply ret_mem · cases' h with n h exists n + 1 -- porting note (#10745): was `simp [get?]`. simpa [get?] · intro s' h cases' h with n h exists n simp only [get?, dropn_think, head_think] apply think_mem h #align stream.wseq.exists_nth_of_mem Stream'.WSeq.exists_get?_of_mem theorem exists_dropn_of_mem {s : WSeq α} {a} (h : a ∈ s) : ∃ n s', some (a, s') ∈ destruct (drop s n) := let ⟨n, h⟩ := exists_get?_of_mem h ⟨n, by rcases (head_terminates_iff _).1 ⟨⟨_, h⟩⟩ with ⟨⟨o, om⟩⟩ have := Computation.mem_unique (Computation.mem_map _ om) h cases' o with o · injection this injection this with i cases' o with a' s' dsimp at i rw [i] at om exact ⟨_, om⟩⟩ #align stream.wseq.exists_dropn_of_mem Stream'.WSeq.exists_dropn_of_mem theorem liftRel_dropn_destruct {R : α → β → Prop} {s t} (H : LiftRel R s t) : ∀ n, Computation.LiftRel (LiftRelO R (LiftRel R)) (destruct (drop s n)) (destruct (drop t n)) | 0 => liftRel_destruct H | n + 1 => by simp only [LiftRelO, drop, Nat.add_eq, Nat.add_zero, destruct_tail, tail.aux] apply liftRel_bind · apply liftRel_dropn_destruct H n exact fun {a b} o => match a, b, o with | none, none, _ => by -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] | some (a, s), some (b, t), ⟨_, h2⟩ => by simpa [tail.aux] using liftRel_destruct h2 #align stream.wseq.lift_rel_dropn_destruct Stream'.WSeq.liftRel_dropn_destruct theorem exists_of_liftRel_left {R : α → β → Prop} {s t} (H : LiftRel R s t) {a} (h : a ∈ s) : ∃ b, b ∈ t ∧ R a b := by let ⟨n, h⟩ := exists_get?_of_mem h -- Porting note: This line is required to infer metavariables in -- `Computation.exists_of_mem_map`. dsimp only [get?, head] at h let ⟨some (_, s'), sd, rfl⟩ := Computation.exists_of_mem_map h let ⟨some (b, t'), td, ⟨ab, _⟩⟩ := (liftRel_dropn_destruct H n).left sd exact ⟨b, get?_mem (Computation.mem_map (Prod.fst.{v, v} <$> ·) td), ab⟩ #align stream.wseq.exists_of_lift_rel_left Stream'.WSeq.exists_of_liftRel_left theorem exists_of_liftRel_right {R : α → β → Prop} {s t} (H : LiftRel R s t) {b} (h : b ∈ t) : ∃ a, a ∈ s ∧ R a b := by rw [← LiftRel.swap] at H; exact exists_of_liftRel_left H h #align stream.wseq.exists_of_lift_rel_right Stream'.WSeq.exists_of_liftRel_right theorem head_terminates_of_mem {s : WSeq α} {a} (h : a ∈ s) : Terminates (head s) := let ⟨_, h⟩ := exists_get?_of_mem h head_terminates_of_get?_terminates ⟨⟨_, h⟩⟩ #align stream.wseq.head_terminates_of_mem Stream'.WSeq.head_terminates_of_mem theorem of_mem_append {s₁ s₂ : WSeq α} {a : α} : a ∈ append s₁ s₂ → a ∈ s₁ ∨ a ∈ s₂ := Seq.of_mem_append #align stream.wseq.of_mem_append Stream'.WSeq.of_mem_append theorem mem_append_left {s₁ s₂ : WSeq α} {a : α} : a ∈ s₁ → a ∈ append s₁ s₂ := Seq.mem_append_left #align stream.wseq.mem_append_left Stream'.WSeq.mem_append_left theorem exists_of_mem_map {f} {b : β} : ∀ {s : WSeq α}, b ∈ map f s → ∃ a, a ∈ s ∧ f a = b | ⟨g, al⟩, h => by let ⟨o, om, oe⟩ := Seq.exists_of_mem_map h cases' o with a · injection oe injection oe with h' exact ⟨a, om, h'⟩ #align stream.wseq.exists_of_mem_map Stream'.WSeq.exists_of_mem_map @[simp] theorem liftRel_nil (R : α → β → Prop) : LiftRel R nil nil := by rw [liftRel_destruct_iff] -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] #align stream.wseq.lift_rel_nil Stream'.WSeq.liftRel_nil @[simp] theorem liftRel_cons (R : α → β → Prop) (a b s t) : LiftRel R (cons a s) (cons b t) ↔ R a b ∧ LiftRel R s t := by rw [liftRel_destruct_iff] -- Porting note: These 2 theorems should be excluded. simp [-liftRel_pure_left, -liftRel_pure_right] #align stream.wseq.lift_rel_cons Stream'.WSeq.liftRel_cons @[simp] theorem liftRel_think_left (R : α → β → Prop) (s t) : LiftRel R (think s) t ↔ LiftRel R s t := by rw [liftRel_destruct_iff, liftRel_destruct_iff]; simp #align stream.wseq.lift_rel_think_left Stream'.WSeq.liftRel_think_left @[simp] theorem liftRel_think_right (R : α → β → Prop) (s t) : LiftRel R s (think t) ↔ LiftRel R s t := by rw [liftRel_destruct_iff, liftRel_destruct_iff]; simp #align stream.wseq.lift_rel_think_right Stream'.WSeq.liftRel_think_right theorem cons_congr {s t : WSeq α} (a : α) (h : s ~ʷ t) : cons a s ~ʷ cons a t := by unfold Equiv; simpa using h #align stream.wseq.cons_congr Stream'.WSeq.cons_congr theorem think_equiv (s : WSeq α) : think s ~ʷ s := by unfold Equiv; simpa using Equiv.refl _ #align stream.wseq.think_equiv Stream'.WSeq.think_equiv theorem think_congr {s t : WSeq α} (h : s ~ʷ t) : think s ~ʷ think t := by unfold Equiv; simpa using h #align stream.wseq.think_congr Stream'.WSeq.think_congr theorem head_congr : ∀ {s t : WSeq α}, s ~ʷ t → head s ~ head t := by suffices ∀ {s t : WSeq α}, s ~ʷ t → ∀ {o}, o ∈ head s → o ∈ head t from fun s t h o => ⟨this h, this h.symm⟩ intro s t h o ho rcases @Computation.exists_of_mem_map _ _ _ _ (destruct s) ho with ⟨ds, dsm, dse⟩ rw [← dse] cases' destruct_congr h with l r rcases l dsm with ⟨dt, dtm, dst⟩ cases' ds with a <;> cases' dt with b · apply Computation.mem_map _ dtm · cases b cases dst · cases a cases dst · cases' a with a s' cases' b with b t' rw [dst.left] exact @Computation.mem_map _ _ (@Functor.map _ _ (α × WSeq α) _ Prod.fst) (some (b, t')) (destruct t) dtm #align stream.wseq.head_congr Stream'.WSeq.head_congr theorem flatten_equiv {c : Computation (WSeq α)} {s} (h : s ∈ c) : flatten c ~ʷ s := by apply Computation.memRecOn h · simp [Equiv.refl] · intro s' apply Equiv.trans simp [think_equiv] #align stream.wseq.flatten_equiv Stream'.WSeq.flatten_equiv theorem liftRel_flatten {R : α → β → Prop} {c1 : Computation (WSeq α)} {c2 : Computation (WSeq β)} (h : c1.LiftRel (LiftRel R) c2) : LiftRel R (flatten c1) (flatten c2) := let S s t := ∃ c1 c2, s = flatten c1 ∧ t = flatten c2 ∧ Computation.LiftRel (LiftRel R) c1 c2 ⟨S, ⟨c1, c2, rfl, rfl, h⟩, fun {s t} h => match s, t, h with | _, _, ⟨c1, c2, rfl, rfl, h⟩ => by simp only [destruct_flatten]; apply liftRel_bind _ _ h intro a b ab; apply Computation.LiftRel.imp _ _ _ (liftRel_destruct ab) intro a b; apply LiftRelO.imp_right intro s t h; refine ⟨Computation.pure s, Computation.pure t, ?_, ?_, ?_⟩ <;> -- Porting note: These 2 theorems should be excluded. simp [h, -liftRel_pure_left, -liftRel_pure_right]⟩ #align stream.wseq.lift_rel_flatten Stream'.WSeq.liftRel_flatten theorem flatten_congr {c1 c2 : Computation (WSeq α)} : Computation.LiftRel Equiv c1 c2 → flatten c1 ~ʷ flatten c2 := liftRel_flatten #align stream.wseq.flatten_congr Stream'.WSeq.flatten_congr theorem tail_congr {s t : WSeq α} (h : s ~ʷ t) : tail s ~ʷ tail t := by apply flatten_congr dsimp only [(· <$> ·)]; rw [← Computation.bind_pure, ← Computation.bind_pure] apply liftRel_bind _ _ (destruct_congr h) intro a b h; simp only [comp_apply, liftRel_pure] cases' a with a <;> cases' b with b · trivial · cases h · cases a cases h · cases' a with a s' cases' b with b t' exact h.right #align stream.wseq.tail_congr Stream'.WSeq.tail_congr theorem dropn_congr {s t : WSeq α} (h : s ~ʷ t) (n) : drop s n ~ʷ drop t n := by induction n <;> simp [*, tail_congr, drop] #align stream.wseq.dropn_congr Stream'.WSeq.dropn_congr theorem get?_congr {s t : WSeq α} (h : s ~ʷ t) (n) : get? s n ~ get? t n := head_congr (dropn_congr h _) #align stream.wseq.nth_congr Stream'.WSeq.get?_congr theorem mem_congr {s t : WSeq α} (h : s ~ʷ t) (a) : a ∈ s ↔ a ∈ t := suffices ∀ {s t : WSeq α}, s ~ʷ t → a ∈ s → a ∈ t from ⟨this h, this h.symm⟩ fun {_ _} h as => let ⟨_, hn⟩ := exists_get?_of_mem as get?_mem ((get?_congr h _ _).1 hn) #align stream.wseq.mem_congr Stream'.WSeq.mem_congr theorem productive_congr {s t : WSeq α} (h : s ~ʷ t) : Productive s ↔ Productive t := by simp only [productive_iff]; exact forall_congr' fun n => terminates_congr <| get?_congr h _ #align stream.wseq.productive_congr Stream'.WSeq.productive_congr theorem Equiv.ext {s t : WSeq α} (h : ∀ n, get? s n ~ get? t n) : s ~ʷ t := ⟨fun s t => ∀ n, get? s n ~ get? t n, h, fun {s t} h => by refine liftRel_def.2 ⟨?_, ?_⟩ · rw [← head_terminates_iff, ← head_terminates_iff] exact terminates_congr (h 0) · intro a b ma mb cases' a with a <;> cases' b with b · trivial · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) · injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) · cases' a with a s' cases' b with b t' injection mem_unique (Computation.mem_map _ ma) ((h 0 _).2 (Computation.mem_map _ mb)) with ab refine ⟨ab, fun n => ?_⟩ refine (get?_congr (flatten_equiv (Computation.mem_map _ ma)) n).symm.trans ((?_ : get? (tail s) n ~ get? (tail t) n).trans (get?_congr (flatten_equiv (Computation.mem_map _ mb)) n)) rw [get?_tail, get?_tail] apply h⟩ #align stream.wseq.equiv.ext Stream'.WSeq.Equiv.ext theorem length_eq_map (s : WSeq α) : length s = Computation.map List.length (toList s) := by refine Computation.eq_of_bisim (fun c1 c2 => ∃ (l : List α) (s : WSeq α), c1 = Computation.corec (fun ⟨n, s⟩ => match Seq.destruct s with | none => Sum.inl n | some (none, s') => Sum.inr (n, s') | some (some _, s') => Sum.inr (n + 1, s')) (l.length, s) ∧ c2 = Computation.map List.length (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, s))) ?_ ⟨[], s, rfl, rfl⟩ intro s1 s2 h; rcases h with ⟨l, s, h⟩; rw [h.left, h.right] induction' s using WSeq.recOn with a s s <;> simp [toList, nil, cons, think, length] · refine ⟨a::l, s, ?_, ?_⟩ <;> simp · refine ⟨l, s, ?_, ?_⟩ <;> simp #align stream.wseq.length_eq_map Stream'.WSeq.length_eq_map @[simp] theorem ofList_nil : ofList [] = (nil : WSeq α) := rfl #align stream.wseq.of_list_nil Stream'.WSeq.ofList_nil @[simp] theorem ofList_cons (a : α) (l) : ofList (a::l) = cons a (ofList l) := show Seq.map some (Seq.ofList (a::l)) = Seq.cons (some a) (Seq.map some (Seq.ofList l)) by simp #align stream.wseq.of_list_cons Stream'.WSeq.ofList_cons @[simp] theorem toList'_nil (l : List α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, nil) = Computation.pure l.reverse := destruct_eq_pure rfl #align stream.wseq.to_list'_nil Stream'.WSeq.toList'_nil @[simp] theorem toList'_cons (l : List α) (s : WSeq α) (a : α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, cons a s) = (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (a::l, s)).think := destruct_eq_think <| by simp [toList, cons] #align stream.wseq.to_list'_cons Stream'.WSeq.toList'_cons @[simp] theorem toList'_think (l : List α) (s : WSeq α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, think s) = (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l, s)).think := destruct_eq_think <| by simp [toList, think] #align stream.wseq.to_list'_think Stream'.WSeq.toList'_think theorem toList'_map (l : List α) (s : WSeq α) : Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a :: l, s')) (l, s) = (l.reverse ++ ·) <$> toList s := by refine Computation.eq_of_bisim (fun c1 c2 => ∃ (l' : List α) (s : WSeq α), c1 = Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l' ++ l, s) ∧ c2 = Computation.map (l.reverse ++ ·) (Computation.corec (fun ⟨l, s⟩ => match Seq.destruct s with | none => Sum.inl l.reverse | some (none, s') => Sum.inr (l, s') | some (some a, s') => Sum.inr (a::l, s')) (l', s))) ?_ ⟨[], s, rfl, rfl⟩ intro s1 s2 h; rcases h with ⟨l', s, h⟩; rw [h.left, h.right] induction' s using WSeq.recOn with a s s <;> simp [toList, nil, cons, think, length] · refine ⟨a::l', s, ?_, ?_⟩ <;> simp · refine ⟨l', s, ?_, ?_⟩ <;> simp #align stream.wseq.to_list'_map Stream'.WSeq.toList'_map @[simp] theorem toList_cons (a : α) (s) : toList (cons a s) = (List.cons a <$> toList s).think := destruct_eq_think <| by unfold toList simp only [toList'_cons, Computation.destruct_think, Sum.inr.injEq] rw [toList'_map] simp only [List.reverse_cons, List.reverse_nil, List.nil_append, List.singleton_append] rfl #align stream.wseq.to_list_cons Stream'.WSeq.toList_cons @[simp] theorem toList_nil : toList (nil : WSeq α) = Computation.pure [] := destruct_eq_pure rfl #align stream.wseq.to_list_nil Stream'.WSeq.toList_nil theorem toList_ofList (l : List α) : l ∈ toList (ofList l) := by induction' l with a l IH <;> simp [ret_mem]; exact think_mem (Computation.mem_map _ IH) #align stream.wseq.to_list_of_list Stream'.WSeq.toList_ofList @[simp] theorem destruct_ofSeq (s : Seq α) : destruct (ofSeq s) = Computation.pure (s.head.map fun a => (a, ofSeq s.tail)) := destruct_eq_pure <| by simp only [destruct, Seq.destruct, Option.map_eq_map, ofSeq, Computation.corec_eq, rmap, Seq.head] rw [show Seq.get? (some <$> s) 0 = some <$> Seq.get? s 0 by apply Seq.map_get?] cases' Seq.get? s 0 with a · rfl dsimp only [(· <$> ·)] simp [destruct] #align stream.wseq.destruct_of_seq Stream'.WSeq.destruct_ofSeq @[simp] theorem head_ofSeq (s : Seq α) : head (ofSeq s) = Computation.pure s.head := by simp only [head, Option.map_eq_map, destruct_ofSeq, Computation.map_pure, Option.map_map] cases Seq.head s <;> rfl #align stream.wseq.head_of_seq Stream'.WSeq.head_ofSeq @[simp] theorem tail_ofSeq (s : Seq α) : tail (ofSeq s) = ofSeq s.tail := by simp only [tail, destruct_ofSeq, map_pure', flatten_pure] induction' s using Seq.recOn with x s <;> simp only [ofSeq, Seq.tail_nil, Seq.head_nil, Option.map_none', Seq.tail_cons, Seq.head_cons, Option.map_some'] · rfl #align stream.wseq.tail_of_seq Stream'.WSeq.tail_ofSeq @[simp] theorem dropn_ofSeq (s : Seq α) : ∀ n, drop (ofSeq s) n = ofSeq (s.drop n) | 0 => rfl | n + 1 => by simp only [drop, Nat.add_eq, Nat.add_zero, Seq.drop] rw [dropn_ofSeq s n, tail_ofSeq] #align stream.wseq.dropn_of_seq Stream'.WSeq.dropn_ofSeq theorem get?_ofSeq (s : Seq α) (n) : get? (ofSeq s) n = Computation.pure (Seq.get? s n) := by dsimp [get?]; rw [dropn_ofSeq, head_ofSeq, Seq.head_dropn] #align stream.wseq.nth_of_seq Stream'.WSeq.get?_ofSeq instance productive_ofSeq (s : Seq α) : Productive (ofSeq s) := ⟨fun n => by rw [get?_ofSeq]; infer_instance⟩ #align stream.wseq.productive_of_seq Stream'.WSeq.productive_ofSeq
Mathlib/Data/Seq/WSeq.lean
1,392
1,395
theorem toSeq_ofSeq (s : Seq α) : toSeq (ofSeq s) = s := by
apply Subtype.eq; funext n dsimp [toSeq]; apply get_eq_of_mem rw [get?_ofSeq]; apply ret_mem
import Mathlib.Analysis.Convex.Between import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Convex.Topology import Mathlib.Analysis.Normed.Group.Pointwise import Mathlib.Analysis.NormedSpace.AddTorsor #align_import analysis.convex.normed from "leanprover-community/mathlib"@"a63928c34ec358b5edcda2bf7513c50052a5230f" variable {ι : Type*} {E P : Type*} open Metric Set open scoped Convex variable [SeminormedAddCommGroup E] [NormedSpace ℝ E] [PseudoMetricSpace P] [NormedAddTorsor E P] variable {s t : Set E} theorem convexOn_norm (hs : Convex ℝ s) : ConvexOn ℝ s norm := ⟨hs, fun x _ y _ a b ha hb _ => calc ‖a • x + b • y‖ ≤ ‖a • x‖ + ‖b • y‖ := norm_add_le _ _ _ = a * ‖x‖ + b * ‖y‖ := by rw [norm_smul, norm_smul, Real.norm_of_nonneg ha, Real.norm_of_nonneg hb]⟩ #align convex_on_norm convexOn_norm theorem convexOn_univ_norm : ConvexOn ℝ univ (norm : E → ℝ) := convexOn_norm convex_univ #align convex_on_univ_norm convexOn_univ_norm theorem convexOn_dist (z : E) (hs : Convex ℝ s) : ConvexOn ℝ s fun z' => dist z' z := by simpa [dist_eq_norm, preimage_preimage] using (convexOn_norm (hs.translate (-z))).comp_affineMap (AffineMap.id ℝ E - AffineMap.const ℝ E z) #align convex_on_dist convexOn_dist theorem convexOn_univ_dist (z : E) : ConvexOn ℝ univ fun z' => dist z' z := convexOn_dist z convex_univ #align convex_on_univ_dist convexOn_univ_dist theorem convex_ball (a : E) (r : ℝ) : Convex ℝ (Metric.ball a r) := by simpa only [Metric.ball, sep_univ] using (convexOn_univ_dist a).convex_lt r #align convex_ball convex_ball theorem convex_closedBall (a : E) (r : ℝ) : Convex ℝ (Metric.closedBall a r) := by simpa only [Metric.closedBall, sep_univ] using (convexOn_univ_dist a).convex_le r #align convex_closed_ball convex_closedBall theorem Convex.thickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (thickening δ s) := by rw [← add_ball_zero] exact hs.add (convex_ball 0 _) #align convex.thickening Convex.thickening theorem Convex.cthickening (hs : Convex ℝ s) (δ : ℝ) : Convex ℝ (cthickening δ s) := by obtain hδ | hδ := le_total 0 δ · rw [cthickening_eq_iInter_thickening hδ] exact convex_iInter₂ fun _ _ => hs.thickening _ · rw [cthickening_of_nonpos hδ] exact hs.closure #align convex.cthickening Convex.cthickening theorem convexHull_exists_dist_ge {s : Set E} {x : E} (hx : x ∈ convexHull ℝ s) (y : E) : ∃ x' ∈ s, dist x y ≤ dist x' y := (convexOn_dist y (convex_convexHull ℝ _)).exists_ge_of_mem_convexHull hx #align convex_hull_exists_dist_ge convexHull_exists_dist_ge
Mathlib/Analysis/Convex/Normed.lean
92
97
theorem convexHull_exists_dist_ge2 {s t : Set E} {x y : E} (hx : x ∈ convexHull ℝ s) (hy : y ∈ convexHull ℝ t) : ∃ x' ∈ s, ∃ y' ∈ t, dist x y ≤ dist x' y' := by
rcases convexHull_exists_dist_ge hx y with ⟨x', hx', Hx'⟩ rcases convexHull_exists_dist_ge hy x' with ⟨y', hy', Hy'⟩ use x', hx', y', hy' exact le_trans Hx' (dist_comm y x' ▸ dist_comm y' x' ▸ Hy')
import Mathlib.Analysis.Analytic.Composition #align_import analysis.analytic.inverse from "leanprover-community/mathlib"@"284fdd2962e67d2932fa3a79ce19fcf92d38e228" open scoped Classical Topology open Finset Filter namespace FormalMultilinearSeries variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] noncomputable def leftInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : FormalMultilinearSeries 𝕜 F E | 0 => 0 | 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm | n + 2 => -∑ c : { c : Composition (n + 2) // c.length < n + 2 }, (leftInv p i (c : Composition (n + 2)).length).compAlongComposition (p.compContinuousLinearMap i.symm) c #align formal_multilinear_series.left_inv FormalMultilinearSeries.leftInv @[simp] theorem leftInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.leftInv i 0 = 0 := by rw [leftInv] #align formal_multilinear_series.left_inv_coeff_zero FormalMultilinearSeries.leftInv_coeff_zero @[simp] theorem leftInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.leftInv i 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [leftInv] #align formal_multilinear_series.left_inv_coeff_one FormalMultilinearSeries.leftInv_coeff_one theorem leftInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.removeZero.leftInv i = p.leftInv i := by ext1 n induction' n using Nat.strongRec' with n IH match n with | 0 => simp -- if one replaces `simp` with `refl`, the proof times out in the kernel. | 1 => simp -- TODO: why? | n + 2 => simp only [leftInv, neg_inj] refine Finset.sum_congr rfl fun c cuniv => ?_ rcases c with ⟨c, hc⟩ ext v dsimp simp [IH _ hc] #align formal_multilinear_series.left_inv_remove_zero FormalMultilinearSeries.leftInv_removeZero theorem leftInv_comp (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) : (leftInv p i).comp p = id 𝕜 E := by ext (n v) match n with | 0 => simp only [leftInv_coeff_zero, ContinuousMultilinearMap.zero_apply, id_apply_ne_one, Ne, not_false_iff, zero_ne_one, comp_coeff_zero'] | 1 => simp only [leftInv_coeff_one, comp_coeff_one, h, id_apply_one, ContinuousLinearEquiv.coe_apply, ContinuousLinearEquiv.symm_apply_apply, continuousMultilinearCurryFin1_symm_apply] | n + 2 => have A : (Finset.univ : Finset (Composition (n + 2))) = {c | Composition.length c < n + 2}.toFinset ∪ {Composition.ones (n + 2)} := by refine Subset.antisymm (fun c _ => ?_) (subset_univ _) by_cases h : c.length < n + 2 · simp [h, Set.mem_toFinset (s := {c | Composition.length c < n + 2})] · simp [Composition.eq_ones_iff_le_length.2 (not_lt.1 h)] have B : Disjoint ({c | Composition.length c < n + 2} : Set (Composition (n + 2))).toFinset {Composition.ones (n + 2)} := by simp [Set.mem_toFinset (s := {c | Composition.length c < n + 2})] have C : ((p.leftInv i (Composition.ones (n + 2)).length) fun j : Fin (Composition.ones n.succ.succ).length => p 1 fun _ => v ((Fin.castLE (Composition.length_le _)) j)) = p.leftInv i (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j := by apply FormalMultilinearSeries.congr _ (Composition.ones_length _) fun j hj1 hj2 => ?_ exact FormalMultilinearSeries.congr _ rfl fun k _ _ => by congr have D : (p.leftInv i (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j) = -∑ c ∈ {c : Composition (n + 2) | c.length < n + 2}.toFinset, (p.leftInv i c.length) (p.applyComposition c v) := by simp only [leftInv, ContinuousMultilinearMap.neg_apply, neg_inj, ContinuousMultilinearMap.sum_apply] convert (sum_toFinset_eq_subtype (fun c : Composition (n + 2) => c.length < n + 2) (fun c : Composition (n + 2) => (ContinuousMultilinearMap.compAlongComposition (p.compContinuousLinearMap (i.symm : F →L[𝕜] E)) c (p.leftInv i c.length)) fun j : Fin (n + 2) => p 1 fun _ : Fin 1 => v j)).symm.trans _ simp only [compContinuousLinearMap_applyComposition, ContinuousMultilinearMap.compAlongComposition_apply] congr ext c congr ext k simp [h, Function.comp] simp [FormalMultilinearSeries.comp, show n + 2 ≠ 1 by omega, A, Finset.sum_union B, applyComposition_ones, C, D, -Set.toFinset_setOf] #align formal_multilinear_series.left_inv_comp FormalMultilinearSeries.leftInv_comp noncomputable def rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : FormalMultilinearSeries 𝕜 F E | 0 => 0 | 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm | n + 2 => let q : FormalMultilinearSeries 𝕜 F E := fun k => if k < n + 2 then rightInv p i k else 0; -(i.symm : F →L[𝕜] E).compContinuousMultilinearMap ((p.comp q) (n + 2)) #align formal_multilinear_series.right_inv FormalMultilinearSeries.rightInv @[simp] theorem rightInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.rightInv i 0 = 0 := by rw [rightInv] #align formal_multilinear_series.right_inv_coeff_zero FormalMultilinearSeries.rightInv_coeff_zero @[simp] theorem rightInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.rightInv i 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [rightInv] #align formal_multilinear_series.right_inv_coeff_one FormalMultilinearSeries.rightInv_coeff_one theorem rightInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) : p.removeZero.rightInv i = p.rightInv i := by ext1 n induction' n using Nat.strongRec' with n IH match n with | 0 => simp only [rightInv_coeff_zero] | 1 => simp only [rightInv_coeff_one] | n + 2 => simp only [rightInv, neg_inj] rw [removeZero_comp_of_pos _ _ (add_pos_of_nonneg_of_pos n.zero_le zero_lt_two)] congr (config := { closePost := false }) 2 with k by_cases hk : k < n + 2 <;> simp [hk, IH] #align formal_multilinear_series.right_inv_remove_zero FormalMultilinearSeries.rightInv_removeZero
Mathlib/Analysis/Analytic/Inverse.lean
202
228
theorem comp_rightInv_aux1 {n : ℕ} (hn : 0 < n) (p : FormalMultilinearSeries 𝕜 E F) (q : FormalMultilinearSeries 𝕜 F E) (v : Fin n → F) : p.comp q n v = ∑ c ∈ {c : Composition n | 1 < c.length}.toFinset, p c.length (q.applyComposition c v) + p 1 fun _ => q n v := by
have A : (Finset.univ : Finset (Composition n)) = {c | 1 < Composition.length c}.toFinset ∪ {Composition.single n hn} := by refine Subset.antisymm (fun c _ => ?_) (subset_univ _) by_cases h : 1 < c.length · simp [h, Set.mem_toFinset (s := {c | 1 < Composition.length c})] · have : c.length = 1 := by refine (eq_iff_le_not_lt.2 ⟨?_, h⟩).symm; exact c.length_pos_of_pos hn rw [← Composition.eq_single_iff_length hn] at this simp [this] have B : Disjoint ({c | 1 < Composition.length c} : Set (Composition n)).toFinset {Composition.single n hn} := by simp [Set.mem_toFinset (s := {c | 1 < Composition.length c})] have C : p (Composition.single n hn).length (q.applyComposition (Composition.single n hn) v) = p 1 fun _ : Fin 1 => q n v := by apply p.congr (Composition.single_length hn) fun j hj1 _ => ?_ simp [applyComposition_single] simp [FormalMultilinearSeries.comp, A, Finset.sum_union B, C, -Set.toFinset_setOf, -add_right_inj, -Composition.single_length]
import Mathlib.MeasureTheory.Measure.VectorMeasure import Mathlib.Order.SymmDiff #align_import measure_theory.decomposition.signed_hahn from "leanprover-community/mathlib"@"bc7d81beddb3d6c66f71449c5bc76c38cb77cf9e" noncomputable section open scoped Classical NNReal ENNReal MeasureTheory variable {α β : Type*} [MeasurableSpace α] variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] [OrderedAddCommMonoid M] namespace MeasureTheory namespace SignedMeasure open Filter VectorMeasure variable {s : SignedMeasure α} {i j : Set α} section ExistsSubsetRestrictNonpos private def ExistsOneDivLT (s : SignedMeasure α) (i : Set α) (n : ℕ) : Prop := ∃ k : Set α, k ⊆ i ∧ MeasurableSet k ∧ (1 / (n + 1) : ℝ) < s k private theorem existsNatOneDivLTMeasure_of_not_negative (hi : ¬s ≤[i] 0) : ∃ n : ℕ, ExistsOneDivLT s i n := let ⟨k, hj₁, hj₂, hj⟩ := exists_pos_measure_of_not_restrict_le_zero s hi let ⟨n, hn⟩ := exists_nat_one_div_lt hj ⟨n, k, hj₂, hj₁, hn⟩ private def findExistsOneDivLT (s : SignedMeasure α) (i : Set α) : ℕ := if hi : ¬s ≤[i] 0 then Nat.find (existsNatOneDivLTMeasure_of_not_negative hi) else 0 private theorem findExistsOneDivLT_spec (hi : ¬s ≤[i] 0) : ExistsOneDivLT s i (findExistsOneDivLT s i) := by rw [findExistsOneDivLT, dif_pos hi] convert Nat.find_spec (existsNatOneDivLTMeasure_of_not_negative hi) private theorem findExistsOneDivLT_min (hi : ¬s ≤[i] 0) {m : ℕ} (hm : m < findExistsOneDivLT s i) : ¬ExistsOneDivLT s i m := by rw [findExistsOneDivLT, dif_pos hi] at hm exact Nat.find_min _ hm private def someExistsOneDivLT (s : SignedMeasure α) (i : Set α) : Set α := if hi : ¬s ≤[i] 0 then Classical.choose (findExistsOneDivLT_spec hi) else ∅ private theorem someExistsOneDivLT_spec (hi : ¬s ≤[i] 0) : someExistsOneDivLT s i ⊆ i ∧ MeasurableSet (someExistsOneDivLT s i) ∧ (1 / (findExistsOneDivLT s i + 1) : ℝ) < s (someExistsOneDivLT s i) := by rw [someExistsOneDivLT, dif_pos hi] exact Classical.choose_spec (findExistsOneDivLT_spec hi) private theorem someExistsOneDivLT_subset : someExistsOneDivLT s i ⊆ i := by by_cases hi : ¬s ≤[i] 0 · exact let ⟨h, _⟩ := someExistsOneDivLT_spec hi h · rw [someExistsOneDivLT, dif_neg hi] exact Set.empty_subset _ private theorem someExistsOneDivLT_subset' : someExistsOneDivLT s (i \ j) ⊆ i := someExistsOneDivLT_subset.trans Set.diff_subset private theorem someExistsOneDivLT_measurableSet : MeasurableSet (someExistsOneDivLT s i) := by by_cases hi : ¬s ≤[i] 0 · exact let ⟨_, h, _⟩ := someExistsOneDivLT_spec hi h · rw [someExistsOneDivLT, dif_neg hi] exact MeasurableSet.empty private theorem someExistsOneDivLT_lt (hi : ¬s ≤[i] 0) : (1 / (findExistsOneDivLT s i + 1) : ℝ) < s (someExistsOneDivLT s i) := let ⟨_, _, h⟩ := someExistsOneDivLT_spec hi h private def restrictNonposSeq (s : SignedMeasure α) (i : Set α) : ℕ → Set α | 0 => someExistsOneDivLT s (i \ ∅) -- I used `i \ ∅` instead of `i` to simplify some proofs | n + 1 => someExistsOneDivLT s (i \ ⋃ (k) (H : k ≤ n), have : k < n + 1 := Nat.lt_succ_iff.mpr H restrictNonposSeq s i k) private theorem restrictNonposSeq_succ (n : ℕ) : restrictNonposSeq s i n.succ = someExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) := by rw [restrictNonposSeq] private theorem restrictNonposSeq_subset (n : ℕ) : restrictNonposSeq s i n ⊆ i := by cases n <;> · rw [restrictNonposSeq]; exact someExistsOneDivLT_subset' private theorem restrictNonposSeq_lt (n : ℕ) (hn : ¬s ≤[i \ ⋃ k ≤ n, restrictNonposSeq s i k] 0) : (1 / (findExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) + 1) : ℝ) < s (restrictNonposSeq s i n.succ) := by rw [restrictNonposSeq_succ] apply someExistsOneDivLT_lt hn private theorem measure_of_restrictNonposSeq (hi₂ : ¬s ≤[i] 0) (n : ℕ) (hn : ¬s ≤[i \ ⋃ k < n, restrictNonposSeq s i k] 0) : 0 < s (restrictNonposSeq s i n) := by cases n with | zero => rw [restrictNonposSeq]; rw [← @Set.diff_empty _ i] at hi₂ rcases someExistsOneDivLT_spec hi₂ with ⟨_, _, h⟩ exact lt_trans Nat.one_div_pos_of_nat h | succ n => rw [restrictNonposSeq_succ] have h₁ : ¬s ≤[i \ ⋃ (k : ℕ) (_ : k ≤ n), restrictNonposSeq s i k] 0 := by refine mt (restrict_le_zero_subset _ ?_ (by simp [Nat.lt_succ_iff]; rfl)) hn convert measurable_of_not_restrict_le_zero _ hn using 3 exact funext fun x => by rw [Nat.lt_succ_iff] rcases someExistsOneDivLT_spec h₁ with ⟨_, _, h⟩ exact lt_trans Nat.one_div_pos_of_nat h private theorem restrictNonposSeq_measurableSet (n : ℕ) : MeasurableSet (restrictNonposSeq s i n) := by cases n <;> · rw [restrictNonposSeq] exact someExistsOneDivLT_measurableSet private theorem restrictNonposSeq_disjoint' {n m : ℕ} (h : n < m) : restrictNonposSeq s i n ∩ restrictNonposSeq s i m = ∅ := by rw [Set.eq_empty_iff_forall_not_mem] rintro x ⟨hx₁, hx₂⟩ cases m; · omega · rw [restrictNonposSeq] at hx₂ exact (someExistsOneDivLT_subset hx₂).2 (Set.mem_iUnion.2 ⟨n, Set.mem_iUnion.2 ⟨Nat.lt_succ_iff.mp h, hx₁⟩⟩) private theorem restrictNonposSeq_disjoint : Pairwise (Disjoint on restrictNonposSeq s i) := by intro n m h rw [Function.onFun, Set.disjoint_iff_inter_eq_empty] rcases lt_or_gt_of_ne h with (h | h) · rw [restrictNonposSeq_disjoint' h] · rw [Set.inter_comm, restrictNonposSeq_disjoint' h] private theorem exists_subset_restrict_nonpos' (hi₁ : MeasurableSet i) (hi₂ : s i < 0) (hn : ¬∀ n : ℕ, ¬s ≤[i \ ⋃ l < n, restrictNonposSeq s i l] 0) : ∃ j : Set α, MeasurableSet j ∧ j ⊆ i ∧ s ≤[j] 0 ∧ s j < 0 := by by_cases h : s ≤[i] 0 · exact ⟨i, hi₁, Set.Subset.refl _, h, hi₂⟩ push_neg at hn set k := Nat.find hn have hk₂ : s ≤[i \ ⋃ l < k, restrictNonposSeq s i l] 0 := Nat.find_spec hn have hmeas : MeasurableSet (⋃ (l : ℕ) (_ : l < k), restrictNonposSeq s i l) := MeasurableSet.iUnion fun _ => MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _ refine ⟨i \ ⋃ l < k, restrictNonposSeq s i l, hi₁.diff hmeas, Set.diff_subset, hk₂, ?_⟩ rw [of_diff hmeas hi₁, s.of_disjoint_iUnion_nat] · have h₁ : ∀ l < k, 0 ≤ s (restrictNonposSeq s i l) := by intro l hl refine le_of_lt (measure_of_restrictNonposSeq h _ ?_) refine mt (restrict_le_zero_subset _ (hi₁.diff ?_) (Set.Subset.refl _)) (Nat.find_min hn hl) exact MeasurableSet.iUnion fun _ => MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _ suffices 0 ≤ ∑' l : ℕ, s (⋃ _ : l < k, restrictNonposSeq s i l) by rw [sub_neg] exact lt_of_lt_of_le hi₂ this refine tsum_nonneg ?_ intro l; by_cases h : l < k · convert h₁ _ h ext x rw [Set.mem_iUnion, exists_prop, and_iff_right_iff_imp] exact fun _ => h · convert le_of_eq s.empty.symm ext; simp only [exists_prop, Set.mem_empty_iff_false, Set.mem_iUnion, not_and, iff_false_iff] exact fun h' => False.elim (h h') · intro; exact MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _ · intro a b hab refine Set.disjoint_iUnion_left.mpr fun _ => ?_ refine Set.disjoint_iUnion_right.mpr fun _ => ?_ exact restrictNonposSeq_disjoint hab · apply Set.iUnion_subset intro a x simp only [and_imp, exists_prop, Set.mem_iUnion] intro _ hx exact restrictNonposSeq_subset _ hx
Mathlib/MeasureTheory/Decomposition/SignedHahn.lean
266
328
theorem exists_subset_restrict_nonpos (hi : s i < 0) : ∃ j : Set α, MeasurableSet j ∧ j ⊆ i ∧ s ≤[j] 0 ∧ s j < 0 := by
have hi₁ : MeasurableSet i := by_contradiction fun h => ne_of_lt hi <| s.not_measurable h by_cases h : s ≤[i] 0; · exact ⟨i, hi₁, Set.Subset.refl _, h, hi⟩ by_cases hn : ∀ n : ℕ, ¬s ≤[i \ ⋃ l < n, restrictNonposSeq s i l] 0 swap; · exact exists_subset_restrict_nonpos' hi₁ hi hn set A := i \ ⋃ l, restrictNonposSeq s i l with hA set bdd : ℕ → ℕ := fun n => findExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) have hn' : ∀ n : ℕ, ¬s ≤[i \ ⋃ l ≤ n, restrictNonposSeq s i l] 0 := by intro n convert hn (n + 1) using 5 <;> · ext l simp only [exists_prop, Set.mem_iUnion, and_congr_left_iff] exact fun _ => Nat.lt_succ_iff.symm have h₁ : s i = s A + ∑' l, s (restrictNonposSeq s i l) := by rw [hA, ← s.of_disjoint_iUnion_nat, add_comm, of_add_of_diff] · exact MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _ exacts [hi₁, Set.iUnion_subset fun _ => restrictNonposSeq_subset _, fun _ => restrictNonposSeq_measurableSet _, restrictNonposSeq_disjoint] have h₂ : s A ≤ s i := by rw [h₁] apply le_add_of_nonneg_right exact tsum_nonneg fun n => le_of_lt (measure_of_restrictNonposSeq h _ (hn n)) have h₃' : Summable fun n => (1 / (bdd n + 1) : ℝ) := by have : Summable fun l => s (restrictNonposSeq s i l) := HasSum.summable (s.m_iUnion (fun _ => restrictNonposSeq_measurableSet _) restrictNonposSeq_disjoint) refine .of_nonneg_of_le (fun n => ?_) (fun n => ?_) (this.comp_injective Nat.succ_injective) · exact le_of_lt Nat.one_div_pos_of_nat · exact le_of_lt (restrictNonposSeq_lt n (hn' n)) have h₃ : Tendsto (fun n => (bdd n : ℝ) + 1) atTop atTop := by simp only [one_div] at h₃' exact Summable.tendsto_atTop_of_pos h₃' fun n => Nat.cast_add_one_pos (bdd n) have h₄ : Tendsto (fun n => (bdd n : ℝ)) atTop atTop := by convert atTop.tendsto_atTop_add_const_right (-1) h₃; simp have A_meas : MeasurableSet A := hi₁.diff (MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _) refine ⟨A, A_meas, Set.diff_subset, ?_, h₂.trans_lt hi⟩ by_contra hnn rw [restrict_le_restrict_iff _ _ A_meas] at hnn; push_neg at hnn obtain ⟨E, hE₁, hE₂, hE₃⟩ := hnn have : ∃ k, 1 ≤ bdd k ∧ 1 / (bdd k : ℝ) < s E := by rw [tendsto_atTop_atTop] at h₄ obtain ⟨k, hk⟩ := h₄ (max (1 / s E + 1) 1) refine ⟨k, ?_, ?_⟩ · have hle := le_of_max_le_right (hk k le_rfl) norm_cast at hle · have : 1 / s E < bdd k := by linarith only [le_of_max_le_left (hk k le_rfl)] rw [one_div] at this ⊢ rwa [inv_lt (lt_trans (inv_pos.2 hE₃) this) hE₃] obtain ⟨k, hk₁, hk₂⟩ := this have hA' : A ⊆ i \ ⋃ l ≤ k, restrictNonposSeq s i l := by apply Set.diff_subset_diff_right intro x; simp only [Set.mem_iUnion] rintro ⟨n, _, hn₂⟩ exact ⟨n, hn₂⟩ refine findExistsOneDivLT_min (hn' k) (Nat.sub_lt hk₁ Nat.zero_lt_one) ⟨E, Set.Subset.trans hE₂ hA', hE₁, ?_⟩ convert hk₂; norm_cast exact tsub_add_cancel_of_le hk₁
import Mathlib.Algebra.Order.Ring.Defs import Mathlib.Algebra.Group.Int import Mathlib.Data.Nat.Dist import Mathlib.Data.Ordmap.Ordnode import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith #align_import data.ordmap.ordset from "leanprover-community/mathlib"@"47b51515e69f59bca5cf34ef456e6000fe205a69" variable {α : Type*} namespace Ordnode theorem not_le_delta {s} (H : 1 ≤ s) : ¬s ≤ delta * 0 := not_le_of_gt H #align ordnode.not_le_delta Ordnode.not_le_delta theorem delta_lt_false {a b : ℕ} (h₁ : delta * a < b) (h₂ : delta * b < a) : False := not_le_of_lt (lt_trans ((mul_lt_mul_left (by decide)).2 h₁) h₂) <| by simpa [mul_assoc] using Nat.mul_le_mul_right a (by decide : 1 ≤ delta * delta) #align ordnode.delta_lt_false Ordnode.delta_lt_false def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize def Sized : Ordnode α → Prop | nil => True | node s l _ r => s = size l + size r + 1 ∧ Sized l ∧ Sized r #align ordnode.sized Ordnode.Sized theorem Sized.node' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (node' l x r) := ⟨rfl, hl, hr⟩ #align ordnode.sized.node' Ordnode.Sized.node' theorem Sized.eq_node' {s l x r} (h : @Sized α (node s l x r)) : node s l x r = .node' l x r := by rw [h.1] #align ordnode.sized.eq_node' Ordnode.Sized.eq_node' theorem Sized.size_eq {s l x r} (H : Sized (@node α s l x r)) : size (@node α s l x r) = size l + size r + 1 := H.1 #align ordnode.sized.size_eq Ordnode.Sized.size_eq @[elab_as_elim] theorem Sized.induction {t} (hl : @Sized α t) {C : Ordnode α → Prop} (H0 : C nil) (H1 : ∀ l x r, C l → C r → C (.node' l x r)) : C t := by induction t with | nil => exact H0 | node _ _ _ _ t_ih_l t_ih_r => rw [hl.eq_node'] exact H1 _ _ _ (t_ih_l hl.2.1) (t_ih_r hl.2.2) #align ordnode.sized.induction Ordnode.Sized.induction theorem size_eq_realSize : ∀ {t : Ordnode α}, Sized t → size t = realSize t | nil, _ => rfl | node s l x r, ⟨h₁, h₂, h₃⟩ => by rw [size, h₁, size_eq_realSize h₂, size_eq_realSize h₃]; rfl #align ordnode.size_eq_real_size Ordnode.size_eq_realSize @[simp] theorem Sized.size_eq_zero {t : Ordnode α} (ht : Sized t) : size t = 0 ↔ t = nil := by cases t <;> [simp;simp [ht.1]] #align ordnode.sized.size_eq_zero Ordnode.Sized.size_eq_zero theorem Sized.pos {s l x r} (h : Sized (@node α s l x r)) : 0 < s := by rw [h.1]; apply Nat.le_add_left #align ordnode.sized.pos Ordnode.Sized.pos theorem dual_dual : ∀ t : Ordnode α, dual (dual t) = t | nil => rfl | node s l x r => by rw [dual, dual, dual_dual l, dual_dual r] #align ordnode.dual_dual Ordnode.dual_dual @[simp] theorem size_dual (t : Ordnode α) : size (dual t) = size t := by cases t <;> rfl #align ordnode.size_dual Ordnode.size_dual def BalancedSz (l r : ℕ) : Prop := l + r ≤ 1 ∨ l ≤ delta * r ∧ r ≤ delta * l #align ordnode.balanced_sz Ordnode.BalancedSz instance BalancedSz.dec : DecidableRel BalancedSz := fun _ _ => Or.decidable #align ordnode.balanced_sz.dec Ordnode.BalancedSz.dec def Balanced : Ordnode α → Prop | nil => True | node _ l _ r => BalancedSz (size l) (size r) ∧ Balanced l ∧ Balanced r #align ordnode.balanced Ordnode.Balanced instance Balanced.dec : DecidablePred (@Balanced α) | nil => by unfold Balanced infer_instance | node _ l _ r => by unfold Balanced haveI := Balanced.dec l haveI := Balanced.dec r infer_instance #align ordnode.balanced.dec Ordnode.Balanced.dec @[symm] theorem BalancedSz.symm {l r : ℕ} : BalancedSz l r → BalancedSz r l := Or.imp (by rw [add_comm]; exact id) And.symm #align ordnode.balanced_sz.symm Ordnode.BalancedSz.symm theorem balancedSz_zero {l : ℕ} : BalancedSz l 0 ↔ l ≤ 1 := by simp (config := { contextual := true }) [BalancedSz] #align ordnode.balanced_sz_zero Ordnode.balancedSz_zero theorem balancedSz_up {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ r₂ ≤ delta * l) (H : BalancedSz l r₁) : BalancedSz l r₂ := by refine or_iff_not_imp_left.2 fun h => ?_ refine ⟨?_, h₂.resolve_left h⟩ cases H with | inl H => cases r₂ · cases h (le_trans (Nat.add_le_add_left (Nat.zero_le _) _) H) · exact le_trans (le_trans (Nat.le_add_right _ _) H) (Nat.le_add_left 1 _) | inr H => exact le_trans H.1 (Nat.mul_le_mul_left _ h₁) #align ordnode.balanced_sz_up Ordnode.balancedSz_up theorem balancedSz_down {l r₁ r₂ : ℕ} (h₁ : r₁ ≤ r₂) (h₂ : l + r₂ ≤ 1 ∨ l ≤ delta * r₁) (H : BalancedSz l r₂) : BalancedSz l r₁ := have : l + r₂ ≤ 1 → BalancedSz l r₁ := fun H => Or.inl (le_trans (Nat.add_le_add_left h₁ _) H) Or.casesOn H this fun H => Or.casesOn h₂ this fun h₂ => Or.inr ⟨h₂, le_trans h₁ H.2⟩ #align ordnode.balanced_sz_down Ordnode.balancedSz_down theorem Balanced.dual : ∀ {t : Ordnode α}, Balanced t → Balanced (dual t) | nil, _ => ⟨⟩ | node _ l _ r, ⟨b, bl, br⟩ => ⟨by rw [size_dual, size_dual]; exact b.symm, br.dual, bl.dual⟩ #align ordnode.balanced.dual Ordnode.Balanced.dual def node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' (node' l x m) y r #align ordnode.node3_l Ordnode.node3L def node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' l x (node' m y r) #align ordnode.node3_r Ordnode.node3R def node4L : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r) | l, x, nil, z, r => node3L l x nil z r #align ordnode.node4_l Ordnode.node4L -- should not happen def node4R : Ordnode α → α → Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ ml y mr, z, r => node' (node' l x ml) y (node' mr z r) | l, x, nil, z, r => node3R l x nil z r #align ordnode.node4_r Ordnode.node4R -- should not happen def rotateL : Ordnode α → α → Ordnode α → Ordnode α | l, x, node _ m y r => if size m < ratio * size r then node3L l x m y r else node4L l x m y r | l, x, nil => node' l x nil #align ordnode.rotate_l Ordnode.rotateL -- Porting note (#11467): during the port we marked these lemmas with `@[eqns]` -- to emulate the old Lean 3 behaviour. theorem rotateL_node (l : Ordnode α) (x : α) (sz : ℕ) (m : Ordnode α) (y : α) (r : Ordnode α) : rotateL l x (node sz m y r) = if size m < ratio * size r then node3L l x m y r else node4L l x m y r := rfl theorem rotateL_nil (l : Ordnode α) (x : α) : rotateL l x nil = node' l x nil := rfl -- should not happen def rotateR : Ordnode α → α → Ordnode α → Ordnode α | node _ l x m, y, r => if size m < ratio * size l then node3R l x m y r else node4R l x m y r | nil, y, r => node' nil y r #align ordnode.rotate_r Ordnode.rotateR -- Porting note (#11467): during the port we marked these lemmas with `@[eqns]` -- to emulate the old Lean 3 behaviour. theorem rotateR_node (sz : ℕ) (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : rotateR (node sz l x m) y r = if size m < ratio * size l then node3R l x m y r else node4R l x m y r := rfl theorem rotateR_nil (y : α) (r : Ordnode α) : rotateR nil y r = node' nil y r := rfl -- should not happen def balanceL' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size l > delta * size r then rotateR l x r else node' l x r #align ordnode.balance_l' Ordnode.balanceL' def balanceR' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size r > delta * size l then rotateL l x r else node' l x r #align ordnode.balance_r' Ordnode.balanceR' def balance' (l : Ordnode α) (x : α) (r : Ordnode α) : Ordnode α := if size l + size r ≤ 1 then node' l x r else if size r > delta * size l then rotateL l x r else if size l > delta * size r then rotateR l x r else node' l x r #align ordnode.balance' Ordnode.balance' theorem dual_node' (l : Ordnode α) (x : α) (r : Ordnode α) : dual (node' l x r) = node' (dual r) x (dual l) := by simp [node', add_comm] #align ordnode.dual_node' Ordnode.dual_node' theorem dual_node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node3L l x m y r) = node3R (dual r) y (dual m) x (dual l) := by simp [node3L, node3R, dual_node', add_comm] #align ordnode.dual_node3_l Ordnode.dual_node3L theorem dual_node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node3R l x m y r) = node3L (dual r) y (dual m) x (dual l) := by simp [node3L, node3R, dual_node', add_comm] #align ordnode.dual_node3_r Ordnode.dual_node3R theorem dual_node4L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node4L l x m y r) = node4R (dual r) y (dual m) x (dual l) := by cases m <;> simp [node4L, node4R, node3R, dual_node3L, dual_node', add_comm] #align ordnode.dual_node4_l Ordnode.dual_node4L theorem dual_node4R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : dual (node4R l x m y r) = node4L (dual r) y (dual m) x (dual l) := by cases m <;> simp [node4L, node4R, node3L, dual_node3R, dual_node', add_comm] #align ordnode.dual_node4_r Ordnode.dual_node4R theorem dual_rotateL (l : Ordnode α) (x : α) (r : Ordnode α) : dual (rotateL l x r) = rotateR (dual r) x (dual l) := by cases r <;> simp [rotateL, rotateR, dual_node']; split_ifs <;> simp [dual_node3L, dual_node4L, node3R, add_comm] #align ordnode.dual_rotate_l Ordnode.dual_rotateL theorem dual_rotateR (l : Ordnode α) (x : α) (r : Ordnode α) : dual (rotateR l x r) = rotateL (dual r) x (dual l) := by rw [← dual_dual (rotateL _ _ _), dual_rotateL, dual_dual, dual_dual] #align ordnode.dual_rotate_r Ordnode.dual_rotateR theorem dual_balance' (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balance' l x r) = balance' (dual r) x (dual l) := by simp [balance', add_comm]; split_ifs with h h_1 h_2 <;> simp [dual_node', dual_rotateL, dual_rotateR, add_comm] cases delta_lt_false h_1 h_2 #align ordnode.dual_balance' Ordnode.dual_balance' theorem dual_balanceL (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balanceL l x r) = balanceR (dual r) x (dual l) := by unfold balanceL balanceR cases' r with rs rl rx rr · cases' l with ls ll lx lr; · rfl cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> dsimp only [dual, id] <;> try rfl split_ifs with h <;> repeat simp [h, add_comm] · cases' l with ls ll lx lr; · rfl dsimp only [dual, id] split_ifs; swap; · simp [add_comm] cases' ll with lls lll llx llr <;> cases' lr with lrs lrl lrx lrr <;> try rfl dsimp only [dual, id] split_ifs with h <;> simp [h, add_comm] #align ordnode.dual_balance_l Ordnode.dual_balanceL theorem dual_balanceR (l : Ordnode α) (x : α) (r : Ordnode α) : dual (balanceR l x r) = balanceL (dual r) x (dual l) := by rw [← dual_dual (balanceL _ _ _), dual_balanceL, dual_dual, dual_dual] #align ordnode.dual_balance_r Ordnode.dual_balanceR theorem Sized.node3L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node3L l x m y r) := (hl.node' hm).node' hr #align ordnode.sized.node3_l Ordnode.Sized.node3L theorem Sized.node3R {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node3R l x m y r) := hl.node' (hm.node' hr) #align ordnode.sized.node3_r Ordnode.Sized.node3R theorem Sized.node4L {l x m y r} (hl : @Sized α l) (hm : Sized m) (hr : Sized r) : Sized (node4L l x m y r) := by cases m <;> [exact (hl.node' hm).node' hr; exact (hl.node' hm.2.1).node' (hm.2.2.node' hr)] #align ordnode.sized.node4_l Ordnode.Sized.node4L theorem node3L_size {l x m y r} : size (@node3L α l x m y r) = size l + size m + size r + 2 := by dsimp [node3L, node', size]; rw [add_right_comm _ 1] #align ordnode.node3_l_size Ordnode.node3L_size theorem node3R_size {l x m y r} : size (@node3R α l x m y r) = size l + size m + size r + 2 := by dsimp [node3R, node', size]; rw [← add_assoc, ← add_assoc] #align ordnode.node3_r_size Ordnode.node3R_size theorem node4L_size {l x m y r} (hm : Sized m) : size (@node4L α l x m y r) = size l + size m + size r + 2 := by cases m <;> simp [node4L, node3L, node'] <;> [abel; (simp [size, hm.1]; abel)] #align ordnode.node4_l_size Ordnode.node4L_size theorem Sized.dual : ∀ {t : Ordnode α}, Sized t → Sized (dual t) | nil, _ => ⟨⟩ | node _ l _ r, ⟨rfl, sl, sr⟩ => ⟨by simp [size_dual, add_comm], Sized.dual sr, Sized.dual sl⟩ #align ordnode.sized.dual Ordnode.Sized.dual theorem Sized.dual_iff {t : Ordnode α} : Sized (.dual t) ↔ Sized t := ⟨fun h => by rw [← dual_dual t]; exact h.dual, Sized.dual⟩ #align ordnode.sized.dual_iff Ordnode.Sized.dual_iff theorem Sized.rotateL {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateL l x r) := by cases r; · exact hl.node' hr rw [Ordnode.rotateL_node]; split_ifs · exact hl.node3L hr.2.1 hr.2.2 · exact hl.node4L hr.2.1 hr.2.2 #align ordnode.sized.rotate_l Ordnode.Sized.rotateL theorem Sized.rotateR {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (rotateR l x r) := Sized.dual_iff.1 <| by rw [dual_rotateR]; exact hr.dual.rotateL hl.dual #align ordnode.sized.rotate_r Ordnode.Sized.rotateR theorem Sized.rotateL_size {l x r} (hm : Sized r) : size (@Ordnode.rotateL α l x r) = size l + size r + 1 := by cases r <;> simp [Ordnode.rotateL] simp only [hm.1] split_ifs <;> simp [node3L_size, node4L_size hm.2.1] <;> abel #align ordnode.sized.rotate_l_size Ordnode.Sized.rotateL_size theorem Sized.rotateR_size {l x r} (hl : Sized l) : size (@Ordnode.rotateR α l x r) = size l + size r + 1 := by rw [← size_dual, dual_rotateR, hl.dual.rotateL_size, size_dual, size_dual, add_comm (size l)] #align ordnode.sized.rotate_r_size Ordnode.Sized.rotateR_size theorem Sized.balance' {l x r} (hl : @Sized α l) (hr : Sized r) : Sized (balance' l x r) := by unfold balance'; split_ifs · exact hl.node' hr · exact hl.rotateL hr · exact hl.rotateR hr · exact hl.node' hr #align ordnode.sized.balance' Ordnode.Sized.balance' theorem size_balance' {l x r} (hl : @Sized α l) (hr : Sized r) : size (@balance' α l x r) = size l + size r + 1 := by unfold balance'; split_ifs · rfl · exact hr.rotateL_size · exact hl.rotateR_size · rfl #align ordnode.size_balance' Ordnode.size_balance' theorem All.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, All P t → All Q t | nil, _ => ⟨⟩ | node _ _ _ _, ⟨h₁, h₂, h₃⟩ => ⟨h₁.imp H, H _ h₂, h₃.imp H⟩ #align ordnode.all.imp Ordnode.All.imp theorem Any.imp {P Q : α → Prop} (H : ∀ a, P a → Q a) : ∀ {t}, Any P t → Any Q t | nil => id | node _ _ _ _ => Or.imp (Any.imp H) <| Or.imp (H _) (Any.imp H) #align ordnode.any.imp Ordnode.Any.imp theorem all_singleton {P : α → Prop} {x : α} : All P (singleton x) ↔ P x := ⟨fun h => h.2.1, fun h => ⟨⟨⟩, h, ⟨⟩⟩⟩ #align ordnode.all_singleton Ordnode.all_singleton theorem any_singleton {P : α → Prop} {x : α} : Any P (singleton x) ↔ P x := ⟨by rintro (⟨⟨⟩⟩ | h | ⟨⟨⟩⟩); exact h, fun h => Or.inr (Or.inl h)⟩ #align ordnode.any_singleton Ordnode.any_singleton theorem all_dual {P : α → Prop} : ∀ {t : Ordnode α}, All P (dual t) ↔ All P t | nil => Iff.rfl | node _ _l _x _r => ⟨fun ⟨hr, hx, hl⟩ => ⟨all_dual.1 hl, hx, all_dual.1 hr⟩, fun ⟨hl, hx, hr⟩ => ⟨all_dual.2 hr, hx, all_dual.2 hl⟩⟩ #align ordnode.all_dual Ordnode.all_dual theorem all_iff_forall {P : α → Prop} : ∀ {t}, All P t ↔ ∀ x, Emem x t → P x | nil => (iff_true_intro <| by rintro _ ⟨⟩).symm | node _ l x r => by simp [All, Emem, all_iff_forall, Any, or_imp, forall_and] #align ordnode.all_iff_forall Ordnode.all_iff_forall theorem any_iff_exists {P : α → Prop} : ∀ {t}, Any P t ↔ ∃ x, Emem x t ∧ P x | nil => ⟨by rintro ⟨⟩, by rintro ⟨_, ⟨⟩, _⟩⟩ | node _ l x r => by simp only [Emem]; simp [Any, any_iff_exists, or_and_right, exists_or] #align ordnode.any_iff_exists Ordnode.any_iff_exists theorem emem_iff_all {x : α} {t} : Emem x t ↔ ∀ P, All P t → P x := ⟨fun h _ al => all_iff_forall.1 al _ h, fun H => H _ <| all_iff_forall.2 fun _ => id⟩ #align ordnode.emem_iff_all Ordnode.emem_iff_all theorem all_node' {P l x r} : @All α P (node' l x r) ↔ All P l ∧ P x ∧ All P r := Iff.rfl #align ordnode.all_node' Ordnode.all_node' theorem all_node3L {P l x m y r} : @All α P (node3L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by simp [node3L, all_node', and_assoc] #align ordnode.all_node3_l Ordnode.all_node3L theorem all_node3R {P l x m y r} : @All α P (node3R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := Iff.rfl #align ordnode.all_node3_r Ordnode.all_node3R theorem all_node4L {P l x m y r} : @All α P (node4L l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by cases m <;> simp [node4L, all_node', All, all_node3L, and_assoc] #align ordnode.all_node4_l Ordnode.all_node4L
Mathlib/Data/Ordmap/Ordset.lean
513
515
theorem all_node4R {P l x m y r} : @All α P (node4R l x m y r) ↔ All P l ∧ P x ∧ All P m ∧ P y ∧ All P r := by
cases m <;> simp [node4R, all_node', All, all_node3R, and_assoc]
import Mathlib.Data.Countable.Basic import Mathlib.Data.Fin.VecNotation import Mathlib.Order.Disjointed import Mathlib.MeasureTheory.OuterMeasure.Defs #align_import measure_theory.measure.outer_measure from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55" noncomputable section open Set Function Filter open scoped Classical NNReal Topology ENNReal namespace MeasureTheory section OuterMeasureClass variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} @[simp] theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ #align measure_theory.measure_empty MeasureTheory.measure_empty @[mono, gcongr] theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t := OuterMeasureClass.measure_mono μ h #align measure_theory.measure_mono MeasureTheory.measure_mono theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 := eq_bot_mono (measure_mono h) ht #align measure_theory.measure_mono_null MeasureTheory.measure_mono_null theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t := hs.bot_lt.trans_le (measure_mono h) theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _ calc μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed] _ ≤ ∑' i, μ (disjointed t i) := OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _) _ ≤ ∑' i, μ (t i) := by gcongr; apply disjointed_subset #align measure_theory.measure_Union_le MeasureTheory.measure_iUnion_le theorem measure_biUnion_le {I : Set ι} (μ : F) (hI : I.Countable) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑' i : I, μ (s i) := by have := hI.to_subtype rw [biUnion_eq_iUnion] apply measure_iUnion_le #align measure_theory.measure_bUnion_le MeasureTheory.measure_biUnion_le theorem measure_biUnion_finset_le (I : Finset ι) (s : ι → Set α) : μ (⋃ i ∈ I, s i) ≤ ∑ i ∈ I, μ (s i) := (measure_biUnion_le μ I.countable_toSet s).trans_eq <| I.tsum_subtype (μ <| s ·) #align measure_theory.measure_bUnion_finset_le MeasureTheory.measure_biUnion_finset_le theorem measure_iUnion_fintype_le [Fintype ι] (μ : F) (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑ i, μ (s i) := by simpa using measure_biUnion_finset_le Finset.univ s #align measure_theory.measure_Union_fintype_le MeasureTheory.measure_iUnion_fintype_le theorem measure_union_le (s t : Set α) : μ (s ∪ t) ≤ μ s + μ t := by simpa [union_eq_iUnion] using measure_iUnion_fintype_le μ (cond · s t) #align measure_theory.measure_union_le MeasureTheory.measure_union_le theorem measure_le_inter_add_diff (μ : F) (s t : Set α) : μ s ≤ μ (s ∩ t) + μ (s \ t) := by simpa using measure_union_le (s ∩ t) (s \ t) theorem measure_diff_null (ht : μ t = 0) : μ (s \ t) = μ s := (measure_mono diff_subset).antisymm <| calc μ s ≤ μ (s ∩ t) + μ (s \ t) := measure_le_inter_add_diff _ _ _ _ ≤ μ t + μ (s \ t) := by gcongr; apply inter_subset_right _ = μ (s \ t) := by simp [ht] #align measure_theory.measure_diff_null MeasureTheory.measure_diff_null theorem measure_biUnion_null_iff {I : Set ι} (hI : I.Countable) {s : ι → Set α} : μ (⋃ i ∈ I, s i) = 0 ↔ ∀ i ∈ I, μ (s i) = 0 := by refine ⟨fun h i hi ↦ measure_mono_null (subset_biUnion_of_mem hi) h, fun h ↦ ?_⟩ have _ := hI.to_subtype simpa [h] using measure_iUnion_le (μ := μ) fun x : I ↦ s x #align measure_theory.measure_bUnion_null_iff MeasureTheory.measure_biUnion_null_iff theorem measure_sUnion_null_iff {S : Set (Set α)} (hS : S.Countable) : μ (⋃₀ S) = 0 ↔ ∀ s ∈ S, μ s = 0 := by rw [sUnion_eq_biUnion, measure_biUnion_null_iff hS] #align measure_theory.measure_sUnion_null_iff MeasureTheory.measure_sUnion_null_iff @[simp] theorem measure_iUnion_null_iff {ι : Sort*} [Countable ι] {s : ι → Set α} : μ (⋃ i, s i) = 0 ↔ ∀ i, μ (s i) = 0 := by rw [← sUnion_range, measure_sUnion_null_iff (countable_range s), forall_mem_range] #align measure_theory.measure_Union_null_iff MeasureTheory.measure_iUnion_null_iff alias ⟨_, measure_iUnion_null⟩ := measure_iUnion_null_iff #align measure_theory.measure_Union_null MeasureTheory.measure_iUnion_null @[simp] theorem measure_union_null_iff : μ (s ∪ t) = 0 ↔ μ s = 0 ∧ μ t = 0 := by simp [union_eq_iUnion, and_comm] #align measure_theory.measure_union_null_iff MeasureTheory.measure_union_null_iff
Mathlib/MeasureTheory/OuterMeasure/Basic.lean
129
129
theorem measure_union_null (hs : μ s = 0) (ht : μ t = 0) : μ (s ∪ t) = 0 := by
simp [*]
import Mathlib.Algebra.BigOperators.Group.Multiset import Mathlib.Data.PNat.Prime import Mathlib.Data.Nat.Factors import Mathlib.Data.Multiset.Sort #align_import data.pnat.factors from "leanprover-community/mathlib"@"e3d9ab8faa9dea8f78155c6c27d62a621f4c152d" -- Porting note: `deriving` contained Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, -- SemilatticeSup, OrderBot, Sub, OrderedSub def PrimeMultiset := Multiset Nat.Primes deriving Inhabited, CanonicallyOrderedAddCommMonoid, DistribLattice, SemilatticeSup, Sub #align prime_multiset PrimeMultiset instance : OrderBot PrimeMultiset where bot_le := by simp only [bot_le, forall_const] instance : OrderedSub PrimeMultiset where tsub_le_iff_right _ _ _ := Multiset.sub_le_iff_le_add namespace PrimeMultiset -- `@[derive]` doesn't work for `meta` instances unsafe instance : Repr PrimeMultiset := by delta PrimeMultiset; infer_instance def ofPrime (p : Nat.Primes) : PrimeMultiset := ({p} : Multiset Nat.Primes) #align prime_multiset.of_prime PrimeMultiset.ofPrime theorem card_ofPrime (p : Nat.Primes) : Multiset.card (ofPrime p) = 1 := rfl #align prime_multiset.card_of_prime PrimeMultiset.card_ofPrime def toNatMultiset : PrimeMultiset → Multiset ℕ := fun v => v.map Coe.coe #align prime_multiset.to_nat_multiset PrimeMultiset.toNatMultiset instance coeNat : Coe PrimeMultiset (Multiset ℕ) := ⟨toNatMultiset⟩ #align prime_multiset.coe_nat PrimeMultiset.coeNat def coeNatMonoidHom : PrimeMultiset →+ Multiset ℕ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_nat_monoid_hom PrimeMultiset.coeNatMonoidHom @[simp] theorem coe_coeNatMonoidHom : (coeNatMonoidHom : PrimeMultiset → Multiset ℕ) = Coe.coe := rfl #align prime_multiset.coe_coe_nat_monoid_hom PrimeMultiset.coe_coeNatMonoidHom theorem coeNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ) := Multiset.map_injective Nat.Primes.coe_nat_injective #align prime_multiset.coe_nat_injective PrimeMultiset.coeNat_injective theorem coeNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ) = {(p : ℕ)} := rfl #align prime_multiset.coe_nat_of_prime PrimeMultiset.coeNat_ofPrime theorem coeNat_prime (v : PrimeMultiset) (p : ℕ) (h : p ∈ (v : Multiset ℕ)) : p.Prime := by rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp' #align prime_multiset.coe_nat_prime PrimeMultiset.coeNat_prime def toPNatMultiset : PrimeMultiset → Multiset ℕ+ := fun v => v.map Coe.coe #align prime_multiset.to_pnat_multiset PrimeMultiset.toPNatMultiset instance coePNat : Coe PrimeMultiset (Multiset ℕ+) := ⟨toPNatMultiset⟩ #align prime_multiset.coe_pnat PrimeMultiset.coePNat def coePNatMonoidHom : PrimeMultiset →+ Multiset ℕ+ := { Multiset.mapAddMonoidHom Coe.coe with toFun := Coe.coe } #align prime_multiset.coe_pnat_monoid_hom PrimeMultiset.coePNatMonoidHom @[simp] theorem coe_coePNatMonoidHom : (coePNatMonoidHom : PrimeMultiset → Multiset ℕ+) = Coe.coe := rfl #align prime_multiset.coe_coe_pnat_monoid_hom PrimeMultiset.coe_coePNatMonoidHom theorem coePNat_injective : Function.Injective (Coe.coe : PrimeMultiset → Multiset ℕ+) := Multiset.map_injective Nat.Primes.coe_pnat_injective #align prime_multiset.coe_pnat_injective PrimeMultiset.coePNat_injective theorem coePNat_ofPrime (p : Nat.Primes) : (ofPrime p : Multiset ℕ+) = {(p : ℕ+)} := rfl #align prime_multiset.coe_pnat_of_prime PrimeMultiset.coePNat_ofPrime
Mathlib/Data/PNat/Factors.lean
121
123
theorem coePNat_prime (v : PrimeMultiset) (p : ℕ+) (h : p ∈ (v : Multiset ℕ+)) : p.Prime := by
rcases Multiset.mem_map.mp h with ⟨⟨_, hp'⟩, ⟨_, h_eq⟩⟩ exact h_eq ▸ hp'
import Mathlib.Analysis.Calculus.BumpFunction.FiniteDimension import Mathlib.Geometry.Manifold.ContMDiff.Atlas import Mathlib.Geometry.Manifold.ContMDiff.NormedSpace #align_import geometry.manifold.bump_function from "leanprover-community/mathlib"@"b018406ad2f2a73223a3a9e198ccae61e6f05318" universe uE uF uH uM variable {E : Type uE} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] {H : Type uH} [TopologicalSpace H] (I : ModelWithCorners ℝ E H) {M : Type uM} [TopologicalSpace M] [ChartedSpace H M] [SmoothManifoldWithCorners I M] open Function Filter FiniteDimensional Set Metric open scoped Topology Manifold Classical Filter noncomputable section structure SmoothBumpFunction (c : M) extends ContDiffBump (extChartAt I c c) where closedBall_subset : closedBall (extChartAt I c c) rOut ∩ range I ⊆ (extChartAt I c).target #align smooth_bump_function SmoothBumpFunction namespace SmoothBumpFunction variable {c : M} (f : SmoothBumpFunction I c) {x : M} {I} @[coe] def toFun : M → ℝ := indicator (chartAt H c).source (f.toContDiffBump ∘ extChartAt I c) #align smooth_bump_function.to_fun SmoothBumpFunction.toFun instance : CoeFun (SmoothBumpFunction I c) fun _ => M → ℝ := ⟨toFun⟩ theorem coe_def : ⇑f = indicator (chartAt H c).source (f.toContDiffBump ∘ extChartAt I c) := rfl #align smooth_bump_function.coe_def SmoothBumpFunction.coe_def theorem rOut_pos : 0 < f.rOut := f.toContDiffBump.rOut_pos set_option linter.uppercaseLean3 false in #align smooth_bump_function.R_pos SmoothBumpFunction.rOut_pos theorem ball_subset : ball (extChartAt I c c) f.rOut ∩ range I ⊆ (extChartAt I c).target := Subset.trans (inter_subset_inter_left _ ball_subset_closedBall) f.closedBall_subset #align smooth_bump_function.ball_subset SmoothBumpFunction.ball_subset theorem ball_inter_range_eq_ball_inter_target : ball (extChartAt I c c) f.rOut ∩ range I = ball (extChartAt I c c) f.rOut ∩ (extChartAt I c).target := (subset_inter inter_subset_left f.ball_subset).antisymm <| inter_subset_inter_right _ <| extChartAt_target_subset_range _ _ theorem eqOn_source : EqOn f (f.toContDiffBump ∘ extChartAt I c) (chartAt H c).source := eqOn_indicator #align smooth_bump_function.eq_on_source SmoothBumpFunction.eqOn_source theorem eventuallyEq_of_mem_source (hx : x ∈ (chartAt H c).source) : f =ᶠ[𝓝 x] f.toContDiffBump ∘ extChartAt I c := f.eqOn_source.eventuallyEq_of_mem <| (chartAt H c).open_source.mem_nhds hx #align smooth_bump_function.eventually_eq_of_mem_source SmoothBumpFunction.eventuallyEq_of_mem_source theorem one_of_dist_le (hs : x ∈ (chartAt H c).source) (hd : dist (extChartAt I c x) (extChartAt I c c) ≤ f.rIn) : f x = 1 := by simp only [f.eqOn_source hs, (· ∘ ·), f.one_of_mem_closedBall hd] #align smooth_bump_function.one_of_dist_le SmoothBumpFunction.one_of_dist_le theorem support_eq_inter_preimage : support f = (chartAt H c).source ∩ extChartAt I c ⁻¹' ball (extChartAt I c c) f.rOut := by rw [coe_def, support_indicator, support_comp_eq_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', ← (extChartAt I c).symm_image_target_inter_eq', f.support_eq] #align smooth_bump_function.support_eq_inter_preimage SmoothBumpFunction.support_eq_inter_preimage theorem isOpen_support : IsOpen (support f) := by rw [support_eq_inter_preimage] exact isOpen_extChartAt_preimage I c isOpen_ball #align smooth_bump_function.is_open_support SmoothBumpFunction.isOpen_support theorem support_eq_symm_image : support f = (extChartAt I c).symm '' (ball (extChartAt I c c) f.rOut ∩ range I) := by rw [f.support_eq_inter_preimage, ← extChartAt_source I, ← (extChartAt I c).symm_image_target_inter_eq', inter_comm, ball_inter_range_eq_ball_inter_target] #align smooth_bump_function.support_eq_symm_image SmoothBumpFunction.support_eq_symm_image theorem support_subset_source : support f ⊆ (chartAt H c).source := by rw [f.support_eq_inter_preimage, ← extChartAt_source I]; exact inter_subset_left #align smooth_bump_function.support_subset_source SmoothBumpFunction.support_subset_source theorem image_eq_inter_preimage_of_subset_support {s : Set M} (hs : s ⊆ support f) : extChartAt I c '' s = closedBall (extChartAt I c c) f.rOut ∩ range I ∩ (extChartAt I c).symm ⁻¹' s := by rw [support_eq_inter_preimage, subset_inter_iff, ← extChartAt_source I, ← image_subset_iff] at hs cases' hs with hse hsf apply Subset.antisymm · refine subset_inter (subset_inter (hsf.trans ball_subset_closedBall) ?_) ?_ · rintro _ ⟨x, -, rfl⟩; exact mem_range_self _ · rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] exact inter_subset_right · refine Subset.trans (inter_subset_inter_left _ f.closedBall_subset) ?_ rw [(extChartAt I c).image_eq_target_inter_inv_preimage hse] #align smooth_bump_function.image_eq_inter_preimage_of_subset_support SmoothBumpFunction.image_eq_inter_preimage_of_subset_support theorem mem_Icc : f x ∈ Icc (0 : ℝ) 1 := by have : f x = 0 ∨ f x = _ := indicator_eq_zero_or_self _ _ _ cases' this with h h <;> rw [h] exacts [left_mem_Icc.2 zero_le_one, ⟨f.nonneg, f.le_one⟩] #align smooth_bump_function.mem_Icc SmoothBumpFunction.mem_Icc theorem nonneg : 0 ≤ f x := f.mem_Icc.1 #align smooth_bump_function.nonneg SmoothBumpFunction.nonneg theorem le_one : f x ≤ 1 := f.mem_Icc.2 #align smooth_bump_function.le_one SmoothBumpFunction.le_one theorem eventuallyEq_one_of_dist_lt (hs : x ∈ (chartAt H c).source) (hd : dist (extChartAt I c x) (extChartAt I c c) < f.rIn) : f =ᶠ[𝓝 x] 1 := by filter_upwards [IsOpen.mem_nhds (isOpen_extChartAt_preimage I c isOpen_ball) ⟨hs, hd⟩] rintro z ⟨hzs, hzd⟩ exact f.one_of_dist_le hzs <| le_of_lt hzd #align smooth_bump_function.eventually_eq_one_of_dist_lt SmoothBumpFunction.eventuallyEq_one_of_dist_lt theorem eventuallyEq_one : f =ᶠ[𝓝 c] 1 := f.eventuallyEq_one_of_dist_lt (mem_chart_source _ _) <| by rw [dist_self]; exact f.rIn_pos #align smooth_bump_function.eventually_eq_one SmoothBumpFunction.eventuallyEq_one @[simp] theorem eq_one : f c = 1 := f.eventuallyEq_one.eq_of_nhds #align smooth_bump_function.eq_one SmoothBumpFunction.eq_one theorem support_mem_nhds : support f ∈ 𝓝 c := f.eventuallyEq_one.mono fun x hx => by rw [hx]; exact one_ne_zero #align smooth_bump_function.support_mem_nhds SmoothBumpFunction.support_mem_nhds theorem tsupport_mem_nhds : tsupport f ∈ 𝓝 c := mem_of_superset f.support_mem_nhds subset_closure #align smooth_bump_function.tsupport_mem_nhds SmoothBumpFunction.tsupport_mem_nhds theorem c_mem_support : c ∈ support f := mem_of_mem_nhds f.support_mem_nhds #align smooth_bump_function.c_mem_support SmoothBumpFunction.c_mem_support theorem nonempty_support : (support f).Nonempty := ⟨c, f.c_mem_support⟩ #align smooth_bump_function.nonempty_support SmoothBumpFunction.nonempty_support theorem isCompact_symm_image_closedBall : IsCompact ((extChartAt I c).symm '' (closedBall (extChartAt I c c) f.rOut ∩ range I)) := ((isCompact_closedBall _ _).inter_right I.isClosed_range).image_of_continuousOn <| (continuousOn_extChartAt_symm _ _).mono f.closedBall_subset #align smooth_bump_function.is_compact_symm_image_closed_ball SmoothBumpFunction.isCompact_symm_image_closedBall theorem nhdsWithin_range_basis : (𝓝[range I] extChartAt I c c).HasBasis (fun _ : SmoothBumpFunction I c => True) fun f => closedBall (extChartAt I c c) f.rOut ∩ range I := by refine ((nhdsWithin_hasBasis nhds_basis_closedBall _).restrict_subset (extChartAt_target_mem_nhdsWithin _ _)).to_hasBasis' ?_ ?_ · rintro R ⟨hR0, hsub⟩ exact ⟨⟨⟨R / 2, R, half_pos hR0, half_lt_self hR0⟩, hsub⟩, trivial, Subset.rfl⟩ · exact fun f _ => inter_mem (mem_nhdsWithin_of_mem_nhds <| closedBall_mem_nhds _ f.rOut_pos) self_mem_nhdsWithin #align smooth_bump_function.nhds_within_range_basis SmoothBumpFunction.nhdsWithin_range_basis theorem isClosed_image_of_isClosed {s : Set M} (hsc : IsClosed s) (hs : s ⊆ support f) : IsClosed (extChartAt I c '' s) := by rw [f.image_eq_inter_preimage_of_subset_support hs] refine ContinuousOn.preimage_isClosed_of_isClosed ((continuousOn_extChartAt_symm _ _).mono f.closedBall_subset) ?_ hsc exact IsClosed.inter isClosed_ball I.isClosed_range #align smooth_bump_function.is_closed_image_of_is_closed SmoothBumpFunction.isClosed_image_of_isClosed theorem exists_r_pos_lt_subset_ball {s : Set M} (hsc : IsClosed s) (hs : s ⊆ support f) : ∃ r ∈ Ioo 0 f.rOut, s ⊆ (chartAt H c).source ∩ extChartAt I c ⁻¹' ball (extChartAt I c c) r := by set e := extChartAt I c have : IsClosed (e '' s) := f.isClosed_image_of_isClosed hsc hs rw [support_eq_inter_preimage, subset_inter_iff, ← image_subset_iff] at hs rcases exists_pos_lt_subset_ball f.rOut_pos this hs.2 with ⟨r, hrR, hr⟩ exact ⟨r, hrR, subset_inter hs.1 (image_subset_iff.1 hr)⟩ #align smooth_bump_function.exists_r_pos_lt_subset_ball SmoothBumpFunction.exists_r_pos_lt_subset_ball @[simps rOut rIn] def updateRIn (r : ℝ) (hr : r ∈ Ioo 0 f.rOut) : SmoothBumpFunction I c := ⟨⟨r, f.rOut, hr.1, hr.2⟩, f.closedBall_subset⟩ #align smooth_bump_function.update_r SmoothBumpFunction.updateRIn set_option linter.uppercaseLean3 false in #align smooth_bump_function.update_r_R SmoothBumpFunction.updateRIn_rOut #align smooth_bump_function.update_r_r SmoothBumpFunction.updateRIn_rIn @[simp]
Mathlib/Geometry/Manifold/BumpFunction.lean
246
248
theorem support_updateRIn {r : ℝ} (hr : r ∈ Ioo 0 f.rOut) : support (f.updateRIn r hr) = support f := by
simp only [support_eq_inter_preimage, updateRIn_rOut]
import Mathlib.RepresentationTheory.FdRep import Mathlib.LinearAlgebra.Trace import Mathlib.RepresentationTheory.Invariants #align_import representation_theory.character from "leanprover-community/mathlib"@"55b3f8206b8596db8bb1804d8a92814a0b6670c9" noncomputable section universe u open CategoryTheory LinearMap CategoryTheory.MonoidalCategory Representation FiniteDimensional variable {k : Type u} [Field k] namespace FdRep set_option linter.uppercaseLean3 false -- `FdRep` section Monoid variable {G : Type u} [Monoid G] def character (V : FdRep k G) (g : G) := LinearMap.trace k V (V.ρ g) #align fdRep.character FdRep.character
Mathlib/RepresentationTheory/Character.lean
54
55
theorem char_mul_comm (V : FdRep k G) (g : G) (h : G) : V.character (h * g) = V.character (g * h) := by
simp only [trace_mul_comm, character, map_mul]
import Mathlib.Order.Filter.SmallSets import Mathlib.Tactic.Monotonicity import Mathlib.Topology.Compactness.Compact import Mathlib.Topology.NhdsSet import Mathlib.Algebra.Group.Defs #align_import topology.uniform_space.basic from "leanprover-community/mathlib"@"195fcd60ff2bfe392543bceb0ec2adcdb472db4c" open Set Filter Topology universe u v ua ub uc ud variable {α : Type ua} {β : Type ub} {γ : Type uc} {δ : Type ud} {ι : Sort*} def idRel {α : Type*} := { p : α × α | p.1 = p.2 } #align id_rel idRel @[simp] theorem mem_idRel {a b : α} : (a, b) ∈ @idRel α ↔ a = b := Iff.rfl #align mem_id_rel mem_idRel @[simp] theorem idRel_subset {s : Set (α × α)} : idRel ⊆ s ↔ ∀ a, (a, a) ∈ s := by simp [subset_def] #align id_rel_subset idRel_subset def compRel (r₁ r₂ : Set (α × α)) := { p : α × α | ∃ z : α, (p.1, z) ∈ r₁ ∧ (z, p.2) ∈ r₂ } #align comp_rel compRel @[inherit_doc] scoped[Uniformity] infixl:62 " ○ " => compRel open Uniformity @[simp] theorem mem_compRel {α : Type u} {r₁ r₂ : Set (α × α)} {x y : α} : (x, y) ∈ r₁ ○ r₂ ↔ ∃ z, (x, z) ∈ r₁ ∧ (z, y) ∈ r₂ := Iff.rfl #align mem_comp_rel mem_compRel @[simp] theorem swap_idRel : Prod.swap '' idRel = @idRel α := Set.ext fun ⟨a, b⟩ => by simpa [image_swap_eq_preimage_swap] using eq_comm #align swap_id_rel swap_idRel theorem Monotone.compRel [Preorder β] {f g : β → Set (α × α)} (hf : Monotone f) (hg : Monotone g) : Monotone fun x => f x ○ g x := fun _ _ h _ ⟨z, h₁, h₂⟩ => ⟨z, hf h h₁, hg h h₂⟩ #align monotone.comp_rel Monotone.compRel @[mono] theorem compRel_mono {f g h k : Set (α × α)} (h₁ : f ⊆ h) (h₂ : g ⊆ k) : f ○ g ⊆ h ○ k := fun _ ⟨z, h, h'⟩ => ⟨z, h₁ h, h₂ h'⟩ #align comp_rel_mono compRel_mono theorem prod_mk_mem_compRel {a b c : α} {s t : Set (α × α)} (h₁ : (a, c) ∈ s) (h₂ : (c, b) ∈ t) : (a, b) ∈ s ○ t := ⟨c, h₁, h₂⟩ #align prod_mk_mem_comp_rel prod_mk_mem_compRel @[simp] theorem id_compRel {r : Set (α × α)} : idRel ○ r = r := Set.ext fun ⟨a, b⟩ => by simp #align id_comp_rel id_compRel theorem compRel_assoc {r s t : Set (α × α)} : r ○ s ○ t = r ○ (s ○ t) := by ext ⟨a, b⟩; simp only [mem_compRel]; tauto #align comp_rel_assoc compRel_assoc theorem left_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ t) : s ⊆ s ○ t := fun ⟨_x, y⟩ xy_in => ⟨y, xy_in, h <| rfl⟩ #align left_subset_comp_rel left_subset_compRel theorem right_subset_compRel {s t : Set (α × α)} (h : idRel ⊆ s) : t ⊆ s ○ t := fun ⟨x, _y⟩ xy_in => ⟨x, h <| rfl, xy_in⟩ #align right_subset_comp_rel right_subset_compRel theorem subset_comp_self {s : Set (α × α)} (h : idRel ⊆ s) : s ⊆ s ○ s := left_subset_compRel h #align subset_comp_self subset_comp_self theorem subset_iterate_compRel {s t : Set (α × α)} (h : idRel ⊆ s) (n : ℕ) : t ⊆ (s ○ ·)^[n] t := by induction' n with n ihn generalizing t exacts [Subset.rfl, (right_subset_compRel h).trans ihn] #align subset_iterate_comp_rel subset_iterate_compRel def SymmetricRel (V : Set (α × α)) : Prop := Prod.swap ⁻¹' V = V #align symmetric_rel SymmetricRel def symmetrizeRel (V : Set (α × α)) : Set (α × α) := V ∩ Prod.swap ⁻¹' V #align symmetrize_rel symmetrizeRel theorem symmetric_symmetrizeRel (V : Set (α × α)) : SymmetricRel (symmetrizeRel V) := by simp [SymmetricRel, symmetrizeRel, preimage_inter, inter_comm, ← preimage_comp] #align symmetric_symmetrize_rel symmetric_symmetrizeRel theorem symmetrizeRel_subset_self (V : Set (α × α)) : symmetrizeRel V ⊆ V := sep_subset _ _ #align symmetrize_rel_subset_self symmetrizeRel_subset_self @[mono] theorem symmetrize_mono {V W : Set (α × α)} (h : V ⊆ W) : symmetrizeRel V ⊆ symmetrizeRel W := inter_subset_inter h <| preimage_mono h #align symmetrize_mono symmetrize_mono theorem SymmetricRel.mk_mem_comm {V : Set (α × α)} (hV : SymmetricRel V) {x y : α} : (x, y) ∈ V ↔ (y, x) ∈ V := Set.ext_iff.1 hV (y, x) #align symmetric_rel.mk_mem_comm SymmetricRel.mk_mem_comm theorem SymmetricRel.eq {U : Set (α × α)} (hU : SymmetricRel U) : Prod.swap ⁻¹' U = U := hU #align symmetric_rel.eq SymmetricRel.eq theorem SymmetricRel.inter {U V : Set (α × α)} (hU : SymmetricRel U) (hV : SymmetricRel V) : SymmetricRel (U ∩ V) := by rw [SymmetricRel, preimage_inter, hU.eq, hV.eq] #align symmetric_rel.inter SymmetricRel.inter structure UniformSpace.Core (α : Type u) where uniformity : Filter (α × α) refl : 𝓟 idRel ≤ uniformity symm : Tendsto Prod.swap uniformity uniformity comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity #align uniform_space.core UniformSpace.Core protected theorem UniformSpace.Core.comp_mem_uniformity_sets {c : Core α} {s : Set (α × α)} (hs : s ∈ c.uniformity) : ∃ t ∈ c.uniformity, t ○ t ⊆ s := (mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| c.comp hs def UniformSpace.Core.mk' {α : Type u} (U : Filter (α × α)) (refl : ∀ r ∈ U, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ U, Prod.swap ⁻¹' r ∈ U) (comp : ∀ r ∈ U, ∃ t ∈ U, t ○ t ⊆ r) : UniformSpace.Core α := ⟨U, fun _r ru => idRel_subset.2 (refl _ ru), symm, fun _r ru => let ⟨_s, hs, hsr⟩ := comp _ ru mem_of_superset (mem_lift' hs) hsr⟩ #align uniform_space.core.mk' UniformSpace.Core.mk' def UniformSpace.Core.mkOfBasis {α : Type u} (B : FilterBasis (α × α)) (refl : ∀ r ∈ B, ∀ (x), (x, x) ∈ r) (symm : ∀ r ∈ B, ∃ t ∈ B, t ⊆ Prod.swap ⁻¹' r) (comp : ∀ r ∈ B, ∃ t ∈ B, t ○ t ⊆ r) : UniformSpace.Core α where uniformity := B.filter refl := B.hasBasis.ge_iff.mpr fun _r ru => idRel_subset.2 <| refl _ ru symm := (B.hasBasis.tendsto_iff B.hasBasis).mpr symm comp := (HasBasis.le_basis_iff (B.hasBasis.lift' (monotone_id.compRel monotone_id)) B.hasBasis).2 comp #align uniform_space.core.mk_of_basis UniformSpace.Core.mkOfBasis def UniformSpace.Core.toTopologicalSpace {α : Type u} (u : UniformSpace.Core α) : TopologicalSpace α := .mkOfNhds fun x ↦ .comap (Prod.mk x) u.uniformity #align uniform_space.core.to_topological_space UniformSpace.Core.toTopologicalSpace theorem UniformSpace.Core.ext : ∀ {u₁ u₂ : UniformSpace.Core α}, u₁.uniformity = u₂.uniformity → u₁ = u₂ | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl #align uniform_space.core_eq UniformSpace.Core.ext theorem UniformSpace.Core.nhds_toTopologicalSpace {α : Type u} (u : Core α) (x : α) : @nhds α u.toTopologicalSpace x = comap (Prod.mk x) u.uniformity := by apply TopologicalSpace.nhds_mkOfNhds_of_hasBasis (fun _ ↦ (basis_sets _).comap _) · exact fun a U hU ↦ u.refl hU rfl · intro a U hU rcases u.comp_mem_uniformity_sets hU with ⟨V, hV, hVU⟩ filter_upwards [preimage_mem_comap hV] with b hb filter_upwards [preimage_mem_comap hV] with c hc exact hVU ⟨b, hb, hc⟩ -- the topological structure is embedded in the uniform structure -- to avoid instance diamond issues. See Note [forgetful inheritance]. class UniformSpace (α : Type u) extends TopologicalSpace α where protected uniformity : Filter (α × α) protected symm : Tendsto Prod.swap uniformity uniformity protected comp : (uniformity.lift' fun s => s ○ s) ≤ uniformity protected nhds_eq_comap_uniformity (x : α) : 𝓝 x = comap (Prod.mk x) uniformity #align uniform_space UniformSpace #noalign uniform_space.mk' -- Can't be a `match_pattern`, so not useful anymore def uniformity (α : Type u) [UniformSpace α] : Filter (α × α) := @UniformSpace.uniformity α _ #align uniformity uniformity scoped[Uniformity] notation "𝓤[" u "]" => @uniformity _ u @[inherit_doc] -- Porting note (#11215): TODO: should we drop the `uniformity` def? scoped[Uniformity] notation "𝓤" => uniformity abbrev UniformSpace.ofCoreEq {α : Type u} (u : UniformSpace.Core α) (t : TopologicalSpace α) (h : t = u.toTopologicalSpace) : UniformSpace α where __ := u toTopologicalSpace := t nhds_eq_comap_uniformity x := by rw [h, u.nhds_toTopologicalSpace] #align uniform_space.of_core_eq UniformSpace.ofCoreEq abbrev UniformSpace.ofCore {α : Type u} (u : UniformSpace.Core α) : UniformSpace α := .ofCoreEq u _ rfl #align uniform_space.of_core UniformSpace.ofCore abbrev UniformSpace.toCore (u : UniformSpace α) : UniformSpace.Core α where __ := u refl := by rintro U hU ⟨x, y⟩ (rfl : x = y) have : Prod.mk x ⁻¹' U ∈ 𝓝 x := by rw [UniformSpace.nhds_eq_comap_uniformity] exact preimage_mem_comap hU convert mem_of_mem_nhds this theorem UniformSpace.toCore_toTopologicalSpace (u : UniformSpace α) : u.toCore.toTopologicalSpace = u.toTopologicalSpace := TopologicalSpace.ext_nhds fun a ↦ by rw [u.nhds_eq_comap_uniformity, u.toCore.nhds_toTopologicalSpace] #align uniform_space.to_core_to_topological_space UniformSpace.toCore_toTopologicalSpace @[deprecated UniformSpace.mk (since := "2024-03-20")] def UniformSpace.ofNhdsEqComap (u : UniformSpace.Core α) (_t : TopologicalSpace α) (h : ∀ x, 𝓝 x = u.uniformity.comap (Prod.mk x)) : UniformSpace α where __ := u nhds_eq_comap_uniformity := h @[ext] protected theorem UniformSpace.ext {u₁ u₂ : UniformSpace α} (h : 𝓤[u₁] = 𝓤[u₂]) : u₁ = u₂ := by have : u₁.toTopologicalSpace = u₂.toTopologicalSpace := TopologicalSpace.ext_nhds fun x ↦ by rw [u₁.nhds_eq_comap_uniformity, u₂.nhds_eq_comap_uniformity] exact congr_arg (comap _) h cases u₁; cases u₂; congr #align uniform_space_eq UniformSpace.ext protected theorem UniformSpace.ext_iff {u₁ u₂ : UniformSpace α} : u₁ = u₂ ↔ ∀ s, s ∈ 𝓤[u₁] ↔ s ∈ 𝓤[u₂] := ⟨fun h _ => h ▸ Iff.rfl, fun h => by ext; exact h _⟩ theorem UniformSpace.ofCoreEq_toCore (u : UniformSpace α) (t : TopologicalSpace α) (h : t = u.toCore.toTopologicalSpace) : .ofCoreEq u.toCore t h = u := UniformSpace.ext rfl #align uniform_space.of_core_eq_to_core UniformSpace.ofCoreEq_toCore abbrev UniformSpace.replaceTopology {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α) (h : i = u.toTopologicalSpace) : UniformSpace α where __ := u toTopologicalSpace := i nhds_eq_comap_uniformity x := by rw [h, u.nhds_eq_comap_uniformity] #align uniform_space.replace_topology UniformSpace.replaceTopology theorem UniformSpace.replaceTopology_eq {α : Type*} [i : TopologicalSpace α] (u : UniformSpace α) (h : i = u.toTopologicalSpace) : u.replaceTopology h = u := UniformSpace.ext rfl #align uniform_space.replace_topology_eq UniformSpace.replaceTopology_eq -- Porting note: rfc: use `UniformSpace.Core.mkOfBasis`? This will change defeq here and there def UniformSpace.ofFun {α : Type u} {β : Type v} [OrderedAddCommMonoid β] (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x) (triangle : ∀ x y z, d x z ≤ d x y + d y z) (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) : UniformSpace α := .ofCore { uniformity := ⨅ r > 0, 𝓟 { x | d x.1 x.2 < r } refl := le_iInf₂ fun r hr => principal_mono.2 <| idRel_subset.2 fun x => by simpa [refl] symm := tendsto_iInf_iInf fun r => tendsto_iInf_iInf fun _ => tendsto_principal_principal.2 fun x hx => by rwa [mem_setOf, symm] comp := le_iInf₂ fun r hr => let ⟨δ, h0, hδr⟩ := half r hr; le_principal_iff.2 <| mem_of_superset (mem_lift' <| mem_iInf_of_mem δ <| mem_iInf_of_mem h0 <| mem_principal_self _) fun (x, z) ⟨y, h₁, h₂⟩ => (triangle _ _ _).trans_lt (hδr _ h₁ _ h₂) } #align uniform_space.of_fun UniformSpace.ofFun theorem UniformSpace.hasBasis_ofFun {α : Type u} {β : Type v} [LinearOrderedAddCommMonoid β] (h₀ : ∃ x : β, 0 < x) (d : α → α → β) (refl : ∀ x, d x x = 0) (symm : ∀ x y, d x y = d y x) (triangle : ∀ x y z, d x z ≤ d x y + d y z) (half : ∀ ε > (0 : β), ∃ δ > (0 : β), ∀ x < δ, ∀ y < δ, x + y < ε) : 𝓤[.ofFun d refl symm triangle half].HasBasis ((0 : β) < ·) (fun ε => { x | d x.1 x.2 < ε }) := hasBasis_biInf_principal' (fun ε₁ h₁ ε₂ h₂ => ⟨min ε₁ ε₂, lt_min h₁ h₂, fun _x hx => lt_of_lt_of_le hx (min_le_left _ _), fun _x hx => lt_of_lt_of_le hx (min_le_right _ _)⟩) h₀ #align uniform_space.has_basis_of_fun UniformSpace.hasBasis_ofFun section UniformSpace variable [UniformSpace α] theorem nhds_eq_comap_uniformity {x : α} : 𝓝 x = (𝓤 α).comap (Prod.mk x) := UniformSpace.nhds_eq_comap_uniformity x #align nhds_eq_comap_uniformity nhds_eq_comap_uniformity theorem isOpen_uniformity {s : Set α} : IsOpen s ↔ ∀ x ∈ s, { p : α × α | p.1 = x → p.2 ∈ s } ∈ 𝓤 α := by simp only [isOpen_iff_mem_nhds, nhds_eq_comap_uniformity, mem_comap_prod_mk] #align is_open_uniformity isOpen_uniformity theorem refl_le_uniformity : 𝓟 idRel ≤ 𝓤 α := (@UniformSpace.toCore α _).refl #align refl_le_uniformity refl_le_uniformity instance uniformity.neBot [Nonempty α] : NeBot (𝓤 α) := diagonal_nonempty.principal_neBot.mono refl_le_uniformity #align uniformity.ne_bot uniformity.neBot theorem refl_mem_uniformity {x : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) : (x, x) ∈ s := refl_le_uniformity h rfl #align refl_mem_uniformity refl_mem_uniformity theorem mem_uniformity_of_eq {x y : α} {s : Set (α × α)} (h : s ∈ 𝓤 α) (hx : x = y) : (x, y) ∈ s := refl_le_uniformity h hx #align mem_uniformity_of_eq mem_uniformity_of_eq theorem symm_le_uniformity : map (@Prod.swap α α) (𝓤 _) ≤ 𝓤 _ := UniformSpace.symm #align symm_le_uniformity symm_le_uniformity theorem comp_le_uniformity : ((𝓤 α).lift' fun s : Set (α × α) => s ○ s) ≤ 𝓤 α := UniformSpace.comp #align comp_le_uniformity comp_le_uniformity theorem lift'_comp_uniformity : ((𝓤 α).lift' fun s : Set (α × α) => s ○ s) = 𝓤 α := comp_le_uniformity.antisymm <| le_lift'.2 fun _s hs ↦ mem_of_superset hs <| subset_comp_self <| idRel_subset.2 fun _ ↦ refl_mem_uniformity hs theorem tendsto_swap_uniformity : Tendsto (@Prod.swap α α) (𝓤 α) (𝓤 α) := symm_le_uniformity #align tendsto_swap_uniformity tendsto_swap_uniformity theorem comp_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, t ○ t ⊆ s := (mem_lift'_sets <| monotone_id.compRel monotone_id).mp <| comp_le_uniformity hs #align comp_mem_uniformity_sets comp_mem_uniformity_sets theorem eventually_uniformity_iterate_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) (n : ℕ) : ∀ᶠ t in (𝓤 α).smallSets, (t ○ ·)^[n] t ⊆ s := by suffices ∀ᶠ t in (𝓤 α).smallSets, t ⊆ s ∧ (t ○ ·)^[n] t ⊆ s from (eventually_and.1 this).2 induction' n with n ihn generalizing s · simpa rcases comp_mem_uniformity_sets hs with ⟨t, htU, hts⟩ refine (ihn htU).mono fun U hU => ?_ rw [Function.iterate_succ_apply'] exact ⟨hU.1.trans <| (subset_comp_self <| refl_le_uniformity htU).trans hts, (compRel_mono hU.1 hU.2).trans hts⟩ #align eventually_uniformity_iterate_comp_subset eventually_uniformity_iterate_comp_subset theorem eventually_uniformity_comp_subset {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∀ᶠ t in (𝓤 α).smallSets, t ○ t ⊆ s := eventually_uniformity_iterate_comp_subset hs 1 #align eventually_uniformity_comp_subset eventually_uniformity_comp_subset theorem Filter.Tendsto.uniformity_trans {l : Filter β} {f₁ f₂ f₃ : β → α} (h₁₂ : Tendsto (fun x => (f₁ x, f₂ x)) l (𝓤 α)) (h₂₃ : Tendsto (fun x => (f₂ x, f₃ x)) l (𝓤 α)) : Tendsto (fun x => (f₁ x, f₃ x)) l (𝓤 α) := by refine le_trans (le_lift'.2 fun s hs => mem_map.2 ?_) comp_le_uniformity filter_upwards [mem_map.1 (h₁₂ hs), mem_map.1 (h₂₃ hs)] with x hx₁₂ hx₂₃ using ⟨_, hx₁₂, hx₂₃⟩ #align filter.tendsto.uniformity_trans Filter.Tendsto.uniformity_trans theorem Filter.Tendsto.uniformity_symm {l : Filter β} {f : β → α × α} (h : Tendsto f l (𝓤 α)) : Tendsto (fun x => ((f x).2, (f x).1)) l (𝓤 α) := tendsto_swap_uniformity.comp h #align filter.tendsto.uniformity_symm Filter.Tendsto.uniformity_symm theorem tendsto_diag_uniformity (f : β → α) (l : Filter β) : Tendsto (fun x => (f x, f x)) l (𝓤 α) := fun _s hs => mem_map.2 <| univ_mem' fun _ => refl_mem_uniformity hs #align tendsto_diag_uniformity tendsto_diag_uniformity theorem tendsto_const_uniformity {a : α} {f : Filter β} : Tendsto (fun _ => (a, a)) f (𝓤 α) := tendsto_diag_uniformity (fun _ => a) f #align tendsto_const_uniformity tendsto_const_uniformity theorem symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, (∀ a b, (a, b) ∈ t → (b, a) ∈ t) ∧ t ⊆ s := have : preimage Prod.swap s ∈ 𝓤 α := symm_le_uniformity hs ⟨s ∩ preimage Prod.swap s, inter_mem hs this, fun _ _ ⟨h₁, h₂⟩ => ⟨h₂, h₁⟩, inter_subset_left⟩ #align symm_of_uniformity symm_of_uniformity theorem comp_symm_of_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, (∀ {a b}, (a, b) ∈ t → (b, a) ∈ t) ∧ t ○ t ⊆ s := let ⟨_t, ht₁, ht₂⟩ := comp_mem_uniformity_sets hs let ⟨t', ht', ht'₁, ht'₂⟩ := symm_of_uniformity ht₁ ⟨t', ht', ht'₁ _ _, Subset.trans (monotone_id.compRel monotone_id ht'₂) ht₂⟩ #align comp_symm_of_uniformity comp_symm_of_uniformity theorem uniformity_le_symm : 𝓤 α ≤ @Prod.swap α α <$> 𝓤 α := by rw [map_swap_eq_comap_swap]; exact tendsto_swap_uniformity.le_comap #align uniformity_le_symm uniformity_le_symm theorem uniformity_eq_symm : 𝓤 α = @Prod.swap α α <$> 𝓤 α := le_antisymm uniformity_le_symm symm_le_uniformity #align uniformity_eq_symm uniformity_eq_symm @[simp] theorem comap_swap_uniformity : comap (@Prod.swap α α) (𝓤 α) = 𝓤 α := (congr_arg _ uniformity_eq_symm).trans <| comap_map Prod.swap_injective #align comap_swap_uniformity comap_swap_uniformity theorem symmetrize_mem_uniformity {V : Set (α × α)} (h : V ∈ 𝓤 α) : symmetrizeRel V ∈ 𝓤 α := by apply (𝓤 α).inter_sets h rw [← image_swap_eq_preimage_swap, uniformity_eq_symm] exact image_mem_map h #align symmetrize_mem_uniformity symmetrize_mem_uniformity theorem UniformSpace.hasBasis_symmetric : (𝓤 α).HasBasis (fun s : Set (α × α) => s ∈ 𝓤 α ∧ SymmetricRel s) id := hasBasis_self.2 fun t t_in => ⟨symmetrizeRel t, symmetrize_mem_uniformity t_in, symmetric_symmetrizeRel t, symmetrizeRel_subset_self t⟩ #align uniform_space.has_basis_symmetric UniformSpace.hasBasis_symmetric theorem uniformity_lift_le_swap {g : Set (α × α) → Filter β} {f : Filter β} (hg : Monotone g) (h : ((𝓤 α).lift fun s => g (preimage Prod.swap s)) ≤ f) : (𝓤 α).lift g ≤ f := calc (𝓤 α).lift g ≤ (Filter.map (@Prod.swap α α) <| 𝓤 α).lift g := lift_mono uniformity_le_symm le_rfl _ ≤ _ := by rw [map_lift_eq2 hg, image_swap_eq_preimage_swap]; exact h #align uniformity_lift_le_swap uniformity_lift_le_swap theorem uniformity_lift_le_comp {f : Set (α × α) → Filter β} (h : Monotone f) : ((𝓤 α).lift fun s => f (s ○ s)) ≤ (𝓤 α).lift f := calc ((𝓤 α).lift fun s => f (s ○ s)) = ((𝓤 α).lift' fun s : Set (α × α) => s ○ s).lift f := by rw [lift_lift'_assoc] · exact monotone_id.compRel monotone_id · exact h _ ≤ (𝓤 α).lift f := lift_mono comp_le_uniformity le_rfl #align uniformity_lift_le_comp uniformity_lift_le_comp -- Porting note (#10756): new lemma theorem comp3_mem_uniformity {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, t ○ (t ○ t) ⊆ s := let ⟨_t', ht', ht's⟩ := comp_mem_uniformity_sets hs let ⟨t, ht, htt'⟩ := comp_mem_uniformity_sets ht' ⟨t, ht, (compRel_mono ((subset_comp_self (refl_le_uniformity ht)).trans htt') htt').trans ht's⟩ theorem comp_le_uniformity3 : ((𝓤 α).lift' fun s : Set (α × α) => s ○ (s ○ s)) ≤ 𝓤 α := fun _ h => let ⟨_t, htU, ht⟩ := comp3_mem_uniformity h mem_of_superset (mem_lift' htU) ht #align comp_le_uniformity3 comp_le_uniformity3 theorem comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ⊆ s := by obtain ⟨w, w_in, w_sub⟩ : ∃ w ∈ 𝓤 α, w ○ w ⊆ s := comp_mem_uniformity_sets hs use symmetrizeRel w, symmetrize_mem_uniformity w_in, symmetric_symmetrizeRel w have : symmetrizeRel w ⊆ w := symmetrizeRel_subset_self w calc symmetrizeRel w ○ symmetrizeRel w _ ⊆ w ○ w := by mono _ ⊆ s := w_sub #align comp_symm_mem_uniformity_sets comp_symm_mem_uniformity_sets theorem subset_comp_self_of_mem_uniformity {s : Set (α × α)} (h : s ∈ 𝓤 α) : s ⊆ s ○ s := subset_comp_self (refl_le_uniformity h) #align subset_comp_self_of_mem_uniformity subset_comp_self_of_mem_uniformity theorem comp_comp_symm_mem_uniformity_sets {s : Set (α × α)} (hs : s ∈ 𝓤 α) : ∃ t ∈ 𝓤 α, SymmetricRel t ∧ t ○ t ○ t ⊆ s := by rcases comp_symm_mem_uniformity_sets hs with ⟨w, w_in, _, w_sub⟩ rcases comp_symm_mem_uniformity_sets w_in with ⟨t, t_in, t_symm, t_sub⟩ use t, t_in, t_symm have : t ⊆ t ○ t := subset_comp_self_of_mem_uniformity t_in -- Porting note: Needed the following `have`s to make `mono` work have ht := Subset.refl t have hw := Subset.refl w calc t ○ t ○ t ⊆ w ○ t := by mono _ ⊆ w ○ (t ○ t) := by mono _ ⊆ w ○ w := by mono _ ⊆ s := w_sub #align comp_comp_symm_mem_uniformity_sets comp_comp_symm_mem_uniformity_sets def UniformSpace.ball (x : β) (V : Set (β × β)) : Set β := Prod.mk x ⁻¹' V #align uniform_space.ball UniformSpace.ball open UniformSpace (ball) theorem UniformSpace.mem_ball_self (x : α) {V : Set (α × α)} (hV : V ∈ 𝓤 α) : x ∈ ball x V := refl_mem_uniformity hV #align uniform_space.mem_ball_self UniformSpace.mem_ball_self theorem mem_ball_comp {V W : Set (β × β)} {x y z} (h : y ∈ ball x V) (h' : z ∈ ball y W) : z ∈ ball x (V ○ W) := prod_mk_mem_compRel h h' #align mem_ball_comp mem_ball_comp theorem ball_subset_of_comp_subset {V W : Set (β × β)} {x y} (h : x ∈ ball y W) (h' : W ○ W ⊆ V) : ball x W ⊆ ball y V := fun _z z_in => h' (mem_ball_comp h z_in) #align ball_subset_of_comp_subset ball_subset_of_comp_subset theorem ball_mono {V W : Set (β × β)} (h : V ⊆ W) (x : β) : ball x V ⊆ ball x W := preimage_mono h #align ball_mono ball_mono theorem ball_inter (x : β) (V W : Set (β × β)) : ball x (V ∩ W) = ball x V ∩ ball x W := preimage_inter #align ball_inter ball_inter theorem ball_inter_left (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x V := ball_mono inter_subset_left x #align ball_inter_left ball_inter_left theorem ball_inter_right (x : β) (V W : Set (β × β)) : ball x (V ∩ W) ⊆ ball x W := ball_mono inter_subset_right x #align ball_inter_right ball_inter_right theorem mem_ball_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x y} : x ∈ ball y V ↔ y ∈ ball x V := show (x, y) ∈ Prod.swap ⁻¹' V ↔ (x, y) ∈ V by unfold SymmetricRel at hV rw [hV] #align mem_ball_symmetry mem_ball_symmetry theorem ball_eq_of_symmetry {V : Set (β × β)} (hV : SymmetricRel V) {x} : ball x V = { y | (y, x) ∈ V } := by ext y rw [mem_ball_symmetry hV] exact Iff.rfl #align ball_eq_of_symmetry ball_eq_of_symmetry theorem mem_comp_of_mem_ball {V W : Set (β × β)} {x y z : β} (hV : SymmetricRel V) (hx : x ∈ ball z V) (hy : y ∈ ball z W) : (x, y) ∈ V ○ W := by rw [mem_ball_symmetry hV] at hx exact ⟨z, hx, hy⟩ #align mem_comp_of_mem_ball mem_comp_of_mem_ball theorem UniformSpace.isOpen_ball (x : α) {V : Set (α × α)} (hV : IsOpen V) : IsOpen (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id #align uniform_space.is_open_ball UniformSpace.isOpen_ball theorem UniformSpace.isClosed_ball (x : α) {V : Set (α × α)} (hV : IsClosed V) : IsClosed (ball x V) := hV.preimage <| continuous_const.prod_mk continuous_id
Mathlib/Topology/UniformSpace/Basic.lean
707
715
theorem mem_comp_comp {V W M : Set (β × β)} (hW' : SymmetricRel W) {p : β × β} : p ∈ V ○ M ○ W ↔ (ball p.1 V ×ˢ ball p.2 W ∩ M).Nonempty := by
cases' p with x y constructor · rintro ⟨z, ⟨w, hpw, hwz⟩, hzy⟩ exact ⟨(w, z), ⟨hpw, by rwa [mem_ball_symmetry hW']⟩, hwz⟩ · rintro ⟨⟨w, z⟩, ⟨w_in, z_in⟩, hwz⟩ rw [mem_ball_symmetry hW'] at z_in exact ⟨z, ⟨w, w_in, hwz⟩, z_in⟩
import Mathlib.Data.Finset.Sort import Mathlib.Data.Fin.VecNotation import Mathlib.Data.Sign import Mathlib.LinearAlgebra.AffineSpace.Combination import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv import Mathlib.LinearAlgebra.Basis.VectorSpace #align_import linear_algebra.affine_space.independent from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0" noncomputable section open Finset Function open scoped Affine section AffineIndependent variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V] variable [AffineSpace V P] {ι : Type*} def AffineIndependent (p : ι → P) : Prop := ∀ (s : Finset ι) (w : ι → k), ∑ i ∈ s, w i = 0 → s.weightedVSub p w = (0 : V) → ∀ i ∈ s, w i = 0 #align affine_independent AffineIndependent theorem affineIndependent_def (p : ι → P) : AffineIndependent k p ↔ ∀ (s : Finset ι) (w : ι → k), ∑ i ∈ s, w i = 0 → s.weightedVSub p w = (0 : V) → ∀ i ∈ s, w i = 0 := Iff.rfl #align affine_independent_def affineIndependent_def theorem affineIndependent_of_subsingleton [Subsingleton ι] (p : ι → P) : AffineIndependent k p := fun _ _ h _ i hi => Fintype.eq_of_subsingleton_of_sum_eq h i hi #align affine_independent_of_subsingleton affineIndependent_of_subsingleton theorem affineIndependent_iff_of_fintype [Fintype ι] (p : ι → P) : AffineIndependent k p ↔ ∀ w : ι → k, ∑ i, w i = 0 → Finset.univ.weightedVSub p w = (0 : V) → ∀ i, w i = 0 := by constructor · exact fun h w hw hs i => h Finset.univ w hw hs i (Finset.mem_univ _) · intro h s w hw hs i hi rw [Finset.weightedVSub_indicator_subset _ _ (Finset.subset_univ s)] at hs rw [← Finset.sum_indicator_subset _ (Finset.subset_univ s)] at hw replace h := h ((↑s : Set ι).indicator w) hw hs i simpa [hi] using h #align affine_independent_iff_of_fintype affineIndependent_iff_of_fintype theorem affineIndependent_iff_linearIndependent_vsub (p : ι → P) (i1 : ι) : AffineIndependent k p ↔ LinearIndependent k fun i : { x // x ≠ i1 } => (p i -ᵥ p i1 : V) := by classical constructor · intro h rw [linearIndependent_iff'] intro s g hg i hi set f : ι → k := fun x => if hx : x = i1 then -∑ y ∈ s, g y else g ⟨x, hx⟩ with hfdef let s2 : Finset ι := insert i1 (s.map (Embedding.subtype _)) have hfg : ∀ x : { x // x ≠ i1 }, g x = f x := by intro x rw [hfdef] dsimp only erw [dif_neg x.property, Subtype.coe_eta] rw [hfg] have hf : ∑ ι ∈ s2, f ι = 0 := by rw [Finset.sum_insert (Finset.not_mem_map_subtype_of_not_property s (Classical.not_not.2 rfl)), Finset.sum_subtype_map_embedding fun x _ => (hfg x).symm] rw [hfdef] dsimp only rw [dif_pos rfl] exact neg_add_self _ have hs2 : s2.weightedVSub p f = (0 : V) := by set f2 : ι → V := fun x => f x • (p x -ᵥ p i1) with hf2def set g2 : { x // x ≠ i1 } → V := fun x => g x • (p x -ᵥ p i1) have hf2g2 : ∀ x : { x // x ≠ i1 }, f2 x = g2 x := by simp only [g2, hf2def] refine fun x => ?_ rw [hfg] rw [Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero s2 f p hf (p i1), Finset.weightedVSubOfPoint_insert, Finset.weightedVSubOfPoint_apply, Finset.sum_subtype_map_embedding fun x _ => hf2g2 x] exact hg exact h s2 f hf hs2 i (Finset.mem_insert_of_mem (Finset.mem_map.2 ⟨i, hi, rfl⟩)) · intro h rw [linearIndependent_iff'] at h intro s w hw hs i hi rw [Finset.weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero s w p hw (p i1), ← s.weightedVSubOfPoint_erase w p i1, Finset.weightedVSubOfPoint_apply] at hs let f : ι → V := fun i => w i • (p i -ᵥ p i1) have hs2 : (∑ i ∈ (s.erase i1).subtype fun i => i ≠ i1, f i) = 0 := by rw [← hs] convert Finset.sum_subtype_of_mem f fun x => Finset.ne_of_mem_erase have h2 := h ((s.erase i1).subtype fun i => i ≠ i1) (fun x => w x) hs2 simp_rw [Finset.mem_subtype] at h2 have h2b : ∀ i ∈ s, i ≠ i1 → w i = 0 := fun i his hi => h2 ⟨i, hi⟩ (Finset.mem_erase_of_ne_of_mem hi his) exact Finset.eq_zero_of_sum_eq_zero hw h2b i hi #align affine_independent_iff_linear_independent_vsub affineIndependent_iff_linearIndependent_vsub theorem affineIndependent_set_iff_linearIndependent_vsub {s : Set P} {p₁ : P} (hp₁ : p₁ ∈ s) : AffineIndependent k (fun p => p : s → P) ↔ LinearIndependent k (fun v => v : (fun p => (p -ᵥ p₁ : V)) '' (s \ {p₁}) → V) := by rw [affineIndependent_iff_linearIndependent_vsub k (fun p => p : s → P) ⟨p₁, hp₁⟩] constructor · intro h have hv : ∀ v : (fun p => (p -ᵥ p₁ : V)) '' (s \ {p₁}), (v : V) +ᵥ p₁ ∈ s \ {p₁} := fun v => (vsub_left_injective p₁).mem_set_image.1 ((vadd_vsub (v : V) p₁).symm ▸ v.property) let f : (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) → { x : s // x ≠ ⟨p₁, hp₁⟩ } := fun x => ⟨⟨(x : V) +ᵥ p₁, Set.mem_of_mem_diff (hv x)⟩, fun hx => Set.not_mem_of_mem_diff (hv x) (Subtype.ext_iff.1 hx)⟩ convert h.comp f fun x1 x2 hx => Subtype.ext (vadd_right_cancel p₁ (Subtype.ext_iff.1 (Subtype.ext_iff.1 hx))) ext v exact (vadd_vsub (v : V) p₁).symm · intro h let f : { x : s // x ≠ ⟨p₁, hp₁⟩ } → (fun p : P => (p -ᵥ p₁ : V)) '' (s \ {p₁}) := fun x => ⟨((x : s) : P) -ᵥ p₁, ⟨x, ⟨⟨(x : s).property, fun hx => x.property (Subtype.ext hx)⟩, rfl⟩⟩⟩ convert h.comp f fun x1 x2 hx => Subtype.ext (Subtype.ext (vsub_left_cancel (Subtype.ext_iff.1 hx))) #align affine_independent_set_iff_linear_independent_vsub affineIndependent_set_iff_linearIndependent_vsub theorem linearIndependent_set_iff_affineIndependent_vadd_union_singleton {s : Set V} (hs : ∀ v ∈ s, v ≠ (0 : V)) (p₁ : P) : LinearIndependent k (fun v => v : s → V) ↔ AffineIndependent k (fun p => p : ({p₁} ∪ (fun v => v +ᵥ p₁) '' s : Set P) → P) := by rw [affineIndependent_set_iff_linearIndependent_vsub k (Set.mem_union_left _ (Set.mem_singleton p₁))] have h : (fun p => (p -ᵥ p₁ : V)) '' (({p₁} ∪ (fun v => v +ᵥ p₁) '' s) \ {p₁}) = s := by simp_rw [Set.union_diff_left, Set.image_diff (vsub_left_injective p₁), Set.image_image, Set.image_singleton, vsub_self, vadd_vsub, Set.image_id'] exact Set.diff_singleton_eq_self fun h => hs 0 h rfl rw [h] #align linear_independent_set_iff_affine_independent_vadd_union_singleton linearIndependent_set_iff_affineIndependent_vadd_union_singleton theorem affineIndependent_iff_indicator_eq_of_affineCombination_eq (p : ι → P) : AffineIndependent k p ↔ ∀ (s1 s2 : Finset ι) (w1 w2 : ι → k), ∑ i ∈ s1, w1 i = 1 → ∑ i ∈ s2, w2 i = 1 → s1.affineCombination k p w1 = s2.affineCombination k p w2 → Set.indicator (↑s1) w1 = Set.indicator (↑s2) w2 := by classical constructor · intro ha s1 s2 w1 w2 hw1 hw2 heq ext i by_cases hi : i ∈ s1 ∪ s2 · rw [← sub_eq_zero] rw [← Finset.sum_indicator_subset w1 (s1.subset_union_left (s₂:=s2))] at hw1 rw [← Finset.sum_indicator_subset w2 (s1.subset_union_right)] at hw2 have hws : (∑ i ∈ s1 ∪ s2, (Set.indicator (↑s1) w1 - Set.indicator (↑s2) w2) i) = 0 := by simp [hw1, hw2] rw [Finset.affineCombination_indicator_subset w1 p (s1.subset_union_left (s₂:=s2)), Finset.affineCombination_indicator_subset w2 p s1.subset_union_right, ← @vsub_eq_zero_iff_eq V, Finset.affineCombination_vsub] at heq exact ha (s1 ∪ s2) (Set.indicator (↑s1) w1 - Set.indicator (↑s2) w2) hws heq i hi · rw [← Finset.mem_coe, Finset.coe_union] at hi have h₁ : Set.indicator (↑s1) w1 i = 0 := by simp only [Set.indicator, Finset.mem_coe, ite_eq_right_iff] intro h by_contra exact (mt (@Set.mem_union_left _ i ↑s1 ↑s2) hi) h have h₂ : Set.indicator (↑s2) w2 i = 0 := by simp only [Set.indicator, Finset.mem_coe, ite_eq_right_iff] intro h by_contra exact (mt (@Set.mem_union_right _ i ↑s2 ↑s1) hi) h simp [h₁, h₂] · intro ha s w hw hs i0 hi0 let w1 : ι → k := Function.update (Function.const ι 0) i0 1 have hw1 : ∑ i ∈ s, w1 i = 1 := by rw [Finset.sum_update_of_mem hi0] simp only [Finset.sum_const_zero, add_zero, const_apply] have hw1s : s.affineCombination k p w1 = p i0 := s.affineCombination_of_eq_one_of_eq_zero w1 p hi0 (Function.update_same _ _ _) fun _ _ hne => Function.update_noteq hne _ _ let w2 := w + w1 have hw2 : ∑ i ∈ s, w2 i = 1 := by simp_all only [w2, Pi.add_apply, Finset.sum_add_distrib, zero_add] have hw2s : s.affineCombination k p w2 = p i0 := by simp_all only [w2, ← Finset.weightedVSub_vadd_affineCombination, zero_vadd] replace ha := ha s s w2 w1 hw2 hw1 (hw1s.symm ▸ hw2s) have hws : w2 i0 - w1 i0 = 0 := by rw [← Finset.mem_coe] at hi0 rw [← Set.indicator_of_mem hi0 w2, ← Set.indicator_of_mem hi0 w1, ha, sub_self] simpa [w2] using hws #align affine_independent_iff_indicator_eq_of_affine_combination_eq affineIndependent_iff_indicator_eq_of_affineCombination_eq theorem affineIndependent_iff_eq_of_fintype_affineCombination_eq [Fintype ι] (p : ι → P) : AffineIndependent k p ↔ ∀ w1 w2 : ι → k, ∑ i, w1 i = 1 → ∑ i, w2 i = 1 → Finset.univ.affineCombination k p w1 = Finset.univ.affineCombination k p w2 → w1 = w2 := by rw [affineIndependent_iff_indicator_eq_of_affineCombination_eq] constructor · intro h w1 w2 hw1 hw2 hweq simpa only [Set.indicator_univ, Finset.coe_univ] using h _ _ w1 w2 hw1 hw2 hweq · intro h s1 s2 w1 w2 hw1 hw2 hweq have hw1' : (∑ i, (s1 : Set ι).indicator w1 i) = 1 := by rwa [Finset.sum_indicator_subset _ (Finset.subset_univ s1)] have hw2' : (∑ i, (s2 : Set ι).indicator w2 i) = 1 := by rwa [Finset.sum_indicator_subset _ (Finset.subset_univ s2)] rw [Finset.affineCombination_indicator_subset w1 p (Finset.subset_univ s1), Finset.affineCombination_indicator_subset w2 p (Finset.subset_univ s2)] at hweq exact h _ _ hw1' hw2' hweq #align affine_independent_iff_eq_of_fintype_affine_combination_eq affineIndependent_iff_eq_of_fintype_affineCombination_eq variable {k} theorem AffineIndependent.units_lineMap {p : ι → P} (hp : AffineIndependent k p) (j : ι) (w : ι → Units k) : AffineIndependent k fun i => AffineMap.lineMap (p j) (p i) (w i : k) := by rw [affineIndependent_iff_linearIndependent_vsub k _ j] at hp ⊢ simp only [AffineMap.lineMap_vsub_left, AffineMap.coe_const, AffineMap.lineMap_same, const_apply] exact hp.units_smul fun i => w i #align affine_independent.units_line_map AffineIndependent.units_lineMap theorem AffineIndependent.indicator_eq_of_affineCombination_eq {p : ι → P} (ha : AffineIndependent k p) (s₁ s₂ : Finset ι) (w₁ w₂ : ι → k) (hw₁ : ∑ i ∈ s₁, w₁ i = 1) (hw₂ : ∑ i ∈ s₂, w₂ i = 1) (h : s₁.affineCombination k p w₁ = s₂.affineCombination k p w₂) : Set.indicator (↑s₁) w₁ = Set.indicator (↑s₂) w₂ := (affineIndependent_iff_indicator_eq_of_affineCombination_eq k p).1 ha s₁ s₂ w₁ w₂ hw₁ hw₂ h #align affine_independent.indicator_eq_of_affine_combination_eq AffineIndependent.indicator_eq_of_affineCombination_eq protected theorem AffineIndependent.injective [Nontrivial k] {p : ι → P} (ha : AffineIndependent k p) : Function.Injective p := by intro i j hij rw [affineIndependent_iff_linearIndependent_vsub _ _ j] at ha by_contra hij' refine ha.ne_zero ⟨i, hij'⟩ (vsub_eq_zero_iff_eq.mpr ?_) simp_all only [ne_eq] #align affine_independent.injective AffineIndependent.injective theorem AffineIndependent.comp_embedding {ι2 : Type*} (f : ι2 ↪ ι) {p : ι → P} (ha : AffineIndependent k p) : AffineIndependent k (p ∘ f) := by classical intro fs w hw hs i0 hi0 let fs' := fs.map f let w' i := if h : ∃ i2, f i2 = i then w h.choose else 0 have hw' : ∀ i2 : ι2, w' (f i2) = w i2 := by intro i2 have h : ∃ i : ι2, f i = f i2 := ⟨i2, rfl⟩ have hs : h.choose = i2 := f.injective h.choose_spec simp_rw [w', dif_pos h, hs] have hw's : ∑ i ∈ fs', w' i = 0 := by rw [← hw, Finset.sum_map] simp [hw'] have hs' : fs'.weightedVSub p w' = (0 : V) := by rw [← hs, Finset.weightedVSub_map] congr with i simp_all only [comp_apply, EmbeddingLike.apply_eq_iff_eq, exists_eq, dite_true] rw [← ha fs' w' hw's hs' (f i0) ((Finset.mem_map' _).2 hi0), hw'] #align affine_independent.comp_embedding AffineIndependent.comp_embedding protected theorem AffineIndependent.subtype {p : ι → P} (ha : AffineIndependent k p) (s : Set ι) : AffineIndependent k fun i : s => p i := ha.comp_embedding (Embedding.subtype _) #align affine_independent.subtype AffineIndependent.subtype protected theorem AffineIndependent.range {p : ι → P} (ha : AffineIndependent k p) : AffineIndependent k (fun x => x : Set.range p → P) := by let f : Set.range p → ι := fun x => x.property.choose have hf : ∀ x, p (f x) = x := fun x => x.property.choose_spec let fe : Set.range p ↪ ι := ⟨f, fun x₁ x₂ he => Subtype.ext (hf x₁ ▸ hf x₂ ▸ he ▸ rfl)⟩ convert ha.comp_embedding fe ext simp [fe, hf] #align affine_independent.range AffineIndependent.range theorem affineIndependent_equiv {ι' : Type*} (e : ι ≃ ι') {p : ι' → P} : AffineIndependent k (p ∘ e) ↔ AffineIndependent k p := by refine ⟨?_, AffineIndependent.comp_embedding e.toEmbedding⟩ intro h have : p = p ∘ e ∘ e.symm.toEmbedding := by ext simp rw [this] exact h.comp_embedding e.symm.toEmbedding #align affine_independent_equiv affineIndependent_equiv protected theorem AffineIndependent.mono {s t : Set P} (ha : AffineIndependent k (fun x => x : t → P)) (hs : s ⊆ t) : AffineIndependent k (fun x => x : s → P) := ha.comp_embedding (s.embeddingOfSubset t hs) #align affine_independent.mono AffineIndependent.mono theorem AffineIndependent.of_set_of_injective {p : ι → P} (ha : AffineIndependent k (fun x => x : Set.range p → P)) (hi : Function.Injective p) : AffineIndependent k p := ha.comp_embedding (⟨fun i => ⟨p i, Set.mem_range_self _⟩, fun _ _ h => hi (Subtype.mk_eq_mk.1 h)⟩ : ι ↪ Set.range p) #align affine_independent.of_set_of_injective AffineIndependent.of_set_of_injective section Composition variable {V₂ P₂ : Type*} [AddCommGroup V₂] [Module k V₂] [AffineSpace V₂ P₂] theorem AffineIndependent.of_comp {p : ι → P} (f : P →ᵃ[k] P₂) (hai : AffineIndependent k (f ∘ p)) : AffineIndependent k p := by cases' isEmpty_or_nonempty ι with h h; · haveI := h apply affineIndependent_of_subsingleton obtain ⟨i⟩ := h rw [affineIndependent_iff_linearIndependent_vsub k p i] simp_rw [affineIndependent_iff_linearIndependent_vsub k (f ∘ p) i, Function.comp_apply, ← f.linearMap_vsub] at hai exact LinearIndependent.of_comp f.linear hai #align affine_independent.of_comp AffineIndependent.of_comp
Mathlib/LinearAlgebra/AffineSpace/Independent.lean
374
384
theorem AffineIndependent.map' {p : ι → P} (hai : AffineIndependent k p) (f : P →ᵃ[k] P₂) (hf : Function.Injective f) : AffineIndependent k (f ∘ p) := by
cases' isEmpty_or_nonempty ι with h h · haveI := h apply affineIndependent_of_subsingleton obtain ⟨i⟩ := h rw [affineIndependent_iff_linearIndependent_vsub k p i] at hai simp_rw [affineIndependent_iff_linearIndependent_vsub k (f ∘ p) i, Function.comp_apply, ← f.linearMap_vsub] have hf' : LinearMap.ker f.linear = ⊥ := by rwa [LinearMap.ker_eq_bot, f.linear_injective_iff] exact LinearIndependent.map' hai f.linear hf'