Context stringlengths 57 92.3k | 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 |
|---|---|---|---|---|---|
import Mathlib.RingTheory.RootsOfUnity.Basic
import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
import Mathlib.Algebra.GCDMonoid.IntegrallyClosed
import Mathlib.FieldTheory.Finite.Basic
#align_import ring_theory.roots_of_unity.minpoly from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
open minpoly Polynomial
open scoped Polynomial
namespace IsPrimitiveRoot
section CommRing
variable {n : ℕ} {K : Type*} [CommRing K] {μ : K} (h : IsPrimitiveRoot μ n)
-- Porting note: `hpos` was in the `variable` line, with an `omit` in mathlib3 just after this
-- declaration. For some reason, in Lean4, `hpos` gets included also in the declarations below,
-- even if it is not used in the proof.
| Mathlib/RingTheory/RootsOfUnity/Minpoly.lean | 40 | 45 | theorem isIntegral (hpos : 0 < n) : IsIntegral ℤ μ := by |
use X ^ n - 1
constructor
· exact monic_X_pow_sub_C 1 (ne_of_lt hpos).symm
· simp only [((IsPrimitiveRoot.iff_def μ n).mp h).left, eval₂_one, eval₂_X_pow, eval₂_sub,
sub_self]
|
import Mathlib.Analysis.SpecialFunctions.Pow.Real
import Mathlib.LinearAlgebra.FreeModule.PID
import Mathlib.LinearAlgebra.Matrix.AbsoluteValue
import Mathlib.NumberTheory.ClassNumber.AdmissibleAbsoluteValue
import Mathlib.RingTheory.ClassGroup
import Mathlib.RingTheory.DedekindDomain.IntegralClosure
import Mathlib.RingTheory.Norm
#align_import number_theory.class_number.finite from "leanprover-community/mathlib"@"ea0bcd84221246c801a6f8fbe8a4372f6d04b176"
open scoped nonZeroDivisors
namespace ClassGroup
open Ring
section EuclideanDomain
variable {R S : Type*} (K L : Type*) [EuclideanDomain R] [CommRing S] [IsDomain S]
variable [Field K] [Field L]
variable [Algebra R K] [IsFractionRing R K]
variable [Algebra K L] [FiniteDimensional K L] [IsSeparable K L]
variable [algRL : Algebra R L] [IsScalarTower R K L]
variable [Algebra R S] [Algebra S L]
variable [ist : IsScalarTower R S L] [iic : IsIntegralClosure S R L]
variable (abv : AbsoluteValue R ℤ)
variable {ι : Type*} [DecidableEq ι] [Fintype ι] (bS : Basis ι R S)
noncomputable def normBound : ℤ :=
let n := Fintype.card ι
let i : ι := Nonempty.some bS.index_nonempty
let m : ℤ :=
Finset.max'
(Finset.univ.image fun ijk : ι × ι × ι =>
abv (Algebra.leftMulMatrix bS (bS ijk.1) ijk.2.1 ijk.2.2))
⟨_, Finset.mem_image.mpr ⟨⟨i, i, i⟩, Finset.mem_univ _, rfl⟩⟩
Nat.factorial n • (n • m) ^ n
#align class_group.norm_bound ClassGroup.normBound
theorem normBound_pos : 0 < normBound abv bS := by
obtain ⟨i, j, k, hijk⟩ : ∃ i j k, Algebra.leftMulMatrix bS (bS i) j k ≠ 0 := by
by_contra! h
obtain ⟨i⟩ := bS.index_nonempty
apply bS.ne_zero i
apply
(injective_iff_map_eq_zero (Algebra.leftMulMatrix bS)).mp (Algebra.leftMulMatrix_injective bS)
ext j k
simp [h, DMatrix.zero_apply]
simp only [normBound, Algebra.smul_def, eq_natCast]
apply mul_pos (Int.natCast_pos.mpr (Nat.factorial_pos _))
refine pow_pos (mul_pos (Int.natCast_pos.mpr (Fintype.card_pos_iff.mpr ⟨i⟩)) ?_) _
refine lt_of_lt_of_le (abv.pos hijk) (Finset.le_max' _ _ ?_)
exact Finset.mem_image.mpr ⟨⟨i, j, k⟩, Finset.mem_univ _, rfl⟩
#align class_group.norm_bound_pos ClassGroup.normBound_pos
theorem norm_le (a : S) {y : ℤ} (hy : ∀ k, abv (bS.repr a k) ≤ y) :
abv (Algebra.norm R a) ≤ normBound abv bS * y ^ Fintype.card ι := by
conv_lhs => rw [← bS.sum_repr a]
rw [Algebra.norm_apply, ← LinearMap.det_toMatrix bS]
simp only [Algebra.norm_apply, AlgHom.map_sum, AlgHom.map_smul, map_sum,
map_smul, Algebra.toMatrix_lmul_eq, normBound, smul_mul_assoc, ← mul_pow]
convert Matrix.det_sum_smul_le Finset.univ _ hy using 3
· rw [Finset.card_univ, smul_mul_assoc, mul_comm]
· intro i j k
apply Finset.le_max'
exact Finset.mem_image.mpr ⟨⟨i, j, k⟩, Finset.mem_univ _, rfl⟩
#align class_group.norm_le ClassGroup.norm_le
theorem norm_lt {T : Type*} [LinearOrderedRing T] (a : S) {y : T}
(hy : ∀ k, (abv (bS.repr a k) : T) < y) :
(abv (Algebra.norm R a) : T) < normBound abv bS * y ^ Fintype.card ι := by
obtain ⟨i⟩ := bS.index_nonempty
have him : (Finset.univ.image fun k => abv (bS.repr a k)).Nonempty :=
⟨_, Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩⟩
set y' : ℤ := Finset.max' _ him with y'_def
have hy' : ∀ k, abv (bS.repr a k) ≤ y' := by
intro k
exact @Finset.le_max' ℤ _ _ _ (Finset.mem_image.mpr ⟨k, Finset.mem_univ _, rfl⟩)
have : (y' : T) < y := by
rw [y'_def, ←
Finset.max'_image (show Monotone (_ : ℤ → T) from fun x y h => Int.cast_le.mpr h)]
apply (Finset.max'_lt_iff _ (him.image _)).mpr
simp only [Finset.mem_image, exists_prop]
rintro _ ⟨x, ⟨k, -, rfl⟩, rfl⟩
exact hy k
have y'_nonneg : 0 ≤ y' := le_trans (abv.nonneg _) (hy' i)
apply (Int.cast_le.mpr (norm_le abv bS a hy')).trans_lt
simp only [Int.cast_mul, Int.cast_pow]
apply mul_lt_mul' le_rfl
· exact pow_lt_pow_left this (Int.cast_nonneg.mpr y'_nonneg) (@Fintype.card_ne_zero _ _ ⟨i⟩)
· exact pow_nonneg (Int.cast_nonneg.mpr y'_nonneg) _
· exact Int.cast_pos.mpr (normBound_pos abv bS)
#align class_group.norm_lt ClassGroup.norm_lt
theorem exists_min (I : (Ideal S)⁰) :
∃ b ∈ (I : Ideal S),
b ≠ 0 ∧ ∀ c ∈ (I : Ideal S), abv (Algebra.norm R c) < abv (Algebra.norm R b) → c =
(0 : S) := by
obtain ⟨_, ⟨b, b_mem, b_ne_zero, rfl⟩, min⟩ := @Int.exists_least_of_bdd
(fun a => ∃ b ∈ (I : Ideal S), b ≠ (0 : S) ∧ abv (Algebra.norm R b) = a)
(by
use 0
rintro _ ⟨b, _, _, rfl⟩
apply abv.nonneg)
(by
obtain ⟨b, b_mem, b_ne_zero⟩ := (I : Ideal S).ne_bot_iff.mp (nonZeroDivisors.coe_ne_zero I)
exact ⟨_, ⟨b, b_mem, b_ne_zero, rfl⟩⟩)
refine ⟨b, b_mem, b_ne_zero, ?_⟩
intro c hc lt
contrapose! lt with c_ne_zero
exact min _ ⟨c, hc, c_ne_zero, rfl⟩
#align class_group.exists_min ClassGroup.exists_min
section IsAdmissible
variable {abv} (adm : abv.IsAdmissible)
noncomputable def cardM : ℕ :=
adm.card (normBound abv bS ^ (-1 / Fintype.card ι : ℝ)) ^ Fintype.card ι
set_option linter.uppercaseLean3 false in
#align class_group.cardM ClassGroup.cardM
variable [Infinite R]
noncomputable def distinctElems : Fin (cardM bS adm).succ ↪ R :=
Fin.valEmbedding.trans (Infinite.natEmbedding R)
#align class_group.distinct_elems ClassGroup.distinctElems
variable [DecidableEq R]
noncomputable def finsetApprox : Finset R :=
(Finset.univ.image fun xy : _ × _ => distinctElems bS adm xy.1 - distinctElems bS adm xy.2).erase
0
#align class_group.finset_approx ClassGroup.finsetApprox
theorem finsetApprox.zero_not_mem : (0 : R) ∉ finsetApprox bS adm :=
Finset.not_mem_erase _ _
#align class_group.finset_approx.zero_not_mem ClassGroup.finsetApprox.zero_not_mem
@[simp]
theorem mem_finsetApprox {x : R} :
x ∈ finsetApprox bS adm ↔ ∃ i j, i ≠ j ∧ distinctElems bS adm i - distinctElems bS adm j =
x := by
simp only [finsetApprox, Finset.mem_erase, Finset.mem_image]
constructor
· rintro ⟨hx, ⟨i, j⟩, _, rfl⟩
refine ⟨i, j, ?_, rfl⟩
rintro rfl
simp at hx
· rintro ⟨i, j, hij, rfl⟩
refine ⟨?_, ⟨i, j⟩, Finset.mem_univ _, rfl⟩
rw [Ne, sub_eq_zero]
exact fun h => hij ((distinctElems bS adm).injective h)
#align class_group.mem_finset_approx ClassGroup.mem_finsetApprox
theorem prod_finsetApprox_ne_zero : algebraMap R S (∏ m ∈ finsetApprox bS adm, m) ≠ 0 := by
refine mt ((injective_iff_map_eq_zero _).mp bS.algebraMap_injective _) ?_
simp only [Finset.prod_eq_zero_iff, not_exists]
rintro x ⟨hx, rfl⟩
exact finsetApprox.zero_not_mem bS adm hx
#align class_group.prod_finset_approx_ne_zero ClassGroup.prod_finsetApprox_ne_zero
theorem ne_bot_of_prod_finsetApprox_mem (J : Ideal S)
(h : algebraMap _ _ (∏ m ∈ finsetApprox bS adm, m) ∈ J) : J ≠ ⊥ :=
(Submodule.ne_bot_iff _).mpr ⟨_, h, prod_finsetApprox_ne_zero _ _⟩
#align class_group.ne_bot_of_prod_finset_approx_mem ClassGroup.ne_bot_of_prod_finsetApprox_mem
theorem exists_mk0_eq_mk0 [IsDedekindDomain S] [Algebra.IsAlgebraic R L] (I : (Ideal S)⁰) :
∃ J : (Ideal S)⁰,
ClassGroup.mk0 I = ClassGroup.mk0 J ∧
algebraMap _ _ (∏ m ∈ finsetApprox bS adm, m) ∈ (J : Ideal S) := by
set M := ∏ m ∈ finsetApprox bS adm, m
have hM : algebraMap R S M ≠ 0 := prod_finsetApprox_ne_zero bS adm
obtain ⟨b, b_mem, b_ne_zero, b_min⟩ := exists_min abv I
suffices Ideal.span {b} ∣ Ideal.span {algebraMap _ _ M} * I.1 by
obtain ⟨J, hJ⟩ := this
refine ⟨⟨J, ?_⟩, ?_, ?_⟩
· rw [mem_nonZeroDivisors_iff_ne_zero]
rintro rfl
rw [Ideal.zero_eq_bot, Ideal.mul_bot] at hJ
exact hM (Ideal.span_singleton_eq_bot.mp (I.2 _ hJ))
· rw [ClassGroup.mk0_eq_mk0_iff]
exact ⟨algebraMap _ _ M, b, hM, b_ne_zero, hJ⟩
rw [← SetLike.mem_coe, ← Set.singleton_subset_iff, ← Ideal.span_le, ← Ideal.dvd_iff_le]
apply (mul_dvd_mul_iff_left _).mp _
swap; · exact mt Ideal.span_singleton_eq_bot.mp b_ne_zero
rw [Subtype.coe_mk, Ideal.dvd_iff_le, ← hJ, mul_comm]
apply Ideal.mul_mono le_rfl
rw [Ideal.span_le, Set.singleton_subset_iff]
exact b_mem
rw [Ideal.dvd_iff_le, Ideal.mul_le]
intro r' hr' a ha
rw [Ideal.mem_span_singleton] at hr' ⊢
obtain ⟨q, r, r_mem, lt⟩ := exists_mem_finset_approx' L bS adm a b_ne_zero
apply @dvd_of_mul_left_dvd _ _ q
simp only [Algebra.smul_def] at lt
rw [←
sub_eq_zero.mp (b_min _ (I.1.sub_mem (I.1.mul_mem_left _ ha) (I.1.mul_mem_left _ b_mem)) lt)]
refine mul_dvd_mul_right (dvd_trans (RingHom.map_dvd _ ?_) hr') _
exact Multiset.dvd_prod (Multiset.mem_map.mpr ⟨_, r_mem, rfl⟩)
#align class_group.exists_mk0_eq_mk0 ClassGroup.exists_mk0_eq_mk0
noncomputable def mkMMem [IsDedekindDomain S]
(J : { J : Ideal S // algebraMap _ _ (∏ m ∈ finsetApprox bS adm, m) ∈ J }) : ClassGroup S :=
ClassGroup.mk0
⟨J.1, mem_nonZeroDivisors_iff_ne_zero.mpr (ne_bot_of_prod_finsetApprox_mem bS adm J.1 J.2)⟩
set_option linter.uppercaseLean3 false in
#align class_group.mk_M_mem ClassGroup.mkMMem
| Mathlib/NumberTheory/ClassNumber/Finite.lean | 332 | 337 | theorem mkMMem_surjective [IsDedekindDomain S] [Algebra.IsAlgebraic R L] :
Function.Surjective (ClassGroup.mkMMem bS adm) := by |
intro I'
obtain ⟨⟨I, hI⟩, rfl⟩ := ClassGroup.mk0_surjective I'
obtain ⟨J, mk0_eq_mk0, J_dvd⟩ := exists_mk0_eq_mk0 L bS adm ⟨I, hI⟩
exact ⟨⟨J, J_dvd⟩, mk0_eq_mk0.symm⟩
|
import Mathlib.Order.WellFounded
import Mathlib.Tactic.Common
#align_import data.pi.lex from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1"
assert_not_exists Monoid
variable {ι : Type*} {β : ι → Type*} (r : ι → ι → Prop) (s : ∀ {i}, β i → β i → Prop)
namespace Pi
protected def Lex (x y : ∀ i, β i) : Prop :=
∃ i, (∀ j, r j i → x j = y j) ∧ s (x i) (y i)
#align pi.lex Pi.Lex
notation3 (prettyPrint := false) "Πₗ "(...)", "r:(scoped p => Lex (∀ i, p i)) => r
@[simp]
theorem toLex_apply (x : ∀ i, β i) (i : ι) : toLex x i = x i :=
rfl
#align pi.to_lex_apply Pi.toLex_apply
@[simp]
theorem ofLex_apply (x : Lex (∀ i, β i)) (i : ι) : ofLex x i = x i :=
rfl
#align pi.of_lex_apply Pi.ofLex_apply
theorem lex_lt_of_lt_of_preorder [∀ i, Preorder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i}
(hlt : x < y) : ∃ i, (∀ j, r j i → x j ≤ y j ∧ y j ≤ x j) ∧ x i < y i :=
let h' := Pi.lt_def.1 hlt
let ⟨i, hi, hl⟩ := hwf.has_min _ h'.2
⟨i, fun j hj => ⟨h'.1 j, not_not.1 fun h => hl j (lt_of_le_not_le (h'.1 j) h) hj⟩, hi⟩
#align pi.lex_lt_of_lt_of_preorder Pi.lex_lt_of_lt_of_preorder
theorem lex_lt_of_lt [∀ i, PartialOrder (β i)] {r} (hwf : WellFounded r) {x y : ∀ i, β i}
(hlt : x < y) : Pi.Lex r (@fun i => (· < ·)) x y := by
simp_rw [Pi.Lex, le_antisymm_iff]
exact lex_lt_of_lt_of_preorder hwf hlt
#align pi.lex_lt_of_lt Pi.lex_lt_of_lt
theorem isTrichotomous_lex [∀ i, IsTrichotomous (β i) s] (wf : WellFounded r) :
IsTrichotomous (∀ i, β i) (Pi.Lex r @s) :=
{ trichotomous := fun a b => by
rcases eq_or_ne a b with hab | hab
· exact Or.inr (Or.inl hab)
· rw [Function.ne_iff] at hab
let i := wf.min _ hab
have hri : ∀ j, r j i → a j = b j := by
intro j
rw [← not_imp_not]
exact fun h' => wf.not_lt_min _ _ h'
have hne : a i ≠ b i := wf.min_mem _ hab
cases' trichotomous_of s (a i) (b i) with hi hi
exacts [Or.inl ⟨i, hri, hi⟩,
Or.inr <| Or.inr <| ⟨i, fun j hj => (hri j hj).symm, hi.resolve_left hne⟩] }
#align pi.is_trichotomous_lex Pi.isTrichotomous_lex
instance [LT ι] [∀ a, LT (β a)] : LT (Lex (∀ i, β i)) :=
⟨Pi.Lex (· < ·) @fun _ => (· < ·)⟩
instance Lex.isStrictOrder [LinearOrder ι] [∀ a, PartialOrder (β a)] :
IsStrictOrder (Lex (∀ i, β i)) (· < ·) where
irrefl := fun a ⟨k, _, hk₂⟩ => lt_irrefl (a k) hk₂
trans := by
rintro a b c ⟨N₁, lt_N₁, a_lt_b⟩ ⟨N₂, lt_N₂, b_lt_c⟩
rcases lt_trichotomy N₁ N₂ with (H | rfl | H)
exacts [⟨N₁, fun j hj => (lt_N₁ _ hj).trans (lt_N₂ _ <| hj.trans H), lt_N₂ _ H ▸ a_lt_b⟩,
⟨N₁, fun j hj => (lt_N₁ _ hj).trans (lt_N₂ _ hj), a_lt_b.trans b_lt_c⟩,
⟨N₂, fun j hj => (lt_N₁ _ (hj.trans H)).trans (lt_N₂ _ hj), (lt_N₁ _ H).symm ▸ b_lt_c⟩]
#align pi.lex.is_strict_order Pi.Lex.isStrictOrder
instance [LinearOrder ι] [∀ a, PartialOrder (β a)] : PartialOrder (Lex (∀ i, β i)) :=
partialOrderOfSO (· < ·)
noncomputable instance [LinearOrder ι] [IsWellOrder ι (· < ·)] [∀ a, LinearOrder (β a)] :
LinearOrder (Lex (∀ i, β i)) :=
@linearOrderOfSTO (Πₗ i, β i) (· < ·)
{ trichotomous := (isTrichotomous_lex _ _ IsWellFounded.wf).1 } (Classical.decRel _)
section PartialOrder
variable [LinearOrder ι] [IsWellOrder ι (· < ·)] [∀ i, PartialOrder (β i)] {x y : ∀ i, β i} {i : ι}
{a : β i}
open Function
theorem toLex_monotone : Monotone (@toLex (∀ i, β i)) := fun a b h =>
or_iff_not_imp_left.2 fun hne =>
let ⟨i, hi, hl⟩ := IsWellFounded.wf.has_min (r := (· < ·)) { i | a i ≠ b i }
(Function.ne_iff.1 hne)
⟨i, fun j hj => by
contrapose! hl
exact ⟨j, hl, hj⟩, (h i).lt_of_ne hi⟩
#align pi.to_lex_monotone Pi.toLex_monotone
theorem toLex_strictMono : StrictMono (@toLex (∀ i, β i)) := fun a b h =>
let ⟨i, hi, hl⟩ := IsWellFounded.wf.has_min (r := (· < ·)) { i | a i ≠ b i }
(Function.ne_iff.1 h.ne)
⟨i, fun j hj => by
contrapose! hl
exact ⟨j, hl, hj⟩, (h.le i).lt_of_ne hi⟩
#align pi.to_lex_strict_mono Pi.toLex_strictMono
@[simp]
theorem lt_toLex_update_self_iff : toLex x < toLex (update x i a) ↔ x i < a := by
refine ⟨?_, fun h => toLex_strictMono <| lt_update_self_iff.2 h⟩
rintro ⟨j, hj, h⟩
dsimp at h
obtain rfl : j = i := by
by_contra H
rw [update_noteq H] at h
exact h.false
rwa [update_same] at h
#align pi.lt_to_lex_update_self_iff Pi.lt_toLex_update_self_iff
@[simp]
| Mathlib/Order/PiLex.lean | 148 | 156 | theorem toLex_update_lt_self_iff : toLex (update x i a) < toLex x ↔ a < x i := by |
refine ⟨?_, fun h => toLex_strictMono <| update_lt_self_iff.2 h⟩
rintro ⟨j, hj, h⟩
dsimp at h
obtain rfl : j = i := by
by_contra H
rw [update_noteq H] at h
exact h.false
rwa [update_same] at h
|
import Mathlib.Algebra.Module.Submodule.EqLocus
import Mathlib.Algebra.Module.Submodule.RestrictScalars
import Mathlib.Algebra.Ring.Idempotents
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.LinearAlgebra.Basic
import Mathlib.Order.CompactlyGenerated.Basic
import Mathlib.Order.OmegaCompletePartialOrder
#align_import linear_algebra.span from "leanprover-community/mathlib"@"10878f6bf1dab863445907ab23fbfcefcb5845d0"
variable {R R₂ K M M₂ V S : Type*}
namespace Submodule
open Function Set
open Pointwise
section AddCommMonoid
variable [Semiring R] [AddCommMonoid M] [Module R M]
variable {x : M} (p p' : Submodule R M)
variable [Semiring R₂] {σ₁₂ : R →+* R₂}
variable [AddCommMonoid M₂] [Module R₂ M₂]
variable {F : Type*} [FunLike F M M₂] [SemilinearMapClass F σ₁₂ M M₂]
section
variable (R)
def span (s : Set M) : Submodule R M :=
sInf { p | s ⊆ p }
#align submodule.span Submodule.span
variable {R}
-- Porting note: renamed field to `principal'` and added `principal` to fix explicit argument
@[mk_iff]
class IsPrincipal (S : Submodule R M) : Prop where
principal' : ∃ a, S = span R {a}
#align submodule.is_principal Submodule.IsPrincipal
theorem IsPrincipal.principal (S : Submodule R M) [S.IsPrincipal] :
∃ a, S = span R {a} :=
Submodule.IsPrincipal.principal'
#align submodule.is_principal.principal Submodule.IsPrincipal.principal
end
variable {s t : Set M}
theorem mem_span : x ∈ span R s ↔ ∀ p : Submodule R M, s ⊆ p → x ∈ p :=
mem_iInter₂
#align submodule.mem_span Submodule.mem_span
@[aesop safe 20 apply (rule_sets := [SetLike])]
theorem subset_span : s ⊆ span R s := fun _ h => mem_span.2 fun _ hp => hp h
#align submodule.subset_span Submodule.subset_span
theorem span_le {p} : span R s ≤ p ↔ s ⊆ p :=
⟨Subset.trans subset_span, fun ss _ h => mem_span.1 h _ ss⟩
#align submodule.span_le Submodule.span_le
theorem span_mono (h : s ⊆ t) : span R s ≤ span R t :=
span_le.2 <| Subset.trans h subset_span
#align submodule.span_mono Submodule.span_mono
theorem span_monotone : Monotone (span R : Set M → Submodule R M) := fun _ _ => span_mono
#align submodule.span_monotone Submodule.span_monotone
theorem span_eq_of_le (h₁ : s ⊆ p) (h₂ : p ≤ span R s) : span R s = p :=
le_antisymm (span_le.2 h₁) h₂
#align submodule.span_eq_of_le Submodule.span_eq_of_le
theorem span_eq : span R (p : Set M) = p :=
span_eq_of_le _ (Subset.refl _) subset_span
#align submodule.span_eq Submodule.span_eq
theorem span_eq_span (hs : s ⊆ span R t) (ht : t ⊆ span R s) : span R s = span R t :=
le_antisymm (span_le.2 hs) (span_le.2 ht)
#align submodule.span_eq_span Submodule.span_eq_span
lemma coe_span_eq_self [SetLike S M] [AddSubmonoidClass S M] [SMulMemClass S R M] (s : S) :
(span R (s : Set M) : Set M) = s := by
refine le_antisymm ?_ subset_span
let s' : Submodule R M :=
{ carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
smul_mem' := SMulMemClass.smul_mem }
exact span_le (p := s') |>.mpr le_rfl
@[simp]
theorem span_coe_eq_restrictScalars [Semiring S] [SMul S R] [Module S M] [IsScalarTower S R M] :
span S (p : Set M) = p.restrictScalars S :=
span_eq (p.restrictScalars S)
#align submodule.span_coe_eq_restrict_scalars Submodule.span_coe_eq_restrictScalars
theorem image_span_subset (f : F) (s : Set M) (N : Submodule R₂ M₂) :
f '' span R s ⊆ N ↔ ∀ m ∈ s, f m ∈ N := image_subset_iff.trans <| span_le (p := N.comap f)
theorem image_span_subset_span (f : F) (s : Set M) : f '' span R s ⊆ span R₂ (f '' s) :=
(image_span_subset f s _).2 fun x hx ↦ subset_span ⟨x, hx, rfl⟩
theorem map_span [RingHomSurjective σ₁₂] (f : F) (s : Set M) :
(span R s).map f = span R₂ (f '' s) :=
Eq.symm <| span_eq_of_le _ (Set.image_subset f subset_span) (image_span_subset_span f s)
#align submodule.map_span Submodule.map_span
alias _root_.LinearMap.map_span := Submodule.map_span
#align linear_map.map_span LinearMap.map_span
theorem map_span_le [RingHomSurjective σ₁₂] (f : F) (s : Set M) (N : Submodule R₂ M₂) :
map f (span R s) ≤ N ↔ ∀ m ∈ s, f m ∈ N := image_span_subset f s N
#align submodule.map_span_le Submodule.map_span_le
alias _root_.LinearMap.map_span_le := Submodule.map_span_le
#align linear_map.map_span_le LinearMap.map_span_le
@[simp]
theorem span_insert_zero : span R (insert (0 : M) s) = span R s := by
refine le_antisymm ?_ (Submodule.span_mono (Set.subset_insert 0 s))
rw [span_le, Set.insert_subset_iff]
exact ⟨by simp only [SetLike.mem_coe, Submodule.zero_mem], Submodule.subset_span⟩
#align submodule.span_insert_zero Submodule.span_insert_zero
-- See also `span_preimage_eq` below.
theorem span_preimage_le (f : F) (s : Set M₂) :
span R (f ⁻¹' s) ≤ (span R₂ s).comap f := by
rw [span_le, comap_coe]
exact preimage_mono subset_span
#align submodule.span_preimage_le Submodule.span_preimage_le
alias _root_.LinearMap.span_preimage_le := Submodule.span_preimage_le
#align linear_map.span_preimage_le LinearMap.span_preimage_le
theorem closure_subset_span {s : Set M} : (AddSubmonoid.closure s : Set M) ⊆ span R s :=
(@AddSubmonoid.closure_le _ _ _ (span R s).toAddSubmonoid).mpr subset_span
#align submodule.closure_subset_span Submodule.closure_subset_span
theorem closure_le_toAddSubmonoid_span {s : Set M} :
AddSubmonoid.closure s ≤ (span R s).toAddSubmonoid :=
closure_subset_span
#align submodule.closure_le_to_add_submonoid_span Submodule.closure_le_toAddSubmonoid_span
@[simp]
theorem span_closure {s : Set M} : span R (AddSubmonoid.closure s : Set M) = span R s :=
le_antisymm (span_le.mpr closure_subset_span) (span_mono AddSubmonoid.subset_closure)
#align submodule.span_closure Submodule.span_closure
@[elab_as_elim]
theorem span_induction {p : M → Prop} (h : x ∈ span R s) (mem : ∀ x ∈ s, p x) (zero : p 0)
(add : ∀ x y, p x → p y → p (x + y)) (smul : ∀ (a : R) (x), p x → p (a • x)) : p x :=
((@span_le (p := ⟨⟨⟨p, by intros x y; exact add x y⟩, zero⟩, smul⟩)) s).2 mem h
#align submodule.span_induction Submodule.span_induction
theorem span_induction₂ {p : M → M → Prop} {a b : M} (ha : a ∈ Submodule.span R s)
(hb : b ∈ Submodule.span R s) (mem_mem : ∀ x ∈ s, ∀ y ∈ s, p x y)
(zero_left : ∀ y, p 0 y) (zero_right : ∀ x, p x 0)
(add_left : ∀ x₁ x₂ y, p x₁ y → p x₂ y → p (x₁ + x₂) y)
(add_right : ∀ x y₁ y₂, p x y₁ → p x y₂ → p x (y₁ + y₂))
(smul_left : ∀ (r : R) x y, p x y → p (r • x) y)
(smul_right : ∀ (r : R) x y, p x y → p x (r • y)) : p a b :=
Submodule.span_induction ha
(fun x hx => Submodule.span_induction hb (mem_mem x hx) (zero_right x) (add_right x) fun r =>
smul_right r x)
(zero_left b) (fun x₁ x₂ => add_left x₁ x₂ b) fun r x => smul_left r x b
@[elab_as_elim]
theorem span_induction' {p : ∀ x, x ∈ span R s → Prop}
(mem : ∀ (x) (h : x ∈ s), p x (subset_span h))
(zero : p 0 (Submodule.zero_mem _))
(add : ∀ x hx y hy, p x hx → p y hy → p (x + y) (Submodule.add_mem _ ‹_› ‹_›))
(smul : ∀ (a : R) (x hx), p x hx → p (a • x) (Submodule.smul_mem _ _ ‹_›)) {x}
(hx : x ∈ span R s) : p x hx := by
refine Exists.elim ?_ fun (hx : x ∈ span R s) (hc : p x hx) => hc
refine
span_induction hx (fun m hm => ⟨subset_span hm, mem m hm⟩) ⟨zero_mem _, zero⟩
(fun x y hx hy =>
Exists.elim hx fun hx' hx =>
Exists.elim hy fun hy' hy => ⟨add_mem hx' hy', add _ _ _ _ hx hy⟩)
fun r x hx => Exists.elim hx fun hx' hx => ⟨smul_mem _ _ hx', smul r _ _ hx⟩
#align submodule.span_induction' Submodule.span_induction'
open AddSubmonoid in
| Mathlib/LinearAlgebra/Span.lean | 218 | 226 | theorem span_eq_closure {s : Set M} : (span R s).toAddSubmonoid = closure (@univ R • s) := by |
refine le_antisymm
(fun x hx ↦ span_induction hx (fun x hx ↦ subset_closure ⟨1, trivial, x, hx, one_smul R x⟩)
(zero_mem _) (fun _ _ ↦ add_mem) fun r m hm ↦ closure_induction hm ?_ ?_ fun _ _ h h' ↦ ?_)
(closure_le.2 ?_)
· rintro _ ⟨r, -, m, hm, rfl⟩; exact smul_mem _ _ (subset_span hm)
· rintro _ ⟨r', -, m, hm, rfl⟩; exact subset_closure ⟨r * r', trivial, m, hm, mul_smul r r' m⟩
· rw [smul_zero]; apply zero_mem
· rw [smul_add]; exact add_mem h h'
|
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"
variable {α : Type*}
local infixl:50 " ~ᵤ " => Associated
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
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)]⟩
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
namespace UniqueFactorizationMonoid
variable {R : Type*} [CancelCommMonoidWithZero R] [UniqueFactorizationMonoid R]
theorem isRelPrime_iff_no_prime_factors {a b : R} (ha : a ≠ 0) :
IsRelPrime a b ↔ ∀ ⦃d⦄, d ∣ a → d ∣ b → ¬Prime d :=
⟨fun h _ ha hb ↦ (·.not_unit <| h ha hb), fun h ↦ WfDvdMonoid.isRelPrime_of_no_irreducible_factors
(ha ·.1) fun _ irr ha hb ↦ h ha hb (UniqueFactorizationMonoid.irreducible_iff_prime.mp irr)⟩
#align unique_factorization_monoid.no_factors_of_no_prime_factors UniqueFactorizationMonoid.isRelPrime_iff_no_prime_factors
theorem dvd_of_dvd_mul_left_of_no_prime_factors {a b c : R} (ha : a ≠ 0)
(h : ∀ ⦃d⦄, d ∣ a → d ∣ c → ¬Prime d) : a ∣ b * c → a ∣ b :=
((isRelPrime_iff_no_prime_factors ha).mpr h).dvd_of_dvd_mul_right
#align unique_factorization_monoid.dvd_of_dvd_mul_left_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_left_of_no_prime_factors
theorem dvd_of_dvd_mul_right_of_no_prime_factors {a b c : R} (ha : a ≠ 0)
(no_factors : ∀ {d}, d ∣ a → d ∣ b → ¬Prime d) : a ∣ b * c → a ∣ c := by
simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors
#align unique_factorization_monoid.dvd_of_dvd_mul_right_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors
theorem exists_reduced_factors :
∀ a ≠ (0 : R), ∀ b,
∃ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b := by
intro a
refine induction_on_prime a ?_ ?_ ?_
· intros
contradiction
· intro a a_unit _ b
use a, b, 1
constructor
· intro p p_dvd_a _
exact isUnit_of_dvd_unit p_dvd_a a_unit
· simp
· intro a p a_ne_zero p_prime ih_a pa_ne_zero b
by_cases h : p ∣ b
· rcases h with ⟨b, rfl⟩
obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
refine ⟨a', b', p * c', @no_factor, ?_, ?_⟩
· rw [mul_assoc, ha']
· rw [mul_assoc, hb']
· obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
refine ⟨p * a', b', c', ?_, mul_left_comm _ _ _, rfl⟩
intro q q_dvd_pa' q_dvd_b'
cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
· have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _
contradiction
exact coprime q_dvd_a' q_dvd_b'
#align unique_factorization_monoid.exists_reduced_factors UniqueFactorizationMonoid.exists_reduced_factors
theorem exists_reduced_factors' (a b : R) (hb : b ≠ 0) :
∃ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b :=
let ⟨b', a', c', no_factor, hb, ha⟩ := exists_reduced_factors b hb a
⟨a', b', c', fun _ hpb hpa => no_factor hpa hpb, ha, hb⟩
#align unique_factorization_monoid.exists_reduced_factors' UniqueFactorizationMonoid.exists_reduced_factors'
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
Function.Injective (a ^ · : ℕ → R) := by
letI := Classical.decEq R
intro i j hij
letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij
simp only [normalizedFactors_pow, Multiset.count_nsmul] at this
exact mul_right_cancel₀ (Multiset.count_ne_zero.mpr mem) this
#align unique_factorization_monoid.pow_right_injective UniqueFactorizationMonoid.pow_right_injective
theorem pow_eq_pow_iff {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) {i j : ℕ} : a ^ i = a ^ j ↔ i = j :=
(pow_right_injective ha0 ha1).eq_iff
#align unique_factorization_monoid.pow_eq_pow_iff UniqueFactorizationMonoid.pow_eq_pow_iff
section Multiplicative
variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α]
variable {β : Type*} [CancelCommMonoidWithZero β]
theorem prime_pow_coprime_prod_of_coprime_insert [DecidableEq α] {s : Finset α} (i : α → ℕ) (p : α)
(hps : p ∉ s) (is_prime : ∀ q ∈ insert p s, Prime q)
(is_coprime : ∀ᵉ (q ∈ insert p s) (q' ∈ insert p s), q ∣ q' → q = q') :
IsRelPrime (p ^ i p) (∏ p' ∈ s, p' ^ i p') := by
have hp := is_prime _ (Finset.mem_insert_self _ _)
refine (isRelPrime_iff_no_prime_factors <| pow_ne_zero _ hp.ne_zero).mpr ?_
intro d hdp hdprod hd
apply hps
replace hdp := hd.dvd_of_dvd_pow hdp
obtain ⟨q, q_mem', hdq⟩ := hd.exists_mem_multiset_dvd hdprod
obtain ⟨q, q_mem, rfl⟩ := Multiset.mem_map.mp q_mem'
replace hdq := hd.dvd_of_dvd_pow hdq
have : p ∣ q := dvd_trans (hd.irreducible.dvd_symm hp.irreducible hdp) hdq
convert q_mem
rw [Finset.mem_val,
is_coprime _ (Finset.mem_insert_self p s) _ (Finset.mem_insert_of_mem q_mem) this]
#align unique_factorization_monoid.prime_pow_coprime_prod_of_coprime_insert UniqueFactorizationMonoid.prime_pow_coprime_prod_of_coprime_insert
-- @[elab_as_elim] Porting note: commented out
theorem induction_on_prime_power {P : α → Prop} (s : Finset α) (i : α → ℕ)
(is_prime : ∀ p ∈ s, Prime p) (is_coprime : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q)
(h1 : ∀ {x}, IsUnit x → P x) (hpr : ∀ {p} (i : ℕ), Prime p → P (p ^ i))
(hcp : ∀ {x y}, IsRelPrime x y → P x → P y → P (x * y)) :
P (∏ p ∈ s, p ^ i p) := by
letI := Classical.decEq α
induction' s using Finset.induction_on with p f' hpf' ih
· simpa using h1 isUnit_one
rw [Finset.prod_insert hpf']
exact
hcp (prime_pow_coprime_prod_of_coprime_insert i p hpf' is_prime is_coprime)
(hpr (i p) (is_prime _ (Finset.mem_insert_self _ _)))
(ih (fun q hq => is_prime _ (Finset.mem_insert_of_mem hq)) fun q hq q' hq' =>
is_coprime _ (Finset.mem_insert_of_mem hq) _ (Finset.mem_insert_of_mem hq'))
#align unique_factorization_monoid.induction_on_prime_power UniqueFactorizationMonoid.induction_on_prime_power
@[elab_as_elim]
theorem induction_on_coprime {P : α → Prop} (a : α) (h0 : P 0) (h1 : ∀ {x}, IsUnit x → P x)
(hpr : ∀ {p} (i : ℕ), Prime p → P (p ^ i))
(hcp : ∀ {x y}, IsRelPrime x y → P x → P y → P (x * y)) : P a := by
letI := Classical.decEq α
have P_of_associated : ∀ {x y}, Associated x y → P x → P y := by
rintro x y ⟨u, rfl⟩ hx
exact hcp (fun p _ hpx => isUnit_of_dvd_unit hpx u.isUnit) hx (h1 u.isUnit)
by_cases ha0 : a = 0
· rwa [ha0]
haveI : Nontrivial α := ⟨⟨_, _, ha0⟩⟩
letI : NormalizationMonoid α := UniqueFactorizationMonoid.normalizationMonoid
refine P_of_associated (normalizedFactors_prod ha0) ?_
rw [← (normalizedFactors a).map_id, Finset.prod_multiset_map_count]
refine induction_on_prime_power _ _ ?_ ?_ @h1 @hpr @hcp <;> simp only [Multiset.mem_toFinset]
· apply prime_of_normalized_factor
· apply normalizedFactors_eq_of_dvd
#align unique_factorization_monoid.induction_on_coprime UniqueFactorizationMonoid.induction_on_coprime
-- @[elab_as_elim] Porting note: commented out
| Mathlib/RingTheory/UniqueFactorizationDomain.lean | 1,138 | 1,154 | theorem multiplicative_prime_power {f : α → β} (s : Finset α) (i j : α → ℕ)
(is_prime : ∀ p ∈ s, Prime p) (is_coprime : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q)
(h1 : ∀ {x y}, IsUnit y → f (x * y) = f x * f y)
(hpr : ∀ {p} (i : ℕ), Prime p → f (p ^ i) = f p ^ i)
(hcp : ∀ {x y}, IsRelPrime x y → f (x * y) = f x * f y) :
f (∏ p ∈ s, p ^ (i p + j p)) = f (∏ p ∈ s, p ^ i p) * f (∏ p ∈ s, p ^ j p) := by |
letI := Classical.decEq α
induction' s using Finset.induction_on with p s hps ih
· simpa using h1 isUnit_one
have hpr_p := is_prime _ (Finset.mem_insert_self _ _)
have hpr_s : ∀ p ∈ s, Prime p := fun p hp => is_prime _ (Finset.mem_insert_of_mem hp)
have hcp_p := fun i => prime_pow_coprime_prod_of_coprime_insert i p hps is_prime is_coprime
have hcp_s : ∀ᵉ (p ∈ s) (q ∈ s), p ∣ q → p = q := fun p hp q hq =>
is_coprime p (Finset.mem_insert_of_mem hp) q (Finset.mem_insert_of_mem hq)
rw [Finset.prod_insert hps, Finset.prod_insert hps, Finset.prod_insert hps, hcp (hcp_p _),
hpr _ hpr_p, hcp (hcp_p _), hpr _ hpr_p, hcp (hcp_p (fun p => i p + j p)), hpr _ hpr_p,
ih hpr_s hcp_s, pow_add, mul_assoc, mul_left_comm (f p ^ j p), mul_assoc]
|
import Mathlib.Algebra.Polynomial.Expand
import Mathlib.Algebra.Polynomial.Splits
import Mathlib.Algebra.Squarefree.Basic
import Mathlib.FieldTheory.Minpoly.Field
import Mathlib.RingTheory.PowerBasis
#align_import field_theory.separable from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
universe u v w
open scoped Classical
open Polynomial Finset
namespace Polynomial
section CommRing
variable {R : Type u} [CommRing R]
theorem separable_X_sub_C {x : R} : Separable (X - C x) := by
simpa only [sub_eq_add_neg, C_neg] using separable_X_add_C (-x)
set_option linter.uppercaseLean3 false in
#align polynomial.separable_X_sub_C Polynomial.separable_X_sub_C
| Mathlib/FieldTheory/Separable.lean | 220 | 224 | theorem Separable.mul {f g : R[X]} (hf : f.Separable) (hg : g.Separable) (h : IsCoprime f g) :
(f * g).Separable := by |
rw [separable_def, derivative_mul]
exact
((hf.mul_right h).add_mul_left_right _).mul_left ((h.symm.mul_right hg).mul_add_right_right _)
|
import Mathlib.Data.DFinsupp.Interval
import Mathlib.Data.DFinsupp.Multiset
import Mathlib.Order.Interval.Finset.Nat
#align_import data.multiset.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
open Finset DFinsupp Function
open Pointwise
variable {α : Type*}
namespace Multiset
variable [DecidableEq α] (s t : Multiset α)
instance instLocallyFiniteOrder : LocallyFiniteOrder (Multiset α) :=
LocallyFiniteOrder.ofIcc (Multiset α)
(fun s t => (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map
Multiset.equivDFinsupp.toEquiv.symm.toEmbedding)
fun s t x => by simp
theorem Icc_eq :
Finset.Icc s t = (Finset.Icc (toDFinsupp s) (toDFinsupp t)).map
Multiset.equivDFinsupp.toEquiv.symm.toEmbedding :=
rfl
#align multiset.Icc_eq Multiset.Icc_eq
theorem uIcc_eq :
uIcc s t =
(uIcc (toDFinsupp s) (toDFinsupp t)).map Multiset.equivDFinsupp.toEquiv.symm.toEmbedding :=
(Icc_eq _ _).trans <| by simp [uIcc]
#align multiset.uIcc_eq Multiset.uIcc_eq
| Mathlib/Data/Multiset/Interval.lean | 56 | 59 | theorem card_Icc :
(Finset.Icc s t).card = ∏ i ∈ s.toFinset ∪ t.toFinset, (t.count i + 1 - s.count i) := by |
simp_rw [Icc_eq, Finset.card_map, DFinsupp.card_Icc, Nat.card_Icc, Multiset.toDFinsupp_apply,
toDFinsupp_support]
|
import Mathlib.CategoryTheory.Limits.Shapes.NormalMono.Basic
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
#align_import category_theory.limits.shapes.normal_mono.equalizers from "leanprover-community/mathlib"@"3a061790136d13594ec10c7c90d202335ac5d854"
noncomputable section
open CategoryTheory
open CategoryTheory.Limits
variable {C : Type*} [Category C] [HasZeroMorphisms C]
namespace CategoryTheory.NormalMonoCategory
variable [HasFiniteProducts C] [HasKernels C] [NormalMonoCategory C]
@[irreducible, nolint defLemma] -- Porting note: changed to irreducible and a def
def pullback_of_mono {X Y Z : C} (a : X ⟶ Z) (b : Y ⟶ Z) [Mono a] [Mono b] :
HasLimit (cospan a b) :=
let ⟨P, f, haf, i⟩ := normalMonoOfMono a
let ⟨Q, g, hbg, i'⟩ := normalMonoOfMono b
let ⟨a', ha'⟩ :=
KernelFork.IsLimit.lift' i (kernel.ι (prod.lift f g)) <|
calc kernel.ι (prod.lift f g) ≫ f
_ = kernel.ι (prod.lift f g) ≫ prod.lift f g ≫ Limits.prod.fst := by rw [prod.lift_fst]
_ = (0 : kernel (prod.lift f g) ⟶ P ⨯ Q) ≫ Limits.prod.fst := by rw [kernel.condition_assoc]
_ = 0 := zero_comp
let ⟨b', hb'⟩ :=
KernelFork.IsLimit.lift' i' (kernel.ι (prod.lift f g)) <|
calc kernel.ι (prod.lift f g) ≫ g
_ = kernel.ι (prod.lift f g) ≫ prod.lift f g ≫ Limits.prod.snd := by rw [prod.lift_snd]
_ = (0 : kernel (prod.lift f g) ⟶ P ⨯ Q) ≫ Limits.prod.snd := by rw [kernel.condition_assoc]
_ = 0 := zero_comp
HasLimit.mk
{ cone :=
PullbackCone.mk a' b' <| by
simp? at ha' hb' says
simp only [parallelPair_obj_zero, Fork.ofι_pt, Fork.ι_ofι] at ha' hb'
rw [ha', hb']
isLimit :=
PullbackCone.IsLimit.mk _
(fun s =>
kernel.lift (prod.lift f g) (PullbackCone.snd s ≫ b) <|
prod.hom_ext
(calc
((PullbackCone.snd s ≫ b) ≫ prod.lift f g) ≫ Limits.prod.fst =
PullbackCone.snd s ≫ b ≫ f := by simp only [prod.lift_fst, Category.assoc]
_ = PullbackCone.fst s ≫ a ≫ f := by rw [PullbackCone.condition_assoc]
_ = PullbackCone.fst s ≫ 0 := by rw [haf]
_ = 0 ≫ Limits.prod.fst := by rw [comp_zero, zero_comp]
)
(calc
((PullbackCone.snd s ≫ b) ≫ prod.lift f g) ≫ Limits.prod.snd =
PullbackCone.snd s ≫ b ≫ g := by
simp only [prod.lift_snd, Category.assoc]
_ = PullbackCone.snd s ≫ 0 := by rw [hbg]
_ = 0 ≫ Limits.prod.snd := by rw [comp_zero, zero_comp]
))
(fun s =>
(cancel_mono a).1 <| by
rw [KernelFork.ι_ofι] at ha'
simp [ha', PullbackCone.condition s])
(fun s =>
(cancel_mono b).1 <| by
rw [KernelFork.ι_ofι] at hb'
simp [hb'])
fun s m h₁ _ =>
(cancel_mono (kernel.ι (prod.lift f g))).1 <|
calc
m ≫ kernel.ι (prod.lift f g) = m ≫ a' ≫ a := by
congr
exact ha'.symm
_ = PullbackCone.fst s ≫ a := by rw [← Category.assoc, h₁]
_ = PullbackCone.snd s ≫ b := PullbackCone.condition s
_ =
kernel.lift (prod.lift f g) (PullbackCone.snd s ≫ b) _ ≫
kernel.ι (prod.lift f g) := by rw [kernel.lift_ι]
}
#align category_theory.normal_mono_category.pullback_of_mono CategoryTheory.NormalMonoCategory.pullback_of_mono
section
attribute [local instance] pullback_of_mono
private abbrev P {X Y : C} (f g : X ⟶ Y) [Mono (prod.lift (𝟙 X) f)] [Mono (prod.lift (𝟙 X) g)] :
C :=
pullback (prod.lift (𝟙 X) f) (prod.lift (𝟙 X) g)
-- Porting note: changed to irreducible def since irreducible_def was breaking things
@[irreducible, nolint defLemma]
def hasLimit_parallelPair {X Y : C} (f g : X ⟶ Y) : HasLimit (parallelPair f g) :=
have huv : (pullback.fst : P f g ⟶ X) = pullback.snd :=
calc
(pullback.fst : P f g ⟶ X) = pullback.fst ≫ 𝟙 _ := Eq.symm <| Category.comp_id _
_ = pullback.fst ≫ prod.lift (𝟙 X) f ≫ Limits.prod.fst := by rw [prod.lift_fst]
_ = pullback.snd ≫ prod.lift (𝟙 X) g ≫ Limits.prod.fst := by rw [pullback.condition_assoc]
_ = pullback.snd := by rw [prod.lift_fst, Category.comp_id]
have hvu : (pullback.fst : P f g ⟶ X) ≫ f = pullback.snd ≫ g :=
calc
(pullback.fst : P f g ⟶ X) ≫ f = pullback.fst ≫ prod.lift (𝟙 X) f ≫ Limits.prod.snd := by
rw [prod.lift_snd]
_ = pullback.snd ≫ prod.lift (𝟙 X) g ≫ Limits.prod.snd := by rw [pullback.condition_assoc]
_ = pullback.snd ≫ g := by rw [prod.lift_snd]
have huu : (pullback.fst : P f g ⟶ X) ≫ f = pullback.fst ≫ g := by rw [hvu, ← huv]
HasLimit.mk
{ cone := Fork.ofι pullback.fst huu
isLimit :=
Fork.IsLimit.mk _
(fun s =>
pullback.lift (Fork.ι s) (Fork.ι s) <|
prod.hom_ext (by simp only [prod.lift_fst, Category.assoc])
(by simp only [prod.comp_lift, Fork.condition s]))
(fun s => by simp) fun s m h =>
pullback.hom_ext (by simpa only [pullback.lift_fst] using h)
(by simpa only [huv.symm, pullback.lift_fst] using h) }
#align category_theory.normal_mono_category.has_limit_parallel_pair CategoryTheory.NormalMonoCategory.hasLimit_parallelPair
end
section
attribute [local instance] hasLimit_parallelPair
instance (priority := 100) hasEqualizers : HasEqualizers C :=
hasEqualizers_of_hasLimit_parallelPair _
#align category_theory.normal_mono_category.has_equalizers CategoryTheory.NormalMonoCategory.hasEqualizers
end
| Mathlib/CategoryTheory/Limits/Shapes/NormalMono/Equalizers.lean | 152 | 162 | theorem epi_of_zero_cokernel {X Y : C} (f : X ⟶ Y) (Z : C)
(l : IsColimit (CokernelCofork.ofπ (0 : Y ⟶ Z) (show f ≫ 0 = 0 by simp))) : Epi f :=
⟨fun u v huv => by
obtain ⟨W, w, hw, hl⟩ := normalMonoOfMono (equalizer.ι u v)
obtain ⟨m, hm⟩ := equalizer.lift' f huv
have hwf : f ≫ w = 0 := by | rw [← hm, Category.assoc, hw, comp_zero]
obtain ⟨n, hn⟩ := CokernelCofork.IsColimit.desc' l _ hwf
rw [Cofork.π_ofπ, zero_comp] at hn
have : IsIso (equalizer.ι u v) := by apply isIso_limit_cone_parallelPair_of_eq hn.symm hl
apply (cancel_epi (equalizer.ι u v)).1
exact equalizer.condition _ _⟩
|
import Mathlib.Analysis.Calculus.FDeriv.Bilinear
#align_import analysis.calculus.fderiv.mul from "leanprover-community/mathlib"@"d608fc5d4e69d4cc21885913fb573a88b0deb521"
open scoped Classical
open Filter Asymptotics ContinuousLinearMap Set Metric Topology NNReal ENNReal
noncomputable section
section
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {G' : Type*} [NormedAddCommGroup G'] [NormedSpace 𝕜 G']
variable {f f₀ f₁ g : E → F}
variable {f' f₀' f₁' g' : E →L[𝕜] F}
variable (e : E →L[𝕜] F)
variable {x : E}
variable {s t : Set E}
variable {L L₁ L₂ : Filter E}
section ContinuousMultilinearApplyConst
variable {ι : Type*} [Fintype ι]
{M : ι → Type*} [∀ i, NormedAddCommGroup (M i)] [∀ i, NormedSpace 𝕜 (M i)]
{H : Type*} [NormedAddCommGroup H] [NormedSpace 𝕜 H]
{c : E → ContinuousMultilinearMap 𝕜 M H}
{c' : E →L[𝕜] ContinuousMultilinearMap 𝕜 M H}
@[fun_prop]
theorem HasStrictFDerivAt.continuousMultilinear_apply_const (hc : HasStrictFDerivAt c c' x)
(u : ∀ i, M i) : HasStrictFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasStrictFDerivAt.comp x hc
@[fun_prop]
theorem HasFDerivWithinAt.continuousMultilinear_apply_const (hc : HasFDerivWithinAt c c' s x)
(u : ∀ i, M i) :
HasFDerivWithinAt (fun y ↦ (c y) u) (c'.flipMultilinear u) s x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp_hasFDerivWithinAt x hc
@[fun_prop]
theorem HasFDerivAt.continuousMultilinear_apply_const (hc : HasFDerivAt c c' x) (u : ∀ i, M i) :
HasFDerivAt (fun y ↦ (c y) u) (c'.flipMultilinear u) x :=
(ContinuousMultilinearMap.apply 𝕜 M H u).hasFDerivAt.comp x hc
@[fun_prop]
theorem DifferentiableWithinAt.continuousMultilinear_apply_const
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) :
DifferentiableWithinAt 𝕜 (fun y ↦ (c y) u) s x :=
(hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x)
(u : ∀ i, M i) :
DifferentiableAt 𝕜 (fun y ↦ (c y) u) x :=
(hc.hasFDerivAt.continuousMultilinear_apply_const u).differentiableAt
@[fun_prop]
theorem DifferentiableOn.continuousMultilinear_apply_const (hc : DifferentiableOn 𝕜 c s)
(u : ∀ i, M i) : DifferentiableOn 𝕜 (fun y ↦ (c y) u) s :=
fun x hx ↦ (hc x hx).continuousMultilinear_apply_const u
@[fun_prop]
theorem Differentiable.continuousMultilinear_apply_const (hc : Differentiable 𝕜 c) (u : ∀ i, M i) :
Differentiable 𝕜 fun y ↦ (c y) u := fun x ↦ (hc x).continuousMultilinear_apply_const u
theorem fderivWithin_continuousMultilinear_apply_const (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) :
fderivWithin 𝕜 (fun y ↦ (c y) u) s x = ((fderivWithin 𝕜 c s x).flipMultilinear u) :=
(hc.hasFDerivWithinAt.continuousMultilinear_apply_const u).fderivWithin hxs
theorem fderiv_continuousMultilinear_apply_const (hc : DifferentiableAt 𝕜 c x) (u : ∀ i, M i) :
(fderiv 𝕜 (fun y ↦ (c y) u) x) = (fderiv 𝕜 c x).flipMultilinear u :=
(hc.hasFDerivAt.continuousMultilinear_apply_const u).fderiv
| Mathlib/Analysis/Calculus/FDeriv/Mul.lean | 224 | 227 | theorem fderivWithin_continuousMultilinear_apply_const_apply (hxs : UniqueDiffWithinAt 𝕜 s x)
(hc : DifferentiableWithinAt 𝕜 c s x) (u : ∀ i, M i) (m : E) :
(fderivWithin 𝕜 (fun y ↦ (c y) u) s x) m = (fderivWithin 𝕜 c s x) m u := by |
simp [fderivWithin_continuousMultilinear_apply_const hxs hc]
|
import Mathlib.Algebra.Module.Hom
import Mathlib.Algebra.Module.LinearMap.End
#align_import algebra.module.equiv from "leanprover-community/mathlib"@"ea94d7cd54ad9ca6b7710032868abb7c6a104c9c"
open Function
universe u u' v w x y z
variable {R : Type*} {R₁ : Type*} {R₂ : Type*} {R₃ : Type*}
variable {k : Type*} {K : Type*} {S : Type*} {M : Type*} {M₁ : Type*} {M₂ : Type*} {M₃ : Type*}
variable {N₁ : Type*} {N₂ : Type*} {N₃ : Type*} {N₄ : Type*} {ι : Type*}
section
-- Porting note (#11215): TODO @[nolint has_nonempty_instance]
structure LinearEquiv {R : Type*} {S : Type*} [Semiring R] [Semiring S] (σ : R →+* S)
{σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ] (M : Type*) (M₂ : Type*)
[AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂] extends LinearMap σ M M₂, M ≃+ M₂
#align linear_equiv LinearEquiv
attribute [coe] LinearEquiv.toLinearMap
add_decl_doc LinearEquiv.toLinearMap
#align linear_equiv.to_linear_map LinearEquiv.toLinearMap
add_decl_doc LinearEquiv.toAddEquiv
#align linear_equiv.to_add_equiv LinearEquiv.toAddEquiv
add_decl_doc LinearEquiv.invFun
add_decl_doc LinearEquiv.right_inv
add_decl_doc LinearEquiv.left_inv
notation:50 M " ≃ₛₗ[" σ "] " M₂ => LinearEquiv σ M M₂
notation:50 M " ≃ₗ[" R "] " M₂ => LinearEquiv (RingHom.id R) M M₂
notation:50 M " ≃ₗ⋆[" R "] " M₂ => LinearEquiv (starRingEnd R) M M₂
class SemilinearEquivClass (F : Type*) {R S : outParam Type*} [Semiring R] [Semiring S]
(σ : outParam <| R →+* S) {σ' : outParam <| S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]
(M M₂ : outParam Type*) [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂]
[EquivLike F M M₂]
extends AddEquivClass F M M₂ : Prop where
map_smulₛₗ : ∀ (f : F) (r : R) (x : M), f (r • x) = σ r • f x
#align semilinear_equiv_class SemilinearEquivClass
-- `R, S, σ, σ'` become metavars, but it's OK since they are outparams.
abbrev LinearEquivClass (F : Type*) (R M M₂ : outParam Type*) [Semiring R] [AddCommMonoid M]
[AddCommMonoid M₂] [Module R M] [Module R M₂] [EquivLike F M M₂] :=
SemilinearEquivClass F (RingHom.id R) M M₂
#align linear_equiv_class LinearEquivClass
end
namespace LinearEquiv
section AddCommMonoid
variable {M₄ : Type*}
variable [Semiring R] [Semiring S]
section
variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂]
variable [Module R M] [Module S M₂] {σ : R →+* S} {σ' : S →+* R}
variable [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]
instance : Coe (M ≃ₛₗ[σ] M₂) (M →ₛₗ[σ] M₂) :=
⟨toLinearMap⟩
-- This exists for compatibility, previously `≃ₗ[R]` extended `≃` instead of `≃+`.
def toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂ := fun f => f.toAddEquiv.toEquiv
#align linear_equiv.to_equiv LinearEquiv.toEquiv
theorem toEquiv_injective : Function.Injective (toEquiv : (M ≃ₛₗ[σ] M₂) → M ≃ M₂) :=
fun ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ ⟨⟨⟨_, _⟩, _⟩, _, _, _⟩ h =>
(LinearEquiv.mk.injEq _ _ _ _ _ _ _ _).mpr
⟨LinearMap.ext (congr_fun (Equiv.mk.inj h).1), (Equiv.mk.inj h).2⟩
#align linear_equiv.to_equiv_injective LinearEquiv.toEquiv_injective
@[simp]
theorem toEquiv_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : e₁.toEquiv = e₂.toEquiv ↔ e₁ = e₂ :=
toEquiv_injective.eq_iff
#align linear_equiv.to_equiv_inj LinearEquiv.toEquiv_inj
theorem toLinearMap_injective : Injective (toLinearMap : (M ≃ₛₗ[σ] M₂) → M →ₛₗ[σ] M₂) :=
fun _ _ H => toEquiv_injective <| Equiv.ext <| LinearMap.congr_fun H
#align linear_equiv.to_linear_map_injective LinearEquiv.toLinearMap_injective
@[simp, norm_cast]
theorem toLinearMap_inj {e₁ e₂ : M ≃ₛₗ[σ] M₂} : (↑e₁ : M →ₛₗ[σ] M₂) = e₂ ↔ e₁ = e₂ :=
toLinearMap_injective.eq_iff
#align linear_equiv.to_linear_map_inj LinearEquiv.toLinearMap_inj
instance : EquivLike (M ≃ₛₗ[σ] M₂) M M₂ where
inv := LinearEquiv.invFun
coe_injective' _ _ h _ := toLinearMap_injective (DFunLike.coe_injective h)
left_inv := LinearEquiv.left_inv
right_inv := LinearEquiv.right_inv
instance : FunLike (M ≃ₛₗ[σ] M₂) M M₂ where
coe := DFunLike.coe
coe_injective' := DFunLike.coe_injective
instance : SemilinearEquivClass (M ≃ₛₗ[σ] M₂) σ M M₂ where
map_add := (·.map_add') --map_add' Porting note (#11215): TODO why did I need to change this?
map_smulₛₗ := (·.map_smul') --map_smul' Porting note (#11215): TODO why did I need to change this?
-- Porting note: moved to a lower line since there is no shortcut `CoeFun` instance any more
@[simp]
theorem coe_mk {to_fun inv_fun map_add map_smul left_inv right_inv} :
(⟨⟨⟨to_fun, map_add⟩, map_smul⟩, inv_fun, left_inv, right_inv⟩ : M ≃ₛₗ[σ] M₂) = to_fun := rfl
#align linear_equiv.coe_mk LinearEquiv.coe_mk
theorem coe_injective : @Injective (M ≃ₛₗ[σ] M₂) (M → M₂) CoeFun.coe :=
DFunLike.coe_injective
#align linear_equiv.coe_injective LinearEquiv.coe_injective
end
section
variable [Semiring R₁] [Semiring R₂] [Semiring R₃]
variable [AddCommMonoid M] [AddCommMonoid M₁] [AddCommMonoid M₂]
variable [AddCommMonoid M₃] [AddCommMonoid M₄]
variable [AddCommMonoid N₁] [AddCommMonoid N₂]
variable {module_M : Module R M} {module_S_M₂ : Module S M₂} {σ : R →+* S} {σ' : S →+* R}
variable {re₁ : RingHomInvPair σ σ'} {re₂ : RingHomInvPair σ' σ}
variable (e e' : M ≃ₛₗ[σ] M₂)
@[simp, norm_cast]
theorem coe_coe : ⇑(e : M →ₛₗ[σ] M₂) = e :=
rfl
#align linear_equiv.coe_coe LinearEquiv.coe_coe
@[simp]
theorem coe_toEquiv : ⇑(e.toEquiv) = e :=
rfl
#align linear_equiv.coe_to_equiv LinearEquiv.coe_toEquiv
@[simp]
theorem coe_toLinearMap : ⇑e.toLinearMap = e :=
rfl
#align linear_equiv.coe_to_linear_map LinearEquiv.coe_toLinearMap
-- Porting note: no longer a `simp`
theorem toFun_eq_coe : e.toFun = e := rfl
#align linear_equiv.to_fun_eq_coe LinearEquiv.toFun_eq_coe
section
variable {e e'}
@[ext]
theorem ext (h : ∀ x, e x = e' x) : e = e' :=
DFunLike.ext _ _ h
#align linear_equiv.ext LinearEquiv.ext
theorem ext_iff : e = e' ↔ ∀ x, e x = e' x :=
DFunLike.ext_iff
#align linear_equiv.ext_iff LinearEquiv.ext_iff
protected theorem congr_arg {x x'} : x = x' → e x = e x' :=
DFunLike.congr_arg e
#align linear_equiv.congr_arg LinearEquiv.congr_arg
protected theorem congr_fun (h : e = e') (x : M) : e x = e' x :=
DFunLike.congr_fun h x
#align linear_equiv.congr_fun LinearEquiv.congr_fun
end
section
variable (M R)
@[refl]
def refl [Module R M] : M ≃ₗ[R] M :=
{ LinearMap.id, Equiv.refl M with }
#align linear_equiv.refl LinearEquiv.refl
end
@[simp]
theorem refl_apply [Module R M] (x : M) : refl R M x = x :=
rfl
#align linear_equiv.refl_apply LinearEquiv.refl_apply
@[symm]
def symm (e : M ≃ₛₗ[σ] M₂) : M₂ ≃ₛₗ[σ'] M :=
{ e.toLinearMap.inverse e.invFun e.left_inv e.right_inv,
e.toEquiv.symm with
toFun := e.toLinearMap.inverse e.invFun e.left_inv e.right_inv
invFun := e.toEquiv.symm.invFun
map_smul' := fun r x => by dsimp only; rw [map_smulₛₗ] }
#align linear_equiv.symm LinearEquiv.symm
-- Porting note: this is new
def Simps.apply {R : Type*} {S : Type*} [Semiring R] [Semiring S]
{σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]
{M : Type*} {M₂ : Type*} [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂]
(e : M ≃ₛₗ[σ] M₂) : M → M₂ :=
e
#align linear_equiv.simps.apply LinearEquiv.Simps.apply
def Simps.symm_apply {R : Type*} {S : Type*} [Semiring R] [Semiring S]
{σ : R →+* S} {σ' : S →+* R} [RingHomInvPair σ σ'] [RingHomInvPair σ' σ]
{M : Type*} {M₂ : Type*} [AddCommMonoid M] [AddCommMonoid M₂] [Module R M] [Module S M₂]
(e : M ≃ₛₗ[σ] M₂) : M₂ → M :=
e.symm
#align linear_equiv.simps.symm_apply LinearEquiv.Simps.symm_apply
initialize_simps_projections LinearEquiv (toFun → apply, invFun → symm_apply)
@[simp]
theorem invFun_eq_symm : e.invFun = e.symm :=
rfl
#align linear_equiv.inv_fun_eq_symm LinearEquiv.invFun_eq_symm
@[simp]
theorem coe_toEquiv_symm : e.toEquiv.symm = e.symm :=
rfl
#align linear_equiv.coe_to_equiv_symm LinearEquiv.coe_toEquiv_symm
variable {module_M₁ : Module R₁ M₁} {module_M₂ : Module R₂ M₂} {module_M₃ : Module R₃ M₃}
variable {module_N₁ : Module R₁ N₁} {module_N₂ : Module R₁ N₂}
variable {σ₁₂ : R₁ →+* R₂} {σ₂₃ : R₂ →+* R₃} {σ₁₃ : R₁ →+* R₃}
variable {σ₂₁ : R₂ →+* R₁} {σ₃₂ : R₃ →+* R₂} {σ₃₁ : R₃ →+* R₁}
variable [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃]
variable [RingHomCompTriple σ₃₂ σ₂₁ σ₃₁]
variable {re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₃ : RingHomInvPair σ₂₃ σ₃₂}
variable [RingHomInvPair σ₁₃ σ₃₁] {re₂₁ : RingHomInvPair σ₂₁ σ₁₂}
variable {re₃₂ : RingHomInvPair σ₃₂ σ₂₃} [RingHomInvPair σ₃₁ σ₁₃]
variable (e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃)
-- Porting note: Lean 4 aggressively removes unused variables declared using `variable`, so
-- we have to list all the variables explicitly here in order to match the Lean 3 signature.
set_option linter.unusedVariables false in
-- Note: the `RingHomCompTriple σ₃₂ σ₂₁ σ₃₁` is unused, but is convenient to carry around
-- implicitly for lemmas like `LinearEquiv.self_trans_symm`.
@[trans, nolint unusedArguments]
def trans
[RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] [RingHomCompTriple σ₃₂ σ₂₁ σ₃₁]
{re₁₂ : RingHomInvPair σ₁₂ σ₂₁} {re₂₃ : RingHomInvPair σ₂₃ σ₃₂}
[RingHomInvPair σ₁₃ σ₃₁] {re₂₁ : RingHomInvPair σ₂₁ σ₁₂}
{re₃₂ : RingHomInvPair σ₃₂ σ₂₃} [RingHomInvPair σ₃₁ σ₁₃]
(e₁₂ : M₁ ≃ₛₗ[σ₁₂] M₂) (e₂₃ : M₂ ≃ₛₗ[σ₂₃] M₃) : M₁ ≃ₛₗ[σ₁₃] M₃ :=
{ e₂₃.toLinearMap.comp e₁₂.toLinearMap, e₁₂.toEquiv.trans e₂₃.toEquiv with }
#align linear_equiv.trans LinearEquiv.trans
notation3:80 (name := transNotation) e₁:80 " ≪≫ₗ " e₂:81 =>
@LinearEquiv.trans _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ (RingHom.id _) (RingHom.id _) (RingHom.id _)
(RingHom.id _) (RingHom.id _) (RingHom.id _) RingHomCompTriple.ids RingHomCompTriple.ids
RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids RingHomInvPair.ids
RingHomInvPair.ids e₁ e₂
variable {e₁₂} {e₂₃}
@[simp]
theorem coe_toAddEquiv : e.toAddEquiv = e :=
rfl
#align linear_equiv.coe_to_add_equiv LinearEquiv.coe_toAddEquiv
theorem toAddMonoidHom_commutes : e.toLinearMap.toAddMonoidHom = e.toAddEquiv.toAddMonoidHom :=
rfl
#align linear_equiv.to_add_monoid_hom_commutes LinearEquiv.toAddMonoidHom_commutes
@[simp]
theorem trans_apply (c : M₁) : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃) c = e₂₃ (e₁₂ c) :=
rfl
#align linear_equiv.trans_apply LinearEquiv.trans_apply
theorem coe_trans :
(e₁₂.trans e₂₃ : M₁ →ₛₗ[σ₁₃] M₃) = (e₂₃ : M₂ →ₛₗ[σ₂₃] M₃).comp (e₁₂ : M₁ →ₛₗ[σ₁₂] M₂) :=
rfl
#align linear_equiv.coe_trans LinearEquiv.coe_trans
@[simp]
theorem apply_symm_apply (c : M₂) : e (e.symm c) = c :=
e.right_inv c
#align linear_equiv.apply_symm_apply LinearEquiv.apply_symm_apply
@[simp]
theorem symm_apply_apply (b : M) : e.symm (e b) = b :=
e.left_inv b
#align linear_equiv.symm_apply_apply LinearEquiv.symm_apply_apply
@[simp]
theorem trans_symm : (e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm = e₂₃.symm.trans e₁₂.symm :=
rfl
#align linear_equiv.trans_symm LinearEquiv.trans_symm
theorem symm_trans_apply (c : M₃) :
(e₁₂.trans e₂₃ : M₁ ≃ₛₗ[σ₁₃] M₃).symm c = e₁₂.symm (e₂₃.symm c) :=
rfl
#align linear_equiv.symm_trans_apply LinearEquiv.symm_trans_apply
@[simp]
theorem trans_refl : e.trans (refl S M₂) = e :=
toEquiv_injective e.toEquiv.trans_refl
#align linear_equiv.trans_refl LinearEquiv.trans_refl
@[simp]
theorem refl_trans : (refl R M).trans e = e :=
toEquiv_injective e.toEquiv.refl_trans
#align linear_equiv.refl_trans LinearEquiv.refl_trans
theorem symm_apply_eq {x y} : e.symm x = y ↔ x = e y :=
e.toEquiv.symm_apply_eq
#align linear_equiv.symm_apply_eq LinearEquiv.symm_apply_eq
theorem eq_symm_apply {x y} : y = e.symm x ↔ e y = x :=
e.toEquiv.eq_symm_apply
#align linear_equiv.eq_symm_apply LinearEquiv.eq_symm_apply
theorem eq_comp_symm {α : Type*} (f : M₂ → α) (g : M₁ → α) : f = g ∘ e₁₂.symm ↔ f ∘ e₁₂ = g :=
e₁₂.toEquiv.eq_comp_symm f g
#align linear_equiv.eq_comp_symm LinearEquiv.eq_comp_symm
theorem comp_symm_eq {α : Type*} (f : M₂ → α) (g : M₁ → α) : g ∘ e₁₂.symm = f ↔ g = f ∘ e₁₂ :=
e₁₂.toEquiv.comp_symm_eq f g
#align linear_equiv.comp_symm_eq LinearEquiv.comp_symm_eq
theorem eq_symm_comp {α : Type*} (f : α → M₁) (g : α → M₂) : f = e₁₂.symm ∘ g ↔ e₁₂ ∘ f = g :=
e₁₂.toEquiv.eq_symm_comp f g
#align linear_equiv.eq_symm_comp LinearEquiv.eq_symm_comp
theorem symm_comp_eq {α : Type*} (f : α → M₁) (g : α → M₂) : e₁₂.symm ∘ g = f ↔ g = e₁₂ ∘ f :=
e₁₂.toEquiv.symm_comp_eq f g
#align linear_equiv.symm_comp_eq LinearEquiv.symm_comp_eq
variable [RingHomCompTriple σ₂₁ σ₁₃ σ₂₃] [RingHomCompTriple σ₃₁ σ₁₂ σ₃₂]
theorem eq_comp_toLinearMap_symm (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₃] M₃) :
f = g.comp e₁₂.symm.toLinearMap ↔ f.comp e₁₂.toLinearMap = g := by
constructor <;> intro H <;> ext
· simp [H, e₁₂.toEquiv.eq_comp_symm f g]
· simp [← H, ← e₁₂.toEquiv.eq_comp_symm f g]
#align linear_equiv.eq_comp_to_linear_map_symm LinearEquiv.eq_comp_toLinearMap_symm
theorem comp_toLinearMap_symm_eq (f : M₂ →ₛₗ[σ₂₃] M₃) (g : M₁ →ₛₗ[σ₁₃] M₃) :
g.comp e₁₂.symm.toLinearMap = f ↔ g = f.comp e₁₂.toLinearMap := by
constructor <;> intro H <;> ext
· simp [← H, ← e₁₂.toEquiv.comp_symm_eq f g]
· simp [H, e₁₂.toEquiv.comp_symm_eq f g]
#align linear_equiv.comp_to_linear_map_symm_eq LinearEquiv.comp_toLinearMap_symm_eq
theorem eq_toLinearMap_symm_comp (f : M₃ →ₛₗ[σ₃₁] M₁) (g : M₃ →ₛₗ[σ₃₂] M₂) :
f = e₁₂.symm.toLinearMap.comp g ↔ e₁₂.toLinearMap.comp f = g := by
constructor <;> intro H <;> ext
· simp [H, e₁₂.toEquiv.eq_symm_comp f g]
· simp [← H, ← e₁₂.toEquiv.eq_symm_comp f g]
#align linear_equiv.eq_to_linear_map_symm_comp LinearEquiv.eq_toLinearMap_symm_comp
theorem toLinearMap_symm_comp_eq (f : M₃ →ₛₗ[σ₃₁] M₁) (g : M₃ →ₛₗ[σ₃₂] M₂) :
e₁₂.symm.toLinearMap.comp g = f ↔ g = e₁₂.toLinearMap.comp f := by
constructor <;> intro H <;> ext
· simp [← H, ← e₁₂.toEquiv.symm_comp_eq f g]
· simp [H, e₁₂.toEquiv.symm_comp_eq f g]
#align linear_equiv.to_linear_map_symm_comp_eq LinearEquiv.toLinearMap_symm_comp_eq
@[simp]
theorem refl_symm [Module R M] : (refl R M).symm = LinearEquiv.refl R M :=
rfl
#align linear_equiv.refl_symm LinearEquiv.refl_symm
@[simp]
theorem self_trans_symm (f : M₁ ≃ₛₗ[σ₁₂] M₂) : f.trans f.symm = LinearEquiv.refl R₁ M₁ := by
ext x
simp
#align linear_equiv.self_trans_symm LinearEquiv.self_trans_symm
@[simp]
| Mathlib/Algebra/Module/Equiv.lean | 473 | 475 | theorem symm_trans_self (f : M₁ ≃ₛₗ[σ₁₂] M₂) : f.symm.trans f = LinearEquiv.refl R₂ M₂ := by |
ext x
simp
|
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.RingTheory.Polynomial.Bernstein
import Mathlib.Topology.ContinuousFunction.Polynomial
import Mathlib.Topology.ContinuousFunction.Compact
#align_import analysis.special_functions.bernstein from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
set_option linter.uppercaseLean3 false -- S
noncomputable section
open scoped Classical BoundedContinuousFunction unitInterval
def bernstein (n ν : ℕ) : C(I, ℝ) :=
(bernsteinPolynomial ℝ n ν).toContinuousMapOn I
#align bernstein bernstein
@[simp]
theorem bernstein_apply (n ν : ℕ) (x : I) :
bernstein n ν x = (n.choose ν : ℝ) * (x : ℝ) ^ ν * (1 - (x : ℝ)) ^ (n - ν) := by
dsimp [bernstein, Polynomial.toContinuousMapOn, Polynomial.toContinuousMap, bernsteinPolynomial]
simp
#align bernstein_apply bernstein_apply
theorem bernstein_nonneg {n ν : ℕ} {x : I} : 0 ≤ bernstein n ν x := by
simp only [bernstein_apply]
have h₁ : (0:ℝ) ≤ x := by unit_interval
have h₂ : (0:ℝ) ≤ 1 - x := by unit_interval
positivity
#align bernstein_nonneg bernstein_nonneg
open bernstein
local postfix:1024 "/ₙ" => z
def bernsteinApproximation (n : ℕ) (f : C(I, ℝ)) : C(I, ℝ) :=
∑ k : Fin (n + 1), f k/ₙ • bernstein n k
#align bernstein_approximation bernsteinApproximation
namespace bernsteinApproximation
@[simp]
theorem apply (n : ℕ) (f : C(I, ℝ)) (x : I) :
bernsteinApproximation n f x = ∑ k : Fin (n + 1), f k/ₙ * bernstein n k x := by
simp [bernsteinApproximation]
#align bernstein_approximation.apply bernsteinApproximation.apply
def δ (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) : ℝ :=
f.modulus (ε / 2) (half_pos h)
#align bernstein_approximation.δ bernsteinApproximation.δ
theorem δ_pos {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} : 0 < δ f ε h :=
f.modulus_pos
#align bernstein_approximation.δ_pos bernsteinApproximation.δ_pos
def S (f : C(I, ℝ)) (ε : ℝ) (h : 0 < ε) (n : ℕ) (x : I) : Finset (Fin (n + 1)) :=
{k : Fin (n + 1) | dist k/ₙ x < δ f ε h}.toFinset
#align bernstein_approximation.S bernsteinApproximation.S
theorem lt_of_mem_S {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
(m : k ∈ S f ε h n x) : |f k/ₙ - f x| < ε / 2 := by
apply f.dist_lt_of_dist_lt_modulus (ε / 2) (half_pos h)
-- Porting note: `simp` fails to apply `Set.mem_toFinset` on its own
simpa [S, (Set.mem_toFinset)] using m
#align bernstein_approximation.lt_of_mem_S bernsteinApproximation.lt_of_mem_S
| Mathlib/Analysis/SpecialFunctions/Bernstein.lean | 203 | 209 | theorem le_of_mem_S_compl {f : C(I, ℝ)} {ε : ℝ} {h : 0 < ε} {n : ℕ} {x : I} {k : Fin (n + 1)}
(m : k ∈ (S f ε h n x)ᶜ) : (1 : ℝ) ≤ δ f ε h ^ (-2 : ℤ) * ((x : ℝ) - k/ₙ) ^ 2 := by |
-- Porting note: added parentheses to help `simp`
simp only [Finset.mem_compl, not_lt, Set.mem_toFinset, Set.mem_setOf_eq, S] at m
rw [zpow_neg, ← div_eq_inv_mul, zpow_two, ← pow_two, one_le_div (pow_pos δ_pos 2), sq_le_sq,
abs_of_pos δ_pos]
rwa [dist_comm] at m
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Complex
#align_import analysis.special_functions.trigonometric.complex_deriv from "leanprover-community/mathlib"@"2c1d8ca2812b64f88992a5294ea3dba144755cd1"
noncomputable section
namespace Complex
open Set Filter
open scoped Real
| Mathlib/Analysis/SpecialFunctions/Trigonometric/ComplexDeriv.lean | 25 | 28 | theorem hasStrictDerivAt_tan {x : ℂ} (h : cos x ≠ 0) : HasStrictDerivAt tan (1 / cos x ^ 2) x := by |
convert (hasStrictDerivAt_sin x).div (hasStrictDerivAt_cos x) h using 1
rw_mod_cast [← sin_sq_add_cos_sq x]
ring
|
import Mathlib.Algebra.Order.Group.TypeTags
import Mathlib.FieldTheory.RatFunc.Degree
import Mathlib.RingTheory.DedekindDomain.IntegralClosure
import Mathlib.RingTheory.IntegrallyClosed
import Mathlib.Topology.Algebra.ValuedField
#align_import number_theory.function_field from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
open scoped nonZeroDivisors Polynomial DiscreteValuation
variable (Fq F : Type) [Field Fq] [Field F]
abbrev FunctionField [Algebra (RatFunc Fq) F] : Prop :=
FiniteDimensional (RatFunc Fq) F
#align function_field FunctionField
-- Porting note: Removed `protected`
theorem functionField_iff (Fqt : Type*) [Field Fqt] [Algebra Fq[X] Fqt]
[IsFractionRing Fq[X] Fqt] [Algebra (RatFunc Fq) F] [Algebra Fqt F] [Algebra Fq[X] F]
[IsScalarTower Fq[X] Fqt F] [IsScalarTower Fq[X] (RatFunc Fq) F] :
FunctionField Fq F ↔ FiniteDimensional Fqt F := by
let e := IsLocalization.algEquiv Fq[X]⁰ (RatFunc Fq) Fqt
have : ∀ (c) (x : F), e c • x = c • x := by
intro c x
rw [Algebra.smul_def, Algebra.smul_def]
congr
refine congr_fun (f := fun c => algebraMap Fqt F (e c)) ?_ c -- Porting note: Added `(f := _)`
refine IsLocalization.ext (nonZeroDivisors Fq[X]) _ _ ?_ ?_ ?_ ?_ ?_ <;> intros <;>
simp only [AlgEquiv.map_one, RingHom.map_one, AlgEquiv.map_mul, RingHom.map_mul,
AlgEquiv.commutes, ← IsScalarTower.algebraMap_apply]
constructor <;> intro h
· let b := FiniteDimensional.finBasis (RatFunc Fq) F
exact FiniteDimensional.of_fintype_basis (b.mapCoeffs e this)
· let b := FiniteDimensional.finBasis Fqt F
refine FiniteDimensional.of_fintype_basis (b.mapCoeffs e.symm ?_)
intro c x; convert (this (e.symm c) x).symm; simp only [e.apply_symm_apply]
#align function_field_iff functionField_iff
theorem algebraMap_injective [Algebra Fq[X] F] [Algebra (RatFunc Fq) F]
[IsScalarTower Fq[X] (RatFunc Fq) F] : Function.Injective (⇑(algebraMap Fq[X] F)) := by
rw [IsScalarTower.algebraMap_eq Fq[X] (RatFunc Fq) F]
exact (algebraMap (RatFunc Fq) F).injective.comp (IsFractionRing.injective Fq[X] (RatFunc Fq))
#align algebra_map_injective algebraMap_injective
namespace FunctionField
def ringOfIntegers [Algebra Fq[X] F] :=
integralClosure Fq[X] F
#align function_field.ring_of_integers FunctionField.ringOfIntegers
section InftyValuation
variable [DecidableEq (RatFunc Fq)]
def inftyValuationDef (r : RatFunc Fq) : ℤₘ₀ :=
if r = 0 then 0 else ↑(Multiplicative.ofAdd r.intDegree)
#align function_field.infty_valuation_def FunctionField.inftyValuationDef
theorem InftyValuation.map_zero' : inftyValuationDef Fq 0 = 0 :=
if_pos rfl
#align function_field.infty_valuation.map_zero' FunctionField.InftyValuation.map_zero'
theorem InftyValuation.map_one' : inftyValuationDef Fq 1 = 1 :=
(if_neg one_ne_zero).trans <| by rw [RatFunc.intDegree_one, ofAdd_zero, WithZero.coe_one]
#align function_field.infty_valuation.map_one' FunctionField.InftyValuation.map_one'
theorem InftyValuation.map_mul' (x y : RatFunc Fq) :
inftyValuationDef Fq (x * y) = inftyValuationDef Fq x * inftyValuationDef Fq y := by
rw [inftyValuationDef, inftyValuationDef, inftyValuationDef]
by_cases hx : x = 0
· rw [hx, zero_mul, if_pos (Eq.refl _), zero_mul]
· by_cases hy : y = 0
· rw [hy, mul_zero, if_pos (Eq.refl _), mul_zero]
· rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← WithZero.coe_mul, WithZero.coe_inj,
← ofAdd_add, RatFunc.intDegree_mul hx hy]
#align function_field.infty_valuation.map_mul' FunctionField.InftyValuation.map_mul'
theorem InftyValuation.map_add_le_max' (x y : RatFunc Fq) :
inftyValuationDef Fq (x + y) ≤ max (inftyValuationDef Fq x) (inftyValuationDef Fq y) := by
by_cases hx : x = 0
· rw [hx, zero_add]
conv_rhs => rw [inftyValuationDef, if_pos (Eq.refl _)]
rw [max_eq_right (WithZero.zero_le (inftyValuationDef Fq y))]
· by_cases hy : y = 0
· rw [hy, add_zero]
conv_rhs => rw [max_comm, inftyValuationDef, if_pos (Eq.refl _)]
rw [max_eq_right (WithZero.zero_le (inftyValuationDef Fq x))]
· by_cases hxy : x + y = 0
· rw [inftyValuationDef, if_pos hxy]; exact zero_le'
· rw [inftyValuationDef, inftyValuationDef, inftyValuationDef, if_neg hx, if_neg hy,
if_neg hxy]
rw [le_max_iff, WithZero.coe_le_coe, Multiplicative.ofAdd_le, WithZero.coe_le_coe,
Multiplicative.ofAdd_le, ← le_max_iff]
exact RatFunc.intDegree_add_le hy hxy
#align function_field.infty_valuation.map_add_le_max' FunctionField.InftyValuation.map_add_le_max'
@[simp]
| Mathlib/NumberTheory/FunctionField.lean | 199 | 201 | theorem inftyValuation_of_nonzero {x : RatFunc Fq} (hx : x ≠ 0) :
inftyValuationDef Fq x = Multiplicative.ofAdd x.intDegree := by |
rw [inftyValuationDef, if_neg hx]
|
import Mathlib.Data.Stream.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Init.Data.List.Basic
import Mathlib.Data.List.Basic
#align_import data.stream.init from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
set_option autoImplicit true
open Nat Function Option
namespace Stream'
variable {α : Type u} {β : Type v} {δ : Type w}
instance [Inhabited α] : Inhabited (Stream' α) :=
⟨Stream'.const default⟩
protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
funext fun i => by cases i <;> rfl
#align stream.eta Stream'.eta
@[ext]
protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, get s₁ n = get s₂ n) → s₁ = s₂ :=
fun h => funext h
#align stream.ext Stream'.ext
@[simp]
theorem get_zero_cons (a : α) (s : Stream' α) : get (a::s) 0 = a :=
rfl
#align stream.nth_zero_cons Stream'.get_zero_cons
@[simp]
theorem head_cons (a : α) (s : Stream' α) : head (a::s) = a :=
rfl
#align stream.head_cons Stream'.head_cons
@[simp]
theorem tail_cons (a : α) (s : Stream' α) : tail (a::s) = s :=
rfl
#align stream.tail_cons Stream'.tail_cons
@[simp]
theorem get_drop (n m : Nat) (s : Stream' α) : get (drop m s) n = get s (n + m) :=
rfl
#align stream.nth_drop Stream'.get_drop
theorem tail_eq_drop (s : Stream' α) : tail s = drop 1 s :=
rfl
#align stream.tail_eq_drop Stream'.tail_eq_drop
@[simp]
theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s := by
ext; simp [Nat.add_assoc]
#align stream.drop_drop Stream'.drop_drop
@[simp] theorem get_tail {s : Stream' α} : s.tail.get n = s.get (n + 1) := rfl
@[simp] theorem tail_drop' {s : Stream' α} : tail (drop i s) = s.drop (i+1) := by
ext; simp [Nat.add_comm, Nat.add_assoc, Nat.add_left_comm]
@[simp] theorem drop_tail' {s : Stream' α} : drop i (tail s) = s.drop (i+1) := rfl
theorem tail_drop (n : Nat) (s : Stream' α) : tail (drop n s) = drop n (tail s) := by simp
#align stream.tail_drop Stream'.tail_drop
theorem get_succ (n : Nat) (s : Stream' α) : get s (succ n) = get (tail s) n :=
rfl
#align stream.nth_succ Stream'.get_succ
@[simp]
theorem get_succ_cons (n : Nat) (s : Stream' α) (x : α) : get (x::s) n.succ = get s n :=
rfl
#align stream.nth_succ_cons Stream'.get_succ_cons
@[simp] theorem drop_zero {s : Stream' α} : s.drop 0 = s := rfl
theorem drop_succ (n : Nat) (s : Stream' α) : drop (succ n) s = drop n (tail s) :=
rfl
#align stream.drop_succ Stream'.drop_succ
theorem head_drop (a : Stream' α) (n : ℕ) : (a.drop n).head = a.get n := by simp
#align stream.head_drop Stream'.head_drop
theorem cons_injective2 : Function.Injective2 (cons : α → Stream' α → Stream' α) := fun x y s t h =>
⟨by rw [← get_zero_cons x s, h, get_zero_cons],
Stream'.ext fun n => by rw [← get_succ_cons n _ x, h, get_succ_cons]⟩
#align stream.cons_injective2 Stream'.cons_injective2
theorem cons_injective_left (s : Stream' α) : Function.Injective fun x => cons x s :=
cons_injective2.left _
#align stream.cons_injective_left Stream'.cons_injective_left
theorem cons_injective_right (x : α) : Function.Injective (cons x) :=
cons_injective2.right _
#align stream.cons_injective_right Stream'.cons_injective_right
theorem all_def (p : α → Prop) (s : Stream' α) : All p s = ∀ n, p (get s n) :=
rfl
#align stream.all_def Stream'.all_def
theorem any_def (p : α → Prop) (s : Stream' α) : Any p s = ∃ n, p (get s n) :=
rfl
#align stream.any_def Stream'.any_def
@[simp]
theorem mem_cons (a : α) (s : Stream' α) : a ∈ a::s :=
Exists.intro 0 rfl
#align stream.mem_cons Stream'.mem_cons
theorem mem_cons_of_mem {a : α} {s : Stream' α} (b : α) : a ∈ s → a ∈ b::s := fun ⟨n, h⟩ =>
Exists.intro (succ n) (by rw [get_succ, tail_cons, h])
#align stream.mem_cons_of_mem Stream'.mem_cons_of_mem
theorem eq_or_mem_of_mem_cons {a b : α} {s : Stream' α} : (a ∈ b::s) → a = b ∨ a ∈ s :=
fun ⟨n, h⟩ => by
cases' n with n'
· left
exact h
· right
rw [get_succ, tail_cons] at h
exact ⟨n', h⟩
#align stream.eq_or_mem_of_mem_cons Stream'.eq_or_mem_of_mem_cons
theorem mem_of_get_eq {n : Nat} {s : Stream' α} {a : α} : a = get s n → a ∈ s := fun h =>
Exists.intro n h
#align stream.mem_of_nth_eq Stream'.mem_of_get_eq
@[simp]
theorem mem_const (a : α) : a ∈ const a :=
Exists.intro 0 rfl
#align stream.mem_const Stream'.mem_const
theorem const_eq (a : α) : const a = a::const a := by
apply Stream'.ext; intro n
cases n <;> rfl
#align stream.const_eq Stream'.const_eq
@[simp]
theorem tail_const (a : α) : tail (const a) = const a :=
suffices tail (a::const a) = const a by rwa [← const_eq] at this
rfl
#align stream.tail_const Stream'.tail_const
@[simp]
theorem map_const (f : α → β) (a : α) : map f (const a) = const (f a) :=
rfl
#align stream.map_const Stream'.map_const
@[simp]
theorem get_const (n : Nat) (a : α) : get (const a) n = a :=
rfl
#align stream.nth_const Stream'.get_const
@[simp]
theorem drop_const (n : Nat) (a : α) : drop n (const a) = const a :=
Stream'.ext fun _ => rfl
#align stream.drop_const Stream'.drop_const
@[simp]
theorem head_iterate (f : α → α) (a : α) : head (iterate f a) = a :=
rfl
#align stream.head_iterate Stream'.head_iterate
theorem get_succ_iterate' (n : Nat) (f : α → α) (a : α) :
get (iterate f a) (succ n) = f (get (iterate f a) n) := rfl
theorem tail_iterate (f : α → α) (a : α) : tail (iterate f a) = iterate f (f a) := by
ext n
rw [get_tail]
induction' n with n' ih
· rfl
· rw [get_succ_iterate', ih, get_succ_iterate']
#align stream.tail_iterate Stream'.tail_iterate
theorem iterate_eq (f : α → α) (a : α) : iterate f a = a::iterate f (f a) := by
rw [← Stream'.eta (iterate f a)]
rw [tail_iterate]; rfl
#align stream.iterate_eq Stream'.iterate_eq
@[simp]
theorem get_zero_iterate (f : α → α) (a : α) : get (iterate f a) 0 = a :=
rfl
#align stream.nth_zero_iterate Stream'.get_zero_iterate
theorem get_succ_iterate (n : Nat) (f : α → α) (a : α) :
get (iterate f a) (succ n) = get (iterate f (f a)) n := by rw [get_succ, tail_iterate]
#align stream.nth_succ_iterate Stream'.get_succ_iterate
theorem bisim_simple (s₁ s₂ : Stream' α) :
head s₁ = head s₂ → s₁ = tail s₁ → s₂ = tail s₂ → s₁ = s₂ := fun hh ht₁ ht₂ =>
eq_of_bisim (fun s₁ s₂ => head s₁ = head s₂ ∧ s₁ = tail s₁ ∧ s₂ = tail s₂)
(fun s₁ s₂ ⟨h₁, h₂, h₃⟩ => by
constructor
· exact h₁
rw [← h₂, ← h₃]
(repeat' constructor) <;> assumption)
(And.intro hh (And.intro ht₁ ht₂))
#align stream.bisim_simple Stream'.bisim_simple
theorem coinduction {s₁ s₂ : Stream' α} :
head s₁ = head s₂ →
(∀ (β : Type u) (fr : Stream' α → β),
fr s₁ = fr s₂ → fr (tail s₁) = fr (tail s₂)) → s₁ = s₂ :=
fun hh ht =>
eq_of_bisim
(fun s₁ s₂ =>
head s₁ = head s₂ ∧
∀ (β : Type u) (fr : Stream' α → β), fr s₁ = fr s₂ → fr (tail s₁) = fr (tail s₂))
(fun s₁ s₂ h =>
have h₁ : head s₁ = head s₂ := And.left h
have h₂ : head (tail s₁) = head (tail s₂) := And.right h α (@head α) h₁
have h₃ :
∀ (β : Type u) (fr : Stream' α → β),
fr (tail s₁) = fr (tail s₂) → fr (tail (tail s₁)) = fr (tail (tail s₂)) :=
fun β fr => And.right h β fun s => fr (tail s)
And.intro h₁ (And.intro h₂ h₃))
(And.intro hh ht)
#align stream.coinduction Stream'.coinduction
@[simp]
theorem iterate_id (a : α) : iterate id a = const a :=
coinduction rfl fun β fr ch => by rw [tail_iterate, tail_const]; exact ch
#align stream.iterate_id Stream'.iterate_id
theorem map_iterate (f : α → α) (a : α) : iterate f (f a) = map f (iterate f a) := by
funext n
induction' n with n' ih
· rfl
· unfold map iterate get
rw [map, get] at ih
rw [iterate]
exact congrArg f ih
#align stream.map_iterate Stream'.map_iterate
theorem unfolds_eq (g : α → β) (f : α → α) (a : α) : unfolds g f a = g a::unfolds g f (f a) := by
unfold unfolds; rw [corec_eq]
#align stream.unfolds_eq Stream'.unfolds_eq
theorem get_unfolds_head_tail : ∀ (n : Nat) (s : Stream' α),
get (unfolds head tail s) n = get s n := by
intro n; induction' n with n' ih
· intro s
rfl
· intro s
rw [get_succ, get_succ, unfolds_eq, tail_cons, ih]
#align stream.nth_unfolds_head_tail Stream'.get_unfolds_head_tail
theorem unfolds_head_eq : ∀ s : Stream' α, unfolds head tail s = s := fun s =>
Stream'.ext fun n => get_unfolds_head_tail n s
#align stream.unfolds_head_eq Stream'.unfolds_head_eq
theorem interleave_eq (s₁ s₂ : Stream' α) : s₁ ⋈ s₂ = head s₁::head s₂::(tail s₁ ⋈ tail s₂) := by
let t := tail s₁ ⋈ tail s₂
show s₁ ⋈ s₂ = head s₁::head s₂::t
unfold interleave; unfold corecOn; rw [corec_eq]; dsimp; rw [corec_eq]; rfl
#align stream.interleave_eq Stream'.interleave_eq
theorem tail_interleave (s₁ s₂ : Stream' α) : tail (s₁ ⋈ s₂) = s₂ ⋈ tail s₁ := by
unfold interleave corecOn; rw [corec_eq]; rfl
#align stream.tail_interleave Stream'.tail_interleave
theorem interleave_tail_tail (s₁ s₂ : Stream' α) : tail s₁ ⋈ tail s₂ = tail (tail (s₁ ⋈ s₂)) := by
rw [interleave_eq s₁ s₂]; rfl
#align stream.interleave_tail_tail Stream'.interleave_tail_tail
theorem get_interleave_left : ∀ (n : Nat) (s₁ s₂ : Stream' α),
get (s₁ ⋈ s₂) (2 * n) = get s₁ n
| 0, s₁, s₂ => rfl
| n + 1, s₁, s₂ => by
change get (s₁ ⋈ s₂) (succ (succ (2 * n))) = get s₁ (succ n)
rw [get_succ, get_succ, interleave_eq, tail_cons, tail_cons]
rw [get_interleave_left n (tail s₁) (tail s₂)]
rfl
#align stream.nth_interleave_left Stream'.get_interleave_left
theorem get_interleave_right : ∀ (n : Nat) (s₁ s₂ : Stream' α),
get (s₁ ⋈ s₂) (2 * n + 1) = get s₂ n
| 0, s₁, s₂ => rfl
| n + 1, s₁, s₂ => by
change get (s₁ ⋈ s₂) (succ (succ (2 * n + 1))) = get s₂ (succ n)
rw [get_succ, get_succ, interleave_eq, tail_cons, tail_cons,
get_interleave_right n (tail s₁) (tail s₂)]
rfl
#align stream.nth_interleave_right Stream'.get_interleave_right
theorem mem_interleave_left {a : α} {s₁ : Stream' α} (s₂ : Stream' α) : a ∈ s₁ → a ∈ s₁ ⋈ s₂ :=
fun ⟨n, h⟩ => Exists.intro (2 * n) (by rw [h, get_interleave_left])
#align stream.mem_interleave_left Stream'.mem_interleave_left
theorem mem_interleave_right {a : α} {s₁ : Stream' α} (s₂ : Stream' α) : a ∈ s₂ → a ∈ s₁ ⋈ s₂ :=
fun ⟨n, h⟩ => Exists.intro (2 * n + 1) (by rw [h, get_interleave_right])
#align stream.mem_interleave_right Stream'.mem_interleave_right
theorem odd_eq (s : Stream' α) : odd s = even (tail s) :=
rfl
#align stream.odd_eq Stream'.odd_eq
@[simp]
theorem head_even (s : Stream' α) : head (even s) = head s :=
rfl
#align stream.head_even Stream'.head_even
theorem tail_even (s : Stream' α) : tail (even s) = even (tail (tail s)) := by
unfold even
rw [corec_eq]
rfl
#align stream.tail_even Stream'.tail_even
theorem even_cons_cons (a₁ a₂ : α) (s : Stream' α) : even (a₁::a₂::s) = a₁::even s := by
unfold even
rw [corec_eq]; rfl
#align stream.even_cons_cons Stream'.even_cons_cons
theorem even_tail (s : Stream' α) : even (tail s) = odd s :=
rfl
#align stream.even_tail Stream'.even_tail
theorem even_interleave (s₁ s₂ : Stream' α) : even (s₁ ⋈ s₂) = s₁ :=
eq_of_bisim (fun s₁' s₁ => ∃ s₂, s₁' = even (s₁ ⋈ s₂))
(fun s₁' s₁ ⟨s₂, h₁⟩ => by
rw [h₁]
constructor
· rfl
· exact ⟨tail s₂, by rw [interleave_eq, even_cons_cons, tail_cons]⟩)
(Exists.intro s₂ rfl)
#align stream.even_interleave Stream'.even_interleave
theorem interleave_even_odd (s₁ : Stream' α) : even s₁ ⋈ odd s₁ = s₁ :=
eq_of_bisim (fun s' s => s' = even s ⋈ odd s)
(fun s' s (h : s' = even s ⋈ odd s) => by
rw [h]; constructor
· rfl
· simp [odd_eq, odd_eq, tail_interleave, tail_even])
rfl
#align stream.interleave_even_odd Stream'.interleave_even_odd
theorem get_even : ∀ (n : Nat) (s : Stream' α), get (even s) n = get s (2 * n)
| 0, s => rfl
| succ n, s => by
change get (even s) (succ n) = get s (succ (succ (2 * n)))
rw [get_succ, get_succ, tail_even, get_even n]; rfl
#align stream.nth_even Stream'.get_even
theorem get_odd : ∀ (n : Nat) (s : Stream' α), get (odd s) n = get s (2 * n + 1) := fun n s => by
rw [odd_eq, get_even]; rfl
#align stream.nth_odd Stream'.get_odd
theorem mem_of_mem_even (a : α) (s : Stream' α) : a ∈ even s → a ∈ s := fun ⟨n, h⟩ =>
Exists.intro (2 * n) (by rw [h, get_even])
#align stream.mem_of_mem_even Stream'.mem_of_mem_even
theorem mem_of_mem_odd (a : α) (s : Stream' α) : a ∈ odd s → a ∈ s := fun ⟨n, h⟩ =>
Exists.intro (2 * n + 1) (by rw [h, get_odd])
#align stream.mem_of_mem_odd Stream'.mem_of_mem_odd
theorem nil_append_stream (s : Stream' α) : appendStream' [] s = s :=
rfl
#align stream.nil_append_stream Stream'.nil_append_stream
theorem cons_append_stream (a : α) (l : List α) (s : Stream' α) :
appendStream' (a::l) s = a::appendStream' l s :=
rfl
#align stream.cons_append_stream Stream'.cons_append_stream
theorem append_append_stream : ∀ (l₁ l₂ : List α) (s : Stream' α),
l₁ ++ l₂ ++ₛ s = l₁ ++ₛ (l₂ ++ₛ s)
| [], l₂, s => rfl
| List.cons a l₁, l₂, s => by
rw [List.cons_append, cons_append_stream, cons_append_stream, append_append_stream l₁]
#align stream.append_append_stream Stream'.append_append_stream
theorem map_append_stream (f : α → β) :
∀ (l : List α) (s : Stream' α), map f (l ++ₛ s) = List.map f l ++ₛ map f s
| [], s => rfl
| List.cons a l, s => by
rw [cons_append_stream, List.map_cons, map_cons, cons_append_stream, map_append_stream f l]
#align stream.map_append_stream Stream'.map_append_stream
theorem drop_append_stream : ∀ (l : List α) (s : Stream' α), drop l.length (l ++ₛ s) = s
| [], s => by rfl
| List.cons a l, s => by
rw [List.length_cons, drop_succ, cons_append_stream, tail_cons, drop_append_stream l s]
#align stream.drop_append_stream Stream'.drop_append_stream
theorem append_stream_head_tail (s : Stream' α) : [head s] ++ₛ tail s = s := by
rw [cons_append_stream, nil_append_stream, Stream'.eta]
#align stream.append_stream_head_tail Stream'.append_stream_head_tail
theorem mem_append_stream_right : ∀ {a : α} (l : List α) {s : Stream' α}, a ∈ s → a ∈ l ++ₛ s
| _, [], _, h => h
| a, List.cons _ l, s, h =>
have ih : a ∈ l ++ₛ s := mem_append_stream_right l h
mem_cons_of_mem _ ih
#align stream.mem_append_stream_right Stream'.mem_append_stream_right
theorem mem_append_stream_left : ∀ {a : α} {l : List α} (s : Stream' α), a ∈ l → a ∈ l ++ₛ s
| _, [], _, h => absurd h (List.not_mem_nil _)
| a, List.cons b l, s, h =>
Or.elim (List.eq_or_mem_of_mem_cons h) (fun aeqb : a = b => Exists.intro 0 aeqb)
fun ainl : a ∈ l => mem_cons_of_mem b (mem_append_stream_left s ainl)
#align stream.mem_append_stream_left Stream'.mem_append_stream_left
@[simp]
theorem take_zero (s : Stream' α) : take 0 s = [] :=
rfl
#align stream.take_zero Stream'.take_zero
-- This lemma used to be simp, but we removed it from the simp set because:
-- 1) It duplicates the (often large) `s` term, resulting in large tactic states.
-- 2) It conflicts with the very useful `dropLast_take` lemma below (causing nonconfluence).
theorem take_succ (n : Nat) (s : Stream' α) : take (succ n) s = head s::take n (tail s) :=
rfl
#align stream.take_succ Stream'.take_succ
@[simp] theorem take_succ_cons (n : Nat) (s : Stream' α) : take (n+1) (a::s) = a :: take n s := rfl
theorem take_succ' {s : Stream' α} : ∀ n, s.take (n+1) = s.take n ++ [s.get n]
| 0 => rfl
| n+1 => by rw [take_succ, take_succ' n, ← List.cons_append, ← take_succ, get_tail]
@[simp]
theorem length_take (n : ℕ) (s : Stream' α) : (take n s).length = n := by
induction n generalizing s <;> simp [*, take_succ]
#align stream.length_take Stream'.length_take
@[simp]
theorem take_take {s : Stream' α} : ∀ {m n}, (s.take n).take m = s.take (min n m)
| 0, n => by rw [Nat.min_zero, List.take_zero, take_zero]
| m, 0 => by rw [Nat.zero_min, take_zero, List.take_nil]
| m+1, n+1 => by rw [take_succ, List.take_cons, Nat.succ_min_succ, take_succ, take_take]
@[simp] theorem concat_take_get {s : Stream' α} : s.take n ++ [s.get n] = s.take (n+1) :=
(take_succ' n).symm
theorem get?_take {s : Stream' α} : ∀ {k n}, k < n → (s.take n).get? k = s.get k
| 0, n+1, _ => rfl
| k+1, n+1, h => by rw [take_succ, List.get?, get?_take (Nat.lt_of_succ_lt_succ h), get_succ]
theorem get?_take_succ (n : Nat) (s : Stream' α) :
List.get? (take (succ n) s) n = some (get s n) :=
get?_take (Nat.lt_succ_self n)
#align stream.nth_take_succ Stream'.get?_take_succ
@[simp] theorem dropLast_take {xs : Stream' α} :
(Stream'.take n xs).dropLast = Stream'.take (n-1) xs := by
cases n with
| zero => simp
| succ n => rw [take_succ', List.dropLast_concat, Nat.add_one_sub_one]
@[simp]
theorem append_take_drop : ∀ (n : Nat) (s : Stream' α),
appendStream' (take n s) (drop n s) = s := by
intro n
induction' n with n' ih
· intro s
rfl
· intro s
rw [take_succ, drop_succ, cons_append_stream, ih (tail s), Stream'.eta]
#align stream.append_take_drop Stream'.append_take_drop
-- Take theorem reduces a proof of equality of infinite streams to an
-- induction over all their finite approximations.
theorem take_theorem (s₁ s₂ : Stream' α) : (∀ n : Nat, take n s₁ = take n s₂) → s₁ = s₂ := by
intro h; apply Stream'.ext; intro n
induction' n with n _
· have aux := h 1
simp? [take] at aux says
simp only [take, List.cons.injEq, and_true] at aux
exact aux
· have h₁ : some (get s₁ (succ n)) = some (get s₂ (succ n)) := by
rw [← get?_take_succ, ← get?_take_succ, h (succ (succ n))]
injection h₁
#align stream.take_theorem Stream'.take_theorem
protected theorem cycle_g_cons (a : α) (a₁ : α) (l₁ : List α) (a₀ : α) (l₀ : List α) :
Stream'.cycleG (a, a₁::l₁, a₀, l₀) = (a₁, l₁, a₀, l₀) :=
rfl
#align stream.cycle_g_cons Stream'.cycle_g_cons
theorem cycle_eq : ∀ (l : List α) (h : l ≠ []), cycle l h = l ++ₛ cycle l h
| [], h => absurd rfl h
| List.cons a l, _ =>
have gen : ∀ l' a', corec Stream'.cycleF Stream'.cycleG (a', l', a, l) =
(a'::l') ++ₛ corec Stream'.cycleF Stream'.cycleG (a, l, a, l) := by
intro l'
induction' l' with a₁ l₁ ih
· intros
rw [corec_eq]
rfl
· intros
rw [corec_eq, Stream'.cycle_g_cons, ih a₁]
rfl
gen l a
#align stream.cycle_eq Stream'.cycle_eq
theorem mem_cycle {a : α} {l : List α} : ∀ h : l ≠ [], a ∈ l → a ∈ cycle l h := fun h ainl => by
rw [cycle_eq]; exact mem_append_stream_left _ ainl
#align stream.mem_cycle Stream'.mem_cycle
@[simp]
theorem cycle_singleton (a : α) : cycle [a] (by simp) = const a :=
coinduction rfl fun β fr ch => by rwa [cycle_eq, const_eq]
#align stream.cycle_singleton Stream'.cycle_singleton
theorem tails_eq (s : Stream' α) : tails s = tail s::tails (tail s) := by
unfold tails; rw [corec_eq]; rfl
#align stream.tails_eq Stream'.tails_eq
@[simp]
theorem get_tails : ∀ (n : Nat) (s : Stream' α), get (tails s) n = drop n (tail s) := by
intro n; induction' n with n' ih
· intros
rfl
· intro s
rw [get_succ, drop_succ, tails_eq, tail_cons, ih]
#align stream.nth_tails Stream'.get_tails
theorem tails_eq_iterate (s : Stream' α) : tails s = iterate tail (tail s) :=
rfl
#align stream.tails_eq_iterate Stream'.tails_eq_iterate
theorem inits_core_eq (l : List α) (s : Stream' α) :
initsCore l s = l::initsCore (l ++ [head s]) (tail s) := by
unfold initsCore corecOn
rw [corec_eq]
#align stream.inits_core_eq Stream'.inits_core_eq
theorem tail_inits (s : Stream' α) :
tail (inits s) = initsCore [head s, head (tail s)] (tail (tail s)) := by
unfold inits
rw [inits_core_eq]; rfl
#align stream.tail_inits Stream'.tail_inits
theorem inits_tail (s : Stream' α) : inits (tail s) = initsCore [head (tail s)] (tail (tail s)) :=
rfl
#align stream.inits_tail Stream'.inits_tail
| Mathlib/Data/Stream/Init.lean | 702 | 711 | theorem cons_get_inits_core :
∀ (a : α) (n : Nat) (l : List α) (s : Stream' α),
(a::get (initsCore l s) n) = get (initsCore (a::l) s) n := by |
intro a n
induction' n with n' ih
· intros
rfl
· intro l s
rw [get_succ, inits_core_eq, tail_cons, ih, inits_core_eq (a::l) s]
rfl
|
import Mathlib.SetTheory.Ordinal.Basic
import Mathlib.Data.Nat.SuccPred
#align_import set_theory.ordinal.arithmetic from "leanprover-community/mathlib"@"31b269b60935483943542d547a6dd83a66b37dc7"
assert_not_exists Field
assert_not_exists Module
noncomputable section
open Function Cardinal Set Equiv Order
open scoped Classical
open Cardinal Ordinal
universe u v w
namespace Ordinal
variable {α : Type*} {β : Type*} {γ : Type*} {r : α → α → Prop} {s : β → β → Prop}
{t : γ → γ → Prop}
@[simp]
theorem lift_add (a b : Ordinal.{v}) : lift.{u} (a + b) = lift.{u} a + lift.{u} b :=
Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ =>
Quotient.sound
⟨(RelIso.preimage Equiv.ulift _).trans
(RelIso.sumLexCongr (RelIso.preimage Equiv.ulift _) (RelIso.preimage Equiv.ulift _)).symm⟩
#align ordinal.lift_add Ordinal.lift_add
@[simp]
theorem lift_succ (a : Ordinal.{v}) : lift.{u} (succ a) = succ (lift.{u} a) := by
rw [← add_one_eq_succ, lift_add, lift_one]
rfl
#align ordinal.lift_succ Ordinal.lift_succ
instance add_contravariantClass_le : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· ≤ ·) :=
⟨fun a b c =>
inductionOn a fun α r hr =>
inductionOn b fun β₁ s₁ hs₁ =>
inductionOn c fun β₂ s₂ hs₂ ⟨f⟩ =>
⟨have fl : ∀ a, f (Sum.inl a) = Sum.inl a := fun a => by
simpa only [InitialSeg.trans_apply, InitialSeg.leAdd_apply] using
@InitialSeg.eq _ _ _ _ _
((InitialSeg.leAdd r s₁).trans f) (InitialSeg.leAdd r s₂) a
have : ∀ b, { b' // f (Sum.inr b) = Sum.inr b' } := by
intro b; cases e : f (Sum.inr b)
· rw [← fl] at e
have := f.inj' e
contradiction
· exact ⟨_, rfl⟩
let g (b) := (this b).1
have fr : ∀ b, f (Sum.inr b) = Sum.inr (g b) := fun b => (this b).2
⟨⟨⟨g, fun x y h => by
injection f.inj' (by rw [fr, fr, h] : f (Sum.inr x) = f (Sum.inr y))⟩,
@fun a b => by
-- Porting note:
-- `relEmbedding.coe_fn_to_embedding` & `initial_seg.coe_fn_to_rel_embedding`
-- → `InitialSeg.coe_coe_fn`
simpa only [Sum.lex_inr_inr, fr, InitialSeg.coe_coe_fn, Embedding.coeFn_mk] using
@RelEmbedding.map_rel_iff _ _ _ _ f.toRelEmbedding (Sum.inr a) (Sum.inr b)⟩,
fun a b H => by
rcases f.init (by rw [fr] <;> exact Sum.lex_inr_inr.2 H) with ⟨a' | a', h⟩
· rw [fl] at h
cases h
· rw [fr] at h
exact ⟨a', Sum.inr.inj h⟩⟩⟩⟩
#align ordinal.add_contravariant_class_le Ordinal.add_contravariantClass_le
theorem add_left_cancel (a) {b c : Ordinal} : a + b = a + c ↔ b = c := by
simp only [le_antisymm_iff, add_le_add_iff_left]
#align ordinal.add_left_cancel Ordinal.add_left_cancel
private theorem add_lt_add_iff_left' (a) {b c : Ordinal} : a + b < a + c ↔ b < c := by
rw [← not_le, ← not_le, add_le_add_iff_left]
instance add_covariantClass_lt : CovariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) :=
⟨fun a _b _c => (add_lt_add_iff_left' a).2⟩
#align ordinal.add_covariant_class_lt Ordinal.add_covariantClass_lt
instance add_contravariantClass_lt : ContravariantClass Ordinal.{u} Ordinal.{u} (· + ·) (· < ·) :=
⟨fun a _b _c => (add_lt_add_iff_left' a).1⟩
#align ordinal.add_contravariant_class_lt Ordinal.add_contravariantClass_lt
instance add_swap_contravariantClass_lt :
ContravariantClass Ordinal.{u} Ordinal.{u} (swap (· + ·)) (· < ·) :=
⟨fun _a _b _c => lt_imp_lt_of_le_imp_le fun h => add_le_add_right h _⟩
#align ordinal.add_swap_contravariant_class_lt Ordinal.add_swap_contravariantClass_lt
theorem add_le_add_iff_right {a b : Ordinal} : ∀ n : ℕ, a + n ≤ b + n ↔ a ≤ b
| 0 => by simp
| n + 1 => by
simp only [natCast_succ, add_succ, add_succ, succ_le_succ_iff, add_le_add_iff_right]
#align ordinal.add_le_add_iff_right Ordinal.add_le_add_iff_right
theorem add_right_cancel {a b : Ordinal} (n : ℕ) : a + n = b + n ↔ a = b := by
simp only [le_antisymm_iff, add_le_add_iff_right]
#align ordinal.add_right_cancel Ordinal.add_right_cancel
theorem add_eq_zero_iff {a b : Ordinal} : a + b = 0 ↔ a = 0 ∧ b = 0 :=
inductionOn a fun α r _ =>
inductionOn b fun β s _ => by
simp_rw [← type_sum_lex, type_eq_zero_iff_isEmpty]
exact isEmpty_sum
#align ordinal.add_eq_zero_iff Ordinal.add_eq_zero_iff
theorem left_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : a = 0 :=
(add_eq_zero_iff.1 h).1
#align ordinal.left_eq_zero_of_add_eq_zero Ordinal.left_eq_zero_of_add_eq_zero
theorem right_eq_zero_of_add_eq_zero {a b : Ordinal} (h : a + b = 0) : b = 0 :=
(add_eq_zero_iff.1 h).2
#align ordinal.right_eq_zero_of_add_eq_zero Ordinal.right_eq_zero_of_add_eq_zero
def pred (o : Ordinal) : Ordinal :=
if h : ∃ a, o = succ a then Classical.choose h else o
#align ordinal.pred Ordinal.pred
@[simp]
theorem pred_succ (o) : pred (succ o) = o := by
have h : ∃ a, succ o = succ a := ⟨_, rfl⟩;
simpa only [pred, dif_pos h] using (succ_injective <| Classical.choose_spec h).symm
#align ordinal.pred_succ Ordinal.pred_succ
theorem pred_le_self (o) : pred o ≤ o :=
if h : ∃ a, o = succ a then by
let ⟨a, e⟩ := h
rw [e, pred_succ]; exact le_succ a
else by rw [pred, dif_neg h]
#align ordinal.pred_le_self Ordinal.pred_le_self
theorem pred_eq_iff_not_succ {o} : pred o = o ↔ ¬∃ a, o = succ a :=
⟨fun e ⟨a, e'⟩ => by rw [e', pred_succ] at e; exact (lt_succ a).ne e, fun h => dif_neg h⟩
#align ordinal.pred_eq_iff_not_succ Ordinal.pred_eq_iff_not_succ
theorem pred_eq_iff_not_succ' {o} : pred o = o ↔ ∀ a, o ≠ succ a := by
simpa using pred_eq_iff_not_succ
#align ordinal.pred_eq_iff_not_succ' Ordinal.pred_eq_iff_not_succ'
theorem pred_lt_iff_is_succ {o} : pred o < o ↔ ∃ a, o = succ a :=
Iff.trans (by simp only [le_antisymm_iff, pred_le_self, true_and_iff, not_le])
(iff_not_comm.1 pred_eq_iff_not_succ).symm
#align ordinal.pred_lt_iff_is_succ Ordinal.pred_lt_iff_is_succ
@[simp]
theorem pred_zero : pred 0 = 0 :=
pred_eq_iff_not_succ'.2 fun a => (succ_ne_zero a).symm
#align ordinal.pred_zero Ordinal.pred_zero
theorem succ_pred_iff_is_succ {o} : succ (pred o) = o ↔ ∃ a, o = succ a :=
⟨fun e => ⟨_, e.symm⟩, fun ⟨a, e⟩ => by simp only [e, pred_succ]⟩
#align ordinal.succ_pred_iff_is_succ Ordinal.succ_pred_iff_is_succ
theorem succ_lt_of_not_succ {o b : Ordinal} (h : ¬∃ a, o = succ a) : succ b < o ↔ b < o :=
⟨(lt_succ b).trans, fun l => lt_of_le_of_ne (succ_le_of_lt l) fun e => h ⟨_, e.symm⟩⟩
#align ordinal.succ_lt_of_not_succ Ordinal.succ_lt_of_not_succ
theorem lt_pred {a b} : a < pred b ↔ succ a < b :=
if h : ∃ a, b = succ a then by
let ⟨c, e⟩ := h
rw [e, pred_succ, succ_lt_succ_iff]
else by simp only [pred, dif_neg h, succ_lt_of_not_succ h]
#align ordinal.lt_pred Ordinal.lt_pred
theorem pred_le {a b} : pred a ≤ b ↔ a ≤ succ b :=
le_iff_le_iff_lt_iff_lt.2 lt_pred
#align ordinal.pred_le Ordinal.pred_le
@[simp]
theorem lift_is_succ {o : Ordinal.{v}} : (∃ a, lift.{u} o = succ a) ↔ ∃ a, o = succ a :=
⟨fun ⟨a, h⟩ =>
let ⟨b, e⟩ := lift_down <| show a ≤ lift.{u} o from le_of_lt <| h.symm ▸ lt_succ a
⟨b, lift_inj.1 <| by rw [h, ← e, lift_succ]⟩,
fun ⟨a, h⟩ => ⟨lift.{u} a, by simp only [h, lift_succ]⟩⟩
#align ordinal.lift_is_succ Ordinal.lift_is_succ
@[simp]
theorem lift_pred (o : Ordinal.{v}) : lift.{u} (pred o) = pred (lift.{u} o) :=
if h : ∃ a, o = succ a then by cases' h with a e; simp only [e, pred_succ, lift_succ]
else by rw [pred_eq_iff_not_succ.2 h, pred_eq_iff_not_succ.2 (mt lift_is_succ.1 h)]
#align ordinal.lift_pred Ordinal.lift_pred
def IsLimit (o : Ordinal) : Prop :=
o ≠ 0 ∧ ∀ a < o, succ a < o
#align ordinal.is_limit Ordinal.IsLimit
theorem IsLimit.isSuccLimit {o} (h : IsLimit o) : IsSuccLimit o := isSuccLimit_iff_succ_lt.mpr h.2
theorem IsLimit.succ_lt {o a : Ordinal} (h : IsLimit o) : a < o → succ a < o :=
h.2 a
#align ordinal.is_limit.succ_lt Ordinal.IsLimit.succ_lt
theorem isSuccLimit_zero : IsSuccLimit (0 : Ordinal) := isSuccLimit_bot
theorem not_zero_isLimit : ¬IsLimit 0
| ⟨h, _⟩ => h rfl
#align ordinal.not_zero_is_limit Ordinal.not_zero_isLimit
theorem not_succ_isLimit (o) : ¬IsLimit (succ o)
| ⟨_, h⟩ => lt_irrefl _ (h _ (lt_succ o))
#align ordinal.not_succ_is_limit Ordinal.not_succ_isLimit
theorem not_succ_of_isLimit {o} (h : IsLimit o) : ¬∃ a, o = succ a
| ⟨a, e⟩ => not_succ_isLimit a (e ▸ h)
#align ordinal.not_succ_of_is_limit Ordinal.not_succ_of_isLimit
theorem succ_lt_of_isLimit {o a : Ordinal} (h : IsLimit o) : succ a < o ↔ a < o :=
⟨(lt_succ a).trans, h.2 _⟩
#align ordinal.succ_lt_of_is_limit Ordinal.succ_lt_of_isLimit
theorem le_succ_of_isLimit {o} (h : IsLimit o) {a} : o ≤ succ a ↔ o ≤ a :=
le_iff_le_iff_lt_iff_lt.2 <| succ_lt_of_isLimit h
#align ordinal.le_succ_of_is_limit Ordinal.le_succ_of_isLimit
theorem limit_le {o} (h : IsLimit o) {a} : o ≤ a ↔ ∀ x < o, x ≤ a :=
⟨fun h _x l => l.le.trans h, fun H =>
(le_succ_of_isLimit h).1 <| le_of_not_lt fun hn => not_lt_of_le (H _ hn) (lt_succ a)⟩
#align ordinal.limit_le Ordinal.limit_le
theorem lt_limit {o} (h : IsLimit o) {a} : a < o ↔ ∃ x < o, a < x := by
-- Porting note: `bex_def` is required.
simpa only [not_forall₂, not_le, bex_def] using not_congr (@limit_le _ h a)
#align ordinal.lt_limit Ordinal.lt_limit
@[simp]
theorem lift_isLimit (o) : IsLimit (lift o) ↔ IsLimit o :=
and_congr (not_congr <| by simpa only [lift_zero] using @lift_inj o 0)
⟨fun H a h => lift_lt.1 <| by simpa only [lift_succ] using H _ (lift_lt.2 h), fun H a h => by
obtain ⟨a', rfl⟩ := lift_down h.le
rw [← lift_succ, lift_lt]
exact H a' (lift_lt.1 h)⟩
#align ordinal.lift_is_limit Ordinal.lift_isLimit
theorem IsLimit.pos {o : Ordinal} (h : IsLimit o) : 0 < o :=
lt_of_le_of_ne (Ordinal.zero_le _) h.1.symm
#align ordinal.is_limit.pos Ordinal.IsLimit.pos
theorem IsLimit.one_lt {o : Ordinal} (h : IsLimit o) : 1 < o := by
simpa only [succ_zero] using h.2 _ h.pos
#align ordinal.is_limit.one_lt Ordinal.IsLimit.one_lt
theorem IsLimit.nat_lt {o : Ordinal} (h : IsLimit o) : ∀ n : ℕ, (n : Ordinal) < o
| 0 => h.pos
| n + 1 => h.2 _ (IsLimit.nat_lt h n)
#align ordinal.is_limit.nat_lt Ordinal.IsLimit.nat_lt
theorem zero_or_succ_or_limit (o : Ordinal) : o = 0 ∨ (∃ a, o = succ a) ∨ IsLimit o :=
if o0 : o = 0 then Or.inl o0
else
if h : ∃ a, o = succ a then Or.inr (Or.inl h)
else Or.inr <| Or.inr ⟨o0, fun _a => (succ_lt_of_not_succ h).2⟩
#align ordinal.zero_or_succ_or_limit Ordinal.zero_or_succ_or_limit
@[elab_as_elim]
def limitRecOn {C : Ordinal → Sort*} (o : Ordinal) (H₁ : C 0) (H₂ : ∀ o, C o → C (succ o))
(H₃ : ∀ o, IsLimit o → (∀ o' < o, C o') → C o) : C o :=
SuccOrder.limitRecOn o (fun o _ ↦ H₂ o) fun o hl ↦
if h : o = 0 then fun _ ↦ h ▸ H₁ else H₃ o ⟨h, fun _ ↦ hl.succ_lt⟩
#align ordinal.limit_rec_on Ordinal.limitRecOn
@[simp]
theorem limitRecOn_zero {C} (H₁ H₂ H₃) : @limitRecOn C 0 H₁ H₂ H₃ = H₁ := by
rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ isSuccLimit_zero, dif_pos rfl]
#align ordinal.limit_rec_on_zero Ordinal.limitRecOn_zero
@[simp]
theorem limitRecOn_succ {C} (o H₁ H₂ H₃) :
@limitRecOn C (succ o) H₁ H₂ H₃ = H₂ o (@limitRecOn C o H₁ H₂ H₃) := by
simp_rw [limitRecOn, SuccOrder.limitRecOn_succ _ _ (not_isMax _)]
#align ordinal.limit_rec_on_succ Ordinal.limitRecOn_succ
@[simp]
theorem limitRecOn_limit {C} (o H₁ H₂ H₃ h) :
@limitRecOn C o H₁ H₂ H₃ = H₃ o h fun x _h => @limitRecOn C x H₁ H₂ H₃ := by
simp_rw [limitRecOn, SuccOrder.limitRecOn_limit _ _ h.isSuccLimit, dif_neg h.1]
#align ordinal.limit_rec_on_limit Ordinal.limitRecOn_limit
instance orderTopOutSucc (o : Ordinal) : OrderTop (succ o).out.α :=
@OrderTop.mk _ _ (Top.mk _) le_enum_succ
#align ordinal.order_top_out_succ Ordinal.orderTopOutSucc
theorem enum_succ_eq_top {o : Ordinal} :
enum (· < ·) o
(by
rw [type_lt]
exact lt_succ o) =
(⊤ : (succ o).out.α) :=
rfl
#align ordinal.enum_succ_eq_top Ordinal.enum_succ_eq_top
theorem has_succ_of_type_succ_lt {α} {r : α → α → Prop} [wo : IsWellOrder α r]
(h : ∀ a < type r, succ a < type r) (x : α) : ∃ y, r x y := by
use enum r (succ (typein r x)) (h _ (typein_lt_type r x))
convert (enum_lt_enum (typein_lt_type r x)
(h _ (typein_lt_type r x))).mpr (lt_succ _); rw [enum_typein]
#align ordinal.has_succ_of_type_succ_lt Ordinal.has_succ_of_type_succ_lt
theorem out_no_max_of_succ_lt {o : Ordinal} (ho : ∀ a < o, succ a < o) : NoMaxOrder o.out.α :=
⟨has_succ_of_type_succ_lt (by rwa [type_lt])⟩
#align ordinal.out_no_max_of_succ_lt Ordinal.out_no_max_of_succ_lt
theorem bounded_singleton {r : α → α → Prop} [IsWellOrder α r] (hr : (type r).IsLimit) (x) :
Bounded r {x} := by
refine ⟨enum r (succ (typein r x)) (hr.2 _ (typein_lt_type r x)), ?_⟩
intro b hb
rw [mem_singleton_iff.1 hb]
nth_rw 1 [← enum_typein r x]
rw [@enum_lt_enum _ r]
apply lt_succ
#align ordinal.bounded_singleton Ordinal.bounded_singleton
-- Porting note: `· < ·` requires a type ascription for an `IsWellOrder` instance.
theorem type_subrel_lt (o : Ordinal.{u}) :
type (Subrel ((· < ·) : Ordinal → Ordinal → Prop) { o' : Ordinal | o' < o })
= Ordinal.lift.{u + 1} o := by
refine Quotient.inductionOn o ?_
rintro ⟨α, r, wo⟩; apply Quotient.sound
-- Porting note: `symm; refine' [term]` → `refine' [term].symm`
constructor; refine ((RelIso.preimage Equiv.ulift r).trans (enumIso r).symm).symm
#align ordinal.type_subrel_lt Ordinal.type_subrel_lt
theorem mk_initialSeg (o : Ordinal.{u}) :
#{ o' : Ordinal | o' < o } = Cardinal.lift.{u + 1} o.card := by
rw [lift_card, ← type_subrel_lt, card_type]
#align ordinal.mk_initial_seg Ordinal.mk_initialSeg
def IsNormal (f : Ordinal → Ordinal) : Prop :=
(∀ o, f o < f (succ o)) ∧ ∀ o, IsLimit o → ∀ a, f o ≤ a ↔ ∀ b < o, f b ≤ a
#align ordinal.is_normal Ordinal.IsNormal
theorem IsNormal.limit_le {f} (H : IsNormal f) :
∀ {o}, IsLimit o → ∀ {a}, f o ≤ a ↔ ∀ b < o, f b ≤ a :=
@H.2
#align ordinal.is_normal.limit_le Ordinal.IsNormal.limit_le
theorem IsNormal.limit_lt {f} (H : IsNormal f) {o} (h : IsLimit o) {a} :
a < f o ↔ ∃ b < o, a < f b :=
not_iff_not.1 <| by simpa only [exists_prop, not_exists, not_and, not_lt] using H.2 _ h a
#align ordinal.is_normal.limit_lt Ordinal.IsNormal.limit_lt
theorem IsNormal.strictMono {f} (H : IsNormal f) : StrictMono f := fun a b =>
limitRecOn b (Not.elim (not_lt_of_le <| Ordinal.zero_le _))
(fun _b IH h =>
(lt_or_eq_of_le (le_of_lt_succ h)).elim (fun h => (IH h).trans (H.1 _)) fun e => e ▸ H.1 _)
fun _b l _IH h => lt_of_lt_of_le (H.1 a) ((H.2 _ l _).1 le_rfl _ (l.2 _ h))
#align ordinal.is_normal.strict_mono Ordinal.IsNormal.strictMono
theorem IsNormal.monotone {f} (H : IsNormal f) : Monotone f :=
H.strictMono.monotone
#align ordinal.is_normal.monotone Ordinal.IsNormal.monotone
theorem isNormal_iff_strictMono_limit (f : Ordinal → Ordinal) :
IsNormal f ↔ StrictMono f ∧ ∀ o, IsLimit o → ∀ a, (∀ b < o, f b ≤ a) → f o ≤ a :=
⟨fun hf => ⟨hf.strictMono, fun a ha c => (hf.2 a ha c).2⟩, fun ⟨hs, hl⟩ =>
⟨fun a => hs (lt_succ a), fun a ha c =>
⟨fun hac _b hba => ((hs hba).trans_le hac).le, hl a ha c⟩⟩⟩
#align ordinal.is_normal_iff_strict_mono_limit Ordinal.isNormal_iff_strictMono_limit
theorem IsNormal.lt_iff {f} (H : IsNormal f) {a b} : f a < f b ↔ a < b :=
StrictMono.lt_iff_lt <| H.strictMono
#align ordinal.is_normal.lt_iff Ordinal.IsNormal.lt_iff
theorem IsNormal.le_iff {f} (H : IsNormal f) {a b} : f a ≤ f b ↔ a ≤ b :=
le_iff_le_iff_lt_iff_lt.2 H.lt_iff
#align ordinal.is_normal.le_iff Ordinal.IsNormal.le_iff
theorem IsNormal.inj {f} (H : IsNormal f) {a b} : f a = f b ↔ a = b := by
simp only [le_antisymm_iff, H.le_iff]
#align ordinal.is_normal.inj Ordinal.IsNormal.inj
theorem IsNormal.self_le {f} (H : IsNormal f) (a) : a ≤ f a :=
lt_wf.self_le_of_strictMono H.strictMono a
#align ordinal.is_normal.self_le Ordinal.IsNormal.self_le
theorem IsNormal.le_set {f o} (H : IsNormal f) (p : Set Ordinal) (p0 : p.Nonempty) (b)
(H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f a ≤ o :=
⟨fun h a pa => (H.le_iff.2 ((H₂ _).1 le_rfl _ pa)).trans h, fun h => by
-- Porting note: `refine'` didn't work well so `induction` is used
induction b using limitRecOn with
| H₁ =>
cases' p0 with x px
have := Ordinal.le_zero.1 ((H₂ _).1 (Ordinal.zero_le _) _ px)
rw [this] at px
exact h _ px
| H₂ S _ =>
rcases not_forall₂.1 (mt (H₂ S).2 <| (lt_succ S).not_le) with ⟨a, h₁, h₂⟩
exact (H.le_iff.2 <| succ_le_of_lt <| not_le.1 h₂).trans (h _ h₁)
| H₃ S L _ =>
refine (H.2 _ L _).2 fun a h' => ?_
rcases not_forall₂.1 (mt (H₂ a).2 h'.not_le) with ⟨b, h₁, h₂⟩
exact (H.le_iff.2 <| (not_le.1 h₂).le).trans (h _ h₁)⟩
#align ordinal.is_normal.le_set Ordinal.IsNormal.le_set
theorem IsNormal.le_set' {f o} (H : IsNormal f) (p : Set α) (p0 : p.Nonempty) (g : α → Ordinal) (b)
(H₂ : ∀ o, b ≤ o ↔ ∀ a ∈ p, g a ≤ o) : f b ≤ o ↔ ∀ a ∈ p, f (g a) ≤ o := by
simpa [H₂] using H.le_set (g '' p) (p0.image g) b
#align ordinal.is_normal.le_set' Ordinal.IsNormal.le_set'
theorem IsNormal.refl : IsNormal id :=
⟨lt_succ, fun _o l _a => Ordinal.limit_le l⟩
#align ordinal.is_normal.refl Ordinal.IsNormal.refl
theorem IsNormal.trans {f g} (H₁ : IsNormal f) (H₂ : IsNormal g) : IsNormal (f ∘ g) :=
⟨fun _x => H₁.lt_iff.2 (H₂.1 _), fun o l _a =>
H₁.le_set' (· < o) ⟨0, l.pos⟩ g _ fun _c => H₂.2 _ l _⟩
#align ordinal.is_normal.trans Ordinal.IsNormal.trans
theorem IsNormal.isLimit {f} (H : IsNormal f) {o} (l : IsLimit o) : IsLimit (f o) :=
⟨ne_of_gt <| (Ordinal.zero_le _).trans_lt <| H.lt_iff.2 l.pos, fun _ h =>
let ⟨_b, h₁, h₂⟩ := (H.limit_lt l).1 h
(succ_le_of_lt h₂).trans_lt (H.lt_iff.2 h₁)⟩
#align ordinal.is_normal.is_limit Ordinal.IsNormal.isLimit
theorem IsNormal.le_iff_eq {f} (H : IsNormal f) {a} : f a ≤ a ↔ f a = a :=
(H.self_le a).le_iff_eq
#align ordinal.is_normal.le_iff_eq Ordinal.IsNormal.le_iff_eq
theorem add_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a + b ≤ c ↔ ∀ b' < b, a + b' ≤ c :=
⟨fun h b' l => (add_le_add_left l.le _).trans h, fun H =>
le_of_not_lt <| by
-- Porting note: `induction` tactics are required because of the parser bug.
induction a using inductionOn with
| H α r =>
induction b using inductionOn with
| H β s =>
intro l
suffices ∀ x : β, Sum.Lex r s (Sum.inr x) (enum _ _ l) by
-- Porting note: `revert` & `intro` is required because `cases'` doesn't replace
-- `enum _ _ l` in `this`.
revert this; cases' enum _ _ l with x x <;> intro this
· cases this (enum s 0 h.pos)
· exact irrefl _ (this _)
intro x
rw [← typein_lt_typein (Sum.Lex r s), typein_enum]
have := H _ (h.2 _ (typein_lt_type s x))
rw [add_succ, succ_le_iff] at this
refine
(RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this
· rcases a with ⟨a | b, h⟩
· exact Sum.inl a
· exact Sum.inr ⟨b, by cases h; assumption⟩
· rcases a with ⟨a | a, h₁⟩ <;> rcases b with ⟨b | b, h₂⟩ <;> cases h₁ <;> cases h₂ <;>
rintro ⟨⟩ <;> constructor <;> assumption⟩
#align ordinal.add_le_of_limit Ordinal.add_le_of_limit
theorem add_isNormal (a : Ordinal) : IsNormal (a + ·) :=
⟨fun b => (add_lt_add_iff_left a).2 (lt_succ b), fun _b l _c => add_le_of_limit l⟩
#align ordinal.add_is_normal Ordinal.add_isNormal
theorem add_isLimit (a) {b} : IsLimit b → IsLimit (a + b) :=
(add_isNormal a).isLimit
#align ordinal.add_is_limit Ordinal.add_isLimit
alias IsLimit.add := add_isLimit
#align ordinal.is_limit.add Ordinal.IsLimit.add
theorem sub_nonempty {a b : Ordinal} : { o | a ≤ b + o }.Nonempty :=
⟨a, le_add_left _ _⟩
#align ordinal.sub_nonempty Ordinal.sub_nonempty
instance sub : Sub Ordinal :=
⟨fun a b => sInf { o | a ≤ b + o }⟩
theorem le_add_sub (a b : Ordinal) : a ≤ b + (a - b) :=
csInf_mem sub_nonempty
#align ordinal.le_add_sub Ordinal.le_add_sub
theorem sub_le {a b c : Ordinal} : a - b ≤ c ↔ a ≤ b + c :=
⟨fun h => (le_add_sub a b).trans (add_le_add_left h _), fun h => csInf_le' h⟩
#align ordinal.sub_le Ordinal.sub_le
theorem lt_sub {a b c : Ordinal} : a < b - c ↔ c + a < b :=
lt_iff_lt_of_le_iff_le sub_le
#align ordinal.lt_sub Ordinal.lt_sub
theorem add_sub_cancel (a b : Ordinal) : a + b - a = b :=
le_antisymm (sub_le.2 <| le_rfl) ((add_le_add_iff_left a).1 <| le_add_sub _ _)
#align ordinal.add_sub_cancel Ordinal.add_sub_cancel
theorem sub_eq_of_add_eq {a b c : Ordinal} (h : a + b = c) : c - a = b :=
h ▸ add_sub_cancel _ _
#align ordinal.sub_eq_of_add_eq Ordinal.sub_eq_of_add_eq
theorem sub_le_self (a b : Ordinal) : a - b ≤ a :=
sub_le.2 <| le_add_left _ _
#align ordinal.sub_le_self Ordinal.sub_le_self
protected theorem add_sub_cancel_of_le {a b : Ordinal} (h : b ≤ a) : b + (a - b) = a :=
(le_add_sub a b).antisymm'
(by
rcases zero_or_succ_or_limit (a - b) with (e | ⟨c, e⟩ | l)
· simp only [e, add_zero, h]
· rw [e, add_succ, succ_le_iff, ← lt_sub, e]
exact lt_succ c
· exact (add_le_of_limit l).2 fun c l => (lt_sub.1 l).le)
#align ordinal.add_sub_cancel_of_le Ordinal.add_sub_cancel_of_le
theorem le_sub_of_le {a b c : Ordinal} (h : b ≤ a) : c ≤ a - b ↔ b + c ≤ a := by
rw [← add_le_add_iff_left b, Ordinal.add_sub_cancel_of_le h]
#align ordinal.le_sub_of_le Ordinal.le_sub_of_le
theorem sub_lt_of_le {a b c : Ordinal} (h : b ≤ a) : a - b < c ↔ a < b + c :=
lt_iff_lt_of_le_iff_le (le_sub_of_le h)
#align ordinal.sub_lt_of_le Ordinal.sub_lt_of_le
instance existsAddOfLE : ExistsAddOfLE Ordinal :=
⟨fun h => ⟨_, (Ordinal.add_sub_cancel_of_le h).symm⟩⟩
@[simp]
theorem sub_zero (a : Ordinal) : a - 0 = a := by simpa only [zero_add] using add_sub_cancel 0 a
#align ordinal.sub_zero Ordinal.sub_zero
@[simp]
theorem zero_sub (a : Ordinal) : 0 - a = 0 := by rw [← Ordinal.le_zero]; apply sub_le_self
#align ordinal.zero_sub Ordinal.zero_sub
@[simp]
theorem sub_self (a : Ordinal) : a - a = 0 := by simpa only [add_zero] using add_sub_cancel a 0
#align ordinal.sub_self Ordinal.sub_self
protected theorem sub_eq_zero_iff_le {a b : Ordinal} : a - b = 0 ↔ a ≤ b :=
⟨fun h => by simpa only [h, add_zero] using le_add_sub a b, fun h => by
rwa [← Ordinal.le_zero, sub_le, add_zero]⟩
#align ordinal.sub_eq_zero_iff_le Ordinal.sub_eq_zero_iff_le
theorem sub_sub (a b c : Ordinal) : a - b - c = a - (b + c) :=
eq_of_forall_ge_iff fun d => by rw [sub_le, sub_le, sub_le, add_assoc]
#align ordinal.sub_sub Ordinal.sub_sub
@[simp]
theorem add_sub_add_cancel (a b c : Ordinal) : a + b - (a + c) = b - c := by
rw [← sub_sub, add_sub_cancel]
#align ordinal.add_sub_add_cancel Ordinal.add_sub_add_cancel
theorem sub_isLimit {a b} (l : IsLimit a) (h : b < a) : IsLimit (a - b) :=
⟨ne_of_gt <| lt_sub.2 <| by rwa [add_zero], fun c h => by
rw [lt_sub, add_succ]; exact l.2 _ (lt_sub.1 h)⟩
#align ordinal.sub_is_limit Ordinal.sub_isLimit
-- @[simp] -- Porting note (#10618): simp can prove this
theorem one_add_omega : 1 + ω = ω := by
refine le_antisymm ?_ (le_add_left _ _)
rw [omega, ← lift_one.{_, 0}, ← lift_add, lift_le, ← type_unit, ← type_sum_lex]
refine ⟨RelEmbedding.collapse (RelEmbedding.ofMonotone ?_ ?_)⟩
· apply Sum.rec
· exact fun _ => 0
· exact Nat.succ
· intro a b
cases a <;> cases b <;> intro H <;> cases' H with _ _ H _ _ H <;>
[exact H.elim; exact Nat.succ_pos _; exact Nat.succ_lt_succ H]
#align ordinal.one_add_omega Ordinal.one_add_omega
@[simp]
theorem one_add_of_omega_le {o} (h : ω ≤ o) : 1 + o = o := by
rw [← Ordinal.add_sub_cancel_of_le h, ← add_assoc, one_add_omega]
#align ordinal.one_add_of_omega_le Ordinal.one_add_of_omega_le
instance monoid : Monoid Ordinal.{u} where
mul a b :=
Quotient.liftOn₂ a b
(fun ⟨α, r, wo⟩ ⟨β, s, wo'⟩ => ⟦⟨β × α, Prod.Lex s r, inferInstance⟩⟧ :
WellOrder → WellOrder → Ordinal)
fun ⟨α₁, r₁, o₁⟩ ⟨α₂, r₂, o₂⟩ ⟨β₁, s₁, p₁⟩ ⟨β₂, s₂, p₂⟩ ⟨f⟩ ⟨g⟩ =>
Quot.sound ⟨RelIso.prodLexCongr g f⟩
one := 1
mul_assoc a b c :=
Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ =>
Eq.symm <|
Quotient.sound
⟨⟨prodAssoc _ _ _, @fun a b => by
rcases a with ⟨⟨a₁, a₂⟩, a₃⟩
rcases b with ⟨⟨b₁, b₂⟩, b₃⟩
simp [Prod.lex_def, and_or_left, or_assoc, and_assoc]⟩⟩
mul_one a :=
inductionOn a fun α r _ =>
Quotient.sound
⟨⟨punitProd _, @fun a b => by
rcases a with ⟨⟨⟨⟩⟩, a⟩; rcases b with ⟨⟨⟨⟩⟩, b⟩
simp only [Prod.lex_def, EmptyRelation, false_or_iff]
simp only [eq_self_iff_true, true_and_iff]
rfl⟩⟩
one_mul a :=
inductionOn a fun α r _ =>
Quotient.sound
⟨⟨prodPUnit _, @fun a b => by
rcases a with ⟨a, ⟨⟨⟩⟩⟩; rcases b with ⟨b, ⟨⟨⟩⟩⟩
simp only [Prod.lex_def, EmptyRelation, and_false_iff, or_false_iff]
rfl⟩⟩
@[simp]
theorem type_prod_lex {α β : Type u} (r : α → α → Prop) (s : β → β → Prop) [IsWellOrder α r]
[IsWellOrder β s] : type (Prod.Lex s r) = type r * type s :=
rfl
#align ordinal.type_prod_lex Ordinal.type_prod_lex
private theorem mul_eq_zero' {a b : Ordinal} : a * b = 0 ↔ a = 0 ∨ b = 0 :=
inductionOn a fun α _ _ =>
inductionOn b fun β _ _ => by
simp_rw [← type_prod_lex, type_eq_zero_iff_isEmpty]
rw [or_comm]
exact isEmpty_prod
instance monoidWithZero : MonoidWithZero Ordinal :=
{ Ordinal.monoid with
zero := 0
mul_zero := fun _a => mul_eq_zero'.2 <| Or.inr rfl
zero_mul := fun _a => mul_eq_zero'.2 <| Or.inl rfl }
instance noZeroDivisors : NoZeroDivisors Ordinal :=
⟨fun {_ _} => mul_eq_zero'.1⟩
@[simp]
theorem lift_mul (a b : Ordinal.{v}) : lift.{u} (a * b) = lift.{u} a * lift.{u} b :=
Quotient.inductionOn₂ a b fun ⟨_α, _r, _⟩ ⟨_β, _s, _⟩ =>
Quotient.sound
⟨(RelIso.preimage Equiv.ulift _).trans
(RelIso.prodLexCongr (RelIso.preimage Equiv.ulift _)
(RelIso.preimage Equiv.ulift _)).symm⟩
#align ordinal.lift_mul Ordinal.lift_mul
@[simp]
theorem card_mul (a b) : card (a * b) = card a * card b :=
Quotient.inductionOn₂ a b fun ⟨α, _r, _⟩ ⟨β, _s, _⟩ => mul_comm #β #α
#align ordinal.card_mul Ordinal.card_mul
instance leftDistribClass : LeftDistribClass Ordinal.{u} :=
⟨fun a b c =>
Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ =>
Quotient.sound
⟨⟨sumProdDistrib _ _ _, by
rintro ⟨a₁ | a₁, a₂⟩ ⟨b₁ | b₁, b₂⟩ <;>
simp only [Prod.lex_def, Sum.lex_inl_inl, Sum.Lex.sep, Sum.lex_inr_inl,
Sum.lex_inr_inr, sumProdDistrib_apply_left, sumProdDistrib_apply_right] <;>
-- Porting note: `Sum.inr.inj_iff` is required.
simp only [Sum.inl.inj_iff, Sum.inr.inj_iff,
true_or_iff, false_and_iff, false_or_iff]⟩⟩⟩
theorem mul_succ (a b : Ordinal) : a * succ b = a * b + a :=
mul_add_one a b
#align ordinal.mul_succ Ordinal.mul_succ
instance mul_covariantClass_le : CovariantClass Ordinal.{u} Ordinal.{u} (· * ·) (· ≤ ·) :=
⟨fun c a b =>
Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by
refine
(RelEmbedding.ofMonotone (fun a : α × γ => (f a.1, a.2)) fun a b h => ?_).ordinal_type_le
cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h'
· exact Prod.Lex.left _ _ (f.toRelEmbedding.map_rel_iff.2 h')
· exact Prod.Lex.right _ h'⟩
#align ordinal.mul_covariant_class_le Ordinal.mul_covariantClass_le
instance mul_swap_covariantClass_le :
CovariantClass Ordinal.{u} Ordinal.{u} (swap (· * ·)) (· ≤ ·) :=
⟨fun c a b =>
Quotient.inductionOn₃ a b c fun ⟨α, r, _⟩ ⟨β, s, _⟩ ⟨γ, t, _⟩ ⟨f⟩ => by
refine
(RelEmbedding.ofMonotone (fun a : γ × α => (a.1, f a.2)) fun a b h => ?_).ordinal_type_le
cases' h with a₁ b₁ a₂ b₂ h' a b₁ b₂ h'
· exact Prod.Lex.left _ _ h'
· exact Prod.Lex.right _ (f.toRelEmbedding.map_rel_iff.2 h')⟩
#align ordinal.mul_swap_covariant_class_le Ordinal.mul_swap_covariantClass_le
theorem le_mul_left (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ a * b := by
convert mul_le_mul_left' (one_le_iff_pos.2 hb) a
rw [mul_one a]
#align ordinal.le_mul_left Ordinal.le_mul_left
theorem le_mul_right (a : Ordinal) {b : Ordinal} (hb : 0 < b) : a ≤ b * a := by
convert mul_le_mul_right' (one_le_iff_pos.2 hb) a
rw [one_mul a]
#align ordinal.le_mul_right Ordinal.le_mul_right
private theorem mul_le_of_limit_aux {α β r s} [IsWellOrder α r] [IsWellOrder β s] {c}
(h : IsLimit (type s)) (H : ∀ b' < type s, type r * b' ≤ c) (l : c < type r * type s) :
False := by
suffices ∀ a b, Prod.Lex s r (b, a) (enum _ _ l) by
cases' enum _ _ l with b a
exact irrefl _ (this _ _)
intro a b
rw [← typein_lt_typein (Prod.Lex s r), typein_enum]
have := H _ (h.2 _ (typein_lt_type s b))
rw [mul_succ] at this
have := ((add_lt_add_iff_left _).2 (typein_lt_type _ a)).trans_le this
refine (RelEmbedding.ofMonotone (fun a => ?_) fun a b => ?_).ordinal_type_le.trans_lt this
· rcases a with ⟨⟨b', a'⟩, h⟩
by_cases e : b = b'
· refine Sum.inr ⟨a', ?_⟩
subst e
cases' h with _ _ _ _ h _ _ _ h
· exact (irrefl _ h).elim
· exact h
· refine Sum.inl (⟨b', ?_⟩, a')
cases' h with _ _ _ _ h _ _ _ h
· exact h
· exact (e rfl).elim
· rcases a with ⟨⟨b₁, a₁⟩, h₁⟩
rcases b with ⟨⟨b₂, a₂⟩, h₂⟩
intro h
by_cases e₁ : b = b₁ <;> by_cases e₂ : b = b₂
· substs b₁ b₂
simpa only [subrel_val, Prod.lex_def, @irrefl _ s _ b, true_and_iff, false_or_iff,
eq_self_iff_true, dif_pos, Sum.lex_inr_inr] using h
· subst b₁
simp only [subrel_val, Prod.lex_def, e₂, Prod.lex_def, dif_pos, subrel_val, eq_self_iff_true,
or_false_iff, dif_neg, not_false_iff, Sum.lex_inr_inl, false_and_iff] at h ⊢
cases' h₂ with _ _ _ _ h₂_h h₂_h <;> [exact asymm h h₂_h; exact e₂ rfl]
-- Porting note: `cc` hadn't ported yet.
· simp [e₂, dif_neg e₁, show b₂ ≠ b₁ from e₂ ▸ e₁]
· simpa only [dif_neg e₁, dif_neg e₂, Prod.lex_def, subrel_val, Subtype.mk_eq_mk,
Sum.lex_inl_inl] using h
theorem mul_le_of_limit {a b c : Ordinal} (h : IsLimit b) : a * b ≤ c ↔ ∀ b' < b, a * b' ≤ c :=
⟨fun h b' l => (mul_le_mul_left' l.le _).trans h, fun H =>
-- Porting note: `induction` tactics are required because of the parser bug.
le_of_not_lt <| by
induction a using inductionOn with
| H α r =>
induction b using inductionOn with
| H β s =>
exact mul_le_of_limit_aux h H⟩
#align ordinal.mul_le_of_limit Ordinal.mul_le_of_limit
theorem mul_isNormal {a : Ordinal} (h : 0 < a) : IsNormal (a * ·) :=
-- Porting note(#12129): additional beta reduction needed
⟨fun b => by
beta_reduce
rw [mul_succ]
simpa only [add_zero] using (add_lt_add_iff_left (a * b)).2 h,
fun b l c => mul_le_of_limit l⟩
#align ordinal.mul_is_normal Ordinal.mul_isNormal
theorem lt_mul_of_limit {a b c : Ordinal} (h : IsLimit c) : a < b * c ↔ ∃ c' < c, a < b * c' := by
-- Porting note: `bex_def` is required.
simpa only [not_forall₂, not_le, bex_def] using not_congr (@mul_le_of_limit b c a h)
#align ordinal.lt_mul_of_limit Ordinal.lt_mul_of_limit
theorem mul_lt_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b < a * c ↔ b < c :=
(mul_isNormal a0).lt_iff
#align ordinal.mul_lt_mul_iff_left Ordinal.mul_lt_mul_iff_left
theorem mul_le_mul_iff_left {a b c : Ordinal} (a0 : 0 < a) : a * b ≤ a * c ↔ b ≤ c :=
(mul_isNormal a0).le_iff
#align ordinal.mul_le_mul_iff_left Ordinal.mul_le_mul_iff_left
theorem mul_lt_mul_of_pos_left {a b c : Ordinal} (h : a < b) (c0 : 0 < c) : c * a < c * b :=
(mul_lt_mul_iff_left c0).2 h
#align ordinal.mul_lt_mul_of_pos_left Ordinal.mul_lt_mul_of_pos_left
theorem mul_pos {a b : Ordinal} (h₁ : 0 < a) (h₂ : 0 < b) : 0 < a * b := by
simpa only [mul_zero] using mul_lt_mul_of_pos_left h₂ h₁
#align ordinal.mul_pos Ordinal.mul_pos
theorem mul_ne_zero {a b : Ordinal} : a ≠ 0 → b ≠ 0 → a * b ≠ 0 := by
simpa only [Ordinal.pos_iff_ne_zero] using mul_pos
#align ordinal.mul_ne_zero Ordinal.mul_ne_zero
theorem le_of_mul_le_mul_left {a b c : Ordinal} (h : c * a ≤ c * b) (h0 : 0 < c) : a ≤ b :=
le_imp_le_of_lt_imp_lt (fun h' => mul_lt_mul_of_pos_left h' h0) h
#align ordinal.le_of_mul_le_mul_left Ordinal.le_of_mul_le_mul_left
theorem mul_right_inj {a b c : Ordinal} (a0 : 0 < a) : a * b = a * c ↔ b = c :=
(mul_isNormal a0).inj
#align ordinal.mul_right_inj Ordinal.mul_right_inj
theorem mul_isLimit {a b : Ordinal} (a0 : 0 < a) : IsLimit b → IsLimit (a * b) :=
(mul_isNormal a0).isLimit
#align ordinal.mul_is_limit Ordinal.mul_isLimit
| Mathlib/SetTheory/Ordinal/Arithmetic.lean | 845 | 850 | theorem mul_isLimit_left {a b : Ordinal} (l : IsLimit a) (b0 : 0 < b) : IsLimit (a * b) := by |
rcases zero_or_succ_or_limit b with (rfl | ⟨b, rfl⟩ | lb)
· exact b0.false.elim
· rw [mul_succ]
exact add_isLimit _ l
· exact mul_isLimit l.pos lb
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic
import Mathlib.Analysis.Normed.Group.AddCircle
import Mathlib.Algebra.CharZero.Quotient
import Mathlib.Topology.Instances.Sign
#align_import analysis.special_functions.trigonometric.angle from "leanprover-community/mathlib"@"213b0cff7bc5ab6696ee07cceec80829ce42efec"
open Real
noncomputable section
namespace Real
-- Porting note: can't derive `NormedAddCommGroup, Inhabited`
def Angle : Type :=
AddCircle (2 * π)
#align real.angle Real.Angle
namespace Angle
-- Porting note (#10754): added due to missing instances due to no deriving
instance : NormedAddCommGroup Angle :=
inferInstanceAs (NormedAddCommGroup (AddCircle (2 * π)))
-- Porting note (#10754): added due to missing instances due to no deriving
instance : Inhabited Angle :=
inferInstanceAs (Inhabited (AddCircle (2 * π)))
-- Porting note (#10754): added due to missing instances due to no deriving
-- also, without this, a plain `QuotientAddGroup.mk`
-- causes coerced terms to be of type `ℝ ⧸ AddSubgroup.zmultiples (2 * π)`
@[coe]
protected def coe (r : ℝ) : Angle := QuotientAddGroup.mk r
instance : Coe ℝ Angle := ⟨Angle.coe⟩
instance : CircularOrder Real.Angle :=
QuotientAddGroup.circularOrder (hp' := ⟨by norm_num [pi_pos]⟩)
@[continuity]
theorem continuous_coe : Continuous ((↑) : ℝ → Angle) :=
continuous_quotient_mk'
#align real.angle.continuous_coe Real.Angle.continuous_coe
def coeHom : ℝ →+ Angle :=
QuotientAddGroup.mk' _
#align real.angle.coe_hom Real.Angle.coeHom
@[simp]
theorem coe_coeHom : (coeHom : ℝ → Angle) = ((↑) : ℝ → Angle) :=
rfl
#align real.angle.coe_coe_hom Real.Angle.coe_coeHom
@[elab_as_elim]
protected theorem induction_on {p : Angle → Prop} (θ : Angle) (h : ∀ x : ℝ, p x) : p θ :=
Quotient.inductionOn' θ h
#align real.angle.induction_on Real.Angle.induction_on
@[simp]
theorem coe_zero : ↑(0 : ℝ) = (0 : Angle) :=
rfl
#align real.angle.coe_zero Real.Angle.coe_zero
@[simp]
theorem coe_add (x y : ℝ) : ↑(x + y : ℝ) = (↑x + ↑y : Angle) :=
rfl
#align real.angle.coe_add Real.Angle.coe_add
@[simp]
theorem coe_neg (x : ℝ) : ↑(-x : ℝ) = -(↑x : Angle) :=
rfl
#align real.angle.coe_neg Real.Angle.coe_neg
@[simp]
theorem coe_sub (x y : ℝ) : ↑(x - y : ℝ) = (↑x - ↑y : Angle) :=
rfl
#align real.angle.coe_sub Real.Angle.coe_sub
theorem coe_nsmul (n : ℕ) (x : ℝ) : ↑(n • x : ℝ) = n • (↑x : Angle) :=
rfl
#align real.angle.coe_nsmul Real.Angle.coe_nsmul
theorem coe_zsmul (z : ℤ) (x : ℝ) : ↑(z • x : ℝ) = z • (↑x : Angle) :=
rfl
#align real.angle.coe_zsmul Real.Angle.coe_zsmul
@[simp, norm_cast]
theorem natCast_mul_eq_nsmul (x : ℝ) (n : ℕ) : ↑((n : ℝ) * x) = n • (↑x : Angle) := by
simpa only [nsmul_eq_mul] using coeHom.map_nsmul x n
#align real.angle.coe_nat_mul_eq_nsmul Real.Angle.natCast_mul_eq_nsmul
@[simp, norm_cast]
theorem intCast_mul_eq_zsmul (x : ℝ) (n : ℤ) : ↑((n : ℝ) * x : ℝ) = n • (↑x : Angle) := by
simpa only [zsmul_eq_mul] using coeHom.map_zsmul x n
#align real.angle.coe_int_mul_eq_zsmul Real.Angle.intCast_mul_eq_zsmul
@[deprecated (since := "2024-05-25")] alias coe_nat_mul_eq_nsmul := natCast_mul_eq_nsmul
@[deprecated (since := "2024-05-25")] alias coe_int_mul_eq_zsmul := intCast_mul_eq_zsmul
theorem angle_eq_iff_two_pi_dvd_sub {ψ θ : ℝ} : (θ : Angle) = ψ ↔ ∃ k : ℤ, θ - ψ = 2 * π * k := by
simp only [QuotientAddGroup.eq, AddSubgroup.zmultiples_eq_closure,
AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
-- Porting note: added `rw`, `simp [Angle.coe, QuotientAddGroup.eq]` doesn't fire otherwise
rw [Angle.coe, Angle.coe, QuotientAddGroup.eq]
simp only [AddSubgroup.zmultiples_eq_closure,
AddSubgroup.mem_closure_singleton, zsmul_eq_mul', (sub_eq_neg_add _ _).symm, eq_comm]
#align real.angle.angle_eq_iff_two_pi_dvd_sub Real.Angle.angle_eq_iff_two_pi_dvd_sub
@[simp]
theorem coe_two_pi : ↑(2 * π : ℝ) = (0 : Angle) :=
angle_eq_iff_two_pi_dvd_sub.2 ⟨1, by rw [sub_zero, Int.cast_one, mul_one]⟩
#align real.angle.coe_two_pi Real.Angle.coe_two_pi
@[simp]
theorem neg_coe_pi : -(π : Angle) = π := by
rw [← coe_neg, angle_eq_iff_two_pi_dvd_sub]
use -1
simp [two_mul, sub_eq_add_neg]
#align real.angle.neg_coe_pi Real.Angle.neg_coe_pi
@[simp]
theorem two_nsmul_coe_div_two (θ : ℝ) : (2 : ℕ) • (↑(θ / 2) : Angle) = θ := by
rw [← coe_nsmul, two_nsmul, add_halves]
#align real.angle.two_nsmul_coe_div_two Real.Angle.two_nsmul_coe_div_two
@[simp]
theorem two_zsmul_coe_div_two (θ : ℝ) : (2 : ℤ) • (↑(θ / 2) : Angle) = θ := by
rw [← coe_zsmul, two_zsmul, add_halves]
#align real.angle.two_zsmul_coe_div_two Real.Angle.two_zsmul_coe_div_two
-- Porting note (#10618): @[simp] can prove it
theorem two_nsmul_neg_pi_div_two : (2 : ℕ) • (↑(-π / 2) : Angle) = π := by
rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi]
#align real.angle.two_nsmul_neg_pi_div_two Real.Angle.two_nsmul_neg_pi_div_two
-- Porting note (#10618): @[simp] can prove it
theorem two_zsmul_neg_pi_div_two : (2 : ℤ) • (↑(-π / 2) : Angle) = π := by
rw [two_zsmul, ← two_nsmul, two_nsmul_neg_pi_div_two]
#align real.angle.two_zsmul_neg_pi_div_two Real.Angle.two_zsmul_neg_pi_div_two
theorem sub_coe_pi_eq_add_coe_pi (θ : Angle) : θ - π = θ + π := by
rw [sub_eq_add_neg, neg_coe_pi]
#align real.angle.sub_coe_pi_eq_add_coe_pi Real.Angle.sub_coe_pi_eq_add_coe_pi
@[simp]
theorem two_nsmul_coe_pi : (2 : ℕ) • (π : Angle) = 0 := by simp [← natCast_mul_eq_nsmul]
#align real.angle.two_nsmul_coe_pi Real.Angle.two_nsmul_coe_pi
@[simp]
theorem two_zsmul_coe_pi : (2 : ℤ) • (π : Angle) = 0 := by simp [← intCast_mul_eq_zsmul]
#align real.angle.two_zsmul_coe_pi Real.Angle.two_zsmul_coe_pi
@[simp]
theorem coe_pi_add_coe_pi : (π : Real.Angle) + π = 0 := by rw [← two_nsmul, two_nsmul_coe_pi]
#align real.angle.coe_pi_add_coe_pi Real.Angle.coe_pi_add_coe_pi
theorem zsmul_eq_iff {ψ θ : Angle} {z : ℤ} (hz : z ≠ 0) :
z • ψ = z • θ ↔ ∃ k : Fin z.natAbs, ψ = θ + (k : ℕ) • (2 * π / z : ℝ) :=
QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz
#align real.angle.zsmul_eq_iff Real.Angle.zsmul_eq_iff
theorem nsmul_eq_iff {ψ θ : Angle} {n : ℕ} (hz : n ≠ 0) :
n • ψ = n • θ ↔ ∃ k : Fin n, ψ = θ + (k : ℕ) • (2 * π / n : ℝ) :=
QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz
#align real.angle.nsmul_eq_iff Real.Angle.nsmul_eq_iff
theorem two_zsmul_eq_iff {ψ θ : Angle} : (2 : ℤ) • ψ = (2 : ℤ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by
-- Porting note: no `Int.natAbs_bit0` anymore
have : Int.natAbs 2 = 2 := rfl
rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero,
Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two,
mul_div_cancel_left₀ (_ : ℝ) two_ne_zero]
#align real.angle.two_zsmul_eq_iff Real.Angle.two_zsmul_eq_iff
theorem two_nsmul_eq_iff {ψ θ : Angle} : (2 : ℕ) • ψ = (2 : ℕ) • θ ↔ ψ = θ ∨ ψ = θ + ↑π := by
simp_rw [← natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff]
#align real.angle.two_nsmul_eq_iff Real.Angle.two_nsmul_eq_iff
theorem two_nsmul_eq_zero_iff {θ : Angle} : (2 : ℕ) • θ = 0 ↔ θ = 0 ∨ θ = π := by
convert two_nsmul_eq_iff <;> simp
#align real.angle.two_nsmul_eq_zero_iff Real.Angle.two_nsmul_eq_zero_iff
theorem two_nsmul_ne_zero_iff {θ : Angle} : (2 : ℕ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← two_nsmul_eq_zero_iff]
#align real.angle.two_nsmul_ne_zero_iff Real.Angle.two_nsmul_ne_zero_iff
theorem two_zsmul_eq_zero_iff {θ : Angle} : (2 : ℤ) • θ = 0 ↔ θ = 0 ∨ θ = π := by
simp_rw [two_zsmul, ← two_nsmul, two_nsmul_eq_zero_iff]
#align real.angle.two_zsmul_eq_zero_iff Real.Angle.two_zsmul_eq_zero_iff
theorem two_zsmul_ne_zero_iff {θ : Angle} : (2 : ℤ) • θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← two_zsmul_eq_zero_iff]
#align real.angle.two_zsmul_ne_zero_iff Real.Angle.two_zsmul_ne_zero_iff
theorem eq_neg_self_iff {θ : Angle} : θ = -θ ↔ θ = 0 ∨ θ = π := by
rw [← add_eq_zero_iff_eq_neg, ← two_nsmul, two_nsmul_eq_zero_iff]
#align real.angle.eq_neg_self_iff Real.Angle.eq_neg_self_iff
theorem ne_neg_self_iff {θ : Angle} : θ ≠ -θ ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← eq_neg_self_iff.not]
#align real.angle.ne_neg_self_iff Real.Angle.ne_neg_self_iff
theorem neg_eq_self_iff {θ : Angle} : -θ = θ ↔ θ = 0 ∨ θ = π := by rw [eq_comm, eq_neg_self_iff]
#align real.angle.neg_eq_self_iff Real.Angle.neg_eq_self_iff
theorem neg_ne_self_iff {θ : Angle} : -θ ≠ θ ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← neg_eq_self_iff.not]
#align real.angle.neg_ne_self_iff Real.Angle.neg_ne_self_iff
theorem two_nsmul_eq_pi_iff {θ : Angle} : (2 : ℕ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
have h : (π : Angle) = ((2 : ℕ) • (π / 2 : ℝ) :) := by rw [two_nsmul, add_halves]
nth_rw 1 [h]
rw [coe_nsmul, two_nsmul_eq_iff]
-- Porting note: `congr` didn't simplify the goal of iff of `Or`s
convert Iff.rfl
rw [add_comm, ← coe_add, ← sub_eq_zero, ← coe_sub, neg_div, ← neg_sub, sub_neg_eq_add, add_assoc,
add_halves, ← two_mul, coe_neg, coe_two_pi, neg_zero]
#align real.angle.two_nsmul_eq_pi_iff Real.Angle.two_nsmul_eq_pi_iff
theorem two_zsmul_eq_pi_iff {θ : Angle} : (2 : ℤ) • θ = π ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
rw [two_zsmul, ← two_nsmul, two_nsmul_eq_pi_iff]
#align real.angle.two_zsmul_eq_pi_iff Real.Angle.two_zsmul_eq_pi_iff
theorem cos_eq_iff_coe_eq_or_eq_neg {θ ψ : ℝ} :
cos θ = cos ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) = -ψ := by
constructor
· intro Hcos
rw [← sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero,
eq_false (two_ne_zero' ℝ), false_or_iff, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos
rcases Hcos with (⟨n, hn⟩ | ⟨n, hn⟩)
· right
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), ← sub_eq_iff_eq_add] at hn
rw [← hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul,
mul_comm, coe_two_pi, zsmul_zero]
· left
rw [eq_div_iff_mul_eq (two_ne_zero' ℝ), eq_sub_iff_add_eq] at hn
rw [← hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero,
zero_add]
· rw [angle_eq_iff_two_pi_dvd_sub, ← coe_neg, angle_eq_iff_two_pi_dvd_sub]
rintro (⟨k, H⟩ | ⟨k, H⟩)
· rw [← sub_eq_zero, cos_sub_cos, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ),
mul_comm π _, sin_int_mul_pi, mul_zero]
rw [← sub_eq_zero, cos_sub_cos, ← sub_neg_eq_add, H, mul_assoc 2 π k,
mul_div_cancel_left₀ _ (two_ne_zero' ℝ), mul_comm π _, sin_int_mul_pi, mul_zero,
zero_mul]
#align real.angle.cos_eq_iff_coe_eq_or_eq_neg Real.Angle.cos_eq_iff_coe_eq_or_eq_neg
theorem sin_eq_iff_coe_eq_or_add_eq_pi {θ ψ : ℝ} :
sin θ = sin ψ ↔ (θ : Angle) = ψ ∨ (θ : Angle) + ψ = π := by
constructor
· intro Hsin
rw [← cos_pi_div_two_sub, ← cos_pi_div_two_sub] at Hsin
cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h h
· left
rw [coe_sub, coe_sub] at h
exact sub_right_inj.1 h
right
rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, ← coe_add,
add_halves, sub_sub, sub_eq_zero] at h
exact h.symm
· rw [angle_eq_iff_two_pi_dvd_sub, ← eq_sub_iff_add_eq, ← coe_sub, angle_eq_iff_two_pi_dvd_sub]
rintro (⟨k, H⟩ | ⟨k, H⟩)
· rw [← sub_eq_zero, sin_sub_sin, H, mul_assoc 2 π k, mul_div_cancel_left₀ _ (two_ne_zero' ℝ),
mul_comm π _, sin_int_mul_pi, mul_zero, zero_mul]
have H' : θ + ψ = 2 * k * π + π := by
rwa [← sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm π _, ←
mul_assoc] at H
rw [← sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ π,
mul_div_cancel_left₀ _ (two_ne_zero' ℝ), cos_add_pi_div_two, sin_int_mul_pi, neg_zero,
mul_zero]
#align real.angle.sin_eq_iff_coe_eq_or_add_eq_pi Real.Angle.sin_eq_iff_coe_eq_or_add_eq_pi
theorem cos_sin_inj {θ ψ : ℝ} (Hcos : cos θ = cos ψ) (Hsin : sin θ = sin ψ) : (θ : Angle) = ψ := by
cases' cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc hc; · exact hc
cases' sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs hs; · exact hs
rw [eq_neg_iff_add_eq_zero, hs] at hc
obtain ⟨n, hn⟩ : ∃ n, n • _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc)
rw [← neg_one_mul, add_zero, ← sub_eq_zero, zsmul_eq_mul, ← mul_assoc, ← sub_mul, mul_eq_zero,
eq_false (ne_of_gt pi_pos), or_false_iff, sub_neg_eq_add, ← Int.cast_zero, ← Int.cast_one,
← Int.cast_ofNat, ← Int.cast_mul, ← Int.cast_add, Int.cast_inj] at hn
have : (n * 2 + 1) % (2 : ℤ) = 0 % (2 : ℤ) := congr_arg (· % (2 : ℤ)) hn
rw [add_comm, Int.add_mul_emod_self] at this
exact absurd this one_ne_zero
#align real.angle.cos_sin_inj Real.Angle.cos_sin_inj
def sin (θ : Angle) : ℝ :=
sin_periodic.lift θ
#align real.angle.sin Real.Angle.sin
@[simp]
theorem sin_coe (x : ℝ) : sin (x : Angle) = Real.sin x :=
rfl
#align real.angle.sin_coe Real.Angle.sin_coe
@[continuity]
theorem continuous_sin : Continuous sin :=
Real.continuous_sin.quotient_liftOn' _
#align real.angle.continuous_sin Real.Angle.continuous_sin
def cos (θ : Angle) : ℝ :=
cos_periodic.lift θ
#align real.angle.cos Real.Angle.cos
@[simp]
theorem cos_coe (x : ℝ) : cos (x : Angle) = Real.cos x :=
rfl
#align real.angle.cos_coe Real.Angle.cos_coe
@[continuity]
theorem continuous_cos : Continuous cos :=
Real.continuous_cos.quotient_liftOn' _
#align real.angle.continuous_cos Real.Angle.continuous_cos
theorem cos_eq_real_cos_iff_eq_or_eq_neg {θ : Angle} {ψ : ℝ} :
cos θ = Real.cos ψ ↔ θ = ψ ∨ θ = -ψ := by
induction θ using Real.Angle.induction_on
exact cos_eq_iff_coe_eq_or_eq_neg
#align real.angle.cos_eq_real_cos_iff_eq_or_eq_neg Real.Angle.cos_eq_real_cos_iff_eq_or_eq_neg
theorem cos_eq_iff_eq_or_eq_neg {θ ψ : Angle} : cos θ = cos ψ ↔ θ = ψ ∨ θ = -ψ := by
induction ψ using Real.Angle.induction_on
exact cos_eq_real_cos_iff_eq_or_eq_neg
#align real.angle.cos_eq_iff_eq_or_eq_neg Real.Angle.cos_eq_iff_eq_or_eq_neg
theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {θ : Angle} {ψ : ℝ} :
sin θ = Real.sin ψ ↔ θ = ψ ∨ θ + ψ = π := by
induction θ using Real.Angle.induction_on
exact sin_eq_iff_coe_eq_or_add_eq_pi
#align real.angle.sin_eq_real_sin_iff_eq_or_add_eq_pi Real.Angle.sin_eq_real_sin_iff_eq_or_add_eq_pi
theorem sin_eq_iff_eq_or_add_eq_pi {θ ψ : Angle} : sin θ = sin ψ ↔ θ = ψ ∨ θ + ψ = π := by
induction ψ using Real.Angle.induction_on
exact sin_eq_real_sin_iff_eq_or_add_eq_pi
#align real.angle.sin_eq_iff_eq_or_add_eq_pi Real.Angle.sin_eq_iff_eq_or_add_eq_pi
@[simp]
theorem sin_zero : sin (0 : Angle) = 0 := by rw [← coe_zero, sin_coe, Real.sin_zero]
#align real.angle.sin_zero Real.Angle.sin_zero
-- Porting note (#10618): @[simp] can prove it
theorem sin_coe_pi : sin (π : Angle) = 0 := by rw [sin_coe, Real.sin_pi]
#align real.angle.sin_coe_pi Real.Angle.sin_coe_pi
theorem sin_eq_zero_iff {θ : Angle} : sin θ = 0 ↔ θ = 0 ∨ θ = π := by
nth_rw 1 [← sin_zero]
rw [sin_eq_iff_eq_or_add_eq_pi]
simp
#align real.angle.sin_eq_zero_iff Real.Angle.sin_eq_zero_iff
theorem sin_ne_zero_iff {θ : Angle} : sin θ ≠ 0 ↔ θ ≠ 0 ∧ θ ≠ π := by
rw [← not_or, ← sin_eq_zero_iff]
#align real.angle.sin_ne_zero_iff Real.Angle.sin_ne_zero_iff
@[simp]
theorem sin_neg (θ : Angle) : sin (-θ) = -sin θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_neg _
#align real.angle.sin_neg Real.Angle.sin_neg
theorem sin_antiperiodic : Function.Antiperiodic sin (π : Angle) := by
intro θ
induction θ using Real.Angle.induction_on
exact Real.sin_antiperiodic _
#align real.angle.sin_antiperiodic Real.Angle.sin_antiperiodic
@[simp]
theorem sin_add_pi (θ : Angle) : sin (θ + π) = -sin θ :=
sin_antiperiodic θ
#align real.angle.sin_add_pi Real.Angle.sin_add_pi
@[simp]
theorem sin_sub_pi (θ : Angle) : sin (θ - π) = -sin θ :=
sin_antiperiodic.sub_eq θ
#align real.angle.sin_sub_pi Real.Angle.sin_sub_pi
@[simp]
theorem cos_zero : cos (0 : Angle) = 1 := by rw [← coe_zero, cos_coe, Real.cos_zero]
#align real.angle.cos_zero Real.Angle.cos_zero
-- Porting note (#10618): @[simp] can prove it
theorem cos_coe_pi : cos (π : Angle) = -1 := by rw [cos_coe, Real.cos_pi]
#align real.angle.cos_coe_pi Real.Angle.cos_coe_pi
@[simp]
theorem cos_neg (θ : Angle) : cos (-θ) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_neg _
#align real.angle.cos_neg Real.Angle.cos_neg
theorem cos_antiperiodic : Function.Antiperiodic cos (π : Angle) := by
intro θ
induction θ using Real.Angle.induction_on
exact Real.cos_antiperiodic _
#align real.angle.cos_antiperiodic Real.Angle.cos_antiperiodic
@[simp]
theorem cos_add_pi (θ : Angle) : cos (θ + π) = -cos θ :=
cos_antiperiodic θ
#align real.angle.cos_add_pi Real.Angle.cos_add_pi
@[simp]
theorem cos_sub_pi (θ : Angle) : cos (θ - π) = -cos θ :=
cos_antiperiodic.sub_eq θ
#align real.angle.cos_sub_pi Real.Angle.cos_sub_pi
theorem cos_eq_zero_iff {θ : Angle} : cos θ = 0 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by
rw [← cos_pi_div_two, ← cos_coe, cos_eq_iff_eq_or_eq_neg, ← coe_neg, ← neg_div]
#align real.angle.cos_eq_zero_iff Real.Angle.cos_eq_zero_iff
theorem sin_add (θ₁ θ₂ : Real.Angle) : sin (θ₁ + θ₂) = sin θ₁ * cos θ₂ + cos θ₁ * sin θ₂ := by
induction θ₁ using Real.Angle.induction_on
induction θ₂ using Real.Angle.induction_on
exact Real.sin_add _ _
#align real.angle.sin_add Real.Angle.sin_add
theorem cos_add (θ₁ θ₂ : Real.Angle) : cos (θ₁ + θ₂) = cos θ₁ * cos θ₂ - sin θ₁ * sin θ₂ := by
induction θ₂ using Real.Angle.induction_on
induction θ₁ using Real.Angle.induction_on
exact Real.cos_add _ _
#align real.angle.cos_add Real.Angle.cos_add
@[simp]
theorem cos_sq_add_sin_sq (θ : Real.Angle) : cos θ ^ 2 + sin θ ^ 2 = 1 := by
induction θ using Real.Angle.induction_on
exact Real.cos_sq_add_sin_sq _
#align real.angle.cos_sq_add_sin_sq Real.Angle.cos_sq_add_sin_sq
theorem sin_add_pi_div_two (θ : Angle) : sin (θ + ↑(π / 2)) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_add_pi_div_two _
#align real.angle.sin_add_pi_div_two Real.Angle.sin_add_pi_div_two
theorem sin_sub_pi_div_two (θ : Angle) : sin (θ - ↑(π / 2)) = -cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_sub_pi_div_two _
#align real.angle.sin_sub_pi_div_two Real.Angle.sin_sub_pi_div_two
theorem sin_pi_div_two_sub (θ : Angle) : sin (↑(π / 2) - θ) = cos θ := by
induction θ using Real.Angle.induction_on
exact Real.sin_pi_div_two_sub _
#align real.angle.sin_pi_div_two_sub Real.Angle.sin_pi_div_two_sub
theorem cos_add_pi_div_two (θ : Angle) : cos (θ + ↑(π / 2)) = -sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_add_pi_div_two _
#align real.angle.cos_add_pi_div_two Real.Angle.cos_add_pi_div_two
theorem cos_sub_pi_div_two (θ : Angle) : cos (θ - ↑(π / 2)) = sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_sub_pi_div_two _
#align real.angle.cos_sub_pi_div_two Real.Angle.cos_sub_pi_div_two
theorem cos_pi_div_two_sub (θ : Angle) : cos (↑(π / 2) - θ) = sin θ := by
induction θ using Real.Angle.induction_on
exact Real.cos_pi_div_two_sub _
#align real.angle.cos_pi_div_two_sub Real.Angle.cos_pi_div_two_sub
theorem abs_sin_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|sin θ| = |sin ψ| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
· rfl
· rw [sin_add_pi, abs_neg]
#align real.angle.abs_sin_eq_of_two_nsmul_eq Real.Angle.abs_sin_eq_of_two_nsmul_eq
theorem abs_sin_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|sin θ| = |sin ψ| := by
simp_rw [two_zsmul, ← two_nsmul] at h
exact abs_sin_eq_of_two_nsmul_eq h
#align real.angle.abs_sin_eq_of_two_zsmul_eq Real.Angle.abs_sin_eq_of_two_zsmul_eq
theorem abs_cos_eq_of_two_nsmul_eq {θ ψ : Angle} (h : (2 : ℕ) • θ = (2 : ℕ) • ψ) :
|cos θ| = |cos ψ| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
· rfl
· rw [cos_add_pi, abs_neg]
#align real.angle.abs_cos_eq_of_two_nsmul_eq Real.Angle.abs_cos_eq_of_two_nsmul_eq
theorem abs_cos_eq_of_two_zsmul_eq {θ ψ : Angle} (h : (2 : ℤ) • θ = (2 : ℤ) • ψ) :
|cos θ| = |cos ψ| := by
simp_rw [two_zsmul, ← two_nsmul] at h
exact abs_cos_eq_of_two_nsmul_eq h
#align real.angle.abs_cos_eq_of_two_zsmul_eq Real.Angle.abs_cos_eq_of_two_zsmul_eq
@[simp]
theorem coe_toIcoMod (θ ψ : ℝ) : ↑(toIcoMod two_pi_pos ψ θ) = (θ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine ⟨-toIcoDiv two_pi_pos ψ θ, ?_⟩
rw [toIcoMod_sub_self, zsmul_eq_mul, mul_comm]
#align real.angle.coe_to_Ico_mod Real.Angle.coe_toIcoMod
@[simp]
theorem coe_toIocMod (θ ψ : ℝ) : ↑(toIocMod two_pi_pos ψ θ) = (θ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine ⟨-toIocDiv two_pi_pos ψ θ, ?_⟩
rw [toIocMod_sub_self, zsmul_eq_mul, mul_comm]
#align real.angle.coe_to_Ioc_mod Real.Angle.coe_toIocMod
def toReal (θ : Angle) : ℝ :=
(toIocMod_periodic two_pi_pos (-π)).lift θ
#align real.angle.to_real Real.Angle.toReal
theorem toReal_coe (θ : ℝ) : (θ : Angle).toReal = toIocMod two_pi_pos (-π) θ :=
rfl
#align real.angle.to_real_coe Real.Angle.toReal_coe
theorem toReal_coe_eq_self_iff {θ : ℝ} : (θ : Angle).toReal = θ ↔ -π < θ ∧ θ ≤ π := by
rw [toReal_coe, toIocMod_eq_self two_pi_pos]
ring_nf
rfl
#align real.angle.to_real_coe_eq_self_iff Real.Angle.toReal_coe_eq_self_iff
theorem toReal_coe_eq_self_iff_mem_Ioc {θ : ℝ} : (θ : Angle).toReal = θ ↔ θ ∈ Set.Ioc (-π) π := by
rw [toReal_coe_eq_self_iff, ← Set.mem_Ioc]
#align real.angle.to_real_coe_eq_self_iff_mem_Ioc Real.Angle.toReal_coe_eq_self_iff_mem_Ioc
theorem toReal_injective : Function.Injective toReal := by
intro θ ψ h
induction θ using Real.Angle.induction_on
induction ψ using Real.Angle.induction_on
simpa [toReal_coe, toIocMod_eq_toIocMod, zsmul_eq_mul, mul_comm _ (2 * π), ←
angle_eq_iff_two_pi_dvd_sub, eq_comm] using h
#align real.angle.to_real_injective Real.Angle.toReal_injective
@[simp]
theorem toReal_inj {θ ψ : Angle} : θ.toReal = ψ.toReal ↔ θ = ψ :=
toReal_injective.eq_iff
#align real.angle.to_real_inj Real.Angle.toReal_inj
@[simp]
theorem coe_toReal (θ : Angle) : (θ.toReal : Angle) = θ := by
induction θ using Real.Angle.induction_on
exact coe_toIocMod _ _
#align real.angle.coe_to_real Real.Angle.coe_toReal
theorem neg_pi_lt_toReal (θ : Angle) : -π < θ.toReal := by
induction θ using Real.Angle.induction_on
exact left_lt_toIocMod _ _ _
#align real.angle.neg_pi_lt_to_real Real.Angle.neg_pi_lt_toReal
theorem toReal_le_pi (θ : Angle) : θ.toReal ≤ π := by
induction θ using Real.Angle.induction_on
convert toIocMod_le_right two_pi_pos _ _
ring
#align real.angle.to_real_le_pi Real.Angle.toReal_le_pi
theorem abs_toReal_le_pi (θ : Angle) : |θ.toReal| ≤ π :=
abs_le.2 ⟨(neg_pi_lt_toReal _).le, toReal_le_pi _⟩
#align real.angle.abs_to_real_le_pi Real.Angle.abs_toReal_le_pi
theorem toReal_mem_Ioc (θ : Angle) : θ.toReal ∈ Set.Ioc (-π) π :=
⟨neg_pi_lt_toReal _, toReal_le_pi _⟩
#align real.angle.to_real_mem_Ioc Real.Angle.toReal_mem_Ioc
@[simp]
theorem toIocMod_toReal (θ : Angle) : toIocMod two_pi_pos (-π) θ.toReal = θ.toReal := by
induction θ using Real.Angle.induction_on
rw [toReal_coe]
exact toIocMod_toIocMod _ _ _ _
#align real.angle.to_Ioc_mod_to_real Real.Angle.toIocMod_toReal
@[simp]
theorem toReal_zero : (0 : Angle).toReal = 0 := by
rw [← coe_zero, toReal_coe_eq_self_iff]
exact ⟨Left.neg_neg_iff.2 Real.pi_pos, Real.pi_pos.le⟩
#align real.angle.to_real_zero Real.Angle.toReal_zero
@[simp]
theorem toReal_eq_zero_iff {θ : Angle} : θ.toReal = 0 ↔ θ = 0 := by
nth_rw 1 [← toReal_zero]
exact toReal_inj
#align real.angle.to_real_eq_zero_iff Real.Angle.toReal_eq_zero_iff
@[simp]
theorem toReal_pi : (π : Angle).toReal = π := by
rw [toReal_coe_eq_self_iff]
exact ⟨Left.neg_lt_self Real.pi_pos, le_refl _⟩
#align real.angle.to_real_pi Real.Angle.toReal_pi
@[simp]
theorem toReal_eq_pi_iff {θ : Angle} : θ.toReal = π ↔ θ = π := by rw [← toReal_inj, toReal_pi]
#align real.angle.to_real_eq_pi_iff Real.Angle.toReal_eq_pi_iff
theorem pi_ne_zero : (π : Angle) ≠ 0 := by
rw [← toReal_injective.ne_iff, toReal_pi, toReal_zero]
exact Real.pi_ne_zero
#align real.angle.pi_ne_zero Real.Angle.pi_ne_zero
@[simp]
theorem toReal_pi_div_two : ((π / 2 : ℝ) : Angle).toReal = π / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
#align real.angle.to_real_pi_div_two Real.Angle.toReal_pi_div_two
@[simp]
theorem toReal_eq_pi_div_two_iff {θ : Angle} : θ.toReal = π / 2 ↔ θ = (π / 2 : ℝ) := by
rw [← toReal_inj, toReal_pi_div_two]
#align real.angle.to_real_eq_pi_div_two_iff Real.Angle.toReal_eq_pi_div_two_iff
@[simp]
theorem toReal_neg_pi_div_two : ((-π / 2 : ℝ) : Angle).toReal = -π / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
#align real.angle.to_real_neg_pi_div_two Real.Angle.toReal_neg_pi_div_two
@[simp]
theorem toReal_eq_neg_pi_div_two_iff {θ : Angle} : θ.toReal = -π / 2 ↔ θ = (-π / 2 : ℝ) := by
rw [← toReal_inj, toReal_neg_pi_div_two]
#align real.angle.to_real_eq_neg_pi_div_two_iff Real.Angle.toReal_eq_neg_pi_div_two_iff
theorem pi_div_two_ne_zero : ((π / 2 : ℝ) : Angle) ≠ 0 := by
rw [← toReal_injective.ne_iff, toReal_pi_div_two, toReal_zero]
exact div_ne_zero Real.pi_ne_zero two_ne_zero
#align real.angle.pi_div_two_ne_zero Real.Angle.pi_div_two_ne_zero
theorem neg_pi_div_two_ne_zero : ((-π / 2 : ℝ) : Angle) ≠ 0 := by
rw [← toReal_injective.ne_iff, toReal_neg_pi_div_two, toReal_zero]
exact div_ne_zero (neg_ne_zero.2 Real.pi_ne_zero) two_ne_zero
#align real.angle.neg_pi_div_two_ne_zero Real.Angle.neg_pi_div_two_ne_zero
theorem abs_toReal_coe_eq_self_iff {θ : ℝ} : |(θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π :=
⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h =>
(toReal_coe_eq_self_iff.2 ⟨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2⟩).symm ▸
abs_eq_self.2 h.1⟩
#align real.angle.abs_to_real_coe_eq_self_iff Real.Angle.abs_toReal_coe_eq_self_iff
theorem abs_toReal_neg_coe_eq_self_iff {θ : ℝ} : |(-θ : Angle).toReal| = θ ↔ 0 ≤ θ ∧ θ ≤ π := by
refine ⟨fun h => h ▸ ⟨abs_nonneg _, abs_toReal_le_pi _⟩, fun h => ?_⟩
by_cases hnegpi : θ = π; · simp [hnegpi, Real.pi_pos.le]
rw [← coe_neg,
toReal_coe_eq_self_iff.2
⟨neg_lt_neg (lt_of_le_of_ne h.2 hnegpi), (neg_nonpos.2 h.1).trans Real.pi_pos.le⟩,
abs_neg, abs_eq_self.2 h.1]
#align real.angle.abs_to_real_neg_coe_eq_self_iff Real.Angle.abs_toReal_neg_coe_eq_self_iff
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean | 657 | 660 | theorem abs_toReal_eq_pi_div_two_iff {θ : Angle} :
|θ.toReal| = π / 2 ↔ θ = (π / 2 : ℝ) ∨ θ = (-π / 2 : ℝ) := by |
rw [abs_eq (div_nonneg Real.pi_pos.le two_pos.le), ← neg_div, toReal_eq_pi_div_two_iff,
toReal_eq_neg_pi_div_two_iff]
|
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.SpecialFunctions.Complex.Circle
import Mathlib.Analysis.InnerProductSpace.l2Space
import Mathlib.MeasureTheory.Function.ContinuousMapDense
import Mathlib.MeasureTheory.Function.L2Space
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Integral.Periodic
import Mathlib.Topology.ContinuousFunction.StoneWeierstrass
import Mathlib.MeasureTheory.Integral.FundThmCalculus
#align_import analysis.fourier.add_circle from "leanprover-community/mathlib"@"8f9fea08977f7e450770933ee6abb20733b47c92"
noncomputable section
open scoped ENNReal ComplexConjugate Real
open TopologicalSpace ContinuousMap MeasureTheory MeasureTheory.Measure Algebra Submodule Set
variable {T : ℝ}
open AddCircle
section Monomials
def fourier (n : ℤ) : C(AddCircle T, ℂ) where
toFun x := toCircle (n • x :)
continuous_toFun := continuous_induced_dom.comp <| continuous_toCircle.comp <| continuous_zsmul _
#align fourier fourier
@[simp]
theorem fourier_apply {n : ℤ} {x : AddCircle T} : fourier n x = toCircle (n • x :) :=
rfl
#align fourier_apply fourier_apply
-- @[simp] -- Porting note: simp normal form is `fourier_coe_apply'`
theorem fourier_coe_apply {n : ℤ} {x : ℝ} :
fourier n (x : AddCircle T) = Complex.exp (2 * π * Complex.I * n * x / T) := by
rw [fourier_apply, ← QuotientAddGroup.mk_zsmul, toCircle, Function.Periodic.lift_coe,
expMapCircle_apply, Complex.ofReal_mul, Complex.ofReal_div, Complex.ofReal_mul, zsmul_eq_mul,
Complex.ofReal_mul, Complex.ofReal_intCast]
norm_num
congr 1; ring
#align fourier_coe_apply fourier_coe_apply
@[simp]
theorem fourier_coe_apply' {n : ℤ} {x : ℝ} :
toCircle (n • (x : AddCircle T) :) = Complex.exp (2 * π * Complex.I * n * x / T) := by
rw [← fourier_apply]; exact fourier_coe_apply
-- @[simp] -- Porting note: simp normal form is `fourier_zero'`
theorem fourier_zero {x : AddCircle T} : fourier 0 x = 1 := by
induction x using QuotientAddGroup.induction_on'
simp only [fourier_coe_apply]
norm_num
#align fourier_zero fourier_zero
@[simp]
theorem fourier_zero' {x : AddCircle T} : @toCircle T 0 = (1 : ℂ) := by
have : fourier 0 x = @toCircle T 0 := by rw [fourier_apply, zero_smul]
rw [← this]; exact fourier_zero
-- @[simp] -- Porting note: simp normal form is *also* `fourier_zero'`
theorem fourier_eval_zero (n : ℤ) : fourier n (0 : AddCircle T) = 1 := by
rw [← QuotientAddGroup.mk_zero, fourier_coe_apply, Complex.ofReal_zero, mul_zero,
zero_div, Complex.exp_zero]
#align fourier_eval_zero fourier_eval_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem fourier_one {x : AddCircle T} : fourier 1 x = toCircle x := by rw [fourier_apply, one_zsmul]
#align fourier_one fourier_one
-- @[simp] -- Porting note: simp normal form is `fourier_neg'`
theorem fourier_neg {n : ℤ} {x : AddCircle T} : fourier (-n) x = conj (fourier n x) := by
induction x using QuotientAddGroup.induction_on'
simp_rw [fourier_apply, toCircle]
rw [← QuotientAddGroup.mk_zsmul, ← QuotientAddGroup.mk_zsmul]
simp_rw [Function.Periodic.lift_coe, ← coe_inv_circle_eq_conj, ← expMapCircle_neg,
neg_smul, mul_neg]
#align fourier_neg fourier_neg
@[simp]
theorem fourier_neg' {n : ℤ} {x : AddCircle T} : @toCircle T (-(n • x)) = conj (fourier n x) := by
rw [← neg_smul, ← fourier_apply]; exact fourier_neg
-- @[simp] -- Porting note: simp normal form is `fourier_add'`
theorem fourier_add {m n : ℤ} {x : AddCircle T} : fourier (m+n) x = fourier m x * fourier n x := by
simp_rw [fourier_apply, add_zsmul, toCircle_add, coe_mul_unitSphere]
#align fourier_add fourier_add
@[simp]
theorem fourier_add' {m n : ℤ} {x : AddCircle T} :
toCircle ((m + n) • x :) = fourier m x * fourier n x := by
rw [← fourier_apply]; exact fourier_add
theorem fourier_norm [Fact (0 < T)] (n : ℤ) : ‖@fourier T n‖ = 1 := by
rw [ContinuousMap.norm_eq_iSup_norm]
have : ∀ x : AddCircle T, ‖fourier n x‖ = 1 := fun x => abs_coe_circle _
simp_rw [this]
exact @ciSup_const _ _ _ Zero.instNonempty _
#align fourier_norm fourier_norm
theorem fourier_add_half_inv_index {n : ℤ} (hn : n ≠ 0) (hT : 0 < T) (x : AddCircle T) :
@fourier T n (x + ↑(T / 2 / n)) = -fourier n x := by
rw [fourier_apply, zsmul_add, ← QuotientAddGroup.mk_zsmul, toCircle_add, coe_mul_unitSphere]
have : (n : ℂ) ≠ 0 := by simpa using hn
have : (@toCircle T (n • (T / 2 / n) : ℝ) : ℂ) = -1 := by
rw [zsmul_eq_mul, toCircle, Function.Periodic.lift_coe, expMapCircle_apply]
replace hT := Complex.ofReal_ne_zero.mpr hT.ne'
convert Complex.exp_pi_mul_I using 3
field_simp; ring
rw [this]; simp
#align fourier_add_half_inv_index fourier_add_half_inv_index
def fourierSubalgebra : StarSubalgebra ℂ C(AddCircle T, ℂ) where
toSubalgebra := Algebra.adjoin ℂ (range fourier)
star_mem' := by
show Algebra.adjoin ℂ (range (fourier (T := T))) ≤
star (Algebra.adjoin ℂ (range (fourier (T := T))))
refine adjoin_le ?_
rintro - ⟨n, rfl⟩
exact subset_adjoin ⟨-n, ext fun _ => fourier_neg⟩
#align fourier_subalgebra fourierSubalgebra
theorem fourierSubalgebra_coe :
Subalgebra.toSubmodule (@fourierSubalgebra T).toSubalgebra = span ℂ (range (@fourier T)) := by
apply adjoin_eq_span_of_subset
refine Subset.trans ?_ Submodule.subset_span
intro x hx
refine Submonoid.closure_induction hx (fun _ => id) ⟨0, ?_⟩ ?_
· ext1 z; exact fourier_zero
· rintro _ _ ⟨m, rfl⟩ ⟨n, rfl⟩
refine ⟨m + n, ?_⟩
ext1 z
exact fourier_add
#align fourier_subalgebra_coe fourierSubalgebra_coe
#noalign fourier_subalgebra_conj_invariant
variable [hT : Fact (0 < T)]
| Mathlib/Analysis/Fourier/AddCircle.lean | 231 | 237 | theorem fourierSubalgebra_separatesPoints : (@fourierSubalgebra T).SeparatesPoints := by |
intro x y hxy
refine ⟨_, ⟨fourier 1, subset_adjoin ⟨1, rfl⟩, rfl⟩, ?_⟩
dsimp only; rw [fourier_one, fourier_one]
contrapose! hxy
rw [Subtype.coe_inj] at hxy
exact injective_toCircle hT.elim.ne' hxy
|
import Mathlib.Algebra.Ring.Prod
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.FinCases
#align_import data.zmod.basic from "leanprover-community/mathlib"@"74ad1c88c77e799d2fea62801d1dbbd698cff1b7"
assert_not_exists Submodule
open Function
namespace ZMod
instance charZero : CharZero (ZMod 0) := inferInstanceAs (CharZero ℤ)
def val : ∀ {n : ℕ}, ZMod n → ℕ
| 0 => Int.natAbs
| n + 1 => ((↑) : Fin (n + 1) → ℕ)
#align zmod.val ZMod.val
theorem val_lt {n : ℕ} [NeZero n] (a : ZMod n) : a.val < n := by
cases n
· cases NeZero.ne 0 rfl
exact Fin.is_lt a
#align zmod.val_lt ZMod.val_lt
theorem val_le {n : ℕ} [NeZero n] (a : ZMod n) : a.val ≤ n :=
a.val_lt.le
#align zmod.val_le ZMod.val_le
@[simp]
theorem val_zero : ∀ {n}, (0 : ZMod n).val = 0
| 0 => rfl
| _ + 1 => rfl
#align zmod.val_zero ZMod.val_zero
@[simp]
theorem val_one' : (1 : ZMod 0).val = 1 :=
rfl
#align zmod.val_one' ZMod.val_one'
@[simp]
theorem val_neg' {n : ZMod 0} : (-n).val = n.val :=
Int.natAbs_neg n
#align zmod.val_neg' ZMod.val_neg'
@[simp]
theorem val_mul' {m n : ZMod 0} : (m * n).val = m.val * n.val :=
Int.natAbs_mul m n
#align zmod.val_mul' ZMod.val_mul'
@[simp]
theorem val_natCast {n : ℕ} (a : ℕ) : (a : ZMod n).val = a % n := by
cases n
· rw [Nat.mod_zero]
exact Int.natAbs_ofNat a
· apply Fin.val_natCast
#align zmod.val_nat_cast ZMod.val_natCast
@[deprecated (since := "2024-04-17")]
alias val_nat_cast := val_natCast
theorem val_unit' {n : ZMod 0} : IsUnit n ↔ n.val = 1 := by
simp only [val]
rw [Int.isUnit_iff, Int.natAbs_eq_iff, Nat.cast_one]
lemma eq_one_of_isUnit_natCast {n : ℕ} (h : IsUnit (n : ZMod 0)) : n = 1 := by
rw [← Nat.mod_zero n, ← val_natCast, val_unit'.mp h]
theorem val_natCast_of_lt {n a : ℕ} (h : a < n) : (a : ZMod n).val = a := by
rwa [val_natCast, Nat.mod_eq_of_lt]
@[deprecated (since := "2024-04-17")]
alias val_nat_cast_of_lt := val_natCast_of_lt
instance charP (n : ℕ) : CharP (ZMod n) n where
cast_eq_zero_iff' := by
intro k
cases' n with n
· simp [zero_dvd_iff, Int.natCast_eq_zero, Nat.zero_eq]
· exact Fin.natCast_eq_zero
@[simp]
theorem addOrderOf_one (n : ℕ) : addOrderOf (1 : ZMod n) = n :=
CharP.eq _ (CharP.addOrderOf_one _) (ZMod.charP n)
#align zmod.add_order_of_one ZMod.addOrderOf_one
@[simp]
theorem addOrderOf_coe (a : ℕ) {n : ℕ} (n0 : n ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
cases' a with a
· simp only [Nat.zero_eq, Nat.cast_zero, addOrderOf_zero, Nat.gcd_zero_right,
Nat.pos_of_ne_zero n0, Nat.div_self]
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a.succ_ne_zero, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe ZMod.addOrderOf_coe
@[simp]
theorem addOrderOf_coe' {a : ℕ} (n : ℕ) (a0 : a ≠ 0) : addOrderOf (a : ZMod n) = n / n.gcd a := by
rw [← Nat.smul_one_eq_cast, addOrderOf_nsmul' _ a0, ZMod.addOrderOf_one]
#align zmod.add_order_of_coe' ZMod.addOrderOf_coe'
theorem ringChar_zmod_n (n : ℕ) : ringChar (ZMod n) = n := by
rw [ringChar.eq_iff]
exact ZMod.charP n
#align zmod.ring_char_zmod_n ZMod.ringChar_zmod_n
-- @[simp] -- Porting note (#10618): simp can prove this
theorem natCast_self (n : ℕ) : (n : ZMod n) = 0 :=
CharP.cast_eq_zero (ZMod n) n
#align zmod.nat_cast_self ZMod.natCast_self
@[deprecated (since := "2024-04-17")]
alias nat_cast_self := natCast_self
@[simp]
theorem natCast_self' (n : ℕ) : (n + 1 : ZMod (n + 1)) = 0 := by
rw [← Nat.cast_add_one, natCast_self (n + 1)]
#align zmod.nat_cast_self' ZMod.natCast_self'
@[deprecated (since := "2024-04-17")]
alias nat_cast_self' := natCast_self'
section UniversalProperty
variable {n : ℕ} {R : Type*}
section
variable [AddGroupWithOne R]
def cast : ∀ {n : ℕ}, ZMod n → R
| 0 => Int.cast
| _ + 1 => fun i => i.val
#align zmod.cast ZMod.cast
@[simp]
theorem cast_zero : (cast (0 : ZMod n) : R) = 0 := by
delta ZMod.cast
cases n
· exact Int.cast_zero
· simp
#align zmod.cast_zero ZMod.cast_zero
theorem cast_eq_val [NeZero n] (a : ZMod n) : (cast a : R) = a.val := by
cases n
· cases NeZero.ne 0 rfl
rfl
#align zmod.cast_eq_val ZMod.cast_eq_val
variable {S : Type*} [AddGroupWithOne S]
@[simp]
theorem _root_.Prod.fst_zmod_cast (a : ZMod n) : (cast a : R × S).fst = cast a := by
cases n
· rfl
· simp [ZMod.cast]
#align prod.fst_zmod_cast Prod.fst_zmod_cast
@[simp]
theorem _root_.Prod.snd_zmod_cast (a : ZMod n) : (cast a : R × S).snd = cast a := by
cases n
· rfl
· simp [ZMod.cast]
#align prod.snd_zmod_cast Prod.snd_zmod_cast
end
theorem natCast_zmod_val {n : ℕ} [NeZero n] (a : ZMod n) : (a.val : ZMod n) = a := by
cases n
· cases NeZero.ne 0 rfl
· apply Fin.cast_val_eq_self
#align zmod.nat_cast_zmod_val ZMod.natCast_zmod_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_zmod_val := natCast_zmod_val
theorem natCast_rightInverse [NeZero n] : Function.RightInverse val ((↑) : ℕ → ZMod n) :=
natCast_zmod_val
#align zmod.nat_cast_right_inverse ZMod.natCast_rightInverse
@[deprecated (since := "2024-04-17")]
alias nat_cast_rightInverse := natCast_rightInverse
theorem natCast_zmod_surjective [NeZero n] : Function.Surjective ((↑) : ℕ → ZMod n) :=
natCast_rightInverse.surjective
#align zmod.nat_cast_zmod_surjective ZMod.natCast_zmod_surjective
@[deprecated (since := "2024-04-17")]
alias nat_cast_zmod_surjective := natCast_zmod_surjective
@[norm_cast]
theorem intCast_zmod_cast (a : ZMod n) : ((cast a : ℤ) : ZMod n) = a := by
cases n
· simp [ZMod.cast, ZMod]
· dsimp [ZMod.cast, ZMod]
erw [Int.cast_natCast, Fin.cast_val_eq_self]
#align zmod.int_cast_zmod_cast ZMod.intCast_zmod_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_zmod_cast := intCast_zmod_cast
theorem intCast_rightInverse : Function.RightInverse (cast : ZMod n → ℤ) ((↑) : ℤ → ZMod n) :=
intCast_zmod_cast
#align zmod.int_cast_right_inverse ZMod.intCast_rightInverse
@[deprecated (since := "2024-04-17")]
alias int_cast_rightInverse := intCast_rightInverse
theorem intCast_surjective : Function.Surjective ((↑) : ℤ → ZMod n) :=
intCast_rightInverse.surjective
#align zmod.int_cast_surjective ZMod.intCast_surjective
@[deprecated (since := "2024-04-17")]
alias int_cast_surjective := intCast_surjective
theorem cast_id : ∀ (n) (i : ZMod n), (ZMod.cast i : ZMod n) = i
| 0, _ => Int.cast_id
| _ + 1, i => natCast_zmod_val i
#align zmod.cast_id ZMod.cast_id
@[simp]
theorem cast_id' : (ZMod.cast : ZMod n → ZMod n) = id :=
funext (cast_id n)
#align zmod.cast_id' ZMod.cast_id'
variable (R) [Ring R]
@[simp]
theorem natCast_comp_val [NeZero n] : ((↑) : ℕ → R) ∘ (val : ZMod n → ℕ) = cast := by
cases n
· cases NeZero.ne 0 rfl
rfl
#align zmod.nat_cast_comp_val ZMod.natCast_comp_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_comp_val := natCast_comp_val
@[simp]
theorem intCast_comp_cast : ((↑) : ℤ → R) ∘ (cast : ZMod n → ℤ) = cast := by
cases n
· exact congr_arg (Int.cast ∘ ·) ZMod.cast_id'
· ext
simp [ZMod, ZMod.cast]
#align zmod.int_cast_comp_cast ZMod.intCast_comp_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_comp_cast := intCast_comp_cast
variable {R}
@[simp]
theorem natCast_val [NeZero n] (i : ZMod n) : (i.val : R) = cast i :=
congr_fun (natCast_comp_val R) i
#align zmod.nat_cast_val ZMod.natCast_val
@[deprecated (since := "2024-04-17")]
alias nat_cast_val := natCast_val
@[simp]
theorem intCast_cast (i : ZMod n) : ((cast i : ℤ) : R) = cast i :=
congr_fun (intCast_comp_cast R) i
#align zmod.int_cast_cast ZMod.intCast_cast
@[deprecated (since := "2024-04-17")]
alias int_cast_cast := intCast_cast
theorem cast_add_eq_ite {n : ℕ} (a b : ZMod n) :
(cast (a + b) : ℤ) =
if (n : ℤ) ≤ cast a + cast b then (cast a + cast b - n : ℤ) else cast a + cast b := by
cases' n with n
· simp; rfl
change Fin (n + 1) at a b
change ((((a + b) : Fin (n + 1)) : ℕ) : ℤ) = if ((n + 1 : ℕ) : ℤ) ≤ (a : ℕ) + b then _ else _
simp only [Fin.val_add_eq_ite, Int.ofNat_succ, Int.ofNat_le]
norm_cast
split_ifs with h
· rw [Nat.cast_sub h]
congr
· rfl
#align zmod.coe_add_eq_ite ZMod.cast_add_eq_ite
theorem intCast_eq_intCast_iff (a b : ℤ) (c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a ≡ b [ZMOD c] :=
CharP.intCast_eq_intCast (ZMod c) c
#align zmod.int_coe_eq_int_coe_iff ZMod.intCast_eq_intCast_iff
@[deprecated (since := "2024-04-17")]
alias int_cast_eq_int_cast_iff := intCast_eq_intCast_iff
theorem intCast_eq_intCast_iff' (a b : ℤ) (c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a % c = b % c :=
ZMod.intCast_eq_intCast_iff a b c
#align zmod.int_coe_eq_int_coe_iff' ZMod.intCast_eq_intCast_iff'
@[deprecated (since := "2024-04-17")]
alias int_cast_eq_int_cast_iff' := intCast_eq_intCast_iff'
| Mathlib/Data/ZMod/Basic.lean | 566 | 567 | theorem natCast_eq_natCast_iff (a b c : ℕ) : (a : ZMod c) = (b : ZMod c) ↔ a ≡ b [MOD c] := by |
simpa [Int.natCast_modEq_iff] using ZMod.intCast_eq_intCast_iff a b c
|
import Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks
import Mathlib.CategoryTheory.Limits.Shapes.BinaryProducts
#align_import category_theory.limits.shapes.pullbacks from "leanprover-community/mathlib"@"7316286ff2942aa14e540add9058c6b0aa1c8070"
noncomputable section
open CategoryTheory
universe w v₁ v₂ v u u₂
namespace CategoryTheory.Limits
-- attribute [local tidy] tactic.case_bash Porting note: no tidy, no local
abbrev WalkingCospan : Type :=
WidePullbackShape WalkingPair
#align category_theory.limits.walking_cospan CategoryTheory.Limits.WalkingCospan
@[match_pattern]
abbrev WalkingCospan.left : WalkingCospan :=
some WalkingPair.left
#align category_theory.limits.walking_cospan.left CategoryTheory.Limits.WalkingCospan.left
@[match_pattern]
abbrev WalkingCospan.right : WalkingCospan :=
some WalkingPair.right
#align category_theory.limits.walking_cospan.right CategoryTheory.Limits.WalkingCospan.right
@[match_pattern]
abbrev WalkingCospan.one : WalkingCospan :=
none
#align category_theory.limits.walking_cospan.one CategoryTheory.Limits.WalkingCospan.one
abbrev WalkingSpan : Type :=
WidePushoutShape WalkingPair
#align category_theory.limits.walking_span CategoryTheory.Limits.WalkingSpan
@[match_pattern]
abbrev WalkingSpan.left : WalkingSpan :=
some WalkingPair.left
#align category_theory.limits.walking_span.left CategoryTheory.Limits.WalkingSpan.left
@[match_pattern]
abbrev WalkingSpan.right : WalkingSpan :=
some WalkingPair.right
#align category_theory.limits.walking_span.right CategoryTheory.Limits.WalkingSpan.right
@[match_pattern]
abbrev WalkingSpan.zero : WalkingSpan :=
none
#align category_theory.limits.walking_span.zero CategoryTheory.Limits.WalkingSpan.zero
open WalkingSpan.Hom WalkingCospan.Hom WidePullbackShape.Hom WidePushoutShape.Hom
variable {C : Type u} [Category.{v} C]
def WalkingCospan.ext {F : WalkingCospan ⥤ C} {s t : Cone F} (i : s.pt ≅ t.pt)
(w₁ : s.π.app WalkingCospan.left = i.hom ≫ t.π.app WalkingCospan.left)
(w₂ : s.π.app WalkingCospan.right = i.hom ≫ t.π.app WalkingCospan.right) : s ≅ t := by
apply Cones.ext i _
rintro (⟨⟩ | ⟨⟨⟩⟩)
· have h₁ := s.π.naturality WalkingCospan.Hom.inl
dsimp at h₁
simp only [Category.id_comp] at h₁
have h₂ := t.π.naturality WalkingCospan.Hom.inl
dsimp at h₂
simp only [Category.id_comp] at h₂
simp_rw [h₂, ← Category.assoc, ← w₁, ← h₁]
· exact w₁
· exact w₂
#align category_theory.limits.walking_cospan.ext CategoryTheory.Limits.WalkingCospan.ext
def WalkingSpan.ext {F : WalkingSpan ⥤ C} {s t : Cocone F} (i : s.pt ≅ t.pt)
(w₁ : s.ι.app WalkingCospan.left ≫ i.hom = t.ι.app WalkingCospan.left)
(w₂ : s.ι.app WalkingCospan.right ≫ i.hom = t.ι.app WalkingCospan.right) : s ≅ t := by
apply Cocones.ext i _
rintro (⟨⟩ | ⟨⟨⟩⟩)
· have h₁ := s.ι.naturality WalkingSpan.Hom.fst
dsimp at h₁
simp only [Category.comp_id] at h₁
have h₂ := t.ι.naturality WalkingSpan.Hom.fst
dsimp at h₂
simp only [Category.comp_id] at h₂
simp_rw [← h₁, Category.assoc, w₁, h₂]
· exact w₁
· exact w₂
#align category_theory.limits.walking_span.ext CategoryTheory.Limits.WalkingSpan.ext
def cospan {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : WalkingCospan ⥤ C :=
WidePullbackShape.wideCospan Z (fun j => WalkingPair.casesOn j X Y) fun j =>
WalkingPair.casesOn j f g
#align category_theory.limits.cospan CategoryTheory.Limits.cospan
def span {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : WalkingSpan ⥤ C :=
WidePushoutShape.wideSpan X (fun j => WalkingPair.casesOn j Y Z) fun j =>
WalkingPair.casesOn j f g
#align category_theory.limits.span CategoryTheory.Limits.span
@[simp]
theorem cospan_left {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).obj WalkingCospan.left = X :=
rfl
#align category_theory.limits.cospan_left CategoryTheory.Limits.cospan_left
@[simp]
theorem span_left {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.left = Y :=
rfl
#align category_theory.limits.span_left CategoryTheory.Limits.span_left
@[simp]
theorem cospan_right {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(cospan f g).obj WalkingCospan.right = Y := rfl
#align category_theory.limits.cospan_right CategoryTheory.Limits.cospan_right
@[simp]
theorem span_right {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.right = Z :=
rfl
#align category_theory.limits.span_right CategoryTheory.Limits.span_right
@[simp]
theorem cospan_one {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) : (cospan f g).obj WalkingCospan.one = Z :=
rfl
#align category_theory.limits.cospan_one CategoryTheory.Limits.cospan_one
@[simp]
theorem span_zero {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).obj WalkingSpan.zero = X :=
rfl
#align category_theory.limits.span_zero CategoryTheory.Limits.span_zero
@[simp]
theorem cospan_map_inl {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(cospan f g).map WalkingCospan.Hom.inl = f := rfl
#align category_theory.limits.cospan_map_inl CategoryTheory.Limits.cospan_map_inl
@[simp]
theorem span_map_fst {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).map WalkingSpan.Hom.fst = f :=
rfl
#align category_theory.limits.span_map_fst CategoryTheory.Limits.span_map_fst
@[simp]
theorem cospan_map_inr {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
(cospan f g).map WalkingCospan.Hom.inr = g := rfl
#align category_theory.limits.cospan_map_inr CategoryTheory.Limits.cospan_map_inr
@[simp]
theorem span_map_snd {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) : (span f g).map WalkingSpan.Hom.snd = g :=
rfl
#align category_theory.limits.span_map_snd CategoryTheory.Limits.span_map_snd
theorem cospan_map_id {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) (w : WalkingCospan) :
(cospan f g).map (WalkingCospan.Hom.id w) = 𝟙 _ := rfl
#align category_theory.limits.cospan_map_id CategoryTheory.Limits.cospan_map_id
theorem span_map_id {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) (w : WalkingSpan) :
(span f g).map (WalkingSpan.Hom.id w) = 𝟙 _ := rfl
#align category_theory.limits.span_map_id CategoryTheory.Limits.span_map_id
-- @[simps (config := { rhsMd := semireducible })] Porting note: no semireducible
@[simps!]
def diagramIsoCospan (F : WalkingCospan ⥤ C) : F ≅ cospan (F.map inl) (F.map inr) :=
NatIso.ofComponents
(fun j => eqToIso (by rcases j with (⟨⟩ | ⟨⟨⟩⟩) <;> rfl))
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)
#align category_theory.limits.diagram_iso_cospan CategoryTheory.Limits.diagramIsoCospan
-- @[simps (config := { rhsMd := semireducible })] Porting note: no semireducible
@[simps!]
def diagramIsoSpan (F : WalkingSpan ⥤ C) : F ≅ span (F.map fst) (F.map snd) :=
NatIso.ofComponents
(fun j => eqToIso (by rcases j with (⟨⟩ | ⟨⟨⟩⟩) <;> rfl))
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)
#align category_theory.limits.diagram_iso_span CategoryTheory.Limits.diagramIsoSpan
variable {D : Type u₂} [Category.{v₂} D]
def cospanCompIso (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :
cospan f g ⋙ F ≅ cospan (F.map f) (F.map g) :=
NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩) <;> exact Iso.refl _)
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)
#align category_theory.limits.cospan_comp_iso CategoryTheory.Limits.cospanCompIso
section
variable (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
@[simp]
theorem cospanCompIso_app_left : (cospanCompIso F f g).app WalkingCospan.left = Iso.refl _ := rfl
#align category_theory.limits.cospan_comp_iso_app_left CategoryTheory.Limits.cospanCompIso_app_left
@[simp]
theorem cospanCompIso_app_right : (cospanCompIso F f g).app WalkingCospan.right = Iso.refl _ :=
rfl
#align category_theory.limits.cospan_comp_iso_app_right CategoryTheory.Limits.cospanCompIso_app_right
@[simp]
theorem cospanCompIso_app_one : (cospanCompIso F f g).app WalkingCospan.one = Iso.refl _ := rfl
#align category_theory.limits.cospan_comp_iso_app_one CategoryTheory.Limits.cospanCompIso_app_one
@[simp]
theorem cospanCompIso_hom_app_left : (cospanCompIso F f g).hom.app WalkingCospan.left = 𝟙 _ :=
rfl
#align category_theory.limits.cospan_comp_iso_hom_app_left CategoryTheory.Limits.cospanCompIso_hom_app_left
@[simp]
theorem cospanCompIso_hom_app_right : (cospanCompIso F f g).hom.app WalkingCospan.right = 𝟙 _ :=
rfl
#align category_theory.limits.cospan_comp_iso_hom_app_right CategoryTheory.Limits.cospanCompIso_hom_app_right
@[simp]
theorem cospanCompIso_hom_app_one : (cospanCompIso F f g).hom.app WalkingCospan.one = 𝟙 _ := rfl
#align category_theory.limits.cospan_comp_iso_hom_app_one CategoryTheory.Limits.cospanCompIso_hom_app_one
@[simp]
theorem cospanCompIso_inv_app_left : (cospanCompIso F f g).inv.app WalkingCospan.left = 𝟙 _ :=
rfl
#align category_theory.limits.cospan_comp_iso_inv_app_left CategoryTheory.Limits.cospanCompIso_inv_app_left
@[simp]
theorem cospanCompIso_inv_app_right : (cospanCompIso F f g).inv.app WalkingCospan.right = 𝟙 _ :=
rfl
#align category_theory.limits.cospan_comp_iso_inv_app_right CategoryTheory.Limits.cospanCompIso_inv_app_right
@[simp]
theorem cospanCompIso_inv_app_one : (cospanCompIso F f g).inv.app WalkingCospan.one = 𝟙 _ := rfl
#align category_theory.limits.cospan_comp_iso_inv_app_one CategoryTheory.Limits.cospanCompIso_inv_app_one
end
def spanCompIso (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :
span f g ⋙ F ≅ span (F.map f) (F.map g) :=
NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩) <;> exact Iso.refl _)
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp)
#align category_theory.limits.span_comp_iso CategoryTheory.Limits.spanCompIso
section
variable (F : C ⥤ D) {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)
@[simp]
theorem spanCompIso_app_left : (spanCompIso F f g).app WalkingSpan.left = Iso.refl _ := rfl
#align category_theory.limits.span_comp_iso_app_left CategoryTheory.Limits.spanCompIso_app_left
@[simp]
theorem spanCompIso_app_right : (spanCompIso F f g).app WalkingSpan.right = Iso.refl _ := rfl
#align category_theory.limits.span_comp_iso_app_right CategoryTheory.Limits.spanCompIso_app_right
@[simp]
theorem spanCompIso_app_zero : (spanCompIso F f g).app WalkingSpan.zero = Iso.refl _ := rfl
#align category_theory.limits.span_comp_iso_app_zero CategoryTheory.Limits.spanCompIso_app_zero
@[simp]
theorem spanCompIso_hom_app_left : (spanCompIso F f g).hom.app WalkingSpan.left = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_hom_app_left CategoryTheory.Limits.spanCompIso_hom_app_left
@[simp]
theorem spanCompIso_hom_app_right : (spanCompIso F f g).hom.app WalkingSpan.right = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_hom_app_right CategoryTheory.Limits.spanCompIso_hom_app_right
@[simp]
theorem spanCompIso_hom_app_zero : (spanCompIso F f g).hom.app WalkingSpan.zero = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_hom_app_zero CategoryTheory.Limits.spanCompIso_hom_app_zero
@[simp]
theorem spanCompIso_inv_app_left : (spanCompIso F f g).inv.app WalkingSpan.left = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_inv_app_left CategoryTheory.Limits.spanCompIso_inv_app_left
@[simp]
theorem spanCompIso_inv_app_right : (spanCompIso F f g).inv.app WalkingSpan.right = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_inv_app_right CategoryTheory.Limits.spanCompIso_inv_app_right
@[simp]
theorem spanCompIso_inv_app_zero : (spanCompIso F f g).inv.app WalkingSpan.zero = 𝟙 _ := rfl
#align category_theory.limits.span_comp_iso_inv_app_zero CategoryTheory.Limits.spanCompIso_inv_app_zero
end
section
variable {X Y Z X' Y' Z' : C} (iX : X ≅ X') (iY : Y ≅ Y') (iZ : Z ≅ Z')
section
variable {f : X ⟶ Z} {g : Y ⟶ Z} {f' : X' ⟶ Z'} {g' : Y' ⟶ Z'}
def cospanExt (wf : iX.hom ≫ f' = f ≫ iZ.hom) (wg : iY.hom ≫ g' = g ≫ iZ.hom) :
cospan f g ≅ cospan f' g' :=
NatIso.ofComponents
(by rintro (⟨⟩ | ⟨⟨⟩⟩); exacts [iZ, iX, iY])
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp [wf, wg])
#align category_theory.limits.cospan_ext CategoryTheory.Limits.cospanExt
variable (wf : iX.hom ≫ f' = f ≫ iZ.hom) (wg : iY.hom ≫ g' = g ≫ iZ.hom)
@[simp]
theorem cospanExt_app_left : (cospanExt iX iY iZ wf wg).app WalkingCospan.left = iX := by
dsimp [cospanExt]
#align category_theory.limits.cospan_ext_app_left CategoryTheory.Limits.cospanExt_app_left
@[simp]
theorem cospanExt_app_right : (cospanExt iX iY iZ wf wg).app WalkingCospan.right = iY := by
dsimp [cospanExt]
#align category_theory.limits.cospan_ext_app_right CategoryTheory.Limits.cospanExt_app_right
@[simp]
theorem cospanExt_app_one : (cospanExt iX iY iZ wf wg).app WalkingCospan.one = iZ := by
dsimp [cospanExt]
#align category_theory.limits.cospan_ext_app_one CategoryTheory.Limits.cospanExt_app_one
@[simp]
theorem cospanExt_hom_app_left :
(cospanExt iX iY iZ wf wg).hom.app WalkingCospan.left = iX.hom := by dsimp [cospanExt]
#align category_theory.limits.cospan_ext_hom_app_left CategoryTheory.Limits.cospanExt_hom_app_left
@[simp]
theorem cospanExt_hom_app_right :
(cospanExt iX iY iZ wf wg).hom.app WalkingCospan.right = iY.hom := by dsimp [cospanExt]
#align category_theory.limits.cospan_ext_hom_app_right CategoryTheory.Limits.cospanExt_hom_app_right
@[simp]
theorem cospanExt_hom_app_one : (cospanExt iX iY iZ wf wg).hom.app WalkingCospan.one = iZ.hom := by
dsimp [cospanExt]
#align category_theory.limits.cospan_ext_hom_app_one CategoryTheory.Limits.cospanExt_hom_app_one
@[simp]
theorem cospanExt_inv_app_left :
(cospanExt iX iY iZ wf wg).inv.app WalkingCospan.left = iX.inv := by dsimp [cospanExt]
#align category_theory.limits.cospan_ext_inv_app_left CategoryTheory.Limits.cospanExt_inv_app_left
@[simp]
theorem cospanExt_inv_app_right :
(cospanExt iX iY iZ wf wg).inv.app WalkingCospan.right = iY.inv := by dsimp [cospanExt]
#align category_theory.limits.cospan_ext_inv_app_right CategoryTheory.Limits.cospanExt_inv_app_right
@[simp]
theorem cospanExt_inv_app_one : (cospanExt iX iY iZ wf wg).inv.app WalkingCospan.one = iZ.inv := by
dsimp [cospanExt]
#align category_theory.limits.cospan_ext_inv_app_one CategoryTheory.Limits.cospanExt_inv_app_one
end
section
variable {f : X ⟶ Y} {g : X ⟶ Z} {f' : X' ⟶ Y'} {g' : X' ⟶ Z'}
def spanExt (wf : iX.hom ≫ f' = f ≫ iY.hom) (wg : iX.hom ≫ g' = g ≫ iZ.hom) :
span f g ≅ span f' g' :=
NatIso.ofComponents (by rintro (⟨⟩ | ⟨⟨⟩⟩); exacts [iX, iY, iZ])
(by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) f <;> cases f <;> dsimp <;> simp [wf, wg])
#align category_theory.limits.span_ext CategoryTheory.Limits.spanExt
variable (wf : iX.hom ≫ f' = f ≫ iY.hom) (wg : iX.hom ≫ g' = g ≫ iZ.hom)
@[simp]
theorem spanExt_app_left : (spanExt iX iY iZ wf wg).app WalkingSpan.left = iY := by
dsimp [spanExt]
#align category_theory.limits.span_ext_app_left CategoryTheory.Limits.spanExt_app_left
@[simp]
theorem spanExt_app_right : (spanExt iX iY iZ wf wg).app WalkingSpan.right = iZ := by
dsimp [spanExt]
#align category_theory.limits.span_ext_app_right CategoryTheory.Limits.spanExt_app_right
@[simp]
theorem spanExt_app_one : (spanExt iX iY iZ wf wg).app WalkingSpan.zero = iX := by
dsimp [spanExt]
#align category_theory.limits.span_ext_app_one CategoryTheory.Limits.spanExt_app_one
@[simp]
theorem spanExt_hom_app_left : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.left = iY.hom := by
dsimp [spanExt]
#align category_theory.limits.span_ext_hom_app_left CategoryTheory.Limits.spanExt_hom_app_left
@[simp]
theorem spanExt_hom_app_right : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.right = iZ.hom := by
dsimp [spanExt]
#align category_theory.limits.span_ext_hom_app_right CategoryTheory.Limits.spanExt_hom_app_right
@[simp]
theorem spanExt_hom_app_zero : (spanExt iX iY iZ wf wg).hom.app WalkingSpan.zero = iX.hom := by
dsimp [spanExt]
#align category_theory.limits.span_ext_hom_app_zero CategoryTheory.Limits.spanExt_hom_app_zero
@[simp]
theorem spanExt_inv_app_left : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.left = iY.inv := by
dsimp [spanExt]
#align category_theory.limits.span_ext_inv_app_left CategoryTheory.Limits.spanExt_inv_app_left
@[simp]
theorem spanExt_inv_app_right : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.right = iZ.inv := by
dsimp [spanExt]
#align category_theory.limits.span_ext_inv_app_right CategoryTheory.Limits.spanExt_inv_app_right
@[simp]
theorem spanExt_inv_app_zero : (spanExt iX iY iZ wf wg).inv.app WalkingSpan.zero = iX.inv := by
dsimp [spanExt]
#align category_theory.limits.span_ext_inv_app_zero CategoryTheory.Limits.spanExt_inv_app_zero
end
end
variable {W X Y Z : C}
abbrev PullbackCone (f : X ⟶ Z) (g : Y ⟶ Z) :=
Cone (cospan f g)
#align category_theory.limits.pullback_cone CategoryTheory.Limits.PullbackCone
namespace PullbackCone
variable {f : X ⟶ Z} {g : Y ⟶ Z}
abbrev fst (t : PullbackCone f g) : t.pt ⟶ X :=
t.π.app WalkingCospan.left
#align category_theory.limits.pullback_cone.fst CategoryTheory.Limits.PullbackCone.fst
abbrev snd (t : PullbackCone f g) : t.pt ⟶ Y :=
t.π.app WalkingCospan.right
#align category_theory.limits.pullback_cone.snd CategoryTheory.Limits.PullbackCone.snd
@[simp]
theorem π_app_left (c : PullbackCone f g) : c.π.app WalkingCospan.left = c.fst := rfl
#align category_theory.limits.pullback_cone.π_app_left CategoryTheory.Limits.PullbackCone.π_app_left
@[simp]
theorem π_app_right (c : PullbackCone f g) : c.π.app WalkingCospan.right = c.snd := rfl
#align category_theory.limits.pullback_cone.π_app_right CategoryTheory.Limits.PullbackCone.π_app_right
@[simp]
theorem condition_one (t : PullbackCone f g) : t.π.app WalkingCospan.one = t.fst ≫ f := by
have w := t.π.naturality WalkingCospan.Hom.inl
dsimp at w; simpa using w
#align category_theory.limits.pullback_cone.condition_one CategoryTheory.Limits.PullbackCone.condition_one
def isLimitAux (t : PullbackCone f g) (lift : ∀ s : PullbackCone f g, s.pt ⟶ t.pt)
(fac_left : ∀ s : PullbackCone f g, lift s ≫ t.fst = s.fst)
(fac_right : ∀ s : PullbackCone f g, lift s ≫ t.snd = s.snd)
(uniq : ∀ (s : PullbackCone f g) (m : s.pt ⟶ t.pt)
(_ : ∀ j : WalkingCospan, m ≫ t.π.app j = s.π.app j), m = lift s) : IsLimit t :=
{ lift
fac := fun s j => Option.casesOn j (by
rw [← s.w inl, ← t.w inl, ← Category.assoc]
congr
exact fac_left s)
fun j' => WalkingPair.casesOn j' (fac_left s) (fac_right s)
uniq := uniq }
#align category_theory.limits.pullback_cone.is_limit_aux CategoryTheory.Limits.PullbackCone.isLimitAux
def isLimitAux' (t : PullbackCone f g)
(create :
∀ s : PullbackCone f g,
{ l //
l ≫ t.fst = s.fst ∧
l ≫ t.snd = s.snd ∧ ∀ {m}, m ≫ t.fst = s.fst → m ≫ t.snd = s.snd → m = l }) :
Limits.IsLimit t :=
PullbackCone.isLimitAux t (fun s => (create s).1) (fun s => (create s).2.1)
(fun s => (create s).2.2.1) fun s _ w =>
(create s).2.2.2 (w WalkingCospan.left) (w WalkingCospan.right)
#align category_theory.limits.pullback_cone.is_limit_aux' CategoryTheory.Limits.PullbackCone.isLimitAux'
@[simps]
def mk {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) : PullbackCone f g where
pt := W
π := { app := fun j => Option.casesOn j (fst ≫ f) fun j' => WalkingPair.casesOn j' fst snd
naturality := by rintro (⟨⟩ | ⟨⟨⟩⟩) (⟨⟩ | ⟨⟨⟩⟩) j <;> cases j <;> dsimp <;> simp [eq] }
#align category_theory.limits.pullback_cone.mk CategoryTheory.Limits.PullbackCone.mk
@[simp]
theorem mk_π_app_left {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :
(mk fst snd eq).π.app WalkingCospan.left = fst := rfl
#align category_theory.limits.pullback_cone.mk_π_app_left CategoryTheory.Limits.PullbackCone.mk_π_app_left
@[simp]
theorem mk_π_app_right {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :
(mk fst snd eq).π.app WalkingCospan.right = snd := rfl
#align category_theory.limits.pullback_cone.mk_π_app_right CategoryTheory.Limits.PullbackCone.mk_π_app_right
@[simp]
theorem mk_π_app_one {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :
(mk fst snd eq).π.app WalkingCospan.one = fst ≫ f := rfl
#align category_theory.limits.pullback_cone.mk_π_app_one CategoryTheory.Limits.PullbackCone.mk_π_app_one
@[simp]
theorem mk_fst {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :
(mk fst snd eq).fst = fst := rfl
#align category_theory.limits.pullback_cone.mk_fst CategoryTheory.Limits.PullbackCone.mk_fst
@[simp]
theorem mk_snd {W : C} (fst : W ⟶ X) (snd : W ⟶ Y) (eq : fst ≫ f = snd ≫ g) :
(mk fst snd eq).snd = snd := rfl
#align category_theory.limits.pullback_cone.mk_snd CategoryTheory.Limits.PullbackCone.mk_snd
@[reassoc]
theorem condition (t : PullbackCone f g) : fst t ≫ f = snd t ≫ g :=
(t.w inl).trans (t.w inr).symm
#align category_theory.limits.pullback_cone.condition CategoryTheory.Limits.PullbackCone.condition
theorem equalizer_ext (t : PullbackCone f g) {W : C} {k l : W ⟶ t.pt} (h₀ : k ≫ fst t = l ≫ fst t)
(h₁ : k ≫ snd t = l ≫ snd t) : ∀ j : WalkingCospan, k ≫ t.π.app j = l ≫ t.π.app j
| some WalkingPair.left => h₀
| some WalkingPair.right => h₁
| none => by rw [← t.w inl, reassoc_of% h₀]
#align category_theory.limits.pullback_cone.equalizer_ext CategoryTheory.Limits.PullbackCone.equalizer_ext
theorem IsLimit.hom_ext {t : PullbackCone f g} (ht : IsLimit t) {W : C} {k l : W ⟶ t.pt}
(h₀ : k ≫ fst t = l ≫ fst t) (h₁ : k ≫ snd t = l ≫ snd t) : k = l :=
ht.hom_ext <| equalizer_ext _ h₀ h₁
#align category_theory.limits.pullback_cone.is_limit.hom_ext CategoryTheory.Limits.PullbackCone.IsLimit.hom_ext
theorem mono_snd_of_is_pullback_of_mono {t : PullbackCone f g} (ht : IsLimit t) [Mono f] :
Mono t.snd := by
refine ⟨fun {W} h k i => IsLimit.hom_ext ht ?_ i⟩
rw [← cancel_mono f, Category.assoc, Category.assoc, condition]
have := congrArg (· ≫ g) i; dsimp at this
rwa [Category.assoc, Category.assoc] at this
#align category_theory.limits.pullback_cone.mono_snd_of_is_pullback_of_mono CategoryTheory.Limits.PullbackCone.mono_snd_of_is_pullback_of_mono
theorem mono_fst_of_is_pullback_of_mono {t : PullbackCone f g} (ht : IsLimit t) [Mono g] :
Mono t.fst := by
refine ⟨fun {W} h k i => IsLimit.hom_ext ht i ?_⟩
rw [← cancel_mono g, Category.assoc, Category.assoc, ← condition]
have := congrArg (· ≫ f) i; dsimp at this
rwa [Category.assoc, Category.assoc] at this
#align category_theory.limits.pullback_cone.mono_fst_of_is_pullback_of_mono CategoryTheory.Limits.PullbackCone.mono_fst_of_is_pullback_of_mono
def ext {s t : PullbackCone f g} (i : s.pt ≅ t.pt) (w₁ : s.fst = i.hom ≫ t.fst)
(w₂ : s.snd = i.hom ≫ t.snd) : s ≅ t :=
WalkingCospan.ext i w₁ w₂
#align category_theory.limits.pullback_cone.ext CategoryTheory.Limits.PullbackCone.ext
-- Porting note: `IsLimit.lift` and the two following simp lemmas were introduced to ease the port
def IsLimit.lift {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : W ⟶ t.pt :=
ht.lift <| PullbackCone.mk _ _ w
@[reassoc (attr := simp)]
lemma IsLimit.lift_fst {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : IsLimit.lift ht h k w ≫ fst t = h := ht.fac _ _
@[reassoc (attr := simp)]
lemma IsLimit.lift_snd {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : IsLimit.lift ht h k w ≫ snd t = k := ht.fac _ _
def IsLimit.lift' {t : PullbackCone f g} (ht : IsLimit t) {W : C} (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : { l : W ⟶ t.pt // l ≫ fst t = h ∧ l ≫ snd t = k } :=
⟨IsLimit.lift ht h k w, by simp⟩
#align category_theory.limits.pullback_cone.is_limit.lift' CategoryTheory.Limits.PullbackCone.IsLimit.lift'
def IsLimit.mk {W : C} {fst : W ⟶ X} {snd : W ⟶ Y} (eq : fst ≫ f = snd ≫ g)
(lift : ∀ s : PullbackCone f g, s.pt ⟶ W)
(fac_left : ∀ s : PullbackCone f g, lift s ≫ fst = s.fst)
(fac_right : ∀ s : PullbackCone f g, lift s ≫ snd = s.snd)
(uniq :
∀ (s : PullbackCone f g) (m : s.pt ⟶ W) (_ : m ≫ fst = s.fst) (_ : m ≫ snd = s.snd),
m = lift s) :
IsLimit (mk fst snd eq) :=
isLimitAux _ lift fac_left fac_right fun s m w =>
uniq s m (w WalkingCospan.left) (w WalkingCospan.right)
#align category_theory.limits.pullback_cone.is_limit.mk CategoryTheory.Limits.PullbackCone.IsLimit.mk
@[simps]
def Cone.ofPullbackCone {F : WalkingCospan ⥤ C} (t : PullbackCone (F.map inl) (F.map inr)) :
Cone F where
pt := t.pt
π := t.π ≫ (diagramIsoCospan F).inv
#align category_theory.limits.cone.of_pullback_cone CategoryTheory.Limits.Cone.ofPullbackCone
@[simps]
def Cocone.ofPushoutCocone {F : WalkingSpan ⥤ C} (t : PushoutCocone (F.map fst) (F.map snd)) :
Cocone F where
pt := t.pt
ι := (diagramIsoSpan F).hom ≫ t.ι
#align category_theory.limits.cocone.of_pushout_cocone CategoryTheory.Limits.Cocone.ofPushoutCocone
@[simps]
def PullbackCone.ofCone {F : WalkingCospan ⥤ C} (t : Cone F) :
PullbackCone (F.map inl) (F.map inr) where
pt := t.pt
π := t.π ≫ (diagramIsoCospan F).hom
#align category_theory.limits.pullback_cone.of_cone CategoryTheory.Limits.PullbackCone.ofCone
@[simps!]
def PullbackCone.isoMk {F : WalkingCospan ⥤ C} (t : Cone F) :
(Cones.postcompose (diagramIsoCospan.{v} _).hom).obj t ≅
PullbackCone.mk (t.π.app WalkingCospan.left) (t.π.app WalkingCospan.right)
((t.π.naturality inl).symm.trans (t.π.naturality inr : _)) :=
Cones.ext (Iso.refl _) <| by
rintro (_ | (_ | _)) <;>
· dsimp
simp
#align category_theory.limits.pullback_cone.iso_mk CategoryTheory.Limits.PullbackCone.isoMk
@[simps]
def PushoutCocone.ofCocone {F : WalkingSpan ⥤ C} (t : Cocone F) :
PushoutCocone (F.map fst) (F.map snd) where
pt := t.pt
ι := (diagramIsoSpan F).inv ≫ t.ι
#align category_theory.limits.pushout_cocone.of_cocone CategoryTheory.Limits.PushoutCocone.ofCocone
@[simps!]
def PushoutCocone.isoMk {F : WalkingSpan ⥤ C} (t : Cocone F) :
(Cocones.precompose (diagramIsoSpan.{v} _).inv).obj t ≅
PushoutCocone.mk (t.ι.app WalkingSpan.left) (t.ι.app WalkingSpan.right)
((t.ι.naturality fst).trans (t.ι.naturality snd).symm) :=
Cocones.ext (Iso.refl _) <| by
rintro (_ | (_ | _)) <;>
· dsimp
simp
#align category_theory.limits.pushout_cocone.iso_mk CategoryTheory.Limits.PushoutCocone.isoMk
abbrev HasPullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) :=
HasLimit (cospan f g)
#align category_theory.limits.has_pullback CategoryTheory.Limits.HasPullback
abbrev HasPushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) :=
HasColimit (span f g)
#align category_theory.limits.has_pushout CategoryTheory.Limits.HasPushout
abbrev pullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] :=
limit (cospan f g)
#align category_theory.limits.pullback CategoryTheory.Limits.pullback
abbrev pushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] :=
colimit (span f g)
#align category_theory.limits.pushout CategoryTheory.Limits.pushout
abbrev pullback.fst {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] : pullback f g ⟶ X :=
limit.π (cospan f g) WalkingCospan.left
#align category_theory.limits.pullback.fst CategoryTheory.Limits.pullback.fst
abbrev pullback.snd {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] : pullback f g ⟶ Y :=
limit.π (cospan f g) WalkingCospan.right
#align category_theory.limits.pullback.snd CategoryTheory.Limits.pullback.snd
abbrev pushout.inl {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] : Y ⟶ pushout f g :=
colimit.ι (span f g) WalkingSpan.left
#align category_theory.limits.pushout.inl CategoryTheory.Limits.pushout.inl
abbrev pushout.inr {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] : Z ⟶ pushout f g :=
colimit.ι (span f g) WalkingSpan.right
#align category_theory.limits.pushout.inr CategoryTheory.Limits.pushout.inr
abbrev pullback.lift {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : W ⟶ pullback f g :=
limit.lift _ (PullbackCone.mk h k w)
#align category_theory.limits.pullback.lift CategoryTheory.Limits.pullback.lift
abbrev pushout.desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W) (k : Z ⟶ W)
(w : f ≫ h = g ≫ k) : pushout f g ⟶ W :=
colimit.desc _ (PushoutCocone.mk h k w)
#align category_theory.limits.pushout.desc CategoryTheory.Limits.pushout.desc
@[simp]
theorem PullbackCone.fst_colimit_cocone {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
[HasLimit (cospan f g)] : PullbackCone.fst (limit.cone (cospan f g)) = pullback.fst := rfl
#align category_theory.limits.pullback_cone.fst_colimit_cocone CategoryTheory.Limits.PullbackCone.fst_colimit_cocone
@[simp]
theorem PullbackCone.snd_colimit_cocone {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
[HasLimit (cospan f g)] : PullbackCone.snd (limit.cone (cospan f g)) = pullback.snd := rfl
#align category_theory.limits.pullback_cone.snd_colimit_cocone CategoryTheory.Limits.PullbackCone.snd_colimit_cocone
-- Porting note (#10618): simp can prove this; removed simp
theorem PushoutCocone.inl_colimit_cocone {X Y Z : C} (f : Z ⟶ X) (g : Z ⟶ Y)
[HasColimit (span f g)] : PushoutCocone.inl (colimit.cocone (span f g)) = pushout.inl := rfl
#align category_theory.limits.pushout_cocone.inl_colimit_cocone CategoryTheory.Limits.PushoutCocone.inl_colimit_cocone
-- Porting note (#10618): simp can prove this; removed simp
theorem PushoutCocone.inr_colimit_cocone {X Y Z : C} (f : Z ⟶ X) (g : Z ⟶ Y)
[HasColimit (span f g)] : PushoutCocone.inr (colimit.cocone (span f g)) = pushout.inr := rfl
#align category_theory.limits.pushout_cocone.inr_colimit_cocone CategoryTheory.Limits.PushoutCocone.inr_colimit_cocone
-- Porting note (#10618): simp can prove this and reassoced version; removed simp
@[reassoc]
theorem pullback.lift_fst {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X)
(k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.fst = h :=
limit.lift_π _ _
#align category_theory.limits.pullback.lift_fst CategoryTheory.Limits.pullback.lift_fst
-- Porting note (#10618): simp can prove this and reassoced version; removed simp
@[reassoc]
theorem pullback.lift_snd {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X)
(k : W ⟶ Y) (w : h ≫ f = k ≫ g) : pullback.lift h k w ≫ pullback.snd = k :=
limit.lift_π _ _
#align category_theory.limits.pullback.lift_snd CategoryTheory.Limits.pullback.lift_snd
-- Porting note (#10618): simp can prove this and reassoced version; removed simp
@[reassoc]
theorem pushout.inl_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W)
(k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inl ≫ pushout.desc h k w = h :=
colimit.ι_desc _ _
#align category_theory.limits.pushout.inl_desc CategoryTheory.Limits.pushout.inl_desc
-- Porting note (#10618): simp can prove this and reassoced version; removed simp
@[reassoc]
theorem pushout.inr_desc {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W)
(k : Z ⟶ W) (w : f ≫ h = g ≫ k) : pushout.inr ≫ pushout.desc h k w = k :=
colimit.ι_desc _ _
#align category_theory.limits.pushout.inr_desc CategoryTheory.Limits.pushout.inr_desc
def pullback.lift' {W X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] (h : W ⟶ X) (k : W ⟶ Y)
(w : h ≫ f = k ≫ g) : { l : W ⟶ pullback f g // l ≫ pullback.fst = h ∧ l ≫ pullback.snd = k } :=
⟨pullback.lift h k w, pullback.lift_fst _ _ _, pullback.lift_snd _ _ _⟩
#align category_theory.limits.pullback.lift' CategoryTheory.Limits.pullback.lift'
def pullback.desc' {W X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] (h : Y ⟶ W) (k : Z ⟶ W)
(w : f ≫ h = g ≫ k) : { l : pushout f g ⟶ W // pushout.inl ≫ l = h ∧ pushout.inr ≫ l = k } :=
⟨pushout.desc h k w, pushout.inl_desc _ _ _, pushout.inr_desc _ _ _⟩
#align category_theory.limits.pullback.desc' CategoryTheory.Limits.pullback.desc'
@[reassoc]
theorem pullback.condition {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] :
(pullback.fst : pullback f g ⟶ X) ≫ f = pullback.snd ≫ g :=
PullbackCone.condition _
#align category_theory.limits.pullback.condition CategoryTheory.Limits.pullback.condition
@[reassoc]
theorem pushout.condition {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] :
f ≫ (pushout.inl : Y ⟶ pushout f g) = g ≫ pushout.inr :=
PushoutCocone.condition _
#align category_theory.limits.pushout.condition CategoryTheory.Limits.pushout.condition
abbrev pullback.map {W X Y Z S T : C} (f₁ : W ⟶ S) (f₂ : X ⟶ S) [HasPullback f₁ f₂] (g₁ : Y ⟶ T)
(g₂ : Z ⟶ T) [HasPullback g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)
(eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) : pullback f₁ f₂ ⟶ pullback g₁ g₂ :=
pullback.lift (pullback.fst ≫ i₁) (pullback.snd ≫ i₂)
(by simp [← eq₁, ← eq₂, pullback.condition_assoc])
#align category_theory.limits.pullback.map CategoryTheory.Limits.pullback.map
abbrev pullback.mapDesc {X Y S T : C} (f : X ⟶ S) (g : Y ⟶ S) (i : S ⟶ T) [HasPullback f g]
[HasPullback (f ≫ i) (g ≫ i)] : pullback f g ⟶ pullback (f ≫ i) (g ≫ i) :=
pullback.map f g (f ≫ i) (g ≫ i) (𝟙 _) (𝟙 _) i (Category.id_comp _).symm (Category.id_comp _).symm
#align category_theory.limits.pullback.map_desc CategoryTheory.Limits.pullback.mapDesc
abbrev pushout.map {W X Y Z S T : C} (f₁ : S ⟶ W) (f₂ : S ⟶ X) [HasPushout f₁ f₂] (g₁ : T ⟶ Y)
(g₂ : T ⟶ Z) [HasPushout g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T) (eq₁ : f₁ ≫ i₁ = i₃ ≫ g₁)
(eq₂ : f₂ ≫ i₂ = i₃ ≫ g₂) : pushout f₁ f₂ ⟶ pushout g₁ g₂ :=
pushout.desc (i₁ ≫ pushout.inl) (i₂ ≫ pushout.inr)
(by
simp only [← Category.assoc, eq₁, eq₂]
simp [pushout.condition])
#align category_theory.limits.pushout.map CategoryTheory.Limits.pushout.map
abbrev pushout.mapLift {X Y S T : C} (f : T ⟶ X) (g : T ⟶ Y) (i : S ⟶ T) [HasPushout f g]
[HasPushout (i ≫ f) (i ≫ g)] : pushout (i ≫ f) (i ≫ g) ⟶ pushout f g :=
pushout.map (i ≫ f) (i ≫ g) f g (𝟙 _) (𝟙 _) i (Category.comp_id _) (Category.comp_id _)
#align category_theory.limits.pushout.map_lift CategoryTheory.Limits.pushout.mapLift
@[ext 1100]
theorem pullback.hom_ext {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] {W : C}
{k l : W ⟶ pullback f g} (h₀ : k ≫ pullback.fst = l ≫ pullback.fst)
(h₁ : k ≫ pullback.snd = l ≫ pullback.snd) : k = l :=
limit.hom_ext <| PullbackCone.equalizer_ext _ h₀ h₁
#align category_theory.limits.pullback.hom_ext CategoryTheory.Limits.pullback.hom_ext
def pullbackIsPullback {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] :
IsLimit (PullbackCone.mk (pullback.fst : pullback f g ⟶ _) pullback.snd pullback.condition) :=
PullbackCone.IsLimit.mk _ (fun s => pullback.lift s.fst s.snd s.condition) (by simp) (by simp)
(by aesop_cat)
#align category_theory.limits.pullback_is_pullback CategoryTheory.Limits.pullbackIsPullback
instance pullback.fst_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] [Mono g] :
Mono (pullback.fst : pullback f g ⟶ X) :=
PullbackCone.mono_fst_of_is_pullback_of_mono (limit.isLimit _)
#align category_theory.limits.pullback.fst_of_mono CategoryTheory.Limits.pullback.fst_of_mono
instance pullback.snd_of_mono {X Y Z : C} {f : X ⟶ Z} {g : Y ⟶ Z} [HasPullback f g] [Mono f] :
Mono (pullback.snd : pullback f g ⟶ Y) :=
PullbackCone.mono_snd_of_is_pullback_of_mono (limit.isLimit _)
#align category_theory.limits.pullback.snd_of_mono CategoryTheory.Limits.pullback.snd_of_mono
instance mono_pullback_to_prod {C : Type*} [Category C] {X Y Z : C} (f : X ⟶ Z) (g : Y ⟶ Z)
[HasPullback f g] [HasBinaryProduct X Y] :
Mono (prod.lift pullback.fst pullback.snd : pullback f g ⟶ _) :=
⟨fun {W} i₁ i₂ h => by
ext
· simpa using congrArg (fun f => f ≫ prod.fst) h
· simpa using congrArg (fun f => f ≫ prod.snd) h⟩
#align category_theory.limits.mono_pullback_to_prod CategoryTheory.Limits.mono_pullback_to_prod
@[ext 1100]
theorem pushout.hom_ext {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] {W : C}
{k l : pushout f g ⟶ W} (h₀ : pushout.inl ≫ k = pushout.inl ≫ l)
(h₁ : pushout.inr ≫ k = pushout.inr ≫ l) : k = l :=
colimit.hom_ext <| PushoutCocone.coequalizer_ext _ h₀ h₁
#align category_theory.limits.pushout.hom_ext CategoryTheory.Limits.pushout.hom_ext
def pushoutIsPushout {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] :
IsColimit (PushoutCocone.mk (pushout.inl : _ ⟶ pushout f g) pushout.inr pushout.condition) :=
PushoutCocone.IsColimit.mk _ (fun s => pushout.desc s.inl s.inr s.condition) (by simp) (by simp)
(by aesop_cat)
#align category_theory.limits.pushout_is_pushout CategoryTheory.Limits.pushoutIsPushout
instance pushout.inl_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] [Epi g] :
Epi (pushout.inl : Y ⟶ pushout f g) :=
PushoutCocone.epi_inl_of_is_pushout_of_epi (colimit.isColimit _)
#align category_theory.limits.pushout.inl_of_epi CategoryTheory.Limits.pushout.inl_of_epi
instance pushout.inr_of_epi {X Y Z : C} {f : X ⟶ Y} {g : X ⟶ Z} [HasPushout f g] [Epi f] :
Epi (pushout.inr : Z ⟶ pushout f g) :=
PushoutCocone.epi_inr_of_is_pushout_of_epi (colimit.isColimit _)
#align category_theory.limits.pushout.inr_of_epi CategoryTheory.Limits.pushout.inr_of_epi
instance epi_coprod_to_pushout {C : Type*} [Category C] {X Y Z : C} (f : X ⟶ Y) (g : X ⟶ Z)
[HasPushout f g] [HasBinaryCoproduct Y Z] :
Epi (coprod.desc pushout.inl pushout.inr : _ ⟶ pushout f g) :=
⟨fun {W} i₁ i₂ h => by
ext
· simpa using congrArg (fun f => coprod.inl ≫ f) h
· simpa using congrArg (fun f => coprod.inr ≫ f) h⟩
#align category_theory.limits.epi_coprod_to_pushout CategoryTheory.Limits.epi_coprod_to_pushout
instance pullback.map_isIso {W X Y Z S T : C} (f₁ : W ⟶ S) (f₂ : X ⟶ S) [HasPullback f₁ f₂]
(g₁ : Y ⟶ T) (g₂ : Z ⟶ T) [HasPullback g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)
(eq₁ : f₁ ≫ i₃ = i₁ ≫ g₁) (eq₂ : f₂ ≫ i₃ = i₂ ≫ g₂) [IsIso i₁] [IsIso i₂] [IsIso i₃] :
IsIso (pullback.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by
refine ⟨⟨pullback.map _ _ _ _ (inv i₁) (inv i₂) (inv i₃) ?_ ?_, ?_, ?_⟩⟩
· rw [IsIso.comp_inv_eq, Category.assoc, eq₁, IsIso.inv_hom_id_assoc]
· rw [IsIso.comp_inv_eq, Category.assoc, eq₂, IsIso.inv_hom_id_assoc]
· aesop_cat
· aesop_cat
#align category_theory.limits.pullback.map_is_iso CategoryTheory.Limits.pullback.map_isIso
@[simps! hom]
def pullback.congrHom {X Y Z : C} {f₁ f₂ : X ⟶ Z} {g₁ g₂ : Y ⟶ Z} (h₁ : f₁ = f₂) (h₂ : g₁ = g₂)
[HasPullback f₁ g₁] [HasPullback f₂ g₂] : pullback f₁ g₁ ≅ pullback f₂ g₂ :=
asIso <| pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂])
#align category_theory.limits.pullback.congr_hom CategoryTheory.Limits.pullback.congrHom
@[simp]
theorem pullback.congrHom_inv {X Y Z : C} {f₁ f₂ : X ⟶ Z} {g₁ g₂ : Y ⟶ Z} (h₁ : f₁ = f₂)
(h₂ : g₁ = g₂) [HasPullback f₁ g₁] [HasPullback f₂ g₂] :
(pullback.congrHom h₁ h₂).inv =
pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂]) := by
ext
· erw [pullback.lift_fst]
rw [Iso.inv_comp_eq]
erw [pullback.lift_fst_assoc]
rw [Category.comp_id, Category.comp_id]
· erw [pullback.lift_snd]
rw [Iso.inv_comp_eq]
erw [pullback.lift_snd_assoc]
rw [Category.comp_id, Category.comp_id]
#align category_theory.limits.pullback.congr_hom_inv CategoryTheory.Limits.pullback.congrHom_inv
instance pushout.map_isIso {W X Y Z S T : C} (f₁ : S ⟶ W) (f₂ : S ⟶ X) [HasPushout f₁ f₂]
(g₁ : T ⟶ Y) (g₂ : T ⟶ Z) [HasPushout g₁ g₂] (i₁ : W ⟶ Y) (i₂ : X ⟶ Z) (i₃ : S ⟶ T)
(eq₁ : f₁ ≫ i₁ = i₃ ≫ g₁) (eq₂ : f₂ ≫ i₂ = i₃ ≫ g₂) [IsIso i₁] [IsIso i₂] [IsIso i₃] :
IsIso (pushout.map f₁ f₂ g₁ g₂ i₁ i₂ i₃ eq₁ eq₂) := by
refine ⟨⟨pushout.map _ _ _ _ (inv i₁) (inv i₂) (inv i₃) ?_ ?_, ?_, ?_⟩⟩
· rw [IsIso.comp_inv_eq, Category.assoc, eq₁, IsIso.inv_hom_id_assoc]
· rw [IsIso.comp_inv_eq, Category.assoc, eq₂, IsIso.inv_hom_id_assoc]
· aesop_cat
· aesop_cat
#align category_theory.limits.pushout.map_is_iso CategoryTheory.Limits.pushout.map_isIso
theorem pullback.mapDesc_comp {X Y S T S' : C} (f : X ⟶ T) (g : Y ⟶ T) (i : T ⟶ S) (i' : S ⟶ S')
[HasPullback f g] [HasPullback (f ≫ i) (g ≫ i)] [HasPullback (f ≫ i ≫ i') (g ≫ i ≫ i')]
[HasPullback ((f ≫ i) ≫ i') ((g ≫ i) ≫ i')] :
pullback.mapDesc f g (i ≫ i') = pullback.mapDesc f g i ≫ pullback.mapDesc _ _ i' ≫
(pullback.congrHom (Category.assoc _ _ _) (Category.assoc _ _ _)).hom := by
aesop_cat
#align category_theory.limits.pullback.map_desc_comp CategoryTheory.Limits.pullback.mapDesc_comp
@[simps! hom]
def pushout.congrHom {X Y Z : C} {f₁ f₂ : X ⟶ Y} {g₁ g₂ : X ⟶ Z} (h₁ : f₁ = f₂) (h₂ : g₁ = g₂)
[HasPushout f₁ g₁] [HasPushout f₂ g₂] : pushout f₁ g₁ ≅ pushout f₂ g₂ :=
asIso <| pushout.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂])
#align category_theory.limits.pushout.congr_hom CategoryTheory.Limits.pushout.congrHom
@[simp]
theorem pushout.congrHom_inv {X Y Z : C} {f₁ f₂ : X ⟶ Y} {g₁ g₂ : X ⟶ Z} (h₁ : f₁ = f₂)
(h₂ : g₁ = g₂) [HasPushout f₁ g₁] [HasPushout f₂ g₂] :
(pushout.congrHom h₁ h₂).inv =
pushout.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simp [h₁]) (by simp [h₂]) := by
ext
· erw [pushout.inl_desc]
rw [Iso.comp_inv_eq, Category.id_comp]
erw [pushout.inl_desc]
rw [Category.id_comp]
· erw [pushout.inr_desc]
rw [Iso.comp_inv_eq, Category.id_comp]
erw [pushout.inr_desc]
rw [Category.id_comp]
#align category_theory.limits.pushout.congr_hom_inv CategoryTheory.Limits.pushout.congrHom_inv
theorem pushout.mapLift_comp {X Y S T S' : C} (f : T ⟶ X) (g : T ⟶ Y) (i : S ⟶ T) (i' : S' ⟶ S)
[HasPushout f g] [HasPushout (i ≫ f) (i ≫ g)] [HasPushout (i' ≫ i ≫ f) (i' ≫ i ≫ g)]
[HasPushout ((i' ≫ i) ≫ f) ((i' ≫ i) ≫ g)] :
pushout.mapLift f g (i' ≫ i) =
(pushout.congrHom (Category.assoc _ _ _) (Category.assoc _ _ _)).hom ≫
pushout.mapLift _ _ i' ≫ pushout.mapLift f g i := by
aesop_cat
#align category_theory.limits.pushout.map_lift_comp CategoryTheory.Limits.pushout.mapLift_comp
section
variable (G : C ⥤ D)
def pullbackComparison (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g] [HasPullback (G.map f) (G.map g)] :
G.obj (pullback f g) ⟶ pullback (G.map f) (G.map g) :=
pullback.lift (G.map pullback.fst) (G.map pullback.snd)
(by simp only [← G.map_comp, pullback.condition])
#align category_theory.limits.pullback_comparison CategoryTheory.Limits.pullbackComparison
@[reassoc (attr := simp)]
theorem pullbackComparison_comp_fst (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]
[HasPullback (G.map f) (G.map g)] :
pullbackComparison G f g ≫ pullback.fst = G.map pullback.fst :=
pullback.lift_fst _ _ _
#align category_theory.limits.pullback_comparison_comp_fst CategoryTheory.Limits.pullbackComparison_comp_fst
@[reassoc (attr := simp)]
theorem pullbackComparison_comp_snd (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]
[HasPullback (G.map f) (G.map g)] :
pullbackComparison G f g ≫ pullback.snd = G.map pullback.snd :=
pullback.lift_snd _ _ _
#align category_theory.limits.pullback_comparison_comp_snd CategoryTheory.Limits.pullbackComparison_comp_snd
@[reassoc (attr := simp)]
theorem map_lift_pullbackComparison (f : X ⟶ Z) (g : Y ⟶ Z) [HasPullback f g]
[HasPullback (G.map f) (G.map g)] {W : C} {h : W ⟶ X} {k : W ⟶ Y} (w : h ≫ f = k ≫ g) :
G.map (pullback.lift _ _ w) ≫ pullbackComparison G f g =
pullback.lift (G.map h) (G.map k) (by simp only [← G.map_comp, w]) := by
ext <;> simp [← G.map_comp]
#align category_theory.limits.map_lift_pullback_comparison CategoryTheory.Limits.map_lift_pullbackComparison
def pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g] [HasPushout (G.map f) (G.map g)] :
pushout (G.map f) (G.map g) ⟶ G.obj (pushout f g) :=
pushout.desc (G.map pushout.inl) (G.map pushout.inr)
(by simp only [← G.map_comp, pushout.condition])
#align category_theory.limits.pushout_comparison CategoryTheory.Limits.pushoutComparison
@[reassoc (attr := simp)]
theorem inl_comp_pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]
[HasPushout (G.map f) (G.map g)] : pushout.inl ≫ pushoutComparison G f g = G.map pushout.inl :=
pushout.inl_desc _ _ _
#align category_theory.limits.inl_comp_pushout_comparison CategoryTheory.Limits.inl_comp_pushoutComparison
@[reassoc (attr := simp)]
theorem inr_comp_pushoutComparison (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]
[HasPushout (G.map f) (G.map g)] : pushout.inr ≫ pushoutComparison G f g = G.map pushout.inr :=
pushout.inr_desc _ _ _
#align category_theory.limits.inr_comp_pushout_comparison CategoryTheory.Limits.inr_comp_pushoutComparison
@[reassoc (attr := simp)]
theorem pushoutComparison_map_desc (f : X ⟶ Y) (g : X ⟶ Z) [HasPushout f g]
[HasPushout (G.map f) (G.map g)] {W : C} {h : Y ⟶ W} {k : Z ⟶ W} (w : f ≫ h = g ≫ k) :
pushoutComparison G f g ≫ G.map (pushout.desc _ _ w) =
pushout.desc (G.map h) (G.map k) (by simp only [← G.map_comp, w]) := by
ext <;> simp [← G.map_comp]
#align category_theory.limits.pushout_comparison_map_desc CategoryTheory.Limits.pushoutComparison_map_desc
end
section
open WalkingCospan
variable (f : X ⟶ Y)
instance has_kernel_pair_of_mono [Mono f] : HasPullback f f :=
⟨⟨⟨_, PullbackCone.isLimitMkIdId f⟩⟩⟩
#align category_theory.limits.has_kernel_pair_of_mono CategoryTheory.Limits.has_kernel_pair_of_mono
theorem fst_eq_snd_of_mono_eq [Mono f] : (pullback.fst : pullback f f ⟶ _) = pullback.snd :=
((PullbackCone.isLimitMkIdId f).fac (getLimitCone (cospan f f)).cone left).symm.trans
((PullbackCone.isLimitMkIdId f).fac (getLimitCone (cospan f f)).cone right : _)
#align category_theory.limits.fst_eq_snd_of_mono_eq CategoryTheory.Limits.fst_eq_snd_of_mono_eq
@[simp]
theorem pullbackSymmetry_hom_of_mono_eq [Mono f] : (pullbackSymmetry f f).hom = 𝟙 _ := by
ext
· simp [fst_eq_snd_of_mono_eq]
· simp [fst_eq_snd_of_mono_eq]
#align category_theory.limits.pullback_symmetry_hom_of_mono_eq CategoryTheory.Limits.pullbackSymmetry_hom_of_mono_eq
instance fst_iso_of_mono_eq [Mono f] : IsIso (pullback.fst : pullback f f ⟶ _) := by
refine ⟨⟨pullback.lift (𝟙 _) (𝟙 _) (by simp), ?_, by simp⟩⟩
ext
· simp
· simp [fst_eq_snd_of_mono_eq]
#align category_theory.limits.fst_iso_of_mono_eq CategoryTheory.Limits.fst_iso_of_mono_eq
instance snd_iso_of_mono_eq [Mono f] : IsIso (pullback.snd : pullback f f ⟶ _) := by
rw [← fst_eq_snd_of_mono_eq]
infer_instance
#align category_theory.limits.snd_iso_of_mono_eq CategoryTheory.Limits.snd_iso_of_mono_eq
end
section
open WalkingSpan
variable (f : X ⟶ Y)
instance has_cokernel_pair_of_epi [Epi f] : HasPushout f f :=
⟨⟨⟨_, PushoutCocone.isColimitMkIdId f⟩⟩⟩
#align category_theory.limits.has_cokernel_pair_of_epi CategoryTheory.Limits.has_cokernel_pair_of_epi
theorem inl_eq_inr_of_epi_eq [Epi f] : (pushout.inl : _ ⟶ pushout f f) = pushout.inr :=
((PushoutCocone.isColimitMkIdId f).fac (getColimitCocone (span f f)).cocone left).symm.trans
((PushoutCocone.isColimitMkIdId f).fac (getColimitCocone (span f f)).cocone right : _)
#align category_theory.limits.inl_eq_inr_of_epi_eq CategoryTheory.Limits.inl_eq_inr_of_epi_eq
@[simp]
theorem pullback_symmetry_hom_of_epi_eq [Epi f] : (pushoutSymmetry f f).hom = 𝟙 _ := by
ext <;> simp [inl_eq_inr_of_epi_eq]
#align category_theory.limits.pullback_symmetry_hom_of_epi_eq CategoryTheory.Limits.pullback_symmetry_hom_of_epi_eq
instance inl_iso_of_epi_eq [Epi f] : IsIso (pushout.inl : _ ⟶ pushout f f) := by
refine ⟨⟨pushout.desc (𝟙 _) (𝟙 _) (by simp), by simp, ?_⟩⟩
apply pushout.hom_ext
· simp
· simp [inl_eq_inr_of_epi_eq]
#align category_theory.limits.inl_iso_of_epi_eq CategoryTheory.Limits.inl_iso_of_epi_eq
instance inr_iso_of_epi_eq [Epi f] : IsIso (pushout.inr : _ ⟶ pushout f f) := by
rw [← inl_eq_inr_of_epi_eq]
infer_instance
#align category_theory.limits.inr_iso_of_epi_eq CategoryTheory.Limits.inr_iso_of_epi_eq
end
section
variable (f : X ⟶ Z) (g : Y ⟶ Z) (f' : W ⟶ X)
variable [HasPullback f g] [HasPullback f' (pullback.fst : pullback f g ⟶ _)]
variable [HasPullback (f' ≫ f) g]
noncomputable def pullbackRightPullbackFstIso :
pullback f' (pullback.fst : pullback f g ⟶ _) ≅ pullback (f' ≫ f) g := by
let this :=
bigSquareIsPullback (pullback.snd : pullback f' (pullback.fst : pullback f g ⟶ _) ⟶ _)
pullback.snd f' f pullback.fst pullback.fst g pullback.condition pullback.condition
(pullbackIsPullback _ _) (pullbackIsPullback _ _)
exact (this.conePointUniqueUpToIso (pullbackIsPullback _ _) : _)
#align category_theory.limits.pullback_right_pullback_fst_iso CategoryTheory.Limits.pullbackRightPullbackFstIso
@[reassoc (attr := simp)]
theorem pullbackRightPullbackFstIso_hom_fst :
(pullbackRightPullbackFstIso f g f').hom ≫ pullback.fst = pullback.fst :=
IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.left
#align category_theory.limits.pullback_right_pullback_fst_iso_hom_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_hom_fst
@[reassoc (attr := simp)]
theorem pullbackRightPullbackFstIso_hom_snd :
(pullbackRightPullbackFstIso f g f').hom ≫ pullback.snd = pullback.snd ≫ pullback.snd :=
IsLimit.conePointUniqueUpToIso_hom_comp _ _ WalkingCospan.right
#align category_theory.limits.pullback_right_pullback_fst_iso_hom_snd CategoryTheory.Limits.pullbackRightPullbackFstIso_hom_snd
@[reassoc (attr := simp)]
theorem pullbackRightPullbackFstIso_inv_fst :
(pullbackRightPullbackFstIso f g f').inv ≫ pullback.fst = pullback.fst :=
IsLimit.conePointUniqueUpToIso_inv_comp _ _ WalkingCospan.left
#align category_theory.limits.pullback_right_pullback_fst_iso_inv_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_fst
@[reassoc (attr := simp)]
theorem pullbackRightPullbackFstIso_inv_snd_snd :
(pullbackRightPullbackFstIso f g f').inv ≫ pullback.snd ≫ pullback.snd = pullback.snd :=
IsLimit.conePointUniqueUpToIso_inv_comp _ _ WalkingCospan.right
#align category_theory.limits.pullback_right_pullback_fst_iso_inv_snd_snd CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_snd_snd
@[reassoc (attr := simp)]
theorem pullbackRightPullbackFstIso_inv_snd_fst :
(pullbackRightPullbackFstIso f g f').inv ≫ pullback.snd ≫ pullback.fst = pullback.fst ≫ f' := by
rw [← pullback.condition]
exact pullbackRightPullbackFstIso_inv_fst_assoc _ _ _ _
#align category_theory.limits.pullback_right_pullback_fst_iso_inv_snd_fst CategoryTheory.Limits.pullbackRightPullbackFstIso_inv_snd_fst
end
section
variable (f : X ⟶ Y) (g : X ⟶ Z) (g' : Z ⟶ W)
variable [HasPushout f g] [HasPushout (pushout.inr : _ ⟶ pushout f g) g']
variable [HasPushout f (g ≫ g')]
noncomputable def pushoutLeftPushoutInrIso :
pushout (pushout.inr : _ ⟶ pushout f g) g' ≅ pushout f (g ≫ g') :=
((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)
(pushoutIsPushout _ _)).coconePointUniqueUpToIso
(pushoutIsPushout _ _) :
_)
#align category_theory.limits.pushout_left_pushout_inr_iso CategoryTheory.Limits.pushoutLeftPushoutInrIso
@[reassoc (attr := simp)]
theorem inl_pushoutLeftPushoutInrIso_inv :
pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').inv = pushout.inl ≫ pushout.inl :=
((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)
(pushoutIsPushout _ _)).comp_coconePointUniqueUpToIso_inv
(pushoutIsPushout _ _) WalkingSpan.left :
_)
#align category_theory.limits.inl_pushout_left_pushout_inr_iso_inv CategoryTheory.Limits.inl_pushoutLeftPushoutInrIso_inv
@[reassoc (attr := simp)]
theorem inr_pushoutLeftPushoutInrIso_hom :
pushout.inr ≫ (pushoutLeftPushoutInrIso f g g').hom = pushout.inr :=
((bigSquareIsPushout g g' _ _ f _ _ pushout.condition pushout.condition (pushoutIsPushout _ _)
(pushoutIsPushout _ _)).comp_coconePointUniqueUpToIso_hom
(pushoutIsPushout _ _) WalkingSpan.right :
_)
#align category_theory.limits.inr_pushout_left_pushout_inr_iso_hom CategoryTheory.Limits.inr_pushoutLeftPushoutInrIso_hom
@[reassoc (attr := simp)]
theorem inr_pushoutLeftPushoutInrIso_inv :
pushout.inr ≫ (pushoutLeftPushoutInrIso f g g').inv = pushout.inr := by
rw [Iso.comp_inv_eq, inr_pushoutLeftPushoutInrIso_hom]
#align category_theory.limits.inr_pushout_left_pushout_inr_iso_inv CategoryTheory.Limits.inr_pushoutLeftPushoutInrIso_inv
@[reassoc (attr := simp)]
theorem inl_inl_pushoutLeftPushoutInrIso_hom :
pushout.inl ≫ pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').hom = pushout.inl := by
rw [← Category.assoc, ← Iso.eq_comp_inv, inl_pushoutLeftPushoutInrIso_inv]
#align category_theory.limits.inl_inl_pushout_left_pushout_inr_iso_hom CategoryTheory.Limits.inl_inl_pushoutLeftPushoutInrIso_hom
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Pullbacks.lean | 2,273 | 2,276 | theorem inr_inl_pushoutLeftPushoutInrIso_hom :
pushout.inr ≫ pushout.inl ≫ (pushoutLeftPushoutInrIso f g g').hom = g' ≫ pushout.inr := by |
rw [← Category.assoc, ← Iso.eq_comp_inv, Category.assoc, inr_pushoutLeftPushoutInrIso_inv,
pushout.condition]
|
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Matrix.Notation
import Mathlib.LinearAlgebra.StdBasis
import Mathlib.RingTheory.AlgebraTower
import Mathlib.Algebra.Algebra.Subalgebra.Tower
#align_import linear_algebra.matrix.to_lin from "leanprover-community/mathlib"@"0e2aab2b0d521f060f62a14d2cf2e2c54e8491d6"
noncomputable section
open LinearMap Matrix Set Submodule
section ToMatrix
variable {R : Type*} [CommSemiring R]
variable {l m n : Type*} [Fintype n] [Fintype m] [DecidableEq n]
variable {M₁ M₂ : Type*} [AddCommMonoid M₁] [AddCommMonoid M₂] [Module R M₁] [Module R M₂]
variable (v₁ : Basis n R M₁) (v₂ : Basis m R M₂)
theorem Matrix.toLin_apply (M : Matrix m n R) (v : M₁) :
Matrix.toLin v₁ v₂ M v = ∑ j, (M *ᵥ v₁.repr v) j • v₂ j :=
show v₂.equivFun.symm (Matrix.toLin' M (v₁.repr v)) = _ by
rw [Matrix.toLin'_apply, v₂.equivFun_symm_apply]
#align matrix.to_lin_apply Matrix.toLin_apply
@[simp]
theorem Matrix.toLin_self (M : Matrix m n R) (i : n) :
Matrix.toLin v₁ v₂ M (v₁ i) = ∑ j, M j i • v₂ j := by
rw [Matrix.toLin_apply, Finset.sum_congr rfl fun j _hj ↦ ?_]
rw [Basis.repr_self, Matrix.mulVec, dotProduct, Finset.sum_eq_single i, Finsupp.single_eq_same,
mul_one]
· intro i' _ i'_ne
rw [Finsupp.single_eq_of_ne i'_ne.symm, mul_zero]
· intros
have := Finset.mem_univ i
contradiction
#align matrix.to_lin_self Matrix.toLin_self
variable {M₃ : Type*} [AddCommMonoid M₃] [Module R M₃] (v₃ : Basis l R M₃)
theorem LinearMap.toMatrix_comp [Finite l] [DecidableEq m] (f : M₂ →ₗ[R] M₃) (g : M₁ →ₗ[R] M₂) :
LinearMap.toMatrix v₁ v₃ (f.comp g) =
LinearMap.toMatrix v₂ v₃ f * LinearMap.toMatrix v₁ v₂ g := by
simp_rw [LinearMap.toMatrix, LinearEquiv.trans_apply, LinearEquiv.arrowCongr_comp _ v₂.equivFun,
LinearMap.toMatrix'_comp]
#align linear_map.to_matrix_comp LinearMap.toMatrix_comp
theorem LinearMap.toMatrix_mul (f g : M₁ →ₗ[R] M₁) :
LinearMap.toMatrix v₁ v₁ (f * g) = LinearMap.toMatrix v₁ v₁ f * LinearMap.toMatrix v₁ v₁ g := by
rw [LinearMap.mul_eq_comp, LinearMap.toMatrix_comp v₁ v₁ v₁ f g]
#align linear_map.to_matrix_mul LinearMap.toMatrix_mul
lemma LinearMap.toMatrix_pow (f : M₁ →ₗ[R] M₁) (k : ℕ) :
(toMatrix v₁ v₁ f) ^ k = toMatrix v₁ v₁ (f ^ k) := by
induction k with
| zero => simp
| succ k ih => rw [pow_succ, pow_succ, ih, ← toMatrix_mul]
theorem Matrix.toLin_mul [Finite l] [DecidableEq m] (A : Matrix l m R) (B : Matrix m n R) :
Matrix.toLin v₁ v₃ (A * B) = (Matrix.toLin v₂ v₃ A).comp (Matrix.toLin v₁ v₂ B) := by
apply (LinearMap.toMatrix v₁ v₃).injective
haveI : DecidableEq l := fun _ _ ↦ Classical.propDecidable _
rw [LinearMap.toMatrix_comp v₁ v₂ v₃]
repeat' rw [LinearMap.toMatrix_toLin]
#align matrix.to_lin_mul Matrix.toLin_mul
theorem Matrix.toLin_mul_apply [Finite l] [DecidableEq m] (A : Matrix l m R) (B : Matrix m n R)
(x) : Matrix.toLin v₁ v₃ (A * B) x = (Matrix.toLin v₂ v₃ A) (Matrix.toLin v₁ v₂ B x) := by
rw [Matrix.toLin_mul v₁ v₂, LinearMap.comp_apply]
#align matrix.to_lin_mul_apply Matrix.toLin_mul_apply
@[simps]
def Matrix.toLinOfInv [DecidableEq m] {M : Matrix m n R} {M' : Matrix n m R} (hMM' : M * M' = 1)
(hM'M : M' * M = 1) : M₁ ≃ₗ[R] M₂ :=
{ Matrix.toLin v₁ v₂ M with
toFun := Matrix.toLin v₁ v₂ M
invFun := Matrix.toLin v₂ v₁ M'
left_inv := fun x ↦ by rw [← Matrix.toLin_mul_apply, hM'M, Matrix.toLin_one, id_apply]
right_inv := fun x ↦ by
simp only
rw [← Matrix.toLin_mul_apply, hMM', Matrix.toLin_one, id_apply] }
#align matrix.to_lin_of_inv Matrix.toLinOfInv
def LinearMap.toMatrixAlgEquiv : (M₁ →ₗ[R] M₁) ≃ₐ[R] Matrix n n R :=
AlgEquiv.ofLinearEquiv
(LinearMap.toMatrix v₁ v₁) (LinearMap.toMatrix_one v₁) (LinearMap.toMatrix_mul v₁)
#align linear_map.to_matrix_alg_equiv LinearMap.toMatrixAlgEquiv
def Matrix.toLinAlgEquiv : Matrix n n R ≃ₐ[R] M₁ →ₗ[R] M₁ :=
(LinearMap.toMatrixAlgEquiv v₁).symm
#align matrix.to_lin_alg_equiv Matrix.toLinAlgEquiv
@[simp]
theorem LinearMap.toMatrixAlgEquiv_symm :
(LinearMap.toMatrixAlgEquiv v₁).symm = Matrix.toLinAlgEquiv v₁ :=
rfl
#align linear_map.to_matrix_alg_equiv_symm LinearMap.toMatrixAlgEquiv_symm
@[simp]
theorem Matrix.toLinAlgEquiv_symm :
(Matrix.toLinAlgEquiv v₁).symm = LinearMap.toMatrixAlgEquiv v₁ :=
rfl
#align matrix.to_lin_alg_equiv_symm Matrix.toLinAlgEquiv_symm
@[simp]
theorem Matrix.toLinAlgEquiv_toMatrixAlgEquiv (f : M₁ →ₗ[R] M₁) :
Matrix.toLinAlgEquiv v₁ (LinearMap.toMatrixAlgEquiv v₁ f) = f := by
rw [← Matrix.toLinAlgEquiv_symm, AlgEquiv.apply_symm_apply]
#align matrix.to_lin_alg_equiv_to_matrix_alg_equiv Matrix.toLinAlgEquiv_toMatrixAlgEquiv
@[simp]
theorem LinearMap.toMatrixAlgEquiv_toLinAlgEquiv (M : Matrix n n R) :
LinearMap.toMatrixAlgEquiv v₁ (Matrix.toLinAlgEquiv v₁ M) = M := by
rw [← Matrix.toLinAlgEquiv_symm, AlgEquiv.symm_apply_apply]
#align linear_map.to_matrix_alg_equiv_to_lin_alg_equiv LinearMap.toMatrixAlgEquiv_toLinAlgEquiv
theorem LinearMap.toMatrixAlgEquiv_apply (f : M₁ →ₗ[R] M₁) (i j : n) :
LinearMap.toMatrixAlgEquiv v₁ f i j = v₁.repr (f (v₁ j)) i := by
simp [LinearMap.toMatrixAlgEquiv, LinearMap.toMatrix_apply]
#align linear_map.to_matrix_alg_equiv_apply LinearMap.toMatrixAlgEquiv_apply
theorem LinearMap.toMatrixAlgEquiv_transpose_apply (f : M₁ →ₗ[R] M₁) (j : n) :
(LinearMap.toMatrixAlgEquiv v₁ f)ᵀ j = v₁.repr (f (v₁ j)) :=
funext fun i ↦ f.toMatrix_apply _ _ i j
#align linear_map.to_matrix_alg_equiv_transpose_apply LinearMap.toMatrixAlgEquiv_transpose_apply
theorem LinearMap.toMatrixAlgEquiv_apply' (f : M₁ →ₗ[R] M₁) (i j : n) :
LinearMap.toMatrixAlgEquiv v₁ f i j = v₁.repr (f (v₁ j)) i :=
LinearMap.toMatrixAlgEquiv_apply v₁ f i j
#align linear_map.to_matrix_alg_equiv_apply' LinearMap.toMatrixAlgEquiv_apply'
theorem LinearMap.toMatrixAlgEquiv_transpose_apply' (f : M₁ →ₗ[R] M₁) (j : n) :
(LinearMap.toMatrixAlgEquiv v₁ f)ᵀ j = v₁.repr (f (v₁ j)) :=
LinearMap.toMatrixAlgEquiv_transpose_apply v₁ f j
#align linear_map.to_matrix_alg_equiv_transpose_apply' LinearMap.toMatrixAlgEquiv_transpose_apply'
theorem Matrix.toLinAlgEquiv_apply (M : Matrix n n R) (v : M₁) :
Matrix.toLinAlgEquiv v₁ M v = ∑ j, (M *ᵥ v₁.repr v) j • v₁ j :=
show v₁.equivFun.symm (Matrix.toLinAlgEquiv' M (v₁.repr v)) = _ by
rw [Matrix.toLinAlgEquiv'_apply, v₁.equivFun_symm_apply]
#align matrix.to_lin_alg_equiv_apply Matrix.toLinAlgEquiv_apply
@[simp]
theorem Matrix.toLinAlgEquiv_self (M : Matrix n n R) (i : n) :
Matrix.toLinAlgEquiv v₁ M (v₁ i) = ∑ j, M j i • v₁ j :=
Matrix.toLin_self _ _ _ _
#align matrix.to_lin_alg_equiv_self Matrix.toLinAlgEquiv_self
theorem LinearMap.toMatrixAlgEquiv_id : LinearMap.toMatrixAlgEquiv v₁ id = 1 := by
simp_rw [LinearMap.toMatrixAlgEquiv, AlgEquiv.ofLinearEquiv_apply, LinearMap.toMatrix_id]
#align linear_map.to_matrix_alg_equiv_id LinearMap.toMatrixAlgEquiv_id
-- Porting note: the simpNF linter rejects this, as `simp` already simplifies the lhs
-- to `(1 : M₁ →ₗ[R] M₁)`.
-- @[simp]
theorem Matrix.toLinAlgEquiv_one : Matrix.toLinAlgEquiv v₁ 1 = LinearMap.id := by
rw [← LinearMap.toMatrixAlgEquiv_id v₁, Matrix.toLinAlgEquiv_toMatrixAlgEquiv]
#align matrix.to_lin_alg_equiv_one Matrix.toLinAlgEquiv_one
theorem LinearMap.toMatrixAlgEquiv_reindexRange [DecidableEq M₁] (f : M₁ →ₗ[R] M₁) (k i : n) :
LinearMap.toMatrixAlgEquiv v₁.reindexRange f
⟨v₁ k, Set.mem_range_self k⟩ ⟨v₁ i, Set.mem_range_self i⟩ =
LinearMap.toMatrixAlgEquiv v₁ f k i := by
simp_rw [LinearMap.toMatrixAlgEquiv_apply, Basis.reindexRange_self, Basis.reindexRange_repr]
#align linear_map.to_matrix_alg_equiv_reindex_range LinearMap.toMatrixAlgEquiv_reindexRange
theorem LinearMap.toMatrixAlgEquiv_comp (f g : M₁ →ₗ[R] M₁) :
LinearMap.toMatrixAlgEquiv v₁ (f.comp g) =
LinearMap.toMatrixAlgEquiv v₁ f * LinearMap.toMatrixAlgEquiv v₁ g := by
simp [LinearMap.toMatrixAlgEquiv, LinearMap.toMatrix_comp v₁ v₁ v₁ f g]
#align linear_map.to_matrix_alg_equiv_comp LinearMap.toMatrixAlgEquiv_comp
theorem LinearMap.toMatrixAlgEquiv_mul (f g : M₁ →ₗ[R] M₁) :
LinearMap.toMatrixAlgEquiv v₁ (f * g) =
LinearMap.toMatrixAlgEquiv v₁ f * LinearMap.toMatrixAlgEquiv v₁ g := by
rw [LinearMap.mul_eq_comp, LinearMap.toMatrixAlgEquiv_comp v₁ f g]
#align linear_map.to_matrix_alg_equiv_mul LinearMap.toMatrixAlgEquiv_mul
| Mathlib/LinearAlgebra/Matrix/ToLin.lean | 839 | 842 | theorem Matrix.toLinAlgEquiv_mul (A B : Matrix n n R) :
Matrix.toLinAlgEquiv v₁ (A * B) =
(Matrix.toLinAlgEquiv v₁ A).comp (Matrix.toLinAlgEquiv v₁ B) := by |
convert Matrix.toLin_mul v₁ v₁ v₁ A B
|
import Mathlib.NumberTheory.Divisors
import Mathlib.Data.Nat.Digits
import Mathlib.Data.Nat.MaxPowDiv
import Mathlib.Data.Nat.Multiplicity
import Mathlib.Tactic.IntervalCases
#align_import number_theory.padics.padic_val from "leanprover-community/mathlib"@"60fa54e778c9e85d930efae172435f42fb0d71f7"
universe u
open Nat
open Rat
open multiplicity
def padicValNat (p : ℕ) (n : ℕ) : ℕ :=
if h : p ≠ 1 ∧ 0 < n then (multiplicity p n).get (multiplicity.finite_nat_iff.2 h) else 0
#align padic_val_nat padicValNat
namespace padicValNat
open multiplicity
variable {p : ℕ}
@[simp]
protected theorem zero : padicValNat p 0 = 0 := by simp [padicValNat]
#align padic_val_nat.zero padicValNat.zero
@[simp]
protected theorem one : padicValNat p 1 = 0 := by
unfold padicValNat
split_ifs
· simp
· rfl
#align padic_val_nat.one padicValNat.one
@[simp]
theorem self (hp : 1 < p) : padicValNat p p = 1 := by
have neq_one : ¬p = 1 ↔ True := iff_of_true hp.ne' trivial
have eq_zero_false : p = 0 ↔ False := iff_false_intro (zero_lt_one.trans hp).ne'
simp [padicValNat, neq_one, eq_zero_false]
#align padic_val_nat.self padicValNat.self
@[simp]
theorem eq_zero_iff {n : ℕ} : padicValNat p n = 0 ↔ p = 1 ∨ n = 0 ∨ ¬p ∣ n := by
simp only [padicValNat, dite_eq_right_iff, PartENat.get_eq_iff_eq_coe, Nat.cast_zero,
multiplicity_eq_zero, and_imp, pos_iff_ne_zero, Ne, ← or_iff_not_imp_left]
#align padic_val_nat.eq_zero_iff padicValNat.eq_zero_iff
theorem eq_zero_of_not_dvd {n : ℕ} (h : ¬p ∣ n) : padicValNat p n = 0 :=
eq_zero_iff.2 <| Or.inr <| Or.inr h
#align padic_val_nat.eq_zero_of_not_dvd padicValNat.eq_zero_of_not_dvd
open Nat.maxPowDiv
theorem maxPowDiv_eq_multiplicity {p n : ℕ} (hp : 1 < p) (hn : 0 < n) :
p.maxPowDiv n = multiplicity p n := by
apply multiplicity.unique <| pow_dvd p n
intro h
apply Nat.not_lt.mpr <| le_of_dvd hp hn h
simp
theorem maxPowDiv_eq_multiplicity_get {p n : ℕ} (hp : 1 < p) (hn : 0 < n) (h : Finite p n) :
p.maxPowDiv n = (multiplicity p n).get h := by
rw [PartENat.get_eq_iff_eq_coe.mpr]
apply maxPowDiv_eq_multiplicity hp hn|>.symm
@[csimp]
theorem padicValNat_eq_maxPowDiv : @padicValNat = @maxPowDiv := by
ext p n
by_cases h : 1 < p ∧ 0 < n
· dsimp [padicValNat]
rw [dif_pos ⟨Nat.ne_of_gt h.1,h.2⟩, maxPowDiv_eq_multiplicity_get h.1 h.2]
· simp only [not_and_or,not_gt_eq,Nat.le_zero] at h
apply h.elim
· intro h
interval_cases p
· simp [Classical.em]
· dsimp [padicValNat, maxPowDiv]
rw [go, if_neg, dif_neg] <;> simp
· intro h
simp [h]
end padicValNat
def padicValInt (p : ℕ) (z : ℤ) : ℕ :=
padicValNat p z.natAbs
#align padic_val_int padicValInt
namespace padicValInt
open multiplicity
variable {p : ℕ}
theorem of_ne_one_ne_zero {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
padicValInt p z =
(multiplicity (p : ℤ) z).get
(by
apply multiplicity.finite_int_iff.2
simp [hp, hz]) := by
rw [padicValInt, padicValNat, dif_pos (And.intro hp (Int.natAbs_pos.mpr hz))]
simp only [multiplicity.Int.natAbs p z]
#align padic_val_int.of_ne_one_ne_zero padicValInt.of_ne_one_ne_zero
@[simp]
protected theorem zero : padicValInt p 0 = 0 := by simp [padicValInt]
#align padic_val_int.zero padicValInt.zero
@[simp]
protected theorem one : padicValInt p 1 = 0 := by simp [padicValInt]
#align padic_val_int.one padicValInt.one
@[simp]
theorem of_nat {n : ℕ} : padicValInt p n = padicValNat p n := by simp [padicValInt]
#align padic_val_int.of_nat padicValInt.of_nat
theorem self (hp : 1 < p) : padicValInt p p = 1 := by simp [padicValNat.self hp]
#align padic_val_int.self padicValInt.self
theorem eq_zero_of_not_dvd {z : ℤ} (h : ¬(p : ℤ) ∣ z) : padicValInt p z = 0 := by
rw [padicValInt, padicValNat]
split_ifs <;> simp [multiplicity.Int.natAbs, multiplicity_eq_zero.2 h]
#align padic_val_int.eq_zero_of_not_dvd padicValInt.eq_zero_of_not_dvd
end padicValInt
def padicValRat (p : ℕ) (q : ℚ) : ℤ :=
padicValInt p q.num - padicValNat p q.den
#align padic_val_rat padicValRat
lemma padicValRat_def (p : ℕ) (q : ℚ) :
padicValRat p q = padicValInt p q.num - padicValNat p q.den :=
rfl
namespace padicValRat
open multiplicity
variable {p : ℕ}
@[simp]
protected theorem neg (q : ℚ) : padicValRat p (-q) = padicValRat p q := by
simp [padicValRat, padicValInt]
#align padic_val_rat.neg padicValRat.neg
@[simp]
protected theorem zero : padicValRat p 0 = 0 := by simp [padicValRat]
#align padic_val_rat.zero padicValRat.zero
@[simp]
protected theorem one : padicValRat p 1 = 0 := by simp [padicValRat]
#align padic_val_rat.one padicValRat.one
@[simp]
theorem of_int {z : ℤ} : padicValRat p z = padicValInt p z := by simp [padicValRat]
#align padic_val_rat.of_int padicValRat.of_int
theorem of_int_multiplicity {z : ℤ} (hp : p ≠ 1) (hz : z ≠ 0) :
padicValRat p (z : ℚ) = (multiplicity (p : ℤ) z).get (finite_int_iff.2 ⟨hp, hz⟩) := by
rw [of_int, padicValInt.of_ne_one_ne_zero hp hz]
#align padic_val_rat.of_int_multiplicity padicValRat.of_int_multiplicity
theorem multiplicity_sub_multiplicity {q : ℚ} (hp : p ≠ 1) (hq : q ≠ 0) :
padicValRat p q =
(multiplicity (p : ℤ) q.num).get (finite_int_iff.2 ⟨hp, Rat.num_ne_zero.2 hq⟩) -
(multiplicity p q.den).get
(by
rw [← finite_iff_dom, finite_nat_iff]
exact ⟨hp, q.pos⟩) := by
rw [padicValRat, padicValInt.of_ne_one_ne_zero hp, padicValNat, dif_pos]
· exact ⟨hp, q.pos⟩
· exact Rat.num_ne_zero.2 hq
#align padic_val_rat.multiplicity_sub_multiplicity padicValRat.multiplicity_sub_multiplicity
@[simp]
theorem of_nat {n : ℕ} : padicValRat p n = padicValNat p n := by simp [padicValRat]
#align padic_val_rat.of_nat padicValRat.of_nat
theorem self (hp : 1 < p) : padicValRat p p = 1 := by simp [hp]
#align padic_val_rat.self padicValRat.self
end padicValRat
def padicValInt (p : ℕ) (z : ℤ) : ℕ :=
padicValNat p z.natAbs
#align padic_val_int padicValInt
def padicValRat (p : ℕ) (q : ℚ) : ℤ :=
padicValInt p q.num - padicValNat p q.den
#align padic_val_rat padicValRat
lemma padicValRat_def (p : ℕ) (q : ℚ) :
padicValRat p q = padicValInt p q.num - padicValNat p q.den :=
rfl
section padicValNat
variable {p : ℕ}
theorem dvd_of_one_le_padicValNat {n : ℕ} (hp : 1 ≤ padicValNat p n) : p ∣ n := by
by_contra h
rw [padicValNat.eq_zero_of_not_dvd h] at hp
exact lt_irrefl 0 (lt_of_lt_of_le zero_lt_one hp)
#align dvd_of_one_le_padic_val_nat dvd_of_one_le_padicValNat
theorem pow_padicValNat_dvd {n : ℕ} : p ^ padicValNat p n ∣ n := by
rcases n.eq_zero_or_pos with (rfl | hn); · simp
rcases eq_or_ne p 1 with (rfl | hp); · simp
rw [multiplicity.pow_dvd_iff_le_multiplicity, padicValNat_def'] <;> assumption
#align pow_padic_val_nat_dvd pow_padicValNat_dvd
theorem padicValNat_dvd_iff_le [hp : Fact p.Prime] {a n : ℕ} (ha : a ≠ 0) :
p ^ n ∣ a ↔ n ≤ padicValNat p a := by
rw [pow_dvd_iff_le_multiplicity, ← padicValNat_def' hp.out.ne_one ha.bot_lt, PartENat.coe_le_coe]
#align padic_val_nat_dvd_iff_le padicValNat_dvd_iff_le
theorem padicValNat_dvd_iff (n : ℕ) [hp : Fact p.Prime] (a : ℕ) :
p ^ n ∣ a ↔ a = 0 ∨ n ≤ padicValNat p a := by
rcases eq_or_ne a 0 with (rfl | ha)
· exact iff_of_true (dvd_zero _) (Or.inl rfl)
· rw [padicValNat_dvd_iff_le ha, or_iff_right ha]
#align padic_val_nat_dvd_iff padicValNat_dvd_iff
theorem pow_succ_padicValNat_not_dvd {n : ℕ} [hp : Fact p.Prime] (hn : n ≠ 0) :
¬p ^ (padicValNat p n + 1) ∣ n := by
rw [padicValNat_dvd_iff_le hn, not_le]
exact Nat.lt_succ_self _
#align pow_succ_padic_val_nat_not_dvd pow_succ_padicValNat_not_dvd
theorem padicValNat_primes {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime] (neq : p ≠ q) :
padicValNat p q = 0 :=
@padicValNat.eq_zero_of_not_dvd p q <|
(not_congr (Iff.symm (prime_dvd_prime_iff_eq hp.1 hq.1))).mp neq
#align padic_val_nat_primes padicValNat_primes
theorem padicValNat_prime_prime_pow {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime]
(n : ℕ) (neq : p ≠ q) : padicValNat p (q ^ n) = 0 := by
rw [padicValNat.pow _ <| Nat.Prime.ne_zero hq.elim, padicValNat_primes neq, mul_zero]
theorem padicValNat_mul_pow_left {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime]
(n m : ℕ) (neq : p ≠ q) : padicValNat p (p^n * q^m) = n := by
rw [padicValNat.mul (NeZero.ne' (p^n)).symm (NeZero.ne' (q^m)).symm,
padicValNat.prime_pow, padicValNat_prime_prime_pow m neq, add_zero]
theorem padicValNat_mul_pow_right {q : ℕ} [hp : Fact p.Prime] [hq : Fact q.Prime]
(n m : ℕ) (neq : q ≠ p) : padicValNat q (p^n * q^m) = m := by
rw [mul_comm (p^n) (q^m)]
exact padicValNat_mul_pow_left m n neq
lemma padicValNat_le_nat_log (n : ℕ) : padicValNat p n ≤ Nat.log p n := by
rcases n with _ | n
· simp
rcases p with _ | _ | p
· simp
· simp
exact Nat.le_log_of_pow_le p.one_lt_succ_succ (le_of_dvd n.succ_pos pow_padicValNat_dvd)
lemma nat_log_eq_padicValNat_iff {n : ℕ} [hp : Fact (Nat.Prime p)] (hn : 0 < n) :
Nat.log p n = padicValNat p n ↔ n < p ^ (padicValNat p n + 1) := by
rw [Nat.log_eq_iff (Or.inr ⟨(Nat.Prime.one_lt' p).out, by omega⟩), and_iff_right_iff_imp]
exact fun _ => Nat.le_of_dvd hn pow_padicValNat_dvd
lemma Nat.log_ne_padicValNat_succ {n : ℕ} (hn : n ≠ 0) : log 2 n ≠ padicValNat 2 (n + 1) := by
rw [Ne, log_eq_iff (by simp [hn])]
rintro ⟨h1, h2⟩
rw [← lt_add_one_iff, ← mul_one (2 ^ _)] at h1
rw [← add_one_le_iff, Nat.pow_succ] at h2
refine not_dvd_of_between_consec_multiples h1 (lt_of_le_of_ne' h2 ?_) pow_padicValNat_dvd
-- TODO(kmill): Why is this `p := 2` necessary?
exact pow_succ_padicValNat_not_dvd (p := 2) n.succ_ne_zero ∘ dvd_of_eq
lemma Nat.max_log_padicValNat_succ_eq_log_succ (n : ℕ) :
max (log 2 n) (padicValNat 2 (n + 1)) = log 2 (n + 1) := by
apply le_antisymm (max_le (le_log_of_pow_le one_lt_two (pow_log_le_add_one 2 n))
(padicValNat_le_nat_log (n + 1)))
rw [le_max_iff, or_iff_not_imp_left, not_le]
intro h
replace h := le_antisymm (add_one_le_iff.mpr (lt_pow_of_log_lt one_lt_two h))
(pow_log_le_self 2 n.succ_ne_zero)
rw [h, padicValNat.prime_pow, ← h]
theorem range_pow_padicValNat_subset_divisors {n : ℕ} (hn : n ≠ 0) :
(Finset.range (padicValNat p n + 1)).image (p ^ ·) ⊆ n.divisors := by
intro t ht
simp only [exists_prop, Finset.mem_image, Finset.mem_range] at ht
obtain ⟨k, hk, rfl⟩ := ht
rw [Nat.mem_divisors]
exact ⟨(pow_dvd_pow p <| by omega).trans pow_padicValNat_dvd, hn⟩
#align range_pow_padic_val_nat_subset_divisors range_pow_padicValNat_subset_divisors
theorem range_pow_padicValNat_subset_divisors' {n : ℕ} [hp : Fact p.Prime] :
((Finset.range (padicValNat p n)).image fun t => p ^ (t + 1)) ⊆ n.divisors.erase 1 := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp
intro t ht
simp only [exists_prop, Finset.mem_image, Finset.mem_range] at ht
obtain ⟨k, hk, rfl⟩ := ht
rw [Finset.mem_erase, Nat.mem_divisors]
refine ⟨?_, (pow_dvd_pow p <| succ_le_iff.2 hk).trans pow_padicValNat_dvd, hn⟩
exact (Nat.one_lt_pow k.succ_ne_zero hp.out.one_lt).ne'
#align range_pow_padic_val_nat_subset_divisors' range_pow_padicValNat_subset_divisors'
theorem padicValNat_factorial_mul (n : ℕ) [hp : Fact p.Prime] :
padicValNat p (p * n) ! = padicValNat p n ! + n := by
refine PartENat.natCast_inj.mp ?_
rw [padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos (p * n), Nat.cast_add,
padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos n]
exact Prime.multiplicity_factorial_mul hp.out
theorem padicValNat_eq_zero_of_mem_Ioo {m k : ℕ}
(hm : m ∈ Set.Ioo (p * k) (p * (k + 1))) : padicValNat p m = 0 :=
padicValNat.eq_zero_of_not_dvd <| not_dvd_of_between_consec_multiples hm.1 hm.2
theorem padicValNat_factorial_mul_add {n : ℕ} (m : ℕ) [hp : Fact p.Prime] (h : n < p) :
padicValNat p (p * m + n) ! = padicValNat p (p * m) ! := by
induction' n with n hn
· rw [add_zero]
· rw [add_succ, factorial_succ,
padicValNat.mul (succ_ne_zero (p * m + n)) <| factorial_ne_zero (p * m + _),
hn <| lt_of_succ_lt h, ← add_succ,
padicValNat_eq_zero_of_mem_Ioo ⟨(Nat.lt_add_of_pos_right <| succ_pos n),
(Nat.mul_add _ _ _▸ Nat.mul_one _ ▸ ((add_lt_add_iff_left (p * m)).mpr h))⟩,
zero_add]
@[simp] theorem padicValNat_mul_div_factorial (n : ℕ) [hp : Fact p.Prime] :
padicValNat p (p * (n / p))! = padicValNat p n ! := by
nth_rw 2 [← div_add_mod n p]
exact (padicValNat_factorial_mul_add (n / p) <| mod_lt n hp.out.pos).symm
theorem padicValNat_factorial {n b : ℕ} [hp : Fact p.Prime] (hnb : log p n < b) :
padicValNat p (n !) = ∑ i ∈ Finset.Ico 1 b, n / p ^ i :=
PartENat.natCast_inj.mp ((padicValNat_def' (Nat.Prime.ne_one hp.out) <| factorial_pos _) ▸
Prime.multiplicity_factorial hp.out hnb)
theorem sub_one_mul_padicValNat_factorial [hp : Fact p.Prime] (n : ℕ):
(p - 1) * padicValNat p (n !) = n - (p.digits n).sum := by
rw [padicValNat_factorial <| lt_succ_of_lt <| lt.base (log p n)]
nth_rw 2 [← zero_add 1]
rw [Nat.succ_eq_add_one, ← Finset.sum_Ico_add' _ 0 _ 1,
Ico_zero_eq_range, ← sub_one_mul_sum_log_div_pow_eq_sub_sum_digits, Nat.succ_eq_add_one]
theorem padicValNat_choose {n k b : ℕ} [hp : Fact p.Prime] (hkn : k ≤ n) (hnb : log p n < b) :
padicValNat p (choose n k) =
((Finset.Ico 1 b).filter fun i => p ^ i ≤ k % p ^ i + (n - k) % p ^ i).card :=
PartENat.natCast_inj.mp <| (padicValNat_def' (Nat.Prime.ne_one hp.out) <| choose_pos hkn) ▸
Prime.multiplicity_choose hp.out hkn hnb
theorem padicValNat_choose' {n k b : ℕ} [hp : Fact p.Prime] (hnb : log p (n + k) < b) :
padicValNat p (choose (n + k) k) =
((Finset.Ico 1 b).filter fun i => p ^ i ≤ k % p ^ i + n % p ^ i).card :=
PartENat.natCast_inj.mp <| (padicValNat_def' (Nat.Prime.ne_one hp.out) <| choose_pos <|
Nat.le_add_left k n)▸ Prime.multiplicity_choose' hp.out hnb
theorem sub_one_mul_padicValNat_choose_eq_sub_sum_digits' {k n : ℕ} [hp : Fact p.Prime] :
(p - 1) * padicValNat p (choose (n + k) k) =
(p.digits k).sum + (p.digits n).sum - (p.digits (n + k)).sum := by
have h : k ≤ n + k := by exact Nat.le_add_left k n
simp only [Nat.choose_eq_factorial_div_factorial h]
rw [padicValNat.div_of_dvd <| factorial_mul_factorial_dvd_factorial h, Nat.mul_sub_left_distrib,
padicValNat.mul (factorial_ne_zero _) (factorial_ne_zero _), Nat.mul_add]
simp only [sub_one_mul_padicValNat_factorial]
rw [← Nat.sub_add_comm <| digit_sum_le p k, Nat.add_sub_cancel n k, ← Nat.add_sub_assoc <|
digit_sum_le p n, Nat.sub_sub (k + n), ← Nat.sub_right_comm, Nat.sub_sub, sub_add_eq,
add_comm, tsub_tsub_assoc (Nat.le_refl (k + n)) <| (add_comm k n) ▸ (Nat.add_le_add
(digit_sum_le p n) (digit_sum_le p k)), Nat.sub_self (k + n), zero_add, add_comm]
| Mathlib/NumberTheory/Padics/PadicVal.lean | 765 | 769 | theorem sub_one_mul_padicValNat_choose_eq_sub_sum_digits {k n : ℕ} [hp : Fact p.Prime]
(h : k ≤ n) : (p - 1) * padicValNat p (choose n k) =
(p.digits k).sum + (p.digits (n - k)).sum - (p.digits n).sum := by |
convert @sub_one_mul_padicValNat_choose_eq_sub_sum_digits' _ _ _ ‹_›
all_goals omega
|
import Mathlib.Algebra.Homology.Homology
import Mathlib.Algebra.Homology.Single
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
#align_import algebra.homology.additive from "leanprover-community/mathlib"@"200eda15d8ff5669854ff6bcc10aaf37cb70498f"
universe v u
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits HomologicalComplex
variable {ι : Type*}
variable {V : Type u} [Category.{v} V] [Preadditive V]
variable {W : Type*} [Category W] [Preadditive W]
variable {W₁ W₂ : Type*} [Category W₁] [Category W₂] [HasZeroMorphisms W₁] [HasZeroMorphisms W₂]
variable {c : ComplexShape ι} {C D E : HomologicalComplex V c}
variable (f g : C ⟶ D) (h k : D ⟶ E) (i : ι)
variable [HasZeroObject W₁] [HasZeroObject W₂]
namespace HomologicalComplex
instance (W : Type*) [Category W] [Preadditive W] [HasZeroObject W] [DecidableEq ι] (j : ι) :
(single W c j).Additive where
map_add {_ _ f g} := by ext; simp [single]
variable (F : W₁ ⥤ W₂) [F.PreservesZeroMorphisms]
(c : ComplexShape ι) [DecidableEq ι]
noncomputable def singleMapHomologicalComplex (j : ι) :
single W₁ c j ⋙ F.mapHomologicalComplex _ ≅ F ⋙ single W₂ c j :=
NatIso.ofComponents
(fun X =>
{ hom := { f := fun i => if h : i = j then eqToHom (by simp [h]) else 0 }
inv := { f := fun i => if h : i = j then eqToHom (by simp [h]) else 0 }
hom_inv_id := by
ext i
dsimp
split_ifs with h
· simp [h]
· rw [zero_comp, ← F.map_id,
(isZero_single_obj_X c j X _ h).eq_of_src (𝟙 _) 0, F.map_zero]
inv_hom_id := by
ext i
dsimp
split_ifs with h
· simp [h]
· apply (isZero_single_obj_X c j _ _ h).eq_of_src })
fun f => by
ext i
dsimp
split_ifs with h
· subst h
simp [single_map_f_self, singleObjXSelf, singleObjXIsoOfEq, eqToHom_map]
· apply (isZero_single_obj_X c j _ _ h).eq_of_tgt
#align homological_complex.single_map_homological_complex HomologicalComplex.singleMapHomologicalComplex
@[simp]
theorem singleMapHomologicalComplex_hom_app_self (j : ι) (X : W₁) :
((singleMapHomologicalComplex F c j).hom.app X).f j =
F.map (singleObjXSelf c j X).hom ≫ (singleObjXSelf c j (F.obj X)).inv := by
simp [singleMapHomologicalComplex, singleObjXSelf, singleObjXIsoOfEq, eqToHom_map]
#align homological_complex.single_map_homological_complex_hom_app_self HomologicalComplex.singleMapHomologicalComplex_hom_app_self
@[simp]
| Mathlib/Algebra/Homology/Additive.lean | 325 | 327 | theorem singleMapHomologicalComplex_hom_app_ne {i j : ι} (h : i ≠ j) (X : W₁) :
((singleMapHomologicalComplex F c j).hom.app X).f i = 0 := by |
simp [singleMapHomologicalComplex, h]
|
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"
open Function OrderDual Set
variable {α β β₂ γ : Type*} {ι ι' : Sort*} {κ : ι → Sort*} {κ' : ι' → Sort*}
instance OrderDual.supSet (α) [InfSet α] : SupSet αᵒᵈ :=
⟨(sInf : Set α → α)⟩
instance OrderDual.infSet (α) [SupSet α] : InfSet αᵒᵈ :=
⟨(sSup : Set α → α)⟩
class CompleteSemilatticeSup (α : Type*) extends PartialOrder α, SupSet α where
le_sSup : ∀ s, ∀ a ∈ s, a ≤ sSup s
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
class CompleteSemilatticeInf (α : Type*) extends PartialOrder α, InfSet α where
sInf_le : ∀ s, ∀ a ∈ s, sInf s ≤ a
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
class CompleteLattice (α : Type*) extends Lattice α, CompleteSemilatticeSup α,
CompleteSemilatticeInf α, Top α, Bot α where
protected le_top : ∀ x : α, x ≤ ⊤
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
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
def completeLatticeOfCompleteSemilatticeInf (α : Type*) [CompleteSemilatticeInf α] :
CompleteLattice α :=
completeLatticeOfInf α fun s => isGLB_sInf s
#align complete_lattice_of_complete_semilattice_Inf completeLatticeOfCompleteSemilatticeInf
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
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.
class CompleteLinearOrder (α : Type*) extends CompleteLattice α where
le_total (a b : α) : a ≤ b ∨ b ≤ a
decidableLE : DecidableRel (· ≤ · : α → α → Prop)
decidableEq : DecidableEq α := @decidableEqOfDecidableLE _ _ decidableLE
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]
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
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
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
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
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
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
@[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
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
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
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'
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]
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
| Mathlib/Order/CompleteLattice.lean | 1,388 | 1,390 | 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 }
|
import Mathlib.Tactic.CategoryTheory.Reassoc
#align_import category_theory.natural_transformation from "leanprover-community/mathlib"@"8350c34a64b9bc3fc64335df8006bffcadc7baa6"
namespace CategoryTheory
-- declare the `v`'s first; see note [CategoryTheory universes].
universe v₁ v₂ v₃ v₄ u₁ u₂ u₃ u₄
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
@[ext]
structure NatTrans (F G : C ⥤ D) : Type max u₁ v₂ where
app : ∀ X : C, F.obj X ⟶ G.obj X
naturality : ∀ ⦃X Y : C⦄ (f : X ⟶ Y), F.map f ≫ app Y = app X ≫ G.map f := by aesop_cat
#align category_theory.nat_trans CategoryTheory.NatTrans
#align category_theory.nat_trans.naturality CategoryTheory.NatTrans.naturality
#align category_theory.nat_trans.ext_iff CategoryTheory.NatTrans.ext_iff
#align category_theory.nat_trans.ext CategoryTheory.NatTrans.ext
-- Rather arbitrarily, we say that the 'simpler' form is
-- components of natural transformations moving earlier.
attribute [reassoc (attr := simp)] NatTrans.naturality
#align category_theory.nat_trans.naturality_assoc CategoryTheory.NatTrans.naturality_assoc
| Mathlib/CategoryTheory/NatTrans.lean | 63 | 64 | theorem congr_app {F G : C ⥤ D} {α β : NatTrans F G} (h : α = β) (X : C) : α.app X = β.app X := by |
aesop_cat
|
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Algebra.Order.Group.Instances
import Mathlib.Data.Prod.Lex
import Mathlib.Data.Set.Image
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Order.Monotone.Monovary
import Mathlib.Tactic.Abel
#align_import algebra.order.rearrangement from "leanprover-community/mathlib"@"b3f25363ae62cb169e72cd6b8b1ac97bacf21ca7"
open Equiv Equiv.Perm Finset Function OrderDual
variable {ι α β : Type*}
section SMul
variable [LinearOrderedRing α] [LinearOrderedAddCommGroup β] [Module α β] [OrderedSMul α β]
{s : Finset ι} {σ : Perm ι} {f : ι → α} {g : ι → β}
theorem MonovaryOn.sum_smul_comp_perm_le_sum_smul (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) : (∑ i ∈ s, f i • g (σ i)) ≤ ∑ i ∈ s, f i • g i := by
classical
revert hσ σ hfg
-- Porting note: Specify `p` to get around `∀ {σ}` in the current goal.
apply Finset.induction_on_max_value (fun i ↦ toLex (g i, f i))
(p := fun t ↦ ∀ {σ : Perm ι}, MonovaryOn f g t → { x | σ x ≠ x } ⊆ t →
(∑ i ∈ t, f i • g (σ i)) ≤ ∑ i ∈ t, f i • g i) s
· simp only [le_rfl, Finset.sum_empty, imp_true_iff]
intro a s has hamax hind σ hfg hσ
set τ : Perm ι := σ.trans (swap a (σ a)) with hτ
have hτs : { x | τ x ≠ x } ⊆ s := by
intro x hx
simp only [τ, Ne, Set.mem_setOf_eq, Equiv.coe_trans, Equiv.swap_comp_apply] at hx
split_ifs at hx with h₁ h₂
· obtain rfl | hax := eq_or_ne x a
· contradiction
· exact mem_of_mem_insert_of_ne (hσ fun h ↦ hax <| h.symm.trans h₁) hax
· exact (hx <| σ.injective h₂.symm).elim
· exact mem_of_mem_insert_of_ne (hσ hx) (ne_of_apply_ne _ h₂)
specialize hind (hfg.subset <| subset_insert _ _) hτs
simp_rw [sum_insert has]
refine le_trans ?_ (add_le_add_left hind _)
obtain hσa | hσa := eq_or_ne a (σ a)
· rw [hτ, ← hσa, swap_self, trans_refl]
have h1s : σ⁻¹ a ∈ s := by
rw [Ne, ← inv_eq_iff_eq] at hσa
refine mem_of_mem_insert_of_ne (hσ fun h ↦ hσa ?_) hσa
rwa [apply_inv_self, eq_comm] at h
simp only [← s.sum_erase_add _ h1s, add_comm]
rw [← add_assoc, ← add_assoc]
simp only [hτ, swap_apply_left, Function.comp_apply, Equiv.coe_trans, apply_inv_self]
refine add_le_add (smul_add_smul_le_smul_add_smul' ?_ ?_) (sum_congr rfl fun x hx ↦ ?_).le
· specialize hamax (σ⁻¹ a) h1s
rw [Prod.Lex.le_iff] at hamax
cases' hamax with hamax hamax
· exact hfg (mem_insert_of_mem h1s) (mem_insert_self _ _) hamax
· exact hamax.2
· specialize hamax (σ a) (mem_of_mem_insert_of_ne (hσ <| σ.injective.ne hσa.symm) hσa.symm)
rw [Prod.Lex.le_iff] at hamax
cases' hamax with hamax hamax
· exact hamax.le
· exact hamax.1.le
· rw [mem_erase, Ne, eq_inv_iff_eq] at hx
rw [swap_apply_of_ne_of_ne hx.1 (σ.injective.ne _)]
rintro rfl
exact has hx.2
#align monovary_on.sum_smul_comp_perm_le_sum_smul MonovaryOn.sum_smul_comp_perm_le_sum_smul
theorem MonovaryOn.sum_smul_comp_perm_eq_sum_smul_iff (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f i • g (σ i)) = ∑ i ∈ s, f i • g i) ↔ MonovaryOn f (g ∘ σ) s := by
classical
refine ⟨not_imp_not.1 fun h ↦ ?_, fun h ↦ (hfg.sum_smul_comp_perm_le_sum_smul hσ).antisymm ?_⟩
· rw [MonovaryOn] at h
push_neg at h
obtain ⟨x, hx, y, hy, hgxy, hfxy⟩ := h
set τ : Perm ι := (Equiv.swap x y).trans σ
have hτs : { x | τ x ≠ x } ⊆ s := by
refine (set_support_mul_subset σ <| swap x y).trans (Set.union_subset hσ fun z hz ↦ ?_)
obtain ⟨_, rfl | rfl⟩ := swap_apply_ne_self_iff.1 hz <;> assumption
refine ((hfg.sum_smul_comp_perm_le_sum_smul hτs).trans_lt' ?_).ne
obtain rfl | hxy := eq_or_ne x y
· cases lt_irrefl _ hfxy
simp only [τ, ← s.sum_erase_add _ hx,
← (s.erase x).sum_erase_add _ (mem_erase.2 ⟨hxy.symm, hy⟩),
add_assoc, Equiv.coe_trans, Function.comp_apply, swap_apply_right, swap_apply_left]
refine add_lt_add_of_le_of_lt (Finset.sum_congr rfl fun z hz ↦ ?_).le
(smul_add_smul_lt_smul_add_smul hfxy hgxy)
simp_rw [mem_erase] at hz
rw [swap_apply_of_ne_of_ne hz.2.1 hz.1]
· convert h.sum_smul_comp_perm_le_sum_smul ((set_support_inv_eq _).subset.trans hσ) using 1
simp_rw [Function.comp_apply, apply_inv_self]
#align monovary_on.sum_smul_comp_perm_eq_sum_smul_iff MonovaryOn.sum_smul_comp_perm_eq_sum_smul_iff
theorem MonovaryOn.sum_smul_comp_perm_lt_sum_smul_iff (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f i • g (σ i)) < ∑ i ∈ s, f i • g i) ↔ ¬MonovaryOn f (g ∘ σ) s := by
simp [← hfg.sum_smul_comp_perm_eq_sum_smul_iff hσ, lt_iff_le_and_ne,
hfg.sum_smul_comp_perm_le_sum_smul hσ]
#align monovary_on.sum_smul_comp_perm_lt_sum_smul_iff MonovaryOn.sum_smul_comp_perm_lt_sum_smul_iff
theorem MonovaryOn.sum_comp_perm_smul_le_sum_smul (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) : (∑ i ∈ s, f (σ i) • g i) ≤ ∑ i ∈ s, f i • g i := by
convert hfg.sum_smul_comp_perm_le_sum_smul
(show { x | σ⁻¹ x ≠ x } ⊆ s by simp only [set_support_inv_eq, hσ]) using 1
exact σ.sum_comp' s (fun i j ↦ f i • g j) hσ
#align monovary_on.sum_comp_perm_smul_le_sum_smul MonovaryOn.sum_comp_perm_smul_le_sum_smul
theorem MonovaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f (σ i) • g i) = ∑ i ∈ s, f i • g i) ↔ MonovaryOn (f ∘ σ) g s := by
have hσinv : { x | σ⁻¹ x ≠ x } ⊆ s := (set_support_inv_eq _).subset.trans hσ
refine (Iff.trans ?_ <| hfg.sum_smul_comp_perm_eq_sum_smul_iff hσinv).trans
⟨fun h ↦ ?_, fun h ↦ ?_⟩
· apply eq_iff_eq_cancel_right.2
rw [σ.sum_comp' s (fun i j ↦ f i • g j) hσ]
congr
· convert h.comp_right σ
· rw [comp.assoc, inv_def, symm_comp_self, comp_id]
· rw [σ.eq_preimage_iff_image_eq, Set.image_perm hσ]
· convert h.comp_right σ.symm
· rw [comp.assoc, self_comp_symm, comp_id]
· rw [σ.symm.eq_preimage_iff_image_eq]
exact Set.image_perm hσinv
#align monovary_on.sum_comp_perm_smul_eq_sum_smul_iff MonovaryOn.sum_comp_perm_smul_eq_sum_smul_iff
theorem MonovaryOn.sum_comp_perm_smul_lt_sum_smul_iff (hfg : MonovaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f (σ i) • g i) < ∑ i ∈ s, f i • g i) ↔ ¬MonovaryOn (f ∘ σ) g s := by
simp [← hfg.sum_comp_perm_smul_eq_sum_smul_iff hσ, lt_iff_le_and_ne,
hfg.sum_comp_perm_smul_le_sum_smul hσ]
#align monovary_on.sum_comp_perm_smul_lt_sum_smul_iff MonovaryOn.sum_comp_perm_smul_lt_sum_smul_iff
theorem AntivaryOn.sum_smul_le_sum_smul_comp_perm (hfg : AntivaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) : ∑ i ∈ s, f i • g i ≤ ∑ i ∈ s, f i • g (σ i) :=
hfg.dual_right.sum_smul_comp_perm_le_sum_smul hσ
#align antivary_on.sum_smul_le_sum_smul_comp_perm AntivaryOn.sum_smul_le_sum_smul_comp_perm
theorem AntivaryOn.sum_smul_eq_sum_smul_comp_perm_iff (hfg : AntivaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f i • g (σ i)) = ∑ i ∈ s, f i • g i) ↔ AntivaryOn f (g ∘ σ) s :=
(hfg.dual_right.sum_smul_comp_perm_eq_sum_smul_iff hσ).trans monovaryOn_toDual_right
#align antivary_on.sum_smul_eq_sum_smul_comp_perm_iff AntivaryOn.sum_smul_eq_sum_smul_comp_perm_iff
| Mathlib/Algebra/Order/Rearrangement.lean | 209 | 213 | theorem AntivaryOn.sum_smul_lt_sum_smul_comp_perm_iff (hfg : AntivaryOn f g s)
(hσ : { x | σ x ≠ x } ⊆ s) :
((∑ i ∈ s, f i • g i) < ∑ i ∈ s, f i • g (σ i)) ↔ ¬AntivaryOn f (g ∘ σ) s := by |
simp [← hfg.sum_smul_eq_sum_smul_comp_perm_iff hσ, lt_iff_le_and_ne, eq_comm,
hfg.sum_smul_le_sum_smul_comp_perm hσ]
|
import Mathlib.Topology.Algebra.InfiniteSum.Basic
import Mathlib.Topology.Algebra.UniformGroup
noncomputable section
open Filter Finset Function
open scoped Topology
variable {α β γ δ : Type*}
section TopologicalGroup
variable [CommGroup α] [TopologicalSpace α] [TopologicalGroup α]
variable {f g : β → α} {a a₁ a₂ : α}
-- `by simpa using` speeds up elaboration. Why?
@[to_additive]
theorem HasProd.inv (h : HasProd f a) : HasProd (fun b ↦ (f b)⁻¹) a⁻¹ := by
simpa only using h.map (MonoidHom.id α)⁻¹ continuous_inv
#align has_sum.neg HasSum.neg
@[to_additive]
theorem Multipliable.inv (hf : Multipliable f) : Multipliable fun b ↦ (f b)⁻¹ :=
hf.hasProd.inv.multipliable
#align summable.neg Summable.neg
@[to_additive]
theorem Multipliable.of_inv (hf : Multipliable fun b ↦ (f b)⁻¹) : Multipliable f := by
simpa only [inv_inv] using hf.inv
#align summable.of_neg Summable.of_neg
@[to_additive]
theorem multipliable_inv_iff : (Multipliable fun b ↦ (f b)⁻¹) ↔ Multipliable f :=
⟨Multipliable.of_inv, Multipliable.inv⟩
#align summable_neg_iff summable_neg_iff
@[to_additive]
theorem HasProd.div (hf : HasProd f a₁) (hg : HasProd g a₂) :
HasProd (fun b ↦ f b / g b) (a₁ / a₂) := by
simp only [div_eq_mul_inv]
exact hf.mul hg.inv
#align has_sum.sub HasSum.sub
@[to_additive]
theorem Multipliable.div (hf : Multipliable f) (hg : Multipliable g) :
Multipliable fun b ↦ f b / g b :=
(hf.hasProd.div hg.hasProd).multipliable
#align summable.sub Summable.sub
@[to_additive]
theorem Multipliable.trans_div (hg : Multipliable g) (hfg : Multipliable fun b ↦ f b / g b) :
Multipliable f := by
simpa only [div_mul_cancel] using hfg.mul hg
#align summable.trans_sub Summable.trans_sub
@[to_additive]
theorem multipliable_iff_of_multipliable_div (hfg : Multipliable fun b ↦ f b / g b) :
Multipliable f ↔ Multipliable g :=
⟨fun hf ↦ hf.trans_div <| by simpa only [inv_div] using hfg.inv, fun hg ↦ hg.trans_div hfg⟩
#align summable_iff_of_summable_sub summable_iff_of_summable_sub
@[to_additive]
theorem HasProd.update (hf : HasProd f a₁) (b : β) [DecidableEq β] (a : α) :
HasProd (update f b a) (a / f b * a₁) := by
convert (hasProd_ite_eq b (a / f b)).mul hf with b'
by_cases h : b' = b
· rw [h, update_same]
simp [eq_self_iff_true, if_true, sub_add_cancel]
· simp only [h, update_noteq, if_false, Ne, one_mul, not_false_iff]
#align has_sum.update HasSum.update
@[to_additive]
theorem Multipliable.update (hf : Multipliable f) (b : β) [DecidableEq β] (a : α) :
Multipliable (update f b a) :=
(hf.hasProd.update b a).multipliable
#align summable.update Summable.update
@[to_additive]
theorem HasProd.hasProd_compl_iff {s : Set β} (hf : HasProd (f ∘ (↑) : s → α) a₁) :
HasProd (f ∘ (↑) : ↑sᶜ → α) a₂ ↔ HasProd f (a₁ * a₂) := by
refine ⟨fun h ↦ hf.mul_compl h, fun h ↦ ?_⟩
rw [hasProd_subtype_iff_mulIndicator] at hf ⊢
rw [Set.mulIndicator_compl]
simpa only [div_eq_mul_inv, mul_inv_cancel_comm] using h.div hf
#align has_sum.has_sum_compl_iff HasSum.hasSum_compl_iff
@[to_additive]
theorem HasProd.hasProd_iff_compl {s : Set β} (hf : HasProd (f ∘ (↑) : s → α) a₁) :
HasProd f a₂ ↔ HasProd (f ∘ (↑) : ↑sᶜ → α) (a₂ / a₁) :=
Iff.symm <| hf.hasProd_compl_iff.trans <| by rw [mul_div_cancel]
#align has_sum.has_sum_iff_compl HasSum.hasSum_iff_compl
@[to_additive]
theorem Multipliable.multipliable_compl_iff {s : Set β} (hf : Multipliable (f ∘ (↑) : s → α)) :
Multipliable (f ∘ (↑) : ↑sᶜ → α) ↔ Multipliable f where
mp := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_compl_iff.1 ha).multipliable
mpr := fun ⟨_, ha⟩ ↦ (hf.hasProd.hasProd_iff_compl.1 ha).multipliable
#align summable.summable_compl_iff Summable.summable_compl_iff
@[to_additive]
protected theorem Finset.hasProd_compl_iff (s : Finset β) :
HasProd (fun x : { x // x ∉ s } ↦ f x) a ↔ HasProd f (a * ∏ i ∈ s, f i) :=
(s.hasProd f).hasProd_compl_iff.trans <| by rw [mul_comm]
#align finset.has_sum_compl_iff Finset.hasSum_compl_iff
@[to_additive]
protected theorem Finset.hasProd_iff_compl (s : Finset β) :
HasProd f a ↔ HasProd (fun x : { x // x ∉ s } ↦ f x) (a / ∏ i ∈ s, f i) :=
(s.hasProd f).hasProd_iff_compl
#align finset.has_sum_iff_compl Finset.hasSum_iff_compl
@[to_additive]
protected theorem Finset.multipliable_compl_iff (s : Finset β) :
(Multipliable fun x : { x // x ∉ s } ↦ f x) ↔ Multipliable f :=
(s.multipliable f).multipliable_compl_iff
#align finset.summable_compl_iff Finset.summable_compl_iff
@[to_additive]
theorem Set.Finite.multipliable_compl_iff {s : Set β} (hs : s.Finite) :
Multipliable (f ∘ (↑) : ↑sᶜ → α) ↔ Multipliable f :=
(hs.multipliable f).multipliable_compl_iff
#align set.finite.summable_compl_iff Set.Finite.summable_compl_iff
@[to_additive]
theorem hasProd_ite_div_hasProd [DecidableEq β] (hf : HasProd f a) (b : β) :
HasProd (fun n ↦ ite (n = b) 1 (f n)) (a / f b) := by
convert hf.update b 1 using 1
· ext n
rw [Function.update_apply]
· rw [div_mul_eq_mul_div, one_mul]
#align has_sum_ite_sub_has_sum hasSum_ite_sub_hasSum
section TopologicalGroup
variable {G : Type*} [TopologicalSpace G] [CommGroup G] [TopologicalGroup G] {f : α → G}
@[to_additive]
theorem Multipliable.vanishing (hf : Multipliable f) ⦃e : Set G⦄ (he : e ∈ 𝓝 (1 : G)) :
∃ s : Finset α, ∀ t, Disjoint t s → (∏ k ∈ t, f k) ∈ e := by
classical
letI : UniformSpace G := TopologicalGroup.toUniformSpace G
have : UniformGroup G := comm_topologicalGroup_is_uniform
exact cauchySeq_finset_iff_prod_vanishing.1 hf.hasProd.cauchySeq e he
#align summable.vanishing Summable.vanishing
@[to_additive]
| Mathlib/Topology/Algebra/InfiniteSum/Group.lean | 335 | 340 | theorem Multipliable.tprod_vanishing (hf : Multipliable f) ⦃e : Set G⦄ (he : e ∈ 𝓝 1) :
∃ s : Finset α, ∀ t : Set α, Disjoint t s → (∏' b : t, f b) ∈ e := by |
classical
letI : UniformSpace G := TopologicalGroup.toUniformSpace G
have : UniformGroup G := comm_topologicalGroup_is_uniform
exact cauchySeq_finset_iff_tprod_vanishing.1 hf.hasProd.cauchySeq e he
|
import Mathlib.Data.Int.Interval
import Mathlib.RingTheory.Binomial
import Mathlib.RingTheory.HahnSeries.PowerSeries
import Mathlib.RingTheory.HahnSeries.Summable
import Mathlib.FieldTheory.RatFunc.AsPolynomial
import Mathlib.RingTheory.Localization.FractionRing
#align_import ring_theory.laurent_series from "leanprover-community/mathlib"@"831c494092374cfe9f50591ed0ac81a25efc5b86"
universe u
open scoped Classical
open HahnSeries Polynomial
noncomputable section
abbrev LaurentSeries (R : Type u) [Zero R] :=
HahnSeries ℤ R
#align laurent_series LaurentSeries
variable {R : Type*}
namespace LaurentSeries
namespace RatFunc
section RatFunc
open RatFunc
variable {F : Type u} [Field F] (p q : F[X]) (f g : RatFunc F)
def coeAlgHom (F : Type u) [Field F] : RatFunc F →ₐ[F[X]] LaurentSeries F :=
liftAlgHom (Algebra.ofId _ _) <|
nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _ <|
Polynomial.algebraMap_hahnSeries_injective _
#align ratfunc.coe_alg_hom RatFunc.coeAlgHom
@[coe]
def coeToLaurentSeries_fun {F : Type u} [Field F] : RatFunc F → LaurentSeries F :=
coeAlgHom F
instance coeToLaurentSeries : Coe (RatFunc F) (LaurentSeries F) :=
⟨coeToLaurentSeries_fun⟩
#align ratfunc.coe_to_laurent_series RatFunc.coeToLaurentSeries
theorem coe_def : (f : LaurentSeries F) = coeAlgHom F f :=
rfl
#align ratfunc.coe_def RatFunc.coe_def
theorem coe_num_denom : (f : LaurentSeries F) = f.num / f.denom :=
liftAlgHom_apply _ _ f
#align ratfunc.coe_num_denom RatFunc.coe_num_denom
theorem coe_injective : Function.Injective ((↑) : RatFunc F → LaurentSeries F) :=
liftAlgHom_injective _ (Polynomial.algebraMap_hahnSeries_injective _)
#align ratfunc.coe_injective RatFunc.coe_injective
-- Porting note: removed the `norm_cast` tag:
-- `norm_cast: badly shaped lemma, rhs can't start with coe `↑(coeAlgHom F) f`
@[simp]
theorem coe_apply : coeAlgHom F f = f :=
rfl
#align ratfunc.coe_apply RatFunc.coe_apply
theorem coe_coe (P : Polynomial F) : (P : LaurentSeries F) = (P : RatFunc F) := by
simp only [coePolynomial, coe_def, AlgHom.commutes, algebraMap_hahnSeries_apply]
@[simp, norm_cast]
theorem coe_zero : ((0 : RatFunc F) : LaurentSeries F) = 0 :=
(coeAlgHom F).map_zero
#align ratfunc.coe_zero RatFunc.coe_zero
theorem coe_ne_zero {f : Polynomial F} (hf : f ≠ 0) : (↑f : PowerSeries F) ≠ 0 := by
simp only [ne_eq, Polynomial.coe_eq_zero_iff, hf, not_false_eq_true]
@[simp, norm_cast]
theorem coe_one : ((1 : RatFunc F) : LaurentSeries F) = 1 :=
(coeAlgHom F).map_one
#align ratfunc.coe_one RatFunc.coe_one
@[simp, norm_cast]
theorem coe_add : ((f + g : RatFunc F) : LaurentSeries F) = f + g :=
(coeAlgHom F).map_add _ _
#align ratfunc.coe_add RatFunc.coe_add
@[simp, norm_cast]
theorem coe_sub : ((f - g : RatFunc F) : LaurentSeries F) = f - g :=
(coeAlgHom F).map_sub _ _
#align ratfunc.coe_sub RatFunc.coe_sub
@[simp, norm_cast]
theorem coe_neg : ((-f : RatFunc F) : LaurentSeries F) = -f :=
(coeAlgHom F).map_neg _
#align ratfunc.coe_neg RatFunc.coe_neg
@[simp, norm_cast]
theorem coe_mul : ((f * g : RatFunc F) : LaurentSeries F) = f * g :=
(coeAlgHom F).map_mul _ _
#align ratfunc.coe_mul RatFunc.coe_mul
@[simp, norm_cast]
theorem coe_pow (n : ℕ) : ((f ^ n : RatFunc F) : LaurentSeries F) = (f : LaurentSeries F) ^ n :=
(coeAlgHom F).map_pow _ _
#align ratfunc.coe_pow RatFunc.coe_pow
@[simp, norm_cast]
theorem coe_div :
((f / g : RatFunc F) : LaurentSeries F) = (f : LaurentSeries F) / (g : LaurentSeries F) :=
map_div₀ (coeAlgHom F) _ _
#align ratfunc.coe_div RatFunc.coe_div
@[simp, norm_cast]
theorem coe_C (r : F) : ((RatFunc.C r : RatFunc F) : LaurentSeries F) = HahnSeries.C r := by
rw [coe_num_denom, num_C, denom_C, Polynomial.coe_C, -- Porting note: removed `coe_C`
Polynomial.coe_one,
PowerSeries.coe_one, div_one]
simp only [algebraMap_eq_C, ofPowerSeries_C, C_apply] -- Porting note: added
set_option linter.uppercaseLean3 false in
#align ratfunc.coe_C RatFunc.coe_C
-- TODO: generalize over other modules
@[simp, norm_cast]
theorem coe_smul (r : F) : ((r • f : RatFunc F) : LaurentSeries F) = r • (f : LaurentSeries F) := by
rw [RatFunc.smul_eq_C_mul, ← C_mul_eq_smul, coe_mul, coe_C]
#align ratfunc.coe_smul RatFunc.coe_smul
-- Porting note: removed `norm_cast` because "badly shaped lemma, rhs can't start with coe"
-- even though `single 1 1` is a bundled function application, not a "real" coercion
@[simp, nolint simpNF] -- Added `simpNF` to avoid timeout #8386
theorem coe_X : ((X : RatFunc F) : LaurentSeries F) = single 1 1 := by
rw [coe_num_denom, num_X, denom_X, Polynomial.coe_X, -- Porting note: removed `coe_C`
Polynomial.coe_one,
PowerSeries.coe_one, div_one]
simp only [ofPowerSeries_X] -- Porting note: added
set_option linter.uppercaseLean3 false in
#align ratfunc.coe_X RatFunc.coe_X
theorem single_one_eq_pow {R : Type _} [Ring R] (n : ℕ) :
single (n : ℤ) (1 : R) = single (1 : ℤ) 1 ^ n := by
induction' n with n h_ind
· simp only [Nat.cast_zero, pow_zero]
rfl
· rw [← Int.ofNat_add_one_out, pow_succ', ← h_ind, HahnSeries.single_mul_single, one_mul,
add_comm]
theorem single_inv (d : ℤ) {α : F} (hα : α ≠ 0) :
single (-d) (α⁻¹ : F) = (single (d : ℤ) (α : F))⁻¹ := by
apply eq_inv_of_mul_eq_one_right
rw [HahnSeries.single_mul_single, add_right_neg, mul_comm,
inv_mul_cancel hα]
rfl
| Mathlib/RingTheory/LaurentSeries.lean | 409 | 415 | theorem single_zpow (n : ℤ) :
single (n : ℤ) (1 : F) = single (1 : ℤ) 1 ^ n := by |
induction' n with n_pos n_neg
· apply single_one_eq_pow
· rw [Int.negSucc_coe, Int.ofNat_add, Nat.cast_one, ← inv_one,
single_inv (n_neg + 1 : ℤ) one_ne_zero, zpow_neg, ← Nat.cast_one, ← Int.ofNat_add,
Nat.cast_one, inv_inj, zpow_natCast, single_one_eq_pow, inv_one]
|
import Mathlib.MeasureTheory.Constructions.Prod.Integral
import Mathlib.MeasureTheory.Integral.CircleIntegral
#align_import measure_theory.integral.torus_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
variable {n : ℕ}
variable {E : Type*} [NormedAddCommGroup E]
noncomputable section
open Complex Set MeasureTheory Function Filter TopologicalSpace
open scoped Real
-- Porting note: notation copied from `./DivergenceTheorem`
local macro:arg t:term:max noWs "ⁿ⁺¹" : term => `(Fin (n + 1) → $t)
local macro:arg t:term:max noWs "ⁿ" : term => `(Fin n → $t)
local macro:arg t:term:max noWs "⁰" : term => `(Fin 0 → $t)
local macro:arg t:term:max noWs "¹" : term => `(Fin 1 → $t)
def torusMap (c : ℂⁿ) (R : ℝⁿ) : ℝⁿ → ℂⁿ := fun θ i => c i + R i * exp (θ i * I)
#align torus_map torusMap
theorem torusMap_sub_center (c : ℂⁿ) (R : ℝⁿ) (θ : ℝⁿ) : torusMap c R θ - c = torusMap 0 R θ := by
ext1 i; simp [torusMap]
#align torus_map_sub_center torusMap_sub_center
theorem torusMap_eq_center_iff {c : ℂⁿ} {R : ℝⁿ} {θ : ℝⁿ} : torusMap c R θ = c ↔ R = 0 := by
simp [funext_iff, torusMap, exp_ne_zero]
#align torus_map_eq_center_iff torusMap_eq_center_iff
@[simp]
theorem torusMap_zero_radius (c : ℂⁿ) : torusMap c 0 = const ℝⁿ c :=
funext fun _ ↦ torusMap_eq_center_iff.2 rfl
#align torus_map_zero_radius torusMap_zero_radius
def TorusIntegrable (f : ℂⁿ → E) (c : ℂⁿ) (R : ℝⁿ) : Prop :=
IntegrableOn (fun θ : ℝⁿ => f (torusMap c R θ)) (Icc (0 : ℝⁿ) fun _ => 2 * π) volume
#align torus_integrable TorusIntegrable
namespace TorusIntegrable
-- Porting note (#11215): TODO: restore notation; `neg`, `add` etc fail if I use notation here
variable {f g : (Fin n → ℂ) → E} {c : Fin n → ℂ} {R : Fin n → ℝ}
theorem torusIntegrable_const (a : E) (c : ℂⁿ) (R : ℝⁿ) : TorusIntegrable (fun _ => a) c R := by
simp [TorusIntegrable, measure_Icc_lt_top]
#align torus_integrable.torus_integrable_const TorusIntegrable.torusIntegrable_const
protected nonrec theorem neg (hf : TorusIntegrable f c R) : TorusIntegrable (-f) c R := hf.neg
#align torus_integrable.neg TorusIntegrable.neg
protected nonrec theorem add (hf : TorusIntegrable f c R) (hg : TorusIntegrable g c R) :
TorusIntegrable (f + g) c R :=
hf.add hg
#align torus_integrable.add TorusIntegrable.add
protected nonrec theorem sub (hf : TorusIntegrable f c R) (hg : TorusIntegrable g c R) :
TorusIntegrable (f - g) c R :=
hf.sub hg
#align torus_integrable.sub TorusIntegrable.sub
| Mathlib/MeasureTheory/Integral/TorusIntegral.lean | 133 | 135 | theorem torusIntegrable_zero_radius {f : ℂⁿ → E} {c : ℂⁿ} : TorusIntegrable f c 0 := by |
rw [TorusIntegrable, torusMap_zero_radius]
apply torusIntegrable_const (f c) c 0
|
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import topology.metric_space.hausdorff_distance from "leanprover-community/mathlib"@"bc91ed7093bf098d253401e69df601fc33dde156"
noncomputable section
open NNReal ENNReal Topology Set Filter Bornology
universe u v w
variable {ι : Sort*} {α : Type u} {β : Type v}
namespace Metric
section Cthickening
variable [PseudoEMetricSpace α] {δ ε : ℝ} {s t : Set α} {x : α}
open EMetric
def cthickening (δ : ℝ) (E : Set α) : Set α :=
{ x : α | infEdist x E ≤ ENNReal.ofReal δ }
#align metric.cthickening Metric.cthickening
@[simp]
theorem mem_cthickening_iff : x ∈ cthickening δ s ↔ infEdist x s ≤ ENNReal.ofReal δ :=
Iff.rfl
#align metric.mem_cthickening_iff Metric.mem_cthickening_iff
lemma eventually_not_mem_cthickening_of_infEdist_pos {E : Set α} {x : α} (h : x ∉ closure E) :
∀ᶠ δ in 𝓝 (0 : ℝ), x ∉ Metric.cthickening δ E := by
obtain ⟨ε, ⟨ε_pos, ε_lt⟩⟩ := exists_real_pos_lt_infEdist_of_not_mem_closure h
filter_upwards [eventually_lt_nhds ε_pos] with δ hδ
simp only [cthickening, mem_setOf_eq, not_le]
exact ((ofReal_lt_ofReal_iff ε_pos).mpr hδ).trans ε_lt
theorem mem_cthickening_of_edist_le (x y : α) (δ : ℝ) (E : Set α) (h : y ∈ E)
(h' : edist x y ≤ ENNReal.ofReal δ) : x ∈ cthickening δ E :=
(infEdist_le_edist_of_mem h).trans h'
#align metric.mem_cthickening_of_edist_le Metric.mem_cthickening_of_edist_le
theorem mem_cthickening_of_dist_le {α : Type*} [PseudoMetricSpace α] (x y : α) (δ : ℝ) (E : Set α)
(h : y ∈ E) (h' : dist x y ≤ δ) : x ∈ cthickening δ E := by
apply mem_cthickening_of_edist_le x y δ E h
rw [edist_dist]
exact ENNReal.ofReal_le_ofReal h'
#align metric.mem_cthickening_of_dist_le Metric.mem_cthickening_of_dist_le
theorem cthickening_eq_preimage_infEdist (δ : ℝ) (E : Set α) :
cthickening δ E = (fun x => infEdist x E) ⁻¹' Iic (ENNReal.ofReal δ) :=
rfl
#align metric.cthickening_eq_preimage_inf_edist Metric.cthickening_eq_preimage_infEdist
theorem isClosed_cthickening {δ : ℝ} {E : Set α} : IsClosed (cthickening δ E) :=
IsClosed.preimage continuous_infEdist isClosed_Iic
#align metric.is_closed_cthickening Metric.isClosed_cthickening
@[simp]
theorem cthickening_empty (δ : ℝ) : cthickening δ (∅ : Set α) = ∅ := by
simp only [cthickening, ENNReal.ofReal_ne_top, setOf_false, infEdist_empty, top_le_iff]
#align metric.cthickening_empty Metric.cthickening_empty
theorem cthickening_of_nonpos {δ : ℝ} (hδ : δ ≤ 0) (E : Set α) : cthickening δ E = closure E := by
ext x
simp [mem_closure_iff_infEdist_zero, cthickening, ENNReal.ofReal_eq_zero.2 hδ]
#align metric.cthickening_of_nonpos Metric.cthickening_of_nonpos
@[simp]
theorem cthickening_zero (E : Set α) : cthickening 0 E = closure E :=
cthickening_of_nonpos le_rfl E
#align metric.cthickening_zero Metric.cthickening_zero
theorem cthickening_max_zero (δ : ℝ) (E : Set α) : cthickening (max 0 δ) E = cthickening δ E := by
cases le_total δ 0 <;> simp [cthickening_of_nonpos, *]
#align metric.cthickening_max_zero Metric.cthickening_max_zero
theorem cthickening_mono {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
cthickening δ₁ E ⊆ cthickening δ₂ E :=
preimage_mono (Iic_subset_Iic.mpr (ENNReal.ofReal_le_ofReal hle))
#align metric.cthickening_mono Metric.cthickening_mono
@[simp]
theorem cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) {δ : ℝ} (hδ : 0 ≤ δ) :
cthickening δ ({x} : Set α) = closedBall x δ := by
ext y
simp [cthickening, edist_dist, ENNReal.ofReal_le_ofReal_iff hδ]
#align metric.cthickening_singleton Metric.cthickening_singleton
theorem closedBall_subset_cthickening_singleton {α : Type*} [PseudoMetricSpace α] (x : α) (δ : ℝ) :
closedBall x δ ⊆ cthickening δ ({x} : Set α) := by
rcases lt_or_le δ 0 with (hδ | hδ)
· simp only [closedBall_eq_empty.mpr hδ, empty_subset]
· simp only [cthickening_singleton x hδ, Subset.rfl]
#align metric.closed_ball_subset_cthickening_singleton Metric.closedBall_subset_cthickening_singleton
theorem cthickening_subset_of_subset (δ : ℝ) {E₁ E₂ : Set α} (h : E₁ ⊆ E₂) :
cthickening δ E₁ ⊆ cthickening δ E₂ := fun _ hx => le_trans (infEdist_anti h) hx
#align metric.cthickening_subset_of_subset Metric.cthickening_subset_of_subset
theorem cthickening_subset_thickening {δ₁ : ℝ≥0} {δ₂ : ℝ} (hlt : (δ₁ : ℝ) < δ₂) (E : Set α) :
cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx =>
hx.out.trans_lt ((ENNReal.ofReal_lt_ofReal_iff (lt_of_le_of_lt δ₁.prop hlt)).mpr hlt)
#align metric.cthickening_subset_thickening Metric.cthickening_subset_thickening
theorem cthickening_subset_thickening' {δ₁ δ₂ : ℝ} (δ₂_pos : 0 < δ₂) (hlt : δ₁ < δ₂) (E : Set α) :
cthickening δ₁ E ⊆ thickening δ₂ E := fun _ hx =>
lt_of_le_of_lt hx.out ((ENNReal.ofReal_lt_ofReal_iff δ₂_pos).mpr hlt)
#align metric.cthickening_subset_thickening' Metric.cthickening_subset_thickening'
theorem thickening_subset_cthickening (δ : ℝ) (E : Set α) : thickening δ E ⊆ cthickening δ E := by
intro x hx
rw [thickening, mem_setOf_eq] at hx
exact hx.le
#align metric.thickening_subset_cthickening Metric.thickening_subset_cthickening
theorem thickening_subset_cthickening_of_le {δ₁ δ₂ : ℝ} (hle : δ₁ ≤ δ₂) (E : Set α) :
thickening δ₁ E ⊆ cthickening δ₂ E :=
(thickening_subset_cthickening δ₁ E).trans (cthickening_mono hle E)
#align metric.thickening_subset_cthickening_of_le Metric.thickening_subset_cthickening_of_le
theorem _root_.Bornology.IsBounded.cthickening {α : Type*} [PseudoMetricSpace α] {δ : ℝ} {E : Set α}
(h : IsBounded E) : IsBounded (cthickening δ E) := by
have : IsBounded (thickening (max (δ + 1) 1) E) := h.thickening
apply this.subset
exact cthickening_subset_thickening' (zero_lt_one.trans_le (le_max_right _ _))
((lt_add_one _).trans_le (le_max_left _ _)) _
#align metric.bounded.cthickening Bornology.IsBounded.cthickening
protected theorem _root_.IsCompact.cthickening
{α : Type*} [PseudoMetricSpace α] [ProperSpace α] {s : Set α}
(hs : IsCompact s) {r : ℝ} : IsCompact (cthickening r s) :=
isCompact_of_isClosed_isBounded isClosed_cthickening hs.isBounded.cthickening
theorem thickening_subset_interior_cthickening (δ : ℝ) (E : Set α) :
thickening δ E ⊆ interior (cthickening δ E) :=
(subset_interior_iff_isOpen.mpr isOpen_thickening).trans
(interior_mono (thickening_subset_cthickening δ E))
#align metric.thickening_subset_interior_cthickening Metric.thickening_subset_interior_cthickening
theorem closure_thickening_subset_cthickening (δ : ℝ) (E : Set α) :
closure (thickening δ E) ⊆ cthickening δ E :=
(closure_mono (thickening_subset_cthickening δ E)).trans isClosed_cthickening.closure_subset
#align metric.closure_thickening_subset_cthickening Metric.closure_thickening_subset_cthickening
theorem closure_subset_cthickening (δ : ℝ) (E : Set α) : closure E ⊆ cthickening δ E := by
rw [← cthickening_of_nonpos (min_le_right δ 0)]
exact cthickening_mono (min_le_left δ 0) E
#align metric.closure_subset_cthickening Metric.closure_subset_cthickening
theorem closure_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) :
closure E ⊆ thickening δ E := by
rw [← cthickening_zero]
exact cthickening_subset_thickening' δ_pos δ_pos E
#align metric.closure_subset_thickening Metric.closure_subset_thickening
theorem self_subset_thickening {δ : ℝ} (δ_pos : 0 < δ) (E : Set α) : E ⊆ thickening δ E :=
(@subset_closure _ E).trans (closure_subset_thickening δ_pos E)
#align metric.self_subset_thickening Metric.self_subset_thickening
theorem self_subset_cthickening {δ : ℝ} (E : Set α) : E ⊆ cthickening δ E :=
subset_closure.trans (closure_subset_cthickening δ E)
#align metric.self_subset_cthickening Metric.self_subset_cthickening
theorem thickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : thickening δ E ∈ 𝓝ˢ E :=
isOpen_thickening.mem_nhdsSet.2 <| self_subset_thickening hδ E
#align metric.thickening_mem_nhds_set Metric.thickening_mem_nhdsSet
theorem cthickening_mem_nhdsSet (E : Set α) {δ : ℝ} (hδ : 0 < δ) : cthickening δ E ∈ 𝓝ˢ E :=
mem_of_superset (thickening_mem_nhdsSet E hδ) (thickening_subset_cthickening _ _)
#align metric.cthickening_mem_nhds_set Metric.cthickening_mem_nhdsSet
@[simp]
theorem thickening_union (δ : ℝ) (s t : Set α) :
thickening δ (s ∪ t) = thickening δ s ∪ thickening δ t := by
simp_rw [thickening, infEdist_union, inf_eq_min, min_lt_iff, setOf_or]
#align metric.thickening_union Metric.thickening_union
@[simp]
theorem cthickening_union (δ : ℝ) (s t : Set α) :
cthickening δ (s ∪ t) = cthickening δ s ∪ cthickening δ t := by
simp_rw [cthickening, infEdist_union, inf_eq_min, min_le_iff, setOf_or]
#align metric.cthickening_union Metric.cthickening_union
@[simp]
theorem thickening_iUnion (δ : ℝ) (f : ι → Set α) :
thickening δ (⋃ i, f i) = ⋃ i, thickening δ (f i) := by
simp_rw [thickening, infEdist_iUnion, iInf_lt_iff, setOf_exists]
#align metric.thickening_Union Metric.thickening_iUnion
lemma thickening_biUnion {ι : Type*} (δ : ℝ) (f : ι → Set α) (I : Set ι) :
thickening δ (⋃ i ∈ I, f i) = ⋃ i ∈ I, thickening δ (f i) := by simp only [thickening_iUnion]
theorem ediam_cthickening_le (ε : ℝ≥0) :
EMetric.diam (cthickening ε s) ≤ EMetric.diam s + 2 * ε := by
refine diam_le fun x hx y hy => ENNReal.le_of_forall_pos_le_add fun δ hδ _ => ?_
rw [mem_cthickening_iff, ENNReal.ofReal_coe_nnreal] at hx hy
have hε : (ε : ℝ≥0∞) < ε + δ := ENNReal.coe_lt_coe.2 (lt_add_of_pos_right _ hδ)
replace hx := hx.trans_lt hε
obtain ⟨x', hx', hxx'⟩ := infEdist_lt_iff.mp hx
calc
edist x y ≤ edist x x' + edist y x' := edist_triangle_right _ _ _
_ ≤ ε + δ + (infEdist y s + EMetric.diam s) :=
add_le_add hxx'.le (edist_le_infEdist_add_ediam hx')
_ ≤ ε + δ + (ε + EMetric.diam s) := add_le_add_left (add_le_add_right hy _) _
_ = _ := by rw [two_mul]; ac_rfl
#align metric.ediam_cthickening_le Metric.ediam_cthickening_le
theorem ediam_thickening_le (ε : ℝ≥0) : EMetric.diam (thickening ε s) ≤ EMetric.diam s + 2 * ε :=
(EMetric.diam_mono <| thickening_subset_cthickening _ _).trans <| ediam_cthickening_le _
#align metric.ediam_thickening_le Metric.ediam_thickening_le
theorem diam_cthickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) :
diam (cthickening ε s) ≤ diam s + 2 * ε := by
lift ε to ℝ≥0 using hε
refine (toReal_le_add' (ediam_cthickening_le _) ?_ ?_).trans_eq ?_
· exact fun h ↦ top_unique <| h ▸ EMetric.diam_mono (self_subset_cthickening _)
· simp [mul_eq_top]
· simp [diam]
#align metric.diam_cthickening_le Metric.diam_cthickening_le
theorem diam_thickening_le {α : Type*} [PseudoMetricSpace α] (s : Set α) (hε : 0 ≤ ε) :
diam (thickening ε s) ≤ diam s + 2 * ε := by
by_cases hs : IsBounded s
· exact (diam_mono (thickening_subset_cthickening _ _) hs.cthickening).trans
(diam_cthickening_le _ hε)
obtain rfl | hε := hε.eq_or_lt
· simp [thickening_of_nonpos, diam_nonneg]
· rw [diam_eq_zero_of_unbounded (mt (IsBounded.subset · <| self_subset_thickening hε _) hs)]
positivity
#align metric.diam_thickening_le Metric.diam_thickening_le
@[simp]
theorem thickening_closure : thickening δ (closure s) = thickening δ s := by
simp_rw [thickening, infEdist_closure]
#align metric.thickening_closure Metric.thickening_closure
@[simp]
theorem cthickening_closure : cthickening δ (closure s) = cthickening δ s := by
simp_rw [cthickening, infEdist_closure]
#align metric.cthickening_closure Metric.cthickening_closure
open ENNReal
theorem _root_.Disjoint.exists_thickenings (hst : Disjoint s t) (hs : IsCompact s)
(ht : IsClosed t) :
∃ δ, 0 < δ ∧ Disjoint (thickening δ s) (thickening δ t) := by
obtain ⟨r, hr, h⟩ := exists_pos_forall_lt_edist hs ht hst
refine ⟨r / 2, half_pos (NNReal.coe_pos.2 hr), ?_⟩
rw [disjoint_iff_inf_le]
rintro z ⟨hzs, hzt⟩
rw [mem_thickening_iff_exists_edist_lt] at hzs hzt
rw [← NNReal.coe_two, ← NNReal.coe_div, ENNReal.ofReal_coe_nnreal] at hzs hzt
obtain ⟨x, hx, hzx⟩ := hzs
obtain ⟨y, hy, hzy⟩ := hzt
refine (h x hx y hy).not_le ?_
calc
edist x y ≤ edist z x + edist z y := edist_triangle_left _ _ _
_ ≤ ↑(r / 2) + ↑(r / 2) := add_le_add hzx.le hzy.le
_ = r := by rw [← ENNReal.coe_add, add_halves]
#align disjoint.exists_thickenings Disjoint.exists_thickenings
theorem _root_.Disjoint.exists_cthickenings (hst : Disjoint s t) (hs : IsCompact s)
(ht : IsClosed t) :
∃ δ, 0 < δ ∧ Disjoint (cthickening δ s) (cthickening δ t) := by
obtain ⟨δ, hδ, h⟩ := hst.exists_thickenings hs ht
refine ⟨δ / 2, half_pos hδ, h.mono ?_ ?_⟩ <;>
exact cthickening_subset_thickening' hδ (half_lt_self hδ) _
#align disjoint.exists_cthickenings Disjoint.exists_cthickenings
theorem _root_.IsCompact.exists_cthickening_subset_open (hs : IsCompact s) (ht : IsOpen t)
(hst : s ⊆ t) :
∃ δ, 0 < δ ∧ cthickening δ s ⊆ t :=
(hst.disjoint_compl_right.exists_cthickenings hs ht.isClosed_compl).imp fun _ h =>
⟨h.1, disjoint_compl_right_iff_subset.1 <| h.2.mono_right <| self_subset_cthickening _⟩
#align is_compact.exists_cthickening_subset_open IsCompact.exists_cthickening_subset_open
theorem _root_.IsCompact.exists_isCompact_cthickening [LocallyCompactSpace α] (hs : IsCompact s) :
∃ δ, 0 < δ ∧ IsCompact (cthickening δ s) := by
rcases exists_compact_superset hs with ⟨K, K_compact, hK⟩
rcases hs.exists_cthickening_subset_open isOpen_interior hK with ⟨δ, δpos, hδ⟩
refine ⟨δ, δpos, ?_⟩
exact K_compact.of_isClosed_subset isClosed_cthickening (hδ.trans interior_subset)
theorem _root_.IsCompact.exists_thickening_subset_open (hs : IsCompact s) (ht : IsOpen t)
(hst : s ⊆ t) : ∃ δ, 0 < δ ∧ thickening δ s ⊆ t :=
let ⟨δ, h₀, hδ⟩ := hs.exists_cthickening_subset_open ht hst
⟨δ, h₀, (thickening_subset_cthickening _ _).trans hδ⟩
#align is_compact.exists_thickening_subset_open IsCompact.exists_thickening_subset_open
theorem hasBasis_nhdsSet_thickening {K : Set α} (hK : IsCompact K) :
(𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => thickening δ K :=
(hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_thickening_subset_open hU.1 hU.2)
fun _ => thickening_mem_nhdsSet K
#align metric.has_basis_nhds_set_thickening Metric.hasBasis_nhdsSet_thickening
theorem hasBasis_nhdsSet_cthickening {K : Set α} (hK : IsCompact K) :
(𝓝ˢ K).HasBasis (fun δ : ℝ => 0 < δ) fun δ => cthickening δ K :=
(hasBasis_nhdsSet K).to_hasBasis' (fun _U hU => hK.exists_cthickening_subset_open hU.1 hU.2)
fun _ => cthickening_mem_nhdsSet K
#align metric.has_basis_nhds_set_cthickening Metric.hasBasis_nhdsSet_cthickening
| Mathlib/Topology/MetricSpace/Thickening.lean | 495 | 508 | theorem cthickening_eq_iInter_cthickening' {δ : ℝ} (s : Set ℝ) (hsδ : s ⊆ Ioi δ)
(hs : ∀ ε, δ < ε → (s ∩ Ioc δ ε).Nonempty) (E : Set α) :
cthickening δ E = ⋂ ε ∈ s, cthickening ε E := by |
apply Subset.antisymm
· exact subset_iInter₂ fun _ hε => cthickening_mono (le_of_lt (hsδ hε)) E
· unfold cthickening
intro x hx
simp only [mem_iInter, mem_setOf_eq] at *
apply ENNReal.le_of_forall_pos_le_add
intro η η_pos _
rcases hs (δ + η) (lt_add_of_pos_right _ (NNReal.coe_pos.mpr η_pos)) with ⟨ε, ⟨hsε, hε⟩⟩
apply ((hx ε hsε).trans (ENNReal.ofReal_le_ofReal hε.2)).trans
rw [ENNReal.coe_nnreal_eq η]
exact ENNReal.ofReal_add_le
|
import Mathlib.NumberTheory.Cyclotomic.Discriminant
import Mathlib.RingTheory.Polynomial.Eisenstein.IsIntegral
import Mathlib.RingTheory.Ideal.Norm
#align_import number_theory.cyclotomic.rat from "leanprover-community/mathlib"@"b353176c24d96c23f0ce1cc63efc3f55019702d9"
universe u
open Algebra IsCyclotomicExtension Polynomial NumberField
open scoped Cyclotomic Nat
variable {p : ℕ+} {k : ℕ} {K : Type u} [Field K] [CharZero K] {ζ : K} [hp : Fact (p : ℕ).Prime]
section PowerBasis
open IsCyclotomicExtension.Rat
section absdiscr
namespace IsCyclotomicExtension.Rat
open nonZeroDivisors IsPrimitiveRoot
variable (K p k)
| Mathlib/NumberTheory/Cyclotomic/Rat.lean | 544 | 561 | theorem absdiscr_prime_pow [NumberField K] [IsCyclotomicExtension {p ^ k} ℚ K] :
NumberField.discr K =
(-1) ^ ((p ^ k : ℕ).totient / 2) * p ^ ((p : ℕ) ^ (k - 1) * ((p - 1) * k - 1)) := by |
have hζ := IsCyclotomicExtension.zeta_spec (p ^ k) ℚ K
let pB₁ := integralPowerBasis hζ
apply (algebraMap ℤ ℚ).injective_int
rw [← NumberField.discr_eq_discr _ pB₁.basis, ← Algebra.discr_localizationLocalization ℤ ℤ⁰ K]
convert IsCyclotomicExtension.discr_prime_pow hζ (cyclotomic.irreducible_rat (p ^ k).2) using 1
· have : pB₁.dim = (IsPrimitiveRoot.powerBasis ℚ hζ).dim := by
rw [← PowerBasis.finrank, ← PowerBasis.finrank]
exact RingOfIntegers.rank K
rw [← Algebra.discr_reindex _ _ (finCongr this)]
congr 1
ext i
simp_rw [Function.comp_apply, Basis.localizationLocalization_apply, powerBasis_dim,
PowerBasis.coe_basis, pB₁, integralPowerBasis_gen]
convert ← ((IsPrimitiveRoot.powerBasis ℚ hζ).basis_eq_pow i).symm using 1
· simp_rw [algebraMap_int_eq, map_mul, map_pow, map_neg, map_one, map_natCast]
|
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Group.Pi.Basic
import Mathlib.Order.Fin
import Mathlib.Order.PiLex
import Mathlib.Order.Interval.Set.Basic
#align_import data.fin.tuple.basic from "leanprover-community/mathlib"@"ef997baa41b5c428be3fb50089a7139bf4ee886b"
assert_not_exists MonoidWithZero
universe u v
namespace Fin
variable {m n : ℕ}
open Function
section Tuple
example (α : Fin 0 → Sort u) : Unique (∀ i : Fin 0, α i) := by infer_instance
theorem tuple0_le {α : Fin 0 → Type*} [∀ i, Preorder (α i)] (f g : ∀ i, α i) : f ≤ g :=
finZeroElim
#align fin.tuple0_le Fin.tuple0_le
variable {α : Fin (n + 1) → Type u} (x : α 0) (q : ∀ i, α i) (p : ∀ i : Fin n, α i.succ) (i : Fin n)
(y : α i.succ) (z : α 0)
def tail (q : ∀ i, α i) : ∀ i : Fin n, α i.succ := fun i ↦ q i.succ
#align fin.tail Fin.tail
theorem tail_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} :
(tail fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q k.succ :=
rfl
#align fin.tail_def Fin.tail_def
def cons (x : α 0) (p : ∀ i : Fin n, α i.succ) : ∀ i, α i := fun j ↦ Fin.cases x p j
#align fin.cons Fin.cons
@[simp]
theorem tail_cons : tail (cons x p) = p := by
simp (config := { unfoldPartialApp := true }) [tail, cons]
#align fin.tail_cons Fin.tail_cons
@[simp]
theorem cons_succ : cons x p i.succ = p i := by simp [cons]
#align fin.cons_succ Fin.cons_succ
@[simp]
theorem cons_zero : cons x p 0 = x := by simp [cons]
#align fin.cons_zero Fin.cons_zero
@[simp]
theorem cons_one {α : Fin (n + 2) → Type*} (x : α 0) (p : ∀ i : Fin n.succ, α i.succ) :
cons x p 1 = p 0 := by
rw [← cons_succ x p]; rfl
@[simp]
theorem cons_update : cons x (update p i y) = update (cons x p) i.succ y := by
ext j
by_cases h : j = 0
· rw [h]
simp [Ne.symm (succ_ne_zero i)]
· let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this, cons_succ]
by_cases h' : j' = i
· rw [h']
simp
· have : j'.succ ≠ i.succ := by rwa [Ne, succ_inj]
rw [update_noteq h', update_noteq this, cons_succ]
#align fin.cons_update Fin.cons_update
theorem cons_injective2 : Function.Injective2 (@cons n α) := fun x₀ y₀ x y h ↦
⟨congr_fun h 0, funext fun i ↦ by simpa using congr_fun h (Fin.succ i)⟩
#align fin.cons_injective2 Fin.cons_injective2
@[simp]
theorem cons_eq_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} :
cons x₀ x = cons y₀ y ↔ x₀ = y₀ ∧ x = y :=
cons_injective2.eq_iff
#align fin.cons_eq_cons Fin.cons_eq_cons
theorem cons_left_injective (x : ∀ i : Fin n, α i.succ) : Function.Injective fun x₀ ↦ cons x₀ x :=
cons_injective2.left _
#align fin.cons_left_injective Fin.cons_left_injective
theorem cons_right_injective (x₀ : α 0) : Function.Injective (cons x₀) :=
cons_injective2.right _
#align fin.cons_right_injective Fin.cons_right_injective
theorem update_cons_zero : update (cons x p) 0 z = cons z p := by
ext j
by_cases h : j = 0
· rw [h]
simp
· simp only [h, update_noteq, Ne, not_false_iff]
let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this, cons_succ, cons_succ]
#align fin.update_cons_zero Fin.update_cons_zero
@[simp, nolint simpNF] -- Porting note: linter claims LHS doesn't simplify
theorem cons_self_tail : cons (q 0) (tail q) = q := by
ext j
by_cases h : j = 0
· rw [h]
simp
· let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this]
unfold tail
rw [cons_succ]
#align fin.cons_self_tail Fin.cons_self_tail
-- Porting note: Mathport removes `_root_`?
@[elab_as_elim]
def consCases {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x))
(x : ∀ i : Fin n.succ, α i) : P x :=
_root_.cast (by rw [cons_self_tail]) <| h (x 0) (tail x)
#align fin.cons_cases Fin.consCases
@[simp]
theorem consCases_cons {P : (∀ i : Fin n.succ, α i) → Sort v} (h : ∀ x₀ x, P (Fin.cons x₀ x))
(x₀ : α 0) (x : ∀ i : Fin n, α i.succ) : @consCases _ _ _ h (cons x₀ x) = h x₀ x := by
rw [consCases, cast_eq]
congr
#align fin.cons_cases_cons Fin.consCases_cons
@[elab_as_elim]
def consInduction {α : Type*} {P : ∀ {n : ℕ}, (Fin n → α) → Sort v} (h0 : P Fin.elim0)
(h : ∀ {n} (x₀) (x : Fin n → α), P x → P (Fin.cons x₀ x)) : ∀ {n : ℕ} (x : Fin n → α), P x
| 0, x => by convert h0
| n + 1, x => consCases (fun x₀ x ↦ h _ _ <| consInduction h0 h _) x
#align fin.cons_induction Fin.consInductionₓ -- Porting note: universes
theorem cons_injective_of_injective {α} {x₀ : α} {x : Fin n → α} (hx₀ : x₀ ∉ Set.range x)
(hx : Function.Injective x) : Function.Injective (cons x₀ x : Fin n.succ → α) := by
refine Fin.cases ?_ ?_
· refine Fin.cases ?_ ?_
· intro
rfl
· intro j h
rw [cons_zero, cons_succ] at h
exact hx₀.elim ⟨_, h.symm⟩
· intro i
refine Fin.cases ?_ ?_
· intro h
rw [cons_zero, cons_succ] at h
exact hx₀.elim ⟨_, h⟩
· intro j h
rw [cons_succ, cons_succ] at h
exact congr_arg _ (hx h)
#align fin.cons_injective_of_injective Fin.cons_injective_of_injective
theorem cons_injective_iff {α} {x₀ : α} {x : Fin n → α} :
Function.Injective (cons x₀ x : Fin n.succ → α) ↔ x₀ ∉ Set.range x ∧ Function.Injective x := by
refine ⟨fun h ↦ ⟨?_, ?_⟩, fun h ↦ cons_injective_of_injective h.1 h.2⟩
· rintro ⟨i, hi⟩
replace h := @h i.succ 0
simp [hi, succ_ne_zero] at h
· simpa [Function.comp] using h.comp (Fin.succ_injective _)
#align fin.cons_injective_iff Fin.cons_injective_iff
@[simp]
theorem forall_fin_zero_pi {α : Fin 0 → Sort*} {P : (∀ i, α i) → Prop} :
(∀ x, P x) ↔ P finZeroElim :=
⟨fun h ↦ h _, fun h x ↦ Subsingleton.elim finZeroElim x ▸ h⟩
#align fin.forall_fin_zero_pi Fin.forall_fin_zero_pi
@[simp]
theorem exists_fin_zero_pi {α : Fin 0 → Sort*} {P : (∀ i, α i) → Prop} :
(∃ x, P x) ↔ P finZeroElim :=
⟨fun ⟨x, h⟩ ↦ Subsingleton.elim x finZeroElim ▸ h, fun h ↦ ⟨_, h⟩⟩
#align fin.exists_fin_zero_pi Fin.exists_fin_zero_pi
theorem forall_fin_succ_pi {P : (∀ i, α i) → Prop} : (∀ x, P x) ↔ ∀ a v, P (Fin.cons a v) :=
⟨fun h a v ↦ h (Fin.cons a v), consCases⟩
#align fin.forall_fin_succ_pi Fin.forall_fin_succ_pi
theorem exists_fin_succ_pi {P : (∀ i, α i) → Prop} : (∃ x, P x) ↔ ∃ a v, P (Fin.cons a v) :=
⟨fun ⟨x, h⟩ ↦ ⟨x 0, tail x, (cons_self_tail x).symm ▸ h⟩, fun ⟨_, _, h⟩ ↦ ⟨_, h⟩⟩
#align fin.exists_fin_succ_pi Fin.exists_fin_succ_pi
@[simp]
theorem tail_update_zero : tail (update q 0 z) = tail q := by
ext j
simp [tail, Fin.succ_ne_zero]
#align fin.tail_update_zero Fin.tail_update_zero
@[simp]
theorem tail_update_succ : tail (update q i.succ y) = update (tail q) i y := by
ext j
by_cases h : j = i
· rw [h]
simp [tail]
· simp [tail, (Fin.succ_injective n).ne h, h]
#align fin.tail_update_succ Fin.tail_update_succ
theorem comp_cons {α : Type*} {β : Type*} (g : α → β) (y : α) (q : Fin n → α) :
g ∘ cons y q = cons (g y) (g ∘ q) := by
ext j
by_cases h : j = 0
· rw [h]
rfl
· let j' := pred j h
have : j'.succ = j := succ_pred j h
rw [← this, cons_succ, comp_apply, comp_apply, cons_succ]
#align fin.comp_cons Fin.comp_cons
theorem comp_tail {α : Type*} {β : Type*} (g : α → β) (q : Fin n.succ → α) :
g ∘ tail q = tail (g ∘ q) := by
ext j
simp [tail]
#align fin.comp_tail Fin.comp_tail
theorem le_cons [∀ i, Preorder (α i)] {x : α 0} {q : ∀ i, α i} {p : ∀ i : Fin n, α i.succ} :
q ≤ cons x p ↔ q 0 ≤ x ∧ tail q ≤ p :=
forall_fin_succ.trans <| and_congr Iff.rfl <| forall_congr' fun j ↦ by simp [tail]
#align fin.le_cons Fin.le_cons
theorem cons_le [∀ i, Preorder (α i)] {x : α 0} {q : ∀ i, α i} {p : ∀ i : Fin n, α i.succ} :
cons x p ≤ q ↔ x ≤ q 0 ∧ p ≤ tail q :=
@le_cons _ (fun i ↦ (α i)ᵒᵈ) _ x q p
#align fin.cons_le Fin.cons_le
theorem cons_le_cons [∀ i, Preorder (α i)] {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ} :
cons x₀ x ≤ cons y₀ y ↔ x₀ ≤ y₀ ∧ x ≤ y :=
forall_fin_succ.trans <| and_congr_right' <| by simp only [cons_succ, Pi.le_def]
#align fin.cons_le_cons Fin.cons_le_cons
theorem pi_lex_lt_cons_cons {x₀ y₀ : α 0} {x y : ∀ i : Fin n, α i.succ}
(s : ∀ {i : Fin n.succ}, α i → α i → Prop) :
Pi.Lex (· < ·) (@s) (Fin.cons x₀ x) (Fin.cons y₀ y) ↔
s x₀ y₀ ∨ x₀ = y₀ ∧ Pi.Lex (· < ·) (@fun i : Fin n ↦ @s i.succ) x y := by
simp_rw [Pi.Lex, Fin.exists_fin_succ, Fin.cons_succ, Fin.cons_zero, Fin.forall_fin_succ]
simp [and_assoc, exists_and_left]
#align fin.pi_lex_lt_cons_cons Fin.pi_lex_lt_cons_cons
theorem range_fin_succ {α} (f : Fin (n + 1) → α) :
Set.range f = insert (f 0) (Set.range (Fin.tail f)) :=
Set.ext fun _ ↦ exists_fin_succ.trans <| eq_comm.or Iff.rfl
#align fin.range_fin_succ Fin.range_fin_succ
@[simp]
theorem range_cons {α : Type*} {n : ℕ} (x : α) (b : Fin n → α) :
Set.range (Fin.cons x b : Fin n.succ → α) = insert x (Set.range b) := by
rw [range_fin_succ, cons_zero, tail_cons]
#align fin.range_cons Fin.range_cons
section TupleRight
-- Porting note: `i.castSucc` does not work like it did in Lean 3;
-- `(castSucc i)` must be used.
variable {α : Fin (n + 1) → Type u} (x : α (last n)) (q : ∀ i, α i)
(p : ∀ i : Fin n, α (castSucc i)) (i : Fin n) (y : α (castSucc i)) (z : α (last n))
def init (q : ∀ i, α i) (i : Fin n) : α (castSucc i) :=
q (castSucc i)
#align fin.init Fin.init
theorem init_def {n : ℕ} {α : Fin (n + 1) → Type*} {q : ∀ i, α i} :
(init fun k : Fin (n + 1) ↦ q k) = fun k : Fin n ↦ q (castSucc k) :=
rfl
#align fin.init_def Fin.init_def
def snoc (p : ∀ i : Fin n, α (castSucc i)) (x : α (last n)) (i : Fin (n + 1)) : α i :=
if h : i.val < n then _root_.cast (by rw [Fin.castSucc_castLT i h]) (p (castLT i h))
else _root_.cast (by rw [eq_last_of_not_lt h]) x
#align fin.snoc Fin.snoc
@[simp]
theorem init_snoc : init (snoc p x) = p := by
ext i
simp only [init, snoc, coe_castSucc, is_lt, cast_eq, dite_true]
convert cast_eq rfl (p i)
#align fin.init_snoc Fin.init_snoc
@[simp]
theorem snoc_castSucc : snoc p x (castSucc i) = p i := by
simp only [snoc, coe_castSucc, is_lt, cast_eq, dite_true]
convert cast_eq rfl (p i)
#align fin.snoc_cast_succ Fin.snoc_castSucc
@[simp]
theorem snoc_comp_castSucc {n : ℕ} {α : Sort _} {a : α} {f : Fin n → α} :
(snoc f a : Fin (n + 1) → α) ∘ castSucc = f :=
funext fun i ↦ by rw [Function.comp_apply, snoc_castSucc]
#align fin.snoc_comp_cast_succ Fin.snoc_comp_castSucc
@[simp]
| Mathlib/Data/Fin/Tuple/Basic.lean | 512 | 512 | theorem snoc_last : snoc p x (last n) = x := by | simp [snoc]
|
import Mathlib.Data.Set.Card
import Mathlib.Order.Minimal
import Mathlib.Data.Matroid.Init
set_option autoImplicit true
open Set
def Matroid.ExchangeProperty {α : Type _} (P : Set α → Prop) : Prop :=
∀ X Y, P X → P Y → ∀ a ∈ X \ Y, ∃ b ∈ Y \ X, P (insert b (X \ {a}))
def Matroid.ExistsMaximalSubsetProperty {α : Type _} (P : Set α → Prop) (X : Set α) : Prop :=
∀ I, P I → I ⊆ X → (maximals (· ⊆ ·) {Y | P Y ∧ I ⊆ Y ∧ Y ⊆ X}).Nonempty
@[ext] structure Matroid (α : Type _) where
(E : Set α)
(Base : Set α → Prop)
(Indep : Set α → Prop)
(indep_iff' : ∀ ⦃I⦄, Indep I ↔ ∃ B, Base B ∧ I ⊆ B)
(exists_base : ∃ B, Base B)
(base_exchange : Matroid.ExchangeProperty Base)
(maximality : ∀ X, X ⊆ E → Matroid.ExistsMaximalSubsetProperty Indep X)
(subset_ground : ∀ B, Base B → B ⊆ E)
namespace Matroid
variable {α : Type*} {M : Matroid α}
protected class Finite (M : Matroid α) : Prop where
(ground_finite : M.E.Finite)
protected class Nonempty (M : Matroid α) : Prop where
(ground_nonempty : M.E.Nonempty)
theorem ground_nonempty (M : Matroid α) [M.Nonempty] : M.E.Nonempty :=
Nonempty.ground_nonempty
theorem ground_nonempty_iff (M : Matroid α) : M.E.Nonempty ↔ M.Nonempty :=
⟨fun h ↦ ⟨h⟩, fun ⟨h⟩ ↦ h⟩
theorem ground_finite (M : Matroid α) [M.Finite] : M.E.Finite :=
Finite.ground_finite
theorem set_finite (M : Matroid α) [M.Finite] (X : Set α) (hX : X ⊆ M.E := by aesop) : X.Finite :=
M.ground_finite.subset hX
instance finite_of_finite [Finite α] {M : Matroid α} : M.Finite :=
⟨Set.toFinite _⟩
class FiniteRk (M : Matroid α) : Prop where
exists_finite_base : ∃ B, M.Base B ∧ B.Finite
instance finiteRk_of_finite (M : Matroid α) [M.Finite] : FiniteRk M :=
⟨M.exists_base.imp (fun B hB ↦ ⟨hB, M.set_finite B (M.subset_ground _ hB)⟩)⟩
class InfiniteRk (M : Matroid α) : Prop where
exists_infinite_base : ∃ B, M.Base B ∧ B.Infinite
class RkPos (M : Matroid α) : Prop where
empty_not_base : ¬M.Base ∅
theorem rkPos_iff_empty_not_base : M.RkPos ↔ ¬M.Base ∅ :=
⟨fun ⟨h⟩ ↦ h, fun h ↦ ⟨h⟩⟩
section exchange
section Basis
def Basis (M : Matroid α) (I X : Set α) : Prop :=
I ∈ maximals (· ⊆ ·) {A | M.Indep A ∧ A ⊆ X} ∧ X ⊆ M.E
def Basis' (M : Matroid α) (I X : Set α) : Prop :=
I ∈ maximals (· ⊆ ·) {A | M.Indep A ∧ A ⊆ X}
theorem Basis'.indep (hI : M.Basis' I X) : M.Indep I :=
hI.1.1
theorem Basis.indep (hI : M.Basis I X) : M.Indep I :=
hI.1.1.1
theorem Basis.subset (hI : M.Basis I X) : I ⊆ X :=
hI.1.1.2
theorem Basis.basis' (hI : M.Basis I X) : M.Basis' I X :=
hI.1
theorem Basis'.basis (hI : M.Basis' I X) (hX : X ⊆ M.E := by aesop_mat) : M.Basis I X :=
⟨hI, hX⟩
theorem Basis'.subset (hI : M.Basis' I X) : I ⊆ X :=
hI.1.2
theorem setOf_basis_eq (M : Matroid α) (hX : X ⊆ M.E := by aesop_mat) :
{I | M.Basis I X} = maximals (· ⊆ ·) ({I | M.Indep I} ∩ Iic X) := by
ext I; simp [Matroid.Basis, maximals, iff_true_intro hX]
@[aesop unsafe 15% (rule_sets := [Matroid])]
theorem Basis.subset_ground (hI : M.Basis I X) : X ⊆ M.E :=
hI.2
theorem Basis.basis_inter_ground (hI : M.Basis I X) : M.Basis I (X ∩ M.E) := by
convert hI
rw [inter_eq_self_of_subset_left hI.subset_ground]
@[aesop unsafe 15% (rule_sets := [Matroid])]
theorem Basis.left_subset_ground (hI : M.Basis I X) : I ⊆ M.E :=
hI.indep.subset_ground
theorem Basis.eq_of_subset_indep (hI : M.Basis I X) (hJ : M.Indep J) (hIJ : I ⊆ J) (hJX : J ⊆ X) :
I = J :=
hIJ.antisymm (hI.1.2 ⟨hJ, hJX⟩ hIJ)
theorem Basis.Finite (hI : M.Basis I X) [FiniteRk M] : I.Finite := hI.indep.finite
theorem basis_iff' :
M.Basis I X ↔ (M.Indep I ∧ I ⊆ X ∧ ∀ J, M.Indep J → I ⊆ J → J ⊆ X → I = J) ∧ X ⊆ M.E := by
simp [Basis, mem_maximals_setOf_iff, and_assoc, and_congr_left_iff, and_imp,
and_congr_left_iff, and_congr_right_iff, @Imp.swap (_ ⊆ X)]
theorem basis_iff (hX : X ⊆ M.E := by aesop_mat) :
M.Basis I X ↔ (M.Indep I ∧ I ⊆ X ∧ ∀ J, M.Indep J → I ⊆ J → J ⊆ X → I = J) := by
rw [basis_iff', and_iff_left hX]
theorem basis'_iff_basis_inter_ground : M.Basis' I X ↔ M.Basis I (X ∩ M.E) := by
rw [Basis', Basis, and_iff_left inter_subset_right]
convert Iff.rfl using 3
ext I
simp only [subset_inter_iff, mem_setOf_eq, and_congr_right_iff, and_iff_left_iff_imp]
exact fun h _ ↦ h.subset_ground
theorem basis'_iff_basis (hX : X ⊆ M.E := by aesop_mat) : M.Basis' I X ↔ M.Basis I X := by
rw [basis'_iff_basis_inter_ground, inter_eq_self_of_subset_left hX]
theorem basis_iff_basis'_subset_ground : M.Basis I X ↔ M.Basis' I X ∧ X ⊆ M.E :=
⟨fun h ↦ ⟨h.basis', h.subset_ground⟩, fun h ↦ (basis'_iff_basis h.2).mp h.1⟩
theorem Basis'.basis_inter_ground (hIX : M.Basis' I X) : M.Basis I (X ∩ M.E) :=
basis'_iff_basis_inter_ground.mp hIX
theorem Basis'.eq_of_subset_indep (hI : M.Basis' I X) (hJ : M.Indep J) (hIJ : I ⊆ J)
(hJX : J ⊆ X) : I = J :=
hIJ.antisymm (hI.2 ⟨hJ, hJX⟩ hIJ)
theorem Basis'.insert_not_indep (hI : M.Basis' I X) (he : e ∈ X \ I) : ¬ M.Indep (insert e I) :=
fun hi ↦ he.2 <| insert_eq_self.1 <| Eq.symm <|
hI.eq_of_subset_indep hi (subset_insert _ _) (insert_subset he.1 hI.subset)
theorem basis_iff_mem_maximals (hX : X ⊆ M.E := by aesop_mat):
M.Basis I X ↔ I ∈ maximals (· ⊆ ·) {I | M.Indep I ∧ I ⊆ X} := by
rw [Basis, and_iff_left hX]
theorem basis_iff_mem_maximals_Prop (hX : X ⊆ M.E := by aesop_mat):
M.Basis I X ↔ I ∈ maximals (· ⊆ ·) (fun I ↦ M.Indep I ∧ I ⊆ X) :=
basis_iff_mem_maximals
theorem Indep.basis_of_maximal_subset (hI : M.Indep I) (hIX : I ⊆ X)
(hmax : ∀ ⦃J⦄, M.Indep J → I ⊆ J → J ⊆ X → J ⊆ I) (hX : X ⊆ M.E := by aesop_mat) :
M.Basis I X := by
rw [basis_iff (by aesop_mat : X ⊆ M.E), and_iff_right hI, and_iff_right hIX]
exact fun J hJ hIJ hJX ↦ hIJ.antisymm (hmax hJ hIJ hJX)
theorem Basis.basis_subset (hI : M.Basis I X) (hIY : I ⊆ Y) (hYX : Y ⊆ X) : M.Basis I Y := by
rw [basis_iff (hYX.trans hI.subset_ground), and_iff_right hI.indep, and_iff_right hIY]
exact fun J hJ hIJ hJY ↦ hI.eq_of_subset_indep hJ hIJ (hJY.trans hYX)
@[simp] theorem basis_self_iff_indep : M.Basis I I ↔ M.Indep I := by
rw [basis_iff', and_iff_right rfl.subset, and_assoc, and_iff_left_iff_imp]
exact fun hi ↦ ⟨fun _ _ ↦ subset_antisymm, hi.subset_ground⟩
theorem Indep.basis_self (h : M.Indep I) : M.Basis I I :=
basis_self_iff_indep.mpr h
@[simp] theorem basis_empty_iff (M : Matroid α) : M.Basis I ∅ ↔ I = ∅ :=
⟨fun h ↦ subset_empty_iff.mp h.subset, fun h ↦ by (rw [h]; exact M.empty_indep.basis_self)⟩
theorem Basis.dep_of_ssubset (hI : M.Basis I X) (hIY : I ⊂ Y) (hYX : Y ⊆ X) : M.Dep Y := by
have : X ⊆ M.E := hI.subset_ground
rw [← not_indep_iff]
exact fun hY ↦ hIY.ne (hI.eq_of_subset_indep hY hIY.subset hYX)
theorem Basis.insert_dep (hI : M.Basis I X) (he : e ∈ X \ I) : M.Dep (insert e I) :=
hI.dep_of_ssubset (ssubset_insert he.2) (insert_subset he.1 hI.subset)
theorem Basis.mem_of_insert_indep (hI : M.Basis I X) (he : e ∈ X) (hIe : M.Indep (insert e I)) :
e ∈ I :=
by_contra (fun heI ↦ (hI.insert_dep ⟨he, heI⟩).not_indep hIe)
theorem Basis'.mem_of_insert_indep (hI : M.Basis' I X) (he : e ∈ X) (hIe : M.Indep (insert e I)) :
e ∈ I :=
hI.basis_inter_ground.mem_of_insert_indep ⟨he, hIe.subset_ground (mem_insert _ _)⟩ hIe
theorem Basis.not_basis_of_ssubset (hI : M.Basis I X) (hJI : J ⊂ I) : ¬ M.Basis J X :=
fun h ↦ hJI.ne (h.eq_of_subset_indep hI.indep hJI.subset hI.subset)
theorem Indep.subset_basis_of_subset (hI : M.Indep I) (hIX : I ⊆ X) (hX : X ⊆ M.E := by aesop_mat) :
∃ J, M.Basis J X ∧ I ⊆ J := by
obtain ⟨J, ⟨(hJ : M.Indep J),hIJ,hJX⟩, hJmax⟩ := M.maximality X hX I hI hIX
use J
rw [and_iff_left hIJ, basis_iff, and_iff_right hJ, and_iff_right hJX]
exact fun K hK hJK hKX ↦ hJK.antisymm (hJmax ⟨hK, hIJ.trans hJK, hKX⟩ hJK)
theorem Indep.subset_basis'_of_subset (hI : M.Indep I) (hIX : I ⊆ X) :
∃ J, M.Basis' J X ∧ I ⊆ J := by
simp_rw [basis'_iff_basis_inter_ground]
exact hI.subset_basis_of_subset (subset_inter hIX hI.subset_ground)
theorem exists_basis (M : Matroid α) (X : Set α) (hX : X ⊆ M.E := by aesop_mat) :
∃ I, M.Basis I X :=
let ⟨_, hI, _⟩ := M.empty_indep.subset_basis_of_subset (empty_subset X)
⟨_,hI⟩
theorem exists_basis' (M : Matroid α) (X : Set α) : ∃ I, M.Basis' I X :=
let ⟨_, hI, _⟩ := M.empty_indep.subset_basis'_of_subset (empty_subset X)
⟨_,hI⟩
theorem exists_basis_subset_basis (M : Matroid α) (hXY : X ⊆ Y) (hY : Y ⊆ M.E := by aesop_mat) :
∃ I J, M.Basis I X ∧ M.Basis J Y ∧ I ⊆ J := by
obtain ⟨I, hI⟩ := M.exists_basis X (hXY.trans hY)
obtain ⟨J, hJ, hIJ⟩ := hI.indep.subset_basis_of_subset (hI.subset.trans hXY)
exact ⟨_, _, hI, hJ, hIJ⟩
theorem Basis.exists_basis_inter_eq_of_superset (hI : M.Basis I X) (hXY : X ⊆ Y)
(hY : Y ⊆ M.E := by aesop_mat) : ∃ J, M.Basis J Y ∧ J ∩ X = I := by
obtain ⟨J, hJ, hIJ⟩ := hI.indep.subset_basis_of_subset (hI.subset.trans hXY)
refine ⟨J, hJ, subset_antisymm ?_ (subset_inter hIJ hI.subset)⟩
exact fun e he ↦ hI.mem_of_insert_indep he.2 (hJ.indep.subset (insert_subset he.1 hIJ))
theorem exists_basis_union_inter_basis (M : Matroid α) (X Y : Set α) (hX : X ⊆ M.E := by aesop_mat)
(hY : Y ⊆ M.E := by aesop_mat) : ∃ I, M.Basis I (X ∪ Y) ∧ M.Basis (I ∩ Y) Y :=
let ⟨J, hJ⟩ := M.exists_basis Y
(hJ.exists_basis_inter_eq_of_superset subset_union_right).imp
(fun I hI ↦ ⟨hI.1, by rwa [hI.2]⟩)
theorem Indep.eq_of_basis (hI : M.Indep I) (hJ : M.Basis J I) : J = I :=
hJ.eq_of_subset_indep hI hJ.subset rfl.subset
theorem Basis.exists_base (hI : M.Basis I X) : ∃ B, M.Base B ∧ I = B ∩ X :=
let ⟨B,hB, hIB⟩ := hI.indep.exists_base_superset
⟨B, hB, subset_antisymm (subset_inter hIB hI.subset)
(by rw [hI.eq_of_subset_indep (hB.indep.inter_right X) (subset_inter hIB hI.subset)
inter_subset_right])⟩
@[simp] theorem basis_ground_iff : M.Basis B M.E ↔ M.Base B := by
rw [base_iff_maximal_indep, basis_iff', and_assoc, and_congr_right]
rw [and_iff_left (rfl.subset : M.E ⊆ M.E)]
exact fun h ↦ ⟨fun h' I hI hBI ↦ h'.2 _ hI hBI hI.subset_ground,
fun h' ↦ ⟨h.subset_ground,fun J hJ hBJ _ ↦ h' J hJ hBJ⟩⟩
theorem Base.basis_ground (hB : M.Base B) : M.Basis B M.E :=
basis_ground_iff.mpr hB
theorem Indep.basis_iff_forall_insert_dep (hI : M.Indep I) (hIX : I ⊆ X) :
M.Basis I X ↔ ∀ e ∈ X \ I, M.Dep (insert e I) := by
rw [basis_iff', and_iff_right hIX, and_iff_right hI]
refine ⟨fun h e he ↦ ⟨fun hi ↦ he.2 ?_, insert_subset (h.2 he.1) hI.subset_ground⟩,
fun h ↦ ⟨fun J hJ hIJ hJX ↦ hIJ.antisymm (fun e heJ ↦ by_contra (fun heI ↦ ?_)), ?_⟩⟩
· exact (h.1 _ hi (subset_insert _ _) (insert_subset he.1 hIX)).symm.subset (mem_insert e I)
· exact (h e ⟨hJX heJ, heI⟩).not_indep (hJ.subset (insert_subset heJ hIJ))
rw [← diff_union_of_subset hIX, union_subset_iff, and_iff_left hI.subset_ground]
exact fun e he ↦ (h e he).subset_ground (mem_insert _ _)
theorem Indep.basis_of_forall_insert (hI : M.Indep I) (hIX : I ⊆ X)
(he : ∀ e ∈ X \ I, M.Dep (insert e I)) : M.Basis I X :=
(hI.basis_iff_forall_insert_dep hIX).mpr he
theorem Indep.basis_insert_iff (hI : M.Indep I) :
M.Basis I (insert e I) ↔ M.Dep (insert e I) ∨ e ∈ I := by
simp_rw [hI.basis_iff_forall_insert_dep (subset_insert _ _), dep_iff, insert_subset_iff,
and_iff_left hI.subset_ground, mem_diff, mem_insert_iff, or_and_right, and_not_self,
or_false, and_imp, forall_eq]
tauto
theorem Basis.iUnion_basis_iUnion {ι : Type _} (X I : ι → Set α) (hI : ∀ i, M.Basis (I i) (X i))
(h_ind : M.Indep (⋃ i, I i)) : M.Basis (⋃ i, I i) (⋃ i, X i) := by
refine h_ind.basis_of_forall_insert
(iUnion_subset (fun i ↦ (hI i).subset.trans (subset_iUnion _ _))) ?_
rintro e ⟨⟨_, ⟨⟨i, hi, rfl⟩, (hes : e ∈ X i)⟩⟩, he'⟩
rw [mem_iUnion, not_exists] at he'
refine ((hI i).insert_dep ⟨hes, he' _⟩).superset (insert_subset_insert (subset_iUnion _ _)) ?_
rw [insert_subset_iff, iUnion_subset_iff, and_iff_left (fun i ↦ (hI i).indep.subset_ground)]
exact (hI i).subset_ground hes
| Mathlib/Data/Matroid/Basic.lean | 907 | 910 | theorem Basis.basis_iUnion {ι : Type _} [Nonempty ι] (X : ι → Set α)
(hI : ∀ i, M.Basis I (X i)) : M.Basis I (⋃ i, X i) := by |
convert Basis.iUnion_basis_iUnion X (fun _ ↦ I) (fun i ↦ hI i) _ <;> rw [iUnion_const]
exact (hI (Classical.arbitrary ι)).indep
|
import Mathlib.Topology.Constructions
#align_import topology.continuous_on from "leanprover-community/mathlib"@"d4f691b9e5f94cfc64639973f3544c95f8d5d494"
open Set Filter Function Topology Filter
variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
variable [TopologicalSpace α]
@[simp]
theorem nhds_bind_nhdsWithin {a : α} {s : Set α} : ((𝓝 a).bind fun x => 𝓝[s] x) = 𝓝[s] a :=
bind_inf_principal.trans <| congr_arg₂ _ nhds_bind_nhds rfl
#align nhds_bind_nhds_within nhds_bind_nhdsWithin
@[simp]
theorem eventually_nhds_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝 a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x :=
Filter.ext_iff.1 nhds_bind_nhdsWithin { x | p x }
#align eventually_nhds_nhds_within eventually_nhds_nhdsWithin
theorem eventually_nhdsWithin_iff {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ x in 𝓝[s] a, p x) ↔ ∀ᶠ x in 𝓝 a, x ∈ s → p x :=
eventually_inf_principal
#align eventually_nhds_within_iff eventually_nhdsWithin_iff
theorem frequently_nhdsWithin_iff {z : α} {s : Set α} {p : α → Prop} :
(∃ᶠ x in 𝓝[s] z, p x) ↔ ∃ᶠ x in 𝓝 z, p x ∧ x ∈ s :=
frequently_inf_principal.trans <| by simp only [and_comm]
#align frequently_nhds_within_iff frequently_nhdsWithin_iff
theorem mem_closure_ne_iff_frequently_within {z : α} {s : Set α} :
z ∈ closure (s \ {z}) ↔ ∃ᶠ x in 𝓝[≠] z, x ∈ s := by
simp [mem_closure_iff_frequently, frequently_nhdsWithin_iff]
#align mem_closure_ne_iff_frequently_within mem_closure_ne_iff_frequently_within
@[simp]
theorem eventually_nhdsWithin_nhdsWithin {a : α} {s : Set α} {p : α → Prop} :
(∀ᶠ y in 𝓝[s] a, ∀ᶠ x in 𝓝[s] y, p x) ↔ ∀ᶠ x in 𝓝[s] a, p x := by
refine ⟨fun h => ?_, fun h => (eventually_nhds_nhdsWithin.2 h).filter_mono inf_le_left⟩
simp only [eventually_nhdsWithin_iff] at h ⊢
exact h.mono fun x hx hxs => (hx hxs).self_of_nhds hxs
#align eventually_nhds_within_nhds_within eventually_nhdsWithin_nhdsWithin
theorem nhdsWithin_eq (a : α) (s : Set α) :
𝓝[s] a = ⨅ t ∈ { t : Set α | a ∈ t ∧ IsOpen t }, 𝓟 (t ∩ s) :=
((nhds_basis_opens a).inf_principal s).eq_biInf
#align nhds_within_eq nhdsWithin_eq
theorem nhdsWithin_univ (a : α) : 𝓝[Set.univ] a = 𝓝 a := by
rw [nhdsWithin, principal_univ, inf_top_eq]
#align nhds_within_univ nhdsWithin_univ
theorem nhdsWithin_hasBasis {p : β → Prop} {s : β → Set α} {a : α} (h : (𝓝 a).HasBasis p s)
(t : Set α) : (𝓝[t] a).HasBasis p fun i => s i ∩ t :=
h.inf_principal t
#align nhds_within_has_basis nhdsWithin_hasBasis
theorem nhdsWithin_basis_open (a : α) (t : Set α) :
(𝓝[t] a).HasBasis (fun u => a ∈ u ∧ IsOpen u) fun u => u ∩ t :=
nhdsWithin_hasBasis (nhds_basis_opens a) t
#align nhds_within_basis_open nhdsWithin_basis_open
theorem mem_nhdsWithin {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u, IsOpen u ∧ a ∈ u ∧ u ∩ s ⊆ t := by
simpa only [and_assoc, and_left_comm] using (nhdsWithin_basis_open a s).mem_iff
#align mem_nhds_within mem_nhdsWithin
theorem mem_nhdsWithin_iff_exists_mem_nhds_inter {t : Set α} {a : α} {s : Set α} :
t ∈ 𝓝[s] a ↔ ∃ u ∈ 𝓝 a, u ∩ s ⊆ t :=
(nhdsWithin_hasBasis (𝓝 a).basis_sets s).mem_iff
#align mem_nhds_within_iff_exists_mem_nhds_inter mem_nhdsWithin_iff_exists_mem_nhds_inter
theorem diff_mem_nhdsWithin_compl {x : α} {s : Set α} (hs : s ∈ 𝓝 x) (t : Set α) :
s \ t ∈ 𝓝[tᶜ] x :=
diff_mem_inf_principal_compl hs t
#align diff_mem_nhds_within_compl diff_mem_nhdsWithin_compl
theorem diff_mem_nhdsWithin_diff {x : α} {s t : Set α} (hs : s ∈ 𝓝[t] x) (t' : Set α) :
s \ t' ∈ 𝓝[t \ t'] x := by
rw [nhdsWithin, diff_eq, diff_eq, ← inf_principal, ← inf_assoc]
exact inter_mem_inf hs (mem_principal_self _)
#align diff_mem_nhds_within_diff diff_mem_nhdsWithin_diff
theorem nhds_of_nhdsWithin_of_nhds {s t : Set α} {a : α} (h1 : s ∈ 𝓝 a) (h2 : t ∈ 𝓝[s] a) :
t ∈ 𝓝 a := by
rcases mem_nhdsWithin_iff_exists_mem_nhds_inter.mp h2 with ⟨_, Hw, hw⟩
exact (𝓝 a).sets_of_superset ((𝓝 a).inter_sets Hw h1) hw
#align nhds_of_nhds_within_of_nhds nhds_of_nhdsWithin_of_nhds
theorem mem_nhdsWithin_iff_eventually {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ ∀ᶠ y in 𝓝 x, y ∈ s → y ∈ t :=
eventually_inf_principal
#align mem_nhds_within_iff_eventually mem_nhdsWithin_iff_eventually
theorem mem_nhdsWithin_iff_eventuallyEq {s t : Set α} {x : α} :
t ∈ 𝓝[s] x ↔ s =ᶠ[𝓝 x] (s ∩ t : Set α) := by
simp_rw [mem_nhdsWithin_iff_eventually, eventuallyEq_set, mem_inter_iff, iff_self_and]
#align mem_nhds_within_iff_eventually_eq mem_nhdsWithin_iff_eventuallyEq
theorem nhdsWithin_eq_iff_eventuallyEq {s t : Set α} {x : α} : 𝓝[s] x = 𝓝[t] x ↔ s =ᶠ[𝓝 x] t :=
set_eventuallyEq_iff_inf_principal.symm
#align nhds_within_eq_iff_eventually_eq nhdsWithin_eq_iff_eventuallyEq
theorem nhdsWithin_le_iff {s t : Set α} {x : α} : 𝓝[s] x ≤ 𝓝[t] x ↔ t ∈ 𝓝[s] x :=
set_eventuallyLE_iff_inf_principal_le.symm.trans set_eventuallyLE_iff_mem_inf_principal
#align nhds_within_le_iff nhdsWithin_le_iff
-- Porting note: golfed, dropped an unneeded assumption
theorem preimage_nhdsWithin_coinduced' {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝[t] a := by
lift a to t using h
replace hs : (fun x : t => π x) ⁻¹' s ∈ 𝓝 a := preimage_nhds_coinduced hs
rwa [← map_nhds_subtype_val, mem_map]
#align preimage_nhds_within_coinduced' preimage_nhdsWithin_coinduced'ₓ
theorem mem_nhdsWithin_of_mem_nhds {s t : Set α} {a : α} (h : s ∈ 𝓝 a) : s ∈ 𝓝[t] a :=
mem_inf_of_left h
#align mem_nhds_within_of_mem_nhds mem_nhdsWithin_of_mem_nhds
theorem self_mem_nhdsWithin {a : α} {s : Set α} : s ∈ 𝓝[s] a :=
mem_inf_of_right (mem_principal_self s)
#align self_mem_nhds_within self_mem_nhdsWithin
theorem eventually_mem_nhdsWithin {a : α} {s : Set α} : ∀ᶠ x in 𝓝[s] a, x ∈ s :=
self_mem_nhdsWithin
#align eventually_mem_nhds_within eventually_mem_nhdsWithin
theorem inter_mem_nhdsWithin (s : Set α) {t : Set α} {a : α} (h : t ∈ 𝓝 a) : s ∩ t ∈ 𝓝[s] a :=
inter_mem self_mem_nhdsWithin (mem_inf_of_left h)
#align inter_mem_nhds_within inter_mem_nhdsWithin
theorem nhdsWithin_mono (a : α) {s t : Set α} (h : s ⊆ t) : 𝓝[s] a ≤ 𝓝[t] a :=
inf_le_inf_left _ (principal_mono.mpr h)
#align nhds_within_mono nhdsWithin_mono
theorem pure_le_nhdsWithin {a : α} {s : Set α} (ha : a ∈ s) : pure a ≤ 𝓝[s] a :=
le_inf (pure_le_nhds a) (le_principal_iff.2 ha)
#align pure_le_nhds_within pure_le_nhdsWithin
theorem mem_of_mem_nhdsWithin {a : α} {s t : Set α} (ha : a ∈ s) (ht : t ∈ 𝓝[s] a) : a ∈ t :=
pure_le_nhdsWithin ha ht
#align mem_of_mem_nhds_within mem_of_mem_nhdsWithin
theorem Filter.Eventually.self_of_nhdsWithin {p : α → Prop} {s : Set α} {x : α}
(h : ∀ᶠ y in 𝓝[s] x, p y) (hx : x ∈ s) : p x :=
mem_of_mem_nhdsWithin hx h
#align filter.eventually.self_of_nhds_within Filter.Eventually.self_of_nhdsWithin
theorem tendsto_const_nhdsWithin {l : Filter β} {s : Set α} {a : α} (ha : a ∈ s) :
Tendsto (fun _ : β => a) l (𝓝[s] a) :=
tendsto_const_pure.mono_right <| pure_le_nhdsWithin ha
#align tendsto_const_nhds_within tendsto_const_nhdsWithin
theorem nhdsWithin_restrict'' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝[s] a) :
𝓝[s] a = 𝓝[s ∩ t] a :=
le_antisymm (le_inf inf_le_left (le_principal_iff.mpr (inter_mem self_mem_nhdsWithin h)))
(inf_le_inf_left _ (principal_mono.mpr Set.inter_subset_left))
#align nhds_within_restrict'' nhdsWithin_restrict''
theorem nhdsWithin_restrict' {a : α} (s : Set α) {t : Set α} (h : t ∈ 𝓝 a) : 𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict'' s <| mem_inf_of_left h
#align nhds_within_restrict' nhdsWithin_restrict'
theorem nhdsWithin_restrict {a : α} (s : Set α) {t : Set α} (h₀ : a ∈ t) (h₁ : IsOpen t) :
𝓝[s] a = 𝓝[s ∩ t] a :=
nhdsWithin_restrict' s (IsOpen.mem_nhds h₁ h₀)
#align nhds_within_restrict nhdsWithin_restrict
theorem nhdsWithin_le_of_mem {a : α} {s t : Set α} (h : s ∈ 𝓝[t] a) : 𝓝[t] a ≤ 𝓝[s] a :=
nhdsWithin_le_iff.mpr h
#align nhds_within_le_of_mem nhdsWithin_le_of_mem
theorem nhdsWithin_le_nhds {a : α} {s : Set α} : 𝓝[s] a ≤ 𝓝 a := by
rw [← nhdsWithin_univ]
apply nhdsWithin_le_of_mem
exact univ_mem
#align nhds_within_le_nhds nhdsWithin_le_nhds
theorem nhdsWithin_eq_nhdsWithin' {a : α} {s t u : Set α} (hs : s ∈ 𝓝 a) (h₂ : t ∩ s = u ∩ s) :
𝓝[t] a = 𝓝[u] a := by rw [nhdsWithin_restrict' t hs, nhdsWithin_restrict' u hs, h₂]
#align nhds_within_eq_nhds_within' nhdsWithin_eq_nhdsWithin'
theorem nhdsWithin_eq_nhdsWithin {a : α} {s t u : Set α} (h₀ : a ∈ s) (h₁ : IsOpen s)
(h₂ : t ∩ s = u ∩ s) : 𝓝[t] a = 𝓝[u] a := by
rw [nhdsWithin_restrict t h₀ h₁, nhdsWithin_restrict u h₀ h₁, h₂]
#align nhds_within_eq_nhds_within nhdsWithin_eq_nhdsWithin
@[simp] theorem nhdsWithin_eq_nhds {a : α} {s : Set α} : 𝓝[s] a = 𝓝 a ↔ s ∈ 𝓝 a :=
inf_eq_left.trans le_principal_iff
#align nhds_within_eq_nhds nhdsWithin_eq_nhds
theorem IsOpen.nhdsWithin_eq {a : α} {s : Set α} (h : IsOpen s) (ha : a ∈ s) : 𝓝[s] a = 𝓝 a :=
nhdsWithin_eq_nhds.2 <| h.mem_nhds ha
#align is_open.nhds_within_eq IsOpen.nhdsWithin_eq
theorem preimage_nhds_within_coinduced {π : α → β} {s : Set β} {t : Set α} {a : α} (h : a ∈ t)
(ht : IsOpen t)
(hs : s ∈ @nhds β (.coinduced (fun x : t => π x) inferInstance) (π a)) :
π ⁻¹' s ∈ 𝓝 a := by
rw [← ht.nhdsWithin_eq h]
exact preimage_nhdsWithin_coinduced' h hs
#align preimage_nhds_within_coinduced preimage_nhds_within_coinduced
@[simp]
theorem nhdsWithin_empty (a : α) : 𝓝[∅] a = ⊥ := by rw [nhdsWithin, principal_empty, inf_bot_eq]
#align nhds_within_empty nhdsWithin_empty
theorem nhdsWithin_union (a : α) (s t : Set α) : 𝓝[s ∪ t] a = 𝓝[s] a ⊔ 𝓝[t] a := by
delta nhdsWithin
rw [← inf_sup_left, sup_principal]
#align nhds_within_union nhdsWithin_union
theorem nhdsWithin_biUnion {ι} {I : Set ι} (hI : I.Finite) (s : ι → Set α) (a : α) :
𝓝[⋃ i ∈ I, s i] a = ⨆ i ∈ I, 𝓝[s i] a :=
Set.Finite.induction_on hI (by simp) fun _ _ hT ↦ by
simp only [hT, nhdsWithin_union, iSup_insert, biUnion_insert]
#align nhds_within_bUnion nhdsWithin_biUnion
theorem nhdsWithin_sUnion {S : Set (Set α)} (hS : S.Finite) (a : α) :
𝓝[⋃₀ S] a = ⨆ s ∈ S, 𝓝[s] a := by
rw [sUnion_eq_biUnion, nhdsWithin_biUnion hS]
#align nhds_within_sUnion nhdsWithin_sUnion
| Mathlib/Topology/ContinuousOn.lean | 251 | 253 | theorem nhdsWithin_iUnion {ι} [Finite ι] (s : ι → Set α) (a : α) :
𝓝[⋃ i, s i] a = ⨆ i, 𝓝[s i] a := by |
rw [← sUnion_range, nhdsWithin_sUnion (finite_range s), iSup_range]
|
import Mathlib.Analysis.SpecialFunctions.Trigonometric.Arctan
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
#align_import geometry.euclidean.angle.unoriented.right_angle from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace InnerProductGeometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V]
theorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by
rw [norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
#align inner_product_geometry.norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two InnerProductGeometry.norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two
theorem norm_add_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :
‖x + y‖ * ‖x + y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
#align inner_product_geometry.norm_add_sq_eq_norm_sq_add_norm_sq' InnerProductGeometry.norm_add_sq_eq_norm_sq_add_norm_sq'
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ ↔ angle x y = π / 2 := by
rw [norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
#align inner_product_geometry.norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two InnerProductGeometry.norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two
theorem norm_sub_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = π / 2) :
‖x - y‖ * ‖x - y‖ = ‖x‖ * ‖x‖ + ‖y‖ * ‖y‖ :=
(norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
#align inner_product_geometry.norm_sub_sq_eq_norm_sq_add_norm_sq' InnerProductGeometry.norm_sub_sq_eq_norm_sq_add_norm_sq'
theorem angle_add_eq_arccos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x + y) = Real.arccos (‖x‖ / ‖x + y‖) := by
rw [angle, inner_add_right, h, add_zero, real_inner_self_eq_norm_mul_norm]
by_cases hx : ‖x‖ = 0; · simp [hx]
rw [div_mul_eq_div_div, mul_self_div_self]
#align inner_product_geometry.angle_add_eq_arccos_of_inner_eq_zero InnerProductGeometry.angle_add_eq_arccos_of_inner_eq_zero
theorem angle_add_eq_arcsin_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0 ∨ y ≠ 0) :
angle x (x + y) = Real.arcsin (‖y‖ / ‖x + y‖) := by
have hxy : ‖x + y‖ ^ 2 ≠ 0 := by
rw [pow_two, norm_add_sq_eq_norm_sq_add_norm_sq_real h, ne_comm]
refine ne_of_lt ?_
rcases h0 with (h0 | h0)
· exact
Left.add_pos_of_pos_of_nonneg (mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)
· exact
Left.add_pos_of_nonneg_of_pos (mul_self_nonneg _) (mul_self_pos.2 (norm_ne_zero_iff.2 h0))
rw [angle_add_eq_arccos_of_inner_eq_zero h,
Real.arccos_eq_arcsin (div_nonneg (norm_nonneg _) (norm_nonneg _)), div_pow, one_sub_div hxy]
nth_rw 1 [pow_two]
rw [norm_add_sq_eq_norm_sq_add_norm_sq_real h, pow_two, add_sub_cancel_left, ← pow_two, ← div_pow,
Real.sqrt_sq (div_nonneg (norm_nonneg _) (norm_nonneg _))]
#align inner_product_geometry.angle_add_eq_arcsin_of_inner_eq_zero InnerProductGeometry.angle_add_eq_arcsin_of_inner_eq_zero
theorem angle_add_eq_arctan_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x + y) = Real.arctan (‖y‖ / ‖x‖) := by
rw [angle_add_eq_arcsin_of_inner_eq_zero h (Or.inl h0), Real.arctan_eq_arcsin, ←
div_mul_eq_div_div, norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
nth_rw 3 [← Real.sqrt_sq (norm_nonneg x)]
rw_mod_cast [← Real.sqrt_mul (sq_nonneg _), div_pow, pow_two, pow_two, mul_add, mul_one, mul_div,
mul_comm (‖x‖ * ‖x‖), ← mul_div, div_self (mul_self_pos.2 (norm_ne_zero_iff.2 h0)).ne', mul_one]
#align inner_product_geometry.angle_add_eq_arctan_of_inner_eq_zero InnerProductGeometry.angle_add_eq_arctan_of_inner_eq_zero
theorem angle_add_pos_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x = 0 ∨ y ≠ 0) :
0 < angle x (x + y) := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_pos,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
by_cases hx : x = 0; · simp [hx]
rw [div_lt_one (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg (mul_self_pos.2
(norm_ne_zero_iff.2 hx)) (mul_self_nonneg _))), Real.lt_sqrt (norm_nonneg _), pow_two]
simpa [hx] using h0
#align inner_product_geometry.angle_add_pos_of_inner_eq_zero InnerProductGeometry.angle_add_pos_of_inner_eq_zero
theorem angle_add_le_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) :
angle x (x + y) ≤ π / 2 := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_le_pi_div_two]
exact div_nonneg (norm_nonneg _) (norm_nonneg _)
#align inner_product_geometry.angle_add_le_pi_div_two_of_inner_eq_zero InnerProductGeometry.angle_add_le_pi_div_two_of_inner_eq_zero
| Mathlib/Geometry/Euclidean/Angle/Unoriented/RightAngle.lean | 123 | 128 | theorem angle_add_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : ⟪x, y⟫ = 0) (h0 : x ≠ 0) :
angle x (x + y) < π / 2 := by |
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_lt_pi_div_two,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
exact div_pos (norm_pos_iff.2 h0) (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg
(mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)))
|
import Mathlib.Algebra.Algebra.Defs
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Sort
import Mathlib.Data.List.FinRange
import Mathlib.LinearAlgebra.Pi
import Mathlib.Logic.Equiv.Fintype
#align_import linear_algebra.multilinear.basic from "leanprover-community/mathlib"@"78fdf68dcd2fdb3fe64c0dd6f88926a49418a6ea"
open Function Fin Set
universe uR uS uι v v' v₁ v₂ v₃
variable {R : Type uR} {S : Type uS} {ι : Type uι} {n : ℕ}
{M : Fin n.succ → Type v} {M₁ : ι → Type v₁} {M₂ : Type v₂} {M₃ : Type v₃} {M' : Type v'}
structure MultilinearMap (R : Type uR) {ι : Type uι} (M₁ : ι → Type v₁) (M₂ : Type v₂) [Semiring R]
[∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂] [∀ i, Module R (M₁ i)] [Module R M₂] where
toFun : (∀ i, M₁ i) → M₂
map_add' :
∀ [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i),
toFun (update m i (x + y)) = toFun (update m i x) + toFun (update m i y)
map_smul' :
∀ [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (c : R) (x : M₁ i),
toFun (update m i (c • x)) = c • toFun (update m i x)
#align multilinear_map MultilinearMap
-- Porting note: added to avoid a linter timeout.
attribute [nolint simpNF] MultilinearMap.mk.injEq
namespace MultilinearMap
section Semiring
variable [Semiring R] [∀ i, AddCommMonoid (M i)] [∀ i, AddCommMonoid (M₁ i)] [AddCommMonoid M₂]
[AddCommMonoid M₃] [AddCommMonoid M'] [∀ i, Module R (M i)] [∀ i, Module R (M₁ i)] [Module R M₂]
[Module R M₃] [Module R M'] (f f' : MultilinearMap R M₁ M₂)
-- Porting note: Replaced CoeFun with FunLike instance
instance : FunLike (MultilinearMap R M₁ M₂) (∀ i, M₁ i) M₂ where
coe f := f.toFun
coe_injective' := fun f g h ↦ by cases f; cases g; cases h; rfl
initialize_simps_projections MultilinearMap (toFun → apply)
@[simp]
theorem toFun_eq_coe : f.toFun = ⇑f :=
rfl
#align multilinear_map.to_fun_eq_coe MultilinearMap.toFun_eq_coe
@[simp]
theorem coe_mk (f : (∀ i, M₁ i) → M₂) (h₁ h₂) : ⇑(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f :=
rfl
#align multilinear_map.coe_mk MultilinearMap.coe_mk
theorem congr_fun {f g : MultilinearMap R M₁ M₂} (h : f = g) (x : ∀ i, M₁ i) : f x = g x :=
DFunLike.congr_fun h x
#align multilinear_map.congr_fun MultilinearMap.congr_fun
nonrec theorem congr_arg (f : MultilinearMap R M₁ M₂) {x y : ∀ i, M₁ i} (h : x = y) : f x = f y :=
DFunLike.congr_arg f h
#align multilinear_map.congr_arg MultilinearMap.congr_arg
theorem coe_injective : Injective ((↑) : MultilinearMap R M₁ M₂ → (∀ i, M₁ i) → M₂) :=
DFunLike.coe_injective
#align multilinear_map.coe_injective MultilinearMap.coe_injective
@[norm_cast] -- Porting note (#10618): Removed simp attribute, simp can prove this
theorem coe_inj {f g : MultilinearMap R M₁ M₂} : (f : (∀ i, M₁ i) → M₂) = g ↔ f = g :=
DFunLike.coe_fn_eq
#align multilinear_map.coe_inj MultilinearMap.coe_inj
@[ext]
theorem ext {f f' : MultilinearMap R M₁ M₂} (H : ∀ x, f x = f' x) : f = f' :=
DFunLike.ext _ _ H
#align multilinear_map.ext MultilinearMap.ext
theorem ext_iff {f g : MultilinearMap R M₁ M₂} : f = g ↔ ∀ x, f x = g x :=
DFunLike.ext_iff
#align multilinear_map.ext_iff MultilinearMap.ext_iff
@[simp]
theorem mk_coe (f : MultilinearMap R M₁ M₂) (h₁ h₂) :
(⟨f, h₁, h₂⟩ : MultilinearMap R M₁ M₂) = f := rfl
#align multilinear_map.mk_coe MultilinearMap.mk_coe
@[simp]
protected theorem map_add [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (x y : M₁ i) :
f (update m i (x + y)) = f (update m i x) + f (update m i y) :=
f.map_add' m i x y
#align multilinear_map.map_add MultilinearMap.map_add
@[simp]
protected theorem map_smul [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) (c : R) (x : M₁ i) :
f (update m i (c • x)) = c • f (update m i x) :=
f.map_smul' m i c x
#align multilinear_map.map_smul MultilinearMap.map_smul
theorem map_coord_zero {m : ∀ i, M₁ i} (i : ι) (h : m i = 0) : f m = 0 := by
classical
have : (0 : R) • (0 : M₁ i) = 0 := by simp
rw [← update_eq_self i m, h, ← this, f.map_smul, zero_smul R (M := M₂)]
#align multilinear_map.map_coord_zero MultilinearMap.map_coord_zero
@[simp]
theorem map_update_zero [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) : f (update m i 0) = 0 :=
f.map_coord_zero i (update_same i 0 m)
#align multilinear_map.map_update_zero MultilinearMap.map_update_zero
@[simp]
theorem map_zero [Nonempty ι] : f 0 = 0 := by
obtain ⟨i, _⟩ : ∃ i : ι, i ∈ Set.univ := Set.exists_mem_of_nonempty ι
exact map_coord_zero f i rfl
#align multilinear_map.map_zero MultilinearMap.map_zero
instance : Add (MultilinearMap R M₁ M₂) :=
⟨fun f f' =>
⟨fun x => f x + f' x, fun m i x y => by simp [add_left_comm, add_assoc], fun m i c x => by
simp [smul_add]⟩⟩
@[simp]
theorem add_apply (m : ∀ i, M₁ i) : (f + f') m = f m + f' m :=
rfl
#align multilinear_map.add_apply MultilinearMap.add_apply
instance : Zero (MultilinearMap R M₁ M₂) :=
⟨⟨fun _ => 0, fun _ i _ _ => by simp, fun _ i c _ => by simp⟩⟩
instance : Inhabited (MultilinearMap R M₁ M₂) :=
⟨0⟩
@[simp]
theorem zero_apply (m : ∀ i, M₁ i) : (0 : MultilinearMap R M₁ M₂) m = 0 :=
rfl
#align multilinear_map.zero_apply MultilinearMap.zero_apply
instance addCommMonoid : AddCommMonoid (MultilinearMap R M₁ M₂) :=
coe_injective.addCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl
#align multilinear_map.add_comm_monoid MultilinearMap.addCommMonoid
@[simps] def coeAddMonoidHom : MultilinearMap R M₁ M₂ →+ (((i : ι) → M₁ i) → M₂) where
toFun := DFunLike.coe; map_zero' := rfl; map_add' _ _ := rfl
@[simp]
theorem coe_sum {α : Type*} (f : α → MultilinearMap R M₁ M₂) (s : Finset α) :
⇑(∑ a ∈ s, f a) = ∑ a ∈ s, ⇑(f a) :=
map_sum coeAddMonoidHom f s
theorem sum_apply {α : Type*} (f : α → MultilinearMap R M₁ M₂) (m : ∀ i, M₁ i) {s : Finset α} :
(∑ a ∈ s, f a) m = ∑ a ∈ s, f a m := by simp
#align multilinear_map.sum_apply MultilinearMap.sum_apply
@[simps]
def toLinearMap [DecidableEq ι] (m : ∀ i, M₁ i) (i : ι) : M₁ i →ₗ[R] M₂ where
toFun x := f (update m i x)
map_add' x y := by simp
map_smul' c x := by simp
#align multilinear_map.to_linear_map MultilinearMap.toLinearMap
#align multilinear_map.to_linear_map_to_add_hom_apply MultilinearMap.toLinearMap_apply
@[simps]
def prod (f : MultilinearMap R M₁ M₂) (g : MultilinearMap R M₁ M₃) :
MultilinearMap R M₁ (M₂ × M₃) where
toFun m := (f m, g m)
map_add' m i x y := by simp
map_smul' m i c x := by simp
#align multilinear_map.prod MultilinearMap.prod
#align multilinear_map.prod_apply MultilinearMap.prod_apply
@[simps]
def pi {ι' : Type*} {M' : ι' → Type*} [∀ i, AddCommMonoid (M' i)] [∀ i, Module R (M' i)]
(f : ∀ i, MultilinearMap R M₁ (M' i)) : MultilinearMap R M₁ (∀ i, M' i) where
toFun m i := f i m
map_add' _ _ _ _ := funext fun j => (f j).map_add _ _ _ _
map_smul' _ _ _ _ := funext fun j => (f j).map_smul _ _ _ _
#align multilinear_map.pi MultilinearMap.pi
#align multilinear_map.pi_apply MultilinearMap.pi_apply
section
variable (R M₂ M₃)
@[simps]
def ofSubsingleton [Subsingleton ι] (i : ι) :
(M₂ →ₗ[R] M₃) ≃ MultilinearMap R (fun _ : ι ↦ M₂) M₃ where
toFun f :=
{ toFun := fun x ↦ f (x i)
map_add' := by intros; simp [update_eq_const_of_subsingleton]
map_smul' := by intros; simp [update_eq_const_of_subsingleton] }
invFun f :=
{ toFun := fun x ↦ f fun _ ↦ x
map_add' := fun x y ↦ by simpa [update_eq_const_of_subsingleton] using f.map_add 0 i x y
map_smul' := fun c x ↦ by simpa [update_eq_const_of_subsingleton] using f.map_smul 0 i c x }
left_inv f := rfl
right_inv f := by ext x; refine congr_arg f ?_; exact (eq_const_of_subsingleton _ _).symm
#align multilinear_map.of_subsingleton MultilinearMap.ofSubsingletonₓ
#align multilinear_map.of_subsingleton_apply MultilinearMap.ofSubsingleton_apply_applyₓ
variable (M₁) {M₂}
-- Porting note: Removed [simps] & added simpNF-approved version of the generated lemma manually.
@[simps (config := .asFn)]
def constOfIsEmpty [IsEmpty ι] (m : M₂) : MultilinearMap R M₁ M₂ where
toFun := Function.const _ m
map_add' _ := isEmptyElim
map_smul' _ := isEmptyElim
#align multilinear_map.const_of_is_empty MultilinearMap.constOfIsEmpty
#align multilinear_map.const_of_is_empty_apply MultilinearMap.constOfIsEmpty_apply
end
-- Porting note: Included `DFunLike.coe` to avoid strange CoeFun instance for Equiv
def restr {k n : ℕ} (f : MultilinearMap R (fun _ : Fin n => M') M₂) (s : Finset (Fin n))
(hk : s.card = k) (z : M') : MultilinearMap R (fun _ : Fin k => M') M₂ where
toFun v := f fun j => if h : j ∈ s then v ((DFunLike.coe (s.orderIsoOfFin hk).symm) ⟨j, h⟩) else z
map_add' v i x y := by
have : DFunLike.coe (s.orderIsoOfFin hk).symm = (s.orderIsoOfFin hk).toEquiv.symm := rfl
simp only [this]
erw [dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv]
simp
map_smul' v i c x := by
have : DFunLike.coe (s.orderIsoOfFin hk).symm = (s.orderIsoOfFin hk).toEquiv.symm := rfl
simp only [this]
erw [dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv,
dite_comp_equiv_update (s.orderIsoOfFin hk).toEquiv]
simp
#align multilinear_map.restr MultilinearMap.restr
theorem cons_add (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M i.succ) (x y : M 0) :
f (cons (x + y) m) = f (cons x m) + f (cons y m) := by
simp_rw [← update_cons_zero x m (x + y), f.map_add, update_cons_zero]
#align multilinear_map.cons_add MultilinearMap.cons_add
theorem cons_smul (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M i.succ) (c : R) (x : M 0) :
f (cons (c • x) m) = c • f (cons x m) := by
simp_rw [← update_cons_zero x m (c • x), f.map_smul, update_cons_zero]
#align multilinear_map.cons_smul MultilinearMap.cons_smul
theorem snoc_add (f : MultilinearMap R M M₂)
(m : ∀ i : Fin n, M (castSucc i)) (x y : M (last n)) :
f (snoc m (x + y)) = f (snoc m x) + f (snoc m y) := by
simp_rw [← update_snoc_last x m (x + y), f.map_add, update_snoc_last]
#align multilinear_map.snoc_add MultilinearMap.snoc_add
theorem snoc_smul (f : MultilinearMap R M M₂) (m : ∀ i : Fin n, M (castSucc i)) (c : R)
(x : M (last n)) : f (snoc m (c • x)) = c • f (snoc m x) := by
simp_rw [← update_snoc_last x m (c • x), f.map_smul, update_snoc_last]
#align multilinear_map.snoc_smul MultilinearMap.snoc_smul
section
variable {M₁' : ι → Type*} [∀ i, AddCommMonoid (M₁' i)] [∀ i, Module R (M₁' i)]
variable {M₁'' : ι → Type*} [∀ i, AddCommMonoid (M₁'' i)] [∀ i, Module R (M₁'' i)]
def compLinearMap (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i →ₗ[R] M₁' i) :
MultilinearMap R M₁ M₂ where
toFun m := g fun i => f i (m i)
map_add' m i x y := by
have : ∀ j z, f j (update m i z j) = update (fun k => f k (m k)) i (f i z) j := fun j z =>
Function.apply_update (fun k => f k) _ _ _ _
simp [this]
map_smul' m i c x := by
have : ∀ j z, f j (update m i z j) = update (fun k => f k (m k)) i (f i z) j := fun j z =>
Function.apply_update (fun k => f k) _ _ _ _
simp [this]
#align multilinear_map.comp_linear_map MultilinearMap.compLinearMap
@[simp]
theorem compLinearMap_apply (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i →ₗ[R] M₁' i)
(m : ∀ i, M₁ i) : g.compLinearMap f m = g fun i => f i (m i) :=
rfl
#align multilinear_map.comp_linear_map_apply MultilinearMap.compLinearMap_apply
theorem compLinearMap_assoc (g : MultilinearMap R M₁'' M₂) (f₁ : ∀ i, M₁' i →ₗ[R] M₁'' i)
(f₂ : ∀ i, M₁ i →ₗ[R] M₁' i) :
(g.compLinearMap f₁).compLinearMap f₂ = g.compLinearMap fun i => f₁ i ∘ₗ f₂ i :=
rfl
#align multilinear_map.comp_linear_map_assoc MultilinearMap.compLinearMap_assoc
@[simp]
theorem zero_compLinearMap (f : ∀ i, M₁ i →ₗ[R] M₁' i) :
(0 : MultilinearMap R M₁' M₂).compLinearMap f = 0 :=
ext fun _ => rfl
#align multilinear_map.zero_comp_linear_map MultilinearMap.zero_compLinearMap
@[simp]
theorem compLinearMap_id (g : MultilinearMap R M₁' M₂) :
(g.compLinearMap fun _ => LinearMap.id) = g :=
ext fun _ => rfl
#align multilinear_map.comp_linear_map_id MultilinearMap.compLinearMap_id
theorem compLinearMap_injective (f : ∀ i, M₁ i →ₗ[R] M₁' i) (hf : ∀ i, Surjective (f i)) :
Injective fun g : MultilinearMap R M₁' M₂ => g.compLinearMap f := fun g₁ g₂ h =>
ext fun x => by
simpa [fun i => surjInv_eq (hf i)] using ext_iff.mp h fun i => surjInv (hf i) (x i)
#align multilinear_map.comp_linear_map_injective MultilinearMap.compLinearMap_injective
theorem compLinearMap_inj (f : ∀ i, M₁ i →ₗ[R] M₁' i) (hf : ∀ i, Surjective (f i))
(g₁ g₂ : MultilinearMap R M₁' M₂) : g₁.compLinearMap f = g₂.compLinearMap f ↔ g₁ = g₂ :=
(compLinearMap_injective _ hf).eq_iff
#align multilinear_map.comp_linear_map_inj MultilinearMap.compLinearMap_inj
@[simp]
theorem comp_linearEquiv_eq_zero_iff (g : MultilinearMap R M₁' M₂) (f : ∀ i, M₁ i ≃ₗ[R] M₁' i) :
(g.compLinearMap fun i => (f i : M₁ i →ₗ[R] M₁' i)) = 0 ↔ g = 0 := by
set f' := fun i => (f i : M₁ i →ₗ[R] M₁' i)
rw [← zero_compLinearMap f', compLinearMap_inj f' fun i => (f i).surjective]
#align multilinear_map.comp_linear_equiv_eq_zero_iff MultilinearMap.comp_linearEquiv_eq_zero_iff
end
theorem map_piecewise_add [DecidableEq ι] (m m' : ∀ i, M₁ i) (t : Finset ι) :
f (t.piecewise (m + m') m') = ∑ s ∈ t.powerset, f (s.piecewise m m') := by
revert m'
refine Finset.induction_on t (by simp) ?_
intro i t hit Hrec m'
have A : (insert i t).piecewise (m + m') m' = update (t.piecewise (m + m') m') i (m i + m' i) :=
t.piecewise_insert _ _ _
have B : update (t.piecewise (m + m') m') i (m' i) = t.piecewise (m + m') m' := by
ext j
by_cases h : j = i
· rw [h]
simp [hit]
· simp [h]
let m'' := update m' i (m i)
have C : update (t.piecewise (m + m') m') i (m i) = t.piecewise (m + m'') m'' := by
ext j
by_cases h : j = i
· rw [h]
simp [m'', hit]
· by_cases h' : j ∈ t <;> simp [m'', h, hit, h']
rw [A, f.map_add, B, C, Finset.sum_powerset_insert hit, Hrec, Hrec, add_comm (_ : M₂)]
congr 1
refine Finset.sum_congr rfl fun s hs => ?_
have : (insert i s).piecewise m m' = s.piecewise m m'' := by
ext j
by_cases h : j = i
· rw [h]
simp [m'', Finset.not_mem_of_mem_powerset_of_not_mem hs hit]
· by_cases h' : j ∈ s <;> simp [m'', h, h']
rw [this]
#align multilinear_map.map_piecewise_add MultilinearMap.map_piecewise_add
theorem map_add_univ [DecidableEq ι] [Fintype ι] (m m' : ∀ i, M₁ i) :
f (m + m') = ∑ s : Finset ι, f (s.piecewise m m') := by
simpa using f.map_piecewise_add m m' Finset.univ
#align multilinear_map.map_add_univ MultilinearMap.map_add_univ
@[simps]
def codRestrict (f : MultilinearMap R M₁ M₂) (p : Submodule R M₂) (h : ∀ v, f v ∈ p) :
MultilinearMap R M₁ p where
toFun v := ⟨f v, h v⟩
map_add' _ _ _ _ := Subtype.ext <| MultilinearMap.map_add _ _ _ _ _
map_smul' _ _ _ _ := Subtype.ext <| MultilinearMap.map_smul _ _ _ _ _
#align multilinear_map.cod_restrict MultilinearMap.codRestrict
#align multilinear_map.cod_restrict_apply_coe MultilinearMap.codRestrict_apply_coe
namespace MultilinearMap
section Semiring
variable [Semiring R] [(i : ι) → AddCommMonoid (M₁ i)] [(i : ι) → Module R (M₁ i)]
[AddCommMonoid M₂] [Module R M₂]
instance [Monoid S] [DistribMulAction S M₂] [Module R M₂] [SMulCommClass R S M₂] :
DistribMulAction S (MultilinearMap R M₁ M₂) :=
coe_injective.distribMulAction coeAddMonoidHom fun _ _ ↦ rfl
section Module
variable [Semiring S] [Module S M₂] [SMulCommClass R S M₂]
instance : Module S (MultilinearMap R M₁ M₂) :=
coe_injective.module _ coeAddMonoidHom fun _ _ ↦ rfl
instance [NoZeroSMulDivisors S M₂] : NoZeroSMulDivisors S (MultilinearMap R M₁ M₂) :=
coe_injective.noZeroSMulDivisors _ rfl coe_smul
variable (R S M₁ M₂ M₃)
section Currying
open MultilinearMap
variable [CommSemiring R] [∀ i, AddCommMonoid (M i)] [AddCommMonoid M'] [AddCommMonoid M₂]
[∀ i, Module R (M i)] [Module R M'] [Module R M₂]
def LinearMap.uncurryLeft (f : M 0 →ₗ[R] MultilinearMap R (fun i : Fin n => M i.succ) M₂) :
MultilinearMap R M M₂ where
toFun m := f (m 0) (tail m)
map_add' := @fun dec m i x y => by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
by_cases h : i = 0
· subst i
simp only [update_same, map_add, tail_update_zero, MultilinearMap.add_apply]
· simp_rw [update_noteq (Ne.symm h)]
revert x y
rw [← succ_pred i h]
intro x y
rw [tail_update_succ, MultilinearMap.map_add, tail_update_succ, tail_update_succ]
map_smul' := @fun dec m i c x => by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
by_cases h : i = 0
· subst i
simp only [update_same, map_smul, tail_update_zero, MultilinearMap.smul_apply]
· simp_rw [update_noteq (Ne.symm h)]
revert x
rw [← succ_pred i h]
intro x
rw [tail_update_succ, tail_update_succ, MultilinearMap.map_smul]
#align linear_map.uncurry_left LinearMap.uncurryLeft
@[simp]
theorem LinearMap.uncurryLeft_apply (f : M 0 →ₗ[R] MultilinearMap R (fun i : Fin n => M i.succ) M₂)
(m : ∀ i, M i) : f.uncurryLeft m = f (m 0) (tail m) :=
rfl
#align linear_map.uncurry_left_apply LinearMap.uncurryLeft_apply
def MultilinearMap.curryLeft (f : MultilinearMap R M M₂) :
M 0 →ₗ[R] MultilinearMap R (fun i : Fin n => M i.succ) M₂ where
toFun x :=
{ toFun := fun m => f (cons x m)
map_add' := @fun dec m i y y' => by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]
simp
map_smul' := @fun dec m i y c => by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]
simp }
map_add' x y := by
ext m
exact cons_add f m x y
map_smul' c x := by
ext m
exact cons_smul f m c x
#align multilinear_map.curry_left MultilinearMap.curryLeft
@[simp]
theorem MultilinearMap.curryLeft_apply (f : MultilinearMap R M M₂) (x : M 0)
(m : ∀ i : Fin n, M i.succ) : f.curryLeft x m = f (cons x m) :=
rfl
#align multilinear_map.curry_left_apply MultilinearMap.curryLeft_apply
@[simp]
theorem LinearMap.curry_uncurryLeft (f : M 0 →ₗ[R] MultilinearMap R (fun i :
Fin n => M i.succ) M₂) : f.uncurryLeft.curryLeft = f := by
ext m x
simp only [tail_cons, LinearMap.uncurryLeft_apply, MultilinearMap.curryLeft_apply]
rw [cons_zero]
#align linear_map.curry_uncurry_left LinearMap.curry_uncurryLeft
@[simp]
theorem MultilinearMap.uncurry_curryLeft (f : MultilinearMap R M M₂) :
f.curryLeft.uncurryLeft = f := by
ext m
simp
#align multilinear_map.uncurry_curry_left MultilinearMap.uncurry_curryLeft
variable (R M M₂)
def multilinearCurryLeftEquiv :
(M 0 →ₗ[R] MultilinearMap R (fun i : Fin n => M i.succ) M₂) ≃ₗ[R] MultilinearMap R M M₂ where
toFun := LinearMap.uncurryLeft
map_add' f₁ f₂ := by
ext m
rfl
map_smul' c f := by
ext m
rfl
invFun := MultilinearMap.curryLeft
left_inv := LinearMap.curry_uncurryLeft
right_inv := MultilinearMap.uncurry_curryLeft
#align multilinear_curry_left_equiv multilinearCurryLeftEquiv
variable {R M M₂}
def MultilinearMap.uncurryRight
(f : MultilinearMap R (fun i : Fin n => M (castSucc i)) (M (last n) →ₗ[R] M₂)) :
MultilinearMap R M M₂ where
toFun m := f (init m) (m (last n))
map_add' {dec} m i x y := by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
by_cases h : i.val < n
· have : last n ≠ i := Ne.symm (ne_of_lt h)
simp_rw [update_noteq this]
revert x y
rw [(castSucc_castLT i h).symm]
intro x y
rw [init_update_castSucc, MultilinearMap.map_add, init_update_castSucc,
init_update_castSucc, LinearMap.add_apply]
· revert x y
rw [eq_last_of_not_lt h]
intro x y
simp_rw [init_update_last, update_same, LinearMap.map_add]
map_smul' {dec} m i c x := by
-- Porting note: `clear` not necessary in Lean 3 due to not being in the instance cache
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
by_cases h : i.val < n
· have : last n ≠ i := Ne.symm (ne_of_lt h)
simp_rw [update_noteq this]
revert x
rw [(castSucc_castLT i h).symm]
intro x
rw [init_update_castSucc, init_update_castSucc, MultilinearMap.map_smul,
LinearMap.smul_apply]
· revert x
rw [eq_last_of_not_lt h]
intro x
simp_rw [update_same, init_update_last, map_smul]
#align multilinear_map.uncurry_right MultilinearMap.uncurryRight
@[simp]
theorem MultilinearMap.uncurryRight_apply
(f : MultilinearMap R (fun i : Fin n => M (castSucc i)) (M (last n) →ₗ[R] M₂))
(m : ∀ i, M i) : f.uncurryRight m = f (init m) (m (last n)) :=
rfl
#align multilinear_map.uncurry_right_apply MultilinearMap.uncurryRight_apply
def MultilinearMap.curryRight (f : MultilinearMap R M M₂) :
MultilinearMap R (fun i : Fin n => M (Fin.castSucc i)) (M (last n) →ₗ[R] M₂) where
toFun m :=
{ toFun := fun x => f (snoc m x)
map_add' := fun x y => by simp_rw [f.snoc_add]
map_smul' := fun c x => by simp only [f.snoc_smul, RingHom.id_apply] }
map_add' := @fun dec m i x y => by
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
ext z
change f (snoc (update m i (x + y)) z) = f (snoc (update m i x) z) + f (snoc (update m i y) z)
rw [snoc_update, snoc_update, snoc_update, f.map_add]
map_smul' := @fun dec m i c x => by
rw [Subsingleton.elim dec (by clear dec; infer_instance)]; clear dec
ext z
change f (snoc (update m i (c • x)) z) = c • f (snoc (update m i x) z)
rw [snoc_update, snoc_update, f.map_smul]
#align multilinear_map.curry_right MultilinearMap.curryRight
@[simp]
theorem MultilinearMap.curryRight_apply (f : MultilinearMap R M M₂)
(m : ∀ i : Fin n, M (castSucc i)) (x : M (last n)) : f.curryRight m x = f (snoc m x) :=
rfl
#align multilinear_map.curry_right_apply MultilinearMap.curryRight_apply
@[simp]
theorem MultilinearMap.curry_uncurryRight
(f : MultilinearMap R (fun i : Fin n => M (castSucc i)) (M (last n) →ₗ[R] M₂)) :
f.uncurryRight.curryRight = f := by
ext m x
simp only [snoc_last, MultilinearMap.curryRight_apply, MultilinearMap.uncurryRight_apply]
rw [init_snoc]
#align multilinear_map.curry_uncurry_right MultilinearMap.curry_uncurryRight
@[simp]
| Mathlib/LinearAlgebra/Multilinear/Basic.lean | 1,652 | 1,655 | theorem MultilinearMap.uncurry_curryRight (f : MultilinearMap R M M₂) :
f.curryRight.uncurryRight = f := by |
ext m
simp
|
import Mathlib.Algebra.CharP.Pi
import Mathlib.Algebra.CharP.Quotient
import Mathlib.Algebra.CharP.Subring
import Mathlib.Algebra.Ring.Pi
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.FieldTheory.Perfect
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.Algebra.Ring.Subring.Basic
import Mathlib.RingTheory.Valuation.Integers
#align_import ring_theory.perfection from "leanprover-community/mathlib"@"0b9eaaa7686280fad8cce467f5c3c57ee6ce77f8"
universe u₁ u₂ u₃ u₄
open scoped NNReal
def Monoid.perfection (M : Type u₁) [CommMonoid M] (p : ℕ) : Submonoid (ℕ → M) where
carrier := { f | ∀ n, f (n + 1) ^ p = f n }
one_mem' _ := one_pow _
mul_mem' hf hg n := (mul_pow _ _ _).trans <| congr_arg₂ _ (hf n) (hg n)
#align monoid.perfection Monoid.perfection
def Ring.perfectionSubsemiring (R : Type u₁) [CommSemiring R] (p : ℕ) [hp : Fact p.Prime]
[CharP R p] : Subsemiring (ℕ → R) :=
{ Monoid.perfection R p with
zero_mem' := fun _ ↦ zero_pow hp.1.ne_zero
add_mem' := fun hf hg n => (frobenius_add R p _ _).trans <| congr_arg₂ _ (hf n) (hg n) }
#align ring.perfection_subsemiring Ring.perfectionSubsemiring
def Ring.perfectionSubring (R : Type u₁) [CommRing R] (p : ℕ) [hp : Fact p.Prime] [CharP R p] :
Subring (ℕ → R) :=
(Ring.perfectionSubsemiring R p).toSubring fun n => by
simp_rw [← frobenius_def, Pi.neg_apply, Pi.one_apply, RingHom.map_neg, RingHom.map_one]
#align ring.perfection_subring Ring.perfectionSubring
def Ring.Perfection (R : Type u₁) [CommSemiring R] (p : ℕ) : Type u₁ :=
{ f // ∀ n : ℕ, (f : ℕ → R) (n + 1) ^ p = f n }
#align ring.perfection Ring.Perfection
-- @[nolint has_nonempty_instance] -- Porting note(#5171): This linter does not exist yet.
structure PerfectionMap (p : ℕ) [Fact p.Prime] {R : Type u₁} [CommSemiring R] [CharP R p]
{P : Type u₂} [CommSemiring P] [CharP P p] [PerfectRing P p] (π : P →+* R) : Prop where
injective : ∀ ⦃x y : P⦄,
(∀ n, π (((frobeniusEquiv P p).symm)^[n] x) = π (((frobeniusEquiv P p).symm)^[n] y)) → x = y
surjective : ∀ f : ℕ → R, (∀ n, f (n + 1) ^ p = f n) → ∃ x : P, ∀ n,
π (((frobeniusEquiv P p).symm)^[n] x) = f n
#align perfection_map PerfectionMap
section Perfectoid
variable (K : Type u₁) [Field K] (v : Valuation K ℝ≥0)
variable (O : Type u₂) [CommRing O] [Algebra O K] (hv : v.Integers O)
variable (p : ℕ)
-- Porting note: Specified all arguments explicitly
@[nolint unusedArguments] -- Porting note(#5171): removed `nolint has_nonempty_instance`
def ModP (K : Type u₁) [Field K] (v : Valuation K ℝ≥0) (O : Type u₂) [CommRing O] [Algebra O K]
(_ : v.Integers O) (p : ℕ) :=
O ⧸ (Ideal.span {(p : O)} : Ideal O)
#align mod_p ModP
variable [hp : Fact p.Prime] [hvp : Fact (v p ≠ 1)]
namespace ModP
instance commRing : CommRing (ModP K v O hv p) :=
Ideal.Quotient.commRing (Ideal.span {(p : O)} : Ideal O)
instance charP : CharP (ModP K v O hv p) p :=
CharP.quotient O p <| mt hv.one_of_isUnit <| (map_natCast (algebraMap O K) p).symm ▸ hvp.1
instance : Nontrivial (ModP K v O hv p) :=
CharP.nontrivial_of_char_ne_one hp.1.ne_one
section Classical
attribute [local instance] Classical.dec
noncomputable def preVal (x : ModP K v O hv p) : ℝ≥0 :=
if x = 0 then 0 else v (algebraMap O K x.out')
#align mod_p.pre_val ModP.preVal
variable {K v O hv p}
theorem preVal_mk {x : O} (hx : (Ideal.Quotient.mk _ x : ModP K v O hv p) ≠ 0) :
preVal K v O hv p (Ideal.Quotient.mk _ x) = v (algebraMap O K x) := by
obtain ⟨r, hr⟩ : ∃ (a : O), a * (p : O) = (Quotient.mk'' x).out' - x :=
Ideal.mem_span_singleton'.1 <| Ideal.Quotient.eq.1 <| Quotient.sound' <| Quotient.mk_out' _
refine (if_neg hx).trans (v.map_eq_of_sub_lt <| lt_of_not_le ?_)
erw [← RingHom.map_sub, ← hr, hv.le_iff_dvd]
exact fun hprx =>
hx (Ideal.Quotient.eq_zero_iff_mem.2 <| Ideal.mem_span_singleton.2 <| dvd_of_mul_left_dvd hprx)
#align mod_p.pre_val_mk ModP.preVal_mk
theorem preVal_zero : preVal K v O hv p 0 = 0 :=
if_pos rfl
#align mod_p.pre_val_zero ModP.preVal_zero
theorem preVal_mul {x y : ModP K v O hv p} (hxy0 : x * y ≠ 0) :
preVal K v O hv p (x * y) = preVal K v O hv p x * preVal K v O hv p y := by
have hx0 : x ≠ 0 := mt (by rintro rfl; rw [zero_mul]) hxy0
have hy0 : y ≠ 0 := mt (by rintro rfl; rw [mul_zero]) hxy0
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← map_mul (Ideal.Quotient.mk (Ideal.span {↑p})) r s] at hxy0 ⊢
rw [preVal_mk hx0, preVal_mk hy0, preVal_mk hxy0, RingHom.map_mul, v.map_mul]
#align mod_p.pre_val_mul ModP.preVal_mul
theorem preVal_add (x y : ModP K v O hv p) :
preVal K v O hv p (x + y) ≤ max (preVal K v O hv p x) (preVal K v O hv p y) := by
by_cases hx0 : x = 0
· rw [hx0, zero_add]; exact le_max_right _ _
by_cases hy0 : y = 0
· rw [hy0, add_zero]; exact le_max_left _ _
by_cases hxy0 : x + y = 0
· rw [hxy0, preVal_zero]; exact zero_le _
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective y
rw [← map_add (Ideal.Quotient.mk (Ideal.span {↑p})) r s] at hxy0 ⊢
rw [preVal_mk hx0, preVal_mk hy0, preVal_mk hxy0, RingHom.map_add]; exact v.map_add _ _
#align mod_p.pre_val_add ModP.preVal_add
| Mathlib/RingTheory/Perfection.lean | 444 | 449 | theorem v_p_lt_preVal {x : ModP K v O hv p} : v p < preVal K v O hv p x ↔ x ≠ 0 := by |
refine ⟨fun h hx => by rw [hx, preVal_zero] at h; exact not_lt_zero' h,
fun h => lt_of_not_le fun hp => h ?_⟩
obtain ⟨r, rfl⟩ := Ideal.Quotient.mk_surjective x
rw [preVal_mk h, ← map_natCast (algebraMap O K) p, hv.le_iff_dvd] at hp
rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_span_singleton]; exact hp
|
import Mathlib.Data.List.Sigma
#align_import data.list.alist from "leanprover-community/mathlib"@"f808feb6c18afddb25e66a71d317643cf7fb5fbb"
universe u v w
open List
variable {α : Type u} {β : α → Type v}
structure AList (β : α → Type v) : Type max u v where
entries : List (Sigma β)
nodupKeys : entries.NodupKeys
#align alist AList
def List.toAList [DecidableEq α] {β : α → Type v} (l : List (Sigma β)) : AList β where
entries := _
nodupKeys := nodupKeys_dedupKeys l
#align list.to_alist List.toAList
namespace AList
@[ext]
theorem ext : ∀ {s t : AList β}, s.entries = t.entries → s = t
| ⟨l₁, h₁⟩, ⟨l₂, _⟩, H => by congr
#align alist.ext AList.ext
theorem ext_iff {s t : AList β} : s = t ↔ s.entries = t.entries :=
⟨congr_arg _, ext⟩
#align alist.ext_iff AList.ext_iff
instance [DecidableEq α] [∀ a, DecidableEq (β a)] : DecidableEq (AList β) := fun xs ys => by
rw [ext_iff]; infer_instance
def keys (s : AList β) : List α :=
s.entries.keys
#align alist.keys AList.keys
theorem keys_nodup (s : AList β) : s.keys.Nodup :=
s.nodupKeys
#align alist.keys_nodup AList.keys_nodup
instance : Membership α (AList β) :=
⟨fun a s => a ∈ s.keys⟩
theorem mem_keys {a : α} {s : AList β} : a ∈ s ↔ a ∈ s.keys :=
Iff.rfl
#align alist.mem_keys AList.mem_keys
theorem mem_of_perm {a : α} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) : a ∈ s₁ ↔ a ∈ s₂ :=
(p.map Sigma.fst).mem_iff
#align alist.mem_of_perm AList.mem_of_perm
instance : EmptyCollection (AList β) :=
⟨⟨[], nodupKeys_nil⟩⟩
instance : Inhabited (AList β) :=
⟨∅⟩
@[simp]
theorem not_mem_empty (a : α) : a ∉ (∅ : AList β) :=
not_mem_nil a
#align alist.not_mem_empty AList.not_mem_empty
@[simp]
theorem empty_entries : (∅ : AList β).entries = [] :=
rfl
#align alist.empty_entries AList.empty_entries
@[simp]
theorem keys_empty : (∅ : AList β).keys = [] :=
rfl
#align alist.keys_empty AList.keys_empty
def singleton (a : α) (b : β a) : AList β :=
⟨[⟨a, b⟩], nodupKeys_singleton _⟩
#align alist.singleton AList.singleton
@[simp]
theorem singleton_entries (a : α) (b : β a) : (singleton a b).entries = [Sigma.mk a b] :=
rfl
#align alist.singleton_entries AList.singleton_entries
@[simp]
theorem keys_singleton (a : α) (b : β a) : (singleton a b).keys = [a] :=
rfl
#align alist.keys_singleton AList.keys_singleton
section
variable [DecidableEq α]
def lookup (a : α) (s : AList β) : Option (β a) :=
s.entries.dlookup a
#align alist.lookup AList.lookup
@[simp]
theorem lookup_empty (a) : lookup a (∅ : AList β) = none :=
rfl
#align alist.lookup_empty AList.lookup_empty
theorem lookup_isSome {a : α} {s : AList β} : (s.lookup a).isSome ↔ a ∈ s :=
dlookup_isSome
#align alist.lookup_is_some AList.lookup_isSome
theorem lookup_eq_none {a : α} {s : AList β} : lookup a s = none ↔ a ∉ s :=
dlookup_eq_none
#align alist.lookup_eq_none AList.lookup_eq_none
theorem mem_lookup_iff {a : α} {b : β a} {s : AList β} :
b ∈ lookup a s ↔ Sigma.mk a b ∈ s.entries :=
mem_dlookup_iff s.nodupKeys
#align alist.mem_lookup_iff AList.mem_lookup_iff
theorem perm_lookup {a : α} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) :
s₁.lookup a = s₂.lookup a :=
perm_dlookup _ s₁.nodupKeys s₂.nodupKeys p
#align alist.perm_lookup AList.perm_lookup
instance (a : α) (s : AList β) : Decidable (a ∈ s) :=
decidable_of_iff _ lookup_isSome
theorem keys_subset_keys_of_entries_subset_entries
{s₁ s₂ : AList β} (h : s₁.entries ⊆ s₂.entries) : s₁.keys ⊆ s₂.keys := by
intro k hk
letI : DecidableEq α := Classical.decEq α
have := h (mem_lookup_iff.1 (Option.get_mem (lookup_isSome.2 hk)))
rw [← mem_lookup_iff, Option.mem_def] at this
rw [← mem_keys, ← lookup_isSome, this]
exact Option.isSome_some
def replace (a : α) (b : β a) (s : AList β) : AList β :=
⟨kreplace a b s.entries, (kreplace_nodupKeys a b).2 s.nodupKeys⟩
#align alist.replace AList.replace
@[simp]
theorem keys_replace (a : α) (b : β a) (s : AList β) : (replace a b s).keys = s.keys :=
keys_kreplace _ _ _
#align alist.keys_replace AList.keys_replace
@[simp]
theorem mem_replace {a a' : α} {b : β a} {s : AList β} : a' ∈ replace a b s ↔ a' ∈ s := by
rw [mem_keys, keys_replace, ← mem_keys]
#align alist.mem_replace AList.mem_replace
theorem perm_replace {a : α} {b : β a} {s₁ s₂ : AList β} :
s₁.entries ~ s₂.entries → (replace a b s₁).entries ~ (replace a b s₂).entries :=
Perm.kreplace s₁.nodupKeys
#align alist.perm_replace AList.perm_replace
end
def foldl {δ : Type w} (f : δ → ∀ a, β a → δ) (d : δ) (m : AList β) : δ :=
m.entries.foldl (fun r a => f r a.1 a.2) d
#align alist.foldl AList.foldl
section
variable [DecidableEq α]
def erase (a : α) (s : AList β) : AList β :=
⟨s.entries.kerase a, s.nodupKeys.kerase a⟩
#align alist.erase AList.erase
@[simp]
theorem keys_erase (a : α) (s : AList β) : (erase a s).keys = s.keys.erase a :=
keys_kerase
#align alist.keys_erase AList.keys_erase
@[simp]
theorem mem_erase {a a' : α} {s : AList β} : a' ∈ erase a s ↔ a' ≠ a ∧ a' ∈ s := by
rw [mem_keys, keys_erase, s.keys_nodup.mem_erase_iff, ← mem_keys]
#align alist.mem_erase AList.mem_erase
theorem perm_erase {a : α} {s₁ s₂ : AList β} :
s₁.entries ~ s₂.entries → (erase a s₁).entries ~ (erase a s₂).entries :=
Perm.kerase s₁.nodupKeys
#align alist.perm_erase AList.perm_erase
@[simp]
theorem lookup_erase (a) (s : AList β) : lookup a (erase a s) = none :=
dlookup_kerase a s.nodupKeys
#align alist.lookup_erase AList.lookup_erase
@[simp]
theorem lookup_erase_ne {a a'} {s : AList β} (h : a ≠ a') : lookup a (erase a' s) = lookup a s :=
dlookup_kerase_ne h
#align alist.lookup_erase_ne AList.lookup_erase_ne
theorem erase_erase (a a' : α) (s : AList β) : (s.erase a).erase a' = (s.erase a').erase a :=
ext <| kerase_kerase
#align alist.erase_erase AList.erase_erase
def insert (a : α) (b : β a) (s : AList β) : AList β :=
⟨kinsert a b s.entries, kinsert_nodupKeys a b s.nodupKeys⟩
#align alist.insert AList.insert
@[simp]
theorem insert_entries {a} {b : β a} {s : AList β} :
(insert a b s).entries = Sigma.mk a b :: kerase a s.entries :=
rfl
#align alist.insert_entries AList.insert_entries
theorem insert_entries_of_neg {a} {b : β a} {s : AList β} (h : a ∉ s) :
(insert a b s).entries = ⟨a, b⟩ :: s.entries := by rw [insert_entries, kerase_of_not_mem_keys h]
#align alist.insert_entries_of_neg AList.insert_entries_of_neg
-- Todo: rename to `insert_of_not_mem`.
theorem insert_of_neg {a} {b : β a} {s : AList β} (h : a ∉ s) :
insert a b s = ⟨⟨a, b⟩ :: s.entries, nodupKeys_cons.2 ⟨h, s.2⟩⟩ :=
ext <| insert_entries_of_neg h
#align alist.insert_of_neg AList.insert_of_neg
@[simp]
theorem insert_empty (a) (b : β a) : insert a b ∅ = singleton a b :=
rfl
#align alist.insert_empty AList.insert_empty
@[simp]
theorem mem_insert {a a'} {b' : β a'} (s : AList β) : a ∈ insert a' b' s ↔ a = a' ∨ a ∈ s :=
mem_keys_kinsert
#align alist.mem_insert AList.mem_insert
@[simp]
theorem keys_insert {a} {b : β a} (s : AList β) : (insert a b s).keys = a :: s.keys.erase a := by
simp [insert, keys, keys_kerase]
#align alist.keys_insert AList.keys_insert
theorem perm_insert {a} {b : β a} {s₁ s₂ : AList β} (p : s₁.entries ~ s₂.entries) :
(insert a b s₁).entries ~ (insert a b s₂).entries := by
simp only [insert_entries]; exact p.kinsert s₁.nodupKeys
#align alist.perm_insert AList.perm_insert
@[simp]
| Mathlib/Data/List/AList.lean | 310 | 311 | theorem lookup_insert {a} {b : β a} (s : AList β) : lookup a (insert a b s) = some b := by |
simp only [lookup, insert, dlookup_kinsert]
|
import Mathlib.Analysis.Normed.Group.Hom
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Data.Set.Image
import Mathlib.MeasureTheory.Function.LpSeminorm.ChebyshevMarkov
import Mathlib.MeasureTheory.Function.LpSeminorm.CompareExp
import Mathlib.MeasureTheory.Function.LpSeminorm.TriangleInequality
import Mathlib.MeasureTheory.Measure.OpenPos
import Mathlib.Topology.ContinuousFunction.Compact
import Mathlib.Order.Filter.IndicatorFunction
#align_import measure_theory.function.lp_space from "leanprover-community/mathlib"@"c4015acc0a223449d44061e27ddac1835a3852b9"
noncomputable section
set_option linter.uppercaseLean3 false
open TopologicalSpace MeasureTheory Filter
open scoped NNReal ENNReal Topology MeasureTheory Uniformity
variable {α E F G : Type*} {m m0 : MeasurableSpace α} {p : ℝ≥0∞} {q : ℝ} {μ ν : Measure α}
[NormedAddCommGroup E] [NormedAddCommGroup F] [NormedAddCommGroup G]
namespace MeasureTheory
@[simp]
theorem snorm_aeeqFun {α E : Type*} [MeasurableSpace α] {μ : Measure α} [NormedAddCommGroup E]
{p : ℝ≥0∞} {f : α → E} (hf : AEStronglyMeasurable f μ) :
snorm (AEEqFun.mk f hf) p μ = snorm f p μ :=
snorm_congr_ae (AEEqFun.coeFn_mk _ _)
#align measure_theory.snorm_ae_eq_fun MeasureTheory.snorm_aeeqFun
theorem Memℒp.snorm_mk_lt_top {α E : Type*} [MeasurableSpace α] {μ : Measure α}
[NormedAddCommGroup E] {p : ℝ≥0∞} {f : α → E} (hfp : Memℒp f p μ) :
snorm (AEEqFun.mk f hfp.1) p μ < ∞ := by simp [hfp.2]
#align measure_theory.mem_ℒp.snorm_mk_lt_top MeasureTheory.Memℒp.snorm_mk_lt_top
def Lp {α} (E : Type*) {m : MeasurableSpace α} [NormedAddCommGroup E] (p : ℝ≥0∞)
(μ : Measure α := by volume_tac) : AddSubgroup (α →ₘ[μ] E) where
carrier := { f | snorm f p μ < ∞ }
zero_mem' := by simp [snorm_congr_ae AEEqFun.coeFn_zero, snorm_zero]
add_mem' {f g} hf hg := by
simp [snorm_congr_ae (AEEqFun.coeFn_add f g),
snorm_add_lt_top ⟨f.aestronglyMeasurable, hf⟩ ⟨g.aestronglyMeasurable, hg⟩]
neg_mem' {f} hf := by rwa [Set.mem_setOf_eq, snorm_congr_ae (AEEqFun.coeFn_neg f), snorm_neg]
#align measure_theory.Lp MeasureTheory.Lp
-- Porting note: calling the first argument `α` breaks the `(α := ·)` notation
scoped notation:25 α' " →₁[" μ "] " E => MeasureTheory.Lp (α := α') E 1 μ
scoped notation:25 α' " →₂[" μ "] " E => MeasureTheory.Lp (α := α') E 2 μ
namespace Lp
instance instCoeFun : CoeFun (Lp E p μ) (fun _ => α → E) :=
⟨fun f => ((f : α →ₘ[μ] E) : α → E)⟩
#align measure_theory.Lp.has_coe_to_fun MeasureTheory.Lp.instCoeFun
@[ext high]
theorem ext {f g : Lp E p μ} (h : f =ᵐ[μ] g) : f = g := by
cases f
cases g
simp only [Subtype.mk_eq_mk]
exact AEEqFun.ext h
#align measure_theory.Lp.ext MeasureTheory.Lp.ext
theorem ext_iff {f g : Lp E p μ} : f = g ↔ f =ᵐ[μ] g :=
⟨fun h => by rw [h], fun h => ext h⟩
#align measure_theory.Lp.ext_iff MeasureTheory.Lp.ext_iff
theorem mem_Lp_iff_snorm_lt_top {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ snorm f p μ < ∞ := Iff.rfl
#align measure_theory.Lp.mem_Lp_iff_snorm_lt_top MeasureTheory.Lp.mem_Lp_iff_snorm_lt_top
theorem mem_Lp_iff_memℒp {f : α →ₘ[μ] E} : f ∈ Lp E p μ ↔ Memℒp f p μ := by
simp [mem_Lp_iff_snorm_lt_top, Memℒp, f.stronglyMeasurable.aestronglyMeasurable]
#align measure_theory.Lp.mem_Lp_iff_mem_ℒp MeasureTheory.Lp.mem_Lp_iff_memℒp
protected theorem antitone [IsFiniteMeasure μ] {p q : ℝ≥0∞} (hpq : p ≤ q) : Lp E q μ ≤ Lp E p μ :=
fun f hf => (Memℒp.memℒp_of_exponent_le ⟨f.aestronglyMeasurable, hf⟩ hpq).2
#align measure_theory.Lp.antitone MeasureTheory.Lp.antitone
@[simp]
theorem coeFn_mk {f : α →ₘ[μ] E} (hf : snorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α → E) = f :=
rfl
#align measure_theory.Lp.coe_fn_mk MeasureTheory.Lp.coeFn_mk
-- @[simp] -- Porting note (#10685): dsimp can prove this
theorem coe_mk {f : α →ₘ[μ] E} (hf : snorm f p μ < ∞) : ((⟨f, hf⟩ : Lp E p μ) : α →ₘ[μ] E) = f :=
rfl
#align measure_theory.Lp.coe_mk MeasureTheory.Lp.coe_mk
@[simp]
theorem toLp_coeFn (f : Lp E p μ) (hf : Memℒp f p μ) : hf.toLp f = f := by
cases f
simp [Memℒp.toLp]
#align measure_theory.Lp.to_Lp_coe_fn MeasureTheory.Lp.toLp_coeFn
theorem snorm_lt_top (f : Lp E p μ) : snorm f p μ < ∞ :=
f.prop
#align measure_theory.Lp.snorm_lt_top MeasureTheory.Lp.snorm_lt_top
theorem snorm_ne_top (f : Lp E p μ) : snorm f p μ ≠ ∞ :=
(snorm_lt_top f).ne
#align measure_theory.Lp.snorm_ne_top MeasureTheory.Lp.snorm_ne_top
@[measurability]
protected theorem stronglyMeasurable (f : Lp E p μ) : StronglyMeasurable f :=
f.val.stronglyMeasurable
#align measure_theory.Lp.strongly_measurable MeasureTheory.Lp.stronglyMeasurable
@[measurability]
protected theorem aestronglyMeasurable (f : Lp E p μ) : AEStronglyMeasurable f μ :=
f.val.aestronglyMeasurable
#align measure_theory.Lp.ae_strongly_measurable MeasureTheory.Lp.aestronglyMeasurable
protected theorem memℒp (f : Lp E p μ) : Memℒp f p μ :=
⟨Lp.aestronglyMeasurable f, f.prop⟩
#align measure_theory.Lp.mem_ℒp MeasureTheory.Lp.memℒp
variable (E p μ)
theorem coeFn_zero : ⇑(0 : Lp E p μ) =ᵐ[μ] 0 :=
AEEqFun.coeFn_zero
#align measure_theory.Lp.coe_fn_zero MeasureTheory.Lp.coeFn_zero
variable {E p μ}
theorem coeFn_neg (f : Lp E p μ) : ⇑(-f) =ᵐ[μ] -f :=
AEEqFun.coeFn_neg _
#align measure_theory.Lp.coe_fn_neg MeasureTheory.Lp.coeFn_neg
theorem coeFn_add (f g : Lp E p μ) : ⇑(f + g) =ᵐ[μ] f + g :=
AEEqFun.coeFn_add _ _
#align measure_theory.Lp.coe_fn_add MeasureTheory.Lp.coeFn_add
theorem coeFn_sub (f g : Lp E p μ) : ⇑(f - g) =ᵐ[μ] f - g :=
AEEqFun.coeFn_sub _ _
#align measure_theory.Lp.coe_fn_sub MeasureTheory.Lp.coeFn_sub
theorem const_mem_Lp (α) {_ : MeasurableSpace α} (μ : Measure α) (c : E) [IsFiniteMeasure μ] :
@AEEqFun.const α _ _ μ _ c ∈ Lp E p μ :=
(memℒp_const c).snorm_mk_lt_top
#align measure_theory.Lp.mem_Lp_const MeasureTheory.Lp.const_mem_Lp
instance instNorm : Norm (Lp E p μ) where norm f := ENNReal.toReal (snorm f p μ)
#align measure_theory.Lp.has_norm MeasureTheory.Lp.instNorm
-- note: we need this to be defeq to the instance from `SeminormedAddGroup.toNNNorm`, so
-- can't use `ENNReal.toNNReal (snorm f p μ)`
instance instNNNorm : NNNorm (Lp E p μ) where nnnorm f := ⟨‖f‖, ENNReal.toReal_nonneg⟩
#align measure_theory.Lp.has_nnnorm MeasureTheory.Lp.instNNNorm
instance instDist : Dist (Lp E p μ) where dist f g := ‖f - g‖
#align measure_theory.Lp.has_dist MeasureTheory.Lp.instDist
instance instEDist : EDist (Lp E p μ) where edist f g := snorm (⇑f - ⇑g) p μ
#align measure_theory.Lp.has_edist MeasureTheory.Lp.instEDist
theorem norm_def (f : Lp E p μ) : ‖f‖ = ENNReal.toReal (snorm f p μ) :=
rfl
#align measure_theory.Lp.norm_def MeasureTheory.Lp.norm_def
theorem nnnorm_def (f : Lp E p μ) : ‖f‖₊ = ENNReal.toNNReal (snorm f p μ) :=
rfl
#align measure_theory.Lp.nnnorm_def MeasureTheory.Lp.nnnorm_def
@[simp, norm_cast]
protected theorem coe_nnnorm (f : Lp E p μ) : (‖f‖₊ : ℝ) = ‖f‖ :=
rfl
#align measure_theory.Lp.coe_nnnorm MeasureTheory.Lp.coe_nnnorm
@[simp, norm_cast]
theorem nnnorm_coe_ennreal (f : Lp E p μ) : (‖f‖₊ : ℝ≥0∞) = snorm f p μ :=
ENNReal.coe_toNNReal <| Lp.snorm_ne_top f
@[simp]
theorem norm_toLp (f : α → E) (hf : Memℒp f p μ) : ‖hf.toLp f‖ = ENNReal.toReal (snorm f p μ) := by
erw [norm_def, snorm_congr_ae (Memℒp.coeFn_toLp hf)]
#align measure_theory.Lp.norm_to_Lp MeasureTheory.Lp.norm_toLp
@[simp]
theorem nnnorm_toLp (f : α → E) (hf : Memℒp f p μ) :
‖hf.toLp f‖₊ = ENNReal.toNNReal (snorm f p μ) :=
NNReal.eq <| norm_toLp f hf
#align measure_theory.Lp.nnnorm_to_Lp MeasureTheory.Lp.nnnorm_toLp
theorem coe_nnnorm_toLp {f : α → E} (hf : Memℒp f p μ) : (‖hf.toLp f‖₊ : ℝ≥0∞) = snorm f p μ := by
rw [nnnorm_toLp f hf, ENNReal.coe_toNNReal hf.2.ne]
theorem dist_def (f g : Lp E p μ) : dist f g = (snorm (⇑f - ⇑g) p μ).toReal := by
simp_rw [dist, norm_def]
refine congr_arg _ ?_
apply snorm_congr_ae (coeFn_sub _ _)
#align measure_theory.Lp.dist_def MeasureTheory.Lp.dist_def
theorem edist_def (f g : Lp E p μ) : edist f g = snorm (⇑f - ⇑g) p μ :=
rfl
#align measure_theory.Lp.edist_def MeasureTheory.Lp.edist_def
protected theorem edist_dist (f g : Lp E p μ) : edist f g = .ofReal (dist f g) := by
rw [edist_def, dist_def, ← snorm_congr_ae (coeFn_sub _ _),
ENNReal.ofReal_toReal (snorm_ne_top (f - g))]
protected theorem dist_edist (f g : Lp E p μ) : dist f g = (edist f g).toReal :=
MeasureTheory.Lp.dist_def ..
theorem dist_eq_norm (f g : Lp E p μ) : dist f g = ‖f - g‖ := rfl
@[simp]
theorem edist_toLp_toLp (f g : α → E) (hf : Memℒp f p μ) (hg : Memℒp g p μ) :
edist (hf.toLp f) (hg.toLp g) = snorm (f - g) p μ := by
rw [edist_def]
exact snorm_congr_ae (hf.coeFn_toLp.sub hg.coeFn_toLp)
#align measure_theory.Lp.edist_to_Lp_to_Lp MeasureTheory.Lp.edist_toLp_toLp
@[simp]
theorem edist_toLp_zero (f : α → E) (hf : Memℒp f p μ) : edist (hf.toLp f) 0 = snorm f p μ := by
convert edist_toLp_toLp f 0 hf zero_memℒp
simp
#align measure_theory.Lp.edist_to_Lp_zero MeasureTheory.Lp.edist_toLp_zero
@[simp]
theorem nnnorm_zero : ‖(0 : Lp E p μ)‖₊ = 0 := by
rw [nnnorm_def]
change (snorm (⇑(0 : α →ₘ[μ] E)) p μ).toNNReal = 0
simp [snorm_congr_ae AEEqFun.coeFn_zero, snorm_zero]
#align measure_theory.Lp.nnnorm_zero MeasureTheory.Lp.nnnorm_zero
@[simp]
theorem norm_zero : ‖(0 : Lp E p μ)‖ = 0 :=
congr_arg ((↑) : ℝ≥0 → ℝ) nnnorm_zero
#align measure_theory.Lp.norm_zero MeasureTheory.Lp.norm_zero
@[simp]
theorem norm_measure_zero (f : Lp E p (0 : MeasureTheory.Measure α)) : ‖f‖ = 0 := by
simp [norm_def]
@[simp] theorem norm_exponent_zero (f : Lp E 0 μ) : ‖f‖ = 0 := by simp [norm_def]
theorem nnnorm_eq_zero_iff {f : Lp E p μ} (hp : 0 < p) : ‖f‖₊ = 0 ↔ f = 0 := by
refine ⟨fun hf => ?_, fun hf => by simp [hf]⟩
rw [nnnorm_def, ENNReal.toNNReal_eq_zero_iff] at hf
cases hf with
| inl hf =>
rw [snorm_eq_zero_iff (Lp.aestronglyMeasurable f) hp.ne.symm] at hf
exact Subtype.eq (AEEqFun.ext (hf.trans AEEqFun.coeFn_zero.symm))
| inr hf =>
exact absurd hf (snorm_ne_top f)
#align measure_theory.Lp.nnnorm_eq_zero_iff MeasureTheory.Lp.nnnorm_eq_zero_iff
theorem norm_eq_zero_iff {f : Lp E p μ} (hp : 0 < p) : ‖f‖ = 0 ↔ f = 0 :=
NNReal.coe_eq_zero.trans (nnnorm_eq_zero_iff hp)
#align measure_theory.Lp.norm_eq_zero_iff MeasureTheory.Lp.norm_eq_zero_iff
theorem eq_zero_iff_ae_eq_zero {f : Lp E p μ} : f = 0 ↔ f =ᵐ[μ] 0 := by
rw [← (Lp.memℒp f).toLp_eq_toLp_iff zero_memℒp, Memℒp.toLp_zero, toLp_coeFn]
#align measure_theory.Lp.eq_zero_iff_ae_eq_zero MeasureTheory.Lp.eq_zero_iff_ae_eq_zero
@[simp]
theorem nnnorm_neg (f : Lp E p μ) : ‖-f‖₊ = ‖f‖₊ := by
rw [nnnorm_def, nnnorm_def, snorm_congr_ae (coeFn_neg _), snorm_neg]
#align measure_theory.Lp.nnnorm_neg MeasureTheory.Lp.nnnorm_neg
@[simp]
theorem norm_neg (f : Lp E p μ) : ‖-f‖ = ‖f‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) (nnnorm_neg f)
#align measure_theory.Lp.norm_neg MeasureTheory.Lp.norm_neg
theorem nnnorm_le_mul_nnnorm_of_ae_le_mul {c : ℝ≥0} {f : Lp E p μ} {g : Lp F p μ}
(h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : ‖f‖₊ ≤ c * ‖g‖₊ := by
simp only [nnnorm_def]
have := snorm_le_nnreal_smul_snorm_of_ae_le_mul h p
rwa [← ENNReal.toNNReal_le_toNNReal, ENNReal.smul_def, smul_eq_mul, ENNReal.toNNReal_mul,
ENNReal.toNNReal_coe] at this
· exact (Lp.memℒp _).snorm_ne_top
· exact ENNReal.mul_ne_top ENNReal.coe_ne_top (Lp.memℒp _).snorm_ne_top
#align measure_theory.Lp.nnnorm_le_mul_nnnorm_of_ae_le_mul MeasureTheory.Lp.nnnorm_le_mul_nnnorm_of_ae_le_mul
theorem norm_le_mul_norm_of_ae_le_mul {c : ℝ} {f : Lp E p μ} {g : Lp F p μ}
(h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) : ‖f‖ ≤ c * ‖g‖ := by
rcases le_or_lt 0 c with hc | hc
· lift c to ℝ≥0 using hc
exact NNReal.coe_le_coe.mpr (nnnorm_le_mul_nnnorm_of_ae_le_mul h)
· simp only [norm_def]
have := snorm_eq_zero_and_zero_of_ae_le_mul_neg h hc p
simp [this]
#align measure_theory.Lp.norm_le_mul_norm_of_ae_le_mul MeasureTheory.Lp.norm_le_mul_norm_of_ae_le_mul
theorem norm_le_norm_of_ae_le {f : Lp E p μ} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) :
‖f‖ ≤ ‖g‖ := by
rw [norm_def, norm_def, ENNReal.toReal_le_toReal (snorm_ne_top _) (snorm_ne_top _)]
exact snorm_mono_ae h
#align measure_theory.Lp.norm_le_norm_of_ae_le MeasureTheory.Lp.norm_le_norm_of_ae_le
theorem mem_Lp_of_nnnorm_ae_le_mul {c : ℝ≥0} {f : α →ₘ[μ] E} {g : Lp F p μ}
(h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ c * ‖g x‖₊) : f ∈ Lp E p μ :=
mem_Lp_iff_memℒp.2 <| Memℒp.of_nnnorm_le_mul (Lp.memℒp g) f.aestronglyMeasurable h
#align measure_theory.Lp.mem_Lp_of_nnnorm_ae_le_mul MeasureTheory.Lp.mem_Lp_of_nnnorm_ae_le_mul
theorem mem_Lp_of_ae_le_mul {c : ℝ} {f : α →ₘ[μ] E} {g : Lp F p μ}
(h : ∀ᵐ x ∂μ, ‖f x‖ ≤ c * ‖g x‖) : f ∈ Lp E p μ :=
mem_Lp_iff_memℒp.2 <| Memℒp.of_le_mul (Lp.memℒp g) f.aestronglyMeasurable h
#align measure_theory.Lp.mem_Lp_of_ae_le_mul MeasureTheory.Lp.mem_Lp_of_ae_le_mul
theorem mem_Lp_of_nnnorm_ae_le {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ ‖g x‖₊) :
f ∈ Lp E p μ :=
mem_Lp_iff_memℒp.2 <| Memℒp.of_le (Lp.memℒp g) f.aestronglyMeasurable h
#align measure_theory.Lp.mem_Lp_of_nnnorm_ae_le MeasureTheory.Lp.mem_Lp_of_nnnorm_ae_le
theorem mem_Lp_of_ae_le {f : α →ₘ[μ] E} {g : Lp F p μ} (h : ∀ᵐ x ∂μ, ‖f x‖ ≤ ‖g x‖) :
f ∈ Lp E p μ :=
mem_Lp_of_nnnorm_ae_le h
#align measure_theory.Lp.mem_Lp_of_ae_le MeasureTheory.Lp.mem_Lp_of_ae_le
theorem mem_Lp_of_ae_nnnorm_bound [IsFiniteMeasure μ] {f : α →ₘ[μ] E} (C : ℝ≥0)
(hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : f ∈ Lp E p μ :=
mem_Lp_iff_memℒp.2 <| Memℒp.of_bound f.aestronglyMeasurable _ hfC
#align measure_theory.Lp.mem_Lp_of_ae_nnnorm_bound MeasureTheory.Lp.mem_Lp_of_ae_nnnorm_bound
theorem mem_Lp_of_ae_bound [IsFiniteMeasure μ] {f : α →ₘ[μ] E} (C : ℝ) (hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) :
f ∈ Lp E p μ :=
mem_Lp_iff_memℒp.2 <| Memℒp.of_bound f.aestronglyMeasurable _ hfC
#align measure_theory.Lp.mem_Lp_of_ae_bound MeasureTheory.Lp.mem_Lp_of_ae_bound
theorem nnnorm_le_of_ae_bound [IsFiniteMeasure μ] {f : Lp E p μ} {C : ℝ≥0}
(hfC : ∀ᵐ x ∂μ, ‖f x‖₊ ≤ C) : ‖f‖₊ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * C := by
by_cases hμ : μ = 0
· by_cases hp : p.toReal⁻¹ = 0
· simp [hp, hμ, nnnorm_def]
· simp [hμ, nnnorm_def, Real.zero_rpow hp]
rw [← ENNReal.coe_le_coe, nnnorm_def, ENNReal.coe_toNNReal (snorm_ne_top _)]
refine (snorm_le_of_ae_nnnorm_bound hfC).trans_eq ?_
rw [← coe_measureUnivNNReal μ, ENNReal.coe_rpow_of_ne_zero (measureUnivNNReal_pos hμ).ne',
ENNReal.coe_mul, mul_comm, ENNReal.smul_def, smul_eq_mul]
#align measure_theory.Lp.nnnorm_le_of_ae_bound MeasureTheory.Lp.nnnorm_le_of_ae_bound
theorem norm_le_of_ae_bound [IsFiniteMeasure μ] {f : Lp E p μ} {C : ℝ} (hC : 0 ≤ C)
(hfC : ∀ᵐ x ∂μ, ‖f x‖ ≤ C) : ‖f‖ ≤ measureUnivNNReal μ ^ p.toReal⁻¹ * C := by
lift C to ℝ≥0 using hC
have := nnnorm_le_of_ae_bound hfC
rwa [← NNReal.coe_le_coe, NNReal.coe_mul, NNReal.coe_rpow] at this
#align measure_theory.Lp.norm_le_of_ae_bound MeasureTheory.Lp.norm_le_of_ae_bound
instance instNormedAddCommGroup [hp : Fact (1 ≤ p)] : NormedAddCommGroup (Lp E p μ) :=
{ AddGroupNorm.toNormedAddCommGroup
{ toFun := (norm : Lp E p μ → ℝ)
map_zero' := norm_zero
neg' := by simp
add_le' := fun f g => by
suffices (‖f + g‖₊ : ℝ≥0∞) ≤ ‖f‖₊ + ‖g‖₊ from mod_cast this
simp only [Lp.nnnorm_coe_ennreal]
exact (snorm_congr_ae (AEEqFun.coeFn_add _ _)).trans_le
(snorm_add_le (Lp.aestronglyMeasurable _) (Lp.aestronglyMeasurable _) hp.out)
eq_zero_of_map_eq_zero' := fun f =>
(norm_eq_zero_iff <| zero_lt_one.trans_le hp.1).1 } with
edist := edist
edist_dist := Lp.edist_dist }
#align measure_theory.Lp.normed_add_comm_group MeasureTheory.Lp.instNormedAddCommGroup
-- check no diamond is created
example [Fact (1 ≤ p)] : PseudoEMetricSpace.toEDist = (Lp.instEDist : EDist (Lp E p μ)) := by
with_reducible_and_instances rfl
example [Fact (1 ≤ p)] : SeminormedAddGroup.toNNNorm = (Lp.instNNNorm : NNNorm (Lp E p μ)) := by
with_reducible_and_instances rfl
open MeasureTheory
section Composition
variable {g : E → F} {c : ℝ≥0}
theorem LipschitzWith.comp_memℒp {α E F} {K} [MeasurableSpace α] {μ : Measure α}
[NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : E → F} (hg : LipschitzWith K g)
(g0 : g 0 = 0) (hL : Memℒp f p μ) : Memℒp (g ∘ f) p μ :=
have : ∀ x, ‖g (f x)‖ ≤ K * ‖f x‖ := fun x ↦ by
-- TODO: add `LipschitzWith.nnnorm_sub_le` and `LipschitzWith.nnnorm_le`
simpa [g0] using hg.norm_sub_le (f x) 0
hL.of_le_mul (hg.continuous.comp_aestronglyMeasurable hL.1) (eventually_of_forall this)
#align lipschitz_with.comp_mem_ℒp LipschitzWith.comp_memℒp
theorem MeasureTheory.Memℒp.of_comp_antilipschitzWith {α E F} {K'} [MeasurableSpace α]
{μ : Measure α} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : α → E} {g : E → F}
(hL : Memℒp (g ∘ f) p μ) (hg : UniformContinuous g) (hg' : AntilipschitzWith K' g)
(g0 : g 0 = 0) : Memℒp f p μ := by
have A : ∀ x, ‖f x‖ ≤ K' * ‖g (f x)‖ := by
intro x
-- TODO: add `AntilipschitzWith.le_mul_nnnorm_sub` and `AntilipschitzWith.le_mul_norm`
rw [← dist_zero_right, ← dist_zero_right, ← g0]
apply hg'.le_mul_dist
have B : AEStronglyMeasurable f μ :=
(hg'.uniformEmbedding hg).embedding.aestronglyMeasurable_comp_iff.1 hL.1
exact hL.of_le_mul B (Filter.eventually_of_forall A)
#align measure_theory.mem_ℒp.of_comp_antilipschitz_with MeasureTheory.Memℒp.of_comp_antilipschitzWith
namespace ContinuousLinearMap
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F]
def compLp (L : E →L[𝕜] F) (f : Lp E p μ) : Lp F p μ :=
L.lipschitz.compLp (map_zero L) f
#align continuous_linear_map.comp_Lp ContinuousLinearMap.compLp
theorem coeFn_compLp (L : E →L[𝕜] F) (f : Lp E p μ) : ∀ᵐ a ∂μ, (L.compLp f) a = L (f a) :=
LipschitzWith.coeFn_compLp _ _ _
#align continuous_linear_map.coe_fn_comp_Lp ContinuousLinearMap.coeFn_compLp
theorem coeFn_compLp' (L : E →L[𝕜] F) (f : Lp E p μ) : L.compLp f =ᵐ[μ] fun a => L (f a) :=
L.coeFn_compLp f
#align continuous_linear_map.coe_fn_comp_Lp' ContinuousLinearMap.coeFn_compLp'
theorem comp_memℒp (L : E →L[𝕜] F) (f : Lp E p μ) : Memℒp (L ∘ f) p μ :=
(Lp.memℒp (L.compLp f)).ae_eq (L.coeFn_compLp' f)
#align continuous_linear_map.comp_mem_ℒp ContinuousLinearMap.comp_memℒp
theorem comp_memℒp' (L : E →L[𝕜] F) {f : α → E} (hf : Memℒp f p μ) : Memℒp (L ∘ f) p μ :=
(L.comp_memℒp (hf.toLp f)).ae_eq (EventuallyEq.fun_comp hf.coeFn_toLp _)
#align continuous_linear_map.comp_mem_ℒp' ContinuousLinearMap.comp_memℒp'
namespace MeasureTheory
theorem indicatorConstLp_eq_toSpanSingleton_compLp {s : Set α} [NormedSpace ℝ F]
(hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : F) :
indicatorConstLp 2 hs hμs x =
(ContinuousLinearMap.toSpanSingleton ℝ x).compLp (indicatorConstLp 2 hs hμs (1 : ℝ)) := by
ext1
refine indicatorConstLp_coeFn.trans ?_
have h_compLp :=
(ContinuousLinearMap.toSpanSingleton ℝ x).coeFn_compLp (indicatorConstLp 2 hs hμs (1 : ℝ))
rw [← EventuallyEq] at h_compLp
refine EventuallyEq.trans ?_ h_compLp.symm
refine (@indicatorConstLp_coeFn _ _ _ 2 μ _ s hs hμs (1 : ℝ)).mono fun y hy => ?_
dsimp only
rw [hy]
simp_rw [ContinuousLinearMap.toSpanSingleton_apply]
by_cases hy_mem : y ∈ s <;> simp [hy_mem, ContinuousLinearMap.lsmul_apply]
#align measure_theory.indicator_const_Lp_eq_to_span_singleton_comp_Lp MeasureTheory.indicatorConstLp_eq_toSpanSingleton_compLp
namespace Lp
section CompleteSpace
namespace MeasureTheory
namespace Lp
theorem snorm'_lim_eq_lintegral_liminf {ι} [Nonempty ι] [LinearOrder ι] {f : ι → α → G} {p : ℝ}
(hp_nonneg : 0 ≤ p) {f_lim : α → G}
(h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) :
snorm' f_lim p μ = (∫⁻ a, atTop.liminf fun m => (‖f m a‖₊ : ℝ≥0∞) ^ p ∂μ) ^ (1 / p) := by
suffices h_no_pow :
(∫⁻ a, (‖f_lim a‖₊ : ℝ≥0∞) ^ p ∂μ) = ∫⁻ a, atTop.liminf fun m => (‖f m a‖₊ : ℝ≥0∞) ^ p ∂μ by
rw [snorm', h_no_pow]
refine lintegral_congr_ae (h_lim.mono fun a ha => ?_)
dsimp only
rw [Tendsto.liminf_eq]
simp_rw [ENNReal.coe_rpow_of_nonneg _ hp_nonneg, ENNReal.tendsto_coe]
refine ((NNReal.continuous_rpow_const hp_nonneg).tendsto ‖f_lim a‖₊).comp ?_
exact (continuous_nnnorm.tendsto (f_lim a)).comp ha
#align measure_theory.Lp.snorm'_lim_eq_lintegral_liminf MeasureTheory.Lp.snorm'_lim_eq_lintegral_liminf
theorem snorm'_lim_le_liminf_snorm' {E} [NormedAddCommGroup E] {f : ℕ → α → E} {p : ℝ}
(hp_pos : 0 < p) (hf : ∀ n, AEStronglyMeasurable (f n) μ) {f_lim : α → E}
(h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) :
snorm' f_lim p μ ≤ atTop.liminf fun n => snorm' (f n) p μ := by
rw [snorm'_lim_eq_lintegral_liminf hp_pos.le h_lim]
rw [← ENNReal.le_rpow_one_div_iff (by simp [hp_pos] : 0 < 1 / p), one_div_one_div]
refine (lintegral_liminf_le' fun m => (hf m).ennnorm.pow_const _).trans_eq ?_
have h_pow_liminf :
(atTop.liminf fun n => snorm' (f n) p μ) ^ p = atTop.liminf fun n => snorm' (f n) p μ ^ p := by
have h_rpow_mono := ENNReal.strictMono_rpow_of_pos hp_pos
have h_rpow_surj := (ENNReal.rpow_left_bijective hp_pos.ne.symm).2
refine (h_rpow_mono.orderIsoOfSurjective _ h_rpow_surj).liminf_apply ?_ ?_ ?_ ?_
all_goals isBoundedDefault
rw [h_pow_liminf]
simp_rw [snorm', ← ENNReal.rpow_mul, one_div, inv_mul_cancel hp_pos.ne.symm, ENNReal.rpow_one]
#align measure_theory.Lp.snorm'_lim_le_liminf_snorm' MeasureTheory.Lp.snorm'_lim_le_liminf_snorm'
theorem snorm_exponent_top_lim_eq_essSup_liminf {ι} [Nonempty ι] [LinearOrder ι] {f : ι → α → G}
{f_lim : α → G} (h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) :
snorm f_lim ∞ μ = essSup (fun x => atTop.liminf fun m => (‖f m x‖₊ : ℝ≥0∞)) μ := by
rw [snorm_exponent_top, snormEssSup]
refine essSup_congr_ae (h_lim.mono fun x hx => ?_)
dsimp only
apply (Tendsto.liminf_eq ..).symm
rw [ENNReal.tendsto_coe]
exact (continuous_nnnorm.tendsto (f_lim x)).comp hx
#align measure_theory.Lp.snorm_exponent_top_lim_eq_ess_sup_liminf MeasureTheory.Lp.snorm_exponent_top_lim_eq_essSup_liminf
theorem snorm_exponent_top_lim_le_liminf_snorm_exponent_top {ι} [Nonempty ι] [Countable ι]
[LinearOrder ι] {f : ι → α → F} {f_lim : α → F}
(h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) :
snorm f_lim ∞ μ ≤ atTop.liminf fun n => snorm (f n) ∞ μ := by
rw [snorm_exponent_top_lim_eq_essSup_liminf h_lim]
simp_rw [snorm_exponent_top, snormEssSup]
exact ENNReal.essSup_liminf_le fun n => fun x => (‖f n x‖₊ : ℝ≥0∞)
#align measure_theory.Lp.snorm_exponent_top_lim_le_liminf_snorm_exponent_top MeasureTheory.Lp.snorm_exponent_top_lim_le_liminf_snorm_exponent_top
theorem snorm_lim_le_liminf_snorm {E} [NormedAddCommGroup E] {f : ℕ → α → E}
(hf : ∀ n, AEStronglyMeasurable (f n) μ) (f_lim : α → E)
(h_lim : ∀ᵐ x : α ∂μ, Tendsto (fun n => f n x) atTop (𝓝 (f_lim x))) :
snorm f_lim p μ ≤ atTop.liminf fun n => snorm (f n) p μ := by
obtain rfl|hp0 := eq_or_ne p 0
· simp
by_cases hp_top : p = ∞
· simp_rw [hp_top]
exact snorm_exponent_top_lim_le_liminf_snorm_exponent_top h_lim
simp_rw [snorm_eq_snorm' hp0 hp_top]
have hp_pos : 0 < p.toReal := ENNReal.toReal_pos hp0 hp_top
exact snorm'_lim_le_liminf_snorm' hp_pos hf h_lim
#align measure_theory.Lp.snorm_lim_le_liminf_snorm MeasureTheory.Lp.snorm_lim_le_liminf_snorm
theorem tendsto_Lp_iff_tendsto_ℒp' {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → Lp E p μ)
(f_lim : Lp E p μ) :
fi.Tendsto f (𝓝 f_lim) ↔ fi.Tendsto (fun n => snorm (⇑(f n) - ⇑f_lim) p μ) (𝓝 0) := by
rw [tendsto_iff_dist_tendsto_zero]
simp_rw [dist_def]
rw [← ENNReal.zero_toReal, ENNReal.tendsto_toReal_iff (fun n => ?_) ENNReal.zero_ne_top]
rw [snorm_congr_ae (Lp.coeFn_sub _ _).symm]
exact Lp.snorm_ne_top _
#align measure_theory.Lp.tendsto_Lp_iff_tendsto_ℒp' MeasureTheory.Lp.tendsto_Lp_iff_tendsto_ℒp'
theorem tendsto_Lp_iff_tendsto_ℒp {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → Lp E p μ)
(f_lim : α → E) (f_lim_ℒp : Memℒp f_lim p μ) :
fi.Tendsto f (𝓝 (f_lim_ℒp.toLp f_lim)) ↔
fi.Tendsto (fun n => snorm (⇑(f n) - f_lim) p μ) (𝓝 0) := by
rw [tendsto_Lp_iff_tendsto_ℒp']
suffices h_eq :
(fun n => snorm (⇑(f n) - ⇑(Memℒp.toLp f_lim f_lim_ℒp)) p μ) =
(fun n => snorm (⇑(f n) - f_lim) p μ) by
rw [h_eq]
exact funext fun n => snorm_congr_ae (EventuallyEq.rfl.sub (Memℒp.coeFn_toLp f_lim_ℒp))
#align measure_theory.Lp.tendsto_Lp_iff_tendsto_ℒp MeasureTheory.Lp.tendsto_Lp_iff_tendsto_ℒp
theorem tendsto_Lp_iff_tendsto_ℒp'' {ι} {fi : Filter ι} [Fact (1 ≤ p)] (f : ι → α → E)
(f_ℒp : ∀ n, Memℒp (f n) p μ) (f_lim : α → E) (f_lim_ℒp : Memℒp f_lim p μ) :
fi.Tendsto (fun n => (f_ℒp n).toLp (f n)) (𝓝 (f_lim_ℒp.toLp f_lim)) ↔
fi.Tendsto (fun n => snorm (f n - f_lim) p μ) (𝓝 0) := by
rw [Lp.tendsto_Lp_iff_tendsto_ℒp' (fun n => (f_ℒp n).toLp (f n)) (f_lim_ℒp.toLp f_lim)]
refine Filter.tendsto_congr fun n => ?_
apply snorm_congr_ae
filter_upwards [((f_ℒp n).sub f_lim_ℒp).coeFn_toLp,
Lp.coeFn_sub ((f_ℒp n).toLp (f n)) (f_lim_ℒp.toLp f_lim)] with _ hx₁ hx₂
rw [← hx₂]
exact hx₁
#align measure_theory.Lp.tendsto_Lp_iff_tendsto_ℒp'' MeasureTheory.Lp.tendsto_Lp_iff_tendsto_ℒp''
theorem tendsto_Lp_of_tendsto_ℒp {ι} {fi : Filter ι} [Fact (1 ≤ p)] {f : ι → Lp E p μ}
(f_lim : α → E) (f_lim_ℒp : Memℒp f_lim p μ)
(h_tendsto : fi.Tendsto (fun n => snorm (⇑(f n) - f_lim) p μ) (𝓝 0)) :
fi.Tendsto f (𝓝 (f_lim_ℒp.toLp f_lim)) :=
(tendsto_Lp_iff_tendsto_ℒp f f_lim f_lim_ℒp).mpr h_tendsto
#align measure_theory.Lp.tendsto_Lp_of_tendsto_ℒp MeasureTheory.Lp.tendsto_Lp_of_tendsto_ℒp
theorem cauchySeq_Lp_iff_cauchySeq_ℒp {ι} [Nonempty ι] [SemilatticeSup ι] [hp : Fact (1 ≤ p)]
(f : ι → Lp E p μ) :
CauchySeq f ↔ Tendsto (fun n : ι × ι => snorm (⇑(f n.fst) - ⇑(f n.snd)) p μ) atTop (𝓝 0) := by
simp_rw [cauchySeq_iff_tendsto_dist_atTop_0, dist_def]
rw [← ENNReal.zero_toReal, ENNReal.tendsto_toReal_iff (fun n => ?_) ENNReal.zero_ne_top]
rw [snorm_congr_ae (Lp.coeFn_sub _ _).symm]
exact snorm_ne_top _
#align measure_theory.Lp.cauchy_seq_Lp_iff_cauchy_seq_ℒp MeasureTheory.Lp.cauchySeq_Lp_iff_cauchySeq_ℒp
| Mathlib/MeasureTheory/Function/LpSpace.lean | 1,457 | 1,490 | theorem completeSpace_lp_of_cauchy_complete_ℒp [hp : Fact (1 ≤ p)]
(H :
∀ (f : ℕ → α → E) (hf : ∀ n, Memℒp (f n) p μ) (B : ℕ → ℝ≥0∞) (hB : ∑' i, B i < ∞)
(h_cau : ∀ N n m : ℕ, N ≤ n → N ≤ m → snorm (f n - f m) p μ < B N),
∃ (f_lim : α → E), Memℒp f_lim p μ ∧
atTop.Tendsto (fun n => snorm (f n - f_lim) p μ) (𝓝 0)) :
CompleteSpace (Lp E p μ) := by |
let B := fun n : ℕ => ((1 : ℝ) / 2) ^ n
have hB_pos : ∀ n, 0 < B n := fun n => pow_pos (div_pos zero_lt_one zero_lt_two) n
refine Metric.complete_of_convergent_controlled_sequences B hB_pos fun f hf => ?_
rsuffices ⟨f_lim, hf_lim_meas, h_tendsto⟩ :
∃ (f_lim : α → E), Memℒp f_lim p μ ∧
atTop.Tendsto (fun n => snorm (⇑(f n) - f_lim) p μ) (𝓝 0)
· exact ⟨hf_lim_meas.toLp f_lim, tendsto_Lp_of_tendsto_ℒp f_lim hf_lim_meas h_tendsto⟩
obtain ⟨M, hB⟩ : Summable B := summable_geometric_two
let B1 n := ENNReal.ofReal (B n)
have hB1_has : HasSum B1 (ENNReal.ofReal M) := by
have h_tsum_B1 : ∑' i, B1 i = ENNReal.ofReal M := by
change (∑' n : ℕ, ENNReal.ofReal (B n)) = ENNReal.ofReal M
rw [← hB.tsum_eq]
exact (ENNReal.ofReal_tsum_of_nonneg (fun n => le_of_lt (hB_pos n)) hB.summable).symm
have h_sum := (@ENNReal.summable _ B1).hasSum
rwa [h_tsum_B1] at h_sum
have hB1 : ∑' i, B1 i < ∞ := by
rw [hB1_has.tsum_eq]
exact ENNReal.ofReal_lt_top
let f1 : ℕ → α → E := fun n => f n
refine H f1 (fun n => Lp.memℒp (f n)) B1 hB1 fun N n m hn hm => ?_
specialize hf N n m hn hm
rw [dist_def] at hf
dsimp only [f1]
rwa [ENNReal.lt_ofReal_iff_toReal_lt]
rw [snorm_congr_ae (Lp.coeFn_sub _ _).symm]
exact Lp.snorm_ne_top _
|
import Mathlib.MeasureTheory.Measure.MeasureSpace
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
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ₗ
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
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₀
@[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
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'
@[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
@[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
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
#align measure_theory.measure.restrict_restrict_of_subset MeasureTheory.Measure.restrict_restrict_of_subset
theorem restrict_restrict₀' (ht : NullMeasurableSet t μ) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
ext fun u hu => by simp only [restrict_apply hu, restrict_apply₀' ht, inter_assoc]
#align measure_theory.measure.restrict_restrict₀' MeasureTheory.Measure.restrict_restrict₀'
theorem restrict_restrict' (ht : MeasurableSet t) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
restrict_restrict₀' ht.nullMeasurableSet
#align measure_theory.measure.restrict_restrict' MeasureTheory.Measure.restrict_restrict'
theorem restrict_comm (hs : MeasurableSet s) :
(μ.restrict t).restrict s = (μ.restrict s).restrict t := by
rw [restrict_restrict hs, restrict_restrict' hs, inter_comm]
#align measure_theory.measure.restrict_comm MeasureTheory.Measure.restrict_comm
| Mathlib/MeasureTheory/Measure/Restrict.lean | 208 | 209 | theorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by |
rw [restrict_apply ht]
|
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"
open Rat Real multiplicity
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
theorem Transcendental.irrational {r : ℝ} (tr : Transcendental ℚ r) : Irrational r := by
rintro ⟨a, rfl⟩
exact tr (isAlgebraic_algebraMap a)
#align transcendental.irrational Transcendental.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
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
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)
@[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 : ℝ}
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⟩
#align irrational.add_cases Irrational.add_cases
theorem of_rat_add (h : Irrational (q + x)) : Irrational x :=
h.add_cases.resolve_left q.not_irrational
#align irrational.of_rat_add Irrational.of_rat_add
theorem rat_add (h : Irrational x) : Irrational (q + x) :=
of_rat_add (-q) <| by rwa [cast_neg, neg_add_cancel_left]
#align irrational.rat_add Irrational.rat_add
theorem of_add_rat : Irrational (x + q) → Irrational x :=
add_comm (↑q) x ▸ of_rat_add q
#align irrational.of_add_rat Irrational.of_add_rat
theorem add_rat (h : Irrational x) : Irrational (x + q) :=
add_comm (↑q) x ▸ h.rat_add q
#align irrational.add_rat Irrational.add_rat
theorem of_int_add (m : ℤ) (h : Irrational (m + x)) : Irrational x := by
rw [← cast_intCast] at h
exact h.of_rat_add m
#align irrational.of_int_add Irrational.of_int_add
theorem of_add_int (m : ℤ) (h : Irrational (x + m)) : Irrational x :=
of_int_add m <| add_comm x m ▸ h
#align irrational.of_add_int Irrational.of_add_int
theorem int_add (h : Irrational x) (m : ℤ) : Irrational (m + x) := by
rw [← cast_intCast]
exact h.rat_add m
#align irrational.int_add Irrational.int_add
theorem add_int (h : Irrational x) (m : ℤ) : Irrational (x + m) :=
add_comm (↑m) x ▸ h.int_add m
#align irrational.add_int Irrational.add_int
theorem of_nat_add (m : ℕ) (h : Irrational (m + x)) : Irrational x :=
h.of_int_add m
#align irrational.of_nat_add Irrational.of_nat_add
theorem of_add_nat (m : ℕ) (h : Irrational (x + m)) : Irrational x :=
h.of_add_int m
#align irrational.of_add_nat Irrational.of_add_nat
theorem nat_add (h : Irrational x) (m : ℕ) : Irrational (m + x) :=
h.int_add m
#align irrational.nat_add Irrational.nat_add
theorem add_nat (h : Irrational x) (m : ℕ) : Irrational (x + m) :=
h.add_int m
#align irrational.add_nat Irrational.add_nat
theorem of_neg (h : Irrational (-x)) : Irrational x := fun ⟨q, hx⟩ => h ⟨-q, by rw [cast_neg, hx]⟩
#align irrational.of_neg Irrational.of_neg
protected theorem neg (h : Irrational x) : Irrational (-x) :=
of_neg <| by rwa [neg_neg]
#align irrational.neg Irrational.neg
theorem sub_rat (h : Irrational x) : Irrational (x - q) := by
simpa only [sub_eq_add_neg, cast_neg] using h.add_rat (-q)
#align irrational.sub_rat Irrational.sub_rat
theorem rat_sub (h : Irrational x) : Irrational (q - x) := by
simpa only [sub_eq_add_neg] using h.neg.rat_add q
#align irrational.rat_sub Irrational.rat_sub
theorem of_sub_rat (h : Irrational (x - q)) : Irrational x :=
of_add_rat (-q) <| by simpa only [cast_neg, sub_eq_add_neg] using h
#align irrational.of_sub_rat Irrational.of_sub_rat
theorem of_rat_sub (h : Irrational (q - x)) : Irrational x :=
of_neg (of_rat_add q (by simpa only [sub_eq_add_neg] using h))
#align irrational.of_rat_sub Irrational.of_rat_sub
theorem sub_int (h : Irrational x) (m : ℤ) : Irrational (x - m) := by
simpa only [Rat.cast_intCast] using h.sub_rat m
#align irrational.sub_int Irrational.sub_int
theorem int_sub (h : Irrational x) (m : ℤ) : Irrational (m - x) := by
simpa only [Rat.cast_intCast] using h.rat_sub m
#align irrational.int_sub Irrational.int_sub
theorem of_sub_int (m : ℤ) (h : Irrational (x - m)) : Irrational x :=
of_sub_rat m <| by rwa [Rat.cast_intCast]
#align irrational.of_sub_int Irrational.of_sub_int
theorem of_int_sub (m : ℤ) (h : Irrational (m - x)) : Irrational x :=
of_rat_sub m <| by rwa [Rat.cast_intCast]
#align irrational.of_int_sub Irrational.of_int_sub
theorem sub_nat (h : Irrational x) (m : ℕ) : Irrational (x - m) :=
h.sub_int m
#align irrational.sub_nat Irrational.sub_nat
theorem nat_sub (h : Irrational x) (m : ℕ) : Irrational (m - x) :=
h.int_sub m
#align irrational.nat_sub Irrational.nat_sub
theorem of_sub_nat (m : ℕ) (h : Irrational (x - m)) : Irrational x :=
h.of_sub_int m
#align irrational.of_sub_nat Irrational.of_sub_nat
theorem of_nat_sub (m : ℕ) (h : Irrational (m - x)) : Irrational x :=
h.of_int_sub m
#align irrational.of_nat_sub Irrational.of_nat_sub
theorem mul_cases : Irrational (x * y) → Irrational x ∨ Irrational y := by
delta Irrational
contrapose!
rintro ⟨⟨rx, rfl⟩, ⟨ry, rfl⟩⟩
exact ⟨rx * ry, cast_mul rx ry⟩
#align irrational.mul_cases Irrational.mul_cases
theorem of_mul_rat (h : Irrational (x * q)) : Irrational x :=
h.mul_cases.resolve_right q.not_irrational
#align irrational.of_mul_rat Irrational.of_mul_rat
theorem mul_rat (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (x * q) :=
of_mul_rat q⁻¹ <| by rwa [mul_assoc, ← cast_mul, mul_inv_cancel hq, cast_one, mul_one]
#align irrational.mul_rat Irrational.mul_rat
theorem of_rat_mul : Irrational (q * x) → Irrational x :=
mul_comm x q ▸ of_mul_rat q
#align irrational.of_rat_mul Irrational.of_rat_mul
theorem rat_mul (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (q * x) :=
mul_comm x q ▸ h.mul_rat hq
#align irrational.rat_mul Irrational.rat_mul
theorem of_mul_int (m : ℤ) (h : Irrational (x * m)) : Irrational x :=
of_mul_rat m <| by rwa [cast_intCast]
#align irrational.of_mul_int Irrational.of_mul_int
theorem of_int_mul (m : ℤ) (h : Irrational (m * x)) : Irrational x :=
of_rat_mul m <| by rwa [cast_intCast]
#align irrational.of_int_mul Irrational.of_int_mul
theorem mul_int (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (x * m) := by
rw [← cast_intCast]
refine h.mul_rat ?_
rwa [Int.cast_ne_zero]
#align irrational.mul_int Irrational.mul_int
theorem int_mul (h : Irrational x) {m : ℤ} (hm : m ≠ 0) : Irrational (m * x) :=
mul_comm x m ▸ h.mul_int hm
#align irrational.int_mul Irrational.int_mul
theorem of_mul_nat (m : ℕ) (h : Irrational (x * m)) : Irrational x :=
h.of_mul_int m
#align irrational.of_mul_nat Irrational.of_mul_nat
theorem of_nat_mul (m : ℕ) (h : Irrational (m * x)) : Irrational x :=
h.of_int_mul m
#align irrational.of_nat_mul Irrational.of_nat_mul
theorem mul_nat (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (x * m) :=
h.mul_int <| Int.natCast_ne_zero.2 hm
#align irrational.mul_nat Irrational.mul_nat
theorem nat_mul (h : Irrational x) {m : ℕ} (hm : m ≠ 0) : Irrational (m * x) :=
h.int_mul <| Int.natCast_ne_zero.2 hm
#align irrational.nat_mul Irrational.nat_mul
theorem of_inv (h : Irrational x⁻¹) : Irrational x := fun ⟨q, hq⟩ => h <| hq ▸ ⟨q⁻¹, q.cast_inv⟩
#align irrational.of_inv Irrational.of_inv
protected theorem inv (h : Irrational x) : Irrational x⁻¹ :=
of_inv <| by rwa [inv_inv]
#align irrational.inv Irrational.inv
theorem div_cases (h : Irrational (x / y)) : Irrational x ∨ Irrational y :=
h.mul_cases.imp id of_inv
#align irrational.div_cases Irrational.div_cases
theorem of_rat_div (h : Irrational (q / x)) : Irrational x :=
(h.of_rat_mul q).of_inv
#align irrational.of_rat_div Irrational.of_rat_div
theorem of_div_rat (h : Irrational (x / q)) : Irrational x :=
h.div_cases.resolve_right q.not_irrational
#align irrational.of_div_rat Irrational.of_div_rat
theorem rat_div (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (q / x) :=
h.inv.rat_mul hq
#align irrational.rat_div Irrational.rat_div
| Mathlib/Data/Real/Irrational.lean | 415 | 417 | theorem div_rat (h : Irrational x) {q : ℚ} (hq : q ≠ 0) : Irrational (x / q) := by |
rw [div_eq_mul_inv, ← cast_inv]
exact h.mul_rat (inv_ne_zero hq)
|
import Mathlib.Order.Cover
import Mathlib.Order.Interval.Finset.Defs
#align_import data.finset.locally_finite from "leanprover-community/mathlib"@"442a83d738cb208d3600056c489be16900ba701d"
assert_not_exists MonoidWithZero
assert_not_exists Finset.sum
open Function OrderDual
open FinsetInterval
variable {ι α : Type*}
namespace Finset
section Preorder
variable [Preorder α]
section LocallyFiniteOrder
variable [LocallyFiniteOrder α] {a a₁ a₂ b b₁ b₂ c x : α}
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem nonempty_Icc : (Icc a b).Nonempty ↔ a ≤ b := by
rw [← coe_nonempty, coe_Icc, Set.nonempty_Icc]
#align finset.nonempty_Icc Finset.nonempty_Icc
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem nonempty_Ico : (Ico a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ico, Set.nonempty_Ico]
#align finset.nonempty_Ico Finset.nonempty_Ico
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
theorem nonempty_Ioc : (Ioc a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ioc, Set.nonempty_Ioc]
#align finset.nonempty_Ioc Finset.nonempty_Ioc
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem nonempty_Ioo [DenselyOrdered α] : (Ioo a b).Nonempty ↔ a < b := by
rw [← coe_nonempty, coe_Ioo, Set.nonempty_Ioo]
#align finset.nonempty_Ioo Finset.nonempty_Ioo
@[simp]
theorem Icc_eq_empty_iff : Icc a b = ∅ ↔ ¬a ≤ b := by
rw [← coe_eq_empty, coe_Icc, Set.Icc_eq_empty_iff]
#align finset.Icc_eq_empty_iff Finset.Icc_eq_empty_iff
@[simp]
theorem Ico_eq_empty_iff : Ico a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ico, Set.Ico_eq_empty_iff]
#align finset.Ico_eq_empty_iff Finset.Ico_eq_empty_iff
@[simp]
theorem Ioc_eq_empty_iff : Ioc a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ioc, Set.Ioc_eq_empty_iff]
#align finset.Ioc_eq_empty_iff Finset.Ioc_eq_empty_iff
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem Ioo_eq_empty_iff [DenselyOrdered α] : Ioo a b = ∅ ↔ ¬a < b := by
rw [← coe_eq_empty, coe_Ioo, Set.Ioo_eq_empty_iff]
#align finset.Ioo_eq_empty_iff Finset.Ioo_eq_empty_iff
alias ⟨_, Icc_eq_empty⟩ := Icc_eq_empty_iff
#align finset.Icc_eq_empty Finset.Icc_eq_empty
alias ⟨_, Ico_eq_empty⟩ := Ico_eq_empty_iff
#align finset.Ico_eq_empty Finset.Ico_eq_empty
alias ⟨_, Ioc_eq_empty⟩ := Ioc_eq_empty_iff
#align finset.Ioc_eq_empty Finset.Ioc_eq_empty
@[simp]
theorem Ioo_eq_empty (h : ¬a < b) : Ioo a b = ∅ :=
eq_empty_iff_forall_not_mem.2 fun _ hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2)
#align finset.Ioo_eq_empty Finset.Ioo_eq_empty
@[simp]
theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = ∅ :=
Icc_eq_empty h.not_le
#align finset.Icc_eq_empty_of_lt Finset.Icc_eq_empty_of_lt
@[simp]
theorem Ico_eq_empty_of_le (h : b ≤ a) : Ico a b = ∅ :=
Ico_eq_empty h.not_lt
#align finset.Ico_eq_empty_of_le Finset.Ico_eq_empty_of_le
@[simp]
theorem Ioc_eq_empty_of_le (h : b ≤ a) : Ioc a b = ∅ :=
Ioc_eq_empty h.not_lt
#align finset.Ioc_eq_empty_of_le Finset.Ioc_eq_empty_of_le
@[simp]
theorem Ioo_eq_empty_of_le (h : b ≤ a) : Ioo a b = ∅ :=
Ioo_eq_empty h.not_lt
#align finset.Ioo_eq_empty_of_le Finset.Ioo_eq_empty_of_le
-- porting note (#10618): simp can prove this
-- @[simp]
theorem left_mem_Icc : a ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, true_and_iff, le_rfl]
#align finset.left_mem_Icc Finset.left_mem_Icc
-- porting note (#10618): simp can prove this
-- @[simp]
theorem left_mem_Ico : a ∈ Ico a b ↔ a < b := by simp only [mem_Ico, true_and_iff, le_refl]
#align finset.left_mem_Ico Finset.left_mem_Ico
-- porting note (#10618): simp can prove this
-- @[simp]
theorem right_mem_Icc : b ∈ Icc a b ↔ a ≤ b := by simp only [mem_Icc, and_true_iff, le_rfl]
#align finset.right_mem_Icc Finset.right_mem_Icc
-- porting note (#10618): simp can prove this
-- @[simp]
theorem right_mem_Ioc : b ∈ Ioc a b ↔ a < b := by simp only [mem_Ioc, and_true_iff, le_rfl]
#align finset.right_mem_Ioc Finset.right_mem_Ioc
-- porting note (#10618): simp can prove this
-- @[simp]
theorem left_not_mem_Ioc : a ∉ Ioc a b := fun h => lt_irrefl _ (mem_Ioc.1 h).1
#align finset.left_not_mem_Ioc Finset.left_not_mem_Ioc
-- porting note (#10618): simp can prove this
-- @[simp]
theorem left_not_mem_Ioo : a ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).1
#align finset.left_not_mem_Ioo Finset.left_not_mem_Ioo
-- porting note (#10618): simp can prove this
-- @[simp]
theorem right_not_mem_Ico : b ∉ Ico a b := fun h => lt_irrefl _ (mem_Ico.1 h).2
#align finset.right_not_mem_Ico Finset.right_not_mem_Ico
-- porting note (#10618): simp can prove this
-- @[simp]
theorem right_not_mem_Ioo : b ∉ Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).2
#align finset.right_not_mem_Ioo Finset.right_not_mem_Ioo
theorem Icc_subset_Icc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Icc a₁ b₁ ⊆ Icc a₂ b₂ := by
simpa [← coe_subset] using Set.Icc_subset_Icc ha hb
#align finset.Icc_subset_Icc Finset.Icc_subset_Icc
theorem Ico_subset_Ico (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ico a₁ b₁ ⊆ Ico a₂ b₂ := by
simpa [← coe_subset] using Set.Ico_subset_Ico ha hb
#align finset.Ico_subset_Ico Finset.Ico_subset_Ico
theorem Ioc_subset_Ioc (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioc a₁ b₁ ⊆ Ioc a₂ b₂ := by
simpa [← coe_subset] using Set.Ioc_subset_Ioc ha hb
#align finset.Ioc_subset_Ioc Finset.Ioc_subset_Ioc
theorem Ioo_subset_Ioo (ha : a₂ ≤ a₁) (hb : b₁ ≤ b₂) : Ioo a₁ b₁ ⊆ Ioo a₂ b₂ := by
simpa [← coe_subset] using Set.Ioo_subset_Ioo ha hb
#align finset.Ioo_subset_Ioo Finset.Ioo_subset_Ioo
theorem Icc_subset_Icc_left (h : a₁ ≤ a₂) : Icc a₂ b ⊆ Icc a₁ b :=
Icc_subset_Icc h le_rfl
#align finset.Icc_subset_Icc_left Finset.Icc_subset_Icc_left
theorem Ico_subset_Ico_left (h : a₁ ≤ a₂) : Ico a₂ b ⊆ Ico a₁ b :=
Ico_subset_Ico h le_rfl
#align finset.Ico_subset_Ico_left Finset.Ico_subset_Ico_left
theorem Ioc_subset_Ioc_left (h : a₁ ≤ a₂) : Ioc a₂ b ⊆ Ioc a₁ b :=
Ioc_subset_Ioc h le_rfl
#align finset.Ioc_subset_Ioc_left Finset.Ioc_subset_Ioc_left
theorem Ioo_subset_Ioo_left (h : a₁ ≤ a₂) : Ioo a₂ b ⊆ Ioo a₁ b :=
Ioo_subset_Ioo h le_rfl
#align finset.Ioo_subset_Ioo_left Finset.Ioo_subset_Ioo_left
theorem Icc_subset_Icc_right (h : b₁ ≤ b₂) : Icc a b₁ ⊆ Icc a b₂ :=
Icc_subset_Icc le_rfl h
#align finset.Icc_subset_Icc_right Finset.Icc_subset_Icc_right
theorem Ico_subset_Ico_right (h : b₁ ≤ b₂) : Ico a b₁ ⊆ Ico a b₂ :=
Ico_subset_Ico le_rfl h
#align finset.Ico_subset_Ico_right Finset.Ico_subset_Ico_right
theorem Ioc_subset_Ioc_right (h : b₁ ≤ b₂) : Ioc a b₁ ⊆ Ioc a b₂ :=
Ioc_subset_Ioc le_rfl h
#align finset.Ioc_subset_Ioc_right Finset.Ioc_subset_Ioc_right
theorem Ioo_subset_Ioo_right (h : b₁ ≤ b₂) : Ioo a b₁ ⊆ Ioo a b₂ :=
Ioo_subset_Ioo le_rfl h
#align finset.Ioo_subset_Ioo_right Finset.Ioo_subset_Ioo_right
| Mathlib/Order/Interval/Finset/Basic.lean | 220 | 222 | theorem Ico_subset_Ioo_left (h : a₁ < a₂) : Ico a₂ b ⊆ Ioo a₁ b := by |
rw [← coe_subset, coe_Ico, coe_Ioo]
exact Set.Ico_subset_Ioo_left h
|
import Mathlib.Topology.Connected.Basic
import Mathlib.Topology.Separation
open scoped Topology
variable {X Y A} [TopologicalSpace X] [TopologicalSpace A]
theorem embedding_toPullbackDiag (f : X → Y) : Embedding (toPullbackDiag f) :=
Embedding.mk' _ (injective_toPullbackDiag f) fun x ↦ by
rw [toPullbackDiag, nhds_induced, Filter.comap_comap, nhds_prod_eq, Filter.comap_prod]
erw [Filter.comap_id, inf_idem]
lemma Continuous.mapPullback {X₁ X₂ Y₁ Y₂ Z₁ Z₂}
[TopologicalSpace X₁] [TopologicalSpace X₂] [TopologicalSpace Z₁] [TopologicalSpace Z₂]
{f₁ : X₁ → Y₁} {g₁ : Z₁ → Y₁} {f₂ : X₂ → Y₂} {g₂ : Z₂ → Y₂}
{mapX : X₁ → X₂} (contX : Continuous mapX) {mapY : Y₁ → Y₂}
{mapZ : Z₁ → Z₂} (contZ : Continuous mapZ)
{commX : f₂ ∘ mapX = mapY ∘ f₁} {commZ : g₂ ∘ mapZ = mapY ∘ g₁} :
Continuous (Function.mapPullback mapX mapY mapZ commX commZ) := by
refine continuous_induced_rng.mpr (continuous_prod_mk.mpr ⟨?_, ?_⟩) <;>
apply_rules [continuous_fst, continuous_snd, continuous_subtype_val, Continuous.comp]
def IsSeparatedMap (f : X → Y) : Prop := ∀ x₁ x₂, f x₁ = f x₂ →
x₁ ≠ x₂ → ∃ s₁ s₂, IsOpen s₁ ∧ IsOpen s₂ ∧ x₁ ∈ s₁ ∧ x₂ ∈ s₂ ∧ Disjoint s₁ s₂
lemma t2space_iff_isSeparatedMap (y : Y) : T2Space X ↔ IsSeparatedMap fun _ : X ↦ y :=
⟨fun ⟨t2⟩ _ _ _ hne ↦ t2 hne, fun sep ↦ ⟨fun x₁ x₂ hne ↦ sep x₁ x₂ rfl hne⟩⟩
lemma T2Space.isSeparatedMap [T2Space X] (f : X → Y) : IsSeparatedMap f := fun _ _ _ ↦ t2_separation
lemma Function.Injective.isSeparatedMap {f : X → Y} (inj : f.Injective) : IsSeparatedMap f :=
fun _ _ he hne ↦ (hne (inj he)).elim
lemma isSeparatedMap_iff_disjoint_nhds {f : X → Y} : IsSeparatedMap f ↔
∀ x₁ x₂, f x₁ = f x₂ → x₁ ≠ x₂ → Disjoint (𝓝 x₁) (𝓝 x₂) :=
forall₃_congr fun x x' _ ↦ by simp only [(nhds_basis_opens x).disjoint_iff (nhds_basis_opens x'),
exists_prop, ← exists_and_left, and_assoc, and_comm, and_left_comm]
lemma isSeparatedMap_iff_nhds {f : X → Y} : IsSeparatedMap f ↔
∀ x₁ x₂, f x₁ = f x₂ → x₁ ≠ x₂ → ∃ s₁ ∈ 𝓝 x₁, ∃ s₂ ∈ 𝓝 x₂, Disjoint s₁ s₂ := by
simp_rw [isSeparatedMap_iff_disjoint_nhds, Filter.disjoint_iff]
open Set Filter in
theorem isSeparatedMap_iff_isClosed_diagonal {f : X → Y} :
IsSeparatedMap f ↔ IsClosed f.pullbackDiagonal := by
simp_rw [isSeparatedMap_iff_nhds, ← isOpen_compl_iff, isOpen_iff_mem_nhds,
Subtype.forall, Prod.forall, nhds_induced, nhds_prod_eq]
refine forall₄_congr fun x₁ x₂ _ _ ↦ ⟨fun h ↦ ?_, fun ⟨t, ht, t_sub⟩ ↦ ?_⟩
· simp_rw [← Filter.disjoint_iff, ← compl_diagonal_mem_prod] at h
exact ⟨_, h, subset_rfl⟩
· obtain ⟨s₁, h₁, s₂, h₂, s_sub⟩ := mem_prod_iff.mp ht
exact ⟨s₁, h₁, s₂, h₂, disjoint_left.2 fun x h₁ h₂ ↦ @t_sub ⟨(x, x), rfl⟩ (s_sub ⟨h₁, h₂⟩) rfl⟩
theorem isSeparatedMap_iff_closedEmbedding {f : X → Y} :
IsSeparatedMap f ↔ ClosedEmbedding (toPullbackDiag f) := by
rw [isSeparatedMap_iff_isClosed_diagonal, ← range_toPullbackDiag]
exact ⟨fun h ↦ ⟨embedding_toPullbackDiag f, h⟩, fun h ↦ h.isClosed_range⟩
theorem isSeparatedMap_iff_isClosedMap {f : X → Y} :
IsSeparatedMap f ↔ IsClosedMap (toPullbackDiag f) :=
isSeparatedMap_iff_closedEmbedding.trans
⟨ClosedEmbedding.isClosedMap, closedEmbedding_of_continuous_injective_closed
(embedding_toPullbackDiag f).continuous (injective_toPullbackDiag f)⟩
open Function.Pullback in
theorem IsSeparatedMap.pullback {f : X → Y} (sep : IsSeparatedMap f) (g : A → Y) :
IsSeparatedMap (@snd X Y A f g) := by
rw [isSeparatedMap_iff_isClosed_diagonal] at sep ⊢
rw [← preimage_map_fst_pullbackDiagonal]
refine sep.preimage (Continuous.mapPullback ?_ ?_) <;>
apply_rules [continuous_fst, continuous_subtype_val, Continuous.comp]
theorem IsSeparatedMap.comp_left {f : X → Y} (sep : IsSeparatedMap f) {g : Y → A}
(inj : g.Injective) : IsSeparatedMap (g ∘ f) := fun x₁ x₂ he ↦ sep x₁ x₂ (inj he)
theorem IsSeparatedMap.comp_right {f : X → Y} (sep : IsSeparatedMap f) {g : A → X}
(cont : Continuous g) (inj : g.Injective) : IsSeparatedMap (f ∘ g) := by
rw [isSeparatedMap_iff_isClosed_diagonal] at sep ⊢
rw [← inj.preimage_pullbackDiagonal]
exact sep.preimage (cont.mapPullback cont)
def IsLocallyInjective (f : X → Y) : Prop := ∀ x : X, ∃ U, IsOpen U ∧ x ∈ U ∧ U.InjOn f
lemma Function.Injective.IsLocallyInjective {f : X → Y} (inj : f.Injective) :
IsLocallyInjective f := fun _ ↦ ⟨_, isOpen_univ, trivial, fun _ _ _ _ ↦ @inj _ _⟩
lemma isLocallyInjective_iff_nhds {f : X → Y} :
IsLocallyInjective f ↔ ∀ x : X, ∃ U ∈ 𝓝 x, U.InjOn f := by
constructor <;> intro h x
· obtain ⟨U, ho, hm, hi⟩ := h x; exact ⟨U, ho.mem_nhds hm, hi⟩
· obtain ⟨U, hn, hi⟩ := h x
exact ⟨interior U, isOpen_interior, mem_interior_iff_mem_nhds.mpr hn, hi.mono interior_subset⟩
theorem isLocallyInjective_iff_isOpen_diagonal {f : X → Y} :
IsLocallyInjective f ↔ IsOpen f.pullbackDiagonal := by
simp_rw [isLocallyInjective_iff_nhds, isOpen_iff_mem_nhds,
Subtype.forall, Prod.forall, nhds_induced, nhds_prod_eq, Filter.mem_comap]
refine ⟨?_, fun h x ↦ ?_⟩
· rintro h x x' hx (rfl : x = x')
obtain ⟨U, hn, hi⟩ := h x
exact ⟨_, Filter.prod_mem_prod hn hn, fun {p} hp ↦ hi hp.1 hp.2 p.2⟩
· obtain ⟨t, ht, t_sub⟩ := h x x rfl rfl
obtain ⟨t₁, h₁, t₂, h₂, prod_sub⟩ := Filter.mem_prod_iff.mp ht
exact ⟨t₁ ∩ t₂, Filter.inter_mem h₁ h₂,
fun x₁ h₁ x₂ h₂ he ↦ @t_sub ⟨(x₁, x₂), he⟩ (prod_sub ⟨h₁.1, h₂.2⟩)⟩
theorem IsLocallyInjective_iff_openEmbedding {f : X → Y} :
IsLocallyInjective f ↔ OpenEmbedding (toPullbackDiag f) := by
rw [isLocallyInjective_iff_isOpen_diagonal, ← range_toPullbackDiag]
exact ⟨fun h ↦ ⟨embedding_toPullbackDiag f, h⟩, fun h ↦ h.isOpen_range⟩
theorem isLocallyInjective_iff_isOpenMap {f : X → Y} :
IsLocallyInjective f ↔ IsOpenMap (toPullbackDiag f) :=
IsLocallyInjective_iff_openEmbedding.trans
⟨OpenEmbedding.isOpenMap, openEmbedding_of_continuous_injective_open
(embedding_toPullbackDiag f).continuous (injective_toPullbackDiag f)⟩
theorem discreteTopology_iff_locallyInjective (y : Y) :
DiscreteTopology X ↔ IsLocallyInjective fun _ : X ↦ y := by
rw [discreteTopology_iff_singleton_mem_nhds, isLocallyInjective_iff_nhds]
refine forall_congr' fun x ↦ ⟨fun h ↦ ⟨{x}, h, Set.injOn_singleton _ _⟩, fun ⟨U, hU, inj⟩ ↦ ?_⟩
convert hU; ext x'; refine ⟨?_, fun h ↦ inj h (mem_of_mem_nhds hU) rfl⟩
rintro rfl; exact mem_of_mem_nhds hU
theorem IsLocallyInjective.comp_left {f : X → Y} (hf : IsLocallyInjective f) {g : Y → A}
(hg : g.Injective) : IsLocallyInjective (g ∘ f) :=
fun x ↦ let ⟨U, hU, hx, inj⟩ := hf x; ⟨U, hU, hx, hg.comp_injOn inj⟩
| Mathlib/Topology/SeparatedMap.lean | 166 | 170 | theorem IsLocallyInjective.comp_right {f : X → Y} (hf : IsLocallyInjective f) {g : A → X}
(cont : Continuous g) (hg : g.Injective) : IsLocallyInjective (f ∘ g) := by |
rw [isLocallyInjective_iff_isOpen_diagonal] at hf ⊢
rw [← hg.preimage_pullbackDiagonal]
apply hf.preimage (cont.mapPullback cont)
|
import Mathlib.Analysis.Calculus.Deriv.Basic
import Mathlib.Analysis.Calculus.FDeriv.Mul
import Mathlib.Analysis.Calculus.FDeriv.Add
#align_import analysis.calculus.deriv.mul from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
universe u v w
noncomputable section
open scoped Classical Topology Filter ENNReal
open Filter Asymptotics Set
open ContinuousLinearMap (smulRight smulRight_one_eq_iff)
variable {𝕜 : Type u} [NontriviallyNormedField 𝕜]
variable {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
variable {E : Type w} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {G : Type*} [NormedAddCommGroup G] [NormedSpace 𝕜 G]
variable {f f₀ f₁ g : 𝕜 → F}
variable {f' f₀' f₁' g' : F}
variable {x : 𝕜}
variable {s t : Set 𝕜}
variable {L L₁ L₂ : Filter 𝕜}
section Prod
section Div
variable {𝕜' : Type*} [NontriviallyNormedField 𝕜'] [NormedAlgebra 𝕜 𝕜'] {c d : 𝕜 → 𝕜'} {c' d' : 𝕜'}
theorem HasDerivAt.div_const (hc : HasDerivAt c c' x) (d : 𝕜') :
HasDerivAt (fun x => c x / d) (c' / d) x := by
simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹
#align has_deriv_at.div_const HasDerivAt.div_const
theorem HasDerivWithinAt.div_const (hc : HasDerivWithinAt c c' s x) (d : 𝕜') :
HasDerivWithinAt (fun x => c x / d) (c' / d) s x := by
simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹
#align has_deriv_within_at.div_const HasDerivWithinAt.div_const
theorem HasStrictDerivAt.div_const (hc : HasStrictDerivAt c c' x) (d : 𝕜') :
HasStrictDerivAt (fun x => c x / d) (c' / d) x := by
simpa only [div_eq_mul_inv] using hc.mul_const d⁻¹
#align has_strict_deriv_at.div_const HasStrictDerivAt.div_const
theorem DifferentiableWithinAt.div_const (hc : DifferentiableWithinAt 𝕜 c s x) (d : 𝕜') :
DifferentiableWithinAt 𝕜 (fun x => c x / d) s x :=
(hc.hasDerivWithinAt.div_const _).differentiableWithinAt
#align differentiable_within_at.div_const DifferentiableWithinAt.div_const
@[simp]
theorem DifferentiableAt.div_const (hc : DifferentiableAt 𝕜 c x) (d : 𝕜') :
DifferentiableAt 𝕜 (fun x => c x / d) x :=
(hc.hasDerivAt.div_const _).differentiableAt
#align differentiable_at.div_const DifferentiableAt.div_const
theorem DifferentiableOn.div_const (hc : DifferentiableOn 𝕜 c s) (d : 𝕜') :
DifferentiableOn 𝕜 (fun x => c x / d) s := fun x hx => (hc x hx).div_const d
#align differentiable_on.div_const DifferentiableOn.div_const
@[simp]
theorem Differentiable.div_const (hc : Differentiable 𝕜 c) (d : 𝕜') :
Differentiable 𝕜 fun x => c x / d := fun x => (hc x).div_const d
#align differentiable.div_const Differentiable.div_const
theorem derivWithin_div_const (hc : DifferentiableWithinAt 𝕜 c s x)
(d : 𝕜') (hxs : UniqueDiffWithinAt 𝕜 s x) :
derivWithin (fun x => c x / d) s x = derivWithin c s x / d := by
simp [div_eq_inv_mul, derivWithin_const_mul, hc, hxs]
#align deriv_within_div_const derivWithin_div_const
@[simp]
| Mathlib/Analysis/Calculus/Deriv/Mul.lean | 431 | 432 | theorem deriv_div_const (d : 𝕜') : deriv (fun x => c x / d) x = deriv c x / d := by |
simp only [div_eq_mul_inv, deriv_mul_const_field]
|
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"
variable {α : Type*}
local infixl:50 " ~ᵤ " => Associated
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
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)]⟩
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
namespace UniqueFactorizationMonoid
variable {R : Type*} [CancelCommMonoidWithZero R] [UniqueFactorizationMonoid R]
theorem isRelPrime_iff_no_prime_factors {a b : R} (ha : a ≠ 0) :
IsRelPrime a b ↔ ∀ ⦃d⦄, d ∣ a → d ∣ b → ¬Prime d :=
⟨fun h _ ha hb ↦ (·.not_unit <| h ha hb), fun h ↦ WfDvdMonoid.isRelPrime_of_no_irreducible_factors
(ha ·.1) fun _ irr ha hb ↦ h ha hb (UniqueFactorizationMonoid.irreducible_iff_prime.mp irr)⟩
#align unique_factorization_monoid.no_factors_of_no_prime_factors UniqueFactorizationMonoid.isRelPrime_iff_no_prime_factors
theorem dvd_of_dvd_mul_left_of_no_prime_factors {a b c : R} (ha : a ≠ 0)
(h : ∀ ⦃d⦄, d ∣ a → d ∣ c → ¬Prime d) : a ∣ b * c → a ∣ b :=
((isRelPrime_iff_no_prime_factors ha).mpr h).dvd_of_dvd_mul_right
#align unique_factorization_monoid.dvd_of_dvd_mul_left_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_left_of_no_prime_factors
theorem dvd_of_dvd_mul_right_of_no_prime_factors {a b c : R} (ha : a ≠ 0)
(no_factors : ∀ {d}, d ∣ a → d ∣ b → ¬Prime d) : a ∣ b * c → a ∣ c := by
simpa [mul_comm b c] using dvd_of_dvd_mul_left_of_no_prime_factors ha @no_factors
#align unique_factorization_monoid.dvd_of_dvd_mul_right_of_no_prime_factors UniqueFactorizationMonoid.dvd_of_dvd_mul_right_of_no_prime_factors
theorem exists_reduced_factors :
∀ a ≠ (0 : R), ∀ b,
∃ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b := by
intro a
refine induction_on_prime a ?_ ?_ ?_
· intros
contradiction
· intro a a_unit _ b
use a, b, 1
constructor
· intro p p_dvd_a _
exact isUnit_of_dvd_unit p_dvd_a a_unit
· simp
· intro a p a_ne_zero p_prime ih_a pa_ne_zero b
by_cases h : p ∣ b
· rcases h with ⟨b, rfl⟩
obtain ⟨a', b', c', no_factor, ha', hb'⟩ := ih_a a_ne_zero b
refine ⟨a', b', p * c', @no_factor, ?_, ?_⟩
· rw [mul_assoc, ha']
· rw [mul_assoc, hb']
· obtain ⟨a', b', c', coprime, rfl, rfl⟩ := ih_a a_ne_zero b
refine ⟨p * a', b', c', ?_, mul_left_comm _ _ _, rfl⟩
intro q q_dvd_pa' q_dvd_b'
cases' p_prime.left_dvd_or_dvd_right_of_dvd_mul q_dvd_pa' with p_dvd_q q_dvd_a'
· have : p ∣ c' * b' := dvd_mul_of_dvd_right (p_dvd_q.trans q_dvd_b') _
contradiction
exact coprime q_dvd_a' q_dvd_b'
#align unique_factorization_monoid.exists_reduced_factors UniqueFactorizationMonoid.exists_reduced_factors
theorem exists_reduced_factors' (a b : R) (hb : b ≠ 0) :
∃ a' b' c', IsRelPrime a' b' ∧ c' * a' = a ∧ c' * b' = b :=
let ⟨b', a', c', no_factor, hb, ha⟩ := exists_reduced_factors b hb a
⟨a', b', c', fun _ hpb hpa => no_factor hpa hpb, ha, hb⟩
#align unique_factorization_monoid.exists_reduced_factors' UniqueFactorizationMonoid.exists_reduced_factors'
theorem pow_right_injective {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) :
Function.Injective (a ^ · : ℕ → R) := by
letI := Classical.decEq R
intro i j hij
letI : Nontrivial R := ⟨⟨a, 0, ha0⟩⟩
letI : NormalizationMonoid R := UniqueFactorizationMonoid.normalizationMonoid
obtain ⟨p', hp', dvd'⟩ := WfDvdMonoid.exists_irreducible_factor ha1 ha0
obtain ⟨p, mem, _⟩ := exists_mem_normalizedFactors_of_dvd ha0 hp' dvd'
have := congr_arg (fun x => Multiset.count p (normalizedFactors x)) hij
simp only [normalizedFactors_pow, Multiset.count_nsmul] at this
exact mul_right_cancel₀ (Multiset.count_ne_zero.mpr mem) this
#align unique_factorization_monoid.pow_right_injective UniqueFactorizationMonoid.pow_right_injective
theorem pow_eq_pow_iff {a : R} (ha0 : a ≠ 0) (ha1 : ¬IsUnit a) {i j : ℕ} : a ^ i = a ^ j ↔ i = j :=
(pow_right_injective ha0 ha1).eq_iff
#align unique_factorization_monoid.pow_eq_pow_iff UniqueFactorizationMonoid.pow_eq_pow_iff
namespace Associates
open UniqueFactorizationMonoid Associated Multiset
variable [CancelCommMonoidWithZero α]
abbrev FactorSet.{u} (α : Type u) [CancelCommMonoidWithZero α] : Type u :=
WithTop (Multiset { a : Associates α // Irreducible a })
#align associates.factor_set Associates.FactorSet
attribute [local instance] Associated.setoid
theorem FactorSet.coe_add {a b : Multiset { a : Associates α // Irreducible a }} :
(↑(a + b) : FactorSet α) = a + b := by norm_cast
#align associates.factor_set.coe_add Associates.FactorSet.coe_add
theorem FactorSet.sup_add_inf_eq_add [DecidableEq (Associates α)] :
∀ a b : FactorSet α, a ⊔ b + a ⊓ b = a + b
| ⊤, b => show ⊤ ⊔ b + ⊤ ⊓ b = ⊤ + b by simp
| a, ⊤ => show a ⊔ ⊤ + a ⊓ ⊤ = a + ⊤ by simp
| WithTop.some a, WithTop.some b =>
show (a : FactorSet α) ⊔ b + (a : FactorSet α) ⊓ b = a + b by
rw [← WithTop.coe_sup, ← WithTop.coe_inf, ← WithTop.coe_add, ← WithTop.coe_add,
WithTop.coe_eq_coe]
exact Multiset.union_add_inter _ _
#align associates.factor_set.sup_add_inf_eq_add Associates.FactorSet.sup_add_inf_eq_add
def FactorSet.prod : FactorSet α → Associates α
| ⊤ => 0
| WithTop.some s => (s.map (↑)).prod
#align associates.factor_set.prod Associates.FactorSet.prod
@[simp]
theorem prod_top : (⊤ : FactorSet α).prod = 0 :=
rfl
#align associates.prod_top Associates.prod_top
@[simp]
theorem prod_coe {s : Multiset { a : Associates α // Irreducible a }} :
FactorSet.prod (s : FactorSet α) = (s.map (↑)).prod :=
rfl
#align associates.prod_coe Associates.prod_coe
@[simp]
theorem prod_add : ∀ a b : FactorSet α, (a + b).prod = a.prod * b.prod
| ⊤, b => show (⊤ + b).prod = (⊤ : FactorSet α).prod * b.prod by simp
| a, ⊤ => show (a + ⊤).prod = a.prod * (⊤ : FactorSet α).prod by simp
| WithTop.some a, WithTop.some b => by
rw [← FactorSet.coe_add, prod_coe, prod_coe, prod_coe, Multiset.map_add, Multiset.prod_add]
#align associates.prod_add Associates.prod_add
@[gcongr]
theorem prod_mono : ∀ {a b : FactorSet α}, a ≤ b → a.prod ≤ b.prod
| ⊤, b, h => by
have : b = ⊤ := top_unique h
rw [this, prod_top]
| a, ⊤, _ => show a.prod ≤ (⊤ : FactorSet α).prod by simp
| WithTop.some a, WithTop.some b, h =>
prod_le_prod <| Multiset.map_le_map <| WithTop.coe_le_coe.1 <| h
#align associates.prod_mono Associates.prod_mono
theorem FactorSet.prod_eq_zero_iff [Nontrivial α] (p : FactorSet α) : p.prod = 0 ↔ p = ⊤ := by
unfold FactorSet at p
induction p -- TODO: `induction_eliminator` doesn't work with `abbrev`
· simp only [iff_self_iff, eq_self_iff_true, Associates.prod_top]
· rw [prod_coe, Multiset.prod_eq_zero_iff, Multiset.mem_map, eq_false WithTop.coe_ne_top,
iff_false_iff, not_exists]
exact fun a => not_and_of_not_right _ a.prop.ne_zero
#align associates.factor_set.prod_eq_zero_iff Associates.FactorSet.prod_eq_zero_iff
theorem prod_le [Nontrivial α] {a b : FactorSet α} : a.prod ≤ b.prod ↔ a ≤ b := by
refine ⟨fun h ↦ ?_, prod_mono⟩
have : a.prod.factors ≤ b.prod.factors := factors_mono h
rwa [prod_factors, prod_factors] at this
#align associates.prod_le Associates.prod_le
open Classical in
noncomputable instance : Sup (Associates α) :=
⟨fun a b => (a.factors ⊔ b.factors).prod⟩
open Classical in
noncomputable instance : Inf (Associates α) :=
⟨fun a b => (a.factors ⊓ b.factors).prod⟩
open Classical in
noncomputable instance : Lattice (Associates α) :=
{ Associates.instPartialOrder with
sup := (· ⊔ ·)
inf := (· ⊓ ·)
sup_le := fun _ _ c hac hbc =>
factors_prod c ▸ prod_mono (sup_le (factors_mono hac) (factors_mono hbc))
le_sup_left := fun a _ => le_trans (le_of_eq (factors_prod a).symm) <| prod_mono <| le_sup_left
le_sup_right := fun _ b =>
le_trans (le_of_eq (factors_prod b).symm) <| prod_mono <| le_sup_right
le_inf := fun a _ _ hac hbc =>
factors_prod a ▸ prod_mono (le_inf (factors_mono hac) (factors_mono hbc))
inf_le_left := fun a _ => le_trans (prod_mono inf_le_left) (le_of_eq (factors_prod a))
inf_le_right := fun _ b => le_trans (prod_mono inf_le_right) (le_of_eq (factors_prod b)) }
open Classical in
theorem sup_mul_inf (a b : Associates α) : (a ⊔ b) * (a ⊓ b) = a * b :=
show (a.factors ⊔ b.factors).prod * (a.factors ⊓ b.factors).prod = a * b by
nontriviality α
refine eq_of_factors_eq_factors ?_
rw [← prod_add, prod_factors, factors_mul, FactorSet.sup_add_inf_eq_add]
#align associates.sup_mul_inf Associates.sup_mul_inf
theorem dvd_of_mem_factors {a p : Associates α} (hm : p ∈ factors a) :
p ∣ a := by
rcases eq_or_ne a 0 with rfl | ha0
· exact dvd_zero p
obtain ⟨a0, nza, ha'⟩ := exists_non_zero_rep ha0
rw [← Associates.factors_prod a]
rw [← ha', factors_mk a0 nza] at hm ⊢
rw [prod_coe]
apply Multiset.dvd_prod; apply Multiset.mem_map.mpr
exact ⟨⟨p, irreducible_of_mem_factorSet hm⟩, mem_factorSet_some.mp hm, rfl⟩
#align associates.dvd_of_mem_factors Associates.dvd_of_mem_factors
theorem dvd_of_mem_factors' {a : α} {p : Associates α} {hp : Irreducible p} {hz : a ≠ 0}
(h_mem : Subtype.mk p hp ∈ factors' a) : p ∣ Associates.mk a := by
haveI := Classical.decEq (Associates α)
apply dvd_of_mem_factors
rw [factors_mk _ hz]
apply mem_factorSet_some.2 h_mem
#align associates.dvd_of_mem_factors' Associates.dvd_of_mem_factors'
theorem mem_factors'_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) (hd : p ∣ a) :
Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a := by
obtain ⟨q, hq, hpq⟩ := exists_mem_factors_of_dvd ha0 hp hd
apply Multiset.mem_pmap.mpr; use q; use hq
exact Subtype.eq (Eq.symm (mk_eq_mk_iff_associated.mpr hpq))
#align associates.mem_factors'_of_dvd Associates.mem_factors'_of_dvd
theorem mem_factors'_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) :
Subtype.mk (Associates.mk p) (irreducible_mk.2 hp) ∈ factors' a ↔ p ∣ a := by
constructor
· rw [← mk_dvd_mk]
apply dvd_of_mem_factors'
apply ha0
· apply mem_factors'_of_dvd ha0 hp
#align associates.mem_factors'_iff_dvd Associates.mem_factors'_iff_dvd
theorem mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) (hd : p ∣ a) :
Associates.mk p ∈ factors (Associates.mk a) := by
rw [factors_mk _ ha0]
exact mem_factorSet_some.mpr (mem_factors'_of_dvd ha0 hp hd)
#align associates.mem_factors_of_dvd Associates.mem_factors_of_dvd
theorem mem_factors_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) :
Associates.mk p ∈ factors (Associates.mk a) ↔ p ∣ a := by
constructor
· rw [← mk_dvd_mk]
apply dvd_of_mem_factors
· apply mem_factors_of_dvd ha0 hp
#align associates.mem_factors_iff_dvd Associates.mem_factors_iff_dvd
open Classical in
theorem exists_prime_dvd_of_not_inf_one {a b : α} (ha : a ≠ 0) (hb : b ≠ 0)
(h : Associates.mk a ⊓ Associates.mk b ≠ 1) : ∃ p : α, Prime p ∧ p ∣ a ∧ p ∣ b := by
have hz : factors (Associates.mk a) ⊓ factors (Associates.mk b) ≠ 0 := by
contrapose! h with hf
change (factors (Associates.mk a) ⊓ factors (Associates.mk b)).prod = 1
rw [hf]
exact Multiset.prod_zero
rw [factors_mk a ha, factors_mk b hb, ← WithTop.coe_inf] at hz
obtain ⟨⟨p0, p0_irr⟩, p0_mem⟩ := Multiset.exists_mem_of_ne_zero ((mt WithTop.coe_eq_coe.mpr) hz)
rw [Multiset.inf_eq_inter] at p0_mem
obtain ⟨p, rfl⟩ : ∃ p, Associates.mk p = p0 := Quot.exists_rep p0
refine ⟨p, ?_, ?_, ?_⟩
· rw [← UniqueFactorizationMonoid.irreducible_iff_prime, ← irreducible_mk]
exact p0_irr
· apply dvd_of_mk_le_mk
apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).left
apply ha
· apply dvd_of_mk_le_mk
apply dvd_of_mem_factors' (Multiset.mem_inter.mp p0_mem).right
apply hb
#align associates.exists_prime_dvd_of_not_inf_one Associates.exists_prime_dvd_of_not_inf_one
theorem coprime_iff_inf_one {a b : α} (ha0 : a ≠ 0) (hb0 : b ≠ 0) :
Associates.mk a ⊓ Associates.mk b = 1 ↔ ∀ {d : α}, d ∣ a → d ∣ b → ¬Prime d := by
constructor
· intro hg p ha hb hp
refine (Associates.prime_mk.mpr hp).not_unit (isUnit_of_dvd_one ?_)
rw [← hg]
exact le_inf (mk_le_mk_of_dvd ha) (mk_le_mk_of_dvd hb)
· contrapose
intro hg hc
obtain ⟨p, hp, hpa, hpb⟩ := exists_prime_dvd_of_not_inf_one ha0 hb0 hg
exact hc hpa hpb hp
#align associates.coprime_iff_inf_one Associates.coprime_iff_inf_one
theorem factors_self [Nontrivial α] {p : Associates α} (hp : Irreducible p) :
p.factors = WithTop.some {⟨p, hp⟩} :=
eq_of_prod_eq_prod
(by rw [factors_prod, FactorSet.prod]; dsimp; rw [prod_singleton])
#align associates.factors_self Associates.factors_self
theorem factors_prime_pow [Nontrivial α] {p : Associates α} (hp : Irreducible p) (k : ℕ) :
factors (p ^ k) = WithTop.some (Multiset.replicate k ⟨p, hp⟩) :=
eq_of_prod_eq_prod
(by
rw [Associates.factors_prod, FactorSet.prod]
dsimp; rw [Multiset.map_replicate, Multiset.prod_replicate, Subtype.coe_mk])
#align associates.factors_prime_pow Associates.factors_prime_pow
theorem prime_pow_le_iff_le_bcount [DecidableEq (Associates α)] {m p : Associates α}
(h₁ : m ≠ 0) (h₂ : Irreducible p) {k : ℕ} : p ^ k ≤ m ↔ k ≤ bcount ⟨p, h₂⟩ m.factors := by
rcases Associates.exists_non_zero_rep h₁ with ⟨m, hm, rfl⟩
have := nontrivial_of_ne _ _ hm
rw [bcount, factors_mk, Multiset.le_count_iff_replicate_le, ← factors_le, factors_prime_pow,
factors_mk, WithTop.coe_le_coe] <;> assumption
section count
variable [DecidableEq (Associates α)] [∀ p : Associates α, Decidable (Irreducible p)]
theorem prime_pow_dvd_iff_le {m p : Associates α} (h₁ : m ≠ 0) (h₂ : Irreducible p) {k : ℕ} :
p ^ k ≤ m ↔ k ≤ count p m.factors := by
rw [count, dif_pos h₂, prime_pow_le_iff_le_bcount h₁]
#align associates.prime_pow_dvd_iff_le Associates.prime_pow_dvd_iff_le
theorem le_of_count_ne_zero {m p : Associates α} (h0 : m ≠ 0) (hp : Irreducible p) :
count p m.factors ≠ 0 → p ≤ m := by
nontriviality α
rw [← pos_iff_ne_zero]
intro h
rw [← pow_one p]
apply (prime_pow_dvd_iff_le h0 hp).2
simpa only
#align associates.le_of_count_ne_zero Associates.le_of_count_ne_zero
theorem count_ne_zero_iff_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) :
(Associates.mk p).count (Associates.mk a).factors ≠ 0 ↔ p ∣ a := by
nontriviality α
rw [← Associates.mk_le_mk_iff_dvd]
refine
⟨fun h =>
Associates.le_of_count_ne_zero (Associates.mk_ne_zero.mpr ha0)
(Associates.irreducible_mk.mpr hp) h,
fun h => ?_⟩
rw [← pow_one (Associates.mk p),
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero.mpr ha0)
(Associates.irreducible_mk.mpr hp)] at h
exact (zero_lt_one.trans_le h).ne'
#align associates.count_ne_zero_iff_dvd Associates.count_ne_zero_iff_dvd
theorem count_self [Nontrivial α] [DecidableEq (Associates α)] {p : Associates α}
(hp : Irreducible p) : p.count p.factors = 1 := by
simp [factors_self hp, Associates.count_some hp]
#align associates.count_self Associates.count_self
theorem count_eq_zero_of_ne [DecidableEq (Associates α)] {p q : Associates α} (hp : Irreducible p)
(hq : Irreducible q) (h : p ≠ q) : p.count q.factors = 0 :=
not_ne_iff.mp fun h' ↦ h <| associated_iff_eq.mp <| hp.associated_of_dvd hq <|
le_of_count_ne_zero hq.ne_zero hp h'
#align associates.count_eq_zero_of_ne Associates.count_eq_zero_of_ne
theorem count_mul [DecidableEq (Associates α)] {a : Associates α} (ha : a ≠ 0) {b : Associates α}
(hb : b ≠ 0) {p : Associates α} (hp : Irreducible p) :
count p (factors (a * b)) = count p a.factors + count p b.factors := by
obtain ⟨a0, nza, rfl⟩ := exists_non_zero_rep ha
obtain ⟨b0, nzb, rfl⟩ := exists_non_zero_rep hb
rw [factors_mul, factors_mk a0 nza, factors_mk b0 nzb, ← FactorSet.coe_add, count_some hp,
Multiset.count_add, count_some hp, count_some hp]
#align associates.count_mul Associates.count_mul
theorem count_of_coprime [DecidableEq (Associates α)] {a : Associates α} (ha : a ≠ 0)
{b : Associates α} (hb : b ≠ 0) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) {p : Associates α}
(hp : Irreducible p) : count p a.factors = 0 ∨ count p b.factors = 0 := by
rw [or_iff_not_imp_left, ← Ne]
intro hca
contrapose! hab with hcb
exact ⟨p, le_of_count_ne_zero ha hp hca, le_of_count_ne_zero hb hp hcb,
UniqueFactorizationMonoid.irreducible_iff_prime.mp hp⟩
#align associates.count_of_coprime Associates.count_of_coprime
theorem count_mul_of_coprime [DecidableEq (Associates α)] {a : Associates α} {b : Associates α}
(hb : b ≠ 0) {p : Associates α} (hp : Irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) :
count p a.factors = 0 ∨ count p a.factors = count p (a * b).factors := by
by_cases ha : a = 0
· simp [ha]
cases' count_of_coprime ha hb hab hp with hz hb0; · tauto
apply Or.intro_right
rw [count_mul ha hb hp, hb0, add_zero]
#align associates.count_mul_of_coprime Associates.count_mul_of_coprime
| Mathlib/RingTheory/UniqueFactorizationDomain.lean | 1,797 | 1,809 | theorem count_mul_of_coprime' [DecidableEq (Associates α)] {a b : Associates α} {p : Associates α}
(hp : Irreducible p) (hab : ∀ d, d ∣ a → d ∣ b → ¬Prime d) :
count p (a * b).factors = count p a.factors ∨ count p (a * b).factors = count p b.factors := by |
by_cases ha : a = 0
· simp [ha]
by_cases hb : b = 0
· simp [hb]
rw [count_mul ha hb hp]
cases' count_of_coprime ha hb hab hp with ha0 hb0
· apply Or.intro_right
rw [ha0, zero_add]
· apply Or.intro_left
rw [hb0, add_zero]
|
import Mathlib.Order.Interval.Set.UnorderedInterval
import Mathlib.Algebra.Order.Interval.Set.Monoid
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Algebra.Order.Group.MinMax
#align_import data.set.pointwise.interval from "leanprover-community/mathlib"@"2196ab363eb097c008d4497125e0dde23fb36db2"
open Interval Pointwise
variable {α : Type*}
namespace Set
section LinearOrderedAddCommGroup
variable [LinearOrderedAddCommGroup α] (a b c d : α)
@[simp]
theorem preimage_const_add_uIcc : (fun x => a + x) ⁻¹' [[b, c]] = [[b - a, c - a]] := by
simp only [← Icc_min_max, preimage_const_add_Icc, min_sub_sub_right, max_sub_sub_right]
#align set.preimage_const_add_uIcc Set.preimage_const_add_uIcc
@[simp]
| Mathlib/Data/Set/Pointwise/Interval.lean | 518 | 519 | theorem preimage_add_const_uIcc : (fun x => x + a) ⁻¹' [[b, c]] = [[b - a, c - a]] := by |
simpa only [add_comm] using preimage_const_add_uIcc a b c
|
import Mathlib.Data.Real.Sqrt
import Mathlib.Analysis.NormedSpace.Star.Basic
import Mathlib.Analysis.NormedSpace.ContinuousLinearMap
import Mathlib.Analysis.NormedSpace.Basic
#align_import data.is_R_or_C.basic from "leanprover-community/mathlib"@"baa88307f3e699fa7054ef04ec79fa4f056169cb"
section
local notation "𝓚" => algebraMap ℝ _
open ComplexConjugate
class RCLike (K : semiOutParam Type*) extends DenselyNormedField K, StarRing K,
NormedAlgebra ℝ K, CompleteSpace K where
re : K →+ ℝ
im : K →+ ℝ
I : K
I_re_ax : re I = 0
I_mul_I_ax : I = 0 ∨ I * I = -1
re_add_im_ax : ∀ z : K, 𝓚 (re z) + 𝓚 (im z) * I = z
ofReal_re_ax : ∀ r : ℝ, re (𝓚 r) = r
ofReal_im_ax : ∀ r : ℝ, im (𝓚 r) = 0
mul_re_ax : ∀ z w : K, re (z * w) = re z * re w - im z * im w
mul_im_ax : ∀ z w : K, im (z * w) = re z * im w + im z * re w
conj_re_ax : ∀ z : K, re (conj z) = re z
conj_im_ax : ∀ z : K, im (conj z) = -im z
conj_I_ax : conj I = -I
norm_sq_eq_def_ax : ∀ z : K, ‖z‖ ^ 2 = re z * re z + im z * im z
mul_im_I_ax : ∀ z : K, im z * im I = im z
[toPartialOrder : PartialOrder K]
le_iff_re_im {z w : K} : z ≤ w ↔ re z ≤ re w ∧ im z = im w
-- note we cannot put this in the `extends` clause
[toDecidableEq : DecidableEq K]
#align is_R_or_C RCLike
scoped[ComplexOrder] attribute [instance 100] RCLike.toPartialOrder
attribute [instance 100] RCLike.toDecidableEq
end
variable {K E : Type*} [RCLike K]
namespace RCLike
section Order
open scoped ComplexOrder
variable {z w : K}
| Mathlib/Analysis/RCLike/Basic.lean | 847 | 853 | theorem lt_iff_re_im : z < w ↔ re z < re w ∧ im z = im w := by |
simp_rw [lt_iff_le_and_ne, @RCLike.le_iff_re_im K]
constructor
· rintro ⟨⟨hr, hi⟩, heq⟩
exact ⟨⟨hr, mt (fun hreq => ext hreq hi) heq⟩, hi⟩
· rintro ⟨⟨hr, hrn⟩, hi⟩
exact ⟨⟨hr, hi⟩, ne_of_apply_ne _ hrn⟩
|
import Mathlib.Computability.NFA
#align_import computability.epsilon_NFA from "leanprover-community/mathlib"@"28aa996fc6fb4317f0083c4e6daf79878d81be33"
open Set
open Computability
-- "ε_NFA"
set_option linter.uppercaseLean3 false
universe u v
structure εNFA (α : Type u) (σ : Type v) where
step : σ → Option α → Set σ
start : Set σ
accept : Set σ
#align ε_NFA εNFA
variable {α : Type u} {σ σ' : Type v} (M : εNFA α σ) {S : Set σ} {x : List α} {s : σ} {a : α}
namespace εNFA
inductive εClosure (S : Set σ) : Set σ
| base : ∀ s ∈ S, εClosure S s
| step : ∀ (s), ∀ t ∈ M.step s none, εClosure S s → εClosure S t
#align ε_NFA.ε_closure εNFA.εClosure
@[simp]
theorem subset_εClosure (S : Set σ) : S ⊆ M.εClosure S :=
εClosure.base
#align ε_NFA.subset_ε_closure εNFA.subset_εClosure
@[simp]
theorem εClosure_empty : M.εClosure ∅ = ∅ :=
eq_empty_of_forall_not_mem fun s hs ↦ by induction hs <;> assumption
#align ε_NFA.ε_closure_empty εNFA.εClosure_empty
@[simp]
theorem εClosure_univ : M.εClosure univ = univ :=
eq_univ_of_univ_subset <| subset_εClosure _ _
#align ε_NFA.ε_closure_univ εNFA.εClosure_univ
def stepSet (S : Set σ) (a : α) : Set σ :=
⋃ s ∈ S, M.εClosure (M.step s a)
#align ε_NFA.step_set εNFA.stepSet
variable {M}
@[simp]
theorem mem_stepSet_iff : s ∈ M.stepSet S a ↔ ∃ t ∈ S, s ∈ M.εClosure (M.step t a) := by
simp_rw [stepSet, mem_iUnion₂, exists_prop]
#align ε_NFA.mem_step_set_iff εNFA.mem_stepSet_iff
@[simp]
theorem stepSet_empty (a : α) : M.stepSet ∅ a = ∅ := by
simp_rw [stepSet, mem_empty_iff_false, iUnion_false, iUnion_empty]
#align ε_NFA.step_set_empty εNFA.stepSet_empty
variable (M)
def evalFrom (start : Set σ) : List α → Set σ :=
List.foldl M.stepSet (M.εClosure start)
#align ε_NFA.eval_from εNFA.evalFrom
@[simp]
theorem evalFrom_nil (S : Set σ) : M.evalFrom S [] = M.εClosure S :=
rfl
#align ε_NFA.eval_from_nil εNFA.evalFrom_nil
@[simp]
theorem evalFrom_singleton (S : Set σ) (a : α) : M.evalFrom S [a] = M.stepSet (M.εClosure S) a :=
rfl
#align ε_NFA.eval_from_singleton εNFA.evalFrom_singleton
@[simp]
theorem evalFrom_append_singleton (S : Set σ) (x : List α) (a : α) :
M.evalFrom S (x ++ [a]) = M.stepSet (M.evalFrom S x) a := by
rw [evalFrom, List.foldl_append, List.foldl_cons, List.foldl_nil]
#align ε_NFA.eval_from_append_singleton εNFA.evalFrom_append_singleton
@[simp]
| Mathlib/Computability/EpsilonNFA.lean | 116 | 119 | theorem evalFrom_empty (x : List α) : M.evalFrom ∅ x = ∅ := by |
induction' x using List.reverseRecOn with x a ih
· rw [evalFrom_nil, εClosure_empty]
· rw [evalFrom_append_singleton, ih, stepSet_empty]
|
import Mathlib.Algebra.Group.Prod
#align_import data.nat.cast.prod from "leanprover-community/mathlib"@"ee0c179cd3c8a45aa5bffbf1b41d8dbede452865"
assert_not_exists MonoidWithZero
variable {α β : Type*}
namespace Prod
variable [AddMonoidWithOne α] [AddMonoidWithOne β]
instance instAddMonoidWithOne : AddMonoidWithOne (α × β) :=
{ Prod.instAddMonoid, @Prod.instOne α β _ _ with
natCast := fun n => (n, n)
natCast_zero := congr_arg₂ Prod.mk Nat.cast_zero Nat.cast_zero
natCast_succ := fun _ => congr_arg₂ Prod.mk (Nat.cast_succ _) (Nat.cast_succ _) }
@[simp]
theorem fst_natCast (n : ℕ) : (n : α × β).fst = n := by induction n <;> simp [*]
#align prod.fst_nat_cast Prod.fst_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem fst_ofNat (n : ℕ) [n.AtLeastTwo] :
(no_index (OfNat.ofNat n : α × β)).1 = (OfNat.ofNat n : α) :=
rfl
@[simp]
| Mathlib/Data/Nat/Cast/Prod.lean | 39 | 39 | theorem snd_natCast (n : ℕ) : (n : α × β).snd = n := by | induction n <;> simp [*]
|
import Mathlib.Data.W.Basic
#align_import data.pfunctor.univariate.basic from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1"
-- "W", "Idx"
set_option linter.uppercaseLean3 false
universe u v v₁ v₂ v₃
@[pp_with_univ]
structure PFunctor where
A : Type u
B : A → Type u
#align pfunctor PFunctor
namespace PFunctor
variable {P : PFunctor.{u}}
open Functor
theorem liftp_iff {α : Type u} (p : α → Prop) (x : P α) :
Liftp p x ↔ ∃ a f, x = ⟨a, f⟩ ∧ ∀ i, p (f i) := by
constructor
· rintro ⟨y, hy⟩
cases' h : y with a f
refine ⟨a, fun i => (f i).val, ?_, fun i => (f i).property⟩
rw [← hy, h, map_eq_map, PFunctor.map_eq]
congr
rintro ⟨a, f, xeq, pf⟩
use ⟨a, fun i => ⟨f i, pf i⟩⟩
rw [xeq]; rfl
#align pfunctor.liftp_iff PFunctor.liftp_iff
| Mathlib/Data/PFunctor/Univariate/Basic.lean | 211 | 217 | theorem liftp_iff' {α : Type u} (p : α → Prop) (a : P.A) (f : P.B a → α) :
@Liftp.{u} P.Obj _ α p ⟨a, f⟩ ↔ ∀ i, p (f i) := by |
simp only [liftp_iff, Sigma.mk.inj_iff]; constructor <;> intro h
· rcases h with ⟨a', f', heq, h'⟩
cases heq
assumption
repeat' first |constructor|assumption
|
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Analysis.NormedSpace.Basic
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.Topology.Instances.RealVectorSpace
#align_import analysis.normed_space.add_torsor from "leanprover-community/mathlib"@"837f72de63ad6cd96519cde5f1ffd5ed8d280ad0"
noncomputable section
open NNReal Topology
open Filter
variable {α V P W Q : Type*} [SeminormedAddCommGroup V] [PseudoMetricSpace P] [NormedAddTorsor V P]
[NormedAddCommGroup W] [MetricSpace Q] [NormedAddTorsor W Q]
section NormedSpace
variable {𝕜 : Type*} [NormedField 𝕜] [NormedSpace 𝕜 V] [NormedSpace 𝕜 W]
open AffineMap
theorem AffineSubspace.isClosed_direction_iff (s : AffineSubspace 𝕜 Q) :
IsClosed (s.direction : Set W) ↔ IsClosed (s : Set Q) := by
rcases s.eq_bot_or_nonempty with (rfl | ⟨x, hx⟩); · simp [isClosed_singleton]
rw [← (IsometryEquiv.vaddConst x).toHomeomorph.symm.isClosed_image,
AffineSubspace.coe_direction_eq_vsub_set_right hx]
rfl
#align affine_subspace.is_closed_direction_iff AffineSubspace.isClosed_direction_iff
@[simp]
theorem dist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
dist p₁ (homothety p₁ c p₂) = ‖c‖ * dist p₁ p₂ := by
simp [homothety_def, norm_smul, ← dist_eq_norm_vsub, dist_comm]
#align dist_center_homothety dist_center_homothety
@[simp]
theorem nndist_center_homothety (p₁ p₂ : P) (c : 𝕜) :
nndist p₁ (homothety p₁ c p₂) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_center_homothety _ _ _
#align nndist_center_homothety nndist_center_homothety
@[simp]
theorem dist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
dist (homothety p₁ c p₂) p₁ = ‖c‖ * dist p₁ p₂ := by rw [dist_comm, dist_center_homothety]
#align dist_homothety_center dist_homothety_center
@[simp]
theorem nndist_homothety_center (p₁ p₂ : P) (c : 𝕜) :
nndist (homothety p₁ c p₂) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_center _ _ _
#align nndist_homothety_center nndist_homothety_center
@[simp]
theorem dist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
dist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = dist c₁ c₂ * dist p₁ p₂ := by
rw [dist_comm p₁ p₂]
simp only [lineMap_apply, dist_eq_norm_vsub, vadd_vsub_vadd_cancel_right,
← sub_smul, norm_smul, vsub_eq_sub]
#align dist_line_map_line_map dist_lineMap_lineMap
@[simp]
theorem nndist_lineMap_lineMap (p₁ p₂ : P) (c₁ c₂ : 𝕜) :
nndist (lineMap p₁ p₂ c₁) (lineMap p₁ p₂ c₂) = nndist c₁ c₂ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_lineMap _ _ _ _
#align nndist_line_map_line_map nndist_lineMap_lineMap
theorem lipschitzWith_lineMap (p₁ p₂ : P) : LipschitzWith (nndist p₁ p₂) (lineMap p₁ p₂ : 𝕜 → P) :=
LipschitzWith.of_dist_le_mul fun c₁ c₂ =>
((dist_lineMap_lineMap p₁ p₂ c₁ c₂).trans (mul_comm _ _)).le
#align lipschitz_with_line_map lipschitzWith_lineMap
@[simp]
theorem dist_lineMap_left (p₁ p₂ : P) (c : 𝕜) : dist (lineMap p₁ p₂ c) p₁ = ‖c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_zero, dist_zero_right] using dist_lineMap_lineMap p₁ p₂ c 0
#align dist_line_map_left dist_lineMap_left
@[simp]
theorem nndist_lineMap_left (p₁ p₂ : P) (c : 𝕜) :
nndist (lineMap p₁ p₂ c) p₁ = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_left _ _ _
#align nndist_line_map_left nndist_lineMap_left
@[simp]
theorem dist_left_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₁ (lineMap p₁ p₂ c) = ‖c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_left _ _ _)
#align dist_left_line_map dist_left_lineMap
@[simp]
theorem nndist_left_lineMap (p₁ p₂ : P) (c : 𝕜) :
nndist p₁ (lineMap p₁ p₂ c) = ‖c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_left_lineMap _ _ _
#align nndist_left_line_map nndist_left_lineMap
@[simp]
theorem dist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
dist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
simpa only [lineMap_apply_one, dist_eq_norm'] using dist_lineMap_lineMap p₁ p₂ c 1
#align dist_line_map_right dist_lineMap_right
@[simp]
theorem nndist_lineMap_right (p₁ p₂ : P) (c : 𝕜) :
nndist (lineMap p₁ p₂ c) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_lineMap_right _ _ _
#align nndist_line_map_right nndist_lineMap_right
@[simp]
theorem dist_right_lineMap (p₁ p₂ : P) (c : 𝕜) : dist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖ * dist p₁ p₂ :=
(dist_comm _ _).trans (dist_lineMap_right _ _ _)
#align dist_right_line_map dist_right_lineMap
@[simp]
theorem nndist_right_lineMap (p₁ p₂ : P) (c : 𝕜) :
nndist p₂ (lineMap p₁ p₂ c) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_right_lineMap _ _ _
#align nndist_right_line_map nndist_right_lineMap
@[simp]
theorem dist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
dist (homothety p₁ c p₂) p₂ = ‖1 - c‖ * dist p₁ p₂ := by
rw [homothety_eq_lineMap, dist_lineMap_right]
#align dist_homothety_self dist_homothety_self
@[simp]
theorem nndist_homothety_self (p₁ p₂ : P) (c : 𝕜) :
nndist (homothety p₁ c p₂) p₂ = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_homothety_self _ _ _
#align nndist_homothety_self nndist_homothety_self
@[simp]
theorem dist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
dist p₂ (homothety p₁ c p₂) = ‖1 - c‖ * dist p₁ p₂ := by rw [dist_comm, dist_homothety_self]
#align dist_self_homothety dist_self_homothety
@[simp]
theorem nndist_self_homothety (p₁ p₂ : P) (c : 𝕜) :
nndist p₂ (homothety p₁ c p₂) = ‖1 - c‖₊ * nndist p₁ p₂ :=
NNReal.eq <| dist_self_homothety _ _ _
#align nndist_self_homothety nndist_self_homothety
@[simp] theorem dist_pointReflection_left (p q : P) :
dist (Equiv.pointReflection p q) p = dist p q := by
simp [dist_eq_norm_vsub V, Equiv.pointReflection_vsub_left (G := V)]
@[simp] theorem dist_left_pointReflection (p q : P) :
dist p (Equiv.pointReflection p q) = dist p q :=
(dist_comm _ _).trans (dist_pointReflection_left _ _)
variable (𝕜) in
theorem dist_pointReflection_right (p q : P) :
dist (Equiv.pointReflection p q) q = ‖(2 : 𝕜)‖ * dist p q := by
simp [dist_eq_norm_vsub V, Equiv.pointReflection_vsub_right (G := V),
nsmul_eq_smul_cast 𝕜, norm_smul]
variable (𝕜) in
theorem dist_right_pointReflection (p q : P) :
dist q (Equiv.pointReflection p q) = ‖(2 : 𝕜)‖ * dist p q :=
(dist_comm _ _).trans (dist_pointReflection_right 𝕜 _ _)
theorem antilipschitzWith_lineMap {p₁ p₂ : Q} (h : p₁ ≠ p₂) :
AntilipschitzWith (nndist p₁ p₂)⁻¹ (lineMap p₁ p₂ : 𝕜 → Q) :=
AntilipschitzWith.of_le_mul_dist fun c₁ c₂ => by
rw [dist_lineMap_lineMap, NNReal.coe_inv, ← dist_nndist, mul_left_comm,
inv_mul_cancel (dist_ne_zero.2 h), mul_one]
#align antilipschitz_with_line_map antilipschitzWith_lineMap
variable (𝕜)
theorem eventually_homothety_mem_of_mem_interior (x : Q) {s : Set Q} {y : Q} (hy : y ∈ interior s) :
∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ y ∈ s := by
rw [(NormedAddCommGroup.nhds_basis_norm_lt (1 : 𝕜)).eventually_iff]
rcases eq_or_ne y x with h | h
· use 1
simp [h.symm, interior_subset hy]
have hxy : 0 < ‖y -ᵥ x‖ := by rwa [norm_pos_iff, vsub_ne_zero]
obtain ⟨u, hu₁, hu₂, hu₃⟩ := mem_interior.mp hy
obtain ⟨ε, hε, hyε⟩ := Metric.isOpen_iff.mp hu₂ y hu₃
refine ⟨ε / ‖y -ᵥ x‖, div_pos hε hxy, fun δ (hδ : ‖δ - 1‖ < ε / ‖y -ᵥ x‖) => hu₁ (hyε ?_)⟩
rw [lt_div_iff hxy, ← norm_smul, sub_smul, one_smul] at hδ
rwa [homothety_apply, Metric.mem_ball, dist_eq_norm_vsub W, vadd_vsub_eq_sub_vsub]
#align eventually_homothety_mem_of_mem_interior eventually_homothety_mem_of_mem_interior
| Mathlib/Analysis/NormedSpace/AddTorsor.lean | 260 | 266 | theorem eventually_homothety_image_subset_of_finite_subset_interior (x : Q) {s : Set Q} {t : Set Q}
(ht : t.Finite) (h : t ⊆ interior s) : ∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ '' t ⊆ s := by |
suffices ∀ y ∈ t, ∀ᶠ δ in 𝓝 (1 : 𝕜), homothety x δ y ∈ s by
simp_rw [Set.image_subset_iff]
exact (Filter.eventually_all_finite ht).mpr this
intro y hy
exact eventually_homothety_mem_of_mem_interior 𝕜 x (h hy)
|
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
#align_import analysis.special_functions.complex.log from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
-- Porting note: @[pp_nodot] does not exist in mathlib4
noncomputable def log (x : ℂ) : ℂ :=
x.abs.log + arg x * I
#align complex.log Complex.log
theorem log_re (x : ℂ) : x.log.re = x.abs.log := by simp [log]
#align complex.log_re Complex.log_re
theorem log_im (x : ℂ) : x.log.im = x.arg := by simp [log]
#align complex.log_im Complex.log_im
theorem neg_pi_lt_log_im (x : ℂ) : -π < (log x).im := by simp only [log_im, neg_pi_lt_arg]
#align complex.neg_pi_lt_log_im Complex.neg_pi_lt_log_im
theorem log_im_le_pi (x : ℂ) : (log x).im ≤ π := by simp only [log_im, arg_le_pi]
#align complex.log_im_le_pi Complex.log_im_le_pi
theorem exp_log {x : ℂ} (hx : x ≠ 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, ← ofReal_sin, sin_arg, ← ofReal_cos, cos_arg hx, ← ofReal_exp,
Real.exp_log (abs.pos hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), ← mul_assoc,
mul_div_cancel₀ _ (ofReal_ne_zero.2 <| abs.ne_zero hx), re_add_im]
#align complex.exp_log Complex.exp_log
@[simp]
theorem range_exp : Set.range exp = {0}ᶜ :=
Set.ext fun x =>
⟨by
rintro ⟨x, rfl⟩
exact exp_ne_zero x, fun hx => ⟨log x, exp_log hx⟩⟩
#align complex.range_exp Complex.range_exp
theorem log_exp {x : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) : log (exp x) = x := by
rw [log, abs_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, ← ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) ⟨hx₁, hx₂⟩, re_add_im]
#align complex.log_exp Complex.log_exp
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : ℂ} (hx₁ : -π < x.im) (hx₂ : x.im ≤ π) (hy₁ : -π < y.im)
(hy₂ : y.im ≤ π) (hxy : exp x = exp y) : x = y := by
rw [← log_exp hx₁ hx₂, ← log_exp hy₁ hy₂, hxy]
#align complex.exp_inj_of_neg_pi_lt_of_le_pi Complex.exp_inj_of_neg_pi_lt_of_le_pi
theorem ofReal_log {x : ℝ} (hx : 0 ≤ x) : (x.log : ℂ) = log x :=
Complex.ext (by rw [log_re, ofReal_re, abs_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
#align complex.of_real_log Complex.ofReal_log
@[simp, norm_cast]
lemma natCast_log {n : ℕ} : Real.log n = log n := ofReal_natCast n ▸ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : ℕ} [n.AtLeastTwo] :
Real.log (no_index (OfNat.ofNat n)) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : ℝ) : (log (x : ℂ)).re = Real.log x := by simp [log_re]
#align complex.log_of_real_re Complex.log_ofReal_re
theorem log_ofReal_mul {r : ℝ} (hr : 0 < r) {x : ℂ} (hx : x ≠ 0) :
log (r * x) = Real.log r + log x := by
replace hx := Complex.abs.ne_zero_iff.mpr hx
simp_rw [log, map_mul, abs_ofReal, arg_real_mul _ hr, abs_of_pos hr, Real.log_mul hr.ne' hx,
ofReal_add, add_assoc]
#align complex.log_of_real_mul Complex.log_ofReal_mul
theorem log_mul_ofReal (r : ℝ) (hr : 0 < r) (x : ℂ) (hx : x ≠ 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
#align complex.log_mul_of_real Complex.log_mul_ofReal
lemma log_mul_eq_add_log_iff {x y : ℂ} (hx₀ : x ≠ 0) (hy₀ : y ≠ 0) :
log (x * y) = log x + log y ↔ arg x + arg y ∈ Set.Ioc (-π) π := by
refine ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hx₀ hy₀
simp_rw [add_re, add_im, log_re, log_im, AbsoluteValue.map_mul,
Real.log_mul (abs.ne_zero hx₀) (abs.ne_zero hy₀), true_and]
alias ⟨_, log_mul⟩ := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
#align complex.log_zero Complex.log_zero
@[simp]
theorem log_one : log 1 = 0 := by simp [log]
#align complex.log_one Complex.log_one
theorem log_neg_one : log (-1) = π * I := by simp [log]
#align complex.log_neg_one Complex.log_neg_one
theorem log_I : log I = π / 2 * I := by simp [log]
set_option linter.uppercaseLean3 false in
#align complex.log_I Complex.log_I
theorem log_neg_I : log (-I) = -(π / 2) * I := by simp [log]
set_option linter.uppercaseLean3 false in
#align complex.log_neg_I Complex.log_neg_I
theorem log_conj_eq_ite (x : ℂ) : log (conj x) = if x.arg = π then log x else conj (log x) := by
simp_rw [log, abs_conj, arg_conj, map_add, map_mul, conj_ofReal]
split_ifs with hx
· rw [hx]
simp_rw [ofReal_neg, conj_I, mul_neg, neg_mul]
#align complex.log_conj_eq_ite Complex.log_conj_eq_ite
theorem log_conj (x : ℂ) (h : x.arg ≠ π) : log (conj x) = conj (log x) := by
rw [log_conj_eq_ite, if_neg h]
#align complex.log_conj Complex.log_conj
theorem log_inv_eq_ite (x : ℂ) : log x⁻¹ = if x.arg = π then -conj (log x) else -log x := by
by_cases hx : x = 0
· simp [hx]
rw [inv_def, log_mul_ofReal, Real.log_inv, ofReal_neg, ← sub_eq_neg_add, log_conj_eq_ite]
· simp_rw [log, map_add, map_mul, conj_ofReal, conj_I, normSq_eq_abs, Real.log_pow,
Nat.cast_two, ofReal_mul, neg_add, mul_neg, neg_neg]
norm_num; rw [two_mul] -- Porting note: added to simplify `↑2`
split_ifs
· rw [add_sub_right_comm, sub_add_cancel_left]
· rw [add_sub_right_comm, sub_add_cancel_left]
· rwa [inv_pos, Complex.normSq_pos]
· rwa [map_ne_zero]
#align complex.log_inv_eq_ite Complex.log_inv_eq_ite
theorem log_inv (x : ℂ) (hx : x.arg ≠ π) : log x⁻¹ = -log x := by rw [log_inv_eq_ite, if_neg hx]
#align complex.log_inv Complex.log_inv
theorem two_pi_I_ne_zero : (2 * π * I : ℂ) ≠ 0 := by norm_num [Real.pi_ne_zero, I_ne_zero]
set_option linter.uppercaseLean3 false in
#align complex.two_pi_I_ne_zero Complex.two_pi_I_ne_zero
theorem exp_eq_one_iff {x : ℂ} : exp x = 1 ↔ ∃ n : ℤ, x = n * (2 * π * I) := by
constructor
· intro h
rcases existsUnique_add_zsmul_mem_Ioc Real.two_pi_pos x.im (-π) with ⟨n, hn, -⟩
use -n
rw [Int.cast_neg, neg_mul, eq_neg_iff_add_eq_zero]
have : (x + n * (2 * π * I)).im ∈ Set.Ioc (-π) π := by simpa [two_mul, mul_add] using hn
rw [← log_exp this.1 this.2, exp_periodic.int_mul n, h, log_one]
· rintro ⟨n, rfl⟩
exact (exp_periodic.int_mul n).eq.trans exp_zero
#align complex.exp_eq_one_iff Complex.exp_eq_one_iff
theorem exp_eq_exp_iff_exp_sub_eq_one {x y : ℂ} : exp x = exp y ↔ exp (x - y) = 1 := by
rw [exp_sub, div_eq_one_iff_eq (exp_ne_zero _)]
#align complex.exp_eq_exp_iff_exp_sub_eq_one Complex.exp_eq_exp_iff_exp_sub_eq_one
theorem exp_eq_exp_iff_exists_int {x y : ℂ} : exp x = exp y ↔ ∃ n : ℤ, x = y + n * (2 * π * I) := by
simp only [exp_eq_exp_iff_exp_sub_eq_one, exp_eq_one_iff, sub_eq_iff_eq_add']
#align complex.exp_eq_exp_iff_exists_int Complex.exp_eq_exp_iff_exists_int
@[simp]
| Mathlib/Analysis/SpecialFunctions/Complex/Log.lean | 177 | 189 | theorem countable_preimage_exp {s : Set ℂ} : (exp ⁻¹' s).Countable ↔ s.Countable := by |
refine ⟨fun hs => ?_, fun hs => ?_⟩
· refine ((hs.image exp).insert 0).mono ?_
rw [Set.image_preimage_eq_inter_range, range_exp, ← Set.diff_eq, ← Set.union_singleton,
Set.diff_union_self]
exact Set.subset_union_left
· rw [← Set.biUnion_preimage_singleton]
refine hs.biUnion fun z hz => ?_
rcases em (∃ w, exp w = z) with (⟨w, rfl⟩ | hne)
· simp only [Set.preimage, Set.mem_singleton_iff, exp_eq_exp_iff_exists_int, Set.setOf_exists]
exact Set.countable_iUnion fun m => Set.countable_singleton _
· push_neg at hne
simp [Set.preimage, hne]
|
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Deprecated.Submonoid
#align_import deprecated.subgroup from "leanprover-community/mathlib"@"f93c11933efbc3c2f0299e47b8ff83e9b539cbf6"
open Set Function
variable {G : Type*} {H : Type*} {A : Type*} {a a₁ a₂ b c : G}
-- Homomorphism subgroups
namespace IsGroupHom
open IsSubmonoid IsSubgroup
@[to_additive "`ker f : Set A` is the underlying subset of the kernel of a map `A → B`"]
def ker [Group H] (f : G → H) : Set G :=
preimage f (trivial H)
#align is_group_hom.ker IsGroupHom.ker
#align is_add_group_hom.ker IsAddGroupHom.ker
@[to_additive]
theorem mem_ker [Group H] (f : G → H) {x : G} : x ∈ ker f ↔ f x = 1 :=
mem_trivial
#align is_group_hom.mem_ker IsGroupHom.mem_ker
#align is_add_group_hom.mem_ker IsAddGroupHom.mem_ker
variable [Group G] [Group H]
@[to_additive]
| Mathlib/Deprecated/Subgroup.lean | 342 | 345 | theorem one_ker_inv {f : G → H} (hf : IsGroupHom f) {a b : G} (h : f (a * b⁻¹) = 1) :
f a = f b := by |
rw [hf.map_mul, hf.map_inv] at h
rw [← inv_inv (f b), eq_inv_of_mul_eq_one_left h]
|
import Mathlib.CategoryTheory.Subobject.Lattice
#align_import category_theory.subobject.limits from "leanprover-community/mathlib"@"956af7c76589f444f2e1313911bad16366ea476d"
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Subobject Opposite
variable {C : Type u} [Category.{v} C] {X Y Z : C}
namespace CategoryTheory
namespace Limits
section Kernel
variable [HasZeroMorphisms C] (f : X ⟶ Y) [HasKernel f]
abbrev kernelSubobject : Subobject X :=
Subobject.mk (kernel.ι f)
#align category_theory.limits.kernel_subobject CategoryTheory.Limits.kernelSubobject
def kernelSubobjectIso : (kernelSubobject f : C) ≅ kernel f :=
Subobject.underlyingIso (kernel.ι f)
#align category_theory.limits.kernel_subobject_iso CategoryTheory.Limits.kernelSubobjectIso
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow :
(kernelSubobjectIso f).hom ≫ kernel.ι f = (kernelSubobject f).arrow := by
simp [kernelSubobjectIso]
#align category_theory.limits.kernel_subobject_arrow CategoryTheory.Limits.kernelSubobject_arrow
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow' :
(kernelSubobjectIso f).inv ≫ (kernelSubobject f).arrow = kernel.ι f := by
simp [kernelSubobjectIso]
#align category_theory.limits.kernel_subobject_arrow' CategoryTheory.Limits.kernelSubobject_arrow'
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobject_arrow_comp : (kernelSubobject f).arrow ≫ f = 0 := by
rw [← kernelSubobject_arrow]
simp only [Category.assoc, kernel.condition, comp_zero]
#align category_theory.limits.kernel_subobject_arrow_comp CategoryTheory.Limits.kernelSubobject_arrow_comp
theorem kernelSubobject_factors {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
(kernelSubobject f).Factors h :=
⟨kernel.lift _ h w, by simp⟩
#align category_theory.limits.kernel_subobject_factors CategoryTheory.Limits.kernelSubobject_factors
theorem kernelSubobject_factors_iff {W : C} (h : W ⟶ X) :
(kernelSubobject f).Factors h ↔ h ≫ f = 0 :=
⟨fun w => by
rw [← Subobject.factorThru_arrow _ _ w, Category.assoc, kernelSubobject_arrow_comp,
comp_zero],
kernelSubobject_factors f h⟩
#align category_theory.limits.kernel_subobject_factors_iff CategoryTheory.Limits.kernelSubobject_factors_iff
def factorThruKernelSubobject {W : C} (h : W ⟶ X) (w : h ≫ f = 0) : W ⟶ kernelSubobject f :=
(kernelSubobject f).factorThru h (kernelSubobject_factors f h w)
#align category_theory.limits.factor_thru_kernel_subobject CategoryTheory.Limits.factorThruKernelSubobject
@[simp]
theorem factorThruKernelSubobject_comp_arrow {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
factorThruKernelSubobject f h w ≫ (kernelSubobject f).arrow = h := by
dsimp [factorThruKernelSubobject]
simp
#align category_theory.limits.factor_thru_kernel_subobject_comp_arrow CategoryTheory.Limits.factorThruKernelSubobject_comp_arrow
@[simp]
theorem factorThruKernelSubobject_comp_kernelSubobjectIso {W : C} (h : W ⟶ X) (w : h ≫ f = 0) :
factorThruKernelSubobject f h w ≫ (kernelSubobjectIso f).hom = kernel.lift f h w :=
(cancel_mono (kernel.ι f)).1 <| by simp
#align category_theory.limits.factor_thru_kernel_subobject_comp_kernel_subobject_iso CategoryTheory.Limits.factorThruKernelSubobject_comp_kernelSubobjectIso
section
variable {f} {X' Y' : C} {f' : X' ⟶ Y'} [HasKernel f']
def kernelSubobjectMap (sq : Arrow.mk f ⟶ Arrow.mk f') :
(kernelSubobject f : C) ⟶ (kernelSubobject f' : C) :=
Subobject.factorThru _ ((kernelSubobject f).arrow ≫ sq.left)
(kernelSubobject_factors _ _ (by simp [sq.w]))
#align category_theory.limits.kernel_subobject_map CategoryTheory.Limits.kernelSubobjectMap
@[reassoc (attr := simp), elementwise (attr := simp)]
theorem kernelSubobjectMap_arrow (sq : Arrow.mk f ⟶ Arrow.mk f') :
kernelSubobjectMap sq ≫ (kernelSubobject f').arrow = (kernelSubobject f).arrow ≫ sq.left := by
simp [kernelSubobjectMap]
#align category_theory.limits.kernel_subobject_map_arrow CategoryTheory.Limits.kernelSubobjectMap_arrow
@[simp]
theorem kernelSubobjectMap_id : kernelSubobjectMap (𝟙 (Arrow.mk f)) = 𝟙 _ := by aesop_cat
#align category_theory.limits.kernel_subobject_map_id CategoryTheory.Limits.kernelSubobjectMap_id
@[simp]
theorem kernelSubobjectMap_comp {X'' Y'' : C} {f'' : X'' ⟶ Y''} [HasKernel f'']
(sq : Arrow.mk f ⟶ Arrow.mk f') (sq' : Arrow.mk f' ⟶ Arrow.mk f'') :
kernelSubobjectMap (sq ≫ sq') = kernelSubobjectMap sq ≫ kernelSubobjectMap sq' := by
aesop_cat
#align category_theory.limits.kernel_subobject_map_comp CategoryTheory.Limits.kernelSubobjectMap_comp
@[reassoc]
theorem kernel_map_comp_kernelSubobjectIso_inv (sq : Arrow.mk f ⟶ Arrow.mk f') :
kernel.map f f' sq.1 sq.2 sq.3.symm ≫ (kernelSubobjectIso _).inv =
(kernelSubobjectIso _).inv ≫ kernelSubobjectMap sq := by aesop_cat
#align category_theory.limits.kernel_map_comp_kernel_subobject_iso_inv CategoryTheory.Limits.kernel_map_comp_kernelSubobjectIso_inv
@[reassoc]
| Mathlib/CategoryTheory/Subobject/Limits.lean | 181 | 184 | theorem kernelSubobjectIso_comp_kernel_map (sq : Arrow.mk f ⟶ Arrow.mk f') :
(kernelSubobjectIso _).hom ≫ kernel.map f f' sq.1 sq.2 sq.3.symm =
kernelSubobjectMap sq ≫ (kernelSubobjectIso _).hom := by |
simp [← Iso.comp_inv_eq, kernel_map_comp_kernelSubobjectIso_inv]
|
import Mathlib.Algebra.CharP.Invertible
import Mathlib.Data.ZMod.Basic
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Polynomial.Chebyshev
import Mathlib.RingTheory.Ideal.LocalRing
#align_import ring_theory.polynomial.dickson from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
noncomputable section
namespace Polynomial
open Polynomial
variable {R S : Type*} [CommRing R] [CommRing S] (k : ℕ) (a : R)
noncomputable def dickson : ℕ → R[X]
| 0 => 3 - k
| 1 => X
| n + 2 => X * dickson (n + 1) - C a * dickson n
#align polynomial.dickson Polynomial.dickson
@[simp]
theorem dickson_zero : dickson k a 0 = 3 - k :=
rfl
#align polynomial.dickson_zero Polynomial.dickson_zero
@[simp]
theorem dickson_one : dickson k a 1 = X :=
rfl
#align polynomial.dickson_one Polynomial.dickson_one
theorem dickson_two : dickson k a 2 = X ^ 2 - C a * (3 - k : R[X]) := by
simp only [dickson, sq]
#align polynomial.dickson_two Polynomial.dickson_two
@[simp]
theorem dickson_add_two (n : ℕ) :
dickson k a (n + 2) = X * dickson k a (n + 1) - C a * dickson k a n := by rw [dickson]
#align polynomial.dickson_add_two Polynomial.dickson_add_two
theorem dickson_of_two_le {n : ℕ} (h : 2 ≤ n) :
dickson k a n = X * dickson k a (n - 1) - C a * dickson k a (n - 2) := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_add_of_le h
rw [add_comm]
exact dickson_add_two k a n
#align polynomial.dickson_of_two_le Polynomial.dickson_of_two_le
variable {k a}
theorem map_dickson (f : R →+* S) : ∀ n : ℕ, map f (dickson k a n) = dickson k (f a) n
| 0 => by
simp_rw [dickson_zero, Polynomial.map_sub, Polynomial.map_natCast, Polynomial.map_ofNat]
| 1 => by simp only [dickson_one, map_X]
| n + 2 => by
simp only [dickson_add_two, Polynomial.map_sub, Polynomial.map_mul, map_X, map_C]
rw [map_dickson f n, map_dickson f (n + 1)]
#align polynomial.map_dickson Polynomial.map_dickson
@[simp]
theorem dickson_two_zero : ∀ n : ℕ, dickson 2 (0 : R) n = X ^ n
| 0 => by
simp only [dickson_zero, pow_zero]
norm_num
| 1 => by simp only [dickson_one, pow_one]
| n + 2 => by
simp only [dickson_add_two, C_0, zero_mul, sub_zero]
rw [dickson_two_zero (n + 1), pow_add X (n + 1) 1, mul_comm, pow_one]
#align polynomial.dickson_two_zero Polynomial.dickson_two_zero
section Dickson
theorem dickson_one_one_eval_add_inv (x y : R) (h : x * y = 1) :
∀ n, (dickson 1 (1 : R) n).eval (x + y) = x ^ n + y ^ n
| 0 => by
simp only [eval_one, eval_add, pow_zero, dickson_zero]; norm_num
| 1 => by simp only [eval_X, dickson_one, pow_one]
| n + 2 => by
simp only [eval_sub, eval_mul, dickson_one_one_eval_add_inv x y h _, eval_X, dickson_add_two,
C_1, eval_one]
conv_lhs => simp only [pow_succ', add_mul, mul_add, h, ← mul_assoc, mul_comm y x, one_mul]
ring
#align polynomial.dickson_one_one_eval_add_inv Polynomial.dickson_one_one_eval_add_inv
variable (R)
-- Porting note: Added 2 new theorems for convenience
private theorem two_mul_C_half_eq_one [Invertible (2 : R)] : 2 * C (⅟ 2 : R) = 1 := by
rw [two_mul, ← C_add, invOf_two_add_invOf_two, C_1]
private theorem C_half_mul_two_eq_one [Invertible (2 : R)] : C (⅟ 2 : R) * 2 = 1 := by
rw [mul_comm, two_mul_C_half_eq_one]
theorem dickson_one_one_eq_chebyshev_T [Invertible (2 : R)] :
∀ n, dickson 1 (1 : R) n = 2 * (Chebyshev.T R n).comp (C (⅟ 2) * X)
| 0 => by
simp only [Chebyshev.T_zero, mul_one, one_comp, dickson_zero]
norm_num
| 1 => by
rw [dickson_one, Nat.cast_one, Chebyshev.T_one, X_comp, ← mul_assoc, two_mul_C_half_eq_one,
one_mul]
| n + 2 => by
rw [dickson_add_two, C_1, Nat.cast_add, Nat.cast_two, Chebyshev.T_add_two,
dickson_one_one_eq_chebyshev_T (n + 1), dickson_one_one_eq_chebyshev_T n, sub_comp, mul_comp,
mul_comp, X_comp, ofNat_comp]
simp_rw [← mul_assoc, Nat.cast_ofNat, two_mul_C_half_eq_one, Nat.cast_add, Nat.cast_one]
ring
set_option linter.uppercaseLean3 false in
#align polynomial.dickson_one_one_eq_chebyshev_T Polynomial.dickson_one_one_eq_chebyshev_T
theorem chebyshev_T_eq_dickson_one_one [Invertible (2 : R)] (n : ℕ) :
Chebyshev.T R n = C (⅟ 2) * (dickson 1 1 n).comp (2 * X) := by
rw [dickson_one_one_eq_chebyshev_T, mul_comp, ofNat_comp, comp_assoc, mul_comp, C_comp, X_comp]
simp_rw [← mul_assoc, Nat.cast_ofNat, C_half_mul_two_eq_one, one_mul, comp_X]
set_option linter.uppercaseLean3 false in
#align polynomial.chebyshev_T_eq_dickson_one_one Polynomial.chebyshev_T_eq_dickson_one_one
| Mathlib/RingTheory/Polynomial/Dickson.lean | 175 | 188 | theorem dickson_one_one_mul (m n : ℕ) :
dickson 1 (1 : R) (m * n) = (dickson 1 1 m).comp (dickson 1 1 n) := by |
have h : (1 : R) = Int.castRingHom R 1 := by simp only [eq_intCast, Int.cast_one]
rw [h]
simp only [← map_dickson (Int.castRingHom R), ← map_comp]
congr 1
apply map_injective (Int.castRingHom ℚ) Int.cast_injective
simp only [map_dickson, map_comp, eq_intCast, Int.cast_one, dickson_one_one_eq_chebyshev_T,
Nat.cast_mul, Chebyshev.T_mul, two_mul, ← add_comp]
simp only [← two_mul, ← comp_assoc]
apply eval₂_congr rfl rfl
rw [comp_assoc]
apply eval₂_congr rfl _ rfl
rw [mul_comp, C_comp, X_comp, ← mul_assoc, C_half_mul_two_eq_one, one_mul]
|
import Mathlib.Data.Stream.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Init.Data.List.Basic
import Mathlib.Data.List.Basic
#align_import data.stream.init from "leanprover-community/mathlib"@"207cfac9fcd06138865b5d04f7091e46d9320432"
set_option autoImplicit true
open Nat Function Option
namespace Stream'
variable {α : Type u} {β : Type v} {δ : Type w}
instance [Inhabited α] : Inhabited (Stream' α) :=
⟨Stream'.const default⟩
protected theorem eta (s : Stream' α) : (head s::tail s) = s :=
funext fun i => by cases i <;> rfl
#align stream.eta Stream'.eta
@[ext]
protected theorem ext {s₁ s₂ : Stream' α} : (∀ n, get s₁ n = get s₂ n) → s₁ = s₂ :=
fun h => funext h
#align stream.ext Stream'.ext
@[simp]
theorem get_zero_cons (a : α) (s : Stream' α) : get (a::s) 0 = a :=
rfl
#align stream.nth_zero_cons Stream'.get_zero_cons
@[simp]
theorem head_cons (a : α) (s : Stream' α) : head (a::s) = a :=
rfl
#align stream.head_cons Stream'.head_cons
@[simp]
theorem tail_cons (a : α) (s : Stream' α) : tail (a::s) = s :=
rfl
#align stream.tail_cons Stream'.tail_cons
@[simp]
theorem get_drop (n m : Nat) (s : Stream' α) : get (drop m s) n = get s (n + m) :=
rfl
#align stream.nth_drop Stream'.get_drop
theorem tail_eq_drop (s : Stream' α) : tail s = drop 1 s :=
rfl
#align stream.tail_eq_drop Stream'.tail_eq_drop
@[simp]
| Mathlib/Data/Stream/Init.lean | 65 | 66 | theorem drop_drop (n m : Nat) (s : Stream' α) : drop n (drop m s) = drop (n + m) s := by |
ext; simp [Nat.add_assoc]
|
import Mathlib.Algebra.Algebra.Defs
import Mathlib.GroupTheory.GroupAction.BigOperators
import Mathlib.LinearAlgebra.Prod
#align_import algebra.triv_sq_zero_ext from "leanprover-community/mathlib"@"ce7e9d53d4bbc38065db3b595cd5bd73c323bc1d"
universe u v w
def TrivSqZeroExt (R : Type u) (M : Type v) :=
R × M
#align triv_sq_zero_ext TrivSqZeroExt
local notation "tsze" => TrivSqZeroExt
open scoped RightActions
namespace TrivSqZeroExt
open MulOpposite
section Algebra
variable (S : Type*) (R R' : Type u) (M : Type v)
variable [CommSemiring S] [Semiring R] [CommSemiring R'] [AddCommMonoid M]
variable [Algebra S R] [Algebra S R'] [Module S M]
variable [Module R M] [Module Rᵐᵒᵖ M] [SMulCommClass R Rᵐᵒᵖ M]
variable [IsScalarTower S R M] [IsScalarTower S Rᵐᵒᵖ M]
variable [Module R' M] [Module R'ᵐᵒᵖ M] [IsCentralScalar R' M] [IsScalarTower S R' M]
instance algebra' : Algebra S (tsze R M) :=
{ (TrivSqZeroExt.inlHom R M).comp (algebraMap S R) with
smul := (· • ·)
commutes' := fun s x =>
ext (Algebra.commutes _ _) <|
show algebraMap S R s •> x.snd + (0 : M) <• x.fst
= x.fst •> (0 : M) + x.snd <• algebraMap S R s by
rw [smul_zero, smul_zero, add_zero, zero_add]
rw [Algebra.algebraMap_eq_smul_one, MulOpposite.op_smul, op_one, smul_assoc,
one_smul, smul_assoc, one_smul]
smul_def' := fun s x =>
ext (Algebra.smul_def _ _) <|
show s • x.snd = algebraMap S R s •> x.snd + (0 : M) <• x.fst by
rw [smul_zero, add_zero, algebraMap_smul] }
#align triv_sq_zero_ext.algebra' TrivSqZeroExt.algebra'
-- shortcut instance for the common case
instance : Algebra R' (tsze R' M) :=
TrivSqZeroExt.algebra' _ _ _
theorem algebraMap_eq_inl : ⇑(algebraMap R' (tsze R' M)) = inl :=
rfl
#align triv_sq_zero_ext.algebra_map_eq_inl TrivSqZeroExt.algebraMap_eq_inl
theorem algebraMap_eq_inlHom : algebraMap R' (tsze R' M) = inlHom R' M :=
rfl
#align triv_sq_zero_ext.algebra_map_eq_inl_hom TrivSqZeroExt.algebraMap_eq_inlHom
theorem algebraMap_eq_inl' (s : S) : algebraMap S (tsze R M) s = inl (algebraMap S R s) :=
rfl
#align triv_sq_zero_ext.algebra_map_eq_inl' TrivSqZeroExt.algebraMap_eq_inl'
@[simps]
def fstHom : tsze R M →ₐ[S] R where
toFun := fst
map_one' := fst_one
map_mul' := fst_mul
map_zero' := fst_zero (M := M)
map_add' := fst_add
commutes' _r := fst_inl M _
#align triv_sq_zero_ext.fst_hom TrivSqZeroExt.fstHom
@[simps]
def inlAlgHom : R →ₐ[S] tsze R M where
toFun := inl
map_one' := inl_one _
map_mul' := inl_mul _
map_zero' := inl_zero (M := M)
map_add' := inl_add _
commutes' _r := (algebraMap_eq_inl' _ _ _ _).symm
variable {R R' S M}
theorem algHom_ext {A} [Semiring A] [Algebra R' A] ⦃f g : tsze R' M →ₐ[R'] A⦄
(h : ∀ m, f (inr m) = g (inr m)) : f = g :=
AlgHom.toLinearMap_injective <|
linearMap_ext (fun _r => (f.commutes _).trans (g.commutes _).symm) h
#align triv_sq_zero_ext.alg_hom_ext TrivSqZeroExt.algHom_ext
@[ext]
theorem algHom_ext' {A} [Semiring A] [Algebra S A] ⦃f g : tsze R M →ₐ[S] A⦄
(hinl : f.comp (inlAlgHom S R M) = g.comp (inlAlgHom S R M))
(hinr : f.toLinearMap.comp (inrHom R M |>.restrictScalars S) =
g.toLinearMap.comp (inrHom R M |>.restrictScalars S)) : f = g :=
AlgHom.toLinearMap_injective <|
linearMap_ext (AlgHom.congr_fun hinl) (LinearMap.congr_fun hinr)
#align triv_sq_zero_ext.alg_hom_ext' TrivSqZeroExt.algHom_ext'
variable {A : Type*} [Semiring A] [Algebra S A] [Algebra R' A]
def lift (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r •> x) = f r * g x)
(hgf : ∀ r x, g (x <• r) = g x * f r) : tsze R M →ₐ[S] A :=
AlgHom.ofLinearMap
((f.comp <| fstHom S R M).toLinearMap + g ∘ₗ (sndHom R M |>.restrictScalars S))
(show f 1 + g (0 : M) = 1 by rw [map_zero, map_one, add_zero])
(TrivSqZeroExt.ind fun r₁ m₁ =>
TrivSqZeroExt.ind fun r₂ m₂ => by
dsimp
simp only [add_zero, zero_add, add_mul, mul_add, smul_mul_smul, hg, smul_zero,
op_smul_eq_smul]
rw [← AlgHom.map_mul, LinearMap.map_add, add_comm (g _), add_assoc, hfg, hgf])
#align triv_sq_zero_ext.lift_aux TrivSqZeroExt.lift
theorem lift_def (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r • x) = f r * g x)
(hgf : ∀ r x, g (op r • x) = g x * f r) (x : tsze R M) :
lift f g hg hfg hgf x = f x.fst + g x.snd :=
rfl
@[simp]
theorem lift_apply_inl (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r •> x) = f r * g x)
(hgf : ∀ r x, g (x <• r) = g x * f r)
(r : R) :
lift f g hg hfg hgf (inl r) = f r :=
show f r + g 0 = f r by rw [map_zero, add_zero]
@[simp]
theorem lift_apply_inr (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r •> x) = f r * g x)
(hgf : ∀ r x, g (x <• r) = g x * f r)
(m : M) :
lift f g hg hfg hgf (inr m) = g m :=
show f 0 + g m = g m by rw [map_zero, zero_add]
#align triv_sq_zero_ext.lift_aux_apply_inr TrivSqZeroExt.lift_apply_inr
@[simp]
theorem lift_comp_inlHom (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r •> x) = f r * g x)
(hgf : ∀ r x, g (x <• r) = g x * f r) :
(lift f g hg hfg hgf).comp (inlAlgHom S R M) = f :=
AlgHom.ext <| lift_apply_inl f g hg hfg hgf
@[simp]
theorem lift_comp_inrHom (f : R →ₐ[S] A) (g : M →ₗ[S] A)
(hg : ∀ x y, g x * g y = 0)
(hfg : ∀ r x, g (r •> x) = f r * g x)
(hgf : ∀ r x, g (x <• r) = g x * f r) :
(lift f g hg hfg hgf).toLinearMap.comp (inrHom R M |>.restrictScalars S) = g :=
LinearMap.ext <| lift_apply_inr f g hg hfg hgf
#align triv_sq_zero_ext.lift_aux_comp_inr_hom TrivSqZeroExt.lift_comp_inrHom
@[simp]
theorem lift_inlAlgHom_inrHom :
lift (inlAlgHom _ _ _) (inrHom R M |>.restrictScalars S)
(inr_mul_inr R) (fun _ _ => (inl_mul_inr _ _).symm) (fun _ _ => (inr_mul_inl _ _).symm) =
AlgHom.id S (tsze R M) :=
algHom_ext' (lift_comp_inlHom _ _ _ _ _) (lift_comp_inrHom _ _ _ _ _)
#align triv_sq_zero_ext.lift_aux_inr_hom TrivSqZeroExt.lift_inlAlgHom_inrHomₓ
@[simps! apply symm_apply_coe]
def liftEquiv :
{fg : (R →ₐ[S] A) × (M →ₗ[S] A) //
(∀ x y, fg.2 x * fg.2 y = 0) ∧
(∀ r x, fg.2 (r •> x) = fg.1 r * fg.2 x) ∧
(∀ r x, fg.2 (x <• r) = fg.2 x * fg.1 r)} ≃ (tsze R M →ₐ[S] A) where
toFun fg := lift fg.val.1 fg.val.2 fg.prop.1 fg.prop.2.1 fg.prop.2.2
invFun F :=
⟨(F.comp (inlAlgHom _ _ _), F.toLinearMap ∘ₗ (inrHom _ _ |>.restrictScalars _)),
(fun _x _y =>
(F.map_mul _ _).symm.trans <| (F.congr_arg <| inr_mul_inr _ _ _).trans F.map_zero),
(fun _r _x => (F.congr_arg (inl_mul_inr _ _).symm).trans (F.map_mul _ _)),
(fun _r _x => (F.congr_arg (inr_mul_inl _ _).symm).trans (F.map_mul _ _))⟩
left_inv _f := Subtype.ext <| Prod.ext (lift_comp_inlHom _ _ _ _ _) (lift_comp_inrHom _ _ _ _ _)
right_inv _F := algHom_ext' (lift_comp_inlHom _ _ _ _ _) (lift_comp_inrHom _ _ _ _ _)
@[simps! apply symm_apply_coe]
def liftEquivOfComm :
{ f : M →ₗ[R'] A // ∀ x y, f x * f y = 0 } ≃ (tsze R' M →ₐ[R'] A) := by
refine Equiv.trans ?_ liftEquiv
exact {
toFun := fun f => ⟨(Algebra.ofId _ _, f.val), f.prop,
fun r x => by simp [Algebra.smul_def, Algebra.ofId_apply],
fun r x => by simp [Algebra.smul_def, Algebra.ofId_apply, Algebra.commutes]⟩
invFun := fun fg => ⟨fg.val.2, fg.prop.1⟩
left_inv := fun f => rfl
right_inv := fun fg => Subtype.ext <|
Prod.ext (AlgHom.toLinearMap_injective <| LinearMap.ext_ring <| by simp)
rfl }
#align triv_sq_zero_ext.lift TrivSqZeroExt.liftEquiv
section map
variable {N P : Type*} [AddCommMonoid N] [Module R' N] [Module R'ᵐᵒᵖ N] [IsCentralScalar R' N]
[AddCommMonoid P] [Module R' P] [Module R'ᵐᵒᵖ P] [IsCentralScalar R' P]
def map (f : M →ₗ[R'] N) : TrivSqZeroExt R' M →ₐ[R'] TrivSqZeroExt R' N :=
liftEquivOfComm ⟨inrHom R' N ∘ₗ f, fun _ _ => inr_mul_inr _ _ _⟩
@[simp]
| Mathlib/Algebra/TrivSqZeroExt.lean | 1,062 | 1,063 | theorem map_inl (f : M →ₗ[R'] N) (r : R') : map f (inl r) = inl r := by |
rw [map, liftEquivOfComm_apply, lift_apply_inl, Algebra.ofId_apply, algebraMap_eq_inl]
|
import Mathlib.Algebra.Polynomial.Degree.Definitions
import Mathlib.Algebra.Polynomial.Induction
#align_import data.polynomial.eval from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f"
set_option linter.uppercaseLean3 false
noncomputable section
open Finset AddMonoidAlgebra
open Polynomial
namespace Polynomial
universe u v w y
variable {R : Type u} {S : Type v} {T : Type w} {ι : Type y} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
section
variable [Semiring S]
variable (f : R →+* S) (x : S)
irreducible_def eval₂ (p : R[X]) : S :=
p.sum fun e a => f a * x ^ e
#align polynomial.eval₂ Polynomial.eval₂
theorem eval₂_eq_sum {f : R →+* S} {x : S} : p.eval₂ f x = p.sum fun e a => f a * x ^ e := by
rw [eval₂_def]
#align polynomial.eval₂_eq_sum Polynomial.eval₂_eq_sum
theorem eval₂_congr {R S : Type*} [Semiring R] [Semiring S] {f g : R →+* S} {s t : S}
{φ ψ : R[X]} : f = g → s = t → φ = ψ → eval₂ f s φ = eval₂ g t ψ := by
rintro rfl rfl rfl; rfl
#align polynomial.eval₂_congr Polynomial.eval₂_congr
@[simp]
theorem eval₂_at_zero : p.eval₂ f 0 = f (coeff p 0) := by
simp (config := { contextual := true }) only [eval₂_eq_sum, zero_pow_eq, mul_ite, mul_zero,
mul_one, sum, Classical.not_not, mem_support_iff, sum_ite_eq', ite_eq_left_iff,
RingHom.map_zero, imp_true_iff, eq_self_iff_true]
#align polynomial.eval₂_at_zero Polynomial.eval₂_at_zero
@[simp]
theorem eval₂_zero : (0 : R[X]).eval₂ f x = 0 := by simp [eval₂_eq_sum]
#align polynomial.eval₂_zero Polynomial.eval₂_zero
@[simp]
theorem eval₂_C : (C a).eval₂ f x = f a := by simp [eval₂_eq_sum]
#align polynomial.eval₂_C Polynomial.eval₂_C
@[simp]
theorem eval₂_X : X.eval₂ f x = x := by simp [eval₂_eq_sum]
#align polynomial.eval₂_X Polynomial.eval₂_X
@[simp]
theorem eval₂_monomial {n : ℕ} {r : R} : (monomial n r).eval₂ f x = f r * x ^ n := by
simp [eval₂_eq_sum]
#align polynomial.eval₂_monomial Polynomial.eval₂_monomial
@[simp]
theorem eval₂_X_pow {n : ℕ} : (X ^ n).eval₂ f x = x ^ n := by
rw [X_pow_eq_monomial]
convert eval₂_monomial f x (n := n) (r := 1)
simp
#align polynomial.eval₂_X_pow Polynomial.eval₂_X_pow
@[simp]
theorem eval₂_add : (p + q).eval₂ f x = p.eval₂ f x + q.eval₂ f x := by
simp only [eval₂_eq_sum]
apply sum_add_index <;> simp [add_mul]
#align polynomial.eval₂_add Polynomial.eval₂_add
@[simp]
theorem eval₂_one : (1 : R[X]).eval₂ f x = 1 := by rw [← C_1, eval₂_C, f.map_one]
#align polynomial.eval₂_one Polynomial.eval₂_one
set_option linter.deprecated false in
@[simp]
theorem eval₂_bit0 : (bit0 p).eval₂ f x = bit0 (p.eval₂ f x) := by rw [bit0, eval₂_add, bit0]
#align polynomial.eval₂_bit0 Polynomial.eval₂_bit0
set_option linter.deprecated false in
@[simp]
theorem eval₂_bit1 : (bit1 p).eval₂ f x = bit1 (p.eval₂ f x) := by
rw [bit1, eval₂_add, eval₂_bit0, eval₂_one, bit1]
#align polynomial.eval₂_bit1 Polynomial.eval₂_bit1
@[simp]
theorem eval₂_smul (g : R →+* S) (p : R[X]) (x : S) {s : R} :
eval₂ g x (s • p) = g s * eval₂ g x p := by
have A : p.natDegree < p.natDegree.succ := Nat.lt_succ_self _
have B : (s • p).natDegree < p.natDegree.succ := (natDegree_smul_le _ _).trans_lt A
rw [eval₂_eq_sum, eval₂_eq_sum, sum_over_range' _ _ _ A, sum_over_range' _ _ _ B] <;>
simp [mul_sum, mul_assoc]
#align polynomial.eval₂_smul Polynomial.eval₂_smul
@[simp]
theorem eval₂_C_X : eval₂ C X p = p :=
Polynomial.induction_on' p (fun p q hp hq => by simp [hp, hq]) fun n x => by
rw [eval₂_monomial, ← smul_X_eq_monomial, C_mul']
#align polynomial.eval₂_C_X Polynomial.eval₂_C_X
@[simps]
def eval₂AddMonoidHom : R[X] →+ S where
toFun := eval₂ f x
map_zero' := eval₂_zero _ _
map_add' _ _ := eval₂_add _ _
#align polynomial.eval₂_add_monoid_hom Polynomial.eval₂AddMonoidHom
#align polynomial.eval₂_add_monoid_hom_apply Polynomial.eval₂AddMonoidHom_apply
@[simp]
theorem eval₂_natCast (n : ℕ) : (n : R[X]).eval₂ f x = n := by
induction' n with n ih
-- Porting note: `Nat.zero_eq` is required.
· simp only [eval₂_zero, Nat.cast_zero, Nat.zero_eq]
· rw [n.cast_succ, eval₂_add, ih, eval₂_one, n.cast_succ]
#align polynomial.eval₂_nat_cast Polynomial.eval₂_natCast
@[deprecated (since := "2024-04-17")]
alias eval₂_nat_cast := eval₂_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
lemma eval₂_ofNat {S : Type*} [Semiring S] (n : ℕ) [n.AtLeastTwo] (f : R →+* S) (a : S) :
(no_index (OfNat.ofNat n : R[X])).eval₂ f a = OfNat.ofNat n := by
simp [OfNat.ofNat]
variable [Semiring T]
theorem eval₂_sum (p : T[X]) (g : ℕ → T → R[X]) (x : S) :
(p.sum g).eval₂ f x = p.sum fun n a => (g n a).eval₂ f x := by
let T : R[X] →+ S :=
{ toFun := eval₂ f x
map_zero' := eval₂_zero _ _
map_add' := fun p q => eval₂_add _ _ }
have A : ∀ y, eval₂ f x y = T y := fun y => rfl
simp only [A]
rw [sum, map_sum, sum]
#align polynomial.eval₂_sum Polynomial.eval₂_sum
theorem eval₂_list_sum (l : List R[X]) (x : S) : eval₂ f x l.sum = (l.map (eval₂ f x)).sum :=
map_list_sum (eval₂AddMonoidHom f x) l
#align polynomial.eval₂_list_sum Polynomial.eval₂_list_sum
theorem eval₂_multiset_sum (s : Multiset R[X]) (x : S) :
eval₂ f x s.sum = (s.map (eval₂ f x)).sum :=
map_multiset_sum (eval₂AddMonoidHom f x) s
#align polynomial.eval₂_multiset_sum Polynomial.eval₂_multiset_sum
theorem eval₂_finset_sum (s : Finset ι) (g : ι → R[X]) (x : S) :
(∑ i ∈ s, g i).eval₂ f x = ∑ i ∈ s, (g i).eval₂ f x :=
map_sum (eval₂AddMonoidHom f x) _ _
#align polynomial.eval₂_finset_sum Polynomial.eval₂_finset_sum
theorem eval₂_ofFinsupp {f : R →+* S} {x : S} {p : R[ℕ]} :
eval₂ f x (⟨p⟩ : R[X]) = liftNC (↑f) (powersHom S x) p := by
simp only [eval₂_eq_sum, sum, toFinsupp_sum, support, coeff]
rfl
#align polynomial.eval₂_of_finsupp Polynomial.eval₂_ofFinsupp
theorem eval₂_mul_noncomm (hf : ∀ k, Commute (f <| q.coeff k) x) :
eval₂ f x (p * q) = eval₂ f x p * eval₂ f x q := by
rcases p with ⟨p⟩; rcases q with ⟨q⟩
simp only [coeff] at hf
simp only [← ofFinsupp_mul, eval₂_ofFinsupp]
exact liftNC_mul _ _ p q fun {k n} _hn => (hf k).pow_right n
#align polynomial.eval₂_mul_noncomm Polynomial.eval₂_mul_noncomm
@[simp]
theorem eval₂_mul_X : eval₂ f x (p * X) = eval₂ f x p * x := by
refine _root_.trans (eval₂_mul_noncomm _ _ fun k => ?_) (by rw [eval₂_X])
rcases em (k = 1) with (rfl | hk)
· simp
· simp [coeff_X_of_ne_one hk]
#align polynomial.eval₂_mul_X Polynomial.eval₂_mul_X
@[simp]
theorem eval₂_X_mul : eval₂ f x (X * p) = eval₂ f x p * x := by rw [X_mul, eval₂_mul_X]
#align polynomial.eval₂_X_mul Polynomial.eval₂_X_mul
theorem eval₂_mul_C' (h : Commute (f a) x) : eval₂ f x (p * C a) = eval₂ f x p * f a := by
rw [eval₂_mul_noncomm, eval₂_C]
intro k
by_cases hk : k = 0
· simp only [hk, h, coeff_C_zero, coeff_C_ne_zero]
· simp only [coeff_C_ne_zero hk, RingHom.map_zero, Commute.zero_left]
#align polynomial.eval₂_mul_C' Polynomial.eval₂_mul_C'
theorem eval₂_list_prod_noncomm (ps : List R[X])
(hf : ∀ p ∈ ps, ∀ (k), Commute (f <| coeff p k) x) :
eval₂ f x ps.prod = (ps.map (Polynomial.eval₂ f x)).prod := by
induction' ps using List.reverseRecOn with ps p ihp
· simp
· simp only [List.forall_mem_append, List.forall_mem_singleton] at hf
simp [eval₂_mul_noncomm _ _ hf.2, ihp hf.1]
#align polynomial.eval₂_list_prod_noncomm Polynomial.eval₂_list_prod_noncomm
@[simps]
def eval₂RingHom' (f : R →+* S) (x : S) (hf : ∀ a, Commute (f a) x) : R[X] →+* S where
toFun := eval₂ f x
map_add' _ _ := eval₂_add _ _
map_zero' := eval₂_zero _ _
map_mul' _p q := eval₂_mul_noncomm f x fun k => hf <| coeff q k
map_one' := eval₂_one _ _
#align polynomial.eval₂_ring_hom' Polynomial.eval₂RingHom'
end
section Comp
def comp (p q : R[X]) : R[X] :=
p.eval₂ C q
#align polynomial.comp Polynomial.comp
theorem comp_eq_sum_left : p.comp q = p.sum fun e a => C a * q ^ e := by rw [comp, eval₂_eq_sum]
#align polynomial.comp_eq_sum_left Polynomial.comp_eq_sum_left
@[simp]
theorem comp_X : p.comp X = p := by
simp only [comp, eval₂_def, C_mul_X_pow_eq_monomial]
exact sum_monomial_eq _
#align polynomial.comp_X Polynomial.comp_X
@[simp]
theorem X_comp : X.comp p = p :=
eval₂_X _ _
#align polynomial.X_comp Polynomial.X_comp
@[simp]
theorem comp_C : p.comp (C a) = C (p.eval a) := by simp [comp, map_sum (C : R →+* _)]
#align polynomial.comp_C Polynomial.comp_C
@[simp]
theorem C_comp : (C a).comp p = C a :=
eval₂_C _ _
#align polynomial.C_comp Polynomial.C_comp
@[simp]
theorem natCast_comp {n : ℕ} : (n : R[X]).comp p = n := by rw [← C_eq_natCast, C_comp]
#align polynomial.nat_cast_comp Polynomial.natCast_comp
@[deprecated (since := "2024-04-17")]
alias nat_cast_comp := natCast_comp
-- Porting note (#10756): new theorem
@[simp]
theorem ofNat_comp (n : ℕ) [n.AtLeastTwo] : (no_index (OfNat.ofNat n) : R[X]).comp p = n :=
natCast_comp
@[simp]
theorem comp_zero : p.comp (0 : R[X]) = C (p.eval 0) := by rw [← C_0, comp_C]
#align polynomial.comp_zero Polynomial.comp_zero
@[simp]
theorem zero_comp : comp (0 : R[X]) p = 0 := by rw [← C_0, C_comp]
#align polynomial.zero_comp Polynomial.zero_comp
@[simp]
theorem comp_one : p.comp 1 = C (p.eval 1) := by rw [← C_1, comp_C]
#align polynomial.comp_one Polynomial.comp_one
@[simp]
theorem one_comp : comp (1 : R[X]) p = 1 := by rw [← C_1, C_comp]
#align polynomial.one_comp Polynomial.one_comp
@[simp]
theorem add_comp : (p + q).comp r = p.comp r + q.comp r :=
eval₂_add _ _
#align polynomial.add_comp Polynomial.add_comp
@[simp]
theorem monomial_comp (n : ℕ) : (monomial n a).comp p = C a * p ^ n :=
eval₂_monomial _ _
#align polynomial.monomial_comp Polynomial.monomial_comp
@[simp]
theorem mul_X_comp : (p * X).comp r = p.comp r * r := by
induction p using Polynomial.induction_on' with
| h_add p q hp hq =>
simp only [hp, hq, add_mul, add_comp]
| h_monomial n b =>
simp only [pow_succ, mul_assoc, monomial_mul_X, monomial_comp]
#align polynomial.mul_X_comp Polynomial.mul_X_comp
@[simp]
theorem X_pow_comp {k : ℕ} : (X ^ k).comp p = p ^ k := by
induction' k with k ih
· simp
· simp [pow_succ, mul_X_comp, ih]
#align polynomial.X_pow_comp Polynomial.X_pow_comp
@[simp]
theorem mul_X_pow_comp {k : ℕ} : (p * X ^ k).comp r = p.comp r * r ^ k := by
induction' k with k ih
· simp
· simp [ih, pow_succ, ← mul_assoc, mul_X_comp]
#align polynomial.mul_X_pow_comp Polynomial.mul_X_pow_comp
@[simp]
theorem C_mul_comp : (C a * p).comp r = C a * p.comp r := by
induction p using Polynomial.induction_on' with
| h_add p q hp hq =>
simp [hp, hq, mul_add]
| h_monomial n b =>
simp [mul_assoc]
#align polynomial.C_mul_comp Polynomial.C_mul_comp
@[simp]
theorem natCast_mul_comp {n : ℕ} : ((n : R[X]) * p).comp r = n * p.comp r := by
rw [← C_eq_natCast, C_mul_comp]
#align polynomial.nat_cast_mul_comp Polynomial.natCast_mul_comp
@[deprecated (since := "2024-04-17")]
alias nat_cast_mul_comp := natCast_mul_comp
theorem mul_X_add_natCast_comp {n : ℕ} :
(p * (X + (n : R[X]))).comp q = p.comp q * (q + n) := by
rw [mul_add, add_comp, mul_X_comp, ← Nat.cast_comm, natCast_mul_comp, Nat.cast_comm, mul_add]
set_option linter.uppercaseLean3 false in
#align polynomial.mul_X_add_nat_cast_comp Polynomial.mul_X_add_natCast_comp
@[deprecated (since := "2024-04-17")]
alias mul_X_add_nat_cast_comp := mul_X_add_natCast_comp
@[simp]
theorem mul_comp {R : Type*} [CommSemiring R] (p q r : R[X]) :
(p * q).comp r = p.comp r * q.comp r :=
eval₂_mul _ _
#align polynomial.mul_comp Polynomial.mul_comp
@[simp]
theorem pow_comp {R : Type*} [CommSemiring R] (p q : R[X]) (n : ℕ) :
(p ^ n).comp q = p.comp q ^ n :=
(MonoidHom.mk (OneHom.mk (fun r : R[X] => r.comp q) one_comp) fun r s => mul_comp r s q).map_pow
p n
#align polynomial.pow_comp Polynomial.pow_comp
set_option linter.deprecated false in
@[simp]
theorem bit0_comp : comp (bit0 p : R[X]) q = bit0 (p.comp q) := by simp only [bit0, add_comp]
#align polynomial.bit0_comp Polynomial.bit0_comp
set_option linter.deprecated false in
@[simp]
theorem bit1_comp : comp (bit1 p : R[X]) q = bit1 (p.comp q) := by
simp only [bit1, add_comp, bit0_comp, one_comp]
#align polynomial.bit1_comp Polynomial.bit1_comp
@[simp]
theorem smul_comp [Monoid S] [DistribMulAction S R] [IsScalarTower S R R] (s : S) (p q : R[X]) :
(s • p).comp q = s • p.comp q := by
rw [← smul_one_smul R s p, comp, comp, eval₂_smul, ← smul_eq_C_mul, smul_assoc, one_smul]
#align polynomial.smul_comp Polynomial.smul_comp
| Mathlib/Algebra/Polynomial/Eval.lean | 695 | 699 | theorem comp_assoc {R : Type*} [CommSemiring R] (φ ψ χ : R[X]) :
(φ.comp ψ).comp χ = φ.comp (ψ.comp χ) := by |
refine Polynomial.induction_on φ ?_ ?_ ?_ <;>
· intros
simp_all only [add_comp, mul_comp, C_comp, X_comp, pow_succ, ← mul_assoc]
|
import Mathlib.Algebra.Group.Nat
import Mathlib.Algebra.Order.Sub.Canonical
import Mathlib.Data.List.Perm
import Mathlib.Data.Set.List
import Mathlib.Init.Quot
import Mathlib.Order.Hom.Basic
#align_import data.multiset.basic from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
universe v
open List Subtype Nat Function
variable {α : Type*} {β : Type v} {γ : Type*}
def Multiset.{u} (α : Type u) : Type u :=
Quotient (List.isSetoid α)
#align multiset Multiset
namespace Multiset
-- Porting note: new
@[coe]
def ofList : List α → Multiset α :=
Quot.mk _
instance : Coe (List α) (Multiset α) :=
⟨ofList⟩
@[simp]
theorem quot_mk_to_coe (l : List α) : @Eq (Multiset α) ⟦l⟧ l :=
rfl
#align multiset.quot_mk_to_coe Multiset.quot_mk_to_coe
@[simp]
theorem quot_mk_to_coe' (l : List α) : @Eq (Multiset α) (Quot.mk (· ≈ ·) l) l :=
rfl
#align multiset.quot_mk_to_coe' Multiset.quot_mk_to_coe'
@[simp]
theorem quot_mk_to_coe'' (l : List α) : @Eq (Multiset α) (Quot.mk Setoid.r l) l :=
rfl
#align multiset.quot_mk_to_coe'' Multiset.quot_mk_to_coe''
@[simp]
theorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Multiset α) = l₂ ↔ l₁ ~ l₂ :=
Quotient.eq
#align multiset.coe_eq_coe Multiset.coe_eq_coe
-- Porting note: new instance;
-- Porting note (#11215): TODO: move to better place
instance [DecidableEq α] (l₁ l₂ : List α) : Decidable (l₁ ≈ l₂) :=
inferInstanceAs (Decidable (l₁ ~ l₂))
-- Porting note: `Quotient.recOnSubsingleton₂ s₁ s₂` was in parens which broke elaboration
instance decidableEq [DecidableEq α] : DecidableEq (Multiset α)
| s₁, s₂ => Quotient.recOnSubsingleton₂ s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq
#align multiset.has_decidable_eq Multiset.decidableEq
protected
def sizeOf [SizeOf α] (s : Multiset α) : ℕ :=
(Quot.liftOn s SizeOf.sizeOf) fun _ _ => Perm.sizeOf_eq_sizeOf
#align multiset.sizeof Multiset.sizeOf
instance [SizeOf α] : SizeOf (Multiset α) :=
⟨Multiset.sizeOf⟩
protected def zero : Multiset α :=
@nil α
#align multiset.zero Multiset.zero
instance : Zero (Multiset α) :=
⟨Multiset.zero⟩
instance : EmptyCollection (Multiset α) :=
⟨0⟩
instance inhabitedMultiset : Inhabited (Multiset α) :=
⟨0⟩
#align multiset.inhabited_multiset Multiset.inhabitedMultiset
instance [IsEmpty α] : Unique (Multiset α) where
default := 0
uniq := by rintro ⟨_ | ⟨a, l⟩⟩; exacts [rfl, isEmptyElim a]
@[simp]
theorem coe_nil : (@nil α : Multiset α) = 0 :=
rfl
#align multiset.coe_nil Multiset.coe_nil
@[simp]
theorem empty_eq_zero : (∅ : Multiset α) = 0 :=
rfl
#align multiset.empty_eq_zero Multiset.empty_eq_zero
@[simp]
theorem coe_eq_zero (l : List α) : (l : Multiset α) = 0 ↔ l = [] :=
Iff.trans coe_eq_coe perm_nil
#align multiset.coe_eq_zero Multiset.coe_eq_zero
theorem coe_eq_zero_iff_isEmpty (l : List α) : (l : Multiset α) = 0 ↔ l.isEmpty :=
Iff.trans (coe_eq_zero l) isEmpty_iff_eq_nil.symm
#align multiset.coe_eq_zero_iff_empty Multiset.coe_eq_zero_iff_isEmpty
def cons (a : α) (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (a :: l : Multiset α)) fun _ _ p => Quot.sound (p.cons a)
#align multiset.cons Multiset.cons
@[inherit_doc Multiset.cons]
infixr:67 " ::ₘ " => Multiset.cons
instance : Insert α (Multiset α) :=
⟨cons⟩
@[simp]
theorem insert_eq_cons (a : α) (s : Multiset α) : insert a s = a ::ₘ s :=
rfl
#align multiset.insert_eq_cons Multiset.insert_eq_cons
@[simp]
theorem cons_coe (a : α) (l : List α) : (a ::ₘ l : Multiset α) = (a :: l : List α) :=
rfl
#align multiset.cons_coe Multiset.cons_coe
@[simp]
theorem cons_inj_left {a b : α} (s : Multiset α) : a ::ₘ s = b ::ₘ s ↔ a = b :=
⟨Quot.inductionOn s fun l e =>
have : [a] ++ l ~ [b] ++ l := Quotient.exact e
singleton_perm_singleton.1 <| (perm_append_right_iff _).1 this,
congr_arg (· ::ₘ _)⟩
#align multiset.cons_inj_left Multiset.cons_inj_left
@[simp]
theorem cons_inj_right (a : α) : ∀ {s t : Multiset α}, a ::ₘ s = a ::ₘ t ↔ s = t := by
rintro ⟨l₁⟩ ⟨l₂⟩; simp
#align multiset.cons_inj_right Multiset.cons_inj_right
@[elab_as_elim]
protected theorem induction {p : Multiset α → Prop} (empty : p 0)
(cons : ∀ (a : α) (s : Multiset α), p s → p (a ::ₘ s)) : ∀ s, p s := by
rintro ⟨l⟩; induction' l with _ _ ih <;> [exact empty; exact cons _ _ ih]
#align multiset.induction Multiset.induction
@[elab_as_elim]
protected theorem induction_on {p : Multiset α → Prop} (s : Multiset α) (empty : p 0)
(cons : ∀ (a : α) (s : Multiset α), p s → p (a ::ₘ s)) : p s :=
Multiset.induction empty cons s
#align multiset.induction_on Multiset.induction_on
theorem cons_swap (a b : α) (s : Multiset α) : a ::ₘ b ::ₘ s = b ::ₘ a ::ₘ s :=
Quot.inductionOn s fun _ => Quotient.sound <| Perm.swap _ _ _
#align multiset.cons_swap Multiset.cons_swap
instance : Singleton α (Multiset α) :=
⟨fun a => a ::ₘ 0⟩
instance : LawfulSingleton α (Multiset α) :=
⟨fun _ => rfl⟩
@[simp]
theorem cons_zero (a : α) : a ::ₘ 0 = {a} :=
rfl
#align multiset.cons_zero Multiset.cons_zero
@[simp, norm_cast]
theorem coe_singleton (a : α) : ([a] : Multiset α) = {a} :=
rfl
#align multiset.coe_singleton Multiset.coe_singleton
@[simp]
theorem mem_singleton {a b : α} : b ∈ ({a} : Multiset α) ↔ b = a := by
simp only [← cons_zero, mem_cons, iff_self_iff, or_false_iff, not_mem_zero]
#align multiset.mem_singleton Multiset.mem_singleton
theorem mem_singleton_self (a : α) : a ∈ ({a} : Multiset α) := by
rw [← cons_zero]
exact mem_cons_self _ _
#align multiset.mem_singleton_self Multiset.mem_singleton_self
@[simp]
theorem singleton_inj {a b : α} : ({a} : Multiset α) = {b} ↔ a = b := by
simp_rw [← cons_zero]
exact cons_inj_left _
#align multiset.singleton_inj Multiset.singleton_inj
@[simp, norm_cast]
theorem coe_eq_singleton {l : List α} {a : α} : (l : Multiset α) = {a} ↔ l = [a] := by
rw [← coe_singleton, coe_eq_coe, List.perm_singleton]
#align multiset.coe_eq_singleton Multiset.coe_eq_singleton
@[simp]
theorem singleton_eq_cons_iff {a b : α} (m : Multiset α) : {a} = b ::ₘ m ↔ a = b ∧ m = 0 := by
rw [← cons_zero, cons_eq_cons]
simp [eq_comm]
#align multiset.singleton_eq_cons_iff Multiset.singleton_eq_cons_iff
theorem pair_comm (x y : α) : ({x, y} : Multiset α) = {y, x} :=
cons_swap x y 0
#align multiset.pair_comm Multiset.pair_comm
protected def Le (s t : Multiset α) : Prop :=
(Quotient.liftOn₂ s t (· <+~ ·)) fun _ _ _ _ p₁ p₂ =>
propext (p₂.subperm_left.trans p₁.subperm_right)
#align multiset.le Multiset.Le
instance : PartialOrder (Multiset α) where
le := Multiset.Le
le_refl := by rintro ⟨l⟩; exact Subperm.refl _
le_trans := by rintro ⟨l₁⟩ ⟨l₂⟩ ⟨l₃⟩; exact @Subperm.trans _ _ _ _
le_antisymm := by rintro ⟨l₁⟩ ⟨l₂⟩ h₁ h₂; exact Quot.sound (Subperm.antisymm h₁ h₂)
instance decidableLE [DecidableEq α] : DecidableRel ((· ≤ ·) : Multiset α → Multiset α → Prop) :=
fun s t => Quotient.recOnSubsingleton₂ s t List.decidableSubperm
#align multiset.decidable_le Multiset.decidableLE
section
variable {s t : Multiset α} {a : α}
theorem subset_of_le : s ≤ t → s ⊆ t :=
Quotient.inductionOn₂ s t fun _ _ => Subperm.subset
#align multiset.subset_of_le Multiset.subset_of_le
alias Le.subset := subset_of_le
#align multiset.le.subset Multiset.Le.subset
theorem mem_of_le (h : s ≤ t) : a ∈ s → a ∈ t :=
mem_of_subset (subset_of_le h)
#align multiset.mem_of_le Multiset.mem_of_le
theorem not_mem_mono (h : s ⊆ t) : a ∉ t → a ∉ s :=
mt <| @h _
#align multiset.not_mem_mono Multiset.not_mem_mono
@[simp]
theorem coe_le {l₁ l₂ : List α} : (l₁ : Multiset α) ≤ l₂ ↔ l₁ <+~ l₂ :=
Iff.rfl
#align multiset.coe_le Multiset.coe_le
@[elab_as_elim]
theorem leInductionOn {C : Multiset α → Multiset α → Prop} {s t : Multiset α} (h : s ≤ t)
(H : ∀ {l₁ l₂ : List α}, l₁ <+ l₂ → C l₁ l₂) : C s t :=
Quotient.inductionOn₂ s t (fun l₁ _ ⟨l, p, s⟩ => (show ⟦l⟧ = ⟦l₁⟧ from Quot.sound p) ▸ H s) h
#align multiset.le_induction_on Multiset.leInductionOn
theorem zero_le (s : Multiset α) : 0 ≤ s :=
Quot.inductionOn s fun l => (nil_sublist l).subperm
#align multiset.zero_le Multiset.zero_le
instance : OrderBot (Multiset α) where
bot := 0
bot_le := zero_le
@[simp]
theorem bot_eq_zero : (⊥ : Multiset α) = 0 :=
rfl
#align multiset.bot_eq_zero Multiset.bot_eq_zero
theorem le_zero : s ≤ 0 ↔ s = 0 :=
le_bot_iff
#align multiset.le_zero Multiset.le_zero
theorem lt_cons_self (s : Multiset α) (a : α) : s < a ::ₘ s :=
Quot.inductionOn s fun l =>
suffices l <+~ a :: l ∧ ¬l ~ a :: l by simpa [lt_iff_le_and_ne]
⟨(sublist_cons _ _).subperm, fun p => _root_.ne_of_lt (lt_succ_self (length l)) p.length_eq⟩
#align multiset.lt_cons_self Multiset.lt_cons_self
theorem le_cons_self (s : Multiset α) (a : α) : s ≤ a ::ₘ s :=
le_of_lt <| lt_cons_self _ _
#align multiset.le_cons_self Multiset.le_cons_self
theorem cons_le_cons_iff (a : α) : a ::ₘ s ≤ a ::ₘ t ↔ s ≤ t :=
Quotient.inductionOn₂ s t fun _ _ => subperm_cons a
#align multiset.cons_le_cons_iff Multiset.cons_le_cons_iff
theorem cons_le_cons (a : α) : s ≤ t → a ::ₘ s ≤ a ::ₘ t :=
(cons_le_cons_iff a).2
#align multiset.cons_le_cons Multiset.cons_le_cons
@[simp] lemma cons_lt_cons_iff : a ::ₘ s < a ::ₘ t ↔ s < t :=
lt_iff_lt_of_le_iff_le' (cons_le_cons_iff _) (cons_le_cons_iff _)
lemma cons_lt_cons (a : α) (h : s < t) : a ::ₘ s < a ::ₘ t := cons_lt_cons_iff.2 h
theorem le_cons_of_not_mem (m : a ∉ s) : s ≤ a ::ₘ t ↔ s ≤ t := by
refine ⟨?_, fun h => le_trans h <| le_cons_self _ _⟩
suffices ∀ {t'}, s ≤ t' → a ∈ t' → a ::ₘ s ≤ t' by
exact fun h => (cons_le_cons_iff a).1 (this h (mem_cons_self _ _))
introv h
revert m
refine leInductionOn h ?_
introv s m₁ m₂
rcases append_of_mem m₂ with ⟨r₁, r₂, rfl⟩
exact
perm_middle.subperm_left.2
((subperm_cons _).2 <| ((sublist_or_mem_of_sublist s).resolve_right m₁).subperm)
#align multiset.le_cons_of_not_mem Multiset.le_cons_of_not_mem
@[simp]
theorem singleton_ne_zero (a : α) : ({a} : Multiset α) ≠ 0 :=
ne_of_gt (lt_cons_self _ _)
#align multiset.singleton_ne_zero Multiset.singleton_ne_zero
@[simp]
theorem singleton_le {a : α} {s : Multiset α} : {a} ≤ s ↔ a ∈ s :=
⟨fun h => mem_of_le h (mem_singleton_self _), fun h =>
let ⟨_t, e⟩ := exists_cons_of_mem h
e.symm ▸ cons_le_cons _ (zero_le _)⟩
#align multiset.singleton_le Multiset.singleton_le
@[simp] lemma le_singleton : s ≤ {a} ↔ s = 0 ∨ s = {a} :=
Quot.induction_on s fun l ↦ by simp only [cons_zero, ← coe_singleton, quot_mk_to_coe'', coe_le,
coe_eq_zero, coe_eq_coe, perm_singleton, subperm_singleton_iff]
@[simp] lemma lt_singleton : s < {a} ↔ s = 0 := by
simp only [lt_iff_le_and_ne, le_singleton, or_and_right, Ne, and_not_self, or_false,
and_iff_left_iff_imp]
rintro rfl
exact (singleton_ne_zero _).symm
@[simp] lemma ssubset_singleton_iff : s ⊂ {a} ↔ s = 0 := by
refine ⟨fun hs ↦ eq_zero_of_subset_zero fun b hb ↦ (hs.2 ?_).elim, ?_⟩
· obtain rfl := mem_singleton.1 (hs.1 hb)
rwa [singleton_subset]
· rintro rfl
simp
end
protected def add (s₁ s₂ : Multiset α) : Multiset α :=
(Quotient.liftOn₂ s₁ s₂ fun l₁ l₂ => ((l₁ ++ l₂ : List α) : Multiset α)) fun _ _ _ _ p₁ p₂ =>
Quot.sound <| p₁.append p₂
#align multiset.add Multiset.add
instance : Add (Multiset α) :=
⟨Multiset.add⟩
@[simp]
theorem coe_add (s t : List α) : (s + t : Multiset α) = (s ++ t : List α) :=
rfl
#align multiset.coe_add Multiset.coe_add
@[simp]
theorem singleton_add (a : α) (s : Multiset α) : {a} + s = a ::ₘ s :=
rfl
#align multiset.singleton_add Multiset.singleton_add
private theorem add_le_add_iff_left' {s t u : Multiset α} : s + t ≤ s + u ↔ t ≤ u :=
Quotient.inductionOn₃ s t u fun _ _ _ => subperm_append_left _
instance : CovariantClass (Multiset α) (Multiset α) (· + ·) (· ≤ ·) :=
⟨fun _s _t _u => add_le_add_iff_left'.2⟩
instance : ContravariantClass (Multiset α) (Multiset α) (· + ·) (· ≤ ·) :=
⟨fun _s _t _u => add_le_add_iff_left'.1⟩
instance : OrderedCancelAddCommMonoid (Multiset α) where
zero := 0
add := (· + ·)
add_comm := fun s t => Quotient.inductionOn₂ s t fun l₁ l₂ => Quot.sound perm_append_comm
add_assoc := fun s₁ s₂ s₃ =>
Quotient.inductionOn₃ s₁ s₂ s₃ fun l₁ l₂ l₃ => congr_arg _ <| append_assoc l₁ l₂ l₃
zero_add := fun s => Quot.inductionOn s fun l => rfl
add_zero := fun s => Quotient.inductionOn s fun l => congr_arg _ <| append_nil l
add_le_add_left := fun s₁ s₂ => add_le_add_left
le_of_add_le_add_left := fun s₁ s₂ s₃ => le_of_add_le_add_left
nsmul := nsmulRec
theorem le_add_right (s t : Multiset α) : s ≤ s + t := by simpa using add_le_add_left (zero_le t) s
#align multiset.le_add_right Multiset.le_add_right
theorem le_add_left (s t : Multiset α) : s ≤ t + s := by simpa using add_le_add_right (zero_le t) s
#align multiset.le_add_left Multiset.le_add_left
theorem le_iff_exists_add {s t : Multiset α} : s ≤ t ↔ ∃ u, t = s + u :=
⟨fun h =>
leInductionOn h fun s =>
let ⟨l, p⟩ := s.exists_perm_append
⟨l, Quot.sound p⟩,
fun ⟨_u, e⟩ => e.symm ▸ le_add_right _ _⟩
#align multiset.le_iff_exists_add Multiset.le_iff_exists_add
instance : CanonicallyOrderedAddCommMonoid (Multiset α) where
__ := inferInstanceAs (OrderBot (Multiset α))
le_self_add := le_add_right
exists_add_of_le h := leInductionOn h fun s =>
let ⟨l, p⟩ := s.exists_perm_append
⟨l, Quot.sound p⟩
@[simp]
theorem cons_add (a : α) (s t : Multiset α) : a ::ₘ s + t = a ::ₘ (s + t) := by
rw [← singleton_add, ← singleton_add, add_assoc]
#align multiset.cons_add Multiset.cons_add
@[simp]
theorem add_cons (a : α) (s t : Multiset α) : s + a ::ₘ t = a ::ₘ (s + t) := by
rw [add_comm, cons_add, add_comm]
#align multiset.add_cons Multiset.add_cons
@[simp]
theorem mem_add {a : α} {s t : Multiset α} : a ∈ s + t ↔ a ∈ s ∨ a ∈ t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => mem_append
#align multiset.mem_add Multiset.mem_add
theorem mem_of_mem_nsmul {a : α} {s : Multiset α} {n : ℕ} (h : a ∈ n • s) : a ∈ s := by
induction' n with n ih
· rw [zero_nsmul] at h
exact absurd h (not_mem_zero _)
· rw [succ_nsmul, mem_add] at h
exact h.elim ih id
#align multiset.mem_of_mem_nsmul Multiset.mem_of_mem_nsmul
@[simp]
theorem mem_nsmul {a : α} {s : Multiset α} {n : ℕ} (h0 : n ≠ 0) : a ∈ n • s ↔ a ∈ s := by
refine ⟨mem_of_mem_nsmul, fun h => ?_⟩
obtain ⟨n, rfl⟩ := exists_eq_succ_of_ne_zero h0
rw [succ_nsmul, mem_add]
exact Or.inr h
#align multiset.mem_nsmul Multiset.mem_nsmul
theorem nsmul_cons {s : Multiset α} (n : ℕ) (a : α) :
n • (a ::ₘ s) = n • ({a} : Multiset α) + n • s := by
rw [← singleton_add, nsmul_add]
#align multiset.nsmul_cons Multiset.nsmul_cons
def card : Multiset α →+ ℕ where
toFun s := (Quot.liftOn s length) fun _l₁ _l₂ => Perm.length_eq
map_zero' := rfl
map_add' s t := Quotient.inductionOn₂ s t length_append
#align multiset.card Multiset.card
@[simp]
theorem coe_card (l : List α) : card (l : Multiset α) = length l :=
rfl
#align multiset.coe_card Multiset.coe_card
@[simp]
theorem length_toList (s : Multiset α) : s.toList.length = card s := by
rw [← coe_card, coe_toList]
#align multiset.length_to_list Multiset.length_toList
@[simp, nolint simpNF] -- Porting note (#10675): `dsimp` can not prove this, yet linter complains
theorem card_zero : @card α 0 = 0 :=
rfl
#align multiset.card_zero Multiset.card_zero
theorem card_add (s t : Multiset α) : card (s + t) = card s + card t :=
card.map_add s t
#align multiset.card_add Multiset.card_add
theorem card_nsmul (s : Multiset α) (n : ℕ) : card (n • s) = n * card s := by
rw [card.map_nsmul s n, Nat.nsmul_eq_mul]
#align multiset.card_nsmul Multiset.card_nsmul
@[simp]
theorem card_cons (a : α) (s : Multiset α) : card (a ::ₘ s) = card s + 1 :=
Quot.inductionOn s fun _l => rfl
#align multiset.card_cons Multiset.card_cons
@[simp]
theorem card_singleton (a : α) : card ({a} : Multiset α) = 1 := by
simp only [← cons_zero, card_zero, eq_self_iff_true, zero_add, card_cons]
#align multiset.card_singleton Multiset.card_singleton
theorem card_pair (a b : α) : card {a, b} = 2 := by
rw [insert_eq_cons, card_cons, card_singleton]
#align multiset.card_pair Multiset.card_pair
theorem card_eq_one {s : Multiset α} : card s = 1 ↔ ∃ a, s = {a} :=
⟨Quot.inductionOn s fun _l h => (List.length_eq_one.1 h).imp fun _a => congr_arg _,
fun ⟨_a, e⟩ => e.symm ▸ rfl⟩
#align multiset.card_eq_one Multiset.card_eq_one
theorem card_le_card {s t : Multiset α} (h : s ≤ t) : card s ≤ card t :=
leInductionOn h Sublist.length_le
#align multiset.card_le_of_le Multiset.card_le_card
@[mono]
theorem card_mono : Monotone (@card α) := fun _a _b => card_le_card
#align multiset.card_mono Multiset.card_mono
theorem eq_of_le_of_card_le {s t : Multiset α} (h : s ≤ t) : card t ≤ card s → s = t :=
leInductionOn h fun s h₂ => congr_arg _ <| s.eq_of_length_le h₂
#align multiset.eq_of_le_of_card_le Multiset.eq_of_le_of_card_le
theorem card_lt_card {s t : Multiset α} (h : s < t) : card s < card t :=
lt_of_not_ge fun h₂ => _root_.ne_of_lt h <| eq_of_le_of_card_le (le_of_lt h) h₂
#align multiset.card_lt_card Multiset.card_lt_card
lemma card_strictMono : StrictMono (card : Multiset α → ℕ) := fun _ _ ↦ card_lt_card
theorem lt_iff_cons_le {s t : Multiset α} : s < t ↔ ∃ a, a ::ₘ s ≤ t :=
⟨Quotient.inductionOn₂ s t fun _l₁ _l₂ h =>
Subperm.exists_of_length_lt (le_of_lt h) (card_lt_card h),
fun ⟨_a, h⟩ => lt_of_lt_of_le (lt_cons_self _ _) h⟩
#align multiset.lt_iff_cons_le Multiset.lt_iff_cons_le
@[simp]
theorem card_eq_zero {s : Multiset α} : card s = 0 ↔ s = 0 :=
⟨fun h => (eq_of_le_of_card_le (zero_le _) (le_of_eq h)).symm, fun e => by simp [e]⟩
#align multiset.card_eq_zero Multiset.card_eq_zero
theorem card_pos {s : Multiset α} : 0 < card s ↔ s ≠ 0 :=
Nat.pos_iff_ne_zero.trans <| not_congr card_eq_zero
#align multiset.card_pos Multiset.card_pos
theorem card_pos_iff_exists_mem {s : Multiset α} : 0 < card s ↔ ∃ a, a ∈ s :=
Quot.inductionOn s fun _l => length_pos_iff_exists_mem
#align multiset.card_pos_iff_exists_mem Multiset.card_pos_iff_exists_mem
theorem card_eq_two {s : Multiset α} : card s = 2 ↔ ∃ x y, s = {x, y} :=
⟨Quot.inductionOn s fun _l h =>
(List.length_eq_two.mp h).imp fun _a => Exists.imp fun _b => congr_arg _,
fun ⟨_a, _b, e⟩ => e.symm ▸ rfl⟩
#align multiset.card_eq_two Multiset.card_eq_two
theorem card_eq_three {s : Multiset α} : card s = 3 ↔ ∃ x y z, s = {x, y, z} :=
⟨Quot.inductionOn s fun _l h =>
(List.length_eq_three.mp h).imp fun _a =>
Exists.imp fun _b => Exists.imp fun _c => congr_arg _,
fun ⟨_a, _b, _c, e⟩ => e.symm ▸ rfl⟩
#align multiset.card_eq_three Multiset.card_eq_three
@[elab_as_elim]
def strongInductionOn {p : Multiset α → Sort*} (s : Multiset α) (ih : ∀ s, (∀ t < s, p t) → p s) :
p s :=
(ih s) fun t _h =>
strongInductionOn t ih
termination_by card s
decreasing_by exact card_lt_card _h
#align multiset.strong_induction_on Multiset.strongInductionOnₓ -- Porting note: reorderd universes
theorem strongInductionOn_eq {p : Multiset α → Sort*} (s : Multiset α) (H) :
@strongInductionOn _ p s H = H s fun t _h => @strongInductionOn _ p t H := by
rw [strongInductionOn]
#align multiset.strong_induction_eq Multiset.strongInductionOn_eq
@[elab_as_elim]
theorem case_strongInductionOn {p : Multiset α → Prop} (s : Multiset α) (h₀ : p 0)
(h₁ : ∀ a s, (∀ t ≤ s, p t) → p (a ::ₘ s)) : p s :=
Multiset.strongInductionOn s fun s =>
Multiset.induction_on s (fun _ => h₀) fun _a _s _ ih =>
(h₁ _ _) fun _t h => ih _ <| lt_of_le_of_lt h <| lt_cons_self _ _
#align multiset.case_strong_induction_on Multiset.case_strongInductionOn
def strongDownwardInduction {p : Multiset α → Sort*} {n : ℕ}
(H : ∀ t₁, (∀ {t₂ : Multiset α}, card t₂ ≤ n → t₁ < t₂ → p t₂) → card t₁ ≤ n → p t₁)
(s : Multiset α) :
card s ≤ n → p s :=
H s fun {t} ht _h =>
strongDownwardInduction H t ht
termination_by n - card s
decreasing_by simp_wf; have := (card_lt_card _h); omega
-- Porting note: reorderd universes
#align multiset.strong_downward_induction Multiset.strongDownwardInductionₓ
theorem strongDownwardInduction_eq {p : Multiset α → Sort*} {n : ℕ}
(H : ∀ t₁, (∀ {t₂ : Multiset α}, card t₂ ≤ n → t₁ < t₂ → p t₂) → card t₁ ≤ n → p t₁)
(s : Multiset α) :
strongDownwardInduction H s = H s fun ht _hst => strongDownwardInduction H _ ht := by
rw [strongDownwardInduction]
#align multiset.strong_downward_induction_eq Multiset.strongDownwardInduction_eq
@[elab_as_elim]
def strongDownwardInductionOn {p : Multiset α → Sort*} {n : ℕ} :
∀ s : Multiset α,
(∀ t₁, (∀ {t₂ : Multiset α}, card t₂ ≤ n → t₁ < t₂ → p t₂) → card t₁ ≤ n → p t₁) →
card s ≤ n → p s :=
fun s H => strongDownwardInduction H s
#align multiset.strong_downward_induction_on Multiset.strongDownwardInductionOn
theorem strongDownwardInductionOn_eq {p : Multiset α → Sort*} (s : Multiset α) {n : ℕ}
(H : ∀ t₁, (∀ {t₂ : Multiset α}, card t₂ ≤ n → t₁ < t₂ → p t₂) → card t₁ ≤ n → p t₁) :
s.strongDownwardInductionOn H = H s fun {t} ht _h => t.strongDownwardInductionOn H ht := by
dsimp only [strongDownwardInductionOn]
rw [strongDownwardInduction]
#align multiset.strong_downward_induction_on_eq Multiset.strongDownwardInductionOn_eq
#align multiset.well_founded_lt wellFounded_lt
instance instWellFoundedLT : WellFoundedLT (Multiset α) :=
⟨Subrelation.wf Multiset.card_lt_card (measure Multiset.card).2⟩
#align multiset.is_well_founded_lt Multiset.instWellFoundedLT
def replicate (n : ℕ) (a : α) : Multiset α :=
List.replicate n a
#align multiset.replicate Multiset.replicate
theorem coe_replicate (n : ℕ) (a : α) : (List.replicate n a : Multiset α) = replicate n a := rfl
#align multiset.coe_replicate Multiset.coe_replicate
@[simp] theorem replicate_zero (a : α) : replicate 0 a = 0 := rfl
#align multiset.replicate_zero Multiset.replicate_zero
@[simp] theorem replicate_succ (a : α) (n) : replicate (n + 1) a = a ::ₘ replicate n a := rfl
#align multiset.replicate_succ Multiset.replicate_succ
theorem replicate_add (m n : ℕ) (a : α) : replicate (m + n) a = replicate m a + replicate n a :=
congr_arg _ <| List.replicate_add ..
#align multiset.replicate_add Multiset.replicate_add
@[simps]
def replicateAddMonoidHom (a : α) : ℕ →+ Multiset α where
toFun := fun n => replicate n a
map_zero' := replicate_zero a
map_add' := fun _ _ => replicate_add _ _ a
#align multiset.replicate_add_monoid_hom Multiset.replicateAddMonoidHom
#align multiset.replicate_add_monoid_hom_apply Multiset.replicateAddMonoidHom_apply
theorem replicate_one (a : α) : replicate 1 a = {a} := rfl
#align multiset.replicate_one Multiset.replicate_one
@[simp] theorem card_replicate (n) (a : α) : card (replicate n a) = n :=
length_replicate n a
#align multiset.card_replicate Multiset.card_replicate
theorem mem_replicate {a b : α} {n : ℕ} : b ∈ replicate n a ↔ n ≠ 0 ∧ b = a :=
List.mem_replicate
#align multiset.mem_replicate Multiset.mem_replicate
theorem eq_of_mem_replicate {a b : α} {n} : b ∈ replicate n a → b = a :=
List.eq_of_mem_replicate
#align multiset.eq_of_mem_replicate Multiset.eq_of_mem_replicate
theorem eq_replicate_card {a : α} {s : Multiset α} : s = replicate (card s) a ↔ ∀ b ∈ s, b = a :=
Quot.inductionOn s fun _l => coe_eq_coe.trans <| perm_replicate.trans eq_replicate_length
#align multiset.eq_replicate_card Multiset.eq_replicate_card
alias ⟨_, eq_replicate_of_mem⟩ := eq_replicate_card
#align multiset.eq_replicate_of_mem Multiset.eq_replicate_of_mem
theorem eq_replicate {a : α} {n} {s : Multiset α} :
s = replicate n a ↔ card s = n ∧ ∀ b ∈ s, b = a :=
⟨fun h => h.symm ▸ ⟨card_replicate _ _, fun _b => eq_of_mem_replicate⟩,
fun ⟨e, al⟩ => e ▸ eq_replicate_of_mem al⟩
#align multiset.eq_replicate Multiset.eq_replicate
theorem replicate_right_injective {n : ℕ} (hn : n ≠ 0) : Injective (@replicate α n) :=
fun _ _ h => (eq_replicate.1 h).2 _ <| mem_replicate.2 ⟨hn, rfl⟩
#align multiset.replicate_right_injective Multiset.replicate_right_injective
@[simp] theorem replicate_right_inj {a b : α} {n : ℕ} (h : n ≠ 0) :
replicate n a = replicate n b ↔ a = b :=
(replicate_right_injective h).eq_iff
#align multiset.replicate_right_inj Multiset.replicate_right_inj
theorem replicate_left_injective (a : α) : Injective (replicate · a) :=
-- Porting note: was `fun m n h => by rw [← (eq_replicate.1 h).1, card_replicate]`
LeftInverse.injective (card_replicate · a)
#align multiset.replicate_left_injective Multiset.replicate_left_injective
theorem replicate_subset_singleton (n : ℕ) (a : α) : replicate n a ⊆ {a} :=
List.replicate_subset_singleton n a
#align multiset.replicate_subset_singleton Multiset.replicate_subset_singleton
theorem replicate_le_coe {a : α} {n} {l : List α} : replicate n a ≤ l ↔ List.replicate n a <+ l :=
⟨fun ⟨_l', p, s⟩ => perm_replicate.1 p ▸ s, Sublist.subperm⟩
#align multiset.replicate_le_coe Multiset.replicate_le_coe
theorem nsmul_replicate {a : α} (n m : ℕ) : n • replicate m a = replicate (n * m) a :=
((replicateAddMonoidHom a).map_nsmul _ _).symm
#align multiset.nsmul_replicate Multiset.nsmul_replicate
theorem nsmul_singleton (a : α) (n) : n • ({a} : Multiset α) = replicate n a := by
rw [← replicate_one, nsmul_replicate, mul_one]
#align multiset.nsmul_singleton Multiset.nsmul_singleton
theorem replicate_le_replicate (a : α) {k n : ℕ} : replicate k a ≤ replicate n a ↔ k ≤ n :=
_root_.trans (by rw [← replicate_le_coe, coe_replicate]) (List.replicate_sublist_replicate a)
#align multiset.replicate_le_replicate Multiset.replicate_le_replicate
theorem le_replicate_iff {m : Multiset α} {a : α} {n : ℕ} :
m ≤ replicate n a ↔ ∃ k ≤ n, m = replicate k a :=
⟨fun h => ⟨card m, (card_mono h).trans_eq (card_replicate _ _),
eq_replicate_card.2 fun _ hb => eq_of_mem_replicate <| subset_of_le h hb⟩,
fun ⟨_, hkn, hm⟩ => hm.symm ▸ (replicate_le_replicate _).2 hkn⟩
#align multiset.le_replicate_iff Multiset.le_replicate_iff
theorem lt_replicate_succ {m : Multiset α} {x : α} {n : ℕ} :
m < replicate (n + 1) x ↔ m ≤ replicate n x := by
rw [lt_iff_cons_le]
constructor
· rintro ⟨x', hx'⟩
have := eq_of_mem_replicate (mem_of_le hx' (mem_cons_self _ _))
rwa [this, replicate_succ, cons_le_cons_iff] at hx'
· intro h
rw [replicate_succ]
exact ⟨x, cons_le_cons _ h⟩
#align multiset.lt_replicate_succ Multiset.lt_replicate_succ
@[simp]
theorem coe_reverse (l : List α) : (reverse l : Multiset α) = l :=
Quot.sound <| reverse_perm _
#align multiset.coe_reverse Multiset.coe_reverse
def map (f : α → β) (s : Multiset α) : Multiset β :=
Quot.liftOn s (fun l : List α => (l.map f : Multiset β)) fun _l₁ _l₂ p => Quot.sound (p.map f)
#align multiset.map Multiset.map
@[congr]
theorem map_congr {f g : α → β} {s t : Multiset α} :
s = t → (∀ x ∈ t, f x = g x) → map f s = map g t := by
rintro rfl h
induction s using Quot.inductionOn
exact congr_arg _ (List.map_congr h)
#align multiset.map_congr Multiset.map_congr
theorem map_hcongr {β' : Type v} {m : Multiset α} {f : α → β} {f' : α → β'} (h : β = β')
(hf : ∀ a ∈ m, HEq (f a) (f' a)) : HEq (map f m) (map f' m) := by
subst h; simp at hf
simp [map_congr rfl hf]
#align multiset.map_hcongr Multiset.map_hcongr
theorem forall_mem_map_iff {f : α → β} {p : β → Prop} {s : Multiset α} :
(∀ y ∈ s.map f, p y) ↔ ∀ x ∈ s, p (f x) :=
Quotient.inductionOn' s fun _L => List.forall_mem_map_iff
#align multiset.forall_mem_map_iff Multiset.forall_mem_map_iff
@[simp, norm_cast] lemma map_coe (f : α → β) (l : List α) : map f l = l.map f := rfl
#align multiset.coe_map Multiset.map_coe
@[simp]
theorem map_zero (f : α → β) : map f 0 = 0 :=
rfl
#align multiset.map_zero Multiset.map_zero
@[simp]
theorem map_cons (f : α → β) (a s) : map f (a ::ₘ s) = f a ::ₘ map f s :=
Quot.inductionOn s fun _l => rfl
#align multiset.map_cons Multiset.map_cons
theorem map_comp_cons (f : α → β) (t) : map f ∘ cons t = cons (f t) ∘ map f := by
ext
simp
#align multiset.map_comp_cons Multiset.map_comp_cons
@[simp]
theorem map_singleton (f : α → β) (a : α) : ({a} : Multiset α).map f = {f a} :=
rfl
#align multiset.map_singleton Multiset.map_singleton
@[simp]
theorem map_replicate (f : α → β) (k : ℕ) (a : α) : (replicate k a).map f = replicate k (f a) := by
simp only [← coe_replicate, map_coe, List.map_replicate]
#align multiset.map_replicate Multiset.map_replicate
@[simp]
theorem map_add (f : α → β) (s t) : map f (s + t) = map f s + map f t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => congr_arg _ <| map_append _ _ _
#align multiset.map_add Multiset.map_add
instance canLift (c) (p) [CanLift α β c p] :
CanLift (Multiset α) (Multiset β) (map c) fun s => ∀ x ∈ s, p x where
prf := by
rintro ⟨l⟩ hl
lift l to List β using hl
exact ⟨l, map_coe _ _⟩
#align multiset.can_lift Multiset.canLift
def mapAddMonoidHom (f : α → β) : Multiset α →+ Multiset β where
toFun := map f
map_zero' := map_zero _
map_add' := map_add _
#align multiset.map_add_monoid_hom Multiset.mapAddMonoidHom
@[simp]
theorem coe_mapAddMonoidHom (f : α → β) :
(mapAddMonoidHom f : Multiset α → Multiset β) = map f :=
rfl
#align multiset.coe_map_add_monoid_hom Multiset.coe_mapAddMonoidHom
theorem map_nsmul (f : α → β) (n : ℕ) (s) : map f (n • s) = n • map f s :=
(mapAddMonoidHom f).map_nsmul _ _
#align multiset.map_nsmul Multiset.map_nsmul
@[simp]
theorem mem_map {f : α → β} {b : β} {s : Multiset α} : b ∈ map f s ↔ ∃ a, a ∈ s ∧ f a = b :=
Quot.inductionOn s fun _l => List.mem_map
#align multiset.mem_map Multiset.mem_map
@[simp]
theorem card_map (f : α → β) (s) : card (map f s) = card s :=
Quot.inductionOn s fun _l => length_map _ _
#align multiset.card_map Multiset.card_map
@[simp]
theorem map_eq_zero {s : Multiset α} {f : α → β} : s.map f = 0 ↔ s = 0 := by
rw [← Multiset.card_eq_zero, Multiset.card_map, Multiset.card_eq_zero]
#align multiset.map_eq_zero Multiset.map_eq_zero
theorem mem_map_of_mem (f : α → β) {a : α} {s : Multiset α} (h : a ∈ s) : f a ∈ map f s :=
mem_map.2 ⟨_, h, rfl⟩
#align multiset.mem_map_of_mem Multiset.mem_map_of_mem
theorem map_eq_singleton {f : α → β} {s : Multiset α} {b : β} :
map f s = {b} ↔ ∃ a : α, s = {a} ∧ f a = b := by
constructor
· intro h
obtain ⟨a, ha⟩ : ∃ a, s = {a} := by rw [← card_eq_one, ← card_map, h, card_singleton]
refine ⟨a, ha, ?_⟩
rw [← mem_singleton, ← h, ha, map_singleton, mem_singleton]
· rintro ⟨a, rfl, rfl⟩
simp
#align multiset.map_eq_singleton Multiset.map_eq_singleton
theorem map_eq_cons [DecidableEq α] (f : α → β) (s : Multiset α) (t : Multiset β) (b : β) :
(∃ a ∈ s, f a = b ∧ (s.erase a).map f = t) ↔ s.map f = b ::ₘ t := by
constructor
· rintro ⟨a, ha, rfl, rfl⟩
rw [← map_cons, Multiset.cons_erase ha]
· intro h
have : b ∈ s.map f := by
rw [h]
exact mem_cons_self _ _
obtain ⟨a, h1, rfl⟩ := mem_map.mp this
obtain ⟨u, rfl⟩ := exists_cons_of_mem h1
rw [map_cons, cons_inj_right] at h
refine ⟨a, mem_cons_self _ _, rfl, ?_⟩
rw [Multiset.erase_cons_head, h]
#align multiset.map_eq_cons Multiset.map_eq_cons
-- The simpNF linter says that the LHS can be simplified via `Multiset.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 : Function.Injective f) {a : α} {s : Multiset α} :
f a ∈ map f s ↔ a ∈ s :=
Quot.inductionOn s fun _l => List.mem_map_of_injective H
#align multiset.mem_map_of_injective Multiset.mem_map_of_injective
@[simp]
theorem map_map (g : β → γ) (f : α → β) (s : Multiset α) : map g (map f s) = map (g ∘ f) s :=
Quot.inductionOn s fun _l => congr_arg _ <| List.map_map _ _ _
#align multiset.map_map Multiset.map_map
theorem map_id (s : Multiset α) : map id s = s :=
Quot.inductionOn s fun _l => congr_arg _ <| List.map_id _
#align multiset.map_id Multiset.map_id
@[simp]
theorem map_id' (s : Multiset α) : map (fun x => x) s = s :=
map_id s
#align multiset.map_id' Multiset.map_id'
-- Porting note: was a `simp` lemma in mathlib3
theorem map_const (s : Multiset α) (b : β) : map (const α b) s = replicate (card s) b :=
Quot.inductionOn s fun _ => congr_arg _ <| List.map_const' _ _
#align multiset.map_const Multiset.map_const
-- Porting note: was not a `simp` lemma in mathlib3 because `Function.const` was reducible
@[simp] theorem map_const' (s : Multiset α) (b : β) : map (fun _ ↦ b) s = replicate (card s) b :=
map_const _ _
#align multiset.map_const' Multiset.map_const'
theorem eq_of_mem_map_const {b₁ b₂ : β} {l : List α} (h : b₁ ∈ map (Function.const α b₂) l) :
b₁ = b₂ :=
eq_of_mem_replicate <| by rwa [map_const] at h
#align multiset.eq_of_mem_map_const Multiset.eq_of_mem_map_const
@[simp]
theorem map_le_map {f : α → β} {s t : Multiset α} (h : s ≤ t) : map f s ≤ map f t :=
leInductionOn h fun h => (h.map f).subperm
#align multiset.map_le_map Multiset.map_le_map
@[simp]
theorem map_lt_map {f : α → β} {s t : Multiset α} (h : s < t) : s.map f < t.map f := by
refine (map_le_map h.le).lt_of_not_le fun H => h.ne <| eq_of_le_of_card_le h.le ?_
rw [← s.card_map f, ← t.card_map f]
exact card_le_card H
#align multiset.map_lt_map Multiset.map_lt_map
theorem map_mono (f : α → β) : Monotone (map f) := fun _ _ => map_le_map
#align multiset.map_mono Multiset.map_mono
theorem map_strictMono (f : α → β) : StrictMono (map f) := fun _ _ => map_lt_map
#align multiset.map_strict_mono Multiset.map_strictMono
@[simp]
theorem map_subset_map {f : α → β} {s t : Multiset α} (H : s ⊆ t) : map f s ⊆ map f t := fun _b m =>
let ⟨a, h, e⟩ := mem_map.1 m
mem_map.2 ⟨a, H h, e⟩
#align multiset.map_subset_map Multiset.map_subset_map
theorem map_erase [DecidableEq α] [DecidableEq β] (f : α → β) (hf : Function.Injective f) (x : α)
(s : Multiset α) : (s.erase x).map f = (s.map f).erase (f x) := by
induction' s using Multiset.induction_on with y s ih
· simp
by_cases hxy : y = x
· cases hxy
simp
· rw [s.erase_cons_tail hxy, map_cons, map_cons, (s.map f).erase_cons_tail (hf.ne hxy), ih]
#align multiset.map_erase Multiset.map_erase
theorem map_erase_of_mem [DecidableEq α] [DecidableEq β] (f : α → β)
(s : Multiset α) {x : α} (h : x ∈ s) : (s.erase x).map f = (s.map f).erase (f x) := by
induction' s using Multiset.induction_on with y s ih
· simp
rcases eq_or_ne y x with rfl | hxy
· simp
replace h : x ∈ s := by simpa [hxy.symm] using h
rw [s.erase_cons_tail hxy, map_cons, map_cons, ih h, erase_cons_tail_of_mem (mem_map_of_mem f h)]
theorem map_surjective_of_surjective {f : α → β} (hf : Function.Surjective f) :
Function.Surjective (map f) := by
intro s
induction' s using Multiset.induction_on with x s ih
· exact ⟨0, map_zero _⟩
· obtain ⟨y, rfl⟩ := hf x
obtain ⟨t, rfl⟩ := ih
exact ⟨y ::ₘ t, map_cons _ _ _⟩
#align multiset.map_surjective_of_surjective Multiset.map_surjective_of_surjective
def foldl (f : β → α → β) (H : RightCommutative f) (b : β) (s : Multiset α) : β :=
Quot.liftOn s (fun l => List.foldl f b l) fun _l₁ _l₂ p => p.foldl_eq H b
#align multiset.foldl Multiset.foldl
@[simp]
theorem foldl_zero (f : β → α → β) (H b) : foldl f H b 0 = b :=
rfl
#align multiset.foldl_zero Multiset.foldl_zero
@[simp]
theorem foldl_cons (f : β → α → β) (H b a s) : foldl f H b (a ::ₘ s) = foldl f H (f b a) s :=
Quot.inductionOn s fun _l => rfl
#align multiset.foldl_cons Multiset.foldl_cons
@[simp]
theorem foldl_add (f : β → α → β) (H b s t) : foldl f H b (s + t) = foldl f H (foldl f H b s) t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => foldl_append _ _ _ _
#align multiset.foldl_add Multiset.foldl_add
def foldr (f : α → β → β) (H : LeftCommutative f) (b : β) (s : Multiset α) : β :=
Quot.liftOn s (fun l => List.foldr f b l) fun _l₁ _l₂ p => p.foldr_eq H b
#align multiset.foldr Multiset.foldr
@[simp]
theorem foldr_zero (f : α → β → β) (H b) : foldr f H b 0 = b :=
rfl
#align multiset.foldr_zero Multiset.foldr_zero
@[simp]
theorem foldr_cons (f : α → β → β) (H b a s) : foldr f H b (a ::ₘ s) = f a (foldr f H b s) :=
Quot.inductionOn s fun _l => rfl
#align multiset.foldr_cons Multiset.foldr_cons
@[simp]
theorem foldr_singleton (f : α → β → β) (H b a) : foldr f H b ({a} : Multiset α) = f a b :=
rfl
#align multiset.foldr_singleton Multiset.foldr_singleton
@[simp]
theorem foldr_add (f : α → β → β) (H b s t) : foldr f H b (s + t) = foldr f H (foldr f H b t) s :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => foldr_append _ _ _ _
#align multiset.foldr_add Multiset.foldr_add
@[simp]
theorem coe_foldr (f : α → β → β) (H : LeftCommutative f) (b : β) (l : List α) :
foldr f H b l = l.foldr f b :=
rfl
#align multiset.coe_foldr Multiset.coe_foldr
@[simp]
theorem coe_foldl (f : β → α → β) (H : RightCommutative f) (b : β) (l : List α) :
foldl f H b l = l.foldl f b :=
rfl
#align multiset.coe_foldl Multiset.coe_foldl
theorem coe_foldr_swap (f : α → β → β) (H : LeftCommutative f) (b : β) (l : List α) :
foldr f H b l = l.foldl (fun x y => f y x) b :=
(congr_arg (foldr f H b) (coe_reverse l)).symm.trans <| foldr_reverse _ _ _
#align multiset.coe_foldr_swap Multiset.coe_foldr_swap
theorem foldr_swap (f : α → β → β) (H : LeftCommutative f) (b : β) (s : Multiset α) :
foldr f H b s = foldl (fun x y => f y x) (fun _x _y _z => (H _ _ _).symm) b s :=
Quot.inductionOn s fun _l => coe_foldr_swap _ _ _ _
#align multiset.foldr_swap Multiset.foldr_swap
theorem foldl_swap (f : β → α → β) (H : RightCommutative f) (b : β) (s : Multiset α) :
foldl f H b s = foldr (fun x y => f y x) (fun _x _y _z => (H _ _ _).symm) b s :=
(foldr_swap _ _ _ _).symm
#align multiset.foldl_swap Multiset.foldl_swap
theorem foldr_induction' (f : α → β → β) (H : LeftCommutative f) (x : β) (q : α → Prop)
(p : β → Prop) (s : Multiset α) (hpqf : ∀ a b, q a → p b → p (f a b)) (px : p x)
(q_s : ∀ a ∈ s, q a) : p (foldr f H x s) := by
induction s using Multiset.induction with
| empty => simpa
| cons a s ihs =>
simp only [forall_mem_cons, foldr_cons] at q_s ⊢
exact hpqf _ _ q_s.1 (ihs q_s.2)
#align multiset.foldr_induction' Multiset.foldr_induction'
theorem foldr_induction (f : α → α → α) (H : LeftCommutative f) (x : α) (p : α → Prop)
(s : Multiset α) (p_f : ∀ a b, p a → p b → p (f a b)) (px : p x) (p_s : ∀ a ∈ s, p a) :
p (foldr f H x s) :=
foldr_induction' f H x p p s p_f px p_s
#align multiset.foldr_induction Multiset.foldr_induction
theorem foldl_induction' (f : β → α → β) (H : RightCommutative f) (x : β) (q : α → Prop)
(p : β → Prop) (s : Multiset α) (hpqf : ∀ a b, q a → p b → p (f b a)) (px : p x)
(q_s : ∀ a ∈ s, q a) : p (foldl f H x s) := by
rw [foldl_swap]
exact foldr_induction' (fun x y => f y x) (fun x y z => (H _ _ _).symm) x q p s hpqf px q_s
#align multiset.foldl_induction' Multiset.foldl_induction'
theorem foldl_induction (f : α → α → α) (H : RightCommutative f) (x : α) (p : α → Prop)
(s : Multiset α) (p_f : ∀ a b, p a → p b → p (f b a)) (px : p x) (p_s : ∀ a ∈ s, p a) :
p (foldl f H x s) :=
foldl_induction' f H x p p s p_f px p_s
#align multiset.foldl_induction Multiset.foldl_induction
nonrec def pmap {p : α → Prop} (f : ∀ a, p a → β) (s : Multiset α) : (∀ a ∈ s, p a) → Multiset β :=
Quot.recOn' s (fun l H => ↑(pmap f l H)) fun l₁ l₂ (pp : l₁ ~ l₂) =>
funext fun H₂ : ∀ a ∈ l₂, p a =>
have H₁ : ∀ a ∈ l₁, p a := fun a h => H₂ a (pp.subset h)
have : ∀ {s₂ e H}, @Eq.ndrec (Multiset α) l₁ (fun s => (∀ a ∈ s, p a) → Multiset β)
(fun _ => ↑(pmap f l₁ H₁)) s₂ e H = ↑(pmap f l₁ H₁) := by
intro s₂ e _; subst e; rfl
this.trans <| Quot.sound <| pp.pmap f
#align multiset.pmap Multiset.pmap
@[simp]
theorem coe_pmap {p : α → Prop} (f : ∀ a, p a → β) (l : List α) (H : ∀ a ∈ l, p a) :
pmap f l H = l.pmap f H :=
rfl
#align multiset.coe_pmap Multiset.coe_pmap
@[simp]
theorem pmap_zero {p : α → Prop} (f : ∀ a, p a → β) (h : ∀ a ∈ (0 : Multiset α), p a) :
pmap f 0 h = 0 :=
rfl
#align multiset.pmap_zero Multiset.pmap_zero
@[simp]
theorem pmap_cons {p : α → Prop} (f : ∀ a, p a → β) (a : α) (m : Multiset α) :
∀ h : ∀ b ∈ a ::ₘ m, p b,
pmap f (a ::ₘ m) h =
f a (h a (mem_cons_self a m)) ::ₘ pmap f m fun a ha => h a <| mem_cons_of_mem ha :=
Quotient.inductionOn m fun _l _h => rfl
#align multiset.pmap_cons Multiset.pmap_cons
def attach (s : Multiset α) : Multiset { x // x ∈ s } :=
pmap Subtype.mk s fun _a => id
#align multiset.attach Multiset.attach
@[simp]
theorem coe_attach (l : List α) : @Eq (Multiset { x // x ∈ l }) (@attach α l) l.attach :=
rfl
#align multiset.coe_attach Multiset.coe_attach
theorem sizeOf_lt_sizeOf_of_mem [SizeOf α] {x : α} {s : Multiset α} (hx : x ∈ s) :
SizeOf.sizeOf x < SizeOf.sizeOf s := by
induction' s using Quot.inductionOn with l a b
exact List.sizeOf_lt_sizeOf_of_mem hx
#align multiset.sizeof_lt_sizeof_of_mem Multiset.sizeOf_lt_sizeOf_of_mem
theorem pmap_eq_map (p : α → Prop) (f : α → β) (s : Multiset α) :
∀ H, @pmap _ _ p (fun a _ => f a) s H = map f s :=
Quot.inductionOn s fun l H => congr_arg _ <| List.pmap_eq_map p f l H
#align multiset.pmap_eq_map Multiset.pmap_eq_map
theorem pmap_congr {p q : α → Prop} {f : ∀ a, p a → β} {g : ∀ a, q a → β} (s : Multiset α) :
∀ {H₁ H₂}, (∀ a ∈ s, ∀ (h₁ h₂), f a h₁ = g a h₂) → pmap f s H₁ = pmap g s H₂ :=
@(Quot.inductionOn s (fun l _H₁ _H₂ h => congr_arg _ <| List.pmap_congr l h))
#align multiset.pmap_congr Multiset.pmap_congr
theorem map_pmap {p : α → Prop} (g : β → γ) (f : ∀ a, p a → β) (s) :
∀ H, map g (pmap f s H) = pmap (fun a h => g (f a h)) s H :=
Quot.inductionOn s fun l H => congr_arg _ <| List.map_pmap g f l H
#align multiset.map_pmap Multiset.map_pmap
theorem pmap_eq_map_attach {p : α → Prop} (f : ∀ a, p a → β) (s) :
∀ H, pmap f s H = s.attach.map fun x => f x.1 (H _ x.2) :=
Quot.inductionOn s fun l H => congr_arg _ <| List.pmap_eq_map_attach f l H
#align multiset.pmap_eq_map_attach Multiset.pmap_eq_map_attach
-- @[simp] -- Porting note: Left hand does not simplify
theorem attach_map_val' (s : Multiset α) (f : α → β) : (s.attach.map fun i => f i.val) = s.map f :=
Quot.inductionOn s fun l => congr_arg _ <| List.attach_map_coe' l f
#align multiset.attach_map_coe' Multiset.attach_map_val'
#align multiset.attach_map_val' Multiset.attach_map_val'
@[simp]
theorem attach_map_val (s : Multiset α) : s.attach.map Subtype.val = s :=
(attach_map_val' _ _).trans s.map_id
#align multiset.attach_map_coe Multiset.attach_map_val
#align multiset.attach_map_val Multiset.attach_map_val
@[simp]
theorem mem_attach (s : Multiset α) : ∀ x, x ∈ s.attach :=
Quot.inductionOn s fun _l => List.mem_attach _
#align multiset.mem_attach Multiset.mem_attach
@[simp]
theorem mem_pmap {p : α → Prop} {f : ∀ a, p a → β} {s H b} :
b ∈ pmap f s H ↔ ∃ (a : _) (h : a ∈ s), f a (H a h) = b :=
Quot.inductionOn s (fun _l _H => List.mem_pmap) H
#align multiset.mem_pmap Multiset.mem_pmap
@[simp]
theorem card_pmap {p : α → Prop} (f : ∀ a, p a → β) (s H) : card (pmap f s H) = card s :=
Quot.inductionOn s (fun _l _H => length_pmap) H
#align multiset.card_pmap Multiset.card_pmap
@[simp]
theorem card_attach {m : Multiset α} : card (attach m) = card m :=
card_pmap _ _ _
#align multiset.card_attach Multiset.card_attach
@[simp]
theorem attach_zero : (0 : Multiset α).attach = 0 :=
rfl
#align multiset.attach_zero Multiset.attach_zero
theorem attach_cons (a : α) (m : Multiset α) :
(a ::ₘ m).attach =
⟨a, mem_cons_self a m⟩ ::ₘ m.attach.map fun p => ⟨p.1, mem_cons_of_mem p.2⟩ :=
Quotient.inductionOn m fun l =>
congr_arg _ <|
congr_arg (List.cons _) <| by
rw [List.map_pmap]; exact List.pmap_congr _ fun _ _ _ _ => Subtype.eq rfl
#align multiset.attach_cons Multiset.attach_cons
section
variable [DecidableEq α] {s t u : Multiset α} {a b : α}
protected def sub (s t : Multiset α) : Multiset α :=
(Quotient.liftOn₂ s t fun l₁ l₂ => (l₁.diff l₂ : Multiset α)) fun _v₁ _v₂ _w₁ _w₂ p₁ p₂ =>
Quot.sound <| p₁.diff p₂
#align multiset.sub Multiset.sub
instance : Sub (Multiset α) :=
⟨Multiset.sub⟩
@[simp]
theorem coe_sub (s t : List α) : (s - t : Multiset α) = (s.diff t : List α) :=
rfl
#align multiset.coe_sub Multiset.coe_sub
protected theorem sub_zero (s : Multiset α) : s - 0 = s :=
Quot.inductionOn s fun _l => rfl
#align multiset.sub_zero Multiset.sub_zero
@[simp]
theorem sub_cons (a : α) (s t : Multiset α) : s - a ::ₘ t = s.erase a - t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => congr_arg _ <| diff_cons _ _ _
#align multiset.sub_cons Multiset.sub_cons
protected theorem sub_le_iff_le_add : s - t ≤ u ↔ s ≤ u + t := by
revert s
exact @(Multiset.induction_on t (by simp [Multiset.sub_zero]) fun a t IH s => by
simp [IH, erase_le_iff_le_cons])
#align multiset.sub_le_iff_le_add Multiset.sub_le_iff_le_add
instance : OrderedSub (Multiset α) :=
⟨fun _n _m _k => Multiset.sub_le_iff_le_add⟩
theorem cons_sub_of_le (a : α) {s t : Multiset α} (h : t ≤ s) : a ::ₘ s - t = a ::ₘ (s - t) := by
rw [← singleton_add, ← singleton_add, add_tsub_assoc_of_le h]
#align multiset.cons_sub_of_le Multiset.cons_sub_of_le
theorem sub_eq_fold_erase (s t : Multiset α) : s - t = foldl erase erase_comm s t :=
Quotient.inductionOn₂ s t fun l₁ l₂ => by
show ofList (l₁.diff l₂) = foldl erase erase_comm l₁ l₂
rw [diff_eq_foldl l₁ l₂]
symm
exact foldl_hom _ _ _ _ _ fun x y => rfl
#align multiset.sub_eq_fold_erase Multiset.sub_eq_fold_erase
@[simp]
theorem card_sub {s t : Multiset α} (h : t ≤ s) : card (s - t) = card s - card t :=
Nat.eq_sub_of_add_eq $ by rw [← card_add, tsub_add_cancel_of_le h]
#align multiset.card_sub Multiset.card_sub
def union (s t : Multiset α) : Multiset α :=
s - t + t
#align multiset.union Multiset.union
instance : Union (Multiset α) :=
⟨union⟩
theorem union_def (s t : Multiset α) : s ∪ t = s - t + t :=
rfl
#align multiset.union_def Multiset.union_def
theorem le_union_left (s t : Multiset α) : s ≤ s ∪ t :=
le_tsub_add
#align multiset.le_union_left Multiset.le_union_left
theorem le_union_right (s t : Multiset α) : t ≤ s ∪ t :=
le_add_left _ _
#align multiset.le_union_right Multiset.le_union_right
theorem eq_union_left : t ≤ s → s ∪ t = s :=
tsub_add_cancel_of_le
#align multiset.eq_union_left Multiset.eq_union_left
theorem union_le_union_right (h : s ≤ t) (u) : s ∪ u ≤ t ∪ u :=
add_le_add_right (tsub_le_tsub_right h _) u
#align multiset.union_le_union_right Multiset.union_le_union_right
theorem union_le (h₁ : s ≤ u) (h₂ : t ≤ u) : s ∪ t ≤ u := by
rw [← eq_union_left h₂]; exact union_le_union_right h₁ t
#align multiset.union_le Multiset.union_le
@[simp]
theorem mem_union : a ∈ s ∪ t ↔ a ∈ s ∨ a ∈ t :=
⟨fun h => (mem_add.1 h).imp_left (mem_of_le tsub_le_self),
(Or.elim · (mem_of_le <| le_union_left _ _) (mem_of_le <| le_union_right _ _))⟩
#align multiset.mem_union Multiset.mem_union
@[simp]
theorem map_union [DecidableEq β] {f : α → β} (finj : Function.Injective f) {s t : Multiset α} :
map f (s ∪ t) = map f s ∪ map f t :=
Quotient.inductionOn₂ s t fun l₁ l₂ =>
congr_arg ofList (by rw [List.map_append f, List.map_diff finj])
#align multiset.map_union Multiset.map_union
-- Porting note (#10756): new theorem
@[simp] theorem zero_union : 0 ∪ s = s := by
simp [union_def]
-- Porting note (#10756): new theorem
@[simp] theorem union_zero : s ∪ 0 = s := by
simp [union_def]
def inter (s t : Multiset α) : Multiset α :=
Quotient.liftOn₂ s t (fun l₁ l₂ => (l₁.bagInter l₂ : Multiset α)) fun _v₁ _v₂ _w₁ _w₂ p₁ p₂ =>
Quot.sound <| p₁.bagInter p₂
#align multiset.inter Multiset.inter
instance : Inter (Multiset α) :=
⟨inter⟩
@[simp]
theorem inter_zero (s : Multiset α) : s ∩ 0 = 0 :=
Quot.inductionOn s fun l => congr_arg ofList l.bagInter_nil
#align multiset.inter_zero Multiset.inter_zero
@[simp]
theorem zero_inter (s : Multiset α) : 0 ∩ s = 0 :=
Quot.inductionOn s fun l => congr_arg ofList l.nil_bagInter
#align multiset.zero_inter Multiset.zero_inter
@[simp]
theorem cons_inter_of_pos {a} (s : Multiset α) {t} : a ∈ t → (a ::ₘ s) ∩ t = a ::ₘ s ∩ t.erase a :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ h => congr_arg ofList <| cons_bagInter_of_pos _ h
#align multiset.cons_inter_of_pos Multiset.cons_inter_of_pos
@[simp]
theorem cons_inter_of_neg {a} (s : Multiset α) {t} : a ∉ t → (a ::ₘ s) ∩ t = s ∩ t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ h => congr_arg ofList <| cons_bagInter_of_neg _ h
#align multiset.cons_inter_of_neg Multiset.cons_inter_of_neg
theorem inter_le_left (s t : Multiset α) : s ∩ t ≤ s :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => (bagInter_sublist_left _ _).subperm
#align multiset.inter_le_left Multiset.inter_le_left
theorem inter_le_right (s : Multiset α) : ∀ t, s ∩ t ≤ t :=
Multiset.induction_on s (fun t => (zero_inter t).symm ▸ zero_le _) fun a s IH t =>
if h : a ∈ t then by simpa [h] using cons_le_cons a (IH (t.erase a)) else by simp [h, IH]
#align multiset.inter_le_right Multiset.inter_le_right
theorem le_inter (h₁ : s ≤ t) (h₂ : s ≤ u) : s ≤ t ∩ u := by
revert s u; refine @(Multiset.induction_on t ?_ fun a t IH => ?_) <;> intros s u h₁ h₂
· simpa only [zero_inter, nonpos_iff_eq_zero] using h₁
by_cases h : a ∈ u
· rw [cons_inter_of_pos _ h, ← erase_le_iff_le_cons]
exact IH (erase_le_iff_le_cons.2 h₁) (erase_le_erase _ h₂)
· rw [cons_inter_of_neg _ h]
exact IH ((le_cons_of_not_mem <| mt (mem_of_le h₂) h).1 h₁) h₂
#align multiset.le_inter Multiset.le_inter
@[simp]
theorem mem_inter : a ∈ s ∩ t ↔ a ∈ s ∧ a ∈ t :=
⟨fun h => ⟨mem_of_le (inter_le_left _ _) h, mem_of_le (inter_le_right _ _) h⟩, fun ⟨h₁, h₂⟩ => by
rw [← cons_erase h₁, cons_inter_of_pos _ h₂]; apply mem_cons_self⟩
#align multiset.mem_inter Multiset.mem_inter
instance : Lattice (Multiset α) :=
{ sup := (· ∪ ·)
sup_le := @union_le _ _
le_sup_left := le_union_left
le_sup_right := le_union_right
inf := (· ∩ ·)
le_inf := @le_inter _ _
inf_le_left := inter_le_left
inf_le_right := inter_le_right }
@[simp]
theorem sup_eq_union (s t : Multiset α) : s ⊔ t = s ∪ t :=
rfl
#align multiset.sup_eq_union Multiset.sup_eq_union
@[simp]
theorem inf_eq_inter (s t : Multiset α) : s ⊓ t = s ∩ t :=
rfl
#align multiset.inf_eq_inter Multiset.inf_eq_inter
@[simp]
theorem le_inter_iff : s ≤ t ∩ u ↔ s ≤ t ∧ s ≤ u :=
le_inf_iff
#align multiset.le_inter_iff Multiset.le_inter_iff
@[simp]
theorem union_le_iff : s ∪ t ≤ u ↔ s ≤ u ∧ t ≤ u :=
sup_le_iff
#align multiset.union_le_iff Multiset.union_le_iff
theorem union_comm (s t : Multiset α) : s ∪ t = t ∪ s := sup_comm _ _
#align multiset.union_comm Multiset.union_comm
theorem inter_comm (s t : Multiset α) : s ∩ t = t ∩ s := inf_comm _ _
#align multiset.inter_comm Multiset.inter_comm
theorem eq_union_right (h : s ≤ t) : s ∪ t = t := by rw [union_comm, eq_union_left h]
#align multiset.eq_union_right Multiset.eq_union_right
theorem union_le_union_left (h : s ≤ t) (u) : u ∪ s ≤ u ∪ t :=
sup_le_sup_left h _
#align multiset.union_le_union_left Multiset.union_le_union_left
theorem union_le_add (s t : Multiset α) : s ∪ t ≤ s + t :=
union_le (le_add_right _ _) (le_add_left _ _)
#align multiset.union_le_add Multiset.union_le_add
theorem union_add_distrib (s t u : Multiset α) : s ∪ t + u = s + u ∪ (t + u) := by
simpa [(· ∪ ·), union, eq_comm, add_assoc] using
show s + u - (t + u) = s - t by rw [add_comm t, tsub_add_eq_tsub_tsub, add_tsub_cancel_right]
#align multiset.union_add_distrib Multiset.union_add_distrib
theorem add_union_distrib (s t u : Multiset α) : s + (t ∪ u) = s + t ∪ (s + u) := by
rw [add_comm, union_add_distrib, add_comm s, add_comm s]
#align multiset.add_union_distrib Multiset.add_union_distrib
theorem cons_union_distrib (a : α) (s t : Multiset α) : a ::ₘ (s ∪ t) = a ::ₘ s ∪ a ::ₘ t := by
simpa using add_union_distrib (a ::ₘ 0) s t
#align multiset.cons_union_distrib Multiset.cons_union_distrib
theorem inter_add_distrib (s t u : Multiset α) : s ∩ t + u = (s + u) ∩ (t + u) := by
by_contra h
cases'
lt_iff_cons_le.1
(lt_of_le_of_ne
(le_inter (add_le_add_right (inter_le_left s t) u)
(add_le_add_right (inter_le_right s t) u))
h) with
a hl
rw [← cons_add] at hl
exact
not_le_of_lt (lt_cons_self (s ∩ t) a)
(le_inter (le_of_add_le_add_right (le_trans hl (inter_le_left _ _)))
(le_of_add_le_add_right (le_trans hl (inter_le_right _ _))))
#align multiset.inter_add_distrib Multiset.inter_add_distrib
theorem add_inter_distrib (s t u : Multiset α) : s + t ∩ u = (s + t) ∩ (s + u) := by
rw [add_comm, inter_add_distrib, add_comm s, add_comm s]
#align multiset.add_inter_distrib Multiset.add_inter_distrib
theorem cons_inter_distrib (a : α) (s t : Multiset α) : a ::ₘ s ∩ t = (a ::ₘ s) ∩ (a ::ₘ t) := by
simp
#align multiset.cons_inter_distrib Multiset.cons_inter_distrib
theorem union_add_inter (s t : Multiset α) : s ∪ t + s ∩ t = s + t := by
apply _root_.le_antisymm
· rw [union_add_distrib]
refine union_le (add_le_add_left (inter_le_right _ _) _) ?_
rw [add_comm]
exact add_le_add_right (inter_le_left _ _) _
· rw [add_comm, add_inter_distrib]
refine le_inter (add_le_add_right (le_union_right _ _) _) ?_
rw [add_comm]
exact add_le_add_right (le_union_left _ _) _
#align multiset.union_add_inter Multiset.union_add_inter
theorem sub_add_inter (s t : Multiset α) : s - t + s ∩ t = s := by
rw [inter_comm]
revert s; refine Multiset.induction_on t (by simp) fun a t IH s => ?_
by_cases h : a ∈ s
· rw [cons_inter_of_pos _ h, sub_cons, add_cons, IH, cons_erase h]
· rw [cons_inter_of_neg _ h, sub_cons, erase_of_not_mem h, IH]
#align multiset.sub_add_inter Multiset.sub_add_inter
theorem sub_inter (s t : Multiset α) : s - s ∩ t = s - t :=
add_right_cancel <| by rw [sub_add_inter s t, tsub_add_cancel_of_le (inter_le_left s t)]
#align multiset.sub_inter Multiset.sub_inter
end
section
variable (p : α → Prop) [DecidablePred p]
def filter (s : Multiset α) : Multiset α :=
Quot.liftOn s (fun l => (List.filter p l : Multiset α)) fun _l₁ _l₂ h => Quot.sound <| h.filter p
#align multiset.filter Multiset.filter
@[simp, norm_cast] lemma filter_coe (l : List α) : filter p l = l.filter p := rfl
#align multiset.coe_filter Multiset.filter_coe
@[simp]
theorem filter_zero : filter p 0 = 0 :=
rfl
#align multiset.filter_zero Multiset.filter_zero
theorem filter_congr {p q : α → Prop} [DecidablePred p] [DecidablePred q] {s : Multiset α} :
(∀ x ∈ s, p x ↔ q x) → filter p s = filter q s :=
Quot.inductionOn s fun _l h => congr_arg ofList <| filter_congr' <| by simpa using h
#align multiset.filter_congr Multiset.filter_congr
@[simp]
theorem filter_add (s t : Multiset α) : filter p (s + t) = filter p s + filter p t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => congr_arg ofList <| filter_append _ _
#align multiset.filter_add Multiset.filter_add
@[simp]
theorem filter_le (s : Multiset α) : filter p s ≤ s :=
Quot.inductionOn s fun _l => (filter_sublist _).subperm
#align multiset.filter_le Multiset.filter_le
@[simp]
theorem filter_subset (s : Multiset α) : filter p s ⊆ s :=
subset_of_le <| filter_le _ _
#align multiset.filter_subset Multiset.filter_subset
theorem filter_le_filter {s t} (h : s ≤ t) : filter p s ≤ filter p t :=
leInductionOn h fun h => (h.filter (p ·)).subperm
#align multiset.filter_le_filter Multiset.filter_le_filter
theorem monotone_filter_left : Monotone (filter p) := fun _s _t => filter_le_filter p
#align multiset.monotone_filter_left Multiset.monotone_filter_left
theorem monotone_filter_right (s : Multiset α) ⦃p q : α → Prop⦄ [DecidablePred p] [DecidablePred q]
(h : ∀ b, p b → q b) :
s.filter p ≤ s.filter q :=
Quotient.inductionOn s fun l => (l.monotone_filter_right <| by simpa using h).subperm
#align multiset.monotone_filter_right Multiset.monotone_filter_right
variable {p}
@[simp]
theorem filter_cons_of_pos {a : α} (s) : p a → filter p (a ::ₘ s) = a ::ₘ filter p s :=
Quot.inductionOn s fun l h => congr_arg ofList <| List.filter_cons_of_pos l <| by simpa using h
#align multiset.filter_cons_of_pos Multiset.filter_cons_of_pos
@[simp]
theorem filter_cons_of_neg {a : α} (s) : ¬p a → filter p (a ::ₘ s) = filter p s :=
Quot.inductionOn s fun l h => congr_arg ofList <| List.filter_cons_of_neg l <| by simpa using h
#align multiset.filter_cons_of_neg Multiset.filter_cons_of_neg
@[simp]
theorem mem_filter {a : α} {s} : a ∈ filter p s ↔ a ∈ s ∧ p a :=
Quot.inductionOn s fun _l => by simpa using List.mem_filter (p := (p ·))
#align multiset.mem_filter Multiset.mem_filter
theorem of_mem_filter {a : α} {s} (h : a ∈ filter p s) : p a :=
(mem_filter.1 h).2
#align multiset.of_mem_filter Multiset.of_mem_filter
theorem mem_of_mem_filter {a : α} {s} (h : a ∈ filter p s) : a ∈ s :=
(mem_filter.1 h).1
#align multiset.mem_of_mem_filter Multiset.mem_of_mem_filter
theorem mem_filter_of_mem {a : α} {l} (m : a ∈ l) (h : p a) : a ∈ filter p l :=
mem_filter.2 ⟨m, h⟩
#align multiset.mem_filter_of_mem Multiset.mem_filter_of_mem
theorem filter_eq_self {s} : filter p s = s ↔ ∀ a ∈ s, p a :=
Quot.inductionOn s fun _l =>
Iff.trans ⟨fun h => (filter_sublist _).eq_of_length (@congr_arg _ _ _ _ card h),
congr_arg ofList⟩ <| by simp
#align multiset.filter_eq_self Multiset.filter_eq_self
theorem filter_eq_nil {s} : filter p s = 0 ↔ ∀ a ∈ s, ¬p a :=
Quot.inductionOn s fun _l =>
Iff.trans ⟨fun h => eq_nil_of_length_eq_zero (@congr_arg _ _ _ _ card h), congr_arg ofList⟩ <|
by simpa using List.filter_eq_nil (p := (p ·))
#align multiset.filter_eq_nil Multiset.filter_eq_nil
theorem le_filter {s t} : s ≤ filter p t ↔ s ≤ t ∧ ∀ a ∈ s, p a :=
⟨fun h => ⟨le_trans h (filter_le _ _), fun _a m => of_mem_filter (mem_of_le h m)⟩, fun ⟨h, al⟩ =>
filter_eq_self.2 al ▸ filter_le_filter p h⟩
#align multiset.le_filter Multiset.le_filter
theorem filter_cons {a : α} (s : Multiset α) :
filter p (a ::ₘ s) = (if p a then {a} else 0) + filter p s := by
split_ifs with h
· rw [filter_cons_of_pos _ h, singleton_add]
· rw [filter_cons_of_neg _ h, zero_add]
#align multiset.filter_cons Multiset.filter_cons
theorem filter_singleton {a : α} (p : α → Prop) [DecidablePred p] :
filter p {a} = if p a then {a} else ∅ := by
simp only [singleton, filter_cons, filter_zero, add_zero, empty_eq_zero]
#align multiset.filter_singleton Multiset.filter_singleton
theorem filter_nsmul (s : Multiset α) (n : ℕ) : filter p (n • s) = n • filter p s := by
refine s.induction_on ?_ ?_
· simp only [filter_zero, nsmul_zero]
· intro a ha ih
rw [nsmul_cons, filter_add, ih, filter_cons, nsmul_add]
congr
split_ifs with hp <;>
· simp only [filter_eq_self, nsmul_zero, filter_eq_nil]
intro b hb
rwa [mem_singleton.mp (mem_of_mem_nsmul hb)]
#align multiset.filter_nsmul Multiset.filter_nsmul
variable (p)
@[simp]
theorem filter_sub [DecidableEq α] (s t : Multiset α) :
filter p (s - t) = filter p s - filter p t := by
revert s; refine Multiset.induction_on t (by simp) fun a t IH s => ?_
rw [sub_cons, IH]
by_cases h : p a
· rw [filter_cons_of_pos _ h, sub_cons]
congr
by_cases m : a ∈ s
· rw [← cons_inj_right a, ← filter_cons_of_pos _ h, cons_erase (mem_filter_of_mem m h),
cons_erase m]
· rw [erase_of_not_mem m, erase_of_not_mem (mt mem_of_mem_filter m)]
· rw [filter_cons_of_neg _ h]
by_cases m : a ∈ s
· rw [(by rw [filter_cons_of_neg _ h] : filter p (erase s a) = filter p (a ::ₘ erase s a)),
cons_erase m]
· rw [erase_of_not_mem m]
#align multiset.filter_sub Multiset.filter_sub
@[simp]
theorem filter_union [DecidableEq α] (s t : Multiset α) :
filter p (s ∪ t) = filter p s ∪ filter p t := by simp [(· ∪ ·), union]
#align multiset.filter_union Multiset.filter_union
@[simp]
theorem filter_inter [DecidableEq α] (s t : Multiset α) :
filter p (s ∩ t) = filter p s ∩ filter p t :=
le_antisymm
(le_inter (filter_le_filter _ <| inter_le_left _ _)
(filter_le_filter _ <| inter_le_right _ _)) <|
le_filter.2
⟨inf_le_inf (filter_le _ _) (filter_le _ _), fun _a h =>
of_mem_filter (mem_of_le (inter_le_left _ _) h)⟩
#align multiset.filter_inter Multiset.filter_inter
@[simp]
theorem filter_filter (q) [DecidablePred q] (s : Multiset α) :
filter p (filter q s) = filter (fun a => p a ∧ q a) s :=
Quot.inductionOn s fun l => by simp
#align multiset.filter_filter Multiset.filter_filter
lemma filter_comm (q) [DecidablePred q] (s : Multiset α) :
filter p (filter q s) = filter q (filter p s) := by simp [and_comm]
#align multiset.filter_comm Multiset.filter_comm
theorem filter_add_filter (q) [DecidablePred q] (s : Multiset α) :
filter p s + filter q s = filter (fun a => p a ∨ q a) s + filter (fun a => p a ∧ q a) s :=
Multiset.induction_on s rfl fun a s IH => by by_cases p a <;> by_cases q a <;> simp [*]
#align multiset.filter_add_filter Multiset.filter_add_filter
theorem filter_add_not (s : Multiset α) : filter p s + filter (fun a => ¬p a) s = s := by
rw [filter_add_filter, filter_eq_self.2, filter_eq_nil.2]
· simp only [add_zero]
· simp [Decidable.em, -Bool.not_eq_true, -not_and, not_and_or, or_comm]
· simp only [Bool.not_eq_true, decide_eq_true_eq, Bool.eq_false_or_eq_true,
decide_True, implies_true, Decidable.em]
#align multiset.filter_add_not Multiset.filter_add_not
theorem map_filter (f : β → α) (s : Multiset β) : filter p (map f s) = map f (filter (p ∘ f) s) :=
Quot.inductionOn s fun l => by simp [List.map_filter]; rfl
#align multiset.map_filter Multiset.map_filter
lemma map_filter' {f : α → β} (hf : Injective f) (s : Multiset α)
[DecidablePred fun b => ∃ a, p a ∧ f a = b] :
(s.filter p).map f = (s.map f).filter fun b => ∃ a, p a ∧ f a = b := by
simp [(· ∘ ·), map_filter, hf.eq_iff]
#align multiset.map_filter' Multiset.map_filter'
lemma card_filter_le_iff (s : Multiset α) (P : α → Prop) [DecidablePred P] (n : ℕ) :
card (s.filter P) ≤ n ↔ ∀ s' ≤ s, n < card s' → ∃ a ∈ s', ¬ P a := by
fconstructor
· intro H s' hs' s'_card
by_contra! rid
have card := card_le_card (monotone_filter_left P hs') |>.trans H
exact s'_card.not_le (filter_eq_self.mpr rid ▸ card)
· contrapose!
exact fun H ↦ ⟨s.filter P, filter_le _ _, H, fun a ha ↦ (mem_filter.mp ha).2⟩
def filterMap (f : α → Option β) (s : Multiset α) : Multiset β :=
Quot.liftOn s (fun l => (List.filterMap f l : Multiset β))
fun _l₁ _l₂ h => Quot.sound <| h.filterMap f
#align multiset.filter_map Multiset.filterMap
@[simp, norm_cast]
lemma filterMap_coe (f : α → Option β) (l : List α) : filterMap f l = l.filterMap f := rfl
#align multiset.coe_filter_map Multiset.filterMap_coe
@[simp]
theorem filterMap_zero (f : α → Option β) : filterMap f 0 = 0 :=
rfl
#align multiset.filter_map_zero Multiset.filterMap_zero
@[simp]
theorem filterMap_cons_none {f : α → Option β} (a : α) (s : Multiset α) (h : f a = none) :
filterMap f (a ::ₘ s) = filterMap f s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filterMap_cons_none a l h
#align multiset.filter_map_cons_none Multiset.filterMap_cons_none
@[simp]
theorem filterMap_cons_some (f : α → Option β) (a : α) (s : Multiset α) {b : β}
(h : f a = some b) : filterMap f (a ::ₘ s) = b ::ₘ filterMap f s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filterMap_cons_some f a l h
#align multiset.filter_map_cons_some Multiset.filterMap_cons_some
theorem filterMap_eq_map (f : α → β) : filterMap (some ∘ f) = map f :=
funext fun s =>
Quot.inductionOn s fun l => congr_arg ofList <| congr_fun (List.filterMap_eq_map f) l
#align multiset.filter_map_eq_map Multiset.filterMap_eq_map
theorem filterMap_eq_filter : filterMap (Option.guard p) = filter p :=
funext fun s =>
Quot.inductionOn s fun l => congr_arg ofList <| by
rw [← List.filterMap_eq_filter]
congr; funext a; simp
#align multiset.filter_map_eq_filter Multiset.filterMap_eq_filter
theorem filterMap_filterMap (f : α → Option β) (g : β → Option γ) (s : Multiset α) :
filterMap g (filterMap f s) = filterMap (fun x => (f x).bind g) s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filterMap_filterMap f g l
#align multiset.filter_map_filter_map Multiset.filterMap_filterMap
theorem map_filterMap (f : α → Option β) (g : β → γ) (s : Multiset α) :
map g (filterMap f s) = filterMap (fun x => (f x).map g) s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.map_filterMap f g l
#align multiset.map_filter_map Multiset.map_filterMap
theorem filterMap_map (f : α → β) (g : β → Option γ) (s : Multiset α) :
filterMap g (map f s) = filterMap (g ∘ f) s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filterMap_map f g l
#align multiset.filter_map_map Multiset.filterMap_map
theorem filter_filterMap (f : α → Option β) (p : β → Prop) [DecidablePred p] (s : Multiset α) :
filter p (filterMap f s) = filterMap (fun x => (f x).filter p) s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filter_filterMap f p l
#align multiset.filter_filter_map Multiset.filter_filterMap
theorem filterMap_filter (f : α → Option β) (s : Multiset α) :
filterMap f (filter p s) = filterMap (fun x => if p x then f x else none) s :=
Quot.inductionOn s fun l => congr_arg ofList <| by simpa using List.filterMap_filter p f l
#align multiset.filter_map_filter Multiset.filterMap_filter
@[simp]
theorem filterMap_some (s : Multiset α) : filterMap some s = s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.filterMap_some l
#align multiset.filter_map_some Multiset.filterMap_some
@[simp]
theorem mem_filterMap (f : α → Option β) (s : Multiset α) {b : β} :
b ∈ filterMap f s ↔ ∃ a, a ∈ s ∧ f a = some b :=
Quot.inductionOn s fun l => List.mem_filterMap f l
#align multiset.mem_filter_map Multiset.mem_filterMap
theorem map_filterMap_of_inv (f : α → Option β) (g : β → α) (H : ∀ x : α, (f x).map g = some x)
(s : Multiset α) : map g (filterMap f s) = s :=
Quot.inductionOn s fun l => congr_arg ofList <| List.map_filterMap_of_inv f g H l
#align multiset.map_filter_map_of_inv Multiset.map_filterMap_of_inv
theorem filterMap_le_filterMap (f : α → Option β) {s t : Multiset α} (h : s ≤ t) :
filterMap f s ≤ filterMap f t :=
leInductionOn h fun h => (h.filterMap _).subperm
#align multiset.filter_map_le_filter_map Multiset.filterMap_le_filterMap
def countP (s : Multiset α) : ℕ :=
Quot.liftOn s (List.countP p) fun _l₁ _l₂ => Perm.countP_eq (p ·)
#align multiset.countp Multiset.countP
@[simp]
theorem coe_countP (l : List α) : countP p l = l.countP p :=
rfl
#align multiset.coe_countp Multiset.coe_countP
@[simp]
theorem countP_zero : countP p 0 = 0 :=
rfl
#align multiset.countp_zero Multiset.countP_zero
variable {p}
@[simp]
theorem countP_cons_of_pos {a : α} (s) : p a → countP p (a ::ₘ s) = countP p s + 1 :=
Quot.inductionOn s <| by simpa using List.countP_cons_of_pos (p ·)
#align multiset.countp_cons_of_pos Multiset.countP_cons_of_pos
@[simp]
theorem countP_cons_of_neg {a : α} (s) : ¬p a → countP p (a ::ₘ s) = countP p s :=
Quot.inductionOn s <| by simpa using List.countP_cons_of_neg (p ·)
#align multiset.countp_cons_of_neg Multiset.countP_cons_of_neg
variable (p)
theorem countP_cons (b : α) (s) : countP p (b ::ₘ s) = countP p s + if p b then 1 else 0 :=
Quot.inductionOn s <| by simp [List.countP_cons]
#align multiset.countp_cons Multiset.countP_cons
theorem countP_eq_card_filter (s) : countP p s = card (filter p s) :=
Quot.inductionOn s fun l => l.countP_eq_length_filter (p ·)
#align multiset.countp_eq_card_filter Multiset.countP_eq_card_filter
theorem countP_le_card (s) : countP p s ≤ card s :=
Quot.inductionOn s fun _l => countP_le_length (p ·)
#align multiset.countp_le_card Multiset.countP_le_card
@[simp]
theorem countP_add (s t) : countP p (s + t) = countP p s + countP p t := by
simp [countP_eq_card_filter]
#align multiset.countp_add Multiset.countP_add
@[simp]
theorem countP_nsmul (s) (n : ℕ) : countP p (n • s) = n * countP p s := by
induction n <;> simp [*, succ_nsmul, succ_mul, zero_nsmul]
#align multiset.countp_nsmul Multiset.countP_nsmul
theorem card_eq_countP_add_countP (s) : card s = countP p s + countP (fun x => ¬p x) s :=
Quot.inductionOn s fun l => by simp [l.length_eq_countP_add_countP p]
#align multiset.card_eq_countp_add_countp Multiset.card_eq_countP_add_countP
def countPAddMonoidHom : Multiset α →+ ℕ where
toFun := countP p
map_zero' := countP_zero _
map_add' := countP_add _
#align multiset.countp_add_monoid_hom Multiset.countPAddMonoidHom
@[simp]
theorem coe_countPAddMonoidHom : (countPAddMonoidHom p : Multiset α → ℕ) = countP p :=
rfl
#align multiset.coe_countp_add_monoid_hom Multiset.coe_countPAddMonoidHom
@[simp]
theorem countP_sub [DecidableEq α] {s t : Multiset α} (h : t ≤ s) :
countP p (s - t) = countP p s - countP p t := by
simp [countP_eq_card_filter, h, filter_le_filter]
#align multiset.countp_sub Multiset.countP_sub
theorem countP_le_of_le {s t} (h : s ≤ t) : countP p s ≤ countP p t := by
simpa [countP_eq_card_filter] using card_le_card (filter_le_filter p h)
#align multiset.countp_le_of_le Multiset.countP_le_of_le
@[simp]
theorem countP_filter (q) [DecidablePred q] (s : Multiset α) :
countP p (filter q s) = countP (fun a => p a ∧ q a) s := by simp [countP_eq_card_filter]
#align multiset.countp_filter Multiset.countP_filter
theorem countP_eq_countP_filter_add (s) (p q : α → Prop) [DecidablePred p] [DecidablePred q] :
countP p s = (filter q s).countP p + (filter (fun a => ¬q a) s).countP p :=
Quot.inductionOn s fun l => by
convert l.countP_eq_countP_filter_add (p ·) (q ·)
simp [countP_filter]
#align multiset.countp_eq_countp_filter_add Multiset.countP_eq_countP_filter_add
@[simp]
theorem countP_True {s : Multiset α} : countP (fun _ => True) s = card s :=
Quot.inductionOn s fun _l => List.countP_true
#align multiset.countp_true Multiset.countP_True
@[simp]
theorem countP_False {s : Multiset α} : countP (fun _ => False) s = 0 :=
Quot.inductionOn s fun _l => List.countP_false
#align multiset.countp_false Multiset.countP_False
theorem countP_map (f : α → β) (s : Multiset α) (p : β → Prop) [DecidablePred p] :
countP p (map f s) = card (s.filter fun a => p (f a)) := by
refine Multiset.induction_on s ?_ fun a t IH => ?_
· rw [map_zero, countP_zero, filter_zero, card_zero]
· rw [map_cons, countP_cons, IH, filter_cons, card_add, apply_ite card, card_zero, card_singleton,
add_comm]
#align multiset.countp_map Multiset.countP_map
-- Porting note: `Lean.Internal.coeM` forces us to type-ascript `{a // a ∈ s}`
lemma countP_attach (s : Multiset α) : s.attach.countP (fun a : {a // a ∈ s} ↦ p a) = s.countP p :=
Quotient.inductionOn s fun l => by
simp only [quot_mk_to_coe, coe_countP]
-- Porting note: was
-- rw [quot_mk_to_coe, coe_attach, coe_countP]
-- exact List.countP_attach _ _
rw [coe_attach]
refine (coe_countP _ _).trans ?_
convert List.countP_attach _ _
rfl
#align multiset.countp_attach Multiset.countP_attach
lemma filter_attach (s : Multiset α) (p : α → Prop) [DecidablePred p] :
(s.attach.filter fun a : {a // a ∈ s} ↦ p ↑a) =
(s.filter p).attach.map (Subtype.map id fun _ ↦ Multiset.mem_of_mem_filter) :=
Quotient.inductionOn s fun l ↦ congr_arg _ (List.filter_attach l p)
#align multiset.filter_attach Multiset.filter_attach
variable {p}
theorem countP_pos {s} : 0 < countP p s ↔ ∃ a ∈ s, p a :=
Quot.inductionOn s fun _l => by simpa using List.countP_pos (p ·)
#align multiset.countp_pos Multiset.countP_pos
theorem countP_eq_zero {s} : countP p s = 0 ↔ ∀ a ∈ s, ¬p a :=
Quot.inductionOn s fun _l => by simp [List.countP_eq_zero]
#align multiset.countp_eq_zero Multiset.countP_eq_zero
theorem countP_eq_card {s} : countP p s = card s ↔ ∀ a ∈ s, p a :=
Quot.inductionOn s fun _l => by simp [List.countP_eq_length]
#align multiset.countp_eq_card Multiset.countP_eq_card
theorem countP_pos_of_mem {s a} (h : a ∈ s) (pa : p a) : 0 < countP p s :=
countP_pos.2 ⟨_, h, pa⟩
#align multiset.countp_pos_of_mem Multiset.countP_pos_of_mem
theorem countP_congr {s s' : Multiset α} (hs : s = s')
{p p' : α → Prop} [DecidablePred p] [DecidablePred p']
(hp : ∀ x ∈ s, p x = p' x) : s.countP p = s'.countP p' := by
revert hs hp
exact Quot.induction_on₂ s s'
(fun l l' hs hp => by
simp only [quot_mk_to_coe'', coe_eq_coe] at hs
apply hs.countP_congr
simpa using hp)
#align multiset.countp_congr Multiset.countP_congr
end
section
variable [DecidableEq α] {s : Multiset α}
def count (a : α) : Multiset α → ℕ :=
countP (a = ·)
#align multiset.count Multiset.count
@[simp]
theorem coe_count (a : α) (l : List α) : count a (ofList l) = l.count a := by
simp_rw [count, List.count, coe_countP (a = ·) l, @eq_comm _ a]
rfl
#align multiset.coe_count Multiset.coe_count
@[simp, nolint simpNF] -- Porting note (#10618): simp can prove this at EOF, but not right now
theorem count_zero (a : α) : count a 0 = 0 :=
rfl
#align multiset.count_zero Multiset.count_zero
@[simp]
theorem count_cons_self (a : α) (s : Multiset α) : count a (a ::ₘ s) = count a s + 1 :=
countP_cons_of_pos _ <| rfl
#align multiset.count_cons_self Multiset.count_cons_self
@[simp]
theorem count_cons_of_ne {a b : α} (h : a ≠ b) (s : Multiset α) : count a (b ::ₘ s) = count a s :=
countP_cons_of_neg _ <| h
#align multiset.count_cons_of_ne Multiset.count_cons_of_ne
theorem count_le_card (a : α) (s) : count a s ≤ card s :=
countP_le_card _ _
#align multiset.count_le_card Multiset.count_le_card
theorem count_le_of_le (a : α) {s t} : s ≤ t → count a s ≤ count a t :=
countP_le_of_le _
#align multiset.count_le_of_le Multiset.count_le_of_le
theorem count_le_count_cons (a b : α) (s : Multiset α) : count a s ≤ count a (b ::ₘ s) :=
count_le_of_le _ (le_cons_self _ _)
#align multiset.count_le_count_cons Multiset.count_le_count_cons
theorem count_cons (a b : α) (s : Multiset α) :
count a (b ::ₘ s) = count a s + if a = b then 1 else 0 :=
countP_cons (a = ·) _ _
#align multiset.count_cons Multiset.count_cons
theorem count_singleton_self (a : α) : count a ({a} : Multiset α) = 1 :=
count_eq_one_of_mem (nodup_singleton a) <| mem_singleton_self a
#align multiset.count_singleton_self Multiset.count_singleton_self
theorem count_singleton (a b : α) : count a ({b} : Multiset α) = if a = b then 1 else 0 := by
simp only [count_cons, ← cons_zero, count_zero, zero_add]
#align multiset.count_singleton Multiset.count_singleton
@[simp]
theorem count_add (a : α) : ∀ s t, count a (s + t) = count a s + count a t :=
countP_add _
#align multiset.count_add Multiset.count_add
def countAddMonoidHom (a : α) : Multiset α →+ ℕ :=
countPAddMonoidHom (a = ·)
#align multiset.count_add_monoid_hom Multiset.countAddMonoidHom
@[simp]
theorem coe_countAddMonoidHom {a : α} : (countAddMonoidHom a : Multiset α → ℕ) = count a :=
rfl
#align multiset.coe_count_add_monoid_hom Multiset.coe_countAddMonoidHom
@[simp]
theorem count_nsmul (a : α) (n s) : count a (n • s) = n * count a s := by
induction n <;> simp [*, succ_nsmul, succ_mul, zero_nsmul]
#align multiset.count_nsmul Multiset.count_nsmul
@[simp]
lemma count_attach (a : {x // x ∈ s}) : s.attach.count a = s.count ↑a :=
Eq.trans (countP_congr rfl fun _ _ => by simp [Subtype.ext_iff]) <| countP_attach _ _
#align multiset.count_attach Multiset.count_attach
theorem count_pos {a : α} {s : Multiset α} : 0 < count a s ↔ a ∈ s := by simp [count, countP_pos]
#align multiset.count_pos Multiset.count_pos
theorem one_le_count_iff_mem {a : α} {s : Multiset α} : 1 ≤ count a s ↔ a ∈ s := by
rw [succ_le_iff, count_pos]
#align multiset.one_le_count_iff_mem Multiset.one_le_count_iff_mem
@[simp]
theorem count_eq_zero_of_not_mem {a : α} {s : Multiset α} (h : a ∉ s) : count a s = 0 :=
by_contradiction fun h' => h <| count_pos.1 (Nat.pos_of_ne_zero h')
#align multiset.count_eq_zero_of_not_mem Multiset.count_eq_zero_of_not_mem
lemma count_ne_zero {a : α} : count a s ≠ 0 ↔ a ∈ s := Nat.pos_iff_ne_zero.symm.trans count_pos
#align multiset.count_ne_zero Multiset.count_ne_zero
@[simp] lemma count_eq_zero {a : α} : count a s = 0 ↔ a ∉ s := count_ne_zero.not_right
#align multiset.count_eq_zero Multiset.count_eq_zero
theorem count_eq_card {a : α} {s} : count a s = card s ↔ ∀ x ∈ s, a = x := by
simp [countP_eq_card, count, @eq_comm _ a]
#align multiset.count_eq_card Multiset.count_eq_card
@[simp]
theorem count_replicate_self (a : α) (n : ℕ) : count a (replicate n a) = n := by
convert List.count_replicate_self a n
rw [← coe_count, coe_replicate]
#align multiset.count_replicate_self Multiset.count_replicate_self
theorem count_replicate (a b : α) (n : ℕ) : count a (replicate n b) = if a = b then n else 0 := by
convert List.count_replicate a b n
rw [← coe_count, coe_replicate]
#align multiset.count_replicate Multiset.count_replicate
@[simp]
theorem count_erase_self (a : α) (s : Multiset α) : count a (erase s a) = count a s - 1 :=
Quotient.inductionOn s fun l => by
convert List.count_erase_self a l <;> rw [← coe_count] <;> simp
#align multiset.count_erase_self Multiset.count_erase_self
@[simp]
theorem count_erase_of_ne {a b : α} (ab : a ≠ b) (s : Multiset α) :
count a (erase s b) = count a s :=
Quotient.inductionOn s fun l => by
convert List.count_erase_of_ne ab l <;> rw [← coe_count] <;> simp
#align multiset.count_erase_of_ne Multiset.count_erase_of_ne
@[simp]
theorem count_sub (a : α) (s t : Multiset α) : count a (s - t) = count a s - count a t := by
revert s; refine Multiset.induction_on t (by simp) fun b t IH s => ?_
rw [sub_cons, IH]
rcases Decidable.eq_or_ne a b with rfl | ab
· rw [count_erase_self, count_cons_self, Nat.sub_sub, add_comm]
· rw [count_erase_of_ne ab, count_cons_of_ne ab]
#align multiset.count_sub Multiset.count_sub
@[simp]
theorem count_union (a : α) (s t : Multiset α) : count a (s ∪ t) = max (count a s) (count a t) := by
simp [(· ∪ ·), union, Nat.sub_add_eq_max]
#align multiset.count_union Multiset.count_union
@[simp]
theorem count_inter (a : α) (s t : Multiset α) : count a (s ∩ t) = min (count a s) (count a t) := by
apply @Nat.add_left_cancel (count a (s - t))
rw [← count_add, sub_add_inter, count_sub, Nat.sub_add_min_cancel]
#align multiset.count_inter Multiset.count_inter
theorem le_count_iff_replicate_le {a : α} {s : Multiset α} {n : ℕ} :
n ≤ count a s ↔ replicate n a ≤ s :=
Quot.inductionOn s fun _l => by
simp only [quot_mk_to_coe'', mem_coe, coe_count]
exact le_count_iff_replicate_sublist.trans replicate_le_coe.symm
#align multiset.le_count_iff_replicate_le Multiset.le_count_iff_replicate_le
@[simp]
theorem count_filter_of_pos {p} [DecidablePred p] {a} {s : Multiset α} (h : p a) :
count a (filter p s) = count a s :=
Quot.inductionOn s fun _l => by
simp only [quot_mk_to_coe'', filter_coe, mem_coe, coe_count, decide_eq_true_eq]
apply count_filter
simpa using h
#align multiset.count_filter_of_pos Multiset.count_filter_of_pos
@[simp]
theorem count_filter_of_neg {p} [DecidablePred p] {a} {s : Multiset α} (h : ¬p a) :
count a (filter p s) = 0 :=
Multiset.count_eq_zero_of_not_mem fun t => h (of_mem_filter t)
#align multiset.count_filter_of_neg Multiset.count_filter_of_neg
theorem count_filter {p} [DecidablePred p] {a} {s : Multiset α} :
count a (filter p s) = if p a then count a s else 0 := by
split_ifs with h
· exact count_filter_of_pos h
· exact count_filter_of_neg h
#align multiset.count_filter Multiset.count_filter
theorem ext {s t : Multiset α} : s = t ↔ ∀ a, count a s = count a t :=
Quotient.inductionOn₂ s t fun _l₁ _l₂ => Quotient.eq.trans <| by
simp only [quot_mk_to_coe, filter_coe, mem_coe, coe_count, decide_eq_true_eq]
apply perm_iff_count
#align multiset.ext Multiset.ext
@[ext]
theorem ext' {s t : Multiset α} : (∀ a, count a s = count a t) → s = t :=
ext.2
#align multiset.ext' Multiset.ext'
@[simp]
theorem coe_inter (s t : List α) : (s ∩ t : Multiset α) = (s.bagInter t : List α) := by ext; simp
#align multiset.coe_inter Multiset.coe_inter
theorem le_iff_count {s t : Multiset α} : s ≤ t ↔ ∀ a, count a s ≤ count a t :=
⟨fun h a => count_le_of_le a h, fun al => by
rw [← (ext.2 fun a => by simp [max_eq_right (al a)] : s ∪ t = t)]; apply le_union_left⟩
#align multiset.le_iff_count Multiset.le_iff_count
instance : DistribLattice (Multiset α) :=
{ le_sup_inf := fun s t u =>
le_of_eq <|
Eq.symm <|
ext.2 fun a => by
simp only [max_min_distrib_left, Multiset.count_inter, Multiset.sup_eq_union,
Multiset.count_union, Multiset.inf_eq_inter] }
| Mathlib/Data/Multiset/Basic.lean | 2,625 | 2,627 | theorem count_map {α β : Type*} (f : α → β) (s : Multiset α) [DecidableEq β] (b : β) :
count b (map f s) = card (s.filter fun a => b = f a) := by |
simp [Bool.beq_eq_decide_eq, eq_comm, count, countP_map]
|
import Mathlib.Algebra.Field.Basic
import Mathlib.Algebra.GroupWithZero.Units.Equiv
import Mathlib.Algebra.Order.Field.Defs
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Order.Bounds.OrderIso
import Mathlib.Tactic.Positivity.Core
#align_import algebra.order.field.basic from "leanprover-community/mathlib"@"84771a9f5f0bd5e5d6218811556508ddf476dcbd"
open Function OrderDual
variable {ι α β : Type*}
section
variable [LinearOrderedField α] {a b c d : α} {n : ℤ}
theorem div_pos_iff : 0 < a / b ↔ 0 < a ∧ 0 < b ∨ a < 0 ∧ b < 0 := by
simp only [division_def, mul_pos_iff, inv_pos, inv_lt_zero]
#align div_pos_iff div_pos_iff
theorem div_neg_iff : a / b < 0 ↔ 0 < a ∧ b < 0 ∨ a < 0 ∧ 0 < b := by
simp [division_def, mul_neg_iff]
#align div_neg_iff div_neg_iff
theorem div_nonneg_iff : 0 ≤ a / b ↔ 0 ≤ a ∧ 0 ≤ b ∨ a ≤ 0 ∧ b ≤ 0 := by
simp [division_def, mul_nonneg_iff]
#align div_nonneg_iff div_nonneg_iff
theorem div_nonpos_iff : a / b ≤ 0 ↔ 0 ≤ a ∧ b ≤ 0 ∨ a ≤ 0 ∧ 0 ≤ b := by
simp [division_def, mul_nonpos_iff]
#align div_nonpos_iff div_nonpos_iff
theorem div_nonneg_of_nonpos (ha : a ≤ 0) (hb : b ≤ 0) : 0 ≤ a / b :=
div_nonneg_iff.2 <| Or.inr ⟨ha, hb⟩
#align div_nonneg_of_nonpos div_nonneg_of_nonpos
theorem div_pos_of_neg_of_neg (ha : a < 0) (hb : b < 0) : 0 < a / b :=
div_pos_iff.2 <| Or.inr ⟨ha, hb⟩
#align div_pos_of_neg_of_neg div_pos_of_neg_of_neg
theorem div_neg_of_neg_of_pos (ha : a < 0) (hb : 0 < b) : a / b < 0 :=
div_neg_iff.2 <| Or.inr ⟨ha, hb⟩
#align div_neg_of_neg_of_pos div_neg_of_neg_of_pos
theorem div_neg_of_pos_of_neg (ha : 0 < a) (hb : b < 0) : a / b < 0 :=
div_neg_iff.2 <| Or.inl ⟨ha, hb⟩
#align div_neg_of_pos_of_neg div_neg_of_pos_of_neg
theorem div_le_iff_of_neg (hc : c < 0) : b / c ≤ a ↔ a * c ≤ b :=
⟨fun h => div_mul_cancel₀ b (ne_of_lt hc) ▸ mul_le_mul_of_nonpos_right h hc.le, fun h =>
calc
a = a * c * (1 / c) := mul_mul_div a (ne_of_lt hc)
_ ≥ b * (1 / c) := mul_le_mul_of_nonpos_right h (one_div_neg.2 hc).le
_ = b / c := (div_eq_mul_one_div b c).symm
⟩
#align div_le_iff_of_neg div_le_iff_of_neg
theorem div_le_iff_of_neg' (hc : c < 0) : b / c ≤ a ↔ c * a ≤ b := by
rw [mul_comm, div_le_iff_of_neg hc]
#align div_le_iff_of_neg' div_le_iff_of_neg'
theorem le_div_iff_of_neg (hc : c < 0) : a ≤ b / c ↔ b ≤ a * c := by
rw [← neg_neg c, mul_neg, div_neg, le_neg, div_le_iff (neg_pos.2 hc), neg_mul]
#align le_div_iff_of_neg le_div_iff_of_neg
theorem le_div_iff_of_neg' (hc : c < 0) : a ≤ b / c ↔ b ≤ c * a := by
rw [mul_comm, le_div_iff_of_neg hc]
#align le_div_iff_of_neg' le_div_iff_of_neg'
theorem div_lt_iff_of_neg (hc : c < 0) : b / c < a ↔ a * c < b :=
lt_iff_lt_of_le_iff_le <| le_div_iff_of_neg hc
#align div_lt_iff_of_neg div_lt_iff_of_neg
theorem div_lt_iff_of_neg' (hc : c < 0) : b / c < a ↔ c * a < b := by
rw [mul_comm, div_lt_iff_of_neg hc]
#align div_lt_iff_of_neg' div_lt_iff_of_neg'
theorem lt_div_iff_of_neg (hc : c < 0) : a < b / c ↔ b < a * c :=
lt_iff_lt_of_le_iff_le <| div_le_iff_of_neg hc
#align lt_div_iff_of_neg lt_div_iff_of_neg
theorem lt_div_iff_of_neg' (hc : c < 0) : a < b / c ↔ b < c * a := by
rw [mul_comm, lt_div_iff_of_neg hc]
#align lt_div_iff_of_neg' lt_div_iff_of_neg'
theorem div_le_one_of_ge (h : b ≤ a) (hb : b ≤ 0) : a / b ≤ 1 := by
simpa only [neg_div_neg_eq] using div_le_one_of_le (neg_le_neg h) (neg_nonneg_of_nonpos hb)
#align div_le_one_of_ge div_le_one_of_ge
theorem inv_le_inv_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ ≤ b⁻¹ ↔ b ≤ a := by
rw [← one_div, div_le_iff_of_neg ha, ← div_eq_inv_mul, div_le_iff_of_neg hb, one_mul]
#align inv_le_inv_of_neg inv_le_inv_of_neg
theorem inv_le_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ ≤ b ↔ b⁻¹ ≤ a := by
rw [← inv_le_inv_of_neg hb (inv_lt_zero.2 ha), inv_inv]
#align inv_le_of_neg inv_le_of_neg
theorem le_inv_of_neg (ha : a < 0) (hb : b < 0) : a ≤ b⁻¹ ↔ b ≤ a⁻¹ := by
rw [← inv_le_inv_of_neg (inv_lt_zero.2 hb) ha, inv_inv]
#align le_inv_of_neg le_inv_of_neg
theorem inv_lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ < b⁻¹ ↔ b < a :=
lt_iff_lt_of_le_iff_le (inv_le_inv_of_neg hb ha)
#align inv_lt_inv_of_neg inv_lt_inv_of_neg
theorem inv_lt_of_neg (ha : a < 0) (hb : b < 0) : a⁻¹ < b ↔ b⁻¹ < a :=
lt_iff_lt_of_le_iff_le (le_inv_of_neg hb ha)
#align inv_lt_of_neg inv_lt_of_neg
theorem lt_inv_of_neg (ha : a < 0) (hb : b < 0) : a < b⁻¹ ↔ b < a⁻¹ :=
lt_iff_lt_of_le_iff_le (inv_le_of_neg hb ha)
#align lt_inv_of_neg lt_inv_of_neg
theorem sub_inv_antitoneOn_Ioi :
AntitoneOn (fun x ↦ (x-c)⁻¹) (Set.Ioi c) :=
antitoneOn_iff_forall_lt.mpr fun _ ha _ hb hab ↦
inv_le_inv (sub_pos.mpr hb) (sub_pos.mpr ha) |>.mpr <| sub_le_sub (le_of_lt hab) le_rfl
theorem sub_inv_antitoneOn_Iio :
AntitoneOn (fun x ↦ (x-c)⁻¹) (Set.Iio c) :=
antitoneOn_iff_forall_lt.mpr fun _ ha _ hb hab ↦
inv_le_inv_of_neg (sub_neg.mpr hb) (sub_neg.mpr ha) |>.mpr <| sub_le_sub (le_of_lt hab) le_rfl
theorem sub_inv_antitoneOn_Icc_right (ha : c < a) :
AntitoneOn (fun x ↦ (x-c)⁻¹) (Set.Icc a b) := by
by_cases hab : a ≤ b
· exact sub_inv_antitoneOn_Ioi.mono <| (Set.Icc_subset_Ioi_iff hab).mpr ha
· simp [hab, Set.Subsingleton.antitoneOn]
theorem sub_inv_antitoneOn_Icc_left (ha : b < c) :
AntitoneOn (fun x ↦ (x-c)⁻¹) (Set.Icc a b) := by
by_cases hab : a ≤ b
· exact sub_inv_antitoneOn_Iio.mono <| (Set.Icc_subset_Iio_iff hab).mpr ha
· simp [hab, Set.Subsingleton.antitoneOn]
theorem inv_antitoneOn_Ioi :
AntitoneOn (fun x:α ↦ x⁻¹) (Set.Ioi 0) := by
convert sub_inv_antitoneOn_Ioi
exact (sub_zero _).symm
theorem inv_antitoneOn_Iio :
AntitoneOn (fun x:α ↦ x⁻¹) (Set.Iio 0) := by
convert sub_inv_antitoneOn_Iio
exact (sub_zero _).symm
theorem inv_antitoneOn_Icc_right (ha : 0 < a) :
AntitoneOn (fun x:α ↦ x⁻¹) (Set.Icc a b) := by
convert sub_inv_antitoneOn_Icc_right ha
exact (sub_zero _).symm
theorem inv_antitoneOn_Icc_left (hb : b < 0) :
AntitoneOn (fun x:α ↦ x⁻¹) (Set.Icc a b) := by
convert sub_inv_antitoneOn_Icc_left hb
exact (sub_zero _).symm
theorem div_le_div_of_nonpos_of_le (hc : c ≤ 0) (h : b ≤ a) : a / c ≤ b / c := by
rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]
exact mul_le_mul_of_nonpos_right h (one_div_nonpos.2 hc)
#align div_le_div_of_nonpos_of_le div_le_div_of_nonpos_of_le
theorem div_lt_div_of_neg_of_lt (hc : c < 0) (h : b < a) : a / c < b / c := by
rw [div_eq_mul_one_div a c, div_eq_mul_one_div b c]
exact mul_lt_mul_of_neg_right h (one_div_neg.2 hc)
#align div_lt_div_of_neg_of_lt div_lt_div_of_neg_of_lt
theorem div_le_div_right_of_neg (hc : c < 0) : a / c ≤ b / c ↔ b ≤ a :=
⟨le_imp_le_of_lt_imp_lt <| div_lt_div_of_neg_of_lt hc, div_le_div_of_nonpos_of_le <| hc.le⟩
#align div_le_div_right_of_neg div_le_div_right_of_neg
theorem div_lt_div_right_of_neg (hc : c < 0) : a / c < b / c ↔ b < a :=
lt_iff_lt_of_le_iff_le <| div_le_div_right_of_neg hc
#align div_lt_div_right_of_neg div_lt_div_right_of_neg
theorem one_le_div_of_neg (hb : b < 0) : 1 ≤ a / b ↔ a ≤ b := by rw [le_div_iff_of_neg hb, one_mul]
#align one_le_div_of_neg one_le_div_of_neg
theorem div_le_one_of_neg (hb : b < 0) : a / b ≤ 1 ↔ b ≤ a := by rw [div_le_iff_of_neg hb, one_mul]
#align div_le_one_of_neg div_le_one_of_neg
theorem one_lt_div_of_neg (hb : b < 0) : 1 < a / b ↔ a < b := by rw [lt_div_iff_of_neg hb, one_mul]
#align one_lt_div_of_neg one_lt_div_of_neg
theorem div_lt_one_of_neg (hb : b < 0) : a / b < 1 ↔ b < a := by rw [div_lt_iff_of_neg hb, one_mul]
#align div_lt_one_of_neg div_lt_one_of_neg
theorem one_div_le_of_neg (ha : a < 0) (hb : b < 0) : 1 / a ≤ b ↔ 1 / b ≤ a := by
simpa using inv_le_of_neg ha hb
#align one_div_le_of_neg one_div_le_of_neg
theorem one_div_lt_of_neg (ha : a < 0) (hb : b < 0) : 1 / a < b ↔ 1 / b < a := by
simpa using inv_lt_of_neg ha hb
#align one_div_lt_of_neg one_div_lt_of_neg
theorem le_one_div_of_neg (ha : a < 0) (hb : b < 0) : a ≤ 1 / b ↔ b ≤ 1 / a := by
simpa using le_inv_of_neg ha hb
#align le_one_div_of_neg le_one_div_of_neg
theorem lt_one_div_of_neg (ha : a < 0) (hb : b < 0) : a < 1 / b ↔ b < 1 / a := by
simpa using lt_inv_of_neg ha hb
#align lt_one_div_of_neg lt_one_div_of_neg
theorem one_lt_div_iff : 1 < a / b ↔ 0 < b ∧ b < a ∨ b < 0 ∧ a < b := by
rcases lt_trichotomy b 0 with (hb | rfl | hb)
· simp [hb, hb.not_lt, one_lt_div_of_neg]
· simp [lt_irrefl, zero_le_one]
· simp [hb, hb.not_lt, one_lt_div]
#align one_lt_div_iff one_lt_div_iff
theorem one_le_div_iff : 1 ≤ a / b ↔ 0 < b ∧ b ≤ a ∨ b < 0 ∧ a ≤ b := by
rcases lt_trichotomy b 0 with (hb | rfl | hb)
· simp [hb, hb.not_lt, one_le_div_of_neg]
· simp [lt_irrefl, zero_lt_one.not_le, zero_lt_one]
· simp [hb, hb.not_lt, one_le_div]
#align one_le_div_iff one_le_div_iff
theorem div_lt_one_iff : a / b < 1 ↔ 0 < b ∧ a < b ∨ b = 0 ∨ b < 0 ∧ b < a := by
rcases lt_trichotomy b 0 with (hb | rfl | hb)
· simp [hb, hb.not_lt, hb.ne, div_lt_one_of_neg]
· simp [zero_lt_one]
· simp [hb, hb.not_lt, div_lt_one, hb.ne.symm]
#align div_lt_one_iff div_lt_one_iff
theorem div_le_one_iff : a / b ≤ 1 ↔ 0 < b ∧ a ≤ b ∨ b = 0 ∨ b < 0 ∧ b ≤ a := by
rcases lt_trichotomy b 0 with (hb | rfl | hb)
· simp [hb, hb.not_lt, hb.ne, div_le_one_of_neg]
· simp [zero_le_one]
· simp [hb, hb.not_lt, div_le_one, hb.ne.symm]
#align div_le_one_iff div_le_one_iff
theorem one_div_le_one_div_of_neg_of_le (hb : b < 0) (h : a ≤ b) : 1 / b ≤ 1 / a := by
rwa [div_le_iff_of_neg' hb, ← div_eq_mul_one_div, div_le_one_of_neg (h.trans_lt hb)]
#align one_div_le_one_div_of_neg_of_le one_div_le_one_div_of_neg_of_le
theorem one_div_lt_one_div_of_neg_of_lt (hb : b < 0) (h : a < b) : 1 / b < 1 / a := by
rwa [div_lt_iff_of_neg' hb, ← div_eq_mul_one_div, div_lt_one_of_neg (h.trans hb)]
#align one_div_lt_one_div_of_neg_of_lt one_div_lt_one_div_of_neg_of_lt
theorem le_of_neg_of_one_div_le_one_div (hb : b < 0) (h : 1 / a ≤ 1 / b) : b ≤ a :=
le_imp_le_of_lt_imp_lt (one_div_lt_one_div_of_neg_of_lt hb) h
#align le_of_neg_of_one_div_le_one_div le_of_neg_of_one_div_le_one_div
theorem lt_of_neg_of_one_div_lt_one_div (hb : b < 0) (h : 1 / a < 1 / b) : b < a :=
lt_imp_lt_of_le_imp_le (one_div_le_one_div_of_neg_of_le hb) h
#align lt_of_neg_of_one_div_lt_one_div lt_of_neg_of_one_div_lt_one_div
theorem one_div_le_one_div_of_neg (ha : a < 0) (hb : b < 0) : 1 / a ≤ 1 / b ↔ b ≤ a := by
simpa [one_div] using inv_le_inv_of_neg ha hb
#align one_div_le_one_div_of_neg one_div_le_one_div_of_neg
theorem one_div_lt_one_div_of_neg (ha : a < 0) (hb : b < 0) : 1 / a < 1 / b ↔ b < a :=
lt_iff_lt_of_le_iff_le (one_div_le_one_div_of_neg hb ha)
#align one_div_lt_one_div_of_neg one_div_lt_one_div_of_neg
theorem one_div_lt_neg_one (h1 : a < 0) (h2 : -1 < a) : 1 / a < -1 :=
suffices 1 / a < 1 / -1 by rwa [one_div_neg_one_eq_neg_one] at this
one_div_lt_one_div_of_neg_of_lt h1 h2
#align one_div_lt_neg_one one_div_lt_neg_one
theorem one_div_le_neg_one (h1 : a < 0) (h2 : -1 ≤ a) : 1 / a ≤ -1 :=
suffices 1 / a ≤ 1 / -1 by rwa [one_div_neg_one_eq_neg_one] at this
one_div_le_one_div_of_neg_of_le h1 h2
#align one_div_le_neg_one one_div_le_neg_one
theorem sub_self_div_two (a : α) : a - a / 2 = a / 2 := by
suffices a / 2 + a / 2 - a / 2 = a / 2 by rwa [add_halves] at this
rw [add_sub_cancel_right]
#align sub_self_div_two sub_self_div_two
theorem div_two_sub_self (a : α) : a / 2 - a = -(a / 2) := by
suffices a / 2 - (a / 2 + a / 2) = -(a / 2) by rwa [add_halves] at this
rw [sub_add_eq_sub_sub, sub_self, zero_sub]
#align div_two_sub_self div_two_sub_self
theorem add_sub_div_two_lt (h : a < b) : a + (b - a) / 2 < b := by
rwa [← div_sub_div_same, sub_eq_add_neg, add_comm (b / 2), ← add_assoc, ← sub_eq_add_neg, ←
lt_sub_iff_add_lt, sub_self_div_two, sub_self_div_two, div_lt_div_right (zero_lt_two' α)]
#align add_sub_div_two_lt add_sub_div_two_lt
| Mathlib/Algebra/Order/Field/Basic.lean | 920 | 928 | theorem sub_one_div_inv_le_two (a2 : 2 ≤ a) : (1 - 1 / a)⁻¹ ≤ 2 := by |
-- Take inverses on both sides to obtain `2⁻¹ ≤ 1 - 1 / a`
refine (inv_le_inv_of_le (inv_pos.2 <| zero_lt_two' α) ?_).trans_eq (inv_inv (2 : α))
-- move `1 / a` to the left and `2⁻¹` to the right.
rw [le_sub_iff_add_le, add_comm, ← le_sub_iff_add_le]
-- take inverses on both sides and use the assumption `2 ≤ a`.
convert (one_div a).le.trans (inv_le_inv_of_le zero_lt_two a2) using 1
-- show `1 - 1 / 2 = 1 / 2`.
rw [sub_eq_iff_eq_add, ← two_mul, mul_inv_cancel two_ne_zero]
|
import Mathlib.Algebra.MvPolynomial.Monad
#align_import data.mv_polynomial.expand from "leanprover-community/mathlib"@"5da451b4c96b4c2e122c0325a7fce17d62ee46c6"
namespace MvPolynomial
variable {σ τ R S : Type*} [CommSemiring R] [CommSemiring S]
noncomputable def expand (p : ℕ) : MvPolynomial σ R →ₐ[R] MvPolynomial σ R :=
{ (eval₂Hom C fun i ↦ X i ^ p : MvPolynomial σ R →+* MvPolynomial σ R) with
commutes' := fun _ ↦ eval₂Hom_C _ _ _ }
#align mv_polynomial.expand MvPolynomial.expand
-- @[simp] -- Porting note (#10618): simp can prove this
theorem expand_C (p : ℕ) (r : R) : expand p (C r : MvPolynomial σ R) = C r :=
eval₂Hom_C _ _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.expand_C MvPolynomial.expand_C
@[simp]
theorem expand_X (p : ℕ) (i : σ) : expand p (X i : MvPolynomial σ R) = X i ^ p :=
eval₂Hom_X' _ _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.expand_X MvPolynomial.expand_X
@[simp]
theorem expand_monomial (p : ℕ) (d : σ →₀ ℕ) (r : R) :
expand p (monomial d r) = C r * ∏ i ∈ d.support, (X i ^ p) ^ d i :=
bind₁_monomial _ _ _
#align mv_polynomial.expand_monomial MvPolynomial.expand_monomial
theorem expand_one_apply (f : MvPolynomial σ R) : expand 1 f = f := by
simp only [expand, pow_one, eval₂Hom_eq_bind₂, bind₂_C_left, RingHom.toMonoidHom_eq_coe,
RingHom.coe_monoidHom_id, AlgHom.coe_mk, RingHom.coe_mk, MonoidHom.id_apply, RingHom.id_apply]
#align mv_polynomial.expand_one_apply MvPolynomial.expand_one_apply
@[simp]
theorem expand_one : expand 1 = AlgHom.id R (MvPolynomial σ R) := by
ext1 f
rw [expand_one_apply, AlgHom.id_apply]
#align mv_polynomial.expand_one MvPolynomial.expand_one
| Mathlib/Algebra/MvPolynomial/Expand.lean | 64 | 68 | theorem expand_comp_bind₁ (p : ℕ) (f : σ → MvPolynomial τ R) :
(expand p).comp (bind₁ f) = bind₁ fun i ↦ expand p (f i) := by |
apply algHom_ext
intro i
simp only [AlgHom.comp_apply, bind₁_X_right]
|
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Algebra.MonoidAlgebra.Basic
import Mathlib.Data.Finset.Sort
#align_import data.polynomial.basic from "leanprover-community/mathlib"@"949dc57e616a621462062668c9f39e4e17b64b69"
set_option linter.uppercaseLean3 false
noncomputable section
structure Polynomial (R : Type*) [Semiring R] where ofFinsupp ::
toFinsupp : AddMonoidAlgebra R ℕ
#align polynomial Polynomial
#align polynomial.of_finsupp Polynomial.ofFinsupp
#align polynomial.to_finsupp Polynomial.toFinsupp
@[inherit_doc] scoped[Polynomial] notation:9000 R "[X]" => Polynomial R
open AddMonoidAlgebra
open Finsupp hiding single
open Function hiding Commute
open Polynomial
namespace Polynomial
universe u
variable {R : Type u} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q : R[X]}
theorem forall_iff_forall_finsupp (P : R[X] → Prop) :
(∀ p, P p) ↔ ∀ q : R[ℕ], P ⟨q⟩ :=
⟨fun h q => h ⟨q⟩, fun h ⟨p⟩ => h p⟩
#align polynomial.forall_iff_forall_finsupp Polynomial.forall_iff_forall_finsupp
theorem exists_iff_exists_finsupp (P : R[X] → Prop) :
(∃ p, P p) ↔ ∃ q : R[ℕ], P ⟨q⟩ :=
⟨fun ⟨⟨p⟩, hp⟩ => ⟨p, hp⟩, fun ⟨q, hq⟩ => ⟨⟨q⟩, hq⟩⟩
#align polynomial.exists_iff_exists_finsupp Polynomial.exists_iff_exists_finsupp
@[simp]
theorem eta (f : R[X]) : Polynomial.ofFinsupp f.toFinsupp = f := by cases f; rfl
#align polynomial.eta Polynomial.eta
theorem ofFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[ℕ]) :
(⟨∑ i ∈ s, f i⟩ : R[X]) = ∑ i ∈ s, ⟨f i⟩ :=
map_sum (toFinsuppIso R).symm f s
#align polynomial.of_finsupp_sum Polynomial.ofFinsupp_sum
theorem toFinsupp_sum {ι : Type*} (s : Finset ι) (f : ι → R[X]) :
(∑ i ∈ s, f i : R[X]).toFinsupp = ∑ i ∈ s, (f i).toFinsupp :=
map_sum (toFinsuppIso R) f s
#align polynomial.to_finsupp_sum Polynomial.toFinsupp_sum
-- @[simp] -- Porting note: The original generated theorem is same to `support_ofFinsupp` and
-- the new generated theorem is different, so this attribute should be
-- removed.
def support : R[X] → Finset ℕ
| ⟨p⟩ => p.support
#align polynomial.support Polynomial.support
@[simp]
theorem support_ofFinsupp (p) : support (⟨p⟩ : R[X]) = p.support := by rw [support]
#align polynomial.support_of_finsupp Polynomial.support_ofFinsupp
theorem support_toFinsupp (p : R[X]) : p.toFinsupp.support = p.support := by rw [support]
@[simp]
theorem support_zero : (0 : R[X]).support = ∅ :=
rfl
#align polynomial.support_zero Polynomial.support_zero
@[simp]
theorem support_eq_empty : p.support = ∅ ↔ p = 0 := by
rcases p with ⟨⟩
simp [support]
#align polynomial.support_eq_empty Polynomial.support_eq_empty
@[simp] lemma support_nonempty : p.support.Nonempty ↔ p ≠ 0 :=
Finset.nonempty_iff_ne_empty.trans support_eq_empty.not
theorem card_support_eq_zero : p.support.card = 0 ↔ p = 0 := by simp
#align polynomial.card_support_eq_zero Polynomial.card_support_eq_zero
def monomial (n : ℕ) : R →ₗ[R] R[X] where
toFun t := ⟨Finsupp.single n t⟩
-- porting note (#10745): was `simp`.
map_add' x y := by simp; rw [ofFinsupp_add]
-- porting note (#10745): was `simp [← ofFinsupp_smul]`.
map_smul' r x := by simp; rw [← ofFinsupp_smul, smul_single']
#align polynomial.monomial Polynomial.monomial
@[simp]
theorem toFinsupp_monomial (n : ℕ) (r : R) : (monomial n r).toFinsupp = Finsupp.single n r := by
simp [monomial]
#align polynomial.to_finsupp_monomial Polynomial.toFinsupp_monomial
@[simp]
theorem ofFinsupp_single (n : ℕ) (r : R) : (⟨Finsupp.single n r⟩ : R[X]) = monomial n r := by
simp [monomial]
#align polynomial.of_finsupp_single Polynomial.ofFinsupp_single
-- @[simp] -- Porting note (#10618): simp can prove this
theorem monomial_zero_right (n : ℕ) : monomial n (0 : R) = 0 :=
(monomial n).map_zero
#align polynomial.monomial_zero_right Polynomial.monomial_zero_right
-- This is not a `simp` lemma as `monomial_zero_left` is more general.
theorem monomial_zero_one : monomial 0 (1 : R) = 1 :=
rfl
#align polynomial.monomial_zero_one Polynomial.monomial_zero_one
-- TODO: can't we just delete this one?
theorem monomial_add (n : ℕ) (r s : R) : monomial n (r + s) = monomial n r + monomial n s :=
(monomial n).map_add _ _
#align polynomial.monomial_add Polynomial.monomial_add
theorem monomial_mul_monomial (n m : ℕ) (r s : R) :
monomial n r * monomial m s = monomial (n + m) (r * s) :=
toFinsupp_injective <| by
simp only [toFinsupp_monomial, toFinsupp_mul, AddMonoidAlgebra.single_mul_single]
#align polynomial.monomial_mul_monomial Polynomial.monomial_mul_monomial
@[simp]
theorem monomial_pow (n : ℕ) (r : R) (k : ℕ) : monomial n r ^ k = monomial (n * k) (r ^ k) := by
induction' k with k ih
· simp [pow_zero, monomial_zero_one]
· simp [pow_succ, ih, monomial_mul_monomial, Nat.succ_eq_add_one, mul_add, add_comm]
#align polynomial.monomial_pow Polynomial.monomial_pow
theorem smul_monomial {S} [SMulZeroClass S R] (a : S) (n : ℕ) (b : R) :
a • monomial n b = monomial n (a • b) :=
toFinsupp_injective <| by simp; rw [smul_single]
#align polynomial.smul_monomial Polynomial.smul_monomial
theorem monomial_injective (n : ℕ) : Function.Injective (monomial n : R → R[X]) :=
(toFinsuppIso R).symm.injective.comp (single_injective n)
#align polynomial.monomial_injective Polynomial.monomial_injective
@[simp]
theorem monomial_eq_zero_iff (t : R) (n : ℕ) : monomial n t = 0 ↔ t = 0 :=
LinearMap.map_eq_zero_iff _ (Polynomial.monomial_injective n)
#align polynomial.monomial_eq_zero_iff Polynomial.monomial_eq_zero_iff
theorem support_add : (p + q).support ⊆ p.support ∪ q.support := by
simpa [support] using Finsupp.support_add
#align polynomial.support_add Polynomial.support_add
def C : R →+* R[X] :=
{ monomial 0 with
map_one' := by simp [monomial_zero_one]
map_mul' := by simp [monomial_mul_monomial]
map_zero' := by simp }
#align polynomial.C Polynomial.C
@[simp]
theorem monomial_zero_left (a : R) : monomial 0 a = C a :=
rfl
#align polynomial.monomial_zero_left Polynomial.monomial_zero_left
@[simp]
theorem toFinsupp_C (a : R) : (C a).toFinsupp = single 0 a :=
rfl
#align polynomial.to_finsupp_C Polynomial.toFinsupp_C
theorem C_0 : C (0 : R) = 0 := by simp
#align polynomial.C_0 Polynomial.C_0
theorem C_1 : C (1 : R) = 1 :=
rfl
#align polynomial.C_1 Polynomial.C_1
theorem C_mul : C (a * b) = C a * C b :=
C.map_mul a b
#align polynomial.C_mul Polynomial.C_mul
theorem C_add : C (a + b) = C a + C b :=
C.map_add a b
#align polynomial.C_add Polynomial.C_add
@[simp]
theorem smul_C {S} [SMulZeroClass S R] (s : S) (r : R) : s • C r = C (s • r) :=
smul_monomial _ _ r
#align polynomial.smul_C Polynomial.smul_C
set_option linter.deprecated false in
-- @[simp] -- Porting note (#10618): simp can prove this
theorem C_bit0 : C (bit0 a) = bit0 (C a) :=
C_add
#align polynomial.C_bit0 Polynomial.C_bit0
set_option linter.deprecated false in
-- @[simp] -- Porting note (#10618): simp can prove this
theorem C_bit1 : C (bit1 a) = bit1 (C a) := by simp [bit1, C_bit0]
#align polynomial.C_bit1 Polynomial.C_bit1
theorem C_pow : C (a ^ n) = C a ^ n :=
C.map_pow a n
#align polynomial.C_pow Polynomial.C_pow
-- @[simp] -- Porting note (#10618): simp can prove this
theorem C_eq_natCast (n : ℕ) : C (n : R) = (n : R[X]) :=
map_natCast C n
#align polynomial.C_eq_nat_cast Polynomial.C_eq_natCast
@[deprecated (since := "2024-04-17")]
alias C_eq_nat_cast := C_eq_natCast
@[simp]
theorem C_mul_monomial : C a * monomial n b = monomial n (a * b) := by
simp only [← monomial_zero_left, monomial_mul_monomial, zero_add]
#align polynomial.C_mul_monomial Polynomial.C_mul_monomial
@[simp]
theorem monomial_mul_C : monomial n a * C b = monomial n (a * b) := by
simp only [← monomial_zero_left, monomial_mul_monomial, add_zero]
#align polynomial.monomial_mul_C Polynomial.monomial_mul_C
def X : R[X] :=
monomial 1 1
#align polynomial.X Polynomial.X
theorem monomial_one_one_eq_X : monomial 1 (1 : R) = X :=
rfl
#align polynomial.monomial_one_one_eq_X Polynomial.monomial_one_one_eq_X
theorem monomial_one_right_eq_X_pow (n : ℕ) : monomial n (1 : R) = X ^ n := by
induction' n with n ih
· simp [monomial_zero_one]
· rw [pow_succ, ← ih, ← monomial_one_one_eq_X, monomial_mul_monomial, mul_one]
#align polynomial.monomial_one_right_eq_X_pow Polynomial.monomial_one_right_eq_X_pow
@[simp]
theorem toFinsupp_X : X.toFinsupp = Finsupp.single 1 (1 : R) :=
rfl
#align polynomial.to_finsupp_X Polynomial.toFinsupp_X
theorem X_mul : X * p = p * X := by
rcases p with ⟨⟩
-- Porting note: `ofFinsupp.injEq` is required.
simp only [X, ← ofFinsupp_single, ← ofFinsupp_mul, LinearMap.coe_mk, ofFinsupp.injEq]
-- Porting note: Was `ext`.
refine Finsupp.ext fun _ => ?_
simp [AddMonoidAlgebra.mul_apply, AddMonoidAlgebra.sum_single_index, add_comm]
#align polynomial.X_mul Polynomial.X_mul
theorem X_pow_mul {n : ℕ} : X ^ n * p = p * X ^ n := by
induction' n with n ih
· simp
· conv_lhs => rw [pow_succ]
rw [mul_assoc, X_mul, ← mul_assoc, ih, mul_assoc, ← pow_succ]
#align polynomial.X_pow_mul Polynomial.X_pow_mul
@[simp]
theorem X_mul_C (r : R) : X * C r = C r * X :=
X_mul
#align polynomial.X_mul_C Polynomial.X_mul_C
@[simp]
theorem X_pow_mul_C (r : R) (n : ℕ) : X ^ n * C r = C r * X ^ n :=
X_pow_mul
#align polynomial.X_pow_mul_C Polynomial.X_pow_mul_C
theorem X_pow_mul_assoc {n : ℕ} : p * X ^ n * q = p * q * X ^ n := by
rw [mul_assoc, X_pow_mul, ← mul_assoc]
#align polynomial.X_pow_mul_assoc Polynomial.X_pow_mul_assoc
@[simp]
theorem X_pow_mul_assoc_C {n : ℕ} (r : R) : p * X ^ n * C r = p * C r * X ^ n :=
X_pow_mul_assoc
#align polynomial.X_pow_mul_assoc_C Polynomial.X_pow_mul_assoc_C
theorem commute_X (p : R[X]) : Commute X p :=
X_mul
#align polynomial.commute_X Polynomial.commute_X
theorem commute_X_pow (p : R[X]) (n : ℕ) : Commute (X ^ n) p :=
X_pow_mul
#align polynomial.commute_X_pow Polynomial.commute_X_pow
@[simp]
theorem monomial_mul_X (n : ℕ) (r : R) : monomial n r * X = monomial (n + 1) r := by
erw [monomial_mul_monomial, mul_one]
#align polynomial.monomial_mul_X Polynomial.monomial_mul_X
@[simp]
theorem monomial_mul_X_pow (n : ℕ) (r : R) (k : ℕ) :
monomial n r * X ^ k = monomial (n + k) r := by
induction' k with k ih
· simp
· simp [ih, pow_succ, ← mul_assoc, add_assoc, Nat.succ_eq_add_one]
#align polynomial.monomial_mul_X_pow Polynomial.monomial_mul_X_pow
@[simp]
theorem X_mul_monomial (n : ℕ) (r : R) : X * monomial n r = monomial (n + 1) r := by
rw [X_mul, monomial_mul_X]
#align polynomial.X_mul_monomial Polynomial.X_mul_monomial
@[simp]
theorem X_pow_mul_monomial (k n : ℕ) (r : R) : X ^ k * monomial n r = monomial (n + k) r := by
rw [X_pow_mul, monomial_mul_X_pow]
#align polynomial.X_pow_mul_monomial Polynomial.X_pow_mul_monomial
-- @[simp] -- Porting note: The original generated theorem is same to `coeff_ofFinsupp` and
-- the new generated theorem is different, so this attribute should be
-- removed.
def coeff : R[X] → ℕ → R
| ⟨p⟩ => p
#align polynomial.coeff Polynomial.coeff
-- Porting note (#10756): new theorem
@[simp]
theorem coeff_ofFinsupp (p) : coeff (⟨p⟩ : R[X]) = p := by rw [coeff]
theorem coeff_injective : Injective (coeff : R[X] → ℕ → R) := by
rintro ⟨p⟩ ⟨q⟩
-- Porting note: `ofFinsupp.injEq` is required.
simp only [coeff, DFunLike.coe_fn_eq, imp_self, ofFinsupp.injEq]
#align polynomial.coeff_injective Polynomial.coeff_injective
@[simp]
theorem coeff_inj : p.coeff = q.coeff ↔ p = q :=
coeff_injective.eq_iff
#align polynomial.coeff_inj Polynomial.coeff_inj
theorem toFinsupp_apply (f : R[X]) (i) : f.toFinsupp i = f.coeff i := by cases f; rfl
#align polynomial.to_finsupp_apply Polynomial.toFinsupp_apply
| Mathlib/Algebra/Polynomial/Basic.lean | 693 | 694 | theorem coeff_monomial : coeff (monomial n a) m = if n = m then a else 0 := by |
simp [coeff, Finsupp.single_apply]
|
import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.Algebra.Group.Submonoid.MulOpposite
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Data.Finset.NoncommProd
import Mathlib.Data.Int.Order.Lemmas
#align_import group_theory.submonoid.membership from "leanprover-community/mathlib"@"e655e4ea5c6d02854696f97494997ba4c31be802"
variable {M A B : Type*}
section Assoc
variable [Monoid M] [SetLike B M] [SubmonoidClass B M] {S : B}
section NonAssoc
variable [MulOneClass M]
open Set
namespace Submonoid
-- TODO: this section can be generalized to `[SubmonoidClass B M] [CompleteLattice B]`
-- such that `CompleteLattice.LE` coincides with `SetLike.LE`
@[to_additive]
theorem mem_iSup_of_directed {ι} [hι : Nonempty ι] {S : ι → Submonoid M} (hS : Directed (· ≤ ·) S)
{x : M} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
suffices x ∈ closure (⋃ i, (S i : Set M)) → ∃ i, x ∈ S i by
simpa only [closure_iUnion, closure_eq (S _)] using this
refine fun hx ↦ closure_induction hx (fun _ ↦ mem_iUnion.1) ?_ ?_
· exact hι.elim fun i ↦ ⟨i, (S i).one_mem⟩
· rintro x y ⟨i, hi⟩ ⟨j, hj⟩
rcases hS i j with ⟨k, hki, hkj⟩
exact ⟨k, (S k).mul_mem (hki hi) (hkj hj)⟩
#align submonoid.mem_supr_of_directed Submonoid.mem_iSup_of_directed
#align add_submonoid.mem_supr_of_directed AddSubmonoid.mem_iSup_of_directed
@[to_additive]
theorem coe_iSup_of_directed {ι} [Nonempty ι] {S : ι → Submonoid M} (hS : Directed (· ≤ ·) S) :
((⨆ i, S i : Submonoid M) : Set M) = ⋃ i, S i :=
Set.ext fun x ↦ by simp [mem_iSup_of_directed hS]
#align submonoid.coe_supr_of_directed Submonoid.coe_iSup_of_directed
#align add_submonoid.coe_supr_of_directed AddSubmonoid.coe_iSup_of_directed
@[to_additive]
theorem mem_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) {x : M} : x ∈ sSup S ↔ ∃ s ∈ S, x ∈ s := by
haveI : Nonempty S := Sne.to_subtype
simp [sSup_eq_iSup', mem_iSup_of_directed hS.directed_val, SetCoe.exists, Subtype.coe_mk]
#align submonoid.mem_Sup_of_directed_on Submonoid.mem_sSup_of_directedOn
#align add_submonoid.mem_Sup_of_directed_on AddSubmonoid.mem_sSup_of_directedOn
@[to_additive]
theorem coe_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) : (↑(sSup S) : Set M) = ⋃ s ∈ S, ↑s :=
Set.ext fun x => by simp [mem_sSup_of_directedOn Sne hS]
#align submonoid.coe_Sup_of_directed_on Submonoid.coe_sSup_of_directedOn
#align add_submonoid.coe_Sup_of_directed_on AddSubmonoid.coe_sSup_of_directedOn
@[to_additive]
theorem mem_sup_left {S T : Submonoid M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T := by
rw [← SetLike.le_def]
exact le_sup_left
#align submonoid.mem_sup_left Submonoid.mem_sup_left
#align add_submonoid.mem_sup_left AddSubmonoid.mem_sup_left
@[to_additive]
theorem mem_sup_right {S T : Submonoid M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T := by
rw [← SetLike.le_def]
exact le_sup_right
#align submonoid.mem_sup_right Submonoid.mem_sup_right
#align add_submonoid.mem_sup_right AddSubmonoid.mem_sup_right
@[to_additive]
theorem mul_mem_sup {S T : Submonoid M} {x y : M} (hx : x ∈ S) (hy : y ∈ T) : x * y ∈ S ⊔ T :=
(S ⊔ T).mul_mem (mem_sup_left hx) (mem_sup_right hy)
#align submonoid.mul_mem_sup Submonoid.mul_mem_sup
#align add_submonoid.add_mem_sup AddSubmonoid.add_mem_sup
@[to_additive]
| Mathlib/Algebra/Group/Submonoid/Membership.lean | 254 | 257 | theorem mem_iSup_of_mem {ι : Sort*} {S : ι → Submonoid M} (i : ι) :
∀ {x : M}, x ∈ S i → x ∈ iSup S := by |
rw [← SetLike.le_def]
exact le_iSup _ _
|
import Mathlib.Algebra.Ring.Int
import Mathlib.GroupTheory.PresentedGroup
import Mathlib.GroupTheory.Coxeter.Matrix
open Function Set List
section
variable {B : Type*} (M : CoxeterMatrix B)
@[ext]
structure CoxeterSystem (W : Type*) [Group W] where
mulEquiv : W ≃* M.Group
class IsCoxeterGroup.{u} (W : Type u) [Group W] : Prop where
nonempty_system : ∃ B : Type u, ∃ M : CoxeterMatrix B, Nonempty (CoxeterSystem M W)
def CoxeterMatrix.toCoxeterSystem : CoxeterSystem M M.Group := ⟨.refl _⟩
end
namespace CoxeterSystem
open CoxeterMatrix
variable {B B' : Type*} (e : B ≃ B')
variable {W H : Type*} [Group W] [Group H]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
@[simps]
protected def reindex (e : B ≃ B') : CoxeterSystem (M.reindex e) W :=
⟨cs.mulEquiv.trans (M.reindexGroupEquiv e).symm⟩
@[simps]
protected def map (e : W ≃* H) : CoxeterSystem M H := ⟨e.symm.trans cs.mulEquiv⟩
def simple (i : B) : W := cs.mulEquiv.symm (PresentedGroup.of i)
@[simp]
theorem _root_.CoxeterMatrix.toCoxeterSystem_simple (M : CoxeterMatrix B) :
M.toCoxeterSystem.simple = M.simple := rfl
@[simp] theorem reindex_simple (i' : B') : (cs.reindex e).simple i' = cs.simple (e.symm i') := rfl
@[simp] theorem map_simple (e : W ≃* H) (i : B) : (cs.map e).simple i = e (cs.simple i) := rfl
local prefix:100 "s" => cs.simple
@[simp]
theorem simple_mul_simple_self (i : B) : s i * s i = 1 := by
have : (FreeGroup.of i) * (FreeGroup.of i) ∈ M.relationsSet := ⟨(i, i), by simp [relation]⟩
have : (QuotientGroup.mk (FreeGroup.of i * FreeGroup.of i) : M.Group) = 1 :=
(QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this)
unfold simple
rw [← map_mul, PresentedGroup.of, ← QuotientGroup.mk_mul, this, map_one]
@[simp]
theorem simple_mul_simple_cancel_right {w : W} (i : B) : w * s i * s i = w := by
simp [mul_assoc]
@[simp]
theorem simple_mul_simple_cancel_left {w : W} (i : B) : s i * (s i * w) = w := by
simp [← mul_assoc]
@[simp] theorem simple_sq (i : B) : s i ^ 2 = 1 := pow_two (s i) ▸ cs.simple_mul_simple_self i
@[simp]
theorem inv_simple (i : B) : (s i)⁻¹ = s i :=
(eq_inv_of_mul_eq_one_right (cs.simple_mul_simple_self i)).symm
@[simp]
theorem simple_mul_simple_pow (i i' : B) : (s i * s i') ^ M i i' = 1 := by
have : (FreeGroup.of i * FreeGroup.of i') ^ M i i' ∈ M.relationsSet := ⟨(i, i'), rfl⟩
have : (QuotientGroup.mk ((FreeGroup.of i * FreeGroup.of i') ^ M i i') : M.Group) = 1 :=
(QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this)
unfold simple
rw [← map_mul, ← map_pow, PresentedGroup.of, PresentedGroup.of,
← QuotientGroup.mk_mul, ← QuotientGroup.mk_pow, this, map_one]
@[simp] theorem simple_mul_simple_pow' (i i' : B) : (s i' * s i) ^ M i i' = 1 :=
M.symmetric i' i ▸ cs.simple_mul_simple_pow i' i
theorem subgroup_closure_range_simple : Subgroup.closure (range cs.simple) = ⊤ := by
have : cs.simple = cs.mulEquiv.symm ∘ PresentedGroup.of := rfl
rw [this, Set.range_comp, ← MulEquiv.coe_toMonoidHom, ← MonoidHom.map_closure,
PresentedGroup.closure_range_of, ← MonoidHom.range_eq_map]
exact MonoidHom.range_top_of_surjective _ (MulEquiv.surjective _)
theorem submonoid_closure_range_simple : Submonoid.closure (range cs.simple) = ⊤ := by
have : range cs.simple = range cs.simple ∪ (range cs.simple)⁻¹ := by
simp_rw [inv_range, inv_simple, union_self]
rw [this, ← Subgroup.closure_toSubmonoid, subgroup_closure_range_simple, Subgroup.top_toSubmonoid]
theorem simple_induction {p : W → Prop} (w : W) (simple : ∀ i : B, p (s i)) (one : p 1)
(mul : ∀ w w' : W, p w → p w' → p (w * w')) : p w := by
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
exact Submonoid.closure_induction this (fun x ⟨i, hi⟩ ↦ hi ▸ simple i) one mul
theorem simple_induction_left {p : W → Prop} (w : W) (one : p 1)
(mul_simple_left : ∀ (w : W) (i : B), p w → p (s i * w)) : p w := by
let p' : (w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop :=
fun w _ ↦ p w
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
apply Submonoid.closure_induction_left (p := p')
· exact one
· rintro _ ⟨i, rfl⟩ y _
exact mul_simple_left y i
· exact this
theorem simple_induction_right {p : W → Prop} (w : W) (one : p 1)
(mul_simple_right : ∀ (w : W) (i : B), p w → p (w * s i)) : p w := by
let p' : ((w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop) :=
fun w _ ↦ p w
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
apply Submonoid.closure_induction_right (p := p')
· exact one
· rintro x _ _ ⟨i, rfl⟩
exact mul_simple_right x i
· exact this
theorem ext_simple {G : Type*} [Monoid G] {φ₁ φ₂ : W →* G} (h : ∀ i : B, φ₁ (s i) = φ₂ (s i)) :
φ₁ = φ₂ :=
MonoidHom.eq_of_eqOn_denseM cs.submonoid_closure_range_simple (fun _ ⟨i, hi⟩ ↦ hi ▸ h i)
def _root_.CoxeterMatrix.IsLiftable {G : Type*} [Monoid G] (M : CoxeterMatrix B) (f : B → G) :
Prop := ∀ i i', (f i * f i') ^ M i i' = 1
private theorem relations_liftable {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f)
(r : FreeGroup B) (hr : r ∈ M.relationsSet) : (FreeGroup.lift f) r = 1 := by
rcases hr with ⟨⟨i, i'⟩, rfl⟩
rw [uncurry, relation, map_pow, _root_.map_mul, FreeGroup.lift.of, FreeGroup.lift.of]
exact hf i i'
private def groupLift {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f) : W →* G :=
(PresentedGroup.toGroup (relations_liftable hf)).comp cs.mulEquiv.toMonoidHom
private def restrictUnit {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) :
Gˣ where
val := f i
inv := f i
val_inv := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i
inv_val := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i
private theorem toMonoidHom_apply_symm_apply (a : PresentedGroup (M.relationsSet)):
(MulEquiv.toMonoidHom cs.mulEquiv : W →* PresentedGroup (M.relationsSet))
((MulEquiv.symm cs.mulEquiv) a) = a := calc
_ = cs.mulEquiv ((MulEquiv.symm cs.mulEquiv) a) := by rfl
_ = _ := by rw [MulEquiv.apply_symm_apply]
def lift {G : Type*} [Monoid G] : {f : B → G // IsLiftable M f} ≃ (W →* G) where
toFun f := MonoidHom.comp (Units.coeHom G) (cs.groupLift
(show ∀ i i', ((restrictUnit f.property) i * (restrictUnit f.property) i') ^ M i i' = 1 from
fun i i' ↦ Units.ext (f.property i i')))
invFun ι := ⟨ι ∘ cs.simple, fun i i' ↦ by
rw [comp_apply, comp_apply, ← map_mul, ← map_pow, simple_mul_simple_pow, map_one]⟩
left_inv f := by
ext i
simp only [MonoidHom.comp_apply, comp_apply, mem_setOf_eq, groupLift, simple]
rw [← MonoidHom.toFun_eq_coe, toMonoidHom_apply_symm_apply, PresentedGroup.toGroup.of,
OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, Units.coeHom_apply, restrictUnit]
right_inv ι := by
apply cs.ext_simple
intro i
dsimp only
rw [groupLift, simple, MonoidHom.comp_apply, MonoidHom.comp_apply, toMonoidHom_apply_symm_apply,
PresentedGroup.toGroup.of, CoxeterSystem.restrictUnit, Units.coeHom_apply]
simp only [comp_apply, simple]
@[simp]
theorem lift_apply_simple {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) :
cs.lift ⟨f, hf⟩ (s i) = f i := congrFun (congrArg Subtype.val (cs.lift.left_inv ⟨f, hf⟩)) i
theorem simple_determines_coxeterSystem :
Injective (simple : CoxeterSystem M W → B → W) := by
intro cs1 cs2 h
apply CoxeterSystem.ext
apply MulEquiv.toMonoidHom_injective
apply cs1.ext_simple
intro i
nth_rw 2 [h]
simp [simple]
def wordProd (ω : List B) : W := prod (map cs.simple ω)
local prefix:100 "π" => cs.wordProd
@[simp] theorem wordProd_nil : π [] = 1 := by simp [wordProd]
theorem wordProd_cons (i : B) (ω : List B) : π (i :: ω) = s i * π ω := by simp [wordProd]
@[simp] theorem wordProd_singleton (i : B) : π ([i]) = s i := by simp [wordProd]
theorem wordProd_concat (i : B) (ω : List B) : π (ω.concat i) = π ω * s i := by simp [wordProd]
theorem wordProd_append (ω ω' : List B) : π (ω ++ ω') = π ω * π ω' := by simp [wordProd]
@[simp] theorem wordProd_reverse (ω : List B) : π (reverse ω) = (π ω)⁻¹ := by
induction' ω with x ω' ih
· simp
· simpa [wordProd_cons, wordProd_append] using ih
theorem wordProd_surjective : Surjective cs.wordProd := by
intro w
apply cs.simple_induction_left w
· use []
rw [wordProd_nil]
· rintro _ i ⟨ω, rfl⟩
use i :: ω
rw [wordProd_cons]
def alternatingWord (i i' : B) (m : ℕ) : List B :=
match m with
| 0 => []
| m+1 => (alternatingWord i' i m).concat i'
abbrev braidWord (M : CoxeterMatrix B) (i i' : B) : List B := alternatingWord i i' (M i i')
theorem alternatingWord_succ (i i' : B) (m : ℕ) :
alternatingWord i i' (m + 1) = (alternatingWord i' i m).concat i' := rfl
theorem alternatingWord_succ' (i i' : B) (m : ℕ) :
alternatingWord i i' (m + 1) = (if Even m then i' else i) :: alternatingWord i i' m := by
induction' m with m ih generalizing i i'
· simp [alternatingWord]
· rw [alternatingWord]
nth_rw 1 [ih i' i]
rw [alternatingWord]
simp [Nat.even_add_one]
@[simp]
| Mathlib/GroupTheory/Coxeter/Basic.lean | 402 | 406 | theorem length_alternatingWord (i i' : B) (m : ℕ) :
List.length (alternatingWord i i' m) = m := by |
induction' m with m ih generalizing i i'
· dsimp [alternatingWord]
· simpa [alternatingWord] using ih i' i
|
import Mathlib.Algebra.BigOperators.Group.List
import Mathlib.Data.Vector.Defs
import Mathlib.Data.List.Nodup
import Mathlib.Data.List.OfFn
import Mathlib.Data.List.InsertNth
import Mathlib.Control.Applicative
import Mathlib.Control.Traversable.Basic
#align_import data.vector.basic from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
set_option autoImplicit true
universe u
variable {n : ℕ}
namespace Vector
variable {α : Type*}
@[inherit_doc]
infixr:67 " ::ᵥ " => Vector.cons
attribute [simp] head_cons tail_cons
instance [Inhabited α] : Inhabited (Vector α n) :=
⟨ofFn default⟩
theorem toList_injective : Function.Injective (@toList α n) :=
Subtype.val_injective
#align vector.to_list_injective Vector.toList_injective
@[ext]
theorem ext : ∀ {v w : Vector α n} (_ : ∀ m : Fin n, Vector.get v m = Vector.get w m), v = w
| ⟨v, hv⟩, ⟨w, hw⟩, h =>
Subtype.eq (List.ext_get (by rw [hv, hw]) fun m hm _ => h ⟨m, hv ▸ hm⟩)
#align vector.ext Vector.ext
instance zero_subsingleton : Subsingleton (Vector α 0) :=
⟨fun _ _ => Vector.ext fun m => Fin.elim0 m⟩
#align vector.zero_subsingleton Vector.zero_subsingleton
@[simp]
theorem cons_val (a : α) : ∀ v : Vector α n, (a ::ᵥ v).val = a :: v.val
| ⟨_, _⟩ => rfl
#align vector.cons_val Vector.cons_val
#align vector.cons_head Vector.head_cons
#align vector.cons_tail Vector.tail_cons
theorem eq_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) :
v = a ::ᵥ v' ↔ v.head = a ∧ v.tail = v' :=
⟨fun h => h.symm ▸ ⟨head_cons a v', tail_cons a v'⟩, fun h =>
_root_.trans (cons_head_tail v).symm (by rw [h.1, h.2])⟩
#align vector.eq_cons_iff Vector.eq_cons_iff
theorem ne_cons_iff (a : α) (v : Vector α n.succ) (v' : Vector α n) :
v ≠ a ::ᵥ v' ↔ v.head ≠ a ∨ v.tail ≠ v' := by rw [Ne, eq_cons_iff a v v', not_and_or]
#align vector.ne_cons_iff Vector.ne_cons_iff
theorem exists_eq_cons (v : Vector α n.succ) : ∃ (a : α) (as : Vector α n), v = a ::ᵥ as :=
⟨v.head, v.tail, (eq_cons_iff v.head v v.tail).2 ⟨rfl, rfl⟩⟩
#align vector.exists_eq_cons Vector.exists_eq_cons
@[simp]
theorem toList_ofFn : ∀ {n} (f : Fin n → α), toList (ofFn f) = List.ofFn f
| 0, f => by rw [ofFn, List.ofFn_zero, toList, nil]
| n + 1, f => by rw [ofFn, List.ofFn_succ, toList_cons, toList_ofFn]
#align vector.to_list_of_fn Vector.toList_ofFn
@[simp]
theorem mk_toList : ∀ (v : Vector α n) (h), (⟨toList v, h⟩ : Vector α n) = v
| ⟨_, _⟩, _ => rfl
#align vector.mk_to_list Vector.mk_toList
@[simp] theorem length_val (v : Vector α n) : v.val.length = n := v.2
-- Porting note: not used in mathlib and coercions done differently in Lean 4
-- @[simp]
-- theorem length_coe (v : Vector α n) :
-- ((coe : { l : List α // l.length = n } → List α) v).length = n :=
-- v.2
#noalign vector.length_coe
@[simp]
| Mathlib/Data/Vector/Basic.lean | 101 | 102 | theorem toList_map {β : Type*} (v : Vector α n) (f : α → β) :
(v.map f).toList = v.toList.map f := by | cases v; rfl
|
import Mathlib.MeasureTheory.Measure.MeasureSpace
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
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ₗ
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
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
| Mathlib/MeasureTheory/Measure/Restrict.lean | 62 | 64 | 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]
|
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Slope
noncomputable section
open scoped Topology Filter ENNReal NNReal
open Filter Asymptotics Set
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
section Module
variable (𝕜)
variable {E : Type*} [AddCommGroup E] [Module 𝕜 E]
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 : 𝕜)
def HasLineDerivAt (f : E → F) (f' : F) (x : E) (v : E) :=
HasDerivAt (fun t ↦ f (x + t • v)) f' (0 : 𝕜)
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 : 𝕜)
def LineDifferentiableAt (f : E → F) (x : E) (v : E) : Prop :=
DifferentiableAt 𝕜 (fun t ↦ f (x + t • v)) (0 : 𝕜)
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 : 𝕜)
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]
| Mathlib/Analysis/Calculus/LineDeriv/Basic.lean | 160 | 163 | theorem lineDifferentiableWithinAt_univ :
LineDifferentiableWithinAt 𝕜 f univ x v ↔ LineDifferentiableAt 𝕜 f x v := by |
simp only [LineDifferentiableWithinAt, LineDifferentiableAt, preimage_univ,
differentiableWithinAt_univ]
|
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Index
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.GroupAction.Quotient
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.Tactic.IntervalCases
#align_import group_theory.p_group from "leanprover-community/mathlib"@"f694c7dead66f5d4c80f446c796a5aad14707f0e"
open Fintype MulAction
variable (p : ℕ) (G : Type*) [Group G]
def IsPGroup : Prop :=
∀ g : G, ∃ k : ℕ, g ^ p ^ k = 1
#align is_p_group IsPGroup
variable {p} {G}
namespace IsPGroup
theorem iff_orderOf [hp : Fact p.Prime] : IsPGroup p G ↔ ∀ g : G, ∃ k : ℕ, orderOf g = p ^ k :=
forall_congr' fun g =>
⟨fun ⟨k, hk⟩ =>
Exists.imp (fun _ h => h.right)
((Nat.dvd_prime_pow hp.out).mp (orderOf_dvd_of_pow_eq_one hk)),
Exists.imp fun k hk => by rw [← hk, pow_orderOf_eq_one]⟩
#align is_p_group.iff_order_of IsPGroup.iff_orderOf
theorem of_card [Fintype G] {n : ℕ} (hG : card G = p ^ n) : IsPGroup p G := fun g =>
⟨n, by rw [← hG, pow_card_eq_one]⟩
#align is_p_group.of_card IsPGroup.of_card
theorem of_bot : IsPGroup p (⊥ : Subgroup G) :=
of_card (by rw [← Nat.card_eq_fintype_card, Subgroup.card_bot, pow_zero])
#align is_p_group.of_bot IsPGroup.of_bot
theorem iff_card [Fact p.Prime] [Fintype G] : IsPGroup p G ↔ ∃ n : ℕ, card G = p ^ n := by
have hG : card G ≠ 0 := card_ne_zero
refine ⟨fun h => ?_, fun ⟨n, hn⟩ => of_card hn⟩
suffices ∀ q ∈ Nat.factors (card G), q = p by
use (card G).factors.length
rw [← List.prod_replicate, ← List.eq_replicate_of_mem this, Nat.prod_factors hG]
intro q hq
obtain ⟨hq1, hq2⟩ := (Nat.mem_factors hG).mp hq
haveI : Fact q.Prime := ⟨hq1⟩
obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card q hq2
obtain ⟨k, hk⟩ := (iff_orderOf.mp h) g
exact (hq1.pow_eq_iff.mp (hg.symm.trans hk).symm).1.symm
#align is_p_group.iff_card IsPGroup.iff_card
alias ⟨exists_card_eq, _⟩ := iff_card
theorem to_le {H K : Subgroup G} (hK : IsPGroup p K) (hHK : H ≤ K) : IsPGroup p H :=
hK.of_injective (Subgroup.inclusion hHK) fun a b h =>
Subtype.ext (by
change ((Subgroup.inclusion hHK) a : G) = (Subgroup.inclusion hHK) b
apply Subtype.ext_iff.mp h)
#align is_p_group.to_le IsPGroup.to_le
theorem to_inf_left {H K : Subgroup G} (hH : IsPGroup p H) : IsPGroup p (H ⊓ K : Subgroup G) :=
hH.to_le inf_le_left
#align is_p_group.to_inf_left IsPGroup.to_inf_left
theorem to_inf_right {H K : Subgroup G} (hK : IsPGroup p K) : IsPGroup p (H ⊓ K : Subgroup G) :=
hK.to_le inf_le_right
#align is_p_group.to_inf_right IsPGroup.to_inf_right
| Mathlib/GroupTheory/PGroup.lean | 279 | 282 | theorem map {H : Subgroup G} (hH : IsPGroup p H) {K : Type*} [Group K] (ϕ : G →* K) :
IsPGroup p (H.map ϕ) := by |
rw [← H.subtype_range, MonoidHom.map_range]
exact hH.of_surjective (ϕ.restrict H).rangeRestrict (ϕ.restrict H).rangeRestrict_surjective
|
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Matrix.Notation
import Mathlib.Data.Matrix.RowCol
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.GroupTheory.Perm.Fin
import Mathlib.LinearAlgebra.Alternating.Basic
#align_import linear_algebra.matrix.determinant from "leanprover-community/mathlib"@"c3019c79074b0619edb4b27553a91b2e82242395"
universe u v w z
open Equiv Equiv.Perm Finset Function
namespace Matrix
open Matrix
variable {m n : Type*} [DecidableEq n] [Fintype n] [DecidableEq m] [Fintype m]
variable {R : Type v} [CommRing R]
local notation "ε " σ:arg => ((sign σ : ℤ) : R)
def detRowAlternating : (n → R) [⋀^n]→ₗ[R] R :=
MultilinearMap.alternatization ((MultilinearMap.mkPiAlgebra R n R).compLinearMap LinearMap.proj)
#align matrix.det_row_alternating Matrix.detRowAlternating
abbrev det (M : Matrix n n R) : R :=
detRowAlternating M
#align matrix.det Matrix.det
theorem det_apply (M : Matrix n n R) : M.det = ∑ σ : Perm n, Equiv.Perm.sign σ • ∏ i, M (σ i) i :=
MultilinearMap.alternatization_apply _ M
#align matrix.det_apply Matrix.det_apply
-- This is what the old definition was. We use it to avoid having to change the old proofs below
theorem det_apply' (M : Matrix n n R) : M.det = ∑ σ : Perm n, ε σ * ∏ i, M (σ i) i := by
simp [det_apply, Units.smul_def]
#align matrix.det_apply' Matrix.det_apply'
@[simp]
theorem det_diagonal {d : n → R} : det (diagonal d) = ∏ i, d i := by
rw [det_apply']
refine (Finset.sum_eq_single 1 ?_ ?_).trans ?_
· rintro σ - h2
cases' not_forall.1 (mt Equiv.ext h2) with x h3
convert mul_zero (ε σ)
apply Finset.prod_eq_zero (mem_univ x)
exact if_neg h3
· simp
· simp
#align matrix.det_diagonal Matrix.det_diagonal
-- @[simp] -- Porting note (#10618): simp can prove this
theorem det_zero (_ : Nonempty n) : det (0 : Matrix n n R) = 0 :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_zero
#align matrix.det_zero Matrix.det_zero
@[simp]
theorem det_one : det (1 : Matrix n n R) = 1 := by rw [← diagonal_one]; simp [-diagonal_one]
#align matrix.det_one Matrix.det_one
theorem det_isEmpty [IsEmpty n] {A : Matrix n n R} : det A = 1 := by simp [det_apply]
#align matrix.det_is_empty Matrix.det_isEmpty
@[simp]
theorem coe_det_isEmpty [IsEmpty n] : (det : Matrix n n R → R) = Function.const _ 1 := by
ext
exact det_isEmpty
#align matrix.coe_det_is_empty Matrix.coe_det_isEmpty
theorem det_eq_one_of_card_eq_zero {A : Matrix n n R} (h : Fintype.card n = 0) : det A = 1 :=
haveI : IsEmpty n := Fintype.card_eq_zero_iff.mp h
det_isEmpty
#align matrix.det_eq_one_of_card_eq_zero Matrix.det_eq_one_of_card_eq_zero
@[simp]
theorem det_unique {n : Type*} [Unique n] [DecidableEq n] [Fintype n] (A : Matrix n n R) :
det A = A default default := by simp [det_apply, univ_unique]
#align matrix.det_unique Matrix.det_unique
theorem det_eq_elem_of_subsingleton [Subsingleton n] (A : Matrix n n R) (k : n) :
det A = A k k := by
have := uniqueOfSubsingleton k
convert det_unique A
#align matrix.det_eq_elem_of_subsingleton Matrix.det_eq_elem_of_subsingleton
theorem det_eq_elem_of_card_eq_one {A : Matrix n n R} (h : Fintype.card n = 1) (k : n) :
det A = A k k :=
haveI : Subsingleton n := Fintype.card_le_one_iff_subsingleton.mp h.le
det_eq_elem_of_subsingleton _ _
#align matrix.det_eq_elem_of_card_eq_one Matrix.det_eq_elem_of_card_eq_one
theorem det_mul_aux {M N : Matrix n n R} {p : n → n} (H : ¬Bijective p) :
(∑ σ : Perm n, ε σ * ∏ x, M (σ x) (p x) * N (p x) x) = 0 := by
obtain ⟨i, j, hpij, hij⟩ : ∃ i j, p i = p j ∧ i ≠ j := by
rw [← Finite.injective_iff_bijective, Injective] at H
push_neg at H
exact H
exact
sum_involution (fun σ _ => σ * Equiv.swap i j)
(fun σ _ => by
have : (∏ x, M (σ x) (p x)) = ∏ x, M ((σ * Equiv.swap i j) x) (p x) :=
Fintype.prod_equiv (swap i j) _ _ (by simp [apply_swap_eq_self hpij])
simp [this, sign_swap hij, -sign_swap', prod_mul_distrib])
(fun σ _ _ => (not_congr mul_swap_eq_iff).mpr hij) (fun _ _ => mem_univ _) fun σ _ =>
mul_swap_involutive i j σ
#align matrix.det_mul_aux Matrix.det_mul_aux
@[simp]
theorem det_mul (M N : Matrix n n R) : det (M * N) = det M * det N :=
calc
det (M * N) = ∑ p : n → n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i := by
simp only [det_apply', mul_apply, prod_univ_sum, mul_sum, Fintype.piFinset_univ]
rw [Finset.sum_comm]
_ =
∑ p ∈ (@univ (n → n) _).filter Bijective,
∑ σ : Perm n, ε σ * ∏ i, M (σ i) (p i) * N (p i) i :=
(Eq.symm <|
sum_subset (filter_subset _ _) fun f _ hbij =>
det_mul_aux <| by simpa only [true_and_iff, mem_filter, mem_univ] using hbij)
_ = ∑ τ : Perm n, ∑ σ : Perm n, ε σ * ∏ i, M (σ i) (τ i) * N (τ i) i :=
sum_bij (fun p h ↦ Equiv.ofBijective p (mem_filter.1 h).2) (fun _ _ ↦ mem_univ _)
(fun _ _ _ _ h ↦ by injection h)
(fun b _ ↦ ⟨b, mem_filter.2 ⟨mem_univ _, b.bijective⟩, coe_fn_injective rfl⟩) fun _ _ ↦ rfl
_ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * ε τ * ∏ j, M (τ j) (σ j) := by
simp only [mul_comm, mul_left_comm, prod_mul_distrib, mul_assoc]
_ = ∑ σ : Perm n, ∑ τ : Perm n, (∏ i, N (σ i) i) * (ε σ * ε τ) * ∏ i, M (τ i) i :=
(sum_congr rfl fun σ _ =>
Fintype.sum_equiv (Equiv.mulRight σ⁻¹) _ _ fun τ => by
have : (∏ j, M (τ j) (σ j)) = ∏ j, M ((τ * σ⁻¹) j) j := by
rw [← (σ⁻¹ : _ ≃ _).prod_comp]
simp only [Equiv.Perm.coe_mul, apply_inv_self, Function.comp_apply]
have h : ε σ * ε (τ * σ⁻¹) = ε τ :=
calc
ε σ * ε (τ * σ⁻¹) = ε (τ * σ⁻¹ * σ) := by
rw [mul_comm, sign_mul (τ * σ⁻¹)]
simp only [Int.cast_mul, Units.val_mul]
_ = ε τ := by simp only [inv_mul_cancel_right]
simp_rw [Equiv.coe_mulRight, h]
simp only [this])
_ = det M * det N := by
simp only [det_apply', Finset.mul_sum, mul_comm, mul_left_comm, mul_assoc]
#align matrix.det_mul Matrix.det_mul
def detMonoidHom : Matrix n n R →* R where
toFun := det
map_one' := det_one
map_mul' := det_mul
#align matrix.det_monoid_hom Matrix.detMonoidHom
@[simp]
theorem coe_detMonoidHom : (detMonoidHom : Matrix n n R → R) = det :=
rfl
#align matrix.coe_det_monoid_hom Matrix.coe_detMonoidHom
| Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean | 194 | 195 | theorem det_mul_comm (M N : Matrix m m R) : det (M * N) = det (N * M) := by |
rw [det_mul, det_mul, mul_comm]
|
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"
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]
def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop :=
IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ
#align interval_integrable IntervalIntegrable
section
variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
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
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]
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
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
theorem Continuous.intervalIntegrable {u : ℝ → E} (hu : Continuous u) (a b : ℝ) :
IntervalIntegrable u μ a b :=
hu.continuousOn.intervalIntegrable
#align continuous.interval_integrable Continuous.intervalIntegrable
end
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
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
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
variable [CompleteSpace E] [NormedSpace ℝ E]
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
-- 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 Comp
variable {a b c d : ℝ} (f : ℝ → E)
-- 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]
| Mathlib/MeasureTheory/Integral/IntervalIntegral.lean | 788 | 790 | 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]
|
import Mathlib.Tactic.Ring
import Mathlib.Data.PNat.Prime
#align_import data.pnat.xgcd from "leanprover-community/mathlib"@"6afc9b06856ad973f6a2619e3e8a0a8d537a58f2"
open Nat
namespace PNat
structure XgcdType where
wp : ℕ
x : ℕ
y : ℕ
zp : ℕ
ap : ℕ
bp : ℕ
deriving Inhabited
#align pnat.xgcd_type PNat.XgcdType
namespace XgcdType
variable (u : XgcdType)
instance : SizeOf XgcdType :=
⟨fun u => u.bp⟩
instance : Repr XgcdType where
reprPrec
| g, _ => s!"[[[{repr (g.wp + 1)}, {repr g.x}], \
[{repr g.y}, {repr (g.zp + 1)}]], \
[{repr (g.ap + 1)}, {repr (g.bp + 1)}]]"
def mk' (w : ℕ+) (x : ℕ) (y : ℕ) (z : ℕ+) (a : ℕ+) (b : ℕ+) : XgcdType :=
mk w.val.pred x y z.val.pred a.val.pred b.val.pred
#align pnat.xgcd_type.mk' PNat.XgcdType.mk'
def w : ℕ+ :=
succPNat u.wp
#align pnat.xgcd_type.w PNat.XgcdType.w
def z : ℕ+ :=
succPNat u.zp
#align pnat.xgcd_type.z PNat.XgcdType.z
def a : ℕ+ :=
succPNat u.ap
#align pnat.xgcd_type.a PNat.XgcdType.a
def b : ℕ+ :=
succPNat u.bp
#align pnat.xgcd_type.b PNat.XgcdType.b
def r : ℕ :=
(u.ap + 1) % (u.bp + 1)
#align pnat.xgcd_type.r PNat.XgcdType.r
def q : ℕ :=
(u.ap + 1) / (u.bp + 1)
#align pnat.xgcd_type.q PNat.XgcdType.q
def qp : ℕ :=
u.q - 1
#align pnat.xgcd_type.qp PNat.XgcdType.qp
def vp : ℕ × ℕ :=
⟨u.wp + u.x + u.ap + u.wp * u.ap + u.x * u.bp, u.y + u.zp + u.bp + u.y * u.ap + u.zp * u.bp⟩
#align pnat.xgcd_type.vp PNat.XgcdType.vp
def v : ℕ × ℕ :=
⟨u.w * u.a + u.x * u.b, u.y * u.a + u.z * u.b⟩
#align pnat.xgcd_type.v PNat.XgcdType.v
def succ₂ (t : ℕ × ℕ) : ℕ × ℕ :=
⟨t.1.succ, t.2.succ⟩
#align pnat.xgcd_type.succ₂ PNat.XgcdType.succ₂
| Mathlib/Data/PNat/Xgcd.lean | 136 | 137 | theorem v_eq_succ_vp : u.v = succ₂ u.vp := by |
ext <;> dsimp [v, vp, w, z, a, b, succ₂] <;> ring_nf
|
import Mathlib.Analysis.Complex.Asymptotics
import Mathlib.Analysis.SpecificLimits.Normed
#align_import analysis.special_functions.exp from "leanprover-community/mathlib"@"ba5ff5ad5d120fb0ef094ad2994967e9bfaf5112"
noncomputable section
open Finset Filter Metric Asymptotics Set Function Bornology
open scoped Classical Topology Nat
namespace Complex
variable {z y x : ℝ}
theorem exp_bound_sq (x z : ℂ) (hz : ‖z‖ ≤ 1) :
‖exp (x + z) - exp x - z • exp x‖ ≤ ‖exp x‖ * ‖z‖ ^ 2 :=
calc
‖exp (x + z) - exp x - z * exp x‖ = ‖exp x * (exp z - 1 - z)‖ := by
congr
rw [exp_add]
ring
_ = ‖exp x‖ * ‖exp z - 1 - z‖ := norm_mul _ _
_ ≤ ‖exp x‖ * ‖z‖ ^ 2 :=
mul_le_mul_of_nonneg_left (abs_exp_sub_one_sub_id_le hz) (norm_nonneg _)
#align complex.exp_bound_sq Complex.exp_bound_sq
theorem locally_lipschitz_exp {r : ℝ} (hr_nonneg : 0 ≤ r) (hr_le : r ≤ 1) (x y : ℂ)
(hyx : ‖y - x‖ < r) : ‖exp y - exp x‖ ≤ (1 + r) * ‖exp x‖ * ‖y - x‖ := by
have hy_eq : y = x + (y - x) := by abel
have hyx_sq_le : ‖y - x‖ ^ 2 ≤ r * ‖y - x‖ := by
rw [pow_two]
exact mul_le_mul hyx.le le_rfl (norm_nonneg _) hr_nonneg
have h_sq : ∀ z, ‖z‖ ≤ 1 → ‖exp (x + z) - exp x‖ ≤ ‖z‖ * ‖exp x‖ + ‖exp x‖ * ‖z‖ ^ 2 := by
intro z hz
have : ‖exp (x + z) - exp x - z • exp x‖ ≤ ‖exp x‖ * ‖z‖ ^ 2 := exp_bound_sq x z hz
rw [← sub_le_iff_le_add', ← norm_smul z]
exact (norm_sub_norm_le _ _).trans this
calc
‖exp y - exp x‖ = ‖exp (x + (y - x)) - exp x‖ := by nth_rw 1 [hy_eq]
_ ≤ ‖y - x‖ * ‖exp x‖ + ‖exp x‖ * ‖y - x‖ ^ 2 := h_sq (y - x) (hyx.le.trans hr_le)
_ ≤ ‖y - x‖ * ‖exp x‖ + ‖exp x‖ * (r * ‖y - x‖) :=
(add_le_add_left (mul_le_mul le_rfl hyx_sq_le (sq_nonneg _) (norm_nonneg _)) _)
_ = (1 + r) * ‖exp x‖ * ‖y - x‖ := by ring
#align complex.locally_lipschitz_exp Complex.locally_lipschitz_exp
-- Porting note: proof by term mode `locally_lipschitz_exp zero_le_one le_rfl x`
-- doesn't work because `‖y - x‖` and `dist y x` don't unify
@[continuity]
theorem continuous_exp : Continuous exp :=
continuous_iff_continuousAt.mpr fun x =>
continuousAt_of_locally_lipschitz zero_lt_one (2 * ‖exp x‖)
(fun y ↦ by
convert locally_lipschitz_exp zero_le_one le_rfl x y using 2
congr
ring)
#align complex.continuous_exp Complex.continuous_exp
theorem continuousOn_exp {s : Set ℂ} : ContinuousOn exp s :=
continuous_exp.continuousOn
#align complex.continuous_on_exp Complex.continuousOn_exp
lemma exp_sub_sum_range_isBigO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range n, x ^ i / i !) =O[𝓝 0] (· ^ n) := by
rcases (zero_le n).eq_or_lt with rfl | hn
· simpa using continuous_exp.continuousAt.norm.isBoundedUnder_le
· refine .of_bound (n.succ / (n ! * n)) ?_
rw [NormedAddCommGroup.nhds_zero_basis_norm_lt.eventually_iff]
refine ⟨1, one_pos, fun x hx ↦ ?_⟩
convert exp_bound hx.out.le hn using 1
field_simp [mul_comm]
lemma exp_sub_sum_range_succ_isLittleO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range (n + 1), x ^ i / i !) =o[𝓝 0] (· ^ n) :=
(exp_sub_sum_range_isBigO_pow (n + 1)).trans_isLittleO <| isLittleO_pow_pow n.lt_succ_self
end Complex
namespace Real
@[continuity]
theorem continuous_exp : Continuous exp :=
Complex.continuous_re.comp Complex.continuous_ofReal.cexp
#align real.continuous_exp Real.continuous_exp
theorem continuousOn_exp {s : Set ℝ} : ContinuousOn exp s :=
continuous_exp.continuousOn
#align real.continuous_on_exp Real.continuousOn_exp
lemma exp_sub_sum_range_isBigO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range n, x ^ i / i !) =O[𝓝 0] (· ^ n) := by
have := (Complex.exp_sub_sum_range_isBigO_pow n).comp_tendsto
(Complex.continuous_ofReal.tendsto' 0 0 rfl)
simp only [(· ∘ ·)] at this
norm_cast at this
lemma exp_sub_sum_range_succ_isLittleO_pow (n : ℕ) :
(fun x ↦ exp x - ∑ i ∈ Finset.range (n + 1), x ^ i / i !) =o[𝓝 0] (· ^ n) :=
(exp_sub_sum_range_isBigO_pow (n + 1)).trans_isLittleO <| isLittleO_pow_pow n.lt_succ_self
end Real
namespace Real
variable {α : Type*} {x y z : ℝ} {l : Filter α}
theorem exp_half (x : ℝ) : exp (x / 2) = √(exp x) := by
rw [eq_comm, sqrt_eq_iff_sq_eq, sq, ← exp_add, add_halves] <;> exact (exp_pos _).le
#align real.exp_half Real.exp_half
theorem tendsto_exp_atTop : Tendsto exp atTop atTop := by
have A : Tendsto (fun x : ℝ => x + 1) atTop atTop :=
tendsto_atTop_add_const_right atTop 1 tendsto_id
have B : ∀ᶠ x in atTop, x + 1 ≤ exp x := eventually_atTop.2 ⟨0, fun x _ => add_one_le_exp x⟩
exact tendsto_atTop_mono' atTop B A
#align real.tendsto_exp_at_top Real.tendsto_exp_atTop
theorem tendsto_exp_neg_atTop_nhds_zero : Tendsto (fun x => exp (-x)) atTop (𝓝 0) :=
(tendsto_inv_atTop_zero.comp tendsto_exp_atTop).congr fun x => (exp_neg x).symm
#align real.tendsto_exp_neg_at_top_nhds_0 Real.tendsto_exp_neg_atTop_nhds_zero
@[deprecated (since := "2024-01-31")]
alias tendsto_exp_neg_atTop_nhds_0 := tendsto_exp_neg_atTop_nhds_zero
theorem tendsto_exp_nhds_zero_nhds_one : Tendsto exp (𝓝 0) (𝓝 1) := by
convert continuous_exp.tendsto 0
simp
#align real.tendsto_exp_nhds_0_nhds_1 Real.tendsto_exp_nhds_zero_nhds_one
@[deprecated (since := "2024-01-31")]
alias tendsto_exp_nhds_0_nhds_1 := tendsto_exp_nhds_zero_nhds_one
theorem tendsto_exp_atBot : Tendsto exp atBot (𝓝 0) :=
(tendsto_exp_neg_atTop_nhds_zero.comp tendsto_neg_atBot_atTop).congr fun x =>
congr_arg exp <| neg_neg x
#align real.tendsto_exp_at_bot Real.tendsto_exp_atBot
theorem tendsto_exp_atBot_nhdsWithin : Tendsto exp atBot (𝓝[>] 0) :=
tendsto_inf.2 ⟨tendsto_exp_atBot, tendsto_principal.2 <| eventually_of_forall exp_pos⟩
#align real.tendsto_exp_at_bot_nhds_within Real.tendsto_exp_atBot_nhdsWithin
@[simp]
theorem isBoundedUnder_ge_exp_comp (l : Filter α) (f : α → ℝ) :
IsBoundedUnder (· ≥ ·) l fun x => exp (f x) :=
isBoundedUnder_of ⟨0, fun _ => (exp_pos _).le⟩
#align real.is_bounded_under_ge_exp_comp Real.isBoundedUnder_ge_exp_comp
@[simp]
theorem isBoundedUnder_le_exp_comp {f : α → ℝ} :
(IsBoundedUnder (· ≤ ·) l fun x => exp (f x)) ↔ IsBoundedUnder (· ≤ ·) l f :=
exp_monotone.isBoundedUnder_le_comp_iff tendsto_exp_atTop
#align real.is_bounded_under_le_exp_comp Real.isBoundedUnder_le_exp_comp
theorem tendsto_exp_div_pow_atTop (n : ℕ) : Tendsto (fun x => exp x / x ^ n) atTop atTop := by
refine (atTop_basis_Ioi.tendsto_iff (atTop_basis' 1)).2 fun C hC₁ => ?_
have hC₀ : 0 < C := zero_lt_one.trans_le hC₁
have : 0 < (exp 1 * C)⁻¹ := inv_pos.2 (mul_pos (exp_pos _) hC₀)
obtain ⟨N, hN⟩ : ∃ N : ℕ, ∀ k ≥ N, (↑k : ℝ) ^ n / exp 1 ^ k < (exp 1 * C)⁻¹ :=
eventually_atTop.1
((tendsto_pow_const_div_const_pow_of_one_lt n (one_lt_exp_iff.2 zero_lt_one)).eventually
(gt_mem_nhds this))
simp only [← exp_nat_mul, mul_one, div_lt_iff, exp_pos, ← div_eq_inv_mul] at hN
refine ⟨N, trivial, fun x hx => ?_⟩
rw [Set.mem_Ioi] at hx
have hx₀ : 0 < x := (Nat.cast_nonneg N).trans_lt hx
rw [Set.mem_Ici, le_div_iff (pow_pos hx₀ _), ← le_div_iff' hC₀]
calc
x ^ n ≤ ⌈x⌉₊ ^ n := mod_cast pow_le_pow_left hx₀.le (Nat.le_ceil _) _
_ ≤ exp ⌈x⌉₊ / (exp 1 * C) := mod_cast (hN _ (Nat.lt_ceil.2 hx).le).le
_ ≤ exp (x + 1) / (exp 1 * C) := by gcongr; exact (Nat.ceil_lt_add_one hx₀.le).le
_ = exp x / C := by rw [add_comm, exp_add, mul_div_mul_left _ _ (exp_pos _).ne']
#align real.tendsto_exp_div_pow_at_top Real.tendsto_exp_div_pow_atTop
theorem tendsto_pow_mul_exp_neg_atTop_nhds_zero (n : ℕ) :
Tendsto (fun x => x ^ n * exp (-x)) atTop (𝓝 0) :=
(tendsto_inv_atTop_zero.comp (tendsto_exp_div_pow_atTop n)).congr fun x => by
rw [comp_apply, inv_eq_one_div, div_div_eq_mul_div, one_mul, div_eq_mul_inv, exp_neg]
#align real.tendsto_pow_mul_exp_neg_at_top_nhds_0 Real.tendsto_pow_mul_exp_neg_atTop_nhds_zero
@[deprecated (since := "2024-01-31")]
alias tendsto_pow_mul_exp_neg_atTop_nhds_0 := tendsto_pow_mul_exp_neg_atTop_nhds_zero
theorem tendsto_mul_exp_add_div_pow_atTop (b c : ℝ) (n : ℕ) (hb : 0 < b) :
Tendsto (fun x => (b * exp x + c) / x ^ n) atTop atTop := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp only [pow_zero, div_one]
exact (tendsto_exp_atTop.const_mul_atTop hb).atTop_add tendsto_const_nhds
simp only [add_div, mul_div_assoc]
exact
((tendsto_exp_div_pow_atTop n).const_mul_atTop hb).atTop_add
(tendsto_const_nhds.div_atTop (tendsto_pow_atTop hn))
#align real.tendsto_mul_exp_add_div_pow_at_top Real.tendsto_mul_exp_add_div_pow_atTop
theorem tendsto_div_pow_mul_exp_add_atTop (b c : ℝ) (n : ℕ) (hb : 0 ≠ b) :
Tendsto (fun x => x ^ n / (b * exp x + c)) atTop (𝓝 0) := by
have H : ∀ d e, 0 < d → Tendsto (fun x : ℝ => x ^ n / (d * exp x + e)) atTop (𝓝 0) := by
intro b' c' h
convert (tendsto_mul_exp_add_div_pow_atTop b' c' n h).inv_tendsto_atTop using 1
ext x
simp
cases' lt_or_gt_of_ne hb with h h
· exact H b c h
· convert (H (-b) (-c) (neg_pos.mpr h)).neg using 1
· ext x
field_simp
rw [← neg_add (b * exp x) c, neg_div_neg_eq]
· rw [neg_zero]
#align real.tendsto_div_pow_mul_exp_add_at_top Real.tendsto_div_pow_mul_exp_add_atTop
def expOrderIso : ℝ ≃o Ioi (0 : ℝ) :=
StrictMono.orderIsoOfSurjective _ (exp_strictMono.codRestrict exp_pos) <|
(continuous_exp.subtype_mk _).surjective
(by simp only [tendsto_Ioi_atTop, Subtype.coe_mk, tendsto_exp_atTop])
(by simp [tendsto_exp_atBot_nhdsWithin])
#align real.exp_order_iso Real.expOrderIso
@[simp]
theorem coe_expOrderIso_apply (x : ℝ) : (expOrderIso x : ℝ) = exp x :=
rfl
#align real.coe_exp_order_iso_apply Real.coe_expOrderIso_apply
@[simp]
theorem coe_comp_expOrderIso : (↑) ∘ expOrderIso = exp :=
rfl
#align real.coe_comp_exp_order_iso Real.coe_comp_expOrderIso
@[simp]
theorem range_exp : range exp = Set.Ioi 0 := by
rw [← coe_comp_expOrderIso, range_comp, expOrderIso.range_eq, image_univ, Subtype.range_coe]
#align real.range_exp Real.range_exp
@[simp]
theorem map_exp_atTop : map exp atTop = atTop := by
rw [← coe_comp_expOrderIso, ← Filter.map_map, OrderIso.map_atTop, map_val_Ioi_atTop]
#align real.map_exp_at_top Real.map_exp_atTop
@[simp]
theorem comap_exp_atTop : comap exp atTop = atTop := by
rw [← map_exp_atTop, comap_map exp_injective, map_exp_atTop]
#align real.comap_exp_at_top Real.comap_exp_atTop
@[simp]
theorem tendsto_exp_comp_atTop {f : α → ℝ} :
Tendsto (fun x => exp (f x)) l atTop ↔ Tendsto f l atTop := by
simp_rw [← comp_apply (f := exp), ← tendsto_comap_iff, comap_exp_atTop]
#align real.tendsto_exp_comp_at_top Real.tendsto_exp_comp_atTop
| Mathlib/Analysis/SpecialFunctions/Exp.lean | 353 | 355 | theorem tendsto_comp_exp_atTop {f : ℝ → α} :
Tendsto (fun x => f (exp x)) atTop l ↔ Tendsto f atTop l := by |
simp_rw [← comp_apply (g := exp), ← tendsto_map'_iff, map_exp_atTop]
|
import Mathlib.Order.UpperLower.Basic
import Mathlib.Data.Finset.Preimage
#align_import combinatorics.young.young_diagram from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
open Function
@[ext]
structure YoungDiagram where
cells : Finset (ℕ × ℕ)
isLowerSet : IsLowerSet (cells : Set (ℕ × ℕ))
#align young_diagram YoungDiagram
namespace YoungDiagram
instance : SetLike YoungDiagram (ℕ × ℕ) where
-- Porting note (#11215): TODO: figure out how to do this correctly
coe := fun y => y.cells
coe_injective' μ ν h := by rwa [YoungDiagram.ext_iff, ← Finset.coe_inj]
@[simp]
theorem mem_cells {μ : YoungDiagram} (c : ℕ × ℕ) : c ∈ μ.cells ↔ c ∈ μ :=
Iff.rfl
#align young_diagram.mem_cells YoungDiagram.mem_cells
@[simp]
theorem mem_mk (c : ℕ × ℕ) (cells) (isLowerSet) :
c ∈ YoungDiagram.mk cells isLowerSet ↔ c ∈ cells :=
Iff.rfl
#align young_diagram.mem_mk YoungDiagram.mem_mk
instance decidableMem (μ : YoungDiagram) : DecidablePred (· ∈ μ) :=
inferInstanceAs (DecidablePred (· ∈ μ.cells))
#align young_diagram.decidable_mem YoungDiagram.decidableMem
theorem up_left_mem (μ : YoungDiagram) {i1 i2 j1 j2 : ℕ} (hi : i1 ≤ i2) (hj : j1 ≤ j2)
(hcell : (i2, j2) ∈ μ) : (i1, j1) ∈ μ :=
μ.isLowerSet (Prod.mk_le_mk.mpr ⟨hi, hj⟩) hcell
#align young_diagram.up_left_mem YoungDiagram.up_left_mem
protected abbrev card (μ : YoungDiagram) : ℕ :=
μ.cells.card
#align young_diagram.card YoungDiagram.card
section RowLens
def rowLens (μ : YoungDiagram) : List ℕ :=
(List.range <| μ.colLen 0).map μ.rowLen
#align young_diagram.row_lens YoungDiagram.rowLens
@[simp]
theorem get_rowLens {μ : YoungDiagram} {i} :
μ.rowLens.get i = μ.rowLen i := by simp only [rowLens, List.get_range, List.get_map]
#align young_diagram.nth_le_row_lens YoungDiagram.get_rowLens
@[simp]
theorem length_rowLens {μ : YoungDiagram} : μ.rowLens.length = μ.colLen 0 := by
simp only [rowLens, List.length_map, List.length_range]
#align young_diagram.length_row_lens YoungDiagram.length_rowLens
theorem rowLens_sorted (μ : YoungDiagram) : μ.rowLens.Sorted (· ≥ ·) :=
(List.pairwise_le_range _).map _ μ.rowLen_anti
#align young_diagram.row_lens_sorted YoungDiagram.rowLens_sorted
| Mathlib/Combinatorics/Young/YoungDiagram.lean | 428 | 431 | theorem pos_of_mem_rowLens (μ : YoungDiagram) (x : ℕ) (hx : x ∈ μ.rowLens) : 0 < x := by |
rw [rowLens, List.mem_map] at hx
obtain ⟨i, hi, rfl : μ.rowLen i = x⟩ := hx
rwa [List.mem_range, ← mem_iff_lt_colLen, mem_iff_lt_rowLen] at hi
|
import Mathlib.CategoryTheory.Functor.Trifunctor
import Mathlib.CategoryTheory.Products.Basic
#align_import category_theory.monoidal.category from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
universe v u
open CategoryTheory.Category
open CategoryTheory.Iso
namespace CategoryTheory
class MonoidalCategoryStruct (C : Type u) [𝒞 : Category.{v} C] where
tensorObj : C → C → C
whiskerLeft (X : C) {Y₁ Y₂ : C} (f : Y₁ ⟶ Y₂) : tensorObj X Y₁ ⟶ tensorObj X Y₂
whiskerRight {X₁ X₂ : C} (f : X₁ ⟶ X₂) (Y : C) : tensorObj X₁ Y ⟶ tensorObj X₂ Y
-- By default, it is defined in terms of whiskerings.
tensorHom {X₁ Y₁ X₂ Y₂ : C} (f : X₁ ⟶ Y₁) (g: X₂ ⟶ Y₂) : (tensorObj X₁ X₂ ⟶ tensorObj Y₁ Y₂) :=
whiskerRight f X₂ ≫ whiskerLeft Y₁ g
tensorUnit : C
associator : ∀ X Y Z : C, tensorObj (tensorObj X Y) Z ≅ tensorObj X (tensorObj Y Z)
leftUnitor : ∀ X : C, tensorObj tensorUnit X ≅ X
rightUnitor : ∀ X : C, tensorObj X tensorUnit ≅ X
@[simps]
def tensorIso {C : Type u} {X Y X' Y' : C} [Category.{v} C] [MonoidalCategory.{v} C] (f : X ≅ Y)
(g : X' ≅ Y') : X ⊗ X' ≅ Y ⊗ Y' where
hom := f.hom ⊗ g.hom
inv := f.inv ⊗ g.inv
hom_inv_id := by rw [← tensor_comp, Iso.hom_inv_id, Iso.hom_inv_id, ← tensor_id]
inv_hom_id := by rw [← tensor_comp, Iso.inv_hom_id, Iso.inv_hom_id, ← tensor_id]
#align category_theory.tensor_iso CategoryTheory.tensorIso
infixr:70 " ⊗ " => tensorIso
namespace MonoidalCategory
section
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C]
instance tensor_isIso {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] : IsIso (f ⊗ g) :=
(asIso f ⊗ asIso g).isIso_hom
#align category_theory.monoidal_category.tensor_is_iso CategoryTheory.MonoidalCategory.tensor_isIso
@[simp]
theorem inv_tensor {W X Y Z : C} (f : W ⟶ X) [IsIso f] (g : Y ⟶ Z) [IsIso g] :
inv (f ⊗ g) = inv f ⊗ inv g := by
simp [tensorHom_def ,whisker_exchange]
#align category_theory.monoidal_category.inv_tensor CategoryTheory.MonoidalCategory.inv_tensor
variable {U V W X Y Z : C}
theorem whiskerLeft_dite {P : Prop} [Decidable P]
(X : C) {Y Z : C} (f : P → (Y ⟶ Z)) (f' : ¬P → (Y ⟶ Z)) :
X ◁ (if h : P then f h else f' h) = if h : P then X ◁ f h else X ◁ f' h := by
split_ifs <;> rfl
theorem dite_whiskerRight {P : Prop} [Decidable P]
{X Y : C} (f : P → (X ⟶ Y)) (f' : ¬P → (X ⟶ Y)) (Z : C):
(if h : P then f h else f' h) ▷ Z = if h : P then f h ▷ Z else f' h ▷ Z := by
split_ifs <;> rfl
theorem tensor_dite {P : Prop} [Decidable P] {W X Y Z : C} (f : W ⟶ X) (g : P → (Y ⟶ Z))
(g' : ¬P → (Y ⟶ Z)) : (f ⊗ if h : P then g h else g' h) =
if h : P then f ⊗ g h else f ⊗ g' h := by split_ifs <;> rfl
#align category_theory.monoidal_category.tensor_dite CategoryTheory.MonoidalCategory.tensor_dite
theorem dite_tensor {P : Prop} [Decidable P] {W X Y Z : C} (f : W ⟶ X) (g : P → (Y ⟶ Z))
(g' : ¬P → (Y ⟶ Z)) : (if h : P then g h else g' h) ⊗ f =
if h : P then g h ⊗ f else g' h ⊗ f := by split_ifs <;> rfl
#align category_theory.monoidal_category.dite_tensor CategoryTheory.MonoidalCategory.dite_tensor
@[simp]
theorem whiskerLeft_eqToHom (X : C) {Y Z : C} (f : Y = Z) :
X ◁ eqToHom f = eqToHom (congr_arg₂ tensorObj rfl f) := by
cases f
simp only [whiskerLeft_id, eqToHom_refl]
@[simp]
theorem eqToHom_whiskerRight {X Y : C} (f : X = Y) (Z : C) :
eqToHom f ▷ Z = eqToHom (congr_arg₂ tensorObj f rfl) := by
cases f
simp only [id_whiskerRight, eqToHom_refl]
@[reassoc]
theorem associator_naturality_left {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ Y ▷ Z ≫ (α_ X' Y Z).hom = (α_ X Y Z).hom ≫ f ▷ (Y ⊗ Z) := by simp
@[reassoc]
theorem associator_inv_naturality_left {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ (Y ⊗ Z) ≫ (α_ X' Y Z).inv = (α_ X Y Z).inv ≫ f ▷ Y ▷ Z := by simp
@[reassoc]
theorem whiskerRight_tensor_symm {X X' : C} (f : X ⟶ X') (Y Z : C) :
f ▷ Y ▷ Z = (α_ X Y Z).hom ≫ f ▷ (Y ⊗ Z) ≫ (α_ X' Y Z).inv := by simp
@[reassoc]
| Mathlib/CategoryTheory/Monoidal/Category.lean | 470 | 471 | theorem associator_naturality_middle (X : C) {Y Y' : C} (f : Y ⟶ Y') (Z : C) :
(X ◁ f) ▷ Z ≫ (α_ X Y' Z).hom = (α_ X Y Z).hom ≫ X ◁ f ▷ Z := by | simp
|
import Mathlib.Algebra.Lie.Nilpotent
import Mathlib.Algebra.Lie.Normalizer
#align_import algebra.lie.engel from "leanprover-community/mathlib"@"210657c4ea4a4a7b234392f70a3a2a83346dfa90"
universe u₁ u₂ u₃ u₄
variable {R : Type u₁} {L : Type u₂} {L₂ : Type u₃} {M : Type u₄}
variable [CommRing R] [LieRing L] [LieAlgebra R L] [LieRing L₂] [LieAlgebra R L₂]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
namespace LieSubmodule
open LieModule
variable {I : LieIdeal R L} {x : L} (hxI : (R ∙ x) ⊔ I = ⊤)
theorem exists_smul_add_of_span_sup_eq_top (y : L) : ∃ t : R, ∃ z ∈ I, y = t • x + z := by
have hy : y ∈ (⊤ : Submodule R L) := Submodule.mem_top
simp only [← hxI, Submodule.mem_sup, Submodule.mem_span_singleton] at hy
obtain ⟨-, ⟨t, rfl⟩, z, hz, rfl⟩ := hy
exact ⟨t, z, hz, rfl⟩
#align lie_submodule.exists_smul_add_of_span_sup_eq_top LieSubmodule.exists_smul_add_of_span_sup_eq_top
| Mathlib/Algebra/Lie/Engel.lean | 89 | 102 | theorem lie_top_eq_of_span_sup_eq_top (N : LieSubmodule R L M) :
(↑⁅(⊤ : LieIdeal R L), N⁆ : Submodule R M) =
(N : Submodule R M).map (toEnd R L M x) ⊔ (↑⁅I, N⁆ : Submodule R M) := by |
simp only [lieIdeal_oper_eq_linear_span', Submodule.sup_span, mem_top, exists_prop,
true_and, Submodule.map_coe, toEnd_apply_apply]
refine le_antisymm (Submodule.span_le.mpr ?_) (Submodule.span_mono fun z hz => ?_)
· rintro z ⟨y, n, hn : n ∈ N, rfl⟩
obtain ⟨t, z, hz, rfl⟩ := exists_smul_add_of_span_sup_eq_top hxI y
simp only [SetLike.mem_coe, Submodule.span_union, Submodule.mem_sup]
exact
⟨t • ⁅x, n⁆, Submodule.subset_span ⟨t • n, N.smul_mem' t hn, lie_smul t x n⟩, ⁅z, n⁆,
Submodule.subset_span ⟨z, hz, n, hn, rfl⟩, by simp⟩
· rcases hz with (⟨m, hm, rfl⟩ | ⟨y, -, m, hm, rfl⟩)
exacts [⟨x, m, hm, rfl⟩, ⟨y, m, hm, rfl⟩]
|
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Analysis.Convex.Hull
import Mathlib.LinearAlgebra.AffineSpace.Basis
#align_import analysis.convex.combination from "leanprover-community/mathlib"@"92bd7b1ffeb306a89f450bee126ddd8a284c259d"
open Set Function
open scoped Classical
open Pointwise
universe u u'
variable {R R' E F ι ι' α : Type*} [LinearOrderedField R] [LinearOrderedField R'] [AddCommGroup E]
[AddCommGroup F] [LinearOrderedAddCommGroup α] [Module R E] [Module R F] [Module R α]
[OrderedSMul R α] {s : Set E}
def Finset.centerMass (t : Finset ι) (w : ι → R) (z : ι → E) : E :=
(∑ i ∈ t, w i)⁻¹ • ∑ i ∈ t, w i • z i
#align finset.center_mass Finset.centerMass
variable (i j : ι) (c : R) (t : Finset ι) (w : ι → R) (z : ι → E)
open Finset
theorem Finset.centerMass_empty : (∅ : Finset ι).centerMass w z = 0 := by
simp only [centerMass, sum_empty, smul_zero]
#align finset.center_mass_empty Finset.centerMass_empty
theorem Finset.centerMass_pair (hne : i ≠ j) :
({i, j} : Finset ι).centerMass w z = (w i / (w i + w j)) • z i + (w j / (w i + w j)) • z j := by
simp only [centerMass, sum_pair hne, smul_add, (mul_smul _ _ _).symm, div_eq_inv_mul]
#align finset.center_mass_pair Finset.centerMass_pair
variable {w}
theorem Finset.centerMass_insert (ha : i ∉ t) (hw : ∑ j ∈ t, w j ≠ 0) :
(insert i t).centerMass w z =
(w i / (w i + ∑ j ∈ t, w j)) • z i +
((∑ j ∈ t, w j) / (w i + ∑ j ∈ t, w j)) • t.centerMass w z := by
simp only [centerMass, sum_insert ha, smul_add, (mul_smul _ _ _).symm, ← div_eq_inv_mul]
congr 2
rw [div_mul_eq_mul_div, mul_inv_cancel hw, one_div]
#align finset.center_mass_insert Finset.centerMass_insert
theorem Finset.centerMass_singleton (hw : w i ≠ 0) : ({i} : Finset ι).centerMass w z = z i := by
rw [centerMass, sum_singleton, sum_singleton, ← mul_smul, inv_mul_cancel hw, one_smul]
#align finset.center_mass_singleton Finset.centerMass_singleton
@[simp] lemma Finset.centerMass_neg_left : t.centerMass (-w) z = t.centerMass w z := by
simp [centerMass, inv_neg]
lemma Finset.centerMass_smul_left {c : R'} [Module R' R] [Module R' E] [SMulCommClass R' R R]
[IsScalarTower R' R R] [SMulCommClass R R' E] [IsScalarTower R' R E] (hc : c ≠ 0) :
t.centerMass (c • w) z = t.centerMass w z := by
simp [centerMass, -smul_assoc, smul_assoc c, ← smul_sum, smul_inv₀, smul_smul_smul_comm, hc]
theorem Finset.centerMass_eq_of_sum_1 (hw : ∑ i ∈ t, w i = 1) :
t.centerMass w z = ∑ i ∈ t, w i • z i := by
simp only [Finset.centerMass, hw, inv_one, one_smul]
#align finset.center_mass_eq_of_sum_1 Finset.centerMass_eq_of_sum_1
theorem Finset.centerMass_smul : (t.centerMass w fun i => c • z i) = c • t.centerMass w z := by
simp only [Finset.centerMass, Finset.smul_sum, (mul_smul _ _ _).symm, mul_comm c, mul_assoc]
#align finset.center_mass_smul Finset.centerMass_smul
theorem Finset.centerMass_segment' (s : Finset ι) (t : Finset ι') (ws : ι → R) (zs : ι → E)
(wt : ι' → R) (zt : ι' → E) (hws : ∑ i ∈ s, ws i = 1) (hwt : ∑ i ∈ t, wt i = 1) (a b : R)
(hab : a + b = 1) : a • s.centerMass ws zs + b • t.centerMass wt zt = (s.disjSum t).centerMass
(Sum.elim (fun i => a * ws i) fun j => b * wt j) (Sum.elim zs zt) := by
rw [s.centerMass_eq_of_sum_1 _ hws, t.centerMass_eq_of_sum_1 _ hwt, smul_sum, smul_sum, ←
Finset.sum_sum_elim, Finset.centerMass_eq_of_sum_1]
· congr with ⟨⟩ <;> simp only [Sum.elim_inl, Sum.elim_inr, mul_smul]
· rw [sum_sum_elim, ← mul_sum, ← mul_sum, hws, hwt, mul_one, mul_one, hab]
#align finset.center_mass_segment' Finset.centerMass_segment'
theorem Finset.centerMass_segment (s : Finset ι) (w₁ w₂ : ι → R) (z : ι → E)
(hw₁ : ∑ i ∈ s, w₁ i = 1) (hw₂ : ∑ i ∈ s, w₂ i = 1) (a b : R) (hab : a + b = 1) :
a • s.centerMass w₁ z + b • s.centerMass w₂ z =
s.centerMass (fun i => a * w₁ i + b * w₂ i) z := by
have hw : (∑ i ∈ s, (a * w₁ i + b * w₂ i)) = 1 := by
simp only [← mul_sum, sum_add_distrib, mul_one, *]
simp only [Finset.centerMass_eq_of_sum_1, Finset.centerMass_eq_of_sum_1 _ _ hw,
smul_sum, sum_add_distrib, add_smul, mul_smul, *]
#align finset.center_mass_segment Finset.centerMass_segment
| Mathlib/Analysis/Convex/Combination.lean | 115 | 123 | theorem Finset.centerMass_ite_eq (hi : i ∈ t) :
t.centerMass (fun j => if i = j then (1 : R) else 0) z = z i := by |
rw [Finset.centerMass_eq_of_sum_1]
· trans ∑ j ∈ t, if i = j then z i else 0
· congr with i
split_ifs with h
exacts [h ▸ one_smul _ _, zero_smul _ _]
· rw [sum_ite_eq, if_pos hi]
· rw [sum_ite_eq, if_pos hi]
|
import Mathlib.Data.Set.NAry
import Mathlib.Order.UpperLower.Basic
import Mathlib.Order.SupClosed
#align_import data.set.sups from "leanprover-community/mathlib"@"20715f4ac6819ef2453d9e5106ecd086a5dc2a5e"
open Function
variable {F α β : Type*}
class HasSups (α : Type*) where
sups : α → α → α
#align has_sups HasSups
class HasInfs (α : Type*) where
infs : α → α → α
#align has_infs HasInfs
-- This notation is meant to have higher precedence than `⊔` and `⊓`, but still within the
-- realm of other binary notation.
@[inherit_doc]
infixl:74 " ⊻ " => HasSups.sups
@[inherit_doc]
infixl:75 " ⊼ " => HasInfs.infs
namespace Set
section Infs
variable [SemilatticeInf α] [SemilatticeInf β] [FunLike F α β] [InfHomClass F α β]
variable (s s₁ s₂ t t₁ t₂ u v : Set α)
protected def hasInfs : HasInfs (Set α) :=
⟨image2 (· ⊓ ·)⟩
#align set.has_infs Set.hasInfs
scoped[SetFamily] attribute [instance] Set.hasInfs
-- Porting note: opening SetFamily, because otherwise the Set.hasSups does not seem to be an
-- instance
open SetFamily
variable {s s₁ s₂ t t₁ t₂ u} {a b c : α}
@[simp]
theorem mem_infs : c ∈ s ⊼ t ↔ ∃ a ∈ s, ∃ b ∈ t, a ⊓ b = c := by simp [(· ⊼ ·)]
#align set.mem_infs Set.mem_infs
theorem inf_mem_infs : a ∈ s → b ∈ t → a ⊓ b ∈ s ⊼ t :=
mem_image2_of_mem
#align set.inf_mem_infs Set.inf_mem_infs
theorem infs_subset : s₁ ⊆ s₂ → t₁ ⊆ t₂ → s₁ ⊼ t₁ ⊆ s₂ ⊼ t₂ :=
image2_subset
#align set.infs_subset Set.infs_subset
theorem infs_subset_left : t₁ ⊆ t₂ → s ⊼ t₁ ⊆ s ⊼ t₂ :=
image2_subset_left
#align set.infs_subset_left Set.infs_subset_left
theorem infs_subset_right : s₁ ⊆ s₂ → s₁ ⊼ t ⊆ s₂ ⊼ t :=
image2_subset_right
#align set.infs_subset_right Set.infs_subset_right
theorem image_subset_infs_left : b ∈ t → (fun a => a ⊓ b) '' s ⊆ s ⊼ t :=
image_subset_image2_left
#align set.image_subset_infs_left Set.image_subset_infs_left
theorem image_subset_infs_right : a ∈ s → (a ⊓ ·) '' t ⊆ s ⊼ t :=
image_subset_image2_right
#align set.image_subset_infs_right Set.image_subset_infs_right
theorem forall_infs_iff {p : α → Prop} : (∀ c ∈ s ⊼ t, p c) ↔ ∀ a ∈ s, ∀ b ∈ t, p (a ⊓ b) :=
forall_image2_iff
#align set.forall_infs_iff Set.forall_infs_iff
@[simp]
theorem infs_subset_iff : s ⊼ t ⊆ u ↔ ∀ a ∈ s, ∀ b ∈ t, a ⊓ b ∈ u :=
image2_subset_iff
#align set.infs_subset_iff Set.infs_subset_iff
@[simp]
theorem infs_nonempty : (s ⊼ t).Nonempty ↔ s.Nonempty ∧ t.Nonempty :=
image2_nonempty_iff
#align set.infs_nonempty Set.infs_nonempty
protected theorem Nonempty.infs : s.Nonempty → t.Nonempty → (s ⊼ t).Nonempty :=
Nonempty.image2
#align set.nonempty.infs Set.Nonempty.infs
theorem Nonempty.of_infs_left : (s ⊼ t).Nonempty → s.Nonempty :=
Nonempty.of_image2_left
#align set.nonempty.of_infs_left Set.Nonempty.of_infs_left
theorem Nonempty.of_infs_right : (s ⊼ t).Nonempty → t.Nonempty :=
Nonempty.of_image2_right
#align set.nonempty.of_infs_right Set.Nonempty.of_infs_right
@[simp]
theorem empty_infs : ∅ ⊼ t = ∅ :=
image2_empty_left
#align set.empty_infs Set.empty_infs
@[simp]
theorem infs_empty : s ⊼ ∅ = ∅ :=
image2_empty_right
#align set.infs_empty Set.infs_empty
@[simp]
theorem infs_eq_empty : s ⊼ t = ∅ ↔ s = ∅ ∨ t = ∅ :=
image2_eq_empty_iff
#align set.infs_eq_empty Set.infs_eq_empty
@[simp]
theorem singleton_infs : {a} ⊼ t = t.image fun b => a ⊓ b :=
image2_singleton_left
#align set.singleton_infs Set.singleton_infs
@[simp]
theorem infs_singleton : s ⊼ {b} = s.image fun a => a ⊓ b :=
image2_singleton_right
#align set.infs_singleton Set.infs_singleton
theorem singleton_infs_singleton : ({a} ⊼ {b} : Set α) = {a ⊓ b} :=
image2_singleton
#align set.singleton_infs_singleton Set.singleton_infs_singleton
theorem infs_union_left : (s₁ ∪ s₂) ⊼ t = s₁ ⊼ t ∪ s₂ ⊼ t :=
image2_union_left
#align set.infs_union_left Set.infs_union_left
theorem infs_union_right : s ⊼ (t₁ ∪ t₂) = s ⊼ t₁ ∪ s ⊼ t₂ :=
image2_union_right
#align set.infs_union_right Set.infs_union_right
theorem infs_inter_subset_left : (s₁ ∩ s₂) ⊼ t ⊆ s₁ ⊼ t ∩ s₂ ⊼ t :=
image2_inter_subset_left
#align set.infs_inter_subset_left Set.infs_inter_subset_left
theorem infs_inter_subset_right : s ⊼ (t₁ ∩ t₂) ⊆ s ⊼ t₁ ∩ s ⊼ t₂ :=
image2_inter_subset_right
#align set.infs_inter_subset_right Set.infs_inter_subset_right
lemma image_infs (f : F) (s t : Set α) : f '' (s ⊼ t) = f '' s ⊼ f '' t :=
image_image2_distrib <| map_inf f
lemma subset_infs_self : s ⊆ s ⊼ s := fun _a ha ↦ mem_infs.2 ⟨_, ha, _, ha, inf_idem _⟩
lemma infs_self_subset : s ⊼ s ⊆ s ↔ InfClosed s := infs_subset_iff
@[simp] lemma infs_self : s ⊼ s = s ↔ InfClosed s :=
subset_infs_self.le.le_iff_eq.symm.trans infs_self_subset
lemma sep_infs_le (s t : Set α) (a : α) :
{b ∈ s ⊼ t | a ≤ b} = {b ∈ s | a ≤ b} ⊼ {b ∈ t | a ≤ b} := by ext; aesop
variable (s t u)
theorem iUnion_image_inf_left : ⋃ a ∈ s, (a ⊓ ·) '' t = s ⊼ t :=
iUnion_image_left _
#align set.Union_image_inf_left Set.iUnion_image_inf_left
theorem iUnion_image_inf_right : ⋃ b ∈ t, (· ⊓ b) '' s = s ⊼ t :=
iUnion_image_right _
#align set.Union_image_inf_right Set.iUnion_image_inf_right
@[simp]
| Mathlib/Data/Set/Sups.lean | 360 | 364 | theorem image_inf_prod (s t : Set α) : Set.image2 (fun x x_1 => x ⊓ x_1) s t = s ⊼ t := by |
have : (s ×ˢ t).image (uncurry (· ⊓ ·)) = Set.image2 (fun x x_1 => x ⊓ x_1) s t := by
simp only [@ge_iff_le, @Set.image_uncurry_prod]
rw [← this]
exact image_uncurry_prod _ _ _
|
import Mathlib.Data.Set.Function
import Mathlib.Logic.Equiv.Defs
import Mathlib.Tactic.Core
import Mathlib.Tactic.Attr.Core
#align_import logic.equiv.local_equiv from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
open Lean Meta Elab Tactic
def mfld_cfg : Simps.Config where
attrs := [`mfld_simps]
fullyApplied := false
#align mfld_cfg mfld_cfg
open Function Set
variable {α : Type*} {β : Type*} {γ : Type*} {δ : Type*}
structure PartialEquiv (α : Type*) (β : Type*) where
toFun : α → β
invFun : β → α
source : Set α
target : Set β
map_source' : ∀ ⦃x⦄, x ∈ source → toFun x ∈ target
map_target' : ∀ ⦃x⦄, x ∈ target → invFun x ∈ source
left_inv' : ∀ ⦃x⦄, x ∈ source → invFun (toFun x) = x
right_inv' : ∀ ⦃x⦄, x ∈ target → toFun (invFun x) = x
#align local_equiv PartialEquiv
attribute [coe] PartialEquiv.toFun
namespace PartialEquiv
variable (e : PartialEquiv α β) (e' : PartialEquiv β γ)
instance [Inhabited α] [Inhabited β] : Inhabited (PartialEquiv α β) :=
⟨⟨const α default, const β default, ∅, ∅, mapsTo_empty _ _, mapsTo_empty _ _, eqOn_empty _ _,
eqOn_empty _ _⟩⟩
@[symm]
protected def symm : PartialEquiv β α where
toFun := e.invFun
invFun := e.toFun
source := e.target
target := e.source
map_source' := e.map_target'
map_target' := e.map_source'
left_inv' := e.right_inv'
right_inv' := e.left_inv'
#align local_equiv.symm PartialEquiv.symm
instance : CoeFun (PartialEquiv α β) fun _ => α → β :=
⟨PartialEquiv.toFun⟩
def Simps.symm_apply (e : PartialEquiv α β) : β → α :=
e.symm
#align local_equiv.simps.symm_apply PartialEquiv.Simps.symm_apply
initialize_simps_projections PartialEquiv (toFun → apply, invFun → symm_apply)
-- Porting note: this can be proven with `dsimp only`
-- @[simp, mfld_simps]
-- theorem coe_mk (f : α → β) (g s t ml mr il ir) :
-- (PartialEquiv.mk f g s t ml mr il ir : α → β) = f := by dsimp only
-- #align local_equiv.coe_mk PartialEquiv.coe_mk
#noalign local_equiv.coe_mk
@[simp, mfld_simps]
theorem coe_symm_mk (f : α → β) (g s t ml mr il ir) :
((PartialEquiv.mk f g s t ml mr il ir).symm : β → α) = g :=
rfl
#align local_equiv.coe_symm_mk PartialEquiv.coe_symm_mk
-- Porting note: this is now a syntactic tautology
-- @[simp, mfld_simps]
-- theorem toFun_as_coe : e.toFun = e := rfl
-- #align local_equiv.to_fun_as_coe PartialEquiv.toFun_as_coe
#noalign local_equiv.to_fun_as_coe
@[simp, mfld_simps]
theorem invFun_as_coe : e.invFun = e.symm :=
rfl
#align local_equiv.inv_fun_as_coe PartialEquiv.invFun_as_coe
@[simp, mfld_simps]
theorem map_source {x : α} (h : x ∈ e.source) : e x ∈ e.target :=
e.map_source' h
#align local_equiv.map_source PartialEquiv.map_source
lemma map_source'' : e '' e.source ⊆ e.target :=
fun _ ⟨_, hx, hex⟩ ↦ mem_of_eq_of_mem (id hex.symm) (e.map_source' hx)
@[simp, mfld_simps]
theorem map_target {x : β} (h : x ∈ e.target) : e.symm x ∈ e.source :=
e.map_target' h
#align local_equiv.map_target PartialEquiv.map_target
@[simp, mfld_simps]
theorem left_inv {x : α} (h : x ∈ e.source) : e.symm (e x) = x :=
e.left_inv' h
#align local_equiv.left_inv PartialEquiv.left_inv
@[simp, mfld_simps]
theorem right_inv {x : β} (h : x ∈ e.target) : e (e.symm x) = x :=
e.right_inv' h
#align local_equiv.right_inv PartialEquiv.right_inv
theorem eq_symm_apply {x : α} {y : β} (hx : x ∈ e.source) (hy : y ∈ e.target) :
x = e.symm y ↔ e x = y :=
⟨fun h => by rw [← e.right_inv hy, h], fun h => by rw [← e.left_inv hx, h]⟩
#align local_equiv.eq_symm_apply PartialEquiv.eq_symm_apply
protected theorem mapsTo : MapsTo e e.source e.target := fun _ => e.map_source
#align local_equiv.maps_to PartialEquiv.mapsTo
theorem symm_mapsTo : MapsTo e.symm e.target e.source :=
e.symm.mapsTo
#align local_equiv.symm_maps_to PartialEquiv.symm_mapsTo
protected theorem leftInvOn : LeftInvOn e.symm e e.source := fun _ => e.left_inv
#align local_equiv.left_inv_on PartialEquiv.leftInvOn
protected theorem rightInvOn : RightInvOn e.symm e e.target := fun _ => e.right_inv
#align local_equiv.right_inv_on PartialEquiv.rightInvOn
protected theorem invOn : InvOn e.symm e e.source e.target :=
⟨e.leftInvOn, e.rightInvOn⟩
#align local_equiv.inv_on PartialEquiv.invOn
protected theorem injOn : InjOn e e.source :=
e.leftInvOn.injOn
#align local_equiv.inj_on PartialEquiv.injOn
protected theorem bijOn : BijOn e e.source e.target :=
e.invOn.bijOn e.mapsTo e.symm_mapsTo
#align local_equiv.bij_on PartialEquiv.bijOn
protected theorem surjOn : SurjOn e e.source e.target :=
e.bijOn.surjOn
#align local_equiv.surj_on PartialEquiv.surjOn
@[simps (config := .asFn)]
def _root_.Equiv.toPartialEquivOfImageEq (e : α ≃ β) (s : Set α) (t : Set β) (h : e '' s = t) :
PartialEquiv α β where
toFun := e
invFun := e.symm
source := s
target := t
map_source' x hx := h ▸ mem_image_of_mem _ hx
map_target' x hx := by
subst t
rcases hx with ⟨x, hx, rfl⟩
rwa [e.symm_apply_apply]
left_inv' x _ := e.symm_apply_apply x
right_inv' x _ := e.apply_symm_apply x
@[simps! (config := mfld_cfg)]
def _root_.Equiv.toPartialEquiv (e : α ≃ β) : PartialEquiv α β :=
e.toPartialEquivOfImageEq univ univ <| by rw [image_univ, e.surjective.range_eq]
#align equiv.to_local_equiv Equiv.toPartialEquiv
#align equiv.to_local_equiv_symm_apply Equiv.toPartialEquiv_symm_apply
#align equiv.to_local_equiv_target Equiv.toPartialEquiv_target
#align equiv.to_local_equiv_apply Equiv.toPartialEquiv_apply
#align equiv.to_local_equiv_source Equiv.toPartialEquiv_source
instance inhabitedOfEmpty [IsEmpty α] [IsEmpty β] : Inhabited (PartialEquiv α β) :=
⟨((Equiv.equivEmpty α).trans (Equiv.equivEmpty β).symm).toPartialEquiv⟩
#align local_equiv.inhabited_of_empty PartialEquiv.inhabitedOfEmpty
@[simps (config := .asFn)]
def copy (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g) (s : Set α)
(hs : e.source = s) (t : Set β) (ht : e.target = t) :
PartialEquiv α β where
toFun := f
invFun := g
source := s
target := t
map_source' _ := ht ▸ hs ▸ hf ▸ e.map_source
map_target' _ := hs ▸ ht ▸ hg ▸ e.map_target
left_inv' _ := hs ▸ hf ▸ hg ▸ e.left_inv
right_inv' _ := ht ▸ hf ▸ hg ▸ e.right_inv
#align local_equiv.copy PartialEquiv.copy
#align local_equiv.copy_source PartialEquiv.copy_source
#align local_equiv.copy_apply PartialEquiv.copy_apply
#align local_equiv.copy_symm_apply PartialEquiv.copy_symm_apply
#align local_equiv.copy_target PartialEquiv.copy_target
theorem copy_eq (e : PartialEquiv α β) (f : α → β) (hf : ⇑e = f) (g : β → α) (hg : ⇑e.symm = g)
(s : Set α) (hs : e.source = s) (t : Set β) (ht : e.target = t) :
e.copy f hf g hg s hs t ht = e := by
substs f g s t
cases e
rfl
#align local_equiv.copy_eq PartialEquiv.copy_eq
protected def toEquiv : e.source ≃ e.target where
toFun x := ⟨e x, e.map_source x.mem⟩
invFun y := ⟨e.symm y, e.map_target y.mem⟩
left_inv := fun ⟨_, hx⟩ => Subtype.eq <| e.left_inv hx
right_inv := fun ⟨_, hy⟩ => Subtype.eq <| e.right_inv hy
#align local_equiv.to_equiv PartialEquiv.toEquiv
@[simp, mfld_simps]
theorem symm_source : e.symm.source = e.target :=
rfl
#align local_equiv.symm_source PartialEquiv.symm_source
@[simp, mfld_simps]
theorem symm_target : e.symm.target = e.source :=
rfl
#align local_equiv.symm_target PartialEquiv.symm_target
@[simp, mfld_simps]
theorem symm_symm : e.symm.symm = e := by
cases e
rfl
#align local_equiv.symm_symm PartialEquiv.symm_symm
theorem symm_bijective :
Function.Bijective (PartialEquiv.symm : PartialEquiv α β → PartialEquiv β α) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
theorem image_source_eq_target : e '' e.source = e.target :=
e.bijOn.image_eq
#align local_equiv.image_source_eq_target PartialEquiv.image_source_eq_target
theorem forall_mem_target {p : β → Prop} : (∀ y ∈ e.target, p y) ↔ ∀ x ∈ e.source, p (e x) := by
rw [← image_source_eq_target, forall_mem_image]
#align local_equiv.forall_mem_target PartialEquiv.forall_mem_target
theorem exists_mem_target {p : β → Prop} : (∃ y ∈ e.target, p y) ↔ ∃ x ∈ e.source, p (e x) := by
rw [← image_source_eq_target, exists_mem_image]
#align local_equiv.exists_mem_target PartialEquiv.exists_mem_target
def IsImage (s : Set α) (t : Set β) : Prop :=
∀ ⦃x⦄, x ∈ e.source → (e x ∈ t ↔ x ∈ s)
#align local_equiv.is_image PartialEquiv.IsImage
theorem isImage_source_target : e.IsImage e.source e.target := fun x hx => by simp [hx]
#align local_equiv.is_image_source_target PartialEquiv.isImage_source_target
theorem isImage_source_target_of_disjoint (e' : PartialEquiv α β) (hs : Disjoint e.source e'.source)
(ht : Disjoint e.target e'.target) : e.IsImage e'.source e'.target :=
IsImage.of_image_eq <| by rw [hs.inter_eq, ht.inter_eq, image_empty]
#align local_equiv.is_image_source_target_of_disjoint PartialEquiv.isImage_source_target_of_disjoint
theorem image_source_inter_eq' (s : Set α) : e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' s := by
rw [inter_comm, e.leftInvOn.image_inter', image_source_eq_target, inter_comm]
#align local_equiv.image_source_inter_eq' PartialEquiv.image_source_inter_eq'
theorem image_source_inter_eq (s : Set α) :
e '' (e.source ∩ s) = e.target ∩ e.symm ⁻¹' (e.source ∩ s) := by
rw [inter_comm, e.leftInvOn.image_inter, image_source_eq_target, inter_comm]
#align local_equiv.image_source_inter_eq PartialEquiv.image_source_inter_eq
theorem image_eq_target_inter_inv_preimage {s : Set α} (h : s ⊆ e.source) :
e '' s = e.target ∩ e.symm ⁻¹' s := by
rw [← e.image_source_inter_eq', inter_eq_self_of_subset_right h]
#align local_equiv.image_eq_target_inter_inv_preimage PartialEquiv.image_eq_target_inter_inv_preimage
theorem symm_image_eq_source_inter_preimage {s : Set β} (h : s ⊆ e.target) :
e.symm '' s = e.source ∩ e ⁻¹' s :=
e.symm.image_eq_target_inter_inv_preimage h
#align local_equiv.symm_image_eq_source_inter_preimage PartialEquiv.symm_image_eq_source_inter_preimage
theorem symm_image_target_inter_eq (s : Set β) :
e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' (e.target ∩ s) :=
e.symm.image_source_inter_eq _
#align local_equiv.symm_image_target_inter_eq PartialEquiv.symm_image_target_inter_eq
theorem symm_image_target_inter_eq' (s : Set β) : e.symm '' (e.target ∩ s) = e.source ∩ e ⁻¹' s :=
e.symm.image_source_inter_eq' _
#align local_equiv.symm_image_target_inter_eq' PartialEquiv.symm_image_target_inter_eq'
theorem source_inter_preimage_inv_preimage (s : Set α) :
e.source ∩ e ⁻¹' (e.symm ⁻¹' s) = e.source ∩ s :=
Set.ext fun x => and_congr_right_iff.2 fun hx =>
by simp only [mem_preimage, e.left_inv hx]
#align local_equiv.source_inter_preimage_inv_preimage PartialEquiv.source_inter_preimage_inv_preimage
theorem source_inter_preimage_target_inter (s : Set β) :
e.source ∩ e ⁻¹' (e.target ∩ s) = e.source ∩ e ⁻¹' s :=
ext fun _ => ⟨fun hx => ⟨hx.1, hx.2.2⟩, fun hx => ⟨hx.1, e.map_source hx.1, hx.2⟩⟩
#align local_equiv.source_inter_preimage_target_inter PartialEquiv.source_inter_preimage_target_inter
theorem target_inter_inv_preimage_preimage (s : Set β) :
e.target ∩ e.symm ⁻¹' (e ⁻¹' s) = e.target ∩ s :=
e.symm.source_inter_preimage_inv_preimage _
#align local_equiv.target_inter_inv_preimage_preimage PartialEquiv.target_inter_inv_preimage_preimage
theorem symm_image_image_of_subset_source {s : Set α} (h : s ⊆ e.source) : e.symm '' (e '' s) = s :=
(e.leftInvOn.mono h).image_image
#align local_equiv.symm_image_image_of_subset_source PartialEquiv.symm_image_image_of_subset_source
theorem image_symm_image_of_subset_target {s : Set β} (h : s ⊆ e.target) : e '' (e.symm '' s) = s :=
e.symm.symm_image_image_of_subset_source h
#align local_equiv.image_symm_image_of_subset_target PartialEquiv.image_symm_image_of_subset_target
theorem source_subset_preimage_target : e.source ⊆ e ⁻¹' e.target :=
e.mapsTo
#align local_equiv.source_subset_preimage_target PartialEquiv.source_subset_preimage_target
theorem symm_image_target_eq_source : e.symm '' e.target = e.source :=
e.symm.image_source_eq_target
#align local_equiv.symm_image_target_eq_source PartialEquiv.symm_image_target_eq_source
theorem target_subset_preimage_source : e.target ⊆ e.symm ⁻¹' e.source :=
e.symm_mapsTo
#align local_equiv.target_subset_preimage_source PartialEquiv.target_subset_preimage_source
@[ext]
protected theorem ext {e e' : PartialEquiv α β} (h : ∀ x, e x = e' x)
(hsymm : ∀ x, e.symm x = e'.symm x) (hs : e.source = e'.source) : e = e' := by
have A : (e : α → β) = e' := by
ext x
exact h x
have B : (e.symm : β → α) = e'.symm := by
ext x
exact hsymm x
have I : e '' e.source = e.target := e.image_source_eq_target
have I' : e' '' e'.source = e'.target := e'.image_source_eq_target
rw [A, hs, I'] at I
cases e; cases e'
simp_all
#align local_equiv.ext PartialEquiv.ext
protected def restr (s : Set α) : PartialEquiv α β :=
(@IsImage.of_symm_preimage_eq α β e s (e.symm ⁻¹' s) rfl).restr
#align local_equiv.restr PartialEquiv.restr
@[simp, mfld_simps]
theorem restr_coe (s : Set α) : (e.restr s : α → β) = e :=
rfl
#align local_equiv.restr_coe PartialEquiv.restr_coe
@[simp, mfld_simps]
theorem restr_coe_symm (s : Set α) : ((e.restr s).symm : β → α) = e.symm :=
rfl
#align local_equiv.restr_coe_symm PartialEquiv.restr_coe_symm
@[simp, mfld_simps]
theorem restr_source (s : Set α) : (e.restr s).source = e.source ∩ s :=
rfl
#align local_equiv.restr_source PartialEquiv.restr_source
@[simp, mfld_simps]
theorem restr_target (s : Set α) : (e.restr s).target = e.target ∩ e.symm ⁻¹' s :=
rfl
#align local_equiv.restr_target PartialEquiv.restr_target
theorem restr_eq_of_source_subset {e : PartialEquiv α β} {s : Set α} (h : e.source ⊆ s) :
e.restr s = e :=
PartialEquiv.ext (fun _ => rfl) (fun _ => rfl) (by simp [inter_eq_self_of_subset_left h])
#align local_equiv.restr_eq_of_source_subset PartialEquiv.restr_eq_of_source_subset
@[simp, mfld_simps]
theorem restr_univ {e : PartialEquiv α β} : e.restr univ = e :=
restr_eq_of_source_subset (subset_univ _)
#align local_equiv.restr_univ PartialEquiv.restr_univ
protected def refl (α : Type*) : PartialEquiv α α :=
(Equiv.refl α).toPartialEquiv
#align local_equiv.refl PartialEquiv.refl
@[simp, mfld_simps]
theorem refl_source : (PartialEquiv.refl α).source = univ :=
rfl
#align local_equiv.refl_source PartialEquiv.refl_source
@[simp, mfld_simps]
theorem refl_target : (PartialEquiv.refl α).target = univ :=
rfl
#align local_equiv.refl_target PartialEquiv.refl_target
@[simp, mfld_simps]
theorem refl_coe : (PartialEquiv.refl α : α → α) = id :=
rfl
#align local_equiv.refl_coe PartialEquiv.refl_coe
@[simp, mfld_simps]
theorem refl_symm : (PartialEquiv.refl α).symm = PartialEquiv.refl α :=
rfl
#align local_equiv.refl_symm PartialEquiv.refl_symm
-- Porting note: removed `simp` because `simp` can prove this
@[mfld_simps]
theorem refl_restr_source (s : Set α) : ((PartialEquiv.refl α).restr s).source = s := by simp
#align local_equiv.refl_restr_source PartialEquiv.refl_restr_source
-- Porting note: removed `simp` because `simp` can prove this
@[mfld_simps]
theorem refl_restr_target (s : Set α) : ((PartialEquiv.refl α).restr s).target = s := by
change univ ∩ id ⁻¹' s = s
simp
#align local_equiv.refl_restr_target PartialEquiv.refl_restr_target
def ofSet (s : Set α) : PartialEquiv α α where
toFun := id
invFun := id
source := s
target := s
map_source' _ hx := hx
map_target' _ hx := hx
left_inv' _ _ := rfl
right_inv' _ _ := rfl
#align local_equiv.of_set PartialEquiv.ofSet
@[simp, mfld_simps]
theorem ofSet_source (s : Set α) : (PartialEquiv.ofSet s).source = s :=
rfl
#align local_equiv.of_set_source PartialEquiv.ofSet_source
@[simp, mfld_simps]
theorem ofSet_target (s : Set α) : (PartialEquiv.ofSet s).target = s :=
rfl
#align local_equiv.of_set_target PartialEquiv.ofSet_target
@[simp, mfld_simps]
theorem ofSet_coe (s : Set α) : (PartialEquiv.ofSet s : α → α) = id :=
rfl
#align local_equiv.of_set_coe PartialEquiv.ofSet_coe
@[simp, mfld_simps]
theorem ofSet_symm (s : Set α) : (PartialEquiv.ofSet s).symm = PartialEquiv.ofSet s :=
rfl
#align local_equiv.of_set_symm PartialEquiv.ofSet_symm
@[simps]
protected def trans' (e' : PartialEquiv β γ) (h : e.target = e'.source) : PartialEquiv α γ where
toFun := e' ∘ e
invFun := e.symm ∘ e'.symm
source := e.source
target := e'.target
map_source' x hx := by simp [← h, hx]
map_target' y hy := by simp [h, hy]
left_inv' x hx := by simp [hx, ← h]
right_inv' y hy := by simp [hy, h]
#align local_equiv.trans' PartialEquiv.trans'
@[trans]
protected def trans : PartialEquiv α γ :=
PartialEquiv.trans' (e.symm.restr e'.source).symm (e'.restr e.target) (inter_comm _ _)
#align local_equiv.trans PartialEquiv.trans
@[simp, mfld_simps]
theorem coe_trans : (e.trans e' : α → γ) = e' ∘ e :=
rfl
#align local_equiv.coe_trans PartialEquiv.coe_trans
@[simp, mfld_simps]
theorem coe_trans_symm : ((e.trans e').symm : γ → α) = e.symm ∘ e'.symm :=
rfl
#align local_equiv.coe_trans_symm PartialEquiv.coe_trans_symm
theorem trans_apply {x : α} : (e.trans e') x = e' (e x) :=
rfl
#align local_equiv.trans_apply PartialEquiv.trans_apply
theorem trans_symm_eq_symm_trans_symm : (e.trans e').symm = e'.symm.trans e.symm := by
cases e; cases e'; rfl
#align local_equiv.trans_symm_eq_symm_trans_symm PartialEquiv.trans_symm_eq_symm_trans_symm
@[simp, mfld_simps]
theorem trans_source : (e.trans e').source = e.source ∩ e ⁻¹' e'.source :=
rfl
#align local_equiv.trans_source PartialEquiv.trans_source
theorem trans_source' : (e.trans e').source = e.source ∩ e ⁻¹' (e.target ∩ e'.source) := by
mfld_set_tac
#align local_equiv.trans_source' PartialEquiv.trans_source'
theorem trans_source'' : (e.trans e').source = e.symm '' (e.target ∩ e'.source) := by
rw [e.trans_source', e.symm_image_target_inter_eq]
#align local_equiv.trans_source'' PartialEquiv.trans_source''
theorem image_trans_source : e '' (e.trans e').source = e.target ∩ e'.source :=
(e.symm.restr e'.source).symm.image_source_eq_target
#align local_equiv.image_trans_source PartialEquiv.image_trans_source
@[simp, mfld_simps]
theorem trans_target : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' e.target :=
rfl
#align local_equiv.trans_target PartialEquiv.trans_target
theorem trans_target' : (e.trans e').target = e'.target ∩ e'.symm ⁻¹' (e'.source ∩ e.target) :=
trans_source' e'.symm e.symm
#align local_equiv.trans_target' PartialEquiv.trans_target'
theorem trans_target'' : (e.trans e').target = e' '' (e'.source ∩ e.target) :=
trans_source'' e'.symm e.symm
#align local_equiv.trans_target'' PartialEquiv.trans_target''
theorem inv_image_trans_target : e'.symm '' (e.trans e').target = e'.source ∩ e.target :=
image_trans_source e'.symm e.symm
#align local_equiv.inv_image_trans_target PartialEquiv.inv_image_trans_target
theorem trans_assoc (e'' : PartialEquiv γ δ) : (e.trans e').trans e'' = e.trans (e'.trans e'') :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl)
(by simp [trans_source, @preimage_comp α β γ, inter_assoc])
#align local_equiv.trans_assoc PartialEquiv.trans_assoc
@[simp, mfld_simps]
theorem trans_refl : e.trans (PartialEquiv.refl β) = e :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl) (by simp [trans_source])
#align local_equiv.trans_refl PartialEquiv.trans_refl
@[simp, mfld_simps]
theorem refl_trans : (PartialEquiv.refl α).trans e = e :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl) (by simp [trans_source, preimage_id])
#align local_equiv.refl_trans PartialEquiv.refl_trans
theorem trans_ofSet (s : Set β) : e.trans (ofSet s) = e.restr (e ⁻¹' s) :=
PartialEquiv.ext (fun _ => rfl) (fun _ => rfl) rfl
theorem trans_refl_restr (s : Set β) :
e.trans ((PartialEquiv.refl β).restr s) = e.restr (e ⁻¹' s) :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl) (by simp [trans_source])
#align local_equiv.trans_refl_restr PartialEquiv.trans_refl_restr
theorem trans_refl_restr' (s : Set β) :
e.trans ((PartialEquiv.refl β).restr s) = e.restr (e.source ∩ e ⁻¹' s) :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl) <| by
simp only [trans_source, restr_source, refl_source, univ_inter]
rw [← inter_assoc, inter_self]
#align local_equiv.trans_refl_restr' PartialEquiv.trans_refl_restr'
theorem restr_trans (s : Set α) : (e.restr s).trans e' = (e.trans e').restr s :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl) <| by
simp [trans_source, inter_comm, inter_assoc]
#align local_equiv.restr_trans PartialEquiv.restr_trans
theorem mem_symm_trans_source {e' : PartialEquiv α γ} {x : α} (he : x ∈ e.source)
(he' : x ∈ e'.source) : e x ∈ (e.symm.trans e').source :=
⟨e.mapsTo he, by rwa [mem_preimage, PartialEquiv.symm_symm, e.left_inv he]⟩
#align local_equiv.mem_symm_trans_source PartialEquiv.mem_symm_trans_source
def EqOnSource (e e' : PartialEquiv α β) : Prop :=
e.source = e'.source ∧ e.source.EqOn e e'
#align local_equiv.eq_on_source PartialEquiv.EqOnSource
instance eqOnSourceSetoid : Setoid (PartialEquiv α β) where
r := EqOnSource
iseqv := by constructor <;> simp only [Equivalence, EqOnSource, EqOn] <;> aesop
#align local_equiv.eq_on_source_setoid PartialEquiv.eqOnSourceSetoid
theorem eqOnSource_refl : e ≈ e :=
Setoid.refl _
#align local_equiv.eq_on_source_refl PartialEquiv.eqOnSource_refl
theorem EqOnSource.source_eq {e e' : PartialEquiv α β} (h : e ≈ e') : e.source = e'.source :=
h.1
#align local_equiv.eq_on_source.source_eq PartialEquiv.EqOnSource.source_eq
theorem EqOnSource.eqOn {e e' : PartialEquiv α β} (h : e ≈ e') : e.source.EqOn e e' :=
h.2
#align local_equiv.eq_on_source.eq_on PartialEquiv.EqOnSource.eqOn
-- Porting note: A lot of dot notation failures here. Maybe we should not use `≈`
theorem EqOnSource.target_eq {e e' : PartialEquiv α β} (h : e ≈ e') : e.target = e'.target := by
simp only [← image_source_eq_target, ← source_eq h, h.2.image_eq]
#align local_equiv.eq_on_source.target_eq PartialEquiv.EqOnSource.target_eq
theorem EqOnSource.symm' {e e' : PartialEquiv α β} (h : e ≈ e') : e.symm ≈ e'.symm := by
refine ⟨target_eq h, eqOn_of_leftInvOn_of_rightInvOn e.leftInvOn ?_ ?_⟩ <;>
simp only [symm_source, target_eq h, source_eq h, e'.symm_mapsTo]
exact e'.rightInvOn.congr_right e'.symm_mapsTo (source_eq h ▸ h.eqOn.symm)
#align local_equiv.eq_on_source.symm' PartialEquiv.EqOnSource.symm'
theorem EqOnSource.symm_eqOn {e e' : PartialEquiv α β} (h : e ≈ e') :
EqOn e.symm e'.symm e.target :=
-- Porting note: `h.symm'` dot notation doesn't work anymore because `h` is not recognised as
-- `PartialEquiv.EqOnSource` for some reason.
eqOn (symm' h)
#align local_equiv.eq_on_source.symm_eq_on PartialEquiv.EqOnSource.symm_eqOn
theorem EqOnSource.trans' {e e' : PartialEquiv α β} {f f' : PartialEquiv β γ} (he : e ≈ e')
(hf : f ≈ f') : e.trans f ≈ e'.trans f' := by
constructor
· rw [trans_source'', trans_source'', ← target_eq he, ← hf.1]
exact (he.symm'.eqOn.mono inter_subset_left).image_eq
· intro x hx
rw [trans_source] at hx
simp [Function.comp_apply, PartialEquiv.coe_trans, (he.2 hx.1).symm, hf.2 hx.2]
#align local_equiv.eq_on_source.trans' PartialEquiv.EqOnSource.trans'
theorem EqOnSource.restr {e e' : PartialEquiv α β} (he : e ≈ e') (s : Set α) :
e.restr s ≈ e'.restr s := by
constructor
· simp [he.1]
· intro x hx
simp only [mem_inter_iff, restr_source] at hx
exact he.2 hx.1
#align local_equiv.eq_on_source.restr PartialEquiv.EqOnSource.restr
theorem EqOnSource.source_inter_preimage_eq {e e' : PartialEquiv α β} (he : e ≈ e') (s : Set β) :
e.source ∩ e ⁻¹' s = e'.source ∩ e' ⁻¹' s := by rw [he.eqOn.inter_preimage_eq, source_eq he]
#align local_equiv.eq_on_source.source_inter_preimage_eq PartialEquiv.EqOnSource.source_inter_preimage_eq
theorem self_trans_symm : e.trans e.symm ≈ ofSet e.source := by
have A : (e.trans e.symm).source = e.source := by mfld_set_tac
refine ⟨by rw [A, ofSet_source], fun x hx => ?_⟩
rw [A] at hx
simp only [hx, mfld_simps]
#align local_equiv.self_trans_symm PartialEquiv.self_trans_symm
theorem symm_trans_self : e.symm.trans e ≈ ofSet e.target :=
self_trans_symm e.symm
#align local_equiv.symm_trans_self PartialEquiv.symm_trans_self
theorem eq_of_eqOnSource_univ (e e' : PartialEquiv α β) (h : e ≈ e') (s : e.source = univ)
(t : e.target = univ) : e = e' := by
refine PartialEquiv.ext (fun x => ?_) (fun x => ?_) h.1
· apply h.2
rw [s]
exact mem_univ _
· apply h.symm'.2
rw [symm_source, t]
exact mem_univ _
#align local_equiv.eq_of_eq_on_source_univ PartialEquiv.eq_of_eqOnSource_univ
@[simps (config := .asFn)]
def piecewise (e e' : PartialEquiv α β) (s : Set α) (t : Set β) [∀ x, Decidable (x ∈ s)]
[∀ y, Decidable (y ∈ t)] (H : e.IsImage s t) (H' : e'.IsImage s t) :
PartialEquiv α β where
toFun := s.piecewise e e'
invFun := t.piecewise e.symm e'.symm
source := s.ite e.source e'.source
target := t.ite e.target e'.target
map_source' := H.mapsTo.piecewise_ite H'.compl.mapsTo
map_target' := H.symm.mapsTo.piecewise_ite H'.symm.compl.mapsTo
left_inv' := H.leftInvOn_piecewise H'
right_inv' := H.symm.leftInvOn_piecewise H'.symm
#align local_equiv.piecewise PartialEquiv.piecewise
#align local_equiv.piecewise_source PartialEquiv.piecewise_source
#align local_equiv.piecewise_target PartialEquiv.piecewise_target
#align local_equiv.piecewise_symm_apply PartialEquiv.piecewise_symm_apply
#align local_equiv.piecewise_apply PartialEquiv.piecewise_apply
theorem symm_piecewise (e e' : PartialEquiv α β) {s : Set α} {t : Set β} [∀ x, Decidable (x ∈ s)]
[∀ y, Decidable (y ∈ t)] (H : e.IsImage s t) (H' : e'.IsImage s t) :
(e.piecewise e' s t H H').symm = e.symm.piecewise e'.symm t s H.symm H'.symm :=
rfl
#align local_equiv.symm_piecewise PartialEquiv.symm_piecewise
@[simps! (config := .asFn)]
def disjointUnion (e e' : PartialEquiv α β) (hs : Disjoint e.source e'.source)
(ht : Disjoint e.target e'.target) [∀ x, Decidable (x ∈ e.source)]
[∀ y, Decidable (y ∈ e.target)] : PartialEquiv α β :=
(e.piecewise e' e.source e.target e.isImage_source_target <|
e'.isImage_source_target_of_disjoint _ hs.symm ht.symm).copy
_ rfl _ rfl (e.source ∪ e'.source) (ite_left _ _) (e.target ∪ e'.target) (ite_left _ _)
#align local_equiv.disjoint_union PartialEquiv.disjointUnion
#align local_equiv.disjoint_union_source PartialEquiv.disjointUnion_source
#align local_equiv.disjoint_union_target PartialEquiv.disjointUnion_target
#align local_equiv.disjoint_union_symm_apply PartialEquiv.disjointUnion_symm_apply
#align local_equiv.disjoint_union_apply PartialEquiv.disjointUnion_apply
theorem disjointUnion_eq_piecewise (e e' : PartialEquiv α β) (hs : Disjoint e.source e'.source)
(ht : Disjoint e.target e'.target) [∀ x, Decidable (x ∈ e.source)]
[∀ y, Decidable (y ∈ e.target)] :
e.disjointUnion e' hs ht =
e.piecewise e' e.source e.target e.isImage_source_target
(e'.isImage_source_target_of_disjoint _ hs.symm ht.symm) :=
copy_eq ..
#align local_equiv.disjoint_union_eq_piecewise PartialEquiv.disjointUnion_eq_piecewise
namespace Equiv
variable (e : α ≃ β) (e' : β ≃ γ)
@[simp, mfld_simps]
theorem refl_toPartialEquiv : (Equiv.refl α).toPartialEquiv = PartialEquiv.refl α :=
rfl
#align equiv.refl_to_local_equiv Equiv.refl_toPartialEquiv
@[simp, mfld_simps]
theorem symm_toPartialEquiv : e.symm.toPartialEquiv = e.toPartialEquiv.symm :=
rfl
#align equiv.symm_to_local_equiv Equiv.symm_toPartialEquiv
@[simp, mfld_simps]
theorem trans_toPartialEquiv :
(e.trans e').toPartialEquiv = e.toPartialEquiv.trans e'.toPartialEquiv :=
PartialEquiv.ext (fun x => rfl) (fun x => rfl)
(by simp [PartialEquiv.trans_source, Equiv.toPartialEquiv])
#align equiv.trans_to_local_equiv Equiv.trans_toPartialEquiv
@[simps!]
def transPartialEquiv (e : α ≃ β) (f' : PartialEquiv β γ) : PartialEquiv α γ :=
(e.toPartialEquiv.trans f').copy _ rfl _ rfl (e ⁻¹' f'.source) (univ_inter _) f'.target
(inter_univ _)
#align equiv.trans_local_equiv Equiv.transPartialEquiv
#align equiv.trans_local_equiv_target Equiv.transPartialEquiv_target
#align equiv.trans_local_equiv_apply Equiv.transPartialEquiv_apply
#align equiv.trans_local_equiv_source Equiv.transPartialEquiv_source
#align equiv.trans_local_equiv_symm_apply Equiv.transPartialEquiv_symm_apply
theorem transPartialEquiv_eq_trans (e : α ≃ β) (f' : PartialEquiv β γ) :
e.transPartialEquiv f' = e.toPartialEquiv.trans f' :=
PartialEquiv.copy_eq ..
#align equiv.trans_local_equiv_eq_trans Equiv.transPartialEquiv_eq_trans
@[simp, mfld_simps]
theorem transPartialEquiv_trans (e : α ≃ β) (f' : PartialEquiv β γ) (f'' : PartialEquiv γ δ) :
(e.transPartialEquiv f').trans f'' = e.transPartialEquiv (f'.trans f'') := by
simp only [transPartialEquiv_eq_trans, PartialEquiv.trans_assoc]
@[simp, mfld_simps]
| Mathlib/Logic/Equiv/PartialEquiv.lean | 1,125 | 1,127 | theorem trans_transPartialEquiv (e : α ≃ β) (e' : β ≃ γ) (f'' : PartialEquiv γ δ) :
(e.trans e').transPartialEquiv f'' = e.transPartialEquiv (e'.transPartialEquiv f'') := by |
simp only [transPartialEquiv_eq_trans, PartialEquiv.trans_assoc, trans_toPartialEquiv]
|
import Mathlib.CategoryTheory.Preadditive.AdditiveFunctor
import Mathlib.CategoryTheory.Monoidal.Functor
#align_import category_theory.monoidal.preadditive from "leanprover-community/mathlib"@"986c4d5761f938b2e1c43c01f001b6d9d88c2055"
noncomputable section
open scoped Classical
namespace CategoryTheory
open CategoryTheory.Limits
open CategoryTheory.MonoidalCategory
variable (C : Type*) [Category C] [Preadditive C] [MonoidalCategory C]
class MonoidalPreadditive : Prop where
whiskerLeft_zero : ∀ {X Y Z : C}, X ◁ (0 : Y ⟶ Z) = 0 := by aesop_cat
zero_whiskerRight : ∀ {X Y Z : C}, (0 : Y ⟶ Z) ▷ X = 0 := by aesop_cat
whiskerLeft_add : ∀ {X Y Z : C} (f g : Y ⟶ Z), X ◁ (f + g) = X ◁ f + X ◁ g := by aesop_cat
add_whiskerRight : ∀ {X Y Z : C} (f g : Y ⟶ Z), (f + g) ▷ X = f ▷ X + g ▷ X := by aesop_cat
#align category_theory.monoidal_preadditive CategoryTheory.MonoidalPreadditive
attribute [simp] MonoidalPreadditive.whiskerLeft_zero MonoidalPreadditive.zero_whiskerRight
attribute [simp] MonoidalPreadditive.whiskerLeft_add MonoidalPreadditive.add_whiskerRight
variable {C}
variable [MonoidalPreadditive C]
instance tensorLeft_additive (X : C) : (tensorLeft X).Additive where
#align category_theory.tensor_left_additive CategoryTheory.tensorLeft_additive
instance tensorRight_additive (X : C) : (tensorRight X).Additive where
#align category_theory.tensor_right_additive CategoryTheory.tensorRight_additive
instance tensoringLeft_additive (X : C) : ((tensoringLeft C).obj X).Additive where
#align category_theory.tensoring_left_additive CategoryTheory.tensoringLeft_additive
instance tensoringRight_additive (X : C) : ((tensoringRight C).obj X).Additive where
#align category_theory.tensoring_right_additive CategoryTheory.tensoringRight_additive
theorem monoidalPreadditive_of_faithful {D} [Category D] [Preadditive D] [MonoidalCategory D]
(F : MonoidalFunctor D C) [F.Faithful] [F.Additive] :
MonoidalPreadditive D :=
{ whiskerLeft_zero := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerLeft]
zero_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp [F.map_whiskerRight]
whiskerLeft_add := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerLeft, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.whiskerLeft_add]
add_whiskerRight := by
intros
apply F.toFunctor.map_injective
simp only [F.map_whiskerRight, Functor.map_add, Preadditive.comp_add, Preadditive.add_comp,
MonoidalPreadditive.add_whiskerRight] }
#align category_theory.monoidal_preadditive_of_faithful CategoryTheory.monoidalPreadditive_of_faithful
theorem whiskerLeft_sum (P : C) {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) :
P ◁ ∑ j ∈ s, g j = ∑ j ∈ s, P ◁ g j :=
map_sum ((tensoringLeft C).obj P).mapAddHom g s
theorem sum_whiskerRight {Q R : C} {J : Type*} (s : Finset J) (g : J → (Q ⟶ R)) (P : C) :
(∑ j ∈ s, g j) ▷ P = ∑ j ∈ s, g j ▷ P :=
map_sum ((tensoringRight C).obj P).mapAddHom g s
theorem tensor_sum {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(f ⊗ ∑ j ∈ s, g j) = ∑ j ∈ s, f ⊗ g j := by
simp only [tensorHom_def, whiskerLeft_sum, Preadditive.comp_sum]
#align category_theory.tensor_sum CategoryTheory.tensor_sum
theorem sum_tensor {P Q R S : C} {J : Type*} (s : Finset J) (f : P ⟶ Q) (g : J → (R ⟶ S)) :
(∑ j ∈ s, g j) ⊗ f = ∑ j ∈ s, g j ⊗ f := by
simp only [tensorHom_def, sum_whiskerRight, Preadditive.sum_comp]
#align category_theory.sum_tensor CategoryTheory.sum_tensor
-- In a closed monoidal category, this would hold because
-- `tensorLeft X` is a left adjoint and hence preserves all colimits.
-- In any case it is true in any preadditive category.
instance (X : C) : PreservesFiniteBiproducts (tensorLeft X) where
preserves {J} :=
{ preserves := fun {f} =>
{ preserves := fun {b} i => isBilimitOfTotal _ (by
dsimp
simp_rw [← id_tensorHom]
simp only [← tensor_comp, Category.comp_id, ← tensor_sum, ← tensor_id,
IsBilimit.total i]) } }
instance (X : C) : PreservesFiniteBiproducts (tensorRight X) where
preserves {J} :=
{ preserves := fun {f} =>
{ preserves := fun {b} i => isBilimitOfTotal _ (by
dsimp
simp_rw [← tensorHom_id]
simp only [← tensor_comp, Category.comp_id, ← sum_tensor, ← tensor_id,
IsBilimit.total i]) } }
variable [HasFiniteBiproducts C]
def leftDistributor {J : Type} [Fintype J] (X : C) (f : J → C) : X ⊗ ⨁ f ≅ ⨁ fun j => X ⊗ f j :=
(tensorLeft X).mapBiproduct f
#align category_theory.left_distributor CategoryTheory.leftDistributor
theorem leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).hom =
∑ j : J, (X ◁ biproduct.π f j) ≫ biproduct.ι (fun j => X ⊗ f j) j := by
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
erw [biproduct.lift_π]
simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,
Finset.sum_dite_eq', Finset.mem_univ, ite_true, eqToHom_refl, Category.comp_id]
#align category_theory.left_distributor_hom CategoryTheory.leftDistributor_hom
theorem leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) :
(leftDistributor X f).inv = ∑ j : J, biproduct.π _ j ≫ (X ◁ biproduct.ι f j) := by
ext
dsimp [leftDistributor, Functor.mapBiproduct, Functor.mapBicone]
simp only [Preadditive.comp_sum, biproduct.ι_π_assoc, dite_comp, zero_comp,
Finset.sum_dite_eq, Finset.mem_univ, ite_true, eqToHom_refl, Category.id_comp,
biproduct.ι_desc]
#align category_theory.left_distributor_inv CategoryTheory.leftDistributor_inv
@[reassoc (attr := simp)]
theorem leftDistributor_hom_comp_biproduct_π {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).hom ≫ biproduct.π _ j = X ◁ biproduct.π _ j := by
simp [leftDistributor_hom, Preadditive.sum_comp, biproduct.ι_π, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_leftDistributor_hom {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(X ◁ biproduct.ι _ j) ≫ (leftDistributor X f).hom = biproduct.ι (fun j => X ⊗ f j) j := by
simp [leftDistributor_hom, Preadditive.comp_sum, ← MonoidalCategory.whiskerLeft_comp_assoc,
biproduct.ι_π, whiskerLeft_dite, dite_comp]
@[reassoc (attr := simp)]
theorem leftDistributor_inv_comp_biproduct_π {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
(leftDistributor X f).inv ≫ (X ◁ biproduct.π _ j) = biproduct.π _ j := by
simp [leftDistributor_inv, Preadditive.sum_comp, ← MonoidalCategory.whiskerLeft_comp,
biproduct.ι_π, whiskerLeft_dite, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_leftDistributor_inv {J : Type} [Fintype J] (X : C) (f : J → C) (j : J) :
biproduct.ι _ j ≫ (leftDistributor X f).inv = X ◁ biproduct.ι _ j := by
simp [leftDistributor_inv, Preadditive.comp_sum, ← id_tensor_comp, biproduct.ι_π_assoc, dite_comp]
theorem leftDistributor_assoc {J : Type} [Fintype J] (X Y : C) (f : J → C) :
(asIso (𝟙 X) ⊗ leftDistributor Y f) ≪≫ leftDistributor X _ =
(α_ X Y (⨁ f)).symm ≪≫ leftDistributor (X ⊗ Y) f ≪≫ biproduct.mapIso fun j => α_ X Y _ := by
ext
simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.trans_hom, Iso.symm_hom,
asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, tensor_sum,
id_tensor_comp, tensorIso_hom, leftDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,
biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero]
simp_rw [← id_tensorHom]
simp only [← id_tensor_comp, biproduct.ι_π]
simp only [id_tensor_comp, tensor_dite, comp_dite]
simp
#align category_theory.left_distributor_assoc CategoryTheory.leftDistributor_assoc
def rightDistributor {J : Type} [Fintype J] (f : J → C) (X : C) : (⨁ f) ⊗ X ≅ ⨁ fun j => f j ⊗ X :=
(tensorRight X).mapBiproduct f
#align category_theory.right_distributor CategoryTheory.rightDistributor
theorem rightDistributor_hom {J : Type} [Fintype J] (f : J → C) (X : C) :
(rightDistributor f X).hom =
∑ j : J, (biproduct.π f j ▷ X) ≫ biproduct.ι (fun j => f j ⊗ X) j := by
ext
dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]
erw [biproduct.lift_π]
simp only [Preadditive.sum_comp, Category.assoc, biproduct.ι_π, comp_dite, comp_zero,
Finset.sum_dite_eq', Finset.mem_univ, eqToHom_refl, Category.comp_id, ite_true]
#align category_theory.right_distributor_hom CategoryTheory.rightDistributor_hom
theorem rightDistributor_inv {J : Type} [Fintype J] (f : J → C) (X : C) :
(rightDistributor f X).inv = ∑ j : J, biproduct.π _ j ≫ (biproduct.ι f j ▷ X) := by
ext
dsimp [rightDistributor, Functor.mapBiproduct, Functor.mapBicone]
simp only [biproduct.ι_desc, Preadditive.comp_sum, ne_eq, biproduct.ι_π_assoc, dite_comp,
zero_comp, Finset.sum_dite_eq, Finset.mem_univ, eqToHom_refl, Category.id_comp, ite_true]
#align category_theory.right_distributor_inv CategoryTheory.rightDistributor_inv
@[reassoc (attr := simp)]
theorem rightDistributor_hom_comp_biproduct_π {J : Type} [Fintype J] (f : J → C) (X : C) (j : J) :
(rightDistributor f X).hom ≫ biproduct.π _ j = biproduct.π _ j ▷ X := by
simp [rightDistributor_hom, Preadditive.sum_comp, biproduct.ι_π, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_rightDistributor_hom {J : Type} [Fintype J] (f : J → C) (X : C) (j : J) :
(biproduct.ι _ j ▷ X) ≫ (rightDistributor f X).hom = biproduct.ι (fun j => f j ⊗ X) j := by
simp [rightDistributor_hom, Preadditive.comp_sum, ← comp_whiskerRight_assoc, biproduct.ι_π,
dite_whiskerRight, dite_comp]
@[reassoc (attr := simp)]
theorem rightDistributor_inv_comp_biproduct_π {J : Type} [Fintype J] (f : J → C) (X : C) (j : J) :
(rightDistributor f X).inv ≫ (biproduct.π _ j ▷ X) = biproduct.π _ j := by
simp [rightDistributor_inv, Preadditive.sum_comp, ← MonoidalCategory.comp_whiskerRight,
biproduct.ι_π, dite_whiskerRight, comp_dite]
@[reassoc (attr := simp)]
theorem biproduct_ι_comp_rightDistributor_inv {J : Type} [Fintype J] (f : J → C) (X : C) (j : J) :
biproduct.ι _ j ≫ (rightDistributor f X).inv = biproduct.ι _ j ▷ X := by
simp [rightDistributor_inv, Preadditive.comp_sum, ← id_tensor_comp, biproduct.ι_π_assoc,
dite_comp]
| Mathlib/CategoryTheory/Monoidal/Preadditive.lean | 252 | 263 | theorem rightDistributor_assoc {J : Type} [Fintype J] (f : J → C) (X Y : C) :
(rightDistributor f X ⊗ asIso (𝟙 Y)) ≪≫ rightDistributor _ Y =
α_ (⨁ f) X Y ≪≫ rightDistributor f (X ⊗ Y) ≪≫ biproduct.mapIso fun j => (α_ _ X Y).symm := by |
ext
simp only [Category.comp_id, Category.assoc, eqToHom_refl, Iso.symm_hom, Iso.trans_hom,
asIso_hom, comp_zero, comp_dite, Preadditive.sum_comp, Preadditive.comp_sum, sum_tensor,
comp_tensor_id, tensorIso_hom, rightDistributor_hom, biproduct.mapIso_hom, biproduct.ι_map,
biproduct.ι_π, Finset.sum_dite_irrel, Finset.sum_dite_eq', Finset.sum_const_zero,
Finset.mem_univ, if_true]
simp_rw [← tensorHom_id]
simp only [← comp_tensor_id, biproduct.ι_π, dite_tensor, comp_dite]
simp
|
import Mathlib.Algebra.Polynomial.FieldDivision
import Mathlib.FieldTheory.Minpoly.Basic
import Mathlib.RingTheory.Algebraic
#align_import field_theory.minpoly.field from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5"
open scoped Classical
open Polynomial Set Function minpoly
namespace minpoly
variable {A B : Type*}
variable (A) [Field A]
section Ring
variable [Ring B] [Algebra A B] (x : B)
theorem degree_le_of_ne_zero {p : A[X]} (pnz : p ≠ 0) (hp : Polynomial.aeval x p = 0) :
degree (minpoly A x) ≤ degree p :=
calc
degree (minpoly A x) ≤ degree (p * C (leadingCoeff p)⁻¹) :=
min A x (monic_mul_leadingCoeff_inv pnz) (by simp [hp])
_ = degree p := degree_mul_leadingCoeff_inv p pnz
#align minpoly.degree_le_of_ne_zero minpoly.degree_le_of_ne_zero
theorem ne_zero_of_finite (e : B) [FiniteDimensional A B] : minpoly A e ≠ 0 :=
minpoly.ne_zero <| .of_finite A _
#align minpoly.ne_zero_of_finite_field_extension minpoly.ne_zero_of_finite
theorem unique {p : A[X]} (pmonic : p.Monic) (hp : Polynomial.aeval x p = 0)
(pmin : ∀ q : A[X], q.Monic → Polynomial.aeval x q = 0 → degree p ≤ degree q) :
p = minpoly A x := by
have hx : IsIntegral A x := ⟨p, pmonic, hp⟩
symm; apply eq_of_sub_eq_zero
by_contra hnz
apply degree_le_of_ne_zero A x hnz (by simp [hp]) |>.not_lt
apply degree_sub_lt _ (minpoly.ne_zero hx)
· rw [(monic hx).leadingCoeff, pmonic.leadingCoeff]
· exact le_antisymm (min A x pmonic hp) (pmin (minpoly A x) (monic hx) (aeval A x))
#align minpoly.unique minpoly.unique
theorem dvd {p : A[X]} (hp : Polynomial.aeval x p = 0) : minpoly A x ∣ p := by
by_cases hp0 : p = 0
· simp only [hp0, dvd_zero]
have hx : IsIntegral A x := IsAlgebraic.isIntegral ⟨p, hp0, hp⟩
rw [← modByMonic_eq_zero_iff_dvd (monic hx)]
by_contra hnz
apply degree_le_of_ne_zero A x hnz
((aeval_modByMonic_eq_self_of_root (monic hx) (aeval _ _)).trans hp) |>.not_lt
exact degree_modByMonic_lt _ (monic hx)
#align minpoly.dvd minpoly.dvd
variable {A x} in
lemma dvd_iff {p : A[X]} : minpoly A x ∣ p ↔ Polynomial.aeval x p = 0 :=
⟨fun ⟨q, hq⟩ ↦ by rw [hq, map_mul, aeval, zero_mul], minpoly.dvd A x⟩
theorem isRadical [IsReduced B] : IsRadical (minpoly A x) := fun n p dvd ↦ by
rw [dvd_iff] at dvd ⊢; rw [map_pow] at dvd; exact IsReduced.eq_zero _ ⟨n, dvd⟩
theorem dvd_map_of_isScalarTower (A K : Type*) {R : Type*} [CommRing A] [Field K] [CommRing R]
[Algebra A K] [Algebra A R] [Algebra K R] [IsScalarTower A K R] (x : R) :
minpoly K x ∣ (minpoly A x).map (algebraMap A K) := by
refine minpoly.dvd K x ?_
rw [aeval_map_algebraMap, minpoly.aeval]
#align minpoly.dvd_map_of_is_scalar_tower minpoly.dvd_map_of_isScalarTower
theorem dvd_map_of_isScalarTower' (R : Type*) {S : Type*} (K L : Type*) [CommRing R]
[CommRing S] [Field K] [CommRing L] [Algebra R S] [Algebra R K] [Algebra S L] [Algebra K L]
[Algebra R L] [IsScalarTower R K L] [IsScalarTower R S L] (s : S) :
minpoly K (algebraMap S L s) ∣ map (algebraMap R K) (minpoly R s) := by
apply minpoly.dvd K (algebraMap S L s)
rw [← map_aeval_eq_aeval_map, minpoly.aeval, map_zero]
rw [← IsScalarTower.algebraMap_eq, ← IsScalarTower.algebraMap_eq]
#align minpoly.dvd_map_of_is_scalar_tower' minpoly.dvd_map_of_isScalarTower'
theorem aeval_of_isScalarTower (R : Type*) {K T U : Type*} [CommRing R] [Field K] [CommRing T]
[Algebra R K] [Algebra K T] [Algebra R T] [IsScalarTower R K T] [CommSemiring U] [Algebra K U]
[Algebra R U] [IsScalarTower R K U] (x : T) (y : U)
(hy : Polynomial.aeval y (minpoly K x) = 0) : Polynomial.aeval y (minpoly R x) = 0 :=
aeval_map_algebraMap K y (minpoly R x) ▸
eval₂_eq_zero_of_dvd_of_eval₂_eq_zero (algebraMap K U) y
(minpoly.dvd_map_of_isScalarTower R K x) hy
#align minpoly.aeval_of_is_scalar_tower minpoly.aeval_of_isScalarTower
@[simp]
lemma ker_aeval_eq_span_minpoly :
RingHom.ker (Polynomial.aeval x) = A[X] ∙ minpoly A x := by
ext p
simp_rw [RingHom.mem_ker, ← minpoly.dvd_iff, Submodule.mem_span_singleton,
dvd_iff_exists_eq_mul_left, smul_eq_mul, eq_comm (a := p)]
variable {A x}
theorem eq_of_irreducible_of_monic [Nontrivial B] {p : A[X]} (hp1 : Irreducible p)
(hp2 : Polynomial.aeval x p = 0) (hp3 : p.Monic) : p = minpoly A x :=
let ⟨_, hq⟩ := dvd A x hp2
eq_of_monic_of_associated hp3 (monic ⟨p, ⟨hp3, hp2⟩⟩) <|
mul_one (minpoly A x) ▸ hq.symm ▸ Associated.mul_left _
(associated_one_iff_isUnit.2 <| (hp1.isUnit_or_isUnit hq).resolve_left <| not_isUnit A x)
#align minpoly.eq_of_irreducible_of_monic minpoly.eq_of_irreducible_of_monic
theorem eq_of_irreducible [Nontrivial B] {p : A[X]} (hp1 : Irreducible p)
(hp2 : Polynomial.aeval x p = 0) : p * C p.leadingCoeff⁻¹ = minpoly A x := by
have : p.leadingCoeff ≠ 0 := leadingCoeff_ne_zero.mpr hp1.ne_zero
apply eq_of_irreducible_of_monic
· exact Associated.irreducible ⟨⟨C p.leadingCoeff⁻¹, C p.leadingCoeff,
by rwa [← C_mul, inv_mul_cancel, C_1], by rwa [← C_mul, mul_inv_cancel, C_1]⟩, rfl⟩ hp1
· rw [aeval_mul, hp2, zero_mul]
· rwa [Polynomial.Monic, leadingCoeff_mul, leadingCoeff_C, mul_inv_cancel]
#align minpoly.eq_of_irreducible minpoly.eq_of_irreducible
theorem add_algebraMap {B : Type*} [CommRing B] [Algebra A B] {x : B} (hx : IsIntegral A x)
(a : A) : minpoly A (x + algebraMap A B a) = (minpoly A x).comp (X - C a) := by
refine (minpoly.unique _ _ ((minpoly.monic hx).comp_X_sub_C _) ?_ fun q qmo hq => ?_).symm
· simp [aeval_comp]
· have : (Polynomial.aeval x) (q.comp (X + C a)) = 0 := by simpa [aeval_comp] using hq
have H := minpoly.min A x (qmo.comp_X_add_C _) this
rw [degree_eq_natDegree qmo.ne_zero,
degree_eq_natDegree ((minpoly.monic hx).comp_X_sub_C _).ne_zero, natDegree_comp,
natDegree_X_sub_C, mul_one]
rwa [degree_eq_natDegree (minpoly.ne_zero hx),
degree_eq_natDegree (qmo.comp_X_add_C _).ne_zero, natDegree_comp,
natDegree_X_add_C, mul_one] at H
#align minpoly.add_algebra_map minpoly.add_algebraMap
| Mathlib/FieldTheory/Minpoly/Field.lean | 155 | 157 | theorem sub_algebraMap {B : Type*} [CommRing B] [Algebra A B] {x : B} (hx : IsIntegral A x)
(a : A) : minpoly A (x - algebraMap A B a) = (minpoly A x).comp (X + C a) := by |
simpa [sub_eq_add_neg] using add_algebraMap hx (-a)
|
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"
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 Liminf
| Mathlib/Topology/Instances/ENNReal.lean | 730 | 736 | 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))
|
import Mathlib.Algebra.Associated
import Mathlib.Algebra.Order.Monoid.Unbundled.Pow
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Data.Nat.GCD.Basic
import Mathlib.Order.Bounds.Basic
#align_import data.nat.prime from "leanprover-community/mathlib"@"8631e2d5ea77f6c13054d9151d82b83069680cb1"
open Bool Subtype
open Nat
namespace Nat
variable {n : ℕ}
-- Porting note (#11180): removed @[pp_nodot]
def Prime (p : ℕ) :=
Irreducible p
#align nat.prime Nat.Prime
theorem irreducible_iff_nat_prime (a : ℕ) : Irreducible a ↔ Nat.Prime a :=
Iff.rfl
#align irreducible_iff_nat_prime Nat.irreducible_iff_nat_prime
@[aesop safe destruct] theorem not_prime_zero : ¬Prime 0
| h => h.ne_zero rfl
#align nat.not_prime_zero Nat.not_prime_zero
@[aesop safe destruct] theorem not_prime_one : ¬Prime 1
| h => h.ne_one rfl
#align nat.not_prime_one Nat.not_prime_one
theorem Prime.ne_zero {n : ℕ} (h : Prime n) : n ≠ 0 :=
Irreducible.ne_zero h
#align nat.prime.ne_zero Nat.Prime.ne_zero
theorem Prime.pos {p : ℕ} (pp : Prime p) : 0 < p :=
Nat.pos_of_ne_zero pp.ne_zero
#align nat.prime.pos Nat.Prime.pos
theorem Prime.two_le : ∀ {p : ℕ}, Prime p → 2 ≤ p
| 0, h => (not_prime_zero h).elim
| 1, h => (not_prime_one h).elim
| _ + 2, _ => le_add_self
#align nat.prime.two_le Nat.Prime.two_le
theorem Prime.one_lt {p : ℕ} : Prime p → 1 < p :=
Prime.two_le
#align nat.prime.one_lt Nat.Prime.one_lt
lemma Prime.one_le {p : ℕ} (hp : p.Prime) : 1 ≤ p := hp.one_lt.le
instance Prime.one_lt' (p : ℕ) [hp : Fact p.Prime] : Fact (1 < p) :=
⟨hp.1.one_lt⟩
#align nat.prime.one_lt' Nat.Prime.one_lt'
theorem Prime.ne_one {p : ℕ} (hp : p.Prime) : p ≠ 1 :=
hp.one_lt.ne'
#align nat.prime.ne_one Nat.Prime.ne_one
theorem Prime.eq_one_or_self_of_dvd {p : ℕ} (pp : p.Prime) (m : ℕ) (hm : m ∣ p) :
m = 1 ∨ m = p := by
obtain ⟨n, hn⟩ := hm
have := pp.isUnit_or_isUnit hn
rw [Nat.isUnit_iff, Nat.isUnit_iff] at this
apply Or.imp_right _ this
rintro rfl
rw [hn, mul_one]
#align nat.prime.eq_one_or_self_of_dvd Nat.Prime.eq_one_or_self_of_dvd
theorem prime_def_lt'' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, m ∣ p → m = 1 ∨ m = p := by
refine ⟨fun h => ⟨h.two_le, h.eq_one_or_self_of_dvd⟩, fun h => ?_⟩
-- Porting note: needed to make ℕ explicit
have h1 := (@one_lt_two ℕ ..).trans_le h.1
refine ⟨mt Nat.isUnit_iff.mp h1.ne', fun a b hab => ?_⟩
simp only [Nat.isUnit_iff]
apply Or.imp_right _ (h.2 a _)
· rintro rfl
rw [← mul_right_inj' (pos_of_gt h1).ne', ← hab, mul_one]
· rw [hab]
exact dvd_mul_right _ _
#align nat.prime_def_lt'' Nat.prime_def_lt''
theorem prime_def_lt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m < p, m ∣ p → m = 1 :=
prime_def_lt''.trans <|
and_congr_right fun p2 =>
forall_congr' fun _ =>
⟨fun h l d => (h d).resolve_right (ne_of_lt l), fun h d =>
(le_of_dvd (le_of_succ_le p2) d).lt_or_eq_dec.imp_left fun l => h l d⟩
#align nat.prime_def_lt Nat.prime_def_lt
theorem prime_def_lt' {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m < p → ¬m ∣ p :=
prime_def_lt.trans <|
and_congr_right fun p2 =>
forall_congr' fun m =>
⟨fun h m2 l d => not_lt_of_ge m2 ((h l d).symm ▸ by decide), fun h l d => by
rcases m with (_ | _ | m)
· rw [eq_zero_of_zero_dvd d] at p2
revert p2
decide
· rfl
· exact (h le_add_self l).elim d⟩
#align nat.prime_def_lt' Nat.prime_def_lt'
theorem prime_def_le_sqrt {p : ℕ} : Prime p ↔ 2 ≤ p ∧ ∀ m, 2 ≤ m → m ≤ sqrt p → ¬m ∣ p :=
prime_def_lt'.trans <|
and_congr_right fun p2 =>
⟨fun a m m2 l => a m m2 <| lt_of_le_of_lt l <| sqrt_lt_self p2, fun a =>
have : ∀ {m k : ℕ}, m ≤ k → 1 < m → p ≠ m * k := fun {m k} mk m1 e =>
a m m1 (le_sqrt.2 (e.symm ▸ Nat.mul_le_mul_left m mk)) ⟨k, e⟩
fun m m2 l ⟨k, e⟩ => by
rcases le_total m k with mk | km
· exact this mk m2 e
· rw [mul_comm] at e
refine this km (lt_of_mul_lt_mul_right ?_ (zero_le m)) e
rwa [one_mul, ← e]⟩
#align nat.prime_def_le_sqrt Nat.prime_def_le_sqrt
theorem prime_of_coprime (n : ℕ) (h1 : 1 < n) (h : ∀ m < n, m ≠ 0 → n.Coprime m) : Prime n := by
refine prime_def_lt.mpr ⟨h1, fun m mlt mdvd => ?_⟩
have hm : m ≠ 0 := by
rintro rfl
rw [zero_dvd_iff] at mdvd
exact mlt.ne' mdvd
exact (h m mlt hm).symm.eq_one_of_dvd mdvd
#align nat.prime_of_coprime Nat.prime_of_coprime
section
@[local instance]
def decidablePrime1 (p : ℕ) : Decidable (Prime p) :=
decidable_of_iff' _ prime_def_lt'
#align nat.decidable_prime_1 Nat.decidablePrime1
theorem prime_two : Prime 2 := by decide
#align nat.prime_two Nat.prime_two
theorem prime_three : Prime 3 := by decide
#align nat.prime_three Nat.prime_three
theorem prime_five : Prime 5 := by decide
theorem Prime.five_le_of_ne_two_of_ne_three {p : ℕ} (hp : p.Prime) (h_two : p ≠ 2)
(h_three : p ≠ 3) : 5 ≤ p := by
by_contra! h
revert h_two h_three hp
-- Porting note (#11043): was `decide!`
match p with
| 0 => decide
| 1 => decide
| 2 => decide
| 3 => decide
| 4 => decide
| n + 5 => exact (h.not_le le_add_self).elim
#align nat.prime.five_le_of_ne_two_of_ne_three Nat.Prime.five_le_of_ne_two_of_ne_three
end
theorem Prime.pred_pos {p : ℕ} (pp : Prime p) : 0 < pred p :=
lt_pred_iff.2 pp.one_lt
#align nat.prime.pred_pos Nat.Prime.pred_pos
theorem succ_pred_prime {p : ℕ} (pp : Prime p) : succ (pred p) = p :=
succ_pred_eq_of_pos pp.pos
#align nat.succ_pred_prime Nat.succ_pred_prime
theorem dvd_prime {p m : ℕ} (pp : Prime p) : m ∣ p ↔ m = 1 ∨ m = p :=
⟨fun d => pp.eq_one_or_self_of_dvd m d, fun h =>
h.elim (fun e => e.symm ▸ one_dvd _) fun e => e.symm ▸ dvd_rfl⟩
#align nat.dvd_prime Nat.dvd_prime
theorem dvd_prime_two_le {p m : ℕ} (pp : Prime p) (H : 2 ≤ m) : m ∣ p ↔ m = p :=
(dvd_prime pp).trans <| or_iff_right_of_imp <| Not.elim <| ne_of_gt H
#align nat.dvd_prime_two_le Nat.dvd_prime_two_le
theorem prime_dvd_prime_iff_eq {p q : ℕ} (pp : p.Prime) (qp : q.Prime) : p ∣ q ↔ p = q :=
dvd_prime_two_le qp (Prime.two_le pp)
#align nat.prime_dvd_prime_iff_eq Nat.prime_dvd_prime_iff_eq
theorem Prime.not_dvd_one {p : ℕ} (pp : Prime p) : ¬p ∣ 1 :=
Irreducible.not_dvd_one pp
#align nat.prime.not_dvd_one Nat.Prime.not_dvd_one
theorem prime_mul_iff {a b : ℕ} : Nat.Prime (a * b) ↔ a.Prime ∧ b = 1 ∨ b.Prime ∧ a = 1 := by
simp only [iff_self_iff, irreducible_mul_iff, ← irreducible_iff_nat_prime, Nat.isUnit_iff]
#align nat.prime_mul_iff Nat.prime_mul_iff
theorem not_prime_mul {a b : ℕ} (a1 : a ≠ 1) (b1 : b ≠ 1) : ¬Prime (a * b) := by
simp [prime_mul_iff, _root_.not_or, *]
#align nat.not_prime_mul Nat.not_prime_mul
theorem not_prime_mul' {a b n : ℕ} (h : a * b = n) (h₁ : a ≠ 1) (h₂ : b ≠ 1) : ¬Prime n :=
h ▸ not_prime_mul h₁ h₂
#align nat.not_prime_mul' Nat.not_prime_mul'
theorem Prime.dvd_iff_eq {p a : ℕ} (hp : p.Prime) (a1 : a ≠ 1) : a ∣ p ↔ p = a := by
refine ⟨?_, by rintro rfl; rfl⟩
rintro ⟨j, rfl⟩
rcases prime_mul_iff.mp hp with (⟨_, rfl⟩ | ⟨_, rfl⟩)
· exact mul_one _
· exact (a1 rfl).elim
#align nat.prime.dvd_iff_eq Nat.Prime.dvd_iff_eq
theorem exists_dvd_of_not_prime {n : ℕ} (n2 : 2 ≤ n) (np : ¬Prime n) : ∃ m, m ∣ n ∧ m ≠ 1 ∧ m ≠ n :=
⟨minFac n, minFac_dvd _, ne_of_gt (minFac_prime (ne_of_gt n2)).one_lt,
ne_of_lt <| (not_prime_iff_minFac_lt n2).1 np⟩
#align nat.exists_dvd_of_not_prime Nat.exists_dvd_of_not_prime
theorem exists_dvd_of_not_prime2 {n : ℕ} (n2 : 2 ≤ n) (np : ¬Prime n) :
∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n :=
⟨minFac n, minFac_dvd _, (minFac_prime (ne_of_gt n2)).two_le,
(not_prime_iff_minFac_lt n2).1 np⟩
#align nat.exists_dvd_of_not_prime2 Nat.exists_dvd_of_not_prime2
theorem not_prime_of_dvd_of_ne {m n : ℕ} (h1 : m ∣ n) (h2 : m ≠ 1) (h3 : m ≠ n) : ¬Prime n :=
fun h => Or.elim (h.eq_one_or_self_of_dvd m h1) h2 h3
theorem not_prime_of_dvd_of_lt {m n : ℕ} (h1 : m ∣ n) (h2 : 2 ≤ m) (h3 : m < n) : ¬Prime n :=
not_prime_of_dvd_of_ne h1 (ne_of_gt h2) (ne_of_lt h3)
theorem not_prime_iff_exists_dvd_ne {n : ℕ} (h : 2 ≤ n) : (¬Prime n) ↔ ∃ m, m ∣ n ∧ m ≠ 1 ∧ m ≠ n :=
⟨exists_dvd_of_not_prime h, fun ⟨_, h1, h2, h3⟩ => not_prime_of_dvd_of_ne h1 h2 h3⟩
theorem not_prime_iff_exists_dvd_lt {n : ℕ} (h : 2 ≤ n) : (¬Prime n) ↔ ∃ m, m ∣ n ∧ 2 ≤ m ∧ m < n :=
⟨exists_dvd_of_not_prime2 h, fun ⟨_, h1, h2, h3⟩ => not_prime_of_dvd_of_lt h1 h2 h3⟩
theorem exists_prime_and_dvd {n : ℕ} (hn : n ≠ 1) : ∃ p, Prime p ∧ p ∣ n :=
⟨minFac n, minFac_prime hn, minFac_dvd _⟩
#align nat.exists_prime_and_dvd Nat.exists_prime_and_dvd
theorem dvd_of_forall_prime_mul_dvd {a b : ℕ}
(hdvd : ∀ p : ℕ, p.Prime → p ∣ a → p * a ∣ b) : a ∣ b := by
obtain rfl | ha := eq_or_ne a 1
· apply one_dvd
obtain ⟨p, hp⟩ := exists_prime_and_dvd ha
exact _root_.trans (dvd_mul_left a p) (hdvd p hp.1 hp.2)
#align nat.dvd_of_forall_prime_mul_dvd Nat.dvd_of_forall_prime_mul_dvd
theorem exists_infinite_primes (n : ℕ) : ∃ p, n ≤ p ∧ Prime p :=
let p := minFac (n ! + 1)
have f1 : n ! + 1 ≠ 1 := ne_of_gt <| succ_lt_succ <| factorial_pos _
have pp : Prime p := minFac_prime f1
have np : n ≤ p :=
le_of_not_ge fun h =>
have h₁ : p ∣ n ! := dvd_factorial (minFac_pos _) h
have h₂ : p ∣ 1 := (Nat.dvd_add_iff_right h₁).2 (minFac_dvd _)
pp.not_dvd_one h₂
⟨p, np, pp⟩
#align nat.exists_infinite_primes Nat.exists_infinite_primes
theorem not_bddAbove_setOf_prime : ¬BddAbove { p | Prime p } := by
rw [not_bddAbove_iff]
intro n
obtain ⟨p, hi, hp⟩ := exists_infinite_primes n.succ
exact ⟨p, hp, hi⟩
#align nat.not_bdd_above_set_of_prime Nat.not_bddAbove_setOf_prime
theorem Prime.eq_two_or_odd {p : ℕ} (hp : Prime p) : p = 2 ∨ p % 2 = 1 :=
p.mod_two_eq_zero_or_one.imp_left fun h =>
((hp.eq_one_or_self_of_dvd 2 (dvd_of_mod_eq_zero h)).resolve_left (by decide)).symm
#align nat.prime.eq_two_or_odd Nat.Prime.eq_two_or_odd
theorem Prime.eq_two_or_odd' {p : ℕ} (hp : Prime p) : p = 2 ∨ Odd p :=
Or.imp_right (fun h => ⟨p / 2, (div_add_mod p 2).symm.trans (congr_arg _ h)⟩) hp.eq_two_or_odd
#align nat.prime.eq_two_or_odd' Nat.Prime.eq_two_or_odd'
theorem Prime.even_iff {p : ℕ} (hp : Prime p) : Even p ↔ p = 2 := by
rw [even_iff_two_dvd, prime_dvd_prime_iff_eq prime_two hp, eq_comm]
#align nat.prime.even_iff Nat.Prime.even_iff
theorem Prime.odd_of_ne_two {p : ℕ} (hp : p.Prime) (h_two : p ≠ 2) : Odd p :=
hp.eq_two_or_odd'.resolve_left h_two
#align nat.prime.odd_of_ne_two Nat.Prime.odd_of_ne_two
theorem Prime.even_sub_one {p : ℕ} (hp : p.Prime) (h2 : p ≠ 2) : Even (p - 1) :=
let ⟨n, hn⟩ := hp.odd_of_ne_two h2; ⟨n, by rw [hn, Nat.add_sub_cancel, two_mul]⟩
#align nat.prime.even_sub_one Nat.Prime.even_sub_one
theorem Prime.mod_two_eq_one_iff_ne_two {p : ℕ} [Fact p.Prime] : p % 2 = 1 ↔ p ≠ 2 := by
refine ⟨fun h hf => ?_, (Nat.Prime.eq_two_or_odd <| @Fact.out p.Prime _).resolve_left⟩
rw [hf] at h
simp at h
#align nat.prime.mod_two_eq_one_iff_ne_two Nat.Prime.mod_two_eq_one_iff_ne_two
theorem coprime_of_dvd {m n : ℕ} (H : ∀ k, Prime k → k ∣ m → ¬k ∣ n) : Coprime m n := by
rw [coprime_iff_gcd_eq_one]
by_contra g2
obtain ⟨p, hp, hpdvd⟩ := exists_prime_and_dvd g2
apply H p hp <;> apply dvd_trans hpdvd
· exact gcd_dvd_left _ _
· exact gcd_dvd_right _ _
#align nat.coprime_of_dvd Nat.coprime_of_dvd
theorem coprime_of_dvd' {m n : ℕ} (H : ∀ k, Prime k → k ∣ m → k ∣ n → k ∣ 1) : Coprime m n :=
coprime_of_dvd fun k kp km kn => not_le_of_gt kp.one_lt <| le_of_dvd zero_lt_one <| H k kp km kn
#align nat.coprime_of_dvd' Nat.coprime_of_dvd'
theorem factors_lemma {k} : (k + 2) / minFac (k + 2) < k + 2 :=
div_lt_self (Nat.zero_lt_succ _) (minFac_prime (by
apply Nat.ne_of_gt
apply Nat.succ_lt_succ
apply Nat.zero_lt_succ
)).one_lt
#align nat.factors_lemma Nat.factors_lemma
theorem Prime.coprime_iff_not_dvd {p n : ℕ} (pp : Prime p) : Coprime p n ↔ ¬p ∣ n :=
⟨fun co d => pp.not_dvd_one <| co.dvd_of_dvd_mul_left (by simp [d]), fun nd =>
coprime_of_dvd fun m m2 mp => ((prime_dvd_prime_iff_eq m2 pp).1 mp).symm ▸ nd⟩
#align nat.prime.coprime_iff_not_dvd Nat.Prime.coprime_iff_not_dvd
theorem Prime.dvd_iff_not_coprime {p n : ℕ} (pp : Prime p) : p ∣ n ↔ ¬Coprime p n :=
iff_not_comm.2 pp.coprime_iff_not_dvd
#align nat.prime.dvd_iff_not_coprime Nat.Prime.dvd_iff_not_coprime
theorem Prime.not_coprime_iff_dvd {m n : ℕ} : ¬Coprime m n ↔ ∃ p, Prime p ∧ p ∣ m ∧ p ∣ n := by
apply Iff.intro
· intro h
exact
⟨minFac (gcd m n), minFac_prime h, (minFac_dvd (gcd m n)).trans (gcd_dvd_left m n),
(minFac_dvd (gcd m n)).trans (gcd_dvd_right m n)⟩
· intro h
cases' h with p hp
apply Nat.not_coprime_of_dvd_of_dvd (Prime.one_lt hp.1) hp.2.1 hp.2.2
#align nat.prime.not_coprime_iff_dvd Nat.Prime.not_coprime_iff_dvd
theorem Prime.dvd_mul {p m n : ℕ} (pp : Prime p) : p ∣ m * n ↔ p ∣ m ∨ p ∣ n :=
⟨fun H => or_iff_not_imp_left.2 fun h => (pp.coprime_iff_not_dvd.2 h).dvd_of_dvd_mul_left H,
Or.rec (fun h : p ∣ m => h.mul_right _) fun h : p ∣ n => h.mul_left _⟩
#align nat.prime.dvd_mul Nat.Prime.dvd_mul
theorem Prime.not_dvd_mul {p m n : ℕ} (pp : Prime p) (Hm : ¬p ∣ m) (Hn : ¬p ∣ n) : ¬p ∣ m * n :=
mt pp.dvd_mul.1 <| by simp [Hm, Hn]
#align nat.prime.not_dvd_mul Nat.Prime.not_dvd_mul
@[simp] lemma coprime_two_left : Coprime 2 n ↔ Odd n := by
rw [prime_two.coprime_iff_not_dvd, odd_iff_not_even, even_iff_two_dvd]
@[simp] lemma coprime_two_right : n.Coprime 2 ↔ Odd n := coprime_comm.trans coprime_two_left
alias ⟨Coprime.odd_of_left, _root_.Odd.coprime_two_left⟩ := coprime_two_left
alias ⟨Coprime.odd_of_right, _root_.Odd.coprime_two_right⟩ := coprime_two_right
theorem prime_iff {p : ℕ} : p.Prime ↔ _root_.Prime p :=
⟨fun h => ⟨h.ne_zero, h.not_unit, fun _ _ => h.dvd_mul.mp⟩, Prime.irreducible⟩
#align nat.prime_iff Nat.prime_iff
alias ⟨Prime.prime, _root_.Prime.nat_prime⟩ := prime_iff
#align nat.prime.prime Nat.Prime.prime
#align prime.nat_prime Prime.nat_prime
-- Porting note: attributes `protected`, `nolint dup_namespace` removed
theorem irreducible_iff_prime {p : ℕ} : Irreducible p ↔ _root_.Prime p :=
prime_iff
#align nat.irreducible_iff_prime Nat.irreducible_iff_prime
theorem Prime.dvd_of_dvd_pow {p m n : ℕ} (pp : Prime p) (h : p ∣ m ^ n) : p ∣ m :=
pp.prime.dvd_of_dvd_pow h
#align nat.prime.dvd_of_dvd_pow Nat.Prime.dvd_of_dvd_pow
theorem Prime.not_prime_pow' {x n : ℕ} (hn : n ≠ 1) : ¬(x ^ n).Prime :=
not_irreducible_pow hn
#align nat.prime.pow_not_prime' Nat.Prime.not_prime_pow'
theorem Prime.not_prime_pow {x n : ℕ} (hn : 2 ≤ n) : ¬(x ^ n).Prime :=
not_prime_pow' ((two_le_iff _).mp hn).2
#align nat.prime.pow_not_prime Nat.Prime.not_prime_pow
theorem Prime.eq_one_of_pow {x n : ℕ} (h : (x ^ n).Prime) : n = 1 :=
not_imp_not.mp Prime.not_prime_pow' h
#align nat.prime.eq_one_of_pow Nat.Prime.eq_one_of_pow
theorem Prime.pow_eq_iff {p a k : ℕ} (hp : p.Prime) : a ^ k = p ↔ a = p ∧ k = 1 := by
refine ⟨fun h => ?_, fun h => by rw [h.1, h.2, pow_one]⟩
rw [← h] at hp
rw [← h, hp.eq_one_of_pow, eq_self_iff_true, and_true_iff, pow_one]
#align nat.prime.pow_eq_iff Nat.Prime.pow_eq_iff
theorem pow_minFac {n k : ℕ} (hk : k ≠ 0) : (n ^ k).minFac = n.minFac := by
rcases eq_or_ne n 1 with (rfl | hn)
· simp
have hnk : n ^ k ≠ 1 := fun hk' => hn ((pow_eq_one_iff hk).1 hk')
apply (minFac_le_of_dvd (minFac_prime hn).two_le ((minFac_dvd n).pow hk)).antisymm
apply
minFac_le_of_dvd (minFac_prime hnk).two_le
((minFac_prime hnk).dvd_of_dvd_pow (minFac_dvd _))
#align nat.pow_min_fac Nat.pow_minFac
theorem Prime.pow_minFac {p k : ℕ} (hp : p.Prime) (hk : k ≠ 0) : (p ^ k).minFac = p := by
rw [Nat.pow_minFac hk, hp.minFac_eq]
#align nat.prime.pow_min_fac Nat.Prime.pow_minFac
theorem Prime.mul_eq_prime_sq_iff {x y p : ℕ} (hp : p.Prime) (hx : x ≠ 1) (hy : y ≠ 1) :
x * y = p ^ 2 ↔ x = p ∧ y = p := by
refine ⟨fun h => ?_, fun ⟨h₁, h₂⟩ => h₁.symm ▸ h₂.symm ▸ (sq _).symm⟩
have pdvdxy : p ∣ x * y := by rw [h]; simp [sq]
-- Could be `wlog := hp.dvd_mul.1 pdvdxy using x y`, but that imports more than we want.
suffices ∀ x' y' : ℕ, x' ≠ 1 → y' ≠ 1 → x' * y' = p ^ 2 → p ∣ x' → x' = p ∧ y' = p by
obtain hx | hy := hp.dvd_mul.1 pdvdxy <;>
[skip; rw [And.comm]] <;>
[skip; rw [mul_comm] at h pdvdxy] <;>
apply this <;>
assumption
rintro x y hx hy h ⟨a, ha⟩
have : a ∣ p := ⟨y, by rwa [ha, sq, mul_assoc, mul_right_inj' hp.ne_zero, eq_comm] at h⟩
obtain ha1 | hap := (Nat.dvd_prime hp).mp ‹a ∣ p›
· subst ha1
rw [mul_one] at ha
subst ha
simp only [sq, mul_right_inj' hp.ne_zero] at h
subst h
exact ⟨rfl, rfl⟩
· refine (hy ?_).elim
subst hap
subst ha
rw [sq, Nat.mul_right_eq_self_iff (Nat.mul_pos hp.pos hp.pos : 0 < a * a)] at h
exact h
#align nat.prime.mul_eq_prime_sq_iff Nat.Prime.mul_eq_prime_sq_iff
theorem Prime.dvd_factorial : ∀ {n p : ℕ} (_ : Prime p), p ∣ n ! ↔ p ≤ n
| 0, p, hp => iff_of_false hp.not_dvd_one (not_le_of_lt hp.pos)
| n + 1, p, hp => by
rw [factorial_succ, hp.dvd_mul, Prime.dvd_factorial hp]
exact
⟨fun h => h.elim (le_of_dvd (succ_pos _)) le_succ_of_le, fun h =>
(_root_.lt_or_eq_of_le h).elim (Or.inr ∘ le_of_lt_succ) fun h => Or.inl <| by rw [h]⟩
#align nat.prime.dvd_factorial Nat.Prime.dvd_factorial
theorem Prime.coprime_pow_of_not_dvd {p m a : ℕ} (pp : Prime p) (h : ¬p ∣ a) : Coprime a (p ^ m) :=
(pp.coprime_iff_not_dvd.2 h).symm.pow_right _
#align nat.prime.coprime_pow_of_not_dvd Nat.Prime.coprime_pow_of_not_dvd
theorem coprime_primes {p q : ℕ} (pp : Prime p) (pq : Prime q) : Coprime p q ↔ p ≠ q :=
pp.coprime_iff_not_dvd.trans <| not_congr <| dvd_prime_two_le pq pp.two_le
#align nat.coprime_primes Nat.coprime_primes
theorem coprime_pow_primes {p q : ℕ} (n m : ℕ) (pp : Prime p) (pq : Prime q) (h : p ≠ q) :
Coprime (p ^ n) (q ^ m) :=
((coprime_primes pp pq).2 h).pow _ _
#align nat.coprime_pow_primes Nat.coprime_pow_primes
theorem coprime_or_dvd_of_prime {p} (pp : Prime p) (i : ℕ) : Coprime p i ∨ p ∣ i := by
rw [pp.dvd_iff_not_coprime]; apply em
#align nat.coprime_or_dvd_of_prime Nat.coprime_or_dvd_of_prime
theorem coprime_of_lt_prime {n p} (n_pos : 0 < n) (hlt : n < p) (pp : Prime p) : Coprime p n :=
(coprime_or_dvd_of_prime pp n).resolve_right fun h => Nat.lt_le_asymm hlt (le_of_dvd n_pos h)
#align nat.coprime_of_lt_prime Nat.coprime_of_lt_prime
theorem eq_or_coprime_of_le_prime {n p} (n_pos : 0 < n) (hle : n ≤ p) (pp : Prime p) :
p = n ∨ Coprime p n :=
hle.eq_or_lt.imp Eq.symm fun h => coprime_of_lt_prime n_pos h pp
#align nat.eq_or_coprime_of_le_prime Nat.eq_or_coprime_of_le_prime
theorem dvd_prime_pow {p : ℕ} (pp : Prime p) {m i : ℕ} : i ∣ p ^ m ↔ ∃ k ≤ m, i = p ^ k := by
simp_rw [_root_.dvd_prime_pow (prime_iff.mp pp) m, associated_eq_eq]
#align nat.dvd_prime_pow Nat.dvd_prime_pow
theorem Prime.dvd_mul_of_dvd_ne {p1 p2 n : ℕ} (h_neq : p1 ≠ p2) (pp1 : Prime p1) (pp2 : Prime p2)
(h1 : p1 ∣ n) (h2 : p2 ∣ n) : p1 * p2 ∣ n :=
Coprime.mul_dvd_of_dvd_of_dvd ((coprime_primes pp1 pp2).mpr h_neq) h1 h2
#align nat.prime.dvd_mul_of_dvd_ne Nat.Prime.dvd_mul_of_dvd_ne
| Mathlib/Data/Nat/Prime.lean | 727 | 731 | theorem eq_prime_pow_of_dvd_least_prime_pow {a p k : ℕ} (pp : Prime p) (h₁ : ¬a ∣ p ^ k)
(h₂ : a ∣ p ^ (k + 1)) : a = p ^ (k + 1) := by |
obtain ⟨l, ⟨h, rfl⟩⟩ := (dvd_prime_pow pp).1 h₂
congr
exact le_antisymm h (not_le.1 ((not_congr (pow_dvd_pow_iff_le_right (Prime.one_lt pp))).1 h₁))
|
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.LinearAlgebra.Determinant
import Mathlib.LinearAlgebra.Matrix.Diagonal
import Mathlib.LinearAlgebra.Matrix.Transvection
import Mathlib.MeasureTheory.Group.LIntegral
import Mathlib.MeasureTheory.Integral.Marginal
import Mathlib.MeasureTheory.Measure.Stieltjes
import Mathlib.MeasureTheory.Measure.Haar.OfBasis
#align_import measure_theory.measure.lebesgue.basic from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
assert_not_exists MeasureTheory.integral
noncomputable section
open scoped Classical
open Set Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ENNReal (ofReal)
open scoped ENNReal NNReal Topology
section regionBetween
variable {α : Type*}
def regionBetween (f g : α → ℝ) (s : Set α) : Set (α × ℝ) :=
{ p : α × ℝ | p.1 ∈ s ∧ p.2 ∈ Ioo (f p.1) (g p.1) }
#align region_between regionBetween
theorem regionBetween_subset (f g : α → ℝ) (s : Set α) : regionBetween f g s ⊆ s ×ˢ univ := by
simpa only [prod_univ, regionBetween, Set.preimage, setOf_subset_setOf] using fun a => And.left
#align region_between_subset regionBetween_subset
variable [MeasurableSpace α] {μ : Measure α} {f g : α → ℝ} {s : Set α}
theorem measurableSet_regionBetween (hf : Measurable f) (hg : Measurable g) (hs : MeasurableSet s) :
MeasurableSet (regionBetween f g s) := by
dsimp only [regionBetween, Ioo, mem_setOf_eq, setOf_and]
refine
MeasurableSet.inter ?_
((measurableSet_lt (hf.comp measurable_fst) measurable_snd).inter
(measurableSet_lt measurable_snd (hg.comp measurable_fst)))
exact measurable_fst hs
#align measurable_set_region_between measurableSet_regionBetween
| Mathlib/MeasureTheory/Measure/Lebesgue/Basic.lean | 468 | 476 | theorem measurableSet_region_between_oc (hf : Measurable f) (hg : Measurable g)
(hs : MeasurableSet s) :
MeasurableSet { p : α × ℝ | p.fst ∈ s ∧ p.snd ∈ Ioc (f p.fst) (g p.fst) } := by |
dsimp only [regionBetween, Ioc, mem_setOf_eq, setOf_and]
refine
MeasurableSet.inter ?_
((measurableSet_lt (hf.comp measurable_fst) measurable_snd).inter
(measurableSet_le measurable_snd (hg.comp measurable_fst)))
exact measurable_fst hs
|
import Mathlib.Tactic.CategoryTheory.Coherence
import Mathlib.CategoryTheory.Monoidal.Free.Coherence
#align_import category_theory.monoidal.coherence_lemmas from "leanprover-community/mathlib"@"b8b8bf3ea0c625fa1f950034a184e07c67f7bcfe"
open CategoryTheory Category Iso
namespace CategoryTheory.MonoidalCategory
variable {C : Type*} [Category C] [MonoidalCategory C]
-- See Proposition 2.2.4 of <http://www-math.mit.edu/~etingof/egnobookfinal.pdf>
@[reassoc]
theorem leftUnitor_tensor'' (X Y : C) :
(α_ (𝟙_ C) X Y).hom ≫ (λ_ (X ⊗ Y)).hom = (λ_ X).hom ⊗ 𝟙 Y := by
coherence
#align category_theory.monoidal_category.left_unitor_tensor' CategoryTheory.MonoidalCategory.leftUnitor_tensor''
@[reassoc]
theorem leftUnitor_tensor' (X Y : C) :
(λ_ (X ⊗ Y)).hom = (α_ (𝟙_ C) X Y).inv ≫ ((λ_ X).hom ⊗ 𝟙 Y) := by
coherence
#align category_theory.monoidal_category.left_unitor_tensor CategoryTheory.MonoidalCategory.leftUnitor_tensor'
@[reassoc]
theorem leftUnitor_tensor_inv' (X Y : C) :
(λ_ (X ⊗ Y)).inv = ((λ_ X).inv ⊗ 𝟙 Y) ≫ (α_ (𝟙_ C) X Y).hom := by coherence
#align category_theory.monoidal_category.left_unitor_tensor_inv CategoryTheory.MonoidalCategory.leftUnitor_tensor_inv'
@[reassoc]
theorem id_tensor_rightUnitor_inv (X Y : C) : 𝟙 X ⊗ (ρ_ Y).inv = (ρ_ _).inv ≫ (α_ _ _ _).hom := by
coherence
#align category_theory.monoidal_category.id_tensor_right_unitor_inv CategoryTheory.MonoidalCategory.id_tensor_rightUnitor_inv
@[reassoc]
theorem leftUnitor_inv_tensor_id (X Y : C) : (λ_ X).inv ⊗ 𝟙 Y = (λ_ _).inv ≫ (α_ _ _ _).inv := by
coherence
#align category_theory.monoidal_category.left_unitor_inv_tensor_id CategoryTheory.MonoidalCategory.leftUnitor_inv_tensor_id
@[reassoc]
theorem pentagon_inv_inv_hom (W X Y Z : C) :
(α_ W (X ⊗ Y) Z).inv ≫ ((α_ W X Y).inv ⊗ 𝟙 Z) ≫ (α_ (W ⊗ X) Y Z).hom =
(𝟙 W ⊗ (α_ X Y Z).hom) ≫ (α_ W X (Y ⊗ Z)).inv := by
coherence
#align category_theory.monoidal_category.pentagon_inv_inv_hom CategoryTheory.MonoidalCategory.pentagon_inv_inv_hom
theorem unitors_equal : (λ_ (𝟙_ C)).hom = (ρ_ (𝟙_ C)).hom := by
coherence
#align category_theory.monoidal_category.unitors_equal CategoryTheory.MonoidalCategory.unitors_equal
theorem unitors_inv_equal : (λ_ (𝟙_ C)).inv = (ρ_ (𝟙_ C)).inv := by
coherence
#align category_theory.monoidal_category.unitors_inv_equal CategoryTheory.MonoidalCategory.unitors_inv_equal
@[reassoc]
| Mathlib/CategoryTheory/Monoidal/CoherenceLemmas.lean | 72 | 75 | theorem pentagon_hom_inv {W X Y Z : C} :
(α_ W X (Y ⊗ Z)).hom ≫ (𝟙 W ⊗ (α_ X Y Z).inv) =
(α_ (W ⊗ X) Y Z).inv ≫ ((α_ W X Y).hom ⊗ 𝟙 Z) ≫ (α_ W (X ⊗ Y) Z).hom := by |
coherence
|
import Mathlib.Algebra.BigOperators.Module
import Mathlib.Algebra.Order.Field.Basic
import Mathlib.Order.Filter.ModEq
import Mathlib.Analysis.Asymptotics.Asymptotics
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.List.TFAE
import Mathlib.Analysis.NormedSpace.Basic
#align_import analysis.specific_limits.normed from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
noncomputable section
open scoped Classical
open Set Function Filter Finset Metric Asymptotics
open scoped Classical
open Topology Nat uniformity NNReal ENNReal
variable {α : Type*} {β : Type*} {ι : Type*}
theorem tendsto_norm_atTop_atTop : Tendsto (norm : ℝ → ℝ) atTop atTop :=
tendsto_abs_atTop_atTop
#align tendsto_norm_at_top_at_top tendsto_norm_atTop_atTop
theorem summable_of_absolute_convergence_real {f : ℕ → ℝ} :
(∃ r, Tendsto (fun n ↦ ∑ i ∈ range n, |f i|) atTop (𝓝 r)) → Summable f
| ⟨r, hr⟩ => by
refine .of_norm ⟨r, (hasSum_iff_tendsto_nat_of_nonneg ?_ _).2 ?_⟩
· exact fun i ↦ norm_nonneg _
· simpa only using hr
#align summable_of_absolute_convergence_real summable_of_absolute_convergence_real
theorem tendsto_norm_zero' {𝕜 : Type*} [NormedAddCommGroup 𝕜] :
Tendsto (norm : 𝕜 → ℝ) (𝓝[≠] 0) (𝓝[>] 0) :=
tendsto_norm_zero.inf <| tendsto_principal_principal.2 fun _ hx ↦ norm_pos_iff.2 hx
#align tendsto_norm_zero' tendsto_norm_zero'
theorem isLittleO_pow_pow_of_lt_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ < r₂) :
(fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n :=
have H : 0 < r₂ := h₁.trans_lt h₂
(isLittleO_of_tendsto fun _ hn ↦ False.elim <| H.ne' <| pow_eq_zero hn) <|
(tendsto_pow_atTop_nhds_zero_of_lt_one
(div_nonneg h₁ (h₁.trans h₂.le)) ((div_lt_one H).2 h₂)).congr fun _ ↦ div_pow _ _ _
#align is_o_pow_pow_of_lt_left isLittleO_pow_pow_of_lt_left
theorem isBigO_pow_pow_of_le_left {r₁ r₂ : ℝ} (h₁ : 0 ≤ r₁) (h₂ : r₁ ≤ r₂) :
(fun n : ℕ ↦ r₁ ^ n) =O[atTop] fun n ↦ r₂ ^ n :=
h₂.eq_or_lt.elim (fun h ↦ h ▸ isBigO_refl _ _) fun h ↦ (isLittleO_pow_pow_of_lt_left h₁ h).isBigO
set_option linter.uppercaseLean3 false in
#align is_O_pow_pow_of_le_left isBigO_pow_pow_of_le_left
theorem isLittleO_pow_pow_of_abs_lt_left {r₁ r₂ : ℝ} (h : |r₁| < |r₂|) :
(fun n : ℕ ↦ r₁ ^ n) =o[atTop] fun n ↦ r₂ ^ n := by
refine (IsLittleO.of_norm_left ?_).of_norm_right
exact (isLittleO_pow_pow_of_lt_left (abs_nonneg r₁) h).congr (pow_abs r₁) (pow_abs r₂)
#align is_o_pow_pow_of_abs_lt_left isLittleO_pow_pow_of_abs_lt_left
open List in
theorem TFAE_exists_lt_isLittleO_pow (f : ℕ → ℝ) (R : ℝ) :
TFAE
[∃ a ∈ Ioo (-R) R, f =o[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =o[atTop] (a ^ ·),
∃ a ∈ Ioo (-R) R, f =O[atTop] (a ^ ·), ∃ a ∈ Ioo 0 R, f =O[atTop] (a ^ ·),
∃ a < R, ∃ C : ℝ, (0 < C ∨ 0 < R) ∧ ∀ n, |f n| ≤ C * a ^ n,
∃ a ∈ Ioo 0 R, ∃ C > 0, ∀ n, |f n| ≤ C * a ^ n, ∃ a < R, ∀ᶠ n in atTop, |f n| ≤ a ^ n,
∃ a ∈ Ioo 0 R, ∀ᶠ n in atTop, |f n| ≤ a ^ n] := by
have A : Ico 0 R ⊆ Ioo (-R) R :=
fun x hx ↦ ⟨(neg_lt_zero.2 (hx.1.trans_lt hx.2)).trans_le hx.1, hx.2⟩
have B : Ioo 0 R ⊆ Ioo (-R) R := Subset.trans Ioo_subset_Ico_self A
-- First we prove that 1-4 are equivalent using 2 → 3 → 4, 1 → 3, and 2 → 1
tfae_have 1 → 3
· exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩
tfae_have 2 → 1
· exact fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩
tfae_have 3 → 2
· rintro ⟨a, ha, H⟩
rcases exists_between (abs_lt.2 ha) with ⟨b, hab, hbR⟩
exact ⟨b, ⟨(abs_nonneg a).trans_lt hab, hbR⟩,
H.trans_isLittleO (isLittleO_pow_pow_of_abs_lt_left (hab.trans_le (le_abs_self b)))⟩
tfae_have 2 → 4
· exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha, H.isBigO⟩
tfae_have 4 → 3
· exact fun ⟨a, ha, H⟩ ↦ ⟨a, B ha, H⟩
-- Add 5 and 6 using 4 → 6 → 5 → 3
tfae_have 4 → 6
· rintro ⟨a, ha, H⟩
rcases bound_of_isBigO_nat_atTop H with ⟨C, hC₀, hC⟩
refine ⟨a, ha, C, hC₀, fun n ↦ ?_⟩
simpa only [Real.norm_eq_abs, abs_pow, abs_of_nonneg ha.1.le] using hC (pow_ne_zero n ha.1.ne')
tfae_have 6 → 5
· exact fun ⟨a, ha, C, H₀, H⟩ ↦ ⟨a, ha.2, C, Or.inl H₀, H⟩
tfae_have 5 → 3
· rintro ⟨a, ha, C, h₀, H⟩
rcases sign_cases_of_C_mul_pow_nonneg fun n ↦ (abs_nonneg _).trans (H n) with (rfl | ⟨hC₀, ha₀⟩)
· obtain rfl : f = 0 := by
ext n
simpa using H n
simp only [lt_irrefl, false_or_iff] at h₀
exact ⟨0, ⟨neg_lt_zero.2 h₀, h₀⟩, isBigO_zero _ _⟩
exact ⟨a, A ⟨ha₀, ha⟩,
isBigO_of_le' _ fun n ↦ (H n).trans <| mul_le_mul_of_nonneg_left (le_abs_self _) hC₀.le⟩
-- Add 7 and 8 using 2 → 8 → 7 → 3
tfae_have 2 → 8
· rintro ⟨a, ha, H⟩
refine ⟨a, ha, (H.def zero_lt_one).mono fun n hn ↦ ?_⟩
rwa [Real.norm_eq_abs, Real.norm_eq_abs, one_mul, abs_pow, abs_of_pos ha.1] at hn
tfae_have 8 → 7
· exact fun ⟨a, ha, H⟩ ↦ ⟨a, ha.2, H⟩
tfae_have 7 → 3
· rintro ⟨a, ha, H⟩
have : 0 ≤ a := nonneg_of_eventually_pow_nonneg (H.mono fun n ↦ (abs_nonneg _).trans)
refine ⟨a, A ⟨this, ha⟩, IsBigO.of_bound 1 ?_⟩
simpa only [Real.norm_eq_abs, one_mul, abs_pow, abs_of_nonneg this]
-- Porting note: used to work without explicitly having 6 → 7
tfae_have 6 → 7
· exact fun h ↦ tfae_8_to_7 <| tfae_2_to_8 <| tfae_3_to_2 <| tfae_5_to_3 <| tfae_6_to_5 h
tfae_finish
#align tfae_exists_lt_is_o_pow TFAE_exists_lt_isLittleO_pow
theorem isLittleO_pow_const_const_pow_of_one_lt {R : Type*} [NormedRing R] (k : ℕ) {r : ℝ}
(hr : 1 < r) : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ r ^ n := by
have : Tendsto (fun x : ℝ ↦ x ^ k) (𝓝[>] 1) (𝓝 1) :=
((continuous_id.pow k).tendsto' (1 : ℝ) 1 (one_pow _)).mono_left inf_le_left
obtain ⟨r' : ℝ, hr' : r' ^ k < r, h1 : 1 < r'⟩ :=
((this.eventually (gt_mem_nhds hr)).and self_mem_nhdsWithin).exists
have h0 : 0 ≤ r' := zero_le_one.trans h1.le
suffices (fun n ↦ (n : R) ^ k : ℕ → R) =O[atTop] fun n : ℕ ↦ (r' ^ k) ^ n from
this.trans_isLittleO (isLittleO_pow_pow_of_lt_left (pow_nonneg h0 _) hr')
conv in (r' ^ _) ^ _ => rw [← pow_mul, mul_comm, pow_mul]
suffices ∀ n : ℕ, ‖(n : R)‖ ≤ (r' - 1)⁻¹ * ‖(1 : R)‖ * ‖r' ^ n‖ from
(isBigO_of_le' _ this).pow _
intro n
rw [mul_right_comm]
refine n.norm_cast_le.trans (mul_le_mul_of_nonneg_right ?_ (norm_nonneg _))
simpa [_root_.div_eq_inv_mul, Real.norm_eq_abs, abs_of_nonneg h0] using n.cast_le_pow_div_sub h1
#align is_o_pow_const_const_pow_of_one_lt isLittleO_pow_const_const_pow_of_one_lt
theorem isLittleO_coe_const_pow_of_one_lt {R : Type*} [NormedRing R] {r : ℝ} (hr : 1 < r) :
((↑) : ℕ → R) =o[atTop] fun n ↦ r ^ n := by
simpa only [pow_one] using @isLittleO_pow_const_const_pow_of_one_lt R _ 1 _ hr
#align is_o_coe_const_pow_of_one_lt isLittleO_coe_const_pow_of_one_lt
theorem isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt {R : Type*} [NormedRing R] (k : ℕ)
{r₁ : R} {r₂ : ℝ} (h : ‖r₁‖ < r₂) :
(fun n ↦ (n : R) ^ k * r₁ ^ n : ℕ → R) =o[atTop] fun n ↦ r₂ ^ n := by
by_cases h0 : r₁ = 0
· refine (isLittleO_zero _ _).congr' (mem_atTop_sets.2 <| ⟨1, fun n hn ↦ ?_⟩) EventuallyEq.rfl
simp [zero_pow (one_le_iff_ne_zero.1 hn), h0]
rw [← Ne, ← norm_pos_iff] at h0
have A : (fun n ↦ (n : R) ^ k : ℕ → R) =o[atTop] fun n ↦ (r₂ / ‖r₁‖) ^ n :=
isLittleO_pow_const_const_pow_of_one_lt k ((one_lt_div h0).2 h)
suffices (fun n ↦ r₁ ^ n) =O[atTop] fun n ↦ ‖r₁‖ ^ n by
simpa [div_mul_cancel₀ _ (pow_pos h0 _).ne'] using A.mul_isBigO this
exact IsBigO.of_bound 1 (by simpa using eventually_norm_pow_le r₁)
#align is_o_pow_const_mul_const_pow_const_pow_of_norm_lt isLittleO_pow_const_mul_const_pow_const_pow_of_norm_lt
theorem tendsto_pow_const_div_const_pow_of_one_lt (k : ℕ) {r : ℝ} (hr : 1 < r) :
Tendsto (fun n ↦ (n : ℝ) ^ k / r ^ n : ℕ → ℝ) atTop (𝓝 0) :=
(isLittleO_pow_const_const_pow_of_one_lt k hr).tendsto_div_nhds_zero
#align tendsto_pow_const_div_const_pow_of_one_lt tendsto_pow_const_div_const_pow_of_one_lt
theorem tendsto_pow_const_mul_const_pow_of_abs_lt_one (k : ℕ) {r : ℝ} (hr : |r| < 1) :
Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
by_cases h0 : r = 0
· exact tendsto_const_nhds.congr'
(mem_atTop_sets.2 ⟨1, fun n hn ↦ by simp [zero_lt_one.trans_le hn |>.ne', h0]⟩)
have hr' : 1 < |r|⁻¹ := one_lt_inv (abs_pos.2 h0) hr
rw [tendsto_zero_iff_norm_tendsto_zero]
simpa [div_eq_mul_inv] using tendsto_pow_const_div_const_pow_of_one_lt k hr'
#align tendsto_pow_const_mul_const_pow_of_abs_lt_one tendsto_pow_const_mul_const_pow_of_abs_lt_one
theorem tendsto_pow_const_mul_const_pow_of_lt_one (k : ℕ) {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
Tendsto (fun n ↦ (n : ℝ) ^ k * r ^ n : ℕ → ℝ) atTop (𝓝 0) :=
tendsto_pow_const_mul_const_pow_of_abs_lt_one k (abs_lt.2 ⟨neg_one_lt_zero.trans_le hr, h'r⟩)
#align tendsto_pow_const_mul_const_pow_of_lt_one tendsto_pow_const_mul_const_pow_of_lt_one
theorem tendsto_self_mul_const_pow_of_abs_lt_one {r : ℝ} (hr : |r| < 1) :
Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_abs_lt_one 1 hr
#align tendsto_self_mul_const_pow_of_abs_lt_one tendsto_self_mul_const_pow_of_abs_lt_one
theorem tendsto_self_mul_const_pow_of_lt_one {r : ℝ} (hr : 0 ≤ r) (h'r : r < 1) :
Tendsto (fun n ↦ n * r ^ n : ℕ → ℝ) atTop (𝓝 0) := by
simpa only [pow_one] using tendsto_pow_const_mul_const_pow_of_lt_one 1 hr h'r
#align tendsto_self_mul_const_pow_of_lt_one tendsto_self_mul_const_pow_of_lt_one
theorem tendsto_pow_atTop_nhds_zero_of_norm_lt_one {R : Type*} [NormedRing R] {x : R}
(h : ‖x‖ < 1) :
Tendsto (fun n : ℕ ↦ x ^ n) atTop (𝓝 0) := by
apply squeeze_zero_norm' (eventually_norm_pow_le x)
exact tendsto_pow_atTop_nhds_zero_of_lt_one (norm_nonneg _) h
#align tendsto_pow_at_top_nhds_0_of_norm_lt_1 tendsto_pow_atTop_nhds_zero_of_norm_lt_one
@[deprecated (since := "2024-01-31")]
alias tendsto_pow_atTop_nhds_0_of_norm_lt_1 := tendsto_pow_atTop_nhds_zero_of_norm_lt_one
theorem tendsto_pow_atTop_nhds_zero_of_abs_lt_one {r : ℝ} (h : |r| < 1) :
Tendsto (fun n : ℕ ↦ r ^ n) atTop (𝓝 0) :=
tendsto_pow_atTop_nhds_zero_of_norm_lt_one h
#align tendsto_pow_at_top_nhds_0_of_abs_lt_1 tendsto_pow_atTop_nhds_zero_of_abs_lt_one
@[deprecated (since := "2024-01-31")]
alias tendsto_pow_atTop_nhds_0_of_abs_lt_1 := tendsto_pow_atTop_nhds_zero_of_abs_lt_one
section SummableLeGeometric
variable [SeminormedAddCommGroup α] {r C : ℝ} {f : ℕ → α}
nonrec theorem SeminormedAddCommGroup.cauchySeq_of_le_geometric {C : ℝ} {r : ℝ} (hr : r < 1)
{u : ℕ → α} (h : ∀ n, ‖u n - u (n + 1)‖ ≤ C * r ^ n) : CauchySeq u :=
cauchySeq_of_le_geometric r C hr (by simpa [dist_eq_norm] using h)
#align seminormed_add_comm_group.cauchy_seq_of_le_geometric SeminormedAddCommGroup.cauchySeq_of_le_geometric
theorem dist_partial_sum_le_of_le_geometric (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) (n : ℕ) :
dist (∑ i ∈ range n, f i) (∑ i ∈ range (n + 1), f i) ≤ C * r ^ n := by
rw [sum_range_succ, dist_eq_norm, ← norm_neg, neg_sub, add_sub_cancel_left]
exact hf n
#align dist_partial_sum_le_of_le_geometric dist_partial_sum_le_of_le_geometric
theorem cauchySeq_finset_of_geometric_bound (hr : r < 1) (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) :
CauchySeq fun s : Finset ℕ ↦ ∑ x ∈ s, f x :=
cauchySeq_finset_of_norm_bounded _
(aux_hasSum_of_le_geometric hr (dist_partial_sum_le_of_le_geometric hf)).summable hf
#align cauchy_seq_finset_of_geometric_bound cauchySeq_finset_of_geometric_bound
theorem norm_sub_le_of_geometric_bound_of_hasSum (hr : r < 1) (hf : ∀ n, ‖f n‖ ≤ C * r ^ n) {a : α}
(ha : HasSum f a) (n : ℕ) : ‖(∑ x ∈ Finset.range n, f x) - a‖ ≤ C * r ^ n / (1 - r) := by
rw [← dist_eq_norm]
apply dist_le_of_le_geometric_of_tendsto r C hr (dist_partial_sum_le_of_le_geometric hf)
exact ha.tendsto_sum_nat
#align norm_sub_le_of_geometric_bound_of_has_sum norm_sub_le_of_geometric_bound_of_hasSum
@[simp]
theorem dist_partial_sum (u : ℕ → α) (n : ℕ) :
dist (∑ k ∈ range (n + 1), u k) (∑ k ∈ range n, u k) = ‖u n‖ := by
simp [dist_eq_norm, sum_range_succ]
#align dist_partial_sum dist_partial_sum
@[simp]
theorem dist_partial_sum' (u : ℕ → α) (n : ℕ) :
dist (∑ k ∈ range n, u k) (∑ k ∈ range (n + 1), u k) = ‖u n‖ := by
simp [dist_eq_norm', sum_range_succ]
#align dist_partial_sum' dist_partial_sum'
theorem cauchy_series_of_le_geometric {C : ℝ} {u : ℕ → α} {r : ℝ} (hr : r < 1)
(h : ∀ n, ‖u n‖ ≤ C * r ^ n) : CauchySeq fun n ↦ ∑ k ∈ range n, u k :=
cauchySeq_of_le_geometric r C hr (by simp [h])
#align cauchy_series_of_le_geometric cauchy_series_of_le_geometric
theorem NormedAddCommGroup.cauchy_series_of_le_geometric' {C : ℝ} {u : ℕ → α} {r : ℝ} (hr : r < 1)
(h : ∀ n, ‖u n‖ ≤ C * r ^ n) : CauchySeq fun n ↦ ∑ k ∈ range (n + 1), u k :=
(cauchy_series_of_le_geometric hr h).comp_tendsto <| tendsto_add_atTop_nat 1
#align normed_add_comm_group.cauchy_series_of_le_geometric' NormedAddCommGroup.cauchy_series_of_le_geometric'
| Mathlib/Analysis/SpecificLimits/Normed.lean | 477 | 495 | theorem NormedAddCommGroup.cauchy_series_of_le_geometric'' {C : ℝ} {u : ℕ → α} {N : ℕ} {r : ℝ}
(hr₀ : 0 < r) (hr₁ : r < 1) (h : ∀ n ≥ N, ‖u n‖ ≤ C * r ^ n) :
CauchySeq fun n ↦ ∑ k ∈ range (n + 1), u k := by |
set v : ℕ → α := fun n ↦ if n < N then 0 else u n
have hC : 0 ≤ C :=
(mul_nonneg_iff_of_pos_right <| pow_pos hr₀ N).mp ((norm_nonneg _).trans <| h N <| le_refl N)
have : ∀ n ≥ N, u n = v n := by
intro n hn
simp [v, hn, if_neg (not_lt.mpr hn)]
apply cauchySeq_sum_of_eventually_eq this
(NormedAddCommGroup.cauchy_series_of_le_geometric' hr₁ _)
· exact C
intro n
simp only [v]
split_ifs with H
· rw [norm_zero]
exact mul_nonneg hC (pow_nonneg hr₀.le _)
· push_neg at H
exact h _ H
|
import Mathlib.Logic.Pairwise
import Mathlib.Order.CompleteBooleanAlgebra
import Mathlib.Order.Directed
import Mathlib.Order.GaloisConnection
#align_import data.set.lattice from "leanprover-community/mathlib"@"b86832321b586c6ac23ef8cdef6a7a27e42b13bd"
open Function Set
universe u
variable {α β γ : Type*} {ι ι' ι₂ : Sort*} {κ κ₁ κ₂ : ι → Sort*} {κ' : ι' → Sort*}
namespace Set
theorem mem_iUnion₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋃ (i) (j), s i j) ↔ ∃ i j, x ∈ s i j := by
simp_rw [mem_iUnion]
#align set.mem_Union₂ Set.mem_iUnion₂
theorem mem_iInter₂ {x : γ} {s : ∀ i, κ i → Set γ} : (x ∈ ⋂ (i) (j), s i j) ↔ ∀ i j, x ∈ s i j := by
simp_rw [mem_iInter]
#align set.mem_Inter₂ Set.mem_iInter₂
theorem mem_iUnion_of_mem {s : ι → Set α} {a : α} (i : ι) (ha : a ∈ s i) : a ∈ ⋃ i, s i :=
mem_iUnion.2 ⟨i, ha⟩
#align set.mem_Union_of_mem Set.mem_iUnion_of_mem
theorem mem_iUnion₂_of_mem {s : ∀ i, κ i → Set α} {a : α} {i : ι} (j : κ i) (ha : a ∈ s i j) :
a ∈ ⋃ (i) (j), s i j :=
mem_iUnion₂.2 ⟨i, j, ha⟩
#align set.mem_Union₂_of_mem Set.mem_iUnion₂_of_mem
theorem mem_iInter_of_mem {s : ι → Set α} {a : α} (h : ∀ i, a ∈ s i) : a ∈ ⋂ i, s i :=
mem_iInter.2 h
#align set.mem_Inter_of_mem Set.mem_iInter_of_mem
theorem mem_iInter₂_of_mem {s : ∀ i, κ i → Set α} {a : α} (h : ∀ i j, a ∈ s i j) :
a ∈ ⋂ (i) (j), s i j :=
mem_iInter₂.2 h
#align set.mem_Inter₂_of_mem Set.mem_iInter₂_of_mem
instance completeAtomicBooleanAlgebra : CompleteAtomicBooleanAlgebra (Set α) :=
{ instBooleanAlgebraSet with
le_sSup := fun s t t_in a a_in => ⟨t, t_in, a_in⟩
sSup_le := fun s t h a ⟨t', ⟨t'_in, a_in⟩⟩ => h t' t'_in a_in
le_sInf := fun s t h a a_in t' t'_in => h t' t'_in a_in
sInf_le := fun s t t_in a h => h _ t_in
iInf_iSup_eq := by intros; ext; simp [Classical.skolem] }
instance : OrderTop (Set α) where
top := univ
le_top := by simp
@[congr]
theorem iUnion_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q)
(f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iUnion f₁ = iUnion f₂ :=
iSup_congr_Prop pq f
#align set.Union_congr_Prop Set.iUnion_congr_Prop
@[congr]
theorem iInter_congr_Prop {p q : Prop} {f₁ : p → Set α} {f₂ : q → Set α} (pq : p ↔ q)
(f : ∀ x, f₁ (pq.mpr x) = f₂ x) : iInter f₁ = iInter f₂ :=
iInf_congr_Prop pq f
#align set.Inter_congr_Prop Set.iInter_congr_Prop
theorem iUnion_plift_up (f : PLift ι → Set α) : ⋃ i, f (PLift.up i) = ⋃ i, f i :=
iSup_plift_up _
#align set.Union_plift_up Set.iUnion_plift_up
theorem iUnion_plift_down (f : ι → Set α) : ⋃ i, f (PLift.down i) = ⋃ i, f i :=
iSup_plift_down _
#align set.Union_plift_down Set.iUnion_plift_down
theorem iInter_plift_up (f : PLift ι → Set α) : ⋂ i, f (PLift.up i) = ⋂ i, f i :=
iInf_plift_up _
#align set.Inter_plift_up Set.iInter_plift_up
theorem iInter_plift_down (f : ι → Set α) : ⋂ i, f (PLift.down i) = ⋂ i, f i :=
iInf_plift_down _
#align set.Inter_plift_down Set.iInter_plift_down
theorem iUnion_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋃ _ : p, s = if p then s else ∅ :=
iSup_eq_if _
#align set.Union_eq_if Set.iUnion_eq_if
theorem iUnion_eq_dif {p : Prop} [Decidable p] (s : p → Set α) :
⋃ h : p, s h = if h : p then s h else ∅ :=
iSup_eq_dif _
#align set.Union_eq_dif Set.iUnion_eq_dif
theorem iInter_eq_if {p : Prop} [Decidable p] (s : Set α) : ⋂ _ : p, s = if p then s else univ :=
iInf_eq_if _
#align set.Inter_eq_if Set.iInter_eq_if
theorem iInf_eq_dif {p : Prop} [Decidable p] (s : p → Set α) :
⋂ h : p, s h = if h : p then s h else univ :=
_root_.iInf_eq_dif _
#align set.Infi_eq_dif Set.iInf_eq_dif
theorem exists_set_mem_of_union_eq_top {ι : Type*} (t : Set ι) (s : ι → Set β)
(w : ⋃ i ∈ t, s i = ⊤) (x : β) : ∃ i ∈ t, x ∈ s i := by
have p : x ∈ ⊤ := Set.mem_univ x
rw [← w, Set.mem_iUnion] at p
simpa using p
#align set.exists_set_mem_of_union_eq_top Set.exists_set_mem_of_union_eq_top
theorem nonempty_of_union_eq_top_of_nonempty {ι : Type*} (t : Set ι) (s : ι → Set α)
(H : Nonempty α) (w : ⋃ i ∈ t, s i = ⊤) : t.Nonempty := by
obtain ⟨x, m, -⟩ := exists_set_mem_of_union_eq_top t s w H.some
exact ⟨x, m⟩
#align set.nonempty_of_union_eq_top_of_nonempty Set.nonempty_of_union_eq_top_of_nonempty
theorem nonempty_of_nonempty_iUnion
{s : ι → Set α} (h_Union : (⋃ i, s i).Nonempty) : Nonempty ι := by
obtain ⟨x, hx⟩ := h_Union
exact ⟨Classical.choose <| mem_iUnion.mp hx⟩
theorem nonempty_of_nonempty_iUnion_eq_univ
{s : ι → Set α} [Nonempty α] (h_Union : ⋃ i, s i = univ) : Nonempty ι :=
nonempty_of_nonempty_iUnion (s := s) (by simpa only [h_Union] using univ_nonempty)
theorem setOf_exists (p : ι → β → Prop) : { x | ∃ i, p i x } = ⋃ i, { x | p i x } :=
ext fun _ => mem_iUnion.symm
#align set.set_of_exists Set.setOf_exists
theorem setOf_forall (p : ι → β → Prop) : { x | ∀ i, p i x } = ⋂ i, { x | p i x } :=
ext fun _ => mem_iInter.symm
#align set.set_of_forall Set.setOf_forall
theorem iUnion_subset {s : ι → Set α} {t : Set α} (h : ∀ i, s i ⊆ t) : ⋃ i, s i ⊆ t :=
iSup_le h
#align set.Union_subset Set.iUnion_subset
theorem iUnion₂_subset {s : ∀ i, κ i → Set α} {t : Set α} (h : ∀ i j, s i j ⊆ t) :
⋃ (i) (j), s i j ⊆ t :=
iUnion_subset fun x => iUnion_subset (h x)
#align set.Union₂_subset Set.iUnion₂_subset
theorem subset_iInter {t : Set β} {s : ι → Set β} (h : ∀ i, t ⊆ s i) : t ⊆ ⋂ i, s i :=
le_iInf h
#align set.subset_Inter Set.subset_iInter
theorem subset_iInter₂ {s : Set α} {t : ∀ i, κ i → Set α} (h : ∀ i j, s ⊆ t i j) :
s ⊆ ⋂ (i) (j), t i j :=
subset_iInter fun x => subset_iInter <| h x
#align set.subset_Inter₂ Set.subset_iInter₂
@[simp]
theorem iUnion_subset_iff {s : ι → Set α} {t : Set α} : ⋃ i, s i ⊆ t ↔ ∀ i, s i ⊆ t :=
⟨fun h _ => Subset.trans (le_iSup s _) h, iUnion_subset⟩
#align set.Union_subset_iff Set.iUnion_subset_iff
theorem iUnion₂_subset_iff {s : ∀ i, κ i → Set α} {t : Set α} :
⋃ (i) (j), s i j ⊆ t ↔ ∀ i j, s i j ⊆ t := by simp_rw [iUnion_subset_iff]
#align set.Union₂_subset_iff Set.iUnion₂_subset_iff
@[simp]
theorem subset_iInter_iff {s : Set α} {t : ι → Set α} : (s ⊆ ⋂ i, t i) ↔ ∀ i, s ⊆ t i :=
le_iInf_iff
#align set.subset_Inter_iff Set.subset_iInter_iff
-- Porting note (#10618): removing `simp`. `simp` can prove it
theorem subset_iInter₂_iff {s : Set α} {t : ∀ i, κ i → Set α} :
(s ⊆ ⋂ (i) (j), t i j) ↔ ∀ i j, s ⊆ t i j := by simp_rw [subset_iInter_iff]
#align set.subset_Inter₂_iff Set.subset_iInter₂_iff
theorem subset_iUnion : ∀ (s : ι → Set β) (i : ι), s i ⊆ ⋃ i, s i :=
le_iSup
#align set.subset_Union Set.subset_iUnion
theorem iInter_subset : ∀ (s : ι → Set β) (i : ι), ⋂ i, s i ⊆ s i :=
iInf_le
#align set.Inter_subset Set.iInter_subset
theorem subset_iUnion₂ {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : s i j ⊆ ⋃ (i') (j'), s i' j' :=
le_iSup₂ i j
#align set.subset_Union₂ Set.subset_iUnion₂
theorem iInter₂_subset {s : ∀ i, κ i → Set α} (i : ι) (j : κ i) : ⋂ (i) (j), s i j ⊆ s i j :=
iInf₂_le i j
#align set.Inter₂_subset Set.iInter₂_subset
theorem subset_iUnion_of_subset {s : Set α} {t : ι → Set α} (i : ι) (h : s ⊆ t i) : s ⊆ ⋃ i, t i :=
le_iSup_of_le i h
#align set.subset_Union_of_subset Set.subset_iUnion_of_subset
theorem iInter_subset_of_subset {s : ι → Set α} {t : Set α} (i : ι) (h : s i ⊆ t) :
⋂ i, s i ⊆ t :=
iInf_le_of_le i h
#align set.Inter_subset_of_subset Set.iInter_subset_of_subset
theorem subset_iUnion₂_of_subset {s : Set α} {t : ∀ i, κ i → Set α} (i : ι) (j : κ i)
(h : s ⊆ t i j) : s ⊆ ⋃ (i) (j), t i j :=
le_iSup₂_of_le i j h
#align set.subset_Union₂_of_subset Set.subset_iUnion₂_of_subset
theorem iInter₂_subset_of_subset {s : ∀ i, κ i → Set α} {t : Set α} (i : ι) (j : κ i)
(h : s i j ⊆ t) : ⋂ (i) (j), s i j ⊆ t :=
iInf₂_le_of_le i j h
#align set.Inter₂_subset_of_subset Set.iInter₂_subset_of_subset
theorem iUnion_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋃ i, s i ⊆ ⋃ i, t i :=
iSup_mono h
#align set.Union_mono Set.iUnion_mono
@[gcongr]
theorem iUnion_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iUnion s ⊆ iUnion t :=
iSup_mono h
theorem iUnion₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
⋃ (i) (j), s i j ⊆ ⋃ (i) (j), t i j :=
iSup₂_mono h
#align set.Union₂_mono Set.iUnion₂_mono
theorem iInter_mono {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : ⋂ i, s i ⊆ ⋂ i, t i :=
iInf_mono h
#align set.Inter_mono Set.iInter_mono
@[gcongr]
theorem iInter_mono'' {s t : ι → Set α} (h : ∀ i, s i ⊆ t i) : iInter s ⊆ iInter t :=
iInf_mono h
theorem iInter₂_mono {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j ⊆ t i j) :
⋂ (i) (j), s i j ⊆ ⋂ (i) (j), t i j :=
iInf₂_mono h
#align set.Inter₂_mono Set.iInter₂_mono
theorem iUnion_mono' {s : ι → Set α} {t : ι₂ → Set α} (h : ∀ i, ∃ j, s i ⊆ t j) :
⋃ i, s i ⊆ ⋃ i, t i :=
iSup_mono' h
#align set.Union_mono' Set.iUnion_mono'
theorem iUnion₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α}
(h : ∀ i j, ∃ i' j', s i j ⊆ t i' j') : ⋃ (i) (j), s i j ⊆ ⋃ (i') (j'), t i' j' :=
iSup₂_mono' h
#align set.Union₂_mono' Set.iUnion₂_mono'
theorem iInter_mono' {s : ι → Set α} {t : ι' → Set α} (h : ∀ j, ∃ i, s i ⊆ t j) :
⋂ i, s i ⊆ ⋂ j, t j :=
Set.subset_iInter fun j =>
let ⟨i, hi⟩ := h j
iInter_subset_of_subset i hi
#align set.Inter_mono' Set.iInter_mono'
theorem iInter₂_mono' {s : ∀ i, κ i → Set α} {t : ∀ i', κ' i' → Set α}
(h : ∀ i' j', ∃ i j, s i j ⊆ t i' j') : ⋂ (i) (j), s i j ⊆ ⋂ (i') (j'), t i' j' :=
subset_iInter₂_iff.2 fun i' j' =>
let ⟨_, _, hst⟩ := h i' j'
(iInter₂_subset _ _).trans hst
#align set.Inter₂_mono' Set.iInter₂_mono'
theorem iUnion₂_subset_iUnion (κ : ι → Sort*) (s : ι → Set α) :
⋃ (i) (_ : κ i), s i ⊆ ⋃ i, s i :=
iUnion_mono fun _ => iUnion_subset fun _ => Subset.rfl
#align set.Union₂_subset_Union Set.iUnion₂_subset_iUnion
theorem iInter_subset_iInter₂ (κ : ι → Sort*) (s : ι → Set α) :
⋂ i, s i ⊆ ⋂ (i) (_ : κ i), s i :=
iInter_mono fun _ => subset_iInter fun _ => Subset.rfl
#align set.Inter_subset_Inter₂ Set.iInter_subset_iInter₂
theorem iUnion_setOf (P : ι → α → Prop) : ⋃ i, { x : α | P i x } = { x : α | ∃ i, P i x } := by
ext
exact mem_iUnion
#align set.Union_set_of Set.iUnion_setOf
theorem iInter_setOf (P : ι → α → Prop) : ⋂ i, { x : α | P i x } = { x : α | ∀ i, P i x } := by
ext
exact mem_iInter
#align set.Inter_set_of Set.iInter_setOf
theorem iUnion_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h)
(h2 : ∀ x, g (h x) = f x) : ⋃ x, f x = ⋃ y, g y :=
h1.iSup_congr h h2
#align set.Union_congr_of_surjective Set.iUnion_congr_of_surjective
theorem iInter_congr_of_surjective {f : ι → Set α} {g : ι₂ → Set α} (h : ι → ι₂) (h1 : Surjective h)
(h2 : ∀ x, g (h x) = f x) : ⋂ x, f x = ⋂ y, g y :=
h1.iInf_congr h h2
#align set.Inter_congr_of_surjective Set.iInter_congr_of_surjective
lemma iUnion_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋃ i, s i = ⋃ i, t i := iSup_congr h
#align set.Union_congr Set.iUnion_congr
lemma iInter_congr {s t : ι → Set α} (h : ∀ i, s i = t i) : ⋂ i, s i = ⋂ i, t i := iInf_congr h
#align set.Inter_congr Set.iInter_congr
lemma iUnion₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) :
⋃ (i) (j), s i j = ⋃ (i) (j), t i j :=
iUnion_congr fun i => iUnion_congr <| h i
#align set.Union₂_congr Set.iUnion₂_congr
lemma iInter₂_congr {s t : ∀ i, κ i → Set α} (h : ∀ i j, s i j = t i j) :
⋂ (i) (j), s i j = ⋂ (i) (j), t i j :=
iInter_congr fun i => iInter_congr <| h i
#align set.Inter₂_congr Set.iInter₂_congr
@[simp]
theorem compl_iUnion (s : ι → Set β) : (⋃ i, s i)ᶜ = ⋂ i, (s i)ᶜ :=
compl_iSup
#align set.compl_Union Set.compl_iUnion
theorem compl_iUnion₂ (s : ∀ i, κ i → Set α) : (⋃ (i) (j), s i j)ᶜ = ⋂ (i) (j), (s i j)ᶜ := by
simp_rw [compl_iUnion]
#align set.compl_Union₂ Set.compl_iUnion₂
@[simp]
theorem compl_iInter (s : ι → Set β) : (⋂ i, s i)ᶜ = ⋃ i, (s i)ᶜ :=
compl_iInf
#align set.compl_Inter Set.compl_iInter
theorem compl_iInter₂ (s : ∀ i, κ i → Set α) : (⋂ (i) (j), s i j)ᶜ = ⋃ (i) (j), (s i j)ᶜ := by
simp_rw [compl_iInter]
#align set.compl_Inter₂ Set.compl_iInter₂
-- classical -- complete_boolean_algebra
theorem iUnion_eq_compl_iInter_compl (s : ι → Set β) : ⋃ i, s i = (⋂ i, (s i)ᶜ)ᶜ := by
simp only [compl_iInter, compl_compl]
#align set.Union_eq_compl_Inter_compl Set.iUnion_eq_compl_iInter_compl
-- classical -- complete_boolean_algebra
theorem iInter_eq_compl_iUnion_compl (s : ι → Set β) : ⋂ i, s i = (⋃ i, (s i)ᶜ)ᶜ := by
simp only [compl_iUnion, compl_compl]
#align set.Inter_eq_compl_Union_compl Set.iInter_eq_compl_iUnion_compl
theorem inter_iUnion (s : Set β) (t : ι → Set β) : (s ∩ ⋃ i, t i) = ⋃ i, s ∩ t i :=
inf_iSup_eq _ _
#align set.inter_Union Set.inter_iUnion
theorem iUnion_inter (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∩ s = ⋃ i, t i ∩ s :=
iSup_inf_eq _ _
#align set.Union_inter Set.iUnion_inter
theorem iUnion_union_distrib (s : ι → Set β) (t : ι → Set β) :
⋃ i, s i ∪ t i = (⋃ i, s i) ∪ ⋃ i, t i :=
iSup_sup_eq
#align set.Union_union_distrib Set.iUnion_union_distrib
theorem iInter_inter_distrib (s : ι → Set β) (t : ι → Set β) :
⋂ i, s i ∩ t i = (⋂ i, s i) ∩ ⋂ i, t i :=
iInf_inf_eq
#align set.Inter_inter_distrib Set.iInter_inter_distrib
theorem union_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∪ ⋃ i, t i) = ⋃ i, s ∪ t i :=
sup_iSup
#align set.union_Union Set.union_iUnion
theorem iUnion_union [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋃ i, t i) ∪ s = ⋃ i, t i ∪ s :=
iSup_sup
#align set.Union_union Set.iUnion_union
theorem inter_iInter [Nonempty ι] (s : Set β) (t : ι → Set β) : (s ∩ ⋂ i, t i) = ⋂ i, s ∩ t i :=
inf_iInf
#align set.inter_Inter Set.inter_iInter
theorem iInter_inter [Nonempty ι] (s : Set β) (t : ι → Set β) : (⋂ i, t i) ∩ s = ⋂ i, t i ∩ s :=
iInf_inf
#align set.Inter_inter Set.iInter_inter
-- classical
theorem union_iInter (s : Set β) (t : ι → Set β) : (s ∪ ⋂ i, t i) = ⋂ i, s ∪ t i :=
sup_iInf_eq _ _
#align set.union_Inter Set.union_iInter
theorem iInter_union (s : ι → Set β) (t : Set β) : (⋂ i, s i) ∪ t = ⋂ i, s i ∪ t :=
iInf_sup_eq _ _
#align set.Inter_union Set.iInter_union
theorem iUnion_diff (s : Set β) (t : ι → Set β) : (⋃ i, t i) \ s = ⋃ i, t i \ s :=
iUnion_inter _ _
#align set.Union_diff Set.iUnion_diff
theorem diff_iUnion [Nonempty ι] (s : Set β) (t : ι → Set β) : (s \ ⋃ i, t i) = ⋂ i, s \ t i := by
rw [diff_eq, compl_iUnion, inter_iInter]; rfl
#align set.diff_Union Set.diff_iUnion
theorem diff_iInter (s : Set β) (t : ι → Set β) : (s \ ⋂ i, t i) = ⋃ i, s \ t i := by
rw [diff_eq, compl_iInter, inter_iUnion]; rfl
#align set.diff_Inter Set.diff_iInter
theorem iUnion_inter_subset {ι α} {s t : ι → Set α} : ⋃ i, s i ∩ t i ⊆ (⋃ i, s i) ∩ ⋃ i, t i :=
le_iSup_inf_iSup s t
#align set.Union_inter_subset Set.iUnion_inter_subset
theorem iUnion_inter_of_monotone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α}
(hs : Monotone s) (ht : Monotone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i :=
iSup_inf_of_monotone hs ht
#align set.Union_inter_of_monotone Set.iUnion_inter_of_monotone
theorem iUnion_inter_of_antitone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α}
(hs : Antitone s) (ht : Antitone t) : ⋃ i, s i ∩ t i = (⋃ i, s i) ∩ ⋃ i, t i :=
iSup_inf_of_antitone hs ht
#align set.Union_inter_of_antitone Set.iUnion_inter_of_antitone
theorem iInter_union_of_monotone {ι α} [Preorder ι] [IsDirected ι (swap (· ≤ ·))] {s t : ι → Set α}
(hs : Monotone s) (ht : Monotone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i :=
iInf_sup_of_monotone hs ht
#align set.Inter_union_of_monotone Set.iInter_union_of_monotone
theorem iInter_union_of_antitone {ι α} [Preorder ι] [IsDirected ι (· ≤ ·)] {s t : ι → Set α}
(hs : Antitone s) (ht : Antitone t) : ⋂ i, s i ∪ t i = (⋂ i, s i) ∪ ⋂ i, t i :=
iInf_sup_of_antitone hs ht
#align set.Inter_union_of_antitone Set.iInter_union_of_antitone
theorem iUnion_iInter_subset {s : ι → ι' → Set α} : (⋃ j, ⋂ i, s i j) ⊆ ⋂ i, ⋃ j, s i j :=
iSup_iInf_le_iInf_iSup (flip s)
#align set.Union_Inter_subset Set.iUnion_iInter_subset
theorem iUnion_option {ι} (s : Option ι → Set α) : ⋃ o, s o = s none ∪ ⋃ i, s (some i) :=
iSup_option s
#align set.Union_option Set.iUnion_option
theorem iInter_option {ι} (s : Option ι → Set α) : ⋂ o, s o = s none ∩ ⋂ i, s (some i) :=
iInf_option s
#align set.Inter_option Set.iInter_option
section
variable (p : ι → Prop) [DecidablePred p]
theorem iUnion_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) :
⋃ 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 _ _ _
#align set.Union_dite Set.iUnion_dite
theorem iUnion_ite (f g : ι → Set α) :
⋃ i, (if p i then f i else g i) = (⋃ (i) (_ : p i), f i) ∪ ⋃ (i) (_ : ¬p i), g i :=
iUnion_dite _ _ _
#align set.Union_ite Set.iUnion_ite
theorem iInter_dite (f : ∀ i, p i → Set α) (g : ∀ i, ¬p i → Set α) :
⋂ 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 :=
iInf_dite _ _ _
#align set.Inter_dite Set.iInter_dite
theorem iInter_ite (f g : ι → Set α) :
⋂ i, (if p i then f i else g i) = (⋂ (i) (_ : p i), f i) ∩ ⋂ (i) (_ : ¬p i), g i :=
iInter_dite _ _ _
#align set.Inter_ite Set.iInter_ite
end
theorem image_projection_prod {ι : Type*} {α : ι → Type*} {v : ∀ i : ι, Set (α i)}
(hv : (pi univ v).Nonempty) (i : ι) :
((fun x : ∀ i : ι, α i => x i) '' ⋂ k, (fun x : ∀ j : ι, α j => x k) ⁻¹' v k) = v i := by
classical
apply Subset.antisymm
· simp [iInter_subset]
· intro y y_in
simp only [mem_image, mem_iInter, mem_preimage]
rcases hv with ⟨z, hz⟩
refine ⟨Function.update z i y, ?_, update_same i y z⟩
rw [@forall_update_iff ι α _ z i y fun i t => t ∈ v i]
exact ⟨y_in, fun j _ => by simpa using hz j⟩
#align set.image_projection_prod Set.image_projection_prod
theorem iInter_false {s : False → Set α} : iInter s = univ :=
iInf_false
#align set.Inter_false Set.iInter_false
theorem iUnion_false {s : False → Set α} : iUnion s = ∅ :=
iSup_false
#align set.Union_false Set.iUnion_false
@[simp]
theorem iInter_true {s : True → Set α} : iInter s = s trivial :=
iInf_true
#align set.Inter_true Set.iInter_true
@[simp]
theorem iUnion_true {s : True → Set α} : iUnion s = s trivial :=
iSup_true
#align set.Union_true Set.iUnion_true
@[simp]
theorem iInter_exists {p : ι → Prop} {f : Exists p → Set α} :
⋂ x, f x = ⋂ (i) (h : p i), f ⟨i, h⟩ :=
iInf_exists
#align set.Inter_exists Set.iInter_exists
@[simp]
theorem iUnion_exists {p : ι → Prop} {f : Exists p → Set α} :
⋃ x, f x = ⋃ (i) (h : p i), f ⟨i, h⟩ :=
iSup_exists
#align set.Union_exists Set.iUnion_exists
@[simp]
theorem iUnion_empty : (⋃ _ : ι, ∅ : Set α) = ∅ :=
iSup_bot
#align set.Union_empty Set.iUnion_empty
@[simp]
theorem iInter_univ : (⋂ _ : ι, univ : Set α) = univ :=
iInf_top
#align set.Inter_univ Set.iInter_univ
section
variable {s : ι → Set α}
@[simp]
theorem iUnion_eq_empty : ⋃ i, s i = ∅ ↔ ∀ i, s i = ∅ :=
iSup_eq_bot
#align set.Union_eq_empty Set.iUnion_eq_empty
@[simp]
theorem iInter_eq_univ : ⋂ i, s i = univ ↔ ∀ i, s i = univ :=
iInf_eq_top
#align set.Inter_eq_univ Set.iInter_eq_univ
@[simp]
theorem nonempty_iUnion : (⋃ i, s i).Nonempty ↔ ∃ i, (s i).Nonempty := by
simp [nonempty_iff_ne_empty]
#align set.nonempty_Union Set.nonempty_iUnion
-- Porting note (#10618): removing `simp`. `simp` can prove it
theorem nonempty_biUnion {t : Set α} {s : α → Set β} :
(⋃ i ∈ t, s i).Nonempty ↔ ∃ i ∈ t, (s i).Nonempty := by simp
#align set.nonempty_bUnion Set.nonempty_biUnion
theorem iUnion_nonempty_index (s : Set α) (t : s.Nonempty → Set β) :
⋃ h, t h = ⋃ x ∈ s, t ⟨x, ‹_›⟩ :=
iSup_exists
#align set.Union_nonempty_index Set.iUnion_nonempty_index
end
@[simp]
theorem iInter_iInter_eq_left {b : β} {s : ∀ x : β, x = b → Set α} :
⋂ (x) (h : x = b), s x h = s b rfl :=
iInf_iInf_eq_left
#align set.Inter_Inter_eq_left Set.iInter_iInter_eq_left
@[simp]
theorem iInter_iInter_eq_right {b : β} {s : ∀ x : β, b = x → Set α} :
⋂ (x) (h : b = x), s x h = s b rfl :=
iInf_iInf_eq_right
#align set.Inter_Inter_eq_right Set.iInter_iInter_eq_right
@[simp]
theorem iUnion_iUnion_eq_left {b : β} {s : ∀ x : β, x = b → Set α} :
⋃ (x) (h : x = b), s x h = s b rfl :=
iSup_iSup_eq_left
#align set.Union_Union_eq_left Set.iUnion_iUnion_eq_left
@[simp]
theorem iUnion_iUnion_eq_right {b : β} {s : ∀ x : β, b = x → Set α} :
⋃ (x) (h : b = x), s x h = s b rfl :=
iSup_iSup_eq_right
#align set.Union_Union_eq_right Set.iUnion_iUnion_eq_right
theorem iInter_or {p q : Prop} (s : p ∨ q → Set α) :
⋂ h, s h = (⋂ h : p, s (Or.inl h)) ∩ ⋂ h : q, s (Or.inr h) :=
iInf_or
#align set.Inter_or Set.iInter_or
theorem iUnion_or {p q : Prop} (s : p ∨ q → Set α) :
⋃ h, s h = (⋃ i, s (Or.inl i)) ∪ ⋃ j, s (Or.inr j) :=
iSup_or
#align set.Union_or Set.iUnion_or
theorem iUnion_and {p q : Prop} (s : p ∧ q → Set α) : ⋃ h, s h = ⋃ (hp) (hq), s ⟨hp, hq⟩ :=
iSup_and
#align set.Union_and Set.iUnion_and
theorem iInter_and {p q : Prop} (s : p ∧ q → Set α) : ⋂ h, s h = ⋂ (hp) (hq), s ⟨hp, hq⟩ :=
iInf_and
#align set.Inter_and Set.iInter_and
theorem iUnion_comm (s : ι → ι' → Set α) : ⋃ (i) (i'), s i i' = ⋃ (i') (i), s i i' :=
iSup_comm
#align set.Union_comm Set.iUnion_comm
theorem iInter_comm (s : ι → ι' → Set α) : ⋂ (i) (i'), s i i' = ⋂ (i') (i), s i i' :=
iInf_comm
#align set.Inter_comm Set.iInter_comm
theorem iUnion_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋃ ia, s ia = ⋃ i, ⋃ a, s ⟨i, a⟩ :=
iSup_sigma
theorem iUnion_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) :
⋃ i, ⋃ a, s i a = ⋃ ia : Sigma γ, s ia.1 ia.2 :=
iSup_sigma' _
theorem iInter_sigma {γ : α → Type*} (s : Sigma γ → Set β) : ⋂ ia, s ia = ⋂ i, ⋂ a, s ⟨i, a⟩ :=
iInf_sigma
theorem iInter_sigma' {γ : α → Type*} (s : ∀ i, γ i → Set β) :
⋂ i, ⋂ a, s i a = ⋂ ia : Sigma γ, s ia.1 ia.2 :=
iInf_sigma' _
theorem iUnion₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) :
⋃ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋃ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ :=
iSup₂_comm _
#align set.Union₂_comm Set.iUnion₂_comm
theorem iInter₂_comm (s : ∀ i₁, κ₁ i₁ → ∀ i₂, κ₂ i₂ → Set α) :
⋂ (i₁) (j₁) (i₂) (j₂), s i₁ j₁ i₂ j₂ = ⋂ (i₂) (j₂) (i₁) (j₁), s i₁ j₁ i₂ j₂ :=
iInf₂_comm _
#align set.Inter₂_comm Set.iInter₂_comm
@[simp]
theorem biUnion_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) :
⋃ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h =
⋃ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by
simp only [iUnion_and, @iUnion_comm _ ι']
#align set.bUnion_and Set.biUnion_and
@[simp]
theorem biUnion_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) :
⋃ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h =
⋃ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by
simp only [iUnion_and, @iUnion_comm _ ι]
#align set.bUnion_and' Set.biUnion_and'
@[simp]
theorem biInter_and (p : ι → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p x ∧ q x y → Set α) :
⋂ (x : ι) (y : ι') (h : p x ∧ q x y), s x y h =
⋂ (x : ι) (hx : p x) (y : ι') (hy : q x y), s x y ⟨hx, hy⟩ := by
simp only [iInter_and, @iInter_comm _ ι']
#align set.bInter_and Set.biInter_and
@[simp]
theorem biInter_and' (p : ι' → Prop) (q : ι → ι' → Prop) (s : ∀ x y, p y ∧ q x y → Set α) :
⋂ (x : ι) (y : ι') (h : p y ∧ q x y), s x y h =
⋂ (y : ι') (hy : p y) (x : ι) (hx : q x y), s x y ⟨hy, hx⟩ := by
simp only [iInter_and, @iInter_comm _ ι]
#align set.bInter_and' Set.biInter_and'
@[simp]
| Mathlib/Data/Set/Lattice.lean | 802 | 804 | theorem iUnion_iUnion_eq_or_left {b : β} {p : β → Prop} {s : ∀ x : β, x = b ∨ p x → Set α} :
⋃ (x) (h), s x h = s b (Or.inl rfl) ∪ ⋃ (x) (h : p x), s x (Or.inr h) := by |
simp only [iUnion_or, iUnion_union_distrib, iUnion_iUnion_eq_left]
|
import Mathlib.MeasureTheory.Integral.SetToL1
#align_import measure_theory.integral.bochner from "leanprover-community/mathlib"@"48fb5b5280e7c81672afc9524185ae994553ebf4"
assert_not_exists Differentiable
noncomputable section
open scoped Topology NNReal ENNReal MeasureTheory
open Set Filter TopologicalSpace ENNReal EMetric
namespace MeasureTheory
variable {α E F 𝕜 : Type*}
local infixr:25 " →ₛ " => SimpleFunc
namespace SimpleFunc
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
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
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
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
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
@[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
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
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
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
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
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
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
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]
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
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
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
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 IntegralTrim
variable {H β γ : Type*} [NormedAddCommGroup H] {m m0 : MeasurableSpace β} {μ : Measure β}
def SimpleFunc.toLargerSpace (hm : m ≤ m0) (f : @SimpleFunc β m γ) : SimpleFunc β γ :=
⟨@SimpleFunc.toFun β m γ f, fun x => hm _ (@SimpleFunc.measurableSet_fiber β γ m f x),
@SimpleFunc.finite_range β γ m f⟩
#align measure_theory.simple_func.to_larger_space MeasureTheory.SimpleFunc.toLargerSpace
theorem SimpleFunc.coe_toLargerSpace_eq (hm : m ≤ m0) (f : @SimpleFunc β m γ) :
⇑(f.toLargerSpace hm) = f := rfl
#align measure_theory.simple_func.coe_to_larger_space_eq MeasureTheory.SimpleFunc.coe_toLargerSpace_eq
theorem integral_simpleFunc_larger_space (hm : m ≤ m0) (f : @SimpleFunc β m F)
(hf_int : Integrable f μ) :
∫ x, f x ∂μ = ∑ x ∈ @SimpleFunc.range β F m f, ENNReal.toReal (μ (f ⁻¹' {x})) • x := by
simp_rw [← f.coe_toLargerSpace_eq hm]
have hf_int : Integrable (f.toLargerSpace hm) μ := by rwa [SimpleFunc.coe_toLargerSpace_eq]
rw [SimpleFunc.integral_eq_sum _ hf_int]
congr 1
#align measure_theory.integral_simple_func_larger_space MeasureTheory.integral_simpleFunc_larger_space
theorem integral_trim_simpleFunc (hm : m ≤ m0) (f : @SimpleFunc β m F) (hf_int : Integrable f μ) :
∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by
have hf : StronglyMeasurable[m] f := @SimpleFunc.stronglyMeasurable β F m _ f
have hf_int_m := hf_int.trim hm hf
rw [integral_simpleFunc_larger_space (le_refl m) f hf_int_m,
integral_simpleFunc_larger_space hm f hf_int]
congr with x
congr 2
exact (trim_measurableSet_eq hm (@SimpleFunc.measurableSet_fiber β F m f x)).symm
#align measure_theory.integral_trim_simple_func MeasureTheory.integral_trim_simpleFunc
theorem integral_trim (hm : m ≤ m0) {f : β → G} (hf : StronglyMeasurable[m] f) :
∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by
by_cases hG : CompleteSpace G; swap
· simp [integral, hG]
borelize G
by_cases hf_int : Integrable f μ
swap
· have hf_int_m : ¬Integrable f (μ.trim hm) := fun hf_int_m =>
hf_int (integrable_of_integrable_trim hm hf_int_m)
rw [integral_undef hf_int, integral_undef hf_int_m]
haveI : SeparableSpace (range f ∪ {0} : Set G) := hf.separableSpace_range_union_singleton
let f_seq := @SimpleFunc.approxOn G β _ _ _ m _ hf.measurable (range f ∪ {0}) 0 (by simp) _
have hf_seq_meas : ∀ n, StronglyMeasurable[m] (f_seq n) := fun n =>
@SimpleFunc.stronglyMeasurable β G m _ (f_seq n)
have hf_seq_int : ∀ n, Integrable (f_seq n) μ :=
SimpleFunc.integrable_approxOn_range (hf.mono hm).measurable hf_int
have hf_seq_int_m : ∀ n, Integrable (f_seq n) (μ.trim hm) := fun n =>
(hf_seq_int n).trim hm (hf_seq_meas n)
have hf_seq_eq : ∀ n, ∫ x, f_seq n x ∂μ = ∫ x, f_seq n x ∂μ.trim hm := fun n =>
integral_trim_simpleFunc hm (f_seq n) (hf_seq_int n)
have h_lim_1 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ)) := by
refine tendsto_integral_of_L1 f hf_int (eventually_of_forall hf_seq_int) ?_
exact SimpleFunc.tendsto_approxOn_range_L1_nnnorm (hf.mono hm).measurable hf_int
have h_lim_2 : atTop.Tendsto (fun n => ∫ x, f_seq n x ∂μ) (𝓝 (∫ x, f x ∂μ.trim hm)) := by
simp_rw [hf_seq_eq]
refine @tendsto_integral_of_L1 β G _ _ m (μ.trim hm) _ f (hf_int.trim hm hf) _ _
(eventually_of_forall hf_seq_int_m) ?_
exact @SimpleFunc.tendsto_approxOn_range_L1_nnnorm β G m _ _ _ f _ _ hf.measurable
(hf_int.trim hm hf)
exact tendsto_nhds_unique h_lim_1 h_lim_2
#align measure_theory.integral_trim MeasureTheory.integral_trim
theorem integral_trim_ae (hm : m ≤ m0) {f : β → G} (hf : AEStronglyMeasurable f (μ.trim hm)) :
∫ x, f x ∂μ = ∫ x, f x ∂μ.trim hm := by
rw [integral_congr_ae (ae_eq_of_ae_eq_trim hf.ae_eq_mk), integral_congr_ae hf.ae_eq_mk]
exact integral_trim hm hf.stronglyMeasurable_mk
#align measure_theory.integral_trim_ae MeasureTheory.integral_trim_ae
theorem ae_eq_trim_of_stronglyMeasurable [TopologicalSpace γ] [MetrizableSpace γ] (hm : m ≤ m0)
{f g : β → γ} (hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g)
(hfg : f =ᵐ[μ] g) : f =ᵐ[μ.trim hm] g := by
rwa [EventuallyEq, ae_iff, trim_measurableSet_eq hm]
exact (hf.measurableSet_eq_fun hg).compl
#align measure_theory.ae_eq_trim_of_strongly_measurable MeasureTheory.ae_eq_trim_of_stronglyMeasurable
theorem ae_eq_trim_iff [TopologicalSpace γ] [MetrizableSpace γ] (hm : m ≤ m0) {f g : β → γ}
(hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) :
f =ᵐ[μ.trim hm] g ↔ f =ᵐ[μ] g :=
⟨ae_eq_of_ae_eq_trim, ae_eq_trim_of_stronglyMeasurable hm hf hg⟩
#align measure_theory.ae_eq_trim_iff MeasureTheory.ae_eq_trim_iff
| Mathlib/MeasureTheory/Integral/Bochner.lean | 2,028 | 2,033 | theorem ae_le_trim_of_stronglyMeasurable [LinearOrder γ] [TopologicalSpace γ]
[OrderClosedTopology γ] [PseudoMetrizableSpace γ] (hm : m ≤ m0) {f g : β → γ}
(hf : StronglyMeasurable[m] f) (hg : StronglyMeasurable[m] g) (hfg : f ≤ᵐ[μ] g) :
f ≤ᵐ[μ.trim hm] g := by |
rwa [EventuallyLE, ae_iff, trim_measurableSet_eq hm]
exact (hf.measurableSet_le hg).compl
|
import Mathlib.Computability.Halting
import Mathlib.Computability.TuringMachine
import Mathlib.Data.Num.Lemmas
import Mathlib.Tactic.DeriveFintype
#align_import computability.tm_to_partrec from "leanprover-community/mathlib"@"6155d4351090a6fad236e3d2e4e0e4e7342668e8"
open Function (update)
open Relation
namespace Turing
namespace ToPartrec
inductive Code
| zero'
| succ
| tail
| cons : Code → Code → Code
| comp : Code → Code → Code
| case : Code → Code → Code
| fix : Code → Code
deriving DecidableEq, Inhabited
#align turing.to_partrec.code Turing.ToPartrec.Code
#align turing.to_partrec.code.zero' Turing.ToPartrec.Code.zero'
#align turing.to_partrec.code.succ Turing.ToPartrec.Code.succ
#align turing.to_partrec.code.tail Turing.ToPartrec.Code.tail
#align turing.to_partrec.code.cons Turing.ToPartrec.Code.cons
#align turing.to_partrec.code.comp Turing.ToPartrec.Code.comp
#align turing.to_partrec.code.case Turing.ToPartrec.Code.case
#align turing.to_partrec.code.fix Turing.ToPartrec.Code.fix
def Code.eval : Code → List ℕ →. List ℕ
| Code.zero' => fun v => pure (0 :: v)
| Code.succ => fun v => pure [v.headI.succ]
| Code.tail => fun v => pure v.tail
| Code.cons f fs => fun v => do
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns)
| Code.comp f g => fun v => g.eval v >>= f.eval
| Code.case f g => fun v => v.headI.rec (f.eval v.tail) fun y _ => g.eval (y::v.tail)
| Code.fix f =>
PFun.fix fun v => (f.eval v).map fun v => if v.headI = 0 then Sum.inl v.tail else Sum.inr v.tail
#align turing.to_partrec.code.eval Turing.ToPartrec.Code.eval
namespace Code
@[simp]
theorem zero'_eval : zero'.eval = fun v => pure (0 :: v) := by simp [eval]
@[simp]
theorem succ_eval : succ.eval = fun v => pure [v.headI.succ] := by simp [eval]
@[simp]
theorem tail_eval : tail.eval = fun v => pure v.tail := by simp [eval]
@[simp]
theorem cons_eval (f fs) : (cons f fs).eval = fun v => do {
let n ← Code.eval f v
let ns ← Code.eval fs v
pure (n.headI :: ns) } := by simp [eval]
@[simp]
| Mathlib/Computability/TMToPartrec.lean | 155 | 155 | theorem comp_eval (f g) : (comp f g).eval = fun v => g.eval v >>= f.eval := by | simp [eval]
|
import Mathlib.CategoryTheory.Balanced
import Mathlib.CategoryTheory.Limits.EssentiallySmall
import Mathlib.CategoryTheory.Limits.Opposites
import Mathlib.CategoryTheory.Limits.Shapes.ZeroMorphisms
import Mathlib.CategoryTheory.Subobject.Lattice
import Mathlib.CategoryTheory.Subobject.WellPowered
import Mathlib.Data.Set.Opposite
import Mathlib.Data.Set.Subsingleton
#align_import category_theory.generator from "leanprover-community/mathlib"@"f187f1074fa1857c94589cc653c786cadc4c35ff"
universe w v₁ v₂ u₁ u₂
open CategoryTheory.Limits Opposite
namespace CategoryTheory
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
def IsSeparating (𝒢 : Set C) : Prop :=
∀ ⦃X Y : C⦄ (f g : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ X), h ≫ f = h ≫ g) → f = g
#align category_theory.is_separating CategoryTheory.IsSeparating
def IsCoseparating (𝒢 : Set C) : Prop :=
∀ ⦃X Y : C⦄ (f g : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : Y ⟶ G), f ≫ h = g ≫ h) → f = g
#align category_theory.is_coseparating CategoryTheory.IsCoseparating
def IsDetecting (𝒢 : Set C) : Prop :=
∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : G ⟶ Y), ∃! h' : G ⟶ X, h' ≫ f = h) → IsIso f
#align category_theory.is_detecting CategoryTheory.IsDetecting
def IsCodetecting (𝒢 : Set C) : Prop :=
∀ ⦃X Y : C⦄ (f : X ⟶ Y), (∀ G ∈ 𝒢, ∀ (h : X ⟶ G), ∃! h' : Y ⟶ G, f ≫ h' = h) → IsIso f
#align category_theory.is_codetecting CategoryTheory.IsCodetecting
theorem IsDetecting.isSeparating [HasEqualizers C] {𝒢 : Set C} (h𝒢 : IsDetecting 𝒢) :
IsSeparating 𝒢 := fun _ _ f g hfg =>
have : IsIso (equalizer.ι f g) := h𝒢 _ fun _ hG _ => equalizer.existsUnique _ (hfg _ hG _)
eq_of_epi_equalizer
#align category_theory.is_detecting.is_separating CategoryTheory.IsDetecting.isSeparating
section
theorem IsCodetecting.isCoseparating [HasCoequalizers C] {𝒢 : Set C} :
IsCodetecting 𝒢 → IsCoseparating 𝒢 := by
simpa only [← isSeparating_op_iff, ← isDetecting_op_iff] using IsDetecting.isSeparating
#align category_theory.is_codetecting.is_coseparating CategoryTheory.IsCodetecting.isCoseparating
end
theorem IsSeparating.isDetecting [Balanced C] {𝒢 : Set C} (h𝒢 : IsSeparating 𝒢) :
IsDetecting 𝒢 := by
intro X Y f hf
refine
(isIso_iff_mono_and_epi _).2 ⟨⟨fun g h hgh => h𝒢 _ _ fun G hG i => ?_⟩, ⟨fun g h hgh => ?_⟩⟩
· obtain ⟨t, -, ht⟩ := hf G hG (i ≫ g ≫ f)
rw [ht (i ≫ g) (Category.assoc _ _ _), ht (i ≫ h) (hgh.symm ▸ Category.assoc _ _ _)]
· refine h𝒢 _ _ fun G hG i => ?_
obtain ⟨t, rfl, -⟩ := hf G hG i
rw [Category.assoc, hgh, Category.assoc]
#align category_theory.is_separating.is_detecting CategoryTheory.IsSeparating.isDetecting
section
attribute [local instance] balanced_opposite
theorem IsCoseparating.isCodetecting [Balanced C] {𝒢 : Set C} :
IsCoseparating 𝒢 → IsCodetecting 𝒢 := by
simpa only [← isDetecting_op_iff, ← isSeparating_op_iff] using IsSeparating.isDetecting
#align category_theory.is_coseparating.is_codetecting CategoryTheory.IsCoseparating.isCodetecting
end
theorem isDetecting_iff_isSeparating [HasEqualizers C] [Balanced C] (𝒢 : Set C) :
IsDetecting 𝒢 ↔ IsSeparating 𝒢 :=
⟨IsDetecting.isSeparating, IsSeparating.isDetecting⟩
#align category_theory.is_detecting_iff_is_separating CategoryTheory.isDetecting_iff_isSeparating
theorem isCodetecting_iff_isCoseparating [HasCoequalizers C] [Balanced C] {𝒢 : Set C} :
IsCodetecting 𝒢 ↔ IsCoseparating 𝒢 :=
⟨IsCodetecting.isCoseparating, IsCoseparating.isCodetecting⟩
#align category_theory.is_codetecting_iff_is_coseparating CategoryTheory.isCodetecting_iff_isCoseparating
theorem isSeparating_iff_epi (𝒢 : Set C)
[∀ A : C, HasCoproduct fun f : ΣG : 𝒢, (G : C) ⟶ A => (f.1 : C)] :
IsSeparating 𝒢 ↔ ∀ A : C, Epi (Sigma.desc (@Sigma.snd 𝒢 fun G => (G : C) ⟶ A)) := by
refine ⟨fun h A => ⟨fun u v huv => h _ _ fun G hG f => ?_⟩, fun h X Y f g hh => ?_⟩
· simpa using Sigma.ι (fun f : ΣG : 𝒢, (G : C) ⟶ A => (f.1 : C)) ⟨⟨G, hG⟩, f⟩ ≫= huv
· haveI := h X
refine
(cancel_epi (Sigma.desc (@Sigma.snd 𝒢 fun G => (G : C) ⟶ X))).1 (colimit.hom_ext fun j => ?_)
simpa using hh j.as.1.1 j.as.1.2 j.as.2
#align category_theory.is_separating_iff_epi CategoryTheory.isSeparating_iff_epi
theorem isCoseparating_iff_mono (𝒢 : Set C)
[∀ A : C, HasProduct fun f : ΣG : 𝒢, A ⟶ (G : C) => (f.1 : C)] :
IsCoseparating 𝒢 ↔ ∀ A : C, Mono (Pi.lift (@Sigma.snd 𝒢 fun G => A ⟶ (G : C))) := by
refine ⟨fun h A => ⟨fun u v huv => h _ _ fun G hG f => ?_⟩, fun h X Y f g hh => ?_⟩
· simpa using huv =≫ Pi.π (fun f : ΣG : 𝒢, A ⟶ (G : C) => (f.1 : C)) ⟨⟨G, hG⟩, f⟩
· haveI := h Y
refine (cancel_mono (Pi.lift (@Sigma.snd 𝒢 fun G => Y ⟶ (G : C)))).1 (limit.hom_ext fun j => ?_)
simpa using hh j.as.1.1 j.as.1.2 j.as.2
#align category_theory.is_coseparating_iff_mono CategoryTheory.isCoseparating_iff_mono
theorem hasInitial_of_isCoseparating [WellPowered C] [HasLimits C] {𝒢 : Set C} [Small.{v₁} 𝒢]
(h𝒢 : IsCoseparating 𝒢) : HasInitial C := by
haveI : HasProductsOfShape 𝒢 C := hasProductsOfShape_of_small C 𝒢
haveI := fun A => hasProductsOfShape_of_small.{v₁} C (ΣG : 𝒢, A ⟶ (G : C))
letI := completeLatticeOfCompleteSemilatticeInf (Subobject (piObj (Subtype.val : 𝒢 → C)))
suffices ∀ A : C, Unique (((⊥ : Subobject (piObj (Subtype.val : 𝒢 → C))) : C) ⟶ A) by
exact hasInitial_of_unique ((⊥ : Subobject (piObj (Subtype.val : 𝒢 → C))) : C)
refine fun A => ⟨⟨?_⟩, fun f => ?_⟩
· let s := Pi.lift fun f : ΣG : 𝒢, A ⟶ (G : C) => id (Pi.π (Subtype.val : 𝒢 → C)) f.1
let t := Pi.lift (@Sigma.snd 𝒢 fun G => A ⟶ (G : C))
haveI : Mono t := (isCoseparating_iff_mono 𝒢).1 h𝒢 A
exact Subobject.ofLEMk _ (pullback.fst : pullback s t ⟶ _) bot_le ≫ pullback.snd
· suffices ∀ (g : Subobject.underlying.obj ⊥ ⟶ A), f = g by
apply this
intro g
suffices IsSplitEpi (equalizer.ι f g) by exact eq_of_epi_equalizer
exact IsSplitEpi.mk' ⟨Subobject.ofLEMk _ (equalizer.ι f g ≫ Subobject.arrow _) bot_le, by
ext
simp⟩
#align category_theory.has_initial_of_is_coseparating CategoryTheory.hasInitial_of_isCoseparating
theorem hasTerminal_of_isSeparating [WellPowered Cᵒᵖ] [HasColimits C] {𝒢 : Set C} [Small.{v₁} 𝒢]
(h𝒢 : IsSeparating 𝒢) : HasTerminal C := by
haveI : Small.{v₁} 𝒢.op := small_of_injective (Set.opEquiv_self 𝒢).injective
haveI : HasInitial Cᵒᵖ := hasInitial_of_isCoseparating ((isCoseparating_op_iff _).2 h𝒢)
exact hasTerminal_of_hasInitial_op
#align category_theory.has_terminal_of_is_separating CategoryTheory.hasTerminal_of_isSeparating
section WellPowered
def IsSeparator (G : C) : Prop :=
IsSeparating ({G} : Set C)
#align category_theory.is_separator CategoryTheory.IsSeparator
def IsCoseparator (G : C) : Prop :=
IsCoseparating ({G} : Set C)
#align category_theory.is_coseparator CategoryTheory.IsCoseparator
def IsDetector (G : C) : Prop :=
IsDetecting ({G} : Set C)
#align category_theory.is_detector CategoryTheory.IsDetector
def IsCodetector (G : C) : Prop :=
IsCodetecting ({G} : Set C)
#align category_theory.is_codetector CategoryTheory.IsCodetector
section Dual
| Mathlib/CategoryTheory/Generator.lean | 404 | 405 | theorem isSeparator_op_iff (G : C) : IsSeparator (op G) ↔ IsCoseparator G := by |
rw [IsSeparator, IsCoseparator, ← isSeparating_op_iff, Set.singleton_op]
|
import Mathlib.Analysis.LocallyConvex.Bounded
import Mathlib.Topology.Algebra.Module.StrongTopology
#align_import analysis.normed_space.compact_operator from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
open Function Set Filter Bornology Metric Pointwise Topology
def IsCompactOperator {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁] [TopologicalSpace M₂]
(f : M₁ → M₂) : Prop :=
∃ K, IsCompact K ∧ f ⁻¹' K ∈ (𝓝 0 : Filter M₁)
#align is_compact_operator IsCompactOperator
theorem isCompactOperator_zero {M₁ M₂ : Type*} [Zero M₁] [TopologicalSpace M₁]
[TopologicalSpace M₂] [Zero M₂] : IsCompactOperator (0 : M₁ → M₂) :=
⟨{0}, isCompact_singleton, mem_of_superset univ_mem fun _ _ => rfl⟩
#align is_compact_operator_zero isCompactOperator_zero
section Characterizations
section
variable {R₁ R₂ : Type*} [Semiring R₁] [Semiring R₂] {σ₁₂ : R₁ →+* R₂} {M₁ M₂ : Type*}
[TopologicalSpace M₁] [AddCommMonoid M₁] [TopologicalSpace M₂]
theorem isCompactOperator_iff_exists_mem_nhds_image_subset_compact (f : M₁ → M₂) :
IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), ∃ K : Set M₂, IsCompact K ∧ f '' V ⊆ K :=
⟨fun ⟨K, hK, hKf⟩ => ⟨f ⁻¹' K, hKf, K, hK, image_preimage_subset _ _⟩, fun ⟨_, hV, K, hK, hVK⟩ =>
⟨K, hK, mem_of_superset hV (image_subset_iff.mp hVK)⟩⟩
#align is_compact_operator_iff_exists_mem_nhds_image_subset_compact isCompactOperator_iff_exists_mem_nhds_image_subset_compact
theorem isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image [T2Space M₂] (f : M₁ → M₂) :
IsCompactOperator f ↔ ∃ V ∈ (𝓝 0 : Filter M₁), IsCompact (closure <| f '' V) := by
rw [isCompactOperator_iff_exists_mem_nhds_image_subset_compact]
exact
⟨fun ⟨V, hV, K, hK, hKV⟩ => ⟨V, hV, hK.closure_of_subset hKV⟩,
fun ⟨V, hV, hVc⟩ => ⟨V, hV, closure (f '' V), hVc, subset_closure⟩⟩
#align is_compact_operator_iff_exists_mem_nhds_is_compact_closure_image isCompactOperator_iff_exists_mem_nhds_isCompact_closure_image
end
section Comp
variable {R₁ R₂ R₃ : Type*} [Semiring R₁] [Semiring R₂] [Semiring R₃] {σ₁₂ : R₁ →+* R₂}
{σ₂₃ : R₂ →+* R₃} {M₁ M₂ M₃ : Type*} [TopologicalSpace M₁] [TopologicalSpace M₂]
[TopologicalSpace M₃] [AddCommMonoid M₁] [Module R₁ M₁]
theorem IsCompactOperator.comp_clm [AddCommMonoid M₂] [Module R₂ M₂] {f : M₂ → M₃}
(hf : IsCompactOperator f) (g : M₁ →SL[σ₁₂] M₂) : IsCompactOperator (f ∘ g) := by
have := g.continuous.tendsto 0
rw [map_zero] at this
rcases hf with ⟨K, hK, hKf⟩
exact ⟨K, hK, this hKf⟩
#align is_compact_operator.comp_clm IsCompactOperator.comp_clm
| Mathlib/Analysis/NormedSpace/CompactOperator.lean | 260 | 265 | theorem IsCompactOperator.continuous_comp {f : M₁ → M₂} (hf : IsCompactOperator f) {g : M₂ → M₃}
(hg : Continuous g) : IsCompactOperator (g ∘ f) := by |
rcases hf with ⟨K, hK, hKf⟩
refine ⟨g '' K, hK.image hg, mem_of_superset hKf ?_⟩
rw [preimage_comp]
exact preimage_mono (subset_preimage_image _ _)
|
import Mathlib.Geometry.Euclidean.Sphere.Basic
#align_import geometry.euclidean.sphere.second_inter from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
noncomputable section
open RealInnerProductSpace
namespace EuclideanGeometry
variable {V : Type*} {P : Type*} [NormedAddCommGroup V] [InnerProductSpace ℝ V] [MetricSpace P]
[NormedAddTorsor V P]
def Sphere.secondInter (s : Sphere P) (p : P) (v : V) : P :=
(-2 * ⟪v, p -ᵥ s.center⟫ / ⟪v, v⟫) • v +ᵥ p
#align euclidean_geometry.sphere.second_inter EuclideanGeometry.Sphere.secondInter
@[simp]
theorem Sphere.secondInter_dist (s : Sphere P) (p : P) (v : V) :
dist (s.secondInter p v) s.center = dist p s.center := by
rw [Sphere.secondInter]
by_cases hv : v = 0; · simp [hv]
rw [dist_smul_vadd_eq_dist _ _ hv]
exact Or.inr rfl
#align euclidean_geometry.sphere.second_inter_dist EuclideanGeometry.Sphere.secondInter_dist
@[simp]
theorem Sphere.secondInter_mem {s : Sphere P} {p : P} (v : V) : s.secondInter p v ∈ s ↔ p ∈ s := by
simp_rw [mem_sphere, Sphere.secondInter_dist]
#align euclidean_geometry.sphere.second_inter_mem EuclideanGeometry.Sphere.secondInter_mem
variable (V)
@[simp]
theorem Sphere.secondInter_zero (s : Sphere P) (p : P) : s.secondInter p (0 : V) = p := by
simp [Sphere.secondInter]
#align euclidean_geometry.sphere.second_inter_zero EuclideanGeometry.Sphere.secondInter_zero
variable {V}
theorem Sphere.secondInter_eq_self_iff {s : Sphere P} {p : P} {v : V} :
s.secondInter p v = p ↔ ⟪v, p -ᵥ s.center⟫ = 0 := by
refine ⟨fun hp => ?_, fun hp => ?_⟩
· by_cases hv : v = 0
· simp [hv]
rwa [Sphere.secondInter, eq_comm, eq_vadd_iff_vsub_eq, vsub_self, eq_comm, smul_eq_zero,
or_iff_left hv, div_eq_zero_iff, inner_self_eq_zero, or_iff_left hv, mul_eq_zero,
or_iff_right (by norm_num : (-2 : ℝ) ≠ 0)] at hp
· rw [Sphere.secondInter, hp, mul_zero, zero_div, zero_smul, zero_vadd]
#align euclidean_geometry.sphere.second_inter_eq_self_iff EuclideanGeometry.Sphere.secondInter_eq_self_iff
theorem Sphere.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem {s : Sphere P} {p : P}
(hp : p ∈ s) {v : V} {p' : P} (hp' : p' ∈ AffineSubspace.mk' p (ℝ ∙ v)) :
p' = p ∨ p' = s.secondInter p v ↔ p' ∈ s := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rcases h with (h | h)
· rwa [h]
· rwa [h, Sphere.secondInter_mem]
· rw [AffineSubspace.mem_mk'_iff_vsub_mem, Submodule.mem_span_singleton] at hp'
rcases hp' with ⟨r, hr⟩
rw [eq_comm, ← eq_vadd_iff_vsub_eq] at hr
subst hr
by_cases hv : v = 0
· simp [hv]
rw [Sphere.secondInter]
rw [mem_sphere] at h hp
rw [← hp, dist_smul_vadd_eq_dist _ _ hv] at h
rcases h with (h | h) <;> simp [h]
#align euclidean_geometry.sphere.eq_or_eq_second_inter_of_mem_mk'_span_singleton_iff_mem EuclideanGeometry.Sphere.eq_or_eq_secondInter_of_mem_mk'_span_singleton_iff_mem
@[simp]
| Mathlib/Geometry/Euclidean/Sphere/SecondInter.lean | 103 | 108 | theorem Sphere.secondInter_smul (s : Sphere P) (p : P) (v : V) {r : ℝ} (hr : r ≠ 0) :
s.secondInter p (r • v) = s.secondInter p v := by |
simp_rw [Sphere.secondInter, real_inner_smul_left, inner_smul_right, smul_smul,
div_mul_eq_div_div]
rw [mul_comm, ← mul_div_assoc, ← mul_div_assoc, mul_div_cancel_left₀ _ hr, mul_comm, mul_assoc,
mul_div_cancel_left₀ _ hr, mul_comm]
|
import Mathlib.Algebra.Module.DedekindDomain
import Mathlib.LinearAlgebra.FreeModule.PID
import Mathlib.Algebra.Module.Projective
import Mathlib.Algebra.Category.ModuleCat.Biproducts
import Mathlib.RingTheory.SimpleModule
#align_import algebra.module.pid from "leanprover-community/mathlib"@"cdc34484a07418af43daf8198beaf5c00324bca8"
universe u v
open scoped Classical
variable {R : Type u} [CommRing R] [IsDomain R] [IsPrincipalIdealRing R]
variable {M : Type v} [AddCommGroup M] [Module R M]
variable {N : Type max u v} [AddCommGroup N] [Module R N]
open scoped DirectSum
open Submodule
open UniqueFactorizationMonoid
theorem Submodule.isSemisimple_torsionBy_of_irreducible {a : R} (h : Irreducible a) :
IsSemisimpleModule R (torsionBy R M a) :=
haveI := PrincipalIdealRing.isMaximal_of_irreducible h
letI := Ideal.Quotient.field (R ∙ a)
(submodule_torsionBy_orderIso a).complementedLattice
theorem Submodule.isInternal_prime_power_torsion_of_pid [Module.Finite R M]
(hM : Module.IsTorsion R M) :
DirectSum.IsInternal fun p : (factors (⊤ : Submodule R M).annihilator).toFinset =>
torsionBy R M
(IsPrincipal.generator (p : Ideal R) ^
(factors (⊤ : Submodule R M).annihilator).count ↑p) := by
convert isInternal_prime_power_torsion hM
ext p : 1
rw [← torsionBySet_span_singleton_eq, Ideal.submodule_span_eq, ← Ideal.span_singleton_pow,
Ideal.span_singleton_generator]
#align submodule.is_internal_prime_power_torsion_of_pid Submodule.isInternal_prime_power_torsion_of_pid
theorem Submodule.exists_isInternal_prime_power_torsion_of_pid [Module.Finite R M]
(hM : Module.IsTorsion R M) :
∃ (ι : Type u) (_ : Fintype ι) (_ : DecidableEq ι) (p : ι → R) (_ : ∀ i, Irreducible <| p i)
(e : ι → ℕ), DirectSum.IsInternal fun i => torsionBy R M <| p i ^ e i := by
refine ⟨_, ?_, _, _, ?_, _, Submodule.isInternal_prime_power_torsion_of_pid hM⟩
· exact Finset.fintypeCoeSort _
· rintro ⟨p, hp⟩
have hP := prime_of_factor p (Multiset.mem_toFinset.mp hp)
haveI := Ideal.isPrime_of_prime hP
exact (IsPrincipal.prime_generator_of_isPrime p hP.ne_zero).irreducible
#align submodule.exists_is_internal_prime_power_torsion_of_pid Submodule.exists_isInternal_prime_power_torsion_of_pid
namespace Module
section PTorsion
variable {p : R} (hp : Irreducible p) (hM : Module.IsTorsion' M (Submonoid.powers p))
variable [dec : ∀ x : M, Decidable (x = 0)]
open Ideal Submodule.IsPrincipal
| Mathlib/Algebra/Module/PID.lean | 110 | 121 | theorem _root_.Ideal.torsionOf_eq_span_pow_pOrder (x : M) :
torsionOf R M x = span {p ^ pOrder hM x} := by |
dsimp only [pOrder]
rw [← (torsionOf R M x).span_singleton_generator, Ideal.span_singleton_eq_span_singleton, ←
Associates.mk_eq_mk_iff_associated, Associates.mk_pow]
have prop :
(fun n : ℕ => p ^ n • x = 0) = fun n : ℕ =>
(Associates.mk <| generator <| torsionOf R M x) ∣ Associates.mk p ^ n := by
ext n; rw [← Associates.mk_pow, Associates.mk_dvd_mk, ← mem_iff_generator_dvd]; rfl
have := (isTorsion'_powers_iff p).mp hM x; rw [prop] at this
convert Associates.eq_pow_find_of_dvd_irreducible_pow (Associates.irreducible_mk.mpr hp)
this.choose_spec
|
import Aesop
import Mathlib.Algebra.Group.Defs
import Mathlib.Data.Nat.Defs
import Mathlib.Data.Int.Defs
import Mathlib.Logic.Function.Basic
import Mathlib.Tactic.Cases
import Mathlib.Tactic.SimpRw
import Mathlib.Tactic.SplitIfs
#align_import algebra.group.basic from "leanprover-community/mathlib"@"a07d750983b94c530ab69a726862c2ab6802b38c"
assert_not_exists MonoidWithZero
assert_not_exists DenselyOrdered
open Function
universe u
variable {α β G M : Type*}
@[to_additive]
instance CommMagma.to_isCommutative [CommMagma G] : Std.Commutative (α := G) (· * ·) := ⟨mul_comm⟩
#align comm_semigroup.to_is_commutative CommMagma.to_isCommutative
#align add_comm_semigroup.to_is_commutative AddCommMagma.to_isCommutative
attribute [local simp] mul_assoc sub_eq_add_neg
section DivisionCommMonoid
variable [DivisionCommMonoid α] (a b c d : α)
attribute [local simp] mul_assoc mul_comm mul_left_comm div_eq_mul_inv
@[to_additive neg_add]
theorem mul_inv : (a * b)⁻¹ = a⁻¹ * b⁻¹ := by simp
#align mul_inv mul_inv
#align neg_add neg_add
@[to_additive]
theorem inv_div' : (a / b)⁻¹ = a⁻¹ / b⁻¹ := by simp
#align inv_div' inv_div'
#align neg_sub' neg_sub'
@[to_additive]
theorem div_eq_inv_mul : a / b = b⁻¹ * a := by simp
#align div_eq_inv_mul div_eq_inv_mul
#align sub_eq_neg_add sub_eq_neg_add
@[to_additive]
theorem inv_mul_eq_div : a⁻¹ * b = b / a := by simp
#align inv_mul_eq_div inv_mul_eq_div
#align neg_add_eq_sub neg_add_eq_sub
@[to_additive]
theorem inv_mul' : (a * b)⁻¹ = a⁻¹ / b := by simp
#align inv_mul' inv_mul'
#align neg_add' neg_add'
@[to_additive]
theorem inv_div_inv : a⁻¹ / b⁻¹ = b / a := by simp
#align inv_div_inv inv_div_inv
#align neg_sub_neg neg_sub_neg
@[to_additive]
theorem inv_inv_div_inv : (a⁻¹ / b⁻¹)⁻¹ = a / b := by simp
#align inv_inv_div_inv inv_inv_div_inv
#align neg_neg_sub_neg neg_neg_sub_neg
@[to_additive]
theorem one_div_mul_one_div : 1 / a * (1 / b) = 1 / (a * b) := by simp
#align one_div_mul_one_div one_div_mul_one_div
#align zero_sub_add_zero_sub zero_sub_add_zero_sub
@[to_additive]
| Mathlib/Algebra/Group/Basic.lean | 766 | 766 | theorem div_right_comm : a / b / c = a / c / b := by | simp
|
import Mathlib.Topology.UniformSpace.UniformConvergenceTopology
#align_import topology.uniform_space.equicontinuity from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
section
open UniformSpace Filter Set Uniformity Topology UniformConvergence Function
variable {ι κ X X' Y Z α α' β β' γ 𝓕 : Type*} [tX : TopologicalSpace X] [tY : TopologicalSpace Y]
[tZ : TopologicalSpace Z] [uα : UniformSpace α] [uβ : UniformSpace β] [uγ : UniformSpace γ]
def EquicontinuousAt (F : ι → X → α) (x₀ : X) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝 x₀, ∀ i, (F i x₀, F i x) ∈ U
#align equicontinuous_at EquicontinuousAt
protected abbrev Set.EquicontinuousAt (H : Set <| X → α) (x₀ : X) : Prop :=
EquicontinuousAt ((↑) : H → X → α) x₀
#align set.equicontinuous_at Set.EquicontinuousAt
def EquicontinuousWithinAt (F : ι → X → α) (S : Set X) (x₀ : X) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ x in 𝓝[S] x₀, ∀ i, (F i x₀, F i x) ∈ U
protected abbrev Set.EquicontinuousWithinAt (H : Set <| X → α) (S : Set X) (x₀ : X) : Prop :=
EquicontinuousWithinAt ((↑) : H → X → α) S x₀
def Equicontinuous (F : ι → X → α) : Prop :=
∀ x₀, EquicontinuousAt F x₀
#align equicontinuous Equicontinuous
protected abbrev Set.Equicontinuous (H : Set <| X → α) : Prop :=
Equicontinuous ((↑) : H → X → α)
#align set.equicontinuous Set.Equicontinuous
def EquicontinuousOn (F : ι → X → α) (S : Set X) : Prop :=
∀ x₀ ∈ S, EquicontinuousWithinAt F S x₀
protected abbrev Set.EquicontinuousOn (H : Set <| X → α) (S : Set X) : Prop :=
EquicontinuousOn ((↑) : H → X → α) S
def UniformEquicontinuous (F : ι → β → α) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β, ∀ i, (F i xy.1, F i xy.2) ∈ U
#align uniform_equicontinuous UniformEquicontinuous
protected abbrev Set.UniformEquicontinuous (H : Set <| β → α) : Prop :=
UniformEquicontinuous ((↑) : H → β → α)
#align set.uniform_equicontinuous Set.UniformEquicontinuous
def UniformEquicontinuousOn (F : ι → β → α) (S : Set β) : Prop :=
∀ U ∈ 𝓤 α, ∀ᶠ xy : β × β in 𝓤 β ⊓ 𝓟 (S ×ˢ S), ∀ i, (F i xy.1, F i xy.2) ∈ U
protected abbrev Set.UniformEquicontinuousOn (H : Set <| β → α) (S : Set β) : Prop :=
UniformEquicontinuousOn ((↑) : H → β → α) S
lemma EquicontinuousAt.equicontinuousWithinAt {F : ι → X → α} {x₀ : X} (H : EquicontinuousAt F x₀)
(S : Set X) : EquicontinuousWithinAt F S x₀ :=
fun U hU ↦ (H U hU).filter_mono inf_le_left
lemma EquicontinuousWithinAt.mono {F : ι → X → α} {x₀ : X} {S T : Set X}
(H : EquicontinuousWithinAt F T x₀) (hST : S ⊆ T) : EquicontinuousWithinAt F S x₀ :=
fun U hU ↦ (H U hU).filter_mono <| nhdsWithin_mono x₀ hST
@[simp] lemma equicontinuousWithinAt_univ (F : ι → X → α) (x₀ : X) :
EquicontinuousWithinAt F univ x₀ ↔ EquicontinuousAt F x₀ := by
rw [EquicontinuousWithinAt, EquicontinuousAt, nhdsWithin_univ]
lemma equicontinuousAt_restrict_iff (F : ι → X → α) {S : Set X} (x₀ : S) :
EquicontinuousAt (S.restrict ∘ F) x₀ ↔ EquicontinuousWithinAt F S x₀ := by
simp [EquicontinuousWithinAt, EquicontinuousAt,
← eventually_nhds_subtype_iff]
lemma Equicontinuous.equicontinuousOn {F : ι → X → α} (H : Equicontinuous F)
(S : Set X) : EquicontinuousOn F S :=
fun x _ ↦ (H x).equicontinuousWithinAt S
lemma EquicontinuousOn.mono {F : ι → X → α} {S T : Set X}
(H : EquicontinuousOn F T) (hST : S ⊆ T) : EquicontinuousOn F S :=
fun x hx ↦ (H x (hST hx)).mono hST
lemma equicontinuousOn_univ (F : ι → X → α) :
EquicontinuousOn F univ ↔ Equicontinuous F := by
simp [EquicontinuousOn, Equicontinuous]
lemma equicontinuous_restrict_iff (F : ι → X → α) {S : Set X} :
Equicontinuous (S.restrict ∘ F) ↔ EquicontinuousOn F S := by
simp [Equicontinuous, EquicontinuousOn, equicontinuousAt_restrict_iff]
lemma UniformEquicontinuous.uniformEquicontinuousOn {F : ι → β → α} (H : UniformEquicontinuous F)
(S : Set β) : UniformEquicontinuousOn F S :=
fun U hU ↦ (H U hU).filter_mono inf_le_left
lemma UniformEquicontinuousOn.mono {F : ι → β → α} {S T : Set β}
(H : UniformEquicontinuousOn F T) (hST : S ⊆ T) : UniformEquicontinuousOn F S :=
fun U hU ↦ (H U hU).filter_mono <| by gcongr
lemma uniformEquicontinuousOn_univ (F : ι → β → α) :
UniformEquicontinuousOn F univ ↔ UniformEquicontinuous F := by
simp [UniformEquicontinuousOn, UniformEquicontinuous]
lemma uniformEquicontinuous_restrict_iff (F : ι → β → α) {S : Set β} :
UniformEquicontinuous (S.restrict ∘ F) ↔ UniformEquicontinuousOn F S := by
rw [UniformEquicontinuous, UniformEquicontinuousOn]
conv in _ ⊓ _ => rw [← Subtype.range_val (s := S), ← range_prod_map, ← map_comap]
rfl
@[simp]
lemma equicontinuousAt_empty [h : IsEmpty ι] (F : ι → X → α) (x₀ : X) :
EquicontinuousAt F x₀ :=
fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim)
@[simp]
lemma equicontinuousWithinAt_empty [h : IsEmpty ι] (F : ι → X → α) (S : Set X) (x₀ : X) :
EquicontinuousWithinAt F S x₀ :=
fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim)
@[simp]
lemma equicontinuous_empty [IsEmpty ι] (F : ι → X → α) :
Equicontinuous F :=
equicontinuousAt_empty F
@[simp]
lemma equicontinuousOn_empty [IsEmpty ι] (F : ι → X → α) (S : Set X) :
EquicontinuousOn F S :=
fun x₀ _ ↦ equicontinuousWithinAt_empty F S x₀
@[simp]
lemma uniformEquicontinuous_empty [h : IsEmpty ι] (F : ι → β → α) :
UniformEquicontinuous F :=
fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim)
@[simp]
lemma uniformEquicontinuousOn_empty [h : IsEmpty ι] (F : ι → β → α) (S : Set β) :
UniformEquicontinuousOn F S :=
fun _ _ ↦ eventually_of_forall (fun _ ↦ h.elim)
theorem equicontinuousAt_finite [Finite ι] {F : ι → X → α} {x₀ : X} :
EquicontinuousAt F x₀ ↔ ∀ i, ContinuousAt (F i) x₀ := by
simp [EquicontinuousAt, ContinuousAt, (nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff,
UniformSpace.ball, @forall_swap _ ι]
theorem equicontinuousWithinAt_finite [Finite ι] {F : ι → X → α} {S : Set X} {x₀ : X} :
EquicontinuousWithinAt F S x₀ ↔ ∀ i, ContinuousWithinAt (F i) S x₀ := by
simp [EquicontinuousWithinAt, ContinuousWithinAt,
(nhds_basis_uniformity' (𝓤 α).basis_sets).tendsto_right_iff, UniformSpace.ball,
@forall_swap _ ι]
theorem equicontinuous_finite [Finite ι] {F : ι → X → α} :
Equicontinuous F ↔ ∀ i, Continuous (F i) := by
simp only [Equicontinuous, equicontinuousAt_finite, continuous_iff_continuousAt, @forall_swap ι]
theorem equicontinuousOn_finite [Finite ι] {F : ι → X → α} {S : Set X} :
EquicontinuousOn F S ↔ ∀ i, ContinuousOn (F i) S := by
simp only [EquicontinuousOn, equicontinuousWithinAt_finite, ContinuousOn, @forall_swap ι]
theorem uniformEquicontinuous_finite [Finite ι] {F : ι → β → α} :
UniformEquicontinuous F ↔ ∀ i, UniformContinuous (F i) := by
simp only [UniformEquicontinuous, eventually_all, @forall_swap _ ι]; rfl
theorem uniformEquicontinuousOn_finite [Finite ι] {F : ι → β → α} {S : Set β} :
UniformEquicontinuousOn F S ↔ ∀ i, UniformContinuousOn (F i) S := by
simp only [UniformEquicontinuousOn, eventually_all, @forall_swap _ ι]; rfl
theorem equicontinuousAt_unique [Unique ι] {F : ι → X → α} {x : X} :
EquicontinuousAt F x ↔ ContinuousAt (F default) x :=
equicontinuousAt_finite.trans Unique.forall_iff
theorem equicontinuousWithinAt_unique [Unique ι] {F : ι → X → α} {S : Set X} {x : X} :
EquicontinuousWithinAt F S x ↔ ContinuousWithinAt (F default) S x :=
equicontinuousWithinAt_finite.trans Unique.forall_iff
theorem equicontinuous_unique [Unique ι] {F : ι → X → α} :
Equicontinuous F ↔ Continuous (F default) :=
equicontinuous_finite.trans Unique.forall_iff
theorem equicontinuousOn_unique [Unique ι] {F : ι → X → α} {S : Set X} :
EquicontinuousOn F S ↔ ContinuousOn (F default) S :=
equicontinuousOn_finite.trans Unique.forall_iff
theorem uniformEquicontinuous_unique [Unique ι] {F : ι → β → α} :
UniformEquicontinuous F ↔ UniformContinuous (F default) :=
uniformEquicontinuous_finite.trans Unique.forall_iff
theorem uniformEquicontinuousOn_unique [Unique ι] {F : ι → β → α} {S : Set β} :
UniformEquicontinuousOn F S ↔ UniformContinuousOn (F default) S :=
uniformEquicontinuousOn_finite.trans Unique.forall_iff
theorem equicontinuousWithinAt_iff_pair {F : ι → X → α} {S : Set X} {x₀ : X} (hx₀ : x₀ ∈ S) :
EquicontinuousWithinAt F S x₀ ↔
∀ U ∈ 𝓤 α, ∃ V ∈ 𝓝[S] x₀, ∀ x ∈ V, ∀ y ∈ V, ∀ i, (F i x, F i y) ∈ U := by
constructor <;> intro H U hU
· rcases comp_symm_mem_uniformity_sets hU with ⟨V, hV, hVsymm, hVU⟩
refine ⟨_, H V hV, fun x hx y hy i => hVU (prod_mk_mem_compRel ?_ (hy i))⟩
exact hVsymm.mk_mem_comm.mp (hx i)
· rcases H U hU with ⟨V, hV, hVU⟩
filter_upwards [hV] using fun x hx i => hVU x₀ (mem_of_mem_nhdsWithin hx₀ hV) x hx i
theorem equicontinuousAt_iff_pair {F : ι → X → α} {x₀ : X} :
EquicontinuousAt F x₀ ↔
∀ U ∈ 𝓤 α, ∃ V ∈ 𝓝 x₀, ∀ x ∈ V, ∀ y ∈ V, ∀ i, (F i x, F i y) ∈ U := by
simp_rw [← equicontinuousWithinAt_univ, equicontinuousWithinAt_iff_pair (mem_univ x₀),
nhdsWithin_univ]
#align equicontinuous_at_iff_pair equicontinuousAt_iff_pair
theorem UniformEquicontinuous.equicontinuous {F : ι → β → α} (h : UniformEquicontinuous F) :
Equicontinuous F := fun x₀ U hU ↦
mem_of_superset (ball_mem_nhds x₀ (h U hU)) fun _ hx i ↦ hx i
#align uniform_equicontinuous.equicontinuous UniformEquicontinuous.equicontinuous
theorem UniformEquicontinuousOn.equicontinuousOn {F : ι → β → α} {S : Set β}
(h : UniformEquicontinuousOn F S) :
EquicontinuousOn F S := fun _ hx₀ U hU ↦
mem_of_superset (ball_mem_nhdsWithin hx₀ (h U hU)) fun _ hx i ↦ hx i
theorem EquicontinuousAt.continuousAt {F : ι → X → α} {x₀ : X} (h : EquicontinuousAt F x₀) (i : ι) :
ContinuousAt (F i) x₀ :=
(UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U ⟨hU, _⟩ ↦ (h U hU).mono fun _x hx ↦ hx i
#align equicontinuous_at.continuous_at EquicontinuousAt.continuousAt
theorem EquicontinuousWithinAt.continuousWithinAt {F : ι → X → α} {S : Set X} {x₀ : X}
(h : EquicontinuousWithinAt F S x₀) (i : ι) :
ContinuousWithinAt (F i) S x₀ :=
(UniformSpace.hasBasis_nhds _).tendsto_right_iff.2 fun U ⟨hU, _⟩ ↦ (h U hU).mono fun _x hx ↦ hx i
protected theorem Set.EquicontinuousAt.continuousAt_of_mem {H : Set <| X → α} {x₀ : X}
(h : H.EquicontinuousAt x₀) {f : X → α} (hf : f ∈ H) : ContinuousAt f x₀ :=
h.continuousAt ⟨f, hf⟩
#align set.equicontinuous_at.continuous_at_of_mem Set.EquicontinuousAt.continuousAt_of_mem
protected theorem Set.EquicontinuousWithinAt.continuousWithinAt_of_mem {H : Set <| X → α}
{S : Set X} {x₀ : X} (h : H.EquicontinuousWithinAt S x₀) {f : X → α} (hf : f ∈ H) :
ContinuousWithinAt f S x₀ :=
h.continuousWithinAt ⟨f, hf⟩
theorem Equicontinuous.continuous {F : ι → X → α} (h : Equicontinuous F) (i : ι) :
Continuous (F i) :=
continuous_iff_continuousAt.mpr fun x => (h x).continuousAt i
#align equicontinuous.continuous Equicontinuous.continuous
theorem EquicontinuousOn.continuousOn {F : ι → X → α} {S : Set X} (h : EquicontinuousOn F S)
(i : ι) : ContinuousOn (F i) S :=
fun x hx ↦ (h x hx).continuousWithinAt i
protected theorem Set.Equicontinuous.continuous_of_mem {H : Set <| X → α} (h : H.Equicontinuous)
{f : X → α} (hf : f ∈ H) : Continuous f :=
h.continuous ⟨f, hf⟩
#align set.equicontinuous.continuous_of_mem Set.Equicontinuous.continuous_of_mem
protected theorem Set.EquicontinuousOn.continuousOn_of_mem {H : Set <| X → α} {S : Set X}
(h : H.EquicontinuousOn S) {f : X → α} (hf : f ∈ H) : ContinuousOn f S :=
h.continuousOn ⟨f, hf⟩
theorem UniformEquicontinuous.uniformContinuous {F : ι → β → α} (h : UniformEquicontinuous F)
(i : ι) : UniformContinuous (F i) := fun U hU =>
mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i)
#align uniform_equicontinuous.uniform_continuous UniformEquicontinuous.uniformContinuous
theorem UniformEquicontinuousOn.uniformContinuousOn {F : ι → β → α} {S : Set β}
(h : UniformEquicontinuousOn F S) (i : ι) :
UniformContinuousOn (F i) S := fun U hU =>
mem_map.mpr (mem_of_superset (h U hU) fun _ hxy => hxy i)
protected theorem Set.UniformEquicontinuous.uniformContinuous_of_mem {H : Set <| β → α}
(h : H.UniformEquicontinuous) {f : β → α} (hf : f ∈ H) : UniformContinuous f :=
h.uniformContinuous ⟨f, hf⟩
#align set.uniform_equicontinuous.uniform_continuous_of_mem Set.UniformEquicontinuous.uniformContinuous_of_mem
protected theorem Set.UniformEquicontinuousOn.uniformContinuousOn_of_mem {H : Set <| β → α}
{S : Set β} (h : H.UniformEquicontinuousOn S) {f : β → α} (hf : f ∈ H) :
UniformContinuousOn f S :=
h.uniformContinuousOn ⟨f, hf⟩
theorem EquicontinuousAt.comp {F : ι → X → α} {x₀ : X} (h : EquicontinuousAt F x₀) (u : κ → ι) :
EquicontinuousAt (F ∘ u) x₀ := fun U hU => (h U hU).mono fun _ H k => H (u k)
#align equicontinuous_at.comp EquicontinuousAt.comp
theorem EquicontinuousWithinAt.comp {F : ι → X → α} {S : Set X} {x₀ : X}
(h : EquicontinuousWithinAt F S x₀) (u : κ → ι) :
EquicontinuousWithinAt (F ∘ u) S x₀ :=
fun U hU ↦ (h U hU).mono fun _ H k => H (u k)
protected theorem Set.EquicontinuousAt.mono {H H' : Set <| X → α} {x₀ : X}
(h : H.EquicontinuousAt x₀) (hH : H' ⊆ H) : H'.EquicontinuousAt x₀ :=
h.comp (inclusion hH)
#align set.equicontinuous_at.mono Set.EquicontinuousAt.mono
protected theorem Set.EquicontinuousWithinAt.mono {H H' : Set <| X → α} {S : Set X} {x₀ : X}
(h : H.EquicontinuousWithinAt S x₀) (hH : H' ⊆ H) : H'.EquicontinuousWithinAt S x₀ :=
h.comp (inclusion hH)
theorem Equicontinuous.comp {F : ι → X → α} (h : Equicontinuous F) (u : κ → ι) :
Equicontinuous (F ∘ u) := fun x => (h x).comp u
#align equicontinuous.comp Equicontinuous.comp
theorem EquicontinuousOn.comp {F : ι → X → α} {S : Set X} (h : EquicontinuousOn F S) (u : κ → ι) :
EquicontinuousOn (F ∘ u) S := fun x hx ↦ (h x hx).comp u
protected theorem Set.Equicontinuous.mono {H H' : Set <| X → α} (h : H.Equicontinuous)
(hH : H' ⊆ H) : H'.Equicontinuous :=
h.comp (inclusion hH)
#align set.equicontinuous.mono Set.Equicontinuous.mono
protected theorem Set.EquicontinuousOn.mono {H H' : Set <| X → α} {S : Set X}
(h : H.EquicontinuousOn S) (hH : H' ⊆ H) : H'.EquicontinuousOn S :=
h.comp (inclusion hH)
theorem UniformEquicontinuous.comp {F : ι → β → α} (h : UniformEquicontinuous F) (u : κ → ι) :
UniformEquicontinuous (F ∘ u) := fun U hU => (h U hU).mono fun _ H k => H (u k)
#align uniform_equicontinuous.comp UniformEquicontinuous.comp
theorem UniformEquicontinuousOn.comp {F : ι → β → α} {S : Set β} (h : UniformEquicontinuousOn F S)
(u : κ → ι) : UniformEquicontinuousOn (F ∘ u) S :=
fun U hU ↦ (h U hU).mono fun _ H k => H (u k)
protected theorem Set.UniformEquicontinuous.mono {H H' : Set <| β → α} (h : H.UniformEquicontinuous)
(hH : H' ⊆ H) : H'.UniformEquicontinuous :=
h.comp (inclusion hH)
#align set.uniform_equicontinuous.mono Set.UniformEquicontinuous.mono
protected theorem Set.UniformEquicontinuousOn.mono {H H' : Set <| β → α} {S : Set β}
(h : H.UniformEquicontinuousOn S) (hH : H' ⊆ H) : H'.UniformEquicontinuousOn S :=
h.comp (inclusion hH)
theorem equicontinuousAt_iff_range {F : ι → X → α} {x₀ : X} :
EquicontinuousAt F x₀ ↔ EquicontinuousAt ((↑) : range F → X → α) x₀ := by
simp only [EquicontinuousAt, forall_subtype_range_iff]
#align equicontinuous_at_iff_range equicontinuousAt_iff_range
theorem equicontinuousWithinAt_iff_range {F : ι → X → α} {S : Set X} {x₀ : X} :
EquicontinuousWithinAt F S x₀ ↔ EquicontinuousWithinAt ((↑) : range F → X → α) S x₀ := by
simp only [EquicontinuousWithinAt, forall_subtype_range_iff]
theorem equicontinuous_iff_range {F : ι → X → α} :
Equicontinuous F ↔ Equicontinuous ((↑) : range F → X → α) :=
forall_congr' fun _ => equicontinuousAt_iff_range
#align equicontinuous_iff_range equicontinuous_iff_range
theorem equicontinuousOn_iff_range {F : ι → X → α} {S : Set X} :
EquicontinuousOn F S ↔ EquicontinuousOn ((↑) : range F → X → α) S :=
forall_congr' fun _ ↦ forall_congr' fun _ ↦ equicontinuousWithinAt_iff_range
theorem uniformEquicontinuous_iff_range {F : ι → β → α} :
UniformEquicontinuous F ↔ UniformEquicontinuous ((↑) : range F → β → α) :=
⟨fun h => by rw [← comp_rangeSplitting F]; exact h.comp _, fun h =>
h.comp (rangeFactorization F)⟩
#align uniform_equicontinuous_at_iff_range uniformEquicontinuous_iff_range
theorem uniformEquicontinuousOn_iff_range {F : ι → β → α} {S : Set β} :
UniformEquicontinuousOn F S ↔ UniformEquicontinuousOn ((↑) : range F → β → α) S :=
⟨fun h => by rw [← comp_rangeSplitting F]; exact h.comp _, fun h =>
h.comp (rangeFactorization F)⟩
section
open UniformFun
theorem equicontinuousAt_iff_continuousAt {F : ι → X → α} {x₀ : X} :
EquicontinuousAt F x₀ ↔ ContinuousAt (ofFun ∘ Function.swap F : X → ι →ᵤ α) x₀ := by
rw [ContinuousAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff]
rfl
#align equicontinuous_at_iff_continuous_at equicontinuousAt_iff_continuousAt
theorem equicontinuousWithinAt_iff_continuousWithinAt {F : ι → X → α} {S : Set X} {x₀ : X} :
EquicontinuousWithinAt F S x₀ ↔
ContinuousWithinAt (ofFun ∘ Function.swap F : X → ι →ᵤ α) S x₀ := by
rw [ContinuousWithinAt, (UniformFun.hasBasis_nhds ι α _).tendsto_right_iff]
rfl
theorem equicontinuous_iff_continuous {F : ι → X → α} :
Equicontinuous F ↔ Continuous (ofFun ∘ Function.swap F : X → ι →ᵤ α) := by
simp_rw [Equicontinuous, continuous_iff_continuousAt, equicontinuousAt_iff_continuousAt]
#align equicontinuous_iff_continuous equicontinuous_iff_continuous
theorem equicontinuousOn_iff_continuousOn {F : ι → X → α} {S : Set X} :
EquicontinuousOn F S ↔ ContinuousOn (ofFun ∘ Function.swap F : X → ι →ᵤ α) S := by
simp_rw [EquicontinuousOn, ContinuousOn, equicontinuousWithinAt_iff_continuousWithinAt]
theorem uniformEquicontinuous_iff_uniformContinuous {F : ι → β → α} :
UniformEquicontinuous F ↔ UniformContinuous (ofFun ∘ Function.swap F : β → ι →ᵤ α) := by
rw [UniformContinuous, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff]
rfl
#align uniform_equicontinuous_iff_uniform_continuous uniformEquicontinuous_iff_uniformContinuous
theorem uniformEquicontinuousOn_iff_uniformContinuousOn {F : ι → β → α} {S : Set β} :
UniformEquicontinuousOn F S ↔ UniformContinuousOn (ofFun ∘ Function.swap F : β → ι →ᵤ α) S := by
rw [UniformContinuousOn, (UniformFun.hasBasis_uniformity ι α).tendsto_right_iff]
rfl
theorem equicontinuousWithinAt_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'}
{S : Set X} {x₀ : X} : EquicontinuousWithinAt (uα := ⨅ k, u k) F S x₀ ↔
∀ k, EquicontinuousWithinAt (uα := u k) F S x₀ := by
simp only [equicontinuousWithinAt_iff_continuousWithinAt (uα := _), topologicalSpace]
unfold ContinuousWithinAt
rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, nhds_iInf, tendsto_iInf]
theorem equicontinuousAt_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'}
{x₀ : X} :
EquicontinuousAt (uα := ⨅ k, u k) F x₀ ↔ ∀ k, EquicontinuousAt (uα := u k) F x₀ := by
simp only [← equicontinuousWithinAt_univ (uα := _), equicontinuousWithinAt_iInf_rng]
theorem equicontinuous_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'} :
Equicontinuous (uα := ⨅ k, u k) F ↔ ∀ k, Equicontinuous (uα := u k) F := by
simp_rw [equicontinuous_iff_continuous (uα := _), UniformFun.topologicalSpace]
rw [UniformFun.iInf_eq, toTopologicalSpace_iInf, continuous_iInf_rng]
theorem equicontinuousOn_iInf_rng {u : κ → UniformSpace α'} {F : ι → X → α'}
{S : Set X} :
EquicontinuousOn (uα := ⨅ k, u k) F S ↔ ∀ k, EquicontinuousOn (uα := u k) F S := by
simp_rw [EquicontinuousOn, equicontinuousWithinAt_iInf_rng, @forall_swap _ κ]
theorem uniformEquicontinuous_iInf_rng {u : κ → UniformSpace α'} {F : ι → β → α'} :
UniformEquicontinuous (uα := ⨅ k, u k) F ↔ ∀ k, UniformEquicontinuous (uα := u k) F := by
simp_rw [uniformEquicontinuous_iff_uniformContinuous (uα := _)]
rw [UniformFun.iInf_eq, uniformContinuous_iInf_rng]
theorem uniformEquicontinuousOn_iInf_rng {u : κ → UniformSpace α'} {F : ι → β → α'}
{S : Set β} : UniformEquicontinuousOn (uα := ⨅ k, u k) F S ↔
∀ k, UniformEquicontinuousOn (uα := u k) F S := by
simp_rw [uniformEquicontinuousOn_iff_uniformContinuousOn (uα := _)]
unfold UniformContinuousOn
rw [UniformFun.iInf_eq, iInf_uniformity, tendsto_iInf]
theorem equicontinuousWithinAt_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α}
{S : Set X'} {x₀ : X'} {k : κ} (hk : EquicontinuousWithinAt (tX := t k) F S x₀) :
EquicontinuousWithinAt (tX := ⨅ k, t k) F S x₀ := by
simp [equicontinuousWithinAt_iff_continuousWithinAt (tX := _)] at hk ⊢
unfold ContinuousWithinAt nhdsWithin at hk ⊢
rw [nhds_iInf]
exact hk.mono_left <| inf_le_inf_right _ <| iInf_le _ k
theorem equicontinuousAt_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α}
{x₀ : X'} {k : κ} (hk : EquicontinuousAt (tX := t k) F x₀) :
EquicontinuousAt (tX := ⨅ k, t k) F x₀ := by
rw [← equicontinuousWithinAt_univ (tX := _)] at hk ⊢
exact equicontinuousWithinAt_iInf_dom hk
theorem equicontinuous_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α}
{k : κ} (hk : Equicontinuous (tX := t k) F) :
Equicontinuous (tX := ⨅ k, t k) F :=
fun x ↦ equicontinuousAt_iInf_dom (hk x)
theorem equicontinuousOn_iInf_dom {t : κ → TopologicalSpace X'} {F : ι → X' → α}
{S : Set X'} {k : κ} (hk : EquicontinuousOn (tX := t k) F S) :
EquicontinuousOn (tX := ⨅ k, t k) F S :=
fun x hx ↦ equicontinuousWithinAt_iInf_dom (hk x hx)
theorem uniformEquicontinuous_iInf_dom {u : κ → UniformSpace β'} {F : ι → β' → α}
{k : κ} (hk : UniformEquicontinuous (uβ := u k) F) :
UniformEquicontinuous (uβ := ⨅ k, u k) F := by
simp_rw [uniformEquicontinuous_iff_uniformContinuous (uβ := _)] at hk ⊢
exact uniformContinuous_iInf_dom hk
theorem uniformEquicontinuousOn_iInf_dom {u : κ → UniformSpace β'} {F : ι → β' → α}
{S : Set β'} {k : κ} (hk : UniformEquicontinuousOn (uβ := u k) F S) :
UniformEquicontinuousOn (uβ := ⨅ k, u k) F S := by
simp_rw [uniformEquicontinuousOn_iff_uniformContinuousOn (uβ := _)] at hk ⊢
unfold UniformContinuousOn
rw [iInf_uniformity]
exact hk.mono_left <| inf_le_inf_right _ <| iInf_le _ k
theorem Filter.HasBasis.equicontinuousAt_iff_left {p : κ → Prop} {s : κ → Set X}
{F : ι → X → α} {x₀ : X} (hX : (𝓝 x₀).HasBasis p s) :
EquicontinuousAt F x₀ ↔ ∀ U ∈ 𝓤 α, ∃ k, p k ∧ ∀ x ∈ s k, ∀ i, (F i x₀, F i x) ∈ U := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds ι α _)]
rfl
#align filter.has_basis.equicontinuous_at_iff_left Filter.HasBasis.equicontinuousAt_iff_left
theorem Filter.HasBasis.equicontinuousWithinAt_iff_left {p : κ → Prop} {s : κ → Set X}
{F : ι → X → α} {S : Set X} {x₀ : X} (hX : (𝓝[S] x₀).HasBasis p s) :
EquicontinuousWithinAt F S x₀ ↔ ∀ U ∈ 𝓤 α, ∃ k, p k ∧ ∀ x ∈ s k, ∀ i, (F i x₀, F i x) ∈ U := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds ι α _)]
rfl
theorem Filter.HasBasis.equicontinuousAt_iff_right {p : κ → Prop} {s : κ → Set (α × α)}
{F : ι → X → α} {x₀ : X} (hα : (𝓤 α).HasBasis p s) :
EquicontinuousAt F x₀ ↔ ∀ k, p k → ∀ᶠ x in 𝓝 x₀, ∀ i, (F i x₀, F i x) ∈ s k := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
(UniformFun.hasBasis_nhds_of_basis ι α _ hα).tendsto_right_iff]
rfl
#align filter.has_basis.equicontinuous_at_iff_right Filter.HasBasis.equicontinuousAt_iff_right
theorem Filter.HasBasis.equicontinuousWithinAt_iff_right {p : κ → Prop}
{s : κ → Set (α × α)} {F : ι → X → α} {S : Set X} {x₀ : X} (hα : (𝓤 α).HasBasis p s) :
EquicontinuousWithinAt F S x₀ ↔ ∀ k, p k → ∀ᶠ x in 𝓝[S] x₀, ∀ i, (F i x₀, F i x) ∈ s k := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
(UniformFun.hasBasis_nhds_of_basis ι α _ hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.equicontinuousAt_iff {κ₁ κ₂ : Type*} {p₁ : κ₁ → Prop} {s₁ : κ₁ → Set X}
{p₂ : κ₂ → Prop} {s₂ : κ₂ → Set (α × α)} {F : ι → X → α} {x₀ : X} (hX : (𝓝 x₀).HasBasis p₁ s₁)
(hα : (𝓤 α).HasBasis p₂ s₂) :
EquicontinuousAt F x₀ ↔
∀ k₂, p₂ k₂ → ∃ k₁, p₁ k₁ ∧ ∀ x ∈ s₁ k₁, ∀ i, (F i x₀, F i x) ∈ s₂ k₂ := by
rw [equicontinuousAt_iff_continuousAt, ContinuousAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds_of_basis ι α _ hα)]
rfl
#align filter.has_basis.equicontinuous_at_iff Filter.HasBasis.equicontinuousAt_iff
theorem Filter.HasBasis.equicontinuousWithinAt_iff {κ₁ κ₂ : Type*} {p₁ : κ₁ → Prop}
{s₁ : κ₁ → Set X} {p₂ : κ₂ → Prop} {s₂ : κ₂ → Set (α × α)} {F : ι → X → α} {S : Set X} {x₀ : X}
(hX : (𝓝[S] x₀).HasBasis p₁ s₁) (hα : (𝓤 α).HasBasis p₂ s₂) :
EquicontinuousWithinAt F S x₀ ↔
∀ k₂, p₂ k₂ → ∃ k₁, p₁ k₁ ∧ ∀ x ∈ s₁ k₁, ∀ i, (F i x₀, F i x) ∈ s₂ k₂ := by
rw [equicontinuousWithinAt_iff_continuousWithinAt, ContinuousWithinAt,
hX.tendsto_iff (UniformFun.hasBasis_nhds_of_basis ι α _ hα)]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff_left {p : κ → Prop}
{s : κ → Set (β × β)} {F : ι → β → α} (hβ : (𝓤 β).HasBasis p s) :
UniformEquicontinuous F ↔
∀ U ∈ 𝓤 α, ∃ k, p k ∧ ∀ x y, (x, y) ∈ s k → ∀ i, (F i x, F i y) ∈ U := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity ι α)]
simp only [Prod.forall]
rfl
#align filter.has_basis.uniform_equicontinuous_iff_left Filter.HasBasis.uniformEquicontinuous_iff_left
theorem Filter.HasBasis.uniformEquicontinuousOn_iff_left {p : κ → Prop}
{s : κ → Set (β × β)} {F : ι → β → α} {S : Set β} (hβ : (𝓤 β ⊓ 𝓟 (S ×ˢ S)).HasBasis p s) :
UniformEquicontinuousOn F S ↔
∀ U ∈ 𝓤 α, ∃ k, p k ∧ ∀ x y, (x, y) ∈ s k → ∀ i, (F i x, F i y) ∈ U := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity ι α)]
simp only [Prod.forall]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff_right {p : κ → Prop}
{s : κ → Set (α × α)} {F : ι → β → α} (hα : (𝓤 α).HasBasis p s) :
UniformEquicontinuous F ↔ ∀ k, p k → ∀ᶠ xy : β × β in 𝓤 β, ∀ i, (F i xy.1, F i xy.2) ∈ s k := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
(UniformFun.hasBasis_uniformity_of_basis ι α hα).tendsto_right_iff]
rfl
#align filter.has_basis.uniform_equicontinuous_iff_right Filter.HasBasis.uniformEquicontinuous_iff_right
theorem Filter.HasBasis.uniformEquicontinuousOn_iff_right {p : κ → Prop}
{s : κ → Set (α × α)} {F : ι → β → α} {S : Set β} (hα : (𝓤 α).HasBasis p s) :
UniformEquicontinuousOn F S ↔
∀ k, p k → ∀ᶠ xy : β × β in 𝓤 β ⊓ 𝓟 (S ×ˢ S), ∀ i, (F i xy.1, F i xy.2) ∈ s k := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
(UniformFun.hasBasis_uniformity_of_basis ι α hα).tendsto_right_iff]
rfl
theorem Filter.HasBasis.uniformEquicontinuous_iff {κ₁ κ₂ : Type*} {p₁ : κ₁ → Prop}
{s₁ : κ₁ → Set (β × β)} {p₂ : κ₂ → Prop} {s₂ : κ₂ → Set (α × α)} {F : ι → β → α}
(hβ : (𝓤 β).HasBasis p₁ s₁) (hα : (𝓤 α).HasBasis p₂ s₂) :
UniformEquicontinuous F ↔
∀ k₂, p₂ k₂ → ∃ k₁, p₁ k₁ ∧ ∀ x y, (x, y) ∈ s₁ k₁ → ∀ i, (F i x, F i y) ∈ s₂ k₂ := by
rw [uniformEquicontinuous_iff_uniformContinuous, UniformContinuous,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity_of_basis ι α hα)]
simp only [Prod.forall]
rfl
#align filter.has_basis.uniform_equicontinuous_iff Filter.HasBasis.uniformEquicontinuous_iff
theorem Filter.HasBasis.uniformEquicontinuousOn_iff {κ₁ κ₂ : Type*} {p₁ : κ₁ → Prop}
{s₁ : κ₁ → Set (β × β)} {p₂ : κ₂ → Prop} {s₂ : κ₂ → Set (α × α)} {F : ι → β → α}
{S : Set β} (hβ : (𝓤 β ⊓ 𝓟 (S ×ˢ S)).HasBasis p₁ s₁) (hα : (𝓤 α).HasBasis p₂ s₂) :
UniformEquicontinuousOn F S ↔
∀ k₂, p₂ k₂ → ∃ k₁, p₁ k₁ ∧ ∀ x y, (x, y) ∈ s₁ k₁ → ∀ i, (F i x, F i y) ∈ s₂ k₂ := by
rw [uniformEquicontinuousOn_iff_uniformContinuousOn, UniformContinuousOn,
hβ.tendsto_iff (UniformFun.hasBasis_uniformity_of_basis ι α hα)]
simp only [Prod.forall]
rfl
theorem UniformInducing.equicontinuousAt_iff {F : ι → X → α} {x₀ : X} {u : α → β}
(hu : UniformInducing u) : EquicontinuousAt F x₀ ↔ EquicontinuousAt ((u ∘ ·) ∘ F) x₀ := by
have := (UniformFun.postcomp_uniformInducing (α := ι) hu).inducing
rw [equicontinuousAt_iff_continuousAt, equicontinuousAt_iff_continuousAt, this.continuousAt_iff]
rfl
#align uniform_inducing.equicontinuous_at_iff UniformInducing.equicontinuousAt_iff
theorem UniformInducing.equicontinuousWithinAt_iff {F : ι → X → α} {S : Set X} {x₀ : X} {u : α → β}
(hu : UniformInducing u) : EquicontinuousWithinAt F S x₀ ↔
EquicontinuousWithinAt ((u ∘ ·) ∘ F) S x₀ := by
have := (UniformFun.postcomp_uniformInducing (α := ι) hu).inducing
simp only [equicontinuousWithinAt_iff_continuousWithinAt, this.continuousWithinAt_iff]
rfl
theorem UniformInducing.equicontinuous_iff {F : ι → X → α} {u : α → β} (hu : UniformInducing u) :
Equicontinuous F ↔ Equicontinuous ((u ∘ ·) ∘ F) := by
congrm ∀ x, ?_
rw [hu.equicontinuousAt_iff]
#align uniform_inducing.equicontinuous_iff UniformInducing.equicontinuous_iff
theorem UniformInducing.equicontinuousOn_iff {F : ι → X → α} {S : Set X} {u : α → β}
(hu : UniformInducing u) : EquicontinuousOn F S ↔ EquicontinuousOn ((u ∘ ·) ∘ F) S := by
congrm ∀ x ∈ S, ?_
rw [hu.equicontinuousWithinAt_iff]
theorem UniformInducing.uniformEquicontinuous_iff {F : ι → β → α} {u : α → γ}
(hu : UniformInducing u) : UniformEquicontinuous F ↔ UniformEquicontinuous ((u ∘ ·) ∘ F) := by
have := UniformFun.postcomp_uniformInducing (α := ι) hu
simp only [uniformEquicontinuous_iff_uniformContinuous, this.uniformContinuous_iff]
rfl
#align uniform_inducing.uniform_equicontinuous_iff UniformInducing.uniformEquicontinuous_iff
theorem UniformInducing.uniformEquicontinuousOn_iff {F : ι → β → α} {S : Set β} {u : α → γ}
(hu : UniformInducing u) :
UniformEquicontinuousOn F S ↔ UniformEquicontinuousOn ((u ∘ ·) ∘ F) S := by
have := UniformFun.postcomp_uniformInducing (α := ι) hu
simp only [uniformEquicontinuousOn_iff_uniformContinuousOn, this.uniformContinuousOn_iff]
rfl
theorem EquicontinuousWithinAt.closure' {A : Set Y} {u : Y → X → α} {S : Set X} {x₀ : X}
(hA : EquicontinuousWithinAt (u ∘ (↑) : A → X → α) S x₀) (hu₁ : Continuous (S.restrict ∘ u))
(hu₂ : Continuous (eval x₀ ∘ u)) :
EquicontinuousWithinAt (u ∘ (↑) : closure A → X → α) S x₀ := by
intro U hU
rcases mem_uniformity_isClosed hU with ⟨V, hV, hVclosed, hVU⟩
filter_upwards [hA V hV, eventually_mem_nhdsWithin] with x hx hxS
rw [SetCoe.forall] at *
change A ⊆ (fun f => (u f x₀, u f x)) ⁻¹' V at hx
refine (closure_minimal hx <| hVclosed.preimage <| hu₂.prod_mk ?_).trans (preimage_mono hVU)
exact (continuous_apply ⟨x, hxS⟩).comp hu₁
| Mathlib/Topology/UniformSpace/Equicontinuity.lean | 820 | 824 | theorem EquicontinuousAt.closure' {A : Set Y} {u : Y → X → α} {x₀ : X}
(hA : EquicontinuousAt (u ∘ (↑) : A → X → α) x₀) (hu : Continuous u) :
EquicontinuousAt (u ∘ (↑) : closure A → X → α) x₀ := by |
rw [← equicontinuousWithinAt_univ] at hA ⊢
exact hA.closure' (Pi.continuous_restrict _ |>.comp hu) (continuous_apply x₀ |>.comp hu)
|
import Mathlib.Analysis.NormedSpace.ConformalLinearMap
import Mathlib.Analysis.InnerProductSpace.Basic
#align_import analysis.inner_product_space.conformal_linear_map from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
variable {E F : Type*}
variable [NormedAddCommGroup E] [NormedAddCommGroup F]
variable [InnerProductSpace ℝ E] [InnerProductSpace ℝ F]
open LinearIsometry ContinuousLinearMap
open RealInnerProductSpace
| Mathlib/Analysis/InnerProductSpace/ConformalLinearMap.lean | 29 | 43 | theorem isConformalMap_iff (f : E →L[ℝ] F) :
IsConformalMap f ↔ ∃ c : ℝ, 0 < c ∧ ∀ u v : E, ⟪f u, f v⟫ = c * ⟪u, v⟫ := by |
constructor
· rintro ⟨c₁, hc₁, li, rfl⟩
refine ⟨c₁ * c₁, mul_self_pos.2 hc₁, fun u v => ?_⟩
simp only [real_inner_smul_left, real_inner_smul_right, mul_assoc, coe_smul',
coe_toContinuousLinearMap, Pi.smul_apply, inner_map_map]
· rintro ⟨c₁, hc₁, huv⟩
obtain ⟨c, hc, rfl⟩ : ∃ c : ℝ, 0 < c ∧ c₁ = c * c :=
⟨√c₁, Real.sqrt_pos.2 hc₁, (Real.mul_self_sqrt hc₁.le).symm⟩
refine ⟨c, hc.ne', (c⁻¹ • f : E →ₗ[ℝ] F).isometryOfInner fun u v => ?_, ?_⟩
· simp only [real_inner_smul_left, real_inner_smul_right, huv, mul_assoc, coe_smul,
inv_mul_cancel_left₀ hc.ne', LinearMap.smul_apply, ContinuousLinearMap.coe_coe]
· ext1 x
exact (smul_inv_smul₀ hc.ne' (f x)).symm
|
import Mathlib.Data.Set.Image
import Mathlib.Order.SuccPred.Relation
import Mathlib.Topology.Clopen
import Mathlib.Topology.Irreducible
#align_import topology.connected from "leanprover-community/mathlib"@"d101e93197bb5f6ea89bd7ba386b7f7dff1f3903"
open Set Function Topology TopologicalSpace Relation
open scoped Classical
universe u v
variable {α : Type u} {β : Type v} {ι : Type*} {π : ι → Type*} [TopologicalSpace α]
{s t u v : Set α}
section Preconnected
def IsPreconnected (s : Set α) : Prop :=
∀ u v : Set α, IsOpen u → IsOpen v → s ⊆ u ∪ v → (s ∩ u).Nonempty → (s ∩ v).Nonempty →
(s ∩ (u ∩ v)).Nonempty
#align is_preconnected IsPreconnected
def IsConnected (s : Set α) : Prop :=
s.Nonempty ∧ IsPreconnected s
#align is_connected IsConnected
theorem IsConnected.nonempty {s : Set α} (h : IsConnected s) : s.Nonempty :=
h.1
#align is_connected.nonempty IsConnected.nonempty
theorem IsConnected.isPreconnected {s : Set α} (h : IsConnected s) : IsPreconnected s :=
h.2
#align is_connected.is_preconnected IsConnected.isPreconnected
theorem IsPreirreducible.isPreconnected {s : Set α} (H : IsPreirreducible s) : IsPreconnected s :=
fun _ _ hu hv _ => H _ _ hu hv
#align is_preirreducible.is_preconnected IsPreirreducible.isPreconnected
theorem IsIrreducible.isConnected {s : Set α} (H : IsIrreducible s) : IsConnected s :=
⟨H.nonempty, H.isPreirreducible.isPreconnected⟩
#align is_irreducible.is_connected IsIrreducible.isConnected
theorem isPreconnected_empty : IsPreconnected (∅ : Set α) :=
isPreirreducible_empty.isPreconnected
#align is_preconnected_empty isPreconnected_empty
theorem isConnected_singleton {x} : IsConnected ({x} : Set α) :=
isIrreducible_singleton.isConnected
#align is_connected_singleton isConnected_singleton
theorem isPreconnected_singleton {x} : IsPreconnected ({x} : Set α) :=
isConnected_singleton.isPreconnected
#align is_preconnected_singleton isPreconnected_singleton
theorem Set.Subsingleton.isPreconnected {s : Set α} (hs : s.Subsingleton) : IsPreconnected s :=
hs.induction_on isPreconnected_empty fun _ => isPreconnected_singleton
#align set.subsingleton.is_preconnected Set.Subsingleton.isPreconnected
theorem isPreconnected_of_forall {s : Set α} (x : α)
(H : ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) : IsPreconnected s := by
rintro u v hu hv hs ⟨z, zs, zu⟩ ⟨y, ys, yv⟩
have xs : x ∈ s := by
rcases H y ys with ⟨t, ts, xt, -, -⟩
exact ts xt
-- Porting note (#11215): TODO: use `wlog xu : x ∈ u := hs xs using u v y z, v u z y`
cases hs xs with
| inl xu =>
rcases H y ys with ⟨t, ts, xt, yt, ht⟩
have := ht u v hu hv (ts.trans hs) ⟨x, xt, xu⟩ ⟨y, yt, yv⟩
exact this.imp fun z hz => ⟨ts hz.1, hz.2⟩
| inr xv =>
rcases H z zs with ⟨t, ts, xt, zt, ht⟩
have := ht v u hv hu (ts.trans <| by rwa [union_comm]) ⟨x, xt, xv⟩ ⟨z, zt, zu⟩
exact this.imp fun _ h => ⟨ts h.1, h.2.2, h.2.1⟩
#align is_preconnected_of_forall isPreconnected_of_forall
theorem isPreconnected_of_forall_pair {s : Set α}
(H : ∀ x ∈ s, ∀ y ∈ s, ∃ t, t ⊆ s ∧ x ∈ t ∧ y ∈ t ∧ IsPreconnected t) :
IsPreconnected s := by
rcases eq_empty_or_nonempty s with (rfl | ⟨x, hx⟩)
exacts [isPreconnected_empty, isPreconnected_of_forall x fun y => H x hx y]
#align is_preconnected_of_forall_pair isPreconnected_of_forall_pair
theorem isPreconnected_sUnion (x : α) (c : Set (Set α)) (H1 : ∀ s ∈ c, x ∈ s)
(H2 : ∀ s ∈ c, IsPreconnected s) : IsPreconnected (⋃₀ c) := by
apply isPreconnected_of_forall x
rintro y ⟨s, sc, ys⟩
exact ⟨s, subset_sUnion_of_mem sc, H1 s sc, ys, H2 s sc⟩
#align is_preconnected_sUnion isPreconnected_sUnion
theorem isPreconnected_iUnion {ι : Sort*} {s : ι → Set α} (h₁ : (⋂ i, s i).Nonempty)
(h₂ : ∀ i, IsPreconnected (s i)) : IsPreconnected (⋃ i, s i) :=
Exists.elim h₁ fun f hf => isPreconnected_sUnion f _ hf (forall_mem_range.2 h₂)
#align is_preconnected_Union isPreconnected_iUnion
theorem IsPreconnected.union (x : α) {s t : Set α} (H1 : x ∈ s) (H2 : x ∈ t) (H3 : IsPreconnected s)
(H4 : IsPreconnected t) : IsPreconnected (s ∪ t) :=
sUnion_pair s t ▸ isPreconnected_sUnion x {s, t} (by rintro r (rfl | rfl | h) <;> assumption)
(by rintro r (rfl | rfl | h) <;> assumption)
#align is_preconnected.union IsPreconnected.union
theorem IsPreconnected.union' {s t : Set α} (H : (s ∩ t).Nonempty) (hs : IsPreconnected s)
(ht : IsPreconnected t) : IsPreconnected (s ∪ t) := by
rcases H with ⟨x, hxs, hxt⟩
exact hs.union x hxs hxt ht
#align is_preconnected.union' IsPreconnected.union'
theorem IsConnected.union {s t : Set α} (H : (s ∩ t).Nonempty) (Hs : IsConnected s)
(Ht : IsConnected t) : IsConnected (s ∪ t) := by
rcases H with ⟨x, hx⟩
refine ⟨⟨x, mem_union_left t (mem_of_mem_inter_left hx)⟩, ?_⟩
exact Hs.isPreconnected.union x (mem_of_mem_inter_left hx) (mem_of_mem_inter_right hx)
Ht.isPreconnected
#align is_connected.union IsConnected.union
theorem IsPreconnected.sUnion_directed {S : Set (Set α)} (K : DirectedOn (· ⊆ ·) S)
(H : ∀ s ∈ S, IsPreconnected s) : IsPreconnected (⋃₀ S) := by
rintro u v hu hv Huv ⟨a, ⟨s, hsS, has⟩, hau⟩ ⟨b, ⟨t, htS, hbt⟩, hbv⟩
obtain ⟨r, hrS, hsr, htr⟩ : ∃ r ∈ S, s ⊆ r ∧ t ⊆ r := K s hsS t htS
have Hnuv : (r ∩ (u ∩ v)).Nonempty :=
H _ hrS u v hu hv ((subset_sUnion_of_mem hrS).trans Huv) ⟨a, hsr has, hau⟩ ⟨b, htr hbt, hbv⟩
have Kruv : r ∩ (u ∩ v) ⊆ ⋃₀ S ∩ (u ∩ v) := inter_subset_inter_left _ (subset_sUnion_of_mem hrS)
exact Hnuv.mono Kruv
#align is_preconnected.sUnion_directed IsPreconnected.sUnion_directed
theorem IsPreconnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α}
(H : ∀ i ∈ t, IsPreconnected (s i))
(K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) :
IsPreconnected (⋃ n ∈ t, s n) := by
let R := fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t
have P : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen R i j →
∃ p, p ⊆ t ∧ i ∈ p ∧ j ∈ p ∧ IsPreconnected (⋃ j ∈ p, s j) := fun i hi j hj h => by
induction h with
| refl =>
refine ⟨{i}, singleton_subset_iff.mpr hi, mem_singleton i, mem_singleton i, ?_⟩
rw [biUnion_singleton]
exact H i hi
| @tail j k _ hjk ih =>
obtain ⟨p, hpt, hip, hjp, hp⟩ := ih hjk.2
refine ⟨insert k p, insert_subset_iff.mpr ⟨hj, hpt⟩, mem_insert_of_mem k hip,
mem_insert k p, ?_⟩
rw [biUnion_insert]
refine (H k hj).union' (hjk.1.mono ?_) hp
rw [inter_comm]
exact inter_subset_inter_right _ (subset_biUnion_of_mem hjp)
refine isPreconnected_of_forall_pair ?_
intro x hx y hy
obtain ⟨i : ι, hi : i ∈ t, hxi : x ∈ s i⟩ := mem_iUnion₂.1 hx
obtain ⟨j : ι, hj : j ∈ t, hyj : y ∈ s j⟩ := mem_iUnion₂.1 hy
obtain ⟨p, hpt, hip, hjp, hp⟩ := P i hi j hj (K i hi j hj)
exact ⟨⋃ j ∈ p, s j, biUnion_subset_biUnion_left hpt, mem_biUnion hip hxi,
mem_biUnion hjp hyj, hp⟩
#align is_preconnected.bUnion_of_refl_trans_gen IsPreconnected.biUnion_of_reflTransGen
theorem IsConnected.biUnion_of_reflTransGen {ι : Type*} {t : Set ι} {s : ι → Set α}
(ht : t.Nonempty) (H : ∀ i ∈ t, IsConnected (s i))
(K : ∀ i, i ∈ t → ∀ j, j ∈ t → ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty ∧ i ∈ t) i j) :
IsConnected (⋃ n ∈ t, s n) :=
⟨nonempty_biUnion.2 <| ⟨ht.some, ht.some_mem, (H _ ht.some_mem).nonempty⟩,
IsPreconnected.biUnion_of_reflTransGen (fun i hi => (H i hi).isPreconnected) K⟩
#align is_connected.bUnion_of_refl_trans_gen IsConnected.biUnion_of_reflTransGen
theorem IsPreconnected.iUnion_of_reflTransGen {ι : Type*} {s : ι → Set α}
(H : ∀ i, IsPreconnected (s i))
(K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) :
IsPreconnected (⋃ n, s n) := by
rw [← biUnion_univ]
exact IsPreconnected.biUnion_of_reflTransGen (fun i _ => H i) fun i _ j _ => by
simpa [mem_univ] using K i j
#align is_preconnected.Union_of_refl_trans_gen IsPreconnected.iUnion_of_reflTransGen
theorem IsConnected.iUnion_of_reflTransGen {ι : Type*} [Nonempty ι] {s : ι → Set α}
(H : ∀ i, IsConnected (s i))
(K : ∀ i j, ReflTransGen (fun i j : ι => (s i ∩ s j).Nonempty) i j) : IsConnected (⋃ n, s n) :=
⟨nonempty_iUnion.2 <| Nonempty.elim ‹_› fun i : ι => ⟨i, (H _).nonempty⟩,
IsPreconnected.iUnion_of_reflTransGen (fun i => (H i).isPreconnected) K⟩
#align is_connected.Union_of_refl_trans_gen IsConnected.iUnion_of_reflTransGen
protected theorem IsPreconnected.subset_closure {s : Set α} {t : Set α} (H : IsPreconnected s)
(Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsPreconnected t :=
fun u v hu hv htuv ⟨_y, hyt, hyu⟩ ⟨_z, hzt, hzv⟩ =>
let ⟨p, hpu, hps⟩ := mem_closure_iff.1 (Ktcs hyt) u hu hyu
let ⟨q, hqv, hqs⟩ := mem_closure_iff.1 (Ktcs hzt) v hv hzv
let ⟨r, hrs, hruv⟩ := H u v hu hv (Subset.trans Kst htuv) ⟨p, hps, hpu⟩ ⟨q, hqs, hqv⟩
⟨r, Kst hrs, hruv⟩
#align is_preconnected.subset_closure IsPreconnected.subset_closure
protected theorem IsConnected.subset_closure {s : Set α} {t : Set α} (H : IsConnected s)
(Kst : s ⊆ t) (Ktcs : t ⊆ closure s) : IsConnected t :=
⟨Nonempty.mono Kst H.left, IsPreconnected.subset_closure H.right Kst Ktcs⟩
#align is_connected.subset_closure IsConnected.subset_closure
protected theorem IsPreconnected.closure {s : Set α} (H : IsPreconnected s) :
IsPreconnected (closure s) :=
IsPreconnected.subset_closure H subset_closure Subset.rfl
#align is_preconnected.closure IsPreconnected.closure
protected theorem IsConnected.closure {s : Set α} (H : IsConnected s) : IsConnected (closure s) :=
IsConnected.subset_closure H subset_closure <| Subset.rfl
#align is_connected.closure IsConnected.closure
protected theorem IsPreconnected.image [TopologicalSpace β] {s : Set α} (H : IsPreconnected s)
(f : α → β) (hf : ContinuousOn f s) : IsPreconnected (f '' s) := by
-- Unfold/destruct definitions in hypotheses
rintro u v hu hv huv ⟨_, ⟨x, xs, rfl⟩, xu⟩ ⟨_, ⟨y, ys, rfl⟩, yv⟩
rcases continuousOn_iff'.1 hf u hu with ⟨u', hu', u'_eq⟩
rcases continuousOn_iff'.1 hf v hv with ⟨v', hv', v'_eq⟩
-- Reformulate `huv : f '' s ⊆ u ∪ v` in terms of `u'` and `v'`
replace huv : s ⊆ u' ∪ v' := by
rw [image_subset_iff, preimage_union] at huv
replace huv := subset_inter huv Subset.rfl
rw [union_inter_distrib_right, u'_eq, v'_eq, ← union_inter_distrib_right] at huv
exact (subset_inter_iff.1 huv).1
-- Now `s ⊆ u' ∪ v'`, so we can apply `‹IsPreconnected s›`
obtain ⟨z, hz⟩ : (s ∩ (u' ∩ v')).Nonempty := by
refine H u' v' hu' hv' huv ⟨x, ?_⟩ ⟨y, ?_⟩ <;> rw [inter_comm]
exacts [u'_eq ▸ ⟨xu, xs⟩, v'_eq ▸ ⟨yv, ys⟩]
rw [← inter_self s, inter_assoc, inter_left_comm s u', ← inter_assoc, inter_comm s, inter_comm s,
← u'_eq, ← v'_eq] at hz
exact ⟨f z, ⟨z, hz.1.2, rfl⟩, hz.1.1, hz.2.1⟩
#align is_preconnected.image IsPreconnected.image
protected theorem IsConnected.image [TopologicalSpace β] {s : Set α} (H : IsConnected s) (f : α → β)
(hf : ContinuousOn f s) : IsConnected (f '' s) :=
⟨image_nonempty.mpr H.nonempty, H.isPreconnected.image f hf⟩
#align is_connected.image IsConnected.image
theorem isPreconnected_closed_iff {s : Set α} :
IsPreconnected s ↔ ∀ t t', IsClosed t → IsClosed t' →
s ⊆ t ∪ t' → (s ∩ t).Nonempty → (s ∩ t').Nonempty → (s ∩ (t ∩ t')).Nonempty :=
⟨by
rintro h t t' ht ht' htt' ⟨x, xs, xt⟩ ⟨y, ys, yt'⟩
rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter]
intro h'
have xt' : x ∉ t' := (h' xs).resolve_left (absurd xt)
have yt : y ∉ t := (h' ys).resolve_right (absurd yt')
have := h _ _ ht.isOpen_compl ht'.isOpen_compl h' ⟨y, ys, yt⟩ ⟨x, xs, xt'⟩
rw [← compl_union] at this
exact this.ne_empty htt'.disjoint_compl_right.inter_eq,
by
rintro h u v hu hv huv ⟨x, xs, xu⟩ ⟨y, ys, yv⟩
rw [← not_disjoint_iff_nonempty_inter, ← subset_compl_iff_disjoint_right, compl_inter]
intro h'
have xv : x ∉ v := (h' xs).elim (absurd xu) id
have yu : y ∉ u := (h' ys).elim id (absurd yv)
have := h _ _ hu.isClosed_compl hv.isClosed_compl h' ⟨y, ys, yu⟩ ⟨x, xs, xv⟩
rw [← compl_union] at this
exact this.ne_empty huv.disjoint_compl_right.inter_eq⟩
#align is_preconnected_closed_iff isPreconnected_closed_iff
theorem Inducing.isPreconnected_image [TopologicalSpace β] {s : Set α} {f : α → β}
(hf : Inducing f) : IsPreconnected (f '' s) ↔ IsPreconnected s := by
refine ⟨fun h => ?_, fun h => h.image _ hf.continuous.continuousOn⟩
rintro u v hu' hv' huv ⟨x, hxs, hxu⟩ ⟨y, hys, hyv⟩
rcases hf.isOpen_iff.1 hu' with ⟨u, hu, rfl⟩
rcases hf.isOpen_iff.1 hv' with ⟨v, hv, rfl⟩
replace huv : f '' s ⊆ u ∪ v := by rwa [image_subset_iff]
rcases h u v hu hv huv ⟨f x, mem_image_of_mem _ hxs, hxu⟩ ⟨f y, mem_image_of_mem _ hys, hyv⟩ with
⟨_, ⟨z, hzs, rfl⟩, hzuv⟩
exact ⟨z, hzs, hzuv⟩
#align inducing.is_preconnected_image Inducing.isPreconnected_image
theorem IsPreconnected.preimage_of_isOpenMap [TopologicalSpace β] {f : α → β} {s : Set β}
(hs : IsPreconnected s) (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) :
IsPreconnected (f ⁻¹' s) := fun u v hu hv hsuv hsu hsv => by
replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf
obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by
refine hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_
· simpa only [hsf, image_union] using image_subset f hsuv
· simpa only [image_preimage_inter] using hsu.image f
· simpa only [image_preimage_inter] using hsv.image f
· exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩
#align is_preconnected.preimage_of_open_map IsPreconnected.preimage_of_isOpenMap
theorem IsPreconnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β}
(hs : IsPreconnected s) {f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f)
(hsf : s ⊆ range f) : IsPreconnected (f ⁻¹' s) :=
isPreconnected_closed_iff.2 fun u v hu hv hsuv hsu hsv => by
replace hsf : f '' (f ⁻¹' s) = s := image_preimage_eq_of_subset hsf
obtain ⟨_, has, ⟨a, hau, rfl⟩, hav⟩ : (s ∩ (f '' u ∩ f '' v)).Nonempty := by
refine isPreconnected_closed_iff.1 hs (f '' u) (f '' v) (hf u hu) (hf v hv) ?_ ?_ ?_
· simpa only [hsf, image_union] using image_subset f hsuv
· simpa only [image_preimage_inter] using hsu.image f
· simpa only [image_preimage_inter] using hsv.image f
· exact ⟨a, has, hau, hinj.mem_set_image.1 hav⟩
#align is_preconnected.preimage_of_closed_map IsPreconnected.preimage_of_isClosedMap
theorem IsConnected.preimage_of_isOpenMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s)
{f : α → β} (hinj : Function.Injective f) (hf : IsOpenMap f) (hsf : s ⊆ range f) :
IsConnected (f ⁻¹' s) :=
⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isOpenMap hinj hf hsf⟩
#align is_connected.preimage_of_open_map IsConnected.preimage_of_isOpenMap
theorem IsConnected.preimage_of_isClosedMap [TopologicalSpace β] {s : Set β} (hs : IsConnected s)
{f : α → β} (hinj : Function.Injective f) (hf : IsClosedMap f) (hsf : s ⊆ range f) :
IsConnected (f ⁻¹' s) :=
⟨hs.nonempty.preimage' hsf, hs.isPreconnected.preimage_of_isClosedMap hinj hf hsf⟩
#align is_connected.preimage_of_closed_map IsConnected.preimage_of_isClosedMap
theorem IsPreconnected.subset_or_subset (hu : IsOpen u) (hv : IsOpen v) (huv : Disjoint u v)
(hsuv : s ⊆ u ∪ v) (hs : IsPreconnected s) : s ⊆ u ∨ s ⊆ v := by
specialize hs u v hu hv hsuv
obtain hsu | hsu := (s ∩ u).eq_empty_or_nonempty
· exact Or.inr ((Set.disjoint_iff_inter_eq_empty.2 hsu).subset_right_of_subset_union hsuv)
· replace hs := mt (hs hsu)
simp_rw [Set.not_nonempty_iff_eq_empty, ← Set.disjoint_iff_inter_eq_empty,
disjoint_iff_inter_eq_empty.1 huv] at hs
exact Or.inl ((hs s.disjoint_empty).subset_left_of_subset_union hsuv)
#align is_preconnected.subset_or_subset IsPreconnected.subset_or_subset
theorem IsPreconnected.subset_left_of_subset_union (hu : IsOpen u) (hv : IsOpen v)
(huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsu : (s ∩ u).Nonempty) (hs : IsPreconnected s) :
s ⊆ u :=
Disjoint.subset_left_of_subset_union hsuv
(by
by_contra hsv
rw [not_disjoint_iff_nonempty_inter] at hsv
obtain ⟨x, _, hx⟩ := hs u v hu hv hsuv hsu hsv
exact Set.disjoint_iff.1 huv hx)
#align is_preconnected.subset_left_of_subset_union IsPreconnected.subset_left_of_subset_union
theorem IsPreconnected.subset_right_of_subset_union (hu : IsOpen u) (hv : IsOpen v)
(huv : Disjoint u v) (hsuv : s ⊆ u ∪ v) (hsv : (s ∩ v).Nonempty) (hs : IsPreconnected s) :
s ⊆ v :=
hs.subset_left_of_subset_union hv hu huv.symm (union_comm u v ▸ hsuv) hsv
#align is_preconnected.subset_right_of_subset_union IsPreconnected.subset_right_of_subset_union
-- Porting note: moved up
theorem IsPreconnected.subset_isClopen {s t : Set α} (hs : IsPreconnected s) (ht : IsClopen t)
(hne : (s ∩ t).Nonempty) : s ⊆ t :=
hs.subset_left_of_subset_union ht.isOpen ht.compl.isOpen disjoint_compl_right (by simp) hne
#align is_preconnected.subset_clopen IsPreconnected.subset_isClopen
| Mathlib/Topology/Connected/Basic.lean | 450 | 460 | theorem IsPreconnected.subset_of_closure_inter_subset (hs : IsPreconnected s) (hu : IsOpen u)
(h'u : (s ∩ u).Nonempty) (h : closure u ∩ s ⊆ u) : s ⊆ u := by |
have A : s ⊆ u ∪ (closure u)ᶜ := by
intro x hx
by_cases xu : x ∈ u
· exact Or.inl xu
· right
intro h'x
exact xu (h (mem_inter h'x hx))
apply hs.subset_left_of_subset_union hu isClosed_closure.isOpen_compl _ A h'u
exact disjoint_compl_right.mono_right (compl_subset_compl.2 subset_closure)
|
import Mathlib.MeasureTheory.Constructions.Prod.Basic
import Mathlib.MeasureTheory.Integral.DominatedConvergence
import Mathlib.MeasureTheory.Integral.SetIntegral
#align_import measure_theory.constructions.prod.integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
noncomputable section
open scoped Classical Topology ENNReal MeasureTheory
open Set Function Real ENNReal
open MeasureTheory MeasurableSpace MeasureTheory.Measure
open TopologicalSpace
open Filter hiding prod_eq map
variable {α α' β β' γ E : Type*}
variable [MeasurableSpace α] [MeasurableSpace α'] [MeasurableSpace β] [MeasurableSpace β']
variable [MeasurableSpace γ]
variable {μ μ' : Measure α} {ν ν' : Measure β} {τ : Measure γ}
variable [NormedAddCommGroup E]
theorem measurableSet_integrable [SigmaFinite ν] ⦃f : α → β → E⦄
(hf : StronglyMeasurable (uncurry f)) : MeasurableSet {x | Integrable (f x) ν} := by
simp_rw [Integrable, hf.of_uncurry_left.aestronglyMeasurable, true_and_iff]
exact measurableSet_lt (Measurable.lintegral_prod_right hf.ennnorm) measurable_const
#align measurable_set_integrable measurableSet_integrable
section
variable [NormedSpace ℝ E]
theorem MeasureTheory.StronglyMeasurable.integral_prod_right [SigmaFinite ν] ⦃f : α → β → E⦄
(hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun x => ∫ y, f x y ∂ν := by
by_cases hE : CompleteSpace E; swap; · simp [integral, hE, stronglyMeasurable_const]
borelize E
haveI : SeparableSpace (range (uncurry f) ∪ {0} : Set E) :=
hf.separableSpace_range_union_singleton
let s : ℕ → SimpleFunc (α × β) E :=
SimpleFunc.approxOn _ hf.measurable (range (uncurry f) ∪ {0}) 0 (by simp)
let s' : ℕ → α → SimpleFunc β E := fun n x => (s n).comp (Prod.mk x) measurable_prod_mk_left
let f' : ℕ → α → E := fun n => {x | Integrable (f x) ν}.indicator fun x => (s' n x).integral ν
have hf' : ∀ n, StronglyMeasurable (f' n) := by
intro n; refine StronglyMeasurable.indicator ?_ (measurableSet_integrable hf)
have : ∀ x, ((s' n x).range.filter fun x => x ≠ 0) ⊆ (s n).range := by
intro x; refine Finset.Subset.trans (Finset.filter_subset _ _) ?_; intro y
simp_rw [SimpleFunc.mem_range]; rintro ⟨z, rfl⟩; exact ⟨(x, z), rfl⟩
simp only [SimpleFunc.integral_eq_sum_of_subset (this _)]
refine Finset.stronglyMeasurable_sum _ fun x _ => ?_
refine (Measurable.ennreal_toReal ?_).stronglyMeasurable.smul_const _
simp only [s', SimpleFunc.coe_comp, preimage_comp]
apply measurable_measure_prod_mk_left
exact (s n).measurableSet_fiber x
have h2f' : Tendsto f' atTop (𝓝 fun x : α => ∫ y : β, f x y ∂ν) := by
rw [tendsto_pi_nhds]; intro x
by_cases hfx : Integrable (f x) ν
· have (n) : Integrable (s' n x) ν := by
apply (hfx.norm.add hfx.norm).mono' (s' n x).aestronglyMeasurable
filter_upwards with y
simp_rw [s', SimpleFunc.coe_comp]; exact SimpleFunc.norm_approxOn_zero_le _ _ (x, y) n
simp only [f', hfx, SimpleFunc.integral_eq_integral _ (this _), indicator_of_mem,
mem_setOf_eq]
refine
tendsto_integral_of_dominated_convergence (fun y => ‖f x y‖ + ‖f x y‖)
(fun n => (s' n x).aestronglyMeasurable) (hfx.norm.add hfx.norm) ?_ ?_
· refine fun n => eventually_of_forall fun y =>
SimpleFunc.norm_approxOn_zero_le ?_ ?_ (x, y) n
-- Porting note: Lean 3 solved the following two subgoals on its own
· exact hf.measurable
· simp
· refine eventually_of_forall fun y => SimpleFunc.tendsto_approxOn ?_ ?_ ?_
-- Porting note: Lean 3 solved the following two subgoals on its own
· exact hf.measurable.of_uncurry_left
· simp
apply subset_closure
simp [-uncurry_apply_pair]
· simp [f', hfx, integral_undef]
exact stronglyMeasurable_of_tendsto _ hf' h2f'
#align measure_theory.strongly_measurable.integral_prod_right MeasureTheory.StronglyMeasurable.integral_prod_right
theorem MeasureTheory.StronglyMeasurable.integral_prod_right' [SigmaFinite ν] ⦃f : α × β → E⦄
(hf : StronglyMeasurable f) : StronglyMeasurable fun x => ∫ y, f (x, y) ∂ν := by
rw [← uncurry_curry f] at hf; exact hf.integral_prod_right
#align measure_theory.strongly_measurable.integral_prod_right' MeasureTheory.StronglyMeasurable.integral_prod_right'
theorem MeasureTheory.StronglyMeasurable.integral_prod_left [SigmaFinite μ] ⦃f : α → β → E⦄
(hf : StronglyMeasurable (uncurry f)) : StronglyMeasurable fun y => ∫ x, f x y ∂μ :=
(hf.comp_measurable measurable_swap).integral_prod_right'
#align measure_theory.strongly_measurable.integral_prod_left MeasureTheory.StronglyMeasurable.integral_prod_left
theorem MeasureTheory.StronglyMeasurable.integral_prod_left' [SigmaFinite μ] ⦃f : α × β → E⦄
(hf : StronglyMeasurable f) : StronglyMeasurable fun y => ∫ x, f (x, y) ∂μ :=
(hf.comp_measurable measurable_swap).integral_prod_right'
#align measure_theory.strongly_measurable.integral_prod_left' MeasureTheory.StronglyMeasurable.integral_prod_left'
end
open MeasureTheory.Measure
section
nonrec theorem MeasureTheory.AEStronglyMeasurable.prod_swap {γ : Type*} [TopologicalSpace γ]
[SigmaFinite μ] [SigmaFinite ν] {f : β × α → γ} (hf : AEStronglyMeasurable f (ν.prod μ)) :
AEStronglyMeasurable (fun z : α × β => f z.swap) (μ.prod ν) := by
rw [← prod_swap] at hf
exact hf.comp_measurable measurable_swap
#align measure_theory.ae_strongly_measurable.prod_swap MeasureTheory.AEStronglyMeasurable.prod_swap
theorem MeasureTheory.AEStronglyMeasurable.fst {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : α → γ}
(hf : AEStronglyMeasurable f μ) : AEStronglyMeasurable (fun z : α × β => f z.1) (μ.prod ν) :=
hf.comp_quasiMeasurePreserving quasiMeasurePreserving_fst
#align measure_theory.ae_strongly_measurable.fst MeasureTheory.AEStronglyMeasurable.fst
theorem MeasureTheory.AEStronglyMeasurable.snd {γ} [TopologicalSpace γ] [SigmaFinite ν] {f : β → γ}
(hf : AEStronglyMeasurable f ν) : AEStronglyMeasurable (fun z : α × β => f z.2) (μ.prod ν) :=
hf.comp_quasiMeasurePreserving quasiMeasurePreserving_snd
#align measure_theory.ae_strongly_measurable.snd MeasureTheory.AEStronglyMeasurable.snd
theorem MeasureTheory.AEStronglyMeasurable.integral_prod_right' [SigmaFinite ν] [NormedSpace ℝ E]
⦃f : α × β → E⦄ (hf : AEStronglyMeasurable f (μ.prod ν)) :
AEStronglyMeasurable (fun x => ∫ y, f (x, y) ∂ν) μ :=
⟨fun x => ∫ y, hf.mk f (x, y) ∂ν, hf.stronglyMeasurable_mk.integral_prod_right', by
filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with _ hx using integral_congr_ae hx⟩
#align measure_theory.ae_strongly_measurable.integral_prod_right' MeasureTheory.AEStronglyMeasurable.integral_prod_right'
theorem MeasureTheory.AEStronglyMeasurable.prod_mk_left {γ : Type*} [SigmaFinite ν]
[TopologicalSpace γ] {f : α × β → γ} (hf : AEStronglyMeasurable f (μ.prod ν)) :
∀ᵐ x ∂μ, AEStronglyMeasurable (fun y => f (x, y)) ν := by
filter_upwards [ae_ae_of_ae_prod hf.ae_eq_mk] with x hx
exact
⟨fun y => hf.mk f (x, y), hf.stronglyMeasurable_mk.comp_measurable measurable_prod_mk_left, hx⟩
#align measure_theory.ae_strongly_measurable.prod_mk_left MeasureTheory.AEStronglyMeasurable.prod_mk_left
end
namespace MeasureTheory
variable [SigmaFinite ν]
section
theorem integrable_swap_iff [SigmaFinite μ] {f : α × β → E} :
Integrable (f ∘ Prod.swap) (ν.prod μ) ↔ Integrable f (μ.prod ν) :=
measurePreserving_swap.integrable_comp_emb MeasurableEquiv.prodComm.measurableEmbedding
#align measure_theory.integrable_swap_iff MeasureTheory.integrable_swap_iff
theorem Integrable.swap [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) :
Integrable (f ∘ Prod.swap) (ν.prod μ) :=
integrable_swap_iff.2 hf
#align measure_theory.integrable.swap MeasureTheory.Integrable.swap
theorem hasFiniteIntegral_prod_iff ⦃f : α × β → E⦄ (h1f : StronglyMeasurable f) :
HasFiniteIntegral f (μ.prod ν) ↔
(∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧
HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by
simp only [HasFiniteIntegral, lintegral_prod_of_measurable _ h1f.ennnorm]
have (x) : ∀ᵐ y ∂ν, 0 ≤ ‖f (x, y)‖ := by filter_upwards with y using norm_nonneg _
simp_rw [integral_eq_lintegral_of_nonneg_ae (this _)
(h1f.norm.comp_measurable measurable_prod_mk_left).aestronglyMeasurable,
ennnorm_eq_ofReal toReal_nonneg, ofReal_norm_eq_coe_nnnorm]
-- this fact is probably too specialized to be its own lemma
have : ∀ {p q r : Prop} (_ : r → p), (r ↔ p ∧ q) ↔ p → (r ↔ q) := fun {p q r} h1 => by
rw [← and_congr_right_iff, and_iff_right_of_imp h1]
rw [this]
· intro h2f; rw [lintegral_congr_ae]
filter_upwards [h2f] with x hx
rw [ofReal_toReal]; rw [← lt_top_iff_ne_top]; exact hx
· intro h2f; refine ae_lt_top ?_ h2f.ne; exact h1f.ennnorm.lintegral_prod_right'
#align measure_theory.has_finite_integral_prod_iff MeasureTheory.hasFiniteIntegral_prod_iff
theorem hasFiniteIntegral_prod_iff' ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) :
HasFiniteIntegral f (μ.prod ν) ↔
(∀ᵐ x ∂μ, HasFiniteIntegral (fun y => f (x, y)) ν) ∧
HasFiniteIntegral (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by
rw [hasFiniteIntegral_congr h1f.ae_eq_mk,
hasFiniteIntegral_prod_iff h1f.stronglyMeasurable_mk]
apply and_congr
· apply eventually_congr
filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm]
intro x hx
exact hasFiniteIntegral_congr hx
· apply hasFiniteIntegral_congr
filter_upwards [ae_ae_of_ae_prod h1f.ae_eq_mk.symm] with _ hx using
integral_congr_ae (EventuallyEq.fun_comp hx _)
#align measure_theory.has_finite_integral_prod_iff' MeasureTheory.hasFiniteIntegral_prod_iff'
theorem integrable_prod_iff ⦃f : α × β → E⦄ (h1f : AEStronglyMeasurable f (μ.prod ν)) :
Integrable f (μ.prod ν) ↔
(∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν) ∧ Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ := by
simp [Integrable, h1f, hasFiniteIntegral_prod_iff', h1f.norm.integral_prod_right',
h1f.prod_mk_left]
#align measure_theory.integrable_prod_iff MeasureTheory.integrable_prod_iff
theorem integrable_prod_iff' [SigmaFinite μ] ⦃f : α × β → E⦄
(h1f : AEStronglyMeasurable f (μ.prod ν)) :
Integrable f (μ.prod ν) ↔
(∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ) ∧ Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν := by
convert integrable_prod_iff h1f.prod_swap using 1
rw [funext fun _ => Function.comp_apply.symm, integrable_swap_iff]
#align measure_theory.integrable_prod_iff' MeasureTheory.integrable_prod_iff'
theorem Integrable.prod_left_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) :
∀ᵐ y ∂ν, Integrable (fun x => f (x, y)) μ :=
((integrable_prod_iff' hf.aestronglyMeasurable).mp hf).1
#align measure_theory.integrable.prod_left_ae MeasureTheory.Integrable.prod_left_ae
theorem Integrable.prod_right_ae [SigmaFinite μ] ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) :
∀ᵐ x ∂μ, Integrable (fun y => f (x, y)) ν :=
hf.swap.prod_left_ae
#align measure_theory.integrable.prod_right_ae MeasureTheory.Integrable.prod_right_ae
theorem Integrable.integral_norm_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) :
Integrable (fun x => ∫ y, ‖f (x, y)‖ ∂ν) μ :=
((integrable_prod_iff hf.aestronglyMeasurable).mp hf).2
#align measure_theory.integrable.integral_norm_prod_left MeasureTheory.Integrable.integral_norm_prod_left
theorem Integrable.integral_norm_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄
(hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, ‖f (x, y)‖ ∂μ) ν :=
hf.swap.integral_norm_prod_left
#align measure_theory.integrable.integral_norm_prod_right MeasureTheory.Integrable.integral_norm_prod_right
theorem Integrable.prod_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
{f : α → 𝕜} {g : β → E} (hf : Integrable f μ) (hg : Integrable g ν) :
Integrable (fun z : α × β => f z.1 • g z.2) (μ.prod ν) := by
refine (integrable_prod_iff ?_).2 ⟨?_, ?_⟩
· exact hf.1.fst.smul hg.1.snd
· exact eventually_of_forall fun x => hg.smul (f x)
· simpa only [norm_smul, integral_mul_left] using hf.norm.mul_const _
theorem Integrable.prod_mul {L : Type*} [RCLike L] {f : α → L} {g : β → L} (hf : Integrable f μ)
(hg : Integrable g ν) : Integrable (fun z : α × β => f z.1 * g z.2) (μ.prod ν) :=
hf.prod_smul hg
#align measure_theory.integrable_prod_mul MeasureTheory.Integrable.prod_mul
end
variable [NormedSpace ℝ E]
theorem Integrable.integral_prod_left ⦃f : α × β → E⦄ (hf : Integrable f (μ.prod ν)) :
Integrable (fun x => ∫ y, f (x, y) ∂ν) μ :=
Integrable.mono hf.integral_norm_prod_left hf.aestronglyMeasurable.integral_prod_right' <|
eventually_of_forall fun x =>
(norm_integral_le_integral_norm _).trans_eq <|
(norm_of_nonneg <|
integral_nonneg_of_ae <|
eventually_of_forall fun y => (norm_nonneg (f (x, y)) : _)).symm
#align measure_theory.integrable.integral_prod_left MeasureTheory.Integrable.integral_prod_left
theorem Integrable.integral_prod_right [SigmaFinite μ] ⦃f : α × β → E⦄
(hf : Integrable f (μ.prod ν)) : Integrable (fun y => ∫ x, f (x, y) ∂μ) ν :=
hf.swap.integral_prod_left
#align measure_theory.integrable.integral_prod_right MeasureTheory.Integrable.integral_prod_right
variable [SigmaFinite μ]
theorem integral_prod_swap (f : α × β → E) :
∫ z, f z.swap ∂ν.prod μ = ∫ z, f z ∂μ.prod ν :=
measurePreserving_swap.integral_comp MeasurableEquiv.prodComm.measurableEmbedding _
#align measure_theory.integral_prod_swap MeasureTheory.integral_prod_swap
variable {E' : Type*} [NormedAddCommGroup E'] [NormedSpace ℝ E']
theorem integral_fn_integral_add ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν))
(hg : Integrable g (μ.prod ν)) :
(∫ x, F (∫ y, f (x, y) + g (x, y) ∂ν) ∂μ) =
∫ x, F ((∫ y, f (x, y) ∂ν) + ∫ y, g (x, y) ∂ν) ∂μ := by
refine integral_congr_ae ?_
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g
simp [integral_add h2f h2g]
#align measure_theory.integral_fn_integral_add MeasureTheory.integral_fn_integral_add
theorem integral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → E') (hf : Integrable f (μ.prod ν))
(hg : Integrable g (μ.prod ν)) :
(∫ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) =
∫ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by
refine integral_congr_ae ?_
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g
simp [integral_sub h2f h2g]
#align measure_theory.integral_fn_integral_sub MeasureTheory.integral_fn_integral_sub
| Mathlib/MeasureTheory/Constructions/Prod/Integral.lean | 378 | 384 | theorem lintegral_fn_integral_sub ⦃f g : α × β → E⦄ (F : E → ℝ≥0∞) (hf : Integrable f (μ.prod ν))
(hg : Integrable g (μ.prod ν)) :
(∫⁻ x, F (∫ y, f (x, y) - g (x, y) ∂ν) ∂μ) =
∫⁻ x, F ((∫ y, f (x, y) ∂ν) - ∫ y, g (x, y) ∂ν) ∂μ := by |
refine lintegral_congr_ae ?_
filter_upwards [hf.prod_right_ae, hg.prod_right_ae] with _ h2f h2g
simp [integral_sub h2f h2g]
|
import Mathlib.LinearAlgebra.FiniteDimensional
import Mathlib.LinearAlgebra.FreeModule.Finite.Basic
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.LinearAlgebra.Projection
import Mathlib.LinearAlgebra.SesquilinearForm
import Mathlib.RingTheory.TensorProduct.Basic
import Mathlib.RingTheory.Ideal.LocalRing
#align_import linear_algebra.dual from "leanprover-community/mathlib"@"b1c017582e9f18d8494e5c18602a8cb4a6f843ac"
noncomputable section
namespace Module
-- Porting note: max u v universe issues so name and specific below
universe uR uA uM uM' uM''
variable (R : Type uR) (A : Type uA) (M : Type uM)
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
abbrev Dual :=
M →ₗ[R] R
#align module.dual Module.Dual
def dualPairing (R M) [CommSemiring R] [AddCommMonoid M] [Module R M] :
Module.Dual R M →ₗ[R] M →ₗ[R] R :=
LinearMap.id
#align module.dual_pairing Module.dualPairing
@[simp]
theorem dualPairing_apply (v x) : dualPairing R M v x = v x :=
rfl
#align module.dual_pairing_apply Module.dualPairing_apply
namespace Dual
instance : Inhabited (Dual R M) := ⟨0⟩
def eval : M →ₗ[R] Dual R (Dual R M) :=
LinearMap.flip LinearMap.id
#align module.dual.eval Module.Dual.eval
@[simp]
theorem eval_apply (v : M) (a : Dual R M) : eval R M v a = a v :=
rfl
#align module.dual.eval_apply Module.Dual.eval_apply
variable {R M} {M' : Type uM'}
variable [AddCommMonoid M'] [Module R M']
def transpose : (M →ₗ[R] M') →ₗ[R] Dual R M' →ₗ[R] Dual R M :=
(LinearMap.llcomp R M M' R).flip
#align module.dual.transpose Module.Dual.transpose
-- Porting note: with reducible def need to specify some parameters to transpose explicitly
theorem transpose_apply (u : M →ₗ[R] M') (l : Dual R M') : transpose (R := R) u l = l.comp u :=
rfl
#align module.dual.transpose_apply Module.Dual.transpose_apply
variable {M'' : Type uM''} [AddCommMonoid M''] [Module R M'']
-- Porting note: with reducible def need to specify some parameters to transpose explicitly
theorem transpose_comp (u : M' →ₗ[R] M'') (v : M →ₗ[R] M') :
transpose (R := R) (u.comp v) = (transpose (R := R) v).comp (transpose (R := R) u) :=
rfl
#align module.dual.transpose_comp Module.Dual.transpose_comp
end Dual
section Prod
variable (M' : Type uM') [AddCommMonoid M'] [Module R M']
@[simps!]
def dualProdDualEquivDual : (Module.Dual R M × Module.Dual R M') ≃ₗ[R] Module.Dual R (M × M') :=
LinearMap.coprodEquiv R
#align module.dual_prod_dual_equiv_dual Module.dualProdDualEquivDual
@[simp]
theorem dualProdDualEquivDual_apply (φ : Module.Dual R M) (ψ : Module.Dual R M') :
dualProdDualEquivDual R M M' (φ, ψ) = φ.coprod ψ :=
rfl
#align module.dual_prod_dual_equiv_dual_apply Module.dualProdDualEquivDual_apply
end Prod
end Module
namespace Basis
universe u v w
open Module Module.Dual Submodule LinearMap Cardinal Function
universe uR uM uK uV uι
variable {R : Type uR} {M : Type uM} {K : Type uK} {V : Type uV} {ι : Type uι}
section
variable [CommSemiring R] [AddCommMonoid M] [Module R M] [Fintype ι]
variable (b : Basis ι R M)
@[simp]
theorem sum_dual_apply_smul_coord (f : Module.Dual R M) :
(∑ x, f (b x) • b.coord x) = f := by
ext m
simp_rw [LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul, mul_comm (f _), ← smul_eq_mul, ←
f.map_smul, ← _root_.map_sum, Basis.coord_apply, Basis.sum_repr]
#align basis.sum_dual_apply_smul_coord Basis.sum_dual_apply_smul_coord
end
section CommRing
variable [CommRing R] [AddCommGroup M] [Module R M] [DecidableEq ι]
variable (b : Basis ι R M)
namespace Module
universe uK uV
variable {K : Type uK} {V : Type uV}
variable [CommRing K] [AddCommGroup V] [Module K V] [Module.Free K V]
open Module Module.Dual Submodule LinearMap Cardinal Basis FiniteDimensional
section
variable (K) (V)
-- Porting note (#11036): broken dot notation lean4#1910 LinearMap.ker
theorem eval_ker : LinearMap.ker (eval K V) = ⊥ := by
classical exact (Module.Free.chooseBasis K V).eval_ker
#align module.eval_ker Module.eval_ker
theorem map_eval_injective : (Submodule.map (eval K V)).Injective := by
apply Submodule.map_injective_of_injective
rw [← LinearMap.ker_eq_bot]
exact eval_ker K V
#align module.map_eval_injective Module.map_eval_injective
theorem comap_eval_surjective : (Submodule.comap (eval K V)).Surjective := by
apply Submodule.comap_surjective_of_injective
rw [← LinearMap.ker_eq_bot]
exact eval_ker K V
#align module.comap_eval_surjective Module.comap_eval_surjective
end
section
variable (K)
theorem eval_apply_eq_zero_iff (v : V) : (eval K V) v = 0 ↔ v = 0 := by
simpa only using SetLike.ext_iff.mp (eval_ker K V) v
#align module.eval_apply_eq_zero_iff Module.eval_apply_eq_zero_iff
theorem eval_apply_injective : Function.Injective (eval K V) :=
(injective_iff_map_eq_zero' (eval K V)).mpr (eval_apply_eq_zero_iff K)
#align module.eval_apply_injective Module.eval_apply_injective
theorem forall_dual_apply_eq_zero_iff (v : V) : (∀ φ : Module.Dual K V, φ v = 0) ↔ v = 0 := by
rw [← eval_apply_eq_zero_iff K v, LinearMap.ext_iff]
rfl
#align module.forall_dual_apply_eq_zero_iff Module.forall_dual_apply_eq_zero_iff
@[simp]
theorem subsingleton_dual_iff :
Subsingleton (Dual K V) ↔ Subsingleton V := by
refine ⟨fun h ↦ ⟨fun v w ↦ ?_⟩, fun h ↦ ⟨fun f g ↦ ?_⟩⟩
· rw [← sub_eq_zero, ← forall_dual_apply_eq_zero_iff K (v - w)]
intros f
simp [Subsingleton.elim f 0]
· ext v
simp [Subsingleton.elim v 0]
instance instSubsingletonDual [Subsingleton V] : Subsingleton (Dual K V) :=
(subsingleton_dual_iff K).mp inferInstance
@[simp]
theorem nontrivial_dual_iff :
Nontrivial (Dual K V) ↔ Nontrivial V := by
rw [← not_iff_not, not_nontrivial_iff_subsingleton, not_nontrivial_iff_subsingleton,
subsingleton_dual_iff]
instance instNontrivialDual [Nontrivial V] : Nontrivial (Dual K V) :=
(nontrivial_dual_iff K).mpr inferInstance
theorem finite_dual_iff : Finite K (Dual K V) ↔ Finite K V := by
constructor <;> intro h
· obtain ⟨⟨ι, b⟩⟩ := Module.Free.exists_basis (R := K) (M := V)
nontriviality K
obtain ⟨⟨s, span_s⟩⟩ := h
classical
haveI := (b.linearIndependent.map' _ b.toDual_ker).finite_of_le_span_finite _ s ?_
· exact Finite.of_basis b
· rw [span_s]; apply le_top
· infer_instance
end
theorem dual_rank_eq [Module.Finite K V] :
Cardinal.lift.{uK,uV} (Module.rank K V) = Module.rank K (Dual K V) :=
(Module.Free.chooseBasis K V).dual_rank_eq
#align module.dual_rank_eq Module.dual_rank_eq
-- Porting note (#11036): broken dot notation lean4#1910 LinearMap.range
theorem erange_coe [Module.Finite K V] : LinearMap.range (eval K V) = ⊤ :=
(Module.Free.chooseBasis K V).eval_range
#align module.erange_coe Module.erange_coe
open Module
namespace TensorProduct
variable (R A : Type*) (M : Type*) (N : Type*)
variable {ι κ : Type*}
variable [DecidableEq ι] [DecidableEq κ]
variable [Fintype ι] [Fintype κ]
open TensorProduct
attribute [local ext] TensorProduct.ext
open TensorProduct
open LinearMap
section
variable [CommSemiring R] [AddCommMonoid M] [AddCommMonoid N]
variable [Module R M] [Module R N]
def dualDistrib : Dual R M ⊗[R] Dual R N →ₗ[R] Dual R (M ⊗[R] N) :=
compRight ↑(TensorProduct.lid R R) ∘ₗ homTensorHomMap R M N R R
#align tensor_product.dual_distrib TensorProduct.dualDistrib
variable {R M N}
@[simp]
theorem dualDistrib_apply (f : Dual R M) (g : Dual R N) (m : M) (n : N) :
dualDistrib R M N (f ⊗ₜ g) (m ⊗ₜ n) = f m * g n :=
rfl
#align tensor_product.dual_distrib_apply TensorProduct.dualDistrib_apply
end
variable {R M N}
variable [CommRing R] [AddCommGroup M] [AddCommGroup N]
variable [Module R M] [Module R N]
noncomputable def dualDistribInvOfBasis (b : Basis ι R M) (c : Basis κ R N) :
Dual R (M ⊗[R] N) →ₗ[R] Dual R M ⊗[R] Dual R N :=
-- Porting note: ∑ (i) (j) does not seem to work; applyₗ needs a little help to unify
∑ i, ∑ j,
(ringLmapEquivSelf R ℕ _).symm (b.dualBasis i ⊗ₜ c.dualBasis j) ∘ₗ
(applyₗ (R := R) (c j)) ∘ₗ (applyₗ (R := R) (b i)) ∘ₗ lcurry R M N R
#align tensor_product.dual_distrib_inv_of_basis TensorProduct.dualDistribInvOfBasis
@[simp]
theorem dualDistribInvOfBasis_apply (b : Basis ι R M) (c : Basis κ R N) (f : Dual R (M ⊗[R] N)) :
dualDistribInvOfBasis b c f = ∑ i, ∑ j, f (b i ⊗ₜ c j) • b.dualBasis i ⊗ₜ c.dualBasis j := by
simp [dualDistribInvOfBasis]
#align tensor_product.dual_distrib_inv_of_basis_apply TensorProduct.dualDistribInvOfBasis_apply
-- Porting note: introduced to help with timeout in dualDistribEquivOfBasis
theorem dualDistrib_dualDistribInvOfBasis_left_inverse (b : Basis ι R M) (c : Basis κ R N) :
comp (dualDistrib R M N) (dualDistribInvOfBasis b c) = LinearMap.id := by
apply (b.tensorProduct c).dualBasis.ext
rintro ⟨i, j⟩
apply (b.tensorProduct c).ext
rintro ⟨i', j'⟩
simp only [dualDistrib, Basis.coe_dualBasis, coe_comp, Function.comp_apply,
dualDistribInvOfBasis_apply, Basis.coord_apply, Basis.tensorProduct_repr_tmul_apply,
Basis.repr_self, ne_eq, _root_.map_sum, map_smul, homTensorHomMap_apply, compRight_apply,
Basis.tensorProduct_apply, coeFn_sum, Finset.sum_apply, smul_apply, LinearEquiv.coe_coe,
map_tmul, lid_tmul, smul_eq_mul, id_coe, id_eq]
rw [Finset.sum_eq_single i, Finset.sum_eq_single j]
· simp
all_goals { intros; simp [*] at * }
-- Porting note: introduced to help with timeout in dualDistribEquivOfBasis
| Mathlib/LinearAlgebra/Dual.lean | 1,866 | 1,875 | theorem dualDistrib_dualDistribInvOfBasis_right_inverse (b : Basis ι R M) (c : Basis κ R N) :
comp (dualDistribInvOfBasis b c) (dualDistrib R M N) = LinearMap.id := by |
apply (b.dualBasis.tensorProduct c.dualBasis).ext
rintro ⟨i, j⟩
simp only [Basis.tensorProduct_apply, Basis.coe_dualBasis, coe_comp, Function.comp_apply,
dualDistribInvOfBasis_apply, dualDistrib_apply, Basis.coord_apply, Basis.repr_self,
ne_eq, id_coe, id_eq]
rw [Finset.sum_eq_single i, Finset.sum_eq_single j]
· simp
all_goals { intros; simp [*] at * }
|
import Mathlib.CategoryTheory.CofilteredSystem
import Mathlib.Combinatorics.SimpleGraph.Connectivity
import Mathlib.Data.Finite.Set
#align_import combinatorics.simple_graph.ends.defs from "leanprover-community/mathlib"@"b99e2d58a5e6861833fa8de11e51a81144258db4"
universe u
variable {V : Type u} (G : SimpleGraph V) (K L L' M : Set V)
namespace SimpleGraph
abbrev ComponentCompl :=
(G.induce Kᶜ).ConnectedComponent
#align simple_graph.component_compl SimpleGraph.ComponentCompl
variable {G} {K L M}
abbrev componentComplMk (G : SimpleGraph V) {v : V} (vK : v ∉ K) : G.ComponentCompl K :=
connectedComponentMk (G.induce Kᶜ) ⟨v, vK⟩
#align simple_graph.component_compl_mk SimpleGraph.componentComplMk
def ComponentCompl.supp (C : G.ComponentCompl K) : Set V :=
{ v : V | ∃ h : v ∉ K, G.componentComplMk h = C }
#align simple_graph.component_compl.supp SimpleGraph.ComponentCompl.supp
@[ext]
theorem ComponentCompl.supp_injective :
Function.Injective (ComponentCompl.supp : G.ComponentCompl K → Set V) := by
refine ConnectedComponent.ind₂ ?_
rintro ⟨v, hv⟩ ⟨w, hw⟩ h
simp only [Set.ext_iff, ConnectedComponent.eq, Set.mem_setOf_eq, ComponentCompl.supp] at h ⊢
exact ((h v).mp ⟨hv, Reachable.refl _⟩).choose_spec
#align simple_graph.component_compl.supp_injective SimpleGraph.ComponentCompl.supp_injective
theorem ComponentCompl.supp_inj {C D : G.ComponentCompl K} : C.supp = D.supp ↔ C = D :=
ComponentCompl.supp_injective.eq_iff
#align simple_graph.component_compl.supp_inj SimpleGraph.ComponentCompl.supp_inj
instance ComponentCompl.setLike : SetLike (G.ComponentCompl K) V where
coe := ComponentCompl.supp
coe_injective' _ _ := ComponentCompl.supp_inj.mp
#align simple_graph.component_compl.set_like SimpleGraph.ComponentCompl.setLike
@[simp]
theorem ComponentCompl.mem_supp_iff {v : V} {C : ComponentCompl G K} :
v ∈ C ↔ ∃ vK : v ∉ K, G.componentComplMk vK = C :=
Iff.rfl
#align simple_graph.component_compl.mem_supp_iff SimpleGraph.ComponentCompl.mem_supp_iff
theorem componentComplMk_mem (G : SimpleGraph V) {v : V} (vK : v ∉ K) : v ∈ G.componentComplMk vK :=
⟨vK, rfl⟩
#align simple_graph.component_compl_mk_mem SimpleGraph.componentComplMk_mem
theorem componentComplMk_eq_of_adj (G : SimpleGraph V) {v w : V} (vK : v ∉ K) (wK : w ∉ K)
(a : G.Adj v w) : G.componentComplMk vK = G.componentComplMk wK := by
rw [ConnectedComponent.eq]
apply Adj.reachable
exact a
#align simple_graph.component_compl_mk_eq_of_adj SimpleGraph.componentComplMk_eq_of_adj
instance componentCompl_nonempty_of_infinite (G : SimpleGraph V) [Infinite V] (K : Finset V) :
Nonempty (G.ComponentCompl K) :=
let ⟨_, kK⟩ := K.finite_toSet.infinite_compl.nonempty
⟨componentComplMk _ kK⟩
instance componentCompl_finite [LocallyFinite G] [Gpc : Fact G.Preconnected] (K : Finset V) :
Finite (G.ComponentCompl K) := by
classical
rcases K.eq_empty_or_nonempty with rfl | h
-- If K is empty, then removing K doesn't change the graph, which is connected, hence has a
-- single connected component
· dsimp [ComponentCompl]
rw [Finset.coe_empty, Set.compl_empty]
have := Gpc.out.subsingleton_connectedComponent
exact Finite.of_equiv _ (induceUnivIso G).connectedComponentEquiv.symm
-- Otherwise, we consider the function `touch` mapping a connected component to one of its
-- vertices adjacent to `K`.
· let touch (C : G.ComponentCompl K) : {v : V | ∃ k : V, k ∈ K ∧ G.Adj k v} :=
let p := C.exists_adj_boundary_pair Gpc.out h
⟨p.choose.1, p.choose.2, p.choose_spec.2.1, p.choose_spec.2.2.symm⟩
-- `touch` is injective
have touch_inj : touch.Injective := fun C D h' => ComponentCompl.pairwise_disjoint.eq
(Set.not_disjoint_iff.mpr ⟨touch C, (C.exists_adj_boundary_pair Gpc.out h).choose_spec.1,
h'.symm ▸ (D.exists_adj_boundary_pair Gpc.out h).choose_spec.1⟩)
-- `touch` has finite range
have : Finite (Set.range touch) := by
refine @Subtype.finite _ (Set.Finite.to_subtype ?_) _
apply Set.Finite.ofFinset (K.biUnion (fun v => G.neighborFinset v))
simp only [Finset.mem_biUnion, mem_neighborFinset, Set.mem_setOf_eq, implies_true]
-- hence `touch` has a finite domain
apply Finite.of_injective_finite_range touch_inj
section Ends
variable (G)
open CategoryTheory
@[simps]
def componentComplFunctor : (Finset V)ᵒᵖ ⥤ Type u where
obj K := G.ComponentCompl K.unop
map f := ComponentCompl.hom (le_of_op_hom f)
map_id _ := funext fun C => C.hom_refl
map_comp h h' := funext fun C => C.hom_trans (le_of_op_hom h) (le_of_op_hom h')
#align simple_graph.component_compl_functor SimpleGraph.componentComplFunctor
protected def «end» :=
(componentComplFunctor G).sections
#align simple_graph.end SimpleGraph.end
theorem end_hom_mk_of_mk {s} (sec : s ∈ G.end) {K L : (Finset V)ᵒᵖ} (h : L ⟶ K) {v : V}
(vnL : v ∉ L.unop) (hs : s L = G.componentComplMk vnL) :
s K = G.componentComplMk (Set.not_mem_subset (le_of_op_hom h : _ ⊆ _) vnL) := by
rw [← sec h, hs]
apply ComponentCompl.hom_mk _ (le_of_op_hom h : _ ⊆ _)
#align simple_graph.end_hom_mk_of_mk SimpleGraph.end_hom_mk_of_mk
| Mathlib/Combinatorics/SimpleGraph/Ends/Defs.lean | 305 | 311 | theorem infinite_iff_in_eventualRange {K : (Finset V)ᵒᵖ} (C : G.componentComplFunctor.obj K) :
C.supp.Infinite ↔ C ∈ G.componentComplFunctor.eventualRange K := by |
simp only [C.infinite_iff_in_all_ranges, CategoryTheory.Functor.eventualRange, Set.mem_iInter,
Set.mem_range, componentComplFunctor_map]
exact
⟨fun h Lop KL => h Lop.unop (le_of_op_hom KL), fun h L KL =>
h (Opposite.op L) (opHomOfLE KL)⟩
|
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Nat.Factors
import Mathlib.Order.Interval.Finset.Nat
#align_import number_theory.divisors from "leanprover-community/mathlib"@"e8638a0fcaf73e4500469f368ef9494e495099b3"
open scoped Classical
open Finset
namespace Nat
variable (n : ℕ)
def divisors : Finset ℕ :=
Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 (n + 1))
#align nat.divisors Nat.divisors
def properDivisors : Finset ℕ :=
Finset.filter (fun x : ℕ => x ∣ n) (Finset.Ico 1 n)
#align nat.proper_divisors Nat.properDivisors
def divisorsAntidiagonal : Finset (ℕ × ℕ) :=
Finset.filter (fun x => x.fst * x.snd = n) (Ico 1 (n + 1) ×ˢ Ico 1 (n + 1))
#align nat.divisors_antidiagonal Nat.divisorsAntidiagonal
variable {n}
@[simp]
| Mathlib/NumberTheory/Divisors.lean | 61 | 64 | theorem filter_dvd_eq_divisors (h : n ≠ 0) : (Finset.range n.succ).filter (· ∣ n) = n.divisors := by |
ext
simp only [divisors, mem_filter, mem_range, mem_Ico, and_congr_left_iff, iff_and_self]
exact fun ha _ => succ_le_iff.mpr (pos_of_dvd_of_pos ha h.bot_lt)
|
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"
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 α}
irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ :=
⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ
#align measure_theory.lintegral MeasureTheory.lintegral
@[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 (μ)
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
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
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
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'
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
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
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
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
@[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'
@[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'
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
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
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₀
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
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)]
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
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
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)]
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
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'
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
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
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'
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
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
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 _
#align measure_theory.lintegral_supr_directed MeasureTheory.lintegral_iSup_directed
end
theorem lintegral_tsum [Countable β] {f : β → α → ℝ≥0∞} (hf : ∀ i, AEMeasurable (f i) μ) :
∫⁻ a, ∑' i, f i a ∂μ = ∑' i, ∫⁻ a, f i a ∂μ := by
simp only [ENNReal.tsum_eq_iSup_sum]
rw [lintegral_iSup_directed]
· simp [lintegral_finset_sum' _ fun i _ => hf i]
· intro b
exact Finset.aemeasurable_sum _ fun i _ => hf i
· intro s t
use s ∪ t
constructor
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_left
· exact fun a => Finset.sum_le_sum_of_subset Finset.subset_union_right
#align measure_theory.lintegral_tsum MeasureTheory.lintegral_tsum
open Measure
theorem lintegral_iUnion₀ [Countable β] {s : β → Set α} (hm : ∀ i, NullMeasurableSet (s i) μ)
(hd : Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ := by
simp only [Measure.restrict_iUnion_ae hd hm, lintegral_sum_measure]
#align measure_theory.lintegral_Union₀ MeasureTheory.lintegral_iUnion₀
theorem lintegral_iUnion [Countable β] {s : β → Set α} (hm : ∀ i, MeasurableSet (s i))
(hd : Pairwise (Disjoint on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ = ∑' i, ∫⁻ a in s i, f a ∂μ :=
lintegral_iUnion₀ (fun i => (hm i).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_Union MeasureTheory.lintegral_iUnion
theorem lintegral_biUnion₀ {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, NullMeasurableSet (s i) μ) (hd : t.Pairwise (AEDisjoint μ on s)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ := by
haveI := ht.toEncodable
rw [biUnion_eq_iUnion, lintegral_iUnion₀ (SetCoe.forall'.1 hm) (hd.subtype _ _)]
#align measure_theory.lintegral_bUnion₀ MeasureTheory.lintegral_biUnion₀
theorem lintegral_biUnion {t : Set β} {s : β → Set α} (ht : t.Countable)
(hm : ∀ i ∈ t, MeasurableSet (s i)) (hd : t.PairwiseDisjoint s) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i ∈ t, s i, f a ∂μ = ∑' i : t, ∫⁻ a in s i, f a ∂μ :=
lintegral_biUnion₀ ht (fun i hi => (hm i hi).nullMeasurableSet) hd.aedisjoint f
#align measure_theory.lintegral_bUnion MeasureTheory.lintegral_biUnion
theorem lintegral_biUnion_finset₀ {s : Finset β} {t : β → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on t)) (hm : ∀ b ∈ s, NullMeasurableSet (t b) μ)
(f : α → ℝ≥0∞) : ∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ := by
simp only [← Finset.mem_coe, lintegral_biUnion₀ s.countable_toSet hm hd, ← Finset.tsum_subtype']
#align measure_theory.lintegral_bUnion_finset₀ MeasureTheory.lintegral_biUnion_finset₀
theorem lintegral_biUnion_finset {s : Finset β} {t : β → Set α} (hd : Set.PairwiseDisjoint (↑s) t)
(hm : ∀ b ∈ s, MeasurableSet (t b)) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ b ∈ s, t b, f a ∂μ = ∑ b ∈ s, ∫⁻ a in t b, f a ∂μ :=
lintegral_biUnion_finset₀ hd.aedisjoint (fun b hb => (hm b hb).nullMeasurableSet) f
#align measure_theory.lintegral_bUnion_finset MeasureTheory.lintegral_biUnion_finset
theorem lintegral_iUnion_le [Countable β] (s : β → Set α) (f : α → ℝ≥0∞) :
∫⁻ a in ⋃ i, s i, f a ∂μ ≤ ∑' i, ∫⁻ a in s i, f a ∂μ := by
rw [← lintegral_sum_measure]
exact lintegral_mono' restrict_iUnion_le le_rfl
#align measure_theory.lintegral_Union_le MeasureTheory.lintegral_iUnion_le
theorem lintegral_union {f : α → ℝ≥0∞} {A B : Set α} (hB : MeasurableSet B) (hAB : Disjoint A B) :
∫⁻ a in A ∪ B, f a ∂μ = ∫⁻ a in A, f a ∂μ + ∫⁻ a in B, f a ∂μ := by
rw [restrict_union hAB hB, lintegral_add_measure]
#align measure_theory.lintegral_union MeasureTheory.lintegral_union
theorem lintegral_union_le (f : α → ℝ≥0∞) (s t : Set α) :
∫⁻ a in s ∪ t, f a ∂μ ≤ ∫⁻ a in s, f a ∂μ + ∫⁻ a in t, f a ∂μ := by
rw [← lintegral_add_measure]
exact lintegral_mono' (restrict_union_le _ _) le_rfl
theorem lintegral_inter_add_diff {B : Set α} (f : α → ℝ≥0∞) (A : Set α) (hB : MeasurableSet B) :
∫⁻ x in A ∩ B, f x ∂μ + ∫⁻ x in A \ B, f x ∂μ = ∫⁻ x in A, f x ∂μ := by
rw [← lintegral_add_measure, restrict_inter_add_diff _ hB]
#align measure_theory.lintegral_inter_add_diff MeasureTheory.lintegral_inter_add_diff
theorem lintegral_add_compl (f : α → ℝ≥0∞) {A : Set α} (hA : MeasurableSet A) :
∫⁻ x in A, f x ∂μ + ∫⁻ x in Aᶜ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [← lintegral_add_measure, Measure.restrict_add_restrict_compl hA]
#align measure_theory.lintegral_add_compl MeasureTheory.lintegral_add_compl
theorem lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ x, max (f x) (g x) ∂μ =
∫⁻ x in { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in { x | g x < f x }, f x ∂μ := by
have hm : MeasurableSet { x | f x ≤ g x } := measurableSet_le hf hg
rw [← lintegral_add_compl (fun x => max (f x) (g x)) hm]
simp only [← compl_setOf, ← not_le]
refine congr_arg₂ (· + ·) (set_lintegral_congr_fun hm ?_) (set_lintegral_congr_fun hm.compl ?_)
exacts [ae_of_all _ fun x => max_eq_right (a := f x) (b := g x),
ae_of_all _ fun x (hx : ¬ f x ≤ g x) => max_eq_left (not_le.1 hx).le]
#align measure_theory.lintegral_max MeasureTheory.lintegral_max
theorem set_lintegral_max {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) (s : Set α) :
∫⁻ x in s, max (f x) (g x) ∂μ =
∫⁻ x in s ∩ { x | f x ≤ g x }, g x ∂μ + ∫⁻ x in s ∩ { x | g x < f x }, f x ∂μ := by
rw [lintegral_max hf hg, restrict_restrict, restrict_restrict, inter_comm s, inter_comm s]
exacts [measurableSet_lt hg hf, measurableSet_le hf hg]
#align measure_theory.set_lintegral_max MeasureTheory.set_lintegral_max
theorem lintegral_map {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by
erw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral (hf.comp hg)]
congr with n : 1
convert SimpleFunc.lintegral_map _ hg
ext1 x; simp only [eapprox_comp hf hg, coe_comp]
#align measure_theory.lintegral_map MeasureTheory.lintegral_map
theorem lintegral_map' {mβ : MeasurableSpace β} {f : β → ℝ≥0∞} {g : α → β}
(hf : AEMeasurable f (Measure.map g μ)) (hg : AEMeasurable g μ) :
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, f (g a) ∂μ :=
calc
∫⁻ a, f a ∂Measure.map g μ = ∫⁻ a, hf.mk f a ∂Measure.map g μ :=
lintegral_congr_ae hf.ae_eq_mk
_ = ∫⁻ a, hf.mk f a ∂Measure.map (hg.mk g) μ := by
congr 1
exact Measure.map_congr hg.ae_eq_mk
_ = ∫⁻ a, hf.mk f (hg.mk g a) ∂μ := lintegral_map hf.measurable_mk hg.measurable_mk
_ = ∫⁻ a, hf.mk f (g a) ∂μ := lintegral_congr_ae <| hg.ae_eq_mk.symm.fun_comp _
_ = ∫⁻ a, f (g a) ∂μ := lintegral_congr_ae (ae_eq_comp hg hf.ae_eq_mk.symm)
#align measure_theory.lintegral_map' MeasureTheory.lintegral_map'
theorem lintegral_map_le {mβ : MeasurableSpace β} (f : β → ℝ≥0∞) {g : α → β} (hg : Measurable g) :
∫⁻ a, f a ∂Measure.map g μ ≤ ∫⁻ a, f (g a) ∂μ := by
rw [← iSup_lintegral_measurable_le_eq_lintegral, ← iSup_lintegral_measurable_le_eq_lintegral]
refine iSup₂_le fun i hi => iSup_le fun h'i => ?_
refine le_iSup₂_of_le (i ∘ g) (hi.comp hg) ?_
exact le_iSup_of_le (fun x => h'i (g x)) (le_of_eq (lintegral_map hi hg))
#align measure_theory.lintegral_map_le MeasureTheory.lintegral_map_le
theorem lintegral_comp [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} (hf : Measurable f)
(hg : Measurable g) : lintegral μ (f ∘ g) = ∫⁻ a, f a ∂map g μ :=
(lintegral_map hf hg).symm
#align measure_theory.lintegral_comp MeasureTheory.lintegral_comp
theorem set_lintegral_map [MeasurableSpace β] {f : β → ℝ≥0∞} {g : α → β} {s : Set β}
(hs : MeasurableSet s) (hf : Measurable f) (hg : Measurable g) :
∫⁻ y in s, f y ∂map g μ = ∫⁻ x in g ⁻¹' s, f (g x) ∂μ := by
rw [restrict_map hg hs, lintegral_map hf hg]
#align measure_theory.set_lintegral_map MeasureTheory.set_lintegral_map
theorem lintegral_indicator_const_comp {mβ : MeasurableSpace β} {f : α → β} {s : Set β}
(hf : Measurable f) (hs : MeasurableSet s) (c : ℝ≥0∞) :
∫⁻ a, s.indicator (fun _ => c) (f a) ∂μ = c * μ (f ⁻¹' s) := by
erw [lintegral_comp (measurable_const.indicator hs) hf, lintegral_indicator_const hs,
Measure.map_apply hf hs]
#align measure_theory.lintegral_indicator_const_comp MeasureTheory.lintegral_indicator_const_comp
theorem _root_.MeasurableEmbedding.lintegral_map [MeasurableSpace β] {g : α → β}
(hg : MeasurableEmbedding g) (f : β → ℝ≥0∞) : ∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ := by
rw [lintegral, lintegral]
refine le_antisymm (iSup₂_le fun f₀ hf₀ => ?_) (iSup₂_le fun f₀ hf₀ => ?_)
· rw [SimpleFunc.lintegral_map _ hg.measurable]
have : (f₀.comp g hg.measurable : α → ℝ≥0∞) ≤ f ∘ g := fun x => hf₀ (g x)
exact le_iSup_of_le (comp f₀ g hg.measurable) (by exact le_iSup (α := ℝ≥0∞) _ this)
· rw [← f₀.extend_comp_eq hg (const _ 0), ← SimpleFunc.lintegral_map, ←
SimpleFunc.lintegral_eq_lintegral, ← lintegral]
refine lintegral_mono_ae (hg.ae_map_iff.2 <| eventually_of_forall fun x => ?_)
exact (extend_apply _ _ _ _).trans_le (hf₀ _)
#align measurable_embedding.lintegral_map MeasurableEmbedding.lintegral_map
theorem lintegral_map_equiv [MeasurableSpace β] (f : β → ℝ≥0∞) (g : α ≃ᵐ β) :
∫⁻ a, f a ∂map g μ = ∫⁻ a, f (g a) ∂μ :=
g.measurableEmbedding.lintegral_map f
#align measure_theory.lintegral_map_equiv MeasureTheory.lintegral_map_equiv
protected theorem MeasurePreserving.lintegral_map_equiv [MeasurableSpace β] {ν : Measure β}
(f : β → ℝ≥0∞) (g : α ≃ᵐ β) (hg : MeasurePreserving g μ ν) :
∫⁻ a, f a ∂ν = ∫⁻ a, f (g a) ∂μ := by
rw [← MeasureTheory.lintegral_map_equiv f g, hg.map_eq]
theorem MeasurePreserving.lintegral_comp {mb : MeasurableSpace β} {ν : Measure β} {g : α → β}
(hg : MeasurePreserving g μ ν) {f : β → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f (g a) ∂μ = ∫⁻ b, f b ∂ν := by rw [← hg.map_eq, lintegral_map hf hg.measurable]
#align measure_theory.measure_preserving.lintegral_comp MeasureTheory.MeasurePreserving.lintegral_comp
theorem MeasurePreserving.lintegral_comp_emb {mb : MeasurableSpace β} {ν : Measure β} {g : α → β}
(hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞) :
∫⁻ a, f (g a) ∂μ = ∫⁻ b, f b ∂ν := by rw [← hg.map_eq, hge.lintegral_map]
#align measure_theory.measure_preserving.lintegral_comp_emb MeasureTheory.MeasurePreserving.lintegral_comp_emb
theorem MeasurePreserving.set_lintegral_comp_preimage {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) {s : Set β} (hs : MeasurableSet s) {f : β → ℝ≥0∞}
(hf : Measurable f) : ∫⁻ a in g ⁻¹' s, f (g a) ∂μ = ∫⁻ b in s, f b ∂ν := by
rw [← hg.map_eq, set_lintegral_map hs hf hg.measurable]
#align measure_theory.measure_preserving.set_lintegral_comp_preimage MeasureTheory.MeasurePreserving.set_lintegral_comp_preimage
theorem MeasurePreserving.set_lintegral_comp_preimage_emb {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞)
(s : Set β) : ∫⁻ a in g ⁻¹' s, f (g a) ∂μ = ∫⁻ b in s, f b ∂ν := by
rw [← hg.map_eq, hge.restrict_map, hge.lintegral_map]
#align measure_theory.measure_preserving.set_lintegral_comp_preimage_emb MeasureTheory.MeasurePreserving.set_lintegral_comp_preimage_emb
theorem MeasurePreserving.set_lintegral_comp_emb {mb : MeasurableSpace β} {ν : Measure β}
{g : α → β} (hg : MeasurePreserving g μ ν) (hge : MeasurableEmbedding g) (f : β → ℝ≥0∞)
(s : Set α) : ∫⁻ a in s, f (g a) ∂μ = ∫⁻ b in g '' s, f b ∂ν := by
rw [← hg.set_lintegral_comp_preimage_emb hge, preimage_image_eq _ hge.injective]
#align measure_theory.measure_preserving.set_lintegral_comp_emb MeasureTheory.MeasurePreserving.set_lintegral_comp_emb
theorem lintegral_subtype_comap {s : Set α} (hs : MeasurableSet s) (f : α → ℝ≥0∞) :
∫⁻ x : s, f x ∂(μ.comap (↑)) = ∫⁻ x in s, f x ∂μ := by
rw [← (MeasurableEmbedding.subtype_coe hs).lintegral_map, map_comap_subtype_coe hs]
theorem set_lintegral_subtype {s : Set α} (hs : MeasurableSet s) (t : Set s) (f : α → ℝ≥0∞) :
∫⁻ x in t, f x ∂(μ.comap (↑)) = ∫⁻ x in (↑) '' t, f x ∂μ := by
rw [(MeasurableEmbedding.subtype_coe hs).restrict_comap, lintegral_subtype_comap hs,
restrict_restrict hs, inter_eq_right.2 (Subtype.coe_image_subset _ _)]
open MeasureTheory.SimpleFunc
variable {m m0 : MeasurableSpace α}
theorem exists_pos_lintegral_lt_of_sigmaFinite (μ : Measure α) [SigmaFinite μ] {ε : ℝ≥0∞}
(ε0 : ε ≠ 0) : ∃ g : α → ℝ≥0, (∀ x, 0 < g x) ∧ Measurable g ∧ ∫⁻ x, g x ∂μ < ε := by
set s : ℕ → Set α := disjointed (spanningSets μ)
have : ∀ n, μ (s n) < ∞ := fun n =>
(measure_mono <| disjointed_subset _ _).trans_lt (measure_spanningSets_lt_top μ n)
obtain ⟨δ, δpos, δsum⟩ : ∃ δ : ℕ → ℝ≥0, (∀ i, 0 < δ i) ∧ (∑' i, μ (s i) * δ i) < ε :=
ENNReal.exists_pos_tsum_mul_lt_of_countable ε0 _ fun n => (this n).ne
set N : α → ℕ := spanningSetsIndex μ
have hN_meas : Measurable N := measurable_spanningSetsIndex μ
have hNs : ∀ n, N ⁻¹' {n} = s n := preimage_spanningSetsIndex_singleton μ
refine ⟨δ ∘ N, fun x => δpos _, measurable_from_nat.comp hN_meas, ?_⟩
erw [lintegral_comp measurable_from_nat.coe_nnreal_ennreal hN_meas]
simpa [N, hNs, lintegral_countable', measurable_spanningSetsIndex, mul_comm] using δsum
#align measure_theory.exists_pos_lintegral_lt_of_sigma_finite MeasureTheory.exists_pos_lintegral_lt_of_sigmaFinite
theorem lintegral_trim {μ : Measure α} (hm : m ≤ m0) {f : α → ℝ≥0∞} (hf : Measurable[m] f) :
∫⁻ a, f a ∂μ.trim hm = ∫⁻ a, f a ∂μ := by
refine
@Measurable.ennreal_induction α m (fun f => ∫⁻ a, f a ∂μ.trim hm = ∫⁻ a, f a ∂μ) ?_ ?_ ?_ f hf
· intro c s hs
rw [lintegral_indicator _ hs, lintegral_indicator _ (hm s hs), set_lintegral_const,
set_lintegral_const]
suffices h_trim_s : μ.trim hm s = μ s by rw [h_trim_s]
exact trim_measurableSet_eq hm hs
· intro f g _ hf _ hf_prop hg_prop
have h_m := lintegral_add_left (μ := Measure.trim μ hm) hf g
have h_m0 := lintegral_add_left (μ := μ) (Measurable.mono hf hm le_rfl) g
rwa [hf_prop, hg_prop, ← h_m0] at h_m
· intro f hf hf_mono hf_prop
rw [lintegral_iSup hf hf_mono]
rw [lintegral_iSup (fun n => Measurable.mono (hf n) hm le_rfl) hf_mono]
congr with n
exact hf_prop n
#align measure_theory.lintegral_trim MeasureTheory.lintegral_trim
theorem lintegral_trim_ae {μ : Measure α} (hm : m ≤ m0) {f : α → ℝ≥0∞}
(hf : AEMeasurable f (μ.trim hm)) : ∫⁻ a, f a ∂μ.trim hm = ∫⁻ a, f a ∂μ := by
rw [lintegral_congr_ae (ae_eq_of_ae_eq_trim hf.ae_eq_mk), lintegral_congr_ae hf.ae_eq_mk,
lintegral_trim hm hf.measurable_mk]
#align measure_theory.lintegral_trim_ae MeasureTheory.lintegral_trim_ae
section SigmaFinite
variable {E : Type*} [NormedAddCommGroup E] [MeasurableSpace E] [OpensMeasurableSpace E]
theorem univ_le_of_forall_fin_meas_le {μ : Measure α} (hm : m ≤ m0) [SigmaFinite (μ.trim hm)]
(C : ℝ≥0∞) {f : Set α → ℝ≥0∞} (hf : ∀ s, MeasurableSet[m] s → μ s ≠ ∞ → f s ≤ C)
(h_F_lim :
∀ S : ℕ → Set α, (∀ n, MeasurableSet[m] (S n)) → Monotone S → f (⋃ n, S n) ≤ ⨆ n, f (S n)) :
f univ ≤ C := by
let S := @spanningSets _ m (μ.trim hm) _
have hS_mono : Monotone S := @monotone_spanningSets _ m (μ.trim hm) _
have hS_meas : ∀ n, MeasurableSet[m] (S n) := @measurable_spanningSets _ m (μ.trim hm) _
rw [← @iUnion_spanningSets _ m (μ.trim hm)]
refine (h_F_lim S hS_meas hS_mono).trans ?_
refine iSup_le fun n => hf (S n) (hS_meas n) ?_
exact ((le_trim hm).trans_lt (@measure_spanningSets_lt_top _ m (μ.trim hm) _ n)).ne
#align measure_theory.univ_le_of_forall_fin_meas_le MeasureTheory.univ_le_of_forall_fin_meas_le
theorem lintegral_le_of_forall_fin_meas_le_of_measurable {μ : Measure α} (hm : m ≤ m0)
[SigmaFinite (μ.trim hm)] (C : ℝ≥0∞) {f : α → ℝ≥0∞} (hf_meas : Measurable f)
(hf : ∀ s, MeasurableSet[m] s → μ s ≠ ∞ → ∫⁻ x in s, f x ∂μ ≤ C) : ∫⁻ x, f x ∂μ ≤ C := by
have : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by simp only [Measure.restrict_univ]
rw [← this]
refine univ_le_of_forall_fin_meas_le hm C hf fun S hS_meas hS_mono => ?_
rw [← lintegral_indicator]
swap
· exact hm (⋃ n, S n) (@MeasurableSet.iUnion _ _ m _ _ hS_meas)
have h_integral_indicator : ⨆ n, ∫⁻ x in S n, f x ∂μ = ⨆ n, ∫⁻ x, (S n).indicator f x ∂μ := by
congr
ext1 n
rw [lintegral_indicator _ (hm _ (hS_meas n))]
rw [h_integral_indicator, ← lintegral_iSup]
· refine le_of_eq (lintegral_congr fun x => ?_)
simp_rw [indicator_apply]
by_cases hx_mem : x ∈ iUnion S
· simp only [hx_mem, if_true]
obtain ⟨n, hxn⟩ := mem_iUnion.mp hx_mem
refine le_antisymm (_root_.trans ?_ (le_iSup _ n)) (iSup_le fun i => ?_)
· simp only [hxn, le_refl, if_true]
· by_cases hxi : x ∈ S i <;> simp [hxi]
· simp only [hx_mem, if_false]
rw [mem_iUnion] at hx_mem
push_neg at hx_mem
refine le_antisymm (zero_le _) (iSup_le fun n => ?_)
simp only [hx_mem n, if_false, nonpos_iff_eq_zero]
· exact fun n => hf_meas.indicator (hm _ (hS_meas n))
· intro n₁ n₂ hn₁₂ a
simp_rw [indicator_apply]
split_ifs with h h_1
· exact le_rfl
· exact absurd (mem_of_mem_of_subset h (hS_mono hn₁₂)) h_1
· exact zero_le _
· exact le_rfl
#align measure_theory.lintegral_le_of_forall_fin_meas_le_of_measurable MeasureTheory.lintegral_le_of_forall_fin_meas_le_of_measurable
theorem lintegral_le_of_forall_fin_meas_le' {μ : Measure α} (hm : m ≤ m0) [SigmaFinite (μ.trim hm)]
(C : ℝ≥0∞) {f : _ → ℝ≥0∞} (hf_meas : AEMeasurable f μ)
(hf : ∀ s, MeasurableSet[m] s → μ s ≠ ∞ → ∫⁻ x in s, f x ∂μ ≤ C) : ∫⁻ x, f x ∂μ ≤ C := by
let f' := hf_meas.mk f
have hf' : ∀ s, MeasurableSet[m] s → μ s ≠ ∞ → ∫⁻ x in s, f' x ∂μ ≤ C := by
refine fun s hs hμs => (le_of_eq ?_).trans (hf s hs hμs)
refine lintegral_congr_ae (ae_restrict_of_ae (hf_meas.ae_eq_mk.mono fun x hx => ?_))
dsimp only
rw [hx]
rw [lintegral_congr_ae hf_meas.ae_eq_mk]
exact lintegral_le_of_forall_fin_meas_le_of_measurable hm C hf_meas.measurable_mk hf'
#align measure_theory.lintegral_le_of_forall_fin_meas_le' MeasureTheory.lintegral_le_of_forall_fin_meas_le'
theorem lintegral_le_of_forall_fin_meas_le [MeasurableSpace α] {μ : Measure α} [SigmaFinite μ]
(C : ℝ≥0∞) {f : α → ℝ≥0∞} (hf_meas : AEMeasurable f μ)
(hf : ∀ s, MeasurableSet s → μ s ≠ ∞ → ∫⁻ x in s, f x ∂μ ≤ C) : ∫⁻ x, f x ∂μ ≤ C :=
@lintegral_le_of_forall_fin_meas_le' _ _ _ _ _ (by rwa [trim_eq_self]) C _ hf_meas hf
#align measure_theory.lintegral_le_of_forall_fin_meas_le MeasureTheory.lintegral_le_of_forall_fin_meas_le
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 1,931 | 1,983 | theorem SimpleFunc.exists_lt_lintegral_simpleFunc_of_lt_lintegral {m : MeasurableSpace α}
{μ : Measure α} [SigmaFinite μ] {f : α →ₛ ℝ≥0} {L : ℝ≥0∞} (hL : L < ∫⁻ x, f x ∂μ) :
∃ g : α →ₛ ℝ≥0, (∀ x, g x ≤ f x) ∧ ∫⁻ x, g x ∂μ < ∞ ∧ L < ∫⁻ x, g x ∂μ := by |
induction' f using MeasureTheory.SimpleFunc.induction with c s hs f₁ f₂ _ h₁ h₂ generalizing L
· simp only [hs, const_zero, coe_piecewise, coe_const, SimpleFunc.coe_zero, univ_inter,
piecewise_eq_indicator, lintegral_indicator, lintegral_const, Measure.restrict_apply',
ENNReal.coe_indicator, Function.const_apply] at hL
have c_ne_zero : c ≠ 0 := by
intro hc
simp only [hc, ENNReal.coe_zero, zero_mul, not_lt_zero] at hL
have : L / c < μ s := by
rwa [ENNReal.div_lt_iff, mul_comm]
· simp only [c_ne_zero, Ne, ENNReal.coe_eq_zero, not_false_iff, true_or_iff]
· simp only [Ne, coe_ne_top, not_false_iff, true_or_iff]
obtain ⟨t, ht, ts, mlt, t_top⟩ :
∃ t : Set α, MeasurableSet t ∧ t ⊆ s ∧ L / ↑c < μ t ∧ μ t < ∞ :=
Measure.exists_subset_measure_lt_top hs this
refine ⟨piecewise t ht (const α c) (const α 0), fun x => ?_, ?_, ?_⟩
· refine indicator_le_indicator_of_subset ts (fun x => ?_) x
exact zero_le _
· simp only [ht, const_zero, coe_piecewise, coe_const, SimpleFunc.coe_zero, univ_inter,
piecewise_eq_indicator, ENNReal.coe_indicator, Function.const_apply, lintegral_indicator,
lintegral_const, Measure.restrict_apply', ENNReal.mul_lt_top ENNReal.coe_ne_top t_top.ne]
· simp only [ht, const_zero, coe_piecewise, coe_const, SimpleFunc.coe_zero,
piecewise_eq_indicator, ENNReal.coe_indicator, Function.const_apply, lintegral_indicator,
lintegral_const, Measure.restrict_apply', univ_inter]
rwa [mul_comm, ← ENNReal.div_lt_iff]
· simp only [c_ne_zero, Ne, ENNReal.coe_eq_zero, not_false_iff, true_or_iff]
· simp only [Ne, coe_ne_top, not_false_iff, true_or_iff]
· replace hL : L < ∫⁻ x, f₁ x ∂μ + ∫⁻ x, f₂ x ∂μ := by
rwa [← lintegral_add_left f₁.measurable.coe_nnreal_ennreal]
by_cases hf₁ : ∫⁻ x, f₁ x ∂μ = 0
· simp only [hf₁, zero_add] at hL
rcases h₂ hL with ⟨g, g_le, g_top, gL⟩
refine ⟨g, fun x => (g_le x).trans ?_, g_top, gL⟩
simp only [SimpleFunc.coe_add, Pi.add_apply, le_add_iff_nonneg_left, zero_le']
by_cases hf₂ : ∫⁻ x, f₂ x ∂μ = 0
· simp only [hf₂, add_zero] at hL
rcases h₁ hL with ⟨g, g_le, g_top, gL⟩
refine ⟨g, fun x => (g_le x).trans ?_, g_top, gL⟩
simp only [SimpleFunc.coe_add, Pi.add_apply, le_add_iff_nonneg_right, zero_le']
obtain ⟨L₁, L₂, hL₁, hL₂, hL⟩ :
∃ L₁ L₂ : ℝ≥0∞, (L₁ < ∫⁻ x, f₁ x ∂μ) ∧ (L₂ < ∫⁻ x, f₂ x ∂μ) ∧ L < L₁ + L₂ :=
ENNReal.exists_lt_add_of_lt_add hL hf₁ hf₂
rcases h₁ hL₁ with ⟨g₁, g₁_le, g₁_top, hg₁⟩
rcases h₂ hL₂ with ⟨g₂, g₂_le, g₂_top, hg₂⟩
refine ⟨g₁ + g₂, fun x => add_le_add (g₁_le x) (g₂_le x), ?_, ?_⟩
· apply lt_of_le_of_lt _ (add_lt_top.2 ⟨g₁_top, g₂_top⟩)
rw [← lintegral_add_left g₁.measurable.coe_nnreal_ennreal]
exact le_rfl
· apply hL.trans ((ENNReal.add_lt_add hg₁ hg₂).trans_le _)
rw [← lintegral_add_left g₁.measurable.coe_nnreal_ennreal]
simp only [coe_add, Pi.add_apply, ENNReal.coe_add, le_rfl]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.