Context
stringlengths
285
157k
file_name
stringlengths
21
79
start
int64
14
3.67k
end
int64
18
3.69k
theorem
stringlengths
25
2.71k
proof
stringlengths
5
10.6k
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Kenny Lau -/ import Mathlib.Algebra.BigOperators.GroupWithZero.Finset import Mathlib.Algebra.Group.Submonoid.Membership import Mathlib.Algebra.Module.LinearMap.Basic import Mathlib.Data.Finset.Preimage import Mathlib.Data.Set.Finite import Mathlib.GroupTheory.GroupAction.BigOperators #align_import data.dfinsupp.basic from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1" /-! # Dependent functions with finite support For a non-dependent version see `data/finsupp.lean`. ## Notation This file introduces the notation `Π₀ a, β a` as notation for `DFinsupp β`, mirroring the `α →₀ β` notation used for `Finsupp`. This works for nested binders too, with `Π₀ a b, γ a b` as notation for `DFinsupp (fun a ↦ DFinsupp (γ a))`. ## Implementation notes The support is internally represented (in the primed `DFinsupp.support'`) as a `Multiset` that represents a superset of the true support of the function, quotiented by the always-true relation so that this does not impact equality. This approach has computational benefits over storing a `Finset`; it allows us to add together two finitely-supported functions without having to evaluate the resulting function to recompute its support (which would required decidability of `b = 0` for `b : β i`). The true support of the function can still be recovered with `DFinsupp.support`; but these decidability obligations are now postponed to when the support is actually needed. As a consequence, there are two ways to sum a `DFinsupp`: with `DFinsupp.sum` which works over an arbitrary function but requires recomputation of the support and therefore a `Decidable` argument; and with `DFinsupp.sumAddHom` which requires an additive morphism, using its properties to show that summing over a superset of the support is sufficient. `Finsupp` takes an altogether different approach here; it uses `Classical.Decidable` and declares the `Add` instance as noncomputable. This design difference is independent of the fact that `DFinsupp` is dependently-typed and `Finsupp` is not; in future, we may want to align these two definitions, or introduce two more definitions for the other combinations of decisions. -/ universe u u₁ u₂ v v₁ v₂ v₃ w x y l variable {ι : Type u} {γ : Type w} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂} variable (β) /-- A dependent function `Π i, β i` with finite support, with notation `Π₀ i, β i`. Note that `DFinsupp.support` is the preferred API for accessing the support of the function, `DFinsupp.support'` is an implementation detail that aids computability; see the implementation notes in this file for more information. -/ structure DFinsupp [∀ i, Zero (β i)] : Type max u v where mk' :: /-- The underlying function of a dependent function with finite support (aka `DFinsupp`). -/ toFun : ∀ i, β i /-- The support of a dependent function with finite support (aka `DFinsupp`). -/ support' : Trunc { s : Multiset ι // ∀ i, i ∈ s ∨ toFun i = 0 } #align dfinsupp DFinsupp variable {β} /-- `Π₀ i, β i` denotes the type of dependent functions with finite support `DFinsupp β`. -/ notation3 "Π₀ "(...)", "r:(scoped f => DFinsupp f) => r namespace DFinsupp section Basic variable [∀ i, Zero (β i)] [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)] instance instDFunLike : DFunLike (Π₀ i, β i) ι β := ⟨fun f => f.toFun, fun ⟨f₁, s₁⟩ ⟨f₂, s₁⟩ ↦ fun (h : f₁ = f₂) ↦ by subst h congr apply Subsingleton.elim ⟩ #align dfinsupp.fun_like DFinsupp.instDFunLike /-- Helper instance for when there are too many metavariables to apply `DFunLike.coeFunForall` directly. -/ instance : CoeFun (Π₀ i, β i) fun _ => ∀ i, β i := inferInstance @[simp] theorem toFun_eq_coe (f : Π₀ i, β i) : f.toFun = f := rfl #align dfinsupp.to_fun_eq_coe DFinsupp.toFun_eq_coe @[ext] theorem ext {f g : Π₀ i, β i} (h : ∀ i, f i = g i) : f = g := DFunLike.ext _ _ h #align dfinsupp.ext DFinsupp.ext #align dfinsupp.ext_iff DFunLike.ext_iff #align dfinsupp.coe_fn_injective DFunLike.coe_injective lemma ne_iff {f g : Π₀ i, β i} : f ≠ g ↔ ∃ i, f i ≠ g i := DFunLike.ne_iff instance : Zero (Π₀ i, β i) := ⟨⟨0, Trunc.mk <| ⟨∅, fun _ => Or.inr rfl⟩⟩⟩ instance : Inhabited (Π₀ i, β i) := ⟨0⟩ @[simp, norm_cast] lemma coe_mk' (f : ∀ i, β i) (s) : ⇑(⟨f, s⟩ : Π₀ i, β i) = f := rfl #align dfinsupp.coe_mk' DFinsupp.coe_mk' @[simp, norm_cast] lemma coe_zero : ⇑(0 : Π₀ i, β i) = 0 := rfl #align dfinsupp.coe_zero DFinsupp.coe_zero theorem zero_apply (i : ι) : (0 : Π₀ i, β i) i = 0 := rfl #align dfinsupp.zero_apply DFinsupp.zero_apply /-- The composition of `f : β₁ → β₂` and `g : Π₀ i, β₁ i` is `mapRange f hf g : Π₀ i, β₂ i`, well defined when `f 0 = 0`. This preserves the structure on `f`, and exists in various bundled forms for when `f` is itself bundled: * `DFinsupp.mapRange.addMonoidHom` * `DFinsupp.mapRange.addEquiv` * `dfinsupp.mapRange.linearMap` * `dfinsupp.mapRange.linearEquiv` -/ def mapRange (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (x : Π₀ i, β₁ i) : Π₀ i, β₂ i := ⟨fun i => f i (x i), x.support'.map fun s => ⟨s.1, fun i => (s.2 i).imp_right fun h : x i = 0 => by rw [← hf i, ← h]⟩⟩ #align dfinsupp.map_range DFinsupp.mapRange @[simp] theorem mapRange_apply (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (g : Π₀ i, β₁ i) (i : ι) : mapRange f hf g i = f i (g i) := rfl #align dfinsupp.map_range_apply DFinsupp.mapRange_apply @[simp] theorem mapRange_id (h : ∀ i, id (0 : β₁ i) = 0 := fun i => rfl) (g : Π₀ i : ι, β₁ i) : mapRange (fun i => (id : β₁ i → β₁ i)) h g = g := by ext rfl #align dfinsupp.map_range_id DFinsupp.mapRange_id theorem mapRange_comp (f : ∀ i, β₁ i → β₂ i) (f₂ : ∀ i, β i → β₁ i) (hf : ∀ i, f i 0 = 0) (hf₂ : ∀ i, f₂ i 0 = 0) (h : ∀ i, (f i ∘ f₂ i) 0 = 0) (g : Π₀ i : ι, β i) : mapRange (fun i => f i ∘ f₂ i) h g = mapRange f hf (mapRange f₂ hf₂ g) := by ext simp only [mapRange_apply]; rfl #align dfinsupp.map_range_comp DFinsupp.mapRange_comp @[simp] theorem mapRange_zero (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) : mapRange f hf (0 : Π₀ i, β₁ i) = 0 := by ext simp only [mapRange_apply, coe_zero, Pi.zero_apply, hf] #align dfinsupp.map_range_zero DFinsupp.mapRange_zero /-- Let `f i` be a binary operation `β₁ i → β₂ i → β i` such that `f i 0 0 = 0`. Then `zipWith f hf` is a binary operation `Π₀ i, β₁ i → Π₀ i, β₂ i → Π₀ i, β i`. -/ def zipWith (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (x : Π₀ i, β₁ i) (y : Π₀ i, β₂ i) : Π₀ i, β i := ⟨fun i => f i (x i) (y i), by refine x.support'.bind fun xs => ?_ refine y.support'.map fun ys => ?_ refine ⟨xs + ys, fun i => ?_⟩ obtain h1 | (h1 : x i = 0) := xs.prop i · left rw [Multiset.mem_add] left exact h1 obtain h2 | (h2 : y i = 0) := ys.prop i · left rw [Multiset.mem_add] right exact h2 right; rw [← hf, ← h1, ← h2]⟩ #align dfinsupp.zip_with DFinsupp.zipWith @[simp] theorem zipWith_apply (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (g₁ : Π₀ i, β₁ i) (g₂ : Π₀ i, β₂ i) (i : ι) : zipWith f hf g₁ g₂ i = f i (g₁ i) (g₂ i) := rfl #align dfinsupp.zip_with_apply DFinsupp.zipWith_apply section Piecewise variable (x y : Π₀ i, β i) (s : Set ι) [∀ i, Decidable (i ∈ s)] /-- `x.piecewise y s` is the finitely supported function equal to `x` on the set `s`, and to `y` on its complement. -/ def piecewise : Π₀ i, β i := zipWith (fun i x y => if i ∈ s then x else y) (fun _ => ite_self 0) x y #align dfinsupp.piecewise DFinsupp.piecewise theorem piecewise_apply (i : ι) : x.piecewise y s i = if i ∈ s then x i else y i := zipWith_apply _ _ x y i #align dfinsupp.piecewise_apply DFinsupp.piecewise_apply @[simp, norm_cast] theorem coe_piecewise : ⇑(x.piecewise y s) = s.piecewise x y := by ext apply piecewise_apply #align dfinsupp.coe_piecewise DFinsupp.coe_piecewise end Piecewise end Basic section Algebra instance [∀ i, AddZeroClass (β i)] : Add (Π₀ i, β i) := ⟨zipWith (fun _ => (· + ·)) fun _ => add_zero 0⟩ theorem add_apply [∀ i, AddZeroClass (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) : (g₁ + g₂) i = g₁ i + g₂ i := rfl #align dfinsupp.add_apply DFinsupp.add_apply @[simp, norm_cast] theorem coe_add [∀ i, AddZeroClass (β i)] (g₁ g₂ : Π₀ i, β i) : ⇑(g₁ + g₂) = g₁ + g₂ := rfl #align dfinsupp.coe_add DFinsupp.coe_add instance addZeroClass [∀ i, AddZeroClass (β i)] : AddZeroClass (Π₀ i, β i) := DFunLike.coe_injective.addZeroClass _ coe_zero coe_add instance instIsLeftCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsLeftCancelAdd (β i)] : IsLeftCancelAdd (Π₀ i, β i) where add_left_cancel _ _ _ h := ext fun x => add_left_cancel <| DFunLike.congr_fun h x instance instIsRightCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsRightCancelAdd (β i)] : IsRightCancelAdd (Π₀ i, β i) where add_right_cancel _ _ _ h := ext fun x => add_right_cancel <| DFunLike.congr_fun h x instance instIsCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsCancelAdd (β i)] : IsCancelAdd (Π₀ i, β i) where /-- Note the general `SMul` instance doesn't apply as `ℕ` is not distributive unless `β i`'s addition is commutative. -/ instance hasNatScalar [∀ i, AddMonoid (β i)] : SMul ℕ (Π₀ i, β i) := ⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => nsmul_zero _⟩ #align dfinsupp.has_nat_scalar DFinsupp.hasNatScalar theorem nsmul_apply [∀ i, AddMonoid (β i)] (b : ℕ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i := rfl #align dfinsupp.nsmul_apply DFinsupp.nsmul_apply @[simp, norm_cast] theorem coe_nsmul [∀ i, AddMonoid (β i)] (b : ℕ) (v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v := rfl #align dfinsupp.coe_nsmul DFinsupp.coe_nsmul instance [∀ i, AddMonoid (β i)] : AddMonoid (Π₀ i, β i) := DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ /-- Coercion from a `DFinsupp` to a pi type is an `AddMonoidHom`. -/ def coeFnAddMonoidHom [∀ i, AddZeroClass (β i)] : (Π₀ i, β i) →+ ∀ i, β i where toFun := (⇑) map_zero' := coe_zero map_add' := coe_add #align dfinsupp.coe_fn_add_monoid_hom DFinsupp.coeFnAddMonoidHom /-- Evaluation at a point is an `AddMonoidHom`. This is the finitely-supported version of `Pi.evalAddMonoidHom`. -/ def evalAddMonoidHom [∀ i, AddZeroClass (β i)] (i : ι) : (Π₀ i, β i) →+ β i := (Pi.evalAddMonoidHom β i).comp coeFnAddMonoidHom #align dfinsupp.eval_add_monoid_hom DFinsupp.evalAddMonoidHom instance addCommMonoid [∀ i, AddCommMonoid (β i)] : AddCommMonoid (Π₀ i, β i) := DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _ @[simp, norm_cast] theorem coe_finset_sum {α} [∀ i, AddCommMonoid (β i)] (s : Finset α) (g : α → Π₀ i, β i) : ⇑(∑ a ∈ s, g a) = ∑ a ∈ s, ⇑(g a) := map_sum coeFnAddMonoidHom g s #align dfinsupp.coe_finset_sum DFinsupp.coe_finset_sum @[simp] theorem finset_sum_apply {α} [∀ i, AddCommMonoid (β i)] (s : Finset α) (g : α → Π₀ i, β i) (i : ι) : (∑ a ∈ s, g a) i = ∑ a ∈ s, g a i := map_sum (evalAddMonoidHom i) g s #align dfinsupp.finset_sum_apply DFinsupp.finset_sum_apply instance [∀ i, AddGroup (β i)] : Neg (Π₀ i, β i) := ⟨fun f => f.mapRange (fun _ => Neg.neg) fun _ => neg_zero⟩ theorem neg_apply [∀ i, AddGroup (β i)] (g : Π₀ i, β i) (i : ι) : (-g) i = -g i := rfl #align dfinsupp.neg_apply DFinsupp.neg_apply @[simp, norm_cast] lemma coe_neg [∀ i, AddGroup (β i)] (g : Π₀ i, β i) : ⇑(-g) = -g := rfl #align dfinsupp.coe_neg DFinsupp.coe_neg instance [∀ i, AddGroup (β i)] : Sub (Π₀ i, β i) := ⟨zipWith (fun _ => Sub.sub) fun _ => sub_zero 0⟩ theorem sub_apply [∀ i, AddGroup (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) : (g₁ - g₂) i = g₁ i - g₂ i := rfl #align dfinsupp.sub_apply DFinsupp.sub_apply @[simp, norm_cast] theorem coe_sub [∀ i, AddGroup (β i)] (g₁ g₂ : Π₀ i, β i) : ⇑(g₁ - g₂) = g₁ - g₂ := rfl #align dfinsupp.coe_sub DFinsupp.coe_sub /-- Note the general `SMul` instance doesn't apply as `ℤ` is not distributive unless `β i`'s addition is commutative. -/ instance hasIntScalar [∀ i, AddGroup (β i)] : SMul ℤ (Π₀ i, β i) := ⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => zsmul_zero _⟩ #align dfinsupp.has_int_scalar DFinsupp.hasIntScalar theorem zsmul_apply [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i := rfl #align dfinsupp.zsmul_apply DFinsupp.zsmul_apply @[simp, norm_cast] theorem coe_zsmul [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v := rfl #align dfinsupp.coe_zsmul DFinsupp.coe_zsmul instance [∀ i, AddGroup (β i)] : AddGroup (Π₀ i, β i) := DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ instance addCommGroup [∀ i, AddCommGroup (β i)] : AddCommGroup (Π₀ i, β i) := DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _) fun _ _ => coe_zsmul _ _ /-- Dependent functions with finite support inherit a semiring action from an action on each coordinate. -/ instance [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] : SMul γ (Π₀ i, β i) := ⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => smul_zero _⟩ theorem smul_apply [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (b : γ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i := rfl #align dfinsupp.smul_apply DFinsupp.smul_apply @[simp, norm_cast] theorem coe_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (b : γ) (v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v := rfl #align dfinsupp.coe_smul DFinsupp.coe_smul instance smulCommClass {δ : Type*} [Monoid γ] [Monoid δ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] [∀ i, DistribMulAction δ (β i)] [∀ i, SMulCommClass γ δ (β i)] : SMulCommClass γ δ (Π₀ i, β i) where smul_comm r s m := ext fun i => by simp only [smul_apply, smul_comm r s (m i)] instance isScalarTower {δ : Type*} [Monoid γ] [Monoid δ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] [∀ i, DistribMulAction δ (β i)] [SMul γ δ] [∀ i, IsScalarTower γ δ (β i)] : IsScalarTower γ δ (Π₀ i, β i) where smul_assoc r s m := ext fun i => by simp only [smul_apply, smul_assoc r s (m i)] instance isCentralScalar [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] [∀ i, DistribMulAction γᵐᵒᵖ (β i)] [∀ i, IsCentralScalar γ (β i)] : IsCentralScalar γ (Π₀ i, β i) where op_smul_eq_smul r m := ext fun i => by simp only [smul_apply, op_smul_eq_smul r (m i)] /-- Dependent functions with finite support inherit a `DistribMulAction` structure from such a structure on each coordinate. -/ instance distribMulAction [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] : DistribMulAction γ (Π₀ i, β i) := Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective coe_smul /-- Dependent functions with finite support inherit a module structure from such a structure on each coordinate. -/ instance module [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] : Module γ (Π₀ i, β i) := { inferInstanceAs (DistribMulAction γ (Π₀ i, β i)) with zero_smul := fun c => ext fun i => by simp only [smul_apply, zero_smul, zero_apply] add_smul := fun c x y => ext fun i => by simp only [add_apply, smul_apply, add_smul] } #align dfinsupp.module DFinsupp.module end Algebra section FilterAndSubtypeDomain /-- `Filter p f` is the function which is `f i` if `p i` is true and 0 otherwise. -/ def filter [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (x : Π₀ i, β i) : Π₀ i, β i := ⟨fun i => if p i then x i else 0, x.support'.map fun xs => ⟨xs.1, fun i => (xs.prop i).imp_right fun H : x i = 0 => by simp only [H, ite_self]⟩⟩ #align dfinsupp.filter DFinsupp.filter @[simp] theorem filter_apply [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (i : ι) (f : Π₀ i, β i) : f.filter p i = if p i then f i else 0 := rfl #align dfinsupp.filter_apply DFinsupp.filter_apply theorem filter_apply_pos [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] (f : Π₀ i, β i) {i : ι} (h : p i) : f.filter p i = f i := by simp only [filter_apply, if_pos h] #align dfinsupp.filter_apply_pos DFinsupp.filter_apply_pos theorem filter_apply_neg [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] (f : Π₀ i, β i) {i : ι} (h : ¬p i) : f.filter p i = 0 := by simp only [filter_apply, if_neg h] #align dfinsupp.filter_apply_neg DFinsupp.filter_apply_neg theorem filter_pos_add_filter_neg [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i) (p : ι → Prop) [DecidablePred p] : (f.filter p + f.filter fun i => ¬p i) = f := ext fun i => by simp only [add_apply, filter_apply]; split_ifs <;> simp only [add_zero, zero_add] #align dfinsupp.filter_pos_add_filter_neg DFinsupp.filter_pos_add_filter_neg @[simp] theorem filter_zero [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] : (0 : Π₀ i, β i).filter p = 0 := by ext simp #align dfinsupp.filter_zero DFinsupp.filter_zero @[simp] theorem filter_add [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] (f g : Π₀ i, β i) : (f + g).filter p = f.filter p + g.filter p := by ext simp [ite_add_zero] #align dfinsupp.filter_add DFinsupp.filter_add @[simp] theorem filter_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (p : ι → Prop) [DecidablePred p] (r : γ) (f : Π₀ i, β i) : (r • f).filter p = r • f.filter p := by ext simp [smul_apply, smul_ite] #align dfinsupp.filter_smul DFinsupp.filter_smul variable (γ β) /-- `DFinsupp.filter` as an `AddMonoidHom`. -/ @[simps] def filterAddMonoidHom [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] : (Π₀ i, β i) →+ Π₀ i, β i where toFun := filter p map_zero' := filter_zero p map_add' := filter_add p #align dfinsupp.filter_add_monoid_hom DFinsupp.filterAddMonoidHom #align dfinsupp.filter_add_monoid_hom_apply DFinsupp.filterAddMonoidHom_apply /-- `DFinsupp.filter` as a `LinearMap`. -/ @[simps] def filterLinearMap [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] (p : ι → Prop) [DecidablePred p] : (Π₀ i, β i) →ₗ[γ] Π₀ i, β i where toFun := filter p map_add' := filter_add p map_smul' := filter_smul p #align dfinsupp.filter_linear_map DFinsupp.filterLinearMap #align dfinsupp.filter_linear_map_apply DFinsupp.filterLinearMap_apply variable {γ β} @[simp] theorem filter_neg [∀ i, AddGroup (β i)] (p : ι → Prop) [DecidablePred p] (f : Π₀ i, β i) : (-f).filter p = -f.filter p := (filterAddMonoidHom β p).map_neg f #align dfinsupp.filter_neg DFinsupp.filter_neg @[simp] theorem filter_sub [∀ i, AddGroup (β i)] (p : ι → Prop) [DecidablePred p] (f g : Π₀ i, β i) : (f - g).filter p = f.filter p - g.filter p := (filterAddMonoidHom β p).map_sub f g #align dfinsupp.filter_sub DFinsupp.filter_sub /-- `subtypeDomain p f` is the restriction of the finitely supported function `f` to the subtype `p`. -/ def subtypeDomain [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (x : Π₀ i, β i) : Π₀ i : Subtype p, β i := ⟨fun i => x (i : ι), x.support'.map fun xs => ⟨(Multiset.filter p xs.1).attach.map fun j => ⟨j.1, (Multiset.mem_filter.1 j.2).2⟩, fun i => (xs.prop i).imp_left fun H => Multiset.mem_map.2 ⟨⟨i, Multiset.mem_filter.2 ⟨H, i.2⟩⟩, Multiset.mem_attach _ _, Subtype.eta _ _⟩⟩⟩ #align dfinsupp.subtype_domain DFinsupp.subtypeDomain @[simp] theorem subtypeDomain_zero [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] : subtypeDomain p (0 : Π₀ i, β i) = 0 := rfl #align dfinsupp.subtype_domain_zero DFinsupp.subtypeDomain_zero @[simp] theorem subtypeDomain_apply [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] {i : Subtype p} {v : Π₀ i, β i} : (subtypeDomain p v) i = v i := rfl #align dfinsupp.subtype_domain_apply DFinsupp.subtypeDomain_apply @[simp] theorem subtypeDomain_add [∀ i, AddZeroClass (β i)] {p : ι → Prop} [DecidablePred p] (v v' : Π₀ i, β i) : (v + v').subtypeDomain p = v.subtypeDomain p + v'.subtypeDomain p := DFunLike.coe_injective rfl #align dfinsupp.subtype_domain_add DFinsupp.subtypeDomain_add @[simp] theorem subtypeDomain_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] {p : ι → Prop} [DecidablePred p] (r : γ) (f : Π₀ i, β i) : (r • f).subtypeDomain p = r • f.subtypeDomain p := DFunLike.coe_injective rfl #align dfinsupp.subtype_domain_smul DFinsupp.subtypeDomain_smul variable (γ β) /-- `subtypeDomain` but as an `AddMonoidHom`. -/ @[simps] def subtypeDomainAddMonoidHom [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] : (Π₀ i : ι, β i) →+ Π₀ i : Subtype p, β i where toFun := subtypeDomain p map_zero' := subtypeDomain_zero map_add' := subtypeDomain_add #align dfinsupp.subtype_domain_add_monoid_hom DFinsupp.subtypeDomainAddMonoidHom #align dfinsupp.subtype_domain_add_monoid_hom_apply DFinsupp.subtypeDomainAddMonoidHom_apply /-- `DFinsupp.subtypeDomain` as a `LinearMap`. -/ @[simps] def subtypeDomainLinearMap [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] (p : ι → Prop) [DecidablePred p] : (Π₀ i, β i) →ₗ[γ] Π₀ i : Subtype p, β i where toFun := subtypeDomain p map_add' := subtypeDomain_add map_smul' := subtypeDomain_smul #align dfinsupp.subtype_domain_linear_map DFinsupp.subtypeDomainLinearMap #align dfinsupp.subtype_domain_linear_map_apply DFinsupp.subtypeDomainLinearMap_apply variable {γ β} @[simp] theorem subtypeDomain_neg [∀ i, AddGroup (β i)] {p : ι → Prop} [DecidablePred p] {v : Π₀ i, β i} : (-v).subtypeDomain p = -v.subtypeDomain p := DFunLike.coe_injective rfl #align dfinsupp.subtype_domain_neg DFinsupp.subtypeDomain_neg @[simp] theorem subtypeDomain_sub [∀ i, AddGroup (β i)] {p : ι → Prop} [DecidablePred p] {v v' : Π₀ i, β i} : (v - v').subtypeDomain p = v.subtypeDomain p - v'.subtypeDomain p := DFunLike.coe_injective rfl #align dfinsupp.subtype_domain_sub DFinsupp.subtypeDomain_sub end FilterAndSubtypeDomain variable [DecidableEq ι] section Basic variable [∀ i, Zero (β i)] theorem finite_support (f : Π₀ i, β i) : Set.Finite { i | f i ≠ 0 } := Trunc.induction_on f.support' fun xs ↦ xs.1.finite_toSet.subset fun i H ↦ ((xs.prop i).resolve_right H) #align dfinsupp.finite_support DFinsupp.finite_support /-- Create an element of `Π₀ i, β i` from a finset `s` and a function `x` defined on this `Finset`. -/ def mk (s : Finset ι) (x : ∀ i : (↑s : Set ι), β (i : ι)) : Π₀ i, β i := ⟨fun i => if H : i ∈ s then x ⟨i, H⟩ else 0, Trunc.mk ⟨s.1, fun i => if H : i ∈ s then Or.inl H else Or.inr <| dif_neg H⟩⟩ #align dfinsupp.mk DFinsupp.mk variable {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i} {i : ι} @[simp] theorem mk_apply : (mk s x : ∀ i, β i) i = if H : i ∈ s then x ⟨i, H⟩ else 0 := rfl #align dfinsupp.mk_apply DFinsupp.mk_apply theorem mk_of_mem (hi : i ∈ s) : (mk s x : ∀ i, β i) i = x ⟨i, hi⟩ := dif_pos hi #align dfinsupp.mk_of_mem DFinsupp.mk_of_mem theorem mk_of_not_mem (hi : i ∉ s) : (mk s x : ∀ i, β i) i = 0 := dif_neg hi #align dfinsupp.mk_of_not_mem DFinsupp.mk_of_not_mem theorem mk_injective (s : Finset ι) : Function.Injective (@mk ι β _ _ s) := by intro x y H ext i have h1 : (mk s x : ∀ i, β i) i = (mk s y : ∀ i, β i) i := by rw [H] obtain ⟨i, hi : i ∈ s⟩ := i dsimp only [mk_apply, Subtype.coe_mk] at h1 simpa only [dif_pos hi] using h1 #align dfinsupp.mk_injective DFinsupp.mk_injective instance unique [∀ i, Subsingleton (β i)] : Unique (Π₀ i, β i) := DFunLike.coe_injective.unique #align dfinsupp.unique DFinsupp.unique instance uniqueOfIsEmpty [IsEmpty ι] : Unique (Π₀ i, β i) := DFunLike.coe_injective.unique #align dfinsupp.unique_of_is_empty DFinsupp.uniqueOfIsEmpty /-- Given `Fintype ι`, `equivFunOnFintype` is the `Equiv` between `Π₀ i, β i` and `Π i, β i`. (All dependent functions on a finite type are finitely supported.) -/ @[simps apply] def equivFunOnFintype [Fintype ι] : (Π₀ i, β i) ≃ ∀ i, β i where toFun := (⇑) invFun f := ⟨f, Trunc.mk ⟨Finset.univ.1, fun _ => Or.inl <| Finset.mem_univ_val _⟩⟩ left_inv _ := DFunLike.coe_injective rfl right_inv _ := rfl #align dfinsupp.equiv_fun_on_fintype DFinsupp.equivFunOnFintype #align dfinsupp.equiv_fun_on_fintype_apply DFinsupp.equivFunOnFintype_apply @[simp] theorem equivFunOnFintype_symm_coe [Fintype ι] (f : Π₀ i, β i) : equivFunOnFintype.symm f = f := Equiv.symm_apply_apply _ _ #align dfinsupp.equiv_fun_on_fintype_symm_coe DFinsupp.equivFunOnFintype_symm_coe /-- The function `single i b : Π₀ i, β i` sends `i` to `b` and all other points to `0`. -/ def single (i : ι) (b : β i) : Π₀ i, β i := ⟨Pi.single i b, Trunc.mk ⟨{i}, fun j => (Decidable.eq_or_ne j i).imp (by simp) fun h => Pi.single_eq_of_ne h _⟩⟩ #align dfinsupp.single DFinsupp.single theorem single_eq_pi_single {i b} : ⇑(single i b : Π₀ i, β i) = Pi.single i b := rfl #align dfinsupp.single_eq_pi_single DFinsupp.single_eq_pi_single @[simp] theorem single_apply {i i' b} : (single i b : Π₀ i, β i) i' = if h : i = i' then Eq.recOn h b else 0 := by rw [single_eq_pi_single, Pi.single, Function.update] simp [@eq_comm _ i i'] #align dfinsupp.single_apply DFinsupp.single_apply @[simp] theorem single_zero (i) : (single i 0 : Π₀ i, β i) = 0 := DFunLike.coe_injective <| Pi.single_zero _ #align dfinsupp.single_zero DFinsupp.single_zero -- @[simp] -- Porting note (#10618): simp can prove this theorem single_eq_same {i b} : (single i b : Π₀ i, β i) i = b := by simp only [single_apply, dite_eq_ite, ite_true] #align dfinsupp.single_eq_same DFinsupp.single_eq_same theorem single_eq_of_ne {i i' b} (h : i ≠ i') : (single i b : Π₀ i, β i) i' = 0 := by simp only [single_apply, dif_neg h] #align dfinsupp.single_eq_of_ne DFinsupp.single_eq_of_ne theorem single_injective {i} : Function.Injective (single i : β i → Π₀ i, β i) := fun _ _ H => Pi.single_injective β i <| DFunLike.coe_injective.eq_iff.mpr H #align dfinsupp.single_injective DFinsupp.single_injective /-- Like `Finsupp.single_eq_single_iff`, but with a `HEq` due to dependent types -/ theorem single_eq_single_iff (i j : ι) (xi : β i) (xj : β j) : DFinsupp.single i xi = DFinsupp.single j xj ↔ i = j ∧ HEq xi xj ∨ xi = 0 ∧ xj = 0 := by constructor · intro h by_cases hij : i = j · subst hij exact Or.inl ⟨rfl, heq_of_eq (DFinsupp.single_injective h)⟩ · have h_coe : ⇑(DFinsupp.single i xi) = DFinsupp.single j xj := congr_arg (⇑) h have hci := congr_fun h_coe i have hcj := congr_fun h_coe j rw [DFinsupp.single_eq_same] at hci hcj rw [DFinsupp.single_eq_of_ne (Ne.symm hij)] at hci rw [DFinsupp.single_eq_of_ne hij] at hcj exact Or.inr ⟨hci, hcj.symm⟩ · rintro (⟨rfl, hxi⟩ | ⟨hi, hj⟩) · rw [eq_of_heq hxi] · rw [hi, hj, DFinsupp.single_zero, DFinsupp.single_zero] #align dfinsupp.single_eq_single_iff DFinsupp.single_eq_single_iff /-- `DFinsupp.single a b` is injective in `a`. For the statement that it is injective in `b`, see `DFinsupp.single_injective` -/ theorem single_left_injective {b : ∀ i : ι, β i} (h : ∀ i, b i ≠ 0) : Function.Injective (fun i => single i (b i) : ι → Π₀ i, β i) := fun _ _ H => (((single_eq_single_iff _ _ _ _).mp H).resolve_right fun hb => h _ hb.1).left #align dfinsupp.single_left_injective DFinsupp.single_left_injective @[simp] theorem single_eq_zero {i : ι} {xi : β i} : single i xi = 0 ↔ xi = 0 := by rw [← single_zero i, single_eq_single_iff] simp #align dfinsupp.single_eq_zero DFinsupp.single_eq_zero theorem filter_single (p : ι → Prop) [DecidablePred p] (i : ι) (x : β i) : (single i x).filter p = if p i then single i x else 0 := by ext j have := apply_ite (fun x : Π₀ i, β i => x j) (p i) (single i x) 0 dsimp at this rw [filter_apply, this] obtain rfl | hij := Decidable.eq_or_ne i j · rfl · rw [single_eq_of_ne hij, ite_self, ite_self] #align dfinsupp.filter_single DFinsupp.filter_single @[simp] theorem filter_single_pos {p : ι → Prop} [DecidablePred p] (i : ι) (x : β i) (h : p i) : (single i x).filter p = single i x := by rw [filter_single, if_pos h] #align dfinsupp.filter_single_pos DFinsupp.filter_single_pos @[simp] theorem filter_single_neg {p : ι → Prop} [DecidablePred p] (i : ι) (x : β i) (h : ¬p i) : (single i x).filter p = 0 := by rw [filter_single, if_neg h] #align dfinsupp.filter_single_neg DFinsupp.filter_single_neg /-- Equality of sigma types is sufficient (but not necessary) to show equality of `DFinsupp`s. -/ theorem single_eq_of_sigma_eq {i j} {xi : β i} {xj : β j} (h : (⟨i, xi⟩ : Sigma β) = ⟨j, xj⟩) : DFinsupp.single i xi = DFinsupp.single j xj := by cases h rfl #align dfinsupp.single_eq_of_sigma_eq DFinsupp.single_eq_of_sigma_eq @[simp] theorem equivFunOnFintype_single [Fintype ι] (i : ι) (m : β i) : (@DFinsupp.equivFunOnFintype ι β _ _) (DFinsupp.single i m) = Pi.single i m := by ext x dsimp [Pi.single, Function.update] simp [DFinsupp.single_eq_pi_single, @eq_comm _ i] #align dfinsupp.equiv_fun_on_fintype_single DFinsupp.equivFunOnFintype_single @[simp] theorem equivFunOnFintype_symm_single [Fintype ι] (i : ι) (m : β i) : (@DFinsupp.equivFunOnFintype ι β _ _).symm (Pi.single i m) = DFinsupp.single i m := by ext i' simp only [← single_eq_pi_single, equivFunOnFintype_symm_coe] #align dfinsupp.equiv_fun_on_fintype_symm_single DFinsupp.equivFunOnFintype_symm_single section SingleAndZipWith variable [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)] @[simp] theorem zipWith_single_single (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) {i} (b₁ : β₁ i) (b₂ : β₂ i) : zipWith f hf (single i b₁) (single i b₂) = single i (f i b₁ b₂) := by ext j rw [zipWith_apply] obtain rfl | hij := Decidable.eq_or_ne i j · rw [single_eq_same, single_eq_same, single_eq_same] · rw [single_eq_of_ne hij, single_eq_of_ne hij, single_eq_of_ne hij, hf] end SingleAndZipWith /-- Redefine `f i` to be `0`. -/ def erase (i : ι) (x : Π₀ i, β i) : Π₀ i, β i := ⟨fun j ↦ if j = i then 0 else x.1 j, x.support'.map fun xs ↦ ⟨xs.1, fun j ↦ (xs.prop j).imp_right (by simp only [·, ite_self])⟩⟩ #align dfinsupp.erase DFinsupp.erase @[simp] theorem erase_apply {i j : ι} {f : Π₀ i, β i} : (f.erase i) j = if j = i then 0 else f j := rfl #align dfinsupp.erase_apply DFinsupp.erase_apply -- @[simp] -- Porting note (#10618): simp can prove this theorem erase_same {i : ι} {f : Π₀ i, β i} : (f.erase i) i = 0 := by simp #align dfinsupp.erase_same DFinsupp.erase_same theorem erase_ne {i i' : ι} {f : Π₀ i, β i} (h : i' ≠ i) : (f.erase i) i' = f i' := by simp [h] #align dfinsupp.erase_ne DFinsupp.erase_ne theorem piecewise_single_erase (x : Π₀ i, β i) (i : ι) [∀ i' : ι, Decidable <| (i' ∈ ({i} : Set ι))] : -- Porting note: added Decidable hypothesis (single i (x i)).piecewise (x.erase i) {i} = x := by ext j; rw [piecewise_apply]; split_ifs with h · rw [(id h : j = i), single_eq_same] · exact erase_ne h #align dfinsupp.piecewise_single_erase DFinsupp.piecewise_single_erase theorem erase_eq_sub_single {β : ι → Type*} [∀ i, AddGroup (β i)] (f : Π₀ i, β i) (i : ι) : f.erase i = f - single i (f i) := by ext j rcases eq_or_ne i j with (rfl | h) · simp · simp [erase_ne h.symm, single_eq_of_ne h, @eq_comm _ j, h] #align dfinsupp.erase_eq_sub_single DFinsupp.erase_eq_sub_single @[simp] theorem erase_zero (i : ι) : erase i (0 : Π₀ i, β i) = 0 := ext fun _ => ite_self _ #align dfinsupp.erase_zero DFinsupp.erase_zero @[simp] theorem filter_ne_eq_erase (f : Π₀ i, β i) (i : ι) : f.filter (· ≠ i) = f.erase i := by ext1 j simp only [DFinsupp.filter_apply, DFinsupp.erase_apply, ite_not] #align dfinsupp.filter_ne_eq_erase DFinsupp.filter_ne_eq_erase @[simp] theorem filter_ne_eq_erase' (f : Π₀ i, β i) (i : ι) : f.filter (i ≠ ·) = f.erase i := by rw [← filter_ne_eq_erase f i] congr with j exact ne_comm #align dfinsupp.filter_ne_eq_erase' DFinsupp.filter_ne_eq_erase' theorem erase_single (j : ι) (i : ι) (x : β i) : (single i x).erase j = if i = j then 0 else single i x := by rw [← filter_ne_eq_erase, filter_single, ite_not] #align dfinsupp.erase_single DFinsupp.erase_single @[simp] theorem erase_single_same (i : ι) (x : β i) : (single i x).erase i = 0 := by rw [erase_single, if_pos rfl] #align dfinsupp.erase_single_same DFinsupp.erase_single_same @[simp] theorem erase_single_ne {i j : ι} (x : β i) (h : i ≠ j) : (single i x).erase j = single i x := by rw [erase_single, if_neg h] #align dfinsupp.erase_single_ne DFinsupp.erase_single_ne section Update variable (f : Π₀ i, β i) (i) (b : β i) /-- Replace the value of a `Π₀ i, β i` at a given point `i : ι` by a given value `b : β i`. If `b = 0`, this amounts to removing `i` from the support. Otherwise, `i` is added to it. This is the (dependent) finitely-supported version of `Function.update`. -/ def update : Π₀ i, β i := ⟨Function.update f i b, f.support'.map fun s => ⟨i ::ₘ s.1, fun j => by rcases eq_or_ne i j with (rfl | hi) · simp · obtain hj | (hj : f j = 0) := s.prop j · exact Or.inl (Multiset.mem_cons_of_mem hj) · exact Or.inr ((Function.update_noteq hi.symm b _).trans hj)⟩⟩ #align dfinsupp.update DFinsupp.update variable (j : ι) @[simp, norm_cast] lemma coe_update : (f.update i b : ∀ i : ι, β i) = Function.update f i b := rfl #align dfinsupp.coe_update DFinsupp.coe_update @[simp] theorem update_self : f.update i (f i) = f := by ext simp #align dfinsupp.update_self DFinsupp.update_self @[simp] theorem update_eq_erase : f.update i 0 = f.erase i := by ext j rcases eq_or_ne i j with (rfl | hi) · simp · simp [hi.symm] #align dfinsupp.update_eq_erase DFinsupp.update_eq_erase theorem update_eq_single_add_erase {β : ι → Type*} [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i) (i : ι) (b : β i) : f.update i b = single i b + f.erase i := by ext j rcases eq_or_ne i j with (rfl | h) · simp · simp [Function.update_noteq h.symm, h, erase_ne, h.symm] #align dfinsupp.update_eq_single_add_erase DFinsupp.update_eq_single_add_erase theorem update_eq_erase_add_single {β : ι → Type*} [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i) (i : ι) (b : β i) : f.update i b = f.erase i + single i b := by ext j rcases eq_or_ne i j with (rfl | h) · simp · simp [Function.update_noteq h.symm, h, erase_ne, h.symm] #align dfinsupp.update_eq_erase_add_single DFinsupp.update_eq_erase_add_single theorem update_eq_sub_add_single {β : ι → Type*} [∀ i, AddGroup (β i)] (f : Π₀ i, β i) (i : ι) (b : β i) : f.update i b = f - single i (f i) + single i b := by rw [update_eq_erase_add_single f i b, erase_eq_sub_single f i] #align dfinsupp.update_eq_sub_add_single DFinsupp.update_eq_sub_add_single end Update end Basic section AddMonoid variable [∀ i, AddZeroClass (β i)] @[simp] theorem single_add (i : ι) (b₁ b₂ : β i) : single i (b₁ + b₂) = single i b₁ + single i b₂ := (zipWith_single_single (fun _ => (· + ·)) _ b₁ b₂).symm #align dfinsupp.single_add DFinsupp.single_add @[simp] theorem erase_add (i : ι) (f₁ f₂ : Π₀ i, β i) : erase i (f₁ + f₂) = erase i f₁ + erase i f₂ := ext fun _ => by simp [ite_zero_add] #align dfinsupp.erase_add DFinsupp.erase_add variable (β) /-- `DFinsupp.single` as an `AddMonoidHom`. -/ @[simps] def singleAddHom (i : ι) : β i →+ Π₀ i, β i where toFun := single i map_zero' := single_zero i map_add' := single_add i #align dfinsupp.single_add_hom DFinsupp.singleAddHom #align dfinsupp.single_add_hom_apply DFinsupp.singleAddHom_apply /-- `DFinsupp.erase` as an `AddMonoidHom`. -/ @[simps] def eraseAddHom (i : ι) : (Π₀ i, β i) →+ Π₀ i, β i where toFun := erase i map_zero' := erase_zero i map_add' := erase_add i #align dfinsupp.erase_add_hom DFinsupp.eraseAddHom #align dfinsupp.erase_add_hom_apply DFinsupp.eraseAddHom_apply variable {β} @[simp] theorem single_neg {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (x : β i) : single i (-x) = -single i x := (singleAddHom β i).map_neg x #align dfinsupp.single_neg DFinsupp.single_neg @[simp] theorem single_sub {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (x y : β i) : single i (x - y) = single i x - single i y := (singleAddHom β i).map_sub x y #align dfinsupp.single_sub DFinsupp.single_sub @[simp] theorem erase_neg {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (f : Π₀ i, β i) : (-f).erase i = -f.erase i := (eraseAddHom β i).map_neg f #align dfinsupp.erase_neg DFinsupp.erase_neg @[simp] theorem erase_sub {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (f g : Π₀ i, β i) : (f - g).erase i = f.erase i - g.erase i := (eraseAddHom β i).map_sub f g #align dfinsupp.erase_sub DFinsupp.erase_sub theorem single_add_erase (i : ι) (f : Π₀ i, β i) : single i (f i) + f.erase i = f := ext fun i' => if h : i = i' then by subst h; simp only [add_apply, single_apply, erase_apply, add_zero, dite_eq_ite, if_true] else by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (Ne.symm h), zero_add] #align dfinsupp.single_add_erase DFinsupp.single_add_erase theorem erase_add_single (i : ι) (f : Π₀ i, β i) : f.erase i + single i (f i) = f := ext fun i' => if h : i = i' then by subst h; simp only [add_apply, single_apply, erase_apply, zero_add, dite_eq_ite, if_true] else by simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (Ne.symm h), add_zero] #align dfinsupp.erase_add_single DFinsupp.erase_add_single protected theorem induction {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i) (h0 : p 0) (ha : ∀ (i b) (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (single i b + f)) : p f := by cases' f with f s induction' s using Trunc.induction_on with s cases' s with s H induction' s using Multiset.induction_on with i s ih generalizing f · have : f = 0 := funext fun i => (H i).resolve_left (Multiset.not_mem_zero _) subst this exact h0 have H2 : p (erase i ⟨f, Trunc.mk ⟨i ::ₘ s, H⟩⟩) := by dsimp only [erase, Trunc.map, Trunc.bind, Trunc.liftOn, Trunc.lift_mk, Function.comp, Subtype.coe_mk] have H2 : ∀ j, j ∈ s ∨ ite (j = i) 0 (f j) = 0 := by intro j cases' H j with H2 H2 · cases' Multiset.mem_cons.1 H2 with H3 H3 · right; exact if_pos H3 · left; exact H3 right split_ifs <;> [rfl; exact H2] have H3 : ∀ aux, (⟨fun j : ι => ite (j = i) 0 (f j), Trunc.mk ⟨i ::ₘ s, aux⟩⟩ : Π₀ i, β i) = ⟨fun j : ι => ite (j = i) 0 (f j), Trunc.mk ⟨s, H2⟩⟩ := fun _ ↦ ext fun _ => rfl rw [H3] apply ih have H3 : single i _ + _ = (⟨f, Trunc.mk ⟨i ::ₘ s, H⟩⟩ : Π₀ i, β i) := single_add_erase _ _ rw [← H3] change p (single i (f i) + _) cases' Classical.em (f i = 0) with h h · rw [h, single_zero, zero_add] exact H2 refine ha _ _ _ ?_ h H2 rw [erase_same] #align dfinsupp.induction DFinsupp.induction theorem induction₂ {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i) (h0 : p 0) (ha : ∀ (i b) (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (f + single i b)) : p f := DFinsupp.induction f h0 fun i b f h1 h2 h3 => have h4 : f + single i b = single i b + f := by ext j; by_cases H : i = j · subst H simp [h1] · simp [H] Eq.recOn h4 <| ha i b f h1 h2 h3 #align dfinsupp.induction₂ DFinsupp.induction₂ @[simp] theorem add_closure_iUnion_range_single : AddSubmonoid.closure (⋃ i : ι, Set.range (single i : β i → Π₀ i, β i)) = ⊤ := top_unique fun x _ => by apply DFinsupp.induction x · exact AddSubmonoid.zero_mem _ exact fun a b f _ _ hf => AddSubmonoid.add_mem _ (AddSubmonoid.subset_closure <| Set.mem_iUnion.2 ⟨a, Set.mem_range_self _⟩) hf #align dfinsupp.add_closure_Union_range_single DFinsupp.add_closure_iUnion_range_single /-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then they are equal. -/ theorem addHom_ext {γ : Type w} [AddZeroClass γ] ⦃f g : (Π₀ i, β i) →+ γ⦄ (H : ∀ (i : ι) (y : β i), f (single i y) = g (single i y)) : f = g := by refine AddMonoidHom.eq_of_eqOn_denseM add_closure_iUnion_range_single fun f hf => ?_ simp only [Set.mem_iUnion, Set.mem_range] at hf rcases hf with ⟨x, y, rfl⟩ apply H #align dfinsupp.add_hom_ext DFinsupp.addHom_ext /-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then they are equal. See note [partially-applied ext lemmas]. -/ @[ext] theorem addHom_ext' {γ : Type w} [AddZeroClass γ] ⦃f g : (Π₀ i, β i) →+ γ⦄ (H : ∀ x, f.comp (singleAddHom β x) = g.comp (singleAddHom β x)) : f = g := addHom_ext fun x => DFunLike.congr_fun (H x) #align dfinsupp.add_hom_ext' DFinsupp.addHom_ext' end AddMonoid @[simp] theorem mk_add [∀ i, AddZeroClass (β i)] {s : Finset ι} {x y : ∀ i : (↑s : Set ι), β i} : mk s (x + y) = mk s x + mk s y := ext fun i => by simp only [add_apply, mk_apply]; split_ifs <;> [rfl; rw [zero_add]] #align dfinsupp.mk_add DFinsupp.mk_add @[simp] theorem mk_zero [∀ i, Zero (β i)] {s : Finset ι} : mk s (0 : ∀ i : (↑s : Set ι), β i.1) = 0 := ext fun i => by simp only [mk_apply]; split_ifs <;> rfl #align dfinsupp.mk_zero DFinsupp.mk_zero @[simp] theorem mk_neg [∀ i, AddGroup (β i)] {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i.1} : mk s (-x) = -mk s x := ext fun i => by simp only [neg_apply, mk_apply]; split_ifs <;> [rfl; rw [neg_zero]] #align dfinsupp.mk_neg DFinsupp.mk_neg @[simp] theorem mk_sub [∀ i, AddGroup (β i)] {s : Finset ι} {x y : ∀ i : (↑s : Set ι), β i.1} : mk s (x - y) = mk s x - mk s y := ext fun i => by simp only [sub_apply, mk_apply]; split_ifs <;> [rfl; rw [sub_zero]] #align dfinsupp.mk_sub DFinsupp.mk_sub /-- If `s` is a subset of `ι` then `mk_addGroupHom s` is the canonical additive group homomorphism from $\prod_{i\in s}\beta_i$ to $\prod_{\mathtt{i : \iota}}\beta_i.$-/ def mkAddGroupHom [∀ i, AddGroup (β i)] (s : Finset ι) : (∀ i : (s : Set ι), β ↑i) →+ Π₀ i : ι, β i where toFun := mk s map_zero' := mk_zero map_add' _ _ := mk_add #align dfinsupp.mk_add_group_hom DFinsupp.mkAddGroupHom section variable [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] @[simp] theorem mk_smul {s : Finset ι} (c : γ) (x : ∀ i : (↑s : Set ι), β (i : ι)) : mk s (c • x) = c • mk s x := ext fun i => by simp only [smul_apply, mk_apply]; split_ifs <;> [rfl; rw [smul_zero]] #align dfinsupp.mk_smul DFinsupp.mk_smul @[simp] theorem single_smul {i : ι} (c : γ) (x : β i) : single i (c • x) = c • single i x := ext fun i => by simp only [smul_apply, single_apply] split_ifs with h · cases h; rfl · rw [smul_zero] #align dfinsupp.single_smul DFinsupp.single_smul end section SupportBasic variable [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] /-- Set `{i | f x ≠ 0}` as a `Finset`. -/ def support (f : Π₀ i, β i) : Finset ι := (f.support'.lift fun xs => (Multiset.toFinset xs.1).filter fun i => f i ≠ 0) <| by rintro ⟨sx, hx⟩ ⟨sy, hy⟩ dsimp only [Subtype.coe_mk, toFun_eq_coe] at * ext i; constructor · intro H rcases Finset.mem_filter.1 H with ⟨_, h⟩ exact Finset.mem_filter.2 ⟨Multiset.mem_toFinset.2 <| (hy i).resolve_right h, h⟩ · intro H rcases Finset.mem_filter.1 H with ⟨_, h⟩ exact Finset.mem_filter.2 ⟨Multiset.mem_toFinset.2 <| (hx i).resolve_right h, h⟩ #align dfinsupp.support DFinsupp.support @[simp] theorem support_mk_subset {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i.1} : (mk s x).support ⊆ s := fun _ H => Multiset.mem_toFinset.1 (Finset.mem_filter.1 H).1 #align dfinsupp.support_mk_subset DFinsupp.support_mk_subset @[simp] theorem support_mk'_subset {f : ∀ i, β i} {s : Multiset ι} {h} : (mk' f <| Trunc.mk ⟨s, h⟩).support ⊆ s.toFinset := fun i H => Multiset.mem_toFinset.1 <| by simpa using (Finset.mem_filter.1 H).1 #align dfinsupp.support_mk'_subset DFinsupp.support_mk'_subset @[simp] theorem mem_support_toFun (f : Π₀ i, β i) (i) : i ∈ f.support ↔ f i ≠ 0 := by cases' f with f s induction' s using Trunc.induction_on with s dsimp only [support, Trunc.lift_mk] rw [Finset.mem_filter, Multiset.mem_toFinset, coe_mk'] exact and_iff_right_of_imp (s.prop i).resolve_right #align dfinsupp.mem_support_to_fun DFinsupp.mem_support_toFun theorem eq_mk_support (f : Π₀ i, β i) : f = mk f.support fun i => f i := by aesop #align dfinsupp.eq_mk_support DFinsupp.eq_mk_support /-- Equivalence between dependent functions with finite support `s : Finset ι` and functions `∀ i, {x : β i // x ≠ 0}`. -/ @[simps] def subtypeSupportEqEquiv (s : Finset ι) : {f : Π₀ i, β i // f.support = s} ≃ ∀ i : s, {x : β i // x ≠ 0} where toFun | ⟨f, hf⟩ => fun ⟨i, hi⟩ ↦ ⟨f i, (f.mem_support_toFun i).1 <| hf.symm ▸ hi⟩ invFun f := ⟨mk s fun i ↦ (f i).1, Finset.ext fun i ↦ by -- TODO: `simp` fails to use `(f _).2` inside `∃ _, _` calc i ∈ support (mk s fun i ↦ (f i).1) ↔ ∃ h : i ∈ s, (f ⟨i, h⟩).1 ≠ 0 := by simp _ ↔ ∃ _ : i ∈ s, True := exists_congr fun h ↦ (iff_true _).mpr (f _).2 _ ↔ i ∈ s := by simp⟩ left_inv := by rintro ⟨f, rfl⟩ ext i simpa using Eq.symm right_inv f := by ext1 simp [Subtype.eta]; rfl /-- Equivalence between all dependent finitely supported functions `f : Π₀ i, β i` and type of pairs `⟨s : Finset ι, f : ∀ i : s, {x : β i // x ≠ 0}⟩`. -/ @[simps! apply_fst apply_snd_coe] def sigmaFinsetFunEquiv : (Π₀ i, β i) ≃ Σ s : Finset ι, ∀ i : s, {x : β i // x ≠ 0} := (Equiv.sigmaFiberEquiv DFinsupp.support).symm.trans (.sigmaCongrRight subtypeSupportEqEquiv) @[simp] theorem support_zero : (0 : Π₀ i, β i).support = ∅ := rfl #align dfinsupp.support_zero DFinsupp.support_zero theorem mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∈ f.support ↔ f i ≠ 0 := f.mem_support_toFun _ #align dfinsupp.mem_support_iff DFinsupp.mem_support_iff theorem not_mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∉ f.support ↔ f i = 0 := not_iff_comm.1 mem_support_iff.symm #align dfinsupp.not_mem_support_iff DFinsupp.not_mem_support_iff @[simp] theorem support_eq_empty {f : Π₀ i, β i} : f.support = ∅ ↔ f = 0 := ⟨fun H => ext <| by simpa [Finset.ext_iff] using H, by simp (config := { contextual := true })⟩ #align dfinsupp.support_eq_empty DFinsupp.support_eq_empty instance decidableZero : DecidablePred (Eq (0 : Π₀ i, β i)) := fun _ => decidable_of_iff _ <| support_eq_empty.trans eq_comm #align dfinsupp.decidable_zero DFinsupp.decidableZero theorem support_subset_iff {s : Set ι} {f : Π₀ i, β i} : ↑f.support ⊆ s ↔ ∀ i ∉ s, f i = 0 := by simp [Set.subset_def]; exact forall_congr' fun i => not_imp_comm #align dfinsupp.support_subset_iff DFinsupp.support_subset_iff theorem support_single_ne_zero {i : ι} {b : β i} (hb : b ≠ 0) : (single i b).support = {i} := by ext j; by_cases h : i = j · subst h simp [hb] simp [Ne.symm h, h] #align dfinsupp.support_single_ne_zero DFinsupp.support_single_ne_zero theorem support_single_subset {i : ι} {b : β i} : (single i b).support ⊆ {i} := support_mk'_subset #align dfinsupp.support_single_subset DFinsupp.support_single_subset section MapRangeAndZipWith variable [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)] theorem mapRange_def [∀ (i) (x : β₁ i), Decidable (x ≠ 0)] {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} : mapRange f hf g = mk g.support fun i => f i.1 (g i.1) := by ext i by_cases h : g i ≠ 0 <;> simp at h <;> simp [h, hf] #align dfinsupp.map_range_def DFinsupp.mapRange_def @[simp] theorem mapRange_single {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {i : ι} {b : β₁ i} : mapRange f hf (single i b) = single i (f i b) := DFinsupp.ext fun i' => by by_cases h : i = i' · subst i' simp · simp [h, hf] #align dfinsupp.map_range_single DFinsupp.mapRange_single variable [∀ (i) (x : β₁ i), Decidable (x ≠ 0)] [∀ (i) (x : β₂ i), Decidable (x ≠ 0)] theorem support_mapRange {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} : (mapRange f hf g).support ⊆ g.support := by simp [mapRange_def] #align dfinsupp.support_map_range DFinsupp.support_mapRange theorem zipWith_def {ι : Type u} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂} [dec : DecidableEq ι] [∀ i : ι, Zero (β i)] [∀ i : ι, Zero (β₁ i)] [∀ i : ι, Zero (β₂ i)] [∀ (i : ι) (x : β₁ i), Decidable (x ≠ 0)] [∀ (i : ι) (x : β₂ i), Decidable (x ≠ 0)] {f : ∀ i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0} {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} : zipWith f hf g₁ g₂ = mk (g₁.support ∪ g₂.support) fun i => f i.1 (g₁ i.1) (g₂ i.1) := by ext i by_cases h1 : g₁ i ≠ 0 <;> by_cases h2 : g₂ i ≠ 0 <;> simp only [not_not, Ne] at h1 h2 <;> simp [h1, h2, hf] #align dfinsupp.zip_with_def DFinsupp.zipWith_def theorem support_zipWith {f : ∀ i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0} {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} : (zipWith f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support := by simp [zipWith_def] #align dfinsupp.support_zip_with DFinsupp.support_zipWith end MapRangeAndZipWith theorem erase_def (i : ι) (f : Π₀ i, β i) : f.erase i = mk (f.support.erase i) fun j => f j.1 := by ext j by_cases h1 : j = i <;> by_cases h2 : f j ≠ 0 <;> simp at h2 <;> simp [h1, h2] #align dfinsupp.erase_def DFinsupp.erase_def @[simp] theorem support_erase (i : ι) (f : Π₀ i, β i) : (f.erase i).support = f.support.erase i := by ext j by_cases h1 : j = i · simp only [h1, mem_support_toFun, erase_apply, ite_true, ne_eq, not_true, not_not, Finset.mem_erase, false_and] by_cases h2 : f j ≠ 0 <;> simp at h2 <;> simp [h1, h2] #align dfinsupp.support_erase DFinsupp.support_erase theorem support_update_ne_zero (f : Π₀ i, β i) (i : ι) {b : β i} (h : b ≠ 0) : support (f.update i b) = insert i f.support := by ext j rcases eq_or_ne i j with (rfl | hi) · simp [h] · simp [hi.symm] #align dfinsupp.support_update_ne_zero DFinsupp.support_update_ne_zero theorem support_update (f : Π₀ i, β i) (i : ι) (b : β i) [Decidable (b = 0)] : support (f.update i b) = if b = 0 then support (f.erase i) else insert i f.support := by ext j split_ifs with hb · subst hb simp [update_eq_erase, support_erase] · rw [support_update_ne_zero f _ hb] #align dfinsupp.support_update DFinsupp.support_update section FilterAndSubtypeDomain variable {p : ι → Prop} [DecidablePred p] theorem filter_def (f : Π₀ i, β i) : f.filter p = mk (f.support.filter p) fun i => f i.1 := by ext i; by_cases h1 : p i <;> by_cases h2 : f i ≠ 0 <;> simp at h2 <;> simp [h1, h2] #align dfinsupp.filter_def DFinsupp.filter_def @[simp] theorem support_filter (f : Π₀ i, β i) : (f.filter p).support = f.support.filter p := by ext i; by_cases h : p i <;> simp [h] #align dfinsupp.support_filter DFinsupp.support_filter theorem subtypeDomain_def (f : Π₀ i, β i) : f.subtypeDomain p = mk (f.support.subtype p) fun i => f i := by ext i; by_cases h2 : f i ≠ 0 <;> try simp at h2; dsimp; simp [h2] #align dfinsupp.subtype_domain_def DFinsupp.subtypeDomain_def @[simp, nolint simpNF] -- Porting note: simpNF claims that LHS does not simplify, but it does theorem support_subtypeDomain {f : Π₀ i, β i} : (subtypeDomain p f).support = f.support.subtype p := by ext i simp #align dfinsupp.support_subtype_domain DFinsupp.support_subtypeDomain end FilterAndSubtypeDomain end SupportBasic theorem support_add [∀ i, AddZeroClass (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] {g₁ g₂ : Π₀ i, β i} : (g₁ + g₂).support ⊆ g₁.support ∪ g₂.support := support_zipWith #align dfinsupp.support_add DFinsupp.support_add @[simp] theorem support_neg [∀ i, AddGroup (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] {f : Π₀ i, β i} : support (-f) = support f := by ext i; simp #align dfinsupp.support_neg DFinsupp.support_neg theorem support_smul {γ : Type w} [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] [∀ (i : ι) (x : β i), Decidable (x ≠ 0)] (b : γ) (v : Π₀ i, β i) : (b • v).support ⊆ v.support := support_mapRange #align dfinsupp.support_smul DFinsupp.support_smul instance [∀ i, Zero (β i)] [∀ i, DecidableEq (β i)] : DecidableEq (Π₀ i, β i) := fun f g => decidable_of_iff (f.support = g.support ∧ ∀ i ∈ f.support, f i = g i) ⟨fun ⟨h₁, h₂⟩ => ext fun i => if h : i ∈ f.support then h₂ i h else by have hf : f i = 0 := by rwa [mem_support_iff, not_not] at h have hg : g i = 0 := by rwa [h₁, mem_support_iff, not_not] at h rw [hf, hg], by rintro rfl; simp⟩ section Equiv open Finset variable {κ : Type*} /-- Reindexing (and possibly removing) terms of a dfinsupp. -/ noncomputable def comapDomain [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ i, β i) : Π₀ k, β (h k) where toFun x := f (h x) support' := f.support'.map fun s => ⟨((Multiset.toFinset s.1).preimage h hh.injOn).val, fun x => (s.prop (h x)).imp_left fun hx => mem_preimage.mpr <| Multiset.mem_toFinset.mpr hx⟩ #align dfinsupp.comap_domain DFinsupp.comapDomain @[simp] theorem comapDomain_apply [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ i, β i) (k : κ) : comapDomain h hh f k = f (h k) := rfl #align dfinsupp.comap_domain_apply DFinsupp.comapDomain_apply @[simp] theorem comapDomain_zero [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) : comapDomain h hh (0 : Π₀ i, β i) = 0 := by ext rw [zero_apply, comapDomain_apply, zero_apply] #align dfinsupp.comap_domain_zero DFinsupp.comapDomain_zero @[simp] theorem comapDomain_add [∀ i, AddZeroClass (β i)] (h : κ → ι) (hh : Function.Injective h) (f g : Π₀ i, β i) : comapDomain h hh (f + g) = comapDomain h hh f + comapDomain h hh g := by ext rw [add_apply, comapDomain_apply, comapDomain_apply, comapDomain_apply, add_apply] #align dfinsupp.comap_domain_add DFinsupp.comapDomain_add @[simp] theorem comapDomain_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (h : κ → ι) (hh : Function.Injective h) (r : γ) (f : Π₀ i, β i) : comapDomain h hh (r • f) = r • comapDomain h hh f := by ext rw [smul_apply, comapDomain_apply, smul_apply, comapDomain_apply] #align dfinsupp.comap_domain_smul DFinsupp.comapDomain_smul @[simp] theorem comapDomain_single [DecidableEq κ] [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (k : κ) (x : β (h k)) : comapDomain h hh (single (h k) x) = single k x := by ext i rw [comapDomain_apply] obtain rfl | hik := Decidable.eq_or_ne i k · rw [single_eq_same, single_eq_same] · rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh.ne hik.symm)] #align dfinsupp.comap_domain_single DFinsupp.comapDomain_single /-- A computable version of comap_domain when an explicit left inverse is provided. -/ def comapDomain' [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (f : Π₀ i, β i) : Π₀ k, β (h k) where toFun x := f (h x) support' := f.support'.map fun s => ⟨Multiset.map h' s.1, fun x => (s.prop (h x)).imp_left fun hx => Multiset.mem_map.mpr ⟨_, hx, hh' _⟩⟩ #align dfinsupp.comap_domain' DFinsupp.comapDomain' @[simp] theorem comapDomain'_apply [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (f : Π₀ i, β i) (k : κ) : comapDomain' h hh' f k = f (h k) := rfl #align dfinsupp.comap_domain'_apply DFinsupp.comapDomain'_apply @[simp] theorem comapDomain'_zero [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) : comapDomain' h hh' (0 : Π₀ i, β i) = 0 := by ext rw [zero_apply, comapDomain'_apply, zero_apply] #align dfinsupp.comap_domain'_zero DFinsupp.comapDomain'_zero @[simp] theorem comapDomain'_add [∀ i, AddZeroClass (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (f g : Π₀ i, β i) : comapDomain' h hh' (f + g) = comapDomain' h hh' f + comapDomain' h hh' g := by ext rw [add_apply, comapDomain'_apply, comapDomain'_apply, comapDomain'_apply, add_apply] #align dfinsupp.comap_domain'_add DFinsupp.comapDomain'_add @[simp] theorem comapDomain'_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (r : γ) (f : Π₀ i, β i) : comapDomain' h hh' (r • f) = r • comapDomain' h hh' f := by ext rw [smul_apply, comapDomain'_apply, smul_apply, comapDomain'_apply] #align dfinsupp.comap_domain'_smul DFinsupp.comapDomain'_smul @[simp] theorem comapDomain'_single [DecidableEq ι] [DecidableEq κ] [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (k : κ) (x : β (h k)) : comapDomain' h hh' (single (h k) x) = single k x := by ext i rw [comapDomain'_apply] obtain rfl | hik := Decidable.eq_or_ne i k · rw [single_eq_same, single_eq_same] · rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh'.injective.ne hik.symm)] #align dfinsupp.comap_domain'_single DFinsupp.comapDomain'_single /-- Reindexing terms of a dfinsupp. This is the dfinsupp version of `Equiv.piCongrLeft'`. -/ @[simps apply] def equivCongrLeft [∀ i, Zero (β i)] (h : ι ≃ κ) : (Π₀ i, β i) ≃ Π₀ k, β (h.symm k) where toFun := comapDomain' h.symm h.right_inv invFun f := mapRange (fun i => Equiv.cast <| congr_arg β <| h.symm_apply_apply i) (fun i => (Equiv.cast_eq_iff_heq _).mpr <| by rw [Equiv.symm_apply_apply]) (@comapDomain' _ _ _ _ h _ h.left_inv f) left_inv f := by ext i rw [mapRange_apply, comapDomain'_apply, comapDomain'_apply, Equiv.cast_eq_iff_heq, h.symm_apply_apply] right_inv f := by ext k rw [comapDomain'_apply, mapRange_apply, comapDomain'_apply, Equiv.cast_eq_iff_heq, h.apply_symm_apply] #align dfinsupp.equiv_congr_left DFinsupp.equivCongrLeft #align dfinsupp.equiv_congr_left_apply DFinsupp.equivCongrLeft_apply section SigmaCurry variable {α : ι → Type*} {δ : ∀ i, α i → Type v} -- lean can't find these instances -- Porting note: but Lean 4 can!!! instance hasAdd₂ [∀ i j, AddZeroClass (δ i j)] : Add (Π₀ (i : ι) (j : α i), δ i j) := inferInstance -- @DFinsupp.hasAdd ι (fun i => Π₀ j, δ i j) _ #align dfinsupp.has_add₂ DFinsupp.hasAdd₂ instance addZeroClass₂ [∀ i j, AddZeroClass (δ i j)] : AddZeroClass (Π₀ (i : ι) (j : α i), δ i j) := inferInstance -- @DFinsupp.addZeroClass ι (fun i => Π₀ j, δ i j) _ #align dfinsupp.add_zero_class₂ DFinsupp.addZeroClass₂ instance addMonoid₂ [∀ i j, AddMonoid (δ i j)] : AddMonoid (Π₀ (i : ι) (j : α i), δ i j) := inferInstance -- @DFinsupp.addMonoid ι (fun i => Π₀ j, δ i j) _ #align dfinsupp.add_monoid₂ DFinsupp.addMonoid₂ instance distribMulAction₂ [Monoid γ] [∀ i j, AddMonoid (δ i j)] [∀ i j, DistribMulAction γ (δ i j)] : DistribMulAction γ (Π₀ (i : ι) (j : α i), δ i j) := @DFinsupp.distribMulAction ι _ (fun i => Π₀ j, δ i j) _ _ _ #align dfinsupp.distrib_mul_action₂ DFinsupp.distribMulAction₂ /-- The natural map between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`. -/ def sigmaCurry [∀ i j, Zero (δ i j)] (f : Π₀ (i : Σ _, _), δ i.1 i.2) : Π₀ (i) (j), δ i j where toFun := fun i ↦ { toFun := fun j ↦ f ⟨i, j⟩, support' := f.support'.map (fun ⟨m, hm⟩ ↦ ⟨m.filterMap (fun ⟨i', j'⟩ ↦ if h : i' = i then some <| h.rec j' else none), fun j ↦ (hm ⟨i, j⟩).imp_left (fun h ↦ (m.mem_filterMap _).mpr ⟨⟨i, j⟩, h, dif_pos rfl⟩)⟩) } support' := f.support'.map (fun ⟨m, hm⟩ ↦ ⟨m.map Sigma.fst, fun i ↦ Decidable.or_iff_not_imp_left.mpr (fun h ↦ DFinsupp.ext (fun j ↦ (hm ⟨i, j⟩).resolve_left (fun H ↦ (Multiset.mem_map.not.mp h) ⟨⟨i, j⟩, H, rfl⟩)))⟩) @[simp] theorem sigmaCurry_apply [∀ i j, Zero (δ i j)] (f : Π₀ (i : Σ _, _), δ i.1 i.2) (i : ι) (j : α i) : sigmaCurry f i j = f ⟨i, j⟩ := rfl #align dfinsupp.sigma_curry_apply DFinsupp.sigmaCurry_apply @[simp] theorem sigmaCurry_zero [∀ i j, Zero (δ i j)] : sigmaCurry (0 : Π₀ (i : Σ _, _), δ i.1 i.2) = 0 := rfl #align dfinsupp.sigma_curry_zero DFinsupp.sigmaCurry_zero @[simp] theorem sigmaCurry_add [∀ i j, AddZeroClass (δ i j)] (f g : Π₀ (i : Σ _, _), δ i.1 i.2) : sigmaCurry (f + g) = sigmaCurry f + sigmaCurry g := by ext (i j) rfl #align dfinsupp.sigma_curry_add DFinsupp.sigmaCurry_add @[simp] theorem sigmaCurry_smul [Monoid γ] [∀ i j, AddMonoid (δ i j)] [∀ i j, DistribMulAction γ (δ i j)] (r : γ) (f : Π₀ (i : Σ _, _), δ i.1 i.2) : sigmaCurry (r • f) = r • sigmaCurry f := by ext (i j) rfl #align dfinsupp.sigma_curry_smul DFinsupp.sigmaCurry_smul @[simp] theorem sigmaCurry_single [∀ i, DecidableEq (α i)] [∀ i j, Zero (δ i j)] (ij : Σ i, α i) (x : δ ij.1 ij.2) : sigmaCurry (single ij x) = single ij.1 (single ij.2 x : Π₀ j, δ ij.1 j) := by obtain ⟨i, j⟩ := ij ext i' j' dsimp only rw [sigmaCurry_apply] obtain rfl | hi := eq_or_ne i i' · rw [single_eq_same] obtain rfl | hj := eq_or_ne j j' · rw [single_eq_same, single_eq_same] · rw [single_eq_of_ne, single_eq_of_ne hj] simpa using hj · rw [single_eq_of_ne, single_eq_of_ne hi, zero_apply] simp [hi] #align dfinsupp.sigma_curry_single DFinsupp.sigmaCurry_single /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ /-- The natural map between `Π₀ i (j : α i), δ i j` and `Π₀ (i : Σ i, α i), δ i.1 i.2`, inverse of `curry`. -/ def sigmaUncurry [∀ i j, Zero (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] (f : Π₀ (i) (j), δ i j) : Π₀ i : Σi, _, δ i.1 i.2 where toFun i := f i.1 i.2 support' := f.support'.map fun s => ⟨Multiset.bind s.1 fun i => ((f i).support.map ⟨Sigma.mk i, sigma_mk_injective⟩).val, fun i => by simp_rw [Multiset.mem_bind, map_val, Multiset.mem_map, Function.Embedding.coeFn_mk, ← Finset.mem_def, mem_support_toFun] obtain hi | (hi : f i.1 = 0) := s.prop i.1 · by_cases hi' : f i.1 i.2 = 0 · exact Or.inr hi' · exact Or.inl ⟨_, hi, i.2, hi', Sigma.eta _⟩ · right rw [hi, zero_apply]⟩ #align dfinsupp.sigma_uncurry DFinsupp.sigmaUncurry /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ @[simp] theorem sigmaUncurry_apply [∀ i j, Zero (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] (f : Π₀ (i) (j), δ i j) (i : ι) (j : α i) : sigmaUncurry f ⟨i, j⟩ = f i j := rfl #align dfinsupp.sigma_uncurry_apply DFinsupp.sigmaUncurry_apply /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ @[simp] theorem sigmaUncurry_zero [∀ i j, Zero (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] : sigmaUncurry (0 : Π₀ (i) (j), δ i j) = 0 := rfl #align dfinsupp.sigma_uncurry_zero DFinsupp.sigmaUncurry_zero /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ @[simp] theorem sigmaUncurry_add [∀ i j, AddZeroClass (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] (f g : Π₀ (i) (j), δ i j) : sigmaUncurry (f + g) = sigmaUncurry f + sigmaUncurry g := DFunLike.coe_injective rfl #align dfinsupp.sigma_uncurry_add DFinsupp.sigmaUncurry_add /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ @[simp] theorem sigmaUncurry_smul [Monoid γ] [∀ i j, AddMonoid (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] [∀ i j, DistribMulAction γ (δ i j)] (r : γ) (f : Π₀ (i) (j), δ i j) : sigmaUncurry (r • f) = r • sigmaUncurry f := DFunLike.coe_injective rfl #align dfinsupp.sigma_uncurry_smul DFinsupp.sigmaUncurry_smul @[simp] theorem sigmaUncurry_single [∀ i j, Zero (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] (i) (j : α i) (x : δ i j) : sigmaUncurry (single i (single j x : Π₀ j : α i, δ i j)) = single ⟨i, j⟩ (by exact x) := by ext ⟨i', j'⟩ dsimp only rw [sigmaUncurry_apply] obtain rfl | hi := eq_or_ne i i' · rw [single_eq_same] obtain rfl | hj := eq_or_ne j j' · rw [single_eq_same, single_eq_same] · rw [single_eq_of_ne hj, single_eq_of_ne] simpa using hj · rw [single_eq_of_ne hi, single_eq_of_ne, zero_apply] simp [hi] #align dfinsupp.sigma_uncurry_single DFinsupp.sigmaUncurry_single /- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/ /-- The natural bijection between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`. This is the dfinsupp version of `Equiv.piCurry`. -/ def sigmaCurryEquiv [∀ i j, Zero (δ i j)] [∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] : (Π₀ i : Σi, _, δ i.1 i.2) ≃ Π₀ (i) (j), δ i j where toFun := sigmaCurry invFun := sigmaUncurry left_inv f := by ext ⟨i, j⟩ rw [sigmaUncurry_apply, sigmaCurry_apply] right_inv f := by ext i j rw [sigmaCurry_apply, sigmaUncurry_apply] #align dfinsupp.sigma_curry_equiv DFinsupp.sigmaCurryEquiv end SigmaCurry variable {α : Option ι → Type v} /-- Adds a term to a dfinsupp, making a dfinsupp indexed by an `Option`. This is the dfinsupp version of `Option.rec`. -/ def extendWith [∀ i, Zero (α i)] (a : α none) (f : Π₀ i, α (some i)) : Π₀ i, α i where toFun := fun i ↦ match i with | none => a | some _ => f _ support' := f.support'.map fun s => ⟨none ::ₘ Multiset.map some s.1, fun i => Option.rec (Or.inl <| Multiset.mem_cons_self _ _) (fun i => (s.prop i).imp_left fun h => Multiset.mem_cons_of_mem <| Multiset.mem_map_of_mem _ h) i⟩ #align dfinsupp.extend_with DFinsupp.extendWith @[simp] theorem extendWith_none [∀ i, Zero (α i)] (f : Π₀ i, α (some i)) (a : α none) : f.extendWith a none = a := rfl #align dfinsupp.extend_with_none DFinsupp.extendWith_none @[simp] theorem extendWith_some [∀ i, Zero (α i)] (f : Π₀ i, α (some i)) (a : α none) (i : ι) : f.extendWith a (some i) = f i := rfl #align dfinsupp.extend_with_some DFinsupp.extendWith_some @[simp] theorem extendWith_single_zero [DecidableEq ι] [∀ i, Zero (α i)] (i : ι) (x : α (some i)) : (single i x).extendWith 0 = single (some i) x := by ext (_ | j) · rw [extendWith_none, single_eq_of_ne (Option.some_ne_none _)] · rw [extendWith_some] obtain rfl | hij := Decidable.eq_or_ne i j · rw [single_eq_same, single_eq_same] · rw [single_eq_of_ne hij, single_eq_of_ne ((Option.some_injective _).ne hij)] #align dfinsupp.extend_with_single_zero DFinsupp.extendWith_single_zero @[simp]
Mathlib/Data/DFinsupp/Basic.lean
1,648
1,652
theorem extendWith_zero [DecidableEq ι] [∀ i, Zero (α i)] (x : α none) : (0 : Π₀ i, α (some i)).extendWith x = single none x := by
ext (_ | j) · rw [extendWith_none, single_eq_same] · rw [extendWith_some, single_eq_of_ne (Option.some_ne_none _).symm, zero_apply]
/- Copyright (c) 2021 Thomas Browning. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Thomas Browning -/ import Mathlib.Data.ZMod.Quotient #align_import group_theory.complement from "leanprover-community/mathlib"@"6ca1a09bc9aa75824bf97388c9e3b441fc4ccf3f" /-! # Complements In this file we define the complement of a subgroup. ## Main definitions - `IsComplement S T` where `S` and `T` are subsets of `G` states that every `g : G` can be written uniquely as a product `s * t` for `s ∈ S`, `t ∈ T`. - `leftTransversals T` where `T` is a subset of `G` is the set of all left-complements of `T`, i.e. the set of all `S : Set G` that contain exactly one element of each left coset of `T`. - `rightTransversals S` where `S` is a subset of `G` is the set of all right-complements of `S`, i.e. the set of all `T : Set G` that contain exactly one element of each right coset of `S`. - `transferTransversal H g` is a specific `leftTransversal` of `H` that is used in the computation of the transfer homomorphism evaluated at an element `g : G`. ## Main results - `isComplement'_of_coprime` : Subgroups of coprime order are complements. -/ open Set open scoped Pointwise namespace Subgroup variable {G : Type*} [Group G] (H K : Subgroup G) (S T : Set G) /-- `S` and `T` are complements if `(*) : S × T → G` is a bijection. This notion generalizes left transversals, right transversals, and complementary subgroups. -/ @[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 /-- `H` and `K` are complements if `(*) : H × K → G` is a bijection -/ @[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' /-- The set of left-complements of `T : Set G` -/ @[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 /-- The set of right-complements of `S : Set G` -/ @[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 /-- Given two subgroups `H' ⊆ H`, there exists a left transversal to `H'` inside `H`. -/ @[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 /-- Given two subgroups `H' ⊆ H`, there exists a right transversal to `H'` inside `H`. -/ @[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 /-- The equivalence `G ≃ S × T`, such that the inverse is `(*) : S × T → G` -/ 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] 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] theorem coe_equiv_fst_eq_one_iff_mem {g : G} (h1 : 1 ∈ S) : ((hST.equiv g).fst : G) = 1 ↔ g ∈ T := by rw [equiv_fst_eq_mul_inv, mul_inv_eq_one, eq_comm, equiv_snd_eq_self_iff_mem _ h1] theorem coe_equiv_snd_eq_one_iff_mem {g : G} (h1 : 1 ∈ T) : ((hST.equiv g).snd : G) = 1 ↔ g ∈ S := by rw [equiv_snd_eq_inv_mul, inv_mul_eq_one, equiv_fst_eq_self_iff_mem _ h1] end IsComplement namespace MemLeftTransversals /-- A left transversal is in bijection with left cosets. -/ @[to_additive "A left transversal is in bijection with left cosets."] noncomputable def toEquiv (hS : S ∈ Subgroup.leftTransversals (H : Set G)) : G ⧸ H ≃ S := (Equiv.ofBijective _ (Subgroup.mem_leftTransversals_iff_bijective.mp hS)).symm #align subgroup.mem_left_transversals.to_equiv Subgroup.MemLeftTransversals.toEquiv #align add_subgroup.mem_left_transversals.to_equiv AddSubgroup.MemLeftTransversals.toEquiv @[to_additive] theorem mk''_toEquiv (hS : S ∈ Subgroup.leftTransversals (H : Set G)) (q : G ⧸ H) : Quotient.mk'' (toEquiv hS q : G) = q := (toEquiv hS).symm_apply_apply q #align subgroup.mem_left_transversals.mk'_to_equiv Subgroup.MemLeftTransversals.mk''_toEquiv #align add_subgroup.mem_left_transversals.mk'_to_equiv AddSubgroup.MemLeftTransversals.mk''_toEquiv @[to_additive] theorem toEquiv_apply {f : G ⧸ H → G} (hf : ∀ q, (f q : G ⧸ H) = q) (q : G ⧸ H) : (toEquiv (range_mem_leftTransversals hf) q : G) = f q := by refine (Subtype.ext_iff.mp ?_).trans (Subtype.coe_mk (f q) ⟨q, rfl⟩) exact (toEquiv (range_mem_leftTransversals hf)).apply_eq_iff_eq_symm_apply.mpr (hf q).symm #align subgroup.mem_left_transversals.to_equiv_apply Subgroup.MemLeftTransversals.toEquiv_apply #align add_subgroup.mem_left_transversals.to_equiv_apply AddSubgroup.MemLeftTransversals.toEquiv_apply /-- A left transversal can be viewed as a function mapping each element of the group to the chosen representative from that left coset. -/ @[to_additive "A left transversal can be viewed as a function mapping each element of the group to the chosen representative from that left coset."] noncomputable def toFun (hS : S ∈ Subgroup.leftTransversals (H : Set G)) : G → S := toEquiv hS ∘ Quotient.mk'' #align subgroup.mem_left_transversals.to_fun Subgroup.MemLeftTransversals.toFun #align add_subgroup.mem_left_transversals.to_fun AddSubgroup.MemLeftTransversals.toFun @[to_additive] theorem inv_toFun_mul_mem (hS : S ∈ Subgroup.leftTransversals (H : Set G)) (g : G) : (toFun hS g : G)⁻¹ * g ∈ H := QuotientGroup.leftRel_apply.mp <| Quotient.exact' <| mk''_toEquiv _ _ #align subgroup.mem_left_transversals.inv_to_fun_mul_mem Subgroup.MemLeftTransversals.inv_toFun_mul_mem #align add_subgroup.mem_left_transversals.neg_to_fun_add_mem AddSubgroup.MemLeftTransversals.neg_toFun_add_mem @[to_additive] theorem inv_mul_toFun_mem (hS : S ∈ Subgroup.leftTransversals (H : Set G)) (g : G) : g⁻¹ * toFun hS g ∈ H := (congr_arg (· ∈ H) (by rw [mul_inv_rev, inv_inv])).mp (H.inv_mem (inv_toFun_mul_mem hS g)) #align subgroup.mem_left_transversals.inv_mul_to_fun_mem Subgroup.MemLeftTransversals.inv_mul_toFun_mem #align add_subgroup.mem_left_transversals.neg_add_to_fun_mem AddSubgroup.MemLeftTransversals.neg_add_toFun_mem end MemLeftTransversals namespace MemRightTransversals /-- A right transversal is in bijection with right cosets. -/ @[to_additive "A right transversal is in bijection with right cosets."] noncomputable def toEquiv (hS : S ∈ Subgroup.rightTransversals (H : Set G)) : Quotient (QuotientGroup.rightRel H) ≃ S := (Equiv.ofBijective _ (Subgroup.mem_rightTransversals_iff_bijective.mp hS)).symm #align subgroup.mem_right_transversals.to_equiv Subgroup.MemRightTransversals.toEquiv #align add_subgroup.mem_right_transversals.to_equiv AddSubgroup.MemRightTransversals.toEquiv @[to_additive] theorem mk''_toEquiv (hS : S ∈ Subgroup.rightTransversals (H : Set G)) (q : Quotient (QuotientGroup.rightRel H)) : Quotient.mk'' (toEquiv hS q : G) = q := (toEquiv hS).symm_apply_apply q #align subgroup.mem_right_transversals.mk'_to_equiv Subgroup.MemRightTransversals.mk''_toEquiv #align add_subgroup.mem_right_transversals.mk'_to_equiv AddSubgroup.MemRightTransversals.mk''_toEquiv @[to_additive] theorem toEquiv_apply {f : Quotient (QuotientGroup.rightRel H) → G} (hf : ∀ q, Quotient.mk'' (f q) = q) (q : Quotient (QuotientGroup.rightRel H)) : (toEquiv (range_mem_rightTransversals hf) q : G) = f q := by refine (Subtype.ext_iff.mp ?_).trans (Subtype.coe_mk (f q) ⟨q, rfl⟩) exact (toEquiv (range_mem_rightTransversals hf)).apply_eq_iff_eq_symm_apply.mpr (hf q).symm #align subgroup.mem_right_transversals.to_equiv_apply Subgroup.MemRightTransversals.toEquiv_apply #align add_subgroup.mem_right_transversals.to_equiv_apply AddSubgroup.MemRightTransversals.toEquiv_apply /-- A right transversal can be viewed as a function mapping each element of the group to the chosen representative from that right coset. -/ @[to_additive "A right transversal can be viewed as a function mapping each element of the group to the chosen representative from that right coset."] noncomputable def toFun (hS : S ∈ Subgroup.rightTransversals (H : Set G)) : G → S := toEquiv hS ∘ Quotient.mk'' #align subgroup.mem_right_transversals.to_fun Subgroup.MemRightTransversals.toFun #align add_subgroup.mem_right_transversals.to_fun AddSubgroup.MemRightTransversals.toFun @[to_additive] theorem mul_inv_toFun_mem (hS : S ∈ Subgroup.rightTransversals (H : Set G)) (g : G) : g * (toFun hS g : G)⁻¹ ∈ H := QuotientGroup.rightRel_apply.mp <| Quotient.exact' <| mk''_toEquiv _ _ #align subgroup.mem_right_transversals.mul_inv_to_fun_mem Subgroup.MemRightTransversals.mul_inv_toFun_mem #align add_subgroup.mem_right_transversals.add_neg_to_fun_mem AddSubgroup.MemRightTransversals.add_neg_toFun_mem @[to_additive] theorem toFun_mul_inv_mem (hS : S ∈ Subgroup.rightTransversals (H : Set G)) (g : G) : (toFun hS g : G) * g⁻¹ ∈ H := (congr_arg (· ∈ H) (by rw [mul_inv_rev, inv_inv])).mp (H.inv_mem (mul_inv_toFun_mem hS g)) #align subgroup.mem_right_transversals.to_fun_mul_inv_mem Subgroup.MemRightTransversals.toFun_mul_inv_mem #align add_subgroup.mem_right_transversals.to_fun_add_neg_mem AddSubgroup.MemRightTransversals.toFun_add_neg_mem end MemRightTransversals section Action open Pointwise MulAction MemLeftTransversals variable {F : Type*} [Group F] [MulAction F G] [QuotientAction F H] @[to_additive] noncomputable instance : MulAction F (leftTransversals (H : Set G)) where smul f T := ⟨f • (T : Set G), by refine mem_leftTransversals_iff_existsUnique_inv_mul_mem.mpr fun g => ?_ obtain ⟨t, ht1, ht2⟩ := mem_leftTransversals_iff_existsUnique_inv_mul_mem.mp T.2 (f⁻¹ • g) refine ⟨⟨f • (t : G), Set.smul_mem_smul_set t.2⟩, ?_, ?_⟩ · exact smul_inv_smul f g ▸ QuotientAction.inv_mul_mem f ht1 · rintro ⟨-, t', ht', rfl⟩ h replace h := QuotientAction.inv_mul_mem f⁻¹ h simp only [Subtype.ext_iff, Subtype.coe_mk, smul_left_cancel_iff, inv_smul_smul] at h ⊢ exact Subtype.ext_iff.mp (ht2 ⟨t', ht'⟩ h)⟩ one_smul T := Subtype.ext (one_smul F (T : Set G)) mul_smul f₁ f₂ T := Subtype.ext (mul_smul f₁ f₂ (T : Set G)) @[to_additive] theorem smul_toFun (f : F) (T : leftTransversals (H : Set G)) (g : G) : (f • (toFun T.2 g : G)) = toFun (f • T).2 (f • g) := Subtype.ext_iff.mp <| @ExistsUnique.unique (↥(f • (T : Set G))) (fun s => (↑s)⁻¹ * f • g ∈ H) (mem_leftTransversals_iff_existsUnique_inv_mul_mem.mp (f • T).2 (f • g)) ⟨f • (toFun T.2 g : G), Set.smul_mem_smul_set (Subtype.coe_prop _)⟩ (toFun (f • T).2 (f • g)) (QuotientAction.inv_mul_mem f (inv_toFun_mul_mem T.2 g)) (inv_toFun_mul_mem (f • T).2 (f • g)) #align subgroup.smul_to_fun Subgroup.smul_toFun #align add_subgroup.vadd_to_fun AddSubgroup.vadd_toFun @[to_additive] theorem smul_toEquiv (f : F) (T : leftTransversals (H : Set G)) (q : G ⧸ H) : f • (toEquiv T.2 q : G) = toEquiv (f • T).2 (f • q) := Quotient.inductionOn' q fun g => smul_toFun f T g #align subgroup.smul_to_equiv Subgroup.smul_toEquiv #align add_subgroup.vadd_to_equiv AddSubgroup.vadd_toEquiv @[to_additive] theorem smul_apply_eq_smul_apply_inv_smul (f : F) (T : leftTransversals (H : Set G)) (q : G ⧸ H) : (toEquiv (f • T).2 q : G) = f • (toEquiv T.2 (f⁻¹ • q) : G) := by rw [smul_toEquiv, smul_inv_smul] #align subgroup.smul_apply_eq_smul_apply_inv_smul Subgroup.smul_apply_eq_smul_apply_inv_smul #align add_subgroup.vadd_apply_eq_vadd_apply_neg_vadd AddSubgroup.vadd_apply_eq_vadd_apply_neg_vadd end Action @[to_additive] instance : Inhabited (leftTransversals (H : Set G)) := ⟨⟨Set.range Quotient.out', range_mem_leftTransversals Quotient.out_eq'⟩⟩ @[to_additive] instance : Inhabited (rightTransversals (H : Set G)) := ⟨⟨Set.range Quotient.out', range_mem_rightTransversals Quotient.out_eq'⟩⟩ theorem IsComplement'.isCompl (h : IsComplement' H K) : IsCompl H K := by refine ⟨disjoint_iff_inf_le.mpr fun g ⟨p, q⟩ => let x : H × K := ⟨⟨g, p⟩, 1⟩ let y : H × K := ⟨1, g, q⟩ Subtype.ext_iff.mp (Prod.ext_iff.mp (show x = y from h.1 ((mul_one g).trans (one_mul g).symm))).1, codisjoint_iff_le_sup.mpr fun g _ => ?_⟩ obtain ⟨⟨h, k⟩, rfl⟩ := h.2 g exact Subgroup.mul_mem_sup h.2 k.2 #align subgroup.is_complement'.is_compl Subgroup.IsComplement'.isCompl theorem IsComplement'.sup_eq_top (h : IsComplement' H K) : H ⊔ K = ⊤ := h.isCompl.sup_eq_top #align subgroup.is_complement'.sup_eq_top Subgroup.IsComplement'.sup_eq_top theorem IsComplement'.disjoint (h : IsComplement' H K) : Disjoint H K := h.isCompl.disjoint #align subgroup.is_complement'.disjoint Subgroup.IsComplement'.disjoint theorem IsComplement'.index_eq_card (h : IsComplement' H K) : K.index = Nat.card H := (card_left_transversal h).symm #align subgroup.is_complement'.index_eq_card Subgroup.IsComplement'.index_eq_card theorem IsComplement.card_mul [Fintype G] [Fintype S] [Fintype T] (h : IsComplement S T) : Fintype.card S * Fintype.card T = Fintype.card G := (Fintype.card_prod _ _).symm.trans (Fintype.card_of_bijective h) #align subgroup.is_complement.card_mul Subgroup.IsComplement.card_mul theorem IsComplement'.card_mul [Fintype G] [Fintype H] [Fintype K] (h : IsComplement' H K) : Fintype.card H * Fintype.card K = Fintype.card G := IsComplement.card_mul h #align subgroup.is_complement'.card_mul Subgroup.IsComplement'.card_mul theorem isComplement'_of_disjoint_and_mul_eq_univ (h1 : Disjoint H K) (h2 : ↑H * ↑K = (Set.univ : Set G)) : IsComplement' H K := by refine ⟨mul_injective_of_disjoint h1, fun g => ?_⟩ obtain ⟨h, hh, k, hk, hg⟩ := Set.eq_univ_iff_forall.mp h2 g exact ⟨(⟨h, hh⟩, ⟨k, hk⟩), hg⟩ #align subgroup.is_complement'_of_disjoint_and_mul_eq_univ Subgroup.isComplement'_of_disjoint_and_mul_eq_univ theorem isComplement'_of_card_mul_and_disjoint [Fintype G] [Fintype H] [Fintype K] (h1 : Fintype.card H * Fintype.card K = Fintype.card G) (h2 : Disjoint H K) : IsComplement' H K := (Fintype.bijective_iff_injective_and_card _).mpr ⟨mul_injective_of_disjoint h2, (Fintype.card_prod H K).trans h1⟩ #align subgroup.is_complement'_of_card_mul_and_disjoint Subgroup.isComplement'_of_card_mul_and_disjoint theorem isComplement'_iff_card_mul_and_disjoint [Fintype G] [Fintype H] [Fintype K] : IsComplement' H K ↔ Fintype.card H * Fintype.card K = Fintype.card G ∧ Disjoint H K := ⟨fun h => ⟨h.card_mul, h.disjoint⟩, fun h => isComplement'_of_card_mul_and_disjoint h.1 h.2⟩ #align subgroup.is_complement'_iff_card_mul_and_disjoint Subgroup.isComplement'_iff_card_mul_and_disjoint theorem isComplement'_of_coprime [Fintype G] [Fintype H] [Fintype K] (h1 : Fintype.card H * Fintype.card K = Fintype.card G) (h2 : Nat.Coprime (Fintype.card H) (Fintype.card K)) : IsComplement' H K := isComplement'_of_card_mul_and_disjoint h1 (disjoint_iff.mpr (inf_eq_bot_of_coprime h2)) #align subgroup.is_complement'_of_coprime Subgroup.isComplement'_of_coprime theorem isComplement'_stabilizer {α : Type*} [MulAction G α] (a : α) (h1 : ∀ h : H, h • a = a → h = 1) (h2 : ∀ g : G, ∃ h : H, h • g • a = a) : IsComplement' H (MulAction.stabilizer G a) := by refine isComplement_iff_existsUnique.mpr fun g => ?_ obtain ⟨h, hh⟩ := h2 g have hh' : (↑h * g) • a = a := by rwa [mul_smul] refine ⟨⟨h⁻¹, h * g, hh'⟩, inv_mul_cancel_left ↑h g, ?_⟩ rintro ⟨h', g, hg : g • a = a⟩ rfl specialize h1 (h * h') (by rwa [mul_smul, smul_def h', ← hg, ← mul_smul, hg]) refine Prod.ext (eq_inv_of_mul_eq_one_right h1) (Subtype.ext ?_) rwa [Subtype.ext_iff, coe_one, coe_mul, ← self_eq_mul_left, mul_assoc (↑h) (↑h') g] at h1 #align subgroup.is_complement'_stabilizer Subgroup.isComplement'_stabilizer end Subgroup namespace Subgroup open Equiv Function MemLeftTransversals MulAction MulAction.quotient ZMod universe u variable {G : Type u} [Group G] (H : Subgroup G) (g : G) /-- Partition `G ⧸ H` into orbits of the action of `g : G`. -/ noncomputable def quotientEquivSigmaZMod : G ⧸ H ≃ Σq : orbitRel.Quotient (zpowers g) (G ⧸ H), ZMod (minimalPeriod (g • ·) q.out') := (selfEquivSigmaOrbits (zpowers g) (G ⧸ H)).trans (sigmaCongrRight fun q => orbitZPowersEquiv g q.out') #align subgroup.quotient_equiv_sigma_zmod Subgroup.quotientEquivSigmaZMod theorem quotientEquivSigmaZMod_symm_apply (q : orbitRel.Quotient (zpowers g) (G ⧸ H)) (k : ZMod (minimalPeriod (g • ·) q.out')) : (quotientEquivSigmaZMod H g).symm ⟨q, k⟩ = g ^ (cast k : ℤ) • q.out' := rfl #align subgroup.quotient_equiv_sigma_zmod_symm_apply Subgroup.quotientEquivSigmaZMod_symm_apply theorem quotientEquivSigmaZMod_apply (q : orbitRel.Quotient (zpowers g) (G ⧸ H)) (k : ℤ) : quotientEquivSigmaZMod H g (g ^ k • q.out') = ⟨q, k⟩ := by rw [apply_eq_iff_eq_symm_apply, quotientEquivSigmaZMod_symm_apply, ZMod.coe_intCast, zpow_smul_mod_minimalPeriod] #align subgroup.quotient_equiv_sigma_zmod_apply Subgroup.quotientEquivSigmaZMod_apply /-- The transfer transversal as a function. Given a `⟨g⟩`-orbit `q₀, g • q₀, ..., g ^ (m - 1) • q₀` in `G ⧸ H`, an element `g ^ k • q₀` is mapped to `g ^ k • g₀` for a fixed choice of representative `g₀` of `q₀`. -/ noncomputable def transferFunction : G ⧸ H → G := fun q => g ^ (cast (quotientEquivSigmaZMod H g q).2 : ℤ) * (quotientEquivSigmaZMod H g q).1.out'.out' #align subgroup.transfer_function Subgroup.transferFunction theorem transferFunction_apply (q : G ⧸ H) : transferFunction H g q = g ^ (cast (quotientEquivSigmaZMod H g q).2 : ℤ) * (quotientEquivSigmaZMod H g q).1.out'.out' := rfl #align subgroup.transfer_function_apply Subgroup.transferFunction_apply theorem coe_transferFunction (q : G ⧸ H) : ↑(transferFunction H g q) = q := by rw [transferFunction_apply, ← smul_eq_mul, Quotient.coe_smul_out', ← quotientEquivSigmaZMod_symm_apply, Sigma.eta, symm_apply_apply] #align subgroup.coe_transfer_function Subgroup.coe_transferFunction /-- The transfer transversal as a set. Contains elements of the form `g ^ k • g₀` for fixed choices of representatives `g₀` of fixed choices of representatives `q₀` of `⟨g⟩`-orbits in `G ⧸ H`. -/ def transferSet : Set G := Set.range (transferFunction H g) #align subgroup.transfer_set Subgroup.transferSet theorem mem_transferSet (q : G ⧸ H) : transferFunction H g q ∈ transferSet H g := ⟨q, rfl⟩ #align subgroup.mem_transfer_set Subgroup.mem_transferSet /-- The transfer transversal. Contains elements of the form `g ^ k • g₀` for fixed choices of representatives `g₀` of fixed choices of representatives `q₀` of `⟨g⟩`-orbits in `G ⧸ H`. -/ def transferTransversal : leftTransversals (H : Set G) := ⟨transferSet H g, range_mem_leftTransversals (coe_transferFunction H g)⟩ #align subgroup.transfer_transversal Subgroup.transferTransversal theorem transferTransversal_apply (q : G ⧸ H) : ↑(toEquiv (transferTransversal H g).2 q) = transferFunction H g q := toEquiv_apply (coe_transferFunction H g) q #align subgroup.transfer_transversal_apply Subgroup.transferTransversal_apply
Mathlib/GroupTheory/Complement.lean
820
825
theorem transferTransversal_apply' (q : orbitRel.Quotient (zpowers g) (G ⧸ H)) (k : ZMod (minimalPeriod (g • ·) q.out')) : ↑(toEquiv (transferTransversal H g).2 (g ^ (cast k : ℤ) • q.out')) = g ^ (cast k : ℤ) * q.out'.out' := by
rw [transferTransversal_apply, transferFunction_apply, ← quotientEquivSigmaZMod_symm_apply, apply_symm_apply]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky -/ import Mathlib.Data.List.Cycle import Mathlib.GroupTheory.Perm.Cycle.Type import Mathlib.GroupTheory.Perm.List #align_import group_theory.perm.cycle.concrete from "leanprover-community/mathlib"@"00638177efd1b2534fc5269363ebf42a7871df9a" /-! # Properties of cyclic permutations constructed from lists/cycles In the following, `{α : Type*} [Fintype α] [DecidableEq α]`. ## Main definitions * `Cycle.formPerm`: the cyclic permutation created by looping over a `Cycle α` * `Equiv.Perm.toList`: the list formed by iterating application of a permutation * `Equiv.Perm.toCycle`: the cycle formed by iterating application of a permutation * `Equiv.Perm.isoCycle`: the equivalence between cyclic permutations `f : Perm α` and the terms of `Cycle α` that correspond to them * `Equiv.Perm.isoCycle'`: the same equivalence as `Equiv.Perm.isoCycle` but with evaluation via choosing over fintypes * The notation `c[1, 2, 3]` to emulate notation of cyclic permutations `(1 2 3)` * A `Repr` instance for any `Perm α`, by representing the `Finset` of `Cycle α` that correspond to the cycle factors. ## Main results * `List.isCycle_formPerm`: a nontrivial list without duplicates, when interpreted as a permutation, is cyclic * `Equiv.Perm.IsCycle.existsUnique_cycle`: there is only one nontrivial `Cycle α` corresponding to each cyclic `f : Perm α` ## Implementation details The forward direction of `Equiv.Perm.isoCycle'` uses `Fintype.choose` of the uniqueness result, relying on the `Fintype` instance of a `Cycle.nodup` subtype. It is unclear if this works faster than the `Equiv.Perm.toCycle`, which relies on recursion over `Finset.univ`. Running `#eval` on even a simple noncyclic permutation `c[(1 : Fin 7), 2, 3] * c[0, 5]` to show it takes a long time. TODO: is this because computing the cycle factors is slow? -/ open Equiv Equiv.Perm List variable {α : Type*} namespace List variable [DecidableEq α] {l l' : List α} theorem formPerm_disjoint_iff (hl : Nodup l) (hl' : Nodup l') (hn : 2 ≤ l.length) (hn' : 2 ≤ l'.length) : Perm.Disjoint (formPerm l) (formPerm l') ↔ l.Disjoint l' := by rw [disjoint_iff_eq_or_eq, List.Disjoint] constructor · rintro h x hx hx' specialize h x rw [formPerm_apply_mem_eq_self_iff _ hl _ hx, formPerm_apply_mem_eq_self_iff _ hl' _ hx'] at h omega · intro h x by_cases hx : x ∈ l on_goal 1 => by_cases hx' : x ∈ l' · exact (h hx hx').elim all_goals have := formPerm_eq_self_of_not_mem _ _ ‹_›; tauto #align list.form_perm_disjoint_iff List.formPerm_disjoint_iff theorem isCycle_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) : IsCycle (formPerm l) := by cases' l with x l · set_option tactic.skipAssignedInstances false in norm_num at hn induction' l with y l generalizing x · set_option tactic.skipAssignedInstances false in norm_num at hn · use x constructor · rwa [formPerm_apply_mem_ne_self_iff _ hl _ (mem_cons_self _ _)] · intro w hw have : w ∈ x::y::l := mem_of_formPerm_ne_self _ _ hw obtain ⟨k, hk⟩ := get_of_mem this use k rw [← hk] simp only [zpow_natCast, formPerm_pow_apply_head _ _ hl k, Nat.mod_eq_of_lt k.isLt] #align list.is_cycle_form_perm List.isCycle_formPerm theorem pairwise_sameCycle_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) : Pairwise l.formPerm.SameCycle l := Pairwise.imp_mem.mpr (pairwise_of_forall fun _ _ hx hy => (isCycle_formPerm hl hn).sameCycle ((formPerm_apply_mem_ne_self_iff _ hl _ hx).mpr hn) ((formPerm_apply_mem_ne_self_iff _ hl _ hy).mpr hn)) #align list.pairwise_same_cycle_form_perm List.pairwise_sameCycle_formPerm theorem cycleOf_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) (x) : cycleOf l.attach.formPerm x = l.attach.formPerm := have hn : 2 ≤ l.attach.length := by rwa [← length_attach] at hn have hl : l.attach.Nodup := by rwa [← nodup_attach] at hl (isCycle_formPerm hl hn).cycleOf_eq ((formPerm_apply_mem_ne_self_iff _ hl _ (mem_attach _ _)).mpr hn) #align list.cycle_of_form_perm List.cycleOf_formPerm theorem cycleType_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) : cycleType l.attach.formPerm = {l.length} := by rw [← length_attach] at hn rw [← nodup_attach] at hl rw [cycleType_eq [l.attach.formPerm]] · simp only [map, Function.comp_apply] rw [support_formPerm_of_nodup _ hl, card_toFinset, dedup_eq_self.mpr hl] · simp · intro x h simp [h, Nat.succ_le_succ_iff] at hn · simp · simpa using isCycle_formPerm hl hn · simp #align list.cycle_type_form_perm List.cycleType_formPerm theorem formPerm_apply_mem_eq_next (hl : Nodup l) (x : α) (hx : x ∈ l) : formPerm l x = next l x hx := by obtain ⟨k, rfl⟩ := get_of_mem hx rw [next_get _ hl, formPerm_apply_get _ hl] #align list.form_perm_apply_mem_eq_next List.formPerm_apply_mem_eq_next end List namespace Cycle variable [DecidableEq α] (s s' : Cycle α) /-- A cycle `s : Cycle α`, given `Nodup s` can be interpreted as an `Equiv.Perm α` where each element in the list is permuted to the next one, defined as `formPerm`. -/ def formPerm : ∀ s : Cycle α, Nodup s → Equiv.Perm α := fun s => Quotient.hrecOn s (fun l _ => List.formPerm l) fun l₁ l₂ (h : l₁ ~r l₂) => by apply Function.hfunext · ext exact h.nodup_iff · intro h₁ h₂ _ exact heq_of_eq (formPerm_eq_of_isRotated h₁ h) #align cycle.form_perm Cycle.formPerm @[simp] theorem formPerm_coe (l : List α) (hl : l.Nodup) : formPerm (l : Cycle α) hl = l.formPerm := rfl #align cycle.form_perm_coe Cycle.formPerm_coe theorem formPerm_subsingleton (s : Cycle α) (h : Subsingleton s) : formPerm s h.nodup = 1 := by induction' s using Quot.inductionOn with s simp only [formPerm_coe, mk_eq_coe] simp only [length_subsingleton_iff, length_coe, mk_eq_coe] at h cases' s with hd tl · simp · simp only [length_eq_zero, add_le_iff_nonpos_left, List.length, nonpos_iff_eq_zero] at h simp [h] #align cycle.form_perm_subsingleton Cycle.formPerm_subsingleton theorem isCycle_formPerm (s : Cycle α) (h : Nodup s) (hn : Nontrivial s) : IsCycle (formPerm s h) := by induction s using Quot.inductionOn exact List.isCycle_formPerm h (length_nontrivial hn) #align cycle.is_cycle_form_perm Cycle.isCycle_formPerm theorem support_formPerm [Fintype α] (s : Cycle α) (h : Nodup s) (hn : Nontrivial s) : support (formPerm s h) = s.toFinset := by induction' s using Quot.inductionOn with s refine support_formPerm_of_nodup s h ?_ rintro _ rfl simpa [Nat.succ_le_succ_iff] using length_nontrivial hn #align cycle.support_form_perm Cycle.support_formPerm theorem formPerm_eq_self_of_not_mem (s : Cycle α) (h : Nodup s) (x : α) (hx : x ∉ s) : formPerm s h x = x := by induction s using Quot.inductionOn simpa using List.formPerm_eq_self_of_not_mem _ _ hx #align cycle.form_perm_eq_self_of_not_mem Cycle.formPerm_eq_self_of_not_mem theorem formPerm_apply_mem_eq_next (s : Cycle α) (h : Nodup s) (x : α) (hx : x ∈ s) : formPerm s h x = next s h x hx := by induction s using Quot.inductionOn simpa using List.formPerm_apply_mem_eq_next h _ (by simp_all) #align cycle.form_perm_apply_mem_eq_next Cycle.formPerm_apply_mem_eq_next nonrec theorem formPerm_reverse (s : Cycle α) (h : Nodup s) : formPerm s.reverse (nodup_reverse_iff.mpr h) = (formPerm s h)⁻¹ := by induction s using Quot.inductionOn simpa using formPerm_reverse _ #align cycle.form_perm_reverse Cycle.formPerm_reverse nonrec theorem formPerm_eq_formPerm_iff {α : Type*} [DecidableEq α] {s s' : Cycle α} {hs : s.Nodup} {hs' : s'.Nodup} : s.formPerm hs = s'.formPerm hs' ↔ s = s' ∨ s.Subsingleton ∧ s'.Subsingleton := by rw [Cycle.length_subsingleton_iff, Cycle.length_subsingleton_iff] revert s s' intro s s' apply @Quotient.inductionOn₂' _ _ _ _ _ s s' intro l l' -- Porting note: was `simpa using formPerm_eq_formPerm_iff` simp_all intro hs hs' constructor <;> intro h <;> simp_all only [formPerm_eq_formPerm_iff] #align cycle.form_perm_eq_form_perm_iff Cycle.formPerm_eq_formPerm_iff end Cycle namespace Equiv.Perm section Fintype variable [Fintype α] [DecidableEq α] (p : Equiv.Perm α) (x : α) /-- `Equiv.Perm.toList (f : Perm α) (x : α)` generates the list `[x, f x, f (f x), ...]` until looping. That means when `f x = x`, `toList f x = []`. -/ def toList : List α := (List.range (cycleOf p x).support.card).map fun k => (p ^ k) x #align equiv.perm.to_list Equiv.Perm.toList @[simp] theorem toList_one : toList (1 : Perm α) x = [] := by simp [toList, cycleOf_one] #align equiv.perm.to_list_one Equiv.Perm.toList_one @[simp] theorem toList_eq_nil_iff {p : Perm α} {x} : toList p x = [] ↔ x ∉ p.support := by simp [toList] #align equiv.perm.to_list_eq_nil_iff Equiv.Perm.toList_eq_nil_iff @[simp] theorem length_toList : length (toList p x) = (cycleOf p x).support.card := by simp [toList] #align equiv.perm.length_to_list Equiv.Perm.length_toList theorem toList_ne_singleton (y : α) : toList p x ≠ [y] := by intro H simpa [card_support_ne_one] using congr_arg length H #align equiv.perm.to_list_ne_singleton Equiv.Perm.toList_ne_singleton theorem two_le_length_toList_iff_mem_support {p : Perm α} {x : α} : 2 ≤ length (toList p x) ↔ x ∈ p.support := by simp #align equiv.perm.two_le_length_to_list_iff_mem_support Equiv.Perm.two_le_length_toList_iff_mem_support theorem length_toList_pos_of_mem_support (h : x ∈ p.support) : 0 < length (toList p x) := zero_lt_two.trans_le (two_le_length_toList_iff_mem_support.mpr h) #align equiv.perm.length_to_list_pos_of_mem_support Equiv.Perm.length_toList_pos_of_mem_support theorem get_toList (n : ℕ) (hn : n < length (toList p x)) : (toList p x).get ⟨n, hn⟩ = (p ^ n) x := by simp [toList] theorem toList_get_zero (h : x ∈ p.support) : (toList p x).get ⟨0, (length_toList_pos_of_mem_support _ _ h)⟩ = x := by simp [toList] set_option linter.deprecated false in @[deprecated get_toList (since := "2024-05-08")] theorem nthLe_toList (n : ℕ) (hn : n < length (toList p x)) : (toList p x).nthLe n hn = (p ^ n) x := by simp [toList] #align equiv.perm.nth_le_to_list Equiv.Perm.nthLe_toList set_option linter.deprecated false in @[deprecated toList_get_zero (since := "2024-05-08")] theorem toList_nthLe_zero (h : x ∈ p.support) : (toList p x).nthLe 0 (length_toList_pos_of_mem_support _ _ h) = x := by simp [toList] #align equiv.perm.to_list_nth_le_zero Equiv.Perm.toList_nthLe_zero variable {p} {x} theorem mem_toList_iff {y : α} : y ∈ toList p x ↔ SameCycle p x y ∧ x ∈ p.support := by simp only [toList, mem_range, mem_map] constructor · rintro ⟨n, hx, rfl⟩ refine ⟨⟨n, rfl⟩, ?_⟩ contrapose! hx rw [← support_cycleOf_eq_nil_iff] at hx simp [hx] · rintro ⟨h, hx⟩ simpa using h.exists_pow_eq_of_mem_support hx #align equiv.perm.mem_to_list_iff Equiv.Perm.mem_toList_iff set_option linter.deprecated false in theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by by_cases hx : p x = x · rw [← not_mem_support, ← toList_eq_nil_iff] at hx simp [hx] have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx rw [nodup_iff_nthLe_inj] rintro n m hn hm rw [length_toList, ← hc.orderOf] at hm hn rw [← cycleOf_apply_self, ← Ne, ← mem_support] at hx rw [nthLe_toList, nthLe_toList, ← cycleOf_pow_apply_self p x n, ← cycleOf_pow_apply_self p x m] cases' n with n <;> cases' m with m · simp · rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support, cycleOf_pow_apply_self] at hx simp [hx.symm] · rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support, cycleOf_pow_apply_self] at hx simp [hx] intro h have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm rw [← hc.support_pow_eq_iff] at hn' hm' rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod] refine support_congr ?_ ?_ · rw [hm', hn'] · rw [hm'] intro y hy obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy) rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply, h, ← mul_apply, ← mul_apply, (Commute.pow_pow_self _ _ _).eq] #align equiv.perm.nodup_to_list Equiv.Perm.nodup_toList set_option linter.deprecated false in theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) : next (toList p x) y hy = p y := by rw [mem_toList_iff] at hy obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right rw [← nthLe_toList p x k (by simpa using hk)] at hk' simp_rw [← hk'] rw [next_nthLe _ (nodup_toList _ _), nthLe_toList, nthLe_toList, ← mul_apply, ← pow_succ', length_toList, ← pow_mod_orderOf_cycleOf_apply p (k + 1), IsCycle.orderOf] exact isCycle_cycleOf _ (mem_support.mp hy.right) #align equiv.perm.next_to_list_eq_apply Equiv.Perm.next_toList_eq_apply set_option linter.deprecated false in theorem toList_pow_apply_eq_rotate (p : Perm α) (x : α) (k : ℕ) : p.toList ((p ^ k) x) = (p.toList x).rotate k := by apply ext_nthLe · simp only [length_toList, cycleOf_self_apply_pow, length_rotate] · intro n hn hn' rw [nthLe_toList, nthLe_rotate, nthLe_toList, length_toList, pow_mod_card_support_cycleOf_self_apply, pow_add, mul_apply] #align equiv.perm.to_list_pow_apply_eq_rotate Equiv.Perm.toList_pow_apply_eq_rotate theorem SameCycle.toList_isRotated {f : Perm α} {x y : α} (h : SameCycle f x y) : toList f x ~r toList f y := by by_cases hx : x ∈ f.support · obtain ⟨_ | k, _, hy⟩ := h.exists_pow_eq_of_mem_support hx · simp only [coe_one, id, pow_zero, Nat.zero_eq] at hy -- Porting note: added `IsRotated.refl` simp [hy, IsRotated.refl] use k.succ rw [← toList_pow_apply_eq_rotate, hy] · rw [toList_eq_nil_iff.mpr hx, isRotated_nil_iff', eq_comm, toList_eq_nil_iff] rwa [← h.mem_support_iff] #align equiv.perm.same_cycle.to_list_is_rotated Equiv.Perm.SameCycle.toList_isRotated theorem pow_apply_mem_toList_iff_mem_support {n : ℕ} : (p ^ n) x ∈ p.toList x ↔ x ∈ p.support := by rw [mem_toList_iff, and_iff_right_iff_imp] refine fun _ => SameCycle.symm ?_ rw [sameCycle_pow_left] #align equiv.perm.pow_apply_mem_to_list_iff_mem_support Equiv.Perm.pow_apply_mem_toList_iff_mem_support theorem toList_formPerm_nil (x : α) : toList (formPerm ([] : List α)) x = [] := by simp #align equiv.perm.to_list_form_perm_nil Equiv.Perm.toList_formPerm_nil theorem toList_formPerm_singleton (x y : α) : toList (formPerm [x]) y = [] := by simp #align equiv.perm.to_list_form_perm_singleton Equiv.Perm.toList_formPerm_singleton
Mathlib/GroupTheory/Perm/Cycle/Concrete.lean
358
369
theorem toList_formPerm_nontrivial (l : List α) (hl : 2 ≤ l.length) (hn : Nodup l) : toList (formPerm l) (l.get ⟨0, (zero_lt_two.trans_le hl)⟩) = l := by
have hc : l.formPerm.IsCycle := List.isCycle_formPerm hn hl have hs : l.formPerm.support = l.toFinset := by refine support_formPerm_of_nodup _ hn ?_ rintro _ rfl simp [Nat.succ_le_succ_iff] at hl rw [toList, hc.cycleOf_eq (mem_support.mp _), hs, card_toFinset, dedup_eq_self.mpr hn] · refine ext_get (by simp) fun k hk hk' => ?_ simp only [Nat.zero_eq, get_map, get_range, formPerm_pow_apply_get _ hn, zero_add, Nat.mod_eq_of_lt hk'] · simpa [hs] using get_mem _ _ _
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Analysis.Convex.StrictConvexSpace #align_import analysis.convex.uniform from "leanprover-community/mathlib"@"17ef379e997badd73e5eabb4d38f11919ab3c4b3" /-! # Uniformly convex spaces This file defines uniformly convex spaces, which are real normed vector spaces in which for all strictly positive `ε`, there exists some strictly positive `δ` such that `ε ≤ ‖x - y‖` implies `‖x + y‖ ≤ 2 - δ` for all `x` and `y` of norm at most than `1`. This means that the triangle inequality is strict with a uniform bound, as opposed to strictly convex spaces where the triangle inequality is strict but not necessarily uniformly (`‖x + y‖ < ‖x‖ + ‖y‖` for all `x` and `y` not in the same ray). ## Main declarations `UniformConvexSpace E` means that `E` is a uniformly convex space. ## TODO * Milman-Pettis * Hanner's inequalities ## Tags convex, uniformly convex -/ open Set Metric open Convex Pointwise /-- A *uniformly convex space* is a real normed space where the triangle inequality is strict with a uniform bound. Namely, over the `x` and `y` of norm `1`, `‖x + y‖` is uniformly bounded above by a constant `< 2` when `‖x - y‖` is uniformly bounded below by a positive constant. -/ class UniformConvexSpace (E : Type*) [SeminormedAddCommGroup E] : Prop where uniform_convex : ∀ ⦃ε : ℝ⦄, 0 < ε → ∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ = 1 → ∀ ⦃y⦄, ‖y‖ = 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ #align uniform_convex_space UniformConvexSpace variable {E : Type*} section SeminormedAddCommGroup variable (E) [SeminormedAddCommGroup E] [UniformConvexSpace E] {ε : ℝ} theorem exists_forall_sphere_dist_add_le_two_sub (hε : 0 < ε) : ∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ = 1 → ∀ ⦃y⦄, ‖y‖ = 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ := UniformConvexSpace.uniform_convex hε #align exists_forall_sphere_dist_add_le_two_sub exists_forall_sphere_dist_add_le_two_sub variable [NormedSpace ℝ E]
Mathlib/Analysis/Convex/Uniform.lean
60
112
theorem exists_forall_closed_ball_dist_add_le_two_sub (hε : 0 < ε) : ∃ δ, 0 < δ ∧ ∀ ⦃x : E⦄, ‖x‖ ≤ 1 → ∀ ⦃y⦄, ‖y‖ ≤ 1 → ε ≤ ‖x - y‖ → ‖x + y‖ ≤ 2 - δ := by
have hε' : 0 < ε / 3 := div_pos hε zero_lt_three obtain ⟨δ, hδ, h⟩ := exists_forall_sphere_dist_add_le_two_sub E hε' set δ' := min (1 / 2) (min (ε / 3) <| δ / 3) refine ⟨δ', lt_min one_half_pos <| lt_min hε' (div_pos hδ zero_lt_three), fun x hx y hy hxy => ?_⟩ obtain hx' | hx' := le_or_lt ‖x‖ (1 - δ') · rw [← one_add_one_eq_two] exact (norm_add_le_of_le hx' hy).trans (sub_add_eq_add_sub _ _ _).le obtain hy' | hy' := le_or_lt ‖y‖ (1 - δ') · rw [← one_add_one_eq_two] exact (norm_add_le_of_le hx hy').trans (add_sub_assoc _ _ _).ge have hδ' : 0 < 1 - δ' := sub_pos_of_lt (min_lt_of_left_lt one_half_lt_one) have h₁ : ∀ z : E, 1 - δ' < ‖z‖ → ‖‖z‖⁻¹ • z‖ = 1 := by rintro z hz rw [norm_smul_of_nonneg (inv_nonneg.2 <| norm_nonneg _), inv_mul_cancel (hδ'.trans hz).ne'] have h₂ : ∀ z : E, ‖z‖ ≤ 1 → 1 - δ' ≤ ‖z‖ → ‖‖z‖⁻¹ • z - z‖ ≤ δ' := by rintro z hz hδz nth_rw 3 [← one_smul ℝ z] rwa [← sub_smul, norm_smul_of_nonneg (sub_nonneg_of_le <| one_le_inv (hδ'.trans_le hδz) hz), sub_mul, inv_mul_cancel (hδ'.trans_le hδz).ne', one_mul, sub_le_comm] set x' := ‖x‖⁻¹ • x set y' := ‖y‖⁻¹ • y have hxy' : ε / 3 ≤ ‖x' - y'‖ := calc ε / 3 = ε - (ε / 3 + ε / 3) := by ring _ ≤ ‖x - y‖ - (‖x' - x‖ + ‖y' - y‖) := by gcongr · exact (h₂ _ hx hx'.le).trans <| min_le_of_right_le <| min_le_left _ _ · exact (h₂ _ hy hy'.le).trans <| min_le_of_right_le <| min_le_left _ _ _ ≤ _ := by have : ∀ x' y', x - y = x' - y' + (x - x') + (y' - y) := fun _ _ => by abel rw [sub_le_iff_le_add, norm_sub_rev _ x, ← add_assoc, this] exact norm_add₃_le _ _ _ calc ‖x + y‖ ≤ ‖x' + y'‖ + ‖x' - x‖ + ‖y' - y‖ := by have : ∀ x' y', x + y = x' + y' + (x - x') + (y - y') := fun _ _ => by abel rw [norm_sub_rev, norm_sub_rev y', this] exact norm_add₃_le _ _ _ _ ≤ 2 - δ + δ' + δ' := (add_le_add_three (h (h₁ _ hx') (h₁ _ hy') hxy') (h₂ _ hx hx'.le) (h₂ _ hy hy'.le)) _ ≤ 2 - δ' := by dsimp [δ'] rw [← le_sub_iff_add_le, ← le_sub_iff_add_le, sub_sub, sub_sub] refine sub_le_sub_left ?_ _ ring_nf rw [← mul_div_cancel₀ δ three_ne_zero] set_option tactic.skipAssignedInstances false in norm_num -- Porting note: these three extra lines needed to make `exact` work have : 3 * (δ / 3) * (1 / 3) = δ / 3 := by linarith rw [this, mul_comm] gcongr exact min_le_of_right_le <| min_le_right _ _
/- Copyright (c) 2020 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ 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" /-! # Mean value inequalities for integrals In this file we prove several inequalities on integrals, notably the Hölder inequality and the Minkowski inequality. The versions for finite sums are in `Analysis.MeanInequalities`. ## Main results Hölder's inequality for the Lebesgue integral of `ℝ≥0∞` and `ℝ≥0` functions: we prove `∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q` conjugate real exponents and `α → (E)NNReal` functions in two cases, * `ENNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions, * `NNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0 functions. `ENNReal.lintegral_mul_norm_pow_le` is a variant where the exponents are not reciprocals: `∫ (f ^ p * g ^ q) ∂μ ≤ (∫ f ∂μ) ^ p * (∫ g ∂μ) ^ q` where `p, q ≥ 0` and `p + q = 1`. `ENNReal.lintegral_prod_norm_pow_le` generalizes this to a finite family of functions: `∫ (∏ i, f i ^ p i) ∂μ ≤ ∏ i, (∫ f i ∂μ) ^ p i` when the `p` is a collection of nonnegative weights with sum 1. Minkowski's inequality for the Lebesgue integral of measurable functions with `ℝ≥0∞` values: we prove `(∫ (f + g)^p ∂μ) ^ (1/p) ≤ (∫ f^p ∂μ) ^ (1/p) + (∫ g^p ∂μ) ^ (1/p)` for `1 ≤ p`. -/ section LIntegral /-! ### Hölder's inequality for the Lebesgue integral of ℝ≥0∞ and ℝ≥0 functions We prove `∫ (f * g) ∂μ ≤ (∫ f^p ∂μ) ^ (1/p) * (∫ g^q ∂μ) ^ (1/q)` for `p`, `q` conjugate real exponents and `α → (E)NNReal` functions in several cases, the first two being useful only to prove the more general results: * `ENNReal.lintegral_mul_le_one_of_lintegral_rpow_eq_one` : ℝ≥0∞ functions for which the integrals on the right are equal to 1, * `ENNReal.lintegral_mul_le_Lp_mul_Lq_of_ne_zero_of_ne_top` : ℝ≥0∞ functions for which the integrals on the right are neither ⊤ nor 0, * `ENNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0∞ functions, * `NNReal.lintegral_mul_le_Lp_mul_Lq` : ℝ≥0 functions. -/ 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 /-- Function multiplied by the inverse of its p-seminorm `(∫⁻ f^p ∂μ) ^ 1/p`-/ 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
Mathlib/MeasureTheory/Integral/MeanInequalities.lean
93
98
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]
/- Copyright (c) 2021 Eric Wieser. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Eric Wieser -/ 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" /-! # Results about the grading structure of the clifford algebra The main result is `CliffordAlgebra.gradedAlgebra`, which says that the clifford algebra is a ℤ₂-graded algebra (or "superalgebra"). -/ namespace CliffordAlgebra variable {R M : Type*} [CommRing R] [AddCommGroup M] [Module R M] variable {Q : QuadraticForm R M} open scoped DirectSum variable (Q) /-- The even or odd submodule, defined as the supremum of the even or odd powers of `(ι Q).range`. `evenOdd 0` is the even submodule, and `evenOdd 1` is the odd submodule. -/ 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 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 #align clifford_algebra.even_odd_mul_le CliffordAlgebra.evenOdd_mul_le instance evenOdd.gradedMonoid : SetLike.GradedMonoid (evenOdd Q) where one_mem := Submodule.one_le.mp (one_le_evenOdd_zero Q) mul_mem _i _j _p _q hp hq := Submodule.mul_le.mp (evenOdd_mul_le Q _ _) _ hp _ hq #align clifford_algebra.even_odd.graded_monoid CliffordAlgebra.evenOdd.gradedMonoid /-- A version of `CliffordAlgebra.ι` that maps directly into the graded structure. This is primarily an auxiliary construction used to provide `CliffordAlgebra.gradedAlgebra`. -/ -- Porting note: added `protected` protected def GradedAlgebra.ι : M →ₗ[R] ⨁ i : ZMod 2, evenOdd Q i := DirectSum.lof R (ZMod 2) (fun i => ↥(evenOdd Q i)) 1 ∘ₗ (ι Q).codRestrict _ (ι_mem_evenOdd_one Q) #align clifford_algebra.graded_algebra.ι CliffordAlgebra.GradedAlgebra.ι theorem GradedAlgebra.ι_apply (m : M) : GradedAlgebra.ι Q m = DirectSum.of (fun i => ↥(evenOdd Q i)) 1 ⟨ι Q m, ι_mem_evenOdd_one Q m⟩ := rfl #align clifford_algebra.graded_algebra.ι_apply CliffordAlgebra.GradedAlgebra.ι_apply nonrec theorem GradedAlgebra.ι_sq_scalar (m : M) : GradedAlgebra.ι Q m * GradedAlgebra.ι Q m = algebraMap R _ (Q m) := by rw [GradedAlgebra.ι_apply Q, DirectSum.of_mul_of, DirectSum.algebraMap_apply] exact DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext rfl <| ι_sq_scalar _ _) #align clifford_algebra.graded_algebra.ι_sq_scalar CliffordAlgebra.GradedAlgebra.ι_sq_scalar theorem GradedAlgebra.lift_ι_eq (i' : ZMod 2) (x' : evenOdd Q i') : -- Porting note: added a second `by apply` lift Q ⟨by apply GradedAlgebra.ι Q, by apply GradedAlgebra.ι_sq_scalar Q⟩ x' = DirectSum.of (fun i => evenOdd Q i) i' x' := by cases' x' with x' hx' dsimp only [Subtype.coe_mk, DirectSum.lof_eq_of] induction hx' using Submodule.iSup_induction' with | mem i x hx => obtain ⟨i, rfl⟩ := i -- Porting note: `dsimp only [Subtype.coe_mk] at hx` doesn't work, use `change` instead change x ∈ LinearMap.range (ι Q) ^ i at hx induction hx using Submodule.pow_induction_on_left' with | algebraMap r => rw [AlgHom.commutes, DirectSum.algebraMap_apply]; rfl | add x y i hx hy ihx ihy => -- Note: in #8386 `map_add` had to be specialized to avoid a timeout -- (the definition was already very slow) rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add] rfl | mem_mul m hm i x hx ih => obtain ⟨_, rfl⟩ := hm rw [AlgHom.map_mul, ih, lift_ι_apply, GradedAlgebra.ι_apply Q, DirectSum.of_mul_of] refine DirectSum.of_eq_of_gradedMonoid_eq (Sigma.subtype_ext ?_ ?_) <;> dsimp only [GradedMonoid.mk, Subtype.coe_mk] · rw [Nat.succ_eq_add_one, add_comm, Nat.cast_add, Nat.cast_one] rfl | zero => rw [AlgHom.map_zero] apply Eq.symm apply DFinsupp.single_eq_zero.mpr; rfl | add x y hx hy ihx ihy => rw [AlgHom.map_add, ihx, ihy, ← AddMonoidHom.map_add]; rfl #align clifford_algebra.graded_algebra.lift_ι_eq CliffordAlgebra.GradedAlgebra.lift_ι_eq /-- The clifford algebra is graded by the even and odd parts. -/ instance gradedAlgebra : GradedAlgebra (evenOdd Q) := GradedAlgebra.ofAlgHom (evenOdd Q) -- while not necessary, the `by apply` makes this elaborate faster (lift Q ⟨by apply GradedAlgebra.ι Q, by apply GradedAlgebra.ι_sq_scalar Q⟩) -- the proof from here onward is mostly similar to the `TensorAlgebra` case, with some extra -- handling for the `iSup` in `evenOdd`. (by ext m dsimp only [LinearMap.comp_apply, AlgHom.toLinearMap_apply, AlgHom.comp_apply, AlgHom.id_apply] rw [lift_ι_apply, GradedAlgebra.ι_apply Q, DirectSum.coeAlgHom_of, Subtype.coe_mk]) (by apply GradedAlgebra.lift_ι_eq Q) #align clifford_algebra.graded_algebra CliffordAlgebra.gradedAlgebra theorem iSup_ι_range_eq_top : ⨆ i : ℕ, LinearMap.range (ι Q) ^ i = ⊤ := by rw [← (DirectSum.Decomposition.isInternal (evenOdd Q)).submodule_iSup_eq_top, eq_comm] calc -- Porting note: needs extra annotations, no longer unifies against the goal in the face of -- ambiguity ⨆ (i : ZMod 2) (j : { n : ℕ // ↑n = i }), LinearMap.range (ι Q) ^ (j : ℕ) = ⨆ i : Σ i : ZMod 2, { n : ℕ // ↑n = i }, LinearMap.range (ι Q) ^ (i.2 : ℕ) := by rw [iSup_sigma] _ = ⨆ i : ℕ, LinearMap.range (ι Q) ^ i := Function.Surjective.iSup_congr (fun i => i.2) (fun i => ⟨⟨_, i, rfl⟩, rfl⟩) fun _ => rfl #align clifford_algebra.supr_ι_range_eq_top CliffordAlgebra.iSup_ι_range_eq_top theorem evenOdd_isCompl : IsCompl (evenOdd Q 0) (evenOdd Q 1) := (DirectSum.Decomposition.isInternal (evenOdd Q)).isCompl zero_ne_one <| by have : (Finset.univ : Finset (ZMod 2)) = {0, 1} := rfl simpa using congr_arg ((↑) : Finset (ZMod 2) → Set (ZMod 2)) this #align clifford_algebra.even_odd_is_compl CliffordAlgebra.evenOdd_isCompl /-- To show a property is true on the even or odd part, it suffices to show it is true on the scalars or vectors (respectively), closed under addition, and under left-multiplication by a pair of vectors. -/ @[elab_as_elim] theorem evenOdd_induction (n : ZMod 2) {motive : ∀ x, x ∈ evenOdd Q n → Prop} (range_ι_pow : ∀ (v) (h : v ∈ LinearMap.range (ι Q) ^ n.val), motive v (Submodule.mem_iSup_of_mem ⟨n.val, n.natCast_zmod_val⟩ h)) (add : ∀ x y hx hy, motive x hx → motive y hy → motive (x + y) (Submodule.add_mem _ hx hy)) (ι_mul_ι_mul : ∀ m₁ m₂ x hx, motive x hx → motive (ι Q m₁ * ι Q m₂ * x) (zero_add n ▸ SetLike.mul_mem_graded (ι_mul_ι_mem_evenOdd_zero Q m₁ m₂) hx)) (x : CliffordAlgebra Q) (hx : x ∈ evenOdd Q n) : motive x hx := by apply Submodule.iSup_induction' (C := motive) _ (range_ι_pow 0 (Submodule.zero_mem _)) add refine Subtype.rec ?_ simp_rw [ZMod.natCast_eq_iff, add_comm n.val] rintro n' ⟨k, rfl⟩ xv simp_rw [pow_add, pow_mul] intro hxv induction hxv using Submodule.mul_induction_on' with | mem_mul_mem a ha b hb => induction ha using Submodule.pow_induction_on_left' with | algebraMap r => simp_rw [← Algebra.smul_def] exact range_ι_pow _ (Submodule.smul_mem _ _ hb) | add x y n hx hy ihx ihy => simp_rw [add_mul] apply add _ _ _ _ ihx ihy | mem_mul x hx n'' y hy ihy => revert hx simp_rw [pow_two] intro hx2 induction hx2 using Submodule.mul_induction_on' with | mem_mul_mem m hm n hn => simp_rw [LinearMap.mem_range] at hm hn obtain ⟨m₁, rfl⟩ := hm; obtain ⟨m₂, rfl⟩ := hn simp_rw [mul_assoc _ y b] exact ι_mul_ι_mul _ _ _ _ ihy | add x hx y hy ihx ihy => simp_rw [add_mul] apply add _ _ _ _ ihx ihy | add x y hx hy ihx ihy => apply add _ _ _ _ ihx ihy #align clifford_algebra.even_odd_induction CliffordAlgebra.evenOdd_induction /-- To show a property is true on the even parts, it suffices to show it is true on the scalars, closed under addition, and under left-multiplication by a pair of vectors. -/ @[elab_as_elim]
Mathlib/LinearAlgebra/CliffordAlgebra/Grading.lean
207
218
theorem even_induction {motive : ∀ x, x ∈ evenOdd Q 0 → Prop} (algebraMap : ∀ r : R, motive (algebraMap _ _ r) (SetLike.algebraMap_mem_graded _ _)) (add : ∀ x y hx hy, motive x hx → motive y hy → motive (x + y) (Submodule.add_mem _ hx hy)) (ι_mul_ι_mul : ∀ m₁ m₂ x hx, motive x hx → motive (ι Q m₁ * ι Q m₂ * x) (zero_add (0 : ZMod 2) ▸ SetLike.mul_mem_graded (ι_mul_ι_mem_evenOdd_zero Q m₁ m₂) hx)) (x : CliffordAlgebra Q) (hx : x ∈ evenOdd Q 0) : motive x hx := by
refine evenOdd_induction (motive := motive) (fun rx => ?_) add ι_mul_ι_mul x hx rintro ⟨r, rfl⟩ exact algebraMap r
/- Copyright (c) 2023 Felix Weilacher. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Felix Weilacher -/ import Mathlib.Topology.MetricSpace.PiNat #align_import topology.metric_space.cantor_scheme from "leanprover-community/mathlib"@"49b7f94aab3a3bdca1f9f34c5d818afb253b3993" /-! # (Topological) Schemes and their induced maps In topology, and especially descriptive set theory, one often constructs functions `(ℕ → β) → α`, where α is some topological space and β is a discrete space, as an appropriate limit of some map `List β → Set α`. We call the latter type of map a "`β`-scheme on `α`". This file develops the basic, abstract theory of these schemes and the functions they induce. ## Main Definitions * `CantorScheme.inducedMap A` : The aforementioned "limit" of a scheme `A : List β → Set α`. This is a partial function from `ℕ → β` to `a`, implemented here as an object of type `Σ s : Set (ℕ → β), s → α`. That is, `(inducedMap A).1` is the domain and `(inducedMap A).2` is the function. ## Implementation Notes We consider end-appending to be the fundamental way to build lists (say on `β`) inductively, as this interacts better with the topology on `ℕ → β`. As a result, functions like `List.get?` or `Stream'.take` do not have their intended meaning in this file. See instead `PiNat.res`. ## References * [kechris1995] (Chapters 6-7) ## Tags scheme, cantor scheme, lusin scheme, approximation. -/ namespace CantorScheme open List Function Filter Set PiNat open scoped Classical open Topology variable {β α : Type*} (A : List β → Set α) /-- From a `β`-scheme on `α` `A`, we define a partial function from `(ℕ → β)` to `α` which sends each infinite sequence `x` to an element of the intersection along the branch corresponding to `x`, if it exists. We call this the map induced by the scheme. -/ noncomputable def inducedMap : Σs : Set (ℕ → β), s → α := ⟨fun x => Set.Nonempty (⋂ n : ℕ, A (res x n)), fun x => x.property.some⟩ #align cantor_scheme.induced_map CantorScheme.inducedMap section Topology /-- A scheme is antitone if each set contains its children. -/ protected def Antitone : Prop := ∀ l : List β, ∀ a : β, A (a :: l) ⊆ A l #align cantor_scheme.antitone CantorScheme.Antitone /-- A useful strengthening of being antitone is to require that each set contains the closure of each of its children. -/ def ClosureAntitone [TopologicalSpace α] : Prop := ∀ l : List β, ∀ a : β, closure (A (a :: l)) ⊆ A l #align cantor_scheme.closure_antitone CantorScheme.ClosureAntitone /-- A scheme is disjoint if the children of each set of pairwise disjoint. -/ protected def Disjoint : Prop := ∀ l : List β, Pairwise fun a b => Disjoint (A (a :: l)) (A (b :: l)) #align cantor_scheme.disjoint CantorScheme.Disjoint variable {A} /-- If `x` is in the domain of the induced map of a scheme `A`, its image under this map is in each set along the corresponding branch. -/ theorem map_mem (x : (inducedMap A).1) (n : ℕ) : (inducedMap A).2 x ∈ A (res x n) := by have := x.property.some_mem rw [mem_iInter] at this exact this n #align cantor_scheme.map_mem CantorScheme.map_mem protected theorem ClosureAntitone.antitone [TopologicalSpace α] (hA : ClosureAntitone A) : CantorScheme.Antitone A := fun l a => subset_closure.trans (hA l a) #align cantor_scheme.closure_antitone.antitone CantorScheme.ClosureAntitone.antitone protected theorem Antitone.closureAntitone [TopologicalSpace α] (hanti : CantorScheme.Antitone A) (hclosed : ∀ l, IsClosed (A l)) : ClosureAntitone A := fun _ _ => (hclosed _).closure_eq.subset.trans (hanti _ _) #align cantor_scheme.antitone.closure_antitone CantorScheme.Antitone.closureAntitone /-- A scheme where the children of each set are pairwise disjoint induces an injective map. -/
Mathlib/Topology/MetricSpace/CantorScheme.lean
99
115
theorem Disjoint.map_injective (hA : CantorScheme.Disjoint A) : Injective (inducedMap A).2 := by
rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy refine Subtype.coe_injective (res_injective ?_) dsimp ext n : 1 induction' n with n ih; · simp simp only [res_succ, cons.injEq] refine ⟨?_, ih⟩ contrapose hA simp only [CantorScheme.Disjoint, _root_.Pairwise, Ne, not_forall, exists_prop] refine ⟨res x n, _, _, hA, ?_⟩ rw [not_disjoint_iff] refine ⟨(inducedMap A).2 ⟨x, hx⟩, ?_, ?_⟩ · rw [← res_succ] apply map_mem rw [hxy, ih, ← res_succ] apply map_mem
/- Copyright (c) 2020 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Manuel Candales -/ import Mathlib.Analysis.InnerProductSpace.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Inverse #align_import geometry.euclidean.angle.unoriented.basic from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5" /-! # Angles between vectors This file defines unoriented angles in real inner product spaces. ## Main definitions * `InnerProductGeometry.angle` is the undirected angle between two vectors. ## TODO Prove the triangle inequality for the angle. -/ assert_not_exists HasFDerivAt assert_not_exists ConformalAt noncomputable section open Real Set open Real open RealInnerProductSpace namespace InnerProductGeometry variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] {x y : V} /-- The undirected angle between two vectors. If either vector is 0, this is π/2. See `Orientation.oangle` for the corresponding oriented angle definition. -/ def angle (x y : V) : ℝ := Real.arccos (⟪x, y⟫ / (‖x‖ * ‖y‖)) #align inner_product_geometry.angle InnerProductGeometry.angle theorem continuousAt_angle {x : V × V} (hx1 : x.1 ≠ 0) (hx2 : x.2 ≠ 0) : ContinuousAt (fun y : V × V => angle y.1 y.2) x := Real.continuous_arccos.continuousAt.comp <| continuous_inner.continuousAt.div ((continuous_norm.comp continuous_fst).mul (continuous_norm.comp continuous_snd)).continuousAt (by simp [hx1, hx2]) #align inner_product_geometry.continuous_at_angle InnerProductGeometry.continuousAt_angle theorem angle_smul_smul {c : ℝ} (hc : c ≠ 0) (x y : V) : angle (c • x) (c • y) = angle x y := by have : c * c ≠ 0 := mul_ne_zero hc hc rw [angle, angle, real_inner_smul_left, inner_smul_right, norm_smul, norm_smul, Real.norm_eq_abs, mul_mul_mul_comm _ ‖x‖, abs_mul_abs_self, ← mul_assoc c c, mul_div_mul_left _ _ this] #align inner_product_geometry.angle_smul_smul InnerProductGeometry.angle_smul_smul @[simp] theorem _root_.LinearIsometry.angle_map {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] [InnerProductSpace ℝ E] [InnerProductSpace ℝ F] (f : E →ₗᵢ[ℝ] F) (u v : E) : angle (f u) (f v) = angle u v := by rw [angle, angle, f.inner_map_map, f.norm_map, f.norm_map] #align linear_isometry.angle_map LinearIsometry.angle_map @[simp, norm_cast] theorem _root_.Submodule.angle_coe {s : Submodule ℝ V} (x y : s) : angle (x : V) (y : V) = angle x y := s.subtypeₗᵢ.angle_map x y #align submodule.angle_coe Submodule.angle_coe /-- The cosine of the angle between two vectors. -/ theorem cos_angle (x y : V) : Real.cos (angle x y) = ⟪x, y⟫ / (‖x‖ * ‖y‖) := Real.cos_arccos (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).1 (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).2 #align inner_product_geometry.cos_angle InnerProductGeometry.cos_angle /-- The angle between two vectors does not depend on their order. -/ theorem angle_comm (x y : V) : angle x y = angle y x := by unfold angle rw [real_inner_comm, mul_comm] #align inner_product_geometry.angle_comm InnerProductGeometry.angle_comm /-- The angle between the negation of two vectors. -/ @[simp] theorem angle_neg_neg (x y : V) : angle (-x) (-y) = angle x y := by unfold angle rw [inner_neg_neg, norm_neg, norm_neg] #align inner_product_geometry.angle_neg_neg InnerProductGeometry.angle_neg_neg /-- The angle between two vectors is nonnegative. -/ theorem angle_nonneg (x y : V) : 0 ≤ angle x y := Real.arccos_nonneg _ #align inner_product_geometry.angle_nonneg InnerProductGeometry.angle_nonneg /-- The angle between two vectors is at most π. -/ theorem angle_le_pi (x y : V) : angle x y ≤ π := Real.arccos_le_pi _ #align inner_product_geometry.angle_le_pi InnerProductGeometry.angle_le_pi /-- The angle between a vector and the negation of another vector. -/ theorem angle_neg_right (x y : V) : angle x (-y) = π - angle x y := by unfold angle rw [← Real.arccos_neg, norm_neg, inner_neg_right, neg_div] #align inner_product_geometry.angle_neg_right InnerProductGeometry.angle_neg_right /-- The angle between the negation of a vector and another vector. -/ theorem angle_neg_left (x y : V) : angle (-x) y = π - angle x y := by rw [← angle_neg_neg, neg_neg, angle_neg_right] #align inner_product_geometry.angle_neg_left InnerProductGeometry.angle_neg_left proof_wanted angle_triangle (x y z : V) : angle x z ≤ angle x y + angle y z /-- The angle between the zero vector and a vector. -/ @[simp] theorem angle_zero_left (x : V) : angle 0 x = π / 2 := by unfold angle rw [inner_zero_left, zero_div, Real.arccos_zero] #align inner_product_geometry.angle_zero_left InnerProductGeometry.angle_zero_left /-- The angle between a vector and the zero vector. -/ @[simp] theorem angle_zero_right (x : V) : angle x 0 = π / 2 := by unfold angle rw [inner_zero_right, zero_div, Real.arccos_zero] #align inner_product_geometry.angle_zero_right InnerProductGeometry.angle_zero_right /-- The angle between a nonzero vector and itself. -/ @[simp] theorem angle_self {x : V} (hx : x ≠ 0) : angle x x = 0 := by unfold angle rw [← real_inner_self_eq_norm_mul_norm, div_self (inner_self_ne_zero.2 hx : ⟪x, x⟫ ≠ 0), Real.arccos_one] #align inner_product_geometry.angle_self InnerProductGeometry.angle_self /-- The angle between a nonzero vector and its negation. -/ @[simp] theorem angle_self_neg_of_nonzero {x : V} (hx : x ≠ 0) : angle x (-x) = π := by rw [angle_neg_right, angle_self hx, sub_zero] #align inner_product_geometry.angle_self_neg_of_nonzero InnerProductGeometry.angle_self_neg_of_nonzero /-- The angle between the negation of a nonzero vector and that vector. -/ @[simp] theorem angle_neg_self_of_nonzero {x : V} (hx : x ≠ 0) : angle (-x) x = π := by rw [angle_comm, angle_self_neg_of_nonzero hx] #align inner_product_geometry.angle_neg_self_of_nonzero InnerProductGeometry.angle_neg_self_of_nonzero /-- The angle between a vector and a positive multiple of a vector. -/ @[simp] theorem angle_smul_right_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : angle x (r • y) = angle x y := by unfold angle rw [inner_smul_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg (le_of_lt hr), ← mul_assoc, mul_comm _ r, mul_assoc, mul_div_mul_left _ _ (ne_of_gt hr)] #align inner_product_geometry.angle_smul_right_of_pos InnerProductGeometry.angle_smul_right_of_pos /-- The angle between a positive multiple of a vector and a vector. -/ @[simp] theorem angle_smul_left_of_pos (x y : V) {r : ℝ} (hr : 0 < r) : angle (r • x) y = angle x y := by rw [angle_comm, angle_smul_right_of_pos y x hr, angle_comm] #align inner_product_geometry.angle_smul_left_of_pos InnerProductGeometry.angle_smul_left_of_pos /-- The angle between a vector and a negative multiple of a vector. -/ @[simp] theorem angle_smul_right_of_neg (x y : V) {r : ℝ} (hr : r < 0) : angle x (r • y) = angle x (-y) := by rw [← neg_neg r, neg_smul, angle_neg_right, angle_smul_right_of_pos x y (neg_pos_of_neg hr), angle_neg_right] #align inner_product_geometry.angle_smul_right_of_neg InnerProductGeometry.angle_smul_right_of_neg /-- The angle between a negative multiple of a vector and a vector. -/ @[simp] theorem angle_smul_left_of_neg (x y : V) {r : ℝ} (hr : r < 0) : angle (r • x) y = angle (-x) y := by rw [angle_comm, angle_smul_right_of_neg y x hr, angle_comm] #align inner_product_geometry.angle_smul_left_of_neg InnerProductGeometry.angle_smul_left_of_neg /-- The cosine of the angle between two vectors, multiplied by the product of their norms. -/ theorem cos_angle_mul_norm_mul_norm (x y : V) : Real.cos (angle x y) * (‖x‖ * ‖y‖) = ⟪x, y⟫ := by rw [cos_angle, div_mul_cancel_of_imp] simp (config := { contextual := true }) [or_imp] #align inner_product_geometry.cos_angle_mul_norm_mul_norm InnerProductGeometry.cos_angle_mul_norm_mul_norm /-- The sine of the angle between two vectors, multiplied by the product of their norms. -/ theorem sin_angle_mul_norm_mul_norm (x y : V) : Real.sin (angle x y) * (‖x‖ * ‖y‖) = √(⟪x, x⟫ * ⟪y, y⟫ - ⟪x, y⟫ * ⟪x, y⟫) := by unfold angle rw [Real.sin_arccos, ← Real.sqrt_mul_self (mul_nonneg (norm_nonneg x) (norm_nonneg y)), ← Real.sqrt_mul' _ (mul_self_nonneg _), sq, Real.sqrt_mul_self (mul_nonneg (norm_nonneg x) (norm_nonneg y)), real_inner_self_eq_norm_mul_norm, real_inner_self_eq_norm_mul_norm] by_cases h : ‖x‖ * ‖y‖ = 0 · rw [show ‖x‖ * ‖x‖ * (‖y‖ * ‖y‖) = ‖x‖ * ‖y‖ * (‖x‖ * ‖y‖) by ring, h, mul_zero, mul_zero, zero_sub] cases' eq_zero_or_eq_zero_of_mul_eq_zero h with hx hy · rw [norm_eq_zero] at hx rw [hx, inner_zero_left, zero_mul, neg_zero] · rw [norm_eq_zero] at hy rw [hy, inner_zero_right, zero_mul, neg_zero] · field_simp [h] ring_nf #align inner_product_geometry.sin_angle_mul_norm_mul_norm InnerProductGeometry.sin_angle_mul_norm_mul_norm /-- The angle between two vectors is zero if and only if they are nonzero and one is a positive multiple of the other. -/ theorem angle_eq_zero_iff {x y : V} : angle x y = 0 ↔ x ≠ 0 ∧ ∃ r : ℝ, 0 < r ∧ y = r • x := by rw [angle, ← real_inner_div_norm_mul_norm_eq_one_iff, Real.arccos_eq_zero, LE.le.le_iff_eq, eq_comm] exact (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).2 #align inner_product_geometry.angle_eq_zero_iff InnerProductGeometry.angle_eq_zero_iff /-- The angle between two vectors is π if and only if they are nonzero and one is a negative multiple of the other. -/ theorem angle_eq_pi_iff {x y : V} : angle x y = π ↔ x ≠ 0 ∧ ∃ r : ℝ, r < 0 ∧ y = r • x := by rw [angle, ← real_inner_div_norm_mul_norm_eq_neg_one_iff, Real.arccos_eq_pi, LE.le.le_iff_eq] exact (abs_le.mp (abs_real_inner_div_norm_mul_norm_le_one x y)).1 #align inner_product_geometry.angle_eq_pi_iff InnerProductGeometry.angle_eq_pi_iff /-- If the angle between two vectors is π, the angles between those vectors and a third vector add to π. -/ theorem angle_add_angle_eq_pi_of_angle_eq_pi {x y : V} (z : V) (h : angle x y = π) : angle x z + angle y z = π := by rcases angle_eq_pi_iff.1 h with ⟨_, ⟨r, ⟨hr, rfl⟩⟩⟩ rw [angle_smul_left_of_neg x z hr, angle_neg_left, add_sub_cancel] #align inner_product_geometry.angle_add_angle_eq_pi_of_angle_eq_pi InnerProductGeometry.angle_add_angle_eq_pi_of_angle_eq_pi /-- Two vectors have inner product 0 if and only if the angle between them is π/2. -/ theorem inner_eq_zero_iff_angle_eq_pi_div_two (x y : V) : ⟪x, y⟫ = 0 ↔ angle x y = π / 2 := Iff.symm <| by simp (config := { contextual := true }) [angle, or_imp] #align inner_product_geometry.inner_eq_zero_iff_angle_eq_pi_div_two InnerProductGeometry.inner_eq_zero_iff_angle_eq_pi_div_two /-- If the angle between two vectors is π, the inner product equals the negative product of the norms. -/ theorem inner_eq_neg_mul_norm_of_angle_eq_pi {x y : V} (h : angle x y = π) : ⟪x, y⟫ = -(‖x‖ * ‖y‖) := by simp [← cos_angle_mul_norm_mul_norm, h] #align inner_product_geometry.inner_eq_neg_mul_norm_of_angle_eq_pi InnerProductGeometry.inner_eq_neg_mul_norm_of_angle_eq_pi /-- If the angle between two vectors is 0, the inner product equals the product of the norms. -/ theorem inner_eq_mul_norm_of_angle_eq_zero {x y : V} (h : angle x y = 0) : ⟪x, y⟫ = ‖x‖ * ‖y‖ := by simp [← cos_angle_mul_norm_mul_norm, h] #align inner_product_geometry.inner_eq_mul_norm_of_angle_eq_zero InnerProductGeometry.inner_eq_mul_norm_of_angle_eq_zero /-- The inner product of two non-zero vectors equals the negative product of their norms if and only if the angle between the two vectors is π. -/ theorem inner_eq_neg_mul_norm_iff_angle_eq_pi {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : ⟪x, y⟫ = -(‖x‖ * ‖y‖) ↔ angle x y = π := by refine ⟨fun h => ?_, inner_eq_neg_mul_norm_of_angle_eq_pi⟩ have h₁ : ‖x‖ * ‖y‖ ≠ 0 := (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)).ne' rw [angle, h, neg_div, div_self h₁, Real.arccos_neg_one] #align inner_product_geometry.inner_eq_neg_mul_norm_iff_angle_eq_pi InnerProductGeometry.inner_eq_neg_mul_norm_iff_angle_eq_pi /-- The inner product of two non-zero vectors equals the product of their norms if and only if the angle between the two vectors is 0. -/ theorem inner_eq_mul_norm_iff_angle_eq_zero {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : ⟪x, y⟫ = ‖x‖ * ‖y‖ ↔ angle x y = 0 := by refine ⟨fun h => ?_, inner_eq_mul_norm_of_angle_eq_zero⟩ have h₁ : ‖x‖ * ‖y‖ ≠ 0 := (mul_pos (norm_pos_iff.mpr hx) (norm_pos_iff.mpr hy)).ne' rw [angle, h, div_self h₁, Real.arccos_one] #align inner_product_geometry.inner_eq_mul_norm_iff_angle_eq_zero InnerProductGeometry.inner_eq_mul_norm_iff_angle_eq_zero /-- If the angle between two vectors is π, the norm of their difference equals the sum of their norms. -/ theorem norm_sub_eq_add_norm_of_angle_eq_pi {x y : V} (h : angle x y = π) : ‖x - y‖ = ‖x‖ + ‖y‖ := by rw [← sq_eq_sq (norm_nonneg (x - y)) (add_nonneg (norm_nonneg x) (norm_nonneg y)), norm_sub_pow_two_real, inner_eq_neg_mul_norm_of_angle_eq_pi h] ring #align inner_product_geometry.norm_sub_eq_add_norm_of_angle_eq_pi InnerProductGeometry.norm_sub_eq_add_norm_of_angle_eq_pi /-- If the angle between two vectors is 0, the norm of their sum equals the sum of their norms. -/ theorem norm_add_eq_add_norm_of_angle_eq_zero {x y : V} (h : angle x y = 0) : ‖x + y‖ = ‖x‖ + ‖y‖ := by rw [← sq_eq_sq (norm_nonneg (x + y)) (add_nonneg (norm_nonneg x) (norm_nonneg y)), norm_add_pow_two_real, inner_eq_mul_norm_of_angle_eq_zero h] ring #align inner_product_geometry.norm_add_eq_add_norm_of_angle_eq_zero InnerProductGeometry.norm_add_eq_add_norm_of_angle_eq_zero /-- If the angle between two vectors is 0, the norm of their difference equals the absolute value of the difference of their norms. -/ theorem norm_sub_eq_abs_sub_norm_of_angle_eq_zero {x y : V} (h : angle x y = 0) : ‖x - y‖ = |‖x‖ - ‖y‖| := by rw [← sq_eq_sq (norm_nonneg (x - y)) (abs_nonneg (‖x‖ - ‖y‖)), norm_sub_pow_two_real, inner_eq_mul_norm_of_angle_eq_zero h, sq_abs (‖x‖ - ‖y‖)] ring #align inner_product_geometry.norm_sub_eq_abs_sub_norm_of_angle_eq_zero InnerProductGeometry.norm_sub_eq_abs_sub_norm_of_angle_eq_zero /-- The norm of the difference of two non-zero vectors equals the sum of their norms if and only the angle between the two vectors is π. -/
Mathlib/Geometry/Euclidean/Angle/Unoriented/Basic.lean
297
305
theorem norm_sub_eq_add_norm_iff_angle_eq_pi {x y : V} (hx : x ≠ 0) (hy : y ≠ 0) : ‖x - y‖ = ‖x‖ + ‖y‖ ↔ angle x y = π := by
refine ⟨fun h => ?_, norm_sub_eq_add_norm_of_angle_eq_pi⟩ rw [← inner_eq_neg_mul_norm_iff_angle_eq_pi hx hy] obtain ⟨hxy₁, hxy₂⟩ := norm_nonneg (x - y), add_nonneg (norm_nonneg x) (norm_nonneg y) rw [← sq_eq_sq hxy₁ hxy₂, norm_sub_pow_two_real] at h calc ⟪x, y⟫ = (‖x‖ ^ 2 + ‖y‖ ^ 2 - (‖x‖ + ‖y‖) ^ 2) / 2 := by linarith _ = -(‖x‖ * ‖y‖) := by ring
/- Copyright (c) 2021 Christopher Hoskin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Christopher Hoskin -/ import Mathlib.Algebra.Order.Group.PosPart import Mathlib.Analysis.Normed.Group.Basic import Mathlib.Topology.Order.Lattice #align_import analysis.normed.order.lattice from "leanprover-community/mathlib"@"5dc275ec639221ca4d5f56938eb966f6ad9bc89f" /-! # Normed lattice ordered groups Motivated by the theory of Banach Lattices, we then define `NormedLatticeAddCommGroup` as a lattice with a covariant normed group addition satisfying the solid axiom. ## Main statements We show that a normed lattice ordered group is a topological lattice with respect to the norm topology. ## References * [Meyer-Nieberg, Banach lattices][MeyerNieberg1991] ## Tags normed, lattice, ordered, group -/ /-! ### Normed lattice ordered groups Motivated by the theory of Banach Lattices, this section introduces normed lattice ordered groups. -/ -- Porting note: this now exists as a global notation -- local notation "|" a "|" => abs a section SolidNorm /-- Let `α` be an `AddCommGroup` with a `Lattice` structure. A norm on `α` is *solid* if, for `a` and `b` in `α`, with absolute values `|a|` and `|b|` respectively, `|a| ≤ |b|` implies `‖a‖ ≤ ‖b‖`. -/ class HasSolidNorm (α : Type*) [NormedAddCommGroup α] [Lattice α] : Prop where solid : ∀ ⦃x y : α⦄, |x| ≤ |y| → ‖x‖ ≤ ‖y‖ #align has_solid_norm HasSolidNorm variable {α : Type*} [NormedAddCommGroup α] [Lattice α] [HasSolidNorm α] theorem norm_le_norm_of_abs_le_abs {a b : α} (h : |a| ≤ |b|) : ‖a‖ ≤ ‖b‖ := HasSolidNorm.solid h #align norm_le_norm_of_abs_le_abs norm_le_norm_of_abs_le_abs /-- If `α` has a solid norm, then the balls centered at the origin of `α` are solid sets. -/ theorem LatticeOrderedAddCommGroup.isSolid_ball (r : ℝ) : LatticeOrderedAddCommGroup.IsSolid (Metric.ball (0 : α) r) := fun _ hx _ hxy => mem_ball_zero_iff.mpr ((HasSolidNorm.solid hxy).trans_lt (mem_ball_zero_iff.mp hx)) #align lattice_ordered_add_comm_group.is_solid_ball LatticeOrderedAddCommGroup.isSolid_ball instance : HasSolidNorm ℝ := ⟨fun _ _ => id⟩ instance : HasSolidNorm ℚ := ⟨fun _ _ _ => by simpa only [norm, ← Rat.cast_abs, Rat.cast_le]⟩ end SolidNorm /-- Let `α` be a normed commutative group equipped with a partial order covariant with addition, with respect which `α` forms a lattice. Suppose that `α` is *solid*, that is to say, for `a` and `b` in `α`, with absolute values `|a|` and `|b|` respectively, `|a| ≤ |b|` implies `‖a‖ ≤ ‖b‖`. Then `α` is said to be a normed lattice ordered group. -/ class NormedLatticeAddCommGroup (α : Type*) extends NormedAddCommGroup α, Lattice α, HasSolidNorm α where add_le_add_left : ∀ a b : α, a ≤ b → ∀ c : α, c + a ≤ c + b #align normed_lattice_add_comm_group NormedLatticeAddCommGroup instance Real.normedLatticeAddCommGroup : NormedLatticeAddCommGroup ℝ where add_le_add_left _ _ h _ := add_le_add le_rfl h -- see Note [lower instance priority] /-- A normed lattice ordered group is an ordered additive commutative group -/ instance (priority := 100) NormedLatticeAddCommGroup.toOrderedAddCommGroup {α : Type*} [h : NormedLatticeAddCommGroup α] : OrderedAddCommGroup α := { h with } #align normed_lattice_add_comm_group_to_ordered_add_comm_group NormedLatticeAddCommGroup.toOrderedAddCommGroup variable {α : Type*} [NormedLatticeAddCommGroup α] open HasSolidNorm
Mathlib/Analysis/Normed/Order/Lattice.lean
96
103
theorem dual_solid (a b : α) (h : b ⊓ -b ≤ a ⊓ -a) : ‖a‖ ≤ ‖b‖ := by
apply solid rw [abs] nth_rw 1 [← neg_neg a] rw [← neg_inf] rw [abs] nth_rw 1 [← neg_neg b] rwa [← neg_inf, neg_le_neg_iff, inf_comm _ b, inf_comm _ a]
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Yaël Dillies -/ import Mathlib.MeasureTheory.Integral.SetIntegral #align_import measure_theory.integral.average from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" /-! # Integral average of a function In this file we define `MeasureTheory.average μ f` (notation: `⨍ x, f x ∂μ`) to be the average value of `f` with respect to measure `μ`. It is defined as `∫ x, f x ∂((μ univ)⁻¹ • μ)`, so it is equal to zero if `f` is not integrable or if `μ` is an infinite measure. If `μ` is a probability measure, then the average of any function is equal to its integral. For the average on a set, we use `⨍ x in s, f x ∂μ` (notation for `⨍ x, f x ∂(μ.restrict s)`). For average w.r.t. the volume, one can omit `∂volume`. Both have a version for the Lebesgue integral rather than Bochner. We prove several version of the first moment method: An integrable function is below/above its average on a set of positive measure. ## Implementation notes The average is defined as an integral over `(μ univ)⁻¹ • μ` so that all theorems about Bochner integrals work for the average without modifications. For theorems that require integrability of a function, we provide a convenience lemma `MeasureTheory.Integrable.to_average`. ## TODO Provide the first moment method for the Lebesgue integral as well. A draft is available on branch `first_moment_lintegral` in mathlib3 repository. ## Tags integral, center mass, average value -/ open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function open scoped Topology ENNReal Convex variable {α E F : Type*} {m0 : MeasurableSpace α} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {μ ν : Measure α} {s t : Set α} /-! ### Average value of a function w.r.t. a measure The (Bochner, Lebesgue) average value of a function `f` w.r.t. a measure `μ` (notation: `⨍ x, f x ∂μ`, `⨍⁻ x, f x ∂μ`) is defined as the (Bochner, Lebesgue) integral divided by the total measure, so it is equal to zero if `μ` is an infinite measure, and (typically) equal to infinity if `f` is not integrable. If `μ` is a probability measure, then the average of any function is equal to its integral. -/ namespace MeasureTheory section ENNReal variable (μ) {f g : α → ℝ≥0∞} /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`, denoted `⨍⁻ x, f x ∂μ`. It is equal to `(μ univ)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `μ` is an infinite measure. If `μ` is a probability measure, then the average of any function is equal to its integral. For the average on a set, use `⨍⁻ x in s, f x ∂μ`, defined as `⨍⁻ x, f x ∂(μ.restrict s)`. For the average w.r.t. the volume, one can omit `∂volume`. -/ noncomputable def laverage (f : α → ℝ≥0∞) := ∫⁻ x, f x ∂(μ univ)⁻¹ • μ #align measure_theory.laverage MeasureTheory.laverage /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ`. It is equal to `(μ univ)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `μ` is an infinite measure. If `μ` is a probability measure, then the average of any function is equal to its integral. For the average on a set, use `⨍⁻ x in s, f x ∂μ`, defined as `⨍⁻ x, f x ∂(μ.restrict s)`. For the average w.r.t. the volume, one can omit `∂volume`. -/ notation3 "⨍⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => laverage μ r /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. to the standard measure. It is equal to `(volume univ)⁻¹ * ∫⁻ x, f x`, so it takes value zero if the space has infinite measure. In a probability space, the average of any function is equal to its integral. For the average on a set, use `⨍⁻ x in s, f x`, defined as `⨍⁻ x, f x ∂(volume.restrict s)`. -/ notation3 "⨍⁻ "(...)", "r:60:(scoped f => laverage volume f) => r /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. a measure `μ` on a set `s`. It is equal to `(μ s)⁻¹ * ∫⁻ x, f x ∂μ`, so it takes value zero if `s` has infinite measure. If `s` has measure `1`, then the average of any function is equal to its integral. For the average w.r.t. the volume, one can omit `∂volume`. -/ notation3 "⨍⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => laverage (Measure.restrict μ s) r /-- Average value of an `ℝ≥0∞`-valued function `f` w.r.t. to the standard measure on a set `s`. It is equal to `(volume s)⁻¹ * ∫⁻ x, f x`, so it takes value zero if `s` has infinite measure. If `s` has measure `1`, then the average of any function is equal to its integral. -/ notation3 (prettyPrint := false) "⨍⁻ "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r @[simp] theorem laverage_zero : ⨍⁻ _x, (0 : ℝ≥0∞) ∂μ = 0 := by rw [laverage, lintegral_zero] #align measure_theory.laverage_zero MeasureTheory.laverage_zero @[simp] theorem laverage_zero_measure (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂(0 : Measure α) = 0 := by simp [laverage] #align measure_theory.laverage_zero_measure MeasureTheory.laverage_zero_measure theorem laverage_eq' (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂(μ univ)⁻¹ • μ := rfl #align measure_theory.laverage_eq' MeasureTheory.laverage_eq' theorem laverage_eq (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = (∫⁻ x, f x ∂μ) / μ univ := by rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul] #align measure_theory.laverage_eq MeasureTheory.laverage_eq theorem laverage_eq_lintegral [IsProbabilityMeasure μ] (f : α → ℝ≥0∞) : ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [laverage, measure_univ, inv_one, one_smul] #align measure_theory.laverage_eq_lintegral MeasureTheory.laverage_eq_lintegral @[simp] theorem measure_mul_laverage [IsFiniteMeasure μ] (f : α → ℝ≥0∞) : μ univ * ⨍⁻ x, f x ∂μ = ∫⁻ x, f x ∂μ := by rcases eq_or_ne μ 0 with hμ | hμ · rw [hμ, lintegral_zero_measure, laverage_zero_measure, mul_zero] · rw [laverage_eq, ENNReal.mul_div_cancel' (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)] #align measure_theory.measure_mul_laverage MeasureTheory.measure_mul_laverage theorem setLaverage_eq (f : α → ℝ≥0∞) (s : Set α) : ⨍⁻ x in s, f x ∂μ = (∫⁻ x in s, f x ∂μ) / μ s := by rw [laverage_eq, restrict_apply_univ] #align measure_theory.set_laverage_eq MeasureTheory.setLaverage_eq theorem setLaverage_eq' (f : α → ℝ≥0∞) (s : Set α) : ⨍⁻ x in s, f x ∂μ = ∫⁻ x, f x ∂(μ s)⁻¹ • μ.restrict s := by simp only [laverage_eq', restrict_apply_univ] #align measure_theory.set_laverage_eq' MeasureTheory.setLaverage_eq' variable {μ} theorem laverage_congr {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ⨍⁻ x, f x ∂μ = ⨍⁻ x, g x ∂μ := by simp only [laverage_eq, lintegral_congr_ae h] #align measure_theory.laverage_congr MeasureTheory.laverage_congr theorem setLaverage_congr (h : s =ᵐ[μ] t) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in t, f x ∂μ := by simp only [setLaverage_eq, set_lintegral_congr h, measure_congr h] #align measure_theory.set_laverage_congr MeasureTheory.setLaverage_congr theorem setLaverage_congr_fun (hs : MeasurableSet s) (h : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ⨍⁻ x in s, f x ∂μ = ⨍⁻ x in s, g x ∂μ := by simp only [laverage_eq, set_lintegral_congr_fun hs h] #align measure_theory.set_laverage_congr_fun MeasureTheory.setLaverage_congr_fun theorem laverage_lt_top (hf : ∫⁻ x, f x ∂μ ≠ ∞) : ⨍⁻ x, f x ∂μ < ∞ := by obtain rfl | hμ := eq_or_ne μ 0 · simp · rw [laverage_eq] exact div_lt_top hf (measure_univ_ne_zero.2 hμ) #align measure_theory.laverage_lt_top MeasureTheory.laverage_lt_top theorem setLaverage_lt_top : ∫⁻ x in s, f x ∂μ ≠ ∞ → ⨍⁻ x in s, f x ∂μ < ∞ := laverage_lt_top #align measure_theory.set_laverage_lt_top MeasureTheory.setLaverage_lt_top theorem laverage_add_measure : ⨍⁻ x, f x ∂(μ + ν) = μ univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂μ + ν univ / (μ univ + ν univ) * ⨍⁻ x, f x ∂ν := by by_cases hμ : IsFiniteMeasure μ; swap · rw [not_isFiniteMeasure_iff] at hμ simp [laverage_eq, hμ] by_cases hν : IsFiniteMeasure ν; swap · rw [not_isFiniteMeasure_iff] at hν simp [laverage_eq, hν] haveI := hμ; haveI := hν simp only [← ENNReal.mul_div_right_comm, measure_mul_laverage, ← ENNReal.add_div, ← lintegral_add_measure, ← Measure.add_apply, ← laverage_eq] #align measure_theory.laverage_add_measure MeasureTheory.laverage_add_measure theorem measure_mul_setLaverage (f : α → ℝ≥0∞) (h : μ s ≠ ∞) : μ s * ⨍⁻ x in s, f x ∂μ = ∫⁻ x in s, f x ∂μ := by have := Fact.mk h.lt_top rw [← measure_mul_laverage, restrict_apply_univ] #align measure_theory.measure_mul_set_laverage MeasureTheory.measure_mul_setLaverage theorem laverage_union (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) : ⨍⁻ x in s ∪ t, f x ∂μ = μ s / (μ s + μ t) * ⨍⁻ x in s, f x ∂μ + μ t / (μ s + μ t) * ⨍⁻ x in t, f x ∂μ := by rw [restrict_union₀ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ] #align measure_theory.laverage_union MeasureTheory.laverage_union theorem laverage_union_mem_openSegment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) (hs₀ : μ s ≠ 0) (ht₀ : μ t ≠ 0) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) : ⨍⁻ x in s ∪ t, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in t, f x ∂μ) := by refine ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), ENNReal.div_pos hs₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, ENNReal.div_pos ht₀ <| add_ne_top.2 ⟨hsμ, htμ⟩, ?_, (laverage_union hd ht).symm⟩ rw [← ENNReal.add_div, ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)] #align measure_theory.laverage_union_mem_open_segment MeasureTheory.laverage_union_mem_openSegment theorem laverage_union_mem_segment (hd : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) (hsμ : μ s ≠ ∞) (htμ : μ t ≠ ∞) : ⨍⁻ x in s ∪ t, f x ∂μ ∈ [⨍⁻ x in s, f x ∂μ -[ℝ≥0∞] ⨍⁻ x in t, f x ∂μ] := by by_cases hs₀ : μ s = 0 · rw [← ae_eq_empty] at hs₀ rw [restrict_congr_set (hs₀.union EventuallyEq.rfl), empty_union] exact right_mem_segment _ _ _ · refine ⟨μ s / (μ s + μ t), μ t / (μ s + μ t), zero_le _, zero_le _, ?_, (laverage_union hd ht).symm⟩ rw [← ENNReal.add_div, ENNReal.div_self (add_eq_zero.not.2 fun h => hs₀ h.1) (add_ne_top.2 ⟨hsμ, htμ⟩)] #align measure_theory.laverage_union_mem_segment MeasureTheory.laverage_union_mem_segment theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ) (hs₀ : μ s ≠ 0) (hsc₀ : μ sᶜ ≠ 0) : ⨍⁻ x, f x ∂μ ∈ openSegment ℝ≥0∞ (⨍⁻ x in s, f x ∂μ) (⨍⁻ x in sᶜ, f x ∂μ) := by simpa only [union_compl_self, restrict_univ] using laverage_union_mem_openSegment aedisjoint_compl_right hs.compl hs₀ hsc₀ (measure_ne_top _ _) (measure_ne_top _ _) #align measure_theory.laverage_mem_open_segment_compl_self MeasureTheory.laverage_mem_openSegment_compl_self @[simp] theorem laverage_const (μ : Measure α) [IsFiniteMeasure μ] [h : NeZero μ] (c : ℝ≥0∞) : ⨍⁻ _x, c ∂μ = c := by simp only [laverage, lintegral_const, measure_univ, mul_one] #align measure_theory.laverage_const MeasureTheory.laverage_const theorem setLaverage_const (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) (c : ℝ≥0∞) : ⨍⁻ _x in s, c ∂μ = c := by simp only [setLaverage_eq, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hs₀ hs, mul_one] #align measure_theory.set_laverage_const MeasureTheory.setLaverage_const theorem laverage_one [IsFiniteMeasure μ] [NeZero μ] : ⨍⁻ _x, (1 : ℝ≥0∞) ∂μ = 1 := laverage_const _ _ #align measure_theory.laverage_one MeasureTheory.laverage_one theorem setLaverage_one (hs₀ : μ s ≠ 0) (hs : μ s ≠ ∞) : ⨍⁻ _x in s, (1 : ℝ≥0∞) ∂μ = 1 := setLaverage_const hs₀ hs _ #align measure_theory.set_laverage_one MeasureTheory.setLaverage_one -- Porting note: Dropped `simp` because of `simp` seeing through `1 : α → ℝ≥0∞` and applying -- `lintegral_const`. This is suboptimal.
Mathlib/MeasureTheory/Integral/Average.lean
247
252
theorem lintegral_laverage (μ : Measure α) [IsFiniteMeasure μ] (f : α → ℝ≥0∞) : ∫⁻ _x, ⨍⁻ a, f a ∂μ ∂μ = ∫⁻ x, f x ∂μ := by
obtain rfl | hμ := eq_or_ne μ 0 · simp · rw [lintegral_const, laverage_eq, ENNReal.div_mul_cancel (measure_univ_ne_zero.2 hμ) (measure_ne_top _ _)]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.Topology.Maps import Mathlib.Topology.NhdsSet #align_import topology.constructions from "leanprover-community/mathlib"@"f7ebde7ee0d1505dfccac8644ae12371aa3c1c9f" /-! # Constructions of new topological spaces from old ones This file constructs products, sums, subtypes and quotients of topological spaces and sets up their basic theory, such as criteria for maps into or out of these constructions to be continuous; descriptions of the open sets, neighborhood filters, and generators of these constructions; and their behavior with respect to embeddings and other specific classes of maps. ## Implementation note The constructed topologies are defined using induced and coinduced topologies along with the complete lattice structure on topologies. Their universal properties (for example, a map `X → Y × Z` is continuous if and only if both projections `X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of continuity. With more work we can also extract descriptions of the open sets, neighborhood filters and so on. ## Tags product, sum, disjoint union, subspace, quotient space -/ noncomputable section open scoped Classical open Topology TopologicalSpace Set Filter Function universe u v variable {X : Type u} {Y : Type v} {Z W ε ζ : Type*} section Constructions instance instTopologicalSpaceSubtype {p : X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Subtype p) := induced (↑) t instance {r : X → X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Quot r) := coinduced (Quot.mk r) t instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] : TopologicalSpace (Quotient s) := coinduced Quotient.mk' t instance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X × Y) := induced Prod.fst t₁ ⊓ induced Prod.snd t₂ instance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X ⊕ Y) := coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂ instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] : TopologicalSpace (Sigma X) := ⨆ i, coinduced (Sigma.mk i) (t₂ i) instance Pi.topologicalSpace {ι : Type*} {Y : ι → Type v} [t₂ : (i : ι) → TopologicalSpace (Y i)] : TopologicalSpace ((i : ι) → Y i) := ⨅ i, induced (fun f => f i) (t₂ i) #align Pi.topological_space Pi.topologicalSpace instance ULift.topologicalSpace [t : TopologicalSpace X] : TopologicalSpace (ULift.{v, u} X) := t.induced ULift.down #align ulift.topological_space ULift.topologicalSpace /-! ### `Additive`, `Multiplicative` The topology on those type synonyms is inherited without change. -/ section variable [TopologicalSpace X] open Additive Multiplicative instance : TopologicalSpace (Additive X) := ‹TopologicalSpace X› instance : TopologicalSpace (Multiplicative X) := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology (Additive X) := ‹DiscreteTopology X› instance [DiscreteTopology X] : DiscreteTopology (Multiplicative X) := ‹DiscreteTopology X› theorem continuous_ofMul : Continuous (ofMul : X → Additive X) := continuous_id #align continuous_of_mul continuous_ofMul theorem continuous_toMul : Continuous (toMul : Additive X → X) := continuous_id #align continuous_to_mul continuous_toMul theorem continuous_ofAdd : Continuous (ofAdd : X → Multiplicative X) := continuous_id #align continuous_of_add continuous_ofAdd theorem continuous_toAdd : Continuous (toAdd : Multiplicative X → X) := continuous_id #align continuous_to_add continuous_toAdd theorem isOpenMap_ofMul : IsOpenMap (ofMul : X → Additive X) := IsOpenMap.id #align is_open_map_of_mul isOpenMap_ofMul theorem isOpenMap_toMul : IsOpenMap (toMul : Additive X → X) := IsOpenMap.id #align is_open_map_to_mul isOpenMap_toMul theorem isOpenMap_ofAdd : IsOpenMap (ofAdd : X → Multiplicative X) := IsOpenMap.id #align is_open_map_of_add isOpenMap_ofAdd theorem isOpenMap_toAdd : IsOpenMap (toAdd : Multiplicative X → X) := IsOpenMap.id #align is_open_map_to_add isOpenMap_toAdd theorem isClosedMap_ofMul : IsClosedMap (ofMul : X → Additive X) := IsClosedMap.id #align is_closed_map_of_mul isClosedMap_ofMul theorem isClosedMap_toMul : IsClosedMap (toMul : Additive X → X) := IsClosedMap.id #align is_closed_map_to_mul isClosedMap_toMul theorem isClosedMap_ofAdd : IsClosedMap (ofAdd : X → Multiplicative X) := IsClosedMap.id #align is_closed_map_of_add isClosedMap_ofAdd theorem isClosedMap_toAdd : IsClosedMap (toAdd : Multiplicative X → X) := IsClosedMap.id #align is_closed_map_to_add isClosedMap_toAdd theorem nhds_ofMul (x : X) : 𝓝 (ofMul x) = map ofMul (𝓝 x) := rfl #align nhds_of_mul nhds_ofMul theorem nhds_ofAdd (x : X) : 𝓝 (ofAdd x) = map ofAdd (𝓝 x) := rfl #align nhds_of_add nhds_ofAdd theorem nhds_toMul (x : Additive X) : 𝓝 (toMul x) = map toMul (𝓝 x) := rfl #align nhds_to_mul nhds_toMul theorem nhds_toAdd (x : Multiplicative X) : 𝓝 (toAdd x) = map toAdd (𝓝 x) := rfl #align nhds_to_add nhds_toAdd end /-! ### Order dual The topology on this type synonym is inherited without change. -/ section variable [TopologicalSpace X] open OrderDual instance : TopologicalSpace Xᵒᵈ := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology Xᵒᵈ := ‹DiscreteTopology X› theorem continuous_toDual : Continuous (toDual : X → Xᵒᵈ) := continuous_id #align continuous_to_dual continuous_toDual theorem continuous_ofDual : Continuous (ofDual : Xᵒᵈ → X) := continuous_id #align continuous_of_dual continuous_ofDual theorem isOpenMap_toDual : IsOpenMap (toDual : X → Xᵒᵈ) := IsOpenMap.id #align is_open_map_to_dual isOpenMap_toDual theorem isOpenMap_ofDual : IsOpenMap (ofDual : Xᵒᵈ → X) := IsOpenMap.id #align is_open_map_of_dual isOpenMap_ofDual theorem isClosedMap_toDual : IsClosedMap (toDual : X → Xᵒᵈ) := IsClosedMap.id #align is_closed_map_to_dual isClosedMap_toDual theorem isClosedMap_ofDual : IsClosedMap (ofDual : Xᵒᵈ → X) := IsClosedMap.id #align is_closed_map_of_dual isClosedMap_ofDual theorem nhds_toDual (x : X) : 𝓝 (toDual x) = map toDual (𝓝 x) := rfl #align nhds_to_dual nhds_toDual theorem nhds_ofDual (x : X) : 𝓝 (ofDual x) = map ofDual (𝓝 x) := rfl #align nhds_of_dual nhds_ofDual end theorem Quotient.preimage_mem_nhds [TopologicalSpace X] [s : Setoid X] {V : Set <| Quotient s} {x : X} (hs : V ∈ 𝓝 (Quotient.mk' x)) : Quotient.mk' ⁻¹' V ∈ 𝓝 x := preimage_nhds_coinduced hs #align quotient.preimage_mem_nhds Quotient.preimage_mem_nhds /-- The image of a dense set under `Quotient.mk'` is a dense set. -/ theorem Dense.quotient [Setoid X] [TopologicalSpace X] {s : Set X} (H : Dense s) : Dense (Quotient.mk' '' s) := Quotient.surjective_Quotient_mk''.denseRange.dense_image continuous_coinduced_rng H #align dense.quotient Dense.quotient /-- The composition of `Quotient.mk'` and a function with dense range has dense range. -/ theorem DenseRange.quotient [Setoid X] [TopologicalSpace X] {f : Y → X} (hf : DenseRange f) : DenseRange (Quotient.mk' ∘ f) := Quotient.surjective_Quotient_mk''.denseRange.comp hf continuous_coinduced_rng #align dense_range.quotient DenseRange.quotient theorem continuous_map_of_le {α : Type*} [TopologicalSpace α] {s t : Setoid α} (h : s ≤ t) : Continuous (Setoid.map_of_le h) := continuous_coinduced_rng theorem continuous_map_sInf {α : Type*} [TopologicalSpace α] {S : Set (Setoid α)} {s : Setoid α} (h : s ∈ S) : Continuous (Setoid.map_sInf h) := continuous_coinduced_rng instance {p : X → Prop} [TopologicalSpace X] [DiscreteTopology X] : DiscreteTopology (Subtype p) := ⟨bot_unique fun s _ => ⟨(↑) '' s, isOpen_discrete _, preimage_image_eq _ Subtype.val_injective⟩⟩ instance Sum.discreteTopology [TopologicalSpace X] [TopologicalSpace Y] [h : DiscreteTopology X] [hY : DiscreteTopology Y] : DiscreteTopology (X ⊕ Y) := ⟨sup_eq_bot_iff.2 <| by simp [h.eq_bot, hY.eq_bot]⟩ #align sum.discrete_topology Sum.discreteTopology instance Sigma.discreteTopology {ι : Type*} {Y : ι → Type v} [∀ i, TopologicalSpace (Y i)] [h : ∀ i, DiscreteTopology (Y i)] : DiscreteTopology (Sigma Y) := ⟨iSup_eq_bot.2 fun _ => by simp only [(h _).eq_bot, coinduced_bot]⟩ #align sigma.discrete_topology Sigma.discreteTopology section Top variable [TopologicalSpace X] /- The 𝓝 filter and the subspace topology. -/ theorem mem_nhds_subtype (s : Set X) (x : { x // x ∈ s }) (t : Set { x // x ∈ s }) : t ∈ 𝓝 x ↔ ∃ u ∈ 𝓝 (x : X), Subtype.val ⁻¹' u ⊆ t := mem_nhds_induced _ x t #align mem_nhds_subtype mem_nhds_subtype theorem nhds_subtype (s : Set X) (x : { x // x ∈ s }) : 𝓝 x = comap (↑) (𝓝 (x : X)) := nhds_induced _ x #align nhds_subtype nhds_subtype theorem nhdsWithin_subtype_eq_bot_iff {s t : Set X} {x : s} : 𝓝[((↑) : s → X) ⁻¹' t] x = ⊥ ↔ 𝓝[t] (x : X) ⊓ 𝓟 s = ⊥ := by rw [inf_principal_eq_bot_iff_comap, nhdsWithin, nhdsWithin, comap_inf, comap_principal, nhds_induced] #align nhds_within_subtype_eq_bot_iff nhdsWithin_subtype_eq_bot_iff theorem nhds_ne_subtype_eq_bot_iff {S : Set X} {x : S} : 𝓝[≠] x = ⊥ ↔ 𝓝[≠] (x : X) ⊓ 𝓟 S = ⊥ := by rw [← nhdsWithin_subtype_eq_bot_iff, preimage_compl, ← image_singleton, Subtype.coe_injective.preimage_image] #align nhds_ne_subtype_eq_bot_iff nhds_ne_subtype_eq_bot_iff theorem nhds_ne_subtype_neBot_iff {S : Set X} {x : S} : (𝓝[≠] x).NeBot ↔ (𝓝[≠] (x : X) ⊓ 𝓟 S).NeBot := by rw [neBot_iff, neBot_iff, not_iff_not, nhds_ne_subtype_eq_bot_iff] #align nhds_ne_subtype_ne_bot_iff nhds_ne_subtype_neBot_iff theorem discreteTopology_subtype_iff {S : Set X} : DiscreteTopology S ↔ ∀ x ∈ S, 𝓝[≠] x ⊓ 𝓟 S = ⊥ := by simp_rw [discreteTopology_iff_nhds_ne, SetCoe.forall', nhds_ne_subtype_eq_bot_iff] #align discrete_topology_subtype_iff discreteTopology_subtype_iff end Top /-- A type synonym equipped with the topology whose open sets are the empty set and the sets with finite complements. -/ def CofiniteTopology (X : Type*) := X #align cofinite_topology CofiniteTopology namespace CofiniteTopology /-- The identity equivalence between `` and `CofiniteTopology `. -/ def of : X ≃ CofiniteTopology X := Equiv.refl X #align cofinite_topology.of CofiniteTopology.of instance [Inhabited X] : Inhabited (CofiniteTopology X) where default := of default instance : TopologicalSpace (CofiniteTopology X) where IsOpen s := s.Nonempty → Set.Finite sᶜ isOpen_univ := by simp isOpen_inter s t := by rintro hs ht ⟨x, hxs, hxt⟩ rw [compl_inter] exact (hs ⟨x, hxs⟩).union (ht ⟨x, hxt⟩) isOpen_sUnion := by rintro s h ⟨x, t, hts, hzt⟩ rw [compl_sUnion] exact Finite.sInter (mem_image_of_mem _ hts) (h t hts ⟨x, hzt⟩) theorem isOpen_iff {s : Set (CofiniteTopology X)} : IsOpen s ↔ s.Nonempty → sᶜ.Finite := Iff.rfl #align cofinite_topology.is_open_iff CofiniteTopology.isOpen_iff theorem isOpen_iff' {s : Set (CofiniteTopology X)} : IsOpen s ↔ s = ∅ ∨ sᶜ.Finite := by simp only [isOpen_iff, nonempty_iff_ne_empty, or_iff_not_imp_left] #align cofinite_topology.is_open_iff' CofiniteTopology.isOpen_iff' theorem isClosed_iff {s : Set (CofiniteTopology X)} : IsClosed s ↔ s = univ ∨ s.Finite := by simp only [← isOpen_compl_iff, isOpen_iff', compl_compl, compl_empty_iff] #align cofinite_topology.is_closed_iff CofiniteTopology.isClosed_iff theorem nhds_eq (x : CofiniteTopology X) : 𝓝 x = pure x ⊔ cofinite := by ext U rw [mem_nhds_iff] constructor · rintro ⟨V, hVU, V_op, haV⟩ exact mem_sup.mpr ⟨hVU haV, mem_of_superset (V_op ⟨_, haV⟩) hVU⟩ · rintro ⟨hU : x ∈ U, hU' : Uᶜ.Finite⟩ exact ⟨U, Subset.rfl, fun _ => hU', hU⟩ #align cofinite_topology.nhds_eq CofiniteTopology.nhds_eq theorem mem_nhds_iff {x : CofiniteTopology X} {s : Set (CofiniteTopology X)} : s ∈ 𝓝 x ↔ x ∈ s ∧ sᶜ.Finite := by simp [nhds_eq] #align cofinite_topology.mem_nhds_iff CofiniteTopology.mem_nhds_iff end CofiniteTopology end Constructions section Prod variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W] [TopologicalSpace ε] [TopologicalSpace ζ] -- Porting note (#11215): TODO: Lean 4 fails to deduce implicit args @[simp] theorem continuous_prod_mk {f : X → Y} {g : X → Z} : (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g := (@continuous_inf_rng X (Y × Z) _ _ (TopologicalSpace.induced Prod.fst _) (TopologicalSpace.induced Prod.snd _)).trans <| continuous_induced_rng.and continuous_induced_rng #align continuous_prod_mk continuous_prod_mk @[continuity] theorem continuous_fst : Continuous (@Prod.fst X Y) := (continuous_prod_mk.1 continuous_id).1 #align continuous_fst continuous_fst /-- Postcomposing `f` with `Prod.fst` is continuous -/ @[fun_prop] theorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 := continuous_fst.comp hf #align continuous.fst Continuous.fst /-- Precomposing `f` with `Prod.fst` is continuous -/ theorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst := hf.comp continuous_fst #align continuous.fst' Continuous.fst' theorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p := continuous_fst.continuousAt #align continuous_at_fst continuousAt_fst /-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/ @[fun_prop] theorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) : ContinuousAt (fun x : X => (f x).1) x := continuousAt_fst.comp hf #align continuous_at.fst ContinuousAt.fst /-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/ theorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) : ContinuousAt (fun x : X × Y => f x.fst) (x, y) := ContinuousAt.comp hf continuousAt_fst #align continuous_at.fst' ContinuousAt.fst' /-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/ theorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) : ContinuousAt (fun x : X × Y => f x.fst) x := hf.comp continuousAt_fst #align continuous_at.fst'' ContinuousAt.fst'' theorem Filter.Tendsto.fst_nhds {l : Filter X} {f : X → Y × Z} {p : Y × Z} (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) := continuousAt_fst.tendsto.comp h @[continuity] theorem continuous_snd : Continuous (@Prod.snd X Y) := (continuous_prod_mk.1 continuous_id).2 #align continuous_snd continuous_snd /-- Postcomposing `f` with `Prod.snd` is continuous -/ @[fun_prop] theorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 := continuous_snd.comp hf #align continuous.snd Continuous.snd /-- Precomposing `f` with `Prod.snd` is continuous -/ theorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd := hf.comp continuous_snd #align continuous.snd' Continuous.snd' theorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p := continuous_snd.continuousAt #align continuous_at_snd continuousAt_snd /-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/ @[fun_prop] theorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) : ContinuousAt (fun x : X => (f x).2) x := continuousAt_snd.comp hf #align continuous_at.snd ContinuousAt.snd /-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/ theorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) : ContinuousAt (fun x : X × Y => f x.snd) (x, y) := ContinuousAt.comp hf continuousAt_snd #align continuous_at.snd' ContinuousAt.snd' /-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/ theorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) : ContinuousAt (fun x : X × Y => f x.snd) x := hf.comp continuousAt_snd #align continuous_at.snd'' ContinuousAt.snd'' theorem Filter.Tendsto.snd_nhds {l : Filter X} {f : X → Y × Z} {p : Y × Z} (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) := continuousAt_snd.tendsto.comp h @[continuity, fun_prop] theorem Continuous.prod_mk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) : Continuous fun x => (f x, g x) := continuous_prod_mk.2 ⟨hf, hg⟩ #align continuous.prod_mk Continuous.prod_mk @[continuity] theorem Continuous.Prod.mk (x : X) : Continuous fun y : Y => (x, y) := continuous_const.prod_mk continuous_id #align continuous.prod.mk Continuous.Prod.mk @[continuity] theorem Continuous.Prod.mk_left (y : Y) : Continuous fun x : X => (x, y) := continuous_id.prod_mk continuous_const #align continuous.prod.mk_left Continuous.Prod.mk_left /-- If `f x y` is continuous in `x` for all `y ∈ s`, then the set of `x` such that `f x` maps `s` to `t` is closed. -/ lemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t) (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} := by simpa only [MapsTo, setOf_forall] using isClosed_biInter fun y hy ↦ ht.preimage (hf y hy) theorem Continuous.comp₂ {g : X × Y → Z} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) : Continuous fun w => g (e w, f w) := hg.comp <| he.prod_mk hf #align continuous.comp₂ Continuous.comp₂ theorem Continuous.comp₃ {g : X × Y × Z → ε} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) : Continuous fun w => g (e w, f w, k w) := hg.comp₂ he <| hf.prod_mk hk #align continuous.comp₃ Continuous.comp₃ theorem Continuous.comp₄ {g : X × Y × Z × ζ → ε} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) {l : W → ζ} (hl : Continuous l) : Continuous fun w => g (e w, f w, k w, l w) := hg.comp₃ he hf <| hk.prod_mk hl #align continuous.comp₄ Continuous.comp₄ @[continuity] theorem Continuous.prod_map {f : Z → X} {g : W → Y} (hf : Continuous f) (hg : Continuous g) : Continuous fun p : Z × W => (f p.1, g p.2) := hf.fst'.prod_mk hg.snd' #align continuous.prod_map Continuous.prod_map /-- A version of `continuous_inf_dom_left` for binary functions -/ theorem continuous_inf_dom_left₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X} {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z} (h : by haveI := ta1; haveI := tb1; exact Continuous fun p : X × Y => f p.1 p.2) : by haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by have ha := @continuous_inf_dom_left _ _ id ta1 ta2 ta1 (@continuous_id _ (id _)) have hb := @continuous_inf_dom_left _ _ id tb1 tb2 tb1 (@continuous_id _ (id _)) have h_continuous_id := @Continuous.prod_map _ _ _ _ ta1 tb1 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id #align continuous_inf_dom_left₂ continuous_inf_dom_left₂ /-- A version of `continuous_inf_dom_right` for binary functions -/ theorem continuous_inf_dom_right₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X} {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z} (h : by haveI := ta2; haveI := tb2; exact Continuous fun p : X × Y => f p.1 p.2) : by haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by have ha := @continuous_inf_dom_right _ _ id ta1 ta2 ta2 (@continuous_id _ (id _)) have hb := @continuous_inf_dom_right _ _ id tb1 tb2 tb2 (@continuous_id _ (id _)) have h_continuous_id := @Continuous.prod_map _ _ _ _ ta2 tb2 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id #align continuous_inf_dom_right₂ continuous_inf_dom_right₂ /-- A version of `continuous_sInf_dom` for binary functions -/ theorem continuous_sInf_dom₂ {X Y Z} {f : X → Y → Z} {tas : Set (TopologicalSpace X)} {tbs : Set (TopologicalSpace Y)} {tX : TopologicalSpace X} {tY : TopologicalSpace Y} {tc : TopologicalSpace Z} (hX : tX ∈ tas) (hY : tY ∈ tbs) (hf : Continuous fun p : X × Y => f p.1 p.2) : by haveI := sInf tas; haveI := sInf tbs; exact @Continuous _ _ _ tc fun p : X × Y => f p.1 p.2 := by have hX := continuous_sInf_dom hX continuous_id have hY := continuous_sInf_dom hY continuous_id have h_continuous_id := @Continuous.prod_map _ _ _ _ tX tY (sInf tas) (sInf tbs) _ _ hX hY exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ hf h_continuous_id #align continuous_Inf_dom₂ continuous_sInf_dom₂ theorem Filter.Eventually.prod_inl_nhds {p : X → Prop} {x : X} (h : ∀ᶠ x in 𝓝 x, p x) (y : Y) : ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).1 := continuousAt_fst h #align filter.eventually.prod_inl_nhds Filter.Eventually.prod_inl_nhds theorem Filter.Eventually.prod_inr_nhds {p : Y → Prop} {y : Y} (h : ∀ᶠ x in 𝓝 y, p x) (x : X) : ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).2 := continuousAt_snd h #align filter.eventually.prod_inr_nhds Filter.Eventually.prod_inr_nhds theorem Filter.Eventually.prod_mk_nhds {px : X → Prop} {x} (hx : ∀ᶠ x in 𝓝 x, px x) {py : Y → Prop} {y} (hy : ∀ᶠ y in 𝓝 y, py y) : ∀ᶠ p in 𝓝 (x, y), px (p : X × Y).1 ∧ py p.2 := (hx.prod_inl_nhds y).and (hy.prod_inr_nhds x) #align filter.eventually.prod_mk_nhds Filter.Eventually.prod_mk_nhds theorem continuous_swap : Continuous (Prod.swap : X × Y → Y × X) := continuous_snd.prod_mk continuous_fst #align continuous_swap continuous_swap lemma isClosedMap_swap : IsClosedMap (Prod.swap : X × Y → Y × X) := fun s hs ↦ by rw [image_swap_eq_preimage_swap] exact hs.preimage continuous_swap theorem Continuous.uncurry_left {f : X → Y → Z} (x : X) (h : Continuous (uncurry f)) : Continuous (f x) := h.comp (Continuous.Prod.mk _) #align continuous_uncurry_left Continuous.uncurry_left theorem Continuous.uncurry_right {f : X → Y → Z} (y : Y) (h : Continuous (uncurry f)) : Continuous fun a => f a y := h.comp (Continuous.Prod.mk_left _) #align continuous_uncurry_right Continuous.uncurry_right -- 2024-03-09 @[deprecated] alias continuous_uncurry_left := Continuous.uncurry_left @[deprecated] alias continuous_uncurry_right := Continuous.uncurry_right theorem continuous_curry {g : X × Y → Z} (x : X) (h : Continuous g) : Continuous (curry g x) := Continuous.uncurry_left x h #align continuous_curry continuous_curry theorem IsOpen.prod {s : Set X} {t : Set Y} (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ×ˢ t) := (hs.preimage continuous_fst).inter (ht.preimage continuous_snd) #align is_open.prod IsOpen.prod -- Porting note (#11215): TODO: Lean fails to find `t₁` and `t₂` by unification theorem nhds_prod_eq {x : X} {y : Y} : 𝓝 (x, y) = 𝓝 x ×ˢ 𝓝 y := by dsimp only [SProd.sprod] rw [Filter.prod, instTopologicalSpaceProd, nhds_inf (t₁ := TopologicalSpace.induced Prod.fst _) (t₂ := TopologicalSpace.induced Prod.snd _), nhds_induced, nhds_induced] #align nhds_prod_eq nhds_prod_eq -- Porting note: moved from `Topology.ContinuousOn` theorem nhdsWithin_prod_eq (x : X) (y : Y) (s : Set X) (t : Set Y) : 𝓝[s ×ˢ t] (x, y) = 𝓝[s] x ×ˢ 𝓝[t] y := by simp only [nhdsWithin, nhds_prod_eq, ← prod_inf_prod, prod_principal_principal] #align nhds_within_prod_eq nhdsWithin_prod_eq #noalign continuous_uncurry_of_discrete_topology theorem mem_nhds_prod_iff {x : X} {y : Y} {s : Set (X × Y)} : s ∈ 𝓝 (x, y) ↔ ∃ u ∈ 𝓝 x, ∃ v ∈ 𝓝 y, u ×ˢ v ⊆ s := by rw [nhds_prod_eq, mem_prod_iff] #align mem_nhds_prod_iff mem_nhds_prod_iff theorem mem_nhdsWithin_prod_iff {x : X} {y : Y} {s : Set (X × Y)} {tx : Set X} {ty : Set Y} : s ∈ 𝓝[tx ×ˢ ty] (x, y) ↔ ∃ u ∈ 𝓝[tx] x, ∃ v ∈ 𝓝[ty] y, u ×ˢ v ⊆ s := by rw [nhdsWithin_prod_eq, mem_prod_iff] -- Porting note: moved up theorem Filter.HasBasis.prod_nhds {ιX ιY : Type*} {px : ιX → Prop} {py : ιY → Prop} {sx : ιX → Set X} {sy : ιY → Set Y} {x : X} {y : Y} (hx : (𝓝 x).HasBasis px sx) (hy : (𝓝 y).HasBasis py sy) : (𝓝 (x, y)).HasBasis (fun i : ιX × ιY => px i.1 ∧ py i.2) fun i => sx i.1 ×ˢ sy i.2 := by rw [nhds_prod_eq] exact hx.prod hy #align filter.has_basis.prod_nhds Filter.HasBasis.prod_nhds -- Porting note: moved up theorem Filter.HasBasis.prod_nhds' {ιX ιY : Type*} {pX : ιX → Prop} {pY : ιY → Prop} {sx : ιX → Set X} {sy : ιY → Set Y} {p : X × Y} (hx : (𝓝 p.1).HasBasis pX sx) (hy : (𝓝 p.2).HasBasis pY sy) : (𝓝 p).HasBasis (fun i : ιX × ιY => pX i.1 ∧ pY i.2) fun i => sx i.1 ×ˢ sy i.2 := hx.prod_nhds hy #align filter.has_basis.prod_nhds' Filter.HasBasis.prod_nhds' theorem mem_nhds_prod_iff' {x : X} {y : Y} {s : Set (X × Y)} : s ∈ 𝓝 (x, y) ↔ ∃ u v, IsOpen u ∧ x ∈ u ∧ IsOpen v ∧ y ∈ v ∧ u ×ˢ v ⊆ s := ((nhds_basis_opens x).prod_nhds (nhds_basis_opens y)).mem_iff.trans <| by simp only [Prod.exists, and_comm, and_assoc, and_left_comm] #align mem_nhds_prod_iff' mem_nhds_prod_iff' theorem Prod.tendsto_iff {X} (seq : X → Y × Z) {f : Filter X} (p : Y × Z) : Tendsto seq f (𝓝 p) ↔ Tendsto (fun n => (seq n).fst) f (𝓝 p.fst) ∧ Tendsto (fun n => (seq n).snd) f (𝓝 p.snd) := by rw [nhds_prod_eq, Filter.tendsto_prod_iff'] #align prod.tendsto_iff Prod.tendsto_iff instance [DiscreteTopology X] [DiscreteTopology Y] : DiscreteTopology (X × Y) := discreteTopology_iff_nhds.2 fun (a, b) => by rw [nhds_prod_eq, nhds_discrete X, nhds_discrete Y, prod_pure_pure] theorem prod_mem_nhds_iff {s : Set X} {t : Set Y} {x : X} {y : Y} : s ×ˢ t ∈ 𝓝 (x, y) ↔ s ∈ 𝓝 x ∧ t ∈ 𝓝 y := by rw [nhds_prod_eq, prod_mem_prod_iff] #align prod_mem_nhds_iff prod_mem_nhds_iff theorem prod_mem_nhds {s : Set X} {t : Set Y} {x : X} {y : Y} (hx : s ∈ 𝓝 x) (hy : t ∈ 𝓝 y) : s ×ˢ t ∈ 𝓝 (x, y) := prod_mem_nhds_iff.2 ⟨hx, hy⟩ #align prod_mem_nhds prod_mem_nhds theorem isOpen_setOf_disjoint_nhds_nhds : IsOpen { p : X × X | Disjoint (𝓝 p.1) (𝓝 p.2) } := by simp only [isOpen_iff_mem_nhds, Prod.forall, mem_setOf_eq] intro x y h obtain ⟨U, hU, V, hV, hd⟩ := ((nhds_basis_opens x).disjoint_iff (nhds_basis_opens y)).mp h exact mem_nhds_prod_iff'.mpr ⟨U, V, hU.2, hU.1, hV.2, hV.1, fun ⟨x', y'⟩ ⟨hx', hy'⟩ => disjoint_of_disjoint_of_mem hd (hU.2.mem_nhds hx') (hV.2.mem_nhds hy')⟩ #align is_open_set_of_disjoint_nhds_nhds isOpen_setOf_disjoint_nhds_nhds theorem Filter.Eventually.prod_nhds {p : X → Prop} {q : Y → Prop} {x : X} {y : Y} (hx : ∀ᶠ x in 𝓝 x, p x) (hy : ∀ᶠ y in 𝓝 y, q y) : ∀ᶠ z : X × Y in 𝓝 (x, y), p z.1 ∧ q z.2 := prod_mem_nhds hx hy #align filter.eventually.prod_nhds Filter.Eventually.prod_nhds theorem nhds_swap (x : X) (y : Y) : 𝓝 (x, y) = (𝓝 (y, x)).map Prod.swap := by rw [nhds_prod_eq, Filter.prod_comm, nhds_prod_eq]; rfl #align nhds_swap nhds_swap theorem Filter.Tendsto.prod_mk_nhds {γ} {x : X} {y : Y} {f : Filter γ} {mx : γ → X} {my : γ → Y} (hx : Tendsto mx f (𝓝 x)) (hy : Tendsto my f (𝓝 y)) : Tendsto (fun c => (mx c, my c)) f (𝓝 (x, y)) := by rw [nhds_prod_eq]; exact Filter.Tendsto.prod_mk hx hy #align filter.tendsto.prod_mk_nhds Filter.Tendsto.prod_mk_nhds theorem Filter.Eventually.curry_nhds {p : X × Y → Prop} {x : X} {y : Y} (h : ∀ᶠ x in 𝓝 (x, y), p x) : ∀ᶠ x' in 𝓝 x, ∀ᶠ y' in 𝓝 y, p (x', y') := by rw [nhds_prod_eq] at h exact h.curry #align filter.eventually.curry_nhds Filter.Eventually.curry_nhds @[fun_prop] theorem ContinuousAt.prod {f : X → Y} {g : X → Z} {x : X} (hf : ContinuousAt f x) (hg : ContinuousAt g x) : ContinuousAt (fun x => (f x, g x)) x := hf.prod_mk_nhds hg #align continuous_at.prod ContinuousAt.prod theorem ContinuousAt.prod_map {f : X → Z} {g : Y → W} {p : X × Y} (hf : ContinuousAt f p.fst) (hg : ContinuousAt g p.snd) : ContinuousAt (fun p : X × Y => (f p.1, g p.2)) p := hf.fst''.prod hg.snd'' #align continuous_at.prod_map ContinuousAt.prod_map theorem ContinuousAt.prod_map' {f : X → Z} {g : Y → W} {x : X} {y : Y} (hf : ContinuousAt f x) (hg : ContinuousAt g y) : ContinuousAt (fun p : X × Y => (f p.1, g p.2)) (x, y) := hf.fst'.prod hg.snd' #align continuous_at.prod_map' ContinuousAt.prod_map' theorem ContinuousAt.comp₂ {f : Y × Z → W} {g : X → Y} {h : X → Z} {x : X} (hf : ContinuousAt f (g x, h x)) (hg : ContinuousAt g x) (hh : ContinuousAt h x) : ContinuousAt (fun x ↦ f (g x, h x)) x := ContinuousAt.comp hf (hg.prod hh) theorem ContinuousAt.comp₂_of_eq {f : Y × Z → W} {g : X → Y} {h : X → Z} {x : X} {y : Y × Z} (hf : ContinuousAt f y) (hg : ContinuousAt g x) (hh : ContinuousAt h x) (e : (g x, h x) = y) : ContinuousAt (fun x ↦ f (g x, h x)) x := by rw [← e] at hf exact hf.comp₂ hg hh /-- Continuous functions on products are continuous in their first argument -/ theorem Continuous.curry_left {f : X × Y → Z} (hf : Continuous f) {y : Y} : Continuous fun x ↦ f (x, y) := hf.comp (continuous_id.prod_mk continuous_const) alias Continuous.along_fst := Continuous.curry_left /-- Continuous functions on products are continuous in their second argument -/ theorem Continuous.curry_right {f : X × Y → Z} (hf : Continuous f) {x : X} : Continuous fun y ↦ f (x, y) := hf.comp (continuous_const.prod_mk continuous_id) alias Continuous.along_snd := Continuous.curry_right -- todo: prove a version of `generateFrom_union` with `image2 (∩) s t` in the LHS and use it here theorem prod_generateFrom_generateFrom_eq {X Y : Type*} {s : Set (Set X)} {t : Set (Set Y)} (hs : ⋃₀ s = univ) (ht : ⋃₀ t = univ) : @instTopologicalSpaceProd X Y (generateFrom s) (generateFrom t) = generateFrom (image2 (· ×ˢ ·) s t) := let G := generateFrom (image2 (· ×ˢ ·) s t) le_antisymm (le_generateFrom fun g ⟨u, hu, v, hv, g_eq⟩ => g_eq.symm ▸ @IsOpen.prod _ _ (generateFrom s) (generateFrom t) _ _ (GenerateOpen.basic _ hu) (GenerateOpen.basic _ hv)) (le_inf (coinduced_le_iff_le_induced.mp <| le_generateFrom fun u hu => have : ⋃ v ∈ t, u ×ˢ v = Prod.fst ⁻¹' u := by simp_rw [← prod_iUnion, ← sUnion_eq_biUnion, ht, prod_univ] show G.IsOpen (Prod.fst ⁻¹' u) by rw [← this] exact isOpen_iUnion fun v => isOpen_iUnion fun hv => GenerateOpen.basic _ ⟨_, hu, _, hv, rfl⟩) (coinduced_le_iff_le_induced.mp <| le_generateFrom fun v hv => have : ⋃ u ∈ s, u ×ˢ v = Prod.snd ⁻¹' v := by simp_rw [← iUnion_prod_const, ← sUnion_eq_biUnion, hs, univ_prod] show G.IsOpen (Prod.snd ⁻¹' v) by rw [← this] exact isOpen_iUnion fun u => isOpen_iUnion fun hu => GenerateOpen.basic _ ⟨_, hu, _, hv, rfl⟩)) #align prod_generate_from_generate_from_eq prod_generateFrom_generateFrom_eq -- todo: use the previous lemma? theorem prod_eq_generateFrom : instTopologicalSpaceProd = generateFrom { g | ∃ (s : Set X) (t : Set Y), IsOpen s ∧ IsOpen t ∧ g = s ×ˢ t } := le_antisymm (le_generateFrom fun g ⟨s, t, hs, ht, g_eq⟩ => g_eq.symm ▸ hs.prod ht) (le_inf (forall_mem_image.2 fun t ht => GenerateOpen.basic _ ⟨t, univ, by simpa [Set.prod_eq] using ht⟩) (forall_mem_image.2 fun t ht => GenerateOpen.basic _ ⟨univ, t, by simpa [Set.prod_eq] using ht⟩)) #align prod_eq_generate_from prod_eq_generateFrom -- Porting note (#11215): TODO: align with `mem_nhds_prod_iff'` theorem isOpen_prod_iff {s : Set (X × Y)} : IsOpen s ↔ ∀ a b, (a, b) ∈ s → ∃ u v, IsOpen u ∧ IsOpen v ∧ a ∈ u ∧ b ∈ v ∧ u ×ˢ v ⊆ s := isOpen_iff_mem_nhds.trans <| by simp_rw [Prod.forall, mem_nhds_prod_iff', and_left_comm] #align is_open_prod_iff isOpen_prod_iff /-- A product of induced topologies is induced by the product map -/ theorem prod_induced_induced (f : X → Y) (g : Z → W) : @instTopologicalSpaceProd X Z (induced f ‹_›) (induced g ‹_›) = induced (fun p => (f p.1, g p.2)) instTopologicalSpaceProd := by delta instTopologicalSpaceProd simp_rw [induced_inf, induced_compose] rfl #align prod_induced_induced prod_induced_induced #noalign continuous_uncurry_of_discrete_topology_left /-- Given a neighborhood `s` of `(x, x)`, then `(x, x)` has a square open neighborhood that is a subset of `s`. -/ theorem exists_nhds_square {s : Set (X × X)} {x : X} (hx : s ∈ 𝓝 (x, x)) : ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ U ×ˢ U ⊆ s := by simpa [nhds_prod_eq, (nhds_basis_opens x).prod_self.mem_iff, and_assoc, and_left_comm] using hx #align exists_nhds_square exists_nhds_square /-- `Prod.fst` maps neighborhood of `x : X × Y` within the section `Prod.snd ⁻¹' {x.2}` to `𝓝 x.1`. -/ theorem map_fst_nhdsWithin (x : X × Y) : map Prod.fst (𝓝[Prod.snd ⁻¹' {x.2}] x) = 𝓝 x.1 := by refine le_antisymm (continuousAt_fst.mono_left inf_le_left) fun s hs => ?_ rcases x with ⟨x, y⟩ rw [mem_map, nhdsWithin, mem_inf_principal, mem_nhds_prod_iff] at hs rcases hs with ⟨u, hu, v, hv, H⟩ simp only [prod_subset_iff, mem_singleton_iff, mem_setOf_eq, mem_preimage] at H exact mem_of_superset hu fun z hz => H _ hz _ (mem_of_mem_nhds hv) rfl #align map_fst_nhds_within map_fst_nhdsWithin @[simp] theorem map_fst_nhds (x : X × Y) : map Prod.fst (𝓝 x) = 𝓝 x.1 := le_antisymm continuousAt_fst <| (map_fst_nhdsWithin x).symm.trans_le (map_mono inf_le_left) #align map_fst_nhds map_fst_nhds /-- The first projection in a product of topological spaces sends open sets to open sets. -/ theorem isOpenMap_fst : IsOpenMap (@Prod.fst X Y) := isOpenMap_iff_nhds_le.2 fun x => (map_fst_nhds x).ge #align is_open_map_fst isOpenMap_fst /-- `Prod.snd` maps neighborhood of `x : X × Y` within the section `Prod.fst ⁻¹' {x.1}` to `𝓝 x.2`. -/ theorem map_snd_nhdsWithin (x : X × Y) : map Prod.snd (𝓝[Prod.fst ⁻¹' {x.1}] x) = 𝓝 x.2 := by refine le_antisymm (continuousAt_snd.mono_left inf_le_left) fun s hs => ?_ rcases x with ⟨x, y⟩ rw [mem_map, nhdsWithin, mem_inf_principal, mem_nhds_prod_iff] at hs rcases hs with ⟨u, hu, v, hv, H⟩ simp only [prod_subset_iff, mem_singleton_iff, mem_setOf_eq, mem_preimage] at H exact mem_of_superset hv fun z hz => H _ (mem_of_mem_nhds hu) _ hz rfl #align map_snd_nhds_within map_snd_nhdsWithin @[simp] theorem map_snd_nhds (x : X × Y) : map Prod.snd (𝓝 x) = 𝓝 x.2 := le_antisymm continuousAt_snd <| (map_snd_nhdsWithin x).symm.trans_le (map_mono inf_le_left) #align map_snd_nhds map_snd_nhds /-- The second projection in a product of topological spaces sends open sets to open sets. -/ theorem isOpenMap_snd : IsOpenMap (@Prod.snd X Y) := isOpenMap_iff_nhds_le.2 fun x => (map_snd_nhds x).ge #align is_open_map_snd isOpenMap_snd /-- A product set is open in a product space if and only if each factor is open, or one of them is empty -/ theorem isOpen_prod_iff' {s : Set X} {t : Set Y} : IsOpen (s ×ˢ t) ↔ IsOpen s ∧ IsOpen t ∨ s = ∅ ∨ t = ∅ := by rcases (s ×ˢ t).eq_empty_or_nonempty with h | h · simp [h, prod_eq_empty_iff.1 h] · have st : s.Nonempty ∧ t.Nonempty := prod_nonempty_iff.1 h constructor · intro (H : IsOpen (s ×ˢ t)) refine Or.inl ⟨?_, ?_⟩ · show IsOpen s rw [← fst_image_prod s st.2] exact isOpenMap_fst _ H · show IsOpen t rw [← snd_image_prod st.1 t] exact isOpenMap_snd _ H · intro H simp only [st.1.ne_empty, st.2.ne_empty, not_false_iff, or_false_iff] at H exact H.1.prod H.2 #align is_open_prod_iff' isOpen_prod_iff' theorem closure_prod_eq {s : Set X} {t : Set Y} : closure (s ×ˢ t) = closure s ×ˢ closure t := ext fun ⟨a, b⟩ => by simp_rw [mem_prod, mem_closure_iff_nhdsWithin_neBot, nhdsWithin_prod_eq, prod_neBot] #align closure_prod_eq closure_prod_eq theorem interior_prod_eq (s : Set X) (t : Set Y) : interior (s ×ˢ t) = interior s ×ˢ interior t := ext fun ⟨a, b⟩ => by simp only [mem_interior_iff_mem_nhds, mem_prod, prod_mem_nhds_iff] #align interior_prod_eq interior_prod_eq theorem frontier_prod_eq (s : Set X) (t : Set Y) : frontier (s ×ˢ t) = closure s ×ˢ frontier t ∪ frontier s ×ˢ closure t := by simp only [frontier, closure_prod_eq, interior_prod_eq, prod_diff_prod] #align frontier_prod_eq frontier_prod_eq @[simp] theorem frontier_prod_univ_eq (s : Set X) : frontier (s ×ˢ (univ : Set Y)) = frontier s ×ˢ univ := by simp [frontier_prod_eq] #align frontier_prod_univ_eq frontier_prod_univ_eq @[simp] theorem frontier_univ_prod_eq (s : Set Y) : frontier ((univ : Set X) ×ˢ s) = univ ×ˢ frontier s := by simp [frontier_prod_eq] #align frontier_univ_prod_eq frontier_univ_prod_eq theorem map_mem_closure₂ {f : X → Y → Z} {x : X} {y : Y} {s : Set X} {t : Set Y} {u : Set Z} (hf : Continuous (uncurry f)) (hx : x ∈ closure s) (hy : y ∈ closure t) (h : ∀ a ∈ s, ∀ b ∈ t, f a b ∈ u) : f x y ∈ closure u := have H₁ : (x, y) ∈ closure (s ×ˢ t) := by simpa only [closure_prod_eq] using mk_mem_prod hx hy have H₂ : MapsTo (uncurry f) (s ×ˢ t) u := forall_prod_set.2 h H₂.closure hf H₁ #align map_mem_closure₂ map_mem_closure₂ theorem IsClosed.prod {s₁ : Set X} {s₂ : Set Y} (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ×ˢ s₂) := closure_eq_iff_isClosed.mp <| by simp only [h₁.closure_eq, h₂.closure_eq, closure_prod_eq] #align is_closed.prod IsClosed.prod /-- The product of two dense sets is a dense set. -/ theorem Dense.prod {s : Set X} {t : Set Y} (hs : Dense s) (ht : Dense t) : Dense (s ×ˢ t) := fun x => by rw [closure_prod_eq] exact ⟨hs x.1, ht x.2⟩ #align dense.prod Dense.prod /-- If `f` and `g` are maps with dense range, then `Prod.map f g` has dense range. -/ theorem DenseRange.prod_map {ι : Type*} {κ : Type*} {f : ι → Y} {g : κ → Z} (hf : DenseRange f) (hg : DenseRange g) : DenseRange (Prod.map f g) := by simpa only [DenseRange, prod_range_range_eq] using hf.prod hg #align dense_range.prod_map DenseRange.prod_map theorem Inducing.prod_map {f : X → Y} {g : Z → W} (hf : Inducing f) (hg : Inducing g) : Inducing (Prod.map f g) := inducing_iff_nhds.2 fun (x, z) => by simp_rw [Prod.map_def, nhds_prod_eq, hf.nhds_eq_comap, hg.nhds_eq_comap, prod_comap_comap_eq] #align inducing.prod_mk Inducing.prod_map @[simp] theorem inducing_const_prod {x : X} {f : Y → Z} : (Inducing fun x' => (x, f x')) ↔ Inducing f := by simp_rw [inducing_iff, instTopologicalSpaceProd, induced_inf, induced_compose, Function.comp, induced_const, top_inf_eq] #align inducing_const_prod inducing_const_prod @[simp] theorem inducing_prod_const {y : Y} {f : X → Z} : (Inducing fun x => (f x, y)) ↔ Inducing f := by simp_rw [inducing_iff, instTopologicalSpaceProd, induced_inf, induced_compose, Function.comp, induced_const, inf_top_eq] #align inducing_prod_const inducing_prod_const theorem Embedding.prod_map {f : X → Y} {g : Z → W} (hf : Embedding f) (hg : Embedding g) : Embedding (Prod.map f g) := { hf.toInducing.prod_map hg.toInducing with inj := fun ⟨x₁, z₁⟩ ⟨x₂, z₂⟩ => by simp [hf.inj.eq_iff, hg.inj.eq_iff] } #align embedding.prod_mk Embedding.prod_map protected theorem IsOpenMap.prod {f : X → Y} {g : Z → W} (hf : IsOpenMap f) (hg : IsOpenMap g) : IsOpenMap fun p : X × Z => (f p.1, g p.2) := by rw [isOpenMap_iff_nhds_le] rintro ⟨a, b⟩ rw [nhds_prod_eq, nhds_prod_eq, ← Filter.prod_map_map_eq] exact Filter.prod_mono (hf.nhds_le a) (hg.nhds_le b) #align is_open_map.prod IsOpenMap.prod protected theorem OpenEmbedding.prod {f : X → Y} {g : Z → W} (hf : OpenEmbedding f) (hg : OpenEmbedding g) : OpenEmbedding fun x : X × Z => (f x.1, g x.2) := openEmbedding_of_embedding_open (hf.1.prod_map hg.1) (hf.isOpenMap.prod hg.isOpenMap) #align open_embedding.prod OpenEmbedding.prod theorem embedding_graph {f : X → Y} (hf : Continuous f) : Embedding fun x => (x, f x) := embedding_of_embedding_compose (continuous_id.prod_mk hf) continuous_fst embedding_id #align embedding_graph embedding_graph theorem embedding_prod_mk (x : X) : Embedding (Prod.mk x : Y → X × Y) := embedding_of_embedding_compose (Continuous.Prod.mk x) continuous_snd embedding_id end Prod section Bool lemma continuous_bool_rng [TopologicalSpace X] {f : X → Bool} (b : Bool) : Continuous f ↔ IsClopen (f ⁻¹' {b}) := by rw [continuous_discrete_rng, Bool.forall_bool' b, IsClopen, ← isOpen_compl_iff, ← preimage_compl, Bool.compl_singleton, and_comm] end Bool section Sum open Sum variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W] theorem continuous_sum_dom {f : X ⊕ Y → Z} : Continuous f ↔ Continuous (f ∘ Sum.inl) ∧ Continuous (f ∘ Sum.inr) := (continuous_sup_dom (t₁ := TopologicalSpace.coinduced Sum.inl _) (t₂ := TopologicalSpace.coinduced Sum.inr _)).trans <| continuous_coinduced_dom.and continuous_coinduced_dom #align continuous_sum_dom continuous_sum_dom theorem continuous_sum_elim {f : X → Z} {g : Y → Z} : Continuous (Sum.elim f g) ↔ Continuous f ∧ Continuous g := continuous_sum_dom #align continuous_sum_elim continuous_sum_elim @[continuity] theorem Continuous.sum_elim {f : X → Z} {g : Y → Z} (hf : Continuous f) (hg : Continuous g) : Continuous (Sum.elim f g) := continuous_sum_elim.2 ⟨hf, hg⟩ #align continuous.sum_elim Continuous.sum_elim @[continuity] theorem continuous_isLeft : Continuous (isLeft : X ⊕ Y → Bool) := continuous_sum_dom.2 ⟨continuous_const, continuous_const⟩ @[continuity] theorem continuous_isRight : Continuous (isRight : X ⊕ Y → Bool) := continuous_sum_dom.2 ⟨continuous_const, continuous_const⟩ @[continuity] -- Porting note: the proof was `continuous_sup_rng_left continuous_coinduced_rng` theorem continuous_inl : Continuous (@inl X Y) := ⟨fun _ => And.left⟩ #align continuous_inl continuous_inl @[continuity] -- Porting note: the proof was `continuous_sup_rng_right continuous_coinduced_rng` theorem continuous_inr : Continuous (@inr X Y) := ⟨fun _ => And.right⟩ #align continuous_inr continuous_inr theorem isOpen_sum_iff {s : Set (X ⊕ Y)} : IsOpen s ↔ IsOpen (inl ⁻¹' s) ∧ IsOpen (inr ⁻¹' s) := Iff.rfl #align is_open_sum_iff isOpen_sum_iff -- Porting note (#10756): new theorem theorem isClosed_sum_iff {s : Set (X ⊕ Y)} : IsClosed s ↔ IsClosed (inl ⁻¹' s) ∧ IsClosed (inr ⁻¹' s) := by simp only [← isOpen_compl_iff, isOpen_sum_iff, preimage_compl] theorem isOpenMap_inl : IsOpenMap (@inl X Y) := fun u hu => by simpa [isOpen_sum_iff, preimage_image_eq u Sum.inl_injective] #align is_open_map_inl isOpenMap_inl theorem isOpenMap_inr : IsOpenMap (@inr X Y) := fun u hu => by simpa [isOpen_sum_iff, preimage_image_eq u Sum.inr_injective] #align is_open_map_inr isOpenMap_inr theorem openEmbedding_inl : OpenEmbedding (@inl X Y) := openEmbedding_of_continuous_injective_open continuous_inl inl_injective isOpenMap_inl #align open_embedding_inl openEmbedding_inl theorem openEmbedding_inr : OpenEmbedding (@inr X Y) := openEmbedding_of_continuous_injective_open continuous_inr inr_injective isOpenMap_inr #align open_embedding_inr openEmbedding_inr theorem embedding_inl : Embedding (@inl X Y) := openEmbedding_inl.1 #align embedding_inl embedding_inl theorem embedding_inr : Embedding (@inr X Y) := openEmbedding_inr.1 #align embedding_inr embedding_inr theorem isOpen_range_inl : IsOpen (range (inl : X → X ⊕ Y)) := openEmbedding_inl.2 #align is_open_range_inl isOpen_range_inl theorem isOpen_range_inr : IsOpen (range (inr : Y → X ⊕ Y)) := openEmbedding_inr.2 #align is_open_range_inr isOpen_range_inr theorem isClosed_range_inl : IsClosed (range (inl : X → X ⊕ Y)) := by rw [← isOpen_compl_iff, compl_range_inl] exact isOpen_range_inr #align is_closed_range_inl isClosed_range_inl theorem isClosed_range_inr : IsClosed (range (inr : Y → X ⊕ Y)) := by rw [← isOpen_compl_iff, compl_range_inr] exact isOpen_range_inl #align is_closed_range_inr isClosed_range_inr theorem closedEmbedding_inl : ClosedEmbedding (inl : X → X ⊕ Y) := ⟨embedding_inl, isClosed_range_inl⟩ #align closed_embedding_inl closedEmbedding_inl theorem closedEmbedding_inr : ClosedEmbedding (inr : Y → X ⊕ Y) := ⟨embedding_inr, isClosed_range_inr⟩ #align closed_embedding_inr closedEmbedding_inr theorem nhds_inl (x : X) : 𝓝 (inl x : X ⊕ Y) = map inl (𝓝 x) := (openEmbedding_inl.map_nhds_eq _).symm #align nhds_inl nhds_inl theorem nhds_inr (y : Y) : 𝓝 (inr y : X ⊕ Y) = map inr (𝓝 y) := (openEmbedding_inr.map_nhds_eq _).symm #align nhds_inr nhds_inr @[simp] theorem continuous_sum_map {f : X → Y} {g : Z → W} : Continuous (Sum.map f g) ↔ Continuous f ∧ Continuous g := continuous_sum_elim.trans <| embedding_inl.continuous_iff.symm.and embedding_inr.continuous_iff.symm #align continuous_sum_map continuous_sum_map @[continuity] theorem Continuous.sum_map {f : X → Y} {g : Z → W} (hf : Continuous f) (hg : Continuous g) : Continuous (Sum.map f g) := continuous_sum_map.2 ⟨hf, hg⟩ #align continuous.sum_map Continuous.sum_map theorem isOpenMap_sum {f : X ⊕ Y → Z} : IsOpenMap f ↔ (IsOpenMap fun a => f (inl a)) ∧ IsOpenMap fun b => f (inr b) := by simp only [isOpenMap_iff_nhds_le, Sum.forall, nhds_inl, nhds_inr, Filter.map_map, comp] #align is_open_map_sum isOpenMap_sum @[simp] theorem isOpenMap_sum_elim {f : X → Z} {g : Y → Z} : IsOpenMap (Sum.elim f g) ↔ IsOpenMap f ∧ IsOpenMap g := by simp only [isOpenMap_sum, elim_inl, elim_inr] #align is_open_map_sum_elim isOpenMap_sum_elim theorem IsOpenMap.sum_elim {f : X → Z} {g : Y → Z} (hf : IsOpenMap f) (hg : IsOpenMap g) : IsOpenMap (Sum.elim f g) := isOpenMap_sum_elim.2 ⟨hf, hg⟩ #align is_open_map.sum_elim IsOpenMap.sum_elim end Sum section Subtype variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] {p : X → Prop} theorem inducing_subtype_val {t : Set Y} : Inducing ((↑) : t → Y) := ⟨rfl⟩ #align inducing_coe inducing_subtype_val theorem Inducing.of_codRestrict {f : X → Y} {t : Set Y} (ht : ∀ x, f x ∈ t) (h : Inducing (t.codRestrict f ht)) : Inducing f := inducing_subtype_val.comp h #align inducing.of_cod_restrict Inducing.of_codRestrict theorem embedding_subtype_val : Embedding ((↑) : Subtype p → X) := ⟨inducing_subtype_val, Subtype.coe_injective⟩ #align embedding_subtype_coe embedding_subtype_val theorem closedEmbedding_subtype_val (h : IsClosed { a | p a }) : ClosedEmbedding ((↑) : Subtype p → X) := ⟨embedding_subtype_val, by rwa [Subtype.range_coe_subtype]⟩ #align closed_embedding_subtype_coe closedEmbedding_subtype_val @[continuity] theorem continuous_subtype_val : Continuous (@Subtype.val X p) := continuous_induced_dom #align continuous_subtype_val continuous_subtype_val #align continuous_subtype_coe continuous_subtype_val theorem Continuous.subtype_val {f : Y → Subtype p} (hf : Continuous f) : Continuous fun x => (f x : X) := continuous_subtype_val.comp hf #align continuous.subtype_coe Continuous.subtype_val theorem IsOpen.openEmbedding_subtype_val {s : Set X} (hs : IsOpen s) : OpenEmbedding ((↑) : s → X) := ⟨embedding_subtype_val, (@Subtype.range_coe _ s).symm ▸ hs⟩ #align is_open.open_embedding_subtype_coe IsOpen.openEmbedding_subtype_val theorem IsOpen.isOpenMap_subtype_val {s : Set X} (hs : IsOpen s) : IsOpenMap ((↑) : s → X) := hs.openEmbedding_subtype_val.isOpenMap #align is_open.is_open_map_subtype_coe IsOpen.isOpenMap_subtype_val theorem IsOpenMap.restrict {f : X → Y} (hf : IsOpenMap f) {s : Set X} (hs : IsOpen s) : IsOpenMap (s.restrict f) := hf.comp hs.isOpenMap_subtype_val #align is_open_map.restrict IsOpenMap.restrict nonrec theorem IsClosed.closedEmbedding_subtype_val {s : Set X} (hs : IsClosed s) : ClosedEmbedding ((↑) : s → X) := closedEmbedding_subtype_val hs #align is_closed.closed_embedding_subtype_coe IsClosed.closedEmbedding_subtype_val @[continuity] theorem Continuous.subtype_mk {f : Y → X} (h : Continuous f) (hp : ∀ x, p (f x)) : Continuous fun x => (⟨f x, hp x⟩ : Subtype p) := continuous_induced_rng.2 h #align continuous.subtype_mk Continuous.subtype_mk theorem Continuous.subtype_map {f : X → Y} (h : Continuous f) {q : Y → Prop} (hpq : ∀ x, p x → q (f x)) : Continuous (Subtype.map f hpq) := (h.comp continuous_subtype_val).subtype_mk _ #align continuous.subtype_map Continuous.subtype_map theorem continuous_inclusion {s t : Set X} (h : s ⊆ t) : Continuous (inclusion h) := continuous_id.subtype_map h #align continuous_inclusion continuous_inclusion theorem continuousAt_subtype_val {p : X → Prop} {x : Subtype p} : ContinuousAt ((↑) : Subtype p → X) x := continuous_subtype_val.continuousAt #align continuous_at_subtype_coe continuousAt_subtype_val theorem Subtype.dense_iff {s : Set X} {t : Set s} : Dense t ↔ s ⊆ closure ((↑) '' t) := by rw [inducing_subtype_val.dense_iff, SetCoe.forall] rfl #align subtype.dense_iff Subtype.dense_iff -- Porting note (#10756): new lemma theorem map_nhds_subtype_val {s : Set X} (x : s) : map ((↑) : s → X) (𝓝 x) = 𝓝[s] ↑x := by rw [inducing_subtype_val.map_nhds_eq, Subtype.range_val] theorem map_nhds_subtype_coe_eq_nhds {x : X} (hx : p x) (h : ∀ᶠ x in 𝓝 x, p x) : map ((↑) : Subtype p → X) (𝓝 ⟨x, hx⟩) = 𝓝 x := map_nhds_induced_of_mem <| by rw [Subtype.range_val]; exact h #align map_nhds_subtype_coe_eq map_nhds_subtype_coe_eq_nhds theorem nhds_subtype_eq_comap {x : X} {h : p x} : 𝓝 (⟨x, h⟩ : Subtype p) = comap (↑) (𝓝 x) := nhds_induced _ _ #align nhds_subtype_eq_comap nhds_subtype_eq_comap theorem tendsto_subtype_rng {Y : Type*} {p : X → Prop} {l : Filter Y} {f : Y → Subtype p} : ∀ {x : Subtype p}, Tendsto f l (𝓝 x) ↔ Tendsto (fun x => (f x : X)) l (𝓝 (x : X)) | ⟨a, ha⟩ => by rw [nhds_subtype_eq_comap, tendsto_comap_iff]; rfl #align tendsto_subtype_rng tendsto_subtype_rng theorem closure_subtype {x : { a // p a }} {s : Set { a // p a }} : x ∈ closure s ↔ (x : X) ∈ closure (((↑) : _ → X) '' s) := closure_induced #align closure_subtype closure_subtype @[simp] theorem continuousAt_codRestrict_iff {f : X → Y} {t : Set Y} (h1 : ∀ x, f x ∈ t) {x : X} : ContinuousAt (codRestrict f t h1) x ↔ ContinuousAt f x := inducing_subtype_val.continuousAt_iff #align continuous_at_cod_restrict_iff continuousAt_codRestrict_iff alias ⟨_, ContinuousAt.codRestrict⟩ := continuousAt_codRestrict_iff #align continuous_at.cod_restrict ContinuousAt.codRestrict theorem ContinuousAt.restrict {f : X → Y} {s : Set X} {t : Set Y} (h1 : MapsTo f s t) {x : s} (h2 : ContinuousAt f x) : ContinuousAt (h1.restrict f s t) x := (h2.comp continuousAt_subtype_val).codRestrict _ #align continuous_at.restrict ContinuousAt.restrict theorem ContinuousAt.restrictPreimage {f : X → Y} {s : Set Y} {x : f ⁻¹' s} (h : ContinuousAt f x) : ContinuousAt (s.restrictPreimage f) x := h.restrict _ #align continuous_at.restrict_preimage ContinuousAt.restrictPreimage @[continuity] theorem Continuous.codRestrict {f : X → Y} {s : Set Y} (hf : Continuous f) (hs : ∀ a, f a ∈ s) : Continuous (s.codRestrict f hs) := hf.subtype_mk hs #align continuous.cod_restrict Continuous.codRestrict @[continuity] theorem Continuous.restrict {f : X → Y} {s : Set X} {t : Set Y} (h1 : MapsTo f s t) (h2 : Continuous f) : Continuous (h1.restrict f s t) := (h2.comp continuous_subtype_val).codRestrict _ @[continuity] theorem Continuous.restrictPreimage {f : X → Y} {s : Set Y} (h : Continuous f) : Continuous (s.restrictPreimage f) := h.restrict _ theorem Inducing.codRestrict {e : X → Y} (he : Inducing e) {s : Set Y} (hs : ∀ x, e x ∈ s) : Inducing (codRestrict e s hs) := inducing_of_inducing_compose (he.continuous.codRestrict hs) continuous_subtype_val he #align inducing.cod_restrict Inducing.codRestrict theorem Embedding.codRestrict {e : X → Y} (he : Embedding e) (s : Set Y) (hs : ∀ x, e x ∈ s) : Embedding (codRestrict e s hs) := embedding_of_embedding_compose (he.continuous.codRestrict hs) continuous_subtype_val he #align embedding.cod_restrict Embedding.codRestrict theorem embedding_inclusion {s t : Set X} (h : s ⊆ t) : Embedding (inclusion h) := embedding_subtype_val.codRestrict _ _ #align embedding_inclusion embedding_inclusion /-- Let `s, t ⊆ X` be two subsets of a topological space `X`. If `t ⊆ s` and the topology induced by `X`on `s` is discrete, then also the topology induces on `t` is discrete. -/ theorem DiscreteTopology.of_subset {X : Type*} [TopologicalSpace X] {s t : Set X} (_ : DiscreteTopology s) (ts : t ⊆ s) : DiscreteTopology t := (embedding_inclusion ts).discreteTopology #align discrete_topology.of_subset DiscreteTopology.of_subset /-- Let `s` be a discrete subset of a topological space. Then the preimage of `s` by a continuous injective map is also discrete. -/ theorem DiscreteTopology.preimage_of_continuous_injective {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] (s : Set Y) [DiscreteTopology s] {f : X → Y} (hc : Continuous f) (hinj : Function.Injective f) : DiscreteTopology (f ⁻¹' s) := DiscreteTopology.of_continuous_injective (β := s) (Continuous.restrict (by exact fun _ x ↦ x) hc) ((MapsTo.restrict_inj _).mpr hinj.injOn) end Subtype section Quotient variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] variable {r : X → X → Prop} {s : Setoid X} theorem quotientMap_quot_mk : QuotientMap (@Quot.mk X r) := ⟨Quot.exists_rep, rfl⟩ #align quotient_map_quot_mk quotientMap_quot_mk @[continuity] theorem continuous_quot_mk : Continuous (@Quot.mk X r) := continuous_coinduced_rng #align continuous_quot_mk continuous_quot_mk @[continuity] theorem continuous_quot_lift {f : X → Y} (hr : ∀ a b, r a b → f a = f b) (h : Continuous f) : Continuous (Quot.lift f hr : Quot r → Y) := continuous_coinduced_dom.2 h #align continuous_quot_lift continuous_quot_lift theorem quotientMap_quotient_mk' : QuotientMap (@Quotient.mk' X s) := quotientMap_quot_mk #align quotient_map_quotient_mk quotientMap_quotient_mk' theorem continuous_quotient_mk' : Continuous (@Quotient.mk' X s) := continuous_coinduced_rng #align continuous_quotient_mk continuous_quotient_mk' theorem Continuous.quotient_lift {f : X → Y} (h : Continuous f) (hs : ∀ a b, a ≈ b → f a = f b) : Continuous (Quotient.lift f hs : Quotient s → Y) := continuous_coinduced_dom.2 h #align continuous.quotient_lift Continuous.quotient_lift theorem Continuous.quotient_liftOn' {f : X → Y} (h : Continuous f) (hs : ∀ a b, @Setoid.r _ s a b → f a = f b) : Continuous (fun x => Quotient.liftOn' x f hs : Quotient s → Y) := h.quotient_lift hs #align continuous.quotient_lift_on' Continuous.quotient_liftOn' @[continuity] theorem Continuous.quotient_map' {t : Setoid Y} {f : X → Y} (hf : Continuous f) (H : (s.r ⇒ t.r) f f) : Continuous (Quotient.map' f H) := (continuous_quotient_mk'.comp hf).quotient_lift _ #align continuous.quotient_map' Continuous.quotient_map' end Quotient section Pi variable {ι : Type*} {π : ι → Type*} {κ : Type*} [TopologicalSpace X] [T : ∀ i, TopologicalSpace (π i)] {f : X → ∀ i : ι, π i} theorem continuous_pi_iff : Continuous f ↔ ∀ i, Continuous fun a => f a i := by simp only [continuous_iInf_rng, continuous_induced_rng, comp] #align continuous_pi_iff continuous_pi_iff @[continuity, fun_prop] theorem continuous_pi (h : ∀ i, Continuous fun a => f a i) : Continuous f := continuous_pi_iff.2 h #align continuous_pi continuous_pi @[continuity, fun_prop] theorem continuous_apply (i : ι) : Continuous fun p : ∀ i, π i => p i := continuous_iInf_dom continuous_induced_dom #align continuous_apply continuous_apply @[continuity] theorem continuous_apply_apply {ρ : κ → ι → Type*} [∀ j i, TopologicalSpace (ρ j i)] (j : κ) (i : ι) : Continuous fun p : ∀ j, ∀ i, ρ j i => p j i := (continuous_apply i).comp (continuous_apply j) #align continuous_apply_apply continuous_apply_apply theorem continuousAt_apply (i : ι) (x : ∀ i, π i) : ContinuousAt (fun p : ∀ i, π i => p i) x := (continuous_apply i).continuousAt #align continuous_at_apply continuousAt_apply theorem Filter.Tendsto.apply_nhds {l : Filter Y} {f : Y → ∀ i, π i} {x : ∀ i, π i} (h : Tendsto f l (𝓝 x)) (i : ι) : Tendsto (fun a => f a i) l (𝓝 <| x i) := (continuousAt_apply i _).tendsto.comp h #align filter.tendsto.apply Filter.Tendsto.apply_nhds theorem nhds_pi {a : ∀ i, π i} : 𝓝 a = pi fun i => 𝓝 (a i) := by simp only [nhds_iInf, nhds_induced, Filter.pi] #align nhds_pi nhds_pi theorem tendsto_pi_nhds {f : Y → ∀ i, π i} {g : ∀ i, π i} {u : Filter Y} : Tendsto f u (𝓝 g) ↔ ∀ x, Tendsto (fun i => f i x) u (𝓝 (g x)) := by rw [nhds_pi, Filter.tendsto_pi] #align tendsto_pi_nhds tendsto_pi_nhds theorem continuousAt_pi {f : X → ∀ i, π i} {x : X} : ContinuousAt f x ↔ ∀ i, ContinuousAt (fun y => f y i) x := tendsto_pi_nhds #align continuous_at_pi continuousAt_pi @[fun_prop] theorem continuousAt_pi' {f : X → ∀ i, π i} {x : X} (hf : ∀ i, ContinuousAt (fun y => f y i) x) : ContinuousAt f x := continuousAt_pi.2 hf theorem Pi.continuous_precomp' {ι' : Type*} (φ : ι' → ι) : Continuous (fun (f : (∀ i, π i)) (j : ι') ↦ f (φ j)) := continuous_pi fun j ↦ continuous_apply (φ j) theorem Pi.continuous_precomp {ι' : Type*} (φ : ι' → ι) : Continuous (· ∘ φ : (ι → X) → (ι' → X)) := Pi.continuous_precomp' φ theorem Pi.continuous_postcomp' {X : ι → Type*} [∀ i, TopologicalSpace (X i)] {g : ∀ i, π i → X i} (hg : ∀ i, Continuous (g i)) : Continuous (fun (f : (∀ i, π i)) (i : ι) ↦ g i (f i)) := continuous_pi fun i ↦ (hg i).comp <| continuous_apply i theorem Pi.continuous_postcomp [TopologicalSpace Y] {g : X → Y} (hg : Continuous g) : Continuous (g ∘ · : (ι → X) → (ι → Y)) := Pi.continuous_postcomp' fun _ ↦ hg lemma Pi.induced_precomp' {ι' : Type*} (φ : ι' → ι) : induced (fun (f : (∀ i, π i)) (j : ι') ↦ f (φ j)) Pi.topologicalSpace = ⨅ i', induced (eval (φ i')) (T (φ i')) := by simp [Pi.topologicalSpace, induced_iInf, induced_compose, comp] lemma Pi.induced_precomp [TopologicalSpace Y] {ι' : Type*} (φ : ι' → ι) : induced (· ∘ φ) Pi.topologicalSpace = ⨅ i', induced (eval (φ i')) ‹TopologicalSpace Y› := induced_precomp' φ lemma Pi.continuous_restrict (S : Set ι) : Continuous (S.restrict : (∀ i : ι, π i) → (∀ i : S, π i)) := Pi.continuous_precomp' ((↑) : S → ι) lemma Pi.induced_restrict (S : Set ι) : induced (S.restrict) Pi.topologicalSpace = ⨅ i ∈ S, induced (eval i) (T i) := by simp (config := { unfoldPartialApp := true }) [← iInf_subtype'', ← induced_precomp' ((↑) : S → ι), restrict] lemma Pi.induced_restrict_sUnion (𝔖 : Set (Set ι)) : induced (⋃₀ 𝔖).restrict (Pi.topologicalSpace (Y := fun i : (⋃₀ 𝔖) ↦ π i)) = ⨅ S ∈ 𝔖, induced S.restrict Pi.topologicalSpace := by simp_rw [Pi.induced_restrict, iInf_sUnion] theorem Filter.Tendsto.update [DecidableEq ι] {l : Filter Y} {f : Y → ∀ i, π i} {x : ∀ i, π i} (hf : Tendsto f l (𝓝 x)) (i : ι) {g : Y → π i} {xi : π i} (hg : Tendsto g l (𝓝 xi)) : Tendsto (fun a => update (f a) i (g a)) l (𝓝 <| update x i xi) := tendsto_pi_nhds.2 fun j => by rcases eq_or_ne j i with (rfl | hj) <;> simp [*, hf.apply_nhds] #align filter.tendsto.update Filter.Tendsto.update theorem ContinuousAt.update [DecidableEq ι] {x : X} (hf : ContinuousAt f x) (i : ι) {g : X → π i} (hg : ContinuousAt g x) : ContinuousAt (fun a => update (f a) i (g a)) x := hf.tendsto.update i hg #align continuous_at.update ContinuousAt.update theorem Continuous.update [DecidableEq ι] (hf : Continuous f) (i : ι) {g : X → π i} (hg : Continuous g) : Continuous fun a => update (f a) i (g a) := continuous_iff_continuousAt.2 fun _ => hf.continuousAt.update i hg.continuousAt #align continuous.update Continuous.update /-- `Function.update f i x` is continuous in `(f, x)`. -/ @[continuity] theorem continuous_update [DecidableEq ι] (i : ι) : Continuous fun f : (∀ j, π j) × π i => update f.1 i f.2 := continuous_fst.update i continuous_snd #align continuous_update continuous_update /-- `Pi.mulSingle i x` is continuous in `x`. -/ -- Porting note (#11215): TODO: restore @[continuity] @[to_additive "`Pi.single i x` is continuous in `x`."] theorem continuous_mulSingle [∀ i, One (π i)] [DecidableEq ι] (i : ι) : Continuous fun x => (Pi.mulSingle i x : ∀ i, π i) := continuous_const.update _ continuous_id #align continuous_mul_single continuous_mulSingle #align continuous_single continuous_single theorem Filter.Tendsto.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : Y → π i} {l : Filter Y} {x : π i} (hf : Tendsto f l (𝓝 x)) {g : Y → ∀ j : Fin n, π (i.succAbove j)} {y : ∀ j, π (i.succAbove j)} (hg : Tendsto g l (𝓝 y)) : Tendsto (fun a => i.insertNth (f a) (g a)) l (𝓝 <| i.insertNth x y) := tendsto_pi_nhds.2 fun j => Fin.succAboveCases i (by simpa) (by simpa using tendsto_pi_nhds.1 hg) j #align filter.tendsto.fin_insert_nth Filter.Tendsto.fin_insertNth theorem ContinuousAt.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : X → π i} {x : X} (hf : ContinuousAt f x) {g : X → ∀ j : Fin n, π (i.succAbove j)} (hg : ContinuousAt g x) : ContinuousAt (fun a => i.insertNth (f a) (g a)) x := hf.tendsto.fin_insertNth i hg #align continuous_at.fin_insert_nth ContinuousAt.fin_insertNth theorem Continuous.fin_insertNth {n} {π : Fin (n + 1) → Type*} [∀ i, TopologicalSpace (π i)] (i : Fin (n + 1)) {f : X → π i} (hf : Continuous f) {g : X → ∀ j : Fin n, π (i.succAbove j)} (hg : Continuous g) : Continuous fun a => i.insertNth (f a) (g a) := continuous_iff_continuousAt.2 fun _ => hf.continuousAt.fin_insertNth i hg.continuousAt #align continuous.fin_insert_nth Continuous.fin_insertNth theorem isOpen_set_pi {i : Set ι} {s : ∀ a, Set (π a)} (hi : i.Finite) (hs : ∀ a ∈ i, IsOpen (s a)) : IsOpen (pi i s) := by rw [pi_def]; exact hi.isOpen_biInter fun a ha => (hs _ ha).preimage (continuous_apply _) #align is_open_set_pi isOpen_set_pi theorem isOpen_pi_iff {s : Set (∀ a, π a)} : IsOpen s ↔ ∀ f, f ∈ s → ∃ (I : Finset ι) (u : ∀ a, Set (π a)), (∀ a, a ∈ I → IsOpen (u a) ∧ f a ∈ u a) ∧ (I : Set ι).pi u ⊆ s := by rw [isOpen_iff_nhds] simp_rw [le_principal_iff, nhds_pi, Filter.mem_pi', mem_nhds_iff] refine forall₂_congr fun a _ => ⟨?_, ?_⟩ · rintro ⟨I, t, ⟨h1, h2⟩⟩ refine ⟨I, fun a => eval a '' (I : Set ι).pi fun a => (h1 a).choose, fun i hi => ?_, ?_⟩ · simp_rw [eval_image_pi (Finset.mem_coe.mpr hi) (pi_nonempty_iff.mpr fun i => ⟨_, fun _ => (h1 i).choose_spec.2.2⟩)] exact (h1 i).choose_spec.2 · exact Subset.trans (pi_mono fun i hi => (eval_image_pi_subset hi).trans (h1 i).choose_spec.1) h2 · rintro ⟨I, t, ⟨h1, h2⟩⟩ refine ⟨I, fun a => ite (a ∈ I) (t a) univ, fun i => ?_, ?_⟩ · by_cases hi : i ∈ I · use t i simp_rw [if_pos hi] exact ⟨Subset.rfl, (h1 i) hi⟩ · use univ simp_rw [if_neg hi] exact ⟨Subset.rfl, isOpen_univ, mem_univ _⟩ · rw [← univ_pi_ite] simp only [← ite_and, ← Finset.mem_coe, and_self_iff, univ_pi_ite, h2] #align is_open_pi_iff isOpen_pi_iff theorem isOpen_pi_iff' [Finite ι] {s : Set (∀ a, π a)} : IsOpen s ↔ ∀ f, f ∈ s → ∃ u : ∀ a, Set (π a), (∀ a, IsOpen (u a) ∧ f a ∈ u a) ∧ univ.pi u ⊆ s := by cases nonempty_fintype ι rw [isOpen_iff_nhds] simp_rw [le_principal_iff, nhds_pi, Filter.mem_pi', mem_nhds_iff] refine forall₂_congr fun a _ => ⟨?_, ?_⟩ · rintro ⟨I, t, ⟨h1, h2⟩⟩ refine ⟨fun i => (h1 i).choose, ⟨fun i => (h1 i).choose_spec.2, (pi_mono fun i _ => (h1 i).choose_spec.1).trans (Subset.trans ?_ h2)⟩⟩ rw [← pi_inter_compl (I : Set ι)] exact inter_subset_left · exact fun ⟨u, ⟨h1, _⟩⟩ => ⟨Finset.univ, u, ⟨fun i => ⟨u i, ⟨rfl.subset, h1 i⟩⟩, by rwa [Finset.coe_univ]⟩⟩ #align is_open_pi_iff' isOpen_pi_iff' theorem isClosed_set_pi {i : Set ι} {s : ∀ a, Set (π a)} (hs : ∀ a ∈ i, IsClosed (s a)) : IsClosed (pi i s) := by rw [pi_def]; exact isClosed_biInter fun a ha => (hs _ ha).preimage (continuous_apply _) #align is_closed_set_pi isClosed_set_pi theorem mem_nhds_of_pi_mem_nhds {I : Set ι} {s : ∀ i, Set (π i)} (a : ∀ i, π i) (hs : I.pi s ∈ 𝓝 a) {i : ι} (hi : i ∈ I) : s i ∈ 𝓝 (a i) := by rw [nhds_pi] at hs; exact mem_of_pi_mem_pi hs hi #align mem_nhds_of_pi_mem_nhds mem_nhds_of_pi_mem_nhds theorem set_pi_mem_nhds {i : Set ι} {s : ∀ a, Set (π a)} {x : ∀ a, π a} (hi : i.Finite) (hs : ∀ a ∈ i, s a ∈ 𝓝 (x a)) : pi i s ∈ 𝓝 x := by rw [pi_def, biInter_mem hi] exact fun a ha => (continuous_apply a).continuousAt (hs a ha) #align set_pi_mem_nhds set_pi_mem_nhds theorem set_pi_mem_nhds_iff {I : Set ι} (hI : I.Finite) {s : ∀ i, Set (π i)} (a : ∀ i, π i) : I.pi s ∈ 𝓝 a ↔ ∀ i : ι, i ∈ I → s i ∈ 𝓝 (a i) := by rw [nhds_pi, pi_mem_pi_iff hI] #align set_pi_mem_nhds_iff set_pi_mem_nhds_iff
Mathlib/Topology/Constructions.lean
1,489
1,492
theorem interior_pi_set {I : Set ι} (hI : I.Finite) {s : ∀ i, Set (π i)} : interior (pi I s) = I.pi fun i => interior (s i) := by
ext a simp only [Set.mem_pi, mem_interior_iff_mem_nhds, set_pi_mem_nhds_iff hI]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Patrick Massot -/ import Mathlib.Data.Set.Image import Mathlib.Data.SProd #align_import data.set.prod from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Sets in product and pi types This file defines the product of sets in `α × β` and in `Π i, α i` along with the diagonal of a type. ## Main declarations * `Set.prod`: Binary product of sets. For `s : Set α`, `t : Set β`, we have `s.prod t : Set (α × β)`. * `Set.diagonal`: Diagonal of a type. `Set.diagonal α = {(x, x) | x : α}`. * `Set.offDiag`: Off-diagonal. `s ×ˢ s` without the diagonal. * `Set.pi`: Arbitrary product of sets. -/ open Function namespace Set /-! ### Cartesian binary product of sets -/ section Prod variable {α β γ δ : Type*} {s s₁ s₂ : Set α} {t t₁ t₂ : Set β} {a : α} {b : β} theorem Subsingleton.prod (hs : s.Subsingleton) (ht : t.Subsingleton) : (s ×ˢ t).Subsingleton := fun _x hx _y hy ↦ Prod.ext (hs hx.1 hy.1) (ht hx.2 hy.2) noncomputable instance decidableMemProd [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] : DecidablePred (· ∈ s ×ˢ t) := fun _ => And.decidable #align set.decidable_mem_prod Set.decidableMemProd @[gcongr] theorem prod_mono (hs : s₁ ⊆ s₂) (ht : t₁ ⊆ t₂) : s₁ ×ˢ t₁ ⊆ s₂ ×ˢ t₂ := fun _ ⟨h₁, h₂⟩ => ⟨hs h₁, ht h₂⟩ #align set.prod_mono Set.prod_mono @[gcongr] theorem prod_mono_left (hs : s₁ ⊆ s₂) : s₁ ×ˢ t ⊆ s₂ ×ˢ t := prod_mono hs Subset.rfl #align set.prod_mono_left Set.prod_mono_left @[gcongr] theorem prod_mono_right (ht : t₁ ⊆ t₂) : s ×ˢ t₁ ⊆ s ×ˢ t₂ := prod_mono Subset.rfl ht #align set.prod_mono_right Set.prod_mono_right @[simp] theorem prod_self_subset_prod_self : s₁ ×ˢ s₁ ⊆ s₂ ×ˢ s₂ ↔ s₁ ⊆ s₂ := ⟨fun h _ hx => (h (mk_mem_prod hx hx)).1, fun h _ hx => ⟨h hx.1, h hx.2⟩⟩ #align set.prod_self_subset_prod_self Set.prod_self_subset_prod_self @[simp] theorem prod_self_ssubset_prod_self : s₁ ×ˢ s₁ ⊂ s₂ ×ˢ s₂ ↔ s₁ ⊂ s₂ := and_congr prod_self_subset_prod_self <| not_congr prod_self_subset_prod_self #align set.prod_self_ssubset_prod_self Set.prod_self_ssubset_prod_self theorem prod_subset_iff {P : Set (α × β)} : s ×ˢ t ⊆ P ↔ ∀ x ∈ s, ∀ y ∈ t, (x, y) ∈ P := ⟨fun h _ hx _ hy => h (mk_mem_prod hx hy), fun h ⟨_, _⟩ hp => h _ hp.1 _ hp.2⟩ #align set.prod_subset_iff Set.prod_subset_iff theorem forall_prod_set {p : α × β → Prop} : (∀ x ∈ s ×ˢ t, p x) ↔ ∀ x ∈ s, ∀ y ∈ t, p (x, y) := prod_subset_iff #align set.forall_prod_set Set.forall_prod_set theorem exists_prod_set {p : α × β → Prop} : (∃ x ∈ s ×ˢ t, p x) ↔ ∃ x ∈ s, ∃ y ∈ t, p (x, y) := by simp [and_assoc] #align set.exists_prod_set Set.exists_prod_set @[simp] theorem prod_empty : s ×ˢ (∅ : Set β) = ∅ := by ext exact and_false_iff _ #align set.prod_empty Set.prod_empty @[simp] theorem empty_prod : (∅ : Set α) ×ˢ t = ∅ := by ext exact false_and_iff _ #align set.empty_prod Set.empty_prod @[simp, mfld_simps] theorem univ_prod_univ : @univ α ×ˢ @univ β = univ := by ext exact true_and_iff _ #align set.univ_prod_univ Set.univ_prod_univ theorem univ_prod {t : Set β} : (univ : Set α) ×ˢ t = Prod.snd ⁻¹' t := by simp [prod_eq] #align set.univ_prod Set.univ_prod theorem prod_univ {s : Set α} : s ×ˢ (univ : Set β) = Prod.fst ⁻¹' s := by simp [prod_eq] #align set.prod_univ Set.prod_univ @[simp] lemma prod_eq_univ [Nonempty α] [Nonempty β] : s ×ˢ t = univ ↔ s = univ ∧ t = univ := by simp [eq_univ_iff_forall, forall_and] @[simp] theorem singleton_prod : ({a} : Set α) ×ˢ t = Prod.mk a '' t := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.singleton_prod Set.singleton_prod @[simp] theorem prod_singleton : s ×ˢ ({b} : Set β) = (fun a => (a, b)) '' s := by ext ⟨x, y⟩ simp [and_left_comm, eq_comm] #align set.prod_singleton Set.prod_singleton theorem singleton_prod_singleton : ({a} : Set α) ×ˢ ({b} : Set β) = {(a, b)} := by simp #align set.singleton_prod_singleton Set.singleton_prod_singleton @[simp] theorem union_prod : (s₁ ∪ s₂) ×ˢ t = s₁ ×ˢ t ∪ s₂ ×ˢ t := by ext ⟨x, y⟩ simp [or_and_right] #align set.union_prod Set.union_prod @[simp] theorem prod_union : s ×ˢ (t₁ ∪ t₂) = s ×ˢ t₁ ∪ s ×ˢ t₂ := by ext ⟨x, y⟩ simp [and_or_left] #align set.prod_union Set.prod_union theorem inter_prod : (s₁ ∩ s₂) ×ˢ t = s₁ ×ˢ t ∩ s₂ ×ˢ t := by ext ⟨x, y⟩ simp only [← and_and_right, mem_inter_iff, mem_prod] #align set.inter_prod Set.inter_prod theorem prod_inter : s ×ˢ (t₁ ∩ t₂) = s ×ˢ t₁ ∩ s ×ˢ t₂ := by ext ⟨x, y⟩ simp only [← and_and_left, mem_inter_iff, mem_prod] #align set.prod_inter Set.prod_inter @[mfld_simps] theorem prod_inter_prod : s₁ ×ˢ t₁ ∩ s₂ ×ˢ t₂ = (s₁ ∩ s₂) ×ˢ (t₁ ∩ t₂) := by ext ⟨x, y⟩ simp [and_assoc, and_left_comm] #align set.prod_inter_prod Set.prod_inter_prod lemma compl_prod_eq_union {α β : Type*} (s : Set α) (t : Set β) : (s ×ˢ t)ᶜ = (sᶜ ×ˢ univ) ∪ (univ ×ˢ tᶜ) := by ext p simp only [mem_compl_iff, mem_prod, not_and, mem_union, mem_univ, and_true, true_and] constructor <;> intro h · by_cases fst_in_s : p.fst ∈ s · exact Or.inr (h fst_in_s) · exact Or.inl fst_in_s · intro fst_in_s simpa only [fst_in_s, not_true, false_or] using h @[simp] theorem disjoint_prod : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) ↔ Disjoint s₁ s₂ ∨ Disjoint t₁ t₂ := by simp_rw [disjoint_left, mem_prod, not_and_or, Prod.forall, and_imp, ← @forall_or_right α, ← @forall_or_left β, ← @forall_or_right (_ ∈ s₁), ← @forall_or_left (_ ∈ t₁)] #align set.disjoint_prod Set.disjoint_prod theorem Disjoint.set_prod_left (hs : Disjoint s₁ s₂) (t₁ t₂ : Set β) : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) := disjoint_left.2 fun ⟨_a, _b⟩ ⟨ha₁, _⟩ ⟨ha₂, _⟩ => disjoint_left.1 hs ha₁ ha₂ #align set.disjoint.set_prod_left Set.Disjoint.set_prod_left theorem Disjoint.set_prod_right (ht : Disjoint t₁ t₂) (s₁ s₂ : Set α) : Disjoint (s₁ ×ˢ t₁) (s₂ ×ˢ t₂) := disjoint_left.2 fun ⟨_a, _b⟩ ⟨_, hb₁⟩ ⟨_, hb₂⟩ => disjoint_left.1 ht hb₁ hb₂ #align set.disjoint.set_prod_right Set.Disjoint.set_prod_right theorem insert_prod : insert a s ×ˢ t = Prod.mk a '' t ∪ s ×ˢ t := by ext ⟨x, y⟩ simp (config := { contextual := true }) [image, iff_def, or_imp] #align set.insert_prod Set.insert_prod theorem prod_insert : s ×ˢ insert b t = (fun a => (a, b)) '' s ∪ s ×ˢ t := by ext ⟨x, y⟩ -- porting note (#10745): -- was `simp (config := { contextual := true }) [image, iff_def, or_imp, Imp.swap]` simp only [mem_prod, mem_insert_iff, image, mem_union, mem_setOf_eq, Prod.mk.injEq] refine ⟨fun h => ?_, fun h => ?_⟩ · obtain ⟨hx, rfl|hy⟩ := h · exact Or.inl ⟨x, hx, rfl, rfl⟩ · exact Or.inr ⟨hx, hy⟩ · obtain ⟨x, hx, rfl, rfl⟩|⟨hx, hy⟩ := h · exact ⟨hx, Or.inl rfl⟩ · exact ⟨hx, Or.inr hy⟩ #align set.prod_insert Set.prod_insert theorem prod_preimage_eq {f : γ → α} {g : δ → β} : (f ⁻¹' s) ×ˢ (g ⁻¹' t) = (fun p : γ × δ => (f p.1, g p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_eq Set.prod_preimage_eq theorem prod_preimage_left {f : γ → α} : (f ⁻¹' s) ×ˢ t = (fun p : γ × β => (f p.1, p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_left Set.prod_preimage_left theorem prod_preimage_right {g : δ → β} : s ×ˢ (g ⁻¹' t) = (fun p : α × δ => (p.1, g p.2)) ⁻¹' s ×ˢ t := rfl #align set.prod_preimage_right Set.prod_preimage_right theorem preimage_prod_map_prod (f : α → β) (g : γ → δ) (s : Set β) (t : Set δ) : Prod.map f g ⁻¹' s ×ˢ t = (f ⁻¹' s) ×ˢ (g ⁻¹' t) := rfl #align set.preimage_prod_map_prod Set.preimage_prod_map_prod theorem mk_preimage_prod (f : γ → α) (g : γ → β) : (fun x => (f x, g x)) ⁻¹' s ×ˢ t = f ⁻¹' s ∩ g ⁻¹' t := rfl #align set.mk_preimage_prod Set.mk_preimage_prod @[simp] theorem mk_preimage_prod_left (hb : b ∈ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = s := by ext a simp [hb] #align set.mk_preimage_prod_left Set.mk_preimage_prod_left @[simp] theorem mk_preimage_prod_right (ha : a ∈ s) : Prod.mk a ⁻¹' s ×ˢ t = t := by ext b simp [ha] #align set.mk_preimage_prod_right Set.mk_preimage_prod_right @[simp] theorem mk_preimage_prod_left_eq_empty (hb : b ∉ t) : (fun a => (a, b)) ⁻¹' s ×ˢ t = ∅ := by ext a simp [hb] #align set.mk_preimage_prod_left_eq_empty Set.mk_preimage_prod_left_eq_empty @[simp] theorem mk_preimage_prod_right_eq_empty (ha : a ∉ s) : Prod.mk a ⁻¹' s ×ˢ t = ∅ := by ext b simp [ha] #align set.mk_preimage_prod_right_eq_empty Set.mk_preimage_prod_right_eq_empty theorem mk_preimage_prod_left_eq_if [DecidablePred (· ∈ t)] : (fun a => (a, b)) ⁻¹' s ×ˢ t = if b ∈ t then s else ∅ := by split_ifs with h <;> simp [h] #align set.mk_preimage_prod_left_eq_if Set.mk_preimage_prod_left_eq_if theorem mk_preimage_prod_right_eq_if [DecidablePred (· ∈ s)] : Prod.mk a ⁻¹' s ×ˢ t = if a ∈ s then t else ∅ := by split_ifs with h <;> simp [h] #align set.mk_preimage_prod_right_eq_if Set.mk_preimage_prod_right_eq_if theorem mk_preimage_prod_left_fn_eq_if [DecidablePred (· ∈ t)] (f : γ → α) : (fun a => (f a, b)) ⁻¹' s ×ˢ t = if b ∈ t then f ⁻¹' s else ∅ := by rw [← mk_preimage_prod_left_eq_if, prod_preimage_left, preimage_preimage] #align set.mk_preimage_prod_left_fn_eq_if Set.mk_preimage_prod_left_fn_eq_if theorem mk_preimage_prod_right_fn_eq_if [DecidablePred (· ∈ s)] (g : δ → β) : (fun b => (a, g b)) ⁻¹' s ×ˢ t = if a ∈ s then g ⁻¹' t else ∅ := by rw [← mk_preimage_prod_right_eq_if, prod_preimage_right, preimage_preimage] #align set.mk_preimage_prod_right_fn_eq_if Set.mk_preimage_prod_right_fn_eq_if @[simp] theorem preimage_swap_prod (s : Set α) (t : Set β) : Prod.swap ⁻¹' s ×ˢ t = t ×ˢ s := by ext ⟨x, y⟩ simp [and_comm] #align set.preimage_swap_prod Set.preimage_swap_prod @[simp] theorem image_swap_prod (s : Set α) (t : Set β) : Prod.swap '' s ×ˢ t = t ×ˢ s := by rw [image_swap_eq_preimage_swap, preimage_swap_prod] #align set.image_swap_prod Set.image_swap_prod theorem prod_image_image_eq {m₁ : α → γ} {m₂ : β → δ} : (m₁ '' s) ×ˢ (m₂ '' t) = (fun p : α × β => (m₁ p.1, m₂ p.2)) '' s ×ˢ t := ext <| by simp [-exists_and_right, exists_and_right.symm, and_left_comm, and_assoc, and_comm] #align set.prod_image_image_eq Set.prod_image_image_eq theorem prod_range_range_eq {m₁ : α → γ} {m₂ : β → δ} : range m₁ ×ˢ range m₂ = range fun p : α × β => (m₁ p.1, m₂ p.2) := ext <| by simp [range] #align set.prod_range_range_eq Set.prod_range_range_eq @[simp, mfld_simps] theorem range_prod_map {m₁ : α → γ} {m₂ : β → δ} : range (Prod.map m₁ m₂) = range m₁ ×ˢ range m₂ := prod_range_range_eq.symm #align set.range_prod_map Set.range_prod_map theorem prod_range_univ_eq {m₁ : α → γ} : range m₁ ×ˢ (univ : Set β) = range fun p : α × β => (m₁ p.1, p.2) := ext <| by simp [range] #align set.prod_range_univ_eq Set.prod_range_univ_eq theorem prod_univ_range_eq {m₂ : β → δ} : (univ : Set α) ×ˢ range m₂ = range fun p : α × β => (p.1, m₂ p.2) := ext <| by simp [range] #align set.prod_univ_range_eq Set.prod_univ_range_eq theorem range_pair_subset (f : α → β) (g : α → γ) : (range fun x => (f x, g x)) ⊆ range f ×ˢ range g := by have : (fun x => (f x, g x)) = Prod.map f g ∘ fun x => (x, x) := funext fun x => rfl rw [this, ← range_prod_map] apply range_comp_subset_range #align set.range_pair_subset Set.range_pair_subset theorem Nonempty.prod : s.Nonempty → t.Nonempty → (s ×ˢ t).Nonempty := fun ⟨x, hx⟩ ⟨y, hy⟩ => ⟨(x, y), ⟨hx, hy⟩⟩ #align set.nonempty.prod Set.Nonempty.prod theorem Nonempty.fst : (s ×ˢ t).Nonempty → s.Nonempty := fun ⟨x, hx⟩ => ⟨x.1, hx.1⟩ #align set.nonempty.fst Set.Nonempty.fst theorem Nonempty.snd : (s ×ˢ t).Nonempty → t.Nonempty := fun ⟨x, hx⟩ => ⟨x.2, hx.2⟩ #align set.nonempty.snd Set.Nonempty.snd @[simp] theorem prod_nonempty_iff : (s ×ˢ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty := ⟨fun h => ⟨h.fst, h.snd⟩, fun h => h.1.prod h.2⟩ #align set.prod_nonempty_iff Set.prod_nonempty_iff @[simp] theorem prod_eq_empty_iff : s ×ˢ t = ∅ ↔ s = ∅ ∨ t = ∅ := by simp only [not_nonempty_iff_eq_empty.symm, prod_nonempty_iff, not_and_or] #align set.prod_eq_empty_iff Set.prod_eq_empty_iff theorem prod_sub_preimage_iff {W : Set γ} {f : α × β → γ} : s ×ˢ t ⊆ f ⁻¹' W ↔ ∀ a b, a ∈ s → b ∈ t → f (a, b) ∈ W := by simp [subset_def] #align set.prod_sub_preimage_iff Set.prod_sub_preimage_iff theorem image_prod_mk_subset_prod {f : α → β} {g : α → γ} {s : Set α} : (fun x => (f x, g x)) '' s ⊆ (f '' s) ×ˢ (g '' s) := by rintro _ ⟨x, hx, rfl⟩ exact mk_mem_prod (mem_image_of_mem f hx) (mem_image_of_mem g hx) #align set.image_prod_mk_subset_prod Set.image_prod_mk_subset_prod theorem image_prod_mk_subset_prod_left (hb : b ∈ t) : (fun a => (a, b)) '' s ⊆ s ×ˢ t := by rintro _ ⟨a, ha, rfl⟩ exact ⟨ha, hb⟩ #align set.image_prod_mk_subset_prod_left Set.image_prod_mk_subset_prod_left theorem image_prod_mk_subset_prod_right (ha : a ∈ s) : Prod.mk a '' t ⊆ s ×ˢ t := by rintro _ ⟨b, hb, rfl⟩ exact ⟨ha, hb⟩ #align set.image_prod_mk_subset_prod_right Set.image_prod_mk_subset_prod_right theorem prod_subset_preimage_fst (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.fst ⁻¹' s := inter_subset_left #align set.prod_subset_preimage_fst Set.prod_subset_preimage_fst theorem fst_image_prod_subset (s : Set α) (t : Set β) : Prod.fst '' s ×ˢ t ⊆ s := image_subset_iff.2 <| prod_subset_preimage_fst s t #align set.fst_image_prod_subset Set.fst_image_prod_subset theorem fst_image_prod (s : Set β) {t : Set α} (ht : t.Nonempty) : Prod.fst '' s ×ˢ t = s := (fst_image_prod_subset _ _).antisymm fun y hy => let ⟨x, hx⟩ := ht ⟨(y, x), ⟨hy, hx⟩, rfl⟩ #align set.fst_image_prod Set.fst_image_prod theorem prod_subset_preimage_snd (s : Set α) (t : Set β) : s ×ˢ t ⊆ Prod.snd ⁻¹' t := inter_subset_right #align set.prod_subset_preimage_snd Set.prod_subset_preimage_snd theorem snd_image_prod_subset (s : Set α) (t : Set β) : Prod.snd '' s ×ˢ t ⊆ t := image_subset_iff.2 <| prod_subset_preimage_snd s t #align set.snd_image_prod_subset Set.snd_image_prod_subset theorem snd_image_prod {s : Set α} (hs : s.Nonempty) (t : Set β) : Prod.snd '' s ×ˢ t = t := (snd_image_prod_subset _ _).antisymm fun y y_in => let ⟨x, x_in⟩ := hs ⟨(x, y), ⟨x_in, y_in⟩, rfl⟩ #align set.snd_image_prod Set.snd_image_prod theorem prod_diff_prod : s ×ˢ t \ s₁ ×ˢ t₁ = s ×ˢ (t \ t₁) ∪ (s \ s₁) ×ˢ t := by ext x by_cases h₁ : x.1 ∈ s₁ <;> by_cases h₂ : x.2 ∈ t₁ <;> simp [*] #align set.prod_diff_prod Set.prod_diff_prod /-- A product set is included in a product set if and only factors are included, or a factor of the first set is empty. -/ theorem prod_subset_prod_iff : s ×ˢ t ⊆ s₁ ×ˢ t₁ ↔ s ⊆ s₁ ∧ t ⊆ t₁ ∨ s = ∅ ∨ t = ∅ := by rcases (s ×ˢ t).eq_empty_or_nonempty with h | h · simp [h, prod_eq_empty_iff.1 h] have st : s.Nonempty ∧ t.Nonempty := by rwa [prod_nonempty_iff] at h refine ⟨fun H => Or.inl ⟨?_, ?_⟩, ?_⟩ · have := image_subset (Prod.fst : α × β → α) H rwa [fst_image_prod _ st.2, fst_image_prod _ (h.mono H).snd] at this · have := image_subset (Prod.snd : α × β → β) H rwa [snd_image_prod st.1, snd_image_prod (h.mono H).fst] at this · intro H simp only [st.1.ne_empty, st.2.ne_empty, or_false_iff] at H exact prod_mono H.1 H.2 #align set.prod_subset_prod_iff Set.prod_subset_prod_iff theorem prod_eq_prod_iff_of_nonempty (h : (s ×ˢ t).Nonempty) : s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ := by constructor · intro heq have h₁ : (s₁ ×ˢ t₁ : Set _).Nonempty := by rwa [← heq] rw [prod_nonempty_iff] at h h₁ rw [← fst_image_prod s h.2, ← fst_image_prod s₁ h₁.2, heq, eq_self_iff_true, true_and_iff, ← snd_image_prod h.1 t, ← snd_image_prod h₁.1 t₁, heq] · rintro ⟨rfl, rfl⟩ rfl #align set.prod_eq_prod_iff_of_nonempty Set.prod_eq_prod_iff_of_nonempty theorem prod_eq_prod_iff : s ×ˢ t = s₁ ×ˢ t₁ ↔ s = s₁ ∧ t = t₁ ∨ (s = ∅ ∨ t = ∅) ∧ (s₁ = ∅ ∨ t₁ = ∅) := by symm rcases eq_empty_or_nonempty (s ×ˢ t) with h | h · simp_rw [h, @eq_comm _ ∅, prod_eq_empty_iff, prod_eq_empty_iff.mp h, true_and_iff, or_iff_right_iff_imp] rintro ⟨rfl, rfl⟩ exact prod_eq_empty_iff.mp h rw [prod_eq_prod_iff_of_nonempty h] rw [nonempty_iff_ne_empty, Ne, prod_eq_empty_iff] at h simp_rw [h, false_and_iff, or_false_iff] #align set.prod_eq_prod_iff Set.prod_eq_prod_iff @[simp] theorem prod_eq_iff_eq (ht : t.Nonempty) : s ×ˢ t = s₁ ×ˢ t ↔ s = s₁ := by simp_rw [prod_eq_prod_iff, ht.ne_empty, and_true_iff, or_iff_left_iff_imp, or_false_iff] rintro ⟨rfl, rfl⟩ rfl #align set.prod_eq_iff_eq Set.prod_eq_iff_eq section Mono variable [Preorder α] {f : α → Set β} {g : α → Set γ} theorem _root_.Monotone.set_prod (hf : Monotone f) (hg : Monotone g) : Monotone fun x => f x ×ˢ g x := fun _ _ h => prod_mono (hf h) (hg h) #align monotone.set_prod Monotone.set_prod theorem _root_.Antitone.set_prod (hf : Antitone f) (hg : Antitone g) : Antitone fun x => f x ×ˢ g x := fun _ _ h => prod_mono (hf h) (hg h) #align antitone.set_prod Antitone.set_prod theorem _root_.MonotoneOn.set_prod (hf : MonotoneOn f s) (hg : MonotoneOn g s) : MonotoneOn (fun x => f x ×ˢ g x) s := fun _ ha _ hb h => prod_mono (hf ha hb h) (hg ha hb h) #align monotone_on.set_prod MonotoneOn.set_prod theorem _root_.AntitoneOn.set_prod (hf : AntitoneOn f s) (hg : AntitoneOn g s) : AntitoneOn (fun x => f x ×ˢ g x) s := fun _ ha _ hb h => prod_mono (hf ha hb h) (hg ha hb h) #align antitone_on.set_prod AntitoneOn.set_prod end Mono end Prod /-! ### Diagonal In this section we prove some lemmas about the diagonal set `{p | p.1 = p.2}` and the diagonal map `fun x ↦ (x, x)`. -/ section Diagonal variable {α : Type*} {s t : Set α} lemma diagonal_nonempty [Nonempty α] : (diagonal α).Nonempty := Nonempty.elim ‹_› fun x => ⟨_, mem_diagonal x⟩ #align set.diagonal_nonempty Set.diagonal_nonempty instance decidableMemDiagonal [h : DecidableEq α] (x : α × α) : Decidable (x ∈ diagonal α) := h x.1 x.2 #align set.decidable_mem_diagonal Set.decidableMemDiagonal theorem preimage_coe_coe_diagonal (s : Set α) : Prod.map (fun x : s => (x : α)) (fun x : s => (x : α)) ⁻¹' diagonal α = diagonal s := by ext ⟨⟨x, hx⟩, ⟨y, hy⟩⟩ simp [Set.diagonal] #align set.preimage_coe_coe_diagonal Set.preimage_coe_coe_diagonal @[simp] theorem range_diag : (range fun x => (x, x)) = diagonal α := by ext ⟨x, y⟩ simp [diagonal, eq_comm] #align set.range_diag Set.range_diag
Mathlib/Data/Set/Prod.lean
489
490
theorem diagonal_subset_iff {s} : diagonal α ⊆ s ↔ ∀ x, (x, x) ∈ s := by
rw [← range_diag, range_subset_iff]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Yury Kudryashov -/ import Mathlib.MeasureTheory.OuterMeasure.Basic /-! # The “almost everywhere” filter of co-null sets. If `μ` is an outer measure or a measure on `α`, then `MeasureTheory.ae μ` is the filter of co-null sets: `s ∈ ae μ ↔ μ sᶜ = 0`. In this file we define the filter and prove some basic theorems about it. ## Notation - `∀ᵐ x ∂μ, p x`: the predicate `p` holds for `μ`-a.e. all `x`; - `∃ᶠ x ∂μ, p x`: the predicate `p` holds on a set of nonzero measure; - `f =ᵐ[μ] g`: `f x = g x` for `μ`-a.e. all `x`; - `f ≤ᵐ[μ] g`: `f x ≤ g x` for `μ`-a.e. all `x`. ## Implementation details All notation introduced in this file reducibly unfolds to the corresponding definitions about filters, so generic lemmas about `Filter.Eventually`, `Filter.EventuallyEq` etc apply. However, we restate some lemmas specifically for `ae`. ## Tags outer measure, measure, almost everywhere -/ open Filter Set open scoped ENNReal namespace MeasureTheory variable {α β F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α} /-- The “almost everywhere” filter of co-null sets. -/ 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 /-- `∀ᵐ a ∂μ, p a` means that `p a` for a.e. `a`, i.e. `p` holds true away from a null set. This is notation for `Filter.Eventually p (MeasureTheory.ae μ)`. -/ notation3 "∀ᵐ "(...)" ∂"μ", "r:(scoped p => Filter.Eventually p <| MeasureTheory.ae μ) => r /-- `∃ᵐ a ∂μ, p a` means that `p` holds `∂μ`-frequently, i.e. `p` holds on a set of positive measure. This is notation for `Filter.Frequently p (MeasureTheory.ae μ)`. -/ notation3 "∃ᵐ "(...)" ∂"μ", "r:(scoped P => Filter.Frequently P <| MeasureTheory.ae μ) => r /-- `f =ᵐ[μ] g` means `f` and `g` are eventually equal along the a.e. filter, i.e. `f=g` away from a null set. This is notation for `Filter.EventuallyEq (MeasureTheory.ae μ) f g`. -/ notation:50 f " =ᵐ[" μ:50 "] " g:50 => Filter.EventuallyEq (MeasureTheory.ae μ) f g /-- `f ≤ᵐ[μ] g` means `f` is eventually less than `g` along the a.e. filter, i.e. `f ≤ g` away from a null set. This is notation for `Filter.EventuallyLE (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]
Mathlib/MeasureTheory/OuterMeasure/AE.lean
184
185
theorem measure_symmDiff_eq_zero_iff {s t : Set α} : μ (s ∆ t) = 0 ↔ s =ᵐ[μ] t := by
simp [ae_eq_set, symmDiff_def]
/- Copyright (c) 2019 Kenny Lau, Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Chris Hughes, Jujian Zhang -/ import Mathlib.Data.Finset.Order import Mathlib.Algebra.DirectSum.Module import Mathlib.RingTheory.FreeCommRing import Mathlib.RingTheory.Ideal.Maps import Mathlib.RingTheory.Ideal.Quotient import Mathlib.Tactic.SuppressCompilation #align_import algebra.direct_limit from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Direct limit of modules, abelian groups, rings, and fields. See Atiyah-Macdonald PP.32-33, Matsumura PP.269-270 Generalizes the notion of "union", or "gluing", of incomparable modules over the same ring, or incomparable abelian groups, or rings, or fields. It is constructed as a quotient of the free module (for the module case) or quotient of the free commutative ring (for the ring case) instead of a quotient of the disjoint union so as to make the operations (addition etc.) "computable". ## Main definitions * `DirectedSystem f` * `Module.DirectLimit G f` * `AddCommGroup.DirectLimit G f` * `Ring.DirectLimit G f` -/ suppress_compilation universe u v v' v'' w u₁ open Submodule variable {R : Type u} [Ring R] variable {ι : Type v} variable [Preorder ι] variable (G : ι → Type w) /-- A directed system is a functor from a category (directed poset) to another category. -/ class DirectedSystem (f : ∀ i j, i ≤ j → G i → G j) : Prop where map_self' : ∀ i x h, f i i h x = x map_map' : ∀ {i j k} (hij hjk x), f j k hjk (f i j hij x) = f i k (le_trans hij hjk) x #align directed_system DirectedSystem section variable {G} (f : ∀ i j, i ≤ j → G i → G j) [DirectedSystem G fun i j h => f i j h] theorem DirectedSystem.map_self i x h : f i i h x = x := DirectedSystem.map_self' i x h theorem DirectedSystem.map_map {i j k} (hij hjk x) : f j k hjk (f i j hij x) = f i k (le_trans hij hjk) x := DirectedSystem.map_map' hij hjk x end namespace Module variable [∀ i, AddCommGroup (G i)] [∀ i, Module R (G i)] variable {G} (f : ∀ i j, i ≤ j → G i →ₗ[R] G j) /-- A copy of `DirectedSystem.map_self` specialized to linear maps, as otherwise the `fun i j h ↦ f i j h` can confuse the simplifier. -/ nonrec theorem DirectedSystem.map_self [DirectedSystem G fun i j h => f i j h] (i x h) : f i i h x = x := DirectedSystem.map_self (fun i j h => f i j h) i x h #align module.directed_system.map_self Module.DirectedSystem.map_self /-- A copy of `DirectedSystem.map_map` specialized to linear maps, as otherwise the `fun i j h ↦ f i j h` can confuse the simplifier. -/ nonrec theorem DirectedSystem.map_map [DirectedSystem G fun i j h => f i j h] {i j k} (hij hjk x) : f j k hjk (f i j hij x) = f i k (le_trans hij hjk) x := DirectedSystem.map_map (fun i j h => f i j h) hij hjk x #align module.directed_system.map_map Module.DirectedSystem.map_map variable (G) variable [DecidableEq ι] /-- The direct limit of a directed system is the modules glued together along the maps. -/ def DirectLimit : Type max v w := DirectSum ι G ⧸ (span R <| { a | ∃ (i j : _) (H : i ≤ j) (x : _), DirectSum.lof R ι G i x - DirectSum.lof R ι G j (f i j H x) = a }) #align module.direct_limit Module.DirectLimit namespace DirectLimit instance addCommGroup : AddCommGroup (DirectLimit G f) := Quotient.addCommGroup _ instance module : Module R (DirectLimit G f) := Quotient.module _ instance inhabited : Inhabited (DirectLimit G f) := ⟨0⟩ instance unique [IsEmpty ι] : Unique (DirectLimit G f) := inferInstanceAs <| Unique (Quotient _) variable (R ι) /-- The canonical map from a component to the direct limit. -/ def of (i) : G i →ₗ[R] DirectLimit G f := (mkQ _).comp <| DirectSum.lof R ι G i #align module.direct_limit.of Module.DirectLimit.of variable {R ι G f} @[simp] theorem of_f {i j hij x} : of R ι G f j (f i j hij x) = of R ι G f i x := Eq.symm <| (Submodule.Quotient.eq _).2 <| subset_span ⟨i, j, hij, x, rfl⟩ #align module.direct_limit.of_f Module.DirectLimit.of_f /-- Every element of the direct limit corresponds to some element in some component of the directed system. -/ theorem exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)] (z : DirectLimit G f) : ∃ i x, of R ι G f i x = z := Nonempty.elim (by infer_instance) fun ind : ι => Quotient.inductionOn' z fun z => DirectSum.induction_on z ⟨ind, 0, LinearMap.map_zero _⟩ (fun i x => ⟨i, x, rfl⟩) fun p q ⟨i, x, ihx⟩ ⟨j, y, ihy⟩ => let ⟨k, hik, hjk⟩ := exists_ge_ge i j ⟨k, f i k hik x + f j k hjk y, by rw [LinearMap.map_add, of_f, of_f, ihx, ihy] rfl ⟩ #align module.direct_limit.exists_of Module.DirectLimit.exists_of @[elab_as_elim] protected theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop} (z : DirectLimit G f) (ih : ∀ i x, C (of R ι G f i x)) : C z := let ⟨i, x, h⟩ := exists_of z h ▸ ih i x #align module.direct_limit.induction_on Module.DirectLimit.induction_on variable {P : Type u₁} [AddCommGroup P] [Module R P] (g : ∀ i, G i →ₗ[R] P) variable (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) variable (R ι G f) /-- The universal property of the direct limit: maps from the components to another module that respect the directed system structure (i.e. make some diagram commute) give rise to a unique map out of the direct limit. -/ def lift : DirectLimit G f →ₗ[R] P := liftQ _ (DirectSum.toModule R ι P g) (span_le.2 fun a ⟨i, j, hij, x, hx⟩ => by rw [← hx, SetLike.mem_coe, LinearMap.sub_mem_ker_iff, DirectSum.toModule_lof, DirectSum.toModule_lof, Hg]) #align module.direct_limit.lift Module.DirectLimit.lift variable {R ι G f} theorem lift_of {i} (x) : lift R ι G f g Hg (of R ι G f i x) = g i x := DirectSum.toModule_lof R _ _ #align module.direct_limit.lift_of Module.DirectLimit.lift_of theorem lift_unique [IsDirected ι (· ≤ ·)] (F : DirectLimit G f →ₗ[R] P) (x) : F x = lift R ι G f (fun i => F.comp <| of R ι G f i) (fun i j hij x => by rw [LinearMap.comp_apply, of_f]; rfl) x := by cases isEmpty_or_nonempty ι · simp_rw [Subsingleton.elim x 0, _root_.map_zero] · exact DirectLimit.induction_on x fun i x => by rw [lift_of]; rfl #align module.direct_limit.lift_unique Module.DirectLimit.lift_unique lemma lift_injective [IsDirected ι (· ≤ ·)] (injective : ∀ i, Function.Injective <| g i) : Function.Injective (lift R ι G f g Hg) := by cases isEmpty_or_nonempty ι · apply Function.injective_of_subsingleton simp_rw [injective_iff_map_eq_zero] at injective ⊢ intros z hz induction' z using DirectLimit.induction_on with _ g rw [lift_of] at hz rw [injective _ g hz, _root_.map_zero] section functorial variable {G' : ι → Type v'} [∀ i, AddCommGroup (G' i)] [∀ i, Module R (G' i)] variable {f' : ∀ i j, i ≤ j → G' i →ₗ[R] G' j} variable {G'' : ι → Type v''} [∀ i, AddCommGroup (G'' i)] [∀ i, Module R (G'' i)] variable {f'' : ∀ i j, i ≤ j → G'' i →ₗ[R] G'' j} /-- Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any family of linear maps `gᵢ : Gᵢ ⟶ G'ᵢ` such that `g ∘ f = f' ∘ g` induces a linear map `lim G ⟶ lim G'`. -/ def map (g : (i : ι) → G i →ₗ[R] G' i) (hg : ∀ i j h, g j ∘ₗ f i j h = f' i j h ∘ₗ g i) : DirectLimit G f →ₗ[R] DirectLimit G' f' := lift _ _ _ _ (fun i ↦ of _ _ _ _ _ ∘ₗ g i) fun i j h g ↦ by cases isEmpty_or_nonempty ι · exact Subsingleton.elim _ _ · have eq1 := LinearMap.congr_fun (hg i j h) g simp only [LinearMap.coe_comp, Function.comp_apply] at eq1 ⊢ rw [eq1, of_f] @[simp] lemma map_apply_of (g : (i : ι) → G i →ₗ[R] G' i) (hg : ∀ i j h, g j ∘ₗ f i j h = f' i j h ∘ₗ g i) {i : ι} (x : G i) : map g hg (of _ _ G f _ x) = of R ι G' f' i (g i x) := lift_of _ _ _ @[simp] lemma map_id [IsDirected ι (· ≤ ·)] : map (fun i ↦ LinearMap.id) (fun _ _ _ ↦ rfl) = LinearMap.id (R := R) (M := DirectLimit G f) := DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦ x.induction_on fun i g ↦ by simp lemma map_comp [IsDirected ι (· ≤ ·)] (g₁ : (i : ι) → G i →ₗ[R] G' i) (g₂ : (i : ι) → G' i →ₗ[R] G'' i) (hg₁ : ∀ i j h, g₁ j ∘ₗ f i j h = f' i j h ∘ₗ g₁ i) (hg₂ : ∀ i j h, g₂ j ∘ₗ f' i j h = f'' i j h ∘ₗ g₂ i) : (map g₂ hg₂ ∘ₗ map g₁ hg₁ : DirectLimit G f →ₗ[R] DirectLimit G'' f'') = (map (fun i ↦ g₂ i ∘ₗ g₁ i) fun i j h ↦ by rw [LinearMap.comp_assoc, hg₁ i, ← LinearMap.comp_assoc, hg₂ i, LinearMap.comp_assoc] : DirectLimit G f →ₗ[R] DirectLimit G'' f'') := DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦ x.induction_on fun i g ↦ by simp open LinearEquiv LinearMap in /-- Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence `lim G ≅ lim G'`. -/ def congr [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃ₗ[R] G' i) (he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i) : DirectLimit G f ≃ₗ[R] DirectLimit G' f' := LinearEquiv.ofLinear (map (e ·) he) (map (fun i ↦ (e i).symm) fun i j h ↦ by rw [toLinearMap_symm_comp_eq, ← comp_assoc, he i, comp_assoc, comp_coe, symm_trans_self, refl_toLinearMap, comp_id]) (by simp [map_comp]) (by simp [map_comp]) lemma congr_apply_of [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃ₗ[R] G' i) (he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i) {i : ι} (g : G i) : congr e he (of _ _ G f i g) = of _ _ G' f' i (e i g) := map_apply_of _ he _ open LinearEquiv LinearMap in lemma congr_symm_apply_of [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃ₗ[R] G' i) (he : ∀ i j h, e j ∘ₗ f i j h = f' i j h ∘ₗ e i) {i : ι} (g : G' i) : (congr e he).symm (of _ _ G' f' i g) = of _ _ G f i ((e i).symm g) := map_apply_of _ (fun i j h ↦ by rw [toLinearMap_symm_comp_eq, ← comp_assoc, he i, comp_assoc, comp_coe, symm_trans_self, refl_toLinearMap, comp_id]) _ end functorial section Totalize open scoped Classical variable (G f) /-- `totalize G f i j` is a linear map from `G i` to `G j`, for *every* `i` and `j`. If `i ≤ j`, then it is the map `f i j` that comes with the directed system `G`, and otherwise it is the zero map. -/ noncomputable def totalize (i j) : G i →ₗ[R] G j := if h : i ≤ j then f i j h else 0 #align module.direct_limit.totalize Module.DirectLimit.totalize variable {G f} theorem totalize_of_le {i j} (h : i ≤ j) : totalize G f i j = f i j h := dif_pos h #align module.direct_limit.totalize_of_le Module.DirectLimit.totalize_of_le theorem totalize_of_not_le {i j} (h : ¬i ≤ j) : totalize G f i j = 0 := dif_neg h #align module.direct_limit.totalize_of_not_le Module.DirectLimit.totalize_of_not_le end Totalize variable [DirectedSystem G fun i j h => f i j h] theorem toModule_totalize_of_le [∀ i (k : G i), Decidable (k ≠ 0)] {x : DirectSum ι G} {i j : ι} (hij : i ≤ j) (hx : ∀ k ∈ x.support, k ≤ i) : DirectSum.toModule R ι (G j) (fun k => totalize G f k j) x = f i j hij (DirectSum.toModule R ι (G i) (fun k => totalize G f k i) x) := by rw [← @DFinsupp.sum_single ι G _ _ _ x] unfold DFinsupp.sum simp only [map_sum] refine Finset.sum_congr rfl fun k hk => ?_ rw [DirectSum.single_eq_lof R k (x k), DirectSum.toModule_lof, DirectSum.toModule_lof, totalize_of_le (hx k hk), totalize_of_le (le_trans (hx k hk) hij), DirectedSystem.map_map] #align module.direct_limit.to_module_totalize_of_le Module.DirectLimit.toModule_totalize_of_le theorem of.zero_exact_aux [∀ i (k : G i), Decidable (k ≠ 0)] [Nonempty ι] [IsDirected ι (· ≤ ·)] {x : DirectSum ι G} (H : (Submodule.Quotient.mk x : DirectLimit G f) = (0 : DirectLimit G f)) : ∃ j, (∀ k ∈ x.support, k ≤ j) ∧ DirectSum.toModule R ι (G j) (fun i => totalize G f i j) x = (0 : G j) := Nonempty.elim (by infer_instance) fun ind : ι => span_induction ((Quotient.mk_eq_zero _).1 H) (fun x ⟨i, j, hij, y, hxy⟩ => let ⟨k, hik, hjk⟩ := exists_ge_ge i j ⟨k, by subst hxy constructor · intro i0 hi0 rw [DFinsupp.mem_support_iff, DirectSum.sub_apply, ← DirectSum.single_eq_lof, ← DirectSum.single_eq_lof, DFinsupp.single_apply, DFinsupp.single_apply] at hi0 split_ifs at hi0 with hi hj hj · rwa [hi] at hik · rwa [hi] at hik · rwa [hj] at hjk exfalso apply hi0 rw [sub_zero] simp [LinearMap.map_sub, totalize_of_le, hik, hjk, DirectedSystem.map_map, DirectSum.apply_eq_component, DirectSum.component.of]⟩) ⟨ind, fun _ h => (Finset.not_mem_empty _ h).elim, LinearMap.map_zero _⟩ (fun x y ⟨i, hi, hxi⟩ ⟨j, hj, hyj⟩ => let ⟨k, hik, hjk⟩ := exists_ge_ge i j ⟨k, fun l hl => (Finset.mem_union.1 (DFinsupp.support_add hl)).elim (fun hl => le_trans (hi _ hl) hik) fun hl => le_trans (hj _ hl) hjk, by -- Porting note: this had been -- simp [LinearMap.map_add, hxi, hyj, toModule_totalize_of_le hik hi, -- toModule_totalize_of_le hjk hj] simp only [map_add] rw [toModule_totalize_of_le hik hi, toModule_totalize_of_le hjk hj] simp [hxi, hyj]⟩) fun a x ⟨i, hi, hxi⟩ => ⟨i, fun k hk => hi k (DirectSum.support_smul _ _ hk), by simp [LinearMap.map_smul, hxi]⟩ #align module.direct_limit.of.zero_exact_aux Module.DirectLimit.of.zero_exact_aux open Classical in /-- A component that corresponds to zero in the direct limit is already zero in some bigger module in the directed system. -/ theorem of.zero_exact [IsDirected ι (· ≤ ·)] {i x} (H : of R ι G f i x = 0) : ∃ j hij, f i j hij x = (0 : G j) := haveI : Nonempty ι := ⟨i⟩ let ⟨j, hj, hxj⟩ := of.zero_exact_aux H if hx0 : x = 0 then ⟨i, le_rfl, by simp [hx0]⟩ else have hij : i ≤ j := hj _ <| by simp [DirectSum.apply_eq_component, hx0] ⟨j, hij, by -- Porting note: this had been -- simpa [totalize_of_le hij] using hxj simp only [DirectSum.toModule_lof] at hxj rwa [totalize_of_le hij] at hxj⟩ #align module.direct_limit.of.zero_exact Module.DirectLimit.of.zero_exact end DirectLimit end Module namespace AddCommGroup variable [DecidableEq ι] [∀ i, AddCommGroup (G i)] /-- The direct limit of a directed system is the abelian groups glued together along the maps. -/ def DirectLimit (f : ∀ i j, i ≤ j → G i →+ G j) : Type _ := @Module.DirectLimit ℤ _ ι _ G _ _ (fun i j hij => (f i j hij).toIntLinearMap) _ #align add_comm_group.direct_limit AddCommGroup.DirectLimit namespace DirectLimit variable (f : ∀ i j, i ≤ j → G i →+ G j) protected theorem directedSystem [h : DirectedSystem G fun i j h => f i j h] : DirectedSystem G fun i j hij => (f i j hij).toIntLinearMap := h #align add_comm_group.direct_limit.directed_system AddCommGroup.DirectLimit.directedSystem attribute [local instance] DirectLimit.directedSystem instance : AddCommGroup (DirectLimit G f) := Module.DirectLimit.addCommGroup G fun i j hij => (f i j hij).toIntLinearMap instance : Inhabited (DirectLimit G f) := ⟨0⟩ instance [IsEmpty ι] : Unique (DirectLimit G f) := Module.DirectLimit.unique _ _ /-- The canonical map from a component to the direct limit. -/ def of (i) : G i →+ DirectLimit G f := (Module.DirectLimit.of ℤ ι G (fun i j hij => (f i j hij).toIntLinearMap) i).toAddMonoidHom #align add_comm_group.direct_limit.of AddCommGroup.DirectLimit.of variable {G f} @[simp] theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x := Module.DirectLimit.of_f #align add_comm_group.direct_limit.of_f AddCommGroup.DirectLimit.of_f @[elab_as_elim] protected theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop} (z : DirectLimit G f) (ih : ∀ i x, C (of G f i x)) : C z := Module.DirectLimit.induction_on z ih #align add_comm_group.direct_limit.induction_on AddCommGroup.DirectLimit.induction_on /-- A component that corresponds to zero in the direct limit is already zero in some bigger module in the directed system. -/ theorem of.zero_exact [IsDirected ι (· ≤ ·)] [DirectedSystem G fun i j h => f i j h] (i x) (h : of G f i x = 0) : ∃ j hij, f i j hij x = 0 := Module.DirectLimit.of.zero_exact h #align add_comm_group.direct_limit.of.zero_exact AddCommGroup.DirectLimit.of.zero_exact variable (P : Type u₁) [AddCommGroup P] variable (g : ∀ i, G i →+ P) variable (Hg : ∀ i j hij x, g j (f i j hij x) = g i x) variable (G f) /-- The universal property of the direct limit: maps from the components to another abelian group that respect the directed system structure (i.e. make some diagram commute) give rise to a unique map out of the direct limit. -/ def lift : DirectLimit G f →+ P := (Module.DirectLimit.lift ℤ ι G (fun i j hij => (f i j hij).toIntLinearMap) (fun i => (g i).toIntLinearMap) Hg).toAddMonoidHom #align add_comm_group.direct_limit.lift AddCommGroup.DirectLimit.lift variable {G f} @[simp] theorem lift_of (i x) : lift G f P g Hg (of G f i x) = g i x := Module.DirectLimit.lift_of -- Note: had to make these arguments explicit #8386 (f := (fun i j hij => (f i j hij).toIntLinearMap)) (fun i => (g i).toIntLinearMap) Hg x #align add_comm_group.direct_limit.lift_of AddCommGroup.DirectLimit.lift_of theorem lift_unique [IsDirected ι (· ≤ ·)] (F : DirectLimit G f →+ P) (x) : F x = lift G f P (fun i => F.comp (of G f i)) (fun i j hij x => by simp) x := by cases isEmpty_or_nonempty ι · simp_rw [Subsingleton.elim x 0, _root_.map_zero] · exact DirectLimit.induction_on x fun i x => by simp #align add_comm_group.direct_limit.lift_unique AddCommGroup.DirectLimit.lift_unique lemma lift_injective [IsDirected ι (· ≤ ·)] (injective : ∀ i, Function.Injective <| g i) : Function.Injective (lift G f P g Hg) := by cases isEmpty_or_nonempty ι · apply Function.injective_of_subsingleton simp_rw [injective_iff_map_eq_zero] at injective ⊢ intros z hz induction' z using DirectLimit.induction_on with _ g rw [lift_of] at hz rw [injective _ g hz, _root_.map_zero] section functorial variable {G' : ι → Type v'} [∀ i, AddCommGroup (G' i)] variable {f' : ∀ i j, i ≤ j → G' i →+ G' j} variable {G'' : ι → Type v''} [∀ i, AddCommGroup (G'' i)] variable {f'' : ∀ i j, i ≤ j → G'' i →+ G'' j} /-- Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any family of group homomorphisms `gᵢ : Gᵢ ⟶ G'ᵢ` such that `g ∘ f = f' ∘ g` induces a group homomorphism `lim G ⟶ lim G'`. -/ def map (g : (i : ι) → G i →+ G' i) (hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i)) : DirectLimit G f →+ DirectLimit G' f' := lift _ _ _ (fun i ↦ (of _ _ _).comp (g i)) fun i j h g ↦ by cases isEmpty_or_nonempty ι · exact Subsingleton.elim _ _ · have eq1 := DFunLike.congr_fun (hg i j h) g simp only [AddMonoidHom.coe_comp, Function.comp_apply] at eq1 ⊢ rw [eq1, of_f] @[simp] lemma map_apply_of (g : (i : ι) → G i →+ G' i) (hg : ∀ i j h, (g j).comp (f i j h) = (f' i j h).comp (g i)) {i : ι} (x : G i) : map g hg (of G f _ x) = of G' f' i (g i x) := lift_of _ _ _ _ _ @[simp] lemma map_id [IsDirected ι (· ≤ ·)] : map (fun i ↦ AddMonoidHom.id _) (fun _ _ _ ↦ rfl) = AddMonoidHom.id (DirectLimit G f) := DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦ x.induction_on fun i g ↦ by simp lemma map_comp [IsDirected ι (· ≤ ·)] (g₁ : (i : ι) → G i →+ G' i) (g₂ : (i : ι) → G' i →+ G'' i) (hg₁ : ∀ i j h, (g₁ j).comp (f i j h) = (f' i j h).comp (g₁ i)) (hg₂ : ∀ i j h, (g₂ j).comp (f' i j h) = (f'' i j h).comp (g₂ i)) : ((map g₂ hg₂).comp (map g₁ hg₁) : DirectLimit G f →+ DirectLimit G'' f'') = (map (fun i ↦ (g₂ i).comp (g₁ i)) fun i j h ↦ by rw [AddMonoidHom.comp_assoc, hg₁ i, ← AddMonoidHom.comp_assoc, hg₂ i, AddMonoidHom.comp_assoc] : DirectLimit G f →+ DirectLimit G'' f'') := DFunLike.ext _ _ fun x ↦ (isEmpty_or_nonempty ι).elim (fun _ ↦ Subsingleton.elim _ _) fun _ ↦ x.induction_on fun i g ↦ by simp /-- Consider direct limits `lim G` and `lim G'` with direct system `f` and `f'` respectively, any family of equivalences `eᵢ : Gᵢ ≅ G'ᵢ` such that `e ∘ f = f' ∘ e` induces an equivalence `lim G ⟶ lim G'`. -/ def congr [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃+ G' i) (he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i)) : DirectLimit G f ≃+ DirectLimit G' f' := AddMonoidHom.toAddEquiv (map (e ·) he) (map (fun i ↦ (e i).symm) fun i j h ↦ DFunLike.ext _ _ fun x ↦ by have eq1 := DFunLike.congr_fun (he i j h) ((e i).symm x) simp only [AddMonoidHom.coe_comp, AddEquiv.coe_toAddMonoidHom, Function.comp_apply, AddMonoidHom.coe_coe, AddEquiv.apply_symm_apply] at eq1 ⊢ simp [← eq1, of_f]) (by rw [map_comp]; convert map_id <;> aesop) (by rw [map_comp]; convert map_id <;> aesop) lemma congr_apply_of [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃+ G' i) (he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i)) {i : ι} (g : G i) : congr e he (of G f i g) = of G' f' i (e i g) := map_apply_of _ he _ lemma congr_symm_apply_of [IsDirected ι (· ≤ ·)] (e : (i : ι) → G i ≃+ G' i) (he : ∀ i j h, (e j).toAddMonoidHom.comp (f i j h) = (f' i j h).comp (e i)) {i : ι} (g : G' i) : (congr e he).symm (of G' f' i g) = of G f i ((e i).symm g) := by simp only [congr, AddMonoidHom.toAddEquiv_symm_apply, map_apply_of, AddMonoidHom.coe_coe] end functorial end DirectLimit end AddCommGroup namespace Ring variable [∀ i, CommRing (G i)] section variable (f : ∀ i j, i ≤ j → G i → G j) open FreeCommRing /-- The direct limit of a directed system is the rings glued together along the maps. -/ def DirectLimit : Type max v w := FreeCommRing (Σi, G i) ⧸ Ideal.span { a | (∃ i j H x, of (⟨j, f i j H x⟩ : Σi, G i) - of ⟨i, x⟩ = a) ∨ (∃ i, of (⟨i, 1⟩ : Σi, G i) - 1 = a) ∨ (∃ i x y, of (⟨i, x + y⟩ : Σi, G i) - (of ⟨i, x⟩ + of ⟨i, y⟩) = a) ∨ ∃ i x y, of (⟨i, x * y⟩ : Σi, G i) - of ⟨i, x⟩ * of ⟨i, y⟩ = a } #align ring.direct_limit Ring.DirectLimit namespace DirectLimit instance commRing : CommRing (DirectLimit G f) := Ideal.Quotient.commRing _ instance ring : Ring (DirectLimit G f) := CommRing.toRing -- Porting note: Added a `Zero` instance to get rid of `0` errors. instance zero : Zero (DirectLimit G f) := by unfold DirectLimit exact ⟨0⟩ instance : Inhabited (DirectLimit G f) := ⟨0⟩ /-- The canonical map from a component to the direct limit. -/ nonrec def of (i) : G i →+* DirectLimit G f := RingHom.mk' { toFun := fun x => Ideal.Quotient.mk _ (of (⟨i, x⟩ : Σi, G i)) map_one' := Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inl ⟨i, rfl⟩ map_mul' := fun x y => Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inr <| Or.inr ⟨i, x, y, rfl⟩ } fun x y => Ideal.Quotient.eq.2 <| subset_span <| Or.inr <| Or.inr <| Or.inl ⟨i, x, y, rfl⟩ #align ring.direct_limit.of Ring.DirectLimit.of variable {G f} -- Porting note: the @[simp] attribute would trigger a `simpNF` linter error: -- failed to synthesize CommMonoidWithZero (Ring.DirectLimit G f) theorem of_f {i j} (hij) (x) : of G f j (f i j hij x) = of G f i x := Ideal.Quotient.eq.2 <| subset_span <| Or.inl ⟨i, j, hij, x, rfl⟩ #align ring.direct_limit.of_f Ring.DirectLimit.of_f /-- Every element of the direct limit corresponds to some element in some component of the directed system. -/ theorem exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)] (z : DirectLimit G f) : ∃ i x, of G f i x = z := Nonempty.elim (by infer_instance) fun ind : ι => Quotient.inductionOn' z fun x => FreeAbelianGroup.induction_on x ⟨ind, 0, (of _ _ ind).map_zero⟩ (fun s => Multiset.induction_on s ⟨ind, 1, (of _ _ ind).map_one⟩ fun a s ih => let ⟨i, x⟩ := a let ⟨j, y, hs⟩ := ih let ⟨k, hik, hjk⟩ := exists_ge_ge i j ⟨k, f i k hik x * f j k hjk y, by rw [(of G f k).map_mul, of_f, of_f, hs] /- porting note: In Lean3, from here, this was `by refl`. I have added the lemma `FreeCommRing.of_cons` to fix this proof. -/ apply congr_arg Quotient.mk'' symm apply FreeCommRing.of_cons⟩) (fun s ⟨i, x, ih⟩ => ⟨i, -x, by -- Porting note: Lean 3 was `of _ _ _`; Lean 4 is not as good at unification -- here as Lean 3 is, for some reason. rw [(of G f i).map_neg, ih] rfl⟩) fun p q ⟨i, x, ihx⟩ ⟨j, y, ihy⟩ => let ⟨k, hik, hjk⟩ := exists_ge_ge i j ⟨k, f i k hik x + f j k hjk y, by rw [(of _ _ _).map_add, of_f, of_f, ihx, ihy]; rfl⟩ #align ring.direct_limit.exists_of Ring.DirectLimit.exists_of section open scoped Classical open Polynomial variable {f' : ∀ i j, i ≤ j → G i →+* G j} nonrec theorem Polynomial.exists_of [Nonempty ι] [IsDirected ι (· ≤ ·)] (q : Polynomial (DirectLimit G fun i j h => f' i j h)) : ∃ i p, Polynomial.map (of G (fun i j h => f' i j h) i) p = q := Polynomial.induction_on q (fun z => let ⟨i, x, h⟩ := exists_of z ⟨i, C x, by rw [map_C, h]⟩) (fun q₁ q₂ ⟨i₁, p₁, ih₁⟩ ⟨i₂, p₂, ih₂⟩ => let ⟨i, h1, h2⟩ := exists_ge_ge i₁ i₂ ⟨i, p₁.map (f' i₁ i h1) + p₂.map (f' i₂ i h2), by rw [Polynomial.map_add, map_map, map_map, ← ih₁, ← ih₂] congr 2 <;> ext x <;> simp_rw [RingHom.comp_apply, of_f]⟩) fun n z _ => let ⟨i, x, h⟩ := exists_of z ⟨i, C x * X ^ (n + 1), by rw [Polynomial.map_mul, map_C, h, Polynomial.map_pow, map_X]⟩ #align ring.direct_limit.polynomial.exists_of Ring.DirectLimit.Polynomial.exists_of end @[elab_as_elim] theorem induction_on [Nonempty ι] [IsDirected ι (· ≤ ·)] {C : DirectLimit G f → Prop} (z : DirectLimit G f) (ih : ∀ i x, C (of G f i x)) : C z := let ⟨i, x, hx⟩ := exists_of z hx ▸ ih i x #align ring.direct_limit.induction_on Ring.DirectLimit.induction_on section OfZeroExact variable (f' : ∀ i j, i ≤ j → G i →+* G j) variable [DirectedSystem G fun i j h => f' i j h] variable (G f)
Mathlib/Algebra/DirectLimit.lean
664
689
theorem of.zero_exact_aux2 {x : FreeCommRing (Σi, G i)} {s t} [DecidablePred (· ∈ s)] [DecidablePred (· ∈ t)] (hxs : IsSupported x s) {j k} (hj : ∀ z : Σi, G i, z ∈ s → z.1 ≤ j) (hk : ∀ z : Σi, G i, z ∈ t → z.1 ≤ k) (hjk : j ≤ k) (hst : s ⊆ t) : f' j k hjk (lift (fun ix : s => f' ix.1.1 j (hj ix ix.2) ix.1.2) (restriction s x)) = lift (fun ix : t => f' ix.1.1 k (hk ix ix.2) ix.1.2) (restriction t x) := by
refine Subring.InClosure.recOn hxs ?_ ?_ ?_ ?_ · rw [(restriction _).map_one, (FreeCommRing.lift _).map_one, (f' j k hjk).map_one, (restriction _).map_one, (FreeCommRing.lift _).map_one] · -- Porting note: Lean 3 had `(FreeCommRing.lift _).map_neg` but I needed to replace it with -- `RingHom.map_neg` to get the rewrite to compile rw [(restriction _).map_neg, (restriction _).map_one, RingHom.map_neg, (FreeCommRing.lift _).map_one, (f' j k hjk).map_neg, (f' j k hjk).map_one, -- Porting note: similarly here I give strictly less information (restriction _).map_neg, (restriction _).map_one, RingHom.map_neg, (FreeCommRing.lift _).map_one] · rintro _ ⟨p, hps, rfl⟩ n ih rw [(restriction _).map_mul, (FreeCommRing.lift _).map_mul, (f' j k hjk).map_mul, ih, (restriction _).map_mul, (FreeCommRing.lift _).map_mul, restriction_of, dif_pos hps, lift_of, restriction_of, dif_pos (hst hps), lift_of] dsimp only -- Porting note: Lean 3 could get away with far fewer hints for inputs in the line below have := DirectedSystem.map_map (fun i j h => f' i j h) (hj p hps) hjk rw [this] · rintro x y ihx ihy rw [(restriction _).map_add, (FreeCommRing.lift _).map_add, (f' j k hjk).map_add, ihx, ihy, (restriction _).map_add, (FreeCommRing.lift _).map_add]
/- Copyright (c) 2022 Andrew Yang. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Andrew Yang -/ import Mathlib.Algebra.Polynomial.Module.AEval #align_import data.polynomial.module from "leanprover-community/mathlib"@"63417e01fbc711beaf25fa73b6edb395c0cfddd0" /-! # Polynomial module In this file, we define the polynomial module for an `R`-module `M`, i.e. the `R[X]`-module `M[X]`. This is defined as a type alias `PolynomialModule R M := ℕ →₀ M`, since there might be different module structures on `ℕ →₀ M` of interest. See the docstring of `PolynomialModule` for details. -/ universe u v open Polynomial BigOperators /-- The `R[X]`-module `M[X]` for an `R`-module `M`. This is isomorphic (as an `R`-module) to `M[X]` when `M` is a ring. We require all the module instances `Module S (PolynomialModule R M)` to factor through `R` except `Module R[X] (PolynomialModule R M)`. In this constraint, we have the following instances for example : - `R` acts on `PolynomialModule R R[X]` - `R[X]` acts on `PolynomialModule R R[X]` as `R[Y]` acting on `R[X][Y]` - `R` acts on `PolynomialModule R[X] R[X]` - `R[X]` acts on `PolynomialModule R[X] R[X]` as `R[X]` acting on `R[X][Y]` - `R[X][X]` acts on `PolynomialModule R[X] R[X]` as `R[X][Y]` acting on itself This is also the reason why `R` is included in the alias, or else there will be two different instances of `Module R[X] (PolynomialModule R[X])`. See https://leanprover.zulipchat.com/#narrow/stream/144837-PR-reviews/topic/.2315065.20polynomial.20modules for the full discussion. -/ @[nolint unusedArguments] def PolynomialModule (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] := ℕ →₀ M #align polynomial_module PolynomialModule variable (R M : Type*) [CommRing R] [AddCommGroup M] [Module R M] (I : Ideal R) -- Porting note: stated instead of deriving noncomputable instance : Inhabited (PolynomialModule R M) := Finsupp.instInhabited noncomputable instance : AddCommGroup (PolynomialModule R M) := Finsupp.instAddCommGroup variable {M} variable {S : Type*} [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] namespace PolynomialModule /-- This is required to have the `IsScalarTower S R M` instance to avoid diamonds. -/ @[nolint unusedArguments] noncomputable instance : Module S (PolynomialModule R M) := Finsupp.module ℕ M instance instFunLike : FunLike (PolynomialModule R M) ℕ M := Finsupp.instFunLike instance : CoeFun (PolynomialModule R M) fun _ => ℕ → M := Finsupp.instCoeFun theorem zero_apply (i : ℕ) : (0 : PolynomialModule R M) i = 0 := Finsupp.zero_apply theorem add_apply (g₁ g₂ : PolynomialModule R M) (a : ℕ) : (g₁ + g₂) a = g₁ a + g₂ a := Finsupp.add_apply g₁ g₂ a /-- The monomial `m * x ^ i`. This is defeq to `Finsupp.singleAddHom`, and is redefined here so that it has the desired type signature. -/ noncomputable def single (i : ℕ) : M →+ PolynomialModule R M := Finsupp.singleAddHom i #align polynomial_module.single PolynomialModule.single theorem single_apply (i : ℕ) (m : M) (n : ℕ) : single R i m n = ite (i = n) m 0 := Finsupp.single_apply #align polynomial_module.single_apply PolynomialModule.single_apply /-- `PolynomialModule.single` as a linear map. -/ noncomputable def lsingle (i : ℕ) : M →ₗ[R] PolynomialModule R M := Finsupp.lsingle i #align polynomial_module.lsingle PolynomialModule.lsingle theorem lsingle_apply (i : ℕ) (m : M) (n : ℕ) : lsingle R i m n = ite (i = n) m 0 := Finsupp.single_apply #align polynomial_module.lsingle_apply PolynomialModule.lsingle_apply theorem single_smul (i : ℕ) (r : R) (m : M) : single R i (r • m) = r • single R i m := (lsingle R i).map_smul r m #align polynomial_module.single_smul PolynomialModule.single_smul variable {R} theorem induction_linear {P : PolynomialModule R M → Prop} (f : PolynomialModule R M) (h0 : P 0) (hadd : ∀ f g, P f → P g → P (f + g)) (hsingle : ∀ a b, P (single R a b)) : P f := Finsupp.induction_linear f h0 hadd hsingle #align polynomial_module.induction_linear PolynomialModule.induction_linear noncomputable instance polynomialModule : Module R[X] (PolynomialModule R M) := inferInstanceAs (Module R[X] (Module.AEval' (Finsupp.lmapDomain M R Nat.succ))) #align polynomial_module.polynomial_module PolynomialModule.polynomialModule lemma smul_def (f : R[X]) (m : PolynomialModule R M) : f • m = aeval (Finsupp.lmapDomain M R Nat.succ) f m := by rfl instance (M : Type u) [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower S R M] : IsScalarTower S R (PolynomialModule R M) := Finsupp.isScalarTower _ _ instance isScalarTower' (M : Type u) [AddCommGroup M] [Module R M] [Module S M] [IsScalarTower S R M] : IsScalarTower S R[X] (PolynomialModule R M) := by haveI : IsScalarTower R R[X] (PolynomialModule R M) := inferInstanceAs <| IsScalarTower R R[X] <| Module.AEval' <| Finsupp.lmapDomain M R Nat.succ constructor intro x y z rw [← @IsScalarTower.algebraMap_smul S R, ← @IsScalarTower.algebraMap_smul S R, smul_assoc] #align polynomial_module.is_scalar_tower' PolynomialModule.isScalarTower' @[simp] theorem monomial_smul_single (i : ℕ) (r : R) (j : ℕ) (m : M) : monomial i r • single R j m = single R (i + j) (r • m) := by simp only [LinearMap.mul_apply, Polynomial.aeval_monomial, LinearMap.pow_apply, Module.algebraMap_end_apply, smul_def] induction i generalizing r j m with | zero => rw [Function.iterate_zero, zero_add] exact Finsupp.smul_single r j m | succ n hn => rw [Function.iterate_succ, Function.comp_apply, add_assoc, ← hn] congr 2 rw [Nat.one_add] exact Finsupp.mapDomain_single #align polynomial_module.monomial_smul_single PolynomialModule.monomial_smul_single @[simp]
Mathlib/Algebra/Polynomial/Module/Basic.lean
139
153
theorem monomial_smul_apply (i : ℕ) (r : R) (g : PolynomialModule R M) (n : ℕ) : (monomial i r • g) n = ite (i ≤ n) (r • g (n - i)) 0 := by
induction' g using PolynomialModule.induction_linear with p q hp hq · simp only [smul_zero, zero_apply, ite_self] · simp only [smul_add, add_apply, hp, hq] split_ifs exacts [rfl, zero_add 0] · rw [monomial_smul_single, single_apply, single_apply, smul_ite, smul_zero, ← ite_and] congr rw [eq_iff_iff] constructor · rintro rfl simp · rintro ⟨e, rfl⟩ rw [add_comm, tsub_add_cancel_of_le e]
/- Copyright (c) 2020 Devon Tuma. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Devon Tuma -/ import Mathlib.RingTheory.Localization.Away.Basic import Mathlib.RingTheory.Ideal.Over import Mathlib.RingTheory.JacobsonIdeal #align_import ring_theory.jacobson from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0" /-! # Jacobson Rings The following conditions are equivalent for a ring `R`: 1. Every radical ideal `I` is equal to its Jacobson radical 2. Every radical ideal `I` can be written as an intersection of maximal ideals 3. Every prime ideal `I` is equal to its Jacobson radical Any ring satisfying any of these equivalent conditions is said to be Jacobson. Some particular examples of Jacobson rings are also proven. `isJacobson_quotient` says that the quotient of a Jacobson ring is Jacobson. `isJacobson_localization` says the localization of a Jacobson ring to a single element is Jacobson. `isJacobson_polynomial_iff_isJacobson` says polynomials over a Jacobson ring form a Jacobson ring. ## Main definitions Let `R` be a commutative ring. Jacobson rings are defined using the first of the above conditions * `IsJacobson R` is the proposition that `R` is a Jacobson ring. It is a class, implemented as the predicate that for any ideal, `I.isRadical` implies `I.jacobson = I`. ## Main statements * `isJacobson_iff_prime_eq` is the equivalence between conditions 1 and 3 above. * `isJacobson_iff_sInf_maximal` is the equivalence between conditions 1 and 2 above. * `isJacobson_of_surjective` says that if `R` is a Jacobson ring and `f : R →+* S` is surjective, then `S` is also a Jacobson ring * `MvPolynomial.isJacobson` says that multi-variate polynomials over a Jacobson ring are Jacobson. ## Tags Jacobson, Jacobson Ring -/ set_option autoImplicit true universe u namespace Ideal open Polynomial open Polynomial section IsJacobson variable {R S : Type*} [CommRing R] [CommRing S] {I : Ideal R} /-- A ring is a Jacobson ring if for every radical ideal `I`, the Jacobson radical of `I` is equal to `I`. See `isJacobson_iff_prime_eq` and `isJacobson_iff_sInf_maximal` for equivalent definitions. -/ class IsJacobson (R : Type*) [CommRing R] : Prop where out' : ∀ I : Ideal R, I.IsRadical → I.jacobson = I #align ideal.is_jacobson Ideal.IsJacobson theorem isJacobson_iff {R} [CommRing R] : IsJacobson R ↔ ∀ I : Ideal R, I.IsRadical → I.jacobson = I := ⟨fun h => h.1, fun h => ⟨h⟩⟩ #align ideal.is_jacobson_iff Ideal.isJacobson_iff theorem IsJacobson.out {R} [CommRing R] : IsJacobson R → ∀ {I : Ideal R}, I.IsRadical → I.jacobson = I := isJacobson_iff.1 #align ideal.is_jacobson.out Ideal.IsJacobson.out /-- A ring is a Jacobson ring if and only if for all prime ideals `P`, the Jacobson radical of `P` is equal to `P`. -/ theorem isJacobson_iff_prime_eq : IsJacobson R ↔ ∀ P : Ideal R, IsPrime P → P.jacobson = P := by refine isJacobson_iff.trans ⟨fun h I hI => h I hI.isRadical, ?_⟩ refine fun h I hI ↦ le_antisymm (fun x hx ↦ ?_) (fun x hx ↦ mem_sInf.mpr fun _ hJ ↦ hJ.left hx) rw [← hI.radical, radical_eq_sInf I, mem_sInf] intro P hP rw [Set.mem_setOf_eq] at hP erw [mem_sInf] at hx erw [← h P hP.right, mem_sInf] exact fun J hJ => hx ⟨le_trans hP.left hJ.left, hJ.right⟩ #align ideal.is_jacobson_iff_prime_eq Ideal.isJacobson_iff_prime_eq /-- A ring `R` is Jacobson if and only if for every prime ideal `I`, `I` can be written as the infimum of some collection of maximal ideals. Allowing ⊤ in the set `M` of maximal ideals is equivalent, but makes some proofs cleaner. -/ theorem isJacobson_iff_sInf_maximal : IsJacobson R ↔ ∀ {I : Ideal R}, I.IsPrime → ∃ M : Set (Ideal R), (∀ J ∈ M, IsMaximal J ∨ J = ⊤) ∧ I = sInf M := ⟨fun H _I h => eq_jacobson_iff_sInf_maximal.1 (H.out h.isRadical), fun H => isJacobson_iff_prime_eq.2 fun _P hP => eq_jacobson_iff_sInf_maximal.2 (H hP)⟩ #align ideal.is_jacobson_iff_Inf_maximal Ideal.isJacobson_iff_sInf_maximal theorem isJacobson_iff_sInf_maximal' : IsJacobson R ↔ ∀ {I : Ideal R}, I.IsPrime → ∃ M : Set (Ideal R), (∀ J ∈ M, ∀ (K : Ideal R), J < K → K = ⊤) ∧ I = sInf M := ⟨fun H _I h => eq_jacobson_iff_sInf_maximal'.1 (H.out h.isRadical), fun H => isJacobson_iff_prime_eq.2 fun _P hP => eq_jacobson_iff_sInf_maximal'.2 (H hP)⟩ #align ideal.is_jacobson_iff_Inf_maximal' Ideal.isJacobson_iff_sInf_maximal' theorem radical_eq_jacobson [H : IsJacobson R] (I : Ideal R) : I.radical = I.jacobson := le_antisymm (le_sInf fun _J ⟨hJ, hJ_max⟩ => (IsPrime.radical_le_iff hJ_max.isPrime).mpr hJ) (H.out (radical_isRadical I) ▸ jacobson_mono le_radical) #align ideal.radical_eq_jacobson Ideal.radical_eq_jacobson /-- Fields have only two ideals, and the condition holds for both of them. -/ instance (priority := 100) isJacobson_field {K : Type*} [Field K] : IsJacobson K := ⟨fun I _ => Or.recOn (eq_bot_or_top I) (fun h => le_antisymm (sInf_le ⟨le_rfl, h.symm ▸ bot_isMaximal⟩) (h.symm ▸ bot_le)) fun h => by rw [h, jacobson_eq_top_iff]⟩ #align ideal.is_jacobson_field Ideal.isJacobson_field theorem isJacobson_of_surjective [H : IsJacobson R] : (∃ f : R →+* S, Function.Surjective ↑f) → IsJacobson S := by rintro ⟨f, hf⟩ rw [isJacobson_iff_sInf_maximal] intro p hp use map f '' { J : Ideal R | comap f p ≤ J ∧ J.IsMaximal } use fun j ⟨J, hJ, hmap⟩ => hmap ▸ (map_eq_top_or_isMaximal_of_surjective f hf hJ.right).symm have : p = map f (comap f p).jacobson := (IsJacobson.out' _ <| hp.isRadical.comap f).symm ▸ (map_comap_of_surjective f hf p).symm exact this.trans (map_sInf hf fun J ⟨hJ, _⟩ => le_trans (Ideal.ker_le_comap f) hJ) #align ideal.is_jacobson_of_surjective Ideal.isJacobson_of_surjective instance (priority := 100) isJacobson_quotient [IsJacobson R] : IsJacobson (R ⧸ I) := isJacobson_of_surjective ⟨Quotient.mk I, by rintro ⟨x⟩ use x rfl⟩ #align ideal.is_jacobson_quotient Ideal.isJacobson_quotient theorem isJacobson_iso (e : R ≃+* S) : IsJacobson R ↔ IsJacobson S := ⟨fun h => @isJacobson_of_surjective _ _ _ _ h ⟨(e : R →+* S), e.surjective⟩, fun h => @isJacobson_of_surjective _ _ _ _ h ⟨(e.symm : S →+* R), e.symm.surjective⟩⟩ #align ideal.is_jacobson_iso Ideal.isJacobson_iso theorem isJacobson_of_isIntegral [Algebra R S] [Algebra.IsIntegral R S] (hR : IsJacobson R) : IsJacobson S := by rw [isJacobson_iff_prime_eq] intro P hP by_cases hP_top : comap (algebraMap R S) P = ⊤ · simp [comap_eq_top_iff.1 hP_top] · haveI : Nontrivial (R ⧸ comap (algebraMap R S) P) := Quotient.nontrivial hP_top rw [jacobson_eq_iff_jacobson_quotient_eq_bot] refine eq_bot_of_comap_eq_bot (R := R ⧸ comap (algebraMap R S) P) ?_ rw [eq_bot_iff, ← jacobson_eq_iff_jacobson_quotient_eq_bot.1 ((isJacobson_iff_prime_eq.1 hR) (comap (algebraMap R S) P) (comap_isPrime _ _)), comap_jacobson] refine sInf_le_sInf fun J hJ => ?_ simp only [true_and_iff, Set.mem_image, bot_le, Set.mem_setOf_eq] have : J.IsMaximal := by simpa using hJ exact exists_ideal_over_maximal_of_isIntegral J (comap_bot_le_of_injective _ algebraMap_quotient_injective) #align ideal.is_jacobson_of_is_integral Ideal.isJacobson_of_isIntegral theorem isJacobson_of_isIntegral' (f : R →+* S) (hf : f.IsIntegral) (hR : IsJacobson R) : IsJacobson S := let _ : Algebra R S := f.toAlgebra have : Algebra.IsIntegral R S := ⟨hf⟩ isJacobson_of_isIntegral hR #align ideal.is_jacobson_of_is_integral' Ideal.isJacobson_of_isIntegral' end IsJacobson section Localization open IsLocalization Submonoid variable {R S : Type*} [CommRing R] [CommRing S] {I : Ideal R} variable (y : R) [Algebra R S] [IsLocalization.Away y S] variable (S) /-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y` correspond to maximal ideals in the original ring `R` that don't contain `y`. This lemma gives the correspondence in the particular case of an ideal and its comap. See `le_relIso_of_maximal` for the more general relation isomorphism -/ theorem isMaximal_iff_isMaximal_disjoint [H : IsJacobson R] (J : Ideal S) : J.IsMaximal ↔ (comap (algebraMap R S) J).IsMaximal ∧ y ∉ Ideal.comap (algebraMap R S) J := by constructor · refine fun h => ⟨?_, fun hy => h.ne_top (Ideal.eq_top_of_isUnit_mem _ hy (map_units _ ⟨y, Submonoid.mem_powers _⟩))⟩ have hJ : J.IsPrime := IsMaximal.isPrime h rw [isPrime_iff_isPrime_disjoint (Submonoid.powers y)] at hJ have : y ∉ (comap (algebraMap R S) J).1 := Set.disjoint_left.1 hJ.right (Submonoid.mem_powers _) erw [← H.out hJ.left.isRadical, mem_sInf] at this push_neg at this rcases this with ⟨I, hI, hI'⟩ convert hI.right by_cases hJ : J = map (algebraMap R S) I · rw [hJ, comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI.right)] rwa [disjoint_powers_iff_not_mem y hI.right.isPrime.isRadical] · have hI_p : (map (algebraMap R S) I).IsPrime := by refine isPrime_of_isPrime_disjoint (powers y) _ I hI.right.isPrime ?_ rwa [disjoint_powers_iff_not_mem y hI.right.isPrime.isRadical] have : J ≤ map (algebraMap R S) I := map_comap (Submonoid.powers y) S J ▸ map_mono hI.left exact absurd (h.1.2 _ (lt_of_le_of_ne this hJ)) hI_p.1 · refine fun h => ⟨⟨fun hJ => h.1.ne_top (eq_top_iff.2 ?_), fun I hI => ?_⟩⟩ · rwa [eq_top_iff, ← (IsLocalization.orderEmbedding (powers y) S).le_iff_le] at hJ · have := congr_arg (map (algebraMap R S)) (h.1.1.2 _ ⟨comap_mono (le_of_lt hI), ?_⟩) · rwa [map_comap (powers y) S I, map_top] at this refine fun hI' => hI.right ?_ rw [← map_comap (powers y) S I, ← map_comap (powers y) S J] exact map_mono hI' #align ideal.is_maximal_iff_is_maximal_disjoint Ideal.isMaximal_iff_isMaximal_disjoint variable {S} /-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y` correspond to maximal ideals in the original ring `R` that don't contain `y`. This lemma gives the correspondence in the particular case of an ideal and its map. See `le_relIso_of_maximal` for the more general statement, and the reverse of this implication -/ theorem isMaximal_of_isMaximal_disjoint [IsJacobson R] (I : Ideal R) (hI : I.IsMaximal) (hy : y ∉ I) : (map (algebraMap R S) I).IsMaximal := by rw [isMaximal_iff_isMaximal_disjoint S y, comap_map_of_isPrime_disjoint (powers y) S I (IsMaximal.isPrime hI) ((disjoint_powers_iff_not_mem y hI.isPrime.isRadical).2 hy)] exact ⟨hI, hy⟩ #align ideal.is_maximal_of_is_maximal_disjoint Ideal.isMaximal_of_isMaximal_disjoint /-- If `R` is a Jacobson ring, then maximal ideals in the localization at `y` correspond to maximal ideals in the original ring `R` that don't contain `y` -/ def orderIsoOfMaximal [IsJacobson R] : { p : Ideal S // p.IsMaximal } ≃o { p : Ideal R // p.IsMaximal ∧ y ∉ p } where toFun p := ⟨Ideal.comap (algebraMap R S) p.1, (isMaximal_iff_isMaximal_disjoint S y p.1).1 p.2⟩ invFun p := ⟨Ideal.map (algebraMap R S) p.1, isMaximal_of_isMaximal_disjoint y p.1 p.2.1 p.2.2⟩ left_inv J := Subtype.eq (map_comap (powers y) S J) right_inv I := Subtype.eq (comap_map_of_isPrime_disjoint _ _ I.1 (IsMaximal.isPrime I.2.1) ((disjoint_powers_iff_not_mem y I.2.1.isPrime.isRadical).2 I.2.2)) map_rel_iff' {I I'} := ⟨fun h => show I.val ≤ I'.val from map_comap (powers y) S I.val ▸ map_comap (powers y) S I'.val ▸ Ideal.map_mono h, fun h _ hx => h hx⟩ #align ideal.order_iso_of_maximal Ideal.orderIsoOfMaximal /-- If `S` is the localization of the Jacobson ring `R` at the submonoid generated by `y : R`, then `S` is Jacobson. -/ theorem isJacobson_localization [H : IsJacobson R] : IsJacobson S := by rw [isJacobson_iff_prime_eq] refine fun P' hP' => le_antisymm ?_ le_jacobson obtain ⟨hP', hPM⟩ := (IsLocalization.isPrime_iff_isPrime_disjoint (powers y) S P').mp hP' have hP := H.out hP'.isRadical refine (IsLocalization.map_comap (powers y) S P'.jacobson).ge.trans ((map_mono ?_).trans (IsLocalization.map_comap (powers y) S P').le) have : sInf { I : Ideal R | comap (algebraMap R S) P' ≤ I ∧ I.IsMaximal ∧ y ∉ I } ≤ comap (algebraMap R S) P' := by intro x hx have hxy : x * y ∈ (comap (algebraMap R S) P').jacobson := by rw [Ideal.jacobson, mem_sInf] intro J hJ by_cases h : y ∈ J · exact J.mul_mem_left x h · exact J.mul_mem_right y ((mem_sInf.1 hx) ⟨hJ.left, ⟨hJ.right, h⟩⟩) rw [hP] at hxy cases' hP'.mem_or_mem hxy with hxy hxy · exact hxy · exact (hPM.le_bot ⟨Submonoid.mem_powers _, hxy⟩).elim refine le_trans ?_ this rw [Ideal.jacobson, comap_sInf', sInf_eq_iInf] refine iInf_le_iInf_of_subset fun I hI => ⟨map (algebraMap R S) I, ⟨?_, ?_⟩⟩ · exact ⟨le_trans (le_of_eq (IsLocalization.map_comap (powers y) S P').symm) (map_mono hI.1), isMaximal_of_isMaximal_disjoint y _ hI.2.1 hI.2.2⟩ · exact IsLocalization.comap_map_of_isPrime_disjoint _ S I (IsMaximal.isPrime hI.2.1) ((disjoint_powers_iff_not_mem y hI.2.1.isPrime.isRadical).2 hI.2.2) #align ideal.is_jacobson_localization Ideal.isJacobson_localization end Localization namespace Polynomial open Polynomial section CommRing -- Porting note: move to better place -- Porting note: make `S` and `T` universe polymorphic lemma Subring.mem_closure_image_of {S T : Type*} [CommRing S] [CommRing T] (g : S →+* T) (u : Set S) (x : S) (hx : x ∈ Subring.closure u) : g x ∈ Subring.closure (g '' u) := by rw [Subring.mem_closure] at hx ⊢ intro T₁ h₁ rw [← Subring.mem_comap] apply hx simp only [Subring.coe_comap, ← Set.image_subset_iff, SetLike.mem_coe] exact h₁ -- Porting note: move to better place lemma mem_closure_X_union_C {R : Type*} [Ring R] (p : R[X]) : p ∈ Subring.closure (insert X {f | f.degree ≤ 0} : Set R[X]) := by refine Polynomial.induction_on p ?_ ?_ ?_ · intro r apply Subring.subset_closure apply Set.mem_insert_of_mem exact degree_C_le · intros p1 p2 h1 h2 exact Subring.add_mem _ h1 h2 · intros n r hr rw [pow_succ, ← mul_assoc] apply Subring.mul_mem _ hr apply Subring.subset_closure apply Set.mem_insert variable {R S : Type*} [CommRing R] [CommRing S] [IsDomain S] variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] /-- If `I` is a prime ideal of `R[X]` and `pX ∈ I` is a non-constant polynomial, then the map `R →+* R[x]/I` descends to an integral map when localizing at `pX.leadingCoeff`. In particular `X` is integral because it satisfies `pX`, and constants are trivially integral, so integrality of the entire extension follows by closure under addition and multiplication. -/ theorem isIntegral_isLocalization_polynomial_quotient (P : Ideal R[X]) (pX : R[X]) (hpX : pX ∈ P) [Algebra (R ⧸ P.comap (C : R →+* R[X])) Rₘ] [IsLocalization.Away (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff Rₘ] [Algebra (R[X] ⧸ P) Sₘ] [IsLocalization ((Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) : Submonoid (R[X] ⧸ P)) Sₘ] : (IsLocalization.map Sₘ (quotientMap P C le_rfl) (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).le_comap_map : Rₘ →+* Sₘ).IsIntegral := by let P' : Ideal R := P.comap C let M : Submonoid (R ⧸ P') := Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff let M' : Submonoid (R[X] ⧸ P) := (Submonoid.powers (pX.map (Quotient.mk (P.comap (C : R →+* R[X])))).leadingCoeff).map (quotientMap P C le_rfl) let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl let φ' : Rₘ →+* Sₘ := IsLocalization.map Sₘ φ M.le_comap_map have hφ' : φ.comp (Quotient.mk P') = (Quotient.mk P).comp C := rfl intro p obtain ⟨⟨p', ⟨q, hq⟩⟩, hp⟩ := IsLocalization.surj M' p suffices φ'.IsIntegralElem (algebraMap (R[X] ⧸ P) Sₘ p') by obtain ⟨q', hq', rfl⟩ := hq obtain ⟨q'', hq''⟩ := isUnit_iff_exists_inv'.1 (IsLocalization.map_units Rₘ (⟨q', hq'⟩ : M)) refine (hp.symm ▸ this).of_mul_unit φ' p (algebraMap (R[X] ⧸ P) Sₘ (φ q')) q'' ?_ rw [← φ'.map_one, ← congr_arg φ' hq'', φ'.map_mul, ← φ'.comp_apply] simp only [IsLocalization.map_comp _] rw [RingHom.comp_apply] dsimp at hp refine @IsIntegral.of_mem_closure'' Rₘ _ Sₘ _ φ' ((algebraMap (R[X] ⧸ P) Sₘ).comp (Quotient.mk P) '' insert X { p | p.degree ≤ 0 }) ?_ ((algebraMap (R[X] ⧸ P) Sₘ) p') ?_ · rintro x ⟨p, hp, rfl⟩ simp only [Set.mem_insert_iff] at hp cases' hp with hy hy · rw [hy] refine φ.isIntegralElem_localization_at_leadingCoeff ((Quotient.mk P) X) (pX.map (Quotient.mk P')) ?_ M ?_ · rwa [eval₂_map, hφ', ← hom_eval₂, Quotient.eq_zero_iff_mem, eval₂_C_X] · use 1 simp only [pow_one] · rw [Set.mem_setOf_eq, degree_le_zero_iff] at hy -- Porting note: was `refine' hy.symm ▸` -- `⟨X - C (algebraMap _ _ ((Quotient.mk P') (p.coeff 0))), monic_X_sub_C _, _⟩` rw [hy] use X - C (algebraMap (R ⧸ P') Rₘ ((Quotient.mk P') (p.coeff 0))) constructor · apply monic_X_sub_C · simp only [eval₂_sub, eval₂_X, eval₂_C] rw [sub_eq_zero, ← φ'.comp_apply] simp only [IsLocalization.map_comp _] rfl · obtain ⟨p, rfl⟩ := Quotient.mk_surjective p' rw [← RingHom.comp_apply] apply Subring.mem_closure_image_of apply Polynomial.mem_closure_X_union_C #align ideal.polynomial.is_integral_is_localization_polynomial_quotient Ideal.Polynomial.isIntegral_isLocalization_polynomial_quotient /-- If `f : R → S` descends to an integral map in the localization at `x`, and `R` is a Jacobson ring, then the intersection of all maximal ideals in `S` is trivial -/ theorem jacobson_bot_of_integral_localization {R : Type*} [CommRing R] [IsDomain R] [IsJacobson R] (Rₘ Sₘ : Type*) [CommRing Rₘ] [CommRing Sₘ] (φ : R →+* S) (hφ : Function.Injective ↑φ) (x : R) (hx : x ≠ 0) [Algebra R Rₘ] [IsLocalization.Away x Rₘ] [Algebra S Sₘ] [IsLocalization ((Submonoid.powers x).map φ : Submonoid S) Sₘ] (hφ' : RingHom.IsIntegral (IsLocalization.map Sₘ φ (Submonoid.powers x).le_comap_map : Rₘ →+* Sₘ)) : (⊥ : Ideal S).jacobson = (⊥ : Ideal S) := by have hM : ((Submonoid.powers x).map φ : Submonoid S) ≤ nonZeroDivisors S := map_le_nonZeroDivisors_of_injective φ hφ (powers_le_nonZeroDivisors_of_noZeroDivisors hx) letI : IsDomain Sₘ := IsLocalization.isDomain_of_le_nonZeroDivisors _ hM let φ' : Rₘ →+* Sₘ := IsLocalization.map _ φ (Submonoid.powers x).le_comap_map suffices ∀ I : Ideal Sₘ, I.IsMaximal → (I.comap (algebraMap S Sₘ)).IsMaximal by have hϕ' : comap (algebraMap S Sₘ) (⊥ : Ideal Sₘ) = (⊥ : Ideal S) := by rw [← RingHom.ker_eq_comap_bot, ← RingHom.injective_iff_ker_eq_bot] exact IsLocalization.injective Sₘ hM have hSₘ : IsJacobson Sₘ := isJacobson_of_isIntegral' φ' hφ' (isJacobson_localization x) refine eq_bot_iff.mpr (le_trans ?_ (le_of_eq hϕ')) rw [← hSₘ.out isRadical_bot_of_noZeroDivisors, comap_jacobson] exact sInf_le_sInf fun j hj => ⟨bot_le, let ⟨J, hJ⟩ := hj hJ.2 ▸ this J hJ.1.2⟩ intro I hI -- Remainder of the proof is pulling and pushing ideals around the square and the quotient square haveI : (I.comap (algebraMap S Sₘ)).IsPrime := comap_isPrime _ I haveI : (I.comap φ').IsPrime := comap_isPrime φ' I haveI : (⊥ : Ideal (S ⧸ I.comap (algebraMap S Sₘ))).IsPrime := bot_prime have hcomm : φ'.comp (algebraMap R Rₘ) = (algebraMap S Sₘ).comp φ := IsLocalization.map_comp _ let f := quotientMap (I.comap (algebraMap S Sₘ)) φ le_rfl let g := quotientMap I (algebraMap S Sₘ) le_rfl have := isMaximal_comap_of_isIntegral_of_isMaximal' φ' hφ' I have := ((isMaximal_iff_isMaximal_disjoint Rₘ x _).1 this).left have : ((I.comap (algebraMap S Sₘ)).comap φ).IsMaximal := by rwa [comap_comap, hcomm, ← comap_comap] at this rw [← bot_quotient_isMaximal_iff] at this ⊢ refine isMaximal_of_isIntegral_of_isMaximal_comap' f ?_ ⊥ ((eq_bot_iff.2 (comap_bot_le_of_injective f quotientMap_injective)).symm ▸ this) exact RingHom.IsIntegral.tower_bot f g quotientMap_injective ((comp_quotientMap_eq_of_comp_eq hcomm I).symm ▸ (RingHom.isIntegral_of_surjective _ (IsLocalization.surjective_quotientMap_of_maximal_of_localization (Submonoid.powers x) Rₘ (by rwa [comap_comap, hcomm, ← bot_quotient_isMaximal_iff]))).trans _ _ (hφ'.quotient _)) #align ideal.polynomial.jacobson_bot_of_integral_localization Ideal.Polynomial.jacobson_bot_of_integral_localization /-- Used to bootstrap the proof of `isJacobson_polynomial_iff_isJacobson`. That theorem is more general and should be used instead of this one. -/ private theorem isJacobson_polynomial_of_domain (R : Type*) [CommRing R] [IsDomain R] [hR : IsJacobson R] (P : Ideal R[X]) [IsPrime P] (hP : ∀ x : R, C x ∈ P → x = 0) : P.jacobson = P := by by_cases Pb : P = ⊥ · exact Pb.symm ▸ jacobson_bot_polynomial_of_jacobson_bot (hR.out isRadical_bot_of_noZeroDivisors) · rw [jacobson_eq_iff_jacobson_quotient_eq_bot] let P' := P.comap (C : R →+* R[X]) haveI : P'.IsPrime := comap_isPrime C P haveI hR' : IsJacobson (R ⧸ P') := by infer_instance obtain ⟨p, pP, p0⟩ := exists_nonzero_mem_of_ne_bot Pb hP let x := (Polynomial.map (Quotient.mk P') p).leadingCoeff have hx : x ≠ 0 := by rwa [Ne, leadingCoeff_eq_zero] let φ : R ⧸ P' →+* R[X] ⧸ P := Ideal.quotientMap P (C : R →+* R[X]) le_rfl let hφ : Function.Injective ↑φ := quotientMap_injective let Rₘ := Localization.Away x let Sₘ := (Localization ((Submonoid.powers x).map φ : Submonoid (R[X] ⧸ P))) refine jacobson_bot_of_integral_localization (S := R[X] ⧸ P) (R := R ⧸ P') Rₘ Sₘ _ hφ _ hx ?_ haveI islocSₘ : IsLocalization (Submonoid.map φ (Submonoid.powers x)) Sₘ := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ Rₘ Sₘ _ _ P p pP _ _ _ islocSₘ theorem isJacobson_polynomial_of_isJacobson (hR : IsJacobson R) : IsJacobson R[X] := by rw [isJacobson_iff_prime_eq] intro I hI let R' : Subring (R[X] ⧸ I) := ((Quotient.mk I).comp C).range let i : R →+* R' := ((Quotient.mk I).comp C).rangeRestrict have hi : Function.Surjective ↑i := ((Quotient.mk I).comp C).rangeRestrict_surjective have hi' : RingHom.ker (mapRingHom i) ≤ I := by intro f hf apply polynomial_mem_ideal_of_coeff_mem_ideal I f intro n replace hf := congrArg (fun g : Polynomial ((Quotient.mk I).comp C).range => g.coeff n) hf change (Polynomial.map ((Quotient.mk I).comp C).rangeRestrict f).coeff n = 0 at hf rw [coeff_map, Subtype.ext_iff] at hf rwa [mem_comap, ← Quotient.eq_zero_iff_mem, ← RingHom.comp_apply] have R'_jacob : IsJacobson R' := isJacobson_of_surjective ⟨i, hi⟩ let J := map (mapRingHom i) I -- Porting note: moved ↓ this up a few lines, so that it can be used in the `have` have h_surj : Function.Surjective (mapRingHom i) := Polynomial.map_surjective i hi have : IsPrime J := map_isPrime_of_surjective h_surj hi' suffices h : J.jacobson = J by replace h := congrArg (comap (Polynomial.mapRingHom i)) h rw [← map_jacobson_of_surjective h_surj hi', comap_map_of_surjective _ h_surj, comap_map_of_surjective _ h_surj] at h refine le_antisymm ?_ le_jacobson exact le_trans (le_sup_of_le_left le_rfl) (le_trans (le_of_eq h) (sup_le le_rfl hi')) apply isJacobson_polynomial_of_domain R' J exact eq_zero_of_polynomial_mem_map_range I #align ideal.polynomial.is_jacobson_polynomial_of_is_jacobson Ideal.Polynomial.isJacobson_polynomial_of_isJacobson theorem isJacobson_polynomial_iff_isJacobson : IsJacobson R[X] ↔ IsJacobson R := by refine ⟨?_, isJacobson_polynomial_of_isJacobson⟩ intro H exact isJacobson_of_surjective ⟨eval₂RingHom (RingHom.id _) 1, fun x => ⟨C x, by simp only [coe_eval₂RingHom, RingHom.id_apply, eval₂_C]⟩⟩ #align ideal.polynomial.is_jacobson_polynomial_iff_is_jacobson Ideal.Polynomial.isJacobson_polynomial_iff_isJacobson instance [IsJacobson R] : IsJacobson R[X] := isJacobson_polynomial_iff_isJacobson.mpr ‹IsJacobson R› end CommRing section variable {R : Type*} [CommRing R] [IsJacobson R] variable (P : Ideal R[X]) [hP : P.IsMaximal] theorem isMaximal_comap_C_of_isMaximal [Nontrivial R] (hP' : ∀ x : R, C x ∈ P → x = 0) : IsMaximal (comap (C : R →+* R[X]) P : Ideal R) := by let P' := comap (C : R →+* R[X]) P haveI hP'_prime : P'.IsPrime := comap_isPrime C P obtain ⟨⟨m, hmem_P⟩, hm⟩ := Submodule.nonzero_mem_of_bot_lt (bot_lt_of_maximal P polynomial_not_isField) have hm' : m ≠ 0 := by simpa [Submodule.coe_eq_zero] using hm let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P (C : R →+* R[X]) le_rfl let a : R ⧸ P' := (m.map (Quotient.mk P')).leadingCoeff let M : Submonoid (R ⧸ P') := Submonoid.powers a rw [← bot_quotient_isMaximal_iff] have hp0 : a ≠ 0 := fun hp0' => hm' <| map_injective (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R)) ((injective_iff_map_eq_zero (Quotient.mk (P.comap (C : R →+* R[X]) : Ideal R))).2 fun x hx => by rwa [Quotient.eq_zero_iff_mem, (by rwa [eq_bot_iff] : (P.comap C : Ideal R) = ⊥)] at hx) (by simpa only [a, leadingCoeff_eq_zero, Polynomial.map_zero] using hp0') have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 (pow_eq_zero hn) suffices (⊥ : Ideal (Localization M)).IsMaximal by rw [← IsLocalization.comap_map_of_isPrime_disjoint M (Localization M) ⊥ bot_prime (disjoint_iff_inf_le.mpr fun x hx => hM (hx.2 ▸ hx.1))] exact ((isMaximal_iff_isMaximal_disjoint (Localization M) a _).mp (by rwa [map_bot])).1 let M' : Submonoid (R[X] ⧸ P) := M.map φ have hM' : (0 : R[X] ⧸ P) ∉ M' := fun ⟨z, hz⟩ => hM (quotientMap_injective (_root_.trans hz.2 φ.map_zero.symm) ▸ hz.1) haveI : IsDomain (Localization M') := IsLocalization.isDomain_localization (le_nonZeroDivisors_of_noZeroDivisors hM') suffices (⊥ : Ideal (Localization M')).IsMaximal by rw [le_antisymm bot_le (comap_bot_le_of_injective _ (IsLocalization.map_injective_of_injective M (Localization M) (Localization M') quotientMap_injective))] refine isMaximal_comap_of_isIntegral_of_isMaximal' _ ?_ ⊥ have isloc : IsLocalization (Submonoid.map φ M) (Localization M') := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P m hmem_P _ _ _ isloc rw [(map_bot.symm : (⊥ : Ideal (Localization M')) = map (algebraMap (R[X] ⧸ P) (Localization M')) ⊥)] let bot_maximal := (bot_quotient_isMaximal_iff _).mpr hP refine map.isMaximal (algebraMap (R[X] ⧸ P) (Localization M')) ?_ bot_maximal apply IsField.localization_map_bijective hM' rwa [← Quotient.maximal_ideal_iff_isField_quotient, ← bot_quotient_isMaximal_iff] set_option linter.uppercaseLean3 false in #align ideal.polynomial.is_maximal_comap_C_of_is_maximal Ideal.Polynomial.isMaximal_comap_C_of_isMaximal /-- Used to bootstrap the more general `quotient_mk_comp_C_isIntegral_of_jacobson` -/ private theorem quotient_mk_comp_C_isIntegral_of_jacobson' [Nontrivial R] (hR : IsJacobson R) (hP' : ∀ x : R, C x ∈ P → x = 0) : ((Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by refine (isIntegral_quotientMap_iff _).mp ?_ let P' : Ideal R := P.comap C obtain ⟨pX, hpX, hp0⟩ := exists_nonzero_mem_of_ne_bot (ne_of_lt (bot_lt_of_maximal P polynomial_not_isField)).symm hP' let a : R ⧸ P' := (pX.map (Quotient.mk P')).leadingCoeff let M : Submonoid (R ⧸ P') := Submonoid.powers a let φ : R ⧸ P' →+* R[X] ⧸ P := quotientMap P C le_rfl haveI hP'_prime : P'.IsPrime := comap_isPrime C P have hM : (0 : R ⧸ P') ∉ M := fun ⟨n, hn⟩ => hp0 <| leadingCoeff_eq_zero.mp (pow_eq_zero hn) let M' : Submonoid (R[X] ⧸ P) := M.map φ refine RingHom.IsIntegral.tower_bot φ (algebraMap _ (Localization M')) ?_ ?_ · refine IsLocalization.injective (Localization M') (show M' ≤ _ from le_nonZeroDivisors_of_noZeroDivisors fun hM' => hM ?_) exact let ⟨z, zM, z0⟩ := hM' quotientMap_injective (_root_.trans z0 φ.map_zero.symm) ▸ zM · suffices RingHom.comp (algebraMap (R[X] ⧸ P) (Localization M')) φ = (IsLocalization.map (Localization M') φ M.le_comap_map).comp (algebraMap (R ⧸ P') (Localization M)) by rw [this] refine RingHom.IsIntegral.trans (algebraMap (R ⧸ P') (Localization M)) (IsLocalization.map (Localization M') φ M.le_comap_map) ?_ ?_ · exact (algebraMap (R ⧸ P') (Localization M)).isIntegral_of_surjective (IsField.localization_map_bijective hM ((Quotient.maximal_ideal_iff_isField_quotient _).mp (isMaximal_comap_C_of_isMaximal P hP'))).2 · -- `convert` here is faster than `exact`, and this proof is near the time limit. -- convert isIntegral_isLocalization_polynomial_quotient P pX hpX have isloc : IsLocalization M' (Localization M') := by infer_instance exact @isIntegral_isLocalization_polynomial_quotient R _ (Localization M) (Localization M') _ _ P pX hpX _ _ _ isloc rw [IsLocalization.map_comp M.le_comap_map] /-- If `R` is a Jacobson ring, and `P` is a maximal ideal of `R[X]`, then `R → R[X]/P` is an integral map. -/ theorem quotient_mk_comp_C_isIntegral_of_jacobson : ((Quotient.mk P).comp C : R →+* R[X] ⧸ P).IsIntegral := by let P' : Ideal R := P.comap C haveI : P'.IsPrime := comap_isPrime C P let f : R[X] →+* Polynomial (R ⧸ P') := Polynomial.mapRingHom (Quotient.mk P') have hf : Function.Surjective ↑f := map_surjective (Quotient.mk P') Quotient.mk_surjective have hPJ : P = (P.map f).comap f := by rw [comap_map_of_surjective _ hf] refine le_antisymm (le_sup_of_le_left le_rfl) (sup_le le_rfl ?_) refine fun p hp => polynomial_mem_ideal_of_coeff_mem_ideal P p fun n => Quotient.eq_zero_iff_mem.mp ?_ simpa only [f, coeff_map, coe_mapRingHom] using (Polynomial.ext_iff.mp hp) n refine RingHom.IsIntegral.tower_bot _ _ (injective_quotient_le_comap_map P) ?_ rw [← quotient_mk_maps_eq] refine ((Quotient.mk P').isIntegral_of_surjective Quotient.mk_surjective).trans _ _ ?_ have : IsMaximal (map (mapRingHom (Quotient.mk (comap C P))) P) := Or.recOn (map_eq_top_or_isMaximal_of_surjective f hf hP) (fun h => absurd (_root_.trans (h ▸ hPJ : P = comap f ⊤) comap_top : P = ⊤) hP.ne_top) id apply quotient_mk_comp_C_isIntegral_of_jacobson' _ ?_ (fun x hx => ?_) any_goals exact Ideal.isJacobson_quotient obtain ⟨z, rfl⟩ := Quotient.mk_surjective x rwa [Quotient.eq_zero_iff_mem, mem_comap, hPJ, mem_comap, coe_mapRingHom, map_C] set_option linter.uppercaseLean3 false in #align ideal.polynomial.quotient_mk_comp_C_is_integral_of_jacobson Ideal.Polynomial.quotient_mk_comp_C_isIntegral_of_jacobson theorem isMaximal_comap_C_of_isJacobson : (P.comap (C : R →+* R[X])).IsMaximal := by rw [← @mk_ker _ _ P, RingHom.ker_eq_comap_bot, comap_comap] have := (bot_quotient_isMaximal_iff _).mpr hP exact isMaximal_comap_of_isIntegral_of_isMaximal' _ (quotient_mk_comp_C_isIntegral_of_jacobson P) ⊥ set_option linter.uppercaseLean3 false in #align ideal.polynomial.is_maximal_comap_C_of_is_jacobson Ideal.Polynomial.isMaximal_comap_C_of_isJacobson lemma isMaximal_comap_C_of_isJacobson' {P : Ideal R[X]} (hP : IsMaximal P) : (P.comap (C : R →+* R[X])).IsMaximal := by haveI := hP exact isMaximal_comap_C_of_isJacobson P
Mathlib/RingTheory/Jacobson.lean
592
602
theorem comp_C_integral_of_surjective_of_jacobson {S : Type*} [Field S] (f : R[X] →+* S) (hf : Function.Surjective ↑f) : (f.comp C).IsIntegral := by
haveI : f.ker.IsMaximal := RingHom.ker_isMaximal_of_surjective f hf let g : R[X] ⧸ (RingHom.ker f) →+* S := Ideal.Quotient.lift (RingHom.ker f) f fun _ h => h have hfg : g.comp (Quotient.mk (RingHom.ker f)) = f := ringHom_ext' rfl rfl rw [← hfg, RingHom.comp_assoc] refine (quotient_mk_comp_C_isIntegral_of_jacobson (RingHom.ker f)).trans _ g (g.isIntegral_of_surjective ?_) rw [← hfg] at hf norm_num at hf exact Function.Surjective.of_comp hf
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro -/ import Mathlib.Algebra.MvPolynomial.Degrees #align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Variables of polynomials This file establishes many results about the variable sets of a multivariate polynomial. The *variable set* of a polynomial $P \in R[X]$ is a `Finset` containing each $x \in X$ that appears in a monomial in $P$. ## Main declarations * `MvPolynomial.vars p` : the finset of variables occurring in `p`. For example if `p = x⁴y+yz` then `vars p = {x, y, z}` ## Notation As in other polynomial files, we typically use the notation: + `σ τ : Type*` (indexing the variables) + `R : Type*` `[CommSemiring R]` (the coefficients) + `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set. This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s` + `r : R` + `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians + `p : MvPolynomial σ R` -/ noncomputable section open Set Function Finsupp AddMonoidAlgebra universe u v w variable {R : Type u} {S : Type v} namespace MvPolynomial variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ} section CommSemiring variable [CommSemiring R] {p q : MvPolynomial σ R} section Vars /-! ### `vars` -/ /-- `vars p` is the set of variables appearing in the polynomial `p` -/ def vars (p : MvPolynomial σ R) : Finset σ := letI := Classical.decEq σ p.degrees.toFinset #align mv_polynomial.vars MvPolynomial.vars theorem vars_def [DecidableEq σ] (p : MvPolynomial σ R) : p.vars = p.degrees.toFinset := by rw [vars] convert rfl #align mv_polynomial.vars_def MvPolynomial.vars_def @[simp] theorem vars_0 : (0 : MvPolynomial σ R).vars = ∅ := by classical rw [vars_def, degrees_zero, Multiset.toFinset_zero] #align mv_polynomial.vars_0 MvPolynomial.vars_0 @[simp] theorem vars_monomial (h : r ≠ 0) : (monomial s r).vars = s.support := by classical rw [vars_def, degrees_monomial_eq _ _ h, Finsupp.toFinset_toMultiset] #align mv_polynomial.vars_monomial MvPolynomial.vars_monomial @[simp] theorem vars_C : (C r : MvPolynomial σ R).vars = ∅ := by classical rw [vars_def, degrees_C, Multiset.toFinset_zero] set_option linter.uppercaseLean3 false in #align mv_polynomial.vars_C MvPolynomial.vars_C @[simp] theorem vars_X [Nontrivial R] : (X n : MvPolynomial σ R).vars = {n} := by rw [X, vars_monomial (one_ne_zero' R), Finsupp.support_single_ne_zero _ (one_ne_zero' ℕ)] set_option linter.uppercaseLean3 false in #align mv_polynomial.vars_X MvPolynomial.vars_X theorem mem_vars (i : σ) : i ∈ p.vars ↔ ∃ d ∈ p.support, i ∈ d.support := by classical simp only [vars_def, Multiset.mem_toFinset, mem_degrees, mem_support_iff, exists_prop] #align mv_polynomial.mem_vars MvPolynomial.mem_vars theorem mem_support_not_mem_vars_zero {f : MvPolynomial σ R} {x : σ →₀ ℕ} (H : x ∈ f.support) {v : σ} (h : v ∉ vars f) : x v = 0 := by contrapose! h exact (mem_vars v).mpr ⟨x, H, Finsupp.mem_support_iff.mpr h⟩ #align mv_polynomial.mem_support_not_mem_vars_zero MvPolynomial.mem_support_not_mem_vars_zero theorem vars_add_subset [DecidableEq σ] (p q : MvPolynomial σ R) : (p + q).vars ⊆ p.vars ∪ q.vars := by intro x hx simp only [vars_def, Finset.mem_union, Multiset.mem_toFinset] at hx ⊢ simpa using Multiset.mem_of_le (degrees_add _ _) hx #align mv_polynomial.vars_add_subset MvPolynomial.vars_add_subset theorem vars_add_of_disjoint [DecidableEq σ] (h : Disjoint p.vars q.vars) : (p + q).vars = p.vars ∪ q.vars := by refine (vars_add_subset p q).antisymm fun x hx => ?_ simp only [vars_def, Multiset.disjoint_toFinset] at h hx ⊢ rwa [degrees_add_of_disjoint h, Multiset.toFinset_union] #align mv_polynomial.vars_add_of_disjoint MvPolynomial.vars_add_of_disjoint section Mul theorem vars_mul [DecidableEq σ] (φ ψ : MvPolynomial σ R) : (φ * ψ).vars ⊆ φ.vars ∪ ψ.vars := by simp_rw [vars_def, ← Multiset.toFinset_add, Multiset.toFinset_subset] exact Multiset.subset_of_le (degrees_mul φ ψ) #align mv_polynomial.vars_mul MvPolynomial.vars_mul @[simp] theorem vars_one : (1 : MvPolynomial σ R).vars = ∅ := vars_C #align mv_polynomial.vars_one MvPolynomial.vars_one theorem vars_pow (φ : MvPolynomial σ R) (n : ℕ) : (φ ^ n).vars ⊆ φ.vars := by classical induction' n with n ih · simp · rw [pow_succ'] apply Finset.Subset.trans (vars_mul _ _) exact Finset.union_subset (Finset.Subset.refl _) ih #align mv_polynomial.vars_pow MvPolynomial.vars_pow /-- The variables of the product of a family of polynomials are a subset of the union of the sets of variables of each polynomial. -/ theorem vars_prod {ι : Type*} [DecidableEq σ] {s : Finset ι} (f : ι → MvPolynomial σ R) : (∏ i ∈ s, f i).vars ⊆ s.biUnion fun i => (f i).vars := by classical induction s using Finset.induction_on with | empty => simp | insert hs hsub => simp only [hs, Finset.biUnion_insert, Finset.prod_insert, not_false_iff] apply Finset.Subset.trans (vars_mul _ _) exact Finset.union_subset_union (Finset.Subset.refl _) hsub #align mv_polynomial.vars_prod MvPolynomial.vars_prod section IsDomain variable {A : Type*} [CommRing A] [IsDomain A] theorem vars_C_mul (a : A) (ha : a ≠ 0) (φ : MvPolynomial σ A) : (C a * φ : MvPolynomial σ A).vars = φ.vars := by ext1 i simp only [mem_vars, exists_prop, mem_support_iff] apply exists_congr intro d apply and_congr _ Iff.rfl rw [coeff_C_mul, mul_ne_zero_iff, eq_true ha, true_and_iff] set_option linter.uppercaseLean3 false in #align mv_polynomial.vars_C_mul MvPolynomial.vars_C_mul end IsDomain end Mul section Sum variable {ι : Type*} (t : Finset ι) (φ : ι → MvPolynomial σ R) theorem vars_sum_subset [DecidableEq σ] : (∑ i ∈ t, φ i).vars ⊆ Finset.biUnion t fun i => (φ i).vars := by classical induction t using Finset.induction_on with | empty => simp | insert has hsum => rw [Finset.biUnion_insert, Finset.sum_insert has] refine Finset.Subset.trans (vars_add_subset _ _) (Finset.union_subset_union (Finset.Subset.refl _) ?_) assumption #align mv_polynomial.vars_sum_subset MvPolynomial.vars_sum_subset theorem vars_sum_of_disjoint [DecidableEq σ] (h : Pairwise <| (Disjoint on fun i => (φ i).vars)) : (∑ i ∈ t, φ i).vars = Finset.biUnion t fun i => (φ i).vars := by classical induction t using Finset.induction_on with | empty => simp | insert has hsum => rw [Finset.biUnion_insert, Finset.sum_insert has, vars_add_of_disjoint, hsum] unfold Pairwise onFun at h rw [hsum] simp only [Finset.disjoint_iff_ne] at h ⊢ intro v hv v2 hv2 rw [Finset.mem_biUnion] at hv2 rcases hv2 with ⟨i, his, hi⟩ refine h ?_ _ hv _ hi rintro rfl contradiction #align mv_polynomial.vars_sum_of_disjoint MvPolynomial.vars_sum_of_disjoint end Sum section Map variable [CommSemiring S] (f : R →+* S) variable (p) theorem vars_map : (map f p).vars ⊆ p.vars := by classical simp [vars_def, degrees_map] #align mv_polynomial.vars_map MvPolynomial.vars_map variable {f} theorem vars_map_of_injective (hf : Injective f) : (map f p).vars = p.vars := by simp [vars, degrees_map_of_injective _ hf] #align mv_polynomial.vars_map_of_injective MvPolynomial.vars_map_of_injective
Mathlib/Algebra/MvPolynomial/Variables.lean
226
228
theorem vars_monomial_single (i : σ) {e : ℕ} {r : R} (he : e ≠ 0) (hr : r ≠ 0) : (monomial (Finsupp.single i e) r).vars = {i} := by
rw [vars_monomial hr, Finsupp.support_single_ne_zero _ he]
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Yury Kudryashov -/ import Mathlib.FieldTheory.Perfect #align_import field_theory.perfect_closure from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a" /-! # The perfect closure of a characteristic `p` ring ## Main definitions - `PerfectClosure`: the perfect closure of a characteristic `p` ring, which is the smallest extension that makes frobenius surjective. - `PerfectClosure.mk K p (n, x)`: for `n : ℕ` and `x : K` this is `x ^ (p ^ -n)` viewed as an element of `PerfectClosure K p`. Every element of `PerfectClosure K p` is of this form (`PerfectClosure.mk_surjective`). - `PerfectClosure.of`: the structure map from `K` to `PerfectClosure K p`. - `PerfectClosure.lift`: given a ring `K` of characteristic `p` and a perfect ring `L` of the same characteristic, any homomorphism `K →+* L` can be lifted to `PerfectClosure K p`. ## Main results - `PerfectClosure.induction_on`: to prove a result for all elements of the prefect closure, one only needs to prove it for all elements of the form `x ^ (p ^ -n)`. - `PerfectClosure.mk_mul_mk`, `PerfectClosure.one_def`, `PerfectClosure.mk_add_mk`, `PerfectClosure.neg_mk`, `PerfectClosure.zero_def`, `PerfectClosure.mk_zero_zero`, `PerfectClosure.mk_zero`, `PerfectClosure.mk_inv`, `PerfectClosure.mk_pow`: how to do multiplication, addition, etc. on elements of form `x ^ (p ^ -n)`. - `PerfectClosure.mk_eq_iff`: when does `x ^ (p ^ -n)` equal. - `PerfectClosure.eq_iff`: same as `PerfectClosure.mk_eq_iff` but with additional assumption that `K` being reduced, hence gives a simpler criterion. - `PerfectClosure.instPerfectRing`: `PerfectClosure K p` is a perfect ring. ## Tags perfect ring, perfect closure -/ universe u v open Function section variable (K : Type u) [CommRing K] (p : ℕ) [Fact p.Prime] [CharP K p] /-- `PerfectClosure.R` is the relation `(n, x) ∼ (n + 1, x ^ p)` for `n : ℕ` and `x : K`. `PerfectClosure K p` is the quotient by this relation. -/ @[mk_iff] inductive PerfectClosure.R : ℕ × K → ℕ × K → Prop | intro : ∀ n x, PerfectClosure.R (n, x) (n + 1, frobenius K p x) #align perfect_closure.r PerfectClosure.R /-- The perfect closure is the smallest extension that makes frobenius surjective. -/ def PerfectClosure : Type u := Quot (PerfectClosure.R K p) #align perfect_closure PerfectClosure end namespace PerfectClosure variable (K : Type u) section Ring variable [CommRing K] (p : ℕ) [Fact p.Prime] [CharP K p] /-- `PerfectClosure.mk K p (n, x)` for `n : ℕ` and `x : K` is an element of `PerfectClosure K p`, viewed as `x ^ (p ^ -n)`. Every element of `PerfectClosure K p` is of this form (`PerfectClosure.mk_surjective`). -/ def mk (x : ℕ × K) : PerfectClosure K p := Quot.mk (R K p) x #align perfect_closure.mk PerfectClosure.mk theorem mk_surjective : Function.Surjective (mk K p) := surjective_quot_mk _ @[simp] theorem mk_succ_pow (m : ℕ) (x : K) : mk K p ⟨m + 1, x ^ p⟩ = mk K p ⟨m, x⟩ := Eq.symm <| Quot.sound (R.intro m x) @[simp] theorem quot_mk_eq_mk (x : ℕ × K) : (Quot.mk (R K p) x : PerfectClosure K p) = mk K p x := rfl #align perfect_closure.quot_mk_eq_mk PerfectClosure.quot_mk_eq_mk variable {K p} /-- Lift a function `ℕ × K → L` to a function on `PerfectClosure K p`. -/ -- Porting note: removed `@[elab_as_elim]` for "unexpected eliminator resulting type L" def liftOn {L : Type*} (x : PerfectClosure K p) (f : ℕ × K → L) (hf : ∀ x y, R K p x y → f x = f y) : L := Quot.liftOn x f hf #align perfect_closure.lift_on PerfectClosure.liftOn @[simp] theorem liftOn_mk {L : Sort _} (f : ℕ × K → L) (hf : ∀ x y, R K p x y → f x = f y) (x : ℕ × K) : (mk K p x).liftOn f hf = f x := rfl #align perfect_closure.lift_on_mk PerfectClosure.liftOn_mk @[elab_as_elim] theorem induction_on (x : PerfectClosure K p) {q : PerfectClosure K p → Prop} (h : ∀ x, q (mk K p x)) : q x := Quot.inductionOn x h #align perfect_closure.induction_on PerfectClosure.induction_on variable (K p) private theorem mul_aux_left (x1 x2 y : ℕ × K) (H : R K p x1 x2) : mk K p (x1.1 + y.1, (frobenius K p)^[y.1] x1.2 * (frobenius K p)^[x1.1] y.2) = mk K p (x2.1 + y.1, (frobenius K p)^[y.1] x2.2 * (frobenius K p)^[x2.1] y.2) := match x1, x2, H with | _, _, R.intro n x => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← frobenius_mul, Nat.succ_add] apply R.intro private theorem mul_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : mk K p (x.1 + y1.1, (frobenius K p)^[y1.1] x.2 * (frobenius K p)^[x.1] y1.2) = mk K p (x.1 + y2.1, (frobenius K p)^[y2.1] x.2 * (frobenius K p)^[x.1] y2.2) := match y1, y2, H with | _, _, R.intro n y => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← frobenius_mul] apply R.intro instance instMul : Mul (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 * (frobenius K p)^[x.1] y.2)) (mul_aux_right K p x)) fun x1 x2 (H : R K p x1 x2) => funext fun e => Quot.inductionOn e fun y => mul_aux_left K p x1 x2 y H⟩ @[simp] theorem mk_mul_mk (x y : ℕ × K) : mk K p x * mk K p y = mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 * (frobenius K p)^[x.1] y.2) := rfl #align perfect_closure.mk_mul_mk PerfectClosure.mk_mul_mk instance instCommMonoid : CommMonoid (PerfectClosure K p) := { (inferInstance : Mul (PerfectClosure K p)) with mul_assoc := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_mul_mk] -- Porting note: added this line apply congr_arg (Quot.mk _) simp only [add_assoc, mul_assoc, iterate_map_mul, ← iterate_add_apply, add_comm, add_left_comm] one := mk K p (0, 1) one_mul := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_one, iterate_zero_apply, one_mul, zero_add] mul_one := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_one, iterate_zero_apply, mul_one, add_zero] mul_comm := fun e f => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => congr_arg (Quot.mk _) <| by simp only [add_comm, mul_comm] } theorem one_def : (1 : PerfectClosure K p) = mk K p (0, 1) := rfl #align perfect_closure.one_def PerfectClosure.one_def instance instInhabited : Inhabited (PerfectClosure K p) := ⟨1⟩ private theorem add_aux_left (x1 x2 y : ℕ × K) (H : R K p x1 x2) : mk K p (x1.1 + y.1, (frobenius K p)^[y.1] x1.2 + (frobenius K p)^[x1.1] y.2) = mk K p (x2.1 + y.1, (frobenius K p)^[y.1] x2.2 + (frobenius K p)^[x2.1] y.2) := match x1, x2, H with | _, _, R.intro n x => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← frobenius_add, Nat.succ_add] apply R.intro private theorem add_aux_right (x y1 y2 : ℕ × K) (H : R K p y1 y2) : mk K p (x.1 + y1.1, (frobenius K p)^[y1.1] x.2 + (frobenius K p)^[x.1] y1.2) = mk K p (x.1 + y2.1, (frobenius K p)^[y2.1] x.2 + (frobenius K p)^[x.1] y2.2) := match y1, y2, H with | _, _, R.intro n y => Quot.sound <| by rw [← iterate_succ_apply, iterate_succ_apply', iterate_succ_apply', ← frobenius_add] apply R.intro instance instAdd : Add (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => Quot.lift (fun y : ℕ × K => mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 + (frobenius K p)^[x.1] y.2)) (add_aux_right K p x)) fun x1 x2 (H : R K p x1 x2) => funext fun e => Quot.inductionOn e fun y => add_aux_left K p x1 x2 y H⟩ @[simp] theorem mk_add_mk (x y : ℕ × K) : mk K p x + mk K p y = mk K p (x.1 + y.1, (frobenius K p)^[y.1] x.2 + (frobenius K p)^[x.1] y.2) := rfl #align perfect_closure.mk_add_mk PerfectClosure.mk_add_mk instance instNeg : Neg (PerfectClosure K p) := ⟨Quot.lift (fun x : ℕ × K => mk K p (x.1, -x.2)) fun x y (H : R K p x y) => match x, y, H with | _, _, R.intro n x => Quot.sound <| by rw [← frobenius_neg]; apply R.intro⟩ @[simp] theorem neg_mk (x : ℕ × K) : -mk K p x = mk K p (x.1, -x.2) := rfl #align perfect_closure.neg_mk PerfectClosure.neg_mk instance instZero : Zero (PerfectClosure K p) := ⟨mk K p (0, 0)⟩ theorem zero_def : (0 : PerfectClosure K p) = mk K p (0, 0) := rfl #align perfect_closure.zero_def PerfectClosure.zero_def @[simp] theorem mk_zero_zero : mk K p (0, 0) = 0 := rfl #align perfect_closure.mk_zero_zero PerfectClosure.mk_zero_zero -- Porting note: improved proof structure theorem mk_zero (n : ℕ) : mk K p (n, 0) = 0 := by induction' n with n ih · rfl rw [← ih] symm apply Quot.sound have := R.intro (p := p) n (0 : K) rwa [frobenius_zero K p] at this #align perfect_closure.mk_zero PerfectClosure.mk_zero -- Porting note: improved proof structure theorem R.sound (m n : ℕ) (x y : K) (H : (frobenius K p)^[m] x = y) : mk K p (n, x) = mk K p (m + n, y) := by subst H induction' m with m ih · simp only [Nat.zero_eq, zero_add, iterate_zero_apply] rw [ih, Nat.succ_add, iterate_succ'] apply Quot.sound apply R.intro #align perfect_closure.r.sound PerfectClosure.R.sound instance instAddCommGroup : AddCommGroup (PerfectClosure K p) := { (inferInstance : Add (PerfectClosure K p)), (inferInstance : Neg (PerfectClosure K p)) with add_assoc := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_add_mk] -- Porting note: added this line apply congr_arg (Quot.mk _) simp only [iterate_map_add, ← iterate_add_apply, add_assoc, add_comm s _] zero := 0 zero_add := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_zero, iterate_zero_apply, zero_add] add_zero := fun e => Quot.inductionOn e fun ⟨n, x⟩ => congr_arg (Quot.mk _) <| by simp only [iterate_map_zero, iterate_zero_apply, add_zero] sub_eq_add_neg := fun a b => rfl add_left_neg := fun e => Quot.inductionOn e fun ⟨n, x⟩ => by simp only [quot_mk_eq_mk, neg_mk, mk_add_mk, iterate_map_neg, add_left_neg, mk_zero] add_comm := fun e f => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => congr_arg (Quot.mk _) <| by simp only [add_comm] nsmul := nsmulRec zsmul := zsmulRec } instance instCommRing : CommRing (PerfectClosure K p) := { instAddCommGroup K p, AddMonoidWithOne.unary, (inferInstance : CommMonoid (PerfectClosure K p)) with -- Porting note: added `zero_mul`, `mul_zero` zero_mul := fun a => by refine Quot.inductionOn a fun ⟨m, x⟩ => ?_ rw [zero_def, quot_mk_eq_mk, mk_mul_mk] simp only [zero_add, iterate_zero, id_eq, iterate_map_zero, zero_mul, mk_zero] mul_zero := fun a => by refine Quot.inductionOn a fun ⟨m, x⟩ => ?_ rw [zero_def, quot_mk_eq_mk, mk_mul_mk] simp only [zero_add, iterate_zero, id_eq, iterate_map_zero, mul_zero, mk_zero] left_distrib := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_add_mk, mk_mul_mk] -- Porting note: added this line simp only [add_assoc, add_comm, add_left_comm] apply R.sound simp only [iterate_map_mul, iterate_map_add, ← iterate_add_apply, mul_add, add_comm, add_left_comm] right_distrib := fun e f g => Quot.inductionOn e fun ⟨m, x⟩ => Quot.inductionOn f fun ⟨n, y⟩ => Quot.inductionOn g fun ⟨s, z⟩ => by simp only [quot_mk_eq_mk, mk_add_mk, mk_mul_mk] -- Porting note: added this line simp only [add_assoc, add_comm _ s, add_left_comm _ s] apply R.sound simp only [iterate_map_mul, iterate_map_add, ← iterate_add_apply, add_mul, add_comm, add_left_comm] }
Mathlib/FieldTheory/PerfectClosure.lean
328
350
theorem mk_eq_iff (x y : ℕ × K) : mk K p x = mk K p y ↔ ∃ z, (frobenius K p)^[y.1 + z] x.2 = (frobenius K p)^[x.1 + z] y.2 := by
constructor · intro H replace H := Quot.exact _ H induction H with | rel x y H => cases' H with n x; exact ⟨0, rfl⟩ | refl H => exact ⟨0, rfl⟩ | symm x y H ih => cases' ih with w ih; exact ⟨w, ih.symm⟩ | trans x y z H1 H2 ih1 ih2 => cases' ih1 with z1 ih1 cases' ih2 with z2 ih2 exists z2 + (y.1 + z1) rw [← add_assoc, iterate_add_apply, ih1] rw [← iterate_add_apply, add_comm, iterate_add_apply, ih2] rw [← iterate_add_apply] simp only [add_comm, add_left_comm] intro H cases' x with m x cases' y with n y cases' H with z H; dsimp only at H rw [R.sound K p (n + z) m x _ rfl, R.sound K p (m + z) n y _ rfl, H] rw [add_assoc, add_comm, add_comm z]
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" /-! # The topology on linearly ordered commutative groups with zero Let `Γ₀` be a linearly ordered commutative group to which we have adjoined a zero element. Then `Γ₀` may naturally be endowed with a topology that turns `Γ₀` into a topological monoid. Neighborhoods of zero are sets containing `{ γ | γ < γ₀ }` for some invertible element `γ₀` and every invertible element is open. In particular the topology is the following: "a subset `U ⊆ Γ₀` is open if `0 ∉ U` or if there is an invertible `γ₀ ∈ Γ₀` such that `{ γ | γ < γ₀ } ⊆ U`", see `WithZeroTopology.isOpen_iff`. We prove this topology is ordered and T₅ (in addition to be compatible with the monoid structure). All this is useful to extend a valuation to a completion. This is an abstract version of how the absolute value (resp. `p`-adic absolute value) on `ℚ` is extended to `ℝ` (resp. `ℚₚ`). ## Implementation notes This topology is defined as a scoped instance since it may not be the desired topology on a linearly ordered commutative group with zero. You can locally activate this topology using `open WithZeroTopology`. -/ open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} /-- The topology on a linearly ordered commutative group with a zero element adjoined. A subset U is open if 0 ∉ U or if there is an invertible element γ₀ such that {γ | γ < γ₀} ⊆ U. -/ 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 /-! ### Neighbourhoods of zero -/ theorem nhds_zero : 𝓝 (0 : Γ₀) = ⨅ γ ≠ 0, 𝓟 (Iio γ) := by rw [nhds_eq_update, update_same] #align with_zero_topology.nhds_zero WithZeroTopology.nhds_zero /-- In a linearly ordered group with zero element adjoined, `U` is a neighbourhood of `0` if and only if there exists a nonzero element `γ₀` such that `Iio γ₀ ⊆ U`. -/ 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 /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `Iio (γ : Γ₀)` is a neighbourhood of `0`. -/ 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 /-! ### Neighbourhoods of non-zero elements -/ /-- The neighbourhood filter of a nonzero element consists of all sets containing that element. -/ @[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 /-- The neighbourhood filter of an invertible element consists of all sets containing that element. -/ theorem nhds_coe_units (γ : Γ₀ˣ) : 𝓝 (γ : Γ₀) = pure (γ : Γ₀) := nhds_of_ne_zero γ.ne_zero #align with_zero_topology.nhds_coe_units WithZeroTopology.nhds_coe_units /-- If `γ` is an invertible element of a linearly ordered group with zero element adjoined, then `{γ}` is a neighbourhood of `γ`. -/ theorem singleton_mem_nhds_of_units (γ : Γ₀ˣ) : ({↑γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp #align with_zero_topology.singleton_mem_nhds_of_units WithZeroTopology.singleton_mem_nhds_of_units /-- If `γ` is a nonzero element of a linearly ordered group with zero element adjoined, then `{γ}` is a neighbourhood of `γ`. -/ theorem singleton_mem_nhds_of_ne_zero (h : γ ≠ 0) : ({γ} : Set Γ₀) ∈ 𝓝 (γ : Γ₀) := by simp [h] #align with_zero_topology.singleton_mem_nhds_of_ne_zero WithZeroTopology.singleton_mem_nhds_of_ne_zero theorem hasBasis_nhds_of_ne_zero {x : Γ₀} (h : x ≠ 0) : HasBasis (𝓝 x) (fun _ : Unit => True) fun _ => {x} := by rw [nhds_of_ne_zero h] exact hasBasis_pure _ #align with_zero_topology.has_basis_nhds_of_ne_zero WithZeroTopology.hasBasis_nhds_of_ne_zero theorem hasBasis_nhds_units (γ : Γ₀ˣ) : HasBasis (𝓝 (γ : Γ₀)) (fun _ : Unit => True) fun _ => {↑γ} := hasBasis_nhds_of_ne_zero γ.ne_zero #align with_zero_topology.has_basis_nhds_units WithZeroTopology.hasBasis_nhds_units theorem tendsto_of_ne_zero {γ : Γ₀} (h : γ ≠ 0) : Tendsto f l (𝓝 γ) ↔ ∀ᶠ x in l, f x = γ := by rw [nhds_of_ne_zero h, tendsto_pure] #align with_zero_topology.tendsto_of_ne_zero WithZeroTopology.tendsto_of_ne_zero theorem tendsto_units {γ₀ : Γ₀ˣ} : Tendsto f l (𝓝 (γ₀ : Γ₀)) ↔ ∀ᶠ x in l, f x = γ₀ := tendsto_of_ne_zero γ₀.ne_zero #align with_zero_topology.tendsto_units WithZeroTopology.tendsto_units
Mathlib/Topology/Algebra/WithZeroTopology.lean
128
129
theorem Iio_mem_nhds (h : γ₁ < γ₂) : Iio γ₂ ∈ 𝓝 γ₁ := by
rcases eq_or_ne γ₁ 0 with (rfl | h₀) <;> simp [*, h.ne', Iio_mem_nhds_zero]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Logic.Function.Iterate import Mathlib.Order.Monotone.Basic #align_import order.iterate from "leanprover-community/mathlib"@"2258b40dacd2942571c8ce136215350c702dc78f" /-! # Inequalities on iterates In this file we prove some inequalities comparing `f^[n] x` and `g^[n] x` where `f` and `g` are two self-maps that commute with each other. Current selection of inequalities is motivated by formalization of the rotation number of a circle homeomorphism. -/ open Function open Function (Commute) namespace Monotone variable {α : Type*} [Preorder α] {f : α → α} {x y : ℕ → α} /-! ### Comparison of two sequences If $f$ is a monotone function, then $∀ k, x_{k+1} ≤ f(x_k)$ implies that $x_k$ grows slower than $f^k(x_0)$, and similarly for the reversed inequalities. If $x_k$ and $y_k$ are two sequences such that $x_{k+1} ≤ f(x_k)$ and $y_{k+1} ≥ f(y_k)$ for all $k < n$, then $x_0 ≤ y_0$ implies $x_n ≤ y_n$, see `Monotone.seq_le_seq`. If some of the inequalities in this lemma are strict, then we have $x_n < y_n$. The rest of the lemmas in this section formalize this fact for different inequalities made strict. -/ theorem seq_le_seq (hf : Monotone f) (n : ℕ) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n ≤ y n := by induction' n with n ihn · exact h₀ · refine (hx _ n.lt_succ_self).trans ((hf <| ihn ?_ ?_).trans (hy _ n.lt_succ_self)) · exact fun k hk => hx _ (hk.trans n.lt_succ_self) · exact fun k hk => hy _ (hk.trans n.lt_succ_self) #align monotone.seq_le_seq Monotone.seq_le_seq theorem seq_pos_lt_seq_of_lt_of_le (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by induction' n with n ihn · exact hn.false.elim suffices x n ≤ y n from (hx n n.lt_succ_self).trans_le ((hf this).trans <| hy n n.lt_succ_self) cases n with | zero => exact h₀ | succ n => refine (ihn n.zero_lt_succ (fun k hk => hx _ ?_) fun k hk => hy _ ?_).le <;> exact hk.trans n.succ.lt_succ_self #align monotone.seq_pos_lt_seq_of_lt_of_le Monotone.seq_pos_lt_seq_of_lt_of_le theorem seq_pos_lt_seq_of_le_of_lt (hf : Monotone f) {n : ℕ} (hn : 0 < n) (h₀ : x 0 ≤ y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := hf.dual.seq_pos_lt_seq_of_lt_of_le hn h₀ hy hx #align monotone.seq_pos_lt_seq_of_le_of_lt Monotone.seq_pos_lt_seq_of_le_of_lt theorem seq_lt_seq_of_lt_of_le (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) (hx : ∀ k < n, x (k + 1) < f (x k)) (hy : ∀ k < n, f (y k) ≤ y (k + 1)) : x n < y n := by cases n exacts [h₀, hf.seq_pos_lt_seq_of_lt_of_le (Nat.zero_lt_succ _) h₀.le hx hy] #align monotone.seq_lt_seq_of_lt_of_le Monotone.seq_lt_seq_of_lt_of_le theorem seq_lt_seq_of_le_of_lt (hf : Monotone f) (n : ℕ) (h₀ : x 0 < y 0) (hx : ∀ k < n, x (k + 1) ≤ f (x k)) (hy : ∀ k < n, f (y k) < y (k + 1)) : x n < y n := hf.dual.seq_lt_seq_of_lt_of_le n h₀ hy hx #align monotone.seq_lt_seq_of_le_of_lt Monotone.seq_lt_seq_of_le_of_lt /-! ### Iterates of two functions In this section we compare the iterates of a monotone function `f : α → α` to iterates of any function `g : β → β`. If `h : β → α` satisfies `h ∘ g ≤ f ∘ h`, then `h (g^[n] x)` grows slower than `f^[n] (h x)`, and similarly for the reversed inequality. Then we specialize these two lemmas to the case `β = α`, `h = id`. -/ variable {β : Type*} {g : β → β} {h : β → α} open Function theorem le_iterate_comp_of_le (hf : Monotone f) (H : h ∘ g ≤ f ∘ h) (n : ℕ) : h ∘ g^[n] ≤ f^[n] ∘ h := fun x => by apply hf.seq_le_seq n <;> intros <;> simp [iterate_succ', -iterate_succ, comp_apply, id_eq, le_refl] case hx => exact H _ #align monotone.le_iterate_comp_of_le Monotone.le_iterate_comp_of_le theorem iterate_comp_le_of_le (hf : Monotone f) (H : f ∘ h ≤ h ∘ g) (n : ℕ) : f^[n] ∘ h ≤ h ∘ g^[n] := hf.dual.le_iterate_comp_of_le H n #align monotone.iterate_comp_le_of_le Monotone.iterate_comp_le_of_le /-- If `f ≤ g` and `f` is monotone, then `f^[n] ≤ g^[n]`. -/ theorem iterate_le_of_le {g : α → α} (hf : Monotone f) (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] := hf.iterate_comp_le_of_le h n #align monotone.iterate_le_of_le Monotone.iterate_le_of_le /-- If `f ≤ g` and `g` is monotone, then `f^[n] ≤ g^[n]`. -/ theorem le_iterate_of_le {g : α → α} (hg : Monotone g) (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] := hg.dual.iterate_le_of_le h n #align monotone.le_iterate_of_le Monotone.le_iterate_of_le end Monotone /-! ### Comparison of iterations and the identity function If $f(x) ≤ x$ for all $x$ (we express this as `f ≤ id` in the code), then the same is true for any iterate of $f$, and similarly for the reversed inequality. -/ namespace Function section Preorder variable {α : Type*} [Preorder α] {f : α → α} /-- If $x ≤ f x$ for all $x$ (we write this as `id ≤ f`), then the same is true for any iterate `f^[n]` of `f`. -/
Mathlib/Order/Iterate.lean
134
135
theorem id_le_iterate_of_id_le (h : id ≤ f) (n : ℕ) : id ≤ f^[n] := by
simpa only [iterate_id] using monotone_id.iterate_le_of_le h n
/- Copyright (c) 2020 Kexing Ying and Kevin Buzzard. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying, Kevin Buzzard, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.GroupWithZero.Finset import Mathlib.Algebra.Group.FiniteSupport import Mathlib.Algebra.Module.Defs import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Data.Set.Subsingleton #align_import algebra.big_operators.finprod from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce" /-! # Finite products and sums over types and sets We define products and sums over types and subsets of types, with no finiteness hypotheses. All infinite products and sums are defined to be junk values (i.e. one or zero). This approach is sometimes easier to use than `Finset.sum`, when issues arise with `Finset` and `Fintype` being data. ## Main definitions We use the following variables: * `α`, `β` - types with no structure; * `s`, `t` - sets * `M`, `N` - additive or multiplicative commutative monoids * `f`, `g` - functions Definitions in this file: * `finsum f : M` : the sum of `f x` as `x` ranges over the support of `f`, if it's finite. Zero otherwise. * `finprod f : M` : the product of `f x` as `x` ranges over the multiplicative support of `f`, if it's finite. One otherwise. ## Notation * `∑ᶠ i, f i` and `∑ᶠ i : α, f i` for `finsum f` * `∏ᶠ i, f i` and `∏ᶠ i : α, f i` for `finprod f` This notation works for functions `f : p → M`, where `p : Prop`, so the following works: * `∑ᶠ i ∈ s, f i`, where `f : α → M`, `s : Set α` : sum over the set `s`; * `∑ᶠ n < 5, f n`, where `f : ℕ → M` : same as `f 0 + f 1 + f 2 + f 3 + f 4`; * `∏ᶠ (n >= -2) (hn : n < 3), f n`, where `f : ℤ → M` : same as `f (-2) * f (-1) * f 0 * f 1 * f 2`. ## Implementation notes `finsum` and `finprod` is "yet another way of doing finite sums and products in Lean". However experiments in the wild (e.g. with matroids) indicate that it is a helpful approach in settings where the user is not interested in computability and wants to do reasoning without running into typeclass diamonds caused by the constructive finiteness used in definitions such as `Finset` and `Fintype`. By sticking solely to `Set.Finite` we avoid these problems. We are aware that there are other solutions but for beginner mathematicians this approach is easier in practice. Another application is the construction of a partition of unity from a collection of “bump” function. In this case the finite set depends on the point and it's convenient to have a definition that does not mention the set explicitly. The first arguments in all definitions and lemmas is the codomain of the function of the big operator. This is necessary for the heuristic in `@[to_additive]`. See the documentation of `to_additive.attr` for more information. We did not add `IsFinite (X : Type) : Prop`, because it is simply `Nonempty (Fintype X)`. ## Tags finsum, finprod, finite sum, finite product -/ open Function Set /-! ### Definition and relation to `Finset.sum` and `Finset.prod` -/ -- Porting note: Used to be section Sort section sort variable {G M N : Type*} {α β ι : Sort*} [CommMonoid M] [CommMonoid N] section /- Note: we use classical logic only for these definitions, to ensure that we do not write lemmas with `Classical.dec` in their statement. -/ open scoped Classical /-- Sum of `f x` as `x` ranges over the elements of the support of `f`, if it's finite. Zero otherwise. -/ noncomputable irreducible_def finsum (lemma := finsum_def') [AddCommMonoid M] (f : α → M) : M := if h : (support (f ∘ PLift.down)).Finite then ∑ i ∈ h.toFinset, f i.down else 0 #align finsum finsum /-- Product of `f x` as `x` ranges over the elements of the multiplicative support of `f`, if it's finite. One otherwise. -/ @[to_additive existing] noncomputable irreducible_def finprod (lemma := finprod_def') (f : α → M) : M := if h : (mulSupport (f ∘ PLift.down)).Finite then ∏ i ∈ h.toFinset, f i.down else 1 #align finprod finprod attribute [to_additive existing] finprod_def' end open Batteries.ExtendedBinder /-- `∑ᶠ x, f x` is notation for `finsum f`. It is the sum of `f x`, where `x` ranges over the support of `f`, if it's finite, zero otherwise. Taking the sum over multiple arguments or conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x`-/ notation3"∑ᶠ "(...)", "r:67:(scoped f => finsum f) => r /-- `∏ᶠ x, f x` is notation for `finprod f`. It is the product of `f x`, where `x` ranges over the multiplicative support of `f`, if it's finite, one otherwise. Taking the product over multiple arguments or conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x`-/ notation3"∏ᶠ "(...)", "r:67:(scoped f => finprod f) => r -- Porting note: The following ports the lean3 notation for this file, but is currently very fickle. -- syntax (name := bigfinsum) "∑ᶠ" extBinders ", " term:67 : term -- macro_rules (kind := bigfinsum) -- | `(∑ᶠ $x:ident, $p) => `(finsum (fun $x:ident ↦ $p)) -- | `(∑ᶠ $x:ident : $t, $p) => `(finsum (fun $x:ident : $t ↦ $p)) -- | `(∑ᶠ $x:ident $b:binderPred, $p) => -- `(finsum fun $x => (finsum (α := satisfies_binder_pred% $x $b) (fun _ => $p))) -- | `(∑ᶠ ($x:ident) ($h:ident : $t), $p) => -- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p)) -- | `(∑ᶠ ($x:ident : $_) ($h:ident : $t), $p) => -- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p)) -- | `(∑ᶠ ($x:ident) ($y:ident), $p) => -- `(finsum fun $x => (finsum fun $y => $p)) -- | `(∑ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) => -- `(finsum fun $x => (finsum fun $y => (finsum (α := $t) fun $h => $p))) -- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident), $p) => -- `(finsum fun $x => (finsum fun $y => (finsum fun $z => $p))) -- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) => -- `(finsum fun $x => (finsum fun $y => (finsum fun $z => (finsum (α := $t) fun $h => $p)))) -- -- -- syntax (name := bigfinprod) "∏ᶠ " extBinders ", " term:67 : term -- macro_rules (kind := bigfinprod) -- | `(∏ᶠ $x:ident, $p) => `(finprod (fun $x:ident ↦ $p)) -- | `(∏ᶠ $x:ident : $t, $p) => `(finprod (fun $x:ident : $t ↦ $p)) -- | `(∏ᶠ $x:ident $b:binderPred, $p) => -- `(finprod fun $x => (finprod (α := satisfies_binder_pred% $x $b) (fun _ => $p))) -- | `(∏ᶠ ($x:ident) ($h:ident : $t), $p) => -- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p)) -- | `(∏ᶠ ($x:ident : $_) ($h:ident : $t), $p) => -- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p)) -- | `(∏ᶠ ($x:ident) ($y:ident), $p) => -- `(finprod fun $x => (finprod fun $y => $p)) -- | `(∏ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) => -- `(finprod fun $x => (finprod fun $y => (finprod (α := $t) fun $h => $p))) -- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident), $p) => -- `(finprod fun $x => (finprod fun $y => (finprod fun $z => $p))) -- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) => -- `(finprod fun $x => (finprod fun $y => (finprod fun $z => -- (finprod (α := $t) fun $h => $p)))) @[to_additive] theorem finprod_eq_prod_plift_of_mulSupport_toFinset_subset {f : α → M} (hf : (mulSupport (f ∘ PLift.down)).Finite) {s : Finset (PLift α)} (hs : hf.toFinset ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i.down := by rw [finprod, dif_pos] refine Finset.prod_subset hs fun x _ hxf => ?_ rwa [hf.mem_toFinset, nmem_mulSupport] at hxf #align finprod_eq_prod_plift_of_mul_support_to_finset_subset finprod_eq_prod_plift_of_mulSupport_toFinset_subset #align finsum_eq_sum_plift_of_support_to_finset_subset finsum_eq_sum_plift_of_support_toFinset_subset @[to_additive] theorem finprod_eq_prod_plift_of_mulSupport_subset {f : α → M} {s : Finset (PLift α)} (hs : mulSupport (f ∘ PLift.down) ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i.down := finprod_eq_prod_plift_of_mulSupport_toFinset_subset (s.finite_toSet.subset hs) fun x hx => by rw [Finite.mem_toFinset] at hx exact hs hx #align finprod_eq_prod_plift_of_mul_support_subset finprod_eq_prod_plift_of_mulSupport_subset #align finsum_eq_sum_plift_of_support_subset finsum_eq_sum_plift_of_support_subset @[to_additive (attr := simp)] theorem finprod_one : (∏ᶠ _ : α, (1 : M)) = 1 := by have : (mulSupport fun x : PLift α => (fun _ => 1 : α → M) x.down) ⊆ (∅ : Finset (PLift α)) := fun x h => by simp at h rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_empty] #align finprod_one finprod_one #align finsum_zero finsum_zero @[to_additive] theorem finprod_of_isEmpty [IsEmpty α] (f : α → M) : ∏ᶠ i, f i = 1 := by rw [← finprod_one] congr simp [eq_iff_true_of_subsingleton] #align finprod_of_is_empty finprod_of_isEmpty #align finsum_of_is_empty finsum_of_isEmpty @[to_additive (attr := simp)] theorem finprod_false (f : False → M) : ∏ᶠ i, f i = 1 := finprod_of_isEmpty _ #align finprod_false finprod_false #align finsum_false finsum_false @[to_additive] theorem finprod_eq_single (f : α → M) (a : α) (ha : ∀ x, x ≠ a → f x = 1) : ∏ᶠ x, f x = f a := by have : mulSupport (f ∘ PLift.down) ⊆ ({PLift.up a} : Finset (PLift α)) := by intro x contrapose simpa [PLift.eq_up_iff_down_eq] using ha x.down rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_singleton] #align finprod_eq_single finprod_eq_single #align finsum_eq_single finsum_eq_single @[to_additive] theorem finprod_unique [Unique α] (f : α → M) : ∏ᶠ i, f i = f default := finprod_eq_single f default fun _x hx => (hx <| Unique.eq_default _).elim #align finprod_unique finprod_unique #align finsum_unique finsum_unique @[to_additive (attr := simp)] theorem finprod_true (f : True → M) : ∏ᶠ i, f i = f trivial := @finprod_unique M True _ ⟨⟨trivial⟩, fun _ => rfl⟩ f #align finprod_true finprod_true #align finsum_true finsum_true @[to_additive] theorem finprod_eq_dif {p : Prop} [Decidable p] (f : p → M) : ∏ᶠ i, f i = if h : p then f h else 1 := by split_ifs with h · haveI : Unique p := ⟨⟨h⟩, fun _ => rfl⟩ exact finprod_unique f · haveI : IsEmpty p := ⟨h⟩ exact finprod_of_isEmpty f #align finprod_eq_dif finprod_eq_dif #align finsum_eq_dif finsum_eq_dif @[to_additive] theorem finprod_eq_if {p : Prop} [Decidable p] {x : M} : ∏ᶠ _ : p, x = if p then x else 1 := finprod_eq_dif fun _ => x #align finprod_eq_if finprod_eq_if #align finsum_eq_if finsum_eq_if @[to_additive] theorem finprod_congr {f g : α → M} (h : ∀ x, f x = g x) : finprod f = finprod g := congr_arg _ <| funext h #align finprod_congr finprod_congr #align finsum_congr finsum_congr @[to_additive (attr := congr)] theorem finprod_congr_Prop {p q : Prop} {f : p → M} {g : q → M} (hpq : p = q) (hfg : ∀ h : q, f (hpq.mpr h) = g h) : finprod f = finprod g := by subst q exact finprod_congr hfg #align finprod_congr_Prop finprod_congr_Prop #align finsum_congr_Prop finsum_congr_Prop /-- To prove a property of a finite product, it suffices to prove that the property is multiplicative and holds on the factors. -/ @[to_additive "To prove a property of a finite sum, it suffices to prove that the property is additive and holds on the summands."] theorem finprod_induction {f : α → M} (p : M → Prop) (hp₀ : p 1) (hp₁ : ∀ x y, p x → p y → p (x * y)) (hp₂ : ∀ i, p (f i)) : p (∏ᶠ i, f i) := by rw [finprod] split_ifs exacts [Finset.prod_induction _ _ hp₁ hp₀ fun i _ => hp₂ _, hp₀] #align finprod_induction finprod_induction #align finsum_induction finsum_induction theorem finprod_nonneg {R : Type*} [OrderedCommSemiring R] {f : α → R} (hf : ∀ x, 0 ≤ f x) : 0 ≤ ∏ᶠ x, f x := finprod_induction (fun x => 0 ≤ x) zero_le_one (fun _ _ => mul_nonneg) hf #align finprod_nonneg finprod_nonneg @[to_additive finsum_nonneg] theorem one_le_finprod' {M : Type*} [OrderedCommMonoid M] {f : α → M} (hf : ∀ i, 1 ≤ f i) : 1 ≤ ∏ᶠ i, f i := finprod_induction _ le_rfl (fun _ _ => one_le_mul) hf #align one_le_finprod' one_le_finprod' #align finsum_nonneg finsum_nonneg @[to_additive] theorem MonoidHom.map_finprod_plift (f : M →* N) (g : α → M) (h : (mulSupport <| g ∘ PLift.down).Finite) : f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) := by rw [finprod_eq_prod_plift_of_mulSupport_subset h.coe_toFinset.ge, finprod_eq_prod_plift_of_mulSupport_subset, map_prod] rw [h.coe_toFinset] exact mulSupport_comp_subset f.map_one (g ∘ PLift.down) #align monoid_hom.map_finprod_plift MonoidHom.map_finprod_plift #align add_monoid_hom.map_finsum_plift AddMonoidHom.map_finsum_plift @[to_additive] theorem MonoidHom.map_finprod_Prop {p : Prop} (f : M →* N) (g : p → M) : f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) := f.map_finprod_plift g (Set.toFinite _) #align monoid_hom.map_finprod_Prop MonoidHom.map_finprod_Prop #align add_monoid_hom.map_finsum_Prop AddMonoidHom.map_finsum_Prop @[to_additive] theorem MonoidHom.map_finprod_of_preimage_one (f : M →* N) (hf : ∀ x, f x = 1 → x = 1) (g : α → M) : f (∏ᶠ i, g i) = ∏ᶠ i, f (g i) := by by_cases hg : (mulSupport <| g ∘ PLift.down).Finite; · exact f.map_finprod_plift g hg rw [finprod, dif_neg, f.map_one, finprod, dif_neg] exacts [Infinite.mono (fun x hx => mt (hf (g x.down)) hx) hg, hg] #align monoid_hom.map_finprod_of_preimage_one MonoidHom.map_finprod_of_preimage_one #align add_monoid_hom.map_finsum_of_preimage_zero AddMonoidHom.map_finsum_of_preimage_zero @[to_additive] theorem MonoidHom.map_finprod_of_injective (g : M →* N) (hg : Injective g) (f : α → M) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) := g.map_finprod_of_preimage_one (fun _ => (hg.eq_iff' g.map_one).mp) f #align monoid_hom.map_finprod_of_injective MonoidHom.map_finprod_of_injective #align add_monoid_hom.map_finsum_of_injective AddMonoidHom.map_finsum_of_injective @[to_additive] theorem MulEquiv.map_finprod (g : M ≃* N) (f : α → M) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) := g.toMonoidHom.map_finprod_of_injective (EquivLike.injective g) f #align mul_equiv.map_finprod MulEquiv.map_finprod #align add_equiv.map_finsum AddEquiv.map_finsum /-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is infinite. For a more usual version assuming `(support f).Finite` instead, see `finsum_smul'`. -/ theorem finsum_smul {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] (f : ι → R) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x := by rcases eq_or_ne x 0 with (rfl | hx) · simp · exact ((smulAddHom R M).flip x).map_finsum_of_injective (smul_left_injective R hx) _ #align finsum_smul finsum_smul /-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is infinite. For a more usual version assuming `(support f).Finite` instead, see `smul_finsum'`. -/ theorem smul_finsum {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M] (c : R) (f : ι → M) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i := by rcases eq_or_ne c 0 with (rfl | hc) · simp · exact (smulAddHom R M c).map_finsum_of_injective (smul_right_injective M hc) _ #align smul_finsum smul_finsum @[to_additive] theorem finprod_inv_distrib [DivisionCommMonoid G] (f : α → G) : (∏ᶠ x, (f x)⁻¹) = (∏ᶠ x, f x)⁻¹ := ((MulEquiv.inv G).map_finprod f).symm #align finprod_inv_distrib finprod_inv_distrib #align finsum_neg_distrib finsum_neg_distrib end sort -- Porting note: Used to be section Type section type variable {α β ι G M N : Type*} [CommMonoid M] [CommMonoid N] @[to_additive] theorem finprod_eq_mulIndicator_apply (s : Set α) (f : α → M) (a : α) : ∏ᶠ _ : a ∈ s, f a = mulIndicator s f a := by classical convert finprod_eq_if (M := M) (p := a ∈ s) (x := f a) #align finprod_eq_mul_indicator_apply finprod_eq_mulIndicator_apply #align finsum_eq_indicator_apply finsum_eq_indicator_apply @[to_additive (attr := simp)] theorem finprod_mem_mulSupport (f : α → M) (a : α) : ∏ᶠ _ : f a ≠ 1, f a = f a := by rw [← mem_mulSupport, finprod_eq_mulIndicator_apply, mulIndicator_mulSupport] #align finprod_mem_mul_support finprod_mem_mulSupport #align finsum_mem_support finsum_mem_support @[to_additive] theorem finprod_mem_def (s : Set α) (f : α → M) : ∏ᶠ a ∈ s, f a = ∏ᶠ a, mulIndicator s f a := finprod_congr <| finprod_eq_mulIndicator_apply s f #align finprod_mem_def finprod_mem_def #align finsum_mem_def finsum_mem_def @[to_additive] theorem finprod_eq_prod_of_mulSupport_subset (f : α → M) {s : Finset α} (h : mulSupport f ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i := by have A : mulSupport (f ∘ PLift.down) = Equiv.plift.symm '' mulSupport f := by rw [mulSupport_comp_eq_preimage] exact (Equiv.plift.symm.image_eq_preimage _).symm have : mulSupport (f ∘ PLift.down) ⊆ s.map Equiv.plift.symm.toEmbedding := by rw [A, Finset.coe_map] exact image_subset _ h rw [finprod_eq_prod_plift_of_mulSupport_subset this] simp only [Finset.prod_map, Equiv.coe_toEmbedding] congr #align finprod_eq_prod_of_mul_support_subset finprod_eq_prod_of_mulSupport_subset #align finsum_eq_sum_of_support_subset finsum_eq_sum_of_support_subset @[to_additive] theorem finprod_eq_prod_of_mulSupport_toFinset_subset (f : α → M) (hf : (mulSupport f).Finite) {s : Finset α} (h : hf.toFinset ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i := finprod_eq_prod_of_mulSupport_subset _ fun _ hx => h <| hf.mem_toFinset.2 hx #align finprod_eq_prod_of_mul_support_to_finset_subset finprod_eq_prod_of_mulSupport_toFinset_subset #align finsum_eq_sum_of_support_to_finset_subset finsum_eq_sum_of_support_toFinset_subset @[to_additive] theorem finprod_eq_finset_prod_of_mulSupport_subset (f : α → M) {s : Finset α} (h : mulSupport f ⊆ (s : Set α)) : ∏ᶠ i, f i = ∏ i ∈ s, f i := haveI h' : (s.finite_toSet.subset h).toFinset ⊆ s := by simpa [← Finset.coe_subset, Set.coe_toFinset] finprod_eq_prod_of_mulSupport_toFinset_subset _ _ h' #align finprod_eq_finset_prod_of_mul_support_subset finprod_eq_finset_prod_of_mulSupport_subset #align finsum_eq_finset_sum_of_support_subset finsum_eq_finset_sum_of_support_subset @[to_additive] theorem finprod_def (f : α → M) [Decidable (mulSupport f).Finite] : ∏ᶠ i : α, f i = if h : (mulSupport f).Finite then ∏ i ∈ h.toFinset, f i else 1 := by split_ifs with h · exact finprod_eq_prod_of_mulSupport_toFinset_subset _ h (Finset.Subset.refl _) · rw [finprod, dif_neg] rw [mulSupport_comp_eq_preimage] exact mt (fun hf => hf.of_preimage Equiv.plift.surjective) h #align finprod_def finprod_def #align finsum_def finsum_def @[to_additive] theorem finprod_of_infinite_mulSupport {f : α → M} (hf : (mulSupport f).Infinite) : ∏ᶠ i, f i = 1 := by classical rw [finprod_def, dif_neg hf] #align finprod_of_infinite_mul_support finprod_of_infinite_mulSupport #align finsum_of_infinite_support finsum_of_infinite_support @[to_additive] theorem finprod_eq_prod (f : α → M) (hf : (mulSupport f).Finite) : ∏ᶠ i : α, f i = ∏ i ∈ hf.toFinset, f i := by classical rw [finprod_def, dif_pos hf] #align finprod_eq_prod finprod_eq_prod #align finsum_eq_sum finsum_eq_sum @[to_additive] theorem finprod_eq_prod_of_fintype [Fintype α] (f : α → M) : ∏ᶠ i : α, f i = ∏ i, f i := finprod_eq_prod_of_mulSupport_toFinset_subset _ (Set.toFinite _) <| Finset.subset_univ _ #align finprod_eq_prod_of_fintype finprod_eq_prod_of_fintype #align finsum_eq_sum_of_fintype finsum_eq_sum_of_fintype @[to_additive] theorem finprod_cond_eq_prod_of_cond_iff (f : α → M) {p : α → Prop} {t : Finset α} (h : ∀ {x}, f x ≠ 1 → (p x ↔ x ∈ t)) : (∏ᶠ (i) (_ : p i), f i) = ∏ i ∈ t, f i := by set s := { x | p x } have : mulSupport (s.mulIndicator f) ⊆ t := by rw [Set.mulSupport_mulIndicator] intro x hx exact (h hx.2).1 hx.1 erw [finprod_mem_def, finprod_eq_prod_of_mulSupport_subset _ this] refine Finset.prod_congr rfl fun x hx => mulIndicator_apply_eq_self.2 fun hxs => ?_ contrapose! hxs exact (h hxs).2 hx #align finprod_cond_eq_prod_of_cond_iff finprod_cond_eq_prod_of_cond_iff #align finsum_cond_eq_sum_of_cond_iff finsum_cond_eq_sum_of_cond_iff @[to_additive] theorem finprod_cond_ne (f : α → M) (a : α) [DecidableEq α] (hf : (mulSupport f).Finite) : (∏ᶠ (i) (_ : i ≠ a), f i) = ∏ i ∈ hf.toFinset.erase a, f i := by apply finprod_cond_eq_prod_of_cond_iff intro x hx rw [Finset.mem_erase, Finite.mem_toFinset, mem_mulSupport] exact ⟨fun h => And.intro h hx, fun h => h.1⟩ #align finprod_cond_ne finprod_cond_ne #align finsum_cond_ne finsum_cond_ne @[to_additive] theorem finprod_mem_eq_prod_of_inter_mulSupport_eq (f : α → M) {s : Set α} {t : Finset α} (h : s ∩ mulSupport f = t.toSet ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i := finprod_cond_eq_prod_of_cond_iff _ <| by intro x hxf rw [← mem_mulSupport] at hxf refine ⟨fun hx => ?_, fun hx => ?_⟩ · refine ((mem_inter_iff x t (mulSupport f)).mp ?_).1 rw [← Set.ext_iff.mp h x, mem_inter_iff] exact ⟨hx, hxf⟩ · refine ((mem_inter_iff x s (mulSupport f)).mp ?_).1 rw [Set.ext_iff.mp h x, mem_inter_iff] exact ⟨hx, hxf⟩ #align finprod_mem_eq_prod_of_inter_mul_support_eq finprod_mem_eq_prod_of_inter_mulSupport_eq #align finsum_mem_eq_sum_of_inter_support_eq finsum_mem_eq_sum_of_inter_support_eq @[to_additive] theorem finprod_mem_eq_prod_of_subset (f : α → M) {s : Set α} {t : Finset α} (h₁ : s ∩ mulSupport f ⊆ t) (h₂ : ↑t ⊆ s) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i := finprod_cond_eq_prod_of_cond_iff _ fun hx => ⟨fun h => h₁ ⟨h, hx⟩, fun h => h₂ h⟩ #align finprod_mem_eq_prod_of_subset finprod_mem_eq_prod_of_subset #align finsum_mem_eq_sum_of_subset finsum_mem_eq_sum_of_subset @[to_additive] theorem finprod_mem_eq_prod (f : α → M) {s : Set α} (hf : (s ∩ mulSupport f).Finite) : ∏ᶠ i ∈ s, f i = ∏ i ∈ hf.toFinset, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp [inter_assoc] #align finprod_mem_eq_prod finprod_mem_eq_prod #align finsum_mem_eq_sum finsum_mem_eq_sum @[to_additive] theorem finprod_mem_eq_prod_filter (f : α → M) (s : Set α) [DecidablePred (· ∈ s)] (hf : (mulSupport f).Finite) : ∏ᶠ i ∈ s, f i = ∏ i ∈ Finset.filter (· ∈ s) hf.toFinset, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by ext x simp [and_comm] #align finprod_mem_eq_prod_filter finprod_mem_eq_prod_filter #align finsum_mem_eq_sum_filter finsum_mem_eq_sum_filter @[to_additive] theorem finprod_mem_eq_toFinset_prod (f : α → M) (s : Set α) [Fintype s] : ∏ᶠ i ∈ s, f i = ∏ i ∈ s.toFinset, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp_rw [coe_toFinset s] #align finprod_mem_eq_to_finset_prod finprod_mem_eq_toFinset_prod #align finsum_mem_eq_to_finset_sum finsum_mem_eq_toFinset_sum @[to_additive] theorem finprod_mem_eq_finite_toFinset_prod (f : α → M) {s : Set α} (hs : s.Finite) : ∏ᶠ i ∈ s, f i = ∏ i ∈ hs.toFinset, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by rw [hs.coe_toFinset] #align finprod_mem_eq_finite_to_finset_prod finprod_mem_eq_finite_toFinset_prod #align finsum_mem_eq_finite_to_finset_sum finsum_mem_eq_finite_toFinset_sum @[to_additive] theorem finprod_mem_finset_eq_prod (f : α → M) (s : Finset α) : ∏ᶠ i ∈ s, f i = ∏ i ∈ s, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl #align finprod_mem_finset_eq_prod finprod_mem_finset_eq_prod #align finsum_mem_finset_eq_sum finsum_mem_finset_eq_sum @[to_additive] theorem finprod_mem_coe_finset (f : α → M) (s : Finset α) : (∏ᶠ i ∈ (s : Set α), f i) = ∏ i ∈ s, f i := finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl #align finprod_mem_coe_finset finprod_mem_coe_finset #align finsum_mem_coe_finset finsum_mem_coe_finset @[to_additive] theorem finprod_mem_eq_one_of_infinite {f : α → M} {s : Set α} (hs : (s ∩ mulSupport f).Infinite) : ∏ᶠ i ∈ s, f i = 1 := by rw [finprod_mem_def] apply finprod_of_infinite_mulSupport rwa [← mulSupport_mulIndicator] at hs #align finprod_mem_eq_one_of_infinite finprod_mem_eq_one_of_infinite #align finsum_mem_eq_zero_of_infinite finsum_mem_eq_zero_of_infinite @[to_additive] theorem finprod_mem_eq_one_of_forall_eq_one {f : α → M} {s : Set α} (h : ∀ x ∈ s, f x = 1) : ∏ᶠ i ∈ s, f i = 1 := by simp (config := { contextual := true }) [h] #align finprod_mem_eq_one_of_forall_eq_one finprod_mem_eq_one_of_forall_eq_one #align finsum_mem_eq_zero_of_forall_eq_zero finsum_mem_eq_zero_of_forall_eq_zero @[to_additive] theorem finprod_mem_inter_mulSupport (f : α → M) (s : Set α) : ∏ᶠ i ∈ s ∩ mulSupport f, f i = ∏ᶠ i ∈ s, f i := by rw [finprod_mem_def, finprod_mem_def, mulIndicator_inter_mulSupport] #align finprod_mem_inter_mul_support finprod_mem_inter_mulSupport #align finsum_mem_inter_support finsum_mem_inter_support @[to_additive] theorem finprod_mem_inter_mulSupport_eq (f : α → M) (s t : Set α) (h : s ∩ mulSupport f = t ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by rw [← finprod_mem_inter_mulSupport, h, finprod_mem_inter_mulSupport] #align finprod_mem_inter_mul_support_eq finprod_mem_inter_mulSupport_eq #align finsum_mem_inter_support_eq finsum_mem_inter_support_eq @[to_additive] theorem finprod_mem_inter_mulSupport_eq' (f : α → M) (s t : Set α) (h : ∀ x ∈ mulSupport f, x ∈ s ↔ x ∈ t) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by apply finprod_mem_inter_mulSupport_eq ext x exact and_congr_left (h x) #align finprod_mem_inter_mul_support_eq' finprod_mem_inter_mulSupport_eq' #align finsum_mem_inter_support_eq' finsum_mem_inter_support_eq' @[to_additive] theorem finprod_mem_univ (f : α → M) : ∏ᶠ i ∈ @Set.univ α, f i = ∏ᶠ i : α, f i := finprod_congr fun _ => finprod_true _ #align finprod_mem_univ finprod_mem_univ #align finsum_mem_univ finsum_mem_univ variable {f g : α → M} {a b : α} {s t : Set α} @[to_additive] theorem finprod_mem_congr (h₀ : s = t) (h₁ : ∀ x ∈ t, f x = g x) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, g i := h₀.symm ▸ finprod_congr fun i => finprod_congr_Prop rfl (h₁ i) #align finprod_mem_congr finprod_mem_congr #align finsum_mem_congr finsum_mem_congr @[to_additive] theorem finprod_eq_one_of_forall_eq_one {f : α → M} (h : ∀ x, f x = 1) : ∏ᶠ i, f i = 1 := by simp (config := { contextual := true }) [h] #align finprod_eq_one_of_forall_eq_one finprod_eq_one_of_forall_eq_one #align finsum_eq_zero_of_forall_eq_zero finsum_eq_zero_of_forall_eq_zero @[to_additive finsum_pos'] theorem one_lt_finprod' {M : Type*} [OrderedCancelCommMonoid M] {f : ι → M} (h : ∀ i, 1 ≤ f i) (h' : ∃ i, 1 < f i) (hf : (mulSupport f).Finite) : 1 < ∏ᶠ i, f i := by rcases h' with ⟨i, hi⟩ rw [finprod_eq_prod _ hf] refine Finset.one_lt_prod' (fun i _ ↦ h i) ⟨i, ?_, hi⟩ simpa only [Finite.mem_toFinset, mem_mulSupport] using ne_of_gt hi /-! ### Distributivity w.r.t. addition, subtraction, and (scalar) multiplication -/ /-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i * g i` equals the product of `f i` multiplied by the product of `g i`. -/ @[to_additive "If the additive supports of `f` and `g` are finite, then the sum of `f i + g i` equals the sum of `f i` plus the sum of `g i`."] theorem finprod_mul_distrib (hf : (mulSupport f).Finite) (hg : (mulSupport g).Finite) : ∏ᶠ i, f i * g i = (∏ᶠ i, f i) * ∏ᶠ i, g i := by classical rw [finprod_eq_prod_of_mulSupport_toFinset_subset f hf Finset.subset_union_left, finprod_eq_prod_of_mulSupport_toFinset_subset g hg Finset.subset_union_right, ← Finset.prod_mul_distrib] refine finprod_eq_prod_of_mulSupport_subset _ ?_ simp only [Finset.coe_union, Finite.coe_toFinset, mulSupport_subset_iff, mem_union, mem_mulSupport] intro x contrapose! rintro ⟨hf, hg⟩ simp [hf, hg] #align finprod_mul_distrib finprod_mul_distrib #align finsum_add_distrib finsum_add_distrib /-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i / g i` equals the product of `f i` divided by the product of `g i`. -/ @[to_additive "If the additive supports of `f` and `g` are finite, then the sum of `f i - g i` equals the sum of `f i` minus the sum of `g i`."] theorem finprod_div_distrib [DivisionCommMonoid G] {f g : α → G} (hf : (mulSupport f).Finite) (hg : (mulSupport g).Finite) : ∏ᶠ i, f i / g i = (∏ᶠ i, f i) / ∏ᶠ i, g i := by simp only [div_eq_mul_inv, finprod_mul_distrib hf ((mulSupport_inv g).symm.rec hg), finprod_inv_distrib] #align finprod_div_distrib finprod_div_distrib #align finsum_sub_distrib finsum_sub_distrib /-- A more general version of `finprod_mem_mul_distrib` that only requires `s ∩ mulSupport f` and `s ∩ mulSupport g` rather than `s` to be finite. -/ @[to_additive "A more general version of `finsum_mem_add_distrib` that only requires `s ∩ support f` and `s ∩ support g` rather than `s` to be finite."] theorem finprod_mem_mul_distrib' (hf : (s ∩ mulSupport f).Finite) (hg : (s ∩ mulSupport g).Finite) : ∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i := by rw [← mulSupport_mulIndicator] at hf hg simp only [finprod_mem_def, mulIndicator_mul, finprod_mul_distrib hf hg] #align finprod_mem_mul_distrib' finprod_mem_mul_distrib' #align finsum_mem_add_distrib' finsum_mem_add_distrib' /-- The product of the constant function `1` over any set equals `1`. -/ @[to_additive "The sum of the constant function `0` over any set equals `0`."] theorem finprod_mem_one (s : Set α) : (∏ᶠ i ∈ s, (1 : M)) = 1 := by simp #align finprod_mem_one finprod_mem_one #align finsum_mem_zero finsum_mem_zero /-- If a function `f` equals `1` on a set `s`, then the product of `f i` over `i ∈ s` equals `1`. -/ @[to_additive "If a function `f` equals `0` on a set `s`, then the product of `f i` over `i ∈ s` equals `0`."] theorem finprod_mem_of_eqOn_one (hf : s.EqOn f 1) : ∏ᶠ i ∈ s, f i = 1 := by rw [← finprod_mem_one s] exact finprod_mem_congr rfl hf #align finprod_mem_of_eq_on_one finprod_mem_of_eqOn_one #align finsum_mem_of_eq_on_zero finsum_mem_of_eqOn_zero /-- If the product of `f i` over `i ∈ s` is not equal to `1`, then there is some `x ∈ s` such that `f x ≠ 1`. -/ @[to_additive "If the product of `f i` over `i ∈ s` is not equal to `0`, then there is some `x ∈ s` such that `f x ≠ 0`."] theorem exists_ne_one_of_finprod_mem_ne_one (h : ∏ᶠ i ∈ s, f i ≠ 1) : ∃ x ∈ s, f x ≠ 1 := by by_contra! h' exact h (finprod_mem_of_eqOn_one h') #align exists_ne_one_of_finprod_mem_ne_one exists_ne_one_of_finprod_mem_ne_one #align exists_ne_zero_of_finsum_mem_ne_zero exists_ne_zero_of_finsum_mem_ne_zero /-- Given a finite set `s`, the product of `f i * g i` over `i ∈ s` equals the product of `f i` over `i ∈ s` times the product of `g i` over `i ∈ s`. -/ @[to_additive "Given a finite set `s`, the sum of `f i + g i` over `i ∈ s` equals the sum of `f i` over `i ∈ s` plus the sum of `g i` over `i ∈ s`."] theorem finprod_mem_mul_distrib (hs : s.Finite) : ∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i := finprod_mem_mul_distrib' (hs.inter_of_left _) (hs.inter_of_left _) #align finprod_mem_mul_distrib finprod_mem_mul_distrib #align finsum_mem_add_distrib finsum_mem_add_distrib @[to_additive] theorem MonoidHom.map_finprod {f : α → M} (g : M →* N) (hf : (mulSupport f).Finite) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) := g.map_finprod_plift f <| hf.preimage Equiv.plift.injective.injOn #align monoid_hom.map_finprod MonoidHom.map_finprod #align add_monoid_hom.map_finsum AddMonoidHom.map_finsum @[to_additive] theorem finprod_pow (hf : (mulSupport f).Finite) (n : ℕ) : (∏ᶠ i, f i) ^ n = ∏ᶠ i, f i ^ n := (powMonoidHom n).map_finprod hf #align finprod_pow finprod_pow #align finsum_nsmul finsum_nsmul /-- See also `finsum_smul` for a version that works even when the support of `f` is not finite, but with slightly stronger typeclass requirements. -/ theorem finsum_smul' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {f : ι → R} (hf : (support f).Finite) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x := ((smulAddHom R M).flip x).map_finsum hf /-- See also `smul_finsum` for a version that works even when the support of `f` is not finite, but with slightly stronger typeclass requirements. -/ theorem smul_finsum' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] (c : R) {f : ι → M} (hf : (support f).Finite) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i := (smulAddHom R M c).map_finsum hf /-- A more general version of `MonoidHom.map_finprod_mem` that requires `s ∩ mulSupport f` rather than `s` to be finite. -/ @[to_additive "A more general version of `AddMonoidHom.map_finsum_mem` that requires `s ∩ support f` rather than `s` to be finite."] theorem MonoidHom.map_finprod_mem' {f : α → M} (g : M →* N) (h₀ : (s ∩ mulSupport f).Finite) : g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) := by rw [g.map_finprod] · simp only [g.map_finprod_Prop] · simpa only [finprod_eq_mulIndicator_apply, mulSupport_mulIndicator] #align monoid_hom.map_finprod_mem' MonoidHom.map_finprod_mem' #align add_monoid_hom.map_finsum_mem' AddMonoidHom.map_finsum_mem' /-- Given a monoid homomorphism `g : M →* N` and a function `f : α → M`, the value of `g` at the product of `f i` over `i ∈ s` equals the product of `g (f i)` over `s`. -/ @[to_additive "Given an additive monoid homomorphism `g : M →* N` and a function `f : α → M`, the value of `g` at the sum of `f i` over `i ∈ s` equals the sum of `g (f i)` over `s`."] theorem MonoidHom.map_finprod_mem (f : α → M) (g : M →* N) (hs : s.Finite) : g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) := g.map_finprod_mem' (hs.inter_of_left _) #align monoid_hom.map_finprod_mem MonoidHom.map_finprod_mem #align add_monoid_hom.map_finsum_mem AddMonoidHom.map_finsum_mem @[to_additive] theorem MulEquiv.map_finprod_mem (g : M ≃* N) (f : α → M) {s : Set α} (hs : s.Finite) : g (∏ᶠ i ∈ s, f i) = ∏ᶠ i ∈ s, g (f i) := g.toMonoidHom.map_finprod_mem f hs #align mul_equiv.map_finprod_mem MulEquiv.map_finprod_mem #align add_equiv.map_finsum_mem AddEquiv.map_finsum_mem @[to_additive] theorem finprod_mem_inv_distrib [DivisionCommMonoid G] (f : α → G) (hs : s.Finite) : (∏ᶠ x ∈ s, (f x)⁻¹) = (∏ᶠ x ∈ s, f x)⁻¹ := ((MulEquiv.inv G).map_finprod_mem f hs).symm #align finprod_mem_inv_distrib finprod_mem_inv_distrib #align finsum_mem_neg_distrib finsum_mem_neg_distrib /-- Given a finite set `s`, the product of `f i / g i` over `i ∈ s` equals the product of `f i` over `i ∈ s` divided by the product of `g i` over `i ∈ s`. -/ @[to_additive "Given a finite set `s`, the sum of `f i / g i` over `i ∈ s` equals the sum of `f i` over `i ∈ s` minus the sum of `g i` over `i ∈ s`."] theorem finprod_mem_div_distrib [DivisionCommMonoid G] (f g : α → G) (hs : s.Finite) : ∏ᶠ i ∈ s, f i / g i = (∏ᶠ i ∈ s, f i) / ∏ᶠ i ∈ s, g i := by simp only [div_eq_mul_inv, finprod_mem_mul_distrib hs, finprod_mem_inv_distrib g hs] #align finprod_mem_div_distrib finprod_mem_div_distrib #align finsum_mem_sub_distrib finsum_mem_sub_distrib /-! ### `∏ᶠ x ∈ s, f x` and set operations -/ /-- The product of any function over an empty set is `1`. -/ @[to_additive "The sum of any function over an empty set is `0`."] theorem finprod_mem_empty : (∏ᶠ i ∈ (∅ : Set α), f i) = 1 := by simp #align finprod_mem_empty finprod_mem_empty #align finsum_mem_empty finsum_mem_empty /-- A set `s` is nonempty if the product of some function over `s` is not equal to `1`. -/ @[to_additive "A set `s` is nonempty if the sum of some function over `s` is not equal to `0`."] theorem nonempty_of_finprod_mem_ne_one (h : ∏ᶠ i ∈ s, f i ≠ 1) : s.Nonempty := nonempty_iff_ne_empty.2 fun h' => h <| h'.symm ▸ finprod_mem_empty #align nonempty_of_finprod_mem_ne_one nonempty_of_finprod_mem_ne_one #align nonempty_of_finsum_mem_ne_zero nonempty_of_finsum_mem_ne_zero /-- Given finite sets `s` and `t`, the product of `f i` over `i ∈ s ∪ t` times the product of `f i` over `i ∈ s ∩ t` equals the product of `f i` over `i ∈ s` times the product of `f i` over `i ∈ t`. -/ @[to_additive "Given finite sets `s` and `t`, the sum of `f i` over `i ∈ s ∪ t` plus the sum of `f i` over `i ∈ s ∩ t` equals the sum of `f i` over `i ∈ s` plus the sum of `f i` over `i ∈ t`."] theorem finprod_mem_union_inter (hs : s.Finite) (ht : t.Finite) : ((∏ᶠ i ∈ s ∪ t, f i) * ∏ᶠ i ∈ s ∩ t, f i) = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by lift s to Finset α using hs; lift t to Finset α using ht classical rw [← Finset.coe_union, ← Finset.coe_inter] simp only [finprod_mem_coe_finset, Finset.prod_union_inter] #align finprod_mem_union_inter finprod_mem_union_inter #align finsum_mem_union_inter finsum_mem_union_inter /-- A more general version of `finprod_mem_union_inter` that requires `s ∩ mulSupport f` and `t ∩ mulSupport f` rather than `s` and `t` to be finite. -/ @[to_additive "A more general version of `finsum_mem_union_inter` that requires `s ∩ support f` and `t ∩ support f` rather than `s` and `t` to be finite."] theorem finprod_mem_union_inter' (hs : (s ∩ mulSupport f).Finite) (ht : (t ∩ mulSupport f).Finite) : ((∏ᶠ i ∈ s ∪ t, f i) * ∏ᶠ i ∈ s ∩ t, f i) = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by rw [← finprod_mem_inter_mulSupport f s, ← finprod_mem_inter_mulSupport f t, ← finprod_mem_union_inter hs ht, ← union_inter_distrib_right, finprod_mem_inter_mulSupport, ← finprod_mem_inter_mulSupport f (s ∩ t)] congr 2 rw [inter_left_comm, inter_assoc, inter_assoc, inter_self, inter_left_comm] #align finprod_mem_union_inter' finprod_mem_union_inter' #align finsum_mem_union_inter' finsum_mem_union_inter' /-- A more general version of `finprod_mem_union` that requires `s ∩ mulSupport f` and `t ∩ mulSupport f` rather than `s` and `t` to be finite. -/ @[to_additive "A more general version of `finsum_mem_union` that requires `s ∩ support f` and `t ∩ support f` rather than `s` and `t` to be finite."] theorem finprod_mem_union' (hst : Disjoint s t) (hs : (s ∩ mulSupport f).Finite) (ht : (t ∩ mulSupport f).Finite) : ∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by rw [← finprod_mem_union_inter' hs ht, disjoint_iff_inter_eq_empty.1 hst, finprod_mem_empty, mul_one] #align finprod_mem_union' finprod_mem_union' #align finsum_mem_union' finsum_mem_union' /-- Given two finite disjoint sets `s` and `t`, the product of `f i` over `i ∈ s ∪ t` equals the product of `f i` over `i ∈ s` times the product of `f i` over `i ∈ t`. -/ @[to_additive "Given two finite disjoint sets `s` and `t`, the sum of `f i` over `i ∈ s ∪ t` equals the sum of `f i` over `i ∈ s` plus the sum of `f i` over `i ∈ t`."] theorem finprod_mem_union (hst : Disjoint s t) (hs : s.Finite) (ht : t.Finite) : ∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := finprod_mem_union' hst (hs.inter_of_left _) (ht.inter_of_left _) #align finprod_mem_union finprod_mem_union #align finsum_mem_union finsum_mem_union /-- A more general version of `finprod_mem_union'` that requires `s ∩ mulSupport f` and `t ∩ mulSupport f` rather than `s` and `t` to be disjoint -/ @[to_additive "A more general version of `finsum_mem_union'` that requires `s ∩ support f` and `t ∩ support f` rather than `s` and `t` to be disjoint"] theorem finprod_mem_union'' (hst : Disjoint (s ∩ mulSupport f) (t ∩ mulSupport f)) (hs : (s ∩ mulSupport f).Finite) (ht : (t ∩ mulSupport f).Finite) : ∏ᶠ i ∈ s ∪ t, f i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ t, f i := by rw [← finprod_mem_inter_mulSupport f s, ← finprod_mem_inter_mulSupport f t, ← finprod_mem_union hst hs ht, ← union_inter_distrib_right, finprod_mem_inter_mulSupport] #align finprod_mem_union'' finprod_mem_union'' #align finsum_mem_union'' finsum_mem_union'' /-- The product of `f i` over `i ∈ {a}` equals `f a`. -/ @[to_additive "The sum of `f i` over `i ∈ {a}` equals `f a`."] theorem finprod_mem_singleton : (∏ᶠ i ∈ ({a} : Set α), f i) = f a := by rw [← Finset.coe_singleton, finprod_mem_coe_finset, Finset.prod_singleton] #align finprod_mem_singleton finprod_mem_singleton #align finsum_mem_singleton finsum_mem_singleton @[to_additive (attr := simp)] theorem finprod_cond_eq_left : (∏ᶠ (i) (_ : i = a), f i) = f a := finprod_mem_singleton #align finprod_cond_eq_left finprod_cond_eq_left #align finsum_cond_eq_left finsum_cond_eq_left @[to_additive (attr := simp)] theorem finprod_cond_eq_right : (∏ᶠ (i) (_ : a = i), f i) = f a := by simp [@eq_comm _ a] #align finprod_cond_eq_right finprod_cond_eq_right #align finsum_cond_eq_right finsum_cond_eq_right /-- A more general version of `finprod_mem_insert` that requires `s ∩ mulSupport f` rather than `s` to be finite. -/ @[to_additive "A more general version of `finsum_mem_insert` that requires `s ∩ support f` rather than `s` to be finite."]
Mathlib/Algebra/BigOperators/Finprod.lean
868
872
theorem finprod_mem_insert' (f : α → M) (h : a ∉ s) (hs : (s ∩ mulSupport f).Finite) : ∏ᶠ i ∈ insert a s, f i = f a * ∏ᶠ i ∈ s, f i := by
rw [insert_eq, finprod_mem_union' _ _ hs, finprod_mem_singleton] · rwa [disjoint_singleton_left] · exact (finite_singleton a).inter_of_left _
/- Copyright (c) 2022 Antoine Labelle, Rémi Bottinelli. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Labelle, Rémi Bottinelli -/ import Mathlib.Combinatorics.Quiver.Basic import Mathlib.Combinatorics.Quiver.Path #align_import combinatorics.quiver.cast from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Rewriting arrows and paths along vertex equalities This files defines `Hom.cast` and `Path.cast` (and associated lemmas) in order to allow rewriting arrows and paths along equalities of their endpoints. -/ universe v v₁ v₂ u u₁ u₂ variable {U : Type*} [Quiver.{u + 1} U] namespace Quiver /-! ### Rewriting arrows along equalities of vertices -/ /-- Change the endpoints of an arrow using equalities. -/ def Hom.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : u' ⟶ v' := Eq.ndrec (motive := (· ⟶ v')) (Eq.ndrec e hv) hu #align quiver.hom.cast Quiver.Hom.cast theorem Hom.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : e.cast hu hv = _root_.cast (by {rw [hu, hv]}) e := by subst_vars rfl #align quiver.hom.cast_eq_cast Quiver.Hom.cast_eq_cast @[simp] theorem Hom.cast_rfl_rfl {u v : U} (e : u ⟶ v) : e.cast rfl rfl = e := rfl #align quiver.hom.cast_rfl_rfl Quiver.Hom.cast_rfl_rfl @[simp] theorem Hom.cast_cast {u v u' v' u'' v'' : U} (e : u ⟶ v) (hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') : (e.cast hu hv).cast hu' hv' = e.cast (hu.trans hu') (hv.trans hv') := by subst_vars rfl #align quiver.hom.cast_cast Quiver.Hom.cast_cast theorem Hom.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) : HEq (e.cast hu hv) e := by subst_vars rfl #align quiver.hom.cast_heq Quiver.Hom.cast_heq theorem Hom.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) (e' : u' ⟶ v') : e.cast hu hv = e' ↔ HEq e e' := by rw [Hom.cast_eq_cast] exact _root_.cast_eq_iff_heq #align quiver.hom.cast_eq_iff_heq Quiver.Hom.cast_eq_iff_heq theorem Hom.eq_cast_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (e : u ⟶ v) (e' : u' ⟶ v') : e' = e.cast hu hv ↔ HEq e' e := by rw [eq_comm, Hom.cast_eq_iff_heq] exact ⟨HEq.symm, HEq.symm⟩ #align quiver.hom.eq_cast_iff_heq Quiver.Hom.eq_cast_iff_heq /-! ### Rewriting paths along equalities of vertices -/ open Path /-- Change the endpoints of a path using equalities. -/ def Path.cast {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) : Path u' v' := Eq.ndrec (motive := (Path · v')) (Eq.ndrec p hv) hu #align quiver.path.cast Quiver.Path.cast theorem Path.cast_eq_cast {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) : p.cast hu hv = _root_.cast (by rw [hu, hv]) p := by subst_vars rfl #align quiver.path.cast_eq_cast Quiver.Path.cast_eq_cast @[simp] theorem Path.cast_rfl_rfl {u v : U} (p : Path u v) : p.cast rfl rfl = p := rfl #align quiver.path.cast_rfl_rfl Quiver.Path.cast_rfl_rfl @[simp] theorem Path.cast_cast {u v u' v' u'' v'' : U} (p : Path u v) (hu : u = u') (hv : v = v') (hu' : u' = u'') (hv' : v' = v'') : (p.cast hu hv).cast hu' hv' = p.cast (hu.trans hu') (hv.trans hv') := by subst_vars rfl #align quiver.path.cast_cast Quiver.Path.cast_cast @[simp] theorem Path.cast_nil {u u' : U} (hu : u = u') : (Path.nil : Path u u).cast hu hu = Path.nil := by subst_vars rfl #align quiver.path.cast_nil Quiver.Path.cast_nil theorem Path.cast_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) : HEq (p.cast hu hv) p := by rw [Path.cast_eq_cast] exact _root_.cast_heq _ _ #align quiver.path.cast_heq Quiver.Path.cast_heq
Mathlib/Combinatorics/Quiver/Cast.lean
118
121
theorem Path.cast_eq_iff_heq {u v u' v' : U} (hu : u = u') (hv : v = v') (p : Path u v) (p' : Path u' v') : p.cast hu hv = p' ↔ HEq p p' := by
rw [Path.cast_eq_cast] exact _root_.cast_eq_iff_heq
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Order.CompleteLattice import Mathlib.Order.GaloisConnection import Mathlib.Data.Set.Lattice import Mathlib.Tactic.AdaptationNote #align_import data.rel from "leanprover-community/mathlib"@"706d88f2b8fdfeb0b22796433d7a6c1a010af9f2" /-! # Relations This file defines bundled relations. A relation between `α` and `β` is a function `α → β → Prop`. Relations are also known as set-valued functions, or partial multifunctions. ## Main declarations * `Rel α β`: Relation between `α` and `β`. * `Rel.inv`: `r.inv` is the `Rel β α` obtained by swapping the arguments of `r`. * `Rel.dom`: Domain of a relation. `x ∈ r.dom` iff there exists `y` such that `r x y`. * `Rel.codom`: Codomain, aka range, of a relation. `y ∈ r.codom` iff there exists `x` such that `r x y`. * `Rel.comp`: Relation composition. Note that the arguments order follows the `CategoryTheory/` one, so `r.comp s x z ↔ ∃ y, r x y ∧ s y z`. * `Rel.image`: Image of a set under a relation. `r.image s` is the set of `f x` over all `x ∈ s`. * `Rel.preimage`: Preimage of a set under a relation. Note that `r.preimage = r.inv.image`. * `Rel.core`: Core of a set. For `s : Set β`, `r.core s` is the set of `x : α` such that all `y` related to `x` are in `s`. * `Rel.restrict_domain`: Domain-restriction of a relation to a subtype. * `Function.graph`: Graph of a function as a relation. ## TODOs The `Rel.comp` function uses the notation `r • s`, rather than the more common `r ∘ s` for things named `comp`. This is because the latter is already used for function composition, and causes a clash. A better notation should be found, perhaps a variant of `r ∘r s` or `r; s`. -/ variable {α β γ : Type*} /-- A relation on `α` and `β`, aka a set-valued function, aka a partial multifunction -/ def Rel (α β : Type*) := α → β → Prop -- deriving CompleteLattice, Inhabited #align rel Rel -- Porting note: `deriving` above doesn't work. instance : CompleteLattice (Rel α β) := show CompleteLattice (α → β → Prop) from inferInstance instance : Inhabited (Rel α β) := show Inhabited (α → β → Prop) from inferInstance namespace Rel variable (r : Rel α β) -- Porting note: required for later theorems. @[ext] theorem ext {r s : Rel α β} : (∀ a, r a = s a) → r = s := funext /-- The inverse relation : `r.inv x y ↔ r y x`. Note that this is *not* a groupoid inverse. -/ def inv : Rel β α := flip r #align rel.inv Rel.inv theorem inv_def (x : α) (y : β) : r.inv y x ↔ r x y := Iff.rfl #align rel.inv_def Rel.inv_def theorem inv_inv : inv (inv r) = r := by ext x y rfl #align rel.inv_inv Rel.inv_inv /-- Domain of a relation -/ def dom := { x | ∃ y, r x y } #align rel.dom Rel.dom theorem dom_mono {r s : Rel α β} (h : r ≤ s) : dom r ⊆ dom s := fun a ⟨b, hx⟩ => ⟨b, h a b hx⟩ #align rel.dom_mono Rel.dom_mono /-- Codomain aka range of a relation -/ def codom := { y | ∃ x, r x y } #align rel.codom Rel.codom theorem codom_inv : r.inv.codom = r.dom := by ext x rfl #align rel.codom_inv Rel.codom_inv
Mathlib/Data/Rel.lean
91
93
theorem dom_inv : r.inv.dom = r.codom := by
ext x rfl
/- Copyright (c) 2024 Amelia Livingston. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Yury Kudryashov, Amelia Livingston -/ import Mathlib.RingTheory.Coalgebra.Hom import Mathlib.RingTheory.Bialgebra.Basic /-! # Homomorphisms of `R`-bialgebras This file defines bundled homomorphisms of `R`-bialgebras. We simply mimic `Mathlib/Algebra/Algebra/Hom.lean`. ## Main definitions * `BialgHom R A B`: the type of `R`-bialgebra morphisms from `A` to `B`. * `Bialgebra.counitBialgHom R A : A →ₐc[R] R`: the counit of a bialgebra as a bialgebra homomorphism. ## Notations * `A →ₐc[R] B` : `R`-bialgebra homomorphism from `A` to `B`. -/ open TensorProduct Bialgebra universe u v w /-- Given `R`-algebras `A, B` with comultiplication maps `Δ_A, Δ_B` and counit maps `ε_A, ε_B`, an `R`-bialgebra homomorphism `A →ₐc[R] B` is an `R`-algebra map `f` such that `ε_B ∘ f = ε_A` and `(f ⊗ f) ∘ Δ_A = Δ_B ∘ f`. -/ structure BialgHom (R A B : Type*) [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] extends A →ₗc[R] B, A →* B /-- Reinterpret a `BialgHom` as a `MonoidHom` -/ add_decl_doc BialgHom.toMonoidHom @[inherit_doc BialgHom] infixr:25 " →ₐc " => BialgHom _ @[inherit_doc] notation:25 A " →ₐc[" R "] " B => BialgHom R A B /-- `BialgHomClass F R A B` asserts `F` is a type of bundled bialgebra homomorphisms from `A` to `B`. -/ class BialgHomClass (F : Type*) (R A B : outParam Type*) [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B] extends CoalgHomClass F R A B, MonoidHomClass F A B : Prop namespace BialgHomClass variable {R A B F : Type*} section variable [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [CoalgebraStruct R A] [CoalgebraStruct R B] [FunLike F A B] [BialgHomClass F R A B] instance (priority := 100) toAlgHomClass : AlgHomClass F R A B where map_mul := map_mul map_one := map_one map_add := map_add map_zero := map_zero commutes := fun c r => by simp only [Algebra.algebraMap_eq_smul_one, map_smul, _root_.map_one] /-- Turn an element of a type `F` satisfying `BialgHomClass F R A B` into an actual `BialgHom`. This is declared as the default coercion from `F` to `A →ₐc[R] B`. -/ @[coe] def toBialgHom (f : F) : A →ₐc[R] B := { CoalgHomClass.toCoalgHom f, AlgHomClass.toAlgHom f with toFun := f } instance instCoeToBialgHom : CoeHead F (A →ₐc[R] B) := ⟨BialgHomClass.toBialgHom⟩ end section variable [CommSemiring R] [Semiring A] [Bialgebra R A] [Semiring B] [Bialgebra R B] [FunLike F A B] [BialgHomClass F R A B] @[simp] theorem counitAlgHom_comp (f : F) : (counitAlgHom R B).comp (f : A →ₐ[R] B) = counitAlgHom R A := AlgHom.toLinearMap_injective (CoalgHomClass.counit_comp f) @[simp] theorem map_comp_comulAlgHom (f : F) : (Algebra.TensorProduct.map f f).comp (comulAlgHom R A) = (comulAlgHom R B).comp f := AlgHom.toLinearMap_injective (CoalgHomClass.map_comp_comul f) end end BialgHomClass namespace BialgHom variable {R A B C D : Type*} [CommSemiring R] [Semiring A] [Algebra R A] [Semiring B] [Algebra R B] [Semiring C] [Algebra R C] [Semiring D] [Algebra R D] [CoalgebraStruct R A] [CoalgebraStruct R B] [CoalgebraStruct R C] [CoalgebraStruct R D] instance funLike : FunLike (A →ₐc[R] B) A B where coe f := f.toFun coe_injective' f g h := by rcases f with ⟨_, _⟩ rcases g with ⟨_, _⟩ simp_all instance bialgHomClass : BialgHomClass (A →ₐc[R] B) R A B where map_add := fun f => f.map_add' map_smulₛₗ := fun f => f.map_smul' counit_comp := fun f => f.counit_comp map_comp_comul := fun f => f.map_comp_comul map_mul := fun f => f.map_mul' map_one := fun f => f.map_one' /-- See Note [custom simps projection] -/ def Simps.apply {R α β : Type*} [CommSemiring R] [Semiring α] [Algebra R α] [Semiring β] [Algebra R β] [CoalgebraStruct R α] [CoalgebraStruct R β] (f : α →ₐc[R] β) : α → β := f initialize_simps_projections BialgHom (toFun → apply) @[simp] protected theorem coe_coe {F : Type*} [FunLike F A B] [BialgHomClass F R A B] (f : F) : ⇑(f : A →ₐc[R] B) = f := rfl @[simp] theorem coe_mk {f : A →ₗc[R] B} (h h₁) : ((⟨f, h, h₁⟩ : A →ₐc[R] B) : A → B) = f := rfl @[norm_cast] theorem coe_mks {f : A → B} (h₀ h₁ h₂ h₃ h₄ h₅) : ⇑(⟨⟨⟨⟨f, h₀⟩, h₁⟩, h₂, h₃⟩, h₄, h₅⟩ : A →ₐc[R] B) = f := rfl @[simp, norm_cast]
Mathlib/RingTheory/Bialgebra/Hom.lean
145
147
theorem coe_coalgHom_mk {f : A →ₗc[R] B} (h h₁) : ((⟨f, h, h₁⟩ : A →ₐc[R] B) : A →ₗc[R] B) = f := by
rfl
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Algebra.Order.Monoid.Unbundled.MinMax import Mathlib.Algebra.Order.Monoid.WithTop import Mathlib.Data.Finset.Image import Mathlib.Data.Multiset.Fold #align_import data.finset.fold from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # The fold operation for a commutative associative operation over a finset. -/ -- TODO: -- assert_not_exists OrderedCommMonoid assert_not_exists MonoidWithZero namespace Finset open Multiset variable {α β γ : Type*} /-! ### fold -/ section Fold variable (op : β → β → β) [hc : Std.Commutative op] [ha : Std.Associative op] local notation a " * " b => op a b /-- `fold op b f s` folds the commutative associative operation `op` over the `f`-image of `s`, i.e. `fold (+) b f {1,2,3} = f 1 + f 2 + f 3 + b`. -/ def fold (b : β) (f : α → β) (s : Finset α) : β := (s.1.map f).fold op b #align finset.fold Finset.fold variable {op} {f : α → β} {b : β} {s : Finset α} {a : α} @[simp] theorem fold_empty : (∅ : Finset α).fold op b f = b := rfl #align finset.fold_empty Finset.fold_empty @[simp] theorem fold_cons (h : a ∉ s) : (cons a s h).fold op b f = f a * s.fold op b f := by dsimp only [fold] rw [cons_val, Multiset.map_cons, fold_cons_left] #align finset.fold_cons Finset.fold_cons @[simp] theorem fold_insert [DecidableEq α] (h : a ∉ s) : (insert a s).fold op b f = f a * s.fold op b f := by unfold fold rw [insert_val, ndinsert_of_not_mem h, Multiset.map_cons, fold_cons_left] #align finset.fold_insert Finset.fold_insert @[simp] theorem fold_singleton : ({a} : Finset α).fold op b f = f a * b := rfl #align finset.fold_singleton Finset.fold_singleton @[simp] theorem fold_map {g : γ ↪ α} {s : Finset γ} : (s.map g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, map, Multiset.map_map] #align finset.fold_map Finset.fold_map @[simp] theorem fold_image [DecidableEq α] {g : γ → α} {s : Finset γ} (H : ∀ x ∈ s, ∀ y ∈ s, g x = g y → x = y) : (s.image g).fold op b f = s.fold op b (f ∘ g) := by simp only [fold, image_val_of_injOn H, Multiset.map_map] #align finset.fold_image Finset.fold_image @[congr] theorem fold_congr {g : α → β} (H : ∀ x ∈ s, f x = g x) : s.fold op b f = s.fold op b g := by rw [fold, fold, map_congr rfl H] #align finset.fold_congr Finset.fold_congr theorem fold_op_distrib {f g : α → β} {b₁ b₂ : β} : (s.fold op (b₁ * b₂) fun x => f x * g x) = s.fold op b₁ f * s.fold op b₂ g := by simp only [fold, fold_distrib] #align finset.fold_op_distrib Finset.fold_op_distrib theorem fold_const [hd : Decidable (s = ∅)] (c : β) (h : op c (op b c) = op b c) : Finset.fold op b (fun _ => c) s = if s = ∅ then b else op b c := by classical induction' s using Finset.induction_on with x s hx IH generalizing hd · simp · simp only [Finset.fold_insert hx, IH, if_false, Finset.insert_ne_empty] split_ifs · rw [hc.comm] · exact h #align finset.fold_const Finset.fold_const theorem fold_hom {op' : γ → γ → γ} [Std.Commutative op'] [Std.Associative op'] {m : β → γ} (hm : ∀ x y, m (op x y) = op' (m x) (m y)) : (s.fold op' (m b) fun x => m (f x)) = m (s.fold op b f) := by rw [fold, fold, ← Multiset.fold_hom op hm, Multiset.map_map] simp only [Function.comp_apply] #align finset.fold_hom Finset.fold_hom theorem fold_disjUnion {s₁ s₂ : Finset α} {b₁ b₂ : β} (h) : (s₁.disjUnion s₂ h).fold op (b₁ * b₂) f = s₁.fold op b₁ f * s₂.fold op b₂ f := (congr_arg _ <| Multiset.map_add _ _ _).trans (Multiset.fold_add _ _ _ _ _) #align finset.fold_disj_union Finset.fold_disjUnion theorem fold_disjiUnion {ι : Type*} {s : Finset ι} {t : ι → Finset α} {b : ι → β} {b₀ : β} (h) : (s.disjiUnion t h).fold op (s.fold op b₀ b) f = s.fold op b₀ fun i => (t i).fold op (b i) f := (congr_arg _ <| Multiset.map_bind _ _ _).trans (Multiset.fold_bind _ _ _ _ _) #align finset.fold_disj_Union Finset.fold_disjiUnion theorem fold_union_inter [DecidableEq α] {s₁ s₂ : Finset α} {b₁ b₂ : β} : ((s₁ ∪ s₂).fold op b₁ f * (s₁ ∩ s₂).fold op b₂ f) = s₁.fold op b₂ f * s₂.fold op b₁ f := by unfold fold rw [← fold_add op, ← Multiset.map_add, union_val, inter_val, union_add_inter, Multiset.map_add, hc.comm, fold_add] #align finset.fold_union_inter Finset.fold_union_inter @[simp] theorem fold_insert_idem [DecidableEq α] [hi : Std.IdempotentOp op] : (insert a s).fold op b f = f a * s.fold op b f := by by_cases h : a ∈ s · rw [← insert_erase h] simp [← ha.assoc, hi.idempotent] · apply fold_insert h #align finset.fold_insert_idem Finset.fold_insert_idem theorem fold_image_idem [DecidableEq α] {g : γ → α} {s : Finset γ} [hi : Std.IdempotentOp op] : (image g s).fold op b f = s.fold op b (f ∘ g) := by induction' s using Finset.cons_induction with x xs hx ih · rw [fold_empty, image_empty, fold_empty] · haveI := Classical.decEq γ rw [fold_cons, cons_eq_insert, image_insert, fold_insert_idem, ih] simp only [Function.comp_apply] #align finset.fold_image_idem Finset.fold_image_idem /-- A stronger version of `Finset.fold_ite`, but relies on an explicit proof of idempotency on the seed element, rather than relying on typeclass idempotency over the whole type. -/ theorem fold_ite' {g : α → β} (hb : op b b = b) (p : α → Prop) [DecidablePred p] : Finset.fold op b (fun i => ite (p i) (f i) (g i)) s = op (Finset.fold op b f (s.filter p)) (Finset.fold op b g (s.filter fun i => ¬p i)) := by classical induction' s using Finset.induction_on with x s hx IH · simp [hb] · simp only [Finset.fold_insert hx] split_ifs with h · have : x ∉ Finset.filter p s := by simp [hx] simp [Finset.filter_insert, h, Finset.fold_insert this, ha.assoc, IH] · have : x ∉ Finset.filter (fun i => ¬ p i) s := by simp [hx] simp [Finset.filter_insert, h, Finset.fold_insert this, IH, ← ha.assoc, hc.comm] #align finset.fold_ite' Finset.fold_ite' /-- A weaker version of `Finset.fold_ite'`, relying on typeclass idempotency over the whole type, instead of solely on the seed element. However, this is easier to use because it does not generate side goals. -/ theorem fold_ite [Std.IdempotentOp op] {g : α → β} (p : α → Prop) [DecidablePred p] : Finset.fold op b (fun i => ite (p i) (f i) (g i)) s = op (Finset.fold op b f (s.filter p)) (Finset.fold op b g (s.filter fun i => ¬p i)) := fold_ite' (Std.IdempotentOp.idempotent _) _ #align finset.fold_ite Finset.fold_ite theorem fold_op_rel_iff_and {r : β → β → Prop} (hr : ∀ {x y z}, r x (op y z) ↔ r x y ∧ r x z) {c : β} : r c (s.fold op b f) ↔ r c b ∧ ∀ x ∈ s, r c (f x) := by classical induction' s using Finset.induction_on with a s ha IH · simp rw [Finset.fold_insert ha, hr, IH, ← and_assoc, @and_comm (r c (f a)), and_assoc] apply and_congr Iff.rfl constructor · rintro ⟨h₁, h₂⟩ intro b hb rw [Finset.mem_insert] at hb rcases hb with (rfl | hb) <;> solve_by_elim · intro h constructor · exact h a (Finset.mem_insert_self _ _) · exact fun b hb => h b <| Finset.mem_insert_of_mem hb #align finset.fold_op_rel_iff_and Finset.fold_op_rel_iff_and theorem fold_op_rel_iff_or {r : β → β → Prop} (hr : ∀ {x y z}, r x (op y z) ↔ r x y ∨ r x z) {c : β} : r c (s.fold op b f) ↔ r c b ∨ ∃ x ∈ s, r c (f x) := by classical induction' s using Finset.induction_on with a s ha IH · simp rw [Finset.fold_insert ha, hr, IH, ← or_assoc, @or_comm (r c (f a)), or_assoc] apply or_congr Iff.rfl constructor · rintro (h₁ | ⟨x, hx, h₂⟩) · use a simp [h₁] · refine ⟨x, by simp [hx], h₂⟩ · rintro ⟨x, hx, h⟩ exact (mem_insert.mp hx).imp (fun hx => by rwa [hx] at h) (fun hx => ⟨x, hx, h⟩) #align finset.fold_op_rel_iff_or Finset.fold_op_rel_iff_or @[simp] theorem fold_union_empty_singleton [DecidableEq α] (s : Finset α) : Finset.fold (· ∪ ·) ∅ singleton s = s := by induction' s using Finset.induction_on with a s has ih · simp only [fold_empty] · rw [fold_insert has, ih, insert_eq] #align finset.fold_union_empty_singleton Finset.fold_union_empty_singleton theorem fold_sup_bot_singleton [DecidableEq α] (s : Finset α) : Finset.fold (· ⊔ ·) ⊥ singleton s = s := fold_union_empty_singleton s #align finset.fold_sup_bot_singleton Finset.fold_sup_bot_singleton section Order variable [LinearOrder β] (c : β) theorem le_fold_min : c ≤ s.fold min b f ↔ c ≤ b ∧ ∀ x ∈ s, c ≤ f x := fold_op_rel_iff_and le_min_iff #align finset.le_fold_min Finset.le_fold_min theorem fold_min_le : s.fold min b f ≤ c ↔ b ≤ c ∨ ∃ x ∈ s, f x ≤ c := by show _ ≥ _ ↔ _ apply fold_op_rel_iff_or intro x y z show _ ≤ _ ↔ _ exact min_le_iff #align finset.fold_min_le Finset.fold_min_le theorem lt_fold_min : c < s.fold min b f ↔ c < b ∧ ∀ x ∈ s, c < f x := fold_op_rel_iff_and lt_min_iff #align finset.lt_fold_min Finset.lt_fold_min theorem fold_min_lt : s.fold min b f < c ↔ b < c ∨ ∃ x ∈ s, f x < c := by show _ > _ ↔ _ apply fold_op_rel_iff_or intro x y z show _ < _ ↔ _ exact min_lt_iff #align finset.fold_min_lt Finset.fold_min_lt theorem fold_max_le : s.fold max b f ≤ c ↔ b ≤ c ∧ ∀ x ∈ s, f x ≤ c := by show _ ≥ _ ↔ _ apply fold_op_rel_iff_and intro x y z show _ ≤ _ ↔ _ exact max_le_iff #align finset.fold_max_le Finset.fold_max_le theorem le_fold_max : c ≤ s.fold max b f ↔ c ≤ b ∨ ∃ x ∈ s, c ≤ f x := fold_op_rel_iff_or le_max_iff #align finset.le_fold_max Finset.le_fold_max theorem fold_max_lt : s.fold max b f < c ↔ b < c ∧ ∀ x ∈ s, f x < c := by show _ > _ ↔ _ apply fold_op_rel_iff_and intro x y z show _ < _ ↔ _ exact max_lt_iff #align finset.fold_max_lt Finset.fold_max_lt theorem lt_fold_max : c < s.fold max b f ↔ c < b ∨ ∃ x ∈ s, c < f x := fold_op_rel_iff_or lt_max_iff #align finset.lt_fold_max Finset.lt_fold_max
Mathlib/Data/Finset/Fold.lean
267
270
theorem fold_max_add [Add β] [CovariantClass β β (Function.swap (· + ·)) (· ≤ ·)] (n : WithBot β) (s : Finset α) : (s.fold max ⊥ fun x : α => ↑(f x) + n) = s.fold max ⊥ ((↑) ∘ f) + n := by
classical induction' s using Finset.induction_on with a s _ ih <;> simp [*, max_add_add_right]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Topology.Order.MonotoneContinuity import Mathlib.Topology.Algebra.Order.LiminfLimsup import Mathlib.Topology.Instances.NNReal import Mathlib.Topology.EMetricSpace.Lipschitz import Mathlib.Topology.Metrizable.Basic import Mathlib.Topology.Order.T5 #align_import topology.instances.ennreal from "leanprover-community/mathlib"@"ec4b2eeb50364487f80421c0b4c41328a611f30d" /-! # Topology on extended non-negative reals -/ noncomputable section open Set Filter Metric Function open scoped Classical Topology ENNReal NNReal Filter variable {α : Type*} {β : Type*} {γ : Type*} namespace ENNReal variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} {x y z : ℝ≥0∞} {ε ε₁ ε₂ : ℝ≥0∞} {s : Set ℝ≥0∞} section TopologicalSpace open TopologicalSpace /-- Topology on `ℝ≥0∞`. Note: this is different from the `EMetricSpace` topology. The `EMetricSpace` topology has `IsOpen {∞}`, while this topology doesn't have singleton elements. -/ instance : TopologicalSpace ℝ≥0∞ := Preorder.topology ℝ≥0∞ instance : OrderTopology ℝ≥0∞ := ⟨rfl⟩ -- short-circuit type class inference instance : T2Space ℝ≥0∞ := inferInstance instance : T5Space ℝ≥0∞ := inferInstance instance : T4Space ℝ≥0∞ := inferInstance instance : SecondCountableTopology ℝ≥0∞ := orderIsoUnitIntervalBirational.toHomeomorph.embedding.secondCountableTopology instance : MetrizableSpace ENNReal := orderIsoUnitIntervalBirational.toHomeomorph.embedding.metrizableSpace theorem embedding_coe : Embedding ((↑) : ℝ≥0 → ℝ≥0∞) := coe_strictMono.embedding_of_ordConnected <| by rw [range_coe']; exact ordConnected_Iio #align ennreal.embedding_coe ENNReal.embedding_coe theorem isOpen_ne_top : IsOpen { a : ℝ≥0∞ | a ≠ ∞ } := isOpen_ne #align ennreal.is_open_ne_top ENNReal.isOpen_ne_top theorem isOpen_Ico_zero : IsOpen (Ico 0 b) := by rw [ENNReal.Ico_eq_Iio] exact isOpen_Iio #align ennreal.is_open_Ico_zero ENNReal.isOpen_Ico_zero theorem openEmbedding_coe : OpenEmbedding ((↑) : ℝ≥0 → ℝ≥0∞) := ⟨embedding_coe, by rw [range_coe']; exact isOpen_Iio⟩ #align ennreal.open_embedding_coe ENNReal.openEmbedding_coe theorem coe_range_mem_nhds : range ((↑) : ℝ≥0 → ℝ≥0∞) ∈ 𝓝 (r : ℝ≥0∞) := IsOpen.mem_nhds openEmbedding_coe.isOpen_range <| mem_range_self _ #align ennreal.coe_range_mem_nhds ENNReal.coe_range_mem_nhds @[norm_cast] theorem tendsto_coe {f : Filter α} {m : α → ℝ≥0} {a : ℝ≥0} : Tendsto (fun a => (m a : ℝ≥0∞)) f (𝓝 ↑a) ↔ Tendsto m f (𝓝 a) := embedding_coe.tendsto_nhds_iff.symm #align ennreal.tendsto_coe ENNReal.tendsto_coe theorem continuous_coe : Continuous ((↑) : ℝ≥0 → ℝ≥0∞) := embedding_coe.continuous #align ennreal.continuous_coe ENNReal.continuous_coe theorem continuous_coe_iff {α} [TopologicalSpace α] {f : α → ℝ≥0} : (Continuous fun a => (f a : ℝ≥0∞)) ↔ Continuous f := embedding_coe.continuous_iff.symm #align ennreal.continuous_coe_iff ENNReal.continuous_coe_iff theorem nhds_coe {r : ℝ≥0} : 𝓝 (r : ℝ≥0∞) = (𝓝 r).map (↑) := (openEmbedding_coe.map_nhds_eq r).symm #align ennreal.nhds_coe ENNReal.nhds_coe theorem tendsto_nhds_coe_iff {α : Type*} {l : Filter α} {x : ℝ≥0} {f : ℝ≥0∞ → α} : Tendsto f (𝓝 ↑x) l ↔ Tendsto (f ∘ (↑) : ℝ≥0 → α) (𝓝 x) l := by rw [nhds_coe, tendsto_map'_iff] #align ennreal.tendsto_nhds_coe_iff ENNReal.tendsto_nhds_coe_iff theorem continuousAt_coe_iff {α : Type*} [TopologicalSpace α] {x : ℝ≥0} {f : ℝ≥0∞ → α} : ContinuousAt f ↑x ↔ ContinuousAt (f ∘ (↑) : ℝ≥0 → α) x := tendsto_nhds_coe_iff #align ennreal.continuous_at_coe_iff ENNReal.continuousAt_coe_iff theorem nhds_coe_coe {r p : ℝ≥0} : 𝓝 ((r : ℝ≥0∞), (p : ℝ≥0∞)) = (𝓝 (r, p)).map fun p : ℝ≥0 × ℝ≥0 => (↑p.1, ↑p.2) := ((openEmbedding_coe.prod openEmbedding_coe).map_nhds_eq (r, p)).symm #align ennreal.nhds_coe_coe ENNReal.nhds_coe_coe theorem continuous_ofReal : Continuous ENNReal.ofReal := (continuous_coe_iff.2 continuous_id).comp continuous_real_toNNReal #align ennreal.continuous_of_real ENNReal.continuous_ofReal theorem tendsto_ofReal {f : Filter α} {m : α → ℝ} {a : ℝ} (h : Tendsto m f (𝓝 a)) : Tendsto (fun a => ENNReal.ofReal (m a)) f (𝓝 (ENNReal.ofReal a)) := (continuous_ofReal.tendsto a).comp h #align ennreal.tendsto_of_real ENNReal.tendsto_ofReal theorem tendsto_toNNReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toNNReal (𝓝 a) (𝓝 a.toNNReal) := by lift a to ℝ≥0 using ha rw [nhds_coe, tendsto_map'_iff] exact tendsto_id #align ennreal.tendsto_to_nnreal ENNReal.tendsto_toNNReal theorem eventuallyEq_of_toReal_eventuallyEq {l : Filter α} {f g : α → ℝ≥0∞} (hfi : ∀ᶠ x in l, f x ≠ ∞) (hgi : ∀ᶠ x in l, g x ≠ ∞) (hfg : (fun x => (f x).toReal) =ᶠ[l] fun x => (g x).toReal) : f =ᶠ[l] g := by filter_upwards [hfi, hgi, hfg] with _ hfx hgx _ rwa [← ENNReal.toReal_eq_toReal hfx hgx] #align ennreal.eventually_eq_of_to_real_eventually_eq ENNReal.eventuallyEq_of_toReal_eventuallyEq theorem continuousOn_toNNReal : ContinuousOn ENNReal.toNNReal { a | a ≠ ∞ } := fun _a ha => ContinuousAt.continuousWithinAt (tendsto_toNNReal ha) #align ennreal.continuous_on_to_nnreal ENNReal.continuousOn_toNNReal theorem tendsto_toReal {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto ENNReal.toReal (𝓝 a) (𝓝 a.toReal) := NNReal.tendsto_coe.2 <| tendsto_toNNReal ha #align ennreal.tendsto_to_real ENNReal.tendsto_toReal lemma continuousOn_toReal : ContinuousOn ENNReal.toReal { a | a ≠ ∞ } := NNReal.continuous_coe.comp_continuousOn continuousOn_toNNReal lemma continuousAt_toReal (hx : x ≠ ∞) : ContinuousAt ENNReal.toReal x := continuousOn_toReal.continuousAt (isOpen_ne_top.mem_nhds_iff.mpr hx) /-- The set of finite `ℝ≥0∞` numbers is homeomorphic to `ℝ≥0`. -/ def neTopHomeomorphNNReal : { a | a ≠ ∞ } ≃ₜ ℝ≥0 where toEquiv := neTopEquivNNReal continuous_toFun := continuousOn_iff_continuous_restrict.1 continuousOn_toNNReal continuous_invFun := continuous_coe.subtype_mk _ #align ennreal.ne_top_homeomorph_nnreal ENNReal.neTopHomeomorphNNReal /-- The set of finite `ℝ≥0∞` numbers is homeomorphic to `ℝ≥0`. -/ def ltTopHomeomorphNNReal : { a | a < ∞ } ≃ₜ ℝ≥0 := by refine (Homeomorph.setCongr ?_).trans neTopHomeomorphNNReal simp only [mem_setOf_eq, lt_top_iff_ne_top] #align ennreal.lt_top_homeomorph_nnreal ENNReal.ltTopHomeomorphNNReal theorem nhds_top : 𝓝 ∞ = ⨅ (a) (_ : a ≠ ∞), 𝓟 (Ioi a) := nhds_top_order.trans <| by simp [lt_top_iff_ne_top, Ioi] #align ennreal.nhds_top ENNReal.nhds_top theorem nhds_top' : 𝓝 ∞ = ⨅ r : ℝ≥0, 𝓟 (Ioi ↑r) := nhds_top.trans <| iInf_ne_top _ #align ennreal.nhds_top' ENNReal.nhds_top' theorem nhds_top_basis : (𝓝 ∞).HasBasis (fun a => a < ∞) fun a => Ioi a := _root_.nhds_top_basis #align ennreal.nhds_top_basis ENNReal.nhds_top_basis theorem tendsto_nhds_top_iff_nnreal {m : α → ℝ≥0∞} {f : Filter α} : Tendsto m f (𝓝 ∞) ↔ ∀ x : ℝ≥0, ∀ᶠ a in f, ↑x < m a := by simp only [nhds_top', tendsto_iInf, tendsto_principal, mem_Ioi] #align ennreal.tendsto_nhds_top_iff_nnreal ENNReal.tendsto_nhds_top_iff_nnreal theorem tendsto_nhds_top_iff_nat {m : α → ℝ≥0∞} {f : Filter α} : Tendsto m f (𝓝 ∞) ↔ ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a := tendsto_nhds_top_iff_nnreal.trans ⟨fun h n => by simpa only [ENNReal.coe_natCast] using h n, fun h x => let ⟨n, hn⟩ := exists_nat_gt x (h n).mono fun y => lt_trans <| by rwa [← ENNReal.coe_natCast, coe_lt_coe]⟩ #align ennreal.tendsto_nhds_top_iff_nat ENNReal.tendsto_nhds_top_iff_nat theorem tendsto_nhds_top {m : α → ℝ≥0∞} {f : Filter α} (h : ∀ n : ℕ, ∀ᶠ a in f, ↑n < m a) : Tendsto m f (𝓝 ∞) := tendsto_nhds_top_iff_nat.2 h #align ennreal.tendsto_nhds_top ENNReal.tendsto_nhds_top theorem tendsto_nat_nhds_top : Tendsto (fun n : ℕ => ↑n) atTop (𝓝 ∞) := tendsto_nhds_top fun n => mem_atTop_sets.2 ⟨n + 1, fun _m hm => mem_setOf.2 <| Nat.cast_lt.2 <| Nat.lt_of_succ_le hm⟩ #align ennreal.tendsto_nat_nhds_top ENNReal.tendsto_nat_nhds_top @[simp, norm_cast] theorem tendsto_coe_nhds_top {f : α → ℝ≥0} {l : Filter α} : Tendsto (fun x => (f x : ℝ≥0∞)) l (𝓝 ∞) ↔ Tendsto f l atTop := by rw [tendsto_nhds_top_iff_nnreal, atTop_basis_Ioi.tendsto_right_iff]; simp #align ennreal.tendsto_coe_nhds_top ENNReal.tendsto_coe_nhds_top theorem tendsto_ofReal_atTop : Tendsto ENNReal.ofReal atTop (𝓝 ∞) := tendsto_coe_nhds_top.2 tendsto_real_toNNReal_atTop #align ennreal.tendsto_of_real_at_top ENNReal.tendsto_ofReal_atTop theorem nhds_zero : 𝓝 (0 : ℝ≥0∞) = ⨅ (a) (_ : a ≠ 0), 𝓟 (Iio a) := nhds_bot_order.trans <| by simp [pos_iff_ne_zero, Iio] #align ennreal.nhds_zero ENNReal.nhds_zero theorem nhds_zero_basis : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) fun a => Iio a := nhds_bot_basis #align ennreal.nhds_zero_basis ENNReal.nhds_zero_basis theorem nhds_zero_basis_Iic : (𝓝 (0 : ℝ≥0∞)).HasBasis (fun a : ℝ≥0∞ => 0 < a) Iic := nhds_bot_basis_Iic #align ennreal.nhds_zero_basis_Iic ENNReal.nhds_zero_basis_Iic -- Porting note (#11215): TODO: add a TC for `≠ ∞`? @[instance] theorem nhdsWithin_Ioi_coe_neBot {r : ℝ≥0} : (𝓝[>] (r : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_self_neBot' ⟨∞, ENNReal.coe_lt_top⟩ #align ennreal.nhds_within_Ioi_coe_ne_bot ENNReal.nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_zero_neBot : (𝓝[>] (0 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot #align ennreal.nhds_within_Ioi_zero_ne_bot ENNReal.nhdsWithin_Ioi_zero_neBot @[instance] theorem nhdsWithin_Ioi_one_neBot : (𝓝[>] (1 : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_nat_neBot (n : ℕ) : (𝓝[>] (n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Ioi_ofNat_nebot (n : ℕ) [n.AtLeastTwo] : (𝓝[>] (OfNat.ofNat n : ℝ≥0∞)).NeBot := nhdsWithin_Ioi_coe_neBot @[instance] theorem nhdsWithin_Iio_neBot [NeZero x] : (𝓝[<] x).NeBot := nhdsWithin_Iio_self_neBot' ⟨0, NeZero.pos x⟩ /-- Closed intervals `Set.Icc (x - ε) (x + ε)`, `ε ≠ 0`, form a basis of neighborhoods of an extended nonnegative real number `x ≠ ∞`. We use `Set.Icc` instead of `Set.Ioo` because this way the statement works for `x = 0`. -/ theorem hasBasis_nhds_of_ne_top' (xt : x ≠ ∞) : (𝓝 x).HasBasis (· ≠ 0) (fun ε => Icc (x - ε) (x + ε)) := by rcases (zero_le x).eq_or_gt with rfl | x0 · simp_rw [zero_tsub, zero_add, ← bot_eq_zero, Icc_bot, ← bot_lt_iff_ne_bot] exact nhds_bot_basis_Iic · refine (nhds_basis_Ioo' ⟨_, x0⟩ ⟨_, xt.lt_top⟩).to_hasBasis ?_ fun ε ε0 => ?_ · rintro ⟨a, b⟩ ⟨ha, hb⟩ rcases exists_between (tsub_pos_of_lt ha) with ⟨ε, ε0, hε⟩ rcases lt_iff_exists_add_pos_lt.1 hb with ⟨δ, δ0, hδ⟩ refine ⟨min ε δ, (lt_min ε0 (coe_pos.2 δ0)).ne', Icc_subset_Ioo ?_ ?_⟩ · exact lt_tsub_comm.2 ((min_le_left _ _).trans_lt hε) · exact (add_le_add_left (min_le_right _ _) _).trans_lt hδ · exact ⟨(x - ε, x + ε), ⟨ENNReal.sub_lt_self xt x0.ne' ε0, lt_add_right xt ε0⟩, Ioo_subset_Icc_self⟩ theorem hasBasis_nhds_of_ne_top (xt : x ≠ ∞) : (𝓝 x).HasBasis (0 < ·) (fun ε => Icc (x - ε) (x + ε)) := by simpa only [pos_iff_ne_zero] using hasBasis_nhds_of_ne_top' xt theorem Icc_mem_nhds (xt : x ≠ ∞) (ε0 : ε ≠ 0) : Icc (x - ε) (x + ε) ∈ 𝓝 x := (hasBasis_nhds_of_ne_top' xt).mem_of_mem ε0 #align ennreal.Icc_mem_nhds ENNReal.Icc_mem_nhds theorem nhds_of_ne_top (xt : x ≠ ∞) : 𝓝 x = ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) := (hasBasis_nhds_of_ne_top xt).eq_biInf #align ennreal.nhds_of_ne_top ENNReal.nhds_of_ne_top theorem biInf_le_nhds : ∀ x : ℝ≥0∞, ⨅ ε > 0, 𝓟 (Icc (x - ε) (x + ε)) ≤ 𝓝 x | ∞ => iInf₂_le_of_le 1 one_pos <| by simpa only [← coe_one, top_sub_coe, top_add, Icc_self, principal_singleton] using pure_le_nhds _ | (x : ℝ≥0) => (nhds_of_ne_top coe_ne_top).ge -- Porting note (#10756): new lemma protected theorem tendsto_nhds_of_Icc {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε)) : Tendsto u f (𝓝 a) := by refine Tendsto.mono_right ?_ (biInf_le_nhds _) simpa only [tendsto_iInf, tendsto_principal] /-- Characterization of neighborhoods for `ℝ≥0∞` numbers. See also `tendsto_order` for a version with strict inequalities. -/ protected theorem tendsto_nhds {f : Filter α} {u : α → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto u f (𝓝 a) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ∈ Icc (a - ε) (a + ε) := by simp only [nhds_of_ne_top ha, tendsto_iInf, tendsto_principal] #align ennreal.tendsto_nhds ENNReal.tendsto_nhds protected theorem tendsto_nhds_zero {f : Filter α} {u : α → ℝ≥0∞} : Tendsto u f (𝓝 0) ↔ ∀ ε > 0, ∀ᶠ x in f, u x ≤ ε := nhds_zero_basis_Iic.tendsto_right_iff #align ennreal.tendsto_nhds_zero ENNReal.tendsto_nhds_zero protected theorem tendsto_atTop [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} {a : ℝ≥0∞} (ha : a ≠ ∞) : Tendsto f atTop (𝓝 a) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ∈ Icc (a - ε) (a + ε) := .trans (atTop_basis.tendsto_iff (hasBasis_nhds_of_ne_top ha)) (by simp only [true_and]; rfl) #align ennreal.tendsto_at_top ENNReal.tendsto_atTop instance : ContinuousAdd ℝ≥0∞ := by refine ⟨continuous_iff_continuousAt.2 ?_⟩ rintro ⟨_ | a, b⟩ · exact tendsto_nhds_top_mono' continuousAt_fst fun p => le_add_right le_rfl rcases b with (_ | b) · exact tendsto_nhds_top_mono' continuousAt_snd fun p => le_add_left le_rfl simp only [ContinuousAt, some_eq_coe, nhds_coe_coe, ← coe_add, tendsto_map'_iff, (· ∘ ·), tendsto_coe, tendsto_add] protected theorem tendsto_atTop_zero [Nonempty β] [SemilatticeSup β] {f : β → ℝ≥0∞} : Tendsto f atTop (𝓝 0) ↔ ∀ ε > 0, ∃ N, ∀ n ≥ N, f n ≤ ε := .trans (atTop_basis.tendsto_iff nhds_zero_basis_Iic) (by simp only [true_and]; rfl) #align ennreal.tendsto_at_top_zero ENNReal.tendsto_atTop_zero theorem tendsto_sub : ∀ {a b : ℝ≥0∞}, (a ≠ ∞ ∨ b ≠ ∞) → Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) (𝓝 (a, b)) (𝓝 (a - b)) | ∞, ∞, h => by simp only [ne_eq, not_true_eq_false, or_self] at h | ∞, (b : ℝ≥0), _ => by rw [top_sub_coe, tendsto_nhds_top_iff_nnreal] refine fun x => ((lt_mem_nhds <| @coe_lt_top (b + 1 + x)).prod_nhds (ge_mem_nhds <| coe_lt_coe.2 <| lt_add_one b)).mono fun y hy => ?_ rw [lt_tsub_iff_left] calc y.2 + x ≤ ↑(b + 1) + x := add_le_add_right hy.2 _ _ < y.1 := hy.1 | (a : ℝ≥0), ∞, _ => by rw [sub_top] refine (tendsto_pure.2 ?_).mono_right (pure_le_nhds _) exact ((gt_mem_nhds <| coe_lt_coe.2 <| lt_add_one a).prod_nhds (lt_mem_nhds <| @coe_lt_top (a + 1))).mono fun x hx => tsub_eq_zero_iff_le.2 (hx.1.trans hx.2).le | (a : ℝ≥0), (b : ℝ≥0), _ => by simp only [nhds_coe_coe, tendsto_map'_iff, ← ENNReal.coe_sub, (· ∘ ·), tendsto_coe] exact continuous_sub.tendsto (a, b) #align ennreal.tendsto_sub ENNReal.tendsto_sub protected theorem Tendsto.sub {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (hmb : Tendsto mb f (𝓝 b)) (h : a ≠ ∞ ∨ b ≠ ∞) : Tendsto (fun a => ma a - mb a) f (𝓝 (a - b)) := show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 - p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a - b)) from Tendsto.comp (ENNReal.tendsto_sub h) (hma.prod_mk_nhds hmb) #align ennreal.tendsto.sub ENNReal.Tendsto.sub protected theorem tendsto_mul (ha : a ≠ 0 ∨ b ≠ ∞) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (a, b)) (𝓝 (a * b)) := by have ht : ∀ b : ℝ≥0∞, b ≠ 0 → Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) (𝓝 (∞, b)) (𝓝 ∞) := fun b hb => by refine tendsto_nhds_top_iff_nnreal.2 fun n => ?_ rcases lt_iff_exists_nnreal_btwn.1 (pos_iff_ne_zero.2 hb) with ⟨ε, hε, hεb⟩ have : ∀ᶠ c : ℝ≥0∞ × ℝ≥0∞ in 𝓝 (∞, b), ↑n / ↑ε < c.1 ∧ ↑ε < c.2 := (lt_mem_nhds <| div_lt_top coe_ne_top hε.ne').prod_nhds (lt_mem_nhds hεb) refine this.mono fun c hc => ?_ exact (ENNReal.div_mul_cancel hε.ne' coe_ne_top).symm.trans_lt (mul_lt_mul hc.1 hc.2) induction a with | top => simp only [ne_eq, or_false, not_true_eq_false] at hb; simp [ht b hb, top_mul hb] | coe a => induction b with | top => simp only [ne_eq, or_false, not_true_eq_false] at ha simpa [(· ∘ ·), mul_comm, mul_top ha] using (ht a ha).comp (continuous_swap.tendsto (ofNNReal a, ∞)) | coe b => simp only [nhds_coe_coe, ← coe_mul, tendsto_coe, tendsto_map'_iff, (· ∘ ·), tendsto_mul] #align ennreal.tendsto_mul ENNReal.tendsto_mul protected theorem Tendsto.mul {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) (hmb : Tendsto mb f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun a => ma a * mb a) f (𝓝 (a * b)) := show Tendsto ((fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 * p.2) ∘ fun a => (ma a, mb a)) f (𝓝 (a * b)) from Tendsto.comp (ENNReal.tendsto_mul ha hb) (hma.prod_mk_nhds hmb) #align ennreal.tendsto.mul ENNReal.Tendsto.mul theorem _root_.ContinuousOn.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} {s : Set α} (hf : ContinuousOn f s) (hg : ContinuousOn g s) (h₁ : ∀ x ∈ s, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x ∈ s, g x ≠ 0 ∨ f x ≠ ∞) : ContinuousOn (fun x => f x * g x) s := fun x hx => ENNReal.Tendsto.mul (hf x hx) (h₁ x hx) (hg x hx) (h₂ x hx) #align continuous_on.ennreal_mul ContinuousOn.ennreal_mul theorem _root_.Continuous.ennreal_mul [TopologicalSpace α] {f g : α → ℝ≥0∞} (hf : Continuous f) (hg : Continuous g) (h₁ : ∀ x, f x ≠ 0 ∨ g x ≠ ∞) (h₂ : ∀ x, g x ≠ 0 ∨ f x ≠ ∞) : Continuous fun x => f x * g x := continuous_iff_continuousAt.2 fun x => ENNReal.Tendsto.mul hf.continuousAt (h₁ x) hg.continuousAt (h₂ x) #align continuous.ennreal_mul Continuous.ennreal_mul protected theorem Tendsto.const_mul {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 b)) (hb : b ≠ 0 ∨ a ≠ ∞) : Tendsto (fun b => a * m b) f (𝓝 (a * b)) := by_cases (fun (this : a = 0) => by simp [this, tendsto_const_nhds]) fun ha : a ≠ 0 => ENNReal.Tendsto.mul tendsto_const_nhds (Or.inl ha) hm hb #align ennreal.tendsto.const_mul ENNReal.Tendsto.const_mul protected theorem Tendsto.mul_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ ∞) : Tendsto (fun x => m x * b) f (𝓝 (a * b)) := by simpa only [mul_comm] using ENNReal.Tendsto.const_mul hm ha #align ennreal.tendsto.mul_const ENNReal.Tendsto.mul_const theorem tendsto_finset_prod_of_ne_top {ι : Type*} {f : ι → α → ℝ≥0∞} {x : Filter α} {a : ι → ℝ≥0∞} (s : Finset ι) (h : ∀ i ∈ s, Tendsto (f i) x (𝓝 (a i))) (h' : ∀ i ∈ s, a i ≠ ∞) : Tendsto (fun b => ∏ c ∈ s, f c b) x (𝓝 (∏ c ∈ s, a c)) := by induction' s using Finset.induction with a s has IH · simp [tendsto_const_nhds] simp only [Finset.prod_insert has] apply Tendsto.mul (h _ (Finset.mem_insert_self _ _)) · right exact (prod_lt_top fun i hi => h' _ (Finset.mem_insert_of_mem hi)).ne · exact IH (fun i hi => h _ (Finset.mem_insert_of_mem hi)) fun i hi => h' _ (Finset.mem_insert_of_mem hi) · exact Or.inr (h' _ (Finset.mem_insert_self _ _)) #align ennreal.tendsto_finset_prod_of_ne_top ENNReal.tendsto_finset_prod_of_ne_top protected theorem continuousAt_const_mul {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) : ContinuousAt (a * ·) b := Tendsto.const_mul tendsto_id h.symm #align ennreal.continuous_at_const_mul ENNReal.continuousAt_const_mul protected theorem continuousAt_mul_const {a b : ℝ≥0∞} (h : a ≠ ∞ ∨ b ≠ 0) : ContinuousAt (fun x => x * a) b := Tendsto.mul_const tendsto_id h.symm #align ennreal.continuous_at_mul_const ENNReal.continuousAt_mul_const protected theorem continuous_const_mul {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous (a * ·) := continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_const_mul (Or.inl ha) #align ennreal.continuous_const_mul ENNReal.continuous_const_mul protected theorem continuous_mul_const {a : ℝ≥0∞} (ha : a ≠ ∞) : Continuous fun x => x * a := continuous_iff_continuousAt.2 fun _ => ENNReal.continuousAt_mul_const (Or.inl ha) #align ennreal.continuous_mul_const ENNReal.continuous_mul_const protected theorem continuous_div_const (c : ℝ≥0∞) (c_ne_zero : c ≠ 0) : Continuous fun x : ℝ≥0∞ => x / c := by simp_rw [div_eq_mul_inv, continuous_iff_continuousAt] intro x exact ENNReal.continuousAt_mul_const (Or.intro_left _ (inv_ne_top.mpr c_ne_zero)) #align ennreal.continuous_div_const ENNReal.continuous_div_const @[continuity] theorem continuous_pow (n : ℕ) : Continuous fun a : ℝ≥0∞ => a ^ n := by induction' n with n IH · simp [continuous_const] simp_rw [pow_add, pow_one, continuous_iff_continuousAt] intro x refine ENNReal.Tendsto.mul (IH.tendsto _) ?_ tendsto_id ?_ <;> by_cases H : x = 0 · simp only [H, zero_ne_top, Ne, or_true_iff, not_false_iff] · exact Or.inl fun h => H (pow_eq_zero h) · simp only [H, pow_eq_top_iff, zero_ne_top, false_or_iff, eq_self_iff_true, not_true, Ne, not_false_iff, false_and_iff] · simp only [H, true_or_iff, Ne, not_false_iff] #align ennreal.continuous_pow ENNReal.continuous_pow theorem continuousOn_sub : ContinuousOn (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) { p : ℝ≥0∞ × ℝ≥0∞ | p ≠ ⟨∞, ∞⟩ } := by rw [ContinuousOn] rintro ⟨x, y⟩ hp simp only [Ne, Set.mem_setOf_eq, Prod.mk.inj_iff] at hp exact tendsto_nhdsWithin_of_tendsto_nhds (tendsto_sub (not_and_or.mp hp)) #align ennreal.continuous_on_sub ENNReal.continuousOn_sub theorem continuous_sub_left {a : ℝ≥0∞} (a_ne_top : a ≠ ∞) : Continuous (a - ·) := by change Continuous (Function.uncurry Sub.sub ∘ (a, ·)) refine continuousOn_sub.comp_continuous (Continuous.Prod.mk a) fun x => ?_ simp only [a_ne_top, Ne, mem_setOf_eq, Prod.mk.inj_iff, false_and_iff, not_false_iff] #align ennreal.continuous_sub_left ENNReal.continuous_sub_left theorem continuous_nnreal_sub {a : ℝ≥0} : Continuous fun x : ℝ≥0∞ => (a : ℝ≥0∞) - x := continuous_sub_left coe_ne_top #align ennreal.continuous_nnreal_sub ENNReal.continuous_nnreal_sub theorem continuousOn_sub_left (a : ℝ≥0∞) : ContinuousOn (a - ·) { x : ℝ≥0∞ | x ≠ ∞ } := by rw [show (fun x => a - x) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨a, x⟩ by rfl] apply ContinuousOn.comp continuousOn_sub (Continuous.continuousOn (Continuous.Prod.mk a)) rintro _ h (_ | _) exact h none_eq_top #align ennreal.continuous_on_sub_left ENNReal.continuousOn_sub_left theorem continuous_sub_right (a : ℝ≥0∞) : Continuous fun x : ℝ≥0∞ => x - a := by by_cases a_infty : a = ∞ · simp [a_infty, continuous_const] · rw [show (fun x => x - a) = (fun p : ℝ≥0∞ × ℝ≥0∞ => p.fst - p.snd) ∘ fun x => ⟨x, a⟩ by rfl] apply ContinuousOn.comp_continuous continuousOn_sub (continuous_id'.prod_mk continuous_const) intro x simp only [a_infty, Ne, mem_setOf_eq, Prod.mk.inj_iff, and_false_iff, not_false_iff] #align ennreal.continuous_sub_right ENNReal.continuous_sub_right protected theorem Tendsto.pow {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} {n : ℕ} (hm : Tendsto m f (𝓝 a)) : Tendsto (fun x => m x ^ n) f (𝓝 (a ^ n)) := ((continuous_pow n).tendsto a).comp hm #align ennreal.tendsto.pow ENNReal.Tendsto.pow theorem le_of_forall_lt_one_mul_le {x y : ℝ≥0∞} (h : ∀ a < 1, a * x ≤ y) : x ≤ y := by have : Tendsto (· * x) (𝓝[<] 1) (𝓝 (1 * x)) := (ENNReal.continuousAt_mul_const (Or.inr one_ne_zero)).mono_left inf_le_left rw [one_mul] at this exact le_of_tendsto this (eventually_nhdsWithin_iff.2 <| eventually_of_forall h) #align ennreal.le_of_forall_lt_one_mul_le ENNReal.le_of_forall_lt_one_mul_le theorem iInf_mul_left' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) (h0 : a = 0 → Nonempty ι) : ⨅ i, a * f i = a * ⨅ i, f i := by by_cases H : a = ∞ ∧ ⨅ i, f i = 0 · rcases h H.1 H.2 with ⟨i, hi⟩ rw [H.2, mul_zero, ← bot_eq_zero, iInf_eq_bot] exact fun b hb => ⟨i, by rwa [hi, mul_zero, ← bot_eq_zero]⟩ · rw [not_and_or] at H cases isEmpty_or_nonempty ι · rw [iInf_of_empty, iInf_of_empty, mul_top] exact mt h0 (not_nonempty_iff.2 ‹_›) · exact (ENNReal.mul_left_mono.map_iInf_of_continuousAt' (ENNReal.continuousAt_const_mul H)).symm #align ennreal.infi_mul_left' ENNReal.iInf_mul_left' theorem iInf_mul_left {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, a * f i = a * ⨅ i, f i := iInf_mul_left' h fun _ => ‹Nonempty ι› #align ennreal.infi_mul_left ENNReal.iInf_mul_left theorem iInf_mul_right' {ι} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) (h0 : a = 0 → Nonempty ι) : ⨅ i, f i * a = (⨅ i, f i) * a := by simpa only [mul_comm a] using iInf_mul_left' h h0 #align ennreal.infi_mul_right' ENNReal.iInf_mul_right' theorem iInf_mul_right {ι} [Nonempty ι] {f : ι → ℝ≥0∞} {a : ℝ≥0∞} (h : a = ∞ → ⨅ i, f i = 0 → ∃ i, f i = 0) : ⨅ i, f i * a = (⨅ i, f i) * a := iInf_mul_right' h fun _ => ‹Nonempty ι› #align ennreal.infi_mul_right ENNReal.iInf_mul_right theorem inv_map_iInf {ι : Sort*} {x : ι → ℝ≥0∞} : (iInf x)⁻¹ = ⨆ i, (x i)⁻¹ := OrderIso.invENNReal.map_iInf x #align ennreal.inv_map_infi ENNReal.inv_map_iInf theorem inv_map_iSup {ι : Sort*} {x : ι → ℝ≥0∞} : (iSup x)⁻¹ = ⨅ i, (x i)⁻¹ := OrderIso.invENNReal.map_iSup x #align ennreal.inv_map_supr ENNReal.inv_map_iSup theorem inv_limsup {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : (limsup x l)⁻¹ = liminf (fun i => (x i)⁻¹) l := OrderIso.invENNReal.limsup_apply #align ennreal.inv_limsup ENNReal.inv_limsup theorem inv_liminf {ι : Sort _} {x : ι → ℝ≥0∞} {l : Filter ι} : (liminf x l)⁻¹ = limsup (fun i => (x i)⁻¹) l := OrderIso.invENNReal.liminf_apply #align ennreal.inv_liminf ENNReal.inv_liminf instance : ContinuousInv ℝ≥0∞ := ⟨OrderIso.invENNReal.continuous⟩ @[simp] -- Porting note (#11215): TODO: generalize to `[InvolutiveInv _] [ContinuousInv _]` protected theorem tendsto_inv_iff {f : Filter α} {m : α → ℝ≥0∞} {a : ℝ≥0∞} : Tendsto (fun x => (m x)⁻¹) f (𝓝 a⁻¹) ↔ Tendsto m f (𝓝 a) := ⟨fun h => by simpa only [inv_inv] using Tendsto.inv h, Tendsto.inv⟩ #align ennreal.tendsto_inv_iff ENNReal.tendsto_inv_iff protected theorem Tendsto.div {f : Filter α} {ma : α → ℝ≥0∞} {mb : α → ℝ≥0∞} {a b : ℝ≥0∞} (hma : Tendsto ma f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) (hmb : Tendsto mb f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun a => ma a / mb a) f (𝓝 (a / b)) := by apply Tendsto.mul hma _ (ENNReal.tendsto_inv_iff.2 hmb) _ <;> simp [ha, hb] #align ennreal.tendsto.div ENNReal.Tendsto.div protected theorem Tendsto.const_div {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 b)) (hb : b ≠ ∞ ∨ a ≠ ∞) : Tendsto (fun b => a / m b) f (𝓝 (a / b)) := by apply Tendsto.const_mul (ENNReal.tendsto_inv_iff.2 hm) simp [hb] #align ennreal.tendsto.const_div ENNReal.Tendsto.const_div protected theorem Tendsto.div_const {f : Filter α} {m : α → ℝ≥0∞} {a b : ℝ≥0∞} (hm : Tendsto m f (𝓝 a)) (ha : a ≠ 0 ∨ b ≠ 0) : Tendsto (fun x => m x / b) f (𝓝 (a / b)) := by apply Tendsto.mul_const hm simp [ha] #align ennreal.tendsto.div_const ENNReal.Tendsto.div_const protected theorem tendsto_inv_nat_nhds_zero : Tendsto (fun n : ℕ => (n : ℝ≥0∞)⁻¹) atTop (𝓝 0) := ENNReal.inv_top ▸ ENNReal.tendsto_inv_iff.2 tendsto_nat_nhds_top #align ennreal.tendsto_inv_nat_nhds_zero ENNReal.tendsto_inv_nat_nhds_zero theorem iSup_add {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : iSup s + a = ⨆ b, s b + a := Monotone.map_iSup_of_continuousAt' (continuousAt_id.add continuousAt_const) <| monotone_id.add monotone_const #align ennreal.supr_add ENNReal.iSup_add theorem biSup_add' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} : (⨆ (i) (_ : p i), f i) + a = ⨆ (i) (_ : p i), f i + a := by haveI : Nonempty { i // p i } := nonempty_subtype.2 h simp only [iSup_subtype', iSup_add] #align ennreal.bsupr_add' ENNReal.biSup_add' theorem add_biSup' {ι : Sort*} {p : ι → Prop} (h : ∃ i, p i) {f : ι → ℝ≥0∞} : (a + ⨆ (i) (_ : p i), f i) = ⨆ (i) (_ : p i), a + f i := by simp only [add_comm a, biSup_add' h] #align ennreal.add_bsupr' ENNReal.add_biSup' theorem biSup_add {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} : (⨆ i ∈ s, f i) + a = ⨆ i ∈ s, f i + a := biSup_add' hs #align ennreal.bsupr_add ENNReal.biSup_add theorem add_biSup {ι} {s : Set ι} (hs : s.Nonempty) {f : ι → ℝ≥0∞} : (a + ⨆ i ∈ s, f i) = ⨆ i ∈ s, a + f i := add_biSup' hs #align ennreal.add_bsupr ENNReal.add_biSup theorem sSup_add {s : Set ℝ≥0∞} (hs : s.Nonempty) : sSup s + a = ⨆ b ∈ s, b + a := by rw [sSup_eq_iSup, biSup_add hs] #align ennreal.Sup_add ENNReal.sSup_add theorem add_iSup {ι : Sort*} {s : ι → ℝ≥0∞} [Nonempty ι] : a + iSup s = ⨆ b, a + s b := by rw [add_comm, iSup_add]; simp [add_comm] #align ennreal.add_supr ENNReal.add_iSup theorem iSup_add_iSup_le {ι ι' : Sort*} [Nonempty ι] [Nonempty ι'] {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i j, f i + g j ≤ a) : iSup f + iSup g ≤ a := by simp_rw [iSup_add, add_iSup]; exact iSup₂_le h #align ennreal.supr_add_supr_le ENNReal.iSup_add_iSup_le theorem biSup_add_biSup_le' {ι ι'} {p : ι → Prop} {q : ι' → Prop} (hp : ∃ i, p i) (hq : ∃ j, q j) {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i, p i → ∀ j, q j → f i + g j ≤ a) : ((⨆ (i) (_ : p i), f i) + ⨆ (j) (_ : q j), g j) ≤ a := by simp_rw [biSup_add' hp, add_biSup' hq] exact iSup₂_le fun i hi => iSup₂_le (h i hi) #align ennreal.bsupr_add_bsupr_le' ENNReal.biSup_add_biSup_le' theorem biSup_add_biSup_le {ι ι'} {s : Set ι} {t : Set ι'} (hs : s.Nonempty) (ht : t.Nonempty) {f : ι → ℝ≥0∞} {g : ι' → ℝ≥0∞} {a : ℝ≥0∞} (h : ∀ i ∈ s, ∀ j ∈ t, f i + g j ≤ a) : ((⨆ i ∈ s, f i) + ⨆ j ∈ t, g j) ≤ a := biSup_add_biSup_le' hs ht h #align ennreal.bsupr_add_bsupr_le ENNReal.biSup_add_biSup_le theorem iSup_add_iSup {ι : Sort*} {f g : ι → ℝ≥0∞} (h : ∀ i j, ∃ k, f i + g j ≤ f k + g k) : iSup f + iSup g = ⨆ a, f a + g a := by cases isEmpty_or_nonempty ι · simp only [iSup_of_empty, bot_eq_zero, zero_add] · refine le_antisymm ?_ (iSup_le fun a => add_le_add (le_iSup _ _) (le_iSup _ _)) refine iSup_add_iSup_le fun i j => ?_ rcases h i j with ⟨k, hk⟩ exact le_iSup_of_le k hk #align ennreal.supr_add_supr ENNReal.iSup_add_iSup theorem iSup_add_iSup_of_monotone {ι : Type*} [SemilatticeSup ι] {f g : ι → ℝ≥0∞} (hf : Monotone f) (hg : Monotone g) : iSup f + iSup g = ⨆ a, f a + g a := iSup_add_iSup fun i j => ⟨i ⊔ j, add_le_add (hf <| le_sup_left) (hg <| le_sup_right)⟩ #align ennreal.supr_add_supr_of_monotone ENNReal.iSup_add_iSup_of_monotone theorem finset_sum_iSup_nat {α} {ι} [SemilatticeSup ι] {s : Finset α} {f : α → ι → ℝ≥0∞} (hf : ∀ a, Monotone (f a)) : (∑ a ∈ s, iSup (f a)) = ⨆ n, ∑ a ∈ s, f a n := by refine Finset.induction_on s ?_ ?_ · simp · intro a s has ih simp only [Finset.sum_insert has] rw [ih, iSup_add_iSup_of_monotone (hf a)] intro i j h exact Finset.sum_le_sum fun a _ => hf a h #align ennreal.finset_sum_supr_nat ENNReal.finset_sum_iSup_nat theorem mul_iSup {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : a * iSup f = ⨆ i, a * f i := by by_cases hf : ∀ i, f i = 0 · obtain rfl : f = fun _ => 0 := funext hf simp only [iSup_zero_eq_zero, mul_zero] · refine (monotone_id.const_mul' _).map_iSup_of_continuousAt ?_ (mul_zero a) refine ENNReal.Tendsto.const_mul tendsto_id (Or.inl ?_) exact mt iSup_eq_zero.1 hf #align ennreal.mul_supr ENNReal.mul_iSup theorem mul_sSup {s : Set ℝ≥0∞} {a : ℝ≥0∞} : a * sSup s = ⨆ i ∈ s, a * i := by simp only [sSup_eq_iSup, mul_iSup] #align ennreal.mul_Sup ENNReal.mul_sSup theorem iSup_mul {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : iSup f * a = ⨆ i, f i * a := by rw [mul_comm, mul_iSup]; congr; funext; rw [mul_comm] #align ennreal.supr_mul ENNReal.iSup_mul theorem smul_iSup {ι : Sort*} {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (f : ι → ℝ≥0∞) (c : R) : (c • ⨆ i, f i) = ⨆ i, c • f i := by -- Porting note: replaced `iSup _` with `iSup f` simp only [← smul_one_mul c (f _), ← smul_one_mul c (iSup f), ENNReal.mul_iSup] #align ennreal.smul_supr ENNReal.smul_iSup theorem smul_sSup {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (s : Set ℝ≥0∞) (c : R) : c • sSup s = ⨆ i ∈ s, c • i := by -- Porting note: replaced `_` with `s` simp_rw [← smul_one_mul c (sSup s), ENNReal.mul_sSup, smul_one_mul] #align ennreal.smul_Sup ENNReal.smul_sSup theorem iSup_div {ι : Sort*} {f : ι → ℝ≥0∞} {a : ℝ≥0∞} : iSup f / a = ⨆ i, f i / a := iSup_mul #align ennreal.supr_div ENNReal.iSup_div protected theorem tendsto_coe_sub {b : ℝ≥0∞} : Tendsto (fun b : ℝ≥0∞ => ↑r - b) (𝓝 b) (𝓝 (↑r - b)) := continuous_nnreal_sub.tendsto _ #align ennreal.tendsto_coe_sub ENNReal.tendsto_coe_sub theorem sub_iSup {ι : Sort*} [Nonempty ι] {b : ι → ℝ≥0∞} (hr : a < ∞) : (a - ⨆ i, b i) = ⨅ i, a - b i := antitone_const_tsub.map_iSup_of_continuousAt' (continuous_sub_left hr.ne).continuousAt #align ennreal.sub_supr ENNReal.sub_iSup theorem exists_countable_dense_no_zero_top : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ 0 ∉ s ∧ ∞ ∉ s := by obtain ⟨s, s_count, s_dense, hs⟩ : ∃ s : Set ℝ≥0∞, s.Countable ∧ Dense s ∧ (∀ x, IsBot x → x ∉ s) ∧ ∀ x, IsTop x → x ∉ s := exists_countable_dense_no_bot_top ℝ≥0∞ exact ⟨s, s_count, s_dense, fun h => hs.1 0 (by simp) h, fun h => hs.2 ∞ (by simp) h⟩ #align ennreal.exists_countable_dense_no_zero_top ENNReal.exists_countable_dense_no_zero_top theorem exists_lt_add_of_lt_add {x y z : ℝ≥0∞} (h : x < y + z) (hy : y ≠ 0) (hz : z ≠ 0) : ∃ y' z', y' < y ∧ z' < z ∧ x < y' + z' := by have : NeZero y := ⟨hy⟩ have : NeZero z := ⟨hz⟩ have A : Tendsto (fun p : ℝ≥0∞ × ℝ≥0∞ => p.1 + p.2) (𝓝[<] y ×ˢ 𝓝[<] z) (𝓝 (y + z)) := by apply Tendsto.mono_left _ (Filter.prod_mono nhdsWithin_le_nhds nhdsWithin_le_nhds) rw [← nhds_prod_eq] exact tendsto_add rcases ((A.eventually (lt_mem_nhds h)).and (Filter.prod_mem_prod self_mem_nhdsWithin self_mem_nhdsWithin)).exists with ⟨⟨y', z'⟩, hx, hy', hz'⟩ exact ⟨y', z', hy', hz', hx⟩ #align ennreal.exists_lt_add_of_lt_add ENNReal.exists_lt_add_of_lt_add theorem ofReal_cinfi (f : α → ℝ) [Nonempty α] : ENNReal.ofReal (⨅ i, f i) = ⨅ i, ENNReal.ofReal (f i) := by by_cases hf : BddBelow (range f) · exact Monotone.map_ciInf_of_continuousAt ENNReal.continuous_ofReal.continuousAt (fun i j hij => ENNReal.ofReal_le_ofReal hij) hf · symm rw [Real.iInf_of_not_bddBelow hf, ENNReal.ofReal_zero, ← ENNReal.bot_eq_zero, iInf_eq_bot] obtain ⟨y, hy_mem, hy_neg⟩ := not_bddBelow_iff.mp hf 0 obtain ⟨i, rfl⟩ := mem_range.mpr hy_mem refine fun x hx => ⟨i, ?_⟩ rwa [ENNReal.ofReal_of_nonpos hy_neg.le] #align ennreal.of_real_cinfi ENNReal.ofReal_cinfi end TopologicalSpace section Liminf theorem exists_frequently_lt_of_liminf_ne_top {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hx : liminf (fun n => (Real.nnabs (x n) : ℝ≥0∞)) l ≠ ∞) : ∃ R, ∃ᶠ n in l, x n < R := by by_contra h simp_rw [not_exists, not_frequently, not_lt] at h refine hx (ENNReal.eq_top_of_forall_nnreal_le fun r => le_limsInf_of_le (by isBoundedDefault) ?_) simp only [eventually_map, ENNReal.coe_le_coe] filter_upwards [h r] with i hi using hi.trans (le_abs_self (x i)) #align ennreal.exists_frequently_lt_of_liminf_ne_top ENNReal.exists_frequently_lt_of_liminf_ne_top theorem exists_frequently_lt_of_liminf_ne_top' {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hx : liminf (fun n => (Real.nnabs (x n) : ℝ≥0∞)) l ≠ ∞) : ∃ R, ∃ᶠ n in l, R < x n := by by_contra h simp_rw [not_exists, not_frequently, not_lt] at h refine hx (ENNReal.eq_top_of_forall_nnreal_le fun r => le_limsInf_of_le (by isBoundedDefault) ?_) simp only [eventually_map, ENNReal.coe_le_coe] filter_upwards [h (-r)] with i hi using(le_neg.1 hi).trans (neg_le_abs _) #align ennreal.exists_frequently_lt_of_liminf_ne_top' ENNReal.exists_frequently_lt_of_liminf_ne_top' theorem exists_upcrossings_of_not_bounded_under {ι : Type*} {l : Filter ι} {x : ι → ℝ} (hf : liminf (fun i => (Real.nnabs (x i) : ℝ≥0∞)) l ≠ ∞) (hbdd : ¬IsBoundedUnder (· ≤ ·) l fun i => |x i|) : ∃ a b : ℚ, a < b ∧ (∃ᶠ i in l, x i < a) ∧ ∃ᶠ i in l, ↑b < x i := by rw [isBoundedUnder_le_abs, not_and_or] at hbdd obtain hbdd | hbdd := hbdd · obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top hf obtain ⟨q, hq⟩ := exists_rat_gt R refine ⟨q, q + 1, (lt_add_iff_pos_right _).2 zero_lt_one, ?_, ?_⟩ · refine fun hcon => hR ?_ filter_upwards [hcon] with x hx using not_lt.2 (lt_of_lt_of_le hq (not_lt.1 hx)).le · simp only [IsBoundedUnder, IsBounded, eventually_map, eventually_atTop, ge_iff_le, not_exists, not_forall, not_le, exists_prop] at hbdd refine fun hcon => hbdd ↑(q + 1) ?_ filter_upwards [hcon] with x hx using not_lt.1 hx · obtain ⟨R, hR⟩ := exists_frequently_lt_of_liminf_ne_top' hf obtain ⟨q, hq⟩ := exists_rat_lt R refine ⟨q - 1, q, (sub_lt_self_iff _).2 zero_lt_one, ?_, ?_⟩ · simp only [IsBoundedUnder, IsBounded, eventually_map, eventually_atTop, ge_iff_le, not_exists, not_forall, not_le, exists_prop] at hbdd refine fun hcon => hbdd ↑(q - 1) ?_ filter_upwards [hcon] with x hx using not_lt.1 hx · refine fun hcon => hR ?_ filter_upwards [hcon] with x hx using not_lt.2 ((not_lt.1 hx).trans hq.le) #align ennreal.exists_upcrossings_of_not_bounded_under ENNReal.exists_upcrossings_of_not_bounded_under end Liminf section tsum variable {f g : α → ℝ≥0∞} @[norm_cast] protected theorem hasSum_coe {f : α → ℝ≥0} {r : ℝ≥0} : HasSum (fun a => (f a : ℝ≥0∞)) ↑r ↔ HasSum f r := by simp only [HasSum, ← coe_finset_sum, tendsto_coe] #align ennreal.has_sum_coe ENNReal.hasSum_coe protected theorem tsum_coe_eq {f : α → ℝ≥0} (h : HasSum f r) : (∑' a, (f a : ℝ≥0∞)) = r := (ENNReal.hasSum_coe.2 h).tsum_eq #align ennreal.tsum_coe_eq ENNReal.tsum_coe_eq protected theorem coe_tsum {f : α → ℝ≥0} : Summable f → ↑(tsum f) = ∑' a, (f a : ℝ≥0∞) | ⟨r, hr⟩ => by rw [hr.tsum_eq, ENNReal.tsum_coe_eq hr] #align ennreal.coe_tsum ENNReal.coe_tsum protected theorem hasSum : HasSum f (⨆ s : Finset α, ∑ a ∈ s, f a) := tendsto_atTop_iSup fun _ _ => Finset.sum_le_sum_of_subset #align ennreal.has_sum ENNReal.hasSum @[simp] protected theorem summable : Summable f := ⟨_, ENNReal.hasSum⟩ #align ennreal.summable ENNReal.summable theorem tsum_coe_ne_top_iff_summable {f : β → ℝ≥0} : (∑' b, (f b : ℝ≥0∞)) ≠ ∞ ↔ Summable f := by refine ⟨fun h => ?_, fun h => ENNReal.coe_tsum h ▸ ENNReal.coe_ne_top⟩ lift ∑' b, (f b : ℝ≥0∞) to ℝ≥0 using h with a ha refine ⟨a, ENNReal.hasSum_coe.1 ?_⟩ rw [ha] exact ENNReal.summable.hasSum #align ennreal.tsum_coe_ne_top_iff_summable ENNReal.tsum_coe_ne_top_iff_summable protected theorem tsum_eq_iSup_sum : ∑' a, f a = ⨆ s : Finset α, ∑ a ∈ s, f a := ENNReal.hasSum.tsum_eq #align ennreal.tsum_eq_supr_sum ENNReal.tsum_eq_iSup_sum protected theorem tsum_eq_iSup_sum' {ι : Type*} (s : ι → Finset α) (hs : ∀ t, ∃ i, t ⊆ s i) : ∑' a, f a = ⨆ i, ∑ a ∈ s i, f a := by rw [ENNReal.tsum_eq_iSup_sum] symm change ⨆ i : ι, (fun t : Finset α => ∑ a ∈ t, f a) (s i) = ⨆ s : Finset α, ∑ a ∈ s, f a exact (Finset.sum_mono_set f).iSup_comp_eq hs #align ennreal.tsum_eq_supr_sum' ENNReal.tsum_eq_iSup_sum' protected theorem tsum_sigma {β : α → Type*} (f : ∀ a, β a → ℝ≥0∞) : ∑' p : Σa, β a, f p.1 p.2 = ∑' (a) (b), f a b := tsum_sigma' (fun _ => ENNReal.summable) ENNReal.summable #align ennreal.tsum_sigma ENNReal.tsum_sigma protected theorem tsum_sigma' {β : α → Type*} (f : (Σa, β a) → ℝ≥0∞) : ∑' p : Σa, β a, f p = ∑' (a) (b), f ⟨a, b⟩ := tsum_sigma' (fun _ => ENNReal.summable) ENNReal.summable #align ennreal.tsum_sigma' ENNReal.tsum_sigma' protected theorem tsum_prod {f : α → β → ℝ≥0∞} : ∑' p : α × β, f p.1 p.2 = ∑' (a) (b), f a b := tsum_prod' ENNReal.summable fun _ => ENNReal.summable #align ennreal.tsum_prod ENNReal.tsum_prod protected theorem tsum_prod' {f : α × β → ℝ≥0∞} : ∑' p : α × β, f p = ∑' (a) (b), f (a, b) := tsum_prod' ENNReal.summable fun _ => ENNReal.summable #align ennreal.tsum_prod' ENNReal.tsum_prod' protected theorem tsum_comm {f : α → β → ℝ≥0∞} : ∑' a, ∑' b, f a b = ∑' b, ∑' a, f a b := tsum_comm' ENNReal.summable (fun _ => ENNReal.summable) fun _ => ENNReal.summable #align ennreal.tsum_comm ENNReal.tsum_comm protected theorem tsum_add : ∑' a, (f a + g a) = ∑' a, f a + ∑' a, g a := tsum_add ENNReal.summable ENNReal.summable #align ennreal.tsum_add ENNReal.tsum_add protected theorem tsum_le_tsum (h : ∀ a, f a ≤ g a) : ∑' a, f a ≤ ∑' a, g a := tsum_le_tsum h ENNReal.summable ENNReal.summable #align ennreal.tsum_le_tsum ENNReal.tsum_le_tsum @[gcongr] protected theorem _root_.GCongr.ennreal_tsum_le_tsum (h : ∀ a, f a ≤ g a) : tsum f ≤ tsum g := ENNReal.tsum_le_tsum h protected theorem sum_le_tsum {f : α → ℝ≥0∞} (s : Finset α) : ∑ x ∈ s, f x ≤ ∑' x, f x := sum_le_tsum s (fun _ _ => zero_le _) ENNReal.summable #align ennreal.sum_le_tsum ENNReal.sum_le_tsum protected theorem tsum_eq_iSup_nat' {f : ℕ → ℝ≥0∞} {N : ℕ → ℕ} (hN : Tendsto N atTop atTop) : ∑' i : ℕ, f i = ⨆ i : ℕ, ∑ a ∈ Finset.range (N i), f a := ENNReal.tsum_eq_iSup_sum' _ fun t => let ⟨n, hn⟩ := t.exists_nat_subset_range let ⟨k, _, hk⟩ := exists_le_of_tendsto_atTop hN 0 n ⟨k, Finset.Subset.trans hn (Finset.range_mono hk)⟩ #align ennreal.tsum_eq_supr_nat' ENNReal.tsum_eq_iSup_nat' protected theorem tsum_eq_iSup_nat {f : ℕ → ℝ≥0∞} : ∑' i : ℕ, f i = ⨆ i : ℕ, ∑ a ∈ Finset.range i, f a := ENNReal.tsum_eq_iSup_sum' _ Finset.exists_nat_subset_range #align ennreal.tsum_eq_supr_nat ENNReal.tsum_eq_iSup_nat protected theorem tsum_eq_liminf_sum_nat {f : ℕ → ℝ≥0∞} : ∑' i, f i = liminf (fun n => ∑ i ∈ Finset.range n, f i) atTop := ENNReal.summable.hasSum.tendsto_sum_nat.liminf_eq.symm #align ennreal.tsum_eq_liminf_sum_nat ENNReal.tsum_eq_liminf_sum_nat protected theorem tsum_eq_limsup_sum_nat {f : ℕ → ℝ≥0∞} : ∑' i, f i = limsup (fun n => ∑ i ∈ Finset.range n, f i) atTop := ENNReal.summable.hasSum.tendsto_sum_nat.limsup_eq.symm protected theorem le_tsum (a : α) : f a ≤ ∑' a, f a := le_tsum' ENNReal.summable a #align ennreal.le_tsum ENNReal.le_tsum @[simp] protected theorem tsum_eq_zero : ∑' i, f i = 0 ↔ ∀ i, f i = 0 := tsum_eq_zero_iff ENNReal.summable #align ennreal.tsum_eq_zero ENNReal.tsum_eq_zero protected theorem tsum_eq_top_of_eq_top : (∃ a, f a = ∞) → ∑' a, f a = ∞ | ⟨a, ha⟩ => top_unique <| ha ▸ ENNReal.le_tsum a #align ennreal.tsum_eq_top_of_eq_top ENNReal.tsum_eq_top_of_eq_top protected theorem lt_top_of_tsum_ne_top {a : α → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞) (j : α) : a j < ∞ := by contrapose! tsum_ne_top with h exact ENNReal.tsum_eq_top_of_eq_top ⟨j, top_unique h⟩ #align ennreal.lt_top_of_tsum_ne_top ENNReal.lt_top_of_tsum_ne_top @[simp] protected theorem tsum_top [Nonempty α] : ∑' _ : α, ∞ = ∞ := let ⟨a⟩ := ‹Nonempty α› ENNReal.tsum_eq_top_of_eq_top ⟨a, rfl⟩ #align ennreal.tsum_top ENNReal.tsum_top theorem tsum_const_eq_top_of_ne_zero {α : Type*} [Infinite α] {c : ℝ≥0∞} (hc : c ≠ 0) : ∑' _ : α, c = ∞ := by have A : Tendsto (fun n : ℕ => (n : ℝ≥0∞) * c) atTop (𝓝 (∞ * c)) := by apply ENNReal.Tendsto.mul_const tendsto_nat_nhds_top simp only [true_or_iff, top_ne_zero, Ne, not_false_iff] have B : ∀ n : ℕ, (n : ℝ≥0∞) * c ≤ ∑' _ : α, c := fun n => by rcases Infinite.exists_subset_card_eq α n with ⟨s, hs⟩ simpa [hs] using @ENNReal.sum_le_tsum α (fun _ => c) s simpa [hc] using le_of_tendsto' A B #align ennreal.tsum_const_eq_top_of_ne_zero ENNReal.tsum_const_eq_top_of_ne_zero protected theorem ne_top_of_tsum_ne_top (h : ∑' a, f a ≠ ∞) (a : α) : f a ≠ ∞ := fun ha => h <| ENNReal.tsum_eq_top_of_eq_top ⟨a, ha⟩ #align ennreal.ne_top_of_tsum_ne_top ENNReal.ne_top_of_tsum_ne_top protected theorem tsum_mul_left : ∑' i, a * f i = a * ∑' i, f i := by by_cases hf : ∀ i, f i = 0 · simp [hf] · rw [← ENNReal.tsum_eq_zero] at hf have : Tendsto (fun s : Finset α => ∑ j ∈ s, a * f j) atTop (𝓝 (a * ∑' i, f i)) := by simp only [← Finset.mul_sum] exact ENNReal.Tendsto.const_mul ENNReal.summable.hasSum (Or.inl hf) exact HasSum.tsum_eq this #align ennreal.tsum_mul_left ENNReal.tsum_mul_left protected theorem tsum_mul_right : ∑' i, f i * a = (∑' i, f i) * a := by simp [mul_comm, ENNReal.tsum_mul_left] #align ennreal.tsum_mul_right ENNReal.tsum_mul_right protected theorem tsum_const_smul {R} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (a : R) : ∑' i, a • f i = a • ∑' i, f i := by simpa only [smul_one_mul] using @ENNReal.tsum_mul_left _ (a • (1 : ℝ≥0∞)) _ #align ennreal.tsum_const_smul ENNReal.tsum_const_smul @[simp] theorem tsum_iSup_eq {α : Type*} (a : α) {f : α → ℝ≥0∞} : (∑' b : α, ⨆ _ : a = b, f b) = f a := (tsum_eq_single a fun _ h => by simp [h.symm]).trans <| by simp #align ennreal.tsum_supr_eq ENNReal.tsum_iSup_eq theorem hasSum_iff_tendsto_nat {f : ℕ → ℝ≥0∞} (r : ℝ≥0∞) : HasSum f r ↔ Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 r) := by refine ⟨HasSum.tendsto_sum_nat, fun h => ?_⟩ rw [← iSup_eq_of_tendsto _ h, ← ENNReal.tsum_eq_iSup_nat] · exact ENNReal.summable.hasSum · exact fun s t hst => Finset.sum_le_sum_of_subset (Finset.range_subset.2 hst) #align ennreal.has_sum_iff_tendsto_nat ENNReal.hasSum_iff_tendsto_nat theorem tendsto_nat_tsum (f : ℕ → ℝ≥0∞) : Tendsto (fun n : ℕ => ∑ i ∈ Finset.range n, f i) atTop (𝓝 (∑' n, f n)) := by rw [← hasSum_iff_tendsto_nat] exact ENNReal.summable.hasSum #align ennreal.tendsto_nat_tsum ENNReal.tendsto_nat_tsum theorem toNNReal_apply_of_tsum_ne_top {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' i, f i ≠ ∞) (x : α) : (((ENNReal.toNNReal ∘ f) x : ℝ≥0) : ℝ≥0∞) = f x := coe_toNNReal <| ENNReal.ne_top_of_tsum_ne_top hf _ #align ennreal.to_nnreal_apply_of_tsum_ne_top ENNReal.toNNReal_apply_of_tsum_ne_top theorem summable_toNNReal_of_tsum_ne_top {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' i, f i ≠ ∞) : Summable (ENNReal.toNNReal ∘ f) := by simpa only [← tsum_coe_ne_top_iff_summable, toNNReal_apply_of_tsum_ne_top hf] using hf #align ennreal.summable_to_nnreal_of_tsum_ne_top ENNReal.summable_toNNReal_of_tsum_ne_top theorem tendsto_cofinite_zero_of_tsum_ne_top {α} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto f cofinite (𝓝 0) := by have f_ne_top : ∀ n, f n ≠ ∞ := ENNReal.ne_top_of_tsum_ne_top hf have h_f_coe : f = fun n => ((f n).toNNReal : ENNReal) := funext fun n => (coe_toNNReal (f_ne_top n)).symm rw [h_f_coe, ← @coe_zero, tendsto_coe] exact NNReal.tendsto_cofinite_zero_of_summable (summable_toNNReal_of_tsum_ne_top hf) #align ennreal.tendsto_cofinite_zero_of_tsum_ne_top ENNReal.tendsto_cofinite_zero_of_tsum_ne_top theorem tendsto_atTop_zero_of_tsum_ne_top {f : ℕ → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto f atTop (𝓝 0) := by rw [← Nat.cofinite_eq_atTop] exact tendsto_cofinite_zero_of_tsum_ne_top hf #align ennreal.tendsto_at_top_zero_of_tsum_ne_top ENNReal.tendsto_atTop_zero_of_tsum_ne_top /-- The sum over the complement of a finset tends to `0` when the finset grows to cover the whole space. This does not need a summability assumption, as otherwise all sums are zero. -/ theorem tendsto_tsum_compl_atTop_zero {α : Type*} {f : α → ℝ≥0∞} (hf : ∑' x, f x ≠ ∞) : Tendsto (fun s : Finset α => ∑' b : { x // x ∉ s }, f b) atTop (𝓝 0) := by lift f to α → ℝ≥0 using ENNReal.ne_top_of_tsum_ne_top hf convert ENNReal.tendsto_coe.2 (NNReal.tendsto_tsum_compl_atTop_zero f) rw [ENNReal.coe_tsum] exact NNReal.summable_comp_injective (tsum_coe_ne_top_iff_summable.1 hf) Subtype.coe_injective #align ennreal.tendsto_tsum_compl_at_top_zero ENNReal.tendsto_tsum_compl_atTop_zero protected theorem tsum_apply {ι α : Type*} {f : ι → α → ℝ≥0∞} {x : α} : (∑' i, f i) x = ∑' i, f i x := tsum_apply <| Pi.summable.mpr fun _ => ENNReal.summable #align ennreal.tsum_apply ENNReal.tsum_apply theorem tsum_sub {f : ℕ → ℝ≥0∞} {g : ℕ → ℝ≥0∞} (h₁ : ∑' i, g i ≠ ∞) (h₂ : g ≤ f) : ∑' i, (f i - g i) = ∑' i, f i - ∑' i, g i := have : ∀ i, f i - g i + g i = f i := fun i => tsub_add_cancel_of_le (h₂ i) ENNReal.eq_sub_of_add_eq h₁ <| by simp only [← ENNReal.tsum_add, this] #align ennreal.tsum_sub ENNReal.tsum_sub theorem tsum_comp_le_tsum_of_injective {f : α → β} (hf : Injective f) (g : β → ℝ≥0∞) : ∑' x, g (f x) ≤ ∑' y, g y := tsum_le_tsum_of_inj f hf (fun _ _ => zero_le _) (fun _ => le_rfl) ENNReal.summable ENNReal.summable theorem tsum_le_tsum_comp_of_surjective {f : α → β} (hf : Surjective f) (g : β → ℝ≥0∞) : ∑' y, g y ≤ ∑' x, g (f x) := calc ∑' y, g y = ∑' y, g (f (surjInv hf y)) := by simp only [surjInv_eq hf] _ ≤ ∑' x, g (f x) := tsum_comp_le_tsum_of_injective (injective_surjInv hf) _ theorem tsum_mono_subtype (f : α → ℝ≥0∞) {s t : Set α} (h : s ⊆ t) : ∑' x : s, f x ≤ ∑' x : t, f x := tsum_comp_le_tsum_of_injective (inclusion_injective h) _ #align ennreal.tsum_mono_subtype ENNReal.tsum_mono_subtype theorem tsum_iUnion_le_tsum {ι : Type*} (f : α → ℝ≥0∞) (t : ι → Set α) : ∑' x : ⋃ i, t i, f x ≤ ∑' i, ∑' x : t i, f x := calc ∑' x : ⋃ i, t i, f x ≤ ∑' x : Σ i, t i, f x.2 := tsum_le_tsum_comp_of_surjective (sigmaToiUnion_surjective t) _ _ = ∑' i, ∑' x : t i, f x := ENNReal.tsum_sigma' _ theorem tsum_biUnion_le_tsum {ι : Type*} (f : α → ℝ≥0∞) (s : Set ι) (t : ι → Set α) : ∑' x : ⋃ i ∈ s , t i, f x ≤ ∑' i : s, ∑' x : t i, f x := calc ∑' x : ⋃ i ∈ s, t i, f x = ∑' x : ⋃ i : s, t i, f x := tsum_congr_set_coe _ <| by simp _ ≤ ∑' i : s, ∑' x : t i, f x := tsum_iUnion_le_tsum _ _ theorem tsum_biUnion_le {ι : Type*} (f : α → ℝ≥0∞) (s : Finset ι) (t : ι → Set α) : ∑' x : ⋃ i ∈ s, t i, f x ≤ ∑ i ∈ s, ∑' x : t i, f x := (tsum_biUnion_le_tsum f s.toSet t).trans_eq (Finset.tsum_subtype s fun i => ∑' x : t i, f x) #align ennreal.tsum_bUnion_le ENNReal.tsum_biUnion_le theorem tsum_iUnion_le {ι : Type*} [Fintype ι] (f : α → ℝ≥0∞) (t : ι → Set α) : ∑' x : ⋃ i, t i, f x ≤ ∑ i, ∑' x : t i, f x := by rw [← tsum_fintype] exact tsum_iUnion_le_tsum f t #align ennreal.tsum_Union_le ENNReal.tsum_iUnion_le theorem tsum_union_le (f : α → ℝ≥0∞) (s t : Set α) : ∑' x : ↑(s ∪ t), f x ≤ ∑' x : s, f x + ∑' x : t, f x := calc ∑' x : ↑(s ∪ t), f x = ∑' x : ⋃ b, cond b s t, f x := tsum_congr_set_coe _ union_eq_iUnion _ ≤ _ := by simpa using tsum_iUnion_le f (cond · s t) #align ennreal.tsum_union_le ENNReal.tsum_union_le theorem tsum_eq_add_tsum_ite {f : β → ℝ≥0∞} (b : β) : ∑' x, f x = f b + ∑' x, ite (x = b) 0 (f x) := tsum_eq_add_tsum_ite' b ENNReal.summable #align ennreal.tsum_eq_add_tsum_ite ENNReal.tsum_eq_add_tsum_ite theorem tsum_add_one_eq_top {f : ℕ → ℝ≥0∞} (hf : ∑' n, f n = ∞) (hf0 : f 0 ≠ ∞) : ∑' n, f (n + 1) = ∞ := by rw [tsum_eq_zero_add' ENNReal.summable, add_eq_top] at hf exact hf.resolve_left hf0 #align ennreal.tsum_add_one_eq_top ENNReal.tsum_add_one_eq_top /-- A sum of extended nonnegative reals which is finite can have only finitely many terms above any positive threshold. -/ theorem finite_const_le_of_tsum_ne_top {ι : Type*} {a : ι → ℝ≥0∞} (tsum_ne_top : ∑' i, a i ≠ ∞) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : { i : ι | ε ≤ a i }.Finite := by by_contra h have := Infinite.to_subtype h refine tsum_ne_top (top_unique ?_) calc ∞ = ∑' _ : { i | ε ≤ a i }, ε := (tsum_const_eq_top_of_ne_zero ε_ne_zero).symm _ ≤ ∑' i, a i := tsum_le_tsum_of_inj (↑) Subtype.val_injective (fun _ _ => zero_le _) (fun i => i.2) ENNReal.summable ENNReal.summable #align ennreal.finite_const_le_of_tsum_ne_top ENNReal.finite_const_le_of_tsum_ne_top /-- Markov's inequality for `Finset.card` and `tsum` in `ℝ≥0∞`. -/ theorem finset_card_const_le_le_of_tsum_le {ι : Type*} {a : ι → ℝ≥0∞} {c : ℝ≥0∞} (c_ne_top : c ≠ ∞) (tsum_le_c : ∑' i, a i ≤ c) {ε : ℝ≥0∞} (ε_ne_zero : ε ≠ 0) : ∃ hf : { i : ι | ε ≤ a i }.Finite, ↑hf.toFinset.card ≤ c / ε := by have hf : { i : ι | ε ≤ a i }.Finite := finite_const_le_of_tsum_ne_top (ne_top_of_le_ne_top c_ne_top tsum_le_c) ε_ne_zero refine ⟨hf, (ENNReal.le_div_iff_mul_le (.inl ε_ne_zero) (.inr c_ne_top)).2 ?_⟩ calc ↑hf.toFinset.card * ε = ∑ _i ∈ hf.toFinset, ε := by rw [Finset.sum_const, nsmul_eq_mul] _ ≤ ∑ i ∈ hf.toFinset, a i := Finset.sum_le_sum fun i => hf.mem_toFinset.1 _ ≤ ∑' i, a i := ENNReal.sum_le_tsum _ _ ≤ c := tsum_le_c #align ennreal.finset_card_const_le_le_of_tsum_le ENNReal.finset_card_const_le_le_of_tsum_le theorem tsum_fiberwise (f : β → ℝ≥0∞) (g : β → γ) : ∑' x, ∑' b : g ⁻¹' {x}, f b = ∑' i, f i := by apply HasSum.tsum_eq let equiv := Equiv.sigmaFiberEquiv g apply (equiv.hasSum_iff.mpr ENNReal.summable.hasSum).sigma exact fun _ ↦ ENNReal.summable.hasSum_iff.mpr rfl end tsum
Mathlib/Topology/Instances/ENNReal.lean
1,095
1,099
theorem tendsto_toReal_iff {ι} {fi : Filter ι} {f : ι → ℝ≥0∞} (hf : ∀ i, f i ≠ ∞) {x : ℝ≥0∞} (hx : x ≠ ∞) : Tendsto (fun n => (f n).toReal) fi (𝓝 x.toReal) ↔ Tendsto f fi (𝓝 x) := by
lift f to ι → ℝ≥0 using hf lift x to ℝ≥0 using hx simp [tendsto_coe]
/- Copyright (c) 2014 Parikshit Khanna. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Parikshit Khanna, Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Mario Carneiro -/ import Mathlib.Data.Nat.Defs import Mathlib.Data.Option.Basic import Mathlib.Data.List.Defs import Mathlib.Init.Data.List.Basic import Mathlib.Init.Data.List.Instances import Mathlib.Init.Data.List.Lemmas import Mathlib.Logic.Unique import Mathlib.Order.Basic import Mathlib.Tactic.Common #align_import data.list.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83" /-! # Basic properties of lists -/ assert_not_exists Set.range assert_not_exists GroupWithZero assert_not_exists Ring open Function open Nat hiding one_pos namespace List universe u v w variable {ι : Type*} {α : Type u} {β : Type v} {γ : Type w} {l₁ l₂ : List α} -- Porting note: Delete this attribute -- attribute [inline] List.head! /-- There is only one list of an empty type -/ instance uniqueOfIsEmpty [IsEmpty α] : Unique (List α) := { instInhabitedList with uniq := fun l => match l with | [] => rfl | a :: _ => isEmptyElim a } #align list.unique_of_is_empty List.uniqueOfIsEmpty instance : Std.LawfulIdentity (α := List α) Append.append [] where left_id := nil_append right_id := append_nil instance : Std.Associative (α := List α) Append.append where assoc := append_assoc #align list.cons_ne_nil List.cons_ne_nil #align list.cons_ne_self List.cons_ne_self #align list.head_eq_of_cons_eq List.head_eq_of_cons_eqₓ -- implicits order #align list.tail_eq_of_cons_eq List.tail_eq_of_cons_eqₓ -- implicits order @[simp] theorem cons_injective {a : α} : Injective (cons a) := fun _ _ => tail_eq_of_cons_eq #align list.cons_injective List.cons_injective #align list.cons_inj List.cons_inj #align list.cons_eq_cons List.cons_eq_cons theorem singleton_injective : Injective fun a : α => [a] := fun _ _ h => (cons_eq_cons.1 h).1 #align list.singleton_injective List.singleton_injective theorem singleton_inj {a b : α} : [a] = [b] ↔ a = b := singleton_injective.eq_iff #align list.singleton_inj List.singleton_inj #align list.exists_cons_of_ne_nil List.exists_cons_of_ne_nil theorem set_of_mem_cons (l : List α) (a : α) : { x | x ∈ a :: l } = insert a { x | x ∈ l } := Set.ext fun _ => mem_cons #align list.set_of_mem_cons List.set_of_mem_cons /-! ### mem -/ #align list.mem_singleton_self List.mem_singleton_self #align list.eq_of_mem_singleton List.eq_of_mem_singleton #align list.mem_singleton List.mem_singleton #align list.mem_of_mem_cons_of_mem List.mem_of_mem_cons_of_mem theorem _root_.Decidable.List.eq_or_ne_mem_of_mem [DecidableEq α] {a b : α} {l : List α} (h : a ∈ b :: l) : a = b ∨ a ≠ b ∧ a ∈ l := by by_cases hab : a = b · exact Or.inl hab · exact ((List.mem_cons.1 h).elim Or.inl (fun h => Or.inr ⟨hab, h⟩)) #align decidable.list.eq_or_ne_mem_of_mem Decidable.List.eq_or_ne_mem_of_mem #align list.eq_or_ne_mem_of_mem List.eq_or_ne_mem_of_mem #align list.not_mem_append List.not_mem_append #align list.ne_nil_of_mem List.ne_nil_of_mem lemma mem_pair {a b c : α} : a ∈ [b, c] ↔ a = b ∨ a = c := by rw [mem_cons, mem_singleton] @[deprecated (since := "2024-03-23")] alias mem_split := append_of_mem #align list.mem_split List.append_of_mem #align list.mem_of_ne_of_mem List.mem_of_ne_of_mem #align list.ne_of_not_mem_cons List.ne_of_not_mem_cons #align list.not_mem_of_not_mem_cons List.not_mem_of_not_mem_cons #align list.not_mem_cons_of_ne_of_not_mem List.not_mem_cons_of_ne_of_not_mem #align list.ne_and_not_mem_of_not_mem_cons List.ne_and_not_mem_of_not_mem_cons #align list.mem_map List.mem_map #align list.exists_of_mem_map List.exists_of_mem_map #align list.mem_map_of_mem List.mem_map_of_memₓ -- implicits order -- The simpNF linter says that the LHS can be simplified via `List.mem_map`. -- However this is a higher priority lemma. -- https://github.com/leanprover/std4/issues/207 @[simp 1100, nolint simpNF] theorem mem_map_of_injective {f : α → β} (H : Injective f) {a : α} {l : List α} : f a ∈ map f l ↔ a ∈ l := ⟨fun m => let ⟨_, m', e⟩ := exists_of_mem_map m; H e ▸ m', mem_map_of_mem _⟩ #align list.mem_map_of_injective List.mem_map_of_injective @[simp] theorem _root_.Function.Involutive.exists_mem_and_apply_eq_iff {f : α → α} (hf : Function.Involutive f) (x : α) (l : List α) : (∃ y : α, y ∈ l ∧ f y = x) ↔ f x ∈ l := ⟨by rintro ⟨y, h, rfl⟩; rwa [hf y], fun h => ⟨f x, h, hf _⟩⟩ #align function.involutive.exists_mem_and_apply_eq_iff Function.Involutive.exists_mem_and_apply_eq_iff theorem mem_map_of_involutive {f : α → α} (hf : Involutive f) {a : α} {l : List α} : a ∈ map f l ↔ f a ∈ l := by rw [mem_map, hf.exists_mem_and_apply_eq_iff] #align list.mem_map_of_involutive List.mem_map_of_involutive #align list.forall_mem_map_iff List.forall_mem_map_iffₓ -- universe order #align list.map_eq_nil List.map_eq_nilₓ -- universe order attribute [simp] List.mem_join #align list.mem_join List.mem_join #align list.exists_of_mem_join List.exists_of_mem_join #align list.mem_join_of_mem List.mem_join_of_memₓ -- implicits order attribute [simp] List.mem_bind #align list.mem_bind List.mem_bindₓ -- implicits order -- Porting note: bExists in Lean3, And in Lean4 #align list.exists_of_mem_bind List.exists_of_mem_bindₓ -- implicits order #align list.mem_bind_of_mem List.mem_bind_of_memₓ -- implicits order #align list.bind_map List.bind_mapₓ -- implicits order theorem map_bind (g : β → List γ) (f : α → β) : ∀ l : List α, (List.map f l).bind g = l.bind fun a => g (f a) | [] => rfl | a :: l => by simp only [cons_bind, map_cons, map_bind _ _ l] #align list.map_bind List.map_bind /-! ### length -/ #align list.length_eq_zero List.length_eq_zero #align list.length_singleton List.length_singleton #align list.length_pos_of_mem List.length_pos_of_mem #align list.exists_mem_of_length_pos List.exists_mem_of_length_pos #align list.length_pos_iff_exists_mem List.length_pos_iff_exists_mem alias ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ := length_pos #align list.ne_nil_of_length_pos List.ne_nil_of_length_pos #align list.length_pos_of_ne_nil List.length_pos_of_ne_nil theorem length_pos_iff_ne_nil {l : List α} : 0 < length l ↔ l ≠ [] := ⟨ne_nil_of_length_pos, length_pos_of_ne_nil⟩ #align list.length_pos_iff_ne_nil List.length_pos_iff_ne_nil #align list.exists_mem_of_ne_nil List.exists_mem_of_ne_nil #align list.length_eq_one List.length_eq_one theorem exists_of_length_succ {n} : ∀ l : List α, l.length = n + 1 → ∃ h t, l = h :: t | [], H => absurd H.symm <| succ_ne_zero n | h :: t, _ => ⟨h, t, rfl⟩ #align list.exists_of_length_succ List.exists_of_length_succ @[simp] lemma length_injective_iff : Injective (List.length : List α → ℕ) ↔ Subsingleton α := by constructor · intro h; refine ⟨fun x y => ?_⟩; (suffices [x] = [y] by simpa using this); apply h; rfl · intros hα l1 l2 hl induction l1 generalizing l2 <;> cases l2 · rfl · cases hl · cases hl · next ih _ _ => congr · exact Subsingleton.elim _ _ · apply ih; simpa using hl #align list.length_injective_iff List.length_injective_iff @[simp default+1] -- Porting note: this used to be just @[simp] lemma length_injective [Subsingleton α] : Injective (length : List α → ℕ) := length_injective_iff.mpr inferInstance #align list.length_injective List.length_injective theorem length_eq_two {l : List α} : l.length = 2 ↔ ∃ a b, l = [a, b] := ⟨fun _ => let [a, b] := l; ⟨a, b, rfl⟩, fun ⟨_, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_two List.length_eq_two theorem length_eq_three {l : List α} : l.length = 3 ↔ ∃ a b c, l = [a, b, c] := ⟨fun _ => let [a, b, c] := l; ⟨a, b, c, rfl⟩, fun ⟨_, _, _, e⟩ => e ▸ rfl⟩ #align list.length_eq_three List.length_eq_three #align list.sublist.length_le List.Sublist.length_le /-! ### set-theoretic notation of lists -/ -- ADHOC Porting note: instance from Lean3 core instance instSingletonList : Singleton α (List α) := ⟨fun x => [x]⟩ #align list.has_singleton List.instSingletonList -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : Insert α (List α) := ⟨List.insert⟩ -- ADHOC Porting note: instance from Lean3 core instance [DecidableEq α] : LawfulSingleton α (List α) := { insert_emptyc_eq := fun x => show (if x ∈ ([] : List α) then [] else [x]) = [x] from if_neg (not_mem_nil _) } #align list.empty_eq List.empty_eq theorem singleton_eq (x : α) : ({x} : List α) = [x] := rfl #align list.singleton_eq List.singleton_eq theorem insert_neg [DecidableEq α] {x : α} {l : List α} (h : x ∉ l) : Insert.insert x l = x :: l := insert_of_not_mem h #align list.insert_neg List.insert_neg theorem insert_pos [DecidableEq α] {x : α} {l : List α} (h : x ∈ l) : Insert.insert x l = l := insert_of_mem h #align list.insert_pos List.insert_pos theorem doubleton_eq [DecidableEq α] {x y : α} (h : x ≠ y) : ({x, y} : List α) = [x, y] := by rw [insert_neg, singleton_eq] rwa [singleton_eq, mem_singleton] #align list.doubleton_eq List.doubleton_eq /-! ### bounded quantifiers over lists -/ #align list.forall_mem_nil List.forall_mem_nil #align list.forall_mem_cons List.forall_mem_cons theorem forall_mem_of_forall_mem_cons {p : α → Prop} {a : α} {l : List α} (h : ∀ x ∈ a :: l, p x) : ∀ x ∈ l, p x := (forall_mem_cons.1 h).2 #align list.forall_mem_of_forall_mem_cons List.forall_mem_of_forall_mem_cons #align list.forall_mem_singleton List.forall_mem_singleton #align list.forall_mem_append List.forall_mem_append #align list.not_exists_mem_nil List.not_exists_mem_nilₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of {p : α → Prop} {a : α} (l : List α) (h : p a) : ∃ x ∈ a :: l, p x := ⟨a, mem_cons_self _ _, h⟩ #align list.exists_mem_cons_of List.exists_mem_cons_ofₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem exists_mem_cons_of_exists {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ l, p x) → ∃ x ∈ a :: l, p x := fun ⟨x, xl, px⟩ => ⟨x, mem_cons_of_mem _ xl, px⟩ #align list.exists_mem_cons_of_exists List.exists_mem_cons_of_existsₓ -- bExists change -- Porting note: bExists in Lean3 and And in Lean4 theorem or_exists_of_exists_mem_cons {p : α → Prop} {a : α} {l : List α} : (∃ x ∈ a :: l, p x) → p a ∨ ∃ x ∈ l, p x := fun ⟨x, xal, px⟩ => Or.elim (eq_or_mem_of_mem_cons xal) (fun h : x = a => by rw [← h]; left; exact px) fun h : x ∈ l => Or.inr ⟨x, h, px⟩ #align list.or_exists_of_exists_mem_cons List.or_exists_of_exists_mem_consₓ -- bExists change theorem exists_mem_cons_iff (p : α → Prop) (a : α) (l : List α) : (∃ x ∈ a :: l, p x) ↔ p a ∨ ∃ x ∈ l, p x := Iff.intro or_exists_of_exists_mem_cons fun h => Or.elim h (exists_mem_cons_of l) exists_mem_cons_of_exists #align list.exists_mem_cons_iff List.exists_mem_cons_iff /-! ### list subset -/ instance : IsTrans (List α) Subset where trans := fun _ _ _ => List.Subset.trans #align list.subset_def List.subset_def #align list.subset_append_of_subset_left List.subset_append_of_subset_left #align list.subset_append_of_subset_right List.subset_append_of_subset_right #align list.cons_subset List.cons_subset theorem cons_subset_of_subset_of_mem {a : α} {l m : List α} (ainm : a ∈ m) (lsubm : l ⊆ m) : a::l ⊆ m := cons_subset.2 ⟨ainm, lsubm⟩ #align list.cons_subset_of_subset_of_mem List.cons_subset_of_subset_of_mem theorem append_subset_of_subset_of_subset {l₁ l₂ l : List α} (l₁subl : l₁ ⊆ l) (l₂subl : l₂ ⊆ l) : l₁ ++ l₂ ⊆ l := fun _ h ↦ (mem_append.1 h).elim (@l₁subl _) (@l₂subl _) #align list.append_subset_of_subset_of_subset List.append_subset_of_subset_of_subset -- Porting note: in Batteries #align list.append_subset_iff List.append_subset alias ⟨eq_nil_of_subset_nil, _⟩ := subset_nil #align list.eq_nil_of_subset_nil List.eq_nil_of_subset_nil #align list.eq_nil_iff_forall_not_mem List.eq_nil_iff_forall_not_mem #align list.map_subset List.map_subset theorem map_subset_iff {l₁ l₂ : List α} (f : α → β) (h : Injective f) : map f l₁ ⊆ map f l₂ ↔ l₁ ⊆ l₂ := by refine ⟨?_, map_subset f⟩; intro h2 x hx rcases mem_map.1 (h2 (mem_map_of_mem f hx)) with ⟨x', hx', hxx'⟩ cases h hxx'; exact hx' #align list.map_subset_iff List.map_subset_iff /-! ### append -/ theorem append_eq_has_append {L₁ L₂ : List α} : List.append L₁ L₂ = L₁ ++ L₂ := rfl #align list.append_eq_has_append List.append_eq_has_append #align list.singleton_append List.singleton_append #align list.append_ne_nil_of_ne_nil_left List.append_ne_nil_of_ne_nil_left #align list.append_ne_nil_of_ne_nil_right List.append_ne_nil_of_ne_nil_right #align list.append_eq_nil List.append_eq_nil -- Porting note: in Batteries #align list.nil_eq_append_iff List.nil_eq_append @[deprecated (since := "2024-03-24")] alias append_eq_cons_iff := append_eq_cons #align list.append_eq_cons_iff List.append_eq_cons @[deprecated (since := "2024-03-24")] alias cons_eq_append_iff := cons_eq_append #align list.cons_eq_append_iff List.cons_eq_append #align list.append_eq_append_iff List.append_eq_append_iff #align list.take_append_drop List.take_append_drop #align list.append_inj List.append_inj #align list.append_inj_right List.append_inj_rightₓ -- implicits order #align list.append_inj_left List.append_inj_leftₓ -- implicits order #align list.append_inj' List.append_inj'ₓ -- implicits order #align list.append_inj_right' List.append_inj_right'ₓ -- implicits order #align list.append_inj_left' List.append_inj_left'ₓ -- implicits order @[deprecated (since := "2024-01-18")] alias append_left_cancel := append_cancel_left #align list.append_left_cancel List.append_cancel_left @[deprecated (since := "2024-01-18")] alias append_right_cancel := append_cancel_right #align list.append_right_cancel List.append_cancel_right @[simp] theorem append_left_eq_self {x y : List α} : x ++ y = y ↔ x = [] := by rw [← append_left_inj (s₁ := x), nil_append] @[simp] theorem self_eq_append_left {x y : List α} : y = x ++ y ↔ x = [] := by rw [eq_comm, append_left_eq_self] @[simp] theorem append_right_eq_self {x y : List α} : x ++ y = x ↔ y = [] := by rw [← append_right_inj (t₁ := y), append_nil] @[simp] theorem self_eq_append_right {x y : List α} : x = x ++ y ↔ y = [] := by rw [eq_comm, append_right_eq_self] theorem append_right_injective (s : List α) : Injective fun t ↦ s ++ t := fun _ _ ↦ append_cancel_left #align list.append_right_injective List.append_right_injective #align list.append_right_inj List.append_right_inj theorem append_left_injective (t : List α) : Injective fun s ↦ s ++ t := fun _ _ ↦ append_cancel_right #align list.append_left_injective List.append_left_injective #align list.append_left_inj List.append_left_inj #align list.map_eq_append_split List.map_eq_append_split /-! ### replicate -/ @[simp] lemma replicate_zero (a : α) : replicate 0 a = [] := rfl #align list.replicate_zero List.replicate_zero attribute [simp] replicate_succ #align list.replicate_succ List.replicate_succ lemma replicate_one (a : α) : replicate 1 a = [a] := rfl #align list.replicate_one List.replicate_one #align list.length_replicate List.length_replicate #align list.mem_replicate List.mem_replicate #align list.eq_of_mem_replicate List.eq_of_mem_replicate theorem eq_replicate_length {a : α} : ∀ {l : List α}, l = replicate l.length a ↔ ∀ b ∈ l, b = a | [] => by simp | (b :: l) => by simp [eq_replicate_length] #align list.eq_replicate_length List.eq_replicate_length #align list.eq_replicate_of_mem List.eq_replicate_of_mem #align list.eq_replicate List.eq_replicate theorem replicate_add (m n) (a : α) : replicate (m + n) a = replicate m a ++ replicate n a := by induction m <;> simp [*, succ_add, replicate] #align list.replicate_add List.replicate_add theorem replicate_succ' (n) (a : α) : replicate (n + 1) a = replicate n a ++ [a] := replicate_add n 1 a #align list.replicate_succ' List.replicate_succ' theorem replicate_subset_singleton (n) (a : α) : replicate n a ⊆ [a] := fun _ h => mem_singleton.2 (eq_of_mem_replicate h) #align list.replicate_subset_singleton List.replicate_subset_singleton theorem subset_singleton_iff {a : α} {L : List α} : L ⊆ [a] ↔ ∃ n, L = replicate n a := by simp only [eq_replicate, subset_def, mem_singleton, exists_eq_left'] #align list.subset_singleton_iff List.subset_singleton_iff @[simp] theorem map_replicate (f : α → β) (n) (a : α) : map f (replicate n a) = replicate n (f a) := by induction n <;> [rfl; simp only [*, replicate, map]] #align list.map_replicate List.map_replicate @[simp] theorem tail_replicate (a : α) (n) : tail (replicate n a) = replicate (n - 1) a := by cases n <;> rfl #align list.tail_replicate List.tail_replicate @[simp] theorem join_replicate_nil (n : ℕ) : join (replicate n []) = @nil α := by induction n <;> [rfl; simp only [*, replicate, join, append_nil]] #align list.join_replicate_nil List.join_replicate_nil theorem replicate_right_injective {n : ℕ} (hn : n ≠ 0) : Injective (@replicate α n) := fun _ _ h => (eq_replicate.1 h).2 _ <| mem_replicate.2 ⟨hn, rfl⟩ #align list.replicate_right_injective List.replicate_right_injective theorem replicate_right_inj {a b : α} {n : ℕ} (hn : n ≠ 0) : replicate n a = replicate n b ↔ a = b := (replicate_right_injective hn).eq_iff #align list.replicate_right_inj List.replicate_right_inj @[simp] theorem replicate_right_inj' {a b : α} : ∀ {n}, replicate n a = replicate n b ↔ n = 0 ∨ a = b | 0 => by simp | n + 1 => (replicate_right_inj n.succ_ne_zero).trans <| by simp only [n.succ_ne_zero, false_or] #align list.replicate_right_inj' List.replicate_right_inj' theorem replicate_left_injective (a : α) : Injective (replicate · a) := LeftInverse.injective (length_replicate · a) #align list.replicate_left_injective List.replicate_left_injective @[simp] theorem replicate_left_inj {a : α} {n m : ℕ} : replicate n a = replicate m a ↔ n = m := (replicate_left_injective a).eq_iff #align list.replicate_left_inj List.replicate_left_inj @[simp] theorem head_replicate (n : ℕ) (a : α) (h) : head (replicate n a) h = a := by cases n <;> simp at h ⊢ /-! ### pure -/ theorem mem_pure (x y : α) : x ∈ (pure y : List α) ↔ x = y := by simp #align list.mem_pure List.mem_pure /-! ### bind -/ @[simp] theorem bind_eq_bind {α β} (f : α → List β) (l : List α) : l >>= f = l.bind f := rfl #align list.bind_eq_bind List.bind_eq_bind #align list.bind_append List.append_bind /-! ### concat -/ #align list.concat_nil List.concat_nil #align list.concat_cons List.concat_cons #align list.concat_eq_append List.concat_eq_append #align list.init_eq_of_concat_eq List.init_eq_of_concat_eq #align list.last_eq_of_concat_eq List.last_eq_of_concat_eq #align list.concat_ne_nil List.concat_ne_nil #align list.concat_append List.concat_append #align list.length_concat List.length_concat #align list.append_concat List.append_concat /-! ### reverse -/ #align list.reverse_nil List.reverse_nil #align list.reverse_core List.reverseAux -- Porting note: Do we need this? attribute [local simp] reverseAux #align list.reverse_cons List.reverse_cons #align list.reverse_core_eq List.reverseAux_eq theorem reverse_cons' (a : α) (l : List α) : reverse (a :: l) = concat (reverse l) a := by simp only [reverse_cons, concat_eq_append] #align list.reverse_cons' List.reverse_cons' theorem reverse_concat' (l : List α) (a : α) : (l ++ [a]).reverse = a :: l.reverse := by rw [reverse_append]; rfl -- Porting note (#10618): simp can prove this -- @[simp] theorem reverse_singleton (a : α) : reverse [a] = [a] := rfl #align list.reverse_singleton List.reverse_singleton #align list.reverse_append List.reverse_append #align list.reverse_concat List.reverse_concat #align list.reverse_reverse List.reverse_reverse @[simp] theorem reverse_involutive : Involutive (@reverse α) := reverse_reverse #align list.reverse_involutive List.reverse_involutive @[simp] theorem reverse_injective : Injective (@reverse α) := reverse_involutive.injective #align list.reverse_injective List.reverse_injective theorem reverse_surjective : Surjective (@reverse α) := reverse_involutive.surjective #align list.reverse_surjective List.reverse_surjective theorem reverse_bijective : Bijective (@reverse α) := reverse_involutive.bijective #align list.reverse_bijective List.reverse_bijective @[simp] theorem reverse_inj {l₁ l₂ : List α} : reverse l₁ = reverse l₂ ↔ l₁ = l₂ := reverse_injective.eq_iff #align list.reverse_inj List.reverse_inj theorem reverse_eq_iff {l l' : List α} : l.reverse = l' ↔ l = l'.reverse := reverse_involutive.eq_iff #align list.reverse_eq_iff List.reverse_eq_iff #align list.reverse_eq_nil List.reverse_eq_nil_iff theorem concat_eq_reverse_cons (a : α) (l : List α) : concat l a = reverse (a :: reverse l) := by simp only [concat_eq_append, reverse_cons, reverse_reverse] #align list.concat_eq_reverse_cons List.concat_eq_reverse_cons #align list.length_reverse List.length_reverse -- Porting note: This one was @[simp] in mathlib 3, -- but Lean contains a competing simp lemma reverse_map. -- For now we remove @[simp] to avoid simplification loops. -- TODO: Change Lean lemma to match mathlib 3? theorem map_reverse (f : α → β) (l : List α) : map f (reverse l) = reverse (map f l) := (reverse_map f l).symm #align list.map_reverse List.map_reverse theorem map_reverseAux (f : α → β) (l₁ l₂ : List α) : map f (reverseAux l₁ l₂) = reverseAux (map f l₁) (map f l₂) := by simp only [reverseAux_eq, map_append, map_reverse] #align list.map_reverse_core List.map_reverseAux #align list.mem_reverse List.mem_reverse @[simp] theorem reverse_replicate (n) (a : α) : reverse (replicate n a) = replicate n a := eq_replicate.2 ⟨by rw [length_reverse, length_replicate], fun b h => eq_of_mem_replicate (mem_reverse.1 h)⟩ #align list.reverse_replicate List.reverse_replicate /-! ### empty -/ -- Porting note: this does not work as desired -- attribute [simp] List.isEmpty theorem isEmpty_iff_eq_nil {l : List α} : l.isEmpty ↔ l = [] := by cases l <;> simp [isEmpty] #align list.empty_iff_eq_nil List.isEmpty_iff_eq_nil /-! ### dropLast -/ #align list.length_init List.length_dropLast /-! ### getLast -/ @[simp] theorem getLast_cons {a : α} {l : List α} : ∀ h : l ≠ nil, getLast (a :: l) (cons_ne_nil a l) = getLast l h := by induction l <;> intros · contradiction · rfl #align list.last_cons List.getLast_cons theorem getLast_append_singleton {a : α} (l : List α) : getLast (l ++ [a]) (append_ne_nil_of_ne_nil_right l _ (cons_ne_nil a _)) = a := by simp only [getLast_append] #align list.last_append_singleton List.getLast_append_singleton -- Porting note: name should be fixed upstream theorem getLast_append' (l₁ l₂ : List α) (h : l₂ ≠ []) : getLast (l₁ ++ l₂) (append_ne_nil_of_ne_nil_right l₁ l₂ h) = getLast l₂ h := by induction' l₁ with _ _ ih · simp · simp only [cons_append] rw [List.getLast_cons] exact ih #align list.last_append List.getLast_append' theorem getLast_concat' {a : α} (l : List α) : getLast (concat l a) (concat_ne_nil a l) = a := getLast_concat .. #align list.last_concat List.getLast_concat' @[simp] theorem getLast_singleton' (a : α) : getLast [a] (cons_ne_nil a []) = a := rfl #align list.last_singleton List.getLast_singleton' -- Porting note (#10618): simp can prove this -- @[simp] theorem getLast_cons_cons (a₁ a₂ : α) (l : List α) : getLast (a₁ :: a₂ :: l) (cons_ne_nil _ _) = getLast (a₂ :: l) (cons_ne_nil a₂ l) := rfl #align list.last_cons_cons List.getLast_cons_cons theorem dropLast_append_getLast : ∀ {l : List α} (h : l ≠ []), dropLast l ++ [getLast l h] = l | [], h => absurd rfl h | [a], h => rfl | a :: b :: l, h => by rw [dropLast_cons₂, cons_append, getLast_cons (cons_ne_nil _ _)] congr exact dropLast_append_getLast (cons_ne_nil b l) #align list.init_append_last List.dropLast_append_getLast theorem getLast_congr {l₁ l₂ : List α} (h₁ : l₁ ≠ []) (h₂ : l₂ ≠ []) (h₃ : l₁ = l₂) : getLast l₁ h₁ = getLast l₂ h₂ := by subst l₁; rfl #align list.last_congr List.getLast_congr #align list.last_mem List.getLast_mem theorem getLast_replicate_succ (m : ℕ) (a : α) : (replicate (m + 1) a).getLast (ne_nil_of_length_eq_succ (length_replicate _ _)) = a := by simp only [replicate_succ'] exact getLast_append_singleton _ #align list.last_replicate_succ List.getLast_replicate_succ /-! ### getLast? -/ -- Porting note: Moved earlier in file, for use in subsequent lemmas. @[simp] theorem getLast?_cons_cons (a b : α) (l : List α) : getLast? (a :: b :: l) = getLast? (b :: l) := rfl @[simp] theorem getLast?_isNone : ∀ {l : List α}, (getLast? l).isNone ↔ l = [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isNone (b :: l)] #align list.last'_is_none List.getLast?_isNone @[simp] theorem getLast?_isSome : ∀ {l : List α}, l.getLast?.isSome ↔ l ≠ [] | [] => by simp | [a] => by simp | a :: b :: l => by simp [@getLast?_isSome (b :: l)] #align list.last'_is_some List.getLast?_isSome theorem mem_getLast?_eq_getLast : ∀ {l : List α} {x : α}, x ∈ l.getLast? → ∃ h, x = getLast l h | [], x, hx => False.elim <| by simp at hx | [a], x, hx => have : a = x := by simpa using hx this ▸ ⟨cons_ne_nil a [], rfl⟩ | a :: b :: l, x, hx => by rw [getLast?_cons_cons] at hx rcases mem_getLast?_eq_getLast hx with ⟨_, h₂⟩ use cons_ne_nil _ _ assumption #align list.mem_last'_eq_last List.mem_getLast?_eq_getLast theorem getLast?_eq_getLast_of_ne_nil : ∀ {l : List α} (h : l ≠ []), l.getLast? = some (l.getLast h) | [], h => (h rfl).elim | [_], _ => rfl | _ :: b :: l, _ => @getLast?_eq_getLast_of_ne_nil (b :: l) (cons_ne_nil _ _) #align list.last'_eq_last_of_ne_nil List.getLast?_eq_getLast_of_ne_nil theorem mem_getLast?_cons {x y : α} : ∀ {l : List α}, x ∈ l.getLast? → x ∈ (y :: l).getLast? | [], _ => by contradiction | _ :: _, h => h #align list.mem_last'_cons List.mem_getLast?_cons theorem mem_of_mem_getLast? {l : List α} {a : α} (ha : a ∈ l.getLast?) : a ∈ l := let ⟨_, h₂⟩ := mem_getLast?_eq_getLast ha h₂.symm ▸ getLast_mem _ #align list.mem_of_mem_last' List.mem_of_mem_getLast? theorem dropLast_append_getLast? : ∀ {l : List α}, ∀ a ∈ l.getLast?, dropLast l ++ [a] = l | [], a, ha => (Option.not_mem_none a ha).elim | [a], _, rfl => rfl | a :: b :: l, c, hc => by rw [getLast?_cons_cons] at hc rw [dropLast_cons₂, cons_append, dropLast_append_getLast? _ hc] #align list.init_append_last' List.dropLast_append_getLast? theorem getLastI_eq_getLast? [Inhabited α] : ∀ l : List α, l.getLastI = l.getLast?.iget | [] => by simp [getLastI, Inhabited.default] | [a] => rfl | [a, b] => rfl | [a, b, c] => rfl | _ :: _ :: c :: l => by simp [getLastI, getLastI_eq_getLast? (c :: l)] #align list.ilast_eq_last' List.getLastI_eq_getLast? @[simp] theorem getLast?_append_cons : ∀ (l₁ : List α) (a : α) (l₂ : List α), getLast? (l₁ ++ a :: l₂) = getLast? (a :: l₂) | [], a, l₂ => rfl | [b], a, l₂ => rfl | b :: c :: l₁, a, l₂ => by rw [cons_append, cons_append, getLast?_cons_cons, ← cons_append, getLast?_append_cons (c :: l₁)] #align list.last'_append_cons List.getLast?_append_cons #align list.last'_cons_cons List.getLast?_cons_cons theorem getLast?_append_of_ne_nil (l₁ : List α) : ∀ {l₂ : List α} (_ : l₂ ≠ []), getLast? (l₁ ++ l₂) = getLast? l₂ | [], hl₂ => by contradiction | b :: l₂, _ => getLast?_append_cons l₁ b l₂ #align list.last'_append_of_ne_nil List.getLast?_append_of_ne_nil theorem getLast?_append {l₁ l₂ : List α} {x : α} (h : x ∈ l₂.getLast?) : x ∈ (l₁ ++ l₂).getLast? := by cases l₂ · contradiction · rw [List.getLast?_append_cons] exact h #align list.last'_append List.getLast?_append /-! ### head(!?) and tail -/ @[simp] theorem head!_nil [Inhabited α] : ([] : List α).head! = default := rfl @[simp] theorem head_cons_tail (x : List α) (h : x ≠ []) : x.head h :: x.tail = x := by cases x <;> simp at h ⊢ theorem head!_eq_head? [Inhabited α] (l : List α) : head! l = (head? l).iget := by cases l <;> rfl #align list.head_eq_head' List.head!_eq_head? theorem surjective_head! [Inhabited α] : Surjective (@head! α _) := fun x => ⟨[x], rfl⟩ #align list.surjective_head List.surjective_head! theorem surjective_head? : Surjective (@head? α) := Option.forall.2 ⟨⟨[], rfl⟩, fun x => ⟨[x], rfl⟩⟩ #align list.surjective_head' List.surjective_head? theorem surjective_tail : Surjective (@tail α) | [] => ⟨[], rfl⟩ | a :: l => ⟨a :: a :: l, rfl⟩ #align list.surjective_tail List.surjective_tail theorem eq_cons_of_mem_head? {x : α} : ∀ {l : List α}, x ∈ l.head? → l = x :: tail l | [], h => (Option.not_mem_none _ h).elim | a :: l, h => by simp only [head?, Option.mem_def, Option.some_inj] at h exact h ▸ rfl #align list.eq_cons_of_mem_head' List.eq_cons_of_mem_head? theorem mem_of_mem_head? {x : α} {l : List α} (h : x ∈ l.head?) : x ∈ l := (eq_cons_of_mem_head? h).symm ▸ mem_cons_self _ _ #align list.mem_of_mem_head' List.mem_of_mem_head? @[simp] theorem head!_cons [Inhabited α] (a : α) (l : List α) : head! (a :: l) = a := rfl #align list.head_cons List.head!_cons #align list.tail_nil List.tail_nil #align list.tail_cons List.tail_cons @[simp] theorem head!_append [Inhabited α] (t : List α) {s : List α} (h : s ≠ []) : head! (s ++ t) = head! s := by induction s · contradiction · rfl #align list.head_append List.head!_append theorem head?_append {s t : List α} {x : α} (h : x ∈ s.head?) : x ∈ (s ++ t).head? := by cases s · contradiction · exact h #align list.head'_append List.head?_append theorem head?_append_of_ne_nil : ∀ (l₁ : List α) {l₂ : List α} (_ : l₁ ≠ []), head? (l₁ ++ l₂) = head? l₁ | _ :: _, _, _ => rfl #align list.head'_append_of_ne_nil List.head?_append_of_ne_nil theorem tail_append_singleton_of_ne_nil {a : α} {l : List α} (h : l ≠ nil) : tail (l ++ [a]) = tail l ++ [a] := by induction l · contradiction · rw [tail, cons_append, tail] #align list.tail_append_singleton_of_ne_nil List.tail_append_singleton_of_ne_nil theorem cons_head?_tail : ∀ {l : List α} {a : α}, a ∈ head? l → a :: tail l = l | [], a, h => by contradiction | b :: l, a, h => by simp? at h says simp only [head?_cons, Option.mem_def, Option.some.injEq] at h simp [h] #align list.cons_head'_tail List.cons_head?_tail theorem head!_mem_head? [Inhabited α] : ∀ {l : List α}, l ≠ [] → head! l ∈ head? l | [], h => by contradiction | a :: l, _ => rfl #align list.head_mem_head' List.head!_mem_head? theorem cons_head!_tail [Inhabited α] {l : List α} (h : l ≠ []) : head! l :: tail l = l := cons_head?_tail (head!_mem_head? h) #align list.cons_head_tail List.cons_head!_tail theorem head!_mem_self [Inhabited α] {l : List α} (h : l ≠ nil) : l.head! ∈ l := by have h' := mem_cons_self l.head! l.tail rwa [cons_head!_tail h] at h' #align list.head_mem_self List.head!_mem_self theorem head_mem {l : List α} : ∀ (h : l ≠ nil), l.head h ∈ l := by cases l <;> simp @[simp] theorem head?_map (f : α → β) (l) : head? (map f l) = (head? l).map f := by cases l <;> rfl #align list.head'_map List.head?_map theorem tail_append_of_ne_nil (l l' : List α) (h : l ≠ []) : (l ++ l').tail = l.tail ++ l' := by cases l · contradiction · simp #align list.tail_append_of_ne_nil List.tail_append_of_ne_nil #align list.nth_le_eq_iff List.get_eq_iff theorem get_eq_get? (l : List α) (i : Fin l.length) : l.get i = (l.get? i).get (by simp [get?_eq_get]) := by simp [get_eq_iff] #align list.some_nth_le_eq List.get?_eq_get section deprecated set_option linter.deprecated false -- TODO(Mario): make replacements for theorems in this section /-- nth element of a list `l` given `n < l.length`. -/ @[deprecated get (since := "2023-01-05")] def nthLe (l : List α) (n) (h : n < l.length) : α := get l ⟨n, h⟩ #align list.nth_le List.nthLe @[simp] theorem nthLe_tail (l : List α) (i) (h : i < l.tail.length) (h' : i + 1 < l.length := (by simp only [length_tail] at h; omega)) : l.tail.nthLe i h = l.nthLe (i + 1) h' := by cases l <;> [cases h; rfl] #align list.nth_le_tail List.nthLe_tail theorem nthLe_cons_aux {l : List α} {a : α} {n} (hn : n ≠ 0) (h : n < (a :: l).length) : n - 1 < l.length := by contrapose! h rw [length_cons] omega #align list.nth_le_cons_aux List.nthLe_cons_aux theorem nthLe_cons {l : List α} {a : α} {n} (hl) : (a :: l).nthLe n hl = if hn : n = 0 then a else l.nthLe (n - 1) (nthLe_cons_aux hn hl) := by split_ifs with h · simp [nthLe, h] cases l · rw [length_singleton, Nat.lt_succ_iff] at hl omega cases n · contradiction rfl #align list.nth_le_cons List.nthLe_cons end deprecated -- Porting note: List.modifyHead has @[simp], and Lean 4 treats this as -- an invitation to unfold modifyHead in any context, -- not just use the equational lemmas. -- @[simp] @[simp 1100, nolint simpNF] theorem modifyHead_modifyHead (l : List α) (f g : α → α) : (l.modifyHead f).modifyHead g = l.modifyHead (g ∘ f) := by cases l <;> simp #align list.modify_head_modify_head List.modifyHead_modifyHead /-! ### Induction from the right -/ /-- Induction principle from the right for lists: if a property holds for the empty list, and for `l ++ [a]` if it holds for `l`, then it holds for all lists. The principle is given for a `Sort`-valued predicate, i.e., it can also be used to construct data. -/ @[elab_as_elim] def reverseRecOn {motive : List α → Sort*} (l : List α) (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : motive l := match h : reverse l with | [] => cast (congr_arg motive <| by simpa using congr(reverse $h.symm)) <| nil | head :: tail => cast (congr_arg motive <| by simpa using congr(reverse $h.symm)) <| append_singleton _ head <| reverseRecOn (reverse tail) nil append_singleton termination_by l.length decreasing_by simp_wf rw [← length_reverse l, h, length_cons] simp [Nat.lt_succ] #align list.reverse_rec_on List.reverseRecOn @[simp] theorem reverseRecOn_nil {motive : List α → Sort*} (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : reverseRecOn [] nil append_singleton = nil := reverseRecOn.eq_1 .. -- `unusedHavesSuffices` is getting confused by the unfolding of `reverseRecOn` @[simp, nolint unusedHavesSuffices] theorem reverseRecOn_concat {motive : List α → Sort*} (x : α) (xs : List α) (nil : motive []) (append_singleton : ∀ (l : List α) (a : α), motive l → motive (l ++ [a])) : reverseRecOn (motive := motive) (xs ++ [x]) nil append_singleton = append_singleton _ _ (reverseRecOn (motive := motive) xs nil append_singleton) := by suffices ∀ ys (h : reverse (reverse xs) = ys), reverseRecOn (motive := motive) (xs ++ [x]) nil append_singleton = cast (by simp [(reverse_reverse _).symm.trans h]) (append_singleton _ x (reverseRecOn (motive := motive) ys nil append_singleton)) by exact this _ (reverse_reverse xs) intros ys hy conv_lhs => unfold reverseRecOn split next h => simp at h next heq => revert heq simp only [reverse_append, reverse_cons, reverse_nil, nil_append, singleton_append, cons.injEq] rintro ⟨rfl, rfl⟩ subst ys rfl /-- Bidirectional induction principle for lists: if a property holds for the empty list, the singleton list, and `a :: (l ++ [b])` from `l`, then it holds for all lists. This can be used to prove statements about palindromes. The principle is given for a `Sort`-valued predicate, i.e., it can also be used to construct data. -/ @[elab_as_elim] def bidirectionalRec {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) : ∀ l, motive l | [] => nil | [a] => singleton a | a :: b :: l => let l' := dropLast (b :: l) let b' := getLast (b :: l) (cons_ne_nil _ _) cast (by rw [← dropLast_append_getLast (cons_ne_nil b l)]) <| cons_append a l' b' (bidirectionalRec nil singleton cons_append l') termination_by l => l.length #align list.bidirectional_rec List.bidirectionalRecₓ -- universe order @[simp] theorem bidirectionalRec_nil {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) : bidirectionalRec nil singleton cons_append [] = nil := bidirectionalRec.eq_1 .. @[simp] theorem bidirectionalRec_singleton {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) (a : α): bidirectionalRec nil singleton cons_append [a] = singleton a := by simp [bidirectionalRec] @[simp] theorem bidirectionalRec_cons_append {motive : List α → Sort*} (nil : motive []) (singleton : ∀ a : α, motive [a]) (cons_append : ∀ (a : α) (l : List α) (b : α), motive l → motive (a :: (l ++ [b]))) (a : α) (l : List α) (b : α) : bidirectionalRec nil singleton cons_append (a :: (l ++ [b])) = cons_append a l b (bidirectionalRec nil singleton cons_append l) := by conv_lhs => unfold bidirectionalRec cases l with | nil => rfl | cons x xs => simp only [List.cons_append] dsimp only [← List.cons_append] suffices ∀ (ys init : List α) (hinit : init = ys) (last : α) (hlast : last = b), (cons_append a init last (bidirectionalRec nil singleton cons_append init)) = cast (congr_arg motive <| by simp [hinit, hlast]) (cons_append a ys b (bidirectionalRec nil singleton cons_append ys)) by rw [this (x :: xs) _ (by rw [dropLast_append_cons, dropLast_single, append_nil]) _ (by simp)] simp rintro ys init rfl last rfl rfl /-- Like `bidirectionalRec`, but with the list parameter placed first. -/ @[elab_as_elim] abbrev bidirectionalRecOn {C : List α → Sort*} (l : List α) (H0 : C []) (H1 : ∀ a : α, C [a]) (Hn : ∀ (a : α) (l : List α) (b : α), C l → C (a :: (l ++ [b]))) : C l := bidirectionalRec H0 H1 Hn l #align list.bidirectional_rec_on List.bidirectionalRecOn /-! ### sublists -/ attribute [refl] List.Sublist.refl #align list.nil_sublist List.nil_sublist #align list.sublist.refl List.Sublist.refl #align list.sublist.trans List.Sublist.trans #align list.sublist_cons List.sublist_cons #align list.sublist_of_cons_sublist List.sublist_of_cons_sublist theorem Sublist.cons_cons {l₁ l₂ : List α} (a : α) (s : l₁ <+ l₂) : a :: l₁ <+ a :: l₂ := Sublist.cons₂ _ s #align list.sublist.cons_cons List.Sublist.cons_cons #align list.sublist_append_left List.sublist_append_left #align list.sublist_append_right List.sublist_append_right theorem sublist_cons_of_sublist (a : α) (h : l₁ <+ l₂) : l₁ <+ a :: l₂ := h.cons _ #align list.sublist_cons_of_sublist List.sublist_cons_of_sublist #align list.sublist_append_of_sublist_left List.sublist_append_of_sublist_left #align list.sublist_append_of_sublist_right List.sublist_append_of_sublist_right theorem tail_sublist : ∀ l : List α, tail l <+ l | [] => .slnil | a::l => sublist_cons a l #align list.tail_sublist List.tail_sublist @[gcongr] protected theorem Sublist.tail : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → tail l₁ <+ tail l₂ | _, _, slnil => .slnil | _, _, Sublist.cons _ h => (tail_sublist _).trans h | _, _, Sublist.cons₂ _ h => h theorem Sublist.of_cons_cons {l₁ l₂ : List α} {a b : α} (h : a :: l₁ <+ b :: l₂) : l₁ <+ l₂ := h.tail #align list.sublist_of_cons_sublist_cons List.Sublist.of_cons_cons @[deprecated (since := "2024-04-07")] theorem sublist_of_cons_sublist_cons {a} (h : a :: l₁ <+ a :: l₂) : l₁ <+ l₂ := h.of_cons_cons attribute [simp] cons_sublist_cons @[deprecated (since := "2024-04-07")] alias cons_sublist_cons_iff := cons_sublist_cons #align list.cons_sublist_cons_iff List.cons_sublist_cons_iff #align list.append_sublist_append_left List.append_sublist_append_left #align list.sublist.append_right List.Sublist.append_right #align list.sublist_or_mem_of_sublist List.sublist_or_mem_of_sublist #align list.sublist.reverse List.Sublist.reverse #align list.reverse_sublist_iff List.reverse_sublist #align list.append_sublist_append_right List.append_sublist_append_right #align list.sublist.append List.Sublist.append #align list.sublist.subset List.Sublist.subset #align list.singleton_sublist List.singleton_sublist theorem eq_nil_of_sublist_nil {l : List α} (s : l <+ []) : l = [] := eq_nil_of_subset_nil <| s.subset #align list.eq_nil_of_sublist_nil List.eq_nil_of_sublist_nil -- Porting note: this lemma seems to have been renamed on the occasion of its move to Batteries alias sublist_nil_iff_eq_nil := sublist_nil #align list.sublist_nil_iff_eq_nil List.sublist_nil_iff_eq_nil @[simp] lemma sublist_singleton {l : List α} {a : α} : l <+ [a] ↔ l = [] ∨ l = [a] := by constructor <;> rintro (_ | _) <;> aesop #align list.replicate_sublist_replicate List.replicate_sublist_replicate theorem sublist_replicate_iff {l : List α} {a : α} {n : ℕ} : l <+ replicate n a ↔ ∃ k ≤ n, l = replicate k a := ⟨fun h => ⟨l.length, h.length_le.trans_eq (length_replicate _ _), eq_replicate_length.mpr fun b hb => eq_of_mem_replicate (h.subset hb)⟩, by rintro ⟨k, h, rfl⟩; exact (replicate_sublist_replicate _).mpr h⟩ #align list.sublist_replicate_iff List.sublist_replicate_iff #align list.sublist.eq_of_length List.Sublist.eq_of_length #align list.sublist.eq_of_length_le List.Sublist.eq_of_length_le theorem Sublist.antisymm (s₁ : l₁ <+ l₂) (s₂ : l₂ <+ l₁) : l₁ = l₂ := s₁.eq_of_length_le s₂.length_le #align list.sublist.antisymm List.Sublist.antisymm instance decidableSublist [DecidableEq α] : ∀ l₁ l₂ : List α, Decidable (l₁ <+ l₂) | [], _ => isTrue <| nil_sublist _ | _ :: _, [] => isFalse fun h => List.noConfusion <| eq_nil_of_sublist_nil h | a :: l₁, b :: l₂ => if h : a = b then @decidable_of_decidable_of_iff _ _ (decidableSublist l₁ l₂) <| h ▸ cons_sublist_cons.symm else @decidable_of_decidable_of_iff _ _ (decidableSublist (a :: l₁) l₂) ⟨sublist_cons_of_sublist _, fun s => match a, l₁, s, h with | _, _, Sublist.cons _ s', h => s' | _, _, Sublist.cons₂ t _, h => absurd rfl h⟩ #align list.decidable_sublist List.decidableSublist /-! ### indexOf -/ section IndexOf variable [DecidableEq α] #align list.index_of_nil List.indexOf_nil /- Porting note: The following proofs were simpler prior to the port. These proofs use the low-level `findIdx.go`. * `indexOf_cons_self` * `indexOf_cons_eq` * `indexOf_cons_ne` * `indexOf_cons` The ported versions of the earlier proofs are given in comments. -/ -- indexOf_cons_eq _ rfl @[simp] theorem indexOf_cons_self (a : α) (l : List α) : indexOf a (a :: l) = 0 := by rw [indexOf, findIdx_cons, beq_self_eq_true, cond] #align list.index_of_cons_self List.indexOf_cons_self -- fun e => if_pos e theorem indexOf_cons_eq {a b : α} (l : List α) : b = a → indexOf a (b :: l) = 0 | e => by rw [← e]; exact indexOf_cons_self b l #align list.index_of_cons_eq List.indexOf_cons_eq -- fun n => if_neg n @[simp] theorem indexOf_cons_ne {a b : α} (l : List α) : b ≠ a → indexOf a (b :: l) = succ (indexOf a l) | h => by simp only [indexOf, findIdx_cons, Bool.cond_eq_ite, beq_iff_eq, h, ite_false] #align list.index_of_cons_ne List.indexOf_cons_ne #align list.index_of_cons List.indexOf_cons theorem indexOf_eq_length {a : α} {l : List α} : indexOf a l = length l ↔ a ∉ l := by induction' l with b l ih · exact iff_of_true rfl (not_mem_nil _) simp only [length, mem_cons, indexOf_cons, eq_comm] rw [cond_eq_if] split_ifs with h <;> simp at h · exact iff_of_false (by rintro ⟨⟩) fun H => H <| Or.inl h.symm · simp only [Ne.symm h, false_or_iff] rw [← ih] exact succ_inj' #align list.index_of_eq_length List.indexOf_eq_length @[simp] theorem indexOf_of_not_mem {l : List α} {a : α} : a ∉ l → indexOf a l = length l := indexOf_eq_length.2 #align list.index_of_of_not_mem List.indexOf_of_not_mem theorem indexOf_le_length {a : α} {l : List α} : indexOf a l ≤ length l := by induction' l with b l ih; · rfl simp only [length, indexOf_cons, cond_eq_if, beq_iff_eq] by_cases h : b = a · rw [if_pos h]; exact Nat.zero_le _ · rw [if_neg h]; exact succ_le_succ ih #align list.index_of_le_length List.indexOf_le_length theorem indexOf_lt_length {a} {l : List α} : indexOf a l < length l ↔ a ∈ l := ⟨fun h => Decidable.by_contradiction fun al => Nat.ne_of_lt h <| indexOf_eq_length.2 al, fun al => (lt_of_le_of_ne indexOf_le_length) fun h => indexOf_eq_length.1 h al⟩ #align list.index_of_lt_length List.indexOf_lt_length theorem indexOf_append_of_mem {a : α} (h : a ∈ l₁) : indexOf a (l₁ ++ l₂) = indexOf a l₁ := by induction' l₁ with d₁ t₁ ih · exfalso exact not_mem_nil a h rw [List.cons_append] by_cases hh : d₁ = a · iterate 2 rw [indexOf_cons_eq _ hh] rw [indexOf_cons_ne _ hh, indexOf_cons_ne _ hh, ih (mem_of_ne_of_mem (Ne.symm hh) h)] #align list.index_of_append_of_mem List.indexOf_append_of_mem theorem indexOf_append_of_not_mem {a : α} (h : a ∉ l₁) : indexOf a (l₁ ++ l₂) = l₁.length + indexOf a l₂ := by induction' l₁ with d₁ t₁ ih · rw [List.nil_append, List.length, Nat.zero_add] rw [List.cons_append, indexOf_cons_ne _ (ne_of_not_mem_cons h).symm, List.length, ih (not_mem_of_not_mem_cons h), Nat.succ_add] #align list.index_of_append_of_not_mem List.indexOf_append_of_not_mem end IndexOf /-! ### nth element -/ section deprecated set_option linter.deprecated false @[deprecated get_of_mem (since := "2023-01-05")] theorem nthLe_of_mem {a} {l : List α} (h : a ∈ l) : ∃ n h, nthLe l n h = a := let ⟨i, h⟩ := get_of_mem h; ⟨i.1, i.2, h⟩ #align list.nth_le_of_mem List.nthLe_of_mem @[deprecated get?_eq_get (since := "2023-01-05")] theorem nthLe_get? {l : List α} {n} (h) : get? l n = some (nthLe l n h) := get?_eq_get _ #align list.nth_le_nth List.nthLe_get? #align list.nth_len_le List.get?_len_le @[simp] theorem get?_length (l : List α) : l.get? l.length = none := get?_len_le le_rfl #align list.nth_length List.get?_length #align list.nth_eq_some List.get?_eq_some #align list.nth_eq_none_iff List.get?_eq_none #align list.nth_of_mem List.get?_of_mem @[deprecated get_mem (since := "2023-01-05")] theorem nthLe_mem (l : List α) (n h) : nthLe l n h ∈ l := get_mem .. #align list.nth_le_mem List.nthLe_mem #align list.nth_mem List.get?_mem @[deprecated mem_iff_get (since := "2023-01-05")] theorem mem_iff_nthLe {a} {l : List α} : a ∈ l ↔ ∃ n h, nthLe l n h = a := mem_iff_get.trans ⟨fun ⟨⟨n, h⟩, e⟩ => ⟨n, h, e⟩, fun ⟨n, h, e⟩ => ⟨⟨n, h⟩, e⟩⟩ #align list.mem_iff_nth_le List.mem_iff_nthLe #align list.mem_iff_nth List.mem_iff_get? #align list.nth_zero List.get?_zero @[deprecated (since := "2024-05-03")] alias get?_injective := get?_inj #align list.nth_injective List.get?_inj #align list.nth_map List.get?_map @[deprecated get_map (since := "2023-01-05")] theorem nthLe_map (f : α → β) {l n} (H1 H2) : nthLe (map f l) n H1 = f (nthLe l n H2) := get_map .. #align list.nth_le_map List.nthLe_map /-- A version of `get_map` that can be used for rewriting. -/ theorem get_map_rev (f : α → β) {l n} : f (get l n) = get (map f l) ⟨n.1, (l.length_map f).symm ▸ n.2⟩ := Eq.symm (get_map _) /-- A version of `nthLe_map` that can be used for rewriting. -/ @[deprecated get_map_rev (since := "2023-01-05")] theorem nthLe_map_rev (f : α → β) {l n} (H) : f (nthLe l n H) = nthLe (map f l) n ((l.length_map f).symm ▸ H) := (nthLe_map f _ _).symm #align list.nth_le_map_rev List.nthLe_map_rev @[simp, deprecated get_map (since := "2023-01-05")] theorem nthLe_map' (f : α → β) {l n} (H) : nthLe (map f l) n H = f (nthLe l n (l.length_map f ▸ H)) := nthLe_map f _ _ #align list.nth_le_map' List.nthLe_map' #align list.nth_le_of_eq List.get_of_eq @[simp, deprecated get_singleton (since := "2023-01-05")] theorem nthLe_singleton (a : α) {n : ℕ} (hn : n < 1) : nthLe [a] n hn = a := get_singleton .. #align list.nth_le_singleton List.get_singleton #align list.nth_le_zero List.get_mk_zero #align list.nth_le_append List.get_append @[deprecated get_append_right' (since := "2023-01-05")] theorem nthLe_append_right {l₁ l₂ : List α} {n : ℕ} (h₁ : l₁.length ≤ n) (h₂) : (l₁ ++ l₂).nthLe n h₂ = l₂.nthLe (n - l₁.length) (get_append_right_aux h₁ h₂) := get_append_right' h₁ h₂ #align list.nth_le_append_right_aux List.get_append_right_aux #align list.nth_le_append_right List.nthLe_append_right #align list.nth_le_replicate List.get_replicate #align list.nth_append List.get?_append #align list.nth_append_right List.get?_append_right #align list.last_eq_nth_le List.getLast_eq_get theorem get_length_sub_one {l : List α} (h : l.length - 1 < l.length) : l.get ⟨l.length - 1, h⟩ = l.getLast (by rintro rfl; exact Nat.lt_irrefl 0 h) := (getLast_eq_get l _).symm #align list.nth_le_length_sub_one List.get_length_sub_one #align list.nth_concat_length List.get?_concat_length @[deprecated get_cons_length (since := "2023-01-05")] theorem nthLe_cons_length : ∀ (x : α) (xs : List α) (n : ℕ) (h : n = xs.length), (x :: xs).nthLe n (by simp [h]) = (x :: xs).getLast (cons_ne_nil x xs) := get_cons_length #align list.nth_le_cons_length List.nthLe_cons_length theorem take_one_drop_eq_of_lt_length {l : List α} {n : ℕ} (h : n < l.length) : (l.drop n).take 1 = [l.get ⟨n, h⟩] := by rw [drop_eq_get_cons h, take, take] #align list.take_one_drop_eq_of_lt_length List.take_one_drop_eq_of_lt_length #align list.ext List.ext -- TODO one may rename ext in the standard library, and it is also not clear -- which of ext_get?, ext_get?', ext_get should be @[ext], if any alias ext_get? := ext theorem ext_get?' {l₁ l₂ : List α} (h' : ∀ n < max l₁.length l₂.length, l₁.get? n = l₂.get? n) : l₁ = l₂ := by apply ext intro n rcases Nat.lt_or_ge n <| max l₁.length l₂.length with hn | hn · exact h' n hn · simp_all [Nat.max_le, get?_eq_none.mpr] theorem ext_get?_iff {l₁ l₂ : List α} : l₁ = l₂ ↔ ∀ n, l₁.get? n = l₂.get? n := ⟨by rintro rfl _; rfl, ext_get?⟩ theorem ext_get_iff {l₁ l₂ : List α} : l₁ = l₂ ↔ l₁.length = l₂.length ∧ ∀ n h₁ h₂, get l₁ ⟨n, h₁⟩ = get l₂ ⟨n, h₂⟩ := by constructor · rintro rfl exact ⟨rfl, fun _ _ _ ↦ rfl⟩ · intro ⟨h₁, h₂⟩ exact ext_get h₁ h₂ theorem ext_get?_iff' {l₁ l₂ : List α} : l₁ = l₂ ↔ ∀ n < max l₁.length l₂.length, l₁.get? n = l₂.get? n := ⟨by rintro rfl _ _; rfl, ext_get?'⟩ @[deprecated ext_get (since := "2023-01-05")] theorem ext_nthLe {l₁ l₂ : List α} (hl : length l₁ = length l₂) (h : ∀ n h₁ h₂, nthLe l₁ n h₁ = nthLe l₂ n h₂) : l₁ = l₂ := ext_get hl h #align list.ext_le List.ext_nthLe @[simp] theorem indexOf_get [DecidableEq α] {a : α} : ∀ {l : List α} (h), get l ⟨indexOf a l, h⟩ = a | b :: l, h => by by_cases h' : b = a <;> simp only [h', if_pos, if_false, indexOf_cons, get, @indexOf_get _ _ l, cond_eq_if, beq_iff_eq] #align list.index_of_nth_le List.indexOf_get @[simp] theorem indexOf_get? [DecidableEq α] {a : α} {l : List α} (h : a ∈ l) : get? l (indexOf a l) = some a := by rw [get?_eq_get, indexOf_get (indexOf_lt_length.2 h)] #align list.index_of_nth List.indexOf_get? @[deprecated (since := "2023-01-05")] theorem get_reverse_aux₁ : ∀ (l r : List α) (i h1 h2), get (reverseAux l r) ⟨i + length l, h1⟩ = get r ⟨i, h2⟩ | [], r, i => fun h1 _ => rfl | a :: l, r, i => by rw [show i + length (a :: l) = i + 1 + length l from Nat.add_right_comm i (length l) 1] exact fun h1 h2 => get_reverse_aux₁ l (a :: r) (i + 1) h1 (succ_lt_succ h2) #align list.nth_le_reverse_aux1 List.get_reverse_aux₁ theorem indexOf_inj [DecidableEq α] {l : List α} {x y : α} (hx : x ∈ l) (hy : y ∈ l) : indexOf x l = indexOf y l ↔ x = y := ⟨fun h => by have x_eq_y : get l ⟨indexOf x l, indexOf_lt_length.2 hx⟩ = get l ⟨indexOf y l, indexOf_lt_length.2 hy⟩ := by simp only [h] simp only [indexOf_get] at x_eq_y; exact x_eq_y, fun h => by subst h; rfl⟩ #align list.index_of_inj List.indexOf_inj theorem get_reverse_aux₂ : ∀ (l r : List α) (i : Nat) (h1) (h2), get (reverseAux l r) ⟨length l - 1 - i, h1⟩ = get l ⟨i, h2⟩ | [], r, i, h1, h2 => absurd h2 (Nat.not_lt_zero _) | a :: l, r, 0, h1, _ => by have aux := get_reverse_aux₁ l (a :: r) 0 rw [Nat.zero_add] at aux exact aux _ (zero_lt_succ _) | a :: l, r, i + 1, h1, h2 => by have aux := get_reverse_aux₂ l (a :: r) i have heq : length (a :: l) - 1 - (i + 1) = length l - 1 - i := by rw [length]; omega rw [← heq] at aux apply aux #align list.nth_le_reverse_aux2 List.get_reverse_aux₂ @[simp] theorem get_reverse (l : List α) (i : Nat) (h1 h2) : get (reverse l) ⟨length l - 1 - i, h1⟩ = get l ⟨i, h2⟩ := get_reverse_aux₂ _ _ _ _ _ @[simp, deprecated get_reverse (since := "2023-01-05")] theorem nthLe_reverse (l : List α) (i : Nat) (h1 h2) : nthLe (reverse l) (length l - 1 - i) h1 = nthLe l i h2 := get_reverse .. #align list.nth_le_reverse List.nthLe_reverse theorem nthLe_reverse' (l : List α) (n : ℕ) (hn : n < l.reverse.length) (hn') : l.reverse.nthLe n hn = l.nthLe (l.length - 1 - n) hn' := by rw [eq_comm] convert nthLe_reverse l.reverse n (by simpa) hn using 1 simp #align list.nth_le_reverse' List.nthLe_reverse' theorem get_reverse' (l : List α) (n) (hn') : l.reverse.get n = l.get ⟨l.length - 1 - n, hn'⟩ := nthLe_reverse' .. -- FIXME: prove it the other way around attribute [deprecated get_reverse' (since := "2023-01-05")] nthLe_reverse' theorem eq_cons_of_length_one {l : List α} (h : l.length = 1) : l = [l.nthLe 0 (by omega)] := by refine ext_get (by convert h) fun n h₁ h₂ => ?_ simp only [get_singleton] congr omega #align list.eq_cons_of_length_one List.eq_cons_of_length_one end deprecated theorem modifyNthTail_modifyNthTail {f g : List α → List α} (m : ℕ) : ∀ (n) (l : List α), (l.modifyNthTail f n).modifyNthTail g (m + n) = l.modifyNthTail (fun l => (f l).modifyNthTail g m) n | 0, _ => rfl | _ + 1, [] => rfl | n + 1, a :: l => congr_arg (List.cons a) (modifyNthTail_modifyNthTail m n l) #align list.modify_nth_tail_modify_nth_tail List.modifyNthTail_modifyNthTail theorem modifyNthTail_modifyNthTail_le {f g : List α → List α} (m n : ℕ) (l : List α) (h : n ≤ m) : (l.modifyNthTail f n).modifyNthTail g m = l.modifyNthTail (fun l => (f l).modifyNthTail g (m - n)) n := by rcases Nat.exists_eq_add_of_le h with ⟨m, rfl⟩ rw [Nat.add_comm, modifyNthTail_modifyNthTail, Nat.add_sub_cancel] #align list.modify_nth_tail_modify_nth_tail_le List.modifyNthTail_modifyNthTail_le theorem modifyNthTail_modifyNthTail_same {f g : List α → List α} (n : ℕ) (l : List α) : (l.modifyNthTail f n).modifyNthTail g n = l.modifyNthTail (g ∘ f) n := by rw [modifyNthTail_modifyNthTail_le n n l (le_refl n), Nat.sub_self]; rfl #align list.modify_nth_tail_modify_nth_tail_same List.modifyNthTail_modifyNthTail_same #align list.modify_nth_tail_id List.modifyNthTail_id #align list.remove_nth_eq_nth_tail List.eraseIdx_eq_modifyNthTail #align list.update_nth_eq_modify_nth List.set_eq_modifyNth @[deprecated (since := "2024-05-04")] alias removeNth_eq_nthTail := eraseIdx_eq_modifyNthTail theorem modifyNth_eq_set (f : α → α) : ∀ (n) (l : List α), modifyNth f n l = ((fun a => set l n (f a)) <$> get? l n).getD l | 0, l => by cases l <;> rfl | n + 1, [] => rfl | n + 1, b :: l => (congr_arg (cons b) (modifyNth_eq_set f n l)).trans <| by cases h : get? l n <;> simp [h] #align list.modify_nth_eq_update_nth List.modifyNth_eq_set #align list.nth_modify_nth List.get?_modifyNth theorem length_modifyNthTail (f : List α → List α) (H : ∀ l, length (f l) = length l) : ∀ n l, length (modifyNthTail f n l) = length l | 0, _ => H _ | _ + 1, [] => rfl | _ + 1, _ :: _ => @congr_arg _ _ _ _ (· + 1) (length_modifyNthTail _ H _ _) #align list.modify_nth_tail_length List.length_modifyNthTail -- Porting note: Duplicate of `modify_get?_length` -- (but with a substantially better name?) -- @[simp] theorem length_modifyNth (f : α → α) : ∀ n l, length (modifyNth f n l) = length l := modify_get?_length f #align list.modify_nth_length List.length_modifyNth #align list.update_nth_length List.length_set #align list.nth_modify_nth_eq List.get?_modifyNth_eq #align list.nth_modify_nth_ne List.get?_modifyNth_ne #align list.nth_update_nth_eq List.get?_set_eq #align list.nth_update_nth_of_lt List.get?_set_eq_of_lt #align list.nth_update_nth_ne List.get?_set_ne #align list.update_nth_nil List.set_nil #align list.update_nth_succ List.set_succ #align list.update_nth_comm List.set_comm #align list.nth_le_update_nth_eq List.get_set_eq @[simp] theorem get_set_of_ne {l : List α} {i j : ℕ} (h : i ≠ j) (a : α) (hj : j < (l.set i a).length) : (l.set i a).get ⟨j, hj⟩ = l.get ⟨j, by simpa using hj⟩ := by rw [← Option.some_inj, ← List.get?_eq_get, List.get?_set_ne _ _ h, List.get?_eq_get] #align list.nth_le_update_nth_of_ne List.get_set_of_ne #align list.mem_or_eq_of_mem_update_nth List.mem_or_eq_of_mem_set /-! ### map -/ #align list.map_nil List.map_nil theorem map_eq_foldr (f : α → β) (l : List α) : map f l = foldr (fun a bs => f a :: bs) [] l := by induction l <;> simp [*] #align list.map_eq_foldr List.map_eq_foldr theorem map_congr {f g : α → β} : ∀ {l : List α}, (∀ x ∈ l, f x = g x) → map f l = map g l | [], _ => rfl | a :: l, h => by let ⟨h₁, h₂⟩ := forall_mem_cons.1 h rw [map, map, h₁, map_congr h₂] #align list.map_congr List.map_congr theorem map_eq_map_iff {f g : α → β} {l : List α} : map f l = map g l ↔ ∀ x ∈ l, f x = g x := by refine ⟨?_, map_congr⟩; intro h x hx rw [mem_iff_get] at hx; rcases hx with ⟨n, hn, rfl⟩ rw [get_map_rev f, get_map_rev g] congr! #align list.map_eq_map_iff List.map_eq_map_iff theorem map_concat (f : α → β) (a : α) (l : List α) : map f (concat l a) = concat (map f l) (f a) := by induction l <;> [rfl; simp only [*, concat_eq_append, cons_append, map, map_append]] #align list.map_concat List.map_concat #align list.map_id'' List.map_id' theorem map_id'' {f : α → α} (h : ∀ x, f x = x) (l : List α) : map f l = l := by simp [show f = id from funext h] #align list.map_id' List.map_id'' theorem eq_nil_of_map_eq_nil {f : α → β} {l : List α} (h : map f l = nil) : l = nil := eq_nil_of_length_eq_zero <| by rw [← length_map l f, h]; rfl #align list.eq_nil_of_map_eq_nil List.eq_nil_of_map_eq_nil @[simp] theorem map_join (f : α → β) (L : List (List α)) : map f (join L) = join (map (map f) L) := by induction L <;> [rfl; simp only [*, join, map, map_append]] #align list.map_join List.map_join theorem bind_pure_eq_map (f : α → β) (l : List α) : l.bind (pure ∘ f) = map f l := .symm <| map_eq_bind .. #align list.bind_ret_eq_map List.bind_pure_eq_map set_option linter.deprecated false in @[deprecated bind_pure_eq_map (since := "2024-03-24")] theorem bind_ret_eq_map (f : α → β) (l : List α) : l.bind (List.ret ∘ f) = map f l := bind_pure_eq_map f l theorem bind_congr {l : List α} {f g : α → List β} (h : ∀ x ∈ l, f x = g x) : List.bind l f = List.bind l g := (congr_arg List.join <| map_congr h : _) #align list.bind_congr List.bind_congr theorem infix_bind_of_mem {a : α} {as : List α} (h : a ∈ as) (f : α → List α) : f a <:+: as.bind f := List.infix_of_mem_join (List.mem_map_of_mem f h) @[simp] theorem map_eq_map {α β} (f : α → β) (l : List α) : f <$> l = map f l := rfl #align list.map_eq_map List.map_eq_map @[simp] theorem map_tail (f : α → β) (l) : map f (tail l) = tail (map f l) := by cases l <;> rfl #align list.map_tail List.map_tail /-- A single `List.map` of a composition of functions is equal to composing a `List.map` with another `List.map`, fully applied. This is the reverse direction of `List.map_map`. -/ theorem comp_map (h : β → γ) (g : α → β) (l : List α) : map (h ∘ g) l = map h (map g l) := (map_map _ _ _).symm #align list.comp_map List.comp_map /-- Composing a `List.map` with another `List.map` is equal to a single `List.map` of composed functions. -/ @[simp] theorem map_comp_map (g : β → γ) (f : α → β) : map g ∘ map f = map (g ∘ f) := by ext l; rw [comp_map, Function.comp_apply] #align list.map_comp_map List.map_comp_map section map_bijectivity theorem _root_.Function.LeftInverse.list_map {f : α → β} {g : β → α} (h : LeftInverse f g) : LeftInverse (map f) (map g) | [] => by simp_rw [map_nil] | x :: xs => by simp_rw [map_cons, h x, h.list_map xs] nonrec theorem _root_.Function.RightInverse.list_map {f : α → β} {g : β → α} (h : RightInverse f g) : RightInverse (map f) (map g) := h.list_map nonrec theorem _root_.Function.Involutive.list_map {f : α → α} (h : Involutive f) : Involutive (map f) := Function.LeftInverse.list_map h @[simp] theorem map_leftInverse_iff {f : α → β} {g : β → α} : LeftInverse (map f) (map g) ↔ LeftInverse f g := ⟨fun h x => by injection h [x], (·.list_map)⟩ @[simp] theorem map_rightInverse_iff {f : α → β} {g : β → α} : RightInverse (map f) (map g) ↔ RightInverse f g := map_leftInverse_iff @[simp] theorem map_involutive_iff {f : α → α} : Involutive (map f) ↔ Involutive f := map_leftInverse_iff theorem _root_.Function.Injective.list_map {f : α → β} (h : Injective f) : Injective (map f) | [], [], _ => rfl | x :: xs, y :: ys, hxy => by injection hxy with hxy hxys rw [h hxy, h.list_map hxys] @[simp] theorem map_injective_iff {f : α → β} : Injective (map f) ↔ Injective f := by refine ⟨fun h x y hxy => ?_, (·.list_map)⟩ suffices [x] = [y] by simpa using this apply h simp [hxy] #align list.map_injective_iff List.map_injective_iff theorem _root_.Function.Surjective.list_map {f : α → β} (h : Surjective f) : Surjective (map f) := let ⟨_, h⟩ := h.hasRightInverse; h.list_map.surjective @[simp]
Mathlib/Data/List/Basic.lean
1,637
1,640
theorem map_surjective_iff {f : α → β} : Surjective (map f) ↔ Surjective f := by
refine ⟨fun h x => ?_, (·.list_map)⟩ let ⟨[y], hxy⟩ := h [x] exact ⟨_, List.singleton_injective hxy⟩
/- Copyright (c) 2023 Peter Nelson. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Peter Nelson -/ import Mathlib.SetTheory.Cardinal.Finite #align_import data.set.ncard from "leanprover-community/mathlib"@"74c2af38a828107941029b03839882c5c6f87a04" /-! # Noncomputable Set Cardinality We define the cardinality of set `s` as a term `Set.encard s : ℕ∞` and a term `Set.ncard s : ℕ`. The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and are defined in terms of `PartENat.card` (which takes a type as its argument); this file can be seen as an API for the same function in the special case where the type is a coercion of a `Set`, allowing for smoother interactions with the `Set` API. `Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even though it takes values in a less convenient type. It is probably the right choice in settings where one is concerned with the cardinalities of sets that may or may not be infinite. `Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'. When working with sets that are finite by virtue of their definition, then `Finset.card` probably makes more sense. One setting where `Set.ncard` works nicely is in a type `α` with `[Finite α]`, where every set is automatically finite. In this setting, we use default arguments and a simple tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems. ## Main Definitions * `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `⊤` if `s` is infinite. * `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite. If `s` is Infinite, then `Set.ncard s = 0`. * `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with `Set.toFinite`. This will work for `s : Set α` where there is a `Finite α` instance. ## Implementation Notes The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the `Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard` in the future. Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`, where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite` type. Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other in the context of the theorem, in which case we only include the ones that are needed, and derive the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require finiteness arguments; they are true by coincidence due to junk values. -/ namespace Set variable {α β : Type*} {s t : Set α} /-- The cardinality of a set as a term in `ℕ∞` -/ noncomputable def encard (s : Set α) : ℕ∞ := PartENat.withTopEquiv (PartENat.card s) @[simp] theorem encard_univ_coe (s : Set α) : encard (univ : Set s) = encard s := by rw [encard, encard, PartENat.card_congr (Equiv.Set.univ ↑s)] theorem encard_univ (α : Type*) : encard (univ : Set α) = PartENat.withTopEquiv (PartENat.card α) := by rw [encard, PartENat.card_congr (Equiv.Set.univ α)] theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by have := h.fintype rw [encard, PartENat.card_eq_coe_fintype_card, PartENat.withTopEquiv_natCast, toFinite_toFinset, toFinset_card] theorem encard_eq_coe_toFinset_card (s : Set α) [Fintype s] : encard s = s.toFinset.card := by have h := toFinite s rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset] theorem encard_coe_eq_coe_finsetCard (s : Finset α) : encard (s : Set α) = s.card := by rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp theorem Infinite.encard_eq {s : Set α} (h : s.Infinite) : s.encard = ⊤ := by have := h.to_subtype rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply, PartENat.withTopEquiv_symm_top, PartENat.card_eq_top_of_infinite] @[simp] theorem encard_eq_zero : s.encard = 0 ↔ s = ∅ := by rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply, PartENat.withTopEquiv_symm_zero, PartENat.card_eq_zero_iff_empty, isEmpty_subtype, eq_empty_iff_forall_not_mem] @[simp] theorem encard_empty : (∅ : Set α).encard = 0 := by rw [encard_eq_zero] theorem nonempty_of_encard_ne_zero (h : s.encard ≠ 0) : s.Nonempty := by rwa [nonempty_iff_ne_empty, Ne, ← encard_eq_zero] theorem encard_ne_zero : s.encard ≠ 0 ↔ s.Nonempty := by rw [ne_eq, encard_eq_zero, nonempty_iff_ne_empty] @[simp] theorem encard_pos : 0 < s.encard ↔ s.Nonempty := by rw [pos_iff_ne_zero, encard_ne_zero] @[simp] theorem encard_singleton (e : α) : ({e} : Set α).encard = 1 := by rw [encard, ← PartENat.withTopEquiv.symm.injective.eq_iff, Equiv.symm_apply_apply, PartENat.card_eq_coe_fintype_card, Fintype.card_ofSubsingleton, Nat.cast_one]; rfl theorem encard_union_eq (h : Disjoint s t) : (s ∪ t).encard = s.encard + t.encard := by classical have e := (Equiv.Set.union (by rwa [subset_empty_iff, ← disjoint_iff_inter_eq_empty])).symm simp [encard, ← PartENat.card_congr e, PartENat.card_sum, PartENat.withTopEquiv] theorem encard_insert_of_not_mem {a : α} (has : a ∉ s) : (insert a s).encard = s.encard + 1 := by rw [← union_singleton, encard_union_eq (by simpa), encard_singleton] theorem Finite.encard_lt_top (h : s.Finite) : s.encard < ⊤ := by refine h.induction_on (by simp) ?_ rintro a t hat _ ht' rw [encard_insert_of_not_mem hat] exact lt_tsub_iff_right.1 ht' theorem Finite.encard_eq_coe (h : s.Finite) : s.encard = ENat.toNat s.encard := (ENat.coe_toNat h.encard_lt_top.ne).symm theorem Finite.exists_encard_eq_coe (h : s.Finite) : ∃ (n : ℕ), s.encard = n := ⟨_, h.encard_eq_coe⟩ @[simp] theorem encard_lt_top_iff : s.encard < ⊤ ↔ s.Finite := ⟨fun h ↦ by_contra fun h' ↦ h.ne (Infinite.encard_eq h'), Finite.encard_lt_top⟩ @[simp] theorem encard_eq_top_iff : s.encard = ⊤ ↔ s.Infinite := by rw [← not_iff_not, ← Ne, ← lt_top_iff_ne_top, encard_lt_top_iff, not_infinite] theorem encard_ne_top_iff : s.encard ≠ ⊤ ↔ s.Finite := by simp theorem finite_of_encard_le_coe {k : ℕ} (h : s.encard ≤ k) : s.Finite := by rw [← encard_lt_top_iff]; exact h.trans_lt (WithTop.coe_lt_top _) theorem finite_of_encard_eq_coe {k : ℕ} (h : s.encard = k) : s.Finite := finite_of_encard_le_coe h.le theorem encard_le_coe_iff {k : ℕ} : s.encard ≤ k ↔ s.Finite ∧ ∃ (n₀ : ℕ), s.encard = n₀ ∧ n₀ ≤ k := ⟨fun h ↦ ⟨finite_of_encard_le_coe h, by rwa [ENat.le_coe_iff] at h⟩, fun ⟨_,⟨n₀,hs, hle⟩⟩ ↦ by rwa [hs, Nat.cast_le]⟩ section Lattice theorem encard_le_card (h : s ⊆ t) : s.encard ≤ t.encard := by rw [← union_diff_cancel h, encard_union_eq disjoint_sdiff_right]; exact le_self_add theorem encard_mono {α : Type*} : Monotone (encard : Set α → ℕ∞) := fun _ _ ↦ encard_le_card theorem encard_diff_add_encard_of_subset (h : s ⊆ t) : (t \ s).encard + s.encard = t.encard := by rw [← encard_union_eq disjoint_sdiff_left, diff_union_self, union_eq_self_of_subset_right h] @[simp] theorem one_le_encard_iff_nonempty : 1 ≤ s.encard ↔ s.Nonempty := by rw [nonempty_iff_ne_empty, Ne, ← encard_eq_zero, ENat.one_le_iff_ne_zero] theorem encard_diff_add_encard_inter (s t : Set α) : (s \ t).encard + (s ∩ t).encard = s.encard := by rw [← encard_union_eq (disjoint_of_subset_right inter_subset_right disjoint_sdiff_left), diff_union_inter] theorem encard_union_add_encard_inter (s t : Set α) : (s ∪ t).encard + (s ∩ t).encard = s.encard + t.encard := by rw [← diff_union_self, encard_union_eq disjoint_sdiff_left, add_right_comm, encard_diff_add_encard_inter] theorem encard_eq_encard_iff_encard_diff_eq_encard_diff (h : (s ∩ t).Finite) : s.encard = t.encard ↔ (s \ t).encard = (t \ s).encard := by rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s, WithTop.add_right_cancel_iff h.encard_lt_top.ne] theorem encard_le_encard_iff_encard_diff_le_encard_diff (h : (s ∩ t).Finite) : s.encard ≤ t.encard ↔ (s \ t).encard ≤ (t \ s).encard := by rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s, WithTop.add_le_add_iff_right h.encard_lt_top.ne] theorem encard_lt_encard_iff_encard_diff_lt_encard_diff (h : (s ∩ t).Finite) : s.encard < t.encard ↔ (s \ t).encard < (t \ s).encard := by rw [← encard_diff_add_encard_inter s t, ← encard_diff_add_encard_inter t s, inter_comm t s, WithTop.add_lt_add_iff_right h.encard_lt_top.ne] theorem encard_union_le (s t : Set α) : (s ∪ t).encard ≤ s.encard + t.encard := by rw [← encard_union_add_encard_inter]; exact le_self_add theorem finite_iff_finite_of_encard_eq_encard (h : s.encard = t.encard) : s.Finite ↔ t.Finite := by rw [← encard_lt_top_iff, ← encard_lt_top_iff, h] theorem infinite_iff_infinite_of_encard_eq_encard (h : s.encard = t.encard) : s.Infinite ↔ t.Infinite := by rw [← encard_eq_top_iff, h, encard_eq_top_iff] theorem Finite.finite_of_encard_le {s : Set α} {t : Set β} (hs : s.Finite) (h : t.encard ≤ s.encard) : t.Finite := encard_lt_top_iff.1 (h.trans_lt hs.encard_lt_top) theorem Finite.eq_of_subset_of_encard_le (ht : t.Finite) (hst : s ⊆ t) (hts : t.encard ≤ s.encard) : s = t := by rw [← zero_add (a := encard s), ← encard_diff_add_encard_of_subset hst] at hts have hdiff := WithTop.le_of_add_le_add_right (ht.subset hst).encard_lt_top.ne hts rw [nonpos_iff_eq_zero, encard_eq_zero, diff_eq_empty] at hdiff exact hst.antisymm hdiff theorem Finite.eq_of_subset_of_encard_le' (hs : s.Finite) (hst : s ⊆ t) (hts : t.encard ≤ s.encard) : s = t := (hs.finite_of_encard_le hts).eq_of_subset_of_encard_le hst hts theorem Finite.encard_lt_encard (ht : t.Finite) (h : s ⊂ t) : s.encard < t.encard := (encard_mono h.subset).lt_of_ne (fun he ↦ h.ne (ht.eq_of_subset_of_encard_le h.subset he.symm.le)) theorem encard_strictMono [Finite α] : StrictMono (encard : Set α → ℕ∞) := fun _ _ h ↦ (toFinite _).encard_lt_encard h theorem encard_diff_add_encard (s t : Set α) : (s \ t).encard + t.encard = (s ∪ t).encard := by rw [← encard_union_eq disjoint_sdiff_left, diff_union_self] theorem encard_le_encard_diff_add_encard (s t : Set α) : s.encard ≤ (s \ t).encard + t.encard := (encard_mono subset_union_left).trans_eq (encard_diff_add_encard _ _).symm theorem tsub_encard_le_encard_diff (s t : Set α) : s.encard - t.encard ≤ (s \ t).encard := by rw [tsub_le_iff_left, add_comm]; apply encard_le_encard_diff_add_encard theorem encard_add_encard_compl (s : Set α) : s.encard + sᶜ.encard = (univ : Set α).encard := by rw [← encard_union_eq disjoint_compl_right, union_compl_self] end Lattice section InsertErase variable {a b : α} theorem encard_insert_le (s : Set α) (x : α) : (insert x s).encard ≤ s.encard + 1 := by rw [← union_singleton, ← encard_singleton x]; apply encard_union_le theorem encard_singleton_inter (s : Set α) (x : α) : ({x} ∩ s).encard ≤ 1 := by rw [← encard_singleton x]; exact encard_le_card inter_subset_left theorem encard_diff_singleton_add_one (h : a ∈ s) : (s \ {a}).encard + 1 = s.encard := by rw [← encard_insert_of_not_mem (fun h ↦ h.2 rfl), insert_diff_singleton, insert_eq_of_mem h] theorem encard_diff_singleton_of_mem (h : a ∈ s) : (s \ {a}).encard = s.encard - 1 := by rw [← encard_diff_singleton_add_one h, ← WithTop.add_right_cancel_iff WithTop.one_ne_top, tsub_add_cancel_of_le (self_le_add_left _ _)] theorem encard_tsub_one_le_encard_diff_singleton (s : Set α) (x : α) : s.encard - 1 ≤ (s \ {x}).encard := by rw [← encard_singleton x]; apply tsub_encard_le_encard_diff theorem encard_exchange (ha : a ∉ s) (hb : b ∈ s) : (insert a (s \ {b})).encard = s.encard := by rw [encard_insert_of_not_mem, encard_diff_singleton_add_one hb] simp_all only [not_true, mem_diff, mem_singleton_iff, false_and, not_false_eq_true] theorem encard_exchange' (ha : a ∉ s) (hb : b ∈ s) : (insert a s \ {b}).encard = s.encard := by rw [← insert_diff_singleton_comm (by rintro rfl; exact ha hb), encard_exchange ha hb] theorem encard_eq_add_one_iff {k : ℕ∞} : s.encard = k + 1 ↔ (∃ a t, ¬a ∈ t ∧ insert a t = s ∧ t.encard = k) := by refine ⟨fun h ↦ ?_, ?_⟩ · obtain ⟨a, ha⟩ := nonempty_of_encard_ne_zero (s := s) (by simp [h]) refine ⟨a, s \ {a}, fun h ↦ h.2 rfl, by rwa [insert_diff_singleton, insert_eq_of_mem], ?_⟩ rw [← WithTop.add_right_cancel_iff WithTop.one_ne_top, ← h, encard_diff_singleton_add_one ha] rintro ⟨a, t, h, rfl, rfl⟩ rw [encard_insert_of_not_mem h] /-- Every set is either empty, infinite, or can have its `encard` reduced by a removal. Intended for well-founded induction on the value of `encard`. -/ theorem eq_empty_or_encard_eq_top_or_encard_diff_singleton_lt (s : Set α) : s = ∅ ∨ s.encard = ⊤ ∨ ∃ a ∈ s, (s \ {a}).encard < s.encard := by refine s.eq_empty_or_nonempty.elim Or.inl (Or.inr ∘ fun ⟨a,ha⟩ ↦ (s.finite_or_infinite.elim (fun hfin ↦ Or.inr ⟨a, ha, ?_⟩) (Or.inl ∘ Infinite.encard_eq))) rw [← encard_diff_singleton_add_one ha]; nth_rw 1 [← add_zero (encard _)] exact WithTop.add_lt_add_left (hfin.diff _).encard_lt_top.ne zero_lt_one end InsertErase section SmallSets theorem encard_pair {x y : α} (hne : x ≠ y) : ({x, y} : Set α).encard = 2 := by rw [encard_insert_of_not_mem (by simpa), ← one_add_one_eq_two, WithTop.add_right_cancel_iff WithTop.one_ne_top, encard_singleton] theorem encard_eq_one : s.encard = 1 ↔ ∃ x, s = {x} := by refine ⟨fun h ↦ ?_, fun ⟨x, hx⟩ ↦ by rw [hx, encard_singleton]⟩ obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp) exact ⟨x, ((finite_singleton x).eq_of_subset_of_encard_le' (by simpa) (by simp [h])).symm⟩ theorem encard_le_one_iff_eq : s.encard ≤ 1 ↔ s = ∅ ∨ ∃ x, s = {x} := by rw [le_iff_lt_or_eq, lt_iff_not_le, ENat.one_le_iff_ne_zero, not_not, encard_eq_zero, encard_eq_one] theorem encard_le_one_iff : s.encard ≤ 1 ↔ ∀ a b, a ∈ s → b ∈ s → a = b := by rw [encard_le_one_iff_eq, or_iff_not_imp_left, ← Ne, ← nonempty_iff_ne_empty] refine ⟨fun h a b has hbs ↦ ?_, fun h ⟨x, hx⟩ ↦ ⟨x, ((singleton_subset_iff.2 hx).antisymm' (fun y hy ↦ h _ _ hy hx))⟩⟩ obtain ⟨x, rfl⟩ := h ⟨_, has⟩ rw [(has : a = x), (hbs : b = x)] theorem one_lt_encard_iff : 1 < s.encard ↔ ∃ a b, a ∈ s ∧ b ∈ s ∧ a ≠ b := by rw [← not_iff_not, not_exists, not_lt, encard_le_one_iff]; aesop theorem exists_ne_of_one_lt_encard (h : 1 < s.encard) (a : α) : ∃ b ∈ s, b ≠ a := by by_contra! h' obtain ⟨b, b', hb, hb', hne⟩ := one_lt_encard_iff.1 h apply hne rw [h' b hb, h' b' hb'] theorem encard_eq_two : s.encard = 2 ↔ ∃ x y, x ≠ y ∧ s = {x, y} := by refine ⟨fun h ↦ ?_, fun ⟨x, y, hne, hs⟩ ↦ by rw [hs, encard_pair hne]⟩ obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp) rw [← insert_eq_of_mem hx, ← insert_diff_singleton, encard_insert_of_not_mem (fun h ↦ h.2 rfl), ← one_add_one_eq_two, WithTop.add_right_cancel_iff (WithTop.one_ne_top), encard_eq_one] at h obtain ⟨y, h⟩ := h refine ⟨x, y, by rintro rfl; exact (h.symm.subset rfl).2 rfl, ?_⟩ rw [← h, insert_diff_singleton, insert_eq_of_mem hx] theorem encard_eq_three {α : Type u_1} {s : Set α} : encard s = 3 ↔ ∃ x y z, x ≠ y ∧ x ≠ z ∧ y ≠ z ∧ s = {x, y, z} := by refine ⟨fun h ↦ ?_, fun ⟨x, y, z, hxy, hyz, hxz, hs⟩ ↦ ?_⟩ · obtain ⟨x, hx⟩ := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp) rw [← insert_eq_of_mem hx, ← insert_diff_singleton, encard_insert_of_not_mem (fun h ↦ h.2 rfl), (by exact rfl : (3 : ℕ∞) = 2 + 1), WithTop.add_right_cancel_iff WithTop.one_ne_top, encard_eq_two] at h obtain ⟨y, z, hne, hs⟩ := h refine ⟨x, y, z, ?_, ?_, hne, ?_⟩ · rintro rfl; exact (hs.symm.subset (Or.inl rfl)).2 rfl · rintro rfl; exact (hs.symm.subset (Or.inr rfl)).2 rfl rw [← hs, insert_diff_singleton, insert_eq_of_mem hx] rw [hs, encard_insert_of_not_mem, encard_insert_of_not_mem, encard_singleton] <;> aesop theorem Nat.encard_range (k : ℕ) : {i | i < k}.encard = k := by convert encard_coe_eq_coe_finsetCard (Finset.range k) using 1 · rw [Finset.coe_range, Iio_def] rw [Finset.card_range] end SmallSets theorem Finite.eq_insert_of_subset_of_encard_eq_succ (hs : s.Finite) (h : s ⊆ t) (hst : t.encard = s.encard + 1) : ∃ a, t = insert a s := by rw [← encard_diff_add_encard_of_subset h, add_comm, WithTop.add_left_cancel_iff hs.encard_lt_top.ne, encard_eq_one] at hst obtain ⟨x, hx⟩ := hst; use x; rw [← diff_union_of_subset h, hx, singleton_union] theorem exists_subset_encard_eq {k : ℕ∞} (hk : k ≤ s.encard) : ∃ t, t ⊆ s ∧ t.encard = k := by revert hk refine ENat.nat_induction k (fun _ ↦ ⟨∅, empty_subset _, by simp⟩) (fun n IH hle ↦ ?_) ?_ · obtain ⟨t₀, ht₀s, ht₀⟩ := IH (le_trans (by simp) hle) simp only [Nat.cast_succ] at * have hne : t₀ ≠ s := by rintro rfl; rw [ht₀, ← Nat.cast_one, ← Nat.cast_add, Nat.cast_le] at hle; simp at hle obtain ⟨x, hx⟩ := exists_of_ssubset (ht₀s.ssubset_of_ne hne) exact ⟨insert x t₀, insert_subset hx.1 ht₀s, by rw [encard_insert_of_not_mem hx.2, ht₀]⟩ simp only [top_le_iff, encard_eq_top_iff] exact fun _ hi ↦ ⟨s, Subset.rfl, hi⟩ theorem exists_superset_subset_encard_eq {k : ℕ∞} (hst : s ⊆ t) (hsk : s.encard ≤ k) (hkt : k ≤ t.encard) : ∃ r, s ⊆ r ∧ r ⊆ t ∧ r.encard = k := by obtain (hs | hs) := eq_or_ne s.encard ⊤ · rw [hs, top_le_iff] at hsk; subst hsk; exact ⟨s, Subset.rfl, hst, hs⟩ obtain ⟨k, rfl⟩ := exists_add_of_le hsk obtain ⟨k', hk'⟩ := exists_add_of_le hkt have hk : k ≤ encard (t \ s) := by rw [← encard_diff_add_encard_of_subset hst, add_comm] at hkt exact WithTop.le_of_add_le_add_right hs hkt obtain ⟨r', hr', rfl⟩ := exists_subset_encard_eq hk refine ⟨s ∪ r', subset_union_left, union_subset hst (hr'.trans diff_subset), ?_⟩ rw [encard_union_eq (disjoint_of_subset_right hr' disjoint_sdiff_right)] section Function variable {s : Set α} {t : Set β} {f : α → β} theorem InjOn.encard_image (h : InjOn f s) : (f '' s).encard = s.encard := by rw [encard, PartENat.card_image_of_injOn h, encard] theorem encard_congr (e : s ≃ t) : s.encard = t.encard := by rw [← encard_univ_coe, ← encard_univ_coe t, encard_univ, encard_univ, PartENat.card_congr e] theorem _root_.Function.Injective.encard_image (hf : f.Injective) (s : Set α) : (f '' s).encard = s.encard := hf.injOn.encard_image theorem _root_.Function.Embedding.enccard_le (e : s ↪ t) : s.encard ≤ t.encard := by rw [← encard_univ_coe, ← e.injective.encard_image, ← Subtype.coe_injective.encard_image] exact encard_mono (by simp) theorem encard_image_le (f : α → β) (s : Set α) : (f '' s).encard ≤ s.encard := by obtain (h | h) := isEmpty_or_nonempty α · rw [s.eq_empty_of_isEmpty]; simp rw [← (f.invFunOn_injOn_image s).encard_image] apply encard_le_card exact f.invFunOn_image_image_subset s theorem Finite.injOn_of_encard_image_eq (hs : s.Finite) (h : (f '' s).encard = s.encard) : InjOn f s := by obtain (h' | hne) := isEmpty_or_nonempty α · rw [s.eq_empty_of_isEmpty]; simp rw [← (f.invFunOn_injOn_image s).encard_image] at h rw [injOn_iff_invFunOn_image_image_eq_self] exact hs.eq_of_subset_of_encard_le (f.invFunOn_image_image_subset s) h.symm.le theorem encard_preimage_of_injective_subset_range (hf : f.Injective) (ht : t ⊆ range f) : (f ⁻¹' t).encard = t.encard := by rw [← hf.encard_image, image_preimage_eq_inter_range, inter_eq_self_of_subset_left ht] theorem encard_le_encard_of_injOn (hf : MapsTo f s t) (f_inj : InjOn f s) : s.encard ≤ t.encard := by rw [← f_inj.encard_image]; apply encard_le_card; rintro _ ⟨x, hx, rfl⟩; exact hf hx theorem Finite.exists_injOn_of_encard_le [Nonempty β] {s : Set α} {t : Set β} (hs : s.Finite) (hle : s.encard ≤ t.encard) : ∃ (f : α → β), s ⊆ f ⁻¹' t ∧ InjOn f s := by classical obtain (rfl | h | ⟨a, has, -⟩) := s.eq_empty_or_encard_eq_top_or_encard_diff_singleton_lt · simp · exact (encard_ne_top_iff.mpr hs h).elim obtain ⟨b, hbt⟩ := encard_pos.1 ((encard_pos.2 ⟨_, has⟩).trans_le hle) have hle' : (s \ {a}).encard ≤ (t \ {b}).encard := by rwa [← WithTop.add_le_add_iff_right WithTop.one_ne_top, encard_diff_singleton_add_one has, encard_diff_singleton_add_one hbt] obtain ⟨f₀, hf₀s, hinj⟩ := exists_injOn_of_encard_le (hs.diff {a}) hle' simp only [preimage_diff, subset_def, mem_diff, mem_singleton_iff, mem_preimage, and_imp] at hf₀s use Function.update f₀ a b rw [← insert_eq_of_mem has, ← insert_diff_singleton, injOn_insert (fun h ↦ h.2 rfl)] simp only [mem_diff, mem_singleton_iff, not_true, and_false, insert_diff_singleton, subset_def, mem_insert_iff, mem_preimage, ne_eq, Function.update_apply, forall_eq_or_imp, ite_true, and_imp, mem_image, ite_eq_left_iff, not_exists, not_and, not_forall, exists_prop, and_iff_right hbt] refine ⟨?_, ?_, fun x hxs hxa ↦ ⟨hxa, (hf₀s x hxs hxa).2⟩⟩ · rintro x hx; split_ifs with h · assumption · exact (hf₀s x hx h).1 exact InjOn.congr hinj (fun x ⟨_, hxa⟩ ↦ by rwa [Function.update_noteq]) termination_by encard s theorem Finite.exists_bijOn_of_encard_eq [Nonempty β] (hs : s.Finite) (h : s.encard = t.encard) : ∃ (f : α → β), BijOn f s t := by obtain ⟨f, hf, hinj⟩ := hs.exists_injOn_of_encard_le h.le; use f convert hinj.bijOn_image rw [(hs.image f).eq_of_subset_of_encard_le' (image_subset_iff.mpr hf) (h.symm.trans hinj.encard_image.symm).le] end Function section ncard open Nat /-- A tactic (for use in default params) that applies `Set.toFinite` to synthesize a `Set.Finite` term. -/ syntax "toFinite_tac" : tactic macro_rules | `(tactic| toFinite_tac) => `(tactic| apply Set.toFinite) /-- A tactic useful for transferring proofs for `encard` to their corresponding `card` statements -/ syntax "to_encard_tac" : tactic macro_rules | `(tactic| to_encard_tac) => `(tactic| simp only [← Nat.cast_le (α := ℕ∞), ← Nat.cast_inj (R := ℕ∞), Nat.cast_add, Nat.cast_one]) /-- The cardinality of `s : Set α` . Has the junk value `0` if `s` is infinite -/ noncomputable def ncard (s : Set α) : ℕ := ENat.toNat s.encard #align set.ncard Set.ncard theorem ncard_def (s : Set α) : s.ncard = ENat.toNat s.encard := rfl theorem Finite.cast_ncard_eq (hs : s.Finite) : s.ncard = s.encard := by rwa [ncard, ENat.coe_toNat_eq_self, ne_eq, encard_eq_top_iff, Set.Infinite, not_not] theorem Nat.card_coe_set_eq (s : Set α) : Nat.card s = s.ncard := by obtain (h | h) := s.finite_or_infinite · have := h.fintype rw [ncard, h.encard_eq_coe_toFinset_card, Nat.card_eq_fintype_card, toFinite_toFinset, toFinset_card, ENat.toNat_coe] have := infinite_coe_iff.2 h rw [ncard, h.encard_eq, Nat.card_eq_zero_of_infinite, ENat.toNat_top] #align set.nat.card_coe_set_eq Set.Nat.card_coe_set_eq theorem ncard_eq_toFinset_card (s : Set α) (hs : s.Finite := by toFinite_tac) : s.ncard = hs.toFinset.card := by rw [← Nat.card_coe_set_eq, @Nat.card_eq_fintype_card _ hs.fintype, @Finite.card_toFinset _ _ hs.fintype hs] #align set.ncard_eq_to_finset_card Set.ncard_eq_toFinset_card theorem ncard_eq_toFinset_card' (s : Set α) [Fintype s] : s.ncard = s.toFinset.card := by simp [← Nat.card_coe_set_eq, Nat.card_eq_fintype_card] theorem encard_le_coe_iff_finite_ncard_le {k : ℕ} : s.encard ≤ k ↔ s.Finite ∧ s.ncard ≤ k := by rw [encard_le_coe_iff, and_congr_right_iff] exact fun hfin ↦ ⟨fun ⟨n₀, hn₀, hle⟩ ↦ by rwa [ncard_def, hn₀, ENat.toNat_coe], fun h ↦ ⟨s.ncard, by rw [hfin.cast_ncard_eq], h⟩⟩ theorem Infinite.ncard (hs : s.Infinite) : s.ncard = 0 := by rw [← Nat.card_coe_set_eq, @Nat.card_eq_zero_of_infinite _ hs.to_subtype] #align set.infinite.ncard Set.Infinite.ncard theorem ncard_le_ncard (hst : s ⊆ t) (ht : t.Finite := by toFinite_tac) : s.ncard ≤ t.ncard := by rw [← Nat.cast_le (α := ℕ∞), ht.cast_ncard_eq, (ht.subset hst).cast_ncard_eq] exact encard_mono hst #align set.ncard_le_of_subset Set.ncard_le_ncard theorem ncard_mono [Finite α] : @Monotone (Set α) _ _ _ ncard := fun _ _ ↦ ncard_le_ncard #align set.ncard_mono Set.ncard_mono @[simp] theorem ncard_eq_zero (hs : s.Finite := by toFinite_tac) : s.ncard = 0 ↔ s = ∅ := by rw [← Nat.cast_inj (R := ℕ∞), hs.cast_ncard_eq, Nat.cast_zero, encard_eq_zero] #align set.ncard_eq_zero Set.ncard_eq_zero @[simp] theorem ncard_coe_Finset (s : Finset α) : (s : Set α).ncard = s.card := by rw [ncard_eq_toFinset_card _, Finset.finite_toSet_toFinset] #align set.ncard_coe_finset Set.ncard_coe_Finset theorem ncard_univ (α : Type*) : (univ : Set α).ncard = Nat.card α := by cases' finite_or_infinite α with h h · have hft := Fintype.ofFinite α rw [ncard_eq_toFinset_card, Finite.toFinset_univ, Finset.card_univ, Nat.card_eq_fintype_card] rw [Nat.card_eq_zero_of_infinite, Infinite.ncard] exact infinite_univ #align set.ncard_univ Set.ncard_univ @[simp] theorem ncard_empty (α : Type*) : (∅ : Set α).ncard = 0 := by rw [ncard_eq_zero] #align set.ncard_empty Set.ncard_empty theorem ncard_pos (hs : s.Finite := by toFinite_tac) : 0 < s.ncard ↔ s.Nonempty := by rw [pos_iff_ne_zero, Ne, ncard_eq_zero hs, nonempty_iff_ne_empty] #align set.ncard_pos Set.ncard_pos theorem ncard_ne_zero_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) : s.ncard ≠ 0 := ((ncard_pos hs).mpr ⟨a, h⟩).ne.symm #align set.ncard_ne_zero_of_mem Set.ncard_ne_zero_of_mem theorem finite_of_ncard_ne_zero (hs : s.ncard ≠ 0) : s.Finite := s.finite_or_infinite.elim id fun h ↦ (hs h.ncard).elim #align set.finite_of_ncard_ne_zero Set.finite_of_ncard_ne_zero theorem finite_of_ncard_pos (hs : 0 < s.ncard) : s.Finite := finite_of_ncard_ne_zero hs.ne.symm #align set.finite_of_ncard_pos Set.finite_of_ncard_pos theorem nonempty_of_ncard_ne_zero (hs : s.ncard ≠ 0) : s.Nonempty := by rw [nonempty_iff_ne_empty]; rintro rfl; simp at hs #align set.nonempty_of_ncard_ne_zero Set.nonempty_of_ncard_ne_zero @[simp] theorem ncard_singleton (a : α) : ({a} : Set α).ncard = 1 := by simp [ncard, ncard_eq_toFinset_card] #align set.ncard_singleton Set.ncard_singleton theorem ncard_singleton_inter (a : α) (s : Set α) : ({a} ∩ s).ncard ≤ 1 := by rw [← Nat.cast_le (α := ℕ∞), (toFinite _).cast_ncard_eq, Nat.cast_one] apply encard_singleton_inter #align set.ncard_singleton_inter Set.ncard_singleton_inter section InsertErase @[simp] theorem ncard_insert_of_not_mem {a : α} (h : a ∉ s) (hs : s.Finite := by toFinite_tac) : (insert a s).ncard = s.ncard + 1 := by rw [← Nat.cast_inj (R := ℕ∞), (hs.insert a).cast_ncard_eq, Nat.cast_add, Nat.cast_one, hs.cast_ncard_eq, encard_insert_of_not_mem h] #align set.ncard_insert_of_not_mem Set.ncard_insert_of_not_mem theorem ncard_insert_of_mem {a : α} (h : a ∈ s) : ncard (insert a s) = s.ncard := by rw [insert_eq_of_mem h] #align set.ncard_insert_of_mem Set.ncard_insert_of_mem theorem ncard_insert_le (a : α) (s : Set α) : (insert a s).ncard ≤ s.ncard + 1 := by obtain hs | hs := s.finite_or_infinite · to_encard_tac; rw [hs.cast_ncard_eq, (hs.insert _).cast_ncard_eq]; apply encard_insert_le rw [(hs.mono (subset_insert a s)).ncard] exact Nat.zero_le _ #align set.ncard_insert_le Set.ncard_insert_le theorem ncard_insert_eq_ite {a : α} [Decidable (a ∈ s)] (hs : s.Finite := by toFinite_tac) : ncard (insert a s) = if a ∈ s then s.ncard else s.ncard + 1 := by by_cases h : a ∈ s · rw [ncard_insert_of_mem h, if_pos h] · rw [ncard_insert_of_not_mem h hs, if_neg h] #align set.ncard_insert_eq_ite Set.ncard_insert_eq_ite theorem ncard_le_ncard_insert (a : α) (s : Set α) : s.ncard ≤ (insert a s).ncard := by classical refine s.finite_or_infinite.elim (fun h ↦ ?_) (fun h ↦ by (rw [h.ncard]; exact Nat.zero_le _)) rw [ncard_insert_eq_ite h]; split_ifs <;> simp #align set.ncard_le_ncard_insert Set.ncard_le_ncard_insert @[simp] theorem ncard_pair {a b : α} (h : a ≠ b) : ({a, b} : Set α).ncard = 2 := by rw [ncard_insert_of_not_mem, ncard_singleton]; simpa #align set.card_doubleton Set.ncard_pair @[simp] theorem ncard_diff_singleton_add_one {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) : (s \ {a}).ncard + 1 = s.ncard := by to_encard_tac; rw [hs.cast_ncard_eq, (hs.diff _).cast_ncard_eq, encard_diff_singleton_add_one h] #align set.ncard_diff_singleton_add_one Set.ncard_diff_singleton_add_one @[simp] theorem ncard_diff_singleton_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) : (s \ {a}).ncard = s.ncard - 1 := eq_tsub_of_add_eq (ncard_diff_singleton_add_one h hs) #align set.ncard_diff_singleton_of_mem Set.ncard_diff_singleton_of_mem theorem ncard_diff_singleton_lt_of_mem {a : α} (h : a ∈ s) (hs : s.Finite := by toFinite_tac) : (s \ {a}).ncard < s.ncard := by rw [← ncard_diff_singleton_add_one h hs]; apply lt_add_one #align set.ncard_diff_singleton_lt_of_mem Set.ncard_diff_singleton_lt_of_mem theorem ncard_diff_singleton_le (s : Set α) (a : α) : (s \ {a}).ncard ≤ s.ncard := by obtain hs | hs := s.finite_or_infinite · apply ncard_le_ncard diff_subset hs convert @zero_le ℕ _ _ exact (hs.diff (by simp : Set.Finite {a})).ncard #align set.ncard_diff_singleton_le Set.ncard_diff_singleton_le theorem pred_ncard_le_ncard_diff_singleton (s : Set α) (a : α) : s.ncard - 1 ≤ (s \ {a}).ncard := by cases' s.finite_or_infinite with hs hs · by_cases h : a ∈ s · rw [ncard_diff_singleton_of_mem h hs] rw [diff_singleton_eq_self h] apply Nat.pred_le convert Nat.zero_le _ rw [hs.ncard] #align set.pred_ncard_le_ncard_diff_singleton Set.pred_ncard_le_ncard_diff_singleton theorem ncard_exchange {a b : α} (ha : a ∉ s) (hb : b ∈ s) : (insert a (s \ {b})).ncard = s.ncard := congr_arg ENat.toNat <| encard_exchange ha hb #align set.ncard_exchange Set.ncard_exchange theorem ncard_exchange' {a b : α} (ha : a ∉ s) (hb : b ∈ s) : (insert a s \ {b}).ncard = s.ncard := by rw [← ncard_exchange ha hb, ← singleton_union, ← singleton_union, union_diff_distrib, @diff_singleton_eq_self _ b {a} fun h ↦ ha (by rwa [← mem_singleton_iff.mp h])] #align set.ncard_exchange' Set.ncard_exchange' end InsertErase variable {f : α → β} theorem ncard_image_le (hs : s.Finite := by toFinite_tac) : (f '' s).ncard ≤ s.ncard := by to_encard_tac; rw [hs.cast_ncard_eq, (hs.image _).cast_ncard_eq]; apply encard_image_le #align set.ncard_image_le Set.ncard_image_le theorem ncard_image_of_injOn (H : Set.InjOn f s) : (f '' s).ncard = s.ncard := congr_arg ENat.toNat <| H.encard_image #align set.ncard_image_of_inj_on Set.ncard_image_of_injOn theorem injOn_of_ncard_image_eq (h : (f '' s).ncard = s.ncard) (hs : s.Finite := by toFinite_tac) : Set.InjOn f s := by rw [← Nat.cast_inj (R := ℕ∞), hs.cast_ncard_eq, (hs.image _).cast_ncard_eq] at h exact hs.injOn_of_encard_image_eq h #align set.inj_on_of_ncard_image_eq Set.injOn_of_ncard_image_eq theorem ncard_image_iff (hs : s.Finite := by toFinite_tac) : (f '' s).ncard = s.ncard ↔ Set.InjOn f s := ⟨fun h ↦ injOn_of_ncard_image_eq h hs, ncard_image_of_injOn⟩ #align set.ncard_image_iff Set.ncard_image_iff theorem ncard_image_of_injective (s : Set α) (H : f.Injective) : (f '' s).ncard = s.ncard := ncard_image_of_injOn fun _ _ _ _ h ↦ H h #align set.ncard_image_of_injective Set.ncard_image_of_injective theorem ncard_preimage_of_injective_subset_range {s : Set β} (H : f.Injective) (hs : s ⊆ Set.range f) : (f ⁻¹' s).ncard = s.ncard := by rw [← ncard_image_of_injective _ H, image_preimage_eq_iff.mpr hs] #align set.ncard_preimage_of_injective_subset_range Set.ncard_preimage_of_injective_subset_range theorem fiber_ncard_ne_zero_iff_mem_image {y : β} (hs : s.Finite := by toFinite_tac) : { x ∈ s | f x = y }.ncard ≠ 0 ↔ y ∈ f '' s := by refine ⟨nonempty_of_ncard_ne_zero, ?_⟩ rintro ⟨z, hz, rfl⟩ exact @ncard_ne_zero_of_mem _ ({ x ∈ s | f x = f z }) z (mem_sep hz rfl) (hs.subset (sep_subset _ _)) #align set.fiber_ncard_ne_zero_iff_mem_image Set.fiber_ncard_ne_zero_iff_mem_image @[simp] theorem ncard_map (f : α ↪ β) : (f '' s).ncard = s.ncard := ncard_image_of_injective _ f.inj' #align set.ncard_map Set.ncard_map @[simp] theorem ncard_subtype (P : α → Prop) (s : Set α) : { x : Subtype P | (x : α) ∈ s }.ncard = (s ∩ setOf P).ncard := by convert (ncard_image_of_injective _ (@Subtype.coe_injective _ P)).symm ext x simp [← and_assoc, exists_eq_right] #align set.ncard_subtype Set.ncard_subtype theorem ncard_inter_le_ncard_left (s t : Set α) (hs : s.Finite := by toFinite_tac) : (s ∩ t).ncard ≤ s.ncard := ncard_le_ncard inter_subset_left hs #align set.ncard_inter_le_ncard_left Set.ncard_inter_le_ncard_left theorem ncard_inter_le_ncard_right (s t : Set α) (ht : t.Finite := by toFinite_tac) : (s ∩ t).ncard ≤ t.ncard := ncard_le_ncard inter_subset_right ht #align set.ncard_inter_le_ncard_right Set.ncard_inter_le_ncard_right theorem eq_of_subset_of_ncard_le (h : s ⊆ t) (h' : t.ncard ≤ s.ncard) (ht : t.Finite := by toFinite_tac) : s = t := ht.eq_of_subset_of_encard_le h (by rwa [← Nat.cast_le (α := ℕ∞), ht.cast_ncard_eq, (ht.subset h).cast_ncard_eq] at h') #align set.eq_of_subset_of_ncard_le Set.eq_of_subset_of_ncard_le theorem subset_iff_eq_of_ncard_le (h : t.ncard ≤ s.ncard) (ht : t.Finite := by toFinite_tac) : s ⊆ t ↔ s = t := ⟨fun hst ↦ eq_of_subset_of_ncard_le hst h ht, Eq.subset'⟩ #align set.subset_iff_eq_of_ncard_le Set.subset_iff_eq_of_ncard_le theorem map_eq_of_subset {f : α ↪ α} (h : f '' s ⊆ s) (hs : s.Finite := by toFinite_tac) : f '' s = s := eq_of_subset_of_ncard_le h (ncard_map _).ge hs #align set.map_eq_of_subset Set.map_eq_of_subset theorem sep_of_ncard_eq {a : α} {P : α → Prop} (h : { x ∈ s | P x }.ncard = s.ncard) (ha : a ∈ s) (hs : s.Finite := by toFinite_tac) : P a := sep_eq_self_iff_mem_true.mp (eq_of_subset_of_ncard_le (by simp) h.symm.le hs) _ ha #align set.sep_of_ncard_eq Set.sep_of_ncard_eq theorem ncard_lt_ncard (h : s ⊂ t) (ht : t.Finite := by toFinite_tac) : s.ncard < t.ncard := by rw [← Nat.cast_lt (α := ℕ∞), ht.cast_ncard_eq, (ht.subset h.subset).cast_ncard_eq] exact ht.encard_lt_encard h #align set.ncard_lt_ncard Set.ncard_lt_ncard theorem ncard_strictMono [Finite α] : @StrictMono (Set α) _ _ _ ncard := fun _ _ h ↦ ncard_lt_ncard h #align set.ncard_strict_mono Set.ncard_strictMono theorem ncard_eq_of_bijective {n : ℕ} (f : ∀ i, i < n → α) (hf : ∀ a ∈ s, ∃ i, ∃ h : i < n, f i h = a) (hf' : ∀ (i) (h : i < n), f i h ∈ s) (f_inj : ∀ (i j) (hi : i < n) (hj : j < n), f i hi = f j hj → i = j) : s.ncard = n := by let f' : Fin n → α := fun i ↦ f i.val i.is_lt suffices himage : s = f' '' Set.univ by rw [← Fintype.card_fin n, ← Nat.card_eq_fintype_card, ← Set.ncard_univ, himage] exact ncard_image_of_injOn <| fun i _hi j _hj h ↦ Fin.ext <| f_inj i.val j.val i.is_lt j.is_lt h ext x simp only [image_univ, mem_range] refine ⟨fun hx ↦ ?_, fun ⟨⟨i, hi⟩, hx⟩ ↦ hx ▸ hf' i hi⟩ obtain ⟨i, hi, rfl⟩ := hf x hx use ⟨i, hi⟩ #align set.ncard_eq_of_bijective Set.ncard_eq_of_bijective theorem ncard_congr {t : Set β} (f : ∀ a ∈ s, β) (h₁ : ∀ a ha, f a ha ∈ t) (h₂ : ∀ a b ha hb, f a ha = f b hb → a = b) (h₃ : ∀ b ∈ t, ∃ a ha, f a ha = b) : s.ncard = t.ncard := by set f' : s → t := fun x ↦ ⟨f x.1 x.2, h₁ _ _⟩ have hbij : f'.Bijective := by constructor · rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy simp only [f', Subtype.mk.injEq] at hxy ⊢ exact h₂ _ _ hx hy hxy rintro ⟨y, hy⟩ obtain ⟨a, ha, rfl⟩ := h₃ y hy simp only [Subtype.mk.injEq, Subtype.exists] exact ⟨_, ha, rfl⟩ simp_rw [← Nat.card_coe_set_eq] exact Nat.card_congr (Equiv.ofBijective f' hbij) #align set.ncard_congr Set.ncard_congr theorem ncard_le_ncard_of_injOn {t : Set β} (f : α → β) (hf : ∀ a ∈ s, f a ∈ t) (f_inj : InjOn f s) (ht : t.Finite := by toFinite_tac) : s.ncard ≤ t.ncard := by have hle := encard_le_encard_of_injOn hf f_inj to_encard_tac; rwa [ht.cast_ncard_eq, (ht.finite_of_encard_le hle).cast_ncard_eq] #align set.ncard_le_ncard_of_inj_on Set.ncard_le_ncard_of_injOn theorem exists_ne_map_eq_of_ncard_lt_of_maps_to {t : Set β} (hc : t.ncard < s.ncard) {f : α → β} (hf : ∀ a ∈ s, f a ∈ t) (ht : t.Finite := by toFinite_tac) : ∃ x ∈ s, ∃ y ∈ s, x ≠ y ∧ f x = f y := by by_contra h' simp only [Ne, exists_prop, not_exists, not_and, not_imp_not] at h' exact (ncard_le_ncard_of_injOn f hf h' ht).not_lt hc #align set.exists_ne_map_eq_of_ncard_lt_of_maps_to Set.exists_ne_map_eq_of_ncard_lt_of_maps_to theorem le_ncard_of_inj_on_range {n : ℕ} (f : ℕ → α) (hf : ∀ i < n, f i ∈ s) (f_inj : ∀ i < n, ∀ j < n, f i = f j → i = j) (hs : s.Finite := by toFinite_tac) : n ≤ s.ncard := by rw [ncard_eq_toFinset_card _ hs] apply Finset.le_card_of_inj_on_range <;> simpa #align set.le_ncard_of_inj_on_range Set.le_ncard_of_inj_on_range theorem surj_on_of_inj_on_of_ncard_le {t : Set β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t) (hinj : ∀ a₁ a₂ ha₁ ha₂, f a₁ ha₁ = f a₂ ha₂ → a₁ = a₂) (hst : t.ncard ≤ s.ncard) (ht : t.Finite := by toFinite_tac) : ∀ b ∈ t, ∃ a ha, b = f a ha := by intro b hb set f' : s → t := fun x ↦ ⟨f x.1 x.2, hf _ _⟩ have finj : f'.Injective := by rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy simp only [f', Subtype.mk.injEq] at hxy ⊢ apply hinj _ _ hx hy hxy have hft := ht.fintype have hft' := Fintype.ofInjective f' finj set f'' : ∀ a, a ∈ s.toFinset → β := fun a h ↦ f a (by simpa using h) convert @Finset.surj_on_of_inj_on_of_card_le _ _ _ t.toFinset f'' _ _ _ _ (by simpa) · simp · simp [hf] · intros a₁ a₂ ha₁ ha₂ h rw [mem_toFinset] at ha₁ ha₂ exact hinj _ _ ha₁ ha₂ h rwa [← ncard_eq_toFinset_card', ← ncard_eq_toFinset_card'] #align set.surj_on_of_inj_on_of_ncard_le Set.surj_on_of_inj_on_of_ncard_le theorem inj_on_of_surj_on_of_ncard_le {t : Set β} (f : ∀ a ∈ s, β) (hf : ∀ a ha, f a ha ∈ t) (hsurj : ∀ b ∈ t, ∃ a ha, f a ha = b) (hst : s.ncard ≤ t.ncard) ⦃a₁⦄ (ha₁ : a₁ ∈ s) ⦃a₂⦄ (ha₂ : a₂ ∈ s) (ha₁a₂ : f a₁ ha₁ = f a₂ ha₂) (hs : s.Finite := by toFinite_tac) : a₁ = a₂ := by classical set f' : s → t := fun x ↦ ⟨f x.1 x.2, hf _ _⟩ have hsurj : f'.Surjective := by rintro ⟨y, hy⟩ obtain ⟨a, ha, rfl⟩ := hsurj y hy simp only [Subtype.mk.injEq, Subtype.exists] exact ⟨_, ha, rfl⟩ haveI := hs.fintype haveI := Fintype.ofSurjective _ hsurj set f'' : ∀ a, a ∈ s.toFinset → β := fun a h ↦ f a (by simpa using h) exact @Finset.inj_on_of_surj_on_of_card_le _ _ _ t.toFinset f'' (fun a ha ↦ by { rw [mem_toFinset] at ha ⊢; exact hf a ha }) (by simpa) (by { rwa [← ncard_eq_toFinset_card', ← ncard_eq_toFinset_card'] }) a₁ (by simpa) a₂ (by simpa) (by simpa) #align set.inj_on_of_surj_on_of_ncard_le Set.inj_on_of_surj_on_of_ncard_le section Lattice theorem ncard_union_add_ncard_inter (s t : Set α) (hs : s.Finite := by toFinite_tac) (ht : t.Finite := by toFinite_tac) : (s ∪ t).ncard + (s ∩ t).ncard = s.ncard + t.ncard := by to_encard_tac; rw [hs.cast_ncard_eq, ht.cast_ncard_eq, (hs.union ht).cast_ncard_eq, (hs.subset inter_subset_left).cast_ncard_eq, encard_union_add_encard_inter] #align set.ncard_union_add_ncard_inter Set.ncard_union_add_ncard_inter theorem ncard_inter_add_ncard_union (s t : Set α) (hs : s.Finite := by toFinite_tac) (ht : t.Finite := by toFinite_tac) : (s ∩ t).ncard + (s ∪ t).ncard = s.ncard + t.ncard := by rw [add_comm, ncard_union_add_ncard_inter _ _ hs ht] #align set.ncard_inter_add_ncard_union Set.ncard_inter_add_ncard_union theorem ncard_union_le (s t : Set α) : (s ∪ t).ncard ≤ s.ncard + t.ncard := by obtain (h | h) := (s ∪ t).finite_or_infinite · to_encard_tac rw [h.cast_ncard_eq, (h.subset subset_union_left).cast_ncard_eq, (h.subset subset_union_right).cast_ncard_eq] apply encard_union_le rw [h.ncard] apply zero_le #align set.ncard_union_le Set.ncard_union_le theorem ncard_union_eq (h : Disjoint s t) (hs : s.Finite := by toFinite_tac) (ht : t.Finite := by toFinite_tac) : (s ∪ t).ncard = s.ncard + t.ncard := by to_encard_tac rw [hs.cast_ncard_eq, ht.cast_ncard_eq, (hs.union ht).cast_ncard_eq, encard_union_eq h] #align set.ncard_union_eq Set.ncard_union_eq theorem ncard_diff_add_ncard_of_subset (h : s ⊆ t) (ht : t.Finite := by toFinite_tac) : (t \ s).ncard + s.ncard = t.ncard := by to_encard_tac rw [ht.cast_ncard_eq, (ht.subset h).cast_ncard_eq, (ht.diff _).cast_ncard_eq, encard_diff_add_encard_of_subset h] #align set.ncard_diff_add_ncard_eq_ncard Set.ncard_diff_add_ncard_of_subset theorem ncard_diff (h : s ⊆ t) (ht : t.Finite := by toFinite_tac) : (t \ s).ncard = t.ncard - s.ncard := by rw [← ncard_diff_add_ncard_of_subset h ht, add_tsub_cancel_right] #align set.ncard_diff Set.ncard_diff theorem ncard_le_ncard_diff_add_ncard (s t : Set α) (ht : t.Finite := by toFinite_tac) : s.ncard ≤ (s \ t).ncard + t.ncard := by cases' s.finite_or_infinite with hs hs · to_encard_tac rw [ht.cast_ncard_eq, hs.cast_ncard_eq, (hs.diff _).cast_ncard_eq] apply encard_le_encard_diff_add_encard convert Nat.zero_le _ rw [hs.ncard] #align set.ncard_le_ncard_diff_add_ncard Set.ncard_le_ncard_diff_add_ncard theorem le_ncard_diff (s t : Set α) (hs : s.Finite := by toFinite_tac) : t.ncard - s.ncard ≤ (t \ s).ncard := tsub_le_iff_left.mpr (by rw [add_comm]; apply ncard_le_ncard_diff_add_ncard _ _ hs) #align set.le_ncard_diff Set.le_ncard_diff theorem ncard_diff_add_ncard (s t : Set α) (hs : s.Finite := by toFinite_tac) (ht : t.Finite := by toFinite_tac) : (s \ t).ncard + t.ncard = (s ∪ t).ncard := by rw [← ncard_union_eq disjoint_sdiff_left (hs.diff _) ht, diff_union_self] #align set.ncard_diff_add_ncard Set.ncard_diff_add_ncard theorem diff_nonempty_of_ncard_lt_ncard (h : s.ncard < t.ncard) (hs : s.Finite := by toFinite_tac) : (t \ s).Nonempty := by rw [Set.nonempty_iff_ne_empty, Ne, diff_eq_empty] exact fun h' ↦ h.not_le (ncard_le_ncard h' hs) #align set.diff_nonempty_of_ncard_lt_ncard Set.diff_nonempty_of_ncard_lt_ncard theorem exists_mem_not_mem_of_ncard_lt_ncard (h : s.ncard < t.ncard) (hs : s.Finite := by toFinite_tac) : ∃ e, e ∈ t ∧ e ∉ s := diff_nonempty_of_ncard_lt_ncard h hs #align set.exists_mem_not_mem_of_ncard_lt_ncard Set.exists_mem_not_mem_of_ncard_lt_ncard @[simp] theorem ncard_inter_add_ncard_diff_eq_ncard (s t : Set α) (hs : s.Finite := by toFinite_tac) : (s ∩ t).ncard + (s \ t).ncard = s.ncard := by rw [← ncard_union_eq (disjoint_of_subset_left inter_subset_right disjoint_sdiff_right) (hs.inter_of_left _) (hs.diff _), union_comm, diff_union_inter] #align set.ncard_inter_add_ncard_diff_eq_ncard Set.ncard_inter_add_ncard_diff_eq_ncard theorem ncard_eq_ncard_iff_ncard_diff_eq_ncard_diff (hs : s.Finite := by toFinite_tac) (ht : t.Finite := by toFinite_tac) : s.ncard = t.ncard ↔ (s \ t).ncard = (t \ s).ncard := by rw [← ncard_inter_add_ncard_diff_eq_ncard s t hs, ← ncard_inter_add_ncard_diff_eq_ncard t s ht, inter_comm, add_right_inj] #align set.ncard_eq_ncard_iff_ncard_diff_eq_ncard_diff Set.ncard_eq_ncard_iff_ncard_diff_eq_ncard_diff
Mathlib/Data/Set/Card.lean
922
925
theorem ncard_le_ncard_iff_ncard_diff_le_ncard_diff (hs : s.Finite := by
toFinite_tac) (ht : t.Finite := by toFinite_tac) : s.ncard ≤ t.ncard ↔ (s \ t).ncard ≤ (t \ s).ncard := by rw [← ncard_inter_add_ncard_diff_eq_ncard s t hs, ← ncard_inter_add_ncard_diff_eq_ncard t s ht, inter_comm, add_le_add_iff_left]
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ 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" /-! # Verification of the `Ordnode α` datatype This file proves the correctness of the operations in `Data.Ordmap.Ordnode`. The public facing version is the type `Ordset α`, which is a wrapper around `Ordnode α` which includes the correctness invariant of the type, and it exposes parallel operations like `insert` as functions on `Ordset` that do the same thing but bundle the correctness proofs. The advantage is that it is possible to, for example, prove that the result of `find` on `insert` will actually find the element, while `Ordnode` cannot guarantee this if the input tree did not satisfy the type invariants. ## Main definitions * `Ordset α`: A well formed set of values of type `α` ## Implementation notes The majority of this file is actually in the `Ordnode` namespace, because we first have to prove the correctness of all the operations (and defining what correctness means here is actually somewhat subtle). So all the actual `Ordset` operations are at the very end, once we have all the theorems. An `Ordnode α` is an inductive type which describes a tree which stores the `size` at internal nodes. The correctness invariant of an `Ordnode α` is: * `Ordnode.Sized t`: All internal `size` fields must match the actual measured size of the tree. (This is not hard to satisfy.) * `Ordnode.Balanced t`: Unless the tree has the form `()` or `((a) b)` or `(a (b))` (that is, nil or a single singleton subtree), the two subtrees must satisfy `size l ≤ δ * size r` and `size r ≤ δ * size l`, where `δ := 3` is a global parameter of the data structure (and this property must hold recursively at subtrees). This is why we say this is a "size balanced tree" data structure. * `Ordnode.Bounded lo hi t`: The members of the tree must be in strictly increasing order, meaning that if `a` is in the left subtree and `b` is the root, then `a ≤ b` and `¬ (b ≤ a)`. We enforce this using `Ordnode.Bounded` which includes also a global upper and lower bound. Because the `Ordnode` file was ported from Haskell, the correctness invariants of some of the functions have not been spelled out, and some theorems like `Ordnode.Valid'.balanceL_aux` show very intricate assumptions on the sizes, which may need to be revised if it turns out some operations violate these assumptions, because there is a decent amount of slop in the actual data structure invariants, so the theorem will go through with multiple choices of assumption. **Note:** This file is incomplete, in the sense that the intent is to have verified versions and lemmas about all the definitions in `Ordnode.lean`, but at the moment only a few operations are verified (the hard part should be out of the way, but still). Contributors are encouraged to pick this up and finish the job, if it appeals to you. ## Tags ordered map, ordered set, data structure, verified programming -/ variable {α : Type*} namespace Ordnode /-! ### delta and ratio -/ 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 /-! ### `singleton` -/ /-! ### `size` and `empty` -/ /-- O(n). Computes the actual number of elements in the set, ignoring the cached `size` field. -/ def realSize : Ordnode α → ℕ | nil => 0 | node _ l _ r => realSize l + realSize r + 1 #align ordnode.real_size Ordnode.realSize /-! ### `Sized` -/ /-- The `Sized` property asserts that all the `size` fields in nodes match the actual size of the respective subtrees. -/ 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 /-! `dual` -/ 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 /-! `Balanced` -/ /-- The `BalancedSz l r` asserts that a hypothetical tree with children of sizes `l` and `r` is balanced: either `l ≤ δ * r` and `r ≤ δ * r`, or the tree is trivial with a singleton on one side and nothing on the other. -/ 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 /-- The `Balanced t` asserts that the tree `t` satisfies the balance invariants (at every level). -/ 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 /-! ### `rotate` and `balance` -/ /-- Build a tree from three nodes, left associated (ignores the invariants). -/ def node3L (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' (node' l x m) y r #align ordnode.node3_l Ordnode.node3L /-- Build a tree from three nodes, right associated (ignores the invariants). -/ def node3R (l : Ordnode α) (x : α) (m : Ordnode α) (y : α) (r : Ordnode α) : Ordnode α := node' l x (node' m y r) #align ordnode.node3_r Ordnode.node3R /-- Build a tree from three nodes, with `a () b -> (a ()) b` and `a (b c) d -> ((a b) (c d))`. -/ 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 /-- Build a tree from three nodes, with `a () b -> a (() b)` and `a (b c) d -> ((a b) (c d))`. -/ 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 /-- Concatenate two nodes, performing a left rotation `x (y z) -> ((x y) z)` if balance is upset. -/ 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 /-- Concatenate two nodes, performing a right rotation `(x y) z -> (x (y z))` if balance is upset. -/ 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 /-- A left balance operation. This will rebalance a concatenation, assuming the original nodes are not too far from balanced. -/ 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' /-- A right balance operation. This will rebalance a concatenation, assuming the original nodes are not too far from balanced. -/ 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' /-- The full balance operation. This is the same as `balance`, but with less manual inlining. It is somewhat easier to work with this version in proofs. -/ 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
Mathlib/Data/Ordmap/Ordset.lean
321
323
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]
/- Copyright (c) 2023 Antoine Chambert-Loir. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Antoine Chambert-Loir -/ import Mathlib.Algebra.Exact import Mathlib.RingTheory.TensorProduct.Basic /-! # Right-exactness properties of tensor product ## Modules * `LinearMap.rTensor_surjective` asserts that when one tensors a surjective map on the right, one still gets a surjective linear map. More generally, `LinearMap.rTensor_range` computes the range of `LinearMap.rTensor` * `LinearMap.lTensor_surjective` asserts that when one tensors a surjective map on the left, one still gets a surjective linear map. More generally, `LinearMap.lTensor_range` computes the range of `LinearMap.lTensor` * `TensorProduct.rTensor_exact` says that when one tensors a short exact sequence on the right, one still gets a short exact sequence (right-exactness of `TensorProduct.rTensor`), and `rTensor.equiv` gives the LinearEquiv that follows from this combined with `LinearMap.rTensor_surjective`. * `TensorProduct.lTensor_exact` says that when one tensors a short exact sequence on the left, one still gets a short exact sequence (right-exactness of `TensorProduct.rTensor`) and `lTensor.equiv` gives the LinearEquiv that follows from this combined with `LinearMap.lTensor_surjective`. * For `N : Submodule R M`, `LinearMap.exact_subtype_mkQ N` says that the inclusion of the submodule and the quotient map form an exact pair, and `lTensor_mkQ` compute `ker (lTensor Q (N.mkQ))` and similarly for `rTensor_mkQ` * `TensorProduct.map_ker` computes the kernel of `TensorProduct.map f g'` in the presence of two short exact sequences. The proofs are those of [bourbaki1989] (chap. 2, §3, n°6) ## Algebras In the case of a tensor product of algebras, these results can be particularized to compute some kernels. * `Algebra.TensorProduct.ker_map` computes the kernel of `Algebra.TensorProduct.map f g` * `Algebra.TensorProduct.lTensor_ker` and `Algebra.TensorProduct.rTensor_ker` compute the kernels of `Algebra.TensorProduct.map f id` and `Algebra.TensorProduct.map id g` ## Note on implementation * All kernels are computed by applying the first isomorphism theorem and establishing some isomorphisms. * The proofs are essentially done twice, once for `lTensor` and then for `rTensor`. It is possible to apply `TensorProduct.flip` to deduce one of them from the other. However, this approach will lead to different isomorphisms, and it is not quicker. * The proofs of `Ideal.map_includeLeft_eq` and `Ideal.map_includeRight_eq` could be easier if `I ⊗[R] B` was naturally an `A ⊗[R] B` module, and the map to `A ⊗[R] B` was known to be linear. This depends on the B-module structure on a tensor product whose use rapidly conflicts with everything… ## TODO * Treat the noncommutative case * Treat the case of modules over semirings (For a possible definition of an exact sequence of commutative semigroups, see [Grillet-1969b], Pierre-Antoine Grillet, *The tensor product of commutative semigroups*, Trans. Amer. Math. Soc. 138 (1969), 281-293, doi:10.1090/S0002-9947-1969-0237688-1 .) -/ section Modules open TensorProduct LinearMap section Semiring variable {R : Type*} [CommSemiring R] {M N P Q: Type*} [AddCommMonoid M] [AddCommMonoid N] [AddCommMonoid P] [AddCommMonoid Q] [Module R M] [Module R N] [Module R P] [Module R Q] {f : M →ₗ[R] N} (g : N →ₗ[R] P) lemma le_comap_range_lTensor (q : Q) : LinearMap.range g ≤ (LinearMap.range (lTensor Q g)).comap (TensorProduct.mk R Q P q) := by rintro x ⟨n, rfl⟩ exact ⟨q ⊗ₜ[R] n, rfl⟩ lemma le_comap_range_rTensor (q : Q) : LinearMap.range g ≤ (LinearMap.range (rTensor Q g)).comap ((TensorProduct.mk R P Q).flip q) := by rintro x ⟨n, rfl⟩ exact ⟨n ⊗ₜ[R] q, rfl⟩ variable (Q) {g} /-- If `g` is surjective, then `lTensor Q g` is surjective -/ theorem LinearMap.lTensor_surjective (hg : Function.Surjective g) : Function.Surjective (lTensor Q g) := by intro z induction z using TensorProduct.induction_on with | zero => exact ⟨0, map_zero _⟩ | tmul q p => obtain ⟨n, rfl⟩ := hg p exact ⟨q ⊗ₜ[R] n, rfl⟩ | add x y hx hy => obtain ⟨x, rfl⟩ := hx obtain ⟨y, rfl⟩ := hy exact ⟨x + y, map_add _ _ _⟩ theorem LinearMap.lTensor_range : range (lTensor Q g) = range (lTensor Q (Submodule.subtype (range g))) := by have : g = (Submodule.subtype _).comp g.rangeRestrict := rfl nth_rewrite 1 [this] rw [lTensor_comp] apply range_comp_of_range_eq_top rw [range_eq_top] apply lTensor_surjective rw [← range_eq_top, range_rangeRestrict] /-- If `g` is surjective, then `rTensor Q g` is surjective -/ theorem LinearMap.rTensor_surjective (hg : Function.Surjective g) : Function.Surjective (rTensor Q g) := by intro z induction z using TensorProduct.induction_on with | zero => exact ⟨0, map_zero _⟩ | tmul p q => obtain ⟨n, rfl⟩ := hg p exact ⟨n ⊗ₜ[R] q, rfl⟩ | add x y hx hy => obtain ⟨x, rfl⟩ := hx obtain ⟨y, rfl⟩ := hy exact ⟨x + y, map_add _ _ _⟩ theorem LinearMap.rTensor_range : range (rTensor Q g) = range (rTensor Q (Submodule.subtype (range g))) := by have : g = (Submodule.subtype _).comp g.rangeRestrict := rfl nth_rewrite 1 [this] rw [rTensor_comp] apply range_comp_of_range_eq_top rw [range_eq_top] apply rTensor_surjective rw [← range_eq_top, range_rangeRestrict] end Semiring variable {R M N P : Type*} [CommRing R] [AddCommGroup M] [AddCommGroup N] [AddCommGroup P] [Module R M] [Module R N] [Module R P] open Function LinearMap -- TODO: Move this and related lemmas to another file lemma LinearMap.exact_subtype_mkQ (Q : Submodule R N) : Exact (Submodule.subtype Q) (Submodule.mkQ Q) := by rw [exact_iff, Submodule.ker_mkQ, Submodule.range_subtype Q] lemma LinearMap.exact_map_mkQ_range (f : M →ₗ[R] N) : Exact f (Submodule.mkQ (range f)) := exact_iff.mpr <| Submodule.ker_mkQ _ lemma LinearMap.exact_subtype_ker_map (g : N →ₗ[R] P) : Exact (Submodule.subtype (ker g)) g := exact_iff.mpr <| (Submodule.range_subtype _).symm variable {f : M →ₗ[R] N} {g : N →ₗ[R] P} (Q : Type*) [AddCommGroup Q] [Module R Q] (hfg : Exact f g) (hg : Function.Surjective g) /-- The direct map in `lTensor.equiv` -/ noncomputable def lTensor.toFun : Q ⊗[R] N ⧸ LinearMap.range (lTensor Q f) →ₗ[R] Q ⊗[R] P := Submodule.liftQ _ (lTensor Q g) <| by rw [LinearMap.range_le_iff_comap, ← LinearMap.ker_comp, ← lTensor_comp, hfg.linearMap_comp_eq_zero, lTensor_zero, ker_zero] /-- The inverse map in `lTensor.equiv_of_rightInverse` (computably, given a right inverse)-/ noncomputable def lTensor.inverse_of_rightInverse {h : P → N} (hgh : Function.RightInverse h g) : Q ⊗[R] P →ₗ[R] Q ⊗[R] N ⧸ LinearMap.range (lTensor Q f) := TensorProduct.lift <| LinearMap.flip <| { toFun := fun p ↦ Submodule.mkQ _ ∘ₗ ((TensorProduct.mk R _ _).flip (h p)) map_add' := fun p p' => LinearMap.ext fun q => (Submodule.Quotient.eq _).mpr <| by change q ⊗ₜ[R] (h (p + p')) - (q ⊗ₜ[R] (h p) + q ⊗ₜ[R] (h p')) ∈ range (lTensor Q f) rw [← TensorProduct.tmul_add, ← TensorProduct.tmul_sub] apply le_comap_range_lTensor f rw [exact_iff] at hfg simp only [← hfg, mem_ker, map_sub, map_add, hgh _, sub_self] map_smul' := fun r p => LinearMap.ext fun q => (Submodule.Quotient.eq _).mpr <| by change q ⊗ₜ[R] (h (r • p)) - r • q ⊗ₜ[R] (h p) ∈ range (lTensor Q f) rw [← TensorProduct.tmul_smul, ← TensorProduct.tmul_sub] apply le_comap_range_lTensor f rw [exact_iff] at hfg simp only [← hfg, mem_ker, map_sub, map_smul, hgh _, sub_self] } lemma lTensor.inverse_of_rightInverse_apply {h : P → N} (hgh : Function.RightInverse h g) (y : Q ⊗[R] N) : (lTensor.inverse_of_rightInverse Q hfg hgh) ((lTensor Q g) y) = Submodule.Quotient.mk (p := (LinearMap.range (lTensor Q f))) y := by simp only [← LinearMap.comp_apply, ← Submodule.mkQ_apply] rw [exact_iff] at hfg apply LinearMap.congr_fun apply TensorProduct.ext' intro n q simp? [lTensor.inverse_of_rightInverse] says simp only [inverse_of_rightInverse, coe_comp, Function.comp_apply, lTensor_tmul, lift.tmul, flip_apply, coe_mk, AddHom.coe_mk, mk_apply, Submodule.mkQ_apply] rw [Submodule.Quotient.eq, ← TensorProduct.tmul_sub] apply le_comap_range_lTensor f n rw [← hfg, mem_ker, map_sub, sub_eq_zero, hgh] lemma lTensor.inverse_of_rightInverse_comp_lTensor {h : P → N} (hgh : Function.RightInverse h g) : (lTensor.inverse_of_rightInverse Q hfg hgh).comp (lTensor Q g) = Submodule.mkQ (p := LinearMap.range (lTensor Q f)) := by rw [LinearMap.ext_iff] intro y simp only [coe_comp, Function.comp_apply, Submodule.mkQ_apply, lTensor.inverse_of_rightInverse_apply] /-- The inverse map in `lTensor.equiv` -/ noncomputable def lTensor.inverse : Q ⊗[R] P →ₗ[R] Q ⊗[R] N ⧸ LinearMap.range (lTensor Q f) := lTensor.inverse_of_rightInverse Q hfg (Function.rightInverse_surjInv hg) lemma lTensor.inverse_apply (y : Q ⊗[R] N) : (lTensor.inverse Q hfg hg) ((lTensor Q g) y) = Submodule.Quotient.mk (p := (LinearMap.range (lTensor Q f))) y := by rw [lTensor.inverse, lTensor.inverse_of_rightInverse_apply] lemma lTensor.inverse_comp_lTensor : (lTensor.inverse Q hfg hg).comp (lTensor Q g) = Submodule.mkQ (p := LinearMap.range (lTensor Q f)) := by rw [lTensor.inverse, lTensor.inverse_of_rightInverse_comp_lTensor] /-- For a surjective `f : N →ₗ[R] P`, the natural equivalence between `Q ⊗ N ⧸ (image of ker f)` to `Q ⊗ P` (computably, given a right inverse) -/ noncomputable def lTensor.linearEquiv_of_rightInverse {h : P → N} (hgh : Function.RightInverse h g) : ((Q ⊗[R] N) ⧸ (LinearMap.range (lTensor Q f))) ≃ₗ[R] (Q ⊗[R] P) := { toLinearMap := lTensor.toFun Q hfg invFun := lTensor.inverse_of_rightInverse Q hfg hgh left_inv := fun y ↦ by simp only [lTensor.toFun, AddHom.toFun_eq_coe, coe_toAddHom] obtain ⟨y, rfl⟩ := Submodule.mkQ_surjective _ y simp only [Submodule.mkQ_apply, Submodule.liftQ_apply, lTensor.inverse_of_rightInverse_apply] right_inv := fun z ↦ by simp only [AddHom.toFun_eq_coe, coe_toAddHom] obtain ⟨y, rfl⟩ := lTensor_surjective Q (hgh.surjective) z rw [lTensor.inverse_of_rightInverse_apply] simp only [lTensor.toFun, Submodule.liftQ_apply] } /-- For a surjective `f : N →ₗ[R] P`, the natural equivalence between `Q ⊗ N ⧸ (image of ker f)` to `Q ⊗ P` -/ noncomputable def lTensor.equiv : ((Q ⊗[R] N) ⧸ (LinearMap.range (lTensor Q f))) ≃ₗ[R] (Q ⊗[R] P) := lTensor.linearEquiv_of_rightInverse Q hfg (Function.rightInverse_surjInv hg) /-- Tensoring an exact pair on the left gives an exact pair -/ theorem lTensor_exact : Exact (lTensor Q f) (lTensor Q g) := by rw [exact_iff, ← Submodule.ker_mkQ (p := range (lTensor Q f)), ← lTensor.inverse_comp_lTensor Q hfg hg] apply symm apply LinearMap.ker_comp_of_ker_eq_bot rw [LinearMap.ker_eq_bot] exact (lTensor.equiv Q hfg hg).symm.injective /-- Right-exactness of tensor product -/ lemma lTensor_mkQ (N : Submodule R M) : ker (lTensor Q (N.mkQ)) = range (lTensor Q N.subtype) := by rw [← exact_iff] exact lTensor_exact Q (LinearMap.exact_subtype_mkQ N) (Submodule.mkQ_surjective N) /-- The direct map in `rTensor.equiv` -/ noncomputable def rTensor.toFun : N ⊗[R] Q ⧸ range (rTensor Q f) →ₗ[R] P ⊗[R] Q := Submodule.liftQ _ (rTensor Q g) <| by rw [range_le_iff_comap, ← ker_comp, ← rTensor_comp, hfg.linearMap_comp_eq_zero, rTensor_zero, ker_zero] /-- The inverse map in `rTensor.equiv_of_rightInverse` (computably, given a right inverse) -/ noncomputable def rTensor.inverse_of_rightInverse {h : P → N} (hgh : Function.RightInverse h g) : P ⊗[R] Q →ₗ[R] N ⊗[R] Q ⧸ LinearMap.range (rTensor Q f) := TensorProduct.lift { toFun := fun p ↦ Submodule.mkQ _ ∘ₗ TensorProduct.mk R _ _ (h p) map_add' := fun p p' => LinearMap.ext fun q => (Submodule.Quotient.eq _).mpr <| by change h (p + p') ⊗ₜ[R] q - (h p ⊗ₜ[R] q + h p' ⊗ₜ[R] q) ∈ range (rTensor Q f) rw [← TensorProduct.add_tmul, ← TensorProduct.sub_tmul] apply le_comap_range_rTensor f rw [exact_iff] at hfg simp only [← hfg, mem_ker, map_sub, map_add, hgh _, sub_self] map_smul' := fun r p => LinearMap.ext fun q => (Submodule.Quotient.eq _).mpr <| by change h (r • p) ⊗ₜ[R] q - r • h p ⊗ₜ[R] q ∈ range (rTensor Q f) rw [TensorProduct.smul_tmul', ← TensorProduct.sub_tmul] apply le_comap_range_rTensor f rw [exact_iff] at hfg simp only [← hfg, mem_ker, map_sub, map_smul, hgh _, sub_self] } lemma rTensor.inverse_of_rightInverse_apply {h : P → N} (hgh : Function.RightInverse h g) (y : N ⊗[R] Q) : (rTensor.inverse_of_rightInverse Q hfg hgh) ((rTensor Q g) y) = Submodule.Quotient.mk (p := LinearMap.range (rTensor Q f)) y := by simp only [← LinearMap.comp_apply, ← Submodule.mkQ_apply] rw [exact_iff] at hfg apply LinearMap.congr_fun apply TensorProduct.ext' intro n q simp? [rTensor.inverse_of_rightInverse] says simp only [inverse_of_rightInverse, coe_comp, Function.comp_apply, rTensor_tmul, lift.tmul, coe_mk, AddHom.coe_mk, mk_apply, Submodule.mkQ_apply] rw [Submodule.Quotient.eq, ← TensorProduct.sub_tmul] apply le_comap_range_rTensor f rw [← hfg, mem_ker, map_sub, sub_eq_zero, hgh] lemma rTensor.inverse_of_rightInverse_comp_rTensor {h : P → N} (hgh : Function.RightInverse h g) : (rTensor.inverse_of_rightInverse Q hfg hgh).comp (rTensor Q g) = Submodule.mkQ (p := LinearMap.range (rTensor Q f)) := by rw [LinearMap.ext_iff] intro y simp only [coe_comp, Function.comp_apply, Submodule.mkQ_apply, rTensor.inverse_of_rightInverse_apply] /-- The inverse map in `rTensor.equiv` -/ noncomputable def rTensor.inverse : P ⊗[R] Q →ₗ[R] N ⊗[R] Q ⧸ LinearMap.range (rTensor Q f) := rTensor.inverse_of_rightInverse Q hfg (Function.rightInverse_surjInv hg) lemma rTensor.inverse_apply (y : N ⊗[R] Q) : (rTensor.inverse Q hfg hg) ((rTensor Q g) y) = Submodule.Quotient.mk (p := LinearMap.range (rTensor Q f)) y := by rw [rTensor.inverse, rTensor.inverse_of_rightInverse_apply] lemma rTensor.inverse_comp_rTensor : (rTensor.inverse Q hfg hg).comp (rTensor Q g) = Submodule.mkQ (p := LinearMap.range (rTensor Q f)) := by rw [rTensor.inverse, rTensor.inverse_of_rightInverse_comp_rTensor] /-- For a surjective `f : N →ₗ[R] P`, the natural equivalence between `N ⊗[R] Q ⧸ (range (rTensor Q f))` and `P ⊗[R] Q` (computably, given a right inverse) -/ noncomputable def rTensor.linearEquiv_of_rightInverse {h : P → N} (hgh : Function.RightInverse h g) : ((N ⊗[R] Q) ⧸ (range (rTensor Q f))) ≃ₗ[R] (P ⊗[R] Q) := { toLinearMap := rTensor.toFun Q hfg invFun := rTensor.inverse_of_rightInverse Q hfg hgh left_inv := fun y ↦ by simp only [rTensor.toFun, AddHom.toFun_eq_coe, coe_toAddHom] obtain ⟨y, rfl⟩ := Submodule.mkQ_surjective _ y simp only [Submodule.mkQ_apply, Submodule.liftQ_apply, rTensor.inverse_of_rightInverse_apply] right_inv := fun z ↦ by simp only [AddHom.toFun_eq_coe, coe_toAddHom] obtain ⟨y, rfl⟩ := rTensor_surjective Q hgh.surjective z rw [rTensor.inverse_of_rightInverse_apply] simp only [rTensor.toFun, Submodule.liftQ_apply] } /-- For a surjective `f : N →ₗ[R] P`, the natural equivalence between `N ⊗[R] Q ⧸ (range (rTensor Q f))` and `P ⊗[R] Q` -/ noncomputable def rTensor.equiv : ((N ⊗[R] Q) ⧸ (LinearMap.range (rTensor Q f))) ≃ₗ[R] (P ⊗[R] Q) := rTensor.linearEquiv_of_rightInverse Q hfg (Function.rightInverse_surjInv hg) /-- Tensoring an exact pair on the right gives an exact pair -/ theorem rTensor_exact : Exact (rTensor Q f) (rTensor Q g) := by rw [exact_iff, ← Submodule.ker_mkQ (p := range (rTensor Q f)), ← rTensor.inverse_comp_rTensor Q hfg hg] apply symm apply ker_comp_of_ker_eq_bot rw [ker_eq_bot] exact (rTensor.equiv Q hfg hg).symm.injective /-- Right-exactness of tensor product (`rTensor`) -/ lemma rTensor_mkQ (N : Submodule R M) : ker (rTensor Q (N.mkQ)) = range (rTensor Q N.subtype) := by rw [← exact_iff] exact rTensor_exact Q (LinearMap.exact_subtype_mkQ N) (Submodule.mkQ_surjective N) variable {M' N' P' : Type*} [AddCommGroup M'] [AddCommGroup N'] [AddCommGroup P'] [Module R M'] [Module R N'] [Module R P'] {f' : M' →ₗ[R] N'} {g' : N' →ₗ[R] P'} (hfg' : Exact f' g') (hg' : Function.Surjective g') theorem TensorProduct.map_surjective : Function.Surjective (TensorProduct.map g g') := by rw [← lTensor_comp_rTensor, coe_comp] exact Function.Surjective.comp (lTensor_surjective _ hg') (rTensor_surjective _ hg) /-- Kernel of a product map (right-exactness of tensor product) -/ theorem TensorProduct.map_ker : ker (TensorProduct.map g g') = range (lTensor N f') ⊔ range (rTensor N' f) := by rw [← lTensor_comp_rTensor] rw [ker_comp] rw [← Exact.linearMap_ker_eq (rTensor_exact N' hfg hg)] rw [← Submodule.comap_map_eq] apply congr_arg₂ _ rfl rw [range_eq_map, ← Submodule.map_comp, rTensor_comp_lTensor, Submodule.map_top] rw [← lTensor_comp_rTensor, range_eq_map, Submodule.map_comp, Submodule.map_top] rw [range_eq_top.mpr (rTensor_surjective M' hg), Submodule.map_top] rw [Exact.linearMap_ker_eq (lTensor_exact P hfg' hg')] variable (M) /-- Left tensoring a module with a quotient of the ring is the same as quotienting that module by the corresponding submodule. -/ noncomputable def quotTensorEquivQuotSMul (I : Ideal R) : (R ⧸ I) ⊗[R] M ≃ₗ[R] M ⧸ (I • ⊤ : Submodule R M) := (rTensor.equiv M (exact_subtype_mkQ I) I.mkQ_surjective).symm.trans <| Submodule.Quotient.equiv _ _ (TensorProduct.lid R M) <| Eq.trans (LinearMap.range_comp _ _).symm <| Eq.trans ((Submodule.topEquiv.lTensor I).range_comp _).symm <| Eq.symm <| Eq.trans (map₂_eq_range_lift_comp_mapIncl _ _ _) <| congrArg _ (TensorProduct.ext' (fun _ _ => rfl)) /-- Right tensoring a module with a quotient of the ring is the same as quotienting that module by the corresponding submodule. -/ noncomputable def tensorQuotEquivQuotSMul (I : Ideal R) : M ⊗[R] (R ⧸ I) ≃ₗ[R] M ⧸ (I • ⊤ : Submodule R M) := TensorProduct.comm R M _ ≪≫ₗ quotTensorEquivQuotSMul M I variable {M} @[simp] lemma quotTensorEquivQuotSMul_mk_tmul (I : Ideal R) (r : R) (x : M) : quotTensorEquivQuotSMul M I (Ideal.Quotient.mk I r ⊗ₜ[R] x) = Submodule.Quotient.mk (r • x) := (quotTensorEquivQuotSMul M I).eq_symm_apply.mp <| Eq.trans (congrArg (· ⊗ₜ[R] x) <| Eq.trans (congrArg (Ideal.Quotient.mk I) (Eq.trans (smul_eq_mul R) (mul_one r))).symm <| Submodule.Quotient.mk_smul I r 1) <| smul_tmul r _ x lemma quotTensorEquivQuotSMul_comp_mkQ_rTensor (I : Ideal R) : quotTensorEquivQuotSMul M I ∘ₗ I.mkQ.rTensor M = (I • ⊤ : Submodule R M).mkQ ∘ₗ TensorProduct.lid R M := TensorProduct.ext' (quotTensorEquivQuotSMul_mk_tmul I) @[simp] lemma quotTensorEquivQuotSMul_symm_mk (I : Ideal R) (x : M) : (quotTensorEquivQuotSMul M I).symm (Submodule.Quotient.mk x) = 1 ⊗ₜ[R] x := rfl lemma quotTensorEquivQuotSMul_symm_comp_mkQ (I : Ideal R) : (quotTensorEquivQuotSMul M I).symm ∘ₗ (I • ⊤ : Submodule R M).mkQ = TensorProduct.mk R (R ⧸ I) M 1 := LinearMap.ext (quotTensorEquivQuotSMul_symm_mk I) lemma quotTensorEquivQuotSMul_comp_mk (I : Ideal R) : quotTensorEquivQuotSMul M I ∘ₗ TensorProduct.mk R (R ⧸ I) M 1 = Submodule.mkQ (I • ⊤) := Eq.symm <| (LinearEquiv.toLinearMap_symm_comp_eq _ _).mp <| quotTensorEquivQuotSMul_symm_comp_mkQ I @[simp] lemma tensorQuotEquivQuotSMul_tmul_mk (I : Ideal R) (x : M) (r : R) : tensorQuotEquivQuotSMul M I (x ⊗ₜ[R] Ideal.Quotient.mk I r) = Submodule.Quotient.mk (r • x) := quotTensorEquivQuotSMul_mk_tmul I r x lemma tensorQuotEquivQuotSMul_comp_mkQ_lTensor (I : Ideal R) : tensorQuotEquivQuotSMul M I ∘ₗ I.mkQ.lTensor M = (I • ⊤ : Submodule R M).mkQ ∘ₗ TensorProduct.rid R M := TensorProduct.ext' (tensorQuotEquivQuotSMul_tmul_mk I) @[simp] lemma tensorQuotEquivQuotSMul_symm_mk (I : Ideal R) (x : M) : (tensorQuotEquivQuotSMul M I).symm (Submodule.Quotient.mk x) = x ⊗ₜ[R] 1 := rfl lemma tensorQuotEquivQuotSMul_symm_comp_mkQ (I : Ideal R) : (tensorQuotEquivQuotSMul M I).symm ∘ₗ (I • ⊤ : Submodule R M).mkQ = (TensorProduct.mk R M (R ⧸ I)).flip 1 := LinearMap.ext (tensorQuotEquivQuotSMul_symm_mk I) lemma tensorQuotEquivQuotSMul_comp_mk (I : Ideal R) : tensorQuotEquivQuotSMul M I ∘ₗ (TensorProduct.mk R M (R ⧸ I)).flip 1 = Submodule.mkQ (I • ⊤) := Eq.symm <| (LinearEquiv.toLinearMap_symm_comp_eq _ _).mp <| tensorQuotEquivQuotSMul_symm_comp_mkQ I end Modules section Algebras open Algebra.TensorProduct open scoped TensorProduct variable {R : Type*} [CommSemiring R] {A B : Type*} [Semiring A] [Semiring B] [Algebra R A] [Algebra R B] /-- The ideal of `A ⊗[R] B` generated by `I` is the image of `I ⊗[R] B` -/ lemma Ideal.map_includeLeft_eq (I : Ideal A) : (I.map (Algebra.TensorProduct.includeLeft : A →ₐ[R] A ⊗[R] B)).restrictScalars R = LinearMap.range (LinearMap.rTensor B (Submodule.subtype (I.restrictScalars R))) := by rw [← Submodule.carrier_inj] apply le_antisymm · intro x simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.restrictScalars_mem, LinearMap.mem_range] intro hx rw [Ideal.map, ← submodule_span_eq] at hx refine Submodule.span_induction hx ?_ ?_ ?_ ?_ · intro x simp only [includeLeft_apply, Set.mem_image, SetLike.mem_coe] rintro ⟨y, hy, rfl⟩ use ⟨y, hy⟩ ⊗ₜ[R] 1 rfl · use 0 simp only [map_zero] · rintro x y ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩ use x + y simp only [map_add] · rintro a x ⟨x, hx, rfl⟩ induction a using TensorProduct.induction_on with | zero => use 0 simp only [map_zero, smul_eq_mul, zero_mul] | tmul a b => induction x using TensorProduct.induction_on with | zero => use 0 simp only [map_zero, smul_eq_mul, mul_zero] | tmul x y => use (a • x) ⊗ₜ[R] (b * y) simp only [LinearMap.lTensor_tmul, Submodule.coeSubtype, smul_eq_mul, tmul_mul_tmul] rfl | add x y hx hy => obtain ⟨x', hx'⟩ := hx obtain ⟨y', hy'⟩ := hy use x' + y' simp only [map_add, hx', smul_add, hy'] | add a b ha hb => obtain ⟨x', ha'⟩ := ha obtain ⟨y', hb'⟩ := hb use x' + y' simp only [map_add, ha', add_smul, hb'] · rintro x ⟨y, rfl⟩ induction y using TensorProduct.induction_on with | zero => rw [map_zero] apply zero_mem | tmul a b => simp only [LinearMap.rTensor_tmul, Submodule.coeSubtype] suffices (a : A) ⊗ₜ[R] b = ((1 : A) ⊗ₜ[R] b) * ((a : A) ⊗ₜ[R] (1 : B)) by simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.restrictScalars_mem] rw [this] apply Ideal.mul_mem_left -- Note: adding `includeLeft` as a hint fixes a timeout #8386 apply Ideal.mem_map_of_mem includeLeft exact Submodule.coe_mem a simp only [Submodule.coe_restrictScalars, Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul] | add x y hx hy => rw [map_add] apply Submodule.add_mem _ hx hy /-- The ideal of `A ⊗[R] B` generated by `I` is the image of `A ⊗[R] I` -/ lemma Ideal.map_includeRight_eq (I : Ideal B) : (I.map (Algebra.TensorProduct.includeRight : B →ₐ[R] A ⊗[R] B)).restrictScalars R = LinearMap.range (LinearMap.lTensor A (Submodule.subtype (I.restrictScalars R))) := by rw [← Submodule.carrier_inj] apply le_antisymm · intro x simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.restrictScalars_mem, LinearMap.mem_range] intro hx rw [Ideal.map, ← submodule_span_eq] at hx refine Submodule.span_induction hx ?_ ?_ ?_ ?_ · intro x simp only [includeRight_apply, Set.mem_image, SetLike.mem_coe] rintro ⟨y, hy, rfl⟩ use 1 ⊗ₜ[R] ⟨y, hy⟩ rfl · use 0 simp only [map_zero] · rintro x y ⟨x, hx, rfl⟩ ⟨y, hy, rfl⟩ use x + y simp only [map_add] · rintro a x ⟨x, hx, rfl⟩ induction a using TensorProduct.induction_on with | zero => use 0 simp only [map_zero, smul_eq_mul, zero_mul] | tmul a b => induction x using TensorProduct.induction_on with | zero => use 0 simp only [map_zero, smul_eq_mul, mul_zero] | tmul x y => use (a * x) ⊗ₜ[R] (b •y) simp only [LinearMap.lTensor_tmul, Submodule.coeSubtype, smul_eq_mul, tmul_mul_tmul] rfl | add x y hx hy => obtain ⟨x', hx'⟩ := hx obtain ⟨y', hy'⟩ := hy use x' + y' simp only [map_add, hx', smul_add, hy'] | add a b ha hb => obtain ⟨x', ha'⟩ := ha obtain ⟨y', hb'⟩ := hb use x' + y' simp only [map_add, ha', add_smul, hb'] · rintro x ⟨y, rfl⟩ induction y using TensorProduct.induction_on with | zero => rw [map_zero] apply zero_mem | tmul a b => simp only [LinearMap.lTensor_tmul, Submodule.coeSubtype] suffices a ⊗ₜ[R] (b : B) = (a ⊗ₜ[R] (1 : B)) * ((1 : A) ⊗ₜ[R] (b : B)) by rw [this] simp only [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, Submodule.mem_toAddSubmonoid, Submodule.restrictScalars_mem] apply Ideal.mul_mem_left -- Note: adding `includeRight` as a hint fixes a timeout #8386 apply Ideal.mem_map_of_mem includeRight exact Submodule.coe_mem b simp only [Submodule.coe_restrictScalars, Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul] | add x y hx hy => rw [map_add] apply Submodule.add_mem _ hx hy -- Now, we can prove the right exactness properties of the tensor product, -- in its versions for algebras variable {R : Type*} [CommRing R] {A B C D : Type*} [Ring A] [Ring B] [Ring C] [Ring D] [Algebra R A] [Algebra R B] [Algebra R C] [Algebra R D] (f : A →ₐ[R] B) (g : C →ₐ[R] D) /-- If `g` is surjective, then the kernel of `(id A) ⊗ g` is generated by the kernel of `g` -/ lemma Algebra.TensorProduct.lTensor_ker (hg : Function.Surjective g) : RingHom.ker (map (AlgHom.id R A) g) = (RingHom.ker g).map (Algebra.TensorProduct.includeRight : C →ₐ[R] A ⊗[R] C) := by rw [← Submodule.restrictScalars_inj R] have : (RingHom.ker (map (AlgHom.id R A) g)).restrictScalars R = LinearMap.ker (LinearMap.lTensor A (AlgHom.toLinearMap g)) := rfl rw [this, Ideal.map_includeRight_eq] rw [(lTensor_exact A g.toLinearMap.exact_subtype_ker_map hg).linearMap_ker_eq] rfl /-- If `f` is surjective, then the kernel of `f ⊗ (id B)` is generated by the kernel of `f` -/ lemma Algebra.TensorProduct.rTensor_ker (hf : Function.Surjective f) : RingHom.ker (map f (AlgHom.id R C)) = (RingHom.ker f).map (Algebra.TensorProduct.includeLeft : A →ₐ[R] A ⊗[R] C) := by rw [← Submodule.restrictScalars_inj R] have : (RingHom.ker (map f (AlgHom.id R C))).restrictScalars R = LinearMap.ker (LinearMap.rTensor C (AlgHom.toLinearMap f)) := rfl rw [this, Ideal.map_includeLeft_eq] rw [(rTensor_exact C f.toLinearMap.exact_subtype_ker_map hf).linearMap_ker_eq] rfl /-- If `f` and `g` are surjective morphisms of algebras, then the kernel of `Algebra.TensorProduct.map f g` is generated by the kernels of `f` and `g` -/
Mathlib/LinearAlgebra/TensorProduct/RightExactness.lean
680
699
theorem Algebra.TensorProduct.map_ker (hf : Function.Surjective f) (hg : Function.Surjective g) : RingHom.ker (map f g) = (RingHom.ker f).map (Algebra.TensorProduct.includeLeft : A →ₐ[R] A ⊗[R] C) ⊔ (RingHom.ker g).map (Algebra.TensorProduct.includeRight : C →ₐ[R] A ⊗[R] C) := by
-- rewrite map f g as the composition of two maps have : map f g = (map f (AlgHom.id R D)).comp (map (AlgHom.id R A) g) := ext rfl rfl rw [this] -- this needs some rewriting to RingHom simp only [AlgHom.coe_ker, AlgHom.comp_toRingHom] rw [← RingHom.comap_ker] simp only [← AlgHom.coe_ker] -- apply one step of exactness rw [← Algebra.TensorProduct.lTensor_ker _ hg, RingHom.ker_eq_comap_bot (map (AlgHom.id R A) g)] rw [← Ideal.comap_map_of_surjective (map (AlgHom.id R A) g) (LinearMap.lTensor_surjective A hg)] -- apply the other step of exactness rw [Algebra.TensorProduct.rTensor_ker _ hf] apply congr_arg₂ _ rfl simp only [AlgHom.coe_ideal_map, Ideal.map_map] rw [← AlgHom.comp_toRingHom, Algebra.TensorProduct.map_comp_includeLeft] rfl
/- Copyright (c) 2022 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.SpecialFunctions.Gaussian.GaussianIntegral import Mathlib.Analysis.Complex.CauchyIntegral import Mathlib.MeasureTheory.Integral.Pi import Mathlib.Analysis.Fourier.FourierTransform /-! # Fourier transform of the Gaussian We prove that the Fourier transform of the Gaussian function is another Gaussian: * `integral_cexp_quadratic`: general formula for `∫ (x : ℝ), exp (b * x ^ 2 + c * x + d)` * `fourierIntegral_gaussian`: for all complex `b` and `t` with `0 < re b`, we have `∫ x:ℝ, exp (I * t * x) * exp (-b * x^2) = (π / b) ^ (1 / 2) * exp (-t ^ 2 / (4 * b))`. * `fourierIntegral_gaussian_pi`: a variant with `b` and `t` scaled to give a more symmetric statement, and formulated in terms of the Fourier transform operator `𝓕`. We also give versions of these formulas in finite-dimensional inner product spaces, see `integral_cexp_neg_mul_sq_norm_add` and `fourierIntegral_gaussian_innerProductSpace`. -/ /-! ## Fourier integral of Gaussian functions -/ open Real Set MeasureTheory Filter Asymptotics intervalIntegral open scoped Real Topology FourierTransform RealInnerProductSpace open Complex hiding exp continuous_exp abs_of_nonneg sq_abs noncomputable section namespace GaussianFourier variable {b : ℂ} /-- The integral of the Gaussian function over the vertical edges of a rectangle with vertices at `(±T, 0)` and `(±T, c)`. -/ def verticalIntegral (b : ℂ) (c T : ℝ) : ℂ := ∫ y : ℝ in (0 : ℝ)..c, I * (cexp (-b * (T + y * I) ^ 2) - cexp (-b * (T - y * I) ^ 2)) #align gaussian_fourier.vertical_integral GaussianFourier.verticalIntegral /-- Explicit formula for the norm of the Gaussian function along the vertical edges. -/
Mathlib/Analysis/SpecialFunctions/Gaussian/FourierTransform.lean
51
55
theorem norm_cexp_neg_mul_sq_add_mul_I (b : ℂ) (c T : ℝ) : ‖cexp (-b * (T + c * I) ^ 2)‖ = exp (-(b.re * T ^ 2 - 2 * b.im * c * T - b.re * c ^ 2)) := by
rw [Complex.norm_eq_abs, Complex.abs_exp, neg_mul, neg_re, ← re_add_im b] simp only [sq, re_add_im, mul_re, mul_im, add_re, add_im, ofReal_re, ofReal_im, I_re, I_im] ring_nf
/- Copyright (c) 2020 Johan Commelin. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johan Commelin, Kevin Buzzard -/ import Mathlib.Algebra.BigOperators.NatAntidiagonal import Mathlib.Algebra.GeomSum import Mathlib.Data.Fintype.BigOperators import Mathlib.RingTheory.PowerSeries.Inverse import Mathlib.RingTheory.PowerSeries.WellKnown import Mathlib.Tactic.FieldSimp #align_import number_theory.bernoulli from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2" /-! # Bernoulli numbers The Bernoulli numbers are a sequence of rational numbers that frequently show up in number theory. ## Mathematical overview The Bernoulli numbers $(B_0, B_1, B_2, \ldots)=(1, -1/2, 1/6, 0, -1/30, \ldots)$ are a sequence of rational numbers. They show up in the formula for the sums of $k$th powers. They are related to the Taylor series expansions of $x/\tan(x)$ and of $\coth(x)$, and also show up in the values that the Riemann Zeta function takes both at both negative and positive integers (and hence in the theory of modular forms). For example, if $1 \leq n$ is even then $$\zeta(2n)=\sum_{t\geq1}t^{-2n}=(-1)^{n+1}\frac{(2\pi)^{2n}B_{2n}}{2(2n)!}.$$ Note however that this result is not yet formalised in Lean. The Bernoulli numbers can be formally defined using the power series $$\sum B_n\frac{t^n}{n!}=\frac{t}{1-e^{-t}}$$ although that happens to not be the definition in mathlib (this is an *implementation detail* and need not concern the mathematician). Note that $B_1=-1/2$, meaning that we are using the $B_n^-$ of [from Wikipedia](https://en.wikipedia.org/wiki/Bernoulli_number). ## Implementation detail The Bernoulli numbers are defined using well-founded induction, by the formula $$B_n=1-\sum_{k\lt n}\frac{\binom{n}{k}}{n-k+1}B_k.$$ This formula is true for all $n$ and in particular $B_0=1$. Note that this is the definition for positive Bernoulli numbers, which we call `bernoulli'`. The negative Bernoulli numbers are then defined as `bernoulli := (-1)^n * bernoulli'`. ## Main theorems `sum_bernoulli : ∑ k ∈ Finset.range n, (n.choose k : ℚ) * bernoulli k = if n = 1 then 1 else 0` -/ open Nat Finset Finset.Nat PowerSeries variable (A : Type*) [CommRing A] [Algebra ℚ A] /-! ### Definitions -/ /-- The Bernoulli numbers: the $n$-th Bernoulli number $B_n$ is defined recursively via $$B_n = 1 - \sum_{k < n} \binom{n}{k}\frac{B_k}{n+1-k}$$ -/ def bernoulli' : ℕ → ℚ := WellFounded.fix Nat.lt_wfRel.wf fun n bernoulli' => 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k k.2 #align bernoulli' bernoulli' theorem bernoulli'_def' (n : ℕ) : bernoulli' n = 1 - ∑ k : Fin n, n.choose k / (n - k + 1) * bernoulli' k := WellFounded.fix_eq _ _ _ #align bernoulli'_def' bernoulli'_def' theorem bernoulli'_def (n : ℕ) : bernoulli' n = 1 - ∑ k ∈ range n, n.choose k / (n - k + 1) * bernoulli' k := by rw [bernoulli'_def', ← Fin.sum_univ_eq_sum_range] #align bernoulli'_def bernoulli'_def theorem bernoulli'_spec (n : ℕ) : (∑ k ∈ range n.succ, (n.choose (n - k) : ℚ) / (n - k + 1) * bernoulli' k) = 1 := by rw [sum_range_succ_comm, bernoulli'_def n, tsub_self, choose_zero_right, sub_self, zero_add, div_one, cast_one, one_mul, sub_add, ← sum_sub_distrib, ← sub_eq_zero, sub_sub_cancel_left, neg_eq_zero] exact Finset.sum_eq_zero (fun x hx => by rw [choose_symm (le_of_lt (mem_range.1 hx)), sub_self]) #align bernoulli'_spec bernoulli'_spec theorem bernoulli'_spec' (n : ℕ) : (∑ k ∈ antidiagonal n, ((k.1 + k.2).choose k.2 : ℚ) / (k.2 + 1) * bernoulli' k.1) = 1 := by refine ((sum_antidiagonal_eq_sum_range_succ_mk _ n).trans ?_).trans (bernoulli'_spec n) refine sum_congr rfl fun x hx => ?_ simp only [add_tsub_cancel_of_le, mem_range_succ_iff.mp hx, cast_sub] #align bernoulli'_spec' bernoulli'_spec' /-! ### Examples -/ section Examples @[simp] theorem bernoulli'_zero : bernoulli' 0 = 1 := by rw [bernoulli'_def] norm_num #align bernoulli'_zero bernoulli'_zero @[simp] theorem bernoulli'_one : bernoulli' 1 = 1 / 2 := by rw [bernoulli'_def] norm_num #align bernoulli'_one bernoulli'_one @[simp] theorem bernoulli'_two : bernoulli' 2 = 1 / 6 := by rw [bernoulli'_def] norm_num [sum_range_succ, sum_range_succ, sum_range_zero] #align bernoulli'_two bernoulli'_two @[simp] theorem bernoulli'_three : bernoulli' 3 = 0 := by rw [bernoulli'_def] norm_num [sum_range_succ, sum_range_succ, sum_range_zero] #align bernoulli'_three bernoulli'_three @[simp] theorem bernoulli'_four : bernoulli' 4 = -1 / 30 := by have : Nat.choose 4 2 = 6 := by decide -- shrug rw [bernoulli'_def] norm_num [sum_range_succ, sum_range_succ, sum_range_zero, this] #align bernoulli'_four bernoulli'_four end Examples @[simp] theorem sum_bernoulli' (n : ℕ) : (∑ k ∈ range n, (n.choose k : ℚ) * bernoulli' k) = n := by cases' n with n · simp suffices ((n + 1 : ℚ) * ∑ k ∈ range n, ↑(n.choose k) / (n - k + 1) * bernoulli' k) = ∑ x ∈ range n, ↑(n.succ.choose x) * bernoulli' x by rw_mod_cast [sum_range_succ, bernoulli'_def, ← this, choose_succ_self_right] ring simp_rw [mul_sum, ← mul_assoc] refine sum_congr rfl fun k hk => ?_ congr have : ((n - k : ℕ) : ℚ) + 1 ≠ 0 := by norm_cast field_simp [← cast_sub (mem_range.1 hk).le, mul_comm] rw_mod_cast [tsub_add_eq_add_tsub (mem_range.1 hk).le, choose_mul_succ_eq] #align sum_bernoulli' sum_bernoulli' /-- The exponential generating function for the Bernoulli numbers `bernoulli' n`. -/ def bernoulli'PowerSeries := mk fun n => algebraMap ℚ A (bernoulli' n / n !) #align bernoulli'_power_series bernoulli'PowerSeries theorem bernoulli'PowerSeries_mul_exp_sub_one : bernoulli'PowerSeries A * (exp A - 1) = X * exp A := by ext n -- constant coefficient is a special case cases' n with n · simp rw [bernoulli'PowerSeries, coeff_mul, mul_comm X, sum_antidiagonal_succ'] suffices (∑ p ∈ antidiagonal n, bernoulli' p.1 / p.1! * ((p.2 + 1) * p.2! : ℚ)⁻¹) = (n ! : ℚ)⁻¹ by simpa [map_sum, Nat.factorial] using congr_arg (algebraMap ℚ A) this apply eq_inv_of_mul_eq_one_left rw [sum_mul] convert bernoulli'_spec' n using 1 apply sum_congr rfl simp_rw [mem_antidiagonal] rintro ⟨i, j⟩ rfl have := factorial_mul_factorial_dvd_factorial_add i j field_simp [mul_comm _ (bernoulli' i), mul_assoc, add_choose] norm_cast simp [mul_comm (j + 1)] #align bernoulli'_power_series_mul_exp_sub_one bernoulli'PowerSeries_mul_exp_sub_one /-- Odd Bernoulli numbers (greater than 1) are zero. -/ theorem bernoulli'_odd_eq_zero {n : ℕ} (h_odd : Odd n) (hlt : 1 < n) : bernoulli' n = 0 := by let B := mk fun n => bernoulli' n / (n ! : ℚ) suffices (B - evalNegHom B) * (exp ℚ - 1) = X * (exp ℚ - 1) by cases' mul_eq_mul_right_iff.mp this with h h <;> simp only [PowerSeries.ext_iff, evalNegHom, coeff_X] at h · apply eq_zero_of_neg_eq specialize h n split_ifs at h <;> simp_all [B, h_odd.neg_one_pow, factorial_ne_zero] · simpa (config := {decide := true}) [Nat.factorial] using h 1 have h : B * (exp ℚ - 1) = X * exp ℚ := by simpa [bernoulli'PowerSeries] using bernoulli'PowerSeries_mul_exp_sub_one ℚ rw [sub_mul, h, mul_sub X, sub_right_inj, ← neg_sub, mul_neg, neg_eq_iff_eq_neg] suffices evalNegHom (B * (exp ℚ - 1)) * exp ℚ = evalNegHom (X * exp ℚ) * exp ℚ by rw [map_mul, map_mul] at this -- Porting note: Why doesn't simp do this? simpa [mul_assoc, sub_mul, mul_comm (evalNegHom (exp ℚ)), exp_mul_exp_neg_eq_one] congr #align bernoulli'_odd_eq_zero bernoulli'_odd_eq_zero /-- The Bernoulli numbers are defined to be `bernoulli'` with a parity sign. -/ def bernoulli (n : ℕ) : ℚ := (-1) ^ n * bernoulli' n #align bernoulli bernoulli theorem bernoulli'_eq_bernoulli (n : ℕ) : bernoulli' n = (-1) ^ n * bernoulli n := by simp [bernoulli, ← mul_assoc, ← sq, ← pow_mul, mul_comm n 2, pow_mul] #align bernoulli'_eq_bernoulli bernoulli'_eq_bernoulli @[simp] theorem bernoulli_zero : bernoulli 0 = 1 := by simp [bernoulli] #align bernoulli_zero bernoulli_zero @[simp]
Mathlib/NumberTheory/Bernoulli.lean
213
213
theorem bernoulli_one : bernoulli 1 = -1 / 2 := by
norm_num [bernoulli]
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Floris van Doorn -/ import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Finsupp.Defs import Mathlib.Data.Nat.Cast.Order import Mathlib.Data.Set.Countable import Mathlib.Logic.Small.Set import Mathlib.Order.SuccPred.CompleteLinearOrder import Mathlib.SetTheory.Cardinal.SchroederBernstein #align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8" /-! # Cardinal Numbers We define cardinal numbers as a quotient of types under the equivalence relation of equinumerity. ## Main definitions * `Cardinal` is the type of cardinal numbers (in a given universe). * `Cardinal.mk α` or `#α` is the cardinality of `α`. The notation `#` lives in the locale `Cardinal`. * Addition `c₁ + c₂` is defined by `Cardinal.add_def α β : #α + #β = #(α ⊕ β)`. * Multiplication `c₁ * c₂` is defined by `Cardinal.mul_def : #α * #β = #(α × β)`. * The order `c₁ ≤ c₂` is defined by `Cardinal.le_def α β : #α ≤ #β ↔ Nonempty (α ↪ β)`. * Exponentiation `c₁ ^ c₂` is defined by `Cardinal.power_def α β : #α ^ #β = #(β → α)`. * `Cardinal.isLimit c` means that `c` is a (weak) limit cardinal: `c ≠ 0 ∧ ∀ x < c, succ x < c`. * `Cardinal.aleph0` or `ℵ₀` is the cardinality of `ℕ`. This definition is universe polymorphic: `Cardinal.aleph0.{u} : Cardinal.{u}` (contrast with `ℕ : Type`, which lives in a specific universe). In some cases the universe level has to be given explicitly. * `Cardinal.sum` is the sum of an indexed family of cardinals, i.e. the cardinality of the corresponding sigma type. * `Cardinal.prod` is the product of an indexed family of cardinals, i.e. the cardinality of the corresponding pi type. * `Cardinal.powerlt a b` or `a ^< b` is defined as the supremum of `a ^ c` for `c < b`. ## Main instances * Cardinals form a `CanonicallyOrderedCommSemiring` with the aforementioned sum and product. * Cardinals form a `SuccOrder`. Use `Order.succ c` for the smallest cardinal greater than `c`. * The less than relation on cardinals forms a well-order. * Cardinals form a `ConditionallyCompleteLinearOrderBot`. Bounded sets for cardinals in universe `u` are precisely the sets indexed by some type in universe `u`, see `Cardinal.bddAbove_iff_small`. One can use `sSup` for the cardinal supremum, and `sInf` for the minimum of a set of cardinals. ## Main Statements * Cantor's theorem: `Cardinal.cantor c : c < 2 ^ c`. * König's theorem: `Cardinal.sum_lt_prod` ## Implementation notes * There is a type of cardinal numbers in every universe level: `Cardinal.{u} : Type (u + 1)` is the quotient of types in `Type u`. The operation `Cardinal.lift` lifts cardinal numbers to a higher level. * Cardinal arithmetic specifically for infinite cardinals (like `κ * κ = κ`) is in the file `Mathlib/SetTheory/Cardinal/Ordinal.lean`. * There is an instance `Pow Cardinal`, but this will only fire if Lean already knows that both the base and the exponent live in the same universe. As a workaround, you can add ``` local infixr:80 " ^' " => @HPow.hPow Cardinal Cardinal Cardinal _ ``` to a file. This notation will work even if Lean doesn't know yet that the base and the exponent live in the same universe (but no exponents in other types can be used). (Porting note: This last point might need to be updated.) ## References * <https://en.wikipedia.org/wiki/Cardinal_number> ## Tags cardinal number, cardinal arithmetic, cardinal exponentiation, aleph, Cantor's theorem, König's theorem, Konig's theorem -/ assert_not_exists Field assert_not_exists Module open scoped Classical open Function Set Order noncomputable section universe u v w variable {α β : Type u} /-- The equivalence relation on types given by equivalence (bijective correspondence) of types. Quotienting by this equivalence relation gives the cardinal numbers. -/ instance Cardinal.isEquivalent : Setoid (Type u) where r α β := Nonempty (α ≃ β) iseqv := ⟨ fun α => ⟨Equiv.refl α⟩, fun ⟨e⟩ => ⟨e.symm⟩, fun ⟨e₁⟩ ⟨e₂⟩ => ⟨e₁.trans e₂⟩⟩ #align cardinal.is_equivalent Cardinal.isEquivalent /-- `Cardinal.{u}` is the type of cardinal numbers in `Type u`, defined as the quotient of `Type u` by existence of an equivalence (a bijection with explicit inverse). -/ @[pp_with_univ] def Cardinal : Type (u + 1) := Quotient Cardinal.isEquivalent #align cardinal Cardinal namespace Cardinal /-- The cardinal number of a type -/ def mk : Type u → Cardinal := Quotient.mk' #align cardinal.mk Cardinal.mk @[inherit_doc] scoped prefix:max "#" => Cardinal.mk instance canLiftCardinalType : CanLift Cardinal.{u} (Type u) mk fun _ => True := ⟨fun c _ => Quot.inductionOn c fun α => ⟨α, rfl⟩⟩ #align cardinal.can_lift_cardinal_Type Cardinal.canLiftCardinalType @[elab_as_elim] theorem inductionOn {p : Cardinal → Prop} (c : Cardinal) (h : ∀ α, p #α) : p c := Quotient.inductionOn c h #align cardinal.induction_on Cardinal.inductionOn @[elab_as_elim] theorem inductionOn₂ {p : Cardinal → Cardinal → Prop} (c₁ : Cardinal) (c₂ : Cardinal) (h : ∀ α β, p #α #β) : p c₁ c₂ := Quotient.inductionOn₂ c₁ c₂ h #align cardinal.induction_on₂ Cardinal.inductionOn₂ @[elab_as_elim] theorem inductionOn₃ {p : Cardinal → Cardinal → Cardinal → Prop} (c₁ : Cardinal) (c₂ : Cardinal) (c₃ : Cardinal) (h : ∀ α β γ, p #α #β #γ) : p c₁ c₂ c₃ := Quotient.inductionOn₃ c₁ c₂ c₃ h #align cardinal.induction_on₃ Cardinal.inductionOn₃ protected theorem eq : #α = #β ↔ Nonempty (α ≃ β) := Quotient.eq' #align cardinal.eq Cardinal.eq @[simp] theorem mk'_def (α : Type u) : @Eq Cardinal ⟦α⟧ #α := rfl #align cardinal.mk_def Cardinal.mk'_def @[simp] theorem mk_out (c : Cardinal) : #c.out = c := Quotient.out_eq _ #align cardinal.mk_out Cardinal.mk_out /-- The representative of the cardinal of a type is equivalent to the original type. -/ def outMkEquiv {α : Type v} : (#α).out ≃ α := Nonempty.some <| Cardinal.eq.mp (by simp) #align cardinal.out_mk_equiv Cardinal.outMkEquiv theorem mk_congr (e : α ≃ β) : #α = #β := Quot.sound ⟨e⟩ #align cardinal.mk_congr Cardinal.mk_congr alias _root_.Equiv.cardinal_eq := mk_congr #align equiv.cardinal_eq Equiv.cardinal_eq /-- Lift a function between `Type*`s to a function between `Cardinal`s. -/ def map (f : Type u → Type v) (hf : ∀ α β, α ≃ β → f α ≃ f β) : Cardinal.{u} → Cardinal.{v} := Quotient.map f fun α β ⟨e⟩ => ⟨hf α β e⟩ #align cardinal.map Cardinal.map @[simp] theorem map_mk (f : Type u → Type v) (hf : ∀ α β, α ≃ β → f α ≃ f β) (α : Type u) : map f hf #α = #(f α) := rfl #align cardinal.map_mk Cardinal.map_mk /-- Lift a binary operation `Type* → Type* → Type*` to a binary operation on `Cardinal`s. -/ def map₂ (f : Type u → Type v → Type w) (hf : ∀ α β γ δ, α ≃ β → γ ≃ δ → f α γ ≃ f β δ) : Cardinal.{u} → Cardinal.{v} → Cardinal.{w} := Quotient.map₂ f fun α β ⟨e₁⟩ γ δ ⟨e₂⟩ => ⟨hf α β γ δ e₁ e₂⟩ #align cardinal.map₂ Cardinal.map₂ /-- The universe lift operation on cardinals. You can specify the universes explicitly with `lift.{u v} : Cardinal.{v} → Cardinal.{max v u}` -/ @[pp_with_univ] def lift (c : Cardinal.{v}) : Cardinal.{max v u} := map ULift.{u, v} (fun _ _ e => Equiv.ulift.trans <| e.trans Equiv.ulift.symm) c #align cardinal.lift Cardinal.lift @[simp] theorem mk_uLift (α) : #(ULift.{v, u} α) = lift.{v} #α := rfl #align cardinal.mk_ulift Cardinal.mk_uLift -- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma -- further down in this file /-- `lift.{max u v, u}` equals `lift.{v, u}`. -/ @[simp, nolint simpNF] theorem lift_umax : lift.{max u v, u} = lift.{v, u} := funext fun a => inductionOn a fun _ => (Equiv.ulift.trans Equiv.ulift.symm).cardinal_eq #align cardinal.lift_umax Cardinal.lift_umax -- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma -- further down in this file /-- `lift.{max v u, u}` equals `lift.{v, u}`. -/ @[simp, nolint simpNF] theorem lift_umax' : lift.{max v u, u} = lift.{v, u} := lift_umax #align cardinal.lift_umax' Cardinal.lift_umax' -- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma -- further down in this file /-- A cardinal lifted to a lower or equal universe equals itself. -/ @[simp, nolint simpNF] theorem lift_id' (a : Cardinal.{max u v}) : lift.{u} a = a := inductionOn a fun _ => mk_congr Equiv.ulift #align cardinal.lift_id' Cardinal.lift_id' /-- A cardinal lifted to the same universe equals itself. -/ @[simp] theorem lift_id (a : Cardinal) : lift.{u, u} a = a := lift_id'.{u, u} a #align cardinal.lift_id Cardinal.lift_id /-- A cardinal lifted to the zero universe equals itself. -/ -- porting note (#10618): simp can prove this -- @[simp] theorem lift_uzero (a : Cardinal.{u}) : lift.{0} a = a := lift_id'.{0, u} a #align cardinal.lift_uzero Cardinal.lift_uzero @[simp] theorem lift_lift.{u_1} (a : Cardinal.{u_1}) : lift.{w} (lift.{v} a) = lift.{max v w} a := inductionOn a fun _ => (Equiv.ulift.trans <| Equiv.ulift.trans Equiv.ulift.symm).cardinal_eq #align cardinal.lift_lift Cardinal.lift_lift /-- We define the order on cardinal numbers by `#α ≤ #β` if and only if there exists an embedding (injective function) from α to β. -/ instance : LE Cardinal.{u} := ⟨fun q₁ q₂ => Quotient.liftOn₂ q₁ q₂ (fun α β => Nonempty <| α ↪ β) fun _ _ _ _ ⟨e₁⟩ ⟨e₂⟩ => propext ⟨fun ⟨e⟩ => ⟨e.congr e₁ e₂⟩, fun ⟨e⟩ => ⟨e.congr e₁.symm e₂.symm⟩⟩⟩ instance partialOrder : PartialOrder Cardinal.{u} where le := (· ≤ ·) le_refl := by rintro ⟨α⟩ exact ⟨Embedding.refl _⟩ le_trans := by rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ ⟨e₁⟩ ⟨e₂⟩ exact ⟨e₁.trans e₂⟩ le_antisymm := by rintro ⟨α⟩ ⟨β⟩ ⟨e₁⟩ ⟨e₂⟩ exact Quotient.sound (e₁.antisymm e₂) instance linearOrder : LinearOrder Cardinal.{u} := { Cardinal.partialOrder with le_total := by rintro ⟨α⟩ ⟨β⟩ apply Embedding.total decidableLE := Classical.decRel _ } theorem le_def (α β : Type u) : #α ≤ #β ↔ Nonempty (α ↪ β) := Iff.rfl #align cardinal.le_def Cardinal.le_def theorem mk_le_of_injective {α β : Type u} {f : α → β} (hf : Injective f) : #α ≤ #β := ⟨⟨f, hf⟩⟩ #align cardinal.mk_le_of_injective Cardinal.mk_le_of_injective theorem _root_.Function.Embedding.cardinal_le {α β : Type u} (f : α ↪ β) : #α ≤ #β := ⟨f⟩ #align function.embedding.cardinal_le Function.Embedding.cardinal_le theorem mk_le_of_surjective {α β : Type u} {f : α → β} (hf : Surjective f) : #β ≤ #α := ⟨Embedding.ofSurjective f hf⟩ #align cardinal.mk_le_of_surjective Cardinal.mk_le_of_surjective theorem le_mk_iff_exists_set {c : Cardinal} {α : Type u} : c ≤ #α ↔ ∃ p : Set α, #p = c := ⟨inductionOn c fun _ ⟨⟨f, hf⟩⟩ => ⟨Set.range f, (Equiv.ofInjective f hf).cardinal_eq.symm⟩, fun ⟨_, e⟩ => e ▸ ⟨⟨Subtype.val, fun _ _ => Subtype.eq⟩⟩⟩ #align cardinal.le_mk_iff_exists_set Cardinal.le_mk_iff_exists_set theorem mk_subtype_le {α : Type u} (p : α → Prop) : #(Subtype p) ≤ #α := ⟨Embedding.subtype p⟩ #align cardinal.mk_subtype_le Cardinal.mk_subtype_le theorem mk_set_le (s : Set α) : #s ≤ #α := mk_subtype_le s #align cardinal.mk_set_le Cardinal.mk_set_le @[simp] lemma mk_preimage_down {s : Set α} : #(ULift.down.{v} ⁻¹' s) = lift.{v} (#s) := by rw [← mk_uLift, Cardinal.eq] constructor let f : ULift.down ⁻¹' s → ULift s := fun x ↦ ULift.up (restrictPreimage s ULift.down x) have : Function.Bijective f := ULift.up_bijective.comp (restrictPreimage_bijective _ (ULift.down_bijective)) exact Equiv.ofBijective f this theorem out_embedding {c c' : Cardinal} : c ≤ c' ↔ Nonempty (c.out ↪ c'.out) := by trans · rw [← Quotient.out_eq c, ← Quotient.out_eq c'] · rw [mk'_def, mk'_def, le_def] #align cardinal.out_embedding Cardinal.out_embedding theorem lift_mk_le {α : Type v} {β : Type w} : lift.{max u w} #α ≤ lift.{max u v} #β ↔ Nonempty (α ↪ β) := ⟨fun ⟨f⟩ => ⟨Embedding.congr Equiv.ulift Equiv.ulift f⟩, fun ⟨f⟩ => ⟨Embedding.congr Equiv.ulift.symm Equiv.ulift.symm f⟩⟩ #align cardinal.lift_mk_le Cardinal.lift_mk_le /-- A variant of `Cardinal.lift_mk_le` with specialized universes. Because Lean often can not realize it should use this specialization itself, we provide this statement separately so you don't have to solve the specialization problem either. -/ theorem lift_mk_le' {α : Type u} {β : Type v} : lift.{v} #α ≤ lift.{u} #β ↔ Nonempty (α ↪ β) := lift_mk_le.{0} #align cardinal.lift_mk_le' Cardinal.lift_mk_le' theorem lift_mk_eq {α : Type u} {β : Type v} : lift.{max v w} #α = lift.{max u w} #β ↔ Nonempty (α ≃ β) := Quotient.eq'.trans ⟨fun ⟨f⟩ => ⟨Equiv.ulift.symm.trans <| f.trans Equiv.ulift⟩, fun ⟨f⟩ => ⟨Equiv.ulift.trans <| f.trans Equiv.ulift.symm⟩⟩ #align cardinal.lift_mk_eq Cardinal.lift_mk_eq /-- A variant of `Cardinal.lift_mk_eq` with specialized universes. Because Lean often can not realize it should use this specialization itself, we provide this statement separately so you don't have to solve the specialization problem either. -/ theorem lift_mk_eq' {α : Type u} {β : Type v} : lift.{v} #α = lift.{u} #β ↔ Nonempty (α ≃ β) := lift_mk_eq.{u, v, 0} #align cardinal.lift_mk_eq' Cardinal.lift_mk_eq' @[simp] theorem lift_le {a b : Cardinal.{v}} : lift.{u, v} a ≤ lift.{u, v} b ↔ a ≤ b := inductionOn₂ a b fun α β => by rw [← lift_umax] exact lift_mk_le.{u} #align cardinal.lift_le Cardinal.lift_le -- Porting note: changed `simps` to `simps!` because the linter told to do so. /-- `Cardinal.lift` as an `OrderEmbedding`. -/ @[simps! (config := .asFn)] def liftOrderEmbedding : Cardinal.{v} ↪o Cardinal.{max v u} := OrderEmbedding.ofMapLEIff lift.{u, v} fun _ _ => lift_le #align cardinal.lift_order_embedding Cardinal.liftOrderEmbedding theorem lift_injective : Injective lift.{u, v} := liftOrderEmbedding.injective #align cardinal.lift_injective Cardinal.lift_injective @[simp] theorem lift_inj {a b : Cardinal.{u}} : lift.{v, u} a = lift.{v, u} b ↔ a = b := lift_injective.eq_iff #align cardinal.lift_inj Cardinal.lift_inj @[simp] theorem lift_lt {a b : Cardinal.{u}} : lift.{v, u} a < lift.{v, u} b ↔ a < b := liftOrderEmbedding.lt_iff_lt #align cardinal.lift_lt Cardinal.lift_lt theorem lift_strictMono : StrictMono lift := fun _ _ => lift_lt.2 #align cardinal.lift_strict_mono Cardinal.lift_strictMono theorem lift_monotone : Monotone lift := lift_strictMono.monotone #align cardinal.lift_monotone Cardinal.lift_monotone instance : Zero Cardinal.{u} := -- `PEmpty` might be more canonical, but this is convenient for defeq with natCast ⟨lift #(Fin 0)⟩ instance : Inhabited Cardinal.{u} := ⟨0⟩ @[simp] theorem mk_eq_zero (α : Type u) [IsEmpty α] : #α = 0 := (Equiv.equivOfIsEmpty α (ULift (Fin 0))).cardinal_eq #align cardinal.mk_eq_zero Cardinal.mk_eq_zero @[simp] theorem lift_zero : lift 0 = 0 := mk_eq_zero _ #align cardinal.lift_zero Cardinal.lift_zero @[simp] theorem lift_eq_zero {a : Cardinal.{v}} : lift.{u} a = 0 ↔ a = 0 := lift_injective.eq_iff' lift_zero #align cardinal.lift_eq_zero Cardinal.lift_eq_zero theorem mk_eq_zero_iff {α : Type u} : #α = 0 ↔ IsEmpty α := ⟨fun e => let ⟨h⟩ := Quotient.exact e h.isEmpty, @mk_eq_zero α⟩ #align cardinal.mk_eq_zero_iff Cardinal.mk_eq_zero_iff theorem mk_ne_zero_iff {α : Type u} : #α ≠ 0 ↔ Nonempty α := (not_iff_not.2 mk_eq_zero_iff).trans not_isEmpty_iff #align cardinal.mk_ne_zero_iff Cardinal.mk_ne_zero_iff @[simp] theorem mk_ne_zero (α : Type u) [Nonempty α] : #α ≠ 0 := mk_ne_zero_iff.2 ‹_› #align cardinal.mk_ne_zero Cardinal.mk_ne_zero instance : One Cardinal.{u} := -- `PUnit` might be more canonical, but this is convenient for defeq with natCast ⟨lift #(Fin 1)⟩ instance : Nontrivial Cardinal.{u} := ⟨⟨1, 0, mk_ne_zero _⟩⟩ theorem mk_eq_one (α : Type u) [Unique α] : #α = 1 := (Equiv.equivOfUnique α (ULift (Fin 1))).cardinal_eq #align cardinal.mk_eq_one Cardinal.mk_eq_one theorem le_one_iff_subsingleton {α : Type u} : #α ≤ 1 ↔ Subsingleton α := ⟨fun ⟨f⟩ => ⟨fun _ _ => f.injective (Subsingleton.elim _ _)⟩, fun ⟨h⟩ => ⟨fun _ => ULift.up 0, fun _ _ _ => h _ _⟩⟩ #align cardinal.le_one_iff_subsingleton Cardinal.le_one_iff_subsingleton @[simp] theorem mk_le_one_iff_set_subsingleton {s : Set α} : #s ≤ 1 ↔ s.Subsingleton := le_one_iff_subsingleton.trans s.subsingleton_coe #align cardinal.mk_le_one_iff_set_subsingleton Cardinal.mk_le_one_iff_set_subsingleton alias ⟨_, _root_.Set.Subsingleton.cardinal_mk_le_one⟩ := mk_le_one_iff_set_subsingleton #align set.subsingleton.cardinal_mk_le_one Set.Subsingleton.cardinal_mk_le_one instance : Add Cardinal.{u} := ⟨map₂ Sum fun _ _ _ _ => Equiv.sumCongr⟩ theorem add_def (α β : Type u) : #α + #β = #(Sum α β) := rfl #align cardinal.add_def Cardinal.add_def instance : NatCast Cardinal.{u} := ⟨fun n => lift #(Fin n)⟩ @[simp] theorem mk_sum (α : Type u) (β : Type v) : #(α ⊕ β) = lift.{v, u} #α + lift.{u, v} #β := mk_congr (Equiv.ulift.symm.sumCongr Equiv.ulift.symm) #align cardinal.mk_sum Cardinal.mk_sum @[simp] theorem mk_option {α : Type u} : #(Option α) = #α + 1 := by rw [(Equiv.optionEquivSumPUnit.{u, u} α).cardinal_eq, mk_sum, mk_eq_one PUnit, lift_id, lift_id] #align cardinal.mk_option Cardinal.mk_option @[simp] theorem mk_psum (α : Type u) (β : Type v) : #(PSum α β) = lift.{v} #α + lift.{u} #β := (mk_congr (Equiv.psumEquivSum α β)).trans (mk_sum α β) #align cardinal.mk_psum Cardinal.mk_psum @[simp] theorem mk_fintype (α : Type u) [h : Fintype α] : #α = Fintype.card α := mk_congr (Fintype.equivOfCardEq (by simp)) protected theorem cast_succ (n : ℕ) : ((n + 1 : ℕ) : Cardinal.{u}) = n + 1 := by change #(ULift.{u} (Fin (n+1))) = # (ULift.{u} (Fin n)) + 1 rw [← mk_option, mk_fintype, mk_fintype] simp only [Fintype.card_ulift, Fintype.card_fin, Fintype.card_option] instance : Mul Cardinal.{u} := ⟨map₂ Prod fun _ _ _ _ => Equiv.prodCongr⟩ theorem mul_def (α β : Type u) : #α * #β = #(α × β) := rfl #align cardinal.mul_def Cardinal.mul_def @[simp] theorem mk_prod (α : Type u) (β : Type v) : #(α × β) = lift.{v, u} #α * lift.{u, v} #β := mk_congr (Equiv.ulift.symm.prodCongr Equiv.ulift.symm) #align cardinal.mk_prod Cardinal.mk_prod private theorem mul_comm' (a b : Cardinal.{u}) : a * b = b * a := inductionOn₂ a b fun α β => mk_congr <| Equiv.prodComm α β /-- The cardinal exponential. `#α ^ #β` is the cardinal of `β → α`. -/ instance instPowCardinal : Pow Cardinal.{u} Cardinal.{u} := ⟨map₂ (fun α β => β → α) fun _ _ _ _ e₁ e₂ => e₂.arrowCongr e₁⟩ theorem power_def (α β : Type u) : #α ^ #β = #(β → α) := rfl #align cardinal.power_def Cardinal.power_def theorem mk_arrow (α : Type u) (β : Type v) : #(α → β) = (lift.{u} #β^lift.{v} #α) := mk_congr (Equiv.ulift.symm.arrowCongr Equiv.ulift.symm) #align cardinal.mk_arrow Cardinal.mk_arrow @[simp] theorem lift_power (a b : Cardinal.{u}) : lift.{v} (a ^ b) = lift.{v} a ^ lift.{v} b := inductionOn₂ a b fun _ _ => mk_congr <| Equiv.ulift.trans (Equiv.ulift.arrowCongr Equiv.ulift).symm #align cardinal.lift_power Cardinal.lift_power @[simp] theorem power_zero {a : Cardinal} : a ^ (0 : Cardinal) = 1 := inductionOn a fun _ => mk_eq_one _ #align cardinal.power_zero Cardinal.power_zero @[simp] theorem power_one {a : Cardinal.{u}} : a ^ (1 : Cardinal) = a := inductionOn a fun α => mk_congr (Equiv.funUnique (ULift.{u} (Fin 1)) α) #align cardinal.power_one Cardinal.power_one theorem power_add {a b c : Cardinal} : a ^ (b + c) = a ^ b * a ^ c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumArrowEquivProdArrow β γ α #align cardinal.power_add Cardinal.power_add instance commSemiring : CommSemiring Cardinal.{u} where zero := 0 one := 1 add := (· + ·) mul := (· * ·) zero_add a := inductionOn a fun α => mk_congr <| Equiv.emptySum (ULift (Fin 0)) α add_zero a := inductionOn a fun α => mk_congr <| Equiv.sumEmpty α (ULift (Fin 0)) add_assoc a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumAssoc α β γ add_comm a b := inductionOn₂ a b fun α β => mk_congr <| Equiv.sumComm α β zero_mul a := inductionOn a fun α => mk_eq_zero _ mul_zero a := inductionOn a fun α => mk_eq_zero _ one_mul a := inductionOn a fun α => mk_congr <| Equiv.uniqueProd α (ULift (Fin 1)) mul_one a := inductionOn a fun α => mk_congr <| Equiv.prodUnique α (ULift (Fin 1)) mul_assoc a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.prodAssoc α β γ mul_comm := mul_comm' left_distrib a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.prodSumDistrib α β γ right_distrib a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumProdDistrib α β γ nsmul := nsmulRec npow n c := c ^ (n : Cardinal) npow_zero := @power_zero npow_succ n c := show c ^ (↑(n + 1) : Cardinal) = c ^ (↑n : Cardinal) * c by rw [Cardinal.cast_succ, power_add, power_one, mul_comm'] natCast := (fun n => lift.{u} #(Fin n) : ℕ → Cardinal.{u}) natCast_zero := rfl natCast_succ := Cardinal.cast_succ /-! Porting note (#11229): Deprecated section. Remove. -/ section deprecated set_option linter.deprecated false @[deprecated (since := "2023-02-11")] theorem power_bit0 (a b : Cardinal) : a ^ bit0 b = a ^ b * a ^ b := power_add #align cardinal.power_bit0 Cardinal.power_bit0 @[deprecated (since := "2023-02-11")] theorem power_bit1 (a b : Cardinal) : a ^ bit1 b = a ^ b * a ^ b * a := by rw [bit1, ← power_bit0, power_add, power_one] #align cardinal.power_bit1 Cardinal.power_bit1 end deprecated @[simp] theorem one_power {a : Cardinal} : (1 : Cardinal) ^ a = 1 := inductionOn a fun _ => mk_eq_one _ #align cardinal.one_power Cardinal.one_power -- porting note (#10618): simp can prove this -- @[simp] theorem mk_bool : #Bool = 2 := by simp #align cardinal.mk_bool Cardinal.mk_bool -- porting note (#10618): simp can prove this -- @[simp] theorem mk_Prop : #Prop = 2 := by simp #align cardinal.mk_Prop Cardinal.mk_Prop @[simp] theorem zero_power {a : Cardinal} : a ≠ 0 → (0 : Cardinal) ^ a = 0 := inductionOn a fun _ heq => mk_eq_zero_iff.2 <| isEmpty_pi.2 <| let ⟨a⟩ := mk_ne_zero_iff.1 heq ⟨a, inferInstance⟩ #align cardinal.zero_power Cardinal.zero_power theorem power_ne_zero {a : Cardinal} (b : Cardinal) : a ≠ 0 → a ^ b ≠ 0 := inductionOn₂ a b fun _ _ h => let ⟨a⟩ := mk_ne_zero_iff.1 h mk_ne_zero_iff.2 ⟨fun _ => a⟩ #align cardinal.power_ne_zero Cardinal.power_ne_zero theorem mul_power {a b c : Cardinal} : (a * b) ^ c = a ^ c * b ^ c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.arrowProdEquivProdArrow α β γ #align cardinal.mul_power Cardinal.mul_power theorem power_mul {a b c : Cardinal} : a ^ (b * c) = (a ^ b) ^ c := by rw [mul_comm b c] exact inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.curry γ β α #align cardinal.power_mul Cardinal.power_mul @[simp] theorem pow_cast_right (a : Cardinal.{u}) (n : ℕ) : a ^ (↑n : Cardinal.{u}) = a ^ n := rfl #align cardinal.pow_cast_right Cardinal.pow_cast_right @[simp] theorem lift_one : lift 1 = 1 := mk_eq_one _ #align cardinal.lift_one Cardinal.lift_one @[simp] theorem lift_eq_one {a : Cardinal.{v}} : lift.{u} a = 1 ↔ a = 1 := lift_injective.eq_iff' lift_one @[simp] theorem lift_add (a b : Cardinal.{u}) : lift.{v} (a + b) = lift.{v} a + lift.{v} b := inductionOn₂ a b fun _ _ => mk_congr <| Equiv.ulift.trans (Equiv.sumCongr Equiv.ulift Equiv.ulift).symm #align cardinal.lift_add Cardinal.lift_add @[simp] theorem lift_mul (a b : Cardinal.{u}) : lift.{v} (a * b) = lift.{v} a * lift.{v} b := inductionOn₂ a b fun _ _ => mk_congr <| Equiv.ulift.trans (Equiv.prodCongr Equiv.ulift Equiv.ulift).symm #align cardinal.lift_mul Cardinal.lift_mul /-! Porting note (#11229): Deprecated section. Remove. -/ section deprecated set_option linter.deprecated false @[simp, deprecated (since := "2023-02-11")] theorem lift_bit0 (a : Cardinal) : lift.{v} (bit0 a) = bit0 (lift.{v} a) := lift_add a a #align cardinal.lift_bit0 Cardinal.lift_bit0 @[simp, deprecated (since := "2023-02-11")] theorem lift_bit1 (a : Cardinal) : lift.{v} (bit1 a) = bit1 (lift.{v} a) := by simp [bit1] #align cardinal.lift_bit1 Cardinal.lift_bit1 end deprecated -- Porting note: Proof used to be simp, needed to remind simp that 1 + 1 = 2 theorem lift_two : lift.{u, v} 2 = 2 := by simp [← one_add_one_eq_two] #align cardinal.lift_two Cardinal.lift_two @[simp] theorem mk_set {α : Type u} : #(Set α) = 2 ^ #α := by simp [← one_add_one_eq_two, Set, mk_arrow] #align cardinal.mk_set Cardinal.mk_set /-- A variant of `Cardinal.mk_set` expressed in terms of a `Set` instead of a `Type`. -/ @[simp] theorem mk_powerset {α : Type u} (s : Set α) : #(↥(𝒫 s)) = 2 ^ #(↥s) := (mk_congr (Equiv.Set.powerset s)).trans mk_set #align cardinal.mk_powerset Cardinal.mk_powerset theorem lift_two_power (a : Cardinal) : lift.{v} (2 ^ a) = 2 ^ lift.{v} a := by simp [← one_add_one_eq_two] #align cardinal.lift_two_power Cardinal.lift_two_power section OrderProperties open Sum protected theorem zero_le : ∀ a : Cardinal, 0 ≤ a := by rintro ⟨α⟩ exact ⟨Embedding.ofIsEmpty⟩ #align cardinal.zero_le Cardinal.zero_le private theorem add_le_add' : ∀ {a b c d : Cardinal}, a ≤ b → c ≤ d → a + c ≤ b + d := by rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ ⟨δ⟩ ⟨e₁⟩ ⟨e₂⟩; exact ⟨e₁.sumMap e₂⟩ -- #align cardinal.add_le_add' Cardinal.add_le_add' instance add_covariantClass : CovariantClass Cardinal Cardinal (· + ·) (· ≤ ·) := ⟨fun _ _ _ => add_le_add' le_rfl⟩ #align cardinal.add_covariant_class Cardinal.add_covariantClass instance add_swap_covariantClass : CovariantClass Cardinal Cardinal (swap (· + ·)) (· ≤ ·) := ⟨fun _ _ _ h => add_le_add' h le_rfl⟩ #align cardinal.add_swap_covariant_class Cardinal.add_swap_covariantClass instance canonicallyOrderedCommSemiring : CanonicallyOrderedCommSemiring Cardinal.{u} := { Cardinal.commSemiring, Cardinal.partialOrder with bot := 0 bot_le := Cardinal.zero_le add_le_add_left := fun a b => add_le_add_left exists_add_of_le := fun {a b} => inductionOn₂ a b fun α β ⟨⟨f, hf⟩⟩ => have : Sum α ((range f)ᶜ : Set β) ≃ β := (Equiv.sumCongr (Equiv.ofInjective f hf) (Equiv.refl _)).trans <| Equiv.Set.sumCompl (range f) ⟨#(↥(range f)ᶜ), mk_congr this.symm⟩ le_self_add := fun a b => (add_zero a).ge.trans <| add_le_add_left (Cardinal.zero_le _) _ eq_zero_or_eq_zero_of_mul_eq_zero := fun {a b} => inductionOn₂ a b fun α β => by simpa only [mul_def, mk_eq_zero_iff, isEmpty_prod] using id } instance : CanonicallyLinearOrderedAddCommMonoid Cardinal.{u} := { Cardinal.canonicallyOrderedCommSemiring, Cardinal.linearOrder with } -- Computable instance to prevent a non-computable one being found via the one above instance : CanonicallyOrderedAddCommMonoid Cardinal.{u} := { Cardinal.canonicallyOrderedCommSemiring with } instance : LinearOrderedCommMonoidWithZero Cardinal.{u} := { Cardinal.commSemiring, Cardinal.linearOrder with mul_le_mul_left := @mul_le_mul_left' _ _ _ _ zero_le_one := zero_le _ } -- Computable instance to prevent a non-computable one being found via the one above instance : CommMonoidWithZero Cardinal.{u} := { Cardinal.canonicallyOrderedCommSemiring with } -- Porting note: new -- Computable instance to prevent a non-computable one being found via the one above instance : CommMonoid Cardinal.{u} := { Cardinal.canonicallyOrderedCommSemiring with } theorem zero_power_le (c : Cardinal.{u}) : (0 : Cardinal.{u}) ^ c ≤ 1 := by by_cases h : c = 0 · rw [h, power_zero] · rw [zero_power h] apply zero_le #align cardinal.zero_power_le Cardinal.zero_power_le theorem power_le_power_left : ∀ {a b c : Cardinal}, a ≠ 0 → b ≤ c → a ^ b ≤ a ^ c := by rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ hα ⟨e⟩ let ⟨a⟩ := mk_ne_zero_iff.1 hα exact ⟨@Function.Embedding.arrowCongrLeft _ _ _ ⟨a⟩ e⟩ #align cardinal.power_le_power_left Cardinal.power_le_power_left theorem self_le_power (a : Cardinal) {b : Cardinal} (hb : 1 ≤ b) : a ≤ a ^ b := by rcases eq_or_ne a 0 with (rfl | ha) · exact zero_le _ · convert power_le_power_left ha hb exact power_one.symm #align cardinal.self_le_power Cardinal.self_le_power /-- **Cantor's theorem** -/ theorem cantor (a : Cardinal.{u}) : a < 2 ^ a := by induction' a using Cardinal.inductionOn with α rw [← mk_set] refine ⟨⟨⟨singleton, fun a b => singleton_eq_singleton_iff.1⟩⟩, ?_⟩ rintro ⟨⟨f, hf⟩⟩ exact cantor_injective f hf #align cardinal.cantor Cardinal.cantor instance : NoMaxOrder Cardinal.{u} where exists_gt a := ⟨_, cantor a⟩ -- short-circuit type class inference instance : DistribLattice Cardinal.{u} := inferInstance theorem one_lt_iff_nontrivial {α : Type u} : 1 < #α ↔ Nontrivial α := by rw [← not_le, le_one_iff_subsingleton, ← not_nontrivial_iff_subsingleton, Classical.not_not] #align cardinal.one_lt_iff_nontrivial Cardinal.one_lt_iff_nontrivial theorem power_le_max_power_one {a b c : Cardinal} (h : b ≤ c) : a ^ b ≤ max (a ^ c) 1 := by by_cases ha : a = 0 · simp [ha, zero_power_le] · exact (power_le_power_left ha h).trans (le_max_left _ _) #align cardinal.power_le_max_power_one Cardinal.power_le_max_power_one theorem power_le_power_right {a b c : Cardinal} : a ≤ b → a ^ c ≤ b ^ c := inductionOn₃ a b c fun _ _ _ ⟨e⟩ => ⟨Embedding.arrowCongrRight e⟩ #align cardinal.power_le_power_right Cardinal.power_le_power_right theorem power_pos {a : Cardinal} (b : Cardinal) (ha : 0 < a) : 0 < a ^ b := (power_ne_zero _ ha.ne').bot_lt #align cardinal.power_pos Cardinal.power_pos end OrderProperties protected theorem lt_wf : @WellFounded Cardinal.{u} (· < ·) := ⟨fun a => by_contradiction fun h => by let ι := { c : Cardinal // ¬Acc (· < ·) c } let f : ι → Cardinal := Subtype.val haveI hι : Nonempty ι := ⟨⟨_, h⟩⟩ obtain ⟨⟨c : Cardinal, hc : ¬Acc (· < ·) c⟩, ⟨h_1 : ∀ j, (f ⟨c, hc⟩).out ↪ (f j).out⟩⟩ := Embedding.min_injective fun i => (f i).out refine hc (Acc.intro _ fun j h' => by_contradiction fun hj => h'.2 ?_) have : #_ ≤ #_ := ⟨h_1 ⟨j, hj⟩⟩ simpa only [mk_out] using this⟩ #align cardinal.lt_wf Cardinal.lt_wf instance : WellFoundedRelation Cardinal.{u} := ⟨(· < ·), Cardinal.lt_wf⟩ -- Porting note: this no longer is automatically inferred. instance : WellFoundedLT Cardinal.{u} := ⟨Cardinal.lt_wf⟩ instance wo : @IsWellOrder Cardinal.{u} (· < ·) where #align cardinal.wo Cardinal.wo instance : ConditionallyCompleteLinearOrderBot Cardinal := IsWellOrder.conditionallyCompleteLinearOrderBot _ @[simp] theorem sInf_empty : sInf (∅ : Set Cardinal.{u}) = 0 := dif_neg Set.not_nonempty_empty #align cardinal.Inf_empty Cardinal.sInf_empty lemma sInf_eq_zero_iff {s : Set Cardinal} : sInf s = 0 ↔ s = ∅ ∨ ∃ a ∈ s, a = 0 := by refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · rcases s.eq_empty_or_nonempty with rfl | hne · exact Or.inl rfl · exact Or.inr ⟨sInf s, csInf_mem hne, h⟩ · rcases h with rfl | ⟨a, ha, rfl⟩ · exact Cardinal.sInf_empty · exact eq_bot_iff.2 (csInf_le' ha) lemma iInf_eq_zero_iff {ι : Sort*} {f : ι → Cardinal} : (⨅ i, f i) = 0 ↔ IsEmpty ι ∨ ∃ i, f i = 0 := by simp [iInf, sInf_eq_zero_iff] /-- Note that the successor of `c` is not the same as `c + 1` except in the case of finite `c`. -/ instance : SuccOrder Cardinal := SuccOrder.ofSuccLeIff (fun c => sInf { c' | c < c' }) -- Porting note: Needed to insert `by apply` in the next line ⟨by apply lt_of_lt_of_le <| csInf_mem <| exists_gt _, -- Porting note used to be just `csInf_le'` fun h ↦ csInf_le' h⟩ theorem succ_def (c : Cardinal) : succ c = sInf { c' | c < c' } := rfl #align cardinal.succ_def Cardinal.succ_def theorem succ_pos : ∀ c : Cardinal, 0 < succ c := bot_lt_succ #align cardinal.succ_pos Cardinal.succ_pos theorem succ_ne_zero (c : Cardinal) : succ c ≠ 0 := (succ_pos _).ne' #align cardinal.succ_ne_zero Cardinal.succ_ne_zero theorem add_one_le_succ (c : Cardinal.{u}) : c + 1 ≤ succ c := by -- Porting note: rewrote the next three lines to avoid defeq abuse. have : Set.Nonempty { c' | c < c' } := exists_gt c simp_rw [succ_def, le_csInf_iff'' this, mem_setOf] intro b hlt rcases b, c with ⟨⟨β⟩, ⟨γ⟩⟩ cases' le_of_lt hlt with f have : ¬Surjective f := fun hn => (not_le_of_lt hlt) (mk_le_of_surjective hn) simp only [Surjective, not_forall] at this rcases this with ⟨b, hb⟩ calc #γ + 1 = #(Option γ) := mk_option.symm _ ≤ #β := (f.optionElim b hb).cardinal_le #align cardinal.add_one_le_succ Cardinal.add_one_le_succ /-- A cardinal is a limit if it is not zero or a successor cardinal. Note that `ℵ₀` is a limit cardinal by this definition, but `0` isn't. Use `IsSuccLimit` if you want to include the `c = 0` case. -/ def IsLimit (c : Cardinal) : Prop := c ≠ 0 ∧ IsSuccLimit c #align cardinal.is_limit Cardinal.IsLimit protected theorem IsLimit.ne_zero {c} (h : IsLimit c) : c ≠ 0 := h.1 #align cardinal.is_limit.ne_zero Cardinal.IsLimit.ne_zero protected theorem IsLimit.isSuccLimit {c} (h : IsLimit c) : IsSuccLimit c := h.2 #align cardinal.is_limit.is_succ_limit Cardinal.IsLimit.isSuccLimit theorem IsLimit.succ_lt {x c} (h : IsLimit c) : x < c → succ x < c := h.isSuccLimit.succ_lt #align cardinal.is_limit.succ_lt Cardinal.IsLimit.succ_lt theorem isSuccLimit_zero : IsSuccLimit (0 : Cardinal) := isSuccLimit_bot #align cardinal.is_succ_limit_zero Cardinal.isSuccLimit_zero /-- The indexed sum of cardinals is the cardinality of the indexed disjoint union, i.e. sigma type. -/ def sum {ι} (f : ι → Cardinal) : Cardinal := mk (Σi, (f i).out) #align cardinal.sum Cardinal.sum theorem le_sum {ι} (f : ι → Cardinal) (i) : f i ≤ sum f := by rw [← Quotient.out_eq (f i)] exact ⟨⟨fun a => ⟨i, a⟩, fun a b h => by injection h⟩⟩ #align cardinal.le_sum Cardinal.le_sum @[simp] theorem mk_sigma {ι} (f : ι → Type*) : #(Σ i, f i) = sum fun i => #(f i) := mk_congr <| Equiv.sigmaCongrRight fun _ => outMkEquiv.symm #align cardinal.mk_sigma Cardinal.mk_sigma @[simp] theorem sum_const (ι : Type u) (a : Cardinal.{v}) : (sum fun _ : ι => a) = lift.{v} #ι * lift.{u} a := inductionOn a fun α => mk_congr <| calc (Σ _ : ι, Quotient.out #α) ≃ ι × Quotient.out #α := Equiv.sigmaEquivProd _ _ _ ≃ ULift ι × ULift α := Equiv.ulift.symm.prodCongr (outMkEquiv.trans Equiv.ulift.symm) #align cardinal.sum_const Cardinal.sum_const theorem sum_const' (ι : Type u) (a : Cardinal.{u}) : (sum fun _ : ι => a) = #ι * a := by simp #align cardinal.sum_const' Cardinal.sum_const' @[simp] theorem sum_add_distrib {ι} (f g : ι → Cardinal) : sum (f + g) = sum f + sum g := by have := mk_congr (Equiv.sigmaSumDistrib (Quotient.out ∘ f) (Quotient.out ∘ g)) simp only [comp_apply, mk_sigma, mk_sum, mk_out, lift_id] at this exact this #align cardinal.sum_add_distrib Cardinal.sum_add_distrib @[simp] theorem sum_add_distrib' {ι} (f g : ι → Cardinal) : (Cardinal.sum fun i => f i + g i) = sum f + sum g := sum_add_distrib f g #align cardinal.sum_add_distrib' Cardinal.sum_add_distrib' @[simp] theorem lift_sum {ι : Type u} (f : ι → Cardinal.{v}) : Cardinal.lift.{w} (Cardinal.sum f) = Cardinal.sum fun i => Cardinal.lift.{w} (f i) := Equiv.cardinal_eq <| Equiv.ulift.trans <| Equiv.sigmaCongrRight fun a => -- Porting note: Inserted universe hint .{_,_,v} below Nonempty.some <| by rw [← lift_mk_eq.{_,_,v}, mk_out, mk_out, lift_lift] #align cardinal.lift_sum Cardinal.lift_sum theorem sum_le_sum {ι} (f g : ι → Cardinal) (H : ∀ i, f i ≤ g i) : sum f ≤ sum g := ⟨(Embedding.refl _).sigmaMap fun i => Classical.choice <| by have := H i; rwa [← Quot.out_eq (f i), ← Quot.out_eq (g i)] at this⟩ #align cardinal.sum_le_sum Cardinal.sum_le_sum theorem mk_le_mk_mul_of_mk_preimage_le {c : Cardinal} (f : α → β) (hf : ∀ b : β, #(f ⁻¹' {b}) ≤ c) : #α ≤ #β * c := by simpa only [← mk_congr (@Equiv.sigmaFiberEquiv α β f), mk_sigma, ← sum_const'] using sum_le_sum _ _ hf #align cardinal.mk_le_mk_mul_of_mk_preimage_le Cardinal.mk_le_mk_mul_of_mk_preimage_le theorem lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le {α : Type u} {β : Type v} {c : Cardinal} (f : α → β) (hf : ∀ b : β, lift.{v} #(f ⁻¹' {b}) ≤ c) : lift.{v} #α ≤ lift.{u} #β * c := (mk_le_mk_mul_of_mk_preimage_le fun x : ULift.{v} α => ULift.up.{u} (f x.1)) <| ULift.forall.2 fun b => (mk_congr <| (Equiv.ulift.image _).trans (Equiv.trans (by rw [Equiv.image_eq_preimage] /- Porting note: Need to insert the following `have` b/c bad fun coercion behaviour for Equivs -/ have : DFunLike.coe (Equiv.symm (Equiv.ulift (α := α))) = ULift.up (α := α) := rfl rw [this] simp only [preimage, mem_singleton_iff, ULift.up_inj, mem_setOf_eq, coe_setOf] exact Equiv.refl _) Equiv.ulift.symm)).trans_le (hf b) #align cardinal.lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le Cardinal.lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le /-- The range of an indexed cardinal function, whose outputs live in a higher universe than the inputs, is always bounded above. -/ theorem bddAbove_range {ι : Type u} (f : ι → Cardinal.{max u v}) : BddAbove (Set.range f) := ⟨_, by rintro a ⟨i, rfl⟩ -- Porting note: Added universe reference below exact le_sum.{v,u} f i⟩ #align cardinal.bdd_above_range Cardinal.bddAbove_range instance (a : Cardinal.{u}) : Small.{u} (Set.Iic a) := by rw [← mk_out a] apply @small_of_surjective (Set a.out) (Iic #a.out) _ fun x => ⟨#x, mk_set_le x⟩ rintro ⟨x, hx⟩ simpa using le_mk_iff_exists_set.1 hx instance (a : Cardinal.{u}) : Small.{u} (Set.Iio a) := small_subset Iio_subset_Iic_self /-- A set of cardinals is bounded above iff it's small, i.e. it corresponds to a usual ZFC set. -/ theorem bddAbove_iff_small {s : Set Cardinal.{u}} : BddAbove s ↔ Small.{u} s := ⟨fun ⟨a, ha⟩ => @small_subset _ (Iic a) s (fun x h => ha h) _, by rintro ⟨ι, ⟨e⟩⟩ suffices (range fun x : ι => (e.symm x).1) = s by rw [← this] apply bddAbove_range.{u, u} ext x refine ⟨?_, fun hx => ⟨e ⟨x, hx⟩, ?_⟩⟩ · rintro ⟨a, rfl⟩ exact (e.symm a).2 · simp_rw [Equiv.symm_apply_apply]⟩ #align cardinal.bdd_above_iff_small Cardinal.bddAbove_iff_small theorem bddAbove_of_small (s : Set Cardinal.{u}) [h : Small.{u} s] : BddAbove s := bddAbove_iff_small.2 h #align cardinal.bdd_above_of_small Cardinal.bddAbove_of_small theorem bddAbove_image (f : Cardinal.{u} → Cardinal.{max u v}) {s : Set Cardinal.{u}} (hs : BddAbove s) : BddAbove (f '' s) := by rw [bddAbove_iff_small] at hs ⊢ -- Porting note: added universes below exact small_lift.{_,v,_} _ #align cardinal.bdd_above_image Cardinal.bddAbove_image theorem bddAbove_range_comp {ι : Type u} {f : ι → Cardinal.{v}} (hf : BddAbove (range f)) (g : Cardinal.{v} → Cardinal.{max v w}) : BddAbove (range (g ∘ f)) := by rw [range_comp] exact bddAbove_image.{v,w} g hf #align cardinal.bdd_above_range_comp Cardinal.bddAbove_range_comp theorem iSup_le_sum {ι} (f : ι → Cardinal) : iSup f ≤ sum f := ciSup_le' <| le_sum.{u_2,u_1} _ #align cardinal.supr_le_sum Cardinal.iSup_le_sum -- Porting note: Added universe hint .{v,_} below theorem sum_le_iSup_lift {ι : Type u} (f : ι → Cardinal.{max u v}) : sum f ≤ Cardinal.lift.{v,_} #ι * iSup f := by rw [← (iSup f).lift_id, ← lift_umax, lift_umax.{max u v, u}, ← sum_const] exact sum_le_sum _ _ (le_ciSup <| bddAbove_range.{u, v} f) #align cardinal.sum_le_supr_lift Cardinal.sum_le_iSup_lift theorem sum_le_iSup {ι : Type u} (f : ι → Cardinal.{u}) : sum f ≤ #ι * iSup f := by rw [← lift_id #ι] exact sum_le_iSup_lift f #align cardinal.sum_le_supr Cardinal.sum_le_iSup theorem sum_nat_eq_add_sum_succ (f : ℕ → Cardinal.{u}) : Cardinal.sum f = f 0 + Cardinal.sum fun i => f (i + 1) := by refine (Equiv.sigmaNatSucc fun i => Quotient.out (f i)).cardinal_eq.trans ?_ simp only [mk_sum, mk_out, lift_id, mk_sigma] #align cardinal.sum_nat_eq_add_sum_succ Cardinal.sum_nat_eq_add_sum_succ -- Porting note: LFS is not in normal form. -- @[simp] /-- A variant of `ciSup_of_empty` but with `0` on the RHS for convenience -/ protected theorem iSup_of_empty {ι} (f : ι → Cardinal) [IsEmpty ι] : iSup f = 0 := ciSup_of_empty f #align cardinal.supr_of_empty Cardinal.iSup_of_empty lemma exists_eq_of_iSup_eq_of_not_isSuccLimit {ι : Type u} (f : ι → Cardinal.{v}) (ω : Cardinal.{v}) (hω : ¬ Order.IsSuccLimit ω) (h : ⨆ i : ι, f i = ω) : ∃ i, f i = ω := by subst h refine (isLUB_csSup' ?_).exists_of_not_isSuccLimit hω contrapose! hω with hf rw [iSup, csSup_of_not_bddAbove hf, csSup_empty] exact Order.isSuccLimit_bot lemma exists_eq_of_iSup_eq_of_not_isLimit {ι : Type u} [hι : Nonempty ι] (f : ι → Cardinal.{v}) (hf : BddAbove (range f)) (ω : Cardinal.{v}) (hω : ¬ ω.IsLimit) (h : ⨆ i : ι, f i = ω) : ∃ i, f i = ω := by refine (not_and_or.mp hω).elim (fun e ↦ ⟨hι.some, ?_⟩) (Cardinal.exists_eq_of_iSup_eq_of_not_isSuccLimit.{u, v} f ω · h) cases not_not.mp e rw [← le_zero_iff] at h ⊢ exact (le_ciSup hf _).trans h -- Porting note: simpNF is not happy with universe levels. @[simp, nolint simpNF] theorem lift_mk_shrink (α : Type u) [Small.{v} α] : Cardinal.lift.{max u w} #(Shrink.{v} α) = Cardinal.lift.{max v w} #α := -- Porting note: Added .{v,u,w} universe hint below lift_mk_eq.{v,u,w}.2 ⟨(equivShrink α).symm⟩ #align cardinal.lift_mk_shrink Cardinal.lift_mk_shrink @[simp] theorem lift_mk_shrink' (α : Type u) [Small.{v} α] : Cardinal.lift.{u} #(Shrink.{v} α) = Cardinal.lift.{v} #α := lift_mk_shrink.{u, v, 0} α #align cardinal.lift_mk_shrink' Cardinal.lift_mk_shrink' @[simp] theorem lift_mk_shrink'' (α : Type max u v) [Small.{v} α] : Cardinal.lift.{u} #(Shrink.{v} α) = #α := by rw [← lift_umax', lift_mk_shrink.{max u v, v, 0} α, ← lift_umax, lift_id] #align cardinal.lift_mk_shrink'' Cardinal.lift_mk_shrink'' /-- The indexed product of cardinals is the cardinality of the Pi type (dependent product). -/ def prod {ι : Type u} (f : ι → Cardinal) : Cardinal := #(∀ i, (f i).out) #align cardinal.prod Cardinal.prod @[simp] theorem mk_pi {ι : Type u} (α : ι → Type v) : #(∀ i, α i) = prod fun i => #(α i) := mk_congr <| Equiv.piCongrRight fun _ => outMkEquiv.symm #align cardinal.mk_pi Cardinal.mk_pi @[simp] theorem prod_const (ι : Type u) (a : Cardinal.{v}) : (prod fun _ : ι => a) = lift.{u} a ^ lift.{v} #ι := inductionOn a fun _ => mk_congr <| Equiv.piCongr Equiv.ulift.symm fun _ => outMkEquiv.trans Equiv.ulift.symm #align cardinal.prod_const Cardinal.prod_const theorem prod_const' (ι : Type u) (a : Cardinal.{u}) : (prod fun _ : ι => a) = a ^ #ι := inductionOn a fun _ => (mk_pi _).symm #align cardinal.prod_const' Cardinal.prod_const' theorem prod_le_prod {ι} (f g : ι → Cardinal) (H : ∀ i, f i ≤ g i) : prod f ≤ prod g := ⟨Embedding.piCongrRight fun i => Classical.choice <| by have := H i; rwa [← mk_out (f i), ← mk_out (g i)] at this⟩ #align cardinal.prod_le_prod Cardinal.prod_le_prod @[simp] theorem prod_eq_zero {ι} (f : ι → Cardinal.{u}) : prod f = 0 ↔ ∃ i, f i = 0 := by lift f to ι → Type u using fun _ => trivial simp only [mk_eq_zero_iff, ← mk_pi, isEmpty_pi] #align cardinal.prod_eq_zero Cardinal.prod_eq_zero theorem prod_ne_zero {ι} (f : ι → Cardinal) : prod f ≠ 0 ↔ ∀ i, f i ≠ 0 := by simp [prod_eq_zero] #align cardinal.prod_ne_zero Cardinal.prod_ne_zero @[simp] theorem lift_prod {ι : Type u} (c : ι → Cardinal.{v}) : lift.{w} (prod c) = prod fun i => lift.{w} (c i) := by lift c to ι → Type v using fun _ => trivial simp only [← mk_pi, ← mk_uLift] exact mk_congr (Equiv.ulift.trans <| Equiv.piCongrRight fun i => Equiv.ulift.symm) #align cardinal.lift_prod Cardinal.lift_prod theorem prod_eq_of_fintype {α : Type u} [h : Fintype α] (f : α → Cardinal.{v}) : prod f = Cardinal.lift.{u} (∏ i, f i) := by revert f refine Fintype.induction_empty_option ?_ ?_ ?_ α (h_fintype := h) · intro α β hβ e h f letI := Fintype.ofEquiv β e.symm rw [← e.prod_comp f, ← h] exact mk_congr (e.piCongrLeft _).symm · intro f rw [Fintype.univ_pempty, Finset.prod_empty, lift_one, Cardinal.prod, mk_eq_one] · intro α hα h f rw [Cardinal.prod, mk_congr Equiv.piOptionEquivProd, mk_prod, lift_umax'.{v, u}, mk_out, ← Cardinal.prod, lift_prod, Fintype.prod_option, lift_mul, ← h fun a => f (some a)] simp only [lift_id] #align cardinal.prod_eq_of_fintype Cardinal.prod_eq_of_fintype -- Porting note: Inserted .{u,v} below @[simp] theorem lift_sInf (s : Set Cardinal) : lift.{u,v} (sInf s) = sInf (lift.{u,v} '' s) := by rcases eq_empty_or_nonempty s with (rfl | hs) · simp · exact lift_monotone.map_csInf hs #align cardinal.lift_Inf Cardinal.lift_sInf -- Porting note: Inserted .{u,v} below @[simp] theorem lift_iInf {ι} (f : ι → Cardinal) : lift.{u,v} (iInf f) = ⨅ i, lift.{u,v} (f i) := by unfold iInf convert lift_sInf (range f) simp_rw [← comp_apply (f := lift), range_comp] #align cardinal.lift_infi Cardinal.lift_iInf theorem lift_down {a : Cardinal.{u}} {b : Cardinal.{max u v}} : b ≤ lift.{v,u} a → ∃ a', lift.{v,u} a' = b := inductionOn₂ a b fun α β => by rw [← lift_id #β, ← lift_umax, ← lift_umax.{u, v}, lift_mk_le.{v}] exact fun ⟨f⟩ => ⟨#(Set.range f), Eq.symm <| lift_mk_eq.{_, _, v}.2 ⟨Function.Embedding.equivOfSurjective (Embedding.codRestrict _ f Set.mem_range_self) fun ⟨a, ⟨b, e⟩⟩ => ⟨b, Subtype.eq e⟩⟩⟩ #align cardinal.lift_down Cardinal.lift_down -- Porting note: Inserted .{u,v} below theorem le_lift_iff {a : Cardinal.{u}} {b : Cardinal.{max u v}} : b ≤ lift.{v,u} a ↔ ∃ a', lift.{v,u} a' = b ∧ a' ≤ a := ⟨fun h => let ⟨a', e⟩ := lift_down h ⟨a', e, lift_le.1 <| e.symm ▸ h⟩, fun ⟨_, e, h⟩ => e ▸ lift_le.2 h⟩ #align cardinal.le_lift_iff Cardinal.le_lift_iff -- Porting note: Inserted .{u,v} below theorem lt_lift_iff {a : Cardinal.{u}} {b : Cardinal.{max u v}} : b < lift.{v,u} a ↔ ∃ a', lift.{v,u} a' = b ∧ a' < a := ⟨fun h => let ⟨a', e⟩ := lift_down h.le ⟨a', e, lift_lt.1 <| e.symm ▸ h⟩, fun ⟨_, e, h⟩ => e ▸ lift_lt.2 h⟩ #align cardinal.lt_lift_iff Cardinal.lt_lift_iff -- Porting note: Inserted .{u,v} below @[simp] theorem lift_succ (a) : lift.{v,u} (succ a) = succ (lift.{v,u} a) := le_antisymm (le_of_not_gt fun h => by rcases lt_lift_iff.1 h with ⟨b, e, h⟩ rw [lt_succ_iff, ← lift_le, e] at h exact h.not_lt (lt_succ _)) (succ_le_of_lt <| lift_lt.2 <| lt_succ a) #align cardinal.lift_succ Cardinal.lift_succ -- Porting note: simpNF is not happy with universe levels. -- Porting note: Inserted .{u,v} below @[simp, nolint simpNF] theorem lift_umax_eq {a : Cardinal.{u}} {b : Cardinal.{v}} : lift.{max v w} a = lift.{max u w} b ↔ lift.{v} a = lift.{u} b := by rw [← lift_lift.{v, w, u}, ← lift_lift.{u, w, v}, lift_inj] #align cardinal.lift_umax_eq Cardinal.lift_umax_eq -- Porting note: Inserted .{u,v} below @[simp] theorem lift_min {a b : Cardinal} : lift.{u,v} (min a b) = min (lift.{u,v} a) (lift.{u,v} b) := lift_monotone.map_min #align cardinal.lift_min Cardinal.lift_min -- Porting note: Inserted .{u,v} below @[simp] theorem lift_max {a b : Cardinal} : lift.{u,v} (max a b) = max (lift.{u,v} a) (lift.{u,v} b) := lift_monotone.map_max #align cardinal.lift_max Cardinal.lift_max /-- The lift of a supremum is the supremum of the lifts. -/ theorem lift_sSup {s : Set Cardinal} (hs : BddAbove s) : lift.{u} (sSup s) = sSup (lift.{u} '' s) := by apply ((le_csSup_iff' (bddAbove_image.{_,u} _ hs)).2 fun c hc => _).antisymm (csSup_le' _) · intro c hc by_contra h obtain ⟨d, rfl⟩ := Cardinal.lift_down (not_le.1 h).le simp_rw [lift_le] at h hc rw [csSup_le_iff' hs] at h exact h fun a ha => lift_le.1 <| hc (mem_image_of_mem _ ha) · rintro i ⟨j, hj, rfl⟩ exact lift_le.2 (le_csSup hs hj) #align cardinal.lift_Sup Cardinal.lift_sSup /-- The lift of a supremum is the supremum of the lifts. -/ theorem lift_iSup {ι : Type v} {f : ι → Cardinal.{w}} (hf : BddAbove (range f)) : lift.{u} (iSup f) = ⨆ i, lift.{u} (f i) := by rw [iSup, iSup, lift_sSup hf, ← range_comp] simp [Function.comp] #align cardinal.lift_supr Cardinal.lift_iSup /-- To prove that the lift of a supremum is bounded by some cardinal `t`, it suffices to show that the lift of each cardinal is bounded by `t`. -/ theorem lift_iSup_le {ι : Type v} {f : ι → Cardinal.{w}} {t : Cardinal} (hf : BddAbove (range f)) (w : ∀ i, lift.{u} (f i) ≤ t) : lift.{u} (iSup f) ≤ t := by rw [lift_iSup hf] exact ciSup_le' w #align cardinal.lift_supr_le Cardinal.lift_iSup_le @[simp] theorem lift_iSup_le_iff {ι : Type v} {f : ι → Cardinal.{w}} (hf : BddAbove (range f)) {t : Cardinal} : lift.{u} (iSup f) ≤ t ↔ ∀ i, lift.{u} (f i) ≤ t := by rw [lift_iSup hf] exact ciSup_le_iff' (bddAbove_range_comp.{_,_,u} hf _) #align cardinal.lift_supr_le_iff Cardinal.lift_iSup_le_iff universe v' w' /-- To prove an inequality between the lifts to a common universe of two different supremums, it suffices to show that the lift of each cardinal from the smaller supremum if bounded by the lift of some cardinal from the larger supremum. -/ theorem lift_iSup_le_lift_iSup {ι : Type v} {ι' : Type v'} {f : ι → Cardinal.{w}} {f' : ι' → Cardinal.{w'}} (hf : BddAbove (range f)) (hf' : BddAbove (range f')) {g : ι → ι'} (h : ∀ i, lift.{w'} (f i) ≤ lift.{w} (f' (g i))) : lift.{w'} (iSup f) ≤ lift.{w} (iSup f') := by rw [lift_iSup hf, lift_iSup hf'] exact ciSup_mono' (bddAbove_range_comp.{_,_,w} hf' _) fun i => ⟨_, h i⟩ #align cardinal.lift_supr_le_lift_supr Cardinal.lift_iSup_le_lift_iSup /-- A variant of `lift_iSup_le_lift_iSup` with universes specialized via `w = v` and `w' = v'`. This is sometimes necessary to avoid universe unification issues. -/ theorem lift_iSup_le_lift_iSup' {ι : Type v} {ι' : Type v'} {f : ι → Cardinal.{v}} {f' : ι' → Cardinal.{v'}} (hf : BddAbove (range f)) (hf' : BddAbove (range f')) (g : ι → ι') (h : ∀ i, lift.{v'} (f i) ≤ lift.{v} (f' (g i))) : lift.{v'} (iSup f) ≤ lift.{v} (iSup f') := lift_iSup_le_lift_iSup hf hf' h #align cardinal.lift_supr_le_lift_supr' Cardinal.lift_iSup_le_lift_iSup' /-- `ℵ₀` is the smallest infinite cardinal. -/ def aleph0 : Cardinal.{u} := lift #ℕ #align cardinal.aleph_0 Cardinal.aleph0 @[inherit_doc] scoped notation "ℵ₀" => Cardinal.aleph0 theorem mk_nat : #ℕ = ℵ₀ := (lift_id _).symm #align cardinal.mk_nat Cardinal.mk_nat theorem aleph0_ne_zero : ℵ₀ ≠ 0 := mk_ne_zero _ #align cardinal.aleph_0_ne_zero Cardinal.aleph0_ne_zero theorem aleph0_pos : 0 < ℵ₀ := pos_iff_ne_zero.2 aleph0_ne_zero #align cardinal.aleph_0_pos Cardinal.aleph0_pos @[simp] theorem lift_aleph0 : lift ℵ₀ = ℵ₀ := lift_lift _ #align cardinal.lift_aleph_0 Cardinal.lift_aleph0 @[simp] theorem aleph0_le_lift {c : Cardinal.{u}} : ℵ₀ ≤ lift.{v} c ↔ ℵ₀ ≤ c := by rw [← lift_aleph0.{u,v}, lift_le] #align cardinal.aleph_0_le_lift Cardinal.aleph0_le_lift @[simp] theorem lift_le_aleph0 {c : Cardinal.{u}} : lift.{v} c ≤ ℵ₀ ↔ c ≤ ℵ₀ := by rw [← lift_aleph0.{u,v}, lift_le] #align cardinal.lift_le_aleph_0 Cardinal.lift_le_aleph0 @[simp] theorem aleph0_lt_lift {c : Cardinal.{u}} : ℵ₀ < lift.{v} c ↔ ℵ₀ < c := by rw [← lift_aleph0.{u,v}, lift_lt] #align cardinal.aleph_0_lt_lift Cardinal.aleph0_lt_lift @[simp] theorem lift_lt_aleph0 {c : Cardinal.{u}} : lift.{v} c < ℵ₀ ↔ c < ℵ₀ := by rw [← lift_aleph0.{u,v}, lift_lt] #align cardinal.lift_lt_aleph_0 Cardinal.lift_lt_aleph0 /-! ### Properties about the cast from `ℕ` -/ section castFromN -- porting note (#10618): simp can prove this -- @[simp] theorem mk_fin (n : ℕ) : #(Fin n) = n := by simp #align cardinal.mk_fin Cardinal.mk_fin @[simp] theorem lift_natCast (n : ℕ) : lift.{u} (n : Cardinal.{v}) = n := by induction n <;> simp [*] #align cardinal.lift_nat_cast Cardinal.lift_natCast -- See note [no_index around OfNat.ofNat] @[simp] theorem lift_ofNat (n : ℕ) [n.AtLeastTwo] : lift.{u} (no_index (OfNat.ofNat n : Cardinal.{v})) = OfNat.ofNat n := lift_natCast n @[simp] theorem lift_eq_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a = n ↔ a = n := lift_injective.eq_iff' (lift_natCast n) #align cardinal.lift_eq_nat_iff Cardinal.lift_eq_nat_iff @[simp] theorem lift_eq_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : lift.{v} a = (no_index (OfNat.ofNat n)) ↔ a = OfNat.ofNat n := lift_eq_nat_iff @[simp] theorem nat_eq_lift_iff {n : ℕ} {a : Cardinal.{u}} : (n : Cardinal) = lift.{v} a ↔ (n : Cardinal) = a := by rw [← lift_natCast.{v,u} n, lift_inj] #align cardinal.nat_eq_lift_iff Cardinal.nat_eq_lift_iff @[simp] theorem zero_eq_lift_iff {a : Cardinal.{u}} : (0 : Cardinal) = lift.{v} a ↔ 0 = a := by simpa using nat_eq_lift_iff (n := 0) @[simp] theorem one_eq_lift_iff {a : Cardinal.{u}} : (1 : Cardinal) = lift.{v} a ↔ 1 = a := by simpa using nat_eq_lift_iff (n := 1) -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_eq_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : (no_index (OfNat.ofNat n : Cardinal)) = lift.{v} a ↔ (OfNat.ofNat n : Cardinal) = a := nat_eq_lift_iff @[simp] theorem lift_le_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a ≤ n ↔ a ≤ n := by rw [← lift_natCast.{v,u}, lift_le] #align cardinal.lift_le_nat_iff Cardinal.lift_le_nat_iff @[simp] theorem lift_le_one_iff {a : Cardinal.{u}} : lift.{v} a ≤ 1 ↔ a ≤ 1 := by simpa using lift_le_nat_iff (n := 1) -- See note [no_index around OfNat.ofNat] @[simp] theorem lift_le_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : lift.{v} a ≤ (no_index (OfNat.ofNat n)) ↔ a ≤ OfNat.ofNat n := lift_le_nat_iff @[simp] theorem nat_le_lift_iff {n : ℕ} {a : Cardinal.{u}} : n ≤ lift.{v} a ↔ n ≤ a := by rw [← lift_natCast.{v,u}, lift_le] #align cardinal.nat_le_lift_iff Cardinal.nat_le_lift_iff @[simp] theorem one_le_lift_iff {a : Cardinal.{u}} : (1 : Cardinal) ≤ lift.{v} a ↔ 1 ≤ a := by simpa using nat_le_lift_iff (n := 1) -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_le_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : (no_index (OfNat.ofNat n : Cardinal)) ≤ lift.{v} a ↔ (OfNat.ofNat n : Cardinal) ≤ a := nat_le_lift_iff @[simp] theorem lift_lt_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a < n ↔ a < n := by rw [← lift_natCast.{v,u}, lift_lt] #align cardinal.lift_lt_nat_iff Cardinal.lift_lt_nat_iff -- See note [no_index around OfNat.ofNat] @[simp] theorem lift_lt_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : lift.{v} a < (no_index (OfNat.ofNat n)) ↔ a < OfNat.ofNat n := lift_lt_nat_iff @[simp] theorem nat_lt_lift_iff {n : ℕ} {a : Cardinal.{u}} : n < lift.{v} a ↔ n < a := by rw [← lift_natCast.{v,u}, lift_lt] #align cardinal.nat_lt_lift_iff Cardinal.nat_lt_lift_iff -- See note [no_index around OfNat.ofNat] @[simp] theorem zero_lt_lift_iff {a : Cardinal.{u}} : (0 : Cardinal) < lift.{v} a ↔ 0 < a := by simpa using nat_lt_lift_iff (n := 0) @[simp] theorem one_lt_lift_iff {a : Cardinal.{u}} : (1 : Cardinal) < lift.{v} a ↔ 1 < a := by simpa using nat_lt_lift_iff (n := 1) -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_lt_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] : (no_index (OfNat.ofNat n : Cardinal)) < lift.{v} a ↔ (OfNat.ofNat n : Cardinal) < a := nat_lt_lift_iff theorem lift_mk_fin (n : ℕ) : lift #(Fin n) = n := rfl #align cardinal.lift_mk_fin Cardinal.lift_mk_fin theorem mk_coe_finset {α : Type u} {s : Finset α} : #s = ↑(Finset.card s) := by simp #align cardinal.mk_coe_finset Cardinal.mk_coe_finset theorem mk_finset_of_fintype [Fintype α] : #(Finset α) = 2 ^ Fintype.card α := by simp [Pow.pow] #align cardinal.mk_finset_of_fintype Cardinal.mk_finset_of_fintype @[simp] theorem mk_finsupp_lift_of_fintype (α : Type u) (β : Type v) [Fintype α] [Zero β] : #(α →₀ β) = lift.{u} #β ^ Fintype.card α := by simpa using (@Finsupp.equivFunOnFinite α β _ _).cardinal_eq #align cardinal.mk_finsupp_lift_of_fintype Cardinal.mk_finsupp_lift_of_fintype theorem mk_finsupp_of_fintype (α β : Type u) [Fintype α] [Zero β] : #(α →₀ β) = #β ^ Fintype.card α := by simp #align cardinal.mk_finsupp_of_fintype Cardinal.mk_finsupp_of_fintype theorem card_le_of_finset {α} (s : Finset α) : (s.card : Cardinal) ≤ #α := @mk_coe_finset _ s ▸ mk_set_le _ #align cardinal.card_le_of_finset Cardinal.card_le_of_finset -- Porting note: was `simp`. LHS is not normal form. -- @[simp, norm_cast] @[norm_cast] theorem natCast_pow {m n : ℕ} : (↑(m ^ n) : Cardinal) = (↑m : Cardinal) ^ (↑n : Cardinal) := by induction n <;> simp [pow_succ, power_add, *, Pow.pow] #align cardinal.nat_cast_pow Cardinal.natCast_pow -- porting note (#10618): simp can prove this -- @[simp, norm_cast] @[norm_cast] theorem natCast_le {m n : ℕ} : (m : Cardinal) ≤ n ↔ m ≤ n := by rw [← lift_mk_fin, ← lift_mk_fin, lift_le, le_def, Function.Embedding.nonempty_iff_card_le, Fintype.card_fin, Fintype.card_fin] #align cardinal.nat_cast_le Cardinal.natCast_le -- porting note (#10618): simp can prove this -- @[simp, norm_cast] @[norm_cast] theorem natCast_lt {m n : ℕ} : (m : Cardinal) < n ↔ m < n := by rw [lt_iff_le_not_le, ← not_le] simp only [natCast_le, not_le, and_iff_right_iff_imp] exact fun h ↦ le_of_lt h #align cardinal.nat_cast_lt Cardinal.natCast_lt instance : CharZero Cardinal := ⟨StrictMono.injective fun _ _ => natCast_lt.2⟩ theorem natCast_inj {m n : ℕ} : (m : Cardinal) = n ↔ m = n := Nat.cast_inj #align cardinal.nat_cast_inj Cardinal.natCast_inj theorem natCast_injective : Injective ((↑) : ℕ → Cardinal) := Nat.cast_injective #align cardinal.nat_cast_injective Cardinal.natCast_injective @[norm_cast] theorem nat_succ (n : ℕ) : (n.succ : Cardinal) = succ ↑n := by rw [Nat.cast_succ] refine (add_one_le_succ _).antisymm (succ_le_of_lt ?_) rw [← Nat.cast_succ] exact natCast_lt.2 (Nat.lt_succ_self _) lemma succ_natCast (n : ℕ) : Order.succ (n : Cardinal) = n + 1 := by rw [← Cardinal.nat_succ] norm_cast lemma natCast_add_one_le_iff {n : ℕ} {c : Cardinal} : n + 1 ≤ c ↔ n < c := by rw [← Order.succ_le_iff, Cardinal.succ_natCast] lemma two_le_iff_one_lt {c : Cardinal} : 2 ≤ c ↔ 1 < c := by convert natCast_add_one_le_iff norm_cast @[simp] theorem succ_zero : succ (0 : Cardinal) = 1 := by norm_cast #align cardinal.succ_zero Cardinal.succ_zero theorem exists_finset_le_card (α : Type*) (n : ℕ) (h : n ≤ #α) : ∃ s : Finset α, n ≤ s.card := by obtain hα|hα := finite_or_infinite α · let hα := Fintype.ofFinite α use Finset.univ simpa only [mk_fintype, Nat.cast_le] using h · obtain ⟨s, hs⟩ := Infinite.exists_subset_card_eq α n exact ⟨s, hs.ge⟩ theorem card_le_of {α : Type u} {n : ℕ} (H : ∀ s : Finset α, s.card ≤ n) : #α ≤ n := by contrapose! H apply exists_finset_le_card α (n+1) simpa only [nat_succ, succ_le_iff] using H #align cardinal.card_le_of Cardinal.card_le_of theorem cantor' (a) {b : Cardinal} (hb : 1 < b) : a < b ^ a := by rw [← succ_le_iff, (by norm_cast : succ (1 : Cardinal) = 2)] at hb exact (cantor a).trans_le (power_le_power_right hb) #align cardinal.cantor' Cardinal.cantor' theorem one_le_iff_pos {c : Cardinal} : 1 ≤ c ↔ 0 < c := by rw [← succ_zero, succ_le_iff] #align cardinal.one_le_iff_pos Cardinal.one_le_iff_pos theorem one_le_iff_ne_zero {c : Cardinal} : 1 ≤ c ↔ c ≠ 0 := by rw [one_le_iff_pos, pos_iff_ne_zero] #align cardinal.one_le_iff_ne_zero Cardinal.one_le_iff_ne_zero @[simp] theorem lt_one_iff_zero {c : Cardinal} : c < 1 ↔ c = 0 := by simpa using lt_succ_bot_iff (a := c) theorem nat_lt_aleph0 (n : ℕ) : (n : Cardinal.{u}) < ℵ₀ := succ_le_iff.1 (by rw [← nat_succ, ← lift_mk_fin, aleph0, lift_mk_le.{u}] exact ⟨⟨(↑), fun a b => Fin.ext⟩⟩) #align cardinal.nat_lt_aleph_0 Cardinal.nat_lt_aleph0 @[simp] theorem one_lt_aleph0 : 1 < ℵ₀ := by simpa using nat_lt_aleph0 1 #align cardinal.one_lt_aleph_0 Cardinal.one_lt_aleph0 theorem one_le_aleph0 : 1 ≤ ℵ₀ := one_lt_aleph0.le #align cardinal.one_le_aleph_0 Cardinal.one_le_aleph0 theorem lt_aleph0 {c : Cardinal} : c < ℵ₀ ↔ ∃ n : ℕ, c = n := ⟨fun h => by rcases lt_lift_iff.1 h with ⟨c, rfl, h'⟩ rcases le_mk_iff_exists_set.1 h'.1 with ⟨S, rfl⟩ suffices S.Finite by lift S to Finset ℕ using this simp contrapose! h' haveI := Infinite.to_subtype h' exact ⟨Infinite.natEmbedding S⟩, fun ⟨n, e⟩ => e.symm ▸ nat_lt_aleph0 _⟩ #align cardinal.lt_aleph_0 Cardinal.lt_aleph0 lemma succ_eq_of_lt_aleph0 {c : Cardinal} (h : c < ℵ₀) : Order.succ c = c + 1 := by obtain ⟨n, hn⟩ := Cardinal.lt_aleph0.mp h rw [hn, succ_natCast] theorem aleph0_le {c : Cardinal} : ℵ₀ ≤ c ↔ ∀ n : ℕ, ↑n ≤ c := ⟨fun h n => (nat_lt_aleph0 _).le.trans h, fun h => le_of_not_lt fun hn => by rcases lt_aleph0.1 hn with ⟨n, rfl⟩ exact (Nat.lt_succ_self _).not_le (natCast_le.1 (h (n + 1)))⟩ #align cardinal.aleph_0_le Cardinal.aleph0_le theorem isSuccLimit_aleph0 : IsSuccLimit ℵ₀ := isSuccLimit_of_succ_lt fun a ha => by rcases lt_aleph0.1 ha with ⟨n, rfl⟩ rw [← nat_succ] apply nat_lt_aleph0 #align cardinal.is_succ_limit_aleph_0 Cardinal.isSuccLimit_aleph0 theorem isLimit_aleph0 : IsLimit ℵ₀ := ⟨aleph0_ne_zero, isSuccLimit_aleph0⟩ #align cardinal.is_limit_aleph_0 Cardinal.isLimit_aleph0 lemma not_isLimit_natCast : (n : ℕ) → ¬ IsLimit (n : Cardinal.{u}) | 0, e => e.1 rfl | Nat.succ n, e => Order.not_isSuccLimit_succ _ (nat_succ n ▸ e.2) theorem IsLimit.aleph0_le {c : Cardinal} (h : IsLimit c) : ℵ₀ ≤ c := by by_contra! h' rcases lt_aleph0.1 h' with ⟨n, rfl⟩ exact not_isLimit_natCast n h lemma exists_eq_natCast_of_iSup_eq {ι : Type u} [Nonempty ι] (f : ι → Cardinal.{v}) (hf : BddAbove (range f)) (n : ℕ) (h : ⨆ i, f i = n) : ∃ i, f i = n := exists_eq_of_iSup_eq_of_not_isLimit.{u, v} f hf _ (not_isLimit_natCast n) h @[simp] theorem range_natCast : range ((↑) : ℕ → Cardinal) = Iio ℵ₀ := ext fun x => by simp only [mem_Iio, mem_range, eq_comm, lt_aleph0] #align cardinal.range_nat_cast Cardinal.range_natCast theorem mk_eq_nat_iff {α : Type u} {n : ℕ} : #α = n ↔ Nonempty (α ≃ Fin n) := by rw [← lift_mk_fin, ← lift_uzero #α, lift_mk_eq'] #align cardinal.mk_eq_nat_iff Cardinal.mk_eq_nat_iff theorem lt_aleph0_iff_finite {α : Type u} : #α < ℵ₀ ↔ Finite α := by simp only [lt_aleph0, mk_eq_nat_iff, finite_iff_exists_equiv_fin] #align cardinal.lt_aleph_0_iff_finite Cardinal.lt_aleph0_iff_finite theorem lt_aleph0_iff_fintype {α : Type u} : #α < ℵ₀ ↔ Nonempty (Fintype α) := lt_aleph0_iff_finite.trans (finite_iff_nonempty_fintype _) #align cardinal.lt_aleph_0_iff_fintype Cardinal.lt_aleph0_iff_fintype theorem lt_aleph0_of_finite (α : Type u) [Finite α] : #α < ℵ₀ := lt_aleph0_iff_finite.2 ‹_› #align cardinal.lt_aleph_0_of_finite Cardinal.lt_aleph0_of_finite -- porting note (#10618): simp can prove this -- @[simp] theorem lt_aleph0_iff_set_finite {S : Set α} : #S < ℵ₀ ↔ S.Finite := lt_aleph0_iff_finite.trans finite_coe_iff #align cardinal.lt_aleph_0_iff_set_finite Cardinal.lt_aleph0_iff_set_finite alias ⟨_, _root_.Set.Finite.lt_aleph0⟩ := lt_aleph0_iff_set_finite #align set.finite.lt_aleph_0 Set.Finite.lt_aleph0 @[simp] theorem lt_aleph0_iff_subtype_finite {p : α → Prop} : #{ x // p x } < ℵ₀ ↔ { x | p x }.Finite := lt_aleph0_iff_set_finite #align cardinal.lt_aleph_0_iff_subtype_finite Cardinal.lt_aleph0_iff_subtype_finite theorem mk_le_aleph0_iff : #α ≤ ℵ₀ ↔ Countable α := by rw [countable_iff_nonempty_embedding, aleph0, ← lift_uzero #α, lift_mk_le'] #align cardinal.mk_le_aleph_0_iff Cardinal.mk_le_aleph0_iff @[simp] theorem mk_le_aleph0 [Countable α] : #α ≤ ℵ₀ := mk_le_aleph0_iff.mpr ‹_› #align cardinal.mk_le_aleph_0 Cardinal.mk_le_aleph0 -- porting note (#10618): simp can prove this -- @[simp] theorem le_aleph0_iff_set_countable {s : Set α} : #s ≤ ℵ₀ ↔ s.Countable := mk_le_aleph0_iff #align cardinal.le_aleph_0_iff_set_countable Cardinal.le_aleph0_iff_set_countable alias ⟨_, _root_.Set.Countable.le_aleph0⟩ := le_aleph0_iff_set_countable #align set.countable.le_aleph_0 Set.Countable.le_aleph0 @[simp] theorem le_aleph0_iff_subtype_countable {p : α → Prop} : #{ x // p x } ≤ ℵ₀ ↔ { x | p x }.Countable := le_aleph0_iff_set_countable #align cardinal.le_aleph_0_iff_subtype_countable Cardinal.le_aleph0_iff_subtype_countable instance canLiftCardinalNat : CanLift Cardinal ℕ (↑) fun x => x < ℵ₀ := ⟨fun _ hx => let ⟨n, hn⟩ := lt_aleph0.mp hx ⟨n, hn.symm⟩⟩ #align cardinal.can_lift_cardinal_nat Cardinal.canLiftCardinalNat theorem add_lt_aleph0 {a b : Cardinal} (ha : a < ℵ₀) (hb : b < ℵ₀) : a + b < ℵ₀ := match a, b, lt_aleph0.1 ha, lt_aleph0.1 hb with | _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ => by rw [← Nat.cast_add]; apply nat_lt_aleph0 #align cardinal.add_lt_aleph_0 Cardinal.add_lt_aleph0 theorem add_lt_aleph0_iff {a b : Cardinal} : a + b < ℵ₀ ↔ a < ℵ₀ ∧ b < ℵ₀ := ⟨fun h => ⟨(self_le_add_right _ _).trans_lt h, (self_le_add_left _ _).trans_lt h⟩, fun ⟨h1, h2⟩ => add_lt_aleph0 h1 h2⟩ #align cardinal.add_lt_aleph_0_iff Cardinal.add_lt_aleph0_iff theorem aleph0_le_add_iff {a b : Cardinal} : ℵ₀ ≤ a + b ↔ ℵ₀ ≤ a ∨ ℵ₀ ≤ b := by simp only [← not_lt, add_lt_aleph0_iff, not_and_or] #align cardinal.aleph_0_le_add_iff Cardinal.aleph0_le_add_iff /-- See also `Cardinal.nsmul_lt_aleph0_iff_of_ne_zero` if you already have `n ≠ 0`. -/ theorem nsmul_lt_aleph0_iff {n : ℕ} {a : Cardinal} : n • a < ℵ₀ ↔ n = 0 ∨ a < ℵ₀ := by cases n with | zero => simpa using nat_lt_aleph0 0 | succ n => simp only [Nat.succ_ne_zero, false_or_iff] induction' n with n ih · simp rw [succ_nsmul, add_lt_aleph0_iff, ih, and_self_iff] #align cardinal.nsmul_lt_aleph_0_iff Cardinal.nsmul_lt_aleph0_iff /-- See also `Cardinal.nsmul_lt_aleph0_iff` for a hypothesis-free version. -/ theorem nsmul_lt_aleph0_iff_of_ne_zero {n : ℕ} {a : Cardinal} (h : n ≠ 0) : n • a < ℵ₀ ↔ a < ℵ₀ := nsmul_lt_aleph0_iff.trans <| or_iff_right h #align cardinal.nsmul_lt_aleph_0_iff_of_ne_zero Cardinal.nsmul_lt_aleph0_iff_of_ne_zero theorem mul_lt_aleph0 {a b : Cardinal} (ha : a < ℵ₀) (hb : b < ℵ₀) : a * b < ℵ₀ := match a, b, lt_aleph0.1 ha, lt_aleph0.1 hb with | _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ => by rw [← Nat.cast_mul]; apply nat_lt_aleph0 #align cardinal.mul_lt_aleph_0 Cardinal.mul_lt_aleph0 theorem mul_lt_aleph0_iff {a b : Cardinal} : a * b < ℵ₀ ↔ a = 0 ∨ b = 0 ∨ a < ℵ₀ ∧ b < ℵ₀ := by refine ⟨fun h => ?_, ?_⟩ · by_cases ha : a = 0 · exact Or.inl ha right by_cases hb : b = 0 · exact Or.inl hb right rw [← Ne, ← one_le_iff_ne_zero] at ha hb constructor · rw [← mul_one a] exact (mul_le_mul' le_rfl hb).trans_lt h · rw [← one_mul b] exact (mul_le_mul' ha le_rfl).trans_lt h rintro (rfl | rfl | ⟨ha, hb⟩) <;> simp only [*, mul_lt_aleph0, aleph0_pos, zero_mul, mul_zero] #align cardinal.mul_lt_aleph_0_iff Cardinal.mul_lt_aleph0_iff /-- See also `Cardinal.aleph0_le_mul_iff`. -/ theorem aleph0_le_mul_iff {a b : Cardinal} : ℵ₀ ≤ a * b ↔ a ≠ 0 ∧ b ≠ 0 ∧ (ℵ₀ ≤ a ∨ ℵ₀ ≤ b) := by let h := (@mul_lt_aleph0_iff a b).not rwa [not_lt, not_or, not_or, not_and_or, not_lt, not_lt] at h #align cardinal.aleph_0_le_mul_iff Cardinal.aleph0_le_mul_iff /-- See also `Cardinal.aleph0_le_mul_iff'`. -/ theorem aleph0_le_mul_iff' {a b : Cardinal.{u}} : ℵ₀ ≤ a * b ↔ a ≠ 0 ∧ ℵ₀ ≤ b ∨ ℵ₀ ≤ a ∧ b ≠ 0 := by have : ∀ {a : Cardinal.{u}}, ℵ₀ ≤ a → a ≠ 0 := fun a => ne_bot_of_le_ne_bot aleph0_ne_zero a simp only [aleph0_le_mul_iff, and_or_left, and_iff_right_of_imp this, @and_left_comm (a ≠ 0)] simp only [and_comm, or_comm] #align cardinal.aleph_0_le_mul_iff' Cardinal.aleph0_le_mul_iff' theorem mul_lt_aleph0_iff_of_ne_zero {a b : Cardinal} (ha : a ≠ 0) (hb : b ≠ 0) : a * b < ℵ₀ ↔ a < ℵ₀ ∧ b < ℵ₀ := by simp [mul_lt_aleph0_iff, ha, hb] #align cardinal.mul_lt_aleph_0_iff_of_ne_zero Cardinal.mul_lt_aleph0_iff_of_ne_zero theorem power_lt_aleph0 {a b : Cardinal} (ha : a < ℵ₀) (hb : b < ℵ₀) : a ^ b < ℵ₀ := match a, b, lt_aleph0.1 ha, lt_aleph0.1 hb with | _, _, ⟨m, rfl⟩, ⟨n, rfl⟩ => by rw [← natCast_pow]; apply nat_lt_aleph0 #align cardinal.power_lt_aleph_0 Cardinal.power_lt_aleph0 theorem eq_one_iff_unique {α : Type*} : #α = 1 ↔ Subsingleton α ∧ Nonempty α := calc #α = 1 ↔ #α ≤ 1 ∧ 1 ≤ #α := le_antisymm_iff _ ↔ Subsingleton α ∧ Nonempty α := le_one_iff_subsingleton.and (one_le_iff_ne_zero.trans mk_ne_zero_iff) #align cardinal.eq_one_iff_unique Cardinal.eq_one_iff_unique theorem infinite_iff {α : Type u} : Infinite α ↔ ℵ₀ ≤ #α := by rw [← not_lt, lt_aleph0_iff_finite, not_finite_iff_infinite] #align cardinal.infinite_iff Cardinal.infinite_iff lemma aleph0_le_mk_iff : ℵ₀ ≤ #α ↔ Infinite α := infinite_iff.symm lemma mk_lt_aleph0_iff : #α < ℵ₀ ↔ Finite α := by simp [← not_le, aleph0_le_mk_iff] @[simp] theorem aleph0_le_mk (α : Type u) [Infinite α] : ℵ₀ ≤ #α := infinite_iff.1 ‹_› #align cardinal.aleph_0_le_mk Cardinal.aleph0_le_mk @[simp] theorem mk_eq_aleph0 (α : Type*) [Countable α] [Infinite α] : #α = ℵ₀ := mk_le_aleph0.antisymm <| aleph0_le_mk _ #align cardinal.mk_eq_aleph_0 Cardinal.mk_eq_aleph0 theorem denumerable_iff {α : Type u} : Nonempty (Denumerable α) ↔ #α = ℵ₀ := ⟨fun ⟨h⟩ => mk_congr ((@Denumerable.eqv α h).trans Equiv.ulift.symm), fun h => by cases' Quotient.exact h with f exact ⟨Denumerable.mk' <| f.trans Equiv.ulift⟩⟩ #align cardinal.denumerable_iff Cardinal.denumerable_iff -- porting note (#10618): simp can prove this -- @[simp] theorem mk_denumerable (α : Type u) [Denumerable α] : #α = ℵ₀ := denumerable_iff.1 ⟨‹_›⟩ #align cardinal.mk_denumerable Cardinal.mk_denumerable theorem _root_.Set.countable_infinite_iff_nonempty_denumerable {α : Type*} {s : Set α} : s.Countable ∧ s.Infinite ↔ Nonempty (Denumerable s) := by rw [nonempty_denumerable_iff, ← Set.infinite_coe_iff, countable_coe_iff] @[simp] theorem aleph0_add_aleph0 : ℵ₀ + ℵ₀ = ℵ₀ := mk_denumerable _ #align cardinal.aleph_0_add_aleph_0 Cardinal.aleph0_add_aleph0 theorem aleph0_mul_aleph0 : ℵ₀ * ℵ₀ = ℵ₀ := mk_denumerable _ #align cardinal.aleph_0_mul_aleph_0 Cardinal.aleph0_mul_aleph0 @[simp] theorem nat_mul_aleph0 {n : ℕ} (hn : n ≠ 0) : ↑n * ℵ₀ = ℵ₀ := le_antisymm (lift_mk_fin n ▸ mk_le_aleph0) <| le_mul_of_one_le_left (zero_le _) <| by rwa [← Nat.cast_one, natCast_le, Nat.one_le_iff_ne_zero] #align cardinal.nat_mul_aleph_0 Cardinal.nat_mul_aleph0 @[simp] theorem aleph0_mul_nat {n : ℕ} (hn : n ≠ 0) : ℵ₀ * n = ℵ₀ := by rw [mul_comm, nat_mul_aleph0 hn] #align cardinal.aleph_0_mul_nat Cardinal.aleph0_mul_nat -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_mul_aleph0 {n : ℕ} [Nat.AtLeastTwo n] : no_index (OfNat.ofNat n) * ℵ₀ = ℵ₀ := nat_mul_aleph0 (NeZero.ne n) -- See note [no_index around OfNat.ofNat] @[simp] theorem aleph0_mul_ofNat {n : ℕ} [Nat.AtLeastTwo n] : ℵ₀ * no_index (OfNat.ofNat n) = ℵ₀ := aleph0_mul_nat (NeZero.ne n) @[simp] theorem add_le_aleph0 {c₁ c₂ : Cardinal} : c₁ + c₂ ≤ ℵ₀ ↔ c₁ ≤ ℵ₀ ∧ c₂ ≤ ℵ₀ := ⟨fun h => ⟨le_self_add.trans h, le_add_self.trans h⟩, fun h => aleph0_add_aleph0 ▸ add_le_add h.1 h.2⟩ #align cardinal.add_le_aleph_0 Cardinal.add_le_aleph0 @[simp] theorem aleph0_add_nat (n : ℕ) : ℵ₀ + n = ℵ₀ := (add_le_aleph0.2 ⟨le_rfl, (nat_lt_aleph0 n).le⟩).antisymm le_self_add #align cardinal.aleph_0_add_nat Cardinal.aleph0_add_nat @[simp] theorem nat_add_aleph0 (n : ℕ) : ↑n + ℵ₀ = ℵ₀ := by rw [add_comm, aleph0_add_nat] #align cardinal.nat_add_aleph_0 Cardinal.nat_add_aleph0 -- See note [no_index around OfNat.ofNat] @[simp] theorem ofNat_add_aleph0 {n : ℕ} [Nat.AtLeastTwo n] : no_index (OfNat.ofNat n) + ℵ₀ = ℵ₀ := nat_add_aleph0 n -- See note [no_index around OfNat.ofNat] @[simp] theorem aleph0_add_ofNat {n : ℕ} [Nat.AtLeastTwo n] : ℵ₀ + no_index (OfNat.ofNat n) = ℵ₀ := aleph0_add_nat n theorem exists_nat_eq_of_le_nat {c : Cardinal} {n : ℕ} (h : c ≤ n) : ∃ m, m ≤ n ∧ c = m := by lift c to ℕ using h.trans_lt (nat_lt_aleph0 _) exact ⟨c, mod_cast h, rfl⟩ #align cardinal.exists_nat_eq_of_le_nat Cardinal.exists_nat_eq_of_le_nat theorem mk_int : #ℤ = ℵ₀ := mk_denumerable ℤ #align cardinal.mk_int Cardinal.mk_int theorem mk_pNat : #ℕ+ = ℵ₀ := mk_denumerable ℕ+ #align cardinal.mk_pnat Cardinal.mk_pNat end castFromN variable {c : Cardinal} /-- **König's theorem** -/ theorem sum_lt_prod {ι} (f g : ι → Cardinal) (H : ∀ i, f i < g i) : sum f < prod g := lt_of_not_ge fun ⟨F⟩ => by have : Inhabited (∀ i : ι, (g i).out) := by refine ⟨fun i => Classical.choice <| mk_ne_zero_iff.1 ?_⟩ rw [mk_out] exact (H i).ne_bot let G := invFun F have sG : Surjective G := invFun_surjective F.2 choose C hc using show ∀ i, ∃ b, ∀ a, G ⟨i, a⟩ i ≠ b by intro i simp only [not_exists.symm, not_forall.symm] refine fun h => (H i).not_le ?_ rw [← mk_out (f i), ← mk_out (g i)] exact ⟨Embedding.ofSurjective _ h⟩ let ⟨⟨i, a⟩, h⟩ := sG C exact hc i a (congr_fun h _) #align cardinal.sum_lt_prod Cardinal.sum_lt_prod /-! Cardinalities of sets: cardinality of empty, finite sets, unions, subsets etc. -/ section sets -- porting note (#10618): simp can prove this -- @[simp] theorem mk_empty : #Empty = 0 := mk_eq_zero _ #align cardinal.mk_empty Cardinal.mk_empty -- porting note (#10618): simp can prove this -- @[simp] theorem mk_pempty : #PEmpty = 0 := mk_eq_zero _ #align cardinal.mk_pempty Cardinal.mk_pempty -- porting note (#10618): simp can prove this -- @[simp] theorem mk_punit : #PUnit = 1 := mk_eq_one PUnit #align cardinal.mk_punit Cardinal.mk_punit theorem mk_unit : #Unit = 1 := mk_punit #align cardinal.mk_unit Cardinal.mk_unit -- porting note (#10618): simp can prove this -- @[simp] theorem mk_singleton {α : Type u} (x : α) : #({x} : Set α) = 1 := mk_eq_one _ #align cardinal.mk_singleton Cardinal.mk_singleton -- porting note (#10618): simp can prove this -- @[simp] theorem mk_plift_true : #(PLift True) = 1 := mk_eq_one _ #align cardinal.mk_plift_true Cardinal.mk_plift_true -- porting note (#10618): simp can prove this -- @[simp] theorem mk_plift_false : #(PLift False) = 0 := mk_eq_zero _ #align cardinal.mk_plift_false Cardinal.mk_plift_false @[simp] theorem mk_vector (α : Type u) (n : ℕ) : #(Vector α n) = #α ^ n := (mk_congr (Equiv.vectorEquivFin α n)).trans <| by simp #align cardinal.mk_vector Cardinal.mk_vector theorem mk_list_eq_sum_pow (α : Type u) : #(List α) = sum fun n : ℕ => #α ^ n := calc #(List α) = #(Σn, Vector α n) := mk_congr (Equiv.sigmaFiberEquiv List.length).symm _ = sum fun n : ℕ => #α ^ n := by simp #align cardinal.mk_list_eq_sum_pow Cardinal.mk_list_eq_sum_pow theorem mk_quot_le {α : Type u} {r : α → α → Prop} : #(Quot r) ≤ #α := mk_le_of_surjective Quot.exists_rep #align cardinal.mk_quot_le Cardinal.mk_quot_le theorem mk_quotient_le {α : Type u} {s : Setoid α} : #(Quotient s) ≤ #α := mk_quot_le #align cardinal.mk_quotient_le Cardinal.mk_quotient_le theorem mk_subtype_le_of_subset {α : Type u} {p q : α → Prop} (h : ∀ ⦃x⦄, p x → q x) : #(Subtype p) ≤ #(Subtype q) := ⟨Embedding.subtypeMap (Embedding.refl α) h⟩ #align cardinal.mk_subtype_le_of_subset Cardinal.mk_subtype_le_of_subset -- porting note (#10618): simp can prove this -- @[simp] theorem mk_emptyCollection (α : Type u) : #(∅ : Set α) = 0 := mk_eq_zero _ #align cardinal.mk_emptyc Cardinal.mk_emptyCollection theorem mk_emptyCollection_iff {α : Type u} {s : Set α} : #s = 0 ↔ s = ∅ := by constructor · intro h rw [mk_eq_zero_iff] at h exact eq_empty_iff_forall_not_mem.2 fun x hx => h.elim' ⟨x, hx⟩ · rintro rfl exact mk_emptyCollection _ #align cardinal.mk_emptyc_iff Cardinal.mk_emptyCollection_iff @[simp] theorem mk_univ {α : Type u} : #(@univ α) = #α := mk_congr (Equiv.Set.univ α) #align cardinal.mk_univ Cardinal.mk_univ theorem mk_image_le {α β : Type u} {f : α → β} {s : Set α} : #(f '' s) ≤ #s := mk_le_of_surjective surjective_onto_image #align cardinal.mk_image_le Cardinal.mk_image_le theorem mk_image_le_lift {α : Type u} {β : Type v} {f : α → β} {s : Set α} : lift.{u} #(f '' s) ≤ lift.{v} #s := lift_mk_le.{0}.mpr ⟨Embedding.ofSurjective _ surjective_onto_image⟩ #align cardinal.mk_image_le_lift Cardinal.mk_image_le_lift theorem mk_range_le {α β : Type u} {f : α → β} : #(range f) ≤ #α := mk_le_of_surjective surjective_onto_range #align cardinal.mk_range_le Cardinal.mk_range_le theorem mk_range_le_lift {α : Type u} {β : Type v} {f : α → β} : lift.{u} #(range f) ≤ lift.{v} #α := lift_mk_le.{0}.mpr ⟨Embedding.ofSurjective _ surjective_onto_range⟩ #align cardinal.mk_range_le_lift Cardinal.mk_range_le_lift theorem mk_range_eq (f : α → β) (h : Injective f) : #(range f) = #α := mk_congr (Equiv.ofInjective f h).symm #align cardinal.mk_range_eq Cardinal.mk_range_eq theorem mk_range_eq_lift {α : Type u} {β : Type v} {f : α → β} (hf : Injective f) : lift.{max u w} #(range f) = lift.{max v w} #α := lift_mk_eq.{v,u,w}.mpr ⟨(Equiv.ofInjective f hf).symm⟩ #align cardinal.mk_range_eq_lift Cardinal.mk_range_eq_lift theorem mk_range_eq_of_injective {α : Type u} {β : Type v} {f : α → β} (hf : Injective f) : lift.{u} #(range f) = lift.{v} #α := lift_mk_eq'.mpr ⟨(Equiv.ofInjective f hf).symm⟩ #align cardinal.mk_range_eq_of_injective Cardinal.mk_range_eq_of_injective lemma lift_mk_le_lift_mk_of_injective {α : Type u} {β : Type v} {f : α → β} (hf : Injective f) : Cardinal.lift.{v} (#α) ≤ Cardinal.lift.{u} (#β) := by rw [← Cardinal.mk_range_eq_of_injective hf] exact Cardinal.lift_le.2 (Cardinal.mk_set_le _) lemma lift_mk_le_lift_mk_of_surjective {α : Type u} {β : Type v} {f : α → β} (hf : Surjective f) : Cardinal.lift.{u} (#β) ≤ Cardinal.lift.{v} (#α) := lift_mk_le_lift_mk_of_injective (injective_surjInv hf) theorem mk_image_eq_of_injOn {α β : Type u} (f : α → β) (s : Set α) (h : InjOn f s) : #(f '' s) = #s := mk_congr (Equiv.Set.imageOfInjOn f s h).symm #align cardinal.mk_image_eq_of_inj_on Cardinal.mk_image_eq_of_injOn theorem mk_image_eq_of_injOn_lift {α : Type u} {β : Type v} (f : α → β) (s : Set α) (h : InjOn f s) : lift.{u} #(f '' s) = lift.{v} #s := lift_mk_eq.{v, u, 0}.mpr ⟨(Equiv.Set.imageOfInjOn f s h).symm⟩ #align cardinal.mk_image_eq_of_inj_on_lift Cardinal.mk_image_eq_of_injOn_lift theorem mk_image_eq {α β : Type u} {f : α → β} {s : Set α} (hf : Injective f) : #(f '' s) = #s := mk_image_eq_of_injOn _ _ hf.injOn #align cardinal.mk_image_eq Cardinal.mk_image_eq theorem mk_image_eq_lift {α : Type u} {β : Type v} (f : α → β) (s : Set α) (h : Injective f) : lift.{u} #(f '' s) = lift.{v} #s := mk_image_eq_of_injOn_lift _ _ h.injOn #align cardinal.mk_image_eq_lift Cardinal.mk_image_eq_lift theorem mk_iUnion_le_sum_mk {α ι : Type u} {f : ι → Set α} : #(⋃ i, f i) ≤ sum fun i => #(f i) := calc #(⋃ i, f i) ≤ #(Σi, f i) := mk_le_of_surjective (Set.sigmaToiUnion_surjective f) _ = sum fun i => #(f i) := mk_sigma _ #align cardinal.mk_Union_le_sum_mk Cardinal.mk_iUnion_le_sum_mk theorem mk_iUnion_le_sum_mk_lift {α : Type u} {ι : Type v} {f : ι → Set α} : lift.{v} #(⋃ i, f i) ≤ sum fun i => #(f i) := calc lift.{v} #(⋃ i, f i) ≤ #(Σi, f i) := mk_le_of_surjective <| ULift.up_surjective.comp (Set.sigmaToiUnion_surjective f) _ = sum fun i => #(f i) := mk_sigma _ theorem mk_iUnion_eq_sum_mk {α ι : Type u} {f : ι → Set α} (h : Pairwise fun i j => Disjoint (f i) (f j)) : #(⋃ i, f i) = sum fun i => #(f i) := calc #(⋃ i, f i) = #(Σi, f i) := mk_congr (Set.unionEqSigmaOfDisjoint h) _ = sum fun i => #(f i) := mk_sigma _ #align cardinal.mk_Union_eq_sum_mk Cardinal.mk_iUnion_eq_sum_mk theorem mk_iUnion_eq_sum_mk_lift {α : Type u} {ι : Type v} {f : ι → Set α} (h : Pairwise fun i j => Disjoint (f i) (f j)) : lift.{v} #(⋃ i, f i) = sum fun i => #(f i) := calc lift.{v} #(⋃ i, f i) = #(Σi, f i) := mk_congr <| .trans Equiv.ulift (Set.unionEqSigmaOfDisjoint h) _ = sum fun i => #(f i) := mk_sigma _ theorem mk_iUnion_le {α ι : Type u} (f : ι → Set α) : #(⋃ i, f i) ≤ #ι * ⨆ i, #(f i) := mk_iUnion_le_sum_mk.trans (sum_le_iSup _) #align cardinal.mk_Union_le Cardinal.mk_iUnion_le theorem mk_iUnion_le_lift {α : Type u} {ι : Type v} (f : ι → Set α) : lift.{v} #(⋃ i, f i) ≤ lift.{u} #ι * ⨆ i, lift.{v} #(f i) := by refine mk_iUnion_le_sum_mk_lift.trans <| Eq.trans_le ?_ (sum_le_iSup_lift _) rw [← lift_sum, lift_id'.{_,u}] theorem mk_sUnion_le {α : Type u} (A : Set (Set α)) : #(⋃₀ A) ≤ #A * ⨆ s : A, #s := by rw [sUnion_eq_iUnion] apply mk_iUnion_le #align cardinal.mk_sUnion_le Cardinal.mk_sUnion_le theorem mk_biUnion_le {ι α : Type u} (A : ι → Set α) (s : Set ι) : #(⋃ x ∈ s, A x) ≤ #s * ⨆ x : s, #(A x.1) := by rw [biUnion_eq_iUnion] apply mk_iUnion_le #align cardinal.mk_bUnion_le Cardinal.mk_biUnion_le theorem mk_biUnion_le_lift {α : Type u} {ι : Type v} (A : ι → Set α) (s : Set ι) : lift.{v} #(⋃ x ∈ s, A x) ≤ lift.{u} #s * ⨆ x : s, lift.{v} #(A x.1) := by rw [biUnion_eq_iUnion] apply mk_iUnion_le_lift theorem finset_card_lt_aleph0 (s : Finset α) : #(↑s : Set α) < ℵ₀ := lt_aleph0_of_finite _ #align cardinal.finset_card_lt_aleph_0 Cardinal.finset_card_lt_aleph0 theorem mk_set_eq_nat_iff_finset {α} {s : Set α} {n : ℕ} : #s = n ↔ ∃ t : Finset α, (t : Set α) = s ∧ t.card = n := by constructor · intro h lift s to Finset α using lt_aleph0_iff_set_finite.1 (h.symm ▸ nat_lt_aleph0 n) simpa using h · rintro ⟨t, rfl, rfl⟩ exact mk_coe_finset #align cardinal.mk_set_eq_nat_iff_finset Cardinal.mk_set_eq_nat_iff_finset theorem mk_eq_nat_iff_finset {n : ℕ} : #α = n ↔ ∃ t : Finset α, (t : Set α) = univ ∧ t.card = n := by rw [← mk_univ, mk_set_eq_nat_iff_finset] #align cardinal.mk_eq_nat_iff_finset Cardinal.mk_eq_nat_iff_finset theorem mk_eq_nat_iff_fintype {n : ℕ} : #α = n ↔ ∃ h : Fintype α, @Fintype.card α h = n := by rw [mk_eq_nat_iff_finset] constructor · rintro ⟨t, ht, hn⟩ exact ⟨⟨t, eq_univ_iff_forall.1 ht⟩, hn⟩ · rintro ⟨⟨t, ht⟩, hn⟩ exact ⟨t, eq_univ_iff_forall.2 ht, hn⟩ #align cardinal.mk_eq_nat_iff_fintype Cardinal.mk_eq_nat_iff_fintype theorem mk_union_add_mk_inter {α : Type u} {S T : Set α} : #(S ∪ T : Set α) + #(S ∩ T : Set α) = #S + #T := Quot.sound ⟨Equiv.Set.unionSumInter S T⟩ #align cardinal.mk_union_add_mk_inter Cardinal.mk_union_add_mk_inter /-- The cardinality of a union is at most the sum of the cardinalities of the two sets. -/ theorem mk_union_le {α : Type u} (S T : Set α) : #(S ∪ T : Set α) ≤ #S + #T := @mk_union_add_mk_inter α S T ▸ self_le_add_right #(S ∪ T : Set α) #(S ∩ T : Set α) #align cardinal.mk_union_le Cardinal.mk_union_le theorem mk_union_of_disjoint {α : Type u} {S T : Set α} (H : Disjoint S T) : #(S ∪ T : Set α) = #S + #T := Quot.sound ⟨Equiv.Set.union H.le_bot⟩ #align cardinal.mk_union_of_disjoint Cardinal.mk_union_of_disjoint theorem mk_insert {α : Type u} {s : Set α} {a : α} (h : a ∉ s) : #(insert a s : Set α) = #s + 1 := by rw [← union_singleton, mk_union_of_disjoint, mk_singleton] simpa #align cardinal.mk_insert Cardinal.mk_insert theorem mk_insert_le {α : Type u} {s : Set α} {a : α} : #(insert a s : Set α) ≤ #s + 1 := by by_cases h : a ∈ s · simp only [insert_eq_of_mem h, self_le_add_right] · rw [mk_insert h] theorem mk_sum_compl {α} (s : Set α) : #s + #(sᶜ : Set α) = #α := mk_congr (Equiv.Set.sumCompl s) #align cardinal.mk_sum_compl Cardinal.mk_sum_compl theorem mk_le_mk_of_subset {α} {s t : Set α} (h : s ⊆ t) : #s ≤ #t := ⟨Set.embeddingOfSubset s t h⟩ #align cardinal.mk_le_mk_of_subset Cardinal.mk_le_mk_of_subset theorem mk_le_iff_forall_finset_subset_card_le {α : Type u} {n : ℕ} {t : Set α} : #t ≤ n ↔ ∀ s : Finset α, (s : Set α) ⊆ t → s.card ≤ n := by refine ⟨fun H s hs ↦ by simpa using (mk_le_mk_of_subset hs).trans H, fun H ↦ ?_⟩ apply card_le_of (fun s ↦ ?_) let u : Finset α := s.image Subtype.val have : u.card = s.card := Finset.card_image_of_injOn Subtype.coe_injective.injOn rw [← this] apply H simp only [u, Finset.coe_image, image_subset_iff, Subtype.coe_preimage_self, subset_univ] theorem mk_subtype_mono {p q : α → Prop} (h : ∀ x, p x → q x) : #{ x // p x } ≤ #{ x // q x } := ⟨embeddingOfSubset _ _ h⟩ #align cardinal.mk_subtype_mono Cardinal.mk_subtype_mono theorem le_mk_diff_add_mk (S T : Set α) : #S ≤ #(S \ T : Set α) + #T := (mk_le_mk_of_subset <| subset_diff_union _ _).trans <| mk_union_le _ _ #align cardinal.le_mk_diff_add_mk Cardinal.le_mk_diff_add_mk theorem mk_diff_add_mk {S T : Set α} (h : T ⊆ S) : #(S \ T : Set α) + #T = #S := by refine (mk_union_of_disjoint <| ?_).symm.trans <| by rw [diff_union_of_subset h] exact disjoint_sdiff_self_left #align cardinal.mk_diff_add_mk Cardinal.mk_diff_add_mk theorem mk_union_le_aleph0 {α} {P Q : Set α} : #(P ∪ Q : Set α) ≤ ℵ₀ ↔ #P ≤ ℵ₀ ∧ #Q ≤ ℵ₀ := by simp only [le_aleph0_iff_subtype_countable, mem_union, setOf_mem_eq, Set.union_def, ← countable_union] #align cardinal.mk_union_le_aleph_0 Cardinal.mk_union_le_aleph0 theorem mk_subtype_of_equiv {α β : Type u} (p : β → Prop) (e : α ≃ β) : #{ a : α // p (e a) } = #{ b : β // p b } := mk_congr (Equiv.subtypeEquivOfSubtype e) #align cardinal.mk_subtype_of_equiv Cardinal.mk_subtype_of_equiv theorem mk_sep (s : Set α) (t : α → Prop) : #({ x ∈ s | t x } : Set α) = #{ x : s | t x.1 } := mk_congr (Equiv.Set.sep s t) #align cardinal.mk_sep Cardinal.mk_sep theorem mk_preimage_of_injective_lift {α : Type u} {β : Type v} (f : α → β) (s : Set β) (h : Injective f) : lift.{v} #(f ⁻¹' s) ≤ lift.{u} #s := by rw [lift_mk_le.{0}] -- Porting note: Needed to insert `mem_preimage.mp` below use Subtype.coind (fun x => f x.1) fun x => mem_preimage.mp x.2 apply Subtype.coind_injective; exact h.comp Subtype.val_injective #align cardinal.mk_preimage_of_injective_lift Cardinal.mk_preimage_of_injective_lift theorem mk_preimage_of_subset_range_lift {α : Type u} {β : Type v} (f : α → β) (s : Set β) (h : s ⊆ range f) : lift.{u} #s ≤ lift.{v} #(f ⁻¹' s) := by rw [lift_mk_le.{0}] refine ⟨⟨?_, ?_⟩⟩ · rintro ⟨y, hy⟩ rcases Classical.subtype_of_exists (h hy) with ⟨x, rfl⟩ exact ⟨x, hy⟩ rintro ⟨y, hy⟩ ⟨y', hy'⟩; dsimp rcases Classical.subtype_of_exists (h hy) with ⟨x, rfl⟩ rcases Classical.subtype_of_exists (h hy') with ⟨x', rfl⟩ simp; intro hxx'; rw [hxx'] #align cardinal.mk_preimage_of_subset_range_lift Cardinal.mk_preimage_of_subset_range_lift theorem mk_preimage_of_injective_of_subset_range_lift {β : Type v} (f : α → β) (s : Set β) (h : Injective f) (h2 : s ⊆ range f) : lift.{v} #(f ⁻¹' s) = lift.{u} #s := le_antisymm (mk_preimage_of_injective_lift f s h) (mk_preimage_of_subset_range_lift f s h2) #align cardinal.mk_preimage_of_injective_of_subset_range_lift Cardinal.mk_preimage_of_injective_of_subset_range_lift theorem mk_preimage_of_injective_of_subset_range (f : α → β) (s : Set β) (h : Injective f) (h2 : s ⊆ range f) : #(f ⁻¹' s) = #s := by convert mk_preimage_of_injective_of_subset_range_lift.{u, u} f s h h2 using 1 <;> rw [lift_id] #align cardinal.mk_preimage_of_injective_of_subset_range Cardinal.mk_preimage_of_injective_of_subset_range theorem mk_preimage_of_injective (f : α → β) (s : Set β) (h : Injective f) : #(f ⁻¹' s) ≤ #s := by rw [← lift_id #(↑(f ⁻¹' s)), ← lift_id #(↑s)] exact mk_preimage_of_injective_lift f s h #align cardinal.mk_preimage_of_injective Cardinal.mk_preimage_of_injective theorem mk_preimage_of_subset_range (f : α → β) (s : Set β) (h : s ⊆ range f) : #s ≤ #(f ⁻¹' s) := by rw [← lift_id #(↑(f ⁻¹' s)), ← lift_id #(↑s)] exact mk_preimage_of_subset_range_lift f s h #align cardinal.mk_preimage_of_subset_range Cardinal.mk_preimage_of_subset_range theorem mk_subset_ge_of_subset_image_lift {α : Type u} {β : Type v} (f : α → β) {s : Set α} {t : Set β} (h : t ⊆ f '' s) : lift.{u} #t ≤ lift.{v} #({ x ∈ s | f x ∈ t } : Set α) := by rw [image_eq_range] at h convert mk_preimage_of_subset_range_lift _ _ h using 1 rw [mk_sep] rfl #align cardinal.mk_subset_ge_of_subset_image_lift Cardinal.mk_subset_ge_of_subset_image_lift theorem mk_subset_ge_of_subset_image (f : α → β) {s : Set α} {t : Set β} (h : t ⊆ f '' s) : #t ≤ #({ x ∈ s | f x ∈ t } : Set α) := by rw [image_eq_range] at h convert mk_preimage_of_subset_range _ _ h using 1 rw [mk_sep] rfl #align cardinal.mk_subset_ge_of_subset_image Cardinal.mk_subset_ge_of_subset_image theorem le_mk_iff_exists_subset {c : Cardinal} {α : Type u} {s : Set α} : c ≤ #s ↔ ∃ p : Set α, p ⊆ s ∧ #p = c := by rw [le_mk_iff_exists_set, ← Subtype.exists_set_subtype] apply exists_congr; intro t; rw [mk_image_eq]; apply Subtype.val_injective #align cardinal.le_mk_iff_exists_subset Cardinal.le_mk_iff_exists_subset theorem two_le_iff : (2 : Cardinal) ≤ #α ↔ ∃ x y : α, x ≠ y := by rw [← Nat.cast_two, nat_succ, succ_le_iff, Nat.cast_one, one_lt_iff_nontrivial, nontrivial_iff] #align cardinal.two_le_iff Cardinal.two_le_iff theorem two_le_iff' (x : α) : (2 : Cardinal) ≤ #α ↔ ∃ y : α, y ≠ x := by rw [two_le_iff, ← nontrivial_iff, nontrivial_iff_exists_ne x] #align cardinal.two_le_iff' Cardinal.two_le_iff' theorem mk_eq_two_iff : #α = 2 ↔ ∃ x y : α, x ≠ y ∧ ({x, y} : Set α) = univ := by simp only [← @Nat.cast_two Cardinal, mk_eq_nat_iff_finset, Finset.card_eq_two] constructor · rintro ⟨t, ht, x, y, hne, rfl⟩ exact ⟨x, y, hne, by simpa using ht⟩ · rintro ⟨x, y, hne, h⟩ exact ⟨{x, y}, by simpa using h, x, y, hne, rfl⟩ #align cardinal.mk_eq_two_iff Cardinal.mk_eq_two_iff
Mathlib/SetTheory/Cardinal/Basic.lean
2,254
2,261
theorem mk_eq_two_iff' (x : α) : #α = 2 ↔ ∃! y, y ≠ x := by
rw [mk_eq_two_iff]; constructor · rintro ⟨a, b, hne, h⟩ simp only [eq_univ_iff_forall, mem_insert_iff, mem_singleton_iff] at h rcases h x with (rfl | rfl) exacts [⟨b, hne.symm, fun z => (h z).resolve_left⟩, ⟨a, hne, fun z => (h z).resolve_right⟩] · rintro ⟨y, hne, hy⟩ exact ⟨x, y, hne.symm, eq_univ_of_forall fun z => or_iff_not_imp_left.2 (hy z)⟩
/- Copyright (c) 2022 Joël Riou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joël Riou -/ import Mathlib.Algebra.Homology.Homotopy import Mathlib.AlgebraicTopology.DoldKan.Notations #align_import algebraic_topology.dold_kan.homotopies from "leanprover-community/mathlib"@"b12099d3b7febf4209824444dd836ef5ad96db55" /-! # Construction of homotopies for the Dold-Kan correspondence (The general strategy of proof of the Dold-Kan correspondence is explained in `Equivalence.lean`.) The purpose of the files `Homotopies.lean`, `Faces.lean`, `Projections.lean` and `PInfty.lean` is to construct an idempotent endomorphism `PInfty : K[X] ⟶ K[X]` of the alternating face map complex for each `X : SimplicialObject C` when `C` is a preadditive category. In the case `C` is abelian, this `PInfty` shall be the projection on the normalized Moore subcomplex of `K[X]` associated to the decomposition of the complex `K[X]` as a direct sum of this normalized subcomplex and of the degenerate subcomplex. In `PInfty.lean`, this endomorphism `PInfty` shall be obtained by passing to the limit idempotent endomorphisms `P q` for all `(q : ℕ)`. These endomorphisms `P q` are defined by induction. The idea is to start from the identity endomorphism `P 0` of `K[X]` and to ensure by induction that the `q` higher face maps (except $d_0$) vanish on the image of `P q`. Then, in a certain degree `n`, the image of `P q` for a big enough `q` will be contained in the normalized subcomplex. This construction is done in `Projections.lean`. It would be easy to define the `P q` degreewise (similarly as it is done in *Simplicial Homotopy Theory* by Goerrs-Jardine p. 149), but then we would have to prove that they are compatible with the differential (i.e. they are chain complex maps), and also that they are homotopic to the identity. These two verifications are quite technical. In order to reduce the number of such technical lemmas, the strategy that is followed here is to define a series of null homotopic maps `Hσ q` (attached to families of maps `hσ`) and use these in order to construct `P q` : the endomorphisms `P q` shall basically be obtained by altering the identity endomorphism by adding null homotopic maps, so that we get for free that they are morphisms of chain complexes and that they are homotopic to the identity. The most technical verifications that are needed about the null homotopic maps `Hσ` are obtained in `Faces.lean`. In this file `Homotopies.lean`, we define the null homotopic maps `Hσ q : K[X] ⟶ K[X]`, show that they are natural (see `natTransHσ`) and compatible the application of additive functors (see `map_Hσ`). ## References * [Albrecht Dold, *Homology of Symmetric Products and Other Functors of Complexes*][dold1958] * [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009] -/ open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive CategoryTheory.SimplicialObject Homotopy Opposite Simplicial DoldKan noncomputable section namespace AlgebraicTopology namespace DoldKan variable {C : Type*} [Category C] [Preadditive C] variable {X : SimplicialObject C} /-- As we are using chain complexes indexed by `ℕ`, we shall need the relation `c` such `c m n` if and only if `n+1=m`. -/ abbrev c := ComplexShape.down ℕ #align algebraic_topology.dold_kan.c AlgebraicTopology.DoldKan.c /-- Helper when we need some `c.rel i j` (i.e. `ComplexShape.down ℕ`), e.g. `c_mk n (n+1) rfl` -/ theorem c_mk (i j : ℕ) (h : j + 1 = i) : c.Rel i j := ComplexShape.down_mk i j h #align algebraic_topology.dold_kan.c_mk AlgebraicTopology.DoldKan.c_mk /-- This lemma is meant to be used with `nullHomotopicMap'_f_of_not_rel_left` -/ theorem cs_down_0_not_rel_left (j : ℕ) : ¬c.Rel 0 j := by intro hj dsimp at hj apply Nat.not_succ_le_zero j rw [Nat.succ_eq_add_one, hj] #align algebraic_topology.dold_kan.cs_down_0_not_rel_left AlgebraicTopology.DoldKan.cs_down_0_not_rel_left /-- The sequence of maps which gives the null homotopic maps `Hσ` that shall be in the inductive construction of the projections `P q : K[X] ⟶ K[X]` -/ def hσ (q : ℕ) (n : ℕ) : X _[n] ⟶ X _[n + 1] := if n < q then 0 else (-1 : ℤ) ^ (n - q) • X.σ ⟨n - q, Nat.lt_succ_of_le (Nat.sub_le _ _)⟩ #align algebraic_topology.dold_kan.hσ AlgebraicTopology.DoldKan.hσ /-- We can turn `hσ` into a datum that can be passed to `nullHomotopicMap'`. -/ def hσ' (q : ℕ) : ∀ n m, c.Rel m n → (K[X].X n ⟶ K[X].X m) := fun n m hnm => hσ q n ≫ eqToHom (by congr) #align algebraic_topology.dold_kan.hσ' AlgebraicTopology.DoldKan.hσ'
Mathlib/AlgebraicTopology/DoldKan/Homotopies.lean
104
108
theorem hσ'_eq_zero {q n m : ℕ} (hnq : n < q) (hnm : c.Rel m n) : (hσ' q n m hnm : X _[n] ⟶ X _[m]) = 0 := by
simp only [hσ', hσ] split_ifs exact zero_comp
/- Copyright (c) 2021 Scott Morrison. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Scott Morrison -/ import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor import Mathlib.CategoryTheory.Linear.Basic #align_import category_theory.linear.linear_functor from "leanprover-community/mathlib"@"829895f162a1f29d0133f4b3538f4cd1fb5bffd3" /-! # Linear Functors An additive functor between two `R`-linear categories is called *linear* if the induced map on hom types is a morphism of `R`-modules. # Implementation details `Functor.Linear` is a `Prop`-valued class, defined by saying that for every two objects `X` and `Y`, the map `F.map : (X ⟶ Y) → (F.obj X ⟶ F.obj Y)` is a morphism of `R`-modules. -/ namespace CategoryTheory variable (R : Type*) [Semiring R] /-- An additive functor `F` is `R`-linear provided `F.map` is an `R`-module morphism. -/ class Functor.Linear {C D : Type*} [Category C] [Category D] [Preadditive C] [Preadditive D] [Linear R C] [Linear R D] (F : C ⥤ D) [F.Additive] : Prop where /-- the functor induces a linear map on morphisms -/ map_smul : ∀ {X Y : C} (f : X ⟶ Y) (r : R), F.map (r • f) = r • F.map f := by aesop_cat #align category_theory.functor.linear CategoryTheory.Functor.Linear section Linear namespace Functor section variable {R} variable {C D : Type*} [Category C] [Category D] [Preadditive C] [Preadditive D] [CategoryTheory.Linear R C] [CategoryTheory.Linear R D] (F : C ⥤ D) [Additive F] [Linear R F] @[simp] theorem map_smul {X Y : C} (r : R) (f : X ⟶ Y) : F.map (r • f) = r • F.map f := Functor.Linear.map_smul _ _ #align category_theory.functor.map_smul CategoryTheory.Functor.map_smul @[simp]
Mathlib/CategoryTheory/Linear/LinearFunctor.lean
53
54
theorem map_units_smul {X Y : C} (r : Rˣ) (f : X ⟶ Y) : F.map (r • f) = r • F.map f := by
apply map_smul
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl -/ import Mathlib.Data.Bool.Set import Mathlib.Data.Nat.Set import Mathlib.Data.Set.Prod import Mathlib.Data.ULift import Mathlib.Order.Bounds.Basic import Mathlib.Order.Hom.Set import Mathlib.Order.SetNotation #align_import order.complete_lattice from "leanprover-community/mathlib"@"5709b0d8725255e76f47debca6400c07b5c2d8e6" /-! # Theory of complete lattices ## Main definitions * `sSup` and `sInf` are the supremum and the infimum of a set; * `iSup (f : ι → α)` and `iInf (f : ι → α)` are indexed supremum and infimum of a function, defined as `sSup` and `sInf` of the range of this function; * class `CompleteLattice`: a bounded lattice such that `sSup s` is always the least upper boundary of `s` and `sInf s` is always the greatest lower boundary of `s`; * class `CompleteLinearOrder`: a linear ordered complete lattice. ## Naming conventions In lemma names, * `sSup` is called `sSup` * `sInf` is called `sInf` * `⨆ i, s i` is called `iSup` * `⨅ i, s i` is called `iInf` * `⨆ i j, s i j` is called `iSup₂`. This is an `iSup` inside an `iSup`. * `⨅ i j, s i j` is called `iInf₂`. This is an `iInf` inside an `iInf`. * `⨆ i ∈ s, t i` is called `biSup` for "bounded `iSup`". This is the special case of `iSup₂` where `j : i ∈ s`. * `⨅ i ∈ s, t i` is called `biInf` for "bounded `iInf`". This is the special case of `iInf₂` where `j : i ∈ s`. ## Notation * `⨆ i, f i` : `iSup f`, the supremum of the range of `f`; * `⨅ i, f i` : `iInf f`, the infimum of the range of `f`. -/ open Function OrderDual Set variable {α β β₂ γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*} instance OrderDual.supSet (α) [InfSet α] : SupSet αᵒᵈ := ⟨(sInf : Set α → α)⟩ instance OrderDual.infSet (α) [SupSet α] : InfSet αᵒᵈ := ⟨(sSup : Set α → α)⟩ /-- Note that we rarely use `CompleteSemilatticeSup` (in fact, any such object is always a `CompleteLattice`, so it's usually best to start there). Nevertheless it is sometimes a useful intermediate step in constructions. -/ class CompleteSemilatticeSup (α : Type*) extends PartialOrder α, SupSet α where /-- Any element of a set is less than the set supremum. -/ le_sSup : ∀ s, ∀ a ∈ s, a ≤ sSup s /-- Any upper bound is more than the set supremum. -/ sSup_le : ∀ s a, (∀ b ∈ s, b ≤ a) → sSup s ≤ a #align complete_semilattice_Sup CompleteSemilatticeSup section variable [CompleteSemilatticeSup α] {s t : Set α} {a b : α} theorem le_sSup : a ∈ s → a ≤ sSup s := CompleteSemilatticeSup.le_sSup s a #align le_Sup le_sSup theorem sSup_le : (∀ b ∈ s, b ≤ a) → sSup s ≤ a := CompleteSemilatticeSup.sSup_le s a #align Sup_le sSup_le theorem isLUB_sSup (s : Set α) : IsLUB s (sSup s) := ⟨fun _ ↦ le_sSup, fun _ ↦ sSup_le⟩ #align is_lub_Sup isLUB_sSup lemma isLUB_iff_sSup_eq : IsLUB s a ↔ sSup s = a := ⟨(isLUB_sSup s).unique, by rintro rfl; exact isLUB_sSup _⟩ alias ⟨IsLUB.sSup_eq, _⟩ := isLUB_iff_sSup_eq #align is_lub.Sup_eq IsLUB.sSup_eq theorem le_sSup_of_le (hb : b ∈ s) (h : a ≤ b) : a ≤ sSup s := le_trans h (le_sSup hb) #align le_Sup_of_le le_sSup_of_le @[gcongr] theorem sSup_le_sSup (h : s ⊆ t) : sSup s ≤ sSup t := (isLUB_sSup s).mono (isLUB_sSup t) h #align Sup_le_Sup sSup_le_sSup @[simp] theorem sSup_le_iff : sSup s ≤ a ↔ ∀ b ∈ s, b ≤ a := isLUB_le_iff (isLUB_sSup s) #align Sup_le_iff sSup_le_iff theorem le_sSup_iff : a ≤ sSup s ↔ ∀ b ∈ upperBounds s, a ≤ b := ⟨fun h _ hb => le_trans h (sSup_le hb), fun hb => hb _ fun _ => le_sSup⟩ #align le_Sup_iff le_sSup_iff theorem le_iSup_iff {s : ι → α} : a ≤ iSup s ↔ ∀ b, (∀ i, s i ≤ b) → a ≤ b := by simp [iSup, le_sSup_iff, upperBounds] #align le_supr_iff le_iSup_iff theorem sSup_le_sSup_of_forall_exists_le (h : ∀ x ∈ s, ∃ y ∈ t, x ≤ y) : sSup s ≤ sSup t := le_sSup_iff.2 fun _ hb => sSup_le fun a ha => let ⟨_, hct, hac⟩ := h a ha hac.trans (hb hct) #align Sup_le_Sup_of_forall_exists_le sSup_le_sSup_of_forall_exists_le -- We will generalize this to conditionally complete lattices in `csSup_singleton`. theorem sSup_singleton {a : α} : sSup {a} = a := isLUB_singleton.sSup_eq #align Sup_singleton sSup_singleton end /-- Note that we rarely use `CompleteSemilatticeInf` (in fact, any such object is always a `CompleteLattice`, so it's usually best to start there). Nevertheless it is sometimes a useful intermediate step in constructions. -/ class CompleteSemilatticeInf (α : Type*) extends PartialOrder α, InfSet α where /-- Any element of a set is more than the set infimum. -/ sInf_le : ∀ s, ∀ a ∈ s, sInf s ≤ a /-- Any lower bound is less than the set infimum. -/ le_sInf : ∀ s a, (∀ b ∈ s, a ≤ b) → a ≤ sInf s #align complete_semilattice_Inf CompleteSemilatticeInf section variable [CompleteSemilatticeInf α] {s t : Set α} {a b : α} theorem sInf_le : a ∈ s → sInf s ≤ a := CompleteSemilatticeInf.sInf_le s a #align Inf_le sInf_le theorem le_sInf : (∀ b ∈ s, a ≤ b) → a ≤ sInf s := CompleteSemilatticeInf.le_sInf s a #align le_Inf le_sInf theorem isGLB_sInf (s : Set α) : IsGLB s (sInf s) := ⟨fun _ => sInf_le, fun _ => le_sInf⟩ #align is_glb_Inf isGLB_sInf lemma isGLB_iff_sInf_eq : IsGLB s a ↔ sInf s = a := ⟨(isGLB_sInf s).unique, by rintro rfl; exact isGLB_sInf _⟩ alias ⟨IsGLB.sInf_eq, _⟩ := isGLB_iff_sInf_eq #align is_glb.Inf_eq IsGLB.sInf_eq theorem sInf_le_of_le (hb : b ∈ s) (h : b ≤ a) : sInf s ≤ a := le_trans (sInf_le hb) h #align Inf_le_of_le sInf_le_of_le @[gcongr] theorem sInf_le_sInf (h : s ⊆ t) : sInf t ≤ sInf s := (isGLB_sInf s).mono (isGLB_sInf t) h #align Inf_le_Inf sInf_le_sInf @[simp] theorem le_sInf_iff : a ≤ sInf s ↔ ∀ b ∈ s, a ≤ b := le_isGLB_iff (isGLB_sInf s) #align le_Inf_iff le_sInf_iff theorem sInf_le_iff : sInf s ≤ a ↔ ∀ b ∈ lowerBounds s, b ≤ a := ⟨fun h _ hb => le_trans (le_sInf hb) h, fun hb => hb _ fun _ => sInf_le⟩ #align Inf_le_iff sInf_le_iff theorem iInf_le_iff {s : ι → α} : iInf s ≤ a ↔ ∀ b, (∀ i, b ≤ s i) → b ≤ a := by simp [iInf, sInf_le_iff, lowerBounds] #align infi_le_iff iInf_le_iff theorem sInf_le_sInf_of_forall_exists_le (h : ∀ x ∈ s, ∃ y ∈ t, y ≤ x) : sInf t ≤ sInf s := le_sInf fun x hx ↦ let ⟨_y, hyt, hyx⟩ := h x hx; sInf_le_of_le hyt hyx #align Inf_le_Inf_of_forall_exists_le sInf_le_sInf_of_forall_exists_le -- We will generalize this to conditionally complete lattices in `csInf_singleton`. theorem sInf_singleton {a : α} : sInf {a} = a := isGLB_singleton.sInf_eq #align Inf_singleton sInf_singleton end /-- A complete lattice is a bounded lattice which has suprema and infima for every subset. -/ class CompleteLattice (α : Type*) extends Lattice α, CompleteSemilatticeSup α, CompleteSemilatticeInf α, Top α, Bot α where /-- Any element is less than the top one. -/ protected le_top : ∀ x : α, x ≤ ⊤ /-- Any element is more than the bottom one. -/ protected bot_le : ∀ x : α, ⊥ ≤ x #align complete_lattice CompleteLattice -- see Note [lower instance priority] instance (priority := 100) CompleteLattice.toBoundedOrder [h : CompleteLattice α] : BoundedOrder α := { h with } #align complete_lattice.to_bounded_order CompleteLattice.toBoundedOrder /-- Create a `CompleteLattice` from a `PartialOrder` and `InfSet` that returns the greatest lower bound of a set. Usually this constructor provides poor definitional equalities. If other fields are known explicitly, they should be provided; for example, if `inf` is known explicitly, construct the `CompleteLattice` instance as ``` instance : CompleteLattice my_T where inf := better_inf le_inf := ... inf_le_right := ... inf_le_left := ... -- don't care to fix sup, sSup, bot, top __ := completeLatticeOfInf my_T _ ``` -/ def completeLatticeOfInf (α : Type*) [H1 : PartialOrder α] [H2 : InfSet α] (isGLB_sInf : ∀ s : Set α, IsGLB s (sInf s)) : CompleteLattice α where __ := H1; __ := H2 bot := sInf univ bot_le x := (isGLB_sInf univ).1 trivial top := sInf ∅ le_top a := (isGLB_sInf ∅).2 <| by simp sup a b := sInf { x : α | a ≤ x ∧ b ≤ x } inf a b := sInf {a, b} le_inf a b c hab hac := by apply (isGLB_sInf _).2 simp [*] inf_le_right a b := (isGLB_sInf _).1 <| mem_insert_of_mem _ <| mem_singleton _ inf_le_left a b := (isGLB_sInf _).1 <| mem_insert _ _ sup_le a b c hac hbc := (isGLB_sInf _).1 <| by simp [*] le_sup_left a b := (isGLB_sInf _).2 fun x => And.left le_sup_right a b := (isGLB_sInf _).2 fun x => And.right le_sInf s a ha := (isGLB_sInf s).2 ha sInf_le s a ha := (isGLB_sInf s).1 ha sSup s := sInf (upperBounds s) le_sSup s a ha := (isGLB_sInf (upperBounds s)).2 fun b hb => hb ha sSup_le s a ha := (isGLB_sInf (upperBounds s)).1 ha #align complete_lattice_of_Inf completeLatticeOfInf /-- Any `CompleteSemilatticeInf` is in fact a `CompleteLattice`. Note that this construction has bad definitional properties: see the doc-string on `completeLatticeOfInf`. -/ def completeLatticeOfCompleteSemilatticeInf (α : Type*) [CompleteSemilatticeInf α] : CompleteLattice α := completeLatticeOfInf α fun s => isGLB_sInf s #align complete_lattice_of_complete_semilattice_Inf completeLatticeOfCompleteSemilatticeInf /-- Create a `CompleteLattice` from a `PartialOrder` and `SupSet` that returns the least upper bound of a set. Usually this constructor provides poor definitional equalities. If other fields are known explicitly, they should be provided; for example, if `inf` is known explicitly, construct the `CompleteLattice` instance as ``` instance : CompleteLattice my_T where inf := better_inf le_inf := ... inf_le_right := ... inf_le_left := ... -- don't care to fix sup, sInf, bot, top __ := completeLatticeOfSup my_T _ ``` -/ def completeLatticeOfSup (α : Type*) [H1 : PartialOrder α] [H2 : SupSet α] (isLUB_sSup : ∀ s : Set α, IsLUB s (sSup s)) : CompleteLattice α where __ := H1; __ := H2 top := sSup univ le_top x := (isLUB_sSup univ).1 trivial bot := sSup ∅ bot_le x := (isLUB_sSup ∅).2 <| by simp sup a b := sSup {a, b} sup_le a b c hac hbc := (isLUB_sSup _).2 (by simp [*]) le_sup_left a b := (isLUB_sSup _).1 <| mem_insert _ _ le_sup_right a b := (isLUB_sSup _).1 <| mem_insert_of_mem _ <| mem_singleton _ inf a b := sSup { x | x ≤ a ∧ x ≤ b } le_inf a b c hab hac := (isLUB_sSup _).1 <| by simp [*] inf_le_left a b := (isLUB_sSup _).2 fun x => And.left inf_le_right a b := (isLUB_sSup _).2 fun x => And.right sInf s := sSup (lowerBounds s) sSup_le s a ha := (isLUB_sSup s).2 ha le_sSup s a ha := (isLUB_sSup s).1 ha sInf_le s a ha := (isLUB_sSup (lowerBounds s)).2 fun b hb => hb ha le_sInf s a ha := (isLUB_sSup (lowerBounds s)).1 ha #align complete_lattice_of_Sup completeLatticeOfSup /-- Any `CompleteSemilatticeSup` is in fact a `CompleteLattice`. Note that this construction has bad definitional properties: see the doc-string on `completeLatticeOfSup`. -/ def completeLatticeOfCompleteSemilatticeSup (α : Type*) [CompleteSemilatticeSup α] : CompleteLattice α := completeLatticeOfSup α fun s => isLUB_sSup s #align complete_lattice_of_complete_semilattice_Sup completeLatticeOfCompleteSemilatticeSup -- Porting note: as we cannot rename fields while extending, -- `CompleteLinearOrder` does not directly extend `LinearOrder`. -- Instead we add the fields by hand, and write a manual instance. /-- A complete linear order is a linear order whose lattice structure is complete. -/ class CompleteLinearOrder (α : Type*) extends CompleteLattice α where /-- A linear order is total. -/ le_total (a b : α) : a ≤ b ∨ b ≤ a /-- In a linearly ordered type, we assume the order relations are all decidable. -/ decidableLE : DecidableRel (· ≤ · : α → α → Prop) /-- In a linearly ordered type, we assume the order relations are all decidable. -/ decidableEq : DecidableEq α := @decidableEqOfDecidableLE _ _ decidableLE /-- In a linearly ordered type, we assume the order relations are all decidable. -/ decidableLT : DecidableRel (· < · : α → α → Prop) := @decidableLTOfDecidableLE _ _ decidableLE #align complete_linear_order CompleteLinearOrder instance CompleteLinearOrder.toLinearOrder [i : CompleteLinearOrder α] : LinearOrder α where __ := i min := Inf.inf max := Sup.sup min_def a b := by split_ifs with h · simp [h] · simp [(CompleteLinearOrder.le_total a b).resolve_left h] max_def a b := by split_ifs with h · simp [h] · simp [(CompleteLinearOrder.le_total a b).resolve_left h] namespace OrderDual instance instCompleteLattice [CompleteLattice α] : CompleteLattice αᵒᵈ where __ := instBoundedOrder α le_sSup := @CompleteLattice.sInf_le α _ sSup_le := @CompleteLattice.le_sInf α _ sInf_le := @CompleteLattice.le_sSup α _ le_sInf := @CompleteLattice.sSup_le α _ instance instCompleteLinearOrder [CompleteLinearOrder α] : CompleteLinearOrder αᵒᵈ where __ := instCompleteLattice __ := instLinearOrder α end OrderDual open OrderDual section variable [CompleteLattice α] {s t : Set α} {a b : α} @[simp] theorem toDual_sSup (s : Set α) : toDual (sSup s) = sInf (ofDual ⁻¹' s) := rfl #align to_dual_Sup toDual_sSup @[simp] theorem toDual_sInf (s : Set α) : toDual (sInf s) = sSup (ofDual ⁻¹' s) := rfl #align to_dual_Inf toDual_sInf @[simp] theorem ofDual_sSup (s : Set αᵒᵈ) : ofDual (sSup s) = sInf (toDual ⁻¹' s) := rfl #align of_dual_Sup ofDual_sSup @[simp] theorem ofDual_sInf (s : Set αᵒᵈ) : ofDual (sInf s) = sSup (toDual ⁻¹' s) := rfl #align of_dual_Inf ofDual_sInf @[simp] theorem toDual_iSup (f : ι → α) : toDual (⨆ i, f i) = ⨅ i, toDual (f i) := rfl #align to_dual_supr toDual_iSup @[simp] theorem toDual_iInf (f : ι → α) : toDual (⨅ i, f i) = ⨆ i, toDual (f i) := rfl #align to_dual_infi toDual_iInf @[simp] theorem ofDual_iSup (f : ι → αᵒᵈ) : ofDual (⨆ i, f i) = ⨅ i, ofDual (f i) := rfl #align of_dual_supr ofDual_iSup @[simp] theorem ofDual_iInf (f : ι → αᵒᵈ) : ofDual (⨅ i, f i) = ⨆ i, ofDual (f i) := rfl #align of_dual_infi ofDual_iInf theorem sInf_le_sSup (hs : s.Nonempty) : sInf s ≤ sSup s := isGLB_le_isLUB (isGLB_sInf s) (isLUB_sSup s) hs #align Inf_le_Sup sInf_le_sSup theorem sSup_union {s t : Set α} : sSup (s ∪ t) = sSup s ⊔ sSup t := ((isLUB_sSup s).union (isLUB_sSup t)).sSup_eq #align Sup_union sSup_union theorem sInf_union {s t : Set α} : sInf (s ∪ t) = sInf s ⊓ sInf t := ((isGLB_sInf s).union (isGLB_sInf t)).sInf_eq #align Inf_union sInf_union theorem sSup_inter_le {s t : Set α} : sSup (s ∩ t) ≤ sSup s ⊓ sSup t := sSup_le fun _ hb => le_inf (le_sSup hb.1) (le_sSup hb.2) #align Sup_inter_le sSup_inter_le theorem le_sInf_inter {s t : Set α} : sInf s ⊔ sInf t ≤ sInf (s ∩ t) := @sSup_inter_le αᵒᵈ _ _ _ #align le_Inf_inter le_sInf_inter @[simp] theorem sSup_empty : sSup ∅ = (⊥ : α) := (@isLUB_empty α _ _).sSup_eq #align Sup_empty sSup_empty @[simp] theorem sInf_empty : sInf ∅ = (⊤ : α) := (@isGLB_empty α _ _).sInf_eq #align Inf_empty sInf_empty @[simp] theorem sSup_univ : sSup univ = (⊤ : α) := (@isLUB_univ α _ _).sSup_eq #align Sup_univ sSup_univ @[simp] theorem sInf_univ : sInf univ = (⊥ : α) := (@isGLB_univ α _ _).sInf_eq #align Inf_univ sInf_univ -- TODO(Jeremy): get this automatically @[simp] theorem sSup_insert {a : α} {s : Set α} : sSup (insert a s) = a ⊔ sSup s := ((isLUB_sSup s).insert a).sSup_eq #align Sup_insert sSup_insert @[simp] theorem sInf_insert {a : α} {s : Set α} : sInf (insert a s) = a ⊓ sInf s := ((isGLB_sInf s).insert a).sInf_eq #align Inf_insert sInf_insert theorem sSup_le_sSup_of_subset_insert_bot (h : s ⊆ insert ⊥ t) : sSup s ≤ sSup t := (sSup_le_sSup h).trans_eq (sSup_insert.trans (bot_sup_eq _)) #align Sup_le_Sup_of_subset_insert_bot sSup_le_sSup_of_subset_insert_bot theorem sInf_le_sInf_of_subset_insert_top (h : s ⊆ insert ⊤ t) : sInf t ≤ sInf s := (sInf_le_sInf h).trans_eq' (sInf_insert.trans (top_inf_eq _)).symm #align Inf_le_Inf_of_subset_insert_top sInf_le_sInf_of_subset_insert_top @[simp] theorem sSup_diff_singleton_bot (s : Set α) : sSup (s \ {⊥}) = sSup s := (sSup_le_sSup diff_subset).antisymm <| sSup_le_sSup_of_subset_insert_bot <| subset_insert_diff_singleton _ _ #align Sup_diff_singleton_bot sSup_diff_singleton_bot @[simp] theorem sInf_diff_singleton_top (s : Set α) : sInf (s \ {⊤}) = sInf s := @sSup_diff_singleton_bot αᵒᵈ _ s #align Inf_diff_singleton_top sInf_diff_singleton_top theorem sSup_pair {a b : α} : sSup {a, b} = a ⊔ b := (@isLUB_pair α _ a b).sSup_eq #align Sup_pair sSup_pair theorem sInf_pair {a b : α} : sInf {a, b} = a ⊓ b := (@isGLB_pair α _ a b).sInf_eq #align Inf_pair sInf_pair @[simp] theorem sSup_eq_bot : sSup s = ⊥ ↔ ∀ a ∈ s, a = ⊥ := ⟨fun h _ ha => bot_unique <| h ▸ le_sSup ha, fun h => bot_unique <| sSup_le fun a ha => le_bot_iff.2 <| h a ha⟩ #align Sup_eq_bot sSup_eq_bot @[simp] theorem sInf_eq_top : sInf s = ⊤ ↔ ∀ a ∈ s, a = ⊤ := @sSup_eq_bot αᵒᵈ _ _ #align Inf_eq_top sInf_eq_top theorem eq_singleton_bot_of_sSup_eq_bot_of_nonempty {s : Set α} (h_sup : sSup s = ⊥) (hne : s.Nonempty) : s = {⊥} := by rw [Set.eq_singleton_iff_nonempty_unique_mem] rw [sSup_eq_bot] at h_sup exact ⟨hne, h_sup⟩ #align eq_singleton_bot_of_Sup_eq_bot_of_nonempty eq_singleton_bot_of_sSup_eq_bot_of_nonempty theorem eq_singleton_top_of_sInf_eq_top_of_nonempty : sInf s = ⊤ → s.Nonempty → s = {⊤} := @eq_singleton_bot_of_sSup_eq_bot_of_nonempty αᵒᵈ _ _ #align eq_singleton_top_of_Inf_eq_top_of_nonempty eq_singleton_top_of_sInf_eq_top_of_nonempty /-- Introduction rule to prove that `b` is the supremum of `s`: it suffices to check that `b` is larger than all elements of `s`, and that this is not the case of any `w < b`. See `csSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in conditionally complete lattices. -/ theorem sSup_eq_of_forall_le_of_forall_lt_exists_gt (h₁ : ∀ a ∈ s, a ≤ b) (h₂ : ∀ w, w < b → ∃ a ∈ s, w < a) : sSup s = b := (sSup_le h₁).eq_of_not_lt fun h => let ⟨_, ha, ha'⟩ := h₂ _ h ((le_sSup ha).trans_lt ha').false #align Sup_eq_of_forall_le_of_forall_lt_exists_gt sSup_eq_of_forall_le_of_forall_lt_exists_gt /-- Introduction rule to prove that `b` is the infimum of `s`: it suffices to check that `b` is smaller than all elements of `s`, and that this is not the case of any `w > b`. See `csInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in conditionally complete lattices. -/ theorem sInf_eq_of_forall_ge_of_forall_gt_exists_lt : (∀ a ∈ s, b ≤ a) → (∀ w, b < w → ∃ a ∈ s, a < w) → sInf s = b := @sSup_eq_of_forall_le_of_forall_lt_exists_gt αᵒᵈ _ _ _ #align Inf_eq_of_forall_ge_of_forall_gt_exists_lt sInf_eq_of_forall_ge_of_forall_gt_exists_lt end section CompleteLinearOrder variable [CompleteLinearOrder α] {s t : Set α} {a b : α} theorem lt_sSup_iff : b < sSup s ↔ ∃ a ∈ s, b < a := lt_isLUB_iff <| isLUB_sSup s #align lt_Sup_iff lt_sSup_iff theorem sInf_lt_iff : sInf s < b ↔ ∃ a ∈ s, a < b := isGLB_lt_iff <| isGLB_sInf s #align Inf_lt_iff sInf_lt_iff theorem sSup_eq_top : sSup s = ⊤ ↔ ∀ b < ⊤, ∃ a ∈ s, b < a := ⟨fun h _ hb => lt_sSup_iff.1 <| hb.trans_eq h.symm, fun h => top_unique <| le_of_not_gt fun h' => let ⟨_, ha, h⟩ := h _ h' (h.trans_le <| le_sSup ha).false⟩ #align Sup_eq_top sSup_eq_top theorem sInf_eq_bot : sInf s = ⊥ ↔ ∀ b > ⊥, ∃ a ∈ s, a < b := @sSup_eq_top αᵒᵈ _ _ #align Inf_eq_bot sInf_eq_bot theorem lt_iSup_iff {f : ι → α} : a < iSup f ↔ ∃ i, a < f i := lt_sSup_iff.trans exists_range_iff #align lt_supr_iff lt_iSup_iff theorem iInf_lt_iff {f : ι → α} : iInf f < a ↔ ∃ i, f i < a := sInf_lt_iff.trans exists_range_iff #align infi_lt_iff iInf_lt_iff end CompleteLinearOrder /- ### iSup & iInf -/ section SupSet variable [SupSet α] {f g : ι → α} theorem sSup_range : sSup (range f) = iSup f := rfl #align Sup_range sSup_range theorem sSup_eq_iSup' (s : Set α) : sSup s = ⨆ a : s, (a : α) := by rw [iSup, Subtype.range_coe] #align Sup_eq_supr' sSup_eq_iSup' theorem iSup_congr (h : ∀ i, f i = g i) : ⨆ i, f i = ⨆ i, g i := congr_arg _ <| funext h #align supr_congr iSup_congr theorem biSup_congr {p : ι → Prop} (h : ∀ i, p i → f i = g i) : ⨆ (i) (_ : p i), f i = ⨆ (i) (_ : p i), g i := iSup_congr fun i ↦ iSup_congr (h i) theorem biSup_congr' {p : ι → Prop} {f g : (i : ι) → p i → α} (h : ∀ i (hi : p i), f i hi = g i hi) : ⨆ i, ⨆ (hi : p i), f i hi = ⨆ i, ⨆ (hi : p i), g i hi := by congr; ext i; congr; ext hi; exact h i hi theorem Function.Surjective.iSup_comp {f : ι → ι'} (hf : Surjective f) (g : ι' → α) : ⨆ x, g (f x) = ⨆ y, g y := by simp only [iSup.eq_1] congr exact hf.range_comp g #align function.surjective.supr_comp Function.Surjective.iSup_comp theorem Equiv.iSup_comp {g : ι' → α} (e : ι ≃ ι') : ⨆ x, g (e x) = ⨆ y, g y := e.surjective.iSup_comp _ #align equiv.supr_comp Equiv.iSup_comp protected theorem Function.Surjective.iSup_congr {g : ι' → α} (h : ι → ι') (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⨆ x, f x = ⨆ y, g y := by convert h1.iSup_comp g exact (h2 _).symm #align function.surjective.supr_congr Function.Surjective.iSup_congr protected theorem Equiv.iSup_congr {g : ι' → α} (e : ι ≃ ι') (h : ∀ x, g (e x) = f x) : ⨆ x, f x = ⨆ y, g y := e.surjective.iSup_congr _ h #align equiv.supr_congr Equiv.iSup_congr @[congr] theorem iSup_congr_Prop {p q : Prop} {f₁ : p → α} {f₂ : q → α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iSup f₁ = iSup f₂ := by obtain rfl := propext pq congr with x apply f #align supr_congr_Prop iSup_congr_Prop theorem iSup_plift_up (f : PLift ι → α) : ⨆ i, f (PLift.up i) = ⨆ i, f i := (PLift.up_surjective.iSup_congr _) fun _ => rfl #align supr_plift_up iSup_plift_up theorem iSup_plift_down (f : ι → α) : ⨆ i, f (PLift.down i) = ⨆ i, f i := (PLift.down_surjective.iSup_congr _) fun _ => rfl #align supr_plift_down iSup_plift_down theorem iSup_range' (g : β → α) (f : ι → β) : ⨆ b : range f, g b = ⨆ i, g (f i) := by rw [iSup, iSup, ← image_eq_range, ← range_comp] rfl #align supr_range' iSup_range' theorem sSup_image' {s : Set β} {f : β → α} : sSup (f '' s) = ⨆ a : s, f a := by rw [iSup, image_eq_range] #align Sup_image' sSup_image' end SupSet section InfSet variable [InfSet α] {f g : ι → α} theorem sInf_range : sInf (range f) = iInf f := rfl #align Inf_range sInf_range theorem sInf_eq_iInf' (s : Set α) : sInf s = ⨅ a : s, (a : α) := @sSup_eq_iSup' αᵒᵈ _ _ #align Inf_eq_infi' sInf_eq_iInf' theorem iInf_congr (h : ∀ i, f i = g i) : ⨅ i, f i = ⨅ i, g i := congr_arg _ <| funext h #align infi_congr iInf_congr theorem biInf_congr {p : ι → Prop} (h : ∀ i, p i → f i = g i) : ⨅ (i) (_ : p i), f i = ⨅ (i) (_ : p i), g i := biSup_congr (α := αᵒᵈ) h theorem biInf_congr' {p : ι → Prop} {f g : (i : ι) → p i → α} (h : ∀ i (hi : p i), f i hi = g i hi) : ⨅ i, ⨅ (hi : p i), f i hi = ⨅ i, ⨅ (hi : p i), g i hi := by congr; ext i; congr; ext hi; exact h i hi theorem Function.Surjective.iInf_comp {f : ι → ι'} (hf : Surjective f) (g : ι' → α) : ⨅ x, g (f x) = ⨅ y, g y := @Function.Surjective.iSup_comp αᵒᵈ _ _ _ f hf g #align function.surjective.infi_comp Function.Surjective.iInf_comp theorem Equiv.iInf_comp {g : ι' → α} (e : ι ≃ ι') : ⨅ x, g (e x) = ⨅ y, g y := @Equiv.iSup_comp αᵒᵈ _ _ _ _ e #align equiv.infi_comp Equiv.iInf_comp protected theorem Function.Surjective.iInf_congr {g : ι' → α} (h : ι → ι') (h1 : Surjective h) (h2 : ∀ x, g (h x) = f x) : ⨅ x, f x = ⨅ y, g y := @Function.Surjective.iSup_congr αᵒᵈ _ _ _ _ _ h h1 h2 #align function.surjective.infi_congr Function.Surjective.iInf_congr protected theorem Equiv.iInf_congr {g : ι' → α} (e : ι ≃ ι') (h : ∀ x, g (e x) = f x) : ⨅ x, f x = ⨅ y, g y := @Equiv.iSup_congr αᵒᵈ _ _ _ _ _ e h #align equiv.infi_congr Equiv.iInf_congr @[congr] theorem iInf_congr_Prop {p q : Prop} {f₁ : p → α} {f₂ : q → α} (pq : p ↔ q) (f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iInf f₁ = iInf f₂ := @iSup_congr_Prop αᵒᵈ _ p q f₁ f₂ pq f #align infi_congr_Prop iInf_congr_Prop theorem iInf_plift_up (f : PLift ι → α) : ⨅ i, f (PLift.up i) = ⨅ i, f i := (PLift.up_surjective.iInf_congr _) fun _ => rfl #align infi_plift_up iInf_plift_up theorem iInf_plift_down (f : ι → α) : ⨅ i, f (PLift.down i) = ⨅ i, f i := (PLift.down_surjective.iInf_congr _) fun _ => rfl #align infi_plift_down iInf_plift_down theorem iInf_range' (g : β → α) (f : ι → β) : ⨅ b : range f, g b = ⨅ i, g (f i) := @iSup_range' αᵒᵈ _ _ _ _ _ #align infi_range' iInf_range' theorem sInf_image' {s : Set β} {f : β → α} : sInf (f '' s) = ⨅ a : s, f a := @sSup_image' αᵒᵈ _ _ _ _ #align Inf_image' sInf_image' end InfSet section variable [CompleteLattice α] {f g s t : ι → α} {a b : α} theorem le_iSup (f : ι → α) (i : ι) : f i ≤ iSup f := le_sSup ⟨i, rfl⟩ #align le_supr le_iSup theorem iInf_le (f : ι → α) (i : ι) : iInf f ≤ f i := sInf_le ⟨i, rfl⟩ #align infi_le iInf_le theorem le_iSup' (f : ι → α) (i : ι) : f i ≤ iSup f := le_sSup ⟨i, rfl⟩ #align le_supr' le_iSup' theorem iInf_le' (f : ι → α) (i : ι) : iInf f ≤ f i := sInf_le ⟨i, rfl⟩ #align infi_le' iInf_le' theorem isLUB_iSup : IsLUB (range f) (⨆ j, f j) := isLUB_sSup _ #align is_lub_supr isLUB_iSup theorem isGLB_iInf : IsGLB (range f) (⨅ j, f j) := isGLB_sInf _ #align is_glb_infi isGLB_iInf theorem IsLUB.iSup_eq (h : IsLUB (range f) a) : ⨆ j, f j = a := h.sSup_eq #align is_lub.supr_eq IsLUB.iSup_eq theorem IsGLB.iInf_eq (h : IsGLB (range f) a) : ⨅ j, f j = a := h.sInf_eq #align is_glb.infi_eq IsGLB.iInf_eq theorem le_iSup_of_le (i : ι) (h : a ≤ f i) : a ≤ iSup f := h.trans <| le_iSup _ i #align le_supr_of_le le_iSup_of_le theorem iInf_le_of_le (i : ι) (h : f i ≤ a) : iInf f ≤ a := (iInf_le _ i).trans h #align infi_le_of_le iInf_le_of_le theorem le_iSup₂ {f : ∀ i, κ i → α} (i : ι) (j : κ i) : f i j ≤ ⨆ (i) (j), f i j := le_iSup_of_le i <| le_iSup (f i) j #align le_supr₂ le_iSup₂ theorem iInf₂_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) : ⨅ (i) (j), f i j ≤ f i j := iInf_le_of_le i <| iInf_le (f i) j #align infi₂_le iInf₂_le theorem le_iSup₂_of_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) (h : a ≤ f i j) : a ≤ ⨆ (i) (j), f i j := h.trans <| le_iSup₂ i j #align le_supr₂_of_le le_iSup₂_of_le theorem iInf₂_le_of_le {f : ∀ i, κ i → α} (i : ι) (j : κ i) (h : f i j ≤ a) : ⨅ (i) (j), f i j ≤ a := (iInf₂_le i j).trans h #align infi₂_le_of_le iInf₂_le_of_le theorem iSup_le (h : ∀ i, f i ≤ a) : iSup f ≤ a := sSup_le fun _ ⟨i, Eq⟩ => Eq ▸ h i #align supr_le iSup_le theorem le_iInf (h : ∀ i, a ≤ f i) : a ≤ iInf f := le_sInf fun _ ⟨i, Eq⟩ => Eq ▸ h i #align le_infi le_iInf theorem iSup₂_le {f : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ a) : ⨆ (i) (j), f i j ≤ a := iSup_le fun i => iSup_le <| h i #align supr₂_le iSup₂_le theorem le_iInf₂ {f : ∀ i, κ i → α} (h : ∀ i j, a ≤ f i j) : a ≤ ⨅ (i) (j), f i j := le_iInf fun i => le_iInf <| h i #align le_infi₂ le_iInf₂ theorem iSup₂_le_iSup (κ : ι → Sort*) (f : ι → α) : ⨆ (i) (_ : κ i), f i ≤ ⨆ i, f i := iSup₂_le fun i _ => le_iSup f i #align supr₂_le_supr iSup₂_le_iSup theorem iInf_le_iInf₂ (κ : ι → Sort*) (f : ι → α) : ⨅ i, f i ≤ ⨅ (i) (_ : κ i), f i := le_iInf₂ fun i _ => iInf_le f i #align infi_le_infi₂ iInf_le_iInf₂ @[gcongr] theorem iSup_mono (h : ∀ i, f i ≤ g i) : iSup f ≤ iSup g := iSup_le fun i => le_iSup_of_le i <| h i #align supr_mono iSup_mono @[gcongr] theorem iInf_mono (h : ∀ i, f i ≤ g i) : iInf f ≤ iInf g := le_iInf fun i => iInf_le_of_le i <| h i #align infi_mono iInf_mono theorem iSup₂_mono {f g : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ g i j) : ⨆ (i) (j), f i j ≤ ⨆ (i) (j), g i j := iSup_mono fun i => iSup_mono <| h i #align supr₂_mono iSup₂_mono theorem iInf₂_mono {f g : ∀ i, κ i → α} (h : ∀ i j, f i j ≤ g i j) : ⨅ (i) (j), f i j ≤ ⨅ (i) (j), g i j := iInf_mono fun i => iInf_mono <| h i #align infi₂_mono iInf₂_mono theorem iSup_mono' {g : ι' → α} (h : ∀ i, ∃ i', f i ≤ g i') : iSup f ≤ iSup g := iSup_le fun i => Exists.elim (h i) le_iSup_of_le #align supr_mono' iSup_mono' theorem iInf_mono' {g : ι' → α} (h : ∀ i', ∃ i, f i ≤ g i') : iInf f ≤ iInf g := le_iInf fun i' => Exists.elim (h i') iInf_le_of_le #align infi_mono' iInf_mono' theorem iSup₂_mono' {f : ∀ i, κ i → α} {g : ∀ i', κ' i' → α} (h : ∀ i j, ∃ i' j', f i j ≤ g i' j') : ⨆ (i) (j), f i j ≤ ⨆ (i) (j), g i j := iSup₂_le fun i j => let ⟨i', j', h⟩ := h i j le_iSup₂_of_le i' j' h #align supr₂_mono' iSup₂_mono' theorem iInf₂_mono' {f : ∀ i, κ i → α} {g : ∀ i', κ' i' → α} (h : ∀ i j, ∃ i' j', f i' j' ≤ g i j) : ⨅ (i) (j), f i j ≤ ⨅ (i) (j), g i j := le_iInf₂ fun i j => let ⟨i', j', h⟩ := h i j iInf₂_le_of_le i' j' h #align infi₂_mono' iInf₂_mono' theorem iSup_const_mono (h : ι → ι') : ⨆ _ : ι, a ≤ ⨆ _ : ι', a := iSup_le <| le_iSup _ ∘ h #align supr_const_mono iSup_const_mono theorem iInf_const_mono (h : ι' → ι) : ⨅ _ : ι, a ≤ ⨅ _ : ι', a := le_iInf <| iInf_le _ ∘ h #align infi_const_mono iInf_const_mono theorem iSup_iInf_le_iInf_iSup (f : ι → ι' → α) : ⨆ i, ⨅ j, f i j ≤ ⨅ j, ⨆ i, f i j := iSup_le fun i => iInf_mono fun j => le_iSup (fun i => f i j) i #align supr_infi_le_infi_supr iSup_iInf_le_iInf_iSup theorem biSup_mono {p q : ι → Prop} (hpq : ∀ i, p i → q i) : ⨆ (i) (_ : p i), f i ≤ ⨆ (i) (_ : q i), f i := iSup_mono fun i => iSup_const_mono (hpq i) #align bsupr_mono biSup_mono theorem biInf_mono {p q : ι → Prop} (hpq : ∀ i, p i → q i) : ⨅ (i) (_ : q i), f i ≤ ⨅ (i) (_ : p i), f i := iInf_mono fun i => iInf_const_mono (hpq i) #align binfi_mono biInf_mono @[simp] theorem iSup_le_iff : iSup f ≤ a ↔ ∀ i, f i ≤ a := (isLUB_le_iff isLUB_iSup).trans forall_mem_range #align supr_le_iff iSup_le_iff @[simp] theorem le_iInf_iff : a ≤ iInf f ↔ ∀ i, a ≤ f i := (le_isGLB_iff isGLB_iInf).trans forall_mem_range #align le_infi_iff le_iInf_iff theorem iSup₂_le_iff {f : ∀ i, κ i → α} : ⨆ (i) (j), f i j ≤ a ↔ ∀ i j, f i j ≤ a := by simp_rw [iSup_le_iff] #align supr₂_le_iff iSup₂_le_iff theorem le_iInf₂_iff {f : ∀ i, κ i → α} : (a ≤ ⨅ (i) (j), f i j) ↔ ∀ i j, a ≤ f i j := by simp_rw [le_iInf_iff] #align le_infi₂_iff le_iInf₂_iff theorem iSup_lt_iff : iSup f < a ↔ ∃ b, b < a ∧ ∀ i, f i ≤ b := ⟨fun h => ⟨iSup f, h, le_iSup f⟩, fun ⟨_, h, hb⟩ => (iSup_le hb).trans_lt h⟩ #align supr_lt_iff iSup_lt_iff theorem lt_iInf_iff : a < iInf f ↔ ∃ b, a < b ∧ ∀ i, b ≤ f i := ⟨fun h => ⟨iInf f, h, iInf_le f⟩, fun ⟨_, h, hb⟩ => h.trans_le <| le_iInf hb⟩ #align lt_infi_iff lt_iInf_iff theorem sSup_eq_iSup {s : Set α} : sSup s = ⨆ a ∈ s, a := le_antisymm (sSup_le le_iSup₂) (iSup₂_le fun _ => le_sSup) #align Sup_eq_supr sSup_eq_iSup theorem sInf_eq_iInf {s : Set α} : sInf s = ⨅ a ∈ s, a := @sSup_eq_iSup αᵒᵈ _ _ #align Inf_eq_infi sInf_eq_iInf theorem Monotone.le_map_iSup [CompleteLattice β] {f : α → β} (hf : Monotone f) : ⨆ i, f (s i) ≤ f (iSup s) := iSup_le fun _ => hf <| le_iSup _ _ #align monotone.le_map_supr Monotone.le_map_iSup theorem Antitone.le_map_iInf [CompleteLattice β] {f : α → β} (hf : Antitone f) : ⨆ i, f (s i) ≤ f (iInf s) := hf.dual_left.le_map_iSup #align antitone.le_map_infi Antitone.le_map_iInf theorem Monotone.le_map_iSup₂ [CompleteLattice β] {f : α → β} (hf : Monotone f) (s : ∀ i, κ i → α) : ⨆ (i) (j), f (s i j) ≤ f (⨆ (i) (j), s i j) := iSup₂_le fun _ _ => hf <| le_iSup₂ _ _ #align monotone.le_map_supr₂ Monotone.le_map_iSup₂ theorem Antitone.le_map_iInf₂ [CompleteLattice β] {f : α → β} (hf : Antitone f) (s : ∀ i, κ i → α) : ⨆ (i) (j), f (s i j) ≤ f (⨅ (i) (j), s i j) := hf.dual_left.le_map_iSup₂ _ #align antitone.le_map_infi₂ Antitone.le_map_iInf₂ theorem Monotone.le_map_sSup [CompleteLattice β] {s : Set α} {f : α → β} (hf : Monotone f) : ⨆ a ∈ s, f a ≤ f (sSup s) := by rw [sSup_eq_iSup]; exact hf.le_map_iSup₂ _ #align monotone.le_map_Sup Monotone.le_map_sSup theorem Antitone.le_map_sInf [CompleteLattice β] {s : Set α} {f : α → β} (hf : Antitone f) : ⨆ a ∈ s, f a ≤ f (sInf s) := hf.dual_left.le_map_sSup #align antitone.le_map_Inf Antitone.le_map_sInf theorem OrderIso.map_iSup [CompleteLattice β] (f : α ≃o β) (x : ι → α) : f (⨆ i, x i) = ⨆ i, f (x i) := eq_of_forall_ge_iff <| f.surjective.forall.2 fun x => by simp only [f.le_iff_le, iSup_le_iff] #align order_iso.map_supr OrderIso.map_iSup theorem OrderIso.map_iInf [CompleteLattice β] (f : α ≃o β) (x : ι → α) : f (⨅ i, x i) = ⨅ i, f (x i) := OrderIso.map_iSup f.dual _ #align order_iso.map_infi OrderIso.map_iInf theorem OrderIso.map_sSup [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sSup s) = ⨆ a ∈ s, f a := by simp only [sSup_eq_iSup, OrderIso.map_iSup] #align order_iso.map_Sup OrderIso.map_sSup theorem OrderIso.map_sInf [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sInf s) = ⨅ a ∈ s, f a := OrderIso.map_sSup f.dual _ #align order_iso.map_Inf OrderIso.map_sInf theorem iSup_comp_le {ι' : Sort*} (f : ι' → α) (g : ι → ι') : ⨆ x, f (g x) ≤ ⨆ y, f y := iSup_mono' fun _ => ⟨_, le_rfl⟩ #align supr_comp_le iSup_comp_le theorem le_iInf_comp {ι' : Sort*} (f : ι' → α) (g : ι → ι') : ⨅ y, f y ≤ ⨅ x, f (g x) := iInf_mono' fun _ => ⟨_, le_rfl⟩ #align le_infi_comp le_iInf_comp theorem Monotone.iSup_comp_eq [Preorder β] {f : β → α} (hf : Monotone f) {s : ι → β} (hs : ∀ x, ∃ i, x ≤ s i) : ⨆ x, f (s x) = ⨆ y, f y := le_antisymm (iSup_comp_le _ _) (iSup_mono' fun x => (hs x).imp fun _ hi => hf hi) #align monotone.supr_comp_eq Monotone.iSup_comp_eq theorem Monotone.iInf_comp_eq [Preorder β] {f : β → α} (hf : Monotone f) {s : ι → β} (hs : ∀ x, ∃ i, s i ≤ x) : ⨅ x, f (s x) = ⨅ y, f y := le_antisymm (iInf_mono' fun x => (hs x).imp fun _ hi => hf hi) (le_iInf_comp _ _) #align monotone.infi_comp_eq Monotone.iInf_comp_eq theorem Antitone.map_iSup_le [CompleteLattice β] {f : α → β} (hf : Antitone f) : f (iSup s) ≤ ⨅ i, f (s i) := le_iInf fun _ => hf <| le_iSup _ _ #align antitone.map_supr_le Antitone.map_iSup_le theorem Monotone.map_iInf_le [CompleteLattice β] {f : α → β} (hf : Monotone f) : f (iInf s) ≤ ⨅ i, f (s i) := hf.dual_left.map_iSup_le #align monotone.map_infi_le Monotone.map_iInf_le theorem Antitone.map_iSup₂_le [CompleteLattice β] {f : α → β} (hf : Antitone f) (s : ∀ i, κ i → α) : f (⨆ (i) (j), s i j) ≤ ⨅ (i) (j), f (s i j) := hf.dual.le_map_iInf₂ _ #align antitone.map_supr₂_le Antitone.map_iSup₂_le theorem Monotone.map_iInf₂_le [CompleteLattice β] {f : α → β} (hf : Monotone f) (s : ∀ i, κ i → α) : f (⨅ (i) (j), s i j) ≤ ⨅ (i) (j), f (s i j) := hf.dual.le_map_iSup₂ _ #align monotone.map_infi₂_le Monotone.map_iInf₂_le theorem Antitone.map_sSup_le [CompleteLattice β] {s : Set α} {f : α → β} (hf : Antitone f) : f (sSup s) ≤ ⨅ a ∈ s, f a := by rw [sSup_eq_iSup] exact hf.map_iSup₂_le _ #align antitone.map_Sup_le Antitone.map_sSup_le theorem Monotone.map_sInf_le [CompleteLattice β] {s : Set α} {f : α → β} (hf : Monotone f) : f (sInf s) ≤ ⨅ a ∈ s, f a := hf.dual_left.map_sSup_le #align monotone.map_Inf_le Monotone.map_sInf_le theorem iSup_const_le : ⨆ _ : ι, a ≤ a := iSup_le fun _ => le_rfl #align supr_const_le iSup_const_le theorem le_iInf_const : a ≤ ⨅ _ : ι, a := le_iInf fun _ => le_rfl #align le_infi_const le_iInf_const -- We generalize this to conditionally complete lattices in `ciSup_const` and `ciInf_const`. theorem iSup_const [Nonempty ι] : ⨆ _ : ι, a = a := by rw [iSup, range_const, sSup_singleton] #align supr_const iSup_const theorem iInf_const [Nonempty ι] : ⨅ _ : ι, a = a := @iSup_const αᵒᵈ _ _ a _ #align infi_const iInf_const @[simp] theorem iSup_bot : (⨆ _ : ι, ⊥ : α) = ⊥ := bot_unique iSup_const_le #align supr_bot iSup_bot @[simp] theorem iInf_top : (⨅ _ : ι, ⊤ : α) = ⊤ := top_unique le_iInf_const #align infi_top iInf_top @[simp] theorem iSup_eq_bot : iSup s = ⊥ ↔ ∀ i, s i = ⊥ := sSup_eq_bot.trans forall_mem_range #align supr_eq_bot iSup_eq_bot @[simp] theorem iInf_eq_top : iInf s = ⊤ ↔ ∀ i, s i = ⊤ := sInf_eq_top.trans forall_mem_range #align infi_eq_top iInf_eq_top theorem iSup₂_eq_bot {f : ∀ i, κ i → α} : ⨆ (i) (j), f i j = ⊥ ↔ ∀ i j, f i j = ⊥ := by simp #align supr₂_eq_bot iSup₂_eq_bot theorem iInf₂_eq_top {f : ∀ i, κ i → α} : ⨅ (i) (j), f i j = ⊤ ↔ ∀ i j, f i j = ⊤ := by simp #align infi₂_eq_top iInf₂_eq_top @[simp] theorem iSup_pos {p : Prop} {f : p → α} (hp : p) : ⨆ h : p, f h = f hp := le_antisymm (iSup_le fun _ => le_rfl) (le_iSup _ _) #align supr_pos iSup_pos @[simp] theorem iInf_pos {p : Prop} {f : p → α} (hp : p) : ⨅ h : p, f h = f hp := le_antisymm (iInf_le _ _) (le_iInf fun _ => le_rfl) #align infi_pos iInf_pos @[simp] theorem iSup_neg {p : Prop} {f : p → α} (hp : ¬p) : ⨆ h : p, f h = ⊥ := le_antisymm (iSup_le fun h => (hp h).elim) bot_le #align supr_neg iSup_neg @[simp] theorem iInf_neg {p : Prop} {f : p → α} (hp : ¬p) : ⨅ h : p, f h = ⊤ := le_antisymm le_top <| le_iInf fun h => (hp h).elim #align infi_neg iInf_neg /-- Introduction rule to prove that `b` is the supremum of `f`: it suffices to check that `b` is larger than `f i` for all `i`, and that this is not the case of any `w<b`. See `ciSup_eq_of_forall_le_of_forall_lt_exists_gt` for a version in conditionally complete lattices. -/ theorem iSup_eq_of_forall_le_of_forall_lt_exists_gt {f : ι → α} (h₁ : ∀ i, f i ≤ b) (h₂ : ∀ w, w < b → ∃ i, w < f i) : ⨆ i : ι, f i = b := sSup_eq_of_forall_le_of_forall_lt_exists_gt (forall_mem_range.mpr h₁) fun w hw => exists_range_iff.mpr <| h₂ w hw #align supr_eq_of_forall_le_of_forall_lt_exists_gt iSup_eq_of_forall_le_of_forall_lt_exists_gt /-- Introduction rule to prove that `b` is the infimum of `f`: it suffices to check that `b` is smaller than `f i` for all `i`, and that this is not the case of any `w>b`. See `ciInf_eq_of_forall_ge_of_forall_gt_exists_lt` for a version in conditionally complete lattices. -/ theorem iInf_eq_of_forall_ge_of_forall_gt_exists_lt : (∀ i, b ≤ f i) → (∀ w, b < w → ∃ i, f i < w) → ⨅ i, f i = b := @iSup_eq_of_forall_le_of_forall_lt_exists_gt αᵒᵈ _ _ _ _ #align infi_eq_of_forall_ge_of_forall_gt_exists_lt iInf_eq_of_forall_ge_of_forall_gt_exists_lt theorem iSup_eq_dif {p : Prop} [Decidable p] (a : p → α) : ⨆ h : p, a h = if h : p then a h else ⊥ := by by_cases h : p <;> simp [h] #align supr_eq_dif iSup_eq_dif theorem iSup_eq_if {p : Prop} [Decidable p] (a : α) : ⨆ _ : p, a = if p then a else ⊥ := iSup_eq_dif fun _ => a #align supr_eq_if iSup_eq_if theorem iInf_eq_dif {p : Prop} [Decidable p] (a : p → α) : ⨅ h : p, a h = if h : p then a h else ⊤ := @iSup_eq_dif αᵒᵈ _ _ _ _ #align infi_eq_dif iInf_eq_dif theorem iInf_eq_if {p : Prop} [Decidable p] (a : α) : ⨅ _ : p, a = if p then a else ⊤ := iInf_eq_dif fun _ => a #align infi_eq_if iInf_eq_if theorem iSup_comm {f : ι → ι' → α} : ⨆ (i) (j), f i j = ⨆ (j) (i), f i j := le_antisymm (iSup_le fun i => iSup_mono fun j => le_iSup (fun i => f i j) i) (iSup_le fun _ => iSup_mono fun _ => le_iSup _ _) #align supr_comm iSup_comm theorem iInf_comm {f : ι → ι' → α} : ⨅ (i) (j), f i j = ⨅ (j) (i), f i j := @iSup_comm αᵒᵈ _ _ _ _ #align infi_comm iInf_comm theorem iSup₂_comm {ι₁ ι₂ : Sort*} {κ₁ : ι₁ → Sort*} {κ₂ : ι₂ → Sort*} (f : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → α) : ⨆ (i₁) (j₁) (i₂) (j₂), f i₁ j₁ i₂ j₂ = ⨆ (i₂) (j₂) (i₁) (j₁), f i₁ j₁ i₂ j₂ := by simp only [@iSup_comm _ (κ₁ _), @iSup_comm _ ι₁] #align supr₂_comm iSup₂_comm theorem iInf₂_comm {ι₁ ι₂ : Sort*} {κ₁ : ι₁ → Sort*} {κ₂ : ι₂ → Sort*} (f : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → α) : ⨅ (i₁) (j₁) (i₂) (j₂), f i₁ j₁ i₂ j₂ = ⨅ (i₂) (j₂) (i₁) (j₁), f i₁ j₁ i₂ j₂ := by simp only [@iInf_comm _ (κ₁ _), @iInf_comm _ ι₁] #align infi₂_comm iInf₂_comm /- TODO: this is strange. In the proof below, we get exactly the desired among the equalities, but close does not get it. begin apply @le_antisymm, simp, intros, begin [smt] ematch, ematch, ematch, trace_state, have := le_refl (f i_1 i), trace_state, close end end -/ @[simp] theorem iSup_iSup_eq_left {b : β} {f : ∀ x : β, x = b → α} : ⨆ x, ⨆ h : x = b, f x h = f b rfl := (@le_iSup₂ _ _ _ _ f b rfl).antisymm' (iSup_le fun c => iSup_le <| by rintro rfl rfl) #align supr_supr_eq_left iSup_iSup_eq_left @[simp] theorem iInf_iInf_eq_left {b : β} {f : ∀ x : β, x = b → α} : ⨅ x, ⨅ h : x = b, f x h = f b rfl := @iSup_iSup_eq_left αᵒᵈ _ _ _ _ #align infi_infi_eq_left iInf_iInf_eq_left @[simp] theorem iSup_iSup_eq_right {b : β} {f : ∀ x : β, b = x → α} : ⨆ x, ⨆ h : b = x, f x h = f b rfl := (le_iSup₂ b rfl).antisymm' (iSup₂_le fun c => by rintro rfl rfl) #align supr_supr_eq_right iSup_iSup_eq_right @[simp] theorem iInf_iInf_eq_right {b : β} {f : ∀ x : β, b = x → α} : ⨅ x, ⨅ h : b = x, f x h = f b rfl := @iSup_iSup_eq_right αᵒᵈ _ _ _ _ #align infi_infi_eq_right iInf_iInf_eq_right theorem iSup_subtype {p : ι → Prop} {f : Subtype p → α} : iSup f = ⨆ (i) (h : p i), f ⟨i, h⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ p _ (fun i h => f ⟨i, h⟩) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_subtype iSup_subtype theorem iInf_subtype : ∀ {p : ι → Prop} {f : Subtype p → α}, iInf f = ⨅ (i) (h : p i), f ⟨i, h⟩ := @iSup_subtype αᵒᵈ _ _ #align infi_subtype iInf_subtype theorem iSup_subtype' {p : ι → Prop} {f : ∀ i, p i → α} : ⨆ (i) (h), f i h = ⨆ x : Subtype p, f x x.property := (@iSup_subtype _ _ _ p fun x => f x.val x.property).symm #align supr_subtype' iSup_subtype' theorem iInf_subtype' {p : ι → Prop} {f : ∀ i, p i → α} : ⨅ (i) (h : p i), f i h = ⨅ x : Subtype p, f x x.property := (@iInf_subtype _ _ _ p fun x => f x.val x.property).symm #align infi_subtype' iInf_subtype' theorem iSup_subtype'' {ι} (s : Set ι) (f : ι → α) : ⨆ i : s, f i = ⨆ (t : ι) (_ : t ∈ s), f t := iSup_subtype #align supr_subtype'' iSup_subtype'' theorem iInf_subtype'' {ι} (s : Set ι) (f : ι → α) : ⨅ i : s, f i = ⨅ (t : ι) (_ : t ∈ s), f t := iInf_subtype #align infi_subtype'' iInf_subtype'' theorem biSup_const {ι : Sort _} {a : α} {s : Set ι} (hs : s.Nonempty) : ⨆ i ∈ s, a = a := by haveI : Nonempty s := Set.nonempty_coe_sort.mpr hs rw [← iSup_subtype'', iSup_const] #align bsupr_const biSup_const theorem biInf_const {ι : Sort _} {a : α} {s : Set ι} (hs : s.Nonempty) : ⨅ i ∈ s, a = a := @biSup_const αᵒᵈ _ ι _ s hs #align binfi_const biInf_const theorem iSup_sup_eq : ⨆ x, f x ⊔ g x = (⨆ x, f x) ⊔ ⨆ x, g x := le_antisymm (iSup_le fun _ => sup_le_sup (le_iSup _ _) <| le_iSup _ _) (sup_le (iSup_mono fun _ => le_sup_left) <| iSup_mono fun _ => le_sup_right) #align supr_sup_eq iSup_sup_eq theorem iInf_inf_eq : ⨅ x, f x ⊓ g x = (⨅ x, f x) ⊓ ⨅ x, g x := @iSup_sup_eq αᵒᵈ _ _ _ _ #align infi_inf_eq iInf_inf_eq lemma Equiv.biSup_comp {ι ι' : Type*} {g : ι' → α} (e : ι ≃ ι') (s : Set ι') : ⨆ i ∈ e.symm '' s, g (e i) = ⨆ i ∈ s, g i := by simpa only [iSup_subtype'] using (image e.symm s).symm.iSup_comp (g := g ∘ (↑)) lemma Equiv.biInf_comp {ι ι' : Type*} {g : ι' → α} (e : ι ≃ ι') (s : Set ι') : ⨅ i ∈ e.symm '' s, g (e i) = ⨅ i ∈ s, g i := e.biSup_comp s (α := αᵒᵈ) lemma biInf_le {ι : Type*} {s : Set ι} (f : ι → α) {i : ι} (hi : i ∈ s) : ⨅ i ∈ s, f i ≤ f i := by simpa only [iInf_subtype'] using iInf_le (ι := s) (f := f ∘ (↑)) ⟨i, hi⟩ lemma le_biSup {ι : Type*} {s : Set ι} (f : ι → α) {i : ι} (hi : i ∈ s) : f i ≤ ⨆ i ∈ s, f i := biInf_le (α := αᵒᵈ) f hi /- TODO: here is another example where more flexible pattern matching might help. begin apply @le_antisymm, safe, pose h := f a ⊓ g a, begin [smt] ematch, ematch end end -/ theorem iSup_sup [Nonempty ι] {f : ι → α} {a : α} : (⨆ x, f x) ⊔ a = ⨆ x, f x ⊔ a := by rw [iSup_sup_eq, iSup_const] #align supr_sup iSup_sup theorem iInf_inf [Nonempty ι] {f : ι → α} {a : α} : (⨅ x, f x) ⊓ a = ⨅ x, f x ⊓ a := by rw [iInf_inf_eq, iInf_const] #align infi_inf iInf_inf theorem sup_iSup [Nonempty ι] {f : ι → α} {a : α} : (a ⊔ ⨆ x, f x) = ⨆ x, a ⊔ f x := by rw [iSup_sup_eq, iSup_const] #align sup_supr sup_iSup theorem inf_iInf [Nonempty ι] {f : ι → α} {a : α} : (a ⊓ ⨅ x, f x) = ⨅ x, a ⊓ f x := by rw [iInf_inf_eq, iInf_const] #align inf_infi inf_iInf theorem biSup_sup {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (⨆ (i) (h : p i), f i h) ⊔ a = ⨆ (i) (h : p i), f i h ⊔ a := by haveI : Nonempty { i // p i } := let ⟨i, hi⟩ := h ⟨⟨i, hi⟩⟩ rw [iSup_subtype', iSup_subtype', iSup_sup] #align bsupr_sup biSup_sup theorem sup_biSup {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (a ⊔ ⨆ (i) (h : p i), f i h) = ⨆ (i) (h : p i), a ⊔ f i h := by simpa only [sup_comm] using @biSup_sup α _ _ p _ _ h #align sup_bsupr sup_biSup theorem biInf_inf {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (⨅ (i) (h : p i), f i h) ⊓ a = ⨅ (i) (h : p i), f i h ⊓ a := @biSup_sup αᵒᵈ ι _ p f _ h #align binfi_inf biInf_inf theorem inf_biInf {p : ι → Prop} {f : ∀ i, p i → α} {a : α} (h : ∃ i, p i) : (a ⊓ ⨅ (i) (h : p i), f i h) = ⨅ (i) (h : p i), a ⊓ f i h := @sup_biSup αᵒᵈ ι _ p f _ h #align inf_binfi inf_biInf /-! ### `iSup` and `iInf` under `Prop` -/ theorem iSup_false {s : False → α} : iSup s = ⊥ := by simp #align supr_false iSup_false theorem iInf_false {s : False → α} : iInf s = ⊤ := by simp #align infi_false iInf_false theorem iSup_true {s : True → α} : iSup s = s trivial := iSup_pos trivial #align supr_true iSup_true theorem iInf_true {s : True → α} : iInf s = s trivial := iInf_pos trivial #align infi_true iInf_true @[simp] theorem iSup_exists {p : ι → Prop} {f : Exists p → α} : ⨆ x, f x = ⨆ (i) (h), f ⟨i, h⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ _ _ (fun _ _ => _) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_exists iSup_exists @[simp] theorem iInf_exists {p : ι → Prop} {f : Exists p → α} : ⨅ x, f x = ⨅ (i) (h), f ⟨i, h⟩ := @iSup_exists αᵒᵈ _ _ _ _ #align infi_exists iInf_exists theorem iSup_and {p q : Prop} {s : p ∧ q → α} : iSup s = ⨆ (h₁) (h₂), s ⟨h₁, h₂⟩ := le_antisymm (iSup_le fun ⟨i, h⟩ => @le_iSup₂ _ _ _ _ (fun _ _ => _) i h) (iSup₂_le fun _ _ => le_iSup _ _) #align supr_and iSup_and theorem iInf_and {p q : Prop} {s : p ∧ q → α} : iInf s = ⨅ (h₁) (h₂), s ⟨h₁, h₂⟩ := @iSup_and αᵒᵈ _ _ _ _ #align infi_and iInf_and /-- The symmetric case of `iSup_and`, useful for rewriting into a supremum over a conjunction -/ theorem iSup_and' {p q : Prop} {s : p → q → α} : ⨆ (h₁ : p) (h₂ : q), s h₁ h₂ = ⨆ h : p ∧ q, s h.1 h.2 := Eq.symm iSup_and #align supr_and' iSup_and' /-- The symmetric case of `iInf_and`, useful for rewriting into an infimum over a conjunction -/ theorem iInf_and' {p q : Prop} {s : p → q → α} : ⨅ (h₁ : p) (h₂ : q), s h₁ h₂ = ⨅ h : p ∧ q, s h.1 h.2 := Eq.symm iInf_and #align infi_and' iInf_and' theorem iSup_or {p q : Prop} {s : p ∨ q → α} : ⨆ x, s x = (⨆ i, s (Or.inl i)) ⊔ ⨆ j, s (Or.inr j) := le_antisymm (iSup_le fun i => match i with | Or.inl _ => le_sup_of_le_left <| le_iSup (fun _ => s _) _ | Or.inr _ => le_sup_of_le_right <| le_iSup (fun _ => s _) _) (sup_le (iSup_comp_le _ _) (iSup_comp_le _ _)) #align supr_or iSup_or theorem iInf_or {p q : Prop} {s : p ∨ q → α} : ⨅ x, s x = (⨅ i, s (Or.inl i)) ⊓ ⨅ j, s (Or.inr j) := @iSup_or αᵒᵈ _ _ _ _ #align infi_or iInf_or section variable (p : ι → Prop) [DecidablePred p] theorem iSup_dite (f : ∀ i, p i → α) (g : ∀ i, ¬p i → α) : ⨆ i, (if h : p i then f i h else g i h) = (⨆ (i) (h : p i), f i h) ⊔ ⨆ (i) (h : ¬p i), g i h := by rw [← iSup_sup_eq] congr 1 with i split_ifs with h <;> simp [h] #align supr_dite iSup_dite theorem iInf_dite (f : ∀ i, p i → α) (g : ∀ i, ¬p i → α) : ⨅ i, (if h : p i then f i h else g i h) = (⨅ (i) (h : p i), f i h) ⊓ ⨅ (i) (h : ¬p i), g i h := iSup_dite p (show ∀ i, p i → αᵒᵈ from f) g #align infi_dite iInf_dite theorem iSup_ite (f g : ι → α) : ⨆ i, (if p i then f i else g i) = (⨆ (i) (_ : p i), f i) ⊔ ⨆ (i) (_ : ¬p i), g i := iSup_dite _ _ _ #align supr_ite iSup_ite theorem iInf_ite (f g : ι → α) : ⨅ i, (if p i then f i else g i) = (⨅ (i) (_ : p i), f i) ⊓ ⨅ (i) (_ : ¬p i), g i := iInf_dite _ _ _ #align infi_ite iInf_ite end theorem iSup_range {g : β → α} {f : ι → β} : ⨆ b ∈ range f, g b = ⨆ i, g (f i) := by rw [← iSup_subtype'', iSup_range'] #align supr_range iSup_range theorem iInf_range : ∀ {g : β → α} {f : ι → β}, ⨅ b ∈ range f, g b = ⨅ i, g (f i) := @iSup_range αᵒᵈ _ _ _ #align infi_range iInf_range theorem sSup_image {s : Set β} {f : β → α} : sSup (f '' s) = ⨆ a ∈ s, f a := by rw [← iSup_subtype'', sSup_image'] #align Sup_image sSup_image theorem sInf_image {s : Set β} {f : β → α} : sInf (f '' s) = ⨅ a ∈ s, f a := @sSup_image αᵒᵈ _ _ _ _ #align Inf_image sInf_image theorem OrderIso.map_sSup_eq_sSup_symm_preimage [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sSup s) = sSup (f.symm ⁻¹' s) := by rw [map_sSup, ← sSup_image, f.image_eq_preimage] theorem OrderIso.map_sInf_eq_sInf_symm_preimage [CompleteLattice β] (f : α ≃o β) (s : Set α) : f (sInf s) = sInf (f.symm ⁻¹' s) := by rw [map_sInf, ← sInf_image, f.image_eq_preimage] /- ### iSup and iInf under set constructions -/ theorem iSup_emptyset {f : β → α} : ⨆ x ∈ (∅ : Set β), f x = ⊥ := by simp #align supr_emptyset iSup_emptyset theorem iInf_emptyset {f : β → α} : ⨅ x ∈ (∅ : Set β), f x = ⊤ := by simp #align infi_emptyset iInf_emptyset theorem iSup_univ {f : β → α} : ⨆ x ∈ (univ : Set β), f x = ⨆ x, f x := by simp #align supr_univ iSup_univ theorem iInf_univ {f : β → α} : ⨅ x ∈ (univ : Set β), f x = ⨅ x, f x := by simp #align infi_univ iInf_univ theorem iSup_union {f : β → α} {s t : Set β} : ⨆ x ∈ s ∪ t, f x = (⨆ x ∈ s, f x) ⊔ ⨆ x ∈ t, f x := by simp_rw [mem_union, iSup_or, iSup_sup_eq] #align supr_union iSup_union theorem iInf_union {f : β → α} {s t : Set β} : ⨅ x ∈ s ∪ t, f x = (⨅ x ∈ s, f x) ⊓ ⨅ x ∈ t, f x := @iSup_union αᵒᵈ _ _ _ _ _ #align infi_union iInf_union theorem iSup_split (f : β → α) (p : β → Prop) : ⨆ i, f i = (⨆ (i) (_ : p i), f i) ⊔ ⨆ (i) (_ : ¬p i), f i := by simpa [Classical.em] using @iSup_union _ _ _ f { i | p i } { i | ¬p i } #align supr_split iSup_split theorem iInf_split : ∀ (f : β → α) (p : β → Prop), ⨅ i, f i = (⨅ (i) (_ : p i), f i) ⊓ ⨅ (i) (_ : ¬p i), f i := @iSup_split αᵒᵈ _ _ #align infi_split iInf_split theorem iSup_split_single (f : β → α) (i₀ : β) : ⨆ i, f i = f i₀ ⊔ ⨆ (i) (_ : i ≠ i₀), f i := by convert iSup_split f (fun i => i = i₀) simp #align supr_split_single iSup_split_single theorem iInf_split_single (f : β → α) (i₀ : β) : ⨅ i, f i = f i₀ ⊓ ⨅ (i) (_ : i ≠ i₀), f i := @iSup_split_single αᵒᵈ _ _ _ _ #align infi_split_single iInf_split_single theorem iSup_le_iSup_of_subset {f : β → α} {s t : Set β} : s ⊆ t → ⨆ x ∈ s, f x ≤ ⨆ x ∈ t, f x := biSup_mono #align supr_le_supr_of_subset iSup_le_iSup_of_subset theorem iInf_le_iInf_of_subset {f : β → α} {s t : Set β} : s ⊆ t → ⨅ x ∈ t, f x ≤ ⨅ x ∈ s, f x := biInf_mono #align infi_le_infi_of_subset iInf_le_iInf_of_subset theorem iSup_insert {f : β → α} {s : Set β} {b : β} : ⨆ x ∈ insert b s, f x = f b ⊔ ⨆ x ∈ s, f x := Eq.trans iSup_union <| congr_arg (fun x => x ⊔ ⨆ x ∈ s, f x) iSup_iSup_eq_left #align supr_insert iSup_insert theorem iInf_insert {f : β → α} {s : Set β} {b : β} : ⨅ x ∈ insert b s, f x = f b ⊓ ⨅ x ∈ s, f x := Eq.trans iInf_union <| congr_arg (fun x => x ⊓ ⨅ x ∈ s, f x) iInf_iInf_eq_left #align infi_insert iInf_insert theorem iSup_singleton {f : β → α} {b : β} : ⨆ x ∈ (singleton b : Set β), f x = f b := by simp #align supr_singleton iSup_singleton theorem iInf_singleton {f : β → α} {b : β} : ⨅ x ∈ (singleton b : Set β), f x = f b := by simp #align infi_singleton iInf_singleton theorem iSup_pair {f : β → α} {a b : β} : ⨆ x ∈ ({a, b} : Set β), f x = f a ⊔ f b := by rw [iSup_insert, iSup_singleton] #align supr_pair iSup_pair theorem iInf_pair {f : β → α} {a b : β} : ⨅ x ∈ ({a, b} : Set β), f x = f a ⊓ f b := by rw [iInf_insert, iInf_singleton] #align infi_pair iInf_pair theorem iSup_image {γ} {f : β → γ} {g : γ → α} {t : Set β} : ⨆ c ∈ f '' t, g c = ⨆ b ∈ t, g (f b) := by rw [← sSup_image, ← sSup_image, ← image_comp]; rfl #align supr_image iSup_image theorem iInf_image : ∀ {γ} {f : β → γ} {g : γ → α} {t : Set β}, ⨅ c ∈ f '' t, g c = ⨅ b ∈ t, g (f b) := @iSup_image αᵒᵈ _ _ #align infi_image iInf_image theorem iSup_extend_bot {e : ι → β} (he : Injective e) (f : ι → α) : ⨆ j, extend e f ⊥ j = ⨆ i, f i := by rw [iSup_split _ fun j => ∃ i, e i = j] simp (config := { contextual := true }) [he.extend_apply, extend_apply', @iSup_comm _ β ι] #align supr_extend_bot iSup_extend_bot theorem iInf_extend_top {e : ι → β} (he : Injective e) (f : ι → α) : ⨅ j, extend e f ⊤ j = iInf f := @iSup_extend_bot αᵒᵈ _ _ _ _ he _ #align infi_extend_top iInf_extend_top /-! ### `iSup` and `iInf` under `Type` -/ theorem iSup_of_empty' {α ι} [SupSet α] [IsEmpty ι] (f : ι → α) : iSup f = sSup (∅ : Set α) := congr_arg sSup (range_eq_empty f) #align supr_of_empty' iSup_of_empty' theorem iInf_of_isEmpty {α ι} [InfSet α] [IsEmpty ι] (f : ι → α) : iInf f = sInf (∅ : Set α) := congr_arg sInf (range_eq_empty f) #align infi_of_empty' iInf_of_isEmpty theorem iSup_of_empty [IsEmpty ι] (f : ι → α) : iSup f = ⊥ := (iSup_of_empty' f).trans sSup_empty #align supr_of_empty iSup_of_empty theorem iInf_of_empty [IsEmpty ι] (f : ι → α) : iInf f = ⊤ := @iSup_of_empty αᵒᵈ _ _ _ f #align infi_of_empty iInf_of_empty theorem iSup_bool_eq {f : Bool → α} : ⨆ b : Bool, f b = f true ⊔ f false := by rw [iSup, Bool.range_eq, sSup_pair, sup_comm] #align supr_bool_eq iSup_bool_eq theorem iInf_bool_eq {f : Bool → α} : ⨅ b : Bool, f b = f true ⊓ f false := @iSup_bool_eq αᵒᵈ _ _ #align infi_bool_eq iInf_bool_eq theorem sup_eq_iSup (x y : α) : x ⊔ y = ⨆ b : Bool, cond b x y := by rw [iSup_bool_eq, Bool.cond_true, Bool.cond_false] #align sup_eq_supr sup_eq_iSup theorem inf_eq_iInf (x y : α) : x ⊓ y = ⨅ b : Bool, cond b x y := @sup_eq_iSup αᵒᵈ _ _ _ #align inf_eq_infi inf_eq_iInf
Mathlib/Order/CompleteLattice.lean
1,496
1,498
theorem isGLB_biInf {s : Set β} {f : β → α} : IsGLB (f '' s) (⨅ x ∈ s, f x) := by
simpa only [range_comp, Subtype.range_coe, iInf_subtype'] using @isGLB_iInf α s _ (f ∘ fun x => (x : β))
/- Copyright (c) 2017 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Data.List.Basic #align_import data.list.infix from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2" /-! # Prefixes, suffixes, infixes This file proves properties about * `List.isPrefix`: `l₁` is a prefix of `l₂` if `l₂` starts with `l₁`. * `List.isSuffix`: `l₁` is a suffix of `l₂` if `l₂` ends with `l₁`. * `List.isInfix`: `l₁` is an infix of `l₂` if `l₁` is a prefix of some suffix of `l₂`. * `List.inits`: The list of prefixes of a list. * `List.tails`: The list of prefixes of a list. * `insert` on lists All those (except `insert`) are defined in `Mathlib.Data.List.Defs`. ## Notation * `l₁ <+: l₂`: `l₁` is a prefix of `l₂`. * `l₁ <:+ l₂`: `l₁` is a suffix of `l₂`. * `l₁ <:+: l₂`: `l₁` is an infix of `l₂`. -/ open Nat variable {α β : Type*} namespace List variable {l l₁ l₂ l₃ : List α} {a b : α} {m n : ℕ} /-! ### prefix, suffix, infix -/ section Fix #align list.prefix_append List.prefix_append #align list.suffix_append List.suffix_append #align list.infix_append List.infix_append #align list.infix_append' List.infix_append' #align list.is_prefix.is_infix List.IsPrefix.isInfix #align list.is_suffix.is_infix List.IsSuffix.isInfix #align list.nil_prefix List.nil_prefix #align list.nil_suffix List.nil_suffix #align list.nil_infix List.nil_infix #align list.prefix_refl List.prefix_refl #align list.suffix_refl List.suffix_refl #align list.infix_refl List.infix_refl theorem prefix_rfl : l <+: l := prefix_refl _ #align list.prefix_rfl List.prefix_rfl theorem suffix_rfl : l <:+ l := suffix_refl _ #align list.suffix_rfl List.suffix_rfl theorem infix_rfl : l <:+: l := infix_refl _ #align list.infix_rfl List.infix_rfl #align list.suffix_cons List.suffix_cons theorem prefix_concat (a : α) (l) : l <+: concat l a := by simp #align list.prefix_concat List.prefix_concat theorem prefix_concat_iff {l₁ l₂ : List α} {a : α} : l₁ <+: l₂ ++ [a] ↔ l₁ = l₂ ++ [a] ∨ l₁ <+: l₂ := by simpa only [← reverse_concat', reverse_inj, reverse_suffix] using suffix_cons_iff (l₁ := l₁.reverse) (l₂ := l₂.reverse) #align list.infix_cons List.infix_cons #align list.infix_concat List.infix_concat #align list.is_prefix.trans List.IsPrefix.trans #align list.is_suffix.trans List.IsSuffix.trans #align list.is_infix.trans List.IsInfix.trans #align list.is_infix.sublist List.IsInfix.sublist #align list.is_infix.subset List.IsInfix.subset #align list.is_prefix.sublist List.IsPrefix.sublist #align list.is_prefix.subset List.IsPrefix.subset #align list.is_suffix.sublist List.IsSuffix.sublist #align list.is_suffix.subset List.IsSuffix.subset #align list.reverse_suffix List.reverse_suffix #align list.reverse_prefix List.reverse_prefix #align list.reverse_infix List.reverse_infix protected alias ⟨_, isSuffix.reverse⟩ := reverse_prefix #align list.is_suffix.reverse List.isSuffix.reverse protected alias ⟨_, isPrefix.reverse⟩ := reverse_suffix #align list.is_prefix.reverse List.isPrefix.reverse protected alias ⟨_, isInfix.reverse⟩ := reverse_infix #align list.is_infix.reverse List.isInfix.reverse #align list.is_infix.length_le List.IsInfix.length_le #align list.is_prefix.length_le List.IsPrefix.length_le #align list.is_suffix.length_le List.IsSuffix.length_le #align list.infix_nil_iff List.infix_nil #align list.prefix_nil_iff List.prefix_nil #align list.suffix_nil_iff List.suffix_nil alias ⟨eq_nil_of_infix_nil, _⟩ := infix_nil #align list.eq_nil_of_infix_nil List.eq_nil_of_infix_nil alias ⟨eq_nil_of_prefix_nil, _⟩ := prefix_nil #align list.eq_nil_of_prefix_nil List.eq_nil_of_prefix_nil alias ⟨eq_nil_of_suffix_nil, _⟩ := suffix_nil #align list.eq_nil_of_suffix_nil List.eq_nil_of_suffix_nil #align list.infix_iff_prefix_suffix List.infix_iff_prefix_suffix theorem eq_of_infix_of_length_eq (h : l₁ <:+: l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length #align list.eq_of_infix_of_length_eq List.eq_of_infix_of_length_eq theorem eq_of_prefix_of_length_eq (h : l₁ <+: l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length #align list.eq_of_prefix_of_length_eq List.eq_of_prefix_of_length_eq theorem eq_of_suffix_of_length_eq (h : l₁ <:+ l₂) : l₁.length = l₂.length → l₁ = l₂ := h.sublist.eq_of_length #align list.eq_of_suffix_of_length_eq List.eq_of_suffix_of_length_eq #align list.prefix_of_prefix_length_le List.prefix_of_prefix_length_le #align list.prefix_or_prefix_of_prefix List.prefix_or_prefix_of_prefix #align list.suffix_of_suffix_length_le List.suffix_of_suffix_length_le #align list.suffix_or_suffix_of_suffix List.suffix_or_suffix_of_suffix #align list.suffix_cons_iff List.suffix_cons_iff #align list.infix_cons_iff List.infix_cons_iff #align list.infix_of_mem_join List.infix_of_mem_join #align list.prefix_append_right_inj List.prefix_append_right_inj #align list.prefix_cons_inj List.prefix_cons_inj #align list.take_prefix List.take_prefix #align list.drop_suffix List.drop_suffix #align list.take_sublist List.take_sublist #align list.drop_sublist List.drop_sublist #align list.take_subset List.take_subset #align list.drop_subset List.drop_subset #align list.mem_of_mem_take List.mem_of_mem_take #align list.mem_of_mem_drop List.mem_of_mem_drop lemma dropSlice_sublist (n m : ℕ) (l : List α) : l.dropSlice n m <+ l := calc l.dropSlice n m = take n l ++ drop m (drop n l) := by rw [dropSlice_eq, drop_drop, Nat.add_comm] _ <+ take n l ++ drop n l := (Sublist.refl _).append (drop_sublist _ _) _ = _ := take_append_drop _ _ #align list.slice_sublist List.dropSlice_sublist lemma dropSlice_subset (n m : ℕ) (l : List α) : l.dropSlice n m ⊆ l := (dropSlice_sublist n m l).subset #align list.slice_subset List.dropSlice_subset lemma mem_of_mem_dropSlice {n m : ℕ} {l : List α} {a : α} (h : a ∈ l.dropSlice n m) : a ∈ l := dropSlice_subset n m l h #align list.mem_of_mem_slice List.mem_of_mem_dropSlice theorem takeWhile_prefix (p : α → Bool) : l.takeWhile p <+: l := ⟨l.dropWhile p, takeWhile_append_dropWhile p l⟩ #align list.take_while_prefix List.takeWhile_prefix theorem dropWhile_suffix (p : α → Bool) : l.dropWhile p <:+ l := ⟨l.takeWhile p, takeWhile_append_dropWhile p l⟩ #align list.drop_while_suffix List.dropWhile_suffix theorem dropLast_prefix : ∀ l : List α, l.dropLast <+: l | [] => ⟨nil, by rw [dropLast, List.append_nil]⟩ | a :: l => ⟨_, dropLast_append_getLast (cons_ne_nil a l)⟩ #align list.init_prefix List.dropLast_prefix
Mathlib/Data/List/Infix.lean
178
178
theorem tail_suffix (l : List α) : tail l <:+ l := by
rw [← drop_one]; apply drop_suffix
/- Copyright (c) 2022 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Topology.EMetricSpace.Paracompact import Mathlib.Topology.Instances.ENNReal import Mathlib.Analysis.Convex.PartitionOfUnity #align_import topology.metric_space.partition_of_unity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Lemmas about (e)metric spaces that need partition of unity The main lemma in this file (see `Metric.exists_continuous_real_forall_closedBall_subset`) says the following. Let `X` be a metric space. Let `K : ι → Set X` be a locally finite family of closed sets, let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then there exists a positive continuous function `δ : C(X, → ℝ)` such that for any `i` and `x ∈ K i`, we have `Metric.closedBall x (δ x) ⊆ U i`. We also formulate versions of this lemma for extended metric spaces and for different codomains (`ℝ`, `ℝ≥0`, and `ℝ≥0∞`). We also prove a few auxiliary lemmas to be used later in a proof of the smooth version of this lemma. ## Tags metric space, partition of unity, locally finite -/ open Topology ENNReal NNReal Filter Set Function TopologicalSpace variable {ι X : Type*} namespace EMetric variable [EMetricSpace X] {K : ι → Set X} {U : ι → Set X} /-- Let `K : ι → Set X` be a locally finite family of closed sets in an emetric space. Let `U : ι → Set X` be a family of open sets such that `K i ⊆ U i` for all `i`. Then for any point `x : X`, for sufficiently small `r : ℝ≥0∞` and for `y` sufficiently close to `x`, for all `i`, if `y ∈ K i`, then `EMetric.closedBall y r ⊆ U i`. -/ theorem eventually_nhds_zero_forall_closedBall_subset (hK : ∀ i, IsClosed (K i)) (hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) (x : X) : ∀ᶠ p : ℝ≥0∞ × X in 𝓝 0 ×ˢ 𝓝 x, ∀ i, p.2 ∈ K i → closedBall p.2 p.1 ⊆ U i := by suffices ∀ i, x ∈ K i → ∀ᶠ p : ℝ≥0∞ × X in 𝓝 0 ×ˢ 𝓝 x, closedBall p.2 p.1 ⊆ U i by apply mp_mem ((eventually_all_finite (hfin.point_finite x)).2 this) (mp_mem (@tendsto_snd ℝ≥0∞ _ (𝓝 0) _ _ (hfin.iInter_compl_mem_nhds hK x)) _) apply univ_mem' rintro ⟨r, y⟩ hxy hyU i hi simp only [mem_iInter, mem_compl_iff, not_imp_not, mem_preimage] at hxy exact hyU _ (hxy _ hi) intro i hi rcases nhds_basis_closed_eball.mem_iff.1 ((hU i).mem_nhds <| hKU i hi) with ⟨R, hR₀, hR⟩ rcases ENNReal.lt_iff_exists_nnreal_btwn.mp hR₀ with ⟨r, hr₀, hrR⟩ filter_upwards [prod_mem_prod (eventually_lt_nhds hr₀) (closedBall_mem_nhds x (tsub_pos_iff_lt.2 hrR))] with p hp z hz apply hR calc edist z x ≤ edist z p.2 + edist p.2 x := edist_triangle _ _ _ _ ≤ p.1 + (R - p.1) := add_le_add hz <| le_trans hp.2 <| tsub_le_tsub_left hp.1.out.le _ _ = R := add_tsub_cancel_of_le (lt_trans (by exact hp.1) hrR).le #align emetric.eventually_nhds_zero_forall_closed_ball_subset EMetric.eventually_nhds_zero_forall_closedBall_subset
Mathlib/Topology/MetricSpace/PartitionOfUnity.lean
64
72
theorem exists_forall_closedBall_subset_aux₁ (hK : ∀ i, IsClosed (K i)) (hU : ∀ i, IsOpen (U i)) (hKU : ∀ i, K i ⊆ U i) (hfin : LocallyFinite K) (x : X) : ∃ r : ℝ, ∀ᶠ y in 𝓝 x, r ∈ Ioi (0 : ℝ) ∩ ENNReal.ofReal ⁻¹' ⋂ (i) (_ : y ∈ K i), { r | closedBall y r ⊆ U i } := by
have := (ENNReal.continuous_ofReal.tendsto' 0 0 ENNReal.ofReal_zero).eventually (eventually_nhds_zero_forall_closedBall_subset hK hU hKU hfin x).curry rcases this.exists_gt with ⟨r, hr0, hr⟩ refine ⟨r, hr.mono fun y hy => ⟨hr0, ?_⟩⟩ rwa [mem_preimage, mem_iInter₂]
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Oriented angles. This file defines oriented angles in real inner product spaces. ## Main definitions * `Orientation.oangle` is the oriented angle between two vectors with respect to an orientation. ## Implementation notes The definitions here use the `Real.angle` type, angles modulo `2 * π`. For some purposes, angles modulo `π` are more convenient, because results are true for such angles with less configuration dependence. Results that are only equalities modulo `π` can be represented modulo `2 * π` as equalities of `(2 : ℤ) • θ`. ## References * Evan Chen, Euclidean Geometry in Mathematical Olympiads. -/ 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 /-- The oriented angle from `x` to `y`, modulo `2 * π`. If either vector is 0, this is 0. See `InnerProductGeometry.angle` for the corresponding unoriented angle definition. -/ def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle /-- Oriented angles are continuous when the vectors involved are nonzero. -/ 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 /-- If the first vector passed to `oangle` is 0, the result is 0. -/ @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left /-- If the second vector passed to `oangle` is 0, the result is 0. -/ @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right /-- If the two vectors passed to `oangle` are the same, the result is 0. -/ @[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 /-- If the angle between two vectors is nonzero, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is nonzero, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is nonzero, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `π`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `π`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `π`, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `π / 2`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `π / 2`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `π / 2`, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `-π / 2`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `-π / 2`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `-π / 2`, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is positive, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is positive, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is positive, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is negative, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is negative, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is negative, the vectors are not equal. -/ 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 /-- Swapping the two vectors passed to `oangle` negates the angle. -/ 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 /-- Adding the angles between two vectors in each order results in 0. -/ @[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 /-- Negating the first vector passed to `oangle` adds `π` to the angle. -/ 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 /-- Negating the second vector passed to `oangle` adds `π` to the angle. -/ 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 /-- Negating the first vector passed to `oangle` does not change twice the angle. -/ @[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 /-- Negating the second vector passed to `oangle` does not change twice the angle. -/ @[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 /-- Negating both vectors passed to `oangle` does not change the angle. -/ @[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 /-- Negating the first vector produces the same angle as negating the second vector. -/ 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 /-- The angle between the negation of a nonzero vector and that vector is `π`. -/ @[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 /-- The angle between a nonzero vector and its negation is `π`. -/ @[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 /-- Twice the angle between the negation of a vector and that vector is 0. -/ -- @[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 /-- Twice the angle between a vector and its negation is 0. -/ -- @[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 /-- Adding the angles between two vectors in each order, with the first vector in each angle negated, results in 0. -/ @[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 /-- Adding the angles between two vectors in each order, with the second vector in each angle negated, results in 0. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a positive real does not change the angle. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a positive real does not change the angle. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a negative real produces the same angle as negating that vector. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a negative real produces the same angle as negating that vector. -/ @[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 /-- The angle between a nonnegative multiple of a vector and that vector is 0. -/ @[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 /-- The angle between a vector and a nonnegative multiple of that vector is 0. -/ @[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 /-- The angle between two nonnegative multiples of the same vector is 0. -/ @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
337
341
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]
/- Copyright (c) 2021 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Order.Interval.Multiset #align_import data.nat.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29" /-! # Finite intervals of naturals This file proves that `ℕ` is a `LocallyFiniteOrder` and calculates the cardinality of its intervals as finsets and fintypes. ## TODO Some lemmas can be generalized using `OrderedGroup`, `CanonicallyOrderedCommMonoid` or `SuccOrder` and subsequently be moved upstream to `Order.Interval.Finset`. -/ -- TODO -- assert_not_exists Ring open Finset Nat variable (a b c : ℕ) namespace Nat instance instLocallyFiniteOrder : LocallyFiniteOrder ℕ where finsetIcc a b := ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ finsetIco a b := ⟨List.range' a (b - a), List.nodup_range' _ _⟩ finsetIoc a b := ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ finsetIoo a b := ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ finset_mem_Icc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ico a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioc a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega finset_mem_Ioo a b x := by rw [Finset.mem_mk, Multiset.mem_coe, List.mem_range'_1]; omega theorem Icc_eq_range' : Icc a b = ⟨List.range' a (b + 1 - a), List.nodup_range' _ _⟩ := rfl #align nat.Icc_eq_range' Nat.Icc_eq_range' theorem Ico_eq_range' : Ico a b = ⟨List.range' a (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ico_eq_range' Nat.Ico_eq_range' theorem Ioc_eq_range' : Ioc a b = ⟨List.range' (a + 1) (b - a), List.nodup_range' _ _⟩ := rfl #align nat.Ioc_eq_range' Nat.Ioc_eq_range' theorem Ioo_eq_range' : Ioo a b = ⟨List.range' (a + 1) (b - a - 1), List.nodup_range' _ _⟩ := rfl #align nat.Ioo_eq_range' Nat.Ioo_eq_range' theorem uIcc_eq_range' : uIcc a b = ⟨List.range' (min a b) (max a b + 1 - min a b), List.nodup_range' _ _⟩ := rfl #align nat.uIcc_eq_range' Nat.uIcc_eq_range' theorem Iio_eq_range : Iio = range := by ext b x rw [mem_Iio, mem_range] #align nat.Iio_eq_range Nat.Iio_eq_range @[simp] theorem Ico_zero_eq_range : Ico 0 = range := by rw [← Nat.bot_eq_zero, ← Iio_eq_Ico, Iio_eq_range] #align nat.Ico_zero_eq_range Nat.Ico_zero_eq_range lemma range_eq_Icc_zero_sub_one (n : ℕ) (hn : n ≠ 0): range n = Icc 0 (n - 1) := by ext b simp_all only [mem_Icc, zero_le, true_and, mem_range] exact lt_iff_le_pred (zero_lt_of_ne_zero hn) theorem _root_.Finset.range_eq_Ico : range = Ico 0 := Ico_zero_eq_range.symm #align finset.range_eq_Ico Finset.range_eq_Ico @[simp] theorem card_Icc : (Icc a b).card = b + 1 - a := List.length_range' _ _ _ #align nat.card_Icc Nat.card_Icc @[simp] theorem card_Ico : (Ico a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ico Nat.card_Ico @[simp] theorem card_Ioc : (Ioc a b).card = b - a := List.length_range' _ _ _ #align nat.card_Ioc Nat.card_Ioc @[simp] theorem card_Ioo : (Ioo a b).card = b - a - 1 := List.length_range' _ _ _ #align nat.card_Ioo Nat.card_Ioo @[simp] theorem card_uIcc : (uIcc a b).card = (b - a : ℤ).natAbs + 1 := (card_Icc _ _).trans $ by rw [← Int.natCast_inj, sup_eq_max, inf_eq_min, Int.ofNat_sub] <;> omega #align nat.card_uIcc Nat.card_uIcc @[simp] lemma card_Iic : (Iic b).card = b + 1 := by rw [Iic_eq_Icc, card_Icc, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iic Nat.card_Iic @[simp] theorem card_Iio : (Iio b).card = b := by rw [Iio_eq_Ico, card_Ico, Nat.bot_eq_zero, Nat.sub_zero] #align nat.card_Iio Nat.card_Iio -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIcc : Fintype.card (Set.Icc a b) = b + 1 - a := by rw [Fintype.card_ofFinset, card_Icc] #align nat.card_fintype_Icc Nat.card_fintypeIcc -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIco : Fintype.card (Set.Ico a b) = b - a := by rw [Fintype.card_ofFinset, card_Ico] #align nat.card_fintype_Ico Nat.card_fintypeIco -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIoc : Fintype.card (Set.Ioc a b) = b - a := by rw [Fintype.card_ofFinset, card_Ioc] #align nat.card_fintype_Ioc Nat.card_fintypeIoc -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIoo : Fintype.card (Set.Ioo a b) = b - a - 1 := by rw [Fintype.card_ofFinset, card_Ioo] #align nat.card_fintype_Ioo Nat.card_fintypeIoo -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIic : Fintype.card (Set.Iic b) = b + 1 := by rw [Fintype.card_ofFinset, card_Iic] #align nat.card_fintype_Iic Nat.card_fintypeIic -- Porting note (#10618): simp can prove this -- @[simp] theorem card_fintypeIio : Fintype.card (Set.Iio b) = b := by rw [Fintype.card_ofFinset, card_Iio] #align nat.card_fintype_Iio Nat.card_fintypeIio -- TODO@Yaël: Generalize all the following lemmas to `SuccOrder` theorem Icc_succ_left : Icc a.succ b = Ioc a b := by ext x rw [mem_Icc, mem_Ioc, succ_le_iff] #align nat.Icc_succ_left Nat.Icc_succ_left theorem Ico_succ_right : Ico a b.succ = Icc a b := by ext x rw [mem_Ico, mem_Icc, Nat.lt_succ_iff] #align nat.Ico_succ_right Nat.Ico_succ_right theorem Ico_succ_left : Ico a.succ b = Ioo a b := by ext x rw [mem_Ico, mem_Ioo, succ_le_iff] #align nat.Ico_succ_left Nat.Ico_succ_left theorem Icc_pred_right {b : ℕ} (h : 0 < b) : Icc a (b - 1) = Ico a b := by ext x rw [mem_Icc, mem_Ico, lt_iff_le_pred h] #align nat.Icc_pred_right Nat.Icc_pred_right theorem Ico_succ_succ : Ico a.succ b.succ = Ioc a b := by ext x rw [mem_Ico, mem_Ioc, succ_le_iff, Nat.lt_succ_iff] #align nat.Ico_succ_succ Nat.Ico_succ_succ @[simp] theorem Ico_succ_singleton : Ico a (a + 1) = {a} := by rw [Ico_succ_right, Icc_self] #align nat.Ico_succ_singleton Nat.Ico_succ_singleton @[simp] theorem Ico_pred_singleton {a : ℕ} (h : 0 < a) : Ico (a - 1) a = {a - 1} := by rw [← Icc_pred_right _ h, Icc_self] #align nat.Ico_pred_singleton Nat.Ico_pred_singleton @[simp] theorem Ioc_succ_singleton : Ioc b (b + 1) = {b + 1} := by rw [← Nat.Icc_succ_left, Icc_self] #align nat.Ioc_succ_singleton Nat.Ioc_succ_singleton variable {a b c} theorem Ico_succ_right_eq_insert_Ico (h : a ≤ b) : Ico a (b + 1) = insert b (Ico a b) := by rw [Ico_succ_right, ← Ico_insert_right h] #align nat.Ico_succ_right_eq_insert_Ico Nat.Ico_succ_right_eq_insert_Ico theorem Ico_insert_succ_left (h : a < b) : insert a (Ico a.succ b) = Ico a b := by rw [Ico_succ_left, ← Ioo_insert_left h] #align nat.Ico_insert_succ_left Nat.Ico_insert_succ_left theorem image_sub_const_Ico (h : c ≤ a) : ((Ico a b).image fun x => x - c) = Ico (a - c) (b - c) := by ext x simp_rw [mem_image, mem_Ico] refine ⟨?_, fun h ↦ ⟨x + c, by omega⟩⟩ rintro ⟨x, hx, rfl⟩ omega #align nat.image_sub_const_Ico Nat.image_sub_const_Ico
Mathlib/Order/Interval/Finset/Nat.lean
205
211
theorem Ico_image_const_sub_eq_Ico (hac : a ≤ c) : ((Ico a b).image fun x => c - x) = Ico (c + 1 - b) (c + 1 - a) := by
ext x simp_rw [mem_image, mem_Ico] refine ⟨?_, fun h ↦ ⟨c - x, by omega⟩⟩ rintro ⟨x, hx, rfl⟩ omega
/- Copyright (c) 2021 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Algebra.GroupWithZero.Indicator import Mathlib.Topology.ContinuousOn import Mathlib.Topology.Instances.ENNReal #align_import topology.semicontinuous from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Semicontinuous maps A function `f` from a topological space `α` to an ordered space `β` is lower semicontinuous at a point `x` if, for any `y < f x`, for any `x'` close enough to `x`, one has `f x' > y`. In other words, `f` can jump up, but it can not jump down. Upper semicontinuous functions are defined similarly. This file introduces these notions, and a basic API around them mimicking the API for continuous functions. ## Main definitions and results We introduce 4 definitions related to lower semicontinuity: * `LowerSemicontinuousWithinAt f s x` * `LowerSemicontinuousAt f x` * `LowerSemicontinuousOn f s` * `LowerSemicontinuous f` We build a basic API using dot notation around these notions, and we prove that * constant functions are lower semicontinuous; * `indicator s (fun _ ↦ y)` is lower semicontinuous when `s` is open and `0 ≤ y`, or when `s` is closed and `y ≤ 0`; * continuous functions are lower semicontinuous; * left composition with a continuous monotone functions maps lower semicontinuous functions to lower semicontinuous functions. If the function is anti-monotone, it instead maps lower semicontinuous functions to upper semicontinuous functions; * right composition with continuous functions preserves lower and upper semicontinuity; * a sum of two (or finitely many) lower semicontinuous functions is lower semicontinuous; * a supremum of a family of lower semicontinuous functions is lower semicontinuous; * An infinite sum of `ℝ≥0∞`-valued lower semicontinuous functions is lower semicontinuous. Similar results are stated and proved for upper semicontinuity. We also prove that a function is continuous if and only if it is both lower and upper semicontinuous. We have some equivalent definitions of lower- and upper-semicontinuity (under certain restrictions on the order on the codomain): * `lowerSemicontinuous_iff_isOpen_preimage` in a linear order; * `lowerSemicontinuous_iff_isClosed_preimage` in a linear order; * `lowerSemicontinuousAt_iff_le_liminf` in a dense complete linear order; * `lowerSemicontinuous_iff_isClosed_epigraph` in a dense complete linear order with the order topology. ## Implementation details All the nontrivial results for upper semicontinuous functions are deduced from the corresponding ones for lower semicontinuous functions using `OrderDual`. ## References * <https://en.wikipedia.org/wiki/Closed_convex_function> * <https://en.wikipedia.org/wiki/Semi-continuity> -/ open Topology ENNReal open Set Function Filter variable {α : Type*} [TopologicalSpace α] {β : Type*} [Preorder β] {f g : α → β} {x : α} {s t : Set α} {y z : β} /-! ### Main definitions -/ /-- A real function `f` is lower semicontinuous at `x` within a set `s` if, for any `ε > 0`, for all `x'` close enough to `x` in `s`, then `f x'` is at least `f x - ε`. We formulate this in a general preordered space, using an arbitrary `y < f x` instead of `f x - ε`. -/ def LowerSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) := ∀ y < f x, ∀ᶠ x' in 𝓝[s] x, y < f x' #align lower_semicontinuous_within_at LowerSemicontinuousWithinAt /-- A real function `f` is lower semicontinuous on a set `s` if, for any `ε > 0`, for any `x ∈ s`, for all `x'` close enough to `x` in `s`, then `f x'` is at least `f x - ε`. We formulate this in a general preordered space, using an arbitrary `y < f x` instead of `f x - ε`. -/ def LowerSemicontinuousOn (f : α → β) (s : Set α) := ∀ x ∈ s, LowerSemicontinuousWithinAt f s x #align lower_semicontinuous_on LowerSemicontinuousOn /-- A real function `f` is lower semicontinuous at `x` if, for any `ε > 0`, for all `x'` close enough to `x`, then `f x'` is at least `f x - ε`. We formulate this in a general preordered space, using an arbitrary `y < f x` instead of `f x - ε`. -/ def LowerSemicontinuousAt (f : α → β) (x : α) := ∀ y < f x, ∀ᶠ x' in 𝓝 x, y < f x' #align lower_semicontinuous_at LowerSemicontinuousAt /-- A real function `f` is lower semicontinuous if, for any `ε > 0`, for any `x`, for all `x'` close enough to `x`, then `f x'` is at least `f x - ε`. We formulate this in a general preordered space, using an arbitrary `y < f x` instead of `f x - ε`. -/ def LowerSemicontinuous (f : α → β) := ∀ x, LowerSemicontinuousAt f x #align lower_semicontinuous LowerSemicontinuous /-- A real function `f` is upper semicontinuous at `x` within a set `s` if, for any `ε > 0`, for all `x'` close enough to `x` in `s`, then `f x'` is at most `f x + ε`. We formulate this in a general preordered space, using an arbitrary `y > f x` instead of `f x + ε`. -/ def UpperSemicontinuousWithinAt (f : α → β) (s : Set α) (x : α) := ∀ y, f x < y → ∀ᶠ x' in 𝓝[s] x, f x' < y #align upper_semicontinuous_within_at UpperSemicontinuousWithinAt /-- A real function `f` is upper semicontinuous on a set `s` if, for any `ε > 0`, for any `x ∈ s`, for all `x'` close enough to `x` in `s`, then `f x'` is at most `f x + ε`. We formulate this in a general preordered space, using an arbitrary `y > f x` instead of `f x + ε`. -/ def UpperSemicontinuousOn (f : α → β) (s : Set α) := ∀ x ∈ s, UpperSemicontinuousWithinAt f s x #align upper_semicontinuous_on UpperSemicontinuousOn /-- A real function `f` is upper semicontinuous at `x` if, for any `ε > 0`, for all `x'` close enough to `x`, then `f x'` is at most `f x + ε`. We formulate this in a general preordered space, using an arbitrary `y > f x` instead of `f x + ε`. -/ def UpperSemicontinuousAt (f : α → β) (x : α) := ∀ y, f x < y → ∀ᶠ x' in 𝓝 x, f x' < y #align upper_semicontinuous_at UpperSemicontinuousAt /-- A real function `f` is upper semicontinuous if, for any `ε > 0`, for any `x`, for all `x'` close enough to `x`, then `f x'` is at most `f x + ε`. We formulate this in a general preordered space, using an arbitrary `y > f x` instead of `f x + ε`. -/ def UpperSemicontinuous (f : α → β) := ∀ x, UpperSemicontinuousAt f x #align upper_semicontinuous UpperSemicontinuous /-! ### Lower semicontinuous functions -/ /-! #### Basic dot notation interface for lower semicontinuity -/ theorem LowerSemicontinuousWithinAt.mono (h : LowerSemicontinuousWithinAt f s x) (hst : t ⊆ s) : LowerSemicontinuousWithinAt f t x := fun y hy => Filter.Eventually.filter_mono (nhdsWithin_mono _ hst) (h y hy) #align lower_semicontinuous_within_at.mono LowerSemicontinuousWithinAt.mono theorem lowerSemicontinuousWithinAt_univ_iff : LowerSemicontinuousWithinAt f univ x ↔ LowerSemicontinuousAt f x := by simp [LowerSemicontinuousWithinAt, LowerSemicontinuousAt, nhdsWithin_univ] #align lower_semicontinuous_within_at_univ_iff lowerSemicontinuousWithinAt_univ_iff theorem LowerSemicontinuousAt.lowerSemicontinuousWithinAt (s : Set α) (h : LowerSemicontinuousAt f x) : LowerSemicontinuousWithinAt f s x := fun y hy => Filter.Eventually.filter_mono nhdsWithin_le_nhds (h y hy) #align lower_semicontinuous_at.lower_semicontinuous_within_at LowerSemicontinuousAt.lowerSemicontinuousWithinAt theorem LowerSemicontinuousOn.lowerSemicontinuousWithinAt (h : LowerSemicontinuousOn f s) (hx : x ∈ s) : LowerSemicontinuousWithinAt f s x := h x hx #align lower_semicontinuous_on.lower_semicontinuous_within_at LowerSemicontinuousOn.lowerSemicontinuousWithinAt theorem LowerSemicontinuousOn.mono (h : LowerSemicontinuousOn f s) (hst : t ⊆ s) : LowerSemicontinuousOn f t := fun x hx => (h x (hst hx)).mono hst #align lower_semicontinuous_on.mono LowerSemicontinuousOn.mono theorem lowerSemicontinuousOn_univ_iff : LowerSemicontinuousOn f univ ↔ LowerSemicontinuous f := by simp [LowerSemicontinuousOn, LowerSemicontinuous, lowerSemicontinuousWithinAt_univ_iff] #align lower_semicontinuous_on_univ_iff lowerSemicontinuousOn_univ_iff theorem LowerSemicontinuous.lowerSemicontinuousAt (h : LowerSemicontinuous f) (x : α) : LowerSemicontinuousAt f x := h x #align lower_semicontinuous.lower_semicontinuous_at LowerSemicontinuous.lowerSemicontinuousAt theorem LowerSemicontinuous.lowerSemicontinuousWithinAt (h : LowerSemicontinuous f) (s : Set α) (x : α) : LowerSemicontinuousWithinAt f s x := (h x).lowerSemicontinuousWithinAt s #align lower_semicontinuous.lower_semicontinuous_within_at LowerSemicontinuous.lowerSemicontinuousWithinAt theorem LowerSemicontinuous.lowerSemicontinuousOn (h : LowerSemicontinuous f) (s : Set α) : LowerSemicontinuousOn f s := fun x _hx => h.lowerSemicontinuousWithinAt s x #align lower_semicontinuous.lower_semicontinuous_on LowerSemicontinuous.lowerSemicontinuousOn /-! #### Constants -/ theorem lowerSemicontinuousWithinAt_const : LowerSemicontinuousWithinAt (fun _x => z) s x := fun _y hy => Filter.eventually_of_forall fun _x => hy #align lower_semicontinuous_within_at_const lowerSemicontinuousWithinAt_const theorem lowerSemicontinuousAt_const : LowerSemicontinuousAt (fun _x => z) x := fun _y hy => Filter.eventually_of_forall fun _x => hy #align lower_semicontinuous_at_const lowerSemicontinuousAt_const theorem lowerSemicontinuousOn_const : LowerSemicontinuousOn (fun _x => z) s := fun _x _hx => lowerSemicontinuousWithinAt_const #align lower_semicontinuous_on_const lowerSemicontinuousOn_const theorem lowerSemicontinuous_const : LowerSemicontinuous fun _x : α => z := fun _x => lowerSemicontinuousAt_const #align lower_semicontinuous_const lowerSemicontinuous_const /-! #### Indicators -/ section variable [Zero β] theorem IsOpen.lowerSemicontinuous_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuous (indicator s fun _x => y) := by intro x z hz by_cases h : x ∈ s <;> simp [h] at hz · filter_upwards [hs.mem_nhds h] simp (config := { contextual := true }) [hz] · refine Filter.eventually_of_forall fun x' => ?_ by_cases h' : x' ∈ s <;> simp [h', hz.trans_le hy, hz] #align is_open.lower_semicontinuous_indicator IsOpen.lowerSemicontinuous_indicator theorem IsOpen.lowerSemicontinuousOn_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousOn (indicator s fun _x => y) t := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t #align is_open.lower_semicontinuous_on_indicator IsOpen.lowerSemicontinuousOn_indicator theorem IsOpen.lowerSemicontinuousAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousAt (indicator s fun _x => y) x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x #align is_open.lower_semicontinuous_at_indicator IsOpen.lowerSemicontinuousAt_indicator theorem IsOpen.lowerSemicontinuousWithinAt_indicator (hs : IsOpen s) (hy : 0 ≤ y) : LowerSemicontinuousWithinAt (indicator s fun _x => y) t x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x #align is_open.lower_semicontinuous_within_at_indicator IsOpen.lowerSemicontinuousWithinAt_indicator theorem IsClosed.lowerSemicontinuous_indicator (hs : IsClosed s) (hy : y ≤ 0) : LowerSemicontinuous (indicator s fun _x => y) := by intro x z hz by_cases h : x ∈ s <;> simp [h] at hz · refine Filter.eventually_of_forall fun x' => ?_ by_cases h' : x' ∈ s <;> simp [h', hz, hz.trans_le hy] · filter_upwards [hs.isOpen_compl.mem_nhds h] simp (config := { contextual := true }) [hz] #align is_closed.lower_semicontinuous_indicator IsClosed.lowerSemicontinuous_indicator theorem IsClosed.lowerSemicontinuousOn_indicator (hs : IsClosed s) (hy : y ≤ 0) : LowerSemicontinuousOn (indicator s fun _x => y) t := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousOn t #align is_closed.lower_semicontinuous_on_indicator IsClosed.lowerSemicontinuousOn_indicator theorem IsClosed.lowerSemicontinuousAt_indicator (hs : IsClosed s) (hy : y ≤ 0) : LowerSemicontinuousAt (indicator s fun _x => y) x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousAt x #align is_closed.lower_semicontinuous_at_indicator IsClosed.lowerSemicontinuousAt_indicator theorem IsClosed.lowerSemicontinuousWithinAt_indicator (hs : IsClosed s) (hy : y ≤ 0) : LowerSemicontinuousWithinAt (indicator s fun _x => y) t x := (hs.lowerSemicontinuous_indicator hy).lowerSemicontinuousWithinAt t x #align is_closed.lower_semicontinuous_within_at_indicator IsClosed.lowerSemicontinuousWithinAt_indicator end /-! #### Relationship with continuity -/ theorem lowerSemicontinuous_iff_isOpen_preimage : LowerSemicontinuous f ↔ ∀ y, IsOpen (f ⁻¹' Ioi y) := ⟨fun H y => isOpen_iff_mem_nhds.2 fun x hx => H x y hx, fun H _x y y_lt => IsOpen.mem_nhds (H y) y_lt⟩ #align lower_semicontinuous_iff_is_open_preimage lowerSemicontinuous_iff_isOpen_preimage theorem LowerSemicontinuous.isOpen_preimage (hf : LowerSemicontinuous f) (y : β) : IsOpen (f ⁻¹' Ioi y) := lowerSemicontinuous_iff_isOpen_preimage.1 hf y #align lower_semicontinuous.is_open_preimage LowerSemicontinuous.isOpen_preimage section variable {γ : Type*} [LinearOrder γ] theorem lowerSemicontinuous_iff_isClosed_preimage {f : α → γ} : LowerSemicontinuous f ↔ ∀ y, IsClosed (f ⁻¹' Iic y) := by rw [lowerSemicontinuous_iff_isOpen_preimage] simp only [← isOpen_compl_iff, ← preimage_compl, compl_Iic] #align lower_semicontinuous_iff_is_closed_preimage lowerSemicontinuous_iff_isClosed_preimage theorem LowerSemicontinuous.isClosed_preimage {f : α → γ} (hf : LowerSemicontinuous f) (y : γ) : IsClosed (f ⁻¹' Iic y) := lowerSemicontinuous_iff_isClosed_preimage.1 hf y #align lower_semicontinuous.is_closed_preimage LowerSemicontinuous.isClosed_preimage variable [TopologicalSpace γ] [OrderTopology γ] theorem ContinuousWithinAt.lowerSemicontinuousWithinAt {f : α → γ} (h : ContinuousWithinAt f s x) : LowerSemicontinuousWithinAt f s x := fun _y hy => h (Ioi_mem_nhds hy) #align continuous_within_at.lower_semicontinuous_within_at ContinuousWithinAt.lowerSemicontinuousWithinAt theorem ContinuousAt.lowerSemicontinuousAt {f : α → γ} (h : ContinuousAt f x) : LowerSemicontinuousAt f x := fun _y hy => h (Ioi_mem_nhds hy) #align continuous_at.lower_semicontinuous_at ContinuousAt.lowerSemicontinuousAt theorem ContinuousOn.lowerSemicontinuousOn {f : α → γ} (h : ContinuousOn f s) : LowerSemicontinuousOn f s := fun x hx => (h x hx).lowerSemicontinuousWithinAt #align continuous_on.lower_semicontinuous_on ContinuousOn.lowerSemicontinuousOn theorem Continuous.lowerSemicontinuous {f : α → γ} (h : Continuous f) : LowerSemicontinuous f := fun _x => h.continuousAt.lowerSemicontinuousAt #align continuous.lower_semicontinuous Continuous.lowerSemicontinuous end /-! #### Equivalent definitions -/ section variable {γ : Type*} [CompleteLinearOrder γ] [DenselyOrdered γ] theorem lowerSemicontinuousWithinAt_iff_le_liminf {f : α → γ} : LowerSemicontinuousWithinAt f s x ↔ f x ≤ liminf f (𝓝[s] x) := by constructor · intro hf; unfold LowerSemicontinuousWithinAt at hf contrapose! hf obtain ⟨y, lty, ylt⟩ := exists_between hf; use y exact ⟨ylt, fun h => lty.not_le (le_liminf_of_le (by isBoundedDefault) (h.mono fun _ hx => le_of_lt hx))⟩ exact fun hf y ylt => eventually_lt_of_lt_liminf (ylt.trans_le hf) alias ⟨LowerSemicontinuousWithinAt.le_liminf, _⟩ := lowerSemicontinuousWithinAt_iff_le_liminf theorem lowerSemicontinuousAt_iff_le_liminf {f : α → γ} : LowerSemicontinuousAt f x ↔ f x ≤ liminf f (𝓝 x) := by rw [← lowerSemicontinuousWithinAt_univ_iff, lowerSemicontinuousWithinAt_iff_le_liminf, ← nhdsWithin_univ] alias ⟨LowerSemicontinuousAt.le_liminf, _⟩ := lowerSemicontinuousAt_iff_le_liminf theorem lowerSemicontinuous_iff_le_liminf {f : α → γ} : LowerSemicontinuous f ↔ ∀ x, f x ≤ liminf f (𝓝 x) := by simp only [← lowerSemicontinuousAt_iff_le_liminf, LowerSemicontinuous] alias ⟨LowerSemicontinuous.le_liminf, _⟩ := lowerSemicontinuous_iff_le_liminf theorem lowerSemicontinuousOn_iff_le_liminf {f : α → γ} : LowerSemicontinuousOn f s ↔ ∀ x ∈ s, f x ≤ liminf f (𝓝[s] x) := by simp only [← lowerSemicontinuousWithinAt_iff_le_liminf, LowerSemicontinuousOn] alias ⟨LowerSemicontinuousOn.le_liminf, _⟩ := lowerSemicontinuousOn_iff_le_liminf variable [TopologicalSpace γ] [OrderTopology γ] theorem lowerSemicontinuous_iff_isClosed_epigraph {f : α → γ} : LowerSemicontinuous f ↔ IsClosed {p : α × γ | f p.1 ≤ p.2} := by constructor · rw [lowerSemicontinuous_iff_le_liminf, isClosed_iff_forall_filter] rintro hf ⟨x, y⟩ F F_ne h h' rw [nhds_prod_eq, le_prod] at h' calc f x ≤ liminf f (𝓝 x) := hf x _ ≤ liminf f (map Prod.fst F) := liminf_le_liminf_of_le h'.1 _ = liminf (f ∘ Prod.fst) F := (Filter.liminf_comp _ _ _).symm _ ≤ liminf Prod.snd F := liminf_le_liminf <| by simpa using (eventually_principal.2 fun (_ : α × γ) ↦ id).filter_mono h _ = y := h'.2.liminf_eq · rw [lowerSemicontinuous_iff_isClosed_preimage] exact fun hf y ↦ hf.preimage (Continuous.Prod.mk_left y) @[deprecated (since := "2024-03-02")] alias lowerSemicontinuous_iff_IsClosed_epigraph := lowerSemicontinuous_iff_isClosed_epigraph alias ⟨LowerSemicontinuous.isClosed_epigraph, _⟩ := lowerSemicontinuous_iff_isClosed_epigraph @[deprecated (since := "2024-03-02")] alias LowerSemicontinuous.IsClosed_epigraph := LowerSemicontinuous.isClosed_epigraph end /-! ### Composition -/ section variable {γ : Type*} [LinearOrder γ] [TopologicalSpace γ] [OrderTopology γ] variable {δ : Type*} [LinearOrder δ] [TopologicalSpace δ] [OrderTopology δ] variable {ι : Type*} [TopologicalSpace ι] theorem ContinuousAt.comp_lowerSemicontinuousWithinAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Monotone g) : LowerSemicontinuousWithinAt (g ∘ f) s x := by intro y hy by_cases h : ∃ l, l < f x · obtain ⟨z, zlt, hz⟩ : ∃ z < f x, Ioc z (f x) ⊆ g ⁻¹' Ioi y := exists_Ioc_subset_of_mem_nhds (hg (Ioi_mem_nhds hy)) h filter_upwards [hf z zlt] with a ha calc y < g (min (f x) (f a)) := hz (by simp [zlt, ha, le_refl]) _ ≤ g (f a) := gmon (min_le_right _ _) · simp only [not_exists, not_lt] at h exact Filter.eventually_of_forall fun a => hy.trans_le (gmon (h (f a))) #align continuous_at.comp_lower_semicontinuous_within_at ContinuousAt.comp_lowerSemicontinuousWithinAt theorem ContinuousAt.comp_lowerSemicontinuousAt {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousAt f x) (gmon : Monotone g) : LowerSemicontinuousAt (g ∘ f) x := by simp only [← lowerSemicontinuousWithinAt_univ_iff] at hf ⊢ exact hg.comp_lowerSemicontinuousWithinAt hf gmon #align continuous_at.comp_lower_semicontinuous_at ContinuousAt.comp_lowerSemicontinuousAt theorem Continuous.comp_lowerSemicontinuousOn {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : LowerSemicontinuousOn f s) (gmon : Monotone g) : LowerSemicontinuousOn (g ∘ f) s := fun x hx => hg.continuousAt.comp_lowerSemicontinuousWithinAt (hf x hx) gmon #align continuous.comp_lower_semicontinuous_on Continuous.comp_lowerSemicontinuousOn theorem Continuous.comp_lowerSemicontinuous {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : LowerSemicontinuous f) (gmon : Monotone g) : LowerSemicontinuous (g ∘ f) := fun x => hg.continuousAt.comp_lowerSemicontinuousAt (hf x) gmon #align continuous.comp_lower_semicontinuous Continuous.comp_lowerSemicontinuous theorem ContinuousAt.comp_lowerSemicontinuousWithinAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousWithinAt f s x) (gmon : Antitone g) : UpperSemicontinuousWithinAt (g ∘ f) s x := @ContinuousAt.comp_lowerSemicontinuousWithinAt α _ x s γ _ _ _ δᵒᵈ _ _ _ g f hg hf gmon #align continuous_at.comp_lower_semicontinuous_within_at_antitone ContinuousAt.comp_lowerSemicontinuousWithinAt_antitone theorem ContinuousAt.comp_lowerSemicontinuousAt_antitone {g : γ → δ} {f : α → γ} (hg : ContinuousAt g (f x)) (hf : LowerSemicontinuousAt f x) (gmon : Antitone g) : UpperSemicontinuousAt (g ∘ f) x := @ContinuousAt.comp_lowerSemicontinuousAt α _ x γ _ _ _ δᵒᵈ _ _ _ g f hg hf gmon #align continuous_at.comp_lower_semicontinuous_at_antitone ContinuousAt.comp_lowerSemicontinuousAt_antitone theorem Continuous.comp_lowerSemicontinuousOn_antitone {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : LowerSemicontinuousOn f s) (gmon : Antitone g) : UpperSemicontinuousOn (g ∘ f) s := fun x hx => hg.continuousAt.comp_lowerSemicontinuousWithinAt_antitone (hf x hx) gmon #align continuous.comp_lower_semicontinuous_on_antitone Continuous.comp_lowerSemicontinuousOn_antitone theorem Continuous.comp_lowerSemicontinuous_antitone {g : γ → δ} {f : α → γ} (hg : Continuous g) (hf : LowerSemicontinuous f) (gmon : Antitone g) : UpperSemicontinuous (g ∘ f) := fun x => hg.continuousAt.comp_lowerSemicontinuousAt_antitone (hf x) gmon #align continuous.comp_lower_semicontinuous_antitone Continuous.comp_lowerSemicontinuous_antitone theorem LowerSemicontinuousAt.comp_continuousAt {f : α → β} {g : ι → α} {x : ι} (hf : LowerSemicontinuousAt f (g x)) (hg : ContinuousAt g x) : LowerSemicontinuousAt (fun x ↦ f (g x)) x := fun _ lt ↦ hg.eventually (hf _ lt) theorem LowerSemicontinuousAt.comp_continuousAt_of_eq {f : α → β} {g : ι → α} {y : α} {x : ι} (hf : LowerSemicontinuousAt f y) (hg : ContinuousAt g x) (hy : g x = y) : LowerSemicontinuousAt (fun x ↦ f (g x)) x := by rw [← hy] at hf exact comp_continuousAt hf hg theorem LowerSemicontinuous.comp_continuous {f : α → β} {g : ι → α} (hf : LowerSemicontinuous f) (hg : Continuous g) : LowerSemicontinuous fun x ↦ f (g x) := fun x ↦ (hf (g x)).comp_continuousAt hg.continuousAt end /-! #### Addition -/ section variable {ι : Type*} {γ : Type*} [LinearOrderedAddCommMonoid γ] [TopologicalSpace γ] [OrderTopology γ] /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with an explicit continuity assumption on addition, for application to `EReal`. The unprimed version of the lemma uses `[ContinuousAdd]`. -/ theorem LowerSemicontinuousWithinAt.add' {f g : α → γ} (hf : LowerSemicontinuousWithinAt f s x) (hg : LowerSemicontinuousWithinAt g s x) (hcont : ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) : LowerSemicontinuousWithinAt (fun z => f z + g z) s x := by intro y hy obtain ⟨u, v, u_open, xu, v_open, xv, h⟩ : ∃ u v : Set γ, IsOpen u ∧ f x ∈ u ∧ IsOpen v ∧ g x ∈ v ∧ u ×ˢ v ⊆ { p : γ × γ | y < p.fst + p.snd } := mem_nhds_prod_iff'.1 (hcont (isOpen_Ioi.mem_nhds hy)) by_cases hx₁ : ∃ l, l < f x · obtain ⟨z₁, z₁lt, h₁⟩ : ∃ z₁ < f x, Ioc z₁ (f x) ⊆ u := exists_Ioc_subset_of_mem_nhds (u_open.mem_nhds xu) hx₁ by_cases hx₂ : ∃ l, l < g x · obtain ⟨z₂, z₂lt, h₂⟩ : ∃ z₂ < g x, Ioc z₂ (g x) ⊆ v := exists_Ioc_subset_of_mem_nhds (v_open.mem_nhds xv) hx₂ filter_upwards [hf z₁ z₁lt, hg z₂ z₂lt] with z h₁z h₂z have A1 : min (f z) (f x) ∈ u := by by_cases H : f z ≤ f x · simp [H] exact h₁ ⟨h₁z, H⟩ · simp [le_of_not_le H] exact h₁ ⟨z₁lt, le_rfl⟩ have A2 : min (g z) (g x) ∈ v := by by_cases H : g z ≤ g x · simp [H] exact h₂ ⟨h₂z, H⟩ · simp [le_of_not_le H] exact h₂ ⟨z₂lt, le_rfl⟩ have : (min (f z) (f x), min (g z) (g x)) ∈ u ×ˢ v := ⟨A1, A2⟩ calc y < min (f z) (f x) + min (g z) (g x) := h this _ ≤ f z + g z := add_le_add (min_le_left _ _) (min_le_left _ _) · simp only [not_exists, not_lt] at hx₂ filter_upwards [hf z₁ z₁lt] with z h₁z have A1 : min (f z) (f x) ∈ u := by by_cases H : f z ≤ f x · simp [H] exact h₁ ⟨h₁z, H⟩ · simp [le_of_not_le H] exact h₁ ⟨z₁lt, le_rfl⟩ have : (min (f z) (f x), g x) ∈ u ×ˢ v := ⟨A1, xv⟩ calc y < min (f z) (f x) + g x := h this _ ≤ f z + g z := add_le_add (min_le_left _ _) (hx₂ (g z)) · simp only [not_exists, not_lt] at hx₁ by_cases hx₂ : ∃ l, l < g x · obtain ⟨z₂, z₂lt, h₂⟩ : ∃ z₂ < g x, Ioc z₂ (g x) ⊆ v := exists_Ioc_subset_of_mem_nhds (v_open.mem_nhds xv) hx₂ filter_upwards [hg z₂ z₂lt] with z h₂z have A2 : min (g z) (g x) ∈ v := by by_cases H : g z ≤ g x · simp [H] exact h₂ ⟨h₂z, H⟩ · simp [le_of_not_le H] exact h₂ ⟨z₂lt, le_rfl⟩ have : (f x, min (g z) (g x)) ∈ u ×ˢ v := ⟨xu, A2⟩ calc y < f x + min (g z) (g x) := h this _ ≤ f z + g z := add_le_add (hx₁ (f z)) (min_le_left _ _) · simp only [not_exists, not_lt] at hx₁ hx₂ apply Filter.eventually_of_forall intro z have : (f x, g x) ∈ u ×ˢ v := ⟨xu, xv⟩ calc y < f x + g x := h this _ ≤ f z + g z := add_le_add (hx₁ (f z)) (hx₂ (g z)) #align lower_semicontinuous_within_at.add' LowerSemicontinuousWithinAt.add' /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with an explicit continuity assumption on addition, for application to `EReal`. The unprimed version of the lemma uses `[ContinuousAdd]`. -/ theorem LowerSemicontinuousAt.add' {f g : α → γ} (hf : LowerSemicontinuousAt f x) (hg : LowerSemicontinuousAt g x) (hcont : ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) : LowerSemicontinuousAt (fun z => f z + g z) x := by simp_rw [← lowerSemicontinuousWithinAt_univ_iff] at * exact hf.add' hg hcont #align lower_semicontinuous_at.add' LowerSemicontinuousAt.add' /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with an explicit continuity assumption on addition, for application to `EReal`. The unprimed version of the lemma uses `[ContinuousAdd]`. -/ theorem LowerSemicontinuousOn.add' {f g : α → γ} (hf : LowerSemicontinuousOn f s) (hg : LowerSemicontinuousOn g s) (hcont : ∀ x ∈ s, ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) : LowerSemicontinuousOn (fun z => f z + g z) s := fun x hx => (hf x hx).add' (hg x hx) (hcont x hx) #align lower_semicontinuous_on.add' LowerSemicontinuousOn.add' /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with an explicit continuity assumption on addition, for application to `EReal`. The unprimed version of the lemma uses `[ContinuousAdd]`. -/ theorem LowerSemicontinuous.add' {f g : α → γ} (hf : LowerSemicontinuous f) (hg : LowerSemicontinuous g) (hcont : ∀ x, ContinuousAt (fun p : γ × γ => p.1 + p.2) (f x, g x)) : LowerSemicontinuous fun z => f z + g z := fun x => (hf x).add' (hg x) (hcont x) #align lower_semicontinuous.add' LowerSemicontinuous.add' variable [ContinuousAdd γ] /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with `[ContinuousAdd]`. The primed version of the lemma uses an explicit continuity assumption on addition, for application to `EReal`. -/ theorem LowerSemicontinuousWithinAt.add {f g : α → γ} (hf : LowerSemicontinuousWithinAt f s x) (hg : LowerSemicontinuousWithinAt g s x) : LowerSemicontinuousWithinAt (fun z => f z + g z) s x := hf.add' hg continuous_add.continuousAt #align lower_semicontinuous_within_at.add LowerSemicontinuousWithinAt.add /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with `[ContinuousAdd]`. The primed version of the lemma uses an explicit continuity assumption on addition, for application to `EReal`. -/ theorem LowerSemicontinuousAt.add {f g : α → γ} (hf : LowerSemicontinuousAt f x) (hg : LowerSemicontinuousAt g x) : LowerSemicontinuousAt (fun z => f z + g z) x := hf.add' hg continuous_add.continuousAt #align lower_semicontinuous_at.add LowerSemicontinuousAt.add /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with `[ContinuousAdd]`. The primed version of the lemma uses an explicit continuity assumption on addition, for application to `EReal`. -/ theorem LowerSemicontinuousOn.add {f g : α → γ} (hf : LowerSemicontinuousOn f s) (hg : LowerSemicontinuousOn g s) : LowerSemicontinuousOn (fun z => f z + g z) s := hf.add' hg fun _x _hx => continuous_add.continuousAt #align lower_semicontinuous_on.add LowerSemicontinuousOn.add /-- The sum of two lower semicontinuous functions is lower semicontinuous. Formulated with `[ContinuousAdd]`. The primed version of the lemma uses an explicit continuity assumption on addition, for application to `EReal`. -/ theorem LowerSemicontinuous.add {f g : α → γ} (hf : LowerSemicontinuous f) (hg : LowerSemicontinuous g) : LowerSemicontinuous fun z => f z + g z := hf.add' hg fun _x => continuous_add.continuousAt #align lower_semicontinuous.add LowerSemicontinuous.add
Mathlib/Topology/Semicontinuous.lean
604
613
theorem lowerSemicontinuousWithinAt_sum {f : ι → α → γ} {a : Finset ι} (ha : ∀ i ∈ a, LowerSemicontinuousWithinAt (f i) s x) : LowerSemicontinuousWithinAt (fun z => ∑ i ∈ a, f i z) s x := by
classical induction' a using Finset.induction_on with i a ia IH · exact lowerSemicontinuousWithinAt_const · simp only [ia, Finset.sum_insert, not_false_iff] exact LowerSemicontinuousWithinAt.add (ha _ (Finset.mem_insert_self i a)) (IH fun j ja => ha j (Finset.mem_insert_of_mem ja))
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers -/ 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" /-! # Oriented angles. This file defines oriented angles in Euclidean affine spaces. ## Main definitions * `EuclideanGeometry.oangle`, with notation `∡`, is the oriented angle determined by three points. -/ 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)] /-- A fixed choice of positive orientation of Euclidean space `ℝ²` -/ abbrev o := @Module.Oriented.positiveOrientation /-- The oriented angle at `p₂` between the line segments to `p₁` and `p₃`, modulo `2 * π`. If either of those points equals `p₂`, this is 0. See `EuclideanGeometry.angle` for the corresponding unoriented angle definition. -/ 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 /-- Oriented angles are continuous when neither end point equals the middle point. -/ 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 /-- The angle ∡AAB at a point. -/ @[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 /-- The angle ∡ABB at a point. -/ @[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 /-- The angle ∡ABA at a point. -/ @[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 /-- If the angle between three points is nonzero, the first two points are not equal. -/ 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 /-- If the angle between three points is nonzero, the last two points are not equal. -/ 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 /-- If the angle between three points is nonzero, the first and third points are not equal. -/ 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 /-- If the angle between three points is `π`, the first two points are not equal. -/ 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 /-- If the angle between three points is `π`, the last two points are not equal. -/ 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 /-- If the angle between three points is `π`, the first and third points are not equal. -/ 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 /-- If the angle between three points is `π / 2`, the first two points are not equal. -/ 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 /-- If the angle between three points is `π / 2`, the last two points are not equal. -/ 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 /-- If the angle between three points is `π / 2`, the first and third points are not equal. -/ 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 /-- If the angle between three points is `-π / 2`, the first two points are not equal. -/ 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 /-- If the angle between three points is `-π / 2`, the last two points are not equal. -/ 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 /-- If the angle between three points is `-π / 2`, the first and third points are not equal. -/ 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 /-- If the sign of the angle between three points is nonzero, the first two points are not equal. -/ 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 /-- If the sign of the angle between three points is nonzero, the last two points are not equal. -/ 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 /-- If the sign of the angle between three points is nonzero, the first and third points are not equal. -/ 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 /-- If the sign of the angle between three points is positive, the first two points are not equal. -/ 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 /-- If the sign of the angle between three points is positive, the last two points are not equal. -/ 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 /-- If the sign of the angle between three points is positive, the first and third points are not equal. -/ 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 /-- If the sign of the angle between three points is negative, the first two points are not equal. -/ 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 /-- If the sign of the angle between three points is negative, the last two points are not equal. -/ 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 /-- If the sign of the angle between three points is negative, the first and third points are not equal. -/ 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 /-- Reversing the order of the points passed to `oangle` negates the angle. -/ theorem oangle_rev (p₁ p₂ p₃ : P) : ∡ p₃ p₂ p₁ = -∡ p₁ p₂ p₃ := o.oangle_rev _ _ #align euclidean_geometry.oangle_rev EuclideanGeometry.oangle_rev /-- Adding an angle to that with the order of the points reversed results in 0. -/ @[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 /-- An oriented angle is zero if and only if the angle with the order of the points reversed is zero. -/ 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 /-- An oriented angle is `π` if and only if the angle with the order of the points reversed is `π`. -/ 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 /-- An oriented angle is not zero or `π` if and only if the three points are affinely independent. -/ 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 /-- An oriented angle is zero or `π` if and only if the three points are collinear. -/ 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 /-- An oriented angle has a sign zero if and only if the three points are 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] /-- If twice the oriented angles between two triples of points are equal, one triple is affinely independent if and only if the other is. -/ 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 /-- If twice the oriented angles between two triples of points are equal, one triple is collinear if and only if the other is. -/ 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 /-- If corresponding pairs of points in two angles have the same vector span, twice those angles are equal. -/ 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 /-- If the lines determined by corresponding pairs of points in two angles are parallel, twice those angles are equal. -/ 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 /-- Given three points not equal to `p`, the angle between the first and the second at `p` plus the angle between the second and the third equals the angle between the first and the third. -/ @[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 /-- Given three points not equal to `p`, the angle between the second and the third at `p` plus the angle between the first and the second equals the angle between the first and the third. -/ @[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 /-- Given three points not equal to `p`, the angle between the first and the third at `p` minus the angle between the first and the second equals the angle between the second and the third. -/ @[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 /-- Given three points not equal to `p`, the angle between the first and the third at `p` minus the angle between the second and the third equals the angle between the first and the second. -/ @[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 /-- Given three points not equal to `p`, adding the angles between them at `p` in cyclic order results in 0. -/ @[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 /-- Pons asinorum, oriented angle-at-point form. -/ 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 /-- The angle at the apex of an isosceles triangle is `π` minus twice a base angle, oriented angle-at-point form. -/ 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 /-- A base angle of an isosceles triangle is acute, oriented angle-at-point form. -/ 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 /-- A base angle of an isosceles triangle is acute, oriented angle-at-point form. -/ 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 /-- The cosine of the oriented angle at `p` between two points not equal to `p` equals that of the unoriented angle. -/ 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 /-- The oriented angle at `p` between two points not equal to `p` is plus or minus the unoriented 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 /-- The unoriented angle at `p` between two points not equal to `p` is the absolute value of the oriented 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 /-- If the sign of the oriented angle at `p` between two points is zero, either one of the points equals `p` or the unoriented angle is 0 or π. -/ 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 /-- If two unoriented angles are equal, and the signs of the corresponding oriented angles are equal, then the oriented angles are equal (even in degenerate cases). -/ 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 /-- If the signs of two nondegenerate oriented angles between points are equal, the oriented angles are equal if and only if the unoriented angles are equal. -/ 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 /-- The oriented angle between three points equals the unoriented angle if the sign is positive. -/ 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 /-- The oriented angle between three points equals minus the unoriented angle if the sign is negative. -/ 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 /-- The unoriented angle at `p` between two points not equal to `p` is zero if and only if the unoriented angle is zero. -/ 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 /-- The oriented angle between three points is `π` if and only if the unoriented angle is `π`. -/ 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 /-- If the oriented angle between three points is `π / 2`, so is the unoriented angle. -/ 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 /-- If the oriented angle between three points is `π / 2`, so is the unoriented angle (reversed). -/ 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 /-- If the oriented angle between three points is `-π / 2`, the unoriented angle is `π / 2`. -/ 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 /-- If the oriented angle between three points is `-π / 2`, the unoriented angle (reversed) is `π / 2`. -/ 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 /-- Swapping the first and second points in an oriented angle negates the sign of that angle. -/ 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 /-- Swapping the first and third points in an oriented angle negates the sign of that angle. -/ 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 /-- Swapping the second and third points in an oriented angle negates the sign of that angle. -/ 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] #align euclidean_geometry.oangle_swap₂₃_sign EuclideanGeometry.oangle_swap₂₃_sign /-- Rotating the points in an oriented angle does not change the sign of that angle. -/ theorem oangle_rotate_sign (p₁ p₂ p₃ : P) : (∡ p₂ p₃ p₁).sign = (∡ p₁ p₂ p₃).sign := by rw [← oangle_swap₁₂_sign, oangle_swap₁₃_sign] #align euclidean_geometry.oangle_rotate_sign EuclideanGeometry.oangle_rotate_sign /-- The oriented angle between three points is π if and only if the second point is strictly between the other two. -/ theorem oangle_eq_pi_iff_sbtw {p₁ p₂ p₃ : P} : ∡ p₁ p₂ p₃ = π ↔ Sbtw ℝ p₁ p₂ p₃ := by rw [oangle_eq_pi_iff_angle_eq_pi, angle_eq_pi_iff_sbtw] #align euclidean_geometry.oangle_eq_pi_iff_sbtw EuclideanGeometry.oangle_eq_pi_iff_sbtw /-- If the second of three points is strictly between the other two, the oriented angle at that point is π. -/ theorem _root_.Sbtw.oangle₁₂₃_eq_pi {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₁ p₂ p₃ = π := oangle_eq_pi_iff_sbtw.2 h #align sbtw.oangle₁₂₃_eq_pi Sbtw.oangle₁₂₃_eq_pi /-- If the second of three points is strictly between the other two, the oriented angle at that point (reversed) is π. -/ theorem _root_.Sbtw.oangle₃₂₁_eq_pi {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₃ p₂ p₁ = π := by rw [oangle_eq_pi_iff_oangle_rev_eq_pi, ← h.oangle₁₂₃_eq_pi] #align sbtw.oangle₃₂₁_eq_pi Sbtw.oangle₃₂₁_eq_pi /-- If the second of three points is weakly between the other two, the oriented angle at the first point is zero. -/ theorem _root_.Wbtw.oangle₂₁₃_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₁ p₃ = 0 := by by_cases hp₂p₁ : p₂ = p₁; · simp [hp₂p₁] by_cases hp₃p₁ : p₃ = p₁; · simp [hp₃p₁] rw [oangle_eq_zero_iff_angle_eq_zero hp₂p₁ hp₃p₁] exact h.angle₂₁₃_eq_zero_of_ne hp₂p₁ #align wbtw.oangle₂₁₃_eq_zero Wbtw.oangle₂₁₃_eq_zero /-- If the second of three points is strictly between the other two, the oriented angle at the first point is zero. -/ theorem _root_.Sbtw.oangle₂₁₃_eq_zero {p₁ p₂ p₃ : P} (h : Sbtw ℝ p₁ p₂ p₃) : ∡ p₂ p₁ p₃ = 0 := h.wbtw.oangle₂₁₃_eq_zero #align sbtw.oangle₂₁₃_eq_zero Sbtw.oangle₂₁₃_eq_zero /-- If the second of three points is weakly between the other two, the oriented angle at the first point (reversed) is zero. -/
Mathlib/Geometry/Euclidean/Angle/Oriented/Affine.lean
509
510
theorem _root_.Wbtw.oangle₃₁₂_eq_zero {p₁ p₂ p₃ : P} (h : Wbtw ℝ p₁ p₂ p₃) : ∡ p₃ p₁ p₂ = 0 := by
rw [oangle_eq_zero_iff_oangle_rev_eq_zero, h.oangle₂₁₃_eq_zero]
/- Copyright (c) 2019 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.FDeriv.Equiv import Mathlib.Analysis.Calculus.FormalMultilinearSeries #align_import analysis.calculus.cont_diff_def from "leanprover-community/mathlib"@"3a69562db5a458db8322b190ec8d9a8bbd8a5b14" /-! # Higher differentiability A function is `C^1` on a domain if it is differentiable there, and its derivative is continuous. By induction, it is `C^n` if it is `C^{n-1}` and its (n-1)-th derivative is `C^1` there or, equivalently, if it is `C^1` and its derivative is `C^{n-1}`. Finally, it is `C^∞` if it is `C^n` for all n. We formalize these notions by defining iteratively the `n+1`-th derivative of a function as the derivative of the `n`-th derivative. It is called `iteratedFDeriv 𝕜 n f x` where `𝕜` is the field, `n` is the number of iterations, `f` is the function and `x` is the point, and it is given as an `n`-multilinear map. We also define a version `iteratedFDerivWithin` relative to a domain, as well as predicates `ContDiffWithinAt`, `ContDiffAt`, `ContDiffOn` and `ContDiff` saying that the function is `C^n` within a set at a point, at a point, on a set and on the whole space respectively. To avoid the issue of choice when choosing a derivative in sets where the derivative is not necessarily unique, `ContDiffOn` is not defined directly in terms of the regularity of the specific choice `iteratedFDerivWithin 𝕜 n f s` inside `s`, but in terms of the existence of a nice sequence of derivatives, expressed with a predicate `HasFTaylorSeriesUpToOn`. We prove basic properties of these notions. ## Main definitions and results Let `f : E → F` be a map between normed vector spaces over a nontrivially normed field `𝕜`. * `HasFTaylorSeriesUpTo n f p`: expresses that the formal multilinear series `p` is a sequence of iterated derivatives of `f`, up to the `n`-th term (where `n` is a natural number or `∞`). * `HasFTaylorSeriesUpToOn n f p s`: same thing, but inside a set `s`. The notion of derivative is now taken inside `s`. In particular, derivatives don't have to be unique. * `ContDiff 𝕜 n f`: expresses that `f` is `C^n`, i.e., it admits a Taylor series up to rank `n`. * `ContDiffOn 𝕜 n f s`: expresses that `f` is `C^n` in `s`. * `ContDiffAt 𝕜 n f x`: expresses that `f` is `C^n` around `x`. * `ContDiffWithinAt 𝕜 n f s x`: expresses that `f` is `C^n` around `x` within the set `s`. * `iteratedFDerivWithin 𝕜 n f s x` is an `n`-th derivative of `f` over the field `𝕜` on the set `s` at the point `x`. It is a continuous multilinear map from `E^n` to `F`, defined as a derivative within `s` of `iteratedFDerivWithin 𝕜 (n-1) f s` if one exists, and `0` otherwise. * `iteratedFDeriv 𝕜 n f x` is the `n`-th derivative of `f` over the field `𝕜` at the point `x`. It is a continuous multilinear map from `E^n` to `F`, defined as a derivative of `iteratedFDeriv 𝕜 (n-1) f` if one exists, and `0` otherwise. In sets of unique differentiability, `ContDiffOn 𝕜 n f s` can be expressed in terms of the properties of `iteratedFDerivWithin 𝕜 m f s` for `m ≤ n`. In the whole space, `ContDiff 𝕜 n f` can be expressed in terms of the properties of `iteratedFDeriv 𝕜 m f` for `m ≤ n`. ## Implementation notes The definitions in this file are designed to work on any field `𝕜`. They are sometimes slightly more complicated than the naive definitions one would guess from the intuition over the real or complex numbers, but they are designed to circumvent the lack of gluing properties and partitions of unity in general. In the usual situations, they coincide with the usual definitions. ### Definition of `C^n` functions in domains One could define `C^n` functions in a domain `s` by fixing an arbitrary choice of derivatives (this is what we do with `iteratedFDerivWithin`) and requiring that all these derivatives up to `n` are continuous. If the derivative is not unique, this could lead to strange behavior like two `C^n` functions `f` and `g` on `s` whose sum is not `C^n`. A better definition is thus to say that a function is `C^n` inside `s` if it admits a sequence of derivatives up to `n` inside `s`. This definition still has the problem that a function which is locally `C^n` would not need to be `C^n`, as different choices of sequences of derivatives around different points might possibly not be glued together to give a globally defined sequence of derivatives. (Note that this issue can not happen over reals, thanks to partition of unity, but the behavior over a general field is not so clear, and we want a definition for general fields). Also, there are locality problems for the order parameter: one could image a function which, for each `n`, has a nice sequence of derivatives up to order `n`, but they do not coincide for varying `n` and can therefore not be glued to give rise to an infinite sequence of derivatives. This would give a function which is `C^n` for all `n`, but not `C^∞`. We solve this issue by putting locality conditions in space and order in our definition of `ContDiffWithinAt` and `ContDiffOn`. The resulting definition is slightly more complicated to work with (in fact not so much), but it gives rise to completely satisfactory theorems. For instance, with this definition, a real function which is `C^m` (but not better) on `(-1/m, 1/m)` for each natural `m` is by definition `C^∞` at `0`. There is another issue with the definition of `ContDiffWithinAt 𝕜 n f s x`. We can require the existence and good behavior of derivatives up to order `n` on a neighborhood of `x` within `s`. However, this does not imply continuity or differentiability within `s` of the function at `x` when `x` does not belong to `s`. Therefore, we require such existence and good behavior on a neighborhood of `x` within `s ∪ {x}` (which appears as `insert x s` in this file). ### Side of the composition, and universe issues With a naïve direct definition, the `n`-th derivative of a function belongs to the space `E →L[𝕜] (E →L[𝕜] (E ... F)...)))` where there are n iterations of `E →L[𝕜]`. This space may also be seen as the space of continuous multilinear functions on `n` copies of `E` with values in `F`, by uncurrying. This is the point of view that is usually adopted in textbooks, and that we also use. This means that the definition and the first proofs are slightly involved, as one has to keep track of the uncurrying operation. The uncurrying can be done from the left or from the right, amounting to defining the `n+1`-th derivative either as the derivative of the `n`-th derivative, or as the `n`-th derivative of the derivative. For proofs, it would be more convenient to use the latter approach (from the right), as it means to prove things at the `n+1`-th step we only need to understand well enough the derivative in `E →L[𝕜] F` (contrary to the approach from the left, where one would need to know enough on the `n`-th derivative to deduce things on the `n+1`-th derivative). However, the definition from the right leads to a universe polymorphism problem: if we define `iteratedFDeriv 𝕜 (n + 1) f x = iteratedFDeriv 𝕜 n (fderiv 𝕜 f) x` by induction, we need to generalize over all spaces (as `f` and `fderiv 𝕜 f` don't take values in the same space). It is only possible to generalize over all spaces in some fixed universe in an inductive definition. For `f : E → F`, then `fderiv 𝕜 f` is a map `E → (E →L[𝕜] F)`. Therefore, the definition will only work if `F` and `E →L[𝕜] F` are in the same universe. This issue does not appear with the definition from the left, where one does not need to generalize over all spaces. Therefore, we use the definition from the left. This means some proofs later on become a little bit more complicated: to prove that a function is `C^n`, the most efficient approach is to exhibit a formula for its `n`-th derivative and prove it is continuous (contrary to the inductive approach where one would prove smoothness statements without giving a formula for the derivative). In the end, this approach is still satisfactory as it is good to have formulas for the iterated derivatives in various constructions. One point where we depart from this explicit approach is in the proof of smoothness of a composition: there is a formula for the `n`-th derivative of a composition (Faà di Bruno's formula), but it is very complicated and barely usable, while the inductive proof is very simple. Thus, we give the inductive proof. As explained above, it works by generalizing over the target space, hence it only works well if all spaces belong to the same universe. To get the general version, we lift things to a common universe using a trick. ### Variables management The textbook definitions and proofs use various identifications and abuse of notations, for instance when saying that the natural space in which the derivative lives, i.e., `E →L[𝕜] (E →L[𝕜] ( ... →L[𝕜] F))`, is the same as a space of multilinear maps. When doing things formally, we need to provide explicit maps for these identifications, and chase some diagrams to see everything is compatible with the identifications. In particular, one needs to check that taking the derivative and then doing the identification, or first doing the identification and then taking the derivative, gives the same result. The key point for this is that taking the derivative commutes with continuous linear equivalences. Therefore, we need to implement all our identifications with continuous linear equivs. ## Notations We use the notation `E [×n]→L[𝕜] F` for the space of continuous multilinear maps on `E^n` with values in `F`. This is the space in which the `n`-th derivative of a function from `E` to `F` lives. In this file, we denote `⊤ : ℕ∞` with `∞`. ## Tags derivative, differentiability, higher derivative, `C^n`, multilinear, Taylor series, formal series -/ noncomputable section open scoped Classical open NNReal Topology Filter local notation "∞" => (⊤ : ℕ∞) /- Porting note: These lines are not required in Mathlib4. attribute [local instance 1001] NormedAddCommGroup.toAddCommGroup NormedSpace.toModule' AddCommGroup.toAddCommMonoid -/ open Set Fin Filter Function universe u uE uF uG uX variable {𝕜 : Type u} [NontriviallyNormedField 𝕜] {E : Type uE} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {F : Type uF} [NormedAddCommGroup F] [NormedSpace 𝕜 F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace 𝕜 G] {X : Type uX} [NormedAddCommGroup X] [NormedSpace 𝕜 X] {s s₁ t u : Set E} {f f₁ : E → F} {g : F → G} {x x₀ : E} {c : F} {m n : ℕ∞} {p : E → FormalMultilinearSeries 𝕜 E F} /-! ### Functions with a Taylor series on a domain -/ /-- `HasFTaylorSeriesUpToOn n f p s` registers the fact that `p 0 = f` and `p (m+1)` is a derivative of `p m` for `m < n`, and is continuous for `m ≤ n`. This is a predicate analogous to `HasFDerivWithinAt` but for higher order derivatives. Notice that `p` does not sum up to `f` on the diagonal (`FormalMultilinearSeries.sum`), even if `f` is analytic and `n = ∞`: an additional `1/m!` factor on the `m`th term is necessary for that. -/ structure HasFTaylorSeriesUpToOn (n : ℕ∞) (f : E → F) (p : E → FormalMultilinearSeries 𝕜 E F) (s : Set E) : Prop where zero_eq : ∀ x ∈ s, (p x 0).uncurry0 = f x protected fderivWithin : ∀ m : ℕ, (m : ℕ∞) < n → ∀ x ∈ s, HasFDerivWithinAt (p · m) (p x m.succ).curryLeft s x cont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (p · m) s #align has_ftaylor_series_up_to_on HasFTaylorSeriesUpToOn theorem HasFTaylorSeriesUpToOn.zero_eq' (h : HasFTaylorSeriesUpToOn n f p s) {x : E} (hx : x ∈ s) : p x 0 = (continuousMultilinearCurryFin0 𝕜 E F).symm (f x) := by rw [← h.zero_eq x hx] exact (p x 0).uncurry0_curry0.symm #align has_ftaylor_series_up_to_on.zero_eq' HasFTaylorSeriesUpToOn.zero_eq' /-- If two functions coincide on a set `s`, then a Taylor series for the first one is as well a Taylor series for the second one. -/ theorem HasFTaylorSeriesUpToOn.congr (h : HasFTaylorSeriesUpToOn n f p s) (h₁ : ∀ x ∈ s, f₁ x = f x) : HasFTaylorSeriesUpToOn n f₁ p s := by refine ⟨fun x hx => ?_, h.fderivWithin, h.cont⟩ rw [h₁ x hx] exact h.zero_eq x hx #align has_ftaylor_series_up_to_on.congr HasFTaylorSeriesUpToOn.congr theorem HasFTaylorSeriesUpToOn.mono (h : HasFTaylorSeriesUpToOn n f p s) {t : Set E} (hst : t ⊆ s) : HasFTaylorSeriesUpToOn n f p t := ⟨fun x hx => h.zero_eq x (hst hx), fun m hm x hx => (h.fderivWithin m hm x (hst hx)).mono hst, fun m hm => (h.cont m hm).mono hst⟩ #align has_ftaylor_series_up_to_on.mono HasFTaylorSeriesUpToOn.mono theorem HasFTaylorSeriesUpToOn.of_le (h : HasFTaylorSeriesUpToOn n f p s) (hmn : m ≤ n) : HasFTaylorSeriesUpToOn m f p s := ⟨h.zero_eq, fun k hk x hx => h.fderivWithin k (lt_of_lt_of_le hk hmn) x hx, fun k hk => h.cont k (le_trans hk hmn)⟩ #align has_ftaylor_series_up_to_on.of_le HasFTaylorSeriesUpToOn.of_le theorem HasFTaylorSeriesUpToOn.continuousOn (h : HasFTaylorSeriesUpToOn n f p s) : ContinuousOn f s := by have := (h.cont 0 bot_le).congr fun x hx => (h.zero_eq' hx).symm rwa [← (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_continuousOn_iff] #align has_ftaylor_series_up_to_on.continuous_on HasFTaylorSeriesUpToOn.continuousOn theorem hasFTaylorSeriesUpToOn_zero_iff : HasFTaylorSeriesUpToOn 0 f p s ↔ ContinuousOn f s ∧ ∀ x ∈ s, (p x 0).uncurry0 = f x := by refine ⟨fun H => ⟨H.continuousOn, H.zero_eq⟩, fun H => ⟨H.2, fun m hm => False.elim (not_le.2 hm bot_le), fun m hm ↦ ?_⟩⟩ obtain rfl : m = 0 := mod_cast hm.antisymm (zero_le _) have : EqOn (p · 0) ((continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f) s := fun x hx ↦ (continuousMultilinearCurryFin0 𝕜 E F).eq_symm_apply.2 (H.2 x hx) rw [continuousOn_congr this, LinearIsometryEquiv.comp_continuousOn_iff] exact H.1 #align has_ftaylor_series_up_to_on_zero_iff hasFTaylorSeriesUpToOn_zero_iff theorem hasFTaylorSeriesUpToOn_top_iff : HasFTaylorSeriesUpToOn ∞ f p s ↔ ∀ n : ℕ, HasFTaylorSeriesUpToOn n f p s := by constructor · intro H n; exact H.of_le le_top · intro H constructor · exact (H 0).zero_eq · intro m _ apply (H m.succ).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) · intro m _ apply (H m).cont m le_rfl #align has_ftaylor_series_up_to_on_top_iff hasFTaylorSeriesUpToOn_top_iff /-- In the case that `n = ∞` we don't need the continuity assumption in `HasFTaylorSeriesUpToOn`. -/ theorem hasFTaylorSeriesUpToOn_top_iff' : HasFTaylorSeriesUpToOn ∞ f p s ↔ (∀ x ∈ s, (p x 0).uncurry0 = f x) ∧ ∀ m : ℕ, ∀ x ∈ s, HasFDerivWithinAt (fun y => p y m) (p x m.succ).curryLeft s x := -- Everything except for the continuity is trivial: ⟨fun h => ⟨h.1, fun m => h.2 m (WithTop.coe_lt_top m)⟩, fun h => ⟨h.1, fun m _ => h.2 m, fun m _ x hx => -- The continuity follows from the existence of a derivative: (h.2 m x hx).continuousWithinAt⟩⟩ #align has_ftaylor_series_up_to_on_top_iff' hasFTaylorSeriesUpToOn_top_iff' /-- If a function has a Taylor series at order at least `1`, then the term of order `1` of this series is a derivative of `f`. -/ theorem HasFTaylorSeriesUpToOn.hasFDerivWithinAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : x ∈ s) : HasFDerivWithinAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x := by have A : ∀ y ∈ s, f y = (continuousMultilinearCurryFin0 𝕜 E F) (p y 0) := fun y hy ↦ (h.zero_eq y hy).symm suffices H : HasFDerivWithinAt (continuousMultilinearCurryFin0 𝕜 E F ∘ (p · 0)) (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) s x from H.congr A (A x hx) rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] have : ((0 : ℕ) : ℕ∞) < n := zero_lt_one.trans_le hn convert h.fderivWithin _ this x hx ext y v change (p x 1) (snoc 0 y) = (p x 1) (cons y v) congr with i rw [Unique.eq_default (α := Fin 1) i] rfl #align has_ftaylor_series_up_to_on.has_fderiv_within_at HasFTaylorSeriesUpToOn.hasFDerivWithinAt theorem HasFTaylorSeriesUpToOn.differentiableOn (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) : DifferentiableOn 𝕜 f s := fun _x hx => (h.hasFDerivWithinAt hn hx).differentiableWithinAt #align has_ftaylor_series_up_to_on.differentiable_on HasFTaylorSeriesUpToOn.differentiableOn /-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then the term of order `1` of this series is a derivative of `f` at `x`. -/ theorem HasFTaylorSeriesUpToOn.hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p x 1)) x := (h.hasFDerivWithinAt hn (mem_of_mem_nhds hx)).hasFDerivAt hx #align has_ftaylor_series_up_to_on.has_fderiv_at HasFTaylorSeriesUpToOn.hasFDerivAt /-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then in a neighborhood of `x`, the term of order `1` of this series is a derivative of `f`. -/ theorem HasFTaylorSeriesUpToOn.eventually_hasFDerivAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : ∀ᶠ y in 𝓝 x, HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p y 1)) y := (eventually_eventually_nhds.2 hx).mono fun _y hy => h.hasFDerivAt hn hy #align has_ftaylor_series_up_to_on.eventually_has_fderiv_at HasFTaylorSeriesUpToOn.eventually_hasFDerivAt /-- If a function has a Taylor series at order at least `1` on a neighborhood of `x`, then it is differentiable at `x`. -/ theorem HasFTaylorSeriesUpToOn.differentiableAt (h : HasFTaylorSeriesUpToOn n f p s) (hn : 1 ≤ n) (hx : s ∈ 𝓝 x) : DifferentiableAt 𝕜 f x := (h.hasFDerivAt hn hx).differentiableAt #align has_ftaylor_series_up_to_on.differentiable_at HasFTaylorSeriesUpToOn.differentiableAt /-- `p` is a Taylor series of `f` up to `n+1` if and only if `p` is a Taylor series up to `n`, and `p (n + 1)` is a derivative of `p n`. -/ theorem hasFTaylorSeriesUpToOn_succ_iff_left {n : ℕ} : HasFTaylorSeriesUpToOn (n + 1) f p s ↔ HasFTaylorSeriesUpToOn n f p s ∧ (∀ x ∈ s, HasFDerivWithinAt (fun y => p y n) (p x n.succ).curryLeft s x) ∧ ContinuousOn (fun x => p x (n + 1)) s := by constructor · exact fun h ↦ ⟨h.of_le (WithTop.coe_le_coe.2 (Nat.le_succ n)), h.fderivWithin _ (WithTop.coe_lt_coe.2 (lt_add_one n)), h.cont (n + 1) le_rfl⟩ · intro h constructor · exact h.1.zero_eq · intro m hm by_cases h' : m < n · exact h.1.fderivWithin m (WithTop.coe_lt_coe.2 h') · have : m = n := Nat.eq_of_lt_succ_of_not_lt (WithTop.coe_lt_coe.1 hm) h' rw [this] exact h.2.1 · intro m hm by_cases h' : m ≤ n · apply h.1.cont m (WithTop.coe_le_coe.2 h') · have : m = n + 1 := le_antisymm (WithTop.coe_le_coe.1 hm) (not_le.1 h') rw [this] exact h.2.2 #align has_ftaylor_series_up_to_on_succ_iff_left hasFTaylorSeriesUpToOn_succ_iff_left #adaptation_note /-- After https://github.com/leanprover/lean4/pull/4119, without `set_option maxSynthPendingDepth 2` this proof needs substantial repair. -/ set_option maxSynthPendingDepth 2 in -- Porting note: this was split out from `hasFTaylorSeriesUpToOn_succ_iff_right` to avoid a timeout. theorem HasFTaylorSeriesUpToOn.shift_of_succ {n : ℕ} (H : HasFTaylorSeriesUpToOn (n + 1 : ℕ) f p s) : (HasFTaylorSeriesUpToOn n (fun x => continuousMultilinearCurryFin1 𝕜 E F (p x 1)) (fun x => (p x).shift)) s := by constructor · intro x _ rfl · intro m (hm : (m : ℕ∞) < n) x (hx : x ∈ s) have A : (m.succ : ℕ∞) < n.succ := by rw [Nat.cast_lt] at hm ⊢ exact Nat.succ_lt_succ hm change HasFDerivWithinAt ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm ∘ (p · m.succ)) (p x m.succ.succ).curryRight.curryLeft s x rw [((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm).comp_hasFDerivWithinAt_iff'] convert H.fderivWithin _ A x hx ext y v change p x (m + 2) (snoc (cons y (init v)) (v (last _))) = p x (m + 2) (cons y v) rw [← cons_snoc_eq_snoc_cons, snoc_init_self] · intro m (hm : (m : ℕ∞) ≤ n) suffices A : ContinuousOn (p · (m + 1)) s from ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm).continuous.comp_continuousOn A refine H.cont _ ?_ rw [Nat.cast_le] at hm ⊢ exact Nat.succ_le_succ hm /-- `p` is a Taylor series of `f` up to `n+1` if and only if `p.shift` is a Taylor series up to `n` for `p 1`, which is a derivative of `f`. -/ theorem hasFTaylorSeriesUpToOn_succ_iff_right {n : ℕ} : HasFTaylorSeriesUpToOn (n + 1 : ℕ) f p s ↔ (∀ x ∈ s, (p x 0).uncurry0 = f x) ∧ (∀ x ∈ s, HasFDerivWithinAt (fun y => p y 0) (p x 1).curryLeft s x) ∧ HasFTaylorSeriesUpToOn n (fun x => continuousMultilinearCurryFin1 𝕜 E F (p x 1)) (fun x => (p x).shift) s := by constructor · intro H refine ⟨H.zero_eq, H.fderivWithin 0 (Nat.cast_lt.2 (Nat.succ_pos n)), ?_⟩ exact H.shift_of_succ · rintro ⟨Hzero_eq, Hfderiv_zero, Htaylor⟩ constructor · exact Hzero_eq · intro m (hm : (m : ℕ∞) < n.succ) x (hx : x ∈ s) cases' m with m · exact Hfderiv_zero x hx · have A : (m : ℕ∞) < n := by rw [Nat.cast_lt] at hm ⊢ exact Nat.lt_of_succ_lt_succ hm have : HasFDerivWithinAt ((continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm ∘ (p · m.succ)) ((p x).shift m.succ).curryLeft s x := Htaylor.fderivWithin _ A x hx rw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] at this convert this ext y v change (p x (Nat.succ (Nat.succ m))) (cons y v) = (p x m.succ.succ) (snoc (cons y (init v)) (v (last _))) rw [← cons_snoc_eq_snoc_cons, snoc_init_self] · intro m (hm : (m : ℕ∞) ≤ n.succ) cases' m with m · have : DifferentiableOn 𝕜 (fun x => p x 0) s := fun x hx => (Hfderiv_zero x hx).differentiableWithinAt exact this.continuousOn · refine (continuousMultilinearCurryRightEquiv' 𝕜 m E F).symm.comp_continuousOn_iff.mp ?_ refine Htaylor.cont _ ?_ rw [Nat.cast_le] at hm ⊢ exact Nat.lt_succ_iff.mp hm #align has_ftaylor_series_up_to_on_succ_iff_right hasFTaylorSeriesUpToOn_succ_iff_right /-! ### Smooth functions within a set around a point -/ variable (𝕜) /-- A function is continuously differentiable up to order `n` within a set `s` at a point `x` if it admits continuous derivatives up to order `n` in a neighborhood of `x` in `s ∪ {x}`. For `n = ∞`, we only require that this holds up to any finite order (where the neighborhood may depend on the finite order we consider). For instance, a real function which is `C^m` on `(-1/m, 1/m)` for each natural `m`, but not better, is `C^∞` at `0` within `univ`. -/ def ContDiffWithinAt (n : ℕ∞) (f : E → F) (s : Set E) (x : E) : Prop := ∀ m : ℕ, (m : ℕ∞) ≤ n → ∃ u ∈ 𝓝[insert x s] x, ∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpToOn m f p u #align cont_diff_within_at ContDiffWithinAt variable {𝕜} theorem contDiffWithinAt_nat {n : ℕ} : ContDiffWithinAt 𝕜 n f s x ↔ ∃ u ∈ 𝓝[insert x s] x, ∃ p : E → FormalMultilinearSeries 𝕜 E F, HasFTaylorSeriesUpToOn n f p u := ⟨fun H => H n le_rfl, fun ⟨u, hu, p, hp⟩ _m hm => ⟨u, hu, p, hp.of_le hm⟩⟩ #align cont_diff_within_at_nat contDiffWithinAt_nat theorem ContDiffWithinAt.of_le (h : ContDiffWithinAt 𝕜 n f s x) (hmn : m ≤ n) : ContDiffWithinAt 𝕜 m f s x := fun k hk => h k (le_trans hk hmn) #align cont_diff_within_at.of_le ContDiffWithinAt.of_le theorem contDiffWithinAt_iff_forall_nat_le : ContDiffWithinAt 𝕜 n f s x ↔ ∀ m : ℕ, ↑m ≤ n → ContDiffWithinAt 𝕜 m f s x := ⟨fun H _m hm => H.of_le hm, fun H m hm => H m hm _ le_rfl⟩ #align cont_diff_within_at_iff_forall_nat_le contDiffWithinAt_iff_forall_nat_le theorem contDiffWithinAt_top : ContDiffWithinAt 𝕜 ∞ f s x ↔ ∀ n : ℕ, ContDiffWithinAt 𝕜 n f s x := contDiffWithinAt_iff_forall_nat_le.trans <| by simp only [forall_prop_of_true, le_top] #align cont_diff_within_at_top contDiffWithinAt_top theorem ContDiffWithinAt.continuousWithinAt (h : ContDiffWithinAt 𝕜 n f s x) : ContinuousWithinAt f s x := by rcases h 0 bot_le with ⟨u, hu, p, H⟩ rw [mem_nhdsWithin_insert] at hu exact (H.continuousOn.continuousWithinAt hu.1).mono_of_mem hu.2 #align cont_diff_within_at.continuous_within_at ContDiffWithinAt.continuousWithinAt theorem ContDiffWithinAt.congr_of_eventuallyEq (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : ContDiffWithinAt 𝕜 n f₁ s x := fun m hm => let ⟨u, hu, p, H⟩ := h m hm ⟨{ x ∈ u | f₁ x = f x }, Filter.inter_mem hu (mem_nhdsWithin_insert.2 ⟨hx, h₁⟩), p, (H.mono (sep_subset _ _)).congr fun _ => And.right⟩ #align cont_diff_within_at.congr_of_eventually_eq ContDiffWithinAt.congr_of_eventuallyEq theorem ContDiffWithinAt.congr_of_eventuallyEq_insert (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : f₁ =ᶠ[𝓝[insert x s] x] f) : ContDiffWithinAt 𝕜 n f₁ s x := h.congr_of_eventuallyEq (nhdsWithin_mono x (subset_insert x s) h₁) (mem_of_mem_nhdsWithin (mem_insert x s) h₁ : _) #align cont_diff_within_at.congr_of_eventually_eq_insert ContDiffWithinAt.congr_of_eventuallyEq_insert theorem ContDiffWithinAt.congr_of_eventually_eq' (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : x ∈ s) : ContDiffWithinAt 𝕜 n f₁ s x := h.congr_of_eventuallyEq h₁ <| h₁.self_of_nhdsWithin hx #align cont_diff_within_at.congr_of_eventually_eq' ContDiffWithinAt.congr_of_eventually_eq' theorem Filter.EventuallyEq.contDiffWithinAt_iff (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : ContDiffWithinAt 𝕜 n f₁ s x ↔ ContDiffWithinAt 𝕜 n f s x := ⟨fun H => ContDiffWithinAt.congr_of_eventuallyEq H h₁.symm hx.symm, fun H => H.congr_of_eventuallyEq h₁ hx⟩ #align filter.eventually_eq.cont_diff_within_at_iff Filter.EventuallyEq.contDiffWithinAt_iff theorem ContDiffWithinAt.congr (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : ∀ y ∈ s, f₁ y = f y) (hx : f₁ x = f x) : ContDiffWithinAt 𝕜 n f₁ s x := h.congr_of_eventuallyEq (Filter.eventuallyEq_of_mem self_mem_nhdsWithin h₁) hx #align cont_diff_within_at.congr ContDiffWithinAt.congr theorem ContDiffWithinAt.congr' (h : ContDiffWithinAt 𝕜 n f s x) (h₁ : ∀ y ∈ s, f₁ y = f y) (hx : x ∈ s) : ContDiffWithinAt 𝕜 n f₁ s x := h.congr h₁ (h₁ _ hx) #align cont_diff_within_at.congr' ContDiffWithinAt.congr' theorem ContDiffWithinAt.mono_of_mem (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E} (hst : s ∈ 𝓝[t] x) : ContDiffWithinAt 𝕜 n f t x := by intro m hm rcases h m hm with ⟨u, hu, p, H⟩ exact ⟨u, nhdsWithin_le_of_mem (insert_mem_nhdsWithin_insert hst) hu, p, H⟩ #align cont_diff_within_at.mono_of_mem ContDiffWithinAt.mono_of_mem theorem ContDiffWithinAt.mono (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E} (hst : t ⊆ s) : ContDiffWithinAt 𝕜 n f t x := h.mono_of_mem <| Filter.mem_of_superset self_mem_nhdsWithin hst #align cont_diff_within_at.mono ContDiffWithinAt.mono theorem ContDiffWithinAt.congr_nhds (h : ContDiffWithinAt 𝕜 n f s x) {t : Set E} (hst : 𝓝[s] x = 𝓝[t] x) : ContDiffWithinAt 𝕜 n f t x := h.mono_of_mem <| hst ▸ self_mem_nhdsWithin #align cont_diff_within_at.congr_nhds ContDiffWithinAt.congr_nhds theorem contDiffWithinAt_congr_nhds {t : Set E} (hst : 𝓝[s] x = 𝓝[t] x) : ContDiffWithinAt 𝕜 n f s x ↔ ContDiffWithinAt 𝕜 n f t x := ⟨fun h => h.congr_nhds hst, fun h => h.congr_nhds hst.symm⟩ #align cont_diff_within_at_congr_nhds contDiffWithinAt_congr_nhds theorem contDiffWithinAt_inter' (h : t ∈ 𝓝[s] x) : ContDiffWithinAt 𝕜 n f (s ∩ t) x ↔ ContDiffWithinAt 𝕜 n f s x := contDiffWithinAt_congr_nhds <| Eq.symm <| nhdsWithin_restrict'' _ h #align cont_diff_within_at_inter' contDiffWithinAt_inter' theorem contDiffWithinAt_inter (h : t ∈ 𝓝 x) : ContDiffWithinAt 𝕜 n f (s ∩ t) x ↔ ContDiffWithinAt 𝕜 n f s x := contDiffWithinAt_inter' (mem_nhdsWithin_of_mem_nhds h) #align cont_diff_within_at_inter contDiffWithinAt_inter theorem contDiffWithinAt_insert_self : ContDiffWithinAt 𝕜 n f (insert x s) x ↔ ContDiffWithinAt 𝕜 n f s x := by simp_rw [ContDiffWithinAt, insert_idem] theorem contDiffWithinAt_insert {y : E} : ContDiffWithinAt 𝕜 n f (insert y s) x ↔ ContDiffWithinAt 𝕜 n f s x := by rcases eq_or_ne x y with (rfl | h) · exact contDiffWithinAt_insert_self simp_rw [ContDiffWithinAt, insert_comm x y, nhdsWithin_insert_of_ne h] #align cont_diff_within_at_insert contDiffWithinAt_insert alias ⟨ContDiffWithinAt.of_insert, ContDiffWithinAt.insert'⟩ := contDiffWithinAt_insert #align cont_diff_within_at.of_insert ContDiffWithinAt.of_insert #align cont_diff_within_at.insert' ContDiffWithinAt.insert' protected theorem ContDiffWithinAt.insert (h : ContDiffWithinAt 𝕜 n f s x) : ContDiffWithinAt 𝕜 n f (insert x s) x := h.insert' #align cont_diff_within_at.insert ContDiffWithinAt.insert /-- If a function is `C^n` within a set at a point, with `n ≥ 1`, then it is differentiable within this set at this point. -/ theorem ContDiffWithinAt.differentiable_within_at' (h : ContDiffWithinAt 𝕜 n f s x) (hn : 1 ≤ n) : DifferentiableWithinAt 𝕜 f (insert x s) x := by rcases h 1 hn with ⟨u, hu, p, H⟩ rcases mem_nhdsWithin.1 hu with ⟨t, t_open, xt, tu⟩ rw [inter_comm] at tu have := ((H.mono tu).differentiableOn le_rfl) x ⟨mem_insert x s, xt⟩ exact (differentiableWithinAt_inter (IsOpen.mem_nhds t_open xt)).1 this #align cont_diff_within_at.differentiable_within_at' ContDiffWithinAt.differentiable_within_at' theorem ContDiffWithinAt.differentiableWithinAt (h : ContDiffWithinAt 𝕜 n f s x) (hn : 1 ≤ n) : DifferentiableWithinAt 𝕜 f s x := (h.differentiable_within_at' hn).mono (subset_insert x s) #align cont_diff_within_at.differentiable_within_at ContDiffWithinAt.differentiableWithinAt /-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`. -/ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt {n : ℕ} : ContDiffWithinAt 𝕜 (n + 1 : ℕ) f s x ↔ ∃ u ∈ 𝓝[insert x s] x, ∃ f' : E → E →L[𝕜] F, (∀ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffWithinAt 𝕜 n f' u x := by constructor · intro h rcases h n.succ le_rfl with ⟨u, hu, p, Hp⟩ refine ⟨u, hu, fun y => (continuousMultilinearCurryFin1 𝕜 E F) (p y 1), fun y hy => Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, ?_⟩ intro m hm refine ⟨u, ?_, fun y : E => (p y).shift, ?_⟩ · -- Porting note: without the explicit argument Lean is not sure of the type. convert @self_mem_nhdsWithin _ _ x u have : x ∈ insert x s := by simp exact insert_eq_of_mem (mem_of_mem_nhdsWithin this hu) · rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp exact Hp.2.2.of_le hm · rintro ⟨u, hu, f', f'_eq_deriv, Hf'⟩ rw [contDiffWithinAt_nat] rcases Hf' n le_rfl with ⟨v, hv, p', Hp'⟩ refine ⟨v ∩ u, ?_, fun x => (p' x).unshift (f x), ?_⟩ · apply Filter.inter_mem _ hu apply nhdsWithin_le_of_mem hu exact nhdsWithin_mono _ (subset_insert x u) hv · rw [hasFTaylorSeriesUpToOn_succ_iff_right] refine ⟨fun y _ => rfl, fun y hy => ?_, ?_⟩ · change HasFDerivWithinAt (fun z => (continuousMultilinearCurryFin0 𝕜 E F).symm (f z)) (FormalMultilinearSeries.unshift (p' y) (f y) 1).curryLeft (v ∩ u) y -- Porting note: needed `erw` here. -- https://github.com/leanprover-community/mathlib4/issues/5164 erw [LinearIsometryEquiv.comp_hasFDerivWithinAt_iff'] convert (f'_eq_deriv y hy.2).mono inter_subset_right rw [← Hp'.zero_eq y hy.1] ext z change ((p' y 0) (init (@cons 0 (fun _ => E) z 0))) (@cons 0 (fun _ => E) z 0 (last 0)) = ((p' y 0) 0) z congr norm_num [eq_iff_true_of_subsingleton] · convert (Hp'.mono inter_subset_left).congr fun x hx => Hp'.zero_eq x hx.1 using 1 · ext x y change p' x 0 (init (@snoc 0 (fun _ : Fin 1 => E) 0 y)) y = p' x 0 0 y rw [init_snoc] · ext x k v y change p' x k (init (@snoc k (fun _ : Fin k.succ => E) v y)) (@snoc k (fun _ : Fin k.succ => E) v y (last k)) = p' x k v y rw [snoc_last, init_snoc] #align cont_diff_within_at_succ_iff_has_fderiv_within_at contDiffWithinAt_succ_iff_hasFDerivWithinAt /-- A version of `contDiffWithinAt_succ_iff_hasFDerivWithinAt` where all derivatives are taken within the same set. -/ theorem contDiffWithinAt_succ_iff_hasFDerivWithinAt' {n : ℕ} : ContDiffWithinAt 𝕜 (n + 1 : ℕ) f s x ↔ ∃ u ∈ 𝓝[insert x s] x, u ⊆ insert x s ∧ ∃ f' : E → E →L[𝕜] F, (∀ x ∈ u, HasFDerivWithinAt f (f' x) s x) ∧ ContDiffWithinAt 𝕜 n f' s x := by refine ⟨fun hf => ?_, ?_⟩ · obtain ⟨u, hu, f', huf', hf'⟩ := contDiffWithinAt_succ_iff_hasFDerivWithinAt.mp hf obtain ⟨w, hw, hxw, hwu⟩ := mem_nhdsWithin.mp hu rw [inter_comm] at hwu refine ⟨insert x s ∩ w, inter_mem_nhdsWithin _ (hw.mem_nhds hxw), inter_subset_left, f', fun y hy => ?_, ?_⟩ · refine ((huf' y <| hwu hy).mono hwu).mono_of_mem ?_ refine mem_of_superset ?_ (inter_subset_inter_left _ (subset_insert _ _)) exact inter_mem_nhdsWithin _ (hw.mem_nhds hy.2) · exact hf'.mono_of_mem (nhdsWithin_mono _ (subset_insert _ _) hu) · rw [← contDiffWithinAt_insert, contDiffWithinAt_succ_iff_hasFDerivWithinAt, insert_eq_of_mem (mem_insert _ _)] rintro ⟨u, hu, hus, f', huf', hf'⟩ exact ⟨u, hu, f', fun y hy => (huf' y hy).insert'.mono hus, hf'.insert.mono hus⟩ #align cont_diff_within_at_succ_iff_has_fderiv_within_at' contDiffWithinAt_succ_iff_hasFDerivWithinAt' /-! ### Smooth functions within a set -/ variable (𝕜) /-- A function is continuously differentiable up to `n` on `s` if, for any point `x` in `s`, it admits continuous derivatives up to order `n` on a neighborhood of `x` in `s`. For `n = ∞`, we only require that this holds up to any finite order (where the neighborhood may depend on the finite order we consider). -/ def ContDiffOn (n : ℕ∞) (f : E → F) (s : Set E) : Prop := ∀ x ∈ s, ContDiffWithinAt 𝕜 n f s x #align cont_diff_on ContDiffOn variable {𝕜} theorem HasFTaylorSeriesUpToOn.contDiffOn {f' : E → FormalMultilinearSeries 𝕜 E F} (hf : HasFTaylorSeriesUpToOn n f f' s) : ContDiffOn 𝕜 n f s := by intro x hx m hm use s simp only [Set.insert_eq_of_mem hx, self_mem_nhdsWithin, true_and_iff] exact ⟨f', hf.of_le hm⟩ #align has_ftaylor_series_up_to_on.cont_diff_on HasFTaylorSeriesUpToOn.contDiffOn theorem ContDiffOn.contDiffWithinAt (h : ContDiffOn 𝕜 n f s) (hx : x ∈ s) : ContDiffWithinAt 𝕜 n f s x := h x hx #align cont_diff_on.cont_diff_within_at ContDiffOn.contDiffWithinAt theorem ContDiffWithinAt.contDiffOn' {m : ℕ} (hm : (m : ℕ∞) ≤ n) (h : ContDiffWithinAt 𝕜 n f s x) : ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 m f (insert x s ∩ u) := by rcases h m hm with ⟨t, ht, p, hp⟩ rcases mem_nhdsWithin.1 ht with ⟨u, huo, hxu, hut⟩ rw [inter_comm] at hut exact ⟨u, huo, hxu, (hp.mono hut).contDiffOn⟩ #align cont_diff_within_at.cont_diff_on' ContDiffWithinAt.contDiffOn' theorem ContDiffWithinAt.contDiffOn {m : ℕ} (hm : (m : ℕ∞) ≤ n) (h : ContDiffWithinAt 𝕜 n f s x) : ∃ u ∈ 𝓝[insert x s] x, u ⊆ insert x s ∧ ContDiffOn 𝕜 m f u := let ⟨_u, uo, xu, h⟩ := h.contDiffOn' hm ⟨_, inter_mem_nhdsWithin _ (uo.mem_nhds xu), inter_subset_left, h⟩ #align cont_diff_within_at.cont_diff_on ContDiffWithinAt.contDiffOn protected theorem ContDiffWithinAt.eventually {n : ℕ} (h : ContDiffWithinAt 𝕜 n f s x) : ∀ᶠ y in 𝓝[insert x s] x, ContDiffWithinAt 𝕜 n f s y := by rcases h.contDiffOn le_rfl with ⟨u, hu, _, hd⟩ have : ∀ᶠ y : E in 𝓝[insert x s] x, u ∈ 𝓝[insert x s] y ∧ y ∈ u := (eventually_nhdsWithin_nhdsWithin.2 hu).and hu refine this.mono fun y hy => (hd y hy.2).mono_of_mem ?_ exact nhdsWithin_mono y (subset_insert _ _) hy.1 #align cont_diff_within_at.eventually ContDiffWithinAt.eventually theorem ContDiffOn.of_le (h : ContDiffOn 𝕜 n f s) (hmn : m ≤ n) : ContDiffOn 𝕜 m f s := fun x hx => (h x hx).of_le hmn #align cont_diff_on.of_le ContDiffOn.of_le theorem ContDiffOn.of_succ {n : ℕ} (h : ContDiffOn 𝕜 (n + 1) f s) : ContDiffOn 𝕜 n f s := h.of_le <| WithTop.coe_le_coe.mpr le_self_add #align cont_diff_on.of_succ ContDiffOn.of_succ theorem ContDiffOn.one_of_succ {n : ℕ} (h : ContDiffOn 𝕜 (n + 1) f s) : ContDiffOn 𝕜 1 f s := h.of_le <| WithTop.coe_le_coe.mpr le_add_self #align cont_diff_on.one_of_succ ContDiffOn.one_of_succ theorem contDiffOn_iff_forall_nat_le : ContDiffOn 𝕜 n f s ↔ ∀ m : ℕ, ↑m ≤ n → ContDiffOn 𝕜 m f s := ⟨fun H _ hm => H.of_le hm, fun H x hx m hm => H m hm x hx m le_rfl⟩ #align cont_diff_on_iff_forall_nat_le contDiffOn_iff_forall_nat_le theorem contDiffOn_top : ContDiffOn 𝕜 ∞ f s ↔ ∀ n : ℕ, ContDiffOn 𝕜 n f s := contDiffOn_iff_forall_nat_le.trans <| by simp only [le_top, forall_prop_of_true] #align cont_diff_on_top contDiffOn_top theorem contDiffOn_all_iff_nat : (∀ n, ContDiffOn 𝕜 n f s) ↔ ∀ n : ℕ, ContDiffOn 𝕜 n f s := by refine ⟨fun H n => H n, ?_⟩ rintro H (_ | n) exacts [contDiffOn_top.2 H, H n] #align cont_diff_on_all_iff_nat contDiffOn_all_iff_nat theorem ContDiffOn.continuousOn (h : ContDiffOn 𝕜 n f s) : ContinuousOn f s := fun x hx => (h x hx).continuousWithinAt #align cont_diff_on.continuous_on ContDiffOn.continuousOn theorem ContDiffOn.congr (h : ContDiffOn 𝕜 n f s) (h₁ : ∀ x ∈ s, f₁ x = f x) : ContDiffOn 𝕜 n f₁ s := fun x hx => (h x hx).congr h₁ (h₁ x hx) #align cont_diff_on.congr ContDiffOn.congr theorem contDiffOn_congr (h₁ : ∀ x ∈ s, f₁ x = f x) : ContDiffOn 𝕜 n f₁ s ↔ ContDiffOn 𝕜 n f s := ⟨fun H => H.congr fun x hx => (h₁ x hx).symm, fun H => H.congr h₁⟩ #align cont_diff_on_congr contDiffOn_congr theorem ContDiffOn.mono (h : ContDiffOn 𝕜 n f s) {t : Set E} (hst : t ⊆ s) : ContDiffOn 𝕜 n f t := fun x hx => (h x (hst hx)).mono hst #align cont_diff_on.mono ContDiffOn.mono theorem ContDiffOn.congr_mono (hf : ContDiffOn 𝕜 n f s) (h₁ : ∀ x ∈ s₁, f₁ x = f x) (hs : s₁ ⊆ s) : ContDiffOn 𝕜 n f₁ s₁ := (hf.mono hs).congr h₁ #align cont_diff_on.congr_mono ContDiffOn.congr_mono /-- If a function is `C^n` on a set with `n ≥ 1`, then it is differentiable there. -/ theorem ContDiffOn.differentiableOn (h : ContDiffOn 𝕜 n f s) (hn : 1 ≤ n) : DifferentiableOn 𝕜 f s := fun x hx => (h x hx).differentiableWithinAt hn #align cont_diff_on.differentiable_on ContDiffOn.differentiableOn /-- If a function is `C^n` around each point in a set, then it is `C^n` on the set. -/ theorem contDiffOn_of_locally_contDiffOn (h : ∀ x ∈ s, ∃ u, IsOpen u ∧ x ∈ u ∧ ContDiffOn 𝕜 n f (s ∩ u)) : ContDiffOn 𝕜 n f s := by intro x xs rcases h x xs with ⟨u, u_open, xu, hu⟩ apply (contDiffWithinAt_inter _).1 (hu x ⟨xs, xu⟩) exact IsOpen.mem_nhds u_open xu #align cont_diff_on_of_locally_cont_diff_on contDiffOn_of_locally_contDiffOn /-- A function is `C^(n + 1)` on a domain iff locally, it has a derivative which is `C^n`. -/ theorem contDiffOn_succ_iff_hasFDerivWithinAt {n : ℕ} : ContDiffOn 𝕜 (n + 1 : ℕ) f s ↔ ∀ x ∈ s, ∃ u ∈ 𝓝[insert x s] x, ∃ f' : E → E →L[𝕜] F, (∀ x ∈ u, HasFDerivWithinAt f (f' x) u x) ∧ ContDiffOn 𝕜 n f' u := by constructor · intro h x hx rcases (h x hx) n.succ le_rfl with ⟨u, hu, p, Hp⟩ refine ⟨u, hu, fun y => (continuousMultilinearCurryFin1 𝕜 E F) (p y 1), fun y hy => Hp.hasFDerivWithinAt (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)) hy, ?_⟩ rw [hasFTaylorSeriesUpToOn_succ_iff_right] at Hp intro z hz m hm refine ⟨u, ?_, fun x : E => (p x).shift, Hp.2.2.of_le hm⟩ -- Porting note: without the explicit arguments `convert` can not determine the type. convert @self_mem_nhdsWithin _ _ z u exact insert_eq_of_mem hz · intro h x hx rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt] rcases h x hx with ⟨u, u_nhbd, f', hu, hf'⟩ have : x ∈ u := mem_of_mem_nhdsWithin (mem_insert _ _) u_nhbd exact ⟨u, u_nhbd, f', hu, hf' x this⟩ #align cont_diff_on_succ_iff_has_fderiv_within_at contDiffOn_succ_iff_hasFDerivWithinAt /-! ### Iterated derivative within a set -/ variable (𝕜) /-- The `n`-th derivative of a function along a set, defined inductively by saying that the `n+1`-th derivative of `f` is the derivative of the `n`-th derivative of `f` along this set, together with an uncurrying step to see it as a multilinear map in `n+1` variables.. -/ noncomputable def iteratedFDerivWithin (n : ℕ) (f : E → F) (s : Set E) : E → E[×n]→L[𝕜] F := Nat.recOn n (fun x => ContinuousMultilinearMap.curry0 𝕜 E (f x)) fun _ rec x => ContinuousLinearMap.uncurryLeft (fderivWithin 𝕜 rec s x) #align iterated_fderiv_within iteratedFDerivWithin /-- Formal Taylor series associated to a function within a set. -/ def ftaylorSeriesWithin (f : E → F) (s : Set E) (x : E) : FormalMultilinearSeries 𝕜 E F := fun n => iteratedFDerivWithin 𝕜 n f s x #align ftaylor_series_within ftaylorSeriesWithin variable {𝕜} @[simp] theorem iteratedFDerivWithin_zero_apply (m : Fin 0 → E) : (iteratedFDerivWithin 𝕜 0 f s x : (Fin 0 → E) → F) m = f x := rfl #align iterated_fderiv_within_zero_apply iteratedFDerivWithin_zero_apply theorem iteratedFDerivWithin_zero_eq_comp : iteratedFDerivWithin 𝕜 0 f s = (continuousMultilinearCurryFin0 𝕜 E F).symm ∘ f := rfl #align iterated_fderiv_within_zero_eq_comp iteratedFDerivWithin_zero_eq_comp @[simp] theorem norm_iteratedFDerivWithin_zero : ‖iteratedFDerivWithin 𝕜 0 f s x‖ = ‖f x‖ := by -- Porting note: added `comp_apply`. rw [iteratedFDerivWithin_zero_eq_comp, comp_apply, LinearIsometryEquiv.norm_map] #align norm_iterated_fderiv_within_zero norm_iteratedFDerivWithin_zero theorem iteratedFDerivWithin_succ_apply_left {n : ℕ} (m : Fin (n + 1) → E) : (iteratedFDerivWithin 𝕜 (n + 1) f s x : (Fin (n + 1) → E) → F) m = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x : E → E[×n]→L[𝕜] F) (m 0) (tail m) := rfl #align iterated_fderiv_within_succ_apply_left iteratedFDerivWithin_succ_apply_left /-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv, and the derivative of the `n`-th derivative. -/ theorem iteratedFDerivWithin_succ_eq_comp_left {n : ℕ} : iteratedFDerivWithin 𝕜 (n + 1) f s = (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F : (E →L[𝕜] (E [×n]→L[𝕜] F)) → (E [×n.succ]→L[𝕜] F)) ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s := rfl #align iterated_fderiv_within_succ_eq_comp_left iteratedFDerivWithin_succ_eq_comp_left theorem fderivWithin_iteratedFDerivWithin {s : Set E} {n : ℕ} : fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s = (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) => E) F).symm ∘ iteratedFDerivWithin 𝕜 (n + 1) f s := by rw [iteratedFDerivWithin_succ_eq_comp_left] ext1 x simp only [Function.comp_apply, LinearIsometryEquiv.symm_apply_apply] theorem norm_fderivWithin_iteratedFDerivWithin {n : ℕ} : ‖fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n f s) s x‖ = ‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ := by -- Porting note: added `comp_apply`. rw [iteratedFDerivWithin_succ_eq_comp_left, comp_apply, LinearIsometryEquiv.norm_map] #align norm_fderiv_within_iterated_fderiv_within norm_fderivWithin_iteratedFDerivWithin theorem iteratedFDerivWithin_succ_apply_right {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) (m : Fin (n + 1) → E) : (iteratedFDerivWithin 𝕜 (n + 1) f s x : (Fin (n + 1) → E) → F) m = iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s x (init m) (m (last n)) := by induction' n with n IH generalizing x · rw [iteratedFDerivWithin_succ_eq_comp_left, iteratedFDerivWithin_zero_eq_comp, iteratedFDerivWithin_zero_apply, Function.comp_apply, LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)] rfl · let I := continuousMultilinearCurryRightEquiv' 𝕜 n E F have A : ∀ y ∈ s, iteratedFDerivWithin 𝕜 n.succ f s y = (I ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) y := fun y hy ↦ by ext m rw [@IH y hy m] rfl calc (iteratedFDerivWithin 𝕜 (n + 2) f s x : (Fin (n + 2) → E) → F) m = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n.succ f s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := rfl _ = (fderivWithin 𝕜 (I ∘ iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by rw [fderivWithin_congr A (A x hx)] _ = (I ∘ fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) s x : E → E[×n + 1]→L[𝕜] F) (m 0) (tail m) := by #adaptation_note /-- After https://github.com/leanprover/lean4/pull/4119 we need to either use `set_option maxSynthPendingDepth 2 in` or fill in an explicit argument as ``` simp only [LinearIsometryEquiv.comp_fderivWithin _ (f := iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s) (hs x hx)] ``` -/ set_option maxSynthPendingDepth 2 in simp only [LinearIsometryEquiv.comp_fderivWithin _ (hs x hx)] rfl _ = (fderivWithin 𝕜 (iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) s x : E → E[×n]→L[𝕜] E →L[𝕜] F) (m 0) (init (tail m)) ((tail m) (last n)) := rfl _ = iteratedFDerivWithin 𝕜 (Nat.succ n) (fun y => fderivWithin 𝕜 f s y) s x (init m) (m (last (n + 1))) := by rw [iteratedFDerivWithin_succ_apply_left, tail_init_eq_init_tail] rfl #align iterated_fderiv_within_succ_apply_right iteratedFDerivWithin_succ_apply_right /-- Writing explicitly the `n+1`-th derivative as the composition of a currying linear equiv, and the `n`-th derivative of the derivative. -/ theorem iteratedFDerivWithin_succ_eq_comp_right {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : iteratedFDerivWithin 𝕜 (n + 1) f s x = (continuousMultilinearCurryRightEquiv' 𝕜 n E F ∘ iteratedFDerivWithin 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) x := by ext m; rw [iteratedFDerivWithin_succ_apply_right hs hx]; rfl #align iterated_fderiv_within_succ_eq_comp_right iteratedFDerivWithin_succ_eq_comp_right theorem norm_iteratedFDerivWithin_fderivWithin {n : ℕ} (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : ‖iteratedFDerivWithin 𝕜 n (fderivWithin 𝕜 f s) s x‖ = ‖iteratedFDerivWithin 𝕜 (n + 1) f s x‖ := by -- Porting note: added `comp_apply`. rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply, LinearIsometryEquiv.norm_map] #align norm_iterated_fderiv_within_fderiv_within norm_iteratedFDerivWithin_fderivWithin @[simp] theorem iteratedFDerivWithin_one_apply (h : UniqueDiffWithinAt 𝕜 s x) (m : Fin 1 → E) : iteratedFDerivWithin 𝕜 1 f s x m = fderivWithin 𝕜 f s x (m 0) := by simp only [iteratedFDerivWithin_succ_apply_left, iteratedFDerivWithin_zero_eq_comp, (continuousMultilinearCurryFin0 𝕜 E F).symm.comp_fderivWithin h] rfl #align iterated_fderiv_within_one_apply iteratedFDerivWithin_one_apply /-- On a set of unique differentiability, the second derivative is obtained by taking the derivative of the derivative. -/ lemma iteratedFDerivWithin_two_apply (f : E → F) {z : E} (hs : UniqueDiffOn 𝕜 s) (hz : z ∈ s) (m : Fin 2 → E) : iteratedFDerivWithin 𝕜 2 f s z m = fderivWithin 𝕜 (fderivWithin 𝕜 f s) s z (m 0) (m 1) := by simp only [iteratedFDerivWithin_succ_apply_right hs hz] rfl theorem Filter.EventuallyEq.iteratedFDerivWithin' (h : f₁ =ᶠ[𝓝[s] x] f) (ht : t ⊆ s) (n : ℕ) : iteratedFDerivWithin 𝕜 n f₁ t =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f t := by induction' n with n ihn · exact h.mono fun y hy => DFunLike.ext _ _ fun _ => hy · have : fderivWithin 𝕜 _ t =ᶠ[𝓝[s] x] fderivWithin 𝕜 _ t := ihn.fderivWithin' ht apply this.mono intro y hy simp only [iteratedFDerivWithin_succ_eq_comp_left, hy, (· ∘ ·)] #align filter.eventually_eq.iterated_fderiv_within' Filter.EventuallyEq.iteratedFDerivWithin' protected theorem Filter.EventuallyEq.iteratedFDerivWithin (h : f₁ =ᶠ[𝓝[s] x] f) (n : ℕ) : iteratedFDerivWithin 𝕜 n f₁ s =ᶠ[𝓝[s] x] iteratedFDerivWithin 𝕜 n f s := h.iteratedFDerivWithin' Subset.rfl n #align filter.eventually_eq.iterated_fderiv_within Filter.EventuallyEq.iteratedFDerivWithin /-- If two functions coincide in a neighborhood of `x` within a set `s` and at `x`, then their iterated differentials within this set at `x` coincide. -/ theorem Filter.EventuallyEq.iteratedFDerivWithin_eq (h : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) (n : ℕ) : iteratedFDerivWithin 𝕜 n f₁ s x = iteratedFDerivWithin 𝕜 n f s x := have : f₁ =ᶠ[𝓝[insert x s] x] f := by simpa [EventuallyEq, hx] (this.iteratedFDerivWithin' (subset_insert _ _) n).self_of_nhdsWithin (mem_insert _ _) #align filter.eventually_eq.iterated_fderiv_within_eq Filter.EventuallyEq.iteratedFDerivWithin_eq /-- If two functions coincide on a set `s`, then their iterated differentials within this set coincide. See also `Filter.EventuallyEq.iteratedFDerivWithin_eq` and `Filter.EventuallyEq.iteratedFDerivWithin`. -/ theorem iteratedFDerivWithin_congr (hs : EqOn f₁ f s) (hx : x ∈ s) (n : ℕ) : iteratedFDerivWithin 𝕜 n f₁ s x = iteratedFDerivWithin 𝕜 n f s x := (hs.eventuallyEq.filter_mono inf_le_right).iteratedFDerivWithin_eq (hs hx) _ #align iterated_fderiv_within_congr iteratedFDerivWithin_congr /-- If two functions coincide on a set `s`, then their iterated differentials within this set coincide. See also `Filter.EventuallyEq.iteratedFDerivWithin_eq` and `Filter.EventuallyEq.iteratedFDerivWithin`. -/ protected theorem Set.EqOn.iteratedFDerivWithin (hs : EqOn f₁ f s) (n : ℕ) : EqOn (iteratedFDerivWithin 𝕜 n f₁ s) (iteratedFDerivWithin 𝕜 n f s) s := fun _x hx => iteratedFDerivWithin_congr hs hx n #align set.eq_on.iterated_fderiv_within Set.EqOn.iteratedFDerivWithin theorem iteratedFDerivWithin_eventually_congr_set' (y : E) (h : s =ᶠ[𝓝[{y}ᶜ] x] t) (n : ℕ) : iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t := by induction' n with n ihn generalizing x · rfl · refine (eventually_nhds_nhdsWithin.2 h).mono fun y hy => ?_ simp only [iteratedFDerivWithin_succ_eq_comp_left, (· ∘ ·)] rw [(ihn hy).fderivWithin_eq_nhds, fderivWithin_congr_set' _ hy] #align iterated_fderiv_within_eventually_congr_set' iteratedFDerivWithin_eventually_congr_set' theorem iteratedFDerivWithin_eventually_congr_set (h : s =ᶠ[𝓝 x] t) (n : ℕ) : iteratedFDerivWithin 𝕜 n f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 n f t := iteratedFDerivWithin_eventually_congr_set' x (h.filter_mono inf_le_left) n #align iterated_fderiv_within_eventually_congr_set iteratedFDerivWithin_eventually_congr_set theorem iteratedFDerivWithin_congr_set (h : s =ᶠ[𝓝 x] t) (n : ℕ) : iteratedFDerivWithin 𝕜 n f s x = iteratedFDerivWithin 𝕜 n f t x := (iteratedFDerivWithin_eventually_congr_set h n).self_of_nhds #align iterated_fderiv_within_congr_set iteratedFDerivWithin_congr_set /-- The iterated differential within a set `s` at a point `x` is not modified if one intersects `s` with a neighborhood of `x` within `s`. -/ theorem iteratedFDerivWithin_inter' {n : ℕ} (hu : u ∈ 𝓝[s] x) : iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x := iteratedFDerivWithin_congr_set (nhdsWithin_eq_iff_eventuallyEq.1 <| nhdsWithin_inter_of_mem' hu) _ #align iterated_fderiv_within_inter' iteratedFDerivWithin_inter' /-- The iterated differential within a set `s` at a point `x` is not modified if one intersects `s` with a neighborhood of `x`. -/ theorem iteratedFDerivWithin_inter {n : ℕ} (hu : u ∈ 𝓝 x) : iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x := iteratedFDerivWithin_inter' (mem_nhdsWithin_of_mem_nhds hu) #align iterated_fderiv_within_inter iteratedFDerivWithin_inter /-- The iterated differential within a set `s` at a point `x` is not modified if one intersects `s` with an open set containing `x`. -/ theorem iteratedFDerivWithin_inter_open {n : ℕ} (hu : IsOpen u) (hx : x ∈ u) : iteratedFDerivWithin 𝕜 n f (s ∩ u) x = iteratedFDerivWithin 𝕜 n f s x := iteratedFDerivWithin_inter (hu.mem_nhds hx) #align iterated_fderiv_within_inter_open iteratedFDerivWithin_inter_open @[simp] theorem contDiffOn_zero : ContDiffOn 𝕜 0 f s ↔ ContinuousOn f s := by refine ⟨fun H => H.continuousOn, fun H => ?_⟩ intro x hx m hm have : (m : ℕ∞) = 0 := le_antisymm hm bot_le rw [this] refine ⟨insert x s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, ?_⟩ rw [hasFTaylorSeriesUpToOn_zero_iff] exact ⟨by rwa [insert_eq_of_mem hx], fun x _ => by simp [ftaylorSeriesWithin]⟩ #align cont_diff_on_zero contDiffOn_zero theorem contDiffWithinAt_zero (hx : x ∈ s) : ContDiffWithinAt 𝕜 0 f s x ↔ ∃ u ∈ 𝓝[s] x, ContinuousOn f (s ∩ u) := by constructor · intro h obtain ⟨u, H, p, hp⟩ := h 0 le_rfl refine ⟨u, ?_, ?_⟩ · simpa [hx] using H · simp only [Nat.cast_zero, hasFTaylorSeriesUpToOn_zero_iff] at hp exact hp.1.mono inter_subset_right · rintro ⟨u, H, hu⟩ rw [← contDiffWithinAt_inter' H] have h' : x ∈ s ∩ u := ⟨hx, mem_of_mem_nhdsWithin hx H⟩ exact (contDiffOn_zero.mpr hu).contDiffWithinAt h' #align cont_diff_within_at_zero contDiffWithinAt_zero /-- On a set with unique differentiability, any choice of iterated differential has to coincide with the one we have chosen in `iteratedFDerivWithin 𝕜 m f s`. -/ theorem HasFTaylorSeriesUpToOn.eq_iteratedFDerivWithin_of_uniqueDiffOn (h : HasFTaylorSeriesUpToOn n f p s) {m : ℕ} (hmn : (m : ℕ∞) ≤ n) (hs : UniqueDiffOn 𝕜 s) (hx : x ∈ s) : p x m = iteratedFDerivWithin 𝕜 m f s x := by induction' m with m IH generalizing x · rw [h.zero_eq' hx, iteratedFDerivWithin_zero_eq_comp]; rfl · have A : (m : ℕ∞) < n := lt_of_lt_of_le (WithTop.coe_lt_coe.2 (lt_add_one m)) hmn have : HasFDerivWithinAt (fun y : E => iteratedFDerivWithin 𝕜 m f s y) (ContinuousMultilinearMap.curryLeft (p x (Nat.succ m))) s x := (h.fderivWithin m A x hx).congr (fun y hy => (IH (le_of_lt A) hy).symm) (IH (le_of_lt A) hx).symm rw [iteratedFDerivWithin_succ_eq_comp_left, Function.comp_apply, this.fderivWithin (hs x hx)] exact (ContinuousMultilinearMap.uncurry_curryLeft _).symm #align has_ftaylor_series_up_to_on.eq_ftaylor_series_of_unique_diff_on HasFTaylorSeriesUpToOn.eq_iteratedFDerivWithin_of_uniqueDiffOn @[deprecated] alias HasFTaylorSeriesUpToOn.eq_ftaylor_series_of_uniqueDiffOn := HasFTaylorSeriesUpToOn.eq_iteratedFDerivWithin_of_uniqueDiffOn -- 2024-03-28 /-- When a function is `C^n` in a set `s` of unique differentiability, it admits `ftaylorSeriesWithin 𝕜 f s` as a Taylor series up to order `n` in `s`. -/ protected theorem ContDiffOn.ftaylorSeriesWithin (h : ContDiffOn 𝕜 n f s) (hs : UniqueDiffOn 𝕜 s) : HasFTaylorSeriesUpToOn n f (ftaylorSeriesWithin 𝕜 f s) s := by constructor · intro x _ simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.uncurry0_apply, iteratedFDerivWithin_zero_apply] · intro m hm x hx rcases (h x hx) m.succ (ENat.add_one_le_of_lt hm) with ⟨u, hu, p, Hp⟩ rw [insert_eq_of_mem hx] at hu rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ rw [inter_comm] at ho have : p x m.succ = ftaylorSeriesWithin 𝕜 f s x m.succ := by change p x m.succ = iteratedFDerivWithin 𝕜 m.succ f s x rw [← iteratedFDerivWithin_inter_open o_open xo] exact (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hx, xo⟩ rw [← this, ← hasFDerivWithinAt_inter (IsOpen.mem_nhds o_open xo)] have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by rintro y ⟨hy, yo⟩ change p y m = iteratedFDerivWithin 𝕜 m f s y rw [← iteratedFDerivWithin_inter_open o_open yo] exact (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn (WithTop.coe_le_coe.2 (Nat.le_succ m)) (hs.inter o_open) ⟨hy, yo⟩ exact ((Hp.mono ho).fderivWithin m (WithTop.coe_lt_coe.2 (lt_add_one m)) x ⟨hx, xo⟩).congr (fun y hy => (A y hy).symm) (A x ⟨hx, xo⟩).symm · intro m hm apply continuousOn_of_locally_continuousOn intro x hx rcases h x hx m hm with ⟨u, hu, p, Hp⟩ rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ rw [insert_eq_of_mem hx] at ho rw [inter_comm] at ho refine ⟨o, o_open, xo, ?_⟩ have A : ∀ y ∈ s ∩ o, p y m = ftaylorSeriesWithin 𝕜 f s y m := by rintro y ⟨hy, yo⟩ change p y m = iteratedFDerivWithin 𝕜 m f s y rw [← iteratedFDerivWithin_inter_open o_open yo] exact (Hp.mono ho).eq_iteratedFDerivWithin_of_uniqueDiffOn le_rfl (hs.inter o_open) ⟨hy, yo⟩ exact ((Hp.mono ho).cont m le_rfl).congr fun y hy => (A y hy).symm #align cont_diff_on.ftaylor_series_within ContDiffOn.ftaylorSeriesWithin theorem contDiffOn_of_continuousOn_differentiableOn (Hcont : ∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s) (Hdiff : ∀ m : ℕ, (m : ℕ∞) < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s) : ContDiffOn 𝕜 n f s := by intro x hx m hm rw [insert_eq_of_mem hx] refine ⟨s, self_mem_nhdsWithin, ftaylorSeriesWithin 𝕜 f s, ?_⟩ constructor · intro y _ simp only [ftaylorSeriesWithin, ContinuousMultilinearMap.uncurry0_apply, iteratedFDerivWithin_zero_apply] · intro k hk y hy convert (Hdiff k (lt_of_lt_of_le hk hm) y hy).hasFDerivWithinAt · intro k hk exact Hcont k (le_trans hk hm) #align cont_diff_on_of_continuous_on_differentiable_on contDiffOn_of_continuousOn_differentiableOn theorem contDiffOn_of_differentiableOn (h : ∀ m : ℕ, (m : ℕ∞) ≤ n → DifferentiableOn 𝕜 (iteratedFDerivWithin 𝕜 m f s) s) : ContDiffOn 𝕜 n f s := contDiffOn_of_continuousOn_differentiableOn (fun m hm => (h m hm).continuousOn) fun m hm => h m (le_of_lt hm) #align cont_diff_on_of_differentiable_on contDiffOn_of_differentiableOn theorem ContDiffOn.continuousOn_iteratedFDerivWithin {m : ℕ} (h : ContDiffOn 𝕜 n f s) (hmn : (m : ℕ∞) ≤ n) (hs : UniqueDiffOn 𝕜 s) : ContinuousOn (iteratedFDerivWithin 𝕜 m f s) s := (h.ftaylorSeriesWithin hs).cont m hmn #align cont_diff_on.continuous_on_iterated_fderiv_within ContDiffOn.continuousOn_iteratedFDerivWithin theorem ContDiffOn.differentiableOn_iteratedFDerivWithin {m : ℕ} (h : ContDiffOn 𝕜 n f s) (hmn : (m : ℕ∞) < n) (hs : UniqueDiffOn 𝕜 s) : DifferentiableOn 𝕜 (iteratedFDerivWithin 𝕜 m f s) s := fun x hx => ((h.ftaylorSeriesWithin hs).fderivWithin m hmn x hx).differentiableWithinAt #align cont_diff_on.differentiable_on_iterated_fderiv_within ContDiffOn.differentiableOn_iteratedFDerivWithin theorem ContDiffWithinAt.differentiableWithinAt_iteratedFDerivWithin {m : ℕ} (h : ContDiffWithinAt 𝕜 n f s x) (hmn : (m : ℕ∞) < n) (hs : UniqueDiffOn 𝕜 (insert x s)) : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f s) s x := by rcases h.contDiffOn' (ENat.add_one_le_of_lt hmn) with ⟨u, uo, xu, hu⟩ set t := insert x s ∩ u have A : t =ᶠ[𝓝[≠] x] s := by simp only [set_eventuallyEq_iff_inf_principal, ← nhdsWithin_inter'] rw [← inter_assoc, nhdsWithin_inter_of_mem', ← diff_eq_compl_inter, insert_diff_of_mem, diff_eq_compl_inter] exacts [rfl, mem_nhdsWithin_of_mem_nhds (uo.mem_nhds xu)] have B : iteratedFDerivWithin 𝕜 m f s =ᶠ[𝓝 x] iteratedFDerivWithin 𝕜 m f t := iteratedFDerivWithin_eventually_congr_set' _ A.symm _ have C : DifferentiableWithinAt 𝕜 (iteratedFDerivWithin 𝕜 m f t) t x := hu.differentiableOn_iteratedFDerivWithin (Nat.cast_lt.2 m.lt_succ_self) (hs.inter uo) x ⟨mem_insert _ _, xu⟩ rw [differentiableWithinAt_congr_set' _ A] at C exact C.congr_of_eventuallyEq (B.filter_mono inf_le_left) B.self_of_nhds #align cont_diff_within_at.differentiable_within_at_iterated_fderiv_within ContDiffWithinAt.differentiableWithinAt_iteratedFDerivWithin theorem contDiffOn_iff_continuousOn_differentiableOn (hs : UniqueDiffOn 𝕜 s) : ContDiffOn 𝕜 n f s ↔ (∀ m : ℕ, (m : ℕ∞) ≤ n → ContinuousOn (fun x => iteratedFDerivWithin 𝕜 m f s x) s) ∧ ∀ m : ℕ, (m : ℕ∞) < n → DifferentiableOn 𝕜 (fun x => iteratedFDerivWithin 𝕜 m f s x) s := ⟨fun h => ⟨fun _m hm => h.continuousOn_iteratedFDerivWithin hm hs, fun _m hm => h.differentiableOn_iteratedFDerivWithin hm hs⟩, fun h => contDiffOn_of_continuousOn_differentiableOn h.1 h.2⟩ #align cont_diff_on_iff_continuous_on_differentiable_on contDiffOn_iff_continuousOn_differentiableOn theorem contDiffOn_succ_of_fderivWithin {n : ℕ} (hf : DifferentiableOn 𝕜 f s) (h : ContDiffOn 𝕜 n (fun y => fderivWithin 𝕜 f s y) s) : ContDiffOn 𝕜 (n + 1 : ℕ) f s := by intro x hx rw [contDiffWithinAt_succ_iff_hasFDerivWithinAt, insert_eq_of_mem hx] exact ⟨s, self_mem_nhdsWithin, fderivWithin 𝕜 f s, fun y hy => (hf y hy).hasFDerivWithinAt, h x hx⟩ #align cont_diff_on_succ_of_fderiv_within contDiffOn_succ_of_fderivWithin /-- A function is `C^(n + 1)` on a domain with unique derivatives if and only if it is differentiable there, and its derivative (expressed with `fderivWithin`) is `C^n`. -/ theorem contDiffOn_succ_iff_fderivWithin {n : ℕ} (hs : UniqueDiffOn 𝕜 s) : ContDiffOn 𝕜 (n + 1 : ℕ) f s ↔ DifferentiableOn 𝕜 f s ∧ ContDiffOn 𝕜 n (fun y => fderivWithin 𝕜 f s y) s := by refine ⟨fun H => ?_, fun h => contDiffOn_succ_of_fderivWithin h.1 h.2⟩ refine ⟨H.differentiableOn (WithTop.coe_le_coe.2 (Nat.le_add_left 1 n)), fun x hx => ?_⟩ rcases contDiffWithinAt_succ_iff_hasFDerivWithinAt.1 (H x hx) with ⟨u, hu, f', hff', hf'⟩ rcases mem_nhdsWithin.1 hu with ⟨o, o_open, xo, ho⟩ rw [inter_comm, insert_eq_of_mem hx] at ho have := hf'.mono ho rw [contDiffWithinAt_inter' (mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds o_open xo))] at this apply this.congr_of_eventually_eq' _ hx have : o ∩ s ∈ 𝓝[s] x := mem_nhdsWithin.2 ⟨o, o_open, xo, Subset.refl _⟩ rw [inter_comm] at this refine Filter.eventuallyEq_of_mem this fun y hy => ?_ have A : fderivWithin 𝕜 f (s ∩ o) y = f' y := ((hff' y (ho hy)).mono ho).fderivWithin (hs.inter o_open y hy) rwa [fderivWithin_inter (o_open.mem_nhds hy.2)] at A #align cont_diff_on_succ_iff_fderiv_within contDiffOn_succ_iff_fderivWithin
Mathlib/Analysis/Calculus/ContDiff/Defs.lean
1,178
1,185
theorem contDiffOn_succ_iff_hasFDerivWithin {n : ℕ} (hs : UniqueDiffOn 𝕜 s) : ContDiffOn 𝕜 (n + 1 : ℕ) f s ↔ ∃ f' : E → E →L[𝕜] F, ContDiffOn 𝕜 n f' s ∧ ∀ x, x ∈ s → HasFDerivWithinAt f (f' x) s x := by
rw [contDiffOn_succ_iff_fderivWithin hs] refine ⟨fun h => ⟨fderivWithin 𝕜 f s, h.2, fun x hx => (h.1 x hx).hasFDerivWithinAt⟩, fun h => ?_⟩ rcases h with ⟨f', h1, h2⟩ refine ⟨fun x hx => (h2 x hx).differentiableWithinAt, fun x hx => ?_⟩ exact (h1 x hx).congr' (fun y hy => (h2 y hy).fderivWithin (hs y hy)) hx
/- Copyright (c) 2022 Anatole Dedecker. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anatole Dedecker -/ import Mathlib.Topology.Algebra.UniformConvergence #align_import topology.algebra.equicontinuity from "leanprover-community/mathlib"@"01ad394a11bf06b950232720cf7e8fc6b22f0d6a" /-! # Algebra-related equicontinuity criterions -/ open Function open UniformConvergence @[to_additive]
Mathlib/Topology/Algebra/Equicontinuity.lean
20
31
theorem equicontinuous_of_equicontinuousAt_one {ι G M hom : Type*} [TopologicalSpace G] [UniformSpace M] [Group G] [Group M] [TopologicalGroup G] [UniformGroup M] [FunLike hom G M] [MonoidHomClass hom G M] (F : ι → hom) (hf : EquicontinuousAt ((↑) ∘ F) (1 : G)) : Equicontinuous ((↑) ∘ F) := by
rw [equicontinuous_iff_continuous] rw [equicontinuousAt_iff_continuousAt] at hf let φ : G →* (ι →ᵤ M) := { toFun := swap ((↑) ∘ F) map_one' := by dsimp [UniformFun]; ext; exact map_one _ map_mul' := fun a b => by dsimp [UniformFun]; ext; exact map_mul _ _ _ } exact continuous_of_continuousAt_one φ hf
/- Copyright (c) 2022 Yaël Dillies, Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies, Bhavik Mehta -/ import Mathlib.Combinatorics.SimpleGraph.Connectivity import Mathlib.Combinatorics.SimpleGraph.Operations import Mathlib.Data.Finset.Pairwise #align_import combinatorics.simple_graph.clique from "leanprover-community/mathlib"@"3365b20c2ffa7c35e47e5209b89ba9abdddf3ffe" /-! # Graph cliques This file defines cliques in simple graphs. A clique is a set of vertices that are pairwise adjacent. ## Main declarations * `SimpleGraph.IsClique`: Predicate for a set of vertices to be a clique. * `SimpleGraph.IsNClique`: Predicate for a set of vertices to be an `n`-clique. * `SimpleGraph.cliqueFinset`: Finset of `n`-cliques of a graph. * `SimpleGraph.CliqueFree`: Predicate for a graph to have no `n`-cliques. ## TODO * Clique numbers * Dualise all the API to get independent sets -/ open Finset Fintype Function SimpleGraph.Walk namespace SimpleGraph variable {α β : Type*} (G H : SimpleGraph α) /-! ### Cliques -/ section Clique variable {s t : Set α} /-- A clique in a graph is a set of vertices that are pairwise adjacent. -/ abbrev IsClique (s : Set α) : Prop := s.Pairwise G.Adj #align simple_graph.is_clique SimpleGraph.IsClique theorem isClique_iff : G.IsClique s ↔ s.Pairwise G.Adj := Iff.rfl #align simple_graph.is_clique_iff SimpleGraph.isClique_iff /-- A clique is a set of vertices whose induced graph is complete. -/ theorem isClique_iff_induce_eq : G.IsClique s ↔ G.induce s = ⊤ := by rw [isClique_iff] constructor · intro h ext ⟨v, hv⟩ ⟨w, hw⟩ simp only [comap_adj, Subtype.coe_mk, top_adj, Ne, Subtype.mk_eq_mk] exact ⟨Adj.ne, h hv hw⟩ · intro h v hv w hw hne have h2 : (G.induce s).Adj ⟨v, hv⟩ ⟨w, hw⟩ = _ := rfl conv_lhs at h2 => rw [h] simp only [top_adj, ne_eq, Subtype.mk.injEq, eq_iff_iff] at h2 exact h2.1 hne #align simple_graph.is_clique_iff_induce_eq SimpleGraph.isClique_iff_induce_eq instance [DecidableEq α] [DecidableRel G.Adj] {s : Finset α} : Decidable (G.IsClique s) := decidable_of_iff' _ G.isClique_iff variable {G H} {a b : α} lemma isClique_empty : G.IsClique ∅ := by simp #align simple_graph.is_clique_empty SimpleGraph.isClique_empty lemma isClique_singleton (a : α) : G.IsClique {a} := by simp #align simple_graph.is_clique_singleton SimpleGraph.isClique_singleton lemma isClique_pair : G.IsClique {a, b} ↔ a ≠ b → G.Adj a b := Set.pairwise_pair_of_symmetric G.symm #align simple_graph.is_clique_pair SimpleGraph.isClique_pair @[simp] lemma isClique_insert : G.IsClique (insert a s) ↔ G.IsClique s ∧ ∀ b ∈ s, a ≠ b → G.Adj a b := Set.pairwise_insert_of_symmetric G.symm #align simple_graph.is_clique_insert SimpleGraph.isClique_insert lemma isClique_insert_of_not_mem (ha : a ∉ s) : G.IsClique (insert a s) ↔ G.IsClique s ∧ ∀ b ∈ s, G.Adj a b := Set.pairwise_insert_of_symmetric_of_not_mem G.symm ha #align simple_graph.is_clique_insert_of_not_mem SimpleGraph.isClique_insert_of_not_mem lemma IsClique.insert (hs : G.IsClique s) (h : ∀ b ∈ s, a ≠ b → G.Adj a b) : G.IsClique (insert a s) := hs.insert_of_symmetric G.symm h #align simple_graph.is_clique.insert SimpleGraph.IsClique.insert theorem IsClique.mono (h : G ≤ H) : G.IsClique s → H.IsClique s := Set.Pairwise.mono' h #align simple_graph.is_clique.mono SimpleGraph.IsClique.mono theorem IsClique.subset (h : t ⊆ s) : G.IsClique s → G.IsClique t := Set.Pairwise.mono h #align simple_graph.is_clique.subset SimpleGraph.IsClique.subset protected theorem IsClique.map {s : Set α} (h : G.IsClique s) {f : α ↪ β} : (G.map f).IsClique (f '' s) := by rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ hab exact ⟨a, b, h ha hb <| ne_of_apply_ne _ hab, rfl, rfl⟩ #align simple_graph.is_clique.map SimpleGraph.IsClique.map @[simp] theorem isClique_bot_iff : (⊥ : SimpleGraph α).IsClique s ↔ (s : Set α).Subsingleton := Set.pairwise_bot_iff #align simple_graph.is_clique_bot_iff SimpleGraph.isClique_bot_iff alias ⟨IsClique.subsingleton, _⟩ := isClique_bot_iff #align simple_graph.is_clique.subsingleton SimpleGraph.IsClique.subsingleton end Clique /-! ### `n`-cliques -/ section NClique variable {n : ℕ} {s : Finset α} /-- An `n`-clique in a graph is a set of `n` vertices which are pairwise connected. -/ structure IsNClique (n : ℕ) (s : Finset α) : Prop where clique : G.IsClique s card_eq : s.card = n #align simple_graph.is_n_clique SimpleGraph.IsNClique theorem isNClique_iff : G.IsNClique n s ↔ G.IsClique s ∧ s.card = n := ⟨fun h ↦ ⟨h.1, h.2⟩, fun h ↦ ⟨h.1, h.2⟩⟩ #align simple_graph.is_n_clique_iff SimpleGraph.isNClique_iff instance [DecidableEq α] [DecidableRel G.Adj] {n : ℕ} {s : Finset α} : Decidable (G.IsNClique n s) := decidable_of_iff' _ G.isNClique_iff variable {G H} {a b c : α} @[simp] lemma isNClique_empty : G.IsNClique n ∅ ↔ n = 0 := by simp [isNClique_iff, eq_comm] #align simple_graph.is_n_clique_empty SimpleGraph.isNClique_empty @[simp] lemma isNClique_singleton : G.IsNClique n {a} ↔ n = 1 := by simp [isNClique_iff, eq_comm] #align simple_graph.is_n_clique_singleton SimpleGraph.isNClique_singleton theorem IsNClique.mono (h : G ≤ H) : G.IsNClique n s → H.IsNClique n s := by simp_rw [isNClique_iff] exact And.imp_left (IsClique.mono h) #align simple_graph.is_n_clique.mono SimpleGraph.IsNClique.mono protected theorem IsNClique.map (h : G.IsNClique n s) {f : α ↪ β} : (G.map f).IsNClique n (s.map f) := ⟨by rw [coe_map]; exact h.1.map, (card_map _).trans h.2⟩ #align simple_graph.is_n_clique.map SimpleGraph.IsNClique.map @[simp] theorem isNClique_bot_iff : (⊥ : SimpleGraph α).IsNClique n s ↔ n ≤ 1 ∧ s.card = n := by rw [isNClique_iff, isClique_bot_iff] refine and_congr_left ?_ rintro rfl exact card_le_one.symm #align simple_graph.is_n_clique_bot_iff SimpleGraph.isNClique_bot_iff @[simp] theorem isNClique_zero : G.IsNClique 0 s ↔ s = ∅ := by simp only [isNClique_iff, Finset.card_eq_zero, and_iff_right_iff_imp]; rintro rfl; simp #align simple_graph.is_n_clique_zero SimpleGraph.isNClique_zero @[simp]
Mathlib/Combinatorics/SimpleGraph/Clique.lean
173
174
theorem isNClique_one : G.IsNClique 1 s ↔ ∃ a, s = {a} := by
simp only [isNClique_iff, card_eq_one, and_iff_right_iff_imp]; rintro ⟨a, rfl⟩; simp
/- Copyright (c) 2019 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.FDeriv.Basic #align_import analysis.calculus.fderiv.restrict_scalars from "leanprover-community/mathlib"@"e3fb84046afd187b710170887195d50bada934ee" /-! # The derivative of the scalar restriction of a linear map For detailed documentation of the Fréchet derivative, see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`. This file contains the usual formulas (and existence assertions) for the derivative of the scalar restriction of a linear map. -/ open Filter Asymptotics ContinuousLinearMap Set Metric open scoped Classical open Topology NNReal Filter Asymptotics ENNReal noncomputable section section RestrictScalars /-! ### Restricting from `ℂ` to `ℝ`, or generally from `𝕜'` to `𝕜` If a function is differentiable over `ℂ`, then it is differentiable over `ℝ`. In this paragraph, we give variants of this statement, in the general situation where `ℂ` and `ℝ` are replaced respectively by `𝕜'` and `𝕜` where `𝕜'` is a normed algebra over `𝕜`. -/ 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] 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 #align has_fderiv_at_of_restrict_scalars hasFDerivAt_of_restrictScalars theorem DifferentiableAt.fderiv_restrictScalars (h : DifferentiableAt 𝕜' f x) : fderiv 𝕜 f x = (fderiv 𝕜' f x).restrictScalars 𝕜 := (h.hasFDerivAt.restrictScalars 𝕜).fderiv #align differentiable_at.fderiv_restrict_scalars DifferentiableAt.fderiv_restrictScalars
Mathlib/Analysis/Calculus/FDeriv/RestrictScalars.lean
110
117
theorem differentiableWithinAt_iff_restrictScalars (hf : DifferentiableWithinAt 𝕜 f s x) (hs : UniqueDiffWithinAt 𝕜 s x) : DifferentiableWithinAt 𝕜' f s x ↔ ∃ g' : E →L[𝕜'] F, g'.restrictScalars 𝕜 = fderivWithin 𝕜 f s x := by
constructor · rintro ⟨g', hg'⟩ exact ⟨g', hs.eq (hg'.restrictScalars 𝕜) hf.hasFDerivWithinAt⟩ · rintro ⟨f', hf'⟩ exact ⟨f', hf.hasFDerivWithinAt.of_restrictScalars 𝕜 hf'⟩
/- Copyright (c) 2022 Joseph Myers. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Myers, Heather Macbeth -/ import Mathlib.Analysis.InnerProductSpace.TwoDim import Mathlib.Geometry.Euclidean.Angle.Unoriented.Basic #align_import geometry.euclidean.angle.oriented.basic from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9" /-! # Oriented angles. This file defines oriented angles in real inner product spaces. ## Main definitions * `Orientation.oangle` is the oriented angle between two vectors with respect to an orientation. ## Implementation notes The definitions here use the `Real.angle` type, angles modulo `2 * π`. For some purposes, angles modulo `π` are more convenient, because results are true for such angles with less configuration dependence. Results that are only equalities modulo `π` can be represented modulo `2 * π` as equalities of `(2 : ℤ) • θ`. ## References * Evan Chen, Euclidean Geometry in Mathematical Olympiads. -/ 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 /-- The oriented angle from `x` to `y`, modulo `2 * π`. If either vector is 0, this is 0. See `InnerProductGeometry.angle` for the corresponding unoriented angle definition. -/ def oangle (x y : V) : Real.Angle := Complex.arg (o.kahler x y) #align orientation.oangle Orientation.oangle /-- Oriented angles are continuous when the vectors involved are nonzero. -/ 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 /-- If the first vector passed to `oangle` is 0, the result is 0. -/ @[simp] theorem oangle_zero_left (x : V) : o.oangle 0 x = 0 := by simp [oangle] #align orientation.oangle_zero_left Orientation.oangle_zero_left /-- If the second vector passed to `oangle` is 0, the result is 0. -/ @[simp] theorem oangle_zero_right (x : V) : o.oangle x 0 = 0 := by simp [oangle] #align orientation.oangle_zero_right Orientation.oangle_zero_right /-- If the two vectors passed to `oangle` are the same, the result is 0. -/ @[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 /-- If the angle between two vectors is nonzero, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is nonzero, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is nonzero, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `π`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `π`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `π`, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `π / 2`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `π / 2`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `π / 2`, the vectors are not equal. -/ 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 /-- If the angle between two vectors is `-π / 2`, the first vector is nonzero. -/ 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 /-- If the angle between two vectors is `-π / 2`, the second vector is nonzero. -/ 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 /-- If the angle between two vectors is `-π / 2`, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is nonzero, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is positive, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is positive, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is positive, the vectors are not equal. -/ 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 /-- If the sign of the angle between two vectors is negative, the first vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is negative, the second vector is nonzero. -/ 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 /-- If the sign of the angle between two vectors is negative, the vectors are not equal. -/ 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 /-- Swapping the two vectors passed to `oangle` negates the angle. -/ 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 /-- Adding the angles between two vectors in each order results in 0. -/ @[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 /-- Negating the first vector passed to `oangle` adds `π` to the angle. -/ 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 /-- Negating the second vector passed to `oangle` adds `π` to the angle. -/ 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 /-- Negating the first vector passed to `oangle` does not change twice the angle. -/ @[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 /-- Negating the second vector passed to `oangle` does not change twice the angle. -/ @[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 /-- Negating both vectors passed to `oangle` does not change the angle. -/ @[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 /-- Negating the first vector produces the same angle as negating the second vector. -/ 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 /-- The angle between the negation of a nonzero vector and that vector is `π`. -/ @[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 /-- The angle between a nonzero vector and its negation is `π`. -/ @[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 /-- Twice the angle between the negation of a vector and that vector is 0. -/ -- @[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 /-- Twice the angle between a vector and its negation is 0. -/ -- @[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 /-- Adding the angles between two vectors in each order, with the first vector in each angle negated, results in 0. -/ @[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 /-- Adding the angles between two vectors in each order, with the second vector in each angle negated, results in 0. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a positive real does not change the angle. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a positive real does not change the angle. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a negative real produces the same angle as negating that vector. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a negative real produces the same angle as negating that vector. -/ @[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 /-- The angle between a nonnegative multiple of a vector and that vector is 0. -/ @[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 /-- The angle between a vector and a nonnegative multiple of that vector is 0. -/ @[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 /-- The angle between two nonnegative multiples of the same vector is 0. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a nonzero real does not change twice the angle. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a nonzero real does not change twice the angle. -/ @[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 /-- Twice the angle between a multiple of a vector and that vector is 0. -/ @[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 /-- Twice the angle between a vector and a multiple of that vector is 0. -/ @[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 /-- Twice the angle between two multiples of a vector is 0. -/ @[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 /-- If the spans of two vectors are equal, twice angles with those vectors on the left are equal. -/ 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 /-- If the spans of two vectors are equal, twice angles with those vectors on the right are equal. -/ 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 /-- If the spans of two pairs of vectors are equal, twice angles between those vectors are equal. -/ 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 /-- The oriented angle between two vectors is zero if and only if the angle with the vectors swapped is zero. -/ 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 /-- The oriented angle between two vectors is zero if and only if they are on the same ray. -/ 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 /-- The oriented angle between two vectors is `π` if and only if the angle with the vectors swapped is `π`. -/ 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 /-- The oriented angle between two vectors is `π` if and only they are nonzero and the first is on the same ray as the negation of the second. -/ 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 /-- The oriented angle between two vectors is zero or `π` if and only if those two vectors are not linearly independent. -/ 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 /-- The oriented angle between two vectors is zero or `π` if and only if the first vector is zero or the second is a multiple of the first. -/ 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 /-- The oriented angle between two vectors is not zero or `π` if and only if those two vectors are linearly independent. -/ 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 /-- Two vectors are equal if and only if they have equal norms and zero angle between them. -/ 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 /-- Two vectors with equal norms are equal if and only if they have zero angle between them. -/ 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 /-- Two vectors with zero angle between them are equal if and only if they have equal norms. -/ 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 /-- Given three nonzero vectors, the angle between the first and the second plus the angle between the second and the third equals the angle between the first and the third. -/ @[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 /-- Given three nonzero vectors, the angle between the second and the third plus the angle between the first and the second equals the angle between the first and the third. -/ @[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 /-- Given three nonzero vectors, the angle between the first and the third minus the angle between the first and the second equals the angle between the second and the third. -/ @[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 /-- Given three nonzero vectors, the angle between the first and the third minus the angle between the second and the third equals the angle between the first and the second. -/ @[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 /-- Given three nonzero vectors, adding the angles between them in cyclic order results in 0. -/ @[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 /-- Given three nonzero vectors, adding the angles between them in cyclic order, with the first vector in each angle negated, results in π. If the vectors add to 0, this is a version of the sum of the angles of a triangle. -/ @[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 /-- Given three nonzero vectors, adding the angles between them in cyclic order, with the second vector in each angle negated, results in π. If the vectors add to 0, this is a version of the sum of the angles of a triangle. -/ @[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 /-- Pons asinorum, oriented vector angle form. -/ 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 /-- The angle at the apex of an isosceles triangle is `π` minus twice a base angle, oriented vector angle form. -/ 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 /-- The angle between two vectors, with respect to an orientation given by `Orientation.map` with a linear isometric equivalence, equals the angle between those two vectors, transformed by the inverse of that equivalence, with respect to the original orientation. -/ @[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 /-- The oriented angle on an oriented real inner product space of dimension 2 can be evaluated in terms of a complex-number representation of the space. -/ 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 /-- Negating the orientation negates the value of `oangle`. -/ 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 /-- The inner product of two vectors is the product of the norms and the cosine of the oriented angle between the vectors. -/ 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 /-- The cosine of the oriented angle between two nonzero vectors is the inner product divided by the product of the norms. -/ 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 /-- The cosine of the oriented angle between two nonzero vectors equals that of the unoriented angle. -/ 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 /-- The oriented angle between two nonzero vectors is plus or minus the unoriented 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 /-- The unoriented angle between two nonzero vectors is the absolute value of the oriented angle, converted to a real. -/ 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 /-- If the sign of the oriented angle between two vectors is zero, either one of the vectors is zero or the unoriented angle is 0 or π. -/ 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 /-- If two unoriented angles are equal, and the signs of the corresponding oriented angles are equal, then the oriented angles are equal (even in degenerate cases). -/ 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 /-- If the signs of two oriented angles between nonzero vectors are equal, the oriented angles are equal if and only if the unoriented angles are equal. -/ 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 /-- The oriented angle between two vectors equals the unoriented angle if the sign is positive. -/ 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 /-- The oriented angle between two vectors equals minus the unoriented angle if the sign is negative. -/ 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 /-- The oriented angle between two nonzero vectors is zero if and only if the unoriented angle is zero. -/ 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 /-- The oriented angle between two vectors is `π` if and only if the unoriented angle is `π`. -/ 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 /-- One of two vectors is zero or the oriented angle between them is plus or minus `π / 2` if and only if the inner product of those vectors is zero. -/ 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 /-- If the oriented angle between two vectors is `π / 2`, the inner product of those vectors is 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 /-- If the oriented angle between two vectors is `π / 2`, the inner product of those vectors (reversed) is zero. -/ 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 /-- If the oriented angle between two vectors is `-π / 2`, the inner product of those vectors is zero. -/ 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 /-- If the oriented angle between two vectors is `-π / 2`, the inner product of those vectors (reversed) is zero. -/ 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 /-- Negating the first vector passed to `oangle` negates the sign of the angle. -/ @[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 /-- Negating the second vector passed to `oangle` negates the sign of the angle. -/ @[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 /-- Multiplying the first vector passed to `oangle` by a real multiplies the sign of the angle by the sign of the real. -/ @[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 /-- Multiplying the second vector passed to `oangle` by a real multiplies the sign of the angle by the sign of the real. -/ @[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 /-- Auxiliary lemma for the proof of `oangle_sign_smul_add_right`; not intended to be used outside of that proof. -/ 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 /-- Adding a multiple of the first vector passed to `oangle` to the second vector does not change the sign of the angle. -/ @[simp]
Mathlib/Geometry/Euclidean/Angle/Oriented/Basic.lean
897
926
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
/- Copyright (c) 2020 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.FieldTheory.Tower import Mathlib.RingTheory.Algebraic import Mathlib.FieldTheory.Minpoly.Basic #align_import field_theory.intermediate_field from "leanprover-community/mathlib"@"c596622fccd6e0321979d94931c964054dea2d26" /-! # Intermediate fields Let `L / K` be a field extension, given as an instance `Algebra K L`. This file defines the type of fields in between `K` and `L`, `IntermediateField K L`. An `IntermediateField K L` is a subfield of `L` which contains (the image of) `K`, i.e. it is a `Subfield L` and a `Subalgebra K L`. ## Main definitions * `IntermediateField K L` : the type of intermediate fields between `K` and `L`. * `Subalgebra.to_intermediateField`: turns a subalgebra closed under `⁻¹` into an intermediate field * `Subfield.to_intermediateField`: turns a subfield containing the image of `K` into an intermediate field * `IntermediateField.map`: map an intermediate field along an `AlgHom` * `IntermediateField.restrict_scalars`: restrict the scalars of an intermediate field to a smaller field in a tower of fields. ## Implementation notes Intermediate fields are defined with a structure extending `Subfield` and `Subalgebra`. A `Subalgebra` is closed under all operations except `⁻¹`, ## Tags intermediate field, field extension -/ open FiniteDimensional Polynomial open Polynomial variable (K L L' : Type*) [Field K] [Field L] [Field L'] [Algebra K L] [Algebra K L'] /-- `S : IntermediateField K L` is a subset of `L` such that there is a field tower `L / S / K`. -/ structure IntermediateField extends Subalgebra K L where inv_mem' : ∀ x ∈ carrier, x⁻¹ ∈ carrier #align intermediate_field IntermediateField /-- Reinterpret an `IntermediateField` as a `Subalgebra`. -/ add_decl_doc IntermediateField.toSubalgebra variable {K L L'} variable (S : IntermediateField K L) namespace IntermediateField instance : SetLike (IntermediateField K L) L := ⟨fun S => S.toSubalgebra.carrier, by rintro ⟨⟨⟩⟩ ⟨⟨⟩⟩ simp ⟩ protected theorem neg_mem {x : L} (hx : x ∈ S) : -x ∈ S := by show -x ∈S.toSubalgebra; simpa #align intermediate_field.neg_mem IntermediateField.neg_mem /-- Reinterpret an `IntermediateField` as a `Subfield`. -/ def toSubfield : Subfield L := { S.toSubalgebra with neg_mem' := S.neg_mem, inv_mem' := S.inv_mem' } #align intermediate_field.to_subfield IntermediateField.toSubfield instance : SubfieldClass (IntermediateField K L) L where add_mem {s} := s.add_mem' zero_mem {s} := s.zero_mem' neg_mem {s} := s.neg_mem mul_mem {s} := s.mul_mem' one_mem {s} := s.one_mem' inv_mem {s} := s.inv_mem' _ --@[simp] Porting note (#10618): simp can prove it theorem mem_carrier {s : IntermediateField K L} {x : L} : x ∈ s.carrier ↔ x ∈ s := Iff.rfl #align intermediate_field.mem_carrier IntermediateField.mem_carrier /-- Two intermediate fields are equal if they have the same elements. -/ @[ext] theorem ext {S T : IntermediateField K L} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T := SetLike.ext h #align intermediate_field.ext IntermediateField.ext @[simp] theorem coe_toSubalgebra : (S.toSubalgebra : Set L) = S := rfl #align intermediate_field.coe_to_subalgebra IntermediateField.coe_toSubalgebra @[simp] theorem coe_toSubfield : (S.toSubfield : Set L) = S := rfl #align intermediate_field.coe_to_subfield IntermediateField.coe_toSubfield @[simp] theorem mem_mk (s : Subsemiring L) (hK : ∀ x, algebraMap K L x ∈ s) (hi) (x : L) : x ∈ IntermediateField.mk (Subalgebra.mk s hK) hi ↔ x ∈ s := Iff.rfl #align intermediate_field.mem_mk IntermediateField.mem_mkₓ @[simp] theorem mem_toSubalgebra (s : IntermediateField K L) (x : L) : x ∈ s.toSubalgebra ↔ x ∈ s := Iff.rfl #align intermediate_field.mem_to_subalgebra IntermediateField.mem_toSubalgebra @[simp] theorem mem_toSubfield (s : IntermediateField K L) (x : L) : x ∈ s.toSubfield ↔ x ∈ s := Iff.rfl #align intermediate_field.mem_to_subfield IntermediateField.mem_toSubfield /-- Copy of an intermediate field with a new `carrier` equal to the old one. Useful to fix definitional equalities. -/ protected def copy (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) : IntermediateField K L where toSubalgebra := S.toSubalgebra.copy s (hs : s = S.toSubalgebra.carrier) inv_mem' := have hs' : (S.toSubalgebra.copy s hs).carrier = S.toSubalgebra.carrier := hs hs'.symm ▸ S.inv_mem' #align intermediate_field.copy IntermediateField.copy @[simp] theorem coe_copy (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) : (S.copy s hs : Set L) = s := rfl #align intermediate_field.coe_copy IntermediateField.coe_copy theorem copy_eq (S : IntermediateField K L) (s : Set L) (hs : s = ↑S) : S.copy s hs = S := SetLike.coe_injective hs #align intermediate_field.copy_eq IntermediateField.copy_eq section InheritedLemmas /-! ### Lemmas inherited from more general structures The declarations in this section derive from the fact that an `IntermediateField` is also a subalgebra or subfield. Their use should be replaceable with the corresponding lemma from a subobject class. -/ /-- An intermediate field contains the image of the smaller field. -/ theorem algebraMap_mem (x : K) : algebraMap K L x ∈ S := S.algebraMap_mem' x #align intermediate_field.algebra_map_mem IntermediateField.algebraMap_mem /-- An intermediate field is closed under scalar multiplication. -/ theorem smul_mem {y : L} : y ∈ S → ∀ {x : K}, x • y ∈ S := S.toSubalgebra.smul_mem #align intermediate_field.smul_mem IntermediateField.smul_mem /-- An intermediate field contains the ring's 1. -/ protected theorem one_mem : (1 : L) ∈ S := one_mem S #align intermediate_field.one_mem IntermediateField.one_mem /-- An intermediate field contains the ring's 0. -/ protected theorem zero_mem : (0 : L) ∈ S := zero_mem S #align intermediate_field.zero_mem IntermediateField.zero_mem /-- An intermediate field is closed under multiplication. -/ protected theorem mul_mem {x y : L} : x ∈ S → y ∈ S → x * y ∈ S := mul_mem #align intermediate_field.mul_mem IntermediateField.mul_mem /-- An intermediate field is closed under addition. -/ protected theorem add_mem {x y : L} : x ∈ S → y ∈ S → x + y ∈ S := add_mem #align intermediate_field.add_mem IntermediateField.add_mem /-- An intermediate field is closed under subtraction -/ protected theorem sub_mem {x y : L} : x ∈ S → y ∈ S → x - y ∈ S := sub_mem #align intermediate_field.sub_mem IntermediateField.sub_mem /-- An intermediate field is closed under inverses. -/ protected theorem inv_mem {x : L} : x ∈ S → x⁻¹ ∈ S := inv_mem #align intermediate_field.inv_mem IntermediateField.inv_mem /-- An intermediate field is closed under division. -/ protected theorem div_mem {x y : L} : x ∈ S → y ∈ S → x / y ∈ S := div_mem #align intermediate_field.div_mem IntermediateField.div_mem /-- Product of a list of elements in an intermediate_field is in the intermediate_field. -/ protected theorem list_prod_mem {l : List L} : (∀ x ∈ l, x ∈ S) → l.prod ∈ S := list_prod_mem #align intermediate_field.list_prod_mem IntermediateField.list_prod_mem /-- Sum of a list of elements in an intermediate field is in the intermediate_field. -/ protected theorem list_sum_mem {l : List L} : (∀ x ∈ l, x ∈ S) → l.sum ∈ S := list_sum_mem #align intermediate_field.list_sum_mem IntermediateField.list_sum_mem /-- Product of a multiset of elements in an intermediate field is in the intermediate_field. -/ protected theorem multiset_prod_mem (m : Multiset L) : (∀ a ∈ m, a ∈ S) → m.prod ∈ S := multiset_prod_mem m #align intermediate_field.multiset_prod_mem IntermediateField.multiset_prod_mem /-- Sum of a multiset of elements in an `IntermediateField` is in the `IntermediateField`. -/ protected theorem multiset_sum_mem (m : Multiset L) : (∀ a ∈ m, a ∈ S) → m.sum ∈ S := multiset_sum_mem m #align intermediate_field.multiset_sum_mem IntermediateField.multiset_sum_mem /-- Product of elements of an intermediate field indexed by a `Finset` is in the intermediate_field. -/ protected theorem prod_mem {ι : Type*} {t : Finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) : (∏ i ∈ t, f i) ∈ S := prod_mem h #align intermediate_field.prod_mem IntermediateField.prod_mem /-- Sum of elements in an `IntermediateField` indexed by a `Finset` is in the `IntermediateField`. -/ protected theorem sum_mem {ι : Type*} {t : Finset ι} {f : ι → L} (h : ∀ c ∈ t, f c ∈ S) : (∑ i ∈ t, f i) ∈ S := sum_mem h #align intermediate_field.sum_mem IntermediateField.sum_mem protected theorem pow_mem {x : L} (hx : x ∈ S) (n : ℤ) : x ^ n ∈ S := zpow_mem hx n #align intermediate_field.pow_mem IntermediateField.pow_mem protected theorem zsmul_mem {x : L} (hx : x ∈ S) (n : ℤ) : n • x ∈ S := zsmul_mem hx n #align intermediate_field.zsmul_mem IntermediateField.zsmul_mem protected theorem intCast_mem (n : ℤ) : (n : L) ∈ S := intCast_mem S n #align intermediate_field.coe_int_mem IntermediateField.intCast_mem protected theorem coe_add (x y : S) : (↑(x + y) : L) = ↑x + ↑y := rfl #align intermediate_field.coe_add IntermediateField.coe_add protected theorem coe_neg (x : S) : (↑(-x) : L) = -↑x := rfl #align intermediate_field.coe_neg IntermediateField.coe_neg protected theorem coe_mul (x y : S) : (↑(x * y) : L) = ↑x * ↑y := rfl #align intermediate_field.coe_mul IntermediateField.coe_mul protected theorem coe_inv (x : S) : (↑x⁻¹ : L) = (↑x)⁻¹ := rfl #align intermediate_field.coe_inv IntermediateField.coe_inv protected theorem coe_zero : ((0 : S) : L) = 0 := rfl #align intermediate_field.coe_zero IntermediateField.coe_zero protected theorem coe_one : ((1 : S) : L) = 1 := rfl #align intermediate_field.coe_one IntermediateField.coe_one protected theorem coe_pow (x : S) (n : ℕ) : (↑(x ^ n : S) : L) = (x : L) ^ n := SubmonoidClass.coe_pow x n #align intermediate_field.coe_pow IntermediateField.coe_pow end InheritedLemmas theorem natCast_mem (n : ℕ) : (n : L) ∈ S := by simpa using intCast_mem S n #align intermediate_field.coe_nat_mem IntermediateField.natCast_mem -- 2024-04-05 @[deprecated _root_.natCast_mem] alias coe_nat_mem := natCast_mem @[deprecated _root_.intCast_mem] alias coe_int_mem := intCast_mem end IntermediateField /-- Turn a subalgebra closed under inverses into an intermediate field -/ def Subalgebra.toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) : IntermediateField K L := { S with inv_mem' := inv_mem } #align subalgebra.to_intermediate_field Subalgebra.toIntermediateField @[simp] theorem toSubalgebra_toIntermediateField (S : Subalgebra K L) (inv_mem : ∀ x ∈ S, x⁻¹ ∈ S) : (S.toIntermediateField inv_mem).toSubalgebra = S := by ext rfl #align to_subalgebra_to_intermediate_field toSubalgebra_toIntermediateField @[simp] theorem toIntermediateField_toSubalgebra (S : IntermediateField K L) : (S.toSubalgebra.toIntermediateField fun x => S.inv_mem) = S := by ext rfl #align to_intermediate_field_to_subalgebra toIntermediateField_toSubalgebra /-- Turn a subalgebra satisfying `IsField` into an intermediate_field -/ def Subalgebra.toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : IntermediateField K L := S.toIntermediateField fun x hx => by by_cases hx0 : x = 0 · rw [hx0, inv_zero] exact S.zero_mem letI hS' := hS.toField obtain ⟨y, hy⟩ := hS.mul_inv_cancel (show (⟨x, hx⟩ : S) ≠ 0 from Subtype.coe_ne_coe.1 hx0) rw [Subtype.ext_iff, S.coe_mul, S.coe_one, Subtype.coe_mk, mul_eq_one_iff_inv_eq₀ hx0] at hy exact hy.symm ▸ y.2 #align subalgebra.to_intermediate_field' Subalgebra.toIntermediateField' @[simp] theorem toSubalgebra_toIntermediateField' (S : Subalgebra K L) (hS : IsField S) : (S.toIntermediateField' hS).toSubalgebra = S := by ext rfl #align to_subalgebra_to_intermediate_field' toSubalgebra_toIntermediateField' @[simp] theorem toIntermediateField'_toSubalgebra (S : IntermediateField K L) : S.toSubalgebra.toIntermediateField' (Field.toIsField S) = S := by ext rfl #align to_intermediate_field'_to_subalgebra toIntermediateField'_toSubalgebra /-- Turn a subfield of `L` containing the image of `K` into an intermediate field -/ def Subfield.toIntermediateField (S : Subfield L) (algebra_map_mem : ∀ x, algebraMap K L x ∈ S) : IntermediateField K L := { S with algebraMap_mem' := algebra_map_mem } #align subfield.to_intermediate_field Subfield.toIntermediateField namespace IntermediateField /-- An intermediate field inherits a field structure -/ instance toField : Field S := S.toSubfield.toField #align intermediate_field.to_field IntermediateField.toField @[simp, norm_cast]
Mathlib/FieldTheory/IntermediateField.lean
344
348
theorem coe_sum {ι : Type*} [Fintype ι] (f : ι → S) : (↑(∑ i, f i) : L) = ∑ i, (f i : L) := by
classical induction' (Finset.univ : Finset ι) using Finset.induction_on with i s hi H · simp · rw [Finset.sum_insert hi, AddMemClass.coe_add, H, Finset.sum_insert hi]
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Measure.Typeclasses import Mathlib.Analysis.Complex.Basic #align_import measure_theory.measure.vector_measure from "leanprover-community/mathlib"@"70a4f2197832bceab57d7f41379b2592d1110570" /-! # Vector valued measures This file defines vector valued measures, which are σ-additive functions from a set to an add monoid `M` such that it maps the empty set and non-measurable sets to zero. In the case that `M = ℝ`, we called the vector measure a signed measure and write `SignedMeasure α`. Similarly, when `M = ℂ`, we call the measure a complex measure and write `ComplexMeasure α`. ## Main definitions * `MeasureTheory.VectorMeasure` is a vector valued, σ-additive function that maps the empty and non-measurable set to zero. * `MeasureTheory.VectorMeasure.map` is the pushforward of a vector measure along a function. * `MeasureTheory.VectorMeasure.restrict` is the restriction of a vector measure on some set. ## Notation * `v ≤[i] w` means that the vector measure `v` restricted on the set `i` is less than or equal to the vector measure `w` restricted on `i`, i.e. `v.restrict i ≤ w.restrict i`. ## Implementation notes We require all non-measurable sets to be mapped to zero in order for the extensionality lemma to only compare the underlying functions for measurable sets. We use `HasSum` instead of `tsum` in the definition of vector measures in comparison to `Measure` since this provides summability. ## Tags vector measure, signed measure, complex measure -/ noncomputable section open scoped Classical open NNReal ENNReal MeasureTheory namespace MeasureTheory variable {α β : Type*} {m : MeasurableSpace α} /-- A vector measure on a measurable space `α` is a σ-additive `M`-valued function (for some `M` an add monoid) such that the empty set and non-measurable sets are mapped to zero. -/ structure VectorMeasure (α : Type*) [MeasurableSpace α] (M : Type*) [AddCommMonoid M] [TopologicalSpace M] where measureOf' : Set α → M empty' : measureOf' ∅ = 0 not_measurable' ⦃i : Set α⦄ : ¬MeasurableSet i → measureOf' i = 0 m_iUnion' ⦃f : ℕ → Set α⦄ : (∀ i, MeasurableSet (f i)) → Pairwise (Disjoint on f) → HasSum (fun i => measureOf' (f i)) (measureOf' (⋃ i, f i)) #align measure_theory.vector_measure MeasureTheory.VectorMeasure #align measure_theory.vector_measure.measure_of' MeasureTheory.VectorMeasure.measureOf' #align measure_theory.vector_measure.empty' MeasureTheory.VectorMeasure.empty' #align measure_theory.vector_measure.not_measurable' MeasureTheory.VectorMeasure.not_measurable' #align measure_theory.vector_measure.m_Union' MeasureTheory.VectorMeasure.m_iUnion' /-- A `SignedMeasure` is an `ℝ`-vector measure. -/ abbrev SignedMeasure (α : Type*) [MeasurableSpace α] := VectorMeasure α ℝ #align measure_theory.signed_measure MeasureTheory.SignedMeasure /-- A `ComplexMeasure` is a `ℂ`-vector measure. -/ abbrev ComplexMeasure (α : Type*) [MeasurableSpace α] := VectorMeasure α ℂ #align measure_theory.complex_measure MeasureTheory.ComplexMeasure open Set MeasureTheory namespace VectorMeasure section variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] attribute [coe] VectorMeasure.measureOf' instance instCoeFun : CoeFun (VectorMeasure α M) fun _ => Set α → M := ⟨VectorMeasure.measureOf'⟩ #align measure_theory.vector_measure.has_coe_to_fun MeasureTheory.VectorMeasure.instCoeFun initialize_simps_projections VectorMeasure (measureOf' → apply) #noalign measure_theory.vector_measure.measure_of_eq_coe @[simp] theorem empty (v : VectorMeasure α M) : v ∅ = 0 := v.empty' #align measure_theory.vector_measure.empty MeasureTheory.VectorMeasure.empty theorem not_measurable (v : VectorMeasure α M) {i : Set α} (hi : ¬MeasurableSet i) : v i = 0 := v.not_measurable' hi #align measure_theory.vector_measure.not_measurable MeasureTheory.VectorMeasure.not_measurable theorem m_iUnion (v : VectorMeasure α M) {f : ℕ → Set α} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) : HasSum (fun i => v (f i)) (v (⋃ i, f i)) := v.m_iUnion' hf₁ hf₂ #align measure_theory.vector_measure.m_Union MeasureTheory.VectorMeasure.m_iUnion theorem of_disjoint_iUnion_nat [T2Space M] (v : VectorMeasure α M) {f : ℕ → Set α} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) : v (⋃ i, f i) = ∑' i, v (f i) := (v.m_iUnion hf₁ hf₂).tsum_eq.symm #align measure_theory.vector_measure.of_disjoint_Union_nat MeasureTheory.VectorMeasure.of_disjoint_iUnion_nat theorem coe_injective : @Function.Injective (VectorMeasure α M) (Set α → M) (⇑) := fun v w h => by cases v cases w congr #align measure_theory.vector_measure.coe_injective MeasureTheory.VectorMeasure.coe_injective theorem ext_iff' (v w : VectorMeasure α M) : v = w ↔ ∀ i : Set α, v i = w i := by rw [← coe_injective.eq_iff, Function.funext_iff] #align measure_theory.vector_measure.ext_iff' MeasureTheory.VectorMeasure.ext_iff' theorem ext_iff (v w : VectorMeasure α M) : v = w ↔ ∀ i : Set α, MeasurableSet i → v i = w i := by constructor · rintro rfl _ _ rfl · rw [ext_iff'] intro h i by_cases hi : MeasurableSet i · exact h i hi · simp_rw [not_measurable _ hi] #align measure_theory.vector_measure.ext_iff MeasureTheory.VectorMeasure.ext_iff @[ext] theorem ext {s t : VectorMeasure α M} (h : ∀ i : Set α, MeasurableSet i → s i = t i) : s = t := (ext_iff s t).2 h #align measure_theory.vector_measure.ext MeasureTheory.VectorMeasure.ext variable [T2Space M] {v : VectorMeasure α M} {f : ℕ → Set α} theorem hasSum_of_disjoint_iUnion [Countable β] {f : β → Set α} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) : HasSum (fun i => v (f i)) (v (⋃ i, f i)) := by cases nonempty_encodable β set g := fun i : ℕ => ⋃ (b : β) (_ : b ∈ Encodable.decode₂ β i), f b with hg have hg₁ : ∀ i, MeasurableSet (g i) := fun _ => MeasurableSet.iUnion fun b => MeasurableSet.iUnion fun _ => hf₁ b have hg₂ : Pairwise (Disjoint on g) := Encodable.iUnion_decode₂_disjoint_on hf₂ have := v.of_disjoint_iUnion_nat hg₁ hg₂ rw [hg, Encodable.iUnion_decode₂] at this have hg₃ : (fun i : β => v (f i)) = fun i => v (g (Encodable.encode i)) := by ext x rw [hg] simp only congr ext y simp only [exists_prop, Set.mem_iUnion, Option.mem_def] constructor · intro hy exact ⟨x, (Encodable.decode₂_is_partial_inv _ _).2 rfl, hy⟩ · rintro ⟨b, hb₁, hb₂⟩ rw [Encodable.decode₂_is_partial_inv _ _] at hb₁ rwa [← Encodable.encode_injective hb₁] rw [Summable.hasSum_iff, this, ← tsum_iUnion_decode₂] · exact v.empty · rw [hg₃] change Summable ((fun i => v (g i)) ∘ Encodable.encode) rw [Function.Injective.summable_iff Encodable.encode_injective] · exact (v.m_iUnion hg₁ hg₂).summable · intro x hx convert v.empty simp only [g, Set.iUnion_eq_empty, Option.mem_def, not_exists, Set.mem_range] at hx ⊢ intro i hi exact False.elim ((hx i) ((Encodable.decode₂_is_partial_inv _ _).1 hi)) #align measure_theory.vector_measure.has_sum_of_disjoint_Union MeasureTheory.VectorMeasure.hasSum_of_disjoint_iUnion theorem of_disjoint_iUnion [Countable β] {f : β → Set α} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) : v (⋃ i, f i) = ∑' i, v (f i) := (hasSum_of_disjoint_iUnion hf₁ hf₂).tsum_eq.symm #align measure_theory.vector_measure.of_disjoint_Union MeasureTheory.VectorMeasure.of_disjoint_iUnion theorem of_union {A B : Set α} (h : Disjoint A B) (hA : MeasurableSet A) (hB : MeasurableSet B) : v (A ∪ B) = v A + v B := by rw [Set.union_eq_iUnion, of_disjoint_iUnion, tsum_fintype, Fintype.sum_bool, cond, cond] exacts [fun b => Bool.casesOn b hB hA, pairwise_disjoint_on_bool.2 h] #align measure_theory.vector_measure.of_union MeasureTheory.VectorMeasure.of_union theorem of_add_of_diff {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B) (h : A ⊆ B) : v A + v (B \ A) = v B := by rw [← of_union (@Set.disjoint_sdiff_right _ A B) hA (hB.diff hA), Set.union_diff_cancel h] #align measure_theory.vector_measure.of_add_of_diff MeasureTheory.VectorMeasure.of_add_of_diff theorem of_diff {M : Type*} [AddCommGroup M] [TopologicalSpace M] [T2Space M] {v : VectorMeasure α M} {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B) (h : A ⊆ B) : v (B \ A) = v B - v A := by rw [← of_add_of_diff hA hB h, add_sub_cancel_left] #align measure_theory.vector_measure.of_diff MeasureTheory.VectorMeasure.of_diff theorem of_diff_of_diff_eq_zero {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B) (h' : v (B \ A) = 0) : v (A \ B) + v B = v A := by symm calc v A = v (A \ B ∪ A ∩ B) := by simp only [Set.diff_union_inter] _ = v (A \ B) + v (A ∩ B) := by rw [of_union] · rw [disjoint_comm] exact Set.disjoint_of_subset_left A.inter_subset_right disjoint_sdiff_self_right · exact hA.diff hB · exact hA.inter hB _ = v (A \ B) + v (A ∩ B ∪ B \ A) := by rw [of_union, h', add_zero] · exact Set.disjoint_of_subset_left A.inter_subset_left disjoint_sdiff_self_right · exact hA.inter hB · exact hB.diff hA _ = v (A \ B) + v B := by rw [Set.union_comm, Set.inter_comm, Set.diff_union_inter] #align measure_theory.vector_measure.of_diff_of_diff_eq_zero MeasureTheory.VectorMeasure.of_diff_of_diff_eq_zero theorem of_iUnion_nonneg {M : Type*} [TopologicalSpace M] [OrderedAddCommMonoid M] [OrderClosedTopology M] {v : VectorMeasure α M} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) (hf₃ : ∀ i, 0 ≤ v (f i)) : 0 ≤ v (⋃ i, f i) := (v.of_disjoint_iUnion_nat hf₁ hf₂).symm ▸ tsum_nonneg hf₃ #align measure_theory.vector_measure.of_Union_nonneg MeasureTheory.VectorMeasure.of_iUnion_nonneg theorem of_iUnion_nonpos {M : Type*} [TopologicalSpace M] [OrderedAddCommMonoid M] [OrderClosedTopology M] {v : VectorMeasure α M} (hf₁ : ∀ i, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) (hf₃ : ∀ i, v (f i) ≤ 0) : v (⋃ i, f i) ≤ 0 := (v.of_disjoint_iUnion_nat hf₁ hf₂).symm ▸ tsum_nonpos hf₃ #align measure_theory.vector_measure.of_Union_nonpos MeasureTheory.VectorMeasure.of_iUnion_nonpos theorem of_nonneg_disjoint_union_eq_zero {s : SignedMeasure α} {A B : Set α} (h : Disjoint A B) (hA₁ : MeasurableSet A) (hB₁ : MeasurableSet B) (hA₂ : 0 ≤ s A) (hB₂ : 0 ≤ s B) (hAB : s (A ∪ B) = 0) : s A = 0 := by rw [of_union h hA₁ hB₁] at hAB linarith #align measure_theory.vector_measure.of_nonneg_disjoint_union_eq_zero MeasureTheory.VectorMeasure.of_nonneg_disjoint_union_eq_zero theorem of_nonpos_disjoint_union_eq_zero {s : SignedMeasure α} {A B : Set α} (h : Disjoint A B) (hA₁ : MeasurableSet A) (hB₁ : MeasurableSet B) (hA₂ : s A ≤ 0) (hB₂ : s B ≤ 0) (hAB : s (A ∪ B) = 0) : s A = 0 := by rw [of_union h hA₁ hB₁] at hAB linarith #align measure_theory.vector_measure.of_nonpos_disjoint_union_eq_zero MeasureTheory.VectorMeasure.of_nonpos_disjoint_union_eq_zero end section SMul variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M] /-- Given a real number `r` and a signed measure `s`, `smul r s` is the signed measure corresponding to the function `r • s`. -/ def smul (r : R) (v : VectorMeasure α M) : VectorMeasure α M where measureOf' := r • ⇑v empty' := by rw [Pi.smul_apply, empty, smul_zero] not_measurable' _ hi := by rw [Pi.smul_apply, v.not_measurable hi, smul_zero] m_iUnion' _ hf₁ hf₂ := by exact HasSum.const_smul _ (v.m_iUnion hf₁ hf₂) #align measure_theory.vector_measure.smul MeasureTheory.VectorMeasure.smul instance instSMul : SMul R (VectorMeasure α M) := ⟨smul⟩ #align measure_theory.vector_measure.has_smul MeasureTheory.VectorMeasure.instSMul @[simp] theorem coe_smul (r : R) (v : VectorMeasure α M) : ⇑(r • v) = r • ⇑v := rfl #align measure_theory.vector_measure.coe_smul MeasureTheory.VectorMeasure.coe_smul theorem smul_apply (r : R) (v : VectorMeasure α M) (i : Set α) : (r • v) i = r • v i := rfl #align measure_theory.vector_measure.smul_apply MeasureTheory.VectorMeasure.smul_apply end SMul section AddCommMonoid variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] instance instZero : Zero (VectorMeasure α M) := ⟨⟨0, rfl, fun _ _ => rfl, fun _ _ _ => hasSum_zero⟩⟩ #align measure_theory.vector_measure.has_zero MeasureTheory.VectorMeasure.instZero instance instInhabited : Inhabited (VectorMeasure α M) := ⟨0⟩ #align measure_theory.vector_measure.inhabited MeasureTheory.VectorMeasure.instInhabited @[simp] theorem coe_zero : ⇑(0 : VectorMeasure α M) = 0 := rfl #align measure_theory.vector_measure.coe_zero MeasureTheory.VectorMeasure.coe_zero theorem zero_apply (i : Set α) : (0 : VectorMeasure α M) i = 0 := rfl #align measure_theory.vector_measure.zero_apply MeasureTheory.VectorMeasure.zero_apply variable [ContinuousAdd M] /-- The sum of two vector measure is a vector measure. -/ def add (v w : VectorMeasure α M) : VectorMeasure α M where measureOf' := v + w empty' := by simp not_measurable' _ hi := by rw [Pi.add_apply, v.not_measurable hi, w.not_measurable hi, add_zero] m_iUnion' f hf₁ hf₂ := HasSum.add (v.m_iUnion hf₁ hf₂) (w.m_iUnion hf₁ hf₂) #align measure_theory.vector_measure.add MeasureTheory.VectorMeasure.add instance instAdd : Add (VectorMeasure α M) := ⟨add⟩ #align measure_theory.vector_measure.has_add MeasureTheory.VectorMeasure.instAdd @[simp] theorem coe_add (v w : VectorMeasure α M) : ⇑(v + w) = v + w := rfl #align measure_theory.vector_measure.coe_add MeasureTheory.VectorMeasure.coe_add theorem add_apply (v w : VectorMeasure α M) (i : Set α) : (v + w) i = v i + w i := rfl #align measure_theory.vector_measure.add_apply MeasureTheory.VectorMeasure.add_apply instance instAddCommMonoid : AddCommMonoid (VectorMeasure α M) := Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _ #align measure_theory.vector_measure.add_comm_monoid MeasureTheory.VectorMeasure.instAddCommMonoid /-- `(⇑)` is an `AddMonoidHom`. -/ @[simps] def coeFnAddMonoidHom : VectorMeasure α M →+ Set α → M where toFun := (⇑) map_zero' := coe_zero map_add' := coe_add #align measure_theory.vector_measure.coe_fn_add_monoid_hom MeasureTheory.VectorMeasure.coeFnAddMonoidHom end AddCommMonoid section AddCommGroup variable {M : Type*} [AddCommGroup M] [TopologicalSpace M] [TopologicalAddGroup M] /-- The negative of a vector measure is a vector measure. -/ def neg (v : VectorMeasure α M) : VectorMeasure α M where measureOf' := -v empty' := by simp not_measurable' _ hi := by rw [Pi.neg_apply, neg_eq_zero, v.not_measurable hi] m_iUnion' f hf₁ hf₂ := HasSum.neg <| v.m_iUnion hf₁ hf₂ #align measure_theory.vector_measure.neg MeasureTheory.VectorMeasure.neg instance instNeg : Neg (VectorMeasure α M) := ⟨neg⟩ #align measure_theory.vector_measure.has_neg MeasureTheory.VectorMeasure.instNeg @[simp] theorem coe_neg (v : VectorMeasure α M) : ⇑(-v) = -v := rfl #align measure_theory.vector_measure.coe_neg MeasureTheory.VectorMeasure.coe_neg theorem neg_apply (v : VectorMeasure α M) (i : Set α) : (-v) i = -v i := rfl #align measure_theory.vector_measure.neg_apply MeasureTheory.VectorMeasure.neg_apply /-- The difference of two vector measure is a vector measure. -/ def sub (v w : VectorMeasure α M) : VectorMeasure α M where measureOf' := v - w empty' := by simp not_measurable' _ hi := by rw [Pi.sub_apply, v.not_measurable hi, w.not_measurable hi, sub_zero] m_iUnion' f hf₁ hf₂ := HasSum.sub (v.m_iUnion hf₁ hf₂) (w.m_iUnion hf₁ hf₂) #align measure_theory.vector_measure.sub MeasureTheory.VectorMeasure.sub instance instSub : Sub (VectorMeasure α M) := ⟨sub⟩ #align measure_theory.vector_measure.has_sub MeasureTheory.VectorMeasure.instSub @[simp] theorem coe_sub (v w : VectorMeasure α M) : ⇑(v - w) = v - w := rfl #align measure_theory.vector_measure.coe_sub MeasureTheory.VectorMeasure.coe_sub theorem sub_apply (v w : VectorMeasure α M) (i : Set α) : (v - w) i = v i - w i := rfl #align measure_theory.vector_measure.sub_apply MeasureTheory.VectorMeasure.sub_apply instance instAddCommGroup : AddCommGroup (VectorMeasure α M) := Function.Injective.addCommGroup _ coe_injective coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _ #align measure_theory.vector_measure.add_comm_group MeasureTheory.VectorMeasure.instAddCommGroup end AddCommGroup section DistribMulAction variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M] instance instDistribMulAction [ContinuousAdd M] : DistribMulAction R (VectorMeasure α M) := Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul #align measure_theory.vector_measure.distrib_mul_action MeasureTheory.VectorMeasure.instDistribMulAction end DistribMulAction section Module variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable {R : Type*} [Semiring R] [Module R M] [ContinuousConstSMul R M] instance instModule [ContinuousAdd M] : Module R (VectorMeasure α M) := Function.Injective.module R coeFnAddMonoidHom coe_injective coe_smul #align measure_theory.vector_measure.module MeasureTheory.VectorMeasure.instModule end Module end VectorMeasure namespace Measure /-- A finite measure coerced into a real function is a signed measure. -/ @[simps] def toSignedMeasure (μ : Measure α) [hμ : IsFiniteMeasure μ] : SignedMeasure α where measureOf' := fun s : Set α => if MeasurableSet s then (μ s).toReal else 0 empty' := by simp [μ.empty] not_measurable' _ hi := if_neg hi m_iUnion' f hf₁ hf₂ := by simp only [*, MeasurableSet.iUnion hf₁, if_true, measure_iUnion hf₂ hf₁] rw [ENNReal.tsum_toReal_eq] exacts [(summable_measure_toReal hf₁ hf₂).hasSum, fun _ ↦ measure_ne_top _ _] #align measure_theory.measure.to_signed_measure MeasureTheory.Measure.toSignedMeasure theorem toSignedMeasure_apply_measurable {μ : Measure α} [IsFiniteMeasure μ] {i : Set α} (hi : MeasurableSet i) : μ.toSignedMeasure i = (μ i).toReal := if_pos hi #align measure_theory.measure.to_signed_measure_apply_measurable MeasureTheory.Measure.toSignedMeasure_apply_measurable -- Without this lemma, `singularPart_neg` in `MeasureTheory.Decomposition.Lebesgue` is -- extremely slow theorem toSignedMeasure_congr {μ ν : Measure α} [IsFiniteMeasure μ] [IsFiniteMeasure ν] (h : μ = ν) : μ.toSignedMeasure = ν.toSignedMeasure := by congr #align measure_theory.measure.to_signed_measure_congr MeasureTheory.Measure.toSignedMeasure_congr theorem toSignedMeasure_eq_toSignedMeasure_iff {μ ν : Measure α} [IsFiniteMeasure μ] [IsFiniteMeasure ν] : μ.toSignedMeasure = ν.toSignedMeasure ↔ μ = ν := by refine ⟨fun h => ?_, fun h => ?_⟩ · ext1 i hi have : μ.toSignedMeasure i = ν.toSignedMeasure i := by rw [h] rwa [toSignedMeasure_apply_measurable hi, toSignedMeasure_apply_measurable hi, ENNReal.toReal_eq_toReal] at this <;> exact measure_ne_top _ _ · congr #align measure_theory.measure.to_signed_measure_eq_to_signed_measure_iff MeasureTheory.Measure.toSignedMeasure_eq_toSignedMeasure_iff @[simp] theorem toSignedMeasure_zero : (0 : Measure α).toSignedMeasure = 0 := by ext i simp #align measure_theory.measure.to_signed_measure_zero MeasureTheory.Measure.toSignedMeasure_zero @[simp] theorem toSignedMeasure_add (μ ν : Measure α) [IsFiniteMeasure μ] [IsFiniteMeasure ν] : (μ + ν).toSignedMeasure = μ.toSignedMeasure + ν.toSignedMeasure := by ext i hi rw [toSignedMeasure_apply_measurable hi, add_apply, ENNReal.toReal_add (ne_of_lt (measure_lt_top _ _)) (ne_of_lt (measure_lt_top _ _)), VectorMeasure.add_apply, toSignedMeasure_apply_measurable hi, toSignedMeasure_apply_measurable hi] #align measure_theory.measure.to_signed_measure_add MeasureTheory.Measure.toSignedMeasure_add @[simp] theorem toSignedMeasure_smul (μ : Measure α) [IsFiniteMeasure μ] (r : ℝ≥0) : (r • μ).toSignedMeasure = r • μ.toSignedMeasure := by ext i hi rw [toSignedMeasure_apply_measurable hi, VectorMeasure.smul_apply, toSignedMeasure_apply_measurable hi, coe_smul, Pi.smul_apply, ENNReal.toReal_smul] #align measure_theory.measure.to_signed_measure_smul MeasureTheory.Measure.toSignedMeasure_smul /-- A measure is a vector measure over `ℝ≥0∞`. -/ @[simps] def toENNRealVectorMeasure (μ : Measure α) : VectorMeasure α ℝ≥0∞ where measureOf' := fun i : Set α => if MeasurableSet i then μ i else 0 empty' := by simp [μ.empty] not_measurable' _ hi := if_neg hi m_iUnion' _ hf₁ hf₂ := by simp only rw [Summable.hasSum_iff ENNReal.summable, if_pos (MeasurableSet.iUnion hf₁), MeasureTheory.measure_iUnion hf₂ hf₁] exact tsum_congr fun n => if_pos (hf₁ n) #align measure_theory.measure.to_ennreal_vector_measure MeasureTheory.Measure.toENNRealVectorMeasure theorem toENNRealVectorMeasure_apply_measurable {μ : Measure α} {i : Set α} (hi : MeasurableSet i) : μ.toENNRealVectorMeasure i = μ i := if_pos hi #align measure_theory.measure.to_ennreal_vector_measure_apply_measurable MeasureTheory.Measure.toENNRealVectorMeasure_apply_measurable @[simp] theorem toENNRealVectorMeasure_zero : (0 : Measure α).toENNRealVectorMeasure = 0 := by ext i simp #align measure_theory.measure.to_ennreal_vector_measure_zero MeasureTheory.Measure.toENNRealVectorMeasure_zero @[simp] theorem toENNRealVectorMeasure_add (μ ν : Measure α) : (μ + ν).toENNRealVectorMeasure = μ.toENNRealVectorMeasure + ν.toENNRealVectorMeasure := by refine MeasureTheory.VectorMeasure.ext fun i hi => ?_ rw [toENNRealVectorMeasure_apply_measurable hi, add_apply, VectorMeasure.add_apply, toENNRealVectorMeasure_apply_measurable hi, toENNRealVectorMeasure_apply_measurable hi] #align measure_theory.measure.to_ennreal_vector_measure_add MeasureTheory.Measure.toENNRealVectorMeasure_add theorem toSignedMeasure_sub_apply {μ ν : Measure α} [IsFiniteMeasure μ] [IsFiniteMeasure ν] {i : Set α} (hi : MeasurableSet i) : (μ.toSignedMeasure - ν.toSignedMeasure) i = (μ i).toReal - (ν i).toReal := by rw [VectorMeasure.sub_apply, toSignedMeasure_apply_measurable hi, Measure.toSignedMeasure_apply_measurable hi] #align measure_theory.measure.to_signed_measure_sub_apply MeasureTheory.Measure.toSignedMeasure_sub_apply end Measure namespace VectorMeasure open Measure section /-- A vector measure over `ℝ≥0∞` is a measure. -/ def ennrealToMeasure {_ : MeasurableSpace α} (v : VectorMeasure α ℝ≥0∞) : Measure α := ofMeasurable (fun s _ => v s) v.empty fun _ hf₁ hf₂ => v.of_disjoint_iUnion_nat hf₁ hf₂ #align measure_theory.vector_measure.ennreal_to_measure MeasureTheory.VectorMeasure.ennrealToMeasure theorem ennrealToMeasure_apply {m : MeasurableSpace α} {v : VectorMeasure α ℝ≥0∞} {s : Set α} (hs : MeasurableSet s) : ennrealToMeasure v s = v s := by rw [ennrealToMeasure, ofMeasurable_apply _ hs] #align measure_theory.vector_measure.ennreal_to_measure_apply MeasureTheory.VectorMeasure.ennrealToMeasure_apply @[simp] theorem _root_.MeasureTheory.Measure.toENNRealVectorMeasure_ennrealToMeasure (μ : VectorMeasure α ℝ≥0∞) : toENNRealVectorMeasure (ennrealToMeasure μ) = μ := ext fun s hs => by rw [toENNRealVectorMeasure_apply_measurable hs, ennrealToMeasure_apply hs] @[simp] theorem ennrealToMeasure_toENNRealVectorMeasure (μ : Measure α) : ennrealToMeasure (toENNRealVectorMeasure μ) = μ := Measure.ext fun s hs => by rw [ennrealToMeasure_apply hs, toENNRealVectorMeasure_apply_measurable hs] /-- The equiv between `VectorMeasure α ℝ≥0∞` and `Measure α` formed by `MeasureTheory.VectorMeasure.ennrealToMeasure` and `MeasureTheory.Measure.toENNRealVectorMeasure`. -/ @[simps] def equivMeasure [MeasurableSpace α] : VectorMeasure α ℝ≥0∞ ≃ Measure α where toFun := ennrealToMeasure invFun := toENNRealVectorMeasure left_inv := toENNRealVectorMeasure_ennrealToMeasure right_inv := ennrealToMeasure_toENNRealVectorMeasure #align measure_theory.vector_measure.equiv_measure MeasureTheory.VectorMeasure.equivMeasure end section variable [MeasurableSpace α] [MeasurableSpace β] variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M] variable (v : VectorMeasure α M) /-- The pushforward of a vector measure along a function. -/ def map (v : VectorMeasure α M) (f : α → β) : VectorMeasure β M := if hf : Measurable f then { measureOf' := fun s => if MeasurableSet s then v (f ⁻¹' s) else 0 empty' := by simp not_measurable' := fun i hi => if_neg hi m_iUnion' := by intro g hg₁ hg₂ simp only convert v.m_iUnion (fun i => hf (hg₁ i)) fun i j hij => (hg₂ hij).preimage _ · rw [if_pos (hg₁ _)] · rw [Set.preimage_iUnion, if_pos (MeasurableSet.iUnion hg₁)] } else 0 #align measure_theory.vector_measure.map MeasureTheory.VectorMeasure.map theorem map_not_measurable {f : α → β} (hf : ¬Measurable f) : v.map f = 0 := dif_neg hf #align measure_theory.vector_measure.map_not_measurable MeasureTheory.VectorMeasure.map_not_measurable theorem map_apply {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) : v.map f s = v (f ⁻¹' s) := by rw [map, dif_pos hf] exact if_pos hs #align measure_theory.vector_measure.map_apply MeasureTheory.VectorMeasure.map_apply @[simp] theorem map_id : v.map id = v := ext fun i hi => by rw [map_apply v measurable_id hi, Set.preimage_id] #align measure_theory.vector_measure.map_id MeasureTheory.VectorMeasure.map_id @[simp] theorem map_zero (f : α → β) : (0 : VectorMeasure α M).map f = 0 := by by_cases hf : Measurable f · ext i hi rw [map_apply _ hf hi, zero_apply, zero_apply] · exact dif_neg hf #align measure_theory.vector_measure.map_zero MeasureTheory.VectorMeasure.map_zero section variable {N : Type*} [AddCommMonoid N] [TopologicalSpace N] /-- Given a vector measure `v` on `M` and a continuous `AddMonoidHom` `f : M → N`, `f ∘ v` is a vector measure on `N`. -/ def mapRange (v : VectorMeasure α M) (f : M →+ N) (hf : Continuous f) : VectorMeasure α N where measureOf' s := f (v s) empty' := by simp only; rw [empty, AddMonoidHom.map_zero] not_measurable' i hi := by simp only; rw [not_measurable v hi, AddMonoidHom.map_zero] m_iUnion' g hg₁ hg₂ := HasSum.map (v.m_iUnion hg₁ hg₂) f hf #align measure_theory.vector_measure.map_range MeasureTheory.VectorMeasure.mapRange @[simp] theorem mapRange_apply {f : M →+ N} (hf : Continuous f) {s : Set α} : v.mapRange f hf s = f (v s) := rfl #align measure_theory.vector_measure.map_range_apply MeasureTheory.VectorMeasure.mapRange_apply @[simp] theorem mapRange_id : v.mapRange (AddMonoidHom.id M) continuous_id = v := by ext rfl #align measure_theory.vector_measure.map_range_id MeasureTheory.VectorMeasure.mapRange_id @[simp] theorem mapRange_zero {f : M →+ N} (hf : Continuous f) : mapRange (0 : VectorMeasure α M) f hf = 0 := by ext simp #align measure_theory.vector_measure.map_range_zero MeasureTheory.VectorMeasure.mapRange_zero section ContinuousAdd variable [ContinuousAdd M] [ContinuousAdd N] @[simp] theorem mapRange_add {v w : VectorMeasure α M} {f : M →+ N} (hf : Continuous f) : (v + w).mapRange f hf = v.mapRange f hf + w.mapRange f hf := by ext simp #align measure_theory.vector_measure.map_range_add MeasureTheory.VectorMeasure.mapRange_add /-- Given a continuous `AddMonoidHom` `f : M → N`, `mapRangeHom` is the `AddMonoidHom` mapping the vector measure `v` on `M` to the vector measure `f ∘ v` on `N`. -/ def mapRangeHom (f : M →+ N) (hf : Continuous f) : VectorMeasure α M →+ VectorMeasure α N where toFun v := v.mapRange f hf map_zero' := mapRange_zero hf map_add' _ _ := mapRange_add hf #align measure_theory.vector_measure.map_range_hom MeasureTheory.VectorMeasure.mapRangeHom end ContinuousAdd section Module variable {R : Type*} [Semiring R] [Module R M] [Module R N] variable [ContinuousAdd M] [ContinuousAdd N] [ContinuousConstSMul R M] [ContinuousConstSMul R N] /-- Given a continuous linear map `f : M → N`, `mapRangeₗ` is the linear map mapping the vector measure `v` on `M` to the vector measure `f ∘ v` on `N`. -/ def mapRangeₗ (f : M →ₗ[R] N) (hf : Continuous f) : VectorMeasure α M →ₗ[R] VectorMeasure α N where toFun v := v.mapRange f.toAddMonoidHom hf map_add' _ _ := mapRange_add hf map_smul' := by intros ext simp #align measure_theory.vector_measure.map_rangeₗ MeasureTheory.VectorMeasure.mapRangeₗ end Module end /-- The restriction of a vector measure on some set. -/ def restrict (v : VectorMeasure α M) (i : Set α) : VectorMeasure α M := if hi : MeasurableSet i then { measureOf' := fun s => if MeasurableSet s then v (s ∩ i) else 0 empty' := by simp not_measurable' := fun i hi => if_neg hi m_iUnion' := by intro f hf₁ hf₂ simp only convert v.m_iUnion (fun n => (hf₁ n).inter hi) (hf₂.mono fun i j => Disjoint.mono inf_le_left inf_le_left) · rw [if_pos (hf₁ _)] · rw [Set.iUnion_inter, if_pos (MeasurableSet.iUnion hf₁)] } else 0 #align measure_theory.vector_measure.restrict MeasureTheory.VectorMeasure.restrict theorem restrict_not_measurable {i : Set α} (hi : ¬MeasurableSet i) : v.restrict i = 0 := dif_neg hi #align measure_theory.vector_measure.restrict_not_measurable MeasureTheory.VectorMeasure.restrict_not_measurable
Mathlib/MeasureTheory/Measure/VectorMeasure.lean
682
685
theorem restrict_apply {i : Set α} (hi : MeasurableSet i) {j : Set α} (hj : MeasurableSet j) : v.restrict i j = v (j ∩ i) := by
rw [restrict, dif_pos hi] exact if_pos hj
/- Copyright (c) 2018 Kenny Lau. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kenny Lau, Mario Carneiro, Johan Commelin, Amelia Livingston, Anne Baanen -/ import Mathlib.Algebra.Algebra.Tower import Mathlib.Algebra.GroupWithZero.NonZeroDivisors import Mathlib.GroupTheory.MonoidLocalization import Mathlib.RingTheory.Ideal.Basic import Mathlib.GroupTheory.GroupAction.Ring #align_import ring_theory.localization.basic from "leanprover-community/mathlib"@"b69c9a770ecf37eb21f7b8cf4fa00de3b62694ec" /-! # Localizations of commutative rings We characterize the localization of a commutative ring `R` at a submonoid `M` up to isomorphism; that is, a commutative ring `S` is the localization of `R` at `M` iff we can find a ring homomorphism `f : R →+* S` satisfying 3 properties: 1. For all `y ∈ M`, `f y` is a unit; 2. For all `z : S`, there exists `(x, y) : R × M` such that `z * f y = f x`; 3. For all `x, y : R` such that `f x = f y`, there exists `c ∈ M` such that `x * c = y * c`. (The converse is a consequence of 1.) In the following, let `R, P` be commutative rings, `S, Q` be `R`- and `P`-algebras and `M, T` be submonoids of `R` and `P` respectively, e.g.: ``` variable (R S P Q : Type*) [CommRing R] [CommRing S] [CommRing P] [CommRing Q] variable [Algebra R S] [Algebra P Q] (M : Submonoid R) (T : Submonoid P) ``` ## Main definitions * `IsLocalization (M : Submonoid R) (S : Type*)` is a typeclass expressing that `S` is a localization of `R` at `M`, i.e. the canonical map `algebraMap R S : R →+* S` is a localization map (satisfying the above properties). * `IsLocalization.mk' S` is a surjection sending `(x, y) : R × M` to `f x * (f y)⁻¹` * `IsLocalization.lift` is the ring homomorphism from `S` induced by a homomorphism from `R` which maps elements of `M` to invertible elements of the codomain. * `IsLocalization.map S Q` is the ring homomorphism from `S` to `Q` which maps elements of `M` to elements of `T` * `IsLocalization.ringEquivOfRingEquiv`: if `R` and `P` are isomorphic by an isomorphism sending `M` to `T`, then `S` and `Q` are isomorphic * `IsLocalization.algEquiv`: if `Q` is another localization of `R` at `M`, then `S` and `Q` are isomorphic as `R`-algebras ## Main results * `Localization M S`, a construction of the localization as a quotient type, defined in `GroupTheory.MonoidLocalization`, has `CommRing`, `Algebra R` and `IsLocalization M` instances if `R` is a ring. `Localization.Away`, `Localization.AtPrime` and `FractionRing` are abbreviations for `Localization`s and have their corresponding `IsLocalization` instances ## Implementation notes In maths it is natural to reason up to isomorphism, but in Lean we cannot naturally `rewrite` one structure with an isomorphic one; one way around this is to isolate a predicate characterizing a structure up to isomorphism, and reason about things that satisfy the predicate. A previous version of this file used a fully bundled type of ring localization maps, then used a type synonym `f.codomain` for `f : LocalizationMap M S` to instantiate the `R`-algebra structure on `S`. This results in defining ad-hoc copies for everything already defined on `S`. By making `IsLocalization` a predicate on the `algebraMap R S`, we can ensure the localization map commutes nicely with other `algebraMap`s. To prove most lemmas about a localization map `algebraMap R S` in this file we invoke the corresponding proof for the underlying `CommMonoid` localization map `IsLocalization.toLocalizationMap M S`, which can be found in `GroupTheory.MonoidLocalization` and the namespace `Submonoid.LocalizationMap`. To reason about the localization as a quotient type, use `mk_eq_of_mk'` and associated lemmas. These show the quotient map `mk : R → M → Localization M` equals the surjection `LocalizationMap.mk'` induced by the map `algebraMap : R →+* Localization M`. The lemma `mk_eq_of_mk'` hence gives you access to the results in the rest of the file, which are about the `LocalizationMap.mk'` induced by any localization map. The proof that "a `CommRing` `K` which is the localization of an integral domain `R` at `R \ {0}` is a field" is a `def` rather than an `instance`, so if you want to reason about a field of fractions `K`, assume `[Field K]` instead of just `[CommRing K]`. ## Tags localization, ring localization, commutative ring localization, characteristic predicate, commutative ring, field of fractions -/ open Function section CommSemiring variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S] variable [Algebra R S] {P : Type*} [CommSemiring P] /-- The typeclass `IsLocalization (M : Submonoid R) S` where `S` is an `R`-algebra expresses that `S` is isomorphic to the localization of `R` at `M`. -/ @[mk_iff] class IsLocalization : Prop where -- Porting note: add ' to fields, and made new versions of these with either `S` or `M` explicit. /-- Everything in the image of `algebraMap` is a unit -/ map_units' : ∀ y : M, IsUnit (algebraMap R S y) /-- The `algebraMap` is surjective -/ surj' : ∀ z : S, ∃ x : R × M, z * algebraMap R S x.2 = algebraMap R S x.1 /-- The kernel of `algebraMap` is contained in the annihilator of `M`; it is then equal to the annihilator by `map_units'` -/ exists_of_eq : ∀ {x y}, algebraMap R S x = algebraMap R S y → ∃ c : M, ↑c * x = ↑c * y #align is_localization IsLocalization variable {M} namespace IsLocalization section IsLocalization variable [IsLocalization M S] section @[inherit_doc IsLocalization.map_units'] theorem map_units : ∀ y : M, IsUnit (algebraMap R S y) := IsLocalization.map_units' variable (M) {S} @[inherit_doc IsLocalization.surj'] theorem surj : ∀ z : S, ∃ x : R × M, z * algebraMap R S x.2 = algebraMap R S x.1 := IsLocalization.surj' variable (S) @[inherit_doc IsLocalization.exists_of_eq] theorem eq_iff_exists {x y} : algebraMap R S x = algebraMap R S y ↔ ∃ c : M, ↑c * x = ↑c * y := Iff.intro IsLocalization.exists_of_eq fun ⟨c, h⟩ ↦ by apply_fun algebraMap R S at h rw [map_mul, map_mul] at h exact (IsLocalization.map_units S c).mul_right_inj.mp h variable {S} theorem of_le (N : Submonoid R) (h₁ : M ≤ N) (h₂ : ∀ r ∈ N, IsUnit (algebraMap R S r)) : IsLocalization N S where map_units' r := h₂ r r.2 surj' s := have ⟨⟨x, y, hy⟩, H⟩ := IsLocalization.surj M s ⟨⟨x, y, h₁ hy⟩, H⟩ exists_of_eq {x y} := by rw [IsLocalization.eq_iff_exists M] rintro ⟨c, hc⟩ exact ⟨⟨c, h₁ c.2⟩, hc⟩ #align is_localization.of_le IsLocalization.of_le variable (S) /-- `IsLocalization.toLocalizationWithZeroMap M S` shows `S` is the monoid localization of `R` at `M`. -/ @[simps] def toLocalizationWithZeroMap : Submonoid.LocalizationWithZeroMap M S where __ := algebraMap R S toFun := algebraMap R S map_units' := IsLocalization.map_units _ surj' := IsLocalization.surj _ exists_of_eq _ _ := IsLocalization.exists_of_eq #align is_localization.to_localization_with_zero_map IsLocalization.toLocalizationWithZeroMap /-- `IsLocalization.toLocalizationMap M S` shows `S` is the monoid localization of `R` at `M`. -/ abbrev toLocalizationMap : Submonoid.LocalizationMap M S := (toLocalizationWithZeroMap M S).toLocalizationMap #align is_localization.to_localization_map IsLocalization.toLocalizationMap @[simp] theorem toLocalizationMap_toMap : (toLocalizationMap M S).toMap = (algebraMap R S : R →*₀ S) := rfl #align is_localization.to_localization_map_to_map IsLocalization.toLocalizationMap_toMap theorem toLocalizationMap_toMap_apply (x) : (toLocalizationMap M S).toMap x = algebraMap R S x := rfl #align is_localization.to_localization_map_to_map_apply IsLocalization.toLocalizationMap_toMap_apply theorem surj₂ : ∀ z w : S, ∃ z' w' : R, ∃ d : M, (z * algebraMap R S d = algebraMap R S z') ∧ (w * algebraMap R S d = algebraMap R S w') := (toLocalizationMap M S).surj₂ end variable (M) {S} /-- Given a localization map `f : M →* N`, a section function sending `z : N` to some `(x, y) : M × S` such that `f x * (f y)⁻¹ = z`. -/ noncomputable def sec (z : S) : R × M := Classical.choose <| IsLocalization.surj _ z #align is_localization.sec IsLocalization.sec @[simp] theorem toLocalizationMap_sec : (toLocalizationMap M S).sec = sec M := rfl #align is_localization.to_localization_map_sec IsLocalization.toLocalizationMap_sec /-- Given `z : S`, `IsLocalization.sec M z` is defined to be a pair `(x, y) : R × M` such that `z * f y = f x` (so this lemma is true by definition). -/ theorem sec_spec (z : S) : z * algebraMap R S (IsLocalization.sec M z).2 = algebraMap R S (IsLocalization.sec M z).1 := Classical.choose_spec <| IsLocalization.surj _ z #align is_localization.sec_spec IsLocalization.sec_spec /-- Given `z : S`, `IsLocalization.sec M z` is defined to be a pair `(x, y) : R × M` such that `z * f y = f x`, so this lemma is just an application of `S`'s commutativity. -/ theorem sec_spec' (z : S) : algebraMap R S (IsLocalization.sec M z).1 = algebraMap R S (IsLocalization.sec M z).2 * z := by rw [mul_comm, sec_spec] #align is_localization.sec_spec' IsLocalization.sec_spec' variable {M} /-- If `M` contains `0` then the localization at `M` is trivial. -/ theorem subsingleton (h : 0 ∈ M) : Subsingleton S := (toLocalizationMap M S).subsingleton h theorem map_right_cancel {x y} {c : M} (h : algebraMap R S (c * x) = algebraMap R S (c * y)) : algebraMap R S x = algebraMap R S y := (toLocalizationMap M S).map_right_cancel h #align is_localization.map_right_cancel IsLocalization.map_right_cancel theorem map_left_cancel {x y} {c : M} (h : algebraMap R S (x * c) = algebraMap R S (y * c)) : algebraMap R S x = algebraMap R S y := (toLocalizationMap M S).map_left_cancel h #align is_localization.map_left_cancel IsLocalization.map_left_cancel theorem eq_zero_of_fst_eq_zero {z x} {y : M} (h : z * algebraMap R S y = algebraMap R S x) (hx : x = 0) : z = 0 := by rw [hx, (algebraMap R S).map_zero] at h exact (IsUnit.mul_left_eq_zero (IsLocalization.map_units S y)).1 h #align is_localization.eq_zero_of_fst_eq_zero IsLocalization.eq_zero_of_fst_eq_zero variable (M S) theorem map_eq_zero_iff (r : R) : algebraMap R S r = 0 ↔ ∃ m : M, ↑m * r = 0 := by constructor · intro h obtain ⟨m, hm⟩ := (IsLocalization.eq_iff_exists M S).mp ((algebraMap R S).map_zero.trans h.symm) exact ⟨m, by simpa using hm.symm⟩ · rintro ⟨m, hm⟩ rw [← (IsLocalization.map_units S m).mul_right_inj, mul_zero, ← RingHom.map_mul, hm, RingHom.map_zero] #align is_localization.map_eq_zero_iff IsLocalization.map_eq_zero_iff variable {M} /-- `IsLocalization.mk' S` is the surjection sending `(x, y) : R × M` to `f x * (f y)⁻¹`. -/ noncomputable def mk' (x : R) (y : M) : S := (toLocalizationMap M S).mk' x y #align is_localization.mk' IsLocalization.mk' @[simp] theorem mk'_sec (z : S) : mk' S (IsLocalization.sec M z).1 (IsLocalization.sec M z).2 = z := (toLocalizationMap M S).mk'_sec _ #align is_localization.mk'_sec IsLocalization.mk'_sec theorem mk'_mul (x₁ x₂ : R) (y₁ y₂ : M) : mk' S (x₁ * x₂) (y₁ * y₂) = mk' S x₁ y₁ * mk' S x₂ y₂ := (toLocalizationMap M S).mk'_mul _ _ _ _ #align is_localization.mk'_mul IsLocalization.mk'_mul theorem mk'_one (x) : mk' S x (1 : M) = algebraMap R S x := (toLocalizationMap M S).mk'_one _ #align is_localization.mk'_one IsLocalization.mk'_one @[simp] theorem mk'_spec (x) (y : M) : mk' S x y * algebraMap R S y = algebraMap R S x := (toLocalizationMap M S).mk'_spec _ _ #align is_localization.mk'_spec IsLocalization.mk'_spec @[simp] theorem mk'_spec' (x) (y : M) : algebraMap R S y * mk' S x y = algebraMap R S x := (toLocalizationMap M S).mk'_spec' _ _ #align is_localization.mk'_spec' IsLocalization.mk'_spec' @[simp] theorem mk'_spec_mk (x) (y : R) (hy : y ∈ M) : mk' S x ⟨y, hy⟩ * algebraMap R S y = algebraMap R S x := mk'_spec S x ⟨y, hy⟩ #align is_localization.mk'_spec_mk IsLocalization.mk'_spec_mk @[simp] theorem mk'_spec'_mk (x) (y : R) (hy : y ∈ M) : algebraMap R S y * mk' S x ⟨y, hy⟩ = algebraMap R S x := mk'_spec' S x ⟨y, hy⟩ #align is_localization.mk'_spec'_mk IsLocalization.mk'_spec'_mk variable {S} theorem eq_mk'_iff_mul_eq {x} {y : M} {z} : z = mk' S x y ↔ z * algebraMap R S y = algebraMap R S x := (toLocalizationMap M S).eq_mk'_iff_mul_eq #align is_localization.eq_mk'_iff_mul_eq IsLocalization.eq_mk'_iff_mul_eq theorem mk'_eq_iff_eq_mul {x} {y : M} {z} : mk' S x y = z ↔ algebraMap R S x = z * algebraMap R S y := (toLocalizationMap M S).mk'_eq_iff_eq_mul #align is_localization.mk'_eq_iff_eq_mul IsLocalization.mk'_eq_iff_eq_mul theorem mk'_add_eq_iff_add_mul_eq_mul {x} {y : M} {z₁ z₂} : mk' S x y + z₁ = z₂ ↔ algebraMap R S x + z₁ * algebraMap R S y = z₂ * algebraMap R S y := by rw [← mk'_spec S x y, ← IsUnit.mul_left_inj (IsLocalization.map_units S y), right_distrib] #align is_localization.mk'_add_eq_iff_add_mul_eq_mul IsLocalization.mk'_add_eq_iff_add_mul_eq_mul variable (M) theorem mk'_surjective (z : S) : ∃ (x : _) (y : M), mk' S x y = z := let ⟨r, hr⟩ := IsLocalization.surj _ z ⟨r.1, r.2, (eq_mk'_iff_mul_eq.2 hr).symm⟩ #align is_localization.mk'_surjective IsLocalization.mk'_surjective variable (S) /-- The localization of a `Fintype` is a `Fintype`. Cannot be an instance. -/ noncomputable def fintype' [Fintype R] : Fintype S := have := Classical.propDecidable Fintype.ofSurjective (Function.uncurry <| IsLocalization.mk' S) fun a => Prod.exists'.mpr <| IsLocalization.mk'_surjective M a #align is_localization.fintype' IsLocalization.fintype' variable {M S} /-- Localizing at a submonoid with 0 inside it leads to the trivial ring. -/ def uniqueOfZeroMem (h : (0 : R) ∈ M) : Unique S := uniqueOfZeroEqOne <| by simpa using IsLocalization.map_units S ⟨0, h⟩ #align is_localization.unique_of_zero_mem IsLocalization.uniqueOfZeroMem theorem mk'_eq_iff_eq {x₁ x₂} {y₁ y₂ : M} : mk' S x₁ y₁ = mk' S x₂ y₂ ↔ algebraMap R S (y₂ * x₁) = algebraMap R S (y₁ * x₂) := (toLocalizationMap M S).mk'_eq_iff_eq #align is_localization.mk'_eq_iff_eq IsLocalization.mk'_eq_iff_eq theorem mk'_eq_iff_eq' {x₁ x₂} {y₁ y₂ : M} : mk' S x₁ y₁ = mk' S x₂ y₂ ↔ algebraMap R S (x₁ * y₂) = algebraMap R S (x₂ * y₁) := (toLocalizationMap M S).mk'_eq_iff_eq' #align is_localization.mk'_eq_iff_eq' IsLocalization.mk'_eq_iff_eq' theorem mk'_mem_iff {x} {y : M} {I : Ideal S} : mk' S x y ∈ I ↔ algebraMap R S x ∈ I := by constructor <;> intro h · rw [← mk'_spec S x y, mul_comm] exact I.mul_mem_left ((algebraMap R S) y) h · rw [← mk'_spec S x y] at h obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.1 (map_units S y) have := I.mul_mem_left b h rwa [mul_comm, mul_assoc, hb, mul_one] at this #align is_localization.mk'_mem_iff IsLocalization.mk'_mem_iff protected theorem eq {a₁ b₁} {a₂ b₂ : M} : mk' S a₁ a₂ = mk' S b₁ b₂ ↔ ∃ c : M, ↑c * (↑b₂ * a₁) = c * (a₂ * b₁) := (toLocalizationMap M S).eq #align is_localization.eq IsLocalization.eq
Mathlib/RingTheory/Localization/Basic.lean
348
349
theorem mk'_eq_zero_iff (x : R) (s : M) : mk' S x s = 0 ↔ ∃ m : M, ↑m * x = 0 := by
rw [← (map_units S s).mul_left_inj, mk'_spec, zero_mul, map_eq_zero_iff M]
/- Copyright (c) 2021 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Init.Data.Nat.Notation import Mathlib.Init.Order.Defs set_option autoImplicit true structure UFModel (n) where parent : Fin n → Fin n rank : Nat → Nat rank_lt : ∀ i, (parent i).1 ≠ i → rank i < rank (parent i) namespace UFModel def empty : UFModel 0 where parent i := i.elim0 rank _ := 0 rank_lt i := i.elim0 def push {n} (m : UFModel n) (k) (le : n ≤ k) : UFModel k where parent i := if h : i < n then let ⟨a, h'⟩ := m.parent ⟨i, h⟩ ⟨a, Nat.lt_of_lt_of_le h' le⟩ else i rank i := if i < n then m.rank i else 0 rank_lt i := by simp; split <;> rename_i h · simp [(m.parent ⟨i, h⟩).2, h]; exact m.rank_lt _ · nofun def setParent {n} (m : UFModel n) (x y : Fin n) (h : m.rank x < m.rank y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank := m.rank rank_lt i := by simp; split <;> rename_i h' · rw [← h']; exact fun _ ↦ h · exact m.rank_lt i def setParentBump {n} (m : UFModel n) (x y : Fin n) (H : m.rank x ≤ m.rank y) (hroot : (m.parent y).1 = y) : UFModel n where parent i := if x.1 = i then y else m.parent i rank i := if y.1 = i ∧ m.rank x = m.rank y then m.rank y + 1 else m.rank i rank_lt i := by simp; split <;> (rename_i h₁; (try simp [h₁]); split <;> rename_i h₂ <;> (intro h; try simp [h] at h₂ <;> simp [h₁, h₂, h])) · simp [← h₁]; split <;> rename_i h₃ · rw [h₃]; apply Nat.lt_succ_self · exact Nat.lt_of_le_of_ne H h₃ · have := Fin.eq_of_val_eq h₂.1; subst this simp [hroot] at h · have := m.rank_lt i h split <;> rename_i h₃ · rw [h₃.1]; exact Nat.lt_succ_of_lt this · exact this end UFModel structure UFNode (α : Type*) where parent : Nat value : α rank : Nat inductive UFModel.Agrees (arr : Array α) (f : α → β) : ∀ {n}, (Fin n → β) → Prop | mk : Agrees arr f fun i ↦ f (arr.get i) namespace UFModel.Agrees
Mathlib/Data/UnionFind.lean
73
77
theorem mk' {arr : Array α} {f : α → β} {n} {g : Fin n → β} (e : n = arr.size) (H : ∀ i h₁ h₂, f (arr.get ⟨i, h₁⟩) = g ⟨i, h₂⟩) : Agrees arr f g := by
cases e have : (fun i ↦ f (arr.get i)) = g := by funext ⟨i, h⟩; apply H cases this; constructor
/- Copyright (c) 2021 Junyan Xu. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Junyan Xu -/ import Mathlib.AlgebraicGeometry.Restrict import Mathlib.CategoryTheory.Adjunction.Limits import Mathlib.CategoryTheory.Adjunction.Reflective #align_import algebraic_geometry.Gamma_Spec_adjunction from "leanprover-community/mathlib"@"d39590fc8728fbf6743249802486f8c91ffe07bc" /-! # Adjunction between `Γ` and `Spec` We define the adjunction `ΓSpec.adjunction : Γ ⊣ Spec` by defining the unit (`toΓSpec`, in multiple steps in this file) and counit (done in `Spec.lean`) and checking that they satisfy the left and right triangle identities. The constructions and proofs make use of maps and lemmas defined and proved in structure_sheaf.lean extensively. Notice that since the adjunction is between contravariant functors, you get to choose one of the two categories to have arrows reversed, and it is equally valid to present the adjunction as `Spec ⊣ Γ` (`Spec.to_LocallyRingedSpace.right_op ⊣ Γ`), in which case the unit and the counit would switch to each other. ## Main definition * `AlgebraicGeometry.identityToΓSpec` : The natural transformation `𝟭 _ ⟶ Γ ⋙ Spec`. * `AlgebraicGeometry.ΓSpec.locallyRingedSpaceAdjunction` : The adjunction `Γ ⊣ Spec` from `CommRingᵒᵖ` to `LocallyRingedSpace`. * `AlgebraicGeometry.ΓSpec.adjunction` : The adjunction `Γ ⊣ Spec` from `CommRingᵒᵖ` to `Scheme`. -/ -- Explicit universe annotations were used in this file to improve perfomance #12737 set_option linter.uppercaseLean3 false noncomputable section universe u open PrimeSpectrum namespace AlgebraicGeometry open Opposite open CategoryTheory open StructureSheaf open Spec (structureSheaf) open TopologicalSpace open AlgebraicGeometry.LocallyRingedSpace open TopCat.Presheaf open TopCat.Presheaf.SheafCondition namespace LocallyRingedSpace variable (X : LocallyRingedSpace.{u}) /-- The map from the global sections to a stalk. -/ def ΓToStalk (x : X) : Γ.obj (op X) ⟶ X.presheaf.stalk x := X.presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens X)) #align algebraic_geometry.LocallyRingedSpace.Γ_to_stalk AlgebraicGeometry.LocallyRingedSpace.ΓToStalk /-- The canonical map from the underlying set to the prime spectrum of `Γ(X)`. -/ def toΓSpecFun : X → PrimeSpectrum (Γ.obj (op X)) := fun x => comap (X.ΓToStalk x) (LocalRing.closedPoint (X.presheaf.stalk x)) #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_fun AlgebraicGeometry.LocallyRingedSpace.toΓSpecFun theorem not_mem_prime_iff_unit_in_stalk (r : Γ.obj (op X)) (x : X) : r ∉ (X.toΓSpecFun x).asIdeal ↔ IsUnit (X.ΓToStalk x r) := by erw [LocalRing.mem_maximalIdeal, Classical.not_not] #align algebraic_geometry.LocallyRingedSpace.not_mem_prime_iff_unit_in_stalk AlgebraicGeometry.LocallyRingedSpace.not_mem_prime_iff_unit_in_stalk /-- The preimage of a basic open in `Spec Γ(X)` under the unit is the basic open in `X` defined by the same element (they are equal as sets). -/ theorem toΓSpec_preim_basicOpen_eq (r : Γ.obj (op X)) : X.toΓSpecFun ⁻¹' (basicOpen r).1 = (X.toRingedSpace.basicOpen r).1 := by ext erw [X.toRingedSpace.mem_top_basicOpen]; apply not_mem_prime_iff_unit_in_stalk #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_preim_basic_open_eq AlgebraicGeometry.LocallyRingedSpace.toΓSpec_preim_basicOpen_eq /-- `toΓSpecFun` is continuous. -/ theorem toΓSpec_continuous : Continuous X.toΓSpecFun := by rw [isTopologicalBasis_basic_opens.continuous_iff] rintro _ ⟨r, rfl⟩ erw [X.toΓSpec_preim_basicOpen_eq r] exact (X.toRingedSpace.basicOpen r).2 #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_continuous AlgebraicGeometry.LocallyRingedSpace.toΓSpec_continuous /-- The canonical (bundled) continuous map from the underlying topological space of `X` to the prime spectrum of its global sections. -/ @[simps] def toΓSpecBase : X.toTopCat ⟶ Spec.topObj (Γ.obj (op X)) where toFun := X.toΓSpecFun continuous_toFun := X.toΓSpec_continuous #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_base AlgebraicGeometry.LocallyRingedSpace.toΓSpecBase -- These lemmas have always been bad (#7657), but lean4#2644 made `simp` start noticing attribute [nolint simpNF] AlgebraicGeometry.LocallyRingedSpace.toΓSpecBase_apply variable (r : Γ.obj (op X)) /-- The preimage in `X` of a basic open in `Spec Γ(X)` (as an open set). -/ abbrev toΓSpecMapBasicOpen : Opens X := (Opens.map X.toΓSpecBase).obj (basicOpen r) #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_map_basic_open AlgebraicGeometry.LocallyRingedSpace.toΓSpecMapBasicOpen /-- The preimage is the basic open in `X` defined by the same element `r`. -/ theorem toΓSpecMapBasicOpen_eq : X.toΓSpecMapBasicOpen r = X.toRingedSpace.basicOpen r := Opens.ext (X.toΓSpec_preim_basicOpen_eq r) #align algebraic_geometry.LocallyRingedSpace.to_Γ_Spec_map_basic_open_eq AlgebraicGeometry.LocallyRingedSpace.toΓSpecMapBasicOpen_eq /-- The map from the global sections `Γ(X)` to the sections on the (preimage of) a basic open. -/ abbrev toToΓSpecMapBasicOpen : X.presheaf.obj (op ⊤) ⟶ X.presheaf.obj (op <| X.toΓSpecMapBasicOpen r) := X.presheaf.map (X.toΓSpecMapBasicOpen r).leTop.op #align algebraic_geometry.LocallyRingedSpace.to_to_Γ_Spec_map_basic_open AlgebraicGeometry.LocallyRingedSpace.toToΓSpecMapBasicOpen /-- `r` is a unit as a section on the basic open defined by `r`. -/
Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean
128
134
theorem isUnit_res_toΓSpecMapBasicOpen : IsUnit (X.toToΓSpecMapBasicOpen r r) := by
convert (X.presheaf.map <| (eqToHom <| X.toΓSpecMapBasicOpen_eq r).op).isUnit_map (X.toRingedSpace.isUnit_res_basicOpen r) -- Porting note: `rw [comp_apply]` to `erw [comp_apply]` erw [← comp_apply, ← Functor.map_comp] congr
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro -/ import Mathlib.MeasureTheory.Measure.MeasureSpace /-! # Restricting a measure to a subset or a subtype Given a measure `μ` on a type `α` and a subset `s` of `α`, we define a measure `μ.restrict s` as the restriction of `μ` to `s` (still as a measure on `α`). We investigate how this notion interacts with usual operations on measures (sum, pushforward, pullback), and on sets (inclusion, union, Union). We also study the relationship between the restriction of a measure to a subtype (given by the pullback under `Subtype.val`) and the restriction to a set as above. -/ open scoped ENNReal NNReal Topology open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function variable {R α β δ γ ι : Type*} namespace MeasureTheory variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ] variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α} namespace Measure /-! ### Restricting a measure -/ /-- Restrict a measure `μ` to a set `s` as an `ℝ≥0∞`-linear map. -/ noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α := liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc] exact le_toOuterMeasure_caratheodory _ _ hs' _ #align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ /-- Restrict a measure `μ` to a set `s`. -/ noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α := restrictₗ s μ #align measure_theory.measure.restrict MeasureTheory.Measure.restrict @[simp] theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) : restrictₗ s μ = μ.restrict s := rfl #align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply /-- This lemma shows that `restrict` and `toOuterMeasure` commute. Note that the LHS has a restrict on measures and the RHS has a restrict on outer measures. -/ theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) : (μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk, toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed] #align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply, coe_toOuterMeasure] #align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀ /-- If `t` is a measurable set, then the measure of `t` with respect to the restriction of the measure to `s` equals the outer measure of `t ∩ s`. An alternate version requiring that `s` be measurable instead of `t` exists as `Measure.restrict_apply'`. -/ @[simp] theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) := restrict_apply₀ ht.nullMeasurableSet #align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply /-- Restriction of a measure to a subset is monotone both in set and in measure. -/ theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s') (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩) _ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s') _ = ν.restrict s' t := (restrict_apply ht).symm #align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono' /-- Restriction of a measure to a subset is monotone both in set and in measure. -/ @[mono] theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' := restrict_mono' (ae_of_all _ hs) hμν #align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t := restrict_mono' h (le_refl μ) #align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t := le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le) #align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set /-- If `s` is a measurable set, then the outer measure of `t` with respect to the restriction of the measure to `s` equals the outer measure of `t ∩ s`. This is an alternate version of `Measure.restrict_apply`, requiring that `s` is measurable instead of `t`. -/ @[simp] theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by rw [← toOuterMeasure_apply, Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs, OuterMeasure.restrict_apply s t _, toOuterMeasure_apply] #align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply' theorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by rw [← restrict_congr_set hs.toMeasurable_ae_eq, restrict_apply' (measurableSet_toMeasurable _ _), measure_congr ((ae_eq_refl t).inter hs.toMeasurable_ae_eq)] #align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀' theorem restrict_le_self : μ.restrict s ≤ μ := Measure.le_iff.2 fun t ht => calc μ.restrict s t = μ (t ∩ s) := restrict_apply ht _ ≤ μ t := measure_mono inter_subset_left #align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self variable (μ) theorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s := (le_iff'.1 restrict_le_self s).antisymm <| calc μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) := measure_mono (subset_inter (subset_toMeasurable _ _) h) _ = μ.restrict t s := by rw [← restrict_apply (measurableSet_toMeasurable _ _), measure_toMeasurable] #align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self @[simp] theorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s := restrict_eq_self μ Subset.rfl #align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self variable {μ} theorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by rw [restrict_apply MeasurableSet.univ, Set.univ_inter] #align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ theorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t := calc μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ inter_subset_right).symm _ ≤ μ.restrict s t := measure_mono inter_subset_left #align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply theorem restrict_apply_le (s t : Set α) : μ.restrict s t ≤ μ t := Measure.le_iff'.1 restrict_le_self _ theorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s := ((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm ((restrict_apply_self μ s).symm.trans_le <| measure_mono h) #align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset @[simp] theorem restrict_add {_m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) : (μ + ν).restrict s = μ.restrict s + ν.restrict s := (restrictₗ s).map_add μ ν #align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add @[simp] theorem restrict_zero {_m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 := (restrictₗ s).map_zero #align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero @[simp] theorem restrict_smul {_m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) : (c • μ).restrict s = c • μ.restrict s := (restrictₗ s).map_smul c μ #align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul theorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := ext fun u hu => by simp only [Set.inter_assoc, restrict_apply hu, restrict_apply₀ (hu.nullMeasurableSet.inter hs)] #align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀ @[simp] theorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) := restrict_restrict₀ hs.nullMeasurableSet #align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict
Mathlib/MeasureTheory/Measure/Restrict.lean
187
190
theorem restrict_restrict_of_subset (h : s ⊆ t) : (μ.restrict t).restrict s = μ.restrict s := by
ext1 u hu rw [restrict_apply hu, restrict_apply hu, restrict_eq_self] exact inter_subset_right.trans h
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Analysis.SpecialFunctions.Exp import Mathlib.Tactic.Positivity.Core import Mathlib.Algebra.Ring.NegOnePow #align_import analysis.special_functions.trigonometric.basic from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Trigonometric functions ## Main definitions This file contains the definition of `π`. See also `Analysis.SpecialFunctions.Trigonometric.Inverse` and `Analysis.SpecialFunctions.Trigonometric.Arctan` for the inverse trigonometric functions. See also `Analysis.SpecialFunctions.Complex.Arg` and `Analysis.SpecialFunctions.Complex.Log` for the complex argument function and the complex logarithm. ## Main statements Many basic inequalities on the real trigonometric functions are established. The continuity of the usual trigonometric functions is proved. Several facts about the real trigonometric functions have the proofs deferred to `Analysis.SpecialFunctions.Trigonometric.Complex`, as they are most easily proved by appealing to the corresponding fact for complex trigonometric functions. See also `Analysis.SpecialFunctions.Trigonometric.Chebyshev` for the multiple angle formulas in terms of Chebyshev polynomials. ## Tags sin, cos, tan, angle -/ noncomputable section open scoped Classical open Topology Filter Set namespace Complex @[continuity, fun_prop] theorem continuous_sin : Continuous sin := by change Continuous fun z => (exp (-z * I) - exp (z * I)) * I / 2 continuity #align complex.continuous_sin Complex.continuous_sin @[fun_prop] theorem continuousOn_sin {s : Set ℂ} : ContinuousOn sin s := continuous_sin.continuousOn #align complex.continuous_on_sin Complex.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := by change Continuous fun z => (exp (z * I) + exp (-z * I)) / 2 continuity #align complex.continuous_cos Complex.continuous_cos @[fun_prop] theorem continuousOn_cos {s : Set ℂ} : ContinuousOn cos s := continuous_cos.continuousOn #align complex.continuous_on_cos Complex.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := by change Continuous fun z => (exp z - exp (-z)) / 2 continuity #align complex.continuous_sinh Complex.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := by change Continuous fun z => (exp z + exp (-z)) / 2 continuity #align complex.continuous_cosh Complex.continuous_cosh end Complex namespace Real variable {x y z : ℝ} @[continuity, fun_prop] theorem continuous_sin : Continuous sin := Complex.continuous_re.comp (Complex.continuous_sin.comp Complex.continuous_ofReal) #align real.continuous_sin Real.continuous_sin @[fun_prop] theorem continuousOn_sin {s} : ContinuousOn sin s := continuous_sin.continuousOn #align real.continuous_on_sin Real.continuousOn_sin @[continuity, fun_prop] theorem continuous_cos : Continuous cos := Complex.continuous_re.comp (Complex.continuous_cos.comp Complex.continuous_ofReal) #align real.continuous_cos Real.continuous_cos @[fun_prop] theorem continuousOn_cos {s} : ContinuousOn cos s := continuous_cos.continuousOn #align real.continuous_on_cos Real.continuousOn_cos @[continuity, fun_prop] theorem continuous_sinh : Continuous sinh := Complex.continuous_re.comp (Complex.continuous_sinh.comp Complex.continuous_ofReal) #align real.continuous_sinh Real.continuous_sinh @[continuity, fun_prop] theorem continuous_cosh : Continuous cosh := Complex.continuous_re.comp (Complex.continuous_cosh.comp Complex.continuous_ofReal) #align real.continuous_cosh Real.continuous_cosh end Real namespace Real theorem exists_cos_eq_zero : 0 ∈ cos '' Icc (1 : ℝ) 2 := intermediate_value_Icc' (by norm_num) continuousOn_cos ⟨le_of_lt cos_two_neg, le_of_lt cos_one_pos⟩ #align real.exists_cos_eq_zero Real.exists_cos_eq_zero /-- The number π = 3.14159265... Defined here using choice as twice a zero of cos in [1,2], from which one can derive all its properties. For explicit bounds on π, see `Data.Real.Pi.Bounds`. -/ protected noncomputable def pi : ℝ := 2 * Classical.choose exists_cos_eq_zero #align real.pi Real.pi @[inherit_doc] scoped notation "π" => Real.pi @[simp] theorem cos_pi_div_two : cos (π / 2) = 0 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).2 #align real.cos_pi_div_two Real.cos_pi_div_two theorem one_le_pi_div_two : (1 : ℝ) ≤ π / 2 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).1.1 #align real.one_le_pi_div_two Real.one_le_pi_div_two theorem pi_div_two_le_two : π / 2 ≤ 2 := by rw [Real.pi, mul_div_cancel_left₀ _ (two_ne_zero' ℝ)] exact (Classical.choose_spec exists_cos_eq_zero).1.2 #align real.pi_div_two_le_two Real.pi_div_two_le_two theorem two_le_pi : (2 : ℝ) ≤ π := (div_le_div_right (show (0 : ℝ) < 2 by norm_num)).1 (by rw [div_self (two_ne_zero' ℝ)]; exact one_le_pi_div_two) #align real.two_le_pi Real.two_le_pi theorem pi_le_four : π ≤ 4 := (div_le_div_right (show (0 : ℝ) < 2 by norm_num)).1 (calc π / 2 ≤ 2 := pi_div_two_le_two _ = 4 / 2 := by norm_num) #align real.pi_le_four Real.pi_le_four theorem pi_pos : 0 < π := lt_of_lt_of_le (by norm_num) two_le_pi #align real.pi_pos Real.pi_pos theorem pi_nonneg : 0 ≤ π := pi_pos.le theorem pi_ne_zero : π ≠ 0 := pi_pos.ne' #align real.pi_ne_zero Real.pi_ne_zero theorem pi_div_two_pos : 0 < π / 2 := half_pos pi_pos #align real.pi_div_two_pos Real.pi_div_two_pos theorem two_pi_pos : 0 < 2 * π := by linarith [pi_pos] #align real.two_pi_pos Real.two_pi_pos end Real namespace Mathlib.Meta.Positivity open Lean.Meta Qq /-- Extension for the `positivity` tactic: `π` is always positive. -/ @[positivity Real.pi] def evalRealPi : PositivityExt where eval {u α} _zα _pα e := do match u, α, e with | 0, ~q(ℝ), ~q(Real.pi) => assertInstancesCommute pure (.positive q(Real.pi_pos)) | _, _, _ => throwError "not Real.pi" end Mathlib.Meta.Positivity namespace NNReal open Real open Real NNReal /-- `π` considered as a nonnegative real. -/ noncomputable def pi : ℝ≥0 := ⟨π, Real.pi_pos.le⟩ #align nnreal.pi NNReal.pi @[simp] theorem coe_real_pi : (pi : ℝ) = π := rfl #align nnreal.coe_real_pi NNReal.coe_real_pi theorem pi_pos : 0 < pi := mod_cast Real.pi_pos #align nnreal.pi_pos NNReal.pi_pos theorem pi_ne_zero : pi ≠ 0 := pi_pos.ne' #align nnreal.pi_ne_zero NNReal.pi_ne_zero end NNReal namespace Real open Real @[simp] theorem sin_pi : sin π = 0 := by rw [← mul_div_cancel_left₀ π (two_ne_zero' ℝ), two_mul, add_div, sin_add, cos_pi_div_two]; simp #align real.sin_pi Real.sin_pi @[simp] theorem cos_pi : cos π = -1 := by rw [← mul_div_cancel_left₀ π (two_ne_zero' ℝ), mul_div_assoc, cos_two_mul, cos_pi_div_two] norm_num #align real.cos_pi Real.cos_pi @[simp] theorem sin_two_pi : sin (2 * π) = 0 := by simp [two_mul, sin_add] #align real.sin_two_pi Real.sin_two_pi @[simp] theorem cos_two_pi : cos (2 * π) = 1 := by simp [two_mul, cos_add] #align real.cos_two_pi Real.cos_two_pi theorem sin_antiperiodic : Function.Antiperiodic sin π := by simp [sin_add] #align real.sin_antiperiodic Real.sin_antiperiodic theorem sin_periodic : Function.Periodic sin (2 * π) := sin_antiperiodic.periodic_two_mul #align real.sin_periodic Real.sin_periodic @[simp] theorem sin_add_pi (x : ℝ) : sin (x + π) = -sin x := sin_antiperiodic x #align real.sin_add_pi Real.sin_add_pi @[simp] theorem sin_add_two_pi (x : ℝ) : sin (x + 2 * π) = sin x := sin_periodic x #align real.sin_add_two_pi Real.sin_add_two_pi @[simp] theorem sin_sub_pi (x : ℝ) : sin (x - π) = -sin x := sin_antiperiodic.sub_eq x #align real.sin_sub_pi Real.sin_sub_pi @[simp] theorem sin_sub_two_pi (x : ℝ) : sin (x - 2 * π) = sin x := sin_periodic.sub_eq x #align real.sin_sub_two_pi Real.sin_sub_two_pi @[simp] theorem sin_pi_sub (x : ℝ) : sin (π - x) = sin x := neg_neg (sin x) ▸ sin_neg x ▸ sin_antiperiodic.sub_eq' #align real.sin_pi_sub Real.sin_pi_sub @[simp] theorem sin_two_pi_sub (x : ℝ) : sin (2 * π - x) = -sin x := sin_neg x ▸ sin_periodic.sub_eq' #align real.sin_two_pi_sub Real.sin_two_pi_sub @[simp] theorem sin_nat_mul_pi (n : ℕ) : sin (n * π) = 0 := sin_antiperiodic.nat_mul_eq_of_eq_zero sin_zero n #align real.sin_nat_mul_pi Real.sin_nat_mul_pi @[simp] theorem sin_int_mul_pi (n : ℤ) : sin (n * π) = 0 := sin_antiperiodic.int_mul_eq_of_eq_zero sin_zero n #align real.sin_int_mul_pi Real.sin_int_mul_pi @[simp] theorem sin_add_nat_mul_two_pi (x : ℝ) (n : ℕ) : sin (x + n * (2 * π)) = sin x := sin_periodic.nat_mul n x #align real.sin_add_nat_mul_two_pi Real.sin_add_nat_mul_two_pi @[simp] theorem sin_add_int_mul_two_pi (x : ℝ) (n : ℤ) : sin (x + n * (2 * π)) = sin x := sin_periodic.int_mul n x #align real.sin_add_int_mul_two_pi Real.sin_add_int_mul_two_pi @[simp] theorem sin_sub_nat_mul_two_pi (x : ℝ) (n : ℕ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_nat_mul_eq n #align real.sin_sub_nat_mul_two_pi Real.sin_sub_nat_mul_two_pi @[simp] theorem sin_sub_int_mul_two_pi (x : ℝ) (n : ℤ) : sin (x - n * (2 * π)) = sin x := sin_periodic.sub_int_mul_eq n #align real.sin_sub_int_mul_two_pi Real.sin_sub_int_mul_two_pi @[simp] theorem sin_nat_mul_two_pi_sub (x : ℝ) (n : ℕ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.nat_mul_sub_eq n #align real.sin_nat_mul_two_pi_sub Real.sin_nat_mul_two_pi_sub @[simp] theorem sin_int_mul_two_pi_sub (x : ℝ) (n : ℤ) : sin (n * (2 * π) - x) = -sin x := sin_neg x ▸ sin_periodic.int_mul_sub_eq n #align real.sin_int_mul_two_pi_sub Real.sin_int_mul_two_pi_sub theorem sin_add_int_mul_pi (x : ℝ) (n : ℤ) : sin (x + n * π) = (-1) ^ n * sin x := n.coe_negOnePow ℝ ▸ sin_antiperiodic.add_int_mul_eq n theorem sin_add_nat_mul_pi (x : ℝ) (n : ℕ) : sin (x + n * π) = (-1) ^ n * sin x := sin_antiperiodic.add_nat_mul_eq n theorem sin_sub_int_mul_pi (x : ℝ) (n : ℤ) : sin (x - n * π) = (-1) ^ n * sin x := n.coe_negOnePow ℝ ▸ sin_antiperiodic.sub_int_mul_eq n theorem sin_sub_nat_mul_pi (x : ℝ) (n : ℕ) : sin (x - n * π) = (-1) ^ n * sin x := sin_antiperiodic.sub_nat_mul_eq n theorem sin_int_mul_pi_sub (x : ℝ) (n : ℤ) : sin (n * π - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg, Int.coe_negOnePow] using sin_antiperiodic.int_mul_sub_eq n theorem sin_nat_mul_pi_sub (x : ℝ) (n : ℕ) : sin (n * π - x) = -((-1) ^ n * sin x) := by simpa only [sin_neg, mul_neg] using sin_antiperiodic.nat_mul_sub_eq n theorem cos_antiperiodic : Function.Antiperiodic cos π := by simp [cos_add] #align real.cos_antiperiodic Real.cos_antiperiodic theorem cos_periodic : Function.Periodic cos (2 * π) := cos_antiperiodic.periodic_two_mul #align real.cos_periodic Real.cos_periodic @[simp] theorem cos_add_pi (x : ℝ) : cos (x + π) = -cos x := cos_antiperiodic x #align real.cos_add_pi Real.cos_add_pi @[simp] theorem cos_add_two_pi (x : ℝ) : cos (x + 2 * π) = cos x := cos_periodic x #align real.cos_add_two_pi Real.cos_add_two_pi @[simp] theorem cos_sub_pi (x : ℝ) : cos (x - π) = -cos x := cos_antiperiodic.sub_eq x #align real.cos_sub_pi Real.cos_sub_pi @[simp] theorem cos_sub_two_pi (x : ℝ) : cos (x - 2 * π) = cos x := cos_periodic.sub_eq x #align real.cos_sub_two_pi Real.cos_sub_two_pi @[simp] theorem cos_pi_sub (x : ℝ) : cos (π - x) = -cos x := cos_neg x ▸ cos_antiperiodic.sub_eq' #align real.cos_pi_sub Real.cos_pi_sub @[simp] theorem cos_two_pi_sub (x : ℝ) : cos (2 * π - x) = cos x := cos_neg x ▸ cos_periodic.sub_eq' #align real.cos_two_pi_sub Real.cos_two_pi_sub @[simp] theorem cos_nat_mul_two_pi (n : ℕ) : cos (n * (2 * π)) = 1 := (cos_periodic.nat_mul_eq n).trans cos_zero #align real.cos_nat_mul_two_pi Real.cos_nat_mul_two_pi @[simp] theorem cos_int_mul_two_pi (n : ℤ) : cos (n * (2 * π)) = 1 := (cos_periodic.int_mul_eq n).trans cos_zero #align real.cos_int_mul_two_pi Real.cos_int_mul_two_pi @[simp] theorem cos_add_nat_mul_two_pi (x : ℝ) (n : ℕ) : cos (x + n * (2 * π)) = cos x := cos_periodic.nat_mul n x #align real.cos_add_nat_mul_two_pi Real.cos_add_nat_mul_two_pi @[simp] theorem cos_add_int_mul_two_pi (x : ℝ) (n : ℤ) : cos (x + n * (2 * π)) = cos x := cos_periodic.int_mul n x #align real.cos_add_int_mul_two_pi Real.cos_add_int_mul_two_pi @[simp] theorem cos_sub_nat_mul_two_pi (x : ℝ) (n : ℕ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_nat_mul_eq n #align real.cos_sub_nat_mul_two_pi Real.cos_sub_nat_mul_two_pi @[simp] theorem cos_sub_int_mul_two_pi (x : ℝ) (n : ℤ) : cos (x - n * (2 * π)) = cos x := cos_periodic.sub_int_mul_eq n #align real.cos_sub_int_mul_two_pi Real.cos_sub_int_mul_two_pi @[simp] theorem cos_nat_mul_two_pi_sub (x : ℝ) (n : ℕ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.nat_mul_sub_eq n #align real.cos_nat_mul_two_pi_sub Real.cos_nat_mul_two_pi_sub @[simp] theorem cos_int_mul_two_pi_sub (x : ℝ) (n : ℤ) : cos (n * (2 * π) - x) = cos x := cos_neg x ▸ cos_periodic.int_mul_sub_eq n #align real.cos_int_mul_two_pi_sub Real.cos_int_mul_two_pi_sub theorem cos_add_int_mul_pi (x : ℝ) (n : ℤ) : cos (x + n * π) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_antiperiodic.add_int_mul_eq n theorem cos_add_nat_mul_pi (x : ℝ) (n : ℕ) : cos (x + n * π) = (-1) ^ n * cos x := cos_antiperiodic.add_nat_mul_eq n theorem cos_sub_int_mul_pi (x : ℝ) (n : ℤ) : cos (x - n * π) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_antiperiodic.sub_int_mul_eq n theorem cos_sub_nat_mul_pi (x : ℝ) (n : ℕ) : cos (x - n * π) = (-1) ^ n * cos x := cos_antiperiodic.sub_nat_mul_eq n theorem cos_int_mul_pi_sub (x : ℝ) (n : ℤ) : cos (n * π - x) = (-1) ^ n * cos x := n.coe_negOnePow ℝ ▸ cos_neg x ▸ cos_antiperiodic.int_mul_sub_eq n theorem cos_nat_mul_pi_sub (x : ℝ) (n : ℕ) : cos (n * π - x) = (-1) ^ n * cos x := cos_neg x ▸ cos_antiperiodic.nat_mul_sub_eq n -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_add_pi (n : ℕ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_add_pi Real.cos_nat_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_add_pi (n : ℤ) : cos (n * (2 * π) + π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).add_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_add_pi Real.cos_int_mul_two_pi_add_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_nat_mul_two_pi_sub_pi (n : ℕ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.nat_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_nat_mul_two_pi_sub_pi Real.cos_nat_mul_two_pi_sub_pi -- Porting note (#10618): was @[simp], but simp can prove it theorem cos_int_mul_two_pi_sub_pi (n : ℤ) : cos (n * (2 * π) - π) = -1 := by simpa only [cos_zero] using (cos_periodic.int_mul n).sub_antiperiod_eq cos_antiperiodic #align real.cos_int_mul_two_pi_sub_pi Real.cos_int_mul_two_pi_sub_pi theorem sin_pos_of_pos_of_lt_pi {x : ℝ} (h0x : 0 < x) (hxp : x < π) : 0 < sin x := if hx2 : x ≤ 2 then sin_pos_of_pos_of_le_two h0x hx2 else have : (2 : ℝ) + 2 = 4 := by norm_num have : π - x ≤ 2 := sub_le_iff_le_add.2 (le_trans pi_le_four (this ▸ add_le_add_left (le_of_not_ge hx2) _)) sin_pi_sub x ▸ sin_pos_of_pos_of_le_two (sub_pos.2 hxp) this #align real.sin_pos_of_pos_of_lt_pi Real.sin_pos_of_pos_of_lt_pi theorem sin_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo 0 π) : 0 < sin x := sin_pos_of_pos_of_lt_pi hx.1 hx.2 #align real.sin_pos_of_mem_Ioo Real.sin_pos_of_mem_Ioo theorem sin_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc 0 π) : 0 ≤ sin x := by rw [← closure_Ioo pi_ne_zero.symm] at hx exact closure_lt_subset_le continuous_const continuous_sin (closure_mono (fun y => sin_pos_of_mem_Ioo) hx) #align real.sin_nonneg_of_mem_Icc Real.sin_nonneg_of_mem_Icc theorem sin_nonneg_of_nonneg_of_le_pi {x : ℝ} (h0x : 0 ≤ x) (hxp : x ≤ π) : 0 ≤ sin x := sin_nonneg_of_mem_Icc ⟨h0x, hxp⟩ #align real.sin_nonneg_of_nonneg_of_le_pi Real.sin_nonneg_of_nonneg_of_le_pi theorem sin_neg_of_neg_of_neg_pi_lt {x : ℝ} (hx0 : x < 0) (hpx : -π < x) : sin x < 0 := neg_pos.1 <| sin_neg x ▸ sin_pos_of_pos_of_lt_pi (neg_pos.2 hx0) (neg_lt.1 hpx) #align real.sin_neg_of_neg_of_neg_pi_lt Real.sin_neg_of_neg_of_neg_pi_lt theorem sin_nonpos_of_nonnpos_of_neg_pi_le {x : ℝ} (hx0 : x ≤ 0) (hpx : -π ≤ x) : sin x ≤ 0 := neg_nonneg.1 <| sin_neg x ▸ sin_nonneg_of_nonneg_of_le_pi (neg_nonneg.2 hx0) (neg_le.1 hpx) #align real.sin_nonpos_of_nonnpos_of_neg_pi_le Real.sin_nonpos_of_nonnpos_of_neg_pi_le @[simp] theorem sin_pi_div_two : sin (π / 2) = 1 := have : sin (π / 2) = 1 ∨ sin (π / 2) = -1 := by simpa [sq, mul_self_eq_one_iff] using sin_sq_add_cos_sq (π / 2) this.resolve_right fun h => show ¬(0 : ℝ) < -1 by norm_num <| h ▸ sin_pos_of_pos_of_lt_pi pi_div_two_pos (half_lt_self pi_pos) #align real.sin_pi_div_two Real.sin_pi_div_two theorem sin_add_pi_div_two (x : ℝ) : sin (x + π / 2) = cos x := by simp [sin_add] #align real.sin_add_pi_div_two Real.sin_add_pi_div_two theorem sin_sub_pi_div_two (x : ℝ) : sin (x - π / 2) = -cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_sub_pi_div_two Real.sin_sub_pi_div_two theorem sin_pi_div_two_sub (x : ℝ) : sin (π / 2 - x) = cos x := by simp [sub_eq_add_neg, sin_add] #align real.sin_pi_div_two_sub Real.sin_pi_div_two_sub theorem cos_add_pi_div_two (x : ℝ) : cos (x + π / 2) = -sin x := by simp [cos_add] #align real.cos_add_pi_div_two Real.cos_add_pi_div_two theorem cos_sub_pi_div_two (x : ℝ) : cos (x - π / 2) = sin x := by simp [sub_eq_add_neg, cos_add] #align real.cos_sub_pi_div_two Real.cos_sub_pi_div_two theorem cos_pi_div_two_sub (x : ℝ) : cos (π / 2 - x) = sin x := by rw [← cos_neg, neg_sub, cos_sub_pi_div_two] #align real.cos_pi_div_two_sub Real.cos_pi_div_two_sub theorem cos_pos_of_mem_Ioo {x : ℝ} (hx : x ∈ Ioo (-(π / 2)) (π / 2)) : 0 < cos x := sin_add_pi_div_two x ▸ sin_pos_of_mem_Ioo ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_pos_of_mem_Ioo Real.cos_pos_of_mem_Ioo theorem cos_nonneg_of_mem_Icc {x : ℝ} (hx : x ∈ Icc (-(π / 2)) (π / 2)) : 0 ≤ cos x := sin_add_pi_div_two x ▸ sin_nonneg_of_mem_Icc ⟨by linarith [hx.1], by linarith [hx.2]⟩ #align real.cos_nonneg_of_mem_Icc Real.cos_nonneg_of_mem_Icc theorem cos_nonneg_of_neg_pi_div_two_le_of_le {x : ℝ} (hl : -(π / 2) ≤ x) (hu : x ≤ π / 2) : 0 ≤ cos x := cos_nonneg_of_mem_Icc ⟨hl, hu⟩ #align real.cos_nonneg_of_neg_pi_div_two_le_of_le Real.cos_nonneg_of_neg_pi_div_two_le_of_le theorem cos_neg_of_pi_div_two_lt_of_lt {x : ℝ} (hx₁ : π / 2 < x) (hx₂ : x < π + π / 2) : cos x < 0 := neg_pos.1 <| cos_pi_sub x ▸ cos_pos_of_mem_Ioo ⟨by linarith, by linarith⟩ #align real.cos_neg_of_pi_div_two_lt_of_lt Real.cos_neg_of_pi_div_two_lt_of_lt theorem cos_nonpos_of_pi_div_two_le_of_le {x : ℝ} (hx₁ : π / 2 ≤ x) (hx₂ : x ≤ π + π / 2) : cos x ≤ 0 := neg_nonneg.1 <| cos_pi_sub x ▸ cos_nonneg_of_mem_Icc ⟨by linarith, by linarith⟩ #align real.cos_nonpos_of_pi_div_two_le_of_le Real.cos_nonpos_of_pi_div_two_le_of_le theorem sin_eq_sqrt_one_sub_cos_sq {x : ℝ} (hl : 0 ≤ x) (hu : x ≤ π) : sin x = √(1 - cos x ^ 2) := by rw [← abs_sin_eq_sqrt_one_sub_cos_sq, abs_of_nonneg (sin_nonneg_of_nonneg_of_le_pi hl hu)] #align real.sin_eq_sqrt_one_sub_cos_sq Real.sin_eq_sqrt_one_sub_cos_sq theorem cos_eq_sqrt_one_sub_sin_sq {x : ℝ} (hl : -(π / 2) ≤ x) (hu : x ≤ π / 2) : cos x = √(1 - sin x ^ 2) := by rw [← abs_cos_eq_sqrt_one_sub_sin_sq, abs_of_nonneg (cos_nonneg_of_mem_Icc ⟨hl, hu⟩)] #align real.cos_eq_sqrt_one_sub_sin_sq Real.cos_eq_sqrt_one_sub_sin_sq lemma cos_half {x : ℝ} (hl : -π ≤ x) (hr : x ≤ π) : cos (x / 2) = sqrt ((1 + cos x) / 2) := by have : 0 ≤ cos (x / 2) := cos_nonneg_of_mem_Icc <| by constructor <;> linarith rw [← sqrt_sq this, cos_sq, add_div, two_mul, add_halves] lemma abs_sin_half (x : ℝ) : |sin (x / 2)| = sqrt ((1 - cos x) / 2) := by rw [← sqrt_sq_eq_abs, sin_sq_eq_half_sub, two_mul, add_halves, sub_div] lemma sin_half_eq_sqrt {x : ℝ} (hl : 0 ≤ x) (hr : x ≤ 2 * π) : sin (x / 2) = sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonneg] apply sin_nonneg_of_nonneg_of_le_pi <;> linarith lemma sin_half_eq_neg_sqrt {x : ℝ} (hl : -(2 * π) ≤ x) (hr : x ≤ 0) : sin (x / 2) = -sqrt ((1 - cos x) / 2) := by rw [← abs_sin_half, abs_of_nonpos, neg_neg] apply sin_nonpos_of_nonnpos_of_neg_pi_le <;> linarith theorem sin_eq_zero_iff_of_lt_of_lt {x : ℝ} (hx₁ : -π < x) (hx₂ : x < π) : sin x = 0 ↔ x = 0 := ⟨fun h => by contrapose! h cases h.lt_or_lt with | inl h0 => exact (sin_neg_of_neg_of_neg_pi_lt h0 hx₁).ne | inr h0 => exact (sin_pos_of_pos_of_lt_pi h0 hx₂).ne', fun h => by simp [h]⟩ #align real.sin_eq_zero_iff_of_lt_of_lt Real.sin_eq_zero_iff_of_lt_of_lt theorem sin_eq_zero_iff {x : ℝ} : sin x = 0 ↔ ∃ n : ℤ, (n : ℝ) * π = x := ⟨fun h => ⟨⌊x / π⌋, le_antisymm (sub_nonneg.1 (Int.sub_floor_div_mul_nonneg _ pi_pos)) (sub_nonpos.1 <| le_of_not_gt fun h₃ => (sin_pos_of_pos_of_lt_pi h₃ (Int.sub_floor_div_mul_lt _ pi_pos)).ne (by simp [sub_eq_add_neg, sin_add, h, sin_int_mul_pi]))⟩, fun ⟨n, hn⟩ => hn ▸ sin_int_mul_pi _⟩ #align real.sin_eq_zero_iff Real.sin_eq_zero_iff theorem sin_ne_zero_iff {x : ℝ} : sin x ≠ 0 ↔ ∀ n : ℤ, (n : ℝ) * π ≠ x := by rw [← not_exists, not_iff_not, sin_eq_zero_iff] #align real.sin_ne_zero_iff Real.sin_ne_zero_iff theorem sin_eq_zero_iff_cos_eq {x : ℝ} : sin x = 0 ↔ cos x = 1 ∨ cos x = -1 := by rw [← mul_self_eq_one_iff, ← sin_sq_add_cos_sq x, sq, sq, ← sub_eq_iff_eq_add, sub_self] exact ⟨fun h => by rw [h, mul_zero], eq_zero_of_mul_self_eq_zero ∘ Eq.symm⟩ #align real.sin_eq_zero_iff_cos_eq Real.sin_eq_zero_iff_cos_eq theorem cos_eq_one_iff (x : ℝ) : cos x = 1 ↔ ∃ n : ℤ, (n : ℝ) * (2 * π) = x := ⟨fun h => let ⟨n, hn⟩ := sin_eq_zero_iff.1 (sin_eq_zero_iff_cos_eq.2 (Or.inl h)) ⟨n / 2, (Int.emod_two_eq_zero_or_one n).elim (fun hn0 => by rwa [← mul_assoc, ← @Int.cast_two ℝ, ← Int.cast_mul, Int.ediv_mul_cancel ((Int.dvd_iff_emod_eq_zero _ _).2 hn0)]) fun hn1 => by rw [← Int.emod_add_ediv n 2, hn1, Int.cast_add, Int.cast_one, add_mul, one_mul, add_comm, mul_comm (2 : ℤ), Int.cast_mul, mul_assoc, Int.cast_two] at hn rw [← hn, cos_int_mul_two_pi_add_pi] at h exact absurd h (by norm_num)⟩, fun ⟨n, hn⟩ => hn ▸ cos_int_mul_two_pi _⟩ #align real.cos_eq_one_iff Real.cos_eq_one_iff theorem cos_eq_one_iff_of_lt_of_lt {x : ℝ} (hx₁ : -(2 * π) < x) (hx₂ : x < 2 * π) : cos x = 1 ↔ x = 0 := ⟨fun h => by rcases (cos_eq_one_iff _).1 h with ⟨n, rfl⟩ rw [mul_lt_iff_lt_one_left two_pi_pos] at hx₂ rw [neg_lt, neg_mul_eq_neg_mul, mul_lt_iff_lt_one_left two_pi_pos] at hx₁ norm_cast at hx₁ hx₂ obtain rfl : n = 0 := le_antisymm (by omega) (by omega) simp, fun h => by simp [h]⟩ #align real.cos_eq_one_iff_of_lt_of_lt Real.cos_eq_one_iff_of_lt_of_lt theorem sin_lt_sin_of_lt_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hy₂ : y ≤ π / 2) (hxy : x < y) : sin x < sin y := by rw [← sub_pos, sin_sub_sin] have : 0 < sin ((y - x) / 2) := by apply sin_pos_of_pos_of_lt_pi <;> linarith have : 0 < cos ((y + x) / 2) := by refine cos_pos_of_mem_Ioo ⟨?_, ?_⟩ <;> linarith positivity #align real.sin_lt_sin_of_lt_of_le_pi_div_two Real.sin_lt_sin_of_lt_of_le_pi_div_two theorem strictMonoOn_sin : StrictMonoOn sin (Icc (-(π / 2)) (π / 2)) := fun _ hx _ hy hxy => sin_lt_sin_of_lt_of_le_pi_div_two hx.1 hy.2 hxy #align real.strict_mono_on_sin Real.strictMonoOn_sin theorem cos_lt_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π) (hxy : x < y) : cos y < cos x := by rw [← sin_pi_div_two_sub, ← sin_pi_div_two_sub] apply sin_lt_sin_of_lt_of_le_pi_div_two <;> linarith #align real.cos_lt_cos_of_nonneg_of_le_pi Real.cos_lt_cos_of_nonneg_of_le_pi theorem cos_lt_cos_of_nonneg_of_le_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π / 2) (hxy : x < y) : cos y < cos x := cos_lt_cos_of_nonneg_of_le_pi hx₁ (hy₂.trans (by linarith)) hxy #align real.cos_lt_cos_of_nonneg_of_le_pi_div_two Real.cos_lt_cos_of_nonneg_of_le_pi_div_two theorem strictAntiOn_cos : StrictAntiOn cos (Icc 0 π) := fun _ hx _ hy hxy => cos_lt_cos_of_nonneg_of_le_pi hx.1 hy.2 hxy #align real.strict_anti_on_cos Real.strictAntiOn_cos theorem cos_le_cos_of_nonneg_of_le_pi {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y ≤ π) (hxy : x ≤ y) : cos y ≤ cos x := (strictAntiOn_cos.le_iff_le ⟨hx₁.trans hxy, hy₂⟩ ⟨hx₁, hxy.trans hy₂⟩).2 hxy #align real.cos_le_cos_of_nonneg_of_le_pi Real.cos_le_cos_of_nonneg_of_le_pi theorem sin_le_sin_of_le_of_le_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) ≤ x) (hy₂ : y ≤ π / 2) (hxy : x ≤ y) : sin x ≤ sin y := (strictMonoOn_sin.le_iff_le ⟨hx₁, hxy.trans hy₂⟩ ⟨hx₁.trans hxy, hy₂⟩).2 hxy #align real.sin_le_sin_of_le_of_le_pi_div_two Real.sin_le_sin_of_le_of_le_pi_div_two theorem injOn_sin : InjOn sin (Icc (-(π / 2)) (π / 2)) := strictMonoOn_sin.injOn #align real.inj_on_sin Real.injOn_sin theorem injOn_cos : InjOn cos (Icc 0 π) := strictAntiOn_cos.injOn #align real.inj_on_cos Real.injOn_cos theorem surjOn_sin : SurjOn sin (Icc (-(π / 2)) (π / 2)) (Icc (-1) 1) := by simpa only [sin_neg, sin_pi_div_two] using intermediate_value_Icc (neg_le_self pi_div_two_pos.le) continuous_sin.continuousOn #align real.surj_on_sin Real.surjOn_sin theorem surjOn_cos : SurjOn cos (Icc 0 π) (Icc (-1) 1) := by simpa only [cos_zero, cos_pi] using intermediate_value_Icc' pi_pos.le continuous_cos.continuousOn #align real.surj_on_cos Real.surjOn_cos theorem sin_mem_Icc (x : ℝ) : sin x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_sin x, sin_le_one x⟩ #align real.sin_mem_Icc Real.sin_mem_Icc theorem cos_mem_Icc (x : ℝ) : cos x ∈ Icc (-1 : ℝ) 1 := ⟨neg_one_le_cos x, cos_le_one x⟩ #align real.cos_mem_Icc Real.cos_mem_Icc theorem mapsTo_sin (s : Set ℝ) : MapsTo sin s (Icc (-1 : ℝ) 1) := fun x _ => sin_mem_Icc x #align real.maps_to_sin Real.mapsTo_sin theorem mapsTo_cos (s : Set ℝ) : MapsTo cos s (Icc (-1 : ℝ) 1) := fun x _ => cos_mem_Icc x #align real.maps_to_cos Real.mapsTo_cos theorem bijOn_sin : BijOn sin (Icc (-(π / 2)) (π / 2)) (Icc (-1) 1) := ⟨mapsTo_sin _, injOn_sin, surjOn_sin⟩ #align real.bij_on_sin Real.bijOn_sin theorem bijOn_cos : BijOn cos (Icc 0 π) (Icc (-1) 1) := ⟨mapsTo_cos _, injOn_cos, surjOn_cos⟩ #align real.bij_on_cos Real.bijOn_cos @[simp] theorem range_cos : range cos = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 cos_mem_Icc) surjOn_cos.subset_range #align real.range_cos Real.range_cos @[simp] theorem range_sin : range sin = (Icc (-1) 1 : Set ℝ) := Subset.antisymm (range_subset_iff.2 sin_mem_Icc) surjOn_sin.subset_range #align real.range_sin Real.range_sin theorem range_cos_infinite : (range Real.cos).Infinite := by rw [Real.range_cos] exact Icc_infinite (by norm_num) #align real.range_cos_infinite Real.range_cos_infinite theorem range_sin_infinite : (range Real.sin).Infinite := by rw [Real.range_sin] exact Icc_infinite (by norm_num) #align real.range_sin_infinite Real.range_sin_infinite section CosDivSq variable (x : ℝ) /-- the series `sqrtTwoAddSeries x n` is `sqrt(2 + sqrt(2 + ... ))` with `n` square roots, starting with `x`. We define it here because `cos (pi / 2 ^ (n+1)) = sqrtTwoAddSeries 0 n / 2` -/ @[simp] noncomputable def sqrtTwoAddSeries (x : ℝ) : ℕ → ℝ | 0 => x | n + 1 => √(2 + sqrtTwoAddSeries x n) #align real.sqrt_two_add_series Real.sqrtTwoAddSeries theorem sqrtTwoAddSeries_zero : sqrtTwoAddSeries x 0 = x := by simp #align real.sqrt_two_add_series_zero Real.sqrtTwoAddSeries_zero theorem sqrtTwoAddSeries_one : sqrtTwoAddSeries 0 1 = √2 := by simp #align real.sqrt_two_add_series_one Real.sqrtTwoAddSeries_one theorem sqrtTwoAddSeries_two : sqrtTwoAddSeries 0 2 = √(2 + √2) := by simp #align real.sqrt_two_add_series_two Real.sqrtTwoAddSeries_two theorem sqrtTwoAddSeries_zero_nonneg : ∀ n : ℕ, 0 ≤ sqrtTwoAddSeries 0 n | 0 => le_refl 0 | _ + 1 => sqrt_nonneg _ #align real.sqrt_two_add_series_zero_nonneg Real.sqrtTwoAddSeries_zero_nonneg theorem sqrtTwoAddSeries_nonneg {x : ℝ} (h : 0 ≤ x) : ∀ n : ℕ, 0 ≤ sqrtTwoAddSeries x n | 0 => h | _ + 1 => sqrt_nonneg _ #align real.sqrt_two_add_series_nonneg Real.sqrtTwoAddSeries_nonneg theorem sqrtTwoAddSeries_lt_two : ∀ n : ℕ, sqrtTwoAddSeries 0 n < 2 | 0 => by norm_num | n + 1 => by refine lt_of_lt_of_le ?_ (sqrt_sq zero_lt_two.le).le rw [sqrtTwoAddSeries, sqrt_lt_sqrt_iff, ← lt_sub_iff_add_lt'] · refine (sqrtTwoAddSeries_lt_two n).trans_le ?_ norm_num · exact add_nonneg zero_le_two (sqrtTwoAddSeries_zero_nonneg n) #align real.sqrt_two_add_series_lt_two Real.sqrtTwoAddSeries_lt_two theorem sqrtTwoAddSeries_succ (x : ℝ) : ∀ n : ℕ, sqrtTwoAddSeries x (n + 1) = sqrtTwoAddSeries (√(2 + x)) n | 0 => rfl | n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries_succ _ _, sqrtTwoAddSeries] #align real.sqrt_two_add_series_succ Real.sqrtTwoAddSeries_succ theorem sqrtTwoAddSeries_monotone_left {x y : ℝ} (h : x ≤ y) : ∀ n : ℕ, sqrtTwoAddSeries x n ≤ sqrtTwoAddSeries y n | 0 => h | n + 1 => by rw [sqrtTwoAddSeries, sqrtTwoAddSeries] exact sqrt_le_sqrt (add_le_add_left (sqrtTwoAddSeries_monotone_left h _) _) #align real.sqrt_two_add_series_monotone_left Real.sqrtTwoAddSeries_monotone_left @[simp] theorem cos_pi_over_two_pow : ∀ n : ℕ, cos (π / 2 ^ (n + 1)) = sqrtTwoAddSeries 0 n / 2 | 0 => by simp | n + 1 => by have A : (1 : ℝ) < 2 ^ (n + 1) := one_lt_pow one_lt_two n.succ_ne_zero have B : π / 2 ^ (n + 1) < π := div_lt_self pi_pos A have C : 0 < π / 2 ^ (n + 1) := by positivity rw [pow_succ, div_mul_eq_div_div, cos_half, cos_pi_over_two_pow n, sqrtTwoAddSeries, add_div_eq_mul_add_div, one_mul, ← div_mul_eq_div_div, sqrt_div, sqrt_mul_self] <;> linarith [sqrtTwoAddSeries_nonneg le_rfl n] #align real.cos_pi_over_two_pow Real.cos_pi_over_two_pow theorem sin_sq_pi_over_two_pow (n : ℕ) : sin (π / 2 ^ (n + 1)) ^ 2 = 1 - (sqrtTwoAddSeries 0 n / 2) ^ 2 := by rw [sin_sq, cos_pi_over_two_pow] #align real.sin_sq_pi_over_two_pow Real.sin_sq_pi_over_two_pow theorem sin_sq_pi_over_two_pow_succ (n : ℕ) : sin (π / 2 ^ (n + 2)) ^ 2 = 1 / 2 - sqrtTwoAddSeries 0 n / 4 := by rw [sin_sq_pi_over_two_pow, sqrtTwoAddSeries, div_pow, sq_sqrt, add_div, ← sub_sub] · congr · norm_num · norm_num · exact add_nonneg two_pos.le (sqrtTwoAddSeries_zero_nonneg _) #align real.sin_sq_pi_over_two_pow_succ Real.sin_sq_pi_over_two_pow_succ @[simp] theorem sin_pi_over_two_pow_succ (n : ℕ) : sin (π / 2 ^ (n + 2)) = √(2 - sqrtTwoAddSeries 0 n) / 2 := by rw [eq_div_iff_mul_eq two_ne_zero, eq_comm, sqrt_eq_iff_sq_eq, mul_pow, sin_sq_pi_over_two_pow_succ, sub_mul] · congr <;> norm_num · rw [sub_nonneg] exact (sqrtTwoAddSeries_lt_two _).le refine mul_nonneg (sin_nonneg_of_nonneg_of_le_pi ?_ ?_) zero_le_two · positivity · exact div_le_self pi_pos.le <| one_le_pow_of_one_le one_le_two _ #align real.sin_pi_over_two_pow_succ Real.sin_pi_over_two_pow_succ @[simp] theorem cos_pi_div_four : cos (π / 4) = √2 / 2 := by trans cos (π / 2 ^ 2) · congr norm_num · simp #align real.cos_pi_div_four Real.cos_pi_div_four @[simp] theorem sin_pi_div_four : sin (π / 4) = √2 / 2 := by trans sin (π / 2 ^ 2) · congr norm_num · simp #align real.sin_pi_div_four Real.sin_pi_div_four @[simp] theorem cos_pi_div_eight : cos (π / 8) = √(2 + √2) / 2 := by trans cos (π / 2 ^ 3) · congr norm_num · simp #align real.cos_pi_div_eight Real.cos_pi_div_eight @[simp] theorem sin_pi_div_eight : sin (π / 8) = √(2 - √2) / 2 := by trans sin (π / 2 ^ 3) · congr norm_num · simp #align real.sin_pi_div_eight Real.sin_pi_div_eight @[simp] theorem cos_pi_div_sixteen : cos (π / 16) = √(2 + √(2 + √2)) / 2 := by trans cos (π / 2 ^ 4) · congr norm_num · simp #align real.cos_pi_div_sixteen Real.cos_pi_div_sixteen @[simp] theorem sin_pi_div_sixteen : sin (π / 16) = √(2 - √(2 + √2)) / 2 := by trans sin (π / 2 ^ 4) · congr norm_num · simp #align real.sin_pi_div_sixteen Real.sin_pi_div_sixteen @[simp] theorem cos_pi_div_thirty_two : cos (π / 32) = √(2 + √(2 + √(2 + √2))) / 2 := by trans cos (π / 2 ^ 5) · congr norm_num · simp #align real.cos_pi_div_thirty_two Real.cos_pi_div_thirty_two @[simp] theorem sin_pi_div_thirty_two : sin (π / 32) = √(2 - √(2 + √(2 + √2))) / 2 := by trans sin (π / 2 ^ 5) · congr norm_num · simp #align real.sin_pi_div_thirty_two Real.sin_pi_div_thirty_two -- This section is also a convenient location for other explicit values of `sin` and `cos`. /-- The cosine of `π / 3` is `1 / 2`. -/ @[simp] theorem cos_pi_div_three : cos (π / 3) = 1 / 2 := by have h₁ : (2 * cos (π / 3) - 1) ^ 2 * (2 * cos (π / 3) + 2) = 0 := by have : cos (3 * (π / 3)) = cos π := by congr 1 ring linarith [cos_pi, cos_three_mul (π / 3)] cases' mul_eq_zero.mp h₁ with h h · linarith [pow_eq_zero h] · have : cos π < cos (π / 3) := by refine cos_lt_cos_of_nonneg_of_le_pi ?_ le_rfl ?_ <;> linarith [pi_pos] linarith [cos_pi] #align real.cos_pi_div_three Real.cos_pi_div_three /-- The cosine of `π / 6` is `√3 / 2`. -/ @[simp] theorem cos_pi_div_six : cos (π / 6) = √3 / 2 := by rw [show (6 : ℝ) = 3 * 2 by norm_num, div_mul_eq_div_div, cos_half, cos_pi_div_three, one_add_div, ← div_mul_eq_div_div, two_add_one_eq_three, sqrt_div, sqrt_mul_self] <;> linarith [pi_pos] #align real.cos_pi_div_six Real.cos_pi_div_six /-- The square of the cosine of `π / 6` is `3 / 4` (this is sometimes more convenient than the result for cosine itself). -/ theorem sq_cos_pi_div_six : cos (π / 6) ^ 2 = 3 / 4 := by rw [cos_pi_div_six, div_pow, sq_sqrt] <;> norm_num #align real.sq_cos_pi_div_six Real.sq_cos_pi_div_six /-- The sine of `π / 6` is `1 / 2`. -/ @[simp] theorem sin_pi_div_six : sin (π / 6) = 1 / 2 := by rw [← cos_pi_div_two_sub, ← cos_pi_div_three] congr ring #align real.sin_pi_div_six Real.sin_pi_div_six /-- The square of the sine of `π / 3` is `3 / 4` (this is sometimes more convenient than the result for cosine itself). -/ theorem sq_sin_pi_div_three : sin (π / 3) ^ 2 = 3 / 4 := by rw [← cos_pi_div_two_sub, ← sq_cos_pi_div_six] congr ring #align real.sq_sin_pi_div_three Real.sq_sin_pi_div_three /-- The sine of `π / 3` is `√3 / 2`. -/ @[simp] theorem sin_pi_div_three : sin (π / 3) = √3 / 2 := by rw [← cos_pi_div_two_sub, ← cos_pi_div_six] congr ring #align real.sin_pi_div_three Real.sin_pi_div_three end CosDivSq /-- `Real.sin` as an `OrderIso` between `[-(π / 2), π / 2]` and `[-1, 1]`. -/ def sinOrderIso : Icc (-(π / 2)) (π / 2) ≃o Icc (-1 : ℝ) 1 := (strictMonoOn_sin.orderIso _ _).trans <| OrderIso.setCongr _ _ bijOn_sin.image_eq #align real.sin_order_iso Real.sinOrderIso @[simp] theorem coe_sinOrderIso_apply (x : Icc (-(π / 2)) (π / 2)) : (sinOrderIso x : ℝ) = sin x := rfl #align real.coe_sin_order_iso_apply Real.coe_sinOrderIso_apply theorem sinOrderIso_apply (x : Icc (-(π / 2)) (π / 2)) : sinOrderIso x = ⟨sin x, sin_mem_Icc x⟩ := rfl #align real.sin_order_iso_apply Real.sinOrderIso_apply @[simp] theorem tan_pi_div_four : tan (π / 4) = 1 := by rw [tan_eq_sin_div_cos, cos_pi_div_four, sin_pi_div_four] have h : √2 / 2 > 0 := by positivity exact div_self (ne_of_gt h) #align real.tan_pi_div_four Real.tan_pi_div_four @[simp] theorem tan_pi_div_two : tan (π / 2) = 0 := by simp [tan_eq_sin_div_cos] #align real.tan_pi_div_two Real.tan_pi_div_two @[simp] theorem tan_pi_div_six : tan (π / 6) = 1 / sqrt 3 := by rw [tan_eq_sin_div_cos, sin_pi_div_six, cos_pi_div_six] ring @[simp] theorem tan_pi_div_three : tan (π / 3) = sqrt 3 := by rw [tan_eq_sin_div_cos, sin_pi_div_three, cos_pi_div_three] ring theorem tan_pos_of_pos_of_lt_pi_div_two {x : ℝ} (h0x : 0 < x) (hxp : x < π / 2) : 0 < tan x := by rw [tan_eq_sin_div_cos] exact div_pos (sin_pos_of_pos_of_lt_pi h0x (by linarith)) (cos_pos_of_mem_Ioo ⟨by linarith, hxp⟩) #align real.tan_pos_of_pos_of_lt_pi_div_two Real.tan_pos_of_pos_of_lt_pi_div_two theorem tan_nonneg_of_nonneg_of_le_pi_div_two {x : ℝ} (h0x : 0 ≤ x) (hxp : x ≤ π / 2) : 0 ≤ tan x := match lt_or_eq_of_le h0x, lt_or_eq_of_le hxp with | Or.inl hx0, Or.inl hxp => le_of_lt (tan_pos_of_pos_of_lt_pi_div_two hx0 hxp) | Or.inl _, Or.inr hxp => by simp [hxp, tan_eq_sin_div_cos] | Or.inr hx0, _ => by simp [hx0.symm] #align real.tan_nonneg_of_nonneg_of_le_pi_div_two Real.tan_nonneg_of_nonneg_of_le_pi_div_two theorem tan_neg_of_neg_of_pi_div_two_lt {x : ℝ} (hx0 : x < 0) (hpx : -(π / 2) < x) : tan x < 0 := neg_pos.1 (tan_neg x ▸ tan_pos_of_pos_of_lt_pi_div_two (by linarith) (by linarith [pi_pos])) #align real.tan_neg_of_neg_of_pi_div_two_lt Real.tan_neg_of_neg_of_pi_div_two_lt theorem tan_nonpos_of_nonpos_of_neg_pi_div_two_le {x : ℝ} (hx0 : x ≤ 0) (hpx : -(π / 2) ≤ x) : tan x ≤ 0 := neg_nonneg.1 (tan_neg x ▸ tan_nonneg_of_nonneg_of_le_pi_div_two (by linarith) (by linarith)) #align real.tan_nonpos_of_nonpos_of_neg_pi_div_two_le Real.tan_nonpos_of_nonpos_of_neg_pi_div_two_le theorem strictMonoOn_tan : StrictMonoOn tan (Ioo (-(π / 2)) (π / 2)) := by rintro x hx y hy hlt rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, div_lt_div_iff (cos_pos_of_mem_Ioo hx) (cos_pos_of_mem_Ioo hy), mul_comm, ← sub_pos, ← sin_sub] exact sin_pos_of_pos_of_lt_pi (sub_pos.2 hlt) <| by linarith [hx.1, hy.2] #align real.strict_mono_on_tan Real.strictMonoOn_tan theorem tan_lt_tan_of_lt_of_lt_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) < x) (hy₂ : y < π / 2) (hxy : x < y) : tan x < tan y := strictMonoOn_tan ⟨hx₁, hxy.trans hy₂⟩ ⟨hx₁.trans hxy, hy₂⟩ hxy #align real.tan_lt_tan_of_lt_of_lt_pi_div_two Real.tan_lt_tan_of_lt_of_lt_pi_div_two theorem tan_lt_tan_of_nonneg_of_lt_pi_div_two {x y : ℝ} (hx₁ : 0 ≤ x) (hy₂ : y < π / 2) (hxy : x < y) : tan x < tan y := tan_lt_tan_of_lt_of_lt_pi_div_two (by linarith) hy₂ hxy #align real.tan_lt_tan_of_nonneg_of_lt_pi_div_two Real.tan_lt_tan_of_nonneg_of_lt_pi_div_two theorem injOn_tan : InjOn tan (Ioo (-(π / 2)) (π / 2)) := strictMonoOn_tan.injOn #align real.inj_on_tan Real.injOn_tan theorem tan_inj_of_lt_of_lt_pi_div_two {x y : ℝ} (hx₁ : -(π / 2) < x) (hx₂ : x < π / 2) (hy₁ : -(π / 2) < y) (hy₂ : y < π / 2) (hxy : tan x = tan y) : x = y := injOn_tan ⟨hx₁, hx₂⟩ ⟨hy₁, hy₂⟩ hxy #align real.tan_inj_of_lt_of_lt_pi_div_two Real.tan_inj_of_lt_of_lt_pi_div_two theorem tan_periodic : Function.Periodic tan π := by simpa only [Function.Periodic, tan_eq_sin_div_cos] using sin_antiperiodic.div cos_antiperiodic #align real.tan_periodic Real.tan_periodic -- Porting note (#10756): added theorem @[simp] theorem tan_pi : tan π = 0 := by rw [tan_periodic.eq, tan_zero] theorem tan_add_pi (x : ℝ) : tan (x + π) = tan x := tan_periodic x #align real.tan_add_pi Real.tan_add_pi theorem tan_sub_pi (x : ℝ) : tan (x - π) = tan x := tan_periodic.sub_eq x #align real.tan_sub_pi Real.tan_sub_pi theorem tan_pi_sub (x : ℝ) : tan (π - x) = -tan x := tan_neg x ▸ tan_periodic.sub_eq' #align real.tan_pi_sub Real.tan_pi_sub theorem tan_pi_div_two_sub (x : ℝ) : tan (π / 2 - x) = (tan x)⁻¹ := by rw [tan_eq_sin_div_cos, tan_eq_sin_div_cos, inv_div, sin_pi_div_two_sub, cos_pi_div_two_sub] #align real.tan_pi_div_two_sub Real.tan_pi_div_two_sub theorem tan_nat_mul_pi (n : ℕ) : tan (n * π) = 0 := tan_zero ▸ tan_periodic.nat_mul_eq n #align real.tan_nat_mul_pi Real.tan_nat_mul_pi theorem tan_int_mul_pi (n : ℤ) : tan (n * π) = 0 := tan_zero ▸ tan_periodic.int_mul_eq n #align real.tan_int_mul_pi Real.tan_int_mul_pi theorem tan_add_nat_mul_pi (x : ℝ) (n : ℕ) : tan (x + n * π) = tan x := tan_periodic.nat_mul n x #align real.tan_add_nat_mul_pi Real.tan_add_nat_mul_pi theorem tan_add_int_mul_pi (x : ℝ) (n : ℤ) : tan (x + n * π) = tan x := tan_periodic.int_mul n x #align real.tan_add_int_mul_pi Real.tan_add_int_mul_pi theorem tan_sub_nat_mul_pi (x : ℝ) (n : ℕ) : tan (x - n * π) = tan x := tan_periodic.sub_nat_mul_eq n #align real.tan_sub_nat_mul_pi Real.tan_sub_nat_mul_pi theorem tan_sub_int_mul_pi (x : ℝ) (n : ℤ) : tan (x - n * π) = tan x := tan_periodic.sub_int_mul_eq n #align real.tan_sub_int_mul_pi Real.tan_sub_int_mul_pi theorem tan_nat_mul_pi_sub (x : ℝ) (n : ℕ) : tan (n * π - x) = -tan x := tan_neg x ▸ tan_periodic.nat_mul_sub_eq n #align real.tan_nat_mul_pi_sub Real.tan_nat_mul_pi_sub theorem tan_int_mul_pi_sub (x : ℝ) (n : ℤ) : tan (n * π - x) = -tan x := tan_neg x ▸ tan_periodic.int_mul_sub_eq n #align real.tan_int_mul_pi_sub Real.tan_int_mul_pi_sub theorem tendsto_sin_pi_div_two : Tendsto sin (𝓝[<] (π / 2)) (𝓝 1) := by convert continuous_sin.continuousWithinAt.tendsto simp #align real.tendsto_sin_pi_div_two Real.tendsto_sin_pi_div_two
Mathlib/Analysis/SpecialFunctions/Trigonometric/Basic.lean
1,080
1,085
theorem tendsto_cos_pi_div_two : Tendsto cos (𝓝[<] (π / 2)) (𝓝[>] 0) := by
apply tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within · convert continuous_cos.continuousWithinAt.tendsto simp · filter_upwards [Ioo_mem_nhdsWithin_Iio (right_mem_Ioc.mpr (neg_lt_self pi_div_two_pos))] with x hx using cos_pos_of_mem_Ioo hx
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ` We construct the power functions `x ^ y`, where `x` and `y` are real numbers. -/ noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set /- ## Definitions -/ namespace Real variable {x y z : ℝ} /-- The real power function `x ^ y`, defined as the real part of the complex power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for `y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/ noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast] theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n #align real.rpow_nat_cast Real.rpow_natCast @[deprecated (since := "2024-04-17")] alias rpow_nat_cast := rpow_natCast @[simp] theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul] #align real.exp_one_rpow Real.exp_one_rpow @[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow] theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [rpow_def_of_nonneg hx] split_ifs <;> simp [*, exp_ne_zero] #align real.rpow_eq_zero_iff_of_nonneg Real.rpow_eq_zero_iff_of_nonneg @[simp] lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [rpow_eq_zero_iff_of_nonneg, *] @[simp] lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 := Real.rpow_eq_zero hx hy |>.not open Real theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by rw [rpow_def, Complex.cpow_def, if_neg] · have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal, Complex.ofReal_mul] ring rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul, Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im, Real.log_neg_eq_log] ring · rw [Complex.ofReal_eq_zero] exact ne_of_lt hx #align real.rpow_def_of_neg Real.rpow_def_of_neg theorem rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * π) := by split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _ #align real.rpow_def_of_nonpos Real.rpow_def_of_nonpos theorem rpow_pos_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : 0 < x ^ y := by rw [rpow_def_of_pos hx]; apply exp_pos #align real.rpow_pos_of_pos Real.rpow_pos_of_pos @[simp] theorem rpow_zero (x : ℝ) : x ^ (0 : ℝ) = 1 := by simp [rpow_def] #align real.rpow_zero Real.rpow_zero theorem rpow_zero_pos (x : ℝ) : 0 < x ^ (0 : ℝ) := by simp @[simp] theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ) ^ x = 0 := by simp [rpow_def, *] #align real.zero_rpow Real.zero_rpow theorem zero_rpow_eq_iff {x : ℝ} {a : ℝ} : 0 ^ x = a ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by constructor · intro hyp simp only [rpow_def, Complex.ofReal_zero] at hyp by_cases h : x = 0 · subst h simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp exact Or.inr ⟨rfl, hyp.symm⟩ · rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp exact Or.inl ⟨h, hyp.symm⟩ · rintro (⟨h, rfl⟩ | ⟨rfl, rfl⟩) · exact zero_rpow h · exact rpow_zero _ #align real.zero_rpow_eq_iff Real.zero_rpow_eq_iff theorem eq_zero_rpow_iff {x : ℝ} {a : ℝ} : a = 0 ^ x ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by rw [← zero_rpow_eq_iff, eq_comm] #align real.eq_zero_rpow_iff Real.eq_zero_rpow_iff @[simp] theorem rpow_one (x : ℝ) : x ^ (1 : ℝ) = x := by simp [rpow_def] #align real.rpow_one Real.rpow_one @[simp] theorem one_rpow (x : ℝ) : (1 : ℝ) ^ x = 1 := by simp [rpow_def] #align real.one_rpow Real.one_rpow theorem zero_rpow_le_one (x : ℝ) : (0 : ℝ) ^ x ≤ 1 := by by_cases h : x = 0 <;> simp [h, zero_le_one] #align real.zero_rpow_le_one Real.zero_rpow_le_one theorem zero_rpow_nonneg (x : ℝ) : 0 ≤ (0 : ℝ) ^ x := by by_cases h : x = 0 <;> simp [h, zero_le_one] #align real.zero_rpow_nonneg Real.zero_rpow_nonneg theorem rpow_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : 0 ≤ x ^ y := by rw [rpow_def_of_nonneg hx]; split_ifs <;> simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)] #align real.rpow_nonneg_of_nonneg Real.rpow_nonneg theorem abs_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : |x ^ y| = |x| ^ y := by have h_rpow_nonneg : 0 ≤ x ^ y := Real.rpow_nonneg hx_nonneg _ rw [abs_eq_self.mpr hx_nonneg, abs_eq_self.mpr h_rpow_nonneg] #align real.abs_rpow_of_nonneg Real.abs_rpow_of_nonneg theorem abs_rpow_le_abs_rpow (x y : ℝ) : |x ^ y| ≤ |x| ^ y := by rcases le_or_lt 0 x with hx | hx · rw [abs_rpow_of_nonneg hx] · rw [abs_of_neg hx, rpow_def_of_neg hx, rpow_def_of_pos (neg_pos.2 hx), log_neg_eq_log, abs_mul, abs_of_pos (exp_pos _)] exact mul_le_of_le_one_right (exp_pos _).le (abs_cos_le_one _) #align real.abs_rpow_le_abs_rpow Real.abs_rpow_le_abs_rpow theorem abs_rpow_le_exp_log_mul (x y : ℝ) : |x ^ y| ≤ exp (log x * y) := by refine (abs_rpow_le_abs_rpow x y).trans ?_ by_cases hx : x = 0 · by_cases hy : y = 0 <;> simp [hx, hy, zero_le_one] · rw [rpow_def_of_pos (abs_pos.2 hx), log_abs] #align real.abs_rpow_le_exp_log_mul Real.abs_rpow_le_exp_log_mul theorem norm_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : ‖x ^ y‖ = ‖x‖ ^ y := by simp_rw [Real.norm_eq_abs] exact abs_rpow_of_nonneg hx_nonneg #align real.norm_rpow_of_nonneg Real.norm_rpow_of_nonneg variable {w x y z : ℝ} theorem rpow_add (hx : 0 < x) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := by simp only [rpow_def_of_pos hx, mul_add, exp_add] #align real.rpow_add Real.rpow_add theorem rpow_add' (hx : 0 ≤ x) (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := by rcases hx.eq_or_lt with (rfl | pos) · rw [zero_rpow h, zero_eq_mul] have : y ≠ 0 ∨ z ≠ 0 := not_and_or.1 fun ⟨hy, hz⟩ => h <| hy.symm ▸ hz.symm ▸ zero_add 0 exact this.imp zero_rpow zero_rpow · exact rpow_add pos _ _ #align real.rpow_add' Real.rpow_add' /-- Variant of `Real.rpow_add'` that avoids having to prove `y + z = w` twice. -/ lemma rpow_of_add_eq (hx : 0 ≤ x) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by rw [← h, rpow_add' hx]; rwa [h] theorem rpow_add_of_nonneg (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) : x ^ (y + z) = x ^ y * x ^ z := by rcases hy.eq_or_lt with (rfl | hy) · rw [zero_add, rpow_zero, one_mul] exact rpow_add' hx (ne_of_gt <| add_pos_of_pos_of_nonneg hy hz) #align real.rpow_add_of_nonneg Real.rpow_add_of_nonneg /-- For `0 ≤ x`, the only problematic case in the equality `x ^ y * x ^ z = x ^ (y + z)` is for `x = 0` and `y + z = 0`, where the right hand side is `1` while the left hand side can vanish. The inequality is always true, though, and given in this lemma. -/ theorem le_rpow_add {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ y * x ^ z ≤ x ^ (y + z) := by rcases le_iff_eq_or_lt.1 hx with (H | pos) · by_cases h : y + z = 0 · simp only [H.symm, h, rpow_zero] calc (0 : ℝ) ^ y * 0 ^ z ≤ 1 * 1 := mul_le_mul (zero_rpow_le_one y) (zero_rpow_le_one z) (zero_rpow_nonneg z) zero_le_one _ = 1 := by simp · simp [rpow_add', ← H, h] · simp [rpow_add pos] #align real.le_rpow_add Real.le_rpow_add theorem rpow_sum_of_pos {ι : Type*} {a : ℝ} (ha : 0 < a) (f : ι → ℝ) (s : Finset ι) : (a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x := map_sum (⟨⟨fun (x : ℝ) => (a ^ x : ℝ), rpow_zero a⟩, rpow_add ha⟩ : ℝ →+ (Additive ℝ)) f s #align real.rpow_sum_of_pos Real.rpow_sum_of_pos theorem rpow_sum_of_nonneg {ι : Type*} {a : ℝ} (ha : 0 ≤ a) {s : Finset ι} {f : ι → ℝ} (h : ∀ x ∈ s, 0 ≤ f x) : (a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x := by induction' s using Finset.cons_induction with i s hi ihs · rw [sum_empty, Finset.prod_empty, rpow_zero] · rw [forall_mem_cons] at h rw [sum_cons, prod_cons, ← ihs h.2, rpow_add_of_nonneg ha h.1 (sum_nonneg h.2)] #align real.rpow_sum_of_nonneg Real.rpow_sum_of_nonneg theorem rpow_neg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := by simp only [rpow_def_of_nonneg hx]; split_ifs <;> simp_all [exp_neg] #align real.rpow_neg Real.rpow_neg theorem rpow_sub {x : ℝ} (hx : 0 < x) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := by simp only [sub_eq_add_neg, rpow_add hx, rpow_neg (le_of_lt hx), div_eq_mul_inv] #align real.rpow_sub Real.rpow_sub theorem rpow_sub' {x : ℝ} (hx : 0 ≤ x) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := by simp only [sub_eq_add_neg] at h ⊢ simp only [rpow_add' hx h, rpow_neg hx, div_eq_mul_inv] #align real.rpow_sub' Real.rpow_sub' end Real /-! ## Comparing real and complex powers -/ namespace Complex theorem ofReal_cpow {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : ((x ^ y : ℝ) : ℂ) = (x : ℂ) ^ (y : ℂ) := by simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;> simp [Complex.ofReal_log hx] #align complex.of_real_cpow Complex.ofReal_cpow theorem ofReal_cpow_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℂ) : (x : ℂ) ^ y = (-x : ℂ) ^ y * exp (π * I * y) := by rcases hx.eq_or_lt with (rfl | hlt) · rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*] have hne : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr hlt.ne rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), ← exp_add, ← add_mul, log, log, abs.map_neg, arg_ofReal_of_neg hlt, ← ofReal_neg, arg_ofReal_of_nonneg (neg_nonneg.2 hx), ofReal_zero, zero_mul, add_zero] #align complex.of_real_cpow_of_nonpos Complex.ofReal_cpow_of_nonpos lemma cpow_ofReal (x : ℂ) (y : ℝ) : x ^ (y : ℂ) = ↑(abs x ^ y) * (Real.cos (arg x * y) + Real.sin (arg x * y) * I) := by rcases eq_or_ne x 0 with rfl | hx · simp [ofReal_cpow le_rfl] · rw [cpow_def_of_ne_zero hx, exp_eq_exp_re_mul_sin_add_cos, mul_comm (log x)] norm_cast rw [re_ofReal_mul, im_ofReal_mul, log_re, log_im, mul_comm y, mul_comm y, Real.exp_mul, Real.exp_log] rwa [abs.pos_iff] lemma cpow_ofReal_re (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).re = (abs x) ^ y * Real.cos (arg x * y) := by rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.cos] lemma cpow_ofReal_im (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).im = (abs x) ^ y * Real.sin (arg x * y) := by rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.sin] theorem abs_cpow_of_ne_zero {z : ℂ} (hz : z ≠ 0) (w : ℂ) : abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by rw [cpow_def_of_ne_zero hz, abs_exp, mul_re, log_re, log_im, Real.exp_sub, Real.rpow_def_of_pos (abs.pos hz)] #align complex.abs_cpow_of_ne_zero Complex.abs_cpow_of_ne_zero theorem abs_cpow_of_imp {z w : ℂ} (h : z = 0 → w.re = 0 → w = 0) : abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by rcases ne_or_eq z 0 with (hz | rfl) <;> [exact abs_cpow_of_ne_zero hz w; rw [map_zero]] rcases eq_or_ne w.re 0 with hw | hw · simp [hw, h rfl hw] · rw [Real.zero_rpow hw, zero_div, zero_cpow, map_zero] exact ne_of_apply_ne re hw #align complex.abs_cpow_of_imp Complex.abs_cpow_of_imp theorem abs_cpow_le (z w : ℂ) : abs (z ^ w) ≤ abs z ^ w.re / Real.exp (arg z * im w) := by by_cases h : z = 0 → w.re = 0 → w = 0 · exact (abs_cpow_of_imp h).le · push_neg at h simp [h] #align complex.abs_cpow_le Complex.abs_cpow_le @[simp] theorem abs_cpow_real (x : ℂ) (y : ℝ) : abs (x ^ (y : ℂ)) = Complex.abs x ^ y := by rw [abs_cpow_of_imp] <;> simp #align complex.abs_cpow_real Complex.abs_cpow_real @[simp] theorem abs_cpow_inv_nat (x : ℂ) (n : ℕ) : abs (x ^ (n⁻¹ : ℂ)) = Complex.abs x ^ (n⁻¹ : ℝ) := by rw [← abs_cpow_real]; simp [-abs_cpow_real] #align complex.abs_cpow_inv_nat Complex.abs_cpow_inv_nat theorem abs_cpow_eq_rpow_re_of_pos {x : ℝ} (hx : 0 < x) (y : ℂ) : abs (x ^ y) = x ^ y.re := by rw [abs_cpow_of_ne_zero (ofReal_ne_zero.mpr hx.ne'), arg_ofReal_of_nonneg hx.le, zero_mul, Real.exp_zero, div_one, abs_of_nonneg hx.le] #align complex.abs_cpow_eq_rpow_re_of_pos Complex.abs_cpow_eq_rpow_re_of_pos theorem abs_cpow_eq_rpow_re_of_nonneg {x : ℝ} (hx : 0 ≤ x) {y : ℂ} (hy : re y ≠ 0) : abs (x ^ y) = x ^ re y := by rw [abs_cpow_of_imp] <;> simp [*, arg_ofReal_of_nonneg, _root_.abs_of_nonneg] #align complex.abs_cpow_eq_rpow_re_of_nonneg Complex.abs_cpow_eq_rpow_re_of_nonneg lemma norm_natCast_cpow_of_re_ne_zero (n : ℕ) {s : ℂ} (hs : s.re ≠ 0) : ‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_nonneg n.cast_nonneg hs] lemma norm_natCast_cpow_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) : ‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_pos (Nat.cast_pos.mpr hn) _] lemma norm_natCast_cpow_pos_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) : 0 < ‖(n : ℂ) ^ s‖ := (norm_natCast_cpow_of_pos hn _).symm ▸ Real.rpow_pos_of_pos (Nat.cast_pos.mpr hn) _ theorem cpow_mul_ofReal_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) (z : ℂ) : (x : ℂ) ^ (↑y * z) = (↑(x ^ y) : ℂ) ^ z := by rw [cpow_mul, ofReal_cpow hx] · rw [← ofReal_log hx, ← ofReal_mul, ofReal_im, neg_lt_zero]; exact Real.pi_pos · rw [← ofReal_log hx, ← ofReal_mul, ofReal_im]; exact Real.pi_pos.le #align complex.cpow_mul_of_real_nonneg Complex.cpow_mul_ofReal_nonneg end Complex /-! ### Positivity extension -/ namespace Mathlib.Meta.Positivity open Lean Meta Qq /-- Extension for the `positivity` tactic: exponentiation by a real number is positive (namely 1) when the exponent is zero. The other cases are done in `evalRpow`. -/ @[positivity (_ : ℝ) ^ (0 : ℝ)] def evalRpowZero : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ℝ), ~q($a ^ (0 : ℝ)) => assertInstancesCommute pure (.positive q(Real.rpow_zero_pos $a)) | _, _, _ => throwError "not Real.rpow" /-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when the base is nonnegative and positive when the base is positive. -/ @[positivity (_ : ℝ) ^ (_ : ℝ)] def evalRpow : PositivityExt where eval {u α} _zα _pα e := do match u, α, e with | 0, ~q(ℝ), ~q($a ^ ($b : ℝ)) => let ra ← core q(inferInstance) q(inferInstance) a assertInstancesCommute match ra with | .positive pa => pure (.positive q(Real.rpow_pos_of_pos $pa $b)) | .nonnegative pa => pure (.nonnegative q(Real.rpow_nonneg $pa $b)) | _ => pure .none | _, _, _ => throwError "not Real.rpow" end Mathlib.Meta.Positivity /-! ## Further algebraic properties of `rpow` -/ namespace Real variable {x y z : ℝ} {n : ℕ} theorem rpow_mul {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := by rw [← Complex.ofReal_inj, Complex.ofReal_cpow (rpow_nonneg hx _), Complex.ofReal_cpow hx, Complex.ofReal_mul, Complex.cpow_mul, Complex.ofReal_cpow hx] <;> simp only [(Complex.ofReal_mul _ _).symm, (Complex.ofReal_log hx).symm, Complex.ofReal_im, neg_lt_zero, pi_pos, le_of_lt pi_pos] #align real.rpow_mul Real.rpow_mul theorem rpow_add_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℤ) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_def, rpow_def, Complex.ofReal_add, Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hx), Complex.ofReal_intCast, Complex.cpow_intCast, ← Complex.ofReal_zpow, mul_comm, Complex.re_ofReal_mul, mul_comm] #align real.rpow_add_int Real.rpow_add_int theorem rpow_add_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y + n) = x ^ y * x ^ n := by simpa using rpow_add_int hx y n #align real.rpow_add_nat Real.rpow_add_nat theorem rpow_sub_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by simpa using rpow_add_int hx y (-n) #align real.rpow_sub_int Real.rpow_sub_int theorem rpow_sub_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by simpa using rpow_sub_int hx y n #align real.rpow_sub_nat Real.rpow_sub_nat lemma rpow_add_int' (hx : 0 ≤ x) {n : ℤ} (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_add' hx h, rpow_intCast] lemma rpow_add_nat' (hx : 0 ≤ x) (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_add' hx h, rpow_natCast] lemma rpow_sub_int' (hx : 0 ≤ x) {n : ℤ} (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by rw [rpow_sub' hx h, rpow_intCast] lemma rpow_sub_nat' (hx : 0 ≤ x) (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by rw [rpow_sub' hx h, rpow_natCast] theorem rpow_add_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y + 1) = x ^ y * x := by simpa using rpow_add_nat hx y 1 #align real.rpow_add_one Real.rpow_add_one theorem rpow_sub_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y - 1) = x ^ y / x := by simpa using rpow_sub_nat hx y 1 #align real.rpow_sub_one Real.rpow_sub_one lemma rpow_add_one' (hx : 0 ≤ x) (h : y + 1 ≠ 0) : x ^ (y + 1) = x ^ y * x := by rw [rpow_add' hx h, rpow_one] lemma rpow_one_add' (hx : 0 ≤ x) (h : 1 + y ≠ 0) : x ^ (1 + y) = x * x ^ y := by rw [rpow_add' hx h, rpow_one] lemma rpow_sub_one' (hx : 0 ≤ x) (h : y - 1 ≠ 0) : x ^ (y - 1) = x ^ y / x := by rw [rpow_sub' hx h, rpow_one] lemma rpow_one_sub' (hx : 0 ≤ x) (h : 1 - y ≠ 0) : x ^ (1 - y) = x / x ^ y := by rw [rpow_sub' hx h, rpow_one] @[simp] theorem rpow_two (x : ℝ) : x ^ (2 : ℝ) = x ^ 2 := by rw [← rpow_natCast] simp only [Nat.cast_ofNat] #align real.rpow_two Real.rpow_two theorem rpow_neg_one (x : ℝ) : x ^ (-1 : ℝ) = x⁻¹ := by suffices H : x ^ ((-1 : ℤ) : ℝ) = x⁻¹ by rwa [Int.cast_neg, Int.cast_one] at H simp only [rpow_intCast, zpow_one, zpow_neg] #align real.rpow_neg_one Real.rpow_neg_one theorem mul_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) : (x * y) ^ z = x ^ z * y ^ z := by iterate 2 rw [Real.rpow_def_of_nonneg]; split_ifs with h_ifs <;> simp_all · rw [log_mul ‹_› ‹_›, add_mul, exp_add, rpow_def_of_pos (hy.lt_of_ne' ‹_›)] all_goals positivity #align real.mul_rpow Real.mul_rpow theorem inv_rpow (hx : 0 ≤ x) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ := by simp only [← rpow_neg_one, ← rpow_mul hx, mul_comm] #align real.inv_rpow Real.inv_rpow theorem div_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) (z : ℝ) : (x / y) ^ z = x ^ z / y ^ z := by simp only [div_eq_mul_inv, mul_rpow hx (inv_nonneg.2 hy), inv_rpow hy] #align real.div_rpow Real.div_rpow theorem log_rpow {x : ℝ} (hx : 0 < x) (y : ℝ) : log (x ^ y) = y * log x := by apply exp_injective rw [exp_log (rpow_pos_of_pos hx y), ← exp_log hx, mul_comm, rpow_def_of_pos (exp_pos (log x)) y] #align real.log_rpow Real.log_rpow theorem mul_log_eq_log_iff {x y z : ℝ} (hx : 0 < x) (hz : 0 < z) : y * log x = log z ↔ x ^ y = z := ⟨fun h ↦ log_injOn_pos (rpow_pos_of_pos hx _) hz <| log_rpow hx _ |>.trans h, by rintro rfl; rw [log_rpow hx]⟩ @[simp] lemma rpow_rpow_inv (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y) ^ y⁻¹ = x := by rw [← rpow_mul hx, mul_inv_cancel hy, rpow_one] @[simp] lemma rpow_inv_rpow (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y⁻¹) ^ y = x := by rw [← rpow_mul hx, inv_mul_cancel hy, rpow_one] theorem pow_rpow_inv_natCast (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ n) ^ (n⁻¹ : ℝ) = x := by have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn rw [← rpow_natCast, ← rpow_mul hx, mul_inv_cancel hn0, rpow_one] #align real.pow_nat_rpow_nat_inv Real.pow_rpow_inv_natCast theorem rpow_inv_natCast_pow (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ (n⁻¹ : ℝ)) ^ n = x := by have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn rw [← rpow_natCast, ← rpow_mul hx, inv_mul_cancel hn0, rpow_one] #align real.rpow_nat_inv_pow_nat Real.rpow_inv_natCast_pow lemma rpow_natCast_mul (hx : 0 ≤ x) (n : ℕ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by rw [rpow_mul hx, rpow_natCast] lemma rpow_mul_natCast (hx : 0 ≤ x) (y : ℝ) (n : ℕ) : x ^ (y * n) = (x ^ y) ^ n := by rw [rpow_mul hx, rpow_natCast] lemma rpow_intCast_mul (hx : 0 ≤ x) (n : ℤ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by rw [rpow_mul hx, rpow_intCast] lemma rpow_mul_intCast (hx : 0 ≤ x) (y : ℝ) (n : ℤ) : x ^ (y * n) = (x ^ y) ^ n := by rw [rpow_mul hx, rpow_intCast] /-! Note: lemmas about `(∏ i ∈ s, f i ^ r)` such as `Real.finset_prod_rpow` are proved in `Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean` instead. -/ /-! ## Order and monotonicity -/ @[gcongr] theorem rpow_lt_rpow (hx : 0 ≤ x) (hxy : x < y) (hz : 0 < z) : x ^ z < y ^ z := by rw [le_iff_eq_or_lt] at hx; cases' hx with hx hx · rw [← hx, zero_rpow (ne_of_gt hz)] exact rpow_pos_of_pos (by rwa [← hx] at hxy) _ · rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp] exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz #align real.rpow_lt_rpow Real.rpow_lt_rpow theorem strictMonoOn_rpow_Ici_of_exponent_pos {r : ℝ} (hr : 0 < r) : StrictMonoOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) := fun _ ha _ _ hab => rpow_lt_rpow ha hab hr @[gcongr] theorem rpow_le_rpow {x y z : ℝ} (h : 0 ≤ x) (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x ^ z ≤ y ^ z := by rcases eq_or_lt_of_le h₁ with (rfl | h₁'); · rfl rcases eq_or_lt_of_le h₂ with (rfl | h₂'); · simp exact le_of_lt (rpow_lt_rpow h h₁' h₂') #align real.rpow_le_rpow Real.rpow_le_rpow theorem monotoneOn_rpow_Ici_of_exponent_nonneg {r : ℝ} (hr : 0 ≤ r) : MonotoneOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) := fun _ ha _ _ hab => rpow_le_rpow ha hab hr lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z := by have := hx.trans hxy rw [← inv_lt_inv, ← rpow_neg, ← rpow_neg] on_goal 1 => refine rpow_lt_rpow ?_ hxy (neg_pos.2 hz) all_goals positivity lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x ≤ y) (hz : z ≤ 0) : y ^ z ≤ x ^ z := by have := hx.trans_le hxy rw [← inv_le_inv, ← rpow_neg, ← rpow_neg] on_goal 1 => refine rpow_le_rpow ?_ hxy (neg_nonneg.2 hz) all_goals positivity theorem rpow_lt_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z < y ^ z ↔ x < y := ⟨lt_imp_lt_of_le_imp_le fun h => rpow_le_rpow hy h (le_of_lt hz), fun h => rpow_lt_rpow hx h hz⟩ #align real.rpow_lt_rpow_iff Real.rpow_lt_rpow_iff theorem rpow_le_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z ≤ y ^ z ↔ x ≤ y := le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff hy hx hz #align real.rpow_le_rpow_iff Real.rpow_le_rpow_iff lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z ↔ y < x := ⟨lt_imp_lt_of_le_imp_le fun h ↦ rpow_le_rpow_of_nonpos hx h hz.le, fun h ↦ rpow_lt_rpow_of_neg hy h hz⟩ lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z ≤ y ^ z ↔ y ≤ x := le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff_of_neg hy hx hz lemma le_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ≤ y ^ z⁻¹ ↔ x ^ z ≤ y := by rw [← rpow_le_rpow_iff hx _ hz, rpow_inv_rpow] <;> positivity lemma rpow_inv_le_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ ≤ y ↔ x ≤ y ^ z := by rw [← rpow_le_rpow_iff _ hy hz, rpow_inv_rpow] <;> positivity lemma lt_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x < y ^ z⁻¹ ↔ x ^ z < y := lt_iff_lt_of_le_iff_le <| rpow_inv_le_iff_of_pos hy hx hz lemma rpow_inv_lt_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ < y ↔ x < y ^ z := lt_iff_lt_of_le_iff_le <| le_rpow_inv_iff_of_pos hy hx hz theorem le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ≤ y ^ z⁻¹ ↔ y ≤ x ^ z := by rw [← rpow_le_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.le_rpow_inv_iff_of_neg Real.le_rpow_inv_iff_of_neg theorem lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x < y ^ z⁻¹ ↔ y < x ^ z := by rw [← rpow_lt_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.lt_rpow_inv_iff_of_neg Real.lt_rpow_inv_iff_of_neg theorem rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z⁻¹ < y ↔ y ^ z < x := by rw [← rpow_lt_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.rpow_inv_lt_iff_of_neg Real.rpow_inv_lt_iff_of_neg theorem rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z⁻¹ ≤ y ↔ y ^ z ≤ x := by rw [← rpow_le_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.rpow_inv_le_iff_of_neg Real.rpow_inv_le_iff_of_neg theorem rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x ^ y < x ^ z := by repeat' rw [rpow_def_of_pos (lt_trans zero_lt_one hx)] rw [exp_lt_exp]; exact mul_lt_mul_of_pos_left hyz (log_pos hx) #align real.rpow_lt_rpow_of_exponent_lt Real.rpow_lt_rpow_of_exponent_lt @[gcongr] theorem rpow_le_rpow_of_exponent_le (hx : 1 ≤ x) (hyz : y ≤ z) : x ^ y ≤ x ^ z := by repeat' rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)] rw [exp_le_exp]; exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx) #align real.rpow_le_rpow_of_exponent_le Real.rpow_le_rpow_of_exponent_le theorem rpow_lt_rpow_of_exponent_neg {x y z : ℝ} (hy : 0 < y) (hxy : y < x) (hz : z < 0) : x ^ z < y ^ z := by have hx : 0 < x := hy.trans hxy rw [← neg_neg z, Real.rpow_neg (le_of_lt hx) (-z), Real.rpow_neg (le_of_lt hy) (-z), inv_lt_inv (rpow_pos_of_pos hx _) (rpow_pos_of_pos hy _)] exact Real.rpow_lt_rpow (by positivity) hxy <| neg_pos_of_neg hz theorem strictAntiOn_rpow_Ioi_of_exponent_neg {r : ℝ} (hr : r < 0) : StrictAntiOn (fun (x:ℝ) => x ^ r) (Set.Ioi 0) := fun _ ha _ _ hab => rpow_lt_rpow_of_exponent_neg ha hab hr theorem rpow_le_rpow_of_exponent_nonpos {x y : ℝ} (hy : 0 < y) (hxy : y ≤ x) (hz : z ≤ 0) : x ^ z ≤ y ^ z := by rcases ne_or_eq z 0 with hz_zero | rfl case inl => rcases ne_or_eq x y with hxy' | rfl case inl => exact le_of_lt <| rpow_lt_rpow_of_exponent_neg hy (Ne.lt_of_le (id (Ne.symm hxy')) hxy) (Ne.lt_of_le hz_zero hz) case inr => simp case inr => simp theorem antitoneOn_rpow_Ioi_of_exponent_nonpos {r : ℝ} (hr : r ≤ 0) : AntitoneOn (fun (x:ℝ) => x ^ r) (Set.Ioi 0) := fun _ ha _ _ hab => rpow_le_rpow_of_exponent_nonpos ha hab hr @[simp] theorem rpow_le_rpow_left_iff (hx : 1 < x) : x ^ y ≤ x ^ z ↔ y ≤ z := by have x_pos : 0 < x := lt_trans zero_lt_one hx rw [← log_le_log_iff (rpow_pos_of_pos x_pos y) (rpow_pos_of_pos x_pos z), log_rpow x_pos, log_rpow x_pos, mul_le_mul_right (log_pos hx)] #align real.rpow_le_rpow_left_iff Real.rpow_le_rpow_left_iff @[simp] theorem rpow_lt_rpow_left_iff (hx : 1 < x) : x ^ y < x ^ z ↔ y < z := by rw [lt_iff_not_le, rpow_le_rpow_left_iff hx, lt_iff_not_le] #align real.rpow_lt_rpow_left_iff Real.rpow_lt_rpow_left_iff theorem rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) : x ^ y < x ^ z := by repeat' rw [rpow_def_of_pos hx0] rw [exp_lt_exp]; exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1) #align real.rpow_lt_rpow_of_exponent_gt Real.rpow_lt_rpow_of_exponent_gt theorem rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x ≤ 1) (hyz : z ≤ y) : x ^ y ≤ x ^ z := by repeat' rw [rpow_def_of_pos hx0] rw [exp_le_exp]; exact mul_le_mul_of_nonpos_left hyz (log_nonpos (le_of_lt hx0) hx1) #align real.rpow_le_rpow_of_exponent_ge Real.rpow_le_rpow_of_exponent_ge @[simp] theorem rpow_le_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) : x ^ y ≤ x ^ z ↔ z ≤ y := by rw [← log_le_log_iff (rpow_pos_of_pos hx0 y) (rpow_pos_of_pos hx0 z), log_rpow hx0, log_rpow hx0, mul_le_mul_right_of_neg (log_neg hx0 hx1)] #align real.rpow_le_rpow_left_iff_of_base_lt_one Real.rpow_le_rpow_left_iff_of_base_lt_one @[simp] theorem rpow_lt_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) : x ^ y < x ^ z ↔ z < y := by rw [lt_iff_not_le, rpow_le_rpow_left_iff_of_base_lt_one hx0 hx1, lt_iff_not_le] #align real.rpow_lt_rpow_left_iff_of_base_lt_one Real.rpow_lt_rpow_left_iff_of_base_lt_one theorem rpow_lt_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x < 1) (hz : 0 < z) : x ^ z < 1 := by rw [← one_rpow z] exact rpow_lt_rpow hx1 hx2 hz #align real.rpow_lt_one Real.rpow_lt_one theorem rpow_le_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x ≤ 1) (hz : 0 ≤ z) : x ^ z ≤ 1 := by rw [← one_rpow z] exact rpow_le_rpow hx1 hx2 hz #align real.rpow_le_one Real.rpow_le_one theorem rpow_lt_one_of_one_lt_of_neg {x z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by convert rpow_lt_rpow_of_exponent_lt hx hz exact (rpow_zero x).symm #align real.rpow_lt_one_of_one_lt_of_neg Real.rpow_lt_one_of_one_lt_of_neg theorem rpow_le_one_of_one_le_of_nonpos {x z : ℝ} (hx : 1 ≤ x) (hz : z ≤ 0) : x ^ z ≤ 1 := by convert rpow_le_rpow_of_exponent_le hx hz exact (rpow_zero x).symm #align real.rpow_le_one_of_one_le_of_nonpos Real.rpow_le_one_of_one_le_of_nonpos theorem one_lt_rpow {x z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by rw [← one_rpow z] exact rpow_lt_rpow zero_le_one hx hz #align real.one_lt_rpow Real.one_lt_rpow theorem one_le_rpow {x z : ℝ} (hx : 1 ≤ x) (hz : 0 ≤ z) : 1 ≤ x ^ z := by rw [← one_rpow z] exact rpow_le_rpow zero_le_one hx hz #align real.one_le_rpow Real.one_le_rpow theorem one_lt_rpow_of_pos_of_lt_one_of_neg (hx1 : 0 < x) (hx2 : x < 1) (hz : z < 0) : 1 < x ^ z := by convert rpow_lt_rpow_of_exponent_gt hx1 hx2 hz exact (rpow_zero x).symm #align real.one_lt_rpow_of_pos_of_lt_one_of_neg Real.one_lt_rpow_of_pos_of_lt_one_of_neg theorem one_le_rpow_of_pos_of_le_one_of_nonpos (hx1 : 0 < x) (hx2 : x ≤ 1) (hz : z ≤ 0) : 1 ≤ x ^ z := by convert rpow_le_rpow_of_exponent_ge hx1 hx2 hz exact (rpow_zero x).symm #align real.one_le_rpow_of_pos_of_le_one_of_nonpos Real.one_le_rpow_of_pos_of_le_one_of_nonpos theorem rpow_lt_one_iff_of_pos (hx : 0 < x) : x ^ y < 1 ↔ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by rw [rpow_def_of_pos hx, exp_lt_one_iff, mul_neg_iff, log_pos_iff hx, log_neg_iff hx] #align real.rpow_lt_one_iff_of_pos Real.rpow_lt_one_iff_of_pos theorem rpow_lt_one_iff (hx : 0 ≤ x) : x ^ y < 1 ↔ x = 0 ∧ y ≠ 0 ∨ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by rcases hx.eq_or_lt with (rfl | hx) · rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, lt_irrefl, zero_lt_one] · simp [rpow_lt_one_iff_of_pos hx, hx.ne.symm] #align real.rpow_lt_one_iff Real.rpow_lt_one_iff theorem rpow_lt_one_iff' {x y : ℝ} (hx : 0 ≤ x) (hy : 0 < y) : x ^ y < 1 ↔ x < 1 := by rw [← Real.rpow_lt_rpow_iff hx zero_le_one hy, Real.one_rpow] theorem one_lt_rpow_iff_of_pos (hx : 0 < x) : 1 < x ^ y ↔ 1 < x ∧ 0 < y ∨ x < 1 ∧ y < 0 := by rw [rpow_def_of_pos hx, one_lt_exp_iff, mul_pos_iff, log_pos_iff hx, log_neg_iff hx] #align real.one_lt_rpow_iff_of_pos Real.one_lt_rpow_iff_of_pos
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
754
757
theorem one_lt_rpow_iff (hx : 0 ≤ x) : 1 < x ^ y ↔ 1 < x ∧ 0 < y ∨ 0 < x ∧ x < 1 ∧ y < 0 := by
rcases hx.eq_or_lt with (rfl | hx) · rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, lt_irrefl, (zero_lt_one' ℝ).not_lt] · simp [one_lt_rpow_iff_of_pos hx, hx]
/- Copyright (c) 2020 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov, Patrick Massot, Eric Wieser, Yaël Dillies -/ import Mathlib.Analysis.NormedSpace.Basic import Mathlib.Topology.Algebra.Module.Basic #align_import analysis.normed_space.basic from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156" /-! # Basic facts about real (semi)normed spaces In this file we prove some theorems about (semi)normed spaces over real numberes. ## Main results - `closure_ball`, `frontier_ball`, `interior_closedBall`, `frontier_closedBall`, `interior_sphere`, `frontier_sphere`: formulas for the closure/interior/frontier of nontrivial balls and spheres in a real seminormed space; - `interior_closedBall'`, `frontier_closedBall'`, `interior_sphere'`, `frontier_sphere'`: similar lemmas assuming that the ambient space is separated and nontrivial instead of `r ≠ 0`. -/ open Metric Set Function Filter open scoped NNReal Topology /-- If `E` is a nontrivial topological module over `ℝ`, then `E` has no isolated points. This is a particular case of `Module.punctured_nhds_neBot`. -/ instance Real.punctured_nhds_module_neBot {E : Type*} [AddCommGroup E] [TopologicalSpace E] [ContinuousAdd E] [Nontrivial E] [Module ℝ E] [ContinuousSMul ℝ E] (x : E) : NeBot (𝓝[≠] x) := Module.punctured_nhds_neBot ℝ E x #align real.punctured_nhds_module_ne_bot Real.punctured_nhds_module_neBot section Seminormed variable {E : Type*} [SeminormedAddCommGroup E] [NormedSpace ℝ E] theorem inv_norm_smul_mem_closed_unit_ball (x : E) : ‖x‖⁻¹ • x ∈ closedBall (0 : E) 1 := by simp only [mem_closedBall_zero_iff, norm_smul, norm_inv, norm_norm, ← div_eq_inv_mul, div_self_le_one] #align inv_norm_smul_mem_closed_unit_ball inv_norm_smul_mem_closed_unit_ball theorem norm_smul_of_nonneg {t : ℝ} (ht : 0 ≤ t) (x : E) : ‖t • x‖ = t * ‖x‖ := by rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ht] #align norm_smul_of_nonneg norm_smul_of_nonneg theorem dist_smul_add_one_sub_smul_le {r : ℝ} {x y : E} (h : r ∈ Icc 0 1) : dist (r • x + (1 - r) • y) x ≤ dist y x := calc dist (r • x + (1 - r) • y) x = ‖1 - r‖ * ‖x - y‖ := by simp_rw [dist_eq_norm', ← norm_smul, sub_smul, one_smul, smul_sub, ← sub_sub, ← sub_add, sub_right_comm] _ = (1 - r) * dist y x := by rw [Real.norm_eq_abs, abs_eq_self.mpr (sub_nonneg.mpr h.2), dist_eq_norm'] _ ≤ (1 - 0) * dist y x := by gcongr; exact h.1 _ = dist y x := by rw [sub_zero, one_mul] theorem closure_ball (x : E) {r : ℝ} (hr : r ≠ 0) : closure (ball x r) = closedBall x r := by refine Subset.antisymm closure_ball_subset_closedBall fun y hy => ?_ have : ContinuousWithinAt (fun c : ℝ => c • (y - x) + x) (Ico 0 1) 1 := ((continuous_id.smul continuous_const).add continuous_const).continuousWithinAt convert this.mem_closure _ _ · rw [one_smul, sub_add_cancel] · simp [closure_Ico zero_ne_one, zero_le_one] · rintro c ⟨hc0, hc1⟩ rw [mem_ball, dist_eq_norm, add_sub_cancel_right, norm_smul, Real.norm_eq_abs, abs_of_nonneg hc0, mul_comm, ← mul_one r] rw [mem_closedBall, dist_eq_norm] at hy replace hr : 0 < r := ((norm_nonneg _).trans hy).lt_of_ne hr.symm apply mul_lt_mul' <;> assumption #align closure_ball closure_ball theorem frontier_ball (x : E) {r : ℝ} (hr : r ≠ 0) : frontier (ball x r) = sphere x r := by rw [frontier, closure_ball x hr, isOpen_ball.interior_eq, closedBall_diff_ball] #align frontier_ball frontier_ball theorem interior_closedBall (x : E) {r : ℝ} (hr : r ≠ 0) : interior (closedBall x r) = ball x r := by cases' hr.lt_or_lt with hr hr · rw [closedBall_eq_empty.2 hr, ball_eq_empty.2 hr.le, interior_empty] refine Subset.antisymm ?_ ball_subset_interior_closedBall intro y hy rcases (mem_closedBall.1 <| interior_subset hy).lt_or_eq with (hr | rfl) · exact hr set f : ℝ → E := fun c : ℝ => c • (y - x) + x suffices f ⁻¹' closedBall x (dist y x) ⊆ Icc (-1) 1 by have hfc : Continuous f := (continuous_id.smul continuous_const).add continuous_const have hf1 : (1 : ℝ) ∈ f ⁻¹' interior (closedBall x <| dist y x) := by simpa [f] have h1 : (1 : ℝ) ∈ interior (Icc (-1 : ℝ) 1) := interior_mono this (preimage_interior_subset_interior_preimage hfc hf1) simp at h1 intro c hc rw [mem_Icc, ← abs_le, ← Real.norm_eq_abs, ← mul_le_mul_right hr] simpa [f, dist_eq_norm, norm_smul] using hc #align interior_closed_ball interior_closedBall
Mathlib/Analysis/NormedSpace/Real.lean
101
103
theorem frontier_closedBall (x : E) {r : ℝ} (hr : r ≠ 0) : frontier (closedBall x r) = sphere x r := by
rw [frontier, closure_closedBall, interior_closedBall x hr, closedBall_diff_ball]
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Measure.Sub import Mathlib.MeasureTheory.Decomposition.SignedHahn import Mathlib.MeasureTheory.Function.AEEqOfIntegral #align_import measure_theory.decomposition.lebesgue from "leanprover-community/mathlib"@"b2ff9a3d7a15fd5b0f060b135421d6a89a999c2f" /-! # Lebesgue decomposition This file proves the Lebesgue decomposition theorem. The Lebesgue decomposition theorem states that, given two σ-finite measures `μ` and `ν`, there exists a σ-finite measure `ξ` and a measurable function `f` such that `μ = ξ + fν` and `ξ` is mutually singular with respect to `ν`. The Lebesgue decomposition provides the Radon-Nikodym theorem readily. ## Main definitions * `MeasureTheory.Measure.HaveLebesgueDecomposition` : A pair of measures `μ` and `ν` is said to `HaveLebesgueDecomposition` if there exist a measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f` * `MeasureTheory.Measure.singularPart` : If a pair of measures `HaveLebesgueDecomposition`, then `singularPart` chooses the measure from `HaveLebesgueDecomposition`, otherwise it returns the zero measure. * `MeasureTheory.Measure.rnDeriv`: If a pair of measures `HaveLebesgueDecomposition`, then `rnDeriv` chooses the measurable function from `HaveLebesgueDecomposition`, otherwise it returns the zero function. ## Main results * `MeasureTheory.Measure.haveLebesgueDecomposition_of_sigmaFinite` : the Lebesgue decomposition theorem. * `MeasureTheory.Measure.eq_singularPart` : Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `s = μ.singularPart ν`. * `MeasureTheory.Measure.eq_rnDeriv` : Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `f = μ.rnDeriv ν`. ## Tags Lebesgue decomposition theorem -/ open scoped MeasureTheory NNReal ENNReal open Set namespace MeasureTheory namespace Measure variable {α β : Type*} {m : MeasurableSpace α} {μ ν : Measure α} /-- A pair of measures `μ` and `ν` is said to `HaveLebesgueDecomposition` if there exists a measure `ξ` and a measurable function `f`, such that `ξ` is mutually singular with respect to `ν` and `μ = ξ + ν.withDensity f`. -/ class HaveLebesgueDecomposition (μ ν : Measure α) : Prop where lebesgue_decomposition : ∃ p : Measure α × (α → ℝ≥0∞), Measurable p.2 ∧ p.1 ⟂ₘ ν ∧ μ = p.1 + ν.withDensity p.2 #align measure_theory.measure.have_lebesgue_decomposition MeasureTheory.Measure.HaveLebesgueDecomposition #align measure_theory.measure.have_lebesgue_decomposition.lebesgue_decomposition MeasureTheory.Measure.HaveLebesgueDecomposition.lebesgue_decomposition open Classical in /-- If a pair of measures `HaveLebesgueDecomposition`, then `singularPart` chooses the measure from `HaveLebesgueDecomposition`, otherwise it returns the zero measure. For sigma-finite measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/ noncomputable irreducible_def singularPart (μ ν : Measure α) : Measure α := if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).1 else 0 #align measure_theory.measure.singular_part MeasureTheory.Measure.singularPart open Classical in /-- If a pair of measures `HaveLebesgueDecomposition`, then `rnDeriv` chooses the measurable function from `HaveLebesgueDecomposition`, otherwise it returns the zero function. For sigma-finite measures, `μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν)`. -/ noncomputable irreducible_def rnDeriv (μ ν : Measure α) : α → ℝ≥0∞ := if h : HaveLebesgueDecomposition μ ν then (Classical.choose h.lebesgue_decomposition).2 else 0 #align measure_theory.measure.rn_deriv MeasureTheory.Measure.rnDeriv section ByDefinition theorem haveLebesgueDecomposition_spec (μ ν : Measure α) [h : HaveLebesgueDecomposition μ ν] : Measurable (μ.rnDeriv ν) ∧ μ.singularPart ν ⟂ₘ ν ∧ μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) := by rw [singularPart, rnDeriv, dif_pos h, dif_pos h] exact Classical.choose_spec h.lebesgue_decomposition #align measure_theory.measure.have_lebesgue_decomposition_spec MeasureTheory.Measure.haveLebesgueDecomposition_spec lemma rnDeriv_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) : μ.rnDeriv ν = 0 := by rw [rnDeriv, dif_neg h] lemma singularPart_of_not_haveLebesgueDecomposition (h : ¬ HaveLebesgueDecomposition μ ν) : μ.singularPart ν = 0 := by rw [singularPart, dif_neg h] @[measurability] theorem measurable_rnDeriv (μ ν : Measure α) : Measurable <| μ.rnDeriv ν := by by_cases h : HaveLebesgueDecomposition μ ν · exact (haveLebesgueDecomposition_spec μ ν).1 · rw [rnDeriv_of_not_haveLebesgueDecomposition h] exact measurable_zero #align measure_theory.measure.measurable_rn_deriv MeasureTheory.Measure.measurable_rnDeriv theorem mutuallySingular_singularPart (μ ν : Measure α) : μ.singularPart ν ⟂ₘ ν := by by_cases h : HaveLebesgueDecomposition μ ν · exact (haveLebesgueDecomposition_spec μ ν).2.1 · rw [singularPart_of_not_haveLebesgueDecomposition h] exact MutuallySingular.zero_left #align measure_theory.measure.mutually_singular_singular_part MeasureTheory.Measure.mutuallySingular_singularPart theorem haveLebesgueDecomposition_add (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] : μ = μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) := (haveLebesgueDecomposition_spec μ ν).2.2 #align measure_theory.measure.have_lebesgue_decomposition_add MeasureTheory.Measure.haveLebesgueDecomposition_add lemma singularPart_add_rnDeriv (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] : μ.singularPart ν + ν.withDensity (μ.rnDeriv ν) = μ := (haveLebesgueDecomposition_add μ ν).symm lemma rnDeriv_add_singularPart (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] : ν.withDensity (μ.rnDeriv ν) + μ.singularPart ν = μ := by rw [add_comm, singularPart_add_rnDeriv] end ByDefinition section HaveLebesgueDecomposition instance instHaveLebesgueDecompositionZeroLeft : HaveLebesgueDecomposition 0 ν where lebesgue_decomposition := ⟨⟨0, 0⟩, measurable_zero, MutuallySingular.zero_left, by simp⟩ instance instHaveLebesgueDecompositionZeroRight : HaveLebesgueDecomposition μ 0 where lebesgue_decomposition := ⟨⟨μ, 0⟩, measurable_zero, MutuallySingular.zero_right, by simp⟩ instance instHaveLebesgueDecompositionSelf : HaveLebesgueDecomposition μ μ where lebesgue_decomposition := ⟨⟨0, 1⟩, measurable_const, MutuallySingular.zero_left, by simp⟩ instance haveLebesgueDecompositionSMul' (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (r : ℝ≥0∞) : (r • μ).HaveLebesgueDecomposition ν where lebesgue_decomposition := by obtain ⟨hmeas, hsing, hadd⟩ := haveLebesgueDecomposition_spec μ ν refine ⟨⟨r • μ.singularPart ν, r • μ.rnDeriv ν⟩, hmeas.const_smul _, hsing.smul _, ?_⟩ simp only [ENNReal.smul_def] rw [withDensity_smul _ hmeas, ← smul_add, ← hadd] instance haveLebesgueDecompositionSMul (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (r : ℝ≥0) : (r • μ).HaveLebesgueDecomposition ν := by rw [ENNReal.smul_def]; infer_instance #align measure_theory.measure.have_lebesgue_decomposition_smul MeasureTheory.Measure.haveLebesgueDecompositionSMul instance haveLebesgueDecompositionSMulRight (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] (r : ℝ≥0) : μ.HaveLebesgueDecomposition (r • ν) where lebesgue_decomposition := by obtain ⟨hmeas, hsing, hadd⟩ := haveLebesgueDecomposition_spec μ ν by_cases hr : r = 0 · exact ⟨⟨μ, 0⟩, measurable_const, by simp [hr], by simp⟩ refine ⟨⟨μ.singularPart ν, r⁻¹ • μ.rnDeriv ν⟩, hmeas.const_smul _, hsing.mono_ac AbsolutelyContinuous.rfl smul_absolutelyContinuous, ?_⟩ have : r⁻¹ • rnDeriv μ ν = ((r⁻¹ : ℝ≥0) : ℝ≥0∞) • rnDeriv μ ν := by simp [ENNReal.smul_def] rw [this, withDensity_smul _ hmeas, ENNReal.smul_def r, withDensity_smul_measure, ← smul_assoc, smul_eq_mul, ENNReal.coe_inv hr, ENNReal.inv_mul_cancel, one_smul] · exact hadd · simp [hr] · exact ENNReal.coe_ne_top theorem haveLebesgueDecomposition_withDensity (μ : Measure α) {f : α → ℝ≥0∞} (hf : Measurable f) : (μ.withDensity f).HaveLebesgueDecomposition μ := ⟨⟨⟨0, f⟩, hf, .zero_left, (zero_add _).symm⟩⟩ instance haveLebesgueDecompositionRnDeriv (μ ν : Measure α) : HaveLebesgueDecomposition (ν.withDensity (μ.rnDeriv ν)) ν := haveLebesgueDecomposition_withDensity ν (measurable_rnDeriv _ _) instance instHaveLebesgueDecompositionSingularPart : HaveLebesgueDecomposition (μ.singularPart ν) ν := ⟨⟨μ.singularPart ν, 0⟩, measurable_zero, mutuallySingular_singularPart μ ν, by simp⟩ end HaveLebesgueDecomposition theorem singularPart_le (μ ν : Measure α) : μ.singularPart ν ≤ μ := by by_cases hl : HaveLebesgueDecomposition μ ν · conv_rhs => rw [haveLebesgueDecomposition_add μ ν] exact Measure.le_add_right le_rfl · rw [singularPart, dif_neg hl] exact Measure.zero_le μ #align measure_theory.measure.singular_part_le MeasureTheory.Measure.singularPart_le theorem withDensity_rnDeriv_le (μ ν : Measure α) : ν.withDensity (μ.rnDeriv ν) ≤ μ := by by_cases hl : HaveLebesgueDecomposition μ ν · conv_rhs => rw [haveLebesgueDecomposition_add μ ν] exact Measure.le_add_left le_rfl · rw [rnDeriv, dif_neg hl, withDensity_zero] exact Measure.zero_le μ #align measure_theory.measure.with_density_rn_deriv_le MeasureTheory.Measure.withDensity_rnDeriv_le lemma _root_.AEMeasurable.singularPart {β : Type*} {_ : MeasurableSpace β} {f : α → β} (hf : AEMeasurable f μ) (ν : Measure α) : AEMeasurable f (μ.singularPart ν) := AEMeasurable.mono_measure hf (Measure.singularPart_le _ _) lemma _root_.AEMeasurable.withDensity_rnDeriv {β : Type*} {_ : MeasurableSpace β} {f : α → β} (hf : AEMeasurable f μ) (ν : Measure α) : AEMeasurable f (ν.withDensity (μ.rnDeriv ν)) := AEMeasurable.mono_measure hf (Measure.withDensity_rnDeriv_le _ _) lemma MutuallySingular.singularPart (h : μ ⟂ₘ ν) (ν' : Measure α) : μ.singularPart ν' ⟂ₘ ν := h.mono (singularPart_le μ ν') le_rfl lemma absolutelyContinuous_withDensity_rnDeriv [HaveLebesgueDecomposition ν μ] (hμν : μ ≪ ν) : μ ≪ μ.withDensity (ν.rnDeriv μ) := by rw [haveLebesgueDecomposition_add ν μ] at hμν refine AbsolutelyContinuous.mk (fun s _ hνs ↦ ?_) obtain ⟨t, _, ht1, ht2⟩ := mutuallySingular_singularPart ν μ rw [← inter_union_compl s] refine le_antisymm ((measure_union_le (s ∩ t) (s ∩ tᶜ)).trans ?_) (zero_le _) simp only [nonpos_iff_eq_zero, add_eq_zero] constructor · refine hμν ?_ simp only [coe_add, Pi.add_apply, add_eq_zero] constructor · exact measure_mono_null Set.inter_subset_right ht1 · exact measure_mono_null Set.inter_subset_left hνs · exact measure_mono_null Set.inter_subset_right ht2 lemma singularPart_eq_zero_of_ac (h : μ ≪ ν) : μ.singularPart ν = 0 := by rw [← MutuallySingular.self_iff] exact MutuallySingular.mono_ac (mutuallySingular_singularPart _ _) AbsolutelyContinuous.rfl ((absolutelyContinuous_of_le (singularPart_le _ _)).trans h) @[simp] theorem singularPart_zero (ν : Measure α) : (0 : Measure α).singularPart ν = 0 := singularPart_eq_zero_of_ac (AbsolutelyContinuous.zero _) #align measure_theory.measure.singular_part_zero MeasureTheory.Measure.singularPart_zero @[simp] lemma singularPart_zero_right (μ : Measure α) : μ.singularPart 0 = μ := by conv_rhs => rw [haveLebesgueDecomposition_add μ 0] simp lemma singularPart_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] : μ.singularPart ν = 0 ↔ μ ≪ ν := by have h_dec := haveLebesgueDecomposition_add μ ν refine ⟨fun h ↦ ?_, singularPart_eq_zero_of_ac⟩ rw [h, zero_add] at h_dec rw [h_dec] exact withDensity_absolutelyContinuous ν _ @[simp] lemma withDensity_rnDeriv_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] : ν.withDensity (μ.rnDeriv ν) = 0 ↔ μ ⟂ₘ ν := by have h_dec := haveLebesgueDecomposition_add μ ν refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · rw [h, add_zero] at h_dec rw [h_dec] exact mutuallySingular_singularPart μ ν · rw [← MutuallySingular.self_iff] rw [h_dec, MutuallySingular.add_left_iff] at h refine MutuallySingular.mono_ac h.2 AbsolutelyContinuous.rfl ?_ exact withDensity_absolutelyContinuous _ _ @[simp] lemma rnDeriv_eq_zero (μ ν : Measure α) [μ.HaveLebesgueDecomposition ν] : μ.rnDeriv ν =ᵐ[ν] 0 ↔ μ ⟂ₘ ν := by rw [← withDensity_rnDeriv_eq_zero, withDensity_eq_zero_iff (measurable_rnDeriv _ _).aemeasurable] lemma rnDeriv_zero (ν : Measure α) : (0 : Measure α).rnDeriv ν =ᵐ[ν] 0 := by rw [rnDeriv_eq_zero] exact MutuallySingular.zero_left lemma MutuallySingular.rnDeriv_ae_eq_zero (hμν : μ ⟂ₘ ν) : μ.rnDeriv ν =ᵐ[ν] 0 := by by_cases h : μ.HaveLebesgueDecomposition ν · rw [rnDeriv_eq_zero] exact hμν · rw [rnDeriv_of_not_haveLebesgueDecomposition h] @[simp] theorem singularPart_withDensity (ν : Measure α) (f : α → ℝ≥0∞) : (ν.withDensity f).singularPart ν = 0 := singularPart_eq_zero_of_ac (withDensity_absolutelyContinuous _ _) #align measure_theory.measure.singular_part_with_density MeasureTheory.Measure.singularPart_withDensity lemma rnDeriv_singularPart (μ ν : Measure α) : (μ.singularPart ν).rnDeriv ν =ᵐ[ν] 0 := by rw [rnDeriv_eq_zero] exact mutuallySingular_singularPart μ ν @[simp] lemma singularPart_self (μ : Measure α) : μ.singularPart μ = 0 := singularPart_eq_zero_of_ac Measure.AbsolutelyContinuous.rfl lemma rnDeriv_self (μ : Measure α) [SigmaFinite μ] : μ.rnDeriv μ =ᵐ[μ] fun _ ↦ 1 := by have h := rnDeriv_add_singularPart μ μ rw [singularPart_self, add_zero] at h have h_one : μ = μ.withDensity 1 := by simp conv_rhs at h => rw [h_one] rwa [withDensity_eq_iff_of_sigmaFinite (measurable_rnDeriv _ _).aemeasurable] at h exact aemeasurable_const lemma singularPart_eq_self [μ.HaveLebesgueDecomposition ν] : μ.singularPart ν = μ ↔ μ ⟂ₘ ν := by have h_dec := haveLebesgueDecomposition_add μ ν refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩ · rw [← h] exact mutuallySingular_singularPart _ _ · conv_rhs => rw [h_dec] rw [(withDensity_rnDeriv_eq_zero _ _).mpr h, add_zero] @[simp] lemma singularPart_singularPart (μ ν : Measure α) : (μ.singularPart ν).singularPart ν = μ.singularPart ν := by rw [Measure.singularPart_eq_self] exact Measure.mutuallySingular_singularPart _ _ instance singularPart.instIsFiniteMeasure [IsFiniteMeasure μ] : IsFiniteMeasure (μ.singularPart ν) := isFiniteMeasure_of_le μ <| singularPart_le μ ν #align measure_theory.measure.singular_part.measure_theory.is_finite_measure MeasureTheory.Measure.singularPart.instIsFiniteMeasure instance singularPart.instSigmaFinite [SigmaFinite μ] : SigmaFinite (μ.singularPart ν) := sigmaFinite_of_le μ <| singularPart_le μ ν #align measure_theory.measure.singular_part.measure_theory.sigma_finite MeasureTheory.Measure.singularPart.instSigmaFinite instance singularPart.instIsLocallyFiniteMeasure [TopologicalSpace α] [IsLocallyFiniteMeasure μ] : IsLocallyFiniteMeasure (μ.singularPart ν) := isLocallyFiniteMeasure_of_le <| singularPart_le μ ν #align measure_theory.measure.singular_part.measure_theory.is_locally_finite_measure MeasureTheory.Measure.singularPart.instIsLocallyFiniteMeasure instance withDensity.instIsFiniteMeasure [IsFiniteMeasure μ] : IsFiniteMeasure (ν.withDensity <| μ.rnDeriv ν) := isFiniteMeasure_of_le μ <| withDensity_rnDeriv_le μ ν #align measure_theory.measure.with_density.measure_theory.is_finite_measure MeasureTheory.Measure.withDensity.instIsFiniteMeasure instance withDensity.instSigmaFinite [SigmaFinite μ] : SigmaFinite (ν.withDensity <| μ.rnDeriv ν) := sigmaFinite_of_le μ <| withDensity_rnDeriv_le μ ν #align measure_theory.measure.with_density.measure_theory.sigma_finite MeasureTheory.Measure.withDensity.instSigmaFinite instance withDensity.instIsLocallyFiniteMeasure [TopologicalSpace α] [IsLocallyFiniteMeasure μ] : IsLocallyFiniteMeasure (ν.withDensity <| μ.rnDeriv ν) := isLocallyFiniteMeasure_of_le <| withDensity_rnDeriv_le μ ν #align measure_theory.measure.with_density.measure_theory.is_locally_finite_measure MeasureTheory.Measure.withDensity.instIsLocallyFiniteMeasure section RNDerivFinite theorem lintegral_rnDeriv_lt_top_of_measure_ne_top (ν : Measure α) {s : Set α} (hs : μ s ≠ ∞) : ∫⁻ x in s, μ.rnDeriv ν x ∂ν < ∞ := by by_cases hl : HaveLebesgueDecomposition μ ν · suffices (∫⁻ x in toMeasurable μ s, μ.rnDeriv ν x ∂ν) < ∞ from lt_of_le_of_lt (lintegral_mono_set (subset_toMeasurable _ _)) this rw [← withDensity_apply _ (measurableSet_toMeasurable _ _)] calc _ ≤ (singularPart μ ν) (toMeasurable μ s) + _ := le_add_self _ = μ s := by rw [← Measure.add_apply, ← haveLebesgueDecomposition_add, measure_toMeasurable] _ < ⊤ := hs.lt_top · simp only [Measure.rnDeriv, dif_neg hl, Pi.zero_apply, lintegral_zero, ENNReal.zero_lt_top] #align measure_theory.measure.lintegral_rn_deriv_lt_top_of_measure_ne_top MeasureTheory.Measure.lintegral_rnDeriv_lt_top_of_measure_ne_top theorem lintegral_rnDeriv_lt_top (μ ν : Measure α) [IsFiniteMeasure μ] : ∫⁻ x, μ.rnDeriv ν x ∂ν < ∞ := by rw [← set_lintegral_univ] exact lintegral_rnDeriv_lt_top_of_measure_ne_top _ (measure_lt_top _ _).ne #align measure_theory.measure.lintegral_rn_deriv_lt_top MeasureTheory.Measure.lintegral_rnDeriv_lt_top lemma integrable_toReal_rnDeriv [IsFiniteMeasure μ] : Integrable (fun x ↦ (μ.rnDeriv ν x).toReal) ν := integrable_toReal_of_lintegral_ne_top (Measure.measurable_rnDeriv _ _).aemeasurable (Measure.lintegral_rnDeriv_lt_top _ _).ne /-- The Radon-Nikodym derivative of a sigma-finite measure `μ` with respect to another measure `ν` is `ν`-almost everywhere finite. -/ theorem rnDeriv_lt_top (μ ν : Measure α) [SigmaFinite μ] : ∀ᵐ x ∂ν, μ.rnDeriv ν x < ∞ := by suffices ∀ n, ∀ᵐ x ∂ν, x ∈ spanningSets μ n → μ.rnDeriv ν x < ∞ by filter_upwards [ae_all_iff.2 this] with _ hx using hx _ (mem_spanningSetsIndex _ _) intro n rw [← ae_restrict_iff' (measurable_spanningSets _ _)] apply ae_lt_top (measurable_rnDeriv _ _) refine (lintegral_rnDeriv_lt_top_of_measure_ne_top _ ?_).ne exact (measure_spanningSets_lt_top _ _).ne #align measure_theory.measure.rn_deriv_lt_top MeasureTheory.Measure.rnDeriv_lt_top lemma rnDeriv_ne_top (μ ν : Measure α) [SigmaFinite μ] : ∀ᵐ x ∂ν, μ.rnDeriv ν x ≠ ∞ := by filter_upwards [Measure.rnDeriv_lt_top μ ν] with x hx using hx.ne end RNDerivFinite /-- Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `s = μ.singularPart μ`. This theorem provides the uniqueness of the `singularPart` in the Lebesgue decomposition theorem, while `MeasureTheory.Measure.eq_rnDeriv` provides the uniqueness of the `rnDeriv`. -/ theorem eq_singularPart {s : Measure α} {f : α → ℝ≥0∞} (hf : Measurable f) (hs : s ⟂ₘ ν) (hadd : μ = s + ν.withDensity f) : s = μ.singularPart ν := by have : HaveLebesgueDecomposition μ ν := ⟨⟨⟨s, f⟩, hf, hs, hadd⟩⟩ obtain ⟨hmeas, hsing, hadd'⟩ := haveLebesgueDecomposition_spec μ ν obtain ⟨⟨S, hS₁, hS₂, hS₃⟩, ⟨T, hT₁, hT₂, hT₃⟩⟩ := hs, hsing rw [hadd'] at hadd have hνinter : ν (S ∩ T)ᶜ = 0 := by rw [compl_inter] refine nonpos_iff_eq_zero.1 (le_trans (measure_union_le _ _) ?_) rw [hT₃, hS₃, add_zero] have heq : s.restrict (S ∩ T)ᶜ = (μ.singularPart ν).restrict (S ∩ T)ᶜ := by ext1 A hA have hf : ν.withDensity f (A ∩ (S ∩ T)ᶜ) = 0 := by refine withDensity_absolutelyContinuous ν _ ?_ rw [← nonpos_iff_eq_zero] exact hνinter ▸ measure_mono inter_subset_right have hrn : ν.withDensity (μ.rnDeriv ν) (A ∩ (S ∩ T)ᶜ) = 0 := by refine withDensity_absolutelyContinuous ν _ ?_ rw [← nonpos_iff_eq_zero] exact hνinter ▸ measure_mono inter_subset_right rw [restrict_apply hA, restrict_apply hA, ← add_zero (s (A ∩ (S ∩ T)ᶜ)), ← hf, ← add_apply, ← hadd, add_apply, hrn, add_zero] have heq' : ∀ A : Set α, MeasurableSet A → s A = s.restrict (S ∩ T)ᶜ A := by intro A hA have hsinter : s (A ∩ (S ∩ T)) = 0 := by rw [← nonpos_iff_eq_zero] exact hS₂ ▸ measure_mono (inter_subset_right.trans inter_subset_left) rw [restrict_apply hA, ← diff_eq, AEDisjoint.measure_diff_left hsinter] ext1 A hA have hμinter : μ.singularPart ν (A ∩ (S ∩ T)) = 0 := by rw [← nonpos_iff_eq_zero] exact hT₂ ▸ measure_mono (inter_subset_right.trans inter_subset_right) rw [heq' A hA, heq, restrict_apply hA, ← diff_eq, AEDisjoint.measure_diff_left hμinter] #align measure_theory.measure.eq_singular_part MeasureTheory.Measure.eq_singularPart theorem singularPart_smul (μ ν : Measure α) (r : ℝ≥0) : (r • μ).singularPart ν = r • μ.singularPart ν := by by_cases hr : r = 0 · rw [hr, zero_smul, zero_smul, singularPart_zero] by_cases hl : HaveLebesgueDecomposition μ ν · refine (eq_singularPart ((measurable_rnDeriv μ ν).const_smul (r : ℝ≥0∞)) (MutuallySingular.smul r (mutuallySingular_singularPart _ _)) ?_).symm rw [withDensity_smul _ (measurable_rnDeriv _ _), ← smul_add, ← haveLebesgueDecomposition_add μ ν, ENNReal.smul_def] · rw [singularPart, singularPart, dif_neg hl, dif_neg, smul_zero] refine fun hl' ↦ hl ?_ rw [← inv_smul_smul₀ hr μ] infer_instance #align measure_theory.measure.singular_part_smul MeasureTheory.Measure.singularPart_smul theorem singularPart_smul_right (μ ν : Measure α) (r : ℝ≥0) (hr : r ≠ 0) : μ.singularPart (r • ν) = μ.singularPart ν := by by_cases hl : HaveLebesgueDecomposition μ ν · refine (eq_singularPart ((measurable_rnDeriv μ ν).const_smul r⁻¹) ?_ ?_).symm · exact (mutuallySingular_singularPart μ ν).mono_ac AbsolutelyContinuous.rfl smul_absolutelyContinuous · rw [ENNReal.smul_def r, withDensity_smul_measure, ← withDensity_smul] swap; · exact (measurable_rnDeriv _ _).const_smul _ convert haveLebesgueDecomposition_add μ ν ext x simp only [Pi.smul_apply] rw [← ENNReal.smul_def, smul_inv_smul₀ hr] · rw [singularPart, singularPart, dif_neg hl, dif_neg] refine fun hl' ↦ hl ?_ rw [← inv_smul_smul₀ hr ν] infer_instance theorem singularPart_add (μ₁ μ₂ ν : Measure α) [HaveLebesgueDecomposition μ₁ ν] [HaveLebesgueDecomposition μ₂ ν] : (μ₁ + μ₂).singularPart ν = μ₁.singularPart ν + μ₂.singularPart ν := by refine (eq_singularPart ((measurable_rnDeriv μ₁ ν).add (measurable_rnDeriv μ₂ ν)) ((mutuallySingular_singularPart _ _).add_left (mutuallySingular_singularPart _ _)) ?_).symm erw [withDensity_add_left (measurable_rnDeriv μ₁ ν)] conv_rhs => rw [add_assoc, add_comm (μ₂.singularPart ν), ← add_assoc, ← add_assoc] rw [← haveLebesgueDecomposition_add μ₁ ν, add_assoc, add_comm (ν.withDensity (μ₂.rnDeriv ν)), ← haveLebesgueDecomposition_add μ₂ ν] #align measure_theory.measure.singular_part_add MeasureTheory.Measure.singularPart_add lemma singularPart_restrict (μ ν : Measure α) [HaveLebesgueDecomposition μ ν] {s : Set α} (hs : MeasurableSet s) : (μ.restrict s).singularPart ν = (μ.singularPart ν).restrict s := by refine (Measure.eq_singularPart (f := s.indicator (μ.rnDeriv ν)) ?_ ?_ ?_).symm · exact (μ.measurable_rnDeriv ν).indicator hs · exact (Measure.mutuallySingular_singularPart μ ν).restrict s · ext t rw [withDensity_indicator hs, ← restrict_withDensity hs, ← Measure.restrict_add, ← μ.haveLebesgueDecomposition_add ν] /-- Given measures `μ` and `ν`, if `s` is a measure mutually singular to `ν` and `f` is a measurable function such that `μ = s + fν`, then `f = μ.rnDeriv ν`. This theorem provides the uniqueness of the `rnDeriv` in the Lebesgue decomposition theorem, while `MeasureTheory.Measure.eq_singularPart` provides the uniqueness of the `singularPart`. Here, the uniqueness is given in terms of the measures, while the uniqueness in terms of the functions is given in `eq_rnDeriv`. -/ theorem eq_withDensity_rnDeriv {s : Measure α} {f : α → ℝ≥0∞} (hf : Measurable f) (hs : s ⟂ₘ ν) (hadd : μ = s + ν.withDensity f) : ν.withDensity f = ν.withDensity (μ.rnDeriv ν) := by have : HaveLebesgueDecomposition μ ν := ⟨⟨⟨s, f⟩, hf, hs, hadd⟩⟩ obtain ⟨hmeas, hsing, hadd'⟩ := haveLebesgueDecomposition_spec μ ν obtain ⟨⟨S, hS₁, hS₂, hS₃⟩, ⟨T, hT₁, hT₂, hT₃⟩⟩ := hs, hsing rw [hadd'] at hadd have hνinter : ν (S ∩ T)ᶜ = 0 := by rw [compl_inter] refine nonpos_iff_eq_zero.1 (le_trans (measure_union_le _ _) ?_) rw [hT₃, hS₃, add_zero] have heq : (ν.withDensity f).restrict (S ∩ T) = (ν.withDensity (μ.rnDeriv ν)).restrict (S ∩ T) := by ext1 A hA have hs : s (A ∩ (S ∩ T)) = 0 := by rw [← nonpos_iff_eq_zero] exact hS₂ ▸ measure_mono (inter_subset_right.trans inter_subset_left) have hsing : μ.singularPart ν (A ∩ (S ∩ T)) = 0 := by rw [← nonpos_iff_eq_zero] exact hT₂ ▸ measure_mono (inter_subset_right.trans inter_subset_right) rw [restrict_apply hA, restrict_apply hA, ← add_zero (ν.withDensity f (A ∩ (S ∩ T))), ← hs, ← add_apply, add_comm, ← hadd, add_apply, hsing, zero_add] have heq' : ∀ A : Set α, MeasurableSet A → ν.withDensity f A = (ν.withDensity f).restrict (S ∩ T) A := by intro A hA have hνfinter : ν.withDensity f (A ∩ (S ∩ T)ᶜ) = 0 := by rw [← nonpos_iff_eq_zero] exact withDensity_absolutelyContinuous ν f hνinter ▸ measure_mono inter_subset_right rw [restrict_apply hA, ← add_zero (ν.withDensity f (A ∩ (S ∩ T))), ← hνfinter, ← diff_eq, measure_inter_add_diff _ (hS₁.inter hT₁)] ext1 A hA have hνrn : ν.withDensity (μ.rnDeriv ν) (A ∩ (S ∩ T)ᶜ) = 0 := by rw [← nonpos_iff_eq_zero] exact withDensity_absolutelyContinuous ν (μ.rnDeriv ν) hνinter ▸ measure_mono inter_subset_right rw [heq' A hA, heq, ← add_zero ((ν.withDensity (μ.rnDeriv ν)).restrict (S ∩ T) A), ← hνrn, restrict_apply hA, ← diff_eq, measure_inter_add_diff _ (hS₁.inter hT₁)] #align measure_theory.measure.eq_with_density_rn_deriv MeasureTheory.Measure.eq_withDensity_rnDeriv
Mathlib/MeasureTheory/Decomposition/Lebesgue.lean
529
533
theorem eq_withDensity_rnDeriv₀ {s : Measure α} {f : α → ℝ≥0∞} (hf : AEMeasurable f ν) (hs : s ⟂ₘ ν) (hadd : μ = s + ν.withDensity f) : ν.withDensity f = ν.withDensity (μ.rnDeriv ν) := by
rw [withDensity_congr_ae hf.ae_eq_mk] at hadd ⊢ exact eq_withDensity_rnDeriv hf.measurable_mk hs hadd
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Yury Kudryashov -/ import Mathlib.Data.Rat.Sqrt import Mathlib.Data.Real.Sqrt import Mathlib.RingTheory.Algebraic import Mathlib.RingTheory.Int.Basic import Mathlib.Tactic.IntervalCases #align_import data.real.irrational from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d" /-! # Irrational real numbers In this file we define a predicate `Irrational` on `ℝ`, prove that the `n`-th root of an integer number is irrational if it is not integer, and that `sqrt q` is irrational if and only if `Rat.sqrt q * Rat.sqrt q ≠ q ∧ 0 ≤ q`. We also provide dot-style constructors like `Irrational.add_rat`, `Irrational.rat_sub` etc. -/ open Rat Real multiplicity /-- A real number is irrational if it is not equal to any rational number. -/ def Irrational (x : ℝ) := x ∉ Set.range ((↑) : ℚ → ℝ) #align irrational Irrational theorem irrational_iff_ne_rational (x : ℝ) : Irrational x ↔ ∀ a b : ℤ, x ≠ a / b := by simp only [Irrational, Rat.forall, cast_mk, not_exists, Set.mem_range, cast_intCast, cast_div, eq_comm] #align irrational_iff_ne_rational irrational_iff_ne_rational /-- A transcendental real number is irrational. -/ theorem Transcendental.irrational {r : ℝ} (tr : Transcendental ℚ r) : Irrational r := by rintro ⟨a, rfl⟩ exact tr (isAlgebraic_algebraMap a) #align transcendental.irrational Transcendental.irrational /-! ### Irrationality of roots of integer and rational numbers -/ /-- If `x^n`, `n > 0`, is integer and is not the `n`-th power of an integer, then `x` is irrational. -/ theorem irrational_nrt_of_notint_nrt {x : ℝ} (n : ℕ) (m : ℤ) (hxr : x ^ n = m) (hv : ¬∃ y : ℤ, x = y) (hnpos : 0 < n) : Irrational x := by rintro ⟨⟨N, D, P, C⟩, rfl⟩ rw [← cast_pow] at hxr have c1 : ((D : ℤ) : ℝ) ≠ 0 := by rw [Int.cast_ne_zero, Int.natCast_ne_zero] exact P have c2 : ((D : ℤ) : ℝ) ^ n ≠ 0 := pow_ne_zero _ c1 rw [mk'_eq_divInt, cast_pow, cast_mk, div_pow, div_eq_iff_mul_eq c2, ← Int.cast_pow, ← Int.cast_pow, ← Int.cast_mul, Int.cast_inj] at hxr have hdivn : (D : ℤ) ^ n ∣ N ^ n := Dvd.intro_left m hxr rw [← Int.dvd_natAbs, ← Int.natCast_pow, Int.natCast_dvd_natCast, Int.natAbs_pow, Nat.pow_dvd_pow_iff hnpos.ne'] at hdivn obtain rfl : D = 1 := by rw [← Nat.gcd_eq_right hdivn, C.gcd_eq_one] refine hv ⟨N, ?_⟩ rw [mk'_eq_divInt, Int.ofNat_one, divInt_one, cast_intCast] #align irrational_nrt_of_notint_nrt irrational_nrt_of_notint_nrt /-- If `x^n = m` is an integer and `n` does not divide the `multiplicity p m`, then `x` is irrational. -/ theorem irrational_nrt_of_n_not_dvd_multiplicity {x : ℝ} (n : ℕ) {m : ℤ} (hm : m ≠ 0) (p : ℕ) [hp : Fact p.Prime] (hxr : x ^ n = m) (hv : (multiplicity (p : ℤ) m).get (finite_int_iff.2 ⟨hp.1.ne_one, hm⟩) % n ≠ 0) : Irrational x := by rcases Nat.eq_zero_or_pos n with (rfl | hnpos) · rw [eq_comm, pow_zero, ← Int.cast_one, Int.cast_inj] at hxr simp [hxr, multiplicity.one_right (mt isUnit_iff_dvd_one.1 (mt Int.natCast_dvd_natCast.1 hp.1.not_dvd_one)), Nat.zero_mod] at hv refine irrational_nrt_of_notint_nrt _ _ hxr ?_ hnpos rintro ⟨y, rfl⟩ rw [← Int.cast_pow, Int.cast_inj] at hxr subst m have : y ≠ 0 := by rintro rfl; rw [zero_pow hnpos.ne'] at hm; exact hm rfl erw [multiplicity.pow' (Nat.prime_iff_prime_int.1 hp.1) (finite_int_iff.2 ⟨hp.1.ne_one, this⟩), Nat.mul_mod_right] at hv exact hv rfl #align irrational_nrt_of_n_not_dvd_multiplicity irrational_nrt_of_n_not_dvd_multiplicity theorem irrational_sqrt_of_multiplicity_odd (m : ℤ) (hm : 0 < m) (p : ℕ) [hp : Fact p.Prime] (Hpv : (multiplicity (p : ℤ) m).get (finite_int_iff.2 ⟨hp.1.ne_one, (ne_of_lt hm).symm⟩) % 2 = 1) : Irrational (√m) := @irrational_nrt_of_n_not_dvd_multiplicity _ 2 _ (Ne.symm (ne_of_lt hm)) p hp (sq_sqrt (Int.cast_nonneg.2 <| le_of_lt hm)) (by rw [Hpv]; exact one_ne_zero) #align irrational_sqrt_of_multiplicity_odd irrational_sqrt_of_multiplicity_odd theorem Nat.Prime.irrational_sqrt {p : ℕ} (hp : Nat.Prime p) : Irrational (√p) := @irrational_sqrt_of_multiplicity_odd p (Int.natCast_pos.2 hp.pos) p ⟨hp⟩ <| by simp [multiplicity.multiplicity_self (mt isUnit_iff_dvd_one.1 (mt Int.natCast_dvd_natCast.1 hp.not_dvd_one))] #align nat.prime.irrational_sqrt Nat.Prime.irrational_sqrt /-- **Irrationality of the Square Root of 2** -/ theorem irrational_sqrt_two : Irrational (√2) := by simpa using Nat.prime_two.irrational_sqrt #align irrational_sqrt_two irrational_sqrt_two theorem irrational_sqrt_rat_iff (q : ℚ) : Irrational (√q) ↔ Rat.sqrt q * Rat.sqrt q ≠ q ∧ 0 ≤ q := if H1 : Rat.sqrt q * Rat.sqrt q = q then iff_of_false (not_not_intro ⟨Rat.sqrt q, by rw [← H1, cast_mul, sqrt_mul_self (cast_nonneg.2 <| Rat.sqrt_nonneg q), sqrt_eq, abs_of_nonneg (Rat.sqrt_nonneg q)]⟩) fun h => h.1 H1 else if H2 : 0 ≤ q then iff_of_true (fun ⟨r, hr⟩ => H1 <| (exists_mul_self _).1 ⟨r, by rwa [eq_comm, sqrt_eq_iff_mul_self_eq (cast_nonneg.2 H2), ← cast_mul, Rat.cast_inj] at hr rw [← hr] exact Real.sqrt_nonneg _⟩) ⟨H1, H2⟩ else iff_of_false (not_not_intro ⟨0, by rw [cast_zero] exact (sqrt_eq_zero_of_nonpos (Rat.cast_nonpos.2 <| le_of_not_le H2)).symm⟩) fun h => H2 h.2 #align irrational_sqrt_rat_iff irrational_sqrt_rat_iff instance (q : ℚ) : Decidable (Irrational (√q)) := decidable_of_iff' _ (irrational_sqrt_rat_iff q) /-! ### Dot-style operations on `Irrational` #### Coercion of a rational/integer/natural number is not irrational -/ namespace Irrational variable {x : ℝ} /-! #### Irrational number is not equal to a rational/integer/natural number -/ theorem ne_rat (h : Irrational x) (q : ℚ) : x ≠ q := fun hq => h ⟨q, hq.symm⟩ #align irrational.ne_rat Irrational.ne_rat theorem ne_int (h : Irrational x) (m : ℤ) : x ≠ m := by rw [← Rat.cast_intCast] exact h.ne_rat _ #align irrational.ne_int Irrational.ne_int theorem ne_nat (h : Irrational x) (m : ℕ) : x ≠ m := h.ne_int m #align irrational.ne_nat Irrational.ne_nat theorem ne_zero (h : Irrational x) : x ≠ 0 := mod_cast h.ne_nat 0 #align irrational.ne_zero Irrational.ne_zero theorem ne_one (h : Irrational x) : x ≠ 1 := by simpa only [Nat.cast_one] using h.ne_nat 1 #align irrational.ne_one Irrational.ne_one end Irrational @[simp] theorem Rat.not_irrational (q : ℚ) : ¬Irrational q := fun h => h ⟨q, rfl⟩ #align rat.not_irrational Rat.not_irrational @[simp] theorem Int.not_irrational (m : ℤ) : ¬Irrational m := fun h => h.ne_int m rfl #align int.not_irrational Int.not_irrational @[simp] theorem Nat.not_irrational (m : ℕ) : ¬Irrational m := fun h => h.ne_nat m rfl #align nat.not_irrational Nat.not_irrational namespace Irrational variable (q : ℚ) {x y : ℝ} /-! #### Addition of rational/integer/natural numbers -/ /-- If `x + y` is irrational, then at least one of `x` and `y` is irrational. -/
Mathlib/Data/Real/Irrational.lean
198
202
theorem add_cases : Irrational (x + y) → Irrational x ∨ Irrational y := by
delta Irrational contrapose! rintro ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩ exact ⟨rx + ry, cast_add rx ry⟩
/- Copyright (c) 2018 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad, Mario Carneiro, Simon Hudon -/ import Mathlib.Data.Fin.Fin2 import Mathlib.Logic.Function.Basic import Mathlib.Tactic.Common #align_import data.typevec from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Tuples of types, and their categorical structure. ## Features * `TypeVec n` - n-tuples of types * `α ⟹ β` - n-tuples of maps * `f ⊚ g` - composition Also, support functions for operating with n-tuples of types, such as: * `append1 α β` - append type `β` to n-tuple `α` to obtain an (n+1)-tuple * `drop α` - drops the last element of an (n+1)-tuple * `last α` - returns the last element of an (n+1)-tuple * `appendFun f g` - appends a function g to an n-tuple of functions * `dropFun f` - drops the last function from an n+1-tuple * `lastFun f` - returns the last function of a tuple. Since e.g. `append1 α.drop α.last` is propositionally equal to `α` but not definitionally equal to it, we need support functions and lemmas to mediate between constructions. -/ universe u v w /-- n-tuples of types, as a category -/ @[pp_with_univ] def TypeVec (n : ℕ) := Fin2 n → Type* #align typevec TypeVec instance {n} : Inhabited (TypeVec.{u} n) := ⟨fun _ => PUnit⟩ namespace TypeVec variable {n : ℕ} /-- arrow in the category of `TypeVec` -/ def Arrow (α β : TypeVec n) := ∀ i : Fin2 n, α i → β i #align typevec.arrow TypeVec.Arrow @[inherit_doc] scoped[MvFunctor] infixl:40 " ⟹ " => TypeVec.Arrow open MvFunctor /-- Extensionality for arrows -/ @[ext] theorem Arrow.ext {α β : TypeVec n} (f g : α ⟹ β) : (∀ i, f i = g i) → f = g := by intro h; funext i; apply h instance Arrow.inhabited (α β : TypeVec n) [∀ i, Inhabited (β i)] : Inhabited (α ⟹ β) := ⟨fun _ _ => default⟩ #align typevec.arrow.inhabited TypeVec.Arrow.inhabited /-- identity of arrow composition -/ def id {α : TypeVec n} : α ⟹ α := fun _ x => x #align typevec.id TypeVec.id /-- arrow composition in the category of `TypeVec` -/ def comp {α β γ : TypeVec n} (g : β ⟹ γ) (f : α ⟹ β) : α ⟹ γ := fun i x => g i (f i x) #align typevec.comp TypeVec.comp @[inherit_doc] scoped[MvFunctor] infixr:80 " ⊚ " => TypeVec.comp -- type as \oo @[simp] theorem id_comp {α β : TypeVec n} (f : α ⟹ β) : id ⊚ f = f := rfl #align typevec.id_comp TypeVec.id_comp @[simp] theorem comp_id {α β : TypeVec n} (f : α ⟹ β) : f ⊚ id = f := rfl #align typevec.comp_id TypeVec.comp_id theorem comp_assoc {α β γ δ : TypeVec n} (h : γ ⟹ δ) (g : β ⟹ γ) (f : α ⟹ β) : (h ⊚ g) ⊚ f = h ⊚ g ⊚ f := rfl #align typevec.comp_assoc TypeVec.comp_assoc /-- Support for extending a `TypeVec` by one element. -/ def append1 (α : TypeVec n) (β : Type*) : TypeVec (n + 1) | Fin2.fs i => α i | Fin2.fz => β #align typevec.append1 TypeVec.append1 @[inherit_doc] infixl:67 " ::: " => append1 /-- retain only a `n-length` prefix of the argument -/ def drop (α : TypeVec.{u} (n + 1)) : TypeVec n := fun i => α i.fs #align typevec.drop TypeVec.drop /-- take the last value of a `(n+1)-length` vector -/ def last (α : TypeVec.{u} (n + 1)) : Type _ := α Fin2.fz #align typevec.last TypeVec.last instance last.inhabited (α : TypeVec (n + 1)) [Inhabited (α Fin2.fz)] : Inhabited (last α) := ⟨show α Fin2.fz from default⟩ #align typevec.last.inhabited TypeVec.last.inhabited theorem drop_append1 {α : TypeVec n} {β : Type*} {i : Fin2 n} : drop (append1 α β) i = α i := rfl #align typevec.drop_append1 TypeVec.drop_append1 theorem drop_append1' {α : TypeVec n} {β : Type*} : drop (append1 α β) = α := funext fun _ => drop_append1 #align typevec.drop_append1' TypeVec.drop_append1' theorem last_append1 {α : TypeVec n} {β : Type*} : last (append1 α β) = β := rfl #align typevec.last_append1 TypeVec.last_append1 @[simp] theorem append1_drop_last (α : TypeVec (n + 1)) : append1 (drop α) (last α) = α := funext fun i => by cases i <;> rfl #align typevec.append1_drop_last TypeVec.append1_drop_last /-- cases on `(n+1)-length` vectors -/ @[elab_as_elim] def append1Cases {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (γ) : C γ := by rw [← @append1_drop_last _ γ]; apply H #align typevec.append1_cases TypeVec.append1Cases @[simp] theorem append1_cases_append1 {C : TypeVec (n + 1) → Sort u} (H : ∀ α β, C (append1 α β)) (α β) : @append1Cases _ C H (append1 α β) = H α β := rfl #align typevec.append1_cases_append1 TypeVec.append1_cases_append1 /-- append an arrow and a function for arbitrary source and target type vectors -/ def splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : α ⟹ α' | Fin2.fs i => f i | Fin2.fz => g #align typevec.split_fun TypeVec.splitFun /-- append an arrow and a function as well as their respective source and target types / typevecs -/ def appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : append1 α β ⟹ append1 α' β' := splitFun f g #align typevec.append_fun TypeVec.appendFun @[inherit_doc] infixl:0 " ::: " => appendFun /-- split off the prefix of an arrow -/ def dropFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : drop α ⟹ drop β := fun i => f i.fs #align typevec.drop_fun TypeVec.dropFun /-- split off the last function of an arrow -/ def lastFun {α β : TypeVec (n + 1)} (f : α ⟹ β) : last α → last β := f Fin2.fz #align typevec.last_fun TypeVec.lastFun -- Porting note: Lean wasn't able to infer the motive in term mode /-- arrow in the category of `0-length` vectors -/ def nilFun {α : TypeVec 0} {β : TypeVec 0} : α ⟹ β := fun i => by apply Fin2.elim0 i #align typevec.nil_fun TypeVec.nilFun theorem eq_of_drop_last_eq {α β : TypeVec (n + 1)} {f g : α ⟹ β} (h₀ : dropFun f = dropFun g) (h₁ : lastFun f = lastFun g) : f = g := by -- Porting note: FIXME: congr_fun h₀ <;> ext1 ⟨⟩ <;> apply_assumption refine funext (fun x => ?_) cases x · apply h₁ · apply congr_fun h₀ #align typevec.eq_of_drop_last_eq TypeVec.eq_of_drop_last_eq @[simp] theorem dropFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : dropFun (splitFun f g) = f := rfl #align typevec.drop_fun_split_fun TypeVec.dropFun_splitFun /-- turn an equality into an arrow -/ def Arrow.mp {α β : TypeVec n} (h : α = β) : α ⟹ β | _ => Eq.mp (congr_fun h _) #align typevec.arrow.mp TypeVec.Arrow.mp /-- turn an equality into an arrow, with reverse direction -/ def Arrow.mpr {α β : TypeVec n} (h : α = β) : β ⟹ α | _ => Eq.mpr (congr_fun h _) #align typevec.arrow.mpr TypeVec.Arrow.mpr /-- decompose a vector into its prefix appended with its last element -/ def toAppend1DropLast {α : TypeVec (n + 1)} : α ⟹ (drop α ::: last α) := Arrow.mpr (append1_drop_last _) #align typevec.to_append1_drop_last TypeVec.toAppend1DropLast /-- stitch two bits of a vector back together -/ def fromAppend1DropLast {α : TypeVec (n + 1)} : (drop α ::: last α) ⟹ α := Arrow.mp (append1_drop_last _) #align typevec.from_append1_drop_last TypeVec.fromAppend1DropLast @[simp] theorem lastFun_splitFun {α α' : TypeVec (n + 1)} (f : drop α ⟹ drop α') (g : last α → last α') : lastFun (splitFun f g) = g := rfl #align typevec.last_fun_split_fun TypeVec.lastFun_splitFun @[simp] theorem dropFun_appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : dropFun (f ::: g) = f := rfl #align typevec.drop_fun_append_fun TypeVec.dropFun_appendFun @[simp] theorem lastFun_appendFun {α α' : TypeVec n} {β β' : Type*} (f : α ⟹ α') (g : β → β') : lastFun (f ::: g) = g := rfl #align typevec.last_fun_append_fun TypeVec.lastFun_appendFun theorem split_dropFun_lastFun {α α' : TypeVec (n + 1)} (f : α ⟹ α') : splitFun (dropFun f) (lastFun f) = f := eq_of_drop_last_eq rfl rfl #align typevec.split_drop_fun_last_fun TypeVec.split_dropFun_lastFun theorem splitFun_inj {α α' : TypeVec (n + 1)} {f f' : drop α ⟹ drop α'} {g g' : last α → last α'} (H : splitFun f g = splitFun f' g') : f = f' ∧ g = g' := by rw [← dropFun_splitFun f g, H, ← lastFun_splitFun f g, H]; simp #align typevec.split_fun_inj TypeVec.splitFun_inj theorem appendFun_inj {α α' : TypeVec n} {β β' : Type*} {f f' : α ⟹ α'} {g g' : β → β'} : (f ::: g : (α ::: β) ⟹ _) = (f' ::: g' : (α ::: β) ⟹ _) → f = f' ∧ g = g' := splitFun_inj #align typevec.append_fun_inj TypeVec.appendFun_inj theorem splitFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : drop α₀ ⟹ drop α₁) (f₁ : drop α₁ ⟹ drop α₂) (g₀ : last α₀ → last α₁) (g₁ : last α₁ → last α₂) : splitFun (f₁ ⊚ f₀) (g₁ ∘ g₀) = splitFun f₁ g₁ ⊚ splitFun f₀ g₀ := eq_of_drop_last_eq rfl rfl #align typevec.split_fun_comp TypeVec.splitFun_comp theorem appendFun_comp_splitFun {α γ : TypeVec n} {β δ : Type*} {ε : TypeVec (n + 1)} (f₀ : drop ε ⟹ α) (f₁ : α ⟹ γ) (g₀ : last ε → β) (g₁ : β → δ) : appendFun f₁ g₁ ⊚ splitFun f₀ g₀ = splitFun (α' := γ.append1 δ) (f₁ ⊚ f₀) (g₁ ∘ g₀) := (splitFun_comp _ _ _ _).symm #align typevec.append_fun_comp_split_fun TypeVec.appendFun_comp_splitFun theorem appendFun_comp {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type*} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ⊚ f₀ ::: g₁ ∘ g₀) = (f₁ ::: g₁) ⊚ (f₀ ::: g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp TypeVec.appendFun_comp theorem appendFun_comp' {α₀ α₁ α₂ : TypeVec n} {β₀ β₁ β₂ : Type*} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (f₁ ::: g₁) ⊚ (f₀ ::: g₀) = (f₁ ⊚ f₀ ::: g₁ ∘ g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp' TypeVec.appendFun_comp' theorem nilFun_comp {α₀ : TypeVec 0} (f₀ : α₀ ⟹ Fin2.elim0) : nilFun ⊚ f₀ = f₀ := funext fun x => by apply Fin2.elim0 x -- Porting note: `by apply` is necessary? #align typevec.nil_fun_comp TypeVec.nilFun_comp theorem appendFun_comp_id {α : TypeVec n} {β₀ β₁ β₂ : Type u} (g₀ : β₀ → β₁) (g₁ : β₁ → β₂) : (@id _ α ::: g₁ ∘ g₀) = (id ::: g₁) ⊚ (id ::: g₀) := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_comp_id TypeVec.appendFun_comp_id @[simp] theorem dropFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) : dropFun (f₁ ⊚ f₀) = dropFun f₁ ⊚ dropFun f₀ := rfl #align typevec.drop_fun_comp TypeVec.dropFun_comp @[simp] theorem lastFun_comp {α₀ α₁ α₂ : TypeVec (n + 1)} (f₀ : α₀ ⟹ α₁) (f₁ : α₁ ⟹ α₂) : lastFun (f₁ ⊚ f₀) = lastFun f₁ ∘ lastFun f₀ := rfl #align typevec.last_fun_comp TypeVec.lastFun_comp theorem appendFun_aux {α α' : TypeVec n} {β β' : Type*} (f : (α ::: β) ⟹ (α' ::: β')) : (dropFun f ::: lastFun f) = f := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_aux TypeVec.appendFun_aux theorem appendFun_id_id {α : TypeVec n} {β : Type*} : (@TypeVec.id n α ::: @_root_.id β) = TypeVec.id := eq_of_drop_last_eq rfl rfl #align typevec.append_fun_id_id TypeVec.appendFun_id_id instance subsingleton0 : Subsingleton (TypeVec 0) := ⟨fun a b => funext fun a => by apply Fin2.elim0 a⟩ -- Porting note: `by apply` necessary? #align typevec.subsingleton0 TypeVec.subsingleton0 -- Porting note: `simp` attribute `TypeVec` moved to file `Tactic/Attr/Register.lean` /-- cases distinction for 0-length type vector -/ protected def casesNil {β : TypeVec 0 → Sort*} (f : β Fin2.elim0) : ∀ v, β v := fun v => cast (by congr; funext i; cases i) f #align typevec.cases_nil TypeVec.casesNil /-- cases distinction for (n+1)-length type vector -/ protected def casesCons (n : ℕ) {β : TypeVec (n + 1) → Sort*} (f : ∀ (t) (v : TypeVec n), β (v ::: t)) : ∀ v, β v := fun v : TypeVec (n + 1) => cast (by simp) (f v.last v.drop) #align typevec.cases_cons TypeVec.casesCons protected theorem casesNil_append1 {β : TypeVec 0 → Sort*} (f : β Fin2.elim0) : TypeVec.casesNil f Fin2.elim0 = f := rfl #align typevec.cases_nil_append1 TypeVec.casesNil_append1 protected theorem casesCons_append1 (n : ℕ) {β : TypeVec (n + 1) → Sort*} (f : ∀ (t) (v : TypeVec n), β (v ::: t)) (v : TypeVec n) (α) : TypeVec.casesCons n f (v ::: α) = f α v := rfl #align typevec.cases_cons_append1 TypeVec.casesCons_append1 /-- cases distinction for an arrow in the category of 0-length type vectors -/ def typevecCasesNil₃ {β : ∀ v v' : TypeVec 0, v ⟹ v' → Sort*} (f : β Fin2.elim0 Fin2.elim0 nilFun) : ∀ v v' fs, β v v' fs := fun v v' fs => by refine cast ?_ f have eq₁ : v = Fin2.elim0 := by funext i; contradiction have eq₂ : v' = Fin2.elim0 := by funext i; contradiction have eq₃ : fs = nilFun := by funext i; contradiction cases eq₁; cases eq₂; cases eq₃; rfl #align typevec.typevec_cases_nil₃ TypeVec.typevecCasesNil₃ /-- cases distinction for an arrow in the category of (n+1)-length type vectors -/ def typevecCasesCons₃ (n : ℕ) {β : ∀ v v' : TypeVec (n + 1), v ⟹ v' → Sort*} (F : ∀ (t t') (f : t → t') (v v' : TypeVec n) (fs : v ⟹ v'), β (v ::: t) (v' ::: t') (fs ::: f)) : ∀ v v' fs, β v v' fs := by intro v v' rw [← append1_drop_last v, ← append1_drop_last v'] intro fs rw [← split_dropFun_lastFun fs] apply F #align typevec.typevec_cases_cons₃ TypeVec.typevecCasesCons₃ /-- specialized cases distinction for an arrow in the category of 0-length type vectors -/ def typevecCasesNil₂ {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort*} (f : β nilFun) : ∀ f, β f := by intro g suffices g = nilFun by rwa [this] ext ⟨⟩ #align typevec.typevec_cases_nil₂ TypeVec.typevecCasesNil₂ /-- specialized cases distinction for an arrow in the category of (n+1)-length type vectors -/ def typevecCasesCons₂ (n : ℕ) (t t' : Type*) (v v' : TypeVec n) {β : (v ::: t) ⟹ (v' ::: t') → Sort*} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) : ∀ fs, β fs := by intro fs rw [← split_dropFun_lastFun fs] apply F #align typevec.typevec_cases_cons₂ TypeVec.typevecCasesCons₂ theorem typevecCasesNil₂_appendFun {β : Fin2.elim0 ⟹ Fin2.elim0 → Sort*} (f : β nilFun) : typevecCasesNil₂ f nilFun = f := rfl #align typevec.typevec_cases_nil₂_append_fun TypeVec.typevecCasesNil₂_appendFun theorem typevecCasesCons₂_appendFun (n : ℕ) (t t' : Type*) (v v' : TypeVec n) {β : (v ::: t) ⟹ (v' ::: t') → Sort*} (F : ∀ (f : t → t') (fs : v ⟹ v'), β (fs ::: f)) (f fs) : typevecCasesCons₂ n t t' v v' F (fs ::: f) = F f fs := rfl #align typevec.typevec_cases_cons₂_append_fun TypeVec.typevecCasesCons₂_appendFun -- for lifting predicates and relations /-- `PredLast α p x` predicates `p` of the last element of `x : α.append1 β`. -/ def PredLast (α : TypeVec n) {β : Type*} (p : β → Prop) : ∀ ⦃i⦄, (α.append1 β) i → Prop | Fin2.fs _ => fun _ => True | Fin2.fz => p #align typevec.pred_last TypeVec.PredLast /-- `RelLast α r x y` says that `p` the last elements of `x y : α.append1 β` are related by `r` and all the other elements are equal. -/ def RelLast (α : TypeVec n) {β γ : Type u} (r : β → γ → Prop) : ∀ ⦃i⦄, (α.append1 β) i → (α.append1 γ) i → Prop | Fin2.fs _ => Eq | Fin2.fz => r #align typevec.rel_last TypeVec.RelLast section Liftp' open Nat /-- `repeat n t` is a `n-length` type vector that contains `n` occurrences of `t` -/ def «repeat» : ∀ (n : ℕ), Sort _ → TypeVec n | 0, _ => Fin2.elim0 | Nat.succ i, t => append1 («repeat» i t) t #align typevec.repeat TypeVec.repeat /-- `prod α β` is the pointwise product of the components of `α` and `β` -/ def prod : ∀ {n}, TypeVec.{u} n → TypeVec.{u} n → TypeVec n | 0, _, _ => Fin2.elim0 | n + 1, α, β => (@prod n (drop α) (drop β)) ::: (last α × last β) #align typevec.prod TypeVec.prod @[inherit_doc] scoped[MvFunctor] infixl:45 " ⊗ " => TypeVec.prod /- porting note: the order of universes in `const` is reversed w.r.t. mathlib3 -/ /-- `const x α` is an arrow that ignores its source and constructs a `TypeVec` that contains nothing but `x` -/ protected def const {β} (x : β) : ∀ {n} (α : TypeVec n), α ⟹ «repeat» _ β | succ _, α, Fin2.fs _ => TypeVec.const x (drop α) _ | succ _, _, Fin2.fz => fun _ => x #align typevec.const TypeVec.const open Function (uncurry) /-- vector of equality on a product of vectors -/ def repeatEq : ∀ {n} (α : TypeVec n), (α ⊗ α) ⟹ «repeat» _ Prop | 0, _ => nilFun | succ _, α => repeatEq (drop α) ::: uncurry Eq #align typevec.repeat_eq TypeVec.repeatEq theorem const_append1 {β γ} (x : γ) {n} (α : TypeVec n) : TypeVec.const x (α ::: β) = appendFun (TypeVec.const x α) fun _ => x := by ext i : 1; cases i <;> rfl #align typevec.const_append1 TypeVec.const_append1 theorem eq_nilFun {α β : TypeVec 0} (f : α ⟹ β) : f = nilFun := by ext x; cases x #align typevec.eq_nil_fun TypeVec.eq_nilFun
Mathlib/Data/TypeVec.lean
437
438
theorem id_eq_nilFun {α : TypeVec 0} : @id _ α = nilFun := by
ext x; cases x
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Kevin Kappelmann -/ import Mathlib.Algebra.CharZero.Lemmas import Mathlib.Algebra.Order.Interval.Set.Group import Mathlib.Algebra.Group.Int import Mathlib.Data.Int.Lemmas import Mathlib.Data.Set.Subsingleton import Mathlib.Init.Data.Nat.Lemmas import Mathlib.Order.GaloisConnection import Mathlib.Tactic.Abel import Mathlib.Tactic.Linarith import Mathlib.Tactic.Positivity #align_import algebra.order.floor from "leanprover-community/mathlib"@"afdb43429311b885a7988ea15d0bac2aac80f69c" /-! # Floor and ceil ## Summary We define the natural- and integer-valued floor and ceil functions on linearly ordered rings. ## Main Definitions * `FloorSemiring`: An ordered semiring with natural-valued floor and ceil. * `Nat.floor a`: Greatest natural `n` such that `n ≤ a`. Equal to `0` if `a < 0`. * `Nat.ceil a`: Least natural `n` such that `a ≤ n`. * `FloorRing`: A linearly ordered ring with integer-valued floor and ceil. * `Int.floor a`: Greatest integer `z` such that `z ≤ a`. * `Int.ceil a`: Least integer `z` such that `a ≤ z`. * `Int.fract a`: Fractional part of `a`, defined as `a - floor a`. * `round a`: Nearest integer to `a`. It rounds halves towards infinity. ## Notations * `⌊a⌋₊` is `Nat.floor a`. * `⌈a⌉₊` is `Nat.ceil a`. * `⌊a⌋` is `Int.floor a`. * `⌈a⌉` is `Int.ceil a`. The index `₊` in the notations for `Nat.floor` and `Nat.ceil` is used in analogy to the notation for `nnnorm`. ## TODO `LinearOrderedRing`/`LinearOrderedSemiring` can be relaxed to `OrderedRing`/`OrderedSemiring` in many lemmas. ## Tags rounding, floor, ceil -/ open Set variable {F α β : Type*} /-! ### Floor semiring -/ /-- A `FloorSemiring` is an ordered semiring over `α` with a function `floor : α → ℕ` satisfying `∀ (n : ℕ) (x : α), n ≤ ⌊x⌋ ↔ (n : α) ≤ x)`. Note that many lemmas require a `LinearOrder`. Please see the above `TODO`. -/ class FloorSemiring (α) [OrderedSemiring α] where /-- `FloorSemiring.floor a` computes the greatest natural `n` such that `(n : α) ≤ a`. -/ floor : α → ℕ /-- `FloorSemiring.ceil a` computes the least natural `n` such that `a ≤ (n : α)`. -/ ceil : α → ℕ /-- `FloorSemiring.floor` of a negative element is zero. -/ floor_of_neg {a : α} (ha : a < 0) : floor a = 0 /-- A natural number `n` is smaller than `FloorSemiring.floor a` iff its coercion to `α` is smaller than `a`. -/ gc_floor {a : α} {n : ℕ} (ha : 0 ≤ a) : n ≤ floor a ↔ (n : α) ≤ a /-- `FloorSemiring.ceil` is the lower adjoint of the coercion `↑ : ℕ → α`. -/ gc_ceil : GaloisConnection ceil (↑) #align floor_semiring FloorSemiring instance : FloorSemiring ℕ where floor := id ceil := id floor_of_neg ha := (Nat.not_lt_zero _ ha).elim gc_floor _ := by rw [Nat.cast_id] rfl gc_ceil n a := by rw [Nat.cast_id] rfl namespace Nat section OrderedSemiring variable [OrderedSemiring α] [FloorSemiring α] {a : α} {n : ℕ} /-- `⌊a⌋₊` is the greatest natural `n` such that `n ≤ a`. If `a` is negative, then `⌊a⌋₊ = 0`. -/ def floor : α → ℕ := FloorSemiring.floor #align nat.floor Nat.floor /-- `⌈a⌉₊` is the least natural `n` such that `a ≤ n` -/ def ceil : α → ℕ := FloorSemiring.ceil #align nat.ceil Nat.ceil @[simp] theorem floor_nat : (Nat.floor : ℕ → ℕ) = id := rfl #align nat.floor_nat Nat.floor_nat @[simp] theorem ceil_nat : (Nat.ceil : ℕ → ℕ) = id := rfl #align nat.ceil_nat Nat.ceil_nat @[inherit_doc] notation "⌊" a "⌋₊" => Nat.floor a @[inherit_doc] notation "⌈" a "⌉₊" => Nat.ceil a end OrderedSemiring section LinearOrderedSemiring variable [LinearOrderedSemiring α] [FloorSemiring α] {a : α} {n : ℕ} theorem le_floor_iff (ha : 0 ≤ a) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := FloorSemiring.gc_floor ha #align nat.le_floor_iff Nat.le_floor_iff theorem le_floor (h : (n : α) ≤ a) : n ≤ ⌊a⌋₊ := (le_floor_iff <| n.cast_nonneg.trans h).2 h #align nat.le_floor Nat.le_floor theorem floor_lt (ha : 0 ≤ a) : ⌊a⌋₊ < n ↔ a < n := lt_iff_lt_of_le_iff_le <| le_floor_iff ha #align nat.floor_lt Nat.floor_lt theorem floor_lt_one (ha : 0 ≤ a) : ⌊a⌋₊ < 1 ↔ a < 1 := (floor_lt ha).trans <| by rw [Nat.cast_one] #align nat.floor_lt_one Nat.floor_lt_one theorem lt_of_floor_lt (h : ⌊a⌋₊ < n) : a < n := lt_of_not_le fun h' => (le_floor h').not_lt h #align nat.lt_of_floor_lt Nat.lt_of_floor_lt theorem lt_one_of_floor_lt_one (h : ⌊a⌋₊ < 1) : a < 1 := mod_cast lt_of_floor_lt h #align nat.lt_one_of_floor_lt_one Nat.lt_one_of_floor_lt_one theorem floor_le (ha : 0 ≤ a) : (⌊a⌋₊ : α) ≤ a := (le_floor_iff ha).1 le_rfl #align nat.floor_le Nat.floor_le theorem lt_succ_floor (a : α) : a < ⌊a⌋₊.succ := lt_of_floor_lt <| Nat.lt_succ_self _ #align nat.lt_succ_floor Nat.lt_succ_floor theorem lt_floor_add_one (a : α) : a < ⌊a⌋₊ + 1 := by simpa using lt_succ_floor a #align nat.lt_floor_add_one Nat.lt_floor_add_one @[simp] theorem floor_natCast (n : ℕ) : ⌊(n : α)⌋₊ = n := eq_of_forall_le_iff fun a => by rw [le_floor_iff, Nat.cast_le] exact n.cast_nonneg #align nat.floor_coe Nat.floor_natCast @[deprecated (since := "2024-06-08")] alias floor_coe := floor_natCast @[simp] theorem floor_zero : ⌊(0 : α)⌋₊ = 0 := by rw [← Nat.cast_zero, floor_natCast] #align nat.floor_zero Nat.floor_zero @[simp] theorem floor_one : ⌊(1 : α)⌋₊ = 1 := by rw [← Nat.cast_one, floor_natCast] #align nat.floor_one Nat.floor_one -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_ofNat (n : ℕ) [n.AtLeastTwo] : ⌊no_index (OfNat.ofNat n : α)⌋₊ = n := Nat.floor_natCast _ theorem floor_of_nonpos (ha : a ≤ 0) : ⌊a⌋₊ = 0 := ha.lt_or_eq.elim FloorSemiring.floor_of_neg <| by rintro rfl exact floor_zero #align nat.floor_of_nonpos Nat.floor_of_nonpos theorem floor_mono : Monotone (floor : α → ℕ) := fun a b h => by obtain ha | ha := le_total a 0 · rw [floor_of_nonpos ha] exact Nat.zero_le _ · exact le_floor ((floor_le ha).trans h) #align nat.floor_mono Nat.floor_mono @[gcongr] theorem floor_le_floor : ∀ x y : α, x ≤ y → ⌊x⌋₊ ≤ ⌊y⌋₊ := floor_mono theorem le_floor_iff' (hn : n ≠ 0) : n ≤ ⌊a⌋₊ ↔ (n : α) ≤ a := by obtain ha | ha := le_total a 0 · rw [floor_of_nonpos ha] exact iff_of_false (Nat.pos_of_ne_zero hn).not_le (not_le_of_lt <| ha.trans_lt <| cast_pos.2 <| Nat.pos_of_ne_zero hn) · exact le_floor_iff ha #align nat.le_floor_iff' Nat.le_floor_iff' @[simp] theorem one_le_floor_iff (x : α) : 1 ≤ ⌊x⌋₊ ↔ 1 ≤ x := mod_cast @le_floor_iff' α _ _ x 1 one_ne_zero #align nat.one_le_floor_iff Nat.one_le_floor_iff theorem floor_lt' (hn : n ≠ 0) : ⌊a⌋₊ < n ↔ a < n := lt_iff_lt_of_le_iff_le <| le_floor_iff' hn #align nat.floor_lt' Nat.floor_lt' theorem floor_pos : 0 < ⌊a⌋₊ ↔ 1 ≤ a := by -- Porting note: broken `convert le_floor_iff' Nat.one_ne_zero` rw [Nat.lt_iff_add_one_le, zero_add, le_floor_iff' Nat.one_ne_zero, cast_one] #align nat.floor_pos Nat.floor_pos theorem pos_of_floor_pos (h : 0 < ⌊a⌋₊) : 0 < a := (le_or_lt a 0).resolve_left fun ha => lt_irrefl 0 <| by rwa [floor_of_nonpos ha] at h #align nat.pos_of_floor_pos Nat.pos_of_floor_pos theorem lt_of_lt_floor (h : n < ⌊a⌋₊) : ↑n < a := (Nat.cast_lt.2 h).trans_le <| floor_le (pos_of_floor_pos <| (Nat.zero_le n).trans_lt h).le #align nat.lt_of_lt_floor Nat.lt_of_lt_floor theorem floor_le_of_le (h : a ≤ n) : ⌊a⌋₊ ≤ n := le_imp_le_iff_lt_imp_lt.2 lt_of_lt_floor h #align nat.floor_le_of_le Nat.floor_le_of_le theorem floor_le_one_of_le_one (h : a ≤ 1) : ⌊a⌋₊ ≤ 1 := floor_le_of_le <| h.trans_eq <| Nat.cast_one.symm #align nat.floor_le_one_of_le_one Nat.floor_le_one_of_le_one @[simp] theorem floor_eq_zero : ⌊a⌋₊ = 0 ↔ a < 1 := by rw [← lt_one_iff, ← @cast_one α] exact floor_lt' Nat.one_ne_zero #align nat.floor_eq_zero Nat.floor_eq_zero theorem floor_eq_iff (ha : 0 ≤ a) : ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1 := by rw [← le_floor_iff ha, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt ha, Nat.lt_add_one_iff, le_antisymm_iff, and_comm] #align nat.floor_eq_iff Nat.floor_eq_iff theorem floor_eq_iff' (hn : n ≠ 0) : ⌊a⌋₊ = n ↔ ↑n ≤ a ∧ a < ↑n + 1 := by rw [← le_floor_iff' hn, ← Nat.cast_one, ← Nat.cast_add, ← floor_lt' (Nat.add_one_ne_zero n), Nat.lt_add_one_iff, le_antisymm_iff, and_comm] #align nat.floor_eq_iff' Nat.floor_eq_iff' theorem floor_eq_on_Ico (n : ℕ) : ∀ a ∈ (Set.Ico n (n + 1) : Set α), ⌊a⌋₊ = n := fun _ ⟨h₀, h₁⟩ => (floor_eq_iff <| n.cast_nonneg.trans h₀).mpr ⟨h₀, h₁⟩ #align nat.floor_eq_on_Ico Nat.floor_eq_on_Ico theorem floor_eq_on_Ico' (n : ℕ) : ∀ a ∈ (Set.Ico n (n + 1) : Set α), (⌊a⌋₊ : α) = n := fun x hx => mod_cast floor_eq_on_Ico n x hx #align nat.floor_eq_on_Ico' Nat.floor_eq_on_Ico' @[simp] theorem preimage_floor_zero : (floor : α → ℕ) ⁻¹' {0} = Iio 1 := ext fun _ => floor_eq_zero #align nat.preimage_floor_zero Nat.preimage_floor_zero -- Porting note: in mathlib3 there was no need for the type annotation in `(n:α)` theorem preimage_floor_of_ne_zero {n : ℕ} (hn : n ≠ 0) : (floor : α → ℕ) ⁻¹' {n} = Ico (n:α) (n + 1) := ext fun _ => floor_eq_iff' hn #align nat.preimage_floor_of_ne_zero Nat.preimage_floor_of_ne_zero /-! #### Ceil -/ theorem gc_ceil_coe : GaloisConnection (ceil : α → ℕ) (↑) := FloorSemiring.gc_ceil #align nat.gc_ceil_coe Nat.gc_ceil_coe @[simp] theorem ceil_le : ⌈a⌉₊ ≤ n ↔ a ≤ n := gc_ceil_coe _ _ #align nat.ceil_le Nat.ceil_le theorem lt_ceil : n < ⌈a⌉₊ ↔ (n : α) < a := lt_iff_lt_of_le_iff_le ceil_le #align nat.lt_ceil Nat.lt_ceil -- porting note (#10618): simp can prove this -- @[simp] theorem add_one_le_ceil_iff : n + 1 ≤ ⌈a⌉₊ ↔ (n : α) < a := by rw [← Nat.lt_ceil, Nat.add_one_le_iff] #align nat.add_one_le_ceil_iff Nat.add_one_le_ceil_iff @[simp] theorem one_le_ceil_iff : 1 ≤ ⌈a⌉₊ ↔ 0 < a := by rw [← zero_add 1, Nat.add_one_le_ceil_iff, Nat.cast_zero] #align nat.one_le_ceil_iff Nat.one_le_ceil_iff theorem ceil_le_floor_add_one (a : α) : ⌈a⌉₊ ≤ ⌊a⌋₊ + 1 := by rw [ceil_le, Nat.cast_add, Nat.cast_one] exact (lt_floor_add_one a).le #align nat.ceil_le_floor_add_one Nat.ceil_le_floor_add_one theorem le_ceil (a : α) : a ≤ ⌈a⌉₊ := ceil_le.1 le_rfl #align nat.le_ceil Nat.le_ceil @[simp] theorem ceil_intCast {α : Type*} [LinearOrderedRing α] [FloorSemiring α] (z : ℤ) : ⌈(z : α)⌉₊ = z.toNat := eq_of_forall_ge_iff fun a => by simp only [ceil_le, Int.toNat_le] norm_cast #align nat.ceil_int_cast Nat.ceil_intCast @[simp] theorem ceil_natCast (n : ℕ) : ⌈(n : α)⌉₊ = n := eq_of_forall_ge_iff fun a => by rw [ceil_le, cast_le] #align nat.ceil_nat_cast Nat.ceil_natCast theorem ceil_mono : Monotone (ceil : α → ℕ) := gc_ceil_coe.monotone_l #align nat.ceil_mono Nat.ceil_mono @[gcongr] theorem ceil_le_ceil : ∀ x y : α, x ≤ y → ⌈x⌉₊ ≤ ⌈y⌉₊ := ceil_mono @[simp] theorem ceil_zero : ⌈(0 : α)⌉₊ = 0 := by rw [← Nat.cast_zero, ceil_natCast] #align nat.ceil_zero Nat.ceil_zero @[simp] theorem ceil_one : ⌈(1 : α)⌉₊ = 1 := by rw [← Nat.cast_one, ceil_natCast] #align nat.ceil_one Nat.ceil_one -- See note [no_index around OfNat.ofNat] @[simp] theorem ceil_ofNat (n : ℕ) [n.AtLeastTwo] : ⌈no_index (OfNat.ofNat n : α)⌉₊ = n := ceil_natCast n @[simp] theorem ceil_eq_zero : ⌈a⌉₊ = 0 ↔ a ≤ 0 := by rw [← Nat.le_zero, ceil_le, Nat.cast_zero] #align nat.ceil_eq_zero Nat.ceil_eq_zero @[simp] theorem ceil_pos : 0 < ⌈a⌉₊ ↔ 0 < a := by rw [lt_ceil, cast_zero] #align nat.ceil_pos Nat.ceil_pos theorem lt_of_ceil_lt (h : ⌈a⌉₊ < n) : a < n := (le_ceil a).trans_lt (Nat.cast_lt.2 h) #align nat.lt_of_ceil_lt Nat.lt_of_ceil_lt theorem le_of_ceil_le (h : ⌈a⌉₊ ≤ n) : a ≤ n := (le_ceil a).trans (Nat.cast_le.2 h) #align nat.le_of_ceil_le Nat.le_of_ceil_le theorem floor_le_ceil (a : α) : ⌊a⌋₊ ≤ ⌈a⌉₊ := by obtain ha | ha := le_total a 0 · rw [floor_of_nonpos ha] exact Nat.zero_le _ · exact cast_le.1 ((floor_le ha).trans <| le_ceil _) #align nat.floor_le_ceil Nat.floor_le_ceil theorem floor_lt_ceil_of_lt_of_pos {a b : α} (h : a < b) (h' : 0 < b) : ⌊a⌋₊ < ⌈b⌉₊ := by rcases le_or_lt 0 a with (ha | ha) · rw [floor_lt ha] exact h.trans_le (le_ceil _) · rwa [floor_of_nonpos ha.le, lt_ceil, Nat.cast_zero] #align nat.floor_lt_ceil_of_lt_of_pos Nat.floor_lt_ceil_of_lt_of_pos theorem ceil_eq_iff (hn : n ≠ 0) : ⌈a⌉₊ = n ↔ ↑(n - 1) < a ∧ a ≤ n := by rw [← ceil_le, ← not_le, ← ceil_le, not_le, tsub_lt_iff_right (Nat.add_one_le_iff.2 (pos_iff_ne_zero.2 hn)), Nat.lt_add_one_iff, le_antisymm_iff, and_comm] #align nat.ceil_eq_iff Nat.ceil_eq_iff @[simp] theorem preimage_ceil_zero : (Nat.ceil : α → ℕ) ⁻¹' {0} = Iic 0 := ext fun _ => ceil_eq_zero #align nat.preimage_ceil_zero Nat.preimage_ceil_zero -- Porting note: in mathlib3 there was no need for the type annotation in `(↑(n - 1))` theorem preimage_ceil_of_ne_zero (hn : n ≠ 0) : (Nat.ceil : α → ℕ) ⁻¹' {n} = Ioc (↑(n - 1) : α) n := ext fun _ => ceil_eq_iff hn #align nat.preimage_ceil_of_ne_zero Nat.preimage_ceil_of_ne_zero /-! #### Intervals -/ -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Ioo {a b : α} (ha : 0 ≤ a) : (Nat.cast : ℕ → α) ⁻¹' Set.Ioo a b = Set.Ioo ⌊a⌋₊ ⌈b⌉₊ := by ext simp [floor_lt, lt_ceil, ha] #align nat.preimage_Ioo Nat.preimage_Ioo -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Ico {a b : α} : (Nat.cast : ℕ → α) ⁻¹' Set.Ico a b = Set.Ico ⌈a⌉₊ ⌈b⌉₊ := by ext simp [ceil_le, lt_ceil] #align nat.preimage_Ico Nat.preimage_Ico -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Ioc {a b : α} (ha : 0 ≤ a) (hb : 0 ≤ b) : (Nat.cast : ℕ → α) ⁻¹' Set.Ioc a b = Set.Ioc ⌊a⌋₊ ⌊b⌋₊ := by ext simp [floor_lt, le_floor_iff, hb, ha] #align nat.preimage_Ioc Nat.preimage_Ioc -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Icc {a b : α} (hb : 0 ≤ b) : (Nat.cast : ℕ → α) ⁻¹' Set.Icc a b = Set.Icc ⌈a⌉₊ ⌊b⌋₊ := by ext simp [ceil_le, hb, le_floor_iff] #align nat.preimage_Icc Nat.preimage_Icc -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Ioi {a : α} (ha : 0 ≤ a) : (Nat.cast : ℕ → α) ⁻¹' Set.Ioi a = Set.Ioi ⌊a⌋₊ := by ext simp [floor_lt, ha] #align nat.preimage_Ioi Nat.preimage_Ioi -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Ici {a : α} : (Nat.cast : ℕ → α) ⁻¹' Set.Ici a = Set.Ici ⌈a⌉₊ := by ext simp [ceil_le] #align nat.preimage_Ici Nat.preimage_Ici -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Iio {a : α} : (Nat.cast : ℕ → α) ⁻¹' Set.Iio a = Set.Iio ⌈a⌉₊ := by ext simp [lt_ceil] #align nat.preimage_Iio Nat.preimage_Iio -- Porting note: changed `(coe : ℕ → α)` to `(Nat.cast : ℕ → α)` @[simp] theorem preimage_Iic {a : α} (ha : 0 ≤ a) : (Nat.cast : ℕ → α) ⁻¹' Set.Iic a = Set.Iic ⌊a⌋₊ := by ext simp [le_floor_iff, ha] #align nat.preimage_Iic Nat.preimage_Iic theorem floor_add_nat (ha : 0 ≤ a) (n : ℕ) : ⌊a + n⌋₊ = ⌊a⌋₊ + n := eq_of_forall_le_iff fun b => by rw [le_floor_iff (add_nonneg ha n.cast_nonneg)] obtain hb | hb := le_total n b · obtain ⟨d, rfl⟩ := exists_add_of_le hb rw [Nat.cast_add, add_comm n, add_comm (n : α), add_le_add_iff_right, add_le_add_iff_right, le_floor_iff ha] · obtain ⟨d, rfl⟩ := exists_add_of_le hb rw [Nat.cast_add, add_left_comm _ b, add_left_comm _ (b : α)] refine iff_of_true ?_ le_self_add exact le_add_of_nonneg_right <| ha.trans <| le_add_of_nonneg_right d.cast_nonneg #align nat.floor_add_nat Nat.floor_add_nat theorem floor_add_one (ha : 0 ≤ a) : ⌊a + 1⌋₊ = ⌊a⌋₊ + 1 := by -- Porting note: broken `convert floor_add_nat ha 1` rw [← cast_one, floor_add_nat ha 1] #align nat.floor_add_one Nat.floor_add_one -- See note [no_index around OfNat.ofNat] theorem floor_add_ofNat (ha : 0 ≤ a) (n : ℕ) [n.AtLeastTwo] : ⌊a + (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ + OfNat.ofNat n := floor_add_nat ha n @[simp] theorem floor_sub_nat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n : ℕ) : ⌊a - n⌋₊ = ⌊a⌋₊ - n := by obtain ha | ha := le_total a 0 · rw [floor_of_nonpos ha, floor_of_nonpos (tsub_nonpos_of_le (ha.trans n.cast_nonneg)), zero_tsub] rcases le_total a n with h | h · rw [floor_of_nonpos (tsub_nonpos_of_le h), eq_comm, tsub_eq_zero_iff_le] exact Nat.cast_le.1 ((Nat.floor_le ha).trans h) · rw [eq_tsub_iff_add_eq_of_le (le_floor h), ← floor_add_nat _, tsub_add_cancel_of_le h] exact le_tsub_of_add_le_left ((add_zero _).trans_le h) #align nat.floor_sub_nat Nat.floor_sub_nat @[simp] theorem floor_sub_one [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) : ⌊a - 1⌋₊ = ⌊a⌋₊ - 1 := mod_cast floor_sub_nat a 1 -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_sub_ofNat [Sub α] [OrderedSub α] [ExistsAddOfLE α] (a : α) (n : ℕ) [n.AtLeastTwo] : ⌊a - (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ - OfNat.ofNat n := floor_sub_nat a n theorem ceil_add_nat (ha : 0 ≤ a) (n : ℕ) : ⌈a + n⌉₊ = ⌈a⌉₊ + n := eq_of_forall_ge_iff fun b => by rw [← not_lt, ← not_lt, not_iff_not, lt_ceil] obtain hb | hb := le_or_lt n b · obtain ⟨d, rfl⟩ := exists_add_of_le hb rw [Nat.cast_add, add_comm n, add_comm (n : α), add_lt_add_iff_right, add_lt_add_iff_right, lt_ceil] · exact iff_of_true (lt_add_of_nonneg_of_lt ha <| cast_lt.2 hb) (Nat.lt_add_left _ hb) #align nat.ceil_add_nat Nat.ceil_add_nat theorem ceil_add_one (ha : 0 ≤ a) : ⌈a + 1⌉₊ = ⌈a⌉₊ + 1 := by -- Porting note: broken `convert ceil_add_nat ha 1` rw [cast_one.symm, ceil_add_nat ha 1] #align nat.ceil_add_one Nat.ceil_add_one -- See note [no_index around OfNat.ofNat] theorem ceil_add_ofNat (ha : 0 ≤ a) (n : ℕ) [n.AtLeastTwo] : ⌈a + (no_index (OfNat.ofNat n))⌉₊ = ⌈a⌉₊ + OfNat.ofNat n := ceil_add_nat ha n theorem ceil_lt_add_one (ha : 0 ≤ a) : (⌈a⌉₊ : α) < a + 1 := lt_ceil.1 <| (Nat.lt_succ_self _).trans_le (ceil_add_one ha).ge #align nat.ceil_lt_add_one Nat.ceil_lt_add_one theorem ceil_add_le (a b : α) : ⌈a + b⌉₊ ≤ ⌈a⌉₊ + ⌈b⌉₊ := by rw [ceil_le, Nat.cast_add] exact _root_.add_le_add (le_ceil _) (le_ceil _) #align nat.ceil_add_le Nat.ceil_add_le end LinearOrderedSemiring section LinearOrderedRing variable [LinearOrderedRing α] [FloorSemiring α] theorem sub_one_lt_floor (a : α) : a - 1 < ⌊a⌋₊ := sub_lt_iff_lt_add.2 <| lt_floor_add_one a #align nat.sub_one_lt_floor Nat.sub_one_lt_floor end LinearOrderedRing section LinearOrderedSemifield variable [LinearOrderedSemifield α] [FloorSemiring α] -- TODO: should these lemmas be `simp`? `norm_cast`? theorem floor_div_nat (a : α) (n : ℕ) : ⌊a / n⌋₊ = ⌊a⌋₊ / n := by rcases le_total a 0 with ha | ha · rw [floor_of_nonpos, floor_of_nonpos ha] · simp apply div_nonpos_of_nonpos_of_nonneg ha n.cast_nonneg obtain rfl | hn := n.eq_zero_or_pos · rw [cast_zero, div_zero, Nat.div_zero, floor_zero] refine (floor_eq_iff ?_).2 ?_ · exact div_nonneg ha n.cast_nonneg constructor · exact cast_div_le.trans (div_le_div_of_nonneg_right (floor_le ha) n.cast_nonneg) rw [div_lt_iff, add_mul, one_mul, ← cast_mul, ← cast_add, ← floor_lt ha] · exact lt_div_mul_add hn · exact cast_pos.2 hn #align nat.floor_div_nat Nat.floor_div_nat -- See note [no_index around OfNat.ofNat] theorem floor_div_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌊a / (no_index (OfNat.ofNat n))⌋₊ = ⌊a⌋₊ / OfNat.ofNat n := floor_div_nat a n /-- Natural division is the floor of field division. -/ theorem floor_div_eq_div (m n : ℕ) : ⌊(m : α) / n⌋₊ = m / n := by convert floor_div_nat (m : α) n rw [m.floor_natCast] #align nat.floor_div_eq_div Nat.floor_div_eq_div end LinearOrderedSemifield end Nat /-- There exists at most one `FloorSemiring` structure on a linear ordered semiring. -/ theorem subsingleton_floorSemiring {α} [LinearOrderedSemiring α] : Subsingleton (FloorSemiring α) := by refine ⟨fun H₁ H₂ => ?_⟩ have : H₁.ceil = H₂.ceil := funext fun a => (H₁.gc_ceil.l_unique H₂.gc_ceil) fun n => rfl have : H₁.floor = H₂.floor := by ext a cases' lt_or_le a 0 with h h · rw [H₁.floor_of_neg, H₂.floor_of_neg] <;> exact h · refine eq_of_forall_le_iff fun n => ?_ rw [H₁.gc_floor, H₂.gc_floor] <;> exact h cases H₁ cases H₂ congr #align subsingleton_floor_semiring subsingleton_floorSemiring /-! ### Floor rings -/ /-- A `FloorRing` is a linear ordered ring over `α` with a function `floor : α → ℤ` satisfying `∀ (z : ℤ) (a : α), z ≤ floor a ↔ (z : α) ≤ a)`. -/ class FloorRing (α) [LinearOrderedRing α] where /-- `FloorRing.floor a` computes the greatest integer `z` such that `(z : α) ≤ a`. -/ floor : α → ℤ /-- `FloorRing.ceil a` computes the least integer `z` such that `a ≤ (z : α)`. -/ ceil : α → ℤ /-- `FloorRing.ceil` is the upper adjoint of the coercion `↑ : ℤ → α`. -/ gc_coe_floor : GaloisConnection (↑) floor /-- `FloorRing.ceil` is the lower adjoint of the coercion `↑ : ℤ → α`. -/ gc_ceil_coe : GaloisConnection ceil (↑) #align floor_ring FloorRing instance : FloorRing ℤ where floor := id ceil := id gc_coe_floor a b := by rw [Int.cast_id] rfl gc_ceil_coe a b := by rw [Int.cast_id] rfl /-- A `FloorRing` constructor from the `floor` function alone. -/ def FloorRing.ofFloor (α) [LinearOrderedRing α] (floor : α → ℤ) (gc_coe_floor : GaloisConnection (↑) floor) : FloorRing α := { floor ceil := fun a => -floor (-a) gc_coe_floor gc_ceil_coe := fun a z => by rw [neg_le, ← gc_coe_floor, Int.cast_neg, neg_le_neg_iff] } #align floor_ring.of_floor FloorRing.ofFloor /-- A `FloorRing` constructor from the `ceil` function alone. -/ def FloorRing.ofCeil (α) [LinearOrderedRing α] (ceil : α → ℤ) (gc_ceil_coe : GaloisConnection ceil (↑)) : FloorRing α := { floor := fun a => -ceil (-a) ceil gc_coe_floor := fun a z => by rw [le_neg, gc_ceil_coe, Int.cast_neg, neg_le_neg_iff] gc_ceil_coe } #align floor_ring.of_ceil FloorRing.ofCeil namespace Int variable [LinearOrderedRing α] [FloorRing α] {z : ℤ} {a : α} /-- `Int.floor a` is the greatest integer `z` such that `z ≤ a`. It is denoted with `⌊a⌋`. -/ def floor : α → ℤ := FloorRing.floor #align int.floor Int.floor /-- `Int.ceil a` is the smallest integer `z` such that `a ≤ z`. It is denoted with `⌈a⌉`. -/ def ceil : α → ℤ := FloorRing.ceil #align int.ceil Int.ceil /-- `Int.fract a`, the fractional part of `a`, is `a` minus its floor. -/ def fract (a : α) : α := a - floor a #align int.fract Int.fract @[simp] theorem floor_int : (Int.floor : ℤ → ℤ) = id := rfl #align int.floor_int Int.floor_int @[simp] theorem ceil_int : (Int.ceil : ℤ → ℤ) = id := rfl #align int.ceil_int Int.ceil_int @[simp] theorem fract_int : (Int.fract : ℤ → ℤ) = 0 := funext fun x => by simp [fract] #align int.fract_int Int.fract_int @[inherit_doc] notation "⌊" a "⌋" => Int.floor a @[inherit_doc] notation "⌈" a "⌉" => Int.ceil a -- Mathematical notation for `fract a` is usually `{a}`. Let's not even go there. @[simp] theorem floorRing_floor_eq : @FloorRing.floor = @Int.floor := rfl #align int.floor_ring_floor_eq Int.floorRing_floor_eq @[simp] theorem floorRing_ceil_eq : @FloorRing.ceil = @Int.ceil := rfl #align int.floor_ring_ceil_eq Int.floorRing_ceil_eq /-! #### Floor -/ theorem gc_coe_floor : GaloisConnection ((↑) : ℤ → α) floor := FloorRing.gc_coe_floor #align int.gc_coe_floor Int.gc_coe_floor theorem le_floor : z ≤ ⌊a⌋ ↔ (z : α) ≤ a := (gc_coe_floor z a).symm #align int.le_floor Int.le_floor theorem floor_lt : ⌊a⌋ < z ↔ a < z := lt_iff_lt_of_le_iff_le le_floor #align int.floor_lt Int.floor_lt theorem floor_le (a : α) : (⌊a⌋ : α) ≤ a := gc_coe_floor.l_u_le a #align int.floor_le Int.floor_le theorem floor_nonneg : 0 ≤ ⌊a⌋ ↔ 0 ≤ a := by rw [le_floor, Int.cast_zero] #align int.floor_nonneg Int.floor_nonneg @[simp] theorem floor_le_sub_one_iff : ⌊a⌋ ≤ z - 1 ↔ a < z := by rw [← floor_lt, le_sub_one_iff] #align int.floor_le_sub_one_iff Int.floor_le_sub_one_iff @[simp] theorem floor_le_neg_one_iff : ⌊a⌋ ≤ -1 ↔ a < 0 := by rw [← zero_sub (1 : ℤ), floor_le_sub_one_iff, cast_zero] #align int.floor_le_neg_one_iff Int.floor_le_neg_one_iff theorem floor_nonpos (ha : a ≤ 0) : ⌊a⌋ ≤ 0 := by rw [← @cast_le α, Int.cast_zero] exact (floor_le a).trans ha #align int.floor_nonpos Int.floor_nonpos theorem lt_succ_floor (a : α) : a < ⌊a⌋.succ := floor_lt.1 <| Int.lt_succ_self _ #align int.lt_succ_floor Int.lt_succ_floor @[simp] theorem lt_floor_add_one (a : α) : a < ⌊a⌋ + 1 := by simpa only [Int.succ, Int.cast_add, Int.cast_one] using lt_succ_floor a #align int.lt_floor_add_one Int.lt_floor_add_one @[simp] theorem sub_one_lt_floor (a : α) : a - 1 < ⌊a⌋ := sub_lt_iff_lt_add.2 (lt_floor_add_one a) #align int.sub_one_lt_floor Int.sub_one_lt_floor @[simp] theorem floor_intCast (z : ℤ) : ⌊(z : α)⌋ = z := eq_of_forall_le_iff fun a => by rw [le_floor, Int.cast_le] #align int.floor_int_cast Int.floor_intCast @[simp] theorem floor_natCast (n : ℕ) : ⌊(n : α)⌋ = n := eq_of_forall_le_iff fun a => by rw [le_floor, ← cast_natCast, cast_le] #align int.floor_nat_cast Int.floor_natCast @[simp] theorem floor_zero : ⌊(0 : α)⌋ = 0 := by rw [← cast_zero, floor_intCast] #align int.floor_zero Int.floor_zero @[simp] theorem floor_one : ⌊(1 : α)⌋ = 1 := by rw [← cast_one, floor_intCast] #align int.floor_one Int.floor_one -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_ofNat (n : ℕ) [n.AtLeastTwo] : ⌊(no_index (OfNat.ofNat n : α))⌋ = n := floor_natCast n @[mono] theorem floor_mono : Monotone (floor : α → ℤ) := gc_coe_floor.monotone_u #align int.floor_mono Int.floor_mono @[gcongr] theorem floor_le_floor : ∀ x y : α, x ≤ y → ⌊x⌋ ≤ ⌊y⌋ := floor_mono theorem floor_pos : 0 < ⌊a⌋ ↔ 1 ≤ a := by -- Porting note: broken `convert le_floor` rw [Int.lt_iff_add_one_le, zero_add, le_floor, cast_one] #align int.floor_pos Int.floor_pos @[simp] theorem floor_add_int (a : α) (z : ℤ) : ⌊a + z⌋ = ⌊a⌋ + z := eq_of_forall_le_iff fun a => by rw [le_floor, ← sub_le_iff_le_add, ← sub_le_iff_le_add, le_floor, Int.cast_sub] #align int.floor_add_int Int.floor_add_int @[simp] theorem floor_add_one (a : α) : ⌊a + 1⌋ = ⌊a⌋ + 1 := by -- Porting note: broken `convert floor_add_int a 1` rw [← cast_one, floor_add_int] #align int.floor_add_one Int.floor_add_one theorem le_floor_add (a b : α) : ⌊a⌋ + ⌊b⌋ ≤ ⌊a + b⌋ := by rw [le_floor, Int.cast_add] exact add_le_add (floor_le _) (floor_le _) #align int.le_floor_add Int.le_floor_add theorem le_floor_add_floor (a b : α) : ⌊a + b⌋ - 1 ≤ ⌊a⌋ + ⌊b⌋ := by rw [← sub_le_iff_le_add, le_floor, Int.cast_sub, sub_le_comm, Int.cast_sub, Int.cast_one] refine le_trans ?_ (sub_one_lt_floor _).le rw [sub_le_iff_le_add', ← add_sub_assoc, sub_le_sub_iff_right] exact floor_le _ #align int.le_floor_add_floor Int.le_floor_add_floor @[simp] theorem floor_int_add (z : ℤ) (a : α) : ⌊↑z + a⌋ = z + ⌊a⌋ := by simpa only [add_comm] using floor_add_int a z #align int.floor_int_add Int.floor_int_add @[simp] theorem floor_add_nat (a : α) (n : ℕ) : ⌊a + n⌋ = ⌊a⌋ + n := by rw [← Int.cast_natCast, floor_add_int] #align int.floor_add_nat Int.floor_add_nat -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_add_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌊a + (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ + OfNat.ofNat n := floor_add_nat a n @[simp] theorem floor_nat_add (n : ℕ) (a : α) : ⌊↑n + a⌋ = n + ⌊a⌋ := by rw [← Int.cast_natCast, floor_int_add] #align int.floor_nat_add Int.floor_nat_add -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_ofNat_add (n : ℕ) [n.AtLeastTwo] (a : α) : ⌊(no_index (OfNat.ofNat n)) + a⌋ = OfNat.ofNat n + ⌊a⌋ := floor_nat_add n a @[simp] theorem floor_sub_int (a : α) (z : ℤ) : ⌊a - z⌋ = ⌊a⌋ - z := Eq.trans (by rw [Int.cast_neg, sub_eq_add_neg]) (floor_add_int _ _) #align int.floor_sub_int Int.floor_sub_int @[simp] theorem floor_sub_nat (a : α) (n : ℕ) : ⌊a - n⌋ = ⌊a⌋ - n := by rw [← Int.cast_natCast, floor_sub_int] #align int.floor_sub_nat Int.floor_sub_nat @[simp] theorem floor_sub_one (a : α) : ⌊a - 1⌋ = ⌊a⌋ - 1 := mod_cast floor_sub_nat a 1 -- See note [no_index around OfNat.ofNat] @[simp] theorem floor_sub_ofNat (a : α) (n : ℕ) [n.AtLeastTwo] : ⌊a - (no_index (OfNat.ofNat n))⌋ = ⌊a⌋ - OfNat.ofNat n := floor_sub_nat a n theorem abs_sub_lt_one_of_floor_eq_floor {α : Type*} [LinearOrderedCommRing α] [FloorRing α] {a b : α} (h : ⌊a⌋ = ⌊b⌋) : |a - b| < 1 := by have : a < ⌊a⌋ + 1 := lt_floor_add_one a have : b < ⌊b⌋ + 1 := lt_floor_add_one b have : (⌊a⌋ : α) = ⌊b⌋ := Int.cast_inj.2 h have : (⌊a⌋ : α) ≤ a := floor_le a have : (⌊b⌋ : α) ≤ b := floor_le b exact abs_sub_lt_iff.2 ⟨by linarith, by linarith⟩ #align int.abs_sub_lt_one_of_floor_eq_floor Int.abs_sub_lt_one_of_floor_eq_floor
Mathlib/Algebra/Order/Floor.lean
851
853
theorem floor_eq_iff : ⌊a⌋ = z ↔ ↑z ≤ a ∧ a < z + 1 := by
rw [le_antisymm_iff, le_floor, ← Int.lt_add_one_iff, floor_lt, Int.cast_add, Int.cast_one, and_comm]
/- Copyright (c) 2021 Hunter Monroe. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Hunter Monroe, Kyle Miller, Alena Gusakov -/ import Mathlib.Combinatorics.SimpleGraph.Finite import Mathlib.Combinatorics.SimpleGraph.Maps #align_import combinatorics.simple_graph.subgraph from "leanprover-community/mathlib"@"c6ef6387ede9983aee397d442974e61f89dfd87b" /-! # Subgraphs of a simple graph A subgraph of a simple graph consists of subsets of the graph's vertices and edges such that the endpoints of each edge are present in the vertex subset. The edge subset is formalized as a sub-relation of the adjacency relation of the simple graph. ## Main definitions * `Subgraph G` is the type of subgraphs of a `G : SimpleGraph V`. * `Subgraph.neighborSet`, `Subgraph.incidenceSet`, and `Subgraph.degree` are like their `SimpleGraph` counterparts, but they refer to vertices from `G` to avoid subtype coercions. * `Subgraph.coe` is the coercion from a `G' : Subgraph G` to a `SimpleGraph G'.verts`. (In Lean 3 this could not be a `Coe` instance since the destination type depends on `G'`.) * `Subgraph.IsSpanning` for whether a subgraph is a spanning subgraph and `Subgraph.IsInduced` for whether a subgraph is an induced subgraph. * Instances for `Lattice (Subgraph G)` and `BoundedOrder (Subgraph G)`. * `SimpleGraph.toSubgraph`: If a `SimpleGraph` is a subgraph of another, then you can turn it into a member of the larger graph's `SimpleGraph.Subgraph` type. * Graph homomorphisms from a subgraph to a graph (`Subgraph.map_top`) and between subgraphs (`Subgraph.map`). ## Implementation notes * Recall that subgraphs are not determined by their vertex sets, so `SetLike` does not apply to this kind of subobject. ## Todo * Images of graph homomorphisms as subgraphs. -/ universe u v namespace SimpleGraph /-- A subgraph of a `SimpleGraph` is a subset of vertices along with a restriction of the adjacency relation that is symmetric and is supported by the vertex subset. They also form a bounded lattice. Thinking of `V → V → Prop` as `Set (V × V)`, a set of darts (i.e., half-edges), then `Subgraph.adj_sub` is that the darts of a subgraph are a subset of the darts of `G`. -/ @[ext] structure Subgraph {V : Type u} (G : SimpleGraph V) where verts : Set V Adj : V → V → Prop adj_sub : ∀ {v w : V}, Adj v w → G.Adj v w edge_vert : ∀ {v w : V}, Adj v w → v ∈ verts symm : Symmetric Adj := by aesop_graph -- Porting note: Originally `by obviously` #align simple_graph.subgraph SimpleGraph.Subgraph initialize_simps_projections SimpleGraph.Subgraph (Adj → adj) variable {ι : Sort*} {V : Type u} {W : Type v} /-- The one-vertex subgraph. -/ @[simps] protected def singletonSubgraph (G : SimpleGraph V) (v : V) : G.Subgraph where verts := {v} Adj := ⊥ adj_sub := False.elim edge_vert := False.elim symm _ _ := False.elim #align simple_graph.singleton_subgraph SimpleGraph.singletonSubgraph /-- The one-edge subgraph. -/ @[simps] def subgraphOfAdj (G : SimpleGraph V) {v w : V} (hvw : G.Adj v w) : G.Subgraph where verts := {v, w} Adj a b := s(v, w) = s(a, b) adj_sub h := by rw [← G.mem_edgeSet, ← h] exact hvw edge_vert {a b} h := by apply_fun fun e ↦ a ∈ e at h simp only [Sym2.mem_iff, true_or, eq_iff_iff, iff_true] at h exact h #align simple_graph.subgraph_of_adj SimpleGraph.subgraphOfAdj namespace Subgraph variable {G : SimpleGraph V} {G₁ G₂ : G.Subgraph} {a b : V} protected theorem loopless (G' : Subgraph G) : Irreflexive G'.Adj := fun v h ↦ G.loopless v (G'.adj_sub h) #align simple_graph.subgraph.loopless SimpleGraph.Subgraph.loopless theorem adj_comm (G' : Subgraph G) (v w : V) : G'.Adj v w ↔ G'.Adj w v := ⟨fun x ↦ G'.symm x, fun x ↦ G'.symm x⟩ #align simple_graph.subgraph.adj_comm SimpleGraph.Subgraph.adj_comm @[symm] theorem adj_symm (G' : Subgraph G) {u v : V} (h : G'.Adj u v) : G'.Adj v u := G'.symm h #align simple_graph.subgraph.adj_symm SimpleGraph.Subgraph.adj_symm protected theorem Adj.symm {G' : Subgraph G} {u v : V} (h : G'.Adj u v) : G'.Adj v u := G'.symm h #align simple_graph.subgraph.adj.symm SimpleGraph.Subgraph.Adj.symm protected theorem Adj.adj_sub {H : G.Subgraph} {u v : V} (h : H.Adj u v) : G.Adj u v := H.adj_sub h #align simple_graph.subgraph.adj.adj_sub SimpleGraph.Subgraph.Adj.adj_sub protected theorem Adj.fst_mem {H : G.Subgraph} {u v : V} (h : H.Adj u v) : u ∈ H.verts := H.edge_vert h #align simple_graph.subgraph.adj.fst_mem SimpleGraph.Subgraph.Adj.fst_mem protected theorem Adj.snd_mem {H : G.Subgraph} {u v : V} (h : H.Adj u v) : v ∈ H.verts := h.symm.fst_mem #align simple_graph.subgraph.adj.snd_mem SimpleGraph.Subgraph.Adj.snd_mem protected theorem Adj.ne {H : G.Subgraph} {u v : V} (h : H.Adj u v) : u ≠ v := h.adj_sub.ne #align simple_graph.subgraph.adj.ne SimpleGraph.Subgraph.Adj.ne /-- Coercion from `G' : Subgraph G` to a `SimpleGraph G'.verts`. -/ @[simps] protected def coe (G' : Subgraph G) : SimpleGraph G'.verts where Adj v w := G'.Adj v w symm _ _ h := G'.symm h loopless v h := loopless G v (G'.adj_sub h) #align simple_graph.subgraph.coe SimpleGraph.Subgraph.coe @[simp] theorem coe_adj_sub (G' : Subgraph G) (u v : G'.verts) (h : G'.coe.Adj u v) : G.Adj u v := G'.adj_sub h #align simple_graph.subgraph.coe_adj_sub SimpleGraph.Subgraph.coe_adj_sub -- Given `h : H.Adj u v`, then `h.coe : H.coe.Adj ⟨u, _⟩ ⟨v, _⟩`. protected theorem Adj.coe {H : G.Subgraph} {u v : V} (h : H.Adj u v) : H.coe.Adj ⟨u, H.edge_vert h⟩ ⟨v, H.edge_vert h.symm⟩ := h #align simple_graph.subgraph.adj.coe SimpleGraph.Subgraph.Adj.coe /-- A subgraph is called a *spanning subgraph* if it contains all the vertices of `G`. -/ def IsSpanning (G' : Subgraph G) : Prop := ∀ v : V, v ∈ G'.verts #align simple_graph.subgraph.is_spanning SimpleGraph.Subgraph.IsSpanning theorem isSpanning_iff {G' : Subgraph G} : G'.IsSpanning ↔ G'.verts = Set.univ := Set.eq_univ_iff_forall.symm #align simple_graph.subgraph.is_spanning_iff SimpleGraph.Subgraph.isSpanning_iff /-- Coercion from `Subgraph G` to `SimpleGraph V`. If `G'` is a spanning subgraph, then `G'.spanningCoe` yields an isomorphic graph. In general, this adds in all vertices from `V` as isolated vertices. -/ @[simps] protected def spanningCoe (G' : Subgraph G) : SimpleGraph V where Adj := G'.Adj symm := G'.symm loopless v hv := G.loopless v (G'.adj_sub hv) #align simple_graph.subgraph.spanning_coe SimpleGraph.Subgraph.spanningCoe @[simp] theorem Adj.of_spanningCoe {G' : Subgraph G} {u v : G'.verts} (h : G'.spanningCoe.Adj u v) : G.Adj u v := G'.adj_sub h #align simple_graph.subgraph.adj.of_spanning_coe SimpleGraph.Subgraph.Adj.of_spanningCoe
Mathlib/Combinatorics/SimpleGraph/Subgraph.lean
177
178
theorem spanningCoe_inj : G₁.spanningCoe = G₂.spanningCoe ↔ G₁.Adj = G₂.Adj := by
simp [Subgraph.spanningCoe]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes -/ import Mathlib.Algebra.Polynomial.FieldDivision import Mathlib.Algebra.Polynomial.Lifts import Mathlib.Data.List.Prime #align_import data.polynomial.splits from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # Split polynomials A polynomial `f : K[X]` splits over a field extension `L` of `K` if it is zero or all of its irreducible factors over `L` have degree `1`. ## Main definitions * `Polynomial.Splits i f`: A predicate on a homomorphism `i : K →+* L` from a commutative ring to a field and a polynomial `f` saying that `f.map i` is zero or all of its irreducible factors over `L` have degree `1`. -/ noncomputable section open Polynomial universe u v w variable {R : Type*} {F : Type u} {K : Type v} {L : Type w} namespace Polynomial open Polynomial section Splits section CommRing variable [CommRing K] [Field L] [Field F] variable (i : K →+* L) /-- A polynomial `Splits` iff it is zero or all of its irreducible factors have `degree` 1. -/ def Splits (f : K[X]) : Prop := f.map i = 0 ∨ ∀ {g : L[X]}, Irreducible g → g ∣ f.map i → degree g = 1 #align polynomial.splits Polynomial.Splits @[simp] theorem splits_zero : Splits i (0 : K[X]) := Or.inl (Polynomial.map_zero i) #align polynomial.splits_zero Polynomial.splits_zero theorem splits_of_map_eq_C {f : K[X]} {a : L} (h : f.map i = C a) : Splits i f := letI := Classical.decEq L if ha : a = 0 then Or.inl (h.trans (ha.symm ▸ C_0)) else Or.inr fun hg ⟨p, hp⟩ => absurd hg.1 <| Classical.not_not.2 <| isUnit_iff_degree_eq_zero.2 <| by have := congr_arg degree hp rw [h, degree_C ha, degree_mul, @eq_comm (WithBot ℕ) 0, Nat.WithBot.add_eq_zero_iff] at this exact this.1 set_option linter.uppercaseLean3 false in #align polynomial.splits_of_map_eq_C Polynomial.splits_of_map_eq_C @[simp] theorem splits_C (a : K) : Splits i (C a) := splits_of_map_eq_C i (map_C i) set_option linter.uppercaseLean3 false in #align polynomial.splits_C Polynomial.splits_C theorem splits_of_map_degree_eq_one {f : K[X]} (hf : degree (f.map i) = 1) : Splits i f := Or.inr fun hg ⟨p, hp⟩ => by have := congr_arg degree hp simp [Nat.WithBot.add_eq_one_iff, hf, @eq_comm (WithBot ℕ) 1, mt isUnit_iff_degree_eq_zero.2 hg.1] at this tauto #align polynomial.splits_of_map_degree_eq_one Polynomial.splits_of_map_degree_eq_one theorem splits_of_degree_le_one {f : K[X]} (hf : degree f ≤ 1) : Splits i f := if hif : degree (f.map i) ≤ 0 then splits_of_map_eq_C i (degree_le_zero_iff.mp hif) else by push_neg at hif rw [← Order.succ_le_iff, ← WithBot.coe_zero, WithBot.succ_coe, Nat.succ_eq_succ] at hif exact splits_of_map_degree_eq_one i (le_antisymm ((degree_map_le i _).trans hf) hif) #align polynomial.splits_of_degree_le_one Polynomial.splits_of_degree_le_one theorem splits_of_degree_eq_one {f : K[X]} (hf : degree f = 1) : Splits i f := splits_of_degree_le_one i hf.le #align polynomial.splits_of_degree_eq_one Polynomial.splits_of_degree_eq_one theorem splits_of_natDegree_le_one {f : K[X]} (hf : natDegree f ≤ 1) : Splits i f := splits_of_degree_le_one i (degree_le_of_natDegree_le hf) #align polynomial.splits_of_nat_degree_le_one Polynomial.splits_of_natDegree_le_one theorem splits_of_natDegree_eq_one {f : K[X]} (hf : natDegree f = 1) : Splits i f := splits_of_natDegree_le_one i (le_of_eq hf) #align polynomial.splits_of_nat_degree_eq_one Polynomial.splits_of_natDegree_eq_one theorem splits_mul {f g : K[X]} (hf : Splits i f) (hg : Splits i g) : Splits i (f * g) := letI := Classical.decEq L if h : (f * g).map i = 0 then Or.inl h else Or.inr @fun p hp hpf => ((irreducible_iff_prime.1 hp).2.2 _ _ (show p ∣ map i f * map i g by convert hpf; rw [Polynomial.map_mul])).elim (hf.resolve_left (fun hf => by simp [hf] at h) hp) (hg.resolve_left (fun hg => by simp [hg] at h) hp) #align polynomial.splits_mul Polynomial.splits_mul theorem splits_of_splits_mul' {f g : K[X]} (hfg : (f * g).map i ≠ 0) (h : Splits i (f * g)) : Splits i f ∧ Splits i g := ⟨Or.inr @fun g hgi hg => Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_right _ _)), Or.inr @fun g hgi hg => Or.resolve_left h hfg hgi (by rw [Polynomial.map_mul]; exact hg.trans (dvd_mul_left _ _))⟩ #align polynomial.splits_of_splits_mul' Polynomial.splits_of_splits_mul' theorem splits_map_iff (j : L →+* F) {f : K[X]} : Splits j (f.map i) ↔ Splits (j.comp i) f := by simp [Splits, Polynomial.map_map] #align polynomial.splits_map_iff Polynomial.splits_map_iff theorem splits_one : Splits i 1 := splits_C i 1 #align polynomial.splits_one Polynomial.splits_one theorem splits_of_isUnit [IsDomain K] {u : K[X]} (hu : IsUnit u) : u.Splits i := (isUnit_iff.mp hu).choose_spec.2 ▸ splits_C _ _ #align polynomial.splits_of_is_unit Polynomial.splits_of_isUnit theorem splits_X_sub_C {x : K} : (X - C x).Splits i := splits_of_degree_le_one _ <| degree_X_sub_C_le _ set_option linter.uppercaseLean3 false in #align polynomial.splits_X_sub_C Polynomial.splits_X_sub_C theorem splits_X : X.Splits i := splits_of_degree_le_one _ degree_X_le set_option linter.uppercaseLean3 false in #align polynomial.splits_X Polynomial.splits_X theorem splits_prod {ι : Type u} {s : ι → K[X]} {t : Finset ι} : (∀ j ∈ t, (s j).Splits i) → (∏ x ∈ t, s x).Splits i := by classical refine Finset.induction_on t (fun _ => splits_one i) fun a t hat ih ht => ?_ rw [Finset.forall_mem_insert] at ht; rw [Finset.prod_insert hat] exact splits_mul i ht.1 (ih ht.2) #align polynomial.splits_prod Polynomial.splits_prod theorem splits_pow {f : K[X]} (hf : f.Splits i) (n : ℕ) : (f ^ n).Splits i := by rw [← Finset.card_range n, ← Finset.prod_const] exact splits_prod i fun j _ => hf #align polynomial.splits_pow Polynomial.splits_pow theorem splits_X_pow (n : ℕ) : (X ^ n).Splits i := splits_pow i (splits_X i) n set_option linter.uppercaseLean3 false in #align polynomial.splits_X_pow Polynomial.splits_X_pow
Mathlib/Algebra/Polynomial/Splits.lean
164
165
theorem splits_id_iff_splits {f : K[X]} : (f.map i).Splits (RingHom.id L) ↔ f.Splits i := by
rw [splits_map_iff, RingHom.id_comp]
/- Copyright (c) 2022 Yaël Dillies. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yaël Dillies -/ import Mathlib.Data.Finset.Lattice #align_import combinatorics.set_family.compression.down from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853" /-! # Down-compressions This file defines down-compression. Down-compressing `𝒜 : Finset (Finset α)` along `a : α` means removing `a` from the elements of `𝒜`, when the resulting set is not already in `𝒜`. ## Main declarations * `Finset.nonMemberSubfamily`: `𝒜.nonMemberSubfamily a` is the subfamily of sets not containing `a`. * `Finset.memberSubfamily`: `𝒜.memberSubfamily a` is the image of the subfamily of sets containing `a` under removing `a`. * `Down.compression`: Down-compression. ## Notation `𝓓 a 𝒜` is notation for `Down.compress a 𝒜` in locale `SetFamily`. ## References * https://github.com/b-mehta/maths-notes/blob/master/iii/mich/combinatorics.pdf ## Tags compression, down-compression -/ variable {α : Type*} [DecidableEq α] {𝒜 ℬ : Finset (Finset α)} {s : Finset α} {a : α} namespace Finset /-- Elements of `𝒜` that do not contain `a`. -/ def nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := 𝒜.filter fun s => a ∉ s #align finset.non_member_subfamily Finset.nonMemberSubfamily /-- Image of the elements of `𝒜` which contain `a` under removing `a`. Finsets that do not contain `a` such that `insert a s ∈ 𝒜`. -/ def memberSubfamily (a : α) (𝒜 : Finset (Finset α)) : Finset (Finset α) := (𝒜.filter fun s => a ∈ s).image fun s => erase s a #align finset.member_subfamily Finset.memberSubfamily @[simp] theorem mem_nonMemberSubfamily : s ∈ 𝒜.nonMemberSubfamily a ↔ s ∈ 𝒜 ∧ a ∉ s := by simp [nonMemberSubfamily] #align finset.mem_non_member_subfamily Finset.mem_nonMemberSubfamily @[simp] theorem mem_memberSubfamily : s ∈ 𝒜.memberSubfamily a ↔ insert a s ∈ 𝒜 ∧ a ∉ s := by simp_rw [memberSubfamily, mem_image, mem_filter] refine ⟨?_, fun h => ⟨insert a s, ⟨h.1, by simp⟩, erase_insert h.2⟩⟩ rintro ⟨s, ⟨hs1, hs2⟩, rfl⟩ rw [insert_erase hs2] exact ⟨hs1, not_mem_erase _ _⟩ #align finset.mem_member_subfamily Finset.mem_memberSubfamily theorem nonMemberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∩ ℬ.nonMemberSubfamily a := filter_inter_distrib _ _ _ #align finset.non_member_subfamily_inter Finset.nonMemberSubfamily_inter theorem memberSubfamily_inter (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∩ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∩ ℬ.memberSubfamily a := by unfold memberSubfamily rw [filter_inter_distrib, image_inter_of_injOn _ _ ((erase_injOn' _).mono _)] simp #align finset.member_subfamily_inter Finset.memberSubfamily_inter theorem nonMemberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a ∪ ℬ.nonMemberSubfamily a := filter_union _ _ _ #align finset.non_member_subfamily_union Finset.nonMemberSubfamily_union theorem memberSubfamily_union (a : α) (𝒜 ℬ : Finset (Finset α)) : (𝒜 ∪ ℬ).memberSubfamily a = 𝒜.memberSubfamily a ∪ ℬ.memberSubfamily a := by simp_rw [memberSubfamily, filter_union, image_union] #align finset.member_subfamily_union Finset.memberSubfamily_union theorem card_memberSubfamily_add_card_nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : (𝒜.memberSubfamily a).card + (𝒜.nonMemberSubfamily a).card = 𝒜.card := by rw [memberSubfamily, nonMemberSubfamily, card_image_of_injOn] · conv_rhs => rw [← filter_card_add_filter_neg_card_eq_card (fun s => (a ∈ s))] · apply (erase_injOn' _).mono simp #align finset.card_member_subfamily_add_card_non_member_subfamily Finset.card_memberSubfamily_add_card_nonMemberSubfamily theorem memberSubfamily_union_nonMemberSubfamily (a : α) (𝒜 : Finset (Finset α)) : 𝒜.memberSubfamily a ∪ 𝒜.nonMemberSubfamily a = 𝒜.image fun s => s.erase a := by ext s simp only [mem_union, mem_memberSubfamily, mem_nonMemberSubfamily, mem_image, exists_prop] constructor · rintro (h | h) · exact ⟨_, h.1, erase_insert h.2⟩ · exact ⟨_, h.1, erase_eq_of_not_mem h.2⟩ · rintro ⟨s, hs, rfl⟩ by_cases ha : a ∈ s · exact Or.inl ⟨by rwa [insert_erase ha], not_mem_erase _ _⟩ · exact Or.inr ⟨by rwa [erase_eq_of_not_mem ha], not_mem_erase _ _⟩ #align finset.member_subfamily_union_non_member_subfamily Finset.memberSubfamily_union_nonMemberSubfamily @[simp] theorem memberSubfamily_memberSubfamily : (𝒜.memberSubfamily a).memberSubfamily a = ∅ := by ext simp #align finset.member_subfamily_member_subfamily Finset.memberSubfamily_memberSubfamily @[simp] theorem memberSubfamily_nonMemberSubfamily : (𝒜.nonMemberSubfamily a).memberSubfamily a = ∅ := by ext simp #align finset.member_subfamily_non_member_subfamily Finset.memberSubfamily_nonMemberSubfamily @[simp] theorem nonMemberSubfamily_memberSubfamily : (𝒜.memberSubfamily a).nonMemberSubfamily a = 𝒜.memberSubfamily a := by ext simp #align finset.non_member_subfamily_member_subfamily Finset.nonMemberSubfamily_memberSubfamily @[simp]
Mathlib/Combinatorics/SetFamily/Compression/Down.lean
133
136
theorem nonMemberSubfamily_nonMemberSubfamily : (𝒜.nonMemberSubfamily a).nonMemberSubfamily a = 𝒜.nonMemberSubfamily a := by
ext simp
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl, Sander Dahmen, Scott Morrison -/ import Mathlib.LinearAlgebra.LinearIndependent #align_import linear_algebra.dimension from "leanprover-community/mathlib"@"47a5f8186becdbc826190ced4312f8199f9db6a5" /-! # Dimension of modules and vector spaces ## Main definitions * The rank of a module is defined as `Module.rank : Cardinal`. This is defined as the supremum of the cardinalities of linearly independent subsets. ## Main statements * `LinearMap.rank_le_of_injective`: the source of an injective linear map has dimension at most that of the target. * `LinearMap.rank_le_of_surjective`: the target of a surjective linear map has dimension at most that of that source. ## Implementation notes Many theorems in this file are not universe-generic when they relate dimensions in different universes. They should be as general as they can be without inserting `lift`s. The types `M`, `M'`, ... all live in different universes, and `M₁`, `M₂`, ... all live in the same universe. -/ noncomputable section universe w w' u u' v v' variable {R : Type u} {R' : Type u'} {M M₁ : Type v} {M' : Type v'} open Cardinal Submodule Function Set section Module section variable [Semiring R] [AddCommMonoid M] [Module R M] variable (R M) /-- The rank of a module, defined as a term of type `Cardinal`. We define this as the supremum of the cardinalities of linearly independent subsets. For a free module over any ring satisfying the strong rank condition (e.g. left-noetherian rings, commutative rings, and in particular division rings and fields), this is the same as the dimension of the space (i.e. the cardinality of any basis). In particular this agrees with the usual notion of the dimension of a vector space. -/ protected irreducible_def Module.rank : Cardinal := ⨆ ι : { s : Set M // LinearIndependent R ((↑) : s → M) }, (#ι.1) #align module.rank Module.rank theorem rank_le_card : Module.rank R M ≤ #M := (Module.rank_def _ _).trans_le (ciSup_le' fun _ ↦ mk_set_le _) lemma nonempty_linearIndependent_set : Nonempty {s : Set M // LinearIndependent R ((↑) : s → M)} := ⟨⟨∅, linearIndependent_empty _ _⟩⟩ end variable [Ring R] [Ring R'] [AddCommGroup M] [AddCommGroup M'] [AddCommGroup M₁] variable [Module R M] [Module R M'] [Module R M₁] [Module R' M'] [Module R' M₁] namespace LinearIndependent variable [Nontrivial R] theorem cardinal_lift_le_rank {ι : Type w} {v : ι → M} (hv : LinearIndependent R v) : Cardinal.lift.{v} #ι ≤ Cardinal.lift.{w} (Module.rank R M) := by rw [Module.rank] refine le_trans ?_ (lift_le.mpr <| le_ciSup (bddAbove_range.{v, v} _) ⟨_, hv.coe_range⟩) exact lift_mk_le'.mpr ⟨(Equiv.ofInjective _ hv.injective).toEmbedding⟩ #align cardinal_lift_le_rank_of_linear_independent LinearIndependent.cardinal_lift_le_rank #align cardinal_lift_le_rank_of_linear_independent' LinearIndependent.cardinal_lift_le_rank lemma aleph0_le_rank {ι : Type w} [Infinite ι] {v : ι → M} (hv : LinearIndependent R v) : ℵ₀ ≤ Module.rank R M := aleph0_le_lift.mp <| (aleph0_le_lift.mpr <| aleph0_le_mk ι).trans hv.cardinal_lift_le_rank theorem cardinal_le_rank {ι : Type v} {v : ι → M} (hv : LinearIndependent R v) : #ι ≤ Module.rank R M := by simpa using hv.cardinal_lift_le_rank #align cardinal_le_rank_of_linear_independent LinearIndependent.cardinal_le_rank theorem cardinal_le_rank' {s : Set M} (hs : LinearIndependent R (fun x => x : s → M)) : #s ≤ Module.rank R M := hs.cardinal_le_rank #align cardinal_le_rank_of_linear_independent' LinearIndependent.cardinal_le_rank' end LinearIndependent @[deprecated (since := "2023-12-27")] alias cardinal_lift_le_rank_of_linearIndependent := LinearIndependent.cardinal_lift_le_rank @[deprecated (since := "2023-12-27")] alias cardinal_lift_le_rank_of_linearIndependent' := LinearIndependent.cardinal_lift_le_rank @[deprecated (since := "2023-12-27")] alias cardinal_le_rank_of_linearIndependent := LinearIndependent.cardinal_le_rank @[deprecated (since := "2023-12-27")] alias cardinal_le_rank_of_linearIndependent' := LinearIndependent.cardinal_le_rank' section SurjectiveInjective section Module /-- If `M / R` and `M' / R'` are modules, `i : R' → R` is a map which sends non-zero elements to non-zero elements, `j : M →+ M'` is an injective group homomorphism, such that the scalar multiplications on `M` and `M'` are compatible, then the rank of `M / R` is smaller than or equal to the rank of `M' / R'`. As a special case, taking `R = R'` it is `LinearMap.lift_rank_le_of_injective`. -/ theorem lift_rank_le_of_injective_injective (i : R' → R) (j : M →+ M') (hi : ∀ r, i r = 0 → r = 0) (hj : Injective j) (hc : ∀ (r : R') (m : M), j (i r • m) = r • j m) : lift.{v'} (Module.rank R M) ≤ lift.{v} (Module.rank R' M') := by simp_rw [Module.rank, lift_iSup (bddAbove_range.{v', v'} _), lift_iSup (bddAbove_range.{v, v} _)] exact ciSup_mono' (bddAbove_range.{v', v} _) fun ⟨s, h⟩ ↦ ⟨⟨j '' s, (h.map_of_injective_injective i j hi (fun _ _ ↦ hj <| by rwa [j.map_zero]) hc).image⟩, lift_mk_le'.mpr ⟨(Equiv.Set.image j s hj).toEmbedding⟩⟩ /-- If `M / R` and `M' / R'` are modules, `i : R → R'` is a surjective map which maps zero to zero, `j : M →+ M'` is an injective group homomorphism, such that the scalar multiplications on `M` and `M'` are compatible, then the rank of `M / R` is smaller than or equal to the rank of `M' / R'`. As a special case, taking `R = R'` it is `LinearMap.lift_rank_le_of_injective`. -/ theorem lift_rank_le_of_surjective_injective (i : ZeroHom R R') (j : M →+ M') (hi : Surjective i) (hj : Injective j) (hc : ∀ (r : R) (m : M), j (r • m) = i r • j m) : lift.{v'} (Module.rank R M) ≤ lift.{v} (Module.rank R' M') := by obtain ⟨i', hi'⟩ := hi.hasRightInverse refine lift_rank_le_of_injective_injective i' j (fun _ h ↦ ?_) hj fun r m ↦ ?_ · apply_fun i at h rwa [hi', i.map_zero] at h rw [hc (i' r) m, hi'] /-- If `M / R` and `M' / R'` are modules, `i : R → R'` is a bijective map which maps zero to zero, `j : M ≃+ M'` is a group isomorphism, such that the scalar multiplications on `M` and `M'` are compatible, then the rank of `M / R` is equal to the rank of `M' / R'`. As a special case, taking `R = R'` it is `LinearEquiv.lift_rank_eq`. -/ theorem lift_rank_eq_of_equiv_equiv (i : ZeroHom R R') (j : M ≃+ M') (hi : Bijective i) (hc : ∀ (r : R) (m : M), j (r • m) = i r • j m) : lift.{v'} (Module.rank R M) = lift.{v} (Module.rank R' M') := (lift_rank_le_of_surjective_injective i j hi.2 j.injective hc).antisymm <| lift_rank_le_of_injective_injective i j.symm (fun _ _ ↦ hi.1 <| by rwa [i.map_zero]) j.symm.injective fun _ _ ↦ j.symm_apply_eq.2 <| by erw [hc, j.apply_symm_apply] /-- The same-universe version of `lift_rank_le_of_injective_injective`. -/ theorem rank_le_of_injective_injective (i : R' → R) (j : M →+ M₁) (hi : ∀ r, i r = 0 → r = 0) (hj : Injective j) (hc : ∀ (r : R') (m : M), j (i r • m) = r • j m) : Module.rank R M ≤ Module.rank R' M₁ := by simpa only [lift_id] using lift_rank_le_of_injective_injective i j hi hj hc /-- The same-universe version of `lift_rank_le_of_surjective_injective`. -/ theorem rank_le_of_surjective_injective (i : ZeroHom R R') (j : M →+ M₁) (hi : Surjective i) (hj : Injective j) (hc : ∀ (r : R) (m : M), j (r • m) = i r • j m) : Module.rank R M ≤ Module.rank R' M₁ := by simpa only [lift_id] using lift_rank_le_of_surjective_injective i j hi hj hc /-- The same-universe version of `lift_rank_eq_of_equiv_equiv`. -/ theorem rank_eq_of_equiv_equiv (i : ZeroHom R R') (j : M ≃+ M₁) (hi : Bijective i) (hc : ∀ (r : R) (m : M), j (r • m) = i r • j m) : Module.rank R M = Module.rank R' M₁ := by simpa only [lift_id] using lift_rank_eq_of_equiv_equiv i j hi hc end Module namespace Algebra variable {R : Type w} {S : Type v} [CommRing R] [Ring S] [Algebra R S] {R' : Type w'} {S' : Type v'} [CommRing R'] [Ring S'] [Algebra R' S'] /-- If `S / R` and `S' / R'` are algebras, `i : R' →+* R` and `j : S →+* S'` are injective ring homomorphisms, such that `R' → R → S → S'` and `R' → S'` commute, then the rank of `S / R` is smaller than or equal to the rank of `S' / R'`. -/
Mathlib/LinearAlgebra/Dimension/Basic.lean
185
193
theorem lift_rank_le_of_injective_injective (i : R' →+* R) (j : S →+* S') (hi : Injective i) (hj : Injective j) (hc : (j.comp (algebraMap R S)).comp i = algebraMap R' S') : lift.{v'} (Module.rank R S) ≤ lift.{v} (Module.rank R' S') := by
refine _root_.lift_rank_le_of_injective_injective i j (fun _ _ ↦ hi <| by rwa [i.map_zero]) hj fun r _ ↦ ?_ have := congr($hc r) simp only [RingHom.coe_comp, comp_apply] at this simp_rw [smul_def, AddMonoidHom.coe_coe, map_mul, this]
/- Copyright (c) 2021 Shing Tak Lam. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Shing Tak Lam -/ import Mathlib.CategoryTheory.Category.Grpd import Mathlib.CategoryTheory.Groupoid import Mathlib.Topology.Category.TopCat.Basic import Mathlib.Topology.Homotopy.Path import Mathlib.Data.Set.Subsingleton #align_import algebraic_topology.fundamental_groupoid.basic from "leanprover-community/mathlib"@"3d7987cda72abc473c7cdbbb075170e9ac620042" /-! # Fundamental groupoid of a space Given a topological space `X`, we can define the fundamental groupoid of `X` to be the category with objects being points of `X`, and morphisms `x ⟶ y` being paths from `x` to `y`, quotiented by homotopy equivalence. With this, the fundamental group of `X` based at `x` is just the automorphism group of `x`. -/ open CategoryTheory universe u v variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y] variable {x₀ x₁ : X} noncomputable section open unitInterval namespace Path namespace Homotopy section /-- Auxiliary function for `reflTransSymm`. -/ def reflTransSymmAux (x : I × I) : ℝ := if (x.2 : ℝ) ≤ 1 / 2 then x.1 * 2 * x.2 else x.1 * (2 - 2 * x.2) #align path.homotopy.refl_trans_symm_aux Path.Homotopy.reflTransSymmAux @[continuity] theorem continuous_reflTransSymmAux : Continuous reflTransSymmAux := by refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_ · continuity · continuity · continuity · continuity intro x hx norm_num [hx, mul_assoc] #align path.homotopy.continuous_refl_trans_symm_aux Path.Homotopy.continuous_reflTransSymmAux theorem reflTransSymmAux_mem_I (x : I × I) : reflTransSymmAux x ∈ I := by dsimp only [reflTransSymmAux] split_ifs · constructor · apply mul_nonneg · apply mul_nonneg · unit_interval · norm_num · unit_interval · rw [mul_assoc] apply mul_le_one · unit_interval · apply mul_nonneg · norm_num · unit_interval · linarith · constructor · apply mul_nonneg · unit_interval linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2] · apply mul_le_one · unit_interval · linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2] · linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2] set_option linter.uppercaseLean3 false in #align path.homotopy.refl_trans_symm_aux_mem_I Path.Homotopy.reflTransSymmAux_mem_I /-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₀` to `p.trans p.symm`. -/ def reflTransSymm (p : Path x₀ x₁) : Homotopy (Path.refl x₀) (p.trans p.symm) where toFun x := p ⟨reflTransSymmAux x, reflTransSymmAux_mem_I x⟩ continuous_toFun := by continuity map_zero_left := by simp [reflTransSymmAux] map_one_left x := by dsimp only [reflTransSymmAux, Path.coe_toContinuousMap, Path.trans] change _ = ite _ _ _ split_ifs with h · rw [Path.extend, Set.IccExtend_of_mem] · norm_num · rw [unitInterval.mul_pos_mem_iff zero_lt_two] exact ⟨unitInterval.nonneg x, h⟩ · rw [Path.symm, Path.extend, Set.IccExtend_of_mem] · simp only [Set.Icc.coe_one, one_mul, coe_mk_mk, Function.comp_apply] congr 1 ext norm_num [sub_sub_eq_add_sub] · rw [unitInterval.two_mul_sub_one_mem_iff] exact ⟨(not_le.1 h).le, unitInterval.le_one x⟩ prop' t x hx := by simp only [Set.mem_singleton_iff, Set.mem_insert_iff] at hx simp only [ContinuousMap.coe_mk, coe_toContinuousMap, Path.refl_apply] cases hx with | inl hx | inr hx => set_option tactic.skipAssignedInstances false in rw [hx] norm_num [reflTransSymmAux] #align path.homotopy.refl_trans_symm Path.Homotopy.reflTransSymm /-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₁` to `p.symm.trans p`. -/ def reflSymmTrans (p : Path x₀ x₁) : Homotopy (Path.refl x₁) (p.symm.trans p) := (reflTransSymm p.symm).cast rfl <| congr_arg _ (Path.symm_symm _) #align path.homotopy.refl_symm_trans Path.Homotopy.reflSymmTrans end section TransRefl /-- Auxiliary function for `trans_refl_reparam`. -/ def transReflReparamAux (t : I) : ℝ := if (t : ℝ) ≤ 1 / 2 then 2 * t else 1 #align path.homotopy.trans_refl_reparam_aux Path.Homotopy.transReflReparamAux @[continuity] theorem continuous_transReflReparamAux : Continuous transReflReparamAux := by refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_ <;> [continuity; continuity; continuity; continuity; skip] intro x hx simp [hx] #align path.homotopy.continuous_trans_refl_reparam_aux Path.Homotopy.continuous_transReflReparamAux theorem transReflReparamAux_mem_I (t : I) : transReflReparamAux t ∈ I := by unfold transReflReparamAux split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t] set_option linter.uppercaseLean3 false in #align path.homotopy.trans_refl_reparam_aux_mem_I Path.Homotopy.transReflReparamAux_mem_I theorem transReflReparamAux_zero : transReflReparamAux 0 = 0 := by set_option tactic.skipAssignedInstances false in norm_num [transReflReparamAux] #align path.homotopy.trans_refl_reparam_aux_zero Path.Homotopy.transReflReparamAux_zero theorem transReflReparamAux_one : transReflReparamAux 1 = 1 := by set_option tactic.skipAssignedInstances false in norm_num [transReflReparamAux] #align path.homotopy.trans_refl_reparam_aux_one Path.Homotopy.transReflReparamAux_one
Mathlib/AlgebraicTopology/FundamentalGroupoid/Basic.lean
152
163
theorem trans_refl_reparam (p : Path x₀ x₁) : p.trans (Path.refl x₁) = p.reparam (fun t => ⟨transReflReparamAux t, transReflReparamAux_mem_I t⟩) (by continuity) (Subtype.ext transReflReparamAux_zero) (Subtype.ext transReflReparamAux_one) := by
ext unfold transReflReparamAux simp only [Path.trans_apply, not_le, coe_reparam, Function.comp_apply, one_div, Path.refl_apply] split_ifs · rfl · rfl · simp · simp
/- Copyright (c) 2023 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Analysis.Calculus.Deriv.Comp import Mathlib.Analysis.Calculus.Deriv.Add import Mathlib.Analysis.Calculus.Deriv.Mul import Mathlib.Analysis.Calculus.Deriv.Slope /-! # Line derivatives We define the line derivative of a function `f : E → F`, at a point `x : E` along a vector `v : E`, as the element `f' : F` such that `f (x + t • v) = f x + t • f' + o (t)` as `t` tends to `0` in the scalar field `𝕜`, if it exists. It is denoted by `lineDeriv 𝕜 f x v`. This notion is generally less well behaved than the full Fréchet derivative (for instance, the composition of functions which are line-differentiable is not line-differentiable in general). The Fréchet derivative should therefore be favored over this one in general, although the line derivative may sometimes prove handy. The line derivative in direction `v` is also called the Gateaux derivative in direction `v`, although the term "Gateaux derivative" is sometimes reserved for the situation where there is such a derivative in all directions, for the map `v ↦ lineDeriv 𝕜 f x v` (which doesn't have to be linear in general). ## Main definition and results We mimic the definitions and statements for the Fréchet derivative and the one-dimensional derivative. We define in particular the following objects: * `LineDifferentiableWithinAt 𝕜 f s x v` * `LineDifferentiableAt 𝕜 f x v` * `HasLineDerivWithinAt 𝕜 f f' s x v` * `HasLineDerivAt 𝕜 f s x v` * `lineDerivWithin 𝕜 f s x v` * `lineDeriv 𝕜 f x v` and develop about them a basic API inspired by the one for the Fréchet derivative. We depart from the Fréchet derivative in two places, as the dependence of the following predicates on the direction would make them barely usable: * We do not define an analogue of the predicate `UniqueDiffOn`; * We do not define `LineDifferentiableOn` nor `LineDifferentiable`. -/ noncomputable section open scoped Topology Filter ENNReal NNReal open Filter Asymptotics Set variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F] section Module /-! Results that do not rely on a topological structure on `E` -/ variable (𝕜) variable {E : Type*} [AddCommGroup E] [Module 𝕜 E] /-- `f` has the derivative `f'` at the point `x` along the direction `v` in the set `s`. That is, `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0` and `x + t v ∈ s`. Note that this definition is less well behaved than the total Fréchet derivative, which should generally be favored over this one. -/ def HasLineDerivWithinAt (f : E → F) (f' : F) (s : Set E) (x : E) (v : E) := HasDerivWithinAt (fun t ↦ f (x + t • v)) f' ((fun t ↦ x + t • v) ⁻¹' s) (0 : 𝕜) /-- `f` has the derivative `f'` at the point `x` along the direction `v`. That is, `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0`. Note that this definition is less well behaved than the total Fréchet derivative, which should generally be favored over this one. -/ def HasLineDerivAt (f : E → F) (f' : F) (x : E) (v : E) := HasDerivAt (fun t ↦ f (x + t • v)) f' (0 : 𝕜) /-- `f` is line-differentiable at the point `x` in the direction `v` in the set `s` if there exists `f'` such that `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0` and `x + t v ∈ s`. -/ def LineDifferentiableWithinAt (f : E → F) (s : Set E) (x : E) (v : E) : Prop := DifferentiableWithinAt 𝕜 (fun t ↦ f (x + t • v)) ((fun t ↦ x + t • v) ⁻¹' s) (0 : 𝕜) /-- `f` is line-differentiable at the point `x` in the direction `v` if there exists `f'` such that `f (x + t v) = f x + t • f' + o (t)` when `t` tends to `0`. -/ def LineDifferentiableAt (f : E → F) (x : E) (v : E) : Prop := DifferentiableAt 𝕜 (fun t ↦ f (x + t • v)) (0 : 𝕜) /-- Line derivative of `f` at the point `x` in the direction `v` within the set `s`, if it exists. Zero otherwise. If the line derivative exists (i.e., `∃ f', HasLineDerivWithinAt 𝕜 f f' s x v`), then `f (x + t v) = f x + t lineDerivWithin 𝕜 f s x v + o (t)` when `t` tends to `0` and `x + t v ∈ s`. -/ def lineDerivWithin (f : E → F) (s : Set E) (x : E) (v : E) : F := derivWithin (fun t ↦ f (x + t • v)) ((fun t ↦ x + t • v) ⁻¹' s) (0 : 𝕜) /-- Line derivative of `f` at the point `x` in the direction `v`, if it exists. Zero otherwise. If the line derivative exists (i.e., `∃ f', HasLineDerivAt 𝕜 f f' x v`), then `f (x + t v) = f x + t lineDeriv 𝕜 f x v + o (t)` when `t` tends to `0`. -/ def lineDeriv (f : E → F) (x : E) (v : E) : F := deriv (fun t ↦ f (x + t • v)) (0 : 𝕜) variable {𝕜} variable {f f₁ : E → F} {f' f₀' f₁' : F} {s t : Set E} {x v : E} lemma HasLineDerivWithinAt.mono (hf : HasLineDerivWithinAt 𝕜 f f' s x v) (hst : t ⊆ s) : HasLineDerivWithinAt 𝕜 f f' t x v := HasDerivWithinAt.mono hf (preimage_mono hst) lemma HasLineDerivAt.hasLineDerivWithinAt (hf : HasLineDerivAt 𝕜 f f' x v) (s : Set E) : HasLineDerivWithinAt 𝕜 f f' s x v := HasDerivAt.hasDerivWithinAt hf lemma HasLineDerivWithinAt.lineDifferentiableWithinAt (hf : HasLineDerivWithinAt 𝕜 f f' s x v) : LineDifferentiableWithinAt 𝕜 f s x v := HasDerivWithinAt.differentiableWithinAt hf theorem HasLineDerivAt.lineDifferentiableAt (hf : HasLineDerivAt 𝕜 f f' x v) : LineDifferentiableAt 𝕜 f x v := HasDerivAt.differentiableAt hf theorem LineDifferentiableWithinAt.hasLineDerivWithinAt (h : LineDifferentiableWithinAt 𝕜 f s x v) : HasLineDerivWithinAt 𝕜 f (lineDerivWithin 𝕜 f s x v) s x v := DifferentiableWithinAt.hasDerivWithinAt h theorem LineDifferentiableAt.hasLineDerivAt (h : LineDifferentiableAt 𝕜 f x v) : HasLineDerivAt 𝕜 f (lineDeriv 𝕜 f x v) x v := DifferentiableAt.hasDerivAt h @[simp] lemma hasLineDerivWithinAt_univ : HasLineDerivWithinAt 𝕜 f f' univ x v ↔ HasLineDerivAt 𝕜 f f' x v := by simp only [HasLineDerivWithinAt, HasLineDerivAt, preimage_univ, hasDerivWithinAt_univ] theorem lineDerivWithin_zero_of_not_lineDifferentiableWithinAt (h : ¬LineDifferentiableWithinAt 𝕜 f s x v) : lineDerivWithin 𝕜 f s x v = 0 := derivWithin_zero_of_not_differentiableWithinAt h theorem lineDeriv_zero_of_not_lineDifferentiableAt (h : ¬LineDifferentiableAt 𝕜 f x v) : lineDeriv 𝕜 f x v = 0 := deriv_zero_of_not_differentiableAt h theorem hasLineDerivAt_iff_isLittleO_nhds_zero : HasLineDerivAt 𝕜 f f' x v ↔ (fun t : 𝕜 => f (x + t • v) - f x - t • f') =o[𝓝 0] fun t => t := by simp only [HasLineDerivAt, hasDerivAt_iff_isLittleO_nhds_zero, zero_add, zero_smul, add_zero] theorem HasLineDerivAt.unique (h₀ : HasLineDerivAt 𝕜 f f₀' x v) (h₁ : HasLineDerivAt 𝕜 f f₁' x v) : f₀' = f₁' := HasDerivAt.unique h₀ h₁ protected theorem HasLineDerivAt.lineDeriv (h : HasLineDerivAt 𝕜 f f' x v) : lineDeriv 𝕜 f x v = f' := by rw [h.unique h.lineDifferentiableAt.hasLineDerivAt] theorem lineDifferentiableWithinAt_univ : LineDifferentiableWithinAt 𝕜 f univ x v ↔ LineDifferentiableAt 𝕜 f x v := by simp only [LineDifferentiableWithinAt, LineDifferentiableAt, preimage_univ, differentiableWithinAt_univ] theorem LineDifferentiableAt.lineDifferentiableWithinAt (h : LineDifferentiableAt 𝕜 f x v) : LineDifferentiableWithinAt 𝕜 f s x v := (differentiableWithinAt_univ.2 h).mono (subset_univ _) @[simp] theorem lineDerivWithin_univ : lineDerivWithin 𝕜 f univ x v = lineDeriv 𝕜 f x v := by simp [lineDerivWithin, lineDeriv] theorem LineDifferentiableWithinAt.mono (h : LineDifferentiableWithinAt 𝕜 f t x v) (st : s ⊆ t) : LineDifferentiableWithinAt 𝕜 f s x v := (h.hasLineDerivWithinAt.mono st).lineDifferentiableWithinAt theorem HasLineDerivWithinAt.congr_mono (h : HasLineDerivWithinAt 𝕜 f f' s x v) (ht : EqOn f₁ f t) (hx : f₁ x = f x) (h₁ : t ⊆ s) : HasLineDerivWithinAt 𝕜 f₁ f' t x v := HasDerivWithinAt.congr_mono h (fun y hy ↦ ht hy) (by simpa using hx) (preimage_mono h₁) theorem HasLineDerivWithinAt.congr (h : HasLineDerivWithinAt 𝕜 f f' s x v) (hs : EqOn f₁ f s) (hx : f₁ x = f x) : HasLineDerivWithinAt 𝕜 f₁ f' s x v := h.congr_mono hs hx (Subset.refl _) theorem HasLineDerivWithinAt.congr' (h : HasLineDerivWithinAt 𝕜 f f' s x v) (hs : EqOn f₁ f s) (hx : x ∈ s) : HasLineDerivWithinAt 𝕜 f₁ f' s x v := h.congr hs (hs hx) theorem LineDifferentiableWithinAt.congr_mono (h : LineDifferentiableWithinAt 𝕜 f s x v) (ht : EqOn f₁ f t) (hx : f₁ x = f x) (h₁ : t ⊆ s) : LineDifferentiableWithinAt 𝕜 f₁ t x v := (HasLineDerivWithinAt.congr_mono h.hasLineDerivWithinAt ht hx h₁).differentiableWithinAt theorem LineDifferentiableWithinAt.congr (h : LineDifferentiableWithinAt 𝕜 f s x v) (ht : ∀ x ∈ s, f₁ x = f x) (hx : f₁ x = f x) : LineDifferentiableWithinAt 𝕜 f₁ s x v := LineDifferentiableWithinAt.congr_mono h ht hx (Subset.refl _) theorem lineDerivWithin_congr (hs : EqOn f₁ f s) (hx : f₁ x = f x) : lineDerivWithin 𝕜 f₁ s x v = lineDerivWithin 𝕜 f s x v := derivWithin_congr (fun y hy ↦ hs hy) (by simpa using hx) theorem lineDerivWithin_congr' (hs : EqOn f₁ f s) (hx : x ∈ s) : lineDerivWithin 𝕜 f₁ s x v = lineDerivWithin 𝕜 f s x v := lineDerivWithin_congr hs (hs hx) theorem hasLineDerivAt_iff_tendsto_slope_zero : HasLineDerivAt 𝕜 f f' x v ↔ Tendsto (fun (t : 𝕜) ↦ t⁻¹ • (f (x + t • v) - f x)) (𝓝[≠] 0) (𝓝 f') := by simp only [HasLineDerivAt, hasDerivAt_iff_tendsto_slope_zero, zero_add, zero_smul, add_zero] alias ⟨HasLineDerivAt.tendsto_slope_zero, _⟩ := hasLineDerivAt_iff_tendsto_slope_zero theorem HasLineDerivAt.tendsto_slope_zero_right [PartialOrder 𝕜] (h : HasLineDerivAt 𝕜 f f' x v) : Tendsto (fun (t : 𝕜) ↦ t⁻¹ • (f (x + t • v) - f x)) (𝓝[>] 0) (𝓝 f') := h.tendsto_slope_zero.mono_left (nhds_right'_le_nhds_ne 0) theorem HasLineDerivAt.tendsto_slope_zero_left [PartialOrder 𝕜] (h : HasLineDerivAt 𝕜 f f' x v) : Tendsto (fun (t : 𝕜) ↦ t⁻¹ • (f (x + t • v) - f x)) (𝓝[<] 0) (𝓝 f') := h.tendsto_slope_zero.mono_left (nhds_left'_le_nhds_ne 0) end Module section NormedSpace /-! Results that need a normed space structure on `E` -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] {f f₀ f₁ : E → F} {f' : F} {s t : Set E} {x v : E} {L : E →L[𝕜] F} theorem HasLineDerivWithinAt.mono_of_mem (h : HasLineDerivWithinAt 𝕜 f f' t x v) (hst : t ∈ 𝓝[s] x) : HasLineDerivWithinAt 𝕜 f f' s x v := by apply HasDerivWithinAt.mono_of_mem h apply ContinuousWithinAt.preimage_mem_nhdsWithin'' _ hst (by simp) apply Continuous.continuousWithinAt; continuity theorem HasLineDerivWithinAt.hasLineDerivAt (h : HasLineDerivWithinAt 𝕜 f f' s x v) (hs : s ∈ 𝓝 x) : HasLineDerivAt 𝕜 f f' x v := by rw [← hasLineDerivWithinAt_univ] rw [← nhdsWithin_univ] at hs exact h.mono_of_mem hs theorem LineDifferentiableWithinAt.lineDifferentiableAt (h : LineDifferentiableWithinAt 𝕜 f s x v) (hs : s ∈ 𝓝 x) : LineDifferentiableAt 𝕜 f x v := (h.hasLineDerivWithinAt.hasLineDerivAt hs).lineDifferentiableAt lemma HasFDerivWithinAt.hasLineDerivWithinAt (hf : HasFDerivWithinAt f L s x) (v : E) : HasLineDerivWithinAt 𝕜 f (L v) s x v := by let F := fun (t : 𝕜) ↦ x + t • v rw [show x = F (0 : 𝕜) by simp [F]] at hf have A : HasDerivWithinAt F (0 + (1 : 𝕜) • v) (F ⁻¹' s) 0 := ((hasDerivAt_const (0 : 𝕜) x).add ((hasDerivAt_id' (0 : 𝕜)).smul_const v)).hasDerivWithinAt simp only [one_smul, zero_add] at A exact hf.comp_hasDerivWithinAt (x := (0 : 𝕜)) A (mapsTo_preimage F s) lemma HasFDerivAt.hasLineDerivAt (hf : HasFDerivAt f L x) (v : E) : HasLineDerivAt 𝕜 f (L v) x v := by rw [← hasLineDerivWithinAt_univ] exact hf.hasFDerivWithinAt.hasLineDerivWithinAt v lemma DifferentiableAt.lineDeriv_eq_fderiv (hf : DifferentiableAt 𝕜 f x) : lineDeriv 𝕜 f x v = fderiv 𝕜 f x v := (hf.hasFDerivAt.hasLineDerivAt v).lineDeriv theorem LineDifferentiableWithinAt.mono_of_mem (h : LineDifferentiableWithinAt 𝕜 f s x v) (hst : s ∈ 𝓝[t] x) : LineDifferentiableWithinAt 𝕜 f t x v := (h.hasLineDerivWithinAt.mono_of_mem hst).lineDifferentiableWithinAt theorem lineDerivWithin_of_mem_nhds (h : s ∈ 𝓝 x) : lineDerivWithin 𝕜 f s x v = lineDeriv 𝕜 f x v := by apply derivWithin_of_mem_nhds apply (Continuous.continuousAt _).preimage_mem_nhds (by simpa using h) continuity theorem lineDerivWithin_of_isOpen (hs : IsOpen s) (hx : x ∈ s) : lineDerivWithin 𝕜 f s x v = lineDeriv 𝕜 f x v := lineDerivWithin_of_mem_nhds (hs.mem_nhds hx) theorem hasLineDerivWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) : HasLineDerivWithinAt 𝕜 f f' s x v ↔ HasLineDerivWithinAt 𝕜 f f' t x v := by apply hasDerivWithinAt_congr_set let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; continuity have : s =ᶠ[𝓝 (F 0)] t := by convert h; simp [F] exact B.preimage_mem_nhds this theorem lineDifferentiableWithinAt_congr_set (h : s =ᶠ[𝓝 x] t) : LineDifferentiableWithinAt 𝕜 f s x v ↔ LineDifferentiableWithinAt 𝕜 f t x v := ⟨fun h' ↦ ((hasLineDerivWithinAt_congr_set h).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt, fun h' ↦ ((hasLineDerivWithinAt_congr_set h.symm).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt⟩ theorem lineDerivWithin_congr_set (h : s =ᶠ[𝓝 x] t) : lineDerivWithin 𝕜 f s x v = lineDerivWithin 𝕜 f t x v := by apply derivWithin_congr_set let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; continuity have : s =ᶠ[𝓝 (F 0)] t := by convert h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.hasLineDerivAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) : HasLineDerivAt 𝕜 f₀ f' x v ↔ HasLineDerivAt 𝕜 f₁ f' x v := by apply hasDerivAt_iff let F := fun (t : 𝕜) ↦ x + t • v have B : ContinuousAt F 0 := by apply Continuous.continuousAt; continuity have : f₀ =ᶠ[𝓝 (F 0)] f₁ := by convert h; simp [F] exact B.preimage_mem_nhds this theorem Filter.EventuallyEq.lineDifferentiableAt_iff (h : f₀ =ᶠ[𝓝 x] f₁) : LineDifferentiableAt 𝕜 f₀ x v ↔ LineDifferentiableAt 𝕜 f₁ x v := ⟨fun h' ↦ (h.hasLineDerivAt_iff.1 h'.hasLineDerivAt).lineDifferentiableAt, fun h' ↦ (h.hasLineDerivAt_iff.2 h'.hasLineDerivAt).lineDifferentiableAt⟩ theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : f₀ x = f₁ x) : HasLineDerivWithinAt 𝕜 f₀ f' s x v ↔ HasLineDerivWithinAt 𝕜 f₁ f' s x v := by apply hasDerivWithinAt_iff · have A : Continuous (fun (t : 𝕜) ↦ x + t • v) := by continuity exact A.continuousWithinAt.preimage_mem_nhdsWithin'' h (by simp) · simpa using hx theorem Filter.EventuallyEq.hasLineDerivWithinAt_iff_of_mem (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : x ∈ s) : HasLineDerivWithinAt 𝕜 f₀ f' s x v ↔ HasLineDerivWithinAt 𝕜 f₁ f' s x v := h.hasLineDerivWithinAt_iff (h.eq_of_nhdsWithin hx) theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : f₀ x = f₁ x) : LineDifferentiableWithinAt 𝕜 f₀ s x v ↔ LineDifferentiableWithinAt 𝕜 f₁ s x v := ⟨fun h' ↦ ((h.hasLineDerivWithinAt_iff hx).1 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt, fun h' ↦ ((h.hasLineDerivWithinAt_iff hx).2 h'.hasLineDerivWithinAt).lineDifferentiableWithinAt⟩ theorem Filter.EventuallyEq.lineDifferentiableWithinAt_iff_of_mem (h : f₀ =ᶠ[𝓝[s] x] f₁) (hx : x ∈ s) : LineDifferentiableWithinAt 𝕜 f₀ s x v ↔ LineDifferentiableWithinAt 𝕜 f₁ s x v := h.lineDifferentiableWithinAt_iff (h.eq_of_nhdsWithin hx) lemma HasLineDerivWithinAt.congr_of_eventuallyEq (hf : HasLineDerivWithinAt 𝕜 f f' s x v) (h'f : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : HasLineDerivWithinAt 𝕜 f₁ f' s x v := by apply HasDerivWithinAt.congr_of_eventuallyEq hf _ (by simp [hx]) have A : Continuous (fun (t : 𝕜) ↦ x + t • v) := by continuity exact A.continuousWithinAt.preimage_mem_nhdsWithin'' h'f (by simp) theorem HasLineDerivAt.congr_of_eventuallyEq (h : HasLineDerivAt 𝕜 f f' x v) (h₁ : f₁ =ᶠ[𝓝 x] f) : HasLineDerivAt 𝕜 f₁ f' x v := by apply HasDerivAt.congr_of_eventuallyEq h let F := fun (t : 𝕜) ↦ x + t • v rw [show x = F 0 by simp [F]] at h₁ exact (Continuous.continuousAt (by continuity)).preimage_mem_nhds h₁ theorem LineDifferentiableWithinAt.congr_of_eventuallyEq (h : LineDifferentiableWithinAt 𝕜 f s x v) (h₁ : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : LineDifferentiableWithinAt 𝕜 f₁ s x v := (h.hasLineDerivWithinAt.congr_of_eventuallyEq h₁ hx).differentiableWithinAt theorem LineDifferentiableAt.congr_of_eventuallyEq (h : LineDifferentiableAt 𝕜 f x v) (hL : f₁ =ᶠ[𝓝 x] f) : LineDifferentiableAt 𝕜 f₁ x v := by apply DifferentiableAt.congr_of_eventuallyEq h let F := fun (t : 𝕜) ↦ x + t • v rw [show x = F 0 by simp [F]] at hL exact (Continuous.continuousAt (by continuity)).preimage_mem_nhds hL theorem Filter.EventuallyEq.lineDerivWithin_eq (hs : f₁ =ᶠ[𝓝[s] x] f) (hx : f₁ x = f x) : lineDerivWithin 𝕜 f₁ s x v = lineDerivWithin 𝕜 f s x v := by apply derivWithin_eq ?_ (by simpa using hx) have A : Continuous (fun (t : 𝕜) ↦ x + t • v) := by continuity exact A.continuousWithinAt.preimage_mem_nhdsWithin'' hs (by simp) theorem Filter.EventuallyEq.lineDerivWithin_eq_nhds (h : f₁ =ᶠ[𝓝 x] f) : lineDerivWithin 𝕜 f₁ s x v = lineDerivWithin 𝕜 f s x v := (h.filter_mono nhdsWithin_le_nhds).lineDerivWithin_eq h.self_of_nhds theorem Filter.EventuallyEq.lineDeriv_eq (h : f₁ =ᶠ[𝓝 x] f) : lineDeriv 𝕜 f₁ x v = lineDeriv 𝕜 f x v := by rw [← lineDerivWithin_univ, ← lineDerivWithin_univ, h.lineDerivWithin_eq_nhds] /-- Converse to the mean value inequality: if `f` is line differentiable at `x₀` and `C`-lipschitz on a neighborhood of `x₀` then its line derivative at `x₀` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/ theorem HasLineDerivAt.le_of_lip' {f : E → F} {f' : F} {x₀ : E} (hf : HasLineDerivAt 𝕜 f f' x₀ v) {C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖f'‖ ≤ C * ‖v‖ := by apply HasDerivAt.le_of_lip' hf (by positivity) have A : Continuous (fun (t : 𝕜) ↦ x₀ + t • v) := by continuity have : ∀ᶠ x in 𝓝 (x₀ + (0 : 𝕜) • v), ‖f x - f x₀‖ ≤ C * ‖x - x₀‖ := by simpa using hlip filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (‖t‖)] at ht simpa [mul_assoc] using ht /-- Converse to the mean value inequality: if `f` is line differentiable at `x₀` and `C`-lipschitz on a neighborhood of `x₀` then its line derivative at `x₀` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. -/ theorem HasLineDerivAt.le_of_lipschitzOn {f : E → F} {f' : F} {x₀ : E} (hf : HasLineDerivAt 𝕜 f f' x₀ v) {s : Set E} (hs : s ∈ 𝓝 x₀) {C : ℝ≥0} (hlip : LipschitzOnWith C f s) : ‖f'‖ ≤ C * ‖v‖ := by refine hf.le_of_lip' C.coe_nonneg ?_ filter_upwards [hs] with x hx using hlip.norm_sub_le hx (mem_of_mem_nhds hs) /-- Converse to the mean value inequality: if `f` is line differentiable at `x₀` and `C`-lipschitz then its line derivative at `x₀` in the direction `v` has norm bounded by `C * ‖v‖`. -/ theorem HasLineDerivAt.le_of_lipschitz {f : E → F} {f' : F} {x₀ : E} (hf : HasLineDerivAt 𝕜 f f' x₀ v) {C : ℝ≥0} (hlip : LipschitzWith C f) : ‖f'‖ ≤ C * ‖v‖ := hf.le_of_lipschitzOn univ_mem (lipschitzOn_univ.2 hlip) variable (𝕜) /-- Converse to the mean value inequality: if `f` is `C`-lipschitz on a neighborhood of `x₀` then its line derivative at `x₀` in the direction `v` has norm bounded by `C * ‖v‖`. This version only assumes that `‖f x - f x₀‖ ≤ C * ‖x - x₀‖` in a neighborhood of `x`. Version using `lineDeriv`. -/
Mathlib/Analysis/Calculus/LineDeriv/Basic.lean
421
429
theorem norm_lineDeriv_le_of_lip' {f : E → F} {x₀ : E} {C : ℝ} (hC₀ : 0 ≤ C) (hlip : ∀ᶠ x in 𝓝 x₀, ‖f x - f x₀‖ ≤ C * ‖x - x₀‖) : ‖lineDeriv 𝕜 f x₀ v‖ ≤ C * ‖v‖ := by
apply norm_deriv_le_of_lip' (by positivity) have A : Continuous (fun (t : 𝕜) ↦ x₀ + t • v) := by continuity have : ∀ᶠ x in 𝓝 (x₀ + (0 : 𝕜) • v), ‖f x - f x₀‖ ≤ C * ‖x - x₀‖ := by simpa using hlip filter_upwards [(A.continuousAt (x := 0)).preimage_mem_nhds this] with t ht simp only [preimage_setOf_eq, add_sub_cancel_left, norm_smul, mem_setOf_eq, mul_comm (‖t‖)] at ht simpa [mul_assoc] using ht
/- Copyright (c) 2023 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Rémy Degenne -/ import Mathlib.MeasureTheory.Decomposition.RadonNikodym import Mathlib.Probability.Kernel.Disintegration.CdfToKernel #align_import probability.kernel.cond_cdf from "leanprover-community/mathlib"@"3b88f4005dc2e28d42f974cc1ce838f0dafb39b8" /-! # Conditional cumulative distribution function Given `ρ : Measure (α × ℝ)`, we define the conditional cumulative distribution function (conditional cdf) of `ρ`. It is a function `condCDF ρ : α → ℝ → ℝ` such that if `ρ` is a finite measure, then for all `a : α` `condCDF ρ a` is monotone and right-continuous with limit 0 at -∞ and limit 1 at +∞, and such that for all `x : ℝ`, `a ↦ condCDF ρ a x` is measurable. For all `x : ℝ` and measurable set `s`, that function satisfies `∫⁻ a in s, ennreal.of_real (condCDF ρ a x) ∂ρ.fst = ρ (s ×ˢ Iic x)`. `condCDF` is build from the more general tools about kernel CDFs developed in the file `Probability.Kernel.Disintegration.CdfToKernel`. In that file, we build a function `α × β → StieltjesFunction` (which is `α × β → ℝ → ℝ` with additional properties) from a function `α × β → ℚ → ℝ`. The restriction to `ℚ` allows to prove some properties like measurability more easily. Here we apply that construction to the case `β = Unit` and then drop `β` to build `condCDF : α → StieltjesFunction`. ## Main definitions * `ProbabilityTheory.condCDF ρ : α → StieltjesFunction`: the conditional cdf of `ρ : Measure (α × ℝ)`. A `StieltjesFunction` is a function `ℝ → ℝ` which is monotone and right-continuous. ## Main statements * `ProbabilityTheory.set_lintegral_condCDF`: for all `a : α` and `x : ℝ`, all measurable set `s`, `∫⁻ a in s, ENNReal.ofReal (condCDF ρ a x) ∂ρ.fst = ρ (s ×ˢ Iic x)`. -/ open MeasureTheory Set Filter TopologicalSpace open scoped NNReal ENNReal MeasureTheory Topology namespace MeasureTheory.Measure variable {α β : Type*} {mα : MeasurableSpace α} (ρ : Measure (α × ℝ)) /-- Measure on `α` such that for a measurable set `s`, `ρ.IicSnd r s = ρ (s ×ˢ Iic r)`. -/ noncomputable def IicSnd (r : ℝ) : Measure α := (ρ.restrict (univ ×ˢ Iic r)).fst #align measure_theory.measure.Iic_snd MeasureTheory.Measure.IicSnd theorem IicSnd_apply (r : ℝ) {s : Set α} (hs : MeasurableSet s) : ρ.IicSnd r s = ρ (s ×ˢ Iic r) := by rw [IicSnd, fst_apply hs, restrict_apply' (MeasurableSet.univ.prod (measurableSet_Iic : MeasurableSet (Iic r))), ← prod_univ, prod_inter_prod, inter_univ, univ_inter] #align measure_theory.measure.Iic_snd_apply MeasureTheory.Measure.IicSnd_apply theorem IicSnd_univ (r : ℝ) : ρ.IicSnd r univ = ρ (univ ×ˢ Iic r) := IicSnd_apply ρ r MeasurableSet.univ #align measure_theory.measure.Iic_snd_univ MeasureTheory.Measure.IicSnd_univ theorem IicSnd_mono {r r' : ℝ} (h_le : r ≤ r') : ρ.IicSnd r ≤ ρ.IicSnd r' := by refine Measure.le_iff.2 fun s hs ↦ ?_ simp_rw [IicSnd_apply ρ _ hs] refine measure_mono (prod_subset_prod_iff.mpr (Or.inl ⟨subset_rfl, Iic_subset_Iic.mpr ?_⟩)) exact mod_cast h_le #align measure_theory.measure.Iic_snd_mono MeasureTheory.Measure.IicSnd_mono theorem IicSnd_le_fst (r : ℝ) : ρ.IicSnd r ≤ ρ.fst := by refine Measure.le_iff.2 fun s hs ↦ ?_ simp_rw [fst_apply hs, IicSnd_apply ρ r hs] exact measure_mono (prod_subset_preimage_fst _ _) #align measure_theory.measure.Iic_snd_le_fst MeasureTheory.Measure.IicSnd_le_fst theorem IicSnd_ac_fst (r : ℝ) : ρ.IicSnd r ≪ ρ.fst := Measure.absolutelyContinuous_of_le (IicSnd_le_fst ρ r) #align measure_theory.measure.Iic_snd_ac_fst MeasureTheory.Measure.IicSnd_ac_fst theorem IsFiniteMeasure.IicSnd {ρ : Measure (α × ℝ)} [IsFiniteMeasure ρ] (r : ℝ) : IsFiniteMeasure (ρ.IicSnd r) := isFiniteMeasure_of_le _ (IicSnd_le_fst ρ _) #align measure_theory.measure.is_finite_measure.Iic_snd MeasureTheory.Measure.IsFiniteMeasure.IicSnd
Mathlib/Probability/Kernel/Disintegration/CondCdf.lean
87
89
theorem iInf_IicSnd_gt (t : ℚ) {s : Set α} (hs : MeasurableSet s) [IsFiniteMeasure ρ] : ⨅ r : { r' : ℚ // t < r' }, ρ.IicSnd r s = ρ.IicSnd t s := by
simp_rw [ρ.IicSnd_apply _ hs, Measure.iInf_rat_gt_prod_Iic hs]
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot -/ import Mathlib.Data.Set.Function import Mathlib.Order.Interval.Set.OrdConnected #align_import data.set.intervals.proj_Icc from "leanprover-community/mathlib"@"4e24c4bfcff371c71f7ba22050308aa17815626c" /-! # Projection of a line onto a closed interval Given a linearly ordered type `α`, in this file we define * `Set.projIci (a : α)` to be the map `α → [a, ∞)` sending `(-∞, a]` to `a`, and each point `x ∈ [a, ∞)` to itself; * `Set.projIic (b : α)` to be the map `α → (-∞, b[` sending `[b, ∞)` to `b`, and each point `x ∈ (-∞, b]` to itself; * `Set.projIcc (a b : α) (h : a ≤ b)` to be the map `α → [a, b]` sending `(-∞, a]` to `a`, `[b, ∞)` to `b`, and each point `x ∈ [a, b]` to itself; * `Set.IccExtend {a b : α} (h : a ≤ b) (f : Icc a b → β)` to be the extension of `f` to `α` defined as `f ∘ projIcc a b h`. * `Set.IciExtend {a : α} (f : Ici a → β)` to be the extension of `f` to `α` defined as `f ∘ projIci a`. * `Set.IicExtend {b : α} (f : Iic b → β)` to be the extension of `f` to `α` defined as `f ∘ projIic b`. We also prove some trivial properties of these maps. -/ variable {α β : Type*} [LinearOrder α] open Function namespace Set /-- Projection of `α` to the closed interval `[a, ∞)`. -/ def projIci (a x : α) : Ici a := ⟨max a x, le_max_left _ _⟩ #align set.proj_Ici Set.projIci /-- Projection of `α` to the closed interval `(-∞, b]`. -/ def projIic (b x : α) : Iic b := ⟨min b x, min_le_left _ _⟩ #align set.proj_Iic Set.projIic /-- Projection of `α` to the closed interval `[a, b]`. -/ def projIcc (a b : α) (h : a ≤ b) (x : α) : Icc a b := ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩ #align set.proj_Icc Set.projIcc variable {a b : α} (h : a ≤ b) {x : α} @[norm_cast] theorem coe_projIci (a x : α) : (projIci a x : α) = max a x := rfl #align set.coe_proj_Ici Set.coe_projIci @[norm_cast] theorem coe_projIic (b x : α) : (projIic b x : α) = min b x := rfl #align set.coe_proj_Iic Set.coe_projIic @[norm_cast] theorem coe_projIcc (a b : α) (h : a ≤ b) (x : α) : (projIcc a b h x : α) = max a (min b x) := rfl #align set.coe_proj_Icc Set.coe_projIcc theorem projIci_of_le (hx : x ≤ a) : projIci a x = ⟨a, le_rfl⟩ := Subtype.ext <| max_eq_left hx #align set.proj_Ici_of_le Set.projIci_of_le theorem projIic_of_le (hx : b ≤ x) : projIic b x = ⟨b, le_rfl⟩ := Subtype.ext <| min_eq_left hx #align set.proj_Iic_of_le Set.projIic_of_le theorem projIcc_of_le_left (hx : x ≤ a) : projIcc a b h x = ⟨a, left_mem_Icc.2 h⟩ := by simp [projIcc, hx, hx.trans h] #align set.proj_Icc_of_le_left Set.projIcc_of_le_left theorem projIcc_of_right_le (hx : b ≤ x) : projIcc a b h x = ⟨b, right_mem_Icc.2 h⟩ := by simp [projIcc, hx, h] #align set.proj_Icc_of_right_le Set.projIcc_of_right_le @[simp] theorem projIci_self (a : α) : projIci a a = ⟨a, le_rfl⟩ := projIci_of_le le_rfl #align set.proj_Ici_self Set.projIci_self @[simp] theorem projIic_self (b : α) : projIic b b = ⟨b, le_rfl⟩ := projIic_of_le le_rfl #align set.proj_Iic_self Set.projIic_self @[simp] theorem projIcc_left : projIcc a b h a = ⟨a, left_mem_Icc.2 h⟩ := projIcc_of_le_left h le_rfl #align set.proj_Icc_left Set.projIcc_left @[simp] theorem projIcc_right : projIcc a b h b = ⟨b, right_mem_Icc.2 h⟩ := projIcc_of_right_le h le_rfl #align set.proj_Icc_right Set.projIcc_right theorem projIci_eq_self : projIci a x = ⟨a, le_rfl⟩ ↔ x ≤ a := by simp [projIci, Subtype.ext_iff] #align set.proj_Ici_eq_self Set.projIci_eq_self theorem projIic_eq_self : projIic b x = ⟨b, le_rfl⟩ ↔ b ≤ x := by simp [projIic, Subtype.ext_iff] #align set.proj_Iic_eq_self Set.projIic_eq_self theorem projIcc_eq_left (h : a < b) : projIcc a b h.le x = ⟨a, left_mem_Icc.mpr h.le⟩ ↔ x ≤ a := by simp [projIcc, Subtype.ext_iff, h.not_le] #align set.proj_Icc_eq_left Set.projIcc_eq_left theorem projIcc_eq_right (h : a < b) : projIcc a b h.le x = ⟨b, right_mem_Icc.2 h.le⟩ ↔ b ≤ x := by simp [projIcc, Subtype.ext_iff, max_min_distrib_left, h.le, h.not_le] #align set.proj_Icc_eq_right Set.projIcc_eq_right theorem projIci_of_mem (hx : x ∈ Ici a) : projIci a x = ⟨x, hx⟩ := by simpa [projIci] #align set.proj_Ici_of_mem Set.projIci_of_mem theorem projIic_of_mem (hx : x ∈ Iic b) : projIic b x = ⟨x, hx⟩ := by simpa [projIic] #align set.proj_Iic_of_mem Set.projIic_of_mem theorem projIcc_of_mem (hx : x ∈ Icc a b) : projIcc a b h x = ⟨x, hx⟩ := by simp [projIcc, hx.1, hx.2] #align set.proj_Icc_of_mem Set.projIcc_of_mem @[simp] theorem projIci_coe (x : Ici a) : projIci a x = x := by cases x; apply projIci_of_mem #align set.proj_Ici_coe Set.projIci_coe @[simp] theorem projIic_coe (x : Iic b) : projIic b x = x := by cases x; apply projIic_of_mem #align set.proj_Iic_coe Set.projIic_coe @[simp] theorem projIcc_val (x : Icc a b) : projIcc a b h x = x := by cases x apply projIcc_of_mem #align set.proj_Icc_coe Set.projIcc_val theorem projIci_surjOn : SurjOn (projIci a) (Ici a) univ := fun x _ => ⟨x, x.2, projIci_coe x⟩ #align set.proj_Ici_surj_on Set.projIci_surjOn theorem projIic_surjOn : SurjOn (projIic b) (Iic b) univ := fun x _ => ⟨x, x.2, projIic_coe x⟩ #align set.proj_Iic_surj_on Set.projIic_surjOn theorem projIcc_surjOn : SurjOn (projIcc a b h) (Icc a b) univ := fun x _ => ⟨x, x.2, projIcc_val h x⟩ #align set.proj_Icc_surj_on Set.projIcc_surjOn theorem projIci_surjective : Surjective (projIci a) := fun x => ⟨x, projIci_coe x⟩ #align set.proj_Ici_surjective Set.projIci_surjective theorem projIic_surjective : Surjective (projIic b) := fun x => ⟨x, projIic_coe x⟩ #align set.proj_Iic_surjective Set.projIic_surjective theorem projIcc_surjective : Surjective (projIcc a b h) := fun x => ⟨x, projIcc_val h x⟩ #align set.proj_Icc_surjective Set.projIcc_surjective @[simp] theorem range_projIci : range (projIci a) = univ := projIci_surjective.range_eq #align set.range_proj_Ici Set.range_projIci @[simp] theorem range_projIic : range (projIic a) = univ := projIic_surjective.range_eq #align set.range_proj_Iic Set.range_projIic @[simp] theorem range_projIcc : range (projIcc a b h) = univ := (projIcc_surjective h).range_eq #align set.range_proj_Icc Set.range_projIcc theorem monotone_projIci : Monotone (projIci a) := fun _ _ => max_le_max le_rfl #align set.monotone_proj_Ici Set.monotone_projIci theorem monotone_projIic : Monotone (projIic a) := fun _ _ => min_le_min le_rfl #align set.monotone_proj_Iic Set.monotone_projIic theorem monotone_projIcc : Monotone (projIcc a b h) := fun _ _ hxy => max_le_max le_rfl <| min_le_min le_rfl hxy #align set.monotone_proj_Icc Set.monotone_projIcc theorem strictMonoOn_projIci : StrictMonoOn (projIci a) (Ici a) := fun x hx y hy hxy => by simpa only [projIci_of_mem, hx, hy] #align set.strict_mono_on_proj_Ici Set.strictMonoOn_projIci theorem strictMonoOn_projIic : StrictMonoOn (projIic b) (Iic b) := fun x hx y hy hxy => by simpa only [projIic_of_mem, hx, hy] #align set.strict_mono_on_proj_Iic Set.strictMonoOn_projIic theorem strictMonoOn_projIcc : StrictMonoOn (projIcc a b h) (Icc a b) := fun x hx y hy hxy => by simpa only [projIcc_of_mem, hx, hy] #align set.strict_mono_on_proj_Icc Set.strictMonoOn_projIcc /-- Extend a function `[a, ∞) → β` to a map `α → β`. -/ def IciExtend (f : Ici a → β) : α → β := f ∘ projIci a #align set.Ici_extend Set.IciExtend /-- Extend a function `(-∞, b] → β` to a map `α → β`. -/ def IicExtend (f : Iic b → β) : α → β := f ∘ projIic b #align set.Iic_extend Set.IicExtend /-- Extend a function `[a, b] → β` to a map `α → β`. -/ def IccExtend {a b : α} (h : a ≤ b) (f : Icc a b → β) : α → β := f ∘ projIcc a b h #align set.Icc_extend Set.IccExtend theorem IciExtend_apply (f : Ici a → β) (x : α) : IciExtend f x = f ⟨max a x, le_max_left _ _⟩ := rfl #align set.Ici_extend_apply Set.IciExtend_apply theorem IicExtend_apply (f : Iic b → β) (x : α) : IicExtend f x = f ⟨min b x, min_le_left _ _⟩ := rfl #align set.Iic_extend_apply Set.IicExtend_apply theorem IccExtend_apply (h : a ≤ b) (f : Icc a b → β) (x : α) : IccExtend h f x = f ⟨max a (min b x), le_max_left _ _, max_le h (min_le_left _ _)⟩ := rfl #align set.Icc_extend_apply Set.IccExtend_apply @[simp]
Mathlib/Order/Interval/Set/ProjIcc.lean
219
220
theorem range_IciExtend (f : Ici a → β) : range (IciExtend f) = range f := by
simp only [IciExtend, range_comp f, range_projIci, range_id', image_univ]
/- Copyright (c) 2018 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot, Johannes Hölzl -/ import Mathlib.Algebra.Algebra.Defs import Mathlib.Logic.Equiv.TransferInstance import Mathlib.Topology.Algebra.GroupCompletion import Mathlib.Topology.Algebra.Ring.Ideal #align_import topology.algebra.uniform_ring from "leanprover-community/mathlib"@"9a59dcb7a2d06bf55da57b9030169219980660cd" /-! # Completion of topological rings: This files endows the completion of a topological ring with a ring structure. More precisely the instance `UniformSpace.Completion.ring` builds a ring structure on the completion of a ring endowed with a compatible uniform structure in the sense of `UniformAddGroup`. There is also a commutative version when the original ring is commutative. Moreover, if a topological ring is an algebra over a commutative semiring, then so is its `UniformSpace.Completion`. The last part of the file builds a ring structure on the biggest separated quotient of a ring. ## Main declarations: Beyond the instances explained above (that don't have to be explicitly invoked), the main constructions deal with continuous ring morphisms. * `UniformSpace.Completion.extensionHom`: extends a continuous ring morphism from `R` to a complete separated group `S` to `Completion R`. * `UniformSpace.Completion.mapRingHom` : promotes a continuous ring morphism from `R` to `S` into a continuous ring morphism from `Completion R` to `Completion S`. TODO: Generalise the results here from the concrete `Completion` to any `AbstractCompletion`. -/ open scoped Classical open Set Filter TopologicalSpace AddCommGroup open scoped Classical noncomputable section universe u namespace UniformSpace.Completion open DenseInducing UniformSpace Function section one_and_mul variable (α : Type*) [Ring α] [UniformSpace α] instance one : One (Completion α) := ⟨(1 : α)⟩ instance mul : Mul (Completion α) := ⟨curry <| (denseInducing_coe.prod denseInducing_coe).extend ((↑) ∘ uncurry (· * ·))⟩ @[norm_cast] theorem coe_one : ((1 : α) : Completion α) = 1 := rfl #align uniform_space.completion.coe_one UniformSpace.Completion.coe_one end one_and_mul variable {α : Type*} [Ring α] [UniformSpace α] [TopologicalRing α] @[norm_cast] theorem coe_mul (a b : α) : ((a * b : α) : Completion α) = a * b := ((denseInducing_coe.prod denseInducing_coe).extend_eq ((continuous_coe α).comp (@continuous_mul α _ _ _)) (a, b)).symm #align uniform_space.completion.coe_mul UniformSpace.Completion.coe_mul variable [UniformAddGroup α] theorem continuous_mul : Continuous fun p : Completion α × Completion α => p.1 * p.2 := by let m := (AddMonoidHom.mul : α →+ α →+ α).compr₂ toCompl have : Continuous fun p : α × α => m p.1 p.2 := by apply (continuous_coe α).comp _ simp only [AddMonoidHom.coe_mul, AddMonoidHom.coe_mulLeft] exact _root_.continuous_mul have di : DenseInducing (toCompl : α → Completion α) := denseInducing_coe convert di.extend_Z_bilin di this #align uniform_space.completion.continuous_mul UniformSpace.Completion.continuous_mul theorem Continuous.mul {β : Type*} [TopologicalSpace β] {f g : β → Completion α} (hf : Continuous f) (hg : Continuous g) : Continuous fun b => f b * g b := Continuous.comp continuous_mul (Continuous.prod_mk hf hg : _) #align uniform_space.completion.continuous.mul UniformSpace.Completion.Continuous.mul instance ring : Ring (Completion α) := { AddMonoidWithOne.unary, (inferInstanceAs (AddCommGroup (Completion α))), (inferInstanceAs (Mul (Completion α))), (inferInstanceAs (One (Completion α))) with zero_mul := fun a => Completion.induction_on a (isClosed_eq (Continuous.mul continuous_const continuous_id) continuous_const) fun a => by rw [← coe_zero, ← coe_mul, zero_mul] mul_zero := fun a => Completion.induction_on a (isClosed_eq (Continuous.mul continuous_id continuous_const) continuous_const) fun a => by rw [← coe_zero, ← coe_mul, mul_zero] one_mul := fun a => Completion.induction_on a (isClosed_eq (Continuous.mul continuous_const continuous_id) continuous_id) fun a => by rw [← coe_one, ← coe_mul, one_mul] mul_one := fun a => Completion.induction_on a (isClosed_eq (Continuous.mul continuous_id continuous_const) continuous_id) fun a => by rw [← coe_one, ← coe_mul, mul_one] mul_assoc := fun a b c => Completion.induction_on₃ a b c (isClosed_eq (Continuous.mul (Continuous.mul continuous_fst (continuous_fst.comp continuous_snd)) (continuous_snd.comp continuous_snd)) (Continuous.mul continuous_fst (Continuous.mul (continuous_fst.comp continuous_snd) (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_mul, ← coe_mul, ← coe_mul, ← coe_mul, mul_assoc] left_distrib := fun a b c => Completion.induction_on₃ a b c (isClosed_eq (Continuous.mul continuous_fst (Continuous.add (continuous_fst.comp continuous_snd) (continuous_snd.comp continuous_snd))) (Continuous.add (Continuous.mul continuous_fst (continuous_fst.comp continuous_snd)) (Continuous.mul continuous_fst (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_add, ← coe_mul, ← coe_mul, ← coe_mul, ← coe_add, mul_add] right_distrib := fun a b c => Completion.induction_on₃ a b c (isClosed_eq (Continuous.mul (Continuous.add continuous_fst (continuous_fst.comp continuous_snd)) (continuous_snd.comp continuous_snd)) (Continuous.add (Continuous.mul continuous_fst (continuous_snd.comp continuous_snd)) (Continuous.mul (continuous_fst.comp continuous_snd) (continuous_snd.comp continuous_snd)))) fun a b c => by rw [← coe_add, ← coe_mul, ← coe_mul, ← coe_mul, ← coe_add, add_mul] } /-- The map from a uniform ring to its completion, as a ring homomorphism. -/ def coeRingHom : α →+* Completion α where toFun := (↑) map_one' := coe_one α map_zero' := coe_zero map_add' := coe_add map_mul' := coe_mul #align uniform_space.completion.coe_ring_hom UniformSpace.Completion.coeRingHom theorem continuous_coeRingHom : Continuous (coeRingHom : α → Completion α) := continuous_coe α #align uniform_space.completion.continuous_coe_ring_hom UniformSpace.Completion.continuous_coeRingHom variable {β : Type u} [UniformSpace β] [Ring β] [UniformAddGroup β] [TopologicalRing β] (f : α →+* β) (hf : Continuous f) /-- The completion extension as a ring morphism. -/ def extensionHom [CompleteSpace β] [T0Space β] : Completion α →+* β := have hf' : Continuous (f : α →+ β) := hf -- helping the elaborator have hf : UniformContinuous f := uniformContinuous_addMonoidHom_of_continuous hf' { toFun := Completion.extension f map_zero' := by simp_rw [← coe_zero, extension_coe hf, f.map_zero] map_add' := fun a b => Completion.induction_on₂ a b (isClosed_eq (continuous_extension.comp continuous_add) ((continuous_extension.comp continuous_fst).add (continuous_extension.comp continuous_snd))) fun a b => by simp_rw [← coe_add, extension_coe hf, f.map_add] map_one' := by rw [← coe_one, extension_coe hf, f.map_one] map_mul' := fun a b => Completion.induction_on₂ a b (isClosed_eq (continuous_extension.comp continuous_mul) ((continuous_extension.comp continuous_fst).mul (continuous_extension.comp continuous_snd))) fun a b => by simp_rw [← coe_mul, extension_coe hf, f.map_mul] } #align uniform_space.completion.extension_hom UniformSpace.Completion.extensionHom instance topologicalRing : TopologicalRing (Completion α) where continuous_add := continuous_add continuous_mul := continuous_mul #align uniform_space.completion.top_ring_compl UniformSpace.Completion.topologicalRing /-- The completion map as a ring morphism. -/ def mapRingHom (hf : Continuous f) : Completion α →+* Completion β := extensionHom (coeRingHom.comp f) (continuous_coeRingHom.comp hf) #align uniform_space.completion.map_ring_hom UniformSpace.Completion.mapRingHom section Algebra variable (A : Type*) [Ring A] [UniformSpace A] [UniformAddGroup A] [TopologicalRing A] (R : Type*) [CommSemiring R] [Algebra R A] [UniformContinuousConstSMul R A] @[simp]
Mathlib/Topology/Algebra/UniformRing.lean
195
200
theorem map_smul_eq_mul_coe (r : R) : Completion.map (r • ·) = ((algebraMap R A r : Completion A) * ·) := by
ext x refine Completion.induction_on x ?_ fun a => ?_ · exact isClosed_eq Completion.continuous_map (continuous_mul_left _) · simp_rw [map_coe (uniformContinuous_const_smul r) a, Algebra.smul_def, coe_mul]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro -/ import Mathlib.Mathport.Rename import Mathlib.Tactic.Lemma import Mathlib.Tactic.TypeStar #align_import data.option.defs from "leanprover-community/mathlib"@"c4658a649d216f57e99621708b09dcb3dcccbd23" /-! # Extra definitions on `Option` This file defines more operations involving `Option α`. Lemmas about them are located in other files under `Mathlib.Data.Option`. Other basic operations on `Option` are defined in the core library. -/ namespace Option #align option.lift_or_get Option.liftOrGet /-- Traverse an object of `Option α` with a function `f : α → F β` for an applicative `F`. -/ protected def traverse.{u, v} {F : Type u → Type v} [Applicative F] {α : Type*} {β : Type u} (f : α → F β) : Option α → F (Option β) | none => pure none | some x => some <$> f x #align option.traverse Option.traverse #align option.maybe Option.sequence #align option.mmap Option.mapM #align option.melim Option.elimM #align option.mget_or_else Option.getDM variable {α : Type*} {β : Type*} -- Porting note: Would need to add the attribute directly in `Init.Prelude`. -- attribute [inline] Option.isSome Option.isNone /-- An elimination principle for `Option`. It is a nondependent version of `Option.rec`. -/ protected def elim' (b : β) (f : α → β) : Option α → β | some a => f a | none => b #align option.elim Option.elim' @[simp] theorem elim'_none (b : β) (f : α → β) : Option.elim' b f none = b := rfl @[simp] theorem elim'_some {a : α} (b : β) (f : α → β) : Option.elim' b f (some a) = f a := rfl -- Porting note: this lemma was introduced because it is necessary -- in `CategoryTheory.Category.PartialFun` lemma elim'_eq_elim {α β : Type*} (b : β) (f : α → β) (a : Option α) : Option.elim' b f a = Option.elim a b f := by cases a <;> rfl theorem mem_some_iff {α : Type*} {a b : α} : a ∈ some b ↔ b = a := by simp #align option.mem_some_iff Option.mem_some_iff /-- `o = none` is decidable even if the wrapped type does not have decidable equality. This is not an instance because it is not definitionally equal to `Option.decidableEq`. Try to use `o.isNone` or `o.isSome` instead. -/ @[inline] def decidableEqNone {o : Option α} : Decidable (o = none) := decidable_of_decidable_of_iff isNone_iff_eq_none #align option.decidable_eq_none Option.decidableEqNone instance decidableForallMem {p : α → Prop} [DecidablePred p] : ∀ o : Option α, Decidable (∀ a ∈ o, p a) | none => isTrue (by simp [false_imp_iff]) | some a => if h : p a then isTrue fun o e ↦ some_inj.1 e ▸ h else isFalse <| mt (fun H ↦ H _ rfl) h instance decidableExistsMem {p : α → Prop} [DecidablePred p] : ∀ o : Option α, Decidable (∃ a ∈ o, p a) | none => isFalse fun ⟨a, ⟨h, _⟩⟩ ↦ by cases h | some a => if h : p a then isTrue <| ⟨_, rfl, h⟩ else isFalse fun ⟨_, ⟨rfl, hn⟩⟩ ↦ h hn /-- Inhabited `get` function. Returns `a` if the input is `some a`, otherwise returns `default`. -/ abbrev iget [Inhabited α] : Option α → α | some x => x | none => default #align option.iget Option.iget theorem iget_some [Inhabited α] {a : α} : (some a).iget = a := rfl #align option.iget_some Option.iget_some @[simp]
Mathlib/Data/Option/Defs.lean
96
97
theorem mem_toList {a : α} {o : Option α} : a ∈ toList o ↔ a ∈ o := by
cases o <;> simp [toList, eq_comm]
/- Copyright (c) 2021 Rémy Degenne. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne -/ import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp #align_import measure_theory.integral.set_to_l1 from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Extension of a linear function from indicators to L1 Let `T : Set α → E →L[ℝ] F` be additive for measurable sets with finite measure, in the sense that for `s, t` two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. `T` is akin to a bilinear map on `Set α × E`, or a linear map on indicator functions. This file constructs an extension of `T` to integrable simple functions, which are finite sums of indicators of measurable sets with finite measure, then to integrable functions, which are limits of integrable simple functions. The main result is a continuous linear map `(α →₁[μ] E) →L[ℝ] F`. This extension process is used to define the Bochner integral in the `MeasureTheory.Integral.Bochner` file and the conditional expectation of an integrable function in `MeasureTheory.Function.ConditionalExpectation`. ## Main Definitions - `FinMeasAdditive μ T`: the property that `T` is additive on measurable sets with finite measure. For two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. - `DominatedFinMeasAdditive μ T C`: `FinMeasAdditive μ T ∧ ∀ s, ‖T s‖ ≤ C * (μ s).toReal`. This is the property needed to perform the extension from indicators to L1. - `setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F`: the extension of `T` from indicators to L1. - `setToFun μ T (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F`: a version of the extension which applies to functions (with value 0 if the function is not integrable). ## Properties For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on measurable sets with finite measure, like `∀ s, MeasurableSet s → μ s < ∞ → T s = T' s`. The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details. Linearity: - `setToFun_zero_left : setToFun μ 0 hT f = 0` - `setToFun_add_left : setToFun μ (T + T') _ f = setToFun μ T hT f + setToFun μ T' hT' f` - `setToFun_smul_left : setToFun μ (fun s ↦ c • (T s)) (hT.smul c) f = c • setToFun μ T hT f` - `setToFun_zero : setToFun μ T hT (0 : α → E) = 0` - `setToFun_neg : setToFun μ T hT (-f) = - setToFun μ T hT f` If `f` and `g` are integrable: - `setToFun_add : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g` - `setToFun_sub : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g` If `T` is verifies `∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x`: - `setToFun_smul : setToFun μ T hT (c • f) = c • setToFun μ T hT f` Other: - `setToFun_congr_ae (h : f =ᵐ[μ] g) : setToFun μ T hT f = setToFun μ T hT g` - `setToFun_measure_zero (h : μ = 0) : setToFun μ T hT f = 0` If the space is a `NormedLatticeAddCommGroup` and `T` is such that `0 ≤ T s x` for `0 ≤ x`, we also prove order-related properties: - `setToFun_mono_left (h : ∀ s x, T s x ≤ T' s x) : setToFun μ T hT f ≤ setToFun μ T' hT' f` - `setToFun_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ setToFun μ T hT f` - `setToFun_mono (hfg : f ≤ᵐ[μ] g) : setToFun μ T hT f ≤ setToFun μ T hT g` ## Implementation notes The starting object `T : Set α → E →L[ℝ] F` matters only through its restriction on measurable sets with finite measure. Its value on other sets is ignored. -/ noncomputable section open scoped Classical Topology NNReal ENNReal MeasureTheory Pointwise open Set Filter TopologicalSpace ENNReal EMetric namespace MeasureTheory variable {α E F F' G 𝕜 : Type*} {p : ℝ≥0∞} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α} local infixr:25 " →ₛ " => SimpleFunc open Finset section FinMeasAdditive /-- A set function is `FinMeasAdditive` if its value on the union of two disjoint measurable sets with finite measure is the sum of its values on each set. -/ def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) : Prop := ∀ s t, MeasurableSet s → MeasurableSet t → μ s ≠ ∞ → μ t ≠ ∞ → s ∩ t = ∅ → T (s ∪ t) = T s + T t #align measure_theory.fin_meas_additive MeasureTheory.FinMeasAdditive namespace FinMeasAdditive variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β} theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun s t _ _ _ _ _ => by simp #align measure_theory.fin_meas_additive.zero MeasureTheory.FinMeasAdditive.zero theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') : FinMeasAdditive μ (T + T') := by intro s t hs ht hμs hμt hst simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply] abel #align measure_theory.fin_meas_additive.add MeasureTheory.FinMeasAdditive.add theorem smul [Monoid 𝕜] [DistribMulAction 𝕜 β] (hT : FinMeasAdditive μ T) (c : 𝕜) : FinMeasAdditive μ fun s => c • T s := fun s t hs ht hμs hμt hst => by simp [hT s t hs ht hμs hμt hst] #align measure_theory.fin_meas_additive.smul MeasureTheory.FinMeasAdditive.smul theorem of_eq_top_imp_eq_top {μ' : Measure α} (h : ∀ s, MeasurableSet s → μ s = ∞ → μ' s = ∞) (hT : FinMeasAdditive μ T) : FinMeasAdditive μ' T := fun s t hs ht hμ's hμ't hst => hT s t hs ht (mt (h s hs) hμ's) (mt (h t ht) hμ't) hst #align measure_theory.fin_meas_additive.of_eq_top_imp_eq_top MeasureTheory.FinMeasAdditive.of_eq_top_imp_eq_top theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : FinMeasAdditive (c • μ) T) : FinMeasAdditive μ T := by refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top] at hμs simp only [hc_ne_top, or_false_iff, Ne, false_and_iff] at hμs exact hμs.2 #align measure_theory.fin_meas_additive.of_smul_measure MeasureTheory.FinMeasAdditive.of_smul_measure theorem smul_measure (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hT : FinMeasAdditive μ T) : FinMeasAdditive (c • μ) T := by refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top] simp only [hc_ne_zero, true_and_iff, Ne, not_false_iff] exact Or.inl hμs #align measure_theory.fin_meas_additive.smul_measure MeasureTheory.FinMeasAdditive.smul_measure theorem smul_measure_iff (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hc_ne_top : c ≠ ∞) : FinMeasAdditive (c • μ) T ↔ FinMeasAdditive μ T := ⟨fun hT => of_smul_measure c hc_ne_top hT, fun hT => smul_measure c hc_ne_zero hT⟩ #align measure_theory.fin_meas_additive.smul_measure_iff MeasureTheory.FinMeasAdditive.smul_measure_iff theorem map_empty_eq_zero {β} [AddCancelMonoid β] {T : Set α → β} (hT : FinMeasAdditive μ T) : T ∅ = 0 := by have h_empty : μ ∅ ≠ ∞ := (measure_empty.le.trans_lt ENNReal.coe_lt_top).ne specialize hT ∅ ∅ MeasurableSet.empty MeasurableSet.empty h_empty h_empty (Set.inter_empty ∅) rw [Set.union_empty] at hT nth_rw 1 [← add_zero (T ∅)] at hT exact (add_left_cancel hT).symm #align measure_theory.fin_meas_additive.map_empty_eq_zero MeasureTheory.FinMeasAdditive.map_empty_eq_zero theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0) (h_add : FinMeasAdditive μ T) {ι} (S : ι → Set α) (sι : Finset ι) (hS_meas : ∀ i, MeasurableSet (S i)) (hSp : ∀ i ∈ sι, μ (S i) ≠ ∞) (h_disj : ∀ᵉ (i ∈ sι) (j ∈ sι), i ≠ j → Disjoint (S i) (S j)) : T (⋃ i ∈ sι, S i) = ∑ i ∈ sι, T (S i) := by revert hSp h_disj refine Finset.induction_on sι ?_ ?_ · simp only [Finset.not_mem_empty, IsEmpty.forall_iff, iUnion_false, iUnion_empty, sum_empty, forall₂_true_iff, imp_true_iff, forall_true_left, not_false_iff, T_empty] intro a s has h hps h_disj rw [Finset.sum_insert has, ← h] swap; · exact fun i hi => hps i (Finset.mem_insert_of_mem hi) swap; · exact fun i hi j hj hij => h_disj i (Finset.mem_insert_of_mem hi) j (Finset.mem_insert_of_mem hj) hij rw [← h_add (S a) (⋃ i ∈ s, S i) (hS_meas a) (measurableSet_biUnion _ fun i _ => hS_meas i) (hps a (Finset.mem_insert_self a s))] · congr; convert Finset.iSup_insert a s S · exact ((measure_biUnion_finset_le _ _).trans_lt <| ENNReal.sum_lt_top fun i hi => hps i <| Finset.mem_insert_of_mem hi).ne · simp_rw [Set.inter_iUnion] refine iUnion_eq_empty.mpr fun i => iUnion_eq_empty.mpr fun hi => ?_ rw [← Set.disjoint_iff_inter_eq_empty] refine h_disj a (Finset.mem_insert_self a s) i (Finset.mem_insert_of_mem hi) fun hai => ?_ rw [← hai] at hi exact has hi #align measure_theory.fin_meas_additive.map_Union_fin_meas_set_eq_sum MeasureTheory.FinMeasAdditive.map_iUnion_fin_meas_set_eq_sum end FinMeasAdditive /-- A `FinMeasAdditive` set function whose norm on every set is less than the measure of the set (up to a multiplicative constant). -/ def DominatedFinMeasAdditive {β} [SeminormedAddCommGroup β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) (C : ℝ) : Prop := FinMeasAdditive μ T ∧ ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal #align measure_theory.dominated_fin_meas_additive MeasureTheory.DominatedFinMeasAdditive namespace DominatedFinMeasAdditive variable {β : Type*} [SeminormedAddCommGroup β] {T T' : Set α → β} {C C' : ℝ} theorem zero {m : MeasurableSpace α} (μ : Measure α) (hC : 0 ≤ C) : DominatedFinMeasAdditive μ (0 : Set α → β) C := by refine ⟨FinMeasAdditive.zero, fun s _ _ => ?_⟩ rw [Pi.zero_apply, norm_zero] exact mul_nonneg hC toReal_nonneg #align measure_theory.dominated_fin_meas_additive.zero MeasureTheory.DominatedFinMeasAdditive.zero theorem eq_zero_of_measure_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C) {s : Set α} (hs : MeasurableSet s) (hs_zero : μ s = 0) : T s = 0 := by refine norm_eq_zero.mp ?_ refine ((hT.2 s hs (by simp [hs_zero])).trans (le_of_eq ?_)).antisymm (norm_nonneg _) rw [hs_zero, ENNReal.zero_toReal, mul_zero] #align measure_theory.dominated_fin_meas_additive.eq_zero_of_measure_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero_of_measure_zero theorem eq_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ} {m : MeasurableSpace α} (hT : DominatedFinMeasAdditive (0 : Measure α) T C) {s : Set α} (hs : MeasurableSet s) : T s = 0 := eq_zero_of_measure_zero hT hs (by simp only [Measure.coe_zero, Pi.zero_apply]) #align measure_theory.dominated_fin_meas_additive.eq_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero theorem add (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') : DominatedFinMeasAdditive μ (T + T') (C + C') := by refine ⟨hT.1.add hT'.1, fun s hs hμs => ?_⟩ rw [Pi.add_apply, add_mul] exact (norm_add_le _ _).trans (add_le_add (hT.2 s hs hμs) (hT'.2 s hs hμs)) #align measure_theory.dominated_fin_meas_additive.add MeasureTheory.DominatedFinMeasAdditive.add theorem smul [NormedField 𝕜] [NormedSpace 𝕜 β] (hT : DominatedFinMeasAdditive μ T C) (c : 𝕜) : DominatedFinMeasAdditive μ (fun s => c • T s) (‖c‖ * C) := by refine ⟨hT.1.smul c, fun s hs hμs => ?_⟩ dsimp only rw [norm_smul, mul_assoc] exact mul_le_mul le_rfl (hT.2 s hs hμs) (norm_nonneg _) (norm_nonneg _) #align measure_theory.dominated_fin_meas_additive.smul MeasureTheory.DominatedFinMeasAdditive.smul theorem of_measure_le {μ' : Measure α} (h : μ ≤ μ') (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive μ' T C := by have h' : ∀ s, μ s = ∞ → μ' s = ∞ := fun s hs ↦ top_unique <| hs.symm.trans_le (h _) refine ⟨hT.1.of_eq_top_imp_eq_top fun s _ ↦ h' s, fun s hs hμ's ↦ ?_⟩ have hμs : μ s < ∞ := (h s).trans_lt hμ's calc ‖T s‖ ≤ C * (μ s).toReal := hT.2 s hs hμs _ ≤ C * (μ' s).toReal := by gcongr; exacts [hμ's.ne, h _] #align measure_theory.dominated_fin_meas_additive.of_measure_le MeasureTheory.DominatedFinMeasAdditive.of_measure_le theorem add_measure_right {_ : MeasurableSpace α} (μ ν : Measure α) (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C := of_measure_le (Measure.le_add_right le_rfl) hT hC #align measure_theory.dominated_fin_meas_additive.add_measure_right MeasureTheory.DominatedFinMeasAdditive.add_measure_right theorem add_measure_left {_ : MeasurableSpace α} (μ ν : Measure α) (hT : DominatedFinMeasAdditive ν T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C := of_measure_le (Measure.le_add_left le_rfl) hT hC #align measure_theory.dominated_fin_meas_additive.add_measure_left MeasureTheory.DominatedFinMeasAdditive.add_measure_left theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : DominatedFinMeasAdditive (c • μ) T C) : DominatedFinMeasAdditive μ T (c.toReal * C) := by have h : ∀ s, MeasurableSet s → c • μ s = ∞ → μ s = ∞ := by intro s _ hcμs simp only [hc_ne_top, Algebra.id.smul_eq_mul, ENNReal.mul_eq_top, or_false_iff, Ne, false_and_iff] at hcμs exact hcμs.2 refine ⟨hT.1.of_eq_top_imp_eq_top (μ := c • μ) h, fun s hs hμs => ?_⟩ have hcμs : c • μ s ≠ ∞ := mt (h s hs) hμs.ne rw [smul_eq_mul] at hcμs simp_rw [DominatedFinMeasAdditive, Measure.smul_apply, smul_eq_mul, toReal_mul] at hT refine (hT.2 s hs hcμs.lt_top).trans (le_of_eq ?_) ring #align measure_theory.dominated_fin_meas_additive.of_smul_measure MeasureTheory.DominatedFinMeasAdditive.of_smul_measure theorem of_measure_le_smul {μ' : Measure α} (c : ℝ≥0∞) (hc : c ≠ ∞) (h : μ ≤ c • μ') (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive μ' T (c.toReal * C) := (hT.of_measure_le h hC).of_smul_measure c hc #align measure_theory.dominated_fin_meas_additive.of_measure_le_smul MeasureTheory.DominatedFinMeasAdditive.of_measure_le_smul end DominatedFinMeasAdditive end FinMeasAdditive namespace SimpleFunc /-- Extend `Set α → (F →L[ℝ] F')` to `(α →ₛ F) → F'`. -/ def setToSimpleFunc {_ : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (f : α →ₛ F) : F' := ∑ x ∈ f.range, T (f ⁻¹' {x}) x #align measure_theory.simple_func.set_to_simple_func MeasureTheory.SimpleFunc.setToSimpleFunc @[simp] theorem setToSimpleFunc_zero {m : MeasurableSpace α} (f : α →ₛ F) : setToSimpleFunc (0 : Set α → F →L[ℝ] F') f = 0 := by simp [setToSimpleFunc] #align measure_theory.simple_func.set_to_simple_func_zero MeasureTheory.SimpleFunc.setToSimpleFunc_zero theorem setToSimpleFunc_zero' {T : Set α → E →L[ℝ] F'} (h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →ₛ E) (hf : Integrable f μ) : setToSimpleFunc T f = 0 := by simp_rw [setToSimpleFunc] refine sum_eq_zero fun x _ => ?_ by_cases hx0 : x = 0 · simp [hx0] rw [h_zero (f ⁻¹' ({x} : Set E)) (measurableSet_fiber _ _) (measure_preimage_lt_top_of_integrable f hf hx0), ContinuousLinearMap.zero_apply] #align measure_theory.simple_func.set_to_simple_func_zero' MeasureTheory.SimpleFunc.setToSimpleFunc_zero' @[simp] theorem setToSimpleFunc_zero_apply {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') : setToSimpleFunc T (0 : α →ₛ F) = 0 := by cases isEmpty_or_nonempty α <;> simp [setToSimpleFunc] #align measure_theory.simple_func.set_to_simple_func_zero_apply MeasureTheory.SimpleFunc.setToSimpleFunc_zero_apply theorem setToSimpleFunc_eq_sum_filter {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (f : α →ₛ F) : setToSimpleFunc T f = ∑ x ∈ f.range.filter fun x => x ≠ 0, (T (f ⁻¹' {x})) x := by symm refine sum_filter_of_ne fun x _ => mt fun hx0 => ?_ rw [hx0] exact ContinuousLinearMap.map_zero _ #align measure_theory.simple_func.set_to_simple_func_eq_sum_filter MeasureTheory.SimpleFunc.setToSimpleFunc_eq_sum_filter theorem map_setToSimpleFunc (T : Set α → F →L[ℝ] F') (h_add : FinMeasAdditive μ T) {f : α →ₛ G} (hf : Integrable f μ) {g : G → F} (hg : g 0 = 0) : (f.map g).setToSimpleFunc T = ∑ x ∈ f.range, T (f ⁻¹' {x}) (g x) := by have T_empty : T ∅ = 0 := h_add.map_empty_eq_zero have hfp : ∀ x ∈ f.range, x ≠ 0 → μ (f ⁻¹' {x}) ≠ ∞ := fun x _ hx0 => (measure_preimage_lt_top_of_integrable f hf hx0).ne simp only [setToSimpleFunc, range_map] refine Finset.sum_image' _ fun b hb => ?_ rcases mem_range.1 hb with ⟨a, rfl⟩ by_cases h0 : g (f a) = 0 · simp_rw [h0] rw [ContinuousLinearMap.map_zero, Finset.sum_eq_zero fun x hx => ?_] rw [mem_filter] at hx rw [hx.2, ContinuousLinearMap.map_zero] have h_left_eq : T (map g f ⁻¹' {g (f a)}) (g (f a)) = T (f ⁻¹' (f.range.filter fun b => g b = g (f a))) (g (f a)) := by congr; rw [map_preimage_singleton] rw [h_left_eq] have h_left_eq' : T (f ⁻¹' (filter (fun b : G => g b = g (f a)) f.range)) (g (f a)) = T (⋃ y ∈ filter (fun b : G => g b = g (f a)) f.range, f ⁻¹' {y}) (g (f a)) := by congr; rw [← Finset.set_biUnion_preimage_singleton] rw [h_left_eq'] rw [h_add.map_iUnion_fin_meas_set_eq_sum T T_empty] · simp only [sum_apply, ContinuousLinearMap.coe_sum'] refine Finset.sum_congr rfl fun x hx => ?_ rw [mem_filter] at hx rw [hx.2] · exact fun i => measurableSet_fiber _ _ · intro i hi rw [mem_filter] at hi refine hfp i hi.1 fun hi0 => ?_ rw [hi0, hg] at hi exact h0 hi.2.symm · intro i _j hi _ hij rw [Set.disjoint_iff] intro x hx rw [Set.mem_inter_iff, Set.mem_preimage, Set.mem_preimage, Set.mem_singleton_iff, Set.mem_singleton_iff] at hx rw [← hx.1, ← hx.2] at hij exact absurd rfl hij #align measure_theory.simple_func.map_set_to_simple_func MeasureTheory.SimpleFunc.map_setToSimpleFunc theorem setToSimpleFunc_congr' (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E} (hf : Integrable f μ) (hg : Integrable g μ) (h : Pairwise fun x y => T (f ⁻¹' {x} ∩ g ⁻¹' {y}) = 0) : f.setToSimpleFunc T = g.setToSimpleFunc T := show ((pair f g).map Prod.fst).setToSimpleFunc T = ((pair f g).map Prod.snd).setToSimpleFunc T by have h_pair : Integrable (f.pair g) μ := integrable_pair hf hg rw [map_setToSimpleFunc T h_add h_pair Prod.fst_zero] rw [map_setToSimpleFunc T h_add h_pair Prod.snd_zero] refine Finset.sum_congr rfl fun p hp => ?_ rcases mem_range.1 hp with ⟨a, rfl⟩ by_cases eq : f a = g a · dsimp only [pair_apply]; rw [eq] · have : T (pair f g ⁻¹' {(f a, g a)}) = 0 := by have h_eq : T ((⇑(f.pair g)) ⁻¹' {(f a, g a)}) = T (f ⁻¹' {f a} ∩ g ⁻¹' {g a}) := by congr; rw [pair_preimage_singleton f g] rw [h_eq] exact h eq simp only [this, ContinuousLinearMap.zero_apply, pair_apply] #align measure_theory.simple_func.set_to_simple_func_congr' MeasureTheory.SimpleFunc.setToSimpleFunc_congr' theorem setToSimpleFunc_congr (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E} (hf : Integrable f μ) (h : f =ᵐ[μ] g) : f.setToSimpleFunc T = g.setToSimpleFunc T := by refine setToSimpleFunc_congr' T h_add hf ((integrable_congr h).mp hf) ?_ refine fun x y hxy => h_zero _ ((measurableSet_fiber f x).inter (measurableSet_fiber g y)) ?_ rw [EventuallyEq, ae_iff] at h refine measure_mono_null (fun z => ?_) h simp_rw [Set.mem_inter_iff, Set.mem_setOf_eq, Set.mem_preimage, Set.mem_singleton_iff] intro h rwa [h.1, h.2] #align measure_theory.simple_func.set_to_simple_func_congr MeasureTheory.SimpleFunc.setToSimpleFunc_congr theorem setToSimpleFunc_congr_left (T T' : Set α → E →L[ℝ] F) (h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →ₛ E) (hf : Integrable f μ) : setToSimpleFunc T f = setToSimpleFunc T' f := by simp_rw [setToSimpleFunc] refine sum_congr rfl fun x _ => ?_ by_cases hx0 : x = 0 · simp [hx0] · rw [h (f ⁻¹' {x}) (SimpleFunc.measurableSet_fiber _ _) (SimpleFunc.measure_preimage_lt_top_of_integrable _ hf hx0)] #align measure_theory.simple_func.set_to_simple_func_congr_left MeasureTheory.SimpleFunc.setToSimpleFunc_congr_left theorem setToSimpleFunc_add_left {m : MeasurableSpace α} (T T' : Set α → F →L[ℝ] F') {f : α →ₛ F} : setToSimpleFunc (T + T') f = setToSimpleFunc T f + setToSimpleFunc T' f := by simp_rw [setToSimpleFunc, Pi.add_apply] push_cast simp_rw [Pi.add_apply, sum_add_distrib] #align measure_theory.simple_func.set_to_simple_func_add_left MeasureTheory.SimpleFunc.setToSimpleFunc_add_left theorem setToSimpleFunc_add_left' (T T' T'' : Set α → E →L[ℝ] F) (h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) {f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T'' f = setToSimpleFunc T f + setToSimpleFunc T' f := by simp_rw [setToSimpleFunc_eq_sum_filter] suffices ∀ x ∈ filter (fun x : E => x ≠ 0) f.range, T'' (f ⁻¹' {x}) = T (f ⁻¹' {x}) + T' (f ⁻¹' {x}) by rw [← sum_add_distrib] refine Finset.sum_congr rfl fun x hx => ?_ rw [this x hx] push_cast rw [Pi.add_apply] intro x hx refine h_add (f ⁻¹' {x}) (measurableSet_preimage _ _) (measure_preimage_lt_top_of_integrable _ hf ?_) rw [mem_filter] at hx exact hx.2 #align measure_theory.simple_func.set_to_simple_func_add_left' MeasureTheory.SimpleFunc.setToSimpleFunc_add_left' theorem setToSimpleFunc_smul_left {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (c : ℝ) (f : α →ₛ F) : setToSimpleFunc (fun s => c • T s) f = c • setToSimpleFunc T f := by simp_rw [setToSimpleFunc, ContinuousLinearMap.smul_apply, smul_sum] #align measure_theory.simple_func.set_to_simple_func_smul_left MeasureTheory.SimpleFunc.setToSimpleFunc_smul_left theorem setToSimpleFunc_smul_left' (T T' : Set α → E →L[ℝ] F') (c : ℝ) (h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) {f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T' f = c • setToSimpleFunc T f := by simp_rw [setToSimpleFunc_eq_sum_filter] suffices ∀ x ∈ filter (fun x : E => x ≠ 0) f.range, T' (f ⁻¹' {x}) = c • T (f ⁻¹' {x}) by rw [smul_sum] refine Finset.sum_congr rfl fun x hx => ?_ rw [this x hx] rfl intro x hx refine h_smul (f ⁻¹' {x}) (measurableSet_preimage _ _) (measure_preimage_lt_top_of_integrable _ hf ?_) rw [mem_filter] at hx exact hx.2 #align measure_theory.simple_func.set_to_simple_func_smul_left' MeasureTheory.SimpleFunc.setToSimpleFunc_smul_left' theorem setToSimpleFunc_add (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E} (hf : Integrable f μ) (hg : Integrable g μ) : setToSimpleFunc T (f + g) = setToSimpleFunc T f + setToSimpleFunc T g := have hp_pair : Integrable (f.pair g) μ := integrable_pair hf hg calc setToSimpleFunc T (f + g) = ∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) (x.fst + x.snd) := by rw [add_eq_map₂, map_setToSimpleFunc T h_add hp_pair]; simp _ = ∑ x ∈ (pair f g).range, (T (pair f g ⁻¹' {x}) x.fst + T (pair f g ⁻¹' {x}) x.snd) := (Finset.sum_congr rfl fun a _ => ContinuousLinearMap.map_add _ _ _) _ = (∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) x.fst) + ∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) x.snd := by rw [Finset.sum_add_distrib] _ = ((pair f g).map Prod.fst).setToSimpleFunc T + ((pair f g).map Prod.snd).setToSimpleFunc T := by rw [map_setToSimpleFunc T h_add hp_pair Prod.snd_zero, map_setToSimpleFunc T h_add hp_pair Prod.fst_zero] #align measure_theory.simple_func.set_to_simple_func_add MeasureTheory.SimpleFunc.setToSimpleFunc_add theorem setToSimpleFunc_neg (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T (-f) = -setToSimpleFunc T f := calc setToSimpleFunc T (-f) = setToSimpleFunc T (f.map Neg.neg) := rfl _ = -setToSimpleFunc T f := by rw [map_setToSimpleFunc T h_add hf neg_zero, setToSimpleFunc, ← sum_neg_distrib] exact Finset.sum_congr rfl fun x _ => ContinuousLinearMap.map_neg _ _ #align measure_theory.simple_func.set_to_simple_func_neg MeasureTheory.SimpleFunc.setToSimpleFunc_neg theorem setToSimpleFunc_sub (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E} (hf : Integrable f μ) (hg : Integrable g μ) : setToSimpleFunc T (f - g) = setToSimpleFunc T f - setToSimpleFunc T g := by rw [sub_eq_add_neg, setToSimpleFunc_add T h_add hf, setToSimpleFunc_neg T h_add hg, sub_eq_add_neg] rw [integrable_iff] at hg ⊢ intro x hx_ne change μ (Neg.neg ∘ g ⁻¹' {x}) < ∞ rw [preimage_comp, neg_preimage, Set.neg_singleton] refine hg (-x) ?_ simp [hx_ne] #align measure_theory.simple_func.set_to_simple_func_sub MeasureTheory.SimpleFunc.setToSimpleFunc_sub theorem setToSimpleFunc_smul_real (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) (c : ℝ) {f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T (c • f) = c • setToSimpleFunc T f := calc setToSimpleFunc T (c • f) = ∑ x ∈ f.range, T (f ⁻¹' {x}) (c • x) := by rw [smul_eq_map c f, map_setToSimpleFunc T h_add hf]; dsimp only; rw [smul_zero] _ = ∑ x ∈ f.range, c • T (f ⁻¹' {x}) x := (Finset.sum_congr rfl fun b _ => by rw [ContinuousLinearMap.map_smul (T (f ⁻¹' {b})) c b]) _ = c • setToSimpleFunc T f := by simp only [setToSimpleFunc, smul_sum, smul_smul, mul_comm] #align measure_theory.simple_func.set_to_simple_func_smul_real MeasureTheory.SimpleFunc.setToSimpleFunc_smul_real theorem setToSimpleFunc_smul {E} [NormedAddCommGroup E] [NormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace ℝ E] [NormedSpace 𝕜 F] (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) (h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜) {f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T (c • f) = c • setToSimpleFunc T f := calc setToSimpleFunc T (c • f) = ∑ x ∈ f.range, T (f ⁻¹' {x}) (c • x) := by rw [smul_eq_map c f, map_setToSimpleFunc T h_add hf]; dsimp only; rw [smul_zero] _ = ∑ x ∈ f.range, c • T (f ⁻¹' {x}) x := Finset.sum_congr rfl fun b _ => by rw [h_smul] _ = c • setToSimpleFunc T f := by simp only [setToSimpleFunc, smul_sum, smul_smul, mul_comm] #align measure_theory.simple_func.set_to_simple_func_smul MeasureTheory.SimpleFunc.setToSimpleFunc_smul section Order variable {G' G'' : Type*} [NormedLatticeAddCommGroup G''] [NormedSpace ℝ G''] [NormedLatticeAddCommGroup G'] [NormedSpace ℝ G'] theorem setToSimpleFunc_mono_left {m : MeasurableSpace α} (T T' : Set α → F →L[ℝ] G'') (hTT' : ∀ s x, T s x ≤ T' s x) (f : α →ₛ F) : setToSimpleFunc T f ≤ setToSimpleFunc T' f := by simp_rw [setToSimpleFunc]; exact sum_le_sum fun i _ => hTT' _ i #align measure_theory.simple_func.set_to_simple_func_mono_left MeasureTheory.SimpleFunc.setToSimpleFunc_mono_left
Mathlib/MeasureTheory/Integral/SetToL1.lean
519
525
theorem setToSimpleFunc_mono_left' (T T' : Set α → E →L[ℝ] G'') (hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →ₛ E) (hf : Integrable f μ) : setToSimpleFunc T f ≤ setToSimpleFunc T' f := by
refine sum_le_sum fun i _ => ?_ by_cases h0 : i = 0 · simp [h0] · exact hTT' _ (measurableSet_fiber _ _) (measure_preimage_lt_top_of_integrable _ hf h0) i
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Yury Kudryashov -/ import Mathlib.Order.Filter.Basic import Mathlib.Topology.Bases import Mathlib.Data.Set.Accumulate import Mathlib.Topology.Bornology.Basic import Mathlib.Topology.LocallyFinite /-! # Compact sets and compact spaces ## Main definitions We define the following properties for sets in a topological space: * `IsCompact`: a set such that each open cover has a finite subcover. This is defined in mathlib using filters. The main property of a compact set is `IsCompact.elim_finite_subcover`. * `CompactSpace`: typeclass stating that the whole space is a compact set. * `NoncompactSpace`: a space that is not a compact space. ## Main results * `isCompact_univ_pi`: **Tychonov's theorem** - an arbitrary product of compact sets is compact. -/ open Set Filter Topology TopologicalSpace Classical Function universe u v variable {X : Type u} {Y : Type v} {ι : Type*} variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X} -- compact sets section Compact lemma IsCompact.exists_clusterPt (hs : IsCompact s) {f : Filter X} [NeBot f] (hf : f ≤ 𝓟 s) : ∃ x ∈ s, ClusterPt x f := hs hf lemma IsCompact.exists_mapClusterPt {ι : Type*} (hs : IsCompact s) {f : Filter ι} [NeBot f] {u : ι → X} (hf : Filter.map u f ≤ 𝓟 s) : ∃ x ∈ s, MapClusterPt x f u := hs hf /-- The complement to a compact set belongs to a filter `f` if it belongs to each filter `𝓝 x ⊓ f`, `x ∈ s`. -/ theorem IsCompact.compl_mem_sets (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, sᶜ ∈ 𝓝 x ⊓ f) : sᶜ ∈ f := by contrapose! hf simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf ⊢ exact @hs _ hf inf_le_right #align is_compact.compl_mem_sets IsCompact.compl_mem_sets /-- The complement to a compact set belongs to a filter `f` if each `x ∈ s` has a neighborhood `t` within `s` such that `tᶜ` belongs to `f`. -/ theorem IsCompact.compl_mem_sets_of_nhdsWithin (hs : IsCompact s) {f : Filter X} (hf : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, tᶜ ∈ f) : sᶜ ∈ f := by refine hs.compl_mem_sets fun x hx => ?_ rcases hf x hx with ⟨t, ht, hst⟩ replace ht := mem_inf_principal.1 ht apply mem_inf_of_inter ht hst rintro x ⟨h₁, h₂⟩ hs exact h₂ (h₁ hs) #align is_compact.compl_mem_sets_of_nhds_within IsCompact.compl_mem_sets_of_nhdsWithin /-- If `p : Set X → Prop` is stable under restriction and union, and each point `x` of a compact set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/ @[elab_as_elim] theorem IsCompact.induction_on (hs : IsCompact s) {p : Set X → Prop} (he : p ∅) (hmono : ∀ ⦃s t⦄, s ⊆ t → p t → p s) (hunion : ∀ ⦃s t⦄, p s → p t → p (s ∪ t)) (hnhds : ∀ x ∈ s, ∃ t ∈ 𝓝[s] x, p t) : p s := by let f : Filter X := comk p he (fun _t ht _s hsub ↦ hmono hsub ht) (fun _s hs _t ht ↦ hunion hs ht) have : sᶜ ∈ f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds) rwa [← compl_compl s] #align is_compact.induction_on IsCompact.induction_on /-- The intersection of a compact set and a closed set is a compact set. -/ theorem IsCompact.inter_right (hs : IsCompact s) (ht : IsClosed t) : IsCompact (s ∩ t) := by intro f hnf hstf obtain ⟨x, hsx, hx⟩ : ∃ x ∈ s, ClusterPt x f := hs (le_trans hstf (le_principal_iff.2 inter_subset_left)) have : x ∈ t := ht.mem_of_nhdsWithin_neBot <| hx.mono <| le_trans hstf (le_principal_iff.2 inter_subset_right) exact ⟨x, ⟨hsx, this⟩, hx⟩ #align is_compact.inter_right IsCompact.inter_right /-- The intersection of a closed set and a compact set is a compact set. -/ theorem IsCompact.inter_left (ht : IsCompact t) (hs : IsClosed s) : IsCompact (s ∩ t) := inter_comm t s ▸ ht.inter_right hs #align is_compact.inter_left IsCompact.inter_left /-- The set difference of a compact set and an open set is a compact set. -/ theorem IsCompact.diff (hs : IsCompact s) (ht : IsOpen t) : IsCompact (s \ t) := hs.inter_right (isClosed_compl_iff.mpr ht) #align is_compact.diff IsCompact.diff /-- A closed subset of a compact set is a compact set. -/ theorem IsCompact.of_isClosed_subset (hs : IsCompact s) (ht : IsClosed t) (h : t ⊆ s) : IsCompact t := inter_eq_self_of_subset_right h ▸ hs.inter_right ht #align is_compact_of_is_closed_subset IsCompact.of_isClosed_subset theorem IsCompact.image_of_continuousOn {f : X → Y} (hs : IsCompact s) (hf : ContinuousOn f s) : IsCompact (f '' s) := by intro l lne ls have : NeBot (l.comap f ⊓ 𝓟 s) := comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls) obtain ⟨x, hxs, hx⟩ : ∃ x ∈ s, ClusterPt x (l.comap f ⊓ 𝓟 s) := @hs _ this inf_le_right haveI := hx.neBot use f x, mem_image_of_mem f hxs have : Tendsto f (𝓝 x ⊓ (comap f l ⊓ 𝓟 s)) (𝓝 (f x) ⊓ l) := by convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1 rw [nhdsWithin] ac_rfl exact this.neBot #align is_compact.image_of_continuous_on IsCompact.image_of_continuousOn theorem IsCompact.image {f : X → Y} (hs : IsCompact s) (hf : Continuous f) : IsCompact (f '' s) := hs.image_of_continuousOn hf.continuousOn #align is_compact.image IsCompact.image theorem IsCompact.adherence_nhdset {f : Filter X} (hs : IsCompact s) (hf₂ : f ≤ 𝓟 s) (ht₁ : IsOpen t) (ht₂ : ∀ x ∈ s, ClusterPt x f → x ∈ t) : t ∈ f := Classical.by_cases mem_of_eq_bot fun (this : f ⊓ 𝓟 tᶜ ≠ ⊥) => let ⟨x, hx, (hfx : ClusterPt x <| f ⊓ 𝓟 tᶜ)⟩ := @hs _ ⟨this⟩ <| inf_le_of_left_le hf₂ have : x ∈ t := ht₂ x hx hfx.of_inf_left have : tᶜ ∩ t ∈ 𝓝[tᶜ] x := inter_mem_nhdsWithin _ (IsOpen.mem_nhds ht₁ this) have A : 𝓝[tᶜ] x = ⊥ := empty_mem_iff_bot.1 <| compl_inter_self t ▸ this have : 𝓝[tᶜ] x ≠ ⊥ := hfx.of_inf_right.ne absurd A this #align is_compact.adherence_nhdset IsCompact.adherence_nhdset theorem isCompact_iff_ultrafilter_le_nhds : IsCompact s ↔ ∀ f : Ultrafilter X, ↑f ≤ 𝓟 s → ∃ x ∈ s, ↑f ≤ 𝓝 x := by refine (forall_neBot_le_iff ?_).trans ?_ · rintro f g hle ⟨x, hxs, hxf⟩ exact ⟨x, hxs, hxf.mono hle⟩ · simp only [Ultrafilter.clusterPt_iff] #align is_compact_iff_ultrafilter_le_nhds isCompact_iff_ultrafilter_le_nhds alias ⟨IsCompact.ultrafilter_le_nhds, _⟩ := isCompact_iff_ultrafilter_le_nhds #align is_compact.ultrafilter_le_nhds IsCompact.ultrafilter_le_nhds theorem isCompact_iff_ultrafilter_le_nhds' : IsCompact s ↔ ∀ f : Ultrafilter X, s ∈ f → ∃ x ∈ s, ↑f ≤ 𝓝 x := by simp only [isCompact_iff_ultrafilter_le_nhds, le_principal_iff, Ultrafilter.mem_coe] alias ⟨IsCompact.ultrafilter_le_nhds', _⟩ := isCompact_iff_ultrafilter_le_nhds' /-- If a compact set belongs to a filter and this filter has a unique cluster point `y` in this set, then the filter is less than or equal to `𝓝 y`. -/ lemma IsCompact.le_nhds_of_unique_clusterPt (hs : IsCompact s) {l : Filter X} {y : X} (hmem : s ∈ l) (h : ∀ x ∈ s, ClusterPt x l → x = y) : l ≤ 𝓝 y := by refine le_iff_ultrafilter.2 fun f hf ↦ ?_ rcases hs.ultrafilter_le_nhds' f (hf hmem) with ⟨x, hxs, hx⟩ convert ← hx exact h x hxs (.mono (.of_le_nhds hx) hf) /-- If values of `f : Y → X` belong to a compact set `s` eventually along a filter `l` and `y` is a unique `MapClusterPt` for `f` along `l` in `s`, then `f` tends to `𝓝 y` along `l`. -/ lemma IsCompact.tendsto_nhds_of_unique_mapClusterPt {l : Filter Y} {y : X} {f : Y → X} (hs : IsCompact s) (hmem : ∀ᶠ x in l, f x ∈ s) (h : ∀ x ∈ s, MapClusterPt x l f → x = y) : Tendsto f l (𝓝 y) := hs.le_nhds_of_unique_clusterPt (mem_map.2 hmem) h /-- For every open directed cover of a compact set, there exists a single element of the cover which itself includes the set. -/ theorem IsCompact.elim_directed_cover {ι : Type v} [hι : Nonempty ι] (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) (hdU : Directed (· ⊆ ·) U) : ∃ i, s ⊆ U i := hι.elim fun i₀ => IsCompact.induction_on hs ⟨i₀, empty_subset _⟩ (fun _ _ hs ⟨i, hi⟩ => ⟨i, hs.trans hi⟩) (fun _ _ ⟨i, hi⟩ ⟨j, hj⟩ => let ⟨k, hki, hkj⟩ := hdU i j ⟨k, union_subset (Subset.trans hi hki) (Subset.trans hj hkj)⟩) fun _x hx => let ⟨i, hi⟩ := mem_iUnion.1 (hsU hx) ⟨U i, mem_nhdsWithin_of_mem_nhds (IsOpen.mem_nhds (hUo i) hi), i, Subset.refl _⟩ #align is_compact.elim_directed_cover IsCompact.elim_directed_cover /-- For every open cover of a compact set, there exists a finite subcover. -/ theorem IsCompact.elim_finite_subcover {ι : Type v} (hs : IsCompact s) (U : ι → Set X) (hUo : ∀ i, IsOpen (U i)) (hsU : s ⊆ ⋃ i, U i) : ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := hs.elim_directed_cover _ (fun _ => isOpen_biUnion fun i _ => hUo i) (iUnion_eq_iUnion_finset U ▸ hsU) (directed_of_isDirected_le fun _ _ h => biUnion_subset_biUnion_left h) #align is_compact.elim_finite_subcover IsCompact.elim_finite_subcover lemma IsCompact.elim_nhds_subcover_nhdsSet' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x hx, U x hx ∈ 𝓝 x) : ∃ t : Finset s, (⋃ x ∈ t, U x.1 x.2) ∈ 𝓝ˢ s := by rcases hs.elim_finite_subcover (fun x : s ↦ interior (U x x.2)) (fun _ ↦ isOpen_interior) fun x hx ↦ mem_iUnion.2 ⟨⟨x, hx⟩, mem_interior_iff_mem_nhds.2 <| hU _ _⟩ with ⟨t, hst⟩ refine ⟨t, mem_nhdsSet_iff_forall.2 fun x hx ↦ ?_⟩ rcases mem_iUnion₂.1 (hst hx) with ⟨y, hyt, hy⟩ refine mem_of_superset ?_ (subset_biUnion_of_mem hyt) exact mem_interior_iff_mem_nhds.1 hy lemma IsCompact.elim_nhds_subcover_nhdsSet (hs : IsCompact s) {U : X → Set X} (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ (⋃ x ∈ t, U x) ∈ 𝓝ˢ s := let ⟨t, ht⟩ := hs.elim_nhds_subcover_nhdsSet' (fun x _ => U x) hU ⟨t.image (↑), fun x hx => let ⟨y, _, hyx⟩ := Finset.mem_image.1 hx hyx ▸ y.2, by rwa [Finset.set_biUnion_finset_image]⟩ theorem IsCompact.elim_nhds_subcover' (hs : IsCompact s) (U : ∀ x ∈ s, Set X) (hU : ∀ x (hx : x ∈ s), U x ‹x ∈ s› ∈ 𝓝 x) : ∃ t : Finset s, s ⊆ ⋃ x ∈ t, U (x : s) x.2 := (hs.elim_nhds_subcover_nhdsSet' U hU).imp fun _ ↦ subset_of_mem_nhdsSet #align is_compact.elim_nhds_subcover' IsCompact.elim_nhds_subcover' theorem IsCompact.elim_nhds_subcover (hs : IsCompact s) (U : X → Set X) (hU : ∀ x ∈ s, U x ∈ 𝓝 x) : ∃ t : Finset X, (∀ x ∈ t, x ∈ s) ∧ s ⊆ ⋃ x ∈ t, U x := (hs.elim_nhds_subcover_nhdsSet hU).imp fun _ h ↦ h.imp_right subset_of_mem_nhdsSet #align is_compact.elim_nhds_subcover IsCompact.elim_nhds_subcover /-- The neighborhood filter of a compact set is disjoint with a filter `l` if and only if the neighborhood filter of each point of this set is disjoint with `l`. -/ theorem IsCompact.disjoint_nhdsSet_left {l : Filter X} (hs : IsCompact s) : Disjoint (𝓝ˢ s) l ↔ ∀ x ∈ s, Disjoint (𝓝 x) l := by refine ⟨fun h x hx => h.mono_left <| nhds_le_nhdsSet hx, fun H => ?_⟩ choose! U hxU hUl using fun x hx => (nhds_basis_opens x).disjoint_iff_left.1 (H x hx) choose hxU hUo using hxU rcases hs.elim_nhds_subcover U fun x hx => (hUo x hx).mem_nhds (hxU x hx) with ⟨t, hts, hst⟩ refine (hasBasis_nhdsSet _).disjoint_iff_left.2 ⟨⋃ x ∈ t, U x, ⟨isOpen_biUnion fun x hx => hUo x (hts x hx), hst⟩, ?_⟩ rw [compl_iUnion₂, biInter_finset_mem] exact fun x hx => hUl x (hts x hx) #align is_compact.disjoint_nhds_set_left IsCompact.disjoint_nhdsSet_left /-- A filter `l` is disjoint with the neighborhood filter of a compact set if and only if it is disjoint with the neighborhood filter of each point of this set. -/ theorem IsCompact.disjoint_nhdsSet_right {l : Filter X} (hs : IsCompact s) : Disjoint l (𝓝ˢ s) ↔ ∀ x ∈ s, Disjoint l (𝓝 x) := by simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left #align is_compact.disjoint_nhds_set_right IsCompact.disjoint_nhdsSet_right -- Porting note (#11215): TODO: reformulate using `Disjoint` /-- For every directed family of closed sets whose intersection avoids a compact set, there exists a single element of the family which itself avoids this compact set. -/ theorem IsCompact.elim_directed_family_closed {ι : Type v} [hι : Nonempty ι] (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) (hdt : Directed (· ⊇ ·) t) : ∃ i : ι, s ∩ t i = ∅ := let ⟨t, ht⟩ := hs.elim_directed_cover (compl ∘ t) (fun i => (htc i).isOpen_compl) (by simpa only [subset_def, not_forall, eq_empty_iff_forall_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, mem_iInter, mem_compl_iff] using hst) (hdt.mono_comp _ fun _ _ => compl_subset_compl.mpr) ⟨t, by simpa only [subset_def, not_forall, eq_empty_iff_forall_not_mem, mem_iUnion, exists_prop, mem_inter_iff, not_and, iff_self_iff, mem_iInter, mem_compl_iff] using ht⟩ #align is_compact.elim_directed_family_closed IsCompact.elim_directed_family_closed -- Porting note (#11215): TODO: reformulate using `Disjoint` /-- For every family of closed sets whose intersection avoids a compact set, there exists a finite subfamily whose intersection avoids this compact set. -/ theorem IsCompact.elim_finite_subfamily_closed {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : (s ∩ ⋂ i, t i) = ∅) : ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := hs.elim_directed_family_closed _ (fun t ↦ isClosed_biInter fun _ _ ↦ htc _) (by rwa [← iInter_eq_iInter_finset]) (directed_of_isDirected_le fun _ _ h ↦ biInter_subset_biInter_left h) #align is_compact.elim_finite_subfamily_closed IsCompact.elim_finite_subfamily_closed /-- If `s` is a compact set in a topological space `X` and `f : ι → Set X` is a locally finite family of sets, then `f i ∩ s` is nonempty only for a finitely many `i`. -/ theorem LocallyFinite.finite_nonempty_inter_compact {f : ι → Set X} (hf : LocallyFinite f) (hs : IsCompact s) : { i | (f i ∩ s).Nonempty }.Finite := by choose U hxU hUf using hf rcases hs.elim_nhds_subcover U fun x _ => hxU x with ⟨t, -, hsU⟩ refine (t.finite_toSet.biUnion fun x _ => hUf x).subset ?_ rintro i ⟨x, hx⟩ rcases mem_iUnion₂.1 (hsU hx.2) with ⟨c, hct, hcx⟩ exact mem_biUnion hct ⟨x, hx.1, hcx⟩ #align locally_finite.finite_nonempty_inter_compact LocallyFinite.finite_nonempty_inter_compact /-- To show that a compact set intersects the intersection of a family of closed sets, it is sufficient to show that it intersects every finite subfamily. -/ theorem IsCompact.inter_iInter_nonempty {ι : Type v} (hs : IsCompact s) (t : ι → Set X) (htc : ∀ i, IsClosed (t i)) (hst : ∀ u : Finset ι, (s ∩ ⋂ i ∈ u, t i).Nonempty) : (s ∩ ⋂ i, t i).Nonempty := by contrapose! hst exact hs.elim_finite_subfamily_closed t htc hst #align is_compact.inter_Inter_nonempty IsCompact.inter_iInter_nonempty /-- Cantor's intersection theorem for `iInter`: the intersection of a directed family of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed {ι : Type v} [hι : Nonempty ι] (t : ι → Set X) (htd : Directed (· ⊇ ·) t) (htn : ∀ i, (t i).Nonempty) (htc : ∀ i, IsCompact (t i)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := by let i₀ := hι.some suffices (t i₀ ∩ ⋂ i, t i).Nonempty by rwa [inter_eq_right.mpr (iInter_subset _ i₀)] at this simp only [nonempty_iff_ne_empty] at htn ⊢ apply mt ((htc i₀).elim_directed_family_closed t htcl) push_neg simp only [← nonempty_iff_ne_empty] at htn ⊢ refine ⟨htd, fun i => ?_⟩ rcases htd i₀ i with ⟨j, hji₀, hji⟩ exact (htn j).mono (subset_inter hji₀ hji) #align is_compact.nonempty_Inter_of_directed_nonempty_compact_closed IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_directed_nonempty_compact_closed := IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed /-- Cantor's intersection theorem for `sInter`: the intersection of a directed family of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_sInter_of_directed_nonempty_isCompact_isClosed {S : Set (Set X)} [hS : Nonempty S] (hSd : DirectedOn (· ⊇ ·) S) (hSn : ∀ U ∈ S, U.Nonempty) (hSc : ∀ U ∈ S, IsCompact U) (hScl : ∀ U ∈ S, IsClosed U) : (⋂₀ S).Nonempty := by rw [sInter_eq_iInter] exact IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ (DirectedOn.directed_val hSd) (fun i ↦ hSn i i.2) (fun i ↦ hSc i i.2) (fun i ↦ hScl i i.2) /-- Cantor's intersection theorem for sequences indexed by `ℕ`: the intersection of a decreasing sequence of nonempty compact closed sets is nonempty. -/ theorem IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed (t : ℕ → Set X) (htd : ∀ i, t (i + 1) ⊆ t i) (htn : ∀ i, (t i).Nonempty) (ht0 : IsCompact (t 0)) (htcl : ∀ i, IsClosed (t i)) : (⋂ i, t i).Nonempty := have tmono : Antitone t := antitone_nat_of_succ_le htd have htd : Directed (· ⊇ ·) t := tmono.directed_ge have : ∀ i, t i ⊆ t 0 := fun i => tmono <| zero_le i have htc : ∀ i, IsCompact (t i) := fun i => ht0.of_isClosed_subset (htcl i) (this i) IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed t htd htn htc htcl #align is_compact.nonempty_Inter_of_sequence_nonempty_compact_closed IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed @[deprecated (since := "2024-02-28")] alias IsCompact.nonempty_iInter_of_sequence_nonempty_compact_closed := IsCompact.nonempty_iInter_of_sequence_nonempty_isCompact_isClosed /-- For every open cover of a compact set, there exists a finite subcover. -/ theorem IsCompact.elim_finite_subcover_image {b : Set ι} {c : ι → Set X} (hs : IsCompact s) (hc₁ : ∀ i ∈ b, IsOpen (c i)) (hc₂ : s ⊆ ⋃ i ∈ b, c i) : ∃ b', b' ⊆ b ∧ Set.Finite b' ∧ s ⊆ ⋃ i ∈ b', c i := by simp only [Subtype.forall', biUnion_eq_iUnion] at hc₁ hc₂ rcases hs.elim_finite_subcover (fun i => c i : b → Set X) hc₁ hc₂ with ⟨d, hd⟩ refine ⟨Subtype.val '' d.toSet, ?_, d.finite_toSet.image _, ?_⟩ · simp · rwa [biUnion_image] #align is_compact.elim_finite_subcover_image IsCompact.elim_finite_subcover_imageₓ /-- A set `s` is compact if for every open cover of `s`, there exists a finite subcover. -/ theorem isCompact_of_finite_subcover (h : ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i) : IsCompact s := fun f hf hfs => by contrapose! h simp only [ClusterPt, not_neBot, ← disjoint_iff, SetCoe.forall', (nhds_basis_opens _).disjoint_iff_left] at h choose U hU hUf using h refine ⟨s, U, fun x => (hU x).2, fun x hx => mem_iUnion.2 ⟨⟨x, hx⟩, (hU _).1⟩, fun t ht => ?_⟩ refine compl_not_mem (le_principal_iff.1 hfs) ?_ refine mem_of_superset ((biInter_finset_mem t).2 fun x _ => hUf x) ?_ rw [subset_compl_comm, compl_iInter₂] simpa only [compl_compl] #align is_compact_of_finite_subcover isCompact_of_finite_subcover -- Porting note (#11215): TODO: reformulate using `Disjoint` /-- A set `s` is compact if for every family of closed sets whose intersection avoids `s`, there exists a finite subfamily whose intersection avoids `s`. -/ theorem isCompact_of_finite_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅) : IsCompact s := isCompact_of_finite_subcover fun U hUo hsU => by rw [← disjoint_compl_right_iff_subset, compl_iUnion, disjoint_iff] at hsU rcases h (fun i => (U i)ᶜ) (fun i => (hUo _).isClosed_compl) hsU with ⟨t, ht⟩ refine ⟨t, ?_⟩ rwa [← disjoint_compl_right_iff_subset, compl_iUnion₂, disjoint_iff] #align is_compact_of_finite_subfamily_closed isCompact_of_finite_subfamily_closed /-- A set `s` is compact if and only if for every open cover of `s`, there exists a finite subcover. -/ theorem isCompact_iff_finite_subcover : IsCompact s ↔ ∀ {ι : Type u} (U : ι → Set X), (∀ i, IsOpen (U i)) → (s ⊆ ⋃ i, U i) → ∃ t : Finset ι, s ⊆ ⋃ i ∈ t, U i := ⟨fun hs => hs.elim_finite_subcover, isCompact_of_finite_subcover⟩ #align is_compact_iff_finite_subcover isCompact_iff_finite_subcover /-- A set `s` is compact if and only if for every family of closed sets whose intersection avoids `s`, there exists a finite subfamily whose intersection avoids `s`. -/ theorem isCompact_iff_finite_subfamily_closed : IsCompact s ↔ ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → (s ∩ ⋂ i, t i) = ∅ → ∃ u : Finset ι, (s ∩ ⋂ i ∈ u, t i) = ∅ := ⟨fun hs => hs.elim_finite_subfamily_closed, isCompact_of_finite_subfamily_closed⟩ #align is_compact_iff_finite_subfamily_closed isCompact_iff_finite_subfamily_closed /-- If `s : Set (X × Y)` belongs to `𝓝 x ×ˢ l` for all `x` from a compact set `K`, then it belongs to `(𝓝ˢ K) ×ˢ l`, i.e., there exist an open `U ⊇ K` and `t ∈ l` such that `U ×ˢ t ⊆ s`. -/ theorem IsCompact.mem_nhdsSet_prod_of_forall {K : Set X} {l : Filter Y} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ x ∈ K, s ∈ 𝓝 x ×ˢ l) : s ∈ (𝓝ˢ K) ×ˢ l := by refine hK.induction_on (by simp) (fun t t' ht hs ↦ ?_) (fun t t' ht ht' ↦ ?_) fun x hx ↦ ?_ · exact prod_mono (nhdsSet_mono ht) le_rfl hs · simp [sup_prod, *] · rcases ((nhds_basis_opens _).prod l.basis_sets).mem_iff.1 (hs x hx) with ⟨⟨u, v⟩, ⟨⟨hx, huo⟩, hv⟩, hs⟩ refine ⟨u, nhdsWithin_le_nhds (huo.mem_nhds hx), mem_of_superset ?_ hs⟩ exact prod_mem_prod (huo.mem_nhdsSet.2 Subset.rfl) hv theorem IsCompact.nhdsSet_prod_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter Y) : (𝓝ˢ K) ×ˢ l = ⨆ x ∈ K, 𝓝 x ×ˢ l := le_antisymm (fun s hs ↦ hK.mem_nhdsSet_prod_of_forall <| by simpa using hs) (iSup₂_le fun x hx ↦ prod_mono (nhds_le_nhdsSet hx) le_rfl) theorem IsCompact.prod_nhdsSet_eq_biSup {K : Set Y} (hK : IsCompact K) (l : Filter X) : l ×ˢ (𝓝ˢ K) = ⨆ y ∈ K, l ×ˢ 𝓝 y := by simp only [prod_comm (f := l), hK.nhdsSet_prod_eq_biSup, map_iSup] /-- If `s : Set (X × Y)` belongs to `l ×ˢ 𝓝 y` for all `y` from a compact set `K`, then it belongs to `l ×ˢ (𝓝ˢ K)`, i.e., there exist `t ∈ l` and an open `U ⊇ K` such that `t ×ˢ U ⊆ s`. -/ theorem IsCompact.mem_prod_nhdsSet_of_forall {K : Set Y} {l : Filter X} {s : Set (X × Y)} (hK : IsCompact K) (hs : ∀ y ∈ K, s ∈ l ×ˢ 𝓝 y) : s ∈ l ×ˢ 𝓝ˢ K := (hK.prod_nhdsSet_eq_biSup l).symm ▸ by simpa using hs -- TODO: Is there a way to prove directly the `inf` version and then deduce the `Prod` one ? -- That would seem a bit more natural. theorem IsCompact.nhdsSet_inf_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : (𝓝ˢ K) ⊓ l = ⨆ x ∈ K, 𝓝 x ⊓ l := by have : ∀ f : Filter X, f ⊓ l = comap (fun x ↦ (x, x)) (f ×ˢ l) := fun f ↦ by simpa only [comap_prod] using congrArg₂ (· ⊓ ·) comap_id.symm comap_id.symm simp_rw [this, ← comap_iSup, hK.nhdsSet_prod_eq_biSup] theorem IsCompact.inf_nhdsSet_eq_biSup {K : Set X} (hK : IsCompact K) (l : Filter X) : l ⊓ (𝓝ˢ K) = ⨆ x ∈ K, l ⊓ 𝓝 x := by simp only [inf_comm l, hK.nhdsSet_inf_eq_biSup] /-- If `s : Set X` belongs to `𝓝 x ⊓ l` for all `x` from a compact set `K`, then it belongs to `(𝓝ˢ K) ⊓ l`, i.e., there exist an open `U ⊇ K` and `T ∈ l` such that `U ∩ T ⊆ s`. -/ theorem IsCompact.mem_nhdsSet_inf_of_forall {K : Set X} {l : Filter X} {s : Set X} (hK : IsCompact K) (hs : ∀ x ∈ K, s ∈ 𝓝 x ⊓ l) : s ∈ (𝓝ˢ K) ⊓ l := (hK.nhdsSet_inf_eq_biSup l).symm ▸ by simpa using hs /-- If `s : Set S` belongs to `l ⊓ 𝓝 x` for all `x` from a compact set `K`, then it belongs to `l ⊓ (𝓝ˢ K)`, i.e., there exist `T ∈ l` and an open `U ⊇ K` such that `T ∩ U ⊆ s`. -/ theorem IsCompact.mem_inf_nhdsSet_of_forall {K : Set X} {l : Filter X} {s : Set X} (hK : IsCompact K) (hs : ∀ y ∈ K, s ∈ l ⊓ 𝓝 y) : s ∈ l ⊓ 𝓝ˢ K := (hK.inf_nhdsSet_eq_biSup l).symm ▸ by simpa using hs /-- To show that `∀ y ∈ K, P x y` holds for `x` close enough to `x₀` when `K` is compact, it is sufficient to show that for all `y₀ ∈ K` there `P x y` holds for `(x, y)` close enough to `(x₀, y₀)`. Provided for backwards compatibility, see `IsCompact.mem_prod_nhdsSet_of_forall` for a stronger statement. -/ theorem IsCompact.eventually_forall_of_forall_eventually {x₀ : X} {K : Set Y} (hK : IsCompact K) {P : X → Y → Prop} (hP : ∀ y ∈ K, ∀ᶠ z : X × Y in 𝓝 (x₀, y), P z.1 z.2) : ∀ᶠ x in 𝓝 x₀, ∀ y ∈ K, P x y := by simp only [nhds_prod_eq, ← eventually_iSup, ← hK.prod_nhdsSet_eq_biSup] at hP exact hP.curry.mono fun _ h ↦ h.self_of_nhdsSet #align is_compact.eventually_forall_of_forall_eventually IsCompact.eventually_forall_of_forall_eventually @[simp] theorem isCompact_empty : IsCompact (∅ : Set X) := fun _f hnf hsf => Not.elim hnf.ne <| empty_mem_iff_bot.1 <| le_principal_iff.1 hsf #align is_compact_empty isCompact_empty @[simp] theorem isCompact_singleton {x : X} : IsCompact ({x} : Set X) := fun f hf hfa => ⟨x, rfl, ClusterPt.of_le_nhds' (hfa.trans <| by simpa only [principal_singleton] using pure_le_nhds x) hf⟩ #align is_compact_singleton isCompact_singleton theorem Set.Subsingleton.isCompact (hs : s.Subsingleton) : IsCompact s := Subsingleton.induction_on hs isCompact_empty fun _ => isCompact_singleton #align set.subsingleton.is_compact Set.Subsingleton.isCompact -- Porting note: golfed a proof instead of fixing it theorem Set.Finite.isCompact_biUnion {s : Set ι} {f : ι → Set X} (hs : s.Finite) (hf : ∀ i ∈ s, IsCompact (f i)) : IsCompact (⋃ i ∈ s, f i) := isCompact_iff_ultrafilter_le_nhds'.2 fun l hl => by rw [Ultrafilter.finite_biUnion_mem_iff hs] at hl rcases hl with ⟨i, his, hi⟩ rcases (hf i his).ultrafilter_le_nhds _ (le_principal_iff.2 hi) with ⟨x, hxi, hlx⟩ exact ⟨x, mem_iUnion₂.2 ⟨i, his, hxi⟩, hlx⟩ #align set.finite.is_compact_bUnion Set.Finite.isCompact_biUnion theorem Finset.isCompact_biUnion (s : Finset ι) {f : ι → Set X} (hf : ∀ i ∈ s, IsCompact (f i)) : IsCompact (⋃ i ∈ s, f i) := s.finite_toSet.isCompact_biUnion hf #align finset.is_compact_bUnion Finset.isCompact_biUnion theorem isCompact_accumulate {K : ℕ → Set X} (hK : ∀ n, IsCompact (K n)) (n : ℕ) : IsCompact (Accumulate K n) := (finite_le_nat n).isCompact_biUnion fun k _ => hK k #align is_compact_accumulate isCompact_accumulate -- Porting note (#10756): new lemma theorem Set.Finite.isCompact_sUnion {S : Set (Set X)} (hf : S.Finite) (hc : ∀ s ∈ S, IsCompact s) : IsCompact (⋃₀ S) := by rw [sUnion_eq_biUnion]; exact hf.isCompact_biUnion hc -- Porting note: generalized to `ι : Sort*` theorem isCompact_iUnion {ι : Sort*} {f : ι → Set X} [Finite ι] (h : ∀ i, IsCompact (f i)) : IsCompact (⋃ i, f i) := (finite_range f).isCompact_sUnion <| forall_mem_range.2 h #align is_compact_Union isCompact_iUnion theorem Set.Finite.isCompact (hs : s.Finite) : IsCompact s := biUnion_of_singleton s ▸ hs.isCompact_biUnion fun _ _ => isCompact_singleton #align set.finite.is_compact Set.Finite.isCompact theorem IsCompact.finite_of_discrete [DiscreteTopology X] (hs : IsCompact s) : s.Finite := by have : ∀ x : X, ({x} : Set X) ∈ 𝓝 x := by simp [nhds_discrete] rcases hs.elim_nhds_subcover (fun x => {x}) fun x _ => this x with ⟨t, _, hst⟩ simp only [← t.set_biUnion_coe, biUnion_of_singleton] at hst exact t.finite_toSet.subset hst #align is_compact.finite_of_discrete IsCompact.finite_of_discrete theorem isCompact_iff_finite [DiscreteTopology X] : IsCompact s ↔ s.Finite := ⟨fun h => h.finite_of_discrete, fun h => h.isCompact⟩ #align is_compact_iff_finite isCompact_iff_finite theorem IsCompact.union (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ∪ t) := by rw [union_eq_iUnion]; exact isCompact_iUnion fun b => by cases b <;> assumption #align is_compact.union IsCompact.union protected theorem IsCompact.insert (hs : IsCompact s) (a) : IsCompact (insert a s) := isCompact_singleton.union hs #align is_compact.insert IsCompact.insert -- Porting note (#11215): TODO: reformulate using `𝓝ˢ` /-- If `V : ι → Set X` is a decreasing family of closed compact sets then any neighborhood of `⋂ i, V i` contains some `V i`. We assume each `V i` is compact *and* closed because `X` is not assumed to be Hausdorff. See `exists_subset_nhd_of_compact` for version assuming this. -/ theorem exists_subset_nhds_of_isCompact' [Nonempty ι] {V : ι → Set X} (hV : Directed (· ⊇ ·) V) (hV_cpct : ∀ i, IsCompact (V i)) (hV_closed : ∀ i, IsClosed (V i)) {U : Set X} (hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U := by obtain ⟨W, hsubW, W_op, hWU⟩ := exists_open_set_nhds hU suffices ∃ i, V i ⊆ W from this.imp fun i hi => hi.trans hWU by_contra! H replace H : ∀ i, (V i ∩ Wᶜ).Nonempty := fun i => Set.inter_compl_nonempty_iff.mpr (H i) have : (⋂ i, V i ∩ Wᶜ).Nonempty := by refine IsCompact.nonempty_iInter_of_directed_nonempty_isCompact_isClosed _ (fun i j => ?_) H (fun i => (hV_cpct i).inter_right W_op.isClosed_compl) fun i => (hV_closed i).inter W_op.isClosed_compl rcases hV i j with ⟨k, hki, hkj⟩ refine ⟨k, ⟨fun x => ?_, fun x => ?_⟩⟩ <;> simp only [and_imp, mem_inter_iff, mem_compl_iff] <;> tauto have : ¬⋂ i : ι, V i ⊆ W := by simpa [← iInter_inter, inter_compl_nonempty_iff] contradiction #align exists_subset_nhds_of_is_compact' exists_subset_nhds_of_isCompact' lemma eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by obtain ⟨Y, f, e, hf⟩ := hb.open_eq_iUnion hUo choose f' hf' using hf have : b ∘ f' = f := funext hf' subst this obtain ⟨t, ht⟩ := hUc.elim_finite_subcover (b ∘ f') (fun i => hb.isOpen (Set.mem_range_self _)) (by rw [e]) refine ⟨t.image f', Set.toFinite _, le_antisymm ?_ ?_⟩ · refine Set.Subset.trans ht ?_ simp only [Set.iUnion_subset_iff] intro i hi erw [← Set.iUnion_subtype (fun x : ι => x ∈ t.image f') fun i => b i.1] exact Set.subset_iUnion (fun i : t.image f' => b i) ⟨_, Finset.mem_image_of_mem _ hi⟩ · apply Set.iUnion₂_subset rintro i hi obtain ⟨j, -, rfl⟩ := Finset.mem_image.mp hi rw [e] exact Set.subset_iUnion (b ∘ f') j lemma eq_sUnion_finset_of_isTopologicalBasis_of_isCompact_open (b : Set (Set X)) (hb : IsTopologicalBasis b) (U : Set X) (hUc : IsCompact U) (hUo : IsOpen U) : ∃ s : Finset b, U = s.toSet.sUnion := by have hb' : b = range (fun i ↦ i : b → Set X) := by simp rw [hb'] at hb choose s hs hU using eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U hUc hUo have : Finite s := hs let _ : Fintype s := Fintype.ofFinite _ use s.toFinset simp [hU] /-- If `X` has a basis consisting of compact opens, then an open set in `X` is compact open iff it is a finite union of some elements in the basis -/ theorem isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis (b : ι → Set X) (hb : IsTopologicalBasis (Set.range b)) (hb' : ∀ i, IsCompact (b i)) (U : Set X) : IsCompact U ∧ IsOpen U ↔ ∃ s : Set ι, s.Finite ∧ U = ⋃ i ∈ s, b i := by constructor · exact fun ⟨h₁, h₂⟩ ↦ eq_finite_iUnion_of_isTopologicalBasis_of_isCompact_open _ hb U h₁ h₂ · rintro ⟨s, hs, rfl⟩ constructor · exact hs.isCompact_biUnion fun i _ => hb' i · exact isOpen_biUnion fun i _ => hb.isOpen (Set.mem_range_self _) #align is_compact_open_iff_eq_finite_Union_of_is_topological_basis isCompact_open_iff_eq_finite_iUnion_of_isTopologicalBasis namespace Filter theorem hasBasis_cocompact : (cocompact X).HasBasis IsCompact compl := hasBasis_biInf_principal' (fun s hs t ht => ⟨s ∪ t, hs.union ht, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩) ⟨∅, isCompact_empty⟩ #align filter.has_basis_cocompact Filter.hasBasis_cocompact theorem mem_cocompact : s ∈ cocompact X ↔ ∃ t, IsCompact t ∧ tᶜ ⊆ s := hasBasis_cocompact.mem_iff #align filter.mem_cocompact Filter.mem_cocompact theorem mem_cocompact' : s ∈ cocompact X ↔ ∃ t, IsCompact t ∧ sᶜ ⊆ t := mem_cocompact.trans <| exists_congr fun _ => and_congr_right fun _ => compl_subset_comm #align filter.mem_cocompact' Filter.mem_cocompact' theorem _root_.IsCompact.compl_mem_cocompact (hs : IsCompact s) : sᶜ ∈ Filter.cocompact X := hasBasis_cocompact.mem_of_mem hs #align is_compact.compl_mem_cocompact IsCompact.compl_mem_cocompact theorem cocompact_le_cofinite : cocompact X ≤ cofinite := fun s hs => compl_compl s ▸ hs.isCompact.compl_mem_cocompact #align filter.cocompact_le_cofinite Filter.cocompact_le_cofinite theorem cocompact_eq_cofinite (X : Type*) [TopologicalSpace X] [DiscreteTopology X] : cocompact X = cofinite := by simp only [cocompact, hasBasis_cofinite.eq_biInf, isCompact_iff_finite] #align filter.cocompact_eq_cofinite Filter.cocompact_eq_cofinite /-- A filter is disjoint from the cocompact filter if and only if it contains a compact set. -/ theorem disjoint_cocompact_left (f : Filter X) : Disjoint (Filter.cocompact X) f ↔ ∃ K ∈ f, IsCompact K := by simp_rw [hasBasis_cocompact.disjoint_iff_left, compl_compl] tauto /-- A filter is disjoint from the cocompact filter if and only if it contains a compact set. -/ theorem disjoint_cocompact_right (f : Filter X) : Disjoint f (Filter.cocompact X) ↔ ∃ K ∈ f, IsCompact K := by simp_rw [hasBasis_cocompact.disjoint_iff_right, compl_compl] tauto @[deprecated "see `cocompact_eq_atTop` with `import Mathlib.Topology.Instances.Nat`" (since := "2024-02-07")] theorem _root_.Nat.cocompact_eq : cocompact ℕ = atTop := (cocompact_eq_cofinite ℕ).trans Nat.cofinite_eq_atTop #align nat.cocompact_eq Nat.cocompact_eq theorem Tendsto.isCompact_insert_range_of_cocompact {f : X → Y} {y} (hf : Tendsto f (cocompact X) (𝓝 y)) (hfc : Continuous f) : IsCompact (insert y (range f)) := by intro l hne hle by_cases hy : ClusterPt y l · exact ⟨y, Or.inl rfl, hy⟩ simp only [clusterPt_iff, not_forall, ← not_disjoint_iff_nonempty_inter, not_not] at hy rcases hy with ⟨s, hsy, t, htl, hd⟩ rcases mem_cocompact.1 (hf hsy) with ⟨K, hKc, hKs⟩ have : f '' K ∈ l := by filter_upwards [htl, le_principal_iff.1 hle] with y hyt hyf rcases hyf with (rfl | ⟨x, rfl⟩) exacts [(hd.le_bot ⟨mem_of_mem_nhds hsy, hyt⟩).elim, mem_image_of_mem _ (not_not.1 fun hxK => hd.le_bot ⟨hKs hxK, hyt⟩)] rcases hKc.image hfc (le_principal_iff.2 this) with ⟨y, hy, hyl⟩ exact ⟨y, Or.inr <| image_subset_range _ _ hy, hyl⟩ #align filter.tendsto.is_compact_insert_range_of_cocompact Filter.Tendsto.isCompact_insert_range_of_cocompact theorem Tendsto.isCompact_insert_range_of_cofinite {f : ι → X} {x} (hf : Tendsto f cofinite (𝓝 x)) : IsCompact (insert x (range f)) := by letI : TopologicalSpace ι := ⊥; haveI h : DiscreteTopology ι := ⟨rfl⟩ rw [← cocompact_eq_cofinite ι] at hf exact hf.isCompact_insert_range_of_cocompact continuous_of_discreteTopology #align filter.tendsto.is_compact_insert_range_of_cofinite Filter.Tendsto.isCompact_insert_range_of_cofinite theorem Tendsto.isCompact_insert_range {f : ℕ → X} {x} (hf : Tendsto f atTop (𝓝 x)) : IsCompact (insert x (range f)) := Filter.Tendsto.isCompact_insert_range_of_cofinite <| Nat.cofinite_eq_atTop.symm ▸ hf #align filter.tendsto.is_compact_insert_range Filter.Tendsto.isCompact_insert_range theorem hasBasis_coclosedCompact : (Filter.coclosedCompact X).HasBasis (fun s => IsClosed s ∧ IsCompact s) compl := by simp only [Filter.coclosedCompact, iInf_and'] refine hasBasis_biInf_principal' ?_ ⟨∅, isClosed_empty, isCompact_empty⟩ rintro s ⟨hs₁, hs₂⟩ t ⟨ht₁, ht₂⟩ exact ⟨s ∪ t, ⟨⟨hs₁.union ht₁, hs₂.union ht₂⟩, compl_subset_compl.2 subset_union_left, compl_subset_compl.2 subset_union_right⟩⟩ #align filter.has_basis_coclosed_compact Filter.hasBasis_coclosedCompact /-- A set belongs to `coclosedCompact` if and only if the closure of its complement is compact. -/ theorem mem_coclosedCompact_iff : s ∈ coclosedCompact X ↔ IsCompact (closure sᶜ) := by refine hasBasis_coclosedCompact.mem_iff.trans ⟨?_, fun h ↦ ?_⟩ · rintro ⟨t, ⟨htcl, htco⟩, hst⟩ exact htco.of_isClosed_subset isClosed_closure <| closure_minimal (compl_subset_comm.2 hst) htcl · exact ⟨closure sᶜ, ⟨isClosed_closure, h⟩, compl_subset_comm.2 subset_closure⟩ @[deprecated mem_coclosedCompact_iff (since := "2024-02-16")] theorem mem_coclosedCompact : s ∈ coclosedCompact X ↔ ∃ t, IsClosed t ∧ IsCompact t ∧ tᶜ ⊆ s := by simp only [hasBasis_coclosedCompact.mem_iff, and_assoc] #align filter.mem_coclosed_compact Filter.mem_coclosedCompact @[deprecated mem_coclosedCompact_iff (since := "2024-02-16")] theorem mem_coclosed_compact' : s ∈ coclosedCompact X ↔ ∃ t, IsClosed t ∧ IsCompact t ∧ sᶜ ⊆ t := by simp only [hasBasis_coclosedCompact.mem_iff, compl_subset_comm, and_assoc] #align filter.mem_coclosed_compact' Filter.mem_coclosed_compact' /-- Complement of a set belongs to `coclosedCompact` if and only if its closure is compact. -/ theorem compl_mem_coclosedCompact : sᶜ ∈ coclosedCompact X ↔ IsCompact (closure s) := by rw [mem_coclosedCompact_iff, compl_compl] theorem cocompact_le_coclosedCompact : cocompact X ≤ coclosedCompact X := iInf_mono fun _ => le_iInf fun _ => le_rfl #align filter.cocompact_le_coclosed_compact Filter.cocompact_le_coclosedCompact end Filter theorem IsCompact.compl_mem_coclosedCompact_of_isClosed (hs : IsCompact s) (hs' : IsClosed s) : sᶜ ∈ Filter.coclosedCompact X := hasBasis_coclosedCompact.mem_of_mem ⟨hs', hs⟩ #align is_compact.compl_mem_coclosed_compact_of_is_closed IsCompact.compl_mem_coclosedCompact_of_isClosed namespace Bornology variable (X) in /-- Sets that are contained in a compact set form a bornology. Its `cobounded` filter is `Filter.cocompact`. See also `Bornology.relativelyCompact` the bornology of sets with compact closure. -/ def inCompact : Bornology X where cobounded' := Filter.cocompact X le_cofinite' := Filter.cocompact_le_cofinite #align bornology.in_compact Bornology.inCompact theorem inCompact.isBounded_iff : @IsBounded _ (inCompact X) s ↔ ∃ t, IsCompact t ∧ s ⊆ t := by change sᶜ ∈ Filter.cocompact X ↔ _ rw [Filter.mem_cocompact] simp #align bornology.in_compact.is_bounded_iff Bornology.inCompact.isBounded_iff end Bornology #noalign nhds_contain_boxes #noalign nhds_contain_boxes.symm #noalign nhds_contain_boxes.comm #noalign nhds_contain_boxes_of_singleton #noalign nhds_contain_boxes_of_compact /-- If `s` and `t` are compact sets, then the set neighborhoods filter of `s ×ˢ t` is the product of set neighborhoods filters for `s` and `t`. For general sets, only the `≤` inequality holds, see `nhdsSet_prod_le`. -/ theorem IsCompact.nhdsSet_prod_eq {t : Set Y} (hs : IsCompact s) (ht : IsCompact t) : 𝓝ˢ (s ×ˢ t) = 𝓝ˢ s ×ˢ 𝓝ˢ t := by simp_rw [hs.nhdsSet_prod_eq_biSup, ht.prod_nhdsSet_eq_biSup, nhdsSet, sSup_image, biSup_prod, nhds_prod_eq] theorem nhdsSet_prod_le_of_disjoint_cocompact {f : Filter Y} (hs : IsCompact s) (hf : Disjoint f (Filter.cocompact Y)) : 𝓝ˢ s ×ˢ f ≤ 𝓝ˢ (s ×ˢ Set.univ) := by obtain ⟨K, hKf, hK⟩ := (disjoint_cocompact_right f).mp hf calc 𝓝ˢ s ×ˢ f _ ≤ 𝓝ˢ s ×ˢ 𝓟 K := Filter.prod_mono_right _ (Filter.le_principal_iff.mpr hKf) _ ≤ 𝓝ˢ s ×ˢ 𝓝ˢ K := Filter.prod_mono_right _ principal_le_nhdsSet _ = 𝓝ˢ (s ×ˢ K) := (hs.nhdsSet_prod_eq hK).symm _ ≤ 𝓝ˢ (s ×ˢ Set.univ) := nhdsSet_mono (prod_mono_right le_top) theorem prod_nhdsSet_le_of_disjoint_cocompact {f : Filter X} (ht : IsCompact t) (hf : Disjoint f (Filter.cocompact X)) : f ×ˢ 𝓝ˢ t ≤ 𝓝ˢ (Set.univ ×ˢ t) := by obtain ⟨K, hKf, hK⟩ := (disjoint_cocompact_right f).mp hf calc f ×ˢ 𝓝ˢ t _ ≤ (𝓟 K) ×ˢ 𝓝ˢ t := Filter.prod_mono_left _ (Filter.le_principal_iff.mpr hKf) _ ≤ 𝓝ˢ K ×ˢ 𝓝ˢ t := Filter.prod_mono_left _ principal_le_nhdsSet _ = 𝓝ˢ (K ×ˢ t) := (hK.nhdsSet_prod_eq ht).symm _ ≤ 𝓝ˢ (Set.univ ×ˢ t) := nhdsSet_mono (prod_mono_left le_top) /-- If `s` and `t` are compact sets and `n` is an open neighborhood of `s × t`, then there exist open neighborhoods `u ⊇ s` and `v ⊇ t` such that `u × v ⊆ n`. See also `IsCompact.nhdsSet_prod_eq`. -/ theorem generalized_tube_lemma (hs : IsCompact s) {t : Set Y} (ht : IsCompact t) {n : Set (X × Y)} (hn : IsOpen n) (hp : s ×ˢ t ⊆ n) : ∃ (u : Set X) (v : Set Y), IsOpen u ∧ IsOpen v ∧ s ⊆ u ∧ t ⊆ v ∧ u ×ˢ v ⊆ n := by rw [← hn.mem_nhdsSet, hs.nhdsSet_prod_eq ht, ((hasBasis_nhdsSet _).prod (hasBasis_nhdsSet _)).mem_iff] at hp rcases hp with ⟨⟨u, v⟩, ⟨⟨huo, hsu⟩, hvo, htv⟩, hn⟩ exact ⟨u, v, huo, hvo, hsu, htv, hn⟩ #align generalized_tube_lemma generalized_tube_lemma -- see Note [lower instance priority] instance (priority := 10) Subsingleton.compactSpace [Subsingleton X] : CompactSpace X := ⟨subsingleton_univ.isCompact⟩ #align subsingleton.compact_space Subsingleton.compactSpace theorem isCompact_univ_iff : IsCompact (univ : Set X) ↔ CompactSpace X := ⟨fun h => ⟨h⟩, fun h => h.1⟩ #align is_compact_univ_iff isCompact_univ_iff theorem isCompact_univ [h : CompactSpace X] : IsCompact (univ : Set X) := h.isCompact_univ #align is_compact_univ isCompact_univ theorem exists_clusterPt_of_compactSpace [CompactSpace X] (f : Filter X) [NeBot f] : ∃ x, ClusterPt x f := by simpa using isCompact_univ (show f ≤ 𝓟 univ by simp) #align cluster_point_of_compact exists_clusterPt_of_compactSpace @[deprecated (since := "2024-01-28")] alias cluster_point_of_compact := exists_clusterPt_of_compactSpace nonrec theorem Ultrafilter.le_nhds_lim [CompactSpace X] (F : Ultrafilter X) : ↑F ≤ 𝓝 F.lim := by rcases isCompact_univ.ultrafilter_le_nhds F (by simp) with ⟨x, -, h⟩ exact le_nhds_lim ⟨x, h⟩ set_option linter.uppercaseLean3 false in #align ultrafilter.le_nhds_Lim Ultrafilter.le_nhds_lim theorem CompactSpace.elim_nhds_subcover [CompactSpace X] (U : X → Set X) (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, U x = ⊤ := by obtain ⟨t, -, s⟩ := IsCompact.elim_nhds_subcover isCompact_univ U fun x _ => hU x exact ⟨t, top_unique s⟩ #align compact_space.elim_nhds_subcover CompactSpace.elim_nhds_subcover theorem compactSpace_of_finite_subfamily_closed (h : ∀ {ι : Type u} (t : ι → Set X), (∀ i, IsClosed (t i)) → ⋂ i, t i = ∅ → ∃ u : Finset ι, ⋂ i ∈ u, t i = ∅) : CompactSpace X where isCompact_univ := isCompact_of_finite_subfamily_closed fun t => by simpa using h t #align compact_space_of_finite_subfamily_closed compactSpace_of_finite_subfamily_closed theorem IsClosed.isCompact [CompactSpace X] (h : IsClosed s) : IsCompact s := isCompact_univ.of_isClosed_subset h (subset_univ _) #align is_closed.is_compact IsClosed.isCompact /-- If a filter has a unique cluster point `y` in a compact topological space, then the filter is less than or equal to `𝓝 y`. -/ lemma le_nhds_of_unique_clusterPt [CompactSpace X] {l : Filter X} {y : X} (h : ∀ x, ClusterPt x l → x = y) : l ≤ 𝓝 y := isCompact_univ.le_nhds_of_unique_clusterPt univ_mem fun x _ ↦ h x /-- If `y` is a unique `MapClusterPt` for `f` along `l` and the codomain of `f` is a compact space, then `f` tends to `𝓝 y` along `l`. -/ lemma tendsto_nhds_of_unique_mapClusterPt [CompactSpace X] {l : Filter Y} {y : X} {f : Y → X} (h : ∀ x, MapClusterPt x l f → x = y) : Tendsto f l (𝓝 y) := le_nhds_of_unique_clusterPt h -- Porting note: a lemma instead of `export` to make `X` explicit lemma noncompact_univ (X : Type*) [TopologicalSpace X] [NoncompactSpace X] : ¬IsCompact (univ : Set X) := NoncompactSpace.noncompact_univ theorem IsCompact.ne_univ [NoncompactSpace X] (hs : IsCompact s) : s ≠ univ := fun h => noncompact_univ X (h ▸ hs) #align is_compact.ne_univ IsCompact.ne_univ instance [NoncompactSpace X] : NeBot (Filter.cocompact X) := by refine Filter.hasBasis_cocompact.neBot_iff.2 fun hs => ?_ contrapose hs; rw [not_nonempty_iff_eq_empty, compl_empty_iff] at hs rw [hs]; exact noncompact_univ X @[simp] theorem Filter.cocompact_eq_bot [CompactSpace X] : Filter.cocompact X = ⊥ := Filter.hasBasis_cocompact.eq_bot_iff.mpr ⟨Set.univ, isCompact_univ, Set.compl_univ⟩ #align filter.cocompact_eq_bot Filter.cocompact_eq_bot instance [NoncompactSpace X] : NeBot (Filter.coclosedCompact X) := neBot_of_le Filter.cocompact_le_coclosedCompact theorem noncompactSpace_of_neBot (_ : NeBot (Filter.cocompact X)) : NoncompactSpace X := ⟨fun h' => (Filter.nonempty_of_mem h'.compl_mem_cocompact).ne_empty compl_univ⟩ #align noncompact_space_of_ne_bot noncompactSpace_of_neBot theorem Filter.cocompact_neBot_iff : NeBot (Filter.cocompact X) ↔ NoncompactSpace X := ⟨noncompactSpace_of_neBot, fun _ => inferInstance⟩ #align filter.cocompact_ne_bot_iff Filter.cocompact_neBot_iff theorem not_compactSpace_iff : ¬CompactSpace X ↔ NoncompactSpace X := ⟨fun h₁ => ⟨fun h₂ => h₁ ⟨h₂⟩⟩, fun ⟨h₁⟩ ⟨h₂⟩ => h₁ h₂⟩ #align not_compact_space_iff not_compactSpace_iff instance : NoncompactSpace ℤ := noncompactSpace_of_neBot <| by simp only [Filter.cocompact_eq_cofinite, Filter.cofinite_neBot] -- Note: We can't make this into an instance because it loops with `Finite.compactSpace`. /-- A compact discrete space is finite. -/ theorem finite_of_compact_of_discrete [CompactSpace X] [DiscreteTopology X] : Finite X := Finite.of_finite_univ <| isCompact_univ.finite_of_discrete #align finite_of_compact_of_discrete finite_of_compact_of_discrete lemma Set.Infinite.exists_accPt_cofinite_inf_principal_of_subset_isCompact {K : Set X} (hs : s.Infinite) (hK : IsCompact K) (hsub : s ⊆ K) : ∃ x ∈ K, AccPt x (cofinite ⊓ 𝓟 s) := (@hK _ hs.cofinite_inf_principal_neBot (inf_le_right.trans <| principal_mono.2 hsub)).imp fun x hx ↦ by rwa [acc_iff_cluster, inf_comm, inf_right_comm, (finite_singleton _).cofinite_inf_principal_compl] lemma Set.Infinite.exists_accPt_of_subset_isCompact {K : Set X} (hs : s.Infinite) (hK : IsCompact K) (hsub : s ⊆ K) : ∃ x ∈ K, AccPt x (𝓟 s) := let ⟨x, hxK, hx⟩ := hs.exists_accPt_cofinite_inf_principal_of_subset_isCompact hK hsub ⟨x, hxK, hx.mono inf_le_right⟩ lemma Set.Infinite.exists_accPt_cofinite_inf_principal [CompactSpace X] (hs : s.Infinite) : ∃ x, AccPt x (cofinite ⊓ 𝓟 s) := by simpa only [mem_univ, true_and] using hs.exists_accPt_cofinite_inf_principal_of_subset_isCompact isCompact_univ s.subset_univ lemma Set.Infinite.exists_accPt_principal [CompactSpace X] (hs : s.Infinite) : ∃ x, AccPt x (𝓟 s) := hs.exists_accPt_cofinite_inf_principal.imp fun _x hx ↦ hx.mono inf_le_right theorem exists_nhds_ne_neBot (X : Type*) [TopologicalSpace X] [CompactSpace X] [Infinite X] : ∃ z : X, (𝓝[≠] z).NeBot := by simpa [AccPt] using (@infinite_univ X _).exists_accPt_principal #align exists_nhds_ne_ne_bot exists_nhds_ne_neBot theorem finite_cover_nhds_interior [CompactSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, interior (U x) = univ := let ⟨t, ht⟩ := isCompact_univ.elim_finite_subcover (fun x => interior (U x)) (fun _ => isOpen_interior) fun x _ => mem_iUnion.2 ⟨x, mem_interior_iff_mem_nhds.2 (hU x)⟩ ⟨t, univ_subset_iff.1 ht⟩ #align finite_cover_nhds_interior finite_cover_nhds_interior theorem finite_cover_nhds [CompactSpace X] {U : X → Set X} (hU : ∀ x, U x ∈ 𝓝 x) : ∃ t : Finset X, ⋃ x ∈ t, U x = univ := let ⟨t, ht⟩ := finite_cover_nhds_interior hU ⟨t, univ_subset_iff.1 <| ht.symm.subset.trans <| iUnion₂_mono fun _ _ => interior_subset⟩ #align finite_cover_nhds finite_cover_nhds /-- If `X` is a compact space, then a locally finite family of sets of `X` can have only finitely many nonempty elements. -/ theorem LocallyFinite.finite_nonempty_of_compact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) : { i | (f i).Nonempty }.Finite := by simpa only [inter_univ] using hf.finite_nonempty_inter_compact isCompact_univ #align locally_finite.finite_nonempty_of_compact LocallyFinite.finite_nonempty_of_compact /-- If `X` is a compact space, then a locally finite family of nonempty sets of `X` can have only finitely many elements, `Set.Finite` version. -/ theorem LocallyFinite.finite_of_compact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : (univ : Set ι).Finite := by simpa only [hne] using hf.finite_nonempty_of_compact #align locally_finite.finite_of_compact LocallyFinite.finite_of_compact /-- If `X` is a compact space, then a locally finite family of nonempty sets of `X` can have only finitely many elements, `Fintype` version. -/ noncomputable def LocallyFinite.fintypeOfCompact [CompactSpace X] {f : ι → Set X} (hf : LocallyFinite f) (hne : ∀ i, (f i).Nonempty) : Fintype ι := fintypeOfFiniteUniv (hf.finite_of_compact hne) #align locally_finite.fintype_of_compact LocallyFinite.fintypeOfCompact /-- The comap of the cocompact filter on `Y` by a continuous function `f : X → Y` is less than or equal to the cocompact filter on `X`. This is a reformulation of the fact that images of compact sets are compact. -/ theorem Filter.comap_cocompact_le {f : X → Y} (hf : Continuous f) : (Filter.cocompact Y).comap f ≤ Filter.cocompact X := by rw [(Filter.hasBasis_cocompact.comap f).le_basis_iff Filter.hasBasis_cocompact] intro t ht refine ⟨f '' t, ht.image hf, ?_⟩ simpa using t.subset_preimage_image f #align filter.comap_cocompact_le Filter.comap_cocompact_le theorem isCompact_range [CompactSpace X] {f : X → Y} (hf : Continuous f) : IsCompact (range f) := by rw [← image_univ]; exact isCompact_univ.image hf #align is_compact_range isCompact_range theorem isCompact_diagonal [CompactSpace X] : IsCompact (diagonal X) := @range_diag X ▸ isCompact_range (continuous_id.prod_mk continuous_id) #align is_compact_diagonal isCompact_diagonal -- Porting note: renamed, golfed /-- If `X` is a compact topological space, then `Prod.snd : X × Y → Y` is a closed map. -/ theorem isClosedMap_snd_of_compactSpace [CompactSpace X] : IsClosedMap (Prod.snd : X × Y → Y) := fun s hs => by rw [← isOpen_compl_iff, isOpen_iff_mem_nhds] intro y hy have : univ ×ˢ {y} ⊆ sᶜ := by exact fun (x, y') ⟨_, rfl⟩ hs => hy ⟨(x, y'), hs, rfl⟩ rcases generalized_tube_lemma isCompact_univ isCompact_singleton hs.isOpen_compl this with ⟨U, V, -, hVo, hU, hV, hs⟩ refine mem_nhds_iff.2 ⟨V, ?_, hVo, hV rfl⟩ rintro _ hzV ⟨z, hzs, rfl⟩ exact hs ⟨hU trivial, hzV⟩ hzs #align is_closed_proj_of_is_compact isClosedMap_snd_of_compactSpace /-- If `Y` is a compact topological space, then `Prod.fst : X × Y → X` is a closed map. -/ theorem isClosedMap_fst_of_compactSpace [CompactSpace Y] : IsClosedMap (Prod.fst : X × Y → X) := isClosedMap_snd_of_compactSpace.comp isClosedMap_swap theorem exists_subset_nhds_of_compactSpace [CompactSpace X] [Nonempty ι] {V : ι → Set X} (hV : Directed (· ⊇ ·) V) (hV_closed : ∀ i, IsClosed (V i)) {U : Set X} (hU : ∀ x ∈ ⋂ i, V i, U ∈ 𝓝 x) : ∃ i, V i ⊆ U := exists_subset_nhds_of_isCompact' hV (fun i => (hV_closed i).isCompact) hV_closed hU #align exists_subset_nhds_of_compact_space exists_subset_nhds_of_compactSpace /-- If `f : X → Y` is an `Inducing` map, the image `f '' s` of a set `s` is compact if and only if `s` is compact. -/ theorem Inducing.isCompact_iff {f : X → Y} (hf : Inducing f) : IsCompact s ↔ IsCompact (f '' s) := by refine ⟨fun hs => hs.image hf.continuous, fun hs F F_ne_bot F_le => ?_⟩ obtain ⟨_, ⟨x, x_in : x ∈ s, rfl⟩, hx : ClusterPt (f x) (map f F)⟩ := hs ((map_mono F_le).trans_eq map_principal) exact ⟨x, x_in, hf.mapClusterPt_iff.1 hx⟩ #align inducing.is_compact_iff Inducing.isCompact_iff /-- If `f : X → Y` is an `Embedding`, the image `f '' s` of a set `s` is compact if and only if `s` is compact. -/ theorem Embedding.isCompact_iff {f : X → Y} (hf : Embedding f) : IsCompact s ↔ IsCompact (f '' s) := hf.toInducing.isCompact_iff #align embedding.is_compact_iff_is_compact_image Embedding.isCompact_iff /-- The preimage of a compact set under an inducing map is a compact set. -/ theorem Inducing.isCompact_preimage {f : X → Y} (hf : Inducing f) (hf' : IsClosed (range f)) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := by replace hK := hK.inter_right hf' rwa [hf.isCompact_iff, image_preimage_eq_inter_range] lemma Inducing.isCompact_preimage_iff {f : X → Y} (hf : Inducing f) {K : Set Y} (Kf : K ⊆ range f) : IsCompact (f ⁻¹' K) ↔ IsCompact K := by rw [hf.isCompact_iff, image_preimage_eq_of_subset Kf] /-- The preimage of a compact set in the image of an inducing map is compact. -/ lemma Inducing.isCompact_preimage' {f : X → Y} (hf : Inducing f) {K : Set Y} (hK: IsCompact K) (Kf : K ⊆ range f) : IsCompact (f ⁻¹' K) := (hf.isCompact_preimage_iff Kf).2 hK /-- The preimage of a compact set under a closed embedding is a compact set. -/ theorem ClosedEmbedding.isCompact_preimage {f : X → Y} (hf : ClosedEmbedding f) {K : Set Y} (hK : IsCompact K) : IsCompact (f ⁻¹' K) := hf.toInducing.isCompact_preimage (hf.isClosed_range) hK #align closed_embedding.is_compact_preimage ClosedEmbedding.isCompact_preimage /-- A closed embedding is proper, ie, inverse images of compact sets are contained in compacts. Moreover, the preimage of a compact set is compact, see `ClosedEmbedding.isCompact_preimage`. -/ theorem ClosedEmbedding.tendsto_cocompact {f : X → Y} (hf : ClosedEmbedding f) : Tendsto f (Filter.cocompact X) (Filter.cocompact Y) := Filter.hasBasis_cocompact.tendsto_right_iff.mpr fun _K hK => (hf.isCompact_preimage hK).compl_mem_cocompact #align closed_embedding.tendsto_cocompact ClosedEmbedding.tendsto_cocompact /-- Sets of subtype are compact iff the image under a coercion is. -/ theorem Subtype.isCompact_iff {p : X → Prop} {s : Set { x // p x }} : IsCompact s ↔ IsCompact ((↑) '' s : Set X) := embedding_subtype_val.isCompact_iff #align is_compact_iff_is_compact_in_subtype Subtype.isCompact_iff theorem isCompact_iff_isCompact_univ : IsCompact s ↔ IsCompact (univ : Set s) := by rw [Subtype.isCompact_iff, image_univ, Subtype.range_coe] #align is_compact_iff_is_compact_univ isCompact_iff_isCompact_univ theorem isCompact_iff_compactSpace : IsCompact s ↔ CompactSpace s := isCompact_iff_isCompact_univ.trans isCompact_univ_iff #align is_compact_iff_compact_space isCompact_iff_compactSpace theorem IsCompact.finite (hs : IsCompact s) (hs' : DiscreteTopology s) : s.Finite := finite_coe_iff.mp (@finite_of_compact_of_discrete _ _ (isCompact_iff_compactSpace.mp hs) hs') #align is_compact.finite IsCompact.finite theorem exists_nhds_ne_inf_principal_neBot (hs : IsCompact s) (hs' : s.Infinite) : ∃ z ∈ s, (𝓝[≠] z ⊓ 𝓟 s).NeBot := hs'.exists_accPt_of_subset_isCompact hs Subset.rfl #align exists_nhds_ne_inf_principal_ne_bot exists_nhds_ne_inf_principal_neBot protected theorem ClosedEmbedding.noncompactSpace [NoncompactSpace X] {f : X → Y} (hf : ClosedEmbedding f) : NoncompactSpace Y := noncompactSpace_of_neBot hf.tendsto_cocompact.neBot #align closed_embedding.noncompact_space ClosedEmbedding.noncompactSpace protected theorem ClosedEmbedding.compactSpace [h : CompactSpace Y] {f : X → Y} (hf : ClosedEmbedding f) : CompactSpace X := ⟨by rw [hf.toInducing.isCompact_iff, image_univ]; exact hf.isClosed_range.isCompact⟩ #align closed_embedding.compact_space ClosedEmbedding.compactSpace
Mathlib/Topology/Compactness/Compact.lean
1,071
1,081
theorem IsCompact.prod {t : Set Y} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s ×ˢ t) := by
rw [isCompact_iff_ultrafilter_le_nhds'] at hs ht ⊢ intro f hfs obtain ⟨x : X, sx : x ∈ s, hx : map Prod.fst f.1 ≤ 𝓝 x⟩ := hs (f.map Prod.fst) (mem_map.2 <| mem_of_superset hfs fun x => And.left) obtain ⟨y : Y, ty : y ∈ t, hy : map Prod.snd f.1 ≤ 𝓝 y⟩ := ht (f.map Prod.snd) (mem_map.2 <| mem_of_superset hfs fun x => And.right) rw [map_le_iff_le_comap] at hx hy refine ⟨⟨x, y⟩, ⟨sx, ty⟩, ?_⟩ rw [nhds_prod_eq]; exact le_inf hx hy
/- Copyright (c) 2021 Patrick Massot. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Patrick Massot -/ import Mathlib.Topology.Algebra.GroupWithZero import Mathlib.Topology.Order.OrderClosed #align_import topology.algebra.with_zero_topology from "leanprover-community/mathlib"@"3e0c4d76b6ebe9dfafb67d16f7286d2731ed6064" /-! # The topology on linearly ordered commutative groups with zero Let `Γ₀` be a linearly ordered commutative group to which we have adjoined a zero element. Then `Γ₀` may naturally be endowed with a topology that turns `Γ₀` into a topological monoid. Neighborhoods of zero are sets containing `{ γ | γ < γ₀ }` for some invertible element `γ₀` and every invertible element is open. In particular the topology is the following: "a subset `U ⊆ Γ₀` is open if `0 ∉ U` or if there is an invertible `γ₀ ∈ Γ₀` such that `{ γ | γ < γ₀ } ⊆ U`", see `WithZeroTopology.isOpen_iff`. We prove this topology is ordered and T₅ (in addition to be compatible with the monoid structure). All this is useful to extend a valuation to a completion. This is an abstract version of how the absolute value (resp. `p`-adic absolute value) on `ℚ` is extended to `ℝ` (resp. `ℚₚ`). ## Implementation notes This topology is defined as a scoped instance since it may not be the desired topology on a linearly ordered commutative group with zero. You can locally activate this topology using `open WithZeroTopology`. -/ open Topology Filter TopologicalSpace Filter Set Function namespace WithZeroTopology variable {α Γ₀ : Type*} [LinearOrderedCommGroupWithZero Γ₀] {γ γ₁ γ₂ : Γ₀} {l : Filter α} {f : α → Γ₀} /-- The topology on a linearly ordered commutative group with a zero element adjoined. A subset U is open if 0 ∉ U or if there is an invertible element γ₀ such that {γ | γ < γ₀} ⊆ U. -/ scoped instance (priority := 100) topologicalSpace : TopologicalSpace Γ₀ := nhdsAdjoint 0 <| ⨅ γ ≠ 0, 𝓟 (Iio γ) #align with_zero_topology.topological_space WithZeroTopology.topologicalSpace
Mathlib/Topology/Algebra/WithZeroTopology.lean
47
49
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γ
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Analytic.Basic import Mathlib.Analysis.Analytic.CPolynomial import Mathlib.Analysis.Calculus.Deriv.Basic import Mathlib.Analysis.Calculus.ContDiff.Defs import Mathlib.Analysis.Calculus.FDeriv.Add #align_import analysis.calculus.fderiv_analytic from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe" /-! # Frechet derivatives of analytic functions. A function expressible as a power series at a point has a Frechet derivative there. Also the special case in terms of `deriv` when the domain is 1-dimensional. As an application, we show that continuous multilinear maps are smooth. We also compute their iterated derivatives, in `ContinuousMultilinearMap.iteratedFDeriv_eq`. -/ open Filter Asymptotics open scoped ENNReal universe u v variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] variable {E : Type u} [NormedAddCommGroup E] [NormedSpace 𝕜 E] variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F] section fderiv variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞} variable {f : E → F} {x : E} {s : Set E} theorem HasFPowerSeriesAt.hasStrictFDerivAt (h : HasFPowerSeriesAt f p x) : HasStrictFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := by refine h.isBigO_image_sub_norm_mul_norm_sub.trans_isLittleO (IsLittleO.of_norm_right ?_) refine isLittleO_iff_exists_eq_mul.2 ⟨fun y => ‖y - (x, x)‖, ?_, EventuallyEq.rfl⟩ refine (continuous_id.sub continuous_const).norm.tendsto' _ _ ?_ rw [_root_.id, sub_self, norm_zero] #align has_fpower_series_at.has_strict_fderiv_at HasFPowerSeriesAt.hasStrictFDerivAt theorem HasFPowerSeriesAt.hasFDerivAt (h : HasFPowerSeriesAt f p x) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p 1)) x := h.hasStrictFDerivAt.hasFDerivAt #align has_fpower_series_at.has_fderiv_at HasFPowerSeriesAt.hasFDerivAt theorem HasFPowerSeriesAt.differentiableAt (h : HasFPowerSeriesAt f p x) : DifferentiableAt 𝕜 f x := h.hasFDerivAt.differentiableAt #align has_fpower_series_at.differentiable_at HasFPowerSeriesAt.differentiableAt theorem AnalyticAt.differentiableAt : AnalyticAt 𝕜 f x → DifferentiableAt 𝕜 f x | ⟨_, hp⟩ => hp.differentiableAt #align analytic_at.differentiable_at AnalyticAt.differentiableAt theorem AnalyticAt.differentiableWithinAt (h : AnalyticAt 𝕜 f x) : DifferentiableWithinAt 𝕜 f s x := h.differentiableAt.differentiableWithinAt #align analytic_at.differentiable_within_at AnalyticAt.differentiableWithinAt theorem HasFPowerSeriesAt.fderiv_eq (h : HasFPowerSeriesAt f p x) : fderiv 𝕜 f x = continuousMultilinearCurryFin1 𝕜 E F (p 1) := h.hasFDerivAt.fderiv #align has_fpower_series_at.fderiv_eq HasFPowerSeriesAt.fderiv_eq theorem HasFPowerSeriesOnBall.differentiableOn [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) : DifferentiableOn 𝕜 f (EMetric.ball x r) := fun _ hy => (h.analyticAt_of_mem hy).differentiableWithinAt #align has_fpower_series_on_ball.differentiable_on HasFPowerSeriesOnBall.differentiableOn theorem AnalyticOn.differentiableOn (h : AnalyticOn 𝕜 f s) : DifferentiableOn 𝕜 f s := fun y hy => (h y hy).differentiableWithinAt #align analytic_on.differentiable_on AnalyticOn.differentiableOn theorem HasFPowerSeriesOnBall.hasFDerivAt [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) := (h.changeOrigin hy).hasFPowerSeriesAt.hasFDerivAt #align has_fpower_series_on_ball.has_fderiv_at HasFPowerSeriesOnBall.hasFDerivAt theorem HasFPowerSeriesOnBall.fderiv_eq [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) := (h.hasFDerivAt hy).fderiv #align has_fpower_series_on_ball.fderiv_eq HasFPowerSeriesOnBall.fderiv_eq /-- If a function has a power series on a ball, then so does its derivative. -/ theorem HasFPowerSeriesOnBall.fderiv [CompleteSpace F] (h : HasFPowerSeriesOnBall f p x r) : HasFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x r := by refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_ fun z hz ↦ ?_ · refine continuousMultilinearCurryFin1 𝕜 E F |>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFPowerSeriesOnBall ?_ simpa using ((p.hasFPowerSeriesOnBall_changeOrigin 1 (h.r_pos.trans_le h.r_le)).mono h.r_pos h.r_le).comp_sub x dsimp only rw [← h.fderiv_eq, add_sub_cancel] simpa only [edist_eq_coe_nnnorm_sub, EMetric.mem_ball] using hz #align has_fpower_series_on_ball.fderiv HasFPowerSeriesOnBall.fderiv /-- If a function is analytic on a set `s`, so is its Fréchet derivative. -/ theorem AnalyticOn.fderiv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) : AnalyticOn 𝕜 (fderiv 𝕜 f) s := by intro y hy rcases h y hy with ⟨p, r, hp⟩ exact hp.fderiv.analyticAt #align analytic_on.fderiv AnalyticOn.fderiv /-- If a function is analytic on a set `s`, so are its successive Fréchet derivative. -/ theorem AnalyticOn.iteratedFDeriv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) (n : ℕ) : AnalyticOn 𝕜 (iteratedFDeriv 𝕜 n f) s := by induction' n with n IH · rw [iteratedFDeriv_zero_eq_comp] exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F).comp_analyticOn h · rw [iteratedFDeriv_succ_eq_comp_left] -- Porting note: for reasons that I do not understand at all, `?g` cannot be inlined. convert ContinuousLinearMap.comp_analyticOn ?g IH.fderiv case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F) simp #align analytic_on.iterated_fderiv AnalyticOn.iteratedFDeriv /-- An analytic function is infinitely differentiable. -/ theorem AnalyticOn.contDiffOn [CompleteSpace F] (h : AnalyticOn 𝕜 f s) {n : ℕ∞} : ContDiffOn 𝕜 n f s := let t := { x | AnalyticAt 𝕜 f x } suffices ContDiffOn 𝕜 n f t from this.mono h have H : AnalyticOn 𝕜 f t := fun _x hx ↦ hx have t_open : IsOpen t := isOpen_analyticAt 𝕜 f contDiffOn_of_continuousOn_differentiableOn (fun m _ ↦ (H.iteratedFDeriv m).continuousOn.congr fun _ hx ↦ iteratedFDerivWithin_of_isOpen _ t_open hx) (fun m _ ↦ (H.iteratedFDeriv m).differentiableOn.congr fun _ hx ↦ iteratedFDerivWithin_of_isOpen _ t_open hx) #align analytic_on.cont_diff_on AnalyticOn.contDiffOn theorem AnalyticAt.contDiffAt [CompleteSpace F] (h : AnalyticAt 𝕜 f x) {n : ℕ∞} : ContDiffAt 𝕜 n f x := by obtain ⟨s, hs, hf⟩ := h.exists_mem_nhds_analyticOn exact hf.contDiffOn.contDiffAt hs end fderiv section deriv variable {p : FormalMultilinearSeries 𝕜 𝕜 F} {r : ℝ≥0∞} variable {f : 𝕜 → F} {x : 𝕜} {s : Set 𝕜} protected theorem HasFPowerSeriesAt.hasStrictDerivAt (h : HasFPowerSeriesAt f p x) : HasStrictDerivAt f (p 1 fun _ => 1) x := h.hasStrictFDerivAt.hasStrictDerivAt #align has_fpower_series_at.has_strict_deriv_at HasFPowerSeriesAt.hasStrictDerivAt protected theorem HasFPowerSeriesAt.hasDerivAt (h : HasFPowerSeriesAt f p x) : HasDerivAt f (p 1 fun _ => 1) x := h.hasStrictDerivAt.hasDerivAt #align has_fpower_series_at.has_deriv_at HasFPowerSeriesAt.hasDerivAt protected theorem HasFPowerSeriesAt.deriv (h : HasFPowerSeriesAt f p x) : deriv f x = p 1 fun _ => 1 := h.hasDerivAt.deriv #align has_fpower_series_at.deriv HasFPowerSeriesAt.deriv /-- If a function is analytic on a set `s`, so is its derivative. -/ theorem AnalyticOn.deriv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) : AnalyticOn 𝕜 (deriv f) s := (ContinuousLinearMap.apply 𝕜 F (1 : 𝕜)).comp_analyticOn h.fderiv #align analytic_on.deriv AnalyticOn.deriv /-- If a function is analytic on a set `s`, so are its successive derivatives. -/ theorem AnalyticOn.iterated_deriv [CompleteSpace F] (h : AnalyticOn 𝕜 f s) (n : ℕ) : AnalyticOn 𝕜 (_root_.deriv^[n] f) s := by induction' n with n IH · exact h · simpa only [Function.iterate_succ', Function.comp_apply] using IH.deriv #align analytic_on.iterated_deriv AnalyticOn.iterated_deriv end deriv section fderiv variable {p : FormalMultilinearSeries 𝕜 E F} {r : ℝ≥0∞} {n : ℕ} variable {f : E → F} {x : E} {s : Set E} /-! The case of continuously polynomial functions. We get the same differentiability results as for analytic functions, but without the assumptions that `F` is complete. -/ theorem HasFiniteFPowerSeriesOnBall.differentiableOn (h : HasFiniteFPowerSeriesOnBall f p x n r) : DifferentiableOn 𝕜 f (EMetric.ball x r) := fun _ hy ↦ (h.cPolynomialAt_of_mem hy).analyticAt.differentiableWithinAt theorem HasFiniteFPowerSeriesOnBall.hasFDerivAt (h : HasFiniteFPowerSeriesOnBall f p x n r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : HasFDerivAt f (continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1)) (x + y) := (h.changeOrigin hy).toHasFPowerSeriesOnBall.hasFPowerSeriesAt.hasFDerivAt theorem HasFiniteFPowerSeriesOnBall.fderiv_eq (h : HasFiniteFPowerSeriesOnBall f p x n r) {y : E} (hy : (‖y‖₊ : ℝ≥0∞) < r) : fderiv 𝕜 f (x + y) = continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin y 1) := (h.hasFDerivAt hy).fderiv /-- If a function has a finite power series on a ball, then so does its derivative. -/ protected theorem HasFiniteFPowerSeriesOnBall.fderiv (h : HasFiniteFPowerSeriesOnBall f p x (n + 1) r) : HasFiniteFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x n r := by refine .congr (f := fun z ↦ continuousMultilinearCurryFin1 𝕜 E F (p.changeOrigin (z - x) 1)) ?_ fun z hz ↦ ?_ · refine continuousMultilinearCurryFin1 𝕜 E F |>.toContinuousLinearEquiv.toContinuousLinearMap.comp_hasFiniteFPowerSeriesOnBall ?_ simpa using ((p.hasFiniteFPowerSeriesOnBall_changeOrigin 1 h.finite).mono h.r_pos le_top).comp_sub x dsimp only rw [← h.fderiv_eq, add_sub_cancel] simpa only [edist_eq_coe_nnnorm_sub, EMetric.mem_ball] using hz /-- If a function has a finite power series on a ball, then so does its derivative. This is a variant of `HasFiniteFPowerSeriesOnBall.fderiv` where the degree of `f` is `< n` and not `< n + 1`. -/ theorem HasFiniteFPowerSeriesOnBall.fderiv' (h : HasFiniteFPowerSeriesOnBall f p x n r) : HasFiniteFPowerSeriesOnBall (fderiv 𝕜 f) p.derivSeries x (n - 1) r := by obtain rfl | hn := eq_or_ne n 0 · rw [zero_tsub] refine HasFiniteFPowerSeriesOnBall.bound_zero_of_eq_zero (fun y hy ↦ ?_) h.r_pos fun n ↦ ?_ · rw [Filter.EventuallyEq.fderiv_eq (f := fun _ ↦ 0)] · rw [fderiv_const, Pi.zero_apply] · exact Filter.eventuallyEq_iff_exists_mem.mpr ⟨EMetric.ball x r, EMetric.isOpen_ball.mem_nhds hy, fun z hz ↦ by rw [h.eq_zero_of_bound_zero z hz]⟩ · apply ContinuousMultilinearMap.ext; intro a change (continuousMultilinearCurryFin1 𝕜 E F) (p.changeOriginSeries 1 n a) = 0 rw [p.changeOriginSeries_finite_of_finite h.finite 1 (Nat.zero_le _)] exact map_zero _ · rw [← Nat.succ_pred hn] at h exact h.fderiv /-- If a function is polynomial on a set `s`, so is its Fréchet derivative. -/ theorem CPolynomialOn.fderiv (h : CPolynomialOn 𝕜 f s) : CPolynomialOn 𝕜 (fderiv 𝕜 f) s := by intro y hy rcases h y hy with ⟨p, r, n, hp⟩ exact hp.fderiv'.cPolynomialAt /-- If a function is polynomial on a set `s`, so are its successive Fréchet derivative. -/ theorem CPolynomialOn.iteratedFDeriv (h : CPolynomialOn 𝕜 f s) (n : ℕ) : CPolynomialOn 𝕜 (iteratedFDeriv 𝕜 n f) s := by induction' n with n IH · rw [iteratedFDeriv_zero_eq_comp] exact ((continuousMultilinearCurryFin0 𝕜 E F).symm : F →L[𝕜] E[×0]→L[𝕜] F).comp_cPolynomialOn h · rw [iteratedFDeriv_succ_eq_comp_left] convert ContinuousLinearMap.comp_cPolynomialOn ?g IH.fderiv case g => exact ↑(continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (n + 1) ↦ E) F) simp /-- A polynomial function is infinitely differentiable. -/ theorem CPolynomialOn.contDiffOn (h : CPolynomialOn 𝕜 f s) {n : ℕ∞} : ContDiffOn 𝕜 n f s := let t := { x | CPolynomialAt 𝕜 f x } suffices ContDiffOn 𝕜 n f t from this.mono h have H : CPolynomialOn 𝕜 f t := fun _x hx ↦ hx have t_open : IsOpen t := isOpen_cPolynomialAt 𝕜 f contDiffOn_of_continuousOn_differentiableOn (fun m _ ↦ (H.iteratedFDeriv m).continuousOn.congr fun _ hx ↦ iteratedFDerivWithin_of_isOpen _ t_open hx) (fun m _ ↦ (H.iteratedFDeriv m).analyticOn.differentiableOn.congr fun _ hx ↦ iteratedFDerivWithin_of_isOpen _ t_open hx) theorem CPolynomialAt.contDiffAt (h : CPolynomialAt 𝕜 f x) {n : ℕ∞} : ContDiffAt 𝕜 n f x := let ⟨_, hs, hf⟩ := h.exists_mem_nhds_cPolynomialOn hf.contDiffOn.contDiffAt hs end fderiv section deriv variable {p : FormalMultilinearSeries 𝕜 𝕜 F} {r : ℝ≥0∞} variable {f : 𝕜 → F} {x : 𝕜} {s : Set 𝕜} /-- If a function is polynomial on a set `s`, so is its derivative. -/ protected theorem CPolynomialOn.deriv (h : CPolynomialOn 𝕜 f s) : CPolynomialOn 𝕜 (deriv f) s := (ContinuousLinearMap.apply 𝕜 F (1 : 𝕜)).comp_cPolynomialOn h.fderiv /-- If a function is polynomial on a set `s`, so are its successive derivatives. -/ theorem CPolynomialOn.iterated_deriv (h : CPolynomialOn 𝕜 f s) (n : ℕ) : CPolynomialOn 𝕜 (deriv^[n] f) s := by induction' n with n IH · exact h · simpa only [Function.iterate_succ', Function.comp_apply] using IH.deriv end deriv namespace ContinuousMultilinearMap variable {ι : Type*} {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] [∀ i, NormedSpace 𝕜 (E i)] [Fintype ι] (f : ContinuousMultilinearMap 𝕜 E F) open FormalMultilinearSeries protected theorem hasFiniteFPowerSeriesOnBall : HasFiniteFPowerSeriesOnBall f f.toFormalMultilinearSeries 0 (Fintype.card ι + 1) ⊤ := .mk' (fun m hm ↦ dif_neg (Nat.succ_le_iff.mp hm).ne) ENNReal.zero_lt_top fun y _ ↦ by rw [Finset.sum_eq_single_of_mem _ (Finset.self_mem_range_succ _), zero_add] · rw [toFormalMultilinearSeries, dif_pos rfl]; rfl · intro m _ ne; rw [toFormalMultilinearSeries, dif_neg ne.symm]; rfl theorem changeOriginSeries_support {k l : ℕ} (h : k + l ≠ Fintype.card ι) : f.toFormalMultilinearSeries.changeOriginSeries k l = 0 := Finset.sum_eq_zero fun _ _ ↦ by simp_rw [FormalMultilinearSeries.changeOriginSeriesTerm, toFormalMultilinearSeries, dif_neg h.symm, LinearIsometryEquiv.map_zero] variable {n : ℕ∞} (x : ∀ i, E i) open Finset in theorem changeOrigin_toFormalMultilinearSeries [DecidableEq ι] : continuousMultilinearCurryFin1 𝕜 (∀ i, E i) F (f.toFormalMultilinearSeries.changeOrigin x 1) = f.linearDeriv x := by ext y rw [continuousMultilinearCurryFin1_apply, linearDeriv_apply, changeOrigin, FormalMultilinearSeries.sum] cases isEmpty_or_nonempty ι · have (l) : 1 + l ≠ Fintype.card ι := by rw [add_comm, Fintype.card_eq_zero]; exact Nat.succ_ne_zero _ simp_rw [Fintype.sum_empty, changeOriginSeries_support _ (this _), zero_apply _, tsum_zero]; rfl rw [tsum_eq_single (Fintype.card ι - 1), changeOriginSeries]; swap · intro m hm rw [Ne, eq_tsub_iff_add_eq_of_le (by exact Fintype.card_pos), add_comm] at hm rw [f.changeOriginSeries_support hm, zero_apply] rw [sum_apply, ContinuousMultilinearMap.sum_apply, Fin.snoc_zero] simp_rw [changeOriginSeriesTerm_apply] refine (Fintype.sum_bijective (?_ ∘ Fintype.equivFinOfCardEq (Nat.add_sub_of_le Fintype.card_pos).symm) (.comp ?_ <| Equiv.bijective _) _ _ fun i ↦ ?_).symm · exact (⟨{·}ᶜ, by rw [card_compl, Fintype.card_fin, card_singleton, Nat.add_sub_cancel_left]⟩) · use fun _ _ ↦ (singleton_injective <| compl_injective <| Subtype.ext_iff.mp ·) intro ⟨s, hs⟩ have h : sᶜ.card = 1 := by rw [card_compl, hs, Fintype.card_fin, Nat.add_sub_cancel] obtain ⟨a, ha⟩ := card_eq_one.mp h exact ⟨a, Subtype.ext (compl_eq_comm.mp ha)⟩ rw [Function.comp_apply, Subtype.coe_mk, compl_singleton, piecewise_erase_univ, toFormalMultilinearSeries, dif_pos (Nat.add_sub_of_le Fintype.card_pos).symm] simp_rw [domDomCongr_apply, compContinuousLinearMap_apply, ContinuousLinearMap.proj_apply, Function.update_apply, (Equiv.injective _).eq_iff, ite_apply] congr; ext j obtain rfl | hj := eq_or_ne j i · rw [Function.update_same, if_pos rfl] · rw [Function.update_noteq hj, if_neg hj] protected theorem hasFDerivAt [DecidableEq ι] : HasFDerivAt f (f.linearDeriv x) x := by rw [← changeOrigin_toFormalMultilinearSeries] convert f.hasFiniteFPowerSeriesOnBall.hasFDerivAt (y := x) ENNReal.coe_lt_top rw [zero_add] /-- Technical lemma used in the proof of `hasFTaylorSeriesUpTo_iteratedFDeriv`, to compare sums over embedding of `Fin k` and `Fin (k + 1)`. -/ private lemma _root_.Equiv.succ_embeddingFinSucc_fst_symm_apply {ι : Type*} [DecidableEq ι] {n : ℕ} (e : Fin (n+1) ↪ ι) {k : ι} (h'k : k ∈ Set.range (Equiv.embeddingFinSucc n ι e).1) (hk : k ∈ Set.range e) : Fin.succ ((Equiv.embeddingFinSucc n ι e).1.toEquivRange.symm ⟨k, h'k⟩) = e.toEquivRange.symm ⟨k, hk⟩ := by rcases hk with ⟨j, rfl⟩ have hj : j ≠ 0 := by rintro rfl simp at h'k simp only [Function.Embedding.toEquivRange_symm_apply_self] have : e j = (Equiv.embeddingFinSucc n ι e).1 (Fin.pred j hj) := by simp simp_rw [this] simp [-Equiv.embeddingFinSucc_fst] /-- A continuous multilinear function `f` admits a Taylor series, whose successive terms are given by `f.iteratedFDeriv n`. This is the point of the definition of `f.iteratedFDeriv`. -/
Mathlib/Analysis/Calculus/FDeriv/Analytic.lean
371
420
theorem hasFTaylorSeriesUpTo_iteratedFDeriv : HasFTaylorSeriesUpTo ⊤ f (fun v n ↦ f.iteratedFDeriv n v) := by
classical constructor · simp [ContinuousMultilinearMap.iteratedFDeriv] · rintro n - x suffices H : curryLeft (f.iteratedFDeriv (Nat.succ n) x) = (∑ e : Fin n ↪ ι, ((iteratedFDerivComponent f e.toEquivRange).linearDeriv (Pi.compRightL 𝕜 _ Subtype.val x)) ∘L (Pi.compRightL 𝕜 _ Subtype.val)) by have A : HasFDerivAt (f.iteratedFDeriv n) (∑ e : Fin n ↪ ι, ((iteratedFDerivComponent f e.toEquivRange).linearDeriv (Pi.compRightL 𝕜 _ Subtype.val x)) ∘L (Pi.compRightL 𝕜 _ Subtype.val)) x := by apply HasFDerivAt.sum (fun s _hs ↦ ?_) exact (ContinuousMultilinearMap.hasFDerivAt _ _).comp x (ContinuousLinearMap.hasFDerivAt _) rwa [← H] at A ext v m simp only [ContinuousMultilinearMap.iteratedFDeriv, curryLeft_apply, sum_apply, iteratedFDerivComponent_apply, Finset.univ_sigma_univ, Pi.compRightL_apply, ContinuousLinearMap.coe_sum', ContinuousLinearMap.coe_comp', Finset.sum_apply, Function.comp_apply, linearDeriv_apply, Finset.sum_sigma'] rw [← (Equiv.embeddingFinSucc n ι).sum_comp] congr with e congr with k by_cases hke : k ∈ Set.range e · simp only [hke, ↓reduceDite] split_ifs with hkf · simp only [← Equiv.succ_embeddingFinSucc_fst_symm_apply e hkf hke, Fin.cons_succ] · obtain rfl : k = e 0 := by rcases hke with ⟨j, rfl⟩ simpa using hkf simp only [Function.Embedding.toEquivRange_symm_apply_self, Fin.cons_zero, Function.update, Pi.compRightL_apply] split_ifs with h · congr! · exfalso apply h simp_rw [← Equiv.embeddingFinSucc_snd e] · have hkf : k ∉ Set.range (Equiv.embeddingFinSucc n ι e).1 := by contrapose! hke rw [Equiv.embeddingFinSucc_fst] at hke exact Set.range_comp_subset_range _ _ hke simp only [hke, hkf, ↓reduceDite, Pi.compRightL, ContinuousLinearMap.coe_mk', LinearMap.coe_mk, AddHom.coe_mk] rw [Function.update_noteq] contrapose! hke rw [show k = _ from Subtype.ext_iff_val.1 hke, Equiv.embeddingFinSucc_snd e] exact Set.mem_range_self _ · rintro n - apply continuous_finset_sum _ (fun e _ ↦ ?_) exact (ContinuousMultilinearMap.coe_continuous _).comp (ContinuousLinearMap.continuous _)
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Floris van Doorn -/ import Mathlib.Data.Finsupp.Multiset import Mathlib.Order.Bounded import Mathlib.SetTheory.Cardinal.PartENat import Mathlib.SetTheory.Ordinal.Principal import Mathlib.Tactic.Linarith #align_import set_theory.cardinal.ordinal from "leanprover-community/mathlib"@"7c2ce0c2da15516b4e65d0c9e254bb6dc93abd1f" /-! # Cardinals and ordinals Relationships between cardinals and ordinals, properties of cardinals that are proved using ordinals. ## Main definitions * The function `Cardinal.aleph'` gives the cardinals listed by their ordinal index, and is the inverse of `Cardinal.aleph/idx`. `aleph' n = n`, `aleph' ω = ℵ₀`, `aleph' (ω + 1) = succ ℵ₀`, etc. It is an order isomorphism between ordinals and cardinals. * The function `Cardinal.aleph` gives the infinite cardinals listed by their ordinal index. `aleph 0 = ℵ₀`, `aleph 1 = succ ℵ₀` is the first uncountable cardinal, and so on. The notation `ω_` combines the latter with `Cardinal.ord`, giving an enumeration of (infinite) initial ordinals. Thus `ω_ 0 = ω` and `ω₁ = ω_ 1` is the first uncountable ordinal. * The function `Cardinal.beth` enumerates the Beth cardinals. `beth 0 = ℵ₀`, `beth (succ o) = 2 ^ beth o`, and for a limit ordinal `o`, `beth o` is the supremum of `beth a` for `a < o`. ## Main Statements * `Cardinal.mul_eq_max` and `Cardinal.add_eq_max` state that the product (resp. sum) of two infinite cardinals is just their maximum. Several variations around this fact are also given. * `Cardinal.mk_list_eq_mk` : when `α` is infinite, `α` and `List α` have the same cardinality. * simp lemmas for inequalities between `bit0 a` and `bit1 b` are registered, making `simp` able to prove inequalities about numeral cardinals. ## Tags cardinal arithmetic (for infinite cardinals) -/ noncomputable section open Function Set Cardinal Equiv Order Ordinal open scoped Classical universe u v w namespace Cardinal section UsingOrdinals theorem ord_isLimit {c} (co : ℵ₀ ≤ c) : (ord c).IsLimit := by refine ⟨fun h => aleph0_ne_zero ?_, fun a => lt_imp_lt_of_le_imp_le fun h => ?_⟩ · rw [← Ordinal.le_zero, ord_le] at h simpa only [card_zero, nonpos_iff_eq_zero] using co.trans h · rw [ord_le] at h ⊢ rwa [← @add_one_of_aleph0_le (card a), ← card_succ] rw [← ord_le, ← le_succ_of_isLimit, ord_le] · exact co.trans h · rw [ord_aleph0] exact omega_isLimit #align cardinal.ord_is_limit Cardinal.ord_isLimit theorem noMaxOrder {c} (h : ℵ₀ ≤ c) : NoMaxOrder c.ord.out.α := Ordinal.out_no_max_of_succ_lt (ord_isLimit h).2 /-! ### Aleph cardinals -/ section aleph /-- The `aleph'` index function, which gives the ordinal index of a cardinal. (The `aleph'` part is because unlike `aleph` this counts also the finite stages. So `alephIdx n = n`, `alephIdx ω = ω`, `alephIdx ℵ₁ = ω + 1` and so on.) In this definition, we register additionally that this function is an initial segment, i.e., it is order preserving and its range is an initial segment of the ordinals. For the basic function version, see `alephIdx`. For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/ def alephIdx.initialSeg : @InitialSeg Cardinal Ordinal (· < ·) (· < ·) := @RelEmbedding.collapse Cardinal Ordinal (· < ·) (· < ·) _ Cardinal.ord.orderEmbedding.ltEmbedding #align cardinal.aleph_idx.initial_seg Cardinal.alephIdx.initialSeg /-- The `aleph'` index function, which gives the ordinal index of a cardinal. (The `aleph'` part is because unlike `aleph` this counts also the finite stages. So `alephIdx n = n`, `alephIdx ω = ω`, `alephIdx ℵ₁ = ω + 1` and so on.) For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/ def alephIdx : Cardinal → Ordinal := alephIdx.initialSeg #align cardinal.aleph_idx Cardinal.alephIdx @[simp] theorem alephIdx.initialSeg_coe : (alephIdx.initialSeg : Cardinal → Ordinal) = alephIdx := rfl #align cardinal.aleph_idx.initial_seg_coe Cardinal.alephIdx.initialSeg_coe @[simp] theorem alephIdx_lt {a b} : alephIdx a < alephIdx b ↔ a < b := alephIdx.initialSeg.toRelEmbedding.map_rel_iff #align cardinal.aleph_idx_lt Cardinal.alephIdx_lt @[simp] theorem alephIdx_le {a b} : alephIdx a ≤ alephIdx b ↔ a ≤ b := by rw [← not_lt, ← not_lt, alephIdx_lt] #align cardinal.aleph_idx_le Cardinal.alephIdx_le theorem alephIdx.init {a b} : b < alephIdx a → ∃ c, alephIdx c = b := alephIdx.initialSeg.init #align cardinal.aleph_idx.init Cardinal.alephIdx.init /-- The `aleph'` index function, which gives the ordinal index of a cardinal. (The `aleph'` part is because unlike `aleph` this counts also the finite stages. So `alephIdx n = n`, `alephIdx ℵ₀ = ω`, `alephIdx ℵ₁ = ω + 1` and so on.) In this version, we register additionally that this function is an order isomorphism between cardinals and ordinals. For the basic function version, see `alephIdx`. -/ def alephIdx.relIso : @RelIso Cardinal.{u} Ordinal.{u} (· < ·) (· < ·) := @RelIso.ofSurjective Cardinal.{u} Ordinal.{u} (· < ·) (· < ·) alephIdx.initialSeg.{u} <| (InitialSeg.eq_or_principal alephIdx.initialSeg.{u}).resolve_right fun ⟨o, e⟩ => by have : ∀ c, alephIdx c < o := fun c => (e _).2 ⟨_, rfl⟩ refine Ordinal.inductionOn o ?_ this; intro α r _ h let s := ⨆ a, invFun alephIdx (Ordinal.typein r a) apply (lt_succ s).not_le have I : Injective.{u+2, u+2} alephIdx := alephIdx.initialSeg.toEmbedding.injective simpa only [typein_enum, leftInverse_invFun I (succ s)] using le_ciSup (Cardinal.bddAbove_range.{u, u} fun a : α => invFun alephIdx (Ordinal.typein r a)) (Ordinal.enum r _ (h (succ s))) #align cardinal.aleph_idx.rel_iso Cardinal.alephIdx.relIso @[simp] theorem alephIdx.relIso_coe : (alephIdx.relIso : Cardinal → Ordinal) = alephIdx := rfl #align cardinal.aleph_idx.rel_iso_coe Cardinal.alephIdx.relIso_coe @[simp] theorem type_cardinal : @type Cardinal (· < ·) _ = Ordinal.univ.{u, u + 1} := by rw [Ordinal.univ_id]; exact Quotient.sound ⟨alephIdx.relIso⟩ #align cardinal.type_cardinal Cardinal.type_cardinal @[simp] theorem mk_cardinal : #Cardinal = univ.{u, u + 1} := by simpa only [card_type, card_univ] using congr_arg card type_cardinal #align cardinal.mk_cardinal Cardinal.mk_cardinal /-- The `aleph'` function gives the cardinals listed by their ordinal index, and is the inverse of `aleph_idx`. `aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = succ ℵ₀`, etc. In this version, we register additionally that this function is an order isomorphism between ordinals and cardinals. For the basic function version, see `aleph'`. -/ def Aleph'.relIso := Cardinal.alephIdx.relIso.symm #align cardinal.aleph'.rel_iso Cardinal.Aleph'.relIso /-- The `aleph'` function gives the cardinals listed by their ordinal index, and is the inverse of `aleph_idx`. `aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = succ ℵ₀`, etc. -/ def aleph' : Ordinal → Cardinal := Aleph'.relIso #align cardinal.aleph' Cardinal.aleph' @[simp] theorem aleph'.relIso_coe : (Aleph'.relIso : Ordinal → Cardinal) = aleph' := rfl #align cardinal.aleph'.rel_iso_coe Cardinal.aleph'.relIso_coe @[simp] theorem aleph'_lt {o₁ o₂ : Ordinal} : aleph' o₁ < aleph' o₂ ↔ o₁ < o₂ := Aleph'.relIso.map_rel_iff #align cardinal.aleph'_lt Cardinal.aleph'_lt @[simp] theorem aleph'_le {o₁ o₂ : Ordinal} : aleph' o₁ ≤ aleph' o₂ ↔ o₁ ≤ o₂ := le_iff_le_iff_lt_iff_lt.2 aleph'_lt #align cardinal.aleph'_le Cardinal.aleph'_le @[simp] theorem aleph'_alephIdx (c : Cardinal) : aleph' c.alephIdx = c := Cardinal.alephIdx.relIso.toEquiv.symm_apply_apply c #align cardinal.aleph'_aleph_idx Cardinal.aleph'_alephIdx @[simp] theorem alephIdx_aleph' (o : Ordinal) : (aleph' o).alephIdx = o := Cardinal.alephIdx.relIso.toEquiv.apply_symm_apply o #align cardinal.aleph_idx_aleph' Cardinal.alephIdx_aleph' @[simp] theorem aleph'_zero : aleph' 0 = 0 := by rw [← nonpos_iff_eq_zero, ← aleph'_alephIdx 0, aleph'_le] apply Ordinal.zero_le #align cardinal.aleph'_zero Cardinal.aleph'_zero @[simp] theorem aleph'_succ {o : Ordinal} : aleph' (succ o) = succ (aleph' o) := by apply (succ_le_of_lt <| aleph'_lt.2 <| lt_succ o).antisymm' (Cardinal.alephIdx_le.1 <| _) rw [alephIdx_aleph', succ_le_iff, ← aleph'_lt, aleph'_alephIdx] apply lt_succ #align cardinal.aleph'_succ Cardinal.aleph'_succ @[simp] theorem aleph'_nat : ∀ n : ℕ, aleph' n = n | 0 => aleph'_zero | n + 1 => show aleph' (succ n) = n.succ by rw [aleph'_succ, aleph'_nat n, nat_succ] #align cardinal.aleph'_nat Cardinal.aleph'_nat theorem aleph'_le_of_limit {o : Ordinal} (l : o.IsLimit) {c} : aleph' o ≤ c ↔ ∀ o' < o, aleph' o' ≤ c := ⟨fun h o' h' => (aleph'_le.2 <| h'.le).trans h, fun h => by rw [← aleph'_alephIdx c, aleph'_le, limit_le l] intro x h' rw [← aleph'_le, aleph'_alephIdx] exact h _ h'⟩ #align cardinal.aleph'_le_of_limit Cardinal.aleph'_le_of_limit theorem aleph'_limit {o : Ordinal} (ho : o.IsLimit) : aleph' o = ⨆ a : Iio o, aleph' a := by refine le_antisymm ?_ (ciSup_le' fun i => aleph'_le.2 (le_of_lt i.2)) rw [aleph'_le_of_limit ho] exact fun a ha => le_ciSup (bddAbove_of_small _) (⟨a, ha⟩ : Iio o) #align cardinal.aleph'_limit Cardinal.aleph'_limit @[simp] theorem aleph'_omega : aleph' ω = ℵ₀ := eq_of_forall_ge_iff fun c => by simp only [aleph'_le_of_limit omega_isLimit, lt_omega, exists_imp, aleph0_le] exact forall_swap.trans (forall_congr' fun n => by simp only [forall_eq, aleph'_nat]) #align cardinal.aleph'_omega Cardinal.aleph'_omega /-- `aleph'` and `aleph_idx` form an equivalence between `Ordinal` and `Cardinal` -/ @[simp] def aleph'Equiv : Ordinal ≃ Cardinal := ⟨aleph', alephIdx, alephIdx_aleph', aleph'_alephIdx⟩ #align cardinal.aleph'_equiv Cardinal.aleph'Equiv /-- The `aleph` function gives the infinite cardinals listed by their ordinal index. `aleph 0 = ℵ₀`, `aleph 1 = succ ℵ₀` is the first uncountable cardinal, and so on. -/ def aleph (o : Ordinal) : Cardinal := aleph' (ω + o) #align cardinal.aleph Cardinal.aleph @[simp] theorem aleph_lt {o₁ o₂ : Ordinal} : aleph o₁ < aleph o₂ ↔ o₁ < o₂ := aleph'_lt.trans (add_lt_add_iff_left _) #align cardinal.aleph_lt Cardinal.aleph_lt @[simp] theorem aleph_le {o₁ o₂ : Ordinal} : aleph o₁ ≤ aleph o₂ ↔ o₁ ≤ o₂ := le_iff_le_iff_lt_iff_lt.2 aleph_lt #align cardinal.aleph_le Cardinal.aleph_le @[simp] theorem max_aleph_eq (o₁ o₂ : Ordinal) : max (aleph o₁) (aleph o₂) = aleph (max o₁ o₂) := by rcases le_total (aleph o₁) (aleph o₂) with h | h · rw [max_eq_right h, max_eq_right (aleph_le.1 h)] · rw [max_eq_left h, max_eq_left (aleph_le.1 h)] #align cardinal.max_aleph_eq Cardinal.max_aleph_eq @[simp] theorem aleph_succ {o : Ordinal} : aleph (succ o) = succ (aleph o) := by rw [aleph, add_succ, aleph'_succ, aleph] #align cardinal.aleph_succ Cardinal.aleph_succ @[simp] theorem aleph_zero : aleph 0 = ℵ₀ := by rw [aleph, add_zero, aleph'_omega] #align cardinal.aleph_zero Cardinal.aleph_zero theorem aleph_limit {o : Ordinal} (ho : o.IsLimit) : aleph o = ⨆ a : Iio o, aleph a := by apply le_antisymm _ (ciSup_le' _) · rw [aleph, aleph'_limit (ho.add _)] refine ciSup_mono' (bddAbove_of_small _) ?_ rintro ⟨i, hi⟩ cases' lt_or_le i ω with h h · rcases lt_omega.1 h with ⟨n, rfl⟩ use ⟨0, ho.pos⟩ simpa using (nat_lt_aleph0 n).le · exact ⟨⟨_, (sub_lt_of_le h).2 hi⟩, aleph'_le.2 (le_add_sub _ _)⟩ · exact fun i => aleph_le.2 (le_of_lt i.2) #align cardinal.aleph_limit Cardinal.aleph_limit theorem aleph0_le_aleph' {o : Ordinal} : ℵ₀ ≤ aleph' o ↔ ω ≤ o := by rw [← aleph'_omega, aleph'_le] #align cardinal.aleph_0_le_aleph' Cardinal.aleph0_le_aleph' theorem aleph0_le_aleph (o : Ordinal) : ℵ₀ ≤ aleph o := by rw [aleph, aleph0_le_aleph'] apply Ordinal.le_add_right #align cardinal.aleph_0_le_aleph Cardinal.aleph0_le_aleph theorem aleph'_pos {o : Ordinal} (ho : 0 < o) : 0 < aleph' o := by rwa [← aleph'_zero, aleph'_lt] #align cardinal.aleph'_pos Cardinal.aleph'_pos theorem aleph_pos (o : Ordinal) : 0 < aleph o := aleph0_pos.trans_le (aleph0_le_aleph o) #align cardinal.aleph_pos Cardinal.aleph_pos @[simp] theorem aleph_toNat (o : Ordinal) : toNat (aleph o) = 0 := toNat_apply_of_aleph0_le <| aleph0_le_aleph o #align cardinal.aleph_to_nat Cardinal.aleph_toNat @[simp] theorem aleph_toPartENat (o : Ordinal) : toPartENat (aleph o) = ⊤ := toPartENat_apply_of_aleph0_le <| aleph0_le_aleph o #align cardinal.aleph_to_part_enat Cardinal.aleph_toPartENat instance nonempty_out_aleph (o : Ordinal) : Nonempty (aleph o).ord.out.α := by rw [out_nonempty_iff_ne_zero, ← ord_zero] exact fun h => (ord_injective h).not_gt (aleph_pos o) #align cardinal.nonempty_out_aleph Cardinal.nonempty_out_aleph theorem ord_aleph_isLimit (o : Ordinal) : (aleph o).ord.IsLimit := ord_isLimit <| aleph0_le_aleph _ #align cardinal.ord_aleph_is_limit Cardinal.ord_aleph_isLimit instance (o : Ordinal) : NoMaxOrder (aleph o).ord.out.α := out_no_max_of_succ_lt (ord_aleph_isLimit o).2 theorem exists_aleph {c : Cardinal} : ℵ₀ ≤ c ↔ ∃ o, c = aleph o := ⟨fun h => ⟨alephIdx c - ω, by rw [aleph, Ordinal.add_sub_cancel_of_le, aleph'_alephIdx] rwa [← aleph0_le_aleph', aleph'_alephIdx]⟩, fun ⟨o, e⟩ => e.symm ▸ aleph0_le_aleph _⟩ #align cardinal.exists_aleph Cardinal.exists_aleph theorem aleph'_isNormal : IsNormal (ord ∘ aleph') := ⟨fun o => ord_lt_ord.2 <| aleph'_lt.2 <| lt_succ o, fun o l a => by simp [ord_le, aleph'_le_of_limit l]⟩ #align cardinal.aleph'_is_normal Cardinal.aleph'_isNormal theorem aleph_isNormal : IsNormal (ord ∘ aleph) := aleph'_isNormal.trans <| add_isNormal ω #align cardinal.aleph_is_normal Cardinal.aleph_isNormal theorem succ_aleph0 : succ ℵ₀ = aleph 1 := by rw [← aleph_zero, ← aleph_succ, Ordinal.succ_zero] #align cardinal.succ_aleph_0 Cardinal.succ_aleph0 theorem aleph0_lt_aleph_one : ℵ₀ < aleph 1 := by rw [← succ_aleph0] apply lt_succ #align cardinal.aleph_0_lt_aleph_one Cardinal.aleph0_lt_aleph_one theorem countable_iff_lt_aleph_one {α : Type*} (s : Set α) : s.Countable ↔ #s < aleph 1 := by rw [← succ_aleph0, lt_succ_iff, le_aleph0_iff_set_countable] #align cardinal.countable_iff_lt_aleph_one Cardinal.countable_iff_lt_aleph_one /-- Ordinals that are cardinals are unbounded. -/ theorem ord_card_unbounded : Unbounded (· < ·) { b : Ordinal | b.card.ord = b } := unbounded_lt_iff.2 fun a => ⟨_, ⟨by dsimp rw [card_ord], (lt_ord_succ_card a).le⟩⟩ #align cardinal.ord_card_unbounded Cardinal.ord_card_unbounded theorem eq_aleph'_of_eq_card_ord {o : Ordinal} (ho : o.card.ord = o) : ∃ a, (aleph' a).ord = o := ⟨Cardinal.alephIdx.relIso o.card, by simpa using ho⟩ #align cardinal.eq_aleph'_of_eq_card_ord Cardinal.eq_aleph'_of_eq_card_ord /-- `ord ∘ aleph'` enumerates the ordinals that are cardinals. -/ theorem ord_aleph'_eq_enum_card : ord ∘ aleph' = enumOrd { b : Ordinal | b.card.ord = b } := by rw [← eq_enumOrd _ ord_card_unbounded, range_eq_iff] exact ⟨aleph'_isNormal.strictMono, ⟨fun a => by dsimp rw [card_ord], fun b hb => eq_aleph'_of_eq_card_ord hb⟩⟩ #align cardinal.ord_aleph'_eq_enum_card Cardinal.ord_aleph'_eq_enum_card /-- Infinite ordinals that are cardinals are unbounded. -/ theorem ord_card_unbounded' : Unbounded (· < ·) { b : Ordinal | b.card.ord = b ∧ ω ≤ b } := (unbounded_lt_inter_le ω).2 ord_card_unbounded #align cardinal.ord_card_unbounded' Cardinal.ord_card_unbounded' theorem eq_aleph_of_eq_card_ord {o : Ordinal} (ho : o.card.ord = o) (ho' : ω ≤ o) : ∃ a, (aleph a).ord = o := by cases' eq_aleph'_of_eq_card_ord ho with a ha use a - ω unfold aleph rwa [Ordinal.add_sub_cancel_of_le] rwa [← aleph0_le_aleph', ← ord_le_ord, ha, ord_aleph0] #align cardinal.eq_aleph_of_eq_card_ord Cardinal.eq_aleph_of_eq_card_ord /-- `ord ∘ aleph` enumerates the infinite ordinals that are cardinals. -/ theorem ord_aleph_eq_enum_card : ord ∘ aleph = enumOrd { b : Ordinal | b.card.ord = b ∧ ω ≤ b } := by rw [← eq_enumOrd _ ord_card_unbounded'] use aleph_isNormal.strictMono rw [range_eq_iff] refine ⟨fun a => ⟨?_, ?_⟩, fun b hb => eq_aleph_of_eq_card_ord hb.1 hb.2⟩ · rw [Function.comp_apply, card_ord] · rw [← ord_aleph0, Function.comp_apply, ord_le_ord] exact aleph0_le_aleph _ #align cardinal.ord_aleph_eq_enum_card Cardinal.ord_aleph_eq_enum_card end aleph /-! ### Beth cardinals -/ section beth /-- Beth numbers are defined so that `beth 0 = ℵ₀`, `beth (succ o) = 2 ^ (beth o)`, and when `o` is a limit ordinal, `beth o` is the supremum of `beth o'` for `o' < o`. Assuming the generalized continuum hypothesis, which is undecidable in ZFC, `beth o = aleph o` for every `o`. -/ def beth (o : Ordinal.{u}) : Cardinal.{u} := limitRecOn o aleph0 (fun _ x => (2 : Cardinal) ^ x) fun a _ IH => ⨆ b : Iio a, IH b.1 b.2 #align cardinal.beth Cardinal.beth @[simp] theorem beth_zero : beth 0 = aleph0 := limitRecOn_zero _ _ _ #align cardinal.beth_zero Cardinal.beth_zero @[simp] theorem beth_succ (o : Ordinal) : beth (succ o) = 2 ^ beth o := limitRecOn_succ _ _ _ _ #align cardinal.beth_succ Cardinal.beth_succ theorem beth_limit {o : Ordinal} : o.IsLimit → beth o = ⨆ a : Iio o, beth a := limitRecOn_limit _ _ _ _ #align cardinal.beth_limit Cardinal.beth_limit theorem beth_strictMono : StrictMono beth := by intro a b induction' b using Ordinal.induction with b IH generalizing a intro h rcases zero_or_succ_or_limit b with (rfl | ⟨c, rfl⟩ | hb) · exact (Ordinal.not_lt_zero a h).elim · rw [lt_succ_iff] at h rw [beth_succ] apply lt_of_le_of_lt _ (cantor _) rcases eq_or_lt_of_le h with (rfl | h) · rfl exact (IH c (lt_succ c) h).le · apply (cantor _).trans_le rw [beth_limit hb, ← beth_succ] exact le_ciSup (bddAbove_of_small _) (⟨_, hb.succ_lt h⟩ : Iio b) #align cardinal.beth_strict_mono Cardinal.beth_strictMono theorem beth_mono : Monotone beth := beth_strictMono.monotone #align cardinal.beth_mono Cardinal.beth_mono @[simp] theorem beth_lt {o₁ o₂ : Ordinal} : beth o₁ < beth o₂ ↔ o₁ < o₂ := beth_strictMono.lt_iff_lt #align cardinal.beth_lt Cardinal.beth_lt @[simp] theorem beth_le {o₁ o₂ : Ordinal} : beth o₁ ≤ beth o₂ ↔ o₁ ≤ o₂ := beth_strictMono.le_iff_le #align cardinal.beth_le Cardinal.beth_le theorem aleph_le_beth (o : Ordinal) : aleph o ≤ beth o := by induction o using limitRecOn with | H₁ => simp | H₂ o h => rw [aleph_succ, beth_succ, succ_le_iff] exact (cantor _).trans_le (power_le_power_left two_ne_zero h) | H₃ o ho IH => rw [aleph_limit ho, beth_limit ho] exact ciSup_mono (bddAbove_of_small _) fun x => IH x.1 x.2 #align cardinal.aleph_le_beth Cardinal.aleph_le_beth theorem aleph0_le_beth (o : Ordinal) : ℵ₀ ≤ beth o := (aleph0_le_aleph o).trans <| aleph_le_beth o #align cardinal.aleph_0_le_beth Cardinal.aleph0_le_beth theorem beth_pos (o : Ordinal) : 0 < beth o := aleph0_pos.trans_le <| aleph0_le_beth o #align cardinal.beth_pos Cardinal.beth_pos theorem beth_ne_zero (o : Ordinal) : beth o ≠ 0 := (beth_pos o).ne' #align cardinal.beth_ne_zero Cardinal.beth_ne_zero theorem beth_normal : IsNormal.{u} fun o => (beth o).ord := (isNormal_iff_strictMono_limit _).2 ⟨ord_strictMono.comp beth_strictMono, fun o ho a ha => by rw [beth_limit ho, ord_le] exact ciSup_le' fun b => ord_le.1 (ha _ b.2)⟩ #align cardinal.beth_normal Cardinal.beth_normal end beth /-! ### Properties of `mul` -/ section mulOrdinals /-- If `α` is an infinite type, then `α × α` and `α` have the same cardinality. -/ theorem mul_eq_self {c : Cardinal} (h : ℵ₀ ≤ c) : c * c = c := by refine le_antisymm ?_ (by simpa only [mul_one] using mul_le_mul_left' (one_le_aleph0.trans h) c) -- the only nontrivial part is `c * c ≤ c`. We prove it inductively. refine Acc.recOn (Cardinal.lt_wf.apply c) (fun c _ => Quotient.inductionOn c fun α IH ol => ?_) h -- consider the minimal well-order `r` on `α` (a type with cardinality `c`). rcases ord_eq α with ⟨r, wo, e⟩ letI := linearOrderOfSTO r haveI : IsWellOrder α (· < ·) := wo -- Define an order `s` on `α × α` by writing `(a, b) < (c, d)` if `max a b < max c d`, or -- the max are equal and `a < c`, or the max are equal and `a = c` and `b < d`. let g : α × α → α := fun p => max p.1 p.2 let f : α × α ↪ Ordinal × α × α := ⟨fun p : α × α => (typein (· < ·) (g p), p), fun p q => congr_arg Prod.snd⟩ let s := f ⁻¹'o Prod.Lex (· < ·) (Prod.Lex (· < ·) (· < ·)) -- this is a well order on `α × α`. haveI : IsWellOrder _ s := (RelEmbedding.preimage _ _).isWellOrder /- it suffices to show that this well order is smaller than `r` if it were larger, then `r` would be a strict prefix of `s`. It would be contained in `β × β` for some `β` of cardinality `< c`. By the inductive assumption, this set has the same cardinality as `β` (or it is finite if `β` is finite), so it is `< c`, which is a contradiction. -/ suffices type s ≤ type r by exact card_le_card this refine le_of_forall_lt fun o h => ?_ rcases typein_surj s h with ⟨p, rfl⟩ rw [← e, lt_ord] refine lt_of_le_of_lt (?_ : _ ≤ card (succ (typein (· < ·) (g p))) * card (succ (typein (· < ·) (g p)))) ?_ · have : { q | s q p } ⊆ insert (g p) { x | x < g p } ×ˢ insert (g p) { x | x < g p } := by intro q h simp only [s, f, Preimage, ge_iff_le, Embedding.coeFn_mk, Prod.lex_def, typein_lt_typein, typein_inj, mem_setOf_eq] at h exact max_le_iff.1 (le_iff_lt_or_eq.2 <| h.imp_right And.left) suffices H : (insert (g p) { x | r x (g p) } : Set α) ≃ Sum { x | r x (g p) } PUnit from ⟨(Set.embeddingOfSubset _ _ this).trans ((Equiv.Set.prod _ _).trans (H.prodCongr H)).toEmbedding⟩ refine (Equiv.Set.insert ?_).trans ((Equiv.refl _).sumCongr punitEquivPUnit) apply @irrefl _ r cases' lt_or_le (card (succ (typein (· < ·) (g p)))) ℵ₀ with qo qo · exact (mul_lt_aleph0 qo qo).trans_le ol · suffices (succ (typein LT.lt (g p))).card < ⟦α⟧ from (IH _ this qo).trans_lt this rw [← lt_ord] apply (ord_isLimit ol).2 rw [mk'_def, e] apply typein_lt_type #align cardinal.mul_eq_self Cardinal.mul_eq_self end mulOrdinals end UsingOrdinals /-! Properties of `mul`, not requiring ordinals -/ section mul /-- If `α` and `β` are infinite types, then the cardinality of `α × β` is the maximum of the cardinalities of `α` and `β`. -/ theorem mul_eq_max {a b : Cardinal} (ha : ℵ₀ ≤ a) (hb : ℵ₀ ≤ b) : a * b = max a b := le_antisymm (mul_eq_self (ha.trans (le_max_left a b)) ▸ mul_le_mul' (le_max_left _ _) (le_max_right _ _)) <| max_le (by simpa only [mul_one] using mul_le_mul_left' (one_le_aleph0.trans hb) a) (by simpa only [one_mul] using mul_le_mul_right' (one_le_aleph0.trans ha) b) #align cardinal.mul_eq_max Cardinal.mul_eq_max @[simp] theorem mul_mk_eq_max {α β : Type u} [Infinite α] [Infinite β] : #α * #β = max #α #β := mul_eq_max (aleph0_le_mk α) (aleph0_le_mk β) #align cardinal.mul_mk_eq_max Cardinal.mul_mk_eq_max @[simp] theorem aleph_mul_aleph (o₁ o₂ : Ordinal) : aleph o₁ * aleph o₂ = aleph (max o₁ o₂) := by rw [Cardinal.mul_eq_max (aleph0_le_aleph o₁) (aleph0_le_aleph o₂), max_aleph_eq] #align cardinal.aleph_mul_aleph Cardinal.aleph_mul_aleph @[simp] theorem aleph0_mul_eq {a : Cardinal} (ha : ℵ₀ ≤ a) : ℵ₀ * a = a := (mul_eq_max le_rfl ha).trans (max_eq_right ha) #align cardinal.aleph_0_mul_eq Cardinal.aleph0_mul_eq @[simp] theorem mul_aleph0_eq {a : Cardinal} (ha : ℵ₀ ≤ a) : a * ℵ₀ = a := (mul_eq_max ha le_rfl).trans (max_eq_left ha) #align cardinal.mul_aleph_0_eq Cardinal.mul_aleph0_eq -- Porting note (#10618): removed `simp`, `simp` can prove it theorem aleph0_mul_mk_eq {α : Type*} [Infinite α] : ℵ₀ * #α = #α := aleph0_mul_eq (aleph0_le_mk α) #align cardinal.aleph_0_mul_mk_eq Cardinal.aleph0_mul_mk_eq -- Porting note (#10618): removed `simp`, `simp` can prove it theorem mk_mul_aleph0_eq {α : Type*} [Infinite α] : #α * ℵ₀ = #α := mul_aleph0_eq (aleph0_le_mk α) #align cardinal.mk_mul_aleph_0_eq Cardinal.mk_mul_aleph0_eq @[simp] theorem aleph0_mul_aleph (o : Ordinal) : ℵ₀ * aleph o = aleph o := aleph0_mul_eq (aleph0_le_aleph o) #align cardinal.aleph_0_mul_aleph Cardinal.aleph0_mul_aleph @[simp] theorem aleph_mul_aleph0 (o : Ordinal) : aleph o * ℵ₀ = aleph o := mul_aleph0_eq (aleph0_le_aleph o) #align cardinal.aleph_mul_aleph_0 Cardinal.aleph_mul_aleph0 theorem mul_lt_of_lt {a b c : Cardinal} (hc : ℵ₀ ≤ c) (h1 : a < c) (h2 : b < c) : a * b < c := (mul_le_mul' (le_max_left a b) (le_max_right a b)).trans_lt <| (lt_or_le (max a b) ℵ₀).elim (fun h => (mul_lt_aleph0 h h).trans_le hc) fun h => by rw [mul_eq_self h] exact max_lt h1 h2 #align cardinal.mul_lt_of_lt Cardinal.mul_lt_of_lt theorem mul_le_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) : a * b ≤ max a b := by convert mul_le_mul' (le_max_left a b) (le_max_right a b) using 1 rw [mul_eq_self] exact h.trans (le_max_left a b) #align cardinal.mul_le_max_of_aleph_0_le_left Cardinal.mul_le_max_of_aleph0_le_left theorem mul_eq_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) (h' : b ≠ 0) : a * b = max a b := by rcases le_or_lt ℵ₀ b with hb | hb · exact mul_eq_max h hb refine (mul_le_max_of_aleph0_le_left h).antisymm ?_ have : b ≤ a := hb.le.trans h rw [max_eq_left this] convert mul_le_mul_left' (one_le_iff_ne_zero.mpr h') a rw [mul_one] #align cardinal.mul_eq_max_of_aleph_0_le_left Cardinal.mul_eq_max_of_aleph0_le_left theorem mul_le_max_of_aleph0_le_right {a b : Cardinal} (h : ℵ₀ ≤ b) : a * b ≤ max a b := by simpa only [mul_comm b, max_comm b] using mul_le_max_of_aleph0_le_left h #align cardinal.mul_le_max_of_aleph_0_le_right Cardinal.mul_le_max_of_aleph0_le_right theorem mul_eq_max_of_aleph0_le_right {a b : Cardinal} (h' : a ≠ 0) (h : ℵ₀ ≤ b) : a * b = max a b := by rw [mul_comm, max_comm] exact mul_eq_max_of_aleph0_le_left h h' #align cardinal.mul_eq_max_of_aleph_0_le_right Cardinal.mul_eq_max_of_aleph0_le_right theorem mul_eq_max' {a b : Cardinal} (h : ℵ₀ ≤ a * b) : a * b = max a b := by rcases aleph0_le_mul_iff.mp h with ⟨ha, hb, ha' | hb'⟩ · exact mul_eq_max_of_aleph0_le_left ha' hb · exact mul_eq_max_of_aleph0_le_right ha hb' #align cardinal.mul_eq_max' Cardinal.mul_eq_max' theorem mul_le_max (a b : Cardinal) : a * b ≤ max (max a b) ℵ₀ := by rcases eq_or_ne a 0 with (rfl | ha0); · simp rcases eq_or_ne b 0 with (rfl | hb0); · simp rcases le_or_lt ℵ₀ a with ha | ha · rw [mul_eq_max_of_aleph0_le_left ha hb0] exact le_max_left _ _ · rcases le_or_lt ℵ₀ b with hb | hb · rw [mul_comm, mul_eq_max_of_aleph0_le_left hb ha0, max_comm] exact le_max_left _ _ · exact le_max_of_le_right (mul_lt_aleph0 ha hb).le #align cardinal.mul_le_max Cardinal.mul_le_max theorem mul_eq_left {a b : Cardinal} (ha : ℵ₀ ≤ a) (hb : b ≤ a) (hb' : b ≠ 0) : a * b = a := by rw [mul_eq_max_of_aleph0_le_left ha hb', max_eq_left hb] #align cardinal.mul_eq_left Cardinal.mul_eq_left theorem mul_eq_right {a b : Cardinal} (hb : ℵ₀ ≤ b) (ha : a ≤ b) (ha' : a ≠ 0) : a * b = b := by rw [mul_comm, mul_eq_left hb ha ha'] #align cardinal.mul_eq_right Cardinal.mul_eq_right theorem le_mul_left {a b : Cardinal} (h : b ≠ 0) : a ≤ b * a := by convert mul_le_mul_right' (one_le_iff_ne_zero.mpr h) a rw [one_mul] #align cardinal.le_mul_left Cardinal.le_mul_left theorem le_mul_right {a b : Cardinal} (h : b ≠ 0) : a ≤ a * b := by rw [mul_comm] exact le_mul_left h #align cardinal.le_mul_right Cardinal.le_mul_right theorem mul_eq_left_iff {a b : Cardinal} : a * b = a ↔ max ℵ₀ b ≤ a ∧ b ≠ 0 ∨ b = 1 ∨ a = 0 := by rw [max_le_iff] refine ⟨fun h => ?_, ?_⟩ · rcases le_or_lt ℵ₀ a with ha | ha · have : a ≠ 0 := by rintro rfl exact ha.not_lt aleph0_pos left rw [and_assoc] use ha constructor · rw [← not_lt] exact fun hb => ne_of_gt (hb.trans_le (le_mul_left this)) h · rintro rfl apply this rw [mul_zero] at h exact h.symm right by_cases h2a : a = 0 · exact Or.inr h2a have hb : b ≠ 0 := by rintro rfl apply h2a rw [mul_zero] at h exact h.symm left rw [← h, mul_lt_aleph0_iff, lt_aleph0, lt_aleph0] at ha rcases ha with (rfl | rfl | ⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩) · contradiction · contradiction rw [← Ne] at h2a rw [← one_le_iff_ne_zero] at h2a hb norm_cast at h2a hb h ⊢ apply le_antisymm _ hb rw [← not_lt] apply fun h2b => ne_of_gt _ h conv_rhs => left; rw [← mul_one n] rw [mul_lt_mul_left] · exact id apply Nat.lt_of_succ_le h2a · rintro (⟨⟨ha, hab⟩, hb⟩ | rfl | rfl) · rw [mul_eq_max_of_aleph0_le_left ha hb, max_eq_left hab] all_goals simp #align cardinal.mul_eq_left_iff Cardinal.mul_eq_left_iff end mul /-! ### Properties of `add` -/ section add /-- If `α` is an infinite type, then `α ⊕ α` and `α` have the same cardinality. -/ theorem add_eq_self {c : Cardinal} (h : ℵ₀ ≤ c) : c + c = c := le_antisymm (by convert mul_le_mul_right' ((nat_lt_aleph0 2).le.trans h) c using 1 <;> simp [two_mul, mul_eq_self h]) (self_le_add_left c c) #align cardinal.add_eq_self Cardinal.add_eq_self /-- If `α` is an infinite type, then the cardinality of `α ⊕ β` is the maximum of the cardinalities of `α` and `β`. -/ theorem add_eq_max {a b : Cardinal} (ha : ℵ₀ ≤ a) : a + b = max a b := le_antisymm (add_eq_self (ha.trans (le_max_left a b)) ▸ add_le_add (le_max_left _ _) (le_max_right _ _)) <| max_le (self_le_add_right _ _) (self_le_add_left _ _) #align cardinal.add_eq_max Cardinal.add_eq_max theorem add_eq_max' {a b : Cardinal} (ha : ℵ₀ ≤ b) : a + b = max a b := by rw [add_comm, max_comm, add_eq_max ha] #align cardinal.add_eq_max' Cardinal.add_eq_max' @[simp] theorem add_mk_eq_max {α β : Type u} [Infinite α] : #α + #β = max #α #β := add_eq_max (aleph0_le_mk α) #align cardinal.add_mk_eq_max Cardinal.add_mk_eq_max @[simp] theorem add_mk_eq_max' {α β : Type u} [Infinite β] : #α + #β = max #α #β := add_eq_max' (aleph0_le_mk β) #align cardinal.add_mk_eq_max' Cardinal.add_mk_eq_max' theorem add_le_max (a b : Cardinal) : a + b ≤ max (max a b) ℵ₀ := by rcases le_or_lt ℵ₀ a with ha | ha · rw [add_eq_max ha] exact le_max_left _ _ · rcases le_or_lt ℵ₀ b with hb | hb · rw [add_comm, add_eq_max hb, max_comm] exact le_max_left _ _ · exact le_max_of_le_right (add_lt_aleph0 ha hb).le #align cardinal.add_le_max Cardinal.add_le_max theorem add_le_of_le {a b c : Cardinal} (hc : ℵ₀ ≤ c) (h1 : a ≤ c) (h2 : b ≤ c) : a + b ≤ c := (add_le_add h1 h2).trans <| le_of_eq <| add_eq_self hc #align cardinal.add_le_of_le Cardinal.add_le_of_le theorem add_lt_of_lt {a b c : Cardinal} (hc : ℵ₀ ≤ c) (h1 : a < c) (h2 : b < c) : a + b < c := (add_le_add (le_max_left a b) (le_max_right a b)).trans_lt <| (lt_or_le (max a b) ℵ₀).elim (fun h => (add_lt_aleph0 h h).trans_le hc) fun h => by rw [add_eq_self h]; exact max_lt h1 h2 #align cardinal.add_lt_of_lt Cardinal.add_lt_of_lt theorem eq_of_add_eq_of_aleph0_le {a b c : Cardinal} (h : a + b = c) (ha : a < c) (hc : ℵ₀ ≤ c) : b = c := by apply le_antisymm · rw [← h] apply self_le_add_left rw [← not_lt]; intro hb have : a + b < c := add_lt_of_lt hc ha hb simp [h, lt_irrefl] at this #align cardinal.eq_of_add_eq_of_aleph_0_le Cardinal.eq_of_add_eq_of_aleph0_le theorem add_eq_left {a b : Cardinal} (ha : ℵ₀ ≤ a) (hb : b ≤ a) : a + b = a := by rw [add_eq_max ha, max_eq_left hb] #align cardinal.add_eq_left Cardinal.add_eq_left theorem add_eq_right {a b : Cardinal} (hb : ℵ₀ ≤ b) (ha : a ≤ b) : a + b = b := by rw [add_comm, add_eq_left hb ha] #align cardinal.add_eq_right Cardinal.add_eq_right theorem add_eq_left_iff {a b : Cardinal} : a + b = a ↔ max ℵ₀ b ≤ a ∨ b = 0 := by rw [max_le_iff] refine ⟨fun h => ?_, ?_⟩ · rcases le_or_lt ℵ₀ a with ha | ha · left use ha rw [← not_lt] apply fun hb => ne_of_gt _ h intro hb exact hb.trans_le (self_le_add_left b a) right rw [← h, add_lt_aleph0_iff, lt_aleph0, lt_aleph0] at ha rcases ha with ⟨⟨n, rfl⟩, ⟨m, rfl⟩⟩ norm_cast at h ⊢ rw [← add_right_inj, h, add_zero] · rintro (⟨h1, h2⟩ | h3) · rw [add_eq_max h1, max_eq_left h2] · rw [h3, add_zero] #align cardinal.add_eq_left_iff Cardinal.add_eq_left_iff theorem add_eq_right_iff {a b : Cardinal} : a + b = b ↔ max ℵ₀ a ≤ b ∨ a = 0 := by rw [add_comm, add_eq_left_iff] #align cardinal.add_eq_right_iff Cardinal.add_eq_right_iff theorem add_nat_eq {a : Cardinal} (n : ℕ) (ha : ℵ₀ ≤ a) : a + n = a := add_eq_left ha ((nat_lt_aleph0 _).le.trans ha) #align cardinal.add_nat_eq Cardinal.add_nat_eq theorem nat_add_eq {a : Cardinal} (n : ℕ) (ha : ℵ₀ ≤ a) : n + a = a := by rw [add_comm, add_nat_eq n ha] theorem add_one_eq {a : Cardinal} (ha : ℵ₀ ≤ a) : a + 1 = a := add_one_of_aleph0_le ha #align cardinal.add_one_eq Cardinal.add_one_eq -- Porting note (#10618): removed `simp`, `simp` can prove it theorem mk_add_one_eq {α : Type*} [Infinite α] : #α + 1 = #α := add_one_eq (aleph0_le_mk α) #align cardinal.mk_add_one_eq Cardinal.mk_add_one_eq protected theorem eq_of_add_eq_add_left {a b c : Cardinal} (h : a + b = a + c) (ha : a < ℵ₀) : b = c := by rcases le_or_lt ℵ₀ b with hb | hb · have : a < b := ha.trans_le hb rw [add_eq_right hb this.le, eq_comm] at h rw [eq_of_add_eq_of_aleph0_le h this hb] · have hc : c < ℵ₀ := by rw [← not_le] intro hc apply lt_irrefl ℵ₀ apply (hc.trans (self_le_add_left _ a)).trans_lt rw [← h] apply add_lt_aleph0 ha hb rw [lt_aleph0] at * rcases ha with ⟨n, rfl⟩ rcases hb with ⟨m, rfl⟩ rcases hc with ⟨k, rfl⟩ norm_cast at h ⊢ apply add_left_cancel h #align cardinal.eq_of_add_eq_add_left Cardinal.eq_of_add_eq_add_left protected theorem eq_of_add_eq_add_right {a b c : Cardinal} (h : a + b = c + b) (hb : b < ℵ₀) : a = c := by rw [add_comm a b, add_comm c b] at h exact Cardinal.eq_of_add_eq_add_left h hb #align cardinal.eq_of_add_eq_add_right Cardinal.eq_of_add_eq_add_right end add section ciSup variable {ι : Type u} {ι' : Type w} (f : ι → Cardinal.{v}) section add variable [Nonempty ι] [Nonempty ι'] (hf : BddAbove (range f)) protected theorem ciSup_add (c : Cardinal.{v}) : (⨆ i, f i) + c = ⨆ i, f i + c := by have : ∀ i, f i + c ≤ (⨆ i, f i) + c := fun i ↦ add_le_add_right (le_ciSup hf i) c refine le_antisymm ?_ (ciSup_le' this) have bdd : BddAbove (range (f · + c)) := ⟨_, forall_mem_range.mpr this⟩ obtain hs | hs := lt_or_le (⨆ i, f i) ℵ₀ · obtain ⟨i, hi⟩ := exists_eq_of_iSup_eq_of_not_isLimit f hf _ (fun h ↦ hs.not_le h.aleph0_le) rfl exact hi ▸ le_ciSup bdd i rw [add_eq_max hs, max_le_iff] exact ⟨ciSup_mono bdd fun i ↦ self_le_add_right _ c, (self_le_add_left _ _).trans (le_ciSup bdd <| Classical.arbitrary ι)⟩ protected theorem add_ciSup (c : Cardinal.{v}) : c + (⨆ i, f i) = ⨆ i, c + f i := by rw [add_comm, Cardinal.ciSup_add f hf]; simp_rw [add_comm] protected theorem ciSup_add_ciSup (g : ι' → Cardinal.{v}) (hg : BddAbove (range g)) : (⨆ i, f i) + (⨆ j, g j) = ⨆ (i) (j), f i + g j := by simp_rw [Cardinal.ciSup_add f hf, Cardinal.add_ciSup g hg] end add protected theorem ciSup_mul (c : Cardinal.{v}) : (⨆ i, f i) * c = ⨆ i, f i * c := by cases isEmpty_or_nonempty ι; · simp obtain rfl | h0 := eq_or_ne c 0; · simp by_cases hf : BddAbove (range f); swap · have hfc : ¬ BddAbove (range (f · * c)) := fun bdd ↦ hf ⟨⨆ i, f i * c, forall_mem_range.mpr fun i ↦ (le_mul_right h0).trans (le_ciSup bdd i)⟩ simp [iSup, csSup_of_not_bddAbove, hf, hfc] have : ∀ i, f i * c ≤ (⨆ i, f i) * c := fun i ↦ mul_le_mul_right' (le_ciSup hf i) c refine le_antisymm ?_ (ciSup_le' this) have bdd : BddAbove (range (f · * c)) := ⟨_, forall_mem_range.mpr this⟩ obtain hs | hs := lt_or_le (⨆ i, f i) ℵ₀ · obtain ⟨i, hi⟩ := exists_eq_of_iSup_eq_of_not_isLimit f hf _ (fun h ↦ hs.not_le h.aleph0_le) rfl exact hi ▸ le_ciSup bdd i rw [mul_eq_max_of_aleph0_le_left hs h0, max_le_iff] obtain ⟨i, hi⟩ := exists_lt_of_lt_ciSup' (one_lt_aleph0.trans_le hs) exact ⟨ciSup_mono bdd fun i ↦ le_mul_right h0, (le_mul_left (zero_lt_one.trans hi).ne').trans (le_ciSup bdd i)⟩ protected theorem mul_ciSup (c : Cardinal.{v}) : c * (⨆ i, f i) = ⨆ i, c * f i := by rw [mul_comm, Cardinal.ciSup_mul f]; simp_rw [mul_comm] protected theorem ciSup_mul_ciSup (g : ι' → Cardinal.{v}) : (⨆ i, f i) * (⨆ j, g j) = ⨆ (i) (j), f i * g j := by simp_rw [Cardinal.ciSup_mul f, Cardinal.mul_ciSup g] end ciSup @[simp] theorem aleph_add_aleph (o₁ o₂ : Ordinal) : aleph o₁ + aleph o₂ = aleph (max o₁ o₂) := by rw [Cardinal.add_eq_max (aleph0_le_aleph o₁), max_aleph_eq] #align cardinal.aleph_add_aleph Cardinal.aleph_add_aleph theorem principal_add_ord {c : Cardinal} (hc : ℵ₀ ≤ c) : Ordinal.Principal (· + ·) c.ord := fun a b ha hb => by rw [lt_ord, Ordinal.card_add] at * exact add_lt_of_lt hc ha hb #align cardinal.principal_add_ord Cardinal.principal_add_ord theorem principal_add_aleph (o : Ordinal) : Ordinal.Principal (· + ·) (aleph o).ord := principal_add_ord <| aleph0_le_aleph o #align cardinal.principal_add_aleph Cardinal.principal_add_aleph theorem add_right_inj_of_lt_aleph0 {α β γ : Cardinal} (γ₀ : γ < aleph0) : α + γ = β + γ ↔ α = β := ⟨fun h => Cardinal.eq_of_add_eq_add_right h γ₀, fun h => congr_arg (· + γ) h⟩ #align cardinal.add_right_inj_of_lt_aleph_0 Cardinal.add_right_inj_of_lt_aleph0 @[simp] theorem add_nat_inj {α β : Cardinal} (n : ℕ) : α + n = β + n ↔ α = β := add_right_inj_of_lt_aleph0 (nat_lt_aleph0 _) #align cardinal.add_nat_inj Cardinal.add_nat_inj @[simp] theorem add_one_inj {α β : Cardinal} : α + 1 = β + 1 ↔ α = β := add_right_inj_of_lt_aleph0 one_lt_aleph0 #align cardinal.add_one_inj Cardinal.add_one_inj theorem add_le_add_iff_of_lt_aleph0 {α β γ : Cardinal} (γ₀ : γ < Cardinal.aleph0) : α + γ ≤ β + γ ↔ α ≤ β := by refine ⟨fun h => ?_, fun h => add_le_add_right h γ⟩ contrapose h rw [not_le, lt_iff_le_and_ne, Ne] at h ⊢ exact ⟨add_le_add_right h.1 γ, mt (add_right_inj_of_lt_aleph0 γ₀).1 h.2⟩ #align cardinal.add_le_add_iff_of_lt_aleph_0 Cardinal.add_le_add_iff_of_lt_aleph0 @[simp] theorem add_nat_le_add_nat_iff {α β : Cardinal} (n : ℕ) : α + n ≤ β + n ↔ α ≤ β := add_le_add_iff_of_lt_aleph0 (nat_lt_aleph0 n) #align cardinal.add_nat_le_add_nat_iff_of_lt_aleph_0 Cardinal.add_nat_le_add_nat_iff @[deprecated (since := "2024-02-12")] alias add_nat_le_add_nat_iff_of_lt_aleph_0 := add_nat_le_add_nat_iff @[simp] theorem add_one_le_add_one_iff {α β : Cardinal} : α + 1 ≤ β + 1 ↔ α ≤ β := add_le_add_iff_of_lt_aleph0 one_lt_aleph0 #align cardinal.add_one_le_add_one_iff_of_lt_aleph_0 Cardinal.add_one_le_add_one_iff @[deprecated (since := "2024-02-12")] alias add_one_le_add_one_iff_of_lt_aleph_0 := add_one_le_add_one_iff /-! ### Properties about power -/ section pow theorem pow_le {κ μ : Cardinal.{u}} (H1 : ℵ₀ ≤ κ) (H2 : μ < ℵ₀) : κ ^ μ ≤ κ := let ⟨n, H3⟩ := lt_aleph0.1 H2 H3.symm ▸ Quotient.inductionOn κ (fun α H1 => Nat.recOn n (lt_of_lt_of_le (by rw [Nat.cast_zero, power_zero] exact one_lt_aleph0) H1).le fun n ih => le_of_le_of_eq (by rw [Nat.cast_succ, power_add, power_one] exact mul_le_mul_right' ih _) (mul_eq_self H1)) H1 #align cardinal.pow_le Cardinal.pow_le theorem pow_eq {κ μ : Cardinal.{u}} (H1 : ℵ₀ ≤ κ) (H2 : 1 ≤ μ) (H3 : μ < ℵ₀) : κ ^ μ = κ := (pow_le H1 H3).antisymm <| self_le_power κ H2 #align cardinal.pow_eq Cardinal.pow_eq theorem power_self_eq {c : Cardinal} (h : ℵ₀ ≤ c) : c ^ c = 2 ^ c := by apply ((power_le_power_right <| (cantor c).le).trans _).antisymm · exact power_le_power_right ((nat_lt_aleph0 2).le.trans h) · rw [← power_mul, mul_eq_self h] #align cardinal.power_self_eq Cardinal.power_self_eq theorem prod_eq_two_power {ι : Type u} [Infinite ι] {c : ι → Cardinal.{v}} (h₁ : ∀ i, 2 ≤ c i) (h₂ : ∀ i, lift.{u} (c i) ≤ lift.{v} #ι) : prod c = 2 ^ lift.{v} #ι := by rw [← lift_id'.{u, v} (prod.{u, v} c), lift_prod, ← lift_two_power] apply le_antisymm · refine (prod_le_prod _ _ h₂).trans_eq ?_ rw [prod_const, lift_lift, ← lift_power, power_self_eq (aleph0_le_mk ι), lift_umax.{u, v}] · rw [← prod_const', lift_prod] refine prod_le_prod _ _ fun i => ?_ rw [lift_two, ← lift_two.{u, v}, lift_le] exact h₁ i #align cardinal.prod_eq_two_power Cardinal.prod_eq_two_power theorem power_eq_two_power {c₁ c₂ : Cardinal} (h₁ : ℵ₀ ≤ c₁) (h₂ : 2 ≤ c₂) (h₂' : c₂ ≤ c₁) : c₂ ^ c₁ = 2 ^ c₁ := le_antisymm (power_self_eq h₁ ▸ power_le_power_right h₂') (power_le_power_right h₂) #align cardinal.power_eq_two_power Cardinal.power_eq_two_power theorem nat_power_eq {c : Cardinal.{u}} (h : ℵ₀ ≤ c) {n : ℕ} (hn : 2 ≤ n) : (n : Cardinal.{u}) ^ c = 2 ^ c := power_eq_two_power h (by assumption_mod_cast) ((nat_lt_aleph0 n).le.trans h) #align cardinal.nat_power_eq Cardinal.nat_power_eq theorem power_nat_le {c : Cardinal.{u}} {n : ℕ} (h : ℵ₀ ≤ c) : c ^ n ≤ c := pow_le h (nat_lt_aleph0 n) #align cardinal.power_nat_le Cardinal.power_nat_le theorem power_nat_eq {c : Cardinal.{u}} {n : ℕ} (h1 : ℵ₀ ≤ c) (h2 : 1 ≤ n) : c ^ n = c := pow_eq h1 (mod_cast h2) (nat_lt_aleph0 n) #align cardinal.power_nat_eq Cardinal.power_nat_eq theorem power_nat_le_max {c : Cardinal.{u}} {n : ℕ} : c ^ (n : Cardinal.{u}) ≤ max c ℵ₀ := by rcases le_or_lt ℵ₀ c with hc | hc · exact le_max_of_le_left (power_nat_le hc) · exact le_max_of_le_right (power_lt_aleph0 hc (nat_lt_aleph0 _)).le #align cardinal.power_nat_le_max Cardinal.power_nat_le_max theorem powerlt_aleph0 {c : Cardinal} (h : ℵ₀ ≤ c) : c ^< ℵ₀ = c := by apply le_antisymm · rw [powerlt_le] intro c' rw [lt_aleph0] rintro ⟨n, rfl⟩ apply power_nat_le h convert le_powerlt c one_lt_aleph0; rw [power_one] #align cardinal.powerlt_aleph_0 Cardinal.powerlt_aleph0 theorem powerlt_aleph0_le (c : Cardinal) : c ^< ℵ₀ ≤ max c ℵ₀ := by rcases le_or_lt ℵ₀ c with h | h · rw [powerlt_aleph0 h] apply le_max_left rw [powerlt_le] exact fun c' hc' => (power_lt_aleph0 h hc').le.trans (le_max_right _ _) #align cardinal.powerlt_aleph_0_le Cardinal.powerlt_aleph0_le end pow /-! ### Computing cardinality of various types -/ section computing section Function variable {α β : Type u} {β' : Type v} theorem mk_equiv_eq_zero_iff_lift_ne : #(α ≃ β') = 0 ↔ lift.{v} #α ≠ lift.{u} #β' := by rw [mk_eq_zero_iff, ← not_nonempty_iff, ← lift_mk_eq'] theorem mk_equiv_eq_zero_iff_ne : #(α ≃ β) = 0 ↔ #α ≠ #β := by rw [mk_equiv_eq_zero_iff_lift_ne, lift_id, lift_id] /-- This lemma makes lemmas assuming `Infinite α` applicable to the situation where we have `Infinite β` instead. -/ theorem mk_equiv_comm : #(α ≃ β') = #(β' ≃ α) := (ofBijective _ symm_bijective).cardinal_eq theorem mk_embedding_eq_zero_iff_lift_lt : #(α ↪ β') = 0 ↔ lift.{u} #β' < lift.{v} #α := by rw [mk_eq_zero_iff, ← not_nonempty_iff, ← lift_mk_le', not_le] theorem mk_embedding_eq_zero_iff_lt : #(α ↪ β) = 0 ↔ #β < #α := by rw [mk_embedding_eq_zero_iff_lift_lt, lift_lt] theorem mk_arrow_eq_zero_iff : #(α → β') = 0 ↔ #α ≠ 0 ∧ #β' = 0 := by simp_rw [mk_eq_zero_iff, mk_ne_zero_iff, isEmpty_fun] theorem mk_surjective_eq_zero_iff_lift : #{f : α → β' | Surjective f} = 0 ↔ lift.{v} #α < lift.{u} #β' ∨ (#α ≠ 0 ∧ #β' = 0) := by rw [← not_iff_not, not_or, not_lt, lift_mk_le', ← Ne, not_and_or, not_ne_iff, and_comm] simp_rw [mk_ne_zero_iff, mk_eq_zero_iff, nonempty_coe_sort, Set.Nonempty, mem_setOf, exists_surjective_iff, nonempty_fun] theorem mk_surjective_eq_zero_iff : #{f : α → β | Surjective f} = 0 ↔ #α < #β ∨ (#α ≠ 0 ∧ #β = 0) := by rw [mk_surjective_eq_zero_iff_lift, lift_lt] variable (α β') theorem mk_equiv_le_embedding : #(α ≃ β') ≤ #(α ↪ β') := ⟨⟨_, Equiv.toEmbedding_injective⟩⟩ theorem mk_embedding_le_arrow : #(α ↪ β') ≤ #(α → β') := ⟨⟨_, DFunLike.coe_injective⟩⟩ variable [Infinite α] {α β'} theorem mk_perm_eq_self_power : #(Equiv.Perm α) = #α ^ #α := ((mk_equiv_le_embedding α α).trans (mk_embedding_le_arrow α α)).antisymm <| by suffices Nonempty ((α → Bool) ↪ Equiv.Perm (α × Bool)) by obtain ⟨e⟩ : Nonempty (α ≃ α × Bool) := by erw [← Cardinal.eq, mk_prod, lift_uzero, mk_bool, lift_natCast, mul_two, add_eq_self (aleph0_le_mk α)] erw [← le_def, mk_arrow, lift_uzero, mk_bool, lift_natCast 2] at this rwa [← power_def, power_self_eq (aleph0_le_mk α), e.permCongr.cardinal_eq] refine ⟨⟨fun f ↦ Involutive.toPerm (fun x ↦ ⟨x.1, xor (f x.1) x.2⟩) fun x ↦ ?_, fun f g h ↦ ?_⟩⟩ · simp_rw [← Bool.xor_assoc, Bool.xor_self, Bool.false_xor] · ext a; rw [← (f a).xor_false, ← (g a).xor_false]; exact congr(($h ⟨a, false⟩).2) theorem mk_perm_eq_two_power : #(Equiv.Perm α) = 2 ^ #α := by rw [mk_perm_eq_self_power, power_self_eq (aleph0_le_mk α)] variable (leq : lift.{v} #α = lift.{u} #β') (eq : #α = #β) theorem mk_equiv_eq_arrow_of_lift_eq : #(α ≃ β') = #(α → β') := by obtain ⟨e⟩ := lift_mk_eq'.mp leq have e₁ := lift_mk_eq'.mpr ⟨.equivCongr (.refl α) e⟩ have e₂ := lift_mk_eq'.mpr ⟨.arrowCongr (.refl α) e⟩ rw [lift_id'.{u,v}] at e₁ e₂ rw [← e₁, ← e₂, lift_inj, mk_perm_eq_self_power, power_def] theorem mk_equiv_eq_arrow_of_eq : #(α ≃ β) = #(α → β) := mk_equiv_eq_arrow_of_lift_eq congr(lift $eq) theorem mk_equiv_of_lift_eq : #(α ≃ β') = 2 ^ lift.{v} #α := by erw [← (lift_mk_eq'.2 ⟨.equivCongr (.refl α) (lift_mk_eq'.1 leq).some⟩).trans (lift_id'.{u,v} _), lift_umax.{u,v}, mk_perm_eq_two_power, lift_power, lift_natCast]; rfl
Mathlib/SetTheory/Cardinal/Ordinal.lean
1,137
1,137
theorem mk_equiv_of_eq : #(α ≃ β) = 2 ^ #α := by
rw [mk_equiv_of_lift_eq (lift_inj.mpr eq), lift_id]
/- Copyright (c) 2021 Yakov Pechersky. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yakov Pechersky, Chris Hughes -/ import Mathlib.Data.List.Nodup #align_import data.list.duplicate from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e" /-! # List duplicates ## Main definitions * `List.Duplicate x l : Prop` is an inductive property that holds when `x` is a duplicate in `l` ## Implementation details In this file, `x ∈+ l` notation is shorthand for `List.Duplicate x l`. -/ variable {α : Type*} namespace List /-- Property that an element `x : α` of `l : List α` can be found in the list more than once. -/ inductive Duplicate (x : α) : List α → Prop | cons_mem {l : List α} : x ∈ l → Duplicate x (x :: l) | cons_duplicate {y : α} {l : List α} : Duplicate x l → Duplicate x (y :: l) #align list.duplicate List.Duplicate local infixl:50 " ∈+ " => List.Duplicate variable {l : List α} {x : α} theorem Mem.duplicate_cons_self (h : x ∈ l) : x ∈+ x :: l := Duplicate.cons_mem h #align list.mem.duplicate_cons_self List.Mem.duplicate_cons_self theorem Duplicate.duplicate_cons (h : x ∈+ l) (y : α) : x ∈+ y :: l := Duplicate.cons_duplicate h #align list.duplicate.duplicate_cons List.Duplicate.duplicate_cons
Mathlib/Data/List/Duplicate.lean
46
49
theorem Duplicate.mem (h : x ∈+ l) : x ∈ l := by
induction' h with l' _ y l' _ hm · exact mem_cons_self _ _ · exact mem_cons_of_mem _ hm
/- Copyright (c) 2021 Yury Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury Kudryashov -/ import Mathlib.Analysis.Calculus.ContDiff.RCLike import Mathlib.MeasureTheory.Measure.Hausdorff #align_import topology.metric_space.hausdorff_dimension from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92" /-! # Hausdorff dimension The Hausdorff dimension of a set `X` in an (extended) metric space is the unique number `dimH s : ℝ≥0∞` such that for any `d : ℝ≥0` we have - `μH[d] s = 0` if `dimH s < d`, and - `μH[d] s = ∞` if `d < dimH s`. In this file we define `dimH s` to be the Hausdorff dimension of `s`, then prove some basic properties of Hausdorff dimension. ## Main definitions * `MeasureTheory.dimH`: the Hausdorff dimension of a set. For the Hausdorff dimension of the whole space we use `MeasureTheory.dimH (Set.univ : Set X)`. ## Main results ### Basic properties of Hausdorff dimension * `hausdorffMeasure_of_lt_dimH`, `dimH_le_of_hausdorffMeasure_ne_top`, `le_dimH_of_hausdorffMeasure_eq_top`, `hausdorffMeasure_of_dimH_lt`, `measure_zero_of_dimH_lt`, `le_dimH_of_hausdorffMeasure_ne_zero`, `dimH_of_hausdorffMeasure_ne_zero_ne_top`: various forms of the characteristic property of the Hausdorff dimension; * `dimH_union`: the Hausdorff dimension of the union of two sets is the maximum of their Hausdorff dimensions. * `dimH_iUnion`, `dimH_bUnion`, `dimH_sUnion`: the Hausdorff dimension of a countable union of sets is the supremum of their Hausdorff dimensions; * `dimH_empty`, `dimH_singleton`, `Set.Subsingleton.dimH_zero`, `Set.Countable.dimH_zero` : `dimH s = 0` whenever `s` is countable; ### (Pre)images under (anti)lipschitz and Hölder continuous maps * `HolderWith.dimH_image_le` etc: if `f : X → Y` is Hölder continuous with exponent `r > 0`, then for any `s`, `dimH (f '' s) ≤ dimH s / r`. We prove versions of this statement for `HolderWith`, `HolderOnWith`, and locally Hölder maps, as well as for `Set.image` and `Set.range`. * `LipschitzWith.dimH_image_le` etc: Lipschitz continuous maps do not increase the Hausdorff dimension of sets. * for a map that is known to be both Lipschitz and antilipschitz (e.g., for an `Isometry` or a `ContinuousLinearEquiv`) we also prove `dimH (f '' s) = dimH s`. ### Hausdorff measure in `ℝⁿ` * `Real.dimH_of_nonempty_interior`: if `s` is a set in a finite dimensional real vector space `E` with nonempty interior, then the Hausdorff dimension of `s` is equal to the dimension of `E`. * `dense_compl_of_dimH_lt_finrank`: if `s` is a set in a finite dimensional real vector space `E` with Hausdorff dimension strictly less than the dimension of `E`, the `s` has a dense complement. * `ContDiff.dense_compl_range_of_finrank_lt_finrank`: the complement to the range of a `C¹` smooth map is dense provided that the dimension of the domain is strictly less than the dimension of the codomain. ## Notations We use the following notation localized in `MeasureTheory`. It is defined in `MeasureTheory.Measure.Hausdorff`. - `μH[d]` : `MeasureTheory.Measure.hausdorffMeasure d` ## Implementation notes * The definition of `dimH` explicitly uses `borel X` as a measurable space structure. This way we can formulate lemmas about Hausdorff dimension without assuming that the environment has a `[MeasurableSpace X]` instance that is equal but possibly not defeq to `borel X`. Lemma `dimH_def` unfolds this definition using whatever `[MeasurableSpace X]` instance we have in the environment (as long as it is equal to `borel X`). * The definition `dimH` is irreducible; use API lemmas or `dimH_def` instead. ## Tags Hausdorff measure, Hausdorff dimension, dimension -/ open scoped MeasureTheory ENNReal NNReal Topology open MeasureTheory MeasureTheory.Measure Set TopologicalSpace FiniteDimensional Filter variable {ι X Y : Type*} [EMetricSpace X] [EMetricSpace Y] /-- Hausdorff dimension of a set in an (e)metric space. -/ @[irreducible] noncomputable def dimH (s : Set X) : ℝ≥0∞ := by borelize X; exact ⨆ (d : ℝ≥0) (_ : @hausdorffMeasure X _ _ ⟨rfl⟩ d s = ∞), d set_option linter.uppercaseLean3 false in #align dimH dimH /-! ### Basic properties -/ section Measurable variable [MeasurableSpace X] [BorelSpace X] /-- Unfold the definition of `dimH` using `[MeasurableSpace X] [BorelSpace X]` from the environment. -/ theorem dimH_def (s : Set X) : dimH s = ⨆ (d : ℝ≥0) (_ : μH[d] s = ∞), (d : ℝ≥0∞) := by borelize X; rw [dimH] set_option linter.uppercaseLean3 false in #align dimH_def dimH_def theorem hausdorffMeasure_of_lt_dimH {s : Set X} {d : ℝ≥0} (h : ↑d < dimH s) : μH[d] s = ∞ := by simp only [dimH_def, lt_iSup_iff] at h rcases h with ⟨d', hsd', hdd'⟩ rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hdd' exact top_unique (hsd' ▸ hausdorffMeasure_mono hdd'.le _) set_option linter.uppercaseLean3 false in #align hausdorff_measure_of_lt_dimH hausdorffMeasure_of_lt_dimH theorem dimH_le {s : Set X} {d : ℝ≥0∞} (H : ∀ d' : ℝ≥0, μH[d'] s = ∞ → ↑d' ≤ d) : dimH s ≤ d := (dimH_def s).trans_le <| iSup₂_le H set_option linter.uppercaseLean3 false in #align dimH_le dimH_le theorem dimH_le_of_hausdorffMeasure_ne_top {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ ∞) : dimH s ≤ d := le_of_not_lt <| mt hausdorffMeasure_of_lt_dimH h set_option linter.uppercaseLean3 false in #align dimH_le_of_hausdorff_measure_ne_top dimH_le_of_hausdorffMeasure_ne_top theorem le_dimH_of_hausdorffMeasure_eq_top {s : Set X} {d : ℝ≥0} (h : μH[d] s = ∞) : ↑d ≤ dimH s := by rw [dimH_def]; exact le_iSup₂ (α := ℝ≥0∞) d h set_option linter.uppercaseLean3 false in #align le_dimH_of_hausdorff_measure_eq_top le_dimH_of_hausdorffMeasure_eq_top theorem hausdorffMeasure_of_dimH_lt {s : Set X} {d : ℝ≥0} (h : dimH s < d) : μH[d] s = 0 := by rw [dimH_def] at h rcases ENNReal.lt_iff_exists_nnreal_btwn.1 h with ⟨d', hsd', hd'd⟩ rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at hd'd exact (hausdorffMeasure_zero_or_top hd'd s).resolve_right fun h₂ => hsd'.not_le <| le_iSup₂ (α := ℝ≥0∞) d' h₂ set_option linter.uppercaseLean3 false in #align hausdorff_measure_of_dimH_lt hausdorffMeasure_of_dimH_lt theorem measure_zero_of_dimH_lt {μ : Measure X} {d : ℝ≥0} (h : μ ≪ μH[d]) {s : Set X} (hd : dimH s < d) : μ s = 0 := h <| hausdorffMeasure_of_dimH_lt hd set_option linter.uppercaseLean3 false in #align measure_zero_of_dimH_lt measure_zero_of_dimH_lt theorem le_dimH_of_hausdorffMeasure_ne_zero {s : Set X} {d : ℝ≥0} (h : μH[d] s ≠ 0) : ↑d ≤ dimH s := le_of_not_lt <| mt hausdorffMeasure_of_dimH_lt h set_option linter.uppercaseLean3 false in #align le_dimH_of_hausdorff_measure_ne_zero le_dimH_of_hausdorffMeasure_ne_zero theorem dimH_of_hausdorffMeasure_ne_zero_ne_top {d : ℝ≥0} {s : Set X} (h : μH[d] s ≠ 0) (h' : μH[d] s ≠ ∞) : dimH s = d := le_antisymm (dimH_le_of_hausdorffMeasure_ne_top h') (le_dimH_of_hausdorffMeasure_ne_zero h) set_option linter.uppercaseLean3 false in #align dimH_of_hausdorff_measure_ne_zero_ne_top dimH_of_hausdorffMeasure_ne_zero_ne_top end Measurable @[mono] theorem dimH_mono {s t : Set X} (h : s ⊆ t) : dimH s ≤ dimH t := by borelize X exact dimH_le fun d hd => le_dimH_of_hausdorffMeasure_eq_top <| top_unique <| hd ▸ measure_mono h set_option linter.uppercaseLean3 false in #align dimH_mono dimH_mono theorem dimH_subsingleton {s : Set X} (h : s.Subsingleton) : dimH s = 0 := by borelize X apply le_antisymm _ (zero_le _) refine dimH_le_of_hausdorffMeasure_ne_top ?_ exact ((hausdorffMeasure_le_one_of_subsingleton h le_rfl).trans_lt ENNReal.one_lt_top).ne set_option linter.uppercaseLean3 false in #align dimH_subsingleton dimH_subsingleton alias Set.Subsingleton.dimH_zero := dimH_subsingleton set_option linter.uppercaseLean3 false in #align set.subsingleton.dimH_zero Set.Subsingleton.dimH_zero @[simp] theorem dimH_empty : dimH (∅ : Set X) = 0 := subsingleton_empty.dimH_zero set_option linter.uppercaseLean3 false in #align dimH_empty dimH_empty @[simp] theorem dimH_singleton (x : X) : dimH ({x} : Set X) = 0 := subsingleton_singleton.dimH_zero set_option linter.uppercaseLean3 false in #align dimH_singleton dimH_singleton @[simp] theorem dimH_iUnion {ι : Sort*} [Countable ι] (s : ι → Set X) : dimH (⋃ i, s i) = ⨆ i, dimH (s i) := by borelize X refine le_antisymm (dimH_le fun d hd => ?_) (iSup_le fun i => dimH_mono <| subset_iUnion _ _) contrapose! hd have : ∀ i, μH[d] (s i) = 0 := fun i => hausdorffMeasure_of_dimH_lt ((le_iSup (fun i => dimH (s i)) i).trans_lt hd) rw [measure_iUnion_null this] exact ENNReal.zero_ne_top set_option linter.uppercaseLean3 false in #align dimH_Union dimH_iUnion @[simp] theorem dimH_bUnion {s : Set ι} (hs : s.Countable) (t : ι → Set X) : dimH (⋃ i ∈ s, t i) = ⨆ i ∈ s, dimH (t i) := by haveI := hs.toEncodable rw [biUnion_eq_iUnion, dimH_iUnion, ← iSup_subtype''] set_option linter.uppercaseLean3 false in #align dimH_bUnion dimH_bUnion @[simp] theorem dimH_sUnion {S : Set (Set X)} (hS : S.Countable) : dimH (⋃₀ S) = ⨆ s ∈ S, dimH s := by rw [sUnion_eq_biUnion, dimH_bUnion hS] set_option linter.uppercaseLean3 false in #align dimH_sUnion dimH_sUnion @[simp] theorem dimH_union (s t : Set X) : dimH (s ∪ t) = max (dimH s) (dimH t) := by rw [union_eq_iUnion, dimH_iUnion, iSup_bool_eq, cond, cond, ENNReal.sup_eq_max] set_option linter.uppercaseLean3 false in #align dimH_union dimH_union theorem dimH_countable {s : Set X} (hs : s.Countable) : dimH s = 0 := biUnion_of_singleton s ▸ by simp only [dimH_bUnion hs, dimH_singleton, ENNReal.iSup_zero_eq_zero] set_option linter.uppercaseLean3 false in #align dimH_countable dimH_countable alias Set.Countable.dimH_zero := dimH_countable set_option linter.uppercaseLean3 false in #align set.countable.dimH_zero Set.Countable.dimH_zero theorem dimH_finite {s : Set X} (hs : s.Finite) : dimH s = 0 := hs.countable.dimH_zero set_option linter.uppercaseLean3 false in #align dimH_finite dimH_finite alias Set.Finite.dimH_zero := dimH_finite set_option linter.uppercaseLean3 false in #align set.finite.dimH_zero Set.Finite.dimH_zero @[simp] theorem dimH_coe_finset (s : Finset X) : dimH (s : Set X) = 0 := s.finite_toSet.dimH_zero set_option linter.uppercaseLean3 false in #align dimH_coe_finset dimH_coe_finset alias Finset.dimH_zero := dimH_coe_finset set_option linter.uppercaseLean3 false in #align finset.dimH_zero Finset.dimH_zero /-! ### Hausdorff dimension as the supremum of local Hausdorff dimensions -/ section variable [SecondCountableTopology X] /-- If `r` is less than the Hausdorff dimension of a set `s` in an (extended) metric space with second countable topology, then there exists a point `x ∈ s` such that every neighborhood `t` of `x` within `s` has Hausdorff dimension greater than `r`. -/ theorem exists_mem_nhdsWithin_lt_dimH_of_lt_dimH {s : Set X} {r : ℝ≥0∞} (h : r < dimH s) : ∃ x ∈ s, ∀ t ∈ 𝓝[s] x, r < dimH t := by contrapose! h; choose! t htx htr using h rcases countable_cover_nhdsWithin htx with ⟨S, hSs, hSc, hSU⟩ calc dimH s ≤ dimH (⋃ x ∈ S, t x) := dimH_mono hSU _ = ⨆ x ∈ S, dimH (t x) := dimH_bUnion hSc _ _ ≤ r := iSup₂_le fun x hx => htr x <| hSs hx set_option linter.uppercaseLean3 false in #align exists_mem_nhds_within_lt_dimH_of_lt_dimH exists_mem_nhdsWithin_lt_dimH_of_lt_dimH /-- In an (extended) metric space with second countable topology, the Hausdorff dimension of a set `s` is the supremum over `x ∈ s` of the limit superiors of `dimH t` along `(𝓝[s] x).smallSets`. -/ theorem bsupr_limsup_dimH (s : Set X) : ⨆ x ∈ s, limsup dimH (𝓝[s] x).smallSets = dimH s := by refine le_antisymm (iSup₂_le fun x _ => ?_) ?_ · refine limsup_le_of_le isCobounded_le_of_bot ?_ exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩ · refine le_of_forall_ge_of_dense fun r hr => ?_ rcases exists_mem_nhdsWithin_lt_dimH_of_lt_dimH hr with ⟨x, hxs, hxr⟩ refine le_iSup₂_of_le x hxs ?_; rw [limsup_eq]; refine le_sInf fun b hb => ?_ rcases eventually_smallSets.1 hb with ⟨t, htx, ht⟩ exact (hxr t htx).le.trans (ht t Subset.rfl) set_option linter.uppercaseLean3 false in #align bsupr_limsup_dimH bsupr_limsup_dimH /-- In an (extended) metric space with second countable topology, the Hausdorff dimension of a set `s` is the supremum over all `x` of the limit superiors of `dimH t` along `(𝓝[s] x).smallSets`. -/ theorem iSup_limsup_dimH (s : Set X) : ⨆ x, limsup dimH (𝓝[s] x).smallSets = dimH s := by refine le_antisymm (iSup_le fun x => ?_) ?_ · refine limsup_le_of_le isCobounded_le_of_bot ?_ exact eventually_smallSets.2 ⟨s, self_mem_nhdsWithin, fun t => dimH_mono⟩ · rw [← bsupr_limsup_dimH]; exact iSup₂_le_iSup _ _ set_option linter.uppercaseLean3 false in #align supr_limsup_dimH iSup_limsup_dimH end /-! ### Hausdorff dimension and Hölder continuity -/ variable {C K r : ℝ≥0} {f : X → Y} {s t : Set X} /-- If `f` is a Hölder continuous map with exponent `r > 0`, then `dimH (f '' s) ≤ dimH s / r`. -/ theorem HolderOnWith.dimH_image_le (h : HolderOnWith C r f s) (hr : 0 < r) : dimH (f '' s) ≤ dimH s / r := by borelize X Y refine dimH_le fun d hd => ?_ have := h.hausdorffMeasure_image_le hr d.coe_nonneg rw [hd, ENNReal.coe_rpow_of_nonneg _ d.coe_nonneg, top_le_iff] at this have Hrd : μH[(r * d : ℝ≥0)] s = ⊤ := by contrapose this exact ENNReal.mul_ne_top ENNReal.coe_ne_top this rw [ENNReal.le_div_iff_mul_le, mul_comm, ← ENNReal.coe_mul] exacts [le_dimH_of_hausdorffMeasure_eq_top Hrd, Or.inl (mt ENNReal.coe_eq_zero.1 hr.ne'), Or.inl ENNReal.coe_ne_top] set_option linter.uppercaseLean3 false in #align holder_on_with.dimH_image_le HolderOnWith.dimH_image_le namespace HolderWith /-- If `f : X → Y` is Hölder continuous with a positive exponent `r`, then the Hausdorff dimension of the image of a set `s` is at most `dimH s / r`. -/ theorem dimH_image_le (h : HolderWith C r f) (hr : 0 < r) (s : Set X) : dimH (f '' s) ≤ dimH s / r := (h.holderOnWith s).dimH_image_le hr set_option linter.uppercaseLean3 false in #align holder_with.dimH_image_le HolderWith.dimH_image_le /-- If `f` is a Hölder continuous map with exponent `r > 0`, then the Hausdorff dimension of its range is at most the Hausdorff dimension of its domain divided by `r`. -/ theorem dimH_range_le (h : HolderWith C r f) (hr : 0 < r) : dimH (range f) ≤ dimH (univ : Set X) / r := @image_univ _ _ f ▸ h.dimH_image_le hr univ set_option linter.uppercaseLean3 false in #align holder_with.dimH_range_le HolderWith.dimH_range_le end HolderWith /-- If `s` is a set in a space `X` with second countable topology and `f : X → Y` is Hölder continuous in a neighborhood within `s` of every point `x ∈ s` with the same positive exponent `r` but possibly different coefficients, then the Hausdorff dimension of the image `f '' s` is at most the Hausdorff dimension of `s` divided by `r`. -/ theorem dimH_image_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y} (hr : 0 < r) {s : Set X} (hf : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, HolderOnWith C r f t) : dimH (f '' s) ≤ dimH s / r := by choose! C t htn hC using hf rcases countable_cover_nhdsWithin htn with ⟨u, hus, huc, huU⟩ replace huU := inter_eq_self_of_subset_left huU; rw [inter_iUnion₂] at huU rw [← huU, image_iUnion₂, dimH_bUnion huc, dimH_bUnion huc]; simp only [ENNReal.iSup_div] exact iSup₂_mono fun x hx => ((hC x (hus hx)).mono inter_subset_right).dimH_image_le hr set_option linter.uppercaseLean3 false in #align dimH_image_le_of_locally_holder_on dimH_image_le_of_locally_holder_on /-- If `f : X → Y` is Hölder continuous in a neighborhood of every point `x : X` with the same positive exponent `r` but possibly different coefficients, then the Hausdorff dimension of the range of `f` is at most the Hausdorff dimension of `X` divided by `r`. -/ theorem dimH_range_le_of_locally_holder_on [SecondCountableTopology X] {r : ℝ≥0} {f : X → Y} (hr : 0 < r) (hf : ∀ x : X, ∃ C : ℝ≥0, ∃ s ∈ 𝓝 x, HolderOnWith C r f s) : dimH (range f) ≤ dimH (univ : Set X) / r := by rw [← image_univ] refine dimH_image_le_of_locally_holder_on hr fun x _ => ?_ simpa only [exists_prop, nhdsWithin_univ] using hf x set_option linter.uppercaseLean3 false in #align dimH_range_le_of_locally_holder_on dimH_range_le_of_locally_holder_on /-! ### Hausdorff dimension and Lipschitz continuity -/ /-- If `f : X → Y` is Lipschitz continuous on `s`, then `dimH (f '' s) ≤ dimH s`. -/ theorem LipschitzOnWith.dimH_image_le (h : LipschitzOnWith K f s) : dimH (f '' s) ≤ dimH s := by simpa using h.holderOnWith.dimH_image_le zero_lt_one set_option linter.uppercaseLean3 false in #align lipschitz_on_with.dimH_image_le LipschitzOnWith.dimH_image_le namespace LipschitzWith /-- If `f` is a Lipschitz continuous map, then `dimH (f '' s) ≤ dimH s`. -/ theorem dimH_image_le (h : LipschitzWith K f) (s : Set X) : dimH (f '' s) ≤ dimH s := (h.lipschitzOnWith s).dimH_image_le set_option linter.uppercaseLean3 false in #align lipschitz_with.dimH_image_le LipschitzWith.dimH_image_le /-- If `f` is a Lipschitz continuous map, then the Hausdorff dimension of its range is at most the Hausdorff dimension of its domain. -/ theorem dimH_range_le (h : LipschitzWith K f) : dimH (range f) ≤ dimH (univ : Set X) := @image_univ _ _ f ▸ h.dimH_image_le univ set_option linter.uppercaseLean3 false in #align lipschitz_with.dimH_range_le LipschitzWith.dimH_range_le end LipschitzWith /-- If `s` is a set in an extended metric space `X` with second countable topology and `f : X → Y` is Lipschitz in a neighborhood within `s` of every point `x ∈ s`, then the Hausdorff dimension of the image `f '' s` is at most the Hausdorff dimension of `s`. -/ theorem dimH_image_le_of_locally_lipschitzOn [SecondCountableTopology X] {f : X → Y} {s : Set X} (hf : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, LipschitzOnWith C f t) : dimH (f '' s) ≤ dimH s := by have : ∀ x ∈ s, ∃ C : ℝ≥0, ∃ t ∈ 𝓝[s] x, HolderOnWith C 1 f t := by simpa only [holderOnWith_one] using hf simpa only [ENNReal.coe_one, div_one] using dimH_image_le_of_locally_holder_on zero_lt_one this set_option linter.uppercaseLean3 false in #align dimH_image_le_of_locally_lipschitz_on dimH_image_le_of_locally_lipschitzOn /-- If `f : X → Y` is Lipschitz in a neighborhood of each point `x : X`, then the Hausdorff dimension of `range f` is at most the Hausdorff dimension of `X`. -/ theorem dimH_range_le_of_locally_lipschitzOn [SecondCountableTopology X] {f : X → Y} (hf : ∀ x : X, ∃ C : ℝ≥0, ∃ s ∈ 𝓝 x, LipschitzOnWith C f s) : dimH (range f) ≤ dimH (univ : Set X) := by rw [← image_univ] refine dimH_image_le_of_locally_lipschitzOn fun x _ => ?_ simpa only [exists_prop, nhdsWithin_univ] using hf x set_option linter.uppercaseLean3 false in #align dimH_range_le_of_locally_lipschitz_on dimH_range_le_of_locally_lipschitzOn namespace AntilipschitzWith theorem dimH_preimage_le (hf : AntilipschitzWith K f) (s : Set Y) : dimH (f ⁻¹' s) ≤ dimH s := by borelize X Y refine dimH_le fun d hd => le_dimH_of_hausdorffMeasure_eq_top ?_ have := hf.hausdorffMeasure_preimage_le d.coe_nonneg s rw [hd, top_le_iff] at this contrapose! this exact ENNReal.mul_ne_top (by simp) this set_option linter.uppercaseLean3 false in #align antilipschitz_with.dimH_preimage_le AntilipschitzWith.dimH_preimage_le theorem le_dimH_image (hf : AntilipschitzWith K f) (s : Set X) : dimH s ≤ dimH (f '' s) := calc dimH s ≤ dimH (f ⁻¹' (f '' s)) := dimH_mono (subset_preimage_image _ _) _ ≤ dimH (f '' s) := hf.dimH_preimage_le _ set_option linter.uppercaseLean3 false in #align antilipschitz_with.le_dimH_image AntilipschitzWith.le_dimH_image end AntilipschitzWith /-! ### Isometries preserve Hausdorff dimension -/ theorem Isometry.dimH_image (hf : Isometry f) (s : Set X) : dimH (f '' s) = dimH s := le_antisymm (hf.lipschitz.dimH_image_le _) (hf.antilipschitz.le_dimH_image _) set_option linter.uppercaseLean3 false in #align isometry.dimH_image Isometry.dimH_image namespace IsometryEquiv @[simp] theorem dimH_image (e : X ≃ᵢ Y) (s : Set X) : dimH (e '' s) = dimH s := e.isometry.dimH_image s set_option linter.uppercaseLean3 false in #align isometry_equiv.dimH_image IsometryEquiv.dimH_image @[simp]
Mathlib/Topology/MetricSpace/HausdorffDimension.lean
470
471
theorem dimH_preimage (e : X ≃ᵢ Y) (s : Set Y) : dimH (e ⁻¹' s) = dimH s := by
rw [← e.image_symm, e.symm.dimH_image]
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Sébastien Gouëzel, Rémy Degenne, David Loeffler -/ import Mathlib.Analysis.SpecialFunctions.Pow.Complex import Qq #align_import analysis.special_functions.pow.real from "leanprover-community/mathlib"@"4fa54b337f7d52805480306db1b1439c741848c8" /-! # Power function on `ℝ` We construct the power functions `x ^ y`, where `x` and `y` are real numbers. -/ noncomputable section open scoped Classical open Real ComplexConjugate open Finset Set /- ## Definitions -/ namespace Real variable {x y z : ℝ} /-- The real power function `x ^ y`, defined as the real part of the complex power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for `y ≠ 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (π y)`. -/ noncomputable def rpow (x y : ℝ) := ((x : ℂ) ^ (y : ℂ)).re #align real.rpow Real.rpow noncomputable instance : Pow ℝ ℝ := ⟨rpow⟩ @[simp] theorem rpow_eq_pow (x y : ℝ) : rpow x y = x ^ y := rfl #align real.rpow_eq_pow Real.rpow_eq_pow theorem rpow_def (x y : ℝ) : x ^ y = ((x : ℂ) ^ (y : ℂ)).re := rfl #align real.rpow_def Real.rpow_def theorem rpow_def_of_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by simp only [rpow_def, Complex.cpow_def]; split_ifs <;> simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul, -RCLike.ofReal_mul, (Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero] #align real.rpow_def_of_nonneg Real.rpow_def_of_nonneg theorem rpow_def_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : x ^ y = exp (log x * y) := by rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)] #align real.rpow_def_of_pos Real.rpow_def_of_pos theorem exp_mul (x y : ℝ) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp] #align real.exp_mul Real.exp_mul @[simp, norm_cast] theorem rpow_intCast (x : ℝ) (n : ℤ) : x ^ (n : ℝ) = x ^ n := by simp only [rpow_def, ← Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast, Complex.ofReal_re] #align real.rpow_int_cast Real.rpow_intCast @[deprecated (since := "2024-04-17")] alias rpow_int_cast := rpow_intCast @[simp, norm_cast] theorem rpow_natCast (x : ℝ) (n : ℕ) : x ^ (n : ℝ) = x ^ n := by simpa using rpow_intCast x n #align real.rpow_nat_cast Real.rpow_natCast @[deprecated (since := "2024-04-17")] alias rpow_nat_cast := rpow_natCast @[simp] theorem exp_one_rpow (x : ℝ) : exp 1 ^ x = exp x := by rw [← exp_mul, one_mul] #align real.exp_one_rpow Real.exp_one_rpow @[simp] lemma exp_one_pow (n : ℕ) : exp 1 ^ n = exp n := by rw [← rpow_natCast, exp_one_rpow] theorem rpow_eq_zero_iff_of_nonneg (hx : 0 ≤ x) : x ^ y = 0 ↔ x = 0 ∧ y ≠ 0 := by simp only [rpow_def_of_nonneg hx] split_ifs <;> simp [*, exp_ne_zero] #align real.rpow_eq_zero_iff_of_nonneg Real.rpow_eq_zero_iff_of_nonneg @[simp] lemma rpow_eq_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y = 0 ↔ x = 0 := by simp [rpow_eq_zero_iff_of_nonneg, *] @[simp] lemma rpow_ne_zero (hx : 0 ≤ x) (hy : y ≠ 0) : x ^ y ≠ 0 ↔ x ≠ 0 := Real.rpow_eq_zero hx hy |>.not open Real theorem rpow_def_of_neg {x : ℝ} (hx : x < 0) (y : ℝ) : x ^ y = exp (log x * y) * cos (y * π) := by rw [rpow_def, Complex.cpow_def, if_neg] · have : Complex.log x * y = ↑(log (-x) * y) + ↑(y * π) * Complex.I := by simp only [Complex.log, abs_of_neg hx, Complex.arg_ofReal_of_neg hx, Complex.abs_ofReal, Complex.ofReal_mul] ring rw [this, Complex.exp_add_mul_I, ← Complex.ofReal_exp, ← Complex.ofReal_cos, ← Complex.ofReal_sin, mul_add, ← Complex.ofReal_mul, ← mul_assoc, ← Complex.ofReal_mul, Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im, Real.log_neg_eq_log] ring · rw [Complex.ofReal_eq_zero] exact ne_of_lt hx #align real.rpow_def_of_neg Real.rpow_def_of_neg theorem rpow_def_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℝ) : x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * π) := by split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _ #align real.rpow_def_of_nonpos Real.rpow_def_of_nonpos theorem rpow_pos_of_pos {x : ℝ} (hx : 0 < x) (y : ℝ) : 0 < x ^ y := by rw [rpow_def_of_pos hx]; apply exp_pos #align real.rpow_pos_of_pos Real.rpow_pos_of_pos @[simp] theorem rpow_zero (x : ℝ) : x ^ (0 : ℝ) = 1 := by simp [rpow_def] #align real.rpow_zero Real.rpow_zero theorem rpow_zero_pos (x : ℝ) : 0 < x ^ (0 : ℝ) := by simp @[simp] theorem zero_rpow {x : ℝ} (h : x ≠ 0) : (0 : ℝ) ^ x = 0 := by simp [rpow_def, *] #align real.zero_rpow Real.zero_rpow theorem zero_rpow_eq_iff {x : ℝ} {a : ℝ} : 0 ^ x = a ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by constructor · intro hyp simp only [rpow_def, Complex.ofReal_zero] at hyp by_cases h : x = 0 · subst h simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp exact Or.inr ⟨rfl, hyp.symm⟩ · rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp exact Or.inl ⟨h, hyp.symm⟩ · rintro (⟨h, rfl⟩ | ⟨rfl, rfl⟩) · exact zero_rpow h · exact rpow_zero _ #align real.zero_rpow_eq_iff Real.zero_rpow_eq_iff theorem eq_zero_rpow_iff {x : ℝ} {a : ℝ} : a = 0 ^ x ↔ x ≠ 0 ∧ a = 0 ∨ x = 0 ∧ a = 1 := by rw [← zero_rpow_eq_iff, eq_comm] #align real.eq_zero_rpow_iff Real.eq_zero_rpow_iff @[simp] theorem rpow_one (x : ℝ) : x ^ (1 : ℝ) = x := by simp [rpow_def] #align real.rpow_one Real.rpow_one @[simp] theorem one_rpow (x : ℝ) : (1 : ℝ) ^ x = 1 := by simp [rpow_def] #align real.one_rpow Real.one_rpow theorem zero_rpow_le_one (x : ℝ) : (0 : ℝ) ^ x ≤ 1 := by by_cases h : x = 0 <;> simp [h, zero_le_one] #align real.zero_rpow_le_one Real.zero_rpow_le_one theorem zero_rpow_nonneg (x : ℝ) : 0 ≤ (0 : ℝ) ^ x := by by_cases h : x = 0 <;> simp [h, zero_le_one] #align real.zero_rpow_nonneg Real.zero_rpow_nonneg theorem rpow_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : 0 ≤ x ^ y := by rw [rpow_def_of_nonneg hx]; split_ifs <;> simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)] #align real.rpow_nonneg_of_nonneg Real.rpow_nonneg theorem abs_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : |x ^ y| = |x| ^ y := by have h_rpow_nonneg : 0 ≤ x ^ y := Real.rpow_nonneg hx_nonneg _ rw [abs_eq_self.mpr hx_nonneg, abs_eq_self.mpr h_rpow_nonneg] #align real.abs_rpow_of_nonneg Real.abs_rpow_of_nonneg theorem abs_rpow_le_abs_rpow (x y : ℝ) : |x ^ y| ≤ |x| ^ y := by rcases le_or_lt 0 x with hx | hx · rw [abs_rpow_of_nonneg hx] · rw [abs_of_neg hx, rpow_def_of_neg hx, rpow_def_of_pos (neg_pos.2 hx), log_neg_eq_log, abs_mul, abs_of_pos (exp_pos _)] exact mul_le_of_le_one_right (exp_pos _).le (abs_cos_le_one _) #align real.abs_rpow_le_abs_rpow Real.abs_rpow_le_abs_rpow theorem abs_rpow_le_exp_log_mul (x y : ℝ) : |x ^ y| ≤ exp (log x * y) := by refine (abs_rpow_le_abs_rpow x y).trans ?_ by_cases hx : x = 0 · by_cases hy : y = 0 <;> simp [hx, hy, zero_le_one] · rw [rpow_def_of_pos (abs_pos.2 hx), log_abs] #align real.abs_rpow_le_exp_log_mul Real.abs_rpow_le_exp_log_mul theorem norm_rpow_of_nonneg {x y : ℝ} (hx_nonneg : 0 ≤ x) : ‖x ^ y‖ = ‖x‖ ^ y := by simp_rw [Real.norm_eq_abs] exact abs_rpow_of_nonneg hx_nonneg #align real.norm_rpow_of_nonneg Real.norm_rpow_of_nonneg variable {w x y z : ℝ} theorem rpow_add (hx : 0 < x) (y z : ℝ) : x ^ (y + z) = x ^ y * x ^ z := by simp only [rpow_def_of_pos hx, mul_add, exp_add] #align real.rpow_add Real.rpow_add theorem rpow_add' (hx : 0 ≤ x) (h : y + z ≠ 0) : x ^ (y + z) = x ^ y * x ^ z := by rcases hx.eq_or_lt with (rfl | pos) · rw [zero_rpow h, zero_eq_mul] have : y ≠ 0 ∨ z ≠ 0 := not_and_or.1 fun ⟨hy, hz⟩ => h <| hy.symm ▸ hz.symm ▸ zero_add 0 exact this.imp zero_rpow zero_rpow · exact rpow_add pos _ _ #align real.rpow_add' Real.rpow_add' /-- Variant of `Real.rpow_add'` that avoids having to prove `y + z = w` twice. -/ lemma rpow_of_add_eq (hx : 0 ≤ x) (hw : w ≠ 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by rw [← h, rpow_add' hx]; rwa [h] theorem rpow_add_of_nonneg (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 ≤ z) : x ^ (y + z) = x ^ y * x ^ z := by rcases hy.eq_or_lt with (rfl | hy) · rw [zero_add, rpow_zero, one_mul] exact rpow_add' hx (ne_of_gt <| add_pos_of_pos_of_nonneg hy hz) #align real.rpow_add_of_nonneg Real.rpow_add_of_nonneg /-- For `0 ≤ x`, the only problematic case in the equality `x ^ y * x ^ z = x ^ (y + z)` is for `x = 0` and `y + z = 0`, where the right hand side is `1` while the left hand side can vanish. The inequality is always true, though, and given in this lemma. -/ theorem le_rpow_add {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ y * x ^ z ≤ x ^ (y + z) := by rcases le_iff_eq_or_lt.1 hx with (H | pos) · by_cases h : y + z = 0 · simp only [H.symm, h, rpow_zero] calc (0 : ℝ) ^ y * 0 ^ z ≤ 1 * 1 := mul_le_mul (zero_rpow_le_one y) (zero_rpow_le_one z) (zero_rpow_nonneg z) zero_le_one _ = 1 := by simp · simp [rpow_add', ← H, h] · simp [rpow_add pos] #align real.le_rpow_add Real.le_rpow_add theorem rpow_sum_of_pos {ι : Type*} {a : ℝ} (ha : 0 < a) (f : ι → ℝ) (s : Finset ι) : (a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x := map_sum (⟨⟨fun (x : ℝ) => (a ^ x : ℝ), rpow_zero a⟩, rpow_add ha⟩ : ℝ →+ (Additive ℝ)) f s #align real.rpow_sum_of_pos Real.rpow_sum_of_pos theorem rpow_sum_of_nonneg {ι : Type*} {a : ℝ} (ha : 0 ≤ a) {s : Finset ι} {f : ι → ℝ} (h : ∀ x ∈ s, 0 ≤ f x) : (a ^ ∑ x ∈ s, f x) = ∏ x ∈ s, a ^ f x := by induction' s using Finset.cons_induction with i s hi ihs · rw [sum_empty, Finset.prod_empty, rpow_zero] · rw [forall_mem_cons] at h rw [sum_cons, prod_cons, ← ihs h.2, rpow_add_of_nonneg ha h.1 (sum_nonneg h.2)] #align real.rpow_sum_of_nonneg Real.rpow_sum_of_nonneg theorem rpow_neg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : x ^ (-y) = (x ^ y)⁻¹ := by simp only [rpow_def_of_nonneg hx]; split_ifs <;> simp_all [exp_neg] #align real.rpow_neg Real.rpow_neg theorem rpow_sub {x : ℝ} (hx : 0 < x) (y z : ℝ) : x ^ (y - z) = x ^ y / x ^ z := by simp only [sub_eq_add_neg, rpow_add hx, rpow_neg (le_of_lt hx), div_eq_mul_inv] #align real.rpow_sub Real.rpow_sub theorem rpow_sub' {x : ℝ} (hx : 0 ≤ x) {y z : ℝ} (h : y - z ≠ 0) : x ^ (y - z) = x ^ y / x ^ z := by simp only [sub_eq_add_neg] at h ⊢ simp only [rpow_add' hx h, rpow_neg hx, div_eq_mul_inv] #align real.rpow_sub' Real.rpow_sub' end Real /-! ## Comparing real and complex powers -/ namespace Complex theorem ofReal_cpow {x : ℝ} (hx : 0 ≤ x) (y : ℝ) : ((x ^ y : ℝ) : ℂ) = (x : ℂ) ^ (y : ℂ) := by simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;> simp [Complex.ofReal_log hx] #align complex.of_real_cpow Complex.ofReal_cpow theorem ofReal_cpow_of_nonpos {x : ℝ} (hx : x ≤ 0) (y : ℂ) : (x : ℂ) ^ y = (-x : ℂ) ^ y * exp (π * I * y) := by rcases hx.eq_or_lt with (rfl | hlt) · rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*] have hne : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr hlt.ne rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), ← exp_add, ← add_mul, log, log, abs.map_neg, arg_ofReal_of_neg hlt, ← ofReal_neg, arg_ofReal_of_nonneg (neg_nonneg.2 hx), ofReal_zero, zero_mul, add_zero] #align complex.of_real_cpow_of_nonpos Complex.ofReal_cpow_of_nonpos lemma cpow_ofReal (x : ℂ) (y : ℝ) : x ^ (y : ℂ) = ↑(abs x ^ y) * (Real.cos (arg x * y) + Real.sin (arg x * y) * I) := by rcases eq_or_ne x 0 with rfl | hx · simp [ofReal_cpow le_rfl] · rw [cpow_def_of_ne_zero hx, exp_eq_exp_re_mul_sin_add_cos, mul_comm (log x)] norm_cast rw [re_ofReal_mul, im_ofReal_mul, log_re, log_im, mul_comm y, mul_comm y, Real.exp_mul, Real.exp_log] rwa [abs.pos_iff] lemma cpow_ofReal_re (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).re = (abs x) ^ y * Real.cos (arg x * y) := by rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.cos] lemma cpow_ofReal_im (x : ℂ) (y : ℝ) : (x ^ (y : ℂ)).im = (abs x) ^ y * Real.sin (arg x * y) := by rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.sin] theorem abs_cpow_of_ne_zero {z : ℂ} (hz : z ≠ 0) (w : ℂ) : abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by rw [cpow_def_of_ne_zero hz, abs_exp, mul_re, log_re, log_im, Real.exp_sub, Real.rpow_def_of_pos (abs.pos hz)] #align complex.abs_cpow_of_ne_zero Complex.abs_cpow_of_ne_zero theorem abs_cpow_of_imp {z w : ℂ} (h : z = 0 → w.re = 0 → w = 0) : abs (z ^ w) = abs z ^ w.re / Real.exp (arg z * im w) := by rcases ne_or_eq z 0 with (hz | rfl) <;> [exact abs_cpow_of_ne_zero hz w; rw [map_zero]] rcases eq_or_ne w.re 0 with hw | hw · simp [hw, h rfl hw] · rw [Real.zero_rpow hw, zero_div, zero_cpow, map_zero] exact ne_of_apply_ne re hw #align complex.abs_cpow_of_imp Complex.abs_cpow_of_imp theorem abs_cpow_le (z w : ℂ) : abs (z ^ w) ≤ abs z ^ w.re / Real.exp (arg z * im w) := by by_cases h : z = 0 → w.re = 0 → w = 0 · exact (abs_cpow_of_imp h).le · push_neg at h simp [h] #align complex.abs_cpow_le Complex.abs_cpow_le @[simp] theorem abs_cpow_real (x : ℂ) (y : ℝ) : abs (x ^ (y : ℂ)) = Complex.abs x ^ y := by rw [abs_cpow_of_imp] <;> simp #align complex.abs_cpow_real Complex.abs_cpow_real @[simp] theorem abs_cpow_inv_nat (x : ℂ) (n : ℕ) : abs (x ^ (n⁻¹ : ℂ)) = Complex.abs x ^ (n⁻¹ : ℝ) := by rw [← abs_cpow_real]; simp [-abs_cpow_real] #align complex.abs_cpow_inv_nat Complex.abs_cpow_inv_nat theorem abs_cpow_eq_rpow_re_of_pos {x : ℝ} (hx : 0 < x) (y : ℂ) : abs (x ^ y) = x ^ y.re := by rw [abs_cpow_of_ne_zero (ofReal_ne_zero.mpr hx.ne'), arg_ofReal_of_nonneg hx.le, zero_mul, Real.exp_zero, div_one, abs_of_nonneg hx.le] #align complex.abs_cpow_eq_rpow_re_of_pos Complex.abs_cpow_eq_rpow_re_of_pos theorem abs_cpow_eq_rpow_re_of_nonneg {x : ℝ} (hx : 0 ≤ x) {y : ℂ} (hy : re y ≠ 0) : abs (x ^ y) = x ^ re y := by rw [abs_cpow_of_imp] <;> simp [*, arg_ofReal_of_nonneg, _root_.abs_of_nonneg] #align complex.abs_cpow_eq_rpow_re_of_nonneg Complex.abs_cpow_eq_rpow_re_of_nonneg lemma norm_natCast_cpow_of_re_ne_zero (n : ℕ) {s : ℂ} (hs : s.re ≠ 0) : ‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_nonneg n.cast_nonneg hs] lemma norm_natCast_cpow_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) : ‖(n : ℂ) ^ s‖ = (n : ℝ) ^ (s.re) := by rw [norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_pos (Nat.cast_pos.mpr hn) _] lemma norm_natCast_cpow_pos_of_pos {n : ℕ} (hn : 0 < n) (s : ℂ) : 0 < ‖(n : ℂ) ^ s‖ := (norm_natCast_cpow_of_pos hn _).symm ▸ Real.rpow_pos_of_pos (Nat.cast_pos.mpr hn) _ theorem cpow_mul_ofReal_nonneg {x : ℝ} (hx : 0 ≤ x) (y : ℝ) (z : ℂ) : (x : ℂ) ^ (↑y * z) = (↑(x ^ y) : ℂ) ^ z := by rw [cpow_mul, ofReal_cpow hx] · rw [← ofReal_log hx, ← ofReal_mul, ofReal_im, neg_lt_zero]; exact Real.pi_pos · rw [← ofReal_log hx, ← ofReal_mul, ofReal_im]; exact Real.pi_pos.le #align complex.cpow_mul_of_real_nonneg Complex.cpow_mul_ofReal_nonneg end Complex /-! ### Positivity extension -/ namespace Mathlib.Meta.Positivity open Lean Meta Qq /-- Extension for the `positivity` tactic: exponentiation by a real number is positive (namely 1) when the exponent is zero. The other cases are done in `evalRpow`. -/ @[positivity (_ : ℝ) ^ (0 : ℝ)] def evalRpowZero : PositivityExt where eval {u α} _ _ e := do match u, α, e with | 0, ~q(ℝ), ~q($a ^ (0 : ℝ)) => assertInstancesCommute pure (.positive q(Real.rpow_zero_pos $a)) | _, _, _ => throwError "not Real.rpow" /-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when the base is nonnegative and positive when the base is positive. -/ @[positivity (_ : ℝ) ^ (_ : ℝ)] def evalRpow : PositivityExt where eval {u α} _zα _pα e := do match u, α, e with | 0, ~q(ℝ), ~q($a ^ ($b : ℝ)) => let ra ← core q(inferInstance) q(inferInstance) a assertInstancesCommute match ra with | .positive pa => pure (.positive q(Real.rpow_pos_of_pos $pa $b)) | .nonnegative pa => pure (.nonnegative q(Real.rpow_nonneg $pa $b)) | _ => pure .none | _, _, _ => throwError "not Real.rpow" end Mathlib.Meta.Positivity /-! ## Further algebraic properties of `rpow` -/ namespace Real variable {x y z : ℝ} {n : ℕ} theorem rpow_mul {x : ℝ} (hx : 0 ≤ x) (y z : ℝ) : x ^ (y * z) = (x ^ y) ^ z := by rw [← Complex.ofReal_inj, Complex.ofReal_cpow (rpow_nonneg hx _), Complex.ofReal_cpow hx, Complex.ofReal_mul, Complex.cpow_mul, Complex.ofReal_cpow hx] <;> simp only [(Complex.ofReal_mul _ _).symm, (Complex.ofReal_log hx).symm, Complex.ofReal_im, neg_lt_zero, pi_pos, le_of_lt pi_pos] #align real.rpow_mul Real.rpow_mul theorem rpow_add_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℤ) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_def, rpow_def, Complex.ofReal_add, Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hx), Complex.ofReal_intCast, Complex.cpow_intCast, ← Complex.ofReal_zpow, mul_comm, Complex.re_ofReal_mul, mul_comm] #align real.rpow_add_int Real.rpow_add_int theorem rpow_add_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y + n) = x ^ y * x ^ n := by simpa using rpow_add_int hx y n #align real.rpow_add_nat Real.rpow_add_nat theorem rpow_sub_int {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by simpa using rpow_add_int hx y (-n) #align real.rpow_sub_int Real.rpow_sub_int theorem rpow_sub_nat {x : ℝ} (hx : x ≠ 0) (y : ℝ) (n : ℕ) : x ^ (y - n) = x ^ y / x ^ n := by simpa using rpow_sub_int hx y n #align real.rpow_sub_nat Real.rpow_sub_nat lemma rpow_add_int' (hx : 0 ≤ x) {n : ℤ} (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_add' hx h, rpow_intCast] lemma rpow_add_nat' (hx : 0 ≤ x) (h : y + n ≠ 0) : x ^ (y + n) = x ^ y * x ^ n := by rw [rpow_add' hx h, rpow_natCast] lemma rpow_sub_int' (hx : 0 ≤ x) {n : ℤ} (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by rw [rpow_sub' hx h, rpow_intCast] lemma rpow_sub_nat' (hx : 0 ≤ x) (h : y - n ≠ 0) : x ^ (y - n) = x ^ y / x ^ n := by rw [rpow_sub' hx h, rpow_natCast] theorem rpow_add_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y + 1) = x ^ y * x := by simpa using rpow_add_nat hx y 1 #align real.rpow_add_one Real.rpow_add_one theorem rpow_sub_one {x : ℝ} (hx : x ≠ 0) (y : ℝ) : x ^ (y - 1) = x ^ y / x := by simpa using rpow_sub_nat hx y 1 #align real.rpow_sub_one Real.rpow_sub_one lemma rpow_add_one' (hx : 0 ≤ x) (h : y + 1 ≠ 0) : x ^ (y + 1) = x ^ y * x := by rw [rpow_add' hx h, rpow_one] lemma rpow_one_add' (hx : 0 ≤ x) (h : 1 + y ≠ 0) : x ^ (1 + y) = x * x ^ y := by rw [rpow_add' hx h, rpow_one] lemma rpow_sub_one' (hx : 0 ≤ x) (h : y - 1 ≠ 0) : x ^ (y - 1) = x ^ y / x := by rw [rpow_sub' hx h, rpow_one] lemma rpow_one_sub' (hx : 0 ≤ x) (h : 1 - y ≠ 0) : x ^ (1 - y) = x / x ^ y := by rw [rpow_sub' hx h, rpow_one] @[simp] theorem rpow_two (x : ℝ) : x ^ (2 : ℝ) = x ^ 2 := by rw [← rpow_natCast] simp only [Nat.cast_ofNat] #align real.rpow_two Real.rpow_two theorem rpow_neg_one (x : ℝ) : x ^ (-1 : ℝ) = x⁻¹ := by suffices H : x ^ ((-1 : ℤ) : ℝ) = x⁻¹ by rwa [Int.cast_neg, Int.cast_one] at H simp only [rpow_intCast, zpow_one, zpow_neg] #align real.rpow_neg_one Real.rpow_neg_one theorem mul_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) : (x * y) ^ z = x ^ z * y ^ z := by iterate 2 rw [Real.rpow_def_of_nonneg]; split_ifs with h_ifs <;> simp_all · rw [log_mul ‹_› ‹_›, add_mul, exp_add, rpow_def_of_pos (hy.lt_of_ne' ‹_›)] all_goals positivity #align real.mul_rpow Real.mul_rpow theorem inv_rpow (hx : 0 ≤ x) (y : ℝ) : x⁻¹ ^ y = (x ^ y)⁻¹ := by simp only [← rpow_neg_one, ← rpow_mul hx, mul_comm] #align real.inv_rpow Real.inv_rpow theorem div_rpow (hx : 0 ≤ x) (hy : 0 ≤ y) (z : ℝ) : (x / y) ^ z = x ^ z / y ^ z := by simp only [div_eq_mul_inv, mul_rpow hx (inv_nonneg.2 hy), inv_rpow hy] #align real.div_rpow Real.div_rpow theorem log_rpow {x : ℝ} (hx : 0 < x) (y : ℝ) : log (x ^ y) = y * log x := by apply exp_injective rw [exp_log (rpow_pos_of_pos hx y), ← exp_log hx, mul_comm, rpow_def_of_pos (exp_pos (log x)) y] #align real.log_rpow Real.log_rpow theorem mul_log_eq_log_iff {x y z : ℝ} (hx : 0 < x) (hz : 0 < z) : y * log x = log z ↔ x ^ y = z := ⟨fun h ↦ log_injOn_pos (rpow_pos_of_pos hx _) hz <| log_rpow hx _ |>.trans h, by rintro rfl; rw [log_rpow hx]⟩ @[simp] lemma rpow_rpow_inv (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y) ^ y⁻¹ = x := by rw [← rpow_mul hx, mul_inv_cancel hy, rpow_one] @[simp] lemma rpow_inv_rpow (hx : 0 ≤ x) (hy : y ≠ 0) : (x ^ y⁻¹) ^ y = x := by rw [← rpow_mul hx, inv_mul_cancel hy, rpow_one] theorem pow_rpow_inv_natCast (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ n) ^ (n⁻¹ : ℝ) = x := by have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn rw [← rpow_natCast, ← rpow_mul hx, mul_inv_cancel hn0, rpow_one] #align real.pow_nat_rpow_nat_inv Real.pow_rpow_inv_natCast theorem rpow_inv_natCast_pow (hx : 0 ≤ x) (hn : n ≠ 0) : (x ^ (n⁻¹ : ℝ)) ^ n = x := by have hn0 : (n : ℝ) ≠ 0 := Nat.cast_ne_zero.2 hn rw [← rpow_natCast, ← rpow_mul hx, inv_mul_cancel hn0, rpow_one] #align real.rpow_nat_inv_pow_nat Real.rpow_inv_natCast_pow lemma rpow_natCast_mul (hx : 0 ≤ x) (n : ℕ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by rw [rpow_mul hx, rpow_natCast] lemma rpow_mul_natCast (hx : 0 ≤ x) (y : ℝ) (n : ℕ) : x ^ (y * n) = (x ^ y) ^ n := by rw [rpow_mul hx, rpow_natCast] lemma rpow_intCast_mul (hx : 0 ≤ x) (n : ℤ) (z : ℝ) : x ^ (n * z) = (x ^ n) ^ z := by rw [rpow_mul hx, rpow_intCast] lemma rpow_mul_intCast (hx : 0 ≤ x) (y : ℝ) (n : ℤ) : x ^ (y * n) = (x ^ y) ^ n := by rw [rpow_mul hx, rpow_intCast] /-! Note: lemmas about `(∏ i ∈ s, f i ^ r)` such as `Real.finset_prod_rpow` are proved in `Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean` instead. -/ /-! ## Order and monotonicity -/ @[gcongr] theorem rpow_lt_rpow (hx : 0 ≤ x) (hxy : x < y) (hz : 0 < z) : x ^ z < y ^ z := by rw [le_iff_eq_or_lt] at hx; cases' hx with hx hx · rw [← hx, zero_rpow (ne_of_gt hz)] exact rpow_pos_of_pos (by rwa [← hx] at hxy) _ · rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp] exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz #align real.rpow_lt_rpow Real.rpow_lt_rpow theorem strictMonoOn_rpow_Ici_of_exponent_pos {r : ℝ} (hr : 0 < r) : StrictMonoOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) := fun _ ha _ _ hab => rpow_lt_rpow ha hab hr @[gcongr] theorem rpow_le_rpow {x y z : ℝ} (h : 0 ≤ x) (h₁ : x ≤ y) (h₂ : 0 ≤ z) : x ^ z ≤ y ^ z := by rcases eq_or_lt_of_le h₁ with (rfl | h₁'); · rfl rcases eq_or_lt_of_le h₂ with (rfl | h₂'); · simp exact le_of_lt (rpow_lt_rpow h h₁' h₂') #align real.rpow_le_rpow Real.rpow_le_rpow theorem monotoneOn_rpow_Ici_of_exponent_nonneg {r : ℝ} (hr : 0 ≤ r) : MonotoneOn (fun (x : ℝ) => x ^ r) (Set.Ici 0) := fun _ ha _ _ hab => rpow_le_rpow ha hab hr lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z := by have := hx.trans hxy rw [← inv_lt_inv, ← rpow_neg, ← rpow_neg] on_goal 1 => refine rpow_lt_rpow ?_ hxy (neg_pos.2 hz) all_goals positivity lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x ≤ y) (hz : z ≤ 0) : y ^ z ≤ x ^ z := by have := hx.trans_le hxy rw [← inv_le_inv, ← rpow_neg, ← rpow_neg] on_goal 1 => refine rpow_le_rpow ?_ hxy (neg_nonneg.2 hz) all_goals positivity theorem rpow_lt_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z < y ^ z ↔ x < y := ⟨lt_imp_lt_of_le_imp_le fun h => rpow_le_rpow hy h (le_of_lt hz), fun h => rpow_lt_rpow hx h hz⟩ #align real.rpow_lt_rpow_iff Real.rpow_lt_rpow_iff theorem rpow_le_rpow_iff (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z ≤ y ^ z ↔ x ≤ y := le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff hy hx hz #align real.rpow_le_rpow_iff Real.rpow_le_rpow_iff lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z ↔ y < x := ⟨lt_imp_lt_of_le_imp_le fun h ↦ rpow_le_rpow_of_nonpos hx h hz.le, fun h ↦ rpow_lt_rpow_of_neg hy h hz⟩ lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z ≤ y ^ z ↔ y ≤ x := le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff_of_neg hy hx hz lemma le_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ≤ y ^ z⁻¹ ↔ x ^ z ≤ y := by rw [← rpow_le_rpow_iff hx _ hz, rpow_inv_rpow] <;> positivity lemma rpow_inv_le_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ ≤ y ↔ x ≤ y ^ z := by rw [← rpow_le_rpow_iff _ hy hz, rpow_inv_rpow] <;> positivity lemma lt_rpow_inv_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x < y ^ z⁻¹ ↔ x ^ z < y := lt_iff_lt_of_le_iff_le <| rpow_inv_le_iff_of_pos hy hx hz lemma rpow_inv_lt_iff_of_pos (hx : 0 ≤ x) (hy : 0 ≤ y) (hz : 0 < z) : x ^ z⁻¹ < y ↔ x < y ^ z := lt_iff_lt_of_le_iff_le <| le_rpow_inv_iff_of_pos hy hx hz theorem le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ≤ y ^ z⁻¹ ↔ y ≤ x ^ z := by rw [← rpow_le_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.le_rpow_inv_iff_of_neg Real.le_rpow_inv_iff_of_neg theorem lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x < y ^ z⁻¹ ↔ y < x ^ z := by rw [← rpow_lt_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.lt_rpow_inv_iff_of_neg Real.lt_rpow_inv_iff_of_neg theorem rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z⁻¹ < y ↔ y ^ z < x := by rw [← rpow_lt_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.rpow_inv_lt_iff_of_neg Real.rpow_inv_lt_iff_of_neg theorem rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z⁻¹ ≤ y ↔ y ^ z ≤ x := by rw [← rpow_le_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity #align real.rpow_inv_le_iff_of_neg Real.rpow_inv_le_iff_of_neg theorem rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x ^ y < x ^ z := by repeat' rw [rpow_def_of_pos (lt_trans zero_lt_one hx)] rw [exp_lt_exp]; exact mul_lt_mul_of_pos_left hyz (log_pos hx) #align real.rpow_lt_rpow_of_exponent_lt Real.rpow_lt_rpow_of_exponent_lt @[gcongr] theorem rpow_le_rpow_of_exponent_le (hx : 1 ≤ x) (hyz : y ≤ z) : x ^ y ≤ x ^ z := by repeat' rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)] rw [exp_le_exp]; exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx) #align real.rpow_le_rpow_of_exponent_le Real.rpow_le_rpow_of_exponent_le theorem rpow_lt_rpow_of_exponent_neg {x y z : ℝ} (hy : 0 < y) (hxy : y < x) (hz : z < 0) : x ^ z < y ^ z := by have hx : 0 < x := hy.trans hxy rw [← neg_neg z, Real.rpow_neg (le_of_lt hx) (-z), Real.rpow_neg (le_of_lt hy) (-z), inv_lt_inv (rpow_pos_of_pos hx _) (rpow_pos_of_pos hy _)] exact Real.rpow_lt_rpow (by positivity) hxy <| neg_pos_of_neg hz theorem strictAntiOn_rpow_Ioi_of_exponent_neg {r : ℝ} (hr : r < 0) : StrictAntiOn (fun (x:ℝ) => x ^ r) (Set.Ioi 0) := fun _ ha _ _ hab => rpow_lt_rpow_of_exponent_neg ha hab hr theorem rpow_le_rpow_of_exponent_nonpos {x y : ℝ} (hy : 0 < y) (hxy : y ≤ x) (hz : z ≤ 0) : x ^ z ≤ y ^ z := by rcases ne_or_eq z 0 with hz_zero | rfl case inl => rcases ne_or_eq x y with hxy' | rfl case inl => exact le_of_lt <| rpow_lt_rpow_of_exponent_neg hy (Ne.lt_of_le (id (Ne.symm hxy')) hxy) (Ne.lt_of_le hz_zero hz) case inr => simp case inr => simp theorem antitoneOn_rpow_Ioi_of_exponent_nonpos {r : ℝ} (hr : r ≤ 0) : AntitoneOn (fun (x:ℝ) => x ^ r) (Set.Ioi 0) := fun _ ha _ _ hab => rpow_le_rpow_of_exponent_nonpos ha hab hr @[simp] theorem rpow_le_rpow_left_iff (hx : 1 < x) : x ^ y ≤ x ^ z ↔ y ≤ z := by have x_pos : 0 < x := lt_trans zero_lt_one hx rw [← log_le_log_iff (rpow_pos_of_pos x_pos y) (rpow_pos_of_pos x_pos z), log_rpow x_pos, log_rpow x_pos, mul_le_mul_right (log_pos hx)] #align real.rpow_le_rpow_left_iff Real.rpow_le_rpow_left_iff @[simp] theorem rpow_lt_rpow_left_iff (hx : 1 < x) : x ^ y < x ^ z ↔ y < z := by rw [lt_iff_not_le, rpow_le_rpow_left_iff hx, lt_iff_not_le] #align real.rpow_lt_rpow_left_iff Real.rpow_lt_rpow_left_iff theorem rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) : x ^ y < x ^ z := by repeat' rw [rpow_def_of_pos hx0] rw [exp_lt_exp]; exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1) #align real.rpow_lt_rpow_of_exponent_gt Real.rpow_lt_rpow_of_exponent_gt theorem rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x ≤ 1) (hyz : z ≤ y) : x ^ y ≤ x ^ z := by repeat' rw [rpow_def_of_pos hx0] rw [exp_le_exp]; exact mul_le_mul_of_nonpos_left hyz (log_nonpos (le_of_lt hx0) hx1) #align real.rpow_le_rpow_of_exponent_ge Real.rpow_le_rpow_of_exponent_ge @[simp] theorem rpow_le_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) : x ^ y ≤ x ^ z ↔ z ≤ y := by rw [← log_le_log_iff (rpow_pos_of_pos hx0 y) (rpow_pos_of_pos hx0 z), log_rpow hx0, log_rpow hx0, mul_le_mul_right_of_neg (log_neg hx0 hx1)] #align real.rpow_le_rpow_left_iff_of_base_lt_one Real.rpow_le_rpow_left_iff_of_base_lt_one @[simp] theorem rpow_lt_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) : x ^ y < x ^ z ↔ z < y := by rw [lt_iff_not_le, rpow_le_rpow_left_iff_of_base_lt_one hx0 hx1, lt_iff_not_le] #align real.rpow_lt_rpow_left_iff_of_base_lt_one Real.rpow_lt_rpow_left_iff_of_base_lt_one theorem rpow_lt_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x < 1) (hz : 0 < z) : x ^ z < 1 := by rw [← one_rpow z] exact rpow_lt_rpow hx1 hx2 hz #align real.rpow_lt_one Real.rpow_lt_one theorem rpow_le_one {x z : ℝ} (hx1 : 0 ≤ x) (hx2 : x ≤ 1) (hz : 0 ≤ z) : x ^ z ≤ 1 := by rw [← one_rpow z] exact rpow_le_rpow hx1 hx2 hz #align real.rpow_le_one Real.rpow_le_one theorem rpow_lt_one_of_one_lt_of_neg {x z : ℝ} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by convert rpow_lt_rpow_of_exponent_lt hx hz exact (rpow_zero x).symm #align real.rpow_lt_one_of_one_lt_of_neg Real.rpow_lt_one_of_one_lt_of_neg theorem rpow_le_one_of_one_le_of_nonpos {x z : ℝ} (hx : 1 ≤ x) (hz : z ≤ 0) : x ^ z ≤ 1 := by convert rpow_le_rpow_of_exponent_le hx hz exact (rpow_zero x).symm #align real.rpow_le_one_of_one_le_of_nonpos Real.rpow_le_one_of_one_le_of_nonpos theorem one_lt_rpow {x z : ℝ} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z := by rw [← one_rpow z] exact rpow_lt_rpow zero_le_one hx hz #align real.one_lt_rpow Real.one_lt_rpow theorem one_le_rpow {x z : ℝ} (hx : 1 ≤ x) (hz : 0 ≤ z) : 1 ≤ x ^ z := by rw [← one_rpow z] exact rpow_le_rpow zero_le_one hx hz #align real.one_le_rpow Real.one_le_rpow theorem one_lt_rpow_of_pos_of_lt_one_of_neg (hx1 : 0 < x) (hx2 : x < 1) (hz : z < 0) : 1 < x ^ z := by convert rpow_lt_rpow_of_exponent_gt hx1 hx2 hz exact (rpow_zero x).symm #align real.one_lt_rpow_of_pos_of_lt_one_of_neg Real.one_lt_rpow_of_pos_of_lt_one_of_neg theorem one_le_rpow_of_pos_of_le_one_of_nonpos (hx1 : 0 < x) (hx2 : x ≤ 1) (hz : z ≤ 0) : 1 ≤ x ^ z := by convert rpow_le_rpow_of_exponent_ge hx1 hx2 hz exact (rpow_zero x).symm #align real.one_le_rpow_of_pos_of_le_one_of_nonpos Real.one_le_rpow_of_pos_of_le_one_of_nonpos theorem rpow_lt_one_iff_of_pos (hx : 0 < x) : x ^ y < 1 ↔ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by rw [rpow_def_of_pos hx, exp_lt_one_iff, mul_neg_iff, log_pos_iff hx, log_neg_iff hx] #align real.rpow_lt_one_iff_of_pos Real.rpow_lt_one_iff_of_pos theorem rpow_lt_one_iff (hx : 0 ≤ x) : x ^ y < 1 ↔ x = 0 ∧ y ≠ 0 ∨ 1 < x ∧ y < 0 ∨ x < 1 ∧ 0 < y := by rcases hx.eq_or_lt with (rfl | hx) · rcases _root_.em (y = 0) with (rfl | hy) <;> simp [*, lt_irrefl, zero_lt_one] · simp [rpow_lt_one_iff_of_pos hx, hx.ne.symm] #align real.rpow_lt_one_iff Real.rpow_lt_one_iff theorem rpow_lt_one_iff' {x y : ℝ} (hx : 0 ≤ x) (hy : 0 < y) : x ^ y < 1 ↔ x < 1 := by rw [← Real.rpow_lt_rpow_iff hx zero_le_one hy, Real.one_rpow]
Mathlib/Analysis/SpecialFunctions/Pow/Real.lean
750
751
theorem one_lt_rpow_iff_of_pos (hx : 0 < x) : 1 < x ^ y ↔ 1 < x ∧ 0 < y ∨ x < 1 ∧ y < 0 := by
rw [rpow_def_of_pos hx, one_lt_exp_iff, mul_pos_iff, log_pos_iff hx, log_neg_iff hx]
/- Copyright (c) 2018 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson -/ import Mathlib.Algebra.BigOperators.Associated import Mathlib.Algebra.GCDMonoid.Basic import Mathlib.Data.Finsupp.Multiset import Mathlib.Data.Nat.Factors import Mathlib.RingTheory.Noetherian import Mathlib.RingTheory.Multiplicity #align_import ring_theory.unique_factorization_domain from "leanprover-community/mathlib"@"570e9f4877079b3a923135b3027ac3be8695ab8c" /-! # Unique factorization ## Main Definitions * `WfDvdMonoid` holds for `Monoid`s for which a strict divisibility relation is well-founded. * `UniqueFactorizationMonoid` holds for `WfDvdMonoid`s where `Irreducible` is equivalent to `Prime` ## To do * set up the complete lattice structure on `FactorSet`. -/ variable {α : Type*} local infixl:50 " ~ᵤ " => Associated /-- Well-foundedness of the strict version of |, which is equivalent to the descending chain condition on divisibility and to the ascending chain condition on principal ideals in an integral domain. -/ class WfDvdMonoid (α : Type*) [CommMonoidWithZero α] : Prop where wellFounded_dvdNotUnit : WellFounded (@DvdNotUnit α _) #align wf_dvd_monoid WfDvdMonoid export WfDvdMonoid (wellFounded_dvdNotUnit) -- see Note [lower instance priority] instance (priority := 100) IsNoetherianRing.wfDvdMonoid [CommRing α] [IsDomain α] [IsNoetherianRing α] : WfDvdMonoid α := ⟨by convert InvImage.wf (fun a => Ideal.span ({a} : Set α)) (wellFounded_submodule_gt _ _) ext exact Ideal.span_singleton_lt_span_singleton.symm⟩ #align is_noetherian_ring.wf_dvd_monoid IsNoetherianRing.wfDvdMonoid namespace WfDvdMonoid variable [CommMonoidWithZero α] open Associates Nat theorem of_wfDvdMonoid_associates (_ : WfDvdMonoid (Associates α)) : WfDvdMonoid α := ⟨(mk_surjective.wellFounded_iff mk_dvdNotUnit_mk_iff.symm).2 wellFounded_dvdNotUnit⟩ #align wf_dvd_monoid.of_wf_dvd_monoid_associates WfDvdMonoid.of_wfDvdMonoid_associates variable [WfDvdMonoid α] instance wfDvdMonoid_associates : WfDvdMonoid (Associates α) := ⟨(mk_surjective.wellFounded_iff mk_dvdNotUnit_mk_iff.symm).1 wellFounded_dvdNotUnit⟩ #align wf_dvd_monoid.wf_dvd_monoid_associates WfDvdMonoid.wfDvdMonoid_associates theorem wellFounded_associates : WellFounded ((· < ·) : Associates α → Associates α → Prop) := Subrelation.wf dvdNotUnit_of_lt wellFounded_dvdNotUnit #align wf_dvd_monoid.well_founded_associates WfDvdMonoid.wellFounded_associates -- Porting note: elab_as_elim can only be global and cannot be changed on an imported decl -- attribute [local elab_as_elim] WellFounded.fix theorem exists_irreducible_factor {a : α} (ha : ¬IsUnit a) (ha0 : a ≠ 0) : ∃ i, Irreducible i ∧ i ∣ a := let ⟨b, hs, hr⟩ := wellFounded_dvdNotUnit.has_min { b | b ∣ a ∧ ¬IsUnit b } ⟨a, dvd_rfl, ha⟩ ⟨b, ⟨hs.2, fun c d he => let h := dvd_trans ⟨d, he⟩ hs.1 or_iff_not_imp_left.2 fun hc => of_not_not fun hd => hr c ⟨h, hc⟩ ⟨ne_zero_of_dvd_ne_zero ha0 h, d, hd, he⟩⟩, hs.1⟩ #align wf_dvd_monoid.exists_irreducible_factor WfDvdMonoid.exists_irreducible_factor @[elab_as_elim] theorem induction_on_irreducible {P : α → Prop} (a : α) (h0 : P 0) (hu : ∀ u : α, IsUnit u → P u) (hi : ∀ a i : α, a ≠ 0 → Irreducible i → P a → P (i * a)) : P a := haveI := Classical.dec wellFounded_dvdNotUnit.fix (fun a ih => if ha0 : a = 0 then ha0.substr h0 else if hau : IsUnit a then hu a hau else let ⟨i, hii, b, hb⟩ := exists_irreducible_factor hau ha0 let hb0 : b ≠ 0 := ne_zero_of_dvd_ne_zero ha0 ⟨i, mul_comm i b ▸ hb⟩ hb.symm ▸ hi b i hb0 hii <| ih b ⟨hb0, i, hii.1, mul_comm i b ▸ hb⟩) a #align wf_dvd_monoid.induction_on_irreducible WfDvdMonoid.induction_on_irreducible theorem exists_factors (a : α) : a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ Associated f.prod a := induction_on_irreducible a (fun h => (h rfl).elim) (fun u hu _ => ⟨0, fun _ h => False.elim (Multiset.not_mem_zero _ h), hu.unit, one_mul _⟩) fun a i ha0 hi ih _ => let ⟨s, hs⟩ := ih ha0 ⟨i ::ₘ s, fun b H => (Multiset.mem_cons.1 H).elim (fun h => h.symm ▸ hi) (hs.1 b), by rw [s.prod_cons i] exact hs.2.mul_left i⟩ #align wf_dvd_monoid.exists_factors WfDvdMonoid.exists_factors theorem not_unit_iff_exists_factors_eq (a : α) (hn0 : a ≠ 0) : ¬IsUnit a ↔ ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ f.prod = a ∧ f ≠ ∅ := ⟨fun hnu => by obtain ⟨f, hi, u, rfl⟩ := exists_factors a hn0 obtain ⟨b, h⟩ := Multiset.exists_mem_of_ne_zero fun h : f = 0 => hnu <| by simp [h] classical refine ⟨(f.erase b).cons (b * u), fun a ha => ?_, ?_, Multiset.cons_ne_zero⟩ · obtain rfl | ha := Multiset.mem_cons.1 ha exacts [Associated.irreducible ⟨u, rfl⟩ (hi b h), hi a (Multiset.mem_of_mem_erase ha)] · rw [Multiset.prod_cons, mul_comm b, mul_assoc, Multiset.prod_erase h, mul_comm], fun ⟨f, hi, he, hne⟩ => let ⟨b, h⟩ := Multiset.exists_mem_of_ne_zero hne not_isUnit_of_not_isUnit_dvd (hi b h).not_unit <| he ▸ Multiset.dvd_prod h⟩ #align wf_dvd_monoid.not_unit_iff_exists_factors_eq WfDvdMonoid.not_unit_iff_exists_factors_eq theorem isRelPrime_of_no_irreducible_factors {x y : α} (nonzero : ¬(x = 0 ∧ y = 0)) (H : ∀ z : α, Irreducible z → z ∣ x → ¬z ∣ y) : IsRelPrime x y := isRelPrime_of_no_nonunits_factors nonzero fun _z znu znz zx zy ↦ have ⟨i, h1, h2⟩ := exists_irreducible_factor znu znz H i h1 (h2.trans zx) (h2.trans zy) end WfDvdMonoid theorem WfDvdMonoid.of_wellFounded_associates [CancelCommMonoidWithZero α] (h : WellFounded ((· < ·) : Associates α → Associates α → Prop)) : WfDvdMonoid α := WfDvdMonoid.of_wfDvdMonoid_associates ⟨by convert h ext exact Associates.dvdNotUnit_iff_lt⟩ #align wf_dvd_monoid.of_well_founded_associates WfDvdMonoid.of_wellFounded_associates theorem WfDvdMonoid.iff_wellFounded_associates [CancelCommMonoidWithZero α] : WfDvdMonoid α ↔ WellFounded ((· < ·) : Associates α → Associates α → Prop) := ⟨by apply WfDvdMonoid.wellFounded_associates, WfDvdMonoid.of_wellFounded_associates⟩ #align wf_dvd_monoid.iff_well_founded_associates WfDvdMonoid.iff_wellFounded_associates theorem WfDvdMonoid.max_power_factor' [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : ¬IsUnit x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := by obtain ⟨a, ⟨n, rfl⟩, hm⟩ := wellFounded_dvdNotUnit.has_min {a | ∃ n, x ^ n * a = a₀} ⟨a₀, 0, by rw [pow_zero, one_mul]⟩ refine ⟨n, a, ?_, rfl⟩; rintro ⟨d, rfl⟩ exact hm d ⟨n + 1, by rw [pow_succ, mul_assoc]⟩ ⟨(right_ne_zero_of_mul <| right_ne_zero_of_mul h), x, hx, mul_comm _ _⟩ theorem WfDvdMonoid.max_power_factor [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α} (h : a₀ ≠ 0) (hx : Irreducible x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := max_power_factor' h hx.not_unit theorem multiplicity.finite_of_not_isUnit [CancelCommMonoidWithZero α] [WfDvdMonoid α] {a b : α} (ha : ¬IsUnit a) (hb : b ≠ 0) : multiplicity.Finite a b := by obtain ⟨n, c, ndvd, rfl⟩ := WfDvdMonoid.max_power_factor' hb ha exact ⟨n, by rwa [pow_succ, mul_dvd_mul_iff_left (left_ne_zero_of_mul hb)]⟩ section Prio -- set_option default_priority 100 -- see Note [default priority] /-- unique factorization monoids. These are defined as `CancelCommMonoidWithZero`s with well-founded strict divisibility relations, but this is equivalent to more familiar definitions: Each element (except zero) is uniquely represented as a multiset of irreducible factors. Uniqueness is only up to associated elements. Each element (except zero) is non-uniquely represented as a multiset of prime factors. To define a UFD using the definition in terms of multisets of irreducible factors, use the definition `of_exists_unique_irreducible_factors` To define a UFD using the definition in terms of multisets of prime factors, use the definition `of_exists_prime_factors` -/ class UniqueFactorizationMonoid (α : Type*) [CancelCommMonoidWithZero α] extends WfDvdMonoid α : Prop where protected irreducible_iff_prime : ∀ {a : α}, Irreducible a ↔ Prime a #align unique_factorization_monoid UniqueFactorizationMonoid /-- Can't be an instance because it would cause a loop `ufm → WfDvdMonoid → ufm → ...`. -/ theorem ufm_of_decomposition_of_wfDvdMonoid [CancelCommMonoidWithZero α] [WfDvdMonoid α] [DecompositionMonoid α] : UniqueFactorizationMonoid α := { ‹WfDvdMonoid α› with irreducible_iff_prime := irreducible_iff_prime } #align ufm_of_gcd_of_wf_dvd_monoid ufm_of_decomposition_of_wfDvdMonoid @[deprecated] alias ufm_of_gcd_of_wfDvdMonoid := ufm_of_decomposition_of_wfDvdMonoid instance Associates.ufm [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] : UniqueFactorizationMonoid (Associates α) := { (WfDvdMonoid.wfDvdMonoid_associates : WfDvdMonoid (Associates α)) with irreducible_iff_prime := by rw [← Associates.irreducible_iff_prime_iff] apply UniqueFactorizationMonoid.irreducible_iff_prime } #align associates.ufm Associates.ufm end Prio namespace UniqueFactorizationMonoid variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] theorem exists_prime_factors (a : α) : a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a := by simp_rw [← UniqueFactorizationMonoid.irreducible_iff_prime] apply WfDvdMonoid.exists_factors a #align unique_factorization_monoid.exists_prime_factors UniqueFactorizationMonoid.exists_prime_factors instance : DecompositionMonoid α where primal a := by obtain rfl | ha := eq_or_ne a 0; · exact isPrimal_zero obtain ⟨f, hf, u, rfl⟩ := exists_prime_factors a ha exact ((Submonoid.isPrimal α).multiset_prod_mem f (hf · ·|>.isPrimal)).mul u.isUnit.isPrimal lemma exists_prime_iff : (∃ (p : α), Prime p) ↔ ∃ (x : α), x ≠ 0 ∧ ¬ IsUnit x := by refine ⟨fun ⟨p, hp⟩ ↦ ⟨p, hp.ne_zero, hp.not_unit⟩, fun ⟨x, hx₀, hxu⟩ ↦ ?_⟩ obtain ⟨f, hf, -⟩ := WfDvdMonoid.exists_irreducible_factor hxu hx₀ exact ⟨f, UniqueFactorizationMonoid.irreducible_iff_prime.mp hf⟩ @[elab_as_elim] theorem induction_on_prime {P : α → Prop} (a : α) (h₁ : P 0) (h₂ : ∀ x : α, IsUnit x → P x) (h₃ : ∀ a p : α, a ≠ 0 → Prime p → P a → P (p * a)) : P a := by simp_rw [← UniqueFactorizationMonoid.irreducible_iff_prime] at h₃ exact WfDvdMonoid.induction_on_irreducible a h₁ h₂ h₃ #align unique_factorization_monoid.induction_on_prime UniqueFactorizationMonoid.induction_on_prime end UniqueFactorizationMonoid theorem prime_factors_unique [CancelCommMonoidWithZero α] : ∀ {f g : Multiset α}, (∀ x ∈ f, Prime x) → (∀ x ∈ g, Prime x) → f.prod ~ᵤ g.prod → Multiset.Rel Associated f g := by classical intro f induction' f using Multiset.induction_on with p f ih · intros g _ hg h exact Multiset.rel_zero_left.2 <| Multiset.eq_zero_of_forall_not_mem fun x hx => have : IsUnit g.prod := by simpa [associated_one_iff_isUnit] using h.symm (hg x hx).not_unit <| isUnit_iff_dvd_one.2 <| (Multiset.dvd_prod hx).trans (isUnit_iff_dvd_one.1 this) · intros g hf hg hfg let ⟨b, hbg, hb⟩ := (exists_associated_mem_of_dvd_prod (hf p (by simp)) fun q hq => hg _ hq) <| hfg.dvd_iff_dvd_right.1 (show p ∣ (p ::ₘ f).prod by simp) haveI := Classical.decEq α rw [← Multiset.cons_erase hbg] exact Multiset.Rel.cons hb (ih (fun q hq => hf _ (by simp [hq])) (fun {q} (hq : q ∈ g.erase b) => hg q (Multiset.mem_of_mem_erase hq)) (Associated.of_mul_left (by rwa [← Multiset.prod_cons, ← Multiset.prod_cons, Multiset.cons_erase hbg]) hb (hf p (by simp)).ne_zero)) #align prime_factors_unique prime_factors_unique namespace UniqueFactorizationMonoid variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] theorem factors_unique {f g : Multiset α} (hf : ∀ x ∈ f, Irreducible x) (hg : ∀ x ∈ g, Irreducible x) (h : f.prod ~ᵤ g.prod) : Multiset.Rel Associated f g := prime_factors_unique (fun x hx => UniqueFactorizationMonoid.irreducible_iff_prime.mp (hf x hx)) (fun x hx => UniqueFactorizationMonoid.irreducible_iff_prime.mp (hg x hx)) h #align unique_factorization_monoid.factors_unique UniqueFactorizationMonoid.factors_unique end UniqueFactorizationMonoid /-- If an irreducible has a prime factorization, then it is an associate of one of its prime factors. -/ theorem prime_factors_irreducible [CancelCommMonoidWithZero α] {a : α} {f : Multiset α} (ha : Irreducible a) (pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a) : ∃ p, a ~ᵤ p ∧ f = {p} := by haveI := Classical.decEq α refine @Multiset.induction_on _ (fun g => (g.prod ~ᵤ a) → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) f ?_ ?_ pfa.2 pfa.1 · intro h; exact (ha.not_unit (associated_one_iff_isUnit.1 (Associated.symm h))).elim · rintro p s _ ⟨u, hu⟩ hs use p have hs0 : s = 0 := by by_contra hs0 obtain ⟨q, hq⟩ := Multiset.exists_mem_of_ne_zero hs0 apply (hs q (by simp [hq])).2.1 refine (ha.isUnit_or_isUnit (?_ : _ = p * ↑u * (s.erase q).prod * _)).resolve_left ?_ · rw [mul_right_comm _ _ q, mul_assoc, ← Multiset.prod_cons, Multiset.cons_erase hq, ← hu, mul_comm, mul_comm p _, mul_assoc] simp apply mt isUnit_of_mul_isUnit_left (mt isUnit_of_mul_isUnit_left _) apply (hs p (Multiset.mem_cons_self _ _)).2.1 simp only [mul_one, Multiset.prod_cons, Multiset.prod_zero, hs0] at * exact ⟨Associated.symm ⟨u, hu⟩, rfl⟩ #align prime_factors_irreducible prime_factors_irreducible section ExistsPrimeFactors variable [CancelCommMonoidWithZero α] variable (pf : ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a) theorem WfDvdMonoid.of_exists_prime_factors : WfDvdMonoid α := ⟨by classical refine RelHomClass.wellFounded (RelHom.mk ?_ ?_ : (DvdNotUnit : α → α → Prop) →r ((· < ·) : ℕ∞ → ℕ∞ → Prop)) wellFounded_lt · intro a by_cases h : a = 0 · exact ⊤ exact ↑(Multiset.card (Classical.choose (pf a h))) rintro a b ⟨ane0, ⟨c, hc, b_eq⟩⟩ rw [dif_neg ane0] by_cases h : b = 0 · simp [h, lt_top_iff_ne_top] · rw [dif_neg h] erw [WithTop.coe_lt_coe] have cne0 : c ≠ 0 := by refine mt (fun con => ?_) h rw [b_eq, con, mul_zero] calc Multiset.card (Classical.choose (pf a ane0)) < _ + Multiset.card (Classical.choose (pf c cne0)) := lt_add_of_pos_right _ (Multiset.card_pos.mpr fun con => hc (associated_one_iff_isUnit.mp ?_)) _ = Multiset.card (Classical.choose (pf a ane0) + Classical.choose (pf c cne0)) := (Multiset.card_add _ _).symm _ = Multiset.card (Classical.choose (pf b h)) := Multiset.card_eq_card_of_rel (prime_factors_unique ?_ (Classical.choose_spec (pf _ h)).1 ?_) · convert (Classical.choose_spec (pf c cne0)).2.symm rw [con, Multiset.prod_zero] · intro x hadd rw [Multiset.mem_add] at hadd cases' hadd with h h <;> apply (Classical.choose_spec (pf _ _)).1 _ h <;> assumption · rw [Multiset.prod_add] trans a * c · apply Associated.mul_mul <;> apply (Classical.choose_spec (pf _ _)).2 <;> assumption · rw [← b_eq] apply (Classical.choose_spec (pf _ _)).2.symm; assumption⟩ #align wf_dvd_monoid.of_exists_prime_factors WfDvdMonoid.of_exists_prime_factors theorem irreducible_iff_prime_of_exists_prime_factors {p : α} : Irreducible p ↔ Prime p := by by_cases hp0 : p = 0 · simp [hp0] refine ⟨fun h => ?_, Prime.irreducible⟩ obtain ⟨f, hf⟩ := pf p hp0 obtain ⟨q, hq, rfl⟩ := prime_factors_irreducible h hf rw [hq.prime_iff] exact hf.1 q (Multiset.mem_singleton_self _) #align irreducible_iff_prime_of_exists_prime_factors irreducible_iff_prime_of_exists_prime_factors theorem UniqueFactorizationMonoid.of_exists_prime_factors : UniqueFactorizationMonoid α := { WfDvdMonoid.of_exists_prime_factors pf with irreducible_iff_prime := irreducible_iff_prime_of_exists_prime_factors pf } #align unique_factorization_monoid.of_exists_prime_factors UniqueFactorizationMonoid.of_exists_prime_factors end ExistsPrimeFactors theorem UniqueFactorizationMonoid.iff_exists_prime_factors [CancelCommMonoidWithZero α] : UniqueFactorizationMonoid α ↔ ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a := ⟨fun h => @UniqueFactorizationMonoid.exists_prime_factors _ _ h, UniqueFactorizationMonoid.of_exists_prime_factors⟩ #align unique_factorization_monoid.iff_exists_prime_factors UniqueFactorizationMonoid.iff_exists_prime_factors section variable {β : Type*} [CancelCommMonoidWithZero α] [CancelCommMonoidWithZero β] theorem MulEquiv.uniqueFactorizationMonoid (e : α ≃* β) (hα : UniqueFactorizationMonoid α) : UniqueFactorizationMonoid β := by rw [UniqueFactorizationMonoid.iff_exists_prime_factors] at hα ⊢ intro a ha obtain ⟨w, hp, u, h⟩ := hα (e.symm a) fun h => ha <| by convert← map_zero e simp [← h] exact ⟨w.map e, fun b hb => let ⟨c, hc, he⟩ := Multiset.mem_map.1 hb he ▸ e.prime_iff.1 (hp c hc), Units.map e.toMonoidHom u, by erw [Multiset.prod_hom, ← e.map_mul, h] simp⟩ #align mul_equiv.unique_factorization_monoid MulEquiv.uniqueFactorizationMonoid theorem MulEquiv.uniqueFactorizationMonoid_iff (e : α ≃* β) : UniqueFactorizationMonoid α ↔ UniqueFactorizationMonoid β := ⟨e.uniqueFactorizationMonoid, e.symm.uniqueFactorizationMonoid⟩ #align mul_equiv.unique_factorization_monoid_iff MulEquiv.uniqueFactorizationMonoid_iff end
Mathlib/RingTheory/UniqueFactorizationDomain.lean
408
445
theorem irreducible_iff_prime_of_exists_unique_irreducible_factors [CancelCommMonoidWithZero α] (eif : ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ f.prod ~ᵤ a) (uif : ∀ f g : Multiset α, (∀ x ∈ f, Irreducible x) → (∀ x ∈ g, Irreducible x) → f.prod ~ᵤ g.prod → Multiset.Rel Associated f g) (p : α) : Irreducible p ↔ Prime p := letI := Classical.decEq α ⟨ fun hpi => ⟨hpi.ne_zero, hpi.1, fun a b ⟨x, hx⟩ => if hab0 : a * b = 0 then (eq_zero_or_eq_zero_of_mul_eq_zero hab0).elim (fun ha0 => by simp [ha0]) fun hb0 => by simp [hb0] else by have hx0 : x ≠ 0 := fun hx0 => by simp_all have ha0 : a ≠ 0 := left_ne_zero_of_mul hab0 have hb0 : b ≠ 0 := right_ne_zero_of_mul hab0 cases' eif x hx0 with fx hfx cases' eif a ha0 with fa hfa cases' eif b hb0 with fb hfb have h : Multiset.Rel Associated (p ::ₘ fx) (fa + fb) := by
apply uif · exact fun i hi => (Multiset.mem_cons.1 hi).elim (fun hip => hip.symm ▸ hpi) (hfx.1 _) · exact fun i hi => (Multiset.mem_add.1 hi).elim (hfa.1 _) (hfb.1 _) calc Multiset.prod (p ::ₘ fx) ~ᵤ a * b := by rw [hx, Multiset.prod_cons]; exact hfx.2.mul_left _ _ ~ᵤ fa.prod * fb.prod := hfa.2.symm.mul_mul hfb.2.symm _ = _ := by rw [Multiset.prod_add] exact let ⟨q, hqf, hq⟩ := Multiset.exists_mem_of_rel_of_mem h (Multiset.mem_cons_self p _) (Multiset.mem_add.1 hqf).elim (fun hqa => Or.inl <| hq.dvd_iff_dvd_left.2 <| hfa.2.dvd_iff_dvd_right.1 (Multiset.dvd_prod hqa)) fun hqb => Or.inr <| hq.dvd_iff_dvd_left.2 <| hfb.2.dvd_iff_dvd_right.1 (Multiset.dvd_prod hqb)⟩, Prime.irreducible⟩
/- Copyright (c) 2018 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Order.Bounds.Basic import Mathlib.Order.WellFounded import Mathlib.Data.Set.Image import Mathlib.Order.Interval.Set.Basic import Mathlib.Data.Set.Lattice #align_import order.conditionally_complete_lattice.basic from "leanprover-community/mathlib"@"29cb56a7b35f72758b05a30490e1f10bd62c35c1" /-! # Theory of conditionally complete lattices. A conditionally complete lattice is a lattice in which every non-empty bounded subset `s` has a least upper bound and a greatest lower bound, denoted below by `sSup s` and `sInf s`. Typical examples are `ℝ`, `ℕ`, and `ℤ` with their usual orders. The theory is very comparable to the theory of complete lattices, except that suitable boundedness and nonemptiness assumptions have to be added to most statements. We introduce two predicates `BddAbove` and `BddBelow` to express this boundedness, prove their basic properties, and then go on to prove most useful properties of `sSup` and `sInf` in conditionally complete lattices. To differentiate the statements between complete lattices and conditionally complete lattices, we prefix `sInf` and `sSup` in the statements by `c`, giving `csInf` and `csSup`. For instance, `sInf_le` is a statement in complete lattices ensuring `sInf s ≤ x`, while `csInf_le` is the same statement in conditionally complete lattices with an additional assumption that `s` is bounded below. -/ open Function OrderDual Set variable {α β γ : Type*} {ι : Sort*} section /-! Extension of `sSup` and `sInf` from a preorder `α` to `WithTop α` and `WithBot α` -/ variable [Preorder α] open scoped Classical noncomputable instance WithTop.instSupSet [SupSet α] : SupSet (WithTop α) := ⟨fun S => if ⊤ ∈ S then ⊤ else if BddAbove ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α) then ↑(sSup ((fun (a : α) ↦ (a : WithTop α)) ⁻¹' S : Set α)) else ⊤⟩ noncomputable instance WithTop.instInfSet [InfSet α] : InfSet (WithTop α) := ⟨fun S => if S ⊆ {⊤} ∨ ¬BddBelow S then ⊤ else ↑(sInf ((fun (a : α) ↦ ↑a) ⁻¹' S : Set α))⟩ noncomputable instance WithBot.instSupSet [SupSet α] : SupSet (WithBot α) := ⟨(WithTop.instInfSet (α := αᵒᵈ)).sInf⟩ noncomputable instance WithBot.instInfSet [InfSet α] : InfSet (WithBot α) := ⟨(WithTop.instSupSet (α := αᵒᵈ)).sSup⟩ theorem WithTop.sSup_eq [SupSet α] {s : Set (WithTop α)} (hs : ⊤ ∉ s) (hs' : BddAbove ((↑) ⁻¹' s : Set α)) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) := (if_neg hs).trans <| if_pos hs' #align with_top.Sup_eq WithTop.sSup_eq theorem WithTop.sInf_eq [InfSet α] {s : Set (WithTop α)} (hs : ¬s ⊆ {⊤}) (h's : BddBelow s) : sInf s = ↑(sInf ((↑) ⁻¹' s) : α) := if_neg <| by simp [hs, h's] #align with_top.Inf_eq WithTop.sInf_eq theorem WithBot.sInf_eq [InfSet α] {s : Set (WithBot α)} (hs : ⊥ ∉ s) (hs' : BddBelow ((↑) ⁻¹' s : Set α)) : sInf s = ↑(sInf ((↑) ⁻¹' s) : α) := (if_neg hs).trans <| if_pos hs' #align with_bot.Inf_eq WithBot.sInf_eq theorem WithBot.sSup_eq [SupSet α] {s : Set (WithBot α)} (hs : ¬s ⊆ {⊥}) (h's : BddAbove s) : sSup s = ↑(sSup ((↑) ⁻¹' s) : α) := WithTop.sInf_eq (α := αᵒᵈ) hs h's #align with_bot.Sup_eq WithBot.sSup_eq @[simp] theorem WithTop.sInf_empty [InfSet α] : sInf (∅ : Set (WithTop α)) = ⊤ := if_pos <| by simp #align with_top.cInf_empty WithTop.sInf_empty @[simp] theorem WithTop.iInf_empty [IsEmpty ι] [InfSet α] (f : ι → WithTop α) : ⨅ i, f i = ⊤ := by rw [iInf, range_eq_empty, WithTop.sInf_empty] #align with_top.cinfi_empty WithTop.iInf_empty theorem WithTop.coe_sInf' [InfSet α] {s : Set α} (hs : s.Nonempty) (h's : BddBelow s) : ↑(sInf s) = (sInf ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by obtain ⟨x, hx⟩ := hs change _ = ite _ _ _ split_ifs with h · rcases h with h1 | h2 · cases h1 (mem_image_of_mem _ hx) · exact (h2 (Monotone.map_bddBelow coe_mono h's)).elim · rw [preimage_image_eq] exact Option.some_injective _ #align with_top.coe_Inf' WithTop.coe_sInf' -- Porting note: the mathlib3 proof uses `range_comp` in the opposite direction and -- does not need `rfl`. @[norm_cast] theorem WithTop.coe_iInf [Nonempty ι] [InfSet α] {f : ι → α} (hf : BddBelow (range f)) : ↑(⨅ i, f i) = (⨅ i, f i : WithTop α) := by rw [iInf, iInf, WithTop.coe_sInf' (range_nonempty f) hf, ← range_comp] rfl #align with_top.coe_infi WithTop.coe_iInf
Mathlib/Order/ConditionallyCompleteLattice/Basic.lean
116
121
theorem WithTop.coe_sSup' [SupSet α] {s : Set α} (hs : BddAbove s) : ↑(sSup s) = (sSup ((fun (a : α) ↦ ↑a) '' s) : WithTop α) := by
change _ = ite _ _ _ rw [if_neg, preimage_image_eq, if_pos hs] · exact Option.some_injective _ · rintro ⟨x, _, ⟨⟩⟩
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov, Patrick Massot, Sébastien Gouëzel -/ import Mathlib.Order.Interval.Set.Disjoint import Mathlib.MeasureTheory.Integral.SetIntegral import Mathlib.MeasureTheory.Measure.Lebesgue.Basic #align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844" /-! # Integral over an interval In this file we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ` if `a ≤ b` and `-∫ x in Ioc b a, f x ∂μ` if `b ≤ a`. ## Implementation notes ### Avoiding `if`, `min`, and `max` In order to avoid `if`s in the definition, we define `IntervalIntegrable f μ a b` as `integrable_on f (Ioc a b) μ ∧ integrable_on f (Ioc b a) μ`. For any `a`, `b` one of these intervals is empty and the other coincides with `Set.uIoc a b = Set.Ioc (min a b) (max a b)`. Similarly, we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`. Again, for any `a`, `b` one of these integrals is zero, and the other gives the expected result. This way some properties can be translated from integrals over sets without dealing with the cases `a ≤ b` and `b ≤ a` separately. ### Choice of the interval We use integral over `Set.uIoc a b = Set.Ioc (min a b) (max a b)` instead of one of the other three possible intervals with the same endpoints for two reasons: * this way `∫ x in a..b, f x ∂μ + ∫ x in b..c, f x ∂μ = ∫ x in a..c, f x ∂μ` holds whenever `f` is integrable on each interval; in particular, it works even if the measure `μ` has an atom at `b`; this rules out `Set.Ioo` and `Set.Icc` intervals; * with this definition for a probability measure `μ`, the integral `∫ x in a..b, 1 ∂μ` equals the difference $F_μ(b)-F_μ(a)$, where $F_μ(a)=μ(-∞, a]$ is the [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) of `μ`. ## Tags integral -/ noncomputable section open scoped Classical open MeasureTheory Set Filter Function open scoped Classical Topology Filter ENNReal Interval NNReal variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E] /-! ### Integrability on an interval -/ /-- A function `f` is called *interval integrable* with respect to a measure `μ` on an unordered interval `a..b` if it is integrable on both intervals `(a, b]` and `(b, a]`. One of these intervals is always empty, so this property is equivalent to `f` being integrable on `(min a b, max a b]`. -/ def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop := IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ #align interval_integrable IntervalIntegrable /-! ## Basic iff's for `IntervalIntegrable` -/ section variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} /-- A function is interval integrable with respect to a given measure `μ` on `a..b` if and only if it is integrable on `uIoc a b` with respect to `μ`. This is an equivalent definition of `IntervalIntegrable`. -/ theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable] #align interval_integrable_iff intervalIntegrable_iff /-- If a function is interval integrable with respect to a given measure `μ` on `a..b` then it is integrable on `uIoc a b` with respect to `μ`. -/ theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ := intervalIntegrable_iff.mp h #align interval_integrable.def IntervalIntegrable.def' theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by rw [intervalIntegrable_iff, uIoc_of_le hab] #align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le theorem intervalIntegrable_iff' [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff' intervalIntegrable_iff' theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b) {μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc] #align interval_integrable_iff_integrable_Icc_of_le intervalIntegrable_iff_integrableOn_Icc_of_le theorem intervalIntegrable_iff_integrableOn_Ico_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ico a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ico] theorem intervalIntegrable_iff_integrableOn_Ioo_of_le [NoAtoms μ] (hab : a ≤ b) : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioo a b) μ := by rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioo] /-- If a function is integrable with respect to a given measure `μ` then it is interval integrable with respect to `μ` on `uIcc a b`. -/ theorem MeasureTheory.Integrable.intervalIntegrable (hf : Integrable f μ) : IntervalIntegrable f μ a b := ⟨hf.integrableOn, hf.integrableOn⟩ #align measure_theory.integrable.interval_integrable MeasureTheory.Integrable.intervalIntegrable theorem MeasureTheory.IntegrableOn.intervalIntegrable (hf : IntegrableOn f [[a, b]] μ) : IntervalIntegrable f μ a b := ⟨MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc), MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc')⟩ #align measure_theory.integrable_on.interval_integrable MeasureTheory.IntegrableOn.intervalIntegrable theorem intervalIntegrable_const_iff {c : E} : IntervalIntegrable (fun _ => c) μ a b ↔ c = 0 ∨ μ (Ι a b) < ∞ := by simp only [intervalIntegrable_iff, integrableOn_const] #align interval_integrable_const_iff intervalIntegrable_const_iff @[simp] theorem intervalIntegrable_const [IsLocallyFiniteMeasure μ] {c : E} : IntervalIntegrable (fun _ => c) μ a b := intervalIntegrable_const_iff.2 <| Or.inr measure_Ioc_lt_top #align interval_integrable_const intervalIntegrable_const end /-! ## Basic properties of interval integrability - interval integrability is symmetric, reflexive, transitive - monotonicity and strong measurability of the interval integral - if `f` is interval integrable, so are its absolute value and norm - arithmetic properties -/ namespace IntervalIntegrable section variable {f : ℝ → E} {a b c d : ℝ} {μ ν : Measure ℝ} @[symm] nonrec theorem symm (h : IntervalIntegrable f μ a b) : IntervalIntegrable f μ b a := h.symm #align interval_integrable.symm IntervalIntegrable.symm @[refl, simp] -- Porting note: added `simp` theorem refl : IntervalIntegrable f μ a a := by constructor <;> simp #align interval_integrable.refl IntervalIntegrable.refl @[trans] theorem trans {a b c : ℝ} (hab : IntervalIntegrable f μ a b) (hbc : IntervalIntegrable f μ b c) : IntervalIntegrable f μ a c := ⟨(hab.1.union hbc.1).mono_set Ioc_subset_Ioc_union_Ioc, (hbc.2.union hab.2).mono_set Ioc_subset_Ioc_union_Ioc⟩ #align interval_integrable.trans IntervalIntegrable.trans theorem trans_iterate_Ico {a : ℕ → ℝ} {m n : ℕ} (hmn : m ≤ n) (hint : ∀ k ∈ Ico m n, IntervalIntegrable f μ (a k) (a <| k + 1)) : IntervalIntegrable f μ (a m) (a n) := by revert hint refine Nat.le_induction ?_ ?_ n hmn · simp · intro p hp IH h exact (IH fun k hk => h k (Ico_subset_Ico_right p.le_succ hk)).trans (h p (by simp [hp])) #align interval_integrable.trans_iterate_Ico IntervalIntegrable.trans_iterate_Ico theorem trans_iterate {a : ℕ → ℝ} {n : ℕ} (hint : ∀ k < n, IntervalIntegrable f μ (a k) (a <| k + 1)) : IntervalIntegrable f μ (a 0) (a n) := trans_iterate_Ico bot_le fun k hk => hint k hk.2 #align interval_integrable.trans_iterate IntervalIntegrable.trans_iterate theorem neg (h : IntervalIntegrable f μ a b) : IntervalIntegrable (-f) μ a b := ⟨h.1.neg, h.2.neg⟩ #align interval_integrable.neg IntervalIntegrable.neg theorem norm (h : IntervalIntegrable f μ a b) : IntervalIntegrable (fun x => ‖f x‖) μ a b := ⟨h.1.norm, h.2.norm⟩ #align interval_integrable.norm IntervalIntegrable.norm theorem intervalIntegrable_norm_iff {f : ℝ → E} {μ : Measure ℝ} {a b : ℝ} (hf : AEStronglyMeasurable f (μ.restrict (Ι a b))) : IntervalIntegrable (fun t => ‖f t‖) μ a b ↔ IntervalIntegrable f μ a b := by simp_rw [intervalIntegrable_iff, IntegrableOn]; exact integrable_norm_iff hf #align interval_integrable.interval_integrable_norm_iff IntervalIntegrable.intervalIntegrable_norm_iff theorem abs {f : ℝ → ℝ} (h : IntervalIntegrable f μ a b) : IntervalIntegrable (fun x => |f x|) μ a b := h.norm #align interval_integrable.abs IntervalIntegrable.abs theorem mono (hf : IntervalIntegrable f ν a b) (h1 : [[c, d]] ⊆ [[a, b]]) (h2 : μ ≤ ν) : IntervalIntegrable f μ c d := intervalIntegrable_iff.mpr <| hf.def'.mono (uIoc_subset_uIoc_of_uIcc_subset_uIcc h1) h2 #align interval_integrable.mono IntervalIntegrable.mono theorem mono_measure (hf : IntervalIntegrable f ν a b) (h : μ ≤ ν) : IntervalIntegrable f μ a b := hf.mono Subset.rfl h #align interval_integrable.mono_measure IntervalIntegrable.mono_measure theorem mono_set (hf : IntervalIntegrable f μ a b) (h : [[c, d]] ⊆ [[a, b]]) : IntervalIntegrable f μ c d := hf.mono h le_rfl #align interval_integrable.mono_set IntervalIntegrable.mono_set theorem mono_set_ae (hf : IntervalIntegrable f μ a b) (h : Ι c d ≤ᵐ[μ] Ι a b) : IntervalIntegrable f μ c d := intervalIntegrable_iff.mpr <| hf.def'.mono_set_ae h #align interval_integrable.mono_set_ae IntervalIntegrable.mono_set_ae theorem mono_set' (hf : IntervalIntegrable f μ a b) (hsub : Ι c d ⊆ Ι a b) : IntervalIntegrable f μ c d := hf.mono_set_ae <| eventually_of_forall hsub #align interval_integrable.mono_set' IntervalIntegrable.mono_set' theorem mono_fun [NormedAddCommGroup F] {g : ℝ → F} (hf : IntervalIntegrable f μ a b) (hgm : AEStronglyMeasurable g (μ.restrict (Ι a b))) (hle : (fun x => ‖g x‖) ≤ᵐ[μ.restrict (Ι a b)] fun x => ‖f x‖) : IntervalIntegrable g μ a b := intervalIntegrable_iff.2 <| hf.def'.integrable.mono hgm hle #align interval_integrable.mono_fun IntervalIntegrable.mono_fun theorem mono_fun' {g : ℝ → ℝ} (hg : IntervalIntegrable g μ a b) (hfm : AEStronglyMeasurable f (μ.restrict (Ι a b))) (hle : (fun x => ‖f x‖) ≤ᵐ[μ.restrict (Ι a b)] g) : IntervalIntegrable f μ a b := intervalIntegrable_iff.2 <| hg.def'.integrable.mono' hfm hle #align interval_integrable.mono_fun' IntervalIntegrable.mono_fun' protected theorem aestronglyMeasurable (h : IntervalIntegrable f μ a b) : AEStronglyMeasurable f (μ.restrict (Ioc a b)) := h.1.aestronglyMeasurable #align interval_integrable.ae_strongly_measurable IntervalIntegrable.aestronglyMeasurable protected theorem aestronglyMeasurable' (h : IntervalIntegrable f μ a b) : AEStronglyMeasurable f (μ.restrict (Ioc b a)) := h.2.aestronglyMeasurable #align interval_integrable.ae_strongly_measurable' IntervalIntegrable.aestronglyMeasurable' end variable [NormedRing A] {f g : ℝ → E} {a b : ℝ} {μ : Measure ℝ} theorem smul [NormedField 𝕜] [NormedSpace 𝕜 E] {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ} (h : IntervalIntegrable f μ a b) (r : 𝕜) : IntervalIntegrable (r • f) μ a b := ⟨h.1.smul r, h.2.smul r⟩ #align interval_integrable.smul IntervalIntegrable.smul @[simp] theorem add (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : IntervalIntegrable (fun x => f x + g x) μ a b := ⟨hf.1.add hg.1, hf.2.add hg.2⟩ #align interval_integrable.add IntervalIntegrable.add @[simp] theorem sub (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : IntervalIntegrable (fun x => f x - g x) μ a b := ⟨hf.1.sub hg.1, hf.2.sub hg.2⟩ #align interval_integrable.sub IntervalIntegrable.sub theorem sum (s : Finset ι) {f : ι → ℝ → E} (h : ∀ i ∈ s, IntervalIntegrable (f i) μ a b) : IntervalIntegrable (∑ i ∈ s, f i) μ a b := ⟨integrable_finset_sum' s fun i hi => (h i hi).1, integrable_finset_sum' s fun i hi => (h i hi).2⟩ #align interval_integrable.sum IntervalIntegrable.sum theorem mul_continuousOn {f g : ℝ → A} (hf : IntervalIntegrable f μ a b) (hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => f x * g x) μ a b := by rw [intervalIntegrable_iff] at hf ⊢ exact hf.mul_continuousOn_of_subset hg measurableSet_Ioc isCompact_uIcc Ioc_subset_Icc_self #align interval_integrable.mul_continuous_on IntervalIntegrable.mul_continuousOn theorem continuousOn_mul {f g : ℝ → A} (hf : IntervalIntegrable f μ a b) (hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => g x * f x) μ a b := by rw [intervalIntegrable_iff] at hf ⊢ exact hf.continuousOn_mul_of_subset hg isCompact_uIcc measurableSet_Ioc Ioc_subset_Icc_self #align interval_integrable.continuous_on_mul IntervalIntegrable.continuousOn_mul @[simp] theorem const_mul {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) : IntervalIntegrable (fun x => c * f x) μ a b := hf.continuousOn_mul continuousOn_const #align interval_integrable.const_mul IntervalIntegrable.const_mul @[simp] theorem mul_const {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) : IntervalIntegrable (fun x => f x * c) μ a b := hf.mul_continuousOn continuousOn_const #align interval_integrable.mul_const IntervalIntegrable.mul_const @[simp] theorem div_const {𝕜 : Type*} {f : ℝ → 𝕜} [NormedField 𝕜] (h : IntervalIntegrable f μ a b) (c : 𝕜) : IntervalIntegrable (fun x => f x / c) μ a b := by simpa only [div_eq_mul_inv] using mul_const h c⁻¹ #align interval_integrable.div_const IntervalIntegrable.div_const theorem comp_mul_left (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (c * x)) volume (a / c) (b / c) := by rcases eq_or_ne c 0 with (hc | hc); · rw [hc]; simp rw [intervalIntegrable_iff'] at hf ⊢ have A : MeasurableEmbedding fun x => x * c⁻¹ := (Homeomorph.mulRight₀ _ (inv_ne_zero hc)).closedEmbedding.measurableEmbedding rw [← Real.smul_map_volume_mul_right (inv_ne_zero hc), IntegrableOn, Measure.restrict_smul, integrable_smul_measure (by simpa : ENNReal.ofReal |c⁻¹| ≠ 0) ENNReal.ofReal_ne_top, ← IntegrableOn, MeasurableEmbedding.integrableOn_map_iff A] convert hf using 1 · ext; simp only [comp_apply]; congr 1; field_simp · rw [preimage_mul_const_uIcc (inv_ne_zero hc)]; field_simp [hc] #align interval_integrable.comp_mul_left IntervalIntegrable.comp_mul_left -- Porting note (#10756): new lemma theorem comp_mul_left_iff {c : ℝ} (hc : c ≠ 0) : IntervalIntegrable (fun x ↦ f (c * x)) volume (a / c) (b / c) ↔ IntervalIntegrable f volume a b := ⟨fun h ↦ by simpa [hc] using h.comp_mul_left c⁻¹, (comp_mul_left · c)⟩ theorem comp_mul_right (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (x * c)) volume (a / c) (b / c) := by simpa only [mul_comm] using comp_mul_left hf c #align interval_integrable.comp_mul_right IntervalIntegrable.comp_mul_right theorem comp_add_right (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (x + c)) volume (a - c) (b - c) := by wlog h : a ≤ b generalizing a b · exact IntervalIntegrable.symm (this hf.symm (le_of_not_le h)) rw [intervalIntegrable_iff'] at hf ⊢ have A : MeasurableEmbedding fun x => x + c := (Homeomorph.addRight c).closedEmbedding.measurableEmbedding rw [← map_add_right_eq_self volume c] at hf convert (MeasurableEmbedding.integrableOn_map_iff A).mp hf using 1 rw [preimage_add_const_uIcc] #align interval_integrable.comp_add_right IntervalIntegrable.comp_add_right theorem comp_add_left (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (c + x)) volume (a - c) (b - c) := by simpa only [add_comm] using IntervalIntegrable.comp_add_right hf c #align interval_integrable.comp_add_left IntervalIntegrable.comp_add_left theorem comp_sub_right (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (x - c)) volume (a + c) (b + c) := by simpa only [sub_neg_eq_add] using IntervalIntegrable.comp_add_right hf (-c) #align interval_integrable.comp_sub_right IntervalIntegrable.comp_sub_right theorem iff_comp_neg : IntervalIntegrable f volume a b ↔ IntervalIntegrable (fun x => f (-x)) volume (-a) (-b) := by rw [← comp_mul_left_iff (neg_ne_zero.2 one_ne_zero)]; simp [div_neg] #align interval_integrable.iff_comp_neg IntervalIntegrable.iff_comp_neg theorem comp_sub_left (hf : IntervalIntegrable f volume a b) (c : ℝ) : IntervalIntegrable (fun x => f (c - x)) volume (c - a) (c - b) := by simpa only [neg_sub, ← sub_eq_add_neg] using iff_comp_neg.mp (hf.comp_add_left c) #align interval_integrable.comp_sub_left IntervalIntegrable.comp_sub_left end IntervalIntegrable /-! ## Continuous functions are interval integrable -/ section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] theorem ContinuousOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : ContinuousOn u (uIcc a b)) : IntervalIntegrable u μ a b := (ContinuousOn.integrableOn_Icc hu).intervalIntegrable #align continuous_on.interval_integrable ContinuousOn.intervalIntegrable theorem ContinuousOn.intervalIntegrable_of_Icc {u : ℝ → E} {a b : ℝ} (h : a ≤ b) (hu : ContinuousOn u (Icc a b)) : IntervalIntegrable u μ a b := ContinuousOn.intervalIntegrable ((uIcc_of_le h).symm ▸ hu) #align continuous_on.interval_integrable_of_Icc ContinuousOn.intervalIntegrable_of_Icc /-- A continuous function on `ℝ` is `IntervalIntegrable` with respect to any locally finite measure `ν` on ℝ. -/ theorem Continuous.intervalIntegrable {u : ℝ → E} (hu : Continuous u) (a b : ℝ) : IntervalIntegrable u μ a b := hu.continuousOn.intervalIntegrable #align continuous.interval_integrable Continuous.intervalIntegrable end /-! ## Monotone and antitone functions are integral integrable -/ section variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] [ConditionallyCompleteLinearOrder E] [OrderTopology E] [SecondCountableTopology E] theorem MonotoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : MonotoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := by rw [intervalIntegrable_iff] exact (hu.integrableOn_isCompact isCompact_uIcc).mono_set Ioc_subset_Icc_self #align monotone_on.interval_integrable MonotoneOn.intervalIntegrable theorem AntitoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : AntitoneOn u (uIcc a b)) : IntervalIntegrable u μ a b := hu.dual_right.intervalIntegrable #align antitone_on.interval_integrable AntitoneOn.intervalIntegrable theorem Monotone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone u) : IntervalIntegrable u μ a b := (hu.monotoneOn _).intervalIntegrable #align monotone.interval_integrable Monotone.intervalIntegrable theorem Antitone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Antitone u) : IntervalIntegrable u μ a b := (hu.antitoneOn _).intervalIntegrable #align antitone.interval_integrable Antitone.intervalIntegrable end /-- Let `l'` be a measurably generated filter; let `l` be a of filter such that each `s ∈ l'` eventually includes `Ioc u v` as both `u` and `v` tend to `l`. Let `μ` be a measure finite at `l'`. Suppose that `f : ℝ → E` has a finite limit at `l' ⊓ ae μ`. Then `f` is interval integrable on `u..v` provided that both `u` and `v` tend to `l`. Typeclass instances allow Lean to find `l'` based on `l` but not vice versa, so `apply Tendsto.eventually_intervalIntegrable_ae` will generate goals `Filter ℝ` and `TendstoIxxClass Ioc ?m_1 l'`. -/ theorem Filter.Tendsto.eventually_intervalIntegrable_ae {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := have := (hf.integrableAtFilter_ae hfm hμ).eventually ((hu.Ioc hv).eventually this).and <| (hv.Ioc hu).eventually this #align filter.tendsto.eventually_interval_integrable_ae Filter.Tendsto.eventually_intervalIntegrable_ae /-- Let `l'` be a measurably generated filter; let `l` be a of filter such that each `s ∈ l'` eventually includes `Ioc u v` as both `u` and `v` tend to `l`. Let `μ` be a measure finite at `l'`. Suppose that `f : ℝ → E` has a finite limit at `l`. Then `f` is interval integrable on `u..v` provided that both `u` and `v` tend to `l`. Typeclass instances allow Lean to find `l'` based on `l` but not vice versa, so `apply Tendsto.eventually_intervalIntegrable` will generate goals `Filter ℝ` and `TendstoIxxClass Ioc ?m_1 l'`. -/ theorem Filter.Tendsto.eventually_intervalIntegrable {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f l' (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) := (hf.mono_left inf_le_left).eventually_intervalIntegrable_ae hfm hμ hu hv #align filter.tendsto.eventually_interval_integrable Filter.Tendsto.eventually_intervalIntegrable /-! ### Interval integral: definition and basic properties In this section we define `∫ x in a..b, f x ∂μ` as `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ` and prove some basic properties. -/ variable [CompleteSpace E] [NormedSpace ℝ E] /-- The interval integral `∫ x in a..b, f x ∂μ` is defined as `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`. If `a ≤ b`, then it equals `∫ x in Ioc a b, f x ∂μ`, otherwise it equals `-∫ x in Ioc b a, f x ∂μ`. -/ def intervalIntegral (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : E := (∫ x in Ioc a b, f x ∂μ) - ∫ x in Ioc b a, f x ∂μ #align interval_integral intervalIntegral notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => f)" ∂"μ:70 => intervalIntegral r a b μ notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => intervalIntegral f a b volume) => r namespace intervalIntegral section Basic variable {a b : ℝ} {f g : ℝ → E} {μ : Measure ℝ} @[simp] theorem integral_zero : (∫ _ in a..b, (0 : E) ∂μ) = 0 := by simp [intervalIntegral] #align interval_integral.integral_zero intervalIntegral.integral_zero theorem integral_of_le (h : a ≤ b) : ∫ x in a..b, f x ∂μ = ∫ x in Ioc a b, f x ∂μ := by simp [intervalIntegral, h] #align interval_integral.integral_of_le intervalIntegral.integral_of_le @[simp] theorem integral_same : ∫ x in a..a, f x ∂μ = 0 := sub_self _ #align interval_integral.integral_same intervalIntegral.integral_same theorem integral_symm (a b) : ∫ x in b..a, f x ∂μ = -∫ x in a..b, f x ∂μ := by simp only [intervalIntegral, neg_sub] #align interval_integral.integral_symm intervalIntegral.integral_symm theorem integral_of_ge (h : b ≤ a) : ∫ x in a..b, f x ∂μ = -∫ x in Ioc b a, f x ∂μ := by simp only [integral_symm b, integral_of_le h] #align interval_integral.integral_of_ge intervalIntegral.integral_of_ge theorem intervalIntegral_eq_integral_uIoc (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : ∫ x in a..b, f x ∂μ = (if a ≤ b then 1 else -1 : ℝ) • ∫ x in Ι a b, f x ∂μ := by split_ifs with h · simp only [integral_of_le h, uIoc_of_le h, one_smul] · simp only [integral_of_ge (not_le.1 h).le, uIoc_of_lt (not_le.1 h), neg_one_smul] #align interval_integral.interval_integral_eq_integral_uIoc intervalIntegral.intervalIntegral_eq_integral_uIoc theorem norm_intervalIntegral_eq (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : ‖∫ x in a..b, f x ∂μ‖ = ‖∫ x in Ι a b, f x ∂μ‖ := by simp_rw [intervalIntegral_eq_integral_uIoc, norm_smul] split_ifs <;> simp only [norm_neg, norm_one, one_mul] #align interval_integral.norm_interval_integral_eq intervalIntegral.norm_intervalIntegral_eq theorem abs_intervalIntegral_eq (f : ℝ → ℝ) (a b : ℝ) (μ : Measure ℝ) : |∫ x in a..b, f x ∂μ| = |∫ x in Ι a b, f x ∂μ| := norm_intervalIntegral_eq f a b μ #align interval_integral.abs_interval_integral_eq intervalIntegral.abs_intervalIntegral_eq theorem integral_cases (f : ℝ → E) (a b) : (∫ x in a..b, f x ∂μ) ∈ ({∫ x in Ι a b, f x ∂μ, -∫ x in Ι a b, f x ∂μ} : Set E) := by rw [intervalIntegral_eq_integral_uIoc]; split_ifs <;> simp #align interval_integral.integral_cases intervalIntegral.integral_cases nonrec theorem integral_undef (h : ¬IntervalIntegrable f μ a b) : ∫ x in a..b, f x ∂μ = 0 := by rw [intervalIntegrable_iff] at h rw [intervalIntegral_eq_integral_uIoc, integral_undef h, smul_zero] #align interval_integral.integral_undef intervalIntegral.integral_undef theorem intervalIntegrable_of_integral_ne_zero {a b : ℝ} {f : ℝ → E} {μ : Measure ℝ} (h : (∫ x in a..b, f x ∂μ) ≠ 0) : IntervalIntegrable f μ a b := not_imp_comm.1 integral_undef h #align interval_integral.interval_integrable_of_integral_ne_zero intervalIntegral.intervalIntegrable_of_integral_ne_zero nonrec theorem integral_non_aestronglyMeasurable (hf : ¬AEStronglyMeasurable f (μ.restrict (Ι a b))) : ∫ x in a..b, f x ∂μ = 0 := by rw [intervalIntegral_eq_integral_uIoc, integral_non_aestronglyMeasurable hf, smul_zero] #align interval_integral.integral_non_ae_strongly_measurable intervalIntegral.integral_non_aestronglyMeasurable theorem integral_non_aestronglyMeasurable_of_le (h : a ≤ b) (hf : ¬AEStronglyMeasurable f (μ.restrict (Ioc a b))) : ∫ x in a..b, f x ∂μ = 0 := integral_non_aestronglyMeasurable <| by rwa [uIoc_of_le h] #align interval_integral.integral_non_ae_strongly_measurable_of_le intervalIntegral.integral_non_aestronglyMeasurable_of_le theorem norm_integral_min_max (f : ℝ → E) : ‖∫ x in min a b..max a b, f x ∂μ‖ = ‖∫ x in a..b, f x ∂μ‖ := by cases le_total a b <;> simp [*, integral_symm a b] #align interval_integral.norm_integral_min_max intervalIntegral.norm_integral_min_max theorem norm_integral_eq_norm_integral_Ioc (f : ℝ → E) : ‖∫ x in a..b, f x ∂μ‖ = ‖∫ x in Ι a b, f x ∂μ‖ := by rw [← norm_integral_min_max, integral_of_le min_le_max, uIoc] #align interval_integral.norm_integral_eq_norm_integral_Ioc intervalIntegral.norm_integral_eq_norm_integral_Ioc theorem abs_integral_eq_abs_integral_uIoc (f : ℝ → ℝ) : |∫ x in a..b, f x ∂μ| = |∫ x in Ι a b, f x ∂μ| := norm_integral_eq_norm_integral_Ioc f #align interval_integral.abs_integral_eq_abs_integral_uIoc intervalIntegral.abs_integral_eq_abs_integral_uIoc theorem norm_integral_le_integral_norm_Ioc : ‖∫ x in a..b, f x ∂μ‖ ≤ ∫ x in Ι a b, ‖f x‖ ∂μ := calc ‖∫ x in a..b, f x ∂μ‖ = ‖∫ x in Ι a b, f x ∂μ‖ := norm_integral_eq_norm_integral_Ioc f _ ≤ ∫ x in Ι a b, ‖f x‖ ∂μ := norm_integral_le_integral_norm f #align interval_integral.norm_integral_le_integral_norm_Ioc intervalIntegral.norm_integral_le_integral_norm_Ioc theorem norm_integral_le_abs_integral_norm : ‖∫ x in a..b, f x ∂μ‖ ≤ |∫ x in a..b, ‖f x‖ ∂μ| := by simp only [← Real.norm_eq_abs, norm_integral_eq_norm_integral_Ioc] exact le_trans (norm_integral_le_integral_norm _) (le_abs_self _) #align interval_integral.norm_integral_le_abs_integral_norm intervalIntegral.norm_integral_le_abs_integral_norm theorem norm_integral_le_integral_norm (h : a ≤ b) : ‖∫ x in a..b, f x ∂μ‖ ≤ ∫ x in a..b, ‖f x‖ ∂μ := norm_integral_le_integral_norm_Ioc.trans_eq <| by rw [uIoc_of_le h, integral_of_le h] #align interval_integral.norm_integral_le_integral_norm intervalIntegral.norm_integral_le_integral_norm nonrec theorem norm_integral_le_of_norm_le {g : ℝ → ℝ} (h : ∀ᵐ t ∂μ.restrict <| Ι a b, ‖f t‖ ≤ g t) (hbound : IntervalIntegrable g μ a b) : ‖∫ t in a..b, f t ∂μ‖ ≤ |∫ t in a..b, g t ∂μ| := by simp_rw [norm_intervalIntegral_eq, abs_intervalIntegral_eq, abs_eq_self.mpr (integral_nonneg_of_ae <| h.mono fun _t ht => (norm_nonneg _).trans ht), norm_integral_le_of_norm_le hbound.def' h] #align interval_integral.norm_integral_le_of_norm_le intervalIntegral.norm_integral_le_of_norm_le theorem norm_integral_le_of_norm_le_const_ae {a b C : ℝ} {f : ℝ → E} (h : ∀ᵐ x, x ∈ Ι a b → ‖f x‖ ≤ C) : ‖∫ x in a..b, f x‖ ≤ C * |b - a| := by rw [norm_integral_eq_norm_integral_Ioc] convert norm_setIntegral_le_of_norm_le_const_ae'' _ measurableSet_Ioc h using 1 · rw [Real.volume_Ioc, max_sub_min_eq_abs, ENNReal.toReal_ofReal (abs_nonneg _)] · simp only [Real.volume_Ioc, ENNReal.ofReal_lt_top] #align interval_integral.norm_integral_le_of_norm_le_const_ae intervalIntegral.norm_integral_le_of_norm_le_const_ae theorem norm_integral_le_of_norm_le_const {a b C : ℝ} {f : ℝ → E} (h : ∀ x ∈ Ι a b, ‖f x‖ ≤ C) : ‖∫ x in a..b, f x‖ ≤ C * |b - a| := norm_integral_le_of_norm_le_const_ae <| eventually_of_forall h #align interval_integral.norm_integral_le_of_norm_le_const intervalIntegral.norm_integral_le_of_norm_le_const @[simp] nonrec theorem integral_add (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : ∫ x in a..b, f x + g x ∂μ = (∫ x in a..b, f x ∂μ) + ∫ x in a..b, g x ∂μ := by simp only [intervalIntegral_eq_integral_uIoc, integral_add hf.def' hg.def', smul_add] #align interval_integral.integral_add intervalIntegral.integral_add nonrec theorem integral_finset_sum {ι} {s : Finset ι} {f : ι → ℝ → E} (h : ∀ i ∈ s, IntervalIntegrable (f i) μ a b) : ∫ x in a..b, ∑ i ∈ s, f i x ∂μ = ∑ i ∈ s, ∫ x in a..b, f i x ∂μ := by simp only [intervalIntegral_eq_integral_uIoc, integral_finset_sum s fun i hi => (h i hi).def', Finset.smul_sum] #align interval_integral.integral_finset_sum intervalIntegral.integral_finset_sum @[simp] nonrec theorem integral_neg : ∫ x in a..b, -f x ∂μ = -∫ x in a..b, f x ∂μ := by simp only [intervalIntegral, integral_neg]; abel #align interval_integral.integral_neg intervalIntegral.integral_neg @[simp] theorem integral_sub (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) : ∫ x in a..b, f x - g x ∂μ = (∫ x in a..b, f x ∂μ) - ∫ x in a..b, g x ∂μ := by simpa only [sub_eq_add_neg] using (integral_add hf hg.neg).trans (congr_arg _ integral_neg) #align interval_integral.integral_sub intervalIntegral.integral_sub @[simp] nonrec theorem integral_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℝ 𝕜 E] (r : 𝕜) (f : ℝ → E) : ∫ x in a..b, r • f x ∂μ = r • ∫ x in a..b, f x ∂μ := by simp only [intervalIntegral, integral_smul, smul_sub] #align interval_integral.integral_smul intervalIntegral.integral_smul @[simp] nonrec theorem integral_smul_const {𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 E] (f : ℝ → 𝕜) (c : E) : ∫ x in a..b, f x • c ∂μ = (∫ x in a..b, f x ∂μ) • c := by simp only [intervalIntegral_eq_integral_uIoc, integral_smul_const, smul_assoc] #align interval_integral.integral_smul_const intervalIntegral.integral_smul_const @[simp] theorem integral_const_mul {𝕜 : Type*} [RCLike 𝕜] (r : 𝕜) (f : ℝ → 𝕜) : ∫ x in a..b, r * f x ∂μ = r * ∫ x in a..b, f x ∂μ := integral_smul r f #align interval_integral.integral_const_mul intervalIntegral.integral_const_mul @[simp] theorem integral_mul_const {𝕜 : Type*} [RCLike 𝕜] (r : 𝕜) (f : ℝ → 𝕜) : ∫ x in a..b, f x * r ∂μ = (∫ x in a..b, f x ∂μ) * r := by simpa only [mul_comm r] using integral_const_mul r f #align interval_integral.integral_mul_const intervalIntegral.integral_mul_const @[simp] theorem integral_div {𝕜 : Type*} [RCLike 𝕜] (r : 𝕜) (f : ℝ → 𝕜) : ∫ x in a..b, f x / r ∂μ = (∫ x in a..b, f x ∂μ) / r := by simpa only [div_eq_mul_inv] using integral_mul_const r⁻¹ f #align interval_integral.integral_div intervalIntegral.integral_div theorem integral_const' (c : E) : ∫ _ in a..b, c ∂μ = ((μ <| Ioc a b).toReal - (μ <| Ioc b a).toReal) • c := by simp only [intervalIntegral, setIntegral_const, sub_smul] #align interval_integral.integral_const' intervalIntegral.integral_const' @[simp] theorem integral_const (c : E) : ∫ _ in a..b, c = (b - a) • c := by simp only [integral_const', Real.volume_Ioc, ENNReal.toReal_ofReal', ← neg_sub b, max_zero_sub_eq_self] #align interval_integral.integral_const intervalIntegral.integral_const nonrec theorem integral_smul_measure (c : ℝ≥0∞) : ∫ x in a..b, f x ∂c • μ = c.toReal • ∫ x in a..b, f x ∂μ := by simp only [intervalIntegral, Measure.restrict_smul, integral_smul_measure, smul_sub] #align interval_integral.integral_smul_measure intervalIntegral.integral_smul_measure end Basic -- Porting note (#11215): TODO: add `Complex.ofReal` version of `_root_.integral_ofReal` nonrec theorem _root_.RCLike.intervalIntegral_ofReal {𝕜 : Type*} [RCLike 𝕜] {a b : ℝ} {μ : Measure ℝ} {f : ℝ → ℝ} : (∫ x in a..b, (f x : 𝕜) ∂μ) = ↑(∫ x in a..b, f x ∂μ) := by simp only [intervalIntegral, integral_ofReal, RCLike.ofReal_sub] @[deprecated (since := "2024-04-06")] alias RCLike.interval_integral_ofReal := RCLike.intervalIntegral_ofReal nonrec theorem integral_ofReal {a b : ℝ} {μ : Measure ℝ} {f : ℝ → ℝ} : (∫ x in a..b, (f x : ℂ) ∂μ) = ↑(∫ x in a..b, f x ∂μ) := RCLike.intervalIntegral_ofReal #align interval_integral.integral_of_real intervalIntegral.integral_ofReal section ContinuousLinearMap variable {a b : ℝ} {μ : Measure ℝ} {f : ℝ → E} variable [RCLike 𝕜] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F] open ContinuousLinearMap theorem _root_.ContinuousLinearMap.intervalIntegral_apply {a b : ℝ} {φ : ℝ → F →L[𝕜] E} (hφ : IntervalIntegrable φ μ a b) (v : F) : (∫ x in a..b, φ x ∂μ) v = ∫ x in a..b, φ x v ∂μ := by simp_rw [intervalIntegral_eq_integral_uIoc, ← integral_apply hφ.def' v, coe_smul', Pi.smul_apply] #align continuous_linear_map.interval_integral_apply ContinuousLinearMap.intervalIntegral_apply variable [NormedSpace ℝ F] [CompleteSpace F] theorem _root_.ContinuousLinearMap.intervalIntegral_comp_comm (L : E →L[𝕜] F) (hf : IntervalIntegrable f μ a b) : (∫ x in a..b, L (f x) ∂μ) = L (∫ x in a..b, f x ∂μ) := by simp_rw [intervalIntegral, L.integral_comp_comm hf.1, L.integral_comp_comm hf.2, L.map_sub] #align continuous_linear_map.interval_integral_comp_comm ContinuousLinearMap.intervalIntegral_comp_comm end ContinuousLinearMap /-! ## Basic arithmetic Includes addition, scalar multiplication and affine transformations. -/ section Comp variable {a b c d : ℝ} (f : ℝ → E) /-! Porting note: some `@[simp]` attributes in this section were removed to make the `simpNF` linter happy. TODO: find out if these lemmas are actually good or bad `simp` lemmas. -/ -- Porting note (#10618): was @[simp] theorem integral_comp_mul_right (hc : c ≠ 0) : (∫ x in a..b, f (x * c)) = c⁻¹ • ∫ x in a * c..b * c, f x := by have A : MeasurableEmbedding fun x => x * c := (Homeomorph.mulRight₀ c hc).closedEmbedding.measurableEmbedding conv_rhs => rw [← Real.smul_map_volume_mul_right hc] simp_rw [integral_smul_measure, intervalIntegral, A.setIntegral_map, ENNReal.toReal_ofReal (abs_nonneg c)] cases' hc.lt_or_lt with h h · simp [h, mul_div_cancel_right₀, hc, abs_of_neg, Measure.restrict_congr_set (α := ℝ) (μ := volume) Ico_ae_eq_Ioc] · simp [h, mul_div_cancel_right₀, hc, abs_of_pos] #align interval_integral.integral_comp_mul_right intervalIntegral.integral_comp_mul_right -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_right (c) : (c • ∫ x in a..b, f (x * c)) = ∫ x in a * c..b * c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_right] #align interval_integral.smul_integral_comp_mul_right intervalIntegral.smul_integral_comp_mul_right -- Porting note (#10618): was @[simp] theorem integral_comp_mul_left (hc : c ≠ 0) : (∫ x in a..b, f (c * x)) = c⁻¹ • ∫ x in c * a..c * b, f x := by simpa only [mul_comm c] using integral_comp_mul_right f hc #align interval_integral.integral_comp_mul_left intervalIntegral.integral_comp_mul_left -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_left (c) : (c • ∫ x in a..b, f (c * x)) = ∫ x in c * a..c * b, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_left] #align interval_integral.smul_integral_comp_mul_left intervalIntegral.smul_integral_comp_mul_left -- Porting note (#10618): was @[simp] theorem integral_comp_div (hc : c ≠ 0) : (∫ x in a..b, f (x / c)) = c • ∫ x in a / c..b / c, f x := by simpa only [inv_inv] using integral_comp_mul_right f (inv_ne_zero hc) #align interval_integral.integral_comp_div intervalIntegral.integral_comp_div -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_div (c) : (c⁻¹ • ∫ x in a..b, f (x / c)) = ∫ x in a / c..b / c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_div] #align interval_integral.inv_smul_integral_comp_div intervalIntegral.inv_smul_integral_comp_div -- Porting note (#10618): was @[simp] theorem integral_comp_add_right (d) : (∫ x in a..b, f (x + d)) = ∫ x in a + d..b + d, f x := have A : MeasurableEmbedding fun x => x + d := (Homeomorph.addRight d).closedEmbedding.measurableEmbedding calc (∫ x in a..b, f (x + d)) = ∫ x in a + d..b + d, f x ∂Measure.map (fun x => x + d) volume := by simp [intervalIntegral, A.setIntegral_map] _ = ∫ x in a + d..b + d, f x := by rw [map_add_right_eq_self] #align interval_integral.integral_comp_add_right intervalIntegral.integral_comp_add_right -- Porting note (#10618): was @[simp] nonrec theorem integral_comp_add_left (d) : (∫ x in a..b, f (d + x)) = ∫ x in d + a..d + b, f x := by simpa only [add_comm d] using integral_comp_add_right f d #align interval_integral.integral_comp_add_left intervalIntegral.integral_comp_add_left -- Porting note (#10618): was @[simp] theorem integral_comp_mul_add (hc : c ≠ 0) (d) : (∫ x in a..b, f (c * x + d)) = c⁻¹ • ∫ x in c * a + d..c * b + d, f x := by rw [← integral_comp_add_right, ← integral_comp_mul_left _ hc] #align interval_integral.integral_comp_mul_add intervalIntegral.integral_comp_mul_add -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_add (c d) : (c • ∫ x in a..b, f (c * x + d)) = ∫ x in c * a + d..c * b + d, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_add] #align interval_integral.smul_integral_comp_mul_add intervalIntegral.smul_integral_comp_mul_add -- Porting note (#10618): was @[simp] theorem integral_comp_add_mul (hc : c ≠ 0) (d) : (∫ x in a..b, f (d + c * x)) = c⁻¹ • ∫ x in d + c * a..d + c * b, f x := by rw [← integral_comp_add_left, ← integral_comp_mul_left _ hc] #align interval_integral.integral_comp_add_mul intervalIntegral.integral_comp_add_mul -- Porting note (#10618): was @[simp] theorem smul_integral_comp_add_mul (c d) : (c • ∫ x in a..b, f (d + c * x)) = ∫ x in d + c * a..d + c * b, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_add_mul] #align interval_integral.smul_integral_comp_add_mul intervalIntegral.smul_integral_comp_add_mul -- Porting note (#10618): was @[simp] theorem integral_comp_div_add (hc : c ≠ 0) (d) : (∫ x in a..b, f (x / c + d)) = c • ∫ x in a / c + d..b / c + d, f x := by simpa only [div_eq_inv_mul, inv_inv] using integral_comp_mul_add f (inv_ne_zero hc) d #align interval_integral.integral_comp_div_add intervalIntegral.integral_comp_div_add -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_div_add (c d) : (c⁻¹ • ∫ x in a..b, f (x / c + d)) = ∫ x in a / c + d..b / c + d, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_div_add] #align interval_integral.inv_smul_integral_comp_div_add intervalIntegral.inv_smul_integral_comp_div_add -- Porting note (#10618): was @[simp] theorem integral_comp_add_div (hc : c ≠ 0) (d) : (∫ x in a..b, f (d + x / c)) = c • ∫ x in d + a / c..d + b / c, f x := by simpa only [div_eq_inv_mul, inv_inv] using integral_comp_add_mul f (inv_ne_zero hc) d #align interval_integral.integral_comp_add_div intervalIntegral.integral_comp_add_div -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_add_div (c d) : (c⁻¹ • ∫ x in a..b, f (d + x / c)) = ∫ x in d + a / c..d + b / c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_add_div] #align interval_integral.inv_smul_integral_comp_add_div intervalIntegral.inv_smul_integral_comp_add_div -- Porting note (#10618): was @[simp] theorem integral_comp_mul_sub (hc : c ≠ 0) (d) : (∫ x in a..b, f (c * x - d)) = c⁻¹ • ∫ x in c * a - d..c * b - d, f x := by simpa only [sub_eq_add_neg] using integral_comp_mul_add f hc (-d) #align interval_integral.integral_comp_mul_sub intervalIntegral.integral_comp_mul_sub -- Porting note (#10618): was @[simp] theorem smul_integral_comp_mul_sub (c d) : (c • ∫ x in a..b, f (c * x - d)) = ∫ x in c * a - d..c * b - d, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_mul_sub] #align interval_integral.smul_integral_comp_mul_sub intervalIntegral.smul_integral_comp_mul_sub -- Porting note (#10618): was @[simp] theorem integral_comp_sub_mul (hc : c ≠ 0) (d) : (∫ x in a..b, f (d - c * x)) = c⁻¹ • ∫ x in d - c * b..d - c * a, f x := by simp only [sub_eq_add_neg, neg_mul_eq_neg_mul] rw [integral_comp_add_mul f (neg_ne_zero.mpr hc) d, integral_symm] simp only [inv_neg, smul_neg, neg_neg, neg_smul] #align interval_integral.integral_comp_sub_mul intervalIntegral.integral_comp_sub_mul -- Porting note (#10618): was @[simp] theorem smul_integral_comp_sub_mul (c d) : (c • ∫ x in a..b, f (d - c * x)) = ∫ x in d - c * b..d - c * a, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_sub_mul] #align interval_integral.smul_integral_comp_sub_mul intervalIntegral.smul_integral_comp_sub_mul -- Porting note (#10618): was @[simp] theorem integral_comp_div_sub (hc : c ≠ 0) (d) : (∫ x in a..b, f (x / c - d)) = c • ∫ x in a / c - d..b / c - d, f x := by simpa only [div_eq_inv_mul, inv_inv] using integral_comp_mul_sub f (inv_ne_zero hc) d #align interval_integral.integral_comp_div_sub intervalIntegral.integral_comp_div_sub -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_div_sub (c d) : (c⁻¹ • ∫ x in a..b, f (x / c - d)) = ∫ x in a / c - d..b / c - d, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_div_sub] #align interval_integral.inv_smul_integral_comp_div_sub intervalIntegral.inv_smul_integral_comp_div_sub -- Porting note (#10618): was @[simp] theorem integral_comp_sub_div (hc : c ≠ 0) (d) : (∫ x in a..b, f (d - x / c)) = c • ∫ x in d - b / c..d - a / c, f x := by simpa only [div_eq_inv_mul, inv_inv] using integral_comp_sub_mul f (inv_ne_zero hc) d #align interval_integral.integral_comp_sub_div intervalIntegral.integral_comp_sub_div -- Porting note (#10618): was @[simp] theorem inv_smul_integral_comp_sub_div (c d) : (c⁻¹ • ∫ x in a..b, f (d - x / c)) = ∫ x in d - b / c..d - a / c, f x := by by_cases hc : c = 0 <;> simp [hc, integral_comp_sub_div] #align interval_integral.inv_smul_integral_comp_sub_div intervalIntegral.inv_smul_integral_comp_sub_div -- Porting note (#10618): was @[simp] theorem integral_comp_sub_right (d) : (∫ x in a..b, f (x - d)) = ∫ x in a - d..b - d, f x := by simpa only [sub_eq_add_neg] using integral_comp_add_right f (-d) #align interval_integral.integral_comp_sub_right intervalIntegral.integral_comp_sub_right -- Porting note (#10618): was @[simp] theorem integral_comp_sub_left (d) : (∫ x in a..b, f (d - x)) = ∫ x in d - b..d - a, f x := by simpa only [one_mul, one_smul, inv_one] using integral_comp_sub_mul f one_ne_zero d #align interval_integral.integral_comp_sub_left intervalIntegral.integral_comp_sub_left -- Porting note (#10618): was @[simp] theorem integral_comp_neg : (∫ x in a..b, f (-x)) = ∫ x in -b..-a, f x := by simpa only [zero_sub] using integral_comp_sub_left f 0 #align interval_integral.integral_comp_neg intervalIntegral.integral_comp_neg end Comp /-! ### Integral is an additive function of the interval In this section we prove that `∫ x in a..b, f x ∂μ + ∫ x in b..c, f x ∂μ = ∫ x in a..c, f x ∂μ` as well as a few other identities trivially equivalent to this one. We also prove that `∫ x in a..b, f x ∂μ = ∫ x, f x ∂μ` provided that `support f ⊆ Ioc a b`. -/ section OrderClosedTopology variable {a b c d : ℝ} {f g : ℝ → E} {μ : Measure ℝ} /-- If two functions are equal in the relevant interval, their interval integrals are also equal. -/ theorem integral_congr {a b : ℝ} (h : EqOn f g [[a, b]]) : ∫ x in a..b, f x ∂μ = ∫ x in a..b, g x ∂μ := by rcases le_total a b with hab | hab <;> simpa [hab, integral_of_le, integral_of_ge] using setIntegral_congr measurableSet_Ioc (h.mono Ioc_subset_Icc_self) #align interval_integral.integral_congr intervalIntegral.integral_congr theorem integral_add_adjacent_intervals_cancel (hab : IntervalIntegrable f μ a b) (hbc : IntervalIntegrable f μ b c) : (((∫ x in a..b, f x ∂μ) + ∫ x in b..c, f x ∂μ) + ∫ x in c..a, f x ∂μ) = 0 := by have hac := hab.trans hbc simp only [intervalIntegral, sub_add_sub_comm, sub_eq_zero] iterate 4 rw [← integral_union] · suffices Ioc a b ∪ Ioc b c ∪ Ioc c a = Ioc b a ∪ Ioc c b ∪ Ioc a c by rw [this] rw [Ioc_union_Ioc_union_Ioc_cycle, union_right_comm, Ioc_union_Ioc_union_Ioc_cycle, min_left_comm, max_left_comm] all_goals simp [*, MeasurableSet.union, measurableSet_Ioc, Ioc_disjoint_Ioc_same, Ioc_disjoint_Ioc_same.symm, hab.1, hab.2, hbc.1, hbc.2, hac.1, hac.2] #align interval_integral.integral_add_adjacent_intervals_cancel intervalIntegral.integral_add_adjacent_intervals_cancel theorem integral_add_adjacent_intervals (hab : IntervalIntegrable f μ a b) (hbc : IntervalIntegrable f μ b c) : ((∫ x in a..b, f x ∂μ) + ∫ x in b..c, f x ∂μ) = ∫ x in a..c, f x ∂μ := by rw [← add_neg_eq_zero, ← integral_symm, integral_add_adjacent_intervals_cancel hab hbc] #align interval_integral.integral_add_adjacent_intervals intervalIntegral.integral_add_adjacent_intervals theorem sum_integral_adjacent_intervals_Ico {a : ℕ → ℝ} {m n : ℕ} (hmn : m ≤ n) (hint : ∀ k ∈ Ico m n, IntervalIntegrable f μ (a k) (a <| k + 1)) : ∑ k ∈ Finset.Ico m n, ∫ x in a k..a <| k + 1, f x ∂μ = ∫ x in a m..a n, f x ∂μ := by revert hint refine Nat.le_induction ?_ ?_ n hmn · simp · intro p hmp IH h rw [Finset.sum_Ico_succ_top hmp, IH, integral_add_adjacent_intervals] · refine IntervalIntegrable.trans_iterate_Ico hmp fun k hk => h k ?_ exact (Ico_subset_Ico le_rfl (Nat.le_succ _)) hk · apply h simp [hmp] · intro k hk exact h _ (Ico_subset_Ico_right p.le_succ hk) #align interval_integral.sum_integral_adjacent_intervals_Ico intervalIntegral.sum_integral_adjacent_intervals_Ico theorem sum_integral_adjacent_intervals {a : ℕ → ℝ} {n : ℕ} (hint : ∀ k < n, IntervalIntegrable f μ (a k) (a <| k + 1)) : ∑ k ∈ Finset.range n, ∫ x in a k..a <| k + 1, f x ∂μ = ∫ x in (a 0)..(a n), f x ∂μ := by rw [← Nat.Ico_zero_eq_range] exact sum_integral_adjacent_intervals_Ico (zero_le n) fun k hk => hint k hk.2 #align interval_integral.sum_integral_adjacent_intervals intervalIntegral.sum_integral_adjacent_intervals theorem integral_interval_sub_left (hab : IntervalIntegrable f μ a b) (hac : IntervalIntegrable f μ a c) : ((∫ x in a..b, f x ∂μ) - ∫ x in a..c, f x ∂μ) = ∫ x in c..b, f x ∂μ := sub_eq_of_eq_add' <| Eq.symm <| integral_add_adjacent_intervals hac (hac.symm.trans hab) #align interval_integral.integral_interval_sub_left intervalIntegral.integral_interval_sub_left theorem integral_interval_add_interval_comm (hab : IntervalIntegrable f μ a b) (hcd : IntervalIntegrable f μ c d) (hac : IntervalIntegrable f μ a c) : ((∫ x in a..b, f x ∂μ) + ∫ x in c..d, f x ∂μ) = (∫ x in a..d, f x ∂μ) + ∫ x in c..b, f x ∂μ := by rw [← integral_add_adjacent_intervals hac hcd, add_assoc, add_left_comm, integral_add_adjacent_intervals hac (hac.symm.trans hab), add_comm] #align interval_integral.integral_interval_add_interval_comm intervalIntegral.integral_interval_add_interval_comm theorem integral_interval_sub_interval_comm (hab : IntervalIntegrable f μ a b) (hcd : IntervalIntegrable f μ c d) (hac : IntervalIntegrable f μ a c) : ((∫ x in a..b, f x ∂μ) - ∫ x in c..d, f x ∂μ) = (∫ x in a..c, f x ∂μ) - ∫ x in b..d, f x ∂μ := by simp only [sub_eq_add_neg, ← integral_symm, integral_interval_add_interval_comm hab hcd.symm (hac.trans hcd)] #align interval_integral.integral_interval_sub_interval_comm intervalIntegral.integral_interval_sub_interval_comm theorem integral_interval_sub_interval_comm' (hab : IntervalIntegrable f μ a b) (hcd : IntervalIntegrable f μ c d) (hac : IntervalIntegrable f μ a c) : ((∫ x in a..b, f x ∂μ) - ∫ x in c..d, f x ∂μ) = (∫ x in d..b, f x ∂μ) - ∫ x in c..a, f x ∂μ := by rw [integral_interval_sub_interval_comm hab hcd hac, integral_symm b d, integral_symm a c, sub_neg_eq_add, sub_eq_neg_add] #align interval_integral.integral_interval_sub_interval_comm' intervalIntegral.integral_interval_sub_interval_comm'
Mathlib/MeasureTheory/Integral/IntervalIntegral.lean
990
996
theorem integral_Iic_sub_Iic (ha : IntegrableOn f (Iic a) μ) (hb : IntegrableOn f (Iic b) μ) : ((∫ x in Iic b, f x ∂μ) - ∫ x in Iic a, f x ∂μ) = ∫ x in a..b, f x ∂μ := by
wlog hab : a ≤ b generalizing a b · rw [integral_symm, ← this hb ha (le_of_not_le hab), neg_sub] rw [sub_eq_iff_eq_add', integral_of_le hab, ← integral_union (Iic_disjoint_Ioc le_rfl), Iic_union_Ioc_eq_Iic hab] exacts [measurableSet_Ioc, ha, hb.mono_set fun _ => And.right]
/- Copyright (c) 2018 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis -/ import Mathlib.Algebra.Order.Field.Power import Mathlib.NumberTheory.Padics.PadicVal #align_import number_theory.padics.padic_norm from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7" /-! # p-adic norm This file defines the `p`-adic norm on `ℚ`. The `p`-adic valuation on `ℚ` is the difference of the multiplicities of `p` in the numerator and denominator of `q`. This function obeys the standard properties of a valuation, with the appropriate assumptions on `p`. The valuation induces a norm on `ℚ`. This norm is a nonarchimedean absolute value. It takes values in {0} ∪ {1/p^k | k ∈ ℤ}. ## Implementation notes Much, but not all, of this file assumes that `p` is prime. This assumption is inferred automatically by taking `[Fact p.Prime]` as a type class argument. ## References * [F. Q. Gouvêa, *p-adic numbers*][gouvea1997] * [R. Y. Lewis, *A formal proof of Hensel's lemma over the p-adic integers*][lewis2019] * <https://en.wikipedia.org/wiki/P-adic_number> ## Tags p-adic, p adic, padic, norm, valuation -/ /-- If `q ≠ 0`, the `p`-adic norm of a rational `q` is `p ^ (-padicValRat p q)`. If `q = 0`, the `p`-adic norm of `q` is `0`. -/ def padicNorm (p : ℕ) (q : ℚ) : ℚ := if q = 0 then 0 else (p : ℚ) ^ (-padicValRat p q) #align padic_norm padicNorm namespace padicNorm open padicValRat variable {p : ℕ} /-- Unfolds the definition of the `p`-adic norm of `q` when `q ≠ 0`. -/ @[simp] protected theorem eq_zpow_of_nonzero {q : ℚ} (hq : q ≠ 0) : padicNorm p q = (p : ℚ) ^ (-padicValRat p q) := by simp [hq, padicNorm] #align padic_norm.eq_zpow_of_nonzero padicNorm.eq_zpow_of_nonzero /-- The `p`-adic norm is nonnegative. -/ protected theorem nonneg (q : ℚ) : 0 ≤ padicNorm p q := if hq : q = 0 then by simp [hq, padicNorm] else by unfold padicNorm split_ifs apply zpow_nonneg exact mod_cast Nat.zero_le _ #align padic_norm.nonneg padicNorm.nonneg /-- The `p`-adic norm of `0` is `0`. -/ @[simp] protected theorem zero : padicNorm p 0 = 0 := by simp [padicNorm] #align padic_norm.zero padicNorm.zero /-- The `p`-adic norm of `1` is `1`. -/ -- @[simp] -- Porting note (#10618): simp can prove this protected theorem one : padicNorm p 1 = 1 := by simp [padicNorm] #align padic_norm.one padicNorm.one /-- The `p`-adic norm of `p` is `p⁻¹` if `p > 1`. See also `padicNorm.padicNorm_p_of_prime` for a version assuming `p` is prime. -/ theorem padicNorm_p (hp : 1 < p) : padicNorm p p = (p : ℚ)⁻¹ := by simp [padicNorm, (pos_of_gt hp).ne', padicValNat.self hp] #align padic_norm.padic_norm_p padicNorm.padicNorm_p /-- The `p`-adic norm of `p` is `p⁻¹` if `p` is prime. See also `padicNorm.padicNorm_p` for a version assuming `1 < p`. -/ @[simp] theorem padicNorm_p_of_prime [Fact p.Prime] : padicNorm p p = (p : ℚ)⁻¹ := padicNorm_p <| Nat.Prime.one_lt Fact.out #align padic_norm.padic_norm_p_of_prime padicNorm.padicNorm_p_of_prime /-- The `p`-adic norm of `q` is `1` if `q` is prime and not equal to `p`. -/ theorem padicNorm_of_prime_of_ne {q : ℕ} [p_prime : Fact p.Prime] [q_prime : Fact q.Prime] (neq : p ≠ q) : padicNorm p q = 1 := by have p : padicValRat p q = 0 := mod_cast padicValNat_primes neq rw [padicNorm, p] simp [q_prime.1.ne_zero] #align padic_norm.padic_norm_of_prime_of_ne padicNorm.padicNorm_of_prime_of_ne /-- The `p`-adic norm of `p` is less than `1` if `1 < p`. See also `padicNorm.padicNorm_p_lt_one_of_prime` for a version assuming `p` is prime. -/ theorem padicNorm_p_lt_one (hp : 1 < p) : padicNorm p p < 1 := by rw [padicNorm_p hp, inv_lt_one_iff] exact mod_cast Or.inr hp #align padic_norm.padic_norm_p_lt_one padicNorm.padicNorm_p_lt_one /-- The `p`-adic norm of `p` is less than `1` if `p` is prime. See also `padicNorm.padicNorm_p_lt_one` for a version assuming `1 < p`. -/ theorem padicNorm_p_lt_one_of_prime [Fact p.Prime] : padicNorm p p < 1 := padicNorm_p_lt_one <| Nat.Prime.one_lt Fact.out #align padic_norm.padic_norm_p_lt_one_of_prime padicNorm.padicNorm_p_lt_one_of_prime /-- `padicNorm p q` takes discrete values `p ^ -z` for `z : ℤ`. -/ protected theorem values_discrete {q : ℚ} (hq : q ≠ 0) : ∃ z : ℤ, padicNorm p q = (p : ℚ) ^ (-z) := ⟨padicValRat p q, by simp [padicNorm, hq]⟩ #align padic_norm.values_discrete padicNorm.values_discrete /-- `padicNorm p` is symmetric. -/ @[simp] protected theorem neg (q : ℚ) : padicNorm p (-q) = padicNorm p q := if hq : q = 0 then by simp [hq] else by simp [padicNorm, hq] #align padic_norm.neg padicNorm.neg variable [hp : Fact p.Prime] /-- If `q ≠ 0`, then `padicNorm p q ≠ 0`. -/ protected theorem nonzero {q : ℚ} (hq : q ≠ 0) : padicNorm p q ≠ 0 := by rw [padicNorm.eq_zpow_of_nonzero hq] apply zpow_ne_zero exact mod_cast ne_of_gt hp.1.pos #align padic_norm.nonzero padicNorm.nonzero /-- If the `p`-adic norm of `q` is 0, then `q` is `0`. -/ theorem zero_of_padicNorm_eq_zero {q : ℚ} (h : padicNorm p q = 0) : q = 0 := by apply by_contradiction; intro hq unfold padicNorm at h; rw [if_neg hq] at h apply absurd h apply zpow_ne_zero exact mod_cast hp.1.ne_zero #align padic_norm.zero_of_padic_norm_eq_zero padicNorm.zero_of_padicNorm_eq_zero /-- The `p`-adic norm is multiplicative. -/ @[simp] protected theorem mul (q r : ℚ) : padicNorm p (q * r) = padicNorm p q * padicNorm p r := if hq : q = 0 then by simp [hq] else if hr : r = 0 then by simp [hr] else by have : (p : ℚ) ≠ 0 := by simp [hp.1.ne_zero] simp [padicNorm, *, padicValRat.mul, zpow_add₀ this, mul_comm] #align padic_norm.mul padicNorm.mul /-- The `p`-adic norm respects division. -/ @[simp] protected theorem div (q r : ℚ) : padicNorm p (q / r) = padicNorm p q / padicNorm p r := if hr : r = 0 then by simp [hr] else eq_div_of_mul_eq (padicNorm.nonzero hr) (by rw [← padicNorm.mul, div_mul_cancel₀ _ hr]) #align padic_norm.div padicNorm.div /-- The `p`-adic norm of an integer is at most `1`. -/ protected theorem of_int (z : ℤ) : padicNorm p z ≤ 1 := if hz : z = 0 then by simp [hz, zero_le_one] else by unfold padicNorm rw [if_neg _] · refine zpow_le_one_of_nonpos ?_ ?_ · exact mod_cast le_of_lt hp.1.one_lt · rw [padicValRat.of_int, neg_nonpos] norm_cast simp exact mod_cast hz #align padic_norm.of_int padicNorm.of_int private theorem nonarchimedean_aux {q r : ℚ} (h : padicValRat p q ≤ padicValRat p r) : padicNorm p (q + r) ≤ max (padicNorm p q) (padicNorm p r) := have hnqp : padicNorm p q ≥ 0 := padicNorm.nonneg _ have hnrp : padicNorm p r ≥ 0 := padicNorm.nonneg _ if hq : q = 0 then by simp [hq, max_eq_right hnrp, le_max_right] else if hr : r = 0 then by simp [hr, max_eq_left hnqp, le_max_left] else if hqr : q + r = 0 then le_trans (by simpa [hqr] using hnqp) (le_max_left _ _) else by unfold padicNorm; split_ifs apply le_max_iff.2 left apply zpow_le_of_le · exact mod_cast le_of_lt hp.1.one_lt · apply neg_le_neg have : padicValRat p q = min (padicValRat p q) (padicValRat p r) := (min_eq_left h).symm rw [this] exact min_le_padicValRat_add hqr /-- The `p`-adic norm is nonarchimedean: the norm of `p + q` is at most the max of the norm of `p` and the norm of `q`. -/ protected theorem nonarchimedean {q r : ℚ} : padicNorm p (q + r) ≤ max (padicNorm p q) (padicNorm p r) := by wlog hle : padicValRat p q ≤ padicValRat p r generalizing q r · rw [add_comm, max_comm] exact this (le_of_not_le hle) exact nonarchimedean_aux hle #align padic_norm.nonarchimedean padicNorm.nonarchimedean /-- The `p`-adic norm respects the triangle inequality: the norm of `p + q` is at most the norm of `p` plus the norm of `q`. -/ theorem triangle_ineq (q r : ℚ) : padicNorm p (q + r) ≤ padicNorm p q + padicNorm p r := calc padicNorm p (q + r) ≤ max (padicNorm p q) (padicNorm p r) := padicNorm.nonarchimedean _ ≤ padicNorm p q + padicNorm p r := max_le_add_of_nonneg (padicNorm.nonneg _) (padicNorm.nonneg _) #align padic_norm.triangle_ineq padicNorm.triangle_ineq /-- The `p`-adic norm of a difference is at most the max of each component. Restates the archimedean property of the `p`-adic norm. -/ protected theorem sub {q r : ℚ} : padicNorm p (q - r) ≤ max (padicNorm p q) (padicNorm p r) := by rw [sub_eq_add_neg, ← padicNorm.neg r] exact padicNorm.nonarchimedean #align padic_norm.sub padicNorm.sub /-- If the `p`-adic norms of `q` and `r` are different, then the norm of `q + r` is equal to the max of the norms of `q` and `r`. -/ theorem add_eq_max_of_ne {q r : ℚ} (hne : padicNorm p q ≠ padicNorm p r) : padicNorm p (q + r) = max (padicNorm p q) (padicNorm p r) := by wlog hlt : padicNorm p r < padicNorm p q · rw [add_comm, max_comm] exact this hne.symm (hne.lt_or_lt.resolve_right hlt) have : padicNorm p q ≤ max (padicNorm p (q + r)) (padicNorm p r) := calc padicNorm p q = padicNorm p (q + r + (-r)) := by ring_nf _ ≤ max (padicNorm p (q + r)) (padicNorm p (-r)) := padicNorm.nonarchimedean _ = max (padicNorm p (q + r)) (padicNorm p r) := by simp have hnge : padicNorm p r ≤ padicNorm p (q + r) := by apply le_of_not_gt intro hgt rw [max_eq_right_of_lt hgt] at this exact not_lt_of_ge this hlt have : padicNorm p q ≤ padicNorm p (q + r) := by rwa [max_eq_left hnge] at this apply _root_.le_antisymm · apply padicNorm.nonarchimedean · rwa [max_eq_left_of_lt hlt] #align padic_norm.add_eq_max_of_ne padicNorm.add_eq_max_of_ne /-- The `p`-adic norm is an absolute value: positive-definite and multiplicative, satisfying the triangle inequality. -/ instance : IsAbsoluteValue (padicNorm p) where abv_nonneg' := padicNorm.nonneg abv_eq_zero' := ⟨zero_of_padicNorm_eq_zero, fun hx ↦ by simp [hx]⟩ abv_add' := padicNorm.triangle_ineq abv_mul' := padicNorm.mul theorem dvd_iff_norm_le {n : ℕ} {z : ℤ} : ↑(p ^ n) ∣ z ↔ padicNorm p z ≤ (p : ℚ) ^ (-n : ℤ) := by unfold padicNorm; split_ifs with hz · norm_cast at hz simp [hz] · rw [zpow_le_iff_le, neg_le_neg_iff, padicValRat.of_int, padicValInt.of_ne_one_ne_zero hp.1.ne_one _] · norm_cast rw [← PartENat.coe_le_coe, PartENat.natCast_get, ← multiplicity.pow_dvd_iff_le_multiplicity, Nat.cast_pow] exact mod_cast hz · exact mod_cast hp.1.one_lt #align padic_norm.dvd_iff_norm_le padicNorm.dvd_iff_norm_le /-- The `p`-adic norm of an integer `m` is one iff `p` doesn't divide `m`. -/ theorem int_eq_one_iff (m : ℤ) : padicNorm p m = 1 ↔ ¬(p : ℤ) ∣ m := by nth_rw 2 [← pow_one p] simp only [dvd_iff_norm_le, Int.cast_natCast, Nat.cast_one, zpow_neg, zpow_one, not_le] constructor · intro h rw [h, inv_lt_one_iff_of_pos] <;> norm_cast · exact Nat.Prime.one_lt Fact.out · exact Nat.Prime.pos Fact.out · simp only [padicNorm] split_ifs · rw [inv_lt_zero, ← Nat.cast_zero, Nat.cast_lt] intro h exact (Nat.not_lt_zero p h).elim · have : 1 < (p : ℚ) := by norm_cast; exact Nat.Prime.one_lt (Fact.out : Nat.Prime p) rw [← zpow_neg_one, zpow_lt_iff_lt this] have : 0 ≤ padicValRat p m := by simp only [of_int, Nat.cast_nonneg] intro h rw [← zpow_zero (p : ℚ), zpow_inj] <;> linarith #align padic_norm.int_eq_one_iff padicNorm.int_eq_one_iff theorem int_lt_one_iff (m : ℤ) : padicNorm p m < 1 ↔ (p : ℤ) ∣ m := by rw [← not_iff_not, ← int_eq_one_iff, eq_iff_le_not_lt] simp only [padicNorm.of_int, true_and_iff] #align padic_norm.int_lt_one_iff padicNorm.int_lt_one_iff theorem of_nat (m : ℕ) : padicNorm p m ≤ 1 := padicNorm.of_int (m : ℤ) #align padic_norm.of_nat padicNorm.of_nat /-- The `p`-adic norm of a natural `m` is one iff `p` doesn't divide `m`. -/ theorem nat_eq_one_iff (m : ℕ) : padicNorm p m = 1 ↔ ¬p ∣ m := by rw [← Int.natCast_dvd_natCast, ← int_eq_one_iff, Int.cast_natCast] #align padic_norm.nat_eq_one_iff padicNorm.nat_eq_one_iff theorem nat_lt_one_iff (m : ℕ) : padicNorm p m < 1 ↔ p ∣ m := by rw [← Int.natCast_dvd_natCast, ← int_lt_one_iff, Int.cast_natCast] #align padic_norm.nat_lt_one_iff padicNorm.nat_lt_one_iff /-- If a rational is not a p-adic integer, it is not an integer. -/ theorem not_int_of_not_padic_int (p : ℕ) {a : ℚ} [hp : Fact (Nat.Prime p)] (H : 1 < padicNorm p a) : ¬ a.isInt := by contrapose! H rw [Rat.eq_num_of_isInt H] apply padicNorm.of_int theorem sum_lt {α : Type*} {F : α → ℚ} {t : ℚ} {s : Finset α} : s.Nonempty → (∀ i ∈ s, padicNorm p (F i) < t) → padicNorm p (∑ i ∈ s, F i) < t := by classical refine s.induction_on (by rintro ⟨-, ⟨⟩⟩) ?_ rintro a S haS IH - ht by_cases hs : S.Nonempty · rw [Finset.sum_insert haS] exact lt_of_le_of_lt padicNorm.nonarchimedean (max_lt (ht a (Finset.mem_insert_self a S)) (IH hs fun b hb ↦ ht b (Finset.mem_insert_of_mem hb))) · simp_all #align padic_norm.sum_lt padicNorm.sum_lt
Mathlib/NumberTheory/Padics/PadicNorm.lean
327
338
theorem sum_le {α : Type*} {F : α → ℚ} {t : ℚ} {s : Finset α} : s.Nonempty → (∀ i ∈ s, padicNorm p (F i) ≤ t) → padicNorm p (∑ i ∈ s, F i) ≤ t := by
classical refine s.induction_on (by rintro ⟨-, ⟨⟩⟩) ?_ rintro a S haS IH - ht by_cases hs : S.Nonempty · rw [Finset.sum_insert haS] exact padicNorm.nonarchimedean.trans (max_le (ht a (Finset.mem_insert_self a S)) (IH hs fun b hb ↦ ht b (Finset.mem_insert_of_mem hb))) · simp_all
/- Copyright (c) 2022 Robert Y. Lewis. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Robert Y. Lewis, Heather Macbeth -/ import Mathlib.Algebra.MvPolynomial.Supported import Mathlib.RingTheory.WittVector.Truncated #align_import ring_theory.witt_vector.mul_coeff from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4" /-! # Leading terms of Witt vector multiplication The goal of this file is to study the leading terms of the formula for the `n+1`st coefficient of a product of Witt vectors `x` and `y` over a ring of characteristic `p`. We aim to isolate the `n+1`st coefficients of `x` and `y`, and express the rest of the product in terms of a function of the lower coefficients. For most of this file we work with terms of type `MvPolynomial (Fin 2 × ℕ) ℤ`. We will eventually evaluate them in `k`, but first we must take care of a calculation that needs to happen in characteristic 0. ## Main declarations * `WittVector.nth_mul_coeff`: expresses the coefficient of a product of Witt vectors in terms of the previous coefficients of the multiplicands. -/ noncomputable section namespace WittVector variable (p : ℕ) [hp : Fact p.Prime] variable {k : Type*} [CommRing k] local notation "𝕎" => WittVector p -- Porting note: new notation local notation "𝕄" => MvPolynomial (Fin 2 × ℕ) ℤ open Finset MvPolynomial /-- ``` (∑ i ∈ range n, (y.coeff i)^(p^(n-i)) * p^i.val) * (∑ i ∈ range n, (y.coeff i)^(p^(n-i)) * p^i.val) ``` -/ def wittPolyProd (n : ℕ) : 𝕄 := rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ n) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ n) #align witt_vector.witt_poly_prod WittVector.wittPolyProd theorem wittPolyProd_vars (n : ℕ) : (wittPolyProd p n).vars ⊆ univ ×ˢ range (n + 1) := by rw [wittPolyProd] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_rename _ _) ?_ simp [wittPolynomial_vars, image_subset_iff] #align witt_vector.witt_poly_prod_vars WittVector.wittPolyProd_vars /-- The "remainder term" of `WittVector.wittPolyProd`. See `mul_polyOfInterest_aux2`. -/ def wittPolyProdRemainder (n : ℕ) : 𝕄 := ∑ i ∈ range n, (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) #align witt_vector.witt_poly_prod_remainder WittVector.wittPolyProdRemainder theorem wittPolyProdRemainder_vars (n : ℕ) : (wittPolyProdRemainder p n).vars ⊆ univ ×ˢ range n := by rw [wittPolyProdRemainder] refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ · apply Subset.trans (vars_pow _ _) have : (p : 𝕄) = C (p : ℤ) := by simp only [Int.cast_natCast, eq_intCast] rw [this, vars_C] apply empty_subset · apply Subset.trans (vars_pow _ _) apply Subset.trans (wittMul_vars _ _) apply product_subset_product (Subset.refl _) simp only [mem_range, range_subset] at hx ⊢ exact hx #align witt_vector.witt_poly_prod_remainder_vars WittVector.wittPolyProdRemainder_vars /-- `remainder p n` represents the remainder term from `mul_polyOfInterest_aux3`. `wittPolyProd p (n+1)` will have variables up to `n+1`, but `remainder` will only have variables up to `n`. -/ def remainder (n : ℕ) : 𝕄 := (∑ x ∈ range (n + 1), (rename (Prod.mk 0)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x))) * ∑ x ∈ range (n + 1), (rename (Prod.mk 1)) ((monomial (Finsupp.single x (p ^ (n + 1 - x)))) ((p : ℤ) ^ x)) #align witt_vector.remainder WittVector.remainder theorem remainder_vars (n : ℕ) : (remainder p n).vars ⊆ univ ×ˢ range (n + 1) := by rw [remainder] apply Subset.trans (vars_mul _ _) refine union_subset ?_ ?_ <;> · refine Subset.trans (vars_sum_subset _ _) ?_ rw [biUnion_subset] intro x hx rw [rename_monomial, vars_monomial, Finsupp.mapDomain_single] · apply Subset.trans Finsupp.support_single_subset simpa using mem_range.mp hx · apply pow_ne_zero exact mod_cast hp.out.ne_zero #align witt_vector.remainder_vars WittVector.remainder_vars /-- This is the polynomial whose degree we want to get a handle on. -/ def polyOfInterest (n : ℕ) : 𝕄 := wittMul p (n + 1) + (p : 𝕄) ^ (n + 1) * X (0, n + 1) * X (1, n + 1) - X (0, n + 1) * rename (Prod.mk (1 : Fin 2)) (wittPolynomial p ℤ (n + 1)) - X (1, n + 1) * rename (Prod.mk (0 : Fin 2)) (wittPolynomial p ℤ (n + 1)) #align witt_vector.poly_of_interest WittVector.polyOfInterest theorem mul_polyOfInterest_aux1 (n : ℕ) : ∑ i ∈ range (n + 1), (p : 𝕄) ^ i * wittMul p i ^ p ^ (n - i) = wittPolyProd p n := by simp only [wittPolyProd] convert wittStructureInt_prop p (X (0 : Fin 2) * X 1) n using 1 · simp only [wittPolynomial, wittMul] rw [AlgHom.map_sum] congr 1 with i congr 1 have hsupp : (Finsupp.single i (p ^ (n - i))).support = {i} := by rw [Finsupp.support_eq_singleton] simp only [and_true_iff, Finsupp.single_eq_same, eq_self_iff_true, Ne] exact pow_ne_zero _ hp.out.ne_zero simp only [bind₁_monomial, hsupp, Int.cast_natCast, prod_singleton, eq_intCast, Finsupp.single_eq_same, C_pow, mul_eq_mul_left_iff, true_or_iff, eq_self_iff_true, Int.cast_pow] · simp only [map_mul, bind₁_X_right] #align witt_vector.mul_poly_of_interest_aux1 WittVector.mul_polyOfInterest_aux1
Mathlib/RingTheory/WittVector/MulCoeff.lean
138
142
theorem mul_polyOfInterest_aux2 (n : ℕ) : (p : 𝕄) ^ n * wittMul p n + wittPolyProdRemainder p n = wittPolyProd p n := by
convert mul_polyOfInterest_aux1 p n rw [sum_range_succ, add_comm, Nat.sub_self, pow_zero, pow_one] rfl
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne -/ import Mathlib.MeasureTheory.Integral.SetToL1 #align_import measure_theory.integral.bochner from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Bochner integral The Bochner integral extends the definition of the Lebesgue integral to functions that map from a measure space into a Banach space (complete normed vector space). It is constructed here by extending the integral on simple functions. ## Main definitions The Bochner integral is defined through the extension process described in the file `SetToL1`, which follows these steps: 1. Define the integral of the indicator of a set. This is `weightedSMul μ s x = (μ s).toReal * x`. `weightedSMul μ` is shown to be linear in the value `x` and `DominatedFinMeasAdditive` (defined in the file `SetToL1`) with respect to the set `s`. 2. Define the integral on simple functions of the type `SimpleFunc α E` (notation : `α →ₛ E`) where `E` is a real normed space. (See `SimpleFunc.integral` for details.) 3. Transfer this definition to define the integral on `L1.simpleFunc α E` (notation : `α →₁ₛ[μ] E`), see `L1.simpleFunc.integral`. Show that this integral is a continuous linear map from `α →₁ₛ[μ] E` to `E`. 4. Define the Bochner integral on L1 functions by extending the integral on integrable simple functions `α →₁ₛ[μ] E` using `ContinuousLinearMap.extend` and the fact that the embedding of `α →₁ₛ[μ] E` into `α →₁[μ] E` is dense. 5. Define the Bochner integral on functions as the Bochner integral of its equivalence class in L1 space, if it is in L1, and 0 otherwise. The result of that construction is `∫ a, f a ∂μ`, which is definitionally equal to `setToFun (dominatedFinMeasAdditive_weightedSMul μ) f`. Some basic properties of the integral (like linearity) are particular cases of the properties of `setToFun` (which are described in the file `SetToL1`). ## Main statements 1. Basic properties of the Bochner integral on functions of type `α → E`, where `α` is a measure space and `E` is a real normed space. * `integral_zero` : `∫ 0 ∂μ = 0` * `integral_add` : `∫ x, f x + g x ∂μ = ∫ x, f ∂μ + ∫ x, g x ∂μ` * `integral_neg` : `∫ x, - f x ∂μ = - ∫ x, f x ∂μ` * `integral_sub` : `∫ x, f x - g x ∂μ = ∫ x, f x ∂μ - ∫ x, g x ∂μ` * `integral_smul` : `∫ x, r • f x ∂μ = r • ∫ x, f x ∂μ` * `integral_congr_ae` : `f =ᵐ[μ] g → ∫ x, f x ∂μ = ∫ x, g x ∂μ` * `norm_integral_le_integral_norm` : `‖∫ x, f x ∂μ‖ ≤ ∫ x, ‖f x‖ ∂μ` 2. Basic properties of the Bochner integral on functions of type `α → ℝ`, where `α` is a measure space. * `integral_nonneg_of_ae` : `0 ≤ᵐ[μ] f → 0 ≤ ∫ x, f x ∂μ` * `integral_nonpos_of_ae` : `f ≤ᵐ[μ] 0 → ∫ x, f x ∂μ ≤ 0` * `integral_mono_ae` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ` * `integral_nonneg` : `0 ≤ f → 0 ≤ ∫ x, f x ∂μ` * `integral_nonpos` : `f ≤ 0 → ∫ x, f x ∂μ ≤ 0` * `integral_mono` : `f ≤ᵐ[μ] g → ∫ x, f x ∂μ ≤ ∫ x, g x ∂μ` 3. Propositions connecting the Bochner integral with the integral on `ℝ≥0∞`-valued functions, which is called `lintegral` and has the notation `∫⁻`. * `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` : `∫ x, f x ∂μ = ∫⁻ x, f⁺ x ∂μ - ∫⁻ x, f⁻ x ∂μ`, where `f⁺` is the positive part of `f` and `f⁻` is the negative part of `f`. * `integral_eq_lintegral_of_nonneg_ae` : `0 ≤ᵐ[μ] f → ∫ x, f x ∂μ = ∫⁻ x, f x ∂μ` 4. (In the file `DominatedConvergence`) `tendsto_integral_of_dominated_convergence` : the Lebesgue dominated convergence theorem 5. (In the file `SetIntegral`) integration commutes with continuous linear maps. * `ContinuousLinearMap.integral_comp_comm` * `LinearIsometry.integral_comp_comm` ## Notes Some tips on how to prove a proposition if the API for the Bochner integral is not enough so that you need to unfold the definition of the Bochner integral and go back to simple functions. One method is to use the theorem `Integrable.induction` in the file `SimpleFuncDenseLp` (or one of the related results, like `Lp.induction` for functions in `Lp`), which allows you to prove something for an arbitrary integrable function. Another method is using the following steps. See `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` for a complicated example, which proves that `∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, with the first integral sign being the Bochner integral of a real-valued function `f : α → ℝ`, and second and third integral sign being the integral on `ℝ≥0∞`-valued functions (called `lintegral`). The proof of `integral_eq_lintegral_pos_part_sub_lintegral_neg_part` is scattered in sections with the name `posPart`. Here are the usual steps of proving that a property `p`, say `∫ f = ∫⁻ f⁺ - ∫⁻ f⁻`, holds for all functions : 1. First go to the `L¹` space. For example, if you see `ENNReal.toReal (∫⁻ a, ENNReal.ofReal <| ‖f a‖)`, that is the norm of `f` in `L¹` space. Rewrite using `L1.norm_of_fun_eq_lintegral_norm`. 2. Show that the set `{f ∈ L¹ | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻}` is closed in `L¹` using `isClosed_eq`. 3. Show that the property holds for all simple functions `s` in `L¹` space. Typically, you need to convert various notions to their `SimpleFunc` counterpart, using lemmas like `L1.integral_coe_eq_integral`. 4. Since simple functions are dense in `L¹`, ``` univ = closure {s simple} = closure {s simple | ∫ s = ∫⁻ s⁺ - ∫⁻ s⁻} : the property holds for all simple functions ⊆ closure {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻} = {f | ∫ f = ∫⁻ f⁺ - ∫⁻ f⁻} : closure of a closed set is itself ``` Use `isClosed_property` or `DenseRange.induction_on` for this argument. ## Notations * `α →ₛ E` : simple functions (defined in `MeasureTheory/Integration`) * `α →₁[μ] E` : functions in L1 space, i.e., equivalence classes of integrable functions (defined in `MeasureTheory/LpSpace`) * `α →₁ₛ[μ] E` : simple functions in L1 space, i.e., equivalence classes of integrable simple functions (defined in `MeasureTheory/SimpleFuncDense`) * `∫ a, f a ∂μ` : integral of `f` with respect to a measure `μ` * `∫ a, f a` : integral of `f` with respect to `volume`, the default measure on the ambient type We also define notations for integral on a set, which are described in the file `MeasureTheory/SetIntegral`. Note : `ₛ` is typed using `\_s`. Sometimes it shows as a box if the font is missing. ## Tags Bochner integral, simple function, function space, Lebesgue dominated convergence theorem -/ assert_not_exists Differentiable noncomputable section open scoped Topology NNReal ENNReal MeasureTheory open Set Filter TopologicalSpace ENNReal EMetric namespace MeasureTheory variable {α E F 𝕜 : Type*} section WeightedSMul open ContinuousLinearMap variable [NormedAddCommGroup F] [NormedSpace ℝ F] {m : MeasurableSpace α} {μ : Measure α} /-- Given a set `s`, return the continuous linear map `fun x => (μ s).toReal • x`. The extension of that set function through `setToL1` gives the Bochner integral of L1 functions. -/ def weightedSMul {_ : MeasurableSpace α} (μ : Measure α) (s : Set α) : F →L[ℝ] F := (μ s).toReal • ContinuousLinearMap.id ℝ F #align measure_theory.weighted_smul MeasureTheory.weightedSMul theorem weightedSMul_apply {m : MeasurableSpace α} (μ : Measure α) (s : Set α) (x : F) : weightedSMul μ s x = (μ s).toReal • x := by simp [weightedSMul] #align measure_theory.weighted_smul_apply MeasureTheory.weightedSMul_apply @[simp] theorem weightedSMul_zero_measure {m : MeasurableSpace α} : weightedSMul (0 : Measure α) = (0 : Set α → F →L[ℝ] F) := by ext1; simp [weightedSMul] #align measure_theory.weighted_smul_zero_measure MeasureTheory.weightedSMul_zero_measure @[simp] theorem weightedSMul_empty {m : MeasurableSpace α} (μ : Measure α) : weightedSMul μ ∅ = (0 : F →L[ℝ] F) := by ext1 x; rw [weightedSMul_apply]; simp #align measure_theory.weighted_smul_empty MeasureTheory.weightedSMul_empty theorem weightedSMul_add_measure {m : MeasurableSpace α} (μ ν : Measure α) {s : Set α} (hμs : μ s ≠ ∞) (hνs : ν s ≠ ∞) : (weightedSMul (μ + ν) s : F →L[ℝ] F) = weightedSMul μ s + weightedSMul ν s := by ext1 x push_cast simp_rw [Pi.add_apply, weightedSMul_apply] push_cast rw [Pi.add_apply, ENNReal.toReal_add hμs hνs, add_smul] #align measure_theory.weighted_smul_add_measure MeasureTheory.weightedSMul_add_measure theorem weightedSMul_smul_measure {m : MeasurableSpace α} (μ : Measure α) (c : ℝ≥0∞) {s : Set α} : (weightedSMul (c • μ) s : F →L[ℝ] F) = c.toReal • weightedSMul μ s := by ext1 x push_cast simp_rw [Pi.smul_apply, weightedSMul_apply] push_cast simp_rw [Pi.smul_apply, smul_eq_mul, toReal_mul, smul_smul] #align measure_theory.weighted_smul_smul_measure MeasureTheory.weightedSMul_smul_measure theorem weightedSMul_congr (s t : Set α) (hst : μ s = μ t) : (weightedSMul μ s : F →L[ℝ] F) = weightedSMul μ t := by ext1 x; simp_rw [weightedSMul_apply]; congr 2 #align measure_theory.weighted_smul_congr MeasureTheory.weightedSMul_congr theorem weightedSMul_null {s : Set α} (h_zero : μ s = 0) : (weightedSMul μ s : F →L[ℝ] F) = 0 := by ext1 x; rw [weightedSMul_apply, h_zero]; simp #align measure_theory.weighted_smul_null MeasureTheory.weightedSMul_null theorem weightedSMul_union' (s t : Set α) (ht : MeasurableSet t) (hs_finite : μ s ≠ ∞) (ht_finite : μ t ≠ ∞) (h_inter : s ∩ t = ∅) : (weightedSMul μ (s ∪ t) : F →L[ℝ] F) = weightedSMul μ s + weightedSMul μ t := by ext1 x simp_rw [add_apply, weightedSMul_apply, measure_union (Set.disjoint_iff_inter_eq_empty.mpr h_inter) ht, ENNReal.toReal_add hs_finite ht_finite, add_smul] #align measure_theory.weighted_smul_union' MeasureTheory.weightedSMul_union' @[nolint unusedArguments] theorem weightedSMul_union (s t : Set α) (_hs : MeasurableSet s) (ht : MeasurableSet t) (hs_finite : μ s ≠ ∞) (ht_finite : μ t ≠ ∞) (h_inter : s ∩ t = ∅) : (weightedSMul μ (s ∪ t) : F →L[ℝ] F) = weightedSMul μ s + weightedSMul μ t := weightedSMul_union' s t ht hs_finite ht_finite h_inter #align measure_theory.weighted_smul_union MeasureTheory.weightedSMul_union theorem weightedSMul_smul [NormedField 𝕜] [NormedSpace 𝕜 F] [SMulCommClass ℝ 𝕜 F] (c : 𝕜) (s : Set α) (x : F) : weightedSMul μ s (c • x) = c • weightedSMul μ s x := by simp_rw [weightedSMul_apply, smul_comm] #align measure_theory.weighted_smul_smul MeasureTheory.weightedSMul_smul theorem norm_weightedSMul_le (s : Set α) : ‖(weightedSMul μ s : F →L[ℝ] F)‖ ≤ (μ s).toReal := calc ‖(weightedSMul μ s : F →L[ℝ] F)‖ = ‖(μ s).toReal‖ * ‖ContinuousLinearMap.id ℝ F‖ := norm_smul (μ s).toReal (ContinuousLinearMap.id ℝ F) _ ≤ ‖(μ s).toReal‖ := ((mul_le_mul_of_nonneg_left norm_id_le (norm_nonneg _)).trans (mul_one _).le) _ = abs (μ s).toReal := Real.norm_eq_abs _ _ = (μ s).toReal := abs_eq_self.mpr ENNReal.toReal_nonneg #align measure_theory.norm_weighted_smul_le MeasureTheory.norm_weightedSMul_le theorem dominatedFinMeasAdditive_weightedSMul {_ : MeasurableSpace α} (μ : Measure α) : DominatedFinMeasAdditive μ (weightedSMul μ : Set α → F →L[ℝ] F) 1 := ⟨weightedSMul_union, fun s _ _ => (norm_weightedSMul_le s).trans (one_mul _).symm.le⟩ #align measure_theory.dominated_fin_meas_additive_weighted_smul MeasureTheory.dominatedFinMeasAdditive_weightedSMul theorem weightedSMul_nonneg (s : Set α) (x : ℝ) (hx : 0 ≤ x) : 0 ≤ weightedSMul μ s x := by simp only [weightedSMul, Algebra.id.smul_eq_mul, coe_smul', _root_.id, coe_id', Pi.smul_apply] exact mul_nonneg toReal_nonneg hx #align measure_theory.weighted_smul_nonneg MeasureTheory.weightedSMul_nonneg end WeightedSMul local infixr:25 " →ₛ " => SimpleFunc namespace SimpleFunc section PosPart variable [LinearOrder E] [Zero E] [MeasurableSpace α] /-- Positive part of a simple function. -/ def posPart (f : α →ₛ E) : α →ₛ E := f.map fun b => max b 0 #align measure_theory.simple_func.pos_part MeasureTheory.SimpleFunc.posPart /-- Negative part of a simple function. -/ def negPart [Neg E] (f : α →ₛ E) : α →ₛ E := posPart (-f) #align measure_theory.simple_func.neg_part MeasureTheory.SimpleFunc.negPart theorem posPart_map_norm (f : α →ₛ ℝ) : (posPart f).map norm = posPart f := by ext; rw [map_apply, Real.norm_eq_abs, abs_of_nonneg]; exact le_max_right _ _ #align measure_theory.simple_func.pos_part_map_norm MeasureTheory.SimpleFunc.posPart_map_norm theorem negPart_map_norm (f : α →ₛ ℝ) : (negPart f).map norm = negPart f := by rw [negPart]; exact posPart_map_norm _ #align measure_theory.simple_func.neg_part_map_norm MeasureTheory.SimpleFunc.negPart_map_norm theorem posPart_sub_negPart (f : α →ₛ ℝ) : f.posPart - f.negPart = f := by simp only [posPart, negPart] ext a rw [coe_sub] exact max_zero_sub_eq_self (f a) #align measure_theory.simple_func.pos_part_sub_neg_part MeasureTheory.SimpleFunc.posPart_sub_negPart end PosPart section Integral /-! ### The Bochner integral of simple functions Define the Bochner integral of simple functions of the type `α →ₛ β` where `β` is a normed group, and prove basic property of this integral. -/ open Finset variable [NormedAddCommGroup E] [NormedAddCommGroup F] [NormedSpace ℝ F] {p : ℝ≥0∞} {G F' : Type*} [NormedAddCommGroup G] [NormedAddCommGroup F'] [NormedSpace ℝ F'] {m : MeasurableSpace α} {μ : Measure α} /-- Bochner integral of simple functions whose codomain is a real `NormedSpace`. This is equal to `∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal • x` (see `integral_eq`). -/ def integral {_ : MeasurableSpace α} (μ : Measure α) (f : α →ₛ F) : F := f.setToSimpleFunc (weightedSMul μ) #align measure_theory.simple_func.integral MeasureTheory.SimpleFunc.integral theorem integral_def {_ : MeasurableSpace α} (μ : Measure α) (f : α →ₛ F) : f.integral μ = f.setToSimpleFunc (weightedSMul μ) := rfl #align measure_theory.simple_func.integral_def MeasureTheory.SimpleFunc.integral_def theorem integral_eq {m : MeasurableSpace α} (μ : Measure α) (f : α →ₛ F) : f.integral μ = ∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal • x := by simp [integral, setToSimpleFunc, weightedSMul_apply] #align measure_theory.simple_func.integral_eq MeasureTheory.SimpleFunc.integral_eq theorem integral_eq_sum_filter [DecidablePred fun x : F => x ≠ 0] {m : MeasurableSpace α} (f : α →ₛ F) (μ : Measure α) : f.integral μ = ∑ x ∈ f.range.filter fun x => x ≠ 0, (μ (f ⁻¹' {x})).toReal • x := by rw [integral_def, setToSimpleFunc_eq_sum_filter]; simp_rw [weightedSMul_apply]; congr #align measure_theory.simple_func.integral_eq_sum_filter MeasureTheory.SimpleFunc.integral_eq_sum_filter /-- The Bochner integral is equal to a sum over any set that includes `f.range` (except `0`). -/ theorem integral_eq_sum_of_subset [DecidablePred fun x : F => x ≠ 0] {f : α →ₛ F} {s : Finset F} (hs : (f.range.filter fun x => x ≠ 0) ⊆ s) : f.integral μ = ∑ x ∈ s, (μ (f ⁻¹' {x})).toReal • x := by rw [SimpleFunc.integral_eq_sum_filter, Finset.sum_subset hs] rintro x - hx; rw [Finset.mem_filter, not_and_or, Ne, Classical.not_not] at hx -- Porting note: reordered for clarity rcases hx.symm with (rfl | hx) · simp rw [SimpleFunc.mem_range] at hx -- Porting note: added simp only [Set.mem_range, not_exists] at hx rw [preimage_eq_empty] <;> simp [Set.disjoint_singleton_left, hx] #align measure_theory.simple_func.integral_eq_sum_of_subset MeasureTheory.SimpleFunc.integral_eq_sum_of_subset @[simp] theorem integral_const {m : MeasurableSpace α} (μ : Measure α) (y : F) : (const α y).integral μ = (μ univ).toReal • y := by classical calc (const α y).integral μ = ∑ z ∈ {y}, (μ (const α y ⁻¹' {z})).toReal • z := integral_eq_sum_of_subset <| (filter_subset _ _).trans (range_const_subset _ _) _ = (μ univ).toReal • y := by simp [Set.preimage] -- Porting note: added `Set.preimage` #align measure_theory.simple_func.integral_const MeasureTheory.SimpleFunc.integral_const @[simp] theorem integral_piecewise_zero {m : MeasurableSpace α} (f : α →ₛ F) (μ : Measure α) {s : Set α} (hs : MeasurableSet s) : (piecewise s hs f 0).integral μ = f.integral (μ.restrict s) := by classical refine (integral_eq_sum_of_subset ?_).trans ((sum_congr rfl fun y hy => ?_).trans (integral_eq_sum_filter _ _).symm) · intro y hy simp only [mem_filter, mem_range, coe_piecewise, coe_zero, piecewise_eq_indicator, mem_range_indicator] at * rcases hy with ⟨⟨rfl, -⟩ | ⟨x, -, rfl⟩, h₀⟩ exacts [(h₀ rfl).elim, ⟨Set.mem_range_self _, h₀⟩] · dsimp rw [Set.piecewise_eq_indicator, indicator_preimage_of_not_mem, Measure.restrict_apply (f.measurableSet_preimage _)] exact fun h₀ => (mem_filter.1 hy).2 (Eq.symm h₀) #align measure_theory.simple_func.integral_piecewise_zero MeasureTheory.SimpleFunc.integral_piecewise_zero /-- Calculate the integral of `g ∘ f : α →ₛ F`, where `f` is an integrable function from `α` to `E` and `g` is a function from `E` to `F`. We require `g 0 = 0` so that `g ∘ f` is integrable. -/ theorem map_integral (f : α →ₛ E) (g : E → F) (hf : Integrable f μ) (hg : g 0 = 0) : (f.map g).integral μ = ∑ x ∈ f.range, ENNReal.toReal (μ (f ⁻¹' {x})) • g x := map_setToSimpleFunc _ weightedSMul_union hf hg #align measure_theory.simple_func.map_integral MeasureTheory.SimpleFunc.map_integral /-- `SimpleFunc.integral` and `SimpleFunc.lintegral` agree when the integrand has type `α →ₛ ℝ≥0∞`. But since `ℝ≥0∞` is not a `NormedSpace`, we need some form of coercion. See `integral_eq_lintegral` for a simpler version. -/ theorem integral_eq_lintegral' {f : α →ₛ E} {g : E → ℝ≥0∞} (hf : Integrable f μ) (hg0 : g 0 = 0) (ht : ∀ b, g b ≠ ∞) : (f.map (ENNReal.toReal ∘ g)).integral μ = ENNReal.toReal (∫⁻ a, g (f a) ∂μ) := by have hf' : f.FinMeasSupp μ := integrable_iff_finMeasSupp.1 hf simp only [← map_apply g f, lintegral_eq_lintegral] rw [map_integral f _ hf, map_lintegral, ENNReal.toReal_sum] · refine Finset.sum_congr rfl fun b _ => ?_ -- Porting note: added `Function.comp_apply` rw [smul_eq_mul, toReal_mul, mul_comm, Function.comp_apply] · rintro a - by_cases a0 : a = 0 · rw [a0, hg0, zero_mul]; exact WithTop.zero_ne_top · apply mul_ne_top (ht a) (hf'.meas_preimage_singleton_ne_zero a0).ne · simp [hg0] #align measure_theory.simple_func.integral_eq_lintegral' MeasureTheory.SimpleFunc.integral_eq_lintegral' variable [NormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace ℝ E] [SMulCommClass ℝ 𝕜 E] theorem integral_congr {f g : α →ₛ E} (hf : Integrable f μ) (h : f =ᵐ[μ] g) : f.integral μ = g.integral μ := setToSimpleFunc_congr (weightedSMul μ) (fun _ _ => weightedSMul_null) weightedSMul_union hf h #align measure_theory.simple_func.integral_congr MeasureTheory.SimpleFunc.integral_congr /-- `SimpleFunc.bintegral` and `SimpleFunc.integral` agree when the integrand has type `α →ₛ ℝ≥0∞`. But since `ℝ≥0∞` is not a `NormedSpace`, we need some form of coercion. -/ theorem integral_eq_lintegral {f : α →ₛ ℝ} (hf : Integrable f μ) (h_pos : 0 ≤ᵐ[μ] f) : f.integral μ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) := by have : f =ᵐ[μ] f.map (ENNReal.toReal ∘ ENNReal.ofReal) := h_pos.mono fun a h => (ENNReal.toReal_ofReal h).symm rw [← integral_eq_lintegral' hf] exacts [integral_congr hf this, ENNReal.ofReal_zero, fun b => ENNReal.ofReal_ne_top] #align measure_theory.simple_func.integral_eq_lintegral MeasureTheory.SimpleFunc.integral_eq_lintegral theorem integral_add {f g : α →ₛ E} (hf : Integrable f μ) (hg : Integrable g μ) : integral μ (f + g) = integral μ f + integral μ g := setToSimpleFunc_add _ weightedSMul_union hf hg #align measure_theory.simple_func.integral_add MeasureTheory.SimpleFunc.integral_add theorem integral_neg {f : α →ₛ E} (hf : Integrable f μ) : integral μ (-f) = -integral μ f := setToSimpleFunc_neg _ weightedSMul_union hf #align measure_theory.simple_func.integral_neg MeasureTheory.SimpleFunc.integral_neg theorem integral_sub {f g : α →ₛ E} (hf : Integrable f μ) (hg : Integrable g μ) : integral μ (f - g) = integral μ f - integral μ g := setToSimpleFunc_sub _ weightedSMul_union hf hg #align measure_theory.simple_func.integral_sub MeasureTheory.SimpleFunc.integral_sub theorem integral_smul (c : 𝕜) {f : α →ₛ E} (hf : Integrable f μ) : integral μ (c • f) = c • integral μ f := setToSimpleFunc_smul _ weightedSMul_union weightedSMul_smul c hf #align measure_theory.simple_func.integral_smul MeasureTheory.SimpleFunc.integral_smul theorem norm_setToSimpleFunc_le_integral_norm (T : Set α → E →L[ℝ] F) {C : ℝ} (hT_norm : ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal) {f : α →ₛ E} (hf : Integrable f μ) : ‖f.setToSimpleFunc T‖ ≤ C * (f.map norm).integral μ := calc ‖f.setToSimpleFunc T‖ ≤ C * ∑ x ∈ f.range, ENNReal.toReal (μ (f ⁻¹' {x})) * ‖x‖ := norm_setToSimpleFunc_le_sum_mul_norm_of_integrable T hT_norm f hf _ = C * (f.map norm).integral μ := by rw [map_integral f norm hf norm_zero]; simp_rw [smul_eq_mul] #align measure_theory.simple_func.norm_set_to_simple_func_le_integral_norm MeasureTheory.SimpleFunc.norm_setToSimpleFunc_le_integral_norm theorem norm_integral_le_integral_norm (f : α →ₛ E) (hf : Integrable f μ) : ‖f.integral μ‖ ≤ (f.map norm).integral μ := by refine (norm_setToSimpleFunc_le_integral_norm _ (fun s _ _ => ?_) hf).trans (one_mul _).le exact (norm_weightedSMul_le s).trans (one_mul _).symm.le #align measure_theory.simple_func.norm_integral_le_integral_norm MeasureTheory.SimpleFunc.norm_integral_le_integral_norm theorem integral_add_measure {ν} (f : α →ₛ E) (hf : Integrable f (μ + ν)) : f.integral (μ + ν) = f.integral μ + f.integral ν := by simp_rw [integral_def] refine setToSimpleFunc_add_left' (weightedSMul μ) (weightedSMul ν) (weightedSMul (μ + ν)) (fun s _ hμνs => ?_) hf rw [lt_top_iff_ne_top, Measure.coe_add, Pi.add_apply, ENNReal.add_ne_top] at hμνs rw [weightedSMul_add_measure _ _ hμνs.1 hμνs.2] #align measure_theory.simple_func.integral_add_measure MeasureTheory.SimpleFunc.integral_add_measure end Integral end SimpleFunc namespace L1 set_option linter.uppercaseLean3 false -- `L1` open AEEqFun Lp.simpleFunc Lp variable [NormedAddCommGroup E] [NormedAddCommGroup F] {m : MeasurableSpace α} {μ : Measure α} namespace SimpleFunc theorem norm_eq_integral (f : α →₁ₛ[μ] E) : ‖f‖ = ((toSimpleFunc f).map norm).integral μ := by rw [norm_eq_sum_mul f, (toSimpleFunc f).map_integral norm (SimpleFunc.integrable f) norm_zero] simp_rw [smul_eq_mul] #align measure_theory.L1.simple_func.norm_eq_integral MeasureTheory.L1.SimpleFunc.norm_eq_integral section PosPart /-- Positive part of a simple function in L1 space. -/ nonrec def posPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := ⟨Lp.posPart (f : α →₁[μ] ℝ), by rcases f with ⟨f, s, hsf⟩ use s.posPart simp only [Subtype.coe_mk, Lp.coe_posPart, ← hsf, AEEqFun.posPart_mk, SimpleFunc.coe_map, mk_eq_mk] -- Porting note: added simp [SimpleFunc.posPart, Function.comp, EventuallyEq.rfl] ⟩ #align measure_theory.L1.simple_func.pos_part MeasureTheory.L1.SimpleFunc.posPart /-- Negative part of a simple function in L1 space. -/ def negPart (f : α →₁ₛ[μ] ℝ) : α →₁ₛ[μ] ℝ := posPart (-f) #align measure_theory.L1.simple_func.neg_part MeasureTheory.L1.SimpleFunc.negPart @[norm_cast] theorem coe_posPart (f : α →₁ₛ[μ] ℝ) : (posPart f : α →₁[μ] ℝ) = Lp.posPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_pos_part MeasureTheory.L1.SimpleFunc.coe_posPart @[norm_cast] theorem coe_negPart (f : α →₁ₛ[μ] ℝ) : (negPart f : α →₁[μ] ℝ) = Lp.negPart (f : α →₁[μ] ℝ) := rfl #align measure_theory.L1.simple_func.coe_neg_part MeasureTheory.L1.SimpleFunc.coe_negPart end PosPart section SimpleFuncIntegral /-! ### The Bochner integral of `L1` Define the Bochner integral on `α →₁ₛ[μ] E` by extension from the simple functions `α →₁ₛ[μ] E`, and prove basic properties of this integral. -/ variable [NormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace ℝ E] [SMulCommClass ℝ 𝕜 E] {F' : Type*} [NormedAddCommGroup F'] [NormedSpace ℝ F'] attribute [local instance] simpleFunc.normedSpace /-- The Bochner integral over simple functions in L1 space. -/ def integral (f : α →₁ₛ[μ] E) : E := (toSimpleFunc f).integral μ #align measure_theory.L1.simple_func.integral MeasureTheory.L1.SimpleFunc.integral theorem integral_eq_integral (f : α →₁ₛ[μ] E) : integral f = (toSimpleFunc f).integral μ := rfl #align measure_theory.L1.simple_func.integral_eq_integral MeasureTheory.L1.SimpleFunc.integral_eq_integral nonrec theorem integral_eq_lintegral {f : α →₁ₛ[μ] ℝ} (h_pos : 0 ≤ᵐ[μ] toSimpleFunc f) : integral f = ENNReal.toReal (∫⁻ a, ENNReal.ofReal ((toSimpleFunc f) a) ∂μ) := by rw [integral, SimpleFunc.integral_eq_lintegral (SimpleFunc.integrable f) h_pos] #align measure_theory.L1.simple_func.integral_eq_lintegral MeasureTheory.L1.SimpleFunc.integral_eq_lintegral theorem integral_eq_setToL1S (f : α →₁ₛ[μ] E) : integral f = setToL1S (weightedSMul μ) f := rfl #align measure_theory.L1.simple_func.integral_eq_set_to_L1s MeasureTheory.L1.SimpleFunc.integral_eq_setToL1S nonrec theorem integral_congr {f g : α →₁ₛ[μ] E} (h : toSimpleFunc f =ᵐ[μ] toSimpleFunc g) : integral f = integral g := SimpleFunc.integral_congr (SimpleFunc.integrable f) h #align measure_theory.L1.simple_func.integral_congr MeasureTheory.L1.SimpleFunc.integral_congr theorem integral_add (f g : α →₁ₛ[μ] E) : integral (f + g) = integral f + integral g := setToL1S_add _ (fun _ _ => weightedSMul_null) weightedSMul_union _ _ #align measure_theory.L1.simple_func.integral_add MeasureTheory.L1.SimpleFunc.integral_add theorem integral_smul (c : 𝕜) (f : α →₁ₛ[μ] E) : integral (c • f) = c • integral f := setToL1S_smul _ (fun _ _ => weightedSMul_null) weightedSMul_union weightedSMul_smul c f #align measure_theory.L1.simple_func.integral_smul MeasureTheory.L1.SimpleFunc.integral_smul theorem norm_integral_le_norm (f : α →₁ₛ[μ] E) : ‖integral f‖ ≤ ‖f‖ := by rw [integral, norm_eq_integral] exact (toSimpleFunc f).norm_integral_le_integral_norm (SimpleFunc.integrable f) #align measure_theory.L1.simple_func.norm_integral_le_norm MeasureTheory.L1.SimpleFunc.norm_integral_le_norm variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E'] [NormedSpace 𝕜 E'] variable (α E μ 𝕜) /-- The Bochner integral over simple functions in L1 space as a continuous linear map. -/ def integralCLM' : (α →₁ₛ[μ] E) →L[𝕜] E := LinearMap.mkContinuous ⟨⟨integral, integral_add⟩, integral_smul⟩ 1 fun f => le_trans (norm_integral_le_norm _) <| by rw [one_mul] #align measure_theory.L1.simple_func.integral_clm' MeasureTheory.L1.SimpleFunc.integralCLM' /-- The Bochner integral over simple functions in L1 space as a continuous linear map over ℝ. -/ def integralCLM : (α →₁ₛ[μ] E) →L[ℝ] E := integralCLM' α E ℝ μ #align measure_theory.L1.simple_func.integral_clm MeasureTheory.L1.SimpleFunc.integralCLM variable {α E μ 𝕜} local notation "Integral" => integralCLM α E μ open ContinuousLinearMap theorem norm_Integral_le_one : ‖Integral‖ ≤ 1 := -- Porting note: Old proof was `LinearMap.mkContinuous_norm_le _ zero_le_one _` LinearMap.mkContinuous_norm_le _ zero_le_one (fun f => by rw [one_mul] exact norm_integral_le_norm f) #align measure_theory.L1.simple_func.norm_Integral_le_one MeasureTheory.L1.SimpleFunc.norm_Integral_le_one section PosPart theorem posPart_toSimpleFunc (f : α →₁ₛ[μ] ℝ) : toSimpleFunc (posPart f) =ᵐ[μ] (toSimpleFunc f).posPart := by have eq : ∀ a, (toSimpleFunc f).posPart a = max ((toSimpleFunc f) a) 0 := fun a => rfl have ae_eq : ∀ᵐ a ∂μ, toSimpleFunc (posPart f) a = max ((toSimpleFunc f) a) 0 := by filter_upwards [toSimpleFunc_eq_toFun (posPart f), Lp.coeFn_posPart (f : α →₁[μ] ℝ), toSimpleFunc_eq_toFun f] with _ _ h₂ h₃ convert h₂ using 1 -- Porting note: added rw [h₃] refine ae_eq.mono fun a h => ?_ rw [h, eq] #align measure_theory.L1.simple_func.pos_part_to_simple_func MeasureTheory.L1.SimpleFunc.posPart_toSimpleFunc theorem negPart_toSimpleFunc (f : α →₁ₛ[μ] ℝ) : toSimpleFunc (negPart f) =ᵐ[μ] (toSimpleFunc f).negPart := by rw [SimpleFunc.negPart, MeasureTheory.SimpleFunc.negPart] filter_upwards [posPart_toSimpleFunc (-f), neg_toSimpleFunc f] intro a h₁ h₂ rw [h₁] show max _ _ = max _ _ rw [h₂] rfl #align measure_theory.L1.simple_func.neg_part_to_simple_func MeasureTheory.L1.SimpleFunc.negPart_toSimpleFunc theorem integral_eq_norm_posPart_sub (f : α →₁ₛ[μ] ℝ) : integral f = ‖posPart f‖ - ‖negPart f‖ := by -- Convert things in `L¹` to their `SimpleFunc` counterpart have ae_eq₁ : (toSimpleFunc f).posPart =ᵐ[μ] (toSimpleFunc (posPart f)).map norm := by filter_upwards [posPart_toSimpleFunc f] with _ h rw [SimpleFunc.map_apply, h] conv_lhs => rw [← SimpleFunc.posPart_map_norm, SimpleFunc.map_apply] -- Convert things in `L¹` to their `SimpleFunc` counterpart have ae_eq₂ : (toSimpleFunc f).negPart =ᵐ[μ] (toSimpleFunc (negPart f)).map norm := by filter_upwards [negPart_toSimpleFunc f] with _ h rw [SimpleFunc.map_apply, h] conv_lhs => rw [← SimpleFunc.negPart_map_norm, SimpleFunc.map_apply] rw [integral, norm_eq_integral, norm_eq_integral, ← SimpleFunc.integral_sub] · show (toSimpleFunc f).integral μ = ((toSimpleFunc (posPart f)).map norm - (toSimpleFunc (negPart f)).map norm).integral μ apply MeasureTheory.SimpleFunc.integral_congr (SimpleFunc.integrable f) filter_upwards [ae_eq₁, ae_eq₂] with _ h₁ h₂ show _ = _ - _ rw [← h₁, ← h₂] have := (toSimpleFunc f).posPart_sub_negPart conv_lhs => rw [← this] rfl · exact (SimpleFunc.integrable f).pos_part.congr ae_eq₁ · exact (SimpleFunc.integrable f).neg_part.congr ae_eq₂ #align measure_theory.L1.simple_func.integral_eq_norm_pos_part_sub MeasureTheory.L1.SimpleFunc.integral_eq_norm_posPart_sub end PosPart end SimpleFuncIntegral end SimpleFunc open SimpleFunc local notation "Integral" => @integralCLM α E _ _ _ _ _ μ _ variable [NormedSpace ℝ E] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℝ 𝕜 E] [NormedSpace ℝ F] [CompleteSpace E] section IntegrationInL1 attribute [local instance] simpleFunc.normedSpace open ContinuousLinearMap variable (𝕜) /-- The Bochner integral in L1 space as a continuous linear map. -/ nonrec def integralCLM' : (α →₁[μ] E) →L[𝕜] E := (integralCLM' α E 𝕜 μ).extend (coeToLp α E 𝕜) (simpleFunc.denseRange one_ne_top) simpleFunc.uniformInducing #align measure_theory.L1.integral_clm' MeasureTheory.L1.integralCLM' variable {𝕜} /-- The Bochner integral in L1 space as a continuous linear map over ℝ. -/ def integralCLM : (α →₁[μ] E) →L[ℝ] E := integralCLM' ℝ #align measure_theory.L1.integral_clm MeasureTheory.L1.integralCLM -- Porting note: added `(E := E)` in several places below. /-- The Bochner integral in L1 space -/ irreducible_def integral (f : α →₁[μ] E) : E := integralCLM (E := E) f #align measure_theory.L1.integral MeasureTheory.L1.integral theorem integral_eq (f : α →₁[μ] E) : integral f = integralCLM (E := E) f := by simp only [integral] #align measure_theory.L1.integral_eq MeasureTheory.L1.integral_eq theorem integral_eq_setToL1 (f : α →₁[μ] E) : integral f = setToL1 (E := E) (dominatedFinMeasAdditive_weightedSMul μ) f := by simp only [integral]; rfl #align measure_theory.L1.integral_eq_set_to_L1 MeasureTheory.L1.integral_eq_setToL1 @[norm_cast] theorem SimpleFunc.integral_L1_eq_integral (f : α →₁ₛ[μ] E) : L1.integral (f : α →₁[μ] E) = SimpleFunc.integral f := by simp only [integral, L1.integral] exact setToL1_eq_setToL1SCLM (dominatedFinMeasAdditive_weightedSMul μ) f #align measure_theory.L1.simple_func.integral_L1_eq_integral MeasureTheory.L1.SimpleFunc.integral_L1_eq_integral variable (α E) @[simp] theorem integral_zero : integral (0 : α →₁[μ] E) = 0 := by simp only [integral] exact map_zero integralCLM #align measure_theory.L1.integral_zero MeasureTheory.L1.integral_zero variable {α E} @[integral_simps] theorem integral_add (f g : α →₁[μ] E) : integral (f + g) = integral f + integral g := by simp only [integral] exact map_add integralCLM f g #align measure_theory.L1.integral_add MeasureTheory.L1.integral_add @[integral_simps] theorem integral_neg (f : α →₁[μ] E) : integral (-f) = -integral f := by simp only [integral] exact map_neg integralCLM f #align measure_theory.L1.integral_neg MeasureTheory.L1.integral_neg @[integral_simps] theorem integral_sub (f g : α →₁[μ] E) : integral (f - g) = integral f - integral g := by simp only [integral] exact map_sub integralCLM f g #align measure_theory.L1.integral_sub MeasureTheory.L1.integral_sub @[integral_simps] theorem integral_smul (c : 𝕜) (f : α →₁[μ] E) : integral (c • f) = c • integral f := by simp only [integral] show (integralCLM' (E := E) 𝕜) (c • f) = c • (integralCLM' (E := E) 𝕜) f exact map_smul (integralCLM' (E := E) 𝕜) c f #align measure_theory.L1.integral_smul MeasureTheory.L1.integral_smul local notation "Integral" => @integralCLM α E _ _ μ _ _ local notation "sIntegral" => @SimpleFunc.integralCLM α E _ _ μ _ theorem norm_Integral_le_one : ‖integralCLM (α := α) (E := E) (μ := μ)‖ ≤ 1 := norm_setToL1_le (dominatedFinMeasAdditive_weightedSMul μ) zero_le_one #align measure_theory.L1.norm_Integral_le_one MeasureTheory.L1.norm_Integral_le_one theorem nnnorm_Integral_le_one : ‖integralCLM (α := α) (E := E) (μ := μ)‖₊ ≤ 1 := norm_Integral_le_one theorem norm_integral_le (f : α →₁[μ] E) : ‖integral f‖ ≤ ‖f‖ := calc ‖integral f‖ = ‖integralCLM (E := E) f‖ := by simp only [integral] _ ≤ ‖integralCLM (α := α) (E := E) (μ := μ)‖ * ‖f‖ := le_opNorm _ _ _ ≤ 1 * ‖f‖ := mul_le_mul_of_nonneg_right norm_Integral_le_one <| norm_nonneg _ _ = ‖f‖ := one_mul _ #align measure_theory.L1.norm_integral_le MeasureTheory.L1.norm_integral_le theorem nnnorm_integral_le (f : α →₁[μ] E) : ‖integral f‖₊ ≤ ‖f‖₊ := norm_integral_le f @[continuity] theorem continuous_integral : Continuous fun f : α →₁[μ] E => integral f := by simp only [integral] exact L1.integralCLM.continuous #align measure_theory.L1.continuous_integral MeasureTheory.L1.continuous_integral section PosPart theorem integral_eq_norm_posPart_sub (f : α →₁[μ] ℝ) : integral f = ‖Lp.posPart f‖ - ‖Lp.negPart f‖ := by -- Use `isClosed_property` and `isClosed_eq` refine @isClosed_property _ _ _ ((↑) : (α →₁ₛ[μ] ℝ) → α →₁[μ] ℝ) (fun f : α →₁[μ] ℝ => integral f = ‖Lp.posPart f‖ - ‖Lp.negPart f‖) (simpleFunc.denseRange one_ne_top) (isClosed_eq ?_ ?_) ?_ f · simp only [integral] exact cont _ · refine Continuous.sub (continuous_norm.comp Lp.continuous_posPart) (continuous_norm.comp Lp.continuous_negPart) -- Show that the property holds for all simple functions in the `L¹` space. · intro s norm_cast exact SimpleFunc.integral_eq_norm_posPart_sub _ #align measure_theory.L1.integral_eq_norm_pos_part_sub MeasureTheory.L1.integral_eq_norm_posPart_sub end PosPart end IntegrationInL1 end L1 /-! ## The Bochner integral on functions Define the Bochner integral on functions generally to be the `L1` Bochner integral, for integrable functions, and 0 otherwise; prove its basic properties. -/ variable [NormedAddCommGroup E] [NormedSpace ℝ E] [hE : CompleteSpace E] [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℝ 𝕜 E] [NormedAddCommGroup F] [NormedSpace ℝ F] [CompleteSpace F] {G : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G] section open scoped Classical /-- The Bochner integral -/ irreducible_def integral {_ : MeasurableSpace α} (μ : Measure α) (f : α → G) : G := if _ : CompleteSpace G then if hf : Integrable f μ then L1.integral (hf.toL1 f) else 0 else 0 #align measure_theory.integral MeasureTheory.integral end /-! In the notation for integrals, an expression like `∫ x, g ‖x‖ ∂μ` will not be parsed correctly, and needs parentheses. We do not set the binding power of `r` to `0`, because then `∫ x, f x = 0` will be parsed incorrectly. -/ @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => integral μ r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)", "r:60:(scoped f => integral volume f) => r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => integral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.integral] notation3 "∫ "(...)" in "s", "r:60:(scoped f => integral (Measure.restrict volume s) f) => r section Properties open ContinuousLinearMap MeasureTheory.SimpleFunc variable {f g : α → E} {m : MeasurableSpace α} {μ : Measure α} theorem integral_eq (f : α → E) (hf : Integrable f μ) : ∫ a, f a ∂μ = L1.integral (hf.toL1 f) := by simp [integral, hE, hf] #align measure_theory.integral_eq MeasureTheory.integral_eq theorem integral_eq_setToFun (f : α → E) : ∫ a, f a ∂μ = setToFun μ (weightedSMul μ) (dominatedFinMeasAdditive_weightedSMul μ) f := by simp only [integral, hE, L1.integral]; rfl #align measure_theory.integral_eq_set_to_fun MeasureTheory.integral_eq_setToFun theorem L1.integral_eq_integral (f : α →₁[μ] E) : L1.integral f = ∫ a, f a ∂μ := by simp only [integral, L1.integral, integral_eq_setToFun] exact (L1.setToFun_eq_setToL1 (dominatedFinMeasAdditive_weightedSMul μ) f).symm set_option linter.uppercaseLean3 false in #align measure_theory.L1.integral_eq_integral MeasureTheory.L1.integral_eq_integral theorem integral_undef {f : α → G} (h : ¬Integrable f μ) : ∫ a, f a ∂μ = 0 := by by_cases hG : CompleteSpace G · simp [integral, hG, h] · simp [integral, hG] #align measure_theory.integral_undef MeasureTheory.integral_undef theorem Integrable.of_integral_ne_zero {f : α → G} (h : ∫ a, f a ∂μ ≠ 0) : Integrable f μ := Not.imp_symm integral_undef h theorem integral_non_aestronglyMeasurable {f : α → G} (h : ¬AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = 0 := integral_undef <| not_and_of_not_left _ h #align measure_theory.integral_non_ae_strongly_measurable MeasureTheory.integral_non_aestronglyMeasurable variable (α G) @[simp] theorem integral_zero : ∫ _ : α, (0 : G) ∂μ = 0 := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_zero (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG] #align measure_theory.integral_zero MeasureTheory.integral_zero @[simp] theorem integral_zero' : integral μ (0 : α → G) = 0 := integral_zero α G #align measure_theory.integral_zero' MeasureTheory.integral_zero' variable {α G} theorem integrable_of_integral_eq_one {f : α → ℝ} (h : ∫ x, f x ∂μ = 1) : Integrable f μ := .of_integral_ne_zero <| h ▸ one_ne_zero #align measure_theory.integrable_of_integral_eq_one MeasureTheory.integrable_of_integral_eq_one theorem integral_add {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a + g a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_add (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] #align measure_theory.integral_add MeasureTheory.integral_add theorem integral_add' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f + g) a ∂μ = ∫ a, f a ∂μ + ∫ a, g a ∂μ := integral_add hf hg #align measure_theory.integral_add' MeasureTheory.integral_add' theorem integral_finset_sum {ι} (s : Finset ι) {f : ι → α → G} (hf : ∀ i ∈ s, Integrable (f i) μ) : ∫ a, ∑ i ∈ s, f i a ∂μ = ∑ i ∈ s, ∫ a, f i a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_finset_sum (dominatedFinMeasAdditive_weightedSMul _) s hf · simp [integral, hG] #align measure_theory.integral_finset_sum MeasureTheory.integral_finset_sum @[integral_simps] theorem integral_neg (f : α → G) : ∫ a, -f a ∂μ = -∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_neg (dominatedFinMeasAdditive_weightedSMul μ) f · simp [integral, hG] #align measure_theory.integral_neg MeasureTheory.integral_neg theorem integral_neg' (f : α → G) : ∫ a, (-f) a ∂μ = -∫ a, f a ∂μ := integral_neg f #align measure_theory.integral_neg' MeasureTheory.integral_neg' theorem integral_sub {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, f a - g a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_sub (dominatedFinMeasAdditive_weightedSMul μ) hf hg · simp [integral, hG] #align measure_theory.integral_sub MeasureTheory.integral_sub theorem integral_sub' {f g : α → G} (hf : Integrable f μ) (hg : Integrable g μ) : ∫ a, (f - g) a ∂μ = ∫ a, f a ∂μ - ∫ a, g a ∂μ := integral_sub hf hg #align measure_theory.integral_sub' MeasureTheory.integral_sub' @[integral_simps] theorem integral_smul [NormedSpace 𝕜 G] [SMulCommClass ℝ 𝕜 G] (c : 𝕜) (f : α → G) : ∫ a, c • f a ∂μ = c • ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_smul (dominatedFinMeasAdditive_weightedSMul μ) weightedSMul_smul c f · simp [integral, hG] #align measure_theory.integral_smul MeasureTheory.integral_smul theorem integral_mul_left {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, r * f a ∂μ = r * ∫ a, f a ∂μ := integral_smul r f #align measure_theory.integral_mul_left MeasureTheory.integral_mul_left theorem integral_mul_right {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a * r ∂μ = (∫ a, f a ∂μ) * r := by simp only [mul_comm]; exact integral_mul_left r f #align measure_theory.integral_mul_right MeasureTheory.integral_mul_right theorem integral_div {L : Type*} [RCLike L] (r : L) (f : α → L) : ∫ a, f a / r ∂μ = (∫ a, f a ∂μ) / r := by simpa only [← div_eq_mul_inv] using integral_mul_right r⁻¹ f #align measure_theory.integral_div MeasureTheory.integral_div theorem integral_congr_ae {f g : α → G} (h : f =ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact setToFun_congr_ae (dominatedFinMeasAdditive_weightedSMul μ) h · simp [integral, hG] #align measure_theory.integral_congr_ae MeasureTheory.integral_congr_ae -- Porting note: `nolint simpNF` added because simplify fails on left-hand side @[simp, nolint simpNF] theorem L1.integral_of_fun_eq_integral {f : α → G} (hf : Integrable f μ) : ∫ a, (hf.toL1 f) a ∂μ = ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [MeasureTheory.integral, hG, L1.integral] exact setToFun_toL1 (dominatedFinMeasAdditive_weightedSMul μ) hf · simp [MeasureTheory.integral, hG] set_option linter.uppercaseLean3 false in #align measure_theory.L1.integral_of_fun_eq_integral MeasureTheory.L1.integral_of_fun_eq_integral @[continuity] theorem continuous_integral : Continuous fun f : α →₁[μ] G => ∫ a, f a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun (dominatedFinMeasAdditive_weightedSMul μ) · simp [integral, hG, continuous_const] #align measure_theory.continuous_integral MeasureTheory.continuous_integral theorem norm_integral_le_lintegral_norm (f : α → G) : ‖∫ a, f a ∂μ‖ ≤ ENNReal.toReal (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) := by by_cases hG : CompleteSpace G · by_cases hf : Integrable f μ · rw [integral_eq f hf, ← Integrable.norm_toL1_eq_lintegral_norm f hf] exact L1.norm_integral_le _ · rw [integral_undef hf, norm_zero]; exact toReal_nonneg · simp [integral, hG] #align measure_theory.norm_integral_le_lintegral_norm MeasureTheory.norm_integral_le_lintegral_norm theorem ennnorm_integral_le_lintegral_ennnorm (f : α → G) : (‖∫ a, f a ∂μ‖₊ : ℝ≥0∞) ≤ ∫⁻ a, ‖f a‖₊ ∂μ := by simp_rw [← ofReal_norm_eq_coe_nnnorm] apply ENNReal.ofReal_le_of_le_toReal exact norm_integral_le_lintegral_norm f #align measure_theory.ennnorm_integral_le_lintegral_ennnorm MeasureTheory.ennnorm_integral_le_lintegral_ennnorm theorem integral_eq_zero_of_ae {f : α → G} (hf : f =ᵐ[μ] 0) : ∫ a, f a ∂μ = 0 := by simp [integral_congr_ae hf, integral_zero] #align measure_theory.integral_eq_zero_of_ae MeasureTheory.integral_eq_zero_of_ae /-- If `f` has finite integral, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. -/ theorem HasFiniteIntegral.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : HasFiniteIntegral f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := by rw [tendsto_zero_iff_norm_tendsto_zero] simp_rw [← coe_nnnorm, ← NNReal.coe_zero, NNReal.tendsto_coe, ← ENNReal.tendsto_coe, ENNReal.coe_zero] exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (tendsto_set_lintegral_zero (ne_of_lt hf) hs) (fun i => zero_le _) fun i => ennnorm_integral_le_lintegral_ennnorm _ #align measure_theory.has_finite_integral.tendsto_set_integral_nhds_zero MeasureTheory.HasFiniteIntegral.tendsto_setIntegral_nhds_zero @[deprecated (since := "2024-04-17")] alias HasFiniteIntegral.tendsto_set_integral_nhds_zero := HasFiniteIntegral.tendsto_setIntegral_nhds_zero /-- If `f` is integrable, then `∫ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. -/ theorem Integrable.tendsto_setIntegral_nhds_zero {ι} {f : α → G} (hf : Integrable f μ) {l : Filter ι} {s : ι → Set α} (hs : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫ x in s i, f x ∂μ) l (𝓝 0) := hf.2.tendsto_setIntegral_nhds_zero hs #align measure_theory.integrable.tendsto_set_integral_nhds_zero MeasureTheory.Integrable.tendsto_setIntegral_nhds_zero @[deprecated (since := "2024-04-17")] alias Integrable.tendsto_set_integral_nhds_zero := Integrable.tendsto_setIntegral_nhds_zero /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ theorem tendsto_integral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i => ∫⁻ x, ‖F i x - f x‖₊ ∂μ) l (𝓝 0)) : Tendsto (fun i => ∫ x, F i x ∂μ) l (𝓝 <| ∫ x, f x ∂μ) := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact tendsto_setToFun_of_L1 (dominatedFinMeasAdditive_weightedSMul μ) f hfi hFi hF · simp [integral, hG, tendsto_const_nhds] set_option linter.uppercaseLean3 false in #align measure_theory.tendsto_integral_of_L1 MeasureTheory.tendsto_integral_of_L1 /-- If `F i → f` in `L1`, then `∫ x, F i x ∂μ → ∫ x, f x ∂μ`. -/ lemma tendsto_integral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ snorm (F i - f) 1 μ) l (𝓝 0)) : Tendsto (fun i ↦ ∫ x, F i x ∂μ) l (𝓝 (∫ x, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi hFi ?_ simp_rw [snorm_one_eq_lintegral_nnnorm, Pi.sub_apply] at hF exact hF /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ lemma tendsto_setIntegral_of_L1 {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ ∫⁻ x, ‖F i x - f x‖₊ ∂μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_integral_of_L1 f hfi.restrict ?_ ?_ · filter_upwards [hFi] with i hi using hi.restrict · simp_rw [← snorm_one_eq_lintegral_nnnorm] at hF ⊢ exact tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds hF (fun _ ↦ zero_le') (fun _ ↦ snorm_mono_measure _ Measure.restrict_le_self) @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_L1 := tendsto_setIntegral_of_L1 /-- If `F i → f` in `L1`, then `∫ x in s, F i x ∂μ → ∫ x in s, f x ∂μ`. -/ lemma tendsto_setIntegral_of_L1' {ι} (f : α → G) (hfi : Integrable f μ) {F : ι → α → G} {l : Filter ι} (hFi : ∀ᶠ i in l, Integrable (F i) μ) (hF : Tendsto (fun i ↦ snorm (F i - f) 1 μ) l (𝓝 0)) (s : Set α) : Tendsto (fun i ↦ ∫ x in s, F i x ∂μ) l (𝓝 (∫ x in s, f x ∂μ)) := by refine tendsto_setIntegral_of_L1 f hfi hFi ?_ s simp_rw [snorm_one_eq_lintegral_nnnorm, Pi.sub_apply] at hF exact hF @[deprecated (since := "2024-04-17")] alias tendsto_set_integral_of_L1' := tendsto_setIntegral_of_L1' variable {X : Type*} [TopologicalSpace X] [FirstCountableTopology X] theorem continuousWithinAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ᶠ x in 𝓝[s] x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝[s] x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousWithinAt (fun x => F x a) s x₀) : ContinuousWithinAt (fun x => ∫ a, F x a ∂μ) s x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousWithinAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousWithinAt_const] #align measure_theory.continuous_within_at_of_dominated MeasureTheory.continuousWithinAt_of_dominated theorem continuousAt_of_dominated {F : X → α → G} {x₀ : X} {bound : α → ℝ} (hF_meas : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (F x) μ) (h_bound : ∀ᶠ x in 𝓝 x₀, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousAt (fun x => F x a) x₀) : ContinuousAt (fun x => ∫ a, F x a ∂μ) x₀ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousAt_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousAt_const] #align measure_theory.continuous_at_of_dominated MeasureTheory.continuousAt_of_dominated theorem continuousOn_of_dominated {F : X → α → G} {bound : α → ℝ} {s : Set X} (hF_meas : ∀ x ∈ s, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x ∈ s, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, ContinuousOn (fun x => F x a) s) : ContinuousOn (fun x => ∫ a, F x a ∂μ) s := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuousOn_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuousOn_const] #align measure_theory.continuous_on_of_dominated MeasureTheory.continuousOn_of_dominated theorem continuous_of_dominated {F : X → α → G} {bound : α → ℝ} (hF_meas : ∀ x, AEStronglyMeasurable (F x) μ) (h_bound : ∀ x, ∀ᵐ a ∂μ, ‖F x a‖ ≤ bound a) (bound_integrable : Integrable bound μ) (h_cont : ∀ᵐ a ∂μ, Continuous fun x => F x a) : Continuous fun x => ∫ a, F x a ∂μ := by by_cases hG : CompleteSpace G · simp only [integral, hG, L1.integral] exact continuous_setToFun_of_dominated (dominatedFinMeasAdditive_weightedSMul μ) hF_meas h_bound bound_integrable h_cont · simp [integral, hG, continuous_const] #align measure_theory.continuous_of_dominated MeasureTheory.continuous_of_dominated /-- The Bochner integral of a real-valued function `f : α → ℝ` is the difference between the integral of the positive part of `f` and the integral of the negative part of `f`. -/ theorem integral_eq_lintegral_pos_part_sub_lintegral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, .ofReal (f a) ∂μ) - ENNReal.toReal (∫⁻ a, .ofReal (-f a) ∂μ) := by let f₁ := hf.toL1 f -- Go to the `L¹` space have eq₁ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) = ‖Lp.posPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_posPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq rw [Real.nnnorm_of_nonneg (le_max_right _ _)] rw [Real.coe_toNNReal', NNReal.coe_mk] -- Go to the `L¹` space have eq₂ : ENNReal.toReal (∫⁻ a, ENNReal.ofReal (-f a) ∂μ) = ‖Lp.negPart f₁‖ := by rw [L1.norm_def] congr 1 apply lintegral_congr_ae filter_upwards [Lp.coeFn_negPart f₁, hf.coeFn_toL1] with _ h₁ h₂ rw [h₁, h₂, ENNReal.ofReal] congr 1 apply NNReal.eq simp only [Real.coe_toNNReal', coe_nnnorm, nnnorm_neg] rw [Real.norm_of_nonpos (min_le_right _ _), ← max_neg_neg, neg_zero] rw [eq₁, eq₂, integral, dif_pos, dif_pos] exact L1.integral_eq_norm_posPart_sub _ #align measure_theory.integral_eq_lintegral_pos_part_sub_lintegral_neg_part MeasureTheory.integral_eq_lintegral_pos_part_sub_lintegral_neg_part theorem integral_eq_lintegral_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfm : AEStronglyMeasurable f μ) : ∫ a, f a ∂μ = ENNReal.toReal (∫⁻ a, ENNReal.ofReal (f a) ∂μ) := by by_cases hfi : Integrable f μ · rw [integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi] have h_min : ∫⁻ a, ENNReal.ofReal (-f a) ∂μ = 0 := by rw [lintegral_eq_zero_iff'] · refine hf.mono ?_ simp only [Pi.zero_apply] intro a h simp only [h, neg_nonpos, ofReal_eq_zero] · exact measurable_ofReal.comp_aemeasurable hfm.aemeasurable.neg rw [h_min, zero_toReal, _root_.sub_zero] · rw [integral_undef hfi] simp_rw [Integrable, hfm, hasFiniteIntegral_iff_norm, lt_top_iff_ne_top, Ne, true_and_iff, Classical.not_not] at hfi have : ∫⁻ a : α, ENNReal.ofReal (f a) ∂μ = ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ := by refine lintegral_congr_ae (hf.mono fun a h => ?_) dsimp only rw [Real.norm_eq_abs, abs_of_nonneg h] rw [this, hfi]; rfl #align measure_theory.integral_eq_lintegral_of_nonneg_ae MeasureTheory.integral_eq_lintegral_of_nonneg_ae theorem integral_norm_eq_lintegral_nnnorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : AEStronglyMeasurable f μ) : ∫ x, ‖f x‖ ∂μ = ENNReal.toReal (∫⁻ x, ‖f x‖₊ ∂μ) := by rw [integral_eq_lintegral_of_nonneg_ae _ hf.norm] · simp_rw [ofReal_norm_eq_coe_nnnorm] · filter_upwards; simp_rw [Pi.zero_apply, norm_nonneg, imp_true_iff] #align measure_theory.integral_norm_eq_lintegral_nnnorm MeasureTheory.integral_norm_eq_lintegral_nnnorm theorem ofReal_integral_norm_eq_lintegral_nnnorm {P : Type*} [NormedAddCommGroup P] {f : α → P} (hf : Integrable f μ) : ENNReal.ofReal (∫ x, ‖f x‖ ∂μ) = ∫⁻ x, ‖f x‖₊ ∂μ := by rw [integral_norm_eq_lintegral_nnnorm hf.aestronglyMeasurable, ENNReal.ofReal_toReal (lt_top_iff_ne_top.mp hf.2)] #align measure_theory.of_real_integral_norm_eq_lintegral_nnnorm MeasureTheory.ofReal_integral_norm_eq_lintegral_nnnorm theorem integral_eq_integral_pos_part_sub_integral_neg_part {f : α → ℝ} (hf : Integrable f μ) : ∫ a, f a ∂μ = ∫ a, (Real.toNNReal (f a) : ℝ) ∂μ - ∫ a, (Real.toNNReal (-f a) : ℝ) ∂μ := by rw [← integral_sub hf.real_toNNReal] · simp · exact hf.neg.real_toNNReal #align measure_theory.integral_eq_integral_pos_part_sub_integral_neg_part MeasureTheory.integral_eq_integral_pos_part_sub_integral_neg_part theorem integral_nonneg_of_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) : 0 ≤ ∫ a, f a ∂μ := by have A : CompleteSpace ℝ := by infer_instance simp only [integral_def, A, L1.integral_def, dite_true, ge_iff_le] exact setToFun_nonneg (dominatedFinMeasAdditive_weightedSMul μ) (fun s _ _ => weightedSMul_nonneg s) hf #align measure_theory.integral_nonneg_of_ae MeasureTheory.integral_nonneg_of_ae theorem lintegral_coe_eq_integral (f : α → ℝ≥0) (hfi : Integrable (fun x => (f x : ℝ)) μ) : ∫⁻ a, f a ∂μ = ENNReal.ofReal (∫ a, f a ∂μ) := by simp_rw [integral_eq_lintegral_of_nonneg_ae (eventually_of_forall fun x => (f x).coe_nonneg) hfi.aestronglyMeasurable, ← ENNReal.coe_nnreal_eq] rw [ENNReal.ofReal_toReal] rw [← lt_top_iff_ne_top] convert hfi.hasFiniteIntegral -- Porting note: `convert` no longer unfolds `HasFiniteIntegral` simp_rw [HasFiniteIntegral, NNReal.nnnorm_eq] #align measure_theory.lintegral_coe_eq_integral MeasureTheory.lintegral_coe_eq_integral theorem ofReal_integral_eq_lintegral_ofReal {f : α → ℝ} (hfi : Integrable f μ) (f_nn : 0 ≤ᵐ[μ] f) : ENNReal.ofReal (∫ x, f x ∂μ) = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by have : f =ᵐ[μ] (‖f ·‖) := f_nn.mono fun _x hx ↦ (abs_of_nonneg hx).symm simp_rw [integral_congr_ae this, ofReal_integral_norm_eq_lintegral_nnnorm hfi, ← ofReal_norm_eq_coe_nnnorm] exact lintegral_congr_ae (this.symm.fun_comp ENNReal.ofReal) #align measure_theory.of_real_integral_eq_lintegral_of_real MeasureTheory.ofReal_integral_eq_lintegral_ofReal theorem integral_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : ∀ᵐ x ∂μ, f x < ∞) : ∫ a, (f a).toReal ∂μ = (∫⁻ a, f a ∂μ).toReal := by rw [integral_eq_lintegral_of_nonneg_ae _ hfm.ennreal_toReal.aestronglyMeasurable, lintegral_congr_ae (ofReal_toReal_ae_eq hf)] exact eventually_of_forall fun x => ENNReal.toReal_nonneg #align measure_theory.integral_to_real MeasureTheory.integral_toReal theorem lintegral_coe_le_coe_iff_integral_le {f : α → ℝ≥0} (hfi : Integrable (fun x => (f x : ℝ)) μ) {b : ℝ≥0} : ∫⁻ a, f a ∂μ ≤ b ↔ ∫ a, (f a : ℝ) ∂μ ≤ b := by rw [lintegral_coe_eq_integral f hfi, ENNReal.ofReal, ENNReal.coe_le_coe, Real.toNNReal_le_iff_le_coe] #align measure_theory.lintegral_coe_le_coe_iff_integral_le MeasureTheory.lintegral_coe_le_coe_iff_integral_le theorem integral_coe_le_of_lintegral_coe_le {f : α → ℝ≥0} {b : ℝ≥0} (h : ∫⁻ a, f a ∂μ ≤ b) : ∫ a, (f a : ℝ) ∂μ ≤ b := by by_cases hf : Integrable (fun a => (f a : ℝ)) μ · exact (lintegral_coe_le_coe_iff_integral_le hf).1 h · rw [integral_undef hf]; exact b.2 #align measure_theory.integral_coe_le_of_lintegral_coe_le MeasureTheory.integral_coe_le_of_lintegral_coe_le theorem integral_nonneg {f : α → ℝ} (hf : 0 ≤ f) : 0 ≤ ∫ a, f a ∂μ := integral_nonneg_of_ae <| eventually_of_forall hf #align measure_theory.integral_nonneg MeasureTheory.integral_nonneg theorem integral_nonpos_of_ae {f : α → ℝ} (hf : f ≤ᵐ[μ] 0) : ∫ a, f a ∂μ ≤ 0 := by have hf : 0 ≤ᵐ[μ] -f := hf.mono fun a h => by rwa [Pi.neg_apply, Pi.zero_apply, neg_nonneg] have : 0 ≤ ∫ a, -f a ∂μ := integral_nonneg_of_ae hf rwa [integral_neg, neg_nonneg] at this #align measure_theory.integral_nonpos_of_ae MeasureTheory.integral_nonpos_of_ae theorem integral_nonpos {f : α → ℝ} (hf : f ≤ 0) : ∫ a, f a ∂μ ≤ 0 := integral_nonpos_of_ae <| eventually_of_forall hf #align measure_theory.integral_nonpos MeasureTheory.integral_nonpos theorem integral_eq_zero_iff_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := by simp_rw [integral_eq_lintegral_of_nonneg_ae hf hfi.1, ENNReal.toReal_eq_zero_iff, ← ENNReal.not_lt_top, ← hasFiniteIntegral_iff_ofReal hf, hfi.2, not_true_eq_false, or_false_iff] -- Porting note: split into parts, to make `rw` and `simp` work rw [lintegral_eq_zero_iff'] · rw [← hf.le_iff_eq, Filter.EventuallyEq, Filter.EventuallyLE] simp only [Pi.zero_apply, ofReal_eq_zero] · exact (ENNReal.measurable_ofReal.comp_aemeasurable hfi.1.aemeasurable) #align measure_theory.integral_eq_zero_iff_of_nonneg_ae MeasureTheory.integral_eq_zero_iff_of_nonneg_ae theorem integral_eq_zero_iff_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : ∫ x, f x ∂μ = 0 ↔ f =ᵐ[μ] 0 := integral_eq_zero_iff_of_nonneg_ae (eventually_of_forall hf) hfi #align measure_theory.integral_eq_zero_iff_of_nonneg MeasureTheory.integral_eq_zero_iff_of_nonneg lemma integral_eq_iff_of_ae_le {f g : α → ℝ} (hf : Integrable f μ) (hg : Integrable g μ) (hfg : f ≤ᵐ[μ] g) : ∫ a, f a ∂μ = ∫ a, g a ∂μ ↔ f =ᵐ[μ] g := by refine ⟨fun h_le ↦ EventuallyEq.symm ?_, fun h ↦ integral_congr_ae h⟩ rw [← sub_ae_eq_zero, ← integral_eq_zero_iff_of_nonneg_ae ((sub_nonneg_ae _ _).mpr hfg) (hg.sub hf)] simpa [Pi.sub_apply, integral_sub hg hf, sub_eq_zero, eq_comm] theorem integral_pos_iff_support_of_nonneg_ae {f : α → ℝ} (hf : 0 ≤ᵐ[μ] f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := by simp_rw [(integral_nonneg_of_ae hf).lt_iff_ne, pos_iff_ne_zero, Ne, @eq_comm ℝ 0, integral_eq_zero_iff_of_nonneg_ae hf hfi, Filter.EventuallyEq, ae_iff, Pi.zero_apply, Function.support] #align measure_theory.integral_pos_iff_support_of_nonneg_ae MeasureTheory.integral_pos_iff_support_of_nonneg_ae theorem integral_pos_iff_support_of_nonneg {f : α → ℝ} (hf : 0 ≤ f) (hfi : Integrable f μ) : (0 < ∫ x, f x ∂μ) ↔ 0 < μ (Function.support f) := integral_pos_iff_support_of_nonneg_ae (eventually_of_forall hf) hfi #align measure_theory.integral_pos_iff_support_of_nonneg MeasureTheory.integral_pos_iff_support_of_nonneg lemma integral_exp_pos {μ : Measure α} {f : α → ℝ} [hμ : NeZero μ] (hf : Integrable (fun x ↦ Real.exp (f x)) μ) : 0 < ∫ x, Real.exp (f x) ∂μ := by rw [integral_pos_iff_support_of_nonneg (fun x ↦ (Real.exp_pos _).le) hf] suffices (Function.support fun x ↦ Real.exp (f x)) = Set.univ by simp [this, hμ.out] ext1 x simp only [Function.mem_support, ne_eq, (Real.exp_pos _).ne', not_false_eq_true, Set.mem_univ] /-- Monotone convergence theorem for real-valued functions and Bochner integrals -/ lemma integral_tendsto_of_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by -- switch from the Bochner to the Lebesgue integral let f' := fun n x ↦ f n x - f 0 x have hf'_nonneg : ∀ᵐ x ∂μ, ∀ n, 0 ≤ f' n x := by filter_upwards [h_mono] with a ha n simp [f', ha (zero_le n)] have hf'_meas : ∀ n, Integrable (f' n) μ := fun n ↦ (hf n).sub (hf 0) suffices Tendsto (fun n ↦ ∫ x, f' n x ∂μ) atTop (𝓝 (∫ x, (F - f 0) x ∂μ)) by simp_rw [integral_sub (hf _) (hf _), integral_sub' hF (hf 0), tendsto_sub_const_iff] at this exact this have hF_ge : 0 ≤ᵐ[μ] fun x ↦ (F - f 0) x := by filter_upwards [h_tendsto, h_mono] with x hx_tendsto hx_mono simp only [Pi.zero_apply, Pi.sub_apply, sub_nonneg] exact ge_of_tendsto' hx_tendsto (fun n ↦ hx_mono (zero_le _)) rw [ae_all_iff] at hf'_nonneg simp_rw [integral_eq_lintegral_of_nonneg_ae (hf'_nonneg _) (hf'_meas _).1] rw [integral_eq_lintegral_of_nonneg_ae hF_ge (hF.1.sub (hf 0).1)] have h_cont := ENNReal.continuousAt_toReal (x := ∫⁻ a, ENNReal.ofReal ((F - f 0) a) ∂μ) ?_ swap · rw [← ofReal_integral_eq_lintegral_ofReal (hF.sub (hf 0)) hF_ge] exact ENNReal.ofReal_ne_top refine h_cont.tendsto.comp ?_ -- use the result for the Lebesgue integral refine lintegral_tendsto_of_tendsto_of_monotone ?_ ?_ ?_ · exact fun n ↦ ((hf n).sub (hf 0)).aemeasurable.ennreal_ofReal · filter_upwards [h_mono] with x hx n m hnm refine ENNReal.ofReal_le_ofReal ?_ simp only [f', tsub_le_iff_right, sub_add_cancel] exact hx hnm · filter_upwards [h_tendsto] with x hx refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ simp only [Pi.sub_apply] exact Tendsto.sub hx tendsto_const_nhds /-- Monotone convergence theorem for real-valued functions and Bochner integrals -/ lemma integral_tendsto_of_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf : ∀ n, Integrable (f n) μ) (hF : Integrable F μ) (h_mono : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫ x, f n x ∂μ) atTop (𝓝 (∫ x, F x ∂μ)) := by suffices Tendsto (fun n ↦ ∫ x, -f n x ∂μ) atTop (𝓝 (∫ x, -F x ∂μ)) by suffices Tendsto (fun n ↦ ∫ x, - -f n x ∂μ) atTop (𝓝 (∫ x, - -F x ∂μ)) by simpa [neg_neg] using this convert this.neg <;> rw [integral_neg] refine integral_tendsto_of_tendsto_of_monotone (fun n ↦ (hf n).neg) hF.neg ?_ ?_ · filter_upwards [h_mono] with x hx n m hnm using neg_le_neg_iff.mpr <| hx hnm · filter_upwards [h_tendsto] with x hx using hx.neg /-- If a monotone sequence of functions has an upper bound and the sequence of integrals of these functions tends to the integral of the upper bound, then the sequence of functions converges almost everywhere to the upper bound. -/ lemma tendsto_of_integral_tendsto_of_monotone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, f i a ≤ F a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by -- reduce to the `ℝ≥0∞` case let f' : ℕ → α → ℝ≥0∞ := fun n a ↦ ENNReal.ofReal (f n a - f 0 a) let F' : α → ℝ≥0∞ := fun a ↦ ENNReal.ofReal (F a - f 0 a) have hf'_int_eq : ∀ i, ∫⁻ a, f' i a ∂μ = ENNReal.ofReal (∫ a, f i a ∂μ - ∫ a, f 0 a ∂μ) := by intro i unfold_let f' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub (hf_int i) (hf_int 0)] · exact (hf_int i).sub (hf_int 0) · filter_upwards [hf_mono] with a h_mono simp [h_mono (zero_le i)] have hF'_int_eq : ∫⁻ a, F' a ∂μ = ENNReal.ofReal (∫ a, F a ∂μ - ∫ a, f 0 a ∂μ) := by unfold_let F' rw [← ofReal_integral_eq_lintegral_ofReal, integral_sub hF_int (hf_int 0)] · exact hF_int.sub (hf_int 0) · filter_upwards [hf_bound] with a h_bound simp [h_bound 0] have h_tendsto : Tendsto (fun i ↦ ∫⁻ a, f' i a ∂μ) atTop (𝓝 (∫⁻ a, F' a ∂μ)) := by simp_rw [hf'_int_eq, hF'_int_eq] refine (ENNReal.continuous_ofReal.tendsto _).comp ?_ rwa [tendsto_sub_const_iff] have h_mono : ∀ᵐ a ∂μ, Monotone (fun i ↦ f' i a) := by filter_upwards [hf_mono] with a ha_mono i j hij refine ENNReal.ofReal_le_ofReal ?_ simp [ha_mono hij] have h_bound : ∀ᵐ a ∂μ, ∀ i, f' i a ≤ F' a := by filter_upwards [hf_bound] with a ha_bound i refine ENNReal.ofReal_le_ofReal ?_ simp only [tsub_le_iff_right, sub_add_cancel, ha_bound i] -- use the corresponding lemma for `ℝ≥0∞` have h := tendsto_of_lintegral_tendsto_of_monotone ?_ h_tendsto h_mono h_bound ?_ rotate_left · exact (hF_int.1.aemeasurable.sub (hf_int 0).1.aemeasurable).ennreal_ofReal · exact ((lintegral_ofReal_le_lintegral_nnnorm _).trans_lt (hF_int.sub (hf_int 0)).2).ne filter_upwards [h, hf_mono, hf_bound] with a ha ha_mono ha_bound have h1 : (fun i ↦ f i a) = fun i ↦ (f' i a).toReal + f 0 a := by unfold_let f' ext i rw [ENNReal.toReal_ofReal] · abel · simp [ha_mono (zero_le i)] have h2 : F a = (F' a).toReal + f 0 a := by unfold_let F' rw [ENNReal.toReal_ofReal] · abel · simp [ha_bound 0] rw [h1, h2] refine Filter.Tendsto.add ?_ tendsto_const_nhds exact (ENNReal.continuousAt_toReal ENNReal.ofReal_ne_top).tendsto.comp ha /-- If an antitone sequence of functions has a lower bound and the sequence of integrals of these functions tends to the integral of the lower bound, then the sequence of functions converges almost everywhere to the lower bound. -/ lemma tendsto_of_integral_tendsto_of_antitone {μ : Measure α} {f : ℕ → α → ℝ} {F : α → ℝ} (hf_int : ∀ n, Integrable (f n) μ) (hF_int : Integrable F μ) (hf_tendsto : Tendsto (fun i ↦ ∫ a, f i a ∂μ) atTop (𝓝 (∫ a, F a ∂μ))) (hf_mono : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (hf_bound : ∀ᵐ a ∂μ, ∀ i, F a ≤ f i a) : ∀ᵐ a ∂μ, Tendsto (fun i ↦ f i a) atTop (𝓝 (F a)) := by let f' : ℕ → α → ℝ := fun i a ↦ - f i a let F' : α → ℝ := fun a ↦ - F a suffices ∀ᵐ a ∂μ, Tendsto (fun i ↦ f' i a) atTop (𝓝 (F' a)) by filter_upwards [this] with a ha_tendsto convert ha_tendsto.neg · simp [f'] · simp [F'] refine tendsto_of_integral_tendsto_of_monotone (fun n ↦ (hf_int n).neg) hF_int.neg ?_ ?_ ?_ · convert hf_tendsto.neg · rw [integral_neg] · rw [integral_neg] · filter_upwards [hf_mono] with a ha i j hij simp [f', ha hij] · filter_upwards [hf_bound] with a ha i simp [f', F', ha i] section NormedAddCommGroup variable {H : Type*} [NormedAddCommGroup H] theorem L1.norm_eq_integral_norm (f : α →₁[μ] H) : ‖f‖ = ∫ a, ‖f a‖ ∂μ := by simp only [snorm, snorm', ENNReal.one_toReal, ENNReal.rpow_one, Lp.norm_def, if_false, ENNReal.one_ne_top, one_ne_zero, _root_.div_one] rw [integral_eq_lintegral_of_nonneg_ae (eventually_of_forall (by simp [norm_nonneg])) (Lp.aestronglyMeasurable f).norm] simp [ofReal_norm_eq_coe_nnnorm] set_option linter.uppercaseLean3 false in #align measure_theory.L1.norm_eq_integral_norm MeasureTheory.L1.norm_eq_integral_norm
Mathlib/MeasureTheory/Integral/Bochner.lean
1,437
1,439
theorem L1.dist_eq_integral_dist (f g : α →₁[μ] H) : dist f g = ∫ a, dist (f a) (g a) ∂μ := by
simp only [dist_eq_norm, L1.norm_eq_integral_norm] exact integral_congr_ae <| (Lp.coeFn_sub _ _).fun_comp norm
/- Copyright (c) 2022 Anne Baanen. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Anne Baanen -/ import Mathlib.RingTheory.DedekindDomain.Ideal #align_import number_theory.ramification_inertia from "leanprover-community/mathlib"@"039a089d2a4b93c761b234f3e5f5aeb752bac60f" /-! # Ramification index and inertia degree Given `P : Ideal S` lying over `p : Ideal R` for the ring extension `f : R →+* S` (assuming `P` and `p` are prime or maximal where needed), the **ramification index** `Ideal.ramificationIdx f p P` is the multiplicity of `P` in `map f p`, and the **inertia degree** `Ideal.inertiaDeg f p P` is the degree of the field extension `(S / P) : (R / p)`. ## Main results The main theorem `Ideal.sum_ramification_inertia` states that for all coprime `P` lying over `p`, `Σ P, ramification_idx f p P * inertia_deg f p P` equals the degree of the field extension `Frac(S) : Frac(R)`. ## Implementation notes Often the above theory is set up in the case where: * `R` is the ring of integers of a number field `K`, * `L` is a finite separable extension of `K`, * `S` is the integral closure of `R` in `L`, * `p` and `P` are maximal ideals, * `P` is an ideal lying over `p` We will try to relax the above hypotheses as much as possible. ## Notation In this file, `e` stands for the ramification index and `f` for the inertia degree of `P` over `p`, leaving `p` and `P` implicit. -/ namespace Ideal universe u v variable {R : Type u} [CommRing R] variable {S : Type v} [CommRing S] (f : R →+* S) variable (p : Ideal R) (P : Ideal S) open FiniteDimensional open UniqueFactorizationMonoid section DecEq open scoped Classical /-- The ramification index of `P` over `p` is the largest exponent `n` such that `p` is contained in `P^n`. In particular, if `p` is not contained in `P^n`, then the ramification index is 0. If there is no largest such `n` (e.g. because `p = ⊥`), then `ramificationIdx` is defined to be 0. -/ noncomputable def ramificationIdx : ℕ := sSup {n | map f p ≤ P ^ n} #align ideal.ramification_idx Ideal.ramificationIdx variable {f p P} theorem ramificationIdx_eq_find (h : ∃ n, ∀ k, map f p ≤ P ^ k → k ≤ n) : ramificationIdx f p P = Nat.find h := Nat.sSup_def h #align ideal.ramification_idx_eq_find Ideal.ramificationIdx_eq_find theorem ramificationIdx_eq_zero (h : ∀ n : ℕ, ∃ k, map f p ≤ P ^ k ∧ n < k) : ramificationIdx f p P = 0 := dif_neg (by push_neg; exact h) #align ideal.ramification_idx_eq_zero Ideal.ramificationIdx_eq_zero theorem ramificationIdx_spec {n : ℕ} (hle : map f p ≤ P ^ n) (hgt : ¬map f p ≤ P ^ (n + 1)) : ramificationIdx f p P = n := by let Q : ℕ → Prop := fun m => ∀ k : ℕ, map f p ≤ P ^ k → k ≤ m have : Q n := by intro k hk refine le_of_not_lt fun hnk => ?_ exact hgt (hk.trans (Ideal.pow_le_pow_right hnk)) rw [ramificationIdx_eq_find ⟨n, this⟩] refine le_antisymm (Nat.find_min' _ this) (le_of_not_gt fun h : Nat.find _ < n => ?_) obtain this' := Nat.find_spec ⟨n, this⟩ exact h.not_le (this' _ hle) #align ideal.ramification_idx_spec Ideal.ramificationIdx_spec theorem ramificationIdx_lt {n : ℕ} (hgt : ¬map f p ≤ P ^ n) : ramificationIdx f p P < n := by cases' n with n n · simp at hgt · rw [Nat.lt_succ_iff] have : ∀ k, map f p ≤ P ^ k → k ≤ n := by refine fun k hk => le_of_not_lt fun hnk => ?_ exact hgt (hk.trans (Ideal.pow_le_pow_right hnk)) rw [ramificationIdx_eq_find ⟨n, this⟩] exact Nat.find_min' ⟨n, this⟩ this #align ideal.ramification_idx_lt Ideal.ramificationIdx_lt @[simp] theorem ramificationIdx_bot : ramificationIdx f ⊥ P = 0 := dif_neg <| not_exists.mpr fun n hn => n.lt_succ_self.not_le (hn _ (by simp)) #align ideal.ramification_idx_bot Ideal.ramificationIdx_bot @[simp] theorem ramificationIdx_of_not_le (h : ¬map f p ≤ P) : ramificationIdx f p P = 0 := ramificationIdx_spec (by simp) (by simpa using h) #align ideal.ramification_idx_of_not_le Ideal.ramificationIdx_of_not_le theorem ramificationIdx_ne_zero {e : ℕ} (he : e ≠ 0) (hle : map f p ≤ P ^ e) (hnle : ¬map f p ≤ P ^ (e + 1)) : ramificationIdx f p P ≠ 0 := by rwa [ramificationIdx_spec hle hnle] #align ideal.ramification_idx_ne_zero Ideal.ramificationIdx_ne_zero theorem le_pow_of_le_ramificationIdx {n : ℕ} (hn : n ≤ ramificationIdx f p P) : map f p ≤ P ^ n := by contrapose! hn exact ramificationIdx_lt hn #align ideal.le_pow_of_le_ramification_idx Ideal.le_pow_of_le_ramificationIdx theorem le_pow_ramificationIdx : map f p ≤ P ^ ramificationIdx f p P := le_pow_of_le_ramificationIdx (le_refl _) #align ideal.le_pow_ramification_idx Ideal.le_pow_ramificationIdx theorem le_comap_pow_ramificationIdx : p ≤ comap f (P ^ ramificationIdx f p P) := map_le_iff_le_comap.mp le_pow_ramificationIdx #align ideal.le_comap_pow_ramification_idx Ideal.le_comap_pow_ramificationIdx theorem le_comap_of_ramificationIdx_ne_zero (h : ramificationIdx f p P ≠ 0) : p ≤ comap f P := Ideal.map_le_iff_le_comap.mp <| le_pow_ramificationIdx.trans <| Ideal.pow_le_self <| h #align ideal.le_comap_of_ramification_idx_ne_zero Ideal.le_comap_of_ramificationIdx_ne_zero namespace IsDedekindDomain variable [IsDedekindDomain S] theorem ramificationIdx_eq_normalizedFactors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (hP0 : P ≠ ⊥) : ramificationIdx f p P = (normalizedFactors (map f p)).count P := by have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible refine ramificationIdx_spec (Ideal.le_of_dvd ?_) (mt Ideal.dvd_iff_le.mpr ?_) <;> rw [dvd_iff_normalizedFactors_le_normalizedFactors (pow_ne_zero _ hP0) hp0, normalizedFactors_pow, normalizedFactors_irreducible hPirr, normalize_eq, Multiset.nsmul_singleton, ← Multiset.le_count_iff_replicate_le] exact (Nat.lt_succ_self _).not_le #align ideal.is_dedekind_domain.ramification_idx_eq_normalized_factors_count Ideal.IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count theorem ramificationIdx_eq_factors_count (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (hP0 : P ≠ ⊥) : ramificationIdx f p P = (factors (map f p)).count P := by rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0, factors_eq_normalizedFactors] #align ideal.is_dedekind_domain.ramification_idx_eq_factors_count Ideal.IsDedekindDomain.ramificationIdx_eq_factors_count theorem ramificationIdx_ne_zero (hp0 : map f p ≠ ⊥) (hP : P.IsPrime) (le : map f p ≤ P) : ramificationIdx f p P ≠ 0 := by have hP0 : P ≠ ⊥ := by rintro rfl have := le_bot_iff.mp le contradiction have hPirr := (Ideal.prime_of_isPrime hP0 hP).irreducible rw [IsDedekindDomain.ramificationIdx_eq_normalizedFactors_count hp0 hP hP0] obtain ⟨P', hP', P'_eq⟩ := exists_mem_normalizedFactors_of_dvd hp0 hPirr (Ideal.dvd_iff_le.mpr le) rwa [Multiset.count_ne_zero, associated_iff_eq.mp P'_eq] #align ideal.is_dedekind_domain.ramification_idx_ne_zero Ideal.IsDedekindDomain.ramificationIdx_ne_zero end IsDedekindDomain variable (f p P) attribute [local instance] Ideal.Quotient.field /-- The inertia degree of `P : Ideal S` lying over `p : Ideal R` is the degree of the extension `(S / P) : (R / p)`. We do not assume `P` lies over `p` in the definition; we return `0` instead. See `inertiaDeg_algebraMap` for the common case where `f = algebraMap R S` and there is an algebra structure `R / p → S / P`. -/ noncomputable def inertiaDeg [p.IsMaximal] : ℕ := if hPp : comap f P = p then @finrank (R ⧸ p) (S ⧸ P) _ _ <| @Algebra.toModule _ _ _ _ <| RingHom.toAlgebra <| Ideal.Quotient.lift p ((Ideal.Quotient.mk P).comp f) fun _ ha => Quotient.eq_zero_iff_mem.mpr <| mem_comap.mp <| hPp.symm ▸ ha else 0 #align ideal.inertia_deg Ideal.inertiaDeg -- Useful for the `nontriviality` tactic using `comap_eq_of_scalar_tower_quotient`. @[simp] theorem inertiaDeg_of_subsingleton [hp : p.IsMaximal] [hQ : Subsingleton (S ⧸ P)] : inertiaDeg f p P = 0 := by have := Ideal.Quotient.subsingleton_iff.mp hQ subst this exact dif_neg fun h => hp.ne_top <| h.symm.trans comap_top #align ideal.inertia_deg_of_subsingleton Ideal.inertiaDeg_of_subsingleton @[simp] theorem inertiaDeg_algebraMap [Algebra R S] [Algebra (R ⧸ p) (S ⧸ P)] [IsScalarTower R (R ⧸ p) (S ⧸ P)] [hp : p.IsMaximal] : inertiaDeg (algebraMap R S) p P = finrank (R ⧸ p) (S ⧸ P) := by nontriviality S ⧸ P using inertiaDeg_of_subsingleton, finrank_zero_of_subsingleton have := comap_eq_of_scalar_tower_quotient (algebraMap (R ⧸ p) (S ⧸ P)).injective rw [inertiaDeg, dif_pos this] congr refine Algebra.algebra_ext _ _ fun x' => Quotient.inductionOn' x' fun x => ?_ change Ideal.Quotient.lift p _ _ (Ideal.Quotient.mk p x) = algebraMap _ _ (Ideal.Quotient.mk p x) rw [Ideal.Quotient.lift_mk, ← Ideal.Quotient.algebraMap_eq P, ← IsScalarTower.algebraMap_eq, ← Ideal.Quotient.algebraMap_eq, ← IsScalarTower.algebraMap_apply] #align ideal.inertia_deg_algebra_map Ideal.inertiaDeg_algebraMap end DecEq section FinrankQuotientMap open scoped nonZeroDivisors variable [Algebra R S] variable {K : Type*} [Field K] [Algebra R K] [hRK : IsFractionRing R K] variable {L : Type*} [Field L] [Algebra S L] [IsFractionRing S L] variable {V V' V'' : Type*} variable [AddCommGroup V] [Module R V] [Module K V] [IsScalarTower R K V] variable [AddCommGroup V'] [Module R V'] [Module S V'] [IsScalarTower R S V'] variable [AddCommGroup V''] [Module R V''] variable (K) /-- Let `V` be a vector space over `K = Frac(R)`, `S / R` a ring extension and `V'` a module over `S`. If `b`, in the intersection `V''` of `V` and `V'`, is linear independent over `S` in `V'`, then it is linear independent over `R` in `V`. The statement we prove is actually slightly more general: * it suffices that the inclusion `algebraMap R S : R → S` is nontrivial * the function `f' : V'' → V'` doesn't need to be injective -/ theorem FinrankQuotientMap.linearIndependent_of_nontrivial [IsDedekindDomain R] (hRS : RingHom.ker (algebraMap R S) ≠ ⊤) (f : V'' →ₗ[R] V) (hf : Function.Injective f) (f' : V'' →ₗ[R] V') {ι : Type*} {b : ι → V''} (hb' : LinearIndependent S (f' ∘ b)) : LinearIndependent K (f ∘ b) := by contrapose! hb' with hb -- Informally, if we have a nontrivial linear dependence with coefficients `g` in `K`, -- then we can find a linear dependence with coefficients `I.Quotient.mk g'` in `R/I`, -- where `I = ker (algebraMap R S)`. -- We make use of the same principle but stay in `R` everywhere. simp only [linearIndependent_iff', not_forall] at hb ⊢ obtain ⟨s, g, eq, j', hj's, hj'g⟩ := hb use s obtain ⟨a, hag, j, hjs, hgI⟩ := Ideal.exist_integer_multiples_not_mem hRS s g hj's hj'g choose g'' hg'' using hag letI := Classical.propDecidable let g' i := if h : i ∈ s then g'' i h else 0 have hg' : ∀ i ∈ s, algebraMap _ _ (g' i) = a * g i := by intro i hi; exact (congr_arg _ (dif_pos hi)).trans (hg'' i hi) -- Because `R/I` is nontrivial, we can lift `g` to a nontrivial linear dependence in `S`. have hgI : algebraMap R S (g' j) ≠ 0 := by simp only [FractionalIdeal.mem_coeIdeal, not_exists, not_and'] at hgI exact hgI _ (hg' j hjs) refine ⟨fun i => algebraMap R S (g' i), ?_, j, hjs, hgI⟩ have eq : f (∑ i ∈ s, g' i • b i) = 0 := by rw [map_sum, ← smul_zero a, ← eq, Finset.smul_sum] refine Finset.sum_congr rfl ?_ intro i hi rw [LinearMap.map_smul, ← IsScalarTower.algebraMap_smul K, hg' i hi, ← smul_assoc, smul_eq_mul, Function.comp_apply] simp only [IsScalarTower.algebraMap_smul, ← map_smul, ← map_sum, (f.map_eq_zero_iff hf).mp eq, LinearMap.map_zero, (· ∘ ·)] #align ideal.finrank_quotient_map.linear_independent_of_nontrivial Ideal.FinrankQuotientMap.linearIndependent_of_nontrivial open scoped Matrix variable {K} /-- If `b` mod `p` spans `S/p` as `R/p`-space, then `b` itself spans `Frac(S)` as `K`-space. Here, * `p` is an ideal of `R` such that `R / p` is nontrivial * `K` is a field that has an embedding of `R` (in particular we can take `K = Frac(R)`) * `L` is a field extension of `K` * `S` is the integral closure of `R` in `L` More precisely, we avoid quotients in this statement and instead require that `b ∪ pS` spans `S`. -/ theorem FinrankQuotientMap.span_eq_top [IsDomain R] [IsDomain S] [Algebra K L] [IsNoetherian R S] [Algebra R L] [IsScalarTower R S L] [IsScalarTower R K L] [IsIntegralClosure S R L] [NoZeroSMulDivisors R K] (hp : p ≠ ⊤) (b : Set S) (hb' : Submodule.span R b ⊔ (p.map (algebraMap R S)).restrictScalars R = ⊤) : Submodule.span K (algebraMap S L '' b) = ⊤ := by have hRL : Function.Injective (algebraMap R L) := by rw [IsScalarTower.algebraMap_eq R K L] exact (algebraMap K L).injective.comp (NoZeroSMulDivisors.algebraMap_injective R K) -- Let `M` be the `R`-module spanned by the proposed basis elements. let M : Submodule R S := Submodule.span R b -- Then `S / M` is generated by some finite set of `n` vectors `a`. letI h : Module.Finite R (S ⧸ M) := Module.Finite.of_surjective (Submodule.mkQ _) (Submodule.Quotient.mk_surjective _) obtain ⟨n, a, ha⟩ := @Module.Finite.exists_fin _ _ _ _ _ h -- Because the image of `p` in `S / M` is `⊤`, have smul_top_eq : p • (⊤ : Submodule R (S ⧸ M)) = ⊤ := by calc p • ⊤ = Submodule.map M.mkQ (p • ⊤) := by rw [Submodule.map_smul'', Submodule.map_top, M.range_mkQ] _ = ⊤ := by rw [Ideal.smul_top_eq_map, (Submodule.map_mkQ_eq_top M _).mpr hb'] -- we can write the elements of `a` as `p`-linear combinations of other elements of `a`. have exists_sum : ∀ x : S ⧸ M, ∃ a' : Fin n → R, (∀ i, a' i ∈ p) ∧ ∑ i, a' i • a i = x := by intro x obtain ⟨a'', ha'', hx⟩ := (Submodule.mem_ideal_smul_span_iff_exists_sum p a x).1 (by { rw [ha, smul_top_eq]; exact Submodule.mem_top } : x ∈ p • Submodule.span R (Set.range a)) · refine ⟨fun i => a'' i, fun i => ha'' _, ?_⟩ rw [← hx, Finsupp.sum_fintype] exact fun _ => zero_smul _ _ choose A' hA'p hA' using fun i => exists_sum (a i) -- This gives us a(n invertible) matrix `A` such that `det A ∈ (M = span R b)`, let A : Matrix (Fin n) (Fin n) R := Matrix.of A' - 1 let B := A.adjugate have A_smul : ∀ i, ∑ j, A i j • a j = 0 := by intros simp [A, Matrix.sub_apply, Matrix.of_apply, ne_eq, Matrix.one_apply, sub_smul, Finset.sum_sub_distrib, hA', sub_self] -- since `span S {det A} / M = 0`. have d_smul : ∀ i, A.det • a i = 0 := by intro i calc A.det • a i = ∑ j, (B * A) i j • a j := ?_ _ = ∑ k, B i k • ∑ j, A k j • a j := ?_ _ = 0 := Finset.sum_eq_zero fun k _ => ?_ · simp only [B, Matrix.adjugate_mul, Matrix.smul_apply, Matrix.one_apply, smul_eq_mul, ite_true, mul_ite, mul_one, mul_zero, ite_smul, zero_smul, Finset.sum_ite_eq, Finset.mem_univ] · simp only [Matrix.mul_apply, Finset.smul_sum, Finset.sum_smul, smul_smul] rw [Finset.sum_comm] · rw [A_smul, smul_zero] -- In the rings of integers we have the desired inclusion. have span_d : (Submodule.span S ({algebraMap R S A.det} : Set S)).restrictScalars R ≤ M := by intro x hx rw [Submodule.restrictScalars_mem] at hx obtain ⟨x', rfl⟩ := Submodule.mem_span_singleton.mp hx rw [smul_eq_mul, mul_comm, ← Algebra.smul_def] at hx ⊢ rw [← Submodule.Quotient.mk_eq_zero, Submodule.Quotient.mk_smul] obtain ⟨a', _, quot_x_eq⟩ := exists_sum (Submodule.Quotient.mk x') rw [← quot_x_eq, Finset.smul_sum] conv => lhs; congr; next => skip intro x; rw [smul_comm A.det, d_smul, smul_zero] exact Finset.sum_const_zero refine top_le_iff.mp (calc ⊤ = (Ideal.span {algebraMap R L A.det}).restrictScalars K := ?_ _ ≤ Submodule.span K (algebraMap S L '' b) := ?_) -- Because `det A ≠ 0`, we have `span L {det A} = ⊤`. · rw [eq_comm, Submodule.restrictScalars_eq_top_iff, Ideal.span_singleton_eq_top] refine IsUnit.mk0 _ ((map_ne_zero_iff (algebraMap R L) hRL).mpr ?_) refine ne_zero_of_map (f := Ideal.Quotient.mk p) ?_ haveI := Ideal.Quotient.nontrivial hp calc Ideal.Quotient.mk p A.det = Matrix.det ((Ideal.Quotient.mk p).mapMatrix A) := by rw [RingHom.map_det] _ = Matrix.det ((Ideal.Quotient.mk p).mapMatrix (Matrix.of A' - 1)) := rfl _ = Matrix.det fun i j => (Ideal.Quotient.mk p) (A' i j) - (1 : Matrix (Fin n) (Fin n) (R ⧸ p)) i j := ?_ _ = Matrix.det (-1 : Matrix (Fin n) (Fin n) (R ⧸ p)) := ?_ _ = (-1 : R ⧸ p) ^ n := by rw [Matrix.det_neg, Fintype.card_fin, Matrix.det_one, mul_one] _ ≠ 0 := IsUnit.ne_zero (isUnit_one.neg.pow _) · refine congr_arg Matrix.det (Matrix.ext fun i j => ?_) rw [map_sub, RingHom.mapMatrix_apply, map_one] rfl · refine congr_arg Matrix.det (Matrix.ext fun i j => ?_) rw [Ideal.Quotient.eq_zero_iff_mem.mpr (hA'p i j), zero_sub] rfl -- And we conclude `L = span L {det A} ≤ span K b`, so `span K b` spans everything. · intro x hx rw [Submodule.restrictScalars_mem, IsScalarTower.algebraMap_apply R S L] at hx have : Algebra.IsAlgebraic R L := by have : NoZeroSMulDivisors R L := NoZeroSMulDivisors.of_algebraMap_injective hRL rw [← IsFractionRing.isAlgebraic_iff' R S] infer_instance refine IsFractionRing.ideal_span_singleton_map_subset R hRL span_d hx #align ideal.finrank_quotient_map.span_eq_top Ideal.FinrankQuotientMap.span_eq_top variable (K L) /-- If `p` is a maximal ideal of `R`, and `S` is the integral closure of `R` in `L`, then the dimension `[S/pS : R/p]` is equal to `[Frac(S) : Frac(R)]`. -/ theorem finrank_quotient_map [IsDomain S] [IsDedekindDomain R] [Algebra K L] [Algebra R L] [IsScalarTower R K L] [IsScalarTower R S L] [IsIntegralClosure S R L] [hp : p.IsMaximal] [IsNoetherian R S] : finrank (R ⧸ p) (S ⧸ map (algebraMap R S) p) = finrank K L := by -- Choose an arbitrary basis `b` for `[S/pS : R/p]`. -- We'll use the previous results to turn it into a basis on `[Frac(S) : Frac(R)]`. letI : Field (R ⧸ p) := Ideal.Quotient.field _ let ι := Module.Free.ChooseBasisIndex (R ⧸ p) (S ⧸ map (algebraMap R S) p) let b : Basis ι (R ⧸ p) (S ⧸ map (algebraMap R S) p) := Module.Free.chooseBasis _ _ -- Namely, choose a representative `b' i : S` for each `b i : S / pS`. let b' : ι → S := fun i => (Ideal.Quotient.mk_surjective (b i)).choose have b_eq_b' : ⇑b = (Submodule.mkQ (map (algebraMap R S) p)).restrictScalars R ∘ b' := funext fun i => (Ideal.Quotient.mk_surjective (b i)).choose_spec.symm -- We claim `b'` is a basis for `Frac(S)` over `Frac(R)` because it is linear independent -- and spans the whole of `Frac(S)`. let b'' : ι → L := algebraMap S L ∘ b' have b''_li : LinearIndependent K b'' := ?_ · have b''_sp : Submodule.span K (Set.range b'') = ⊤ := ?_ -- Since the two bases have the same index set, the spaces have the same dimension. · let c : Basis ι K L := Basis.mk b''_li b''_sp.ge rw [finrank_eq_card_basis b, finrank_eq_card_basis c] -- It remains to show that the basis is indeed linear independent and spans the whole space. · rw [Set.range_comp] refine FinrankQuotientMap.span_eq_top p hp.ne_top _ (top_le_iff.mp ?_) -- The nicest way to show `S ≤ span b' ⊔ pS` is by reducing both sides modulo pS. -- However, this would imply distinguishing between `pS` as `S`-ideal, -- and `pS` as `R`-submodule, since they have different (non-defeq) quotients. -- Instead we'll lift `x mod pS ∈ span b` to `y ∈ span b'` for some `y - x ∈ pS`. intro x _ have mem_span_b : ((Submodule.mkQ (map (algebraMap R S) p)) x : S ⧸ map (algebraMap R S) p) ∈ Submodule.span (R ⧸ p) (Set.range b) := b.mem_span _ rw [← @Submodule.restrictScalars_mem R, Submodule.restrictScalars_span R (R ⧸ p) Ideal.Quotient.mk_surjective, b_eq_b', Set.range_comp, ← Submodule.map_span] at mem_span_b obtain ⟨y, y_mem, y_eq⟩ := Submodule.mem_map.mp mem_span_b suffices y + -(y - x) ∈ _ by simpa rw [LinearMap.restrictScalars_apply, Submodule.mkQ_apply, Submodule.mkQ_apply, Submodule.Quotient.eq] at y_eq exact add_mem (Submodule.mem_sup_left y_mem) (neg_mem <| Submodule.mem_sup_right y_eq) · have := b.linearIndependent; rw [b_eq_b'] at this convert FinrankQuotientMap.linearIndependent_of_nontrivial K _ ((Algebra.linearMap S L).restrictScalars R) _ ((Submodule.mkQ _).restrictScalars R) this · rw [Quotient.algebraMap_eq, Ideal.mk_ker] exact hp.ne_top · exact IsFractionRing.injective S L #align ideal.finrank_quotient_map Ideal.finrank_quotient_map end FinrankQuotientMap section FactLeComap local notation "e" => ramificationIdx f p P /-- `R / p` has a canonical map to `S / (P ^ e)`, where `e` is the ramification index of `P` over `p`. -/ noncomputable instance Quotient.algebraQuotientPowRamificationIdx : Algebra (R ⧸ p) (S ⧸ P ^ e) := Quotient.algebraQuotientOfLEComap (Ideal.map_le_iff_le_comap.mp le_pow_ramificationIdx) #align ideal.quotient.algebra_quotient_pow_ramification_idx Ideal.Quotient.algebraQuotientPowRamificationIdx #adaptation_note /-- 2024-04-23 The right hand side here used to be `Ideal.Quotient.mk _ (f x)` which was somewhat slow, but this is now even slower without `set_option backward.isDefEq.lazyProjDelta false in` Instead we've replaced it with `Ideal.Quotient.mk (P ^ e) (f x)` (compare #12412) -/ @[simp] theorem Quotient.algebraMap_quotient_pow_ramificationIdx (x : R) : algebraMap (R ⧸ p) (S ⧸ P ^ e) (Ideal.Quotient.mk p x) = Ideal.Quotient.mk (P ^ e) (f x) := rfl #align ideal.quotient.algebra_map_quotient_pow_ramification_idx Ideal.Quotient.algebraMap_quotient_pow_ramificationIdx variable [hfp : NeZero (ramificationIdx f p P)] /-- If `P` lies over `p`, then `R / p` has a canonical map to `S / P`. This can't be an instance since the map `f : R → S` is generally not inferrable. -/ def Quotient.algebraQuotientOfRamificationIdxNeZero : Algebra (R ⧸ p) (S ⧸ P) := Quotient.algebraQuotientOfLEComap (le_comap_of_ramificationIdx_ne_zero hfp.out) #align ideal.quotient.algebra_quotient_of_ramification_idx_ne_zero Ideal.Quotient.algebraQuotientOfRamificationIdxNeZero set_option synthInstance.checkSynthOrder false -- Porting note: this is okay by the remark below -- In this file, the value for `f` can be inferred. attribute [local instance] Ideal.Quotient.algebraQuotientOfRamificationIdxNeZero #adaptation_note /-- 2024-04-28 The RHS used to be `Ideal.Quotient.mk _ (f x)`, which was slow, but this is now even slower without `set_option backward.isDefEq.lazyWhnfCore false in` (compare https://github.com/leanprover-community/mathlib4/pull/12412) -/ @[simp] theorem Quotient.algebraMap_quotient_of_ramificationIdx_neZero (x : R) : algebraMap (R ⧸ p) (S ⧸ P) (Ideal.Quotient.mk p x) = Ideal.Quotient.mk P (f x) := rfl #align ideal.quotient.algebra_map_quotient_of_ramification_idx_ne_zero Ideal.Quotient.algebraMap_quotient_of_ramificationIdx_neZero /-- The inclusion `(P^(i + 1) / P^e) ⊂ (P^i / P^e)`. -/ @[simps] def powQuotSuccInclusion (i : ℕ) : Ideal.map (Ideal.Quotient.mk (P ^ e)) (P ^ (i + 1)) →ₗ[R ⧸ p] Ideal.map (Ideal.Quotient.mk (P ^ e)) (P ^ i) where toFun x := ⟨x, Ideal.map_mono (Ideal.pow_le_pow_right i.le_succ) x.2⟩ map_add' _ _ := rfl map_smul' _ _ := rfl #align ideal.pow_quot_succ_inclusion Ideal.powQuotSuccInclusion theorem powQuotSuccInclusion_injective (i : ℕ) : Function.Injective (powQuotSuccInclusion f p P i) := by rw [← LinearMap.ker_eq_bot, LinearMap.ker_eq_bot'] rintro ⟨x, hx⟩ hx0 rw [Subtype.ext_iff] at hx0 ⊢ rwa [powQuotSuccInclusion_apply_coe] at hx0 #align ideal.pow_quot_succ_inclusion_injective Ideal.powQuotSuccInclusion_injective /-- `S ⧸ P` embeds into the quotient by `P^(i+1) ⧸ P^e` as a subspace of `P^i ⧸ P^e`. See `quotientToQuotientRangePowQuotSucc` for this as a linear map, and `quotientRangePowQuotSuccInclusionEquiv` for this as a linear equivalence. -/ noncomputable def quotientToQuotientRangePowQuotSuccAux {i : ℕ} {a : S} (a_mem : a ∈ P ^ i) : S ⧸ P → (P ^ i).map (Ideal.Quotient.mk (P ^ e)) ⧸ LinearMap.range (powQuotSuccInclusion f p P i) := Quotient.map' (fun x : S => ⟨_, Ideal.mem_map_of_mem _ (Ideal.mul_mem_right x _ a_mem)⟩) fun x y h => by rw [Submodule.quotientRel_r_def] at h ⊢ simp only [_root_.map_mul, LinearMap.mem_range] refine ⟨⟨_, Ideal.mem_map_of_mem _ (Ideal.mul_mem_mul a_mem h)⟩, ?_⟩ ext rw [powQuotSuccInclusion_apply_coe, Subtype.coe_mk, Submodule.coe_sub, Subtype.coe_mk, Subtype.coe_mk, _root_.map_mul, map_sub, mul_sub] #align ideal.quotient_to_quotient_range_pow_quot_succ_aux Ideal.quotientToQuotientRangePowQuotSuccAux theorem quotientToQuotientRangePowQuotSuccAux_mk {i : ℕ} {a : S} (a_mem : a ∈ P ^ i) (x : S) : quotientToQuotientRangePowQuotSuccAux f p P a_mem (Submodule.Quotient.mk x) = Submodule.Quotient.mk ⟨_, Ideal.mem_map_of_mem _ (Ideal.mul_mem_right x _ a_mem)⟩ := by apply Quotient.map'_mk'' #align ideal.quotient_to_quotient_range_pow_quot_succ_aux_mk Ideal.quotientToQuotientRangePowQuotSuccAux_mk /-- `S ⧸ P` embeds into the quotient by `P^(i+1) ⧸ P^e` as a subspace of `P^i ⧸ P^e`. -/ noncomputable def quotientToQuotientRangePowQuotSucc {i : ℕ} {a : S} (a_mem : a ∈ P ^ i) : S ⧸ P →ₗ[R ⧸ p] (P ^ i).map (Ideal.Quotient.mk (P ^ e)) ⧸ LinearMap.range (powQuotSuccInclusion f p P i) where toFun := quotientToQuotientRangePowQuotSuccAux f p P a_mem map_add' := by intro x y; refine Quotient.inductionOn' x fun x => Quotient.inductionOn' y fun y => ?_ simp only [Submodule.Quotient.mk''_eq_mk, ← Submodule.Quotient.mk_add, quotientToQuotientRangePowQuotSuccAux_mk, mul_add] exact congr_arg Submodule.Quotient.mk rfl map_smul' := by intro x y; refine Quotient.inductionOn' x fun x => Quotient.inductionOn' y fun y => ?_ simp only [Submodule.Quotient.mk''_eq_mk, RingHom.id_apply, quotientToQuotientRangePowQuotSuccAux_mk] refine congr_arg Submodule.Quotient.mk ?_ ext simp only [mul_assoc, _root_.map_mul, Quotient.mk_eq_mk, Submodule.coe_smul_of_tower, Algebra.smul_def, Quotient.algebraMap_quotient_pow_ramificationIdx] ring #align ideal.quotient_to_quotient_range_pow_quot_succ Ideal.quotientToQuotientRangePowQuotSucc theorem quotientToQuotientRangePowQuotSucc_mk {i : ℕ} {a : S} (a_mem : a ∈ P ^ i) (x : S) : quotientToQuotientRangePowQuotSucc f p P a_mem (Submodule.Quotient.mk x) = Submodule.Quotient.mk ⟨_, Ideal.mem_map_of_mem _ (Ideal.mul_mem_right x _ a_mem)⟩ := quotientToQuotientRangePowQuotSuccAux_mk f p P a_mem x #align ideal.quotient_to_quotient_range_pow_quot_succ_mk Ideal.quotientToQuotientRangePowQuotSucc_mk theorem quotientToQuotientRangePowQuotSucc_injective [IsDedekindDomain S] [P.IsPrime] {i : ℕ} (hi : i < e) {a : S} (a_mem : a ∈ P ^ i) (a_not_mem : a ∉ P ^ (i + 1)) : Function.Injective (quotientToQuotientRangePowQuotSucc f p P a_mem) := fun x => Quotient.inductionOn' x fun x y => Quotient.inductionOn' y fun y h => by have Pe_le_Pi1 : P ^ e ≤ P ^ (i + 1) := Ideal.pow_le_pow_right hi simp only [Submodule.Quotient.mk''_eq_mk, quotientToQuotientRangePowQuotSucc_mk, Submodule.Quotient.eq, LinearMap.mem_range, Subtype.ext_iff, Subtype.coe_mk, Submodule.coe_sub] at h ⊢ rcases h with ⟨⟨⟨z⟩, hz⟩, h⟩ rw [Submodule.Quotient.quot_mk_eq_mk, Ideal.Quotient.mk_eq_mk, Ideal.mem_quotient_iff_mem_sup, sup_eq_left.mpr Pe_le_Pi1] at hz rw [powQuotSuccInclusion_apply_coe, Subtype.coe_mk, Submodule.Quotient.quot_mk_eq_mk, Ideal.Quotient.mk_eq_mk, ← map_sub, Ideal.Quotient.eq, ← mul_sub] at h exact (Ideal.IsPrime.mem_pow_mul _ ((Submodule.sub_mem_iff_right _ hz).mp (Pe_le_Pi1 h))).resolve_left a_not_mem #align ideal.quotient_to_quotient_range_pow_quot_succ_injective Ideal.quotientToQuotientRangePowQuotSucc_injective theorem quotientToQuotientRangePowQuotSucc_surjective [IsDedekindDomain S] (hP0 : P ≠ ⊥) [hP : P.IsPrime] {i : ℕ} (hi : i < e) {a : S} (a_mem : a ∈ P ^ i) (a_not_mem : a ∉ P ^ (i + 1)) : Function.Surjective (quotientToQuotientRangePowQuotSucc f p P a_mem) := by rintro ⟨⟨⟨x⟩, hx⟩⟩ have Pe_le_Pi : P ^ e ≤ P ^ i := Ideal.pow_le_pow_right hi.le rw [Submodule.Quotient.quot_mk_eq_mk, Ideal.Quotient.mk_eq_mk, Ideal.mem_quotient_iff_mem_sup, sup_eq_left.mpr Pe_le_Pi] at hx suffices hx' : x ∈ Ideal.span {a} ⊔ P ^ (i + 1) by obtain ⟨y', hy', z, hz, rfl⟩ := Submodule.mem_sup.mp hx' obtain ⟨y, rfl⟩ := Ideal.mem_span_singleton.mp hy' refine ⟨Submodule.Quotient.mk y, ?_⟩ simp only [Submodule.Quotient.quot_mk_eq_mk, quotientToQuotientRangePowQuotSucc_mk, Submodule.Quotient.eq, LinearMap.mem_range, Subtype.ext_iff, Subtype.coe_mk, Submodule.coe_sub] refine ⟨⟨_, Ideal.mem_map_of_mem _ (Submodule.neg_mem _ hz)⟩, ?_⟩ rw [powQuotSuccInclusion_apply_coe, Subtype.coe_mk, Ideal.Quotient.mk_eq_mk, map_add, sub_add_cancel_left, map_neg] letI := Classical.decEq (Ideal S) rw [sup_eq_prod_inf_factors _ (pow_ne_zero _ hP0), normalizedFactors_pow, normalizedFactors_irreducible ((Ideal.prime_iff_isPrime hP0).mpr hP).irreducible, normalize_eq, Multiset.nsmul_singleton, Multiset.inter_replicate, Multiset.prod_replicate] · rw [← Submodule.span_singleton_le_iff_mem, Ideal.submodule_span_eq] at a_mem a_not_mem rwa [Ideal.count_normalizedFactors_eq a_mem a_not_mem, min_eq_left i.le_succ] · intro ha rw [Ideal.span_singleton_eq_bot.mp ha] at a_not_mem have := (P ^ (i + 1)).zero_mem contradiction #align ideal.quotient_to_quotient_range_pow_quot_succ_surjective Ideal.quotientToQuotientRangePowQuotSucc_surjective /-- Quotienting `P^i / P^e` by its subspace `P^(i+1) ⧸ P^e` is `R ⧸ p`-linearly isomorphic to `S ⧸ P`. -/ noncomputable def quotientRangePowQuotSuccInclusionEquiv [IsDedekindDomain S] [P.IsPrime] (hP : P ≠ ⊥) {i : ℕ} (hi : i < e) : ((P ^ i).map (Ideal.Quotient.mk (P ^ e)) ⧸ LinearMap.range (powQuotSuccInclusion f p P i)) ≃ₗ[R ⧸ p] S ⧸ P := by choose a a_mem a_not_mem using SetLike.exists_of_lt (Ideal.pow_right_strictAnti P hP (Ideal.IsPrime.ne_top inferInstance) (le_refl i.succ)) refine (LinearEquiv.ofBijective ?_ ⟨?_, ?_⟩).symm · exact quotientToQuotientRangePowQuotSucc f p P a_mem · exact quotientToQuotientRangePowQuotSucc_injective f p P hi a_mem a_not_mem · exact quotientToQuotientRangePowQuotSucc_surjective f p P hP hi a_mem a_not_mem #align ideal.quotient_range_pow_quot_succ_inclusion_equiv Ideal.quotientRangePowQuotSuccInclusionEquiv /-- Since the inclusion `(P^(i + 1) / P^e) ⊂ (P^i / P^e)` has a kernel isomorphic to `P / S`, `[P^i / P^e : R / p] = [P^(i+1) / P^e : R / p] + [P / S : R / p]` -/
Mathlib/NumberTheory/RamificationInertia.lean
615
623
theorem rank_pow_quot_aux [IsDedekindDomain S] [p.IsMaximal] [P.IsPrime] (hP0 : P ≠ ⊥) {i : ℕ} (hi : i < e) : Module.rank (R ⧸ p) (Ideal.map (Ideal.Quotient.mk (P ^ e)) (P ^ i)) = Module.rank (R ⧸ p) (S ⧸ P) + Module.rank (R ⧸ p) (Ideal.map (Ideal.Quotient.mk (P ^ e)) (P ^ (i + 1))) := by
letI : Field (R ⧸ p) := Ideal.Quotient.field _ rw [← rank_range_of_injective _ (powQuotSuccInclusion_injective f p P i), (quotientRangePowQuotSuccInclusionEquiv f p P hP0 hi).symm.rank_eq] exact (rank_quotient_add_rank (LinearMap.range (powQuotSuccInclusion f p P i))).symm
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Yury Kudryashov -/ import Mathlib.Algebra.BigOperators.WithTop import Mathlib.Algebra.GroupWithZero.Divisibility import Mathlib.Data.ENNReal.Basic #align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" /-! # Properties of addition, multiplication and subtraction on extended non-negative real numbers In this file we prove elementary properties of algebraic operations on `ℝ≥0∞`, including addition, multiplication, natural powers and truncated subtraction, as well as how these interact with the order structure on `ℝ≥0∞`. Notably excluded from this list are inversion and division, the definitions and properties of which can be found in `Data.ENNReal.Inv`. Note: the definitions of the operations included in this file can be found in `Data.ENNReal.Basic`. -/ open Set NNReal ENNReal namespace ENNReal variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0} section Mul -- Porting note (#11215): TODO: generalize to `WithTop` @[mono, gcongr] theorem mul_lt_mul (ac : a < c) (bd : b < d) : a * b < c * d := by rcases lt_iff_exists_nnreal_btwn.1 ac with ⟨a', aa', a'c⟩ lift a to ℝ≥0 using ne_top_of_lt aa' rcases lt_iff_exists_nnreal_btwn.1 bd with ⟨b', bb', b'd⟩ lift b to ℝ≥0 using ne_top_of_lt bb' norm_cast at * calc ↑(a * b) < ↑(a' * b') := coe_lt_coe.2 (mul_lt_mul₀ aa' bb') _ ≤ c * d := mul_le_mul' a'c.le b'd.le #align ennreal.mul_lt_mul ENNReal.mul_lt_mul -- TODO: generalize to `CovariantClass α α (· * ·) (· ≤ ·)` theorem mul_left_mono : Monotone (a * ·) := fun _ _ => mul_le_mul' le_rfl #align ennreal.mul_left_mono ENNReal.mul_left_mono -- TODO: generalize to `CovariantClass α α (swap (· * ·)) (· ≤ ·)` theorem mul_right_mono : Monotone (· * a) := fun _ _ h => mul_le_mul' h le_rfl #align ennreal.mul_right_mono ENNReal.mul_right_mono -- Porting note (#11215): TODO: generalize to `WithTop` theorem pow_strictMono : ∀ {n : ℕ}, n ≠ 0 → StrictMono fun x : ℝ≥0∞ => x ^ n | 0, h => absurd rfl h | 1, _ => by simpa only [pow_one] using strictMono_id | n + 2, _ => fun x y h ↦ by simp_rw [pow_succ _ (n + 1)]; exact mul_lt_mul (pow_strictMono n.succ_ne_zero h) h #align ennreal.pow_strict_mono ENNReal.pow_strictMono @[gcongr] protected theorem pow_lt_pow_left (h : a < b) {n : ℕ} (hn : n ≠ 0) : a ^ n < b ^ n := ENNReal.pow_strictMono hn h theorem max_mul : max a b * c = max (a * c) (b * c) := mul_right_mono.map_max #align ennreal.max_mul ENNReal.max_mul theorem mul_max : a * max b c = max (a * b) (a * c) := mul_left_mono.map_max #align ennreal.mul_max ENNReal.mul_max -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_left_strictMono (h0 : a ≠ 0) (hinf : a ≠ ∞) : StrictMono (a * ·) := by lift a to ℝ≥0 using hinf rw [coe_ne_zero] at h0 intro x y h contrapose! h simpa only [← mul_assoc, ← coe_mul, inv_mul_cancel h0, coe_one, one_mul] using mul_le_mul_left' h (↑a⁻¹) #align ennreal.mul_left_strict_mono ENNReal.mul_left_strictMono @[gcongr] protected theorem mul_lt_mul_left' (h0 : a ≠ 0) (hinf : a ≠ ⊤) (bc : b < c) : a * b < a * c := ENNReal.mul_left_strictMono h0 hinf bc @[gcongr] protected theorem mul_lt_mul_right' (h0 : a ≠ 0) (hinf : a ≠ ⊤) (bc : b < c) : b * a < c * a := mul_comm b a ▸ mul_comm c a ▸ ENNReal.mul_left_strictMono h0 hinf bc -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_eq_mul_left (h0 : a ≠ 0) (hinf : a ≠ ∞) : a * b = a * c ↔ b = c := (mul_left_strictMono h0 hinf).injective.eq_iff #align ennreal.mul_eq_mul_left ENNReal.mul_eq_mul_left -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_eq_mul_right : c ≠ 0 → c ≠ ∞ → (a * c = b * c ↔ a = b) := mul_comm c a ▸ mul_comm c b ▸ mul_eq_mul_left #align ennreal.mul_eq_mul_right ENNReal.mul_eq_mul_right -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_le_mul_left (h0 : a ≠ 0) (hinf : a ≠ ∞) : (a * b ≤ a * c ↔ b ≤ c) := (mul_left_strictMono h0 hinf).le_iff_le #align ennreal.mul_le_mul_left ENNReal.mul_le_mul_left -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_le_mul_right : c ≠ 0 → c ≠ ∞ → (a * c ≤ b * c ↔ a ≤ b) := mul_comm c a ▸ mul_comm c b ▸ mul_le_mul_left #align ennreal.mul_le_mul_right ENNReal.mul_le_mul_right -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_lt_mul_left (h0 : a ≠ 0) (hinf : a ≠ ∞) : (a * b < a * c ↔ b < c) := (mul_left_strictMono h0 hinf).lt_iff_lt #align ennreal.mul_lt_mul_left ENNReal.mul_lt_mul_left -- Porting note (#11215): TODO: generalize to `WithTop` theorem mul_lt_mul_right : c ≠ 0 → c ≠ ∞ → (a * c < b * c ↔ a < b) := mul_comm c a ▸ mul_comm c b ▸ mul_lt_mul_left #align ennreal.mul_lt_mul_right ENNReal.mul_lt_mul_right end Mul section OperationsAndOrder protected theorem pow_pos : 0 < a → ∀ n : ℕ, 0 < a ^ n := CanonicallyOrderedCommSemiring.pow_pos #align ennreal.pow_pos ENNReal.pow_pos protected theorem pow_ne_zero : a ≠ 0 → ∀ n : ℕ, a ^ n ≠ 0 := by simpa only [pos_iff_ne_zero] using ENNReal.pow_pos #align ennreal.pow_ne_zero ENNReal.pow_ne_zero theorem not_lt_zero : ¬a < 0 := by simp #align ennreal.not_lt_zero ENNReal.not_lt_zero protected theorem le_of_add_le_add_left : a ≠ ∞ → a + b ≤ a + c → b ≤ c := WithTop.le_of_add_le_add_left #align ennreal.le_of_add_le_add_left ENNReal.le_of_add_le_add_left protected theorem le_of_add_le_add_right : a ≠ ∞ → b + a ≤ c + a → b ≤ c := WithTop.le_of_add_le_add_right #align ennreal.le_of_add_le_add_right ENNReal.le_of_add_le_add_right @[gcongr] protected theorem add_lt_add_left : a ≠ ∞ → b < c → a + b < a + c := WithTop.add_lt_add_left #align ennreal.add_lt_add_left ENNReal.add_lt_add_left @[gcongr] protected theorem add_lt_add_right : a ≠ ∞ → b < c → b + a < c + a := WithTop.add_lt_add_right #align ennreal.add_lt_add_right ENNReal.add_lt_add_right protected theorem add_le_add_iff_left : a ≠ ∞ → (a + b ≤ a + c ↔ b ≤ c) := WithTop.add_le_add_iff_left #align ennreal.add_le_add_iff_left ENNReal.add_le_add_iff_left protected theorem add_le_add_iff_right : a ≠ ∞ → (b + a ≤ c + a ↔ b ≤ c) := WithTop.add_le_add_iff_right #align ennreal.add_le_add_iff_right ENNReal.add_le_add_iff_right protected theorem add_lt_add_iff_left : a ≠ ∞ → (a + b < a + c ↔ b < c) := WithTop.add_lt_add_iff_left #align ennreal.add_lt_add_iff_left ENNReal.add_lt_add_iff_left protected theorem add_lt_add_iff_right : a ≠ ∞ → (b + a < c + a ↔ b < c) := WithTop.add_lt_add_iff_right #align ennreal.add_lt_add_iff_right ENNReal.add_lt_add_iff_right protected theorem add_lt_add_of_le_of_lt : a ≠ ∞ → a ≤ b → c < d → a + c < b + d := WithTop.add_lt_add_of_le_of_lt #align ennreal.add_lt_add_of_le_of_lt ENNReal.add_lt_add_of_le_of_lt protected theorem add_lt_add_of_lt_of_le : c ≠ ∞ → a < b → c ≤ d → a + c < b + d := WithTop.add_lt_add_of_lt_of_le #align ennreal.add_lt_add_of_lt_of_le ENNReal.add_lt_add_of_lt_of_le instance contravariantClass_add_lt : ContravariantClass ℝ≥0∞ ℝ≥0∞ (· + ·) (· < ·) := WithTop.contravariantClass_add_lt #align ennreal.contravariant_class_add_lt ENNReal.contravariantClass_add_lt theorem lt_add_right (ha : a ≠ ∞) (hb : b ≠ 0) : a < a + b := by rwa [← pos_iff_ne_zero, ← ENNReal.add_lt_add_iff_left ha, add_zero] at hb #align ennreal.lt_add_right ENNReal.lt_add_right end OperationsAndOrder section OperationsAndInfty variable {α : Type*} @[simp] theorem add_eq_top : a + b = ∞ ↔ a = ∞ ∨ b = ∞ := WithTop.add_eq_top #align ennreal.add_eq_top ENNReal.add_eq_top @[simp] theorem add_lt_top : a + b < ∞ ↔ a < ∞ ∧ b < ∞ := WithTop.add_lt_top #align ennreal.add_lt_top ENNReal.add_lt_top theorem toNNReal_add {r₁ r₂ : ℝ≥0∞} (h₁ : r₁ ≠ ∞) (h₂ : r₂ ≠ ∞) : (r₁ + r₂).toNNReal = r₁.toNNReal + r₂.toNNReal := by lift r₁ to ℝ≥0 using h₁ lift r₂ to ℝ≥0 using h₂ rfl #align ennreal.to_nnreal_add ENNReal.toNNReal_add theorem not_lt_top {x : ℝ≥0∞} : ¬x < ∞ ↔ x = ∞ := by rw [lt_top_iff_ne_top, Classical.not_not] #align ennreal.not_lt_top ENNReal.not_lt_top theorem add_ne_top : a + b ≠ ∞ ↔ a ≠ ∞ ∧ b ≠ ∞ := by simpa only [lt_top_iff_ne_top] using add_lt_top #align ennreal.add_ne_top ENNReal.add_ne_top theorem mul_top' : a * ∞ = if a = 0 then 0 else ∞ := by convert WithTop.mul_top' a #align ennreal.mul_top ENNReal.mul_top' -- Porting note: added because `simp` no longer uses `WithTop` lemmas for `ℝ≥0∞` @[simp] theorem mul_top (h : a ≠ 0) : a * ∞ = ∞ := WithTop.mul_top h
Mathlib/Data/ENNReal/Operations.lean
212
212
theorem top_mul' : ∞ * a = if a = 0 then 0 else ∞ := by
convert WithTop.top_mul' a
/- Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro Coinductive formalization of unbounded computations. -/ import Mathlib.Data.Stream.Init import Mathlib.Tactic.Common #align_import data.seq.computation from "leanprover-community/mathlib"@"1f0096e6caa61e9c849ec2adbd227e960e9dff58" /-! # Coinductive formalization of unbounded computations. This file provides a `Computation` type where `Computation α` is the type of unbounded computations returning `α`. -/ open Function universe u v w /- coinductive Computation (α : Type u) : Type u | pure : α → Computation α | think : Computation α → Computation α -/ /-- `Computation α` is the type of unbounded computations returning `α`. An element of `Computation α` is an infinite sequence of `Option α` such that if `f n = some a` for some `n` then it is constantly `some a` after that. -/ def Computation (α : Type u) : Type u := { f : Stream' (Option α) // ∀ ⦃n a⦄, f n = some a → f (n + 1) = some a } #align computation Computation namespace Computation variable {α : Type u} {β : Type v} {γ : Type w} -- constructors /-- `pure a` is the computation that immediately terminates with result `a`. -/ -- Porting note: `return` is reserved, so changed to `pure` def pure (a : α) : Computation α := ⟨Stream'.const (some a), fun _ _ => id⟩ #align computation.return Computation.pure instance : CoeTC α (Computation α) := ⟨pure⟩ -- note [use has_coe_t] /-- `think c` is the computation that delays for one "tick" and then performs computation `c`. -/ def think (c : Computation α) : Computation α := ⟨Stream'.cons none c.1, fun n a h => by cases' n with n · contradiction · exact c.2 h⟩ #align computation.think Computation.think /-- `thinkN c n` is the computation that delays for `n` ticks and then performs computation `c`. -/ def thinkN (c : Computation α) : ℕ → Computation α | 0 => c | n + 1 => think (thinkN c n) set_option linter.uppercaseLean3 false in #align computation.thinkN Computation.thinkN -- check for immediate result /-- `head c` is the first step of computation, either `some a` if `c = pure a` or `none` if `c = think c'`. -/ def head (c : Computation α) : Option α := c.1.head #align computation.head Computation.head -- one step of computation /-- `tail c` is the remainder of computation, either `c` if `c = pure a` or `c'` if `c = think c'`. -/ def tail (c : Computation α) : Computation α := ⟨c.1.tail, fun _ _ h => c.2 h⟩ #align computation.tail Computation.tail /-- `empty α` is the computation that never returns, an infinite sequence of `think`s. -/ def empty (α) : Computation α := ⟨Stream'.const none, fun _ _ => id⟩ #align computation.empty Computation.empty instance : Inhabited (Computation α) := ⟨empty _⟩ /-- `runFor c n` evaluates `c` for `n` steps and returns the result, or `none` if it did not terminate after `n` steps. -/ def runFor : Computation α → ℕ → Option α := Subtype.val #align computation.run_for Computation.runFor /-- `destruct c` is the destructor for `Computation α` as a coinductive type. It returns `inl a` if `c = pure a` and `inr c'` if `c = think c'`. -/ def destruct (c : Computation α) : Sum α (Computation α) := match c.1 0 with | none => Sum.inr (tail c) | some a => Sum.inl a #align computation.destruct Computation.destruct /-- `run c` is an unsound meta function that runs `c` to completion, possibly resulting in an infinite loop in the VM. -/ unsafe def run : Computation α → α | c => match destruct c with | Sum.inl a => a | Sum.inr ca => run ca #align computation.run Computation.run theorem destruct_eq_pure {s : Computation α} {a : α} : destruct s = Sum.inl a → s = pure a := by dsimp [destruct] induction' f0 : s.1 0 with _ <;> intro h · contradiction · apply Subtype.eq funext n induction' n with n IH · injection h with h' rwa [h'] at f0 · exact s.2 IH #align computation.destruct_eq_ret Computation.destruct_eq_pure theorem destruct_eq_think {s : Computation α} {s'} : destruct s = Sum.inr s' → s = think s' := by dsimp [destruct] induction' f0 : s.1 0 with a' <;> intro h · injection h with h' rw [← h'] cases' s with f al apply Subtype.eq dsimp [think, tail] rw [← f0] exact (Stream'.eta f).symm · contradiction #align computation.destruct_eq_think Computation.destruct_eq_think @[simp] theorem destruct_pure (a : α) : destruct (pure a) = Sum.inl a := rfl #align computation.destruct_ret Computation.destruct_pure @[simp] theorem destruct_think : ∀ s : Computation α, destruct (think s) = Sum.inr s | ⟨_, _⟩ => rfl #align computation.destruct_think Computation.destruct_think @[simp] theorem destruct_empty : destruct (empty α) = Sum.inr (empty α) := rfl #align computation.destruct_empty Computation.destruct_empty @[simp] theorem head_pure (a : α) : head (pure a) = some a := rfl #align computation.head_ret Computation.head_pure @[simp] theorem head_think (s : Computation α) : head (think s) = none := rfl #align computation.head_think Computation.head_think @[simp] theorem head_empty : head (empty α) = none := rfl #align computation.head_empty Computation.head_empty @[simp] theorem tail_pure (a : α) : tail (pure a) = pure a := rfl #align computation.tail_ret Computation.tail_pure @[simp] theorem tail_think (s : Computation α) : tail (think s) = s := by cases' s with f al; apply Subtype.eq; dsimp [tail, think] #align computation.tail_think Computation.tail_think @[simp] theorem tail_empty : tail (empty α) = empty α := rfl #align computation.tail_empty Computation.tail_empty theorem think_empty : empty α = think (empty α) := destruct_eq_think destruct_empty #align computation.think_empty Computation.think_empty /-- Recursion principle for computations, compare with `List.recOn`. -/ def recOn {C : Computation α → Sort v} (s : Computation α) (h1 : ∀ a, C (pure a)) (h2 : ∀ s, C (think s)) : C s := match H : destruct s with | Sum.inl v => by rw [destruct_eq_pure H] apply h1 | Sum.inr v => match v with | ⟨a, s'⟩ => by rw [destruct_eq_think H] apply h2 #align computation.rec_on Computation.recOn /-- Corecursor constructor for `corec`-/ def Corec.f (f : β → Sum α β) : Sum α β → Option α × Sum α β | Sum.inl a => (some a, Sum.inl a) | Sum.inr b => (match f b with | Sum.inl a => some a | Sum.inr _ => none, f b) set_option linter.uppercaseLean3 false in #align computation.corec.F Computation.Corec.f /-- `corec f b` is the corecursor for `Computation α` as a coinductive type. If `f b = inl a` then `corec f b = pure a`, and if `f b = inl b'` then `corec f b = think (corec f b')`. -/ def corec (f : β → Sum α β) (b : β) : Computation α := by refine ⟨Stream'.corec' (Corec.f f) (Sum.inr b), fun n a' h => ?_⟩ rw [Stream'.corec'_eq] change Stream'.corec' (Corec.f f) (Corec.f f (Sum.inr b)).2 n = some a' revert h; generalize Sum.inr b = o; revert o induction' n with n IH <;> intro o · change (Corec.f f o).1 = some a' → (Corec.f f (Corec.f f o).2).1 = some a' cases' o with _ b <;> intro h · exact h unfold Corec.f at *; split <;> simp_all · 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 computation.corec Computation.corec /-- left map of `⊕` -/ def lmap (f : α → β) : Sum α γ → Sum β γ | Sum.inl a => Sum.inl (f a) | Sum.inr b => Sum.inr b #align computation.lmap Computation.lmap /-- right map of `⊕` -/ def rmap (f : β → γ) : Sum α β → Sum α γ | Sum.inl a => Sum.inl a | Sum.inr b => Sum.inr (f b) #align computation.rmap Computation.rmap attribute [simp] lmap rmap -- Porting note: this was far less painful in mathlib3. There seem to be two issues; -- firstly, in mathlib3 we have `corec.F._match_1` and it's the obvious map α ⊕ β → option α. -- In mathlib4 we have `Corec.f.match_1` and it's something completely different. -- Secondly, the proof that `Stream'.corec' (Corec.f f) (Sum.inr b) 0` is this function -- evaluated at `f b`, used to be `rfl` and now is `cases, rfl`. @[simp] theorem corec_eq (f : β → Sum α β) (b : β) : destruct (corec f b) = rmap (corec f) (f b) := by dsimp [corec, destruct] rw [show Stream'.corec' (Corec.f f) (Sum.inr b) 0 = Sum.rec Option.some (fun _ ↦ none) (f b) by dsimp [Corec.f, Stream'.corec', Stream'.corec, Stream'.map, Stream'.get, Stream'.iterate] match (f b) with | Sum.inl x => rfl | Sum.inr x => rfl ] induction' h : f b with a b'; · rfl dsimp [Corec.f, destruct] apply congr_arg; apply Subtype.eq dsimp [corec, tail] rw [Stream'.corec'_eq, Stream'.tail_cons] dsimp [Corec.f]; rw [h] #align computation.corec_eq Computation.corec_eq section Bisim variable (R : Computation α → Computation α → Prop) /-- bisimilarity relation-/ local infixl:50 " ~ " => R /-- Bisimilarity over a sum of `Computation`s-/ def BisimO : Sum α (Computation α) → Sum α (Computation α) → Prop | Sum.inl a, Sum.inl a' => a = a' | Sum.inr s, Sum.inr s' => R s s' | _, _ => False #align computation.bisim_o Computation.BisimO attribute [simp] BisimO /-- Attribute expressing bisimilarity over two `Computation`s-/ def IsBisimulation := ∀ ⦃s₁ s₂⦄, s₁ ~ s₂ → BisimO R (destruct s₁) (destruct s₂) #align computation.is_bisimulation Computation.IsBisimulation -- If two computations are bisimilar, then they are equal 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' : Computation α, s.1 = x ∧ s'.1 = y ∧ R s s' · dsimp [Stream'.IsBisimulation] intro t₁ t₂ e match t₁, t₂, e with | _, _, ⟨s, s', rfl, rfl, r⟩ => 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 h := bisim r; revert r h apply recOn s _ _ <;> intro r' <;> apply recOn s' _ _ <;> intro a' r h · constructor <;> dsimp at h · rw [h] · rw [h] at r rw [tail_pure, tail_pure,h] assumption · rw [destruct_pure, destruct_think] at h exact False.elim h · rw [destruct_pure, destruct_think] at h exact False.elim h · simp_all · exact ⟨s₁, s₂, rfl, rfl, r⟩ #align computation.eq_of_bisim Computation.eq_of_bisim end Bisim -- It's more of a stretch to use ∈ for this relation, but it -- asserts that the computation limits to the given value. /-- Assertion that a `Computation` limits to a given value-/ protected def Mem (a : α) (s : Computation α) := some a ∈ s.1 #align computation.mem Computation.Mem instance : Membership α (Computation α) := ⟨Computation.Mem⟩ theorem le_stable (s : Computation α) {a m n} (h : m ≤ n) : s.1 m = some a → s.1 n = some a := by cases' s with f al induction' h with n _ IH exacts [id, fun h2 => al (IH h2)] #align computation.le_stable Computation.le_stable theorem mem_unique {s : Computation α} {a b : α} : a ∈ s → b ∈ s → a = b | ⟨m, ha⟩, ⟨n, hb⟩ => by injection (le_stable s (le_max_left m n) ha.symm).symm.trans (le_stable s (le_max_right m n) hb.symm) #align computation.mem_unique Computation.mem_unique theorem Mem.left_unique : Relator.LeftUnique ((· ∈ ·) : α → Computation α → Prop) := fun _ _ _ => mem_unique #align computation.mem.left_unique Computation.Mem.left_unique /-- `Terminates s` asserts that the computation `s` eventually terminates with some value. -/ class Terminates (s : Computation α) : Prop where /-- assertion that there is some term `a` such that the `Computation` terminates -/ term : ∃ a, a ∈ s #align computation.terminates Computation.Terminates theorem terminates_iff (s : Computation α) : Terminates s ↔ ∃ a, a ∈ s := ⟨fun h => h.1, Terminates.mk⟩ #align computation.terminates_iff Computation.terminates_iff theorem terminates_of_mem {s : Computation α} {a : α} (h : a ∈ s) : Terminates s := ⟨⟨a, h⟩⟩ #align computation.terminates_of_mem Computation.terminates_of_mem theorem terminates_def (s : Computation α) : Terminates s ↔ ∃ n, (s.1 n).isSome := ⟨fun ⟨⟨a, n, h⟩⟩ => ⟨n, by dsimp [Stream'.get] at h rw [← h] exact rfl⟩, fun ⟨n, h⟩ => ⟨⟨Option.get _ h, n, (Option.eq_some_of_isSome h).symm⟩⟩⟩ #align computation.terminates_def Computation.terminates_def theorem ret_mem (a : α) : a ∈ pure a := Exists.intro 0 rfl #align computation.ret_mem Computation.ret_mem theorem eq_of_pure_mem {a a' : α} (h : a' ∈ pure a) : a' = a := mem_unique h (ret_mem _) #align computation.eq_of_ret_mem Computation.eq_of_pure_mem instance ret_terminates (a : α) : Terminates (pure a) := terminates_of_mem (ret_mem _) #align computation.ret_terminates Computation.ret_terminates theorem think_mem {s : Computation α} {a} : a ∈ s → a ∈ think s | ⟨n, h⟩ => ⟨n + 1, h⟩ #align computation.think_mem Computation.think_mem instance think_terminates (s : Computation α) : ∀ [Terminates s], Terminates (think s) | ⟨⟨a, n, h⟩⟩ => ⟨⟨a, n + 1, h⟩⟩ #align computation.think_terminates Computation.think_terminates theorem of_think_mem {s : Computation α} {a} : a ∈ think s → a ∈ s | ⟨n, h⟩ => by cases' n with n' · contradiction · exact ⟨n', h⟩ #align computation.of_think_mem Computation.of_think_mem theorem of_think_terminates {s : Computation α} : Terminates (think s) → Terminates s | ⟨⟨a, h⟩⟩ => ⟨⟨a, of_think_mem h⟩⟩ #align computation.of_think_terminates Computation.of_think_terminates theorem not_mem_empty (a : α) : a ∉ empty α := fun ⟨n, h⟩ => by contradiction #align computation.not_mem_empty Computation.not_mem_empty theorem not_terminates_empty : ¬Terminates (empty α) := fun ⟨⟨a, h⟩⟩ => not_mem_empty a h #align computation.not_terminates_empty Computation.not_terminates_empty theorem eq_empty_of_not_terminates {s} (H : ¬Terminates s) : s = empty α := by apply Subtype.eq; funext n induction' h : s.val n with _; · rfl refine absurd ?_ H; exact ⟨⟨_, _, h.symm⟩⟩ #align computation.eq_empty_of_not_terminates Computation.eq_empty_of_not_terminates theorem thinkN_mem {s : Computation α} {a} : ∀ n, a ∈ thinkN s n ↔ a ∈ s | 0 => Iff.rfl | n + 1 => Iff.trans ⟨of_think_mem, think_mem⟩ (thinkN_mem n) set_option linter.uppercaseLean3 false in #align computation.thinkN_mem Computation.thinkN_mem instance thinkN_terminates (s : Computation α) : ∀ [Terminates s] (n), Terminates (thinkN s n) | ⟨⟨a, h⟩⟩, n => ⟨⟨a, (thinkN_mem n).2 h⟩⟩ set_option linter.uppercaseLean3 false in #align computation.thinkN_terminates Computation.thinkN_terminates theorem of_thinkN_terminates (s : Computation α) (n) : Terminates (thinkN s n) → Terminates s | ⟨⟨a, h⟩⟩ => ⟨⟨a, (thinkN_mem _).1 h⟩⟩ set_option linter.uppercaseLean3 false in #align computation.of_thinkN_terminates Computation.of_thinkN_terminates /-- `Promises s a`, or `s ~> a`, asserts that although the computation `s` may not terminate, if it does, then the result is `a`. -/ def Promises (s : Computation α) (a : α) : Prop := ∀ ⦃a'⦄, a' ∈ s → a = a' #align computation.promises Computation.Promises /-- `Promises s a`, or `s ~> a`, asserts that although the computation `s` may not terminate, if it does, then the result is `a`. -/ scoped infixl:50 " ~> " => Promises theorem mem_promises {s : Computation α} {a : α} : a ∈ s → s ~> a := fun h _ => mem_unique h #align computation.mem_promises Computation.mem_promises theorem empty_promises (a : α) : empty α ~> a := fun _ h => absurd h (not_mem_empty _) #align computation.empty_promises Computation.empty_promises section get variable (s : Computation α) [h : Terminates s] /-- `length s` gets the number of steps of a terminating computation -/ def length : ℕ := Nat.find ((terminates_def _).1 h) #align computation.length Computation.length /-- `get s` returns the result of a terminating computation -/ def get : α := Option.get _ (Nat.find_spec <| (terminates_def _).1 h) #align computation.get Computation.get theorem get_mem : get s ∈ s := Exists.intro (length s) (Option.eq_some_of_isSome _).symm #align computation.get_mem Computation.get_mem theorem get_eq_of_mem {a} : a ∈ s → get s = a := mem_unique (get_mem _) #align computation.get_eq_of_mem Computation.get_eq_of_mem theorem mem_of_get_eq {a} : get s = a → a ∈ s := by intro h; rw [← h]; apply get_mem #align computation.mem_of_get_eq Computation.mem_of_get_eq @[simp] theorem get_think : get (think s) = get s := get_eq_of_mem _ <| let ⟨n, h⟩ := get_mem s ⟨n + 1, h⟩ #align computation.get_think Computation.get_think @[simp] theorem get_thinkN (n) : get (thinkN s n) = get s := get_eq_of_mem _ <| (thinkN_mem _).2 (get_mem _) set_option linter.uppercaseLean3 false in #align computation.get_thinkN Computation.get_thinkN theorem get_promises : s ~> get s := fun _ => get_eq_of_mem _ #align computation.get_promises Computation.get_promises theorem mem_of_promises {a} (p : s ~> a) : a ∈ s := by cases' h with h cases' h with a' h rw [p h] exact h #align computation.mem_of_promises Computation.mem_of_promises theorem get_eq_of_promises {a} : s ~> a → get s = a := get_eq_of_mem _ ∘ mem_of_promises _ #align computation.get_eq_of_promises Computation.get_eq_of_promises end get /-- `Results s a n` completely characterizes a terminating computation: it asserts that `s` terminates after exactly `n` steps, with result `a`. -/ def Results (s : Computation α) (a : α) (n : ℕ) := ∃ h : a ∈ s, @length _ s (terminates_of_mem h) = n #align computation.results Computation.Results theorem results_of_terminates (s : Computation α) [_T : Terminates s] : Results s (get s) (length s) := ⟨get_mem _, rfl⟩ #align computation.results_of_terminates Computation.results_of_terminates theorem results_of_terminates' (s : Computation α) [T : Terminates s] {a} (h : a ∈ s) : Results s a (length s) := by rw [← get_eq_of_mem _ h]; apply results_of_terminates #align computation.results_of_terminates' Computation.results_of_terminates' theorem Results.mem {s : Computation α} {a n} : Results s a n → a ∈ s | ⟨m, _⟩ => m #align computation.results.mem Computation.Results.mem theorem Results.terminates {s : Computation α} {a n} (h : Results s a n) : Terminates s := terminates_of_mem h.mem #align computation.results.terminates Computation.Results.terminates theorem Results.length {s : Computation α} {a n} [_T : Terminates s] : Results s a n → length s = n | ⟨_, h⟩ => h #align computation.results.length Computation.Results.length theorem Results.val_unique {s : Computation α} {a b m n} (h1 : Results s a m) (h2 : Results s b n) : a = b := mem_unique h1.mem h2.mem #align computation.results.val_unique Computation.Results.val_unique theorem Results.len_unique {s : Computation α} {a b m n} (h1 : Results s a m) (h2 : Results s b n) : m = n := by haveI := h1.terminates; haveI := h2.terminates; rw [← h1.length, h2.length] #align computation.results.len_unique Computation.Results.len_unique theorem exists_results_of_mem {s : Computation α} {a} (h : a ∈ s) : ∃ n, Results s a n := haveI := terminates_of_mem h ⟨_, results_of_terminates' s h⟩ #align computation.exists_results_of_mem Computation.exists_results_of_mem @[simp] theorem get_pure (a : α) : get (pure a) = a := get_eq_of_mem _ ⟨0, rfl⟩ #align computation.get_ret Computation.get_pure @[simp] theorem length_pure (a : α) : length (pure a) = 0 := let h := Computation.ret_terminates a Nat.eq_zero_of_le_zero <| Nat.find_min' ((terminates_def (pure a)).1 h) rfl #align computation.length_ret Computation.length_pure theorem results_pure (a : α) : Results (pure a) a 0 := ⟨ret_mem a, length_pure _⟩ #align computation.results_ret Computation.results_pure @[simp]
Mathlib/Data/Seq/Computation.lean
549
558
theorem length_think (s : Computation α) [h : Terminates s] : length (think s) = length s + 1 := by
apply le_antisymm · exact Nat.find_min' _ (Nat.find_spec ((terminates_def _).1 h)) · have : (Option.isSome ((think s).val (length (think s))) : Prop) := Nat.find_spec ((terminates_def _).1 s.think_terminates) revert this; cases' length (think s) with n <;> intro this · simp [think, Stream'.cons] at this · apply Nat.succ_le_succ apply Nat.find_min' apply this
/- Copyright (c) 2018 Chris Hughes. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle Sönne, Benjamin Davidson -/ import Mathlib.Order.Monotone.Odd import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic #align_import analysis.special_functions.trigonometric.deriv from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1" /-! # Differentiability of trigonometric functions ## Main statements The differentiability of the usual trigonometric functions is proved, and their derivatives are computed. ## Tags sin, cos, tan, angle -/ noncomputable section open scoped Classical Topology Filter open Set Filter namespace Complex /-- The complex sine function is everywhere strictly differentiable, with the derivative `cos x`. -/ theorem hasStrictDerivAt_sin (x : ℂ) : HasStrictDerivAt sin (cos x) x := by simp only [cos, div_eq_mul_inv] convert ((((hasStrictDerivAt_id x).neg.mul_const I).cexp.sub ((hasStrictDerivAt_id x).mul_const I).cexp).mul_const I).mul_const (2 : ℂ)⁻¹ using 1 simp only [Function.comp, id] rw [sub_mul, mul_assoc, mul_assoc, I_mul_I, neg_one_mul, neg_neg, mul_one, one_mul, mul_assoc, I_mul_I, mul_neg_one, sub_neg_eq_add, add_comm] #align complex.has_strict_deriv_at_sin Complex.hasStrictDerivAt_sin /-- The complex sine function is everywhere differentiable, with the derivative `cos x`. -/ theorem hasDerivAt_sin (x : ℂ) : HasDerivAt sin (cos x) x := (hasStrictDerivAt_sin x).hasDerivAt #align complex.has_deriv_at_sin Complex.hasDerivAt_sin theorem contDiff_sin {n} : ContDiff ℂ n sin := (((contDiff_neg.mul contDiff_const).cexp.sub (contDiff_id.mul contDiff_const).cexp).mul contDiff_const).div_const _ #align complex.cont_diff_sin Complex.contDiff_sin theorem differentiable_sin : Differentiable ℂ sin := fun x => (hasDerivAt_sin x).differentiableAt #align complex.differentiable_sin Complex.differentiable_sin theorem differentiableAt_sin {x : ℂ} : DifferentiableAt ℂ sin x := differentiable_sin x #align complex.differentiable_at_sin Complex.differentiableAt_sin @[simp] theorem deriv_sin : deriv sin = cos := funext fun x => (hasDerivAt_sin x).deriv #align complex.deriv_sin Complex.deriv_sin /-- The complex cosine function is everywhere strictly differentiable, with the derivative `-sin x`. -/ theorem hasStrictDerivAt_cos (x : ℂ) : HasStrictDerivAt cos (-sin x) x := by simp only [sin, div_eq_mul_inv, neg_mul_eq_neg_mul] convert (((hasStrictDerivAt_id x).mul_const I).cexp.add ((hasStrictDerivAt_id x).neg.mul_const I).cexp).mul_const (2 : ℂ)⁻¹ using 1 simp only [Function.comp, id] ring #align complex.has_strict_deriv_at_cos Complex.hasStrictDerivAt_cos /-- The complex cosine function is everywhere differentiable, with the derivative `-sin x`. -/ theorem hasDerivAt_cos (x : ℂ) : HasDerivAt cos (-sin x) x := (hasStrictDerivAt_cos x).hasDerivAt #align complex.has_deriv_at_cos Complex.hasDerivAt_cos theorem contDiff_cos {n} : ContDiff ℂ n cos := ((contDiff_id.mul contDiff_const).cexp.add (contDiff_neg.mul contDiff_const).cexp).div_const _ #align complex.cont_diff_cos Complex.contDiff_cos theorem differentiable_cos : Differentiable ℂ cos := fun x => (hasDerivAt_cos x).differentiableAt #align complex.differentiable_cos Complex.differentiable_cos theorem differentiableAt_cos {x : ℂ} : DifferentiableAt ℂ cos x := differentiable_cos x #align complex.differentiable_at_cos Complex.differentiableAt_cos theorem deriv_cos {x : ℂ} : deriv cos x = -sin x := (hasDerivAt_cos x).deriv #align complex.deriv_cos Complex.deriv_cos @[simp] theorem deriv_cos' : deriv cos = fun x => -sin x := funext fun _ => deriv_cos #align complex.deriv_cos' Complex.deriv_cos' /-- The complex hyperbolic sine function is everywhere strictly differentiable, with the derivative `cosh x`. -/ theorem hasStrictDerivAt_sinh (x : ℂ) : HasStrictDerivAt sinh (cosh x) x := by simp only [cosh, div_eq_mul_inv] convert ((hasStrictDerivAt_exp x).sub (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg, neg_neg] #align complex.has_strict_deriv_at_sinh Complex.hasStrictDerivAt_sinh /-- The complex hyperbolic sine function is everywhere differentiable, with the derivative `cosh x`. -/ theorem hasDerivAt_sinh (x : ℂ) : HasDerivAt sinh (cosh x) x := (hasStrictDerivAt_sinh x).hasDerivAt #align complex.has_deriv_at_sinh Complex.hasDerivAt_sinh theorem contDiff_sinh {n} : ContDiff ℂ n sinh := (contDiff_exp.sub contDiff_neg.cexp).div_const _ #align complex.cont_diff_sinh Complex.contDiff_sinh theorem differentiable_sinh : Differentiable ℂ sinh := fun x => (hasDerivAt_sinh x).differentiableAt #align complex.differentiable_sinh Complex.differentiable_sinh theorem differentiableAt_sinh {x : ℂ} : DifferentiableAt ℂ sinh x := differentiable_sinh x #align complex.differentiable_at_sinh Complex.differentiableAt_sinh @[simp] theorem deriv_sinh : deriv sinh = cosh := funext fun x => (hasDerivAt_sinh x).deriv #align complex.deriv_sinh Complex.deriv_sinh /-- The complex hyperbolic cosine function is everywhere strictly differentiable, with the derivative `sinh x`. -/ theorem hasStrictDerivAt_cosh (x : ℂ) : HasStrictDerivAt cosh (sinh x) x := by simp only [sinh, div_eq_mul_inv] convert ((hasStrictDerivAt_exp x).add (hasStrictDerivAt_id x).neg.cexp).mul_const (2 : ℂ)⁻¹ using 1 rw [id, mul_neg_one, sub_eq_add_neg] #align complex.has_strict_deriv_at_cosh Complex.hasStrictDerivAt_cosh /-- The complex hyperbolic cosine function is everywhere differentiable, with the derivative `sinh x`. -/ theorem hasDerivAt_cosh (x : ℂ) : HasDerivAt cosh (sinh x) x := (hasStrictDerivAt_cosh x).hasDerivAt #align complex.has_deriv_at_cosh Complex.hasDerivAt_cosh theorem contDiff_cosh {n} : ContDiff ℂ n cosh := (contDiff_exp.add contDiff_neg.cexp).div_const _ #align complex.cont_diff_cosh Complex.contDiff_cosh theorem differentiable_cosh : Differentiable ℂ cosh := fun x => (hasDerivAt_cosh x).differentiableAt #align complex.differentiable_cosh Complex.differentiable_cosh theorem differentiableAt_cosh {x : ℂ} : DifferentiableAt ℂ cosh x := differentiable_cosh x #align complex.differentiable_at_cosh Complex.differentiableAt_cosh @[simp] theorem deriv_cosh : deriv cosh = sinh := funext fun x => (hasDerivAt_cosh x).deriv #align complex.deriv_cosh Complex.deriv_cosh end Complex section /-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : ℂ → ℂ` -/ variable {f : ℂ → ℂ} {f' x : ℂ} {s : Set ℂ} /-! #### `Complex.cos` -/ theorem HasStrictDerivAt.ccos (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x := (Complex.hasStrictDerivAt_cos (f x)).comp x hf #align has_strict_deriv_at.ccos HasStrictDerivAt.ccos theorem HasDerivAt.ccos (hf : HasDerivAt f f' x) : HasDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') x := (Complex.hasDerivAt_cos (f x)).comp x hf #align has_deriv_at.ccos HasDerivAt.ccos theorem HasDerivWithinAt.ccos (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) * f') s x := (Complex.hasDerivAt_cos (f x)).comp_hasDerivWithinAt x hf #align has_deriv_within_at.ccos HasDerivWithinAt.ccos theorem derivWithin_ccos (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : derivWithin (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) * derivWithin f s x := hf.hasDerivWithinAt.ccos.derivWithin hxs #align deriv_within_ccos derivWithin_ccos @[simp] theorem deriv_ccos (hc : DifferentiableAt ℂ f x) : deriv (fun x => Complex.cos (f x)) x = -Complex.sin (f x) * deriv f x := hc.hasDerivAt.ccos.deriv #align deriv_ccos deriv_ccos /-! #### `Complex.sin` -/ theorem HasStrictDerivAt.csin (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x := (Complex.hasStrictDerivAt_sin (f x)).comp x hf #align has_strict_deriv_at.csin HasStrictDerivAt.csin theorem HasDerivAt.csin (hf : HasDerivAt f f' x) : HasDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') x := (Complex.hasDerivAt_sin (f x)).comp x hf #align has_deriv_at.csin HasDerivAt.csin theorem HasDerivWithinAt.csin (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) * f') s x := (Complex.hasDerivAt_sin (f x)).comp_hasDerivWithinAt x hf #align has_deriv_within_at.csin HasDerivWithinAt.csin theorem derivWithin_csin (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : derivWithin (fun x => Complex.sin (f x)) s x = Complex.cos (f x) * derivWithin f s x := hf.hasDerivWithinAt.csin.derivWithin hxs #align deriv_within_csin derivWithin_csin @[simp] theorem deriv_csin (hc : DifferentiableAt ℂ f x) : deriv (fun x => Complex.sin (f x)) x = Complex.cos (f x) * deriv f x := hc.hasDerivAt.csin.deriv #align deriv_csin deriv_csin /-! #### `Complex.cosh` -/ theorem HasStrictDerivAt.ccosh (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x := (Complex.hasStrictDerivAt_cosh (f x)).comp x hf #align has_strict_deriv_at.ccosh HasStrictDerivAt.ccosh theorem HasDerivAt.ccosh (hf : HasDerivAt f f' x) : HasDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') x := (Complex.hasDerivAt_cosh (f x)).comp x hf #align has_deriv_at.ccosh HasDerivAt.ccosh theorem HasDerivWithinAt.ccosh (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) * f') s x := (Complex.hasDerivAt_cosh (f x)).comp_hasDerivWithinAt x hf #align has_deriv_within_at.ccosh HasDerivWithinAt.ccosh theorem derivWithin_ccosh (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : derivWithin (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) * derivWithin f s x := hf.hasDerivWithinAt.ccosh.derivWithin hxs #align deriv_within_ccosh derivWithin_ccosh @[simp] theorem deriv_ccosh (hc : DifferentiableAt ℂ f x) : deriv (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) * deriv f x := hc.hasDerivAt.ccosh.deriv #align deriv_ccosh deriv_ccosh /-! #### `Complex.sinh` -/ theorem HasStrictDerivAt.csinh (hf : HasStrictDerivAt f f' x) : HasStrictDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x := (Complex.hasStrictDerivAt_sinh (f x)).comp x hf #align has_strict_deriv_at.csinh HasStrictDerivAt.csinh theorem HasDerivAt.csinh (hf : HasDerivAt f f' x) : HasDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') x := (Complex.hasDerivAt_sinh (f x)).comp x hf #align has_deriv_at.csinh HasDerivAt.csinh theorem HasDerivWithinAt.csinh (hf : HasDerivWithinAt f f' s x) : HasDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) * f') s x := (Complex.hasDerivAt_sinh (f x)).comp_hasDerivWithinAt x hf #align has_deriv_within_at.csinh HasDerivWithinAt.csinh theorem derivWithin_csinh (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : derivWithin (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) * derivWithin f s x := hf.hasDerivWithinAt.csinh.derivWithin hxs #align deriv_within_csinh derivWithin_csinh @[simp] theorem deriv_csinh (hc : DifferentiableAt ℂ f x) : deriv (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) * deriv f x := hc.hasDerivAt.csinh.deriv #align deriv_csinh deriv_csinh end section /-! ### Simp lemmas for derivatives of `fun x => Complex.cos (f x)` etc., `f : E → ℂ` -/ variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E] {f : E → ℂ} {f' : E →L[ℂ] ℂ} {x : E} {s : Set E} /-! #### `Complex.cos` -/ theorem HasStrictFDerivAt.ccos (hf : HasStrictFDerivAt f f' x) : HasStrictFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) • f') x := (Complex.hasStrictDerivAt_cos (f x)).comp_hasStrictFDerivAt x hf #align has_strict_fderiv_at.ccos HasStrictFDerivAt.ccos theorem HasFDerivAt.ccos (hf : HasFDerivAt f f' x) : HasFDerivAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) • f') x := (Complex.hasDerivAt_cos (f x)).comp_hasFDerivAt x hf #align has_fderiv_at.ccos HasFDerivAt.ccos theorem HasFDerivWithinAt.ccos (hf : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt (fun x => Complex.cos (f x)) (-Complex.sin (f x) • f') s x := (Complex.hasDerivAt_cos (f x)).comp_hasFDerivWithinAt x hf #align has_fderiv_within_at.ccos HasFDerivWithinAt.ccos theorem DifferentiableWithinAt.ccos (hf : DifferentiableWithinAt ℂ f s x) : DifferentiableWithinAt ℂ (fun x => Complex.cos (f x)) s x := hf.hasFDerivWithinAt.ccos.differentiableWithinAt #align differentiable_within_at.ccos DifferentiableWithinAt.ccos @[simp] theorem DifferentiableAt.ccos (hc : DifferentiableAt ℂ f x) : DifferentiableAt ℂ (fun x => Complex.cos (f x)) x := hc.hasFDerivAt.ccos.differentiableAt #align differentiable_at.ccos DifferentiableAt.ccos theorem DifferentiableOn.ccos (hc : DifferentiableOn ℂ f s) : DifferentiableOn ℂ (fun x => Complex.cos (f x)) s := fun x h => (hc x h).ccos #align differentiable_on.ccos DifferentiableOn.ccos @[simp] theorem Differentiable.ccos (hc : Differentiable ℂ f) : Differentiable ℂ fun x => Complex.cos (f x) := fun x => (hc x).ccos #align differentiable.ccos Differentiable.ccos theorem fderivWithin_ccos (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : fderivWithin ℂ (fun x => Complex.cos (f x)) s x = -Complex.sin (f x) • fderivWithin ℂ f s x := hf.hasFDerivWithinAt.ccos.fderivWithin hxs #align fderiv_within_ccos fderivWithin_ccos @[simp, nolint simpNF] -- `simp` times out trying to find `Module ℂ (E →L[ℂ] ℂ)` -- with all of `Mathlib` opened -- no idea why theorem fderiv_ccos (hc : DifferentiableAt ℂ f x) : fderiv ℂ (fun x => Complex.cos (f x)) x = -Complex.sin (f x) • fderiv ℂ f x := hc.hasFDerivAt.ccos.fderiv #align fderiv_ccos fderiv_ccos theorem ContDiff.ccos {n} (h : ContDiff ℂ n f) : ContDiff ℂ n fun x => Complex.cos (f x) := Complex.contDiff_cos.comp h #align cont_diff.ccos ContDiff.ccos theorem ContDiffAt.ccos {n} (hf : ContDiffAt ℂ n f x) : ContDiffAt ℂ n (fun x => Complex.cos (f x)) x := Complex.contDiff_cos.contDiffAt.comp x hf #align cont_diff_at.ccos ContDiffAt.ccos theorem ContDiffOn.ccos {n} (hf : ContDiffOn ℂ n f s) : ContDiffOn ℂ n (fun x => Complex.cos (f x)) s := Complex.contDiff_cos.comp_contDiffOn hf #align cont_diff_on.ccos ContDiffOn.ccos theorem ContDiffWithinAt.ccos {n} (hf : ContDiffWithinAt ℂ n f s x) : ContDiffWithinAt ℂ n (fun x => Complex.cos (f x)) s x := Complex.contDiff_cos.contDiffAt.comp_contDiffWithinAt x hf #align cont_diff_within_at.ccos ContDiffWithinAt.ccos /-! #### `Complex.sin` -/ theorem HasStrictFDerivAt.csin (hf : HasStrictFDerivAt f f' x) : HasStrictFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) • f') x := (Complex.hasStrictDerivAt_sin (f x)).comp_hasStrictFDerivAt x hf #align has_strict_fderiv_at.csin HasStrictFDerivAt.csin theorem HasFDerivAt.csin (hf : HasFDerivAt f f' x) : HasFDerivAt (fun x => Complex.sin (f x)) (Complex.cos (f x) • f') x := (Complex.hasDerivAt_sin (f x)).comp_hasFDerivAt x hf #align has_fderiv_at.csin HasFDerivAt.csin theorem HasFDerivWithinAt.csin (hf : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt (fun x => Complex.sin (f x)) (Complex.cos (f x) • f') s x := (Complex.hasDerivAt_sin (f x)).comp_hasFDerivWithinAt x hf #align has_fderiv_within_at.csin HasFDerivWithinAt.csin theorem DifferentiableWithinAt.csin (hf : DifferentiableWithinAt ℂ f s x) : DifferentiableWithinAt ℂ (fun x => Complex.sin (f x)) s x := hf.hasFDerivWithinAt.csin.differentiableWithinAt #align differentiable_within_at.csin DifferentiableWithinAt.csin @[simp] theorem DifferentiableAt.csin (hc : DifferentiableAt ℂ f x) : DifferentiableAt ℂ (fun x => Complex.sin (f x)) x := hc.hasFDerivAt.csin.differentiableAt #align differentiable_at.csin DifferentiableAt.csin theorem DifferentiableOn.csin (hc : DifferentiableOn ℂ f s) : DifferentiableOn ℂ (fun x => Complex.sin (f x)) s := fun x h => (hc x h).csin #align differentiable_on.csin DifferentiableOn.csin @[simp] theorem Differentiable.csin (hc : Differentiable ℂ f) : Differentiable ℂ fun x => Complex.sin (f x) := fun x => (hc x).csin #align differentiable.csin Differentiable.csin theorem fderivWithin_csin (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : fderivWithin ℂ (fun x => Complex.sin (f x)) s x = Complex.cos (f x) • fderivWithin ℂ f s x := hf.hasFDerivWithinAt.csin.fderivWithin hxs #align fderiv_within_csin fderivWithin_csin @[simp] theorem fderiv_csin (hc : DifferentiableAt ℂ f x) : fderiv ℂ (fun x => Complex.sin (f x)) x = Complex.cos (f x) • fderiv ℂ f x := hc.hasFDerivAt.csin.fderiv #align fderiv_csin fderiv_csin theorem ContDiff.csin {n} (h : ContDiff ℂ n f) : ContDiff ℂ n fun x => Complex.sin (f x) := Complex.contDiff_sin.comp h #align cont_diff.csin ContDiff.csin theorem ContDiffAt.csin {n} (hf : ContDiffAt ℂ n f x) : ContDiffAt ℂ n (fun x => Complex.sin (f x)) x := Complex.contDiff_sin.contDiffAt.comp x hf #align cont_diff_at.csin ContDiffAt.csin theorem ContDiffOn.csin {n} (hf : ContDiffOn ℂ n f s) : ContDiffOn ℂ n (fun x => Complex.sin (f x)) s := Complex.contDiff_sin.comp_contDiffOn hf #align cont_diff_on.csin ContDiffOn.csin theorem ContDiffWithinAt.csin {n} (hf : ContDiffWithinAt ℂ n f s x) : ContDiffWithinAt ℂ n (fun x => Complex.sin (f x)) s x := Complex.contDiff_sin.contDiffAt.comp_contDiffWithinAt x hf #align cont_diff_within_at.csin ContDiffWithinAt.csin /-! #### `Complex.cosh` -/ theorem HasStrictFDerivAt.ccosh (hf : HasStrictFDerivAt f f' x) : HasStrictFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) • f') x := (Complex.hasStrictDerivAt_cosh (f x)).comp_hasStrictFDerivAt x hf #align has_strict_fderiv_at.ccosh HasStrictFDerivAt.ccosh theorem HasFDerivAt.ccosh (hf : HasFDerivAt f f' x) : HasFDerivAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) • f') x := (Complex.hasDerivAt_cosh (f x)).comp_hasFDerivAt x hf #align has_fderiv_at.ccosh HasFDerivAt.ccosh theorem HasFDerivWithinAt.ccosh (hf : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt (fun x => Complex.cosh (f x)) (Complex.sinh (f x) • f') s x := (Complex.hasDerivAt_cosh (f x)).comp_hasFDerivWithinAt x hf #align has_fderiv_within_at.ccosh HasFDerivWithinAt.ccosh theorem DifferentiableWithinAt.ccosh (hf : DifferentiableWithinAt ℂ f s x) : DifferentiableWithinAt ℂ (fun x => Complex.cosh (f x)) s x := hf.hasFDerivWithinAt.ccosh.differentiableWithinAt #align differentiable_within_at.ccosh DifferentiableWithinAt.ccosh @[simp] theorem DifferentiableAt.ccosh (hc : DifferentiableAt ℂ f x) : DifferentiableAt ℂ (fun x => Complex.cosh (f x)) x := hc.hasFDerivAt.ccosh.differentiableAt #align differentiable_at.ccosh DifferentiableAt.ccosh theorem DifferentiableOn.ccosh (hc : DifferentiableOn ℂ f s) : DifferentiableOn ℂ (fun x => Complex.cosh (f x)) s := fun x h => (hc x h).ccosh #align differentiable_on.ccosh DifferentiableOn.ccosh @[simp] theorem Differentiable.ccosh (hc : Differentiable ℂ f) : Differentiable ℂ fun x => Complex.cosh (f x) := fun x => (hc x).ccosh #align differentiable.ccosh Differentiable.ccosh theorem fderivWithin_ccosh (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : fderivWithin ℂ (fun x => Complex.cosh (f x)) s x = Complex.sinh (f x) • fderivWithin ℂ f s x := hf.hasFDerivWithinAt.ccosh.fderivWithin hxs #align fderiv_within_ccosh fderivWithin_ccosh @[simp] theorem fderiv_ccosh (hc : DifferentiableAt ℂ f x) : fderiv ℂ (fun x => Complex.cosh (f x)) x = Complex.sinh (f x) • fderiv ℂ f x := hc.hasFDerivAt.ccosh.fderiv #align fderiv_ccosh fderiv_ccosh theorem ContDiff.ccosh {n} (h : ContDiff ℂ n f) : ContDiff ℂ n fun x => Complex.cosh (f x) := Complex.contDiff_cosh.comp h #align cont_diff.ccosh ContDiff.ccosh theorem ContDiffAt.ccosh {n} (hf : ContDiffAt ℂ n f x) : ContDiffAt ℂ n (fun x => Complex.cosh (f x)) x := Complex.contDiff_cosh.contDiffAt.comp x hf #align cont_diff_at.ccosh ContDiffAt.ccosh theorem ContDiffOn.ccosh {n} (hf : ContDiffOn ℂ n f s) : ContDiffOn ℂ n (fun x => Complex.cosh (f x)) s := Complex.contDiff_cosh.comp_contDiffOn hf #align cont_diff_on.ccosh ContDiffOn.ccosh theorem ContDiffWithinAt.ccosh {n} (hf : ContDiffWithinAt ℂ n f s x) : ContDiffWithinAt ℂ n (fun x => Complex.cosh (f x)) s x := Complex.contDiff_cosh.contDiffAt.comp_contDiffWithinAt x hf #align cont_diff_within_at.ccosh ContDiffWithinAt.ccosh /-! #### `Complex.sinh` -/ theorem HasStrictFDerivAt.csinh (hf : HasStrictFDerivAt f f' x) : HasStrictFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) • f') x := (Complex.hasStrictDerivAt_sinh (f x)).comp_hasStrictFDerivAt x hf #align has_strict_fderiv_at.csinh HasStrictFDerivAt.csinh theorem HasFDerivAt.csinh (hf : HasFDerivAt f f' x) : HasFDerivAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) • f') x := (Complex.hasDerivAt_sinh (f x)).comp_hasFDerivAt x hf #align has_fderiv_at.csinh HasFDerivAt.csinh theorem HasFDerivWithinAt.csinh (hf : HasFDerivWithinAt f f' s x) : HasFDerivWithinAt (fun x => Complex.sinh (f x)) (Complex.cosh (f x) • f') s x := (Complex.hasDerivAt_sinh (f x)).comp_hasFDerivWithinAt x hf #align has_fderiv_within_at.csinh HasFDerivWithinAt.csinh theorem DifferentiableWithinAt.csinh (hf : DifferentiableWithinAt ℂ f s x) : DifferentiableWithinAt ℂ (fun x => Complex.sinh (f x)) s x := hf.hasFDerivWithinAt.csinh.differentiableWithinAt #align differentiable_within_at.csinh DifferentiableWithinAt.csinh @[simp] theorem DifferentiableAt.csinh (hc : DifferentiableAt ℂ f x) : DifferentiableAt ℂ (fun x => Complex.sinh (f x)) x := hc.hasFDerivAt.csinh.differentiableAt #align differentiable_at.csinh DifferentiableAt.csinh theorem DifferentiableOn.csinh (hc : DifferentiableOn ℂ f s) : DifferentiableOn ℂ (fun x => Complex.sinh (f x)) s := fun x h => (hc x h).csinh #align differentiable_on.csinh DifferentiableOn.csinh @[simp] theorem Differentiable.csinh (hc : Differentiable ℂ f) : Differentiable ℂ fun x => Complex.sinh (f x) := fun x => (hc x).csinh #align differentiable.csinh Differentiable.csinh theorem fderivWithin_csinh (hf : DifferentiableWithinAt ℂ f s x) (hxs : UniqueDiffWithinAt ℂ s x) : fderivWithin ℂ (fun x => Complex.sinh (f x)) s x = Complex.cosh (f x) • fderivWithin ℂ f s x := hf.hasFDerivWithinAt.csinh.fderivWithin hxs #align fderiv_within_csinh fderivWithin_csinh @[simp] theorem fderiv_csinh (hc : DifferentiableAt ℂ f x) : fderiv ℂ (fun x => Complex.sinh (f x)) x = Complex.cosh (f x) • fderiv ℂ f x := hc.hasFDerivAt.csinh.fderiv #align fderiv_csinh fderiv_csinh theorem ContDiff.csinh {n} (h : ContDiff ℂ n f) : ContDiff ℂ n fun x => Complex.sinh (f x) := Complex.contDiff_sinh.comp h #align cont_diff.csinh ContDiff.csinh theorem ContDiffAt.csinh {n} (hf : ContDiffAt ℂ n f x) : ContDiffAt ℂ n (fun x => Complex.sinh (f x)) x := Complex.contDiff_sinh.contDiffAt.comp x hf #align cont_diff_at.csinh ContDiffAt.csinh theorem ContDiffOn.csinh {n} (hf : ContDiffOn ℂ n f s) : ContDiffOn ℂ n (fun x => Complex.sinh (f x)) s := Complex.contDiff_sinh.comp_contDiffOn hf #align cont_diff_on.csinh ContDiffOn.csinh theorem ContDiffWithinAt.csinh {n} (hf : ContDiffWithinAt ℂ n f s x) : ContDiffWithinAt ℂ n (fun x => Complex.sinh (f x)) s x := Complex.contDiff_sinh.contDiffAt.comp_contDiffWithinAt x hf #align cont_diff_within_at.csinh ContDiffWithinAt.csinh end namespace Real variable {x y z : ℝ} theorem hasStrictDerivAt_sin (x : ℝ) : HasStrictDerivAt sin (cos x) x := (Complex.hasStrictDerivAt_sin x).real_of_complex #align real.has_strict_deriv_at_sin Real.hasStrictDerivAt_sin theorem hasDerivAt_sin (x : ℝ) : HasDerivAt sin (cos x) x := (hasStrictDerivAt_sin x).hasDerivAt #align real.has_deriv_at_sin Real.hasDerivAt_sin theorem contDiff_sin {n} : ContDiff ℝ n sin := Complex.contDiff_sin.real_of_complex #align real.cont_diff_sin Real.contDiff_sin theorem differentiable_sin : Differentiable ℝ sin := fun x => (hasDerivAt_sin x).differentiableAt #align real.differentiable_sin Real.differentiable_sin theorem differentiableAt_sin : DifferentiableAt ℝ sin x := differentiable_sin x #align real.differentiable_at_sin Real.differentiableAt_sin @[simp] theorem deriv_sin : deriv sin = cos := funext fun x => (hasDerivAt_sin x).deriv #align real.deriv_sin Real.deriv_sin theorem hasStrictDerivAt_cos (x : ℝ) : HasStrictDerivAt cos (-sin x) x := (Complex.hasStrictDerivAt_cos x).real_of_complex #align real.has_strict_deriv_at_cos Real.hasStrictDerivAt_cos theorem hasDerivAt_cos (x : ℝ) : HasDerivAt cos (-sin x) x := (Complex.hasDerivAt_cos x).real_of_complex #align real.has_deriv_at_cos Real.hasDerivAt_cos theorem contDiff_cos {n} : ContDiff ℝ n cos := Complex.contDiff_cos.real_of_complex #align real.cont_diff_cos Real.contDiff_cos theorem differentiable_cos : Differentiable ℝ cos := fun x => (hasDerivAt_cos x).differentiableAt #align real.differentiable_cos Real.differentiable_cos theorem differentiableAt_cos : DifferentiableAt ℝ cos x := differentiable_cos x #align real.differentiable_at_cos Real.differentiableAt_cos theorem deriv_cos : deriv cos x = -sin x := (hasDerivAt_cos x).deriv #align real.deriv_cos Real.deriv_cos @[simp] theorem deriv_cos' : deriv cos = fun x => -sin x := funext fun _ => deriv_cos #align real.deriv_cos' Real.deriv_cos' theorem hasStrictDerivAt_sinh (x : ℝ) : HasStrictDerivAt sinh (cosh x) x := (Complex.hasStrictDerivAt_sinh x).real_of_complex #align real.has_strict_deriv_at_sinh Real.hasStrictDerivAt_sinh theorem hasDerivAt_sinh (x : ℝ) : HasDerivAt sinh (cosh x) x := (Complex.hasDerivAt_sinh x).real_of_complex #align real.has_deriv_at_sinh Real.hasDerivAt_sinh theorem contDiff_sinh {n} : ContDiff ℝ n sinh := Complex.contDiff_sinh.real_of_complex #align real.cont_diff_sinh Real.contDiff_sinh theorem differentiable_sinh : Differentiable ℝ sinh := fun x => (hasDerivAt_sinh x).differentiableAt #align real.differentiable_sinh Real.differentiable_sinh theorem differentiableAt_sinh : DifferentiableAt ℝ sinh x := differentiable_sinh x #align real.differentiable_at_sinh Real.differentiableAt_sinh @[simp] theorem deriv_sinh : deriv sinh = cosh := funext fun x => (hasDerivAt_sinh x).deriv #align real.deriv_sinh Real.deriv_sinh theorem hasStrictDerivAt_cosh (x : ℝ) : HasStrictDerivAt cosh (sinh x) x := (Complex.hasStrictDerivAt_cosh x).real_of_complex #align real.has_strict_deriv_at_cosh Real.hasStrictDerivAt_cosh theorem hasDerivAt_cosh (x : ℝ) : HasDerivAt cosh (sinh x) x := (Complex.hasDerivAt_cosh x).real_of_complex #align real.has_deriv_at_cosh Real.hasDerivAt_cosh theorem contDiff_cosh {n} : ContDiff ℝ n cosh := Complex.contDiff_cosh.real_of_complex #align real.cont_diff_cosh Real.contDiff_cosh theorem differentiable_cosh : Differentiable ℝ cosh := fun x => (hasDerivAt_cosh x).differentiableAt #align real.differentiable_cosh Real.differentiable_cosh theorem differentiableAt_cosh : DifferentiableAt ℝ cosh x := differentiable_cosh x #align real.differentiable_at_cosh Real.differentiableAt_cosh @[simp] theorem deriv_cosh : deriv cosh = sinh := funext fun x => (hasDerivAt_cosh x).deriv #align real.deriv_cosh Real.deriv_cosh /-- `sinh` is strictly monotone. -/ theorem sinh_strictMono : StrictMono sinh := strictMono_of_deriv_pos <| by rw [Real.deriv_sinh]; exact cosh_pos #align real.sinh_strict_mono Real.sinh_strictMono /-- `sinh` is injective, `∀ a b, sinh a = sinh b → a = b`. -/ theorem sinh_injective : Function.Injective sinh := sinh_strictMono.injective #align real.sinh_injective Real.sinh_injective @[simp] theorem sinh_inj : sinh x = sinh y ↔ x = y := sinh_injective.eq_iff #align real.sinh_inj Real.sinh_inj @[simp] theorem sinh_le_sinh : sinh x ≤ sinh y ↔ x ≤ y := sinh_strictMono.le_iff_le #align real.sinh_le_sinh Real.sinh_le_sinh @[simp] theorem sinh_lt_sinh : sinh x < sinh y ↔ x < y := sinh_strictMono.lt_iff_lt #align real.sinh_lt_sinh Real.sinh_lt_sinh @[simp] lemma sinh_eq_zero : sinh x = 0 ↔ x = 0 := by rw [← @sinh_inj x, sinh_zero] lemma sinh_ne_zero : sinh x ≠ 0 ↔ x ≠ 0 := sinh_eq_zero.not @[simp] theorem sinh_pos_iff : 0 < sinh x ↔ 0 < x := by simpa only [sinh_zero] using @sinh_lt_sinh 0 x #align real.sinh_pos_iff Real.sinh_pos_iff @[simp]
Mathlib/Analysis/SpecialFunctions/Trigonometric/Deriv.lean
711
711
theorem sinh_nonpos_iff : sinh x ≤ 0 ↔ x ≤ 0 := by
simpa only [sinh_zero] using @sinh_le_sinh x 0
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel -/ import Mathlib.Init.Order.Defs import Mathlib.Logic.Nontrivial.Defs import Mathlib.Tactic.Attr.Register import Mathlib.Data.Prod.Basic import Mathlib.Data.Subtype import Mathlib.Logic.Function.Basic import Mathlib.Logic.Unique #align_import logic.nontrivial from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4" /-! # Nontrivial types Results about `Nontrivial`. -/ variable {α : Type*} {β : Type*} open scoped Classical -- `x` and `y` are explicit here, as they are often needed to guide typechecking of `h`. theorem nontrivial_of_lt [Preorder α] (x y : α) (h : x < y) : Nontrivial α := ⟨⟨x, y, ne_of_lt h⟩⟩ #align nontrivial_of_lt nontrivial_of_lt theorem exists_pair_lt (α : Type*) [Nontrivial α] [LinearOrder α] : ∃ x y : α, x < y := by rcases exists_pair_ne α with ⟨x, y, hxy⟩ cases lt_or_gt_of_ne hxy <;> exact ⟨_, _, ‹_›⟩ #align exists_pair_lt exists_pair_lt theorem nontrivial_iff_lt [LinearOrder α] : Nontrivial α ↔ ∃ x y : α, x < y := ⟨fun h ↦ @exists_pair_lt α h _, fun ⟨x, y, h⟩ ↦ nontrivial_of_lt x y h⟩ #align nontrivial_iff_lt nontrivial_iff_lt theorem Subtype.nontrivial_iff_exists_ne (p : α → Prop) (x : Subtype p) : Nontrivial (Subtype p) ↔ ∃ (y : α) (_ : p y), y ≠ x := by simp only [_root_.nontrivial_iff_exists_ne x, Subtype.exists, Ne, Subtype.ext_iff] #align subtype.nontrivial_iff_exists_ne Subtype.nontrivial_iff_exists_ne /-- An inhabited type is either nontrivial, or has a unique element. -/ noncomputable def nontrivialPSumUnique (α : Type*) [Inhabited α] : PSum (Nontrivial α) (Unique α) := if h : Nontrivial α then PSum.inl h else PSum.inr { default := default, uniq := fun x : α ↦ by by_contra H exact h ⟨_, _, H⟩ } #align nontrivial_psum_unique nontrivialPSumUnique instance Option.nontrivial [Nonempty α] : Nontrivial (Option α) := by inhabit α exact ⟨none, some default, nofun⟩ /-- Pushforward a `Nontrivial` instance along an injective function. -/ protected theorem Function.Injective.nontrivial [Nontrivial α] {f : α → β} (hf : Function.Injective f) : Nontrivial β := let ⟨x, y, h⟩ := exists_pair_ne α ⟨⟨f x, f y, hf.ne h⟩⟩ #align function.injective.nontrivial Function.Injective.nontrivial /-- An injective function from a nontrivial type has an argument at which it does not take a given value. -/ protected theorem Function.Injective.exists_ne [Nontrivial α] {f : α → β} (hf : Function.Injective f) (y : β) : ∃ x, f x ≠ y := by rcases exists_pair_ne α with ⟨x₁, x₂, hx⟩ by_cases h:f x₂ = y · exact ⟨x₁, (hf.ne_iff' h).2 hx⟩ · exact ⟨x₂, h⟩ #align function.injective.exists_ne Function.Injective.exists_ne instance nontrivial_prod_right [Nonempty α] [Nontrivial β] : Nontrivial (α × β) := Prod.snd_surjective.nontrivial instance nontrivial_prod_left [Nontrivial α] [Nonempty β] : Nontrivial (α × β) := Prod.fst_surjective.nontrivial namespace Pi variable {I : Type*} {f : I → Type*} /-- A pi type is nontrivial if it's nonempty everywhere and nontrivial somewhere. -/
Mathlib/Logic/Nontrivial/Basic.lean
90
93
theorem nontrivial_at (i' : I) [inst : ∀ i, Nonempty (f i)] [Nontrivial (f i')] : Nontrivial (∀ i : I, f i) := by
letI := Classical.decEq (∀ i : I, f i) exact (Function.update_injective (fun i ↦ Classical.choice (inst i)) i').nontrivial
/- Copyright (c) 2020 Sébastien Gouëzel. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Sébastien Gouëzel, Yury Kudryashov -/ import Mathlib.Analysis.Calculus.FormalMultilinearSeries import Mathlib.Analysis.SpecificLimits.Normed import Mathlib.Logic.Equiv.Fin import Mathlib.Topology.Algebra.InfiniteSum.Module #align_import analysis.analytic.basic from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514" /-! # Analytic functions A function is analytic in one dimension around `0` if it can be written as a converging power series `Σ pₙ zⁿ`. This definition can be extended to any dimension (even in infinite dimension) by requiring that `pₙ` is a continuous `n`-multilinear map. In general, `pₙ` is not unique (in two dimensions, taking `p₂ (x, y) (x', y') = x y'` or `y x'` gives the same map when applied to a vector `(x, y) (x, y)`). A way to guarantee uniqueness is to take a symmetric `pₙ`, but this is not always possible in nonzero characteristic (in characteristic 2, the previous example has no symmetric representative). Therefore, we do not insist on symmetry or uniqueness in the definition, and we only require the existence of a converging series. The general framework is important to say that the exponential map on bounded operators on a Banach space is analytic, as well as the inverse on invertible operators. ## Main definitions Let `p` be a formal multilinear series from `E` to `F`, i.e., `p n` is a multilinear map on `E^n` for `n : ℕ`. * `p.radius`: the largest `r : ℝ≥0∞` such that `‖p n‖ * r^n` grows subexponentially. * `p.le_radius_of_bound`, `p.le_radius_of_bound_nnreal`, `p.le_radius_of_isBigO`: if `‖p n‖ * r ^ n` is bounded above, then `r ≤ p.radius`; * `p.isLittleO_of_lt_radius`, `p.norm_mul_pow_le_mul_pow_of_lt_radius`, `p.isLittleO_one_of_lt_radius`, `p.norm_mul_pow_le_of_lt_radius`, `p.nnnorm_mul_pow_le_of_lt_radius`: if `r < p.radius`, then `‖p n‖ * r ^ n` tends to zero exponentially; * `p.lt_radius_of_isBigO`: if `r ≠ 0` and `‖p n‖ * r ^ n = O(a ^ n)` for some `-1 < a < 1`, then `r < p.radius`; * `p.partialSum n x`: the sum `∑_{i = 0}^{n-1} pᵢ xⁱ`. * `p.sum x`: the sum `∑'_{i = 0}^{∞} pᵢ xⁱ`. Additionally, let `f` be a function from `E` to `F`. * `HasFPowerSeriesOnBall f p x r`: on the ball of center `x` with radius `r`, `f (x + y) = ∑'_n pₙ yⁿ`. * `HasFPowerSeriesAt f p x`: on some ball of center `x` with positive radius, holds `HasFPowerSeriesOnBall f p x r`. * `AnalyticAt 𝕜 f x`: there exists a power series `p` such that holds `HasFPowerSeriesAt f p x`. * `AnalyticOn 𝕜 f s`: the function `f` is analytic at every point of `s`. We develop the basic properties of these notions, notably: * If a function admits a power series, it is continuous (see `HasFPowerSeriesOnBall.continuousOn` and `HasFPowerSeriesAt.continuousAt` and `AnalyticAt.continuousAt`). * In a complete space, the sum of a formal power series with positive radius is well defined on the disk of convergence, see `FormalMultilinearSeries.hasFPowerSeriesOnBall`. * If a function admits a power series in a ball, then it is analytic at any point `y` of this ball, and the power series there can be expressed in terms of the initial power series `p` as `p.changeOrigin y`. See `HasFPowerSeriesOnBall.changeOrigin`. It follows in particular that the set of points at which a given function is analytic is open, see `isOpen_analyticAt`. ## Implementation details We only introduce the radius of convergence of a power series, as `p.radius`. For a power series in finitely many dimensions, there is a finer (directional, coordinate-dependent) notion, describing the polydisk of convergence. This notion is more specific, and not necessary to build the general theory. We do not define it here. -/ noncomputable section variable {𝕜 E F G : Type*} open scoped Classical open Topology NNReal Filter ENNReal open Set Filter Asymptotics namespace FormalMultilinearSeries variable [Ring 𝕜] [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F] variable [TopologicalSpace E] [TopologicalSpace F] variable [TopologicalAddGroup E] [TopologicalAddGroup F] variable [ContinuousConstSMul 𝕜 E] [ContinuousConstSMul 𝕜 F] /-- Given a formal multilinear series `p` and a vector `x`, then `p.sum x` is the sum `Σ pₙ xⁿ`. A priori, it only behaves well when `‖x‖ < p.radius`. -/ protected def sum (p : FormalMultilinearSeries 𝕜 E F) (x : E) : F := ∑' n : ℕ, p n fun _ => x #align formal_multilinear_series.sum FormalMultilinearSeries.sum /-- Given a formal multilinear series `p` and a vector `x`, then `p.partialSum n x` is the sum `Σ pₖ xᵏ` for `k ∈ {0,..., n-1}`. -/ def partialSum (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) (x : E) : F := ∑ k ∈ Finset.range n, p k fun _ : Fin k => x #align formal_multilinear_series.partial_sum FormalMultilinearSeries.partialSum /-- The partial sums of a formal multilinear series are continuous. -/ theorem partialSum_continuous (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) : Continuous (p.partialSum n) := by unfold partialSum -- Porting note: added continuity #align formal_multilinear_series.partial_sum_continuous FormalMultilinearSeries.partialSum_continuous end FormalMultilinearSeries /-! ### The radius of a formal multilinear series -/ variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G] namespace FormalMultilinearSeries variable (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} /-- The radius of a formal multilinear series is the largest `r` such that the sum `Σ ‖pₙ‖ ‖y‖ⁿ` converges for all `‖y‖ < r`. This implies that `Σ pₙ yⁿ` converges for all `‖y‖ < r`, but these definitions are *not* equivalent in general. -/ def radius (p : FormalMultilinearSeries 𝕜 E F) : ℝ≥0∞ := ⨆ (r : ℝ≥0) (C : ℝ) (_ : ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C), (r : ℝ≥0∞) #align formal_multilinear_series.radius FormalMultilinearSeries.radius /-- If `‖pₙ‖ rⁿ` is bounded in `n`, then the radius of `p` is at least `r`. -/ theorem le_radius_of_bound (C : ℝ) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖ * (r : ℝ) ^ n ≤ C) : (r : ℝ≥0∞) ≤ p.radius := le_iSup_of_le r <| le_iSup_of_le C <| le_iSup (fun _ => (r : ℝ≥0∞)) h #align formal_multilinear_series.le_radius_of_bound FormalMultilinearSeries.le_radius_of_bound /-- If `‖pₙ‖ rⁿ` is bounded in `n`, then the radius of `p` is at least `r`. -/ theorem le_radius_of_bound_nnreal (C : ℝ≥0) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖₊ * r ^ n ≤ C) : (r : ℝ≥0∞) ≤ p.radius := p.le_radius_of_bound C fun n => mod_cast h n #align formal_multilinear_series.le_radius_of_bound_nnreal FormalMultilinearSeries.le_radius_of_bound_nnreal /-- If `‖pₙ‖ rⁿ = O(1)`, as `n → ∞`, then the radius of `p` is at least `r`. -/ theorem le_radius_of_isBigO (h : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) : ↑r ≤ p.radius := Exists.elim (isBigO_one_nat_atTop_iff.1 h) fun C hC => p.le_radius_of_bound C fun n => (le_abs_self _).trans (hC n) set_option linter.uppercaseLean3 false in #align formal_multilinear_series.le_radius_of_is_O FormalMultilinearSeries.le_radius_of_isBigO theorem le_radius_of_eventually_le (C) (h : ∀ᶠ n in atTop, ‖p n‖ * (r : ℝ) ^ n ≤ C) : ↑r ≤ p.radius := p.le_radius_of_isBigO <| IsBigO.of_bound C <| h.mono fun n hn => by simpa #align formal_multilinear_series.le_radius_of_eventually_le FormalMultilinearSeries.le_radius_of_eventually_le theorem le_radius_of_summable_nnnorm (h : Summable fun n => ‖p n‖₊ * r ^ n) : ↑r ≤ p.radius := p.le_radius_of_bound_nnreal (∑' n, ‖p n‖₊ * r ^ n) fun _ => le_tsum' h _ #align formal_multilinear_series.le_radius_of_summable_nnnorm FormalMultilinearSeries.le_radius_of_summable_nnnorm theorem le_radius_of_summable (h : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius := p.le_radius_of_summable_nnnorm <| by simp only [← coe_nnnorm] at h exact mod_cast h #align formal_multilinear_series.le_radius_of_summable FormalMultilinearSeries.le_radius_of_summable theorem radius_eq_top_of_forall_nnreal_isBigO (h : ∀ r : ℝ≥0, (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) : p.radius = ∞ := ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_isBigO (h r) set_option linter.uppercaseLean3 false in #align formal_multilinear_series.radius_eq_top_of_forall_nnreal_is_O FormalMultilinearSeries.radius_eq_top_of_forall_nnreal_isBigO theorem radius_eq_top_of_eventually_eq_zero (h : ∀ᶠ n in atTop, p n = 0) : p.radius = ∞ := p.radius_eq_top_of_forall_nnreal_isBigO fun r => (isBigO_zero _ _).congr' (h.mono fun n hn => by simp [hn]) EventuallyEq.rfl #align formal_multilinear_series.radius_eq_top_of_eventually_eq_zero FormalMultilinearSeries.radius_eq_top_of_eventually_eq_zero theorem radius_eq_top_of_forall_image_add_eq_zero (n : ℕ) (hn : ∀ m, p (m + n) = 0) : p.radius = ∞ := p.radius_eq_top_of_eventually_eq_zero <| mem_atTop_sets.2 ⟨n, fun _ hk => tsub_add_cancel_of_le hk ▸ hn _⟩ #align formal_multilinear_series.radius_eq_top_of_forall_image_add_eq_zero FormalMultilinearSeries.radius_eq_top_of_forall_image_add_eq_zero @[simp] theorem constFormalMultilinearSeries_radius {v : F} : (constFormalMultilinearSeries 𝕜 E v).radius = ⊤ := (constFormalMultilinearSeries 𝕜 E v).radius_eq_top_of_forall_image_add_eq_zero 1 (by simp [constFormalMultilinearSeries]) #align formal_multilinear_series.const_formal_multilinear_series_radius FormalMultilinearSeries.constFormalMultilinearSeries_radius /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` tends to zero exponentially: for some `0 < a < 1`, `‖p n‖ rⁿ = o(aⁿ)`. -/ theorem isLittleO_of_lt_radius (h : ↑r < p.radius) : ∃ a ∈ Ioo (0 : ℝ) 1, (fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (a ^ ·) := by have := (TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4 rw [this] -- Porting note: was -- rw [(TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4] simp only [radius, lt_iSup_iff] at h rcases h with ⟨t, C, hC, rt⟩ rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at rt have : 0 < (t : ℝ) := r.coe_nonneg.trans_lt rt rw [← div_lt_one this] at rt refine ⟨_, rt, C, Or.inr zero_lt_one, fun n => ?_⟩ calc |‖p n‖ * (r : ℝ) ^ n| = ‖p n‖ * (t : ℝ) ^ n * (r / t : ℝ) ^ n := by field_simp [mul_right_comm, abs_mul] _ ≤ C * (r / t : ℝ) ^ n := by gcongr; apply hC #align formal_multilinear_series.is_o_of_lt_radius FormalMultilinearSeries.isLittleO_of_lt_radius /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ = o(1)`. -/ theorem isLittleO_one_of_lt_radius (h : ↑r < p.radius) : (fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (fun _ => 1 : ℕ → ℝ) := let ⟨_, ha, hp⟩ := p.isLittleO_of_lt_radius h hp.trans <| (isLittleO_pow_pow_of_lt_left ha.1.le ha.2).congr (fun _ => rfl) one_pow #align formal_multilinear_series.is_o_one_of_lt_radius FormalMultilinearSeries.isLittleO_one_of_lt_radius /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` tends to zero exponentially: for some `0 < a < 1` and `C > 0`, `‖p n‖ * r ^ n ≤ C * a ^ n`. -/ theorem norm_mul_pow_le_mul_pow_of_lt_radius (h : ↑r < p.radius) : ∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C * a ^ n := by -- Porting note: moved out of `rcases` have := ((TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 5).mp (p.isLittleO_of_lt_radius h) rcases this with ⟨a, ha, C, hC, H⟩ exact ⟨a, ha, C, hC, fun n => (le_abs_self _).trans (H n)⟩ #align formal_multilinear_series.norm_mul_pow_le_mul_pow_of_lt_radius FormalMultilinearSeries.norm_mul_pow_le_mul_pow_of_lt_radius /-- If `r ≠ 0` and `‖pₙ‖ rⁿ = O(aⁿ)` for some `-1 < a < 1`, then `r < p.radius`. -/ theorem lt_radius_of_isBigO (h₀ : r ≠ 0) {a : ℝ} (ha : a ∈ Ioo (-1 : ℝ) 1) (hp : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] (a ^ ·)) : ↑r < p.radius := by -- Porting note: moved out of `rcases` have := ((TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 2 5) rcases this.mp ⟨a, ha, hp⟩ with ⟨a, ha, C, hC, hp⟩ rw [← pos_iff_ne_zero, ← NNReal.coe_pos] at h₀ lift a to ℝ≥0 using ha.1.le have : (r : ℝ) < r / a := by simpa only [div_one] using (div_lt_div_left h₀ zero_lt_one ha.1).2 ha.2 norm_cast at this rw [← ENNReal.coe_lt_coe] at this refine this.trans_le (p.le_radius_of_bound C fun n => ?_) rw [NNReal.coe_div, div_pow, ← mul_div_assoc, div_le_iff (pow_pos ha.1 n)] exact (le_abs_self _).trans (hp n) set_option linter.uppercaseLean3 false in #align formal_multilinear_series.lt_radius_of_is_O FormalMultilinearSeries.lt_radius_of_isBigO /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/ theorem norm_mul_pow_le_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C := let ⟨_, ha, C, hC, h⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius h ⟨C, hC, fun n => (h n).trans <| mul_le_of_le_one_right hC.lt.le (pow_le_one _ ha.1.le ha.2.le)⟩ #align formal_multilinear_series.norm_mul_pow_le_of_lt_radius FormalMultilinearSeries.norm_mul_pow_le_of_lt_radius /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/ theorem norm_le_div_pow_of_pos_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h0 : 0 < r) (h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖ ≤ C / (r : ℝ) ^ n := let ⟨C, hC, hp⟩ := p.norm_mul_pow_le_of_lt_radius h ⟨C, hC, fun n => Iff.mpr (le_div_iff (pow_pos h0 _)) (hp n)⟩ #align formal_multilinear_series.norm_le_div_pow_of_pos_of_lt_radius FormalMultilinearSeries.norm_le_div_pow_of_pos_of_lt_radius /-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/ theorem nnnorm_mul_pow_le_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖₊ * r ^ n ≤ C := let ⟨C, hC, hp⟩ := p.norm_mul_pow_le_of_lt_radius h ⟨⟨C, hC.lt.le⟩, hC, mod_cast hp⟩ #align formal_multilinear_series.nnnorm_mul_pow_le_of_lt_radius FormalMultilinearSeries.nnnorm_mul_pow_le_of_lt_radius theorem le_radius_of_tendsto (p : FormalMultilinearSeries 𝕜 E F) {l : ℝ} (h : Tendsto (fun n => ‖p n‖ * (r : ℝ) ^ n) atTop (𝓝 l)) : ↑r ≤ p.radius := p.le_radius_of_isBigO (h.isBigO_one _) #align formal_multilinear_series.le_radius_of_tendsto FormalMultilinearSeries.le_radius_of_tendsto theorem le_radius_of_summable_norm (p : FormalMultilinearSeries 𝕜 E F) (hs : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius := p.le_radius_of_tendsto hs.tendsto_atTop_zero #align formal_multilinear_series.le_radius_of_summable_norm FormalMultilinearSeries.le_radius_of_summable_norm theorem not_summable_norm_of_radius_lt_nnnorm (p : FormalMultilinearSeries 𝕜 E F) {x : E} (h : p.radius < ‖x‖₊) : ¬Summable fun n => ‖p n‖ * ‖x‖ ^ n := fun hs => not_le_of_lt h (p.le_radius_of_summable_norm hs) #align formal_multilinear_series.not_summable_norm_of_radius_lt_nnnorm FormalMultilinearSeries.not_summable_norm_of_radius_lt_nnnorm theorem summable_norm_mul_pow (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : ↑r < p.radius) : Summable fun n : ℕ => ‖p n‖ * (r : ℝ) ^ n := by obtain ⟨a, ha : a ∈ Ioo (0 : ℝ) 1, C, - : 0 < C, hp⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius h exact .of_nonneg_of_le (fun n => mul_nonneg (norm_nonneg _) (pow_nonneg r.coe_nonneg _)) hp ((summable_geometric_of_lt_one ha.1.le ha.2).mul_left _) #align formal_multilinear_series.summable_norm_mul_pow FormalMultilinearSeries.summable_norm_mul_pow theorem summable_norm_apply (p : FormalMultilinearSeries 𝕜 E F) {x : E} (hx : x ∈ EMetric.ball (0 : E) p.radius) : Summable fun n : ℕ => ‖p n fun _ => x‖ := by rw [mem_emetric_ball_zero_iff] at hx refine .of_nonneg_of_le (fun _ ↦ norm_nonneg _) (fun n ↦ ((p n).le_opNorm _).trans_eq ?_) (p.summable_norm_mul_pow hx) simp #align formal_multilinear_series.summable_norm_apply FormalMultilinearSeries.summable_norm_apply theorem summable_nnnorm_mul_pow (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : ↑r < p.radius) : Summable fun n : ℕ => ‖p n‖₊ * r ^ n := by rw [← NNReal.summable_coe] push_cast exact p.summable_norm_mul_pow h #align formal_multilinear_series.summable_nnnorm_mul_pow FormalMultilinearSeries.summable_nnnorm_mul_pow protected theorem summable [CompleteSpace F] (p : FormalMultilinearSeries 𝕜 E F) {x : E} (hx : x ∈ EMetric.ball (0 : E) p.radius) : Summable fun n : ℕ => p n fun _ => x := (p.summable_norm_apply hx).of_norm #align formal_multilinear_series.summable FormalMultilinearSeries.summable theorem radius_eq_top_of_summable_norm (p : FormalMultilinearSeries 𝕜 E F) (hs : ∀ r : ℝ≥0, Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : p.radius = ∞ := ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_summable_norm (hs r) #align formal_multilinear_series.radius_eq_top_of_summable_norm FormalMultilinearSeries.radius_eq_top_of_summable_norm theorem radius_eq_top_iff_summable_norm (p : FormalMultilinearSeries 𝕜 E F) : p.radius = ∞ ↔ ∀ r : ℝ≥0, Summable fun n => ‖p n‖ * (r : ℝ) ^ n := by constructor · intro h r obtain ⟨a, ha : a ∈ Ioo (0 : ℝ) 1, C, - : 0 < C, hp⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius (show (r : ℝ≥0∞) < p.radius from h.symm ▸ ENNReal.coe_lt_top) refine .of_norm_bounded (fun n ↦ (C : ℝ) * a ^ n) ((summable_geometric_of_lt_one ha.1.le ha.2).mul_left _) fun n ↦ ?_ specialize hp n rwa [Real.norm_of_nonneg (mul_nonneg (norm_nonneg _) (pow_nonneg r.coe_nonneg n))] · exact p.radius_eq_top_of_summable_norm #align formal_multilinear_series.radius_eq_top_iff_summable_norm FormalMultilinearSeries.radius_eq_top_iff_summable_norm /-- If the radius of `p` is positive, then `‖pₙ‖` grows at most geometrically. -/ theorem le_mul_pow_of_radius_pos (p : FormalMultilinearSeries 𝕜 E F) (h : 0 < p.radius) : ∃ (C r : _) (hC : 0 < C) (_ : 0 < r), ∀ n, ‖p n‖ ≤ C * r ^ n := by rcases ENNReal.lt_iff_exists_nnreal_btwn.1 h with ⟨r, r0, rlt⟩ have rpos : 0 < (r : ℝ) := by simp [ENNReal.coe_pos.1 r0] rcases norm_le_div_pow_of_pos_of_lt_radius p rpos rlt with ⟨C, Cpos, hCp⟩ refine ⟨C, r⁻¹, Cpos, by simp only [inv_pos, rpos], fun n => ?_⟩ -- Porting note: was `convert` rw [inv_pow, ← div_eq_mul_inv] exact hCp n #align formal_multilinear_series.le_mul_pow_of_radius_pos FormalMultilinearSeries.le_mul_pow_of_radius_pos /-- The radius of the sum of two formal series is at least the minimum of their two radii. -/ theorem min_radius_le_radius_add (p q : FormalMultilinearSeries 𝕜 E F) : min p.radius q.radius ≤ (p + q).radius := by refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_ rw [lt_min_iff] at hr have := ((p.isLittleO_one_of_lt_radius hr.1).add (q.isLittleO_one_of_lt_radius hr.2)).isBigO refine (p + q).le_radius_of_isBigO ((isBigO_of_le _ fun n => ?_).trans this) rw [← add_mul, norm_mul, norm_mul, norm_norm] exact mul_le_mul_of_nonneg_right ((norm_add_le _ _).trans (le_abs_self _)) (norm_nonneg _) #align formal_multilinear_series.min_radius_le_radius_add FormalMultilinearSeries.min_radius_le_radius_add @[simp] theorem radius_neg (p : FormalMultilinearSeries 𝕜 E F) : (-p).radius = p.radius := by simp only [radius, neg_apply, norm_neg] #align formal_multilinear_series.radius_neg FormalMultilinearSeries.radius_neg protected theorem hasSum [CompleteSpace F] (p : FormalMultilinearSeries 𝕜 E F) {x : E} (hx : x ∈ EMetric.ball (0 : E) p.radius) : HasSum (fun n : ℕ => p n fun _ => x) (p.sum x) := (p.summable hx).hasSum #align formal_multilinear_series.has_sum FormalMultilinearSeries.hasSum theorem radius_le_radius_continuousLinearMap_comp (p : FormalMultilinearSeries 𝕜 E F) (f : F →L[𝕜] G) : p.radius ≤ (f.compFormalMultilinearSeries p).radius := by refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_ apply le_radius_of_isBigO apply (IsBigO.trans_isLittleO _ (p.isLittleO_one_of_lt_radius hr)).isBigO refine IsBigO.mul (@IsBigOWith.isBigO _ _ _ _ _ ‖f‖ _ _ _ ?_) (isBigO_refl _ _) refine IsBigOWith.of_bound (eventually_of_forall fun n => ?_) simpa only [norm_norm] using f.norm_compContinuousMultilinearMap_le (p n) #align formal_multilinear_series.radius_le_radius_continuous_linear_map_comp FormalMultilinearSeries.radius_le_radius_continuousLinearMap_comp end FormalMultilinearSeries /-! ### Expanding a function as a power series -/ section variable {f g : E → F} {p pf pg : FormalMultilinearSeries 𝕜 E F} {x : E} {r r' : ℝ≥0∞} /-- Given a function `f : E → F` and a formal multilinear series `p`, we say that `f` has `p` as a power series on the ball of radius `r > 0` around `x` if `f (x + y) = ∑' pₙ yⁿ` for all `‖y‖ < r`. -/ structure HasFPowerSeriesOnBall (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) (r : ℝ≥0∞) : Prop where r_le : r ≤ p.radius r_pos : 0 < r hasSum : ∀ {y}, y ∈ EMetric.ball (0 : E) r → HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y)) #align has_fpower_series_on_ball HasFPowerSeriesOnBall /-- Given a function `f : E → F` and a formal multilinear series `p`, we say that `f` has `p` as a power series around `x` if `f (x + y) = ∑' pₙ yⁿ` for all `y` in a neighborhood of `0`. -/ def HasFPowerSeriesAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) := ∃ r, HasFPowerSeriesOnBall f p x r #align has_fpower_series_at HasFPowerSeriesAt variable (𝕜) /-- Given a function `f : E → F`, we say that `f` is analytic at `x` if it admits a convergent power series expansion around `x`. -/ def AnalyticAt (f : E → F) (x : E) := ∃ p : FormalMultilinearSeries 𝕜 E F, HasFPowerSeriesAt f p x #align analytic_at AnalyticAt /-- Given a function `f : E → F`, we say that `f` is analytic on a set `s` if it is analytic around every point of `s`. -/ def AnalyticOn (f : E → F) (s : Set E) := ∀ x, x ∈ s → AnalyticAt 𝕜 f x #align analytic_on AnalyticOn variable {𝕜} theorem HasFPowerSeriesOnBall.hasFPowerSeriesAt (hf : HasFPowerSeriesOnBall f p x r) : HasFPowerSeriesAt f p x := ⟨r, hf⟩ #align has_fpower_series_on_ball.has_fpower_series_at HasFPowerSeriesOnBall.hasFPowerSeriesAt theorem HasFPowerSeriesAt.analyticAt (hf : HasFPowerSeriesAt f p x) : AnalyticAt 𝕜 f x := ⟨p, hf⟩ #align has_fpower_series_at.analytic_at HasFPowerSeriesAt.analyticAt theorem HasFPowerSeriesOnBall.analyticAt (hf : HasFPowerSeriesOnBall f p x r) : AnalyticAt 𝕜 f x := hf.hasFPowerSeriesAt.analyticAt #align has_fpower_series_on_ball.analytic_at HasFPowerSeriesOnBall.analyticAt theorem HasFPowerSeriesOnBall.congr (hf : HasFPowerSeriesOnBall f p x r) (hg : EqOn f g (EMetric.ball x r)) : HasFPowerSeriesOnBall g p x r := { r_le := hf.r_le r_pos := hf.r_pos hasSum := fun {y} hy => by convert hf.hasSum hy using 1 apply hg.symm simpa [edist_eq_coe_nnnorm_sub] using hy } #align has_fpower_series_on_ball.congr HasFPowerSeriesOnBall.congr /-- If a function `f` has a power series `p` around `x`, then the function `z ↦ f (z - y)` has the same power series around `x + y`. -/ theorem HasFPowerSeriesOnBall.comp_sub (hf : HasFPowerSeriesOnBall f p x r) (y : E) : HasFPowerSeriesOnBall (fun z => f (z - y)) p (x + y) r := { r_le := hf.r_le r_pos := hf.r_pos hasSum := fun {z} hz => by convert hf.hasSum hz using 2 abel } #align has_fpower_series_on_ball.comp_sub HasFPowerSeriesOnBall.comp_sub theorem HasFPowerSeriesOnBall.hasSum_sub (hf : HasFPowerSeriesOnBall f p x r) {y : E} (hy : y ∈ EMetric.ball x r) : HasSum (fun n : ℕ => p n fun _ => y - x) (f y) := by have : y - x ∈ EMetric.ball (0 : E) r := by simpa [edist_eq_coe_nnnorm_sub] using hy simpa only [add_sub_cancel] using hf.hasSum this #align has_fpower_series_on_ball.has_sum_sub HasFPowerSeriesOnBall.hasSum_sub theorem HasFPowerSeriesOnBall.radius_pos (hf : HasFPowerSeriesOnBall f p x r) : 0 < p.radius := lt_of_lt_of_le hf.r_pos hf.r_le #align has_fpower_series_on_ball.radius_pos HasFPowerSeriesOnBall.radius_pos theorem HasFPowerSeriesAt.radius_pos (hf : HasFPowerSeriesAt f p x) : 0 < p.radius := let ⟨_, hr⟩ := hf hr.radius_pos #align has_fpower_series_at.radius_pos HasFPowerSeriesAt.radius_pos theorem HasFPowerSeriesOnBall.mono (hf : HasFPowerSeriesOnBall f p x r) (r'_pos : 0 < r') (hr : r' ≤ r) : HasFPowerSeriesOnBall f p x r' := ⟨le_trans hr hf.1, r'_pos, fun hy => hf.hasSum (EMetric.ball_subset_ball hr hy)⟩ #align has_fpower_series_on_ball.mono HasFPowerSeriesOnBall.mono theorem HasFPowerSeriesAt.congr (hf : HasFPowerSeriesAt f p x) (hg : f =ᶠ[𝓝 x] g) : HasFPowerSeriesAt g p x := by rcases hf with ⟨r₁, h₁⟩ rcases EMetric.mem_nhds_iff.mp hg with ⟨r₂, h₂pos, h₂⟩ exact ⟨min r₁ r₂, (h₁.mono (lt_min h₁.r_pos h₂pos) inf_le_left).congr fun y hy => h₂ (EMetric.ball_subset_ball inf_le_right hy)⟩ #align has_fpower_series_at.congr HasFPowerSeriesAt.congr protected theorem HasFPowerSeriesAt.eventually (hf : HasFPowerSeriesAt f p x) : ∀ᶠ r : ℝ≥0∞ in 𝓝[>] 0, HasFPowerSeriesOnBall f p x r := let ⟨_, hr⟩ := hf mem_of_superset (Ioo_mem_nhdsWithin_Ioi (left_mem_Ico.2 hr.r_pos)) fun _ hr' => hr.mono hr'.1 hr'.2.le #align has_fpower_series_at.eventually HasFPowerSeriesAt.eventually theorem HasFPowerSeriesOnBall.eventually_hasSum (hf : HasFPowerSeriesOnBall f p x r) : ∀ᶠ y in 𝓝 0, HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y)) := by filter_upwards [EMetric.ball_mem_nhds (0 : E) hf.r_pos] using fun _ => hf.hasSum #align has_fpower_series_on_ball.eventually_has_sum HasFPowerSeriesOnBall.eventually_hasSum theorem HasFPowerSeriesAt.eventually_hasSum (hf : HasFPowerSeriesAt f p x) : ∀ᶠ y in 𝓝 0, HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y)) := let ⟨_, hr⟩ := hf hr.eventually_hasSum #align has_fpower_series_at.eventually_has_sum HasFPowerSeriesAt.eventually_hasSum theorem HasFPowerSeriesOnBall.eventually_hasSum_sub (hf : HasFPowerSeriesOnBall f p x r) : ∀ᶠ y in 𝓝 x, HasSum (fun n : ℕ => p n fun _ : Fin n => y - x) (f y) := by filter_upwards [EMetric.ball_mem_nhds x hf.r_pos] with y using hf.hasSum_sub #align has_fpower_series_on_ball.eventually_has_sum_sub HasFPowerSeriesOnBall.eventually_hasSum_sub theorem HasFPowerSeriesAt.eventually_hasSum_sub (hf : HasFPowerSeriesAt f p x) : ∀ᶠ y in 𝓝 x, HasSum (fun n : ℕ => p n fun _ : Fin n => y - x) (f y) := let ⟨_, hr⟩ := hf hr.eventually_hasSum_sub #align has_fpower_series_at.eventually_has_sum_sub HasFPowerSeriesAt.eventually_hasSum_sub theorem HasFPowerSeriesOnBall.eventually_eq_zero (hf : HasFPowerSeriesOnBall f (0 : FormalMultilinearSeries 𝕜 E F) x r) : ∀ᶠ z in 𝓝 x, f z = 0 := by filter_upwards [hf.eventually_hasSum_sub] with z hz using hz.unique hasSum_zero #align has_fpower_series_on_ball.eventually_eq_zero HasFPowerSeriesOnBall.eventually_eq_zero theorem HasFPowerSeriesAt.eventually_eq_zero (hf : HasFPowerSeriesAt f (0 : FormalMultilinearSeries 𝕜 E F) x) : ∀ᶠ z in 𝓝 x, f z = 0 := let ⟨_, hr⟩ := hf hr.eventually_eq_zero #align has_fpower_series_at.eventually_eq_zero HasFPowerSeriesAt.eventually_eq_zero
Mathlib/Analysis/Analytic/Basic.lean
511
514
theorem hasFPowerSeriesOnBall_const {c : F} {e : E} : HasFPowerSeriesOnBall (fun _ => c) (constFormalMultilinearSeries 𝕜 E c) e ⊤ := by
refine ⟨by simp, WithTop.zero_lt_top, fun _ => hasSum_single 0 fun n hn => ?_⟩ simp [constFormalMultilinearSeries_apply hn]
/- Copyright (c) 2019 Zhouhang Zhou. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Zhouhang Zhou -/ import Mathlib.MeasureTheory.Function.LpOrder #align_import measure_theory.function.l1_space from "leanprover-community/mathlib"@"ccdbfb6e5614667af5aa3ab2d50885e0ef44a46f" /-! # Integrable functions and `L¹` space In the first part of this file, the predicate `Integrable` is defined and basic properties of integrable functions are proved. Such a predicate is already available under the name `Memℒp 1`. We give a direct definition which is easier to use, and show that it is equivalent to `Memℒp 1` In the second part, we establish an API between `Integrable` and the space `L¹` of equivalence classes of integrable functions, already defined as a special case of `L^p` spaces for `p = 1`. ## Notation * `α →₁[μ] β` is the type of `L¹` space, where `α` is a `MeasureSpace` and `β` is a `NormedAddCommGroup` with a `SecondCountableTopology`. `f : α →ₘ β` is a "function" in `L¹`. In comments, `[f]` is also used to denote an `L¹` function. `₁` can be typed as `\1`. ## Main definitions * Let `f : α → β` be a function, where `α` is a `MeasureSpace` and `β` a `NormedAddCommGroup`. Then `HasFiniteIntegral f` means `(∫⁻ a, ‖f a‖₊) < ∞`. * If `β` is moreover a `MeasurableSpace` then `f` is called `Integrable` if `f` is `Measurable` and `HasFiniteIntegral f` holds. ## Implementation notes To prove something for an arbitrary integrable function, a useful theorem is `Integrable.induction` in the file `SetIntegral`. ## Tags integrable, function space, l1 -/ noncomputable section open scoped Classical open Topology ENNReal MeasureTheory NNReal open Set Filter TopologicalSpace ENNReal EMetric MeasureTheory variable {α β γ δ : Type*} {m : MeasurableSpace α} {μ ν : Measure α} [MeasurableSpace δ] variable [NormedAddCommGroup β] variable [NormedAddCommGroup γ] namespace MeasureTheory /-! ### Some results about the Lebesgue integral involving a normed group -/ theorem lintegral_nnnorm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ‖f a‖₊ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [edist_eq_coe_nnnorm] #align measure_theory.lintegral_nnnorm_eq_lintegral_edist MeasureTheory.lintegral_nnnorm_eq_lintegral_edist theorem lintegral_norm_eq_lintegral_edist (f : α → β) : ∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ = ∫⁻ a, edist (f a) 0 ∂μ := by simp only [ofReal_norm_eq_coe_nnnorm, edist_eq_coe_nnnorm] #align measure_theory.lintegral_norm_eq_lintegral_edist MeasureTheory.lintegral_norm_eq_lintegral_edist theorem lintegral_edist_triangle {f g h : α → β} (hf : AEStronglyMeasurable f μ) (hh : AEStronglyMeasurable h μ) : (∫⁻ a, edist (f a) (g a) ∂μ) ≤ (∫⁻ a, edist (f a) (h a) ∂μ) + ∫⁻ a, edist (g a) (h a) ∂μ := by rw [← lintegral_add_left' (hf.edist hh)] refine lintegral_mono fun a => ?_ apply edist_triangle_right #align measure_theory.lintegral_edist_triangle MeasureTheory.lintegral_edist_triangle theorem lintegral_nnnorm_zero : (∫⁻ _ : α, ‖(0 : β)‖₊ ∂μ) = 0 := by simp #align measure_theory.lintegral_nnnorm_zero MeasureTheory.lintegral_nnnorm_zero theorem lintegral_nnnorm_add_left {f : α → β} (hf : AEStronglyMeasurable f μ) (g : α → γ) : ∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ := lintegral_add_left' hf.ennnorm _ #align measure_theory.lintegral_nnnorm_add_left MeasureTheory.lintegral_nnnorm_add_left theorem lintegral_nnnorm_add_right (f : α → β) {g : α → γ} (hg : AEStronglyMeasurable g μ) : ∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ = (∫⁻ a, ‖f a‖₊ ∂μ) + ∫⁻ a, ‖g a‖₊ ∂μ := lintegral_add_right' _ hg.ennnorm #align measure_theory.lintegral_nnnorm_add_right MeasureTheory.lintegral_nnnorm_add_right theorem lintegral_nnnorm_neg {f : α → β} : (∫⁻ a, ‖(-f) a‖₊ ∂μ) = ∫⁻ a, ‖f a‖₊ ∂μ := by simp only [Pi.neg_apply, nnnorm_neg] #align measure_theory.lintegral_nnnorm_neg MeasureTheory.lintegral_nnnorm_neg /-! ### The predicate `HasFiniteIntegral` -/ /-- `HasFiniteIntegral f μ` means that the integral `∫⁻ a, ‖f a‖ ∂μ` is finite. `HasFiniteIntegral f` means `HasFiniteIntegral f volume`. -/ def HasFiniteIntegral {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop := (∫⁻ a, ‖f a‖₊ ∂μ) < ∞ #align measure_theory.has_finite_integral MeasureTheory.HasFiniteIntegral theorem hasFiniteIntegral_def {_ : MeasurableSpace α} (f : α → β) (μ : Measure α) : HasFiniteIntegral f μ ↔ ((∫⁻ a, ‖f a‖₊ ∂μ) < ∞) := Iff.rfl theorem hasFiniteIntegral_iff_norm (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) < ∞ := by simp only [HasFiniteIntegral, ofReal_norm_eq_coe_nnnorm] #align measure_theory.has_finite_integral_iff_norm MeasureTheory.hasFiniteIntegral_iff_norm theorem hasFiniteIntegral_iff_edist (f : α → β) : HasFiniteIntegral f μ ↔ (∫⁻ a, edist (f a) 0 ∂μ) < ∞ := by simp only [hasFiniteIntegral_iff_norm, edist_dist, dist_zero_right] #align measure_theory.has_finite_integral_iff_edist MeasureTheory.hasFiniteIntegral_iff_edist theorem hasFiniteIntegral_iff_ofReal {f : α → ℝ} (h : 0 ≤ᵐ[μ] f) : HasFiniteIntegral f μ ↔ (∫⁻ a, ENNReal.ofReal (f a) ∂μ) < ∞ := by rw [HasFiniteIntegral, lintegral_nnnorm_eq_of_ae_nonneg h] #align measure_theory.has_finite_integral_iff_of_real MeasureTheory.hasFiniteIntegral_iff_ofReal theorem hasFiniteIntegral_iff_ofNNReal {f : α → ℝ≥0} : HasFiniteIntegral (fun x => (f x : ℝ)) μ ↔ (∫⁻ a, f a ∂μ) < ∞ := by simp [hasFiniteIntegral_iff_norm] #align measure_theory.has_finite_integral_iff_of_nnreal MeasureTheory.hasFiniteIntegral_iff_ofNNReal theorem HasFiniteIntegral.mono {f : α → β} {g : α → γ} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : HasFiniteIntegral f μ := by simp only [hasFiniteIntegral_iff_norm] at * calc (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) ≤ ∫⁻ a : α, ENNReal.ofReal ‖g a‖ ∂μ := lintegral_mono_ae (h.mono fun a h => ofReal_le_ofReal h) _ < ∞ := hg #align measure_theory.has_finite_integral.mono MeasureTheory.HasFiniteIntegral.mono theorem HasFiniteIntegral.mono' {f : α → β} {g : α → ℝ} (hg : HasFiniteIntegral g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : HasFiniteIntegral f μ := hg.mono <| h.mono fun _x hx => le_trans hx (le_abs_self _) #align measure_theory.has_finite_integral.mono' MeasureTheory.HasFiniteIntegral.mono' theorem HasFiniteIntegral.congr' {f : α → β} {g : α → γ} (hf : HasFiniteIntegral f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral g μ := hf.mono <| EventuallyEq.le <| EventuallyEq.symm h #align measure_theory.has_finite_integral.congr' MeasureTheory.HasFiniteIntegral.congr' theorem hasFiniteIntegral_congr' {f : α → β} {g : α → γ} (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ := ⟨fun hf => hf.congr' h, fun hg => hg.congr' <| EventuallyEq.symm h⟩ #align measure_theory.has_finite_integral_congr' MeasureTheory.hasFiniteIntegral_congr' theorem HasFiniteIntegral.congr {f g : α → β} (hf : HasFiniteIntegral f μ) (h : f =ᵐ[μ] g) : HasFiniteIntegral g μ := hf.congr' <| h.fun_comp norm #align measure_theory.has_finite_integral.congr MeasureTheory.HasFiniteIntegral.congr theorem hasFiniteIntegral_congr {f g : α → β} (h : f =ᵐ[μ] g) : HasFiniteIntegral f μ ↔ HasFiniteIntegral g μ := hasFiniteIntegral_congr' <| h.fun_comp norm #align measure_theory.has_finite_integral_congr MeasureTheory.hasFiniteIntegral_congr theorem hasFiniteIntegral_const_iff {c : β} : HasFiniteIntegral (fun _ : α => c) μ ↔ c = 0 ∨ μ univ < ∞ := by simp [HasFiniteIntegral, lintegral_const, lt_top_iff_ne_top, ENNReal.mul_eq_top, or_iff_not_imp_left] #align measure_theory.has_finite_integral_const_iff MeasureTheory.hasFiniteIntegral_const_iff theorem hasFiniteIntegral_const [IsFiniteMeasure μ] (c : β) : HasFiniteIntegral (fun _ : α => c) μ := hasFiniteIntegral_const_iff.2 (Or.inr <| measure_lt_top _ _) #align measure_theory.has_finite_integral_const MeasureTheory.hasFiniteIntegral_const theorem hasFiniteIntegral_of_bounded [IsFiniteMeasure μ] {f : α → β} {C : ℝ} (hC : ∀ᵐ a ∂μ, ‖f a‖ ≤ C) : HasFiniteIntegral f μ := (hasFiniteIntegral_const C).mono' hC #align measure_theory.has_finite_integral_of_bounded MeasureTheory.hasFiniteIntegral_of_bounded theorem HasFiniteIntegral.of_finite [Finite α] [IsFiniteMeasure μ] {f : α → β} : HasFiniteIntegral f μ := let ⟨_⟩ := nonempty_fintype α hasFiniteIntegral_of_bounded <| ae_of_all μ <| norm_le_pi_norm f @[deprecated (since := "2024-02-05")] alias hasFiniteIntegral_of_fintype := HasFiniteIntegral.of_finite theorem HasFiniteIntegral.mono_measure {f : α → β} (h : HasFiniteIntegral f ν) (hμ : μ ≤ ν) : HasFiniteIntegral f μ := lt_of_le_of_lt (lintegral_mono' hμ le_rfl) h #align measure_theory.has_finite_integral.mono_measure MeasureTheory.HasFiniteIntegral.mono_measure theorem HasFiniteIntegral.add_measure {f : α → β} (hμ : HasFiniteIntegral f μ) (hν : HasFiniteIntegral f ν) : HasFiniteIntegral f (μ + ν) := by simp only [HasFiniteIntegral, lintegral_add_measure] at * exact add_lt_top.2 ⟨hμ, hν⟩ #align measure_theory.has_finite_integral.add_measure MeasureTheory.HasFiniteIntegral.add_measure theorem HasFiniteIntegral.left_of_add_measure {f : α → β} (h : HasFiniteIntegral f (μ + ν)) : HasFiniteIntegral f μ := h.mono_measure <| Measure.le_add_right <| le_rfl #align measure_theory.has_finite_integral.left_of_add_measure MeasureTheory.HasFiniteIntegral.left_of_add_measure theorem HasFiniteIntegral.right_of_add_measure {f : α → β} (h : HasFiniteIntegral f (μ + ν)) : HasFiniteIntegral f ν := h.mono_measure <| Measure.le_add_left <| le_rfl #align measure_theory.has_finite_integral.right_of_add_measure MeasureTheory.HasFiniteIntegral.right_of_add_measure @[simp] theorem hasFiniteIntegral_add_measure {f : α → β} : HasFiniteIntegral f (μ + ν) ↔ HasFiniteIntegral f μ ∧ HasFiniteIntegral f ν := ⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩ #align measure_theory.has_finite_integral_add_measure MeasureTheory.hasFiniteIntegral_add_measure theorem HasFiniteIntegral.smul_measure {f : α → β} (h : HasFiniteIntegral f μ) {c : ℝ≥0∞} (hc : c ≠ ∞) : HasFiniteIntegral f (c • μ) := by simp only [HasFiniteIntegral, lintegral_smul_measure] at * exact mul_lt_top hc h.ne #align measure_theory.has_finite_integral.smul_measure MeasureTheory.HasFiniteIntegral.smul_measure @[simp] theorem hasFiniteIntegral_zero_measure {m : MeasurableSpace α} (f : α → β) : HasFiniteIntegral f (0 : Measure α) := by simp only [HasFiniteIntegral, lintegral_zero_measure, zero_lt_top] #align measure_theory.has_finite_integral_zero_measure MeasureTheory.hasFiniteIntegral_zero_measure variable (α β μ) @[simp] theorem hasFiniteIntegral_zero : HasFiniteIntegral (fun _ : α => (0 : β)) μ := by simp [HasFiniteIntegral] #align measure_theory.has_finite_integral_zero MeasureTheory.hasFiniteIntegral_zero variable {α β μ} theorem HasFiniteIntegral.neg {f : α → β} (hfi : HasFiniteIntegral f μ) : HasFiniteIntegral (-f) μ := by simpa [HasFiniteIntegral] using hfi #align measure_theory.has_finite_integral.neg MeasureTheory.HasFiniteIntegral.neg @[simp] theorem hasFiniteIntegral_neg_iff {f : α → β} : HasFiniteIntegral (-f) μ ↔ HasFiniteIntegral f μ := ⟨fun h => neg_neg f ▸ h.neg, HasFiniteIntegral.neg⟩ #align measure_theory.has_finite_integral_neg_iff MeasureTheory.hasFiniteIntegral_neg_iff theorem HasFiniteIntegral.norm {f : α → β} (hfi : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => ‖f a‖) μ := by have eq : (fun a => (nnnorm ‖f a‖ : ℝ≥0∞)) = fun a => (‖f a‖₊ : ℝ≥0∞) := by funext rw [nnnorm_norm] rwa [HasFiniteIntegral, eq] #align measure_theory.has_finite_integral.norm MeasureTheory.HasFiniteIntegral.norm theorem hasFiniteIntegral_norm_iff (f : α → β) : HasFiniteIntegral (fun a => ‖f a‖) μ ↔ HasFiniteIntegral f μ := hasFiniteIntegral_congr' <| eventually_of_forall fun x => norm_norm (f x) #align measure_theory.has_finite_integral_norm_iff MeasureTheory.hasFiniteIntegral_norm_iff theorem hasFiniteIntegral_toReal_of_lintegral_ne_top {f : α → ℝ≥0∞} (hf : (∫⁻ x, f x ∂μ) ≠ ∞) : HasFiniteIntegral (fun x => (f x).toReal) μ := by have : ∀ x, (‖(f x).toReal‖₊ : ℝ≥0∞) = ENNReal.ofNNReal ⟨(f x).toReal, ENNReal.toReal_nonneg⟩ := by intro x rw [Real.nnnorm_of_nonneg] simp_rw [HasFiniteIntegral, this] refine lt_of_le_of_lt (lintegral_mono fun x => ?_) (lt_top_iff_ne_top.2 hf) by_cases hfx : f x = ∞ · simp [hfx] · lift f x to ℝ≥0 using hfx with fx h simp [← h, ← NNReal.coe_le_coe] #align measure_theory.has_finite_integral_to_real_of_lintegral_ne_top MeasureTheory.hasFiniteIntegral_toReal_of_lintegral_ne_top theorem isFiniteMeasure_withDensity_ofReal {f : α → ℝ} (hfi : HasFiniteIntegral f μ) : IsFiniteMeasure (μ.withDensity fun x => ENNReal.ofReal <| f x) := by refine isFiniteMeasure_withDensity ((lintegral_mono fun x => ?_).trans_lt hfi).ne exact Real.ofReal_le_ennnorm (f x) #align measure_theory.is_finite_measure_with_density_of_real MeasureTheory.isFiniteMeasure_withDensity_ofReal section DominatedConvergence variable {F : ℕ → α → β} {f : α → β} {bound : α → ℝ} theorem all_ae_ofReal_F_le_bound (h : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) : ∀ n, ∀ᵐ a ∂μ, ENNReal.ofReal ‖F n a‖ ≤ ENNReal.ofReal (bound a) := fun n => (h n).mono fun _ h => ENNReal.ofReal_le_ofReal h set_option linter.uppercaseLean3 false in #align measure_theory.all_ae_of_real_F_le_bound MeasureTheory.all_ae_ofReal_F_le_bound theorem all_ae_tendsto_ofReal_norm (h : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop <| 𝓝 <| f a) : ∀ᵐ a ∂μ, Tendsto (fun n => ENNReal.ofReal ‖F n a‖) atTop <| 𝓝 <| ENNReal.ofReal ‖f a‖ := h.mono fun _ h => tendsto_ofReal <| Tendsto.comp (Continuous.tendsto continuous_norm _) h #align measure_theory.all_ae_tendsto_of_real_norm MeasureTheory.all_ae_tendsto_ofReal_norm theorem all_ae_ofReal_f_le_bound (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : ∀ᵐ a ∂μ, ENNReal.ofReal ‖f a‖ ≤ ENNReal.ofReal (bound a) := by have F_le_bound := all_ae_ofReal_F_le_bound h_bound rw [← ae_all_iff] at F_le_bound apply F_le_bound.mp ((all_ae_tendsto_ofReal_norm h_lim).mono _) intro a tendsto_norm F_le_bound exact le_of_tendsto' tendsto_norm F_le_bound #align measure_theory.all_ae_of_real_f_le_bound MeasureTheory.all_ae_ofReal_f_le_bound theorem hasFiniteIntegral_of_dominated_convergence {F : ℕ → α → β} {f : α → β} {bound : α → ℝ} (bound_hasFiniteIntegral : HasFiniteIntegral bound μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : HasFiniteIntegral f μ := by /- `‖F n a‖ ≤ bound a` and `‖F n a‖ --> ‖f a‖` implies `‖f a‖ ≤ bound a`, and so `∫ ‖f‖ ≤ ∫ bound < ∞` since `bound` is has_finite_integral -/ rw [hasFiniteIntegral_iff_norm] calc (∫⁻ a, ENNReal.ofReal ‖f a‖ ∂μ) ≤ ∫⁻ a, ENNReal.ofReal (bound a) ∂μ := lintegral_mono_ae <| all_ae_ofReal_f_le_bound h_bound h_lim _ < ∞ := by rw [← hasFiniteIntegral_iff_ofReal] · exact bound_hasFiniteIntegral exact (h_bound 0).mono fun a h => le_trans (norm_nonneg _) h #align measure_theory.has_finite_integral_of_dominated_convergence MeasureTheory.hasFiniteIntegral_of_dominated_convergence theorem tendsto_lintegral_norm_of_dominated_convergence {F : ℕ → α → β} {f : α → β} {bound : α → ℝ} (F_measurable : ∀ n, AEStronglyMeasurable (F n) μ) (bound_hasFiniteIntegral : HasFiniteIntegral bound μ) (h_bound : ∀ n, ∀ᵐ a ∂μ, ‖F n a‖ ≤ bound a) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, ENNReal.ofReal ‖F n a - f a‖ ∂μ) atTop (𝓝 0) := by have f_measurable : AEStronglyMeasurable f μ := aestronglyMeasurable_of_tendsto_ae _ F_measurable h_lim let b a := 2 * ENNReal.ofReal (bound a) /- `‖F n a‖ ≤ bound a` and `F n a --> f a` implies `‖f a‖ ≤ bound a`, and thus by the triangle inequality, have `‖F n a - f a‖ ≤ 2 * (bound a)`. -/ have hb : ∀ n, ∀ᵐ a ∂μ, ENNReal.ofReal ‖F n a - f a‖ ≤ b a := by intro n filter_upwards [all_ae_ofReal_F_le_bound h_bound n, all_ae_ofReal_f_le_bound h_bound h_lim] with a h₁ h₂ calc ENNReal.ofReal ‖F n a - f a‖ ≤ ENNReal.ofReal ‖F n a‖ + ENNReal.ofReal ‖f a‖ := by rw [← ENNReal.ofReal_add] · apply ofReal_le_ofReal apply norm_sub_le · exact norm_nonneg _ · exact norm_nonneg _ _ ≤ ENNReal.ofReal (bound a) + ENNReal.ofReal (bound a) := add_le_add h₁ h₂ _ = b a := by rw [← two_mul] -- On the other hand, `F n a --> f a` implies that `‖F n a - f a‖ --> 0` have h : ∀ᵐ a ∂μ, Tendsto (fun n => ENNReal.ofReal ‖F n a - f a‖) atTop (𝓝 0) := by rw [← ENNReal.ofReal_zero] refine h_lim.mono fun a h => (continuous_ofReal.tendsto _).comp ?_ rwa [← tendsto_iff_norm_sub_tendsto_zero] /- Therefore, by the dominated convergence theorem for nonnegative integration, have ` ∫ ‖f a - F n a‖ --> 0 ` -/ suffices Tendsto (fun n => ∫⁻ a, ENNReal.ofReal ‖F n a - f a‖ ∂μ) atTop (𝓝 (∫⁻ _ : α, 0 ∂μ)) by rwa [lintegral_zero] at this -- Using the dominated convergence theorem. refine tendsto_lintegral_of_dominated_convergence' _ ?_ hb ?_ ?_ -- Show `fun a => ‖f a - F n a‖` is almost everywhere measurable for all `n` · exact fun n => measurable_ofReal.comp_aemeasurable ((F_measurable n).sub f_measurable).norm.aemeasurable -- Show `2 * bound` `HasFiniteIntegral` · rw [hasFiniteIntegral_iff_ofReal] at bound_hasFiniteIntegral · calc ∫⁻ a, b a ∂μ = 2 * ∫⁻ a, ENNReal.ofReal (bound a) ∂μ := by rw [lintegral_const_mul'] exact coe_ne_top _ ≠ ∞ := mul_ne_top coe_ne_top bound_hasFiniteIntegral.ne filter_upwards [h_bound 0] with _ h using le_trans (norm_nonneg _) h -- Show `‖f a - F n a‖ --> 0` · exact h #align measure_theory.tendsto_lintegral_norm_of_dominated_convergence MeasureTheory.tendsto_lintegral_norm_of_dominated_convergence end DominatedConvergence section PosPart /-! Lemmas used for defining the positive part of an `L¹` function -/ theorem HasFiniteIntegral.max_zero {f : α → ℝ} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => max (f a) 0) μ := hf.mono <| eventually_of_forall fun x => by simp [abs_le, le_abs_self] #align measure_theory.has_finite_integral.max_zero MeasureTheory.HasFiniteIntegral.max_zero theorem HasFiniteIntegral.min_zero {f : α → ℝ} (hf : HasFiniteIntegral f μ) : HasFiniteIntegral (fun a => min (f a) 0) μ := hf.mono <| eventually_of_forall fun x => by simpa [abs_le] using neg_abs_le _ #align measure_theory.has_finite_integral.min_zero MeasureTheory.HasFiniteIntegral.min_zero end PosPart section NormedSpace variable {𝕜 : Type*} theorem HasFiniteIntegral.smul [NormedAddCommGroup 𝕜] [SMulZeroClass 𝕜 β] [BoundedSMul 𝕜 β] (c : 𝕜) {f : α → β} : HasFiniteIntegral f μ → HasFiniteIntegral (c • f) μ := by simp only [HasFiniteIntegral]; intro hfi calc (∫⁻ a : α, ‖c • f a‖₊ ∂μ) ≤ ∫⁻ a : α, ‖c‖₊ * ‖f a‖₊ ∂μ := by refine lintegral_mono ?_ intro i -- After leanprover/lean4#2734, we need to do beta reduction `exact mod_cast` beta_reduce exact mod_cast (nnnorm_smul_le c (f i)) _ < ∞ := by rw [lintegral_const_mul'] exacts [mul_lt_top coe_ne_top hfi.ne, coe_ne_top] #align measure_theory.has_finite_integral.smul MeasureTheory.HasFiniteIntegral.smul theorem hasFiniteIntegral_smul_iff [NormedRing 𝕜] [MulActionWithZero 𝕜 β] [BoundedSMul 𝕜 β] {c : 𝕜} (hc : IsUnit c) (f : α → β) : HasFiniteIntegral (c • f) μ ↔ HasFiniteIntegral f μ := by obtain ⟨c, rfl⟩ := hc constructor · intro h simpa only [smul_smul, Units.inv_mul, one_smul] using h.smul ((c⁻¹ : 𝕜ˣ) : 𝕜) exact HasFiniteIntegral.smul _ #align measure_theory.has_finite_integral_smul_iff MeasureTheory.hasFiniteIntegral_smul_iff theorem HasFiniteIntegral.const_mul [NormedRing 𝕜] {f : α → 𝕜} (h : HasFiniteIntegral f μ) (c : 𝕜) : HasFiniteIntegral (fun x => c * f x) μ := h.smul c #align measure_theory.has_finite_integral.const_mul MeasureTheory.HasFiniteIntegral.const_mul theorem HasFiniteIntegral.mul_const [NormedRing 𝕜] {f : α → 𝕜} (h : HasFiniteIntegral f μ) (c : 𝕜) : HasFiniteIntegral (fun x => f x * c) μ := h.smul (MulOpposite.op c) #align measure_theory.has_finite_integral.mul_const MeasureTheory.HasFiniteIntegral.mul_const end NormedSpace /-! ### The predicate `Integrable` -/ -- variable [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ] /-- `Integrable f μ` means that `f` is measurable and that the integral `∫⁻ a, ‖f a‖ ∂μ` is finite. `Integrable f` means `Integrable f volume`. -/ def Integrable {α} {_ : MeasurableSpace α} (f : α → β) (μ : Measure α := by volume_tac) : Prop := AEStronglyMeasurable f μ ∧ HasFiniteIntegral f μ #align measure_theory.integrable MeasureTheory.Integrable theorem memℒp_one_iff_integrable {f : α → β} : Memℒp f 1 μ ↔ Integrable f μ := by simp_rw [Integrable, HasFiniteIntegral, Memℒp, snorm_one_eq_lintegral_nnnorm] #align measure_theory.mem_ℒp_one_iff_integrable MeasureTheory.memℒp_one_iff_integrable theorem Integrable.aestronglyMeasurable {f : α → β} (hf : Integrable f μ) : AEStronglyMeasurable f μ := hf.1 #align measure_theory.integrable.ae_strongly_measurable MeasureTheory.Integrable.aestronglyMeasurable theorem Integrable.aemeasurable [MeasurableSpace β] [BorelSpace β] {f : α → β} (hf : Integrable f μ) : AEMeasurable f μ := hf.aestronglyMeasurable.aemeasurable #align measure_theory.integrable.ae_measurable MeasureTheory.Integrable.aemeasurable theorem Integrable.hasFiniteIntegral {f : α → β} (hf : Integrable f μ) : HasFiniteIntegral f μ := hf.2 #align measure_theory.integrable.has_finite_integral MeasureTheory.Integrable.hasFiniteIntegral theorem Integrable.mono {f : α → β} {g : α → γ} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ ‖g a‖) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono h⟩ #align measure_theory.integrable.mono MeasureTheory.Integrable.mono theorem Integrable.mono' {f : α → β} {g : α → ℝ} (hg : Integrable g μ) (hf : AEStronglyMeasurable f μ) (h : ∀ᵐ a ∂μ, ‖f a‖ ≤ g a) : Integrable f μ := ⟨hf, hg.hasFiniteIntegral.mono' h⟩ #align measure_theory.integrable.mono' MeasureTheory.Integrable.mono' theorem Integrable.congr' {f : α → β} {g : α → γ} (hf : Integrable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : Integrable g μ := ⟨hg, hf.hasFiniteIntegral.congr' h⟩ #align measure_theory.integrable.congr' MeasureTheory.Integrable.congr' theorem integrable_congr' {f : α → β} {g : α → γ} (hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (h : ∀ᵐ a ∂μ, ‖f a‖ = ‖g a‖) : Integrable f μ ↔ Integrable g μ := ⟨fun h2f => h2f.congr' hg h, fun h2g => h2g.congr' hf <| EventuallyEq.symm h⟩ #align measure_theory.integrable_congr' MeasureTheory.integrable_congr' theorem Integrable.congr {f g : α → β} (hf : Integrable f μ) (h : f =ᵐ[μ] g) : Integrable g μ := ⟨hf.1.congr h, hf.2.congr h⟩ #align measure_theory.integrable.congr MeasureTheory.Integrable.congr theorem integrable_congr {f g : α → β} (h : f =ᵐ[μ] g) : Integrable f μ ↔ Integrable g μ := ⟨fun hf => hf.congr h, fun hg => hg.congr h.symm⟩ #align measure_theory.integrable_congr MeasureTheory.integrable_congr theorem integrable_const_iff {c : β} : Integrable (fun _ : α => c) μ ↔ c = 0 ∨ μ univ < ∞ := by have : AEStronglyMeasurable (fun _ : α => c) μ := aestronglyMeasurable_const rw [Integrable, and_iff_right this, hasFiniteIntegral_const_iff] #align measure_theory.integrable_const_iff MeasureTheory.integrable_const_iff @[simp] theorem integrable_const [IsFiniteMeasure μ] (c : β) : Integrable (fun _ : α => c) μ := integrable_const_iff.2 <| Or.inr <| measure_lt_top _ _ #align measure_theory.integrable_const MeasureTheory.integrable_const @[simp] theorem Integrable.of_finite [Finite α] [MeasurableSpace α] [MeasurableSingletonClass α] (μ : Measure α) [IsFiniteMeasure μ] (f : α → β) : Integrable (fun a ↦ f a) μ := ⟨(StronglyMeasurable.of_finite f).aestronglyMeasurable, .of_finite⟩ @[deprecated (since := "2024-02-05")] alias integrable_of_fintype := Integrable.of_finite theorem Memℒp.integrable_norm_rpow {f : α → β} {p : ℝ≥0∞} (hf : Memℒp f p μ) (hp_ne_zero : p ≠ 0) (hp_ne_top : p ≠ ∞) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by rw [← memℒp_one_iff_integrable] exact hf.norm_rpow hp_ne_zero hp_ne_top #align measure_theory.mem_ℒp.integrable_norm_rpow MeasureTheory.Memℒp.integrable_norm_rpow theorem Memℒp.integrable_norm_rpow' [IsFiniteMeasure μ] {f : α → β} {p : ℝ≥0∞} (hf : Memℒp f p μ) : Integrable (fun x : α => ‖f x‖ ^ p.toReal) μ := by by_cases h_zero : p = 0 · simp [h_zero, integrable_const] by_cases h_top : p = ∞ · simp [h_top, integrable_const] exact hf.integrable_norm_rpow h_zero h_top #align measure_theory.mem_ℒp.integrable_norm_rpow' MeasureTheory.Memℒp.integrable_norm_rpow' theorem Integrable.mono_measure {f : α → β} (h : Integrable f ν) (hμ : μ ≤ ν) : Integrable f μ := ⟨h.aestronglyMeasurable.mono_measure hμ, h.hasFiniteIntegral.mono_measure hμ⟩ #align measure_theory.integrable.mono_measure MeasureTheory.Integrable.mono_measure theorem Integrable.of_measure_le_smul {μ' : Measure α} (c : ℝ≥0∞) (hc : c ≠ ∞) (hμ'_le : μ' ≤ c • μ) {f : α → β} (hf : Integrable f μ) : Integrable f μ' := by rw [← memℒp_one_iff_integrable] at hf ⊢ exact hf.of_measure_le_smul c hc hμ'_le #align measure_theory.integrable.of_measure_le_smul MeasureTheory.Integrable.of_measure_le_smul theorem Integrable.add_measure {f : α → β} (hμ : Integrable f μ) (hν : Integrable f ν) : Integrable f (μ + ν) := by simp_rw [← memℒp_one_iff_integrable] at hμ hν ⊢ refine ⟨hμ.aestronglyMeasurable.add_measure hν.aestronglyMeasurable, ?_⟩ rw [snorm_one_add_measure, ENNReal.add_lt_top] exact ⟨hμ.snorm_lt_top, hν.snorm_lt_top⟩ #align measure_theory.integrable.add_measure MeasureTheory.Integrable.add_measure theorem Integrable.left_of_add_measure {f : α → β} (h : Integrable f (μ + ν)) : Integrable f μ := by rw [← memℒp_one_iff_integrable] at h ⊢ exact h.left_of_add_measure #align measure_theory.integrable.left_of_add_measure MeasureTheory.Integrable.left_of_add_measure theorem Integrable.right_of_add_measure {f : α → β} (h : Integrable f (μ + ν)) : Integrable f ν := by rw [← memℒp_one_iff_integrable] at h ⊢ exact h.right_of_add_measure #align measure_theory.integrable.right_of_add_measure MeasureTheory.Integrable.right_of_add_measure @[simp] theorem integrable_add_measure {f : α → β} : Integrable f (μ + ν) ↔ Integrable f μ ∧ Integrable f ν := ⟨fun h => ⟨h.left_of_add_measure, h.right_of_add_measure⟩, fun h => h.1.add_measure h.2⟩ #align measure_theory.integrable_add_measure MeasureTheory.integrable_add_measure @[simp] theorem integrable_zero_measure {_ : MeasurableSpace α} {f : α → β} : Integrable f (0 : Measure α) := ⟨aestronglyMeasurable_zero_measure f, hasFiniteIntegral_zero_measure f⟩ #align measure_theory.integrable_zero_measure MeasureTheory.integrable_zero_measure theorem integrable_finset_sum_measure {ι} {m : MeasurableSpace α} {f : α → β} {μ : ι → Measure α} {s : Finset ι} : Integrable f (∑ i ∈ s, μ i) ↔ ∀ i ∈ s, Integrable f (μ i) := by induction s using Finset.induction_on <;> simp [*] #align measure_theory.integrable_finset_sum_measure MeasureTheory.integrable_finset_sum_measure theorem Integrable.smul_measure {f : α → β} (h : Integrable f μ) {c : ℝ≥0∞} (hc : c ≠ ∞) : Integrable f (c • μ) := by rw [← memℒp_one_iff_integrable] at h ⊢ exact h.smul_measure hc #align measure_theory.integrable.smul_measure MeasureTheory.Integrable.smul_measure theorem Integrable.smul_measure_nnreal {f : α → β} (h : Integrable f μ) {c : ℝ≥0} : Integrable f (c • μ) := by apply h.smul_measure simp theorem integrable_smul_measure {f : α → β} {c : ℝ≥0∞} (h₁ : c ≠ 0) (h₂ : c ≠ ∞) : Integrable f (c • μ) ↔ Integrable f μ := ⟨fun h => by simpa only [smul_smul, ENNReal.inv_mul_cancel h₁ h₂, one_smul] using h.smul_measure (ENNReal.inv_ne_top.2 h₁), fun h => h.smul_measure h₂⟩ #align measure_theory.integrable_smul_measure MeasureTheory.integrable_smul_measure theorem integrable_inv_smul_measure {f : α → β} {c : ℝ≥0∞} (h₁ : c ≠ 0) (h₂ : c ≠ ∞) : Integrable f (c⁻¹ • μ) ↔ Integrable f μ := integrable_smul_measure (by simpa using h₂) (by simpa using h₁) #align measure_theory.integrable_inv_smul_measure MeasureTheory.integrable_inv_smul_measure theorem Integrable.to_average {f : α → β} (h : Integrable f μ) : Integrable f ((μ univ)⁻¹ • μ) := by rcases eq_or_ne μ 0 with (rfl | hne) · rwa [smul_zero] · apply h.smul_measure simpa #align measure_theory.integrable.to_average MeasureTheory.Integrable.to_average theorem integrable_average [IsFiniteMeasure μ] {f : α → β} : Integrable f ((μ univ)⁻¹ • μ) ↔ Integrable f μ := (eq_or_ne μ 0).by_cases (fun h => by simp [h]) fun h => integrable_smul_measure (ENNReal.inv_ne_zero.2 <| measure_ne_top _ _) (ENNReal.inv_ne_top.2 <| mt Measure.measure_univ_eq_zero.1 h) #align measure_theory.integrable_average MeasureTheory.integrable_average theorem integrable_map_measure {f : α → δ} {g : δ → β} (hg : AEStronglyMeasurable g (Measure.map f μ)) (hf : AEMeasurable f μ) : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memℒp_one_iff_integrable] exact memℒp_map_measure_iff hg hf #align measure_theory.integrable_map_measure MeasureTheory.integrable_map_measure theorem Integrable.comp_aemeasurable {f : α → δ} {g : δ → β} (hg : Integrable g (Measure.map f μ)) (hf : AEMeasurable f μ) : Integrable (g ∘ f) μ := (integrable_map_measure hg.aestronglyMeasurable hf).mp hg #align measure_theory.integrable.comp_ae_measurable MeasureTheory.Integrable.comp_aemeasurable theorem Integrable.comp_measurable {f : α → δ} {g : δ → β} (hg : Integrable g (Measure.map f μ)) (hf : Measurable f) : Integrable (g ∘ f) μ := hg.comp_aemeasurable hf.aemeasurable #align measure_theory.integrable.comp_measurable MeasureTheory.Integrable.comp_measurable theorem _root_.MeasurableEmbedding.integrable_map_iff {f : α → δ} (hf : MeasurableEmbedding f) {g : δ → β} : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memℒp_one_iff_integrable] exact hf.memℒp_map_measure_iff #align measurable_embedding.integrable_map_iff MeasurableEmbedding.integrable_map_iff theorem integrable_map_equiv (f : α ≃ᵐ δ) (g : δ → β) : Integrable g (Measure.map f μ) ↔ Integrable (g ∘ f) μ := by simp_rw [← memℒp_one_iff_integrable] exact f.memℒp_map_measure_iff #align measure_theory.integrable_map_equiv MeasureTheory.integrable_map_equiv theorem MeasurePreserving.integrable_comp {ν : Measure δ} {g : δ → β} {f : α → δ} (hf : MeasurePreserving f μ ν) (hg : AEStronglyMeasurable g ν) : Integrable (g ∘ f) μ ↔ Integrable g ν := by rw [← hf.map_eq] at hg ⊢ exact (integrable_map_measure hg hf.measurable.aemeasurable).symm #align measure_theory.measure_preserving.integrable_comp MeasureTheory.MeasurePreserving.integrable_comp theorem MeasurePreserving.integrable_comp_emb {f : α → δ} {ν} (h₁ : MeasurePreserving f μ ν) (h₂ : MeasurableEmbedding f) {g : δ → β} : Integrable (g ∘ f) μ ↔ Integrable g ν := h₁.map_eq ▸ Iff.symm h₂.integrable_map_iff #align measure_theory.measure_preserving.integrable_comp_emb MeasureTheory.MeasurePreserving.integrable_comp_emb theorem lintegral_edist_lt_top {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : (∫⁻ a, edist (f a) (g a) ∂μ) < ∞ := lt_of_le_of_lt (lintegral_edist_triangle hf.aestronglyMeasurable aestronglyMeasurable_zero) (ENNReal.add_lt_top.2 <| by simp_rw [Pi.zero_apply, ← hasFiniteIntegral_iff_edist] exact ⟨hf.hasFiniteIntegral, hg.hasFiniteIntegral⟩) #align measure_theory.lintegral_edist_lt_top MeasureTheory.lintegral_edist_lt_top variable (α β μ) @[simp] theorem integrable_zero : Integrable (fun _ => (0 : β)) μ := by simp [Integrable, aestronglyMeasurable_const] #align measure_theory.integrable_zero MeasureTheory.integrable_zero variable {α β μ} theorem Integrable.add' {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : HasFiniteIntegral (f + g) μ := calc (∫⁻ a, ‖f a + g a‖₊ ∂μ) ≤ ∫⁻ a, ‖f a‖₊ + ‖g a‖₊ ∂μ := lintegral_mono fun a => by -- After leanprover/lean4#2734, we need to do beta reduction before `exact mod_cast` beta_reduce exact mod_cast nnnorm_add_le _ _ _ = _ := lintegral_nnnorm_add_left hf.aestronglyMeasurable _ _ < ∞ := add_lt_top.2 ⟨hf.hasFiniteIntegral, hg.hasFiniteIntegral⟩ #align measure_theory.integrable.add' MeasureTheory.Integrable.add' theorem Integrable.add {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f + g) μ := ⟨hf.aestronglyMeasurable.add hg.aestronglyMeasurable, hf.add' hg⟩ #align measure_theory.integrable.add MeasureTheory.Integrable.add theorem integrable_finset_sum' {ι} (s : Finset ι) {f : ι → α → β} (hf : ∀ i ∈ s, Integrable (f i) μ) : Integrable (∑ i ∈ s, f i) μ := Finset.sum_induction f (fun g => Integrable g μ) (fun _ _ => Integrable.add) (integrable_zero _ _ _) hf #align measure_theory.integrable_finset_sum' MeasureTheory.integrable_finset_sum' theorem integrable_finset_sum {ι} (s : Finset ι) {f : ι → α → β} (hf : ∀ i ∈ s, Integrable (f i) μ) : Integrable (fun a => ∑ i ∈ s, f i a) μ := by simpa only [← Finset.sum_apply] using integrable_finset_sum' s hf #align measure_theory.integrable_finset_sum MeasureTheory.integrable_finset_sum theorem Integrable.neg {f : α → β} (hf : Integrable f μ) : Integrable (-f) μ := ⟨hf.aestronglyMeasurable.neg, hf.hasFiniteIntegral.neg⟩ #align measure_theory.integrable.neg MeasureTheory.Integrable.neg @[simp] theorem integrable_neg_iff {f : α → β} : Integrable (-f) μ ↔ Integrable f μ := ⟨fun h => neg_neg f ▸ h.neg, Integrable.neg⟩ #align measure_theory.integrable_neg_iff MeasureTheory.integrable_neg_iff @[simp] lemma integrable_add_iff_integrable_right {f g : α → β} (hf : Integrable f μ) : Integrable (f + g) μ ↔ Integrable g μ := ⟨fun h ↦ show g = f + g + (-f) by simp only [add_neg_cancel_comm] ▸ h.add hf.neg, fun h ↦ hf.add h⟩ @[simp] lemma integrable_add_iff_integrable_left {f g : α → β} (hf : Integrable f μ) : Integrable (g + f) μ ↔ Integrable g μ := by rw [add_comm, integrable_add_iff_integrable_right hf] lemma integrable_left_of_integrable_add_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) (h_int : Integrable (f + g) μ) : Integrable f μ := by refine h_int.mono' h_meas ?_ filter_upwards [hf, hg] with a haf hag exact (Real.norm_of_nonneg haf).symm ▸ (le_add_iff_nonneg_right _).mpr hag lemma integrable_right_of_integrable_add_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) (h_int : Integrable (f + g) μ) : Integrable g μ := integrable_left_of_integrable_add_of_nonneg ((AEStronglyMeasurable.add_iff_right h_meas).mp h_int.aestronglyMeasurable) hg hf (add_comm f g ▸ h_int) lemma integrable_add_iff_of_nonneg {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : 0 ≤ᵐ[μ] f) (hg : 0 ≤ᵐ[μ] g) : Integrable (f + g) μ ↔ Integrable f μ ∧ Integrable g μ := ⟨fun h ↦ ⟨integrable_left_of_integrable_add_of_nonneg h_meas hf hg h, integrable_right_of_integrable_add_of_nonneg h_meas hf hg h⟩, fun ⟨hf, hg⟩ ↦ hf.add hg⟩ lemma integrable_add_iff_of_nonpos {f g : α → ℝ} (h_meas : AEStronglyMeasurable f μ) (hf : f ≤ᵐ[μ] 0) (hg : g ≤ᵐ[μ] 0) : Integrable (f + g) μ ↔ Integrable f μ ∧ Integrable g μ := by rw [← integrable_neg_iff, ← integrable_neg_iff (f := f), ← integrable_neg_iff (f := g), neg_add] exact integrable_add_iff_of_nonneg h_meas.neg (hf.mono (fun _ ↦ neg_nonneg_of_nonpos)) (hg.mono (fun _ ↦ neg_nonneg_of_nonpos)) @[simp] lemma integrable_add_const_iff [IsFiniteMeasure μ] {f : α → β} {c : β} : Integrable (fun x ↦ f x + c) μ ↔ Integrable f μ := integrable_add_iff_integrable_left (integrable_const _) @[simp] lemma integrable_const_add_iff [IsFiniteMeasure μ] {f : α → β} {c : β} : Integrable (fun x ↦ c + f x) μ ↔ Integrable f μ := integrable_add_iff_integrable_right (integrable_const _) theorem Integrable.sub {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f - g) μ := by simpa only [sub_eq_add_neg] using hf.add hg.neg #align measure_theory.integrable.sub MeasureTheory.Integrable.sub theorem Integrable.norm {f : α → β} (hf : Integrable f μ) : Integrable (fun a => ‖f a‖) μ := ⟨hf.aestronglyMeasurable.norm, hf.hasFiniteIntegral.norm⟩ #align measure_theory.integrable.norm MeasureTheory.Integrable.norm theorem Integrable.inf {β} [NormedLatticeAddCommGroup β] {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f ⊓ g) μ := by rw [← memℒp_one_iff_integrable] at hf hg ⊢ exact hf.inf hg #align measure_theory.integrable.inf MeasureTheory.Integrable.inf theorem Integrable.sup {β} [NormedLatticeAddCommGroup β] {f g : α → β} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (f ⊔ g) μ := by rw [← memℒp_one_iff_integrable] at hf hg ⊢ exact hf.sup hg #align measure_theory.integrable.sup MeasureTheory.Integrable.sup theorem Integrable.abs {β} [NormedLatticeAddCommGroup β] {f : α → β} (hf : Integrable f μ) : Integrable (fun a => |f a|) μ := by rw [← memℒp_one_iff_integrable] at hf ⊢ exact hf.abs #align measure_theory.integrable.abs MeasureTheory.Integrable.abs theorem Integrable.bdd_mul {F : Type*} [NormedDivisionRing F] {f g : α → F} (hint : Integrable g μ) (hm : AEStronglyMeasurable f μ) (hfbdd : ∃ C, ∀ x, ‖f x‖ ≤ C) : Integrable (fun x => f x * g x) μ := by cases' isEmpty_or_nonempty α with hα hα · rw [μ.eq_zero_of_isEmpty] exact integrable_zero_measure · refine ⟨hm.mul hint.1, ?_⟩ obtain ⟨C, hC⟩ := hfbdd have hCnonneg : 0 ≤ C := le_trans (norm_nonneg _) (hC hα.some) have : (fun x => ‖f x * g x‖₊) ≤ fun x => ⟨C, hCnonneg⟩ * ‖g x‖₊ := by intro x simp only [nnnorm_mul] exact mul_le_mul_of_nonneg_right (hC x) (zero_le _) refine lt_of_le_of_lt (lintegral_mono_nnreal this) ?_ simp only [ENNReal.coe_mul] rw [lintegral_const_mul' _ _ ENNReal.coe_ne_top] exact ENNReal.mul_lt_top ENNReal.coe_ne_top (ne_of_lt hint.2) #align measure_theory.integrable.bdd_mul MeasureTheory.Integrable.bdd_mul /-- **Hölder's inequality for integrable functions**: the scalar multiplication of an integrable vector-valued function by a scalar function with finite essential supremum is integrable. -/ theorem Integrable.essSup_smul {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 β] {f : α → β} (hf : Integrable f μ) {g : α → 𝕜} (g_aestronglyMeasurable : AEStronglyMeasurable g μ) (ess_sup_g : essSup (fun x => (‖g x‖₊ : ℝ≥0∞)) μ ≠ ∞) : Integrable (fun x : α => g x • f x) μ := by rw [← memℒp_one_iff_integrable] at * refine ⟨g_aestronglyMeasurable.smul hf.1, ?_⟩ have h : (1 : ℝ≥0∞) / 1 = 1 / ∞ + 1 / 1 := by norm_num have hg' : snorm g ∞ μ ≠ ∞ := by rwa [snorm_exponent_top] calc snorm (fun x : α => g x • f x) 1 μ ≤ _ := by simpa using MeasureTheory.snorm_smul_le_mul_snorm hf.1 g_aestronglyMeasurable h _ < ∞ := ENNReal.mul_lt_top hg' hf.2.ne #align measure_theory.integrable.ess_sup_smul MeasureTheory.Integrable.essSup_smul /-- Hölder's inequality for integrable functions: the scalar multiplication of an integrable scalar-valued function by a vector-value function with finite essential supremum is integrable. -/ theorem Integrable.smul_essSup {𝕜 : Type*} [NormedRing 𝕜] [Module 𝕜 β] [BoundedSMul 𝕜 β] {f : α → 𝕜} (hf : Integrable f μ) {g : α → β} (g_aestronglyMeasurable : AEStronglyMeasurable g μ) (ess_sup_g : essSup (fun x => (‖g x‖₊ : ℝ≥0∞)) μ ≠ ∞) : Integrable (fun x : α => f x • g x) μ := by rw [← memℒp_one_iff_integrable] at * refine ⟨hf.1.smul g_aestronglyMeasurable, ?_⟩ have h : (1 : ℝ≥0∞) / 1 = 1 / 1 + 1 / ∞ := by norm_num have hg' : snorm g ∞ μ ≠ ∞ := by rwa [snorm_exponent_top] calc snorm (fun x : α => f x • g x) 1 μ ≤ _ := by simpa using MeasureTheory.snorm_smul_le_mul_snorm g_aestronglyMeasurable hf.1 h _ < ∞ := ENNReal.mul_lt_top hf.2.ne hg' #align measure_theory.integrable.smul_ess_sup MeasureTheory.Integrable.smul_essSup theorem integrable_norm_iff {f : α → β} (hf : AEStronglyMeasurable f μ) : Integrable (fun a => ‖f a‖) μ ↔ Integrable f μ := by simp_rw [Integrable, and_iff_right hf, and_iff_right hf.norm, hasFiniteIntegral_norm_iff] #align measure_theory.integrable_norm_iff MeasureTheory.integrable_norm_iff theorem integrable_of_norm_sub_le {f₀ f₁ : α → β} {g : α → ℝ} (hf₁_m : AEStronglyMeasurable f₁ μ) (hf₀_i : Integrable f₀ μ) (hg_i : Integrable g μ) (h : ∀ᵐ a ∂μ, ‖f₀ a - f₁ a‖ ≤ g a) : Integrable f₁ μ := haveI : ∀ᵐ a ∂μ, ‖f₁ a‖ ≤ ‖f₀ a‖ + g a := by apply h.mono intro a ha calc ‖f₁ a‖ ≤ ‖f₀ a‖ + ‖f₀ a - f₁ a‖ := norm_le_insert _ _ _ ≤ ‖f₀ a‖ + g a := add_le_add_left ha _ Integrable.mono' (hf₀_i.norm.add hg_i) hf₁_m this #align measure_theory.integrable_of_norm_sub_le MeasureTheory.integrable_of_norm_sub_le theorem Integrable.prod_mk {f : α → β} {g : α → γ} (hf : Integrable f μ) (hg : Integrable g μ) : Integrable (fun x => (f x, g x)) μ := ⟨hf.aestronglyMeasurable.prod_mk hg.aestronglyMeasurable, (hf.norm.add' hg.norm).mono <| eventually_of_forall fun x => calc max ‖f x‖ ‖g x‖ ≤ ‖f x‖ + ‖g x‖ := max_le_add_of_nonneg (norm_nonneg _) (norm_nonneg _) _ ≤ ‖‖f x‖ + ‖g x‖‖ := le_abs_self _⟩ #align measure_theory.integrable.prod_mk MeasureTheory.Integrable.prod_mk theorem Memℒp.integrable {q : ℝ≥0∞} (hq1 : 1 ≤ q) {f : α → β} [IsFiniteMeasure μ] (hfq : Memℒp f q μ) : Integrable f μ := memℒp_one_iff_integrable.mp (hfq.memℒp_of_exponent_le hq1) #align measure_theory.mem_ℒp.integrable MeasureTheory.Memℒp.integrable /-- A non-quantitative version of Markov inequality for integrable functions: the measure of points where `‖f x‖ ≥ ε` is finite for all positive `ε`. -/
Mathlib/MeasureTheory/Function/L1Space.lean
859
869
theorem Integrable.measure_norm_ge_lt_top {f : α → β} (hf : Integrable f μ) {ε : ℝ} (hε : 0 < ε) : μ { x | ε ≤ ‖f x‖ } < ∞ := by
rw [show { x | ε ≤ ‖f x‖ } = { x | ENNReal.ofReal ε ≤ ‖f x‖₊ } by simp only [ENNReal.ofReal, Real.toNNReal_le_iff_le_coe, ENNReal.coe_le_coe, coe_nnnorm]] refine (meas_ge_le_mul_pow_snorm μ one_ne_zero ENNReal.one_ne_top hf.1 ?_).trans_lt ?_ · simpa only [Ne, ENNReal.ofReal_eq_zero, not_le] using hε apply ENNReal.mul_lt_top · simpa only [ENNReal.one_toReal, ENNReal.rpow_one, Ne, ENNReal.inv_eq_top, ENNReal.ofReal_eq_zero, not_le] using hε simpa only [ENNReal.one_toReal, ENNReal.rpow_one] using (memℒp_one_iff_integrable.2 hf).snorm_ne_top
/- Copyright (c) 2022 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.GroupTheory.Archimedean import Mathlib.Topology.Order.Basic #align_import topology.algebra.order.archimedean from "leanprover-community/mathlib"@"4c19a16e4b705bf135cf9a80ac18fcc99c438514" /-! # Topology on archimedean groups and fields In this file we prove the following theorems: - `Rat.denseRange_cast`: the coercion from `ℚ` to a linear ordered archimedean field has dense range; - `AddSubgroup.dense_of_not_isolated_zero`, `AddSubgroup.dense_of_no_min`: two sufficient conditions for a subgroup of an archimedean linear ordered additive commutative group to be dense; - `AddSubgroup.dense_or_cyclic`: an additive subgroup of an archimedean linear ordered additive commutative group `G` with order topology either is dense in `G` or is a cyclic subgroup. -/ open Set /-- Rational numbers are dense in a linear ordered archimedean field. -/ theorem Rat.denseRange_cast {𝕜} [LinearOrderedField 𝕜] [TopologicalSpace 𝕜] [OrderTopology 𝕜] [Archimedean 𝕜] : DenseRange ((↑) : ℚ → 𝕜) := dense_of_exists_between fun _ _ h => Set.exists_range_iff.2 <| exists_rat_btwn h #align rat.dense_range_cast Rat.denseRange_cast namespace AddSubgroup variable {G : Type*} [LinearOrderedAddCommGroup G] [TopologicalSpace G] [OrderTopology G] [Archimedean G] /-- An additive subgroup of an archimedean linear ordered additive commutative group with order topology is dense provided that for all positive `ε` there exists a positive element of the subgroup that is less than `ε`. -/ theorem dense_of_not_isolated_zero (S : AddSubgroup G) (hS : ∀ ε > 0, ∃ g ∈ S, g ∈ Ioo 0 ε) : Dense (S : Set G) := by cases subsingleton_or_nontrivial G · refine fun x => _root_.subset_closure ?_ rw [Subsingleton.elim x 0] exact zero_mem S refine dense_of_exists_between fun a b hlt => ?_ rcases hS (b - a) (sub_pos.2 hlt) with ⟨g, hgS, hg0, hg⟩ rcases (existsUnique_add_zsmul_mem_Ioc hg0 0 a).exists with ⟨m, hm⟩ rw [zero_add] at hm refine ⟨m • g, zsmul_mem hgS _, hm.1, hm.2.trans_lt ?_⟩ rwa [lt_sub_iff_add_lt'] at hg /-- Let `S` be a nontrivial additive subgroup in an archimedean linear ordered additive commutative group `G` with order topology. If the set of positive elements of `S` does not have a minimal element, then `S` is dense `G`. -/ theorem dense_of_no_min (S : AddSubgroup G) (hbot : S ≠ ⊥) (H : ¬∃ a : G, IsLeast { g : G | g ∈ S ∧ 0 < g } a) : Dense (S : Set G) := by refine S.dense_of_not_isolated_zero fun ε ε0 => ?_ contrapose! H exact exists_isLeast_pos hbot ε0 (disjoint_left.2 H) #align real.subgroup_dense_of_no_min AddSubgroup.dense_of_no_minₓ /-- An additive subgroup of an archimedean linear ordered additive commutative group `G` with order topology either is dense in `G` or is a cyclic subgroup. -/
Mathlib/Topology/Algebra/Order/Archimedean.lean
67
71
theorem dense_or_cyclic (S : AddSubgroup G) : Dense (S : Set G) ∨ ∃ a : G, S = closure {a} := by
refine (em _).imp (dense_of_not_isolated_zero S) fun h => ?_ push_neg at h rcases h with ⟨ε, ε0, hε⟩ exact cyclic_of_isolated_zero ε0 (disjoint_left.2 hε)
/- Copyright (c) 2022 Bhavik Mehta. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Bhavik Mehta, Yaël Dillies -/ import Mathlib.Analysis.Convex.Cone.Extension import Mathlib.Analysis.Convex.Gauge import Mathlib.Topology.Algebra.Module.FiniteDimension import Mathlib.Topology.Algebra.Module.LocallyConvex #align_import analysis.normed_space.hahn_banach.separation from "leanprover-community/mathlib"@"915591b2bb3ea303648db07284a161a7f2a9e3d4" /-! # Separation Hahn-Banach theorem In this file we prove the geometric Hahn-Banach theorem. For any two disjoint convex sets, there exists a continuous linear functional separating them, geometrically meaning that we can intercalate a plane between them. We provide many variations to stricten the result under more assumptions on the convex sets: * `geometric_hahn_banach_open`: One set is open. Weak separation. * `geometric_hahn_banach_open_point`, `geometric_hahn_banach_point_open`: One set is open, the other is a singleton. Weak separation. * `geometric_hahn_banach_open_open`: Both sets are open. Semistrict separation. * `geometric_hahn_banach_compact_closed`, `geometric_hahn_banach_closed_compact`: One set is closed, the other one is compact. Strict separation. * `geometric_hahn_banach_point_closed`, `geometric_hahn_banach_closed_point`: One set is closed, the other one is a singleton. Strict separation. * `geometric_hahn_banach_point_point`: Both sets are singletons. Strict separation. ## TODO * Eidelheit's theorem * `Convex ℝ s → interior (closure s) ⊆ s` -/ open Set open Pointwise variable {𝕜 E : Type*} /-- Given a set `s` which is a convex neighbourhood of `0` and a point `x₀` outside of it, there is a continuous linear functional `f` separating `x₀` and `s`, in the sense that it sends `x₀` to 1 and all of `s` to values strictly below `1`. -/ theorem separate_convex_open_set [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] {s : Set E} (hs₀ : (0 : E) ∈ s) (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) {x₀ : E} (hx₀ : x₀ ∉ s) : ∃ f : E →L[ℝ] ℝ, f x₀ = 1 ∧ ∀ x ∈ s, f x < 1 := by let f : E →ₗ.[ℝ] ℝ := LinearPMap.mkSpanSingleton x₀ 1 (ne_of_mem_of_not_mem hs₀ hx₀).symm have := exists_extension_of_le_sublinear f (gauge s) (fun c hc => gauge_smul_of_nonneg hc.le) (gauge_add_le hs₁ <| absorbent_nhds_zero <| hs₂.mem_nhds hs₀) ?_ · obtain ⟨φ, hφ₁, hφ₂⟩ := this have hφ₃ : φ x₀ = 1 := by rw [← f.domain.coe_mk x₀ (Submodule.mem_span_singleton_self _), hφ₁, LinearPMap.mkSpanSingleton'_apply_self] have hφ₄ : ∀ x ∈ s, φ x < 1 := fun x hx => (hφ₂ x).trans_lt (gauge_lt_one_of_mem_of_isOpen hs₂ hx) refine ⟨⟨φ, ?_⟩, hφ₃, hφ₄⟩ refine φ.continuous_of_nonzero_on_open _ (hs₂.vadd (-x₀)) (Nonempty.vadd_set ⟨0, hs₀⟩) (vadd_set_subset_iff.mpr fun x hx => ?_) change φ (-x₀ + x) ≠ 0 rw [map_add, map_neg] specialize hφ₄ x hx linarith rintro ⟨x, hx⟩ obtain ⟨y, rfl⟩ := Submodule.mem_span_singleton.1 hx rw [LinearPMap.mkSpanSingleton'_apply] simp only [mul_one, Algebra.id.smul_eq_mul, Submodule.coe_mk] obtain h | h := le_or_lt y 0 · exact h.trans (gauge_nonneg _) · rw [gauge_smul_of_nonneg h.le, smul_eq_mul, le_mul_iff_one_le_right h] exact one_le_gauge_of_not_mem (hs₁.starConvex hs₀) (absorbent_nhds_zero <| hs₂.mem_nhds hs₀).absorbs hx₀ #align separate_convex_open_set separate_convex_open_set variable [TopologicalSpace E] [AddCommGroup E] [TopologicalAddGroup E] [Module ℝ E] [ContinuousSMul ℝ E] {s t : Set E} {x y : E} /-- A version of the **Hahn-Banach theorem**: given disjoint convex sets `s`, `t` where `s` is open, there is a continuous linear functional which separates them. -/
Mathlib/Analysis/NormedSpace/HahnBanach/Separation.lean
84
112
theorem geometric_hahn_banach_open (hs₁ : Convex ℝ s) (hs₂ : IsOpen s) (ht : Convex ℝ t) (disj : Disjoint s t) : ∃ (f : E →L[ℝ] ℝ) (u : ℝ), (∀ a ∈ s, f a < u) ∧ ∀ b ∈ t, u ≤ f b := by
obtain rfl | ⟨a₀, ha₀⟩ := s.eq_empty_or_nonempty · exact ⟨0, 0, by simp, fun b _hb => le_rfl⟩ obtain rfl | ⟨b₀, hb₀⟩ := t.eq_empty_or_nonempty · exact ⟨0, 1, fun a _ha => zero_lt_one, by simp⟩ let x₀ := b₀ - a₀ let C := x₀ +ᵥ (s - t) have : (0 : E) ∈ C := ⟨a₀ - b₀, sub_mem_sub ha₀ hb₀, by simp_rw [x₀, vadd_eq_add, sub_add_sub_cancel', sub_self]⟩ have : Convex ℝ C := (hs₁.sub ht).vadd _ have : x₀ ∉ C := by intro hx₀ rw [← add_zero x₀] at hx₀ exact disj.zero_not_mem_sub_set (vadd_mem_vadd_set_iff.1 hx₀) obtain ⟨f, hf₁, hf₂⟩ := separate_convex_open_set ‹0 ∈ C› ‹_› (hs₂.sub_right.vadd _) ‹x₀ ∉ C› have : f b₀ = f a₀ + 1 := by simp [x₀, ← hf₁] have forall_le : ∀ a ∈ s, ∀ b ∈ t, f a ≤ f b := by intro a ha b hb have := hf₂ (x₀ + (a - b)) (vadd_mem_vadd_set <| sub_mem_sub ha hb) simp only [f.map_add, f.map_sub, hf₁] at this linarith refine ⟨f, sInf (f '' t), image_subset_iff.1 (?_ : f '' s ⊆ Iio (sInf (f '' t))), fun b hb => ?_⟩ · rw [← interior_Iic] refine interior_maximal (image_subset_iff.2 fun a ha => ?_) (f.isOpenMap_of_ne_zero ?_ _ hs₂) · exact le_csInf (Nonempty.image _ ⟨_, hb₀⟩) (forall_mem_image.2 <| forall_le _ ha) · rintro rfl simp at hf₁ · exact csInf_le ⟨f a₀, forall_mem_image.2 <| forall_le _ ha₀⟩ (mem_image_of_mem _ hb)
/- Copyright (c) 2021 Martin Zinkevich. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Martin Zinkevich, Rémy Degenne -/ import Mathlib.Logic.Encodable.Lattice import Mathlib.MeasureTheory.MeasurableSpace.Defs #align_import measure_theory.pi_system from "leanprover-community/mathlib"@"98e83c3d541c77cdb7da20d79611a780ff8e7d90" /-! # Induction principles for measurable sets, related to π-systems and λ-systems. ## Main statements * The main theorem of this file is Dynkin's π-λ theorem, which appears here as an induction principle `induction_on_inter`. Suppose `s` is a collection of subsets of `α` such that the intersection of two members of `s` belongs to `s` whenever it is nonempty. Let `m` be the σ-algebra generated by `s`. In order to check that a predicate `C` holds on every member of `m`, it suffices to check that `C` holds on the members of `s` and that `C` is preserved by complementation and *disjoint* countable unions. * The proof of this theorem relies on the notion of `IsPiSystem`, i.e., a collection of sets which is closed under binary non-empty intersections. Note that this is a small variation around the usual notion in the literature, which often requires that a π-system is non-empty, and closed also under disjoint intersections. This variation turns out to be convenient for the formalization. * The proof of Dynkin's π-λ theorem also requires the notion of `DynkinSystem`, i.e., a collection of sets which contains the empty set, is closed under complementation and under countable union of pairwise disjoint sets. The disjointness condition is the only difference with `σ`-algebras. * `generatePiSystem g` gives the minimal π-system containing `g`. This can be considered a Galois insertion into both measurable spaces and sets. * `generateFrom_generatePiSystem_eq` proves that if you start from a collection of sets `g`, take the generated π-system, and then the generated σ-algebra, you get the same result as the σ-algebra generated from `g`. This is useful because there are connections between independent sets that are π-systems and the generated independent spaces. * `mem_generatePiSystem_iUnion_elim` and `mem_generatePiSystem_iUnion_elim'` show that any element of the π-system generated from the union of a set of π-systems can be represented as the intersection of a finite number of elements from these sets. * `piiUnionInter` defines a new π-system from a family of π-systems `π : ι → Set (Set α)` and a set of indices `S : Set ι`. `piiUnionInter π S` is the set of sets that can be written as `⋂ x ∈ t, f x` for some finset `t ∈ S` and sets `f x ∈ π x`. ## Implementation details * `IsPiSystem` is a predicate, not a type. Thus, we don't explicitly define the galois insertion, nor do we define a complete lattice. In theory, we could define a complete lattice and galois insertion on the subtype corresponding to `IsPiSystem`. -/ open MeasurableSpace Set open scoped Classical open MeasureTheory /-- A π-system is a collection of subsets of `α` that is closed under binary intersection of non-disjoint sets. Usually it is also required that the collection is nonempty, but we don't do that here. -/ def IsPiSystem {α} (C : Set (Set α)) : Prop := ∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C #align is_pi_system IsPiSystem namespace MeasurableSpace theorem isPiSystem_measurableSet {α : Type*} [MeasurableSpace α] : IsPiSystem { s : Set α | MeasurableSet s } := fun _ hs _ ht _ => hs.inter ht #align measurable_space.is_pi_system_measurable_set MeasurableSpace.isPiSystem_measurableSet end MeasurableSpace theorem IsPiSystem.singleton {α} (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by intro s h_s t h_t _ rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self, Set.mem_singleton_iff] #align is_pi_system.singleton IsPiSystem.singleton
Mathlib/MeasureTheory/PiSystem.lean
85
92
theorem IsPiSystem.insert_empty {α} {S : Set (Set α)} (h_pi : IsPiSystem S) : IsPiSystem (insert ∅ S) := by
intro s hs t ht hst cases' hs with hs hs · simp [hs] · cases' ht with ht ht · simp [ht] · exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
/- Copyright (c) 2016 Jeremy Avigad. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Jeremy Avigad -/ import Mathlib.Algebra.Order.Ring.Abs #align_import data.int.order.lemmas from "leanprover-community/mathlib"@"fc2ed6f838ce7c9b7c7171e58d78eaf7b438fb0e" /-! # Further lemmas about the integers The distinction between this file and `Data.Int.Order.Basic` is not particularly clear. They are separated by now to minimize the porting requirements for tactics during the transition to mathlib4. Now that `Algebra.Order.Ring.Rat` has been ported, please feel free to reorganize these two files. -/ open Function Nat namespace Int /-! ### nat abs -/ variable {a b : ℤ} {n : ℕ} theorem natAbs_eq_iff_mul_self_eq {a b : ℤ} : a.natAbs = b.natAbs ↔ a * a = b * b := by rw [← abs_eq_iff_mul_self_eq, abs_eq_natAbs, abs_eq_natAbs] exact Int.natCast_inj.symm #align int.nat_abs_eq_iff_mul_self_eq Int.natAbs_eq_iff_mul_self_eq #align int.eq_nat_abs_iff_mul_eq_zero Int.eq_natAbs_iff_mul_eq_zero theorem natAbs_lt_iff_mul_self_lt {a b : ℤ} : a.natAbs < b.natAbs ↔ a * a < b * b := by rw [← abs_lt_iff_mul_self_lt, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_lt.symm #align int.nat_abs_lt_iff_mul_self_lt Int.natAbs_lt_iff_mul_self_lt theorem natAbs_le_iff_mul_self_le {a b : ℤ} : a.natAbs ≤ b.natAbs ↔ a * a ≤ b * b := by rw [← abs_le_iff_mul_self_le, abs_eq_natAbs, abs_eq_natAbs] exact Int.ofNat_le.symm #align int.nat_abs_le_iff_mul_self_le Int.natAbs_le_iff_mul_self_le theorem dvd_div_of_mul_dvd {a b c : ℤ} (h : a * b ∣ c) : b ∣ c / a := by rcases eq_or_ne a 0 with (rfl | ha) · simp only [Int.ediv_zero, Int.dvd_zero] rcases h with ⟨d, rfl⟩ refine ⟨d, ?_⟩ rw [mul_assoc, Int.mul_ediv_cancel_left _ ha] #align int.dvd_div_of_mul_dvd Int.dvd_div_of_mul_dvd lemma pow_right_injective (h : 1 < a.natAbs) : Injective ((a ^ ·) : ℕ → ℤ) := by refine (?_ : Injective (natAbs ∘ (a ^ · : ℕ → ℤ))).of_comp convert Nat.pow_right_injective h using 2 rw [Function.comp_apply, natAbs_pow] #align int.pow_right_injective Int.pow_right_injective /-! ### units -/
Mathlib/Data/Int/Order/Lemmas.lean
62
68
theorem eq_zero_of_abs_lt_dvd {m x : ℤ} (h1 : m ∣ x) (h2 : |x| < m) : x = 0 := by
obtain rfl | hm := eq_or_ne m 0 · exact Int.zero_dvd.1 h1 rcases h1 with ⟨d, rfl⟩ apply mul_eq_zero_of_right rw [← abs_lt_one_iff, ← mul_lt_iff_lt_one_right (abs_pos.mpr hm), ← abs_mul] exact lt_of_lt_of_le h2 (le_abs_self m)
/- Copyright (c) 2020 Yury G. Kudryashov. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Yury G. Kudryashov -/ import Mathlib.Algebra.GroupPower.IterateHom import Mathlib.Analysis.SpecificLimits.Basic import Mathlib.Order.Iterate import Mathlib.Order.SemiconjSup import Mathlib.Tactic.Monotonicity import Mathlib.Topology.Order.MonotoneContinuity #align_import dynamics.circle.rotation_number.translation_number from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982" /-! # Translation number of a monotone real map that commutes with `x ↦ x + 1` Let `f : ℝ → ℝ` be a monotone map such that `f (x + 1) = f x + 1` for all `x`. Then the limit $$ \tau(f)=\lim_{n\to\infty}{f^n(x)-x}{n} $$ exists and does not depend on `x`. This number is called the *translation number* of `f`. Different authors use different notation for this number: `τ`, `ρ`, `rot`, etc In this file we define a structure `CircleDeg1Lift` for bundled maps with these properties, define translation number of `f : CircleDeg1Lift`, prove some estimates relating `f^n(x)-x` to `τ(f)`. In case of a continuous map `f` we also prove that `f` admits a point `x` such that `f^n(x)=x+m` if and only if `τ(f)=m/n`. Maps of this type naturally appear as lifts of orientation preserving circle homeomorphisms. More precisely, let `f` be an orientation preserving homeomorphism of the circle $S^1=ℝ/ℤ$, and consider a real number `a` such that `⟦a⟧ = f 0`, where `⟦⟧` means the natural projection `ℝ → ℝ/ℤ`. Then there exists a unique continuous function `F : ℝ → ℝ` such that `F 0 = a` and `⟦F x⟧ = f ⟦x⟧` for all `x` (this fact is not formalized yet). This function is strictly monotone, continuous, and satisfies `F (x + 1) = F x + 1`. The number `⟦τ F⟧ : ℝ / ℤ` is called the *rotation number* of `f`. It does not depend on the choice of `a`. ## Main definitions * `CircleDeg1Lift`: a monotone map `f : ℝ → ℝ` such that `f (x + 1) = f x + 1` for all `x`; the type `CircleDeg1Lift` is equipped with `Lattice` and `Monoid` structures; the multiplication is given by composition: `(f * g) x = f (g x)`. * `CircleDeg1Lift.translationNumber`: translation number of `f : CircleDeg1Lift`. ## Main statements We prove the following properties of `CircleDeg1Lift.translationNumber`. * `CircleDeg1Lift.translationNumber_eq_of_dist_bounded`: if the distance between `(f^n) 0` and `(g^n) 0` is bounded from above uniformly in `n : ℕ`, then `f` and `g` have equal translation numbers. * `CircleDeg1Lift.translationNumber_eq_of_semiconjBy`: if two `CircleDeg1Lift` maps `f`, `g` are semiconjugate by a `CircleDeg1Lift` map, then `τ f = τ g`. * `CircleDeg1Lift.translationNumber_units_inv`: if `f` is an invertible `CircleDeg1Lift` map (equivalently, `f` is a lift of an orientation-preserving circle homeomorphism), then the translation number of `f⁻¹` is the negative of the translation number of `f`. * `CircleDeg1Lift.translationNumber_mul_of_commute`: if `f` and `g` commute, then `τ (f * g) = τ f + τ g`. * `CircleDeg1Lift.translationNumber_eq_rat_iff`: the translation number of `f` is equal to a rational number `m / n` if and only if `(f^n) x = x + m` for some `x`. * `CircleDeg1Lift.semiconj_of_bijective_of_translationNumber_eq`: if `f` and `g` are two bijective `CircleDeg1Lift` maps and their translation numbers are equal, then these maps are semiconjugate to each other. * `CircleDeg1Lift.semiconj_of_group_action_of_forall_translationNumber_eq`: let `f₁` and `f₂` be two actions of a group `G` on the circle by degree 1 maps (formally, `f₁` and `f₂` are two homomorphisms from `G →* CircleDeg1Lift`). If the translation numbers of `f₁ g` and `f₂ g` are equal to each other for all `g : G`, then these two actions are semiconjugate by some `F : CircleDeg1Lift`. This is a version of Proposition 5.4 from [Étienne Ghys, Groupes d'homeomorphismes du cercle et cohomologie bornee][ghys87:groupes]. ## Notation We use a local notation `τ` for the translation number of `f : CircleDeg1Lift`. ## Implementation notes We define the translation number of `f : CircleDeg1Lift` to be the limit of the sequence `(f ^ (2 ^ n)) 0 / (2 ^ n)`, then prove that `((f ^ n) x - x) / n` tends to this number for any `x`. This way it is much easier to prove that the limit exists and basic properties of the limit. We define translation number for a wider class of maps `f : ℝ → ℝ` instead of lifts of orientation preserving circle homeomorphisms for two reasons: * non-strictly monotone circle self-maps with discontinuities naturally appear as Poincaré maps for some flows on the two-torus (e.g., one can take a constant flow and glue in a few Cherry cells); * definition and some basic properties still work for this class. ## References * [Étienne Ghys, Groupes d'homeomorphismes du cercle et cohomologie bornee][ghys87:groupes] ## TODO Here are some short-term goals. * Introduce a structure or a typeclass for lifts of circle homeomorphisms. We use `Units CircleDeg1Lift` for now, but it's better to have a dedicated type (or a typeclass?). * Prove that the `SemiconjBy` relation on circle homeomorphisms is an equivalence relation. * Introduce `ConditionallyCompleteLattice` structure, use it in the proof of `CircleDeg1Lift.semiconj_of_group_action_of_forall_translationNumber_eq`. * Prove that the orbits of the irrational rotation are dense in the circle. Deduce that a homeomorphism with an irrational rotation is semiconjugate to the corresponding irrational translation by a continuous `CircleDeg1Lift`. ## Tags circle homeomorphism, rotation number -/ open scoped Classical open Filter Set Int Topology open Function hiding Commute /-! ### Definition and monoid structure -/ /-- A lift of a monotone degree one map `S¹ → S¹`. -/ structure CircleDeg1Lift extends ℝ →o ℝ : Type where map_add_one' : ∀ x, toFun (x + 1) = toFun x + 1 #align circle_deg1_lift CircleDeg1Lift namespace CircleDeg1Lift instance : FunLike CircleDeg1Lift ℝ ℝ where coe f := f.toFun coe_injective' | ⟨⟨_, _⟩, _⟩, ⟨⟨_, _⟩, _⟩, rfl => rfl instance : OrderHomClass CircleDeg1Lift ℝ ℝ where map_rel f _ _ h := f.monotone' h @[simp] theorem coe_mk (f h) : ⇑(mk f h) = f := rfl #align circle_deg1_lift.coe_mk CircleDeg1Lift.coe_mk variable (f g : CircleDeg1Lift) @[simp] theorem coe_toOrderHom : ⇑f.toOrderHom = f := rfl protected theorem monotone : Monotone f := f.monotone' #align circle_deg1_lift.monotone CircleDeg1Lift.monotone @[mono] theorem mono {x y} (h : x ≤ y) : f x ≤ f y := f.monotone h #align circle_deg1_lift.mono CircleDeg1Lift.mono theorem strictMono_iff_injective : StrictMono f ↔ Injective f := f.monotone.strictMono_iff_injective #align circle_deg1_lift.strict_mono_iff_injective CircleDeg1Lift.strictMono_iff_injective @[simp] theorem map_add_one : ∀ x, f (x + 1) = f x + 1 := f.map_add_one' #align circle_deg1_lift.map_add_one CircleDeg1Lift.map_add_one @[simp] theorem map_one_add (x : ℝ) : f (1 + x) = 1 + f x := by rw [add_comm, map_add_one, add_comm 1] #align circle_deg1_lift.map_one_add CircleDeg1Lift.map_one_add #noalign circle_deg1_lift.coe_inj -- Use `DFunLike.coe_inj` @[ext] theorem ext ⦃f g : CircleDeg1Lift⦄ (h : ∀ x, f x = g x) : f = g := DFunLike.ext f g h #align circle_deg1_lift.ext CircleDeg1Lift.ext theorem ext_iff {f g : CircleDeg1Lift} : f = g ↔ ∀ x, f x = g x := DFunLike.ext_iff #align circle_deg1_lift.ext_iff CircleDeg1Lift.ext_iff instance : Monoid CircleDeg1Lift where mul f g := { toOrderHom := f.1.comp g.1 map_add_one' := fun x => by simp [map_add_one] } one := ⟨.id, fun _ => rfl⟩ mul_one f := rfl one_mul f := rfl mul_assoc f₁ f₂ f₃ := DFunLike.coe_injective rfl instance : Inhabited CircleDeg1Lift := ⟨1⟩ @[simp] theorem coe_mul : ⇑(f * g) = f ∘ g := rfl #align circle_deg1_lift.coe_mul CircleDeg1Lift.coe_mul theorem mul_apply (x) : (f * g) x = f (g x) := rfl #align circle_deg1_lift.mul_apply CircleDeg1Lift.mul_apply @[simp] theorem coe_one : ⇑(1 : CircleDeg1Lift) = id := rfl #align circle_deg1_lift.coe_one CircleDeg1Lift.coe_one instance unitsHasCoeToFun : CoeFun CircleDeg1Liftˣ fun _ => ℝ → ℝ := ⟨fun f => ⇑(f : CircleDeg1Lift)⟩ #align circle_deg1_lift.units_has_coe_to_fun CircleDeg1Lift.unitsHasCoeToFun #noalign circle_deg1_lift.units_coe -- now LHS = RHS @[simp] theorem units_inv_apply_apply (f : CircleDeg1Liftˣ) (x : ℝ) : (f⁻¹ : CircleDeg1Liftˣ) (f x) = x := by simp only [← mul_apply, f.inv_mul, coe_one, id] #align circle_deg1_lift.units_inv_apply_apply CircleDeg1Lift.units_inv_apply_apply @[simp] theorem units_apply_inv_apply (f : CircleDeg1Liftˣ) (x : ℝ) : f ((f⁻¹ : CircleDeg1Liftˣ) x) = x := by simp only [← mul_apply, f.mul_inv, coe_one, id] #align circle_deg1_lift.units_apply_inv_apply CircleDeg1Lift.units_apply_inv_apply /-- If a lift of a circle map is bijective, then it is an order automorphism of the line. -/ def toOrderIso : CircleDeg1Liftˣ →* ℝ ≃o ℝ where toFun f := { toFun := f invFun := ⇑f⁻¹ left_inv := units_inv_apply_apply f right_inv := units_apply_inv_apply f map_rel_iff' := ⟨fun h => by simpa using mono (↑f⁻¹) h, mono f⟩ } map_one' := rfl map_mul' f g := rfl #align circle_deg1_lift.to_order_iso CircleDeg1Lift.toOrderIso @[simp] theorem coe_toOrderIso (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f) = f := rfl #align circle_deg1_lift.coe_to_order_iso CircleDeg1Lift.coe_toOrderIso @[simp] theorem coe_toOrderIso_symm (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f).symm = (f⁻¹ : CircleDeg1Liftˣ) := rfl #align circle_deg1_lift.coe_to_order_iso_symm CircleDeg1Lift.coe_toOrderIso_symm @[simp] theorem coe_toOrderIso_inv (f : CircleDeg1Liftˣ) : ⇑(toOrderIso f)⁻¹ = (f⁻¹ : CircleDeg1Liftˣ) := rfl #align circle_deg1_lift.coe_to_order_iso_inv CircleDeg1Lift.coe_toOrderIso_inv theorem isUnit_iff_bijective {f : CircleDeg1Lift} : IsUnit f ↔ Bijective f := ⟨fun ⟨u, h⟩ => h ▸ (toOrderIso u).bijective, fun h => Units.isUnit { val := f inv := { toFun := (Equiv.ofBijective f h).symm monotone' := fun x y hxy => (f.strictMono_iff_injective.2 h.1).le_iff_le.1 (by simp only [Equiv.ofBijective_apply_symm_apply f h, hxy]) map_add_one' := fun x => h.1 <| by simp only [Equiv.ofBijective_apply_symm_apply f, f.map_add_one] } val_inv := ext <| Equiv.ofBijective_apply_symm_apply f h inv_val := ext <| Equiv.ofBijective_symm_apply_apply f h }⟩ #align circle_deg1_lift.is_unit_iff_bijective CircleDeg1Lift.isUnit_iff_bijective theorem coe_pow : ∀ n : ℕ, ⇑(f ^ n) = f^[n] | 0 => rfl | n + 1 => by ext x simp [coe_pow n, pow_succ] #align circle_deg1_lift.coe_pow CircleDeg1Lift.coe_pow theorem semiconjBy_iff_semiconj {f g₁ g₂ : CircleDeg1Lift} : SemiconjBy f g₁ g₂ ↔ Semiconj f g₁ g₂ := ext_iff #align circle_deg1_lift.semiconj_by_iff_semiconj CircleDeg1Lift.semiconjBy_iff_semiconj theorem commute_iff_commute {f g : CircleDeg1Lift} : Commute f g ↔ Function.Commute f g := ext_iff #align circle_deg1_lift.commute_iff_commute CircleDeg1Lift.commute_iff_commute /-! ### Translate by a constant -/ /-- The map `y ↦ x + y` as a `CircleDeg1Lift`. More precisely, we define a homomorphism from `Multiplicative ℝ` to `CircleDeg1Liftˣ`, so the translation by `x` is `translation (Multiplicative.ofAdd x)`. -/ def translate : Multiplicative ℝ →* CircleDeg1Liftˣ := MonoidHom.toHomUnits <| { toFun := fun x => ⟨⟨fun y => Multiplicative.toAdd x + y, fun _ _ h => add_le_add_left h _⟩, fun _ => (add_assoc _ _ _).symm⟩ map_one' := ext <| zero_add map_mul' := fun _ _ => ext <| add_assoc _ _ } #align circle_deg1_lift.translate CircleDeg1Lift.translate @[simp] theorem translate_apply (x y : ℝ) : translate (Multiplicative.ofAdd x) y = x + y := rfl #align circle_deg1_lift.translate_apply CircleDeg1Lift.translate_apply @[simp] theorem translate_inv_apply (x y : ℝ) : (translate <| Multiplicative.ofAdd x)⁻¹ y = -x + y := rfl #align circle_deg1_lift.translate_inv_apply CircleDeg1Lift.translate_inv_apply @[simp] theorem translate_zpow (x : ℝ) (n : ℤ) : translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := by simp only [← zsmul_eq_mul, ofAdd_zsmul, MonoidHom.map_zpow] #align circle_deg1_lift.translate_zpow CircleDeg1Lift.translate_zpow @[simp] theorem translate_pow (x : ℝ) (n : ℕ) : translate (Multiplicative.ofAdd x) ^ n = translate (Multiplicative.ofAdd <| ↑n * x) := translate_zpow x n #align circle_deg1_lift.translate_pow CircleDeg1Lift.translate_pow @[simp] theorem translate_iterate (x : ℝ) (n : ℕ) : (translate (Multiplicative.ofAdd x))^[n] = translate (Multiplicative.ofAdd <| ↑n * x) := by rw [← coe_pow, ← Units.val_pow_eq_pow_val, translate_pow] #align circle_deg1_lift.translate_iterate CircleDeg1Lift.translate_iterate /-! ### Commutativity with integer translations In this section we prove that `f` commutes with translations by an integer number. First we formulate these statements (for a natural or an integer number, addition on the left or on the right, addition or subtraction) using `Function.Commute`, then reformulate as `simp` lemmas `map_int_add` etc. -/ theorem commute_nat_add (n : ℕ) : Function.Commute f (n + ·) := by simpa only [nsmul_one, add_left_iterate] using Function.Commute.iterate_right f.map_one_add n #align circle_deg1_lift.commute_nat_add CircleDeg1Lift.commute_nat_add theorem commute_add_nat (n : ℕ) : Function.Commute f (· + n) := by simp only [add_comm _ (n : ℝ), f.commute_nat_add n] #align circle_deg1_lift.commute_add_nat CircleDeg1Lift.commute_add_nat theorem commute_sub_nat (n : ℕ) : Function.Commute f (· - n) := by simpa only [sub_eq_add_neg] using (f.commute_add_nat n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv #align circle_deg1_lift.commute_sub_nat CircleDeg1Lift.commute_sub_nat theorem commute_add_int : ∀ n : ℤ, Function.Commute f (· + n) | (n : ℕ) => f.commute_add_nat n | -[n+1] => by simpa [sub_eq_add_neg] using f.commute_sub_nat (n + 1) #align circle_deg1_lift.commute_add_int CircleDeg1Lift.commute_add_int theorem commute_int_add (n : ℤ) : Function.Commute f (n + ·) := by simpa only [add_comm _ (n : ℝ)] using f.commute_add_int n #align circle_deg1_lift.commute_int_add CircleDeg1Lift.commute_int_add theorem commute_sub_int (n : ℤ) : Function.Commute f (· - n) := by simpa only [sub_eq_add_neg] using (f.commute_add_int n).inverses_right (Equiv.addRight _).right_inv (Equiv.addRight _).left_inv #align circle_deg1_lift.commute_sub_int CircleDeg1Lift.commute_sub_int @[simp] theorem map_int_add (m : ℤ) (x : ℝ) : f (m + x) = m + f x := f.commute_int_add m x #align circle_deg1_lift.map_int_add CircleDeg1Lift.map_int_add @[simp] theorem map_add_int (x : ℝ) (m : ℤ) : f (x + m) = f x + m := f.commute_add_int m x #align circle_deg1_lift.map_add_int CircleDeg1Lift.map_add_int @[simp] theorem map_sub_int (x : ℝ) (n : ℤ) : f (x - n) = f x - n := f.commute_sub_int n x #align circle_deg1_lift.map_sub_int CircleDeg1Lift.map_sub_int @[simp] theorem map_add_nat (x : ℝ) (n : ℕ) : f (x + n) = f x + n := f.map_add_int x n #align circle_deg1_lift.map_add_nat CircleDeg1Lift.map_add_nat @[simp] theorem map_nat_add (n : ℕ) (x : ℝ) : f (n + x) = n + f x := f.map_int_add n x #align circle_deg1_lift.map_nat_add CircleDeg1Lift.map_nat_add @[simp] theorem map_sub_nat (x : ℝ) (n : ℕ) : f (x - n) = f x - n := f.map_sub_int x n #align circle_deg1_lift.map_sub_nat CircleDeg1Lift.map_sub_nat theorem map_int_of_map_zero (n : ℤ) : f n = f 0 + n := by rw [← f.map_add_int, zero_add] #align circle_deg1_lift.map_int_of_map_zero CircleDeg1Lift.map_int_of_map_zero @[simp] theorem map_fract_sub_fract_eq (x : ℝ) : f (fract x) - fract x = f x - x := by rw [Int.fract, f.map_sub_int, sub_sub_sub_cancel_right] #align circle_deg1_lift.map_fract_sub_fract_eq CircleDeg1Lift.map_fract_sub_fract_eq /-! ### Pointwise order on circle maps -/ /-- Monotone circle maps form a lattice with respect to the pointwise order -/ noncomputable instance : Lattice CircleDeg1Lift where sup f g := { toFun := fun x => max (f x) (g x) monotone' := fun x y h => max_le_max (f.mono h) (g.mono h) -- TODO: generalize to `Monotone.max` map_add_one' := fun x => by simp [max_add_add_right] } le f g := ∀ x, f x ≤ g x le_refl f x := le_refl (f x) le_trans f₁ f₂ f₃ h₁₂ h₂₃ x := le_trans (h₁₂ x) (h₂₃ x) le_antisymm f₁ f₂ h₁₂ h₂₁ := ext fun x => le_antisymm (h₁₂ x) (h₂₁ x) le_sup_left f g x := le_max_left (f x) (g x) le_sup_right f g x := le_max_right (f x) (g x) sup_le f₁ f₂ f₃ h₁ h₂ x := max_le (h₁ x) (h₂ x) inf f g := { toFun := fun x => min (f x) (g x) monotone' := fun x y h => min_le_min (f.mono h) (g.mono h) map_add_one' := fun x => by simp [min_add_add_right] } inf_le_left f g x := min_le_left (f x) (g x) inf_le_right f g x := min_le_right (f x) (g x) le_inf f₁ f₂ f₃ h₂ h₃ x := le_min (h₂ x) (h₃ x) @[simp] theorem sup_apply (x : ℝ) : (f ⊔ g) x = max (f x) (g x) := rfl #align circle_deg1_lift.sup_apply CircleDeg1Lift.sup_apply @[simp] theorem inf_apply (x : ℝ) : (f ⊓ g) x = min (f x) (g x) := rfl #align circle_deg1_lift.inf_apply CircleDeg1Lift.inf_apply theorem iterate_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f^[n] := fun f _ h => f.monotone.iterate_le_of_le h _ #align circle_deg1_lift.iterate_monotone CircleDeg1Lift.iterate_monotone theorem iterate_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f^[n] ≤ g^[n] := iterate_monotone n h #align circle_deg1_lift.iterate_mono CircleDeg1Lift.iterate_mono theorem pow_mono {f g : CircleDeg1Lift} (h : f ≤ g) (n : ℕ) : f ^ n ≤ g ^ n := fun x => by simp only [coe_pow, iterate_mono h n x] #align circle_deg1_lift.pow_mono CircleDeg1Lift.pow_mono theorem pow_monotone (n : ℕ) : Monotone fun f : CircleDeg1Lift => f ^ n := fun _ _ h => pow_mono h n #align circle_deg1_lift.pow_monotone CircleDeg1Lift.pow_monotone /-! ### Estimates on `(f * g) 0` We prove the estimates `f 0 + ⌊g 0⌋ ≤ f (g 0) ≤ f 0 + ⌈g 0⌉` and some corollaries with added/removed floors and ceils. We also prove that for two semiconjugate maps `g₁`, `g₂`, the distance between `g₁ 0` and `g₂ 0` is less than two. -/ theorem map_le_of_map_zero (x : ℝ) : f x ≤ f 0 + ⌈x⌉ := calc f x ≤ f ⌈x⌉ := f.monotone <| le_ceil _ _ = f 0 + ⌈x⌉ := f.map_int_of_map_zero _ #align circle_deg1_lift.map_le_of_map_zero CircleDeg1Lift.map_le_of_map_zero theorem map_map_zero_le : f (g 0) ≤ f 0 + ⌈g 0⌉ := f.map_le_of_map_zero (g 0) #align circle_deg1_lift.map_map_zero_le CircleDeg1Lift.map_map_zero_le theorem floor_map_map_zero_le : ⌊f (g 0)⌋ ≤ ⌊f 0⌋ + ⌈g 0⌉ := calc ⌊f (g 0)⌋ ≤ ⌊f 0 + ⌈g 0⌉⌋ := floor_mono <| f.map_map_zero_le g _ = ⌊f 0⌋ + ⌈g 0⌉ := floor_add_int _ _ #align circle_deg1_lift.floor_map_map_zero_le CircleDeg1Lift.floor_map_map_zero_le theorem ceil_map_map_zero_le : ⌈f (g 0)⌉ ≤ ⌈f 0⌉ + ⌈g 0⌉ := calc ⌈f (g 0)⌉ ≤ ⌈f 0 + ⌈g 0⌉⌉ := ceil_mono <| f.map_map_zero_le g _ = ⌈f 0⌉ + ⌈g 0⌉ := ceil_add_int _ _ #align circle_deg1_lift.ceil_map_map_zero_le CircleDeg1Lift.ceil_map_map_zero_le theorem map_map_zero_lt : f (g 0) < f 0 + g 0 + 1 := calc f (g 0) ≤ f 0 + ⌈g 0⌉ := f.map_map_zero_le g _ < f 0 + (g 0 + 1) := add_lt_add_left (ceil_lt_add_one _) _ _ = f 0 + g 0 + 1 := (add_assoc _ _ _).symm #align circle_deg1_lift.map_map_zero_lt CircleDeg1Lift.map_map_zero_lt theorem le_map_of_map_zero (x : ℝ) : f 0 + ⌊x⌋ ≤ f x := calc f 0 + ⌊x⌋ = f ⌊x⌋ := (f.map_int_of_map_zero _).symm _ ≤ f x := f.monotone <| floor_le _ #align circle_deg1_lift.le_map_of_map_zero CircleDeg1Lift.le_map_of_map_zero theorem le_map_map_zero : f 0 + ⌊g 0⌋ ≤ f (g 0) := f.le_map_of_map_zero (g 0) #align circle_deg1_lift.le_map_map_zero CircleDeg1Lift.le_map_map_zero theorem le_floor_map_map_zero : ⌊f 0⌋ + ⌊g 0⌋ ≤ ⌊f (g 0)⌋ := calc ⌊f 0⌋ + ⌊g 0⌋ = ⌊f 0 + ⌊g 0⌋⌋ := (floor_add_int _ _).symm _ ≤ ⌊f (g 0)⌋ := floor_mono <| f.le_map_map_zero g #align circle_deg1_lift.le_floor_map_map_zero CircleDeg1Lift.le_floor_map_map_zero theorem le_ceil_map_map_zero : ⌈f 0⌉ + ⌊g 0⌋ ≤ ⌈(f * g) 0⌉ := calc ⌈f 0⌉ + ⌊g 0⌋ = ⌈f 0 + ⌊g 0⌋⌉ := (ceil_add_int _ _).symm _ ≤ ⌈f (g 0)⌉ := ceil_mono <| f.le_map_map_zero g #align circle_deg1_lift.le_ceil_map_map_zero CircleDeg1Lift.le_ceil_map_map_zero theorem lt_map_map_zero : f 0 + g 0 - 1 < f (g 0) := calc f 0 + g 0 - 1 = f 0 + (g 0 - 1) := add_sub_assoc _ _ _ _ < f 0 + ⌊g 0⌋ := add_lt_add_left (sub_one_lt_floor _) _ _ ≤ f (g 0) := f.le_map_map_zero g #align circle_deg1_lift.lt_map_map_zero CircleDeg1Lift.lt_map_map_zero theorem dist_map_map_zero_lt : dist (f 0 + g 0) (f (g 0)) < 1 := by rw [dist_comm, Real.dist_eq, abs_lt, lt_sub_iff_add_lt', sub_lt_iff_lt_add', ← sub_eq_add_neg] exact ⟨f.lt_map_map_zero g, f.map_map_zero_lt g⟩ #align circle_deg1_lift.dist_map_map_zero_lt CircleDeg1Lift.dist_map_map_zero_lt theorem dist_map_zero_lt_of_semiconj {f g₁ g₂ : CircleDeg1Lift} (h : Function.Semiconj f g₁ g₂) : dist (g₁ 0) (g₂ 0) < 2 := calc dist (g₁ 0) (g₂ 0) ≤ dist (g₁ 0) (f (g₁ 0) - f 0) + dist _ (g₂ 0) := dist_triangle _ _ _ _ = dist (f 0 + g₁ 0) (f (g₁ 0)) + dist (g₂ 0 + f 0) (g₂ (f 0)) := by simp only [h.eq, Real.dist_eq, sub_sub, add_comm (f 0), sub_sub_eq_add_sub, abs_sub_comm (g₂ (f 0))] _ < 1 + 1 := add_lt_add (f.dist_map_map_zero_lt g₁) (g₂.dist_map_map_zero_lt f) _ = 2 := one_add_one_eq_two #align circle_deg1_lift.dist_map_zero_lt_of_semiconj CircleDeg1Lift.dist_map_zero_lt_of_semiconj theorem dist_map_zero_lt_of_semiconjBy {f g₁ g₂ : CircleDeg1Lift} (h : SemiconjBy f g₁ g₂) : dist (g₁ 0) (g₂ 0) < 2 := dist_map_zero_lt_of_semiconj <| semiconjBy_iff_semiconj.1 h #align circle_deg1_lift.dist_map_zero_lt_of_semiconj_by CircleDeg1Lift.dist_map_zero_lt_of_semiconjBy /-! ### Limits at infinities and continuity -/ protected theorem tendsto_atBot : Tendsto f atBot atBot := tendsto_atBot_mono f.map_le_of_map_zero <| tendsto_atBot_add_const_left _ _ <| (tendsto_atBot_mono fun x => (ceil_lt_add_one x).le) <| tendsto_atBot_add_const_right _ _ tendsto_id #align circle_deg1_lift.tendsto_at_bot CircleDeg1Lift.tendsto_atBot protected theorem tendsto_atTop : Tendsto f atTop atTop := tendsto_atTop_mono f.le_map_of_map_zero <| tendsto_atTop_add_const_left _ _ <| (tendsto_atTop_mono fun x => (sub_one_lt_floor x).le) <| by simpa [sub_eq_add_neg] using tendsto_atTop_add_const_right _ _ tendsto_id #align circle_deg1_lift.tendsto_at_top CircleDeg1Lift.tendsto_atTop theorem continuous_iff_surjective : Continuous f ↔ Function.Surjective f := ⟨fun h => h.surjective f.tendsto_atTop f.tendsto_atBot, f.monotone.continuous_of_surjective⟩ #align circle_deg1_lift.continuous_iff_surjective CircleDeg1Lift.continuous_iff_surjective /-! ### Estimates on `(f^n) x` If we know that `f x` is `≤`/`<`/`≥`/`>`/`=` to `x + m`, then we have a similar estimate on `f^[n] x` and `x + n * m`. For `≤`, `≥`, and `=` we formulate both `of` (implication) and `iff` versions because implications work for `n = 0`. For `<` and `>` we formulate only `iff` versions. -/ theorem iterate_le_of_map_le_add_int {x : ℝ} {m : ℤ} (h : f x ≤ x + m) (n : ℕ) : f^[n] x ≤ x + n * m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_le_of_map_le f.monotone (monotone_id.add_const (m : ℝ)) h n #align circle_deg1_lift.iterate_le_of_map_le_add_int CircleDeg1Lift.iterate_le_of_map_le_add_int theorem le_iterate_of_add_int_le_map {x : ℝ} {m : ℤ} (h : x + m ≤ f x) (n : ℕ) : x + n * m ≤ f^[n] x := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).symm.iterate_le_of_map_le (monotone_id.add_const (m : ℝ)) f.monotone h n #align circle_deg1_lift.le_iterate_of_add_int_le_map CircleDeg1Lift.le_iterate_of_add_int_le_map theorem iterate_eq_of_map_eq_add_int {x : ℝ} {m : ℤ} (h : f x = x + m) (n : ℕ) : f^[n] x = x + n * m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_eq_of_map_eq n h #align circle_deg1_lift.iterate_eq_of_map_eq_add_int CircleDeg1Lift.iterate_eq_of_map_eq_add_int theorem iterate_pos_le_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) : f^[n] x ≤ x + n * m ↔ f x ≤ x + m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_le_iff_map_le f.monotone (strictMono_id.add_const (m : ℝ)) hn #align circle_deg1_lift.iterate_pos_le_iff CircleDeg1Lift.iterate_pos_le_iff theorem iterate_pos_lt_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) : f^[n] x < x + n * m ↔ f x < x + m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_lt_iff_map_lt f.monotone (strictMono_id.add_const (m : ℝ)) hn #align circle_deg1_lift.iterate_pos_lt_iff CircleDeg1Lift.iterate_pos_lt_iff theorem iterate_pos_eq_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) : f^[n] x = x + n * m ↔ f x = x + m := by simpa only [nsmul_eq_mul, add_right_iterate] using (f.commute_add_int m).iterate_pos_eq_iff_map_eq f.monotone (strictMono_id.add_const (m : ℝ)) hn #align circle_deg1_lift.iterate_pos_eq_iff CircleDeg1Lift.iterate_pos_eq_iff theorem le_iterate_pos_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) : x + n * m ≤ f^[n] x ↔ x + m ≤ f x := by simpa only [not_lt] using not_congr (f.iterate_pos_lt_iff hn) #align circle_deg1_lift.le_iterate_pos_iff CircleDeg1Lift.le_iterate_pos_iff theorem lt_iterate_pos_iff {x : ℝ} {m : ℤ} {n : ℕ} (hn : 0 < n) : x + n * m < f^[n] x ↔ x + m < f x := by simpa only [not_le] using not_congr (f.iterate_pos_le_iff hn) #align circle_deg1_lift.lt_iterate_pos_iff CircleDeg1Lift.lt_iterate_pos_iff theorem mul_floor_map_zero_le_floor_iterate_zero (n : ℕ) : ↑n * ⌊f 0⌋ ≤ ⌊f^[n] 0⌋ := by rw [le_floor, Int.cast_mul, Int.cast_natCast, ← zero_add ((n : ℝ) * _)] apply le_iterate_of_add_int_le_map simp [floor_le] #align circle_deg1_lift.mul_floor_map_zero_le_floor_iterate_zero CircleDeg1Lift.mul_floor_map_zero_le_floor_iterate_zero /-! ### Definition of translation number -/ noncomputable section /-- An auxiliary sequence used to define the translation number. -/ def transnumAuxSeq (n : ℕ) : ℝ := (f ^ (2 ^ n : ℕ)) 0 / 2 ^ n #align circle_deg1_lift.transnum_aux_seq CircleDeg1Lift.transnumAuxSeq /-- The translation number of a `CircleDeg1Lift`, $τ(f)=\lim_{n→∞}\frac{f^n(x)-x}{n}$. We use an auxiliary sequence `\frac{f^{2^n}(0)}{2^n}` to define `τ(f)` because some proofs are simpler this way. -/ def translationNumber : ℝ := limUnder atTop f.transnumAuxSeq #align circle_deg1_lift.translation_number CircleDeg1Lift.translationNumber end -- TODO: choose two different symbols for `CircleDeg1Lift.translationNumber` and the future -- `circle_mono_homeo.rotation_number`, then make them `localized notation`s local notation "τ" => translationNumber theorem transnumAuxSeq_def : f.transnumAuxSeq = fun n : ℕ => (f ^ (2 ^ n : ℕ)) 0 / 2 ^ n := rfl #align circle_deg1_lift.transnum_aux_seq_def CircleDeg1Lift.transnumAuxSeq_def theorem translationNumber_eq_of_tendsto_aux {τ' : ℝ} (h : Tendsto f.transnumAuxSeq atTop (𝓝 τ')) : τ f = τ' := h.limUnder_eq #align circle_deg1_lift.translation_number_eq_of_tendsto_aux CircleDeg1Lift.translationNumber_eq_of_tendsto_aux theorem translationNumber_eq_of_tendsto₀ {τ' : ℝ} (h : Tendsto (fun n : ℕ => f^[n] 0 / n) atTop (𝓝 τ')) : τ f = τ' := f.translationNumber_eq_of_tendsto_aux <| by simpa [(· ∘ ·), transnumAuxSeq_def, coe_pow] using h.comp (Nat.tendsto_pow_atTop_atTop_of_one_lt one_lt_two) #align circle_deg1_lift.translation_number_eq_of_tendsto₀ CircleDeg1Lift.translationNumber_eq_of_tendsto₀ theorem translationNumber_eq_of_tendsto₀' {τ' : ℝ} (h : Tendsto (fun n : ℕ => f^[n + 1] 0 / (n + 1)) atTop (𝓝 τ')) : τ f = τ' := f.translationNumber_eq_of_tendsto₀ <| (tendsto_add_atTop_iff_nat 1).1 (mod_cast h) #align circle_deg1_lift.translation_number_eq_of_tendsto₀' CircleDeg1Lift.translationNumber_eq_of_tendsto₀' theorem transnumAuxSeq_zero : f.transnumAuxSeq 0 = f 0 := by simp [transnumAuxSeq] #align circle_deg1_lift.transnum_aux_seq_zero CircleDeg1Lift.transnumAuxSeq_zero theorem transnumAuxSeq_dist_lt (n : ℕ) : dist (f.transnumAuxSeq n) (f.transnumAuxSeq (n + 1)) < 1 / 2 / 2 ^ n := by have : 0 < (2 ^ (n + 1) : ℝ) := pow_pos zero_lt_two _ rw [div_div, ← pow_succ', ← abs_of_pos this] replace := abs_pos.2 (ne_of_gt this) convert (div_lt_div_right this).2 ((f ^ 2 ^ n).dist_map_map_zero_lt (f ^ 2 ^ n)) using 1 simp_rw [transnumAuxSeq, Real.dist_eq] rw [← abs_div, sub_div, pow_succ, pow_succ', ← two_mul, mul_div_mul_left _ _ (two_ne_zero' ℝ), pow_mul, sq, mul_apply] #align circle_deg1_lift.transnum_aux_seq_dist_lt CircleDeg1Lift.transnumAuxSeq_dist_lt theorem tendsto_translationNumber_aux : Tendsto f.transnumAuxSeq atTop (𝓝 <| τ f) := (cauchySeq_of_le_geometric_two 1 fun n => le_of_lt <| f.transnumAuxSeq_dist_lt n).tendsto_limUnder #align circle_deg1_lift.tendsto_translation_number_aux CircleDeg1Lift.tendsto_translationNumber_aux theorem dist_map_zero_translationNumber_le : dist (f 0) (τ f) ≤ 1 := f.transnumAuxSeq_zero ▸ dist_le_of_le_geometric_two_of_tendsto₀ 1 (fun n => le_of_lt <| f.transnumAuxSeq_dist_lt n) f.tendsto_translationNumber_aux #align circle_deg1_lift.dist_map_zero_translation_number_le CircleDeg1Lift.dist_map_zero_translationNumber_le theorem tendsto_translationNumber_of_dist_bounded_aux (x : ℕ → ℝ) (C : ℝ) (H : ∀ n : ℕ, dist ((f ^ n) 0) (x n) ≤ C) : Tendsto (fun n : ℕ => x (2 ^ n) / 2 ^ n) atTop (𝓝 <| τ f) := by apply f.tendsto_translationNumber_aux.congr_dist (squeeze_zero (fun _ => dist_nonneg) _ _) · exact fun n => C / 2 ^ n · intro n have : 0 < (2 ^ n : ℝ) := pow_pos zero_lt_two _ convert (div_le_div_right this).2 (H (2 ^ n)) using 1 rw [transnumAuxSeq, Real.dist_eq, ← sub_div, abs_div, abs_of_pos this, Real.dist_eq] · exact mul_zero C ▸ tendsto_const_nhds.mul <| tendsto_inv_atTop_zero.comp <| tendsto_pow_atTop_atTop_of_one_lt one_lt_two #align circle_deg1_lift.tendsto_translation_number_of_dist_bounded_aux CircleDeg1Lift.tendsto_translationNumber_of_dist_bounded_aux theorem translationNumber_eq_of_dist_bounded {f g : CircleDeg1Lift} (C : ℝ) (H : ∀ n : ℕ, dist ((f ^ n) 0) ((g ^ n) 0) ≤ C) : τ f = τ g := Eq.symm <| g.translationNumber_eq_of_tendsto_aux <| f.tendsto_translationNumber_of_dist_bounded_aux _ C H #align circle_deg1_lift.translation_number_eq_of_dist_bounded CircleDeg1Lift.translationNumber_eq_of_dist_bounded @[simp] theorem translationNumber_one : τ 1 = 0 := translationNumber_eq_of_tendsto₀ _ <| by simp [tendsto_const_nhds] #align circle_deg1_lift.translation_number_one CircleDeg1Lift.translationNumber_one theorem translationNumber_eq_of_semiconjBy {f g₁ g₂ : CircleDeg1Lift} (H : SemiconjBy f g₁ g₂) : τ g₁ = τ g₂ := translationNumber_eq_of_dist_bounded 2 fun n => le_of_lt <| dist_map_zero_lt_of_semiconjBy <| H.pow_right n #align circle_deg1_lift.translation_number_eq_of_semiconj_by CircleDeg1Lift.translationNumber_eq_of_semiconjBy theorem translationNumber_eq_of_semiconj {f g₁ g₂ : CircleDeg1Lift} (H : Function.Semiconj f g₁ g₂) : τ g₁ = τ g₂ := translationNumber_eq_of_semiconjBy <| semiconjBy_iff_semiconj.2 H #align circle_deg1_lift.translation_number_eq_of_semiconj CircleDeg1Lift.translationNumber_eq_of_semiconj theorem translationNumber_mul_of_commute {f g : CircleDeg1Lift} (h : Commute f g) : τ (f * g) = τ f + τ g := by refine tendsto_nhds_unique ?_ (f.tendsto_translationNumber_aux.add g.tendsto_translationNumber_aux) simp only [transnumAuxSeq, ← add_div] refine (f * g).tendsto_translationNumber_of_dist_bounded_aux (fun n ↦ (f ^ n) 0 + (g ^ n) 0) 1 fun n ↦ ?_ rw [h.mul_pow, dist_comm] exact le_of_lt ((f ^ n).dist_map_map_zero_lt (g ^ n)) #align circle_deg1_lift.translation_number_mul_of_commute CircleDeg1Lift.translationNumber_mul_of_commute @[simp] theorem translationNumber_units_inv (f : CircleDeg1Liftˣ) : τ ↑f⁻¹ = -τ f := eq_neg_iff_add_eq_zero.2 <| by simp [← translationNumber_mul_of_commute (Commute.refl _).units_inv_left] #align circle_deg1_lift.translation_number_units_inv CircleDeg1Lift.translationNumber_units_inv @[simp] theorem translationNumber_pow : ∀ n : ℕ, τ (f ^ n) = n * τ f | 0 => by simp | n + 1 => by rw [pow_succ, translationNumber_mul_of_commute (Commute.pow_self f n), translationNumber_pow n, Nat.cast_add_one, add_mul, one_mul] #align circle_deg1_lift.translation_number_pow CircleDeg1Lift.translationNumber_pow @[simp] theorem translationNumber_zpow (f : CircleDeg1Liftˣ) : ∀ n : ℤ, τ (f ^ n : Units _) = n * τ f | (n : ℕ) => by simp [translationNumber_pow f n] | -[n+1] => by simp; ring #align circle_deg1_lift.translation_number_zpow CircleDeg1Lift.translationNumber_zpow @[simp] theorem translationNumber_conj_eq (f : CircleDeg1Liftˣ) (g : CircleDeg1Lift) : τ (↑f * g * ↑f⁻¹) = τ g := (translationNumber_eq_of_semiconjBy (f.mk_semiconjBy g)).symm #align circle_deg1_lift.translation_number_conj_eq CircleDeg1Lift.translationNumber_conj_eq @[simp] theorem translationNumber_conj_eq' (f : CircleDeg1Liftˣ) (g : CircleDeg1Lift) : τ (↑f⁻¹ * g * f) = τ g := translationNumber_conj_eq f⁻¹ g #align circle_deg1_lift.translation_number_conj_eq' CircleDeg1Lift.translationNumber_conj_eq' theorem dist_pow_map_zero_mul_translationNumber_le (n : ℕ) : dist ((f ^ n) 0) (n * f.translationNumber) ≤ 1 := f.translationNumber_pow n ▸ (f ^ n).dist_map_zero_translationNumber_le #align circle_deg1_lift.dist_pow_map_zero_mul_translation_number_le CircleDeg1Lift.dist_pow_map_zero_mul_translationNumber_le theorem tendsto_translation_number₀' : Tendsto (fun n : ℕ => (f ^ (n + 1) : CircleDeg1Lift) 0 / ((n : ℝ) + 1)) atTop (𝓝 <| τ f) := by refine tendsto_iff_dist_tendsto_zero.2 <| squeeze_zero (fun _ => dist_nonneg) (fun n => ?_) ((tendsto_const_div_atTop_nhds_zero_nat 1).comp (tendsto_add_atTop_nat 1)) dsimp have : (0 : ℝ) < n + 1 := n.cast_add_one_pos rw [Real.dist_eq, div_sub' _ _ _ (ne_of_gt this), abs_div, ← Real.dist_eq, abs_of_pos this, Nat.cast_add_one, div_le_div_right this, ← Nat.cast_add_one] apply dist_pow_map_zero_mul_translationNumber_le #align circle_deg1_lift.tendsto_translation_number₀' CircleDeg1Lift.tendsto_translation_number₀' theorem tendsto_translation_number₀ : Tendsto (fun n : ℕ => (f ^ n) 0 / n) atTop (𝓝 <| τ f) := (tendsto_add_atTop_iff_nat 1).1 (mod_cast f.tendsto_translation_number₀') #align circle_deg1_lift.tendsto_translation_number₀ CircleDeg1Lift.tendsto_translation_number₀ /-- For any `x : ℝ` the sequence $\frac{f^n(x)-x}{n}$ tends to the translation number of `f`. In particular, this limit does not depend on `x`. -/
Mathlib/Dynamics/Circle/RotationNumber/TranslationNumber.lean
793
797
theorem tendsto_translationNumber (x : ℝ) : Tendsto (fun n : ℕ => ((f ^ n) x - x) / n) atTop (𝓝 <| τ f) := by
rw [← translationNumber_conj_eq' (translate <| Multiplicative.ofAdd x)] refine (tendsto_translation_number₀ _).congr fun n ↦ ?_ simp [sub_eq_neg_add, Units.conj_pow']
/- Copyright (c) 2021 Kexing Ying. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Kexing Ying -/ import Mathlib.MeasureTheory.Decomposition.SignedHahn import Mathlib.MeasureTheory.Measure.MutuallySingular #align_import measure_theory.decomposition.jordan from "leanprover-community/mathlib"@"70a4f2197832bceab57d7f41379b2592d1110570" /-! # Jordan decomposition This file proves the existence and uniqueness of the Jordan decomposition for signed measures. The Jordan decomposition theorem states that, given a signed measure `s`, there exists a unique pair of mutually singular measures `μ` and `ν`, such that `s = μ - ν`. The Jordan decomposition theorem for measures is a corollary of the Hahn decomposition theorem and is useful for the Lebesgue decomposition theorem. ## Main definitions * `MeasureTheory.JordanDecomposition`: a Jordan decomposition of a measurable space is a pair of mutually singular finite measures. We say `j` is a Jordan decomposition of a signed measure `s` if `s = j.posPart - j.negPart`. * `MeasureTheory.SignedMeasure.toJordanDecomposition`: the Jordan decomposition of a signed measure. * `MeasureTheory.SignedMeasure.toJordanDecompositionEquiv`: is the `Equiv` between `MeasureTheory.SignedMeasure` and `MeasureTheory.JordanDecomposition` formed by `MeasureTheory.SignedMeasure.toJordanDecomposition`. ## Main results * `MeasureTheory.SignedMeasure.toSignedMeasure_toJordanDecomposition` : the Jordan decomposition theorem. * `MeasureTheory.JordanDecomposition.toSignedMeasure_injective` : the Jordan decomposition of a signed measure is unique. ## Tags Jordan decomposition theorem -/ noncomputable section open scoped Classical MeasureTheory ENNReal NNReal variable {α β : Type*} [MeasurableSpace α] namespace MeasureTheory /-- A Jordan decomposition of a measurable space is a pair of mutually singular, finite measures. -/ @[ext] structure JordanDecomposition (α : Type*) [MeasurableSpace α] where (posPart negPart : Measure α) [posPart_finite : IsFiniteMeasure posPart] [negPart_finite : IsFiniteMeasure negPart] mutuallySingular : posPart ⟂ₘ negPart #align measure_theory.jordan_decomposition MeasureTheory.JordanDecomposition #align measure_theory.jordan_decomposition.pos_part MeasureTheory.JordanDecomposition.posPart #align measure_theory.jordan_decomposition.neg_part MeasureTheory.JordanDecomposition.negPart #align measure_theory.jordan_decomposition.pos_part_finite MeasureTheory.JordanDecomposition.posPart_finite #align measure_theory.jordan_decomposition.neg_part_finite MeasureTheory.JordanDecomposition.negPart_finite #align measure_theory.jordan_decomposition.mutually_singular MeasureTheory.JordanDecomposition.mutuallySingular attribute [instance] JordanDecomposition.posPart_finite attribute [instance] JordanDecomposition.negPart_finite namespace JordanDecomposition open Measure VectorMeasure variable (j : JordanDecomposition α) instance instZero : Zero (JordanDecomposition α) where zero := ⟨0, 0, MutuallySingular.zero_right⟩ #align measure_theory.jordan_decomposition.has_zero MeasureTheory.JordanDecomposition.instZero instance instInhabited : Inhabited (JordanDecomposition α) where default := 0 #align measure_theory.jordan_decomposition.inhabited MeasureTheory.JordanDecomposition.instInhabited instance instInvolutiveNeg : InvolutiveNeg (JordanDecomposition α) where neg j := ⟨j.negPart, j.posPart, j.mutuallySingular.symm⟩ neg_neg _ := JordanDecomposition.ext _ _ rfl rfl #align measure_theory.jordan_decomposition.has_involutive_neg MeasureTheory.JordanDecomposition.instInvolutiveNeg instance instSMul : SMul ℝ≥0 (JordanDecomposition α) where smul r j := ⟨r • j.posPart, r • j.negPart, MutuallySingular.smul _ (MutuallySingular.smul _ j.mutuallySingular.symm).symm⟩ #align measure_theory.jordan_decomposition.has_smul MeasureTheory.JordanDecomposition.instSMul instance instSMulReal : SMul ℝ (JordanDecomposition α) where smul r j := if 0 ≤ r then r.toNNReal • j else -((-r).toNNReal • j) #align measure_theory.jordan_decomposition.has_smul_real MeasureTheory.JordanDecomposition.instSMulReal @[simp] theorem zero_posPart : (0 : JordanDecomposition α).posPart = 0 := rfl #align measure_theory.jordan_decomposition.zero_pos_part MeasureTheory.JordanDecomposition.zero_posPart @[simp] theorem zero_negPart : (0 : JordanDecomposition α).negPart = 0 := rfl #align measure_theory.jordan_decomposition.zero_neg_part MeasureTheory.JordanDecomposition.zero_negPart @[simp] theorem neg_posPart : (-j).posPart = j.negPart := rfl #align measure_theory.jordan_decomposition.neg_pos_part MeasureTheory.JordanDecomposition.neg_posPart @[simp] theorem neg_negPart : (-j).negPart = j.posPart := rfl #align measure_theory.jordan_decomposition.neg_neg_part MeasureTheory.JordanDecomposition.neg_negPart @[simp] theorem smul_posPart (r : ℝ≥0) : (r • j).posPart = r • j.posPart := rfl #align measure_theory.jordan_decomposition.smul_pos_part MeasureTheory.JordanDecomposition.smul_posPart @[simp] theorem smul_negPart (r : ℝ≥0) : (r • j).negPart = r • j.negPart := rfl #align measure_theory.jordan_decomposition.smul_neg_part MeasureTheory.JordanDecomposition.smul_negPart theorem real_smul_def (r : ℝ) (j : JordanDecomposition α) : r • j = if 0 ≤ r then r.toNNReal • j else -((-r).toNNReal • j) := rfl #align measure_theory.jordan_decomposition.real_smul_def MeasureTheory.JordanDecomposition.real_smul_def @[simp]
Mathlib/MeasureTheory/Decomposition/Jordan.lean
135
137
theorem coe_smul (r : ℝ≥0) : (r : ℝ) • j = r • j := by
-- Porting note: replaced `show` rw [real_smul_def, if_pos (NNReal.coe_nonneg r), Real.toNNReal_coe]
/- Copyright (c) 2018 Mario Carneiro. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Mario Carneiro, Johannes Hölzl -/ import Mathlib.Dynamics.Ergodic.MeasurePreserving import Mathlib.MeasureTheory.Function.SimpleFunc import Mathlib.MeasureTheory.Measure.MutuallySingular import Mathlib.MeasureTheory.Measure.Count import Mathlib.Topology.IndicatorConstPointwise import Mathlib.MeasureTheory.Constructions.BorelSpace.Real #align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520" /-! # Lower Lebesgue integral for `ℝ≥0∞`-valued functions We define the lower Lebesgue integral of an `ℝ≥0∞`-valued function. ## Notation We introduce the following notation for the lower Lebesgue integral of a function `f : α → ℝ≥0∞`. * `∫⁻ x, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` with respect to a measure `μ`; * `∫⁻ x, f x`: integral of a function `f : α → ℝ≥0∞` with respect to the canonical measure `volume` on `α`; * `∫⁻ x in s, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect to a measure `μ`, defined as `∫⁻ x, f x ∂(μ.restrict s)`; * `∫⁻ x in s, f x`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect to the canonical measure `volume`, defined as `∫⁻ x, f x ∂(volume.restrict s)`. -/ assert_not_exists NormedSpace set_option autoImplicit true noncomputable section open Set hiding restrict restrict_apply open Filter ENNReal open Function (support) open scoped Classical open Topology NNReal ENNReal MeasureTheory namespace MeasureTheory local infixr:25 " →ₛ " => SimpleFunc variable {α β γ δ : Type*} section Lintegral open SimpleFunc variable {m : MeasurableSpace α} {μ ν : Measure α} /-- The **lower Lebesgue integral** of a function `f` with respect to a measure `μ`. -/ irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ := ⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ #align measure_theory.lintegral MeasureTheory.lintegral /-! In the notation for integrals, an expression like `∫⁻ x, g ‖x‖ ∂μ` will not be parsed correctly, and needs parentheses. We do not set the binding power of `r` to `0`, because then `∫⁻ x, f x = 0` will be parsed incorrectly. -/ @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r @[inherit_doc MeasureTheory.lintegral] notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r @[inherit_doc MeasureTheory.lintegral] notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = f.lintegral μ := by rw [MeasureTheory.lintegral] exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl) (le_iSup₂_of_le f le_rfl le_rfl) #align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral @[mono] theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by rw [lintegral, lintegral] exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩ #align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono' -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) : lintegral μ f ≤ lintegral ν g := lintegral_mono' h2 hfg theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono' (le_refl μ) hfg #align measure_theory.lintegral_mono MeasureTheory.lintegral_mono -- workaround for the known eta-reduction issue with `@[gcongr]` @[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) : lintegral μ f ≤ lintegral μ g := lintegral_mono hfg theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a) #align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) : ⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by apply le_antisymm · exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i · rw [lintegral] refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_ exact le_of_eq (i.lintegral_eq_lintegral _).symm #align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞} (hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ := lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f) #align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set' theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) := lintegral_mono #align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral @[simp] theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const] rfl #align measure_theory.lintegral_const MeasureTheory.lintegral_const theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp #align measure_theory.lintegral_zero MeasureTheory.lintegral_zero theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 := lintegral_zero #align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun -- @[simp] -- Porting note (#10618): simp can prove this theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul] #align measure_theory.lintegral_one MeasureTheory.lintegral_one theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by rw [lintegral_const, Measure.restrict_apply_univ] #align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul] #align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _ in s, c ∂μ < ∞ := by rw [lintegral_const] exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ) #align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc #align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top section variable (μ) /-- For any function `f : α → ℝ≥0∞`, there exists a measurable function `g ≤ f` with the same integral. -/ theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) : ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀ · exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩ rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩ have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by intro n simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using (hLf n).2 choose g hgm hgf hLg using this refine ⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩ · refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_ exact le_iSup (fun n => g n x) n · exact lintegral_mono fun x => iSup_le fun n => hgf n x #align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq end /-- `∫⁻ a in s, f a ∂μ` is defined as the supremum of integrals of simple functions `φ : α →ₛ ℝ≥0∞` such that `φ ≤ f`. This lemma says that it suffices to take functions `φ : α →ₛ ℝ≥0`. -/ theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) : ∫⁻ a, f a ∂μ = ⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by rw [lintegral] refine le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩) by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞ · let ψ := φ.map ENNReal.toNNReal replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x) exact le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h)) · have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_) obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb) use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞}) simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const, ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast, restrict_const_lintegral] refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩ simp only [mem_preimage, mem_singleton_iff] at hx simp only [hx, le_top] #align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ φ : α →ₛ ℝ≥0, (∀ x, ↑(φ x) ≤ f x) ∧ ∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by rw [lintegral_eq_nnreal] at h have := ENNReal.lt_add_right h hε erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩] simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩ refine ⟨φ, hle, fun ψ hψ => ?_⟩ have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle) rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ norm_cast simp only [add_apply, sub_apply, add_tsub_eq_max] rfl #align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) : ⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by simp only [← iSup_apply] exact (monotone_lintegral μ).le_map_iSup #align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by convert (monotone_lintegral μ).le_map_iSup₂ f with a simp only [iSup_apply] #align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) : ∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by simp only [← iInf_apply] exact (monotone_lintegral μ).map_iInf_le #align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) : ∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by convert (monotone_lintegral μ).map_iInf₂_le f with a simp only [iInf_apply] #align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩ have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0 rw [lintegral, lintegral] refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_ · intro a by_cases h : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true, indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem] exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg)) · refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_) by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true, not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem] exact (hnt hat).elim #align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg #align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae hf hg (ae_of_all _ hfg) #align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s) (hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ := set_lintegral_mono_ae' hs (ae_of_all _ hfg) theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ := lintegral_mono' Measure.restrict_le_self le_rfl theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le) #align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by simp only [h] #align measure_theory.lintegral_congr MeasureTheory.lintegral_congr theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h] #align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s) (hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by rw [lintegral_congr_ae] rw [EventuallyEq] rwa [ae_restrict_iff' hs] #align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) : ∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by simp_rw [← ofReal_norm_eq_coe_nnnorm] refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_ rw [Real.norm_eq_abs] exact le_abs_self (f x) #align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by apply lintegral_congr_ae filter_upwards [h_nonneg] with x hx rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx] #align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) : ∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg) #align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg /-- **Monotone convergence theorem** -- sometimes called **Beppo-Levi convergence**. See `lintegral_iSup_directed` for a more general form. -/ theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by set c : ℝ≥0 → ℝ≥0∞ := (↑) set F := fun a : α => ⨆ n, f n a refine le_antisymm ?_ (iSup_lintegral_le _) rw [lintegral_eq_nnreal] refine iSup_le fun s => iSup_le fun hsf => ?_ refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_ rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩ have ha : r < 1 := ENNReal.coe_lt_coe.1 ha let rs := s.map fun a => r * a have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by intro p rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})] refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_ by_cases p_eq : p = 0 · simp [p_eq] simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx subst hx have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero] have : s x ≠ 0 := right_ne_zero_of_mul this have : (rs.map c) x < ⨆ n : ℕ, f n x := by refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x) suffices r * s x < 1 * s x by simpa exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this) rcases lt_iSup_iff.1 this with ⟨i, hi⟩ exact mem_iUnion.2 ⟨i, le_of_lt hi⟩ have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by intro r i j h refine inter_subset_inter_right _ ?_ simp_rw [subset_def, mem_setOf] intro x hx exact le_trans hx (h_mono h x) have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n => measurableSet_le (SimpleFunc.measurable _) (hf n) calc (r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral] _ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by simp only [(eq _).symm] _ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := (Finset.sum_congr rfl fun x _ => by rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup]) _ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_ gcongr _ * μ ?_ exact mono p h _ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by gcongr with n rw [restrict_lintegral _ (h_meas n)] refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_) congr 2 with a refine and_congr_right ?_ simp (config := { contextual := true }) _ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [← SimpleFunc.lintegral_eq_lintegral] gcongr with n a simp only [map_apply] at h_meas simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)] exact indicator_apply_le id #align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup /-- Monotone convergence theorem -- sometimes called Beppo-Levi convergence. Version with ae_measurable functions. -/ theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp_rw [← iSup_apply] let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f' have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono have h_ae_seq_mono : Monotone (aeSeq hf p) := by intro n m hnm x by_cases hx : x ∈ aeSeqSet hf p · exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm · simp only [aeSeq, hx, if_false, le_rfl] rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm] simp_rw [iSup_apply] rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono] congr with n exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n) #align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup' /-- Monotone convergence theorem expressed with limits -/ theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) : Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij => lintegral_mono_ae (h_mono.mono fun x hx => hx hij) suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by rw [key] exact tendsto_atTop_iSup this rw [← lintegral_iSup' hf h_mono] refine lintegral_congr_ae ?_ filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono) #align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ := calc ∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by congr; ext a; rw [iSup_eapprox_apply f hf] _ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by apply lintegral_iSup · measurability · intro i j h exact monotone_eapprox f h _ = ⨆ n, (eapprox f n).lintegral μ := by congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral] #align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral /-- If `f` has finite integral, then `∫⁻ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. This lemma states this fact in terms of `ε` and `δ`. -/ theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞} (hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩ rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩ rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩ rcases φ.exists_forall_le with ⟨C, hC⟩ use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩ refine fun s hs => lt_of_le_of_lt ?_ hε₂ε simp only [lintegral_eq_nnreal, iSup_le_iff] intro ψ hψ calc (map (↑) ψ).lintegral (μ.restrict s) ≤ (map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add] refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add, SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)] _ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by gcongr refine le_trans ?_ (hφ _ hψ).le exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self _ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by gcongr exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl _ = C * μ s + ε₁ := by simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const, Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const] _ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr _ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le _ = ε₂ := tsub_add_cancel_of_le hε₁₂.le #align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt /-- If `f` has finite integral, then `∫⁻ x in s, f x ∂μ` is absolutely continuous in `s`: it tends to zero as `μ s` tends to zero. -/ theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι} {s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) : Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio, ← pos_iff_ne_zero] at hl ⊢ intro ε ε0 rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩ exact (hl δ δ0).mono fun i => hδ _ #align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero /-- The sum of the lower Lebesgue integrals of two functions is less than or equal to the integral of their sum. The other inequality needs one of these functions to be (a.e.-)measurable. -/ theorem le_lintegral_add (f g : α → ℝ≥0∞) : ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by simp only [lintegral] refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f) (q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_ exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge #align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add -- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by simp only [iSup_eapprox_apply, hf, hg] _ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by congr; funext a rw [ENNReal.iSup_add_iSup_of_monotone] · simp only [Pi.add_apply] · intro i j h exact monotone_eapprox _ h a · intro i j h exact monotone_eapprox _ h a _ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral] simp only [Pi.add_apply, SimpleFunc.coe_add] · measurability · intro i j h a dsimp gcongr <;> exact monotone_eapprox _ h _ _ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;> · intro i j h exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl _ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg] #align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux /-- If `f g : α → ℝ≥0∞` are two functions and one of them is (a.e.) measurable, then the Lebesgue integral of `f + g` equals the sum of integrals. This lemma assumes that `f` is integrable, see also `MeasureTheory.lintegral_add_right` and primed versions of these lemmas. -/ @[simp] theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by refine le_antisymm ?_ (le_lintegral_add _ _) rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩ calc ∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq _ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub _ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf) _ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _ #align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk, lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))] #align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left' theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by simpa only [add_comm] using lintegral_add_left' hg f #align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right' /-- If `f g : α → ℝ≥0∞` are two functions and one of them is (a.e.) measurable, then the Lebesgue integral of `f + g` equals the sum of integrals. This lemma assumes that `g` is integrable, see also `MeasureTheory.lintegral_add_left` and primed versions of these lemmas. -/ @[simp] theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) : ∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := lintegral_add_right' f hg.aemeasurable #align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right @[simp] theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul] #align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by rw [Measure.restrict_smul, lintegral_smul_measure] @[simp] theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum] rw [iSup_comm] congr; funext s induction' s using Finset.induction_on with i s hi hs · simp simp only [Finset.sum_insert hi, ← hs] refine (ENNReal.iSup_add_iSup ?_).symm intro φ ψ exact ⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩, add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl) (Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩ #align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) : HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) := (lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum #align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure @[simp] theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) : ∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν #align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure @[simp] theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞) (μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype'] simp only [Finset.coe_sort_coe] #align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure @[simp] theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂(0 : Measure α) = 0 := by simp [lintegral] #align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure @[simp] theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) : ∫⁻ x, f x ∂μ = 0 := by have : Subsingleton (Measure α) := inferInstance convert lintegral_zero_measure f theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by rw [Measure.restrict_empty, lintegral_zero_measure] #align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by rw [Measure.restrict_univ] #align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) : ∫⁻ x in s, f x ∂μ = 0 := by convert lintegral_zero_measure _ exact Measure.restrict_eq_zero.2 hs' #align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero theorem lintegral_finset_sum' (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, AEMeasurable (f b) μ) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := by induction' s using Finset.induction_on with a s has ih · simp · simp only [Finset.sum_insert has] rw [Finset.forall_mem_insert] at hf rw [lintegral_add_left' hf.1, ih hf.2] #align measure_theory.lintegral_finset_sum' MeasureTheory.lintegral_finset_sum' theorem lintegral_finset_sum (s : Finset β) {f : β → α → ℝ≥0∞} (hf : ∀ b ∈ s, Measurable (f b)) : ∫⁻ a, ∑ b ∈ s, f b a ∂μ = ∑ b ∈ s, ∫⁻ a, f b a ∂μ := lintegral_finset_sum' s fun b hb => (hf b hb).aemeasurable #align measure_theory.lintegral_finset_sum MeasureTheory.lintegral_finset_sum @[simp] theorem lintegral_const_mul (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := calc ∫⁻ a, r * f a ∂μ = ∫⁻ a, ⨆ n, (const α r * eapprox f n) a ∂μ := by congr funext a rw [← iSup_eapprox_apply f hf, ENNReal.mul_iSup] simp _ = ⨆ n, r * (eapprox f n).lintegral μ := by rw [lintegral_iSup] · congr funext n rw [← SimpleFunc.const_mul_lintegral, ← SimpleFunc.lintegral_eq_lintegral] · intro n exact SimpleFunc.measurable _ · intro i j h a exact mul_le_mul_left' (monotone_eapprox _ h _) _ _ = r * ∫⁻ a, f a ∂μ := by rw [← ENNReal.mul_iSup, lintegral_eq_iSup_eapprox_lintegral hf] #align measure_theory.lintegral_const_mul MeasureTheory.lintegral_const_mul theorem lintegral_const_mul'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by have A : ∫⁻ a, f a ∂μ = ∫⁻ a, hf.mk f a ∂μ := lintegral_congr_ae hf.ae_eq_mk have B : ∫⁻ a, r * f a ∂μ = ∫⁻ a, r * hf.mk f a ∂μ := lintegral_congr_ae (EventuallyEq.fun_comp hf.ae_eq_mk _) rw [A, B, lintegral_const_mul _ hf.measurable_mk] #align measure_theory.lintegral_const_mul'' MeasureTheory.lintegral_const_mul'' theorem lintegral_const_mul_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) : r * ∫⁻ a, f a ∂μ ≤ ∫⁻ a, r * f a ∂μ := by rw [lintegral, ENNReal.mul_iSup] refine iSup_le fun s => ?_ rw [ENNReal.mul_iSup, iSup_le_iff] intro hs rw [← SimpleFunc.const_mul_lintegral, lintegral] refine le_iSup_of_le (const α r * s) (le_iSup_of_le (fun x => ?_) le_rfl) exact mul_le_mul_left' (hs x) _ #align measure_theory.lintegral_const_mul_le MeasureTheory.lintegral_const_mul_le theorem lintegral_const_mul' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) : ∫⁻ a, r * f a ∂μ = r * ∫⁻ a, f a ∂μ := by by_cases h : r = 0 · simp [h] apply le_antisymm _ (lintegral_const_mul_le r f) have rinv : r * r⁻¹ = 1 := ENNReal.mul_inv_cancel h hr have rinv' : r⁻¹ * r = 1 := by rw [mul_comm] exact rinv have := lintegral_const_mul_le (μ := μ) r⁻¹ fun x => r * f x simp? [(mul_assoc _ _ _).symm, rinv'] at this says simp only [(mul_assoc _ _ _).symm, rinv', one_mul] at this simpa [(mul_assoc _ _ _).symm, rinv] using mul_le_mul_left' this r #align measure_theory.lintegral_const_mul' MeasureTheory.lintegral_const_mul' theorem lintegral_mul_const (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul r hf] #align measure_theory.lintegral_mul_const MeasureTheory.lintegral_mul_const theorem lintegral_mul_const'' (r : ℝ≥0∞) {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul'' r hf] #align measure_theory.lintegral_mul_const'' MeasureTheory.lintegral_mul_const'' theorem lintegral_mul_const_le (r : ℝ≥0∞) (f : α → ℝ≥0∞) : (∫⁻ a, f a ∂μ) * r ≤ ∫⁻ a, f a * r ∂μ := by simp_rw [mul_comm, lintegral_const_mul_le r f] #align measure_theory.lintegral_mul_const_le MeasureTheory.lintegral_mul_const_le theorem lintegral_mul_const' (r : ℝ≥0∞) (f : α → ℝ≥0∞) (hr : r ≠ ∞) : ∫⁻ a, f a * r ∂μ = (∫⁻ a, f a ∂μ) * r := by simp_rw [mul_comm, lintegral_const_mul' r f hr] #align measure_theory.lintegral_mul_const' MeasureTheory.lintegral_mul_const' /- A double integral of a product where each factor contains only one variable is a product of integrals -/ theorem lintegral_lintegral_mul {β} [MeasurableSpace β] {ν : Measure β} {f : α → ℝ≥0∞} {g : β → ℝ≥0∞} (hf : AEMeasurable f μ) (hg : AEMeasurable g ν) : ∫⁻ x, ∫⁻ y, f x * g y ∂ν ∂μ = (∫⁻ x, f x ∂μ) * ∫⁻ y, g y ∂ν := by simp [lintegral_const_mul'' _ hg, lintegral_mul_const'' _ hf] #align measure_theory.lintegral_lintegral_mul MeasureTheory.lintegral_lintegral_mul -- TODO: Need a better way of rewriting inside of an integral theorem lintegral_rw₁ {f f' : α → β} (h : f =ᵐ[μ] f') (g : β → ℝ≥0∞) : ∫⁻ a, g (f a) ∂μ = ∫⁻ a, g (f' a) ∂μ := lintegral_congr_ae <| h.mono fun a h => by dsimp only; rw [h] #align measure_theory.lintegral_rw₁ MeasureTheory.lintegral_rw₁ -- TODO: Need a better way of rewriting inside of an integral theorem lintegral_rw₂ {f₁ f₁' : α → β} {f₂ f₂' : α → γ} (h₁ : f₁ =ᵐ[μ] f₁') (h₂ : f₂ =ᵐ[μ] f₂') (g : β → γ → ℝ≥0∞) : ∫⁻ a, g (f₁ a) (f₂ a) ∂μ = ∫⁻ a, g (f₁' a) (f₂' a) ∂μ := lintegral_congr_ae <| h₁.mp <| h₂.mono fun _ h₂ h₁ => by dsimp only; rw [h₁, h₂] #align measure_theory.lintegral_rw₂ MeasureTheory.lintegral_rw₂ theorem lintegral_indicator_le (f : α → ℝ≥0∞) (s : Set α) : ∫⁻ a, s.indicator f a ∂μ ≤ ∫⁻ a in s, f a ∂μ := by simp only [lintegral] apply iSup_le (fun g ↦ (iSup_le (fun hg ↦ ?_))) have : g ≤ f := hg.trans (indicator_le_self s f) refine le_iSup_of_le g (le_iSup_of_le this (le_of_eq ?_)) rw [lintegral_restrict, SimpleFunc.lintegral] congr with t by_cases H : t = 0 · simp [H] congr with x simp only [mem_preimage, mem_singleton_iff, mem_inter_iff, iff_self_and] rintro rfl contrapose! H simpa [H] using hg x @[simp] theorem lintegral_indicator (f : α → ℝ≥0∞) {s : Set α} (hs : MeasurableSet s) : ∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by apply le_antisymm (lintegral_indicator_le f s) simp only [lintegral, ← restrict_lintegral_eq_lintegral_restrict _ hs, iSup_subtype'] refine iSup_mono' (Subtype.forall.2 fun φ hφ => ?_) refine ⟨⟨φ.restrict s, fun x => ?_⟩, le_rfl⟩ simp [hφ x, hs, indicator_le_indicator] #align measure_theory.lintegral_indicator MeasureTheory.lintegral_indicator theorem lintegral_indicator₀ (f : α → ℝ≥0∞) {s : Set α} (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator f a ∂μ = ∫⁻ a in s, f a ∂μ := by rw [← lintegral_congr_ae (indicator_ae_eq_of_ae_eq_set hs.toMeasurable_ae_eq), lintegral_indicator _ (measurableSet_toMeasurable _ _), Measure.restrict_congr_set hs.toMeasurable_ae_eq] #align measure_theory.lintegral_indicator₀ MeasureTheory.lintegral_indicator₀ theorem lintegral_indicator_const_le (s : Set α) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ ≤ c * μ s := (lintegral_indicator_le _ _).trans (set_lintegral_const s c).le theorem lintegral_indicator_const₀ {s : Set α} (hs : NullMeasurableSet s μ) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := by rw [lintegral_indicator₀ _ hs, set_lintegral_const] theorem lintegral_indicator_const {s : Set α} (hs : MeasurableSet s) (c : ℝ≥0∞) : ∫⁻ a, s.indicator (fun _ => c) a ∂μ = c * μ s := lintegral_indicator_const₀ hs.nullMeasurableSet c #align measure_theory.lintegral_indicator_const MeasureTheory.lintegral_indicator_const theorem set_lintegral_eq_const {f : α → ℝ≥0∞} (hf : Measurable f) (r : ℝ≥0∞) : ∫⁻ x in { x | f x = r }, f x ∂μ = r * μ { x | f x = r } := by have : ∀ᵐ x ∂μ, x ∈ { x | f x = r } → f x = r := ae_of_all μ fun _ hx => hx rw [set_lintegral_congr_fun _ this] · rw [lintegral_const, Measure.restrict_apply MeasurableSet.univ, Set.univ_inter] · exact hf (measurableSet_singleton r) #align measure_theory.set_lintegral_eq_const MeasureTheory.set_lintegral_eq_const theorem lintegral_indicator_one_le (s : Set α) : ∫⁻ a, s.indicator 1 a ∂μ ≤ μ s := (lintegral_indicator_const_le _ _).trans <| (one_mul _).le @[simp] theorem lintegral_indicator_one₀ (hs : NullMeasurableSet s μ) : ∫⁻ a, s.indicator 1 a ∂μ = μ s := (lintegral_indicator_const₀ hs _).trans <| one_mul _ @[simp] theorem lintegral_indicator_one (hs : MeasurableSet s) : ∫⁻ a, s.indicator 1 a ∂μ = μ s := (lintegral_indicator_const hs _).trans <| one_mul _ #align measure_theory.lintegral_indicator_one MeasureTheory.lintegral_indicator_one /-- A version of **Markov's inequality** for two functions. It doesn't follow from the standard Markov's inequality because we only assume measurability of `g`, not `f`. -/ theorem lintegral_add_mul_meas_add_le_le_lintegral {f g : α → ℝ≥0∞} (hle : f ≤ᵐ[μ] g) (hg : AEMeasurable g μ) (ε : ℝ≥0∞) : ∫⁻ a, f a ∂μ + ε * μ { x | f x + ε ≤ g x } ≤ ∫⁻ a, g a ∂μ := by rcases exists_measurable_le_lintegral_eq μ f with ⟨φ, hφm, hφ_le, hφ_eq⟩ calc ∫⁻ x, f x ∂μ + ε * μ { x | f x + ε ≤ g x } = ∫⁻ x, φ x ∂μ + ε * μ { x | f x + ε ≤ g x } := by rw [hφ_eq] _ ≤ ∫⁻ x, φ x ∂μ + ε * μ { x | φ x + ε ≤ g x } := by gcongr exact fun x => (add_le_add_right (hφ_le _) _).trans _ = ∫⁻ x, φ x + indicator { x | φ x + ε ≤ g x } (fun _ => ε) x ∂μ := by rw [lintegral_add_left hφm, lintegral_indicator₀, set_lintegral_const] exact measurableSet_le (hφm.nullMeasurable.measurable'.add_const _) hg.nullMeasurable _ ≤ ∫⁻ x, g x ∂μ := lintegral_mono_ae (hle.mono fun x hx₁ => ?_) simp only [indicator_apply]; split_ifs with hx₂ exacts [hx₂, (add_zero _).trans_le <| (hφ_le x).trans hx₁] #align measure_theory.lintegral_add_mul_meas_add_le_le_lintegral MeasureTheory.lintegral_add_mul_meas_add_le_le_lintegral /-- **Markov's inequality** also known as **Chebyshev's first inequality**. -/ theorem mul_meas_ge_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (ε : ℝ≥0∞) : ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := by simpa only [lintegral_zero, zero_add] using lintegral_add_mul_meas_add_le_le_lintegral (ae_of_all _ fun x => zero_le (f x)) hf ε #align measure_theory.mul_meas_ge_le_lintegral₀ MeasureTheory.mul_meas_ge_le_lintegral₀ /-- **Markov's inequality** also known as **Chebyshev's first inequality**. For a version assuming `AEMeasurable`, see `mul_meas_ge_le_lintegral₀`. -/ theorem mul_meas_ge_le_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) (ε : ℝ≥0∞) : ε * μ { x | ε ≤ f x } ≤ ∫⁻ a, f a ∂μ := mul_meas_ge_le_lintegral₀ hf.aemeasurable ε #align measure_theory.mul_meas_ge_le_lintegral MeasureTheory.mul_meas_ge_le_lintegral lemma meas_le_lintegral₀ {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {s : Set α} (hs : ∀ x ∈ s, 1 ≤ f x) : μ s ≤ ∫⁻ a, f a ∂μ := by apply le_trans _ (mul_meas_ge_le_lintegral₀ hf 1) rw [one_mul] exact measure_mono hs lemma lintegral_le_meas {s : Set α} {f : α → ℝ≥0∞} (hf : ∀ a, f a ≤ 1) (h'f : ∀ a ∈ sᶜ, f a = 0) : ∫⁻ a, f a ∂μ ≤ μ s := by apply (lintegral_mono (fun x ↦ ?_)).trans (lintegral_indicator_one_le s) by_cases hx : x ∈ s · simpa [hx] using hf x · simpa [hx] using h'f x hx theorem lintegral_eq_top_of_measure_eq_top_ne_zero {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (hμf : μ {x | f x = ∞} ≠ 0) : ∫⁻ x, f x ∂μ = ∞ := eq_top_iff.mpr <| calc ∞ = ∞ * μ { x | ∞ ≤ f x } := by simp [mul_eq_top, hμf] _ ≤ ∫⁻ x, f x ∂μ := mul_meas_ge_le_lintegral₀ hf ∞ #align measure_theory.lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.lintegral_eq_top_of_measure_eq_top_ne_zero theorem setLintegral_eq_top_of_measure_eq_top_ne_zero (hf : AEMeasurable f (μ.restrict s)) (hμf : μ ({x ∈ s | f x = ∞}) ≠ 0) : ∫⁻ x in s, f x ∂μ = ∞ := lintegral_eq_top_of_measure_eq_top_ne_zero hf <| mt (eq_bot_mono <| by rw [← setOf_inter_eq_sep]; exact Measure.le_restrict_apply _ _) hμf #align measure_theory.set_lintegral_eq_top_of_measure_eq_top_ne_zero MeasureTheory.setLintegral_eq_top_of_measure_eq_top_ne_zero theorem measure_eq_top_of_lintegral_ne_top (hf : AEMeasurable f μ) (hμf : ∫⁻ x, f x ∂μ ≠ ∞) : μ {x | f x = ∞} = 0 := of_not_not fun h => hμf <| lintegral_eq_top_of_measure_eq_top_ne_zero hf h #align measure_theory.measure_eq_top_of_lintegral_ne_top MeasureTheory.measure_eq_top_of_lintegral_ne_top theorem measure_eq_top_of_setLintegral_ne_top (hf : AEMeasurable f (μ.restrict s)) (hμf : ∫⁻ x in s, f x ∂μ ≠ ∞) : μ ({x ∈ s | f x = ∞}) = 0 := of_not_not fun h => hμf <| setLintegral_eq_top_of_measure_eq_top_ne_zero hf h #align measure_theory.measure_eq_top_of_set_lintegral_ne_top MeasureTheory.measure_eq_top_of_setLintegral_ne_top /-- **Markov's inequality** also known as **Chebyshev's first inequality**. -/ theorem meas_ge_le_lintegral_div {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) {ε : ℝ≥0∞} (hε : ε ≠ 0) (hε' : ε ≠ ∞) : μ { x | ε ≤ f x } ≤ (∫⁻ a, f a ∂μ) / ε := (ENNReal.le_div_iff_mul_le (Or.inl hε) (Or.inl hε')).2 <| by rw [mul_comm] exact mul_meas_ge_le_lintegral₀ hf ε #align measure_theory.meas_ge_le_lintegral_div MeasureTheory.meas_ge_le_lintegral_div theorem ae_eq_of_ae_le_of_lintegral_le {f g : α → ℝ≥0∞} (hfg : f ≤ᵐ[μ] g) (hf : ∫⁻ x, f x ∂μ ≠ ∞) (hg : AEMeasurable g μ) (hgf : ∫⁻ x, g x ∂μ ≤ ∫⁻ x, f x ∂μ) : f =ᵐ[μ] g := by have : ∀ n : ℕ, ∀ᵐ x ∂μ, g x < f x + (n : ℝ≥0∞)⁻¹ := by intro n simp only [ae_iff, not_lt] have : ∫⁻ x, f x ∂μ + (↑n)⁻¹ * μ { x : α | f x + (n : ℝ≥0∞)⁻¹ ≤ g x } ≤ ∫⁻ x, f x ∂μ := (lintegral_add_mul_meas_add_le_le_lintegral hfg hg n⁻¹).trans hgf rw [(ENNReal.cancel_of_ne hf).add_le_iff_nonpos_right, nonpos_iff_eq_zero, mul_eq_zero] at this exact this.resolve_left (ENNReal.inv_ne_zero.2 (ENNReal.natCast_ne_top _)) refine hfg.mp ((ae_all_iff.2 this).mono fun x hlt hle => hle.antisymm ?_) suffices Tendsto (fun n : ℕ => f x + (n : ℝ≥0∞)⁻¹) atTop (𝓝 (f x)) from ge_of_tendsto' this fun i => (hlt i).le simpa only [inv_top, add_zero] using tendsto_const_nhds.add (ENNReal.tendsto_inv_iff.2 ENNReal.tendsto_nat_nhds_top) #align measure_theory.ae_eq_of_ae_le_of_lintegral_le MeasureTheory.ae_eq_of_ae_le_of_lintegral_le @[simp] theorem lintegral_eq_zero_iff' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 := have : ∫⁻ _ : α, 0 ∂μ ≠ ∞ := by simp [lintegral_zero, zero_ne_top] ⟨fun h => (ae_eq_of_ae_le_of_lintegral_le (ae_of_all _ <| zero_le f) this hf (h.trans lintegral_zero.symm).le).symm, fun h => (lintegral_congr_ae h).trans lintegral_zero⟩ #align measure_theory.lintegral_eq_zero_iff' MeasureTheory.lintegral_eq_zero_iff' @[simp] theorem lintegral_eq_zero_iff {f : α → ℝ≥0∞} (hf : Measurable f) : ∫⁻ a, f a ∂μ = 0 ↔ f =ᵐ[μ] 0 := lintegral_eq_zero_iff' hf.aemeasurable #align measure_theory.lintegral_eq_zero_iff MeasureTheory.lintegral_eq_zero_iff theorem lintegral_pos_iff_support {f : α → ℝ≥0∞} (hf : Measurable f) : (0 < ∫⁻ a, f a ∂μ) ↔ 0 < μ (Function.support f) := by simp [pos_iff_ne_zero, hf, Filter.EventuallyEq, ae_iff, Function.support] #align measure_theory.lintegral_pos_iff_support MeasureTheory.lintegral_pos_iff_support theorem setLintegral_pos_iff {f : α → ℝ≥0∞} (hf : Measurable f) {s : Set α} : 0 < ∫⁻ a in s, f a ∂μ ↔ 0 < μ (Function.support f ∩ s) := by rw [lintegral_pos_iff_support hf, Measure.restrict_apply (measurableSet_support hf)] /-- Weaker version of the monotone convergence theorem-/ theorem lintegral_iSup_ae {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f n.succ a) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by let ⟨s, hs⟩ := exists_measurable_superset_of_null (ae_iff.1 (ae_all_iff.2 h_mono)) let g n a := if a ∈ s then 0 else f n a have g_eq_f : ∀ᵐ a ∂μ, ∀ n, g n a = f n a := (measure_zero_iff_ae_nmem.1 hs.2.2).mono fun a ha n => if_neg ha calc ∫⁻ a, ⨆ n, f n a ∂μ = ∫⁻ a, ⨆ n, g n a ∂μ := lintegral_congr_ae <| g_eq_f.mono fun a ha => by simp only [ha] _ = ⨆ n, ∫⁻ a, g n a ∂μ := (lintegral_iSup (fun n => measurable_const.piecewise hs.2.1 (hf n)) (monotone_nat_of_le_succ fun n a => ?_)) _ = ⨆ n, ∫⁻ a, f n a ∂μ := by simp only [lintegral_congr_ae (g_eq_f.mono fun _a ha => ha _)] simp only [g] split_ifs with h · rfl · have := Set.not_mem_subset hs.1 h simp only [not_forall, not_le, mem_setOf_eq, not_exists, not_lt] at this exact this n #align measure_theory.lintegral_supr_ae MeasureTheory.lintegral_iSup_ae theorem lintegral_sub' {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞) (h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ := by refine ENNReal.eq_sub_of_add_eq hg_fin ?_ rw [← lintegral_add_right' _ hg] exact lintegral_congr_ae (h_le.mono fun x hx => tsub_add_cancel_of_le hx) #align measure_theory.lintegral_sub' MeasureTheory.lintegral_sub' theorem lintegral_sub {f g : α → ℝ≥0∞} (hg : Measurable g) (hg_fin : ∫⁻ a, g a ∂μ ≠ ∞) (h_le : g ≤ᵐ[μ] f) : ∫⁻ a, f a - g a ∂μ = ∫⁻ a, f a ∂μ - ∫⁻ a, g a ∂μ := lintegral_sub' hg.aemeasurable hg_fin h_le #align measure_theory.lintegral_sub MeasureTheory.lintegral_sub theorem lintegral_sub_le' (f g : α → ℝ≥0∞) (hf : AEMeasurable f μ) : ∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ := by rw [tsub_le_iff_right] by_cases hfi : ∫⁻ x, f x ∂μ = ∞ · rw [hfi, add_top] exact le_top · rw [← lintegral_add_right' _ hf] gcongr exact le_tsub_add #align measure_theory.lintegral_sub_le' MeasureTheory.lintegral_sub_le' theorem lintegral_sub_le (f g : α → ℝ≥0∞) (hf : Measurable f) : ∫⁻ x, g x ∂μ - ∫⁻ x, f x ∂μ ≤ ∫⁻ x, g x - f x ∂μ := lintegral_sub_le' f g hf.aemeasurable #align measure_theory.lintegral_sub_le MeasureTheory.lintegral_sub_le theorem lintegral_strict_mono_of_ae_le_of_frequently_ae_lt {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) (h : ∃ᵐ x ∂μ, f x ≠ g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by contrapose! h simp only [not_frequently, Ne, Classical.not_not] exact ae_eq_of_ae_le_of_lintegral_le h_le hfi hg h #align measure_theory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt MeasureTheory.lintegral_strict_mono_of_ae_le_of_frequently_ae_lt theorem lintegral_strict_mono_of_ae_le_of_ae_lt_on {f g : α → ℝ≥0∞} (hg : AEMeasurable g μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h_le : f ≤ᵐ[μ] g) {s : Set α} (hμs : μ s ≠ 0) (h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := lintegral_strict_mono_of_ae_le_of_frequently_ae_lt hg hfi h_le <| ((frequently_ae_mem_iff.2 hμs).and_eventually h).mono fun _x hx => (hx.2 hx.1).ne #align measure_theory.lintegral_strict_mono_of_ae_le_of_ae_lt_on MeasureTheory.lintegral_strict_mono_of_ae_le_of_ae_lt_on theorem lintegral_strict_mono {f g : α → ℝ≥0∞} (hμ : μ ≠ 0) (hg : AEMeasurable g μ) (hfi : ∫⁻ x, f x ∂μ ≠ ∞) (h : ∀ᵐ x ∂μ, f x < g x) : ∫⁻ x, f x ∂μ < ∫⁻ x, g x ∂μ := by rw [Ne, ← Measure.measure_univ_eq_zero] at hμ refine lintegral_strict_mono_of_ae_le_of_ae_lt_on hg hfi (ae_le_of_ae_lt h) hμ ?_ simpa using h #align measure_theory.lintegral_strict_mono MeasureTheory.lintegral_strict_mono theorem set_lintegral_strict_mono {f g : α → ℝ≥0∞} {s : Set α} (hsm : MeasurableSet s) (hs : μ s ≠ 0) (hg : Measurable g) (hfi : ∫⁻ x in s, f x ∂μ ≠ ∞) (h : ∀ᵐ x ∂μ, x ∈ s → f x < g x) : ∫⁻ x in s, f x ∂μ < ∫⁻ x in s, g x ∂μ := lintegral_strict_mono (by simp [hs]) hg.aemeasurable hfi ((ae_restrict_iff' hsm).mpr h) #align measure_theory.set_lintegral_strict_mono MeasureTheory.set_lintegral_strict_mono /-- Monotone convergence theorem for nonincreasing sequences of functions -/ theorem lintegral_iInf_ae {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) (h_mono : ∀ n : ℕ, f n.succ ≤ᵐ[μ] f n) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) : ∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ := have fn_le_f0 : ∫⁻ a, ⨅ n, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ := lintegral_mono fun a => iInf_le_of_le 0 le_rfl have fn_le_f0' : ⨅ n, ∫⁻ a, f n a ∂μ ≤ ∫⁻ a, f 0 a ∂μ := iInf_le_of_le 0 le_rfl (ENNReal.sub_right_inj h_fin fn_le_f0 fn_le_f0').1 <| show ∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ from calc ∫⁻ a, f 0 a ∂μ - ∫⁻ a, ⨅ n, f n a ∂μ = ∫⁻ a, f 0 a - ⨅ n, f n a ∂μ := (lintegral_sub (measurable_iInf h_meas) (ne_top_of_le_ne_top h_fin <| lintegral_mono fun a => iInf_le _ _) (ae_of_all _ fun a => iInf_le _ _)).symm _ = ∫⁻ a, ⨆ n, f 0 a - f n a ∂μ := congr rfl (funext fun a => ENNReal.sub_iInf) _ = ⨆ n, ∫⁻ a, f 0 a - f n a ∂μ := (lintegral_iSup_ae (fun n => (h_meas 0).sub (h_meas n)) fun n => (h_mono n).mono fun a ha => tsub_le_tsub le_rfl ha) _ = ⨆ n, ∫⁻ a, f 0 a ∂μ - ∫⁻ a, f n a ∂μ := (have h_mono : ∀ᵐ a ∂μ, ∀ n : ℕ, f n.succ a ≤ f n a := ae_all_iff.2 h_mono have h_mono : ∀ n, ∀ᵐ a ∂μ, f n a ≤ f 0 a := fun n => h_mono.mono fun a h => by induction' n with n ih · exact le_rfl · exact le_trans (h n) ih congr_arg iSup <| funext fun n => lintegral_sub (h_meas _) (ne_top_of_le_ne_top h_fin <| lintegral_mono_ae <| h_mono n) (h_mono n)) _ = ∫⁻ a, f 0 a ∂μ - ⨅ n, ∫⁻ a, f n a ∂μ := ENNReal.sub_iInf.symm #align measure_theory.lintegral_infi_ae MeasureTheory.lintegral_iInf_ae /-- Monotone convergence theorem for nonincreasing sequences of functions -/ theorem lintegral_iInf {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) (h_anti : Antitone f) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) : ∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ := lintegral_iInf_ae h_meas (fun n => ae_of_all _ <| h_anti n.le_succ) h_fin #align measure_theory.lintegral_infi MeasureTheory.lintegral_iInf theorem lintegral_iInf' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ) (h_anti : ∀ᵐ a ∂μ, Antitone (fun i ↦ f i a)) (h_fin : ∫⁻ a, f 0 a ∂μ ≠ ∞) : ∫⁻ a, ⨅ n, f n a ∂μ = ⨅ n, ∫⁻ a, f n a ∂μ := by simp_rw [← iInf_apply] let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Antitone f' have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_anti have h_ae_seq_mono : Antitone (aeSeq h_meas p) := by intro n m hnm x by_cases hx : x ∈ aeSeqSet h_meas p · exact aeSeq.prop_of_mem_aeSeqSet h_meas hx hnm · simp only [aeSeq, hx, if_false] exact le_rfl rw [lintegral_congr_ae (aeSeq.iInf h_meas hp).symm] simp_rw [iInf_apply] rw [lintegral_iInf (aeSeq.measurable h_meas p) h_ae_seq_mono] · congr exact funext fun n ↦ lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp n) · rwa [lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae h_meas hp 0)] /-- Monotone convergence for an infimum over a directed family and indexed by a countable type -/ theorem lintegral_iInf_directed_of_measurable {mα : MeasurableSpace α} [Countable β] {f : β → α → ℝ≥0∞} {μ : Measure α} (hμ : μ ≠ 0) (hf : ∀ b, Measurable (f b)) (hf_int : ∀ b, ∫⁻ a, f b a ∂μ ≠ ∞) (h_directed : Directed (· ≥ ·) f) : ∫⁻ a, ⨅ b, f b a ∂μ = ⨅ b, ∫⁻ a, f b a ∂μ := by cases nonempty_encodable β cases isEmpty_or_nonempty β · simp only [iInf_of_empty, lintegral_const, ENNReal.top_mul (Measure.measure_univ_ne_zero.mpr hμ)] inhabit β have : ∀ a, ⨅ b, f b a = ⨅ n, f (h_directed.sequence f n) a := by refine fun a => le_antisymm (le_iInf fun n => iInf_le _ _) (le_iInf fun b => iInf_le_of_le (Encodable.encode b + 1) ?_) exact h_directed.sequence_le b a -- Porting note: used `∘` below to deal with its reduced reducibility calc ∫⁻ a, ⨅ b, f b a ∂μ _ = ∫⁻ a, ⨅ n, (f ∘ h_directed.sequence f) n a ∂μ := by simp only [this, Function.comp_apply] _ = ⨅ n, ∫⁻ a, (f ∘ h_directed.sequence f) n a ∂μ := by rw [lintegral_iInf ?_ h_directed.sequence_anti] · exact hf_int _ · exact fun n => hf _ _ = ⨅ b, ∫⁻ a, f b a ∂μ := by refine le_antisymm (le_iInf fun b => ?_) (le_iInf fun n => ?_) · exact iInf_le_of_le (Encodable.encode b + 1) (lintegral_mono <| h_directed.sequence_le b) · exact iInf_le (fun b => ∫⁻ a, f b a ∂μ) _ #align lintegral_infi_directed_of_measurable MeasureTheory.lintegral_iInf_directed_of_measurable /-- Known as Fatou's lemma, version with `AEMeasurable` functions -/ theorem lintegral_liminf_le' {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, AEMeasurable (f n) μ) : ∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop := calc ∫⁻ a, liminf (fun n => f n a) atTop ∂μ = ∫⁻ a, ⨆ n : ℕ, ⨅ i ≥ n, f i a ∂μ := by simp only [liminf_eq_iSup_iInf_of_nat] _ = ⨆ n : ℕ, ∫⁻ a, ⨅ i ≥ n, f i a ∂μ := (lintegral_iSup' (fun n => aemeasurable_biInf _ (to_countable _) (fun i _ ↦ h_meas i)) (ae_of_all μ fun a n m hnm => iInf_le_iInf_of_subset fun i hi => le_trans hnm hi)) _ ≤ ⨆ n : ℕ, ⨅ i ≥ n, ∫⁻ a, f i a ∂μ := iSup_mono fun n => le_iInf₂_lintegral _ _ = atTop.liminf fun n => ∫⁻ a, f n a ∂μ := Filter.liminf_eq_iSup_iInf_of_nat.symm #align measure_theory.lintegral_liminf_le' MeasureTheory.lintegral_liminf_le' /-- Known as Fatou's lemma -/ theorem lintegral_liminf_le {f : ℕ → α → ℝ≥0∞} (h_meas : ∀ n, Measurable (f n)) : ∫⁻ a, liminf (fun n => f n a) atTop ∂μ ≤ liminf (fun n => ∫⁻ a, f n a ∂μ) atTop := lintegral_liminf_le' fun n => (h_meas n).aemeasurable #align measure_theory.lintegral_liminf_le MeasureTheory.lintegral_liminf_le theorem limsup_lintegral_le {f : ℕ → α → ℝ≥0∞} {g : α → ℝ≥0∞} (hf_meas : ∀ n, Measurable (f n)) (h_bound : ∀ n, f n ≤ᵐ[μ] g) (h_fin : ∫⁻ a, g a ∂μ ≠ ∞) : limsup (fun n => ∫⁻ a, f n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => f n a) atTop ∂μ := calc limsup (fun n => ∫⁻ a, f n a ∂μ) atTop = ⨅ n : ℕ, ⨆ i ≥ n, ∫⁻ a, f i a ∂μ := limsup_eq_iInf_iSup_of_nat _ ≤ ⨅ n : ℕ, ∫⁻ a, ⨆ i ≥ n, f i a ∂μ := iInf_mono fun n => iSup₂_lintegral_le _ _ = ∫⁻ a, ⨅ n : ℕ, ⨆ i ≥ n, f i a ∂μ := by refine (lintegral_iInf ?_ ?_ ?_).symm · intro n exact measurable_biSup _ (to_countable _) (fun i _ ↦ hf_meas i) · intro n m hnm a exact iSup_le_iSup_of_subset fun i hi => le_trans hnm hi · refine ne_top_of_le_ne_top h_fin (lintegral_mono_ae ?_) refine (ae_all_iff.2 h_bound).mono fun n hn => ?_ exact iSup_le fun i => iSup_le fun _ => hn i _ = ∫⁻ a, limsup (fun n => f n a) atTop ∂μ := by simp only [limsup_eq_iInf_iSup_of_nat] #align measure_theory.limsup_lintegral_le MeasureTheory.limsup_lintegral_le /-- Dominated convergence theorem for nonnegative functions -/ theorem tendsto_lintegral_of_dominated_convergence {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞) (hF_meas : ∀ n, Measurable (F n)) (h_bound : ∀ n, F n ≤ᵐ[μ] bound) (h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, F n a ∂μ) atTop (𝓝 (∫⁻ a, f a ∂μ)) := tendsto_of_le_liminf_of_limsup_le (calc ∫⁻ a, f a ∂μ = ∫⁻ a, liminf (fun n : ℕ => F n a) atTop ∂μ := lintegral_congr_ae <| h_lim.mono fun a h => h.liminf_eq.symm _ ≤ liminf (fun n => ∫⁻ a, F n a ∂μ) atTop := lintegral_liminf_le hF_meas ) (calc limsup (fun n : ℕ => ∫⁻ a, F n a ∂μ) atTop ≤ ∫⁻ a, limsup (fun n => F n a) atTop ∂μ := limsup_lintegral_le hF_meas h_bound h_fin _ = ∫⁻ a, f a ∂μ := lintegral_congr_ae <| h_lim.mono fun a h => h.limsup_eq ) #align measure_theory.tendsto_lintegral_of_dominated_convergence MeasureTheory.tendsto_lintegral_of_dominated_convergence /-- Dominated convergence theorem for nonnegative functions which are just almost everywhere measurable. -/ theorem tendsto_lintegral_of_dominated_convergence' {F : ℕ → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞) (hF_meas : ∀ n, AEMeasurable (F n) μ) (h_bound : ∀ n, F n ≤ᵐ[μ] bound) (h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) atTop (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, F n a ∂μ) atTop (𝓝 (∫⁻ a, f a ∂μ)) := by have : ∀ n, ∫⁻ a, F n a ∂μ = ∫⁻ a, (hF_meas n).mk (F n) a ∂μ := fun n => lintegral_congr_ae (hF_meas n).ae_eq_mk simp_rw [this] apply tendsto_lintegral_of_dominated_convergence bound (fun n => (hF_meas n).measurable_mk) _ h_fin · have : ∀ n, ∀ᵐ a ∂μ, (hF_meas n).mk (F n) a = F n a := fun n => (hF_meas n).ae_eq_mk.symm have : ∀ᵐ a ∂μ, ∀ n, (hF_meas n).mk (F n) a = F n a := ae_all_iff.mpr this filter_upwards [this, h_lim] with a H H' simp_rw [H] exact H' · intro n filter_upwards [h_bound n, (hF_meas n).ae_eq_mk] with a H H' rwa [H'] at H #align measure_theory.tendsto_lintegral_of_dominated_convergence' MeasureTheory.tendsto_lintegral_of_dominated_convergence' /-- Dominated convergence theorem for filters with a countable basis -/ theorem tendsto_lintegral_filter_of_dominated_convergence {ι} {l : Filter ι} [l.IsCountablyGenerated] {F : ι → α → ℝ≥0∞} {f : α → ℝ≥0∞} (bound : α → ℝ≥0∞) (hF_meas : ∀ᶠ n in l, Measurable (F n)) (h_bound : ∀ᶠ n in l, ∀ᵐ a ∂μ, F n a ≤ bound a) (h_fin : ∫⁻ a, bound a ∂μ ≠ ∞) (h_lim : ∀ᵐ a ∂μ, Tendsto (fun n => F n a) l (𝓝 (f a))) : Tendsto (fun n => ∫⁻ a, F n a ∂μ) l (𝓝 <| ∫⁻ a, f a ∂μ) := by rw [tendsto_iff_seq_tendsto] intro x xl have hxl := by rw [tendsto_atTop'] at xl exact xl have h := inter_mem hF_meas h_bound replace h := hxl _ h rcases h with ⟨k, h⟩ rw [← tendsto_add_atTop_iff_nat k] refine tendsto_lintegral_of_dominated_convergence ?_ ?_ ?_ ?_ ?_ · exact bound · intro refine (h _ ?_).1 exact Nat.le_add_left _ _ · intro refine (h _ ?_).2 exact Nat.le_add_left _ _ · assumption · refine h_lim.mono fun a h_lim => ?_ apply @Tendsto.comp _ _ _ (fun n => x (n + k)) fun n => F n a · assumption rw [tendsto_add_atTop_iff_nat] assumption #align measure_theory.tendsto_lintegral_filter_of_dominated_convergence MeasureTheory.tendsto_lintegral_filter_of_dominated_convergence theorem lintegral_tendsto_of_tendsto_of_antitone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ) (h_anti : ∀ᵐ x ∂μ, Antitone fun n ↦ f n x) (h0 : ∫⁻ a, f 0 a ∂μ ≠ ∞) (h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n ↦ f n x) atTop (𝓝 (F x))) : Tendsto (fun n ↦ ∫⁻ x, f n x ∂μ) atTop (𝓝 (∫⁻ x, F x ∂μ)) := by have : Antitone fun n ↦ ∫⁻ x, f n x ∂μ := fun i j hij ↦ lintegral_mono_ae (h_anti.mono fun x hx ↦ hx hij) suffices key : ∫⁻ x, F x ∂μ = ⨅ n, ∫⁻ x, f n x ∂μ by rw [key] exact tendsto_atTop_iInf this rw [← lintegral_iInf' hf h_anti h0] refine lintegral_congr_ae ?_ filter_upwards [h_anti, h_tendsto] with _ hx_anti hx_tendsto using tendsto_nhds_unique hx_tendsto (tendsto_atTop_iInf hx_anti) section open Encodable /-- Monotone convergence for a supremum over a directed family and indexed by a countable type -/ theorem lintegral_iSup_directed_of_measurable [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ b, Measurable (f b)) (h_directed : Directed (· ≤ ·) f) : ∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by cases nonempty_encodable β cases isEmpty_or_nonempty β · simp [iSup_of_empty] inhabit β have : ∀ a, ⨆ b, f b a = ⨆ n, f (h_directed.sequence f n) a := by intro a refine le_antisymm (iSup_le fun b => ?_) (iSup_le fun n => le_iSup (fun n => f n a) _) exact le_iSup_of_le (encode b + 1) (h_directed.le_sequence b a) calc ∫⁻ a, ⨆ b, f b a ∂μ = ∫⁻ a, ⨆ n, f (h_directed.sequence f n) a ∂μ := by simp only [this] _ = ⨆ n, ∫⁻ a, f (h_directed.sequence f n) a ∂μ := (lintegral_iSup (fun n => hf _) h_directed.sequence_mono) _ = ⨆ b, ∫⁻ a, f b a ∂μ := by refine le_antisymm (iSup_le fun n => ?_) (iSup_le fun b => ?_) · exact le_iSup (fun b => ∫⁻ a, f b a ∂μ) _ · exact le_iSup_of_le (encode b + 1) (lintegral_mono <| h_directed.le_sequence b) #align measure_theory.lintegral_supr_directed_of_measurable MeasureTheory.lintegral_iSup_directed_of_measurable /-- Monotone convergence for a supremum over a directed family and indexed by a countable type. -/
Mathlib/MeasureTheory/Integral/Lebesgue.lean
1,259
1,284
theorem lintegral_iSup_directed [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ b, AEMeasurable (f b) μ) (h_directed : Directed (· ≤ ·) f) : ∫⁻ a, ⨆ b, f b a ∂μ = ⨆ b, ∫⁻ a, f b a ∂μ := by
simp_rw [← iSup_apply] let p : α → (β → ENNReal) → Prop := fun x f' => Directed LE.le f' have hp : ∀ᵐ x ∂μ, p x fun i => f i x := by filter_upwards [] with x i j obtain ⟨z, hz₁, hz₂⟩ := h_directed i j exact ⟨z, hz₁ x, hz₂ x⟩ have h_ae_seq_directed : Directed LE.le (aeSeq hf p) := by intro b₁ b₂ obtain ⟨z, hz₁, hz₂⟩ := h_directed b₁ b₂ refine ⟨z, ?_, ?_⟩ <;> · intro x by_cases hx : x ∈ aeSeqSet hf p · repeat rw [aeSeq.aeSeq_eq_fun_of_mem_aeSeqSet hf hx] apply_rules [hz₁, hz₂] · simp only [aeSeq, hx, if_false] exact le_rfl convert lintegral_iSup_directed_of_measurable (aeSeq.measurable hf p) h_ae_seq_directed using 1 · simp_rw [← iSup_apply] rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm] · congr 1 ext1 b rw [lintegral_congr_ae] apply EventuallyEq.symm exact aeSeq.aeSeq_n_eq_fun_n_ae hf hp _
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.GroupTheory.GroupAction.ConjAct import Mathlib.GroupTheory.GroupAction.Quotient import Mathlib.GroupTheory.QuotientGroup import Mathlib.Topology.Algebra.Monoid import Mathlib.Topology.Algebra.Constructions #align_import topology.algebra.group.basic from "leanprover-community/mathlib"@"3b1890e71632be9e3b2086ab512c3259a7e9a3ef" /-! # Topological groups This file defines the following typeclasses: * `TopologicalGroup`, `TopologicalAddGroup`: multiplicative and additive topological groups, i.e., groups with continuous `(*)` and `(⁻¹)` / `(+)` and `(-)`; * `ContinuousSub G` means that `G` has a continuous subtraction operation. There is an instance deducing `ContinuousSub` from `TopologicalGroup` but we use a separate typeclass because, e.g., `ℕ` and `ℝ≥0` have continuous subtraction but are not additive groups. We also define `Homeomorph` versions of several `Equiv`s: `Homeomorph.mulLeft`, `Homeomorph.mulRight`, `Homeomorph.inv`, and prove a few facts about neighbourhood filters in groups. ## Tags topological space, group, topological group -/ open scoped Classical open Set Filter TopologicalSpace Function Topology Pointwise MulOpposite universe u v w x variable {G : Type w} {H : Type x} {α : Type u} {β : Type v} section ContinuousMulGroup /-! ### Groups with continuous multiplication In this section we prove a few statements about groups with continuous `(*)`. -/ variable [TopologicalSpace G] [Group G] [ContinuousMul G] /-- Multiplication from the left in a topological group as a homeomorphism. -/ @[to_additive "Addition from the left in a topological additive group as a homeomorphism."] protected def Homeomorph.mulLeft (a : G) : G ≃ₜ G := { Equiv.mulLeft a with continuous_toFun := continuous_const.mul continuous_id continuous_invFun := continuous_const.mul continuous_id } #align homeomorph.mul_left Homeomorph.mulLeft #align homeomorph.add_left Homeomorph.addLeft @[to_additive (attr := simp)] theorem Homeomorph.coe_mulLeft (a : G) : ⇑(Homeomorph.mulLeft a) = (a * ·) := rfl #align homeomorph.coe_mul_left Homeomorph.coe_mulLeft #align homeomorph.coe_add_left Homeomorph.coe_addLeft @[to_additive] theorem Homeomorph.mulLeft_symm (a : G) : (Homeomorph.mulLeft a).symm = Homeomorph.mulLeft a⁻¹ := by ext rfl #align homeomorph.mul_left_symm Homeomorph.mulLeft_symm #align homeomorph.add_left_symm Homeomorph.addLeft_symm @[to_additive] lemma isOpenMap_mul_left (a : G) : IsOpenMap (a * ·) := (Homeomorph.mulLeft a).isOpenMap #align is_open_map_mul_left isOpenMap_mul_left #align is_open_map_add_left isOpenMap_add_left @[to_additive IsOpen.left_addCoset] theorem IsOpen.leftCoset {U : Set G} (h : IsOpen U) (x : G) : IsOpen (x • U) := isOpenMap_mul_left x _ h #align is_open.left_coset IsOpen.leftCoset #align is_open.left_add_coset IsOpen.left_addCoset @[to_additive] lemma isClosedMap_mul_left (a : G) : IsClosedMap (a * ·) := (Homeomorph.mulLeft a).isClosedMap #align is_closed_map_mul_left isClosedMap_mul_left #align is_closed_map_add_left isClosedMap_add_left @[to_additive IsClosed.left_addCoset] theorem IsClosed.leftCoset {U : Set G} (h : IsClosed U) (x : G) : IsClosed (x • U) := isClosedMap_mul_left x _ h #align is_closed.left_coset IsClosed.leftCoset #align is_closed.left_add_coset IsClosed.left_addCoset /-- Multiplication from the right in a topological group as a homeomorphism. -/ @[to_additive "Addition from the right in a topological additive group as a homeomorphism."] protected def Homeomorph.mulRight (a : G) : G ≃ₜ G := { Equiv.mulRight a with continuous_toFun := continuous_id.mul continuous_const continuous_invFun := continuous_id.mul continuous_const } #align homeomorph.mul_right Homeomorph.mulRight #align homeomorph.add_right Homeomorph.addRight @[to_additive (attr := simp)] lemma Homeomorph.coe_mulRight (a : G) : ⇑(Homeomorph.mulRight a) = (· * a) := rfl #align homeomorph.coe_mul_right Homeomorph.coe_mulRight #align homeomorph.coe_add_right Homeomorph.coe_addRight @[to_additive] theorem Homeomorph.mulRight_symm (a : G) : (Homeomorph.mulRight a).symm = Homeomorph.mulRight a⁻¹ := by ext rfl #align homeomorph.mul_right_symm Homeomorph.mulRight_symm #align homeomorph.add_right_symm Homeomorph.addRight_symm @[to_additive] theorem isOpenMap_mul_right (a : G) : IsOpenMap (· * a) := (Homeomorph.mulRight a).isOpenMap #align is_open_map_mul_right isOpenMap_mul_right #align is_open_map_add_right isOpenMap_add_right @[to_additive IsOpen.right_addCoset] theorem IsOpen.rightCoset {U : Set G} (h : IsOpen U) (x : G) : IsOpen (op x • U) := isOpenMap_mul_right x _ h #align is_open.right_coset IsOpen.rightCoset #align is_open.right_add_coset IsOpen.right_addCoset @[to_additive] theorem isClosedMap_mul_right (a : G) : IsClosedMap (· * a) := (Homeomorph.mulRight a).isClosedMap #align is_closed_map_mul_right isClosedMap_mul_right #align is_closed_map_add_right isClosedMap_add_right @[to_additive IsClosed.right_addCoset] theorem IsClosed.rightCoset {U : Set G} (h : IsClosed U) (x : G) : IsClosed (op x • U) := isClosedMap_mul_right x _ h #align is_closed.right_coset IsClosed.rightCoset #align is_closed.right_add_coset IsClosed.right_addCoset @[to_additive] theorem discreteTopology_of_isOpen_singleton_one (h : IsOpen ({1} : Set G)) : DiscreteTopology G := by rw [← singletons_open_iff_discrete] intro g suffices {g} = (g⁻¹ * ·) ⁻¹' {1} by rw [this] exact (continuous_mul_left g⁻¹).isOpen_preimage _ h simp only [mul_one, Set.preimage_mul_left_singleton, eq_self_iff_true, inv_inv, Set.singleton_eq_singleton_iff] #align discrete_topology_of_open_singleton_one discreteTopology_of_isOpen_singleton_one #align discrete_topology_of_open_singleton_zero discreteTopology_of_isOpen_singleton_zero @[to_additive] theorem discreteTopology_iff_isOpen_singleton_one : DiscreteTopology G ↔ IsOpen ({1} : Set G) := ⟨fun h => forall_open_iff_discrete.mpr h {1}, discreteTopology_of_isOpen_singleton_one⟩ #align discrete_topology_iff_open_singleton_one discreteTopology_iff_isOpen_singleton_one #align discrete_topology_iff_open_singleton_zero discreteTopology_iff_isOpen_singleton_zero end ContinuousMulGroup /-! ### `ContinuousInv` and `ContinuousNeg` -/ /-- Basic hypothesis to talk about a topological additive group. A topological additive group over `M`, for example, is obtained by requiring the instances `AddGroup M` and `ContinuousAdd M` and `ContinuousNeg M`. -/ class ContinuousNeg (G : Type u) [TopologicalSpace G] [Neg G] : Prop where continuous_neg : Continuous fun a : G => -a #align has_continuous_neg ContinuousNeg -- Porting note: added attribute [continuity] ContinuousNeg.continuous_neg /-- Basic hypothesis to talk about a topological group. A topological group over `M`, for example, is obtained by requiring the instances `Group M` and `ContinuousMul M` and `ContinuousInv M`. -/ @[to_additive (attr := continuity)] class ContinuousInv (G : Type u) [TopologicalSpace G] [Inv G] : Prop where continuous_inv : Continuous fun a : G => a⁻¹ #align has_continuous_inv ContinuousInv --#align has_continuous_neg ContinuousNeg -- Porting note: added attribute [continuity] ContinuousInv.continuous_inv export ContinuousInv (continuous_inv) export ContinuousNeg (continuous_neg) section ContinuousInv variable [TopologicalSpace G] [Inv G] [ContinuousInv G] @[to_additive] protected theorem Specializes.inv {x y : G} (h : x ⤳ y) : (x⁻¹) ⤳ (y⁻¹) := h.map continuous_inv @[to_additive] protected theorem Inseparable.inv {x y : G} (h : Inseparable x y) : Inseparable (x⁻¹) (y⁻¹) := h.map continuous_inv @[to_additive] protected theorem Specializes.zpow {G : Type*} [DivInvMonoid G] [TopologicalSpace G] [ContinuousMul G] [ContinuousInv G] {x y : G} (h : x ⤳ y) : ∀ m : ℤ, (x ^ m) ⤳ (y ^ m) | .ofNat n => by simpa using h.pow n | .negSucc n => by simpa using (h.pow (n + 1)).inv @[to_additive] protected theorem Inseparable.zpow {G : Type*} [DivInvMonoid G] [TopologicalSpace G] [ContinuousMul G] [ContinuousInv G] {x y : G} (h : Inseparable x y) (m : ℤ) : Inseparable (x ^ m) (y ^ m) := (h.specializes.zpow m).antisymm (h.specializes'.zpow m) @[to_additive] instance : ContinuousInv (ULift G) := ⟨continuous_uLift_up.comp (continuous_inv.comp continuous_uLift_down)⟩ @[to_additive] theorem continuousOn_inv {s : Set G} : ContinuousOn Inv.inv s := continuous_inv.continuousOn #align continuous_on_inv continuousOn_inv #align continuous_on_neg continuousOn_neg @[to_additive] theorem continuousWithinAt_inv {s : Set G} {x : G} : ContinuousWithinAt Inv.inv s x := continuous_inv.continuousWithinAt #align continuous_within_at_inv continuousWithinAt_inv #align continuous_within_at_neg continuousWithinAt_neg @[to_additive] theorem continuousAt_inv {x : G} : ContinuousAt Inv.inv x := continuous_inv.continuousAt #align continuous_at_inv continuousAt_inv #align continuous_at_neg continuousAt_neg @[to_additive] theorem tendsto_inv (a : G) : Tendsto Inv.inv (𝓝 a) (𝓝 a⁻¹) := continuousAt_inv #align tendsto_inv tendsto_inv #align tendsto_neg tendsto_neg /-- If a function converges to a value in a multiplicative topological group, then its inverse converges to the inverse of this value. For the version in normed fields assuming additionally that the limit is nonzero, use `Tendsto.inv'`. -/ @[to_additive "If a function converges to a value in an additive topological group, then its negation converges to the negation of this value."] theorem Filter.Tendsto.inv {f : α → G} {l : Filter α} {y : G} (h : Tendsto f l (𝓝 y)) : Tendsto (fun x => (f x)⁻¹) l (𝓝 y⁻¹) := (continuous_inv.tendsto y).comp h #align filter.tendsto.inv Filter.Tendsto.inv #align filter.tendsto.neg Filter.Tendsto.neg variable [TopologicalSpace α] {f : α → G} {s : Set α} {x : α} @[to_additive (attr := continuity, fun_prop)] theorem Continuous.inv (hf : Continuous f) : Continuous fun x => (f x)⁻¹ := continuous_inv.comp hf #align continuous.inv Continuous.inv #align continuous.neg Continuous.neg @[to_additive (attr := fun_prop)] theorem ContinuousAt.inv (hf : ContinuousAt f x) : ContinuousAt (fun x => (f x)⁻¹) x := continuousAt_inv.comp hf #align continuous_at.inv ContinuousAt.inv #align continuous_at.neg ContinuousAt.neg @[to_additive (attr := fun_prop)] theorem ContinuousOn.inv (hf : ContinuousOn f s) : ContinuousOn (fun x => (f x)⁻¹) s := continuous_inv.comp_continuousOn hf #align continuous_on.inv ContinuousOn.inv #align continuous_on.neg ContinuousOn.neg @[to_additive] theorem ContinuousWithinAt.inv (hf : ContinuousWithinAt f s x) : ContinuousWithinAt (fun x => (f x)⁻¹) s x := Filter.Tendsto.inv hf #align continuous_within_at.inv ContinuousWithinAt.inv #align continuous_within_at.neg ContinuousWithinAt.neg @[to_additive] instance Prod.continuousInv [TopologicalSpace H] [Inv H] [ContinuousInv H] : ContinuousInv (G × H) := ⟨continuous_inv.fst'.prod_mk continuous_inv.snd'⟩ variable {ι : Type*} @[to_additive] instance Pi.continuousInv {C : ι → Type*} [∀ i, TopologicalSpace (C i)] [∀ i, Inv (C i)] [∀ i, ContinuousInv (C i)] : ContinuousInv (∀ i, C i) where continuous_inv := continuous_pi fun i => (continuous_apply i).inv #align pi.has_continuous_inv Pi.continuousInv #align pi.has_continuous_neg Pi.continuousNeg /-- A version of `Pi.continuousInv` for non-dependent functions. It is needed because sometimes Lean fails to use `Pi.continuousInv` for non-dependent functions. -/ @[to_additive "A version of `Pi.continuousNeg` for non-dependent functions. It is needed because sometimes Lean fails to use `Pi.continuousNeg` for non-dependent functions."] instance Pi.has_continuous_inv' : ContinuousInv (ι → G) := Pi.continuousInv #align pi.has_continuous_inv' Pi.has_continuous_inv' #align pi.has_continuous_neg' Pi.has_continuous_neg' @[to_additive] instance (priority := 100) continuousInv_of_discreteTopology [TopologicalSpace H] [Inv H] [DiscreteTopology H] : ContinuousInv H := ⟨continuous_of_discreteTopology⟩ #align has_continuous_inv_of_discrete_topology continuousInv_of_discreteTopology #align has_continuous_neg_of_discrete_topology continuousNeg_of_discreteTopology section PointwiseLimits variable (G₁ G₂ : Type*) [TopologicalSpace G₂] [T2Space G₂] @[to_additive] theorem isClosed_setOf_map_inv [Inv G₁] [Inv G₂] [ContinuousInv G₂] : IsClosed { f : G₁ → G₂ | ∀ x, f x⁻¹ = (f x)⁻¹ } := by simp only [setOf_forall] exact isClosed_iInter fun i => isClosed_eq (continuous_apply _) (continuous_apply _).inv #align is_closed_set_of_map_inv isClosed_setOf_map_inv #align is_closed_set_of_map_neg isClosed_setOf_map_neg end PointwiseLimits instance [TopologicalSpace H] [Inv H] [ContinuousInv H] : ContinuousNeg (Additive H) where continuous_neg := @continuous_inv H _ _ _ instance [TopologicalSpace H] [Neg H] [ContinuousNeg H] : ContinuousInv (Multiplicative H) where continuous_inv := @continuous_neg H _ _ _ end ContinuousInv section ContinuousInvolutiveInv variable [TopologicalSpace G] [InvolutiveInv G] [ContinuousInv G] {s : Set G} @[to_additive] theorem IsCompact.inv (hs : IsCompact s) : IsCompact s⁻¹ := by rw [← image_inv] exact hs.image continuous_inv #align is_compact.inv IsCompact.inv #align is_compact.neg IsCompact.neg variable (G) /-- Inversion in a topological group as a homeomorphism. -/ @[to_additive "Negation in a topological group as a homeomorphism."] protected def Homeomorph.inv (G : Type*) [TopologicalSpace G] [InvolutiveInv G] [ContinuousInv G] : G ≃ₜ G := { Equiv.inv G with continuous_toFun := continuous_inv continuous_invFun := continuous_inv } #align homeomorph.inv Homeomorph.inv #align homeomorph.neg Homeomorph.neg @[to_additive (attr := simp)] lemma Homeomorph.coe_inv {G : Type*} [TopologicalSpace G] [InvolutiveInv G] [ContinuousInv G] : ⇑(Homeomorph.inv G) = Inv.inv := rfl @[to_additive] theorem isOpenMap_inv : IsOpenMap (Inv.inv : G → G) := (Homeomorph.inv _).isOpenMap #align is_open_map_inv isOpenMap_inv #align is_open_map_neg isOpenMap_neg @[to_additive] theorem isClosedMap_inv : IsClosedMap (Inv.inv : G → G) := (Homeomorph.inv _).isClosedMap #align is_closed_map_inv isClosedMap_inv #align is_closed_map_neg isClosedMap_neg variable {G} @[to_additive] theorem IsOpen.inv (hs : IsOpen s) : IsOpen s⁻¹ := hs.preimage continuous_inv #align is_open.inv IsOpen.inv #align is_open.neg IsOpen.neg @[to_additive] theorem IsClosed.inv (hs : IsClosed s) : IsClosed s⁻¹ := hs.preimage continuous_inv #align is_closed.inv IsClosed.inv #align is_closed.neg IsClosed.neg @[to_additive] theorem inv_closure : ∀ s : Set G, (closure s)⁻¹ = closure s⁻¹ := (Homeomorph.inv G).preimage_closure #align inv_closure inv_closure #align neg_closure neg_closure end ContinuousInvolutiveInv section LatticeOps variable {ι' : Sort*} [Inv G] @[to_additive] theorem continuousInv_sInf {ts : Set (TopologicalSpace G)} (h : ∀ t ∈ ts, @ContinuousInv G t _) : @ContinuousInv G (sInf ts) _ := letI := sInf ts { continuous_inv := continuous_sInf_rng.2 fun t ht => continuous_sInf_dom ht (@ContinuousInv.continuous_inv G t _ (h t ht)) } #align has_continuous_inv_Inf continuousInv_sInf #align has_continuous_neg_Inf continuousNeg_sInf @[to_additive] theorem continuousInv_iInf {ts' : ι' → TopologicalSpace G} (h' : ∀ i, @ContinuousInv G (ts' i) _) : @ContinuousInv G (⨅ i, ts' i) _ := by rw [← sInf_range] exact continuousInv_sInf (Set.forall_mem_range.mpr h') #align has_continuous_inv_infi continuousInv_iInf #align has_continuous_neg_infi continuousNeg_iInf @[to_additive] theorem continuousInv_inf {t₁ t₂ : TopologicalSpace G} (h₁ : @ContinuousInv G t₁ _) (h₂ : @ContinuousInv G t₂ _) : @ContinuousInv G (t₁ ⊓ t₂) _ := by rw [inf_eq_iInf] refine continuousInv_iInf fun b => ?_ cases b <;> assumption #align has_continuous_inv_inf continuousInv_inf #align has_continuous_neg_inf continuousNeg_inf end LatticeOps @[to_additive] theorem Inducing.continuousInv {G H : Type*} [Inv G] [Inv H] [TopologicalSpace G] [TopologicalSpace H] [ContinuousInv H] {f : G → H} (hf : Inducing f) (hf_inv : ∀ x, f x⁻¹ = (f x)⁻¹) : ContinuousInv G := ⟨hf.continuous_iff.2 <| by simpa only [(· ∘ ·), hf_inv] using hf.continuous.inv⟩ #align inducing.has_continuous_inv Inducing.continuousInv #align inducing.has_continuous_neg Inducing.continuousNeg section TopologicalGroup /-! ### Topological groups A topological group is a group in which the multiplication and inversion operations are continuous. Topological additive groups are defined in the same way. Equivalently, we can require that the division operation `x y ↦ x * y⁻¹` (resp., subtraction) is continuous. -/ -- Porting note (#11215): TODO should this docstring be extended -- to match the multiplicative version? /-- A topological (additive) group is a group in which the addition and negation operations are continuous. -/ class TopologicalAddGroup (G : Type u) [TopologicalSpace G] [AddGroup G] extends ContinuousAdd G, ContinuousNeg G : Prop #align topological_add_group TopologicalAddGroup /-- A topological group is a group in which the multiplication and inversion operations are continuous. When you declare an instance that does not already have a `UniformSpace` instance, you should also provide an instance of `UniformSpace` and `UniformGroup` using `TopologicalGroup.toUniformSpace` and `topologicalCommGroup_isUniform`. -/ -- Porting note: check that these ↑ names exist once they've been ported in the future. @[to_additive] class TopologicalGroup (G : Type*) [TopologicalSpace G] [Group G] extends ContinuousMul G, ContinuousInv G : Prop #align topological_group TopologicalGroup --#align topological_add_group TopologicalAddGroup section Conj instance ConjAct.units_continuousConstSMul {M} [Monoid M] [TopologicalSpace M] [ContinuousMul M] : ContinuousConstSMul (ConjAct Mˣ) M := ⟨fun _ => (continuous_const.mul continuous_id).mul continuous_const⟩ #align conj_act.units_has_continuous_const_smul ConjAct.units_continuousConstSMul variable [TopologicalSpace G] [Inv G] [Mul G] [ContinuousMul G] /-- Conjugation is jointly continuous on `G × G` when both `mul` and `inv` are continuous. -/ @[to_additive "Conjugation is jointly continuous on `G × G` when both `add` and `neg` are continuous."] theorem TopologicalGroup.continuous_conj_prod [ContinuousInv G] : Continuous fun g : G × G => g.fst * g.snd * g.fst⁻¹ := continuous_mul.mul (continuous_inv.comp continuous_fst) #align topological_group.continuous_conj_prod TopologicalGroup.continuous_conj_prod #align topological_add_group.continuous_conj_sum TopologicalAddGroup.continuous_conj_sum /-- Conjugation by a fixed element is continuous when `mul` is continuous. -/ @[to_additive (attr := continuity) "Conjugation by a fixed element is continuous when `add` is continuous."] theorem TopologicalGroup.continuous_conj (g : G) : Continuous fun h : G => g * h * g⁻¹ := (continuous_mul_right g⁻¹).comp (continuous_mul_left g) #align topological_group.continuous_conj TopologicalGroup.continuous_conj #align topological_add_group.continuous_conj TopologicalAddGroup.continuous_conj /-- Conjugation acting on fixed element of the group is continuous when both `mul` and `inv` are continuous. -/ @[to_additive (attr := continuity) "Conjugation acting on fixed element of the additive group is continuous when both `add` and `neg` are continuous."] theorem TopologicalGroup.continuous_conj' [ContinuousInv G] (h : G) : Continuous fun g : G => g * h * g⁻¹ := (continuous_mul_right h).mul continuous_inv #align topological_group.continuous_conj' TopologicalGroup.continuous_conj' #align topological_add_group.continuous_conj' TopologicalAddGroup.continuous_conj' end Conj variable [TopologicalSpace G] [Group G] [TopologicalGroup G] [TopologicalSpace α] {f : α → G} {s : Set α} {x : α} instance : TopologicalGroup (ULift G) where section ZPow @[to_additive (attr := continuity)] theorem continuous_zpow : ∀ z : ℤ, Continuous fun a : G => a ^ z | Int.ofNat n => by simpa using continuous_pow n | Int.negSucc n => by simpa using (continuous_pow (n + 1)).inv #align continuous_zpow continuous_zpow #align continuous_zsmul continuous_zsmul instance AddGroup.continuousConstSMul_int {A} [AddGroup A] [TopologicalSpace A] [TopologicalAddGroup A] : ContinuousConstSMul ℤ A := ⟨continuous_zsmul⟩ #align add_group.has_continuous_const_smul_int AddGroup.continuousConstSMul_int instance AddGroup.continuousSMul_int {A} [AddGroup A] [TopologicalSpace A] [TopologicalAddGroup A] : ContinuousSMul ℤ A := ⟨continuous_prod_of_discrete_left.mpr continuous_zsmul⟩ #align add_group.has_continuous_smul_int AddGroup.continuousSMul_int @[to_additive (attr := continuity, fun_prop)] theorem Continuous.zpow {f : α → G} (h : Continuous f) (z : ℤ) : Continuous fun b => f b ^ z := (continuous_zpow z).comp h #align continuous.zpow Continuous.zpow #align continuous.zsmul Continuous.zsmul @[to_additive] theorem continuousOn_zpow {s : Set G} (z : ℤ) : ContinuousOn (fun x => x ^ z) s := (continuous_zpow z).continuousOn #align continuous_on_zpow continuousOn_zpow #align continuous_on_zsmul continuousOn_zsmul @[to_additive] theorem continuousAt_zpow (x : G) (z : ℤ) : ContinuousAt (fun x => x ^ z) x := (continuous_zpow z).continuousAt #align continuous_at_zpow continuousAt_zpow #align continuous_at_zsmul continuousAt_zsmul @[to_additive] theorem Filter.Tendsto.zpow {α} {l : Filter α} {f : α → G} {x : G} (hf : Tendsto f l (𝓝 x)) (z : ℤ) : Tendsto (fun x => f x ^ z) l (𝓝 (x ^ z)) := (continuousAt_zpow _ _).tendsto.comp hf #align filter.tendsto.zpow Filter.Tendsto.zpow #align filter.tendsto.zsmul Filter.Tendsto.zsmul @[to_additive] theorem ContinuousWithinAt.zpow {f : α → G} {x : α} {s : Set α} (hf : ContinuousWithinAt f s x) (z : ℤ) : ContinuousWithinAt (fun x => f x ^ z) s x := Filter.Tendsto.zpow hf z #align continuous_within_at.zpow ContinuousWithinAt.zpow #align continuous_within_at.zsmul ContinuousWithinAt.zsmul @[to_additive (attr := fun_prop)] theorem ContinuousAt.zpow {f : α → G} {x : α} (hf : ContinuousAt f x) (z : ℤ) : ContinuousAt (fun x => f x ^ z) x := Filter.Tendsto.zpow hf z #align continuous_at.zpow ContinuousAt.zpow #align continuous_at.zsmul ContinuousAt.zsmul @[to_additive (attr := fun_prop)] theorem ContinuousOn.zpow {f : α → G} {s : Set α} (hf : ContinuousOn f s) (z : ℤ) : ContinuousOn (fun x => f x ^ z) s := fun x hx => (hf x hx).zpow z #align continuous_on.zpow ContinuousOn.zpow #align continuous_on.zsmul ContinuousOn.zsmul end ZPow section OrderedCommGroup variable [TopologicalSpace H] [OrderedCommGroup H] [ContinuousInv H] @[to_additive] theorem tendsto_inv_nhdsWithin_Ioi {a : H} : Tendsto Inv.inv (𝓝[>] a) (𝓝[<] a⁻¹) := (continuous_inv.tendsto a).inf <| by simp [tendsto_principal_principal] #align tendsto_inv_nhds_within_Ioi tendsto_inv_nhdsWithin_Ioi #align tendsto_neg_nhds_within_Ioi tendsto_neg_nhdsWithin_Ioi @[to_additive] theorem tendsto_inv_nhdsWithin_Iio {a : H} : Tendsto Inv.inv (𝓝[<] a) (𝓝[>] a⁻¹) := (continuous_inv.tendsto a).inf <| by simp [tendsto_principal_principal] #align tendsto_inv_nhds_within_Iio tendsto_inv_nhdsWithin_Iio #align tendsto_neg_nhds_within_Iio tendsto_neg_nhdsWithin_Iio @[to_additive] theorem tendsto_inv_nhdsWithin_Ioi_inv {a : H} : Tendsto Inv.inv (𝓝[>] a⁻¹) (𝓝[<] a) := by simpa only [inv_inv] using @tendsto_inv_nhdsWithin_Ioi _ _ _ _ a⁻¹ #align tendsto_inv_nhds_within_Ioi_inv tendsto_inv_nhdsWithin_Ioi_inv #align tendsto_neg_nhds_within_Ioi_neg tendsto_neg_nhdsWithin_Ioi_neg @[to_additive] theorem tendsto_inv_nhdsWithin_Iio_inv {a : H} : Tendsto Inv.inv (𝓝[<] a⁻¹) (𝓝[>] a) := by simpa only [inv_inv] using @tendsto_inv_nhdsWithin_Iio _ _ _ _ a⁻¹ #align tendsto_inv_nhds_within_Iio_inv tendsto_inv_nhdsWithin_Iio_inv #align tendsto_neg_nhds_within_Iio_neg tendsto_neg_nhdsWithin_Iio_neg @[to_additive] theorem tendsto_inv_nhdsWithin_Ici {a : H} : Tendsto Inv.inv (𝓝[≥] a) (𝓝[≤] a⁻¹) := (continuous_inv.tendsto a).inf <| by simp [tendsto_principal_principal] #align tendsto_inv_nhds_within_Ici tendsto_inv_nhdsWithin_Ici #align tendsto_neg_nhds_within_Ici tendsto_neg_nhdsWithin_Ici @[to_additive] theorem tendsto_inv_nhdsWithin_Iic {a : H} : Tendsto Inv.inv (𝓝[≤] a) (𝓝[≥] a⁻¹) := (continuous_inv.tendsto a).inf <| by simp [tendsto_principal_principal] #align tendsto_inv_nhds_within_Iic tendsto_inv_nhdsWithin_Iic #align tendsto_neg_nhds_within_Iic tendsto_neg_nhdsWithin_Iic @[to_additive]
Mathlib/Topology/Algebra/Group/Basic.lean
623
624
theorem tendsto_inv_nhdsWithin_Ici_inv {a : H} : Tendsto Inv.inv (𝓝[≥] a⁻¹) (𝓝[≤] a) := by
simpa only [inv_inv] using @tendsto_inv_nhdsWithin_Ici _ _ _ _ a⁻¹
/- Copyright (c) 2017 Johannes Hölzl. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Johannes Hölzl, Mario Carneiro, Patrick Massot -/ import Mathlib.Topology.Maps import Mathlib.Topology.NhdsSet #align_import topology.constructions from "leanprover-community/mathlib"@"f7ebde7ee0d1505dfccac8644ae12371aa3c1c9f" /-! # Constructions of new topological spaces from old ones This file constructs products, sums, subtypes and quotients of topological spaces and sets up their basic theory, such as criteria for maps into or out of these constructions to be continuous; descriptions of the open sets, neighborhood filters, and generators of these constructions; and their behavior with respect to embeddings and other specific classes of maps. ## Implementation note The constructed topologies are defined using induced and coinduced topologies along with the complete lattice structure on topologies. Their universal properties (for example, a map `X → Y × Z` is continuous if and only if both projections `X → Y`, `X → Z` are) follow easily using order-theoretic descriptions of continuity. With more work we can also extract descriptions of the open sets, neighborhood filters and so on. ## Tags product, sum, disjoint union, subspace, quotient space -/ noncomputable section open scoped Classical open Topology TopologicalSpace Set Filter Function universe u v variable {X : Type u} {Y : Type v} {Z W ε ζ : Type*} section Constructions instance instTopologicalSpaceSubtype {p : X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Subtype p) := induced (↑) t instance {r : X → X → Prop} [t : TopologicalSpace X] : TopologicalSpace (Quot r) := coinduced (Quot.mk r) t instance instTopologicalSpaceQuotient {s : Setoid X} [t : TopologicalSpace X] : TopologicalSpace (Quotient s) := coinduced Quotient.mk' t instance instTopologicalSpaceProd [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X × Y) := induced Prod.fst t₁ ⊓ induced Prod.snd t₂ instance instTopologicalSpaceSum [t₁ : TopologicalSpace X] [t₂ : TopologicalSpace Y] : TopologicalSpace (X ⊕ Y) := coinduced Sum.inl t₁ ⊔ coinduced Sum.inr t₂ instance instTopologicalSpaceSigma {ι : Type*} {X : ι → Type v} [t₂ : ∀ i, TopologicalSpace (X i)] : TopologicalSpace (Sigma X) := ⨆ i, coinduced (Sigma.mk i) (t₂ i) instance Pi.topologicalSpace {ι : Type*} {Y : ι → Type v} [t₂ : (i : ι) → TopologicalSpace (Y i)] : TopologicalSpace ((i : ι) → Y i) := ⨅ i, induced (fun f => f i) (t₂ i) #align Pi.topological_space Pi.topologicalSpace instance ULift.topologicalSpace [t : TopologicalSpace X] : TopologicalSpace (ULift.{v, u} X) := t.induced ULift.down #align ulift.topological_space ULift.topologicalSpace /-! ### `Additive`, `Multiplicative` The topology on those type synonyms is inherited without change. -/ section variable [TopologicalSpace X] open Additive Multiplicative instance : TopologicalSpace (Additive X) := ‹TopologicalSpace X› instance : TopologicalSpace (Multiplicative X) := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology (Additive X) := ‹DiscreteTopology X› instance [DiscreteTopology X] : DiscreteTopology (Multiplicative X) := ‹DiscreteTopology X› theorem continuous_ofMul : Continuous (ofMul : X → Additive X) := continuous_id #align continuous_of_mul continuous_ofMul theorem continuous_toMul : Continuous (toMul : Additive X → X) := continuous_id #align continuous_to_mul continuous_toMul theorem continuous_ofAdd : Continuous (ofAdd : X → Multiplicative X) := continuous_id #align continuous_of_add continuous_ofAdd theorem continuous_toAdd : Continuous (toAdd : Multiplicative X → X) := continuous_id #align continuous_to_add continuous_toAdd theorem isOpenMap_ofMul : IsOpenMap (ofMul : X → Additive X) := IsOpenMap.id #align is_open_map_of_mul isOpenMap_ofMul theorem isOpenMap_toMul : IsOpenMap (toMul : Additive X → X) := IsOpenMap.id #align is_open_map_to_mul isOpenMap_toMul theorem isOpenMap_ofAdd : IsOpenMap (ofAdd : X → Multiplicative X) := IsOpenMap.id #align is_open_map_of_add isOpenMap_ofAdd theorem isOpenMap_toAdd : IsOpenMap (toAdd : Multiplicative X → X) := IsOpenMap.id #align is_open_map_to_add isOpenMap_toAdd theorem isClosedMap_ofMul : IsClosedMap (ofMul : X → Additive X) := IsClosedMap.id #align is_closed_map_of_mul isClosedMap_ofMul theorem isClosedMap_toMul : IsClosedMap (toMul : Additive X → X) := IsClosedMap.id #align is_closed_map_to_mul isClosedMap_toMul theorem isClosedMap_ofAdd : IsClosedMap (ofAdd : X → Multiplicative X) := IsClosedMap.id #align is_closed_map_of_add isClosedMap_ofAdd theorem isClosedMap_toAdd : IsClosedMap (toAdd : Multiplicative X → X) := IsClosedMap.id #align is_closed_map_to_add isClosedMap_toAdd theorem nhds_ofMul (x : X) : 𝓝 (ofMul x) = map ofMul (𝓝 x) := rfl #align nhds_of_mul nhds_ofMul theorem nhds_ofAdd (x : X) : 𝓝 (ofAdd x) = map ofAdd (𝓝 x) := rfl #align nhds_of_add nhds_ofAdd theorem nhds_toMul (x : Additive X) : 𝓝 (toMul x) = map toMul (𝓝 x) := rfl #align nhds_to_mul nhds_toMul theorem nhds_toAdd (x : Multiplicative X) : 𝓝 (toAdd x) = map toAdd (𝓝 x) := rfl #align nhds_to_add nhds_toAdd end /-! ### Order dual The topology on this type synonym is inherited without change. -/ section variable [TopologicalSpace X] open OrderDual instance : TopologicalSpace Xᵒᵈ := ‹TopologicalSpace X› instance [DiscreteTopology X] : DiscreteTopology Xᵒᵈ := ‹DiscreteTopology X› theorem continuous_toDual : Continuous (toDual : X → Xᵒᵈ) := continuous_id #align continuous_to_dual continuous_toDual theorem continuous_ofDual : Continuous (ofDual : Xᵒᵈ → X) := continuous_id #align continuous_of_dual continuous_ofDual theorem isOpenMap_toDual : IsOpenMap (toDual : X → Xᵒᵈ) := IsOpenMap.id #align is_open_map_to_dual isOpenMap_toDual theorem isOpenMap_ofDual : IsOpenMap (ofDual : Xᵒᵈ → X) := IsOpenMap.id #align is_open_map_of_dual isOpenMap_ofDual theorem isClosedMap_toDual : IsClosedMap (toDual : X → Xᵒᵈ) := IsClosedMap.id #align is_closed_map_to_dual isClosedMap_toDual theorem isClosedMap_ofDual : IsClosedMap (ofDual : Xᵒᵈ → X) := IsClosedMap.id #align is_closed_map_of_dual isClosedMap_ofDual theorem nhds_toDual (x : X) : 𝓝 (toDual x) = map toDual (𝓝 x) := rfl #align nhds_to_dual nhds_toDual theorem nhds_ofDual (x : X) : 𝓝 (ofDual x) = map ofDual (𝓝 x) := rfl #align nhds_of_dual nhds_ofDual end theorem Quotient.preimage_mem_nhds [TopologicalSpace X] [s : Setoid X] {V : Set <| Quotient s} {x : X} (hs : V ∈ 𝓝 (Quotient.mk' x)) : Quotient.mk' ⁻¹' V ∈ 𝓝 x := preimage_nhds_coinduced hs #align quotient.preimage_mem_nhds Quotient.preimage_mem_nhds /-- The image of a dense set under `Quotient.mk'` is a dense set. -/ theorem Dense.quotient [Setoid X] [TopologicalSpace X] {s : Set X} (H : Dense s) : Dense (Quotient.mk' '' s) := Quotient.surjective_Quotient_mk''.denseRange.dense_image continuous_coinduced_rng H #align dense.quotient Dense.quotient /-- The composition of `Quotient.mk'` and a function with dense range has dense range. -/ theorem DenseRange.quotient [Setoid X] [TopologicalSpace X] {f : Y → X} (hf : DenseRange f) : DenseRange (Quotient.mk' ∘ f) := Quotient.surjective_Quotient_mk''.denseRange.comp hf continuous_coinduced_rng #align dense_range.quotient DenseRange.quotient theorem continuous_map_of_le {α : Type*} [TopologicalSpace α] {s t : Setoid α} (h : s ≤ t) : Continuous (Setoid.map_of_le h) := continuous_coinduced_rng theorem continuous_map_sInf {α : Type*} [TopologicalSpace α] {S : Set (Setoid α)} {s : Setoid α} (h : s ∈ S) : Continuous (Setoid.map_sInf h) := continuous_coinduced_rng instance {p : X → Prop} [TopologicalSpace X] [DiscreteTopology X] : DiscreteTopology (Subtype p) := ⟨bot_unique fun s _ => ⟨(↑) '' s, isOpen_discrete _, preimage_image_eq _ Subtype.val_injective⟩⟩ instance Sum.discreteTopology [TopologicalSpace X] [TopologicalSpace Y] [h : DiscreteTopology X] [hY : DiscreteTopology Y] : DiscreteTopology (X ⊕ Y) := ⟨sup_eq_bot_iff.2 <| by simp [h.eq_bot, hY.eq_bot]⟩ #align sum.discrete_topology Sum.discreteTopology instance Sigma.discreteTopology {ι : Type*} {Y : ι → Type v} [∀ i, TopologicalSpace (Y i)] [h : ∀ i, DiscreteTopology (Y i)] : DiscreteTopology (Sigma Y) := ⟨iSup_eq_bot.2 fun _ => by simp only [(h _).eq_bot, coinduced_bot]⟩ #align sigma.discrete_topology Sigma.discreteTopology section Top variable [TopologicalSpace X] /- The 𝓝 filter and the subspace topology. -/ theorem mem_nhds_subtype (s : Set X) (x : { x // x ∈ s }) (t : Set { x // x ∈ s }) : t ∈ 𝓝 x ↔ ∃ u ∈ 𝓝 (x : X), Subtype.val ⁻¹' u ⊆ t := mem_nhds_induced _ x t #align mem_nhds_subtype mem_nhds_subtype theorem nhds_subtype (s : Set X) (x : { x // x ∈ s }) : 𝓝 x = comap (↑) (𝓝 (x : X)) := nhds_induced _ x #align nhds_subtype nhds_subtype theorem nhdsWithin_subtype_eq_bot_iff {s t : Set X} {x : s} : 𝓝[((↑) : s → X) ⁻¹' t] x = ⊥ ↔ 𝓝[t] (x : X) ⊓ 𝓟 s = ⊥ := by rw [inf_principal_eq_bot_iff_comap, nhdsWithin, nhdsWithin, comap_inf, comap_principal, nhds_induced] #align nhds_within_subtype_eq_bot_iff nhdsWithin_subtype_eq_bot_iff theorem nhds_ne_subtype_eq_bot_iff {S : Set X} {x : S} : 𝓝[≠] x = ⊥ ↔ 𝓝[≠] (x : X) ⊓ 𝓟 S = ⊥ := by rw [← nhdsWithin_subtype_eq_bot_iff, preimage_compl, ← image_singleton, Subtype.coe_injective.preimage_image] #align nhds_ne_subtype_eq_bot_iff nhds_ne_subtype_eq_bot_iff theorem nhds_ne_subtype_neBot_iff {S : Set X} {x : S} : (𝓝[≠] x).NeBot ↔ (𝓝[≠] (x : X) ⊓ 𝓟 S).NeBot := by rw [neBot_iff, neBot_iff, not_iff_not, nhds_ne_subtype_eq_bot_iff] #align nhds_ne_subtype_ne_bot_iff nhds_ne_subtype_neBot_iff theorem discreteTopology_subtype_iff {S : Set X} : DiscreteTopology S ↔ ∀ x ∈ S, 𝓝[≠] x ⊓ 𝓟 S = ⊥ := by simp_rw [discreteTopology_iff_nhds_ne, SetCoe.forall', nhds_ne_subtype_eq_bot_iff] #align discrete_topology_subtype_iff discreteTopology_subtype_iff end Top /-- A type synonym equipped with the topology whose open sets are the empty set and the sets with finite complements. -/ def CofiniteTopology (X : Type*) := X #align cofinite_topology CofiniteTopology namespace CofiniteTopology /-- The identity equivalence between `` and `CofiniteTopology `. -/ def of : X ≃ CofiniteTopology X := Equiv.refl X #align cofinite_topology.of CofiniteTopology.of instance [Inhabited X] : Inhabited (CofiniteTopology X) where default := of default instance : TopologicalSpace (CofiniteTopology X) where IsOpen s := s.Nonempty → Set.Finite sᶜ isOpen_univ := by simp isOpen_inter s t := by rintro hs ht ⟨x, hxs, hxt⟩ rw [compl_inter] exact (hs ⟨x, hxs⟩).union (ht ⟨x, hxt⟩) isOpen_sUnion := by rintro s h ⟨x, t, hts, hzt⟩ rw [compl_sUnion] exact Finite.sInter (mem_image_of_mem _ hts) (h t hts ⟨x, hzt⟩) theorem isOpen_iff {s : Set (CofiniteTopology X)} : IsOpen s ↔ s.Nonempty → sᶜ.Finite := Iff.rfl #align cofinite_topology.is_open_iff CofiniteTopology.isOpen_iff theorem isOpen_iff' {s : Set (CofiniteTopology X)} : IsOpen s ↔ s = ∅ ∨ sᶜ.Finite := by simp only [isOpen_iff, nonempty_iff_ne_empty, or_iff_not_imp_left] #align cofinite_topology.is_open_iff' CofiniteTopology.isOpen_iff' theorem isClosed_iff {s : Set (CofiniteTopology X)} : IsClosed s ↔ s = univ ∨ s.Finite := by simp only [← isOpen_compl_iff, isOpen_iff', compl_compl, compl_empty_iff] #align cofinite_topology.is_closed_iff CofiniteTopology.isClosed_iff theorem nhds_eq (x : CofiniteTopology X) : 𝓝 x = pure x ⊔ cofinite := by ext U rw [mem_nhds_iff] constructor · rintro ⟨V, hVU, V_op, haV⟩ exact mem_sup.mpr ⟨hVU haV, mem_of_superset (V_op ⟨_, haV⟩) hVU⟩ · rintro ⟨hU : x ∈ U, hU' : Uᶜ.Finite⟩ exact ⟨U, Subset.rfl, fun _ => hU', hU⟩ #align cofinite_topology.nhds_eq CofiniteTopology.nhds_eq theorem mem_nhds_iff {x : CofiniteTopology X} {s : Set (CofiniteTopology X)} : s ∈ 𝓝 x ↔ x ∈ s ∧ sᶜ.Finite := by simp [nhds_eq] #align cofinite_topology.mem_nhds_iff CofiniteTopology.mem_nhds_iff end CofiniteTopology end Constructions section Prod variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W] [TopologicalSpace ε] [TopologicalSpace ζ] -- Porting note (#11215): TODO: Lean 4 fails to deduce implicit args @[simp] theorem continuous_prod_mk {f : X → Y} {g : X → Z} : (Continuous fun x => (f x, g x)) ↔ Continuous f ∧ Continuous g := (@continuous_inf_rng X (Y × Z) _ _ (TopologicalSpace.induced Prod.fst _) (TopologicalSpace.induced Prod.snd _)).trans <| continuous_induced_rng.and continuous_induced_rng #align continuous_prod_mk continuous_prod_mk @[continuity] theorem continuous_fst : Continuous (@Prod.fst X Y) := (continuous_prod_mk.1 continuous_id).1 #align continuous_fst continuous_fst /-- Postcomposing `f` with `Prod.fst` is continuous -/ @[fun_prop] theorem Continuous.fst {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).1 := continuous_fst.comp hf #align continuous.fst Continuous.fst /-- Precomposing `f` with `Prod.fst` is continuous -/ theorem Continuous.fst' {f : X → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.fst := hf.comp continuous_fst #align continuous.fst' Continuous.fst' theorem continuousAt_fst {p : X × Y} : ContinuousAt Prod.fst p := continuous_fst.continuousAt #align continuous_at_fst continuousAt_fst /-- Postcomposing `f` with `Prod.fst` is continuous at `x` -/ @[fun_prop] theorem ContinuousAt.fst {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) : ContinuousAt (fun x : X => (f x).1) x := continuousAt_fst.comp hf #align continuous_at.fst ContinuousAt.fst /-- Precomposing `f` with `Prod.fst` is continuous at `(x, y)` -/ theorem ContinuousAt.fst' {f : X → Z} {x : X} {y : Y} (hf : ContinuousAt f x) : ContinuousAt (fun x : X × Y => f x.fst) (x, y) := ContinuousAt.comp hf continuousAt_fst #align continuous_at.fst' ContinuousAt.fst' /-- Precomposing `f` with `Prod.fst` is continuous at `x : X × Y` -/ theorem ContinuousAt.fst'' {f : X → Z} {x : X × Y} (hf : ContinuousAt f x.fst) : ContinuousAt (fun x : X × Y => f x.fst) x := hf.comp continuousAt_fst #align continuous_at.fst'' ContinuousAt.fst'' theorem Filter.Tendsto.fst_nhds {l : Filter X} {f : X → Y × Z} {p : Y × Z} (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).1) l (𝓝 <| p.1) := continuousAt_fst.tendsto.comp h @[continuity] theorem continuous_snd : Continuous (@Prod.snd X Y) := (continuous_prod_mk.1 continuous_id).2 #align continuous_snd continuous_snd /-- Postcomposing `f` with `Prod.snd` is continuous -/ @[fun_prop] theorem Continuous.snd {f : X → Y × Z} (hf : Continuous f) : Continuous fun x : X => (f x).2 := continuous_snd.comp hf #align continuous.snd Continuous.snd /-- Precomposing `f` with `Prod.snd` is continuous -/ theorem Continuous.snd' {f : Y → Z} (hf : Continuous f) : Continuous fun x : X × Y => f x.snd := hf.comp continuous_snd #align continuous.snd' Continuous.snd' theorem continuousAt_snd {p : X × Y} : ContinuousAt Prod.snd p := continuous_snd.continuousAt #align continuous_at_snd continuousAt_snd /-- Postcomposing `f` with `Prod.snd` is continuous at `x` -/ @[fun_prop] theorem ContinuousAt.snd {f : X → Y × Z} {x : X} (hf : ContinuousAt f x) : ContinuousAt (fun x : X => (f x).2) x := continuousAt_snd.comp hf #align continuous_at.snd ContinuousAt.snd /-- Precomposing `f` with `Prod.snd` is continuous at `(x, y)` -/ theorem ContinuousAt.snd' {f : Y → Z} {x : X} {y : Y} (hf : ContinuousAt f y) : ContinuousAt (fun x : X × Y => f x.snd) (x, y) := ContinuousAt.comp hf continuousAt_snd #align continuous_at.snd' ContinuousAt.snd' /-- Precomposing `f` with `Prod.snd` is continuous at `x : X × Y` -/ theorem ContinuousAt.snd'' {f : Y → Z} {x : X × Y} (hf : ContinuousAt f x.snd) : ContinuousAt (fun x : X × Y => f x.snd) x := hf.comp continuousAt_snd #align continuous_at.snd'' ContinuousAt.snd'' theorem Filter.Tendsto.snd_nhds {l : Filter X} {f : X → Y × Z} {p : Y × Z} (h : Tendsto f l (𝓝 p)) : Tendsto (fun a ↦ (f a).2) l (𝓝 <| p.2) := continuousAt_snd.tendsto.comp h @[continuity, fun_prop] theorem Continuous.prod_mk {f : Z → X} {g : Z → Y} (hf : Continuous f) (hg : Continuous g) : Continuous fun x => (f x, g x) := continuous_prod_mk.2 ⟨hf, hg⟩ #align continuous.prod_mk Continuous.prod_mk @[continuity] theorem Continuous.Prod.mk (x : X) : Continuous fun y : Y => (x, y) := continuous_const.prod_mk continuous_id #align continuous.prod.mk Continuous.Prod.mk @[continuity] theorem Continuous.Prod.mk_left (y : Y) : Continuous fun x : X => (x, y) := continuous_id.prod_mk continuous_const #align continuous.prod.mk_left Continuous.Prod.mk_left /-- If `f x y` is continuous in `x` for all `y ∈ s`, then the set of `x` such that `f x` maps `s` to `t` is closed. -/ lemma IsClosed.setOf_mapsTo {α : Type*} {f : X → α → Z} {s : Set α} {t : Set Z} (ht : IsClosed t) (hf : ∀ a ∈ s, Continuous (f · a)) : IsClosed {x | MapsTo (f x) s t} := by simpa only [MapsTo, setOf_forall] using isClosed_biInter fun y hy ↦ ht.preimage (hf y hy) theorem Continuous.comp₂ {g : X × Y → Z} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) : Continuous fun w => g (e w, f w) := hg.comp <| he.prod_mk hf #align continuous.comp₂ Continuous.comp₂ theorem Continuous.comp₃ {g : X × Y × Z → ε} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) : Continuous fun w => g (e w, f w, k w) := hg.comp₂ he <| hf.prod_mk hk #align continuous.comp₃ Continuous.comp₃ theorem Continuous.comp₄ {g : X × Y × Z × ζ → ε} (hg : Continuous g) {e : W → X} (he : Continuous e) {f : W → Y} (hf : Continuous f) {k : W → Z} (hk : Continuous k) {l : W → ζ} (hl : Continuous l) : Continuous fun w => g (e w, f w, k w, l w) := hg.comp₃ he hf <| hk.prod_mk hl #align continuous.comp₄ Continuous.comp₄ @[continuity] theorem Continuous.prod_map {f : Z → X} {g : W → Y} (hf : Continuous f) (hg : Continuous g) : Continuous fun p : Z × W => (f p.1, g p.2) := hf.fst'.prod_mk hg.snd' #align continuous.prod_map Continuous.prod_map /-- A version of `continuous_inf_dom_left` for binary functions -/ theorem continuous_inf_dom_left₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X} {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z} (h : by haveI := ta1; haveI := tb1; exact Continuous fun p : X × Y => f p.1 p.2) : by haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by have ha := @continuous_inf_dom_left _ _ id ta1 ta2 ta1 (@continuous_id _ (id _)) have hb := @continuous_inf_dom_left _ _ id tb1 tb2 tb1 (@continuous_id _ (id _)) have h_continuous_id := @Continuous.prod_map _ _ _ _ ta1 tb1 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id #align continuous_inf_dom_left₂ continuous_inf_dom_left₂ /-- A version of `continuous_inf_dom_right` for binary functions -/ theorem continuous_inf_dom_right₂ {X Y Z} {f : X → Y → Z} {ta1 ta2 : TopologicalSpace X} {tb1 tb2 : TopologicalSpace Y} {tc1 : TopologicalSpace Z} (h : by haveI := ta2; haveI := tb2; exact Continuous fun p : X × Y => f p.1 p.2) : by haveI := ta1 ⊓ ta2; haveI := tb1 ⊓ tb2; exact Continuous fun p : X × Y => f p.1 p.2 := by have ha := @continuous_inf_dom_right _ _ id ta1 ta2 ta2 (@continuous_id _ (id _)) have hb := @continuous_inf_dom_right _ _ id tb1 tb2 tb2 (@continuous_id _ (id _)) have h_continuous_id := @Continuous.prod_map _ _ _ _ ta2 tb2 (ta1 ⊓ ta2) (tb1 ⊓ tb2) _ _ ha hb exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ h h_continuous_id #align continuous_inf_dom_right₂ continuous_inf_dom_right₂ /-- A version of `continuous_sInf_dom` for binary functions -/ theorem continuous_sInf_dom₂ {X Y Z} {f : X → Y → Z} {tas : Set (TopologicalSpace X)} {tbs : Set (TopologicalSpace Y)} {tX : TopologicalSpace X} {tY : TopologicalSpace Y} {tc : TopologicalSpace Z} (hX : tX ∈ tas) (hY : tY ∈ tbs) (hf : Continuous fun p : X × Y => f p.1 p.2) : by haveI := sInf tas; haveI := sInf tbs; exact @Continuous _ _ _ tc fun p : X × Y => f p.1 p.2 := by have hX := continuous_sInf_dom hX continuous_id have hY := continuous_sInf_dom hY continuous_id have h_continuous_id := @Continuous.prod_map _ _ _ _ tX tY (sInf tas) (sInf tbs) _ _ hX hY exact @Continuous.comp _ _ _ (id _) (id _) _ _ _ hf h_continuous_id #align continuous_Inf_dom₂ continuous_sInf_dom₂ theorem Filter.Eventually.prod_inl_nhds {p : X → Prop} {x : X} (h : ∀ᶠ x in 𝓝 x, p x) (y : Y) : ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).1 := continuousAt_fst h #align filter.eventually.prod_inl_nhds Filter.Eventually.prod_inl_nhds theorem Filter.Eventually.prod_inr_nhds {p : Y → Prop} {y : Y} (h : ∀ᶠ x in 𝓝 y, p x) (x : X) : ∀ᶠ x in 𝓝 (x, y), p (x : X × Y).2 := continuousAt_snd h #align filter.eventually.prod_inr_nhds Filter.Eventually.prod_inr_nhds theorem Filter.Eventually.prod_mk_nhds {px : X → Prop} {x} (hx : ∀ᶠ x in 𝓝 x, px x) {py : Y → Prop} {y} (hy : ∀ᶠ y in 𝓝 y, py y) : ∀ᶠ p in 𝓝 (x, y), px (p : X × Y).1 ∧ py p.2 := (hx.prod_inl_nhds y).and (hy.prod_inr_nhds x) #align filter.eventually.prod_mk_nhds Filter.Eventually.prod_mk_nhds theorem continuous_swap : Continuous (Prod.swap : X × Y → Y × X) := continuous_snd.prod_mk continuous_fst #align continuous_swap continuous_swap lemma isClosedMap_swap : IsClosedMap (Prod.swap : X × Y → Y × X) := fun s hs ↦ by rw [image_swap_eq_preimage_swap] exact hs.preimage continuous_swap theorem Continuous.uncurry_left {f : X → Y → Z} (x : X) (h : Continuous (uncurry f)) : Continuous (f x) := h.comp (Continuous.Prod.mk _) #align continuous_uncurry_left Continuous.uncurry_left theorem Continuous.uncurry_right {f : X → Y → Z} (y : Y) (h : Continuous (uncurry f)) : Continuous fun a => f a y := h.comp (Continuous.Prod.mk_left _) #align continuous_uncurry_right Continuous.uncurry_right -- 2024-03-09 @[deprecated] alias continuous_uncurry_left := Continuous.uncurry_left @[deprecated] alias continuous_uncurry_right := Continuous.uncurry_right theorem continuous_curry {g : X × Y → Z} (x : X) (h : Continuous g) : Continuous (curry g x) := Continuous.uncurry_left x h #align continuous_curry continuous_curry theorem IsOpen.prod {s : Set X} {t : Set Y} (hs : IsOpen s) (ht : IsOpen t) : IsOpen (s ×ˢ t) := (hs.preimage continuous_fst).inter (ht.preimage continuous_snd) #align is_open.prod IsOpen.prod -- Porting note (#11215): TODO: Lean fails to find `t₁` and `t₂` by unification theorem nhds_prod_eq {x : X} {y : Y} : 𝓝 (x, y) = 𝓝 x ×ˢ 𝓝 y := by dsimp only [SProd.sprod] rw [Filter.prod, instTopologicalSpaceProd, nhds_inf (t₁ := TopologicalSpace.induced Prod.fst _) (t₂ := TopologicalSpace.induced Prod.snd _), nhds_induced, nhds_induced] #align nhds_prod_eq nhds_prod_eq -- Porting note: moved from `Topology.ContinuousOn` theorem nhdsWithin_prod_eq (x : X) (y : Y) (s : Set X) (t : Set Y) : 𝓝[s ×ˢ t] (x, y) = 𝓝[s] x ×ˢ 𝓝[t] y := by simp only [nhdsWithin, nhds_prod_eq, ← prod_inf_prod, prod_principal_principal] #align nhds_within_prod_eq nhdsWithin_prod_eq #noalign continuous_uncurry_of_discrete_topology theorem mem_nhds_prod_iff {x : X} {y : Y} {s : Set (X × Y)} : s ∈ 𝓝 (x, y) ↔ ∃ u ∈ 𝓝 x, ∃ v ∈ 𝓝 y, u ×ˢ v ⊆ s := by rw [nhds_prod_eq, mem_prod_iff] #align mem_nhds_prod_iff mem_nhds_prod_iff theorem mem_nhdsWithin_prod_iff {x : X} {y : Y} {s : Set (X × Y)} {tx : Set X} {ty : Set Y} : s ∈ 𝓝[tx ×ˢ ty] (x, y) ↔ ∃ u ∈ 𝓝[tx] x, ∃ v ∈ 𝓝[ty] y, u ×ˢ v ⊆ s := by rw [nhdsWithin_prod_eq, mem_prod_iff] -- Porting note: moved up theorem Filter.HasBasis.prod_nhds {ιX ιY : Type*} {px : ιX → Prop} {py : ιY → Prop} {sx : ιX → Set X} {sy : ιY → Set Y} {x : X} {y : Y} (hx : (𝓝 x).HasBasis px sx) (hy : (𝓝 y).HasBasis py sy) : (𝓝 (x, y)).HasBasis (fun i : ιX × ιY => px i.1 ∧ py i.2) fun i => sx i.1 ×ˢ sy i.2 := by rw [nhds_prod_eq] exact hx.prod hy #align filter.has_basis.prod_nhds Filter.HasBasis.prod_nhds -- Porting note: moved up theorem Filter.HasBasis.prod_nhds' {ιX ιY : Type*} {pX : ιX → Prop} {pY : ιY → Prop} {sx : ιX → Set X} {sy : ιY → Set Y} {p : X × Y} (hx : (𝓝 p.1).HasBasis pX sx) (hy : (𝓝 p.2).HasBasis pY sy) : (𝓝 p).HasBasis (fun i : ιX × ιY => pX i.1 ∧ pY i.2) fun i => sx i.1 ×ˢ sy i.2 := hx.prod_nhds hy #align filter.has_basis.prod_nhds' Filter.HasBasis.prod_nhds' theorem mem_nhds_prod_iff' {x : X} {y : Y} {s : Set (X × Y)} : s ∈ 𝓝 (x, y) ↔ ∃ u v, IsOpen u ∧ x ∈ u ∧ IsOpen v ∧ y ∈ v ∧ u ×ˢ v ⊆ s := ((nhds_basis_opens x).prod_nhds (nhds_basis_opens y)).mem_iff.trans <| by simp only [Prod.exists, and_comm, and_assoc, and_left_comm] #align mem_nhds_prod_iff' mem_nhds_prod_iff' theorem Prod.tendsto_iff {X} (seq : X → Y × Z) {f : Filter X} (p : Y × Z) : Tendsto seq f (𝓝 p) ↔ Tendsto (fun n => (seq n).fst) f (𝓝 p.fst) ∧ Tendsto (fun n => (seq n).snd) f (𝓝 p.snd) := by rw [nhds_prod_eq, Filter.tendsto_prod_iff'] #align prod.tendsto_iff Prod.tendsto_iff instance [DiscreteTopology X] [DiscreteTopology Y] : DiscreteTopology (X × Y) := discreteTopology_iff_nhds.2 fun (a, b) => by rw [nhds_prod_eq, nhds_discrete X, nhds_discrete Y, prod_pure_pure] theorem prod_mem_nhds_iff {s : Set X} {t : Set Y} {x : X} {y : Y} : s ×ˢ t ∈ 𝓝 (x, y) ↔ s ∈ 𝓝 x ∧ t ∈ 𝓝 y := by rw [nhds_prod_eq, prod_mem_prod_iff] #align prod_mem_nhds_iff prod_mem_nhds_iff theorem prod_mem_nhds {s : Set X} {t : Set Y} {x : X} {y : Y} (hx : s ∈ 𝓝 x) (hy : t ∈ 𝓝 y) : s ×ˢ t ∈ 𝓝 (x, y) := prod_mem_nhds_iff.2 ⟨hx, hy⟩ #align prod_mem_nhds prod_mem_nhds theorem isOpen_setOf_disjoint_nhds_nhds : IsOpen { p : X × X | Disjoint (𝓝 p.1) (𝓝 p.2) } := by simp only [isOpen_iff_mem_nhds, Prod.forall, mem_setOf_eq] intro x y h obtain ⟨U, hU, V, hV, hd⟩ := ((nhds_basis_opens x).disjoint_iff (nhds_basis_opens y)).mp h exact mem_nhds_prod_iff'.mpr ⟨U, V, hU.2, hU.1, hV.2, hV.1, fun ⟨x', y'⟩ ⟨hx', hy'⟩ => disjoint_of_disjoint_of_mem hd (hU.2.mem_nhds hx') (hV.2.mem_nhds hy')⟩ #align is_open_set_of_disjoint_nhds_nhds isOpen_setOf_disjoint_nhds_nhds theorem Filter.Eventually.prod_nhds {p : X → Prop} {q : Y → Prop} {x : X} {y : Y} (hx : ∀ᶠ x in 𝓝 x, p x) (hy : ∀ᶠ y in 𝓝 y, q y) : ∀ᶠ z : X × Y in 𝓝 (x, y), p z.1 ∧ q z.2 := prod_mem_nhds hx hy #align filter.eventually.prod_nhds Filter.Eventually.prod_nhds theorem nhds_swap (x : X) (y : Y) : 𝓝 (x, y) = (𝓝 (y, x)).map Prod.swap := by rw [nhds_prod_eq, Filter.prod_comm, nhds_prod_eq]; rfl #align nhds_swap nhds_swap theorem Filter.Tendsto.prod_mk_nhds {γ} {x : X} {y : Y} {f : Filter γ} {mx : γ → X} {my : γ → Y} (hx : Tendsto mx f (𝓝 x)) (hy : Tendsto my f (𝓝 y)) : Tendsto (fun c => (mx c, my c)) f (𝓝 (x, y)) := by rw [nhds_prod_eq]; exact Filter.Tendsto.prod_mk hx hy #align filter.tendsto.prod_mk_nhds Filter.Tendsto.prod_mk_nhds theorem Filter.Eventually.curry_nhds {p : X × Y → Prop} {x : X} {y : Y} (h : ∀ᶠ x in 𝓝 (x, y), p x) : ∀ᶠ x' in 𝓝 x, ∀ᶠ y' in 𝓝 y, p (x', y') := by rw [nhds_prod_eq] at h exact h.curry #align filter.eventually.curry_nhds Filter.Eventually.curry_nhds @[fun_prop] theorem ContinuousAt.prod {f : X → Y} {g : X → Z} {x : X} (hf : ContinuousAt f x) (hg : ContinuousAt g x) : ContinuousAt (fun x => (f x, g x)) x := hf.prod_mk_nhds hg #align continuous_at.prod ContinuousAt.prod theorem ContinuousAt.prod_map {f : X → Z} {g : Y → W} {p : X × Y} (hf : ContinuousAt f p.fst) (hg : ContinuousAt g p.snd) : ContinuousAt (fun p : X × Y => (f p.1, g p.2)) p := hf.fst''.prod hg.snd'' #align continuous_at.prod_map ContinuousAt.prod_map theorem ContinuousAt.prod_map' {f : X → Z} {g : Y → W} {x : X} {y : Y} (hf : ContinuousAt f x) (hg : ContinuousAt g y) : ContinuousAt (fun p : X × Y => (f p.1, g p.2)) (x, y) := hf.fst'.prod hg.snd' #align continuous_at.prod_map' ContinuousAt.prod_map' theorem ContinuousAt.comp₂ {f : Y × Z → W} {g : X → Y} {h : X → Z} {x : X} (hf : ContinuousAt f (g x, h x)) (hg : ContinuousAt g x) (hh : ContinuousAt h x) : ContinuousAt (fun x ↦ f (g x, h x)) x := ContinuousAt.comp hf (hg.prod hh) theorem ContinuousAt.comp₂_of_eq {f : Y × Z → W} {g : X → Y} {h : X → Z} {x : X} {y : Y × Z} (hf : ContinuousAt f y) (hg : ContinuousAt g x) (hh : ContinuousAt h x) (e : (g x, h x) = y) : ContinuousAt (fun x ↦ f (g x, h x)) x := by rw [← e] at hf exact hf.comp₂ hg hh /-- Continuous functions on products are continuous in their first argument -/ theorem Continuous.curry_left {f : X × Y → Z} (hf : Continuous f) {y : Y} : Continuous fun x ↦ f (x, y) := hf.comp (continuous_id.prod_mk continuous_const) alias Continuous.along_fst := Continuous.curry_left /-- Continuous functions on products are continuous in their second argument -/ theorem Continuous.curry_right {f : X × Y → Z} (hf : Continuous f) {x : X} : Continuous fun y ↦ f (x, y) := hf.comp (continuous_const.prod_mk continuous_id) alias Continuous.along_snd := Continuous.curry_right -- todo: prove a version of `generateFrom_union` with `image2 (∩) s t` in the LHS and use it here theorem prod_generateFrom_generateFrom_eq {X Y : Type*} {s : Set (Set X)} {t : Set (Set Y)} (hs : ⋃₀ s = univ) (ht : ⋃₀ t = univ) : @instTopologicalSpaceProd X Y (generateFrom s) (generateFrom t) = generateFrom (image2 (· ×ˢ ·) s t) := let G := generateFrom (image2 (· ×ˢ ·) s t) le_antisymm (le_generateFrom fun g ⟨u, hu, v, hv, g_eq⟩ => g_eq.symm ▸ @IsOpen.prod _ _ (generateFrom s) (generateFrom t) _ _ (GenerateOpen.basic _ hu) (GenerateOpen.basic _ hv)) (le_inf (coinduced_le_iff_le_induced.mp <| le_generateFrom fun u hu => have : ⋃ v ∈ t, u ×ˢ v = Prod.fst ⁻¹' u := by simp_rw [← prod_iUnion, ← sUnion_eq_biUnion, ht, prod_univ] show G.IsOpen (Prod.fst ⁻¹' u) by rw [← this] exact isOpen_iUnion fun v => isOpen_iUnion fun hv => GenerateOpen.basic _ ⟨_, hu, _, hv, rfl⟩) (coinduced_le_iff_le_induced.mp <| le_generateFrom fun v hv => have : ⋃ u ∈ s, u ×ˢ v = Prod.snd ⁻¹' v := by simp_rw [← iUnion_prod_const, ← sUnion_eq_biUnion, hs, univ_prod] show G.IsOpen (Prod.snd ⁻¹' v) by rw [← this] exact isOpen_iUnion fun u => isOpen_iUnion fun hu => GenerateOpen.basic _ ⟨_, hu, _, hv, rfl⟩)) #align prod_generate_from_generate_from_eq prod_generateFrom_generateFrom_eq -- todo: use the previous lemma? theorem prod_eq_generateFrom : instTopologicalSpaceProd = generateFrom { g | ∃ (s : Set X) (t : Set Y), IsOpen s ∧ IsOpen t ∧ g = s ×ˢ t } := le_antisymm (le_generateFrom fun g ⟨s, t, hs, ht, g_eq⟩ => g_eq.symm ▸ hs.prod ht) (le_inf (forall_mem_image.2 fun t ht => GenerateOpen.basic _ ⟨t, univ, by simpa [Set.prod_eq] using ht⟩) (forall_mem_image.2 fun t ht => GenerateOpen.basic _ ⟨univ, t, by simpa [Set.prod_eq] using ht⟩)) #align prod_eq_generate_from prod_eq_generateFrom -- Porting note (#11215): TODO: align with `mem_nhds_prod_iff'` theorem isOpen_prod_iff {s : Set (X × Y)} : IsOpen s ↔ ∀ a b, (a, b) ∈ s → ∃ u v, IsOpen u ∧ IsOpen v ∧ a ∈ u ∧ b ∈ v ∧ u ×ˢ v ⊆ s := isOpen_iff_mem_nhds.trans <| by simp_rw [Prod.forall, mem_nhds_prod_iff', and_left_comm] #align is_open_prod_iff isOpen_prod_iff /-- A product of induced topologies is induced by the product map -/ theorem prod_induced_induced (f : X → Y) (g : Z → W) : @instTopologicalSpaceProd X Z (induced f ‹_›) (induced g ‹_›) = induced (fun p => (f p.1, g p.2)) instTopologicalSpaceProd := by delta instTopologicalSpaceProd simp_rw [induced_inf, induced_compose] rfl #align prod_induced_induced prod_induced_induced #noalign continuous_uncurry_of_discrete_topology_left /-- Given a neighborhood `s` of `(x, x)`, then `(x, x)` has a square open neighborhood that is a subset of `s`. -/ theorem exists_nhds_square {s : Set (X × X)} {x : X} (hx : s ∈ 𝓝 (x, x)) : ∃ U : Set X, IsOpen U ∧ x ∈ U ∧ U ×ˢ U ⊆ s := by simpa [nhds_prod_eq, (nhds_basis_opens x).prod_self.mem_iff, and_assoc, and_left_comm] using hx #align exists_nhds_square exists_nhds_square /-- `Prod.fst` maps neighborhood of `x : X × Y` within the section `Prod.snd ⁻¹' {x.2}` to `𝓝 x.1`. -/ theorem map_fst_nhdsWithin (x : X × Y) : map Prod.fst (𝓝[Prod.snd ⁻¹' {x.2}] x) = 𝓝 x.1 := by refine le_antisymm (continuousAt_fst.mono_left inf_le_left) fun s hs => ?_ rcases x with ⟨x, y⟩ rw [mem_map, nhdsWithin, mem_inf_principal, mem_nhds_prod_iff] at hs rcases hs with ⟨u, hu, v, hv, H⟩ simp only [prod_subset_iff, mem_singleton_iff, mem_setOf_eq, mem_preimage] at H exact mem_of_superset hu fun z hz => H _ hz _ (mem_of_mem_nhds hv) rfl #align map_fst_nhds_within map_fst_nhdsWithin @[simp] theorem map_fst_nhds (x : X × Y) : map Prod.fst (𝓝 x) = 𝓝 x.1 := le_antisymm continuousAt_fst <| (map_fst_nhdsWithin x).symm.trans_le (map_mono inf_le_left) #align map_fst_nhds map_fst_nhds /-- The first projection in a product of topological spaces sends open sets to open sets. -/ theorem isOpenMap_fst : IsOpenMap (@Prod.fst X Y) := isOpenMap_iff_nhds_le.2 fun x => (map_fst_nhds x).ge #align is_open_map_fst isOpenMap_fst /-- `Prod.snd` maps neighborhood of `x : X × Y` within the section `Prod.fst ⁻¹' {x.1}` to `𝓝 x.2`. -/ theorem map_snd_nhdsWithin (x : X × Y) : map Prod.snd (𝓝[Prod.fst ⁻¹' {x.1}] x) = 𝓝 x.2 := by refine le_antisymm (continuousAt_snd.mono_left inf_le_left) fun s hs => ?_ rcases x with ⟨x, y⟩ rw [mem_map, nhdsWithin, mem_inf_principal, mem_nhds_prod_iff] at hs rcases hs with ⟨u, hu, v, hv, H⟩ simp only [prod_subset_iff, mem_singleton_iff, mem_setOf_eq, mem_preimage] at H exact mem_of_superset hv fun z hz => H _ (mem_of_mem_nhds hu) _ hz rfl #align map_snd_nhds_within map_snd_nhdsWithin @[simp] theorem map_snd_nhds (x : X × Y) : map Prod.snd (𝓝 x) = 𝓝 x.2 := le_antisymm continuousAt_snd <| (map_snd_nhdsWithin x).symm.trans_le (map_mono inf_le_left) #align map_snd_nhds map_snd_nhds /-- The second projection in a product of topological spaces sends open sets to open sets. -/ theorem isOpenMap_snd : IsOpenMap (@Prod.snd X Y) := isOpenMap_iff_nhds_le.2 fun x => (map_snd_nhds x).ge #align is_open_map_snd isOpenMap_snd /-- A product set is open in a product space if and only if each factor is open, or one of them is empty -/ theorem isOpen_prod_iff' {s : Set X} {t : Set Y} : IsOpen (s ×ˢ t) ↔ IsOpen s ∧ IsOpen t ∨ s = ∅ ∨ t = ∅ := by rcases (s ×ˢ t).eq_empty_or_nonempty with h | h · simp [h, prod_eq_empty_iff.1 h] · have st : s.Nonempty ∧ t.Nonempty := prod_nonempty_iff.1 h constructor · intro (H : IsOpen (s ×ˢ t)) refine Or.inl ⟨?_, ?_⟩ · show IsOpen s rw [← fst_image_prod s st.2] exact isOpenMap_fst _ H · show IsOpen t rw [← snd_image_prod st.1 t] exact isOpenMap_snd _ H · intro H simp only [st.1.ne_empty, st.2.ne_empty, not_false_iff, or_false_iff] at H exact H.1.prod H.2 #align is_open_prod_iff' isOpen_prod_iff' theorem closure_prod_eq {s : Set X} {t : Set Y} : closure (s ×ˢ t) = closure s ×ˢ closure t := ext fun ⟨a, b⟩ => by simp_rw [mem_prod, mem_closure_iff_nhdsWithin_neBot, nhdsWithin_prod_eq, prod_neBot] #align closure_prod_eq closure_prod_eq theorem interior_prod_eq (s : Set X) (t : Set Y) : interior (s ×ˢ t) = interior s ×ˢ interior t := ext fun ⟨a, b⟩ => by simp only [mem_interior_iff_mem_nhds, mem_prod, prod_mem_nhds_iff] #align interior_prod_eq interior_prod_eq theorem frontier_prod_eq (s : Set X) (t : Set Y) : frontier (s ×ˢ t) = closure s ×ˢ frontier t ∪ frontier s ×ˢ closure t := by simp only [frontier, closure_prod_eq, interior_prod_eq, prod_diff_prod] #align frontier_prod_eq frontier_prod_eq @[simp] theorem frontier_prod_univ_eq (s : Set X) : frontier (s ×ˢ (univ : Set Y)) = frontier s ×ˢ univ := by simp [frontier_prod_eq] #align frontier_prod_univ_eq frontier_prod_univ_eq @[simp] theorem frontier_univ_prod_eq (s : Set Y) : frontier ((univ : Set X) ×ˢ s) = univ ×ˢ frontier s := by simp [frontier_prod_eq] #align frontier_univ_prod_eq frontier_univ_prod_eq theorem map_mem_closure₂ {f : X → Y → Z} {x : X} {y : Y} {s : Set X} {t : Set Y} {u : Set Z} (hf : Continuous (uncurry f)) (hx : x ∈ closure s) (hy : y ∈ closure t) (h : ∀ a ∈ s, ∀ b ∈ t, f a b ∈ u) : f x y ∈ closure u := have H₁ : (x, y) ∈ closure (s ×ˢ t) := by simpa only [closure_prod_eq] using mk_mem_prod hx hy have H₂ : MapsTo (uncurry f) (s ×ˢ t) u := forall_prod_set.2 h H₂.closure hf H₁ #align map_mem_closure₂ map_mem_closure₂ theorem IsClosed.prod {s₁ : Set X} {s₂ : Set Y} (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ×ˢ s₂) := closure_eq_iff_isClosed.mp <| by simp only [h₁.closure_eq, h₂.closure_eq, closure_prod_eq] #align is_closed.prod IsClosed.prod /-- The product of two dense sets is a dense set. -/ theorem Dense.prod {s : Set X} {t : Set Y} (hs : Dense s) (ht : Dense t) : Dense (s ×ˢ t) := fun x => by rw [closure_prod_eq] exact ⟨hs x.1, ht x.2⟩ #align dense.prod Dense.prod /-- If `f` and `g` are maps with dense range, then `Prod.map f g` has dense range. -/ theorem DenseRange.prod_map {ι : Type*} {κ : Type*} {f : ι → Y} {g : κ → Z} (hf : DenseRange f) (hg : DenseRange g) : DenseRange (Prod.map f g) := by simpa only [DenseRange, prod_range_range_eq] using hf.prod hg #align dense_range.prod_map DenseRange.prod_map theorem Inducing.prod_map {f : X → Y} {g : Z → W} (hf : Inducing f) (hg : Inducing g) : Inducing (Prod.map f g) := inducing_iff_nhds.2 fun (x, z) => by simp_rw [Prod.map_def, nhds_prod_eq, hf.nhds_eq_comap, hg.nhds_eq_comap, prod_comap_comap_eq] #align inducing.prod_mk Inducing.prod_map @[simp] theorem inducing_const_prod {x : X} {f : Y → Z} : (Inducing fun x' => (x, f x')) ↔ Inducing f := by simp_rw [inducing_iff, instTopologicalSpaceProd, induced_inf, induced_compose, Function.comp, induced_const, top_inf_eq] #align inducing_const_prod inducing_const_prod @[simp] theorem inducing_prod_const {y : Y} {f : X → Z} : (Inducing fun x => (f x, y)) ↔ Inducing f := by simp_rw [inducing_iff, instTopologicalSpaceProd, induced_inf, induced_compose, Function.comp, induced_const, inf_top_eq] #align inducing_prod_const inducing_prod_const theorem Embedding.prod_map {f : X → Y} {g : Z → W} (hf : Embedding f) (hg : Embedding g) : Embedding (Prod.map f g) := { hf.toInducing.prod_map hg.toInducing with inj := fun ⟨x₁, z₁⟩ ⟨x₂, z₂⟩ => by simp [hf.inj.eq_iff, hg.inj.eq_iff] } #align embedding.prod_mk Embedding.prod_map protected theorem IsOpenMap.prod {f : X → Y} {g : Z → W} (hf : IsOpenMap f) (hg : IsOpenMap g) : IsOpenMap fun p : X × Z => (f p.1, g p.2) := by rw [isOpenMap_iff_nhds_le] rintro ⟨a, b⟩ rw [nhds_prod_eq, nhds_prod_eq, ← Filter.prod_map_map_eq] exact Filter.prod_mono (hf.nhds_le a) (hg.nhds_le b) #align is_open_map.prod IsOpenMap.prod protected theorem OpenEmbedding.prod {f : X → Y} {g : Z → W} (hf : OpenEmbedding f) (hg : OpenEmbedding g) : OpenEmbedding fun x : X × Z => (f x.1, g x.2) := openEmbedding_of_embedding_open (hf.1.prod_map hg.1) (hf.isOpenMap.prod hg.isOpenMap) #align open_embedding.prod OpenEmbedding.prod theorem embedding_graph {f : X → Y} (hf : Continuous f) : Embedding fun x => (x, f x) := embedding_of_embedding_compose (continuous_id.prod_mk hf) continuous_fst embedding_id #align embedding_graph embedding_graph theorem embedding_prod_mk (x : X) : Embedding (Prod.mk x : Y → X × Y) := embedding_of_embedding_compose (Continuous.Prod.mk x) continuous_snd embedding_id end Prod section Bool lemma continuous_bool_rng [TopologicalSpace X] {f : X → Bool} (b : Bool) : Continuous f ↔ IsClopen (f ⁻¹' {b}) := by rw [continuous_discrete_rng, Bool.forall_bool' b, IsClopen, ← isOpen_compl_iff, ← preimage_compl, Bool.compl_singleton, and_comm] end Bool section Sum open Sum variable [TopologicalSpace X] [TopologicalSpace Y] [TopologicalSpace Z] [TopologicalSpace W] theorem continuous_sum_dom {f : X ⊕ Y → Z} : Continuous f ↔ Continuous (f ∘ Sum.inl) ∧ Continuous (f ∘ Sum.inr) := (continuous_sup_dom (t₁ := TopologicalSpace.coinduced Sum.inl _) (t₂ := TopologicalSpace.coinduced Sum.inr _)).trans <| continuous_coinduced_dom.and continuous_coinduced_dom #align continuous_sum_dom continuous_sum_dom theorem continuous_sum_elim {f : X → Z} {g : Y → Z} : Continuous (Sum.elim f g) ↔ Continuous f ∧ Continuous g := continuous_sum_dom #align continuous_sum_elim continuous_sum_elim @[continuity] theorem Continuous.sum_elim {f : X → Z} {g : Y → Z} (hf : Continuous f) (hg : Continuous g) : Continuous (Sum.elim f g) := continuous_sum_elim.2 ⟨hf, hg⟩ #align continuous.sum_elim Continuous.sum_elim @[continuity] theorem continuous_isLeft : Continuous (isLeft : X ⊕ Y → Bool) := continuous_sum_dom.2 ⟨continuous_const, continuous_const⟩ @[continuity] theorem continuous_isRight : Continuous (isRight : X ⊕ Y → Bool) := continuous_sum_dom.2 ⟨continuous_const, continuous_const⟩ @[continuity] -- Porting note: the proof was `continuous_sup_rng_left continuous_coinduced_rng` theorem continuous_inl : Continuous (@inl X Y) := ⟨fun _ => And.left⟩ #align continuous_inl continuous_inl @[continuity] -- Porting note: the proof was `continuous_sup_rng_right continuous_coinduced_rng` theorem continuous_inr : Continuous (@inr X Y) := ⟨fun _ => And.right⟩ #align continuous_inr continuous_inr theorem isOpen_sum_iff {s : Set (X ⊕ Y)} : IsOpen s ↔ IsOpen (inl ⁻¹' s) ∧ IsOpen (inr ⁻¹' s) := Iff.rfl #align is_open_sum_iff isOpen_sum_iff -- Porting note (#10756): new theorem theorem isClosed_sum_iff {s : Set (X ⊕ Y)} : IsClosed s ↔ IsClosed (inl ⁻¹' s) ∧ IsClosed (inr ⁻¹' s) := by simp only [← isOpen_compl_iff, isOpen_sum_iff, preimage_compl] theorem isOpenMap_inl : IsOpenMap (@inl X Y) := fun u hu => by simpa [isOpen_sum_iff, preimage_image_eq u Sum.inl_injective] #align is_open_map_inl isOpenMap_inl theorem isOpenMap_inr : IsOpenMap (@inr X Y) := fun u hu => by simpa [isOpen_sum_iff, preimage_image_eq u Sum.inr_injective] #align is_open_map_inr isOpenMap_inr theorem openEmbedding_inl : OpenEmbedding (@inl X Y) := openEmbedding_of_continuous_injective_open continuous_inl inl_injective isOpenMap_inl #align open_embedding_inl openEmbedding_inl theorem openEmbedding_inr : OpenEmbedding (@inr X Y) := openEmbedding_of_continuous_injective_open continuous_inr inr_injective isOpenMap_inr #align open_embedding_inr openEmbedding_inr theorem embedding_inl : Embedding (@inl X Y) := openEmbedding_inl.1 #align embedding_inl embedding_inl theorem embedding_inr : Embedding (@inr X Y) := openEmbedding_inr.1 #align embedding_inr embedding_inr theorem isOpen_range_inl : IsOpen (range (inl : X → X ⊕ Y)) := openEmbedding_inl.2 #align is_open_range_inl isOpen_range_inl theorem isOpen_range_inr : IsOpen (range (inr : Y → X ⊕ Y)) := openEmbedding_inr.2 #align is_open_range_inr isOpen_range_inr theorem isClosed_range_inl : IsClosed (range (inl : X → X ⊕ Y)) := by rw [← isOpen_compl_iff, compl_range_inl] exact isOpen_range_inr #align is_closed_range_inl isClosed_range_inl theorem isClosed_range_inr : IsClosed (range (inr : Y → X ⊕ Y)) := by rw [← isOpen_compl_iff, compl_range_inr] exact isOpen_range_inl #align is_closed_range_inr isClosed_range_inr theorem closedEmbedding_inl : ClosedEmbedding (inl : X → X ⊕ Y) := ⟨embedding_inl, isClosed_range_inl⟩ #align closed_embedding_inl closedEmbedding_inl theorem closedEmbedding_inr : ClosedEmbedding (inr : Y → X ⊕ Y) := ⟨embedding_inr, isClosed_range_inr⟩ #align closed_embedding_inr closedEmbedding_inr theorem nhds_inl (x : X) : 𝓝 (inl x : X ⊕ Y) = map inl (𝓝 x) := (openEmbedding_inl.map_nhds_eq _).symm #align nhds_inl nhds_inl theorem nhds_inr (y : Y) : 𝓝 (inr y : X ⊕ Y) = map inr (𝓝 y) := (openEmbedding_inr.map_nhds_eq _).symm #align nhds_inr nhds_inr @[simp] theorem continuous_sum_map {f : X → Y} {g : Z → W} : Continuous (Sum.map f g) ↔ Continuous f ∧ Continuous g := continuous_sum_elim.trans <| embedding_inl.continuous_iff.symm.and embedding_inr.continuous_iff.symm #align continuous_sum_map continuous_sum_map @[continuity] theorem Continuous.sum_map {f : X → Y} {g : Z → W} (hf : Continuous f) (hg : Continuous g) : Continuous (Sum.map f g) := continuous_sum_map.2 ⟨hf, hg⟩ #align continuous.sum_map Continuous.sum_map
Mathlib/Topology/Constructions.lean
1,042
1,044
theorem isOpenMap_sum {f : X ⊕ Y → Z} : IsOpenMap f ↔ (IsOpenMap fun a => f (inl a)) ∧ IsOpenMap fun b => f (inr b) := by
simp only [isOpenMap_iff_nhds_le, Sum.forall, nhds_inl, nhds_inr, Filter.map_map, comp]