Context stringlengths 285 157k | file_name stringlengths 21 79 | start int64 14 3.67k | end int64 18 3.69k | theorem stringlengths 25 2.71k | proof stringlengths 5 10.6k |
|---|---|---|---|---|---|
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.CharZero.Lemmas
import Mathlib.Order.Interval.Finset.Basic
#align_import data.int.interval from "leanprover-community/mathlib"@"1d29de43a5ba4662dd33b5cfeecfc2a27a5a8a29"
/-!
# Finite intervals of integers
This file proves that `ℤ` is a `LocallyFiniteOrder` and calculates the cardinality of its
intervals as finsets and fintypes.
-/
open Finset Int
namespace Int
instance instLocallyFiniteOrder : LocallyFiniteOrder ℤ where
finsetIcc a b :=
(Finset.range (b + 1 - a).toNat).map <| Nat.castEmbedding.trans <| addLeftEmbedding a
finsetIco a b := (Finset.range (b - a).toNat).map <| Nat.castEmbedding.trans <| addLeftEmbedding a
finsetIoc a b :=
(Finset.range (b - a).toNat).map <| Nat.castEmbedding.trans <| addLeftEmbedding (a + 1)
finsetIoo a b :=
(Finset.range (b - a - 1).toNat).map <| Nat.castEmbedding.trans <| addLeftEmbedding (a + 1)
finset_mem_Icc a b x := by
simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply,
Nat.castEmbedding_apply, addLeftEmbedding_apply]
constructor
· rintro ⟨a, h, rfl⟩
rw [lt_sub_iff_add_lt, Int.lt_add_one_iff, add_comm] at h
exact ⟨Int.le.intro a rfl, h⟩
· rintro ⟨ha, hb⟩
use (x - a).toNat
rw [← lt_add_one_iff] at hb
rw [toNat_sub_of_le ha]
exact ⟨sub_lt_sub_right hb _, add_sub_cancel _ _⟩
finset_mem_Ico a b x := by
simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply,
Nat.castEmbedding_apply, addLeftEmbedding_apply]
constructor
· rintro ⟨a, h, rfl⟩
exact ⟨Int.le.intro a rfl, lt_sub_iff_add_lt'.mp h⟩
· rintro ⟨ha, hb⟩
use (x - a).toNat
rw [toNat_sub_of_le ha]
exact ⟨sub_lt_sub_right hb _, add_sub_cancel _ _⟩
finset_mem_Ioc a b x := by
simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply,
Nat.castEmbedding_apply, addLeftEmbedding_apply]
constructor
· rintro ⟨a, h, rfl⟩
rw [← add_one_le_iff, le_sub_iff_add_le', add_comm _ (1 : ℤ), ← add_assoc] at h
exact ⟨Int.le.intro a rfl, h⟩
· rintro ⟨ha, hb⟩
use (x - (a + 1)).toNat
rw [toNat_sub_of_le ha, ← add_one_le_iff, sub_add, add_sub_cancel_right]
exact ⟨sub_le_sub_right hb _, add_sub_cancel _ _⟩
finset_mem_Ioo a b x := by
simp_rw [mem_map, mem_range, Int.lt_toNat, Function.Embedding.trans_apply,
Nat.castEmbedding_apply, addLeftEmbedding_apply]
constructor
· rintro ⟨a, h, rfl⟩
rw [sub_sub, lt_sub_iff_add_lt'] at h
exact ⟨Int.le.intro a rfl, h⟩
· rintro ⟨ha, hb⟩
use (x - (a + 1)).toNat
rw [toNat_sub_of_le ha, sub_sub]
exact ⟨sub_lt_sub_right hb _, add_sub_cancel _ _⟩
variable (a b : ℤ)
theorem Icc_eq_finset_map :
Icc a b =
(Finset.range (b + 1 - a).toNat).map (Nat.castEmbedding.trans <| addLeftEmbedding a) :=
rfl
#align int.Icc_eq_finset_map Int.Icc_eq_finset_map
theorem Ico_eq_finset_map :
Ico a b = (Finset.range (b - a).toNat).map (Nat.castEmbedding.trans <| addLeftEmbedding a) :=
rfl
#align int.Ico_eq_finset_map Int.Ico_eq_finset_map
theorem Ioc_eq_finset_map :
Ioc a b =
(Finset.range (b - a).toNat).map (Nat.castEmbedding.trans <| addLeftEmbedding (a + 1)) :=
rfl
#align int.Ioc_eq_finset_map Int.Ioc_eq_finset_map
theorem Ioo_eq_finset_map :
Ioo a b =
(Finset.range (b - a - 1).toNat).map (Nat.castEmbedding.trans <| addLeftEmbedding (a + 1)) :=
rfl
#align int.Ioo_eq_finset_map Int.Ioo_eq_finset_map
theorem uIcc_eq_finset_map :
uIcc a b = (range (max a b + 1 - min a b).toNat).map
(Nat.castEmbedding.trans <| addLeftEmbedding <| min a b) := rfl
#align int.uIcc_eq_finset_map Int.uIcc_eq_finset_map
@[simp]
theorem card_Icc : (Icc a b).card = (b + 1 - a).toNat := (card_map _).trans <| card_range _
#align int.card_Icc Int.card_Icc
@[simp]
theorem card_Ico : (Ico a b).card = (b - a).toNat := (card_map _).trans <| card_range _
#align int.card_Ico Int.card_Ico
@[simp]
theorem card_Ioc : (Ioc a b).card = (b - a).toNat := (card_map _).trans <| card_range _
#align int.card_Ioc Int.card_Ioc
@[simp]
theorem card_Ioo : (Ioo a b).card = (b - a - 1).toNat := (card_map _).trans <| card_range _
#align int.card_Ioo Int.card_Ioo
@[simp]
theorem card_uIcc : (uIcc a b).card = (b - a).natAbs + 1 :=
(card_map _).trans <|
Int.ofNat.inj <| by
-- Porting note (#11215): TODO: Restore `int.coe_nat_inj` and remove the `change`
change ((↑) : ℕ → ℤ) _ = ((↑) : ℕ → ℤ) _
rw [card_range, sup_eq_max, inf_eq_min,
Int.toNat_of_nonneg (sub_nonneg_of_le <| le_add_one min_le_max), Int.ofNat_add,
Int.natCast_natAbs, add_comm, add_sub_assoc, max_sub_min_eq_abs, add_comm, Int.ofNat_one]
#align int.card_uIcc Int.card_uIcc
theorem card_Icc_of_le (h : a ≤ b + 1) : ((Icc a b).card : ℤ) = b + 1 - a := by
rw [card_Icc, toNat_sub_of_le h]
#align int.card_Icc_of_le Int.card_Icc_of_le
theorem card_Ico_of_le (h : a ≤ b) : ((Ico a b).card : ℤ) = b - a := by
rw [card_Ico, toNat_sub_of_le h]
#align int.card_Ico_of_le Int.card_Ico_of_le
| Mathlib/Data/Int/Interval.lean | 141 | 142 | theorem card_Ioc_of_le (h : a ≤ b) : ((Ioc a b).card : ℤ) = b - a := by |
rw [card_Ioc, toNat_sub_of_le h]
|
/-
Copyright (c) 2020 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Kexing Ying, Eric Wieser
-/
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.SesquilinearForm
import Mathlib.LinearAlgebra.Matrix.Symmetric
#align_import linear_algebra.quadratic_form.basic from "leanprover-community/mathlib"@"d11f435d4e34a6cea0a1797d6b625b0c170be845"
/-!
# Quadratic forms
This file defines quadratic forms over a `R`-module `M`.
A quadratic form on a commutative ring `R` is a map `Q : M → R` such that:
* `QuadraticForm.map_smul`: `Q (a • x) = a * a * Q x`
* `QuadraticForm.polar_add_left`, `QuadraticForm.polar_add_right`,
`QuadraticForm.polar_smul_left`, `QuadraticForm.polar_smul_right`:
the map `QuadraticForm.polar Q := fun x y ↦ Q (x + y) - Q x - Q y` is bilinear.
This notion generalizes to commutative semirings using the approach in [izhakian2016][] which
requires that there be a (possibly non-unique) companion bilinear form `B` such that
`∀ x y, Q (x + y) = Q x + Q y + B x y`. Over a ring, this `B` is precisely `QuadraticForm.polar Q`.
To build a `QuadraticForm` from the `polar` axioms, use `QuadraticForm.ofPolar`.
Quadratic forms come with a scalar multiplication, `(a • Q) x = Q (a • x) = a * a * Q x`,
and composition with linear maps `f`, `Q.comp f x = Q (f x)`.
## Main definitions
* `QuadraticForm.ofPolar`: a more familiar constructor that works on rings
* `QuadraticForm.associated`: associated bilinear form
* `QuadraticForm.PosDef`: positive definite quadratic forms
* `QuadraticForm.Anisotropic`: anisotropic quadratic forms
* `QuadraticForm.discr`: discriminant of a quadratic form
* `QuadraticForm.IsOrtho`: orthogonality of vectors with respect to a quadratic form.
## Main statements
* `QuadraticForm.associated_left_inverse`,
* `QuadraticForm.associated_rightInverse`: in a commutative ring where 2 has
an inverse, there is a correspondence between quadratic forms and symmetric
bilinear forms
* `LinearMap.BilinForm.exists_orthogonal_basis`: There exists an orthogonal basis with
respect to any nondegenerate, symmetric bilinear form `B`.
## Notation
In this file, the variable `R` is used when a `CommSemiring` structure is available.
The variable `S` is used when `R` itself has a `•` action.
## Implementation notes
While the definition and many results make sense if we drop commutativity assumptions,
the correct definition of a quadratic form in the noncommutative setting would require
substantial refactors from the current version, such that $Q(rm) = rQ(m)r^*$ for some
suitable conjugation $r^*$.
The [Zulip thread](https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/Quadratic.20Maps/near/395529867)
has some further discusion.
## References
* https://en.wikipedia.org/wiki/Quadratic_form
* https://en.wikipedia.org/wiki/Discriminant#Quadratic_forms
## Tags
quadratic form, homogeneous polynomial, quadratic polynomial
-/
universe u v w
variable {S T : Type*}
variable {R : Type*} {M N : Type*}
open LinearMap (BilinForm)
section Polar
variable [CommRing R] [AddCommGroup M]
namespace QuadraticForm
/-- Up to a factor 2, `Q.polar` is the associated bilinear form for a quadratic form `Q`.
Source of this name: https://en.wikipedia.org/wiki/Quadratic_form#Generalization
-/
def polar (f : M → R) (x y : M) :=
f (x + y) - f x - f y
#align quadratic_form.polar QuadraticForm.polar
theorem polar_add (f g : M → R) (x y : M) : polar (f + g) x y = polar f x y + polar g x y := by
simp only [polar, Pi.add_apply]
abel
#align quadratic_form.polar_add QuadraticForm.polar_add
theorem polar_neg (f : M → R) (x y : M) : polar (-f) x y = -polar f x y := by
simp only [polar, Pi.neg_apply, sub_eq_add_neg, neg_add]
#align quadratic_form.polar_neg QuadraticForm.polar_neg
theorem polar_smul [Monoid S] [DistribMulAction S R] (f : M → R) (s : S) (x y : M) :
polar (s • f) x y = s • polar f x y := by simp only [polar, Pi.smul_apply, smul_sub]
#align quadratic_form.polar_smul QuadraticForm.polar_smul
theorem polar_comm (f : M → R) (x y : M) : polar f x y = polar f y x := by
rw [polar, polar, add_comm, sub_sub, sub_sub, add_comm (f x) (f y)]
#align quadratic_form.polar_comm QuadraticForm.polar_comm
/-- Auxiliary lemma to express bilinearity of `QuadraticForm.polar` without subtraction. -/
theorem polar_add_left_iff {f : M → R} {x x' y : M} :
polar f (x + x') y = polar f x y + polar f x' y ↔
f (x + x' + y) + (f x + f x' + f y) = f (x + x') + f (x' + y) + f (y + x) := by
simp only [← add_assoc]
simp only [polar, sub_eq_iff_eq_add, eq_sub_iff_add_eq, sub_add_eq_add_sub, add_sub]
simp only [add_right_comm _ (f y) _, add_right_comm _ (f x') (f x)]
rw [add_comm y x, add_right_comm _ _ (f (x + y)), add_comm _ (f (x + y)),
add_right_comm (f (x + y)), add_left_inj]
#align quadratic_form.polar_add_left_iff QuadraticForm.polar_add_left_iff
theorem polar_comp {F : Type*} [CommRing S] [FunLike F R S] [AddMonoidHomClass F R S]
(f : M → R) (g : F) (x y : M) :
polar (g ∘ f) x y = g (polar f x y) := by
simp only [polar, Pi.smul_apply, Function.comp_apply, map_sub]
#align quadratic_form.polar_comp QuadraticForm.polar_comp
end QuadraticForm
end Polar
/-- A quadratic form over a module.
For a more familiar constructor when `R` is a ring, see `QuadraticForm.ofPolar`. -/
structure QuadraticForm (R : Type u) (M : Type v)
[CommSemiring R] [AddCommMonoid M] [Module R M] where
toFun : M → R
toFun_smul : ∀ (a : R) (x : M), toFun (a • x) = a * a * toFun x
exists_companion' :
∃ B : BilinForm R M, ∀ x y, toFun (x + y) = toFun x + toFun y + B x y
#align quadratic_form QuadraticForm
namespace QuadraticForm
section DFunLike
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable {Q Q' : QuadraticForm R M}
instance instFunLike : FunLike (QuadraticForm R M) M R where
coe := toFun
coe_injective' x y h := by cases x; cases y; congr
#align quadratic_form.fun_like QuadraticForm.instFunLike
/-- Helper instance for when there's too many metavariables to apply
`DFunLike.hasCoeToFun` directly. -/
instance : CoeFun (QuadraticForm R M) fun _ => M → R :=
⟨DFunLike.coe⟩
variable (Q)
/-- The `simp` normal form for a quadratic form is `DFunLike.coe`, not `toFun`. -/
@[simp]
theorem toFun_eq_coe : Q.toFun = ⇑Q :=
rfl
#align quadratic_form.to_fun_eq_coe QuadraticForm.toFun_eq_coe
-- this must come after the coe_to_fun definition
initialize_simps_projections QuadraticForm (toFun → apply)
variable {Q}
@[ext]
theorem ext (H : ∀ x : M, Q x = Q' x) : Q = Q' :=
DFunLike.ext _ _ H
#align quadratic_form.ext QuadraticForm.ext
theorem congr_fun (h : Q = Q') (x : M) : Q x = Q' x :=
DFunLike.congr_fun h _
#align quadratic_form.congr_fun QuadraticForm.congr_fun
theorem ext_iff : Q = Q' ↔ ∀ x, Q x = Q' x :=
DFunLike.ext_iff
#align quadratic_form.ext_iff QuadraticForm.ext_iff
/-- Copy of a `QuadraticForm` with a new `toFun` equal to the old one. Useful to fix definitional
equalities. -/
protected def copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : QuadraticForm R M where
toFun := Q'
toFun_smul := h.symm ▸ Q.toFun_smul
exists_companion' := h.symm ▸ Q.exists_companion'
#align quadratic_form.copy QuadraticForm.copy
@[simp]
theorem coe_copy (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : ⇑(Q.copy Q' h) = Q' :=
rfl
#align quadratic_form.coe_copy QuadraticForm.coe_copy
theorem copy_eq (Q : QuadraticForm R M) (Q' : M → R) (h : Q' = ⇑Q) : Q.copy Q' h = Q :=
DFunLike.ext' h
#align quadratic_form.copy_eq QuadraticForm.copy_eq
end DFunLike
section CommSemiring
variable [CommSemiring R] [AddCommMonoid M] [Module R M]
variable (Q : QuadraticForm R M)
theorem map_smul (a : R) (x : M) : Q (a • x) = a * a * Q x :=
Q.toFun_smul a x
#align quadratic_form.map_smul QuadraticForm.map_smul
theorem exists_companion : ∃ B : BilinForm R M, ∀ x y, Q (x + y) = Q x + Q y + B x y :=
Q.exists_companion'
#align quadratic_form.exists_companion QuadraticForm.exists_companion
theorem map_add_add_add_map (x y z : M) :
Q (x + y + z) + (Q x + Q y + Q z) = Q (x + y) + Q (y + z) + Q (z + x) := by
obtain ⟨B, h⟩ := Q.exists_companion
rw [add_comm z x]
simp only [h, map_add, LinearMap.add_apply]
abel
#align quadratic_form.map_add_add_add_map QuadraticForm.map_add_add_add_map
theorem map_add_self (x : M) : Q (x + x) = 4 * Q x := by
rw [← one_smul R x, ← add_smul, map_smul]
norm_num
#align quadratic_form.map_add_self QuadraticForm.map_add_self
-- Porting note: removed @[simp] because it is superseded by `ZeroHomClass.map_zero`
theorem map_zero : Q 0 = 0 := by
rw [← @zero_smul R _ _ _ _ (0 : M), map_smul, zero_mul, zero_mul]
#align quadratic_form.map_zero QuadraticForm.map_zero
instance zeroHomClass : ZeroHomClass (QuadraticForm R M) M R where
map_zero := map_zero
#align quadratic_form.zero_hom_class QuadraticForm.zeroHomClass
theorem map_smul_of_tower [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M] (a : S)
(x : M) : Q (a • x) = (a * a) • Q x := by
rw [← IsScalarTower.algebraMap_smul R a x, map_smul, ← RingHom.map_mul, Algebra.smul_def]
#align quadratic_form.map_smul_of_tower QuadraticForm.map_smul_of_tower
end CommSemiring
section CommRing
variable [CommRing R] [AddCommGroup M]
variable [Module R M] (Q : QuadraticForm R M)
@[simp]
theorem map_neg (x : M) : Q (-x) = Q x := by
rw [← @neg_one_smul R _ _ _ _ x, map_smul, neg_one_mul, neg_neg, one_mul]
#align quadratic_form.map_neg QuadraticForm.map_neg
theorem map_sub (x y : M) : Q (x - y) = Q (y - x) := by rw [← neg_sub, map_neg]
#align quadratic_form.map_sub QuadraticForm.map_sub
@[simp]
theorem polar_zero_left (y : M) : polar Q 0 y = 0 := by
simp only [polar, zero_add, QuadraticForm.map_zero, sub_zero, sub_self]
#align quadratic_form.polar_zero_left QuadraticForm.polar_zero_left
@[simp]
theorem polar_add_left (x x' y : M) : polar Q (x + x') y = polar Q x y + polar Q x' y :=
polar_add_left_iff.mpr <| Q.map_add_add_add_map x x' y
#align quadratic_form.polar_add_left QuadraticForm.polar_add_left
@[simp]
theorem polar_smul_left (a : R) (x y : M) : polar Q (a • x) y = a * polar Q x y := by
obtain ⟨B, h⟩ := Q.exists_companion
simp_rw [polar, h, Q.map_smul, LinearMap.map_smul₂, sub_sub, add_sub_cancel_left, smul_eq_mul]
#align quadratic_form.polar_smul_left QuadraticForm.polar_smul_left
@[simp]
theorem polar_neg_left (x y : M) : polar Q (-x) y = -polar Q x y := by
rw [← neg_one_smul R x, polar_smul_left, neg_one_mul]
#align quadratic_form.polar_neg_left QuadraticForm.polar_neg_left
@[simp]
theorem polar_sub_left (x x' y : M) : polar Q (x - x') y = polar Q x y - polar Q x' y := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_left, polar_neg_left]
#align quadratic_form.polar_sub_left QuadraticForm.polar_sub_left
@[simp]
theorem polar_zero_right (y : M) : polar Q y 0 = 0 := by
simp only [add_zero, polar, QuadraticForm.map_zero, sub_self]
#align quadratic_form.polar_zero_right QuadraticForm.polar_zero_right
@[simp]
theorem polar_add_right (x y y' : M) : polar Q x (y + y') = polar Q x y + polar Q x y' := by
rw [polar_comm Q x, polar_comm Q x, polar_comm Q x, polar_add_left]
#align quadratic_form.polar_add_right QuadraticForm.polar_add_right
@[simp]
theorem polar_smul_right (a : R) (x y : M) : polar Q x (a • y) = a * polar Q x y := by
rw [polar_comm Q x, polar_comm Q x, polar_smul_left]
#align quadratic_form.polar_smul_right QuadraticForm.polar_smul_right
@[simp]
theorem polar_neg_right (x y : M) : polar Q x (-y) = -polar Q x y := by
rw [← neg_one_smul R y, polar_smul_right, neg_one_mul]
#align quadratic_form.polar_neg_right QuadraticForm.polar_neg_right
@[simp]
theorem polar_sub_right (x y y' : M) : polar Q x (y - y') = polar Q x y - polar Q x y' := by
rw [sub_eq_add_neg, sub_eq_add_neg, polar_add_right, polar_neg_right]
#align quadratic_form.polar_sub_right QuadraticForm.polar_sub_right
@[simp]
theorem polar_self (x : M) : polar Q x x = 2 * Q x := by
rw [polar, map_add_self, sub_sub, sub_eq_iff_eq_add, ← two_mul, ← two_mul, ← mul_assoc]
norm_num
#align quadratic_form.polar_self QuadraticForm.polar_self
/-- `QuadraticForm.polar` as a bilinear map -/
@[simps!]
def polarBilin : BilinForm R M :=
LinearMap.mk₂ R (polar Q) (polar_add_left Q) (polar_smul_left Q) (polar_add_right Q)
(polar_smul_right Q)
#align quadratic_form.polar_bilin QuadraticForm.polarBilin
variable [CommSemiring S] [Algebra S R] [Module S M] [IsScalarTower S R M]
@[simp]
| Mathlib/LinearAlgebra/QuadraticForm/Basic.lean | 331 | 332 | theorem polar_smul_left_of_tower (a : S) (x y : M) : polar Q (a • x) y = a • polar Q x y := by |
rw [← IsScalarTower.algebraMap_smul R a x, polar_smul_left, Algebra.smul_def]
|
/-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth
-/
import Mathlib.Analysis.Calculus.Deriv.Inv
import Mathlib.Analysis.NormedSpace.BallAction
import Mathlib.Analysis.SpecialFunctions.ExpDeriv
import Mathlib.Analysis.InnerProductSpace.Calculus
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Geometry.Manifold.Algebra.LieGroup
import Mathlib.Geometry.Manifold.Instances.Real
import Mathlib.Geometry.Manifold.MFDeriv.Basic
#align_import geometry.manifold.instances.sphere from "leanprover-community/mathlib"@"0dc4079202c28226b2841a51eb6d3cc2135bb80f"
/-!
# Manifold structure on the sphere
This file defines stereographic projection from the sphere in an inner product space `E`, and uses
it to put a smooth manifold structure on the sphere.
## Main results
For a unit vector `v` in `E`, the definition `stereographic` gives the stereographic projection
centred at `v`, a partial homeomorphism from the sphere to `(ℝ ∙ v)ᗮ` (the orthogonal complement of
`v`).
For finite-dimensional `E`, we then construct a smooth manifold instance on the sphere; the charts
here are obtained by composing the partial homeomorphisms `stereographic` with arbitrary isometries
from `(ℝ ∙ v)ᗮ` to Euclidean space.
We prove two lemmas about smooth maps:
* `contMDiff_coe_sphere` states that the coercion map from the sphere into `E` is smooth;
this is a useful tool for constructing smooth maps *from* the sphere.
* `contMDiff.codRestrict_sphere` states that a map from a manifold into the sphere is
smooth if its lift to a map to `E` is smooth; this is a useful tool for constructing smooth maps
*to* the sphere.
As an application we prove `contMdiffNegSphere`, that the antipodal map is smooth.
Finally, we equip the `circle` (defined in `Analysis.Complex.Circle` to be the sphere in `ℂ`
centred at `0` of radius `1`) with the following structure:
* a charted space with model space `EuclideanSpace ℝ (Fin 1)` (inherited from `Metric.Sphere`)
* a Lie group with model with corners `𝓡 1`
We furthermore show that `expMapCircle` (defined in `Analysis.Complex.Circle` to be the natural
map `fun t ↦ exp (t * I)` from `ℝ` to `circle`) is smooth.
## Implementation notes
The model space for the charted space instance is `EuclideanSpace ℝ (Fin n)`, where `n` is a
natural number satisfying the typeclass assumption `[Fact (finrank ℝ E = n + 1)]`. This may seem a
little awkward, but it is designed to circumvent the problem that the literal expression for the
dimension of the model space (up to definitional equality) determines the type. If one used the
naive expression `EuclideanSpace ℝ (Fin (finrank ℝ E - 1))` for the model space, then the sphere in
`ℂ` would be a manifold with model space `EuclideanSpace ℝ (Fin (2 - 1))` but not with model space
`EuclideanSpace ℝ (Fin 1)`.
## TODO
Relate the stereographic projection to the inversion of the space.
-/
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
noncomputable section
open Metric FiniteDimensional Function
open scoped Manifold
section StereographicProjection
variable (v : E)
/-! ### Construction of the stereographic projection -/
/-- Stereographic projection, forward direction. This is a map from an inner product space `E` to
the orthogonal complement of an element `v` of `E`. It is smooth away from the affine hyperplane
through `v` parallel to the orthogonal complement. It restricts on the sphere to the stereographic
projection. -/
def stereoToFun (x : E) : (ℝ ∙ v)ᗮ :=
(2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x
#align stereo_to_fun stereoToFun
variable {v}
@[simp]
theorem stereoToFun_apply (x : E) :
stereoToFun v x = (2 / ((1 : ℝ) - innerSL ℝ v x)) • orthogonalProjection (ℝ ∙ v)ᗮ x :=
rfl
#align stereo_to_fun_apply stereoToFun_apply
theorem contDiffOn_stereoToFun :
ContDiffOn ℝ ⊤ (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} := by
refine ContDiffOn.smul ?_ (orthogonalProjection (ℝ ∙ v)ᗮ).contDiff.contDiffOn
refine contDiff_const.contDiffOn.div ?_ ?_
· exact (contDiff_const.sub (innerSL ℝ v).contDiff).contDiffOn
· intro x h h'
exact h (sub_eq_zero.mp h').symm
#align cont_diff_on_stereo_to_fun contDiffOn_stereoToFun
theorem continuousOn_stereoToFun :
ContinuousOn (stereoToFun v) {x : E | innerSL _ v x ≠ (1 : ℝ)} :=
contDiffOn_stereoToFun.continuousOn
#align continuous_on_stereo_to_fun continuousOn_stereoToFun
variable (v)
/-- Auxiliary function for the construction of the reverse direction of the stereographic
projection. This is a map from the orthogonal complement of a unit vector `v` in an inner product
space `E` to `E`; we will later prove that it takes values in the unit sphere.
For most purposes, use `stereoInvFun`, not `stereoInvFunAux`. -/
def stereoInvFunAux (w : E) : E :=
(‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v)
#align stereo_inv_fun_aux stereoInvFunAux
variable {v}
@[simp]
theorem stereoInvFunAux_apply (w : E) :
stereoInvFunAux v w = (‖w‖ ^ 2 + 4)⁻¹ • ((4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v) :=
rfl
#align stereo_inv_fun_aux_apply stereoInvFunAux_apply
theorem stereoInvFunAux_mem (hv : ‖v‖ = 1) {w : E} (hw : w ∈ (ℝ ∙ v)ᗮ) :
stereoInvFunAux v w ∈ sphere (0 : E) 1 := by
have h₁ : (0 : ℝ) < ‖w‖ ^ 2 + 4 := by positivity
suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ = ‖w‖ ^ 2 + 4 by
simp only [mem_sphere_zero_iff_norm, norm_smul, Real.norm_eq_abs, abs_inv, this,
abs_of_pos h₁, stereoInvFunAux_apply, inv_mul_cancel h₁.ne']
suffices ‖(4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v‖ ^ 2 = (‖w‖ ^ 2 + 4) ^ 2 by
simpa [sq_eq_sq_iff_abs_eq_abs, abs_of_pos h₁] using this
rw [Submodule.mem_orthogonal_singleton_iff_inner_left] at hw
simp [norm_add_sq_real, norm_smul, inner_smul_left, inner_smul_right, hw, mul_pow,
Real.norm_eq_abs, hv]
ring
#align stereo_inv_fun_aux_mem stereoInvFunAux_mem
| Mathlib/Geometry/Manifold/Instances/Sphere.lean | 145 | 160 | theorem hasFDerivAt_stereoInvFunAux (v : E) :
HasFDerivAt (stereoInvFunAux v) (ContinuousLinearMap.id ℝ E) 0 := by |
have h₀ : HasFDerivAt (fun w : E => ‖w‖ ^ 2) (0 : E →L[ℝ] ℝ) 0 := by
convert (hasStrictFDerivAt_norm_sq (0 : E)).hasFDerivAt
simp
have h₁ : HasFDerivAt (fun w : E => (‖w‖ ^ 2 + 4)⁻¹) (0 : E →L[ℝ] ℝ) 0 := by
convert (hasFDerivAt_inv _).comp _ (h₀.add (hasFDerivAt_const 4 0)) <;> simp
have h₂ : HasFDerivAt (fun w => (4 : ℝ) • w + (‖w‖ ^ 2 - 4) • v)
((4 : ℝ) • ContinuousLinearMap.id ℝ E) 0 := by
convert ((hasFDerivAt_const (4 : ℝ) 0).smul (hasFDerivAt_id 0)).add
((h₀.sub (hasFDerivAt_const (4 : ℝ) 0)).smul (hasFDerivAt_const v 0)) using 1
ext w
simp
convert h₁.smul h₂ using 1
ext w
simp
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Kenny Lau
-/
import Mathlib.Algebra.BigOperators.GroupWithZero.Finset
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.Module.LinearMap.Basic
import Mathlib.Data.Finset.Preimage
import Mathlib.Data.Set.Finite
import Mathlib.GroupTheory.GroupAction.BigOperators
#align_import data.dfinsupp.basic from "leanprover-community/mathlib"@"6623e6af705e97002a9054c1c05a980180276fc1"
/-!
# Dependent functions with finite support
For a non-dependent version see `data/finsupp.lean`.
## Notation
This file introduces the notation `Π₀ a, β a` as notation for `DFinsupp β`, mirroring the `α →₀ β`
notation used for `Finsupp`. This works for nested binders too, with `Π₀ a b, γ a b` as notation
for `DFinsupp (fun a ↦ DFinsupp (γ a))`.
## Implementation notes
The support is internally represented (in the primed `DFinsupp.support'`) as a `Multiset` that
represents a superset of the true support of the function, quotiented by the always-true relation so
that this does not impact equality. This approach has computational benefits over storing a
`Finset`; it allows us to add together two finitely-supported functions without
having to evaluate the resulting function to recompute its support (which would required
decidability of `b = 0` for `b : β i`).
The true support of the function can still be recovered with `DFinsupp.support`; but these
decidability obligations are now postponed to when the support is actually needed. As a consequence,
there are two ways to sum a `DFinsupp`: with `DFinsupp.sum` which works over an arbitrary function
but requires recomputation of the support and therefore a `Decidable` argument; and with
`DFinsupp.sumAddHom` which requires an additive morphism, using its properties to show that
summing over a superset of the support is sufficient.
`Finsupp` takes an altogether different approach here; it uses `Classical.Decidable` and declares
the `Add` instance as noncomputable. This design difference is independent of the fact that
`DFinsupp` is dependently-typed and `Finsupp` is not; in future, we may want to align these two
definitions, or introduce two more definitions for the other combinations of decisions.
-/
universe u u₁ u₂ v v₁ v₂ v₃ w x y l
variable {ι : Type u} {γ : Type w} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}
variable (β)
/-- A dependent function `Π i, β i` with finite support, with notation `Π₀ i, β i`.
Note that `DFinsupp.support` is the preferred API for accessing the support of the function,
`DFinsupp.support'` is an implementation detail that aids computability; see the implementation
notes in this file for more information. -/
structure DFinsupp [∀ i, Zero (β i)] : Type max u v where mk' ::
/-- The underlying function of a dependent function with finite support (aka `DFinsupp`). -/
toFun : ∀ i, β i
/-- The support of a dependent function with finite support (aka `DFinsupp`). -/
support' : Trunc { s : Multiset ι // ∀ i, i ∈ s ∨ toFun i = 0 }
#align dfinsupp DFinsupp
variable {β}
/-- `Π₀ i, β i` denotes the type of dependent functions with finite support `DFinsupp β`. -/
notation3 "Π₀ "(...)", "r:(scoped f => DFinsupp f) => r
namespace DFinsupp
section Basic
variable [∀ i, Zero (β i)] [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)]
instance instDFunLike : DFunLike (Π₀ i, β i) ι β :=
⟨fun f => f.toFun, fun ⟨f₁, s₁⟩ ⟨f₂, s₁⟩ ↦ fun (h : f₁ = f₂) ↦ by
subst h
congr
apply Subsingleton.elim ⟩
#align dfinsupp.fun_like DFinsupp.instDFunLike
/-- Helper instance for when there are too many metavariables to apply `DFunLike.coeFunForall`
directly. -/
instance : CoeFun (Π₀ i, β i) fun _ => ∀ i, β i :=
inferInstance
@[simp]
theorem toFun_eq_coe (f : Π₀ i, β i) : f.toFun = f :=
rfl
#align dfinsupp.to_fun_eq_coe DFinsupp.toFun_eq_coe
@[ext]
theorem ext {f g : Π₀ i, β i} (h : ∀ i, f i = g i) : f = g :=
DFunLike.ext _ _ h
#align dfinsupp.ext DFinsupp.ext
#align dfinsupp.ext_iff DFunLike.ext_iff
#align dfinsupp.coe_fn_injective DFunLike.coe_injective
lemma ne_iff {f g : Π₀ i, β i} : f ≠ g ↔ ∃ i, f i ≠ g i := DFunLike.ne_iff
instance : Zero (Π₀ i, β i) :=
⟨⟨0, Trunc.mk <| ⟨∅, fun _ => Or.inr rfl⟩⟩⟩
instance : Inhabited (Π₀ i, β i) :=
⟨0⟩
@[simp, norm_cast] lemma coe_mk' (f : ∀ i, β i) (s) : ⇑(⟨f, s⟩ : Π₀ i, β i) = f := rfl
#align dfinsupp.coe_mk' DFinsupp.coe_mk'
@[simp, norm_cast] lemma coe_zero : ⇑(0 : Π₀ i, β i) = 0 := rfl
#align dfinsupp.coe_zero DFinsupp.coe_zero
theorem zero_apply (i : ι) : (0 : Π₀ i, β i) i = 0 :=
rfl
#align dfinsupp.zero_apply DFinsupp.zero_apply
/-- The composition of `f : β₁ → β₂` and `g : Π₀ i, β₁ i` is
`mapRange f hf g : Π₀ i, β₂ i`, well defined when `f 0 = 0`.
This preserves the structure on `f`, and exists in various bundled forms for when `f` is itself
bundled:
* `DFinsupp.mapRange.addMonoidHom`
* `DFinsupp.mapRange.addEquiv`
* `dfinsupp.mapRange.linearMap`
* `dfinsupp.mapRange.linearEquiv`
-/
def mapRange (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (x : Π₀ i, β₁ i) : Π₀ i, β₂ i :=
⟨fun i => f i (x i),
x.support'.map fun s => ⟨s.1, fun i => (s.2 i).imp_right fun h : x i = 0 => by
rw [← hf i, ← h]⟩⟩
#align dfinsupp.map_range DFinsupp.mapRange
@[simp]
theorem mapRange_apply (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) (g : Π₀ i, β₁ i) (i : ι) :
mapRange f hf g i = f i (g i) :=
rfl
#align dfinsupp.map_range_apply DFinsupp.mapRange_apply
@[simp]
theorem mapRange_id (h : ∀ i, id (0 : β₁ i) = 0 := fun i => rfl) (g : Π₀ i : ι, β₁ i) :
mapRange (fun i => (id : β₁ i → β₁ i)) h g = g := by
ext
rfl
#align dfinsupp.map_range_id DFinsupp.mapRange_id
theorem mapRange_comp (f : ∀ i, β₁ i → β₂ i) (f₂ : ∀ i, β i → β₁ i) (hf : ∀ i, f i 0 = 0)
(hf₂ : ∀ i, f₂ i 0 = 0) (h : ∀ i, (f i ∘ f₂ i) 0 = 0) (g : Π₀ i : ι, β i) :
mapRange (fun i => f i ∘ f₂ i) h g = mapRange f hf (mapRange f₂ hf₂ g) := by
ext
simp only [mapRange_apply]; rfl
#align dfinsupp.map_range_comp DFinsupp.mapRange_comp
@[simp]
theorem mapRange_zero (f : ∀ i, β₁ i → β₂ i) (hf : ∀ i, f i 0 = 0) :
mapRange f hf (0 : Π₀ i, β₁ i) = 0 := by
ext
simp only [mapRange_apply, coe_zero, Pi.zero_apply, hf]
#align dfinsupp.map_range_zero DFinsupp.mapRange_zero
/-- Let `f i` be a binary operation `β₁ i → β₂ i → β i` such that `f i 0 0 = 0`.
Then `zipWith f hf` is a binary operation `Π₀ i, β₁ i → Π₀ i, β₂ i → Π₀ i, β i`. -/
def zipWith (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (x : Π₀ i, β₁ i) (y : Π₀ i, β₂ i) :
Π₀ i, β i :=
⟨fun i => f i (x i) (y i), by
refine x.support'.bind fun xs => ?_
refine y.support'.map fun ys => ?_
refine ⟨xs + ys, fun i => ?_⟩
obtain h1 | (h1 : x i = 0) := xs.prop i
· left
rw [Multiset.mem_add]
left
exact h1
obtain h2 | (h2 : y i = 0) := ys.prop i
· left
rw [Multiset.mem_add]
right
exact h2
right; rw [← hf, ← h1, ← h2]⟩
#align dfinsupp.zip_with DFinsupp.zipWith
@[simp]
theorem zipWith_apply (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0) (g₁ : Π₀ i, β₁ i)
(g₂ : Π₀ i, β₂ i) (i : ι) : zipWith f hf g₁ g₂ i = f i (g₁ i) (g₂ i) :=
rfl
#align dfinsupp.zip_with_apply DFinsupp.zipWith_apply
section Piecewise
variable (x y : Π₀ i, β i) (s : Set ι) [∀ i, Decidable (i ∈ s)]
/-- `x.piecewise y s` is the finitely supported function equal to `x` on the set `s`,
and to `y` on its complement. -/
def piecewise : Π₀ i, β i :=
zipWith (fun i x y => if i ∈ s then x else y) (fun _ => ite_self 0) x y
#align dfinsupp.piecewise DFinsupp.piecewise
theorem piecewise_apply (i : ι) : x.piecewise y s i = if i ∈ s then x i else y i :=
zipWith_apply _ _ x y i
#align dfinsupp.piecewise_apply DFinsupp.piecewise_apply
@[simp, norm_cast]
theorem coe_piecewise : ⇑(x.piecewise y s) = s.piecewise x y := by
ext
apply piecewise_apply
#align dfinsupp.coe_piecewise DFinsupp.coe_piecewise
end Piecewise
end Basic
section Algebra
instance [∀ i, AddZeroClass (β i)] : Add (Π₀ i, β i) :=
⟨zipWith (fun _ => (· + ·)) fun _ => add_zero 0⟩
theorem add_apply [∀ i, AddZeroClass (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) :
(g₁ + g₂) i = g₁ i + g₂ i :=
rfl
#align dfinsupp.add_apply DFinsupp.add_apply
@[simp, norm_cast]
theorem coe_add [∀ i, AddZeroClass (β i)] (g₁ g₂ : Π₀ i, β i) : ⇑(g₁ + g₂) = g₁ + g₂ :=
rfl
#align dfinsupp.coe_add DFinsupp.coe_add
instance addZeroClass [∀ i, AddZeroClass (β i)] : AddZeroClass (Π₀ i, β i) :=
DFunLike.coe_injective.addZeroClass _ coe_zero coe_add
instance instIsLeftCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsLeftCancelAdd (β i)] :
IsLeftCancelAdd (Π₀ i, β i) where
add_left_cancel _ _ _ h := ext fun x => add_left_cancel <| DFunLike.congr_fun h x
instance instIsRightCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsRightCancelAdd (β i)] :
IsRightCancelAdd (Π₀ i, β i) where
add_right_cancel _ _ _ h := ext fun x => add_right_cancel <| DFunLike.congr_fun h x
instance instIsCancelAdd [∀ i, AddZeroClass (β i)] [∀ i, IsCancelAdd (β i)] :
IsCancelAdd (Π₀ i, β i) where
/-- Note the general `SMul` instance doesn't apply as `ℕ` is not distributive
unless `β i`'s addition is commutative. -/
instance hasNatScalar [∀ i, AddMonoid (β i)] : SMul ℕ (Π₀ i, β i) :=
⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => nsmul_zero _⟩
#align dfinsupp.has_nat_scalar DFinsupp.hasNatScalar
theorem nsmul_apply [∀ i, AddMonoid (β i)] (b : ℕ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i :=
rfl
#align dfinsupp.nsmul_apply DFinsupp.nsmul_apply
@[simp, norm_cast]
theorem coe_nsmul [∀ i, AddMonoid (β i)] (b : ℕ) (v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v :=
rfl
#align dfinsupp.coe_nsmul DFinsupp.coe_nsmul
instance [∀ i, AddMonoid (β i)] : AddMonoid (Π₀ i, β i) :=
DFunLike.coe_injective.addMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _
/-- Coercion from a `DFinsupp` to a pi type is an `AddMonoidHom`. -/
def coeFnAddMonoidHom [∀ i, AddZeroClass (β i)] : (Π₀ i, β i) →+ ∀ i, β i where
toFun := (⇑)
map_zero' := coe_zero
map_add' := coe_add
#align dfinsupp.coe_fn_add_monoid_hom DFinsupp.coeFnAddMonoidHom
/-- Evaluation at a point is an `AddMonoidHom`. This is the finitely-supported version of
`Pi.evalAddMonoidHom`. -/
def evalAddMonoidHom [∀ i, AddZeroClass (β i)] (i : ι) : (Π₀ i, β i) →+ β i :=
(Pi.evalAddMonoidHom β i).comp coeFnAddMonoidHom
#align dfinsupp.eval_add_monoid_hom DFinsupp.evalAddMonoidHom
instance addCommMonoid [∀ i, AddCommMonoid (β i)] : AddCommMonoid (Π₀ i, β i) :=
DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add fun _ _ => coe_nsmul _ _
@[simp, norm_cast]
theorem coe_finset_sum {α} [∀ i, AddCommMonoid (β i)] (s : Finset α) (g : α → Π₀ i, β i) :
⇑(∑ a ∈ s, g a) = ∑ a ∈ s, ⇑(g a) :=
map_sum coeFnAddMonoidHom g s
#align dfinsupp.coe_finset_sum DFinsupp.coe_finset_sum
@[simp]
theorem finset_sum_apply {α} [∀ i, AddCommMonoid (β i)] (s : Finset α) (g : α → Π₀ i, β i) (i : ι) :
(∑ a ∈ s, g a) i = ∑ a ∈ s, g a i :=
map_sum (evalAddMonoidHom i) g s
#align dfinsupp.finset_sum_apply DFinsupp.finset_sum_apply
instance [∀ i, AddGroup (β i)] : Neg (Π₀ i, β i) :=
⟨fun f => f.mapRange (fun _ => Neg.neg) fun _ => neg_zero⟩
theorem neg_apply [∀ i, AddGroup (β i)] (g : Π₀ i, β i) (i : ι) : (-g) i = -g i :=
rfl
#align dfinsupp.neg_apply DFinsupp.neg_apply
@[simp, norm_cast] lemma coe_neg [∀ i, AddGroup (β i)] (g : Π₀ i, β i) : ⇑(-g) = -g := rfl
#align dfinsupp.coe_neg DFinsupp.coe_neg
instance [∀ i, AddGroup (β i)] : Sub (Π₀ i, β i) :=
⟨zipWith (fun _ => Sub.sub) fun _ => sub_zero 0⟩
theorem sub_apply [∀ i, AddGroup (β i)] (g₁ g₂ : Π₀ i, β i) (i : ι) : (g₁ - g₂) i = g₁ i - g₂ i :=
rfl
#align dfinsupp.sub_apply DFinsupp.sub_apply
@[simp, norm_cast]
theorem coe_sub [∀ i, AddGroup (β i)] (g₁ g₂ : Π₀ i, β i) : ⇑(g₁ - g₂) = g₁ - g₂ :=
rfl
#align dfinsupp.coe_sub DFinsupp.coe_sub
/-- Note the general `SMul` instance doesn't apply as `ℤ` is not distributive
unless `β i`'s addition is commutative. -/
instance hasIntScalar [∀ i, AddGroup (β i)] : SMul ℤ (Π₀ i, β i) :=
⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => zsmul_zero _⟩
#align dfinsupp.has_int_scalar DFinsupp.hasIntScalar
theorem zsmul_apply [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i :=
rfl
#align dfinsupp.zsmul_apply DFinsupp.zsmul_apply
@[simp, norm_cast]
theorem coe_zsmul [∀ i, AddGroup (β i)] (b : ℤ) (v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v :=
rfl
#align dfinsupp.coe_zsmul DFinsupp.coe_zsmul
instance [∀ i, AddGroup (β i)] : AddGroup (Π₀ i, β i) :=
DFunLike.coe_injective.addGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _)
fun _ _ => coe_zsmul _ _
instance addCommGroup [∀ i, AddCommGroup (β i)] : AddCommGroup (Π₀ i, β i) :=
DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub (fun _ _ => coe_nsmul _ _)
fun _ _ => coe_zsmul _ _
/-- Dependent functions with finite support inherit a semiring action from an action on each
coordinate. -/
instance [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] : SMul γ (Π₀ i, β i) :=
⟨fun c v => v.mapRange (fun _ => (c • ·)) fun _ => smul_zero _⟩
theorem smul_apply [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (b : γ)
(v : Π₀ i, β i) (i : ι) : (b • v) i = b • v i :=
rfl
#align dfinsupp.smul_apply DFinsupp.smul_apply
@[simp, norm_cast]
theorem coe_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (b : γ)
(v : Π₀ i, β i) : ⇑(b • v) = b • ⇑v :=
rfl
#align dfinsupp.coe_smul DFinsupp.coe_smul
instance smulCommClass {δ : Type*} [Monoid γ] [Monoid δ] [∀ i, AddMonoid (β i)]
[∀ i, DistribMulAction γ (β i)] [∀ i, DistribMulAction δ (β i)] [∀ i, SMulCommClass γ δ (β i)] :
SMulCommClass γ δ (Π₀ i, β i) where
smul_comm r s m := ext fun i => by simp only [smul_apply, smul_comm r s (m i)]
instance isScalarTower {δ : Type*} [Monoid γ] [Monoid δ] [∀ i, AddMonoid (β i)]
[∀ i, DistribMulAction γ (β i)] [∀ i, DistribMulAction δ (β i)] [SMul γ δ]
[∀ i, IsScalarTower γ δ (β i)] : IsScalarTower γ δ (Π₀ i, β i) where
smul_assoc r s m := ext fun i => by simp only [smul_apply, smul_assoc r s (m i)]
instance isCentralScalar [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)]
[∀ i, DistribMulAction γᵐᵒᵖ (β i)] [∀ i, IsCentralScalar γ (β i)] :
IsCentralScalar γ (Π₀ i, β i) where
op_smul_eq_smul r m := ext fun i => by simp only [smul_apply, op_smul_eq_smul r (m i)]
/-- Dependent functions with finite support inherit a `DistribMulAction` structure from such a
structure on each coordinate. -/
instance distribMulAction [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] :
DistribMulAction γ (Π₀ i, β i) :=
Function.Injective.distribMulAction coeFnAddMonoidHom DFunLike.coe_injective coe_smul
/-- Dependent functions with finite support inherit a module structure from such a structure on
each coordinate. -/
instance module [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] :
Module γ (Π₀ i, β i) :=
{ inferInstanceAs (DistribMulAction γ (Π₀ i, β i)) with
zero_smul := fun c => ext fun i => by simp only [smul_apply, zero_smul, zero_apply]
add_smul := fun c x y => ext fun i => by simp only [add_apply, smul_apply, add_smul] }
#align dfinsupp.module DFinsupp.module
end Algebra
section FilterAndSubtypeDomain
/-- `Filter p f` is the function which is `f i` if `p i` is true and 0 otherwise. -/
def filter [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (x : Π₀ i, β i) : Π₀ i, β i :=
⟨fun i => if p i then x i else 0,
x.support'.map fun xs =>
⟨xs.1, fun i => (xs.prop i).imp_right fun H : x i = 0 => by simp only [H, ite_self]⟩⟩
#align dfinsupp.filter DFinsupp.filter
@[simp]
theorem filter_apply [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (i : ι) (f : Π₀ i, β i) :
f.filter p i = if p i then f i else 0 :=
rfl
#align dfinsupp.filter_apply DFinsupp.filter_apply
theorem filter_apply_pos [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] (f : Π₀ i, β i) {i : ι}
(h : p i) : f.filter p i = f i := by simp only [filter_apply, if_pos h]
#align dfinsupp.filter_apply_pos DFinsupp.filter_apply_pos
theorem filter_apply_neg [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] (f : Π₀ i, β i) {i : ι}
(h : ¬p i) : f.filter p i = 0 := by simp only [filter_apply, if_neg h]
#align dfinsupp.filter_apply_neg DFinsupp.filter_apply_neg
theorem filter_pos_add_filter_neg [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i) (p : ι → Prop)
[DecidablePred p] : (f.filter p + f.filter fun i => ¬p i) = f :=
ext fun i => by
simp only [add_apply, filter_apply]; split_ifs <;> simp only [add_zero, zero_add]
#align dfinsupp.filter_pos_add_filter_neg DFinsupp.filter_pos_add_filter_neg
@[simp]
theorem filter_zero [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] :
(0 : Π₀ i, β i).filter p = 0 := by
ext
simp
#align dfinsupp.filter_zero DFinsupp.filter_zero
@[simp]
theorem filter_add [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] (f g : Π₀ i, β i) :
(f + g).filter p = f.filter p + g.filter p := by
ext
simp [ite_add_zero]
#align dfinsupp.filter_add DFinsupp.filter_add
@[simp]
theorem filter_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)] (p : ι → Prop)
[DecidablePred p] (r : γ) (f : Π₀ i, β i) : (r • f).filter p = r • f.filter p := by
ext
simp [smul_apply, smul_ite]
#align dfinsupp.filter_smul DFinsupp.filter_smul
variable (γ β)
/-- `DFinsupp.filter` as an `AddMonoidHom`. -/
@[simps]
def filterAddMonoidHom [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] :
(Π₀ i, β i) →+ Π₀ i, β i where
toFun := filter p
map_zero' := filter_zero p
map_add' := filter_add p
#align dfinsupp.filter_add_monoid_hom DFinsupp.filterAddMonoidHom
#align dfinsupp.filter_add_monoid_hom_apply DFinsupp.filterAddMonoidHom_apply
/-- `DFinsupp.filter` as a `LinearMap`. -/
@[simps]
def filterLinearMap [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)] (p : ι → Prop)
[DecidablePred p] : (Π₀ i, β i) →ₗ[γ] Π₀ i, β i where
toFun := filter p
map_add' := filter_add p
map_smul' := filter_smul p
#align dfinsupp.filter_linear_map DFinsupp.filterLinearMap
#align dfinsupp.filter_linear_map_apply DFinsupp.filterLinearMap_apply
variable {γ β}
@[simp]
theorem filter_neg [∀ i, AddGroup (β i)] (p : ι → Prop) [DecidablePred p] (f : Π₀ i, β i) :
(-f).filter p = -f.filter p :=
(filterAddMonoidHom β p).map_neg f
#align dfinsupp.filter_neg DFinsupp.filter_neg
@[simp]
theorem filter_sub [∀ i, AddGroup (β i)] (p : ι → Prop) [DecidablePred p] (f g : Π₀ i, β i) :
(f - g).filter p = f.filter p - g.filter p :=
(filterAddMonoidHom β p).map_sub f g
#align dfinsupp.filter_sub DFinsupp.filter_sub
/-- `subtypeDomain p f` is the restriction of the finitely supported function
`f` to the subtype `p`. -/
def subtypeDomain [∀ i, Zero (β i)] (p : ι → Prop) [DecidablePred p] (x : Π₀ i, β i) :
Π₀ i : Subtype p, β i :=
⟨fun i => x (i : ι),
x.support'.map fun xs =>
⟨(Multiset.filter p xs.1).attach.map fun j => ⟨j.1, (Multiset.mem_filter.1 j.2).2⟩, fun i =>
(xs.prop i).imp_left fun H =>
Multiset.mem_map.2
⟨⟨i, Multiset.mem_filter.2 ⟨H, i.2⟩⟩, Multiset.mem_attach _ _, Subtype.eta _ _⟩⟩⟩
#align dfinsupp.subtype_domain DFinsupp.subtypeDomain
@[simp]
theorem subtypeDomain_zero [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] :
subtypeDomain p (0 : Π₀ i, β i) = 0 :=
rfl
#align dfinsupp.subtype_domain_zero DFinsupp.subtypeDomain_zero
@[simp]
theorem subtypeDomain_apply [∀ i, Zero (β i)] {p : ι → Prop} [DecidablePred p] {i : Subtype p}
{v : Π₀ i, β i} : (subtypeDomain p v) i = v i :=
rfl
#align dfinsupp.subtype_domain_apply DFinsupp.subtypeDomain_apply
@[simp]
theorem subtypeDomain_add [∀ i, AddZeroClass (β i)] {p : ι → Prop} [DecidablePred p]
(v v' : Π₀ i, β i) : (v + v').subtypeDomain p = v.subtypeDomain p + v'.subtypeDomain p :=
DFunLike.coe_injective rfl
#align dfinsupp.subtype_domain_add DFinsupp.subtypeDomain_add
@[simp]
theorem subtypeDomain_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)]
{p : ι → Prop} [DecidablePred p] (r : γ) (f : Π₀ i, β i) :
(r • f).subtypeDomain p = r • f.subtypeDomain p :=
DFunLike.coe_injective rfl
#align dfinsupp.subtype_domain_smul DFinsupp.subtypeDomain_smul
variable (γ β)
/-- `subtypeDomain` but as an `AddMonoidHom`. -/
@[simps]
def subtypeDomainAddMonoidHom [∀ i, AddZeroClass (β i)] (p : ι → Prop) [DecidablePred p] :
(Π₀ i : ι, β i) →+ Π₀ i : Subtype p, β i where
toFun := subtypeDomain p
map_zero' := subtypeDomain_zero
map_add' := subtypeDomain_add
#align dfinsupp.subtype_domain_add_monoid_hom DFinsupp.subtypeDomainAddMonoidHom
#align dfinsupp.subtype_domain_add_monoid_hom_apply DFinsupp.subtypeDomainAddMonoidHom_apply
/-- `DFinsupp.subtypeDomain` as a `LinearMap`. -/
@[simps]
def subtypeDomainLinearMap [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)]
(p : ι → Prop) [DecidablePred p] : (Π₀ i, β i) →ₗ[γ] Π₀ i : Subtype p, β i where
toFun := subtypeDomain p
map_add' := subtypeDomain_add
map_smul' := subtypeDomain_smul
#align dfinsupp.subtype_domain_linear_map DFinsupp.subtypeDomainLinearMap
#align dfinsupp.subtype_domain_linear_map_apply DFinsupp.subtypeDomainLinearMap_apply
variable {γ β}
@[simp]
theorem subtypeDomain_neg [∀ i, AddGroup (β i)] {p : ι → Prop} [DecidablePred p] {v : Π₀ i, β i} :
(-v).subtypeDomain p = -v.subtypeDomain p :=
DFunLike.coe_injective rfl
#align dfinsupp.subtype_domain_neg DFinsupp.subtypeDomain_neg
@[simp]
theorem subtypeDomain_sub [∀ i, AddGroup (β i)] {p : ι → Prop} [DecidablePred p]
{v v' : Π₀ i, β i} : (v - v').subtypeDomain p = v.subtypeDomain p - v'.subtypeDomain p :=
DFunLike.coe_injective rfl
#align dfinsupp.subtype_domain_sub DFinsupp.subtypeDomain_sub
end FilterAndSubtypeDomain
variable [DecidableEq ι]
section Basic
variable [∀ i, Zero (β i)]
theorem finite_support (f : Π₀ i, β i) : Set.Finite { i | f i ≠ 0 } :=
Trunc.induction_on f.support' fun xs ↦
xs.1.finite_toSet.subset fun i H ↦ ((xs.prop i).resolve_right H)
#align dfinsupp.finite_support DFinsupp.finite_support
/-- Create an element of `Π₀ i, β i` from a finset `s` and a function `x`
defined on this `Finset`. -/
def mk (s : Finset ι) (x : ∀ i : (↑s : Set ι), β (i : ι)) : Π₀ i, β i :=
⟨fun i => if H : i ∈ s then x ⟨i, H⟩ else 0,
Trunc.mk ⟨s.1, fun i => if H : i ∈ s then Or.inl H else Or.inr <| dif_neg H⟩⟩
#align dfinsupp.mk DFinsupp.mk
variable {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i} {i : ι}
@[simp]
theorem mk_apply : (mk s x : ∀ i, β i) i = if H : i ∈ s then x ⟨i, H⟩ else 0 :=
rfl
#align dfinsupp.mk_apply DFinsupp.mk_apply
theorem mk_of_mem (hi : i ∈ s) : (mk s x : ∀ i, β i) i = x ⟨i, hi⟩ :=
dif_pos hi
#align dfinsupp.mk_of_mem DFinsupp.mk_of_mem
theorem mk_of_not_mem (hi : i ∉ s) : (mk s x : ∀ i, β i) i = 0 :=
dif_neg hi
#align dfinsupp.mk_of_not_mem DFinsupp.mk_of_not_mem
theorem mk_injective (s : Finset ι) : Function.Injective (@mk ι β _ _ s) := by
intro x y H
ext i
have h1 : (mk s x : ∀ i, β i) i = (mk s y : ∀ i, β i) i := by rw [H]
obtain ⟨i, hi : i ∈ s⟩ := i
dsimp only [mk_apply, Subtype.coe_mk] at h1
simpa only [dif_pos hi] using h1
#align dfinsupp.mk_injective DFinsupp.mk_injective
instance unique [∀ i, Subsingleton (β i)] : Unique (Π₀ i, β i) :=
DFunLike.coe_injective.unique
#align dfinsupp.unique DFinsupp.unique
instance uniqueOfIsEmpty [IsEmpty ι] : Unique (Π₀ i, β i) :=
DFunLike.coe_injective.unique
#align dfinsupp.unique_of_is_empty DFinsupp.uniqueOfIsEmpty
/-- Given `Fintype ι`, `equivFunOnFintype` is the `Equiv` between `Π₀ i, β i` and `Π i, β i`.
(All dependent functions on a finite type are finitely supported.) -/
@[simps apply]
def equivFunOnFintype [Fintype ι] : (Π₀ i, β i) ≃ ∀ i, β i where
toFun := (⇑)
invFun f := ⟨f, Trunc.mk ⟨Finset.univ.1, fun _ => Or.inl <| Finset.mem_univ_val _⟩⟩
left_inv _ := DFunLike.coe_injective rfl
right_inv _ := rfl
#align dfinsupp.equiv_fun_on_fintype DFinsupp.equivFunOnFintype
#align dfinsupp.equiv_fun_on_fintype_apply DFinsupp.equivFunOnFintype_apply
@[simp]
theorem equivFunOnFintype_symm_coe [Fintype ι] (f : Π₀ i, β i) : equivFunOnFintype.symm f = f :=
Equiv.symm_apply_apply _ _
#align dfinsupp.equiv_fun_on_fintype_symm_coe DFinsupp.equivFunOnFintype_symm_coe
/-- The function `single i b : Π₀ i, β i` sends `i` to `b`
and all other points to `0`. -/
def single (i : ι) (b : β i) : Π₀ i, β i :=
⟨Pi.single i b,
Trunc.mk ⟨{i}, fun j => (Decidable.eq_or_ne j i).imp (by simp) fun h => Pi.single_eq_of_ne h _⟩⟩
#align dfinsupp.single DFinsupp.single
theorem single_eq_pi_single {i b} : ⇑(single i b : Π₀ i, β i) = Pi.single i b :=
rfl
#align dfinsupp.single_eq_pi_single DFinsupp.single_eq_pi_single
@[simp]
theorem single_apply {i i' b} :
(single i b : Π₀ i, β i) i' = if h : i = i' then Eq.recOn h b else 0 := by
rw [single_eq_pi_single, Pi.single, Function.update]
simp [@eq_comm _ i i']
#align dfinsupp.single_apply DFinsupp.single_apply
@[simp]
theorem single_zero (i) : (single i 0 : Π₀ i, β i) = 0 :=
DFunLike.coe_injective <| Pi.single_zero _
#align dfinsupp.single_zero DFinsupp.single_zero
-- @[simp] -- Porting note (#10618): simp can prove this
theorem single_eq_same {i b} : (single i b : Π₀ i, β i) i = b := by
simp only [single_apply, dite_eq_ite, ite_true]
#align dfinsupp.single_eq_same DFinsupp.single_eq_same
theorem single_eq_of_ne {i i' b} (h : i ≠ i') : (single i b : Π₀ i, β i) i' = 0 := by
simp only [single_apply, dif_neg h]
#align dfinsupp.single_eq_of_ne DFinsupp.single_eq_of_ne
theorem single_injective {i} : Function.Injective (single i : β i → Π₀ i, β i) := fun _ _ H =>
Pi.single_injective β i <| DFunLike.coe_injective.eq_iff.mpr H
#align dfinsupp.single_injective DFinsupp.single_injective
/-- Like `Finsupp.single_eq_single_iff`, but with a `HEq` due to dependent types -/
theorem single_eq_single_iff (i j : ι) (xi : β i) (xj : β j) :
DFinsupp.single i xi = DFinsupp.single j xj ↔ i = j ∧ HEq xi xj ∨ xi = 0 ∧ xj = 0 := by
constructor
· intro h
by_cases hij : i = j
· subst hij
exact Or.inl ⟨rfl, heq_of_eq (DFinsupp.single_injective h)⟩
· have h_coe : ⇑(DFinsupp.single i xi) = DFinsupp.single j xj := congr_arg (⇑) h
have hci := congr_fun h_coe i
have hcj := congr_fun h_coe j
rw [DFinsupp.single_eq_same] at hci hcj
rw [DFinsupp.single_eq_of_ne (Ne.symm hij)] at hci
rw [DFinsupp.single_eq_of_ne hij] at hcj
exact Or.inr ⟨hci, hcj.symm⟩
· rintro (⟨rfl, hxi⟩ | ⟨hi, hj⟩)
· rw [eq_of_heq hxi]
· rw [hi, hj, DFinsupp.single_zero, DFinsupp.single_zero]
#align dfinsupp.single_eq_single_iff DFinsupp.single_eq_single_iff
/-- `DFinsupp.single a b` is injective in `a`. For the statement that it is injective in `b`, see
`DFinsupp.single_injective` -/
theorem single_left_injective {b : ∀ i : ι, β i} (h : ∀ i, b i ≠ 0) :
Function.Injective (fun i => single i (b i) : ι → Π₀ i, β i) := fun _ _ H =>
(((single_eq_single_iff _ _ _ _).mp H).resolve_right fun hb => h _ hb.1).left
#align dfinsupp.single_left_injective DFinsupp.single_left_injective
@[simp]
theorem single_eq_zero {i : ι} {xi : β i} : single i xi = 0 ↔ xi = 0 := by
rw [← single_zero i, single_eq_single_iff]
simp
#align dfinsupp.single_eq_zero DFinsupp.single_eq_zero
theorem filter_single (p : ι → Prop) [DecidablePred p] (i : ι) (x : β i) :
(single i x).filter p = if p i then single i x else 0 := by
ext j
have := apply_ite (fun x : Π₀ i, β i => x j) (p i) (single i x) 0
dsimp at this
rw [filter_apply, this]
obtain rfl | hij := Decidable.eq_or_ne i j
· rfl
· rw [single_eq_of_ne hij, ite_self, ite_self]
#align dfinsupp.filter_single DFinsupp.filter_single
@[simp]
theorem filter_single_pos {p : ι → Prop} [DecidablePred p] (i : ι) (x : β i) (h : p i) :
(single i x).filter p = single i x := by rw [filter_single, if_pos h]
#align dfinsupp.filter_single_pos DFinsupp.filter_single_pos
@[simp]
theorem filter_single_neg {p : ι → Prop} [DecidablePred p] (i : ι) (x : β i) (h : ¬p i) :
(single i x).filter p = 0 := by rw [filter_single, if_neg h]
#align dfinsupp.filter_single_neg DFinsupp.filter_single_neg
/-- Equality of sigma types is sufficient (but not necessary) to show equality of `DFinsupp`s. -/
theorem single_eq_of_sigma_eq {i j} {xi : β i} {xj : β j} (h : (⟨i, xi⟩ : Sigma β) = ⟨j, xj⟩) :
DFinsupp.single i xi = DFinsupp.single j xj := by
cases h
rfl
#align dfinsupp.single_eq_of_sigma_eq DFinsupp.single_eq_of_sigma_eq
@[simp]
theorem equivFunOnFintype_single [Fintype ι] (i : ι) (m : β i) :
(@DFinsupp.equivFunOnFintype ι β _ _) (DFinsupp.single i m) = Pi.single i m := by
ext x
dsimp [Pi.single, Function.update]
simp [DFinsupp.single_eq_pi_single, @eq_comm _ i]
#align dfinsupp.equiv_fun_on_fintype_single DFinsupp.equivFunOnFintype_single
@[simp]
theorem equivFunOnFintype_symm_single [Fintype ι] (i : ι) (m : β i) :
(@DFinsupp.equivFunOnFintype ι β _ _).symm (Pi.single i m) = DFinsupp.single i m := by
ext i'
simp only [← single_eq_pi_single, equivFunOnFintype_symm_coe]
#align dfinsupp.equiv_fun_on_fintype_symm_single DFinsupp.equivFunOnFintype_symm_single
section SingleAndZipWith
variable [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)]
@[simp]
theorem zipWith_single_single (f : ∀ i, β₁ i → β₂ i → β i) (hf : ∀ i, f i 0 0 = 0)
{i} (b₁ : β₁ i) (b₂ : β₂ i) :
zipWith f hf (single i b₁) (single i b₂) = single i (f i b₁ b₂) := by
ext j
rw [zipWith_apply]
obtain rfl | hij := Decidable.eq_or_ne i j
· rw [single_eq_same, single_eq_same, single_eq_same]
· rw [single_eq_of_ne hij, single_eq_of_ne hij, single_eq_of_ne hij, hf]
end SingleAndZipWith
/-- Redefine `f i` to be `0`. -/
def erase (i : ι) (x : Π₀ i, β i) : Π₀ i, β i :=
⟨fun j ↦ if j = i then 0 else x.1 j,
x.support'.map fun xs ↦ ⟨xs.1, fun j ↦ (xs.prop j).imp_right (by simp only [·, ite_self])⟩⟩
#align dfinsupp.erase DFinsupp.erase
@[simp]
theorem erase_apply {i j : ι} {f : Π₀ i, β i} : (f.erase i) j = if j = i then 0 else f j :=
rfl
#align dfinsupp.erase_apply DFinsupp.erase_apply
-- @[simp] -- Porting note (#10618): simp can prove this
theorem erase_same {i : ι} {f : Π₀ i, β i} : (f.erase i) i = 0 := by simp
#align dfinsupp.erase_same DFinsupp.erase_same
theorem erase_ne {i i' : ι} {f : Π₀ i, β i} (h : i' ≠ i) : (f.erase i) i' = f i' := by simp [h]
#align dfinsupp.erase_ne DFinsupp.erase_ne
theorem piecewise_single_erase (x : Π₀ i, β i) (i : ι)
[∀ i' : ι, Decidable <| (i' ∈ ({i} : Set ι))] : -- Porting note: added Decidable hypothesis
(single i (x i)).piecewise (x.erase i) {i} = x := by
ext j; rw [piecewise_apply]; split_ifs with h
· rw [(id h : j = i), single_eq_same]
· exact erase_ne h
#align dfinsupp.piecewise_single_erase DFinsupp.piecewise_single_erase
theorem erase_eq_sub_single {β : ι → Type*} [∀ i, AddGroup (β i)] (f : Π₀ i, β i) (i : ι) :
f.erase i = f - single i (f i) := by
ext j
rcases eq_or_ne i j with (rfl | h)
· simp
· simp [erase_ne h.symm, single_eq_of_ne h, @eq_comm _ j, h]
#align dfinsupp.erase_eq_sub_single DFinsupp.erase_eq_sub_single
@[simp]
theorem erase_zero (i : ι) : erase i (0 : Π₀ i, β i) = 0 :=
ext fun _ => ite_self _
#align dfinsupp.erase_zero DFinsupp.erase_zero
@[simp]
theorem filter_ne_eq_erase (f : Π₀ i, β i) (i : ι) : f.filter (· ≠ i) = f.erase i := by
ext1 j
simp only [DFinsupp.filter_apply, DFinsupp.erase_apply, ite_not]
#align dfinsupp.filter_ne_eq_erase DFinsupp.filter_ne_eq_erase
@[simp]
theorem filter_ne_eq_erase' (f : Π₀ i, β i) (i : ι) : f.filter (i ≠ ·) = f.erase i := by
rw [← filter_ne_eq_erase f i]
congr with j
exact ne_comm
#align dfinsupp.filter_ne_eq_erase' DFinsupp.filter_ne_eq_erase'
theorem erase_single (j : ι) (i : ι) (x : β i) :
(single i x).erase j = if i = j then 0 else single i x := by
rw [← filter_ne_eq_erase, filter_single, ite_not]
#align dfinsupp.erase_single DFinsupp.erase_single
@[simp]
theorem erase_single_same (i : ι) (x : β i) : (single i x).erase i = 0 := by
rw [erase_single, if_pos rfl]
#align dfinsupp.erase_single_same DFinsupp.erase_single_same
@[simp]
theorem erase_single_ne {i j : ι} (x : β i) (h : i ≠ j) : (single i x).erase j = single i x := by
rw [erase_single, if_neg h]
#align dfinsupp.erase_single_ne DFinsupp.erase_single_ne
section Update
variable (f : Π₀ i, β i) (i) (b : β i)
/-- Replace the value of a `Π₀ i, β i` at a given point `i : ι` by a given value `b : β i`.
If `b = 0`, this amounts to removing `i` from the support.
Otherwise, `i` is added to it.
This is the (dependent) finitely-supported version of `Function.update`. -/
def update : Π₀ i, β i :=
⟨Function.update f i b,
f.support'.map fun s =>
⟨i ::ₘ s.1, fun j => by
rcases eq_or_ne i j with (rfl | hi)
· simp
· obtain hj | (hj : f j = 0) := s.prop j
· exact Or.inl (Multiset.mem_cons_of_mem hj)
· exact Or.inr ((Function.update_noteq hi.symm b _).trans hj)⟩⟩
#align dfinsupp.update DFinsupp.update
variable (j : ι)
@[simp, norm_cast] lemma coe_update : (f.update i b : ∀ i : ι, β i) = Function.update f i b := rfl
#align dfinsupp.coe_update DFinsupp.coe_update
@[simp]
theorem update_self : f.update i (f i) = f := by
ext
simp
#align dfinsupp.update_self DFinsupp.update_self
@[simp]
theorem update_eq_erase : f.update i 0 = f.erase i := by
ext j
rcases eq_or_ne i j with (rfl | hi)
· simp
· simp [hi.symm]
#align dfinsupp.update_eq_erase DFinsupp.update_eq_erase
theorem update_eq_single_add_erase {β : ι → Type*} [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i)
(i : ι) (b : β i) : f.update i b = single i b + f.erase i := by
ext j
rcases eq_or_ne i j with (rfl | h)
· simp
· simp [Function.update_noteq h.symm, h, erase_ne, h.symm]
#align dfinsupp.update_eq_single_add_erase DFinsupp.update_eq_single_add_erase
theorem update_eq_erase_add_single {β : ι → Type*} [∀ i, AddZeroClass (β i)] (f : Π₀ i, β i)
(i : ι) (b : β i) : f.update i b = f.erase i + single i b := by
ext j
rcases eq_or_ne i j with (rfl | h)
· simp
· simp [Function.update_noteq h.symm, h, erase_ne, h.symm]
#align dfinsupp.update_eq_erase_add_single DFinsupp.update_eq_erase_add_single
theorem update_eq_sub_add_single {β : ι → Type*} [∀ i, AddGroup (β i)] (f : Π₀ i, β i) (i : ι)
(b : β i) : f.update i b = f - single i (f i) + single i b := by
rw [update_eq_erase_add_single f i b, erase_eq_sub_single f i]
#align dfinsupp.update_eq_sub_add_single DFinsupp.update_eq_sub_add_single
end Update
end Basic
section AddMonoid
variable [∀ i, AddZeroClass (β i)]
@[simp]
theorem single_add (i : ι) (b₁ b₂ : β i) : single i (b₁ + b₂) = single i b₁ + single i b₂ :=
(zipWith_single_single (fun _ => (· + ·)) _ b₁ b₂).symm
#align dfinsupp.single_add DFinsupp.single_add
@[simp]
theorem erase_add (i : ι) (f₁ f₂ : Π₀ i, β i) : erase i (f₁ + f₂) = erase i f₁ + erase i f₂ :=
ext fun _ => by simp [ite_zero_add]
#align dfinsupp.erase_add DFinsupp.erase_add
variable (β)
/-- `DFinsupp.single` as an `AddMonoidHom`. -/
@[simps]
def singleAddHom (i : ι) : β i →+ Π₀ i, β i where
toFun := single i
map_zero' := single_zero i
map_add' := single_add i
#align dfinsupp.single_add_hom DFinsupp.singleAddHom
#align dfinsupp.single_add_hom_apply DFinsupp.singleAddHom_apply
/-- `DFinsupp.erase` as an `AddMonoidHom`. -/
@[simps]
def eraseAddHom (i : ι) : (Π₀ i, β i) →+ Π₀ i, β i where
toFun := erase i
map_zero' := erase_zero i
map_add' := erase_add i
#align dfinsupp.erase_add_hom DFinsupp.eraseAddHom
#align dfinsupp.erase_add_hom_apply DFinsupp.eraseAddHom_apply
variable {β}
@[simp]
theorem single_neg {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (x : β i) :
single i (-x) = -single i x :=
(singleAddHom β i).map_neg x
#align dfinsupp.single_neg DFinsupp.single_neg
@[simp]
theorem single_sub {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (x y : β i) :
single i (x - y) = single i x - single i y :=
(singleAddHom β i).map_sub x y
#align dfinsupp.single_sub DFinsupp.single_sub
@[simp]
theorem erase_neg {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (f : Π₀ i, β i) :
(-f).erase i = -f.erase i :=
(eraseAddHom β i).map_neg f
#align dfinsupp.erase_neg DFinsupp.erase_neg
@[simp]
theorem erase_sub {β : ι → Type v} [∀ i, AddGroup (β i)] (i : ι) (f g : Π₀ i, β i) :
(f - g).erase i = f.erase i - g.erase i :=
(eraseAddHom β i).map_sub f g
#align dfinsupp.erase_sub DFinsupp.erase_sub
theorem single_add_erase (i : ι) (f : Π₀ i, β i) : single i (f i) + f.erase i = f :=
ext fun i' =>
if h : i = i' then by
subst h; simp only [add_apply, single_apply, erase_apply, add_zero, dite_eq_ite, if_true]
else by
simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (Ne.symm h), zero_add]
#align dfinsupp.single_add_erase DFinsupp.single_add_erase
theorem erase_add_single (i : ι) (f : Π₀ i, β i) : f.erase i + single i (f i) = f :=
ext fun i' =>
if h : i = i' then by
subst h; simp only [add_apply, single_apply, erase_apply, zero_add, dite_eq_ite, if_true]
else by
simp only [add_apply, single_apply, erase_apply, dif_neg h, if_neg (Ne.symm h), add_zero]
#align dfinsupp.erase_add_single DFinsupp.erase_add_single
protected theorem induction {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i) (h0 : p 0)
(ha : ∀ (i b) (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (single i b + f)) : p f := by
cases' f with f s
induction' s using Trunc.induction_on with s
cases' s with s H
induction' s using Multiset.induction_on with i s ih generalizing f
· have : f = 0 := funext fun i => (H i).resolve_left (Multiset.not_mem_zero _)
subst this
exact h0
have H2 : p (erase i ⟨f, Trunc.mk ⟨i ::ₘ s, H⟩⟩) := by
dsimp only [erase, Trunc.map, Trunc.bind, Trunc.liftOn, Trunc.lift_mk,
Function.comp, Subtype.coe_mk]
have H2 : ∀ j, j ∈ s ∨ ite (j = i) 0 (f j) = 0 := by
intro j
cases' H j with H2 H2
· cases' Multiset.mem_cons.1 H2 with H3 H3
· right; exact if_pos H3
· left; exact H3
right
split_ifs <;> [rfl; exact H2]
have H3 : ∀ aux, (⟨fun j : ι => ite (j = i) 0 (f j), Trunc.mk ⟨i ::ₘ s, aux⟩⟩ : Π₀ i, β i) =
⟨fun j : ι => ite (j = i) 0 (f j), Trunc.mk ⟨s, H2⟩⟩ :=
fun _ ↦ ext fun _ => rfl
rw [H3]
apply ih
have H3 : single i _ + _ = (⟨f, Trunc.mk ⟨i ::ₘ s, H⟩⟩ : Π₀ i, β i) := single_add_erase _ _
rw [← H3]
change p (single i (f i) + _)
cases' Classical.em (f i = 0) with h h
· rw [h, single_zero, zero_add]
exact H2
refine ha _ _ _ ?_ h H2
rw [erase_same]
#align dfinsupp.induction DFinsupp.induction
theorem induction₂ {p : (Π₀ i, β i) → Prop} (f : Π₀ i, β i) (h0 : p 0)
(ha : ∀ (i b) (f : Π₀ i, β i), f i = 0 → b ≠ 0 → p f → p (f + single i b)) : p f :=
DFinsupp.induction f h0 fun i b f h1 h2 h3 =>
have h4 : f + single i b = single i b + f := by
ext j; by_cases H : i = j
· subst H
simp [h1]
· simp [H]
Eq.recOn h4 <| ha i b f h1 h2 h3
#align dfinsupp.induction₂ DFinsupp.induction₂
@[simp]
theorem add_closure_iUnion_range_single :
AddSubmonoid.closure (⋃ i : ι, Set.range (single i : β i → Π₀ i, β i)) = ⊤ :=
top_unique fun x _ => by
apply DFinsupp.induction x
· exact AddSubmonoid.zero_mem _
exact fun a b f _ _ hf =>
AddSubmonoid.add_mem _
(AddSubmonoid.subset_closure <| Set.mem_iUnion.2 ⟨a, Set.mem_range_self _⟩) hf
#align dfinsupp.add_closure_Union_range_single DFinsupp.add_closure_iUnion_range_single
/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then
they are equal. -/
theorem addHom_ext {γ : Type w} [AddZeroClass γ] ⦃f g : (Π₀ i, β i) →+ γ⦄
(H : ∀ (i : ι) (y : β i), f (single i y) = g (single i y)) : f = g := by
refine AddMonoidHom.eq_of_eqOn_denseM add_closure_iUnion_range_single fun f hf => ?_
simp only [Set.mem_iUnion, Set.mem_range] at hf
rcases hf with ⟨x, y, rfl⟩
apply H
#align dfinsupp.add_hom_ext DFinsupp.addHom_ext
/-- If two additive homomorphisms from `Π₀ i, β i` are equal on each `single a b`, then
they are equal.
See note [partially-applied ext lemmas]. -/
@[ext]
theorem addHom_ext' {γ : Type w} [AddZeroClass γ] ⦃f g : (Π₀ i, β i) →+ γ⦄
(H : ∀ x, f.comp (singleAddHom β x) = g.comp (singleAddHom β x)) : f = g :=
addHom_ext fun x => DFunLike.congr_fun (H x)
#align dfinsupp.add_hom_ext' DFinsupp.addHom_ext'
end AddMonoid
@[simp]
theorem mk_add [∀ i, AddZeroClass (β i)] {s : Finset ι} {x y : ∀ i : (↑s : Set ι), β i} :
mk s (x + y) = mk s x + mk s y :=
ext fun i => by simp only [add_apply, mk_apply]; split_ifs <;> [rfl; rw [zero_add]]
#align dfinsupp.mk_add DFinsupp.mk_add
@[simp]
theorem mk_zero [∀ i, Zero (β i)] {s : Finset ι} : mk s (0 : ∀ i : (↑s : Set ι), β i.1) = 0 :=
ext fun i => by simp only [mk_apply]; split_ifs <;> rfl
#align dfinsupp.mk_zero DFinsupp.mk_zero
@[simp]
theorem mk_neg [∀ i, AddGroup (β i)] {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i.1} :
mk s (-x) = -mk s x :=
ext fun i => by simp only [neg_apply, mk_apply]; split_ifs <;> [rfl; rw [neg_zero]]
#align dfinsupp.mk_neg DFinsupp.mk_neg
@[simp]
theorem mk_sub [∀ i, AddGroup (β i)] {s : Finset ι} {x y : ∀ i : (↑s : Set ι), β i.1} :
mk s (x - y) = mk s x - mk s y :=
ext fun i => by simp only [sub_apply, mk_apply]; split_ifs <;> [rfl; rw [sub_zero]]
#align dfinsupp.mk_sub DFinsupp.mk_sub
/-- If `s` is a subset of `ι` then `mk_addGroupHom s` is the canonical additive
group homomorphism from $\prod_{i\in s}\beta_i$ to $\prod_{\mathtt{i : \iota}}\beta_i.$-/
def mkAddGroupHom [∀ i, AddGroup (β i)] (s : Finset ι) :
(∀ i : (s : Set ι), β ↑i) →+ Π₀ i : ι, β i where
toFun := mk s
map_zero' := mk_zero
map_add' _ _ := mk_add
#align dfinsupp.mk_add_group_hom DFinsupp.mkAddGroupHom
section
variable [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)]
@[simp]
theorem mk_smul {s : Finset ι} (c : γ) (x : ∀ i : (↑s : Set ι), β (i : ι)) :
mk s (c • x) = c • mk s x :=
ext fun i => by simp only [smul_apply, mk_apply]; split_ifs <;> [rfl; rw [smul_zero]]
#align dfinsupp.mk_smul DFinsupp.mk_smul
@[simp]
theorem single_smul {i : ι} (c : γ) (x : β i) : single i (c • x) = c • single i x :=
ext fun i => by
simp only [smul_apply, single_apply]
split_ifs with h
· cases h; rfl
· rw [smul_zero]
#align dfinsupp.single_smul DFinsupp.single_smul
end
section SupportBasic
variable [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
/-- Set `{i | f x ≠ 0}` as a `Finset`. -/
def support (f : Π₀ i, β i) : Finset ι :=
(f.support'.lift fun xs => (Multiset.toFinset xs.1).filter fun i => f i ≠ 0) <| by
rintro ⟨sx, hx⟩ ⟨sy, hy⟩
dsimp only [Subtype.coe_mk, toFun_eq_coe] at *
ext i; constructor
· intro H
rcases Finset.mem_filter.1 H with ⟨_, h⟩
exact Finset.mem_filter.2 ⟨Multiset.mem_toFinset.2 <| (hy i).resolve_right h, h⟩
· intro H
rcases Finset.mem_filter.1 H with ⟨_, h⟩
exact Finset.mem_filter.2 ⟨Multiset.mem_toFinset.2 <| (hx i).resolve_right h, h⟩
#align dfinsupp.support DFinsupp.support
@[simp]
theorem support_mk_subset {s : Finset ι} {x : ∀ i : (↑s : Set ι), β i.1} : (mk s x).support ⊆ s :=
fun _ H => Multiset.mem_toFinset.1 (Finset.mem_filter.1 H).1
#align dfinsupp.support_mk_subset DFinsupp.support_mk_subset
@[simp]
theorem support_mk'_subset {f : ∀ i, β i} {s : Multiset ι} {h} :
(mk' f <| Trunc.mk ⟨s, h⟩).support ⊆ s.toFinset := fun i H =>
Multiset.mem_toFinset.1 <| by simpa using (Finset.mem_filter.1 H).1
#align dfinsupp.support_mk'_subset DFinsupp.support_mk'_subset
@[simp]
theorem mem_support_toFun (f : Π₀ i, β i) (i) : i ∈ f.support ↔ f i ≠ 0 := by
cases' f with f s
induction' s using Trunc.induction_on with s
dsimp only [support, Trunc.lift_mk]
rw [Finset.mem_filter, Multiset.mem_toFinset, coe_mk']
exact and_iff_right_of_imp (s.prop i).resolve_right
#align dfinsupp.mem_support_to_fun DFinsupp.mem_support_toFun
theorem eq_mk_support (f : Π₀ i, β i) : f = mk f.support fun i => f i := by aesop
#align dfinsupp.eq_mk_support DFinsupp.eq_mk_support
/-- Equivalence between dependent functions with finite support `s : Finset ι` and functions
`∀ i, {x : β i // x ≠ 0}`. -/
@[simps]
def subtypeSupportEqEquiv (s : Finset ι) :
{f : Π₀ i, β i // f.support = s} ≃ ∀ i : s, {x : β i // x ≠ 0} where
toFun | ⟨f, hf⟩ => fun ⟨i, hi⟩ ↦ ⟨f i, (f.mem_support_toFun i).1 <| hf.symm ▸ hi⟩
invFun f := ⟨mk s fun i ↦ (f i).1, Finset.ext fun i ↦ by
-- TODO: `simp` fails to use `(f _).2` inside `∃ _, _`
calc
i ∈ support (mk s fun i ↦ (f i).1) ↔ ∃ h : i ∈ s, (f ⟨i, h⟩).1 ≠ 0 := by simp
_ ↔ ∃ _ : i ∈ s, True := exists_congr fun h ↦ (iff_true _).mpr (f _).2
_ ↔ i ∈ s := by simp⟩
left_inv := by
rintro ⟨f, rfl⟩
ext i
simpa using Eq.symm
right_inv f := by
ext1
simp [Subtype.eta]; rfl
/-- Equivalence between all dependent finitely supported functions `f : Π₀ i, β i` and type
of pairs `⟨s : Finset ι, f : ∀ i : s, {x : β i // x ≠ 0}⟩`. -/
@[simps! apply_fst apply_snd_coe]
def sigmaFinsetFunEquiv : (Π₀ i, β i) ≃ Σ s : Finset ι, ∀ i : s, {x : β i // x ≠ 0} :=
(Equiv.sigmaFiberEquiv DFinsupp.support).symm.trans (.sigmaCongrRight subtypeSupportEqEquiv)
@[simp]
theorem support_zero : (0 : Π₀ i, β i).support = ∅ :=
rfl
#align dfinsupp.support_zero DFinsupp.support_zero
theorem mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∈ f.support ↔ f i ≠ 0 :=
f.mem_support_toFun _
#align dfinsupp.mem_support_iff DFinsupp.mem_support_iff
theorem not_mem_support_iff {f : Π₀ i, β i} {i : ι} : i ∉ f.support ↔ f i = 0 :=
not_iff_comm.1 mem_support_iff.symm
#align dfinsupp.not_mem_support_iff DFinsupp.not_mem_support_iff
@[simp]
theorem support_eq_empty {f : Π₀ i, β i} : f.support = ∅ ↔ f = 0 :=
⟨fun H => ext <| by simpa [Finset.ext_iff] using H, by simp (config := { contextual := true })⟩
#align dfinsupp.support_eq_empty DFinsupp.support_eq_empty
instance decidableZero : DecidablePred (Eq (0 : Π₀ i, β i)) := fun _ =>
decidable_of_iff _ <| support_eq_empty.trans eq_comm
#align dfinsupp.decidable_zero DFinsupp.decidableZero
theorem support_subset_iff {s : Set ι} {f : Π₀ i, β i} : ↑f.support ⊆ s ↔ ∀ i ∉ s, f i = 0 := by
simp [Set.subset_def]; exact forall_congr' fun i => not_imp_comm
#align dfinsupp.support_subset_iff DFinsupp.support_subset_iff
theorem support_single_ne_zero {i : ι} {b : β i} (hb : b ≠ 0) : (single i b).support = {i} := by
ext j; by_cases h : i = j
· subst h
simp [hb]
simp [Ne.symm h, h]
#align dfinsupp.support_single_ne_zero DFinsupp.support_single_ne_zero
theorem support_single_subset {i : ι} {b : β i} : (single i b).support ⊆ {i} :=
support_mk'_subset
#align dfinsupp.support_single_subset DFinsupp.support_single_subset
section MapRangeAndZipWith
variable [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)]
theorem mapRange_def [∀ (i) (x : β₁ i), Decidable (x ≠ 0)] {f : ∀ i, β₁ i → β₂ i}
{hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :
mapRange f hf g = mk g.support fun i => f i.1 (g i.1) := by
ext i
by_cases h : g i ≠ 0 <;> simp at h <;> simp [h, hf]
#align dfinsupp.map_range_def DFinsupp.mapRange_def
@[simp]
theorem mapRange_single {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {i : ι} {b : β₁ i} :
mapRange f hf (single i b) = single i (f i b) :=
DFinsupp.ext fun i' => by
by_cases h : i = i'
· subst i'
simp
· simp [h, hf]
#align dfinsupp.map_range_single DFinsupp.mapRange_single
variable [∀ (i) (x : β₁ i), Decidable (x ≠ 0)] [∀ (i) (x : β₂ i), Decidable (x ≠ 0)]
theorem support_mapRange {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} :
(mapRange f hf g).support ⊆ g.support := by simp [mapRange_def]
#align dfinsupp.support_map_range DFinsupp.support_mapRange
theorem zipWith_def {ι : Type u} {β : ι → Type v} {β₁ : ι → Type v₁} {β₂ : ι → Type v₂}
[dec : DecidableEq ι] [∀ i : ι, Zero (β i)] [∀ i : ι, Zero (β₁ i)] [∀ i : ι, Zero (β₂ i)]
[∀ (i : ι) (x : β₁ i), Decidable (x ≠ 0)] [∀ (i : ι) (x : β₂ i), Decidable (x ≠ 0)]
{f : ∀ i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0} {g₁ : Π₀ i, β₁ i} {g₂ : Π₀ i, β₂ i} :
zipWith f hf g₁ g₂ = mk (g₁.support ∪ g₂.support) fun i => f i.1 (g₁ i.1) (g₂ i.1) := by
ext i
by_cases h1 : g₁ i ≠ 0 <;> by_cases h2 : g₂ i ≠ 0 <;> simp only [not_not, Ne] at h1 h2 <;>
simp [h1, h2, hf]
#align dfinsupp.zip_with_def DFinsupp.zipWith_def
theorem support_zipWith {f : ∀ i, β₁ i → β₂ i → β i} {hf : ∀ i, f i 0 0 = 0} {g₁ : Π₀ i, β₁ i}
{g₂ : Π₀ i, β₂ i} : (zipWith f hf g₁ g₂).support ⊆ g₁.support ∪ g₂.support := by
simp [zipWith_def]
#align dfinsupp.support_zip_with DFinsupp.support_zipWith
end MapRangeAndZipWith
theorem erase_def (i : ι) (f : Π₀ i, β i) : f.erase i = mk (f.support.erase i) fun j => f j.1 := by
ext j
by_cases h1 : j = i <;> by_cases h2 : f j ≠ 0 <;> simp at h2 <;> simp [h1, h2]
#align dfinsupp.erase_def DFinsupp.erase_def
@[simp]
theorem support_erase (i : ι) (f : Π₀ i, β i) : (f.erase i).support = f.support.erase i := by
ext j
by_cases h1 : j = i
· simp only [h1, mem_support_toFun, erase_apply, ite_true, ne_eq, not_true, not_not,
Finset.mem_erase, false_and]
by_cases h2 : f j ≠ 0 <;> simp at h2 <;> simp [h1, h2]
#align dfinsupp.support_erase DFinsupp.support_erase
theorem support_update_ne_zero (f : Π₀ i, β i) (i : ι) {b : β i} (h : b ≠ 0) :
support (f.update i b) = insert i f.support := by
ext j
rcases eq_or_ne i j with (rfl | hi)
· simp [h]
· simp [hi.symm]
#align dfinsupp.support_update_ne_zero DFinsupp.support_update_ne_zero
theorem support_update (f : Π₀ i, β i) (i : ι) (b : β i) [Decidable (b = 0)] :
support (f.update i b) = if b = 0 then support (f.erase i) else insert i f.support := by
ext j
split_ifs with hb
· subst hb
simp [update_eq_erase, support_erase]
· rw [support_update_ne_zero f _ hb]
#align dfinsupp.support_update DFinsupp.support_update
section FilterAndSubtypeDomain
variable {p : ι → Prop} [DecidablePred p]
theorem filter_def (f : Π₀ i, β i) : f.filter p = mk (f.support.filter p) fun i => f i.1 := by
ext i; by_cases h1 : p i <;> by_cases h2 : f i ≠ 0 <;> simp at h2 <;> simp [h1, h2]
#align dfinsupp.filter_def DFinsupp.filter_def
@[simp]
theorem support_filter (f : Π₀ i, β i) : (f.filter p).support = f.support.filter p := by
ext i; by_cases h : p i <;> simp [h]
#align dfinsupp.support_filter DFinsupp.support_filter
theorem subtypeDomain_def (f : Π₀ i, β i) :
f.subtypeDomain p = mk (f.support.subtype p) fun i => f i := by
ext i; by_cases h2 : f i ≠ 0 <;> try simp at h2; dsimp; simp [h2]
#align dfinsupp.subtype_domain_def DFinsupp.subtypeDomain_def
@[simp, nolint simpNF] -- Porting note: simpNF claims that LHS does not simplify, but it does
theorem support_subtypeDomain {f : Π₀ i, β i} :
(subtypeDomain p f).support = f.support.subtype p := by
ext i
simp
#align dfinsupp.support_subtype_domain DFinsupp.support_subtypeDomain
end FilterAndSubtypeDomain
end SupportBasic
theorem support_add [∀ i, AddZeroClass (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
{g₁ g₂ : Π₀ i, β i} : (g₁ + g₂).support ⊆ g₁.support ∪ g₂.support :=
support_zipWith
#align dfinsupp.support_add DFinsupp.support_add
@[simp]
theorem support_neg [∀ i, AddGroup (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] {f : Π₀ i, β i} :
support (-f) = support f := by ext i; simp
#align dfinsupp.support_neg DFinsupp.support_neg
theorem support_smul {γ : Type w} [Semiring γ] [∀ i, AddCommMonoid (β i)] [∀ i, Module γ (β i)]
[∀ (i : ι) (x : β i), Decidable (x ≠ 0)] (b : γ) (v : Π₀ i, β i) :
(b • v).support ⊆ v.support :=
support_mapRange
#align dfinsupp.support_smul DFinsupp.support_smul
instance [∀ i, Zero (β i)] [∀ i, DecidableEq (β i)] : DecidableEq (Π₀ i, β i) := fun f g =>
decidable_of_iff (f.support = g.support ∧ ∀ i ∈ f.support, f i = g i)
⟨fun ⟨h₁, h₂⟩ => ext fun i => if h : i ∈ f.support then h₂ i h else by
have hf : f i = 0 := by rwa [mem_support_iff, not_not] at h
have hg : g i = 0 := by rwa [h₁, mem_support_iff, not_not] at h
rw [hf, hg],
by rintro rfl; simp⟩
section Equiv
open Finset
variable {κ : Type*}
/-- Reindexing (and possibly removing) terms of a dfinsupp. -/
noncomputable def comapDomain [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h)
(f : Π₀ i, β i) : Π₀ k, β (h k) where
toFun x := f (h x)
support' :=
f.support'.map fun s =>
⟨((Multiset.toFinset s.1).preimage h hh.injOn).val, fun x =>
(s.prop (h x)).imp_left fun hx => mem_preimage.mpr <| Multiset.mem_toFinset.mpr hx⟩
#align dfinsupp.comap_domain DFinsupp.comapDomain
@[simp]
theorem comapDomain_apply [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) (f : Π₀ i, β i)
(k : κ) : comapDomain h hh f k = f (h k) :=
rfl
#align dfinsupp.comap_domain_apply DFinsupp.comapDomain_apply
@[simp]
theorem comapDomain_zero [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h) :
comapDomain h hh (0 : Π₀ i, β i) = 0 := by
ext
rw [zero_apply, comapDomain_apply, zero_apply]
#align dfinsupp.comap_domain_zero DFinsupp.comapDomain_zero
@[simp]
theorem comapDomain_add [∀ i, AddZeroClass (β i)] (h : κ → ι) (hh : Function.Injective h)
(f g : Π₀ i, β i) : comapDomain h hh (f + g) = comapDomain h hh f + comapDomain h hh g := by
ext
rw [add_apply, comapDomain_apply, comapDomain_apply, comapDomain_apply, add_apply]
#align dfinsupp.comap_domain_add DFinsupp.comapDomain_add
@[simp]
theorem comapDomain_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)]
(h : κ → ι) (hh : Function.Injective h) (r : γ) (f : Π₀ i, β i) :
comapDomain h hh (r • f) = r • comapDomain h hh f := by
ext
rw [smul_apply, comapDomain_apply, smul_apply, comapDomain_apply]
#align dfinsupp.comap_domain_smul DFinsupp.comapDomain_smul
@[simp]
theorem comapDomain_single [DecidableEq κ] [∀ i, Zero (β i)] (h : κ → ι) (hh : Function.Injective h)
(k : κ) (x : β (h k)) : comapDomain h hh (single (h k) x) = single k x := by
ext i
rw [comapDomain_apply]
obtain rfl | hik := Decidable.eq_or_ne i k
· rw [single_eq_same, single_eq_same]
· rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh.ne hik.symm)]
#align dfinsupp.comap_domain_single DFinsupp.comapDomain_single
/-- A computable version of comap_domain when an explicit left inverse is provided. -/
def comapDomain' [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h)
(f : Π₀ i, β i) : Π₀ k, β (h k) where
toFun x := f (h x)
support' :=
f.support'.map fun s =>
⟨Multiset.map h' s.1, fun x =>
(s.prop (h x)).imp_left fun hx => Multiset.mem_map.mpr ⟨_, hx, hh' _⟩⟩
#align dfinsupp.comap_domain' DFinsupp.comapDomain'
@[simp]
theorem comapDomain'_apply [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ}
(hh' : Function.LeftInverse h' h) (f : Π₀ i, β i) (k : κ) : comapDomain' h hh' f k = f (h k) :=
rfl
#align dfinsupp.comap_domain'_apply DFinsupp.comapDomain'_apply
@[simp]
theorem comapDomain'_zero [∀ i, Zero (β i)] (h : κ → ι) {h' : ι → κ}
(hh' : Function.LeftInverse h' h) : comapDomain' h hh' (0 : Π₀ i, β i) = 0 := by
ext
rw [zero_apply, comapDomain'_apply, zero_apply]
#align dfinsupp.comap_domain'_zero DFinsupp.comapDomain'_zero
@[simp]
theorem comapDomain'_add [∀ i, AddZeroClass (β i)] (h : κ → ι) {h' : ι → κ}
(hh' : Function.LeftInverse h' h) (f g : Π₀ i, β i) :
comapDomain' h hh' (f + g) = comapDomain' h hh' f + comapDomain' h hh' g := by
ext
rw [add_apply, comapDomain'_apply, comapDomain'_apply, comapDomain'_apply, add_apply]
#align dfinsupp.comap_domain'_add DFinsupp.comapDomain'_add
@[simp]
theorem comapDomain'_smul [Monoid γ] [∀ i, AddMonoid (β i)] [∀ i, DistribMulAction γ (β i)]
(h : κ → ι) {h' : ι → κ} (hh' : Function.LeftInverse h' h) (r : γ) (f : Π₀ i, β i) :
comapDomain' h hh' (r • f) = r • comapDomain' h hh' f := by
ext
rw [smul_apply, comapDomain'_apply, smul_apply, comapDomain'_apply]
#align dfinsupp.comap_domain'_smul DFinsupp.comapDomain'_smul
@[simp]
theorem comapDomain'_single [DecidableEq ι] [DecidableEq κ] [∀ i, Zero (β i)] (h : κ → ι)
{h' : ι → κ} (hh' : Function.LeftInverse h' h) (k : κ) (x : β (h k)) :
comapDomain' h hh' (single (h k) x) = single k x := by
ext i
rw [comapDomain'_apply]
obtain rfl | hik := Decidable.eq_or_ne i k
· rw [single_eq_same, single_eq_same]
· rw [single_eq_of_ne hik.symm, single_eq_of_ne (hh'.injective.ne hik.symm)]
#align dfinsupp.comap_domain'_single DFinsupp.comapDomain'_single
/-- Reindexing terms of a dfinsupp.
This is the dfinsupp version of `Equiv.piCongrLeft'`. -/
@[simps apply]
def equivCongrLeft [∀ i, Zero (β i)] (h : ι ≃ κ) : (Π₀ i, β i) ≃ Π₀ k, β (h.symm k) where
toFun := comapDomain' h.symm h.right_inv
invFun f :=
mapRange (fun i => Equiv.cast <| congr_arg β <| h.symm_apply_apply i)
(fun i => (Equiv.cast_eq_iff_heq _).mpr <| by rw [Equiv.symm_apply_apply])
(@comapDomain' _ _ _ _ h _ h.left_inv f)
left_inv f := by
ext i
rw [mapRange_apply, comapDomain'_apply, comapDomain'_apply, Equiv.cast_eq_iff_heq,
h.symm_apply_apply]
right_inv f := by
ext k
rw [comapDomain'_apply, mapRange_apply, comapDomain'_apply, Equiv.cast_eq_iff_heq,
h.apply_symm_apply]
#align dfinsupp.equiv_congr_left DFinsupp.equivCongrLeft
#align dfinsupp.equiv_congr_left_apply DFinsupp.equivCongrLeft_apply
section SigmaCurry
variable {α : ι → Type*} {δ : ∀ i, α i → Type v}
-- lean can't find these instances -- Porting note: but Lean 4 can!!!
instance hasAdd₂ [∀ i j, AddZeroClass (δ i j)] : Add (Π₀ (i : ι) (j : α i), δ i j) :=
inferInstance
-- @DFinsupp.hasAdd ι (fun i => Π₀ j, δ i j) _
#align dfinsupp.has_add₂ DFinsupp.hasAdd₂
instance addZeroClass₂ [∀ i j, AddZeroClass (δ i j)] : AddZeroClass (Π₀ (i : ι) (j : α i), δ i j) :=
inferInstance
-- @DFinsupp.addZeroClass ι (fun i => Π₀ j, δ i j) _
#align dfinsupp.add_zero_class₂ DFinsupp.addZeroClass₂
instance addMonoid₂ [∀ i j, AddMonoid (δ i j)] : AddMonoid (Π₀ (i : ι) (j : α i), δ i j) :=
inferInstance
-- @DFinsupp.addMonoid ι (fun i => Π₀ j, δ i j) _
#align dfinsupp.add_monoid₂ DFinsupp.addMonoid₂
instance distribMulAction₂ [Monoid γ] [∀ i j, AddMonoid (δ i j)]
[∀ i j, DistribMulAction γ (δ i j)] : DistribMulAction γ (Π₀ (i : ι) (j : α i), δ i j) :=
@DFinsupp.distribMulAction ι _ (fun i => Π₀ j, δ i j) _ _ _
#align dfinsupp.distrib_mul_action₂ DFinsupp.distribMulAction₂
/-- The natural map between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`. -/
def sigmaCurry [∀ i j, Zero (δ i j)] (f : Π₀ (i : Σ _, _), δ i.1 i.2) :
Π₀ (i) (j), δ i j where
toFun := fun i ↦
{ toFun := fun j ↦ f ⟨i, j⟩,
support' := f.support'.map (fun ⟨m, hm⟩ ↦
⟨m.filterMap (fun ⟨i', j'⟩ ↦ if h : i' = i then some <| h.rec j' else none),
fun j ↦ (hm ⟨i, j⟩).imp_left (fun h ↦ (m.mem_filterMap _).mpr ⟨⟨i, j⟩, h, dif_pos rfl⟩)⟩) }
support' := f.support'.map (fun ⟨m, hm⟩ ↦
⟨m.map Sigma.fst, fun i ↦ Decidable.or_iff_not_imp_left.mpr (fun h ↦ DFinsupp.ext
(fun j ↦ (hm ⟨i, j⟩).resolve_left (fun H ↦ (Multiset.mem_map.not.mp h) ⟨⟨i, j⟩, H, rfl⟩)))⟩)
@[simp]
theorem sigmaCurry_apply [∀ i j, Zero (δ i j)] (f : Π₀ (i : Σ _, _), δ i.1 i.2) (i : ι) (j : α i) :
sigmaCurry f i j = f ⟨i, j⟩ :=
rfl
#align dfinsupp.sigma_curry_apply DFinsupp.sigmaCurry_apply
@[simp]
theorem sigmaCurry_zero [∀ i j, Zero (δ i j)] :
sigmaCurry (0 : Π₀ (i : Σ _, _), δ i.1 i.2) = 0 :=
rfl
#align dfinsupp.sigma_curry_zero DFinsupp.sigmaCurry_zero
@[simp]
theorem sigmaCurry_add [∀ i j, AddZeroClass (δ i j)] (f g : Π₀ (i : Σ _, _), δ i.1 i.2) :
sigmaCurry (f + g) = sigmaCurry f + sigmaCurry g := by
ext (i j)
rfl
#align dfinsupp.sigma_curry_add DFinsupp.sigmaCurry_add
@[simp]
theorem sigmaCurry_smul [Monoid γ] [∀ i j, AddMonoid (δ i j)] [∀ i j, DistribMulAction γ (δ i j)]
(r : γ) (f : Π₀ (i : Σ _, _), δ i.1 i.2) :
sigmaCurry (r • f) = r • sigmaCurry f := by
ext (i j)
rfl
#align dfinsupp.sigma_curry_smul DFinsupp.sigmaCurry_smul
@[simp]
theorem sigmaCurry_single [∀ i, DecidableEq (α i)] [∀ i j, Zero (δ i j)]
(ij : Σ i, α i) (x : δ ij.1 ij.2) :
sigmaCurry (single ij x) = single ij.1 (single ij.2 x : Π₀ j, δ ij.1 j) := by
obtain ⟨i, j⟩ := ij
ext i' j'
dsimp only
rw [sigmaCurry_apply]
obtain rfl | hi := eq_or_ne i i'
· rw [single_eq_same]
obtain rfl | hj := eq_or_ne j j'
· rw [single_eq_same, single_eq_same]
· rw [single_eq_of_ne, single_eq_of_ne hj]
simpa using hj
· rw [single_eq_of_ne, single_eq_of_ne hi, zero_apply]
simp [hi]
#align dfinsupp.sigma_curry_single DFinsupp.sigmaCurry_single
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
/-- The natural map between `Π₀ i (j : α i), δ i j` and `Π₀ (i : Σ i, α i), δ i.1 i.2`, inverse of
`curry`. -/
def sigmaUncurry [∀ i j, Zero (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)]
(f : Π₀ (i) (j), δ i j) :
Π₀ i : Σi, _, δ i.1 i.2 where
toFun i := f i.1 i.2
support' := f.support'.map fun s => ⟨Multiset.bind s.1 fun i =>
((f i).support.map ⟨Sigma.mk i, sigma_mk_injective⟩).val, fun i => by
simp_rw [Multiset.mem_bind, map_val, Multiset.mem_map, Function.Embedding.coeFn_mk, ←
Finset.mem_def, mem_support_toFun]
obtain hi | (hi : f i.1 = 0) := s.prop i.1
· by_cases hi' : f i.1 i.2 = 0
· exact Or.inr hi'
· exact Or.inl ⟨_, hi, i.2, hi', Sigma.eta _⟩
· right
rw [hi, zero_apply]⟩
#align dfinsupp.sigma_uncurry DFinsupp.sigmaUncurry
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
@[simp]
theorem sigmaUncurry_apply [∀ i j, Zero (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)]
(f : Π₀ (i) (j), δ i j) (i : ι) (j : α i) :
sigmaUncurry f ⟨i, j⟩ = f i j :=
rfl
#align dfinsupp.sigma_uncurry_apply DFinsupp.sigmaUncurry_apply
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
@[simp]
theorem sigmaUncurry_zero [∀ i j, Zero (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] :
sigmaUncurry (0 : Π₀ (i) (j), δ i j) = 0 :=
rfl
#align dfinsupp.sigma_uncurry_zero DFinsupp.sigmaUncurry_zero
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
@[simp]
theorem sigmaUncurry_add [∀ i j, AddZeroClass (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)]
(f g : Π₀ (i) (j), δ i j) :
sigmaUncurry (f + g) = sigmaUncurry f + sigmaUncurry g :=
DFunLike.coe_injective rfl
#align dfinsupp.sigma_uncurry_add DFinsupp.sigmaUncurry_add
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
@[simp]
theorem sigmaUncurry_smul [Monoid γ] [∀ i j, AddMonoid (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)]
[∀ i j, DistribMulAction γ (δ i j)]
(r : γ) (f : Π₀ (i) (j), δ i j) : sigmaUncurry (r • f) = r • sigmaUncurry f :=
DFunLike.coe_injective rfl
#align dfinsupp.sigma_uncurry_smul DFinsupp.sigmaUncurry_smul
@[simp]
theorem sigmaUncurry_single [∀ i j, Zero (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)]
(i) (j : α i) (x : δ i j) :
sigmaUncurry (single i (single j x : Π₀ j : α i, δ i j)) = single ⟨i, j⟩ (by exact x) := by
ext ⟨i', j'⟩
dsimp only
rw [sigmaUncurry_apply]
obtain rfl | hi := eq_or_ne i i'
· rw [single_eq_same]
obtain rfl | hj := eq_or_ne j j'
· rw [single_eq_same, single_eq_same]
· rw [single_eq_of_ne hj, single_eq_of_ne]
simpa using hj
· rw [single_eq_of_ne hi, single_eq_of_ne, zero_apply]
simp [hi]
#align dfinsupp.sigma_uncurry_single DFinsupp.sigmaUncurry_single
/- ./././Mathport/Syntax/Translate/Expr.lean:107:6: warning: expanding binder group (i j) -/
/-- The natural bijection between `Π₀ (i : Σ i, α i), δ i.1 i.2` and `Π₀ i (j : α i), δ i j`.
This is the dfinsupp version of `Equiv.piCurry`. -/
def sigmaCurryEquiv [∀ i j, Zero (δ i j)]
[∀ i, DecidableEq (α i)] [∀ i j (x : δ i j), Decidable (x ≠ 0)] :
(Π₀ i : Σi, _, δ i.1 i.2) ≃ Π₀ (i) (j), δ i j where
toFun := sigmaCurry
invFun := sigmaUncurry
left_inv f := by
ext ⟨i, j⟩
rw [sigmaUncurry_apply, sigmaCurry_apply]
right_inv f := by
ext i j
rw [sigmaCurry_apply, sigmaUncurry_apply]
#align dfinsupp.sigma_curry_equiv DFinsupp.sigmaCurryEquiv
end SigmaCurry
variable {α : Option ι → Type v}
/-- Adds a term to a dfinsupp, making a dfinsupp indexed by an `Option`.
This is the dfinsupp version of `Option.rec`. -/
def extendWith [∀ i, Zero (α i)] (a : α none) (f : Π₀ i, α (some i)) : Π₀ i, α i where
toFun := fun i ↦ match i with | none => a | some _ => f _
support' :=
f.support'.map fun s =>
⟨none ::ₘ Multiset.map some s.1, fun i =>
Option.rec (Or.inl <| Multiset.mem_cons_self _ _)
(fun i =>
(s.prop i).imp_left fun h => Multiset.mem_cons_of_mem <| Multiset.mem_map_of_mem _ h)
i⟩
#align dfinsupp.extend_with DFinsupp.extendWith
@[simp]
theorem extendWith_none [∀ i, Zero (α i)] (f : Π₀ i, α (some i)) (a : α none) :
f.extendWith a none = a :=
rfl
#align dfinsupp.extend_with_none DFinsupp.extendWith_none
@[simp]
theorem extendWith_some [∀ i, Zero (α i)] (f : Π₀ i, α (some i)) (a : α none) (i : ι) :
f.extendWith a (some i) = f i :=
rfl
#align dfinsupp.extend_with_some DFinsupp.extendWith_some
@[simp]
theorem extendWith_single_zero [DecidableEq ι] [∀ i, Zero (α i)] (i : ι) (x : α (some i)) :
(single i x).extendWith 0 = single (some i) x := by
ext (_ | j)
· rw [extendWith_none, single_eq_of_ne (Option.some_ne_none _)]
· rw [extendWith_some]
obtain rfl | hij := Decidable.eq_or_ne i j
· rw [single_eq_same, single_eq_same]
· rw [single_eq_of_ne hij, single_eq_of_ne ((Option.some_injective _).ne hij)]
#align dfinsupp.extend_with_single_zero DFinsupp.extendWith_single_zero
@[simp]
theorem extendWith_zero [DecidableEq ι] [∀ i, Zero (α i)] (x : α none) :
(0 : Π₀ i, α (some i)).extendWith x = single none x := by
ext (_ | j)
· rw [extendWith_none, single_eq_same]
· rw [extendWith_some, single_eq_of_ne (Option.some_ne_none _).symm, zero_apply]
#align dfinsupp.extend_with_zero DFinsupp.extendWith_zero
/-- Bijection obtained by separating the term of index `none` of a dfinsupp over `Option ι`.
This is the dfinsupp version of `Equiv.piOptionEquivProd`. -/
@[simps]
noncomputable def equivProdDFinsupp [∀ i, Zero (α i)] :
(Π₀ i, α i) ≃ α none × Π₀ i, α (some i) where
toFun f := (f none, comapDomain some (Option.some_injective _) f)
invFun f := f.2.extendWith f.1
left_inv f := by
ext i; cases' i with i
· rw [extendWith_none]
· rw [extendWith_some, comapDomain_apply]
right_inv x := by
dsimp only
ext
· exact extendWith_none x.snd _
· rw [comapDomain_apply, extendWith_some]
#align dfinsupp.equiv_prod_dfinsupp DFinsupp.equivProdDFinsupp
#align dfinsupp.equiv_prod_dfinsupp_apply DFinsupp.equivProdDFinsupp_apply
#align dfinsupp.equiv_prod_dfinsupp_symm_apply DFinsupp.equivProdDFinsupp_symm_apply
theorem equivProdDFinsupp_add [∀ i, AddZeroClass (α i)] (f g : Π₀ i, α i) :
equivProdDFinsupp (f + g) = equivProdDFinsupp f + equivProdDFinsupp g :=
Prod.ext (add_apply _ _ _) (comapDomain_add _ (Option.some_injective _) _ _)
#align dfinsupp.equiv_prod_dfinsupp_add DFinsupp.equivProdDFinsupp_add
theorem equivProdDFinsupp_smul [Monoid γ] [∀ i, AddMonoid (α i)] [∀ i, DistribMulAction γ (α i)]
(r : γ) (f : Π₀ i, α i) : equivProdDFinsupp (r • f) = r • equivProdDFinsupp f :=
Prod.ext (smul_apply _ _ _) (comapDomain_smul _ (Option.some_injective _) _ _)
#align dfinsupp.equiv_prod_dfinsupp_smul DFinsupp.equivProdDFinsupp_smul
end Equiv
section ProdAndSum
/-- `DFinsupp.prod f g` is the product of `g i (f i)` over the support of `f`. -/
@[to_additive "`sum f g` is the sum of `g i (f i)` over the support of `f`."]
def prod [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ] (f : Π₀ i, β i)
(g : ∀ i, β i → γ) : γ :=
∏ i ∈ f.support, g i (f i)
#align dfinsupp.prod DFinsupp.prod
#align dfinsupp.sum DFinsupp.sum
@[to_additive (attr := simp)]
theorem _root_.map_dfinsupp_prod
{R S H : Type*} [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[CommMonoid R] [CommMonoid S] [FunLike H R S] [MonoidHomClass H R S] (h : H) (f : Π₀ i, β i)
(g : ∀ i, β i → R) : h (f.prod g) = f.prod fun a b => h (g a b) :=
map_prod _ _ _
@[to_additive]
theorem prod_mapRange_index {β₁ : ι → Type v₁} {β₂ : ι → Type v₂} [∀ i, Zero (β₁ i)]
[∀ i, Zero (β₂ i)] [∀ (i) (x : β₁ i), Decidable (x ≠ 0)] [∀ (i) (x : β₂ i), Decidable (x ≠ 0)]
[CommMonoid γ] {f : ∀ i, β₁ i → β₂ i} {hf : ∀ i, f i 0 = 0} {g : Π₀ i, β₁ i} {h : ∀ i, β₂ i → γ}
(h0 : ∀ i, h i 0 = 1) : (mapRange f hf g).prod h = g.prod fun i b => h i (f i b) := by
rw [mapRange_def]
refine (Finset.prod_subset support_mk_subset ?_).trans ?_
· intro i h1 h2
simp only [mem_support_toFun, ne_eq] at h1
simp only [Finset.coe_sort_coe, mem_support_toFun, mk_apply, ne_eq, h1, not_false_iff,
dite_eq_ite, ite_true, not_not] at h2
simp [h2, h0]
· refine Finset.prod_congr rfl ?_
intro i h1
simp only [mem_support_toFun, ne_eq] at h1
simp [h1]
#align dfinsupp.prod_map_range_index DFinsupp.prod_mapRange_index
#align dfinsupp.sum_map_range_index DFinsupp.sum_mapRange_index
@[to_additive]
theorem prod_zero_index [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[CommMonoid γ] {h : ∀ i, β i → γ} : (0 : Π₀ i, β i).prod h = 1 :=
rfl
#align dfinsupp.prod_zero_index DFinsupp.prod_zero_index
#align dfinsupp.sum_zero_index DFinsupp.sum_zero_index
@[to_additive]
theorem prod_single_index [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
{i : ι} {b : β i} {h : ∀ i, β i → γ} (h_zero : h i 0 = 1) : (single i b).prod h = h i b := by
by_cases h : b ≠ 0
· simp [DFinsupp.prod, support_single_ne_zero h]
· rw [not_not] at h
simp [h, prod_zero_index, h_zero]
rfl
#align dfinsupp.prod_single_index DFinsupp.prod_single_index
#align dfinsupp.sum_single_index DFinsupp.sum_single_index
@[to_additive]
theorem prod_neg_index [∀ i, AddGroup (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
{g : Π₀ i, β i} {h : ∀ i, β i → γ} (h0 : ∀ i, h i 0 = 1) :
(-g).prod h = g.prod fun i b => h i (-b) :=
prod_mapRange_index h0
#align dfinsupp.prod_neg_index DFinsupp.prod_neg_index
#align dfinsupp.sum_neg_index DFinsupp.sum_neg_index
@[to_additive]
theorem prod_comm {ι₁ ι₂ : Sort _} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*} [DecidableEq ι₁]
[DecidableEq ι₂] [∀ i, Zero (β₁ i)] [∀ i, Zero (β₂ i)] [∀ (i) (x : β₁ i), Decidable (x ≠ 0)]
[∀ (i) (x : β₂ i), Decidable (x ≠ 0)] [CommMonoid γ] (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i)
(h : ∀ i, β₁ i → ∀ i, β₂ i → γ) :
(f₁.prod fun i₁ x₁ => f₂.prod fun i₂ x₂ => h i₁ x₁ i₂ x₂) =
f₂.prod fun i₂ x₂ => f₁.prod fun i₁ x₁ => h i₁ x₁ i₂ x₂ :=
Finset.prod_comm
#align dfinsupp.prod_comm DFinsupp.prod_comm
#align dfinsupp.sum_comm DFinsupp.sum_comm
@[simp]
theorem sum_apply {ι₁ : Type u₁} [DecidableEq ι₁] {β₁ : ι₁ → Type v₁} [∀ i₁, Zero (β₁ i₁)]
[∀ (i) (x : β₁ i), Decidable (x ≠ 0)] [∀ i, AddCommMonoid (β i)] {f : Π₀ i₁, β₁ i₁}
{g : ∀ i₁, β₁ i₁ → Π₀ i, β i} {i₂ : ι} : (f.sum g) i₂ = f.sum fun i₁ b => g i₁ b i₂ :=
map_sum (evalAddMonoidHom i₂) _ f.support
#align dfinsupp.sum_apply DFinsupp.sum_apply
theorem support_sum {ι₁ : Type u₁} [DecidableEq ι₁] {β₁ : ι₁ → Type v₁} [∀ i₁, Zero (β₁ i₁)]
[∀ (i) (x : β₁ i), Decidable (x ≠ 0)] [∀ i, AddCommMonoid (β i)]
[∀ (i) (x : β i), Decidable (x ≠ 0)] {f : Π₀ i₁, β₁ i₁} {g : ∀ i₁, β₁ i₁ → Π₀ i, β i} :
(f.sum g).support ⊆ f.support.biUnion fun i => (g i (f i)).support := by
have :
∀ i₁ : ι,
(f.sum fun (i : ι₁) (b : β₁ i) => (g i b) i₁) ≠ 0 → ∃ i : ι₁, f i ≠ 0 ∧ ¬(g i (f i)) i₁ = 0 :=
fun i₁ h =>
let ⟨i, hi, Ne⟩ := Finset.exists_ne_zero_of_sum_ne_zero h
⟨i, mem_support_iff.1 hi, Ne⟩
simpa [Finset.subset_iff, mem_support_iff, Finset.mem_biUnion, sum_apply] using this
#align dfinsupp.support_sum DFinsupp.support_sum
@[to_additive (attr := simp)]
theorem prod_one [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
{f : Π₀ i, β i} : (f.prod fun _ _ => (1 : γ)) = 1 :=
Finset.prod_const_one
#align dfinsupp.prod_one DFinsupp.prod_one
#align dfinsupp.sum_zero DFinsupp.sum_zero
@[to_additive (attr := simp)]
theorem prod_mul [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
{f : Π₀ i, β i} {h₁ h₂ : ∀ i, β i → γ} :
(f.prod fun i b => h₁ i b * h₂ i b) = f.prod h₁ * f.prod h₂ :=
Finset.prod_mul_distrib
#align dfinsupp.prod_mul DFinsupp.prod_mul
#align dfinsupp.sum_add DFinsupp.sum_add
@[to_additive (attr := simp)]
theorem prod_inv [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommGroup γ]
{f : Π₀ i, β i} {h : ∀ i, β i → γ} : (f.prod fun i b => (h i b)⁻¹) = (f.prod h)⁻¹ :=
(map_prod (invMonoidHom : γ →* γ) _ f.support).symm
#align dfinsupp.prod_inv DFinsupp.prod_inv
#align dfinsupp.sum_neg DFinsupp.sum_neg
@[to_additive]
theorem prod_eq_one [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)] [CommMonoid γ]
{f : Π₀ i, β i} {h : ∀ i, β i → γ} (hyp : ∀ i, h i (f i) = 1) : f.prod h = 1 :=
Finset.prod_eq_one fun i _ => hyp i
#align dfinsupp.prod_eq_one DFinsupp.prod_eq_one
#align dfinsupp.sum_eq_zero DFinsupp.sum_eq_zero
theorem smul_sum {α : Type*} [Monoid α] [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[AddCommMonoid γ] [DistribMulAction α γ] {f : Π₀ i, β i} {h : ∀ i, β i → γ} {c : α} :
c • f.sum h = f.sum fun a b => c • h a b :=
Finset.smul_sum
#align dfinsupp.smul_sum DFinsupp.smul_sum
@[to_additive]
theorem prod_add_index [∀ i, AddCommMonoid (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[CommMonoid γ] {f g : Π₀ i, β i} {h : ∀ i, β i → γ} (h_zero : ∀ i, h i 0 = 1)
(h_add : ∀ i b₁ b₂, h i (b₁ + b₂) = h i b₁ * h i b₂) : (f + g).prod h = f.prod h * g.prod h :=
have f_eq : (∏ i ∈ f.support ∪ g.support, h i (f i)) = f.prod h :=
(Finset.prod_subset Finset.subset_union_left <| by
simp (config := { contextual := true }) [mem_support_iff, h_zero]).symm
have g_eq : (∏ i ∈ f.support ∪ g.support, h i (g i)) = g.prod h :=
(Finset.prod_subset Finset.subset_union_right <| by
simp (config := { contextual := true }) [mem_support_iff, h_zero]).symm
calc
(∏ i ∈ (f + g).support, h i ((f + g) i)) = ∏ i ∈ f.support ∪ g.support, h i ((f + g) i) :=
Finset.prod_subset support_add <| by
simp (config := { contextual := true }) [mem_support_iff, h_zero]
_ = (∏ i ∈ f.support ∪ g.support, h i (f i)) * ∏ i ∈ f.support ∪ g.support, h i (g i) := by
{ simp [h_add, Finset.prod_mul_distrib] }
_ = _ := by rw [f_eq, g_eq]
#align dfinsupp.prod_add_index DFinsupp.prod_add_index
#align dfinsupp.sum_add_index DFinsupp.sum_add_index
@[to_additive]
theorem _root_.dfinsupp_prod_mem [∀ i, Zero (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[CommMonoid γ] {S : Type*} [SetLike S γ] [SubmonoidClass S γ]
(s : S) (f : Π₀ i, β i) (g : ∀ i, β i → γ)
(h : ∀ c, f c ≠ 0 → g c (f c) ∈ s) : f.prod g ∈ s :=
prod_mem fun _ hi => h _ <| mem_support_iff.1 hi
#align dfinsupp_prod_mem dfinsupp_prod_mem
#align dfinsupp_sum_mem dfinsupp_sum_mem
@[to_additive (attr := simp)]
theorem prod_eq_prod_fintype [Fintype ι] [∀ i, Zero (β i)] [∀ (i : ι) (x : β i), Decidable (x ≠ 0)]
-- Porting note: `f` was a typeclass argument
[CommMonoid γ] (v : Π₀ i, β i) {f : ∀ i, β i → γ} (hf : ∀ i, f i 0 = 1) :
v.prod f = ∏ i, f i (DFinsupp.equivFunOnFintype v i) := by
suffices (∏ i ∈ v.support, f i (v i)) = ∏ i, f i (v i) by simp [DFinsupp.prod, this]
apply Finset.prod_subset v.support.subset_univ
intro i _ hi
rw [mem_support_iff, not_not] at hi
rw [hi, hf]
#align dfinsupp.prod_eq_prod_fintype DFinsupp.prod_eq_prod_fintype
#align dfinsupp.sum_eq_sum_fintype DFinsupp.sum_eq_sum_fintype
section CommMonoidWithZero
variable [Π i, Zero (β i)] [CommMonoidWithZero γ] [Nontrivial γ] [NoZeroDivisors γ]
[Π i, DecidableEq (β i)] {f : Π₀ i, β i} {g : Π i, β i → γ}
@[simp]
lemma prod_eq_zero_iff : f.prod g = 0 ↔ ∃ i ∈ f.support, g i (f i) = 0 := Finset.prod_eq_zero_iff
lemma prod_ne_zero_iff : f.prod g ≠ 0 ↔ ∀ i ∈ f.support, g i (f i) ≠ 0 := Finset.prod_ne_zero_iff
end CommMonoidWithZero
/--
When summing over an `AddMonoidHom`, the decidability assumption is not needed, and the result is
also an `AddMonoidHom`.
-/
def sumAddHom [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] (φ : ∀ i, β i →+ γ) :
(Π₀ i, β i) →+ γ where
toFun f :=
(f.support'.lift fun s => ∑ i ∈ Multiset.toFinset s.1, φ i (f i)) <| by
rintro ⟨sx, hx⟩ ⟨sy, hy⟩
dsimp only [Subtype.coe_mk, toFun_eq_coe] at *
have H1 : sx.toFinset ∩ sy.toFinset ⊆ sx.toFinset := Finset.inter_subset_left
have H2 : sx.toFinset ∩ sy.toFinset ⊆ sy.toFinset := Finset.inter_subset_right
refine
(Finset.sum_subset H1 ?_).symm.trans
((Finset.sum_congr rfl ?_).trans (Finset.sum_subset H2 ?_))
· intro i H1 H2
rw [Finset.mem_inter] at H2
simp only [Multiset.mem_toFinset] at H1 H2
convert AddMonoidHom.map_zero (φ i)
exact (hy i).resolve_left (mt (And.intro H1) H2)
· intro i _
rfl
· intro i H1 H2
rw [Finset.mem_inter] at H2
simp only [Multiset.mem_toFinset] at H1 H2
convert AddMonoidHom.map_zero (φ i)
exact (hx i).resolve_left (mt (fun H3 => And.intro H3 H1) H2)
map_add' := by
rintro ⟨f, sf, hf⟩ ⟨g, sg, hg⟩
change (∑ i ∈ _, _) = (∑ i ∈ _, _) + ∑ i ∈ _, _
simp only [coe_add, coe_mk', Subtype.coe_mk, Pi.add_apply, map_add, Finset.sum_add_distrib]
congr 1
· refine (Finset.sum_subset ?_ ?_).symm
· intro i
simp only [Multiset.mem_toFinset, Multiset.mem_add]
exact Or.inl
· intro i _ H2
simp only [Multiset.mem_toFinset, Multiset.mem_add] at H2
rw [(hf i).resolve_left H2, AddMonoidHom.map_zero]
· refine (Finset.sum_subset ?_ ?_).symm
· intro i
simp only [Multiset.mem_toFinset, Multiset.mem_add]
exact Or.inr
· intro i _ H2
simp only [Multiset.mem_toFinset, Multiset.mem_add] at H2
rw [(hg i).resolve_left H2, AddMonoidHom.map_zero]
map_zero' := by
simp only [toFun_eq_coe, coe_zero, Pi.zero_apply, map_zero, Finset.sum_const_zero]; rfl
#align dfinsupp.sum_add_hom DFinsupp.sumAddHom
@[simp]
theorem sumAddHom_single [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] (φ : ∀ i, β i →+ γ) (i)
(x : β i) : sumAddHom φ (single i x) = φ i x := by
dsimp [sumAddHom, single, Trunc.lift_mk]
rw [Multiset.toFinset_singleton, Finset.sum_singleton, Pi.single_eq_same]
#align dfinsupp.sum_add_hom_single DFinsupp.sumAddHom_single
@[simp]
theorem sumAddHom_comp_single [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] (f : ∀ i, β i →+ γ)
(i : ι) : (sumAddHom f).comp (singleAddHom β i) = f i :=
AddMonoidHom.ext fun x => sumAddHom_single f i x
#align dfinsupp.sum_add_hom_comp_single DFinsupp.sumAddHom_comp_single
/-- While we didn't need decidable instances to define it, we do to reduce it to a sum -/
theorem sumAddHom_apply [∀ i, AddZeroClass (β i)] [∀ (i) (x : β i), Decidable (x ≠ 0)]
[AddCommMonoid γ] (φ : ∀ i, β i →+ γ) (f : Π₀ i, β i) : sumAddHom φ f = f.sum fun x => φ x := by
rcases f with ⟨f, s, hf⟩
change (∑ i ∈ _, _) = ∑ i ∈ Finset.filter _ _, _
rw [Finset.sum_filter, Finset.sum_congr rfl]
intro i _
dsimp only [coe_mk', Subtype.coe_mk] at *
split_ifs with h
· rfl
· rw [not_not.mp h, AddMonoidHom.map_zero]
#align dfinsupp.sum_add_hom_apply DFinsupp.sumAddHom_apply
theorem _root_.dfinsupp_sumAddHom_mem [∀ i, AddZeroClass (β i)] [AddCommMonoid γ] {S : Type*}
[SetLike S γ] [AddSubmonoidClass S γ] (s : S) (f : Π₀ i, β i) (g : ∀ i, β i →+ γ)
(h : ∀ c, f c ≠ 0 → g c (f c) ∈ s) : DFinsupp.sumAddHom g f ∈ s := by
classical
rw [DFinsupp.sumAddHom_apply]
exact dfinsupp_sum_mem s f (g ·) h
#align dfinsupp_sum_add_hom_mem dfinsupp_sumAddHom_mem
/-- The supremum of a family of commutative additive submonoids is equal to the range of
`DFinsupp.sumAddHom`; that is, every element in the `iSup` can be produced from taking a finite
number of non-zero elements of `S i`, coercing them to `γ`, and summing them. -/
theorem _root_.AddSubmonoid.iSup_eq_mrange_dfinsupp_sumAddHom
[AddCommMonoid γ] (S : ι → AddSubmonoid γ) :
iSup S = AddMonoidHom.mrange (DFinsupp.sumAddHom fun i => (S i).subtype) := by
apply le_antisymm
· apply iSup_le _
intro i y hy
exact ⟨DFinsupp.single i ⟨y, hy⟩, DFinsupp.sumAddHom_single _ _ _⟩
· rintro x ⟨v, rfl⟩
exact dfinsupp_sumAddHom_mem _ v _ fun i _ => (le_iSup S i : S i ≤ _) (v i).prop
#align add_submonoid.supr_eq_mrange_dfinsupp_sum_add_hom AddSubmonoid.iSup_eq_mrange_dfinsupp_sumAddHom
/-- The bounded supremum of a family of commutative additive submonoids is equal to the range of
`DFinsupp.sumAddHom` composed with `DFinsupp.filterAddMonoidHom`; that is, every element in the
bounded `iSup` can be produced from taking a finite number of non-zero elements from the `S i` that
satisfy `p i`, coercing them to `γ`, and summing them. -/
theorem _root_.AddSubmonoid.bsupr_eq_mrange_dfinsupp_sumAddHom (p : ι → Prop) [DecidablePred p]
[AddCommMonoid γ] (S : ι → AddSubmonoid γ) :
⨆ (i) (_ : p i), S i =
AddMonoidHom.mrange ((sumAddHom fun i => (S i).subtype).comp (filterAddMonoidHom _ p)) := by
apply le_antisymm
· refine iSup₂_le fun i hi y hy => ⟨DFinsupp.single i ⟨y, hy⟩, ?_⟩
rw [AddMonoidHom.comp_apply, filterAddMonoidHom_apply, filter_single_pos _ _ hi]
exact sumAddHom_single _ _ _
· rintro x ⟨v, rfl⟩
refine dfinsupp_sumAddHom_mem _ _ _ fun i _ => ?_
refine AddSubmonoid.mem_iSup_of_mem i ?_
by_cases hp : p i
· simp [hp]
· simp [hp]
#align add_submonoid.bsupr_eq_mrange_dfinsupp_sum_add_hom AddSubmonoid.bsupr_eq_mrange_dfinsupp_sumAddHom
theorem _root_.AddSubmonoid.mem_iSup_iff_exists_dfinsupp [AddCommMonoid γ] (S : ι → AddSubmonoid γ)
(x : γ) : x ∈ iSup S ↔ ∃ f : Π₀ i, S i, DFinsupp.sumAddHom (fun i => (S i).subtype) f = x :=
SetLike.ext_iff.mp (AddSubmonoid.iSup_eq_mrange_dfinsupp_sumAddHom S) x
#align add_submonoid.mem_supr_iff_exists_dfinsupp AddSubmonoid.mem_iSup_iff_exists_dfinsupp
/-- A variant of `AddSubmonoid.mem_iSup_iff_exists_dfinsupp` with the RHS fully unfolded. -/
theorem _root_.AddSubmonoid.mem_iSup_iff_exists_dfinsupp' [AddCommMonoid γ] (S : ι → AddSubmonoid γ)
[∀ (i) (x : S i), Decidable (x ≠ 0)] (x : γ) :
x ∈ iSup S ↔ ∃ f : Π₀ i, S i, (f.sum fun i xi => ↑xi) = x := by
rw [AddSubmonoid.mem_iSup_iff_exists_dfinsupp]
simp_rw [sumAddHom_apply]
rfl
#align add_submonoid.mem_supr_iff_exists_dfinsupp' AddSubmonoid.mem_iSup_iff_exists_dfinsupp'
theorem _root_.AddSubmonoid.mem_bsupr_iff_exists_dfinsupp (p : ι → Prop) [DecidablePred p]
[AddCommMonoid γ] (S : ι → AddSubmonoid γ) (x : γ) :
(x ∈ ⨆ (i) (_ : p i), S i) ↔
∃ f : Π₀ i, S i, DFinsupp.sumAddHom (fun i => (S i).subtype) (f.filter p) = x :=
SetLike.ext_iff.mp (AddSubmonoid.bsupr_eq_mrange_dfinsupp_sumAddHom p S) x
#align add_submonoid.mem_bsupr_iff_exists_dfinsupp AddSubmonoid.mem_bsupr_iff_exists_dfinsupp
| Mathlib/Data/DFinsupp/Basic.lean | 2,007 | 2,015 | theorem sumAddHom_comm {ι₁ ι₂ : Sort _} {β₁ : ι₁ → Type*} {β₂ : ι₂ → Type*} {γ : Type*}
[DecidableEq ι₁] [DecidableEq ι₂] [∀ i, AddZeroClass (β₁ i)] [∀ i, AddZeroClass (β₂ i)]
[AddCommMonoid γ] (f₁ : Π₀ i, β₁ i) (f₂ : Π₀ i, β₂ i) (h : ∀ i j, β₁ i →+ β₂ j →+ γ) :
sumAddHom (fun i₂ => sumAddHom (fun i₁ => h i₁ i₂) f₁) f₂ =
sumAddHom (fun i₁ => sumAddHom (fun i₂ => (h i₁ i₂).flip) f₂) f₁ := by |
obtain ⟨⟨f₁, s₁, h₁⟩, ⟨f₂, s₂, h₂⟩⟩ := f₁, f₂
simp only [sumAddHom, AddMonoidHom.finset_sum_apply, Quotient.liftOn_mk, AddMonoidHom.coe_mk,
AddMonoidHom.flip_apply, Trunc.lift, toFun_eq_coe, ZeroHom.coe_mk, coe_mk']
exact Finset.sum_comm
|
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.Data.List.TFAE
#align_import algebraic_geometry.morphisms.basic from "leanprover-community/mathlib"@"434e2fd21c1900747afc6d13d8be7f4eedba7218"
/-!
# Properties of morphisms between Schemes
We provide the basic framework for talking about properties of morphisms between Schemes.
A `MorphismProperty Scheme` is a predicate on morphisms between schemes, and an
`AffineTargetMorphismProperty` is a predicate on morphisms into affine schemes. Given a
`P : AffineTargetMorphismProperty`, we may construct a `MorphismProperty` called
`targetAffineLocally P` that holds for `f : X ⟶ Y` whenever `P` holds for the
restriction of `f` on every affine open subset of `Y`.
## Main definitions
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal`: We say that `P.IsLocal` if `P`
satisfies the assumptions of the affine communication lemma
(`AlgebraicGeometry.of_affine_open_cover`). That is,
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basicOpen r` for any
global section `r`.
3. If `P` holds for `f ∣_ Y.basicOpen r` for all `r` in a spanning set of the global sections,
then `P` holds for `f`.
- `AlgebraicGeometry.PropertyIsLocalAtTarget`: We say that `PropertyIsLocalAtTarget P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.
## Main results
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_openCover_TFAE`:
If `P.IsLocal`, then `targetAffineLocally P f` iff there exists an affine cover `{ Uᵢ }` of `Y`
such that `P` holds for `f ∣_ Uᵢ`.
- `AlgebraicGeometry.AffineTargetMorphismProperty.isLocalOfOpenCoverImply`:
If the existence of an affine cover `{ Uᵢ }` of `Y` such that `P` holds for `f ∣_ Uᵢ` implies
`targetAffineLocally P f`, then `P.IsLocal`.
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.affine_target_iff`:
If `Y` is affine and `f : X ⟶ Y`, then `targetAffineLocally P f ↔ P f` provided `P.IsLocal`.
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal.targetAffineLocallyIsLocal` :
If `P.IsLocal`, then `PropertyIsLocalAtTarget (targetAffineLocally P)`.
- `AlgebraicGeometry.PropertyIsLocalAtTarget.openCover_TFAE`:
If `PropertyIsLocalAtTarget P`, then `P f` iff there exists an open cover `{ Uᵢ }` of `Y`
such that `P` holds for `f ∣_ Uᵢ`.
These results should not be used directly, and should be ported to each property that is local.
-/
set_option linter.uppercaseLean3 false
universe u
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
/-- An `AffineTargetMorphismProperty` is a class of morphisms from an arbitrary scheme into an
affine scheme. -/
def AffineTargetMorphismProperty :=
∀ ⦃X Y : Scheme⦄ (_ : X ⟶ Y) [IsAffine Y], Prop
#align algebraic_geometry.affine_target_morphism_property AlgebraicGeometry.AffineTargetMorphismProperty
/-- `IsIso` as a `MorphismProperty`. -/
protected def Scheme.isIso : MorphismProperty Scheme :=
@IsIso Scheme _
#align algebraic_geometry.Scheme.is_iso AlgebraicGeometry.Scheme.isIso
/-- `IsIso` as an `AffineTargetMorphismProperty`. -/
protected def Scheme.affineTargetIsIso : AffineTargetMorphismProperty := fun _ _ f _ => IsIso f
#align algebraic_geometry.Scheme.affine_target_is_iso AlgebraicGeometry.Scheme.affineTargetIsIso
instance : Inhabited AffineTargetMorphismProperty := ⟨Scheme.affineTargetIsIso⟩
/-- An `AffineTargetMorphismProperty` can be extended to a `MorphismProperty` such that it
*never* holds when the target is not affine -/
def AffineTargetMorphismProperty.toProperty (P : AffineTargetMorphismProperty) :
MorphismProperty Scheme := fun _ _ f => ∃ h, @P _ _ f h
#align algebraic_geometry.affine_target_morphism_property.to_property AlgebraicGeometry.AffineTargetMorphismProperty.toProperty
theorem AffineTargetMorphismProperty.toProperty_apply (P : AffineTargetMorphismProperty)
{X Y : Scheme} (f : X ⟶ Y) [i : IsAffine Y] : P.toProperty f ↔ P f := by
delta AffineTargetMorphismProperty.toProperty; simp [*]
#align algebraic_geometry.affine_target_morphism_property.to_property_apply AlgebraicGeometry.AffineTargetMorphismProperty.toProperty_apply
theorem affine_cancel_left_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsAffine Z] : P (f ≫ g) ↔ P g := by
rw [← P.toProperty_apply, ← P.toProperty_apply, hP.cancel_left_isIso]
#align algebraic_geometry.affine_cancel_left_is_iso AlgebraicGeometry.affine_cancel_left_isIso
theorem affine_cancel_right_isIso {P : AffineTargetMorphismProperty} (hP : P.toProperty.RespectsIso)
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsAffine Z] [IsAffine Y] :
P (f ≫ g) ↔ P f := by rw [← P.toProperty_apply, ← P.toProperty_apply, hP.cancel_right_isIso]
#align algebraic_geometry.affine_cancel_right_is_iso AlgebraicGeometry.affine_cancel_right_isIso
theorem AffineTargetMorphismProperty.respectsIso_mk {P : AffineTargetMorphismProperty}
(h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
(h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
P f → @P _ _ (f ≫ e.hom) (isAffineOfIso e.inv)) :
P.toProperty.RespectsIso := by
constructor
· rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
· rintro X Y Z e f ⟨a, h⟩; exact ⟨isAffineOfIso e.inv, h₂ e f h⟩
#align algebraic_geometry.affine_target_morphism_property.respects_iso_mk AlgebraicGeometry.AffineTargetMorphismProperty.respectsIso_mk
/-- For a `P : AffineTargetMorphismProperty`, `targetAffineLocally P` holds for
`f : X ⟶ Y` whenever `P` holds for the restriction of `f` on every affine open subset of `Y`. -/
def targetAffineLocally (P : AffineTargetMorphismProperty) : MorphismProperty Scheme :=
fun {X Y : Scheme} (f : X ⟶ Y) => ∀ U : Y.affineOpens, @P _ _ (f ∣_ U) U.prop
#align algebraic_geometry.target_affine_locally AlgebraicGeometry.targetAffineLocally
theorem IsAffineOpen.map_isIso {X Y : Scheme} {U : Opens Y.carrier} (hU : IsAffineOpen U)
(f : X ⟶ Y) [IsIso f] : IsAffineOpen ((Opens.map f.1.base).obj U) :=
haveI : IsAffine _ := hU
isAffineOfIso (f ∣_ U)
#align algebraic_geometry.is_affine_open.map_is_iso AlgebraicGeometry.IsAffineOpen.map_isIso
| Mathlib/AlgebraicGeometry/Morphisms/Basic.lean | 131 | 141 | theorem targetAffineLocally_respectsIso {P : AffineTargetMorphismProperty}
(hP : P.toProperty.RespectsIso) : (targetAffineLocally P).RespectsIso := by |
constructor
· introv H U
rw [morphismRestrict_comp, affine_cancel_left_isIso hP]
exact H U
· introv H
rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
haveI : IsAffine _ := hU.map_isIso e.hom
rw [morphismRestrict_comp, affine_cancel_right_isIso hP]
exact H ⟨(Opens.map e.hom.val.base).obj U, hU.map_isIso e.hom⟩
|
/-
Copyright (c) 2021 Yury Kudriashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudriashov, Malo Jaffré
-/
import Mathlib.Analysis.Convex.Function
import Mathlib.Tactic.AdaptationNote
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Linarith
#align_import analysis.convex.slope from "leanprover-community/mathlib"@"a8b2226cfb0a79f5986492053fc49b1a0c6aeffb"
/-!
# Slopes of convex functions
This file relates convexity/concavity of functions in a linearly ordered field and the monotonicity
of their slopes.
The main use is to show convexity/concavity from monotonicity of the derivative.
-/
variable {𝕜 : Type*} [LinearOrderedField 𝕜] {s : Set 𝕜} {f : 𝕜 → 𝕜}
#adaptation_note /-- after v4.7.0-rc1, there is a performance problem in `field_simp`.
(Part of the code was ignoring the `maxDischargeDepth` setting:
now that we have to increase it, other paths become slow.) -/
/-- If `f : 𝕜 → 𝕜` is convex, then for any three points `x < y < z` the slope of the secant line of
`f` on `[x, y]` is less than the slope of the secant line of `f` on `[x, z]`. -/
theorem ConvexOn.slope_mono_adjacent (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s)
(hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) ≤ (f z - f y) / (z - y) := by
have hxz := hxy.trans hyz
rw [← sub_pos] at hxy hxz hyz
suffices f y / (y - x) + f y / (z - y) ≤ f x / (y - x) + f z / (z - y) by
ring_nf at this ⊢
linarith
set a := (z - y) / (z - x)
set b := (y - x) / (z - x)
have hy : a • x + b • z = y := by field_simp [a, b]; ring
have key :=
hf.2 hx hz (show 0 ≤ a by apply div_nonneg <;> linarith)
(show 0 ≤ b by apply div_nonneg <;> linarith)
(show a + b = 1 by field_simp [a, b])
rw [hy] at key
replace key := mul_le_mul_of_nonneg_left key hxz.le
field_simp [a, b, mul_comm (z - x) _] at key ⊢
rw [div_le_div_right]
· linarith
· nlinarith
#align convex_on.slope_mono_adjacent ConvexOn.slope_mono_adjacent
/-- If `f : 𝕜 → 𝕜` is concave, then for any three points `x < y < z` the slope of the secant line of
`f` on `[x, y]` is greater than the slope of the secant line of `f` on `[x, z]`. -/
theorem ConcaveOn.slope_anti_adjacent (hf : ConcaveOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s)
(hxy : x < y) (hyz : y < z) : (f z - f y) / (z - y) ≤ (f y - f x) / (y - x) := by
have := neg_le_neg (ConvexOn.slope_mono_adjacent hf.neg hx hz hxy hyz)
simp only [Pi.neg_apply, ← neg_div, neg_sub', neg_neg] at this
exact this
#align concave_on.slope_anti_adjacent ConcaveOn.slope_anti_adjacent
/-- If `f : 𝕜 → 𝕜` is strictly convex, then for any three points `x < y < z` the slope of the
secant line of `f` on `[x, y]` is strictly less than the slope of the secant line of `f` on
`[x, z]`. -/
theorem StrictConvexOn.slope_strict_mono_adjacent (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜}
(hx : x ∈ s) (hz : z ∈ s) (hxy : x < y) (hyz : y < z) :
(f y - f x) / (y - x) < (f z - f y) / (z - y) := by
have hxz := hxy.trans hyz
have hxz' := hxz.ne
rw [← sub_pos] at hxy hxz hyz
suffices f y / (y - x) + f y / (z - y) < f x / (y - x) + f z / (z - y) by
ring_nf at this ⊢
linarith
set a := (z - y) / (z - x)
set b := (y - x) / (z - x)
have hy : a • x + b • z = y := by field_simp [a, b]; ring
have key :=
hf.2 hx hz hxz' (div_pos hyz hxz) (div_pos hxy hxz)
(show a + b = 1 by field_simp [a, b])
rw [hy] at key
replace key := mul_lt_mul_of_pos_left key hxz
field_simp [mul_comm (z - x) _] at key ⊢
rw [div_lt_div_right]
· linarith
· nlinarith
#align strict_convex_on.slope_strict_mono_adjacent StrictConvexOn.slope_strict_mono_adjacent
/-- If `f : 𝕜 → 𝕜` is strictly concave, then for any three points `x < y < z` the slope of the
secant line of `f` on `[x, y]` is strictly greater than the slope of the secant line of `f` on
`[x, z]`. -/
theorem StrictConcaveOn.slope_anti_adjacent (hf : StrictConcaveOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s)
(hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f z - f y) / (z - y) < (f y - f x) / (y - x) := by
have := neg_lt_neg (StrictConvexOn.slope_strict_mono_adjacent hf.neg hx hz hxy hyz)
simp only [Pi.neg_apply, ← neg_div, neg_sub', neg_neg] at this
exact this
#align strict_concave_on.slope_anti_adjacent StrictConcaveOn.slope_anti_adjacent
/-- If for any three points `x < y < z`, the slope of the secant line of `f : 𝕜 → 𝕜` on `[x, y]` is
less than the slope of the secant line of `f` on `[x, z]`, then `f` is convex. -/
theorem convexOn_of_slope_mono_adjacent (hs : Convex 𝕜 s)
(hf :
∀ {x y z : 𝕜},
x ∈ s → z ∈ s → x < y → y < z → (f y - f x) / (y - x) ≤ (f z - f y) / (z - y)) :
ConvexOn 𝕜 s f :=
LinearOrder.convexOn_of_lt hs fun x hx z hz hxz a b ha hb hab => by
let y := a * x + b * z
have hxy : x < y := by
rw [← one_mul x, ← hab, add_mul]
exact add_lt_add_left ((mul_lt_mul_left hb).2 hxz) _
have hyz : y < z := by
rw [← one_mul z, ← hab, add_mul]
exact add_lt_add_right ((mul_lt_mul_left ha).2 hxz) _
have : (f y - f x) * (z - y) ≤ (f z - f y) * (y - x) :=
(div_le_div_iff (sub_pos.2 hxy) (sub_pos.2 hyz)).1 (hf hx hz hxy hyz)
have hxz : 0 < z - x := sub_pos.2 (hxy.trans hyz)
have ha : (z - y) / (z - x) = a := by
rw [eq_comm, ← sub_eq_iff_eq_add'] at hab
dsimp [y]
simp_rw [div_eq_iff hxz.ne', ← hab]
ring
have hb : (y - x) / (z - x) = b := by
rw [eq_comm, ← sub_eq_iff_eq_add] at hab
dsimp [y]
simp_rw [div_eq_iff hxz.ne', ← hab]
ring
rwa [sub_mul, sub_mul, sub_le_iff_le_add', ← add_sub_assoc, le_sub_iff_add_le, ← mul_add,
sub_add_sub_cancel, ← le_div_iff hxz, add_div, mul_div_assoc, mul_div_assoc, mul_comm (f x),
mul_comm (f z), ha, hb] at this
#align convex_on_of_slope_mono_adjacent convexOn_of_slope_mono_adjacent
/-- If for any three points `x < y < z`, the slope of the secant line of `f : 𝕜 → 𝕜` on `[x, y]` is
greater than the slope of the secant line of `f` on `[x, z]`, then `f` is concave. -/
theorem concaveOn_of_slope_anti_adjacent (hs : Convex 𝕜 s)
(hf :
∀ {x y z : 𝕜},
x ∈ s → z ∈ s → x < y → y < z → (f z - f y) / (z - y) ≤ (f y - f x) / (y - x)) :
ConcaveOn 𝕜 s f := by
rw [← neg_convexOn_iff]
refine convexOn_of_slope_mono_adjacent hs fun hx hz hxy hyz => ?_
rw [← neg_le_neg_iff]
simp_rw [← neg_div, neg_sub, Pi.neg_apply, neg_sub_neg]
exact hf hx hz hxy hyz
#align concave_on_of_slope_anti_adjacent concaveOn_of_slope_anti_adjacent
/-- If for any three points `x < y < z`, the slope of the secant line of `f : 𝕜 → 𝕜` on `[x, y]` is
strictly less than the slope of the secant line of `f` on `[x, z]`, then `f` is strictly convex. -/
theorem strictConvexOn_of_slope_strict_mono_adjacent (hs : Convex 𝕜 s)
(hf :
∀ {x y z : 𝕜},
x ∈ s → z ∈ s → x < y → y < z → (f y - f x) / (y - x) < (f z - f y) / (z - y)) :
StrictConvexOn 𝕜 s f :=
LinearOrder.strictConvexOn_of_lt hs fun x hx z hz hxz a b ha hb hab => by
let y := a * x + b * z
have hxy : x < y := by
rw [← one_mul x, ← hab, add_mul]
exact add_lt_add_left ((mul_lt_mul_left hb).2 hxz) _
have hyz : y < z := by
rw [← one_mul z, ← hab, add_mul]
exact add_lt_add_right ((mul_lt_mul_left ha).2 hxz) _
have : (f y - f x) * (z - y) < (f z - f y) * (y - x) :=
(div_lt_div_iff (sub_pos.2 hxy) (sub_pos.2 hyz)).1 (hf hx hz hxy hyz)
have hxz : 0 < z - x := sub_pos.2 (hxy.trans hyz)
have ha : (z - y) / (z - x) = a := by
rw [eq_comm, ← sub_eq_iff_eq_add'] at hab
dsimp [y]
simp_rw [div_eq_iff hxz.ne', ← hab]
ring
have hb : (y - x) / (z - x) = b := by
rw [eq_comm, ← sub_eq_iff_eq_add] at hab
dsimp [y]
simp_rw [div_eq_iff hxz.ne', ← hab]
ring
rwa [sub_mul, sub_mul, sub_lt_iff_lt_add', ← add_sub_assoc, lt_sub_iff_add_lt, ← mul_add,
sub_add_sub_cancel, ← lt_div_iff hxz, add_div, mul_div_assoc, mul_div_assoc, mul_comm (f x),
mul_comm (f z), ha, hb] at this
#align strict_convex_on_of_slope_strict_mono_adjacent strictConvexOn_of_slope_strict_mono_adjacent
/-- If for any three points `x < y < z`, the slope of the secant line of `f : 𝕜 → 𝕜` on `[x, y]` is
strictly greater than the slope of the secant line of `f` on `[x, z]`, then `f` is strictly concave.
-/
theorem strictConcaveOn_of_slope_strict_anti_adjacent (hs : Convex 𝕜 s)
(hf :
∀ {x y z : 𝕜},
x ∈ s → z ∈ s → x < y → y < z → (f z - f y) / (z - y) < (f y - f x) / (y - x)) :
StrictConcaveOn 𝕜 s f := by
rw [← neg_strictConvexOn_iff]
refine strictConvexOn_of_slope_strict_mono_adjacent hs fun hx hz hxy hyz => ?_
rw [← neg_lt_neg_iff]
simp_rw [← neg_div, neg_sub, Pi.neg_apply, neg_sub_neg]
exact hf hx hz hxy hyz
#align strict_concave_on_of_slope_strict_anti_adjacent strictConcaveOn_of_slope_strict_anti_adjacent
/-- A function `f : 𝕜 → 𝕜` is convex iff for any three points `x < y < z` the slope of the secant
line of `f` on `[x, y]` is less than the slope of the secant line of `f` on `[x, z]`. -/
theorem convexOn_iff_slope_mono_adjacent :
ConvexOn 𝕜 s f ↔
Convex 𝕜 s ∧ ∀ ⦃x y z : 𝕜⦄,
x ∈ s → z ∈ s → x < y → y < z → (f y - f x) / (y - x) ≤ (f z - f y) / (z - y) :=
⟨fun h => ⟨h.1, fun _ _ _ => h.slope_mono_adjacent⟩, fun h =>
convexOn_of_slope_mono_adjacent h.1 (@fun _ _ _ hx hy => h.2 hx hy)⟩
#align convex_on_iff_slope_mono_adjacent convexOn_iff_slope_mono_adjacent
/-- A function `f : 𝕜 → 𝕜` is concave iff for any three points `x < y < z` the slope of the secant
line of `f` on `[x, y]` is greater than the slope of the secant line of `f` on `[x, z]`. -/
theorem concaveOn_iff_slope_anti_adjacent :
ConcaveOn 𝕜 s f ↔
Convex 𝕜 s ∧
∀ ⦃x y z : 𝕜⦄,
x ∈ s → z ∈ s → x < y → y < z → (f z - f y) / (z - y) ≤ (f y - f x) / (y - x) :=
⟨fun h => ⟨h.1, fun _ _ _ => h.slope_anti_adjacent⟩, fun h =>
concaveOn_of_slope_anti_adjacent h.1 (@fun _ _ _ hx hy => h.2 hx hy)⟩
#align concave_on_iff_slope_anti_adjacent concaveOn_iff_slope_anti_adjacent
/-- A function `f : 𝕜 → 𝕜` is strictly convex iff for any three points `x < y < z` the slope of
the secant line of `f` on `[x, y]` is strictly less than the slope of the secant line of `f` on
`[x, z]`. -/
theorem strictConvexOn_iff_slope_strict_mono_adjacent :
StrictConvexOn 𝕜 s f ↔
Convex 𝕜 s ∧
∀ ⦃x y z : 𝕜⦄,
x ∈ s → z ∈ s → x < y → y < z → (f y - f x) / (y - x) < (f z - f y) / (z - y) :=
⟨fun h => ⟨h.1, fun _ _ _ => h.slope_strict_mono_adjacent⟩, fun h =>
strictConvexOn_of_slope_strict_mono_adjacent h.1 (@fun _ _ _ hx hy => h.2 hx hy)⟩
#align strict_convex_on_iff_slope_strict_mono_adjacent strictConvexOn_iff_slope_strict_mono_adjacent
/-- A function `f : 𝕜 → 𝕜` is strictly concave iff for any three points `x < y < z` the slope of
the secant line of `f` on `[x, y]` is strictly greater than the slope of the secant line of `f` on
`[x, z]`. -/
theorem strictConcaveOn_iff_slope_strict_anti_adjacent :
StrictConcaveOn 𝕜 s f ↔
Convex 𝕜 s ∧
∀ ⦃x y z : 𝕜⦄,
x ∈ s → z ∈ s → x < y → y < z → (f z - f y) / (z - y) < (f y - f x) / (y - x) :=
⟨fun h => ⟨h.1, fun _ _ _ => h.slope_anti_adjacent⟩, fun h =>
strictConcaveOn_of_slope_strict_anti_adjacent h.1 (@fun _ _ _ hx hy => h.2 hx hy)⟩
#align strict_concave_on_iff_slope_strict_anti_adjacent strictConcaveOn_iff_slope_strict_anti_adjacent
theorem ConvexOn.secant_mono_aux1 (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s)
(hxy : x < y) (hyz : y < z) : (z - x) * f y ≤ (z - y) * f x + (y - x) * f z := by
have hxy' : 0 < y - x := by linarith
have hyz' : 0 < z - y := by linarith
have hxz' : 0 < z - x := by linarith
rw [← le_div_iff' hxz']
have ha : 0 ≤ (z - y) / (z - x) := by positivity
have hb : 0 ≤ (y - x) / (z - x) := by positivity
calc
f y = f ((z - y) / (z - x) * x + (y - x) / (z - x) * z) := ?_
_ ≤ (z - y) / (z - x) * f x + (y - x) / (z - x) * f z := hf.2 hx hz ha hb ?_
_ = ((z - y) * f x + (y - x) * f z) / (z - x) := ?_
· congr 1
field_simp
ring
· -- Porting note: this `show` wasn't needed in Lean 3
show (z - y) / (z - x) + (y - x) / (z - x) = 1
field_simp
· field_simp
#align convex_on.secant_mono_aux1 ConvexOn.secant_mono_aux1
theorem ConvexOn.secant_mono_aux2 (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s)
(hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) ≤ (f z - f x) / (z - x) := by
have hxy' : 0 < y - x := by linarith
have hxz' : 0 < z - x := by linarith
rw [div_le_div_iff hxy' hxz']
linarith only [hf.secant_mono_aux1 hx hz hxy hyz]
#align convex_on.secant_mono_aux2 ConvexOn.secant_mono_aux2
theorem ConvexOn.secant_mono_aux3 (hf : ConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s) (hz : z ∈ s)
(hxy : x < y) (hyz : y < z) : (f z - f x) / (z - x) ≤ (f z - f y) / (z - y) := by
have hyz' : 0 < z - y := by linarith
have hxz' : 0 < z - x := by linarith
rw [div_le_div_iff hxz' hyz']
linarith only [hf.secant_mono_aux1 hx hz hxy hyz]
#align convex_on.secant_mono_aux3 ConvexOn.secant_mono_aux3
theorem ConvexOn.secant_mono (hf : ConvexOn 𝕜 s f) {a x y : 𝕜} (ha : a ∈ s) (hx : x ∈ s)
(hy : y ∈ s) (hxa : x ≠ a) (hya : y ≠ a) (hxy : x ≤ y) :
(f x - f a) / (x - a) ≤ (f y - f a) / (y - a) := by
rcases eq_or_lt_of_le hxy with (rfl | hxy)
· simp
cases' lt_or_gt_of_ne hxa with hxa hxa
· cases' lt_or_gt_of_ne hya with hya hya
· convert hf.secant_mono_aux3 hx ha hxy hya using 1 <;> rw [← neg_div_neg_eq] <;> field_simp
· convert hf.slope_mono_adjacent hx hy hxa hya using 1
rw [← neg_div_neg_eq]; field_simp
· exact hf.secant_mono_aux2 ha hy hxa hxy
#align convex_on.secant_mono ConvexOn.secant_mono
theorem StrictConvexOn.secant_strict_mono_aux1 (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s)
(hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (z - x) * f y < (z - y) * f x + (y - x) * f z := by
have hxy' : 0 < y - x := by linarith
have hyz' : 0 < z - y := by linarith
have hxz' : 0 < z - x := by linarith
rw [← lt_div_iff' hxz']
have ha : 0 < (z - y) / (z - x) := by positivity
have hb : 0 < (y - x) / (z - x) := by positivity
calc
f y = f ((z - y) / (z - x) * x + (y - x) / (z - x) * z) := ?_
_ < (z - y) / (z - x) * f x + (y - x) / (z - x) * f z := hf.2 hx hz (by linarith) ha hb ?_
_ = ((z - y) * f x + (y - x) * f z) / (z - x) := ?_
· congr 1
field_simp
ring
· -- Porting note: this `show` wasn't needed in Lean 3
show (z - y) / (z - x) + (y - x) / (z - x) = 1
field_simp
· field_simp
#align strict_convex_on.secant_strict_mono_aux1 StrictConvexOn.secant_strict_mono_aux1
theorem StrictConvexOn.secant_strict_mono_aux2 (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s)
(hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f y - f x) / (y - x) < (f z - f x) / (z - x) := by
have hxy' : 0 < y - x := by linarith
have hxz' : 0 < z - x := by linarith
rw [div_lt_div_iff hxy' hxz']
linarith only [hf.secant_strict_mono_aux1 hx hz hxy hyz]
#align strict_convex_on.secant_strict_mono_aux2 StrictConvexOn.secant_strict_mono_aux2
| Mathlib/Analysis/Convex/Slope.lean | 315 | 320 | theorem StrictConvexOn.secant_strict_mono_aux3 (hf : StrictConvexOn 𝕜 s f) {x y z : 𝕜} (hx : x ∈ s)
(hz : z ∈ s) (hxy : x < y) (hyz : y < z) : (f z - f x) / (z - x) < (f z - f y) / (z - y) := by |
have hyz' : 0 < z - y := by linarith
have hxz' : 0 < z - x := by linarith
rw [div_lt_div_iff hxz' hyz']
linarith only [hf.secant_strict_mono_aux1 hx hz hxy hyz]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Scott Morrison
-/
import Mathlib.Algebra.Group.Indicator
import Mathlib.Algebra.Group.Submonoid.Basic
import Mathlib.Data.Set.Finite
#align_import data.finsupp.defs from "leanprover-community/mathlib"@"842328d9df7e96fd90fc424e115679c15fb23a71"
/-!
# Type of functions with finite support
For any type `α` and any type `M` with zero, we define the type `Finsupp α M` (notation: `α →₀ M`)
of finitely supported functions from `α` to `M`, i.e. the functions which are zero everywhere
on `α` except on a finite set.
Functions with finite support are used (at least) in the following parts of the library:
* `MonoidAlgebra R M` and `AddMonoidAlgebra R M` are defined as `M →₀ R`;
* polynomials and multivariate polynomials are defined as `AddMonoidAlgebra`s, hence they use
`Finsupp` under the hood;
* the linear combination of a family of vectors `v i` with coefficients `f i` (as used, e.g., to
define linearly independent family `LinearIndependent`) is defined as a map
`Finsupp.total : (ι → M) → (ι →₀ R) →ₗ[R] M`.
Some other constructions are naturally equivalent to `α →₀ M` with some `α` and `M` but are defined
in a different way in the library:
* `Multiset α ≃+ α →₀ ℕ`;
* `FreeAbelianGroup α ≃+ α →₀ ℤ`.
Most of the theory assumes that the range is a commutative additive monoid. This gives us the big
sum operator as a powerful way to construct `Finsupp` elements, which is defined in
`Algebra/BigOperators/Finsupp`.
-- Porting note: the semireducibility remark no longer applies in Lean 4, afaict.
Many constructions based on `α →₀ M` use `semireducible` type tags to avoid reusing unwanted type
instances. E.g., `MonoidAlgebra`, `AddMonoidAlgebra`, and types based on these two have
non-pointwise multiplication.
## Main declarations
* `Finsupp`: The type of finitely supported functions from `α` to `β`.
* `Finsupp.single`: The `Finsupp` which is nonzero in exactly one point.
* `Finsupp.update`: Changes one value of a `Finsupp`.
* `Finsupp.erase`: Replaces one value of a `Finsupp` by `0`.
* `Finsupp.onFinset`: The restriction of a function to a `Finset` as a `Finsupp`.
* `Finsupp.mapRange`: Composition of a `ZeroHom` with a `Finsupp`.
* `Finsupp.embDomain`: Maps the domain of a `Finsupp` by an embedding.
* `Finsupp.zipWith`: Postcomposition of two `Finsupp`s with a function `f` such that `f 0 0 = 0`.
## Notations
This file adds `α →₀ M` as a global notation for `Finsupp α M`.
We also use the following convention for `Type*` variables in this file
* `α`, `β`, `γ`: types with no additional structure that appear as the first argument to `Finsupp`
somewhere in the statement;
* `ι` : an auxiliary index type;
* `M`, `M'`, `N`, `P`: types with `Zero` or `(Add)(Comm)Monoid` structure; `M` is also used
for a (semi)module over a (semi)ring.
* `G`, `H`: groups (commutative or not, multiplicative or additive);
* `R`, `S`: (semi)rings.
## Implementation notes
This file is a `noncomputable theory` and uses classical logic throughout.
## TODO
* Expand the list of definitions and important lemmas to the module docstring.
-/
noncomputable section
open Finset Function
variable {α β γ ι M M' N P G H R S : Type*}
/-- `Finsupp α M`, denoted `α →₀ M`, is the type of functions `f : α → M` such that
`f x = 0` for all but finitely many `x`. -/
structure Finsupp (α : Type*) (M : Type*) [Zero M] where
/-- The support of a finitely supported function (aka `Finsupp`). -/
support : Finset α
/-- The underlying function of a bundled finitely supported function (aka `Finsupp`). -/
toFun : α → M
/-- The witness that the support of a `Finsupp` is indeed the exact locus where its
underlying function is nonzero. -/
mem_support_toFun : ∀ a, a ∈ support ↔ toFun a ≠ 0
#align finsupp Finsupp
#align finsupp.support Finsupp.support
#align finsupp.to_fun Finsupp.toFun
#align finsupp.mem_support_to_fun Finsupp.mem_support_toFun
@[inherit_doc]
infixr:25 " →₀ " => Finsupp
namespace Finsupp
/-! ### Basic declarations about `Finsupp` -/
section Basic
variable [Zero M]
instance instFunLike : FunLike (α →₀ M) α M :=
⟨toFun, by
rintro ⟨s, f, hf⟩ ⟨t, g, hg⟩ (rfl : f = g)
congr
ext a
exact (hf _).trans (hg _).symm⟩
#align finsupp.fun_like Finsupp.instFunLike
/-- Helper instance for when there are too many metavariables to apply the `DFunLike` instance
directly. -/
instance instCoeFun : CoeFun (α →₀ M) fun _ => α → M :=
inferInstance
#align finsupp.has_coe_to_fun Finsupp.instCoeFun
@[ext]
theorem ext {f g : α →₀ M} (h : ∀ a, f a = g a) : f = g :=
DFunLike.ext _ _ h
#align finsupp.ext Finsupp.ext
#align finsupp.ext_iff DFunLike.ext_iff
lemma ne_iff {f g : α →₀ M} : f ≠ g ↔ ∃ a, f a ≠ g a := DFunLike.ne_iff
#align finsupp.coe_fn_inj DFunLike.coe_fn_eq
#align finsupp.coe_fn_injective DFunLike.coe_injective
#align finsupp.congr_fun DFunLike.congr_fun
@[simp, norm_cast]
theorem coe_mk (f : α → M) (s : Finset α) (h : ∀ a, a ∈ s ↔ f a ≠ 0) : ⇑(⟨s, f, h⟩ : α →₀ M) = f :=
rfl
#align finsupp.coe_mk Finsupp.coe_mk
instance instZero : Zero (α →₀ M) :=
⟨⟨∅, 0, fun _ => ⟨fun h ↦ (not_mem_empty _ h).elim, fun H => (H rfl).elim⟩⟩⟩
#align finsupp.has_zero Finsupp.instZero
@[simp, norm_cast] lemma coe_zero : ⇑(0 : α →₀ M) = 0 := rfl
#align finsupp.coe_zero Finsupp.coe_zero
theorem zero_apply {a : α} : (0 : α →₀ M) a = 0 :=
rfl
#align finsupp.zero_apply Finsupp.zero_apply
@[simp]
theorem support_zero : (0 : α →₀ M).support = ∅ :=
rfl
#align finsupp.support_zero Finsupp.support_zero
instance instInhabited : Inhabited (α →₀ M) :=
⟨0⟩
#align finsupp.inhabited Finsupp.instInhabited
@[simp]
theorem mem_support_iff {f : α →₀ M} : ∀ {a : α}, a ∈ f.support ↔ f a ≠ 0 :=
@(f.mem_support_toFun)
#align finsupp.mem_support_iff Finsupp.mem_support_iff
@[simp, norm_cast]
theorem fun_support_eq (f : α →₀ M) : Function.support f = f.support :=
Set.ext fun _x => mem_support_iff.symm
#align finsupp.fun_support_eq Finsupp.fun_support_eq
theorem not_mem_support_iff {f : α →₀ M} {a} : a ∉ f.support ↔ f a = 0 :=
not_iff_comm.1 mem_support_iff.symm
#align finsupp.not_mem_support_iff Finsupp.not_mem_support_iff
@[simp, norm_cast]
theorem coe_eq_zero {f : α →₀ M} : (f : α → M) = 0 ↔ f = 0 := by rw [← coe_zero, DFunLike.coe_fn_eq]
#align finsupp.coe_eq_zero Finsupp.coe_eq_zero
theorem ext_iff' {f g : α →₀ M} : f = g ↔ f.support = g.support ∧ ∀ x ∈ f.support, f x = g x :=
⟨fun h => h ▸ ⟨rfl, fun _ _ => rfl⟩, fun ⟨h₁, h₂⟩ =>
ext fun a => by
classical
exact if h : a ∈ f.support then h₂ a h else by
have hf : f a = 0 := not_mem_support_iff.1 h
have hg : g a = 0 := by rwa [h₁, not_mem_support_iff] at h
rw [hf, hg]⟩
#align finsupp.ext_iff' Finsupp.ext_iff'
@[simp]
theorem support_eq_empty {f : α →₀ M} : f.support = ∅ ↔ f = 0 :=
mod_cast @Function.support_eq_empty_iff _ _ _ f
#align finsupp.support_eq_empty Finsupp.support_eq_empty
theorem support_nonempty_iff {f : α →₀ M} : f.support.Nonempty ↔ f ≠ 0 := by
simp only [Finsupp.support_eq_empty, Finset.nonempty_iff_ne_empty, Ne]
#align finsupp.support_nonempty_iff Finsupp.support_nonempty_iff
#align finsupp.nonzero_iff_exists Finsupp.ne_iff
theorem card_support_eq_zero {f : α →₀ M} : card f.support = 0 ↔ f = 0 := by simp
#align finsupp.card_support_eq_zero Finsupp.card_support_eq_zero
instance instDecidableEq [DecidableEq α] [DecidableEq M] : DecidableEq (α →₀ M) := fun f g =>
decidable_of_iff (f.support = g.support ∧ ∀ a ∈ f.support, f a = g a) ext_iff'.symm
#align finsupp.decidable_eq Finsupp.instDecidableEq
theorem finite_support (f : α →₀ M) : Set.Finite (Function.support f) :=
f.fun_support_eq.symm ▸ f.support.finite_toSet
#align finsupp.finite_support Finsupp.finite_support
theorem support_subset_iff {s : Set α} {f : α →₀ M} :
↑f.support ⊆ s ↔ ∀ a ∉ s, f a = 0 := by
simp only [Set.subset_def, mem_coe, mem_support_iff]; exact forall_congr' fun a => not_imp_comm
#align finsupp.support_subset_iff Finsupp.support_subset_iff
/-- Given `Finite α`, `equivFunOnFinite` is the `Equiv` between `α →₀ β` and `α → β`.
(All functions on a finite type are finitely supported.) -/
@[simps]
def equivFunOnFinite [Finite α] : (α →₀ M) ≃ (α → M) where
toFun := (⇑)
invFun f := mk (Function.support f).toFinite.toFinset f fun _a => Set.Finite.mem_toFinset _
left_inv _f := ext fun _x => rfl
right_inv _f := rfl
#align finsupp.equiv_fun_on_finite Finsupp.equivFunOnFinite
@[simp]
theorem equivFunOnFinite_symm_coe {α} [Finite α] (f : α →₀ M) : equivFunOnFinite.symm f = f :=
equivFunOnFinite.symm_apply_apply f
#align finsupp.equiv_fun_on_finite_symm_coe Finsupp.equivFunOnFinite_symm_coe
/--
If `α` has a unique term, the type of finitely supported functions `α →₀ β` is equivalent to `β`.
-/
@[simps!]
noncomputable def _root_.Equiv.finsuppUnique {ι : Type*} [Unique ι] : (ι →₀ M) ≃ M :=
Finsupp.equivFunOnFinite.trans (Equiv.funUnique ι M)
#align equiv.finsupp_unique Equiv.finsuppUnique
#align equiv.finsupp_unique_symm_apply_support_val Equiv.finsuppUnique_symm_apply_support_val
#align equiv.finsupp_unique_symm_apply_to_fun Equiv.finsuppUnique_symm_apply_toFun
#align equiv.finsupp_unique_apply Equiv.finsuppUnique_apply
@[ext]
theorem unique_ext [Unique α] {f g : α →₀ M} (h : f default = g default) : f = g :=
ext fun a => by rwa [Unique.eq_default a]
#align finsupp.unique_ext Finsupp.unique_ext
theorem unique_ext_iff [Unique α] {f g : α →₀ M} : f = g ↔ f default = g default :=
⟨fun h => h ▸ rfl, unique_ext⟩
#align finsupp.unique_ext_iff Finsupp.unique_ext_iff
end Basic
/-! ### Declarations about `single` -/
section Single
variable [Zero M] {a a' : α} {b : M}
/-- `single a b` is the finitely supported function with value `b` at `a` and zero otherwise. -/
def single (a : α) (b : M) : α →₀ M where
support :=
haveI := Classical.decEq M
if b = 0 then ∅ else {a}
toFun :=
haveI := Classical.decEq α
Pi.single a b
mem_support_toFun a' := by
classical
obtain rfl | hb := eq_or_ne b 0
· simp [Pi.single, update]
rw [if_neg hb, mem_singleton]
obtain rfl | ha := eq_or_ne a' a
· simp [hb, Pi.single, update]
simp [Pi.single_eq_of_ne' ha.symm, ha]
#align finsupp.single Finsupp.single
theorem single_apply [Decidable (a = a')] : single a b a' = if a = a' then b else 0 := by
classical
simp_rw [@eq_comm _ a a']
convert Pi.single_apply a b a'
#align finsupp.single_apply Finsupp.single_apply
theorem single_apply_left {f : α → β} (hf : Function.Injective f) (x z : α) (y : M) :
single (f x) y (f z) = single x y z := by classical simp only [single_apply, hf.eq_iff]
#align finsupp.single_apply_left Finsupp.single_apply_left
theorem single_eq_set_indicator : ⇑(single a b) = Set.indicator {a} fun _ => b := by
classical
ext
simp [single_apply, Set.indicator, @eq_comm _ a]
#align finsupp.single_eq_set_indicator Finsupp.single_eq_set_indicator
@[simp]
theorem single_eq_same : (single a b : α →₀ M) a = b := by
classical exact Pi.single_eq_same (f := fun _ ↦ M) a b
#align finsupp.single_eq_same Finsupp.single_eq_same
@[simp]
theorem single_eq_of_ne (h : a ≠ a') : (single a b : α →₀ M) a' = 0 := by
classical exact Pi.single_eq_of_ne' h _
#align finsupp.single_eq_of_ne Finsupp.single_eq_of_ne
theorem single_eq_update [DecidableEq α] (a : α) (b : M) :
⇑(single a b) = Function.update (0 : _) a b := by
classical rw [single_eq_set_indicator, ← Set.piecewise_eq_indicator, Set.piecewise_singleton]
#align finsupp.single_eq_update Finsupp.single_eq_update
theorem single_eq_pi_single [DecidableEq α] (a : α) (b : M) : ⇑(single a b) = Pi.single a b :=
single_eq_update a b
#align finsupp.single_eq_pi_single Finsupp.single_eq_pi_single
@[simp]
theorem single_zero (a : α) : (single a 0 : α →₀ M) = 0 :=
DFunLike.coe_injective <| by
classical simpa only [single_eq_update, coe_zero] using Function.update_eq_self a (0 : α → M)
#align finsupp.single_zero Finsupp.single_zero
theorem single_of_single_apply (a a' : α) (b : M) :
single a ((single a' b) a) = single a' (single a' b) a := by
classical
rw [single_apply, single_apply]
ext
split_ifs with h
· rw [h]
· rw [zero_apply, single_apply, ite_self]
#align finsupp.single_of_single_apply Finsupp.single_of_single_apply
theorem support_single_ne_zero (a : α) (hb : b ≠ 0) : (single a b).support = {a} :=
if_neg hb
#align finsupp.support_single_ne_zero Finsupp.support_single_ne_zero
theorem support_single_subset : (single a b).support ⊆ {a} := by
classical show ite _ _ _ ⊆ _; split_ifs <;> [exact empty_subset _; exact Subset.refl _]
#align finsupp.support_single_subset Finsupp.support_single_subset
theorem single_apply_mem (x) : single a b x ∈ ({0, b} : Set M) := by
rcases em (a = x) with (rfl | hx) <;> [simp; simp [single_eq_of_ne hx]]
#align finsupp.single_apply_mem Finsupp.single_apply_mem
theorem range_single_subset : Set.range (single a b) ⊆ {0, b} :=
Set.range_subset_iff.2 single_apply_mem
#align finsupp.range_single_subset Finsupp.range_single_subset
/-- `Finsupp.single a b` is injective in `b`. For the statement that it is injective in `a`, see
`Finsupp.single_left_injective` -/
theorem single_injective (a : α) : Function.Injective (single a : M → α →₀ M) := fun b₁ b₂ eq => by
have : (single a b₁ : α →₀ M) a = (single a b₂ : α →₀ M) a := by rw [eq]
rwa [single_eq_same, single_eq_same] at this
#align finsupp.single_injective Finsupp.single_injective
theorem single_apply_eq_zero {a x : α} {b : M} : single a b x = 0 ↔ x = a → b = 0 := by
simp [single_eq_set_indicator]
#align finsupp.single_apply_eq_zero Finsupp.single_apply_eq_zero
theorem single_apply_ne_zero {a x : α} {b : M} : single a b x ≠ 0 ↔ x = a ∧ b ≠ 0 := by
simp [single_apply_eq_zero]
#align finsupp.single_apply_ne_zero Finsupp.single_apply_ne_zero
theorem mem_support_single (a a' : α) (b : M) : a ∈ (single a' b).support ↔ a = a' ∧ b ≠ 0 := by
simp [single_apply_eq_zero, not_or]
#align finsupp.mem_support_single Finsupp.mem_support_single
theorem eq_single_iff {f : α →₀ M} {a b} : f = single a b ↔ f.support ⊆ {a} ∧ f a = b := by
refine ⟨fun h => h.symm ▸ ⟨support_single_subset, single_eq_same⟩, ?_⟩
rintro ⟨h, rfl⟩
ext x
by_cases hx : a = x <;> simp only [hx, single_eq_same, single_eq_of_ne, Ne, not_false_iff]
exact not_mem_support_iff.1 (mt (fun hx => (mem_singleton.1 (h hx)).symm) hx)
#align finsupp.eq_single_iff Finsupp.eq_single_iff
theorem single_eq_single_iff (a₁ a₂ : α) (b₁ b₂ : M) :
single a₁ b₁ = single a₂ b₂ ↔ a₁ = a₂ ∧ b₁ = b₂ ∨ b₁ = 0 ∧ b₂ = 0 := by
constructor
· intro eq
by_cases h : a₁ = a₂
· refine Or.inl ⟨h, ?_⟩
rwa [h, (single_injective a₂).eq_iff] at eq
· rw [DFunLike.ext_iff] at eq
have h₁ := eq a₁
have h₂ := eq a₂
simp only [single_eq_same, single_eq_of_ne h, single_eq_of_ne (Ne.symm h)] at h₁ h₂
exact Or.inr ⟨h₁, h₂.symm⟩
· rintro (⟨rfl, rfl⟩ | ⟨rfl, rfl⟩)
· rfl
· rw [single_zero, single_zero]
#align finsupp.single_eq_single_iff Finsupp.single_eq_single_iff
/-- `Finsupp.single a b` is injective in `a`. For the statement that it is injective in `b`, see
`Finsupp.single_injective` -/
theorem single_left_injective (h : b ≠ 0) : Function.Injective fun a : α => single a b :=
fun _a _a' H => (((single_eq_single_iff _ _ _ _).mp H).resolve_right fun hb => h hb.1).left
#align finsupp.single_left_injective Finsupp.single_left_injective
theorem single_left_inj (h : b ≠ 0) : single a b = single a' b ↔ a = a' :=
(single_left_injective h).eq_iff
#align finsupp.single_left_inj Finsupp.single_left_inj
theorem support_single_ne_bot (i : α) (h : b ≠ 0) : (single i b).support ≠ ⊥ := by
simpa only [support_single_ne_zero _ h] using singleton_ne_empty _
#align finsupp.support_single_ne_bot Finsupp.support_single_ne_bot
theorem support_single_disjoint {b' : M} (hb : b ≠ 0) (hb' : b' ≠ 0) {i j : α} :
Disjoint (single i b).support (single j b').support ↔ i ≠ j := by
rw [support_single_ne_zero _ hb, support_single_ne_zero _ hb', disjoint_singleton]
#align finsupp.support_single_disjoint Finsupp.support_single_disjoint
@[simp]
theorem single_eq_zero : single a b = 0 ↔ b = 0 := by
simp [DFunLike.ext_iff, single_eq_set_indicator]
#align finsupp.single_eq_zero Finsupp.single_eq_zero
theorem single_swap (a₁ a₂ : α) (b : M) : single a₁ b a₂ = single a₂ b a₁ := by
classical simp only [single_apply, eq_comm]
#align finsupp.single_swap Finsupp.single_swap
instance instNontrivial [Nonempty α] [Nontrivial M] : Nontrivial (α →₀ M) := by
inhabit α
rcases exists_ne (0 : M) with ⟨x, hx⟩
exact nontrivial_of_ne (single default x) 0 (mt single_eq_zero.1 hx)
#align finsupp.nontrivial Finsupp.instNontrivial
theorem unique_single [Unique α] (x : α →₀ M) : x = single default (x default) :=
ext <| Unique.forall_iff.2 single_eq_same.symm
#align finsupp.unique_single Finsupp.unique_single
@[simp]
theorem unique_single_eq_iff [Unique α] {b' : M} : single a b = single a' b' ↔ b = b' := by
rw [unique_ext_iff, Unique.eq_default a, Unique.eq_default a', single_eq_same, single_eq_same]
#align finsupp.unique_single_eq_iff Finsupp.unique_single_eq_iff
lemma apply_single [AddCommMonoid N] [AddCommMonoid P]
{F : Type*} [FunLike F N P] [AddMonoidHomClass F N P] (e : F)
(a : α) (n : N) (b : α) :
e ((single a n) b) = single a (e n) b := by
classical
simp only [single_apply]
split_ifs
· rfl
· exact map_zero e
theorem support_eq_singleton {f : α →₀ M} {a : α} :
f.support = {a} ↔ f a ≠ 0 ∧ f = single a (f a) :=
⟨fun h =>
⟨mem_support_iff.1 <| h.symm ▸ Finset.mem_singleton_self a,
eq_single_iff.2 ⟨subset_of_eq h, rfl⟩⟩,
fun h => h.2.symm ▸ support_single_ne_zero _ h.1⟩
#align finsupp.support_eq_singleton Finsupp.support_eq_singleton
theorem support_eq_singleton' {f : α →₀ M} {a : α} :
f.support = {a} ↔ ∃ b ≠ 0, f = single a b :=
⟨fun h =>
let h := support_eq_singleton.1 h
⟨_, h.1, h.2⟩,
fun ⟨_b, hb, hf⟩ => hf.symm ▸ support_single_ne_zero _ hb⟩
#align finsupp.support_eq_singleton' Finsupp.support_eq_singleton'
theorem card_support_eq_one {f : α →₀ M} :
card f.support = 1 ↔ ∃ a, f a ≠ 0 ∧ f = single a (f a) := by
simp only [card_eq_one, support_eq_singleton]
#align finsupp.card_support_eq_one Finsupp.card_support_eq_one
theorem card_support_eq_one' {f : α →₀ M} :
card f.support = 1 ↔ ∃ a, ∃ b ≠ 0, f = single a b := by
simp only [card_eq_one, support_eq_singleton']
#align finsupp.card_support_eq_one' Finsupp.card_support_eq_one'
theorem support_subset_singleton {f : α →₀ M} {a : α} : f.support ⊆ {a} ↔ f = single a (f a) :=
⟨fun h => eq_single_iff.mpr ⟨h, rfl⟩, fun h => (eq_single_iff.mp h).left⟩
#align finsupp.support_subset_singleton Finsupp.support_subset_singleton
theorem support_subset_singleton' {f : α →₀ M} {a : α} : f.support ⊆ {a} ↔ ∃ b, f = single a b :=
⟨fun h => ⟨f a, support_subset_singleton.mp h⟩, fun ⟨b, hb⟩ => by
rw [hb, support_subset_singleton, single_eq_same]⟩
#align finsupp.support_subset_singleton' Finsupp.support_subset_singleton'
theorem card_support_le_one [Nonempty α] {f : α →₀ M} :
card f.support ≤ 1 ↔ ∃ a, f = single a (f a) := by
simp only [card_le_one_iff_subset_singleton, support_subset_singleton]
#align finsupp.card_support_le_one Finsupp.card_support_le_one
theorem card_support_le_one' [Nonempty α] {f : α →₀ M} :
card f.support ≤ 1 ↔ ∃ a b, f = single a b := by
simp only [card_le_one_iff_subset_singleton, support_subset_singleton']
#align finsupp.card_support_le_one' Finsupp.card_support_le_one'
@[simp]
theorem equivFunOnFinite_single [DecidableEq α] [Finite α] (x : α) (m : M) :
Finsupp.equivFunOnFinite (Finsupp.single x m) = Pi.single x m := by
ext
simp [Finsupp.single_eq_pi_single, equivFunOnFinite]
#align finsupp.equiv_fun_on_finite_single Finsupp.equivFunOnFinite_single
@[simp]
theorem equivFunOnFinite_symm_single [DecidableEq α] [Finite α] (x : α) (m : M) :
Finsupp.equivFunOnFinite.symm (Pi.single x m) = Finsupp.single x m := by
rw [← equivFunOnFinite_single, Equiv.symm_apply_apply]
#align finsupp.equiv_fun_on_finite_symm_single Finsupp.equivFunOnFinite_symm_single
end Single
/-! ### Declarations about `update` -/
section Update
variable [Zero M] (f : α →₀ M) (a : α) (b : M) (i : α)
/-- Replace the value of a `α →₀ M` at a given point `a : α` by a given value `b : M`.
If `b = 0`, this amounts to removing `a` from the `Finsupp.support`.
Otherwise, if `a` was not in the `Finsupp.support`, it is added to it.
This is the finitely-supported version of `Function.update`. -/
def update (f : α →₀ M) (a : α) (b : M) : α →₀ M where
support := by
haveI := Classical.decEq α; haveI := Classical.decEq M
exact if b = 0 then f.support.erase a else insert a f.support
toFun :=
haveI := Classical.decEq α
Function.update f a b
mem_support_toFun i := by
classical
rw [Function.update]
simp only [eq_rec_constant, dite_eq_ite, ne_eq]
split_ifs with hb ha ha <;>
try simp only [*, not_false_iff, iff_true, not_true, iff_false]
· rw [Finset.mem_erase]
simp
· rw [Finset.mem_erase]
simp [ha]
· rw [Finset.mem_insert]
simp [ha]
· rw [Finset.mem_insert]
simp [ha]
#align finsupp.update Finsupp.update
@[simp, norm_cast]
| Mathlib/Data/Finsupp/Defs.lean | 547 | 551 | theorem coe_update [DecidableEq α] : (f.update a b : α → M) = Function.update f a b := by |
delta update Function.update
ext
dsimp
split_ifs <;> simp
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Regular.SMul
#align_import data.polynomial.monic from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5"
/-!
# Theory of monic polynomials
We give several tools for proving that polynomials are monic, e.g.
`Monic.mul`, `Monic.map`, `Monic.pow`.
-/
noncomputable section
open Finset
open Polynomial
namespace Polynomial
universe u v y
variable {R : Type u} {S : Type v} {a b : R} {m n : ℕ} {ι : Type y}
section Semiring
variable [Semiring R] {p q r : R[X]}
theorem monic_zero_iff_subsingleton : Monic (0 : R[X]) ↔ Subsingleton R :=
subsingleton_iff_zero_eq_one
#align polynomial.monic_zero_iff_subsingleton Polynomial.monic_zero_iff_subsingleton
theorem not_monic_zero_iff : ¬Monic (0 : R[X]) ↔ (0 : R) ≠ 1 :=
(monic_zero_iff_subsingleton.trans subsingleton_iff_zero_eq_one.symm).not
#align polynomial.not_monic_zero_iff Polynomial.not_monic_zero_iff
theorem monic_zero_iff_subsingleton' :
Monic (0 : R[X]) ↔ (∀ f g : R[X], f = g) ∧ ∀ a b : R, a = b :=
Polynomial.monic_zero_iff_subsingleton.trans
⟨by
intro
simp [eq_iff_true_of_subsingleton], fun h => subsingleton_iff.mpr h.2⟩
#align polynomial.monic_zero_iff_subsingleton' Polynomial.monic_zero_iff_subsingleton'
theorem Monic.as_sum (hp : p.Monic) :
p = X ^ p.natDegree + ∑ i ∈ range p.natDegree, C (p.coeff i) * X ^ i := by
conv_lhs => rw [p.as_sum_range_C_mul_X_pow, sum_range_succ_comm]
suffices C (p.coeff p.natDegree) = 1 by rw [this, one_mul]
exact congr_arg C hp
#align polynomial.monic.as_sum Polynomial.Monic.as_sum
theorem ne_zero_of_ne_zero_of_monic (hp : p ≠ 0) (hq : Monic q) : q ≠ 0 := by
rintro rfl
rw [Monic.def, leadingCoeff_zero] at hq
rw [← mul_one p, ← C_1, ← hq, C_0, mul_zero] at hp
exact hp rfl
#align polynomial.ne_zero_of_ne_zero_of_monic Polynomial.ne_zero_of_ne_zero_of_monic
| Mathlib/Algebra/Polynomial/Monic.lean | 65 | 73 | theorem Monic.map [Semiring S] (f : R →+* S) (hp : Monic p) : Monic (p.map f) := by |
unfold Monic
nontriviality
have : f p.leadingCoeff ≠ 0 := by
rw [show _ = _ from hp, f.map_one]
exact one_ne_zero
rw [Polynomial.leadingCoeff, coeff_map]
suffices p.coeff (p.map f).natDegree = 1 by simp [this]
rwa [natDegree_eq_of_degree_eq (degree_map_eq_of_leadingCoeff_ne_zero f this)]
|
/-
Copyright (c) 2024 Mitchell Lee. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mitchell Lee
-/
import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Coxeter.Basic
/-!
# The length function, reduced words, and descents
Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix.
`cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data
of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on
`B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean`
for more details.
Given any element $w \in W$, its *length* (`CoxeterSystem.length`), denoted $\ell(w)$, is the
minimum number $\ell$ such that $w$ can be written as a product of a sequence of $\ell$ simple
reflections:
$$w = s_{i_1} \cdots s_{i_\ell}.$$
We prove for all $w_1, w_2 \in W$ that $\ell (w_1 w_2) \leq \ell (w_1) + \ell (w_2)$
and that $\ell (w_1 w_2)$ has the same parity as $\ell (w_1) + \ell (w_2)$.
We define a *reduced word* (`CoxeterSystem.IsReduced`) for an element $w \in W$ to be a way of
writing $w$ as a product of exactly $\ell(w)$ simple reflections. Every element of $W$ has a reduced
word.
We say that $i \in B$ is a *left descent* (`CoxeterSystem.IsLeftDescent`) of $w \in W$ if
$\ell(s_i w) < \ell(w)$. We show that if $i$ is a left descent of $w$, then
$\ell(s_i w) + 1 = \ell(w)$. On the other hand, if $i$ is not a left descent of $w$, then
$\ell(s_i w) = \ell(w) + 1$. We similarly define right descents (`CoxeterSystem.IsRightDescent`) and
prove analogous results.
## Main definitions
* `cs.length`
* `cs.IsReduced`
* `cs.IsLeftDescent`
* `cs.IsRightDescent`
## References
* [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005)
-/
namespace CoxeterSystem
open List Matrix Function Classical
variable {B : Type*}
variable {W : Type*} [Group W]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
local prefix:100 "s" => cs.simple
local prefix:100 "π" => cs.wordProd
/-! ### Length -/
private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by
rcases cs.wordProd_surjective w with ⟨ω, rfl⟩
use ω.length, ω
/-- The length of `w`; i.e., the minimum number of simple reflections that
must be multiplied to form `w`. -/
noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w)
local prefix:100 "ℓ" => cs.length
theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by
have := Nat.find_spec (cs.exists_word_with_prod w)
tauto
theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length :=
Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩
@[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le [])
@[simp]
theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by
constructor
· intro h
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h)
rw [this, wordProd_nil]
· rintro rfl
exact cs.length_one
@[simp]
theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by
apply Nat.le_antisymm
· rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
have := cs.length_wordProd_le (List.reverse ω)
rwa [wordProd_reverse, length_reverse, hω] at this
· rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩
have := cs.length_wordProd_le (List.reverse ω)
rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
theorem length_mul_le (w₁ w₂ : W) :
ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by
rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩
rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩
have := cs.length_wordProd_le (ω₁ ++ ω₂)
simpa [hω₁, hω₂, wordProd_append] using this
theorem length_mul_ge_length_sub_length (w₁ w₂ : W) :
ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹
theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) :
ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂)
theorem length_mul_ge_max (w₁ w₂ : W) :
max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) :=
max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩
/-- The homomorphism that sends each element `w : W` to the parity of the length of `w`.
(See `lengthParity_eq_ofAdd_length`.) -/
def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by
simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)]
simp⟩
theorem lengthParity_simple (i : B):
cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _
theorem lengthParity_comp_simple :
cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple
theorem lengthParity_eq_ofAdd_length (w : W) :
cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const',
prod_replicate, ← ofAdd_nsmul, nsmul_one]
theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by
rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add]
simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂
@[simp]
theorem length_simple (i : B) : ℓ (s i) = 1 := by
apply Nat.le_antisymm
· simpa using cs.length_wordProd_le [i]
· by_contra! length_lt_one
have : cs.lengthParity (s i) = Multiplicative.ofAdd 0 := by
rw [lengthParity_eq_ofAdd_length, Nat.lt_one_iff.mp length_lt_one, Nat.cast_zero]
have : Multiplicative.ofAdd (0 : ZMod 2) = Multiplicative.ofAdd 1 :=
this.symm.trans (cs.lengthParity_simple i)
contradiction
theorem length_eq_one_iff {w : W} : ℓ w = 1 ↔ ∃ i : B, w = s i := by
constructor
· intro h
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
rcases List.length_eq_one.mp (hω.trans h) with ⟨i, rfl⟩
exact ⟨i, cs.wordProd_singleton i⟩
· rintro ⟨i, rfl⟩
exact cs.length_simple i
theorem length_mul_simple_ne (w : W) (i : B) : ℓ (w * s i) ≠ ℓ w := by
intro eq
have length_mod_two := cs.length_mul_mod_two w (s i)
rw [eq, length_simple] at length_mod_two
rcases Nat.mod_two_eq_zero_or_one (ℓ w) with even | odd
· rw [even, Nat.succ_mod_two_eq_one_iff.mpr even] at length_mod_two
contradiction
· rw [odd, Nat.succ_mod_two_eq_zero_iff.mpr odd] at length_mod_two
contradiction
theorem length_simple_mul_ne (w : W) (i : B) : ℓ (s i * w) ≠ ℓ w := by
convert cs.length_mul_simple_ne w⁻¹ i using 1
· convert cs.length_inv ?_ using 2
simp
· simp
theorem length_mul_simple (w : W) (i : B) :
ℓ (w * s i) = ℓ w + 1 ∨ ℓ (w * s i) + 1 = ℓ w := by
rcases Nat.lt_or_gt_of_ne (cs.length_mul_simple_ne w i) with lt | gt
· -- lt : ℓ (w * s i) < ℓ w
right
have length_ge := cs.length_mul_ge_length_sub_length w (s i)
simp only [length_simple, tsub_le_iff_right] at length_ge
-- length_ge : ℓ w ≤ ℓ (w * s i) + 1
linarith
· -- gt : ℓ w < ℓ (w * s i)
left
have length_le := cs.length_mul_le w (s i)
simp only [length_simple] at length_le
-- length_le : ℓ (w * s i) ≤ ℓ w + 1
linarith
theorem length_simple_mul (w : W) (i : B) :
ℓ (s i * w) = ℓ w + 1 ∨ ℓ (s i * w) + 1 = ℓ w := by
have := cs.length_mul_simple w⁻¹ i
rwa [(by simp : w⁻¹ * (s i) = ((s i) * w)⁻¹), length_inv, length_inv] at this
/-! ### Reduced words -/
/-- The proposition that `ω` is reduced; that is, it has minimal length among all words that
represent the same element of `W`. -/
def IsReduced (ω : List B) : Prop := ℓ (π ω) = ω.length
@[simp]
theorem isReduced_reverse (ω : List B) : cs.IsReduced (ω.reverse) ↔ cs.IsReduced ω := by
simp [IsReduced]
theorem exists_reduced_word' (w : W) : ∃ ω : List B, cs.IsReduced ω ∧ w = π ω := by
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
use ω
tauto
private theorem isReduced_take_and_drop {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) :
cs.IsReduced (ω.take j) ∧ cs.IsReduced (ω.drop j) := by
have h₁ : ℓ (π (ω.take j)) ≤ (ω.take j).length := cs.length_wordProd_le (ω.take j)
have h₂ : ℓ (π (ω.drop j)) ≤ (ω.drop j).length := cs.length_wordProd_le (ω.drop j)
have h₃ := calc
(ω.take j).length + (ω.drop j).length
_ = ω.length := by rw [← List.length_append, ω.take_append_drop j];
_ = ℓ (π ω) := hω.symm
_ = ℓ (π (ω.take j) * π (ω.drop j)) := by rw [← cs.wordProd_append, ω.take_append_drop j];
_ ≤ ℓ (π (ω.take j)) + ℓ (π (ω.drop j)) := cs.length_mul_le _ _
unfold IsReduced
exact ⟨by linarith, by linarith⟩
theorem isReduced_take {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) : cs.IsReduced (ω.take j) :=
(isReduced_take_and_drop _ hω _).1
theorem isReduced_drop {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) : cs.IsReduced (ω.drop j) :=
(isReduced_take_and_drop _ hω _).2
theorem not_isReduced_alternatingWord (i i' : B) {m : ℕ} (hM : M i i' ≠ 0) (hm : m > M i i') :
¬cs.IsReduced (alternatingWord i i' m) := by
induction' hm with m _ ih
· -- Base case; m = M i i' + 1
suffices h : ℓ (π (alternatingWord i i' (M i i' + 1))) < M i i' + 1 by
unfold IsReduced
rw [Nat.succ_eq_add_one, length_alternatingWord]
linarith
have : M i i' + 1 ≤ M i i' * 2 := by linarith [Nat.one_le_iff_ne_zero.mpr hM]
rw [cs.prod_alternatingWord_eq_prod_alternatingWord_sub i i' _ this]
have : M i i' * 2 - (M i i' + 1) = M i i' - 1 := by
apply (Nat.sub_eq_iff_eq_add' this).mpr
rw [add_assoc, add_comm 1, Nat.sub_add_cancel (Nat.one_le_iff_ne_zero.mpr hM)]
exact mul_two _
rw [this]
calc
ℓ (π (alternatingWord i' i (M i i' - 1)))
_ ≤ (alternatingWord i' i (M i i' - 1)).length := cs.length_wordProd_le _
_ = M i i' - 1 := length_alternatingWord _ _ _
_ ≤ M i i' := Nat.sub_le _ _
_ < M i i' + 1 := Nat.lt_succ_self _
· -- Inductive step
contrapose! ih
rw [alternatingWord_succ'] at ih
apply isReduced_drop (j := 1) at ih
simpa using ih
/-! ### Descents -/
/-- The proposition that `i` is a left descent of `w`; that is, $\ell(s_i w) < \ell(w)$. -/
def IsLeftDescent (w : W) (i : B) : Prop := ℓ (s i * w) < ℓ w
/-- The proposition that `i` is a right descent of `w`; that is, $\ell(w s_i) < \ell(w)$. -/
def IsRightDescent (w : W) (i : B) : Prop := ℓ (w * s i) < ℓ w
theorem not_isLeftDescent_one (i : B) : ¬cs.IsLeftDescent 1 i := by simp [IsLeftDescent]
| Mathlib/GroupTheory/Coxeter/Length.lean | 269 | 269 | theorem not_isRightDescent_one (i : B) : ¬cs.IsRightDescent 1 i := by | simp [IsRightDescent]
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.LinearAlgebra.AffineSpace.AffineEquiv
#align_import linear_algebra.affine_space.affine_subspace from "leanprover-community/mathlib"@"e96bdfbd1e8c98a09ff75f7ac6204d142debc840"
/-!
# Affine spaces
This file defines affine subspaces (over modules) and the affine span of a set of points.
## Main definitions
* `AffineSubspace k P` is the type of affine subspaces. Unlike affine spaces, affine subspaces are
allowed to be empty, and lemmas that do not apply to empty affine subspaces have `Nonempty`
hypotheses. There is a `CompleteLattice` structure on affine subspaces.
* `AffineSubspace.direction` gives the `Submodule` spanned by the pairwise differences of points
in an `AffineSubspace`. There are various lemmas relating to the set of vectors in the
`direction`, and relating the lattice structure on affine subspaces to that on their directions.
* `AffineSubspace.parallel`, notation `∥`, gives the property of two affine subspaces being
parallel (one being a translate of the other).
* `affineSpan` gives the affine subspace spanned by a set of points, with `vectorSpan` giving its
direction. The `affineSpan` is defined in terms of `spanPoints`, which gives an explicit
description of the points contained in the affine span; `spanPoints` itself should generally only
be used when that description is required, with `affineSpan` being the main definition for other
purposes. Two other descriptions of the affine span are proved equivalent: it is the `sInf` of
affine subspaces containing the points, and (if `[Nontrivial k]`) it contains exactly those points
that are affine combinations of points in the given set.
## Implementation notes
`outParam` is used in the definition of `AddTorsor V P` to make `V` an implicit argument (deduced
from `P`) in most cases. As for modules, `k` is an explicit argument rather than implied by `P` or
`V`.
This file only provides purely algebraic definitions and results. Those depending on analysis or
topology are defined elsewhere; see `Analysis.NormedSpace.AddTorsor` and `Topology.Algebra.Affine`.
## References
* https://en.wikipedia.org/wiki/Affine_space
* https://en.wikipedia.org/wiki/Principal_homogeneous_space
-/
noncomputable section
open Affine
open Set
section
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [AffineSpace V P]
/-- The submodule spanning the differences of a (possibly empty) set of points. -/
def vectorSpan (s : Set P) : Submodule k V :=
Submodule.span k (s -ᵥ s)
#align vector_span vectorSpan
/-- The definition of `vectorSpan`, for rewriting. -/
theorem vectorSpan_def (s : Set P) : vectorSpan k s = Submodule.span k (s -ᵥ s) :=
rfl
#align vector_span_def vectorSpan_def
/-- `vectorSpan` is monotone. -/
theorem vectorSpan_mono {s₁ s₂ : Set P} (h : s₁ ⊆ s₂) : vectorSpan k s₁ ≤ vectorSpan k s₂ :=
Submodule.span_mono (vsub_self_mono h)
#align vector_span_mono vectorSpan_mono
variable (P)
/-- The `vectorSpan` of the empty set is `⊥`. -/
@[simp]
theorem vectorSpan_empty : vectorSpan k (∅ : Set P) = (⊥ : Submodule k V) := by
rw [vectorSpan_def, vsub_empty, Submodule.span_empty]
#align vector_span_empty vectorSpan_empty
variable {P}
/-- The `vectorSpan` of a single point is `⊥`. -/
@[simp]
theorem vectorSpan_singleton (p : P) : vectorSpan k ({p} : Set P) = ⊥ := by simp [vectorSpan_def]
#align vector_span_singleton vectorSpan_singleton
/-- The `s -ᵥ s` lies within the `vectorSpan k s`. -/
theorem vsub_set_subset_vectorSpan (s : Set P) : s -ᵥ s ⊆ ↑(vectorSpan k s) :=
Submodule.subset_span
#align vsub_set_subset_vector_span vsub_set_subset_vectorSpan
/-- Each pairwise difference is in the `vectorSpan`. -/
theorem vsub_mem_vectorSpan {s : Set P} {p1 p2 : P} (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) :
p1 -ᵥ p2 ∈ vectorSpan k s :=
vsub_set_subset_vectorSpan k s (vsub_mem_vsub hp1 hp2)
#align vsub_mem_vector_span vsub_mem_vectorSpan
/-- The points in the affine span of a (possibly empty) set of points. Use `affineSpan` instead to
get an `AffineSubspace k P`. -/
def spanPoints (s : Set P) : Set P :=
{ p | ∃ p1 ∈ s, ∃ v ∈ vectorSpan k s, p = v +ᵥ p1 }
#align span_points spanPoints
/-- A point in a set is in its affine span. -/
theorem mem_spanPoints (p : P) (s : Set P) : p ∈ s → p ∈ spanPoints k s
| hp => ⟨p, hp, 0, Submodule.zero_mem _, (zero_vadd V p).symm⟩
#align mem_span_points mem_spanPoints
/-- A set is contained in its `spanPoints`. -/
theorem subset_spanPoints (s : Set P) : s ⊆ spanPoints k s := fun p => mem_spanPoints k p s
#align subset_span_points subset_spanPoints
/-- The `spanPoints` of a set is nonempty if and only if that set is. -/
@[simp]
theorem spanPoints_nonempty (s : Set P) : (spanPoints k s).Nonempty ↔ s.Nonempty := by
constructor
· contrapose
rw [Set.not_nonempty_iff_eq_empty, Set.not_nonempty_iff_eq_empty]
intro h
simp [h, spanPoints]
· exact fun h => h.mono (subset_spanPoints _ _)
#align span_points_nonempty spanPoints_nonempty
/-- Adding a point in the affine span and a vector in the spanning submodule produces a point in the
affine span. -/
theorem vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan {s : Set P} {p : P} {v : V}
(hp : p ∈ spanPoints k s) (hv : v ∈ vectorSpan k s) : v +ᵥ p ∈ spanPoints k s := by
rcases hp with ⟨p2, ⟨hp2, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
rw [hv2p, vadd_vadd]
exact ⟨p2, hp2, v + v2, (vectorSpan k s).add_mem hv hv2, rfl⟩
#align vadd_mem_span_points_of_mem_span_points_of_mem_vector_span vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan
/-- Subtracting two points in the affine span produces a vector in the spanning submodule. -/
theorem vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints {s : Set P} {p1 p2 : P}
(hp1 : p1 ∈ spanPoints k s) (hp2 : p2 ∈ spanPoints k s) : p1 -ᵥ p2 ∈ vectorSpan k s := by
rcases hp1 with ⟨p1a, ⟨hp1a, ⟨v1, ⟨hv1, hv1p⟩⟩⟩⟩
rcases hp2 with ⟨p2a, ⟨hp2a, ⟨v2, ⟨hv2, hv2p⟩⟩⟩⟩
rw [hv1p, hv2p, vsub_vadd_eq_vsub_sub (v1 +ᵥ p1a), vadd_vsub_assoc, add_comm, add_sub_assoc]
have hv1v2 : v1 - v2 ∈ vectorSpan k s := (vectorSpan k s).sub_mem hv1 hv2
refine (vectorSpan k s).add_mem ?_ hv1v2
exact vsub_mem_vectorSpan k hp1a hp2a
#align vsub_mem_vector_span_of_mem_span_points_of_mem_span_points vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints
end
/-- An `AffineSubspace k P` is a subset of an `AffineSpace V P` that, if not empty, has an affine
space structure induced by a corresponding subspace of the `Module k V`. -/
structure AffineSubspace (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V]
[Module k V] [AffineSpace V P] where
/-- The affine subspace seen as a subset. -/
carrier : Set P
smul_vsub_vadd_mem :
∀ (c : k) {p1 p2 p3 : P},
p1 ∈ carrier → p2 ∈ carrier → p3 ∈ carrier → c • (p1 -ᵥ p2 : V) +ᵥ p3 ∈ carrier
#align affine_subspace AffineSubspace
namespace Submodule
variable {k V : Type*} [Ring k] [AddCommGroup V] [Module k V]
/-- Reinterpret `p : Submodule k V` as an `AffineSubspace k V`. -/
def toAffineSubspace (p : Submodule k V) : AffineSubspace k V where
carrier := p
smul_vsub_vadd_mem _ _ _ _ h₁ h₂ h₃ := p.add_mem (p.smul_mem _ (p.sub_mem h₁ h₂)) h₃
#align submodule.to_affine_subspace Submodule.toAffineSubspace
end Submodule
namespace AffineSubspace
variable (k : Type*) {V : Type*} (P : Type*) [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
instance : SetLike (AffineSubspace k P) P where
coe := carrier
coe_injective' p q _ := by cases p; cases q; congr
/-- A point is in an affine subspace coerced to a set if and only if it is in that affine
subspace. -/
-- Porting note: removed `simp`, proof is `simp only [SetLike.mem_coe]`
theorem mem_coe (p : P) (s : AffineSubspace k P) : p ∈ (s : Set P) ↔ p ∈ s :=
Iff.rfl
#align affine_subspace.mem_coe AffineSubspace.mem_coe
variable {k P}
/-- The direction of an affine subspace is the submodule spanned by
the pairwise differences of points. (Except in the case of an empty
affine subspace, where the direction is the zero submodule, every
vector in the direction is the difference of two points in the affine
subspace.) -/
def direction (s : AffineSubspace k P) : Submodule k V :=
vectorSpan k (s : Set P)
#align affine_subspace.direction AffineSubspace.direction
/-- The direction equals the `vectorSpan`. -/
theorem direction_eq_vectorSpan (s : AffineSubspace k P) : s.direction = vectorSpan k (s : Set P) :=
rfl
#align affine_subspace.direction_eq_vector_span AffineSubspace.direction_eq_vectorSpan
/-- Alternative definition of the direction when the affine subspace is nonempty. This is defined so
that the order on submodules (as used in the definition of `Submodule.span`) can be used in the
proof of `coe_direction_eq_vsub_set`, and is not intended to be used beyond that proof. -/
def directionOfNonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) : Submodule k V where
carrier := (s : Set P) -ᵥ s
zero_mem' := by
cases' h with p hp
exact vsub_self p ▸ vsub_mem_vsub hp hp
add_mem' := by
rintro _ _ ⟨p1, hp1, p2, hp2, rfl⟩ ⟨p3, hp3, p4, hp4, rfl⟩
rw [← vadd_vsub_assoc]
refine vsub_mem_vsub ?_ hp4
convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp3
rw [one_smul]
smul_mem' := by
rintro c _ ⟨p1, hp1, p2, hp2, rfl⟩
rw [← vadd_vsub (c • (p1 -ᵥ p2)) p2]
refine vsub_mem_vsub ?_ hp2
exact s.smul_vsub_vadd_mem c hp1 hp2 hp2
#align affine_subspace.direction_of_nonempty AffineSubspace.directionOfNonempty
/-- `direction_of_nonempty` gives the same submodule as `direction`. -/
theorem directionOfNonempty_eq_direction {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
directionOfNonempty h = s.direction := by
refine le_antisymm ?_ (Submodule.span_le.2 Set.Subset.rfl)
rw [← SetLike.coe_subset_coe, directionOfNonempty, direction, Submodule.coe_set_mk,
AddSubmonoid.coe_set_mk]
exact vsub_set_subset_vectorSpan k _
#align affine_subspace.direction_of_nonempty_eq_direction AffineSubspace.directionOfNonempty_eq_direction
/-- The set of vectors in the direction of a nonempty affine subspace is given by `vsub_set`. -/
theorem coe_direction_eq_vsub_set {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
(s.direction : Set V) = (s : Set P) -ᵥ s :=
directionOfNonempty_eq_direction h ▸ rfl
#align affine_subspace.coe_direction_eq_vsub_set AffineSubspace.coe_direction_eq_vsub_set
/-- A vector is in the direction of a nonempty affine subspace if and only if it is the subtraction
of two vectors in the subspace. -/
theorem mem_direction_iff_eq_vsub {s : AffineSubspace k P} (h : (s : Set P).Nonempty) (v : V) :
v ∈ s.direction ↔ ∃ p1 ∈ s, ∃ p2 ∈ s, v = p1 -ᵥ p2 := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set h, Set.mem_vsub]
simp only [SetLike.mem_coe, eq_comm]
#align affine_subspace.mem_direction_iff_eq_vsub AffineSubspace.mem_direction_iff_eq_vsub
/-- Adding a vector in the direction to a point in the subspace produces a point in the
subspace. -/
theorem vadd_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction) {p : P}
(hp : p ∈ s) : v +ᵥ p ∈ s := by
rw [mem_direction_iff_eq_vsub ⟨p, hp⟩] at hv
rcases hv with ⟨p1, hp1, p2, hp2, hv⟩
rw [hv]
convert s.smul_vsub_vadd_mem 1 hp1 hp2 hp
rw [one_smul]
exact s.mem_coe k P _
#align affine_subspace.vadd_mem_of_mem_direction AffineSubspace.vadd_mem_of_mem_direction
/-- Subtracting two points in the subspace produces a vector in the direction. -/
theorem vsub_mem_direction {s : AffineSubspace k P} {p1 p2 : P} (hp1 : p1 ∈ s) (hp2 : p2 ∈ s) :
p1 -ᵥ p2 ∈ s.direction :=
vsub_mem_vectorSpan k hp1 hp2
#align affine_subspace.vsub_mem_direction AffineSubspace.vsub_mem_direction
/-- Adding a vector to a point in a subspace produces a point in the subspace if and only if the
vector is in the direction. -/
theorem vadd_mem_iff_mem_direction {s : AffineSubspace k P} (v : V) {p : P} (hp : p ∈ s) :
v +ᵥ p ∈ s ↔ v ∈ s.direction :=
⟨fun h => by simpa using vsub_mem_direction h hp, fun h => vadd_mem_of_mem_direction h hp⟩
#align affine_subspace.vadd_mem_iff_mem_direction AffineSubspace.vadd_mem_iff_mem_direction
/-- Adding a vector in the direction to a point produces a point in the subspace if and only if
the original point is in the subspace. -/
theorem vadd_mem_iff_mem_of_mem_direction {s : AffineSubspace k P} {v : V} (hv : v ∈ s.direction)
{p : P} : v +ᵥ p ∈ s ↔ p ∈ s := by
refine ⟨fun h => ?_, fun h => vadd_mem_of_mem_direction hv h⟩
convert vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) h
simp
#align affine_subspace.vadd_mem_iff_mem_of_mem_direction AffineSubspace.vadd_mem_iff_mem_of_mem_direction
/-- Given a point in an affine subspace, the set of vectors in its direction equals the set of
vectors subtracting that point on the right. -/
theorem coe_direction_eq_vsub_set_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) :
(s.direction : Set V) = (· -ᵥ p) '' s := by
rw [coe_direction_eq_vsub_set ⟨p, hp⟩]
refine le_antisymm ?_ ?_
· rintro v ⟨p1, hp1, p2, hp2, rfl⟩
exact ⟨p1 -ᵥ p2 +ᵥ p, vadd_mem_of_mem_direction (vsub_mem_direction hp1 hp2) hp, vadd_vsub _ _⟩
· rintro v ⟨p2, hp2, rfl⟩
exact ⟨p2, hp2, p, hp, rfl⟩
#align affine_subspace.coe_direction_eq_vsub_set_right AffineSubspace.coe_direction_eq_vsub_set_right
/-- Given a point in an affine subspace, the set of vectors in its direction equals the set of
vectors subtracting that point on the left. -/
theorem coe_direction_eq_vsub_set_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) :
(s.direction : Set V) = (p -ᵥ ·) '' s := by
ext v
rw [SetLike.mem_coe, ← Submodule.neg_mem_iff, ← SetLike.mem_coe,
coe_direction_eq_vsub_set_right hp, Set.mem_image, Set.mem_image]
conv_lhs =>
congr
ext
rw [← neg_vsub_eq_vsub_rev, neg_inj]
#align affine_subspace.coe_direction_eq_vsub_set_left AffineSubspace.coe_direction_eq_vsub_set_left
/-- Given a point in an affine subspace, a vector is in its direction if and only if it results from
subtracting that point on the right. -/
theorem mem_direction_iff_eq_vsub_right {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) :
v ∈ s.direction ↔ ∃ p2 ∈ s, v = p2 -ᵥ p := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_right hp]
exact ⟨fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩, fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩⟩
#align affine_subspace.mem_direction_iff_eq_vsub_right AffineSubspace.mem_direction_iff_eq_vsub_right
/-- Given a point in an affine subspace, a vector is in its direction if and only if it results from
subtracting that point on the left. -/
theorem mem_direction_iff_eq_vsub_left {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (v : V) :
v ∈ s.direction ↔ ∃ p2 ∈ s, v = p -ᵥ p2 := by
rw [← SetLike.mem_coe, coe_direction_eq_vsub_set_left hp]
exact ⟨fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩, fun ⟨p2, hp2, hv⟩ => ⟨p2, hp2, hv.symm⟩⟩
#align affine_subspace.mem_direction_iff_eq_vsub_left AffineSubspace.mem_direction_iff_eq_vsub_left
/-- Given a point in an affine subspace, a result of subtracting that point on the right is in the
direction if and only if the other point is in the subspace. -/
theorem vsub_right_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p2 : P) :
p2 -ᵥ p ∈ s.direction ↔ p2 ∈ s := by
rw [mem_direction_iff_eq_vsub_right hp]
simp
#align affine_subspace.vsub_right_mem_direction_iff_mem AffineSubspace.vsub_right_mem_direction_iff_mem
/-- Given a point in an affine subspace, a result of subtracting that point on the left is in the
direction if and only if the other point is in the subspace. -/
theorem vsub_left_mem_direction_iff_mem {s : AffineSubspace k P} {p : P} (hp : p ∈ s) (p2 : P) :
p -ᵥ p2 ∈ s.direction ↔ p2 ∈ s := by
rw [mem_direction_iff_eq_vsub_left hp]
simp
#align affine_subspace.vsub_left_mem_direction_iff_mem AffineSubspace.vsub_left_mem_direction_iff_mem
/-- Two affine subspaces are equal if they have the same points. -/
theorem coe_injective : Function.Injective ((↑) : AffineSubspace k P → Set P) :=
SetLike.coe_injective
#align affine_subspace.coe_injective AffineSubspace.coe_injective
@[ext]
theorem ext {p q : AffineSubspace k P} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q :=
SetLike.ext h
#align affine_subspace.ext AffineSubspace.ext
-- Porting note: removed `simp`, proof is `simp only [SetLike.ext'_iff]`
theorem ext_iff (s₁ s₂ : AffineSubspace k P) : (s₁ : Set P) = s₂ ↔ s₁ = s₂ :=
SetLike.ext'_iff.symm
#align affine_subspace.ext_iff AffineSubspace.ext_iff
/-- Two affine subspaces with the same direction and nonempty intersection are equal. -/
theorem ext_of_direction_eq {s1 s2 : AffineSubspace k P} (hd : s1.direction = s2.direction)
(hn : ((s1 : Set P) ∩ s2).Nonempty) : s1 = s2 := by
ext p
have hq1 := Set.mem_of_mem_inter_left hn.some_mem
have hq2 := Set.mem_of_mem_inter_right hn.some_mem
constructor
· intro hp
rw [← vsub_vadd p hn.some]
refine vadd_mem_of_mem_direction ?_ hq2
rw [← hd]
exact vsub_mem_direction hp hq1
· intro hp
rw [← vsub_vadd p hn.some]
refine vadd_mem_of_mem_direction ?_ hq1
rw [hd]
exact vsub_mem_direction hp hq2
#align affine_subspace.ext_of_direction_eq AffineSubspace.ext_of_direction_eq
-- See note [reducible non instances]
/-- This is not an instance because it loops with `AddTorsor.nonempty`. -/
abbrev toAddTorsor (s : AffineSubspace k P) [Nonempty s] : AddTorsor s.direction s where
vadd a b := ⟨(a : V) +ᵥ (b : P), vadd_mem_of_mem_direction a.2 b.2⟩
zero_vadd := fun a => by
ext
exact zero_vadd _ _
add_vadd a b c := by
ext
apply add_vadd
vsub a b := ⟨(a : P) -ᵥ (b : P), (vsub_left_mem_direction_iff_mem a.2 _).mpr b.2⟩
vsub_vadd' a b := by
ext
apply AddTorsor.vsub_vadd'
vadd_vsub' a b := by
ext
apply AddTorsor.vadd_vsub'
#align affine_subspace.to_add_torsor AffineSubspace.toAddTorsor
attribute [local instance] toAddTorsor
@[simp, norm_cast]
theorem coe_vsub (s : AffineSubspace k P) [Nonempty s] (a b : s) : ↑(a -ᵥ b) = (a : P) -ᵥ (b : P) :=
rfl
#align affine_subspace.coe_vsub AffineSubspace.coe_vsub
@[simp, norm_cast]
theorem coe_vadd (s : AffineSubspace k P) [Nonempty s] (a : s.direction) (b : s) :
↑(a +ᵥ b) = (a : V) +ᵥ (b : P) :=
rfl
#align affine_subspace.coe_vadd AffineSubspace.coe_vadd
/-- Embedding of an affine subspace to the ambient space, as an affine map. -/
protected def subtype (s : AffineSubspace k P) [Nonempty s] : s →ᵃ[k] P where
toFun := (↑)
linear := s.direction.subtype
map_vadd' _ _ := rfl
#align affine_subspace.subtype AffineSubspace.subtype
@[simp]
theorem subtype_linear (s : AffineSubspace k P) [Nonempty s] :
s.subtype.linear = s.direction.subtype := rfl
#align affine_subspace.subtype_linear AffineSubspace.subtype_linear
theorem subtype_apply (s : AffineSubspace k P) [Nonempty s] (p : s) : s.subtype p = p :=
rfl
#align affine_subspace.subtype_apply AffineSubspace.subtype_apply
@[simp]
theorem coeSubtype (s : AffineSubspace k P) [Nonempty s] : (s.subtype : s → P) = ((↑) : s → P) :=
rfl
#align affine_subspace.coe_subtype AffineSubspace.coeSubtype
theorem injective_subtype (s : AffineSubspace k P) [Nonempty s] : Function.Injective s.subtype :=
Subtype.coe_injective
#align affine_subspace.injective_subtype AffineSubspace.injective_subtype
/-- Two affine subspaces with nonempty intersection are equal if and only if their directions are
equal. -/
theorem eq_iff_direction_eq_of_mem {s₁ s₂ : AffineSubspace k P} {p : P} (h₁ : p ∈ s₁)
(h₂ : p ∈ s₂) : s₁ = s₂ ↔ s₁.direction = s₂.direction :=
⟨fun h => h ▸ rfl, fun h => ext_of_direction_eq h ⟨p, h₁, h₂⟩⟩
#align affine_subspace.eq_iff_direction_eq_of_mem AffineSubspace.eq_iff_direction_eq_of_mem
/-- Construct an affine subspace from a point and a direction. -/
def mk' (p : P) (direction : Submodule k V) : AffineSubspace k P where
carrier := { q | ∃ v ∈ direction, q = v +ᵥ p }
smul_vsub_vadd_mem c p1 p2 p3 hp1 hp2 hp3 := by
rcases hp1 with ⟨v1, hv1, hp1⟩
rcases hp2 with ⟨v2, hv2, hp2⟩
rcases hp3 with ⟨v3, hv3, hp3⟩
use c • (v1 - v2) + v3, direction.add_mem (direction.smul_mem c (direction.sub_mem hv1 hv2)) hv3
simp [hp1, hp2, hp3, vadd_vadd]
#align affine_subspace.mk' AffineSubspace.mk'
/-- An affine subspace constructed from a point and a direction contains that point. -/
theorem self_mem_mk' (p : P) (direction : Submodule k V) : p ∈ mk' p direction :=
⟨0, ⟨direction.zero_mem, (zero_vadd _ _).symm⟩⟩
#align affine_subspace.self_mem_mk' AffineSubspace.self_mem_mk'
/-- An affine subspace constructed from a point and a direction contains the result of adding a
vector in that direction to that point. -/
theorem vadd_mem_mk' {v : V} (p : P) {direction : Submodule k V} (hv : v ∈ direction) :
v +ᵥ p ∈ mk' p direction :=
⟨v, hv, rfl⟩
#align affine_subspace.vadd_mem_mk' AffineSubspace.vadd_mem_mk'
/-- An affine subspace constructed from a point and a direction is nonempty. -/
theorem mk'_nonempty (p : P) (direction : Submodule k V) : (mk' p direction : Set P).Nonempty :=
⟨p, self_mem_mk' p direction⟩
#align affine_subspace.mk'_nonempty AffineSubspace.mk'_nonempty
/-- The direction of an affine subspace constructed from a point and a direction. -/
@[simp]
theorem direction_mk' (p : P) (direction : Submodule k V) :
(mk' p direction).direction = direction := by
ext v
rw [mem_direction_iff_eq_vsub (mk'_nonempty _ _)]
constructor
· rintro ⟨p1, ⟨v1, hv1, hp1⟩, p2, ⟨v2, hv2, hp2⟩, hv⟩
rw [hv, hp1, hp2, vadd_vsub_vadd_cancel_right]
exact direction.sub_mem hv1 hv2
· exact fun hv => ⟨v +ᵥ p, vadd_mem_mk' _ hv, p, self_mem_mk' _ _, (vadd_vsub _ _).symm⟩
#align affine_subspace.direction_mk' AffineSubspace.direction_mk'
/-- A point lies in an affine subspace constructed from another point and a direction if and only
if their difference is in that direction. -/
theorem mem_mk'_iff_vsub_mem {p₁ p₂ : P} {direction : Submodule k V} :
p₂ ∈ mk' p₁ direction ↔ p₂ -ᵥ p₁ ∈ direction := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [← direction_mk' p₁ direction]
exact vsub_mem_direction h (self_mem_mk' _ _)
· rw [← vsub_vadd p₂ p₁]
exact vadd_mem_mk' p₁ h
#align affine_subspace.mem_mk'_iff_vsub_mem AffineSubspace.mem_mk'_iff_vsub_mem
/-- Constructing an affine subspace from a point in a subspace and that subspace's direction
yields the original subspace. -/
@[simp]
theorem mk'_eq {s : AffineSubspace k P} {p : P} (hp : p ∈ s) : mk' p s.direction = s :=
ext_of_direction_eq (direction_mk' p s.direction) ⟨p, Set.mem_inter (self_mem_mk' _ _) hp⟩
#align affine_subspace.mk'_eq AffineSubspace.mk'_eq
/-- If an affine subspace contains a set of points, it contains the `spanPoints` of that set. -/
theorem spanPoints_subset_coe_of_subset_coe {s : Set P} {s1 : AffineSubspace k P} (h : s ⊆ s1) :
spanPoints k s ⊆ s1 := by
rintro p ⟨p1, hp1, v, hv, hp⟩
rw [hp]
have hp1s1 : p1 ∈ (s1 : Set P) := Set.mem_of_mem_of_subset hp1 h
refine vadd_mem_of_mem_direction ?_ hp1s1
have hs : vectorSpan k s ≤ s1.direction := vectorSpan_mono k h
rw [SetLike.le_def] at hs
rw [← SetLike.mem_coe]
exact Set.mem_of_mem_of_subset hv hs
#align affine_subspace.span_points_subset_coe_of_subset_coe AffineSubspace.spanPoints_subset_coe_of_subset_coe
end AffineSubspace
namespace Submodule
variable {k V : Type*} [Ring k] [AddCommGroup V] [Module k V]
@[simp]
theorem mem_toAffineSubspace {p : Submodule k V} {x : V} :
x ∈ p.toAffineSubspace ↔ x ∈ p :=
Iff.rfl
@[simp]
theorem toAffineSubspace_direction (s : Submodule k V) : s.toAffineSubspace.direction = s := by
ext x; simp [← s.toAffineSubspace.vadd_mem_iff_mem_direction _ s.zero_mem]
end Submodule
theorem AffineMap.lineMap_mem {k V P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AddTorsor V P] {Q : AffineSubspace k P} {p₀ p₁ : P} (c : k) (h₀ : p₀ ∈ Q) (h₁ : p₁ ∈ Q) :
AffineMap.lineMap p₀ p₁ c ∈ Q := by
rw [AffineMap.lineMap_apply]
exact Q.smul_vsub_vadd_mem c h₁ h₀ h₀
#align affine_map.line_map_mem AffineMap.lineMap_mem
section affineSpan
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
/-- The affine span of a set of points is the smallest affine subspace containing those points.
(Actually defined here in terms of spans in modules.) -/
def affineSpan (s : Set P) : AffineSubspace k P where
carrier := spanPoints k s
smul_vsub_vadd_mem c _ _ _ hp1 hp2 hp3 :=
vadd_mem_spanPoints_of_mem_spanPoints_of_mem_vectorSpan k hp3
((vectorSpan k s).smul_mem c
(vsub_mem_vectorSpan_of_mem_spanPoints_of_mem_spanPoints k hp1 hp2))
#align affine_span affineSpan
/-- The affine span, converted to a set, is `spanPoints`. -/
@[simp]
theorem coe_affineSpan (s : Set P) : (affineSpan k s : Set P) = spanPoints k s :=
rfl
#align coe_affine_span coe_affineSpan
/-- A set is contained in its affine span. -/
theorem subset_affineSpan (s : Set P) : s ⊆ affineSpan k s :=
subset_spanPoints k s
#align subset_affine_span subset_affineSpan
/-- The direction of the affine span is the `vectorSpan`. -/
theorem direction_affineSpan (s : Set P) : (affineSpan k s).direction = vectorSpan k s := by
apply le_antisymm
· refine Submodule.span_le.2 ?_
rintro v ⟨p1, ⟨p2, hp2, v1, hv1, hp1⟩, p3, ⟨p4, hp4, v2, hv2, hp3⟩, rfl⟩
simp only [SetLike.mem_coe]
rw [hp1, hp3, vsub_vadd_eq_vsub_sub, vadd_vsub_assoc]
exact
(vectorSpan k s).sub_mem ((vectorSpan k s).add_mem hv1 (vsub_mem_vectorSpan k hp2 hp4)) hv2
· exact vectorSpan_mono k (subset_spanPoints k s)
#align direction_affine_span direction_affineSpan
/-- A point in a set is in its affine span. -/
theorem mem_affineSpan {p : P} {s : Set P} (hp : p ∈ s) : p ∈ affineSpan k s :=
mem_spanPoints k p s hp
#align mem_affine_span mem_affineSpan
end affineSpan
namespace AffineSubspace
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[S : AffineSpace V P]
instance : CompleteLattice (AffineSubspace k P) :=
{
PartialOrder.lift ((↑) : AffineSubspace k P → Set P)
coe_injective with
sup := fun s1 s2 => affineSpan k (s1 ∪ s2)
le_sup_left := fun s1 s2 =>
Set.Subset.trans Set.subset_union_left (subset_spanPoints k _)
le_sup_right := fun s1 s2 =>
Set.Subset.trans Set.subset_union_right (subset_spanPoints k _)
sup_le := fun s1 s2 s3 hs1 hs2 => spanPoints_subset_coe_of_subset_coe (Set.union_subset hs1 hs2)
inf := fun s1 s2 =>
mk (s1 ∩ s2) fun c p1 p2 p3 hp1 hp2 hp3 =>
⟨s1.smul_vsub_vadd_mem c hp1.1 hp2.1 hp3.1, s2.smul_vsub_vadd_mem c hp1.2 hp2.2 hp3.2⟩
inf_le_left := fun _ _ => Set.inter_subset_left
inf_le_right := fun _ _ => Set.inter_subset_right
le_sInf := fun S s1 hs1 => by
-- Porting note: surely there is an easier way?
refine Set.subset_sInter (t := (s1 : Set P)) ?_
rintro t ⟨s, _hs, rfl⟩
exact Set.subset_iInter (hs1 s)
top :=
{ carrier := Set.univ
smul_vsub_vadd_mem := fun _ _ _ _ _ _ _ => Set.mem_univ _ }
le_top := fun _ _ _ => Set.mem_univ _
bot :=
{ carrier := ∅
smul_vsub_vadd_mem := fun _ _ _ _ => False.elim }
bot_le := fun _ _ => False.elim
sSup := fun s => affineSpan k (⋃ s' ∈ s, (s' : Set P))
sInf := fun s =>
mk (⋂ s' ∈ s, (s' : Set P)) fun c p1 p2 p3 hp1 hp2 hp3 =>
Set.mem_iInter₂.2 fun s2 hs2 => by
rw [Set.mem_iInter₂] at *
exact s2.smul_vsub_vadd_mem c (hp1 s2 hs2) (hp2 s2 hs2) (hp3 s2 hs2)
le_sSup := fun _ _ h => Set.Subset.trans (Set.subset_biUnion_of_mem h) (subset_spanPoints k _)
sSup_le := fun _ _ h => spanPoints_subset_coe_of_subset_coe (Set.iUnion₂_subset h)
sInf_le := fun _ _ => Set.biInter_subset_of_mem
le_inf := fun _ _ _ => Set.subset_inter }
instance : Inhabited (AffineSubspace k P) :=
⟨⊤⟩
/-- The `≤` order on subspaces is the same as that on the corresponding sets. -/
theorem le_def (s1 s2 : AffineSubspace k P) : s1 ≤ s2 ↔ (s1 : Set P) ⊆ s2 :=
Iff.rfl
#align affine_subspace.le_def AffineSubspace.le_def
/-- One subspace is less than or equal to another if and only if all its points are in the second
subspace. -/
theorem le_def' (s1 s2 : AffineSubspace k P) : s1 ≤ s2 ↔ ∀ p ∈ s1, p ∈ s2 :=
Iff.rfl
#align affine_subspace.le_def' AffineSubspace.le_def'
/-- The `<` order on subspaces is the same as that on the corresponding sets. -/
theorem lt_def (s1 s2 : AffineSubspace k P) : s1 < s2 ↔ (s1 : Set P) ⊂ s2 :=
Iff.rfl
#align affine_subspace.lt_def AffineSubspace.lt_def
/-- One subspace is not less than or equal to another if and only if it has a point not in the
second subspace. -/
theorem not_le_iff_exists (s1 s2 : AffineSubspace k P) : ¬s1 ≤ s2 ↔ ∃ p ∈ s1, p ∉ s2 :=
Set.not_subset
#align affine_subspace.not_le_iff_exists AffineSubspace.not_le_iff_exists
/-- If a subspace is less than another, there is a point only in the second. -/
theorem exists_of_lt {s1 s2 : AffineSubspace k P} (h : s1 < s2) : ∃ p ∈ s2, p ∉ s1 :=
Set.exists_of_ssubset h
#align affine_subspace.exists_of_lt AffineSubspace.exists_of_lt
/-- A subspace is less than another if and only if it is less than or equal to the second subspace
and there is a point only in the second. -/
theorem lt_iff_le_and_exists (s1 s2 : AffineSubspace k P) :
s1 < s2 ↔ s1 ≤ s2 ∧ ∃ p ∈ s2, p ∉ s1 := by
rw [lt_iff_le_not_le, not_le_iff_exists]
#align affine_subspace.lt_iff_le_and_exists AffineSubspace.lt_iff_le_and_exists
/-- If an affine subspace is nonempty and contained in another with the same direction, they are
equal. -/
theorem eq_of_direction_eq_of_nonempty_of_le {s₁ s₂ : AffineSubspace k P}
(hd : s₁.direction = s₂.direction) (hn : (s₁ : Set P).Nonempty) (hle : s₁ ≤ s₂) : s₁ = s₂ :=
let ⟨p, hp⟩ := hn
ext_of_direction_eq hd ⟨p, hp, hle hp⟩
#align affine_subspace.eq_of_direction_eq_of_nonempty_of_le AffineSubspace.eq_of_direction_eq_of_nonempty_of_le
variable (k V)
/-- The affine span is the `sInf` of subspaces containing the given points. -/
theorem affineSpan_eq_sInf (s : Set P) :
affineSpan k s = sInf { s' : AffineSubspace k P | s ⊆ s' } :=
le_antisymm (spanPoints_subset_coe_of_subset_coe <| Set.subset_iInter₂ fun _ => id)
(sInf_le (subset_spanPoints k _))
#align affine_subspace.affine_span_eq_Inf AffineSubspace.affineSpan_eq_sInf
variable (P)
/-- The Galois insertion formed by `affineSpan` and coercion back to a set. -/
protected def gi : GaloisInsertion (affineSpan k) ((↑) : AffineSubspace k P → Set P) where
choice s _ := affineSpan k s
gc s1 _s2 :=
⟨fun h => Set.Subset.trans (subset_spanPoints k s1) h, spanPoints_subset_coe_of_subset_coe⟩
le_l_u _ := subset_spanPoints k _
choice_eq _ _ := rfl
#align affine_subspace.gi AffineSubspace.gi
/-- The span of the empty set is `⊥`. -/
@[simp]
theorem span_empty : affineSpan k (∅ : Set P) = ⊥ :=
(AffineSubspace.gi k V P).gc.l_bot
#align affine_subspace.span_empty AffineSubspace.span_empty
/-- The span of `univ` is `⊤`. -/
@[simp]
theorem span_univ : affineSpan k (Set.univ : Set P) = ⊤ :=
eq_top_iff.2 <| subset_spanPoints k _
#align affine_subspace.span_univ AffineSubspace.span_univ
variable {k V P}
theorem _root_.affineSpan_le {s : Set P} {Q : AffineSubspace k P} :
affineSpan k s ≤ Q ↔ s ⊆ (Q : Set P) :=
(AffineSubspace.gi k V P).gc _ _
#align affine_span_le affineSpan_le
variable (k V) {p₁ p₂ : P}
/-- The affine span of a single point, coerced to a set, contains just that point. -/
@[simp 1001] -- Porting note: this needs to take priority over `coe_affineSpan`
theorem coe_affineSpan_singleton (p : P) : (affineSpan k ({p} : Set P) : Set P) = {p} := by
ext x
rw [mem_coe, ← vsub_right_mem_direction_iff_mem (mem_affineSpan k (Set.mem_singleton p)) _,
direction_affineSpan]
simp
#align affine_subspace.coe_affine_span_singleton AffineSubspace.coe_affineSpan_singleton
/-- A point is in the affine span of a single point if and only if they are equal. -/
@[simp]
theorem mem_affineSpan_singleton : p₁ ∈ affineSpan k ({p₂} : Set P) ↔ p₁ = p₂ := by
simp [← mem_coe]
#align affine_subspace.mem_affine_span_singleton AffineSubspace.mem_affineSpan_singleton
@[simp]
theorem preimage_coe_affineSpan_singleton (x : P) :
((↑) : affineSpan k ({x} : Set P) → P) ⁻¹' {x} = univ :=
eq_univ_of_forall fun y => (AffineSubspace.mem_affineSpan_singleton _ _).1 y.2
#align affine_subspace.preimage_coe_affine_span_singleton AffineSubspace.preimage_coe_affineSpan_singleton
/-- The span of a union of sets is the sup of their spans. -/
theorem span_union (s t : Set P) : affineSpan k (s ∪ t) = affineSpan k s ⊔ affineSpan k t :=
(AffineSubspace.gi k V P).gc.l_sup
#align affine_subspace.span_union AffineSubspace.span_union
/-- The span of a union of an indexed family of sets is the sup of their spans. -/
theorem span_iUnion {ι : Type*} (s : ι → Set P) :
affineSpan k (⋃ i, s i) = ⨆ i, affineSpan k (s i) :=
(AffineSubspace.gi k V P).gc.l_iSup
#align affine_subspace.span_Union AffineSubspace.span_iUnion
variable (P)
/-- `⊤`, coerced to a set, is the whole set of points. -/
@[simp]
theorem top_coe : ((⊤ : AffineSubspace k P) : Set P) = Set.univ :=
rfl
#align affine_subspace.top_coe AffineSubspace.top_coe
variable {P}
/-- All points are in `⊤`. -/
@[simp]
theorem mem_top (p : P) : p ∈ (⊤ : AffineSubspace k P) :=
Set.mem_univ p
#align affine_subspace.mem_top AffineSubspace.mem_top
variable (P)
/-- The direction of `⊤` is the whole module as a submodule. -/
@[simp]
theorem direction_top : (⊤ : AffineSubspace k P).direction = ⊤ := by
cases' S.nonempty with p
ext v
refine ⟨imp_intro Submodule.mem_top, fun _hv => ?_⟩
have hpv : (v +ᵥ p -ᵥ p : V) ∈ (⊤ : AffineSubspace k P).direction :=
vsub_mem_direction (mem_top k V _) (mem_top k V _)
rwa [vadd_vsub] at hpv
#align affine_subspace.direction_top AffineSubspace.direction_top
/-- `⊥`, coerced to a set, is the empty set. -/
@[simp]
theorem bot_coe : ((⊥ : AffineSubspace k P) : Set P) = ∅ :=
rfl
#align affine_subspace.bot_coe AffineSubspace.bot_coe
theorem bot_ne_top : (⊥ : AffineSubspace k P) ≠ ⊤ := by
intro contra
rw [← ext_iff, bot_coe, top_coe] at contra
exact Set.empty_ne_univ contra
#align affine_subspace.bot_ne_top AffineSubspace.bot_ne_top
instance : Nontrivial (AffineSubspace k P) :=
⟨⟨⊥, ⊤, bot_ne_top k V P⟩⟩
theorem nonempty_of_affineSpan_eq_top {s : Set P} (h : affineSpan k s = ⊤) : s.Nonempty := by
rw [Set.nonempty_iff_ne_empty]
rintro rfl
rw [AffineSubspace.span_empty] at h
exact bot_ne_top k V P h
#align affine_subspace.nonempty_of_affine_span_eq_top AffineSubspace.nonempty_of_affineSpan_eq_top
/-- If the affine span of a set is `⊤`, then the vector span of the same set is the `⊤`. -/
theorem vectorSpan_eq_top_of_affineSpan_eq_top {s : Set P} (h : affineSpan k s = ⊤) :
vectorSpan k s = ⊤ := by rw [← direction_affineSpan, h, direction_top]
#align affine_subspace.vector_span_eq_top_of_affine_span_eq_top AffineSubspace.vectorSpan_eq_top_of_affineSpan_eq_top
/-- For a nonempty set, the affine span is `⊤` iff its vector span is `⊤`. -/
theorem affineSpan_eq_top_iff_vectorSpan_eq_top_of_nonempty {s : Set P} (hs : s.Nonempty) :
affineSpan k s = ⊤ ↔ vectorSpan k s = ⊤ := by
refine ⟨vectorSpan_eq_top_of_affineSpan_eq_top k V P, ?_⟩
intro h
suffices Nonempty (affineSpan k s) by
obtain ⟨p, hp : p ∈ affineSpan k s⟩ := this
rw [eq_iff_direction_eq_of_mem hp (mem_top k V p), direction_affineSpan, h, direction_top]
obtain ⟨x, hx⟩ := hs
exact ⟨⟨x, mem_affineSpan k hx⟩⟩
#align affine_subspace.affine_span_eq_top_iff_vector_span_eq_top_of_nonempty AffineSubspace.affineSpan_eq_top_iff_vectorSpan_eq_top_of_nonempty
/-- For a non-trivial space, the affine span of a set is `⊤` iff its vector span is `⊤`. -/
theorem affineSpan_eq_top_iff_vectorSpan_eq_top_of_nontrivial {s : Set P} [Nontrivial P] :
affineSpan k s = ⊤ ↔ vectorSpan k s = ⊤ := by
rcases s.eq_empty_or_nonempty with hs | hs
· simp [hs, subsingleton_iff_bot_eq_top, AddTorsor.subsingleton_iff V P, not_subsingleton]
· rw [affineSpan_eq_top_iff_vectorSpan_eq_top_of_nonempty k V P hs]
#align affine_subspace.affine_span_eq_top_iff_vector_span_eq_top_of_nontrivial AffineSubspace.affineSpan_eq_top_iff_vectorSpan_eq_top_of_nontrivial
theorem card_pos_of_affineSpan_eq_top {ι : Type*} [Fintype ι] {p : ι → P}
(h : affineSpan k (range p) = ⊤) : 0 < Fintype.card ι := by
obtain ⟨-, ⟨i, -⟩⟩ := nonempty_of_affineSpan_eq_top k V P h
exact Fintype.card_pos_iff.mpr ⟨i⟩
#align affine_subspace.card_pos_of_affine_span_eq_top AffineSubspace.card_pos_of_affineSpan_eq_top
attribute [local instance] toAddTorsor
/-- The top affine subspace is linearly equivalent to the affine space.
This is the affine version of `Submodule.topEquiv`. -/
@[simps! linear apply symm_apply_coe]
def topEquiv : (⊤ : AffineSubspace k P) ≃ᵃ[k] P where
toEquiv := Equiv.Set.univ P
linear := .ofEq _ _ (direction_top _ _ _) ≪≫ₗ Submodule.topEquiv
map_vadd' _p _v := rfl
variable {P}
/-- No points are in `⊥`. -/
theorem not_mem_bot (p : P) : p ∉ (⊥ : AffineSubspace k P) :=
Set.not_mem_empty p
#align affine_subspace.not_mem_bot AffineSubspace.not_mem_bot
variable (P)
/-- The direction of `⊥` is the submodule `⊥`. -/
@[simp]
theorem direction_bot : (⊥ : AffineSubspace k P).direction = ⊥ := by
rw [direction_eq_vectorSpan, bot_coe, vectorSpan_def, vsub_empty, Submodule.span_empty]
#align affine_subspace.direction_bot AffineSubspace.direction_bot
variable {k V P}
@[simp]
theorem coe_eq_bot_iff (Q : AffineSubspace k P) : (Q : Set P) = ∅ ↔ Q = ⊥ :=
coe_injective.eq_iff' (bot_coe _ _ _)
#align affine_subspace.coe_eq_bot_iff AffineSubspace.coe_eq_bot_iff
@[simp]
theorem coe_eq_univ_iff (Q : AffineSubspace k P) : (Q : Set P) = univ ↔ Q = ⊤ :=
coe_injective.eq_iff' (top_coe _ _ _)
#align affine_subspace.coe_eq_univ_iff AffineSubspace.coe_eq_univ_iff
theorem nonempty_iff_ne_bot (Q : AffineSubspace k P) : (Q : Set P).Nonempty ↔ Q ≠ ⊥ := by
rw [nonempty_iff_ne_empty]
exact not_congr Q.coe_eq_bot_iff
#align affine_subspace.nonempty_iff_ne_bot AffineSubspace.nonempty_iff_ne_bot
theorem eq_bot_or_nonempty (Q : AffineSubspace k P) : Q = ⊥ ∨ (Q : Set P).Nonempty := by
rw [nonempty_iff_ne_bot]
apply eq_or_ne
#align affine_subspace.eq_bot_or_nonempty AffineSubspace.eq_bot_or_nonempty
theorem subsingleton_of_subsingleton_span_eq_top {s : Set P} (h₁ : s.Subsingleton)
(h₂ : affineSpan k s = ⊤) : Subsingleton P := by
obtain ⟨p, hp⟩ := AffineSubspace.nonempty_of_affineSpan_eq_top k V P h₂
have : s = {p} := Subset.antisymm (fun q hq => h₁ hq hp) (by simp [hp])
rw [this, ← AffineSubspace.ext_iff, AffineSubspace.coe_affineSpan_singleton,
AffineSubspace.top_coe, eq_comm, ← subsingleton_iff_singleton (mem_univ _)] at h₂
exact subsingleton_of_univ_subsingleton h₂
#align affine_subspace.subsingleton_of_subsingleton_span_eq_top AffineSubspace.subsingleton_of_subsingleton_span_eq_top
theorem eq_univ_of_subsingleton_span_eq_top {s : Set P} (h₁ : s.Subsingleton)
(h₂ : affineSpan k s = ⊤) : s = (univ : Set P) := by
obtain ⟨p, hp⟩ := AffineSubspace.nonempty_of_affineSpan_eq_top k V P h₂
have : s = {p} := Subset.antisymm (fun q hq => h₁ hq hp) (by simp [hp])
rw [this, eq_comm, ← subsingleton_iff_singleton (mem_univ p), subsingleton_univ_iff]
exact subsingleton_of_subsingleton_span_eq_top h₁ h₂
#align affine_subspace.eq_univ_of_subsingleton_span_eq_top AffineSubspace.eq_univ_of_subsingleton_span_eq_top
/-- A nonempty affine subspace is `⊤` if and only if its direction is `⊤`. -/
@[simp]
theorem direction_eq_top_iff_of_nonempty {s : AffineSubspace k P} (h : (s : Set P).Nonempty) :
s.direction = ⊤ ↔ s = ⊤ := by
constructor
· intro hd
rw [← direction_top k V P] at hd
refine ext_of_direction_eq hd ?_
simp [h]
· rintro rfl
simp
#align affine_subspace.direction_eq_top_iff_of_nonempty AffineSubspace.direction_eq_top_iff_of_nonempty
/-- The inf of two affine subspaces, coerced to a set, is the intersection of the two sets of
points. -/
@[simp]
theorem inf_coe (s1 s2 : AffineSubspace k P) : (s1 ⊓ s2 : Set P) = (s1 : Set P) ∩ s2 :=
rfl
#align affine_subspace.inf_coe AffineSubspace.inf_coe
/-- A point is in the inf of two affine subspaces if and only if it is in both of them. -/
theorem mem_inf_iff (p : P) (s1 s2 : AffineSubspace k P) : p ∈ s1 ⊓ s2 ↔ p ∈ s1 ∧ p ∈ s2 :=
Iff.rfl
#align affine_subspace.mem_inf_iff AffineSubspace.mem_inf_iff
/-- The direction of the inf of two affine subspaces is less than or equal to the inf of their
directions. -/
theorem direction_inf (s1 s2 : AffineSubspace k P) :
(s1 ⊓ s2).direction ≤ s1.direction ⊓ s2.direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact
le_inf (sInf_le_sInf fun p hp => trans (vsub_self_mono inter_subset_left) hp)
(sInf_le_sInf fun p hp => trans (vsub_self_mono inter_subset_right) hp)
#align affine_subspace.direction_inf AffineSubspace.direction_inf
/-- If two affine subspaces have a point in common, the direction of their inf equals the inf of
their directions. -/
theorem direction_inf_of_mem {s₁ s₂ : AffineSubspace k P} {p : P} (h₁ : p ∈ s₁) (h₂ : p ∈ s₂) :
(s₁ ⊓ s₂).direction = s₁.direction ⊓ s₂.direction := by
ext v
rw [Submodule.mem_inf, ← vadd_mem_iff_mem_direction v h₁, ← vadd_mem_iff_mem_direction v h₂, ←
vadd_mem_iff_mem_direction v ((mem_inf_iff p s₁ s₂).2 ⟨h₁, h₂⟩), mem_inf_iff]
#align affine_subspace.direction_inf_of_mem AffineSubspace.direction_inf_of_mem
/-- If two affine subspaces have a point in their inf, the direction of their inf equals the inf of
their directions. -/
theorem direction_inf_of_mem_inf {s₁ s₂ : AffineSubspace k P} {p : P} (h : p ∈ s₁ ⊓ s₂) :
(s₁ ⊓ s₂).direction = s₁.direction ⊓ s₂.direction :=
direction_inf_of_mem ((mem_inf_iff p s₁ s₂).1 h).1 ((mem_inf_iff p s₁ s₂).1 h).2
#align affine_subspace.direction_inf_of_mem_inf AffineSubspace.direction_inf_of_mem_inf
/-- If one affine subspace is less than or equal to another, the same applies to their
directions. -/
theorem direction_le {s1 s2 : AffineSubspace k P} (h : s1 ≤ s2) : s1.direction ≤ s2.direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact vectorSpan_mono k h
#align affine_subspace.direction_le AffineSubspace.direction_le
/-- If one nonempty affine subspace is less than another, the same applies to their directions -/
theorem direction_lt_of_nonempty {s1 s2 : AffineSubspace k P} (h : s1 < s2)
(hn : (s1 : Set P).Nonempty) : s1.direction < s2.direction := by
cases' hn with p hp
rw [lt_iff_le_and_exists] at h
rcases h with ⟨hle, p2, hp2, hp2s1⟩
rw [SetLike.lt_iff_le_and_exists]
use direction_le hle, p2 -ᵥ p, vsub_mem_direction hp2 (hle hp)
intro hm
rw [vsub_right_mem_direction_iff_mem hp p2] at hm
exact hp2s1 hm
#align affine_subspace.direction_lt_of_nonempty AffineSubspace.direction_lt_of_nonempty
/-- The sup of the directions of two affine subspaces is less than or equal to the direction of
their sup. -/
theorem sup_direction_le (s1 s2 : AffineSubspace k P) :
s1.direction ⊔ s2.direction ≤ (s1 ⊔ s2).direction := by
simp only [direction_eq_vectorSpan, vectorSpan_def]
exact
sup_le
(sInf_le_sInf fun p hp => Set.Subset.trans (vsub_self_mono (le_sup_left : s1 ≤ s1 ⊔ s2)) hp)
(sInf_le_sInf fun p hp => Set.Subset.trans (vsub_self_mono (le_sup_right : s2 ≤ s1 ⊔ s2)) hp)
#align affine_subspace.sup_direction_le AffineSubspace.sup_direction_le
/-- The sup of the directions of two nonempty affine subspaces with empty intersection is less than
the direction of their sup. -/
theorem sup_direction_lt_of_nonempty_of_inter_empty {s1 s2 : AffineSubspace k P}
(h1 : (s1 : Set P).Nonempty) (h2 : (s2 : Set P).Nonempty) (he : (s1 ∩ s2 : Set P) = ∅) :
s1.direction ⊔ s2.direction < (s1 ⊔ s2).direction := by
cases' h1 with p1 hp1
cases' h2 with p2 hp2
rw [SetLike.lt_iff_le_and_exists]
use sup_direction_le s1 s2, p2 -ᵥ p1,
vsub_mem_direction ((le_sup_right : s2 ≤ s1 ⊔ s2) hp2) ((le_sup_left : s1 ≤ s1 ⊔ s2) hp1)
intro h
rw [Submodule.mem_sup] at h
rcases h with ⟨v1, hv1, v2, hv2, hv1v2⟩
rw [← sub_eq_zero, sub_eq_add_neg, neg_vsub_eq_vsub_rev, add_comm v1, add_assoc, ←
vadd_vsub_assoc, ← neg_neg v2, add_comm, ← sub_eq_add_neg, ← vsub_vadd_eq_vsub_sub,
vsub_eq_zero_iff_eq] at hv1v2
refine Set.Nonempty.ne_empty ?_ he
use v1 +ᵥ p1, vadd_mem_of_mem_direction hv1 hp1
rw [hv1v2]
exact vadd_mem_of_mem_direction (Submodule.neg_mem _ hv2) hp2
#align affine_subspace.sup_direction_lt_of_nonempty_of_inter_empty AffineSubspace.sup_direction_lt_of_nonempty_of_inter_empty
/-- If the directions of two nonempty affine subspaces span the whole module, they have nonempty
intersection. -/
theorem inter_nonempty_of_nonempty_of_sup_direction_eq_top {s1 s2 : AffineSubspace k P}
(h1 : (s1 : Set P).Nonempty) (h2 : (s2 : Set P).Nonempty)
(hd : s1.direction ⊔ s2.direction = ⊤) : ((s1 : Set P) ∩ s2).Nonempty := by
by_contra h
rw [Set.not_nonempty_iff_eq_empty] at h
have hlt := sup_direction_lt_of_nonempty_of_inter_empty h1 h2 h
rw [hd] at hlt
exact not_top_lt hlt
#align affine_subspace.inter_nonempty_of_nonempty_of_sup_direction_eq_top AffineSubspace.inter_nonempty_of_nonempty_of_sup_direction_eq_top
/-- If the directions of two nonempty affine subspaces are complements of each other, they intersect
in exactly one point. -/
theorem inter_eq_singleton_of_nonempty_of_isCompl {s1 s2 : AffineSubspace k P}
(h1 : (s1 : Set P).Nonempty) (h2 : (s2 : Set P).Nonempty)
(hd : IsCompl s1.direction s2.direction) : ∃ p, (s1 : Set P) ∩ s2 = {p} := by
cases' inter_nonempty_of_nonempty_of_sup_direction_eq_top h1 h2 hd.sup_eq_top with p hp
use p
ext q
rw [Set.mem_singleton_iff]
constructor
· rintro ⟨hq1, hq2⟩
have hqp : q -ᵥ p ∈ s1.direction ⊓ s2.direction :=
⟨vsub_mem_direction hq1 hp.1, vsub_mem_direction hq2 hp.2⟩
rwa [hd.inf_eq_bot, Submodule.mem_bot, vsub_eq_zero_iff_eq] at hqp
· exact fun h => h.symm ▸ hp
#align affine_subspace.inter_eq_singleton_of_nonempty_of_is_compl AffineSubspace.inter_eq_singleton_of_nonempty_of_isCompl
/-- Coercing a subspace to a set then taking the affine span produces the original subspace. -/
@[simp]
theorem affineSpan_coe (s : AffineSubspace k P) : affineSpan k (s : Set P) = s := by
refine le_antisymm ?_ (subset_spanPoints _ _)
rintro p ⟨p1, hp1, v, hv, rfl⟩
exact vadd_mem_of_mem_direction hv hp1
#align affine_subspace.affine_span_coe AffineSubspace.affineSpan_coe
end AffineSubspace
section AffineSpace'
variable (k : Type*) {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
variable {ι : Type*}
open AffineSubspace Set
/-- The `vectorSpan` is the span of the pairwise subtractions with a given point on the left. -/
theorem vectorSpan_eq_span_vsub_set_left {s : Set P} {p : P} (hp : p ∈ s) :
vectorSpan k s = Submodule.span k ((p -ᵥ ·) '' s) := by
rw [vectorSpan_def]
refine le_antisymm ?_ (Submodule.span_mono ?_)
· rw [Submodule.span_le]
rintro v ⟨p1, hp1, p2, hp2, hv⟩
simp_rw [← vsub_sub_vsub_cancel_left p1 p2 p] at hv
rw [← hv, SetLike.mem_coe, Submodule.mem_span]
exact fun m hm => Submodule.sub_mem _ (hm ⟨p2, hp2, rfl⟩) (hm ⟨p1, hp1, rfl⟩)
· rintro v ⟨p2, hp2, hv⟩
exact ⟨p, hp, p2, hp2, hv⟩
#align vector_span_eq_span_vsub_set_left vectorSpan_eq_span_vsub_set_left
/-- The `vectorSpan` is the span of the pairwise subtractions with a given point on the right. -/
theorem vectorSpan_eq_span_vsub_set_right {s : Set P} {p : P} (hp : p ∈ s) :
vectorSpan k s = Submodule.span k ((· -ᵥ p) '' s) := by
rw [vectorSpan_def]
refine le_antisymm ?_ (Submodule.span_mono ?_)
· rw [Submodule.span_le]
rintro v ⟨p1, hp1, p2, hp2, hv⟩
simp_rw [← vsub_sub_vsub_cancel_right p1 p2 p] at hv
rw [← hv, SetLike.mem_coe, Submodule.mem_span]
exact fun m hm => Submodule.sub_mem _ (hm ⟨p1, hp1, rfl⟩) (hm ⟨p2, hp2, rfl⟩)
· rintro v ⟨p2, hp2, hv⟩
exact ⟨p2, hp2, p, hp, hv⟩
#align vector_span_eq_span_vsub_set_right vectorSpan_eq_span_vsub_set_right
/-- The `vectorSpan` is the span of the pairwise subtractions with a given point on the left,
excluding the subtraction of that point from itself. -/
theorem vectorSpan_eq_span_vsub_set_left_ne {s : Set P} {p : P} (hp : p ∈ s) :
vectorSpan k s = Submodule.span k ((p -ᵥ ·) '' (s \ {p})) := by
conv_lhs =>
rw [vectorSpan_eq_span_vsub_set_left k hp, ← Set.insert_eq_of_mem hp, ←
Set.insert_diff_singleton, Set.image_insert_eq]
simp [Submodule.span_insert_eq_span]
#align vector_span_eq_span_vsub_set_left_ne vectorSpan_eq_span_vsub_set_left_ne
/-- The `vectorSpan` is the span of the pairwise subtractions with a given point on the right,
excluding the subtraction of that point from itself. -/
theorem vectorSpan_eq_span_vsub_set_right_ne {s : Set P} {p : P} (hp : p ∈ s) :
vectorSpan k s = Submodule.span k ((· -ᵥ p) '' (s \ {p})) := by
conv_lhs =>
rw [vectorSpan_eq_span_vsub_set_right k hp, ← Set.insert_eq_of_mem hp, ←
Set.insert_diff_singleton, Set.image_insert_eq]
simp [Submodule.span_insert_eq_span]
#align vector_span_eq_span_vsub_set_right_ne vectorSpan_eq_span_vsub_set_right_ne
/-- The `vectorSpan` is the span of the pairwise subtractions with a given point on the right,
excluding the subtraction of that point from itself. -/
theorem vectorSpan_eq_span_vsub_finset_right_ne [DecidableEq P] [DecidableEq V] {s : Finset P}
{p : P} (hp : p ∈ s) :
vectorSpan k (s : Set P) = Submodule.span k ((s.erase p).image (· -ᵥ p)) := by
simp [vectorSpan_eq_span_vsub_set_right_ne _ (Finset.mem_coe.mpr hp)]
#align vector_span_eq_span_vsub_finset_right_ne vectorSpan_eq_span_vsub_finset_right_ne
/-- The `vectorSpan` of the image of a function is the span of the pairwise subtractions with a
given point on the left, excluding the subtraction of that point from itself. -/
theorem vectorSpan_image_eq_span_vsub_set_left_ne (p : ι → P) {s : Set ι} {i : ι} (hi : i ∈ s) :
vectorSpan k (p '' s) = Submodule.span k ((p i -ᵥ ·) '' (p '' (s \ {i}))) := by
conv_lhs =>
rw [vectorSpan_eq_span_vsub_set_left k (Set.mem_image_of_mem p hi), ← Set.insert_eq_of_mem hi, ←
Set.insert_diff_singleton, Set.image_insert_eq, Set.image_insert_eq]
simp [Submodule.span_insert_eq_span]
#align vector_span_image_eq_span_vsub_set_left_ne vectorSpan_image_eq_span_vsub_set_left_ne
/-- The `vectorSpan` of the image of a function is the span of the pairwise subtractions with a
given point on the right, excluding the subtraction of that point from itself. -/
theorem vectorSpan_image_eq_span_vsub_set_right_ne (p : ι → P) {s : Set ι} {i : ι} (hi : i ∈ s) :
vectorSpan k (p '' s) = Submodule.span k ((· -ᵥ p i) '' (p '' (s \ {i}))) := by
conv_lhs =>
rw [vectorSpan_eq_span_vsub_set_right k (Set.mem_image_of_mem p hi), ← Set.insert_eq_of_mem hi,
← Set.insert_diff_singleton, Set.image_insert_eq, Set.image_insert_eq]
simp [Submodule.span_insert_eq_span]
#align vector_span_image_eq_span_vsub_set_right_ne vectorSpan_image_eq_span_vsub_set_right_ne
/-- The `vectorSpan` of an indexed family is the span of the pairwise subtractions with a given
point on the left. -/
theorem vectorSpan_range_eq_span_range_vsub_left (p : ι → P) (i0 : ι) :
vectorSpan k (Set.range p) = Submodule.span k (Set.range fun i : ι => p i0 -ᵥ p i) := by
rw [vectorSpan_eq_span_vsub_set_left k (Set.mem_range_self i0), ← Set.range_comp]
congr
#align vector_span_range_eq_span_range_vsub_left vectorSpan_range_eq_span_range_vsub_left
/-- The `vectorSpan` of an indexed family is the span of the pairwise subtractions with a given
point on the right. -/
theorem vectorSpan_range_eq_span_range_vsub_right (p : ι → P) (i0 : ι) :
vectorSpan k (Set.range p) = Submodule.span k (Set.range fun i : ι => p i -ᵥ p i0) := by
rw [vectorSpan_eq_span_vsub_set_right k (Set.mem_range_self i0), ← Set.range_comp]
congr
#align vector_span_range_eq_span_range_vsub_right vectorSpan_range_eq_span_range_vsub_right
/-- The `vectorSpan` of an indexed family is the span of the pairwise subtractions with a given
point on the left, excluding the subtraction of that point from itself. -/
theorem vectorSpan_range_eq_span_range_vsub_left_ne (p : ι → P) (i₀ : ι) :
vectorSpan k (Set.range p) =
Submodule.span k (Set.range fun i : { x // x ≠ i₀ } => p i₀ -ᵥ p i) := by
rw [← Set.image_univ, vectorSpan_image_eq_span_vsub_set_left_ne k _ (Set.mem_univ i₀)]
congr with v
simp only [Set.mem_range, Set.mem_image, Set.mem_diff, Set.mem_singleton_iff, Subtype.exists,
Subtype.coe_mk]
constructor
· rintro ⟨x, ⟨i₁, ⟨⟨_, hi₁⟩, rfl⟩⟩, hv⟩
exact ⟨i₁, hi₁, hv⟩
· exact fun ⟨i₁, hi₁, hv⟩ => ⟨p i₁, ⟨i₁, ⟨Set.mem_univ _, hi₁⟩, rfl⟩, hv⟩
#align vector_span_range_eq_span_range_vsub_left_ne vectorSpan_range_eq_span_range_vsub_left_ne
/-- The `vectorSpan` of an indexed family is the span of the pairwise subtractions with a given
point on the right, excluding the subtraction of that point from itself. -/
theorem vectorSpan_range_eq_span_range_vsub_right_ne (p : ι → P) (i₀ : ι) :
vectorSpan k (Set.range p) =
Submodule.span k (Set.range fun i : { x // x ≠ i₀ } => p i -ᵥ p i₀) := by
rw [← Set.image_univ, vectorSpan_image_eq_span_vsub_set_right_ne k _ (Set.mem_univ i₀)]
congr with v
simp only [Set.mem_range, Set.mem_image, Set.mem_diff, Set.mem_singleton_iff, Subtype.exists,
Subtype.coe_mk]
constructor
· rintro ⟨x, ⟨i₁, ⟨⟨_, hi₁⟩, rfl⟩⟩, hv⟩
exact ⟨i₁, hi₁, hv⟩
· exact fun ⟨i₁, hi₁, hv⟩ => ⟨p i₁, ⟨i₁, ⟨Set.mem_univ _, hi₁⟩, rfl⟩, hv⟩
#align vector_span_range_eq_span_range_vsub_right_ne vectorSpan_range_eq_span_range_vsub_right_ne
section
variable {s : Set P}
/-- The affine span of a set is nonempty if and only if that set is. -/
theorem affineSpan_nonempty : (affineSpan k s : Set P).Nonempty ↔ s.Nonempty :=
spanPoints_nonempty k s
#align affine_span_nonempty affineSpan_nonempty
alias ⟨_, _root_.Set.Nonempty.affineSpan⟩ := affineSpan_nonempty
#align set.nonempty.affine_span Set.Nonempty.affineSpan
/-- The affine span of a nonempty set is nonempty. -/
instance [Nonempty s] : Nonempty (affineSpan k s) :=
((nonempty_coe_sort.1 ‹_›).affineSpan _).to_subtype
/-- The affine span of a set is `⊥` if and only if that set is empty. -/
@[simp]
theorem affineSpan_eq_bot : affineSpan k s = ⊥ ↔ s = ∅ := by
rw [← not_iff_not, ← Ne, ← Ne, ← nonempty_iff_ne_bot, affineSpan_nonempty,
nonempty_iff_ne_empty]
#align affine_span_eq_bot affineSpan_eq_bot
@[simp]
theorem bot_lt_affineSpan : ⊥ < affineSpan k s ↔ s.Nonempty := by
rw [bot_lt_iff_ne_bot, nonempty_iff_ne_empty]
exact (affineSpan_eq_bot _).not
#align bot_lt_affine_span bot_lt_affineSpan
end
variable {k}
/-- An induction principle for span membership. If `p` holds for all elements of `s` and is
preserved under certain affine combinations, then `p` holds for all elements of the span of `s`. -/
theorem affineSpan_induction {x : P} {s : Set P} {p : P → Prop} (h : x ∈ affineSpan k s)
(mem : ∀ x : P, x ∈ s → p x)
(smul_vsub_vadd : ∀ (c : k) (u v w : P), p u → p v → p w → p (c • (u -ᵥ v) +ᵥ w)) : p x :=
(affineSpan_le (Q := ⟨p, smul_vsub_vadd⟩)).mpr mem h
#align affine_span_induction affineSpan_induction
/-- A dependent version of `affineSpan_induction`. -/
@[elab_as_elim]
theorem affineSpan_induction' {s : Set P} {p : ∀ x, x ∈ affineSpan k s → Prop}
(mem : ∀ (y) (hys : y ∈ s), p y (subset_affineSpan k _ hys))
(smul_vsub_vadd :
∀ (c : k) (u hu v hv w hw),
p u hu →
p v hv → p w hw → p (c • (u -ᵥ v) +ᵥ w) (AffineSubspace.smul_vsub_vadd_mem _ _ hu hv hw))
{x : P} (h : x ∈ affineSpan k s) : p x h := by
refine Exists.elim ?_ fun (hx : x ∈ affineSpan k s) (hc : p x hx) => hc
-- Porting note: Lean couldn't infer the motive
refine affineSpan_induction (p := fun y => ∃ z, p y z) h ?_ ?_
· exact fun y hy => ⟨subset_affineSpan _ _ hy, mem y hy⟩
· exact fun c u v w hu hv hw =>
Exists.elim hu fun hu' hu =>
Exists.elim hv fun hv' hv =>
Exists.elim hw fun hw' hw =>
⟨AffineSubspace.smul_vsub_vadd_mem _ _ hu' hv' hw',
smul_vsub_vadd _ _ _ _ _ _ _ hu hv hw⟩
#align affine_span_induction' affineSpan_induction'
section WithLocalInstance
attribute [local instance] AffineSubspace.toAddTorsor
/-- A set, considered as a subset of its spanned affine subspace, spans the whole subspace. -/
@[simp]
theorem affineSpan_coe_preimage_eq_top (A : Set P) [Nonempty A] :
affineSpan k (((↑) : affineSpan k A → P) ⁻¹' A) = ⊤ := by
rw [eq_top_iff]
rintro ⟨x, hx⟩ -
refine affineSpan_induction' (fun y hy ↦ ?_) (fun c u hu v hv w hw ↦ ?_) hx
· exact subset_affineSpan _ _ hy
· exact AffineSubspace.smul_vsub_vadd_mem _ _
#align affine_span_coe_preimage_eq_top affineSpan_coe_preimage_eq_top
end WithLocalInstance
/-- Suppose a set of vectors spans `V`. Then a point `p`, together with those vectors added to `p`,
spans `P`. -/
theorem affineSpan_singleton_union_vadd_eq_top_of_span_eq_top {s : Set V} (p : P)
(h : Submodule.span k (Set.range ((↑) : s → V)) = ⊤) :
affineSpan k ({p} ∪ (fun v => v +ᵥ p) '' s) = ⊤ := by
convert ext_of_direction_eq _
⟨p, mem_affineSpan k (Set.mem_union_left _ (Set.mem_singleton _)), mem_top k V p⟩
rw [direction_affineSpan, direction_top,
vectorSpan_eq_span_vsub_set_right k (Set.mem_union_left _ (Set.mem_singleton _) : p ∈ _),
eq_top_iff, ← h]
apply Submodule.span_mono
rintro v ⟨v', rfl⟩
use (v' : V) +ᵥ p
simp
#align affine_span_singleton_union_vadd_eq_top_of_span_eq_top affineSpan_singleton_union_vadd_eq_top_of_span_eq_top
variable (k)
/-- The `vectorSpan` of two points is the span of their difference. -/
theorem vectorSpan_pair (p₁ p₂ : P) : vectorSpan k ({p₁, p₂} : Set P) = k ∙ p₁ -ᵥ p₂ := by
simp_rw [vectorSpan_eq_span_vsub_set_left k (mem_insert p₁ _), image_pair, vsub_self,
Submodule.span_insert_zero]
#align vector_span_pair vectorSpan_pair
/-- The `vectorSpan` of two points is the span of their difference (reversed). -/
theorem vectorSpan_pair_rev (p₁ p₂ : P) : vectorSpan k ({p₁, p₂} : Set P) = k ∙ p₂ -ᵥ p₁ := by
rw [pair_comm, vectorSpan_pair]
#align vector_span_pair_rev vectorSpan_pair_rev
/-- The difference between two points lies in their `vectorSpan`. -/
theorem vsub_mem_vectorSpan_pair (p₁ p₂ : P) : p₁ -ᵥ p₂ ∈ vectorSpan k ({p₁, p₂} : Set P) :=
vsub_mem_vectorSpan _ (Set.mem_insert _ _) (Set.mem_insert_of_mem _ (Set.mem_singleton _))
#align vsub_mem_vector_span_pair vsub_mem_vectorSpan_pair
/-- The difference between two points (reversed) lies in their `vectorSpan`. -/
theorem vsub_rev_mem_vectorSpan_pair (p₁ p₂ : P) : p₂ -ᵥ p₁ ∈ vectorSpan k ({p₁, p₂} : Set P) :=
vsub_mem_vectorSpan _ (Set.mem_insert_of_mem _ (Set.mem_singleton _)) (Set.mem_insert _ _)
#align vsub_rev_mem_vector_span_pair vsub_rev_mem_vectorSpan_pair
variable {k}
/-- A multiple of the difference between two points lies in their `vectorSpan`. -/
theorem smul_vsub_mem_vectorSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₁ -ᵥ p₂) ∈ vectorSpan k ({p₁, p₂} : Set P) :=
Submodule.smul_mem _ _ (vsub_mem_vectorSpan_pair k p₁ p₂)
#align smul_vsub_mem_vector_span_pair smul_vsub_mem_vectorSpan_pair
/-- A multiple of the difference between two points (reversed) lies in their `vectorSpan`. -/
theorem smul_vsub_rev_mem_vectorSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₂ -ᵥ p₁) ∈ vectorSpan k ({p₁, p₂} : Set P) :=
Submodule.smul_mem _ _ (vsub_rev_mem_vectorSpan_pair k p₁ p₂)
#align smul_vsub_rev_mem_vector_span_pair smul_vsub_rev_mem_vectorSpan_pair
/-- A vector lies in the `vectorSpan` of two points if and only if it is a multiple of their
difference. -/
theorem mem_vectorSpan_pair {p₁ p₂ : P} {v : V} :
v ∈ vectorSpan k ({p₁, p₂} : Set P) ↔ ∃ r : k, r • (p₁ -ᵥ p₂) = v := by
rw [vectorSpan_pair, Submodule.mem_span_singleton]
#align mem_vector_span_pair mem_vectorSpan_pair
/-- A vector lies in the `vectorSpan` of two points if and only if it is a multiple of their
difference (reversed). -/
theorem mem_vectorSpan_pair_rev {p₁ p₂ : P} {v : V} :
v ∈ vectorSpan k ({p₁, p₂} : Set P) ↔ ∃ r : k, r • (p₂ -ᵥ p₁) = v := by
rw [vectorSpan_pair_rev, Submodule.mem_span_singleton]
#align mem_vector_span_pair_rev mem_vectorSpan_pair_rev
variable (k)
/-- The line between two points, as an affine subspace. -/
notation "line[" k ", " p₁ ", " p₂ "]" =>
affineSpan k (insert p₁ (@singleton _ _ Set.instSingletonSet p₂))
/-- The first of two points lies in their affine span. -/
theorem left_mem_affineSpan_pair (p₁ p₂ : P) : p₁ ∈ line[k, p₁, p₂] :=
mem_affineSpan _ (Set.mem_insert _ _)
#align left_mem_affine_span_pair left_mem_affineSpan_pair
/-- The second of two points lies in their affine span. -/
theorem right_mem_affineSpan_pair (p₁ p₂ : P) : p₂ ∈ line[k, p₁, p₂] :=
mem_affineSpan _ (Set.mem_insert_of_mem _ (Set.mem_singleton _))
#align right_mem_affine_span_pair right_mem_affineSpan_pair
variable {k}
/-- A combination of two points expressed with `lineMap` lies in their affine span. -/
theorem AffineMap.lineMap_mem_affineSpan_pair (r : k) (p₁ p₂ : P) :
AffineMap.lineMap p₁ p₂ r ∈ line[k, p₁, p₂] :=
AffineMap.lineMap_mem _ (left_mem_affineSpan_pair _ _ _) (right_mem_affineSpan_pair _ _ _)
#align affine_map.line_map_mem_affine_span_pair AffineMap.lineMap_mem_affineSpan_pair
/-- A combination of two points expressed with `lineMap` (with the two points reversed) lies in
their affine span. -/
theorem AffineMap.lineMap_rev_mem_affineSpan_pair (r : k) (p₁ p₂ : P) :
AffineMap.lineMap p₂ p₁ r ∈ line[k, p₁, p₂] :=
AffineMap.lineMap_mem _ (right_mem_affineSpan_pair _ _ _) (left_mem_affineSpan_pair _ _ _)
#align affine_map.line_map_rev_mem_affine_span_pair AffineMap.lineMap_rev_mem_affineSpan_pair
/-- A multiple of the difference of two points added to the first point lies in their affine
span. -/
theorem smul_vsub_vadd_mem_affineSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₂ -ᵥ p₁) +ᵥ p₁ ∈ line[k, p₁, p₂] :=
AffineMap.lineMap_mem_affineSpan_pair _ _ _
#align smul_vsub_vadd_mem_affine_span_pair smul_vsub_vadd_mem_affineSpan_pair
/-- A multiple of the difference of two points added to the second point lies in their affine
span. -/
theorem smul_vsub_rev_vadd_mem_affineSpan_pair (r : k) (p₁ p₂ : P) :
r • (p₁ -ᵥ p₂) +ᵥ p₂ ∈ line[k, p₁, p₂] :=
AffineMap.lineMap_rev_mem_affineSpan_pair _ _ _
#align smul_vsub_rev_vadd_mem_affine_span_pair smul_vsub_rev_vadd_mem_affineSpan_pair
/-- A vector added to the first point lies in the affine span of two points if and only if it is
a multiple of their difference. -/
theorem vadd_left_mem_affineSpan_pair {p₁ p₂ : P} {v : V} :
v +ᵥ p₁ ∈ line[k, p₁, p₂] ↔ ∃ r : k, r • (p₂ -ᵥ p₁) = v := by
rw [vadd_mem_iff_mem_direction _ (left_mem_affineSpan_pair _ _ _), direction_affineSpan,
mem_vectorSpan_pair_rev]
#align vadd_left_mem_affine_span_pair vadd_left_mem_affineSpan_pair
/-- A vector added to the second point lies in the affine span of two points if and only if it is
a multiple of their difference. -/
theorem vadd_right_mem_affineSpan_pair {p₁ p₂ : P} {v : V} :
v +ᵥ p₂ ∈ line[k, p₁, p₂] ↔ ∃ r : k, r • (p₁ -ᵥ p₂) = v := by
rw [vadd_mem_iff_mem_direction _ (right_mem_affineSpan_pair _ _ _), direction_affineSpan,
mem_vectorSpan_pair]
#align vadd_right_mem_affine_span_pair vadd_right_mem_affineSpan_pair
/-- The span of two points that lie in an affine subspace is contained in that subspace. -/
theorem affineSpan_pair_le_of_mem_of_mem {p₁ p₂ : P} {s : AffineSubspace k P} (hp₁ : p₁ ∈ s)
(hp₂ : p₂ ∈ s) : line[k, p₁, p₂] ≤ s := by
rw [affineSpan_le, Set.insert_subset_iff, Set.singleton_subset_iff]
exact ⟨hp₁, hp₂⟩
#align affine_span_pair_le_of_mem_of_mem affineSpan_pair_le_of_mem_of_mem
/-- One line is contained in another differing in the first point if the first point of the first
line is contained in the second line. -/
theorem affineSpan_pair_le_of_left_mem {p₁ p₂ p₃ : P} (h : p₁ ∈ line[k, p₂, p₃]) :
line[k, p₁, p₃] ≤ line[k, p₂, p₃] :=
affineSpan_pair_le_of_mem_of_mem h (right_mem_affineSpan_pair _ _ _)
#align affine_span_pair_le_of_left_mem affineSpan_pair_le_of_left_mem
/-- One line is contained in another differing in the second point if the second point of the
first line is contained in the second line. -/
theorem affineSpan_pair_le_of_right_mem {p₁ p₂ p₃ : P} (h : p₁ ∈ line[k, p₂, p₃]) :
line[k, p₂, p₁] ≤ line[k, p₂, p₃] :=
affineSpan_pair_le_of_mem_of_mem (left_mem_affineSpan_pair _ _ _) h
#align affine_span_pair_le_of_right_mem affineSpan_pair_le_of_right_mem
variable (k)
/-- `affineSpan` is monotone. -/
@[mono]
theorem affineSpan_mono {s₁ s₂ : Set P} (h : s₁ ⊆ s₂) : affineSpan k s₁ ≤ affineSpan k s₂ :=
spanPoints_subset_coe_of_subset_coe (Set.Subset.trans h (subset_affineSpan k _))
#align affine_span_mono affineSpan_mono
/-- Taking the affine span of a set, adding a point and taking the span again produces the same
results as adding the point to the set and taking the span. -/
theorem affineSpan_insert_affineSpan (p : P) (ps : Set P) :
affineSpan k (insert p (affineSpan k ps : Set P)) = affineSpan k (insert p ps) := by
rw [Set.insert_eq, Set.insert_eq, span_union, span_union, affineSpan_coe]
#align affine_span_insert_affine_span affineSpan_insert_affineSpan
/-- If a point is in the affine span of a set, adding it to that set does not change the affine
span. -/
theorem affineSpan_insert_eq_affineSpan {p : P} {ps : Set P} (h : p ∈ affineSpan k ps) :
affineSpan k (insert p ps) = affineSpan k ps := by
rw [← mem_coe] at h
rw [← affineSpan_insert_affineSpan, Set.insert_eq_of_mem h, affineSpan_coe]
#align affine_span_insert_eq_affine_span affineSpan_insert_eq_affineSpan
variable {k}
/-- If a point is in the affine span of a set, adding it to that set does not change the vector
span. -/
theorem vectorSpan_insert_eq_vectorSpan {p : P} {ps : Set P} (h : p ∈ affineSpan k ps) :
vectorSpan k (insert p ps) = vectorSpan k ps := by
simp_rw [← direction_affineSpan, affineSpan_insert_eq_affineSpan _ h]
#align vector_span_insert_eq_vector_span vectorSpan_insert_eq_vectorSpan
/-- When the affine space is also a vector space, the affine span is contained within the linear
span. -/
lemma affineSpan_le_toAffineSubspace_span {s : Set V} :
affineSpan k s ≤ (Submodule.span k s).toAffineSubspace := by
intro x hx
show x ∈ Submodule.span k s
induction hx using affineSpan_induction' with
| mem x hx => exact Submodule.subset_span hx
| smul_vsub_vadd c u _ v _ w _ hu hv hw =>
simp only [vsub_eq_sub, vadd_eq_add]
apply Submodule.add_mem _ _ hw
exact Submodule.smul_mem _ _ (Submodule.sub_mem _ hu hv)
lemma affineSpan_subset_span {s : Set V} :
(affineSpan k s : Set V) ⊆ Submodule.span k s :=
affineSpan_le_toAffineSubspace_span
end AffineSpace'
namespace AffineSubspace
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
[AffineSpace V P]
/-- The direction of the sup of two nonempty affine subspaces is the sup of the two directions and
of any one difference between points in the two subspaces. -/
theorem direction_sup {s1 s2 : AffineSubspace k P} {p1 p2 : P} (hp1 : p1 ∈ s1) (hp2 : p2 ∈ s2) :
(s1 ⊔ s2).direction = s1.direction ⊔ s2.direction ⊔ k ∙ p2 -ᵥ p1 := by
refine le_antisymm ?_ ?_
· change (affineSpan k ((s1 : Set P) ∪ s2)).direction ≤ _
rw [← mem_coe] at hp1
rw [direction_affineSpan, vectorSpan_eq_span_vsub_set_right k (Set.mem_union_left _ hp1),
Submodule.span_le]
rintro v ⟨p3, hp3, rfl⟩
cases' hp3 with hp3 hp3
· rw [sup_assoc, sup_comm, SetLike.mem_coe, Submodule.mem_sup]
use 0, Submodule.zero_mem _, p3 -ᵥ p1, vsub_mem_direction hp3 hp1
rw [zero_add]
· rw [sup_assoc, SetLike.mem_coe, Submodule.mem_sup]
use 0, Submodule.zero_mem _, p3 -ᵥ p1
rw [and_comm, zero_add]
use rfl
rw [← vsub_add_vsub_cancel p3 p2 p1, Submodule.mem_sup]
use p3 -ᵥ p2, vsub_mem_direction hp3 hp2, p2 -ᵥ p1, Submodule.mem_span_singleton_self _
· refine sup_le (sup_direction_le _ _) ?_
rw [direction_eq_vectorSpan, vectorSpan_def]
exact
sInf_le_sInf fun p hp =>
Set.Subset.trans
(Set.singleton_subset_iff.2
(vsub_mem_vsub (mem_spanPoints k p2 _ (Set.mem_union_right _ hp2))
(mem_spanPoints k p1 _ (Set.mem_union_left _ hp1))))
hp
#align affine_subspace.direction_sup AffineSubspace.direction_sup
/-- The direction of the span of the result of adding a point to a nonempty affine subspace is the
sup of the direction of that subspace and of any one difference between that point and a point in
the subspace. -/
theorem direction_affineSpan_insert {s : AffineSubspace k P} {p1 p2 : P} (hp1 : p1 ∈ s) :
(affineSpan k (insert p2 (s : Set P))).direction =
Submodule.span k {p2 -ᵥ p1} ⊔ s.direction := by
rw [sup_comm, ← Set.union_singleton, ← coe_affineSpan_singleton k V p2]
change (s ⊔ affineSpan k {p2}).direction = _
rw [direction_sup hp1 (mem_affineSpan k (Set.mem_singleton _)), direction_affineSpan]
simp
#align affine_subspace.direction_affine_span_insert AffineSubspace.direction_affineSpan_insert
/-- Given a point `p1` in an affine subspace `s`, and a point `p2`, a point `p` is in the span of
`s` with `p2` added if and only if it is a multiple of `p2 -ᵥ p1` added to a point in `s`. -/
theorem mem_affineSpan_insert_iff {s : AffineSubspace k P} {p1 : P} (hp1 : p1 ∈ s) (p2 p : P) :
p ∈ affineSpan k (insert p2 (s : Set P)) ↔
∃ r : k, ∃ p0 ∈ s, p = r • (p2 -ᵥ p1 : V) +ᵥ p0 := by
rw [← mem_coe] at hp1
rw [← vsub_right_mem_direction_iff_mem (mem_affineSpan k (Set.mem_insert_of_mem _ hp1)),
direction_affineSpan_insert hp1, Submodule.mem_sup]
constructor
· rintro ⟨v1, hv1, v2, hv2, hp⟩
rw [Submodule.mem_span_singleton] at hv1
rcases hv1 with ⟨r, rfl⟩
use r, v2 +ᵥ p1, vadd_mem_of_mem_direction hv2 hp1
symm at hp
rw [← sub_eq_zero, ← vsub_vadd_eq_vsub_sub, vsub_eq_zero_iff_eq] at hp
rw [hp, vadd_vadd]
· rintro ⟨r, p3, hp3, rfl⟩
use r • (p2 -ᵥ p1), Submodule.mem_span_singleton.2 ⟨r, rfl⟩, p3 -ᵥ p1,
vsub_mem_direction hp3 hp1
rw [vadd_vsub_assoc]
#align affine_subspace.mem_affine_span_insert_iff AffineSubspace.mem_affineSpan_insert_iff
end AffineSubspace
section MapComap
variable {k V₁ P₁ V₂ P₂ V₃ P₃ : Type*} [Ring k]
variable [AddCommGroup V₁] [Module k V₁] [AddTorsor V₁ P₁]
variable [AddCommGroup V₂] [Module k V₂] [AddTorsor V₂ P₂]
variable [AddCommGroup V₃] [Module k V₃] [AddTorsor V₃ P₃]
section
variable (f : P₁ →ᵃ[k] P₂)
@[simp]
theorem AffineMap.vectorSpan_image_eq_submodule_map {s : Set P₁} :
Submodule.map f.linear (vectorSpan k s) = vectorSpan k (f '' s) := by
rw [vectorSpan_def, vectorSpan_def, f.image_vsub_image, Submodule.span_image]
-- Porting note: Lean unfolds things too far with `simp` here.
#align affine_map.vector_span_image_eq_submodule_map AffineMap.vectorSpan_image_eq_submodule_map
namespace AffineSubspace
/-- The image of an affine subspace under an affine map as an affine subspace. -/
def map (s : AffineSubspace k P₁) : AffineSubspace k P₂ where
carrier := f '' s
smul_vsub_vadd_mem := by
rintro t - - - ⟨p₁, h₁, rfl⟩ ⟨p₂, h₂, rfl⟩ ⟨p₃, h₃, rfl⟩
use t • (p₁ -ᵥ p₂) +ᵥ p₃
suffices t • (p₁ -ᵥ p₂) +ᵥ p₃ ∈ s by
{ simp only [SetLike.mem_coe, true_and, this]
rw [AffineMap.map_vadd, map_smul, AffineMap.linearMap_vsub] }
exact s.smul_vsub_vadd_mem t h₁ h₂ h₃
#align affine_subspace.map AffineSubspace.map
@[simp]
theorem coe_map (s : AffineSubspace k P₁) : (s.map f : Set P₂) = f '' s :=
rfl
#align affine_subspace.coe_map AffineSubspace.coe_map
@[simp]
theorem mem_map {f : P₁ →ᵃ[k] P₂} {x : P₂} {s : AffineSubspace k P₁} :
x ∈ s.map f ↔ ∃ y ∈ s, f y = x :=
Iff.rfl
#align affine_subspace.mem_map AffineSubspace.mem_map
theorem mem_map_of_mem {x : P₁} {s : AffineSubspace k P₁} (h : x ∈ s) : f x ∈ s.map f :=
Set.mem_image_of_mem _ h
#align affine_subspace.mem_map_of_mem AffineSubspace.mem_map_of_mem
-- The simpNF linter says that the LHS can be simplified via `AffineSubspace.mem_map`.
-- However this is a higher priority lemma.
-- https://github.com/leanprover/std4/issues/207
@[simp 1100, nolint simpNF]
theorem mem_map_iff_mem_of_injective {f : P₁ →ᵃ[k] P₂} {x : P₁} {s : AffineSubspace k P₁}
(hf : Function.Injective f) : f x ∈ s.map f ↔ x ∈ s :=
hf.mem_set_image
#align affine_subspace.mem_map_iff_mem_of_injective AffineSubspace.mem_map_iff_mem_of_injective
@[simp]
theorem map_bot : (⊥ : AffineSubspace k P₁).map f = ⊥ :=
coe_injective <| image_empty f
#align affine_subspace.map_bot AffineSubspace.map_bot
@[simp]
theorem map_eq_bot_iff {s : AffineSubspace k P₁} : s.map f = ⊥ ↔ s = ⊥ := by
refine ⟨fun h => ?_, fun h => ?_⟩
· rwa [← coe_eq_bot_iff, coe_map, image_eq_empty, coe_eq_bot_iff] at h
· rw [h, map_bot]
#align affine_subspace.map_eq_bot_iff AffineSubspace.map_eq_bot_iff
@[simp]
theorem map_id (s : AffineSubspace k P₁) : s.map (AffineMap.id k P₁) = s :=
coe_injective <| image_id _
#align affine_subspace.map_id AffineSubspace.map_id
theorem map_map (s : AffineSubspace k P₁) (f : P₁ →ᵃ[k] P₂) (g : P₂ →ᵃ[k] P₃) :
(s.map f).map g = s.map (g.comp f) :=
coe_injective <| image_image _ _ _
#align affine_subspace.map_map AffineSubspace.map_map
@[simp]
theorem map_direction (s : AffineSubspace k P₁) :
(s.map f).direction = s.direction.map f.linear := by
rw [direction_eq_vectorSpan, direction_eq_vectorSpan, coe_map,
AffineMap.vectorSpan_image_eq_submodule_map]
-- Porting note: again, Lean unfolds too aggressively with `simp`
#align affine_subspace.map_direction AffineSubspace.map_direction
| Mathlib/LinearAlgebra/AffineSpace/AffineSubspace.lean | 1,597 | 1,605 | theorem map_span (s : Set P₁) : (affineSpan k s).map f = affineSpan k (f '' s) := by |
rcases s.eq_empty_or_nonempty with (rfl | ⟨p, hp⟩);
· rw [image_empty, span_empty, span_empty, map_bot]
-- Porting note: I don't know exactly why this `simp` was broken.
apply ext_of_direction_eq
· simp [direction_affineSpan]
· exact
⟨f p, mem_image_of_mem f (subset_affineSpan k _ hp),
subset_affineSpan k _ (mem_image_of_mem f hp)⟩
|
/-
Copyright (c) 2023 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.PUnitInstances
import Mathlib.GroupTheory.Congruence.Basic
/-!
# Coproduct (free product) of two monoids or groups
In this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)
to be the coproduct (a.k.a. free product) of two monoids.
The same type is used for the coproduct of two monoids and for the coproduct of two groups.
The coproduct `M ∗ N` has the following universal property:
for any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,
there exists a unique homomorphism `fg : M ∗ N →* P`
such that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,
where `Monoid.Coprod.inl : M →* M ∗ N`
and `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.
This homomorphism `fg` is given by `Monoid.Coprod.lift f g`.
We also define some homomorphisms and isomorphisms about `M ∗ N`,
and provide additive versions of all definitions and theorems.
## Main definitions
### Types
* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):
the free product (a.k.a. coproduct) of two monoids `M` and `N`.
* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.
In other sections, we only list multiplicative definitions.
### Instances
* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.
### Monoid homomorphisms
* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.
* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.
* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`
from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.
* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`
that allows the user to control the computational behavior.
* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`
into `M ∗ M' →* N ∗ N'`.
* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.
* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:
natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.
### Monoid isomorphisms
* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.
* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.
* `MulEquiv.coprodAssoc`: associativity of the coproduct.
* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:
free product by `PUnit` on the left or on the right is isomorphic to the original monoid.
## Main results
The universal property of the coproduct
is given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.
We also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`
for homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.
## Implementation details
The definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.
While mathematically `M ∗ N` is a particular case
of the coproduct of an indexed family of monoids,
it is easier to build API from scratch instead of using something like
```
def Monoid.Coprod M N := Monoid.CoprodI ![M, N]
```
or
```
def Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)
```
There are several reasons to build an API from scratch.
- API about `Con` makes it easy to define the required type and prove the universal property,
so there is little overhead compared to transferring API from `Monoid.CoprodI`.
- If `M` and `N` live in different universes, then the definition has to add `ULift`s;
this makes it harder to transfer API and definitions.
- As of now, we have no way
to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`
from `[Monoid M]` and `[Monoid N]`,
not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.
- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`
as the underlying type makes it possible to write computationally effective code
(though this point is not tested yet).
## TODO
- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and
`Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.
## Tags
group, monoid, coproduct, free product
-/
open FreeMonoid Function List Set
namespace Monoid
/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`
such that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms
to the quotient by `c`. -/
@[to_additive "The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`
such that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`
are additive monoid homomorphisms to the quotient by `c`."]
def coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=
sInf {c |
(∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))
∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))
∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}
/-- Coproduct of two monoids or groups. -/
@[to_additive "Coproduct of two additive monoids or groups."]
def Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient
namespace Coprod
@[inherit_doc]
scoped infix:30 " ∗ " => Coprod
section MulOneClass
variable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']
[MulOneClass P]
@[to_additive] protected instance : MulOneClass (M ∗ N) := Con.mulOneClass _
/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/
@[to_additive "The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`."]
def mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _
@[to_additive (attr := simp)]
theorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _
@[to_additive]
theorem mk_surjective : Surjective (@mk M N _ _) := surjective_quot_mk _
@[to_additive (attr := simp)]
theorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'
@[to_additive]
theorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _
/-- The natural embedding `M →* M ∗ N`. -/
@[to_additive "The natural embedding `M →+ AddMonoid.Coprod M N`."]
def inl : M →* M ∗ N where
toFun := fun x => mk (of (.inl x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y
/-- The natural embedding `N →* M ∗ N`. -/
@[to_additive "The natural embedding `N →+ AddMonoid.Coprod M N`."]
def inr : N →* M ∗ N where
toFun := fun x => mk (of (.inr x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y
@[to_additive (attr := simp)]
theorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl
@[to_additive (attr := simp)]
theorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl
@[to_additive (attr := elab_as_elim)]
theorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)
(one : C 1)
(inl_mul : ∀ m x, C x → C (inl m * x))
(inr_mul : ∀ n x, C x → C (inr n * x)) : C m := by
rcases mk_surjective m with ⟨x, rfl⟩
induction x using FreeMonoid.recOn with
| h0 => exact one
| ih x xs ih =>
cases x with
| inl m => simpa using inl_mul m _ ih
| inr n => simpa using inr_mul n _ ih
@[to_additive (attr := elab_as_elim)]
theorem induction_on {C : M ∗ N → Prop} (m : M ∗ N)
(inl : ∀ m, C (inl m)) (inr : ∀ n, C (inr n)) (mul : ∀ x y, C x → C y → C (x * y)) : C m :=
induction_on' m (by simpa using inl 1) (fun _ _ ↦ mul _ _ (inl _)) fun _ _ ↦ mul _ _ (inr _)
/-- Lift a monoid homomorphism `FreeMonoid (M ⊕ N) →* P` satisfying additional properties to
`M ∗ N →* P`. In many cases, `Coprod.lift` is more convenient.
Compared to `Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `MulOneclass` assumptions while `Coprod.lift` needs a `Monoid` structure.
-/
@[to_additive "Lift an additive monoid homomorphism `FreeAddMonoid (M ⊕ N) →+ P` satisfying
additional properties to `AddMonoid.Coprod M N →+ P`.
Compared to `AddMonoid.Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `AddZeroclass` assumptions
while `AddMonoid.Coprod.lift` needs an `AddMonoid` structure. "]
def clift (f : FreeMonoid (M ⊕ N) →* P)
(hM₁ : f (of (.inl 1)) = 1) (hN₁ : f (of (.inr 1)) = 1)
(hM : ∀ x y, f (of (.inl (x * y))) = f (of (.inl x) * of (.inl y)))
(hN : ∀ x y, f (of (.inr (x * y))) = f (of (.inr x) * of (.inr y))) :
M ∗ N →* P :=
Con.lift _ f <| sInf_le ⟨hM, hN, hM₁.trans (map_one f).symm, hN₁.trans (map_one f).symm⟩
@[to_additive (attr := simp)]
theorem clift_apply_inl (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : M) :
clift f hM₁ hN₁ hM hN (inl x) = f (of (.inl x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_inr (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : N) :
clift f hM₁ hN₁ hM hN (inr x) = f (of (.inr x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN w) :
clift f hM₁ hN₁ hM hN (mk w) = f w :=
rfl
@[to_additive (attr := simp)]
theorem clift_comp_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) :
(clift f hM₁ hN₁ hM hN).comp mk = f :=
DFunLike.ext' rfl
@[to_additive (attr := simp)]
theorem mclosure_range_inl_union_inr :
Submonoid.closure (range (inl : M →* M ∗ N) ∪ range (inr : N →* M ∗ N)) = ⊤ := by
rw [← mrange_mk, MonoidHom.mrange_eq_map, ← closure_range_of, MonoidHom.map_mclosure,
← range_comp, Sum.range_eq]; rfl
@[to_additive (attr := simp)] theorem mrange_inl_sup_mrange_inr :
MonoidHom.mrange (inl : M →* M ∗ N) ⊔ MonoidHom.mrange (inr : N →* M ∗ N) = ⊤ := by
rw [← mclosure_range_inl_union_inr, Submonoid.closure_union, ← MonoidHom.coe_mrange,
← MonoidHom.coe_mrange, Submonoid.closure_eq, Submonoid.closure_eq]
@[to_additive]
theorem codisjoint_mrange_inl_mrange_inr :
Codisjoint (MonoidHom.mrange (inl : M →* M ∗ N)) (MonoidHom.mrange inr) :=
codisjoint_iff.2 mrange_inl_sup_mrange_inr
@[to_additive] theorem mrange_eq (f : M ∗ N →* P) :
MonoidHom.mrange f = MonoidHom.mrange (f.comp inl) ⊔ MonoidHom.mrange (f.comp inr) := by
rw [MonoidHom.mrange_eq_map, ← mrange_inl_sup_mrange_inr, Submonoid.map_sup, MonoidHom.map_mrange,
MonoidHom.map_mrange]
/-- Extensionality lemma for monoid homomorphisms `M ∗ N →* P`.
If two homomorphisms agree on the ranges of `Monoid.Coprod.inl` and `Monoid.Coprod.inr`,
then they are equal. -/
@[to_additive (attr := ext 1100)
"Extensionality lemma for additive monoid homomorphisms `AddMonoid.Coprod M N →+ P`.
If two homomorphisms agree on the ranges of `AddMonoid.Coprod.inl` and `AddMonoid.Coprod.inr`,
then they are equal."]
theorem hom_ext {f g : M ∗ N →* P} (h₁ : f.comp inl = g.comp inl) (h₂ : f.comp inr = g.comp inr) :
f = g :=
MonoidHom.eq_of_eqOn_denseM mclosure_range_inl_union_inr <| eqOn_union.2
⟨eqOn_range.2 <| DFunLike.ext'_iff.1 h₁, eqOn_range.2 <| DFunLike.ext'_iff.1 h₂⟩
@[to_additive (attr := simp)]
theorem clift_mk :
clift (mk : FreeMonoid (M ⊕ N) →* M ∗ N) (map_one inl) (map_one inr) (map_mul inl)
(map_mul inr) = .id _ :=
hom_ext rfl rfl
/-- Map `M ∗ N` to `M' ∗ N'` by applying `Sum.map f g` to each element of the underlying list. -/
@[to_additive "Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod M' N'`
by applying `Sum.map f g` to each element of the underlying list."]
def map (f : M →* M') (g : N →* N') : M ∗ N →* M' ∗ N' :=
clift (mk.comp <| FreeMonoid.map <| Sum.map f g)
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_one, mk_of_inl])
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_one, mk_of_inr])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_mul, mk_of_inl])
fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_mul, mk_of_inr]
@[to_additive (attr := simp)]
theorem map_mk_ofList (f : M →* M') (g : N →* N') (l : List (M ⊕ N)) :
map f g (mk (ofList l)) = mk (ofList (l.map (Sum.map f g))) :=
rfl
@[to_additive (attr := simp)]
theorem map_apply_inl (f : M →* M') (g : N →* N') (x : M) : map f g (inl x) = inl (f x) := rfl
@[to_additive (attr := simp)]
theorem map_apply_inr (f : M →* M') (g : N →* N') (x : N) : map f g (inr x) = inr (g x) := rfl
@[to_additive (attr := simp)]
theorem map_comp_inl (f : M →* M') (g : N →* N') : (map f g).comp inl = inl.comp f := rfl
@[to_additive (attr := simp)]
theorem map_comp_inr (f : M →* M') (g : N →* N') : (map f g).comp inr = inr.comp g := rfl
@[to_additive (attr := simp)]
theorem map_id_id : map (.id M) (.id N) = .id (M ∗ N) := hom_ext rfl rfl
@[to_additive]
theorem map_comp_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' →* M'') (g' : N' →* N'')
(f : M →* M') (g : N →* N') : (map f' g').comp (map f g) = map (f'.comp f) (g'.comp g) :=
hom_ext rfl rfl
@[to_additive]
theorem map_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' →* M'') (g' : N' →* N'')
(f : M →* M') (g : N →* N') (x : M ∗ N) :
map f' g' (map f g x) = map (f'.comp f) (g'.comp g) x :=
DFunLike.congr_fun (map_comp_map f' g' f g) x
variable (M N)
/-- Map `M ∗ N` to `N ∗ M` by applying `Sum.swap` to each element of the underlying list.
See also `MulEquiv.coprodComm` for a `MulEquiv` version. -/
@[to_additive "Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod N M`
by applying `Sum.swap` to each element of the underlying list.
See also `AddEquiv.coprodComm` for an `AddEquiv` version."]
def swap : M ∗ N →* N ∗ M :=
clift (mk.comp <| FreeMonoid.map Sum.swap)
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_one])
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_one])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_mul])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_mul])
@[to_additive (attr := simp)]
theorem swap_comp_swap : (swap M N).comp (swap N M) = .id _ := hom_ext rfl rfl
variable {M N}
@[to_additive (attr := simp)]
theorem swap_swap (x : M ∗ N) : swap N M (swap M N x) = x :=
DFunLike.congr_fun (swap_comp_swap _ _) x
@[to_additive]
theorem swap_comp_map (f : M →* M') (g : N →* N') :
(swap M' N').comp (map f g) = (map g f).comp (swap M N) :=
hom_ext rfl rfl
@[to_additive]
theorem swap_map (f : M →* M') (g : N →* N') (x : M ∗ N) :
swap M' N' (map f g x) = map g f (swap M N x) :=
DFunLike.congr_fun (swap_comp_map f g) x
@[to_additive (attr := simp)] theorem swap_comp_inl : (swap M N).comp inl = inr := rfl
@[to_additive (attr := simp)] theorem swap_inl (x : M) : swap M N (inl x) = inr x := rfl
@[to_additive (attr := simp)] theorem swap_comp_inr : (swap M N).comp inr = inl := rfl
@[to_additive (attr := simp)] theorem swap_inr (x : N) : swap M N (inr x) = inl x := rfl
@[to_additive]
theorem swap_injective : Injective (swap M N) := LeftInverse.injective swap_swap
@[to_additive (attr := simp)]
theorem swap_inj {x y : M ∗ N} : swap M N x = swap M N y ↔ x = y := swap_injective.eq_iff
@[to_additive (attr := simp)]
theorem swap_eq_one {x : M ∗ N} : swap M N x = 1 ↔ x = 1 := swap_injective.eq_iff' (map_one _)
@[to_additive]
theorem swap_surjective : Surjective (swap M N) := LeftInverse.surjective swap_swap
@[to_additive]
theorem swap_bijective : Bijective (swap M N) := ⟨swap_injective, swap_surjective⟩
@[to_additive (attr := simp)]
theorem mker_swap : MonoidHom.mker (swap M N) = ⊥ := Submonoid.ext fun _ ↦ swap_eq_one
@[to_additive (attr := simp)]
theorem mrange_swap : MonoidHom.mrange (swap M N) = ⊤ :=
MonoidHom.mrange_top_of_surjective _ swap_surjective
end MulOneClass
section Lift
variable {M N P : Type*} [MulOneClass M] [MulOneClass N] [Monoid P]
/-- Lift a pair of monoid homomorphisms `f : M →* P`, `g : N →* P`
to a monoid homomorphism `M ∗ N →* P`.
See also `Coprod.clift` for a version that allows custom computational behavior
and works for a `MulOneClass` codomain.
-/
@[to_additive "Lift a pair of additive monoid homomorphisms `f : M →+ P`, `g : N →+ P`
to an additive monoid homomorphism `AddMonoid.Coprod M N →+ P`.
See also `AddMonoid.Coprod.clift` for a version that allows custom computational behavior
and works for an `AddZeroClass` codomain."]
def lift (f : M →* P) (g : N →* P) : (M ∗ N) →* P :=
clift (FreeMonoid.lift <| Sum.elim f g) (map_one f) (map_one g) (map_mul f) (map_mul g)
@[to_additive (attr := simp)]
theorem lift_apply_mk (f : M →* P) (g : N →* P) (x : FreeMonoid (M ⊕ N)) :
lift f g (mk x) = FreeMonoid.lift (Sum.elim f g) x :=
rfl
@[to_additive (attr := simp)]
theorem lift_apply_inl (f : M →* P) (g : N →* P) (x : M) : lift f g (inl x) = f x :=
rfl
@[to_additive]
theorem lift_unique {f : M →* P} {g : N →* P} {fg : M ∗ N →* P} (h₁ : fg.comp inl = f)
(h₂ : fg.comp inr = g) : fg = lift f g :=
hom_ext h₁ h₂
@[to_additive (attr := simp)]
theorem lift_comp_inl (f : M →* P) (g : N →* P) : (lift f g).comp inl = f := rfl
@[to_additive (attr := simp)]
theorem lift_apply_inr (f : M →* P) (g : N →* P) (x : N) : lift f g (inr x) = g x :=
rfl
@[to_additive (attr := simp)]
theorem lift_comp_inr (f : M →* P) (g : N →* P) : (lift f g).comp inr = g := rfl
@[to_additive (attr := simp)]
theorem lift_comp_swap (f : M →* P) (g : N →* P) : (lift f g).comp (swap N M) = lift g f :=
hom_ext rfl rfl
@[to_additive (attr := simp)]
theorem lift_swap (f : M →* P) (g : N →* P) (x : N ∗ M) : lift f g (swap N M x) = lift g f x :=
DFunLike.congr_fun (lift_comp_swap f g) x
@[to_additive]
theorem comp_lift {P' : Type*} [Monoid P'] (f : P →* P') (g₁ : M →* P) (g₂ : N →* P) :
f.comp (lift g₁ g₂) = lift (f.comp g₁) (f.comp g₂) :=
hom_ext (by rw [MonoidHom.comp_assoc, lift_comp_inl, lift_comp_inl]) <| by
rw [MonoidHom.comp_assoc, lift_comp_inr, lift_comp_inr]
/-- `Coprod.lift` as an equivalence. -/
@[to_additive "`AddMonoid.Coprod.lift` as an equivalence."]
def liftEquiv : (M →* P) × (N →* P) ≃ (M ∗ N →* P) where
toFun fg := lift fg.1 fg.2
invFun f := (f.comp inl, f.comp inr)
left_inv _ := rfl
right_inv _ := Eq.symm <| lift_unique rfl rfl
@[to_additive (attr := simp)]
theorem mrange_lift (f : M →* P) (g : N →* P) :
MonoidHom.mrange (lift f g) = MonoidHom.mrange f ⊔ MonoidHom.mrange g := by
simp [mrange_eq]
end Lift
section ToProd
variable {M N : Type*} [Monoid M] [Monoid N]
@[to_additive] instance : Monoid (M ∗ N) :=
{ mul_assoc := (Con.monoid _).mul_assoc
one_mul := (Con.monoid _).one_mul
mul_one := (Con.monoid _).mul_one }
/-- The natural projection `M ∗ N →* M`. -/
@[to_additive "The natural projection `AddMonoid.Coprod M N →+ M`."]
def fst : M ∗ N →* M := lift (.id M) 1
/-- The natural projection `M ∗ N →* N`. -/
@[to_additive "The natural projection `AddMonoid.Coprod M N →+ N`."]
def snd : M ∗ N →* N := lift 1 (.id N)
/-- The natural projection `M ∗ N →* M × N`. -/
@[to_additive "The natural projection `AddMonoid.Coprod M N →+ M × N`."]
def toProd : M ∗ N →* M × N := lift (.inl _ _) (.inr _ _)
@[to_additive (attr := simp)] theorem fst_comp_inl : (fst : M ∗ N →* M).comp inl = .id _ := rfl
@[to_additive (attr := simp)] theorem fst_apply_inl (x : M) : fst (inl x : M ∗ N) = x := rfl
@[to_additive (attr := simp)] theorem fst_comp_inr : (fst : M ∗ N →* M).comp inr = 1 := rfl
@[to_additive (attr := simp)] theorem fst_apply_inr (x : N) : fst (inr x : M ∗ N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inl : (snd : M ∗ N →* N).comp inl = 1 := rfl
@[to_additive (attr := simp)] theorem snd_apply_inl (x : M) : snd (inl x : M ∗ N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inr : (snd : M ∗ N →* N).comp inr = .id _ := rfl
@[to_additive (attr := simp)] theorem snd_apply_inr (x : N) : snd (inr x : M ∗ N) = x := rfl
@[to_additive (attr := simp)]
theorem toProd_comp_inl : (toProd : M ∗ N →* M × N).comp inl = .inl _ _ := rfl
@[to_additive (attr := simp)]
theorem toProd_comp_inr : (toProd : M ∗ N →* M × N).comp inr = .inr _ _ := rfl
@[to_additive (attr := simp)]
theorem toProd_apply_inl (x : M) : toProd (inl x : M ∗ N) = (x, 1) := rfl
@[to_additive (attr := simp)]
theorem toProd_apply_inr (x : N) : toProd (inr x : M ∗ N) = (1, x) := rfl
@[to_additive (attr := simp)]
theorem fst_prod_snd : (fst : M ∗ N →* M).prod snd = toProd := by ext1 <;> rfl
@[to_additive (attr := simp)]
theorem prod_mk_fst_snd (x : M ∗ N) : (fst x, snd x) = toProd x := by
rw [← fst_prod_snd, MonoidHom.prod_apply]
@[to_additive (attr := simp)]
| Mathlib/GroupTheory/Coprod/Basic.lean | 512 | 513 | theorem fst_comp_toProd : (MonoidHom.fst M N).comp toProd = fst := by |
rw [← fst_prod_snd, MonoidHom.fst_comp_prod]
|
/-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Bhavik Mehta
-/
import Mathlib.CategoryTheory.Limits.Preserves.Basic
#align_import category_theory.limits.preserves.limits from "leanprover-community/mathlib"@"e97cf15cd1aec9bd5c193b2ffac5a6dc9118912b"
/-!
# Isomorphisms about functors which preserve (co)limits
If `G` preserves limits, and `C` and `D` have limits, then for any diagram `F : J ⥤ C` we have a
canonical isomorphism `preservesLimitsIso : G.obj (Limit F) ≅ Limit (F ⋙ G)`.
We also show that we can commute `IsLimit.lift` of a preserved limit with `Functor.mapCone`:
`(PreservesLimit.preserves t).lift (G.mapCone c₂) = G.map (t.lift c₂)`.
The duals of these are also given. For functors which preserve (co)limits of specific shapes, see
`preserves/shapes.lean`.
-/
universe w' w v₁ v₂ u₁ u₂
noncomputable section
namespace CategoryTheory
open Category Limits
variable {C : Type u₁} [Category.{v₁} C]
variable {D : Type u₂} [Category.{v₂} D]
variable (G : C ⥤ D)
variable {J : Type w} [Category.{w'} J]
variable (F : J ⥤ C)
section
variable [PreservesLimit F G]
@[simp]
theorem preserves_lift_mapCone (c₁ c₂ : Cone F) (t : IsLimit c₁) :
(PreservesLimit.preserves t).lift (G.mapCone c₂) = G.map (t.lift c₂) :=
((PreservesLimit.preserves t).uniq (G.mapCone c₂) _ (by simp [← G.map_comp])).symm
#align category_theory.preserves_lift_map_cone CategoryTheory.preserves_lift_mapCone
variable [HasLimit F]
/-- If `G` preserves limits, we have an isomorphism from the image of the limit of a functor `F`
to the limit of the functor `F ⋙ G`.
-/
def preservesLimitIso : G.obj (limit F) ≅ limit (F ⋙ G) :=
(PreservesLimit.preserves (limit.isLimit _)).conePointUniqueUpToIso (limit.isLimit _)
#align category_theory.preserves_limit_iso CategoryTheory.preservesLimitIso
@[reassoc (attr := simp)]
theorem preservesLimitsIso_hom_π (j) :
(preservesLimitIso G F).hom ≫ limit.π _ j = G.map (limit.π F j) :=
IsLimit.conePointUniqueUpToIso_hom_comp _ _ j
#align category_theory.preserves_limits_iso_hom_π CategoryTheory.preservesLimitsIso_hom_π
@[reassoc (attr := simp)]
theorem preservesLimitsIso_inv_π (j) :
(preservesLimitIso G F).inv ≫ G.map (limit.π F j) = limit.π _ j :=
IsLimit.conePointUniqueUpToIso_inv_comp _ _ j
#align category_theory.preserves_limits_iso_inv_π CategoryTheory.preservesLimitsIso_inv_π
@[reassoc (attr := simp)]
theorem lift_comp_preservesLimitsIso_hom (t : Cone F) :
G.map (limit.lift _ t) ≫ (preservesLimitIso G F).hom =
limit.lift (F ⋙ G) (G.mapCone _) := by
ext
simp [← G.map_comp]
#align category_theory.lift_comp_preserves_limits_iso_hom CategoryTheory.lift_comp_preservesLimitsIso_hom
instance : IsIso (limit.post F G) :=
show IsIso (preservesLimitIso G F).hom from inferInstance
variable [PreservesLimitsOfShape J G] [HasLimitsOfShape J D] [HasLimitsOfShape J C]
/-- If `C, D` has all limits of shape `J`, and `G` preserves them, then `preservesLimitsIso` is
functorial wrt `F`. -/
@[simps!]
def preservesLimitNatIso : lim ⋙ G ≅ (whiskeringRight J C D).obj G ⋙ lim :=
NatIso.ofComponents (fun F => preservesLimitIso G F)
(by
intro _ _ f
apply limit.hom_ext; intro j
dsimp
simp only [preservesLimitsIso_hom_π, whiskerRight_app, limMap_π, Category.assoc,
preservesLimitsIso_hom_π_assoc, ← G.map_comp])
#align category_theory.preserves_limit_nat_iso CategoryTheory.preservesLimitNatIso
end
section
variable [HasLimit F] [HasLimit (F ⋙ G)]
/-- If the comparison morphism `G.obj (limit F) ⟶ limit (F ⋙ G)` is an isomorphism, then `G`
preserves limits of `F`. -/
def preservesLimitOfIsIsoPost [IsIso (limit.post F G)] : PreservesLimit F G :=
preservesLimitOfPreservesLimitCone (limit.isLimit F) (by
convert IsLimit.ofPointIso (limit.isLimit (F ⋙ G))
assumption)
end
section
variable [PreservesColimit F G]
@[simp]
theorem preserves_desc_mapCocone (c₁ c₂ : Cocone F) (t : IsColimit c₁) :
(PreservesColimit.preserves t).desc (G.mapCocone _) = G.map (t.desc c₂) :=
((PreservesColimit.preserves t).uniq (G.mapCocone _) _ (by simp [← G.map_comp])).symm
#align category_theory.preserves_desc_map_cocone CategoryTheory.preserves_desc_mapCocone
variable [HasColimit F]
-- TODO: think about swapping the order here
/-- If `G` preserves colimits, we have an isomorphism from the image of the colimit of a functor `F`
to the colimit of the functor `F ⋙ G`.
-/
def preservesColimitIso : G.obj (colimit F) ≅ colimit (F ⋙ G) :=
(PreservesColimit.preserves (colimit.isColimit _)).coconePointUniqueUpToIso (colimit.isColimit _)
#align category_theory.preserves_colimit_iso CategoryTheory.preservesColimitIso
@[reassoc (attr := simp)]
theorem ι_preservesColimitsIso_inv (j : J) :
colimit.ι _ j ≫ (preservesColimitIso G F).inv = G.map (colimit.ι F j) :=
IsColimit.comp_coconePointUniqueUpToIso_inv _ (colimit.isColimit (F ⋙ G)) j
#align category_theory.ι_preserves_colimits_iso_inv CategoryTheory.ι_preservesColimitsIso_inv
@[reassoc (attr := simp)]
theorem ι_preservesColimitsIso_hom (j : J) :
G.map (colimit.ι F j) ≫ (preservesColimitIso G F).hom = colimit.ι (F ⋙ G) j :=
(PreservesColimit.preserves (colimit.isColimit _)).comp_coconePointUniqueUpToIso_hom _ j
#align category_theory.ι_preserves_colimits_iso_hom CategoryTheory.ι_preservesColimitsIso_hom
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Preserves/Limits.lean | 142 | 146 | theorem preservesColimitsIso_inv_comp_desc (t : Cocone F) :
(preservesColimitIso G F).inv ≫ G.map (colimit.desc _ t) =
colimit.desc _ (G.mapCocone t) := by |
ext
simp [← G.map_comp]
|
/-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.RingHomProperties
import Mathlib.RingTheory.IntegralClosure
#align_import ring_theory.ring_hom.integral from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
/-!
# The meta properties of integral ring homomorphisms.
-/
namespace RingHom
open scoped TensorProduct
open TensorProduct Algebra.TensorProduct
| Mathlib/RingTheory/RingHom/Integral.lean | 24 | 25 | theorem isIntegral_stableUnderComposition : StableUnderComposition fun f => f.IsIntegral := by |
introv R hf hg; exact hf.trans _ _ hg
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.Module.Equiv
import Mathlib.Algebra.Module.Submodule.Basic
import Mathlib.Algebra.PUnitInstances
import Mathlib.Data.Set.Subsingleton
#align_import algebra.module.submodule.lattice from "leanprover-community/mathlib"@"f7fc89d5d5ff1db2d1242c7bb0e9062ce47ef47c"
/-!
# The lattice structure on `Submodule`s
This file defines the lattice structure on submodules, `Submodule.CompleteLattice`, with `⊥`
defined as `{0}` and `⊓` defined as intersection of the underlying carrier.
If `p` and `q` are submodules of a module, `p ≤ q` means that `p ⊆ q`.
Many results about operations on this lattice structure are defined in `LinearAlgebra/Basic.lean`,
most notably those which use `span`.
## Implementation notes
This structure should match the `AddSubmonoid.CompleteLattice` structure, and we should try
to unify the APIs where possible.
-/
universe v
variable {R S M : Type*}
section AddCommMonoid
variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M] [Module S M]
variable [SMul S R] [IsScalarTower S R M]
variable {p q : Submodule R M}
namespace Submodule
/-!
## Bottom element of a submodule
-/
/-- The set `{0}` is the bottom element of the lattice of submodules. -/
instance : Bot (Submodule R M) :=
⟨{ (⊥ : AddSubmonoid M) with
carrier := {0}
smul_mem' := by simp }⟩
instance inhabited' : Inhabited (Submodule R M) :=
⟨⊥⟩
#align submodule.inhabited' Submodule.inhabited'
@[simp]
theorem bot_coe : ((⊥ : Submodule R M) : Set M) = {0} :=
rfl
#align submodule.bot_coe Submodule.bot_coe
@[simp]
theorem bot_toAddSubmonoid : (⊥ : Submodule R M).toAddSubmonoid = ⊥ :=
rfl
#align submodule.bot_to_add_submonoid Submodule.bot_toAddSubmonoid
@[simp]
lemma bot_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] :
(⊥ : Submodule R M).toAddSubgroup = ⊥ := rfl
variable (R) in
@[simp]
theorem mem_bot {x : M} : x ∈ (⊥ : Submodule R M) ↔ x = 0 :=
Set.mem_singleton_iff
#align submodule.mem_bot Submodule.mem_bot
instance uniqueBot : Unique (⊥ : Submodule R M) :=
⟨inferInstance, fun x ↦ Subtype.ext <| (mem_bot R).1 x.mem⟩
#align submodule.unique_bot Submodule.uniqueBot
instance : OrderBot (Submodule R M) where
bot := ⊥
bot_le p x := by simp (config := { contextual := true }) [zero_mem]
protected theorem eq_bot_iff (p : Submodule R M) : p = ⊥ ↔ ∀ x ∈ p, x = (0 : M) :=
⟨fun h ↦ h.symm ▸ fun _ hx ↦ (mem_bot R).mp hx,
fun h ↦ eq_bot_iff.mpr fun x hx ↦ (mem_bot R).mpr (h x hx)⟩
#align submodule.eq_bot_iff Submodule.eq_bot_iff
@[ext high]
protected theorem bot_ext (x y : (⊥ : Submodule R M)) : x = y := by
rcases x with ⟨x, xm⟩; rcases y with ⟨y, ym⟩; congr
rw [(Submodule.eq_bot_iff _).mp rfl x xm]
rw [(Submodule.eq_bot_iff _).mp rfl y ym]
#align submodule.bot_ext Submodule.bot_ext
protected theorem ne_bot_iff (p : Submodule R M) : p ≠ ⊥ ↔ ∃ x ∈ p, x ≠ (0 : M) := by
simp only [ne_eq, p.eq_bot_iff, not_forall, exists_prop]
#align submodule.ne_bot_iff Submodule.ne_bot_iff
theorem nonzero_mem_of_bot_lt {p : Submodule R M} (bot_lt : ⊥ < p) : ∃ a : p, a ≠ 0 :=
let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp bot_lt.ne'
⟨⟨b, hb₁⟩, hb₂ ∘ congr_arg Subtype.val⟩
#align submodule.nonzero_mem_of_bot_lt Submodule.nonzero_mem_of_bot_lt
theorem exists_mem_ne_zero_of_ne_bot {p : Submodule R M} (h : p ≠ ⊥) : ∃ b : M, b ∈ p ∧ b ≠ 0 :=
let ⟨b, hb₁, hb₂⟩ := p.ne_bot_iff.mp h
⟨b, hb₁, hb₂⟩
#align submodule.exists_mem_ne_zero_of_ne_bot Submodule.exists_mem_ne_zero_of_ne_bot
-- FIXME: we default PUnit to PUnit.{1} here without the explicit universe annotation
/-- The bottom submodule is linearly equivalent to punit as an `R`-module. -/
@[simps]
def botEquivPUnit : (⊥ : Submodule R M) ≃ₗ[R] PUnit.{v+1} where
toFun _ := PUnit.unit
invFun _ := 0
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv _ := Subsingleton.elim _ _
right_inv _ := rfl
#align submodule.bot_equiv_punit Submodule.botEquivPUnit
theorem subsingleton_iff_eq_bot : Subsingleton p ↔ p = ⊥ := by
rw [subsingleton_iff, Submodule.eq_bot_iff]
refine ⟨fun h x hx ↦ by simpa using h ⟨x, hx⟩ ⟨0, p.zero_mem⟩,
fun h ⟨x, hx⟩ ⟨y, hy⟩ ↦ by simp [h x hx, h y hy]⟩
theorem eq_bot_of_subsingleton [Subsingleton p] : p = ⊥ :=
subsingleton_iff_eq_bot.mp inferInstance
#align submodule.eq_bot_of_subsingleton Submodule.eq_bot_of_subsingleton
theorem nontrivial_iff_ne_bot : Nontrivial p ↔ p ≠ ⊥ := by
rw [iff_not_comm, not_nontrivial_iff_subsingleton, subsingleton_iff_eq_bot]
/-!
## Top element of a submodule
-/
/-- The universal set is the top element of the lattice of submodules. -/
instance : Top (Submodule R M) :=
⟨{ (⊤ : AddSubmonoid M) with
carrier := Set.univ
smul_mem' := fun _ _ _ ↦ trivial }⟩
@[simp]
theorem top_coe : ((⊤ : Submodule R M) : Set M) = Set.univ :=
rfl
#align submodule.top_coe Submodule.top_coe
@[simp]
theorem top_toAddSubmonoid : (⊤ : Submodule R M).toAddSubmonoid = ⊤ :=
rfl
#align submodule.top_to_add_submonoid Submodule.top_toAddSubmonoid
@[simp]
lemma top_toAddSubgroup {R M} [Ring R] [AddCommGroup M] [Module R M] :
(⊤ : Submodule R M).toAddSubgroup = ⊤ := rfl
@[simp]
theorem mem_top {x : M} : x ∈ (⊤ : Submodule R M) :=
trivial
#align submodule.mem_top Submodule.mem_top
instance : OrderTop (Submodule R M) where
top := ⊤
le_top _ _ _ := trivial
theorem eq_top_iff' {p : Submodule R M} : p = ⊤ ↔ ∀ x, x ∈ p :=
eq_top_iff.trans ⟨fun h _ ↦ h trivial, fun h x _ ↦ h x⟩
#align submodule.eq_top_iff' Submodule.eq_top_iff'
/-- The top submodule is linearly equivalent to the module.
This is the module version of `AddSubmonoid.topEquiv`. -/
@[simps]
def topEquiv : (⊤ : Submodule R M) ≃ₗ[R] M where
toFun x := x
invFun x := ⟨x, mem_top⟩
map_add' _ _ := rfl
map_smul' _ _ := rfl
left_inv _ := rfl
right_inv _ := rfl
#align submodule.top_equiv Submodule.topEquiv
/-!
## Infima & suprema in a submodule
-/
instance : InfSet (Submodule R M) :=
⟨fun S ↦
{ carrier := ⋂ s ∈ S, (s : Set M)
zero_mem' := by simp [zero_mem]
add_mem' := by simp (config := { contextual := true }) [add_mem]
smul_mem' := by simp (config := { contextual := true }) [smul_mem] }⟩
private theorem sInf_le' {S : Set (Submodule R M)} {p} : p ∈ S → sInf S ≤ p :=
Set.biInter_subset_of_mem
private theorem le_sInf' {S : Set (Submodule R M)} {p} : (∀ q ∈ S, p ≤ q) → p ≤ sInf S :=
Set.subset_iInter₂
instance : Inf (Submodule R M) :=
⟨fun p q ↦
{ carrier := p ∩ q
zero_mem' := by simp [zero_mem]
add_mem' := by simp (config := { contextual := true }) [add_mem]
smul_mem' := by simp (config := { contextual := true }) [smul_mem] }⟩
instance completeLattice : CompleteLattice (Submodule R M) :=
{ (inferInstance : OrderTop (Submodule R M)),
(inferInstance : OrderBot (Submodule R M)) with
sup := fun a b ↦ sInf { x | a ≤ x ∧ b ≤ x }
le_sup_left := fun _ _ ↦ le_sInf' fun _ ⟨h, _⟩ ↦ h
le_sup_right := fun _ _ ↦ le_sInf' fun _ ⟨_, h⟩ ↦ h
sup_le := fun _ _ _ h₁ h₂ ↦ sInf_le' ⟨h₁, h₂⟩
inf := (· ⊓ ·)
le_inf := fun _ _ _ ↦ Set.subset_inter
inf_le_left := fun _ _ ↦ Set.inter_subset_left
inf_le_right := fun _ _ ↦ Set.inter_subset_right
le_sSup := fun _ _ hs ↦ le_sInf' fun _ hq ↦ by exact hq _ hs
sSup_le := fun _ _ hs ↦ sInf_le' hs
le_sInf := fun _ _ ↦ le_sInf'
sInf_le := fun _ _ ↦ sInf_le' }
#align submodule.complete_lattice Submodule.completeLattice
@[simp]
theorem inf_coe : ↑(p ⊓ q) = (p ∩ q : Set M) :=
rfl
#align submodule.inf_coe Submodule.inf_coe
@[simp]
theorem mem_inf {p q : Submodule R M} {x : M} : x ∈ p ⊓ q ↔ x ∈ p ∧ x ∈ q :=
Iff.rfl
#align submodule.mem_inf Submodule.mem_inf
@[simp]
theorem sInf_coe (P : Set (Submodule R M)) : (↑(sInf P) : Set M) = ⋂ p ∈ P, ↑p :=
rfl
#align submodule.Inf_coe Submodule.sInf_coe
@[simp]
theorem finset_inf_coe {ι} (s : Finset ι) (p : ι → Submodule R M) :
(↑(s.inf p) : Set M) = ⋂ i ∈ s, ↑(p i) := by
letI := Classical.decEq ι
refine s.induction_on ?_ fun i s _ ih ↦ ?_
· simp
· rw [Finset.inf_insert, inf_coe, ih]
simp
#align submodule.finset_inf_coe Submodule.finset_inf_coe
@[simp]
theorem iInf_coe {ι} (p : ι → Submodule R M) : (↑(⨅ i, p i) : Set M) = ⋂ i, ↑(p i) := by
rw [iInf, sInf_coe]; simp only [Set.mem_range, Set.iInter_exists, Set.iInter_iInter_eq']
#align submodule.infi_coe Submodule.iInf_coe
@[simp]
theorem mem_sInf {S : Set (Submodule R M)} {x : M} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=
Set.mem_iInter₂
#align submodule.mem_Inf Submodule.mem_sInf
@[simp]
theorem mem_iInf {ι} (p : ι → Submodule R M) {x} : (x ∈ ⨅ i, p i) ↔ ∀ i, x ∈ p i := by
rw [← SetLike.mem_coe, iInf_coe, Set.mem_iInter]; rfl
#align submodule.mem_infi Submodule.mem_iInf
@[simp]
theorem mem_finset_inf {ι} {s : Finset ι} {p : ι → Submodule R M} {x : M} :
x ∈ s.inf p ↔ ∀ i ∈ s, x ∈ p i := by
simp only [← SetLike.mem_coe, finset_inf_coe, Set.mem_iInter]
#align submodule.mem_finset_inf Submodule.mem_finset_inf
theorem mem_sup_left {S T : Submodule R M} : ∀ {x : M}, x ∈ S → x ∈ S ⊔ T := by
have : S ≤ S ⊔ T := le_sup_left
rw [LE.le] at this
exact this
#align submodule.mem_sup_left Submodule.mem_sup_left
theorem mem_sup_right {S T : Submodule R M} : ∀ {x : M}, x ∈ T → x ∈ S ⊔ T := by
have : T ≤ S ⊔ T := le_sup_right
rw [LE.le] at this
exact this
#align submodule.mem_sup_right Submodule.mem_sup_right
theorem add_mem_sup {S T : Submodule R M} {s t : M} (hs : s ∈ S) (ht : t ∈ T) : s + t ∈ S ⊔ T :=
add_mem (mem_sup_left hs) (mem_sup_right ht)
#align submodule.add_mem_sup Submodule.add_mem_sup
theorem sub_mem_sup {R' M' : Type*} [Ring R'] [AddCommGroup M'] [Module R' M']
{S T : Submodule R' M'} {s t : M'} (hs : s ∈ S) (ht : t ∈ T) : s - t ∈ S ⊔ T := by
rw [sub_eq_add_neg]
exact add_mem_sup hs (neg_mem ht)
#align submodule.sub_mem_sup Submodule.sub_mem_sup
theorem mem_iSup_of_mem {ι : Sort*} {b : M} {p : ι → Submodule R M} (i : ι) (h : b ∈ p i) :
b ∈ ⨆ i, p i :=
(le_iSup p i) h
#align submodule.mem_supr_of_mem Submodule.mem_iSup_of_mem
theorem sum_mem_iSup {ι : Type*} [Fintype ι] {f : ι → M} {p : ι → Submodule R M}
(h : ∀ i, f i ∈ p i) : (∑ i, f i) ∈ ⨆ i, p i :=
sum_mem fun i _ ↦ mem_iSup_of_mem i (h i)
#align submodule.sum_mem_supr Submodule.sum_mem_iSup
theorem sum_mem_biSup {ι : Type*} {s : Finset ι} {f : ι → M} {p : ι → Submodule R M}
(h : ∀ i ∈ s, f i ∈ p i) : (∑ i ∈ s, f i) ∈ ⨆ i ∈ s, p i :=
sum_mem fun i hi ↦ mem_iSup_of_mem i <| mem_iSup_of_mem hi (h i hi)
#align submodule.sum_mem_bsupr Submodule.sum_mem_biSup
/-! Note that `Submodule.mem_iSup` is provided in `Mathlib/LinearAlgebra/Span.lean`. -/
theorem mem_sSup_of_mem {S : Set (Submodule R M)} {s : Submodule R M} (hs : s ∈ S) :
∀ {x : M}, x ∈ s → x ∈ sSup S := by
have := le_sSup hs
rw [LE.le] at this
exact this
#align submodule.mem_Sup_of_mem Submodule.mem_sSup_of_mem
@[simp]
theorem toAddSubmonoid_sSup (s : Set (Submodule R M)) :
(sSup s).toAddSubmonoid = sSup (toAddSubmonoid '' s) := by
let p : Submodule R M :=
{ toAddSubmonoid := sSup (toAddSubmonoid '' s)
smul_mem' := fun t {m} h ↦ by
simp_rw [AddSubsemigroup.mem_carrier, AddSubmonoid.mem_toSubsemigroup, sSup_eq_iSup'] at h ⊢
refine AddSubmonoid.iSup_induction'
(C := fun x _ ↦ t • x ∈ ⨆ p : toAddSubmonoid '' s, (p : AddSubmonoid M)) ?_ ?_
(fun x y _ _ ↦ ?_) h
· rintro ⟨-, ⟨p : Submodule R M, hp : p ∈ s, rfl⟩⟩ x (hx : x ∈ p)
suffices p.toAddSubmonoid ≤ ⨆ q : toAddSubmonoid '' s, (q : AddSubmonoid M) by
exact this (smul_mem p t hx)
apply le_sSup
rw [Subtype.range_coe_subtype]
exact ⟨p, hp, rfl⟩
· simpa only [smul_zero] using zero_mem _
· simp_rw [smul_add]; exact add_mem }
refine le_antisymm (?_ : sSup s ≤ p) ?_
· exact sSup_le fun q hq ↦ le_sSup <| Set.mem_image_of_mem toAddSubmonoid hq
· exact sSup_le fun _ ⟨q, hq, hq'⟩ ↦ hq'.symm ▸ le_sSup hq
variable (R)
@[simp]
| Mathlib/Algebra/Module/Submodule/Lattice.lean | 343 | 347 | theorem subsingleton_iff : Subsingleton (Submodule R M) ↔ Subsingleton M :=
have h : Subsingleton (Submodule R M) ↔ Subsingleton (AddSubmonoid M) := by |
rw [← subsingleton_iff_bot_eq_top, ← subsingleton_iff_bot_eq_top, ← toAddSubmonoid_eq,
bot_toAddSubmonoid, top_toAddSubmonoid]
h.trans AddSubmonoid.subsingleton_iff
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes Hölzl
-/
import Mathlib.Dynamics.Ergodic.MeasurePreserving
import Mathlib.MeasureTheory.Function.SimpleFunc
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.MeasureTheory.Measure.Count
import Mathlib.Topology.IndicatorConstPointwise
import Mathlib.MeasureTheory.Constructions.BorelSpace.Real
#align_import measure_theory.integral.lebesgue from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
/-!
# Lower Lebesgue integral for `ℝ≥0∞`-valued functions
We define the lower Lebesgue integral of an `ℝ≥0∞`-valued function.
## Notation
We introduce the following notation for the lower Lebesgue integral of a function `f : α → ℝ≥0∞`.
* `∫⁻ x, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` with respect to a measure `μ`;
* `∫⁻ x, f x`: integral of a function `f : α → ℝ≥0∞` with respect to the canonical measure
`volume` on `α`;
* `∫⁻ x in s, f x ∂μ`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect
to a measure `μ`, defined as `∫⁻ x, f x ∂(μ.restrict s)`;
* `∫⁻ x in s, f x`: integral of a function `f : α → ℝ≥0∞` over a set `s` with respect
to the canonical measure `volume`, defined as `∫⁻ x, f x ∂(volume.restrict s)`.
-/
assert_not_exists NormedSpace
set_option autoImplicit true
noncomputable section
open Set hiding restrict restrict_apply
open Filter ENNReal
open Function (support)
open scoped Classical
open Topology NNReal ENNReal MeasureTheory
namespace MeasureTheory
local infixr:25 " →ₛ " => SimpleFunc
variable {α β γ δ : Type*}
section Lintegral
open SimpleFunc
variable {m : MeasurableSpace α} {μ ν : Measure α}
/-- The **lower Lebesgue integral** of a function `f` with respect to a measure `μ`. -/
irreducible_def lintegral {_ : MeasurableSpace α} (μ : Measure α) (f : α → ℝ≥0∞) : ℝ≥0∞ :=
⨆ (g : α →ₛ ℝ≥0∞) (_ : ⇑g ≤ f), g.lintegral μ
#align measure_theory.lintegral MeasureTheory.lintegral
/-! In the notation for integrals, an expression like `∫⁻ x, g ‖x‖ ∂μ` will not be parsed correctly,
and needs parentheses. We do not set the binding power of `r` to `0`, because then
`∫⁻ x, f x = 0` will be parsed incorrectly. -/
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => f)" ∂"μ:70 => lintegral μ r
@[inherit_doc MeasureTheory.lintegral]
notation3 "∫⁻ "(...)", "r:60:(scoped f => lintegral volume f) => r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => f)" ∂"μ:70 => lintegral (Measure.restrict μ s) r
@[inherit_doc MeasureTheory.lintegral]
notation3"∫⁻ "(...)" in "s", "r:60:(scoped f => lintegral (Measure.restrict volume s) f) => r
theorem SimpleFunc.lintegral_eq_lintegral {m : MeasurableSpace α} (f : α →ₛ ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ = f.lintegral μ := by
rw [MeasureTheory.lintegral]
exact le_antisymm (iSup₂_le fun g hg => lintegral_mono hg <| le_rfl)
(le_iSup₂_of_le f le_rfl le_rfl)
#align measure_theory.simple_func.lintegral_eq_lintegral MeasureTheory.SimpleFunc.lintegral_eq_lintegral
@[mono]
theorem lintegral_mono' {m : MeasurableSpace α} ⦃μ ν : Measure α⦄ (hμν : μ ≤ ν) ⦃f g : α → ℝ≥0∞⦄
(hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂ν := by
rw [lintegral, lintegral]
exact iSup_mono fun φ => iSup_mono' fun hφ => ⟨le_trans hφ hfg, lintegral_mono (le_refl φ) hμν⟩
#align measure_theory.lintegral_mono' MeasureTheory.lintegral_mono'
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn' ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) (h2 : μ ≤ ν) :
lintegral μ f ≤ lintegral ν g :=
lintegral_mono' h2 hfg
theorem lintegral_mono ⦃f g : α → ℝ≥0∞⦄ (hfg : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono' (le_refl μ) hfg
#align measure_theory.lintegral_mono MeasureTheory.lintegral_mono
-- workaround for the known eta-reduction issue with `@[gcongr]`
@[gcongr] theorem lintegral_mono_fn ⦃f g : α → ℝ≥0∞⦄ (hfg : ∀ x, f x ≤ g x) :
lintegral μ f ≤ lintegral μ g :=
lintegral_mono hfg
theorem lintegral_mono_nnreal {f g : α → ℝ≥0} (h : f ≤ g) : ∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ :=
lintegral_mono fun a => ENNReal.coe_le_coe.2 (h a)
#align measure_theory.lintegral_mono_nnreal MeasureTheory.lintegral_mono_nnreal
theorem iSup_lintegral_measurable_le_eq_lintegral (f : α → ℝ≥0∞) :
⨆ (g : α → ℝ≥0∞) (_ : Measurable g) (_ : g ≤ f), ∫⁻ a, g a ∂μ = ∫⁻ a, f a ∂μ := by
apply le_antisymm
· exact iSup_le fun i => iSup_le fun _ => iSup_le fun h'i => lintegral_mono h'i
· rw [lintegral]
refine iSup₂_le fun i hi => le_iSup₂_of_le i i.measurable <| le_iSup_of_le hi ?_
exact le_of_eq (i.lintegral_eq_lintegral _).symm
#align measure_theory.supr_lintegral_measurable_le_eq_lintegral MeasureTheory.iSup_lintegral_measurable_le_eq_lintegral
theorem lintegral_mono_set {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ⊆ t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set MeasureTheory.lintegral_mono_set
theorem lintegral_mono_set' {_ : MeasurableSpace α} ⦃μ : Measure α⦄ {s t : Set α} {f : α → ℝ≥0∞}
(hst : s ≤ᵐ[μ] t) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in t, f x ∂μ :=
lintegral_mono' (Measure.restrict_mono' hst (le_refl μ)) (le_refl f)
#align measure_theory.lintegral_mono_set' MeasureTheory.lintegral_mono_set'
theorem monotone_lintegral {_ : MeasurableSpace α} (μ : Measure α) : Monotone (lintegral μ) :=
lintegral_mono
#align measure_theory.monotone_lintegral MeasureTheory.monotone_lintegral
@[simp]
theorem lintegral_const (c : ℝ≥0∞) : ∫⁻ _, c ∂μ = c * μ univ := by
rw [← SimpleFunc.const_lintegral, ← SimpleFunc.lintegral_eq_lintegral, SimpleFunc.coe_const]
rfl
#align measure_theory.lintegral_const MeasureTheory.lintegral_const
theorem lintegral_zero : ∫⁻ _ : α, 0 ∂μ = 0 := by simp
#align measure_theory.lintegral_zero MeasureTheory.lintegral_zero
theorem lintegral_zero_fun : lintegral μ (0 : α → ℝ≥0∞) = 0 :=
lintegral_zero
#align measure_theory.lintegral_zero_fun MeasureTheory.lintegral_zero_fun
-- @[simp] -- Porting note (#10618): simp can prove this
theorem lintegral_one : ∫⁻ _, (1 : ℝ≥0∞) ∂μ = μ univ := by rw [lintegral_const, one_mul]
#align measure_theory.lintegral_one MeasureTheory.lintegral_one
theorem set_lintegral_const (s : Set α) (c : ℝ≥0∞) : ∫⁻ _ in s, c ∂μ = c * μ s := by
rw [lintegral_const, Measure.restrict_apply_univ]
#align measure_theory.set_lintegral_const MeasureTheory.set_lintegral_const
theorem set_lintegral_one (s) : ∫⁻ _ in s, 1 ∂μ = μ s := by rw [set_lintegral_const, one_mul]
#align measure_theory.set_lintegral_one MeasureTheory.set_lintegral_one
theorem set_lintegral_const_lt_top [IsFiniteMeasure μ] (s : Set α) {c : ℝ≥0∞} (hc : c ≠ ∞) :
∫⁻ _ in s, c ∂μ < ∞ := by
rw [lintegral_const]
exact ENNReal.mul_lt_top hc (measure_ne_top (μ.restrict s) univ)
#align measure_theory.set_lintegral_const_lt_top MeasureTheory.set_lintegral_const_lt_top
theorem lintegral_const_lt_top [IsFiniteMeasure μ] {c : ℝ≥0∞} (hc : c ≠ ∞) : ∫⁻ _, c ∂μ < ∞ := by
simpa only [Measure.restrict_univ] using set_lintegral_const_lt_top (univ : Set α) hc
#align measure_theory.lintegral_const_lt_top MeasureTheory.lintegral_const_lt_top
section
variable (μ)
/-- For any function `f : α → ℝ≥0∞`, there exists a measurable function `g ≤ f` with the same
integral. -/
theorem exists_measurable_le_lintegral_eq (f : α → ℝ≥0∞) :
∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
rcases eq_or_ne (∫⁻ a, f a ∂μ) 0 with h₀ | h₀
· exact ⟨0, measurable_zero, zero_le f, h₀.trans lintegral_zero.symm⟩
rcases exists_seq_strictMono_tendsto' h₀.bot_lt with ⟨L, _, hLf, hL_tendsto⟩
have : ∀ n, ∃ g : α → ℝ≥0∞, Measurable g ∧ g ≤ f ∧ L n < ∫⁻ a, g a ∂μ := by
intro n
simpa only [← iSup_lintegral_measurable_le_eq_lintegral f, lt_iSup_iff, exists_prop] using
(hLf n).2
choose g hgm hgf hLg using this
refine
⟨fun x => ⨆ n, g n x, measurable_iSup hgm, fun x => iSup_le fun n => hgf n x, le_antisymm ?_ ?_⟩
· refine le_of_tendsto' hL_tendsto fun n => (hLg n).le.trans <| lintegral_mono fun x => ?_
exact le_iSup (fun n => g n x) n
· exact lintegral_mono fun x => iSup_le fun n => hgf n x
#align measure_theory.exists_measurable_le_lintegral_eq MeasureTheory.exists_measurable_le_lintegral_eq
end
/-- `∫⁻ a in s, f a ∂μ` is defined as the supremum of integrals of simple functions
`φ : α →ₛ ℝ≥0∞` such that `φ ≤ f`. This lemma says that it suffices to take
functions `φ : α →ₛ ℝ≥0`. -/
theorem lintegral_eq_nnreal {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : Measure α) :
∫⁻ a, f a ∂μ =
⨆ (φ : α →ₛ ℝ≥0) (_ : ∀ x, ↑(φ x) ≤ f x), (φ.map ((↑) : ℝ≥0 → ℝ≥0∞)).lintegral μ := by
rw [lintegral]
refine
le_antisymm (iSup₂_le fun φ hφ => ?_) (iSup_mono' fun φ => ⟨φ.map ((↑) : ℝ≥0 → ℝ≥0∞), le_rfl⟩)
by_cases h : ∀ᵐ a ∂μ, φ a ≠ ∞
· let ψ := φ.map ENNReal.toNNReal
replace h : ψ.map ((↑) : ℝ≥0 → ℝ≥0∞) =ᵐ[μ] φ := h.mono fun a => ENNReal.coe_toNNReal
have : ∀ x, ↑(ψ x) ≤ f x := fun x => le_trans ENNReal.coe_toNNReal_le_self (hφ x)
exact
le_iSup_of_le (φ.map ENNReal.toNNReal) (le_iSup_of_le this (ge_of_eq <| lintegral_congr h))
· have h_meas : μ (φ ⁻¹' {∞}) ≠ 0 := mt measure_zero_iff_ae_nmem.1 h
refine le_trans le_top (ge_of_eq <| (iSup_eq_top _).2 fun b hb => ?_)
obtain ⟨n, hn⟩ : ∃ n : ℕ, b < n * μ (φ ⁻¹' {∞}) := exists_nat_mul_gt h_meas (ne_of_lt hb)
use (const α (n : ℝ≥0)).restrict (φ ⁻¹' {∞})
simp only [lt_iSup_iff, exists_prop, coe_restrict, φ.measurableSet_preimage, coe_const,
ENNReal.coe_indicator, map_coe_ennreal_restrict, SimpleFunc.map_const, ENNReal.coe_natCast,
restrict_const_lintegral]
refine ⟨indicator_le fun x hx => le_trans ?_ (hφ _), hn⟩
simp only [mem_preimage, mem_singleton_iff] at hx
simp only [hx, le_top]
#align measure_theory.lintegral_eq_nnreal MeasureTheory.lintegral_eq_nnreal
theorem exists_simpleFunc_forall_lintegral_sub_lt_of_pos {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞)
{ε : ℝ≥0∞} (hε : ε ≠ 0) :
∃ φ : α →ₛ ℝ≥0,
(∀ x, ↑(φ x) ≤ f x) ∧
∀ ψ : α →ₛ ℝ≥0, (∀ x, ↑(ψ x) ≤ f x) → (map (↑) (ψ - φ)).lintegral μ < ε := by
rw [lintegral_eq_nnreal] at h
have := ENNReal.lt_add_right h hε
erw [ENNReal.biSup_add] at this <;> [skip; exact ⟨0, fun x => zero_le _⟩]
simp_rw [lt_iSup_iff, iSup_lt_iff, iSup_le_iff] at this
rcases this with ⟨φ, hle : ∀ x, ↑(φ x) ≤ f x, b, hbφ, hb⟩
refine ⟨φ, hle, fun ψ hψ => ?_⟩
have : (map (↑) φ).lintegral μ ≠ ∞ := ne_top_of_le_ne_top h (by exact le_iSup₂ (α := ℝ≥0∞) φ hle)
rw [← ENNReal.add_lt_add_iff_left this, ← add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine (hb _ fun x => le_trans ?_ (max_le (hle x) (hψ x))).trans_lt hbφ
norm_cast
simp only [add_apply, sub_apply, add_tsub_eq_max]
rfl
#align measure_theory.exists_simple_func_forall_lintegral_sub_lt_of_pos MeasureTheory.exists_simpleFunc_forall_lintegral_sub_lt_of_pos
theorem iSup_lintegral_le {ι : Sort*} (f : ι → α → ℝ≥0∞) :
⨆ i, ∫⁻ a, f i a ∂μ ≤ ∫⁻ a, ⨆ i, f i a ∂μ := by
simp only [← iSup_apply]
exact (monotone_lintegral μ).le_map_iSup
#align measure_theory.supr_lintegral_le MeasureTheory.iSup_lintegral_le
theorem iSup₂_lintegral_le {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
⨆ (i) (j), ∫⁻ a, f i j a ∂μ ≤ ∫⁻ a, ⨆ (i) (j), f i j a ∂μ := by
convert (monotone_lintegral μ).le_map_iSup₂ f with a
simp only [iSup_apply]
#align measure_theory.supr₂_lintegral_le MeasureTheory.iSup₂_lintegral_le
theorem le_iInf_lintegral {ι : Sort*} (f : ι → α → ℝ≥0∞) :
∫⁻ a, ⨅ i, f i a ∂μ ≤ ⨅ i, ∫⁻ a, f i a ∂μ := by
simp only [← iInf_apply]
exact (monotone_lintegral μ).map_iInf_le
#align measure_theory.le_infi_lintegral MeasureTheory.le_iInf_lintegral
theorem le_iInf₂_lintegral {ι : Sort*} {ι' : ι → Sort*} (f : ∀ i, ι' i → α → ℝ≥0∞) :
∫⁻ a, ⨅ (i) (h : ι' i), f i h a ∂μ ≤ ⨅ (i) (h : ι' i), ∫⁻ a, f i h a ∂μ := by
convert (monotone_lintegral μ).map_iInf₂_le f with a
simp only [iInf_apply]
#align measure_theory.le_infi₂_lintegral MeasureTheory.le_iInf₂_lintegral
theorem lintegral_mono_ae {f g : α → ℝ≥0∞} (h : ∀ᵐ a ∂μ, f a ≤ g a) :
∫⁻ a, f a ∂μ ≤ ∫⁻ a, g a ∂μ := by
rcases exists_measurable_superset_of_null h with ⟨t, hts, ht, ht0⟩
have : ∀ᵐ x ∂μ, x ∉ t := measure_zero_iff_ae_nmem.1 ht0
rw [lintegral, lintegral]
refine iSup_le fun s => iSup_le fun hfs => le_iSup_of_le (s.restrict tᶜ) <| le_iSup_of_le ?_ ?_
· intro a
by_cases h : a ∈ t <;>
simp only [restrict_apply s ht.compl, mem_compl_iff, h, not_true, not_false_eq_true,
indicator_of_not_mem, zero_le, not_false_eq_true, indicator_of_mem]
exact le_trans (hfs a) (_root_.by_contradiction fun hnfg => h (hts hnfg))
· refine le_of_eq (SimpleFunc.lintegral_congr <| this.mono fun a hnt => ?_)
by_cases hat : a ∈ t <;> simp only [restrict_apply s ht.compl, mem_compl_iff, hat, not_true,
not_false_eq_true, indicator_of_not_mem, not_false_eq_true, indicator_of_mem]
exact (hnt hat).elim
#align measure_theory.lintegral_mono_ae MeasureTheory.lintegral_mono_ae
theorem set_lintegral_mono_ae {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff <| measurableSet_le hf hg).2 hfg
#align measure_theory.set_lintegral_mono_ae MeasureTheory.set_lintegral_mono_ae
theorem set_lintegral_mono {s : Set α} {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae hf hg (ae_of_all _ hfg)
#align measure_theory.set_lintegral_mono MeasureTheory.set_lintegral_mono
theorem set_lintegral_mono_ae' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
lintegral_mono_ae <| (ae_restrict_iff' hs).2 hfg
theorem set_lintegral_mono' {s : Set α} {f g : α → ℝ≥0∞} (hs : MeasurableSet s)
(hfg : ∀ x ∈ s, f x ≤ g x) : ∫⁻ x in s, f x ∂μ ≤ ∫⁻ x in s, g x ∂μ :=
set_lintegral_mono_ae' hs (ae_of_all _ hfg)
theorem set_lintegral_le_lintegral (s : Set α) (f : α → ℝ≥0∞) :
∫⁻ x in s, f x ∂μ ≤ ∫⁻ x, f x ∂μ :=
lintegral_mono' Measure.restrict_le_self le_rfl
theorem lintegral_congr_ae {f g : α → ℝ≥0∞} (h : f =ᵐ[μ] g) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ :=
le_antisymm (lintegral_mono_ae <| h.le) (lintegral_mono_ae <| h.symm.le)
#align measure_theory.lintegral_congr_ae MeasureTheory.lintegral_congr_ae
theorem lintegral_congr {f g : α → ℝ≥0∞} (h : ∀ a, f a = g a) : ∫⁻ a, f a ∂μ = ∫⁻ a, g a ∂μ := by
simp only [h]
#align measure_theory.lintegral_congr MeasureTheory.lintegral_congr
theorem set_lintegral_congr {f : α → ℝ≥0∞} {s t : Set α} (h : s =ᵐ[μ] t) :
∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ := by rw [Measure.restrict_congr_set h]
#align measure_theory.set_lintegral_congr MeasureTheory.set_lintegral_congr
theorem set_lintegral_congr_fun {f g : α → ℝ≥0∞} {s : Set α} (hs : MeasurableSet s)
(hfg : ∀ᵐ x ∂μ, x ∈ s → f x = g x) : ∫⁻ x in s, f x ∂μ = ∫⁻ x in s, g x ∂μ := by
rw [lintegral_congr_ae]
rw [EventuallyEq]
rwa [ae_restrict_iff' hs]
#align measure_theory.set_lintegral_congr_fun MeasureTheory.set_lintegral_congr_fun
theorem lintegral_ofReal_le_lintegral_nnnorm (f : α → ℝ) :
∫⁻ x, ENNReal.ofReal (f x) ∂μ ≤ ∫⁻ x, ‖f x‖₊ ∂μ := by
simp_rw [← ofReal_norm_eq_coe_nnnorm]
refine lintegral_mono fun x => ENNReal.ofReal_le_ofReal ?_
rw [Real.norm_eq_abs]
exact le_abs_self (f x)
#align measure_theory.lintegral_of_real_le_lintegral_nnnorm MeasureTheory.lintegral_ofReal_le_lintegral_nnnorm
theorem lintegral_nnnorm_eq_of_ae_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ᵐ[μ] f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ := by
apply lintegral_congr_ae
filter_upwards [h_nonneg] with x hx
rw [Real.nnnorm_of_nonneg hx, ENNReal.ofReal_eq_coe_nnreal hx]
#align measure_theory.lintegral_nnnorm_eq_of_ae_nonneg MeasureTheory.lintegral_nnnorm_eq_of_ae_nonneg
theorem lintegral_nnnorm_eq_of_nonneg {f : α → ℝ} (h_nonneg : 0 ≤ f) :
∫⁻ x, ‖f x‖₊ ∂μ = ∫⁻ x, ENNReal.ofReal (f x) ∂μ :=
lintegral_nnnorm_eq_of_ae_nonneg (Filter.eventually_of_forall h_nonneg)
#align measure_theory.lintegral_nnnorm_eq_of_nonneg MeasureTheory.lintegral_nnnorm_eq_of_nonneg
/-- **Monotone convergence theorem** -- sometimes called **Beppo-Levi convergence**.
See `lintegral_iSup_directed` for a more general form. -/
theorem lintegral_iSup {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, Measurable (f n)) (h_mono : Monotone f) :
∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
set c : ℝ≥0 → ℝ≥0∞ := (↑)
set F := fun a : α => ⨆ n, f n a
refine le_antisymm ?_ (iSup_lintegral_le _)
rw [lintegral_eq_nnreal]
refine iSup_le fun s => iSup_le fun hsf => ?_
refine ENNReal.le_of_forall_lt_one_mul_le fun a ha => ?_
rcases ENNReal.lt_iff_exists_coe.1 ha with ⟨r, rfl, _⟩
have ha : r < 1 := ENNReal.coe_lt_coe.1 ha
let rs := s.map fun a => r * a
have eq_rs : rs.map c = (const α r : α →ₛ ℝ≥0∞) * map c s := rfl
have eq : ∀ p, rs.map c ⁻¹' {p} = ⋃ n, rs.map c ⁻¹' {p} ∩ { a | p ≤ f n a } := by
intro p
rw [← inter_iUnion]; nth_rw 1 [← inter_univ (map c rs ⁻¹' {p})]
refine Set.ext fun x => and_congr_right fun hx => true_iff_iff.2 ?_
by_cases p_eq : p = 0
· simp [p_eq]
simp only [coe_map, mem_preimage, Function.comp_apply, mem_singleton_iff] at hx
subst hx
have : r * s x ≠ 0 := by rwa [Ne, ← ENNReal.coe_eq_zero]
have : s x ≠ 0 := right_ne_zero_of_mul this
have : (rs.map c) x < ⨆ n : ℕ, f n x := by
refine lt_of_lt_of_le (ENNReal.coe_lt_coe.2 ?_) (hsf x)
suffices r * s x < 1 * s x by simpa
exact mul_lt_mul_of_pos_right ha (pos_iff_ne_zero.2 this)
rcases lt_iSup_iff.1 this with ⟨i, hi⟩
exact mem_iUnion.2 ⟨i, le_of_lt hi⟩
have mono : ∀ r : ℝ≥0∞, Monotone fun n => rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a } := by
intro r i j h
refine inter_subset_inter_right _ ?_
simp_rw [subset_def, mem_setOf]
intro x hx
exact le_trans hx (h_mono h x)
have h_meas : ∀ n, MeasurableSet {a : α | map c rs a ≤ f n a} := fun n =>
measurableSet_le (SimpleFunc.measurable _) (hf n)
calc
(r : ℝ≥0∞) * (s.map c).lintegral μ = ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r}) := by
rw [← const_mul_lintegral, eq_rs, SimpleFunc.lintegral]
_ = ∑ r ∈ (rs.map c).range, r * μ (⋃ n, rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
simp only [(eq _).symm]
_ = ∑ r ∈ (rs.map c).range, ⨆ n, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) :=
(Finset.sum_congr rfl fun x _ => by
rw [measure_iUnion_eq_iSup (mono x).directed_le, ENNReal.mul_iSup])
_ = ⨆ n, ∑ r ∈ (rs.map c).range, r * μ (rs.map c ⁻¹' {r} ∩ { a | r ≤ f n a }) := by
refine ENNReal.finset_sum_iSup_nat fun p i j h ↦ ?_
gcongr _ * μ ?_
exact mono p h
_ ≤ ⨆ n : ℕ, ((rs.map c).restrict { a | (rs.map c) a ≤ f n a }).lintegral μ := by
gcongr with n
rw [restrict_lintegral _ (h_meas n)]
refine le_of_eq (Finset.sum_congr rfl fun r _ => ?_)
congr 2 with a
refine and_congr_right ?_
simp (config := { contextual := true })
_ ≤ ⨆ n, ∫⁻ a, f n a ∂μ := by
simp only [← SimpleFunc.lintegral_eq_lintegral]
gcongr with n a
simp only [map_apply] at h_meas
simp only [coe_map, restrict_apply _ (h_meas _), (· ∘ ·)]
exact indicator_apply_le id
#align measure_theory.lintegral_supr MeasureTheory.lintegral_iSup
/-- Monotone convergence theorem -- sometimes called Beppo-Levi convergence. Version with
ae_measurable functions. -/
theorem lintegral_iSup' {f : ℕ → α → ℝ≥0∞} (hf : ∀ n, AEMeasurable (f n) μ)
(h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x) : ∫⁻ a, ⨆ n, f n a ∂μ = ⨆ n, ∫⁻ a, f n a ∂μ := by
simp_rw [← iSup_apply]
let p : α → (ℕ → ℝ≥0∞) → Prop := fun _ f' => Monotone f'
have hp : ∀ᵐ x ∂μ, p x fun i => f i x := h_mono
have h_ae_seq_mono : Monotone (aeSeq hf p) := by
intro n m hnm x
by_cases hx : x ∈ aeSeqSet hf p
· exact aeSeq.prop_of_mem_aeSeqSet hf hx hnm
· simp only [aeSeq, hx, if_false, le_rfl]
rw [lintegral_congr_ae (aeSeq.iSup hf hp).symm]
simp_rw [iSup_apply]
rw [lintegral_iSup (aeSeq.measurable hf p) h_ae_seq_mono]
congr with n
exact lintegral_congr_ae (aeSeq.aeSeq_n_eq_fun_n_ae hf hp n)
#align measure_theory.lintegral_supr' MeasureTheory.lintegral_iSup'
/-- Monotone convergence theorem expressed with limits -/
theorem lintegral_tendsto_of_tendsto_of_monotone {f : ℕ → α → ℝ≥0∞} {F : α → ℝ≥0∞}
(hf : ∀ n, AEMeasurable (f n) μ) (h_mono : ∀ᵐ x ∂μ, Monotone fun n => f n x)
(h_tendsto : ∀ᵐ x ∂μ, Tendsto (fun n => f n x) atTop (𝓝 <| F x)) :
Tendsto (fun n => ∫⁻ x, f n x ∂μ) atTop (𝓝 <| ∫⁻ x, F x ∂μ) := by
have : Monotone fun n => ∫⁻ x, f n x ∂μ := fun i j hij =>
lintegral_mono_ae (h_mono.mono fun x hx => hx hij)
suffices key : ∫⁻ x, F x ∂μ = ⨆ n, ∫⁻ x, f n x ∂μ by
rw [key]
exact tendsto_atTop_iSup this
rw [← lintegral_iSup' hf h_mono]
refine lintegral_congr_ae ?_
filter_upwards [h_mono, h_tendsto] with _ hx_mono hx_tendsto using
tendsto_nhds_unique hx_tendsto (tendsto_atTop_iSup hx_mono)
#align measure_theory.lintegral_tendsto_of_tendsto_of_monotone MeasureTheory.lintegral_tendsto_of_tendsto_of_monotone
theorem lintegral_eq_iSup_eapprox_lintegral {f : α → ℝ≥0∞} (hf : Measurable f) :
∫⁻ a, f a ∂μ = ⨆ n, (eapprox f n).lintegral μ :=
calc
∫⁻ a, f a ∂μ = ∫⁻ a, ⨆ n, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
congr; ext a; rw [iSup_eapprox_apply f hf]
_ = ⨆ n, ∫⁻ a, (eapprox f n : α → ℝ≥0∞) a ∂μ := by
apply lintegral_iSup
· measurability
· intro i j h
exact monotone_eapprox f h
_ = ⨆ n, (eapprox f n).lintegral μ := by
congr; ext n; rw [(eapprox f n).lintegral_eq_lintegral]
#align measure_theory.lintegral_eq_supr_eapprox_lintegral MeasureTheory.lintegral_eq_iSup_eapprox_lintegral
/-- If `f` has finite integral, then `∫⁻ x in s, f x ∂μ` is absolutely continuous in `s`: it tends
to zero as `μ s` tends to zero. This lemma states this fact in terms of `ε` and `δ`. -/
theorem exists_pos_set_lintegral_lt_of_measure_lt {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {ε : ℝ≥0∞}
(hε : ε ≠ 0) : ∃ δ > 0, ∀ s, μ s < δ → ∫⁻ x in s, f x ∂μ < ε := by
rcases exists_between (pos_iff_ne_zero.mpr hε) with ⟨ε₂, hε₂0, hε₂ε⟩
rcases exists_between hε₂0 with ⟨ε₁, hε₁0, hε₁₂⟩
rcases exists_simpleFunc_forall_lintegral_sub_lt_of_pos h hε₁0.ne' with ⟨φ, _, hφ⟩
rcases φ.exists_forall_le with ⟨C, hC⟩
use (ε₂ - ε₁) / C, ENNReal.div_pos_iff.2 ⟨(tsub_pos_iff_lt.2 hε₁₂).ne', ENNReal.coe_ne_top⟩
refine fun s hs => lt_of_le_of_lt ?_ hε₂ε
simp only [lintegral_eq_nnreal, iSup_le_iff]
intro ψ hψ
calc
(map (↑) ψ).lintegral (μ.restrict s) ≤
(map (↑) φ).lintegral (μ.restrict s) + (map (↑) (ψ - φ)).lintegral (μ.restrict s) := by
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.map_add @ENNReal.coe_add]
refine SimpleFunc.lintegral_mono (fun x => ?_) le_rfl
simp only [add_tsub_eq_max, le_max_right, coe_map, Function.comp_apply, SimpleFunc.coe_add,
SimpleFunc.coe_sub, Pi.add_apply, Pi.sub_apply, ENNReal.coe_max (φ x) (ψ x)]
_ ≤ (map (↑) φ).lintegral (μ.restrict s) + ε₁ := by
gcongr
refine le_trans ?_ (hφ _ hψ).le
exact SimpleFunc.lintegral_mono le_rfl Measure.restrict_le_self
_ ≤ (SimpleFunc.const α (C : ℝ≥0∞)).lintegral (μ.restrict s) + ε₁ := by
gcongr
exact SimpleFunc.lintegral_mono (fun x ↦ ENNReal.coe_le_coe.2 (hC x)) le_rfl
_ = C * μ s + ε₁ := by
simp only [← SimpleFunc.lintegral_eq_lintegral, coe_const, lintegral_const,
Measure.restrict_apply, MeasurableSet.univ, univ_inter, Function.const]
_ ≤ C * ((ε₂ - ε₁) / C) + ε₁ := by gcongr
_ ≤ ε₂ - ε₁ + ε₁ := by gcongr; apply mul_div_le
_ = ε₂ := tsub_add_cancel_of_le hε₁₂.le
#align measure_theory.exists_pos_set_lintegral_lt_of_measure_lt MeasureTheory.exists_pos_set_lintegral_lt_of_measure_lt
/-- If `f` has finite integral, then `∫⁻ x in s, f x ∂μ` is absolutely continuous in `s`: it tends
to zero as `μ s` tends to zero. -/
theorem tendsto_set_lintegral_zero {ι} {f : α → ℝ≥0∞} (h : ∫⁻ x, f x ∂μ ≠ ∞) {l : Filter ι}
{s : ι → Set α} (hl : Tendsto (μ ∘ s) l (𝓝 0)) :
Tendsto (fun i => ∫⁻ x in s i, f x ∂μ) l (𝓝 0) := by
simp only [ENNReal.nhds_zero, tendsto_iInf, tendsto_principal, mem_Iio,
← pos_iff_ne_zero] at hl ⊢
intro ε ε0
rcases exists_pos_set_lintegral_lt_of_measure_lt h ε0.ne' with ⟨δ, δ0, hδ⟩
exact (hl δ δ0).mono fun i => hδ _
#align measure_theory.tendsto_set_lintegral_zero MeasureTheory.tendsto_set_lintegral_zero
/-- The sum of the lower Lebesgue integrals of two functions is less than or equal to the integral
of their sum. The other inequality needs one of these functions to be (a.e.-)measurable. -/
theorem le_lintegral_add (f g : α → ℝ≥0∞) :
∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ ≤ ∫⁻ a, f a + g a ∂μ := by
simp only [lintegral]
refine ENNReal.biSup_add_biSup_le' (p := fun h : α →ₛ ℝ≥0∞ => h ≤ f)
(q := fun h : α →ₛ ℝ≥0∞ => h ≤ g) ⟨0, zero_le f⟩ ⟨0, zero_le g⟩ fun f' hf' g' hg' => ?_
exact le_iSup₂_of_le (f' + g') (add_le_add hf' hg') (add_lintegral _ _).ge
#align measure_theory.le_lintegral_add MeasureTheory.le_lintegral_add
-- Use stronger lemmas `lintegral_add_left`/`lintegral_add_right` instead
theorem lintegral_add_aux {f g : α → ℝ≥0∞} (hf : Measurable f) (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
calc
∫⁻ a, f a + g a ∂μ =
∫⁻ a, (⨆ n, (eapprox f n : α → ℝ≥0∞) a) + ⨆ n, (eapprox g n : α → ℝ≥0∞) a ∂μ := by
simp only [iSup_eapprox_apply, hf, hg]
_ = ∫⁻ a, ⨆ n, (eapprox f n + eapprox g n : α → ℝ≥0∞) a ∂μ := by
congr; funext a
rw [ENNReal.iSup_add_iSup_of_monotone]
· simp only [Pi.add_apply]
· intro i j h
exact monotone_eapprox _ h a
· intro i j h
exact monotone_eapprox _ h a
_ = ⨆ n, (eapprox f n).lintegral μ + (eapprox g n).lintegral μ := by
rw [lintegral_iSup]
· congr
funext n
rw [← SimpleFunc.add_lintegral, ← SimpleFunc.lintegral_eq_lintegral]
simp only [Pi.add_apply, SimpleFunc.coe_add]
· measurability
· intro i j h a
dsimp
gcongr <;> exact monotone_eapprox _ h _
_ = (⨆ n, (eapprox f n).lintegral μ) + ⨆ n, (eapprox g n).lintegral μ := by
refine (ENNReal.iSup_add_iSup_of_monotone ?_ ?_).symm <;>
· intro i j h
exact SimpleFunc.lintegral_mono (monotone_eapprox _ h) le_rfl
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_eq_iSup_eapprox_lintegral hf, lintegral_eq_iSup_eapprox_lintegral hg]
#align measure_theory.lintegral_add_aux MeasureTheory.lintegral_add_aux
/-- If `f g : α → ℝ≥0∞` are two functions and one of them is (a.e.) measurable, then the Lebesgue
integral of `f + g` equals the sum of integrals. This lemma assumes that `f` is integrable, see also
`MeasureTheory.lintegral_add_right` and primed versions of these lemmas. -/
@[simp]
theorem lintegral_add_left {f : α → ℝ≥0∞} (hf : Measurable f) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
refine le_antisymm ?_ (le_lintegral_add _ _)
rcases exists_measurable_le_lintegral_eq μ fun a => f a + g a with ⟨φ, hφm, hφ_le, hφ_eq⟩
calc
∫⁻ a, f a + g a ∂μ = ∫⁻ a, φ a ∂μ := hφ_eq
_ ≤ ∫⁻ a, f a + (φ a - f a) ∂μ := lintegral_mono fun a => le_add_tsub
_ = ∫⁻ a, f a ∂μ + ∫⁻ a, φ a - f a ∂μ := lintegral_add_aux hf (hφm.sub hf)
_ ≤ ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
add_le_add_left (lintegral_mono fun a => tsub_le_iff_left.2 <| hφ_le a) _
#align measure_theory.lintegral_add_left MeasureTheory.lintegral_add_left
theorem lintegral_add_left' {f : α → ℝ≥0∞} (hf : AEMeasurable f μ) (g : α → ℝ≥0∞) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
rw [lintegral_congr_ae hf.ae_eq_mk, ← lintegral_add_left hf.measurable_mk,
lintegral_congr_ae (hf.ae_eq_mk.add (ae_eq_refl g))]
#align measure_theory.lintegral_add_left' MeasureTheory.lintegral_add_left'
theorem lintegral_add_right' (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : AEMeasurable g μ) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ := by
simpa only [add_comm] using lintegral_add_left' hg f
#align measure_theory.lintegral_add_right' MeasureTheory.lintegral_add_right'
/-- If `f g : α → ℝ≥0∞` are two functions and one of them is (a.e.) measurable, then the Lebesgue
integral of `f + g` equals the sum of integrals. This lemma assumes that `g` is integrable, see also
`MeasureTheory.lintegral_add_left` and primed versions of these lemmas. -/
@[simp]
theorem lintegral_add_right (f : α → ℝ≥0∞) {g : α → ℝ≥0∞} (hg : Measurable g) :
∫⁻ a, f a + g a ∂μ = ∫⁻ a, f a ∂μ + ∫⁻ a, g a ∂μ :=
lintegral_add_right' f hg.aemeasurable
#align measure_theory.lintegral_add_right MeasureTheory.lintegral_add_right
@[simp]
theorem lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) : ∫⁻ a, f a ∂c • μ = c * ∫⁻ a, f a ∂μ := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_smul, ENNReal.mul_iSup, smul_eq_mul]
#align measure_theory.lintegral_smul_measure MeasureTheory.lintegral_smul_measure
lemma set_lintegral_smul_measure (c : ℝ≥0∞) (f : α → ℝ≥0∞) (s : Set α) :
∫⁻ a in s, f a ∂(c • μ) = c * ∫⁻ a in s, f a ∂μ := by
rw [Measure.restrict_smul, lintegral_smul_measure]
@[simp]
theorem lintegral_sum_measure {m : MeasurableSpace α} {ι} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
∫⁻ a, f a ∂Measure.sum μ = ∑' i, ∫⁻ a, f a ∂μ i := by
simp only [lintegral, iSup_subtype', SimpleFunc.lintegral_sum, ENNReal.tsum_eq_iSup_sum]
rw [iSup_comm]
congr; funext s
induction' s using Finset.induction_on with i s hi hs
· simp
simp only [Finset.sum_insert hi, ← hs]
refine (ENNReal.iSup_add_iSup ?_).symm
intro φ ψ
exact
⟨⟨φ ⊔ ψ, fun x => sup_le (φ.2 x) (ψ.2 x)⟩,
add_le_add (SimpleFunc.lintegral_mono le_sup_left le_rfl)
(Finset.sum_le_sum fun j _ => SimpleFunc.lintegral_mono le_sup_right le_rfl)⟩
#align measure_theory.lintegral_sum_measure MeasureTheory.lintegral_sum_measure
theorem hasSum_lintegral_measure {ι} {_ : MeasurableSpace α} (f : α → ℝ≥0∞) (μ : ι → Measure α) :
HasSum (fun i => ∫⁻ a, f a ∂μ i) (∫⁻ a, f a ∂Measure.sum μ) :=
(lintegral_sum_measure f μ).symm ▸ ENNReal.summable.hasSum
#align measure_theory.has_sum_lintegral_measure MeasureTheory.hasSum_lintegral_measure
@[simp]
theorem lintegral_add_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) (μ ν : Measure α) :
∫⁻ a, f a ∂(μ + ν) = ∫⁻ a, f a ∂μ + ∫⁻ a, f a ∂ν := by
simpa [tsum_fintype] using lintegral_sum_measure f fun b => cond b μ ν
#align measure_theory.lintegral_add_measure MeasureTheory.lintegral_add_measure
@[simp]
theorem lintegral_finset_sum_measure {ι} {m : MeasurableSpace α} (s : Finset ι) (f : α → ℝ≥0∞)
(μ : ι → Measure α) : ∫⁻ a, f a ∂(∑ i ∈ s, μ i) = ∑ i ∈ s, ∫⁻ a, f a ∂μ i := by
rw [← Measure.sum_coe_finset, lintegral_sum_measure, ← Finset.tsum_subtype']
simp only [Finset.coe_sort_coe]
#align measure_theory.lintegral_finset_sum_measure MeasureTheory.lintegral_finset_sum_measure
@[simp]
theorem lintegral_zero_measure {m : MeasurableSpace α} (f : α → ℝ≥0∞) :
∫⁻ a, f a ∂(0 : Measure α) = 0 := by
simp [lintegral]
#align measure_theory.lintegral_zero_measure MeasureTheory.lintegral_zero_measure
@[simp]
theorem lintegral_of_isEmpty {α} [MeasurableSpace α] [IsEmpty α] (μ : Measure α) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = 0 := by
have : Subsingleton (Measure α) := inferInstance
convert lintegral_zero_measure f
theorem set_lintegral_empty (f : α → ℝ≥0∞) : ∫⁻ x in ∅, f x ∂μ = 0 := by
rw [Measure.restrict_empty, lintegral_zero_measure]
#align measure_theory.set_lintegral_empty MeasureTheory.set_lintegral_empty
theorem set_lintegral_univ (f : α → ℝ≥0∞) : ∫⁻ x in univ, f x ∂μ = ∫⁻ x, f x ∂μ := by
rw [Measure.restrict_univ]
#align measure_theory.set_lintegral_univ MeasureTheory.set_lintegral_univ
theorem set_lintegral_measure_zero (s : Set α) (f : α → ℝ≥0∞) (hs' : μ s = 0) :
∫⁻ x in s, f x ∂μ = 0 := by
convert lintegral_zero_measure _
exact Measure.restrict_eq_zero.2 hs'
#align measure_theory.set_lintegral_measure_zero MeasureTheory.set_lintegral_measure_zero
| Mathlib/MeasureTheory/Integral/Lebesgue.lean | 653 | 660 | 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]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Floris van Doorn
-/
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Finsupp.Defs
import Mathlib.Data.Nat.Cast.Order
import Mathlib.Data.Set.Countable
import Mathlib.Logic.Small.Set
import Mathlib.Order.SuccPred.CompleteLinearOrder
import Mathlib.SetTheory.Cardinal.SchroederBernstein
#align_import set_theory.cardinal.basic from "leanprover-community/mathlib"@"3ff3f2d6a3118b8711063de7111a0d77a53219a8"
/-!
# Cardinal Numbers
We define cardinal numbers as a quotient of types under the equivalence relation of equinumerity.
## Main definitions
* `Cardinal` is the type of cardinal numbers (in a given universe).
* `Cardinal.mk α` or `#α` is the cardinality of `α`. The notation `#` lives in the locale
`Cardinal`.
* Addition `c₁ + c₂` is defined by `Cardinal.add_def α β : #α + #β = #(α ⊕ β)`.
* Multiplication `c₁ * c₂` is defined by `Cardinal.mul_def : #α * #β = #(α × β)`.
* The order `c₁ ≤ c₂` is defined by `Cardinal.le_def α β : #α ≤ #β ↔ Nonempty (α ↪ β)`.
* Exponentiation `c₁ ^ c₂` is defined by `Cardinal.power_def α β : #α ^ #β = #(β → α)`.
* `Cardinal.isLimit c` means that `c` is a (weak) limit cardinal: `c ≠ 0 ∧ ∀ x < c, succ x < c`.
* `Cardinal.aleph0` or `ℵ₀` is the cardinality of `ℕ`. This definition is universe polymorphic:
`Cardinal.aleph0.{u} : Cardinal.{u}` (contrast with `ℕ : Type`, which lives in a specific
universe). In some cases the universe level has to be given explicitly.
* `Cardinal.sum` is the sum of an indexed family of cardinals, i.e. the cardinality of the
corresponding sigma type.
* `Cardinal.prod` is the product of an indexed family of cardinals, i.e. the cardinality of the
corresponding pi type.
* `Cardinal.powerlt a b` or `a ^< b` is defined as the supremum of `a ^ c` for `c < b`.
## Main instances
* Cardinals form a `CanonicallyOrderedCommSemiring` with the aforementioned sum and product.
* Cardinals form a `SuccOrder`. Use `Order.succ c` for the smallest cardinal greater than `c`.
* The less than relation on cardinals forms a well-order.
* Cardinals form a `ConditionallyCompleteLinearOrderBot`. Bounded sets for cardinals in universe
`u` are precisely the sets indexed by some type in universe `u`, see
`Cardinal.bddAbove_iff_small`. One can use `sSup` for the cardinal supremum, and `sInf` for the
minimum of a set of cardinals.
## Main Statements
* Cantor's theorem: `Cardinal.cantor c : c < 2 ^ c`.
* König's theorem: `Cardinal.sum_lt_prod`
## Implementation notes
* There is a type of cardinal numbers in every universe level:
`Cardinal.{u} : Type (u + 1)` is the quotient of types in `Type u`.
The operation `Cardinal.lift` lifts cardinal numbers to a higher level.
* Cardinal arithmetic specifically for infinite cardinals (like `κ * κ = κ`) is in the file
`Mathlib/SetTheory/Cardinal/Ordinal.lean`.
* There is an instance `Pow Cardinal`, but this will only fire if Lean already knows that both
the base and the exponent live in the same universe. As a workaround, you can add
```
local infixr:80 " ^' " => @HPow.hPow Cardinal Cardinal Cardinal _
```
to a file. This notation will work even if Lean doesn't know yet that the base and the exponent
live in the same universe (but no exponents in other types can be used).
(Porting note: This last point might need to be updated.)
## References
* <https://en.wikipedia.org/wiki/Cardinal_number>
## Tags
cardinal number, cardinal arithmetic, cardinal exponentiation, aleph,
Cantor's theorem, König's theorem, Konig's theorem
-/
assert_not_exists Field
assert_not_exists Module
open scoped Classical
open Function Set Order
noncomputable section
universe u v w
variable {α β : Type u}
/-- The equivalence relation on types given by equivalence (bijective correspondence) of types.
Quotienting by this equivalence relation gives the cardinal numbers.
-/
instance Cardinal.isEquivalent : Setoid (Type u) where
r α β := Nonempty (α ≃ β)
iseqv := ⟨
fun α => ⟨Equiv.refl α⟩,
fun ⟨e⟩ => ⟨e.symm⟩,
fun ⟨e₁⟩ ⟨e₂⟩ => ⟨e₁.trans e₂⟩⟩
#align cardinal.is_equivalent Cardinal.isEquivalent
/-- `Cardinal.{u}` is the type of cardinal numbers in `Type u`,
defined as the quotient of `Type u` by existence of an equivalence
(a bijection with explicit inverse). -/
@[pp_with_univ]
def Cardinal : Type (u + 1) :=
Quotient Cardinal.isEquivalent
#align cardinal Cardinal
namespace Cardinal
/-- The cardinal number of a type -/
def mk : Type u → Cardinal :=
Quotient.mk'
#align cardinal.mk Cardinal.mk
@[inherit_doc]
scoped prefix:max "#" => Cardinal.mk
instance canLiftCardinalType : CanLift Cardinal.{u} (Type u) mk fun _ => True :=
⟨fun c _ => Quot.inductionOn c fun α => ⟨α, rfl⟩⟩
#align cardinal.can_lift_cardinal_Type Cardinal.canLiftCardinalType
@[elab_as_elim]
theorem inductionOn {p : Cardinal → Prop} (c : Cardinal) (h : ∀ α, p #α) : p c :=
Quotient.inductionOn c h
#align cardinal.induction_on Cardinal.inductionOn
@[elab_as_elim]
theorem inductionOn₂ {p : Cardinal → Cardinal → Prop} (c₁ : Cardinal) (c₂ : Cardinal)
(h : ∀ α β, p #α #β) : p c₁ c₂ :=
Quotient.inductionOn₂ c₁ c₂ h
#align cardinal.induction_on₂ Cardinal.inductionOn₂
@[elab_as_elim]
theorem inductionOn₃ {p : Cardinal → Cardinal → Cardinal → Prop} (c₁ : Cardinal) (c₂ : Cardinal)
(c₃ : Cardinal) (h : ∀ α β γ, p #α #β #γ) : p c₁ c₂ c₃ :=
Quotient.inductionOn₃ c₁ c₂ c₃ h
#align cardinal.induction_on₃ Cardinal.inductionOn₃
protected theorem eq : #α = #β ↔ Nonempty (α ≃ β) :=
Quotient.eq'
#align cardinal.eq Cardinal.eq
@[simp]
theorem mk'_def (α : Type u) : @Eq Cardinal ⟦α⟧ #α :=
rfl
#align cardinal.mk_def Cardinal.mk'_def
@[simp]
theorem mk_out (c : Cardinal) : #c.out = c :=
Quotient.out_eq _
#align cardinal.mk_out Cardinal.mk_out
/-- The representative of the cardinal of a type is equivalent to the original type. -/
def outMkEquiv {α : Type v} : (#α).out ≃ α :=
Nonempty.some <| Cardinal.eq.mp (by simp)
#align cardinal.out_mk_equiv Cardinal.outMkEquiv
theorem mk_congr (e : α ≃ β) : #α = #β :=
Quot.sound ⟨e⟩
#align cardinal.mk_congr Cardinal.mk_congr
alias _root_.Equiv.cardinal_eq := mk_congr
#align equiv.cardinal_eq Equiv.cardinal_eq
/-- Lift a function between `Type*`s to a function between `Cardinal`s. -/
def map (f : Type u → Type v) (hf : ∀ α β, α ≃ β → f α ≃ f β) : Cardinal.{u} → Cardinal.{v} :=
Quotient.map f fun α β ⟨e⟩ => ⟨hf α β e⟩
#align cardinal.map Cardinal.map
@[simp]
theorem map_mk (f : Type u → Type v) (hf : ∀ α β, α ≃ β → f α ≃ f β) (α : Type u) :
map f hf #α = #(f α) :=
rfl
#align cardinal.map_mk Cardinal.map_mk
/-- Lift a binary operation `Type* → Type* → Type*` to a binary operation on `Cardinal`s. -/
def map₂ (f : Type u → Type v → Type w) (hf : ∀ α β γ δ, α ≃ β → γ ≃ δ → f α γ ≃ f β δ) :
Cardinal.{u} → Cardinal.{v} → Cardinal.{w} :=
Quotient.map₂ f fun α β ⟨e₁⟩ γ δ ⟨e₂⟩ => ⟨hf α β γ δ e₁ e₂⟩
#align cardinal.map₂ Cardinal.map₂
/-- The universe lift operation on cardinals. You can specify the universes explicitly with
`lift.{u v} : Cardinal.{v} → Cardinal.{max v u}` -/
@[pp_with_univ]
def lift (c : Cardinal.{v}) : Cardinal.{max v u} :=
map ULift.{u, v} (fun _ _ e => Equiv.ulift.trans <| e.trans Equiv.ulift.symm) c
#align cardinal.lift Cardinal.lift
@[simp]
theorem mk_uLift (α) : #(ULift.{v, u} α) = lift.{v} #α :=
rfl
#align cardinal.mk_ulift Cardinal.mk_uLift
-- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma
-- further down in this file
/-- `lift.{max u v, u}` equals `lift.{v, u}`. -/
@[simp, nolint simpNF]
theorem lift_umax : lift.{max u v, u} = lift.{v, u} :=
funext fun a => inductionOn a fun _ => (Equiv.ulift.trans Equiv.ulift.symm).cardinal_eq
#align cardinal.lift_umax Cardinal.lift_umax
-- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma
-- further down in this file
/-- `lift.{max v u, u}` equals `lift.{v, u}`. -/
@[simp, nolint simpNF]
theorem lift_umax' : lift.{max v u, u} = lift.{v, u} :=
lift_umax
#align cardinal.lift_umax' Cardinal.lift_umax'
-- Porting note: simpNF is not happy with universe levels, but this is needed as simp lemma
-- further down in this file
/-- A cardinal lifted to a lower or equal universe equals itself. -/
@[simp, nolint simpNF]
theorem lift_id' (a : Cardinal.{max u v}) : lift.{u} a = a :=
inductionOn a fun _ => mk_congr Equiv.ulift
#align cardinal.lift_id' Cardinal.lift_id'
/-- A cardinal lifted to the same universe equals itself. -/
@[simp]
theorem lift_id (a : Cardinal) : lift.{u, u} a = a :=
lift_id'.{u, u} a
#align cardinal.lift_id Cardinal.lift_id
/-- A cardinal lifted to the zero universe equals itself. -/
-- porting note (#10618): simp can prove this
-- @[simp]
theorem lift_uzero (a : Cardinal.{u}) : lift.{0} a = a :=
lift_id'.{0, u} a
#align cardinal.lift_uzero Cardinal.lift_uzero
@[simp]
theorem lift_lift.{u_1} (a : Cardinal.{u_1}) : lift.{w} (lift.{v} a) = lift.{max v w} a :=
inductionOn a fun _ => (Equiv.ulift.trans <| Equiv.ulift.trans Equiv.ulift.symm).cardinal_eq
#align cardinal.lift_lift Cardinal.lift_lift
/-- We define the order on cardinal numbers by `#α ≤ #β` if and only if
there exists an embedding (injective function) from α to β. -/
instance : LE Cardinal.{u} :=
⟨fun q₁ q₂ =>
Quotient.liftOn₂ q₁ q₂ (fun α β => Nonempty <| α ↪ β) fun _ _ _ _ ⟨e₁⟩ ⟨e₂⟩ =>
propext ⟨fun ⟨e⟩ => ⟨e.congr e₁ e₂⟩, fun ⟨e⟩ => ⟨e.congr e₁.symm e₂.symm⟩⟩⟩
instance partialOrder : PartialOrder Cardinal.{u} where
le := (· ≤ ·)
le_refl := by
rintro ⟨α⟩
exact ⟨Embedding.refl _⟩
le_trans := by
rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ ⟨e₁⟩ ⟨e₂⟩
exact ⟨e₁.trans e₂⟩
le_antisymm := by
rintro ⟨α⟩ ⟨β⟩ ⟨e₁⟩ ⟨e₂⟩
exact Quotient.sound (e₁.antisymm e₂)
instance linearOrder : LinearOrder Cardinal.{u} :=
{ Cardinal.partialOrder with
le_total := by
rintro ⟨α⟩ ⟨β⟩
apply Embedding.total
decidableLE := Classical.decRel _ }
theorem le_def (α β : Type u) : #α ≤ #β ↔ Nonempty (α ↪ β) :=
Iff.rfl
#align cardinal.le_def Cardinal.le_def
theorem mk_le_of_injective {α β : Type u} {f : α → β} (hf : Injective f) : #α ≤ #β :=
⟨⟨f, hf⟩⟩
#align cardinal.mk_le_of_injective Cardinal.mk_le_of_injective
theorem _root_.Function.Embedding.cardinal_le {α β : Type u} (f : α ↪ β) : #α ≤ #β :=
⟨f⟩
#align function.embedding.cardinal_le Function.Embedding.cardinal_le
theorem mk_le_of_surjective {α β : Type u} {f : α → β} (hf : Surjective f) : #β ≤ #α :=
⟨Embedding.ofSurjective f hf⟩
#align cardinal.mk_le_of_surjective Cardinal.mk_le_of_surjective
theorem le_mk_iff_exists_set {c : Cardinal} {α : Type u} : c ≤ #α ↔ ∃ p : Set α, #p = c :=
⟨inductionOn c fun _ ⟨⟨f, hf⟩⟩ => ⟨Set.range f, (Equiv.ofInjective f hf).cardinal_eq.symm⟩,
fun ⟨_, e⟩ => e ▸ ⟨⟨Subtype.val, fun _ _ => Subtype.eq⟩⟩⟩
#align cardinal.le_mk_iff_exists_set Cardinal.le_mk_iff_exists_set
theorem mk_subtype_le {α : Type u} (p : α → Prop) : #(Subtype p) ≤ #α :=
⟨Embedding.subtype p⟩
#align cardinal.mk_subtype_le Cardinal.mk_subtype_le
theorem mk_set_le (s : Set α) : #s ≤ #α :=
mk_subtype_le s
#align cardinal.mk_set_le Cardinal.mk_set_le
@[simp]
lemma mk_preimage_down {s : Set α} : #(ULift.down.{v} ⁻¹' s) = lift.{v} (#s) := by
rw [← mk_uLift, Cardinal.eq]
constructor
let f : ULift.down ⁻¹' s → ULift s := fun x ↦ ULift.up (restrictPreimage s ULift.down x)
have : Function.Bijective f :=
ULift.up_bijective.comp (restrictPreimage_bijective _ (ULift.down_bijective))
exact Equiv.ofBijective f this
theorem out_embedding {c c' : Cardinal} : c ≤ c' ↔ Nonempty (c.out ↪ c'.out) := by
trans
· rw [← Quotient.out_eq c, ← Quotient.out_eq c']
· rw [mk'_def, mk'_def, le_def]
#align cardinal.out_embedding Cardinal.out_embedding
theorem lift_mk_le {α : Type v} {β : Type w} :
lift.{max u w} #α ≤ lift.{max u v} #β ↔ Nonempty (α ↪ β) :=
⟨fun ⟨f⟩ => ⟨Embedding.congr Equiv.ulift Equiv.ulift f⟩, fun ⟨f⟩ =>
⟨Embedding.congr Equiv.ulift.symm Equiv.ulift.symm f⟩⟩
#align cardinal.lift_mk_le Cardinal.lift_mk_le
/-- A variant of `Cardinal.lift_mk_le` with specialized universes.
Because Lean often can not realize it should use this specialization itself,
we provide this statement separately so you don't have to solve the specialization problem either.
-/
theorem lift_mk_le' {α : Type u} {β : Type v} : lift.{v} #α ≤ lift.{u} #β ↔ Nonempty (α ↪ β) :=
lift_mk_le.{0}
#align cardinal.lift_mk_le' Cardinal.lift_mk_le'
theorem lift_mk_eq {α : Type u} {β : Type v} :
lift.{max v w} #α = lift.{max u w} #β ↔ Nonempty (α ≃ β) :=
Quotient.eq'.trans
⟨fun ⟨f⟩ => ⟨Equiv.ulift.symm.trans <| f.trans Equiv.ulift⟩, fun ⟨f⟩ =>
⟨Equiv.ulift.trans <| f.trans Equiv.ulift.symm⟩⟩
#align cardinal.lift_mk_eq Cardinal.lift_mk_eq
/-- A variant of `Cardinal.lift_mk_eq` with specialized universes.
Because Lean often can not realize it should use this specialization itself,
we provide this statement separately so you don't have to solve the specialization problem either.
-/
theorem lift_mk_eq' {α : Type u} {β : Type v} : lift.{v} #α = lift.{u} #β ↔ Nonempty (α ≃ β) :=
lift_mk_eq.{u, v, 0}
#align cardinal.lift_mk_eq' Cardinal.lift_mk_eq'
@[simp]
theorem lift_le {a b : Cardinal.{v}} : lift.{u, v} a ≤ lift.{u, v} b ↔ a ≤ b :=
inductionOn₂ a b fun α β => by
rw [← lift_umax]
exact lift_mk_le.{u}
#align cardinal.lift_le Cardinal.lift_le
-- Porting note: changed `simps` to `simps!` because the linter told to do so.
/-- `Cardinal.lift` as an `OrderEmbedding`. -/
@[simps! (config := .asFn)]
def liftOrderEmbedding : Cardinal.{v} ↪o Cardinal.{max v u} :=
OrderEmbedding.ofMapLEIff lift.{u, v} fun _ _ => lift_le
#align cardinal.lift_order_embedding Cardinal.liftOrderEmbedding
theorem lift_injective : Injective lift.{u, v} :=
liftOrderEmbedding.injective
#align cardinal.lift_injective Cardinal.lift_injective
@[simp]
theorem lift_inj {a b : Cardinal.{u}} : lift.{v, u} a = lift.{v, u} b ↔ a = b :=
lift_injective.eq_iff
#align cardinal.lift_inj Cardinal.lift_inj
@[simp]
theorem lift_lt {a b : Cardinal.{u}} : lift.{v, u} a < lift.{v, u} b ↔ a < b :=
liftOrderEmbedding.lt_iff_lt
#align cardinal.lift_lt Cardinal.lift_lt
theorem lift_strictMono : StrictMono lift := fun _ _ => lift_lt.2
#align cardinal.lift_strict_mono Cardinal.lift_strictMono
theorem lift_monotone : Monotone lift :=
lift_strictMono.monotone
#align cardinal.lift_monotone Cardinal.lift_monotone
instance : Zero Cardinal.{u} :=
-- `PEmpty` might be more canonical, but this is convenient for defeq with natCast
⟨lift #(Fin 0)⟩
instance : Inhabited Cardinal.{u} :=
⟨0⟩
@[simp]
theorem mk_eq_zero (α : Type u) [IsEmpty α] : #α = 0 :=
(Equiv.equivOfIsEmpty α (ULift (Fin 0))).cardinal_eq
#align cardinal.mk_eq_zero Cardinal.mk_eq_zero
@[simp]
theorem lift_zero : lift 0 = 0 := mk_eq_zero _
#align cardinal.lift_zero Cardinal.lift_zero
@[simp]
theorem lift_eq_zero {a : Cardinal.{v}} : lift.{u} a = 0 ↔ a = 0 :=
lift_injective.eq_iff' lift_zero
#align cardinal.lift_eq_zero Cardinal.lift_eq_zero
theorem mk_eq_zero_iff {α : Type u} : #α = 0 ↔ IsEmpty α :=
⟨fun e =>
let ⟨h⟩ := Quotient.exact e
h.isEmpty,
@mk_eq_zero α⟩
#align cardinal.mk_eq_zero_iff Cardinal.mk_eq_zero_iff
theorem mk_ne_zero_iff {α : Type u} : #α ≠ 0 ↔ Nonempty α :=
(not_iff_not.2 mk_eq_zero_iff).trans not_isEmpty_iff
#align cardinal.mk_ne_zero_iff Cardinal.mk_ne_zero_iff
@[simp]
theorem mk_ne_zero (α : Type u) [Nonempty α] : #α ≠ 0 :=
mk_ne_zero_iff.2 ‹_›
#align cardinal.mk_ne_zero Cardinal.mk_ne_zero
instance : One Cardinal.{u} :=
-- `PUnit` might be more canonical, but this is convenient for defeq with natCast
⟨lift #(Fin 1)⟩
instance : Nontrivial Cardinal.{u} :=
⟨⟨1, 0, mk_ne_zero _⟩⟩
theorem mk_eq_one (α : Type u) [Unique α] : #α = 1 :=
(Equiv.equivOfUnique α (ULift (Fin 1))).cardinal_eq
#align cardinal.mk_eq_one Cardinal.mk_eq_one
theorem le_one_iff_subsingleton {α : Type u} : #α ≤ 1 ↔ Subsingleton α :=
⟨fun ⟨f⟩ => ⟨fun _ _ => f.injective (Subsingleton.elim _ _)⟩, fun ⟨h⟩ =>
⟨fun _ => ULift.up 0, fun _ _ _ => h _ _⟩⟩
#align cardinal.le_one_iff_subsingleton Cardinal.le_one_iff_subsingleton
@[simp]
theorem mk_le_one_iff_set_subsingleton {s : Set α} : #s ≤ 1 ↔ s.Subsingleton :=
le_one_iff_subsingleton.trans s.subsingleton_coe
#align cardinal.mk_le_one_iff_set_subsingleton Cardinal.mk_le_one_iff_set_subsingleton
alias ⟨_, _root_.Set.Subsingleton.cardinal_mk_le_one⟩ := mk_le_one_iff_set_subsingleton
#align set.subsingleton.cardinal_mk_le_one Set.Subsingleton.cardinal_mk_le_one
instance : Add Cardinal.{u} :=
⟨map₂ Sum fun _ _ _ _ => Equiv.sumCongr⟩
theorem add_def (α β : Type u) : #α + #β = #(Sum α β) :=
rfl
#align cardinal.add_def Cardinal.add_def
instance : NatCast Cardinal.{u} :=
⟨fun n => lift #(Fin n)⟩
@[simp]
theorem mk_sum (α : Type u) (β : Type v) : #(α ⊕ β) = lift.{v, u} #α + lift.{u, v} #β :=
mk_congr (Equiv.ulift.symm.sumCongr Equiv.ulift.symm)
#align cardinal.mk_sum Cardinal.mk_sum
@[simp]
theorem mk_option {α : Type u} : #(Option α) = #α + 1 := by
rw [(Equiv.optionEquivSumPUnit.{u, u} α).cardinal_eq, mk_sum, mk_eq_one PUnit, lift_id, lift_id]
#align cardinal.mk_option Cardinal.mk_option
@[simp]
theorem mk_psum (α : Type u) (β : Type v) : #(PSum α β) = lift.{v} #α + lift.{u} #β :=
(mk_congr (Equiv.psumEquivSum α β)).trans (mk_sum α β)
#align cardinal.mk_psum Cardinal.mk_psum
@[simp]
theorem mk_fintype (α : Type u) [h : Fintype α] : #α = Fintype.card α :=
mk_congr (Fintype.equivOfCardEq (by simp))
protected theorem cast_succ (n : ℕ) : ((n + 1 : ℕ) : Cardinal.{u}) = n + 1 := by
change #(ULift.{u} (Fin (n+1))) = # (ULift.{u} (Fin n)) + 1
rw [← mk_option, mk_fintype, mk_fintype]
simp only [Fintype.card_ulift, Fintype.card_fin, Fintype.card_option]
instance : Mul Cardinal.{u} :=
⟨map₂ Prod fun _ _ _ _ => Equiv.prodCongr⟩
theorem mul_def (α β : Type u) : #α * #β = #(α × β) :=
rfl
#align cardinal.mul_def Cardinal.mul_def
@[simp]
theorem mk_prod (α : Type u) (β : Type v) : #(α × β) = lift.{v, u} #α * lift.{u, v} #β :=
mk_congr (Equiv.ulift.symm.prodCongr Equiv.ulift.symm)
#align cardinal.mk_prod Cardinal.mk_prod
private theorem mul_comm' (a b : Cardinal.{u}) : a * b = b * a :=
inductionOn₂ a b fun α β => mk_congr <| Equiv.prodComm α β
/-- The cardinal exponential. `#α ^ #β` is the cardinal of `β → α`. -/
instance instPowCardinal : Pow Cardinal.{u} Cardinal.{u} :=
⟨map₂ (fun α β => β → α) fun _ _ _ _ e₁ e₂ => e₂.arrowCongr e₁⟩
theorem power_def (α β : Type u) : #α ^ #β = #(β → α) :=
rfl
#align cardinal.power_def Cardinal.power_def
theorem mk_arrow (α : Type u) (β : Type v) : #(α → β) = (lift.{u} #β^lift.{v} #α) :=
mk_congr (Equiv.ulift.symm.arrowCongr Equiv.ulift.symm)
#align cardinal.mk_arrow Cardinal.mk_arrow
@[simp]
theorem lift_power (a b : Cardinal.{u}) : lift.{v} (a ^ b) = lift.{v} a ^ lift.{v} b :=
inductionOn₂ a b fun _ _ =>
mk_congr <| Equiv.ulift.trans (Equiv.ulift.arrowCongr Equiv.ulift).symm
#align cardinal.lift_power Cardinal.lift_power
@[simp]
theorem power_zero {a : Cardinal} : a ^ (0 : Cardinal) = 1 :=
inductionOn a fun _ => mk_eq_one _
#align cardinal.power_zero Cardinal.power_zero
@[simp]
theorem power_one {a : Cardinal.{u}} : a ^ (1 : Cardinal) = a :=
inductionOn a fun α => mk_congr (Equiv.funUnique (ULift.{u} (Fin 1)) α)
#align cardinal.power_one Cardinal.power_one
theorem power_add {a b c : Cardinal} : a ^ (b + c) = a ^ b * a ^ c :=
inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumArrowEquivProdArrow β γ α
#align cardinal.power_add Cardinal.power_add
instance commSemiring : CommSemiring Cardinal.{u} where
zero := 0
one := 1
add := (· + ·)
mul := (· * ·)
zero_add a := inductionOn a fun α => mk_congr <| Equiv.emptySum (ULift (Fin 0)) α
add_zero a := inductionOn a fun α => mk_congr <| Equiv.sumEmpty α (ULift (Fin 0))
add_assoc a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumAssoc α β γ
add_comm a b := inductionOn₂ a b fun α β => mk_congr <| Equiv.sumComm α β
zero_mul a := inductionOn a fun α => mk_eq_zero _
mul_zero a := inductionOn a fun α => mk_eq_zero _
one_mul a := inductionOn a fun α => mk_congr <| Equiv.uniqueProd α (ULift (Fin 1))
mul_one a := inductionOn a fun α => mk_congr <| Equiv.prodUnique α (ULift (Fin 1))
mul_assoc a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.prodAssoc α β γ
mul_comm := mul_comm'
left_distrib a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.prodSumDistrib α β γ
right_distrib a b c := inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.sumProdDistrib α β γ
nsmul := nsmulRec
npow n c := c ^ (n : Cardinal)
npow_zero := @power_zero
npow_succ n c := show c ^ (↑(n + 1) : Cardinal) = c ^ (↑n : Cardinal) * c
by rw [Cardinal.cast_succ, power_add, power_one, mul_comm']
natCast := (fun n => lift.{u} #(Fin n) : ℕ → Cardinal.{u})
natCast_zero := rfl
natCast_succ := Cardinal.cast_succ
/-! Porting note (#11229): Deprecated section. Remove. -/
section deprecated
set_option linter.deprecated false
@[deprecated (since := "2023-02-11")]
theorem power_bit0 (a b : Cardinal) : a ^ bit0 b = a ^ b * a ^ b :=
power_add
#align cardinal.power_bit0 Cardinal.power_bit0
@[deprecated (since := "2023-02-11")]
theorem power_bit1 (a b : Cardinal) : a ^ bit1 b = a ^ b * a ^ b * a := by
rw [bit1, ← power_bit0, power_add, power_one]
#align cardinal.power_bit1 Cardinal.power_bit1
end deprecated
@[simp]
theorem one_power {a : Cardinal} : (1 : Cardinal) ^ a = 1 :=
inductionOn a fun _ => mk_eq_one _
#align cardinal.one_power Cardinal.one_power
-- porting note (#10618): simp can prove this
-- @[simp]
theorem mk_bool : #Bool = 2 := by simp
#align cardinal.mk_bool Cardinal.mk_bool
-- porting note (#10618): simp can prove this
-- @[simp]
theorem mk_Prop : #Prop = 2 := by simp
#align cardinal.mk_Prop Cardinal.mk_Prop
@[simp]
theorem zero_power {a : Cardinal} : a ≠ 0 → (0 : Cardinal) ^ a = 0 :=
inductionOn a fun _ heq =>
mk_eq_zero_iff.2 <|
isEmpty_pi.2 <|
let ⟨a⟩ := mk_ne_zero_iff.1 heq
⟨a, inferInstance⟩
#align cardinal.zero_power Cardinal.zero_power
theorem power_ne_zero {a : Cardinal} (b : Cardinal) : a ≠ 0 → a ^ b ≠ 0 :=
inductionOn₂ a b fun _ _ h =>
let ⟨a⟩ := mk_ne_zero_iff.1 h
mk_ne_zero_iff.2 ⟨fun _ => a⟩
#align cardinal.power_ne_zero Cardinal.power_ne_zero
theorem mul_power {a b c : Cardinal} : (a * b) ^ c = a ^ c * b ^ c :=
inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.arrowProdEquivProdArrow α β γ
#align cardinal.mul_power Cardinal.mul_power
theorem power_mul {a b c : Cardinal} : a ^ (b * c) = (a ^ b) ^ c := by
rw [mul_comm b c]
exact inductionOn₃ a b c fun α β γ => mk_congr <| Equiv.curry γ β α
#align cardinal.power_mul Cardinal.power_mul
@[simp]
theorem pow_cast_right (a : Cardinal.{u}) (n : ℕ) : a ^ (↑n : Cardinal.{u}) = a ^ n :=
rfl
#align cardinal.pow_cast_right Cardinal.pow_cast_right
@[simp]
theorem lift_one : lift 1 = 1 := mk_eq_one _
#align cardinal.lift_one Cardinal.lift_one
@[simp]
theorem lift_eq_one {a : Cardinal.{v}} : lift.{u} a = 1 ↔ a = 1 :=
lift_injective.eq_iff' lift_one
@[simp]
theorem lift_add (a b : Cardinal.{u}) : lift.{v} (a + b) = lift.{v} a + lift.{v} b :=
inductionOn₂ a b fun _ _ =>
mk_congr <| Equiv.ulift.trans (Equiv.sumCongr Equiv.ulift Equiv.ulift).symm
#align cardinal.lift_add Cardinal.lift_add
@[simp]
theorem lift_mul (a b : Cardinal.{u}) : lift.{v} (a * b) = lift.{v} a * lift.{v} b :=
inductionOn₂ a b fun _ _ =>
mk_congr <| Equiv.ulift.trans (Equiv.prodCongr Equiv.ulift Equiv.ulift).symm
#align cardinal.lift_mul Cardinal.lift_mul
/-! Porting note (#11229): Deprecated section. Remove. -/
section deprecated
set_option linter.deprecated false
@[simp, deprecated (since := "2023-02-11")]
theorem lift_bit0 (a : Cardinal) : lift.{v} (bit0 a) = bit0 (lift.{v} a) :=
lift_add a a
#align cardinal.lift_bit0 Cardinal.lift_bit0
@[simp, deprecated (since := "2023-02-11")]
theorem lift_bit1 (a : Cardinal) : lift.{v} (bit1 a) = bit1 (lift.{v} a) := by simp [bit1]
#align cardinal.lift_bit1 Cardinal.lift_bit1
end deprecated
-- Porting note: Proof used to be simp, needed to remind simp that 1 + 1 = 2
theorem lift_two : lift.{u, v} 2 = 2 := by simp [← one_add_one_eq_two]
#align cardinal.lift_two Cardinal.lift_two
@[simp]
theorem mk_set {α : Type u} : #(Set α) = 2 ^ #α := by simp [← one_add_one_eq_two, Set, mk_arrow]
#align cardinal.mk_set Cardinal.mk_set
/-- A variant of `Cardinal.mk_set` expressed in terms of a `Set` instead of a `Type`. -/
@[simp]
theorem mk_powerset {α : Type u} (s : Set α) : #(↥(𝒫 s)) = 2 ^ #(↥s) :=
(mk_congr (Equiv.Set.powerset s)).trans mk_set
#align cardinal.mk_powerset Cardinal.mk_powerset
theorem lift_two_power (a : Cardinal) : lift.{v} (2 ^ a) = 2 ^ lift.{v} a := by
simp [← one_add_one_eq_two]
#align cardinal.lift_two_power Cardinal.lift_two_power
section OrderProperties
open Sum
protected theorem zero_le : ∀ a : Cardinal, 0 ≤ a := by
rintro ⟨α⟩
exact ⟨Embedding.ofIsEmpty⟩
#align cardinal.zero_le Cardinal.zero_le
private theorem add_le_add' : ∀ {a b c d : Cardinal}, a ≤ b → c ≤ d → a + c ≤ b + d := by
rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ ⟨δ⟩ ⟨e₁⟩ ⟨e₂⟩; exact ⟨e₁.sumMap e₂⟩
-- #align cardinal.add_le_add' Cardinal.add_le_add'
instance add_covariantClass : CovariantClass Cardinal Cardinal (· + ·) (· ≤ ·) :=
⟨fun _ _ _ => add_le_add' le_rfl⟩
#align cardinal.add_covariant_class Cardinal.add_covariantClass
instance add_swap_covariantClass : CovariantClass Cardinal Cardinal (swap (· + ·)) (· ≤ ·) :=
⟨fun _ _ _ h => add_le_add' h le_rfl⟩
#align cardinal.add_swap_covariant_class Cardinal.add_swap_covariantClass
instance canonicallyOrderedCommSemiring : CanonicallyOrderedCommSemiring Cardinal.{u} :=
{ Cardinal.commSemiring,
Cardinal.partialOrder with
bot := 0
bot_le := Cardinal.zero_le
add_le_add_left := fun a b => add_le_add_left
exists_add_of_le := fun {a b} =>
inductionOn₂ a b fun α β ⟨⟨f, hf⟩⟩ =>
have : Sum α ((range f)ᶜ : Set β) ≃ β :=
(Equiv.sumCongr (Equiv.ofInjective f hf) (Equiv.refl _)).trans <|
Equiv.Set.sumCompl (range f)
⟨#(↥(range f)ᶜ), mk_congr this.symm⟩
le_self_add := fun a b => (add_zero a).ge.trans <| add_le_add_left (Cardinal.zero_le _) _
eq_zero_or_eq_zero_of_mul_eq_zero := fun {a b} =>
inductionOn₂ a b fun α β => by
simpa only [mul_def, mk_eq_zero_iff, isEmpty_prod] using id }
instance : CanonicallyLinearOrderedAddCommMonoid Cardinal.{u} :=
{ Cardinal.canonicallyOrderedCommSemiring, Cardinal.linearOrder with }
-- Computable instance to prevent a non-computable one being found via the one above
instance : CanonicallyOrderedAddCommMonoid Cardinal.{u} :=
{ Cardinal.canonicallyOrderedCommSemiring with }
instance : LinearOrderedCommMonoidWithZero Cardinal.{u} :=
{ Cardinal.commSemiring,
Cardinal.linearOrder with
mul_le_mul_left := @mul_le_mul_left' _ _ _ _
zero_le_one := zero_le _ }
-- Computable instance to prevent a non-computable one being found via the one above
instance : CommMonoidWithZero Cardinal.{u} :=
{ Cardinal.canonicallyOrderedCommSemiring with }
-- Porting note: new
-- Computable instance to prevent a non-computable one being found via the one above
instance : CommMonoid Cardinal.{u} :=
{ Cardinal.canonicallyOrderedCommSemiring with }
theorem zero_power_le (c : Cardinal.{u}) : (0 : Cardinal.{u}) ^ c ≤ 1 := by
by_cases h : c = 0
· rw [h, power_zero]
· rw [zero_power h]
apply zero_le
#align cardinal.zero_power_le Cardinal.zero_power_le
theorem power_le_power_left : ∀ {a b c : Cardinal}, a ≠ 0 → b ≤ c → a ^ b ≤ a ^ c := by
rintro ⟨α⟩ ⟨β⟩ ⟨γ⟩ hα ⟨e⟩
let ⟨a⟩ := mk_ne_zero_iff.1 hα
exact ⟨@Function.Embedding.arrowCongrLeft _ _ _ ⟨a⟩ e⟩
#align cardinal.power_le_power_left Cardinal.power_le_power_left
theorem self_le_power (a : Cardinal) {b : Cardinal} (hb : 1 ≤ b) : a ≤ a ^ b := by
rcases eq_or_ne a 0 with (rfl | ha)
· exact zero_le _
· convert power_le_power_left ha hb
exact power_one.symm
#align cardinal.self_le_power Cardinal.self_le_power
/-- **Cantor's theorem** -/
theorem cantor (a : Cardinal.{u}) : a < 2 ^ a := by
induction' a using Cardinal.inductionOn with α
rw [← mk_set]
refine ⟨⟨⟨singleton, fun a b => singleton_eq_singleton_iff.1⟩⟩, ?_⟩
rintro ⟨⟨f, hf⟩⟩
exact cantor_injective f hf
#align cardinal.cantor Cardinal.cantor
instance : NoMaxOrder Cardinal.{u} where exists_gt a := ⟨_, cantor a⟩
-- short-circuit type class inference
instance : DistribLattice Cardinal.{u} := inferInstance
theorem one_lt_iff_nontrivial {α : Type u} : 1 < #α ↔ Nontrivial α := by
rw [← not_le, le_one_iff_subsingleton, ← not_nontrivial_iff_subsingleton, Classical.not_not]
#align cardinal.one_lt_iff_nontrivial Cardinal.one_lt_iff_nontrivial
theorem power_le_max_power_one {a b c : Cardinal} (h : b ≤ c) : a ^ b ≤ max (a ^ c) 1 := by
by_cases ha : a = 0
· simp [ha, zero_power_le]
· exact (power_le_power_left ha h).trans (le_max_left _ _)
#align cardinal.power_le_max_power_one Cardinal.power_le_max_power_one
theorem power_le_power_right {a b c : Cardinal} : a ≤ b → a ^ c ≤ b ^ c :=
inductionOn₃ a b c fun _ _ _ ⟨e⟩ => ⟨Embedding.arrowCongrRight e⟩
#align cardinal.power_le_power_right Cardinal.power_le_power_right
theorem power_pos {a : Cardinal} (b : Cardinal) (ha : 0 < a) : 0 < a ^ b :=
(power_ne_zero _ ha.ne').bot_lt
#align cardinal.power_pos Cardinal.power_pos
end OrderProperties
protected theorem lt_wf : @WellFounded Cardinal.{u} (· < ·) :=
⟨fun a =>
by_contradiction fun h => by
let ι := { c : Cardinal // ¬Acc (· < ·) c }
let f : ι → Cardinal := Subtype.val
haveI hι : Nonempty ι := ⟨⟨_, h⟩⟩
obtain ⟨⟨c : Cardinal, hc : ¬Acc (· < ·) c⟩, ⟨h_1 : ∀ j, (f ⟨c, hc⟩).out ↪ (f j).out⟩⟩ :=
Embedding.min_injective fun i => (f i).out
refine hc (Acc.intro _ fun j h' => by_contradiction fun hj => h'.2 ?_)
have : #_ ≤ #_ := ⟨h_1 ⟨j, hj⟩⟩
simpa only [mk_out] using this⟩
#align cardinal.lt_wf Cardinal.lt_wf
instance : WellFoundedRelation Cardinal.{u} :=
⟨(· < ·), Cardinal.lt_wf⟩
-- Porting note: this no longer is automatically inferred.
instance : WellFoundedLT Cardinal.{u} :=
⟨Cardinal.lt_wf⟩
instance wo : @IsWellOrder Cardinal.{u} (· < ·) where
#align cardinal.wo Cardinal.wo
instance : ConditionallyCompleteLinearOrderBot Cardinal :=
IsWellOrder.conditionallyCompleteLinearOrderBot _
@[simp]
theorem sInf_empty : sInf (∅ : Set Cardinal.{u}) = 0 :=
dif_neg Set.not_nonempty_empty
#align cardinal.Inf_empty Cardinal.sInf_empty
lemma sInf_eq_zero_iff {s : Set Cardinal} : sInf s = 0 ↔ s = ∅ ∨ ∃ a ∈ s, a = 0 := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases s.eq_empty_or_nonempty with rfl | hne
· exact Or.inl rfl
· exact Or.inr ⟨sInf s, csInf_mem hne, h⟩
· rcases h with rfl | ⟨a, ha, rfl⟩
· exact Cardinal.sInf_empty
· exact eq_bot_iff.2 (csInf_le' ha)
lemma iInf_eq_zero_iff {ι : Sort*} {f : ι → Cardinal} :
(⨅ i, f i) = 0 ↔ IsEmpty ι ∨ ∃ i, f i = 0 := by
simp [iInf, sInf_eq_zero_iff]
/-- Note that the successor of `c` is not the same as `c + 1` except in the case of finite `c`. -/
instance : SuccOrder Cardinal :=
SuccOrder.ofSuccLeIff (fun c => sInf { c' | c < c' })
-- Porting note: Needed to insert `by apply` in the next line
⟨by apply lt_of_lt_of_le <| csInf_mem <| exists_gt _,
-- Porting note used to be just `csInf_le'`
fun h ↦ csInf_le' h⟩
theorem succ_def (c : Cardinal) : succ c = sInf { c' | c < c' } :=
rfl
#align cardinal.succ_def Cardinal.succ_def
theorem succ_pos : ∀ c : Cardinal, 0 < succ c :=
bot_lt_succ
#align cardinal.succ_pos Cardinal.succ_pos
theorem succ_ne_zero (c : Cardinal) : succ c ≠ 0 :=
(succ_pos _).ne'
#align cardinal.succ_ne_zero Cardinal.succ_ne_zero
theorem add_one_le_succ (c : Cardinal.{u}) : c + 1 ≤ succ c := by
-- Porting note: rewrote the next three lines to avoid defeq abuse.
have : Set.Nonempty { c' | c < c' } := exists_gt c
simp_rw [succ_def, le_csInf_iff'' this, mem_setOf]
intro b hlt
rcases b, c with ⟨⟨β⟩, ⟨γ⟩⟩
cases' le_of_lt hlt with f
have : ¬Surjective f := fun hn => (not_le_of_lt hlt) (mk_le_of_surjective hn)
simp only [Surjective, not_forall] at this
rcases this with ⟨b, hb⟩
calc
#γ + 1 = #(Option γ) := mk_option.symm
_ ≤ #β := (f.optionElim b hb).cardinal_le
#align cardinal.add_one_le_succ Cardinal.add_one_le_succ
/-- A cardinal is a limit if it is not zero or a successor cardinal. Note that `ℵ₀` is a limit
cardinal by this definition, but `0` isn't.
Use `IsSuccLimit` if you want to include the `c = 0` case. -/
def IsLimit (c : Cardinal) : Prop :=
c ≠ 0 ∧ IsSuccLimit c
#align cardinal.is_limit Cardinal.IsLimit
protected theorem IsLimit.ne_zero {c} (h : IsLimit c) : c ≠ 0 :=
h.1
#align cardinal.is_limit.ne_zero Cardinal.IsLimit.ne_zero
protected theorem IsLimit.isSuccLimit {c} (h : IsLimit c) : IsSuccLimit c :=
h.2
#align cardinal.is_limit.is_succ_limit Cardinal.IsLimit.isSuccLimit
theorem IsLimit.succ_lt {x c} (h : IsLimit c) : x < c → succ x < c :=
h.isSuccLimit.succ_lt
#align cardinal.is_limit.succ_lt Cardinal.IsLimit.succ_lt
theorem isSuccLimit_zero : IsSuccLimit (0 : Cardinal) :=
isSuccLimit_bot
#align cardinal.is_succ_limit_zero Cardinal.isSuccLimit_zero
/-- The indexed sum of cardinals is the cardinality of the
indexed disjoint union, i.e. sigma type. -/
def sum {ι} (f : ι → Cardinal) : Cardinal :=
mk (Σi, (f i).out)
#align cardinal.sum Cardinal.sum
theorem le_sum {ι} (f : ι → Cardinal) (i) : f i ≤ sum f := by
rw [← Quotient.out_eq (f i)]
exact ⟨⟨fun a => ⟨i, a⟩, fun a b h => by injection h⟩⟩
#align cardinal.le_sum Cardinal.le_sum
@[simp]
theorem mk_sigma {ι} (f : ι → Type*) : #(Σ i, f i) = sum fun i => #(f i) :=
mk_congr <| Equiv.sigmaCongrRight fun _ => outMkEquiv.symm
#align cardinal.mk_sigma Cardinal.mk_sigma
@[simp]
theorem sum_const (ι : Type u) (a : Cardinal.{v}) :
(sum fun _ : ι => a) = lift.{v} #ι * lift.{u} a :=
inductionOn a fun α =>
mk_congr <|
calc
(Σ _ : ι, Quotient.out #α) ≃ ι × Quotient.out #α := Equiv.sigmaEquivProd _ _
_ ≃ ULift ι × ULift α := Equiv.ulift.symm.prodCongr (outMkEquiv.trans Equiv.ulift.symm)
#align cardinal.sum_const Cardinal.sum_const
theorem sum_const' (ι : Type u) (a : Cardinal.{u}) : (sum fun _ : ι => a) = #ι * a := by simp
#align cardinal.sum_const' Cardinal.sum_const'
@[simp]
theorem sum_add_distrib {ι} (f g : ι → Cardinal) : sum (f + g) = sum f + sum g := by
have := mk_congr (Equiv.sigmaSumDistrib (Quotient.out ∘ f) (Quotient.out ∘ g))
simp only [comp_apply, mk_sigma, mk_sum, mk_out, lift_id] at this
exact this
#align cardinal.sum_add_distrib Cardinal.sum_add_distrib
@[simp]
theorem sum_add_distrib' {ι} (f g : ι → Cardinal) :
(Cardinal.sum fun i => f i + g i) = sum f + sum g :=
sum_add_distrib f g
#align cardinal.sum_add_distrib' Cardinal.sum_add_distrib'
@[simp]
theorem lift_sum {ι : Type u} (f : ι → Cardinal.{v}) :
Cardinal.lift.{w} (Cardinal.sum f) = Cardinal.sum fun i => Cardinal.lift.{w} (f i) :=
Equiv.cardinal_eq <|
Equiv.ulift.trans <|
Equiv.sigmaCongrRight fun a =>
-- Porting note: Inserted universe hint .{_,_,v} below
Nonempty.some <| by rw [← lift_mk_eq.{_,_,v}, mk_out, mk_out, lift_lift]
#align cardinal.lift_sum Cardinal.lift_sum
theorem sum_le_sum {ι} (f g : ι → Cardinal) (H : ∀ i, f i ≤ g i) : sum f ≤ sum g :=
⟨(Embedding.refl _).sigmaMap fun i =>
Classical.choice <| by have := H i; rwa [← Quot.out_eq (f i), ← Quot.out_eq (g i)] at this⟩
#align cardinal.sum_le_sum Cardinal.sum_le_sum
theorem mk_le_mk_mul_of_mk_preimage_le {c : Cardinal} (f : α → β) (hf : ∀ b : β, #(f ⁻¹' {b}) ≤ c) :
#α ≤ #β * c := by
simpa only [← mk_congr (@Equiv.sigmaFiberEquiv α β f), mk_sigma, ← sum_const'] using
sum_le_sum _ _ hf
#align cardinal.mk_le_mk_mul_of_mk_preimage_le Cardinal.mk_le_mk_mul_of_mk_preimage_le
theorem lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le {α : Type u} {β : Type v} {c : Cardinal}
(f : α → β) (hf : ∀ b : β, lift.{v} #(f ⁻¹' {b}) ≤ c) : lift.{v} #α ≤ lift.{u} #β * c :=
(mk_le_mk_mul_of_mk_preimage_le fun x : ULift.{v} α => ULift.up.{u} (f x.1)) <|
ULift.forall.2 fun b =>
(mk_congr <|
(Equiv.ulift.image _).trans
(Equiv.trans
(by
rw [Equiv.image_eq_preimage]
/- Porting note: Need to insert the following `have` b/c bad fun coercion
behaviour for Equivs -/
have : DFunLike.coe (Equiv.symm (Equiv.ulift (α := α))) = ULift.up (α := α) := rfl
rw [this]
simp only [preimage, mem_singleton_iff, ULift.up_inj, mem_setOf_eq, coe_setOf]
exact Equiv.refl _)
Equiv.ulift.symm)).trans_le
(hf b)
#align cardinal.lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le Cardinal.lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le
/-- The range of an indexed cardinal function, whose outputs live in a higher universe than the
inputs, is always bounded above. -/
theorem bddAbove_range {ι : Type u} (f : ι → Cardinal.{max u v}) : BddAbove (Set.range f) :=
⟨_, by
rintro a ⟨i, rfl⟩
-- Porting note: Added universe reference below
exact le_sum.{v,u} f i⟩
#align cardinal.bdd_above_range Cardinal.bddAbove_range
instance (a : Cardinal.{u}) : Small.{u} (Set.Iic a) := by
rw [← mk_out a]
apply @small_of_surjective (Set a.out) (Iic #a.out) _ fun x => ⟨#x, mk_set_le x⟩
rintro ⟨x, hx⟩
simpa using le_mk_iff_exists_set.1 hx
instance (a : Cardinal.{u}) : Small.{u} (Set.Iio a) :=
small_subset Iio_subset_Iic_self
/-- A set of cardinals is bounded above iff it's small, i.e. it corresponds to a usual ZFC set. -/
theorem bddAbove_iff_small {s : Set Cardinal.{u}} : BddAbove s ↔ Small.{u} s :=
⟨fun ⟨a, ha⟩ => @small_subset _ (Iic a) s (fun x h => ha h) _, by
rintro ⟨ι, ⟨e⟩⟩
suffices (range fun x : ι => (e.symm x).1) = s by
rw [← this]
apply bddAbove_range.{u, u}
ext x
refine ⟨?_, fun hx => ⟨e ⟨x, hx⟩, ?_⟩⟩
· rintro ⟨a, rfl⟩
exact (e.symm a).2
· simp_rw [Equiv.symm_apply_apply]⟩
#align cardinal.bdd_above_iff_small Cardinal.bddAbove_iff_small
theorem bddAbove_of_small (s : Set Cardinal.{u}) [h : Small.{u} s] : BddAbove s :=
bddAbove_iff_small.2 h
#align cardinal.bdd_above_of_small Cardinal.bddAbove_of_small
theorem bddAbove_image (f : Cardinal.{u} → Cardinal.{max u v}) {s : Set Cardinal.{u}}
(hs : BddAbove s) : BddAbove (f '' s) := by
rw [bddAbove_iff_small] at hs ⊢
-- Porting note: added universes below
exact small_lift.{_,v,_} _
#align cardinal.bdd_above_image Cardinal.bddAbove_image
theorem bddAbove_range_comp {ι : Type u} {f : ι → Cardinal.{v}} (hf : BddAbove (range f))
(g : Cardinal.{v} → Cardinal.{max v w}) : BddAbove (range (g ∘ f)) := by
rw [range_comp]
exact bddAbove_image.{v,w} g hf
#align cardinal.bdd_above_range_comp Cardinal.bddAbove_range_comp
theorem iSup_le_sum {ι} (f : ι → Cardinal) : iSup f ≤ sum f :=
ciSup_le' <| le_sum.{u_2,u_1} _
#align cardinal.supr_le_sum Cardinal.iSup_le_sum
-- Porting note: Added universe hint .{v,_} below
theorem sum_le_iSup_lift {ι : Type u}
(f : ι → Cardinal.{max u v}) : sum f ≤ Cardinal.lift.{v,_} #ι * iSup f := by
rw [← (iSup f).lift_id, ← lift_umax, lift_umax.{max u v, u}, ← sum_const]
exact sum_le_sum _ _ (le_ciSup <| bddAbove_range.{u, v} f)
#align cardinal.sum_le_supr_lift Cardinal.sum_le_iSup_lift
theorem sum_le_iSup {ι : Type u} (f : ι → Cardinal.{u}) : sum f ≤ #ι * iSup f := by
rw [← lift_id #ι]
exact sum_le_iSup_lift f
#align cardinal.sum_le_supr Cardinal.sum_le_iSup
theorem sum_nat_eq_add_sum_succ (f : ℕ → Cardinal.{u}) :
Cardinal.sum f = f 0 + Cardinal.sum fun i => f (i + 1) := by
refine (Equiv.sigmaNatSucc fun i => Quotient.out (f i)).cardinal_eq.trans ?_
simp only [mk_sum, mk_out, lift_id, mk_sigma]
#align cardinal.sum_nat_eq_add_sum_succ Cardinal.sum_nat_eq_add_sum_succ
-- Porting note: LFS is not in normal form.
-- @[simp]
/-- A variant of `ciSup_of_empty` but with `0` on the RHS for convenience -/
protected theorem iSup_of_empty {ι} (f : ι → Cardinal) [IsEmpty ι] : iSup f = 0 :=
ciSup_of_empty f
#align cardinal.supr_of_empty Cardinal.iSup_of_empty
lemma exists_eq_of_iSup_eq_of_not_isSuccLimit
{ι : Type u} (f : ι → Cardinal.{v}) (ω : Cardinal.{v})
(hω : ¬ Order.IsSuccLimit ω)
(h : ⨆ i : ι, f i = ω) : ∃ i, f i = ω := by
subst h
refine (isLUB_csSup' ?_).exists_of_not_isSuccLimit hω
contrapose! hω with hf
rw [iSup, csSup_of_not_bddAbove hf, csSup_empty]
exact Order.isSuccLimit_bot
lemma exists_eq_of_iSup_eq_of_not_isLimit
{ι : Type u} [hι : Nonempty ι] (f : ι → Cardinal.{v}) (hf : BddAbove (range f))
(ω : Cardinal.{v}) (hω : ¬ ω.IsLimit)
(h : ⨆ i : ι, f i = ω) : ∃ i, f i = ω := by
refine (not_and_or.mp hω).elim (fun e ↦ ⟨hι.some, ?_⟩)
(Cardinal.exists_eq_of_iSup_eq_of_not_isSuccLimit.{u, v} f ω · h)
cases not_not.mp e
rw [← le_zero_iff] at h ⊢
exact (le_ciSup hf _).trans h
-- Porting note: simpNF is not happy with universe levels.
@[simp, nolint simpNF]
theorem lift_mk_shrink (α : Type u) [Small.{v} α] :
Cardinal.lift.{max u w} #(Shrink.{v} α) = Cardinal.lift.{max v w} #α :=
-- Porting note: Added .{v,u,w} universe hint below
lift_mk_eq.{v,u,w}.2 ⟨(equivShrink α).symm⟩
#align cardinal.lift_mk_shrink Cardinal.lift_mk_shrink
@[simp]
theorem lift_mk_shrink' (α : Type u) [Small.{v} α] :
Cardinal.lift.{u} #(Shrink.{v} α) = Cardinal.lift.{v} #α :=
lift_mk_shrink.{u, v, 0} α
#align cardinal.lift_mk_shrink' Cardinal.lift_mk_shrink'
@[simp]
theorem lift_mk_shrink'' (α : Type max u v) [Small.{v} α] :
Cardinal.lift.{u} #(Shrink.{v} α) = #α := by
rw [← lift_umax', lift_mk_shrink.{max u v, v, 0} α, ← lift_umax, lift_id]
#align cardinal.lift_mk_shrink'' Cardinal.lift_mk_shrink''
/-- The indexed product of cardinals is the cardinality of the Pi type
(dependent product). -/
def prod {ι : Type u} (f : ι → Cardinal) : Cardinal :=
#(∀ i, (f i).out)
#align cardinal.prod Cardinal.prod
@[simp]
theorem mk_pi {ι : Type u} (α : ι → Type v) : #(∀ i, α i) = prod fun i => #(α i) :=
mk_congr <| Equiv.piCongrRight fun _ => outMkEquiv.symm
#align cardinal.mk_pi Cardinal.mk_pi
@[simp]
theorem prod_const (ι : Type u) (a : Cardinal.{v}) :
(prod fun _ : ι => a) = lift.{u} a ^ lift.{v} #ι :=
inductionOn a fun _ =>
mk_congr <| Equiv.piCongr Equiv.ulift.symm fun _ => outMkEquiv.trans Equiv.ulift.symm
#align cardinal.prod_const Cardinal.prod_const
theorem prod_const' (ι : Type u) (a : Cardinal.{u}) : (prod fun _ : ι => a) = a ^ #ι :=
inductionOn a fun _ => (mk_pi _).symm
#align cardinal.prod_const' Cardinal.prod_const'
theorem prod_le_prod {ι} (f g : ι → Cardinal) (H : ∀ i, f i ≤ g i) : prod f ≤ prod g :=
⟨Embedding.piCongrRight fun i =>
Classical.choice <| by have := H i; rwa [← mk_out (f i), ← mk_out (g i)] at this⟩
#align cardinal.prod_le_prod Cardinal.prod_le_prod
@[simp]
theorem prod_eq_zero {ι} (f : ι → Cardinal.{u}) : prod f = 0 ↔ ∃ i, f i = 0 := by
lift f to ι → Type u using fun _ => trivial
simp only [mk_eq_zero_iff, ← mk_pi, isEmpty_pi]
#align cardinal.prod_eq_zero Cardinal.prod_eq_zero
theorem prod_ne_zero {ι} (f : ι → Cardinal) : prod f ≠ 0 ↔ ∀ i, f i ≠ 0 := by simp [prod_eq_zero]
#align cardinal.prod_ne_zero Cardinal.prod_ne_zero
@[simp]
theorem lift_prod {ι : Type u} (c : ι → Cardinal.{v}) :
lift.{w} (prod c) = prod fun i => lift.{w} (c i) := by
lift c to ι → Type v using fun _ => trivial
simp only [← mk_pi, ← mk_uLift]
exact mk_congr (Equiv.ulift.trans <| Equiv.piCongrRight fun i => Equiv.ulift.symm)
#align cardinal.lift_prod Cardinal.lift_prod
theorem prod_eq_of_fintype {α : Type u} [h : Fintype α] (f : α → Cardinal.{v}) :
prod f = Cardinal.lift.{u} (∏ i, f i) := by
revert f
refine Fintype.induction_empty_option ?_ ?_ ?_ α (h_fintype := h)
· intro α β hβ e h f
letI := Fintype.ofEquiv β e.symm
rw [← e.prod_comp f, ← h]
exact mk_congr (e.piCongrLeft _).symm
· intro f
rw [Fintype.univ_pempty, Finset.prod_empty, lift_one, Cardinal.prod, mk_eq_one]
· intro α hα h f
rw [Cardinal.prod, mk_congr Equiv.piOptionEquivProd, mk_prod, lift_umax'.{v, u}, mk_out, ←
Cardinal.prod, lift_prod, Fintype.prod_option, lift_mul, ← h fun a => f (some a)]
simp only [lift_id]
#align cardinal.prod_eq_of_fintype Cardinal.prod_eq_of_fintype
-- Porting note: Inserted .{u,v} below
@[simp]
theorem lift_sInf (s : Set Cardinal) : lift.{u,v} (sInf s) = sInf (lift.{u,v} '' s) := by
rcases eq_empty_or_nonempty s with (rfl | hs)
· simp
· exact lift_monotone.map_csInf hs
#align cardinal.lift_Inf Cardinal.lift_sInf
-- Porting note: Inserted .{u,v} below
@[simp]
theorem lift_iInf {ι} (f : ι → Cardinal) : lift.{u,v} (iInf f) = ⨅ i, lift.{u,v} (f i) := by
unfold iInf
convert lift_sInf (range f)
simp_rw [← comp_apply (f := lift), range_comp]
#align cardinal.lift_infi Cardinal.lift_iInf
theorem lift_down {a : Cardinal.{u}} {b : Cardinal.{max u v}} :
b ≤ lift.{v,u} a → ∃ a', lift.{v,u} a' = b :=
inductionOn₂ a b fun α β => by
rw [← lift_id #β, ← lift_umax, ← lift_umax.{u, v}, lift_mk_le.{v}]
exact fun ⟨f⟩ =>
⟨#(Set.range f),
Eq.symm <| lift_mk_eq.{_, _, v}.2
⟨Function.Embedding.equivOfSurjective (Embedding.codRestrict _ f Set.mem_range_self)
fun ⟨a, ⟨b, e⟩⟩ => ⟨b, Subtype.eq e⟩⟩⟩
#align cardinal.lift_down Cardinal.lift_down
-- Porting note: Inserted .{u,v} below
theorem le_lift_iff {a : Cardinal.{u}} {b : Cardinal.{max u v}} :
b ≤ lift.{v,u} a ↔ ∃ a', lift.{v,u} a' = b ∧ a' ≤ a :=
⟨fun h =>
let ⟨a', e⟩ := lift_down h
⟨a', e, lift_le.1 <| e.symm ▸ h⟩,
fun ⟨_, e, h⟩ => e ▸ lift_le.2 h⟩
#align cardinal.le_lift_iff Cardinal.le_lift_iff
-- Porting note: Inserted .{u,v} below
theorem lt_lift_iff {a : Cardinal.{u}} {b : Cardinal.{max u v}} :
b < lift.{v,u} a ↔ ∃ a', lift.{v,u} a' = b ∧ a' < a :=
⟨fun h =>
let ⟨a', e⟩ := lift_down h.le
⟨a', e, lift_lt.1 <| e.symm ▸ h⟩,
fun ⟨_, e, h⟩ => e ▸ lift_lt.2 h⟩
#align cardinal.lt_lift_iff Cardinal.lt_lift_iff
-- Porting note: Inserted .{u,v} below
@[simp]
theorem lift_succ (a) : lift.{v,u} (succ a) = succ (lift.{v,u} a) :=
le_antisymm
(le_of_not_gt fun h => by
rcases lt_lift_iff.1 h with ⟨b, e, h⟩
rw [lt_succ_iff, ← lift_le, e] at h
exact h.not_lt (lt_succ _))
(succ_le_of_lt <| lift_lt.2 <| lt_succ a)
#align cardinal.lift_succ Cardinal.lift_succ
-- Porting note: simpNF is not happy with universe levels.
-- Porting note: Inserted .{u,v} below
@[simp, nolint simpNF]
theorem lift_umax_eq {a : Cardinal.{u}} {b : Cardinal.{v}} :
lift.{max v w} a = lift.{max u w} b ↔ lift.{v} a = lift.{u} b := by
rw [← lift_lift.{v, w, u}, ← lift_lift.{u, w, v}, lift_inj]
#align cardinal.lift_umax_eq Cardinal.lift_umax_eq
-- Porting note: Inserted .{u,v} below
@[simp]
theorem lift_min {a b : Cardinal} : lift.{u,v} (min a b) = min (lift.{u,v} a) (lift.{u,v} b) :=
lift_monotone.map_min
#align cardinal.lift_min Cardinal.lift_min
-- Porting note: Inserted .{u,v} below
@[simp]
theorem lift_max {a b : Cardinal} : lift.{u,v} (max a b) = max (lift.{u,v} a) (lift.{u,v} b) :=
lift_monotone.map_max
#align cardinal.lift_max Cardinal.lift_max
/-- The lift of a supremum is the supremum of the lifts. -/
theorem lift_sSup {s : Set Cardinal} (hs : BddAbove s) :
lift.{u} (sSup s) = sSup (lift.{u} '' s) := by
apply ((le_csSup_iff' (bddAbove_image.{_,u} _ hs)).2 fun c hc => _).antisymm (csSup_le' _)
· intro c hc
by_contra h
obtain ⟨d, rfl⟩ := Cardinal.lift_down (not_le.1 h).le
simp_rw [lift_le] at h hc
rw [csSup_le_iff' hs] at h
exact h fun a ha => lift_le.1 <| hc (mem_image_of_mem _ ha)
· rintro i ⟨j, hj, rfl⟩
exact lift_le.2 (le_csSup hs hj)
#align cardinal.lift_Sup Cardinal.lift_sSup
/-- The lift of a supremum is the supremum of the lifts. -/
theorem lift_iSup {ι : Type v} {f : ι → Cardinal.{w}} (hf : BddAbove (range f)) :
lift.{u} (iSup f) = ⨆ i, lift.{u} (f i) := by
rw [iSup, iSup, lift_sSup hf, ← range_comp]
simp [Function.comp]
#align cardinal.lift_supr Cardinal.lift_iSup
/-- To prove that the lift of a supremum is bounded by some cardinal `t`,
it suffices to show that the lift of each cardinal is bounded by `t`. -/
theorem lift_iSup_le {ι : Type v} {f : ι → Cardinal.{w}} {t : Cardinal} (hf : BddAbove (range f))
(w : ∀ i, lift.{u} (f i) ≤ t) : lift.{u} (iSup f) ≤ t := by
rw [lift_iSup hf]
exact ciSup_le' w
#align cardinal.lift_supr_le Cardinal.lift_iSup_le
@[simp]
theorem lift_iSup_le_iff {ι : Type v} {f : ι → Cardinal.{w}} (hf : BddAbove (range f))
{t : Cardinal} : lift.{u} (iSup f) ≤ t ↔ ∀ i, lift.{u} (f i) ≤ t := by
rw [lift_iSup hf]
exact ciSup_le_iff' (bddAbove_range_comp.{_,_,u} hf _)
#align cardinal.lift_supr_le_iff Cardinal.lift_iSup_le_iff
universe v' w'
/-- To prove an inequality between the lifts to a common universe of two different supremums,
it suffices to show that the lift of each cardinal from the smaller supremum
if bounded by the lift of some cardinal from the larger supremum.
-/
theorem lift_iSup_le_lift_iSup {ι : Type v} {ι' : Type v'} {f : ι → Cardinal.{w}}
{f' : ι' → Cardinal.{w'}} (hf : BddAbove (range f)) (hf' : BddAbove (range f')) {g : ι → ι'}
(h : ∀ i, lift.{w'} (f i) ≤ lift.{w} (f' (g i))) : lift.{w'} (iSup f) ≤ lift.{w} (iSup f') := by
rw [lift_iSup hf, lift_iSup hf']
exact ciSup_mono' (bddAbove_range_comp.{_,_,w} hf' _) fun i => ⟨_, h i⟩
#align cardinal.lift_supr_le_lift_supr Cardinal.lift_iSup_le_lift_iSup
/-- A variant of `lift_iSup_le_lift_iSup` with universes specialized via `w = v` and `w' = v'`.
This is sometimes necessary to avoid universe unification issues. -/
theorem lift_iSup_le_lift_iSup' {ι : Type v} {ι' : Type v'} {f : ι → Cardinal.{v}}
{f' : ι' → Cardinal.{v'}} (hf : BddAbove (range f)) (hf' : BddAbove (range f')) (g : ι → ι')
(h : ∀ i, lift.{v'} (f i) ≤ lift.{v} (f' (g i))) : lift.{v'} (iSup f) ≤ lift.{v} (iSup f') :=
lift_iSup_le_lift_iSup hf hf' h
#align cardinal.lift_supr_le_lift_supr' Cardinal.lift_iSup_le_lift_iSup'
/-- `ℵ₀` is the smallest infinite cardinal. -/
def aleph0 : Cardinal.{u} :=
lift #ℕ
#align cardinal.aleph_0 Cardinal.aleph0
@[inherit_doc]
scoped notation "ℵ₀" => Cardinal.aleph0
theorem mk_nat : #ℕ = ℵ₀ :=
(lift_id _).symm
#align cardinal.mk_nat Cardinal.mk_nat
theorem aleph0_ne_zero : ℵ₀ ≠ 0 :=
mk_ne_zero _
#align cardinal.aleph_0_ne_zero Cardinal.aleph0_ne_zero
theorem aleph0_pos : 0 < ℵ₀ :=
pos_iff_ne_zero.2 aleph0_ne_zero
#align cardinal.aleph_0_pos Cardinal.aleph0_pos
@[simp]
theorem lift_aleph0 : lift ℵ₀ = ℵ₀ :=
lift_lift _
#align cardinal.lift_aleph_0 Cardinal.lift_aleph0
@[simp]
theorem aleph0_le_lift {c : Cardinal.{u}} : ℵ₀ ≤ lift.{v} c ↔ ℵ₀ ≤ c := by
rw [← lift_aleph0.{u,v}, lift_le]
#align cardinal.aleph_0_le_lift Cardinal.aleph0_le_lift
@[simp]
theorem lift_le_aleph0 {c : Cardinal.{u}} : lift.{v} c ≤ ℵ₀ ↔ c ≤ ℵ₀ := by
rw [← lift_aleph0.{u,v}, lift_le]
#align cardinal.lift_le_aleph_0 Cardinal.lift_le_aleph0
@[simp]
theorem aleph0_lt_lift {c : Cardinal.{u}} : ℵ₀ < lift.{v} c ↔ ℵ₀ < c := by
rw [← lift_aleph0.{u,v}, lift_lt]
#align cardinal.aleph_0_lt_lift Cardinal.aleph0_lt_lift
@[simp]
theorem lift_lt_aleph0 {c : Cardinal.{u}} : lift.{v} c < ℵ₀ ↔ c < ℵ₀ := by
rw [← lift_aleph0.{u,v}, lift_lt]
#align cardinal.lift_lt_aleph_0 Cardinal.lift_lt_aleph0
/-! ### Properties about the cast from `ℕ` -/
section castFromN
-- porting note (#10618): simp can prove this
-- @[simp]
theorem mk_fin (n : ℕ) : #(Fin n) = n := by simp
#align cardinal.mk_fin Cardinal.mk_fin
@[simp]
theorem lift_natCast (n : ℕ) : lift.{u} (n : Cardinal.{v}) = n := by induction n <;> simp [*]
#align cardinal.lift_nat_cast Cardinal.lift_natCast
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem lift_ofNat (n : ℕ) [n.AtLeastTwo] :
lift.{u} (no_index (OfNat.ofNat n : Cardinal.{v})) = OfNat.ofNat n :=
lift_natCast n
@[simp]
theorem lift_eq_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a = n ↔ a = n :=
lift_injective.eq_iff' (lift_natCast n)
#align cardinal.lift_eq_nat_iff Cardinal.lift_eq_nat_iff
@[simp]
theorem lift_eq_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
lift.{v} a = (no_index (OfNat.ofNat n)) ↔ a = OfNat.ofNat n :=
lift_eq_nat_iff
@[simp]
theorem nat_eq_lift_iff {n : ℕ} {a : Cardinal.{u}} :
(n : Cardinal) = lift.{v} a ↔ (n : Cardinal) = a := by
rw [← lift_natCast.{v,u} n, lift_inj]
#align cardinal.nat_eq_lift_iff Cardinal.nat_eq_lift_iff
@[simp]
theorem zero_eq_lift_iff {a : Cardinal.{u}} :
(0 : Cardinal) = lift.{v} a ↔ 0 = a := by
simpa using nat_eq_lift_iff (n := 0)
@[simp]
theorem one_eq_lift_iff {a : Cardinal.{u}} :
(1 : Cardinal) = lift.{v} a ↔ 1 = a := by
simpa using nat_eq_lift_iff (n := 1)
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_eq_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
(no_index (OfNat.ofNat n : Cardinal)) = lift.{v} a ↔ (OfNat.ofNat n : Cardinal) = a :=
nat_eq_lift_iff
@[simp]
theorem lift_le_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a ≤ n ↔ a ≤ n := by
rw [← lift_natCast.{v,u}, lift_le]
#align cardinal.lift_le_nat_iff Cardinal.lift_le_nat_iff
@[simp]
theorem lift_le_one_iff {a : Cardinal.{u}} :
lift.{v} a ≤ 1 ↔ a ≤ 1 := by
simpa using lift_le_nat_iff (n := 1)
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem lift_le_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
lift.{v} a ≤ (no_index (OfNat.ofNat n)) ↔ a ≤ OfNat.ofNat n :=
lift_le_nat_iff
@[simp]
theorem nat_le_lift_iff {n : ℕ} {a : Cardinal.{u}} : n ≤ lift.{v} a ↔ n ≤ a := by
rw [← lift_natCast.{v,u}, lift_le]
#align cardinal.nat_le_lift_iff Cardinal.nat_le_lift_iff
@[simp]
theorem one_le_lift_iff {a : Cardinal.{u}} :
(1 : Cardinal) ≤ lift.{v} a ↔ 1 ≤ a := by
simpa using nat_le_lift_iff (n := 1)
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_le_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
(no_index (OfNat.ofNat n : Cardinal)) ≤ lift.{v} a ↔ (OfNat.ofNat n : Cardinal) ≤ a :=
nat_le_lift_iff
@[simp]
theorem lift_lt_nat_iff {a : Cardinal.{u}} {n : ℕ} : lift.{v} a < n ↔ a < n := by
rw [← lift_natCast.{v,u}, lift_lt]
#align cardinal.lift_lt_nat_iff Cardinal.lift_lt_nat_iff
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem lift_lt_ofNat_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
lift.{v} a < (no_index (OfNat.ofNat n)) ↔ a < OfNat.ofNat n :=
lift_lt_nat_iff
@[simp]
theorem nat_lt_lift_iff {n : ℕ} {a : Cardinal.{u}} : n < lift.{v} a ↔ n < a := by
rw [← lift_natCast.{v,u}, lift_lt]
#align cardinal.nat_lt_lift_iff Cardinal.nat_lt_lift_iff
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem zero_lt_lift_iff {a : Cardinal.{u}} :
(0 : Cardinal) < lift.{v} a ↔ 0 < a := by
simpa using nat_lt_lift_iff (n := 0)
@[simp]
theorem one_lt_lift_iff {a : Cardinal.{u}} :
(1 : Cardinal) < lift.{v} a ↔ 1 < a := by
simpa using nat_lt_lift_iff (n := 1)
-- See note [no_index around OfNat.ofNat]
@[simp]
theorem ofNat_lt_lift_iff {a : Cardinal.{u}} {n : ℕ} [n.AtLeastTwo] :
(no_index (OfNat.ofNat n : Cardinal)) < lift.{v} a ↔ (OfNat.ofNat n : Cardinal) < a :=
nat_lt_lift_iff
theorem lift_mk_fin (n : ℕ) : lift #(Fin n) = n := rfl
#align cardinal.lift_mk_fin Cardinal.lift_mk_fin
theorem mk_coe_finset {α : Type u} {s : Finset α} : #s = ↑(Finset.card s) := by simp
#align cardinal.mk_coe_finset Cardinal.mk_coe_finset
theorem mk_finset_of_fintype [Fintype α] : #(Finset α) = 2 ^ Fintype.card α := by
simp [Pow.pow]
#align cardinal.mk_finset_of_fintype Cardinal.mk_finset_of_fintype
@[simp]
theorem mk_finsupp_lift_of_fintype (α : Type u) (β : Type v) [Fintype α] [Zero β] :
#(α →₀ β) = lift.{u} #β ^ Fintype.card α := by
simpa using (@Finsupp.equivFunOnFinite α β _ _).cardinal_eq
#align cardinal.mk_finsupp_lift_of_fintype Cardinal.mk_finsupp_lift_of_fintype
theorem mk_finsupp_of_fintype (α β : Type u) [Fintype α] [Zero β] :
#(α →₀ β) = #β ^ Fintype.card α := by simp
#align cardinal.mk_finsupp_of_fintype Cardinal.mk_finsupp_of_fintype
theorem card_le_of_finset {α} (s : Finset α) : (s.card : Cardinal) ≤ #α :=
@mk_coe_finset _ s ▸ mk_set_le _
#align cardinal.card_le_of_finset Cardinal.card_le_of_finset
-- Porting note: was `simp`. LHS is not normal form.
-- @[simp, norm_cast]
@[norm_cast]
theorem natCast_pow {m n : ℕ} : (↑(m ^ n) : Cardinal) = (↑m : Cardinal) ^ (↑n : Cardinal) := by
induction n <;> simp [pow_succ, power_add, *, Pow.pow]
#align cardinal.nat_cast_pow Cardinal.natCast_pow
-- porting note (#10618): simp can prove this
-- @[simp, norm_cast]
@[norm_cast]
theorem natCast_le {m n : ℕ} : (m : Cardinal) ≤ n ↔ m ≤ n := by
rw [← lift_mk_fin, ← lift_mk_fin, lift_le, le_def, Function.Embedding.nonempty_iff_card_le,
Fintype.card_fin, Fintype.card_fin]
#align cardinal.nat_cast_le Cardinal.natCast_le
-- porting note (#10618): simp can prove this
-- @[simp, norm_cast]
@[norm_cast]
theorem natCast_lt {m n : ℕ} : (m : Cardinal) < n ↔ m < n := by
rw [lt_iff_le_not_le, ← not_le]
simp only [natCast_le, not_le, and_iff_right_iff_imp]
exact fun h ↦ le_of_lt h
#align cardinal.nat_cast_lt Cardinal.natCast_lt
instance : CharZero Cardinal :=
⟨StrictMono.injective fun _ _ => natCast_lt.2⟩
theorem natCast_inj {m n : ℕ} : (m : Cardinal) = n ↔ m = n :=
Nat.cast_inj
#align cardinal.nat_cast_inj Cardinal.natCast_inj
theorem natCast_injective : Injective ((↑) : ℕ → Cardinal) :=
Nat.cast_injective
#align cardinal.nat_cast_injective Cardinal.natCast_injective
@[norm_cast]
theorem nat_succ (n : ℕ) : (n.succ : Cardinal) = succ ↑n := by
rw [Nat.cast_succ]
refine (add_one_le_succ _).antisymm (succ_le_of_lt ?_)
rw [← Nat.cast_succ]
exact natCast_lt.2 (Nat.lt_succ_self _)
lemma succ_natCast (n : ℕ) : Order.succ (n : Cardinal) = n + 1 := by
rw [← Cardinal.nat_succ]
norm_cast
lemma natCast_add_one_le_iff {n : ℕ} {c : Cardinal} : n + 1 ≤ c ↔ n < c := by
rw [← Order.succ_le_iff, Cardinal.succ_natCast]
lemma two_le_iff_one_lt {c : Cardinal} : 2 ≤ c ↔ 1 < c := by
convert natCast_add_one_le_iff
norm_cast
@[simp]
theorem succ_zero : succ (0 : Cardinal) = 1 := by norm_cast
#align cardinal.succ_zero Cardinal.succ_zero
theorem exists_finset_le_card (α : Type*) (n : ℕ) (h : n ≤ #α) :
∃ s : Finset α, n ≤ s.card := by
obtain hα|hα := finite_or_infinite α
· let hα := Fintype.ofFinite α
use Finset.univ
simpa only [mk_fintype, Nat.cast_le] using h
· obtain ⟨s, hs⟩ := Infinite.exists_subset_card_eq α n
exact ⟨s, hs.ge⟩
theorem card_le_of {α : Type u} {n : ℕ} (H : ∀ s : Finset α, s.card ≤ n) : #α ≤ n := by
contrapose! H
apply exists_finset_le_card α (n+1)
simpa only [nat_succ, succ_le_iff] using H
#align cardinal.card_le_of Cardinal.card_le_of
| Mathlib/SetTheory/Cardinal/Basic.lean | 1,521 | 1,523 | theorem cantor' (a) {b : Cardinal} (hb : 1 < b) : a < b ^ a := by |
rw [← succ_le_iff, (by norm_cast : succ (1 : Cardinal) = 2)] at hb
exact (cantor a).trans_le (power_le_power_right hb)
|
/-
Copyright (c) 2022 Kyle Miller, Adam Topaz, Rémi Bottinelli, Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kyle Miller, Adam Topaz, Rémi Bottinelli, Junyan Xu
-/
import Mathlib.CategoryTheory.Filtered.Basic
import Mathlib.Data.Set.Finite
import Mathlib.Data.Set.Subsingleton
import Mathlib.Topology.Category.TopCat.Limits.Konig
import Mathlib.Tactic.AdaptationNote
#align_import category_theory.cofiltered_system from "leanprover-community/mathlib"@"178a32653e369dce2da68dc6b2694e385d484ef1"
/-!
# Cofiltered systems
This file deals with properties of cofiltered (and inverse) systems.
## Main definitions
Given a functor `F : J ⥤ Type v`:
* For `j : J`, `F.eventualRange j` is the intersections of all ranges of morphisms `F.map f`
where `f` has codomain `j`.
* `F.IsMittagLeffler` states that the functor `F` satisfies the Mittag-Leffler
condition: the ranges of morphisms `F.map f` (with `f` having codomain `j`) stabilize.
* If `J` is cofiltered `F.toEventualRanges` is the subfunctor of `F` obtained by restriction
to `F.eventualRange`.
* `F.toPreimages` restricts a functor to preimages of a given set in some `F.obj i`. If `J` is
cofiltered, then it is Mittag-Leffler if `F` is, see `IsMittagLeffler.toPreimages`.
## Main statements
* `nonempty_sections_of_finite_cofiltered_system` shows that if `J` is cofiltered and each
`F.obj j` is nonempty and finite, `F.sections` is nonempty.
* `nonempty_sections_of_finite_inverse_system` is a specialization of the above to `J` being a
directed set (and `F : Jᵒᵖ ⥤ Type v`).
* `isMittagLeffler_of_exists_finite_range` shows that if `J` is cofiltered and for all `j`,
there exists some `i` and `f : i ⟶ j` such that the range of `F.map f` is finite, then
`F` is Mittag-Leffler.
* `surjective_toEventualRanges` shows that if `F` is Mittag-Leffler, then `F.toEventualRanges`
has all morphisms `F.map f` surjective.
## Todo
* Prove [Stacks: Lemma 0597](https://stacks.math.columbia.edu/tag/0597)
## References
* [Stacks: Mittag-Leffler systems](https://stacks.math.columbia.edu/tag/0594)
## Tags
Mittag-Leffler, surjective, eventual range, inverse system,
-/
universe u v w
open CategoryTheory CategoryTheory.IsCofiltered Set CategoryTheory.FunctorToTypes
section FiniteKonig
/-- This bootstraps `nonempty_sections_of_finite_inverse_system`. In this version,
the `F` functor is between categories of the same universe, and it is an easy
corollary to `TopCat.nonempty_limitCone_of_compact_t2_cofiltered_system`. -/
theorem nonempty_sections_of_finite_cofiltered_system.init {J : Type u} [SmallCategory J]
[IsCofilteredOrEmpty J] (F : J ⥤ Type u) [hf : ∀ j, Finite (F.obj j)]
[hne : ∀ j, Nonempty (F.obj j)] : F.sections.Nonempty := by
let F' : J ⥤ TopCat := F ⋙ TopCat.discrete
haveI : ∀ j, DiscreteTopology (F'.obj j) := fun _ => ⟨rfl⟩
haveI : ∀ j, Finite (F'.obj j) := hf
haveI : ∀ j, Nonempty (F'.obj j) := hne
obtain ⟨⟨u, hu⟩⟩ := TopCat.nonempty_limitCone_of_compact_t2_cofiltered_system.{u} F'
exact ⟨u, hu⟩
#align nonempty_sections_of_finite_cofiltered_system.init nonempty_sections_of_finite_cofiltered_system.init
/-- The cofiltered limit of nonempty finite types is nonempty.
See `nonempty_sections_of_finite_inverse_system` for a specialization to inverse limits. -/
theorem nonempty_sections_of_finite_cofiltered_system {J : Type u} [Category.{w} J]
[IsCofilteredOrEmpty J] (F : J ⥤ Type v) [∀ j : J, Finite (F.obj j)]
[∀ j : J, Nonempty (F.obj j)] : F.sections.Nonempty := by
-- Step 1: lift everything to the `max u v w` universe.
let J' : Type max w v u := AsSmall.{max w v} J
let down : J' ⥤ J := AsSmall.down
let F' : J' ⥤ Type max u v w := down ⋙ F ⋙ uliftFunctor.{max u w, v}
haveI : ∀ i, Nonempty (F'.obj i) := fun i => ⟨⟨Classical.arbitrary (F.obj (down.obj i))⟩⟩
haveI : ∀ i, Finite (F'.obj i) := fun i => Finite.of_equiv (F.obj (down.obj i)) Equiv.ulift.symm
-- Step 2: apply the bootstrap theorem
cases isEmpty_or_nonempty J
· fconstructor <;> apply isEmptyElim
haveI : IsCofiltered J := ⟨⟩
obtain ⟨u, hu⟩ := nonempty_sections_of_finite_cofiltered_system.init F'
-- Step 3: interpret the results
use fun j => (u ⟨j⟩).down
intro j j' f
have h := @hu (⟨j⟩ : J') (⟨j'⟩ : J') (ULift.up f)
simp only [F', down, AsSmall.down, Functor.comp_map, uliftFunctor_map, Functor.op_map] at h
simp_rw [← h]
#align nonempty_sections_of_finite_cofiltered_system nonempty_sections_of_finite_cofiltered_system
/-- The inverse limit of nonempty finite types is nonempty.
See `nonempty_sections_of_finite_cofiltered_system` for a generalization to cofiltered limits.
That version applies in almost all cases, and the only difference is that this version
allows `J` to be empty.
This may be regarded as a generalization of Kőnig's lemma.
To specialize: given a locally finite connected graph, take `Jᵒᵖ` to be `ℕ` and
`F j` to be length-`j` paths that start from an arbitrary fixed vertex.
Elements of `F.sections` can be read off as infinite rays in the graph. -/
theorem nonempty_sections_of_finite_inverse_system {J : Type u} [Preorder J] [IsDirected J (· ≤ ·)]
(F : Jᵒᵖ ⥤ Type v) [∀ j : Jᵒᵖ, Finite (F.obj j)] [∀ j : Jᵒᵖ, Nonempty (F.obj j)] :
F.sections.Nonempty := by
cases isEmpty_or_nonempty J
· haveI : IsEmpty Jᵒᵖ := ⟨fun j => isEmptyElim j.unop⟩ -- TODO: this should be a global instance
exact ⟨isEmptyElim, by apply isEmptyElim⟩
· exact nonempty_sections_of_finite_cofiltered_system _
#align nonempty_sections_of_finite_inverse_system nonempty_sections_of_finite_inverse_system
end FiniteKonig
namespace CategoryTheory
namespace Functor
variable {J : Type u} [Category J] (F : J ⥤ Type v) {i j k : J} (s : Set (F.obj i))
/-- The eventual range of the functor `F : J ⥤ Type v` at index `j : J` is the intersection
of the ranges of all maps `F.map f` with `i : J` and `f : i ⟶ j`. -/
def eventualRange (j : J) :=
⋂ (i) (f : i ⟶ j), range (F.map f)
#align category_theory.functor.eventual_range CategoryTheory.Functor.eventualRange
theorem mem_eventualRange_iff {x : F.obj j} :
x ∈ F.eventualRange j ↔ ∀ ⦃i⦄ (f : i ⟶ j), x ∈ range (F.map f) :=
mem_iInter₂
#align category_theory.functor.mem_eventual_range_iff CategoryTheory.Functor.mem_eventualRange_iff
/-- The functor `F : J ⥤ Type v` satisfies the Mittag-Leffler condition if for all `j : J`,
there exists some `i : J` and `f : i ⟶ j` such that for all `k : J` and `g : k ⟶ j`, the range
of `F.map f` is contained in that of `F.map g`;
in other words (see `isMittagLeffler_iff_eventualRange`), the eventual range at `j` is attained
by some `f : i ⟶ j`. -/
def IsMittagLeffler : Prop :=
∀ j : J, ∃ (i : _) (f : i ⟶ j), ∀ ⦃k⦄ (g : k ⟶ j), range (F.map f) ⊆ range (F.map g)
#align category_theory.functor.is_mittag_leffler CategoryTheory.Functor.IsMittagLeffler
theorem isMittagLeffler_iff_eventualRange :
F.IsMittagLeffler ↔ ∀ j : J, ∃ (i : _) (f : i ⟶ j), F.eventualRange j = range (F.map f) :=
forall_congr' fun _ =>
exists₂_congr fun _ _ =>
⟨fun h => (iInter₂_subset _ _).antisymm <| subset_iInter₂ h, fun h => h ▸ iInter₂_subset⟩
#align category_theory.functor.is_mittag_leffler_iff_eventual_range CategoryTheory.Functor.isMittagLeffler_iff_eventualRange
theorem IsMittagLeffler.subset_image_eventualRange (h : F.IsMittagLeffler) (f : j ⟶ i) :
F.eventualRange i ⊆ F.map f '' F.eventualRange j := by
obtain ⟨k, g, hg⟩ := F.isMittagLeffler_iff_eventualRange.1 h j
rw [hg]; intro x hx
obtain ⟨x, rfl⟩ := F.mem_eventualRange_iff.1 hx (g ≫ f)
exact ⟨_, ⟨x, rfl⟩, by rw [map_comp_apply]⟩
#align category_theory.functor.is_mittag_leffler.subset_image_eventual_range CategoryTheory.Functor.IsMittagLeffler.subset_image_eventualRange
theorem eventualRange_eq_range_precomp (f : i ⟶ j) (g : j ⟶ k)
(h : F.eventualRange k = range (F.map g)) : F.eventualRange k = range (F.map <| f ≫ g) := by
apply subset_antisymm
· apply iInter₂_subset
· rw [h, F.map_comp]
apply range_comp_subset_range
#align category_theory.functor.eventual_range_eq_range_precomp CategoryTheory.Functor.eventualRange_eq_range_precomp
theorem isMittagLeffler_of_surjective (h : ∀ ⦃i j : J⦄ (f : i ⟶ j), (F.map f).Surjective) :
F.IsMittagLeffler :=
fun j => ⟨j, 𝟙 j, fun k g => by rw [map_id, types_id, range_id, (h g).range_eq]⟩
#align category_theory.functor.is_mittag_leffler_of_surjective CategoryTheory.Functor.isMittagLeffler_of_surjective
/-- The subfunctor of `F` obtained by restricting to the preimages of a set `s ∈ F.obj i`. -/
@[simps]
def toPreimages : J ⥤ Type v where
obj j := ⋂ f : j ⟶ i, F.map f ⁻¹' s
map g := MapsTo.restrict (F.map g) _ _ fun x h => by
rw [mem_iInter] at h ⊢
intro f
rw [← mem_preimage, preimage_preimage, mem_preimage]
convert h (g ≫ f); rw [F.map_comp]; rfl
map_id j := by
#adaptation_note /-- nightly-2024-03-16: simp was
simp (config := { unfoldPartialApp := true }) only [MapsTo.restrict, Subtype.map, F.map_id] -/
simp only [MapsTo.restrict, Subtype.map_def, F.map_id]
ext
rfl
map_comp f g := by
#adaptation_note /-- nightly-2024-03-16: simp was
simp (config := { unfoldPartialApp := true }) only [MapsTo.restrict, Subtype.map, F.map_comp] -/
simp only [MapsTo.restrict, Subtype.map_def, F.map_comp]
rfl
#align category_theory.functor.to_preimages CategoryTheory.Functor.toPreimages
instance toPreimages_finite [∀ j, Finite (F.obj j)] : ∀ j, Finite ((F.toPreimages s).obj j) :=
fun _ => Subtype.finite
#align category_theory.functor.to_preimages_finite CategoryTheory.Functor.toPreimages_finite
variable [IsCofilteredOrEmpty J]
theorem eventualRange_mapsTo (f : j ⟶ i) :
(F.eventualRange j).MapsTo (F.map f) (F.eventualRange i) := fun x hx => by
rw [mem_eventualRange_iff] at hx ⊢
intro k f'
obtain ⟨l, g, g', he⟩ := cospan f f'
obtain ⟨x, rfl⟩ := hx g
rw [← map_comp_apply, he, F.map_comp]
exact ⟨_, rfl⟩
#align category_theory.functor.eventual_range_maps_to CategoryTheory.Functor.eventualRange_mapsTo
theorem IsMittagLeffler.eq_image_eventualRange (h : F.IsMittagLeffler) (f : j ⟶ i) :
F.eventualRange i = F.map f '' F.eventualRange j :=
(h.subset_image_eventualRange F f).antisymm <| mapsTo'.1 (F.eventualRange_mapsTo f)
#align category_theory.functor.is_mittag_leffler.eq_image_eventual_range CategoryTheory.Functor.IsMittagLeffler.eq_image_eventualRange
| Mathlib/CategoryTheory/CofilteredSystem.lean | 222 | 230 | theorem eventualRange_eq_iff {f : i ⟶ j} :
F.eventualRange j = range (F.map f) ↔
∀ ⦃k⦄ (g : k ⟶ i), range (F.map f) ⊆ range (F.map <| g ≫ f) := by |
rw [subset_antisymm_iff, eventualRange, and_iff_right (iInter₂_subset _ _), subset_iInter₂_iff]
refine ⟨fun h k g => h _ _, fun h j' f' => ?_⟩
obtain ⟨k, g, g', he⟩ := cospan f f'
refine (h g).trans ?_
rw [he, F.map_comp]
apply range_comp_subset_range
|
/-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
import Mathlib.CategoryTheory.Limits.Shapes.CommSq
import Mathlib.CategoryTheory.Adjunction.Over
#align_import category_theory.limits.shapes.diagonal from "leanprover-community/mathlib"@"f6bab67886fb92c3e2f539cc90a83815f69a189d"
/-!
# The diagonal object of a morphism.
We provide various API and isomorphisms considering the diagonal object `Δ_{Y/X} := pullback f f`
of a morphism `f : X ⟶ Y`.
-/
open CategoryTheory
noncomputable section
namespace CategoryTheory.Limits
variable {C : Type*} [Category C] {X Y Z : C}
namespace pullback
section Diagonal
variable (f : X ⟶ Y) [HasPullback f f]
/-- The diagonal object of a morphism `f : X ⟶ Y` is `Δ_{X/Y} := pullback f f`. -/
abbrev diagonalObj : C :=
pullback f f
#align category_theory.limits.pullback.diagonal_obj CategoryTheory.Limits.pullback.diagonalObj
/-- The diagonal morphism `X ⟶ Δ_{X/Y}` for a morphism `f : X ⟶ Y`. -/
def diagonal : X ⟶ diagonalObj f :=
pullback.lift (𝟙 _) (𝟙 _) rfl
#align category_theory.limits.pullback.diagonal CategoryTheory.Limits.pullback.diagonal
@[reassoc (attr := simp)]
theorem diagonal_fst : diagonal f ≫ pullback.fst = 𝟙 _ :=
pullback.lift_fst _ _ _
#align category_theory.limits.pullback.diagonal_fst CategoryTheory.Limits.pullback.diagonal_fst
@[reassoc (attr := simp)]
theorem diagonal_snd : diagonal f ≫ pullback.snd = 𝟙 _ :=
pullback.lift_snd _ _ _
#align category_theory.limits.pullback.diagonal_snd CategoryTheory.Limits.pullback.diagonal_snd
instance : IsSplitMono (diagonal f) :=
⟨⟨⟨pullback.fst, diagonal_fst f⟩⟩⟩
instance : IsSplitEpi (pullback.fst : pullback f f ⟶ X) :=
⟨⟨⟨diagonal f, diagonal_fst f⟩⟩⟩
instance : IsSplitEpi (pullback.snd : pullback f f ⟶ X) :=
⟨⟨⟨diagonal f, diagonal_snd f⟩⟩⟩
instance [Mono f] : IsIso (diagonal f) := by
rw [(IsIso.inv_eq_of_inv_hom_id (diagonal_fst f)).symm]
infer_instance
/-- The two projections `Δ_{X/Y} ⟶ X` form a kernel pair for `f : X ⟶ Y`. -/
theorem diagonal_isKernelPair : IsKernelPair f (pullback.fst : diagonalObj f ⟶ _) pullback.snd :=
IsPullback.of_hasPullback f f
#align category_theory.limits.pullback.diagonal_is_kernel_pair CategoryTheory.Limits.pullback.diagonal_isKernelPair
end Diagonal
end pullback
variable [HasPullbacks C]
open pullback
section
variable {U V₁ V₂ : C} (f : X ⟶ Y) (i : U ⟶ Y)
variable (i₁ : V₁ ⟶ pullback f i) (i₂ : V₂ ⟶ pullback f i)
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_fst_fst :
(pullback.snd :
pullback (diagonal f)
(map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp [condition])
(by simp [condition])) ⟶
_) ≫
fst ≫ i₁ ≫ fst =
pullback.fst := by
conv_rhs => rw [← Category.comp_id pullback.fst]
rw [← diagonal_fst f, pullback.condition_assoc, pullback.lift_fst]
#align category_theory.limits.pullback_diagonal_map_snd_fst_fst CategoryTheory.Limits.pullback_diagonal_map_snd_fst_fst
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_snd_fst :
(pullback.snd :
pullback (diagonal f)
(map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i (by simp [condition])
(by simp [condition])) ⟶
_) ≫
snd ≫ i₂ ≫ fst =
pullback.fst := by
conv_rhs => rw [← Category.comp_id pullback.fst]
rw [← diagonal_snd f, pullback.condition_assoc, pullback.lift_snd]
#align category_theory.limits.pullback_diagonal_map_snd_snd_fst CategoryTheory.Limits.pullback_diagonal_map_snd_snd_fst
variable [HasPullback i₁ i₂]
set_option maxHeartbeats 400000 in
/-- This iso witnesses the fact that
given `f : X ⟶ Y`, `i : U ⟶ Y`, and `i₁ : V₁ ⟶ X ×[Y] U`, `i₂ : V₂ ⟶ X ×[Y] U`, the diagram
V₁ ×[X ×[Y] U] V₂ ⟶ V₁ ×[U] V₂
| |
| |
↓ ↓
X ⟶ X ×[Y] X
is a pullback square.
Also see `pullback_fst_map_snd_isPullback`.
-/
def pullbackDiagonalMapIso :
pullback (diagonal f)
(map (i₁ ≫ snd) (i₂ ≫ snd) f f (i₁ ≫ fst) (i₂ ≫ fst) i
(by simp only [Category.assoc, condition])
(by simp only [Category.assoc, condition])) ≅
pullback i₁ i₂ where
hom :=
pullback.lift (pullback.snd ≫ pullback.fst) (pullback.snd ≫ pullback.snd) (by
ext
· simp [Category.assoc, pullback_diagonal_map_snd_fst_fst, pullback_diagonal_map_snd_snd_fst]
· simp [Category.assoc, pullback.condition, pullback.condition_assoc])
inv :=
pullback.lift (pullback.fst ≫ i₁ ≫ pullback.fst)
(pullback.map _ _ _ _ (𝟙 _) (𝟙 _) pullback.snd (Category.id_comp _).symm
(Category.id_comp _).symm) (by
ext
· simp only [Category.assoc, diagonal_fst, Category.comp_id, limit.lift_π,
PullbackCone.mk_pt, PullbackCone.mk_π_app, limit.lift_π_assoc, cospan_left]
· simp only [condition_assoc, Category.assoc, diagonal_snd, Category.comp_id,
limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
limit.lift_π_assoc, cospan_right])
#align category_theory.limits.pullback_diagonal_map_iso CategoryTheory.Limits.pullbackDiagonalMapIso
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso_hom_fst :
(pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.fst = pullback.snd ≫ pullback.fst := by
delta pullbackDiagonalMapIso
simp
#align category_theory.limits.pullback_diagonal_map_iso_hom_fst CategoryTheory.Limits.pullbackDiagonalMapIso_hom_fst
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso_hom_snd :
(pullbackDiagonalMapIso f i i₁ i₂).hom ≫ pullback.snd = pullback.snd ≫ pullback.snd := by
delta pullbackDiagonalMapIso
simp
#align category_theory.limits.pullback_diagonal_map_iso_hom_snd CategoryTheory.Limits.pullbackDiagonalMapIso_hom_snd
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso_inv_fst :
(pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.fst = pullback.fst ≫ i₁ ≫ pullback.fst := by
delta pullbackDiagonalMapIso
simp
#align category_theory.limits.pullback_diagonal_map_iso_inv_fst CategoryTheory.Limits.pullbackDiagonalMapIso_inv_fst
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Diagonal.lean | 172 | 175 | theorem pullbackDiagonalMapIso_inv_snd_fst :
(pullbackDiagonalMapIso f i i₁ i₂).inv ≫ pullback.snd ≫ pullback.fst = pullback.fst := by |
delta pullbackDiagonalMapIso
simp
|
/-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth, Eric Wieser
-/
import Mathlib.Analysis.NormedSpace.PiLp
import Mathlib.Analysis.InnerProductSpace.PiL2
#align_import analysis.matrix from "leanprover-community/mathlib"@"46b633fd842bef9469441c0209906f6dddd2b4f5"
/-!
# Matrices as a normed space
In this file we provide the following non-instances for norms on matrices:
* The elementwise norm:
* `Matrix.seminormedAddCommGroup`
* `Matrix.normedAddCommGroup`
* `Matrix.normedSpace`
* `Matrix.boundedSMul`
* The Frobenius norm:
* `Matrix.frobeniusSeminormedAddCommGroup`
* `Matrix.frobeniusNormedAddCommGroup`
* `Matrix.frobeniusNormedSpace`
* `Matrix.frobeniusNormedRing`
* `Matrix.frobeniusNormedAlgebra`
* `Matrix.frobeniusBoundedSMul`
* The $L^\infty$ operator norm:
* `Matrix.linftyOpSeminormedAddCommGroup`
* `Matrix.linftyOpNormedAddCommGroup`
* `Matrix.linftyOpNormedSpace`
* `Matrix.linftyOpBoundedSMul`
* `Matrix.linftyOpNonUnitalSemiNormedRing`
* `Matrix.linftyOpSemiNormedRing`
* `Matrix.linftyOpNonUnitalNormedRing`
* `Matrix.linftyOpNormedRing`
* `Matrix.linftyOpNormedAlgebra`
These are not declared as instances because there are several natural choices for defining the norm
of a matrix.
The norm induced by the identification of `Matrix m n 𝕜` with
`EuclideanSpace n 𝕜 →L[𝕜] EuclideanSpace m 𝕜` (i.e., the ℓ² operator norm) can be found in
`Analysis.NormedSpace.Star.Matrix`. It is separated to avoid extraneous imports in this file.
-/
noncomputable section
open scoped NNReal Matrix
namespace Matrix
variable {R l m n α β : Type*} [Fintype l] [Fintype m] [Fintype n]
/-! ### The elementwise supremum norm -/
section LinfLinf
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
/-- Seminormed group instance (using sup norm of sup norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) :=
Pi.seminormedAddCommGroup
#align matrix.seminormed_add_comm_group Matrix.seminormedAddCommGroup
attribute [local instance] Matrix.seminormedAddCommGroup
-- Porting note (#10756): new theorem (along with all the uses of this lemma below)
theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl
/-- The norm of a matrix is the sup of the sup of the nnnorm of the entries -/
lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) :
‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by
simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def]
-- Porting note (#10756): new theorem (along with all the uses of this lemma below)
theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl
theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by
simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr]
#align matrix.norm_le_iff Matrix.norm_le_iff
theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by
simp_rw [nnnorm_def, pi_nnnorm_le_iff]
#align matrix.nnnorm_le_iff Matrix.nnnorm_le_iff
theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by
simp_rw [norm_def, pi_norm_lt_iff hr]
#align matrix.norm_lt_iff Matrix.norm_lt_iff
theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} :
‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by
simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr]
#align matrix.nnnorm_lt_iff Matrix.nnnorm_lt_iff
theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ :=
(norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i)
#align matrix.norm_entry_le_entrywise_sup_norm Matrix.norm_entry_le_entrywise_sup_norm
theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ :=
(nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i)
#align matrix.nnnorm_entry_le_entrywise_sup_nnnorm Matrix.nnnorm_entry_le_entrywise_sup_nnnorm
@[simp]
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
#align matrix.nnnorm_map_eq Matrix.nnnorm_map_eq
@[simp]
theorem norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) : ‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
#align matrix.norm_map_eq Matrix.norm_map_eq
@[simp]
theorem nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ :=
Finset.sup_comm _ _ _
#align matrix.nnnorm_transpose Matrix.nnnorm_transpose
@[simp]
theorem norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_transpose A
#align matrix.norm_transpose Matrix.norm_transpose
@[simp]
theorem nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(nnnorm_map_eq _ _ nnnorm_star).trans A.nnnorm_transpose
#align matrix.nnnorm_conj_transpose Matrix.nnnorm_conjTranspose
@[simp]
theorem norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) : ‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_conjTranspose A
#align matrix.norm_conj_transpose Matrix.norm_conjTranspose
instance [StarAddMonoid α] [NormedStarGroup α] : NormedStarGroup (Matrix m m α) :=
⟨norm_conjTranspose⟩
@[simp]
theorem nnnorm_col (v : m → α) : ‖col v‖₊ = ‖v‖₊ := by
simp [nnnorm_def, Pi.nnnorm_def]
#align matrix.nnnorm_col Matrix.nnnorm_col
@[simp]
theorem norm_col (v : m → α) : ‖col v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_col v
#align matrix.norm_col Matrix.norm_col
@[simp]
theorem nnnorm_row (v : n → α) : ‖row v‖₊ = ‖v‖₊ := by
simp [nnnorm_def, Pi.nnnorm_def]
#align matrix.nnnorm_row Matrix.nnnorm_row
@[simp]
theorem norm_row (v : n → α) : ‖row v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_row v
#align matrix.norm_row Matrix.norm_row
@[simp]
theorem nnnorm_diagonal [DecidableEq n] (v : n → α) : ‖diagonal v‖₊ = ‖v‖₊ := by
simp_rw [nnnorm_def, Pi.nnnorm_def]
congr 1 with i : 1
refine le_antisymm (Finset.sup_le fun j hj => ?_) ?_
· obtain rfl | hij := eq_or_ne i j
· rw [diagonal_apply_eq]
· rw [diagonal_apply_ne _ hij, nnnorm_zero]
exact zero_le _
· refine Eq.trans_le ?_ (Finset.le_sup (Finset.mem_univ i))
rw [diagonal_apply_eq]
#align matrix.nnnorm_diagonal Matrix.nnnorm_diagonal
@[simp]
theorem norm_diagonal [DecidableEq n] (v : n → α) : ‖diagonal v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_diagonal v
#align matrix.norm_diagonal Matrix.norm_diagonal
/-- Note this is safe as an instance as it carries no data. -/
-- Porting note: not yet implemented: `@[nolint fails_quickly]`
instance [Nonempty n] [DecidableEq n] [One α] [NormOneClass α] : NormOneClass (Matrix n n α) :=
⟨(norm_diagonal _).trans <| norm_one⟩
end SeminormedAddCommGroup
/-- Normed group instance (using sup norm of sup norm) for matrices over a normed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def normedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
Pi.normedAddCommGroup
#align matrix.normed_add_comm_group Matrix.normedAddCommGroup
section NormedSpace
attribute [local instance] Matrix.seminormedAddCommGroup
/-- This applies to the sup norm of sup norm. -/
protected theorem boundedSMul [SeminormedRing R] [SeminormedAddCommGroup α] [Module R α]
[BoundedSMul R α] : BoundedSMul R (Matrix m n α) :=
Pi.instBoundedSMul
variable [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α]
/-- Normed space instance (using sup norm of sup norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def normedSpace : NormedSpace R (Matrix m n α) :=
Pi.normedSpace
#align matrix.normed_space Matrix.normedSpace
end NormedSpace
end LinfLinf
/-! ### The $L_\infty$ operator norm
This section defines the matrix norm $\|A\|_\infty = \operatorname{sup}_i (\sum_j \|A_{ij}\|)$.
Note that this is equivalent to the operator norm, considering $A$ as a linear map between two
$L^\infty$ spaces.
-/
section LinftyOp
/-- Seminormed group instance (using sup norm of L1 norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpSeminormedAddCommGroup [SeminormedAddCommGroup α] :
SeminormedAddCommGroup (Matrix m n α) :=
(by infer_instance : SeminormedAddCommGroup (m → PiLp 1 fun j : n => α))
#align matrix.linfty_op_seminormed_add_comm_group Matrix.linftyOpSeminormedAddCommGroup
/-- Normed group instance (using sup norm of L1 norm) for matrices over a normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedAddCommGroup [NormedAddCommGroup α] :
NormedAddCommGroup (Matrix m n α) :=
(by infer_instance : NormedAddCommGroup (m → PiLp 1 fun j : n => α))
#align matrix.linfty_op_normed_add_comm_group Matrix.linftyOpNormedAddCommGroup
/-- This applies to the sup norm of L1 norm. -/
@[local instance]
protected theorem linftyOpBoundedSMul
[SeminormedRing R] [SeminormedAddCommGroup α] [Module R α] [BoundedSMul R α] :
BoundedSMul R (Matrix m n α) :=
(by infer_instance : BoundedSMul R (m → PiLp 1 fun j : n => α))
/-- Normed space instance (using sup norm of L1 norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedSpace [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α] :
NormedSpace R (Matrix m n α) :=
(by infer_instance : NormedSpace R (m → PiLp 1 fun j : n => α))
#align matrix.linfty_op_normed_space Matrix.linftyOpNormedSpace
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α]
theorem linfty_opNorm_def (A : Matrix m n α) :
‖A‖ = ((Finset.univ : Finset m).sup fun i : m => ∑ j : n, ‖A i j‖₊ : ℝ≥0) := by
-- Porting note: added
change ‖fun i => (WithLp.equiv 1 _).symm (A i)‖ = _
simp [Pi.norm_def, PiLp.nnnorm_eq_sum ENNReal.one_ne_top]
#align matrix.linfty_op_norm_def Matrix.linfty_opNorm_def
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_def := linfty_opNorm_def
theorem linfty_opNNNorm_def (A : Matrix m n α) :
‖A‖₊ = (Finset.univ : Finset m).sup fun i : m => ∑ j : n, ‖A i j‖₊ :=
Subtype.ext <| linfty_opNorm_def A
#align matrix.linfty_op_nnnorm_def Matrix.linfty_opNNNorm_def
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_def := linfty_opNNNorm_def
@[simp, nolint simpNF] -- Porting note: linter times out
theorem linfty_opNNNorm_col (v : m → α) : ‖col v‖₊ = ‖v‖₊ := by
rw [linfty_opNNNorm_def, Pi.nnnorm_def]
simp
#align matrix.linfty_op_nnnorm_col Matrix.linfty_opNNNorm_col
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_col := linfty_opNNNorm_col
@[simp]
theorem linfty_opNorm_col (v : m → α) : ‖col v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_col v
#align matrix.linfty_op_norm_col Matrix.linfty_opNorm_col
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_col := linfty_opNorm_col
@[simp]
theorem linfty_opNNNorm_row (v : n → α) : ‖row v‖₊ = ∑ i, ‖v i‖₊ := by simp [linfty_opNNNorm_def]
#align matrix.linfty_op_nnnorm_row Matrix.linfty_opNNNorm_row
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_row := linfty_opNNNorm_row
@[simp]
theorem linfty_opNorm_row (v : n → α) : ‖row v‖ = ∑ i, ‖v i‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_row v).trans <| by simp [NNReal.coe_sum]
#align matrix.linfty_op_norm_row Matrix.linfty_opNorm_row
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_row := linfty_opNorm_row
@[simp]
theorem linfty_opNNNorm_diagonal [DecidableEq m] (v : m → α) : ‖diagonal v‖₊ = ‖v‖₊ := by
rw [linfty_opNNNorm_def, Pi.nnnorm_def]
congr 1 with i : 1
refine (Finset.sum_eq_single_of_mem _ (Finset.mem_univ i) fun j _hj hij => ?_).trans ?_
· rw [diagonal_apply_ne' _ hij, nnnorm_zero]
· rw [diagonal_apply_eq]
#align matrix.linfty_op_nnnorm_diagonal Matrix.linfty_opNNNorm_diagonal
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_diagonal := linfty_opNNNorm_diagonal
@[simp]
theorem linfty_opNorm_diagonal [DecidableEq m] (v : m → α) : ‖diagonal v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_diagonal v
#align matrix.linfty_op_norm_diagonal Matrix.linfty_opNorm_diagonal
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_diagonal := linfty_opNorm_diagonal
end SeminormedAddCommGroup
section NonUnitalSeminormedRing
variable [NonUnitalSeminormedRing α]
theorem linfty_opNNNorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖₊ ≤ ‖A‖₊ * ‖B‖₊ := by
simp_rw [linfty_opNNNorm_def, Matrix.mul_apply]
calc
(Finset.univ.sup fun i => ∑ k, ‖∑ j, A i j * B j k‖₊) ≤
Finset.univ.sup fun i => ∑ k, ∑ j, ‖A i j‖₊ * ‖B j k‖₊ :=
Finset.sup_mono_fun fun i _hi =>
Finset.sum_le_sum fun k _hk => nnnorm_sum_le_of_le _ fun j _hj => nnnorm_mul_le _ _
_ = Finset.univ.sup fun i => ∑ j, ‖A i j‖₊ * ∑ k, ‖B j k‖₊ := by
simp_rw [@Finset.sum_comm m, Finset.mul_sum]
_ ≤ Finset.univ.sup fun i => ∑ j, ‖A i j‖₊ * Finset.univ.sup fun i => ∑ j, ‖B i j‖₊ := by
refine Finset.sup_mono_fun fun i _hi => ?_
gcongr with j hj
exact Finset.le_sup (f := fun i ↦ ∑ k : n, ‖B i k‖₊) hj
_ ≤ (Finset.univ.sup fun i => ∑ j, ‖A i j‖₊) * Finset.univ.sup fun i => ∑ j, ‖B i j‖₊ := by
simp_rw [← Finset.sum_mul, ← NNReal.finset_sup_mul]
rfl
#align matrix.linfty_op_nnnorm_mul Matrix.linfty_opNNNorm_mul
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_mul := linfty_opNNNorm_mul
theorem linfty_opNorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖ ≤ ‖A‖ * ‖B‖ :=
linfty_opNNNorm_mul _ _
#align matrix.linfty_op_norm_mul Matrix.linfty_opNorm_mul
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_mul := linfty_opNorm_mul
theorem linfty_opNNNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖₊ ≤ ‖A‖₊ * ‖v‖₊ := by
rw [← linfty_opNNNorm_col (A *ᵥ v), ← linfty_opNNNorm_col v]
exact linfty_opNNNorm_mul A (col v)
#align matrix.linfty_op_nnnorm_mul_vec Matrix.linfty_opNNNorm_mulVec
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_mulVec := linfty_opNNNorm_mulVec
theorem linfty_opNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖ ≤ ‖A‖ * ‖v‖ :=
linfty_opNNNorm_mulVec _ _
#align matrix.linfty_op_norm_mul_vec Matrix.linfty_opNorm_mulVec
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_mulVec := linfty_opNorm_mulVec
end NonUnitalSeminormedRing
/-- Seminormed non-unital ring instance (using sup norm of L1 norm) for matrices over a semi normed
non-unital ring. Not declared as an instance because there are several natural choices for defining
the norm of a matrix. -/
@[local instance]
protected def linftyOpNonUnitalSemiNormedRing [NonUnitalSeminormedRing α] :
NonUnitalSeminormedRing (Matrix n n α) :=
{ Matrix.linftyOpSeminormedAddCommGroup, Matrix.instNonUnitalRing with
norm_mul := linfty_opNorm_mul }
#align matrix.linfty_op_non_unital_semi_normed_ring Matrix.linftyOpNonUnitalSemiNormedRing
/-- The `L₁-L∞` norm preserves one on non-empty matrices. Note this is safe as an instance, as it
carries no data. -/
instance linfty_opNormOneClass [SeminormedRing α] [NormOneClass α] [DecidableEq n] [Nonempty n] :
NormOneClass (Matrix n n α) where norm_one := (linfty_opNorm_diagonal _).trans norm_one
#align matrix.linfty_op_norm_one_class Matrix.linfty_opNormOneClass
/-- Seminormed ring instance (using sup norm of L1 norm) for matrices over a semi normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpSemiNormedRing [SeminormedRing α] [DecidableEq n] :
SeminormedRing (Matrix n n α) :=
{ Matrix.linftyOpNonUnitalSemiNormedRing, Matrix.instRing with }
#align matrix.linfty_op_semi_normed_ring Matrix.linftyOpSemiNormedRing
/-- Normed non-unital ring instance (using sup norm of L1 norm) for matrices over a normed
non-unital ring. Not declared as an instance because there are several natural choices for defining
the norm of a matrix. -/
@[local instance]
protected def linftyOpNonUnitalNormedRing [NonUnitalNormedRing α] :
NonUnitalNormedRing (Matrix n n α) :=
{ Matrix.linftyOpNonUnitalSemiNormedRing with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
#align matrix.linfty_op_non_unital_normed_ring Matrix.linftyOpNonUnitalNormedRing
/-- Normed ring instance (using sup norm of L1 norm) for matrices over a normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedRing [NormedRing α] [DecidableEq n] : NormedRing (Matrix n n α) :=
{ Matrix.linftyOpSemiNormedRing with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
#align matrix.linfty_op_normed_ring Matrix.linftyOpNormedRing
/-- Normed algebra instance (using sup norm of L1 norm) for matrices over a normed algebra. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedAlgebra [NormedField R] [SeminormedRing α] [NormedAlgebra R α]
[DecidableEq n] : NormedAlgebra R (Matrix n n α) :=
{ Matrix.linftyOpNormedSpace, Matrix.instAlgebra with }
#align matrix.linfty_op_normed_algebra Matrix.linftyOpNormedAlgebra
section
variable [NormedDivisionRing α] [NormedAlgebra ℝ α] [CompleteSpace α]
/-- Auxiliary construction; an element of norm 1 such that `a * unitOf a = ‖a‖`. -/
private def unitOf (a : α) : α := by classical exact if a = 0 then 1 else ‖a‖ • a⁻¹
private theorem norm_unitOf (a : α) : ‖unitOf a‖₊ = 1 := by
rw [unitOf]
split_ifs with h
· simp
· rw [← nnnorm_eq_zero] at h
rw [nnnorm_smul, nnnorm_inv, nnnorm_norm, mul_inv_cancel h]
set_option tactic.skipAssignedInstances false in
private theorem mul_unitOf (a : α) : a * unitOf a = algebraMap _ _ (‖a‖₊ : ℝ) := by
simp [unitOf]
split_ifs with h
· simp [h]
· rw [mul_smul_comm, mul_inv_cancel h, Algebra.algebraMap_eq_smul_one]
end
/-!
For a matrix over a field, the norm defined in this section agrees with the operator norm on
`ContinuousLinearMap`s between function types (which have the infinity norm).
-/
section
variable [NontriviallyNormedField α] [NormedAlgebra ℝ α]
lemma linfty_opNNNorm_eq_opNNNorm (A : Matrix m n α) :
‖A‖₊ = ‖ContinuousLinearMap.mk (Matrix.mulVecLin A)‖₊ := by
rw [ContinuousLinearMap.opNNNorm_eq_of_bounds _ (linfty_opNNNorm_mulVec _) fun N hN => ?_]
rw [linfty_opNNNorm_def]
refine Finset.sup_le fun i _ => ?_
cases isEmpty_or_nonempty n
· simp
classical
let x : n → α := fun j => unitOf (A i j)
have hxn : ‖x‖₊ = 1 := by
simp_rw [x, Pi.nnnorm_def, norm_unitOf, Finset.sup_const Finset.univ_nonempty]
specialize hN x
rw [hxn, mul_one, Pi.nnnorm_def, Finset.sup_le_iff] at hN
replace hN := hN i (Finset.mem_univ _)
dsimp [mulVec, dotProduct] at hN
simp_rw [x, mul_unitOf, ← map_sum, nnnorm_algebraMap, ← NNReal.coe_sum, NNReal.nnnorm_eq,
nnnorm_one, mul_one] at hN
exact hN
@[deprecated (since := "2024-02-02")]
alias linfty_op_nnnorm_eq_op_nnnorm := linfty_opNNNorm_eq_opNNNorm
lemma linfty_opNorm_eq_opNorm (A : Matrix m n α) :
‖A‖ = ‖ContinuousLinearMap.mk (Matrix.mulVecLin A)‖ :=
congr_arg NNReal.toReal (linfty_opNNNorm_eq_opNNNorm A)
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_eq_op_norm := linfty_opNorm_eq_opNorm
variable [DecidableEq n]
@[simp] lemma linfty_opNNNorm_toMatrix (f : (n → α) →L[α] (m → α)) :
‖LinearMap.toMatrix' (↑f : (n → α) →ₗ[α] (m → α))‖₊ = ‖f‖₊ := by
rw [linfty_opNNNorm_eq_opNNNorm]
simp only [← toLin'_apply', toLin'_toMatrix']
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_toMatrix := linfty_opNNNorm_toMatrix
@[simp] lemma linfty_opNorm_toMatrix (f : (n → α) →L[α] (m → α)) :
‖LinearMap.toMatrix' (↑f : (n → α) →ₗ[α] (m → α))‖ = ‖f‖ :=
congr_arg NNReal.toReal (linfty_opNNNorm_toMatrix f)
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_toMatrix := linfty_opNorm_toMatrix
end
end LinftyOp
/-! ### The Frobenius norm
This is defined as $\|A\| = \sqrt{\sum_{i,j} \|A_{ij}\|^2}$.
When the matrix is over the real or complex numbers, this norm is submultiplicative.
-/
section frobenius
open scoped Matrix
/-- Seminormed group instance (using frobenius norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusSeminormedAddCommGroup [SeminormedAddCommGroup α] :
SeminormedAddCommGroup (Matrix m n α) :=
inferInstanceAs (SeminormedAddCommGroup (PiLp 2 fun _i : m => PiLp 2 fun _j : n => α))
#align matrix.frobenius_seminormed_add_comm_group Matrix.frobeniusSeminormedAddCommGroup
/-- Normed group instance (using frobenius norm) for matrices over a normed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
(by infer_instance : NormedAddCommGroup (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
#align matrix.frobenius_normed_add_comm_group Matrix.frobeniusNormedAddCommGroup
/-- This applies to the frobenius norm. -/
@[local instance]
theorem frobeniusBoundedSMul [SeminormedRing R] [SeminormedAddCommGroup α] [Module R α]
[BoundedSMul R α] :
BoundedSMul R (Matrix m n α) :=
(by infer_instance : BoundedSMul R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
/-- Normed space instance (using frobenius norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedSpace [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α] :
NormedSpace R (Matrix m n α) :=
(by infer_instance : NormedSpace R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
#align matrix.frobenius_normed_space Matrix.frobeniusNormedSpace
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
theorem frobenius_nnnorm_def (A : Matrix m n α) :
‖A‖₊ = (∑ i, ∑ j, ‖A i j‖₊ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) := by
-- Porting note: added, along with `WithLp.equiv_symm_pi_apply` below
change ‖(WithLp.equiv 2 _).symm fun i => (WithLp.equiv 2 _).symm fun j => A i j‖₊ = _
simp_rw [PiLp.nnnorm_eq_of_L2, NNReal.sq_sqrt, NNReal.sqrt_eq_rpow, NNReal.rpow_two,
WithLp.equiv_symm_pi_apply]
#align matrix.frobenius_nnnorm_def Matrix.frobenius_nnnorm_def
theorem frobenius_norm_def (A : Matrix m n α) :
‖A‖ = (∑ i, ∑ j, ‖A i j‖ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) :=
(congr_arg ((↑) : ℝ≥0 → ℝ) (frobenius_nnnorm_def A)).trans <| by simp [NNReal.coe_sum]
#align matrix.frobenius_norm_def Matrix.frobenius_norm_def
@[simp]
theorem frobenius_nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by simp_rw [frobenius_nnnorm_def, Matrix.map_apply, hf]
#align matrix.frobenius_nnnorm_map_eq Matrix.frobenius_nnnorm_map_eq
@[simp]
theorem frobenius_norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) :
‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
#align matrix.frobenius_norm_map_eq Matrix.frobenius_norm_map_eq
@[simp]
theorem frobenius_nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ := by
rw [frobenius_nnnorm_def, frobenius_nnnorm_def, Finset.sum_comm]
simp_rw [Matrix.transpose_apply] -- Porting note: added
#align matrix.frobenius_nnnorm_transpose Matrix.frobenius_nnnorm_transpose
@[simp]
theorem frobenius_norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_transpose A
#align matrix.frobenius_norm_transpose Matrix.frobenius_norm_transpose
@[simp]
theorem frobenius_nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(frobenius_nnnorm_map_eq _ _ nnnorm_star).trans A.frobenius_nnnorm_transpose
#align matrix.frobenius_nnnorm_conj_transpose Matrix.frobenius_nnnorm_conjTranspose
@[simp]
theorem frobenius_norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_conjTranspose A
#align matrix.frobenius_norm_conj_transpose Matrix.frobenius_norm_conjTranspose
instance frobenius_normedStarGroup [StarAddMonoid α] [NormedStarGroup α] :
NormedStarGroup (Matrix m m α) :=
⟨frobenius_norm_conjTranspose⟩
#align matrix.frobenius_normed_star_group Matrix.frobenius_normedStarGroup
@[simp]
| Mathlib/Analysis/Matrix.lean | 613 | 615 | theorem frobenius_norm_row (v : m → α) : ‖row v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by |
rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [row_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
|
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp
#align_import measure_theory.integral.set_to_l1 from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Extension of a linear function from indicators to L1
Let `T : Set α → E →L[ℝ] F` be additive for measurable sets with finite measure, in the sense that
for `s, t` two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. `T` is akin to a bilinear map on
`Set α × E`, or a linear map on indicator functions.
This file constructs an extension of `T` to integrable simple functions, which are finite sums of
indicators of measurable sets with finite measure, then to integrable functions, which are limits of
integrable simple functions.
The main result is a continuous linear map `(α →₁[μ] E) →L[ℝ] F`. This extension process is used to
define the Bochner integral in the `MeasureTheory.Integral.Bochner` file and the conditional
expectation of an integrable function in `MeasureTheory.Function.ConditionalExpectation`.
## Main Definitions
- `FinMeasAdditive μ T`: the property that `T` is additive on measurable sets with finite measure.
For two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`.
- `DominatedFinMeasAdditive μ T C`: `FinMeasAdditive μ T ∧ ∀ s, ‖T s‖ ≤ C * (μ s).toReal`.
This is the property needed to perform the extension from indicators to L1.
- `setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F`: the extension of `T`
from indicators to L1.
- `setToFun μ T (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F`: a version of the
extension which applies to functions (with value 0 if the function is not integrable).
## Properties
For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on
all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on
measurable sets with finite measure, like `∀ s, MeasurableSet s → μ s < ∞ → T s = T' s`.
The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details.
Linearity:
- `setToFun_zero_left : setToFun μ 0 hT f = 0`
- `setToFun_add_left : setToFun μ (T + T') _ f = setToFun μ T hT f + setToFun μ T' hT' f`
- `setToFun_smul_left : setToFun μ (fun s ↦ c • (T s)) (hT.smul c) f = c • setToFun μ T hT f`
- `setToFun_zero : setToFun μ T hT (0 : α → E) = 0`
- `setToFun_neg : setToFun μ T hT (-f) = - setToFun μ T hT f`
If `f` and `g` are integrable:
- `setToFun_add : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g`
- `setToFun_sub : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g`
If `T` is verifies `∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x`:
- `setToFun_smul : setToFun μ T hT (c • f) = c • setToFun μ T hT f`
Other:
- `setToFun_congr_ae (h : f =ᵐ[μ] g) : setToFun μ T hT f = setToFun μ T hT g`
- `setToFun_measure_zero (h : μ = 0) : setToFun μ T hT f = 0`
If the space is a `NormedLatticeAddCommGroup` and `T` is such that `0 ≤ T s x` for `0 ≤ x`, we
also prove order-related properties:
- `setToFun_mono_left (h : ∀ s x, T s x ≤ T' s x) : setToFun μ T hT f ≤ setToFun μ T' hT' f`
- `setToFun_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ setToFun μ T hT f`
- `setToFun_mono (hfg : f ≤ᵐ[μ] g) : setToFun μ T hT f ≤ setToFun μ T hT g`
## Implementation notes
The starting object `T : Set α → E →L[ℝ] F` matters only through its restriction on measurable sets
with finite measure. Its value on other sets is ignored.
-/
noncomputable section
open scoped Classical Topology NNReal ENNReal MeasureTheory Pointwise
open Set Filter TopologicalSpace ENNReal EMetric
namespace MeasureTheory
variable {α E F F' G 𝕜 : Type*} {p : ℝ≥0∞} [NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F']
[NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α}
local infixr:25 " →ₛ " => SimpleFunc
open Finset
section FinMeasAdditive
/-- A set function is `FinMeasAdditive` if its value on the union of two disjoint measurable
sets with finite measure is the sum of its values on each set. -/
def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) :
Prop :=
∀ s t, MeasurableSet s → MeasurableSet t → μ s ≠ ∞ → μ t ≠ ∞ → s ∩ t = ∅ → T (s ∪ t) = T s + T t
#align measure_theory.fin_meas_additive MeasureTheory.FinMeasAdditive
namespace FinMeasAdditive
variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β}
theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun s t _ _ _ _ _ => by simp
#align measure_theory.fin_meas_additive.zero MeasureTheory.FinMeasAdditive.zero
theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') :
FinMeasAdditive μ (T + T') := by
intro s t hs ht hμs hμt hst
simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply]
abel
#align measure_theory.fin_meas_additive.add MeasureTheory.FinMeasAdditive.add
theorem smul [Monoid 𝕜] [DistribMulAction 𝕜 β] (hT : FinMeasAdditive μ T) (c : 𝕜) :
FinMeasAdditive μ fun s => c • T s := fun s t hs ht hμs hμt hst => by
simp [hT s t hs ht hμs hμt hst]
#align measure_theory.fin_meas_additive.smul MeasureTheory.FinMeasAdditive.smul
theorem of_eq_top_imp_eq_top {μ' : Measure α} (h : ∀ s, MeasurableSet s → μ s = ∞ → μ' s = ∞)
(hT : FinMeasAdditive μ T) : FinMeasAdditive μ' T := fun s t hs ht hμ's hμ't hst =>
hT s t hs ht (mt (h s hs) hμ's) (mt (h t ht) hμ't) hst
#align measure_theory.fin_meas_additive.of_eq_top_imp_eq_top MeasureTheory.FinMeasAdditive.of_eq_top_imp_eq_top
theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : FinMeasAdditive (c • μ) T) :
FinMeasAdditive μ T := by
refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT
rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top] at hμs
simp only [hc_ne_top, or_false_iff, Ne, false_and_iff] at hμs
exact hμs.2
#align measure_theory.fin_meas_additive.of_smul_measure MeasureTheory.FinMeasAdditive.of_smul_measure
theorem smul_measure (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hT : FinMeasAdditive μ T) :
FinMeasAdditive (c • μ) T := by
refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT
rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top]
simp only [hc_ne_zero, true_and_iff, Ne, not_false_iff]
exact Or.inl hμs
#align measure_theory.fin_meas_additive.smul_measure MeasureTheory.FinMeasAdditive.smul_measure
theorem smul_measure_iff (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hc_ne_top : c ≠ ∞) :
FinMeasAdditive (c • μ) T ↔ FinMeasAdditive μ T :=
⟨fun hT => of_smul_measure c hc_ne_top hT, fun hT => smul_measure c hc_ne_zero hT⟩
#align measure_theory.fin_meas_additive.smul_measure_iff MeasureTheory.FinMeasAdditive.smul_measure_iff
theorem map_empty_eq_zero {β} [AddCancelMonoid β] {T : Set α → β} (hT : FinMeasAdditive μ T) :
T ∅ = 0 := by
have h_empty : μ ∅ ≠ ∞ := (measure_empty.le.trans_lt ENNReal.coe_lt_top).ne
specialize hT ∅ ∅ MeasurableSet.empty MeasurableSet.empty h_empty h_empty (Set.inter_empty ∅)
rw [Set.union_empty] at hT
nth_rw 1 [← add_zero (T ∅)] at hT
exact (add_left_cancel hT).symm
#align measure_theory.fin_meas_additive.map_empty_eq_zero MeasureTheory.FinMeasAdditive.map_empty_eq_zero
theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0)
(h_add : FinMeasAdditive μ T) {ι} (S : ι → Set α) (sι : Finset ι)
(hS_meas : ∀ i, MeasurableSet (S i)) (hSp : ∀ i ∈ sι, μ (S i) ≠ ∞)
(h_disj : ∀ᵉ (i ∈ sι) (j ∈ sι), i ≠ j → Disjoint (S i) (S j)) :
T (⋃ i ∈ sι, S i) = ∑ i ∈ sι, T (S i) := by
revert hSp h_disj
refine Finset.induction_on sι ?_ ?_
· simp only [Finset.not_mem_empty, IsEmpty.forall_iff, iUnion_false, iUnion_empty, sum_empty,
forall₂_true_iff, imp_true_iff, forall_true_left, not_false_iff, T_empty]
intro a s has h hps h_disj
rw [Finset.sum_insert has, ← h]
swap; · exact fun i hi => hps i (Finset.mem_insert_of_mem hi)
swap;
· exact fun i hi j hj hij =>
h_disj i (Finset.mem_insert_of_mem hi) j (Finset.mem_insert_of_mem hj) hij
rw [←
h_add (S a) (⋃ i ∈ s, S i) (hS_meas a) (measurableSet_biUnion _ fun i _ => hS_meas i)
(hps a (Finset.mem_insert_self a s))]
· congr; convert Finset.iSup_insert a s S
· exact
((measure_biUnion_finset_le _ _).trans_lt <|
ENNReal.sum_lt_top fun i hi => hps i <| Finset.mem_insert_of_mem hi).ne
· simp_rw [Set.inter_iUnion]
refine iUnion_eq_empty.mpr fun i => iUnion_eq_empty.mpr fun hi => ?_
rw [← Set.disjoint_iff_inter_eq_empty]
refine h_disj a (Finset.mem_insert_self a s) i (Finset.mem_insert_of_mem hi) fun hai => ?_
rw [← hai] at hi
exact has hi
#align measure_theory.fin_meas_additive.map_Union_fin_meas_set_eq_sum MeasureTheory.FinMeasAdditive.map_iUnion_fin_meas_set_eq_sum
end FinMeasAdditive
/-- A `FinMeasAdditive` set function whose norm on every set is less than the measure of the
set (up to a multiplicative constant). -/
def DominatedFinMeasAdditive {β} [SeminormedAddCommGroup β] {_ : MeasurableSpace α} (μ : Measure α)
(T : Set α → β) (C : ℝ) : Prop :=
FinMeasAdditive μ T ∧ ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal
#align measure_theory.dominated_fin_meas_additive MeasureTheory.DominatedFinMeasAdditive
namespace DominatedFinMeasAdditive
variable {β : Type*} [SeminormedAddCommGroup β] {T T' : Set α → β} {C C' : ℝ}
theorem zero {m : MeasurableSpace α} (μ : Measure α) (hC : 0 ≤ C) :
DominatedFinMeasAdditive μ (0 : Set α → β) C := by
refine ⟨FinMeasAdditive.zero, fun s _ _ => ?_⟩
rw [Pi.zero_apply, norm_zero]
exact mul_nonneg hC toReal_nonneg
#align measure_theory.dominated_fin_meas_additive.zero MeasureTheory.DominatedFinMeasAdditive.zero
theorem eq_zero_of_measure_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ}
(hT : DominatedFinMeasAdditive μ T C) {s : Set α} (hs : MeasurableSet s) (hs_zero : μ s = 0) :
T s = 0 := by
refine norm_eq_zero.mp ?_
refine ((hT.2 s hs (by simp [hs_zero])).trans (le_of_eq ?_)).antisymm (norm_nonneg _)
rw [hs_zero, ENNReal.zero_toReal, mul_zero]
#align measure_theory.dominated_fin_meas_additive.eq_zero_of_measure_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero_of_measure_zero
theorem eq_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ} {m : MeasurableSpace α}
(hT : DominatedFinMeasAdditive (0 : Measure α) T C) {s : Set α} (hs : MeasurableSet s) :
T s = 0 :=
eq_zero_of_measure_zero hT hs (by simp only [Measure.coe_zero, Pi.zero_apply])
#align measure_theory.dominated_fin_meas_additive.eq_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero
theorem add (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') :
DominatedFinMeasAdditive μ (T + T') (C + C') := by
refine ⟨hT.1.add hT'.1, fun s hs hμs => ?_⟩
rw [Pi.add_apply, add_mul]
exact (norm_add_le _ _).trans (add_le_add (hT.2 s hs hμs) (hT'.2 s hs hμs))
#align measure_theory.dominated_fin_meas_additive.add MeasureTheory.DominatedFinMeasAdditive.add
theorem smul [NormedField 𝕜] [NormedSpace 𝕜 β] (hT : DominatedFinMeasAdditive μ T C) (c : 𝕜) :
DominatedFinMeasAdditive μ (fun s => c • T s) (‖c‖ * C) := by
refine ⟨hT.1.smul c, fun s hs hμs => ?_⟩
dsimp only
rw [norm_smul, mul_assoc]
exact mul_le_mul le_rfl (hT.2 s hs hμs) (norm_nonneg _) (norm_nonneg _)
#align measure_theory.dominated_fin_meas_additive.smul MeasureTheory.DominatedFinMeasAdditive.smul
theorem of_measure_le {μ' : Measure α} (h : μ ≤ μ') (hT : DominatedFinMeasAdditive μ T C)
(hC : 0 ≤ C) : DominatedFinMeasAdditive μ' T C := by
have h' : ∀ s, μ s = ∞ → μ' s = ∞ := fun s hs ↦ top_unique <| hs.symm.trans_le (h _)
refine ⟨hT.1.of_eq_top_imp_eq_top fun s _ ↦ h' s, fun s hs hμ's ↦ ?_⟩
have hμs : μ s < ∞ := (h s).trans_lt hμ's
calc
‖T s‖ ≤ C * (μ s).toReal := hT.2 s hs hμs
_ ≤ C * (μ' s).toReal := by gcongr; exacts [hμ's.ne, h _]
#align measure_theory.dominated_fin_meas_additive.of_measure_le MeasureTheory.DominatedFinMeasAdditive.of_measure_le
theorem add_measure_right {_ : MeasurableSpace α} (μ ν : Measure α)
(hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C :=
of_measure_le (Measure.le_add_right le_rfl) hT hC
#align measure_theory.dominated_fin_meas_additive.add_measure_right MeasureTheory.DominatedFinMeasAdditive.add_measure_right
theorem add_measure_left {_ : MeasurableSpace α} (μ ν : Measure α)
(hT : DominatedFinMeasAdditive ν T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C :=
of_measure_le (Measure.le_add_left le_rfl) hT hC
#align measure_theory.dominated_fin_meas_additive.add_measure_left MeasureTheory.DominatedFinMeasAdditive.add_measure_left
theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : DominatedFinMeasAdditive (c • μ) T C) :
DominatedFinMeasAdditive μ T (c.toReal * C) := by
have h : ∀ s, MeasurableSet s → c • μ s = ∞ → μ s = ∞ := by
intro s _ hcμs
simp only [hc_ne_top, Algebra.id.smul_eq_mul, ENNReal.mul_eq_top, or_false_iff, Ne,
false_and_iff] at hcμs
exact hcμs.2
refine ⟨hT.1.of_eq_top_imp_eq_top (μ := c • μ) h, fun s hs hμs => ?_⟩
have hcμs : c • μ s ≠ ∞ := mt (h s hs) hμs.ne
rw [smul_eq_mul] at hcμs
simp_rw [DominatedFinMeasAdditive, Measure.smul_apply, smul_eq_mul, toReal_mul] at hT
refine (hT.2 s hs hcμs.lt_top).trans (le_of_eq ?_)
ring
#align measure_theory.dominated_fin_meas_additive.of_smul_measure MeasureTheory.DominatedFinMeasAdditive.of_smul_measure
theorem of_measure_le_smul {μ' : Measure α} (c : ℝ≥0∞) (hc : c ≠ ∞) (h : μ ≤ c • μ')
(hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) :
DominatedFinMeasAdditive μ' T (c.toReal * C) :=
(hT.of_measure_le h hC).of_smul_measure c hc
#align measure_theory.dominated_fin_meas_additive.of_measure_le_smul MeasureTheory.DominatedFinMeasAdditive.of_measure_le_smul
end DominatedFinMeasAdditive
end FinMeasAdditive
namespace SimpleFunc
/-- Extend `Set α → (F →L[ℝ] F')` to `(α →ₛ F) → F'`. -/
def setToSimpleFunc {_ : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (f : α →ₛ F) : F' :=
∑ x ∈ f.range, T (f ⁻¹' {x}) x
#align measure_theory.simple_func.set_to_simple_func MeasureTheory.SimpleFunc.setToSimpleFunc
@[simp]
theorem setToSimpleFunc_zero {m : MeasurableSpace α} (f : α →ₛ F) :
setToSimpleFunc (0 : Set α → F →L[ℝ] F') f = 0 := by simp [setToSimpleFunc]
#align measure_theory.simple_func.set_to_simple_func_zero MeasureTheory.SimpleFunc.setToSimpleFunc_zero
theorem setToSimpleFunc_zero' {T : Set α → E →L[ℝ] F'}
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →ₛ E) (hf : Integrable f μ) :
setToSimpleFunc T f = 0 := by
simp_rw [setToSimpleFunc]
refine sum_eq_zero fun x _ => ?_
by_cases hx0 : x = 0
· simp [hx0]
rw [h_zero (f ⁻¹' ({x} : Set E)) (measurableSet_fiber _ _)
(measure_preimage_lt_top_of_integrable f hf hx0),
ContinuousLinearMap.zero_apply]
#align measure_theory.simple_func.set_to_simple_func_zero' MeasureTheory.SimpleFunc.setToSimpleFunc_zero'
@[simp]
theorem setToSimpleFunc_zero_apply {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') :
setToSimpleFunc T (0 : α →ₛ F) = 0 := by
cases isEmpty_or_nonempty α <;> simp [setToSimpleFunc]
#align measure_theory.simple_func.set_to_simple_func_zero_apply MeasureTheory.SimpleFunc.setToSimpleFunc_zero_apply
theorem setToSimpleFunc_eq_sum_filter {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F')
(f : α →ₛ F) :
setToSimpleFunc T f = ∑ x ∈ f.range.filter fun x => x ≠ 0, (T (f ⁻¹' {x})) x := by
symm
refine sum_filter_of_ne fun x _ => mt fun hx0 => ?_
rw [hx0]
exact ContinuousLinearMap.map_zero _
#align measure_theory.simple_func.set_to_simple_func_eq_sum_filter MeasureTheory.SimpleFunc.setToSimpleFunc_eq_sum_filter
theorem map_setToSimpleFunc (T : Set α → F →L[ℝ] F') (h_add : FinMeasAdditive μ T) {f : α →ₛ G}
(hf : Integrable f μ) {g : G → F} (hg : g 0 = 0) :
(f.map g).setToSimpleFunc T = ∑ x ∈ f.range, T (f ⁻¹' {x}) (g x) := by
have T_empty : T ∅ = 0 := h_add.map_empty_eq_zero
have hfp : ∀ x ∈ f.range, x ≠ 0 → μ (f ⁻¹' {x}) ≠ ∞ := fun x _ hx0 =>
(measure_preimage_lt_top_of_integrable f hf hx0).ne
simp only [setToSimpleFunc, range_map]
refine Finset.sum_image' _ fun b hb => ?_
rcases mem_range.1 hb with ⟨a, rfl⟩
by_cases h0 : g (f a) = 0
· simp_rw [h0]
rw [ContinuousLinearMap.map_zero, Finset.sum_eq_zero fun x hx => ?_]
rw [mem_filter] at hx
rw [hx.2, ContinuousLinearMap.map_zero]
have h_left_eq :
T (map g f ⁻¹' {g (f a)}) (g (f a)) =
T (f ⁻¹' (f.range.filter fun b => g b = g (f a))) (g (f a)) := by
congr; rw [map_preimage_singleton]
rw [h_left_eq]
have h_left_eq' :
T (f ⁻¹' (filter (fun b : G => g b = g (f a)) f.range)) (g (f a)) =
T (⋃ y ∈ filter (fun b : G => g b = g (f a)) f.range, f ⁻¹' {y}) (g (f a)) := by
congr; rw [← Finset.set_biUnion_preimage_singleton]
rw [h_left_eq']
rw [h_add.map_iUnion_fin_meas_set_eq_sum T T_empty]
· simp only [sum_apply, ContinuousLinearMap.coe_sum']
refine Finset.sum_congr rfl fun x hx => ?_
rw [mem_filter] at hx
rw [hx.2]
· exact fun i => measurableSet_fiber _ _
· intro i hi
rw [mem_filter] at hi
refine hfp i hi.1 fun hi0 => ?_
rw [hi0, hg] at hi
exact h0 hi.2.symm
· intro i _j hi _ hij
rw [Set.disjoint_iff]
intro x hx
rw [Set.mem_inter_iff, Set.mem_preimage, Set.mem_preimage, Set.mem_singleton_iff,
Set.mem_singleton_iff] at hx
rw [← hx.1, ← hx.2] at hij
exact absurd rfl hij
#align measure_theory.simple_func.map_set_to_simple_func MeasureTheory.SimpleFunc.map_setToSimpleFunc
theorem setToSimpleFunc_congr' (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E}
(hf : Integrable f μ) (hg : Integrable g μ)
(h : Pairwise fun x y => T (f ⁻¹' {x} ∩ g ⁻¹' {y}) = 0) :
f.setToSimpleFunc T = g.setToSimpleFunc T :=
show ((pair f g).map Prod.fst).setToSimpleFunc T = ((pair f g).map Prod.snd).setToSimpleFunc T by
have h_pair : Integrable (f.pair g) μ := integrable_pair hf hg
rw [map_setToSimpleFunc T h_add h_pair Prod.fst_zero]
rw [map_setToSimpleFunc T h_add h_pair Prod.snd_zero]
refine Finset.sum_congr rfl fun p hp => ?_
rcases mem_range.1 hp with ⟨a, rfl⟩
by_cases eq : f a = g a
· dsimp only [pair_apply]; rw [eq]
· have : T (pair f g ⁻¹' {(f a, g a)}) = 0 := by
have h_eq : T ((⇑(f.pair g)) ⁻¹' {(f a, g a)}) = T (f ⁻¹' {f a} ∩ g ⁻¹' {g a}) := by
congr; rw [pair_preimage_singleton f g]
rw [h_eq]
exact h eq
simp only [this, ContinuousLinearMap.zero_apply, pair_apply]
#align measure_theory.simple_func.set_to_simple_func_congr' MeasureTheory.SimpleFunc.setToSimpleFunc_congr'
theorem setToSimpleFunc_congr (T : Set α → E →L[ℝ] F)
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E}
(hf : Integrable f μ) (h : f =ᵐ[μ] g) : f.setToSimpleFunc T = g.setToSimpleFunc T := by
refine setToSimpleFunc_congr' T h_add hf ((integrable_congr h).mp hf) ?_
refine fun x y hxy => h_zero _ ((measurableSet_fiber f x).inter (measurableSet_fiber g y)) ?_
rw [EventuallyEq, ae_iff] at h
refine measure_mono_null (fun z => ?_) h
simp_rw [Set.mem_inter_iff, Set.mem_setOf_eq, Set.mem_preimage, Set.mem_singleton_iff]
intro h
rwa [h.1, h.2]
#align measure_theory.simple_func.set_to_simple_func_congr MeasureTheory.SimpleFunc.setToSimpleFunc_congr
theorem setToSimpleFunc_congr_left (T T' : Set α → E →L[ℝ] F)
(h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →ₛ E) (hf : Integrable f μ) :
setToSimpleFunc T f = setToSimpleFunc T' f := by
simp_rw [setToSimpleFunc]
refine sum_congr rfl fun x _ => ?_
by_cases hx0 : x = 0
· simp [hx0]
· rw [h (f ⁻¹' {x}) (SimpleFunc.measurableSet_fiber _ _)
(SimpleFunc.measure_preimage_lt_top_of_integrable _ hf hx0)]
#align measure_theory.simple_func.set_to_simple_func_congr_left MeasureTheory.SimpleFunc.setToSimpleFunc_congr_left
theorem setToSimpleFunc_add_left {m : MeasurableSpace α} (T T' : Set α → F →L[ℝ] F') {f : α →ₛ F} :
setToSimpleFunc (T + T') f = setToSimpleFunc T f + setToSimpleFunc T' f := by
simp_rw [setToSimpleFunc, Pi.add_apply]
push_cast
simp_rw [Pi.add_apply, sum_add_distrib]
#align measure_theory.simple_func.set_to_simple_func_add_left MeasureTheory.SimpleFunc.setToSimpleFunc_add_left
theorem setToSimpleFunc_add_left' (T T' T'' : Set α → E →L[ℝ] F)
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) {f : α →ₛ E}
(hf : Integrable f μ) : setToSimpleFunc T'' f = setToSimpleFunc T f + setToSimpleFunc T' f := by
simp_rw [setToSimpleFunc_eq_sum_filter]
suffices
∀ x ∈ filter (fun x : E => x ≠ 0) f.range, T'' (f ⁻¹' {x}) = T (f ⁻¹' {x}) + T' (f ⁻¹' {x}) by
rw [← sum_add_distrib]
refine Finset.sum_congr rfl fun x hx => ?_
rw [this x hx]
push_cast
rw [Pi.add_apply]
intro x hx
refine
h_add (f ⁻¹' {x}) (measurableSet_preimage _ _) (measure_preimage_lt_top_of_integrable _ hf ?_)
rw [mem_filter] at hx
exact hx.2
#align measure_theory.simple_func.set_to_simple_func_add_left' MeasureTheory.SimpleFunc.setToSimpleFunc_add_left'
theorem setToSimpleFunc_smul_left {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (c : ℝ)
(f : α →ₛ F) : setToSimpleFunc (fun s => c • T s) f = c • setToSimpleFunc T f := by
simp_rw [setToSimpleFunc, ContinuousLinearMap.smul_apply, smul_sum]
#align measure_theory.simple_func.set_to_simple_func_smul_left MeasureTheory.SimpleFunc.setToSimpleFunc_smul_left
theorem setToSimpleFunc_smul_left' (T T' : Set α → E →L[ℝ] F') (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) {f : α →ₛ E} (hf : Integrable f μ) :
setToSimpleFunc T' f = c • setToSimpleFunc T f := by
simp_rw [setToSimpleFunc_eq_sum_filter]
suffices ∀ x ∈ filter (fun x : E => x ≠ 0) f.range, T' (f ⁻¹' {x}) = c • T (f ⁻¹' {x}) by
rw [smul_sum]
refine Finset.sum_congr rfl fun x hx => ?_
rw [this x hx]
rfl
intro x hx
refine
h_smul (f ⁻¹' {x}) (measurableSet_preimage _ _) (measure_preimage_lt_top_of_integrable _ hf ?_)
rw [mem_filter] at hx
exact hx.2
#align measure_theory.simple_func.set_to_simple_func_smul_left' MeasureTheory.SimpleFunc.setToSimpleFunc_smul_left'
theorem setToSimpleFunc_add (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E}
(hf : Integrable f μ) (hg : Integrable g μ) :
setToSimpleFunc T (f + g) = setToSimpleFunc T f + setToSimpleFunc T g :=
have hp_pair : Integrable (f.pair g) μ := integrable_pair hf hg
calc
setToSimpleFunc T (f + g) = ∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) (x.fst + x.snd) := by
rw [add_eq_map₂, map_setToSimpleFunc T h_add hp_pair]; simp
_ = ∑ x ∈ (pair f g).range, (T (pair f g ⁻¹' {x}) x.fst + T (pair f g ⁻¹' {x}) x.snd) :=
(Finset.sum_congr rfl fun a _ => ContinuousLinearMap.map_add _ _ _)
_ = (∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) x.fst) +
∑ x ∈ (pair f g).range, T (pair f g ⁻¹' {x}) x.snd := by
rw [Finset.sum_add_distrib]
_ = ((pair f g).map Prod.fst).setToSimpleFunc T +
((pair f g).map Prod.snd).setToSimpleFunc T := by
rw [map_setToSimpleFunc T h_add hp_pair Prod.snd_zero,
map_setToSimpleFunc T h_add hp_pair Prod.fst_zero]
#align measure_theory.simple_func.set_to_simple_func_add MeasureTheory.SimpleFunc.setToSimpleFunc_add
theorem setToSimpleFunc_neg (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f : α →ₛ E}
(hf : Integrable f μ) : setToSimpleFunc T (-f) = -setToSimpleFunc T f :=
calc
setToSimpleFunc T (-f) = setToSimpleFunc T (f.map Neg.neg) := rfl
_ = -setToSimpleFunc T f := by
rw [map_setToSimpleFunc T h_add hf neg_zero, setToSimpleFunc, ← sum_neg_distrib]
exact Finset.sum_congr rfl fun x _ => ContinuousLinearMap.map_neg _ _
#align measure_theory.simple_func.set_to_simple_func_neg MeasureTheory.SimpleFunc.setToSimpleFunc_neg
theorem setToSimpleFunc_sub (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) {f g : α →ₛ E}
(hf : Integrable f μ) (hg : Integrable g μ) :
setToSimpleFunc T (f - g) = setToSimpleFunc T f - setToSimpleFunc T g := by
rw [sub_eq_add_neg, setToSimpleFunc_add T h_add hf, setToSimpleFunc_neg T h_add hg,
sub_eq_add_neg]
rw [integrable_iff] at hg ⊢
intro x hx_ne
change μ (Neg.neg ∘ g ⁻¹' {x}) < ∞
rw [preimage_comp, neg_preimage, Set.neg_singleton]
refine hg (-x) ?_
simp [hx_ne]
#align measure_theory.simple_func.set_to_simple_func_sub MeasureTheory.SimpleFunc.setToSimpleFunc_sub
theorem setToSimpleFunc_smul_real (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T) (c : ℝ)
{f : α →ₛ E} (hf : Integrable f μ) : setToSimpleFunc T (c • f) = c • setToSimpleFunc T f :=
calc
setToSimpleFunc T (c • f) = ∑ x ∈ f.range, T (f ⁻¹' {x}) (c • x) := by
rw [smul_eq_map c f, map_setToSimpleFunc T h_add hf]; dsimp only; rw [smul_zero]
_ = ∑ x ∈ f.range, c • T (f ⁻¹' {x}) x :=
(Finset.sum_congr rfl fun b _ => by rw [ContinuousLinearMap.map_smul (T (f ⁻¹' {b})) c b])
_ = c • setToSimpleFunc T f := by simp only [setToSimpleFunc, smul_sum, smul_smul, mul_comm]
#align measure_theory.simple_func.set_to_simple_func_smul_real MeasureTheory.SimpleFunc.setToSimpleFunc_smul_real
theorem setToSimpleFunc_smul {E} [NormedAddCommGroup E] [NormedField 𝕜] [NormedSpace 𝕜 E]
[NormedSpace ℝ E] [NormedSpace 𝕜 F] (T : Set α → E →L[ℝ] F) (h_add : FinMeasAdditive μ T)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜) {f : α →ₛ E} (hf : Integrable f μ) :
setToSimpleFunc T (c • f) = c • setToSimpleFunc T f :=
calc
setToSimpleFunc T (c • f) = ∑ x ∈ f.range, T (f ⁻¹' {x}) (c • x) := by
rw [smul_eq_map c f, map_setToSimpleFunc T h_add hf]; dsimp only; rw [smul_zero]
_ = ∑ x ∈ f.range, c • T (f ⁻¹' {x}) x := Finset.sum_congr rfl fun b _ => by rw [h_smul]
_ = c • setToSimpleFunc T f := by simp only [setToSimpleFunc, smul_sum, smul_smul, mul_comm]
#align measure_theory.simple_func.set_to_simple_func_smul MeasureTheory.SimpleFunc.setToSimpleFunc_smul
section Order
variable {G' G'' : Type*} [NormedLatticeAddCommGroup G''] [NormedSpace ℝ G'']
[NormedLatticeAddCommGroup G'] [NormedSpace ℝ G']
theorem setToSimpleFunc_mono_left {m : MeasurableSpace α} (T T' : Set α → F →L[ℝ] G'')
(hTT' : ∀ s x, T s x ≤ T' s x) (f : α →ₛ F) : setToSimpleFunc T f ≤ setToSimpleFunc T' f := by
simp_rw [setToSimpleFunc]; exact sum_le_sum fun i _ => hTT' _ i
#align measure_theory.simple_func.set_to_simple_func_mono_left MeasureTheory.SimpleFunc.setToSimpleFunc_mono_left
theorem setToSimpleFunc_mono_left' (T T' : Set α → E →L[ℝ] G'')
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →ₛ E)
(hf : Integrable f μ) : setToSimpleFunc T f ≤ setToSimpleFunc T' f := by
refine sum_le_sum fun i _ => ?_
by_cases h0 : i = 0
· simp [h0]
· exact hTT' _ (measurableSet_fiber _ _) (measure_preimage_lt_top_of_integrable _ hf h0) i
#align measure_theory.simple_func.set_to_simple_func_mono_left' MeasureTheory.SimpleFunc.setToSimpleFunc_mono_left'
theorem setToSimpleFunc_nonneg {m : MeasurableSpace α} (T : Set α → G' →L[ℝ] G'')
(hT_nonneg : ∀ s x, 0 ≤ x → 0 ≤ T s x) (f : α →ₛ G') (hf : 0 ≤ f) :
0 ≤ setToSimpleFunc T f := by
refine sum_nonneg fun i hi => hT_nonneg _ i ?_
rw [mem_range] at hi
obtain ⟨y, hy⟩ := Set.mem_range.mp hi
rw [← hy]
refine le_trans ?_ (hf y)
simp
#align measure_theory.simple_func.set_to_simple_func_nonneg MeasureTheory.SimpleFunc.setToSimpleFunc_nonneg
theorem setToSimpleFunc_nonneg' (T : Set α → G' →L[ℝ] G'')
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) (f : α →ₛ G') (hf : 0 ≤ f)
(hfi : Integrable f μ) : 0 ≤ setToSimpleFunc T f := by
refine sum_nonneg fun i hi => ?_
by_cases h0 : i = 0
· simp [h0]
refine
hT_nonneg _ (measurableSet_fiber _ _) (measure_preimage_lt_top_of_integrable _ hfi h0) i ?_
rw [mem_range] at hi
obtain ⟨y, hy⟩ := Set.mem_range.mp hi
rw [← hy]
convert hf y
#align measure_theory.simple_func.set_to_simple_func_nonneg' MeasureTheory.SimpleFunc.setToSimpleFunc_nonneg'
theorem setToSimpleFunc_mono {T : Set α → G' →L[ℝ] G''} (h_add : FinMeasAdditive μ T)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →ₛ G'}
(hfi : Integrable f μ) (hgi : Integrable g μ) (hfg : f ≤ g) :
setToSimpleFunc T f ≤ setToSimpleFunc T g := by
rw [← sub_nonneg, ← setToSimpleFunc_sub T h_add hgi hfi]
refine setToSimpleFunc_nonneg' T hT_nonneg _ ?_ (hgi.sub hfi)
intro x
simp only [coe_sub, sub_nonneg, coe_zero, Pi.zero_apply, Pi.sub_apply]
exact hfg x
#align measure_theory.simple_func.set_to_simple_func_mono MeasureTheory.SimpleFunc.setToSimpleFunc_mono
end Order
theorem norm_setToSimpleFunc_le_sum_opNorm {m : MeasurableSpace α} (T : Set α → F' →L[ℝ] F)
(f : α →ₛ F') : ‖f.setToSimpleFunc T‖ ≤ ∑ x ∈ f.range, ‖T (f ⁻¹' {x})‖ * ‖x‖ :=
calc
‖∑ x ∈ f.range, T (f ⁻¹' {x}) x‖ ≤ ∑ x ∈ f.range, ‖T (f ⁻¹' {x}) x‖ := norm_sum_le _ _
_ ≤ ∑ x ∈ f.range, ‖T (f ⁻¹' {x})‖ * ‖x‖ := by
refine Finset.sum_le_sum fun b _ => ?_; simp_rw [ContinuousLinearMap.le_opNorm]
#align measure_theory.simple_func.norm_set_to_simple_func_le_sum_op_norm MeasureTheory.SimpleFunc.norm_setToSimpleFunc_le_sum_opNorm
@[deprecated (since := "2024-02-02")]
alias norm_setToSimpleFunc_le_sum_op_norm := norm_setToSimpleFunc_le_sum_opNorm
theorem norm_setToSimpleFunc_le_sum_mul_norm (T : Set α → F →L[ℝ] F') {C : ℝ}
(hT_norm : ∀ s, MeasurableSet s → ‖T s‖ ≤ C * (μ s).toReal) (f : α →ₛ F) :
‖f.setToSimpleFunc T‖ ≤ C * ∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal * ‖x‖ :=
calc
‖f.setToSimpleFunc T‖ ≤ ∑ x ∈ f.range, ‖T (f ⁻¹' {x})‖ * ‖x‖ :=
norm_setToSimpleFunc_le_sum_opNorm T f
_ ≤ ∑ x ∈ f.range, C * (μ (f ⁻¹' {x})).toReal * ‖x‖ := by
gcongr
exact hT_norm _ <| SimpleFunc.measurableSet_fiber _ _
_ ≤ C * ∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal * ‖x‖ := by simp_rw [mul_sum, ← mul_assoc]; rfl
#align measure_theory.simple_func.norm_set_to_simple_func_le_sum_mul_norm MeasureTheory.SimpleFunc.norm_setToSimpleFunc_le_sum_mul_norm
theorem norm_setToSimpleFunc_le_sum_mul_norm_of_integrable (T : Set α → E →L[ℝ] F') {C : ℝ}
(hT_norm : ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal) (f : α →ₛ E)
(hf : Integrable f μ) :
‖f.setToSimpleFunc T‖ ≤ C * ∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal * ‖x‖ :=
calc
‖f.setToSimpleFunc T‖ ≤ ∑ x ∈ f.range, ‖T (f ⁻¹' {x})‖ * ‖x‖ :=
norm_setToSimpleFunc_le_sum_opNorm T f
_ ≤ ∑ x ∈ f.range, C * (μ (f ⁻¹' {x})).toReal * ‖x‖ := by
refine Finset.sum_le_sum fun b hb => ?_
obtain rfl | hb := eq_or_ne b 0
· simp
gcongr
exact hT_norm _ (SimpleFunc.measurableSet_fiber _ _) <|
SimpleFunc.measure_preimage_lt_top_of_integrable _ hf hb
_ ≤ C * ∑ x ∈ f.range, (μ (f ⁻¹' {x})).toReal * ‖x‖ := by simp_rw [mul_sum, ← mul_assoc]; rfl
#align measure_theory.simple_func.norm_set_to_simple_func_le_sum_mul_norm_of_integrable MeasureTheory.SimpleFunc.norm_setToSimpleFunc_le_sum_mul_norm_of_integrable
theorem setToSimpleFunc_indicator (T : Set α → F →L[ℝ] F') (hT_empty : T ∅ = 0)
{m : MeasurableSpace α} {s : Set α} (hs : MeasurableSet s) (x : F) :
SimpleFunc.setToSimpleFunc T
(SimpleFunc.piecewise s hs (SimpleFunc.const α x) (SimpleFunc.const α 0)) =
T s x := by
obtain rfl | hs_empty := s.eq_empty_or_nonempty
· simp only [hT_empty, ContinuousLinearMap.zero_apply, piecewise_empty, const_zero,
setToSimpleFunc_zero_apply]
simp_rw [setToSimpleFunc]
obtain rfl | hs_univ := eq_or_ne s univ
· haveI hα := hs_empty.to_type
simp [← Function.const_def]
rw [range_indicator hs hs_empty hs_univ]
by_cases hx0 : x = 0
· simp_rw [hx0]; simp
rw [sum_insert]
swap; · rw [Finset.mem_singleton]; exact hx0
rw [sum_singleton, (T _).map_zero, add_zero]
congr
simp only [coe_piecewise, piecewise_eq_indicator, coe_const, Function.const_zero,
piecewise_eq_indicator]
rw [indicator_preimage, ← Function.const_def, preimage_const_of_mem]
swap; · exact Set.mem_singleton x
rw [← Function.const_zero, ← Function.const_def, preimage_const_of_not_mem]
swap; · rw [Set.mem_singleton_iff]; exact Ne.symm hx0
simp
#align measure_theory.simple_func.set_to_simple_func_indicator MeasureTheory.SimpleFunc.setToSimpleFunc_indicator
theorem setToSimpleFunc_const' [Nonempty α] (T : Set α → F →L[ℝ] F') (x : F)
{m : MeasurableSpace α} : SimpleFunc.setToSimpleFunc T (SimpleFunc.const α x) = T univ x := by
simp only [setToSimpleFunc, range_const, Set.mem_singleton, preimage_const_of_mem,
sum_singleton, ← Function.const_def, coe_const]
#align measure_theory.simple_func.set_to_simple_func_const' MeasureTheory.SimpleFunc.setToSimpleFunc_const'
theorem setToSimpleFunc_const (T : Set α → F →L[ℝ] F') (hT_empty : T ∅ = 0) (x : F)
{m : MeasurableSpace α} : SimpleFunc.setToSimpleFunc T (SimpleFunc.const α x) = T univ x := by
cases isEmpty_or_nonempty α
· have h_univ_empty : (univ : Set α) = ∅ := Subsingleton.elim _ _
rw [h_univ_empty, hT_empty]
simp only [setToSimpleFunc, ContinuousLinearMap.zero_apply, sum_empty,
range_eq_empty_of_isEmpty]
· exact setToSimpleFunc_const' T x
#align measure_theory.simple_func.set_to_simple_func_const MeasureTheory.SimpleFunc.setToSimpleFunc_const
end SimpleFunc
namespace L1
set_option linter.uppercaseLean3 false
open AEEqFun Lp.simpleFunc Lp
namespace SimpleFunc
theorem norm_eq_sum_mul (f : α →₁ₛ[μ] G) :
‖f‖ = ∑ x ∈ (toSimpleFunc f).range, (μ (toSimpleFunc f ⁻¹' {x})).toReal * ‖x‖ := by
rw [norm_toSimpleFunc, snorm_one_eq_lintegral_nnnorm]
have h_eq := SimpleFunc.map_apply (fun x => (‖x‖₊ : ℝ≥0∞)) (toSimpleFunc f)
simp_rw [← h_eq]
rw [SimpleFunc.lintegral_eq_lintegral, SimpleFunc.map_lintegral, ENNReal.toReal_sum]
· congr
ext1 x
rw [ENNReal.toReal_mul, mul_comm, ← ofReal_norm_eq_coe_nnnorm,
ENNReal.toReal_ofReal (norm_nonneg _)]
· intro x _
by_cases hx0 : x = 0
· rw [hx0]; simp
· exact
ENNReal.mul_ne_top ENNReal.coe_ne_top
(SimpleFunc.measure_preimage_lt_top_of_integrable _ (SimpleFunc.integrable f) hx0).ne
#align measure_theory.L1.simple_func.norm_eq_sum_mul MeasureTheory.L1.SimpleFunc.norm_eq_sum_mul
section SetToL1S
variable [NormedField 𝕜] [NormedSpace 𝕜 E]
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
/-- Extend `Set α → (E →L[ℝ] F')` to `(α →₁ₛ[μ] E) → F'`. -/
def setToL1S (T : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) : F :=
(toSimpleFunc f).setToSimpleFunc T
#align measure_theory.L1.simple_func.set_to_L1s MeasureTheory.L1.SimpleFunc.setToL1S
theorem setToL1S_eq_setToSimpleFunc (T : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) :
setToL1S T f = (toSimpleFunc f).setToSimpleFunc T :=
rfl
#align measure_theory.L1.simple_func.set_to_L1s_eq_set_to_simple_func MeasureTheory.L1.SimpleFunc.setToL1S_eq_setToSimpleFunc
@[simp]
theorem setToL1S_zero_left (f : α →₁ₛ[μ] E) : setToL1S (0 : Set α → E →L[ℝ] F) f = 0 :=
SimpleFunc.setToSimpleFunc_zero _
#align measure_theory.L1.simple_func.set_to_L1s_zero_left MeasureTheory.L1.SimpleFunc.setToL1S_zero_left
theorem setToL1S_zero_left' {T : Set α → E →L[ℝ] F}
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁ₛ[μ] E) : setToL1S T f = 0 :=
SimpleFunc.setToSimpleFunc_zero' h_zero _ (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_zero_left' MeasureTheory.L1.SimpleFunc.setToL1S_zero_left'
theorem setToL1S_congr (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) {f g : α →₁ₛ[μ] E} (h : toSimpleFunc f =ᵐ[μ] toSimpleFunc g) :
setToL1S T f = setToL1S T g :=
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) h
#align measure_theory.L1.simple_func.set_to_L1s_congr MeasureTheory.L1.SimpleFunc.setToL1S_congr
theorem setToL1S_congr_left (T T' : Set α → E →L[ℝ] F)
(h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →₁ₛ[μ] E) :
setToL1S T f = setToL1S T' f :=
SimpleFunc.setToSimpleFunc_congr_left T T' h (simpleFunc.toSimpleFunc f) (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_congr_left MeasureTheory.L1.SimpleFunc.setToL1S_congr_left
/-- `setToL1S` does not change if we replace the measure `μ` by `μ'` with `μ ≪ μ'`. The statement
uses two functions `f` and `f'` because they have to belong to different types, but morally these
are the same function (we have `f =ᵐ[μ] f'`). -/
theorem setToL1S_congr_measure {μ' : Measure α} (T : Set α → E →L[ℝ] F)
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (hμ : μ ≪ μ')
(f : α →₁ₛ[μ] E) (f' : α →₁ₛ[μ'] E) (h : (f : α → E) =ᵐ[μ] f') :
setToL1S T f = setToL1S T f' := by
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable f) ?_
refine (toSimpleFunc_eq_toFun f).trans ?_
suffices (f' : α → E) =ᵐ[μ] simpleFunc.toSimpleFunc f' from h.trans this
have goal' : (f' : α → E) =ᵐ[μ'] simpleFunc.toSimpleFunc f' := (toSimpleFunc_eq_toFun f').symm
exact hμ.ae_eq goal'
#align measure_theory.L1.simple_func.set_to_L1s_congr_measure MeasureTheory.L1.SimpleFunc.setToL1S_congr_measure
theorem setToL1S_add_left (T T' : Set α → E →L[ℝ] F) (f : α →₁ₛ[μ] E) :
setToL1S (T + T') f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left T T'
#align measure_theory.L1.simple_func.set_to_L1s_add_left MeasureTheory.L1.SimpleFunc.setToL1S_add_left
theorem setToL1S_add_left' (T T' T'' : Set α → E →L[ℝ] F)
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁ₛ[μ] E) :
setToL1S T'' f = setToL1S T f + setToL1S T' f :=
SimpleFunc.setToSimpleFunc_add_left' T T' T'' h_add (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_add_left' MeasureTheory.L1.SimpleFunc.setToL1S_add_left'
theorem setToL1S_smul_left (T : Set α → E →L[ℝ] F) (c : ℝ) (f : α →₁ₛ[μ] E) :
setToL1S (fun s => c • T s) f = c • setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left T c _
#align measure_theory.L1.simple_func.set_to_L1s_smul_left MeasureTheory.L1.SimpleFunc.setToL1S_smul_left
theorem setToL1S_smul_left' (T T' : Set α → E →L[ℝ] F) (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁ₛ[μ] E) :
setToL1S T' f = c • setToL1S T f :=
SimpleFunc.setToSimpleFunc_smul_left' T T' c h_smul (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_smul_left' MeasureTheory.L1.SimpleFunc.setToL1S_smul_left'
theorem setToL1S_add (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f g : α →₁ₛ[μ] E) :
setToL1S T (f + g) = setToL1S T f + setToL1S T g := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_add T h_add (SimpleFunc.integrable f)
(SimpleFunc.integrable g)]
exact
SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _)
(add_toSimpleFunc f g)
#align measure_theory.L1.simple_func.set_to_L1s_add MeasureTheory.L1.SimpleFunc.setToL1S_add
theorem setToL1S_neg {T : Set α → E →L[ℝ] F} (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f : α →₁ₛ[μ] E) : setToL1S T (-f) = -setToL1S T f := by
simp_rw [setToL1S]
have : simpleFunc.toSimpleFunc (-f) =ᵐ[μ] ⇑(-simpleFunc.toSimpleFunc f) :=
neg_toSimpleFunc f
rw [SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) this]
exact SimpleFunc.setToSimpleFunc_neg T h_add (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_neg MeasureTheory.L1.SimpleFunc.setToL1S_neg
theorem setToL1S_sub {T : Set α → E →L[ℝ] F} (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (f g : α →₁ₛ[μ] E) :
setToL1S T (f - g) = setToL1S T f - setToL1S T g := by
rw [sub_eq_add_neg, setToL1S_add T h_zero h_add, setToL1S_neg h_zero h_add, sub_eq_add_neg]
#align measure_theory.L1.simple_func.set_to_L1s_sub MeasureTheory.L1.SimpleFunc.setToL1S_sub
theorem setToL1S_smul_real (T : Set α → E →L[ℝ] F)
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (c : ℝ)
(f : α →₁ₛ[μ] E) : setToL1S T (c • f) = c • setToL1S T f := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_smul_real T h_add c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
#align measure_theory.L1.simple_func.set_to_L1s_smul_real MeasureTheory.L1.SimpleFunc.setToL1S_smul_real
theorem setToL1S_smul {E} [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedSpace 𝕜 E]
[NormedSpace 𝕜 F] (T : Set α → E →L[ℝ] F) (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T) (h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜)
(f : α →₁ₛ[μ] E) : setToL1S T (c • f) = c • setToL1S T f := by
simp_rw [setToL1S]
rw [← SimpleFunc.setToSimpleFunc_smul T h_add h_smul c (SimpleFunc.integrable f)]
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact smul_toSimpleFunc c f
#align measure_theory.L1.simple_func.set_to_L1s_smul MeasureTheory.L1.SimpleFunc.setToL1S_smul
theorem norm_setToL1S_le (T : Set α → E →L[ℝ] F) {C : ℝ}
(hT_norm : ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal) (f : α →₁ₛ[μ] E) :
‖setToL1S T f‖ ≤ C * ‖f‖ := by
rw [setToL1S, norm_eq_sum_mul f]
exact
SimpleFunc.norm_setToSimpleFunc_le_sum_mul_norm_of_integrable T hT_norm _
(SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.norm_set_to_L1s_le MeasureTheory.L1.SimpleFunc.norm_setToL1S_le
theorem setToL1S_indicatorConst {T : Set α → E →L[ℝ] F} {s : Set α}
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T)
(hs : MeasurableSet s) (hμs : μ s < ∞) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 hs hμs.ne x) = T s x := by
have h_empty : T ∅ = 0 := h_zero _ MeasurableSet.empty measure_empty
rw [setToL1S_eq_setToSimpleFunc]
refine Eq.trans ?_ (SimpleFunc.setToSimpleFunc_indicator T h_empty hs x)
refine SimpleFunc.setToSimpleFunc_congr T h_zero h_add (SimpleFunc.integrable _) ?_
exact toSimpleFunc_indicatorConst hs hμs.ne x
#align measure_theory.L1.simple_func.set_to_L1s_indicator_const MeasureTheory.L1.SimpleFunc.setToL1S_indicatorConst
theorem setToL1S_const [IsFiniteMeasure μ] {T : Set α → E →L[ℝ] F}
(h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0) (h_add : FinMeasAdditive μ T) (x : E) :
setToL1S T (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top μ _) x) = T univ x :=
setToL1S_indicatorConst h_zero h_add MeasurableSet.univ (measure_lt_top _ _) x
#align measure_theory.L1.simple_func.set_to_L1s_const MeasureTheory.L1.SimpleFunc.setToL1S_const
section Order
variable {G'' G' : Type*} [NormedLatticeAddCommGroup G'] [NormedSpace ℝ G']
[NormedLatticeAddCommGroup G''] [NormedSpace ℝ G''] {T : Set α → G'' →L[ℝ] G'}
theorem setToL1S_mono_left {T T' : Set α → E →L[ℝ] G''} (hTT' : ∀ s x, T s x ≤ T' s x)
(f : α →₁ₛ[μ] E) : setToL1S T f ≤ setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
#align measure_theory.L1.simple_func.set_to_L1s_mono_left MeasureTheory.L1.SimpleFunc.setToL1S_mono_left
theorem setToL1S_mono_left' {T T' : Set α → E →L[ℝ] G''}
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1S T f ≤ setToL1S T' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_mono_left' MeasureTheory.L1.SimpleFunc.setToL1S_mono_left'
theorem setToL1S_nonneg (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f : α →₁ₛ[μ] G''}
(hf : 0 ≤ f) : 0 ≤ setToL1S T f := by
simp_rw [setToL1S]
obtain ⟨f', hf', hff'⟩ : ∃ f' : α →ₛ G'', 0 ≤ f' ∧ simpleFunc.toSimpleFunc f =ᵐ[μ] f' := by
obtain ⟨f'', hf'', hff''⟩ := exists_simpleFunc_nonneg_ae_eq hf
exact ⟨f'', hf'', (Lp.simpleFunc.toSimpleFunc_eq_toFun f).trans hff''⟩
rw [SimpleFunc.setToSimpleFunc_congr _ h_zero h_add (SimpleFunc.integrable _) hff']
exact
SimpleFunc.setToSimpleFunc_nonneg' T hT_nonneg _ hf' ((SimpleFunc.integrable f).congr hff')
#align measure_theory.L1.simple_func.set_to_L1s_nonneg MeasureTheory.L1.SimpleFunc.setToL1S_nonneg
theorem setToL1S_mono (h_zero : ∀ s, MeasurableSet s → μ s = 0 → T s = 0)
(h_add : FinMeasAdditive μ T)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →₁ₛ[μ] G''}
(hfg : f ≤ g) : setToL1S T f ≤ setToL1S T g := by
rw [← sub_nonneg] at hfg ⊢
rw [← setToL1S_sub h_zero h_add]
exact setToL1S_nonneg h_zero h_add hT_nonneg hfg
#align measure_theory.L1.simple_func.set_to_L1s_mono MeasureTheory.L1.SimpleFunc.setToL1S_mono
end Order
variable [NormedSpace 𝕜 F]
variable (α E μ 𝕜)
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁ₛ[μ] E) →L[𝕜] F`. -/
def setToL1SCLM' {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) : (α →₁ₛ[μ] E) →L[𝕜] F :=
LinearMap.mkContinuous
⟨⟨setToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩,
setToL1S_smul T (fun _ => hT.eq_zero_of_measure_zero) hT.1 h_smul⟩
C fun f => norm_setToL1S_le T hT.2 f
#align measure_theory.L1.simple_func.set_to_L1s_clm' MeasureTheory.L1.SimpleFunc.setToL1SCLM'
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁ₛ[μ] E) →L[ℝ] F`. -/
def setToL1SCLM {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C) :
(α →₁ₛ[μ] E) →L[ℝ] F :=
LinearMap.mkContinuous
⟨⟨setToL1S T, setToL1S_add T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩,
setToL1S_smul_real T (fun _ => hT.eq_zero_of_measure_zero) hT.1⟩
C fun f => norm_setToL1S_le T hT.2 f
#align measure_theory.L1.simple_func.set_to_L1s_clm MeasureTheory.L1.SimpleFunc.setToL1SCLM
variable {α E μ 𝕜}
variable {T T' T'' : Set α → E →L[ℝ] F} {C C' C'' : ℝ}
@[simp]
theorem setToL1SCLM_zero_left (hT : DominatedFinMeasAdditive μ (0 : Set α → E →L[ℝ] F) C)
(f : α →₁ₛ[μ] E) : setToL1SCLM α E μ hT f = 0 :=
setToL1S_zero_left _
#align measure_theory.L1.simple_func.set_to_L1s_clm_zero_left MeasureTheory.L1.SimpleFunc.setToL1SCLM_zero_left
theorem setToL1SCLM_zero_left' (hT : DominatedFinMeasAdditive μ T C)
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f = 0 :=
setToL1S_zero_left' h_zero f
#align measure_theory.L1.simple_func.set_to_L1s_clm_zero_left' MeasureTheory.L1.SimpleFunc.setToL1SCLM_zero_left'
theorem setToL1SCLM_congr_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : T = T') (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f = setToL1SCLM α E μ hT' f :=
setToL1S_congr_left T T' (fun _ _ _ => by rw [h]) f
#align measure_theory.L1.simple_func.set_to_L1s_clm_congr_left MeasureTheory.L1.SimpleFunc.setToL1SCLM_congr_left
theorem setToL1SCLM_congr_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s)
(f : α →₁ₛ[μ] E) : setToL1SCLM α E μ hT f = setToL1SCLM α E μ hT' f :=
setToL1S_congr_left T T' h f
#align measure_theory.L1.simple_func.set_to_L1s_clm_congr_left' MeasureTheory.L1.SimpleFunc.setToL1SCLM_congr_left'
theorem setToL1SCLM_congr_measure {μ' : Measure α} (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ' T C') (hμ : μ ≪ μ') (f : α →₁ₛ[μ] E) (f' : α →₁ₛ[μ'] E)
(h : (f : α → E) =ᵐ[μ] f') : setToL1SCLM α E μ hT f = setToL1SCLM α E μ' hT' f' :=
setToL1S_congr_measure T (fun _ => hT.eq_zero_of_measure_zero) hT.1 hμ _ _ h
#align measure_theory.L1.simple_func.set_to_L1s_clm_congr_measure MeasureTheory.L1.SimpleFunc.setToL1SCLM_congr_measure
theorem setToL1SCLM_add_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ (hT.add hT') f = setToL1SCLM α E μ hT f + setToL1SCLM α E μ hT' f :=
setToL1S_add_left T T' f
#align measure_theory.L1.simple_func.set_to_L1s_clm_add_left MeasureTheory.L1.SimpleFunc.setToL1SCLM_add_left
theorem setToL1SCLM_add_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (hT'' : DominatedFinMeasAdditive μ T'' C'')
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT'' f = setToL1SCLM α E μ hT f + setToL1SCLM α E μ hT' f :=
setToL1S_add_left' T T' T'' h_add f
#align measure_theory.L1.simple_func.set_to_L1s_clm_add_left' MeasureTheory.L1.SimpleFunc.setToL1SCLM_add_left'
theorem setToL1SCLM_smul_left (c : ℝ) (hT : DominatedFinMeasAdditive μ T C) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ (hT.smul c) f = c • setToL1SCLM α E μ hT f :=
setToL1S_smul_left T c f
#align measure_theory.L1.simple_func.set_to_L1s_clm_smul_left MeasureTheory.L1.SimpleFunc.setToL1SCLM_smul_left
theorem setToL1SCLM_smul_left' (c : ℝ) (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C')
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT' f = c • setToL1SCLM α E μ hT f :=
setToL1S_smul_left' T T' c h_smul f
#align measure_theory.L1.simple_func.set_to_L1s_clm_smul_left' MeasureTheory.L1.SimpleFunc.setToL1SCLM_smul_left'
theorem norm_setToL1SCLM_le {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hC : 0 ≤ C) : ‖setToL1SCLM α E μ hT‖ ≤ C :=
LinearMap.mkContinuous_norm_le _ hC _
#align measure_theory.L1.simple_func.norm_set_to_L1s_clm_le MeasureTheory.L1.SimpleFunc.norm_setToL1SCLM_le
theorem norm_setToL1SCLM_le' {T : Set α → E →L[ℝ] F} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C) :
‖setToL1SCLM α E μ hT‖ ≤ max C 0 :=
LinearMap.mkContinuous_norm_le' _ _
#align measure_theory.L1.simple_func.norm_set_to_L1s_clm_le' MeasureTheory.L1.SimpleFunc.norm_setToL1SCLM_le'
theorem setToL1SCLM_const [IsFiniteMeasure μ] {T : Set α → E →L[ℝ] F} {C : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (x : E) :
setToL1SCLM α E μ hT (simpleFunc.indicatorConst 1 MeasurableSet.univ (measure_ne_top μ _) x) =
T univ x :=
setToL1S_const (fun _ => hT.eq_zero_of_measure_zero) hT.1 x
#align measure_theory.L1.simple_func.set_to_L1s_clm_const MeasureTheory.L1.SimpleFunc.setToL1SCLM_const
section Order
variable {G' G'' : Type*} [NormedLatticeAddCommGroup G''] [NormedSpace ℝ G'']
[NormedLatticeAddCommGroup G'] [NormedSpace ℝ G']
theorem setToL1SCLM_mono_left {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f ≤ setToL1SCLM α E μ hT' f :=
SimpleFunc.setToSimpleFunc_mono_left T T' hTT' _
#align measure_theory.L1.simple_func.set_to_L1s_clm_mono_left MeasureTheory.L1.SimpleFunc.setToL1SCLM_mono_left
theorem setToL1SCLM_mono_left' {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁ₛ[μ] E) :
setToL1SCLM α E μ hT f ≤ setToL1SCLM α E μ hT' f :=
SimpleFunc.setToSimpleFunc_mono_left' T T' hTT' _ (SimpleFunc.integrable f)
#align measure_theory.L1.simple_func.set_to_L1s_clm_mono_left' MeasureTheory.L1.SimpleFunc.setToL1SCLM_mono_left'
theorem setToL1SCLM_nonneg {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f : α →₁ₛ[μ] G'}
(hf : 0 ≤ f) : 0 ≤ setToL1SCLM α G' μ hT f :=
setToL1S_nonneg (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hf
#align measure_theory.L1.simple_func.set_to_L1s_clm_nonneg MeasureTheory.L1.SimpleFunc.setToL1SCLM_nonneg
theorem setToL1SCLM_mono {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →₁ₛ[μ] G'}
(hfg : f ≤ g) : setToL1SCLM α G' μ hT f ≤ setToL1SCLM α G' μ hT g :=
setToL1S_mono (fun _ => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg hfg
#align measure_theory.L1.simple_func.set_to_L1s_clm_mono MeasureTheory.L1.SimpleFunc.setToL1SCLM_mono
end Order
end SetToL1S
end SimpleFunc
open SimpleFunc
section SetToL1
attribute [local instance] Lp.simpleFunc.module
attribute [local instance] Lp.simpleFunc.normedSpace
variable (𝕜) [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F] [CompleteSpace F]
{T T' T'' : Set α → E →L[ℝ] F} {C C' C'' : ℝ}
/-- Extend `set α → (E →L[ℝ] F)` to `(α →₁[μ] E) →L[𝕜] F`. -/
def setToL1' (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) : (α →₁[μ] E) →L[𝕜] F :=
(setToL1SCLM' α E 𝕜 μ hT h_smul).extend (coeToLp α E 𝕜) (simpleFunc.denseRange one_ne_top)
simpleFunc.uniformInducing
#align measure_theory.L1.set_to_L1' MeasureTheory.L1.setToL1'
variable {𝕜}
/-- Extend `Set α → E →L[ℝ] F` to `(α →₁[μ] E) →L[ℝ] F`. -/
def setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F :=
(setToL1SCLM α E μ hT).extend (coeToLp α E ℝ) (simpleFunc.denseRange one_ne_top)
simpleFunc.uniformInducing
#align measure_theory.L1.set_to_L1 MeasureTheory.L1.setToL1
theorem setToL1_eq_setToL1SCLM (hT : DominatedFinMeasAdditive μ T C) (f : α →₁ₛ[μ] E) :
setToL1 hT f = setToL1SCLM α E μ hT f :=
uniformly_extend_of_ind simpleFunc.uniformInducing (simpleFunc.denseRange one_ne_top)
(setToL1SCLM α E μ hT).uniformContinuous _
#align measure_theory.L1.set_to_L1_eq_set_to_L1s_clm MeasureTheory.L1.setToL1_eq_setToL1SCLM
theorem setToL1_eq_setToL1' (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (f : α →₁[μ] E) :
setToL1 hT f = setToL1' 𝕜 hT h_smul f :=
rfl
#align measure_theory.L1.set_to_L1_eq_set_to_L1' MeasureTheory.L1.setToL1_eq_setToL1'
@[simp]
theorem setToL1_zero_left (hT : DominatedFinMeasAdditive μ (0 : Set α → E →L[ℝ] F) C)
(f : α →₁[μ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left hT f, ContinuousLinearMap.zero_comp, ContinuousLinearMap.zero_apply]
#align measure_theory.L1.set_to_L1_zero_left MeasureTheory.L1.setToL1_zero_left
theorem setToL1_zero_left' (hT : DominatedFinMeasAdditive μ T C)
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →₁[μ] E) : setToL1 hT f = 0 := by
suffices setToL1 hT = 0 by rw [this]; simp
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
rw [setToL1SCLM_zero_left' hT h_zero f, ContinuousLinearMap.zero_comp,
ContinuousLinearMap.zero_apply]
#align measure_theory.L1.set_to_L1_zero_left' MeasureTheory.L1.setToL1_zero_left'
theorem setToL1_congr_left (T T' : Set α → E →L[ℝ] F) {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') (h : T = T')
(f : α →₁[μ] E) : setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E μ hT f by rw [← this]; rfl
rw [setToL1_eq_setToL1SCLM]
exact setToL1SCLM_congr_left hT' hT h.symm f
#align measure_theory.L1.set_to_L1_congr_left MeasureTheory.L1.setToL1_congr_left
theorem setToL1_congr_left' (T T' : Set α → E →L[ℝ] F) {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s) (f : α →₁[μ] E) :
setToL1 hT f = setToL1 hT' f := by
suffices setToL1 hT = setToL1 hT' by rw [this]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT) _ _ _ _ ?_
ext1 f
suffices setToL1 hT' f = setToL1SCLM α E μ hT f by rw [← this]; rfl
rw [setToL1_eq_setToL1SCLM]
exact (setToL1SCLM_congr_left' hT hT' h f).symm
#align measure_theory.L1.set_to_L1_congr_left' MeasureTheory.L1.setToL1_congr_left'
theorem setToL1_add_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (f : α →₁[μ] E) :
setToL1 (hT.add hT') f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 (hT.add hT') = setToL1 hT + setToL1 hT' by
rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ (hT.add hT')) _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E μ (hT.add hT') f by
rw [← this]; rfl
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM, setToL1SCLM_add_left hT hT']
#align measure_theory.L1.set_to_L1_add_left MeasureTheory.L1.setToL1_add_left
theorem setToL1_add_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (hT'' : DominatedFinMeasAdditive μ T'' C'')
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α →₁[μ] E) :
setToL1 hT'' f = setToL1 hT f + setToL1 hT' f := by
suffices setToL1 hT'' = setToL1 hT + setToL1 hT' by rw [this, ContinuousLinearMap.add_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT'') _ _ _ _ ?_
ext1 f
suffices setToL1 hT f + setToL1 hT' f = setToL1SCLM α E μ hT'' f by rw [← this]; congr
rw [setToL1_eq_setToL1SCLM, setToL1_eq_setToL1SCLM,
setToL1SCLM_add_left' hT hT' hT'' h_add]
#align measure_theory.L1.set_to_L1_add_left' MeasureTheory.L1.setToL1_add_left'
theorem setToL1_smul_left (hT : DominatedFinMeasAdditive μ T C) (c : ℝ) (f : α →₁[μ] E) :
setToL1 (hT.smul c) f = c • setToL1 hT f := by
suffices setToL1 (hT.smul c) = c • setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ (hT.smul c)) _ _ _ _ ?_
ext1 f
suffices c • setToL1 hT f = setToL1SCLM α E μ (hT.smul c) f by rw [← this]; congr
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left c hT]
#align measure_theory.L1.set_to_L1_smul_left MeasureTheory.L1.setToL1_smul_left
theorem setToL1_smul_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α →₁[μ] E) :
setToL1 hT' f = c • setToL1 hT f := by
suffices setToL1 hT' = c • setToL1 hT by rw [this, ContinuousLinearMap.smul_apply]
refine ContinuousLinearMap.extend_unique (setToL1SCLM α E μ hT') _ _ _ _ ?_
ext1 f
suffices c • setToL1 hT f = setToL1SCLM α E μ hT' f by rw [← this]; congr
rw [setToL1_eq_setToL1SCLM, setToL1SCLM_smul_left' c hT hT' h_smul]
#align measure_theory.L1.set_to_L1_smul_left' MeasureTheory.L1.setToL1_smul_left'
theorem setToL1_smul (hT : DominatedFinMeasAdditive μ T C)
(h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜) (f : α →₁[μ] E) :
setToL1 hT (c • f) = c • setToL1 hT f := by
rw [setToL1_eq_setToL1' hT h_smul, setToL1_eq_setToL1' hT h_smul]
exact ContinuousLinearMap.map_smul _ _ _
#align measure_theory.L1.set_to_L1_smul MeasureTheory.L1.setToL1_smul
theorem setToL1_simpleFunc_indicatorConst (hT : DominatedFinMeasAdditive μ T C) {s : Set α}
(hs : MeasurableSet s) (hμs : μ s < ∞) (x : E) :
setToL1 hT (simpleFunc.indicatorConst 1 hs hμs.ne x) = T s x := by
rw [setToL1_eq_setToL1SCLM]
exact setToL1S_indicatorConst (fun s => hT.eq_zero_of_measure_zero) hT.1 hs hμs x
#align measure_theory.L1.set_to_L1_simple_func_indicator_const MeasureTheory.L1.setToL1_simpleFunc_indicatorConst
theorem setToL1_indicatorConstLp (hT : DominatedFinMeasAdditive μ T C) {s : Set α}
(hs : MeasurableSet s) (hμs : μ s ≠ ∞) (x : E) :
setToL1 hT (indicatorConstLp 1 hs hμs x) = T s x := by
rw [← Lp.simpleFunc.coe_indicatorConst hs hμs x]
exact setToL1_simpleFunc_indicatorConst hT hs hμs.lt_top x
#align measure_theory.L1.set_to_L1_indicator_const_Lp MeasureTheory.L1.setToL1_indicatorConstLp
theorem setToL1_const [IsFiniteMeasure μ] (hT : DominatedFinMeasAdditive μ T C) (x : E) :
setToL1 hT (indicatorConstLp 1 MeasurableSet.univ (measure_ne_top _ _) x) = T univ x :=
setToL1_indicatorConstLp hT MeasurableSet.univ (measure_ne_top _ _) x
#align measure_theory.L1.set_to_L1_const MeasureTheory.L1.setToL1_const
section Order
variable {G' G'' : Type*} [NormedLatticeAddCommGroup G''] [NormedSpace ℝ G''] [CompleteSpace G'']
[NormedLatticeAddCommGroup G'] [NormedSpace ℝ G']
theorem setToL1_mono_left' {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, T s x ≤ T' s x) (f : α →₁[μ] E) :
setToL1 hT f ≤ setToL1 hT' f := by
induction f using Lp.induction (hp_ne_top := one_ne_top) with
| @h_ind c s hs hμs =>
rw [setToL1_simpleFunc_indicatorConst hT hs hμs, setToL1_simpleFunc_indicatorConst hT' hs hμs]
exact hTT' s hs hμs c
| @h_add f g hf hg _ hf_le hg_le =>
rw [(setToL1 hT).map_add, (setToL1 hT').map_add]
exact add_le_add hf_le hg_le
| h_closed => exact isClosed_le (setToL1 hT).continuous (setToL1 hT').continuous
#align measure_theory.L1.set_to_L1_mono_left' MeasureTheory.L1.setToL1_mono_left'
theorem setToL1_mono_left {T T' : Set α → E →L[ℝ] G''} {C C' : ℝ}
(hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C')
(hTT' : ∀ s x, T s x ≤ T' s x) (f : α →₁[μ] E) : setToL1 hT f ≤ setToL1 hT' f :=
setToL1_mono_left' hT hT' (fun s _ _ x => hTT' s x) f
#align measure_theory.L1.set_to_L1_mono_left MeasureTheory.L1.setToL1_mono_left
theorem setToL1_nonneg {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f : α →₁[μ] G'}
(hf : 0 ≤ f) : 0 ≤ setToL1 hT f := by
suffices ∀ f : { g : α →₁[μ] G' // 0 ≤ g }, 0 ≤ setToL1 hT f from
this (⟨f, hf⟩ : { g : α →₁[μ] G' // 0 ≤ g })
refine fun g =>
@isClosed_property { g : α →₁ₛ[μ] G' // 0 ≤ g } { g : α →₁[μ] G' // 0 ≤ g } _ _
(fun g => 0 ≤ setToL1 hT g)
(denseRange_coeSimpleFuncNonnegToLpNonneg 1 μ G' one_ne_top) ?_ ?_ g
· exact isClosed_le continuous_zero ((setToL1 hT).continuous.comp continuous_induced_dom)
· intro g
have : (coeSimpleFuncNonnegToLpNonneg 1 μ G' g : α →₁[μ] G') = (g : α →₁ₛ[μ] G') := rfl
rw [this, setToL1_eq_setToL1SCLM]
exact setToL1S_nonneg (fun s => hT.eq_zero_of_measure_zero) hT.1 hT_nonneg g.2
#align measure_theory.L1.set_to_L1_nonneg MeasureTheory.L1.setToL1_nonneg
theorem setToL1_mono {T : Set α → G' →L[ℝ] G''} {C : ℝ} (hT : DominatedFinMeasAdditive μ T C)
(hT_nonneg : ∀ s, MeasurableSet s → μ s < ∞ → ∀ x, 0 ≤ x → 0 ≤ T s x) {f g : α →₁[μ] G'}
(hfg : f ≤ g) : setToL1 hT f ≤ setToL1 hT g := by
rw [← sub_nonneg] at hfg ⊢
rw [← (setToL1 hT).map_sub]
exact setToL1_nonneg hT hT_nonneg hfg
#align measure_theory.L1.set_to_L1_mono MeasureTheory.L1.setToL1_mono
end Order
theorem norm_setToL1_le_norm_setToL1SCLM (hT : DominatedFinMeasAdditive μ T C) :
‖setToL1 hT‖ ≤ ‖setToL1SCLM α E μ hT‖ :=
calc
‖setToL1 hT‖ ≤ (1 : ℝ≥0) * ‖setToL1SCLM α E μ hT‖ := by
refine
ContinuousLinearMap.opNorm_extend_le (setToL1SCLM α E μ hT) (coeToLp α E ℝ)
(simpleFunc.denseRange one_ne_top) fun x => le_of_eq ?_
rw [NNReal.coe_one, one_mul]
rfl
_ = ‖setToL1SCLM α E μ hT‖ := by rw [NNReal.coe_one, one_mul]
#align measure_theory.L1.norm_set_to_L1_le_norm_set_to_L1s_clm MeasureTheory.L1.norm_setToL1_le_norm_setToL1SCLM
theorem norm_setToL1_le_mul_norm (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C)
(f : α →₁[μ] E) : ‖setToL1 hT f‖ ≤ C * ‖f‖ :=
calc
‖setToL1 hT f‖ ≤ ‖setToL1SCLM α E μ hT‖ * ‖f‖ :=
ContinuousLinearMap.le_of_opNorm_le _ (norm_setToL1_le_norm_setToL1SCLM hT) _
_ ≤ C * ‖f‖ := mul_le_mul (norm_setToL1SCLM_le hT hC) le_rfl (norm_nonneg _) hC
#align measure_theory.L1.norm_set_to_L1_le_mul_norm MeasureTheory.L1.norm_setToL1_le_mul_norm
theorem norm_setToL1_le_mul_norm' (hT : DominatedFinMeasAdditive μ T C) (f : α →₁[μ] E) :
‖setToL1 hT f‖ ≤ max C 0 * ‖f‖ :=
calc
‖setToL1 hT f‖ ≤ ‖setToL1SCLM α E μ hT‖ * ‖f‖ :=
ContinuousLinearMap.le_of_opNorm_le _ (norm_setToL1_le_norm_setToL1SCLM hT) _
_ ≤ max C 0 * ‖f‖ :=
mul_le_mul (norm_setToL1SCLM_le' hT) le_rfl (norm_nonneg _) (le_max_right _ _)
#align measure_theory.L1.norm_set_to_L1_le_mul_norm' MeasureTheory.L1.norm_setToL1_le_mul_norm'
theorem norm_setToL1_le (hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : ‖setToL1 hT‖ ≤ C :=
ContinuousLinearMap.opNorm_le_bound _ hC (norm_setToL1_le_mul_norm hT hC)
#align measure_theory.L1.norm_set_to_L1_le MeasureTheory.L1.norm_setToL1_le
theorem norm_setToL1_le' (hT : DominatedFinMeasAdditive μ T C) : ‖setToL1 hT‖ ≤ max C 0 :=
ContinuousLinearMap.opNorm_le_bound _ (le_max_right _ _) (norm_setToL1_le_mul_norm' hT)
#align measure_theory.L1.norm_set_to_L1_le' MeasureTheory.L1.norm_setToL1_le'
theorem setToL1_lipschitz (hT : DominatedFinMeasAdditive μ T C) :
LipschitzWith (Real.toNNReal C) (setToL1 hT) :=
(setToL1 hT).lipschitz.weaken (norm_setToL1_le' hT)
#align measure_theory.L1.set_to_L1_lipschitz MeasureTheory.L1.setToL1_lipschitz
/-- If `fs i → f` in `L1`, then `setToL1 hT (fs i) → setToL1 hT f`. -/
theorem tendsto_setToL1 (hT : DominatedFinMeasAdditive μ T C) (f : α →₁[μ] E) {ι}
(fs : ι → α →₁[μ] E) {l : Filter ι} (hfs : Tendsto fs l (𝓝 f)) :
Tendsto (fun i => setToL1 hT (fs i)) l (𝓝 <| setToL1 hT f) :=
((setToL1 hT).continuous.tendsto _).comp hfs
#align measure_theory.L1.tendsto_set_to_L1 MeasureTheory.L1.tendsto_setToL1
end SetToL1
end L1
section Function
set_option linter.uppercaseLean3 false
variable [CompleteSpace F] {T T' T'' : Set α → E →L[ℝ] F} {C C' C'' : ℝ} {f g : α → E}
variable (μ T)
/-- Extend `T : Set α → E →L[ℝ] F` to `(α → E) → F` (for integrable functions `α → E`). We set it to
0 if the function is not integrable. -/
def setToFun (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F :=
if hf : Integrable f μ then L1.setToL1 hT (hf.toL1 f) else 0
#align measure_theory.set_to_fun MeasureTheory.setToFun
variable {μ T}
theorem setToFun_eq (hT : DominatedFinMeasAdditive μ T C) (hf : Integrable f μ) :
setToFun μ T hT f = L1.setToL1 hT (hf.toL1 f) :=
dif_pos hf
#align measure_theory.set_to_fun_eq MeasureTheory.setToFun_eq
theorem L1.setToFun_eq_setToL1 (hT : DominatedFinMeasAdditive μ T C) (f : α →₁[μ] E) :
setToFun μ T hT f = L1.setToL1 hT f := by
rw [setToFun_eq hT (L1.integrable_coeFn f), Integrable.toL1_coeFn]
#align measure_theory.L1.set_to_fun_eq_set_to_L1 MeasureTheory.L1.setToFun_eq_setToL1
theorem setToFun_undef (hT : DominatedFinMeasAdditive μ T C) (hf : ¬Integrable f μ) :
setToFun μ T hT f = 0 :=
dif_neg hf
#align measure_theory.set_to_fun_undef MeasureTheory.setToFun_undef
theorem setToFun_non_aEStronglyMeasurable (hT : DominatedFinMeasAdditive μ T C)
(hf : ¬AEStronglyMeasurable f μ) : setToFun μ T hT f = 0 :=
setToFun_undef hT (not_and_of_not_left _ hf)
#align measure_theory.set_to_fun_non_ae_strongly_measurable MeasureTheory.setToFun_non_aEStronglyMeasurable
theorem setToFun_congr_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : T = T') (f : α → E) :
setToFun μ T hT f = setToFun μ T' hT' f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_congr_left T T' hT hT' h]
· simp_rw [setToFun_undef _ hf]
#align measure_theory.set_to_fun_congr_left MeasureTheory.setToFun_congr_left
theorem setToFun_congr_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (h : ∀ s, MeasurableSet s → μ s < ∞ → T s = T' s)
(f : α → E) : setToFun μ T hT f = setToFun μ T' hT' f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_congr_left' T T' hT hT' h]
· simp_rw [setToFun_undef _ hf]
#align measure_theory.set_to_fun_congr_left' MeasureTheory.setToFun_congr_left'
theorem setToFun_add_left (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (f : α → E) :
setToFun μ (T + T') (hT.add hT') f = setToFun μ T hT f + setToFun μ T' hT' f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_add_left hT hT']
· simp_rw [setToFun_undef _ hf, add_zero]
#align measure_theory.set_to_fun_add_left MeasureTheory.setToFun_add_left
theorem setToFun_add_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (hT'' : DominatedFinMeasAdditive μ T'' C'')
(h_add : ∀ s, MeasurableSet s → μ s < ∞ → T'' s = T s + T' s) (f : α → E) :
setToFun μ T'' hT'' f = setToFun μ T hT f + setToFun μ T' hT' f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_add_left' hT hT' hT'' h_add]
· simp_rw [setToFun_undef _ hf, add_zero]
#align measure_theory.set_to_fun_add_left' MeasureTheory.setToFun_add_left'
theorem setToFun_smul_left (hT : DominatedFinMeasAdditive μ T C) (c : ℝ) (f : α → E) :
setToFun μ (fun s => c • T s) (hT.smul c) f = c • setToFun μ T hT f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_smul_left hT c]
· simp_rw [setToFun_undef _ hf, smul_zero]
#align measure_theory.set_to_fun_smul_left MeasureTheory.setToFun_smul_left
theorem setToFun_smul_left' (hT : DominatedFinMeasAdditive μ T C)
(hT' : DominatedFinMeasAdditive μ T' C') (c : ℝ)
(h_smul : ∀ s, MeasurableSet s → μ s < ∞ → T' s = c • T s) (f : α → E) :
setToFun μ T' hT' f = c • setToFun μ T hT f := by
by_cases hf : Integrable f μ
· simp_rw [setToFun_eq _ hf, L1.setToL1_smul_left' hT hT' c h_smul]
· simp_rw [setToFun_undef _ hf, smul_zero]
#align measure_theory.set_to_fun_smul_left' MeasureTheory.setToFun_smul_left'
@[simp]
theorem setToFun_zero (hT : DominatedFinMeasAdditive μ T C) : setToFun μ T hT (0 : α → E) = 0 := by
erw [setToFun_eq hT (integrable_zero _ _ _), Integrable.toL1_zero, ContinuousLinearMap.map_zero]
#align measure_theory.set_to_fun_zero MeasureTheory.setToFun_zero
@[simp]
theorem setToFun_zero_left {hT : DominatedFinMeasAdditive μ (0 : Set α → E →L[ℝ] F) C} :
setToFun μ 0 hT f = 0 := by
by_cases hf : Integrable f μ
· rw [setToFun_eq hT hf]; exact L1.setToL1_zero_left hT _
· exact setToFun_undef hT hf
#align measure_theory.set_to_fun_zero_left MeasureTheory.setToFun_zero_left
theorem setToFun_zero_left' (hT : DominatedFinMeasAdditive μ T C)
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) : setToFun μ T hT f = 0 := by
by_cases hf : Integrable f μ
· rw [setToFun_eq hT hf]; exact L1.setToL1_zero_left' hT h_zero _
· exact setToFun_undef hT hf
#align measure_theory.set_to_fun_zero_left' MeasureTheory.setToFun_zero_left'
theorem setToFun_add (hT : DominatedFinMeasAdditive μ T C) (hf : Integrable f μ)
(hg : Integrable g μ) : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g := by
rw [setToFun_eq hT (hf.add hg), setToFun_eq hT hf, setToFun_eq hT hg, Integrable.toL1_add,
(L1.setToL1 hT).map_add]
#align measure_theory.set_to_fun_add MeasureTheory.setToFun_add
theorem setToFun_finset_sum' (hT : DominatedFinMeasAdditive μ T C) {ι} (s : Finset ι)
{f : ι → α → E} (hf : ∀ i ∈ s, Integrable (f i) μ) :
setToFun μ T hT (∑ i ∈ s, f i) = ∑ i ∈ s, setToFun μ T hT (f i) := by
revert hf
refine Finset.induction_on s ?_ ?_
· intro _
simp only [setToFun_zero, Finset.sum_empty]
· intro i s his ih hf
simp only [his, Finset.sum_insert, not_false_iff]
rw [setToFun_add hT (hf i (Finset.mem_insert_self i s)) _]
· rw [ih fun i hi => hf i (Finset.mem_insert_of_mem hi)]
· convert integrable_finset_sum s fun i hi => hf i (Finset.mem_insert_of_mem hi) with x
simp
#align measure_theory.set_to_fun_finset_sum' MeasureTheory.setToFun_finset_sum'
theorem setToFun_finset_sum (hT : DominatedFinMeasAdditive μ T C) {ι} (s : Finset ι) {f : ι → α → E}
(hf : ∀ i ∈ s, Integrable (f i) μ) :
(setToFun μ T hT fun a => ∑ i ∈ s, f i a) = ∑ i ∈ s, setToFun μ T hT (f i) := by
convert setToFun_finset_sum' hT s hf with a; simp
#align measure_theory.set_to_fun_finset_sum MeasureTheory.setToFun_finset_sum
theorem setToFun_neg (hT : DominatedFinMeasAdditive μ T C) (f : α → E) :
setToFun μ T hT (-f) = -setToFun μ T hT f := by
by_cases hf : Integrable f μ
· rw [setToFun_eq hT hf, setToFun_eq hT hf.neg, Integrable.toL1_neg,
(L1.setToL1 hT).map_neg]
· rw [setToFun_undef hT hf, setToFun_undef hT, neg_zero]
rwa [← integrable_neg_iff] at hf
#align measure_theory.set_to_fun_neg MeasureTheory.setToFun_neg
theorem setToFun_sub (hT : DominatedFinMeasAdditive μ T C) (hf : Integrable f μ)
(hg : Integrable g μ) : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g := by
rw [sub_eq_add_neg, sub_eq_add_neg, setToFun_add hT hf hg.neg, setToFun_neg hT g]
#align measure_theory.set_to_fun_sub MeasureTheory.setToFun_sub
| Mathlib/MeasureTheory/Integral/SetToL1.lean | 1,396 | 1,405 | theorem setToFun_smul [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 F]
(hT : DominatedFinMeasAdditive μ T C) (h_smul : ∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x) (c : 𝕜)
(f : α → E) : setToFun μ T hT (c • f) = c • setToFun μ T hT f := by |
by_cases hf : Integrable f μ
· rw [setToFun_eq hT hf, setToFun_eq hT, Integrable.toL1_smul',
L1.setToL1_smul hT h_smul c _]
· by_cases hr : c = 0
· rw [hr]; simp
· have hf' : ¬Integrable (c • f) μ := by rwa [integrable_smul_iff hr f]
rw [setToFun_undef hT hf, setToFun_undef hT hf', smul_zero]
|
/-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Equivalence
#align_import algebraic_topology.dold_kan.compatibility from "leanprover-community/mathlib"@"32a7e535287f9c73f2e4d2aef306a39190f0b504"
/-! Tools for compatibilities between Dold-Kan equivalences
The purpose of this file is to introduce tools which will enable the
construction of the Dold-Kan equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
for a pseudoabelian category `C` from the equivalence
`Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)` and the two
equivalences `simplicial_object C ≅ Karoubi (SimplicialObject C)` and
`ChainComplex C ℕ ≅ Karoubi (ChainComplex C ℕ)`.
It is certainly possible to get an equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
using a compositions of the three equivalences above, but then neither the functor
nor the inverse would have good definitional properties. For example, it would be better
if the inverse functor of the equivalence was exactly the functor
`Γ₀ : SimplicialObject C ⥤ ChainComplex C ℕ` which was constructed in `FunctorGamma.lean`.
In this file, given four categories `A`, `A'`, `B`, `B'`, equivalences `eA : A ≅ A'`,
`eB : B ≅ B'`, `e' : A' ≅ B'`, functors `F : A ⥤ B'`, `G : B ⥤ A` equipped with certain
compatibilities, we construct successive equivalences:
- `equivalence₀` from `A` to `B'`, which is the composition of `eA` and `e'`.
- `equivalence₁` from `A` to `B'`, with the same inverse functor as `equivalence₀`,
but whose functor is `F`.
- `equivalence₂` from `A` to `B`, which is the composition of `equivalence₁` and the
inverse of `eB`:
- `equivalence` from `A` to `B`, which has the same functor `F ⋙ eB.inverse` as `equivalence₂`,
but whose inverse functor is `G`.
When extra assumptions are given, we shall also provide simplification lemmas for the
unit and counit isomorphisms of `equivalence`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category
namespace AlgebraicTopology
namespace DoldKan
namespace Compatibility
variable {A A' B B' : Type*} [Category A] [Category A'] [Category B] [Category B'] (eA : A ≌ A')
(eB : B ≌ B') (e' : A' ≌ B') {F : A ⥤ B'} (hF : eA.functor ⋙ e'.functor ≅ F) {G : B ⥤ A}
(hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor)
/-- A basic equivalence `A ≅ B'` obtained by composing `eA : A ≅ A'` and `e' : A' ≅ B'`. -/
@[simps! functor inverse unitIso_hom_app]
def equivalence₀ : A ≌ B' :=
eA.trans e'
#align algebraic_topology.dold_kan.compatibility.equivalence₀ AlgebraicTopology.DoldKan.Compatibility.equivalence₀
variable {eA} {e'}
/-- An intermediate equivalence `A ≅ B'` whose functor is `F` and whose inverse is
`e'.inverse ⋙ eA.inverse`. -/
@[simps! functor]
def equivalence₁ : A ≌ B' := (equivalence₀ eA e').changeFunctor hF
#align algebraic_topology.dold_kan.compatibility.equivalence₁ AlgebraicTopology.DoldKan.Compatibility.equivalence₁
theorem equivalence₁_inverse : (equivalence₁ hF).inverse = e'.inverse ⋙ eA.inverse :=
rfl
#align algebraic_topology.dold_kan.compatibility.equivalence₁_inverse AlgebraicTopology.DoldKan.Compatibility.equivalence₁_inverse
/-- The counit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/
@[simps!]
def equivalence₁CounitIso : (e'.inverse ⋙ eA.inverse) ⋙ F ≅ 𝟭 B' :=
calc
(e'.inverse ⋙ eA.inverse) ⋙ F ≅ (e'.inverse ⋙ eA.inverse) ⋙ eA.functor ⋙ e'.functor :=
isoWhiskerLeft _ hF.symm
_ ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor) ⋙ e'.functor := Iso.refl _
_ ≅ e'.inverse ⋙ 𝟭 _ ⋙ e'.functor := isoWhiskerLeft _ (isoWhiskerRight eA.counitIso _)
_ ≅ e'.inverse ⋙ e'.functor := Iso.refl _
_ ≅ 𝟭 B' := e'.counitIso
#align algebraic_topology.dold_kan.compatibility.equivalence₁_counit_iso AlgebraicTopology.DoldKan.Compatibility.equivalence₁CounitIso
| Mathlib/AlgebraicTopology/DoldKan/Compatibility.lean | 86 | 88 | theorem equivalence₁CounitIso_eq : (equivalence₁ hF).counitIso = equivalence₁CounitIso hF := by |
ext Y
simp [equivalence₁, equivalence₀]
|
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Data.Finsupp.Encodable
import Mathlib.LinearAlgebra.Pi
import Mathlib.LinearAlgebra.Span
import Mathlib.Data.Set.Countable
#align_import linear_algebra.finsupp from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb"
/-!
# Properties of the module `α →₀ M`
Given an `R`-module `M`, the `R`-module structure on `α →₀ M` is defined in
`Data.Finsupp.Basic`.
In this file we define `Finsupp.supported s` to be the set `{f : α →₀ M | f.support ⊆ s}`
interpreted as a submodule of `α →₀ M`. We also define `LinearMap` versions of various maps:
* `Finsupp.lsingle a : M →ₗ[R] ι →₀ M`: `Finsupp.single a` as a linear map;
* `Finsupp.lapply a : (ι →₀ M) →ₗ[R] M`: the map `fun f ↦ f a` as a linear map;
* `Finsupp.lsubtypeDomain (s : Set α) : (α →₀ M) →ₗ[R] (s →₀ M)`: restriction to a subtype as a
linear map;
* `Finsupp.restrictDom`: `Finsupp.filter` as a linear map to `Finsupp.supported s`;
* `Finsupp.lsum`: `Finsupp.sum` or `Finsupp.liftAddHom` as a `LinearMap`;
* `Finsupp.total α M R (v : ι → M)`: sends `l : ι → R` to the linear combination of `v i` with
coefficients `l i`;
* `Finsupp.totalOn`: a restricted version of `Finsupp.total` with domain `Finsupp.supported R R s`
and codomain `Submodule.span R (v '' s)`;
* `Finsupp.supportedEquivFinsupp`: a linear equivalence between the functions `α →₀ M` supported
on `s` and the functions `s →₀ M`;
* `Finsupp.lmapDomain`: a linear map version of `Finsupp.mapDomain`;
* `Finsupp.domLCongr`: a `LinearEquiv` version of `Finsupp.domCongr`;
* `Finsupp.congr`: if the sets `s` and `t` are equivalent, then `supported M R s` is equivalent to
`supported M R t`;
* `Finsupp.lcongr`: a `LinearEquiv`alence between `α →₀ M` and `β →₀ N` constructed using
`e : α ≃ β` and `e' : M ≃ₗ[R] N`.
## Tags
function with finite support, module, linear algebra
-/
noncomputable section
open Set LinearMap Submodule
namespace Finsupp
section SMul
variable {α : Type*} {β : Type*} {R : Type*} {M : Type*} {M₂ : Type*}
theorem smul_sum [Zero β] [AddCommMonoid M] [DistribSMul R M] {v : α →₀ β} {c : R} {h : α → β → M} :
c • v.sum h = v.sum fun a b => c • h a b :=
Finset.smul_sum
#align finsupp.smul_sum Finsupp.smul_sum
@[simp]
theorem sum_smul_index_linearMap' [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid M₂]
[Module R M₂] {v : α →₀ M} {c : R} {h : α → M →ₗ[R] M₂} :
((c • v).sum fun a => h a) = c • v.sum fun a => h a := by
rw [Finsupp.sum_smul_index', Finsupp.smul_sum]
· simp only [map_smul]
· intro i
exact (h i).map_zero
#align finsupp.sum_smul_index_linear_map' Finsupp.sum_smul_index_linearMap'
end SMul
section LinearEquivFunOnFinite
variable (R : Type*) {S : Type*} (M : Type*) (α : Type*)
variable [Finite α] [AddCommMonoid M] [Semiring R] [Module R M]
/-- Given `Finite α`, `linearEquivFunOnFinite R` is the natural `R`-linear equivalence between
`α →₀ β` and `α → β`. -/
@[simps apply]
noncomputable def linearEquivFunOnFinite : (α →₀ M) ≃ₗ[R] α → M :=
{ equivFunOnFinite with
toFun := (⇑)
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
#align finsupp.linear_equiv_fun_on_finite Finsupp.linearEquivFunOnFinite
@[simp]
theorem linearEquivFunOnFinite_single [DecidableEq α] (x : α) (m : M) :
(linearEquivFunOnFinite R M α) (single x m) = Pi.single x m :=
equivFunOnFinite_single x m
#align finsupp.linear_equiv_fun_on_finite_single Finsupp.linearEquivFunOnFinite_single
@[simp]
theorem linearEquivFunOnFinite_symm_single [DecidableEq α] (x : α) (m : M) :
(linearEquivFunOnFinite R M α).symm (Pi.single x m) = single x m :=
equivFunOnFinite_symm_single x m
#align finsupp.linear_equiv_fun_on_finite_symm_single Finsupp.linearEquivFunOnFinite_symm_single
@[simp]
theorem linearEquivFunOnFinite_symm_coe (f : α →₀ M) : (linearEquivFunOnFinite R M α).symm f = f :=
(linearEquivFunOnFinite R M α).symm_apply_apply f
#align finsupp.linear_equiv_fun_on_finite_symm_coe Finsupp.linearEquivFunOnFinite_symm_coe
end LinearEquivFunOnFinite
section LinearEquiv.finsuppUnique
variable (R : Type*) {S : Type*} (M : Type*)
variable [AddCommMonoid M] [Semiring R] [Module R M]
variable (α : Type*) [Unique α]
/-- If `α` has a unique term, then the type of finitely supported functions `α →₀ M` is
`R`-linearly equivalent to `M`. -/
noncomputable def LinearEquiv.finsuppUnique : (α →₀ M) ≃ₗ[R] M :=
{ Finsupp.equivFunOnFinite.trans (Equiv.funUnique α M) with
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
#align finsupp.linear_equiv.finsupp_unique Finsupp.LinearEquiv.finsuppUnique
variable {R M}
@[simp]
theorem LinearEquiv.finsuppUnique_apply (f : α →₀ M) :
LinearEquiv.finsuppUnique R M α f = f default :=
rfl
#align finsupp.linear_equiv.finsupp_unique_apply Finsupp.LinearEquiv.finsuppUnique_apply
variable {α}
@[simp]
theorem LinearEquiv.finsuppUnique_symm_apply [Unique α] (m : M) :
(LinearEquiv.finsuppUnique R M α).symm m = Finsupp.single default m := by
ext; simp [LinearEquiv.finsuppUnique, Equiv.funUnique, single, Pi.single,
equivFunOnFinite, Function.update]
#align finsupp.linear_equiv.finsupp_unique_symm_apply Finsupp.LinearEquiv.finsuppUnique_symm_apply
end LinearEquiv.finsuppUnique
variable {α : Type*} {M : Type*} {N : Type*} {P : Type*} {R : Type*} {S : Type*}
variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M]
variable [AddCommMonoid N] [Module R N]
variable [AddCommMonoid P] [Module R P]
/-- Interpret `Finsupp.single a` as a linear map. -/
def lsingle (a : α) : M →ₗ[R] α →₀ M :=
{ Finsupp.singleAddHom a with map_smul' := fun _ _ => (smul_single _ _ _).symm }
#align finsupp.lsingle Finsupp.lsingle
/-- Two `R`-linear maps from `Finsupp X M` which agree on each `single x y` agree everywhere. -/
theorem lhom_ext ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a b, φ (single a b) = ψ (single a b)) : φ = ψ :=
LinearMap.toAddMonoidHom_injective <| addHom_ext h
#align finsupp.lhom_ext Finsupp.lhom_ext
/-- Two `R`-linear maps from `Finsupp X M` which agree on each `single x y` agree everywhere.
We formulate this fact using equality of linear maps `φ.comp (lsingle a)` and `ψ.comp (lsingle a)`
so that the `ext` tactic can apply a type-specific extensionality lemma to prove equality of these
maps. E.g., if `M = R`, then it suffices to verify `φ (single a 1) = ψ (single a 1)`. -/
-- Porting note: The priority should be higher than `LinearMap.ext`.
@[ext high]
theorem lhom_ext' ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a, φ.comp (lsingle a) = ψ.comp (lsingle a)) :
φ = ψ :=
lhom_ext fun a => LinearMap.congr_fun (h a)
#align finsupp.lhom_ext' Finsupp.lhom_ext'
/-- Interpret `fun f : α →₀ M ↦ f a` as a linear map. -/
def lapply (a : α) : (α →₀ M) →ₗ[R] M :=
{ Finsupp.applyAddHom a with map_smul' := fun _ _ => rfl }
#align finsupp.lapply Finsupp.lapply
section CompatibleSMul
variable (R S M N ι : Type*)
variable [Semiring S] [AddCommMonoid M] [AddCommMonoid N] [Module S M] [Module S N]
instance _root_.LinearMap.CompatibleSMul.finsupp_dom [SMulZeroClass R M] [DistribSMul R N]
[LinearMap.CompatibleSMul M N R S] : LinearMap.CompatibleSMul (ι →₀ M) N R S where
map_smul f r m := by
conv_rhs => rw [← sum_single m, map_finsupp_sum, smul_sum]
erw [← sum_single (r • m), sum_mapRange_index single_zero, map_finsupp_sum]
congr; ext i m; exact (f.comp <| lsingle i).map_smul_of_tower r m
instance _root_.LinearMap.CompatibleSMul.finsupp_cod [SMul R M] [SMulZeroClass R N]
[LinearMap.CompatibleSMul M N R S] : LinearMap.CompatibleSMul M (ι →₀ N) R S where
map_smul f r m := by ext i; apply ((lapply i).comp f).map_smul_of_tower
end CompatibleSMul
/-- Forget that a function is finitely supported.
This is the linear version of `Finsupp.toFun`. -/
@[simps]
def lcoeFun : (α →₀ M) →ₗ[R] α → M where
toFun := (⇑)
map_add' x y := by
ext
simp
map_smul' x y := by
ext
simp
#align finsupp.lcoe_fun Finsupp.lcoeFun
section LSubtypeDomain
variable (s : Set α)
/-- Interpret `Finsupp.subtypeDomain s` as a linear map. -/
def lsubtypeDomain : (α →₀ M) →ₗ[R] s →₀ M where
toFun := subtypeDomain fun x => x ∈ s
map_add' _ _ := subtypeDomain_add
map_smul' _ _ := ext fun _ => rfl
#align finsupp.lsubtype_domain Finsupp.lsubtypeDomain
theorem lsubtypeDomain_apply (f : α →₀ M) :
(lsubtypeDomain s : (α →₀ M) →ₗ[R] s →₀ M) f = subtypeDomain (fun x => x ∈ s) f :=
rfl
#align finsupp.lsubtype_domain_apply Finsupp.lsubtypeDomain_apply
end LSubtypeDomain
@[simp]
theorem lsingle_apply (a : α) (b : M) : (lsingle a : M →ₗ[R] α →₀ M) b = single a b :=
rfl
#align finsupp.lsingle_apply Finsupp.lsingle_apply
@[simp]
theorem lapply_apply (a : α) (f : α →₀ M) : (lapply a : (α →₀ M) →ₗ[R] M) f = f a :=
rfl
#align finsupp.lapply_apply Finsupp.lapply_apply
@[simp]
theorem lapply_comp_lsingle_same (a : α) : lapply a ∘ₗ lsingle a = (.id : M →ₗ[R] M) := by ext; simp
@[simp]
theorem lapply_comp_lsingle_of_ne (a a' : α) (h : a ≠ a') :
lapply a ∘ₗ lsingle a' = (0 : M →ₗ[R] M) := by ext; simp [h.symm]
@[simp]
theorem ker_lsingle (a : α) : ker (lsingle a : M →ₗ[R] α →₀ M) = ⊥ :=
ker_eq_bot_of_injective (single_injective a)
#align finsupp.ker_lsingle Finsupp.ker_lsingle
theorem lsingle_range_le_ker_lapply (s t : Set α) (h : Disjoint s t) :
⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) ≤
⨅ a ∈ t, ker (lapply a : (α →₀ M) →ₗ[R] M) := by
refine iSup_le fun a₁ => iSup_le fun h₁ => range_le_iff_comap.2 ?_
simp only [(ker_comp _ _).symm, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
intro b _ a₂ h₂
have : a₁ ≠ a₂ := fun eq => h.le_bot ⟨h₁, eq.symm ▸ h₂⟩
exact single_eq_of_ne this
#align finsupp.lsingle_range_le_ker_lapply Finsupp.lsingle_range_le_ker_lapply
theorem iInf_ker_lapply_le_bot : ⨅ a, ker (lapply a : (α →₀ M) →ₗ[R] M) ≤ ⊥ := by
simp only [SetLike.le_def, mem_iInf, mem_ker, mem_bot, lapply_apply]
exact fun a h => Finsupp.ext h
#align finsupp.infi_ker_lapply_le_bot Finsupp.iInf_ker_lapply_le_bot
theorem iSup_lsingle_range : ⨆ a, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) = ⊤ := by
refine eq_top_iff.2 <| SetLike.le_def.2 fun f _ => ?_
rw [← sum_single f]
exact sum_mem fun a _ => Submodule.mem_iSup_of_mem a ⟨_, rfl⟩
#align finsupp.supr_lsingle_range Finsupp.iSup_lsingle_range
theorem disjoint_lsingle_lsingle (s t : Set α) (hs : Disjoint s t) :
Disjoint (⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M))
(⨆ a ∈ t, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M)) := by
-- Porting note: 2 placeholders are added to prevent timeout.
refine
(Disjoint.mono
(lsingle_range_le_ker_lapply s sᶜ ?_)
(lsingle_range_le_ker_lapply t tᶜ ?_))
?_
· apply disjoint_compl_right
· apply disjoint_compl_right
rw [disjoint_iff_inf_le]
refine le_trans (le_iInf fun i => ?_) iInf_ker_lapply_le_bot
classical
by_cases his : i ∈ s
· by_cases hit : i ∈ t
· exact (hs.le_bot ⟨his, hit⟩).elim
exact inf_le_of_right_le (iInf_le_of_le i <| iInf_le _ hit)
exact inf_le_of_left_le (iInf_le_of_le i <| iInf_le _ his)
#align finsupp.disjoint_lsingle_lsingle Finsupp.disjoint_lsingle_lsingle
| Mathlib/LinearAlgebra/Finsupp.lean | 287 | 289 | theorem span_single_image (s : Set M) (a : α) :
Submodule.span R (single a '' s) = (Submodule.span R s).map (lsingle a : M →ₗ[R] α →₀ M) := by |
rw [← span_image]; rfl
|
/-
Copyright (c) 2019 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Lu-Ming Zhang
-/
import Mathlib.Data.Matrix.Invertible
import Mathlib.LinearAlgebra.Matrix.Adjugate
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import linear_algebra.matrix.nonsingular_inverse from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422"
/-!
# Nonsingular inverses
In this file, we define an inverse for square matrices of invertible determinant.
For matrices that are not square or not of full rank, there is a more general notion of
pseudoinverses which we do not consider here.
The definition of inverse used in this file is the adjugate divided by the determinant.
We show that dividing the adjugate by `det A` (if possible), giving a matrix `A⁻¹` (`nonsing_inv`),
will result in a multiplicative inverse to `A`.
Note that there are at least three different inverses in mathlib:
* `A⁻¹` (`Inv.inv`): alone, this satisfies no properties, although it is usually used in
conjunction with `Group` or `GroupWithZero`. On matrices, this is defined to be zero when no
inverse exists.
* `⅟A` (`invOf`): this is only available in the presence of `[Invertible A]`, which guarantees an
inverse exists.
* `Ring.inverse A`: this is defined on any `MonoidWithZero`, and just like `⁻¹` on matrices, is
defined to be zero when no inverse exists.
We start by working with `Invertible`, and show the main results:
* `Matrix.invertibleOfDetInvertible`
* `Matrix.detInvertibleOfInvertible`
* `Matrix.isUnit_iff_isUnit_det`
* `Matrix.mul_eq_one_comm`
After this we define `Matrix.inv` and show it matches `⅟A` and `Ring.inverse A`.
The rest of the results in the file are then about `A⁻¹`
## References
* https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix
## Tags
matrix inverse, cramer, cramer's rule, adjugate
-/
namespace Matrix
universe u u' v
variable {l : Type*} {m : Type u} {n : Type u'} {α : Type v}
open Matrix Equiv Equiv.Perm Finset
/-! ### Matrices are `Invertible` iff their determinants are -/
section Invertible
variable [Fintype n] [DecidableEq n] [CommRing α]
variable (A : Matrix n n α) (B : Matrix n n α)
/-- If `A.det` has a constructive inverse, produce one for `A`. -/
def invertibleOfDetInvertible [Invertible A.det] : Invertible A where
invOf := ⅟ A.det • A.adjugate
mul_invOf_self := by
rw [mul_smul_comm, mul_adjugate, smul_smul, invOf_mul_self, one_smul]
invOf_mul_self := by
rw [smul_mul_assoc, adjugate_mul, smul_smul, invOf_mul_self, one_smul]
#align matrix.invertible_of_det_invertible Matrix.invertibleOfDetInvertible
theorem invOf_eq [Invertible A.det] [Invertible A] : ⅟ A = ⅟ A.det • A.adjugate := by
letI := invertibleOfDetInvertible A
convert (rfl : ⅟ A = _)
#align matrix.inv_of_eq Matrix.invOf_eq
/-- `A.det` is invertible if `A` has a left inverse. -/
def detInvertibleOfLeftInverse (h : B * A = 1) : Invertible A.det where
invOf := B.det
mul_invOf_self := by rw [mul_comm, ← det_mul, h, det_one]
invOf_mul_self := by rw [← det_mul, h, det_one]
#align matrix.det_invertible_of_left_inverse Matrix.detInvertibleOfLeftInverse
/-- `A.det` is invertible if `A` has a right inverse. -/
def detInvertibleOfRightInverse (h : A * B = 1) : Invertible A.det where
invOf := B.det
mul_invOf_self := by rw [← det_mul, h, det_one]
invOf_mul_self := by rw [mul_comm, ← det_mul, h, det_one]
#align matrix.det_invertible_of_right_inverse Matrix.detInvertibleOfRightInverse
/-- If `A` has a constructive inverse, produce one for `A.det`. -/
def detInvertibleOfInvertible [Invertible A] : Invertible A.det :=
detInvertibleOfLeftInverse A (⅟ A) (invOf_mul_self _)
#align matrix.det_invertible_of_invertible Matrix.detInvertibleOfInvertible
theorem det_invOf [Invertible A] [Invertible A.det] : (⅟ A).det = ⅟ A.det := by
letI := detInvertibleOfInvertible A
convert (rfl : _ = ⅟ A.det)
#align matrix.det_inv_of Matrix.det_invOf
/-- Together `Matrix.detInvertibleOfInvertible` and `Matrix.invertibleOfDetInvertible` form an
equivalence, although both sides of the equiv are subsingleton anyway. -/
@[simps]
def invertibleEquivDetInvertible : Invertible A ≃ Invertible A.det where
toFun := @detInvertibleOfInvertible _ _ _ _ _ A
invFun := @invertibleOfDetInvertible _ _ _ _ _ A
left_inv _ := Subsingleton.elim _ _
right_inv _ := Subsingleton.elim _ _
#align matrix.invertible_equiv_det_invertible Matrix.invertibleEquivDetInvertible
variable {A B}
theorem mul_eq_one_comm : A * B = 1 ↔ B * A = 1 :=
suffices ∀ A B : Matrix n n α, A * B = 1 → B * A = 1 from ⟨this A B, this B A⟩
fun A B h => by
letI : Invertible B.det := detInvertibleOfLeftInverse _ _ h
letI : Invertible B := invertibleOfDetInvertible B
calc
B * A = B * A * (B * ⅟ B) := by rw [mul_invOf_self, Matrix.mul_one]
_ = B * (A * B * ⅟ B) := by simp only [Matrix.mul_assoc]
_ = B * ⅟ B := by rw [h, Matrix.one_mul]
_ = 1 := mul_invOf_self B
#align matrix.mul_eq_one_comm Matrix.mul_eq_one_comm
variable (A B)
/-- We can construct an instance of invertible A if A has a left inverse. -/
def invertibleOfLeftInverse (h : B * A = 1) : Invertible A :=
⟨B, h, mul_eq_one_comm.mp h⟩
#align matrix.invertible_of_left_inverse Matrix.invertibleOfLeftInverse
/-- We can construct an instance of invertible A if A has a right inverse. -/
def invertibleOfRightInverse (h : A * B = 1) : Invertible A :=
⟨B, mul_eq_one_comm.mp h, h⟩
#align matrix.invertible_of_right_inverse Matrix.invertibleOfRightInverse
/-- Given a proof that `A.det` has a constructive inverse, lift `A` to `(Matrix n n α)ˣ`-/
def unitOfDetInvertible [Invertible A.det] : (Matrix n n α)ˣ :=
@unitOfInvertible _ _ A (invertibleOfDetInvertible A)
#align matrix.unit_of_det_invertible Matrix.unitOfDetInvertible
/-- When lowered to a prop, `Matrix.invertibleEquivDetInvertible` forms an `iff`. -/
theorem isUnit_iff_isUnit_det : IsUnit A ↔ IsUnit A.det := by
simp only [← nonempty_invertible_iff_isUnit, (invertibleEquivDetInvertible A).nonempty_congr]
#align matrix.is_unit_iff_is_unit_det Matrix.isUnit_iff_isUnit_det
@[simp]
theorem isUnits_det_units (A : (Matrix n n α)ˣ) : IsUnit (A : Matrix n n α).det :=
isUnit_iff_isUnit_det _ |>.mp A.isUnit
/-! #### Variants of the statements above with `IsUnit`-/
theorem isUnit_det_of_invertible [Invertible A] : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfInvertible A)
#align matrix.is_unit_det_of_invertible Matrix.isUnit_det_of_invertible
variable {A B}
theorem isUnit_of_left_inverse (h : B * A = 1) : IsUnit A :=
⟨⟨A, B, mul_eq_one_comm.mp h, h⟩, rfl⟩
#align matrix.is_unit_of_left_inverse Matrix.isUnit_of_left_inverse
theorem exists_left_inverse_iff_isUnit : (∃ B, B * A = 1) ↔ IsUnit A :=
⟨fun ⟨_, h⟩ ↦ isUnit_of_left_inverse h, fun h ↦ have := h.invertible; ⟨⅟A, invOf_mul_self' A⟩⟩
theorem isUnit_of_right_inverse (h : A * B = 1) : IsUnit A :=
⟨⟨A, B, h, mul_eq_one_comm.mp h⟩, rfl⟩
#align matrix.is_unit_of_right_inverse Matrix.isUnit_of_right_inverse
theorem exists_right_inverse_iff_isUnit : (∃ B, A * B = 1) ↔ IsUnit A :=
⟨fun ⟨_, h⟩ ↦ isUnit_of_right_inverse h, fun h ↦ have := h.invertible; ⟨⅟A, mul_invOf_self' A⟩⟩
theorem isUnit_det_of_left_inverse (h : B * A = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfLeftInverse _ _ h)
#align matrix.is_unit_det_of_left_inverse Matrix.isUnit_det_of_left_inverse
theorem isUnit_det_of_right_inverse (h : A * B = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfRightInverse _ _ h)
#align matrix.is_unit_det_of_right_inverse Matrix.isUnit_det_of_right_inverse
theorem det_ne_zero_of_left_inverse [Nontrivial α] (h : B * A = 1) : A.det ≠ 0 :=
(isUnit_det_of_left_inverse h).ne_zero
#align matrix.det_ne_zero_of_left_inverse Matrix.det_ne_zero_of_left_inverse
theorem det_ne_zero_of_right_inverse [Nontrivial α] (h : A * B = 1) : A.det ≠ 0 :=
(isUnit_det_of_right_inverse h).ne_zero
#align matrix.det_ne_zero_of_right_inverse Matrix.det_ne_zero_of_right_inverse
end Invertible
section Inv
variable [Fintype n] [DecidableEq n] [CommRing α]
variable (A : Matrix n n α) (B : Matrix n n α)
theorem isUnit_det_transpose (h : IsUnit A.det) : IsUnit Aᵀ.det := by
rw [det_transpose]
exact h
#align matrix.is_unit_det_transpose Matrix.isUnit_det_transpose
/-! ### A noncomputable `Inv` instance -/
/-- The inverse of a square matrix, when it is invertible (and zero otherwise). -/
noncomputable instance inv : Inv (Matrix n n α) :=
⟨fun A => Ring.inverse A.det • A.adjugate⟩
theorem inv_def (A : Matrix n n α) : A⁻¹ = Ring.inverse A.det • A.adjugate :=
rfl
#align matrix.inv_def Matrix.inv_def
theorem nonsing_inv_apply_not_isUnit (h : ¬IsUnit A.det) : A⁻¹ = 0 := by
rw [inv_def, Ring.inverse_non_unit _ h, zero_smul]
#align matrix.nonsing_inv_apply_not_is_unit Matrix.nonsing_inv_apply_not_isUnit
theorem nonsing_inv_apply (h : IsUnit A.det) : A⁻¹ = (↑h.unit⁻¹ : α) • A.adjugate := by
rw [inv_def, ← Ring.inverse_unit h.unit, IsUnit.unit_spec]
#align matrix.nonsing_inv_apply Matrix.nonsing_inv_apply
/-- The nonsingular inverse is the same as `invOf` when `A` is invertible. -/
@[simp]
theorem invOf_eq_nonsing_inv [Invertible A] : ⅟ A = A⁻¹ := by
letI := detInvertibleOfInvertible A
rw [inv_def, Ring.inverse_invertible, invOf_eq]
#align matrix.inv_of_eq_nonsing_inv Matrix.invOf_eq_nonsing_inv
/-- Coercing the result of `Units.instInv` is the same as coercing first and applying the
nonsingular inverse. -/
@[simp, norm_cast]
theorem coe_units_inv (A : (Matrix n n α)ˣ) : ↑A⁻¹ = (A⁻¹ : Matrix n n α) := by
letI := A.invertible
rw [← invOf_eq_nonsing_inv, invOf_units]
#align matrix.coe_units_inv Matrix.coe_units_inv
/-- The nonsingular inverse is the same as the general `Ring.inverse`. -/
theorem nonsing_inv_eq_ring_inverse : A⁻¹ = Ring.inverse A := by
by_cases h_det : IsUnit A.det
· cases (A.isUnit_iff_isUnit_det.mpr h_det).nonempty_invertible
rw [← invOf_eq_nonsing_inv, Ring.inverse_invertible]
· have h := mt A.isUnit_iff_isUnit_det.mp h_det
rw [Ring.inverse_non_unit _ h, nonsing_inv_apply_not_isUnit A h_det]
#align matrix.nonsing_inv_eq_ring_inverse Matrix.nonsing_inv_eq_ring_inverse
theorem transpose_nonsing_inv : A⁻¹ᵀ = Aᵀ⁻¹ := by
rw [inv_def, inv_def, transpose_smul, det_transpose, adjugate_transpose]
#align matrix.transpose_nonsing_inv Matrix.transpose_nonsing_inv
theorem conjTranspose_nonsing_inv [StarRing α] : A⁻¹ᴴ = Aᴴ⁻¹ := by
rw [inv_def, inv_def, conjTranspose_smul, det_conjTranspose, adjugate_conjTranspose,
Ring.inverse_star]
#align matrix.conj_transpose_nonsing_inv Matrix.conjTranspose_nonsing_inv
/-- The `nonsing_inv` of `A` is a right inverse. -/
@[simp]
theorem mul_nonsing_inv (h : IsUnit A.det) : A * A⁻¹ = 1 := by
cases (A.isUnit_iff_isUnit_det.mpr h).nonempty_invertible
rw [← invOf_eq_nonsing_inv, mul_invOf_self]
#align matrix.mul_nonsing_inv Matrix.mul_nonsing_inv
/-- The `nonsing_inv` of `A` is a left inverse. -/
@[simp]
theorem nonsing_inv_mul (h : IsUnit A.det) : A⁻¹ * A = 1 := by
cases (A.isUnit_iff_isUnit_det.mpr h).nonempty_invertible
rw [← invOf_eq_nonsing_inv, invOf_mul_self]
#align matrix.nonsing_inv_mul Matrix.nonsing_inv_mul
instance [Invertible A] : Invertible A⁻¹ := by
rw [← invOf_eq_nonsing_inv]
infer_instance
@[simp]
theorem inv_inv_of_invertible [Invertible A] : A⁻¹⁻¹ = A := by
simp only [← invOf_eq_nonsing_inv, invOf_invOf]
#align matrix.inv_inv_of_invertible Matrix.inv_inv_of_invertible
@[simp]
theorem mul_nonsing_inv_cancel_right (B : Matrix m n α) (h : IsUnit A.det) : B * A * A⁻¹ = B := by
simp [Matrix.mul_assoc, mul_nonsing_inv A h]
#align matrix.mul_nonsing_inv_cancel_right Matrix.mul_nonsing_inv_cancel_right
@[simp]
theorem mul_nonsing_inv_cancel_left (B : Matrix n m α) (h : IsUnit A.det) : A * (A⁻¹ * B) = B := by
simp [← Matrix.mul_assoc, mul_nonsing_inv A h]
#align matrix.mul_nonsing_inv_cancel_left Matrix.mul_nonsing_inv_cancel_left
@[simp]
theorem nonsing_inv_mul_cancel_right (B : Matrix m n α) (h : IsUnit A.det) : B * A⁻¹ * A = B := by
simp [Matrix.mul_assoc, nonsing_inv_mul A h]
#align matrix.nonsing_inv_mul_cancel_right Matrix.nonsing_inv_mul_cancel_right
@[simp]
theorem nonsing_inv_mul_cancel_left (B : Matrix n m α) (h : IsUnit A.det) : A⁻¹ * (A * B) = B := by
simp [← Matrix.mul_assoc, nonsing_inv_mul A h]
#align matrix.nonsing_inv_mul_cancel_left Matrix.nonsing_inv_mul_cancel_left
@[simp]
theorem mul_inv_of_invertible [Invertible A] : A * A⁻¹ = 1 :=
mul_nonsing_inv A (isUnit_det_of_invertible A)
#align matrix.mul_inv_of_invertible Matrix.mul_inv_of_invertible
@[simp]
theorem inv_mul_of_invertible [Invertible A] : A⁻¹ * A = 1 :=
nonsing_inv_mul A (isUnit_det_of_invertible A)
#align matrix.inv_mul_of_invertible Matrix.inv_mul_of_invertible
@[simp]
theorem mul_inv_cancel_right_of_invertible (B : Matrix m n α) [Invertible A] : B * A * A⁻¹ = B :=
mul_nonsing_inv_cancel_right A B (isUnit_det_of_invertible A)
#align matrix.mul_inv_cancel_right_of_invertible Matrix.mul_inv_cancel_right_of_invertible
@[simp]
theorem mul_inv_cancel_left_of_invertible (B : Matrix n m α) [Invertible A] : A * (A⁻¹ * B) = B :=
mul_nonsing_inv_cancel_left A B (isUnit_det_of_invertible A)
#align matrix.mul_inv_cancel_left_of_invertible Matrix.mul_inv_cancel_left_of_invertible
@[simp]
theorem inv_mul_cancel_right_of_invertible (B : Matrix m n α) [Invertible A] : B * A⁻¹ * A = B :=
nonsing_inv_mul_cancel_right A B (isUnit_det_of_invertible A)
#align matrix.inv_mul_cancel_right_of_invertible Matrix.inv_mul_cancel_right_of_invertible
@[simp]
theorem inv_mul_cancel_left_of_invertible (B : Matrix n m α) [Invertible A] : A⁻¹ * (A * B) = B :=
nonsing_inv_mul_cancel_left A B (isUnit_det_of_invertible A)
#align matrix.inv_mul_cancel_left_of_invertible Matrix.inv_mul_cancel_left_of_invertible
theorem inv_mul_eq_iff_eq_mul_of_invertible (A B C : Matrix n n α) [Invertible A] :
A⁻¹ * B = C ↔ B = A * C :=
⟨fun h => by rw [← h, mul_inv_cancel_left_of_invertible],
fun h => by rw [h, inv_mul_cancel_left_of_invertible]⟩
#align matrix.inv_mul_eq_iff_eq_mul_of_invertible Matrix.inv_mul_eq_iff_eq_mul_of_invertible
theorem mul_inv_eq_iff_eq_mul_of_invertible (A B C : Matrix n n α) [Invertible A] :
B * A⁻¹ = C ↔ B = C * A :=
⟨fun h => by rw [← h, inv_mul_cancel_right_of_invertible],
fun h => by rw [h, mul_inv_cancel_right_of_invertible]⟩
#align matrix.mul_inv_eq_iff_eq_mul_of_invertible Matrix.mul_inv_eq_iff_eq_mul_of_invertible
lemma mul_right_injective_of_invertible [Invertible A] :
Function.Injective (fun (x : Matrix n m α) => A * x) :=
fun _ _ h => by simpa only [inv_mul_cancel_left_of_invertible] using congr_arg (A⁻¹ * ·) h
lemma mul_left_injective_of_invertible [Invertible A] :
Function.Injective (fun (x : Matrix m n α) => x * A) :=
fun a x hax => by simpa only [mul_inv_cancel_right_of_invertible] using congr_arg (· * A⁻¹) hax
lemma mul_right_inj_of_invertible [Invertible A] {x y : Matrix n m α} : A * x = A * y ↔ x = y :=
(mul_right_injective_of_invertible A).eq_iff
lemma mul_left_inj_of_invertible [Invertible A] {x y : Matrix m n α} : x * A = y * A ↔ x = y :=
(mul_left_injective_of_invertible A).eq_iff
end Inv
section InjectiveMul
variable [Fintype n] [Fintype m] [DecidableEq m] [CommRing α]
variable [Fintype l] [DecidableEq l]
lemma mul_left_injective_of_inv (A : Matrix m n α) (B : Matrix n m α) (h : A * B = 1) :
Function.Injective (fun x : Matrix l m α => x * A) := fun _ _ g => by
simpa only [Matrix.mul_assoc, Matrix.mul_one, h] using congr_arg (· * B) g
lemma mul_right_injective_of_inv (A : Matrix m n α) (B : Matrix n m α) (h : A * B = 1) :
Function.Injective (fun x : Matrix m l α => B * x) :=
fun _ _ g => by simpa only [← Matrix.mul_assoc, Matrix.one_mul, h] using congr_arg (A * ·) g
end InjectiveMul
section vecMul
variable [DecidableEq m] [DecidableEq n]
section Semiring
variable {R : Type*} [Semiring R]
theorem vecMul_surjective_iff_exists_left_inverse [Fintype m] [Finite n] {A : Matrix m n R} :
Function.Surjective A.vecMul ↔ ∃ B : Matrix n m R, B * A = 1 := by
cases nonempty_fintype n
refine ⟨fun h ↦ ?_, fun ⟨B, hBA⟩ y ↦ ⟨y ᵥ* B, by simp [hBA]⟩⟩
choose rows hrows using (h <| Pi.single · 1)
refine ⟨Matrix.of rows, Matrix.ext fun i j => ?_⟩
rw [mul_apply_eq_vecMul, one_eq_pi_single, ← hrows]
rfl
theorem mulVec_surjective_iff_exists_right_inverse [Finite m] [Fintype n] {A : Matrix m n R} :
Function.Surjective A.mulVec ↔ ∃ B : Matrix n m R, A * B = 1 := by
cases nonempty_fintype m
refine ⟨fun h ↦ ?_, fun ⟨B, hBA⟩ y ↦ ⟨B *ᵥ y, by simp [hBA]⟩⟩
choose cols hcols using (h <| Pi.single · 1)
refine ⟨(Matrix.of cols)ᵀ, Matrix.ext fun i j ↦ ?_⟩
rw [one_eq_pi_single, Pi.single_comm, ← hcols j]
rfl
end Semiring
variable {R K : Type*} [CommRing R] [Field K] [Fintype m]
theorem vecMul_surjective_iff_isUnit {A : Matrix m m R} :
Function.Surjective A.vecMul ↔ IsUnit A := by
rw [vecMul_surjective_iff_exists_left_inverse, exists_left_inverse_iff_isUnit]
theorem mulVec_surjective_iff_isUnit {A : Matrix m m R} :
Function.Surjective A.mulVec ↔ IsUnit A := by
rw [mulVec_surjective_iff_exists_right_inverse, exists_right_inverse_iff_isUnit]
theorem vecMul_injective_iff_isUnit {A : Matrix m m K} :
Function.Injective A.vecMul ↔ IsUnit A := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rw [← vecMul_surjective_iff_isUnit]
exact LinearMap.surjective_of_injective (f := A.vecMulLinear) h
change Function.Injective A.vecMulLinear
rw [← LinearMap.ker_eq_bot, LinearMap.ker_eq_bot']
intro c hc
replace h := h.invertible
simpa using congr_arg A⁻¹.vecMulLinear hc
theorem mulVec_injective_iff_isUnit {A : Matrix m m K} :
Function.Injective A.mulVec ↔ IsUnit A := by
rw [← isUnit_transpose, ← vecMul_injective_iff_isUnit]
simp_rw [vecMul_transpose]
theorem linearIndependent_rows_iff_isUnit {A : Matrix m m K} :
LinearIndependent K (fun i ↦ A i) ↔ IsUnit A := by
rw [← transpose_transpose A, ← mulVec_injective_iff, ← coe_mulVecLin, mulVecLin_transpose,
transpose_transpose, ← vecMul_injective_iff_isUnit, coe_vecMulLinear]
theorem linearIndependent_cols_iff_isUnit {A : Matrix m m K} :
LinearIndependent K (fun i ↦ Aᵀ i) ↔ IsUnit A := by
rw [← transpose_transpose A, isUnit_transpose, linearIndependent_rows_iff_isUnit,
transpose_transpose]
theorem vecMul_surjective_of_invertible (A : Matrix m m R) [Invertible A] :
Function.Surjective A.vecMul :=
vecMul_surjective_iff_isUnit.2 <| isUnit_of_invertible A
theorem mulVec_surjective_of_invertible (A : Matrix m m R) [Invertible A] :
Function.Surjective A.mulVec :=
mulVec_surjective_iff_isUnit.2 <| isUnit_of_invertible A
theorem vecMul_injective_of_invertible (A : Matrix m m K) [Invertible A] :
Function.Injective A.vecMul :=
vecMul_injective_iff_isUnit.2 <| isUnit_of_invertible A
theorem mulVec_injective_of_invertible (A : Matrix m m K) [Invertible A] :
Function.Injective A.mulVec :=
mulVec_injective_iff_isUnit.2 <| isUnit_of_invertible A
theorem linearIndependent_rows_of_invertible (A : Matrix m m K) [Invertible A] :
LinearIndependent K (fun i ↦ A i) :=
linearIndependent_rows_iff_isUnit.2 <| isUnit_of_invertible A
theorem linearIndependent_cols_of_invertible (A : Matrix m m K) [Invertible A] :
LinearIndependent K (fun i ↦ Aᵀ i) :=
linearIndependent_cols_iff_isUnit.2 <| isUnit_of_invertible A
end vecMul
variable [Fintype n] [DecidableEq n] [CommRing α]
variable (A : Matrix n n α) (B : Matrix n n α)
theorem nonsing_inv_cancel_or_zero : A⁻¹ * A = 1 ∧ A * A⁻¹ = 1 ∨ A⁻¹ = 0 := by
by_cases h : IsUnit A.det
· exact Or.inl ⟨nonsing_inv_mul _ h, mul_nonsing_inv _ h⟩
· exact Or.inr (nonsing_inv_apply_not_isUnit _ h)
#align matrix.nonsing_inv_cancel_or_zero Matrix.nonsing_inv_cancel_or_zero
theorem det_nonsing_inv_mul_det (h : IsUnit A.det) : A⁻¹.det * A.det = 1 := by
rw [← det_mul, A.nonsing_inv_mul h, det_one]
#align matrix.det_nonsing_inv_mul_det Matrix.det_nonsing_inv_mul_det
@[simp]
theorem det_nonsing_inv : A⁻¹.det = Ring.inverse A.det := by
by_cases h : IsUnit A.det
· cases h.nonempty_invertible
letI := invertibleOfDetInvertible A
rw [Ring.inverse_invertible, ← invOf_eq_nonsing_inv, det_invOf]
cases isEmpty_or_nonempty n
· rw [det_isEmpty, det_isEmpty, Ring.inverse_one]
· rw [Ring.inverse_non_unit _ h, nonsing_inv_apply_not_isUnit _ h, det_zero ‹_›]
#align matrix.det_nonsing_inv Matrix.det_nonsing_inv
theorem isUnit_nonsing_inv_det (h : IsUnit A.det) : IsUnit A⁻¹.det :=
isUnit_of_mul_eq_one _ _ (A.det_nonsing_inv_mul_det h)
#align matrix.is_unit_nonsing_inv_det Matrix.isUnit_nonsing_inv_det
@[simp]
theorem nonsing_inv_nonsing_inv (h : IsUnit A.det) : A⁻¹⁻¹ = A :=
calc
A⁻¹⁻¹ = 1 * A⁻¹⁻¹ := by rw [Matrix.one_mul]
_ = A * A⁻¹ * A⁻¹⁻¹ := by rw [A.mul_nonsing_inv h]
_ = A := by
rw [Matrix.mul_assoc, A⁻¹.mul_nonsing_inv (A.isUnit_nonsing_inv_det h), Matrix.mul_one]
#align matrix.nonsing_inv_nonsing_inv Matrix.nonsing_inv_nonsing_inv
theorem isUnit_nonsing_inv_det_iff {A : Matrix n n α} : IsUnit A⁻¹.det ↔ IsUnit A.det := by
rw [Matrix.det_nonsing_inv, isUnit_ring_inverse]
#align matrix.is_unit_nonsing_inv_det_iff Matrix.isUnit_nonsing_inv_det_iff
-- `IsUnit.invertible` lifts the proposition `IsUnit A` to a constructive inverse of `A`.
/-- A version of `Matrix.invertibleOfDetInvertible` with the inverse defeq to `A⁻¹` that is
therefore noncomputable. -/
noncomputable def invertibleOfIsUnitDet (h : IsUnit A.det) : Invertible A :=
⟨A⁻¹, nonsing_inv_mul A h, mul_nonsing_inv A h⟩
#align matrix.invertible_of_is_unit_det Matrix.invertibleOfIsUnitDet
/-- A version of `Matrix.unitOfDetInvertible` with the inverse defeq to `A⁻¹` that is therefore
noncomputable. -/
noncomputable def nonsingInvUnit (h : IsUnit A.det) : (Matrix n n α)ˣ :=
@unitOfInvertible _ _ _ (invertibleOfIsUnitDet A h)
#align matrix.nonsing_inv_unit Matrix.nonsingInvUnit
theorem unitOfDetInvertible_eq_nonsingInvUnit [Invertible A.det] :
unitOfDetInvertible A = nonsingInvUnit A (isUnit_of_invertible _) := by
ext
rfl
#align matrix.unit_of_det_invertible_eq_nonsing_inv_unit Matrix.unitOfDetInvertible_eq_nonsingInvUnit
variable {A} {B}
/-- If matrix A is left invertible, then its inverse equals its left inverse. -/
theorem inv_eq_left_inv (h : B * A = 1) : A⁻¹ = B :=
letI := invertibleOfLeftInverse _ _ h
invOf_eq_nonsing_inv A ▸ invOf_eq_left_inv h
#align matrix.inv_eq_left_inv Matrix.inv_eq_left_inv
/-- If matrix A is right invertible, then its inverse equals its right inverse. -/
theorem inv_eq_right_inv (h : A * B = 1) : A⁻¹ = B :=
inv_eq_left_inv (mul_eq_one_comm.2 h)
#align matrix.inv_eq_right_inv Matrix.inv_eq_right_inv
section InvEqInv
variable {C : Matrix n n α}
/-- The left inverse of matrix A is unique when existing. -/
theorem left_inv_eq_left_inv (h : B * A = 1) (g : C * A = 1) : B = C := by
rw [← inv_eq_left_inv h, ← inv_eq_left_inv g]
#align matrix.left_inv_eq_left_inv Matrix.left_inv_eq_left_inv
/-- The right inverse of matrix A is unique when existing. -/
theorem right_inv_eq_right_inv (h : A * B = 1) (g : A * C = 1) : B = C := by
rw [← inv_eq_right_inv h, ← inv_eq_right_inv g]
#align matrix.right_inv_eq_right_inv Matrix.right_inv_eq_right_inv
/-- The right inverse of matrix A equals the left inverse of A when they exist. -/
| Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean | 556 | 557 | theorem right_inv_eq_left_inv (h : A * B = 1) (g : C * A = 1) : B = C := by |
rw [← inv_eq_right_inv h, ← inv_eq_left_inv g]
|
/-
Copyright (c) 2022 Jon Eugster. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jon Eugster
-/
import Mathlib.Algebra.CharP.LocalRing
import Mathlib.RingTheory.Ideal.Quotient
import Mathlib.Tactic.FieldSimp
#align_import algebra.char_p.mixed_char_zero from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Equal and mixed characteristic
In commutative algebra, some statements are simpler when working over a `ℚ`-algebra `R`, in which
case one also says that the ring has "equal characteristic zero". A ring that is not a
`ℚ`-algebra has either positive characteristic or there exists a prime ideal `I ⊂ R` such that
the quotient `R ⧸ I` has positive characteristic `p > 0`. In this case one speaks of
"mixed characteristic `(0, p)`", where `p` is only unique if `R` is local.
Examples of mixed characteristic rings are `ℤ` or the `p`-adic integers/numbers.
This file provides the main theorem `split_by_characteristic` that splits any proposition `P` into
the following three cases:
1) Positive characteristic: `CharP R p` (where `p ≠ 0`)
2) Equal characteristic zero: `Algebra ℚ R`
3) Mixed characteristic: `MixedCharZero R p` (where `p` is prime)
## Main definitions
- `MixedCharZero` : A ring has mixed characteristic `(0, p)` if it has characteristic zero
and there exists an ideal such that the quotient `R ⧸ I` has characteristic `p`.
## Main results
- `split_equalCharZero_mixedCharZero` : Split a statement into equal/mixed characteristic zero.
This main theorem has the following three corollaries which include the positive
characteristic case for convenience:
- `split_by_characteristic` : Generally consider positive char `p ≠ 0`.
- `split_by_characteristic_domain` : In a domain we can assume that `p` is prime.
- `split_by_characteristic_localRing` : In a local ring we can assume that `p` is a prime power.
## Implementation Notes
We use the terms `EqualCharZero` and `AlgebraRat` despite not being such definitions in mathlib.
The former refers to the statement `∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I)`, the latter
refers to the existence of an instance `[Algebra ℚ R]`. The two are shown to be
equivalent conditions.
## TODO
- Relate mixed characteristic in a local ring to p-adic numbers [NumberTheory.PAdics].
-/
variable (R : Type*) [CommRing R]
/-!
### Mixed characteristic
-/
/--
A ring of characteristic zero is of "mixed characteristic `(0, p)`" if there exists an ideal
such that the quotient `R ⧸ I` has characteristic `p`.
**Remark:** For `p = 0`, `MixedChar R 0` is a meaningless definition (i.e. satisfied by any ring)
as `R ⧸ ⊥ ≅ R` has by definition always characteristic zero.
One could require `(I ≠ ⊥)` in the definition, but then `MixedChar R 0` would mean something
like `ℤ`-algebra of extension degree `≥ 1` and would be completely independent from
whether something is a `ℚ`-algebra or not (e.g. `ℚ[X]` would satisfy it but `ℚ` wouldn't).
-/
class MixedCharZero (p : ℕ) : Prop where
[toCharZero : CharZero R]
charP_quotient : ∃ I : Ideal R, I ≠ ⊤ ∧ CharP (R ⧸ I) p
#align mixed_char_zero MixedCharZero
namespace MixedCharZero
/--
Reduction to `p` prime: When proving any statement `P` about mixed characteristic rings we
can always assume that `p` is prime.
-/
theorem reduce_to_p_prime {P : Prop} :
(∀ p > 0, MixedCharZero R p → P) ↔ ∀ p : ℕ, p.Prime → MixedCharZero R p → P := by
constructor
· intro h q q_prime q_mixedChar
exact h q (Nat.Prime.pos q_prime) q_mixedChar
· intro h q q_pos q_mixedChar
rcases q_mixedChar.charP_quotient with ⟨I, hI_ne_top, _⟩
-- Krull's Thm: There exists a prime ideal `P` such that `I ≤ P`
rcases Ideal.exists_le_maximal I hI_ne_top with ⟨M, hM_max, h_IM⟩
let r := ringChar (R ⧸ M)
have r_pos : r ≠ 0 := by
have q_zero :=
congr_arg (Ideal.Quotient.factor I M h_IM) (CharP.cast_eq_zero (R ⧸ I) q)
simp only [map_natCast, map_zero] at q_zero
apply ne_zero_of_dvd_ne_zero (ne_of_gt q_pos)
exact (CharP.cast_eq_zero_iff (R ⧸ M) r q).mp q_zero
have r_prime : Nat.Prime r :=
or_iff_not_imp_right.1 (CharP.char_is_prime_or_zero (R ⧸ M) r) r_pos
apply h r r_prime
have : CharZero R := q_mixedChar.toCharZero
exact ⟨⟨M, hM_max.ne_top, ringChar.of_eq rfl⟩⟩
#align mixed_char_zero.reduce_to_p_prime MixedCharZero.reduce_to_p_prime
/--
Reduction to `I` prime ideal: When proving statements about mixed characteristic rings,
after we reduced to `p` prime, we can assume that the ideal `I` in the definition is maximal.
-/
theorem reduce_to_maximal_ideal {p : ℕ} (hp : Nat.Prime p) :
(∃ I : Ideal R, I ≠ ⊤ ∧ CharP (R ⧸ I) p) ↔ ∃ I : Ideal R, I.IsMaximal ∧ CharP (R ⧸ I) p := by
constructor
· intro g
rcases g with ⟨I, ⟨hI_not_top, _⟩⟩
-- Krull's Thm: There exists a prime ideal `M` such that `I ≤ M`.
rcases Ideal.exists_le_maximal I hI_not_top with ⟨M, ⟨hM_max, hM_ge⟩⟩
use M
constructor
· exact hM_max
· cases CharP.exists (R ⧸ M) with
| intro r hr =>
-- Porting note: This is odd. Added `have hr := hr`.
-- Without this it seems that lean does not find `hr` as an instance.
have hr := hr
convert hr
have r_dvd_p : r ∣ p := by
rw [← CharP.cast_eq_zero_iff (R ⧸ M) r p]
convert congr_arg (Ideal.Quotient.factor I M hM_ge) (CharP.cast_eq_zero (R ⧸ I) p)
symm
apply (Nat.Prime.eq_one_or_self_of_dvd hp r r_dvd_p).resolve_left
exact CharP.char_ne_one (R ⧸ M) r
· intro ⟨I, hI_max, h_charP⟩
use I
exact ⟨Ideal.IsMaximal.ne_top hI_max, h_charP⟩
#align mixed_char_zero.reduce_to_maximal_ideal MixedCharZero.reduce_to_maximal_ideal
end MixedCharZero
/-!
### Equal characteristic zero
A commutative ring `R` has "equal characteristic zero" if it satisfies one of the following
equivalent properties:
1) `R` is a `ℚ`-algebra.
2) The quotient `R ⧸ I` has characteristic zero for any proper ideal `I ⊂ R`.
3) `R` has characteristic zero and does not have mixed characteristic for any prime `p`.
We show `(1) ↔ (2) ↔ (3)`, and most of the following is concerned with constructing
an explicit algebra map `ℚ →+* R` (given by `x ↦ (x.num : R) /ₚ ↑x.pnatDen`)
for the direction `(1) ← (2)`.
Note: Property `(2)` is denoted as `EqualCharZero` in the statement names below.
-/
namespace EqualCharZero
/-- `ℚ`-algebra implies equal characteristic. -/
| Mathlib/Algebra/CharP/MixedCharZero.lean | 161 | 169 | theorem of_algebraRat [Algebra ℚ R] : ∀ I : Ideal R, I ≠ ⊤ → CharZero (R ⧸ I) := by |
intro I hI
constructor
intro a b h_ab
contrapose! hI
-- `↑a - ↑b` is a unit contained in `I`, which contradicts `I ≠ ⊤`.
refine I.eq_top_of_isUnit_mem ?_ (IsUnit.map (algebraMap ℚ R) (IsUnit.mk0 (a - b : ℚ) ?_))
· simpa only [← Ideal.Quotient.eq_zero_iff_mem, map_sub, sub_eq_zero, map_natCast]
simpa only [Ne, sub_eq_zero] using (@Nat.cast_injective ℚ _ _).ne hI
|
/-
Copyright (c) 2016 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad
-/
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.Nat.Bitwise
import Mathlib.Data.Nat.Size
#align_import data.int.bitwise from "leanprover-community/mathlib"@"0743cc5d9d86bcd1bba10f480e948a257d65056f"
#align_import init.data.int.bitwise from "leanprover-community/lean"@"855e5b74e3a52a40552e8f067169d747d48743fd"
/-!
# Bitwise operations on integers
Possibly only of archaeological significance.
## Recursors
* `Int.bitCasesOn`: Parity disjunction. Something is true/defined on `ℤ` if it's true/defined for
even and for odd values.
-/
namespace Int
/-- `div2 n = n/2`-/
def div2 : ℤ → ℤ
| (n : ℕ) => n.div2
| -[n +1] => negSucc n.div2
#align int.div2 Int.div2
/-- `bodd n` returns `true` if `n` is odd-/
def bodd : ℤ → Bool
| (n : ℕ) => n.bodd
| -[n +1] => not (n.bodd)
#align int.bodd Int.bodd
-- Porting note: `bit0, bit1` deprecated, do we need to adapt `bit`?
set_option linter.deprecated false in
/-- `bit b` appends the digit `b` to the binary representation of
its integer input. -/
def bit (b : Bool) : ℤ → ℤ :=
cond b bit1 bit0
#align int.bit Int.bit
/-- `testBit m n` returns whether the `(n+1)ˢᵗ` least significant bit is `1` or `0`-/
def testBit : ℤ → ℕ → Bool
| (m : ℕ), n => Nat.testBit m n
| -[m +1], n => !(Nat.testBit m n)
#align int.test_bit Int.testBit
/-- `Int.natBitwise` is an auxiliary definition for `Int.bitwise`. -/
def natBitwise (f : Bool → Bool → Bool) (m n : ℕ) : ℤ :=
cond (f false false) -[ Nat.bitwise (fun x y => not (f x y)) m n +1] (Nat.bitwise f m n)
#align int.nat_bitwise Int.natBitwise
/-- `Int.bitwise` applies the function `f` to pairs of bits in the same position in
the binary representations of its inputs. -/
def bitwise (f : Bool → Bool → Bool) : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => natBitwise f m n
| (m : ℕ), -[n +1] => natBitwise (fun x y => f x (not y)) m n
| -[m +1], (n : ℕ) => natBitwise (fun x y => f (not x) y) m n
| -[m +1], -[n +1] => natBitwise (fun x y => f (not x) (not y)) m n
#align int.bitwise Int.bitwise
/-- `lnot` flips all the bits in the binary representation of its input -/
def lnot : ℤ → ℤ
| (m : ℕ) => -[m +1]
| -[m +1] => m
#align int.lnot Int.lnot
/-- `lor` takes two integers and returns their bitwise `or`-/
def lor : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => m ||| n
| (m : ℕ), -[n +1] => -[Nat.ldiff n m +1]
| -[m +1], (n : ℕ) => -[Nat.ldiff m n +1]
| -[m +1], -[n +1] => -[m &&& n +1]
#align int.lor Int.lor
/-- `land` takes two integers and returns their bitwise `and`-/
def land : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => m &&& n
| (m : ℕ), -[n +1] => Nat.ldiff m n
| -[m +1], (n : ℕ) => Nat.ldiff n m
| -[m +1], -[n +1] => -[m ||| n +1]
#align int.land Int.land
-- Porting note: I don't know why `Nat.ldiff` got the prime, but I'm matching this change here
/-- `ldiff a b` performs bitwise set difference. For each corresponding
pair of bits taken as booleans, say `aᵢ` and `bᵢ`, it applies the
boolean operation `aᵢ ∧ bᵢ` to obtain the `iᵗʰ` bit of the result. -/
def ldiff : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => Nat.ldiff m n
| (m : ℕ), -[n +1] => m &&& n
| -[m +1], (n : ℕ) => -[m ||| n +1]
| -[m +1], -[n +1] => Nat.ldiff n m
#align int.ldiff Int.ldiff
-- Porting note: I don't know why `Nat.xor'` got the prime, but I'm matching this change here
/-- `xor` computes the bitwise `xor` of two natural numbers-/
protected def xor : ℤ → ℤ → ℤ
| (m : ℕ), (n : ℕ) => (m ^^^ n)
| (m : ℕ), -[n +1] => -[(m ^^^ n) +1]
| -[m +1], (n : ℕ) => -[(m ^^^ n) +1]
| -[m +1], -[n +1] => (m ^^^ n)
#align int.lxor Int.xor
/-- `m <<< n` produces an integer whose binary representation
is obtained by left-shifting the binary representation of `m` by `n` places -/
instance : ShiftLeft ℤ where
shiftLeft
| (m : ℕ), (n : ℕ) => Nat.shiftLeft' false m n
| (m : ℕ), -[n +1] => m >>> (Nat.succ n)
| -[m +1], (n : ℕ) => -[Nat.shiftLeft' true m n +1]
| -[m +1], -[n +1] => -[m >>> (Nat.succ n) +1]
#align int.shiftl ShiftLeft.shiftLeft
/-- `m >>> n` produces an integer whose binary representation
is obtained by right-shifting the binary representation of `m` by `n` places -/
instance : ShiftRight ℤ where
shiftRight m n := m <<< (-n)
#align int.shiftr ShiftRight.shiftRight
/-! ### bitwise ops -/
@[simp]
theorem bodd_zero : bodd 0 = false :=
rfl
#align int.bodd_zero Int.bodd_zero
@[simp]
theorem bodd_one : bodd 1 = true :=
rfl
#align int.bodd_one Int.bodd_one
theorem bodd_two : bodd 2 = false :=
rfl
#align int.bodd_two Int.bodd_two
@[simp, norm_cast]
theorem bodd_coe (n : ℕ) : Int.bodd n = Nat.bodd n :=
rfl
#align int.bodd_coe Int.bodd_coe
@[simp]
theorem bodd_subNatNat (m n : ℕ) : bodd (subNatNat m n) = xor m.bodd n.bodd := by
apply subNatNat_elim m n fun m n i => bodd i = xor m.bodd n.bodd <;>
intros i j <;>
simp only [Int.bodd, Int.bodd_coe, Nat.bodd_add] <;>
cases Nat.bodd i <;> simp
#align int.bodd_sub_nat_nat Int.bodd_subNatNat
@[simp]
theorem bodd_negOfNat (n : ℕ) : bodd (negOfNat n) = n.bodd := by
cases n <;> simp (config := {decide := true})
rfl
#align int.bodd_neg_of_nat Int.bodd_negOfNat
@[simp]
theorem bodd_neg (n : ℤ) : bodd (-n) = bodd n := by
cases n with
| ofNat =>
rw [← negOfNat_eq, bodd_negOfNat]
simp
| negSucc n =>
rw [neg_negSucc, bodd_coe, Nat.bodd_succ]
change (!Nat.bodd n) = !(bodd n)
rw [bodd_coe]
-- Porting note: Heavily refactored proof, used to work all with `simp`:
-- `cases n <;> simp [Neg.neg, Int.natCast_eq_ofNat, Int.neg, bodd, -of_nat_eq_coe]`
#align int.bodd_neg Int.bodd_neg
@[simp]
theorem bodd_add (m n : ℤ) : bodd (m + n) = xor (bodd m) (bodd n) := by
cases' m with m m <;>
cases' n with n n <;>
simp only [ofNat_eq_coe, ofNat_add_negSucc, negSucc_add_ofNat,
negSucc_add_negSucc, bodd_subNatNat] <;>
simp only [negSucc_coe, bodd_neg, bodd_coe, ← Nat.bodd_add, Bool.xor_comm, ← Nat.cast_add]
rw [← Nat.succ_add, add_assoc]
-- Porting note: Heavily refactored proof, used to work all with `simp`:
-- `by cases m with m m; cases n with n n; unfold has_add.add;`
-- `simp [int.add, -of_nat_eq_coe, bool.xor_comm]`
#align int.bodd_add Int.bodd_add
@[simp]
| Mathlib/Data/Int/Bitwise.lean | 186 | 190 | theorem bodd_mul (m n : ℤ) : bodd (m * n) = (bodd m && bodd n) := by |
cases' m with m m <;> cases' n with n n <;>
simp only [ofNat_eq_coe, ofNat_mul_negSucc, negSucc_mul_ofNat, ofNat_mul_ofNat,
negSucc_mul_negSucc] <;>
simp only [negSucc_coe, bodd_neg, bodd_coe, ← Nat.bodd_mul]
|
/-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Johannes Hölzl, Mario Carneiro, Patrick Massot
-/
import Mathlib.Data.Prod.PProd
import Mathlib.Data.Set.Countable
import Mathlib.Order.Filter.Prod
import Mathlib.Order.Filter.Ker
#align_import order.filter.bases from "leanprover-community/mathlib"@"996b0ff959da753a555053a480f36e5f264d4207"
/-!
# Filter bases
A filter basis `B : FilterBasis α` on a type `α` is a nonempty collection of sets of `α`
such that the intersection of two elements of this collection contains some element of
the collection. Compared to filters, filter bases do not require that any set containing
an element of `B` belongs to `B`.
A filter basis `B` can be used to construct `B.filter : Filter α` such that a set belongs
to `B.filter` if and only if it contains an element of `B`.
Given an indexing type `ι`, a predicate `p : ι → Prop`, and a map `s : ι → Set α`,
the proposition `h : Filter.IsBasis p s` makes sure the range of `s` bounded by `p`
(ie. `s '' setOf p`) defines a filter basis `h.filterBasis`.
If one already has a filter `l` on `α`, `Filter.HasBasis l p s` (where `p : ι → Prop`
and `s : ι → Set α` as above) means that a set belongs to `l` if and
only if it contains some `s i` with `p i`. It implies `h : Filter.IsBasis p s`, and
`l = h.filterBasis.filter`. The point of this definition is that checking statements
involving elements of `l` often reduces to checking them on the basis elements.
We define a function `HasBasis.index (h : Filter.HasBasis l p s) (t) (ht : t ∈ l)` that returns
some index `i` such that `p i` and `s i ⊆ t`. This function can be useful to avoid manual
destruction of `h.mem_iff.mpr ht` using `cases` or `let`.
This file also introduces more restricted classes of bases, involving monotonicity or
countability. In particular, for `l : Filter α`, `l.IsCountablyGenerated` means
there is a countable set of sets which generates `s`. This is reformulated in term of bases,
and consequences are derived.
## Main statements
* `Filter.HasBasis.mem_iff`, `HasBasis.mem_of_superset`, `HasBasis.mem_of_mem` : restate `t ∈ f` in
terms of a basis;
* `Filter.basis_sets` : all sets of a filter form a basis;
* `Filter.HasBasis.inf`, `Filter.HasBasis.inf_principal`, `Filter.HasBasis.prod`,
`Filter.HasBasis.prod_self`, `Filter.HasBasis.map`, `Filter.HasBasis.comap` : combinators to
construct filters of `l ⊓ l'`, `l ⊓ 𝓟 t`, `l ×ˢ l'`, `l ×ˢ l`, `l.map f`, `l.comap f`
respectively;
* `Filter.HasBasis.le_iff`, `Filter.HasBasis.ge_iff`, `Filter.HasBasis.le_basis_iff` : restate
`l ≤ l'` in terms of bases.
* `Filter.HasBasis.tendsto_right_iff`, `Filter.HasBasis.tendsto_left_iff`,
`Filter.HasBasis.tendsto_iff` : restate `Tendsto f l l'` in terms of bases.
* `isCountablyGenerated_iff_exists_antitone_basis` : proves a filter is countably generated if and
only if it admits a basis parametrized by a decreasing sequence of sets indexed by `ℕ`.
* `tendsto_iff_seq_tendsto` : an abstract version of "sequentially continuous implies continuous".
## Implementation notes
As with `Set.iUnion`/`biUnion`/`Set.sUnion`, there are three different approaches to filter bases:
* `Filter.HasBasis l s`, `s : Set (Set α)`;
* `Filter.HasBasis l s`, `s : ι → Set α`;
* `Filter.HasBasis l p s`, `p : ι → Prop`, `s : ι → Set α`.
We use the latter one because, e.g., `𝓝 x` in an `EMetricSpace` or in a `MetricSpace` has a basis
of this form. The other two can be emulated using `s = id` or `p = fun _ ↦ True`.
With this approach sometimes one needs to `simp` the statement provided by the `Filter.HasBasis`
machinery, e.g., `simp only [true_and]` or `simp only [forall_const]` can help with the case
`p = fun _ ↦ True`.
-/
set_option autoImplicit true
open Set Filter
open scoped Classical
open Filter
section sort
variable {α β γ : Type*} {ι ι' : Sort*}
/-- A filter basis `B` on a type `α` is a nonempty collection of sets of `α`
such that the intersection of two elements of this collection contains some element
of the collection. -/
structure FilterBasis (α : Type*) where
/-- Sets of a filter basis. -/
sets : Set (Set α)
/-- The set of filter basis sets is nonempty. -/
nonempty : sets.Nonempty
/-- The set of filter basis sets is directed downwards. -/
inter_sets {x y} : x ∈ sets → y ∈ sets → ∃ z ∈ sets, z ⊆ x ∩ y
#align filter_basis FilterBasis
instance FilterBasis.nonempty_sets (B : FilterBasis α) : Nonempty B.sets :=
B.nonempty.to_subtype
#align filter_basis.nonempty_sets FilterBasis.nonempty_sets
-- Porting note: this instance was reducible but it doesn't work the same way in Lean 4
/-- If `B` is a filter basis on `α`, and `U` a subset of `α` then we can write `U ∈ B` as
on paper. -/
instance {α : Type*} : Membership (Set α) (FilterBasis α) :=
⟨fun U B => U ∈ B.sets⟩
@[simp] theorem FilterBasis.mem_sets {s : Set α} {B : FilterBasis α} : s ∈ B.sets ↔ s ∈ B := Iff.rfl
-- For illustration purposes, the filter basis defining `(atTop : Filter ℕ)`
instance : Inhabited (FilterBasis ℕ) :=
⟨{ sets := range Ici
nonempty := ⟨Ici 0, mem_range_self 0⟩
inter_sets := by
rintro _ _ ⟨n, rfl⟩ ⟨m, rfl⟩
exact ⟨Ici (max n m), mem_range_self _, Ici_inter_Ici.symm.subset⟩ }⟩
/-- View a filter as a filter basis. -/
def Filter.asBasis (f : Filter α) : FilterBasis α :=
⟨f.sets, ⟨univ, univ_mem⟩, fun {x y} hx hy => ⟨x ∩ y, inter_mem hx hy, subset_rfl⟩⟩
#align filter.as_basis Filter.asBasis
-- Porting note: was `protected` in Lean 3 but `protected` didn't work; removed
/-- `is_basis p s` means the image of `s` bounded by `p` is a filter basis. -/
structure Filter.IsBasis (p : ι → Prop) (s : ι → Set α) : Prop where
/-- There exists at least one `i` that satisfies `p`. -/
nonempty : ∃ i, p i
/-- `s` is directed downwards on `i` such that `p i`. -/
inter : ∀ {i j}, p i → p j → ∃ k, p k ∧ s k ⊆ s i ∩ s j
#align filter.is_basis Filter.IsBasis
namespace Filter
namespace IsBasis
/-- Constructs a filter basis from an indexed family of sets satisfying `IsBasis`. -/
protected def filterBasis {p : ι → Prop} {s : ι → Set α} (h : IsBasis p s) : FilterBasis α where
sets := { t | ∃ i, p i ∧ s i = t }
nonempty :=
let ⟨i, hi⟩ := h.nonempty
⟨s i, ⟨i, hi, rfl⟩⟩
inter_sets := by
rintro _ _ ⟨i, hi, rfl⟩ ⟨j, hj, rfl⟩
rcases h.inter hi hj with ⟨k, hk, hk'⟩
exact ⟨_, ⟨k, hk, rfl⟩, hk'⟩
#align filter.is_basis.filter_basis Filter.IsBasis.filterBasis
variable {p : ι → Prop} {s : ι → Set α} (h : IsBasis p s)
theorem mem_filterBasis_iff {U : Set α} : U ∈ h.filterBasis ↔ ∃ i, p i ∧ s i = U :=
Iff.rfl
#align filter.is_basis.mem_filter_basis_iff Filter.IsBasis.mem_filterBasis_iff
end IsBasis
end Filter
namespace FilterBasis
/-- The filter associated to a filter basis. -/
protected def filter (B : FilterBasis α) : Filter α where
sets := { s | ∃ t ∈ B, t ⊆ s }
univ_sets := B.nonempty.imp fun s s_in => ⟨s_in, s.subset_univ⟩
sets_of_superset := fun ⟨s, s_in, h⟩ hxy => ⟨s, s_in, Set.Subset.trans h hxy⟩
inter_sets := fun ⟨_s, s_in, hs⟩ ⟨_t, t_in, ht⟩ =>
let ⟨u, u_in, u_sub⟩ := B.inter_sets s_in t_in
⟨u, u_in, u_sub.trans (inter_subset_inter hs ht)⟩
#align filter_basis.filter FilterBasis.filter
theorem mem_filter_iff (B : FilterBasis α) {U : Set α} : U ∈ B.filter ↔ ∃ s ∈ B, s ⊆ U :=
Iff.rfl
#align filter_basis.mem_filter_iff FilterBasis.mem_filter_iff
theorem mem_filter_of_mem (B : FilterBasis α) {U : Set α} : U ∈ B → U ∈ B.filter := fun U_in =>
⟨U, U_in, Subset.refl _⟩
#align filter_basis.mem_filter_of_mem FilterBasis.mem_filter_of_mem
theorem eq_iInf_principal (B : FilterBasis α) : B.filter = ⨅ s : B.sets, 𝓟 s := by
have : Directed (· ≥ ·) fun s : B.sets => 𝓟 (s : Set α) := by
rintro ⟨U, U_in⟩ ⟨V, V_in⟩
rcases B.inter_sets U_in V_in with ⟨W, W_in, W_sub⟩
use ⟨W, W_in⟩
simp only [ge_iff_le, le_principal_iff, mem_principal, Subtype.coe_mk]
exact subset_inter_iff.mp W_sub
ext U
simp [mem_filter_iff, mem_iInf_of_directed this]
#align filter_basis.eq_infi_principal FilterBasis.eq_iInf_principal
protected theorem generate (B : FilterBasis α) : generate B.sets = B.filter := by
apply le_antisymm
· intro U U_in
rcases B.mem_filter_iff.mp U_in with ⟨V, V_in, h⟩
exact GenerateSets.superset (GenerateSets.basic V_in) h
· rw [le_generate_iff]
apply mem_filter_of_mem
#align filter_basis.generate FilterBasis.generate
end FilterBasis
namespace Filter
namespace IsBasis
variable {p : ι → Prop} {s : ι → Set α}
/-- Constructs a filter from an indexed family of sets satisfying `IsBasis`. -/
protected def filter (h : IsBasis p s) : Filter α :=
h.filterBasis.filter
#align filter.is_basis.filter Filter.IsBasis.filter
protected theorem mem_filter_iff (h : IsBasis p s) {U : Set α} :
U ∈ h.filter ↔ ∃ i, p i ∧ s i ⊆ U := by
simp only [IsBasis.filter, FilterBasis.mem_filter_iff, mem_filterBasis_iff,
exists_exists_and_eq_and]
#align filter.is_basis.mem_filter_iff Filter.IsBasis.mem_filter_iff
theorem filter_eq_generate (h : IsBasis p s) : h.filter = generate { U | ∃ i, p i ∧ s i = U } := by
erw [h.filterBasis.generate]; rfl
#align filter.is_basis.filter_eq_generate Filter.IsBasis.filter_eq_generate
end IsBasis
-- Porting note: was `protected` in Lean 3 but `protected` didn't work; removed
/-- We say that a filter `l` has a basis `s : ι → Set α` bounded by `p : ι → Prop`,
if `t ∈ l` if and only if `t` includes `s i` for some `i` such that `p i`. -/
structure HasBasis (l : Filter α) (p : ι → Prop) (s : ι → Set α) : Prop where
/-- A set `t` belongs to a filter `l` iff it includes an element of the basis. -/
mem_iff' : ∀ t : Set α, t ∈ l ↔ ∃ i, p i ∧ s i ⊆ t
#align filter.has_basis Filter.HasBasis
section SameType
variable {l l' : Filter α} {p : ι → Prop} {s : ι → Set α} {t : Set α} {i : ι} {p' : ι' → Prop}
{s' : ι' → Set α} {i' : ι'}
theorem hasBasis_generate (s : Set (Set α)) :
(generate s).HasBasis (fun t => Set.Finite t ∧ t ⊆ s) fun t => ⋂₀ t :=
⟨fun U => by simp only [mem_generate_iff, exists_prop, and_assoc, and_left_comm]⟩
#align filter.has_basis_generate Filter.hasBasis_generate
/-- The smallest filter basis containing a given collection of sets. -/
def FilterBasis.ofSets (s : Set (Set α)) : FilterBasis α where
sets := sInter '' { t | Set.Finite t ∧ t ⊆ s }
nonempty := ⟨univ, ∅, ⟨⟨finite_empty, empty_subset s⟩, sInter_empty⟩⟩
inter_sets := by
rintro _ _ ⟨a, ⟨fina, suba⟩, rfl⟩ ⟨b, ⟨finb, subb⟩, rfl⟩
exact ⟨⋂₀ (a ∪ b), mem_image_of_mem _ ⟨fina.union finb, union_subset suba subb⟩,
(sInter_union _ _).subset⟩
#align filter.filter_basis.of_sets Filter.FilterBasis.ofSets
lemma FilterBasis.ofSets_sets (s : Set (Set α)) :
(FilterBasis.ofSets s).sets = sInter '' { t | Set.Finite t ∧ t ⊆ s } :=
rfl
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
/-- Definition of `HasBasis` unfolded with implicit set argument. -/
theorem HasBasis.mem_iff (hl : l.HasBasis p s) : t ∈ l ↔ ∃ i, p i ∧ s i ⊆ t :=
hl.mem_iff' t
#align filter.has_basis.mem_iff Filter.HasBasis.mem_iffₓ
theorem HasBasis.eq_of_same_basis (hl : l.HasBasis p s) (hl' : l'.HasBasis p s) : l = l' := by
ext t
rw [hl.mem_iff, hl'.mem_iff]
#align filter.has_basis.eq_of_same_basis Filter.HasBasis.eq_of_same_basis
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
theorem hasBasis_iff : l.HasBasis p s ↔ ∀ t, t ∈ l ↔ ∃ i, p i ∧ s i ⊆ t :=
⟨fun ⟨h⟩ => h, fun h => ⟨h⟩⟩
#align filter.has_basis_iff Filter.hasBasis_iffₓ
theorem HasBasis.ex_mem (h : l.HasBasis p s) : ∃ i, p i :=
(h.mem_iff.mp univ_mem).imp fun _ => And.left
#align filter.has_basis.ex_mem Filter.HasBasis.ex_mem
protected theorem HasBasis.nonempty (h : l.HasBasis p s) : Nonempty ι :=
nonempty_of_exists h.ex_mem
#align filter.has_basis.nonempty Filter.HasBasis.nonempty
protected theorem IsBasis.hasBasis (h : IsBasis p s) : HasBasis h.filter p s :=
⟨fun t => by simp only [h.mem_filter_iff, exists_prop]⟩
#align filter.is_basis.has_basis Filter.IsBasis.hasBasis
protected theorem HasBasis.mem_of_superset (hl : l.HasBasis p s) (hi : p i) (ht : s i ⊆ t) :
t ∈ l :=
hl.mem_iff.2 ⟨i, hi, ht⟩
#align filter.has_basis.mem_of_superset Filter.HasBasis.mem_of_superset
theorem HasBasis.mem_of_mem (hl : l.HasBasis p s) (hi : p i) : s i ∈ l :=
hl.mem_of_superset hi Subset.rfl
#align filter.has_basis.mem_of_mem Filter.HasBasis.mem_of_mem
/-- Index of a basis set such that `s i ⊆ t` as an element of `Subtype p`. -/
noncomputable def HasBasis.index (h : l.HasBasis p s) (t : Set α) (ht : t ∈ l) : { i : ι // p i } :=
⟨(h.mem_iff.1 ht).choose, (h.mem_iff.1 ht).choose_spec.1⟩
#align filter.has_basis.index Filter.HasBasis.index
theorem HasBasis.property_index (h : l.HasBasis p s) (ht : t ∈ l) : p (h.index t ht) :=
(h.index t ht).2
#align filter.has_basis.property_index Filter.HasBasis.property_index
theorem HasBasis.set_index_mem (h : l.HasBasis p s) (ht : t ∈ l) : s (h.index t ht) ∈ l :=
h.mem_of_mem <| h.property_index _
#align filter.has_basis.set_index_mem Filter.HasBasis.set_index_mem
theorem HasBasis.set_index_subset (h : l.HasBasis p s) (ht : t ∈ l) : s (h.index t ht) ⊆ t :=
(h.mem_iff.1 ht).choose_spec.2
#align filter.has_basis.set_index_subset Filter.HasBasis.set_index_subset
theorem HasBasis.isBasis (h : l.HasBasis p s) : IsBasis p s where
nonempty := h.ex_mem
inter hi hj := by
simpa only [h.mem_iff] using inter_mem (h.mem_of_mem hi) (h.mem_of_mem hj)
#align filter.has_basis.is_basis Filter.HasBasis.isBasis
theorem HasBasis.filter_eq (h : l.HasBasis p s) : h.isBasis.filter = l := by
ext U
simp [h.mem_iff, IsBasis.mem_filter_iff]
#align filter.has_basis.filter_eq Filter.HasBasis.filter_eq
theorem HasBasis.eq_generate (h : l.HasBasis p s) : l = generate { U | ∃ i, p i ∧ s i = U } := by
rw [← h.isBasis.filter_eq_generate, h.filter_eq]
#align filter.has_basis.eq_generate Filter.HasBasis.eq_generate
theorem generate_eq_generate_inter (s : Set (Set α)) :
generate s = generate (sInter '' { t | Set.Finite t ∧ t ⊆ s }) := by
rw [← FilterBasis.ofSets_sets, FilterBasis.generate, ← (hasBasis_generate s).filter_eq]; rfl
#align filter.generate_eq_generate_inter Filter.generate_eq_generate_inter
theorem ofSets_filter_eq_generate (s : Set (Set α)) :
(FilterBasis.ofSets s).filter = generate s := by
rw [← (FilterBasis.ofSets s).generate, FilterBasis.ofSets_sets, ← generate_eq_generate_inter]
#align filter.of_sets_filter_eq_generate Filter.ofSets_filter_eq_generate
protected theorem _root_.FilterBasis.hasBasis (B : FilterBasis α) :
HasBasis B.filter (fun s : Set α => s ∈ B) id :=
⟨fun _ => B.mem_filter_iff⟩
#align filter_basis.has_basis FilterBasis.hasBasis
theorem HasBasis.to_hasBasis' (hl : l.HasBasis p s) (h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i)
(h' : ∀ i', p' i' → s' i' ∈ l) : l.HasBasis p' s' := by
refine ⟨fun t => ⟨fun ht => ?_, fun ⟨i', hi', ht⟩ => mem_of_superset (h' i' hi') ht⟩⟩
rcases hl.mem_iff.1 ht with ⟨i, hi, ht⟩
rcases h i hi with ⟨i', hi', hs's⟩
exact ⟨i', hi', hs's.trans ht⟩
#align filter.has_basis.to_has_basis' Filter.HasBasis.to_hasBasis'
theorem HasBasis.to_hasBasis (hl : l.HasBasis p s) (h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i)
(h' : ∀ i', p' i' → ∃ i, p i ∧ s i ⊆ s' i') : l.HasBasis p' s' :=
hl.to_hasBasis' h fun i' hi' =>
let ⟨i, hi, hss'⟩ := h' i' hi'
hl.mem_iff.2 ⟨i, hi, hss'⟩
#align filter.has_basis.to_has_basis Filter.HasBasis.to_hasBasis
protected lemma HasBasis.congr (hl : l.HasBasis p s) {p' s'} (hp : ∀ i, p i ↔ p' i)
(hs : ∀ i, p i → s i = s' i) : l.HasBasis p' s' :=
⟨fun t ↦ by simp only [hl.mem_iff, ← hp]; exact exists_congr fun i ↦
and_congr_right fun hi ↦ hs i hi ▸ Iff.rfl⟩
theorem HasBasis.to_subset (hl : l.HasBasis p s) {t : ι → Set α} (h : ∀ i, p i → t i ⊆ s i)
(ht : ∀ i, p i → t i ∈ l) : l.HasBasis p t :=
hl.to_hasBasis' (fun i hi => ⟨i, hi, h i hi⟩) ht
#align filter.has_basis.to_subset Filter.HasBasis.to_subset
theorem HasBasis.eventually_iff (hl : l.HasBasis p s) {q : α → Prop} :
(∀ᶠ x in l, q x) ↔ ∃ i, p i ∧ ∀ ⦃x⦄, x ∈ s i → q x := by simpa using hl.mem_iff
#align filter.has_basis.eventually_iff Filter.HasBasis.eventually_iff
theorem HasBasis.frequently_iff (hl : l.HasBasis p s) {q : α → Prop} :
(∃ᶠ x in l, q x) ↔ ∀ i, p i → ∃ x ∈ s i, q x := by
simp only [Filter.Frequently, hl.eventually_iff]; push_neg; rfl
#align filter.has_basis.frequently_iff Filter.HasBasis.frequently_iff
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
theorem HasBasis.exists_iff (hl : l.HasBasis p s) {P : Set α → Prop}
(mono : ∀ ⦃s t⦄, s ⊆ t → P t → P s) : (∃ s ∈ l, P s) ↔ ∃ i, p i ∧ P (s i) :=
⟨fun ⟨_s, hs, hP⟩ =>
let ⟨i, hi, his⟩ := hl.mem_iff.1 hs
⟨i, hi, mono his hP⟩,
fun ⟨i, hi, hP⟩ => ⟨s i, hl.mem_of_mem hi, hP⟩⟩
#align filter.has_basis.exists_iff Filter.HasBasis.exists_iffₓ
theorem HasBasis.forall_iff (hl : l.HasBasis p s) {P : Set α → Prop}
(mono : ∀ ⦃s t⦄, s ⊆ t → P s → P t) : (∀ s ∈ l, P s) ↔ ∀ i, p i → P (s i) :=
⟨fun H i hi => H (s i) <| hl.mem_of_mem hi, fun H _s hs =>
let ⟨i, hi, his⟩ := hl.mem_iff.1 hs
mono his (H i hi)⟩
#align filter.has_basis.forall_iff Filter.HasBasis.forall_iff
protected theorem HasBasis.neBot_iff (hl : l.HasBasis p s) :
NeBot l ↔ ∀ {i}, p i → (s i).Nonempty :=
forall_mem_nonempty_iff_neBot.symm.trans <| hl.forall_iff fun _ _ => Nonempty.mono
#align filter.has_basis.ne_bot_iff Filter.HasBasis.neBot_iff
theorem HasBasis.eq_bot_iff (hl : l.HasBasis p s) : l = ⊥ ↔ ∃ i, p i ∧ s i = ∅ :=
not_iff_not.1 <| neBot_iff.symm.trans <|
hl.neBot_iff.trans <| by simp only [not_exists, not_and, nonempty_iff_ne_empty]
#align filter.has_basis.eq_bot_iff Filter.HasBasis.eq_bot_iff
theorem generate_neBot_iff {s : Set (Set α)} :
NeBot (generate s) ↔ ∀ t, t ⊆ s → t.Finite → (⋂₀ t).Nonempty :=
(hasBasis_generate s).neBot_iff.trans <| by simp only [← and_imp, and_comm]
#align filter.generate_ne_bot_iff Filter.generate_neBot_iff
theorem basis_sets (l : Filter α) : l.HasBasis (fun s : Set α => s ∈ l) id :=
⟨fun _ => exists_mem_subset_iff.symm⟩
#align filter.basis_sets Filter.basis_sets
theorem asBasis_filter (f : Filter α) : f.asBasis.filter = f :=
Filter.ext fun _ => exists_mem_subset_iff
#align filter.as_basis_filter Filter.asBasis_filter
theorem hasBasis_self {l : Filter α} {P : Set α → Prop} :
HasBasis l (fun s => s ∈ l ∧ P s) id ↔ ∀ t ∈ l, ∃ r ∈ l, P r ∧ r ⊆ t := by
simp only [hasBasis_iff, id, and_assoc]
exact forall_congr' fun s =>
⟨fun h => h.1, fun h => ⟨h, fun ⟨t, hl, _, hts⟩ => mem_of_superset hl hts⟩⟩
#align filter.has_basis_self Filter.hasBasis_self
theorem HasBasis.comp_surjective (h : l.HasBasis p s) {g : ι' → ι} (hg : Function.Surjective g) :
l.HasBasis (p ∘ g) (s ∘ g) :=
⟨fun _ => h.mem_iff.trans hg.exists⟩
#align filter.has_basis.comp_surjective Filter.HasBasis.comp_surjective
theorem HasBasis.comp_equiv (h : l.HasBasis p s) (e : ι' ≃ ι) : l.HasBasis (p ∘ e) (s ∘ e) :=
h.comp_surjective e.surjective
#align filter.has_basis.comp_equiv Filter.HasBasis.comp_equiv
theorem HasBasis.to_image_id' (h : l.HasBasis p s) : l.HasBasis (fun t ↦ ∃ i, p i ∧ s i = t) id :=
⟨fun _ ↦ by simp [h.mem_iff]⟩
theorem HasBasis.to_image_id {ι : Type*} {p : ι → Prop} {s : ι → Set α} (h : l.HasBasis p s) :
l.HasBasis (· ∈ s '' {i | p i}) id :=
h.to_image_id'
/-- If `{s i | p i}` is a basis of a filter `l` and each `s i` includes `s j` such that
`p j ∧ q j`, then `{s j | p j ∧ q j}` is a basis of `l`. -/
theorem HasBasis.restrict (h : l.HasBasis p s) {q : ι → Prop}
(hq : ∀ i, p i → ∃ j, p j ∧ q j ∧ s j ⊆ s i) : l.HasBasis (fun i => p i ∧ q i) s := by
refine ⟨fun t => ⟨fun ht => ?_, fun ⟨i, hpi, hti⟩ => h.mem_iff.2 ⟨i, hpi.1, hti⟩⟩⟩
rcases h.mem_iff.1 ht with ⟨i, hpi, hti⟩
rcases hq i hpi with ⟨j, hpj, hqj, hji⟩
exact ⟨j, ⟨hpj, hqj⟩, hji.trans hti⟩
#align filter.has_basis.restrict Filter.HasBasis.restrict
/-- If `{s i | p i}` is a basis of a filter `l` and `V ∈ l`, then `{s i | p i ∧ s i ⊆ V}`
is a basis of `l`. -/
theorem HasBasis.restrict_subset (h : l.HasBasis p s) {V : Set α} (hV : V ∈ l) :
l.HasBasis (fun i => p i ∧ s i ⊆ V) s :=
h.restrict fun _i hi => (h.mem_iff.1 (inter_mem hV (h.mem_of_mem hi))).imp fun _j hj =>
⟨hj.1, subset_inter_iff.1 hj.2⟩
#align filter.has_basis.restrict_subset Filter.HasBasis.restrict_subset
theorem HasBasis.hasBasis_self_subset {p : Set α → Prop} (h : l.HasBasis (fun s => s ∈ l ∧ p s) id)
{V : Set α} (hV : V ∈ l) : l.HasBasis (fun s => s ∈ l ∧ p s ∧ s ⊆ V) id := by
simpa only [and_assoc] using h.restrict_subset hV
#align filter.has_basis.has_basis_self_subset Filter.HasBasis.hasBasis_self_subset
theorem HasBasis.ge_iff (hl' : l'.HasBasis p' s') : l ≤ l' ↔ ∀ i', p' i' → s' i' ∈ l :=
⟨fun h _i' hi' => h <| hl'.mem_of_mem hi', fun h _s hs =>
let ⟨_i', hi', hs⟩ := hl'.mem_iff.1 hs
mem_of_superset (h _ hi') hs⟩
#align filter.has_basis.ge_iff Filter.HasBasis.ge_iff
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
theorem HasBasis.le_iff (hl : l.HasBasis p s) : l ≤ l' ↔ ∀ t ∈ l', ∃ i, p i ∧ s i ⊆ t := by
simp only [le_def, hl.mem_iff]
#align filter.has_basis.le_iff Filter.HasBasis.le_iffₓ
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
theorem HasBasis.le_basis_iff (hl : l.HasBasis p s) (hl' : l'.HasBasis p' s') :
l ≤ l' ↔ ∀ i', p' i' → ∃ i, p i ∧ s i ⊆ s' i' := by
simp only [hl'.ge_iff, hl.mem_iff]
#align filter.has_basis.le_basis_iff Filter.HasBasis.le_basis_iffₓ
-- Porting note: use `∃ i, p i ∧ _` instead of `∃ i (hi : p i), _`.
theorem HasBasis.ext (hl : l.HasBasis p s) (hl' : l'.HasBasis p' s')
(h : ∀ i, p i → ∃ i', p' i' ∧ s' i' ⊆ s i) (h' : ∀ i', p' i' → ∃ i, p i ∧ s i ⊆ s' i') :
l = l' := by
apply le_antisymm
· rw [hl.le_basis_iff hl']
simpa using h'
· rw [hl'.le_basis_iff hl]
simpa using h
#align filter.has_basis.ext Filter.HasBasis.extₓ
theorem HasBasis.inf' (hl : l.HasBasis p s) (hl' : l'.HasBasis p' s') :
(l ⊓ l').HasBasis (fun i : PProd ι ι' => p i.1 ∧ p' i.2) fun i => s i.1 ∩ s' i.2 :=
⟨by
intro t
constructor
· simp only [mem_inf_iff, hl.mem_iff, hl'.mem_iff]
rintro ⟨t, ⟨i, hi, ht⟩, t', ⟨i', hi', ht'⟩, rfl⟩
exact ⟨⟨i, i'⟩, ⟨hi, hi'⟩, inter_subset_inter ht ht'⟩
· rintro ⟨⟨i, i'⟩, ⟨hi, hi'⟩, H⟩
exact mem_inf_of_inter (hl.mem_of_mem hi) (hl'.mem_of_mem hi') H⟩
#align filter.has_basis.inf' Filter.HasBasis.inf'
theorem HasBasis.inf {ι ι' : Type*} {p : ι → Prop} {s : ι → Set α} {p' : ι' → Prop}
{s' : ι' → Set α} (hl : l.HasBasis p s) (hl' : l'.HasBasis p' s') :
(l ⊓ l').HasBasis (fun i : ι × ι' => p i.1 ∧ p' i.2) fun i => s i.1 ∩ s' i.2 :=
(hl.inf' hl').comp_equiv Equiv.pprodEquivProd.symm
#align filter.has_basis.inf Filter.HasBasis.inf
theorem hasBasis_iInf' {ι : Type*} {ι' : ι → Type*} {l : ι → Filter α} {p : ∀ i, ι' i → Prop}
{s : ∀ i, ι' i → Set α} (hl : ∀ i, (l i).HasBasis (p i) (s i)) :
(⨅ i, l i).HasBasis (fun If : Set ι × ∀ i, ι' i => If.1.Finite ∧ ∀ i ∈ If.1, p i (If.2 i))
fun If : Set ι × ∀ i, ι' i => ⋂ i ∈ If.1, s i (If.2 i) :=
⟨by
intro t
constructor
· simp only [mem_iInf', (hl _).mem_iff]
rintro ⟨I, hI, V, hV, -, rfl, -⟩
choose u hu using hV
exact ⟨⟨I, u⟩, ⟨hI, fun i _ => (hu i).1⟩, iInter₂_mono fun i _ => (hu i).2⟩
· rintro ⟨⟨I, f⟩, ⟨hI₁, hI₂⟩, hsub⟩
refine mem_of_superset ?_ hsub
exact (biInter_mem hI₁).mpr fun i hi => mem_iInf_of_mem i <| (hl i).mem_of_mem <| hI₂ _ hi⟩
#align filter.has_basis_infi' Filter.hasBasis_iInf'
theorem hasBasis_iInf {ι : Type*} {ι' : ι → Type*} {l : ι → Filter α} {p : ∀ i, ι' i → Prop}
{s : ∀ i, ι' i → Set α} (hl : ∀ i, (l i).HasBasis (p i) (s i)) :
(⨅ i, l i).HasBasis
(fun If : Σ I : Set ι, ∀ i : I, ι' i => If.1.Finite ∧ ∀ i : If.1, p i (If.2 i)) fun If =>
⋂ i : If.1, s i (If.2 i) := by
refine ⟨fun t => ⟨fun ht => ?_, ?_⟩⟩
· rcases (hasBasis_iInf' hl).mem_iff.mp ht with ⟨⟨I, f⟩, ⟨hI, hf⟩, hsub⟩
exact ⟨⟨I, fun i => f i⟩, ⟨hI, Subtype.forall.mpr hf⟩, trans (iInter_subtype _ _) hsub⟩
· rintro ⟨⟨I, f⟩, ⟨hI, hf⟩, hsub⟩
refine mem_of_superset ?_ hsub
cases hI.nonempty_fintype
exact iInter_mem.2 fun i => mem_iInf_of_mem ↑i <| (hl i).mem_of_mem <| hf _
#align filter.has_basis_infi Filter.hasBasis_iInf
| Mathlib/Order/Filter/Bases.lean | 541 | 547 | theorem hasBasis_iInf_of_directed' {ι : Type*} {ι' : ι → Sort _} [Nonempty ι] {l : ι → Filter α}
(s : ∀ i, ι' i → Set α) (p : ∀ i, ι' i → Prop) (hl : ∀ i, (l i).HasBasis (p i) (s i))
(h : Directed (· ≥ ·) l) :
(⨅ i, l i).HasBasis (fun ii' : Σi, ι' i => p ii'.1 ii'.2) fun ii' => s ii'.1 ii'.2 := by |
refine ⟨fun t => ?_⟩
rw [mem_iInf_of_directed h, Sigma.exists]
exact exists_congr fun i => (hl i).mem_iff
|
/-
Copyright (c) 2014 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.Order.Monoid.WithTop
import Mathlib.Data.Nat.Cast.Field
#align_import algebra.char_zero.lemmas from "leanprover-community/mathlib"@"acee671f47b8e7972a1eb6f4eed74b4b3abce829"
/-!
# Characteristic zero (additional theorems)
A ring `R` is called of characteristic zero if every natural number `n` is non-zero when considered
as an element of `R`. Since this definition doesn't mention the multiplicative structure of `R`
except for the existence of `1` in this file characteristic zero is defined for additive monoids
with `1`.
## Main statements
* Characteristic zero implies that the additive monoid is infinite.
-/
open Function Set
namespace Nat
variable {R : Type*} [AddMonoidWithOne R] [CharZero R]
/-- `Nat.cast` as an embedding into monoids of characteristic `0`. -/
@[simps]
def castEmbedding : ℕ ↪ R :=
⟨Nat.cast, cast_injective⟩
#align nat.cast_embedding Nat.castEmbedding
#align nat.cast_embedding_apply Nat.castEmbedding_apply
@[simp]
theorem cast_pow_eq_one {R : Type*} [Semiring R] [CharZero R] (q : ℕ) (n : ℕ) (hn : n ≠ 0) :
(q : R) ^ n = 1 ↔ q = 1 := by
rw [← cast_pow, cast_eq_one]
exact pow_eq_one_iff hn
#align nat.cast_pow_eq_one Nat.cast_pow_eq_one
@[simp, norm_cast]
theorem cast_div_charZero {k : Type*} [DivisionSemiring k] [CharZero k] {m n : ℕ} (n_dvd : n ∣ m) :
((m / n : ℕ) : k) = m / n := by
rcases eq_or_ne n 0 with (rfl | hn)
· simp
· exact cast_div n_dvd (cast_ne_zero.2 hn)
#align nat.cast_div_char_zero Nat.cast_div_charZero
end Nat
section AddMonoidWithOne
variable {α M : Type*} [AddMonoidWithOne M] [CharZero M] {n : ℕ}
instance CharZero.NeZero.two : NeZero (2 : M) :=
⟨by
have : ((2 : ℕ) : M) ≠ 0 := Nat.cast_ne_zero.2 (by decide)
rwa [Nat.cast_two] at this⟩
#align char_zero.ne_zero.two CharZero.NeZero.two
namespace Function
lemma support_natCast (hn : n ≠ 0) : support (n : α → M) = univ :=
support_const <| Nat.cast_ne_zero.2 hn
#align function.support_nat_cast Function.support_natCast
@[deprecated (since := "2024-04-17")]
alias support_nat_cast := support_natCast
lemma mulSupport_natCast (hn : n ≠ 1) : mulSupport (n : α → M) = univ :=
mulSupport_const <| Nat.cast_ne_one.2 hn
#align function.mul_support_nat_cast Function.mulSupport_natCast
@[deprecated (since := "2024-04-17")]
alias mulSupport_nat_cast := mulSupport_natCast
end Function
end AddMonoidWithOne
section
variable {R : Type*} [NonAssocSemiring R] [NoZeroDivisors R] [CharZero R] {a : R}
@[simp]
theorem add_self_eq_zero {a : R} : a + a = 0 ↔ a = 0 := by
simp only [(two_mul a).symm, mul_eq_zero, two_ne_zero, false_or_iff]
#align add_self_eq_zero add_self_eq_zero
set_option linter.deprecated false
@[simp]
theorem bit0_eq_zero {a : R} : bit0 a = 0 ↔ a = 0 :=
add_self_eq_zero
#align bit0_eq_zero bit0_eq_zero
@[simp]
theorem zero_eq_bit0 {a : R} : 0 = bit0 a ↔ a = 0 := by
rw [eq_comm]
exact bit0_eq_zero
#align zero_eq_bit0 zero_eq_bit0
theorem bit0_ne_zero : bit0 a ≠ 0 ↔ a ≠ 0 :=
bit0_eq_zero.not
#align bit0_ne_zero bit0_ne_zero
theorem zero_ne_bit0 : 0 ≠ bit0 a ↔ a ≠ 0 :=
zero_eq_bit0.not
#align zero_ne_bit0 zero_ne_bit0
end
section
variable {R : Type*} [NonAssocRing R] [NoZeroDivisors R] [CharZero R]
@[simp] theorem neg_eq_self_iff {a : R} : -a = a ↔ a = 0 :=
neg_eq_iff_add_eq_zero.trans add_self_eq_zero
#align neg_eq_self_iff neg_eq_self_iff
@[simp] theorem eq_neg_self_iff {a : R} : a = -a ↔ a = 0 :=
eq_neg_iff_add_eq_zero.trans add_self_eq_zero
#align eq_neg_self_iff eq_neg_self_iff
theorem nat_mul_inj {n : ℕ} {a b : R} (h : (n : R) * a = (n : R) * b) : n = 0 ∨ a = b := by
rw [← sub_eq_zero, ← mul_sub, mul_eq_zero, sub_eq_zero] at h
exact mod_cast h
#align nat_mul_inj nat_mul_inj
| Mathlib/Algebra/CharZero/Lemmas.lean | 132 | 133 | theorem nat_mul_inj' {n : ℕ} {a b : R} (h : (n : R) * a = (n : R) * b) (w : n ≠ 0) : a = b := by |
simpa [w] using nat_mul_inj h
|
/-
Copyright (c) 2023 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.LinearAlgebra.Matrix.Gershgorin
import Mathlib.NumberTheory.NumberField.CanonicalEmbedding.ConvexBody
import Mathlib.NumberTheory.NumberField.Units.Basic
import Mathlib.RingTheory.RootsOfUnity.Basic
#align_import number_theory.number_field.units from "leanprover-community/mathlib"@"00f91228655eecdcd3ac97a7fd8dbcb139fe990a"
/-!
# Dirichlet theorem on the group of units of a number field
This file is devoted to the proof of Dirichlet unit theorem that states that the group of
units `(𝓞 K)ˣ` of units of the ring of integers `𝓞 K` of a number field `K` modulo its torsion
subgroup is a free `ℤ`-module of rank `card (InfinitePlace K) - 1`.
## Main definitions
* `NumberField.Units.rank`: the unit rank of the number field `K`.
* `NumberField.Units.fundSystem`: a fundamental system of units of `K`.
* `NumberField.Units.basisModTorsion`: a `ℤ`-basis of `(𝓞 K)ˣ ⧸ (torsion K)`
as an additive `ℤ`-module.
## Main results
* `NumberField.Units.rank_modTorsion`: the `ℤ`-rank of `(𝓞 K)ˣ ⧸ (torsion K)` is equal to
`card (InfinitePlace K) - 1`.
* `NumberField.Units.exist_unique_eq_mul_prod`: **Dirichlet Unit Theorem**. Any unit of `𝓞 K`
can be written uniquely as the product of a root of unity and powers of the units of the
fundamental system `fundSystem`.
## Tags
number field, units, Dirichlet unit theorem
-/
open scoped NumberField
noncomputable section
open NumberField NumberField.InfinitePlace NumberField.Units BigOperators
variable (K : Type*) [Field K] [NumberField K]
namespace NumberField.Units.dirichletUnitTheorem
/-!
### Dirichlet Unit Theorem
We define a group morphism from `(𝓞 K)ˣ` to `{w : InfinitePlace K // w ≠ w₀} → ℝ` where `w₀` is a
distinguished (arbitrary) infinite place, prove that its kernel is the torsion subgroup (see
`logEmbedding_eq_zero_iff`) and that its image, called `unitLattice`, is a full `ℤ`-lattice. It
follows that `unitLattice` is a free `ℤ`-module (see `instModuleFree_unitLattice`) of rank
`card (InfinitePlaces K) - 1` (see `unitLattice_rank`). To prove that the `unitLattice` is a full
`ℤ`-lattice, we need to prove that it is discrete (see `unitLattice_inter_ball_finite`) and that it
spans the full space over `ℝ` (see `unitLattice_span_eq_top`); this is the main part of the proof,
see the section `span_top` below for more details.
-/
open scoped Classical
open Finset
variable {K}
/-- The distinguished infinite place. -/
def w₀ : InfinitePlace K := (inferInstance : Nonempty (InfinitePlace K)).some
variable (K)
/-- The logarithmic embedding of the units (seen as an `Additive` group). -/
def logEmbedding : Additive ((𝓞 K)ˣ) →+ ({w : InfinitePlace K // w ≠ w₀} → ℝ) :=
{ toFun := fun x w => mult w.val * Real.log (w.val ↑(Additive.toMul x))
map_zero' := by simp; rfl
map_add' := fun _ _ => by simp [Real.log_mul, mul_add]; rfl }
variable {K}
@[simp]
theorem logEmbedding_component (x : (𝓞 K)ˣ) (w : {w : InfinitePlace K // w ≠ w₀}) :
(logEmbedding K x) w = mult w.val * Real.log (w.val x) := rfl
theorem sum_logEmbedding_component (x : (𝓞 K)ˣ) :
∑ w, logEmbedding K x w = - mult (w₀ : InfinitePlace K) * Real.log (w₀ (x : K)) := by
have h := congr_arg Real.log (prod_eq_abs_norm (x : K))
rw [show |(Algebra.norm ℚ) (x : K)| = 1 from isUnit_iff_norm.mp x.isUnit, Rat.cast_one,
Real.log_one, Real.log_prod] at h
· simp_rw [Real.log_pow] at h
rw [← insert_erase (mem_univ w₀), sum_insert (not_mem_erase w₀ univ), add_comm,
add_eq_zero_iff_eq_neg] at h
convert h using 1
· refine (sum_subtype _ (fun w => ?_) (fun w => (mult w) * (Real.log (w (x : K))))).symm
exact ⟨ne_of_mem_erase, fun h => mem_erase_of_ne_of_mem h (mem_univ w)⟩
· norm_num
· exact fun w _ => pow_ne_zero _ (AbsoluteValue.ne_zero _ (coe_ne_zero x))
theorem mult_log_place_eq_zero {x : (𝓞 K)ˣ} {w : InfinitePlace K} :
mult w * Real.log (w x) = 0 ↔ w x = 1 := by
rw [mul_eq_zero, or_iff_right, Real.log_eq_zero, or_iff_right, or_iff_left]
· linarith [(apply_nonneg _ _ : 0 ≤ w x)]
· simp only [ne_eq, map_eq_zero, coe_ne_zero x, not_false_eq_true]
· refine (ne_of_gt ?_)
rw [mult]; split_ifs <;> norm_num
theorem logEmbedding_eq_zero_iff {x : (𝓞 K)ˣ} :
logEmbedding K x = 0 ↔ x ∈ torsion K := by
rw [mem_torsion]
refine ⟨fun h w => ?_, fun h => ?_⟩
· by_cases hw : w = w₀
· suffices -mult w₀ * Real.log (w₀ (x : K)) = 0 by
rw [neg_mul, neg_eq_zero, ← hw] at this
exact mult_log_place_eq_zero.mp this
rw [← sum_logEmbedding_component, sum_eq_zero]
exact fun w _ => congrFun h w
· exact mult_log_place_eq_zero.mp (congrFun h ⟨w, hw⟩)
· ext w
rw [logEmbedding_component, h w.val, Real.log_one, mul_zero, Pi.zero_apply]
theorem logEmbedding_component_le {r : ℝ} {x : (𝓞 K)ˣ} (hr : 0 ≤ r) (h : ‖logEmbedding K x‖ ≤ r)
(w : {w : InfinitePlace K // w ≠ w₀}) : |logEmbedding K x w| ≤ r := by
lift r to NNReal using hr
simp_rw [Pi.norm_def, NNReal.coe_le_coe, Finset.sup_le_iff, ← NNReal.coe_le_coe] at h
exact h w (mem_univ _)
| Mathlib/NumberTheory/NumberField/Units/DirichletTheorem.lean | 128 | 151 | theorem log_le_of_logEmbedding_le {r : ℝ} {x : (𝓞 K)ˣ} (hr : 0 ≤ r) (h : ‖logEmbedding K x‖ ≤ r)
(w : InfinitePlace K) : |Real.log (w x)| ≤ (Fintype.card (InfinitePlace K)) * r := by |
have tool : ∀ x : ℝ, 0 ≤ x → x ≤ mult w * x := fun x hx => by
nth_rw 1 [← one_mul x]
refine mul_le_mul ?_ le_rfl hx ?_
all_goals { rw [mult]; split_ifs <;> norm_num }
by_cases hw : w = w₀
· have hyp := congr_arg (‖·‖) (sum_logEmbedding_component x).symm
replace hyp := (le_of_eq hyp).trans (norm_sum_le _ _)
simp_rw [norm_mul, norm_neg, Real.norm_eq_abs, Nat.abs_cast] at hyp
refine (le_trans ?_ hyp).trans ?_
· rw [← hw]
exact tool _ (abs_nonneg _)
· refine (sum_le_card_nsmul univ _ _
(fun w _ => logEmbedding_component_le hr h w)).trans ?_
rw [nsmul_eq_mul]
refine mul_le_mul ?_ le_rfl hr (Fintype.card (InfinitePlace K)).cast_nonneg
simp [card_univ]
· have hyp := logEmbedding_component_le hr h ⟨w, hw⟩
rw [logEmbedding_component, abs_mul, Nat.abs_cast] at hyp
refine (le_trans ?_ hyp).trans ?_
· exact tool _ (abs_nonneg _)
· nth_rw 1 [← one_mul r]
exact mul_le_mul (Nat.one_le_cast.mpr Fintype.card_pos) (le_of_eq rfl) hr (Nat.cast_nonneg _)
|
/-
Copyright (c) 2019 Anne Baanen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Anne Baanen, Lu-Ming Zhang
-/
import Mathlib.Data.Matrix.Invertible
import Mathlib.LinearAlgebra.Matrix.Adjugate
import Mathlib.LinearAlgebra.FiniteDimensional
#align_import linear_algebra.matrix.nonsingular_inverse from "leanprover-community/mathlib"@"722b3b152ddd5e0cf21c0a29787c76596cb6b422"
/-!
# Nonsingular inverses
In this file, we define an inverse for square matrices of invertible determinant.
For matrices that are not square or not of full rank, there is a more general notion of
pseudoinverses which we do not consider here.
The definition of inverse used in this file is the adjugate divided by the determinant.
We show that dividing the adjugate by `det A` (if possible), giving a matrix `A⁻¹` (`nonsing_inv`),
will result in a multiplicative inverse to `A`.
Note that there are at least three different inverses in mathlib:
* `A⁻¹` (`Inv.inv`): alone, this satisfies no properties, although it is usually used in
conjunction with `Group` or `GroupWithZero`. On matrices, this is defined to be zero when no
inverse exists.
* `⅟A` (`invOf`): this is only available in the presence of `[Invertible A]`, which guarantees an
inverse exists.
* `Ring.inverse A`: this is defined on any `MonoidWithZero`, and just like `⁻¹` on matrices, is
defined to be zero when no inverse exists.
We start by working with `Invertible`, and show the main results:
* `Matrix.invertibleOfDetInvertible`
* `Matrix.detInvertibleOfInvertible`
* `Matrix.isUnit_iff_isUnit_det`
* `Matrix.mul_eq_one_comm`
After this we define `Matrix.inv` and show it matches `⅟A` and `Ring.inverse A`.
The rest of the results in the file are then about `A⁻¹`
## References
* https://en.wikipedia.org/wiki/Cramer's_rule#Finding_inverse_matrix
## Tags
matrix inverse, cramer, cramer's rule, adjugate
-/
namespace Matrix
universe u u' v
variable {l : Type*} {m : Type u} {n : Type u'} {α : Type v}
open Matrix Equiv Equiv.Perm Finset
/-! ### Matrices are `Invertible` iff their determinants are -/
section Invertible
variable [Fintype n] [DecidableEq n] [CommRing α]
variable (A : Matrix n n α) (B : Matrix n n α)
/-- If `A.det` has a constructive inverse, produce one for `A`. -/
def invertibleOfDetInvertible [Invertible A.det] : Invertible A where
invOf := ⅟ A.det • A.adjugate
mul_invOf_self := by
rw [mul_smul_comm, mul_adjugate, smul_smul, invOf_mul_self, one_smul]
invOf_mul_self := by
rw [smul_mul_assoc, adjugate_mul, smul_smul, invOf_mul_self, one_smul]
#align matrix.invertible_of_det_invertible Matrix.invertibleOfDetInvertible
theorem invOf_eq [Invertible A.det] [Invertible A] : ⅟ A = ⅟ A.det • A.adjugate := by
letI := invertibleOfDetInvertible A
convert (rfl : ⅟ A = _)
#align matrix.inv_of_eq Matrix.invOf_eq
/-- `A.det` is invertible if `A` has a left inverse. -/
def detInvertibleOfLeftInverse (h : B * A = 1) : Invertible A.det where
invOf := B.det
mul_invOf_self := by rw [mul_comm, ← det_mul, h, det_one]
invOf_mul_self := by rw [← det_mul, h, det_one]
#align matrix.det_invertible_of_left_inverse Matrix.detInvertibleOfLeftInverse
/-- `A.det` is invertible if `A` has a right inverse. -/
def detInvertibleOfRightInverse (h : A * B = 1) : Invertible A.det where
invOf := B.det
mul_invOf_self := by rw [← det_mul, h, det_one]
invOf_mul_self := by rw [mul_comm, ← det_mul, h, det_one]
#align matrix.det_invertible_of_right_inverse Matrix.detInvertibleOfRightInverse
/-- If `A` has a constructive inverse, produce one for `A.det`. -/
def detInvertibleOfInvertible [Invertible A] : Invertible A.det :=
detInvertibleOfLeftInverse A (⅟ A) (invOf_mul_self _)
#align matrix.det_invertible_of_invertible Matrix.detInvertibleOfInvertible
theorem det_invOf [Invertible A] [Invertible A.det] : (⅟ A).det = ⅟ A.det := by
letI := detInvertibleOfInvertible A
convert (rfl : _ = ⅟ A.det)
#align matrix.det_inv_of Matrix.det_invOf
/-- Together `Matrix.detInvertibleOfInvertible` and `Matrix.invertibleOfDetInvertible` form an
equivalence, although both sides of the equiv are subsingleton anyway. -/
@[simps]
def invertibleEquivDetInvertible : Invertible A ≃ Invertible A.det where
toFun := @detInvertibleOfInvertible _ _ _ _ _ A
invFun := @invertibleOfDetInvertible _ _ _ _ _ A
left_inv _ := Subsingleton.elim _ _
right_inv _ := Subsingleton.elim _ _
#align matrix.invertible_equiv_det_invertible Matrix.invertibleEquivDetInvertible
variable {A B}
theorem mul_eq_one_comm : A * B = 1 ↔ B * A = 1 :=
suffices ∀ A B : Matrix n n α, A * B = 1 → B * A = 1 from ⟨this A B, this B A⟩
fun A B h => by
letI : Invertible B.det := detInvertibleOfLeftInverse _ _ h
letI : Invertible B := invertibleOfDetInvertible B
calc
B * A = B * A * (B * ⅟ B) := by rw [mul_invOf_self, Matrix.mul_one]
_ = B * (A * B * ⅟ B) := by simp only [Matrix.mul_assoc]
_ = B * ⅟ B := by rw [h, Matrix.one_mul]
_ = 1 := mul_invOf_self B
#align matrix.mul_eq_one_comm Matrix.mul_eq_one_comm
variable (A B)
/-- We can construct an instance of invertible A if A has a left inverse. -/
def invertibleOfLeftInverse (h : B * A = 1) : Invertible A :=
⟨B, h, mul_eq_one_comm.mp h⟩
#align matrix.invertible_of_left_inverse Matrix.invertibleOfLeftInverse
/-- We can construct an instance of invertible A if A has a right inverse. -/
def invertibleOfRightInverse (h : A * B = 1) : Invertible A :=
⟨B, mul_eq_one_comm.mp h, h⟩
#align matrix.invertible_of_right_inverse Matrix.invertibleOfRightInverse
/-- Given a proof that `A.det` has a constructive inverse, lift `A` to `(Matrix n n α)ˣ`-/
def unitOfDetInvertible [Invertible A.det] : (Matrix n n α)ˣ :=
@unitOfInvertible _ _ A (invertibleOfDetInvertible A)
#align matrix.unit_of_det_invertible Matrix.unitOfDetInvertible
/-- When lowered to a prop, `Matrix.invertibleEquivDetInvertible` forms an `iff`. -/
theorem isUnit_iff_isUnit_det : IsUnit A ↔ IsUnit A.det := by
simp only [← nonempty_invertible_iff_isUnit, (invertibleEquivDetInvertible A).nonempty_congr]
#align matrix.is_unit_iff_is_unit_det Matrix.isUnit_iff_isUnit_det
@[simp]
theorem isUnits_det_units (A : (Matrix n n α)ˣ) : IsUnit (A : Matrix n n α).det :=
isUnit_iff_isUnit_det _ |>.mp A.isUnit
/-! #### Variants of the statements above with `IsUnit`-/
theorem isUnit_det_of_invertible [Invertible A] : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfInvertible A)
#align matrix.is_unit_det_of_invertible Matrix.isUnit_det_of_invertible
variable {A B}
theorem isUnit_of_left_inverse (h : B * A = 1) : IsUnit A :=
⟨⟨A, B, mul_eq_one_comm.mp h, h⟩, rfl⟩
#align matrix.is_unit_of_left_inverse Matrix.isUnit_of_left_inverse
theorem exists_left_inverse_iff_isUnit : (∃ B, B * A = 1) ↔ IsUnit A :=
⟨fun ⟨_, h⟩ ↦ isUnit_of_left_inverse h, fun h ↦ have := h.invertible; ⟨⅟A, invOf_mul_self' A⟩⟩
theorem isUnit_of_right_inverse (h : A * B = 1) : IsUnit A :=
⟨⟨A, B, h, mul_eq_one_comm.mp h⟩, rfl⟩
#align matrix.is_unit_of_right_inverse Matrix.isUnit_of_right_inverse
theorem exists_right_inverse_iff_isUnit : (∃ B, A * B = 1) ↔ IsUnit A :=
⟨fun ⟨_, h⟩ ↦ isUnit_of_right_inverse h, fun h ↦ have := h.invertible; ⟨⅟A, mul_invOf_self' A⟩⟩
theorem isUnit_det_of_left_inverse (h : B * A = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfLeftInverse _ _ h)
#align matrix.is_unit_det_of_left_inverse Matrix.isUnit_det_of_left_inverse
theorem isUnit_det_of_right_inverse (h : A * B = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfRightInverse _ _ h)
#align matrix.is_unit_det_of_right_inverse Matrix.isUnit_det_of_right_inverse
theorem det_ne_zero_of_left_inverse [Nontrivial α] (h : B * A = 1) : A.det ≠ 0 :=
(isUnit_det_of_left_inverse h).ne_zero
#align matrix.det_ne_zero_of_left_inverse Matrix.det_ne_zero_of_left_inverse
theorem det_ne_zero_of_right_inverse [Nontrivial α] (h : A * B = 1) : A.det ≠ 0 :=
(isUnit_det_of_right_inverse h).ne_zero
#align matrix.det_ne_zero_of_right_inverse Matrix.det_ne_zero_of_right_inverse
end Invertible
section Inv
variable [Fintype n] [DecidableEq n] [CommRing α]
variable (A : Matrix n n α) (B : Matrix n n α)
theorem isUnit_det_transpose (h : IsUnit A.det) : IsUnit Aᵀ.det := by
rw [det_transpose]
exact h
#align matrix.is_unit_det_transpose Matrix.isUnit_det_transpose
/-! ### A noncomputable `Inv` instance -/
/-- The inverse of a square matrix, when it is invertible (and zero otherwise). -/
noncomputable instance inv : Inv (Matrix n n α) :=
⟨fun A => Ring.inverse A.det • A.adjugate⟩
theorem inv_def (A : Matrix n n α) : A⁻¹ = Ring.inverse A.det • A.adjugate :=
rfl
#align matrix.inv_def Matrix.inv_def
theorem nonsing_inv_apply_not_isUnit (h : ¬IsUnit A.det) : A⁻¹ = 0 := by
rw [inv_def, Ring.inverse_non_unit _ h, zero_smul]
#align matrix.nonsing_inv_apply_not_is_unit Matrix.nonsing_inv_apply_not_isUnit
theorem nonsing_inv_apply (h : IsUnit A.det) : A⁻¹ = (↑h.unit⁻¹ : α) • A.adjugate := by
rw [inv_def, ← Ring.inverse_unit h.unit, IsUnit.unit_spec]
#align matrix.nonsing_inv_apply Matrix.nonsing_inv_apply
/-- The nonsingular inverse is the same as `invOf` when `A` is invertible. -/
@[simp]
theorem invOf_eq_nonsing_inv [Invertible A] : ⅟ A = A⁻¹ := by
letI := detInvertibleOfInvertible A
rw [inv_def, Ring.inverse_invertible, invOf_eq]
#align matrix.inv_of_eq_nonsing_inv Matrix.invOf_eq_nonsing_inv
/-- Coercing the result of `Units.instInv` is the same as coercing first and applying the
nonsingular inverse. -/
@[simp, norm_cast]
theorem coe_units_inv (A : (Matrix n n α)ˣ) : ↑A⁻¹ = (A⁻¹ : Matrix n n α) := by
letI := A.invertible
rw [← invOf_eq_nonsing_inv, invOf_units]
#align matrix.coe_units_inv Matrix.coe_units_inv
/-- The nonsingular inverse is the same as the general `Ring.inverse`. -/
theorem nonsing_inv_eq_ring_inverse : A⁻¹ = Ring.inverse A := by
by_cases h_det : IsUnit A.det
· cases (A.isUnit_iff_isUnit_det.mpr h_det).nonempty_invertible
rw [← invOf_eq_nonsing_inv, Ring.inverse_invertible]
· have h := mt A.isUnit_iff_isUnit_det.mp h_det
rw [Ring.inverse_non_unit _ h, nonsing_inv_apply_not_isUnit A h_det]
#align matrix.nonsing_inv_eq_ring_inverse Matrix.nonsing_inv_eq_ring_inverse
theorem transpose_nonsing_inv : A⁻¹ᵀ = Aᵀ⁻¹ := by
rw [inv_def, inv_def, transpose_smul, det_transpose, adjugate_transpose]
#align matrix.transpose_nonsing_inv Matrix.transpose_nonsing_inv
theorem conjTranspose_nonsing_inv [StarRing α] : A⁻¹ᴴ = Aᴴ⁻¹ := by
rw [inv_def, inv_def, conjTranspose_smul, det_conjTranspose, adjugate_conjTranspose,
Ring.inverse_star]
#align matrix.conj_transpose_nonsing_inv Matrix.conjTranspose_nonsing_inv
/-- The `nonsing_inv` of `A` is a right inverse. -/
@[simp]
theorem mul_nonsing_inv (h : IsUnit A.det) : A * A⁻¹ = 1 := by
cases (A.isUnit_iff_isUnit_det.mpr h).nonempty_invertible
rw [← invOf_eq_nonsing_inv, mul_invOf_self]
#align matrix.mul_nonsing_inv Matrix.mul_nonsing_inv
/-- The `nonsing_inv` of `A` is a left inverse. -/
@[simp]
theorem nonsing_inv_mul (h : IsUnit A.det) : A⁻¹ * A = 1 := by
cases (A.isUnit_iff_isUnit_det.mpr h).nonempty_invertible
rw [← invOf_eq_nonsing_inv, invOf_mul_self]
#align matrix.nonsing_inv_mul Matrix.nonsing_inv_mul
instance [Invertible A] : Invertible A⁻¹ := by
rw [← invOf_eq_nonsing_inv]
infer_instance
@[simp]
theorem inv_inv_of_invertible [Invertible A] : A⁻¹⁻¹ = A := by
simp only [← invOf_eq_nonsing_inv, invOf_invOf]
#align matrix.inv_inv_of_invertible Matrix.inv_inv_of_invertible
@[simp]
theorem mul_nonsing_inv_cancel_right (B : Matrix m n α) (h : IsUnit A.det) : B * A * A⁻¹ = B := by
simp [Matrix.mul_assoc, mul_nonsing_inv A h]
#align matrix.mul_nonsing_inv_cancel_right Matrix.mul_nonsing_inv_cancel_right
@[simp]
theorem mul_nonsing_inv_cancel_left (B : Matrix n m α) (h : IsUnit A.det) : A * (A⁻¹ * B) = B := by
simp [← Matrix.mul_assoc, mul_nonsing_inv A h]
#align matrix.mul_nonsing_inv_cancel_left Matrix.mul_nonsing_inv_cancel_left
@[simp]
| Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean | 296 | 297 | theorem nonsing_inv_mul_cancel_right (B : Matrix m n α) (h : IsUnit A.det) : B * A⁻¹ * A = B := by |
simp [Matrix.mul_assoc, nonsing_inv_mul A h]
|
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.Data.Fintype.Basic
import Mathlib.Data.Finset.Card
import Mathlib.Data.List.NodupEquivFin
import Mathlib.Data.Set.Image
#align_import data.fintype.card from "leanprover-community/mathlib"@"bf2428c9486c407ca38b5b3fb10b87dad0bc99fa"
/-!
# Cardinalities of finite types
## Main declarations
* `Fintype.card α`: Cardinality of a fintype. Equal to `Finset.univ.card`.
* `Fintype.truncEquivFin`: A fintype `α` is computably equivalent to `Fin (card α)`. The
`Trunc`-free, noncomputable version is `Fintype.equivFin`.
* `Fintype.truncEquivOfCardEq` `Fintype.equivOfCardEq`: Two fintypes of same cardinality are
equivalent. See above.
* `Fin.equiv_iff_eq`: `Fin m ≃ Fin n` iff `m = n`.
* `Infinite.natEmbedding`: An embedding of `ℕ` into an infinite type.
We also provide the following versions of the pigeonholes principle.
* `Fintype.exists_ne_map_eq_of_card_lt` and `isEmpty_of_card_lt`: Finitely many pigeons and
pigeonholes. Weak formulation.
* `Finite.exists_ne_map_eq_of_infinite`: Infinitely many pigeons in finitely many pigeonholes.
Weak formulation.
* `Finite.exists_infinite_fiber`: Infinitely many pigeons in finitely many pigeonholes. Strong
formulation.
Some more pigeonhole-like statements can be found in `Data.Fintype.CardEmbedding`.
Types which have an injection from/a surjection to an `Infinite` type are themselves `Infinite`.
See `Infinite.of_injective` and `Infinite.of_surjective`.
## Instances
We provide `Infinite` instances for
* specific types: `ℕ`, `ℤ`, `String`
* type constructors: `Multiset α`, `List α`
-/
assert_not_exists MonoidWithZero
assert_not_exists MulAction
open Function
open Nat
universe u v
variable {α β γ : Type*}
open Finset Function
namespace Fintype
/-- `card α` is the number of elements in `α`, defined when `α` is a fintype. -/
def card (α) [Fintype α] : ℕ :=
(@univ α _).card
#align fintype.card Fintype.card
/-- There is (computably) an equivalence between `α` and `Fin (card α)`.
Since it is not unique and depends on which permutation
of the universe list is used, the equivalence is wrapped in `Trunc` to
preserve computability.
See `Fintype.equivFin` for the noncomputable version,
and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq`
for an equiv `α ≃ Fin n` given `Fintype.card α = n`.
See `Fintype.truncFinBijection` for a version without `[DecidableEq α]`.
-/
def truncEquivFin (α) [DecidableEq α] [Fintype α] : Trunc (α ≃ Fin (card α)) := by
unfold card Finset.card
exact
Quot.recOnSubsingleton'
(motive := fun s : Multiset α =>
(∀ x : α, x ∈ s) → s.Nodup → Trunc (α ≃ Fin (Multiset.card s)))
univ.val
(fun l (h : ∀ x : α, x ∈ l) (nd : l.Nodup) => Trunc.mk (nd.getEquivOfForallMemList _ h).symm)
mem_univ_val univ.2
#align fintype.trunc_equiv_fin Fintype.truncEquivFin
/-- There is (noncomputably) an equivalence between `α` and `Fin (card α)`.
See `Fintype.truncEquivFin` for the computable version,
and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq`
for an equiv `α ≃ Fin n` given `Fintype.card α = n`.
-/
noncomputable def equivFin (α) [Fintype α] : α ≃ Fin (card α) :=
letI := Classical.decEq α
(truncEquivFin α).out
#align fintype.equiv_fin Fintype.equivFin
/-- There is (computably) a bijection between `Fin (card α)` and `α`.
Since it is not unique and depends on which permutation
of the universe list is used, the bijection is wrapped in `Trunc` to
preserve computability.
See `Fintype.truncEquivFin` for a version that gives an equivalence
given `[DecidableEq α]`.
-/
def truncFinBijection (α) [Fintype α] : Trunc { f : Fin (card α) → α // Bijective f } := by
unfold card Finset.card
refine
Quot.recOnSubsingleton'
(motive := fun s : Multiset α =>
(∀ x : α, x ∈ s) → s.Nodup → Trunc {f : Fin (Multiset.card s) → α // Bijective f})
univ.val
(fun l (h : ∀ x : α, x ∈ l) (nd : l.Nodup) => Trunc.mk (nd.getBijectionOfForallMemList _ h))
mem_univ_val univ.2
#align fintype.trunc_fin_bijection Fintype.truncFinBijection
theorem subtype_card {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x) :
@card { x // p x } (Fintype.subtype s H) = s.card :=
Multiset.card_pmap _ _ _
#align fintype.subtype_card Fintype.subtype_card
theorem card_of_subtype {p : α → Prop} (s : Finset α) (H : ∀ x : α, x ∈ s ↔ p x)
[Fintype { x // p x }] : card { x // p x } = s.card := by
rw [← subtype_card s H]
congr
apply Subsingleton.elim
#align fintype.card_of_subtype Fintype.card_of_subtype
@[simp]
theorem card_ofFinset {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) :
@Fintype.card p (ofFinset s H) = s.card :=
Fintype.subtype_card s H
#align fintype.card_of_finset Fintype.card_ofFinset
theorem card_of_finset' {p : Set α} (s : Finset α) (H : ∀ x, x ∈ s ↔ x ∈ p) [Fintype p] :
Fintype.card p = s.card := by rw [← card_ofFinset s H]; congr; apply Subsingleton.elim
#align fintype.card_of_finset' Fintype.card_of_finset'
end Fintype
namespace Fintype
theorem ofEquiv_card [Fintype α] (f : α ≃ β) : @card β (ofEquiv α f) = card α :=
Multiset.card_map _ _
#align fintype.of_equiv_card Fintype.ofEquiv_card
theorem card_congr {α β} [Fintype α] [Fintype β] (f : α ≃ β) : card α = card β := by
rw [← ofEquiv_card f]; congr; apply Subsingleton.elim
#align fintype.card_congr Fintype.card_congr
@[congr]
theorem card_congr' {α β} [Fintype α] [Fintype β] (h : α = β) : card α = card β :=
card_congr (by rw [h])
#align fintype.card_congr' Fintype.card_congr'
section
variable [Fintype α] [Fintype β]
/-- If the cardinality of `α` is `n`, there is computably a bijection between `α` and `Fin n`.
See `Fintype.equivFinOfCardEq` for the noncomputable definition,
and `Fintype.truncEquivFin` and `Fintype.equivFin` for the bijection `α ≃ Fin (card α)`.
-/
def truncEquivFinOfCardEq [DecidableEq α] {n : ℕ} (h : Fintype.card α = n) : Trunc (α ≃ Fin n) :=
(truncEquivFin α).map fun e => e.trans (finCongr h)
#align fintype.trunc_equiv_fin_of_card_eq Fintype.truncEquivFinOfCardEq
/-- If the cardinality of `α` is `n`, there is noncomputably a bijection between `α` and `Fin n`.
See `Fintype.truncEquivFinOfCardEq` for the computable definition,
and `Fintype.truncEquivFin` and `Fintype.equivFin` for the bijection `α ≃ Fin (card α)`.
-/
noncomputable def equivFinOfCardEq {n : ℕ} (h : Fintype.card α = n) : α ≃ Fin n :=
letI := Classical.decEq α
(truncEquivFinOfCardEq h).out
#align fintype.equiv_fin_of_card_eq Fintype.equivFinOfCardEq
/-- Two `Fintype`s with the same cardinality are (computably) in bijection.
See `Fintype.equivOfCardEq` for the noncomputable version,
and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for
the specialization to `Fin`.
-/
def truncEquivOfCardEq [DecidableEq α] [DecidableEq β] (h : card α = card β) : Trunc (α ≃ β) :=
(truncEquivFinOfCardEq h).bind fun e => (truncEquivFin β).map fun e' => e.trans e'.symm
#align fintype.trunc_equiv_of_card_eq Fintype.truncEquivOfCardEq
/-- Two `Fintype`s with the same cardinality are (noncomputably) in bijection.
See `Fintype.truncEquivOfCardEq` for the computable version,
and `Fintype.truncEquivFinOfCardEq` and `Fintype.equivFinOfCardEq` for
the specialization to `Fin`.
-/
noncomputable def equivOfCardEq (h : card α = card β) : α ≃ β := by
letI := Classical.decEq α
letI := Classical.decEq β
exact (truncEquivOfCardEq h).out
#align fintype.equiv_of_card_eq Fintype.equivOfCardEq
end
theorem card_eq {α β} [_F : Fintype α] [_G : Fintype β] : card α = card β ↔ Nonempty (α ≃ β) :=
⟨fun h =>
haveI := Classical.propDecidable
(truncEquivOfCardEq h).nonempty,
fun ⟨f⟩ => card_congr f⟩
#align fintype.card_eq Fintype.card_eq
/-- Note: this lemma is specifically about `Fintype.ofSubsingleton`. For a statement about
arbitrary `Fintype` instances, use either `Fintype.card_le_one_iff_subsingleton` or
`Fintype.card_unique`. -/
@[simp]
theorem card_ofSubsingleton (a : α) [Subsingleton α] : @Fintype.card _ (ofSubsingleton a) = 1 :=
rfl
#align fintype.card_of_subsingleton Fintype.card_ofSubsingleton
@[simp]
theorem card_unique [Unique α] [h : Fintype α] : Fintype.card α = 1 :=
Subsingleton.elim (ofSubsingleton default) h ▸ card_ofSubsingleton _
#align fintype.card_unique Fintype.card_unique
/-- Note: this lemma is specifically about `Fintype.ofIsEmpty`. For a statement about
arbitrary `Fintype` instances, use `Fintype.card_eq_zero`. -/
@[simp]
theorem card_ofIsEmpty [IsEmpty α] : @Fintype.card α Fintype.ofIsEmpty = 0 :=
rfl
#align fintype.card_of_is_empty Fintype.card_ofIsEmpty
end Fintype
namespace Set
variable {s t : Set α}
-- We use an arbitrary `[Fintype s]` instance here,
-- not necessarily coming from a `[Fintype α]`.
@[simp]
theorem toFinset_card {α : Type*} (s : Set α) [Fintype s] : s.toFinset.card = Fintype.card s :=
Multiset.card_map Subtype.val Finset.univ.val
#align set.to_finset_card Set.toFinset_card
end Set
@[simp]
theorem Finset.card_univ [Fintype α] : (Finset.univ : Finset α).card = Fintype.card α :=
rfl
#align finset.card_univ Finset.card_univ
theorem Finset.eq_univ_of_card [Fintype α] (s : Finset α) (hs : s.card = Fintype.card α) :
s = univ :=
eq_of_subset_of_card_le (subset_univ _) <| by rw [hs, Finset.card_univ]
#align finset.eq_univ_of_card Finset.eq_univ_of_card
theorem Finset.card_eq_iff_eq_univ [Fintype α] (s : Finset α) :
s.card = Fintype.card α ↔ s = Finset.univ :=
⟨s.eq_univ_of_card, by
rintro rfl
exact Finset.card_univ⟩
#align finset.card_eq_iff_eq_univ Finset.card_eq_iff_eq_univ
theorem Finset.card_le_univ [Fintype α] (s : Finset α) : s.card ≤ Fintype.card α :=
card_le_card (subset_univ s)
#align finset.card_le_univ Finset.card_le_univ
theorem Finset.card_lt_univ_of_not_mem [Fintype α] {s : Finset α} {x : α} (hx : x ∉ s) :
s.card < Fintype.card α :=
card_lt_card ⟨subset_univ s, not_forall.2 ⟨x, fun hx' => hx (hx' <| mem_univ x)⟩⟩
#align finset.card_lt_univ_of_not_mem Finset.card_lt_univ_of_not_mem
theorem Finset.card_lt_iff_ne_univ [Fintype α] (s : Finset α) :
s.card < Fintype.card α ↔ s ≠ Finset.univ :=
s.card_le_univ.lt_iff_ne.trans (not_congr s.card_eq_iff_eq_univ)
#align finset.card_lt_iff_ne_univ Finset.card_lt_iff_ne_univ
theorem Finset.card_compl_lt_iff_nonempty [Fintype α] [DecidableEq α] (s : Finset α) :
sᶜ.card < Fintype.card α ↔ s.Nonempty :=
sᶜ.card_lt_iff_ne_univ.trans s.compl_ne_univ_iff_nonempty
#align finset.card_compl_lt_iff_nonempty Finset.card_compl_lt_iff_nonempty
theorem Finset.card_univ_diff [DecidableEq α] [Fintype α] (s : Finset α) :
(Finset.univ \ s).card = Fintype.card α - s.card :=
Finset.card_sdiff (subset_univ s)
#align finset.card_univ_diff Finset.card_univ_diff
theorem Finset.card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
sᶜ.card = Fintype.card α - s.card :=
Finset.card_univ_diff s
#align finset.card_compl Finset.card_compl
@[simp]
theorem Finset.card_add_card_compl [DecidableEq α] [Fintype α] (s : Finset α) :
s.card + sᶜ.card = Fintype.card α := by
rw [Finset.card_compl, ← Nat.add_sub_assoc (card_le_univ s), Nat.add_sub_cancel_left]
@[simp]
theorem Finset.card_compl_add_card [DecidableEq α] [Fintype α] (s : Finset α) :
sᶜ.card + s.card = Fintype.card α := by
rw [add_comm, card_add_card_compl]
theorem Fintype.card_compl_set [Fintype α] (s : Set α) [Fintype s] [Fintype (↥sᶜ : Sort _)] :
Fintype.card (↥sᶜ : Sort _) = Fintype.card α - Fintype.card s := by
classical rw [← Set.toFinset_card, ← Set.toFinset_card, ← Finset.card_compl, Set.toFinset_compl]
#align fintype.card_compl_set Fintype.card_compl_set
@[simp]
theorem Fintype.card_fin (n : ℕ) : Fintype.card (Fin n) = n :=
List.length_finRange n
#align fintype.card_fin Fintype.card_fin
theorem Fintype.card_fin_lt_of_le {m n : ℕ} (h : m ≤ n) :
Fintype.card {i : Fin n // i < m} = m := by
conv_rhs => rw [← Fintype.card_fin m]
apply Fintype.card_congr
exact { toFun := fun ⟨⟨i, _⟩, hi⟩ ↦ ⟨i, hi⟩
invFun := fun ⟨i, hi⟩ ↦ ⟨⟨i, lt_of_lt_of_le hi h⟩, hi⟩
left_inv := fun i ↦ rfl
right_inv := fun i ↦ rfl }
theorem Finset.card_fin (n : ℕ) : Finset.card (Finset.univ : Finset (Fin n)) = n := by simp
#align finset.card_fin Finset.card_fin
/-- `Fin` as a map from `ℕ` to `Type` is injective. Note that since this is a statement about
equality of types, using it should be avoided if possible. -/
theorem fin_injective : Function.Injective Fin := fun m n h =>
(Fintype.card_fin m).symm.trans <| (Fintype.card_congr <| Equiv.cast h).trans (Fintype.card_fin n)
#align fin_injective fin_injective
/-- A reversed version of `Fin.cast_eq_cast` that is easier to rewrite with. -/
theorem Fin.cast_eq_cast' {n m : ℕ} (h : Fin n = Fin m) :
_root_.cast h = Fin.cast (fin_injective h) := by
cases fin_injective h
rfl
#align fin.cast_eq_cast' Fin.cast_eq_cast'
theorem card_finset_fin_le {n : ℕ} (s : Finset (Fin n)) : s.card ≤ n := by
simpa only [Fintype.card_fin] using s.card_le_univ
#align card_finset_fin_le card_finset_fin_le
--@[simp] Porting note (#10618): simp can prove it
theorem Fintype.card_subtype_eq (y : α) [Fintype { x // x = y }] :
Fintype.card { x // x = y } = 1 :=
Fintype.card_unique
#align fintype.card_subtype_eq Fintype.card_subtype_eq
--@[simp] Porting note (#10618): simp can prove it
theorem Fintype.card_subtype_eq' (y : α) [Fintype { x // y = x }] :
Fintype.card { x // y = x } = 1 :=
Fintype.card_unique
#align fintype.card_subtype_eq' Fintype.card_subtype_eq'
theorem Fintype.card_empty : Fintype.card Empty = 0 :=
rfl
#align fintype.card_empty Fintype.card_empty
theorem Fintype.card_pempty : Fintype.card PEmpty = 0 :=
rfl
#align fintype.card_pempty Fintype.card_pempty
theorem Fintype.card_unit : Fintype.card Unit = 1 :=
rfl
#align fintype.card_unit Fintype.card_unit
@[simp]
theorem Fintype.card_punit : Fintype.card PUnit = 1 :=
rfl
#align fintype.card_punit Fintype.card_punit
@[simp]
theorem Fintype.card_bool : Fintype.card Bool = 2 :=
rfl
#align fintype.card_bool Fintype.card_bool
@[simp]
theorem Fintype.card_ulift (α : Type*) [Fintype α] : Fintype.card (ULift α) = Fintype.card α :=
Fintype.ofEquiv_card _
#align fintype.card_ulift Fintype.card_ulift
@[simp]
theorem Fintype.card_plift (α : Type*) [Fintype α] : Fintype.card (PLift α) = Fintype.card α :=
Fintype.ofEquiv_card _
#align fintype.card_plift Fintype.card_plift
@[simp]
theorem Fintype.card_orderDual (α : Type*) [Fintype α] : Fintype.card αᵒᵈ = Fintype.card α :=
rfl
#align fintype.card_order_dual Fintype.card_orderDual
@[simp]
theorem Fintype.card_lex (α : Type*) [Fintype α] : Fintype.card (Lex α) = Fintype.card α :=
rfl
#align fintype.card_lex Fintype.card_lex
@[simp] lemma Fintype.card_multiplicative (α : Type*) [Fintype α] :
card (Multiplicative α) = card α := Finset.card_map _
@[simp] lemma Fintype.card_additive (α : Type*) [Fintype α] : card (Additive α) = card α :=
Finset.card_map _
/-- Given that `α ⊕ β` is a fintype, `α` is also a fintype. This is non-computable as it uses
that `Sum.inl` is an injection, but there's no clear inverse if `α` is empty. -/
noncomputable def Fintype.sumLeft {α β} [Fintype (Sum α β)] : Fintype α :=
Fintype.ofInjective (Sum.inl : α → Sum α β) Sum.inl_injective
#align fintype.sum_left Fintype.sumLeft
/-- Given that `α ⊕ β` is a fintype, `β` is also a fintype. This is non-computable as it uses
that `Sum.inr` is an injection, but there's no clear inverse if `β` is empty. -/
noncomputable def Fintype.sumRight {α β} [Fintype (Sum α β)] : Fintype β :=
Fintype.ofInjective (Sum.inr : β → Sum α β) Sum.inr_injective
#align fintype.sum_right Fintype.sumRight
/-!
### Relation to `Finite`
In this section we prove that `α : Type*` is `Finite` if and only if `Fintype α` is nonempty.
-/
-- @[nolint fintype_finite] -- Porting note: do we need this
protected theorem Fintype.finite {α : Type*} (_inst : Fintype α) : Finite α :=
⟨Fintype.equivFin α⟩
#align fintype.finite Fintype.finite
/-- For efficiency reasons, we want `Finite` instances to have higher
priority than ones coming from `Fintype` instances. -/
-- @[nolint fintype_finite] -- Porting note: do we need this
instance (priority := 900) Finite.of_fintype (α : Type*) [Fintype α] : Finite α :=
Fintype.finite ‹_›
#align finite.of_fintype Finite.of_fintype
theorem finite_iff_nonempty_fintype (α : Type*) : Finite α ↔ Nonempty (Fintype α) :=
⟨fun h =>
let ⟨_k, ⟨e⟩⟩ := @Finite.exists_equiv_fin α h
⟨Fintype.ofEquiv _ e.symm⟩,
fun ⟨_⟩ => inferInstance⟩
#align finite_iff_nonempty_fintype finite_iff_nonempty_fintype
/-- See also `nonempty_encodable`, `nonempty_denumerable`. -/
theorem nonempty_fintype (α : Type*) [Finite α] : Nonempty (Fintype α) :=
(finite_iff_nonempty_fintype α).mp ‹_›
#align nonempty_fintype nonempty_fintype
/-- Noncomputably get a `Fintype` instance from a `Finite` instance. This is not an
instance because we want `Fintype` instances to be useful for computations. -/
noncomputable def Fintype.ofFinite (α : Type*) [Finite α] : Fintype α :=
(nonempty_fintype α).some
#align fintype.of_finite Fintype.ofFinite
theorem Finite.of_injective {α β : Sort*} [Finite β] (f : α → β) (H : Injective f) : Finite α := by
rcases Finite.exists_equiv_fin β with ⟨n, ⟨e⟩⟩
classical exact .of_equiv (Set.range (e ∘ f)) (Equiv.ofInjective _ (e.injective.comp H)).symm
#align finite.of_injective Finite.of_injective
/-- This instance also provides `[Finite s]` for `s : Set α`. -/
instance Subtype.finite {α : Sort*} [Finite α] {p : α → Prop} : Finite { x // p x } :=
Finite.of_injective (↑) Subtype.coe_injective
#align subtype.finite Subtype.finite
theorem Finite.of_surjective {α β : Sort*} [Finite α] (f : α → β) (H : Surjective f) : Finite β :=
Finite.of_injective _ <| injective_surjInv H
#align finite.of_surjective Finite.of_surjective
theorem Finite.exists_univ_list (α) [Finite α] : ∃ l : List α, l.Nodup ∧ ∀ x : α, x ∈ l := by
cases nonempty_fintype α
obtain ⟨l, e⟩ := Quotient.exists_rep (@univ α _).1
have := And.intro (@univ α _).2 (@mem_univ_val α _)
exact ⟨_, by rwa [← e] at this⟩
#align finite.exists_univ_list Finite.exists_univ_list
theorem List.Nodup.length_le_card {α : Type*} [Fintype α] {l : List α} (h : l.Nodup) :
l.length ≤ Fintype.card α := by
classical exact List.toFinset_card_of_nodup h ▸ l.toFinset.card_le_univ
#align list.nodup.length_le_card List.Nodup.length_le_card
namespace Fintype
variable [Fintype α] [Fintype β]
theorem card_le_of_injective (f : α → β) (hf : Function.Injective f) : card α ≤ card β :=
Finset.card_le_card_of_inj_on f (fun _ _ => Finset.mem_univ _) fun _ _ _ _ h => hf h
#align fintype.card_le_of_injective Fintype.card_le_of_injective
theorem card_le_of_embedding (f : α ↪ β) : card α ≤ card β :=
card_le_of_injective f f.2
#align fintype.card_le_of_embedding Fintype.card_le_of_embedding
theorem card_lt_of_injective_of_not_mem (f : α → β) (h : Function.Injective f) {b : β}
(w : b ∉ Set.range f) : card α < card β :=
calc
card α = (univ.map ⟨f, h⟩).card := (card_map _).symm
_ < card β :=
Finset.card_lt_univ_of_not_mem <| by rwa [← mem_coe, coe_map, coe_univ, Set.image_univ]
#align fintype.card_lt_of_injective_of_not_mem Fintype.card_lt_of_injective_of_not_mem
theorem card_lt_of_injective_not_surjective (f : α → β) (h : Function.Injective f)
(h' : ¬Function.Surjective f) : card α < card β :=
let ⟨_y, hy⟩ := not_forall.1 h'
card_lt_of_injective_of_not_mem f h hy
#align fintype.card_lt_of_injective_not_surjective Fintype.card_lt_of_injective_not_surjective
theorem card_le_of_surjective (f : α → β) (h : Function.Surjective f) : card β ≤ card α :=
card_le_of_injective _ (Function.injective_surjInv h)
#align fintype.card_le_of_surjective Fintype.card_le_of_surjective
theorem card_range_le {α β : Type*} (f : α → β) [Fintype α] [Fintype (Set.range f)] :
Fintype.card (Set.range f) ≤ Fintype.card α :=
Fintype.card_le_of_surjective (fun a => ⟨f a, by simp⟩) fun ⟨_, a, ha⟩ => ⟨a, by simpa using ha⟩
#align fintype.card_range_le Fintype.card_range_le
theorem card_range {α β F : Type*} [FunLike F α β] [EmbeddingLike F α β] (f : F) [Fintype α]
[Fintype (Set.range f)] : Fintype.card (Set.range f) = Fintype.card α :=
Eq.symm <| Fintype.card_congr <| Equiv.ofInjective _ <| EmbeddingLike.injective f
#align fintype.card_range Fintype.card_range
/-- The pigeonhole principle for finitely many pigeons and pigeonholes.
This is the `Fintype` version of `Finset.exists_ne_map_eq_of_card_lt_of_maps_to`.
-/
theorem exists_ne_map_eq_of_card_lt (f : α → β) (h : Fintype.card β < Fintype.card α) :
∃ x y, x ≠ y ∧ f x = f y :=
let ⟨x, _, y, _, h⟩ := Finset.exists_ne_map_eq_of_card_lt_of_maps_to h fun x _ => mem_univ (f x)
⟨x, y, h⟩
#align fintype.exists_ne_map_eq_of_card_lt Fintype.exists_ne_map_eq_of_card_lt
theorem card_eq_one_iff : card α = 1 ↔ ∃ x : α, ∀ y, y = x := by
rw [← card_unit, card_eq]
exact
⟨fun ⟨a⟩ => ⟨a.symm (), fun y => a.injective (Subsingleton.elim _ _)⟩,
fun ⟨x, hx⟩ =>
⟨⟨fun _ => (), fun _ => x, fun _ => (hx _).trans (hx _).symm, fun _ =>
Subsingleton.elim _ _⟩⟩⟩
#align fintype.card_eq_one_iff Fintype.card_eq_one_iff
theorem card_eq_zero_iff : card α = 0 ↔ IsEmpty α := by
rw [card, Finset.card_eq_zero, univ_eq_empty_iff]
#align fintype.card_eq_zero_iff Fintype.card_eq_zero_iff
@[simp] theorem card_eq_zero [IsEmpty α] : card α = 0 :=
card_eq_zero_iff.2 ‹_›
#align fintype.card_eq_zero Fintype.card_eq_zero
alias card_of_isEmpty := card_eq_zero
theorem card_eq_one_iff_nonempty_unique : card α = 1 ↔ Nonempty (Unique α) :=
⟨fun h =>
let ⟨d, h⟩ := Fintype.card_eq_one_iff.mp h
⟨{ default := d
uniq := h }⟩,
fun ⟨_h⟩ => Fintype.card_unique⟩
#align fintype.card_eq_one_iff_nonempty_unique Fintype.card_eq_one_iff_nonempty_unique
/-- A `Fintype` with cardinality zero is equivalent to `Empty`. -/
def cardEqZeroEquivEquivEmpty : card α = 0 ≃ (α ≃ Empty) :=
(Equiv.ofIff card_eq_zero_iff).trans (Equiv.equivEmptyEquiv α).symm
#align fintype.card_eq_zero_equiv_equiv_empty Fintype.cardEqZeroEquivEquivEmpty
theorem card_pos_iff : 0 < card α ↔ Nonempty α :=
Nat.pos_iff_ne_zero.trans <| not_iff_comm.mp <| not_nonempty_iff.trans card_eq_zero_iff.symm
#align fintype.card_pos_iff Fintype.card_pos_iff
theorem card_pos [h : Nonempty α] : 0 < card α :=
card_pos_iff.mpr h
#align fintype.card_pos Fintype.card_pos
@[simp]
theorem card_ne_zero [Nonempty α] : card α ≠ 0 :=
_root_.ne_of_gt card_pos
#align fintype.card_ne_zero Fintype.card_ne_zero
instance [Nonempty α] : NeZero (card α) := ⟨card_ne_zero⟩
theorem card_le_one_iff : card α ≤ 1 ↔ ∀ a b : α, a = b :=
let n := card α
have hn : n = card α := rfl
match n, hn with
| 0, ha =>
⟨fun _h => fun a => (card_eq_zero_iff.1 ha.symm).elim a, fun _ => ha ▸ Nat.le_succ _⟩
| 1, ha =>
⟨fun _h => fun a b => by
let ⟨x, hx⟩ := card_eq_one_iff.1 ha.symm
rw [hx a, hx b], fun _ => ha ▸ le_rfl⟩
| n + 2, ha =>
⟨fun h => False.elim <| by rw [← ha] at h; cases h with | step h => cases h; , fun h =>
card_unit ▸ card_le_of_injective (fun _ => ()) fun _ _ _ => h _ _⟩
#align fintype.card_le_one_iff Fintype.card_le_one_iff
theorem card_le_one_iff_subsingleton : card α ≤ 1 ↔ Subsingleton α :=
card_le_one_iff.trans subsingleton_iff.symm
#align fintype.card_le_one_iff_subsingleton Fintype.card_le_one_iff_subsingleton
theorem one_lt_card_iff_nontrivial : 1 < card α ↔ Nontrivial α := by
rw [← not_iff_not, not_lt, not_nontrivial_iff_subsingleton, card_le_one_iff_subsingleton]
#align fintype.one_lt_card_iff_nontrivial Fintype.one_lt_card_iff_nontrivial
theorem exists_ne_of_one_lt_card (h : 1 < card α) (a : α) : ∃ b : α, b ≠ a :=
haveI : Nontrivial α := one_lt_card_iff_nontrivial.1 h
exists_ne a
#align fintype.exists_ne_of_one_lt_card Fintype.exists_ne_of_one_lt_card
theorem exists_pair_of_one_lt_card (h : 1 < card α) : ∃ a b : α, a ≠ b :=
haveI : Nontrivial α := one_lt_card_iff_nontrivial.1 h
exists_pair_ne α
#align fintype.exists_pair_of_one_lt_card Fintype.exists_pair_of_one_lt_card
theorem card_eq_one_of_forall_eq {i : α} (h : ∀ j, j = i) : card α = 1 :=
Fintype.card_eq_one_iff.2 ⟨i, h⟩
#align fintype.card_eq_one_of_forall_eq Fintype.card_eq_one_of_forall_eq
theorem exists_unique_iff_card_one {α} [Fintype α] (p : α → Prop) [DecidablePred p] :
(∃! a : α, p a) ↔ (Finset.univ.filter p).card = 1 := by
rw [Finset.card_eq_one]
refine exists_congr fun x => ?_
simp only [forall_true_left, Subset.antisymm_iff, subset_singleton_iff', singleton_subset_iff,
true_and, and_comm, mem_univ, mem_filter]
theorem one_lt_card [h : Nontrivial α] : 1 < Fintype.card α :=
Fintype.one_lt_card_iff_nontrivial.mpr h
#align fintype.one_lt_card Fintype.one_lt_card
theorem one_lt_card_iff : 1 < card α ↔ ∃ a b : α, a ≠ b :=
one_lt_card_iff_nontrivial.trans nontrivial_iff
#align fintype.one_lt_card_iff Fintype.one_lt_card_iff
nonrec theorem two_lt_card_iff : 2 < card α ↔ ∃ a b c : α, a ≠ b ∧ a ≠ c ∧ b ≠ c := by
simp_rw [← Finset.card_univ, two_lt_card_iff, mem_univ, true_and_iff]
#align fintype.two_lt_card_iff Fintype.two_lt_card_iff
theorem card_of_bijective {f : α → β} (hf : Bijective f) : card α = card β :=
card_congr (Equiv.ofBijective f hf)
#align fintype.card_of_bijective Fintype.card_of_bijective
end Fintype
namespace Finite
variable [Finite α]
-- Porting note (#10756): new theorem
theorem surjective_of_injective {f : α → α} (hinj : Injective f) : Surjective f := by
intro x
have := Classical.propDecidable
cases nonempty_fintype α
have h₁ : image f univ = univ :=
eq_of_subset_of_card_le (subset_univ _)
((card_image_of_injective univ hinj).symm ▸ le_rfl)
have h₂ : x ∈ image f univ := h₁.symm ▸ mem_univ x
obtain ⟨y, h⟩ := mem_image.1 h₂
exact ⟨y, h.2⟩
theorem injective_iff_surjective {f : α → α} : Injective f ↔ Surjective f :=
⟨surjective_of_injective, fun hsurj =>
HasLeftInverse.injective ⟨surjInv hsurj, leftInverse_of_surjective_of_rightInverse
(surjective_of_injective (injective_surjInv _))
(rightInverse_surjInv _)⟩⟩
#align finite.injective_iff_surjective Finite.injective_iff_surjective
theorem injective_iff_bijective {f : α → α} : Injective f ↔ Bijective f := by
simp [Bijective, injective_iff_surjective]
#align finite.injective_iff_bijective Finite.injective_iff_bijective
theorem surjective_iff_bijective {f : α → α} : Surjective f ↔ Bijective f := by
simp [Bijective, injective_iff_surjective]
#align finite.surjective_iff_bijective Finite.surjective_iff_bijective
theorem injective_iff_surjective_of_equiv {f : α → β} (e : α ≃ β) : Injective f ↔ Surjective f :=
have : Injective (e.symm ∘ f) ↔ Surjective (e.symm ∘ f) := injective_iff_surjective
⟨fun hinj => by
simpa [Function.comp] using e.surjective.comp (this.1 (e.symm.injective.comp hinj)),
fun hsurj => by
simpa [Function.comp] using e.injective.comp (this.2 (e.symm.surjective.comp hsurj))⟩
#align finite.injective_iff_surjective_of_equiv Finite.injective_iff_surjective_of_equiv
alias ⟨_root_.Function.Injective.bijective_of_finite, _⟩ := injective_iff_bijective
#align function.injective.bijective_of_finite Function.Injective.bijective_of_finite
alias ⟨_root_.Function.Surjective.bijective_of_finite, _⟩ := surjective_iff_bijective
#align function.surjective.bijective_of_finite Function.Surjective.bijective_of_finite
alias ⟨_root_.Function.Injective.surjective_of_fintype,
_root_.Function.Surjective.injective_of_fintype⟩ :=
injective_iff_surjective_of_equiv
#align function.injective.surjective_of_fintype Function.Injective.surjective_of_fintype
#align function.surjective.injective_of_fintype Function.Surjective.injective_of_fintype
end Finite
namespace Fintype
variable [Fintype α] [Fintype β]
theorem bijective_iff_injective_and_card (f : α → β) :
Bijective f ↔ Injective f ∧ card α = card β :=
⟨fun h => ⟨h.1, card_of_bijective h⟩, fun h =>
⟨h.1, h.1.surjective_of_fintype <| equivOfCardEq h.2⟩⟩
#align fintype.bijective_iff_injective_and_card Fintype.bijective_iff_injective_and_card
theorem bijective_iff_surjective_and_card (f : α → β) :
Bijective f ↔ Surjective f ∧ card α = card β :=
⟨fun h => ⟨h.2, card_of_bijective h⟩, fun h =>
⟨h.1.injective_of_fintype <| equivOfCardEq h.2, h.1⟩⟩
#align fintype.bijective_iff_surjective_and_card Fintype.bijective_iff_surjective_and_card
theorem _root_.Function.LeftInverse.rightInverse_of_card_le {f : α → β} {g : β → α}
(hfg : LeftInverse f g) (hcard : card α ≤ card β) : RightInverse f g :=
have hsurj : Surjective f := surjective_iff_hasRightInverse.2 ⟨g, hfg⟩
rightInverse_of_injective_of_leftInverse
((bijective_iff_surjective_and_card _).2
⟨hsurj, le_antisymm hcard (card_le_of_surjective f hsurj)⟩).1
hfg
#align function.left_inverse.right_inverse_of_card_le Function.LeftInverse.rightInverse_of_card_le
theorem _root_.Function.RightInverse.leftInverse_of_card_le {f : α → β} {g : β → α}
(hfg : RightInverse f g) (hcard : card β ≤ card α) : LeftInverse f g :=
Function.LeftInverse.rightInverse_of_card_le hfg hcard
#align function.right_inverse.left_inverse_of_card_le Function.RightInverse.leftInverse_of_card_le
end Fintype
namespace Equiv
variable [Fintype α] [Fintype β]
open Fintype
/-- Construct an equivalence from functions that are inverse to each other. -/
@[simps]
def ofLeftInverseOfCardLE (hβα : card β ≤ card α) (f : α → β) (g : β → α) (h : LeftInverse g f) :
α ≃ β where
toFun := f
invFun := g
left_inv := h
right_inv := h.rightInverse_of_card_le hβα
#align equiv.of_left_inverse_of_card_le Equiv.ofLeftInverseOfCardLE
#align equiv.of_left_inverse_of_card_le_symm_apply Equiv.ofLeftInverseOfCardLE_symm_apply
#align equiv.of_left_inverse_of_card_le_apply Equiv.ofLeftInverseOfCardLE_apply
/-- Construct an equivalence from functions that are inverse to each other. -/
@[simps]
def ofRightInverseOfCardLE (hαβ : card α ≤ card β) (f : α → β) (g : β → α) (h : RightInverse g f) :
α ≃ β where
toFun := f
invFun := g
left_inv := h.leftInverse_of_card_le hαβ
right_inv := h
#align equiv.of_right_inverse_of_card_le Equiv.ofRightInverseOfCardLE
#align equiv.of_right_inverse_of_card_le_symm_apply Equiv.ofRightInverseOfCardLE_symm_apply
#align equiv.of_right_inverse_of_card_le_apply Equiv.ofRightInverseOfCardLE_apply
end Equiv
@[simp]
theorem Fintype.card_coe (s : Finset α) [Fintype s] : Fintype.card s = s.card :=
@Fintype.card_of_finset' _ _ _ (fun _ => Iff.rfl) (id _)
#align fintype.card_coe Fintype.card_coe
/-- Noncomputable equivalence between a finset `s` coerced to a type and `Fin s.card`. -/
noncomputable def Finset.equivFin (s : Finset α) : s ≃ Fin s.card :=
Fintype.equivFinOfCardEq (Fintype.card_coe _)
#align finset.equiv_fin Finset.equivFin
/-- Noncomputable equivalence between a finset `s` as a fintype and `Fin n`, when there is a
proof that `s.card = n`. -/
noncomputable def Finset.equivFinOfCardEq {s : Finset α} {n : ℕ} (h : s.card = n) : s ≃ Fin n :=
Fintype.equivFinOfCardEq ((Fintype.card_coe _).trans h)
#align finset.equiv_fin_of_card_eq Finset.equivFinOfCardEq
theorem Finset.card_eq_of_equiv_fin {s : Finset α} {n : ℕ} (i : s ≃ Fin n) : s.card = n :=
Fin.equiv_iff_eq.1 ⟨s.equivFin.symm.trans i⟩
theorem Finset.card_eq_of_equiv_fintype {s : Finset α} [Fintype β] (i : s ≃ β) :
s.card = Fintype.card β := card_eq_of_equiv_fin <| i.trans <| Fintype.equivFin β
/-- Noncomputable equivalence between two finsets `s` and `t` as fintypes when there is a proof
that `s.card = t.card`. -/
noncomputable def Finset.equivOfCardEq {s : Finset α} {t : Finset β} (h : s.card = t.card) :
s ≃ t := Fintype.equivOfCardEq ((Fintype.card_coe _).trans (h.trans (Fintype.card_coe _).symm))
#align finset.equiv_of_card_eq Finset.equivOfCardEq
theorem Finset.card_eq_of_equiv {s : Finset α} {t : Finset β} (i : s ≃ t) : s.card = t.card :=
(card_eq_of_equiv_fintype i).trans (Fintype.card_coe _)
@[simp]
theorem Fintype.card_prop : Fintype.card Prop = 2 :=
rfl
#align fintype.card_Prop Fintype.card_prop
theorem set_fintype_card_le_univ [Fintype α] (s : Set α) [Fintype s] :
Fintype.card s ≤ Fintype.card α :=
Fintype.card_le_of_embedding (Function.Embedding.subtype s)
#align set_fintype_card_le_univ set_fintype_card_le_univ
theorem set_fintype_card_eq_univ_iff [Fintype α] (s : Set α) [Fintype s] :
Fintype.card s = Fintype.card α ↔ s = Set.univ := by
rw [← Set.toFinset_card, Finset.card_eq_iff_eq_univ, ← Set.toFinset_univ, Set.toFinset_inj]
#align set_fintype_card_eq_univ_iff set_fintype_card_eq_univ_iff
namespace Function.Embedding
/-- An embedding from a `Fintype` to itself can be promoted to an equivalence. -/
noncomputable def equivOfFintypeSelfEmbedding [Finite α] (e : α ↪ α) : α ≃ α :=
Equiv.ofBijective e e.2.bijective_of_finite
#align function.embedding.equiv_of_fintype_self_embedding Function.Embedding.equivOfFintypeSelfEmbedding
@[simp]
theorem equiv_of_fintype_self_embedding_to_embedding [Finite α] (e : α ↪ α) :
e.equivOfFintypeSelfEmbedding.toEmbedding = e := by
ext
rfl
#align function.embedding.equiv_of_fintype_self_embedding_to_embedding Function.Embedding.equiv_of_fintype_self_embedding_to_embedding
/-- If `‖β‖ < ‖α‖` there are no embeddings `α ↪ β`.
This is a formulation of the pigeonhole principle.
Note this cannot be an instance as it needs `h`. -/
@[simp]
theorem isEmpty_of_card_lt [Fintype α] [Fintype β] (h : Fintype.card β < Fintype.card α) :
IsEmpty (α ↪ β) :=
⟨fun f =>
let ⟨_x, _y, ne, feq⟩ := Fintype.exists_ne_map_eq_of_card_lt f h
ne <| f.injective feq⟩
#align function.embedding.is_empty_of_card_lt Function.Embedding.isEmpty_of_card_lt
/-- A constructive embedding of a fintype `α` in another fintype `β` when `card α ≤ card β`. -/
def truncOfCardLE [Fintype α] [Fintype β] [DecidableEq α] [DecidableEq β]
(h : Fintype.card α ≤ Fintype.card β) : Trunc (α ↪ β) :=
(Fintype.truncEquivFin α).bind fun ea =>
(Fintype.truncEquivFin β).map fun eb =>
ea.toEmbedding.trans ((Fin.castLEEmb h).trans eb.symm.toEmbedding)
#align function.embedding.trunc_of_card_le Function.Embedding.truncOfCardLE
theorem nonempty_of_card_le [Fintype α] [Fintype β] (h : Fintype.card α ≤ Fintype.card β) :
Nonempty (α ↪ β) := by classical exact (truncOfCardLE h).nonempty
#align function.embedding.nonempty_of_card_le Function.Embedding.nonempty_of_card_le
theorem nonempty_iff_card_le [Fintype α] [Fintype β] :
Nonempty (α ↪ β) ↔ Fintype.card α ≤ Fintype.card β :=
⟨fun ⟨e⟩ => Fintype.card_le_of_embedding e, nonempty_of_card_le⟩
#align function.embedding.nonempty_iff_card_le Function.Embedding.nonempty_iff_card_le
theorem exists_of_card_le_finset [Fintype α] {s : Finset β} (h : Fintype.card α ≤ s.card) :
∃ f : α ↪ β, Set.range f ⊆ s := by
rw [← Fintype.card_coe] at h
rcases nonempty_of_card_le h with ⟨f⟩
exact ⟨f.trans (Embedding.subtype _), by simp [Set.range_subset_iff]⟩
#align function.embedding.exists_of_card_le_finset Function.Embedding.exists_of_card_le_finset
end Function.Embedding
@[simp]
| Mathlib/Data/Fintype/Card.lean | 853 | 854 | theorem Finset.univ_map_embedding {α : Type*} [Fintype α] (e : α ↪ α) : univ.map e = univ := by |
rw [← e.equiv_of_fintype_self_embedding_to_embedding, univ_map_equiv_to_embedding]
|
/-
Copyright (c) 2023 Dagur Asgeirsson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson
-/
import Mathlib.Algebra.Category.ModuleCat.Free
import Mathlib.Topology.Category.Profinite.CofilteredLimit
import Mathlib.Topology.Category.Profinite.Product
import Mathlib.Topology.LocallyConstant.Algebra
import Mathlib.Init.Data.Bool.Lemmas
/-!
# Nöbeling's theorem
This file proves Nöbeling's theorem.
## Main result
* `LocallyConstant.freeOfProfinite`: Nöbeling's theorem.
For `S : Profinite`, the `ℤ`-module `LocallyConstant S ℤ` is free.
## Proof idea
We follow the proof of theorem 5.4 in [scholze2019condensed], in which the idea is to embed `S` in
a product of `I` copies of `Bool` for some sufficiently large `I`, and then to choose a
well-ordering on `I` and use ordinal induction over that well-order. Here we can let `I` be
the set of clopen subsets of `S` since `S` is totally separated.
The above means it suffices to prove the following statement: For a closed subset `C` of `I → Bool`,
the `ℤ`-module `LocallyConstant C ℤ` is free.
For `i : I`, let `e C i : LocallyConstant C ℤ` denote the map `fun f ↦ (if f.val i then 1 else 0)`.
The basis will consist of products `e C iᵣ * ⋯ * e C i₁` with `iᵣ > ⋯ > i₁` which cannot be written
as linear combinations of lexicographically smaller products. We call this set `GoodProducts C`
What is proved by ordinal induction is that this set is linearly independent. The fact that it
spans can be proved directly.
## References
- [scholze2019condensed], Theorem 5.4.
-/
universe u
namespace Profinite
namespace NobelingProof
variable {I : Type u} [LinearOrder I] [IsWellOrder I (·<·)] (C : Set (I → Bool))
open Profinite ContinuousMap CategoryTheory Limits Opposite Submodule
section Projections
/-!
## Projection maps
The purpose of this section is twofold.
Firstly, in the proof that the set `GoodProducts C` spans the whole module `LocallyConstant C ℤ`,
we need to project `C` down to finite discrete subsets and write `C` as a cofiltered limit of those.
Secondly, in the inductive argument, we need to project `C` down to "smaller" sets satisfying the
inductive hypothesis.
In this section we define the relevant projection maps and prove some compatibility results.
### Main definitions
* Let `J : I → Prop`. Then `Proj J : (I → Bool) → (I → Bool)` is the projection mapping everything
that satisfies `J i` to itself, and everything else to `false`.
* The image of `C` under `Proj J` is denoted `π C J` and the corresponding map `C → π C J` is called
`ProjRestrict`. If `J` implies `K` we have a map `ProjRestricts : π C K → π C J`.
* `spanCone_isLimit` establishes that when `C` is compact, it can be written as a limit of its
images under the maps `Proj (· ∈ s)` where `s : Finset I`.
-/
variable (J K L : I → Prop) [∀ i, Decidable (J i)] [∀ i, Decidable (K i)] [∀ i, Decidable (L i)]
/--
The projection mapping everything that satisfies `J i` to itself, and everything else to `false`
-/
def Proj : (I → Bool) → (I → Bool) :=
fun c i ↦ if J i then c i else false
@[simp]
theorem continuous_proj :
Continuous (Proj J : (I → Bool) → (I → Bool)) := by
dsimp (config := { unfoldPartialApp := true }) [Proj]
apply continuous_pi
intro i
split
· apply continuous_apply
· apply continuous_const
/-- The image of `Proj π J` -/
def π : Set (I → Bool) := (Proj J) '' C
/-- The restriction of `Proj π J` to a subset, mapping to its image. -/
@[simps!]
def ProjRestrict : C → π C J :=
Set.MapsTo.restrict (Proj J) _ _ (Set.mapsTo_image _ _)
@[simp]
theorem continuous_projRestrict : Continuous (ProjRestrict C J) :=
Continuous.restrict _ (continuous_proj _)
theorem proj_eq_self {x : I → Bool} (h : ∀ i, x i ≠ false → J i) : Proj J x = x := by
ext i
simp only [Proj, ite_eq_left_iff]
contrapose!
simpa only [ne_comm] using h i
theorem proj_prop_eq_self (hh : ∀ i x, x ∈ C → x i ≠ false → J i) : π C J = C := by
ext x
refine ⟨fun ⟨y, hy, h⟩ ↦ ?_, fun h ↦ ⟨x, h, ?_⟩⟩
· rwa [← h, proj_eq_self]; exact (hh · y hy)
· rw [proj_eq_self]; exact (hh · x h)
theorem proj_comp_of_subset (h : ∀ i, J i → K i) : (Proj J ∘ Proj K) =
(Proj J : (I → Bool) → (I → Bool)) := by
ext x i; dsimp [Proj]; aesop
theorem proj_eq_of_subset (h : ∀ i, J i → K i) : π (π C K) J = π C J := by
ext x
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· obtain ⟨y, ⟨z, hz, rfl⟩, rfl⟩ := h
refine ⟨z, hz, (?_ : _ = (Proj J ∘ Proj K) z)⟩
rw [proj_comp_of_subset J K h]
· obtain ⟨y, hy, rfl⟩ := h
dsimp [π]
rw [← Set.image_comp]
refine ⟨y, hy, ?_⟩
rw [proj_comp_of_subset J K h]
variable {J K L}
/-- A variant of `ProjRestrict` with domain of the form `π C K` -/
@[simps!]
def ProjRestricts (h : ∀ i, J i → K i) : π C K → π C J :=
Homeomorph.setCongr (proj_eq_of_subset C J K h) ∘ ProjRestrict (π C K) J
@[simp]
theorem continuous_projRestricts (h : ∀ i, J i → K i) : Continuous (ProjRestricts C h) :=
Continuous.comp (Homeomorph.continuous _) (continuous_projRestrict _ _)
theorem surjective_projRestricts (h : ∀ i, J i → K i) : Function.Surjective (ProjRestricts C h) :=
(Homeomorph.surjective _).comp (Set.surjective_mapsTo_image_restrict _ _)
variable (J) in
theorem projRestricts_eq_id : ProjRestricts C (fun i (h : J i) ↦ h) = id := by
ext ⟨x, y, hy, rfl⟩ i
simp (config := { contextual := true }) only [π, Proj, ProjRestricts_coe, id_eq, if_true]
theorem projRestricts_eq_comp (hJK : ∀ i, J i → K i) (hKL : ∀ i, K i → L i) :
ProjRestricts C hJK ∘ ProjRestricts C hKL = ProjRestricts C (fun i ↦ hKL i ∘ hJK i) := by
ext x i
simp only [π, Proj, Function.comp_apply, ProjRestricts_coe]
aesop
| Mathlib/Topology/Category/Profinite/Nobeling.lean | 166 | 170 | theorem projRestricts_comp_projRestrict (h : ∀ i, J i → K i) :
ProjRestricts C h ∘ ProjRestrict C K = ProjRestrict C J := by |
ext x i
simp only [π, Proj, Function.comp_apply, ProjRestricts_coe, ProjRestrict_coe]
aesop
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Johan Commelin, Mario Carneiro
-/
import Mathlib.Algebra.MonoidAlgebra.Degree
import Mathlib.Algebra.MvPolynomial.Rename
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
#align_import data.mv_polynomial.variables from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
/-!
# Degrees of polynomials
This file establishes many results about the degree of a multivariate polynomial.
The *degree set* of a polynomial $P \in R[X]$ is a `Multiset` containing, for each $x$ in the
variable set, $n$ copies of $x$, where $n$ is the maximum number of copies of $x$ appearing in a
monomial of $P$.
## Main declarations
* `MvPolynomial.degrees p` : the multiset of variables representing the union of the multisets
corresponding to each non-zero monomial in `p`.
For example if `7 ≠ 0` in `R` and `p = x²y+7y³` then `degrees p = {x, x, y, y, y}`
* `MvPolynomial.degreeOf n p : ℕ` : the total degree of `p` with respect to the variable `n`.
For example if `p = x⁴y+yz` then `degreeOf y p = 1`.
* `MvPolynomial.totalDegree p : ℕ` :
the max of the sizes of the multisets `s` whose monomials `X^s` occur in `p`.
For example if `p = x⁴y+yz` then `totalDegree p = 5`.
## Notation
As in other polynomial files, we typically use the notation:
+ `σ τ : Type*` (indexing the variables)
+ `R : Type*` `[CommSemiring R]` (the coefficients)
+ `s : σ →₀ ℕ`, a function from `σ` to `ℕ` which is zero away from a finite set.
This will give rise to a monomial in `MvPolynomial σ R` which mathematicians might call `X^s`
+ `r : R`
+ `i : σ`, with corresponding monomial `X i`, often denoted `X_i` by mathematicians
+ `p : MvPolynomial σ R`
-/
noncomputable section
open Set Function Finsupp AddMonoidAlgebra
universe u v w
variable {R : Type u} {S : Type v}
namespace MvPolynomial
variable {σ τ : Type*} {r : R} {e : ℕ} {n m : σ} {s : σ →₀ ℕ}
section CommSemiring
variable [CommSemiring R] {p q : MvPolynomial σ R}
section Degrees
/-! ### `degrees` -/
/-- The maximal degrees of each variable in a multi-variable polynomial, expressed as a multiset.
(For example, `degrees (x^2 * y + y^3)` would be `{x, x, y, y, y}`.)
-/
def degrees (p : MvPolynomial σ R) : Multiset σ :=
letI := Classical.decEq σ
p.support.sup fun s : σ →₀ ℕ => toMultiset s
#align mv_polynomial.degrees MvPolynomial.degrees
theorem degrees_def [DecidableEq σ] (p : MvPolynomial σ R) :
p.degrees = p.support.sup fun s : σ →₀ ℕ => Finsupp.toMultiset s := by rw [degrees]; convert rfl
#align mv_polynomial.degrees_def MvPolynomial.degrees_def
theorem degrees_monomial (s : σ →₀ ℕ) (a : R) : degrees (monomial s a) ≤ toMultiset s := by
classical
refine (supDegree_single s a).trans_le ?_
split_ifs
exacts [bot_le, le_rfl]
#align mv_polynomial.degrees_monomial MvPolynomial.degrees_monomial
theorem degrees_monomial_eq (s : σ →₀ ℕ) (a : R) (ha : a ≠ 0) :
degrees (monomial s a) = toMultiset s := by
classical
exact (supDegree_single s a).trans (if_neg ha)
#align mv_polynomial.degrees_monomial_eq MvPolynomial.degrees_monomial_eq
theorem degrees_C (a : R) : degrees (C a : MvPolynomial σ R) = 0 :=
Multiset.le_zero.1 <| degrees_monomial _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_C MvPolynomial.degrees_C
theorem degrees_X' (n : σ) : degrees (X n : MvPolynomial σ R) ≤ {n} :=
le_trans (degrees_monomial _ _) <| le_of_eq <| toMultiset_single _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X' MvPolynomial.degrees_X'
@[simp]
theorem degrees_X [Nontrivial R] (n : σ) : degrees (X n : MvPolynomial σ R) = {n} :=
(degrees_monomial_eq _ (1 : R) one_ne_zero).trans (toMultiset_single _ _)
set_option linter.uppercaseLean3 false in
#align mv_polynomial.degrees_X MvPolynomial.degrees_X
@[simp]
theorem degrees_zero : degrees (0 : MvPolynomial σ R) = 0 := by
rw [← C_0]
exact degrees_C 0
#align mv_polynomial.degrees_zero MvPolynomial.degrees_zero
@[simp]
theorem degrees_one : degrees (1 : MvPolynomial σ R) = 0 :=
degrees_C 1
#align mv_polynomial.degrees_one MvPolynomial.degrees_one
theorem degrees_add [DecidableEq σ] (p q : MvPolynomial σ R) :
(p + q).degrees ≤ p.degrees ⊔ q.degrees := by
simp_rw [degrees_def]; exact supDegree_add_le
#align mv_polynomial.degrees_add MvPolynomial.degrees_add
theorem degrees_sum {ι : Type*} [DecidableEq σ] (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∑ i ∈ s, f i).degrees ≤ s.sup fun i => (f i).degrees := by
simp_rw [degrees_def]; exact supDegree_sum_le
#align mv_polynomial.degrees_sum MvPolynomial.degrees_sum
theorem degrees_mul (p q : MvPolynomial σ R) : (p * q).degrees ≤ p.degrees + q.degrees := by
classical
simp_rw [degrees_def]
exact supDegree_mul_le (map_add _)
#align mv_polynomial.degrees_mul MvPolynomial.degrees_mul
theorem degrees_prod {ι : Type*} (s : Finset ι) (f : ι → MvPolynomial σ R) :
(∏ i ∈ s, f i).degrees ≤ ∑ i ∈ s, (f i).degrees := by
classical exact supDegree_prod_le (map_zero _) (map_add _)
#align mv_polynomial.degrees_prod MvPolynomial.degrees_prod
theorem degrees_pow (p : MvPolynomial σ R) (n : ℕ) : (p ^ n).degrees ≤ n • p.degrees := by
simpa using degrees_prod (Finset.range n) fun _ ↦ p
#align mv_polynomial.degrees_pow MvPolynomial.degrees_pow
theorem mem_degrees {p : MvPolynomial σ R} {i : σ} :
i ∈ p.degrees ↔ ∃ d, p.coeff d ≠ 0 ∧ i ∈ d.support := by
classical
simp only [degrees_def, Multiset.mem_sup, ← mem_support_iff, Finsupp.mem_toMultiset, exists_prop]
#align mv_polynomial.mem_degrees MvPolynomial.mem_degrees
theorem le_degrees_add {p q : MvPolynomial σ R} (h : p.degrees.Disjoint q.degrees) :
p.degrees ≤ (p + q).degrees := by
classical
apply Finset.sup_le
intro d hd
rw [Multiset.disjoint_iff_ne] at h
obtain rfl | h0 := eq_or_ne d 0
· rw [toMultiset_zero]; apply Multiset.zero_le
· refine Finset.le_sup_of_le (b := d) ?_ le_rfl
rw [mem_support_iff, coeff_add]
suffices q.coeff d = 0 by rwa [this, add_zero, coeff, ← Finsupp.mem_support_iff]
rw [Ne, ← Finsupp.support_eq_empty, ← Ne, ← Finset.nonempty_iff_ne_empty] at h0
obtain ⟨j, hj⟩ := h0
contrapose! h
rw [mem_support_iff] at hd
refine ⟨j, ?_, j, ?_, rfl⟩
all_goals rw [mem_degrees]; refine ⟨d, ?_, hj⟩; assumption
#align mv_polynomial.le_degrees_add MvPolynomial.le_degrees_add
theorem degrees_add_of_disjoint [DecidableEq σ] {p q : MvPolynomial σ R}
(h : Multiset.Disjoint p.degrees q.degrees) : (p + q).degrees = p.degrees ∪ q.degrees := by
apply le_antisymm
· apply degrees_add
· apply Multiset.union_le
· apply le_degrees_add h
· rw [add_comm]
apply le_degrees_add h.symm
#align mv_polynomial.degrees_add_of_disjoint MvPolynomial.degrees_add_of_disjoint
theorem degrees_map [CommSemiring S] (p : MvPolynomial σ R) (f : R →+* S) :
(map f p).degrees ⊆ p.degrees := by
classical
dsimp only [degrees]
apply Multiset.subset_of_le
apply Finset.sup_mono
apply MvPolynomial.support_map_subset
#align mv_polynomial.degrees_map MvPolynomial.degrees_map
theorem degrees_rename (f : σ → τ) (φ : MvPolynomial σ R) :
(rename f φ).degrees ⊆ φ.degrees.map f := by
classical
intro i
rw [mem_degrees, Multiset.mem_map]
rintro ⟨d, hd, hi⟩
obtain ⟨x, rfl, hx⟩ := coeff_rename_ne_zero _ _ _ hd
simp only [Finsupp.mapDomain, Finsupp.mem_support_iff] at hi
rw [sum_apply, Finsupp.sum] at hi
contrapose! hi
rw [Finset.sum_eq_zero]
intro j hj
simp only [exists_prop, mem_degrees] at hi
specialize hi j ⟨x, hx, hj⟩
rw [Finsupp.single_apply, if_neg hi]
#align mv_polynomial.degrees_rename MvPolynomial.degrees_rename
theorem degrees_map_of_injective [CommSemiring S] (p : MvPolynomial σ R) {f : R →+* S}
(hf : Injective f) : (map f p).degrees = p.degrees := by
simp only [degrees, MvPolynomial.support_map_of_injective _ hf]
#align mv_polynomial.degrees_map_of_injective MvPolynomial.degrees_map_of_injective
theorem degrees_rename_of_injective {p : MvPolynomial σ R} {f : σ → τ} (h : Function.Injective f) :
degrees (rename f p) = (degrees p).map f := by
classical
simp only [degrees, Multiset.map_finset_sup p.support Finsupp.toMultiset f h,
support_rename_of_injective h, Finset.sup_image]
refine Finset.sup_congr rfl fun x _ => ?_
exact (Finsupp.toMultiset_map _ _).symm
#align mv_polynomial.degrees_rename_of_injective MvPolynomial.degrees_rename_of_injective
end Degrees
section DegreeOf
/-! ### `degreeOf` -/
/-- `degreeOf n p` gives the highest power of X_n that appears in `p` -/
def degreeOf (n : σ) (p : MvPolynomial σ R) : ℕ :=
letI := Classical.decEq σ
p.degrees.count n
#align mv_polynomial.degree_of MvPolynomial.degreeOf
theorem degreeOf_def [DecidableEq σ] (n : σ) (p : MvPolynomial σ R) :
p.degreeOf n = p.degrees.count n := by rw [degreeOf]; convert rfl
#align mv_polynomial.degree_of_def MvPolynomial.degreeOf_def
theorem degreeOf_eq_sup (n : σ) (f : MvPolynomial σ R) :
degreeOf n f = f.support.sup fun m => m n := by
classical
rw [degreeOf_def, degrees, Multiset.count_finset_sup]
congr
ext
simp
#align mv_polynomial.degree_of_eq_sup MvPolynomial.degreeOf_eq_sup
| Mathlib/Algebra/MvPolynomial/Degrees.lean | 254 | 256 | theorem degreeOf_lt_iff {n : σ} {f : MvPolynomial σ R} {d : ℕ} (h : 0 < d) :
degreeOf n f < d ↔ ∀ m : σ →₀ ℕ, m ∈ f.support → m n < d := by |
rwa [degreeOf_eq_sup, Finset.sup_lt_iff]
|
/-
Copyright (c) 2022 Cuma Kökmen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Cuma Kökmen, Yury Kudryashov
-/
import Mathlib.MeasureTheory.Constructions.Prod.Integral
import Mathlib.MeasureTheory.Integral.CircleIntegral
#align_import measure_theory.integral.torus_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Integral over a torus in `ℂⁿ`
In this file we define the integral of a function `f : ℂⁿ → E` over a torus
`{z : ℂⁿ | ∀ i, z i ∈ Metric.sphere (c i) (R i)}`. In order to do this, we define
`torusMap (c : ℂⁿ) (R θ : ℝⁿ)` to be the point in `ℂⁿ` given by $z_k=c_k+R_ke^{θ_ki}$,
where $i$ is the imaginary unit, then define `torusIntegral f c R` as the integral over
the cube $[0, (fun _ ↦ 2π)] = \{θ\|∀ k, 0 ≤ θ_k ≤ 2π\}$ of the Jacobian of the
`torusMap` multiplied by `f (torusMap c R θ)`.
We also define a predicate saying that `f ∘ torusMap c R` is integrable on the cube
`[0, (fun _ ↦ 2π)]`.
## Main definitions
* `torusMap c R`: the generalized multidimensional exponential map from `ℝⁿ` to `ℂⁿ` that sends
$θ=(θ_0,…,θ_{n-1})$ to $z=(z_0,…,z_{n-1})$, where $z_k= c_k + R_ke^{θ_k i}$;
* `TorusIntegrable f c R`: a function `f : ℂⁿ → E` is integrable over the generalized torus
with center `c : ℂⁿ` and radius `R : ℝⁿ` if `f ∘ torusMap c R` is integrable on the
closed cube `Icc (0 : ℝⁿ) (fun _ ↦ 2 * π)`;
* `torusIntegral f c R`: the integral of a function `f : ℂⁿ → E` over a torus with
center `c ∈ ℂⁿ` and radius `R ∈ ℝⁿ` defined as
$\iiint_{[0, 2 * π]} (∏_{k = 1}^{n} i R_k e^{θ_k * i}) • f (c + Re^{θ_k i})\,dθ_0…dθ_{k-1}$.
## Main statements
* `torusIntegral_dim0`, `torusIntegral_dim1`, `torusIntegral_succ`: formulas for `torusIntegral`
in cases of dimension `0`, `1`, and `n + 1`.
## Notations
- `ℝ⁰`, `ℝ¹`, `ℝⁿ`, `ℝⁿ⁺¹`: local notation for `Fin 0 → ℝ`, `Fin 1 → ℝ`, `Fin n → ℝ`, and
`Fin (n + 1) → ℝ`, respectively;
- `ℂ⁰`, `ℂ¹`, `ℂⁿ`, `ℂⁿ⁺¹`: local notation for `Fin 0 → ℂ`, `Fin 1 → ℂ`, `Fin n → ℂ`, and
`Fin (n + 1) → ℂ`, respectively;
- `∯ z in T(c, R), f z`: notation for `torusIntegral f c R`;
- `∮ z in C(c, R), f z`: notation for `circleIntegral f c R`, defined elsewhere;
- `∏ k, f k`: notation for `Finset.prod`, defined elsewhere;
- `π`: notation for `Real.pi`, defined elsewhere.
## Tags
integral, torus
-/
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)
/-!
### `torusMap`, a parametrization of a torus
-/
/-- The n dimensional exponential map $θ_i ↦ c + R e^{θ_i*I}, θ ∈ ℝⁿ$ representing
a torus in `ℂⁿ` with center `c ∈ ℂⁿ` and generalized radius `R ∈ ℝⁿ`, so we can adjust
it to every n axis. -/
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
/-!
### Integrability of a function on a generalized torus
-/
/-- A function `f : ℂⁿ → E` is integrable on the generalized torus if the function
`f ∘ torusMap c R θ` is integrable on `Icc (0 : ℝⁿ) (fun _ ↦ 2 * π)`. -/
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 → ℝ}
/-- Constant functions are torus integrable -/
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
/-- If `f` is torus integrable then `-f` is torus integrable. -/
protected nonrec theorem neg (hf : TorusIntegrable f c R) : TorusIntegrable (-f) c R := hf.neg
#align torus_integrable.neg TorusIntegrable.neg
/-- If `f` and `g` are two torus integrable functions, then so is `f + g`. -/
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
/-- If `f` and `g` are two torus integrable functions, then so is `f - g`. -/
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
theorem torusIntegrable_zero_radius {f : ℂⁿ → E} {c : ℂⁿ} : TorusIntegrable f c 0 := by
rw [TorusIntegrable, torusMap_zero_radius]
apply torusIntegrable_const (f c) c 0
#align torus_integrable.torus_integrable_zero_radius TorusIntegrable.torusIntegrable_zero_radius
/-- The function given in the definition of `torusIntegral` is integrable. -/
theorem function_integrable [NormedSpace ℂ E] (hf : TorusIntegrable f c R) :
IntegrableOn (fun θ : ℝⁿ => (∏ i, R i * exp (θ i * I) * I : ℂ) • f (torusMap c R θ))
(Icc (0 : ℝⁿ) fun _ => 2 * π) volume := by
refine (hf.norm.const_mul (∏ i, |R i|)).mono' ?_ ?_
· refine (Continuous.aestronglyMeasurable ?_).smul hf.1; continuity
simp [norm_smul, map_prod]
#align torus_integrable.function_integrable TorusIntegrable.function_integrable
end TorusIntegrable
variable [NormedSpace ℂ E] [CompleteSpace E] {f g : (Fin n → ℂ) → E} {c : Fin n → ℂ} {R : Fin n → ℝ}
/-- The integral over a generalized torus with center `c ∈ ℂⁿ` and radius `R ∈ ℝⁿ`, defined
as the `•`-product of the derivative of `torusMap` and `f (torusMap c R θ)`-/
def torusIntegral (f : ℂⁿ → E) (c : ℂⁿ) (R : ℝⁿ) :=
∫ θ : ℝⁿ in Icc (0 : ℝⁿ) fun _ => 2 * π, (∏ i, R i * exp (θ i * I) * I : ℂ) • f (torusMap c R θ)
#align torus_integral torusIntegral
@[inherit_doc torusIntegral]
notation3"∯ "(...)" in ""T("c", "R")"", "r:(scoped f => torusIntegral f c R) => r
theorem torusIntegral_radius_zero (hn : n ≠ 0) (f : ℂⁿ → E) (c : ℂⁿ) :
(∯ x in T(c, 0), f x) = 0 := by
simp only [torusIntegral, Pi.zero_apply, ofReal_zero, mul_zero, zero_mul, Fin.prod_const,
zero_pow hn, zero_smul, integral_zero]
#align torus_integral_radius_zero torusIntegral_radius_zero
theorem torusIntegral_neg (f : ℂⁿ → E) (c : ℂⁿ) (R : ℝⁿ) :
(∯ x in T(c, R), -f x) = -∯ x in T(c, R), f x := by simp [torusIntegral, integral_neg]
#align torus_integral_neg torusIntegral_neg
theorem torusIntegral_add (hf : TorusIntegrable f c R) (hg : TorusIntegrable g c R) :
(∯ x in T(c, R), f x + g x) = (∯ x in T(c, R), f x) + ∯ x in T(c, R), g x := by
simpa only [torusIntegral, smul_add, Pi.add_apply] using
integral_add hf.function_integrable hg.function_integrable
#align torus_integral_add torusIntegral_add
theorem torusIntegral_sub (hf : TorusIntegrable f c R) (hg : TorusIntegrable g c R) :
(∯ x in T(c, R), f x - g x) = (∯ x in T(c, R), f x) - ∯ x in T(c, R), g x := by
simpa only [sub_eq_add_neg, ← torusIntegral_neg] using torusIntegral_add hf hg.neg
#align torus_integral_sub torusIntegral_sub
theorem torusIntegral_smul {𝕜 : Type*} [RCLike 𝕜] [NormedSpace 𝕜 E] [SMulCommClass 𝕜 ℂ E] (a : 𝕜)
(f : ℂⁿ → E) (c : ℂⁿ) (R : ℝⁿ) : (∯ x in T(c, R), a • f x) = a • ∯ x in T(c, R), f x := by
simp only [torusIntegral, integral_smul, ← smul_comm a (_ : ℂ) (_ : E)]
#align torus_integral_smul torusIntegral_smul
theorem torusIntegral_const_mul (a : ℂ) (f : ℂⁿ → ℂ) (c : ℂⁿ) (R : ℝⁿ) :
(∯ x in T(c, R), a * f x) = a * ∯ x in T(c, R), f x :=
torusIntegral_smul a f c R
#align torus_integral_const_mul torusIntegral_const_mul
/-- If for all `θ : ℝⁿ`, `‖f (torusMap c R θ)‖` is less than or equal to a constant `C : ℝ`, then
`‖∯ x in T(c, R), f x‖` is less than or equal to `(2 * π)^n * (∏ i, |R i|) * C`-/
| Mathlib/MeasureTheory/Integral/TorusIntegral.lean | 193 | 204 | theorem norm_torusIntegral_le_of_norm_le_const {C : ℝ} (hf : ∀ θ, ‖f (torusMap c R θ)‖ ≤ C) :
‖∯ x in T(c, R), f x‖ ≤ ((2 * π) ^ (n : ℕ) * ∏ i, |R i|) * C :=
calc
‖∯ x in T(c, R), f x‖ ≤ (∏ i, |R i|) * C * (volume (Icc (0 : ℝⁿ) fun _ => 2 * π)).toReal :=
norm_setIntegral_le_of_norm_le_const' measure_Icc_lt_top measurableSet_Icc fun θ _ =>
calc
‖(∏ i : Fin n, R i * exp (θ i * I) * I : ℂ) • f (torusMap c R θ)‖ =
(∏ i : Fin n, |R i|) * ‖f (torusMap c R θ)‖ := by | simp [norm_smul]
_ ≤ (∏ i : Fin n, |R i|) * C := mul_le_mul_of_nonneg_left (hf _) <| by positivity
_ = ((2 * π) ^ (n : ℕ) * ∏ i, |R i|) * C := by
simp only [Pi.zero_def, Real.volume_Icc_pi_toReal fun _ => Real.two_pi_pos.le, sub_zero,
Fin.prod_const, mul_assoc, mul_comm ((2 * π) ^ (n : ℕ))]
|
/-
Copyright (c) 2019 Calle Sönne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Calle Sönne
-/
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"
/-!
# The type of angles
In this file we define `Real.Angle` to be the quotient group `ℝ/2πℤ` and prove a few simple lemmas
about trigonometric functions and angles.
-/
open Real
noncomputable section
namespace Real
-- Porting note: can't derive `NormedAddCommGroup, Inhabited`
/-- The type of angles -/
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 * π)`
/-- The canonical map from `ℝ` to the quotient `Angle`. -/
@[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
/-- Coercion `ℝ → Angle` as an additive homomorphism. -/
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
/-- An induction principle to deduce results for `Angle` from those for `ℝ`, used with
`induction θ using Real.Angle.induction_on`. -/
@[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
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean | 160 | 161 | theorem sub_coe_pi_eq_add_coe_pi (θ : Angle) : θ - π = θ + π := by |
rw [sub_eq_add_neg, neg_coe_pi]
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura, Floris van Doorn, Yury Kudryashov, Neil Strickland
-/
import Mathlib.Algebra.Group.Defs
import Mathlib.Algebra.GroupWithZero.Defs
import Mathlib.Data.Int.Cast.Defs
import Mathlib.Tactic.Spread
import Mathlib.Util.AssertExists
#align_import algebra.ring.defs from "leanprover-community/mathlib"@"76de8ae01554c3b37d66544866659ff174e66e1f"
/-!
# Semirings and rings
This file defines semirings, rings and domains. This is analogous to `Algebra.Group.Defs` and
`Algebra.Group.Basic`, the difference being that the former is about `+` and `*` separately, while
the present file is about their interaction.
## Main definitions
* `Distrib`: Typeclass for distributivity of multiplication over addition.
* `HasDistribNeg`: Typeclass for commutativity of negation and multiplication. This is useful when
dealing with multiplicative submonoids which are closed under negation without being closed under
addition, for example `Units`.
* `(NonUnital)(NonAssoc)(Semi)Ring`: Typeclasses for possibly non-unital or non-associative
rings and semirings. Some combinations are not defined yet because they haven't found use.
## Tags
`Semiring`, `CommSemiring`, `Ring`, `CommRing`, domain, `IsDomain`, nonzero, units
-/
universe u v w x
variable {α : Type u} {β : Type v} {γ : Type w} {R : Type x}
open Function
/-!
### `Distrib` class
-/
/-- A typeclass stating that multiplication is left and right distributive
over addition. -/
class Distrib (R : Type*) extends Mul R, Add R where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
#align distrib Distrib
/-- A typeclass stating that multiplication is left distributive over addition. -/
class LeftDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is left distributive over addition -/
protected left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c
#align left_distrib_class LeftDistribClass
/-- A typeclass stating that multiplication is right distributive over addition. -/
class RightDistribClass (R : Type*) [Mul R] [Add R] : Prop where
/-- Multiplication is right distributive over addition -/
protected right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c
#align right_distrib_class RightDistribClass
-- see Note [lower instance priority]
instance (priority := 100) Distrib.leftDistribClass (R : Type*) [Distrib R] : LeftDistribClass R :=
⟨Distrib.left_distrib⟩
#align distrib.left_distrib_class Distrib.leftDistribClass
-- see Note [lower instance priority]
instance (priority := 100) Distrib.rightDistribClass (R : Type*) [Distrib R] :
RightDistribClass R :=
⟨Distrib.right_distrib⟩
#align distrib.right_distrib_class Distrib.rightDistribClass
theorem left_distrib [Mul R] [Add R] [LeftDistribClass R] (a b c : R) :
a * (b + c) = a * b + a * c :=
LeftDistribClass.left_distrib a b c
#align left_distrib left_distrib
alias mul_add := left_distrib
#align mul_add mul_add
theorem right_distrib [Mul R] [Add R] [RightDistribClass R] (a b c : R) :
(a + b) * c = a * c + b * c :=
RightDistribClass.right_distrib a b c
#align right_distrib right_distrib
alias add_mul := right_distrib
#align add_mul add_mul
theorem distrib_three_right [Mul R] [Add R] [RightDistribClass R] (a b c d : R) :
(a + b + c) * d = a * d + b * d + c * d := by simp [right_distrib]
#align distrib_three_right distrib_three_right
/-!
### Classes of semirings and rings
We make sure that the canonical path from `NonAssocSemiring` to `Ring` passes through `Semiring`,
as this is a path which is followed all the time in linear algebra where the defining semilinear map
`σ : R →+* S` depends on the `NonAssocSemiring` structure of `R` and `S` while the module
definition depends on the `Semiring` structure.
It is not currently possible to adjust priorities by hand (see lean4#2115). Instead, the last
declared instance is used, so we make sure that `Semiring` is declared after `NonAssocRing`, so
that `Semiring -> NonAssocSemiring` is tried before `NonAssocRing -> NonAssocSemiring`.
TODO: clean this once lean4#2115 is fixed
-/
/-- A not-necessarily-unital, not-necessarily-associative semiring. -/
class NonUnitalNonAssocSemiring (α : Type u) extends AddCommMonoid α, Distrib α, MulZeroClass α
#align non_unital_non_assoc_semiring NonUnitalNonAssocSemiring
/-- An associative but not-necessarily unital semiring. -/
class NonUnitalSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, SemigroupWithZero α
#align non_unital_semiring NonUnitalSemiring
/-- A unital but not-necessarily-associative semiring. -/
class NonAssocSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, MulZeroOneClass α,
AddCommMonoidWithOne α
#align non_assoc_semiring NonAssocSemiring
/-- A not-necessarily-unital, not-necessarily-associative ring. -/
class NonUnitalNonAssocRing (α : Type u) extends AddCommGroup α, NonUnitalNonAssocSemiring α
#align non_unital_non_assoc_ring NonUnitalNonAssocRing
/-- An associative but not-necessarily unital ring. -/
class NonUnitalRing (α : Type*) extends NonUnitalNonAssocRing α, NonUnitalSemiring α
#align non_unital_ring NonUnitalRing
/-- A unital but not-necessarily-associative ring. -/
class NonAssocRing (α : Type*) extends NonUnitalNonAssocRing α, NonAssocSemiring α,
AddCommGroupWithOne α
#align non_assoc_ring NonAssocRing
/-- A `Semiring` is a type with addition, multiplication, a `0` and a `1` where addition is
commutative and associative, multiplication is associative and left and right distributive over
addition, and `0` and `1` are additive and multiplicative identities. -/
class Semiring (α : Type u) extends NonUnitalSemiring α, NonAssocSemiring α, MonoidWithZero α
#align semiring Semiring
/-- A `Ring` is a `Semiring` with negation making it an additive group. -/
class Ring (R : Type u) extends Semiring R, AddCommGroup R, AddGroupWithOne R
#align ring Ring
/-!
### Semirings
-/
section DistribMulOneClass
variable [Add α] [MulOneClass α]
theorem add_one_mul [RightDistribClass α] (a b : α) : (a + 1) * b = a * b + b := by
rw [add_mul, one_mul]
#align add_one_mul add_one_mul
theorem mul_add_one [LeftDistribClass α] (a b : α) : a * (b + 1) = a * b + a := by
rw [mul_add, mul_one]
#align mul_add_one mul_add_one
theorem one_add_mul [RightDistribClass α] (a b : α) : (1 + a) * b = b + a * b := by
rw [add_mul, one_mul]
#align one_add_mul one_add_mul
theorem mul_one_add [LeftDistribClass α] (a b : α) : a * (1 + b) = a + a * b := by
rw [mul_add, mul_one]
#align mul_one_add mul_one_add
end DistribMulOneClass
section NonAssocSemiring
variable [NonAssocSemiring α]
-- Porting note: was [has_add α] [mul_one_class α] [right_distrib_class α]
theorem two_mul (n : α) : 2 * n = n + n :=
(congrArg₂ _ one_add_one_eq_two.symm rfl).trans <| (right_distrib 1 1 n).trans (by rw [one_mul])
#align two_mul two_mul
-- Porting note: was [has_add α] [mul_one_class α] [right_distrib_class α]
set_option linter.deprecated false in
theorem bit0_eq_two_mul (n : α) : bit0 n = 2 * n :=
(two_mul _).symm
#align bit0_eq_two_mul bit0_eq_two_mul
-- Porting note: was [has_add α] [mul_one_class α] [left_distrib_class α]
theorem mul_two (n : α) : n * 2 = n + n :=
(congrArg₂ _ rfl one_add_one_eq_two.symm).trans <| (left_distrib n 1 1).trans (by rw [mul_one])
#align mul_two mul_two
end NonAssocSemiring
@[to_additive]
theorem mul_ite {α} [Mul α] (P : Prop) [Decidable P] (a b c : α) :
(a * if P then b else c) = if P then a * b else a * c := by split_ifs <;> rfl
#align mul_ite mul_ite
#align add_ite add_ite
@[to_additive]
theorem ite_mul {α} [Mul α] (P : Prop) [Decidable P] (a b c : α) :
(if P then a else b) * c = if P then a * c else b * c := by split_ifs <;> rfl
#align ite_mul ite_mul
#align ite_add ite_add
-- We make `mul_ite` and `ite_mul` simp lemmas,
-- but not `add_ite` or `ite_add`.
-- The problem we're trying to avoid is dealing with
-- summations of the form `∑ x ∈ s, (f x + ite P 1 0)`,
-- in which `add_ite` followed by `sum_ite` would needlessly slice up
-- the `f x` terms according to whether `P` holds at `x`.
-- There doesn't appear to be a corresponding difficulty so far with
-- `mul_ite` and `ite_mul`.
attribute [simp] mul_ite ite_mul
theorem ite_sub_ite {α} [Sub α] (P : Prop) [Decidable P] (a b c d : α) :
((if P then a else b) - if P then c else d) = if P then a - c else b - d := by
split
repeat rfl
theorem ite_add_ite {α} [Add α] (P : Prop) [Decidable P] (a b c d : α) :
((if P then a else b) + if P then c else d) = if P then a + c else b + d := by
split
repeat rfl
section MulZeroClass
variable [MulZeroClass α] (P Q : Prop) [Decidable P] [Decidable Q] (a b : α)
lemma ite_zero_mul : ite P a 0 * b = ite P (a * b) 0 := by simp
#align ite_mul_zero_left ite_zero_mul
lemma mul_ite_zero : a * ite P b 0 = ite P (a * b) 0 := by simp
#align ite_mul_zero_right mul_ite_zero
lemma ite_zero_mul_ite_zero : ite P a 0 * ite Q b 0 = ite (P ∧ Q) (a * b) 0 := by
simp only [← ite_and, ite_mul, mul_ite, mul_zero, zero_mul, and_comm]
#align ite_and_mul_zero ite_zero_mul_ite_zero
end MulZeroClass
-- Porting note: no @[simp] because simp proves it
theorem mul_boole {α} [MulZeroOneClass α] (P : Prop) [Decidable P] (a : α) :
(a * if P then 1 else 0) = if P then a else 0 := by simp
#align mul_boole mul_boole
-- Porting note: no @[simp] because simp proves it
theorem boole_mul {α} [MulZeroOneClass α] (P : Prop) [Decidable P] (a : α) :
(if P then 1 else 0) * a = if P then a else 0 := by simp
#align boole_mul boole_mul
/-- A not-necessarily-unital, not-necessarily-associative, but commutative semiring. -/
class NonUnitalNonAssocCommSemiring (α : Type u) extends NonUnitalNonAssocSemiring α, CommMagma α
/-- A non-unital commutative semiring is a `NonUnitalSemiring` with commutative multiplication.
In other words, it is a type with the following structures: additive commutative monoid
(`AddCommMonoid`), commutative semigroup (`CommSemigroup`), distributive laws (`Distrib`), and
multiplication by zero law (`MulZeroClass`). -/
class NonUnitalCommSemiring (α : Type u) extends NonUnitalSemiring α, CommSemigroup α
#align non_unital_comm_semiring NonUnitalCommSemiring
/-- A commutative semiring is a semiring with commutative multiplication. -/
class CommSemiring (R : Type u) extends Semiring R, CommMonoid R
#align comm_semiring CommSemiring
-- see Note [lower instance priority]
instance (priority := 100) CommSemiring.toNonUnitalCommSemiring [CommSemiring α] :
NonUnitalCommSemiring α :=
{ inferInstanceAs (CommMonoid α), inferInstanceAs (CommSemiring α) with }
#align comm_semiring.to_non_unital_comm_semiring CommSemiring.toNonUnitalCommSemiring
-- see Note [lower instance priority]
instance (priority := 100) CommSemiring.toCommMonoidWithZero [CommSemiring α] :
CommMonoidWithZero α :=
{ inferInstanceAs (CommMonoid α), inferInstanceAs (CommSemiring α) with }
#align comm_semiring.to_comm_monoid_with_zero CommSemiring.toCommMonoidWithZero
section CommSemiring
variable [CommSemiring α] {a b c : α}
theorem add_mul_self_eq (a b : α) : (a + b) * (a + b) = a * a + 2 * a * b + b * b := by
simp only [two_mul, add_mul, mul_add, add_assoc, mul_comm b]
#align add_mul_self_eq add_mul_self_eq
lemma add_sq (a b : α) : (a + b) ^ 2 = a ^ 2 + 2 * a * b + b ^ 2 := by
simp only [sq, add_mul_self_eq]
#align add_sq add_sq
lemma add_sq' (a b : α) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b := by
rw [add_sq, add_assoc, add_comm _ (b ^ 2), add_assoc]
#align add_sq' add_sq'
alias add_pow_two := add_sq
#align add_pow_two add_pow_two
end CommSemiring
section HasDistribNeg
/-- Typeclass for a negation operator that distributes across multiplication.
This is useful for dealing with submonoids of a ring that contain `-1` without having to duplicate
lemmas. -/
class HasDistribNeg (α : Type*) [Mul α] extends InvolutiveNeg α where
/-- Negation is left distributive over multiplication -/
neg_mul : ∀ x y : α, -x * y = -(x * y)
/-- Negation is right distributive over multiplication -/
mul_neg : ∀ x y : α, x * -y = -(x * y)
#align has_distrib_neg HasDistribNeg
section Mul
variable [Mul α] [HasDistribNeg α]
@[simp]
theorem neg_mul (a b : α) : -a * b = -(a * b) :=
HasDistribNeg.neg_mul _ _
#align neg_mul neg_mul
@[simp]
theorem mul_neg (a b : α) : a * -b = -(a * b) :=
HasDistribNeg.mul_neg _ _
#align mul_neg mul_neg
| Mathlib/Algebra/Ring/Defs.lean | 327 | 327 | theorem neg_mul_neg (a b : α) : -a * -b = a * b := by | simp
|
/-
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
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"
/-!
# Streams a.k.a. infinite lists a.k.a. infinite sequences
Porting note:
This file used to be in the core library. It was moved to `mathlib` and renamed to `init` to avoid
name clashes. -/
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
section Map
variable (f : α → β)
theorem drop_map (n : Nat) (s : Stream' α) : drop n (map f s) = map f (drop n s) :=
Stream'.ext fun _ => rfl
#align stream.drop_map Stream'.drop_map
@[simp]
theorem get_map (n : Nat) (s : Stream' α) : get (map f s) n = f (get s n) :=
rfl
#align stream.nth_map Stream'.get_map
theorem tail_map (s : Stream' α) : tail (map f s) = map f (tail s) := rfl
#align stream.tail_map Stream'.tail_map
@[simp]
theorem head_map (s : Stream' α) : head (map f s) = f (head s) :=
rfl
#align stream.head_map Stream'.head_map
theorem map_eq (s : Stream' α) : map f s = f (head s)::map f (tail s) := by
rw [← Stream'.eta (map f s), tail_map, head_map]
#align stream.map_eq Stream'.map_eq
theorem map_cons (a : α) (s : Stream' α) : map f (a::s) = f a::map f s := by
rw [← Stream'.eta (map f (a::s)), map_eq]; rfl
#align stream.map_cons Stream'.map_cons
@[simp]
theorem map_id (s : Stream' α) : map id s = s :=
rfl
#align stream.map_id Stream'.map_id
@[simp]
theorem map_map (g : β → δ) (f : α → β) (s : Stream' α) : map g (map f s) = map (g ∘ f) s :=
rfl
#align stream.map_map Stream'.map_map
@[simp]
theorem map_tail (s : Stream' α) : map f (tail s) = tail (map f s) :=
rfl
#align stream.map_tail Stream'.map_tail
theorem mem_map {a : α} {s : Stream' α} : a ∈ s → f a ∈ map f s := fun ⟨n, h⟩ =>
Exists.intro n (by rw [get_map, h])
#align stream.mem_map Stream'.mem_map
theorem exists_of_mem_map {f} {b : β} {s : Stream' α} : b ∈ map f s → ∃ a, a ∈ s ∧ f a = b :=
fun ⟨n, h⟩ => ⟨get s n, ⟨n, rfl⟩, h.symm⟩
#align stream.exists_of_mem_map Stream'.exists_of_mem_map
end Map
section Zip
variable (f : α → β → δ)
theorem drop_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
drop n (zip f s₁ s₂) = zip f (drop n s₁) (drop n s₂) :=
Stream'.ext fun _ => rfl
#align stream.drop_zip Stream'.drop_zip
@[simp]
theorem get_zip (n : Nat) (s₁ : Stream' α) (s₂ : Stream' β) :
get (zip f s₁ s₂) n = f (get s₁ n) (get s₂ n) :=
rfl
#align stream.nth_zip Stream'.get_zip
theorem head_zip (s₁ : Stream' α) (s₂ : Stream' β) : head (zip f s₁ s₂) = f (head s₁) (head s₂) :=
rfl
#align stream.head_zip Stream'.head_zip
theorem tail_zip (s₁ : Stream' α) (s₂ : Stream' β) :
tail (zip f s₁ s₂) = zip f (tail s₁) (tail s₂) :=
rfl
#align stream.tail_zip Stream'.tail_zip
theorem zip_eq (s₁ : Stream' α) (s₂ : Stream' β) :
zip f s₁ s₂ = f (head s₁) (head s₂)::zip f (tail s₁) (tail s₂) := by
rw [← Stream'.eta (zip f s₁ s₂)]; rfl
#align stream.zip_eq Stream'.zip_eq
@[simp]
theorem get_enum (s : Stream' α) (n : ℕ) : get (enum s) n = (n, s.get n) :=
rfl
#align stream.nth_enum Stream'.get_enum
theorem enum_eq_zip (s : Stream' α) : enum s = zip Prod.mk nats s :=
rfl
#align stream.enum_eq_zip Stream'.enum_eq_zip
end Zip
@[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
section Bisim
variable (R : Stream' α → Stream' α → Prop)
/-- equivalence relation -/
local infixl:50 " ~ " => R
/-- Streams `s₁` and `s₂` are defined to be bisimulations if
their heads are equal and tails are bisimulations. -/
def IsBisimulation :=
∀ ⦃s₁ s₂⦄, s₁ ~ s₂ →
head s₁ = head s₂ ∧ tail s₁ ~ tail s₂
#align stream.is_bisimulation Stream'.IsBisimulation
theorem get_of_bisim (bisim : IsBisimulation R) :
∀ {s₁ s₂} (n), s₁ ~ s₂ → get s₁ n = get s₂ n ∧ drop (n + 1) s₁ ~ drop (n + 1) s₂
| _, _, 0, h => bisim h
| _, _, n + 1, h =>
match bisim h with
| ⟨_, trel⟩ => get_of_bisim bisim n trel
#align stream.nth_of_bisim Stream'.get_of_bisim
-- If two streams are bisimilar, then they are equal
theorem eq_of_bisim (bisim : IsBisimulation R) : ∀ {s₁ s₂}, s₁ ~ s₂ → s₁ = s₂ := fun r =>
Stream'.ext fun n => And.left (get_of_bisim R bisim n r)
#align stream.eq_of_bisim Stream'.eq_of_bisim
end Bisim
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
section Corec
theorem corec_def (f : α → β) (g : α → α) (a : α) : corec f g a = map f (iterate g a) :=
rfl
#align stream.corec_def Stream'.corec_def
theorem corec_eq (f : α → β) (g : α → α) (a : α) : corec f g a = f a::corec f g (g a) := by
rw [corec_def, map_eq, head_iterate, tail_iterate]; rfl
#align stream.corec_eq Stream'.corec_eq
theorem corec_id_id_eq_const (a : α) : corec id id a = const a := by
rw [corec_def, map_id, iterate_id]
#align stream.corec_id_id_eq_const Stream'.corec_id_id_eq_const
theorem corec_id_f_eq_iterate (f : α → α) (a : α) : corec id f a = iterate f a :=
rfl
#align stream.corec_id_f_eq_iterate Stream'.corec_id_f_eq_iterate
end Corec
section Corec'
theorem corec'_eq (f : α → β × α) (a : α) : corec' f a = (f a).1::corec' f (f a).2 :=
corec_eq _ _ _
#align stream.corec'_eq Stream'.corec'_eq
end Corec'
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
| Mathlib/Data/Stream/Init.lean | 644 | 657 | 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
|
/-
Copyright (c) 2020 Markus Himmel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Markus Himmel
-/
import Mathlib.CategoryTheory.Comma.Basic
#align_import category_theory.arrow from "leanprover-community/mathlib"@"32253a1a1071173b33dc7d6a218cf722c6feb514"
/-!
# The category of arrows
The category of arrows, with morphisms commutative squares.
We set this up as a specialization of the comma category `Comma L R`,
where `L` and `R` are both the identity functor.
## Tags
comma, arrow
-/
namespace CategoryTheory
universe v u
-- morphism levels before object levels. See note [CategoryTheory universes].
variable {T : Type u} [Category.{v} T]
section
variable (T)
/-- The arrow category of `T` has as objects all morphisms in `T` and as morphisms commutative
squares in `T`. -/
def Arrow :=
Comma.{v, v, v} (𝟭 T) (𝟭 T)
#align category_theory.arrow CategoryTheory.Arrow
/- Porting note: could not derive `Category` above so this instance works in its place-/
instance : Category (Arrow T) := commaCategory
-- Satisfying the inhabited linter
instance Arrow.inhabited [Inhabited T] : Inhabited (Arrow T) where
default := show Comma (𝟭 T) (𝟭 T) from default
#align category_theory.arrow.inhabited CategoryTheory.Arrow.inhabited
end
namespace Arrow
@[ext]
lemma hom_ext {X Y : Arrow T} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
CommaMorphism.ext _ _ h₁ h₂
@[simp]
theorem id_left (f : Arrow T) : CommaMorphism.left (𝟙 f) = 𝟙 f.left :=
rfl
#align category_theory.arrow.id_left CategoryTheory.Arrow.id_left
@[simp]
theorem id_right (f : Arrow T) : CommaMorphism.right (𝟙 f) = 𝟙 f.right :=
rfl
#align category_theory.arrow.id_right CategoryTheory.Arrow.id_right
-- Porting note (#10688): added to ease automation
@[simp, reassoc]
theorem comp_left {X Y Z : Arrow T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).left = f.left ≫ g.left := rfl
-- Porting note (#10688): added to ease automation
@[simp, reassoc]
theorem comp_right {X Y Z : Arrow T} (f : X ⟶ Y) (g : Y ⟶ Z) :
(f ≫ g).right = f.right ≫ g.right := rfl
/-- An object in the arrow category is simply a morphism in `T`. -/
@[simps]
def mk {X Y : T} (f : X ⟶ Y) : Arrow T where
left := X
right := Y
hom := f
#align category_theory.arrow.mk CategoryTheory.Arrow.mk
@[simp]
theorem mk_eq (f : Arrow T) : Arrow.mk f.hom = f := by
cases f
rfl
#align category_theory.arrow.mk_eq CategoryTheory.Arrow.mk_eq
theorem mk_injective (A B : T) :
Function.Injective (Arrow.mk : (A ⟶ B) → Arrow T) := fun f g h => by
cases h
rfl
#align category_theory.arrow.mk_injective CategoryTheory.Arrow.mk_injective
theorem mk_inj (A B : T) {f g : A ⟶ B} : Arrow.mk f = Arrow.mk g ↔ f = g :=
(mk_injective A B).eq_iff
#align category_theory.arrow.mk_inj CategoryTheory.Arrow.mk_inj
/- Porting note: was marked as dangerous instance so changed from `Coe` to `CoeOut` -/
instance {X Y : T} : CoeOut (X ⟶ Y) (Arrow T) where
coe := mk
/-- A morphism in the arrow category is a commutative square connecting two objects of the arrow
category. -/
@[simps]
def homMk {f g : Arrow T} {u : f.left ⟶ g.left} {v : f.right ⟶ g.right}
(w : u ≫ g.hom = f.hom ≫ v) : f ⟶ g where
left := u
right := v
w := w
#align category_theory.arrow.hom_mk CategoryTheory.Arrow.homMk
/-- We can also build a morphism in the arrow category out of any commutative square in `T`. -/
@[simps]
def homMk' {X Y : T} {f : X ⟶ Y} {P Q : T} {g : P ⟶ Q} {u : X ⟶ P} {v : Y ⟶ Q} (w : u ≫ g = f ≫ v) :
Arrow.mk f ⟶ Arrow.mk g where
left := u
right := v
w := w
#align category_theory.arrow.hom_mk' CategoryTheory.Arrow.homMk'
/- Porting note: was warned simp could prove reassoc'd version. Found simp could not.
Added nolint. -/
@[reassoc (attr := simp, nolint simpNF)]
theorem w {f g : Arrow T} (sq : f ⟶ g) : sq.left ≫ g.hom = f.hom ≫ sq.right :=
sq.w
#align category_theory.arrow.w CategoryTheory.Arrow.w
-- `w_mk_left` is not needed, as it is a consequence of `w` and `mk_hom`.
@[reassoc (attr := simp)]
theorem w_mk_right {f : Arrow T} {X Y : T} {g : X ⟶ Y} (sq : f ⟶ mk g) :
sq.left ≫ g = f.hom ≫ sq.right :=
sq.w
#align category_theory.arrow.w_mk_right CategoryTheory.Arrow.w_mk_right
theorem isIso_of_isIso_left_of_isIso_right {f g : Arrow T} (ff : f ⟶ g) [IsIso ff.left]
[IsIso ff.right] : IsIso ff where
out := by
let inverse : g ⟶ f := ⟨inv ff.left, inv ff.right, (by simp)⟩
apply Exists.intro inverse
aesop_cat
#align category_theory.arrow.is_iso_of_iso_left_of_is_iso_right CategoryTheory.Arrow.isIso_of_isIso_left_of_isIso_right
/-- Create an isomorphism between arrows,
by providing isomorphisms between the domains and codomains,
and a proof that the square commutes. -/
@[simps!]
def isoMk {f g : Arrow T} (l : f.left ≅ g.left) (r : f.right ≅ g.right)
(h : l.hom ≫ g.hom = f.hom ≫ r.hom := by aesop_cat) : f ≅ g :=
Comma.isoMk l r h
#align category_theory.arrow.iso_mk CategoryTheory.Arrow.isoMk
/-- A variant of `Arrow.isoMk` that creates an iso between two `Arrow.mk`s with a better type
signature. -/
abbrev isoMk' {W X Y Z : T} (f : W ⟶ X) (g : Y ⟶ Z) (e₁ : W ≅ Y) (e₂ : X ≅ Z)
(h : e₁.hom ≫ g = f ≫ e₂.hom := by aesop_cat) : Arrow.mk f ≅ Arrow.mk g :=
Arrow.isoMk e₁ e₂ h
#align category_theory.arrow.iso_mk' CategoryTheory.Arrow.isoMk'
theorem hom.congr_left {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.left = φ₂.left := by
rw [h]
#align category_theory.arrow.hom.congr_left CategoryTheory.Arrow.hom.congr_left
@[simp]
theorem hom.congr_right {f g : Arrow T} {φ₁ φ₂ : f ⟶ g} (h : φ₁ = φ₂) : φ₁.right = φ₂.right := by
rw [h]
#align category_theory.arrow.hom.congr_right CategoryTheory.Arrow.hom.congr_right
theorem iso_w {f g : Arrow T} (e : f ≅ g) : g.hom = e.inv.left ≫ f.hom ≫ e.hom.right := by
have eq := Arrow.hom.congr_right e.inv_hom_id
rw [Arrow.comp_right, Arrow.id_right] at eq
erw [Arrow.w_assoc, eq, Category.comp_id]
#align category_theory.arrow.iso_w CategoryTheory.Arrow.iso_w
theorem iso_w' {W X Y Z : T} {f : W ⟶ X} {g : Y ⟶ Z} (e : Arrow.mk f ≅ Arrow.mk g) :
g = e.inv.left ≫ f ≫ e.hom.right :=
iso_w e
#align category_theory.arrow.iso_w' CategoryTheory.Arrow.iso_w'
section
variable {f g : Arrow T} (sq : f ⟶ g)
instance isIso_left [IsIso sq] : IsIso sq.left where
out := by
apply Exists.intro (inv sq).left
simp only [← Comma.comp_left, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_left,
eq_self_iff_true, and_self_iff]
simp
#align category_theory.arrow.is_iso_left CategoryTheory.Arrow.isIso_left
instance isIso_right [IsIso sq] : IsIso sq.right where
out := by
apply Exists.intro (inv sq).right
simp only [← Comma.comp_right, IsIso.hom_inv_id, IsIso.inv_hom_id, Arrow.id_right,
eq_self_iff_true, and_self_iff]
simp
#align category_theory.arrow.is_iso_right CategoryTheory.Arrow.isIso_right
@[simp]
theorem inv_left [IsIso sq] : (inv sq).left = inv sq.left :=
IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_left, IsIso.hom_inv_id, id_left]
#align category_theory.arrow.inv_left CategoryTheory.Arrow.inv_left
@[simp]
theorem inv_right [IsIso sq] : (inv sq).right = inv sq.right :=
IsIso.eq_inv_of_hom_inv_id <| by rw [← Comma.comp_right, IsIso.hom_inv_id, id_right]
#align category_theory.arrow.inv_right CategoryTheory.Arrow.inv_right
/- Porting note (#10618): simp can prove this so removed @[simp] -/
theorem left_hom_inv_right [IsIso sq] : sq.left ≫ g.hom ≫ inv sq.right = f.hom := by
simp only [← Category.assoc, IsIso.comp_inv_eq, w]
#align category_theory.arrow.left_hom_inv_right CategoryTheory.Arrow.left_hom_inv_right
-- simp proves this
theorem inv_left_hom_right [IsIso sq] : inv sq.left ≫ f.hom ≫ sq.right = g.hom := by
simp only [w, IsIso.inv_comp_eq]
#align category_theory.arrow.inv_left_hom_right CategoryTheory.Arrow.inv_left_hom_right
instance mono_left [Mono sq] : Mono sq.left where
right_cancellation {Z} φ ψ h := by
let aux : (Z ⟶ f.left) → (Arrow.mk (𝟙 Z) ⟶ f) := fun φ =>
{ left := φ
right := φ ≫ f.hom }
have : ∀ g, (aux g).right = g ≫ f.hom := fun g => by dsimp
show (aux φ).left = (aux ψ).left
congr 1
rw [← cancel_mono sq]
apply CommaMorphism.ext
· exact h
· rw [Comma.comp_right, Comma.comp_right, this, this, Category.assoc, Category.assoc]
rw [← Arrow.w]
simp only [← Category.assoc, h]
#align category_theory.arrow.mono_left CategoryTheory.Arrow.mono_left
instance epi_right [Epi sq] : Epi sq.right where
left_cancellation {Z} φ ψ h := by
let aux : (g.right ⟶ Z) → (g ⟶ Arrow.mk (𝟙 Z)) := fun φ =>
{ right := φ
left := g.hom ≫ φ }
show (aux φ).right = (aux ψ).right
congr 1
rw [← cancel_epi sq]
apply CommaMorphism.ext
· rw [Comma.comp_left, Comma.comp_left, Arrow.w_assoc, Arrow.w_assoc, h]
· exact h
#align category_theory.arrow.epi_right CategoryTheory.Arrow.epi_right
@[reassoc (attr := simp)]
lemma hom_inv_id_left (e : f ≅ g) : e.hom.left ≫ e.inv.left = 𝟙 _ := by
rw [← comp_left, e.hom_inv_id, id_left]
@[reassoc (attr := simp)]
lemma inv_hom_id_left (e : f ≅ g) : e.inv.left ≫ e.hom.left = 𝟙 _ := by
rw [← comp_left, e.inv_hom_id, id_left]
@[reassoc (attr := simp)]
lemma hom_inv_id_right (e : f ≅ g) : e.hom.right ≫ e.inv.right = 𝟙 _ := by
rw [← comp_right, e.hom_inv_id, id_right]
@[reassoc (attr := simp)]
lemma inv_hom_id_right (e : f ≅ g) : e.inv.right ≫ e.hom.right = 𝟙 _ := by
rw [← comp_right, e.inv_hom_id, id_right]
end
/-- Given a square from an arrow `i` to an isomorphism `p`, express the source part of `sq`
in terms of the inverse of `p`. -/
@[simp]
| Mathlib/CategoryTheory/Comma/Arrow.lean | 272 | 274 | theorem square_to_iso_invert (i : Arrow T) {X Y : T} (p : X ≅ Y) (sq : i ⟶ Arrow.mk p.hom) :
i.hom ≫ sq.right ≫ p.inv = sq.left := by |
simpa only [Category.assoc] using (Iso.comp_inv_eq p).mpr (Arrow.w_mk_right sq).symm
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.MeasureSpace
/-!
# Restricting a measure to a subset or a subtype
Given a measure `μ` on a type `α` and a subset `s` of `α`, we define a measure `μ.restrict s` as
the restriction of `μ` to `s` (still as a measure on `α`).
We investigate how this notion interacts with usual operations on measures (sum, pushforward,
pullback), and on sets (inclusion, union, Union).
We also study the relationship between the restriction of a measure to a subtype (given by the
pullback under `Subtype.val`) and the restriction to a set as above.
-/
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter MeasurableSpace ENNReal Function
variable {R α β δ γ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ]
variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α}
namespace Measure
/-! ### Restricting a measure -/
/-- Restrict a measure `μ` to a set `s` as an `ℝ≥0∞`-linear map. -/
noncomputable def restrictₗ {m0 : MeasurableSpace α} (s : Set α) : Measure α →ₗ[ℝ≥0∞] Measure α :=
liftLinear (OuterMeasure.restrict s) fun μ s' hs' t => by
suffices μ (s ∩ t) = μ (s ∩ t ∩ s') + μ ((s ∩ t) \ s') by
simpa [← Set.inter_assoc, Set.inter_comm _ s, ← inter_diff_assoc]
exact le_toOuterMeasure_caratheodory _ _ hs' _
#align measure_theory.measure.restrictₗ MeasureTheory.Measure.restrictₗ
/-- Restrict a measure `μ` to a set `s`. -/
noncomputable def restrict {_m0 : MeasurableSpace α} (μ : Measure α) (s : Set α) : Measure α :=
restrictₗ s μ
#align measure_theory.measure.restrict MeasureTheory.Measure.restrict
@[simp]
theorem restrictₗ_apply {_m0 : MeasurableSpace α} (s : Set α) (μ : Measure α) :
restrictₗ s μ = μ.restrict s :=
rfl
#align measure_theory.measure.restrictₗ_apply MeasureTheory.Measure.restrictₗ_apply
/-- This lemma shows that `restrict` and `toOuterMeasure` commute. Note that the LHS has a
restrict on measures and the RHS has a restrict on outer measures. -/
theorem restrict_toOuterMeasure_eq_toOuterMeasure_restrict (h : MeasurableSet s) :
(μ.restrict s).toOuterMeasure = OuterMeasure.restrict s μ.toOuterMeasure := by
simp_rw [restrict, restrictₗ, liftLinear, LinearMap.coe_mk, AddHom.coe_mk,
toMeasure_toOuterMeasure, OuterMeasure.restrict_trim h, μ.trimmed]
#align measure_theory.measure.restrict_to_outer_measure_eq_to_outer_measure_restrict MeasureTheory.Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict
theorem restrict_apply₀ (ht : NullMeasurableSet t (μ.restrict s)) : μ.restrict s t = μ (t ∩ s) := by
rw [← restrictₗ_apply, restrictₗ, liftLinear_apply₀ _ ht, OuterMeasure.restrict_apply,
coe_toOuterMeasure]
#align measure_theory.measure.restrict_apply₀ MeasureTheory.Measure.restrict_apply₀
/-- If `t` is a measurable set, then the measure of `t` with respect to the restriction of
the measure to `s` equals the outer measure of `t ∩ s`. An alternate version requiring that `s`
be measurable instead of `t` exists as `Measure.restrict_apply'`. -/
@[simp]
theorem restrict_apply (ht : MeasurableSet t) : μ.restrict s t = μ (t ∩ s) :=
restrict_apply₀ ht.nullMeasurableSet
#align measure_theory.measure.restrict_apply MeasureTheory.Measure.restrict_apply
/-- Restriction of a measure to a subset is monotone both in set and in measure. -/
theorem restrict_mono' {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ ⦃μ ν : Measure α⦄ (hs : s ≤ᵐ[μ] s')
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
Measure.le_iff.2 fun t ht => calc
μ.restrict s t = μ (t ∩ s) := restrict_apply ht
_ ≤ μ (t ∩ s') := (measure_mono_ae <| hs.mono fun _x hx ⟨hxt, hxs⟩ => ⟨hxt, hx hxs⟩)
_ ≤ ν (t ∩ s') := le_iff'.1 hμν (t ∩ s')
_ = ν.restrict s' t := (restrict_apply ht).symm
#align measure_theory.measure.restrict_mono' MeasureTheory.Measure.restrict_mono'
/-- Restriction of a measure to a subset is monotone both in set and in measure. -/
@[mono]
theorem restrict_mono {_m0 : MeasurableSpace α} ⦃s s' : Set α⦄ (hs : s ⊆ s') ⦃μ ν : Measure α⦄
(hμν : μ ≤ ν) : μ.restrict s ≤ ν.restrict s' :=
restrict_mono' (ae_of_all _ hs) hμν
#align measure_theory.measure.restrict_mono MeasureTheory.Measure.restrict_mono
theorem restrict_mono_ae (h : s ≤ᵐ[μ] t) : μ.restrict s ≤ μ.restrict t :=
restrict_mono' h (le_refl μ)
#align measure_theory.measure.restrict_mono_ae MeasureTheory.Measure.restrict_mono_ae
theorem restrict_congr_set (h : s =ᵐ[μ] t) : μ.restrict s = μ.restrict t :=
le_antisymm (restrict_mono_ae h.le) (restrict_mono_ae h.symm.le)
#align measure_theory.measure.restrict_congr_set MeasureTheory.Measure.restrict_congr_set
/-- If `s` is a measurable set, then the outer measure of `t` with respect to the restriction of
the measure to `s` equals the outer measure of `t ∩ s`. This is an alternate version of
`Measure.restrict_apply`, requiring that `s` is measurable instead of `t`. -/
@[simp]
theorem restrict_apply' (hs : MeasurableSet s) : μ.restrict s t = μ (t ∩ s) := by
rw [← toOuterMeasure_apply,
Measure.restrict_toOuterMeasure_eq_toOuterMeasure_restrict hs,
OuterMeasure.restrict_apply s t _, toOuterMeasure_apply]
#align measure_theory.measure.restrict_apply' MeasureTheory.Measure.restrict_apply'
theorem restrict_apply₀' (hs : NullMeasurableSet s μ) : μ.restrict s t = μ (t ∩ s) := by
rw [← restrict_congr_set hs.toMeasurable_ae_eq,
restrict_apply' (measurableSet_toMeasurable _ _),
measure_congr ((ae_eq_refl t).inter hs.toMeasurable_ae_eq)]
#align measure_theory.measure.restrict_apply₀' MeasureTheory.Measure.restrict_apply₀'
theorem restrict_le_self : μ.restrict s ≤ μ :=
Measure.le_iff.2 fun t ht => calc
μ.restrict s t = μ (t ∩ s) := restrict_apply ht
_ ≤ μ t := measure_mono inter_subset_left
#align measure_theory.measure.restrict_le_self MeasureTheory.Measure.restrict_le_self
variable (μ)
theorem restrict_eq_self (h : s ⊆ t) : μ.restrict t s = μ s :=
(le_iff'.1 restrict_le_self s).antisymm <|
calc
μ s ≤ μ (toMeasurable (μ.restrict t) s ∩ t) :=
measure_mono (subset_inter (subset_toMeasurable _ _) h)
_ = μ.restrict t s := by
rw [← restrict_apply (measurableSet_toMeasurable _ _), measure_toMeasurable]
#align measure_theory.measure.restrict_eq_self MeasureTheory.Measure.restrict_eq_self
@[simp]
theorem restrict_apply_self (s : Set α) : (μ.restrict s) s = μ s :=
restrict_eq_self μ Subset.rfl
#align measure_theory.measure.restrict_apply_self MeasureTheory.Measure.restrict_apply_self
variable {μ}
theorem restrict_apply_univ (s : Set α) : μ.restrict s univ = μ s := by
rw [restrict_apply MeasurableSet.univ, Set.univ_inter]
#align measure_theory.measure.restrict_apply_univ MeasureTheory.Measure.restrict_apply_univ
theorem le_restrict_apply (s t : Set α) : μ (t ∩ s) ≤ μ.restrict s t :=
calc
μ (t ∩ s) = μ.restrict s (t ∩ s) := (restrict_eq_self μ inter_subset_right).symm
_ ≤ μ.restrict s t := measure_mono inter_subset_left
#align measure_theory.measure.le_restrict_apply MeasureTheory.Measure.le_restrict_apply
theorem restrict_apply_le (s t : Set α) : μ.restrict s t ≤ μ t :=
Measure.le_iff'.1 restrict_le_self _
theorem restrict_apply_superset (h : s ⊆ t) : μ.restrict s t = μ s :=
((measure_mono (subset_univ _)).trans_eq <| restrict_apply_univ _).antisymm
((restrict_apply_self μ s).symm.trans_le <| measure_mono h)
#align measure_theory.measure.restrict_apply_superset MeasureTheory.Measure.restrict_apply_superset
@[simp]
theorem restrict_add {_m0 : MeasurableSpace α} (μ ν : Measure α) (s : Set α) :
(μ + ν).restrict s = μ.restrict s + ν.restrict s :=
(restrictₗ s).map_add μ ν
#align measure_theory.measure.restrict_add MeasureTheory.Measure.restrict_add
@[simp]
theorem restrict_zero {_m0 : MeasurableSpace α} (s : Set α) : (0 : Measure α).restrict s = 0 :=
(restrictₗ s).map_zero
#align measure_theory.measure.restrict_zero MeasureTheory.Measure.restrict_zero
@[simp]
theorem restrict_smul {_m0 : MeasurableSpace α} (c : ℝ≥0∞) (μ : Measure α) (s : Set α) :
(c • μ).restrict s = c • μ.restrict s :=
(restrictₗ s).map_smul c μ
#align measure_theory.measure.restrict_smul MeasureTheory.Measure.restrict_smul
theorem restrict_restrict₀ (hs : NullMeasurableSet s (μ.restrict t)) :
(μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
ext fun u hu => by
simp only [Set.inter_assoc, restrict_apply hu,
restrict_apply₀ (hu.nullMeasurableSet.inter hs)]
#align measure_theory.measure.restrict_restrict₀ MeasureTheory.Measure.restrict_restrict₀
@[simp]
theorem restrict_restrict (hs : MeasurableSet s) : (μ.restrict t).restrict s = μ.restrict (s ∩ t) :=
restrict_restrict₀ hs.nullMeasurableSet
#align measure_theory.measure.restrict_restrict MeasureTheory.Measure.restrict_restrict
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
theorem restrict_apply_eq_zero (ht : MeasurableSet t) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by
rw [restrict_apply ht]
#align measure_theory.measure.restrict_apply_eq_zero MeasureTheory.Measure.restrict_apply_eq_zero
theorem measure_inter_eq_zero_of_restrict (h : μ.restrict s t = 0) : μ (t ∩ s) = 0 :=
nonpos_iff_eq_zero.1 (h ▸ le_restrict_apply _ _)
#align measure_theory.measure.measure_inter_eq_zero_of_restrict MeasureTheory.Measure.measure_inter_eq_zero_of_restrict
theorem restrict_apply_eq_zero' (hs : MeasurableSet s) : μ.restrict s t = 0 ↔ μ (t ∩ s) = 0 := by
rw [restrict_apply' hs]
#align measure_theory.measure.restrict_apply_eq_zero' MeasureTheory.Measure.restrict_apply_eq_zero'
@[simp]
theorem restrict_eq_zero : μ.restrict s = 0 ↔ μ s = 0 := by
rw [← measure_univ_eq_zero, restrict_apply_univ]
#align measure_theory.measure.restrict_eq_zero MeasureTheory.Measure.restrict_eq_zero
/-- If `μ s ≠ 0`, then `μ.restrict s ≠ 0`, in terms of `NeZero` instances. -/
instance restrict.neZero [NeZero (μ s)] : NeZero (μ.restrict s) :=
⟨mt restrict_eq_zero.mp <| NeZero.ne _⟩
theorem restrict_zero_set {s : Set α} (h : μ s = 0) : μ.restrict s = 0 :=
restrict_eq_zero.2 h
#align measure_theory.measure.restrict_zero_set MeasureTheory.Measure.restrict_zero_set
@[simp]
theorem restrict_empty : μ.restrict ∅ = 0 :=
restrict_zero_set measure_empty
#align measure_theory.measure.restrict_empty MeasureTheory.Measure.restrict_empty
@[simp]
theorem restrict_univ : μ.restrict univ = μ :=
ext fun s hs => by simp [hs]
#align measure_theory.measure.restrict_univ MeasureTheory.Measure.restrict_univ
theorem restrict_inter_add_diff₀ (s : Set α) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∩ t) + μ.restrict (s \ t) = μ.restrict s := by
ext1 u hu
simp only [add_apply, restrict_apply hu, ← inter_assoc, diff_eq]
exact measure_inter_add_diff₀ (u ∩ s) ht
#align measure_theory.measure.restrict_inter_add_diff₀ MeasureTheory.Measure.restrict_inter_add_diff₀
theorem restrict_inter_add_diff (s : Set α) (ht : MeasurableSet t) :
μ.restrict (s ∩ t) + μ.restrict (s \ t) = μ.restrict s :=
restrict_inter_add_diff₀ s ht.nullMeasurableSet
#align measure_theory.measure.restrict_inter_add_diff MeasureTheory.Measure.restrict_inter_add_diff
theorem restrict_union_add_inter₀ (s : Set α) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by
rw [← restrict_inter_add_diff₀ (s ∪ t) ht, union_inter_cancel_right, union_diff_right, ←
restrict_inter_add_diff₀ s ht, add_comm, ← add_assoc, add_right_comm]
#align measure_theory.measure.restrict_union_add_inter₀ MeasureTheory.Measure.restrict_union_add_inter₀
theorem restrict_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t :=
restrict_union_add_inter₀ s ht.nullMeasurableSet
#align measure_theory.measure.restrict_union_add_inter MeasureTheory.Measure.restrict_union_add_inter
theorem restrict_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ.restrict (s ∪ t) + μ.restrict (s ∩ t) = μ.restrict s + μ.restrict t := by
simpa only [union_comm, inter_comm, add_comm] using restrict_union_add_inter t hs
#align measure_theory.measure.restrict_union_add_inter' MeasureTheory.Measure.restrict_union_add_inter'
theorem restrict_union₀ (h : AEDisjoint μ s t) (ht : NullMeasurableSet t μ) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by
simp [← restrict_union_add_inter₀ s ht, restrict_zero_set h]
#align measure_theory.measure.restrict_union₀ MeasureTheory.Measure.restrict_union₀
theorem restrict_union (h : Disjoint s t) (ht : MeasurableSet t) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t :=
restrict_union₀ h.aedisjoint ht.nullMeasurableSet
#align measure_theory.measure.restrict_union MeasureTheory.Measure.restrict_union
theorem restrict_union' (h : Disjoint s t) (hs : MeasurableSet s) :
μ.restrict (s ∪ t) = μ.restrict s + μ.restrict t := by
rw [union_comm, restrict_union h.symm hs, add_comm]
#align measure_theory.measure.restrict_union' MeasureTheory.Measure.restrict_union'
@[simp]
theorem restrict_add_restrict_compl (hs : MeasurableSet s) :
μ.restrict s + μ.restrict sᶜ = μ := by
rw [← restrict_union (@disjoint_compl_right (Set α) _ _) hs.compl, union_compl_self,
restrict_univ]
#align measure_theory.measure.restrict_add_restrict_compl MeasureTheory.Measure.restrict_add_restrict_compl
@[simp]
theorem restrict_compl_add_restrict (hs : MeasurableSet s) : μ.restrict sᶜ + μ.restrict s = μ := by
rw [add_comm, restrict_add_restrict_compl hs]
#align measure_theory.measure.restrict_compl_add_restrict MeasureTheory.Measure.restrict_compl_add_restrict
theorem restrict_union_le (s s' : Set α) : μ.restrict (s ∪ s') ≤ μ.restrict s + μ.restrict s' :=
le_iff.2 fun t ht ↦ by
simpa [ht, inter_union_distrib_left] using measure_union_le (t ∩ s) (t ∩ s')
#align measure_theory.measure.restrict_union_le MeasureTheory.Measure.restrict_union_le
theorem restrict_iUnion_apply_ae [Countable ι] {s : ι → Set α} (hd : Pairwise (AEDisjoint μ on s))
(hm : ∀ i, NullMeasurableSet (s i) μ) {t : Set α} (ht : MeasurableSet t) :
μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t := by
simp only [restrict_apply, ht, inter_iUnion]
exact
measure_iUnion₀ (hd.mono fun i j h => h.mono inter_subset_right inter_subset_right)
fun i => ht.nullMeasurableSet.inter (hm i)
#align measure_theory.measure.restrict_Union_apply_ae MeasureTheory.Measure.restrict_iUnion_apply_ae
theorem restrict_iUnion_apply [Countable ι] {s : ι → Set α} (hd : Pairwise (Disjoint on s))
(hm : ∀ i, MeasurableSet (s i)) {t : Set α} (ht : MeasurableSet t) :
μ.restrict (⋃ i, s i) t = ∑' i, μ.restrict (s i) t :=
restrict_iUnion_apply_ae hd.aedisjoint (fun i => (hm i).nullMeasurableSet) ht
#align measure_theory.measure.restrict_Union_apply MeasureTheory.Measure.restrict_iUnion_apply
theorem restrict_iUnion_apply_eq_iSup [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s)
{t : Set α} (ht : MeasurableSet t) : μ.restrict (⋃ i, s i) t = ⨆ i, μ.restrict (s i) t := by
simp only [restrict_apply ht, inter_iUnion]
rw [measure_iUnion_eq_iSup]
exacts [hd.mono_comp _ fun s₁ s₂ => inter_subset_inter_right _]
#align measure_theory.measure.restrict_Union_apply_eq_supr MeasureTheory.Measure.restrict_iUnion_apply_eq_iSup
/-- The restriction of the pushforward measure is the pushforward of the restriction. For a version
assuming only `AEMeasurable`, see `restrict_map_of_aemeasurable`. -/
theorem restrict_map {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
(μ.map f).restrict s = (μ.restrict <| f ⁻¹' s).map f :=
ext fun t ht => by simp [*, hf ht]
#align measure_theory.measure.restrict_map MeasureTheory.Measure.restrict_map
theorem restrict_toMeasurable (h : μ s ≠ ∞) : μ.restrict (toMeasurable μ s) = μ.restrict s :=
ext fun t ht => by
rw [restrict_apply ht, restrict_apply ht, inter_comm, measure_toMeasurable_inter ht h,
inter_comm]
#align measure_theory.measure.restrict_to_measurable MeasureTheory.Measure.restrict_toMeasurable
theorem restrict_eq_self_of_ae_mem {_m0 : MeasurableSpace α} ⦃s : Set α⦄ ⦃μ : Measure α⦄
(hs : ∀ᵐ x ∂μ, x ∈ s) : μ.restrict s = μ :=
calc
μ.restrict s = μ.restrict univ := restrict_congr_set (eventuallyEq_univ.mpr hs)
_ = μ := restrict_univ
#align measure_theory.measure.restrict_eq_self_of_ae_mem MeasureTheory.Measure.restrict_eq_self_of_ae_mem
theorem restrict_congr_meas (hs : MeasurableSet s) :
μ.restrict s = ν.restrict s ↔ ∀ t ⊆ s, MeasurableSet t → μ t = ν t :=
⟨fun H t hts ht => by
rw [← inter_eq_self_of_subset_left hts, ← restrict_apply ht, H, restrict_apply ht], fun H =>
ext fun t ht => by
rw [restrict_apply ht, restrict_apply ht, H _ inter_subset_right (ht.inter hs)]⟩
#align measure_theory.measure.restrict_congr_meas MeasureTheory.Measure.restrict_congr_meas
theorem restrict_congr_mono (hs : s ⊆ t) (h : μ.restrict t = ν.restrict t) :
μ.restrict s = ν.restrict s := by
rw [← restrict_restrict_of_subset hs, h, restrict_restrict_of_subset hs]
#align measure_theory.measure.restrict_congr_mono MeasureTheory.Measure.restrict_congr_mono
/-- If two measures agree on all measurable subsets of `s` and `t`, then they agree on all
measurable subsets of `s ∪ t`. -/
theorem restrict_union_congr :
μ.restrict (s ∪ t) = ν.restrict (s ∪ t) ↔
μ.restrict s = ν.restrict s ∧ μ.restrict t = ν.restrict t := by
refine
⟨fun h =>
⟨restrict_congr_mono subset_union_left h,
restrict_congr_mono subset_union_right h⟩,
?_⟩
rintro ⟨hs, ht⟩
ext1 u hu
simp only [restrict_apply hu, inter_union_distrib_left]
rcases exists_measurable_superset₂ μ ν (u ∩ s) with ⟨US, hsub, hm, hμ, hν⟩
calc
μ (u ∩ s ∪ u ∩ t) = μ (US ∪ u ∩ t) :=
measure_union_congr_of_subset hsub hμ.le Subset.rfl le_rfl
_ = μ US + μ ((u ∩ t) \ US) := (measure_add_diff hm _).symm
_ = restrict μ s u + restrict μ t (u \ US) := by
simp only [restrict_apply, hu, hu.diff hm, hμ, ← inter_comm t, inter_diff_assoc]
_ = restrict ν s u + restrict ν t (u \ US) := by rw [hs, ht]
_ = ν US + ν ((u ∩ t) \ US) := by
simp only [restrict_apply, hu, hu.diff hm, hν, ← inter_comm t, inter_diff_assoc]
_ = ν (US ∪ u ∩ t) := measure_add_diff hm _
_ = ν (u ∩ s ∪ u ∩ t) := Eq.symm <| measure_union_congr_of_subset hsub hν.le Subset.rfl le_rfl
#align measure_theory.measure.restrict_union_congr MeasureTheory.Measure.restrict_union_congr
theorem restrict_finset_biUnion_congr {s : Finset ι} {t : ι → Set α} :
μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔
∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) := by
classical
induction' s using Finset.induction_on with i s _ hs; · simp
simp only [forall_eq_or_imp, iUnion_iUnion_eq_or_left, Finset.mem_insert]
rw [restrict_union_congr, ← hs]
#align measure_theory.measure.restrict_finset_bUnion_congr MeasureTheory.Measure.restrict_finset_biUnion_congr
theorem restrict_iUnion_congr [Countable ι] {s : ι → Set α} :
μ.restrict (⋃ i, s i) = ν.restrict (⋃ i, s i) ↔ ∀ i, μ.restrict (s i) = ν.restrict (s i) := by
refine ⟨fun h i => restrict_congr_mono (subset_iUnion _ _) h, fun h => ?_⟩
ext1 t ht
have D : Directed (· ⊆ ·) fun t : Finset ι => ⋃ i ∈ t, s i :=
Monotone.directed_le fun t₁ t₂ ht => biUnion_subset_biUnion_left ht
rw [iUnion_eq_iUnion_finset]
simp only [restrict_iUnion_apply_eq_iSup D ht, restrict_finset_biUnion_congr.2 fun i _ => h i]
#align measure_theory.measure.restrict_Union_congr MeasureTheory.Measure.restrict_iUnion_congr
theorem restrict_biUnion_congr {s : Set ι} {t : ι → Set α} (hc : s.Countable) :
μ.restrict (⋃ i ∈ s, t i) = ν.restrict (⋃ i ∈ s, t i) ↔
∀ i ∈ s, μ.restrict (t i) = ν.restrict (t i) := by
haveI := hc.toEncodable
simp only [biUnion_eq_iUnion, SetCoe.forall', restrict_iUnion_congr]
#align measure_theory.measure.restrict_bUnion_congr MeasureTheory.Measure.restrict_biUnion_congr
theorem restrict_sUnion_congr {S : Set (Set α)} (hc : S.Countable) :
μ.restrict (⋃₀ S) = ν.restrict (⋃₀ S) ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s := by
rw [sUnion_eq_biUnion, restrict_biUnion_congr hc]
#align measure_theory.measure.restrict_sUnion_congr MeasureTheory.Measure.restrict_sUnion_congr
/-- This lemma shows that `Inf` and `restrict` commute for measures. -/
theorem restrict_sInf_eq_sInf_restrict {m0 : MeasurableSpace α} {m : Set (Measure α)}
(hm : m.Nonempty) (ht : MeasurableSet t) :
(sInf m).restrict t = sInf ((fun μ : Measure α => μ.restrict t) '' m) := by
ext1 s hs
simp_rw [sInf_apply hs, restrict_apply hs, sInf_apply (MeasurableSet.inter hs ht),
Set.image_image, restrict_toOuterMeasure_eq_toOuterMeasure_restrict ht, ←
Set.image_image _ toOuterMeasure, ← OuterMeasure.restrict_sInf_eq_sInf_restrict _ (hm.image _),
OuterMeasure.restrict_apply]
#align measure_theory.measure.restrict_Inf_eq_Inf_restrict MeasureTheory.Measure.restrict_sInf_eq_sInf_restrict
theorem exists_mem_of_measure_ne_zero_of_ae (hs : μ s ≠ 0) {p : α → Prop}
(hp : ∀ᵐ x ∂μ.restrict s, p x) : ∃ x, x ∈ s ∧ p x := by
rw [← μ.restrict_apply_self, ← frequently_ae_mem_iff] at hs
exact (hs.and_eventually hp).exists
#align measure_theory.measure.exists_mem_of_measure_ne_zero_of_ae MeasureTheory.Measure.exists_mem_of_measure_ne_zero_of_ae
/-! ### Extensionality results -/
/-- Two measures are equal if they have equal restrictions on a spanning collection of sets
(formulated using `Union`). -/
theorem ext_iff_of_iUnion_eq_univ [Countable ι] {s : ι → Set α} (hs : ⋃ i, s i = univ) :
μ = ν ↔ ∀ i, μ.restrict (s i) = ν.restrict (s i) := by
rw [← restrict_iUnion_congr, hs, restrict_univ, restrict_univ]
#align measure_theory.measure.ext_iff_of_Union_eq_univ MeasureTheory.Measure.ext_iff_of_iUnion_eq_univ
alias ⟨_, ext_of_iUnion_eq_univ⟩ := ext_iff_of_iUnion_eq_univ
#align measure_theory.measure.ext_of_Union_eq_univ MeasureTheory.Measure.ext_of_iUnion_eq_univ
/-- Two measures are equal if they have equal restrictions on a spanning collection of sets
(formulated using `biUnion`). -/
theorem ext_iff_of_biUnion_eq_univ {S : Set ι} {s : ι → Set α} (hc : S.Countable)
(hs : ⋃ i ∈ S, s i = univ) : μ = ν ↔ ∀ i ∈ S, μ.restrict (s i) = ν.restrict (s i) := by
rw [← restrict_biUnion_congr hc, hs, restrict_univ, restrict_univ]
#align measure_theory.measure.ext_iff_of_bUnion_eq_univ MeasureTheory.Measure.ext_iff_of_biUnion_eq_univ
alias ⟨_, ext_of_biUnion_eq_univ⟩ := ext_iff_of_biUnion_eq_univ
#align measure_theory.measure.ext_of_bUnion_eq_univ MeasureTheory.Measure.ext_of_biUnion_eq_univ
/-- Two measures are equal if they have equal restrictions on a spanning collection of sets
(formulated using `sUnion`). -/
theorem ext_iff_of_sUnion_eq_univ {S : Set (Set α)} (hc : S.Countable) (hs : ⋃₀ S = univ) :
μ = ν ↔ ∀ s ∈ S, μ.restrict s = ν.restrict s :=
ext_iff_of_biUnion_eq_univ hc <| by rwa [← sUnion_eq_biUnion]
#align measure_theory.measure.ext_iff_of_sUnion_eq_univ MeasureTheory.Measure.ext_iff_of_sUnion_eq_univ
alias ⟨_, ext_of_sUnion_eq_univ⟩ := ext_iff_of_sUnion_eq_univ
#align measure_theory.measure.ext_of_sUnion_eq_univ MeasureTheory.Measure.ext_of_sUnion_eq_univ
| Mathlib/MeasureTheory/Measure/Restrict.lean | 465 | 481 | theorem ext_of_generateFrom_of_cover {S T : Set (Set α)} (h_gen : ‹_› = generateFrom S)
(hc : T.Countable) (h_inter : IsPiSystem S) (hU : ⋃₀ T = univ) (htop : ∀ t ∈ T, μ t ≠ ∞)
(ST_eq : ∀ t ∈ T, ∀ s ∈ S, μ (s ∩ t) = ν (s ∩ t)) (T_eq : ∀ t ∈ T, μ t = ν t) : μ = ν := by |
refine ext_of_sUnion_eq_univ hc hU fun t ht => ?_
ext1 u hu
simp only [restrict_apply hu]
refine induction_on_inter h_gen h_inter ?_ (ST_eq t ht) ?_ ?_ hu
· simp only [Set.empty_inter, measure_empty]
· intro v hv hvt
have := T_eq t ht
rw [Set.inter_comm] at hvt ⊢
rwa [← measure_inter_add_diff t hv, ← measure_inter_add_diff t hv, ← hvt,
ENNReal.add_right_inj] at this
exact ne_top_of_le_ne_top (htop t ht) (measure_mono Set.inter_subset_left)
· intro f hfd hfm h_eq
simp only [← restrict_apply (hfm _), ← restrict_apply (MeasurableSet.iUnion hfm)] at h_eq ⊢
simp only [measure_iUnion hfd hfm, h_eq]
|
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Zhouhang Zhou, Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.MeasureTheory.Function.SimpleFuncDenseLp
#align_import measure_theory.integral.set_to_l1 from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Extension of a linear function from indicators to L1
Let `T : Set α → E →L[ℝ] F` be additive for measurable sets with finite measure, in the sense that
for `s, t` two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`. `T` is akin to a bilinear map on
`Set α × E`, or a linear map on indicator functions.
This file constructs an extension of `T` to integrable simple functions, which are finite sums of
indicators of measurable sets with finite measure, then to integrable functions, which are limits of
integrable simple functions.
The main result is a continuous linear map `(α →₁[μ] E) →L[ℝ] F`. This extension process is used to
define the Bochner integral in the `MeasureTheory.Integral.Bochner` file and the conditional
expectation of an integrable function in `MeasureTheory.Function.ConditionalExpectation`.
## Main Definitions
- `FinMeasAdditive μ T`: the property that `T` is additive on measurable sets with finite measure.
For two such sets, `s ∩ t = ∅ → T (s ∪ t) = T s + T t`.
- `DominatedFinMeasAdditive μ T C`: `FinMeasAdditive μ T ∧ ∀ s, ‖T s‖ ≤ C * (μ s).toReal`.
This is the property needed to perform the extension from indicators to L1.
- `setToL1 (hT : DominatedFinMeasAdditive μ T C) : (α →₁[μ] E) →L[ℝ] F`: the extension of `T`
from indicators to L1.
- `setToFun μ T (hT : DominatedFinMeasAdditive μ T C) (f : α → E) : F`: a version of the
extension which applies to functions (with value 0 if the function is not integrable).
## Properties
For most properties of `setToFun`, we provide two lemmas. One version uses hypotheses valid on
all sets, like `T = T'`, and a second version which uses a primed name uses hypotheses on
measurable sets with finite measure, like `∀ s, MeasurableSet s → μ s < ∞ → T s = T' s`.
The lemmas listed here don't show all hypotheses. Refer to the actual lemmas for details.
Linearity:
- `setToFun_zero_left : setToFun μ 0 hT f = 0`
- `setToFun_add_left : setToFun μ (T + T') _ f = setToFun μ T hT f + setToFun μ T' hT' f`
- `setToFun_smul_left : setToFun μ (fun s ↦ c • (T s)) (hT.smul c) f = c • setToFun μ T hT f`
- `setToFun_zero : setToFun μ T hT (0 : α → E) = 0`
- `setToFun_neg : setToFun μ T hT (-f) = - setToFun μ T hT f`
If `f` and `g` are integrable:
- `setToFun_add : setToFun μ T hT (f + g) = setToFun μ T hT f + setToFun μ T hT g`
- `setToFun_sub : setToFun μ T hT (f - g) = setToFun μ T hT f - setToFun μ T hT g`
If `T` is verifies `∀ c : 𝕜, ∀ s x, T s (c • x) = c • T s x`:
- `setToFun_smul : setToFun μ T hT (c • f) = c • setToFun μ T hT f`
Other:
- `setToFun_congr_ae (h : f =ᵐ[μ] g) : setToFun μ T hT f = setToFun μ T hT g`
- `setToFun_measure_zero (h : μ = 0) : setToFun μ T hT f = 0`
If the space is a `NormedLatticeAddCommGroup` and `T` is such that `0 ≤ T s x` for `0 ≤ x`, we
also prove order-related properties:
- `setToFun_mono_left (h : ∀ s x, T s x ≤ T' s x) : setToFun μ T hT f ≤ setToFun μ T' hT' f`
- `setToFun_nonneg (hf : 0 ≤ᵐ[μ] f) : 0 ≤ setToFun μ T hT f`
- `setToFun_mono (hfg : f ≤ᵐ[μ] g) : setToFun μ T hT f ≤ setToFun μ T hT g`
## Implementation notes
The starting object `T : Set α → E →L[ℝ] F` matters only through its restriction on measurable sets
with finite measure. Its value on other sets is ignored.
-/
noncomputable section
open scoped Classical Topology NNReal ENNReal MeasureTheory Pointwise
open Set Filter TopologicalSpace ENNReal EMetric
namespace MeasureTheory
variable {α E F F' G 𝕜 : Type*} {p : ℝ≥0∞} [NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F] [NormedAddCommGroup F'] [NormedSpace ℝ F']
[NormedAddCommGroup G] {m : MeasurableSpace α} {μ : Measure α}
local infixr:25 " →ₛ " => SimpleFunc
open Finset
section FinMeasAdditive
/-- A set function is `FinMeasAdditive` if its value on the union of two disjoint measurable
sets with finite measure is the sum of its values on each set. -/
def FinMeasAdditive {β} [AddMonoid β] {_ : MeasurableSpace α} (μ : Measure α) (T : Set α → β) :
Prop :=
∀ s t, MeasurableSet s → MeasurableSet t → μ s ≠ ∞ → μ t ≠ ∞ → s ∩ t = ∅ → T (s ∪ t) = T s + T t
#align measure_theory.fin_meas_additive MeasureTheory.FinMeasAdditive
namespace FinMeasAdditive
variable {β : Type*} [AddCommMonoid β] {T T' : Set α → β}
theorem zero : FinMeasAdditive μ (0 : Set α → β) := fun s t _ _ _ _ _ => by simp
#align measure_theory.fin_meas_additive.zero MeasureTheory.FinMeasAdditive.zero
theorem add (hT : FinMeasAdditive μ T) (hT' : FinMeasAdditive μ T') :
FinMeasAdditive μ (T + T') := by
intro s t hs ht hμs hμt hst
simp only [hT s t hs ht hμs hμt hst, hT' s t hs ht hμs hμt hst, Pi.add_apply]
abel
#align measure_theory.fin_meas_additive.add MeasureTheory.FinMeasAdditive.add
theorem smul [Monoid 𝕜] [DistribMulAction 𝕜 β] (hT : FinMeasAdditive μ T) (c : 𝕜) :
FinMeasAdditive μ fun s => c • T s := fun s t hs ht hμs hμt hst => by
simp [hT s t hs ht hμs hμt hst]
#align measure_theory.fin_meas_additive.smul MeasureTheory.FinMeasAdditive.smul
theorem of_eq_top_imp_eq_top {μ' : Measure α} (h : ∀ s, MeasurableSet s → μ s = ∞ → μ' s = ∞)
(hT : FinMeasAdditive μ T) : FinMeasAdditive μ' T := fun s t hs ht hμ's hμ't hst =>
hT s t hs ht (mt (h s hs) hμ's) (mt (h t ht) hμ't) hst
#align measure_theory.fin_meas_additive.of_eq_top_imp_eq_top MeasureTheory.FinMeasAdditive.of_eq_top_imp_eq_top
theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : FinMeasAdditive (c • μ) T) :
FinMeasAdditive μ T := by
refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT
rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top] at hμs
simp only [hc_ne_top, or_false_iff, Ne, false_and_iff] at hμs
exact hμs.2
#align measure_theory.fin_meas_additive.of_smul_measure MeasureTheory.FinMeasAdditive.of_smul_measure
theorem smul_measure (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hT : FinMeasAdditive μ T) :
FinMeasAdditive (c • μ) T := by
refine of_eq_top_imp_eq_top (fun s _ hμs => ?_) hT
rw [Measure.smul_apply, smul_eq_mul, ENNReal.mul_eq_top]
simp only [hc_ne_zero, true_and_iff, Ne, not_false_iff]
exact Or.inl hμs
#align measure_theory.fin_meas_additive.smul_measure MeasureTheory.FinMeasAdditive.smul_measure
theorem smul_measure_iff (c : ℝ≥0∞) (hc_ne_zero : c ≠ 0) (hc_ne_top : c ≠ ∞) :
FinMeasAdditive (c • μ) T ↔ FinMeasAdditive μ T :=
⟨fun hT => of_smul_measure c hc_ne_top hT, fun hT => smul_measure c hc_ne_zero hT⟩
#align measure_theory.fin_meas_additive.smul_measure_iff MeasureTheory.FinMeasAdditive.smul_measure_iff
theorem map_empty_eq_zero {β} [AddCancelMonoid β] {T : Set α → β} (hT : FinMeasAdditive μ T) :
T ∅ = 0 := by
have h_empty : μ ∅ ≠ ∞ := (measure_empty.le.trans_lt ENNReal.coe_lt_top).ne
specialize hT ∅ ∅ MeasurableSet.empty MeasurableSet.empty h_empty h_empty (Set.inter_empty ∅)
rw [Set.union_empty] at hT
nth_rw 1 [← add_zero (T ∅)] at hT
exact (add_left_cancel hT).symm
#align measure_theory.fin_meas_additive.map_empty_eq_zero MeasureTheory.FinMeasAdditive.map_empty_eq_zero
theorem map_iUnion_fin_meas_set_eq_sum (T : Set α → β) (T_empty : T ∅ = 0)
(h_add : FinMeasAdditive μ T) {ι} (S : ι → Set α) (sι : Finset ι)
(hS_meas : ∀ i, MeasurableSet (S i)) (hSp : ∀ i ∈ sι, μ (S i) ≠ ∞)
(h_disj : ∀ᵉ (i ∈ sι) (j ∈ sι), i ≠ j → Disjoint (S i) (S j)) :
T (⋃ i ∈ sι, S i) = ∑ i ∈ sι, T (S i) := by
revert hSp h_disj
refine Finset.induction_on sι ?_ ?_
· simp only [Finset.not_mem_empty, IsEmpty.forall_iff, iUnion_false, iUnion_empty, sum_empty,
forall₂_true_iff, imp_true_iff, forall_true_left, not_false_iff, T_empty]
intro a s has h hps h_disj
rw [Finset.sum_insert has, ← h]
swap; · exact fun i hi => hps i (Finset.mem_insert_of_mem hi)
swap;
· exact fun i hi j hj hij =>
h_disj i (Finset.mem_insert_of_mem hi) j (Finset.mem_insert_of_mem hj) hij
rw [←
h_add (S a) (⋃ i ∈ s, S i) (hS_meas a) (measurableSet_biUnion _ fun i _ => hS_meas i)
(hps a (Finset.mem_insert_self a s))]
· congr; convert Finset.iSup_insert a s S
· exact
((measure_biUnion_finset_le _ _).trans_lt <|
ENNReal.sum_lt_top fun i hi => hps i <| Finset.mem_insert_of_mem hi).ne
· simp_rw [Set.inter_iUnion]
refine iUnion_eq_empty.mpr fun i => iUnion_eq_empty.mpr fun hi => ?_
rw [← Set.disjoint_iff_inter_eq_empty]
refine h_disj a (Finset.mem_insert_self a s) i (Finset.mem_insert_of_mem hi) fun hai => ?_
rw [← hai] at hi
exact has hi
#align measure_theory.fin_meas_additive.map_Union_fin_meas_set_eq_sum MeasureTheory.FinMeasAdditive.map_iUnion_fin_meas_set_eq_sum
end FinMeasAdditive
/-- A `FinMeasAdditive` set function whose norm on every set is less than the measure of the
set (up to a multiplicative constant). -/
def DominatedFinMeasAdditive {β} [SeminormedAddCommGroup β] {_ : MeasurableSpace α} (μ : Measure α)
(T : Set α → β) (C : ℝ) : Prop :=
FinMeasAdditive μ T ∧ ∀ s, MeasurableSet s → μ s < ∞ → ‖T s‖ ≤ C * (μ s).toReal
#align measure_theory.dominated_fin_meas_additive MeasureTheory.DominatedFinMeasAdditive
namespace DominatedFinMeasAdditive
variable {β : Type*} [SeminormedAddCommGroup β] {T T' : Set α → β} {C C' : ℝ}
theorem zero {m : MeasurableSpace α} (μ : Measure α) (hC : 0 ≤ C) :
DominatedFinMeasAdditive μ (0 : Set α → β) C := by
refine ⟨FinMeasAdditive.zero, fun s _ _ => ?_⟩
rw [Pi.zero_apply, norm_zero]
exact mul_nonneg hC toReal_nonneg
#align measure_theory.dominated_fin_meas_additive.zero MeasureTheory.DominatedFinMeasAdditive.zero
theorem eq_zero_of_measure_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ}
(hT : DominatedFinMeasAdditive μ T C) {s : Set α} (hs : MeasurableSet s) (hs_zero : μ s = 0) :
T s = 0 := by
refine norm_eq_zero.mp ?_
refine ((hT.2 s hs (by simp [hs_zero])).trans (le_of_eq ?_)).antisymm (norm_nonneg _)
rw [hs_zero, ENNReal.zero_toReal, mul_zero]
#align measure_theory.dominated_fin_meas_additive.eq_zero_of_measure_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero_of_measure_zero
theorem eq_zero {β : Type*} [NormedAddCommGroup β] {T : Set α → β} {C : ℝ} {m : MeasurableSpace α}
(hT : DominatedFinMeasAdditive (0 : Measure α) T C) {s : Set α} (hs : MeasurableSet s) :
T s = 0 :=
eq_zero_of_measure_zero hT hs (by simp only [Measure.coe_zero, Pi.zero_apply])
#align measure_theory.dominated_fin_meas_additive.eq_zero MeasureTheory.DominatedFinMeasAdditive.eq_zero
theorem add (hT : DominatedFinMeasAdditive μ T C) (hT' : DominatedFinMeasAdditive μ T' C') :
DominatedFinMeasAdditive μ (T + T') (C + C') := by
refine ⟨hT.1.add hT'.1, fun s hs hμs => ?_⟩
rw [Pi.add_apply, add_mul]
exact (norm_add_le _ _).trans (add_le_add (hT.2 s hs hμs) (hT'.2 s hs hμs))
#align measure_theory.dominated_fin_meas_additive.add MeasureTheory.DominatedFinMeasAdditive.add
theorem smul [NormedField 𝕜] [NormedSpace 𝕜 β] (hT : DominatedFinMeasAdditive μ T C) (c : 𝕜) :
DominatedFinMeasAdditive μ (fun s => c • T s) (‖c‖ * C) := by
refine ⟨hT.1.smul c, fun s hs hμs => ?_⟩
dsimp only
rw [norm_smul, mul_assoc]
exact mul_le_mul le_rfl (hT.2 s hs hμs) (norm_nonneg _) (norm_nonneg _)
#align measure_theory.dominated_fin_meas_additive.smul MeasureTheory.DominatedFinMeasAdditive.smul
theorem of_measure_le {μ' : Measure α} (h : μ ≤ μ') (hT : DominatedFinMeasAdditive μ T C)
(hC : 0 ≤ C) : DominatedFinMeasAdditive μ' T C := by
have h' : ∀ s, μ s = ∞ → μ' s = ∞ := fun s hs ↦ top_unique <| hs.symm.trans_le (h _)
refine ⟨hT.1.of_eq_top_imp_eq_top fun s _ ↦ h' s, fun s hs hμ's ↦ ?_⟩
have hμs : μ s < ∞ := (h s).trans_lt hμ's
calc
‖T s‖ ≤ C * (μ s).toReal := hT.2 s hs hμs
_ ≤ C * (μ' s).toReal := by gcongr; exacts [hμ's.ne, h _]
#align measure_theory.dominated_fin_meas_additive.of_measure_le MeasureTheory.DominatedFinMeasAdditive.of_measure_le
theorem add_measure_right {_ : MeasurableSpace α} (μ ν : Measure α)
(hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C :=
of_measure_le (Measure.le_add_right le_rfl) hT hC
#align measure_theory.dominated_fin_meas_additive.add_measure_right MeasureTheory.DominatedFinMeasAdditive.add_measure_right
theorem add_measure_left {_ : MeasurableSpace α} (μ ν : Measure α)
(hT : DominatedFinMeasAdditive ν T C) (hC : 0 ≤ C) : DominatedFinMeasAdditive (μ + ν) T C :=
of_measure_le (Measure.le_add_left le_rfl) hT hC
#align measure_theory.dominated_fin_meas_additive.add_measure_left MeasureTheory.DominatedFinMeasAdditive.add_measure_left
theorem of_smul_measure (c : ℝ≥0∞) (hc_ne_top : c ≠ ∞) (hT : DominatedFinMeasAdditive (c • μ) T C) :
DominatedFinMeasAdditive μ T (c.toReal * C) := by
have h : ∀ s, MeasurableSet s → c • μ s = ∞ → μ s = ∞ := by
intro s _ hcμs
simp only [hc_ne_top, Algebra.id.smul_eq_mul, ENNReal.mul_eq_top, or_false_iff, Ne,
false_and_iff] at hcμs
exact hcμs.2
refine ⟨hT.1.of_eq_top_imp_eq_top (μ := c • μ) h, fun s hs hμs => ?_⟩
have hcμs : c • μ s ≠ ∞ := mt (h s hs) hμs.ne
rw [smul_eq_mul] at hcμs
simp_rw [DominatedFinMeasAdditive, Measure.smul_apply, smul_eq_mul, toReal_mul] at hT
refine (hT.2 s hs hcμs.lt_top).trans (le_of_eq ?_)
ring
#align measure_theory.dominated_fin_meas_additive.of_smul_measure MeasureTheory.DominatedFinMeasAdditive.of_smul_measure
theorem of_measure_le_smul {μ' : Measure α} (c : ℝ≥0∞) (hc : c ≠ ∞) (h : μ ≤ c • μ')
(hT : DominatedFinMeasAdditive μ T C) (hC : 0 ≤ C) :
DominatedFinMeasAdditive μ' T (c.toReal * C) :=
(hT.of_measure_le h hC).of_smul_measure c hc
#align measure_theory.dominated_fin_meas_additive.of_measure_le_smul MeasureTheory.DominatedFinMeasAdditive.of_measure_le_smul
end DominatedFinMeasAdditive
end FinMeasAdditive
namespace SimpleFunc
/-- Extend `Set α → (F →L[ℝ] F')` to `(α →ₛ F) → F'`. -/
def setToSimpleFunc {_ : MeasurableSpace α} (T : Set α → F →L[ℝ] F') (f : α →ₛ F) : F' :=
∑ x ∈ f.range, T (f ⁻¹' {x}) x
#align measure_theory.simple_func.set_to_simple_func MeasureTheory.SimpleFunc.setToSimpleFunc
@[simp]
theorem setToSimpleFunc_zero {m : MeasurableSpace α} (f : α →ₛ F) :
setToSimpleFunc (0 : Set α → F →L[ℝ] F') f = 0 := by simp [setToSimpleFunc]
#align measure_theory.simple_func.set_to_simple_func_zero MeasureTheory.SimpleFunc.setToSimpleFunc_zero
theorem setToSimpleFunc_zero' {T : Set α → E →L[ℝ] F'}
(h_zero : ∀ s, MeasurableSet s → μ s < ∞ → T s = 0) (f : α →ₛ E) (hf : Integrable f μ) :
setToSimpleFunc T f = 0 := by
simp_rw [setToSimpleFunc]
refine sum_eq_zero fun x _ => ?_
by_cases hx0 : x = 0
· simp [hx0]
rw [h_zero (f ⁻¹' ({x} : Set E)) (measurableSet_fiber _ _)
(measure_preimage_lt_top_of_integrable f hf hx0),
ContinuousLinearMap.zero_apply]
#align measure_theory.simple_func.set_to_simple_func_zero' MeasureTheory.SimpleFunc.setToSimpleFunc_zero'
@[simp]
theorem setToSimpleFunc_zero_apply {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F') :
setToSimpleFunc T (0 : α →ₛ F) = 0 := by
cases isEmpty_or_nonempty α <;> simp [setToSimpleFunc]
#align measure_theory.simple_func.set_to_simple_func_zero_apply MeasureTheory.SimpleFunc.setToSimpleFunc_zero_apply
| Mathlib/MeasureTheory/Integral/SetToL1.lean | 306 | 312 | theorem setToSimpleFunc_eq_sum_filter {m : MeasurableSpace α} (T : Set α → F →L[ℝ] F')
(f : α →ₛ F) :
setToSimpleFunc T f = ∑ x ∈ f.range.filter fun x => x ≠ 0, (T (f ⁻¹' {x})) x := by |
symm
refine sum_filter_of_ne fun x _ => mt fun hx0 => ?_
rw [hx0]
exact ContinuousLinearMap.map_zero _
|
/-
Copyright (c) 2021 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Algebra.Order.Group.WithTop
import Mathlib.RingTheory.HahnSeries.Multiplication
import Mathlib.RingTheory.Valuation.Basic
#align_import ring_theory.hahn_series from "leanprover-community/mathlib"@"a484a7d0eade4e1268f4fb402859b6686037f965"
/-!
# Hahn Series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and
`Γ`, we can add further structure on `HahnSeries Γ R`. We introduce valuations and a notion of
summability for possibly infinite families of series.
## Main Definitions
* `HahnSeries.addVal Γ R` defines an `AddValuation` on `HahnSeries Γ R` when `Γ` is linearly
ordered.
* A `HahnSeries.SummableFamily` is a family of Hahn series such that the union of their supports
is well-founded and only finitely many are nonzero at any given coefficient. They have a formal
sum, `HahnSeries.SummableFamily.hsum`, which can be bundled as a `LinearMap` as
`HahnSeries.SummableFamily.lsum`. Note that this is different from `Summable` in the valuation
topology, because there are topologically summable families that do not satisfy the axioms of
`HahnSeries.SummableFamily`, and formally summable families whose sums do not converge
topologically.
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
set_option linter.uppercaseLean3 false
open Finset Function
open scoped Classical
open Pointwise
noncomputable section
variable {Γ : Type*} {R : Type*}
namespace HahnSeries
section Valuation
variable (Γ R) [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series. -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
AddValuation.of (fun x => if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order)
(if_pos rfl) ((if_neg one_ne_zero).trans (by simp [order_of_ne]))
(fun x y => by
by_cases hx : x = 0
· by_cases hy : y = 0 <;> · simp [hx, hy]
· by_cases hy : y = 0
· simp [hx, hy]
· simp only [hx, hy, support_nonempty_iff, if_neg, not_false_iff, isWF_support]
by_cases hxy : x + y = 0
· simp [hxy]
rw [if_neg hxy, ← WithTop.coe_min, WithTop.coe_le_coe]
exact min_order_le_order_add hxy)
fun x y => by
by_cases hx : x = 0
· simp [hx]
by_cases hy : y = 0
· simp [hy]
dsimp only
rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), ← WithTop.coe_add, WithTop.coe_eq_coe,
order_mul hx hy]
#align hahn_series.add_val HahnSeries.addVal
variable {Γ} {R}
theorem addVal_apply {x : HahnSeries Γ R} :
addVal Γ R x = if x = (0 : HahnSeries Γ R) then (⊤ : WithTop Γ) else x.order :=
AddValuation.of_apply _
#align hahn_series.add_val_apply HahnSeries.addVal_apply
@[simp]
theorem addVal_apply_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) : addVal Γ R x = x.order :=
if_neg hx
#align hahn_series.add_val_apply_of_ne HahnSeries.addVal_apply_of_ne
theorem addVal_le_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) :
addVal Γ R x ≤ g := by
rw [addVal_apply_of_ne (ne_zero_of_coeff_ne_zero h), WithTop.coe_le_coe]
exact order_le_of_coeff_ne_zero h
#align hahn_series.add_val_le_of_coeff_ne_zero HahnSeries.addVal_le_of_coeff_ne_zero
end Valuation
theorem isPWO_iUnion_support_powers [LinearOrderedCancelAddCommMonoid Γ] [Ring R] [IsDomain R]
{x : HahnSeries Γ R} (hx : 0 < addVal Γ R x) : (⋃ n : ℕ, (x ^ n).support).IsPWO := by
apply (x.isWF_support.isPWO.addSubmonoid_closure _).mono _
· exact fun g hg => WithTop.coe_le_coe.1 (le_trans (le_of_lt hx) (addVal_le_of_coeff_ne_zero hg))
refine Set.iUnion_subset fun n => ?_
induction' n with n ih <;> intro g hn
· simp only [Nat.zero_eq, pow_zero, support_one, Set.mem_singleton_iff] at hn
rw [hn, SetLike.mem_coe]
exact AddSubmonoid.zero_mem _
· obtain ⟨i, hi, j, hj, rfl⟩ := support_mul_subset_add_support hn
exact SetLike.mem_coe.2 (AddSubmonoid.add_mem _ (ih hi) (AddSubmonoid.subset_closure hj))
#align hahn_series.is_pwo_Union_support_powers HahnSeries.isPWO_iUnion_support_powers
section
variable (Γ) (R) [PartialOrder Γ] [AddCommMonoid R]
/-- An infinite family of Hahn series which has a formal coefficient-wise sum.
The requirements for this are that the union of the supports of the series is well-founded,
and that only finitely many series are nonzero at any given coefficient. -/
structure SummableFamily (α : Type*) where
toFun : α → HahnSeries Γ R
isPWO_iUnion_support' : Set.IsPWO (⋃ a : α, (toFun a).support)
finite_co_support' : ∀ g : Γ, { a | (toFun a).coeff g ≠ 0 }.Finite
#align hahn_series.summable_family HahnSeries.SummableFamily
end
namespace SummableFamily
section AddCommMonoid
variable [PartialOrder Γ] [AddCommMonoid R] {α : Type*}
instance : FunLike (SummableFamily Γ R α) α (HahnSeries Γ R) where
coe := toFun
coe_injective' | ⟨_, _, _⟩, ⟨_, _, _⟩, rfl => rfl
theorem isPWO_iUnion_support (s : SummableFamily Γ R α) : Set.IsPWO (⋃ a : α, (s a).support) :=
s.isPWO_iUnion_support'
#align hahn_series.summable_family.is_pwo_Union_support HahnSeries.SummableFamily.isPWO_iUnion_support
theorem finite_co_support (s : SummableFamily Γ R α) (g : Γ) :
(Function.support fun a => (s a).coeff g).Finite :=
s.finite_co_support' g
#align hahn_series.summable_family.finite_co_support HahnSeries.SummableFamily.finite_co_support
theorem coe_injective : @Function.Injective (SummableFamily Γ R α) (α → HahnSeries Γ R) (⇑) :=
DFunLike.coe_injective
#align hahn_series.summable_family.coe_injective HahnSeries.SummableFamily.coe_injective
@[ext]
theorem ext {s t : SummableFamily Γ R α} (h : ∀ a : α, s a = t a) : s = t :=
DFunLike.ext s t h
#align hahn_series.summable_family.ext HahnSeries.SummableFamily.ext
instance : Add (SummableFamily Γ R α) :=
⟨fun x y =>
{ toFun := x + y
isPWO_iUnion_support' :=
(x.isPWO_iUnion_support.union y.isPWO_iUnion_support).mono
(by
rw [← Set.iUnion_union_distrib]
exact Set.iUnion_mono fun a => support_add_subset)
finite_co_support' := fun g =>
((x.finite_co_support g).union (y.finite_co_support g)).subset
(by
intro a ha
change (x a).coeff g + (y a).coeff g ≠ 0 at ha
rw [Set.mem_union, Function.mem_support, Function.mem_support]
contrapose! ha
rw [ha.1, ha.2, add_zero]) }⟩
instance : Zero (SummableFamily Γ R α) :=
⟨⟨0, by simp, by simp⟩⟩
instance : Inhabited (SummableFamily Γ R α) :=
⟨0⟩
@[simp]
theorem coe_add {s t : SummableFamily Γ R α} : ⇑(s + t) = s + t :=
rfl
#align hahn_series.summable_family.coe_add HahnSeries.SummableFamily.coe_add
theorem add_apply {s t : SummableFamily Γ R α} {a : α} : (s + t) a = s a + t a :=
rfl
#align hahn_series.summable_family.add_apply HahnSeries.SummableFamily.add_apply
@[simp]
theorem coe_zero : ((0 : SummableFamily Γ R α) : α → HahnSeries Γ R) = 0 :=
rfl
#align hahn_series.summable_family.coe_zero HahnSeries.SummableFamily.coe_zero
theorem zero_apply {a : α} : (0 : SummableFamily Γ R α) a = 0 :=
rfl
#align hahn_series.summable_family.zero_apply HahnSeries.SummableFamily.zero_apply
instance : AddCommMonoid (SummableFamily Γ R α) where
zero := 0
nsmul := nsmulRec
zero_add s := by
ext
apply zero_add
add_zero s := by
ext
apply add_zero
add_comm s t := by
ext
apply add_comm
add_assoc r s t := by
ext
apply add_assoc
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
coeff g := ∑ᶠ i, (s i).coeff g
isPWO_support' :=
s.isPWO_iUnion_support.mono fun g => by
contrapose
rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
simp_rw [mem_support, Classical.not_not]
intro h
rw [finsum_congr h, finsum_zero]
#align hahn_series.summable_family.hsum HahnSeries.SummableFamily.hsum
@[simp]
theorem hsum_coeff {s : SummableFamily Γ R α} {g : Γ} : s.hsum.coeff g = ∑ᶠ i, (s i).coeff g :=
rfl
#align hahn_series.summable_family.hsum_coeff HahnSeries.SummableFamily.hsum_coeff
theorem support_hsum_subset {s : SummableFamily Γ R α} : s.hsum.support ⊆ ⋃ a : α, (s a).support :=
fun g hg => by
rw [mem_support, hsum_coeff, finsum_eq_sum _ (s.finite_co_support _)] at hg
obtain ⟨a, _, h2⟩ := exists_ne_zero_of_sum_ne_zero hg
rw [Set.mem_iUnion]
exact ⟨a, h2⟩
#align hahn_series.summable_family.support_hsum_subset HahnSeries.SummableFamily.support_hsum_subset
@[simp]
theorem hsum_add {s t : SummableFamily Γ R α} : (s + t).hsum = s.hsum + t.hsum := by
ext g
simp only [hsum_coeff, add_coeff, add_apply]
exact finsum_add_distrib (s.finite_co_support _) (t.finite_co_support _)
#align hahn_series.summable_family.hsum_add HahnSeries.SummableFamily.hsum_add
end AddCommMonoid
section AddCommGroup
variable [PartialOrder Γ] [AddCommGroup R] {α : Type*} {s t : SummableFamily Γ R α} {a : α}
instance : Neg (SummableFamily Γ R α) :=
⟨fun s =>
{ toFun := fun a => -s a
isPWO_iUnion_support' := by
simp_rw [support_neg]
exact s.isPWO_iUnion_support
finite_co_support' := fun g => by
simp only [neg_coeff', Pi.neg_apply, Ne, neg_eq_zero]
exact s.finite_co_support g }⟩
instance : AddCommGroup (SummableFamily Γ R α) :=
{ inferInstanceAs (AddCommMonoid (SummableFamily Γ R α)) with
zsmul := zsmulRec
add_left_neg := fun a => by
ext
apply add_left_neg }
@[simp]
theorem coe_neg : ⇑(-s) = -s :=
rfl
#align hahn_series.summable_family.coe_neg HahnSeries.SummableFamily.coe_neg
theorem neg_apply : (-s) a = -s a :=
rfl
#align hahn_series.summable_family.neg_apply HahnSeries.SummableFamily.neg_apply
@[simp]
theorem coe_sub : ⇑(s - t) = s - t :=
rfl
#align hahn_series.summable_family.coe_sub HahnSeries.SummableFamily.coe_sub
theorem sub_apply : (s - t) a = s a - t a :=
rfl
#align hahn_series.summable_family.sub_apply HahnSeries.SummableFamily.sub_apply
end AddCommGroup
section Semiring
variable [OrderedCancelAddCommMonoid Γ] [Semiring R] {α : Type*}
instance : SMul (HahnSeries Γ R) (SummableFamily Γ R α) where
smul x s :=
{ toFun := fun a => x * s a
isPWO_iUnion_support' := by
apply (x.isPWO_support.add s.isPWO_iUnion_support).mono
refine Set.Subset.trans (Set.iUnion_mono fun a => support_mul_subset_add_support) ?_
intro g
simp only [Set.mem_iUnion, exists_imp]
exact fun a ha => (Set.add_subset_add (Set.Subset.refl _) (Set.subset_iUnion _ a)) ha
finite_co_support' := fun g => by
apply ((addAntidiagonal x.isPWO_support s.isPWO_iUnion_support g).finite_toSet.biUnion'
fun ij _ => ?_).subset fun a ha => ?_
· exact fun ij _ => Function.support fun a => (s a).coeff ij.2
· apply s.finite_co_support
· obtain ⟨i, hi, j, hj, rfl⟩ := support_mul_subset_add_support ha
simp only [exists_prop, Set.mem_iUnion, mem_addAntidiagonal, mul_coeff, mem_support,
isPWO_support, Prod.exists]
exact ⟨i, j, mem_coe.2 (mem_addAntidiagonal.2 ⟨hi, Set.mem_iUnion.2 ⟨a, hj⟩, rfl⟩), hj⟩ }
@[simp]
theorem smul_apply {x : HahnSeries Γ R} {s : SummableFamily Γ R α} {a : α} : (x • s) a = x * s a :=
rfl
#align hahn_series.summable_family.smul_apply HahnSeries.SummableFamily.smul_apply
instance : Module (HahnSeries Γ R) (SummableFamily Γ R α) where
smul := (· • ·)
smul_zero _ := ext fun _ => mul_zero _
zero_smul _ := ext fun _ => zero_mul _
one_smul _ := ext fun _ => one_mul _
add_smul _ _ _ := ext fun _ => add_mul _ _ _
smul_add _ _ _ := ext fun _ => mul_add _ _ _
mul_smul _ _ _ := ext fun _ => mul_assoc _ _ _
@[simp]
theorem hsum_smul {x : HahnSeries Γ R} {s : SummableFamily Γ R α} : (x • s).hsum = x * s.hsum := by
ext g
simp only [mul_coeff, hsum_coeff, smul_apply]
refine
(Eq.trans (finsum_congr fun a => ?_)
(finsum_sum_comm (addAntidiagonal x.isPWO_support s.isPWO_iUnion_support g)
(fun i ij => x.coeff (Prod.fst ij) * (s i).coeff ij.snd) ?_)).trans
?_
· refine sum_subset (addAntidiagonal_mono_right
(Set.subset_iUnion (fun j => support (toFun s j)) a)) ?_
rintro ⟨i, j⟩ hU ha
rw [mem_addAntidiagonal] at *
rw [Classical.not_not.1 fun con => ha ⟨hU.1, con, hU.2.2⟩, mul_zero]
· rintro ⟨i, j⟩ _
refine (s.finite_co_support j).subset ?_
simp_rw [Function.support_subset_iff', Function.mem_support, Classical.not_not]
intro a ha
rw [ha, mul_zero]
· refine (sum_congr rfl ?_).trans (sum_subset (addAntidiagonal_mono_right ?_) ?_).symm
· rintro ⟨i, j⟩ _
rw [mul_finsum]
apply s.finite_co_support
· intro x hx
simp only [Set.mem_iUnion, Ne, mem_support]
contrapose! hx
simp [hx]
· rintro ⟨i, j⟩ hU ha
rw [mem_addAntidiagonal] at *
rw [← hsum_coeff, Classical.not_not.1 fun con => ha ⟨hU.1, con, hU.2.2⟩,
mul_zero]
#align hahn_series.summable_family.hsum_smul HahnSeries.SummableFamily.hsum_smul
/-- The summation of a `summable_family` as a `LinearMap`. -/
@[simps]
def lsum : SummableFamily Γ R α →ₗ[HahnSeries Γ R] HahnSeries Γ R where
toFun := hsum
map_add' _ _ := hsum_add
map_smul' _ _ := hsum_smul
#align hahn_series.summable_family.lsum HahnSeries.SummableFamily.lsum
@[simp]
theorem hsum_sub {R : Type*} [Ring R] {s t : SummableFamily Γ R α} :
(s - t).hsum = s.hsum - t.hsum := by
rw [← lsum_apply, LinearMap.map_sub, lsum_apply, lsum_apply]
#align hahn_series.summable_family.hsum_sub HahnSeries.SummableFamily.hsum_sub
end Semiring
section OfFinsupp
variable [PartialOrder Γ] [AddCommMonoid R] {α : Type*}
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
toFun := f
isPWO_iUnion_support' := by
apply (f.support.isPWO_bUnion.2 fun a _ => (f a).isPWO_support).mono
refine Set.iUnion_subset_iff.2 fun a g hg => ?_
have haf : a ∈ f.support := by
rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
exact ⟨g, hg⟩
exact Set.mem_biUnion haf hg
finite_co_support' g := by
refine f.support.finite_toSet.subset fun a ha => ?_
simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne,
Function.mem_support]
contrapose! ha
simp [ha]
#align hahn_series.summable_family.of_finsupp HahnSeries.SummableFamily.ofFinsupp
@[simp]
theorem coe_ofFinsupp {f : α →₀ HahnSeries Γ R} : ⇑(SummableFamily.ofFinsupp f) = f :=
rfl
#align hahn_series.summable_family.coe_of_finsupp HahnSeries.SummableFamily.coe_ofFinsupp
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
ext g
simp only [hsum_coeff, coe_ofFinsupp, Finsupp.sum, Ne]
simp_rw [← coeff.addMonoidHom_apply, id]
rw [map_sum, finsum_eq_sum_of_support_subset]
intro x h
simp only [coeff.addMonoidHom_apply, mem_coe, Finsupp.mem_support_iff, Ne]
contrapose! h
simp [h]
#align hahn_series.summable_family.hsum_of_finsupp HahnSeries.SummableFamily.hsum_ofFinsupp
end OfFinsupp
section EmbDomain
variable [PartialOrder Γ] [AddCommMonoid R] {α β : Type*}
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
isPWO_iUnion_support' := by
refine s.isPWO_iUnion_support.mono (Set.iUnion_subset fun b g h => ?_)
by_cases hb : b ∈ Set.range f
· dsimp only at h
rw [dif_pos hb] at h
exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
· simp [-Set.mem_range, dif_neg hb] at h
finite_co_support' g :=
((s.finite_co_support g).image f).subset
(by
intro b h
by_cases hb : b ∈ Set.range f
· simp only [Ne, Set.mem_setOf_eq, dif_pos hb] at h
exact ⟨Classical.choose hb, h, Classical.choose_spec hb⟩
· simp only [Ne, Set.mem_setOf_eq, dif_neg hb, zero_coeff, not_true_eq_false] at h)
#align hahn_series.summable_family.emb_domain HahnSeries.SummableFamily.embDomain
variable (s : SummableFamily Γ R α) (f : α ↪ β) {a : α} {b : β}
theorem embDomain_apply :
s.embDomain f b = if h : b ∈ Set.range f then s (Classical.choose h) else 0 :=
rfl
#align hahn_series.summable_family.emb_domain_apply HahnSeries.SummableFamily.embDomain_apply
@[simp]
theorem embDomain_image : s.embDomain f (f a) = s a := by
rw [embDomain_apply, dif_pos (Set.mem_range_self a)]
exact congr rfl (f.injective (Classical.choose_spec (Set.mem_range_self a)))
#align hahn_series.summable_family.emb_domain_image HahnSeries.SummableFamily.embDomain_image
@[simp]
theorem embDomain_notin_range (h : b ∉ Set.range f) : s.embDomain f b = 0 := by
rw [embDomain_apply, dif_neg h]
#align hahn_series.summable_family.emb_domain_notin_range HahnSeries.SummableFamily.embDomain_notin_range
@[simp]
theorem hsum_embDomain : (s.embDomain f).hsum = s.hsum := by
ext g
simp only [hsum_coeff, embDomain_apply, apply_dite HahnSeries.coeff, dite_apply, zero_coeff]
exact finsum_emb_domain f fun a => (s a).coeff g
#align hahn_series.summable_family.hsum_emb_domain HahnSeries.SummableFamily.hsum_embDomain
end EmbDomain
section powers
variable [LinearOrderedCancelAddCommMonoid Γ] [CommRing R] [IsDomain R]
/-- The powers of an element of positive valuation form a summable family. -/
def powers (x : HahnSeries Γ R) (hx : 0 < addVal Γ R x) : SummableFamily Γ R ℕ where
toFun n := x ^ n
isPWO_iUnion_support' := isPWO_iUnion_support_powers hx
finite_co_support' g := by
have hpwo := isPWO_iUnion_support_powers hx
by_cases hg : g ∈ ⋃ n : ℕ, { g | (x ^ n).coeff g ≠ 0 }
swap; · exact Set.finite_empty.subset fun n hn => hg (Set.mem_iUnion.2 ⟨n, hn⟩)
apply hpwo.isWF.induction hg
intro y ys hy
refine
((((addAntidiagonal x.isPWO_support hpwo y).finite_toSet.biUnion fun ij hij =>
hy ij.snd ?_ ?_).image
Nat.succ).union
(Set.finite_singleton 0)).subset
?_
· exact (mem_addAntidiagonal.1 (mem_coe.1 hij)).2.1
· obtain ⟨hi, _, rfl⟩ := mem_addAntidiagonal.1 (mem_coe.1 hij)
rw [← zero_add ij.snd, ← add_assoc, add_zero]
exact
add_lt_add_right (WithTop.coe_lt_coe.1 (lt_of_lt_of_le hx (addVal_le_of_coeff_ne_zero hi)))
_
· rintro (_ | n) hn
· exact Set.mem_union_right _ (Set.mem_singleton 0)
· obtain ⟨i, hi, j, hj, rfl⟩ := support_mul_subset_add_support hn
refine Set.mem_union_left _ ⟨n, Set.mem_iUnion.2 ⟨⟨j, i⟩, Set.mem_iUnion.2 ⟨?_, hi⟩⟩, rfl⟩
simp only [and_true_iff, Set.mem_iUnion, mem_addAntidiagonal, mem_coe, eq_self_iff_true,
Ne, mem_support, Set.mem_setOf_eq]
exact ⟨hj, ⟨n, hi⟩, add_comm j i⟩
#align hahn_series.summable_family.powers HahnSeries.SummableFamily.powers
variable {x : HahnSeries Γ R} (hx : 0 < addVal Γ R x)
@[simp]
theorem coe_powers : ⇑(powers x hx) = HPow.hPow x :=
rfl
#align hahn_series.summable_family.coe_powers HahnSeries.SummableFamily.coe_powers
theorem embDomain_succ_smul_powers :
(x • powers x hx).embDomain ⟨Nat.succ, Nat.succ_injective⟩ =
powers x hx - ofFinsupp (Finsupp.single 0 1) := by
apply SummableFamily.ext
rintro (_ | n)
· rw [embDomain_notin_range, sub_apply, coe_powers, pow_zero, coe_ofFinsupp,
Finsupp.single_eq_same, sub_self]
rw [Set.mem_range, not_exists]
exact Nat.succ_ne_zero
· refine Eq.trans (embDomain_image _ ⟨Nat.succ, Nat.succ_injective⟩) ?_
simp only [pow_succ', coe_powers, coe_sub, smul_apply, coe_ofFinsupp, Pi.sub_apply]
rw [Finsupp.single_eq_of_ne n.succ_ne_zero.symm, sub_zero]
#align hahn_series.summable_family.emb_domain_succ_smul_powers HahnSeries.SummableFamily.embDomain_succ_smul_powers
| Mathlib/RingTheory/HahnSeries/Summable.lean | 518 | 521 | theorem one_sub_self_mul_hsum_powers : (1 - x) * (powers x hx).hsum = 1 := by |
rw [← hsum_smul, sub_smul 1 x (powers x hx), one_smul, hsum_sub, ←
hsum_embDomain (x • powers x hx) ⟨Nat.succ, Nat.succ_injective⟩, embDomain_succ_smul_powers]
simp
|
/-
Copyright (c) 2019 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Analysis.SpecificLimits.Basic
import Mathlib.Data.Rat.Denumerable
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.SetTheory.Cardinal.Continuum
#align_import data.real.cardinality from "leanprover-community/mathlib"@"7e7aaccf9b0182576cabdde36cf1b5ad3585b70d"
/-!
# The cardinality of the reals
This file shows that the real numbers have cardinality continuum, i.e. `#ℝ = 𝔠`.
We show that `#ℝ ≤ 𝔠` by noting that every real number is determined by a Cauchy-sequence of the
form `ℕ → ℚ`, which has cardinality `𝔠`. To show that `#ℝ ≥ 𝔠` we define an injection from
`{0, 1} ^ ℕ` to `ℝ` with `f ↦ Σ n, f n * (1 / 3) ^ n`.
We conclude that all intervals with distinct endpoints have cardinality continuum.
## Main definitions
* `Cardinal.cantorFunction` is the function that sends `f` in `{0, 1} ^ ℕ` to `ℝ` by
`f ↦ Σ' n, f n * (1 / 3) ^ n`
## Main statements
* `Cardinal.mk_real : #ℝ = 𝔠`: the reals have cardinality continuum.
* `Cardinal.not_countable_real`: the universal set of real numbers is not countable.
We can use this same proof to show that all the other sets in this file are not countable.
* 8 lemmas of the form `mk_Ixy_real` for `x,y ∈ {i,o,c}` state that intervals on the reals
have cardinality continuum.
## Notation
* `𝔠` : notation for `Cardinal.Continuum` in locale `Cardinal`, defined in `SetTheory.Continuum`.
## Tags
continuum, cardinality, reals, cardinality of the reals
-/
open Nat Set
open Cardinal
noncomputable section
namespace Cardinal
variable {c : ℝ} {f g : ℕ → Bool} {n : ℕ}
/-- The body of the sum in `cantorFunction`.
`cantorFunctionAux c f n = c ^ n` if `f n = true`;
`cantorFunctionAux c f n = 0` if `f n = false`. -/
def cantorFunctionAux (c : ℝ) (f : ℕ → Bool) (n : ℕ) : ℝ :=
cond (f n) (c ^ n) 0
#align cardinal.cantor_function_aux Cardinal.cantorFunctionAux
@[simp]
theorem cantorFunctionAux_true (h : f n = true) : cantorFunctionAux c f n = c ^ n := by
simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_tt Cardinal.cantorFunctionAux_true
@[simp]
theorem cantorFunctionAux_false (h : f n = false) : cantorFunctionAux c f n = 0 := by
simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_ff Cardinal.cantorFunctionAux_false
theorem cantorFunctionAux_nonneg (h : 0 ≤ c) : 0 ≤ cantorFunctionAux c f n := by
cases h' : f n <;> simp [h']
apply pow_nonneg h
#align cardinal.cantor_function_aux_nonneg Cardinal.cantorFunctionAux_nonneg
theorem cantorFunctionAux_eq (h : f n = g n) :
cantorFunctionAux c f n = cantorFunctionAux c g n := by simp [cantorFunctionAux, h]
#align cardinal.cantor_function_aux_eq Cardinal.cantorFunctionAux_eq
theorem cantorFunctionAux_zero (f : ℕ → Bool) : cantorFunctionAux c f 0 = cond (f 0) 1 0 := by
cases h : f 0 <;> simp [h]
#align cardinal.cantor_function_aux_zero Cardinal.cantorFunctionAux_zero
theorem cantorFunctionAux_succ (f : ℕ → Bool) :
(fun n => cantorFunctionAux c f (n + 1)) = fun n =>
c * cantorFunctionAux c (fun n => f (n + 1)) n := by
ext n
cases h : f (n + 1) <;> simp [h, _root_.pow_succ']
#align cardinal.cantor_function_aux_succ Cardinal.cantorFunctionAux_succ
theorem summable_cantor_function (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :
Summable (cantorFunctionAux c f) := by
apply (summable_geometric_of_lt_one h1 h2).summable_of_eq_zero_or_self
intro n; cases h : f n <;> simp [h]
#align cardinal.summable_cantor_function Cardinal.summable_cantor_function
/-- `cantorFunction c (f : ℕ → Bool)` is `Σ n, f n * c ^ n`, where `true` is interpreted as `1` and
`false` is interpreted as `0`. It is implemented using `cantorFunctionAux`. -/
def cantorFunction (c : ℝ) (f : ℕ → Bool) : ℝ :=
∑' n, cantorFunctionAux c f n
#align cardinal.cantor_function Cardinal.cantorFunction
theorem cantorFunction_le (h1 : 0 ≤ c) (h2 : c < 1) (h3 : ∀ n, f n → g n) :
cantorFunction c f ≤ cantorFunction c g := by
apply tsum_le_tsum _ (summable_cantor_function f h1 h2) (summable_cantor_function g h1 h2)
intro n; cases h : f n
· simp [h, cantorFunctionAux_nonneg h1]
replace h3 : g n = true := h3 n h; simp [h, h3]
#align cardinal.cantor_function_le Cardinal.cantorFunction_le
theorem cantorFunction_succ (f : ℕ → Bool) (h1 : 0 ≤ c) (h2 : c < 1) :
cantorFunction c f = cond (f 0) 1 0 + c * cantorFunction c fun n => f (n + 1) := by
rw [cantorFunction, tsum_eq_zero_add (summable_cantor_function f h1 h2)]
rw [cantorFunctionAux_succ, tsum_mul_left, cantorFunctionAux, _root_.pow_zero]
rfl
#align cardinal.cantor_function_succ Cardinal.cantorFunction_succ
/-- `cantorFunction c` is strictly increasing with if `0 < c < 1/2`, if we endow `ℕ → Bool` with a
lexicographic order. The lexicographic order doesn't exist for these infinitary products, so we
explicitly write out what it means. -/
theorem increasing_cantorFunction (h1 : 0 < c) (h2 : c < 1 / 2) {n : ℕ} {f g : ℕ → Bool}
(hn : ∀ k < n, f k = g k) (fn : f n = false) (gn : g n = true) :
cantorFunction c f < cantorFunction c g := by
have h3 : c < 1 := by
apply h2.trans
norm_num
induction' n with n ih generalizing f g
· let f_max : ℕ → Bool := fun n => Nat.rec false (fun _ _ => true) n
have hf_max : ∀ n, f n → f_max n := by
intro n hn
cases n
· rw [fn] at hn
contradiction
apply rfl
let g_min : ℕ → Bool := fun n => Nat.rec true (fun _ _ => false) n
have hg_min : ∀ n, g_min n → g n := by
intro n hn
cases n
· rw [gn]
simp at hn
apply (cantorFunction_le (le_of_lt h1) h3 hf_max).trans_lt
refine lt_of_lt_of_le ?_ (cantorFunction_le (le_of_lt h1) h3 hg_min)
have : c / (1 - c) < 1 := by
rw [div_lt_one, lt_sub_iff_add_lt]
· convert _root_.add_lt_add h2 h2
norm_num
rwa [sub_pos]
convert this
· rw [cantorFunction_succ _ (le_of_lt h1) h3, div_eq_mul_inv, ←
tsum_geometric_of_lt_one (le_of_lt h1) h3]
apply zero_add
· refine (tsum_eq_single 0 ?_).trans ?_
· intro n hn
cases n
· contradiction
rfl
· exact cantorFunctionAux_zero _
rw [cantorFunction_succ f (le_of_lt h1) h3, cantorFunction_succ g (le_of_lt h1) h3]
rw [hn 0 <| zero_lt_succ n]
apply add_lt_add_left
rw [mul_lt_mul_left h1]
exact ih (fun k hk => hn _ <| Nat.succ_lt_succ hk) fn gn
#align cardinal.increasing_cantor_function Cardinal.increasing_cantorFunction
/-- `cantorFunction c` is injective if `0 < c < 1/2`. -/
theorem cantorFunction_injective (h1 : 0 < c) (h2 : c < 1 / 2) :
Function.Injective (cantorFunction c) := by
intro f g hfg
classical
by_contra h
revert hfg
have : ∃ n, f n ≠ g n := by
rw [← not_forall]
intro h'
apply h
ext
apply h'
let n := Nat.find this
have hn : ∀ k : ℕ, k < n → f k = g k := by
intro k hk
apply of_not_not
exact Nat.find_min this hk
cases fn : f n
· apply _root_.ne_of_lt
refine increasing_cantorFunction h1 h2 hn fn ?_
apply Bool.eq_true_of_not_eq_false
rw [← fn]
apply Ne.symm
exact Nat.find_spec this
· apply _root_.ne_of_gt
refine increasing_cantorFunction h1 h2 (fun k hk => (hn k hk).symm) ?_ fn
apply Bool.eq_false_of_not_eq_true
rw [← fn]
apply Ne.symm
exact Nat.find_spec this
#align cardinal.cantor_function_injective Cardinal.cantorFunction_injective
/-- The cardinality of the reals, as a type. -/
theorem mk_real : #ℝ = 𝔠 := by
apply le_antisymm
· rw [Real.equivCauchy.cardinal_eq]
apply mk_quotient_le.trans
apply (mk_subtype_le _).trans_eq
rw [← power_def, mk_nat, mkRat, aleph0_power_aleph0]
· convert mk_le_of_injective (cantorFunction_injective _ _)
· rw [← power_def, mk_bool, mk_nat, two_power_aleph0]
· exact 1 / 3
· norm_num
· norm_num
#align cardinal.mk_real Cardinal.mk_real
/-- The cardinality of the reals, as a set. -/
theorem mk_univ_real : #(Set.univ : Set ℝ) = 𝔠 := by rw [mk_univ, mk_real]
#align cardinal.mk_univ_real Cardinal.mk_univ_real
/-- **Non-Denumerability of the Continuum**: The reals are not countable. -/
| Mathlib/Data/Real/Cardinality.lean | 219 | 221 | theorem not_countable_real : ¬(Set.univ : Set ℝ).Countable := by |
rw [← le_aleph0_iff_set_countable, not_le, mk_univ_real]
apply cantor
|
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.Algebra.Field.Rat
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.GroupWithZero.Units.Lemmas
import Mathlib.Algebra.Order.Field.Rat
import Mathlib.Data.Int.Cast.Lemmas
import Mathlib.Data.Rat.Lemmas
#align_import data.rat.cast from "leanprover-community/mathlib"@"acebd8d49928f6ed8920e502a6c90674e75bd441"
/-!
# Casts for Rational Numbers
## Summary
We define the canonical injection from ℚ into an arbitrary division ring and prove various
casting lemmas showing the well-behavedness of this injection.
## Notations
- `/.` is infix notation for `Rat.divInt`.
## Tags
rat, rationals, field, ℚ, numerator, denominator, num, denom, cast, coercion, casting
-/
variable {F ι α β : Type*}
namespace NNRat
variable [DivisionSemiring α] {q r : ℚ≥0}
@[simp, norm_cast] lemma cast_natCast (n : ℕ) : ((n : ℚ≥0) : α) = n := by simp [cast_def]
-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast] lemma cast_ofNat (n : ℕ) [n.AtLeastTwo] :
no_index (OfNat.ofNat n : ℚ≥0) = (OfNat.ofNat n : α) := cast_natCast _
@[simp, norm_cast] lemma cast_zero : ((0 : ℚ≥0) : α) = 0 := (cast_natCast _).trans Nat.cast_zero
@[simp, norm_cast] lemma cast_one : ((1 : ℚ≥0) : α) = 1 := (cast_natCast _).trans Nat.cast_one
lemma cast_commute (q : ℚ≥0) (a : α) : Commute (↑q) a := by
simpa only [cast_def] using (q.num.cast_commute a).div_left (q.den.cast_commute a)
lemma commute_cast (a : α) (q : ℚ≥0) : Commute a q := (cast_commute ..).symm
lemma cast_comm (q : ℚ≥0) (a : α) : q * a = a * q := cast_commute _ _
@[norm_cast] lemma cast_divNat_of_ne_zero (a : ℕ) {b : ℕ} (hb : (b : α) ≠ 0) :
divNat a b = (a / b : α) := by
rcases e : divNat a b with ⟨⟨n, d, h, c⟩, hn⟩
rw [← Rat.num_nonneg] at hn
lift n to ℕ using hn
have hd : (d : α) ≠ 0 := by
refine fun hd ↦ hb ?_
have : Rat.divInt a b = _ := congr_arg NNRat.cast e
obtain ⟨k, rfl⟩ : d ∣ b := by simpa [Int.natCast_dvd_natCast, this] using Rat.den_dvd a b
simp [*]
have hb' : b ≠ 0 := by rintro rfl; exact hb Nat.cast_zero
have hd' : d ≠ 0 := by rintro rfl; exact hd Nat.cast_zero
simp_rw [Rat.mk'_eq_divInt, mk_divInt, divNat_inj hb' hd'] at e
rw [cast_def]
dsimp
rw [Commute.div_eq_div_iff _ hd hb]
· norm_cast
rw [e]
exact b.commute_cast _
@[norm_cast]
lemma cast_add_of_ne_zero (hq : (q.den : α) ≠ 0) (hr : (r.den : α) ≠ 0) :
↑(q + r) = (q + r : α) := by
rw [add_def, cast_divNat_of_ne_zero, cast_def, cast_def, mul_comm _ q.den,
(Nat.commute_cast _ _).div_add_div (Nat.commute_cast _ _) hq hr]
· push_cast
rfl
· push_cast
exact mul_ne_zero hq hr
@[norm_cast]
lemma cast_mul_of_ne_zero (hq : (q.den : α) ≠ 0) (hr : (r.den : α) ≠ 0) :
↑(q * r) = (q * r : α) := by
rw [mul_def, cast_divNat_of_ne_zero, cast_def, cast_def,
(Nat.commute_cast _ _).div_mul_div_comm (Nat.commute_cast _ _)]
· push_cast
rfl
· push_cast
exact mul_ne_zero hq hr
@[norm_cast]
lemma cast_inv_of_ne_zero (hq : (q.num : α) ≠ 0) : (q⁻¹ : ℚ≥0) = (q⁻¹ : α) := by
rw [inv_def, cast_divNat_of_ne_zero _ hq, cast_def, inv_div]
@[norm_cast]
lemma cast_div_of_ne_zero (hq : (q.den : α) ≠ 0) (hr : (r.num : α) ≠ 0) :
↑(q / r) = (q / r : α) := by
rw [div_def, cast_divNat_of_ne_zero, cast_def, cast_def, div_eq_mul_inv (_ / _),
inv_div, (Nat.commute_cast _ _).div_mul_div_comm (Nat.commute_cast _ _)]
· push_cast
rfl
· push_cast
exact mul_ne_zero hq hr
end NNRat
namespace Rat
variable [DivisionRing α] {p q : ℚ}
@[simp, norm_cast]
theorem cast_intCast (n : ℤ) : ((n : ℚ) : α) = n :=
(cast_def _).trans <| show (n / (1 : ℕ) : α) = n by rw [Nat.cast_one, div_one]
#align rat.cast_coe_int Rat.cast_intCast
@[simp, norm_cast]
| Mathlib/Data/Rat/Cast/Defs.lean | 120 | 121 | theorem cast_natCast (n : ℕ) : ((n : ℚ) : α) = n := by |
rw [← Int.cast_natCast, cast_intCast, Int.cast_natCast]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Yury Kudryashov
-/
import Mathlib.Algebra.Order.Ring.WithTop
import Mathlib.Algebra.Order.Sub.WithTop
import Mathlib.Data.Real.NNReal
import Mathlib.Order.Interval.Set.WithBotTop
#align_import data.real.ennreal from "leanprover-community/mathlib"@"c14c8fcde993801fca8946b0d80131a1a81d1520"
/-!
# Extended non-negative reals
We define `ENNReal = ℝ≥0∞ := WithTop ℝ≥0` to be the type of extended nonnegative real numbers,
i.e., the interval `[0, +∞]`. This type is used as the codomain of a `MeasureTheory.Measure`,
and of the extended distance `edist` in an `EMetricSpace`.
In this file we set up many of the instances on `ℝ≥0∞`, and provide relationships between `ℝ≥0∞` and
`ℝ≥0`, and between `ℝ≥0∞` and `ℝ`. In particular, we provide a coercion from `ℝ≥0` to `ℝ≥0∞` as well
as functions `ENNReal.toNNReal`, `ENNReal.ofReal` and `ENNReal.toReal`, all of which take the value
zero wherever they cannot be the identity. Also included is the relationship between `ℝ≥0∞` and `ℕ`.
The interaction of these functions, especially `ENNReal.ofReal` and `ENNReal.toReal`, with the
algebraic and lattice structure can be found in `Data.ENNReal.Real`.
This file proves many of the order properties of `ℝ≥0∞`, with the exception of the ways those relate
to the algebraic structure, which are included in `Data.ENNReal.Operations`.
This file also defines inversion and division: this includes `Inv` and `Div` instances on `ℝ≥0∞`
making it into a `DivInvOneMonoid`.
As a consequence of being a `DivInvOneMonoid`, `ℝ≥0∞` inherits a power operation with integer
exponent: this and other properties is shown in `Data.ENNReal.Inv`.
## Main definitions
* `ℝ≥0∞`: the extended nonnegative real numbers `[0, ∞]`; defined as `WithTop ℝ≥0`; it is
equipped with the following structures:
- coercion from `ℝ≥0` defined in the natural way;
- the natural structure of a complete dense linear order: `↑p ≤ ↑q ↔ p ≤ q` and `∀ a, a ≤ ∞`;
- `a + b` is defined so that `↑p + ↑q = ↑(p + q)` for `(p q : ℝ≥0)` and `a + ∞ = ∞ + a = ∞`;
- `a * b` is defined so that `↑p * ↑q = ↑(p * q)` for `(p q : ℝ≥0)`, `0 * ∞ = ∞ * 0 = 0`, and
`a * ∞ = ∞ * a = ∞` for `a ≠ 0`;
- `a - b` is defined as the minimal `d` such that `a ≤ d + b`; this way we have
`↑p - ↑q = ↑(p - q)`, `∞ - ↑p = ∞`, `↑p - ∞ = ∞ - ∞ = 0`; note that there is no negation, only
subtraction;
The addition and multiplication defined this way together with `0 = ↑0` and `1 = ↑1` turn
`ℝ≥0∞` into a canonically ordered commutative semiring of characteristic zero.
- `a⁻¹` is defined as `Inf {b | 1 ≤ a * b}`. This way we have `(↑p)⁻¹ = ↑(p⁻¹)` for
`p : ℝ≥0`, `p ≠ 0`, `0⁻¹ = ∞`, and `∞⁻¹ = 0`.
- `a / b` is defined as `a * b⁻¹`.
This inversion and division include `Inv` and `Div` instances on `ℝ≥0∞`,
making it into a `DivInvOneMonoid`. Further properties of these are shown in `Data.ENNReal.Inv`.
* Coercions to/from other types:
- coercion `ℝ≥0 → ℝ≥0∞` is defined as `Coe`, so one can use `(p : ℝ≥0)` in a context that
expects `a : ℝ≥0∞`, and Lean will apply `coe` automatically;
- `ENNReal.toNNReal` sends `↑p` to `p` and `∞` to `0`;
- `ENNReal.toReal := coe ∘ ENNReal.toNNReal` sends `↑p`, `p : ℝ≥0` to `(↑p : ℝ)` and `∞` to `0`;
- `ENNReal.ofReal := coe ∘ Real.toNNReal` sends `x : ℝ` to `↑⟨max x 0, _⟩`
- `ENNReal.neTopEquivNNReal` is an equivalence between `{a : ℝ≥0∞ // a ≠ 0}` and `ℝ≥0`.
## Implementation notes
We define a `CanLift ℝ≥0∞ ℝ≥0` instance, so one of the ways to prove theorems about an `ℝ≥0∞`
number `a` is to consider the cases `a = ∞` and `a ≠ ∞`, and use the tactic `lift a to ℝ≥0 using ha`
in the second case. This instance is even more useful if one already has `ha : a ≠ ∞` in the
context, or if we have `(f : α → ℝ≥0∞) (hf : ∀ x, f x ≠ ∞)`.
## Notations
* `ℝ≥0∞`: the type of the extended nonnegative real numbers;
* `ℝ≥0`: the type of nonnegative real numbers `[0, ∞)`; defined in `Data.Real.NNReal`;
* `∞`: a localized notation in `ENNReal` for `⊤ : ℝ≥0∞`.
-/
open Function Set NNReal
variable {α : Type*}
/-- The extended nonnegative real numbers. This is usually denoted [0, ∞],
and is relevant as the codomain of a measure. -/
def ENNReal := WithTop ℝ≥0
deriving Zero, AddCommMonoidWithOne, SemilatticeSup, DistribLattice, Nontrivial
#align ennreal ENNReal
@[inherit_doc]
scoped[ENNReal] notation "ℝ≥0∞" => ENNReal
/-- Notation for infinity as an `ENNReal` number. -/
scoped[ENNReal] notation "∞" => (⊤ : ENNReal)
namespace ENNReal
instance : OrderBot ℝ≥0∞ := inferInstanceAs (OrderBot (WithTop ℝ≥0))
instance : BoundedOrder ℝ≥0∞ := inferInstanceAs (BoundedOrder (WithTop ℝ≥0))
instance : CharZero ℝ≥0∞ := inferInstanceAs (CharZero (WithTop ℝ≥0))
noncomputable instance : CanonicallyOrderedCommSemiring ℝ≥0∞ :=
inferInstanceAs (CanonicallyOrderedCommSemiring (WithTop ℝ≥0))
noncomputable instance : CompleteLinearOrder ℝ≥0∞ :=
inferInstanceAs (CompleteLinearOrder (WithTop ℝ≥0))
instance : DenselyOrdered ℝ≥0∞ := inferInstanceAs (DenselyOrdered (WithTop ℝ≥0))
noncomputable instance : CanonicallyLinearOrderedAddCommMonoid ℝ≥0∞ :=
inferInstanceAs (CanonicallyLinearOrderedAddCommMonoid (WithTop ℝ≥0))
noncomputable instance instSub : Sub ℝ≥0∞ := inferInstanceAs (Sub (WithTop ℝ≥0))
noncomputable instance : OrderedSub ℝ≥0∞ := inferInstanceAs (OrderedSub (WithTop ℝ≥0))
noncomputable instance : LinearOrderedAddCommMonoidWithTop ℝ≥0∞ :=
inferInstanceAs (LinearOrderedAddCommMonoidWithTop (WithTop ℝ≥0))
-- Porting note: rfc: redefine using pattern matching?
noncomputable instance : Inv ℝ≥0∞ := ⟨fun a => sInf { b | 1 ≤ a * b }⟩
noncomputable instance : DivInvMonoid ℝ≥0∞ where
variable {a b c d : ℝ≥0∞} {r p q : ℝ≥0}
-- Porting note: are these 2 instances still required in Lean 4?
instance covariantClass_mul_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· * ·) (· ≤ ·) := inferInstance
#align ennreal.covariant_class_mul_le ENNReal.covariantClass_mul_le
instance covariantClass_add_le : CovariantClass ℝ≥0∞ ℝ≥0∞ (· + ·) (· ≤ ·) := inferInstance
#align ennreal.covariant_class_add_le ENNReal.covariantClass_add_le
-- Porting note (#11215): TODO: add a `WithTop` instance and use it here
noncomputable instance : LinearOrderedCommMonoidWithZero ℝ≥0∞ :=
{ inferInstanceAs (LinearOrderedAddCommMonoidWithTop ℝ≥0∞),
inferInstanceAs (CommSemiring ℝ≥0∞) with
mul_le_mul_left := fun _ _ => mul_le_mul_left'
zero_le_one := zero_le 1 }
noncomputable instance : Unique (AddUnits ℝ≥0∞) where
default := 0
uniq a := AddUnits.ext <| le_zero_iff.1 <| by rw [← a.add_neg]; exact le_self_add
instance : Inhabited ℝ≥0∞ := ⟨0⟩
/-- Coercion from `ℝ≥0` to `ℝ≥0∞`. -/
@[coe, match_pattern] def ofNNReal : ℝ≥0 → ℝ≥0∞ := WithTop.some
instance : Coe ℝ≥0 ℝ≥0∞ := ⟨ofNNReal⟩
/-- A version of `WithTop.recTopCoe` that uses `ENNReal.ofNNReal`. -/
@[elab_as_elim, induction_eliminator, cases_eliminator]
def recTopCoe {C : ℝ≥0∞ → Sort*} (top : C ∞) (coe : ∀ x : ℝ≥0, C x) (x : ℝ≥0∞) : C x :=
WithTop.recTopCoe top coe x
instance canLift : CanLift ℝ≥0∞ ℝ≥0 ofNNReal (· ≠ ∞) := WithTop.canLift
#align ennreal.can_lift ENNReal.canLift
@[simp] theorem none_eq_top : (none : ℝ≥0∞) = ∞ := rfl
#align ennreal.none_eq_top ENNReal.none_eq_top
@[simp] theorem some_eq_coe (a : ℝ≥0) : (Option.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl
#align ennreal.some_eq_coe ENNReal.some_eq_coe
@[simp] theorem some_eq_coe' (a : ℝ≥0) : (WithTop.some a : ℝ≥0∞) = (↑a : ℝ≥0∞) := rfl
lemma coe_injective : Injective ((↑) : ℝ≥0 → ℝ≥0∞) := WithTop.coe_injective
@[simp, norm_cast] lemma coe_inj : (p : ℝ≥0∞) = q ↔ p = q := coe_injective.eq_iff
#align ennreal.coe_eq_coe ENNReal.coe_inj
lemma coe_ne_coe : (p : ℝ≥0∞) ≠ q ↔ p ≠ q := coe_inj.not
theorem range_coe' : range ofNNReal = Iio ∞ := WithTop.range_coe
theorem range_coe : range ofNNReal = {∞}ᶜ := (isCompl_range_some_none ℝ≥0).symm.compl_eq.symm
/-- `toNNReal x` returns `x` if it is real, otherwise 0. -/
protected def toNNReal : ℝ≥0∞ → ℝ≥0 := WithTop.untop' 0
#align ennreal.to_nnreal ENNReal.toNNReal
/-- `toReal x` returns `x` if it is real, `0` otherwise. -/
protected def toReal (a : ℝ≥0∞) : Real := a.toNNReal
#align ennreal.to_real ENNReal.toReal
/-- `ofReal x` returns `x` if it is nonnegative, `0` otherwise. -/
protected noncomputable def ofReal (r : Real) : ℝ≥0∞ := r.toNNReal
#align ennreal.of_real ENNReal.ofReal
@[simp, norm_cast]
theorem toNNReal_coe : (r : ℝ≥0∞).toNNReal = r := rfl
#align ennreal.to_nnreal_coe ENNReal.toNNReal_coe
@[simp]
theorem coe_toNNReal : ∀ {a : ℝ≥0∞}, a ≠ ∞ → ↑a.toNNReal = a
| ofNNReal _, _ => rfl
| ⊤, h => (h rfl).elim
#align ennreal.coe_to_nnreal ENNReal.coe_toNNReal
@[simp]
theorem ofReal_toReal {a : ℝ≥0∞} (h : a ≠ ∞) : ENNReal.ofReal a.toReal = a := by
simp [ENNReal.toReal, ENNReal.ofReal, h]
#align ennreal.of_real_to_real ENNReal.ofReal_toReal
@[simp]
theorem toReal_ofReal {r : ℝ} (h : 0 ≤ r) : (ENNReal.ofReal r).toReal = r :=
max_eq_left h
#align ennreal.to_real_of_real ENNReal.toReal_ofReal
theorem toReal_ofReal' {r : ℝ} : (ENNReal.ofReal r).toReal = max r 0 := rfl
#align ennreal.to_real_of_real' ENNReal.toReal_ofReal'
theorem coe_toNNReal_le_self : ∀ {a : ℝ≥0∞}, ↑a.toNNReal ≤ a
| ofNNReal r => by rw [toNNReal_coe]
| ⊤ => le_top
#align ennreal.coe_to_nnreal_le_self ENNReal.coe_toNNReal_le_self
theorem coe_nnreal_eq (r : ℝ≥0) : (r : ℝ≥0∞) = ENNReal.ofReal r := by
rw [ENNReal.ofReal, Real.toNNReal_coe]
#align ennreal.coe_nnreal_eq ENNReal.coe_nnreal_eq
theorem ofReal_eq_coe_nnreal {x : ℝ} (h : 0 ≤ x) :
ENNReal.ofReal x = ofNNReal ⟨x, h⟩ :=
(coe_nnreal_eq ⟨x, h⟩).symm
#align ennreal.of_real_eq_coe_nnreal ENNReal.ofReal_eq_coe_nnreal
@[simp] theorem ofReal_coe_nnreal : ENNReal.ofReal p = p := (coe_nnreal_eq p).symm
#align ennreal.of_real_coe_nnreal ENNReal.ofReal_coe_nnreal
@[simp, norm_cast] theorem coe_zero : ↑(0 : ℝ≥0) = (0 : ℝ≥0∞) := rfl
#align ennreal.coe_zero ENNReal.coe_zero
@[simp, norm_cast] theorem coe_one : ↑(1 : ℝ≥0) = (1 : ℝ≥0∞) := rfl
#align ennreal.coe_one ENNReal.coe_one
@[simp] theorem toReal_nonneg {a : ℝ≥0∞} : 0 ≤ a.toReal := a.toNNReal.2
#align ennreal.to_real_nonneg ENNReal.toReal_nonneg
@[simp] theorem top_toNNReal : ∞.toNNReal = 0 := rfl
#align ennreal.top_to_nnreal ENNReal.top_toNNReal
@[simp] theorem top_toReal : ∞.toReal = 0 := rfl
#align ennreal.top_to_real ENNReal.top_toReal
@[simp] theorem one_toReal : (1 : ℝ≥0∞).toReal = 1 := rfl
#align ennreal.one_to_real ENNReal.one_toReal
@[simp] theorem one_toNNReal : (1 : ℝ≥0∞).toNNReal = 1 := rfl
#align ennreal.one_to_nnreal ENNReal.one_toNNReal
@[simp] theorem coe_toReal (r : ℝ≥0) : (r : ℝ≥0∞).toReal = r := rfl
#align ennreal.coe_to_real ENNReal.coe_toReal
@[simp] theorem zero_toNNReal : (0 : ℝ≥0∞).toNNReal = 0 := rfl
#align ennreal.zero_to_nnreal ENNReal.zero_toNNReal
@[simp] theorem zero_toReal : (0 : ℝ≥0∞).toReal = 0 := rfl
#align ennreal.zero_to_real ENNReal.zero_toReal
@[simp] theorem ofReal_zero : ENNReal.ofReal (0 : ℝ) = 0 := by simp [ENNReal.ofReal]
#align ennreal.of_real_zero ENNReal.ofReal_zero
@[simp] theorem ofReal_one : ENNReal.ofReal (1 : ℝ) = (1 : ℝ≥0∞) := by simp [ENNReal.ofReal]
#align ennreal.of_real_one ENNReal.ofReal_one
theorem ofReal_toReal_le {a : ℝ≥0∞} : ENNReal.ofReal a.toReal ≤ a :=
if ha : a = ∞ then ha.symm ▸ le_top else le_of_eq (ofReal_toReal ha)
#align ennreal.of_real_to_real_le ENNReal.ofReal_toReal_le
theorem forall_ennreal {p : ℝ≥0∞ → Prop} : (∀ a, p a) ↔ (∀ r : ℝ≥0, p r) ∧ p ∞ :=
Option.forall.trans and_comm
#align ennreal.forall_ennreal ENNReal.forall_ennreal
theorem forall_ne_top {p : ℝ≥0∞ → Prop} : (∀ a, a ≠ ∞ → p a) ↔ ∀ r : ℝ≥0, p r :=
Option.ball_ne_none
#align ennreal.forall_ne_top ENNReal.forall_ne_top
theorem exists_ne_top {p : ℝ≥0∞ → Prop} : (∃ a ≠ ∞, p a) ↔ ∃ r : ℝ≥0, p r :=
Option.exists_ne_none
#align ennreal.exists_ne_top ENNReal.exists_ne_top
theorem toNNReal_eq_zero_iff (x : ℝ≥0∞) : x.toNNReal = 0 ↔ x = 0 ∨ x = ∞ :=
WithTop.untop'_eq_self_iff
#align ennreal.to_nnreal_eq_zero_iff ENNReal.toNNReal_eq_zero_iff
theorem toReal_eq_zero_iff (x : ℝ≥0∞) : x.toReal = 0 ↔ x = 0 ∨ x = ∞ := by
simp [ENNReal.toReal, toNNReal_eq_zero_iff]
#align ennreal.to_real_eq_zero_iff ENNReal.toReal_eq_zero_iff
theorem toNNReal_ne_zero : a.toNNReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ :=
a.toNNReal_eq_zero_iff.not.trans not_or
#align ennreal.to_nnreal_ne_zero ENNReal.toNNReal_ne_zero
theorem toReal_ne_zero : a.toReal ≠ 0 ↔ a ≠ 0 ∧ a ≠ ∞ :=
a.toReal_eq_zero_iff.not.trans not_or
#align ennreal.to_real_ne_zero ENNReal.toReal_ne_zero
theorem toNNReal_eq_one_iff (x : ℝ≥0∞) : x.toNNReal = 1 ↔ x = 1 :=
WithTop.untop'_eq_iff.trans <| by simp
#align ennreal.to_nnreal_eq_one_iff ENNReal.toNNReal_eq_one_iff
theorem toReal_eq_one_iff (x : ℝ≥0∞) : x.toReal = 1 ↔ x = 1 := by
rw [ENNReal.toReal, NNReal.coe_eq_one, ENNReal.toNNReal_eq_one_iff]
#align ennreal.to_real_eq_one_iff ENNReal.toReal_eq_one_iff
theorem toNNReal_ne_one : a.toNNReal ≠ 1 ↔ a ≠ 1 :=
a.toNNReal_eq_one_iff.not
#align ennreal.to_nnreal_ne_one ENNReal.toNNReal_ne_one
theorem toReal_ne_one : a.toReal ≠ 1 ↔ a ≠ 1 :=
a.toReal_eq_one_iff.not
#align ennreal.to_real_ne_one ENNReal.toReal_ne_one
@[simp] theorem coe_ne_top : (r : ℝ≥0∞) ≠ ∞ := WithTop.coe_ne_top
#align ennreal.coe_ne_top ENNReal.coe_ne_top
@[simp] theorem top_ne_coe : ∞ ≠ (r : ℝ≥0∞) := WithTop.top_ne_coe
#align ennreal.top_ne_coe ENNReal.top_ne_coe
@[simp] theorem coe_lt_top : (r : ℝ≥0∞) < ∞ := WithTop.coe_lt_top r
#align ennreal.coe_lt_top ENNReal.coe_lt_top
@[simp] theorem ofReal_ne_top {r : ℝ} : ENNReal.ofReal r ≠ ∞ := coe_ne_top
#align ennreal.of_real_ne_top ENNReal.ofReal_ne_top
@[simp] theorem ofReal_lt_top {r : ℝ} : ENNReal.ofReal r < ∞ := coe_lt_top
#align ennreal.of_real_lt_top ENNReal.ofReal_lt_top
@[simp] theorem top_ne_ofReal {r : ℝ} : ∞ ≠ ENNReal.ofReal r := top_ne_coe
#align ennreal.top_ne_of_real ENNReal.top_ne_ofReal
@[simp]
theorem ofReal_toReal_eq_iff : ENNReal.ofReal a.toReal = a ↔ a ≠ ⊤ :=
⟨fun h => by
rw [← h]
exact ofReal_ne_top, ofReal_toReal⟩
#align ennreal.of_real_to_real_eq_iff ENNReal.ofReal_toReal_eq_iff
@[simp]
theorem toReal_ofReal_eq_iff {a : ℝ} : (ENNReal.ofReal a).toReal = a ↔ 0 ≤ a :=
⟨fun h => by
rw [← h]
exact toReal_nonneg, toReal_ofReal⟩
#align ennreal.to_real_of_real_eq_iff ENNReal.toReal_ofReal_eq_iff
@[simp] theorem zero_ne_top : 0 ≠ ∞ := coe_ne_top
#align ennreal.zero_ne_top ENNReal.zero_ne_top
@[simp] theorem top_ne_zero : ∞ ≠ 0 := top_ne_coe
#align ennreal.top_ne_zero ENNReal.top_ne_zero
@[simp] theorem one_ne_top : 1 ≠ ∞ := coe_ne_top
#align ennreal.one_ne_top ENNReal.one_ne_top
@[simp] theorem top_ne_one : ∞ ≠ 1 := top_ne_coe
#align ennreal.top_ne_one ENNReal.top_ne_one
@[simp] theorem zero_lt_top : 0 < ∞ := coe_lt_top
@[simp, norm_cast] theorem coe_le_coe : (↑r : ℝ≥0∞) ≤ ↑q ↔ r ≤ q := WithTop.coe_le_coe
#align ennreal.coe_le_coe ENNReal.coe_le_coe
@[simp, norm_cast] theorem coe_lt_coe : (↑r : ℝ≥0∞) < ↑q ↔ r < q := WithTop.coe_lt_coe
#align ennreal.coe_lt_coe ENNReal.coe_lt_coe
-- Needed until `@[gcongr]` accepts iff statements
alias ⟨_, coe_le_coe_of_le⟩ := coe_le_coe
attribute [gcongr] ENNReal.coe_le_coe_of_le
-- Needed until `@[gcongr]` accepts iff statements
alias ⟨_, coe_lt_coe_of_lt⟩ := coe_lt_coe
attribute [gcongr] ENNReal.coe_lt_coe_of_lt
theorem coe_mono : Monotone ofNNReal := fun _ _ => coe_le_coe.2
#align ennreal.coe_mono ENNReal.coe_mono
theorem coe_strictMono : StrictMono ofNNReal := fun _ _ => coe_lt_coe.2
@[simp, norm_cast] theorem coe_eq_zero : (↑r : ℝ≥0∞) = 0 ↔ r = 0 := coe_inj
#align ennreal.coe_eq_zero ENNReal.coe_eq_zero
@[simp, norm_cast] theorem zero_eq_coe : 0 = (↑r : ℝ≥0∞) ↔ 0 = r := coe_inj
#align ennreal.zero_eq_coe ENNReal.zero_eq_coe
@[simp, norm_cast] theorem coe_eq_one : (↑r : ℝ≥0∞) = 1 ↔ r = 1 := coe_inj
#align ennreal.coe_eq_one ENNReal.coe_eq_one
@[simp, norm_cast] theorem one_eq_coe : 1 = (↑r : ℝ≥0∞) ↔ 1 = r := coe_inj
#align ennreal.one_eq_coe ENNReal.one_eq_coe
@[simp, norm_cast] theorem coe_pos : 0 < (r : ℝ≥0∞) ↔ 0 < r := coe_lt_coe
#align ennreal.coe_pos ENNReal.coe_pos
theorem coe_ne_zero : (r : ℝ≥0∞) ≠ 0 ↔ r ≠ 0 := coe_eq_zero.not
#align ennreal.coe_ne_zero ENNReal.coe_ne_zero
lemma coe_ne_one : (r : ℝ≥0∞) ≠ 1 ↔ r ≠ 1 := coe_eq_one.not
@[simp, norm_cast] lemma coe_add (x y : ℝ≥0) : (↑(x + y) : ℝ≥0∞) = x + y := rfl
#align ennreal.coe_add ENNReal.coe_add
@[simp, norm_cast] lemma coe_mul (x y : ℝ≥0) : (↑(x * y) : ℝ≥0∞) = x * y := rfl
#align ennreal.coe_mul ENNReal.coe_mul
@[norm_cast] lemma coe_nsmul (n : ℕ) (x : ℝ≥0) : (↑(n • x) : ℝ≥0∞) = n • x := rfl
@[simp, norm_cast] lemma coe_pow (x : ℝ≥0) (n : ℕ) : (↑(x ^ n) : ℝ≥0∞) = x ^ n := rfl
#noalign ennreal.coe_bit0
#noalign ennreal.coe_bit1
-- See note [no_index around OfNat.ofNat]
@[simp, norm_cast] -- Porting note (#10756): new theorem
theorem coe_ofNat (n : ℕ) [n.AtLeastTwo] :
((no_index (OfNat.ofNat n) : ℝ≥0) : ℝ≥0∞) = OfNat.ofNat n := rfl
-- Porting note (#11215): TODO: add lemmas about `OfNat.ofNat` and `<`/`≤`
theorem coe_two : ((2 : ℝ≥0) : ℝ≥0∞) = 2 := rfl
#align ennreal.coe_two ENNReal.coe_two
theorem toNNReal_eq_toNNReal_iff (x y : ℝ≥0∞) :
x.toNNReal = y.toNNReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 :=
WithTop.untop'_eq_untop'_iff
#align ennreal.to_nnreal_eq_to_nnreal_iff ENNReal.toNNReal_eq_toNNReal_iff
theorem toReal_eq_toReal_iff (x y : ℝ≥0∞) :
x.toReal = y.toReal ↔ x = y ∨ x = 0 ∧ y = ⊤ ∨ x = ⊤ ∧ y = 0 := by
simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff]
#align ennreal.to_real_eq_to_real_iff ENNReal.toReal_eq_toReal_iff
theorem toNNReal_eq_toNNReal_iff' {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) :
x.toNNReal = y.toNNReal ↔ x = y := by
simp only [ENNReal.toNNReal_eq_toNNReal_iff x y, hx, hy, and_false, false_and, or_false]
#align ennreal.to_nnreal_eq_to_nnreal_iff' ENNReal.toNNReal_eq_toNNReal_iff'
theorem toReal_eq_toReal_iff' {x y : ℝ≥0∞} (hx : x ≠ ⊤) (hy : y ≠ ⊤) :
x.toReal = y.toReal ↔ x = y := by
simp only [ENNReal.toReal, NNReal.coe_inj, toNNReal_eq_toNNReal_iff' hx hy]
#align ennreal.to_real_eq_to_real_iff' ENNReal.toReal_eq_toReal_iff'
theorem one_lt_two : (1 : ℝ≥0∞) < 2 := Nat.one_lt_ofNat
#align ennreal.one_lt_two ENNReal.one_lt_two
@[simp] theorem two_ne_top : (2 : ℝ≥0∞) ≠ ∞ := coe_ne_top
#align ennreal.two_ne_top ENNReal.two_ne_top
@[simp] theorem two_lt_top : (2 : ℝ≥0∞) < ∞ := coe_lt_top
/-- `(1 : ℝ≥0∞) ≤ 1`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_one_ennreal : Fact ((1 : ℝ≥0∞) ≤ 1) :=
⟨le_rfl⟩
#align fact_one_le_one_ennreal fact_one_le_one_ennreal
/-- `(1 : ℝ≥0∞) ≤ 2`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_two_ennreal : Fact ((1 : ℝ≥0∞) ≤ 2) :=
⟨one_le_two⟩
#align fact_one_le_two_ennreal fact_one_le_two_ennreal
/-- `(1 : ℝ≥0∞) ≤ ∞`, recorded as a `Fact` for use with `Lp` spaces. -/
instance _root_.fact_one_le_top_ennreal : Fact ((1 : ℝ≥0∞) ≤ ∞) :=
⟨le_top⟩
#align fact_one_le_top_ennreal fact_one_le_top_ennreal
/-- The set of numbers in `ℝ≥0∞` that are not equal to `∞` is equivalent to `ℝ≥0`. -/
def neTopEquivNNReal : { a | a ≠ ∞ } ≃ ℝ≥0 where
toFun x := ENNReal.toNNReal x
invFun x := ⟨x, coe_ne_top⟩
left_inv := fun x => Subtype.eq <| coe_toNNReal x.2
right_inv _ := toNNReal_coe
#align ennreal.ne_top_equiv_nnreal ENNReal.neTopEquivNNReal
theorem cinfi_ne_top [InfSet α] (f : ℝ≥0∞ → α) : ⨅ x : { x // x ≠ ∞ }, f x = ⨅ x : ℝ≥0, f x :=
Eq.symm <| neTopEquivNNReal.symm.surjective.iInf_congr _ fun _ => rfl
#align ennreal.cinfi_ne_top ENNReal.cinfi_ne_top
theorem iInf_ne_top [CompleteLattice α] (f : ℝ≥0∞ → α) :
⨅ (x) (_ : x ≠ ∞), f x = ⨅ x : ℝ≥0, f x := by rw [iInf_subtype', cinfi_ne_top]
#align ennreal.infi_ne_top ENNReal.iInf_ne_top
theorem csupr_ne_top [SupSet α] (f : ℝ≥0∞ → α) : ⨆ x : { x // x ≠ ∞ }, f x = ⨆ x : ℝ≥0, f x :=
@cinfi_ne_top αᵒᵈ _ _
#align ennreal.csupr_ne_top ENNReal.csupr_ne_top
theorem iSup_ne_top [CompleteLattice α] (f : ℝ≥0∞ → α) :
⨆ (x) (_ : x ≠ ∞), f x = ⨆ x : ℝ≥0, f x :=
@iInf_ne_top αᵒᵈ _ _
#align ennreal.supr_ne_top ENNReal.iSup_ne_top
theorem iInf_ennreal {α : Type*} [CompleteLattice α] {f : ℝ≥0∞ → α} :
⨅ n, f n = (⨅ n : ℝ≥0, f n) ⊓ f ∞ :=
(iInf_option f).trans (inf_comm _ _)
#align ennreal.infi_ennreal ENNReal.iInf_ennreal
theorem iSup_ennreal {α : Type*} [CompleteLattice α] {f : ℝ≥0∞ → α} :
⨆ n, f n = (⨆ n : ℝ≥0, f n) ⊔ f ∞ :=
@iInf_ennreal αᵒᵈ _ _
#align ennreal.supr_ennreal ENNReal.iSup_ennreal
/-- Coercion `ℝ≥0 → ℝ≥0∞` as a `RingHom`. -/
def ofNNRealHom : ℝ≥0 →+* ℝ≥0∞ where
toFun := some
map_one' := coe_one
map_mul' _ _ := coe_mul _ _
map_zero' := coe_zero
map_add' _ _ := coe_add _ _
#align ennreal.of_nnreal_hom ENNReal.ofNNRealHom
@[simp] theorem coe_ofNNRealHom : ⇑ofNNRealHom = some := rfl
#align ennreal.coe_of_nnreal_hom ENNReal.coe_ofNNRealHom
@[simp, norm_cast]
theorem coe_indicator {α} (s : Set α) (f : α → ℝ≥0) (a : α) :
((s.indicator f a : ℝ≥0) : ℝ≥0∞) = s.indicator (fun x => ↑(f x)) a :=
(ofNNRealHom : ℝ≥0 →+ ℝ≥0∞).map_indicator _ _ _
#align ennreal.coe_indicator ENNReal.coe_indicator
section Order
theorem bot_eq_zero : (⊥ : ℝ≥0∞) = 0 := rfl
#align ennreal.bot_eq_zero ENNReal.bot_eq_zero
-- `coe_lt_top` moved up
theorem not_top_le_coe : ¬∞ ≤ ↑r := WithTop.not_top_le_coe r
#align ennreal.not_top_le_coe ENNReal.not_top_le_coe
@[simp, norm_cast]
theorem one_le_coe_iff : (1 : ℝ≥0∞) ≤ ↑r ↔ 1 ≤ r := coe_le_coe
#align ennreal.one_le_coe_iff ENNReal.one_le_coe_iff
@[simp, norm_cast]
theorem coe_le_one_iff : ↑r ≤ (1 : ℝ≥0∞) ↔ r ≤ 1 := coe_le_coe
#align ennreal.coe_le_one_iff ENNReal.coe_le_one_iff
@[simp, norm_cast]
theorem coe_lt_one_iff : (↑p : ℝ≥0∞) < 1 ↔ p < 1 := coe_lt_coe
#align ennreal.coe_lt_one_iff ENNReal.coe_lt_one_iff
@[simp, norm_cast]
theorem one_lt_coe_iff : 1 < (↑p : ℝ≥0∞) ↔ 1 < p := coe_lt_coe
#align ennreal.one_lt_coe_iff ENNReal.one_lt_coe_iff
@[simp, norm_cast]
theorem coe_natCast (n : ℕ) : ((n : ℝ≥0) : ℝ≥0∞) = n := rfl
#align ennreal.coe_nat ENNReal.coe_natCast
@[simp, norm_cast] lemma ofReal_natCast (n : ℕ) : ENNReal.ofReal n = n := by simp [ENNReal.ofReal]
#align ennreal.of_real_coe_nat ENNReal.ofReal_natCast
-- See note [no_index around OfNat.ofNat]
@[simp] theorem ofReal_ofNat (n : ℕ) [n.AtLeastTwo] :
ENNReal.ofReal (no_index (OfNat.ofNat n)) = OfNat.ofNat n :=
ofReal_natCast n
@[simp] theorem natCast_ne_top (n : ℕ) : (n : ℝ≥0∞) ≠ ∞ := WithTop.natCast_ne_top n
#align ennreal.nat_ne_top ENNReal.natCast_ne_top
@[simp] theorem top_ne_natCast (n : ℕ) : ∞ ≠ n := WithTop.top_ne_natCast n
#align ennreal.top_ne_nat ENNReal.top_ne_natCast
@[simp] theorem one_lt_top : 1 < ∞ := coe_lt_top
#align ennreal.one_lt_top ENNReal.one_lt_top
@[simp, norm_cast]
theorem toNNReal_nat (n : ℕ) : (n : ℝ≥0∞).toNNReal = n := by
rw [← ENNReal.coe_natCast n, ENNReal.toNNReal_coe]
#align ennreal.to_nnreal_nat ENNReal.toNNReal_nat
@[simp, norm_cast]
theorem toReal_nat (n : ℕ) : (n : ℝ≥0∞).toReal = n := by
rw [← ENNReal.ofReal_natCast n, ENNReal.toReal_ofReal (Nat.cast_nonneg _)]
#align ennreal.to_real_nat ENNReal.toReal_nat
-- See note [no_index around OfNat.ofNat]
@[simp] theorem toReal_ofNat (n : ℕ) [n.AtLeastTwo] :
ENNReal.toReal (no_index (OfNat.ofNat n)) = OfNat.ofNat n :=
toReal_nat n
theorem le_coe_iff : a ≤ ↑r ↔ ∃ p : ℝ≥0, a = p ∧ p ≤ r := WithTop.le_coe_iff
#align ennreal.le_coe_iff ENNReal.le_coe_iff
theorem coe_le_iff : ↑r ≤ a ↔ ∀ p : ℝ≥0, a = p → r ≤ p := WithTop.coe_le_iff
#align ennreal.coe_le_iff ENNReal.coe_le_iff
theorem lt_iff_exists_coe : a < b ↔ ∃ p : ℝ≥0, a = p ∧ ↑p < b :=
WithTop.lt_iff_exists_coe
#align ennreal.lt_iff_exists_coe ENNReal.lt_iff_exists_coe
theorem toReal_le_coe_of_le_coe {a : ℝ≥0∞} {b : ℝ≥0} (h : a ≤ b) : a.toReal ≤ b := by
lift a to ℝ≥0 using ne_top_of_le_ne_top coe_ne_top h
simpa using h
#align ennreal.to_real_le_coe_of_le_coe ENNReal.toReal_le_coe_of_le_coe
@[simp, norm_cast]
theorem coe_finset_sup {s : Finset α} {f : α → ℝ≥0} : ↑(s.sup f) = s.sup fun x => (f x : ℝ≥0∞) :=
Finset.comp_sup_eq_sup_comp_of_is_total _ coe_mono rfl
#align ennreal.coe_finset_sup ENNReal.coe_finset_sup
@[simp] theorem max_eq_zero_iff : max a b = 0 ↔ a = 0 ∧ b = 0 := max_eq_bot
#align ennreal.max_eq_zero_iff ENNReal.max_eq_zero_iff
theorem max_zero_left : max 0 a = a :=
max_eq_right (zero_le a)
#align ennreal.max_zero_left ENNReal.max_zero_left
theorem max_zero_right : max a 0 = a :=
max_eq_left (zero_le a)
#align ennreal.max_zero_right ENNReal.max_zero_right
@[simp] theorem sup_eq_max : a ⊔ b = max a b := rfl
#align ennreal.sup_eq_max ENNReal.sup_eq_max
-- Porting note: moved `le_of_forall_pos_le_add` down
theorem lt_iff_exists_rat_btwn :
a < b ↔ ∃ q : ℚ, 0 ≤ q ∧ a < Real.toNNReal q ∧ (Real.toNNReal q : ℝ≥0∞) < b :=
⟨fun h => by
rcases lt_iff_exists_coe.1 h with ⟨p, rfl, _⟩
rcases exists_between h with ⟨c, pc, cb⟩
rcases lt_iff_exists_coe.1 cb with ⟨r, rfl, _⟩
rcases (NNReal.lt_iff_exists_rat_btwn _ _).1 (coe_lt_coe.1 pc) with ⟨q, hq0, pq, qr⟩
exact ⟨q, hq0, coe_lt_coe.2 pq, lt_trans (coe_lt_coe.2 qr) cb⟩,
fun ⟨q, _, qa, qb⟩ => lt_trans qa qb⟩
#align ennreal.lt_iff_exists_rat_btwn ENNReal.lt_iff_exists_rat_btwn
theorem lt_iff_exists_real_btwn :
a < b ↔ ∃ r : ℝ, 0 ≤ r ∧ a < ENNReal.ofReal r ∧ (ENNReal.ofReal r : ℝ≥0∞) < b :=
⟨fun h =>
let ⟨q, q0, aq, qb⟩ := ENNReal.lt_iff_exists_rat_btwn.1 h
⟨q, Rat.cast_nonneg.2 q0, aq, qb⟩,
fun ⟨_, _, qa, qb⟩ => lt_trans qa qb⟩
#align ennreal.lt_iff_exists_real_btwn ENNReal.lt_iff_exists_real_btwn
theorem lt_iff_exists_nnreal_btwn : a < b ↔ ∃ r : ℝ≥0, a < r ∧ (r : ℝ≥0∞) < b :=
WithTop.lt_iff_exists_coe_btwn
#align ennreal.lt_iff_exists_nnreal_btwn ENNReal.lt_iff_exists_nnreal_btwn
theorem lt_iff_exists_add_pos_lt : a < b ↔ ∃ r : ℝ≥0, 0 < r ∧ a + r < b := by
refine ⟨fun hab => ?_, fun ⟨r, _, hr⟩ => lt_of_le_of_lt le_self_add hr⟩
rcases lt_iff_exists_nnreal_btwn.1 hab with ⟨c, ac, cb⟩
lift a to ℝ≥0 using ac.ne_top
rw [coe_lt_coe] at ac
refine ⟨c - a, tsub_pos_iff_lt.2 ac, ?_⟩
rwa [← coe_add, add_tsub_cancel_of_le ac.le]
#align ennreal.lt_iff_exists_add_pos_lt ENNReal.lt_iff_exists_add_pos_lt
theorem le_of_forall_pos_le_add (h : ∀ ε : ℝ≥0, 0 < ε → b < ∞ → a ≤ b + ε) : a ≤ b := by
contrapose! h
rcases lt_iff_exists_add_pos_lt.1 h with ⟨r, hr0, hr⟩
exact ⟨r, hr0, h.trans_le le_top, hr⟩
#align ennreal.le_of_forall_pos_le_add ENNReal.le_of_forall_pos_le_add
theorem natCast_lt_coe {n : ℕ} : n < (r : ℝ≥0∞) ↔ n < r := ENNReal.coe_natCast n ▸ coe_lt_coe
#align ennreal.coe_nat_lt_coe ENNReal.natCast_lt_coe
theorem coe_lt_natCast {n : ℕ} : (r : ℝ≥0∞) < n ↔ r < n := ENNReal.coe_natCast n ▸ coe_lt_coe
#align ennreal.coe_lt_coe_nat ENNReal.coe_lt_natCast
@[deprecated (since := "2024-04-05")] alias coe_nat := coe_natCast
@[deprecated (since := "2024-04-05")] alias ofReal_coe_nat := ofReal_natCast
@[deprecated (since := "2024-04-05")] alias nat_ne_top := natCast_ne_top
@[deprecated (since := "2024-04-05")] alias top_ne_nat := top_ne_natCast
@[deprecated (since := "2024-04-05")] alias coe_nat_lt_coe := natCast_lt_coe
@[deprecated (since := "2024-04-05")] alias coe_lt_coe_nat := coe_lt_natCast
protected theorem exists_nat_gt {r : ℝ≥0∞} (h : r ≠ ∞) : ∃ n : ℕ, r < n := by
lift r to ℝ≥0 using h
rcases exists_nat_gt r with ⟨n, hn⟩
exact ⟨n, coe_lt_natCast.2 hn⟩
#align ennreal.exists_nat_gt ENNReal.exists_nat_gt
@[simp]
theorem iUnion_Iio_coe_nat : ⋃ n : ℕ, Iio (n : ℝ≥0∞) = {∞}ᶜ := by
ext x
rw [mem_iUnion]
exact ⟨fun ⟨n, hn⟩ => ne_top_of_lt hn, ENNReal.exists_nat_gt⟩
#align ennreal.Union_Iio_coe_nat ENNReal.iUnion_Iio_coe_nat
@[simp]
theorem iUnion_Iic_coe_nat : ⋃ n : ℕ, Iic (n : ℝ≥0∞) = {∞}ᶜ :=
Subset.antisymm (iUnion_subset fun n _x hx => ne_top_of_le_ne_top (natCast_ne_top n) hx) <|
iUnion_Iio_coe_nat ▸ iUnion_mono fun _ => Iio_subset_Iic_self
#align ennreal.Union_Iic_coe_nat ENNReal.iUnion_Iic_coe_nat
@[simp]
theorem iUnion_Ioc_coe_nat : ⋃ n : ℕ, Ioc a n = Ioi a \ {∞} := by
simp only [← Ioi_inter_Iic, ← inter_iUnion, iUnion_Iic_coe_nat, diff_eq]
#align ennreal.Union_Ioc_coe_nat ENNReal.iUnion_Ioc_coe_nat
@[simp]
| Mathlib/Data/ENNReal/Basic.lean | 703 | 704 | theorem iUnion_Ioo_coe_nat : ⋃ n : ℕ, Ioo a n = Ioi a \ {∞} := by |
simp only [← Ioi_inter_Iio, ← inter_iUnion, iUnion_Iio_coe_nat, diff_eq]
|
/-
Copyright (c) 2021 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.Fintype.List
#align_import data.list.cycle from "leanprover-community/mathlib"@"7413128c3bcb3b0818e3e18720abc9ea3100fb49"
/-!
# Cycles of a list
Lists have an equivalence relation of whether they are rotational permutations of one another.
This relation is defined as `IsRotated`.
Based on this, we define the quotient of lists by the rotation relation, called `Cycle`.
We also define a representation of concrete cycles, available when viewing them in a goal state or
via `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown
as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation
is different.
-/
assert_not_exists MonoidWithZero
namespace List
variable {α : Type*} [DecidableEq α]
/-- Return the `z` such that `x :: z :: _` appears in `xs`, or `default` if there is no such `z`. -/
def nextOr : ∀ (_ : List α) (_ _ : α), α
| [], _, default => default
| [_], _, default => default
-- Handles the not-found and the wraparound case
| y :: z :: xs, x, default => if x = y then z else nextOr (z :: xs) x default
#align list.next_or List.nextOr
@[simp]
theorem nextOr_nil (x d : α) : nextOr [] x d = d :=
rfl
#align list.next_or_nil List.nextOr_nil
@[simp]
theorem nextOr_singleton (x y d : α) : nextOr [y] x d = d :=
rfl
#align list.next_or_singleton List.nextOr_singleton
@[simp]
theorem nextOr_self_cons_cons (xs : List α) (x y d : α) : nextOr (x :: y :: xs) x d = y :=
if_pos rfl
#align list.next_or_self_cons_cons List.nextOr_self_cons_cons
theorem nextOr_cons_of_ne (xs : List α) (y x d : α) (h : x ≠ y) :
nextOr (y :: xs) x d = nextOr xs x d := by
cases' xs with z zs
· rfl
· exact if_neg h
#align list.next_or_cons_of_ne List.nextOr_cons_of_ne
/-- `nextOr` does not depend on the default value, if the next value appears. -/
theorem nextOr_eq_nextOr_of_mem_of_ne (xs : List α) (x d d' : α) (x_mem : x ∈ xs)
(x_ne : x ≠ xs.getLast (ne_nil_of_mem x_mem)) : nextOr xs x d = nextOr xs x d' := by
induction' xs with y ys IH
· cases x_mem
cases' ys with z zs
· simp at x_mem x_ne
contradiction
by_cases h : x = y
· rw [h, nextOr_self_cons_cons, nextOr_self_cons_cons]
· rw [nextOr, nextOr, IH]
· simpa [h] using x_mem
· simpa using x_ne
#align list.next_or_eq_next_or_of_mem_of_ne List.nextOr_eq_nextOr_of_mem_of_ne
theorem mem_of_nextOr_ne {xs : List α} {x d : α} (h : nextOr xs x d ≠ d) : x ∈ xs := by
induction' xs with y ys IH
· simp at h
cases' ys with z zs
· simp at h
· by_cases hx : x = y
· simp [hx]
· rw [nextOr_cons_of_ne _ _ _ _ hx] at h
simpa [hx] using IH h
#align list.mem_of_next_or_ne List.mem_of_nextOr_ne
theorem nextOr_concat {xs : List α} {x : α} (d : α) (h : x ∉ xs) : nextOr (xs ++ [x]) x d = d := by
induction' xs with z zs IH
· simp
· obtain ⟨hz, hzs⟩ := not_or.mp (mt mem_cons.2 h)
rw [cons_append, nextOr_cons_of_ne _ _ _ _ hz, IH hzs]
#align list.next_or_concat List.nextOr_concat
theorem nextOr_mem {xs : List α} {x d : α} (hd : d ∈ xs) : nextOr xs x d ∈ xs := by
revert hd
suffices ∀ xs' : List α, (∀ x ∈ xs, x ∈ xs') → d ∈ xs' → nextOr xs x d ∈ xs' by
exact this xs fun _ => id
intro xs' hxs' hd
induction' xs with y ys ih
· exact hd
cases' ys with z zs
· exact hd
rw [nextOr]
split_ifs with h
· exact hxs' _ (mem_cons_of_mem _ (mem_cons_self _ _))
· exact ih fun _ h => hxs' _ (mem_cons_of_mem _ h)
#align list.next_or_mem List.nextOr_mem
/-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the next
element of `l`. This works from head to tail, (including a check for last element)
so it will match on first hit, ignoring later duplicates.
For example:
* `next [1, 2, 3] 2 _ = 3`
* `next [1, 2, 3] 3 _ = 1`
* `next [1, 2, 3, 2, 4] 2 _ = 3`
* `next [1, 2, 3, 2] 2 _ = 3`
* `next [1, 1, 2, 3, 2] 1 _ = 1`
-/
def next (l : List α) (x : α) (h : x ∈ l) : α :=
nextOr l x (l.get ⟨0, length_pos_of_mem h⟩)
#align list.next List.next
/-- Given an element `x : α` of `l : List α` such that `x ∈ l`, get the previous
element of `l`. This works from head to tail, (including a check for last element)
so it will match on first hit, ignoring later duplicates.
* `prev [1, 2, 3] 2 _ = 1`
* `prev [1, 2, 3] 1 _ = 3`
* `prev [1, 2, 3, 2, 4] 2 _ = 1`
* `prev [1, 2, 3, 4, 2] 2 _ = 1`
* `prev [1, 1, 2] 1 _ = 2`
-/
def prev : ∀ l : List α, ∀ x ∈ l, α
| [], _, h => by simp at h
| [y], _, _ => y
| y :: z :: xs, x, h =>
if hx : x = y then getLast (z :: xs) (cons_ne_nil _ _)
else if x = z then y else prev (z :: xs) x (by simpa [hx] using h)
#align list.prev List.prev
variable (l : List α) (x : α)
@[simp]
theorem next_singleton (x y : α) (h : x ∈ [y]) : next [y] x h = y :=
rfl
#align list.next_singleton List.next_singleton
@[simp]
theorem prev_singleton (x y : α) (h : x ∈ [y]) : prev [y] x h = y :=
rfl
#align list.prev_singleton List.prev_singleton
theorem next_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) :
next (y :: z :: l) x h = z := by rw [next, nextOr, if_pos hx]
#align list.next_cons_cons_eq' List.next_cons_cons_eq'
@[simp]
theorem next_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) : next (x :: z :: l) x h = z :=
next_cons_cons_eq' l x x z h rfl
#align list.next_cons_cons_eq List.next_cons_cons_eq
theorem next_ne_head_ne_getLast (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x ≠ getLast (y :: l) (cons_ne_nil _ _)) :
next (y :: l) x h = next l x (by simpa [hy] using h) := by
rw [next, next, nextOr_cons_of_ne _ _ _ _ hy, nextOr_eq_nextOr_of_mem_of_ne]
· rwa [getLast_cons] at hx
exact ne_nil_of_mem (by assumption)
· rwa [getLast_cons] at hx
#align list.next_ne_head_ne_last List.next_ne_head_ne_getLast
theorem next_cons_concat (y : α) (hy : x ≠ y) (hx : x ∉ l)
(h : x ∈ y :: l ++ [x] := mem_append_right _ (mem_singleton_self x)) :
next (y :: l ++ [x]) x h = y := by
rw [next, nextOr_concat]
· rfl
· simp [hy, hx]
#align list.next_cons_concat List.next_cons_concat
theorem next_getLast_cons (h : x ∈ l) (y : α) (h : x ∈ y :: l) (hy : x ≠ y)
(hx : x = getLast (y :: l) (cons_ne_nil _ _)) (hl : Nodup l) : next (y :: l) x h = y := by
rw [next, get, ← dropLast_append_getLast (cons_ne_nil y l), hx, nextOr_concat]
subst hx
intro H
obtain ⟨⟨_ | k, hk⟩, hk'⟩ := get_of_mem H
· rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?_zero, head?_cons,
Option.some_inj] at hk'
· exact hy (Eq.symm hk')
rw [length_cons, Nat.pred_succ]
exact length_pos_of_mem (by assumption)
suffices k + 1 = l.length by simp [this] at hk
cases' l with hd tl
· simp at hk
· rw [nodup_iff_injective_get] at hl
rw [length, Nat.succ_inj']
refine Fin.val_eq_of_eq <| @hl ⟨k, Nat.lt_of_succ_lt <| by simpa using hk⟩
⟨tl.length, by simp⟩ ?_
rw [← Option.some_inj] at hk'
rw [← get?_eq_get, dropLast_eq_take, get?_take, get?, get?_eq_get, Option.some_inj] at hk'
· rw [hk']
simp only [getLast_eq_get, length_cons, ge_iff_le, Nat.succ_sub_succ_eq_sub,
nonpos_iff_eq_zero, add_eq_zero_iff, and_false, Nat.sub_zero, get_cons_succ]
simpa using hk
#align list.next_last_cons List.next_getLast_cons
theorem prev_getLast_cons' (y : α) (hxy : x ∈ y :: l) (hx : x = y) :
prev (y :: l) x hxy = getLast (y :: l) (cons_ne_nil _ _) := by cases l <;> simp [prev, hx]
#align list.prev_last_cons' List.prev_getLast_cons'
@[simp]
theorem prev_getLast_cons (h : x ∈ x :: l) :
prev (x :: l) x h = getLast (x :: l) (cons_ne_nil _ _) :=
prev_getLast_cons' l x x h rfl
#align list.prev_last_cons List.prev_getLast_cons
theorem prev_cons_cons_eq' (y z : α) (h : x ∈ y :: z :: l) (hx : x = y) :
prev (y :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) := by rw [prev, dif_pos hx]
#align list.prev_cons_cons_eq' List.prev_cons_cons_eq'
--@[simp] Porting note (#10618): `simp` can prove it
theorem prev_cons_cons_eq (z : α) (h : x ∈ x :: z :: l) :
prev (x :: z :: l) x h = getLast (z :: l) (cons_ne_nil _ _) :=
prev_cons_cons_eq' l x x z h rfl
#align list.prev_cons_cons_eq List.prev_cons_cons_eq
theorem prev_cons_cons_of_ne' (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x = z) :
prev (y :: z :: l) x h = y := by
cases l
· simp [prev, hy, hz]
· rw [prev, dif_neg hy, if_pos hz]
#align list.prev_cons_cons_of_ne' List.prev_cons_cons_of_ne'
theorem prev_cons_cons_of_ne (y : α) (h : x ∈ y :: x :: l) (hy : x ≠ y) :
prev (y :: x :: l) x h = y :=
prev_cons_cons_of_ne' _ _ _ _ _ hy rfl
#align list.prev_cons_cons_of_ne List.prev_cons_cons_of_ne
theorem prev_ne_cons_cons (y z : α) (h : x ∈ y :: z :: l) (hy : x ≠ y) (hz : x ≠ z) :
prev (y :: z :: l) x h = prev (z :: l) x (by simpa [hy] using h) := by
cases l
· simp [hy, hz] at h
· rw [prev, dif_neg hy, if_neg hz]
#align list.prev_ne_cons_cons List.prev_ne_cons_cons
theorem next_mem (h : x ∈ l) : l.next x h ∈ l :=
nextOr_mem (get_mem _ _ _)
#align list.next_mem List.next_mem
theorem prev_mem (h : x ∈ l) : l.prev x h ∈ l := by
cases' l with hd tl
· simp at h
induction' tl with hd' tl hl generalizing hd
· simp
· by_cases hx : x = hd
· simp only [hx, prev_cons_cons_eq]
exact mem_cons_of_mem _ (getLast_mem _)
· rw [prev, dif_neg hx]
split_ifs with hm
· exact mem_cons_self _ _
· exact mem_cons_of_mem _ (hl _ _)
#align list.prev_mem List.prev_mem
-- Porting note (#10756): new theorem
theorem next_get : ∀ (l : List α) (_h : Nodup l) (i : Fin l.length),
next l (l.get i) (get_mem _ _ _) = l.get ⟨(i + 1) % l.length,
Nat.mod_lt _ (i.1.zero_le.trans_lt i.2)⟩
| [], _, i => by simpa using i.2
| [_], _, _ => by simp
| x::y::l, _h, ⟨0, h0⟩ => by
have h₁ : get (x :: y :: l) { val := 0, isLt := h0 } = x := by simp
rw [next_cons_cons_eq' _ _ _ _ _ h₁]
simp
| x::y::l, hn, ⟨i+1, hi⟩ => by
have hx' : (x :: y :: l).get ⟨i+1, hi⟩ ≠ x := by
intro H
suffices (i + 1 : ℕ) = 0 by simpa
rw [nodup_iff_injective_get] at hn
refine Fin.val_eq_of_eq (@hn ⟨i + 1, hi⟩ ⟨0, by simp⟩ ?_)
simpa using H
have hi' : i ≤ l.length := Nat.le_of_lt_succ (Nat.succ_lt_succ_iff.1 hi)
rcases hi'.eq_or_lt with (hi' | hi')
· subst hi'
rw [next_getLast_cons]
· simp [hi', get]
· rw [get_cons_succ]; exact get_mem _ _ _
· exact hx'
· simp [getLast_eq_get]
· exact hn.of_cons
· rw [next_ne_head_ne_getLast _ _ _ _ _ hx']
· simp only [get_cons_succ]
rw [next_get (y::l), ← get_cons_succ (a := x)]
· congr
dsimp
rw [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'),
Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 (Nat.succ_lt_succ_iff.2 hi'))]
· simp [Nat.mod_eq_of_lt (Nat.succ_lt_succ_iff.2 hi'), Nat.succ_eq_add_one, hi']
· exact hn.of_cons
· rw [getLast_eq_get]
intro h
have := nodup_iff_injective_get.1 hn h
simp at this; simp [this] at hi'
· rw [get_cons_succ]; exact get_mem _ _ _
set_option linter.deprecated false in
@[deprecated next_get (since := "2023-01-27")]
theorem next_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
next l (l.nthLe n hn) (nthLe_mem _ _ _) =
l.nthLe ((n + 1) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) :=
next_get l h ⟨n, hn⟩
#align list.next_nth_le List.next_nthLe
set_option linter.deprecated false in
theorem prev_nthLe (l : List α) (h : Nodup l) (n : ℕ) (hn : n < l.length) :
prev l (l.nthLe n hn) (nthLe_mem _ _ _) =
l.nthLe ((n + (l.length - 1)) % l.length) (Nat.mod_lt _ (n.zero_le.trans_lt hn)) := by
cases' l with x l
· simp at hn
induction' l with y l hl generalizing n x
· simp
· rcases n with (_ | _ | n)
· simp [Nat.add_succ_sub_one, add_zero, List.prev_cons_cons_eq, Nat.zero_eq, List.length,
List.nthLe, Nat.succ_add_sub_one, zero_add, getLast_eq_get,
Nat.mod_eq_of_lt (Nat.succ_lt_succ l.length.lt_succ_self)]
· simp only [mem_cons, nodup_cons] at h
push_neg at h
simp only [List.prev_cons_cons_of_ne _ _ _ _ h.left.left.symm, Nat.zero_eq, List.length,
List.nthLe, add_comm, eq_self_iff_true, Nat.succ_add_sub_one, Nat.mod_self, zero_add,
List.get]
· rw [prev_ne_cons_cons]
· convert hl n.succ y h.of_cons (Nat.le_of_succ_le_succ hn) using 1
have : ∀ k hk, (y :: l).nthLe k hk = (x :: y :: l).nthLe (k + 1) (Nat.succ_lt_succ hk) := by
intros
simp [List.nthLe]
rw [this]
congr
simp only [Nat.add_succ_sub_one, add_zero, length]
simp only [length, Nat.succ_lt_succ_iff] at hn
set k := l.length
rw [Nat.succ_add, ← Nat.add_succ, Nat.add_mod_right, Nat.succ_add, ← Nat.add_succ _ k,
Nat.add_mod_right, Nat.mod_eq_of_lt, Nat.mod_eq_of_lt]
· exact Nat.lt_succ_of_lt hn
· exact Nat.succ_lt_succ (Nat.lt_succ_of_lt hn)
· intro H
suffices n.succ.succ = 0 by simpa
rw [nodup_iff_nthLe_inj] at h
refine h _ _ hn Nat.succ_pos' ?_
simpa using H
· intro H
suffices n.succ.succ = 1 by simpa
rw [nodup_iff_nthLe_inj] at h
refine h _ _ hn (Nat.succ_lt_succ Nat.succ_pos') ?_
simpa using H
#align list.prev_nth_le List.prev_nthLe
set_option linter.deprecated false in
theorem pmap_next_eq_rotate_one (h : Nodup l) : (l.pmap l.next fun _ h => h) = l.rotate 1 := by
apply List.ext_nthLe
· simp
· intros
rw [nthLe_pmap, nthLe_rotate, next_nthLe _ h]
#align list.pmap_next_eq_rotate_one List.pmap_next_eq_rotate_one
set_option linter.deprecated false in
theorem pmap_prev_eq_rotate_length_sub_one (h : Nodup l) :
(l.pmap l.prev fun _ h => h) = l.rotate (l.length - 1) := by
apply List.ext_nthLe
· simp
· intro n hn hn'
rw [nthLe_rotate, nthLe_pmap, prev_nthLe _ h]
#align list.pmap_prev_eq_rotate_length_sub_one List.pmap_prev_eq_rotate_length_sub_one
set_option linter.deprecated false in
theorem prev_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
prev l (next l x hx) (next_mem _ _ _) = x := by
obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
cases' l with hd tl
· simp at hx
· have : (n + 1 + length tl) % (length tl + 1) = n := by
rw [length_cons, Nat.succ_eq_add_one] at hn
rw [add_assoc, add_comm 1, Nat.add_mod_right, Nat.mod_eq_of_lt hn]
simp only [length_cons, Nat.succ_sub_succ_eq_sub, Nat.sub_zero, Nat.succ_eq_add_one, this]
#align list.prev_next List.prev_next
set_option linter.deprecated false in
theorem next_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
next l (prev l x hx) (prev_mem _ _ _) = x := by
obtain ⟨n, hn, rfl⟩ := nthLe_of_mem hx
simp only [next_nthLe, prev_nthLe, h, Nat.mod_add_mod]
cases' l with hd tl
· simp at hx
· have : (n + length tl + 1) % (length tl + 1) = n := by
rw [length_cons, Nat.succ_eq_add_one] at hn
rw [add_assoc, Nat.add_mod_right, Nat.mod_eq_of_lt hn]
simp [this]
#align list.next_prev List.next_prev
set_option linter.deprecated false in
theorem prev_reverse_eq_next (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
prev l.reverse x (mem_reverse.mpr hx) = next l x hx := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
have lpos : 0 < l.length := k.zero_le.trans_lt hk
have key : l.length - 1 - k < l.length := by omega
rw [← nthLe_pmap l.next (fun _ h => h) (by simpa using hk)]
simp_rw [← nthLe_reverse l k (key.trans_le (by simp)), pmap_next_eq_rotate_one _ h]
rw [← nthLe_pmap l.reverse.prev fun _ h => h]
· simp_rw [pmap_prev_eq_rotate_length_sub_one _ (nodup_reverse.mpr h), rotate_reverse,
length_reverse, Nat.mod_eq_of_lt (Nat.sub_lt lpos Nat.succ_pos'),
Nat.sub_sub_self (Nat.succ_le_of_lt lpos)]
rw [← nthLe_reverse]
· simp [Nat.sub_sub_self (Nat.le_sub_one_of_lt hk)]
· simpa using (Nat.sub_le _ _).trans_lt (Nat.sub_lt lpos Nat.succ_pos')
· simpa
#align list.prev_reverse_eq_next List.prev_reverse_eq_next
theorem next_reverse_eq_prev (l : List α) (h : Nodup l) (x : α) (hx : x ∈ l) :
next l.reverse x (mem_reverse.mpr hx) = prev l x hx := by
convert (prev_reverse_eq_next l.reverse (nodup_reverse.mpr h) x (mem_reverse.mpr hx)).symm
exact (reverse_reverse l).symm
#align list.next_reverse_eq_prev List.next_reverse_eq_prev
set_option linter.deprecated false in
theorem isRotated_next_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
l.next x hx = l'.next x (h.mem_iff.mp hx) := by
obtain ⟨k, hk, rfl⟩ := nthLe_of_mem hx
obtain ⟨n, rfl⟩ := id h
rw [next_nthLe _ hn]
simp_rw [← nthLe_rotate' _ n k]
rw [next_nthLe _ (h.nodup_iff.mp hn), ← nthLe_rotate' _ n]
simp [add_assoc]
#align list.is_rotated_next_eq List.isRotated_next_eq
theorem isRotated_prev_eq {l l' : List α} (h : l ~r l') (hn : Nodup l) {x : α} (hx : x ∈ l) :
l.prev x hx = l'.prev x (h.mem_iff.mp hx) := by
rw [← next_reverse_eq_prev _ hn, ← next_reverse_eq_prev _ (h.nodup_iff.mp hn)]
exact isRotated_next_eq h.reverse (nodup_reverse.mpr hn) _
#align list.is_rotated_prev_eq List.isRotated_prev_eq
end List
open List
/-- `Cycle α` is the quotient of `List α` by cyclic permutation.
Duplicates are allowed.
-/
def Cycle (α : Type*) : Type _ :=
Quotient (IsRotated.setoid α)
#align cycle Cycle
namespace Cycle
variable {α : Type*}
-- Porting note (#11445): new definition
/-- The coercion from `List α` to `Cycle α` -/
@[coe] def ofList : List α → Cycle α :=
Quot.mk _
instance : Coe (List α) (Cycle α) :=
⟨ofList⟩
@[simp]
theorem coe_eq_coe {l₁ l₂ : List α} : (l₁ : Cycle α) = (l₂ : Cycle α) ↔ l₁ ~r l₂ :=
@Quotient.eq _ (IsRotated.setoid _) _ _
#align cycle.coe_eq_coe Cycle.coe_eq_coe
@[simp]
theorem mk_eq_coe (l : List α) : Quot.mk _ l = (l : Cycle α) :=
rfl
#align cycle.mk_eq_coe Cycle.mk_eq_coe
@[simp]
theorem mk''_eq_coe (l : List α) : Quotient.mk'' l = (l : Cycle α) :=
rfl
#align cycle.mk'_eq_coe Cycle.mk''_eq_coe
theorem coe_cons_eq_coe_append (l : List α) (a : α) :
(↑(a :: l) : Cycle α) = (↑(l ++ [a]) : Cycle α) :=
Quot.sound ⟨1, by rw [rotate_cons_succ, rotate_zero]⟩
#align cycle.coe_cons_eq_coe_append Cycle.coe_cons_eq_coe_append
/-- The unique empty cycle. -/
def nil : Cycle α :=
([] : List α)
#align cycle.nil Cycle.nil
@[simp]
theorem coe_nil : ↑([] : List α) = @nil α :=
rfl
#align cycle.coe_nil Cycle.coe_nil
@[simp]
theorem coe_eq_nil (l : List α) : (l : Cycle α) = nil ↔ l = [] :=
coe_eq_coe.trans isRotated_nil_iff
#align cycle.coe_eq_nil Cycle.coe_eq_nil
/-- For consistency with `EmptyCollection (List α)`. -/
instance : EmptyCollection (Cycle α) :=
⟨nil⟩
@[simp]
theorem empty_eq : ∅ = @nil α :=
rfl
#align cycle.empty_eq Cycle.empty_eq
instance : Inhabited (Cycle α) :=
⟨nil⟩
/-- An induction principle for `Cycle`. Use as `induction s using Cycle.induction_on`. -/
@[elab_as_elim]
theorem induction_on {C : Cycle α → Prop} (s : Cycle α) (H0 : C nil)
(HI : ∀ (a) (l : List α), C ↑l → C ↑(a :: l)) : C s :=
Quotient.inductionOn' s fun l => by
refine List.recOn l ?_ ?_ <;> simp
assumption'
#align cycle.induction_on Cycle.induction_on
/-- For `x : α`, `s : Cycle α`, `x ∈ s` indicates that `x` occurs at least once in `s`. -/
def Mem (a : α) (s : Cycle α) : Prop :=
Quot.liftOn s (fun l => a ∈ l) fun _ _ e => propext <| e.mem_iff
#align cycle.mem Cycle.Mem
instance : Membership α (Cycle α) :=
⟨Mem⟩
@[simp]
theorem mem_coe_iff {a : α} {l : List α} : a ∈ (↑l : Cycle α) ↔ a ∈ l :=
Iff.rfl
#align cycle.mem_coe_iff Cycle.mem_coe_iff
@[simp]
theorem not_mem_nil : ∀ a, a ∉ @nil α :=
List.not_mem_nil
#align cycle.not_mem_nil Cycle.not_mem_nil
instance [DecidableEq α] : DecidableEq (Cycle α) := fun s₁ s₂ =>
Quotient.recOnSubsingleton₂' s₁ s₂ fun _ _ => decidable_of_iff' _ Quotient.eq''
instance [DecidableEq α] (x : α) (s : Cycle α) : Decidable (x ∈ s) :=
Quotient.recOnSubsingleton' s fun l => show Decidable (x ∈ l) from inferInstance
/-- Reverse a `s : Cycle α` by reversing the underlying `List`. -/
nonrec def reverse (s : Cycle α) : Cycle α :=
Quot.map reverse (fun _ _ => IsRotated.reverse) s
#align cycle.reverse Cycle.reverse
@[simp]
theorem reverse_coe (l : List α) : (l : Cycle α).reverse = l.reverse :=
rfl
#align cycle.reverse_coe Cycle.reverse_coe
@[simp]
theorem mem_reverse_iff {a : α} {s : Cycle α} : a ∈ s.reverse ↔ a ∈ s :=
Quot.inductionOn s fun _ => mem_reverse
#align cycle.mem_reverse_iff Cycle.mem_reverse_iff
@[simp]
theorem reverse_reverse (s : Cycle α) : s.reverse.reverse = s :=
Quot.inductionOn s fun _ => by simp
#align cycle.reverse_reverse Cycle.reverse_reverse
@[simp]
theorem reverse_nil : nil.reverse = @nil α :=
rfl
#align cycle.reverse_nil Cycle.reverse_nil
/-- The length of the `s : Cycle α`, which is the number of elements, counting duplicates. -/
def length (s : Cycle α) : ℕ :=
Quot.liftOn s List.length fun _ _ e => e.perm.length_eq
#align cycle.length Cycle.length
@[simp]
theorem length_coe (l : List α) : length (l : Cycle α) = l.length :=
rfl
#align cycle.length_coe Cycle.length_coe
@[simp]
theorem length_nil : length (@nil α) = 0 :=
rfl
#align cycle.length_nil Cycle.length_nil
@[simp]
theorem length_reverse (s : Cycle α) : s.reverse.length = s.length :=
Quot.inductionOn s List.length_reverse
#align cycle.length_reverse Cycle.length_reverse
/-- A `s : Cycle α` that is at most one element. -/
def Subsingleton (s : Cycle α) : Prop :=
s.length ≤ 1
#align cycle.subsingleton Cycle.Subsingleton
theorem subsingleton_nil : Subsingleton (@nil α) := Nat.zero_le _
#align cycle.subsingleton_nil Cycle.subsingleton_nil
theorem length_subsingleton_iff {s : Cycle α} : Subsingleton s ↔ length s ≤ 1 :=
Iff.rfl
#align cycle.length_subsingleton_iff Cycle.length_subsingleton_iff
@[simp]
theorem subsingleton_reverse_iff {s : Cycle α} : s.reverse.Subsingleton ↔ s.Subsingleton := by
simp [length_subsingleton_iff]
#align cycle.subsingleton_reverse_iff Cycle.subsingleton_reverse_iff
theorem Subsingleton.congr {s : Cycle α} (h : Subsingleton s) :
∀ ⦃x⦄ (_hx : x ∈ s) ⦃y⦄ (_hy : y ∈ s), x = y := by
induction' s using Quot.inductionOn with l
simp only [length_subsingleton_iff, length_coe, mk_eq_coe, le_iff_lt_or_eq, Nat.lt_add_one_iff,
length_eq_zero, length_eq_one, Nat.not_lt_zero, false_or_iff] at h
rcases h with (rfl | ⟨z, rfl⟩) <;> simp
#align cycle.subsingleton.congr Cycle.Subsingleton.congr
/-- A `s : Cycle α` that is made up of at least two unique elements. -/
def Nontrivial (s : Cycle α) : Prop :=
∃ x y : α, x ≠ y ∧ x ∈ s ∧ y ∈ s
#align cycle.nontrivial Cycle.Nontrivial
@[simp]
theorem nontrivial_coe_nodup_iff {l : List α} (hl : l.Nodup) :
Nontrivial (l : Cycle α) ↔ 2 ≤ l.length := by
rw [Nontrivial]
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp
· simp
· simp only [mem_cons, exists_prop, mem_coe_iff, List.length, Ne, Nat.succ_le_succ_iff,
Nat.zero_le, iff_true_iff]
refine ⟨hd, hd', ?_, by simp⟩
simp only [not_or, mem_cons, nodup_cons] at hl
exact hl.left.left
#align cycle.nontrivial_coe_nodup_iff Cycle.nontrivial_coe_nodup_iff
@[simp]
theorem nontrivial_reverse_iff {s : Cycle α} : s.reverse.Nontrivial ↔ s.Nontrivial := by
simp [Nontrivial]
#align cycle.nontrivial_reverse_iff Cycle.nontrivial_reverse_iff
theorem length_nontrivial {s : Cycle α} (h : Nontrivial s) : 2 ≤ length s := by
obtain ⟨x, y, hxy, hx, hy⟩ := h
induction' s using Quot.inductionOn with l
rcases l with (_ | ⟨hd, _ | ⟨hd', tl⟩⟩)
· simp at hx
· simp only [mem_coe_iff, mk_eq_coe, mem_singleton] at hx hy
simp [hx, hy] at hxy
· simp [Nat.succ_le_succ_iff]
#align cycle.length_nontrivial Cycle.length_nontrivial
/-- The `s : Cycle α` contains no duplicates. -/
nonrec def Nodup (s : Cycle α) : Prop :=
Quot.liftOn s Nodup fun _l₁ _l₂ e => propext <| e.nodup_iff
#align cycle.nodup Cycle.Nodup
@[simp]
nonrec theorem nodup_nil : Nodup (@nil α) :=
nodup_nil
#align cycle.nodup_nil Cycle.nodup_nil
@[simp]
theorem nodup_coe_iff {l : List α} : Nodup (l : Cycle α) ↔ l.Nodup :=
Iff.rfl
#align cycle.nodup_coe_iff Cycle.nodup_coe_iff
@[simp]
theorem nodup_reverse_iff {s : Cycle α} : s.reverse.Nodup ↔ s.Nodup :=
Quot.inductionOn s fun _ => nodup_reverse
#align cycle.nodup_reverse_iff Cycle.nodup_reverse_iff
theorem Subsingleton.nodup {s : Cycle α} (h : Subsingleton s) : Nodup s := by
induction' s using Quot.inductionOn with l
cases' l with hd tl
· simp
· have : tl = [] := by simpa [Subsingleton, length_eq_zero, Nat.succ_le_succ_iff] using h
simp [this]
#align cycle.subsingleton.nodup Cycle.Subsingleton.nodup
theorem Nodup.nontrivial_iff {s : Cycle α} (h : Nodup s) : Nontrivial s ↔ ¬Subsingleton s := by
rw [length_subsingleton_iff]
induction s using Quotient.inductionOn'
simp only [mk''_eq_coe, nodup_coe_iff] at h
simp [h, Nat.succ_le_iff]
#align cycle.nodup.nontrivial_iff Cycle.Nodup.nontrivial_iff
/-- The `s : Cycle α` as a `Multiset α`.
-/
def toMultiset (s : Cycle α) : Multiset α :=
Quotient.liftOn' s (↑) fun _ _ h => Multiset.coe_eq_coe.mpr h.perm
#align cycle.to_multiset Cycle.toMultiset
@[simp]
theorem coe_toMultiset (l : List α) : (l : Cycle α).toMultiset = l :=
rfl
#align cycle.coe_to_multiset Cycle.coe_toMultiset
@[simp]
theorem nil_toMultiset : nil.toMultiset = (0 : Multiset α) :=
rfl
#align cycle.nil_to_multiset Cycle.nil_toMultiset
@[simp]
theorem card_toMultiset (s : Cycle α) : Multiset.card s.toMultiset = s.length :=
Quotient.inductionOn' s (by simp)
#align cycle.card_to_multiset Cycle.card_toMultiset
@[simp]
theorem toMultiset_eq_nil {s : Cycle α} : s.toMultiset = 0 ↔ s = Cycle.nil :=
Quotient.inductionOn' s (by simp)
#align cycle.to_multiset_eq_nil Cycle.toMultiset_eq_nil
/-- The lift of `list.map`. -/
def map {β : Type*} (f : α → β) : Cycle α → Cycle β :=
Quotient.map' (List.map f) fun _ _ h => h.map _
#align cycle.map Cycle.map
@[simp]
theorem map_nil {β : Type*} (f : α → β) : map f nil = nil :=
rfl
#align cycle.map_nil Cycle.map_nil
@[simp]
theorem map_coe {β : Type*} (f : α → β) (l : List α) : map f ↑l = List.map f l :=
rfl
#align cycle.map_coe Cycle.map_coe
@[simp]
theorem map_eq_nil {β : Type*} (f : α → β) (s : Cycle α) : map f s = nil ↔ s = nil :=
Quotient.inductionOn' s (by simp)
#align cycle.map_eq_nil Cycle.map_eq_nil
@[simp]
theorem mem_map {β : Type*} {f : α → β} {b : β} {s : Cycle α} :
b ∈ s.map f ↔ ∃ a, a ∈ s ∧ f a = b :=
Quotient.inductionOn' s (by simp)
#align cycle.mem_map Cycle.mem_map
/-- The `Multiset` of lists that can make the cycle. -/
def lists (s : Cycle α) : Multiset (List α) :=
Quotient.liftOn' s (fun l => (l.cyclicPermutations : Multiset (List α))) fun l₁ l₂ h => by
simpa using h.cyclicPermutations.perm
#align cycle.lists Cycle.lists
@[simp]
theorem lists_coe (l : List α) : lists (l : Cycle α) = ↑l.cyclicPermutations :=
rfl
#align cycle.lists_coe Cycle.lists_coe
@[simp]
theorem mem_lists_iff_coe_eq {s : Cycle α} {l : List α} : l ∈ s.lists ↔ (l : Cycle α) = s :=
Quotient.inductionOn' s fun l => by
rw [lists, Quotient.liftOn'_mk'']
simp
#align cycle.mem_lists_iff_coe_eq Cycle.mem_lists_iff_coe_eq
@[simp]
theorem lists_nil : lists (@nil α) = [([] : List α)] := by
rw [nil, lists_coe, cyclicPermutations_nil]
#align cycle.lists_nil Cycle.lists_nil
section Decidable
variable [DecidableEq α]
/-- Auxiliary decidability algorithm for lists that contain at least two unique elements.
-/
def decidableNontrivialCoe : ∀ l : List α, Decidable (Nontrivial (l : Cycle α))
| [] => isFalse (by simp [Nontrivial])
| [x] => isFalse (by simp [Nontrivial])
| x :: y :: l =>
if h : x = y then
@decidable_of_iff' _ (Nontrivial (x :: l : Cycle α)) (by simp [h, Nontrivial])
(decidableNontrivialCoe (x :: l))
else isTrue ⟨x, y, h, by simp, by simp⟩
#align cycle.decidable_nontrivial_coe Cycle.decidableNontrivialCoe
instance {s : Cycle α} : Decidable (Nontrivial s) :=
Quot.recOnSubsingleton' s decidableNontrivialCoe
instance {s : Cycle α} : Decidable (Nodup s) :=
Quot.recOnSubsingleton' s List.nodupDecidable
instance fintypeNodupCycle [Fintype α] : Fintype { s : Cycle α // s.Nodup } :=
Fintype.ofSurjective (fun l : { l : List α // l.Nodup } => ⟨l.val, by simpa using l.prop⟩)
fun ⟨s, hs⟩ => by
induction' s using Quotient.inductionOn' with s hs
exact ⟨⟨s, hs⟩, by simp⟩
#align cycle.fintype_nodup_cycle Cycle.fintypeNodupCycle
instance fintypeNodupNontrivialCycle [Fintype α] :
Fintype { s : Cycle α // s.Nodup ∧ s.Nontrivial } :=
Fintype.subtype
(((Finset.univ : Finset { s : Cycle α // s.Nodup }).map (Function.Embedding.subtype _)).filter
Cycle.Nontrivial)
(by simp)
#align cycle.fintype_nodup_nontrivial_cycle Cycle.fintypeNodupNontrivialCycle
/-- The `s : Cycle α` as a `Finset α`. -/
def toFinset (s : Cycle α) : Finset α :=
s.toMultiset.toFinset
#align cycle.to_finset Cycle.toFinset
@[simp]
theorem toFinset_toMultiset (s : Cycle α) : s.toMultiset.toFinset = s.toFinset :=
rfl
#align cycle.to_finset_to_multiset Cycle.toFinset_toMultiset
@[simp]
theorem coe_toFinset (l : List α) : (l : Cycle α).toFinset = l.toFinset :=
rfl
#align cycle.coe_to_finset Cycle.coe_toFinset
@[simp]
theorem nil_toFinset : (@nil α).toFinset = ∅ :=
rfl
#align cycle.nil_to_finset Cycle.nil_toFinset
@[simp]
theorem toFinset_eq_nil {s : Cycle α} : s.toFinset = ∅ ↔ s = Cycle.nil :=
Quotient.inductionOn' s (by simp)
#align cycle.to_finset_eq_nil Cycle.toFinset_eq_nil
/-- Given a `s : Cycle α` such that `Nodup s`, retrieve the next element after `x ∈ s`. -/
nonrec def next : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s), α := fun s =>
Quot.hrecOn (motive := fun (s : Cycle α) => ∀ (_hs : Cycle.Nodup s) (x : α) (_hx : x ∈ s), α) s
(fun l _hn x hx => next l x hx) fun l₁ l₂ h =>
Function.hfunext (propext h.nodup_iff) fun h₁ h₂ _he =>
Function.hfunext rfl fun x y hxy =>
Function.hfunext (propext (by rw [eq_of_heq hxy]; simpa [eq_of_heq hxy] using h.mem_iff))
fun hm hm' he' => heq_of_eq
(by rw [heq_iff_eq] at hxy; subst x; simpa using isRotated_next_eq h h₁ _)
#align cycle.next Cycle.next
/-- Given a `s : Cycle α` such that `Nodup s`, retrieve the previous element before `x ∈ s`. -/
nonrec def prev : ∀ (s : Cycle α) (_hs : Nodup s) (x : α) (_hx : x ∈ s), α := fun s =>
Quot.hrecOn (motive := fun (s : Cycle α) => ∀ (_hs : Cycle.Nodup s) (x : α) (_hx : x ∈ s), α) s
(fun l _hn x hx => prev l x hx) fun l₁ l₂ h =>
Function.hfunext (propext h.nodup_iff) fun h₁ h₂ _he =>
Function.hfunext rfl fun x y hxy =>
Function.hfunext (propext (by rw [eq_of_heq hxy]; simpa [eq_of_heq hxy] using h.mem_iff))
fun hm hm' he' => heq_of_eq
(by rw [heq_iff_eq] at hxy; subst x; simpa using isRotated_prev_eq h h₁ _)
#align cycle.prev Cycle.prev
-- Porting note: removed `simp` and added `prev_reverse_eq_next'` with `simp` attribute
nonrec theorem prev_reverse_eq_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),
s.reverse.prev (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.next hs x hx :=
Quotient.inductionOn' s prev_reverse_eq_next
#align cycle.prev_reverse_eq_next Cycle.prev_reverse_eq_next
-- Porting note (#10756): new theorem
@[simp]
nonrec theorem prev_reverse_eq_next' (s : Cycle α) (hs : Nodup s.reverse) (x : α)
(hx : x ∈ s.reverse) :
s.reverse.prev hs x hx = s.next (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) :=
prev_reverse_eq_next s (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx)
-- Porting note: removed `simp` and added `next_reverse_eq_prev'` with `simp` attribute
theorem next_reverse_eq_prev (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) :
s.reverse.next (nodup_reverse_iff.mpr hs) x (mem_reverse_iff.mpr hx) = s.prev hs x hx := by
simp [← prev_reverse_eq_next]
#align cycle.next_reverse_eq_prev Cycle.next_reverse_eq_prev
-- Porting note (#10756): new theorem
@[simp]
theorem next_reverse_eq_prev' (s : Cycle α) (hs : Nodup s.reverse) (x : α) (hx : x ∈ s.reverse) :
s.reverse.next hs x hx = s.prev (nodup_reverse_iff.mp hs) x (mem_reverse_iff.mp hx) := by
simp [← prev_reverse_eq_next]
@[simp]
nonrec theorem next_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.next hs x hx ∈ s := by
induction s using Quot.inductionOn
apply next_mem; assumption
#align cycle.next_mem Cycle.next_mem
theorem prev_mem (s : Cycle α) (hs : Nodup s) (x : α) (hx : x ∈ s) : s.prev hs x hx ∈ s := by
rw [← next_reverse_eq_prev, ← mem_reverse_iff]
apply next_mem
#align cycle.prev_mem Cycle.prev_mem
@[simp]
nonrec theorem prev_next (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),
s.prev hs (s.next hs x hx) (next_mem s hs x hx) = x :=
Quotient.inductionOn' s prev_next
#align cycle.prev_next Cycle.prev_next
@[simp]
nonrec theorem next_prev (s : Cycle α) : ∀ (hs : Nodup s) (x : α) (hx : x ∈ s),
s.next hs (s.prev hs x hx) (prev_mem s hs x hx) = x :=
Quotient.inductionOn' s next_prev
#align cycle.next_prev Cycle.next_prev
end Decidable
/-- We define a representation of concrete cycles, available when viewing them in a goal state or
via `#eval`, when over representable types. For example, the cycle `(2 1 4 3)` will be shown
as `c[2, 1, 4, 3]`. Two equal cycles may be printed differently if their internal representation
is different.
-/
unsafe instance [Repr α] : Repr (Cycle α) :=
⟨fun s _ => "c[" ++ Std.Format.joinSep (s.map repr).lists.unquot.head! ", " ++ "]"⟩
/-- `chain R s` means that `R` holds between adjacent elements of `s`.
`chain R ([a, b, c] : Cycle α) ↔ R a b ∧ R b c ∧ R c a` -/
nonrec def Chain (r : α → α → Prop) (c : Cycle α) : Prop :=
Quotient.liftOn' c
(fun l =>
match l with
| [] => True
| a :: m => Chain r a (m ++ [a]))
fun a b hab =>
propext <| by
cases' a with a l <;> cases' b with b m
· rfl
· have := isRotated_nil_iff'.1 hab
contradiction
· have := isRotated_nil_iff.1 hab
contradiction
· dsimp only
cases' hab with n hn
induction' n with d hd generalizing a b l m
· simp only [Nat.zero_eq, rotate_zero, cons.injEq] at hn
rw [hn.1, hn.2]
· cases' l with c s
· simp only [rotate_cons_succ, nil_append, rotate_singleton, cons.injEq] at hn
rw [hn.1, hn.2]
· rw [Nat.add_comm, ← rotate_rotate, rotate_cons_succ, rotate_zero, cons_append] at hn
rw [← hd c _ _ _ hn]
simp [and_comm]
#align cycle.chain Cycle.Chain
@[simp]
| Mathlib/Data/List/Cycle.lean | 930 | 930 | theorem Chain.nil (r : α → α → Prop) : Cycle.Chain r (@nil α) := by | trivial
|
/-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.Algebra.Homology.ComplexShape
import Mathlib.CategoryTheory.Subobject.Limits
import Mathlib.CategoryTheory.GradedObject
import Mathlib.Algebra.Homology.ShortComplex.Basic
#align_import algebra.homology.homological_complex from "leanprover-community/mathlib"@"88bca0ce5d22ebfd9e73e682e51d60ea13b48347"
/-!
# Homological complexes.
A `HomologicalComplex V c` with a "shape" controlled by `c : ComplexShape ι`
has chain groups `X i` (objects in `V`) indexed by `i : ι`,
and a differential `d i j` whenever `c.Rel i j`.
We in fact ask for differentials `d i j` for all `i j : ι`,
but have a field `shape` requiring that these are zero when not allowed by `c`.
This avoids a lot of dependent type theory hell!
The composite of any two differentials `d i j ≫ d j k` must be zero.
We provide `ChainComplex V α` for
`α`-indexed chain complexes in which `d i j ≠ 0` only if `j + 1 = i`,
and similarly `CochainComplex V α`, with `i = j + 1`.
There is a category structure, where morphisms are chain maps.
For `C : HomologicalComplex V c`, we define `C.xNext i`, which is either `C.X j` for some
arbitrarily chosen `j` such that `c.r i j`, or `C.X i` if there is no such `j`.
Similarly we have `C.xPrev j`.
Defined in terms of these we have `C.dFrom i : C.X i ⟶ C.xNext i` and
`C.dTo j : C.xPrev j ⟶ C.X j`, which are either defined as `C.d i j`, or zero, as needed.
-/
universe v u
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
variable {ι : Type*}
variable (V : Type u) [Category.{v} V] [HasZeroMorphisms V]
/-- A `HomologicalComplex V c` with a "shape" controlled by `c : ComplexShape ι`
has chain groups `X i` (objects in `V`) indexed by `i : ι`,
and a differential `d i j` whenever `c.Rel i j`.
We in fact ask for differentials `d i j` for all `i j : ι`,
but have a field `shape` requiring that these are zero when not allowed by `c`.
This avoids a lot of dependent type theory hell!
The composite of any two differentials `d i j ≫ d j k` must be zero.
-/
structure HomologicalComplex (c : ComplexShape ι) where
X : ι → V
d : ∀ i j, X i ⟶ X j
shape : ∀ i j, ¬c.Rel i j → d i j = 0 := by aesop_cat
d_comp_d' : ∀ i j k, c.Rel i j → c.Rel j k → d i j ≫ d j k = 0 := by aesop_cat
#align homological_complex HomologicalComplex
namespace HomologicalComplex
attribute [simp] shape
variable {V} {c : ComplexShape ι}
@[reassoc (attr := simp)]
theorem d_comp_d (C : HomologicalComplex V c) (i j k : ι) : C.d i j ≫ C.d j k = 0 := by
by_cases hij : c.Rel i j
· by_cases hjk : c.Rel j k
· exact C.d_comp_d' i j k hij hjk
· rw [C.shape j k hjk, comp_zero]
· rw [C.shape i j hij, zero_comp]
#align homological_complex.d_comp_d HomologicalComplex.d_comp_d
theorem ext {C₁ C₂ : HomologicalComplex V c} (h_X : C₁.X = C₂.X)
(h_d :
∀ i j : ι,
c.Rel i j → C₁.d i j ≫ eqToHom (congr_fun h_X j) = eqToHom (congr_fun h_X i) ≫ C₂.d i j) :
C₁ = C₂ := by
obtain ⟨X₁, d₁, s₁, h₁⟩ := C₁
obtain ⟨X₂, d₂, s₂, h₂⟩ := C₂
dsimp at h_X
subst h_X
simp only [mk.injEq, heq_eq_eq, true_and]
ext i j
by_cases hij: c.Rel i j
· simpa only [comp_id, id_comp, eqToHom_refl] using h_d i j hij
· rw [s₁ i j hij, s₂ i j hij]
#align homological_complex.ext HomologicalComplex.ext
/-- The obvious isomorphism `K.X p ≅ K.X q` when `p = q`. -/
def XIsoOfEq (K : HomologicalComplex V c) {p q : ι} (h : p = q) : K.X p ≅ K.X q :=
eqToIso (by rw [h])
@[simp]
lemma XIsoOfEq_rfl (K : HomologicalComplex V c) (p : ι) :
K.XIsoOfEq (rfl : p = p) = Iso.refl _ := rfl
@[reassoc (attr := simp)]
lemma XIsoOfEq_hom_comp_XIsoOfEq_hom (K : HomologicalComplex V c) {p₁ p₂ p₃ : ι}
(h₁₂ : p₁ = p₂) (h₂₃ : p₂ = p₃) :
(K.XIsoOfEq h₁₂).hom ≫ (K.XIsoOfEq h₂₃).hom = (K.XIsoOfEq (h₁₂.trans h₂₃)).hom := by
dsimp [XIsoOfEq]
simp only [eqToHom_trans]
@[reassoc (attr := simp)]
lemma XIsoOfEq_hom_comp_XIsoOfEq_inv (K : HomologicalComplex V c) {p₁ p₂ p₃ : ι}
(h₁₂ : p₁ = p₂) (h₃₂ : p₃ = p₂) :
(K.XIsoOfEq h₁₂).hom ≫ (K.XIsoOfEq h₃₂).inv = (K.XIsoOfEq (h₁₂.trans h₃₂.symm)).hom := by
dsimp [XIsoOfEq]
simp only [eqToHom_trans]
@[reassoc (attr := simp)]
lemma XIsoOfEq_inv_comp_XIsoOfEq_hom (K : HomologicalComplex V c) {p₁ p₂ p₃ : ι}
(h₂₁ : p₂ = p₁) (h₂₃ : p₂ = p₃) :
(K.XIsoOfEq h₂₁).inv ≫ (K.XIsoOfEq h₂₃).hom = (K.XIsoOfEq (h₂₁.symm.trans h₂₃)).hom := by
dsimp [XIsoOfEq]
simp only [eqToHom_trans]
@[reassoc (attr := simp)]
lemma XIsoOfEq_inv_comp_XIsoOfEq_inv (K : HomologicalComplex V c) {p₁ p₂ p₃ : ι}
(h₂₁ : p₂ = p₁) (h₃₂ : p₃ = p₂) :
(K.XIsoOfEq h₂₁).inv ≫ (K.XIsoOfEq h₃₂).inv = (K.XIsoOfEq (h₃₂.trans h₂₁).symm).hom := by
dsimp [XIsoOfEq]
simp only [eqToHom_trans]
@[reassoc (attr := simp)]
lemma XIsoOfEq_hom_comp_d (K : HomologicalComplex V c) {p₁ p₂ : ι} (h : p₁ = p₂) (p₃ : ι) :
(K.XIsoOfEq h).hom ≫ K.d p₂ p₃ = K.d p₁ p₃ := by subst h; simp
@[reassoc (attr := simp)]
lemma XIsoOfEq_inv_comp_d (K : HomologicalComplex V c) {p₂ p₁ : ι} (h : p₂ = p₁) (p₃ : ι) :
(K.XIsoOfEq h).inv ≫ K.d p₂ p₃ = K.d p₁ p₃ := by subst h; simp
@[reassoc (attr := simp)]
lemma d_comp_XIsoOfEq_hom (K : HomologicalComplex V c) {p₂ p₃ : ι} (h : p₂ = p₃) (p₁ : ι) :
K.d p₁ p₂ ≫ (K.XIsoOfEq h).hom = K.d p₁ p₃ := by subst h; simp
@[reassoc (attr := simp)]
lemma d_comp_XIsoOfEq_inv (K : HomologicalComplex V c) {p₂ p₃ : ι} (h : p₃ = p₂) (p₁ : ι) :
K.d p₁ p₂ ≫ (K.XIsoOfEq h).inv = K.d p₁ p₃ := by subst h; simp
end HomologicalComplex
/-- An `α`-indexed chain complex is a `HomologicalComplex`
in which `d i j ≠ 0` only if `j + 1 = i`.
-/
abbrev ChainComplex (α : Type*) [AddRightCancelSemigroup α] [One α] : Type _ :=
HomologicalComplex V (ComplexShape.down α)
#align chain_complex ChainComplex
/-- An `α`-indexed cochain complex is a `HomologicalComplex`
in which `d i j ≠ 0` only if `i + 1 = j`.
-/
abbrev CochainComplex (α : Type*) [AddRightCancelSemigroup α] [One α] : Type _ :=
HomologicalComplex V (ComplexShape.up α)
#align cochain_complex CochainComplex
namespace ChainComplex
@[simp]
theorem prev (α : Type*) [AddRightCancelSemigroup α] [One α] (i : α) :
(ComplexShape.down α).prev i = i + 1 :=
(ComplexShape.down α).prev_eq' rfl
#align chain_complex.prev ChainComplex.prev
@[simp]
theorem next (α : Type*) [AddGroup α] [One α] (i : α) : (ComplexShape.down α).next i = i - 1 :=
(ComplexShape.down α).next_eq' <| sub_add_cancel _ _
#align chain_complex.next ChainComplex.next
@[simp]
theorem next_nat_zero : (ComplexShape.down ℕ).next 0 = 0 := by
classical
refine dif_neg ?_
push_neg
intro
apply Nat.noConfusion
#align chain_complex.next_nat_zero ChainComplex.next_nat_zero
@[simp]
theorem next_nat_succ (i : ℕ) : (ComplexShape.down ℕ).next (i + 1) = i :=
(ComplexShape.down ℕ).next_eq' rfl
#align chain_complex.next_nat_succ ChainComplex.next_nat_succ
end ChainComplex
namespace CochainComplex
@[simp]
theorem prev (α : Type*) [AddGroup α] [One α] (i : α) : (ComplexShape.up α).prev i = i - 1 :=
(ComplexShape.up α).prev_eq' <| sub_add_cancel _ _
#align cochain_complex.prev CochainComplex.prev
@[simp]
theorem next (α : Type*) [AddRightCancelSemigroup α] [One α] (i : α) :
(ComplexShape.up α).next i = i + 1 :=
(ComplexShape.up α).next_eq' rfl
#align cochain_complex.next CochainComplex.next
@[simp]
theorem prev_nat_zero : (ComplexShape.up ℕ).prev 0 = 0 := by
classical
refine dif_neg ?_
push_neg
intro
apply Nat.noConfusion
#align cochain_complex.prev_nat_zero CochainComplex.prev_nat_zero
@[simp]
theorem prev_nat_succ (i : ℕ) : (ComplexShape.up ℕ).prev (i + 1) = i :=
(ComplexShape.up ℕ).prev_eq' rfl
#align cochain_complex.prev_nat_succ CochainComplex.prev_nat_succ
end CochainComplex
namespace HomologicalComplex
variable {V}
variable {c : ComplexShape ι} (C : HomologicalComplex V c)
/-- A morphism of homological complexes consists of maps between the chain groups,
commuting with the differentials.
-/
@[ext]
structure Hom (A B : HomologicalComplex V c) where
f : ∀ i, A.X i ⟶ B.X i
comm' : ∀ i j, c.Rel i j → f i ≫ B.d i j = A.d i j ≫ f j := by aesop_cat
#align homological_complex.hom HomologicalComplex.Hom
@[reassoc (attr := simp)]
theorem Hom.comm {A B : HomologicalComplex V c} (f : A.Hom B) (i j : ι) :
f.f i ≫ B.d i j = A.d i j ≫ f.f j := by
by_cases hij : c.Rel i j
· exact f.comm' i j hij
· rw [A.shape i j hij, B.shape i j hij, comp_zero, zero_comp]
#align homological_complex.hom.comm HomologicalComplex.Hom.comm
instance (A B : HomologicalComplex V c) : Inhabited (Hom A B) :=
⟨{ f := fun i => 0 }⟩
/-- Identity chain map. -/
def id (A : HomologicalComplex V c) : Hom A A where f _ := 𝟙 _
#align homological_complex.id HomologicalComplex.id
/-- Composition of chain maps. -/
def comp (A B C : HomologicalComplex V c) (φ : Hom A B) (ψ : Hom B C) : Hom A C where
f i := φ.f i ≫ ψ.f i
#align homological_complex.comp HomologicalComplex.comp
section
attribute [local simp] id comp
instance : Category (HomologicalComplex V c) where
Hom := Hom
id := id
comp := comp _ _ _
end
-- Porting note: added because `Hom.ext` is not triggered automatically
@[ext]
lemma hom_ext {C D : HomologicalComplex V c} (f g : C ⟶ D)
(h : ∀ i, f.f i = g.f i) : f = g := by
apply Hom.ext
funext
apply h
@[simp]
theorem id_f (C : HomologicalComplex V c) (i : ι) : Hom.f (𝟙 C) i = 𝟙 (C.X i) :=
rfl
#align homological_complex.id_f HomologicalComplex.id_f
@[simp, reassoc]
theorem comp_f {C₁ C₂ C₃ : HomologicalComplex V c} (f : C₁ ⟶ C₂) (g : C₂ ⟶ C₃) (i : ι) :
(f ≫ g).f i = f.f i ≫ g.f i :=
rfl
#align homological_complex.comp_f HomologicalComplex.comp_f
@[simp]
theorem eqToHom_f {C₁ C₂ : HomologicalComplex V c} (h : C₁ = C₂) (n : ι) :
HomologicalComplex.Hom.f (eqToHom h) n =
eqToHom (congr_fun (congr_arg HomologicalComplex.X h) n) := by
subst h
rfl
#align homological_complex.eq_to_hom_f HomologicalComplex.eqToHom_f
-- We'll use this later to show that `HomologicalComplex V c` is preadditive when `V` is.
theorem hom_f_injective {C₁ C₂ : HomologicalComplex V c} :
Function.Injective fun f : Hom C₁ C₂ => f.f := by aesop_cat
#align homological_complex.hom_f_injective HomologicalComplex.hom_f_injective
instance (X Y : HomologicalComplex V c) : Zero (X ⟶ Y) :=
⟨{ f := fun i => 0}⟩
@[simp]
theorem zero_f (C D : HomologicalComplex V c) (i : ι) : (0 : C ⟶ D).f i = 0 :=
rfl
#align homological_complex.zero_apply HomologicalComplex.zero_f
instance : HasZeroMorphisms (HomologicalComplex V c) where
open ZeroObject
/-- The zero complex -/
noncomputable def zero [HasZeroObject V] : HomologicalComplex V c where
X _ := 0
d _ _ := 0
#align homological_complex.zero HomologicalComplex.zero
theorem isZero_zero [HasZeroObject V] : IsZero (zero : HomologicalComplex V c) := by
refine ⟨fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩, fun X => ⟨⟨⟨0⟩, fun f => ?_⟩⟩⟩
all_goals
ext
dsimp [zero]
apply Subsingleton.elim
#align homological_complex.is_zero_zero HomologicalComplex.isZero_zero
instance [HasZeroObject V] : HasZeroObject (HomologicalComplex V c) :=
⟨⟨zero, isZero_zero⟩⟩
noncomputable instance [HasZeroObject V] : Inhabited (HomologicalComplex V c) :=
⟨zero⟩
theorem congr_hom {C D : HomologicalComplex V c} {f g : C ⟶ D} (w : f = g) (i : ι) :
f.f i = g.f i :=
congr_fun (congr_arg Hom.f w) i
#align homological_complex.congr_hom HomologicalComplex.congr_hom
lemma mono_of_mono_f {K L : HomologicalComplex V c} (φ : K ⟶ L)
(hφ : ∀ i, Mono (φ.f i)) : Mono φ where
right_cancellation g h eq := by
ext i
rw [← cancel_mono (φ.f i)]
exact congr_hom eq i
lemma epi_of_epi_f {K L : HomologicalComplex V c} (φ : K ⟶ L)
(hφ : ∀ i, Epi (φ.f i)) : Epi φ where
left_cancellation g h eq := by
ext i
rw [← cancel_epi (φ.f i)]
exact congr_hom eq i
section
variable (V c)
/-- The functor picking out the `i`-th object of a complex. -/
@[simps]
def eval (i : ι) : HomologicalComplex V c ⥤ V where
obj C := C.X i
map f := f.f i
#align homological_complex.eval HomologicalComplex.eval
/-- The functor forgetting the differential in a complex, obtaining a graded object. -/
@[simps]
def forget : HomologicalComplex V c ⥤ GradedObject ι V where
obj C := C.X
map f := f.f
#align homological_complex.forget HomologicalComplex.forget
instance : (forget V c).Faithful where
map_injective h := by
ext i
exact congr_fun h i
/-- Forgetting the differentials than picking out the `i`-th object is the same as
just picking out the `i`-th object. -/
@[simps!]
def forgetEval (i : ι) : forget V c ⋙ GradedObject.eval i ≅ eval V c i :=
NatIso.ofComponents fun X => Iso.refl _
#align homological_complex.forget_eval HomologicalComplex.forgetEval
end
noncomputable section
@[reassoc]
lemma XIsoOfEq_hom_naturality {K L : HomologicalComplex V c} (φ : K ⟶ L) {n n' : ι} (h : n = n') :
φ.f n ≫ (L.XIsoOfEq h).hom = (K.XIsoOfEq h).hom ≫ φ.f n' := by subst h; simp
@[reassoc]
lemma XIsoOfEq_inv_naturality {K L : HomologicalComplex V c} (φ : K ⟶ L) {n n' : ι} (h : n = n') :
φ.f n' ≫ (L.XIsoOfEq h).inv = (K.XIsoOfEq h).inv ≫ φ.f n := by subst h; simp
-- Porting note: removed @[simp] as the linter complained
/-- If `C.d i j` and `C.d i j'` are both allowed, then we must have `j = j'`,
and so the differentials only differ by an `eqToHom`.
-/
theorem d_comp_eqToHom {i j j' : ι} (rij : c.Rel i j) (rij' : c.Rel i j') :
C.d i j' ≫ eqToHom (congr_arg C.X (c.next_eq rij' rij)) = C.d i j := by
obtain rfl := c.next_eq rij rij'
simp only [eqToHom_refl, comp_id]
#align homological_complex.d_comp_eq_to_hom HomologicalComplex.d_comp_eqToHom
-- Porting note: removed @[simp] as the linter complained
/-- If `C.d i j` and `C.d i' j` are both allowed, then we must have `i = i'`,
and so the differentials only differ by an `eqToHom`.
-/
theorem eqToHom_comp_d {i i' j : ι} (rij : c.Rel i j) (rij' : c.Rel i' j) :
eqToHom (congr_arg C.X (c.prev_eq rij rij')) ≫ C.d i' j = C.d i j := by
obtain rfl := c.prev_eq rij rij'
simp only [eqToHom_refl, id_comp]
#align homological_complex.eq_to_hom_comp_d HomologicalComplex.eqToHom_comp_d
theorem kernel_eq_kernel [HasKernels V] {i j j' : ι} (r : c.Rel i j) (r' : c.Rel i j') :
kernelSubobject (C.d i j) = kernelSubobject (C.d i j') := by
rw [← d_comp_eqToHom C r r']
apply kernelSubobject_comp_mono
#align homological_complex.kernel_eq_kernel HomologicalComplex.kernel_eq_kernel
theorem image_eq_image [HasImages V] [HasEqualizers V] {i i' j : ι} (r : c.Rel i j)
(r' : c.Rel i' j) : imageSubobject (C.d i j) = imageSubobject (C.d i' j) := by
rw [← eqToHom_comp_d C r r']
apply imageSubobject_iso_comp
#align homological_complex.image_eq_image HomologicalComplex.image_eq_image
section
/-- Either `C.X i`, if there is some `i` with `c.Rel i j`, or `C.X j`. -/
abbrev xPrev (j : ι) : V :=
C.X (c.prev j)
set_option linter.uppercaseLean3 false in
#align homological_complex.X_prev HomologicalComplex.xPrev
/-- If `c.Rel i j`, then `C.xPrev j` is isomorphic to `C.X i`. -/
def xPrevIso {i j : ι} (r : c.Rel i j) : C.xPrev j ≅ C.X i :=
eqToIso <| by rw [← c.prev_eq' r]
set_option linter.uppercaseLean3 false in
#align homological_complex.X_prev_iso HomologicalComplex.xPrevIso
/-- If there is no `i` so `c.Rel i j`, then `C.xPrev j` is isomorphic to `C.X j`. -/
def xPrevIsoSelf {j : ι} (h : ¬c.Rel (c.prev j) j) : C.xPrev j ≅ C.X j :=
eqToIso <|
congr_arg C.X
(by
dsimp [ComplexShape.prev]
rw [dif_neg]
push_neg; intro i hi
have : c.prev j = i := c.prev_eq' hi
rw [this] at h; contradiction)
set_option linter.uppercaseLean3 false in
#align homological_complex.X_prev_iso_self HomologicalComplex.xPrevIsoSelf
/-- Either `C.X j`, if there is some `j` with `c.rel i j`, or `C.X i`. -/
abbrev xNext (i : ι) : V :=
C.X (c.next i)
set_option linter.uppercaseLean3 false in
#align homological_complex.X_next HomologicalComplex.xNext
/-- If `c.Rel i j`, then `C.xNext i` is isomorphic to `C.X j`. -/
def xNextIso {i j : ι} (r : c.Rel i j) : C.xNext i ≅ C.X j :=
eqToIso <| by rw [← c.next_eq' r]
set_option linter.uppercaseLean3 false in
#align homological_complex.X_next_iso HomologicalComplex.xNextIso
/-- If there is no `j` so `c.Rel i j`, then `C.xNext i` is isomorphic to `C.X i`. -/
def xNextIsoSelf {i : ι} (h : ¬c.Rel i (c.next i)) : C.xNext i ≅ C.X i :=
eqToIso <|
congr_arg C.X
(by
dsimp [ComplexShape.next]
rw [dif_neg]; rintro ⟨j, hj⟩
have : c.next i = j := c.next_eq' hj
rw [this] at h; contradiction)
set_option linter.uppercaseLean3 false in
#align homological_complex.X_next_iso_self HomologicalComplex.xNextIsoSelf
/-- The differential mapping into `C.X j`, or zero if there isn't one.
-/
abbrev dTo (j : ι) : C.xPrev j ⟶ C.X j :=
C.d (c.prev j) j
#align homological_complex.d_to HomologicalComplex.dTo
/-- The differential mapping out of `C.X i`, or zero if there isn't one.
-/
abbrev dFrom (i : ι) : C.X i ⟶ C.xNext i :=
C.d i (c.next i)
#align homological_complex.d_from HomologicalComplex.dFrom
theorem dTo_eq {i j : ι} (r : c.Rel i j) : C.dTo j = (C.xPrevIso r).hom ≫ C.d i j := by
obtain rfl := c.prev_eq' r
exact (Category.id_comp _).symm
#align homological_complex.d_to_eq HomologicalComplex.dTo_eq
@[simp]
theorem dTo_eq_zero {j : ι} (h : ¬c.Rel (c.prev j) j) : C.dTo j = 0 :=
C.shape _ _ h
#align homological_complex.d_to_eq_zero HomologicalComplex.dTo_eq_zero
theorem dFrom_eq {i j : ι} (r : c.Rel i j) : C.dFrom i = C.d i j ≫ (C.xNextIso r).inv := by
obtain rfl := c.next_eq' r
exact (Category.comp_id _).symm
#align homological_complex.d_from_eq HomologicalComplex.dFrom_eq
@[simp]
theorem dFrom_eq_zero {i : ι} (h : ¬c.Rel i (c.next i)) : C.dFrom i = 0 :=
C.shape _ _ h
#align homological_complex.d_from_eq_zero HomologicalComplex.dFrom_eq_zero
@[reassoc (attr := simp)]
theorem xPrevIso_comp_dTo {i j : ι} (r : c.Rel i j) : (C.xPrevIso r).inv ≫ C.dTo j = C.d i j := by
simp [C.dTo_eq r]
set_option linter.uppercaseLean3 false in
#align homological_complex.X_prev_iso_comp_d_to HomologicalComplex.xPrevIso_comp_dTo
@[reassoc (attr := simp)]
theorem xPrevIsoSelf_comp_dTo {j : ι} (h : ¬c.Rel (c.prev j) j) :
(C.xPrevIsoSelf h).inv ≫ C.dTo j = 0 := by simp [h]
set_option linter.uppercaseLean3 false in
#align homological_complex.X_prev_iso_self_comp_d_to HomologicalComplex.xPrevIsoSelf_comp_dTo
@[reassoc (attr := simp)]
theorem dFrom_comp_xNextIso {i j : ι} (r : c.Rel i j) :
C.dFrom i ≫ (C.xNextIso r).hom = C.d i j := by
simp [C.dFrom_eq r]
set_option linter.uppercaseLean3 false in
#align homological_complex.d_from_comp_X_next_iso HomologicalComplex.dFrom_comp_xNextIso
@[reassoc (attr := simp)]
theorem dFrom_comp_xNextIsoSelf {i : ι} (h : ¬c.Rel i (c.next i)) :
C.dFrom i ≫ (C.xNextIsoSelf h).hom = 0 := by simp [h]
set_option linter.uppercaseLean3 false in
#align homological_complex.d_from_comp_X_next_iso_self HomologicalComplex.dFrom_comp_xNextIsoSelf
@[simp 1100]
theorem dTo_comp_dFrom (j : ι) : C.dTo j ≫ C.dFrom j = 0 :=
C.d_comp_d _ _ _
#align homological_complex.d_to_comp_d_from HomologicalComplex.dTo_comp_dFrom
theorem kernel_from_eq_kernel [HasKernels V] {i j : ι} (r : c.Rel i j) :
kernelSubobject (C.dFrom i) = kernelSubobject (C.d i j) := by
rw [C.dFrom_eq r]
apply kernelSubobject_comp_mono
#align homological_complex.kernel_from_eq_kernel HomologicalComplex.kernel_from_eq_kernel
theorem image_to_eq_image [HasImages V] [HasEqualizers V] {i j : ι} (r : c.Rel i j) :
imageSubobject (C.dTo j) = imageSubobject (C.d i j) := by
rw [C.dTo_eq r]
apply imageSubobject_iso_comp
#align homological_complex.image_to_eq_image HomologicalComplex.image_to_eq_image
end
namespace Hom
variable {C₁ C₂ C₃ : HomologicalComplex V c}
/-- The `i`-th component of an isomorphism of chain complexes. -/
@[simps!]
def isoApp (f : C₁ ≅ C₂) (i : ι) : C₁.X i ≅ C₂.X i :=
(eval V c i).mapIso f
#align homological_complex.hom.iso_app HomologicalComplex.Hom.isoApp
/-- Construct an isomorphism of chain complexes from isomorphism of the objects
which commute with the differentials. -/
@[simps]
def isoOfComponents (f : ∀ i, C₁.X i ≅ C₂.X i)
(hf : ∀ i j, c.Rel i j → (f i).hom ≫ C₂.d i j = C₁.d i j ≫ (f j).hom := by aesop_cat) :
C₁ ≅ C₂ where
hom :=
{ f := fun i => (f i).hom
comm' := hf }
inv :=
{ f := fun i => (f i).inv
comm' := fun i j hij =>
calc
(f i).inv ≫ C₁.d i j = (f i).inv ≫ (C₁.d i j ≫ (f j).hom) ≫ (f j).inv := by simp
_ = (f i).inv ≫ ((f i).hom ≫ C₂.d i j) ≫ (f j).inv := by rw [hf i j hij]
_ = C₂.d i j ≫ (f j).inv := by simp }
hom_inv_id := by
ext i
exact (f i).hom_inv_id
inv_hom_id := by
ext i
exact (f i).inv_hom_id
#align homological_complex.hom.iso_of_components HomologicalComplex.Hom.isoOfComponents
@[simp]
theorem isoOfComponents_app (f : ∀ i, C₁.X i ≅ C₂.X i)
(hf : ∀ i j, c.Rel i j → (f i).hom ≫ C₂.d i j = C₁.d i j ≫ (f j).hom) (i : ι) :
isoApp (isoOfComponents f hf) i = f i := by
ext
simp
#align homological_complex.hom.iso_of_components_app HomologicalComplex.Hom.isoOfComponents_app
theorem isIso_of_components (f : C₁ ⟶ C₂) [∀ n : ι, IsIso (f.f n)] : IsIso f :=
(HomologicalComplex.Hom.isoOfComponents fun n => asIso (f.f n)).isIso_hom
#align homological_complex.hom.is_iso_of_components HomologicalComplex.Hom.isIso_of_components
/-! Lemmas relating chain maps and `dTo`/`dFrom`. -/
/-- `f.prev j` is `f.f i` if there is some `r i j`, and `f.f j` otherwise. -/
abbrev prev (f : Hom C₁ C₂) (j : ι) : C₁.xPrev j ⟶ C₂.xPrev j :=
f.f _
#align homological_complex.hom.prev HomologicalComplex.Hom.prev
theorem prev_eq (f : Hom C₁ C₂) {i j : ι} (w : c.Rel i j) :
f.prev j = (C₁.xPrevIso w).hom ≫ f.f i ≫ (C₂.xPrevIso w).inv := by
obtain rfl := c.prev_eq' w
simp only [xPrevIso, eqToIso_refl, Iso.refl_hom, Iso.refl_inv, comp_id, id_comp]
#align homological_complex.hom.prev_eq HomologicalComplex.Hom.prev_eq
/-- `f.next i` is `f.f j` if there is some `r i j`, and `f.f j` otherwise. -/
abbrev next (f : Hom C₁ C₂) (i : ι) : C₁.xNext i ⟶ C₂.xNext i :=
f.f _
#align homological_complex.hom.next HomologicalComplex.Hom.next
theorem next_eq (f : Hom C₁ C₂) {i j : ι} (w : c.Rel i j) :
f.next i = (C₁.xNextIso w).hom ≫ f.f j ≫ (C₂.xNextIso w).inv := by
obtain rfl := c.next_eq' w
simp only [xNextIso, eqToIso_refl, Iso.refl_hom, Iso.refl_inv, comp_id, id_comp]
#align homological_complex.hom.next_eq HomologicalComplex.Hom.next_eq
@[reassoc, elementwise] -- @[simp] -- Porting note (#10618): simp can prove this
theorem comm_from (f : Hom C₁ C₂) (i : ι) : f.f i ≫ C₂.dFrom i = C₁.dFrom i ≫ f.next i :=
f.comm _ _
#align homological_complex.hom.comm_from HomologicalComplex.Hom.comm_from
attribute [simp 1100] comm_from_assoc
attribute [simp] comm_from_apply
@[reassoc, elementwise] -- @[simp] -- Porting note (#10618): simp can prove this
theorem comm_to (f : Hom C₁ C₂) (j : ι) : f.prev j ≫ C₂.dTo j = C₁.dTo j ≫ f.f j :=
f.comm _ _
#align homological_complex.hom.comm_to HomologicalComplex.Hom.comm_to
attribute [simp 1100] comm_to_assoc
attribute [simp] comm_to_apply
/-- A morphism of chain complexes
induces a morphism of arrows of the differentials out of each object.
-/
def sqFrom (f : Hom C₁ C₂) (i : ι) : Arrow.mk (C₁.dFrom i) ⟶ Arrow.mk (C₂.dFrom i) :=
Arrow.homMk (f.comm_from i)
#align homological_complex.hom.sq_from HomologicalComplex.Hom.sqFrom
@[simp]
theorem sqFrom_left (f : Hom C₁ C₂) (i : ι) : (f.sqFrom i).left = f.f i :=
rfl
#align homological_complex.hom.sq_from_left HomologicalComplex.Hom.sqFrom_left
@[simp]
theorem sqFrom_right (f : Hom C₁ C₂) (i : ι) : (f.sqFrom i).right = f.next i :=
rfl
#align homological_complex.hom.sq_from_right HomologicalComplex.Hom.sqFrom_right
@[simp]
theorem sqFrom_id (C₁ : HomologicalComplex V c) (i : ι) : sqFrom (𝟙 C₁) i = 𝟙 _ :=
rfl
#align homological_complex.hom.sq_from_id HomologicalComplex.Hom.sqFrom_id
@[simp]
theorem sqFrom_comp (f : C₁ ⟶ C₂) (g : C₂ ⟶ C₃) (i : ι) :
sqFrom (f ≫ g) i = sqFrom f i ≫ sqFrom g i :=
rfl
#align homological_complex.hom.sq_from_comp HomologicalComplex.Hom.sqFrom_comp
/-- A morphism of chain complexes
induces a morphism of arrows of the differentials into each object.
-/
def sqTo (f : Hom C₁ C₂) (j : ι) : Arrow.mk (C₁.dTo j) ⟶ Arrow.mk (C₂.dTo j) :=
Arrow.homMk (f.comm_to j)
#align homological_complex.hom.sq_to HomologicalComplex.Hom.sqTo
@[simp]
theorem sqTo_left (f : Hom C₁ C₂) (j : ι) : (f.sqTo j).left = f.prev j :=
rfl
#align homological_complex.hom.sq_to_left HomologicalComplex.Hom.sqTo_left
@[simp]
theorem sqTo_right (f : Hom C₁ C₂) (j : ι) : (f.sqTo j).right = f.f j :=
rfl
#align homological_complex.hom.sq_to_right HomologicalComplex.Hom.sqTo_right
end Hom
end
end HomologicalComplex
namespace ChainComplex
section Of
variable {V} {α : Type*} [AddRightCancelSemigroup α] [One α] [DecidableEq α]
/-- Construct an `α`-indexed chain complex from a dependently-typed differential.
-/
def of (X : α → V) (d : ∀ n, X (n + 1) ⟶ X n) (sq : ∀ n, d (n + 1) ≫ d n = 0) : ChainComplex V α :=
{ X := X
d := fun i j => if h : i = j + 1 then eqToHom (by rw [h]) ≫ d j else 0
shape := fun i j w => by
dsimp
rw [dif_neg (Ne.symm w)]
d_comp_d' := fun i j k hij hjk => by
dsimp at hij hjk
substs hij hjk
simp only [eqToHom_refl, id_comp, dite_eq_ite, ite_true, sq] }
#align chain_complex.of ChainComplex.of
variable (X : α → V) (d : ∀ n, X (n + 1) ⟶ X n) (sq : ∀ n, d (n + 1) ≫ d n = 0)
@[simp]
theorem of_x (n : α) : (of X d sq).X n = X n :=
rfl
set_option linter.uppercaseLean3 false in
#align chain_complex.of_X ChainComplex.of_x
@[simp]
theorem of_d (j : α) : (of X d sq).d (j + 1) j = d j := by
dsimp [of]
rw [if_pos rfl, Category.id_comp]
#align chain_complex.of_d ChainComplex.of_d
theorem of_d_ne {i j : α} (h : i ≠ j + 1) : (of X d sq).d i j = 0 := by
dsimp [of]
rw [dif_neg h]
#align chain_complex.of_d_ne ChainComplex.of_d_ne
end Of
section OfHom
variable {V} {α : Type*} [AddRightCancelSemigroup α] [One α] [DecidableEq α]
variable (X : α → V) (d_X : ∀ n, X (n + 1) ⟶ X n) (sq_X : ∀ n, d_X (n + 1) ≫ d_X n = 0) (Y : α → V)
(d_Y : ∀ n, Y (n + 1) ⟶ Y n) (sq_Y : ∀ n, d_Y (n + 1) ≫ d_Y n = 0)
/-- A constructor for chain maps between `α`-indexed chain complexes built using `ChainComplex.of`,
from a dependently typed collection of morphisms.
-/
@[simps]
def ofHom (f : ∀ i : α, X i ⟶ Y i) (comm : ∀ i : α, f (i + 1) ≫ d_Y i = d_X i ≫ f i) :
of X d_X sq_X ⟶ of Y d_Y sq_Y :=
{ f
comm' := fun n m => by
by_cases h : n = m + 1
· subst h
simpa using comm m
· rw [of_d_ne X _ _ h, of_d_ne Y _ _ h]
simp }
#align chain_complex.of_hom ChainComplex.ofHom
end OfHom
section Mk
variable {V}
variable (X₀ X₁ X₂ : V) (d₀ : X₁ ⟶ X₀) (d₁ : X₂ ⟶ X₁) (s : d₁ ≫ d₀ = 0)
(succ : ∀ (S : ShortComplex V), Σ' (X₃ : V) (d₂ : X₃ ⟶ S.X₁), d₂ ≫ S.f = 0)
/-- Auxiliary definition for `mk`. -/
def mkAux : ℕ → ShortComplex V
| 0 => ShortComplex.mk _ _ s
| n + 1 => ShortComplex.mk _ _ (succ (mkAux n)).2.2
#align chain_complex.mk_aux ChainComplex.mkAux
/-- An inductive constructor for `ℕ`-indexed chain complexes.
You provide explicitly the first two differentials,
then a function which takes two differentials and the fact they compose to zero,
and returns the next object, its differential, and the fact it composes appropriately to zero.
See also `mk'`, which only sees the previous differential in the inductive step.
-/
def mk : ChainComplex V ℕ :=
of (fun n => (mkAux X₀ X₁ X₂ d₀ d₁ s succ n).X₃) (fun n => (mkAux X₀ X₁ X₂ d₀ d₁ s succ n).g)
fun n => (mkAux X₀ X₁ X₂ d₀ d₁ s succ n).zero
#align chain_complex.mk ChainComplex.mk
@[simp]
theorem mk_X_0 : (mk X₀ X₁ X₂ d₀ d₁ s succ).X 0 = X₀ :=
rfl
set_option linter.uppercaseLean3 false in
#align chain_complex.mk_X_0 ChainComplex.mk_X_0
@[simp]
theorem mk_X_1 : (mk X₀ X₁ X₂ d₀ d₁ s succ).X 1 = X₁ :=
rfl
set_option linter.uppercaseLean3 false in
#align chain_complex.mk_X_1 ChainComplex.mk_X_1
@[simp]
theorem mk_X_2 : (mk X₀ X₁ X₂ d₀ d₁ s succ).X 2 = X₂ :=
rfl
set_option linter.uppercaseLean3 false in
#align chain_complex.mk_X_2 ChainComplex.mk_X_2
@[simp]
theorem mk_d_1_0 : (mk X₀ X₁ X₂ d₀ d₁ s succ).d 1 0 = d₀ := by
change ite (1 = 0 + 1) (𝟙 X₁ ≫ d₀) 0 = d₀
rw [if_pos rfl, Category.id_comp]
#align chain_complex.mk_d_1_0 ChainComplex.mk_d_1_0
@[simp]
| Mathlib/Algebra/Homology/HomologicalComplex.lean | 804 | 806 | theorem mk_d_2_1 : (mk X₀ X₁ X₂ d₀ d₁ s succ).d 2 1 = d₁ := by |
change ite (2 = 1 + 1) (𝟙 X₂ ≫ d₁) 0 = d₁
rw [if_pos rfl, Category.id_comp]
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Michael Howes
-/
import Mathlib.Data.Finite.Card
import Mathlib.GroupTheory.Commutator
import Mathlib.GroupTheory.Finiteness
#align_import group_theory.abelianization from "leanprover-community/mathlib"@"4be589053caf347b899a494da75410deb55fb3ef"
/-!
# The abelianization of a group
This file defines the commutator and the abelianization of a group. It furthermore prepares for the
result that the abelianization is left adjoint to the forgetful functor from abelian groups to
groups, which can be found in `Algebra/Category/Group/Adjunctions`.
## Main definitions
* `commutator`: defines the commutator of a group `G` as a subgroup of `G`.
* `Abelianization`: defines the abelianization of a group `G` as the quotient of a group by its
commutator subgroup.
* `Abelianization.map`: lifts a group homomorphism to a homomorphism between the abelianizations
* `MulEquiv.abelianizationCongr`: Equivalent groups have equivalent abelianizations
-/
universe u v w
-- Let G be a group.
variable (G : Type u) [Group G]
open Subgroup (centralizer)
/-- The commutator subgroup of a group G is the normal subgroup
generated by the commutators [p,q]=`p*q*p⁻¹*q⁻¹`. -/
def commutator : Subgroup G := ⁅(⊤ : Subgroup G), ⊤⁆
#align commutator commutator
-- Porting note: this instance should come from `deriving Subgroup.Normal`
instance : Subgroup.Normal (commutator G) := Subgroup.commutator_normal ⊤ ⊤
theorem commutator_def : commutator G = ⁅(⊤ : Subgroup G), ⊤⁆ :=
rfl
#align commutator_def commutator_def
theorem commutator_eq_closure : commutator G = Subgroup.closure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def, commutatorSet]
#align commutator_eq_closure commutator_eq_closure
theorem commutator_eq_normalClosure : commutator G = Subgroup.normalClosure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def', commutatorSet]
#align commutator_eq_normal_closure commutator_eq_normalClosure
instance commutator_characteristic : (commutator G).Characteristic :=
Subgroup.commutator_characteristic ⊤ ⊤
#align commutator_characteristic commutator_characteristic
instance [Finite (commutatorSet G)] : Group.FG (commutator G) := by
rw [commutator_eq_closure]
apply Group.closure_finite_fg
theorem rank_commutator_le_card [Finite (commutatorSet G)] :
Group.rank (commutator G) ≤ Nat.card (commutatorSet G) := by
rw [Subgroup.rank_congr (commutator_eq_closure G)]
apply Subgroup.rank_closure_finite_le_nat_card
#align rank_commutator_le_card rank_commutator_le_card
theorem commutator_centralizer_commutator_le_center :
⁅centralizer (commutator G : Set G), centralizer (commutator G)⁆ ≤ Subgroup.center G := by
rw [← Subgroup.centralizer_univ, ← Subgroup.coe_top, ←
Subgroup.commutator_eq_bot_iff_le_centralizer]
suffices ⁅⁅⊤, centralizer (commutator G : Set G)⁆, centralizer (commutator G : Set G)⁆ = ⊥ by
refine Subgroup.commutator_commutator_eq_bot_of_rotate ?_ this
rwa [Subgroup.commutator_comm (centralizer (commutator G : Set G))]
rw [Subgroup.commutator_comm, Subgroup.commutator_eq_bot_iff_le_centralizer]
exact Set.centralizer_subset (Subgroup.commutator_mono le_top le_top)
#align commutator_centralizer_commutator_le_center commutator_centralizer_commutator_le_center
/-- The abelianization of G is the quotient of G by its commutator subgroup. -/
def Abelianization : Type u :=
G ⧸ commutator G
#align abelianization Abelianization
namespace Abelianization
attribute [local instance] QuotientGroup.leftRel
instance commGroup : CommGroup (Abelianization G) :=
{ QuotientGroup.Quotient.group _ with
mul_comm := fun x y =>
Quotient.inductionOn₂' x y fun a b =>
Quotient.sound' <|
QuotientGroup.leftRel_apply.mpr <|
Subgroup.subset_closure
⟨b⁻¹, Subgroup.mem_top b⁻¹, a⁻¹, Subgroup.mem_top a⁻¹, by group⟩ }
instance : Inhabited (Abelianization G) :=
⟨1⟩
instance [Unique G] : Unique (Abelianization G) := Quotient.instUniqueQuotient _
instance [Fintype G] [DecidablePred (· ∈ commutator G)] : Fintype (Abelianization G) :=
QuotientGroup.fintype (commutator G)
instance [Finite G] : Finite (Abelianization G) :=
Quotient.finite _
variable {G}
/-- `of` is the canonical projection from G to its abelianization. -/
def of : G →* Abelianization G where
toFun := QuotientGroup.mk
map_one' := rfl
map_mul' _ _ := rfl
#align abelianization.of Abelianization.of
@[simp]
theorem mk_eq_of (a : G) : Quot.mk _ a = of a :=
rfl
#align abelianization.mk_eq_of Abelianization.mk_eq_of
section lift
-- So far we have built Gᵃᵇ and proved it's an abelian group.
-- Furthermore we defined the canonical projection `of : G → Gᵃᵇ`
-- Let `A` be an abelian group and let `f` be a group homomorphism from `G` to `A`.
variable {A : Type v} [CommGroup A] (f : G →* A)
theorem commutator_subset_ker : commutator G ≤ f.ker := by
rw [commutator_eq_closure, Subgroup.closure_le]
rintro x ⟨p, q, rfl⟩
simp [MonoidHom.mem_ker, mul_right_comm (f p) (f q), commutatorElement_def]
#align abelianization.commutator_subset_ker Abelianization.commutator_subset_ker
/-- If `f : G → A` is a group homomorphism to an abelian group, then `lift f` is the unique map
from the abelianization of a `G` to `A` that factors through `f`. -/
def lift : (G →* A) ≃ (Abelianization G →* A) where
toFun f := QuotientGroup.lift _ f fun _ h => f.mem_ker.2 <| commutator_subset_ker _ h
invFun F := F.comp of
left_inv _ := MonoidHom.ext fun _ => rfl
right_inv _ := MonoidHom.ext fun x => QuotientGroup.induction_on x fun _ => rfl
#align abelianization.lift Abelianization.lift
@[simp]
theorem lift.of (x : G) : lift f (of x) = f x :=
rfl
#align abelianization.lift.of Abelianization.lift.of
theorem lift.unique (φ : Abelianization G →* A)
-- hφ : φ agrees with f on the image of G in Gᵃᵇ
(hφ : ∀ x : G, φ (Abelianization.of x) = f x)
{x : Abelianization G} : φ x = lift f x :=
QuotientGroup.induction_on x hφ
#align abelianization.lift.unique Abelianization.lift.unique
@[simp]
theorem lift_of : lift of = MonoidHom.id (Abelianization G) :=
lift.apply_symm_apply <| MonoidHom.id _
#align abelianization.lift_of Abelianization.lift_of
end lift
variable {A : Type v} [Monoid A]
/-- See note [partially-applied ext lemmas]. -/
@[ext]
theorem hom_ext (φ ψ : Abelianization G →* A) (h : φ.comp of = ψ.comp of) : φ = ψ :=
MonoidHom.ext fun x => QuotientGroup.induction_on x <| DFunLike.congr_fun h
#align abelianization.hom_ext Abelianization.hom_ext
section Map
variable {H : Type v} [Group H] (f : G →* H)
/-- The map operation of the `Abelianization` functor -/
def map : Abelianization G →* Abelianization H :=
lift (of.comp f)
#align abelianization.map Abelianization.map
/-- Use `map` as the preferred simp normal form. -/
@[simp] theorem lift_of_comp :
Abelianization.lift (Abelianization.of.comp f) = Abelianization.map f := rfl
@[simp]
theorem map_of (x : G) : map f (of x) = of (f x) :=
rfl
#align abelianization.map_of Abelianization.map_of
@[simp]
theorem map_id : map (MonoidHom.id G) = MonoidHom.id (Abelianization G) :=
hom_ext _ _ rfl
#align abelianization.map_id Abelianization.map_id
@[simp]
theorem map_comp {I : Type w} [Group I] (g : H →* I) : (map g).comp (map f) = map (g.comp f) :=
hom_ext _ _ rfl
#align abelianization.map_comp Abelianization.map_comp
@[simp]
theorem map_map_apply {I : Type w} [Group I] {g : H →* I} {x : Abelianization G} :
map g (map f x) = map (g.comp f) x :=
DFunLike.congr_fun (map_comp _ _) x
#align abelianization.map_map_apply Abelianization.map_map_apply
end Map
end Abelianization
section AbelianizationCongr
-- Porting note: `[Group G]` should not be necessary here
variable {G} [Group G] {H : Type v} [Group H] (e : G ≃* H)
/-- Equivalent groups have equivalent abelianizations -/
def MulEquiv.abelianizationCongr : Abelianization G ≃* Abelianization H where
toFun := Abelianization.map e.toMonoidHom
invFun := Abelianization.map e.symm.toMonoidHom
left_inv := by
rintro ⟨a⟩
simp
right_inv := by
rintro ⟨a⟩
simp
map_mul' := MonoidHom.map_mul _
#align mul_equiv.abelianization_congr MulEquiv.abelianizationCongr
@[simp]
theorem abelianizationCongr_of (x : G) :
e.abelianizationCongr (Abelianization.of x) = Abelianization.of (e x) :=
rfl
#align abelianization_congr_of abelianizationCongr_of
@[simp]
theorem abelianizationCongr_refl :
(MulEquiv.refl G).abelianizationCongr = MulEquiv.refl (Abelianization G) :=
MulEquiv.toMonoidHom_injective Abelianization.lift_of
#align abelianization_congr_refl abelianizationCongr_refl
@[simp]
theorem abelianizationCongr_symm : e.abelianizationCongr.symm = e.symm.abelianizationCongr :=
rfl
#align abelianization_congr_symm abelianizationCongr_symm
@[simp]
theorem abelianizationCongr_trans {I : Type v} [Group I] (e₂ : H ≃* I) :
e.abelianizationCongr.trans e₂.abelianizationCongr = (e.trans e₂).abelianizationCongr :=
MulEquiv.toMonoidHom_injective (Abelianization.hom_ext _ _ rfl)
#align abelianization_congr_trans abelianizationCongr_trans
end AbelianizationCongr
/-- An Abelian group is equivalent to its own abelianization. -/
@[simps]
def Abelianization.equivOfComm {H : Type*} [CommGroup H] : H ≃* Abelianization H :=
{ Abelianization.of with
toFun := Abelianization.of
invFun := Abelianization.lift (MonoidHom.id H)
left_inv := fun a => rfl
right_inv := by
rintro ⟨a⟩
rfl }
#align abelianization.equiv_of_comm Abelianization.equivOfComm
section commutatorRepresentatives
open Subgroup
/-- Representatives `(g₁, g₂) : G × G` of commutators `⁅g₁, g₂⁆ ∈ G`. -/
def commutatorRepresentatives : Set (G × G) :=
Set.range fun g : commutatorSet G => (g.2.choose, g.2.choose_spec.choose)
#align commutator_representatives commutatorRepresentatives
instance [Finite (commutatorSet G)] : Finite (commutatorRepresentatives G) :=
Set.finite_coe_iff.mpr (Set.finite_range _)
/-- Subgroup generated by representatives `g₁ g₂ : G` of commutators `⁅g₁, g₂⁆ ∈ G`. -/
def closureCommutatorRepresentatives : Subgroup G :=
closure (Prod.fst '' commutatorRepresentatives G ∪ Prod.snd '' commutatorRepresentatives G)
#align closure_commutator_representatives closureCommutatorRepresentatives
instance closureCommutatorRepresentatives_fg [Finite (commutatorSet G)] :
Group.FG (closureCommutatorRepresentatives G) :=
Group.closure_finite_fg _
#align closure_commutator_representatives_fg closureCommutatorRepresentatives_fg
theorem rank_closureCommutatorRepresentatives_le [Finite (commutatorSet G)] :
Group.rank (closureCommutatorRepresentatives G) ≤ 2 * Nat.card (commutatorSet G) := by
rw [two_mul]
exact
(Subgroup.rank_closure_finite_le_nat_card _).trans
((Set.card_union_le _ _).trans
(add_le_add ((Finite.card_image_le _).trans (Finite.card_range_le _))
((Finite.card_image_le _).trans (Finite.card_range_le _))))
#align rank_closure_commutator_representations_le rank_closureCommutatorRepresentatives_le
| Mathlib/GroupTheory/Abelianization.lean | 299 | 310 | theorem image_commutatorSet_closureCommutatorRepresentatives :
(closureCommutatorRepresentatives G).subtype ''
commutatorSet (closureCommutatorRepresentatives G) =
commutatorSet G := by |
apply Set.Subset.antisymm
· rintro - ⟨-, ⟨g₁, g₂, rfl⟩, rfl⟩
exact ⟨g₁, g₂, rfl⟩
· exact fun g hg =>
⟨_,
⟨⟨_, subset_closure (Or.inl ⟨_, ⟨⟨g, hg⟩, rfl⟩, rfl⟩)⟩,
⟨_, subset_closure (Or.inr ⟨_, ⟨⟨g, hg⟩, rfl⟩, rfl⟩)⟩, rfl⟩,
hg.choose_spec.choose_spec⟩
|
/-
Copyright (c) 2019 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Algebra.Ring.Int
import Mathlib.Data.ZMod.Basic
import Mathlib.FieldTheory.Finite.Basic
import Mathlib.Data.Fintype.BigOperators
#align_import number_theory.sum_four_squares from "leanprover-community/mathlib"@"bd9851ca476957ea4549eb19b40e7b5ade9428cc"
/-!
# Lagrange's four square theorem
The main result in this file is `sum_four_squares`,
a proof that every natural number is the sum of four square numbers.
## Implementation Notes
The proof used is close to Lagrange's original proof.
-/
open Finset Polynomial FiniteField Equiv
/-- **Euler's four-square identity**. -/
theorem euler_four_squares {R : Type*} [CommRing R] (a b c d x y z w : R) :
(a * x - b * y - c * z - d * w) ^ 2 + (a * y + b * x + c * w - d * z) ^ 2 +
(a * z - b * w + c * x + d * y) ^ 2 + (a * w + b * z - c * y + d * x) ^ 2 =
(a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2) := by ring
/-- **Euler's four-square identity**, a version for natural numbers. -/
theorem Nat.euler_four_squares (a b c d x y z w : ℕ) :
((a : ℤ) * x - b * y - c * z - d * w).natAbs ^ 2 +
((a : ℤ) * y + b * x + c * w - d * z).natAbs ^ 2 +
((a : ℤ) * z - b * w + c * x + d * y).natAbs ^ 2 +
((a : ℤ) * w + b * z - c * y + d * x).natAbs ^ 2 =
(a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2) * (x ^ 2 + y ^ 2 + z ^ 2 + w ^ 2) := by
rw [← Int.natCast_inj]
push_cast
simp only [sq_abs, _root_.euler_four_squares]
namespace Int
theorem sq_add_sq_of_two_mul_sq_add_sq {m x y : ℤ} (h : 2 * m = x ^ 2 + y ^ 2) :
m = ((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2 :=
have : Even (x ^ 2 + y ^ 2) := by simp [← h, even_mul]
have hxaddy : Even (x + y) := by simpa [sq, parity_simps]
have hxsuby : Even (x - y) := by simpa [sq, parity_simps]
mul_right_injective₀ (show (2 * 2 : ℤ) ≠ 0 by decide) <|
calc
2 * 2 * m = (x - y) ^ 2 + (x + y) ^ 2 := by rw [mul_assoc, h]; ring
_ = (2 * ((x - y) / 2)) ^ 2 + (2 * ((x + y) / 2)) ^ 2 := by
rw [even_iff_two_dvd] at hxsuby hxaddy
rw [Int.mul_ediv_cancel' hxsuby, Int.mul_ediv_cancel' hxaddy]
_ = 2 * 2 * (((x - y) / 2) ^ 2 + ((x + y) / 2) ^ 2) := by
set_option simprocs false in
simp [mul_add, pow_succ, mul_comm, mul_assoc, mul_left_comm]
#align int.sq_add_sq_of_two_mul_sq_add_sq Int.sq_add_sq_of_two_mul_sq_add_sq
-- Porting note (#10756): new theorem
theorem lt_of_sum_four_squares_eq_mul {a b c d k m : ℕ}
(h : a ^ 2 + b ^ 2 + c ^ 2 + d ^ 2 = k * m)
(ha : 2 * a < m) (hb : 2 * b < m) (hc : 2 * c < m) (hd : 2 * d < m) :
k < m := by
refine _root_.lt_of_mul_lt_mul_right
(_root_.lt_of_mul_lt_mul_left ?_ (zero_le (2 ^ 2))) (zero_le m)
calc
2 ^ 2 * (k * ↑m) = ∑ i : Fin 4, (2 * ![a, b, c, d] i) ^ 2 := by
simp [← h, Fin.sum_univ_succ, mul_add, mul_pow, add_assoc]
_ < ∑ _i : Fin 4, m ^ 2 := Finset.sum_lt_sum_of_nonempty Finset.univ_nonempty fun i _ ↦ by
refine pow_lt_pow_left ?_ (zero_le _) two_ne_zero
fin_cases i <;> assumption
_ = 2 ^ 2 * (m * m) := by simp; ring
-- Porting note (#10756): new theorem
| Mathlib/NumberTheory/SumFourSquares.lean | 78 | 96 | theorem exists_sq_add_sq_add_one_eq_mul (p : ℕ) [hp : Fact p.Prime] :
∃ (a b k : ℕ), 0 < k ∧ k < p ∧ a ^ 2 + b ^ 2 + 1 = k * p := by |
rcases hp.1.eq_two_or_odd' with (rfl | hodd)
· use 1, 0, 1; simp
rcases Nat.sq_add_sq_zmodEq p (-1) with ⟨a, b, ha, hb, hab⟩
rcases Int.modEq_iff_dvd.1 hab.symm with ⟨k, hk⟩
rw [sub_neg_eq_add, mul_comm] at hk
have hk₀ : 0 < k := by
refine pos_of_mul_pos_left ?_ (Nat.cast_nonneg p)
rw [← hk]
positivity
lift k to ℕ using hk₀.le
refine ⟨a, b, k, Nat.cast_pos.1 hk₀, ?_, mod_cast hk⟩
replace hk : a ^ 2 + b ^ 2 + 1 ^ 2 + 0 ^ 2 = k * p := mod_cast hk
refine lt_of_sum_four_squares_eq_mul hk ?_ ?_ ?_ ?_
· exact (mul_le_mul' le_rfl ha).trans_lt (Nat.mul_div_lt_iff_not_dvd.2 hodd.not_two_dvd_nat)
· exact (mul_le_mul' le_rfl hb).trans_lt (Nat.mul_div_lt_iff_not_dvd.2 hodd.not_two_dvd_nat)
· exact lt_of_le_of_ne hp.1.two_le (hodd.ne_two_of_dvd_nat (dvd_refl _)).symm
· exact hp.1.pos
|
/-
Copyright (c) 2021 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash, Eric Wieser
-/
import Mathlib.Topology.Algebra.InfiniteSum.Basic
import Mathlib.Topology.Algebra.Ring.Basic
import Mathlib.Topology.Algebra.Star
import Mathlib.LinearAlgebra.Matrix.NonsingularInverse
import Mathlib.LinearAlgebra.Matrix.Trace
#align_import topology.instances.matrix from "leanprover-community/mathlib"@"3e068ece210655b7b9a9477c3aff38a492400aa1"
/-!
# Topological properties of matrices
This file is a place to collect topological results about matrices.
## Main definitions:
* `Matrix.topologicalRing`: square matrices form a topological ring
## Main results
* Continuity:
* `Continuous.matrix_det`: the determinant is continuous over a topological ring.
* `Continuous.matrix_adjugate`: the adjugate is continuous over a topological ring.
* Infinite sums
* `Matrix.transpose_tsum`: transpose commutes with infinite sums
* `Matrix.diagonal_tsum`: diagonal commutes with infinite sums
* `Matrix.blockDiagonal_tsum`: block diagonal commutes with infinite sums
* `Matrix.blockDiagonal'_tsum`: non-uniform block diagonal commutes with infinite sums
-/
open Matrix
variable {X α l m n p S R : Type*} {m' n' : l → Type*}
instance [TopologicalSpace R] : TopologicalSpace (Matrix m n R) :=
Pi.topologicalSpace
instance [TopologicalSpace R] [T2Space R] : T2Space (Matrix m n R) :=
Pi.t2Space
/-! ### Lemmas about continuity of operations -/
section Continuity
variable [TopologicalSpace X] [TopologicalSpace R]
instance [SMul α R] [ContinuousConstSMul α R] : ContinuousConstSMul α (Matrix m n R) :=
inferInstanceAs (ContinuousConstSMul α (m → n → R))
instance [TopologicalSpace α] [SMul α R] [ContinuousSMul α R] : ContinuousSMul α (Matrix m n R) :=
inferInstanceAs (ContinuousSMul α (m → n → R))
instance [Add R] [ContinuousAdd R] : ContinuousAdd (Matrix m n R) :=
Pi.continuousAdd
instance [Neg R] [ContinuousNeg R] : ContinuousNeg (Matrix m n R) :=
Pi.continuousNeg
instance [AddGroup R] [TopologicalAddGroup R] : TopologicalAddGroup (Matrix m n R) :=
Pi.topologicalAddGroup
/-- To show a function into matrices is continuous it suffices to show the coefficients of the
resulting matrix are continuous -/
@[continuity]
theorem continuous_matrix [TopologicalSpace α] {f : α → Matrix m n R}
(h : ∀ i j, Continuous fun a => f a i j) : Continuous f :=
continuous_pi fun _ => continuous_pi fun _ => h _ _
#align continuous_matrix continuous_matrix
theorem Continuous.matrix_elem {A : X → Matrix m n R} (hA : Continuous A) (i : m) (j : n) :
Continuous fun x => A x i j :=
(continuous_apply_apply i j).comp hA
#align continuous.matrix_elem Continuous.matrix_elem
@[continuity]
theorem Continuous.matrix_map [TopologicalSpace S] {A : X → Matrix m n S} {f : S → R}
(hA : Continuous A) (hf : Continuous f) : Continuous fun x => (A x).map f :=
continuous_matrix fun _ _ => hf.comp <| hA.matrix_elem _ _
#align continuous.matrix_map Continuous.matrix_map
@[continuity]
theorem Continuous.matrix_transpose {A : X → Matrix m n R} (hA : Continuous A) :
Continuous fun x => (A x)ᵀ :=
continuous_matrix fun i j => hA.matrix_elem j i
#align continuous.matrix_transpose Continuous.matrix_transpose
theorem Continuous.matrix_conjTranspose [Star R] [ContinuousStar R] {A : X → Matrix m n R}
(hA : Continuous A) : Continuous fun x => (A x)ᴴ :=
hA.matrix_transpose.matrix_map continuous_star
#align continuous.matrix_conj_transpose Continuous.matrix_conjTranspose
instance [Star R] [ContinuousStar R] : ContinuousStar (Matrix m m R) :=
⟨continuous_id.matrix_conjTranspose⟩
@[continuity]
theorem Continuous.matrix_col {A : X → n → R} (hA : Continuous A) : Continuous fun x => col (A x) :=
continuous_matrix fun i _ => (continuous_apply i).comp hA
#align continuous.matrix_col Continuous.matrix_col
@[continuity]
theorem Continuous.matrix_row {A : X → n → R} (hA : Continuous A) : Continuous fun x => row (A x) :=
continuous_matrix fun _ _ => (continuous_apply _).comp hA
#align continuous.matrix_row Continuous.matrix_row
@[continuity]
theorem Continuous.matrix_diagonal [Zero R] [DecidableEq n] {A : X → n → R} (hA : Continuous A) :
Continuous fun x => diagonal (A x) :=
continuous_matrix fun i _ => ((continuous_apply i).comp hA).if_const _ continuous_zero
#align continuous.matrix_diagonal Continuous.matrix_diagonal
@[continuity]
theorem Continuous.matrix_dotProduct [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R]
[ContinuousMul R] {A : X → n → R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) :
Continuous fun x => dotProduct (A x) (B x) :=
continuous_finset_sum _ fun i _ =>
((continuous_apply i).comp hA).mul ((continuous_apply i).comp hB)
#align continuous.matrix_dot_product Continuous.matrix_dotProduct
/-- For square matrices the usual `continuous_mul` can be used. -/
@[continuity]
theorem Continuous.matrix_mul [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R]
[ContinuousMul R] {A : X → Matrix m n R} {B : X → Matrix n p R} (hA : Continuous A)
(hB : Continuous B) : Continuous fun x => A x * B x :=
continuous_matrix fun _ _ =>
continuous_finset_sum _ fun _ _ => (hA.matrix_elem _ _).mul (hB.matrix_elem _ _)
#align continuous.matrix_mul Continuous.matrix_mul
instance [Fintype n] [Mul R] [AddCommMonoid R] [ContinuousAdd R] [ContinuousMul R] :
ContinuousMul (Matrix n n R) :=
⟨continuous_fst.matrix_mul continuous_snd⟩
instance [Fintype n] [NonUnitalNonAssocSemiring R] [TopologicalSemiring R] :
TopologicalSemiring (Matrix n n R) where
instance Matrix.topologicalRing [Fintype n] [NonUnitalNonAssocRing R] [TopologicalRing R] :
TopologicalRing (Matrix n n R) where
#align matrix.topological_ring Matrix.topologicalRing
@[continuity]
theorem Continuous.matrix_vecMulVec [Mul R] [ContinuousMul R] {A : X → m → R} {B : X → n → R}
(hA : Continuous A) (hB : Continuous B) : Continuous fun x => vecMulVec (A x) (B x) :=
continuous_matrix fun _ _ => ((continuous_apply _).comp hA).mul ((continuous_apply _).comp hB)
#align continuous.matrix_vec_mul_vec Continuous.matrix_vecMulVec
@[continuity]
theorem Continuous.matrix_mulVec [NonUnitalNonAssocSemiring R] [ContinuousAdd R] [ContinuousMul R]
[Fintype n] {A : X → Matrix m n R} {B : X → n → R} (hA : Continuous A) (hB : Continuous B) :
Continuous fun x => A x *ᵥ B x :=
continuous_pi fun i => ((continuous_apply i).comp hA).matrix_dotProduct hB
#align continuous.matrix_mul_vec Continuous.matrix_mulVec
@[continuity]
theorem Continuous.matrix_vecMul [NonUnitalNonAssocSemiring R] [ContinuousAdd R] [ContinuousMul R]
[Fintype m] {A : X → m → R} {B : X → Matrix m n R} (hA : Continuous A) (hB : Continuous B) :
Continuous fun x => A x ᵥ* B x :=
continuous_pi fun _i => hA.matrix_dotProduct <| continuous_pi fun _j => hB.matrix_elem _ _
#align continuous.matrix_vec_mul Continuous.matrix_vecMul
@[continuity]
theorem Continuous.matrix_submatrix {A : X → Matrix l n R} (hA : Continuous A) (e₁ : m → l)
(e₂ : p → n) : Continuous fun x => (A x).submatrix e₁ e₂ :=
continuous_matrix fun _i _j => hA.matrix_elem _ _
#align continuous.matrix_submatrix Continuous.matrix_submatrix
@[continuity]
theorem Continuous.matrix_reindex {A : X → Matrix l n R} (hA : Continuous A) (e₁ : l ≃ m)
(e₂ : n ≃ p) : Continuous fun x => reindex e₁ e₂ (A x) :=
hA.matrix_submatrix _ _
#align continuous.matrix_reindex Continuous.matrix_reindex
@[continuity]
theorem Continuous.matrix_diag {A : X → Matrix n n R} (hA : Continuous A) :
Continuous fun x => Matrix.diag (A x) :=
continuous_pi fun _ => hA.matrix_elem _ _
#align continuous.matrix_diag Continuous.matrix_diag
-- note this doesn't elaborate well from the above
theorem continuous_matrix_diag : Continuous (Matrix.diag : Matrix n n R → n → R) :=
show Continuous fun x : Matrix n n R => Matrix.diag x from continuous_id.matrix_diag
#align continuous_matrix_diag continuous_matrix_diag
@[continuity]
theorem Continuous.matrix_trace [Fintype n] [AddCommMonoid R] [ContinuousAdd R]
{A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => trace (A x) :=
continuous_finset_sum _ fun _ _ => hA.matrix_elem _ _
#align continuous.matrix_trace Continuous.matrix_trace
@[continuity]
| Mathlib/Topology/Instances/Matrix.lean | 194 | 198 | theorem Continuous.matrix_det [Fintype n] [DecidableEq n] [CommRing R] [TopologicalRing R]
{A : X → Matrix n n R} (hA : Continuous A) : Continuous fun x => (A x).det := by |
simp_rw [Matrix.det_apply]
refine continuous_finset_sum _ fun l _ => Continuous.const_smul ?_ _
exact continuous_finset_prod _ fun l _ => hA.matrix_elem _ _
|
/-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kenny Lau
-/
import Mathlib.Algebra.Polynomial.AlgebraMap
import Mathlib.Algebra.Polynomial.Basic
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.MvPowerSeries.Basic
#align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60"
/-!
# Formal power series (in one variable)
This file defines (univariate) formal power series
and develops the basic properties of these objects.
A formal power series is to a polynomial like an infinite sum is to a finite sum.
Formal power series in one variable are defined from multivariate
power series as `PowerSeries R := MvPowerSeries Unit R`.
The file sets up the (semi)ring structure on univariate power series.
We provide the natural inclusion from polynomials to formal power series.
Additional results can be found in:
* `Mathlib.RingTheory.PowerSeries.Trunc`, truncation of power series;
* `Mathlib.RingTheory.PowerSeries.Inverse`, about inverses of power series,
and the fact that power series over a local ring form a local ring;
* `Mathlib.RingTheory.PowerSeries.Order`, the order of a power series at 0,
and application to the fact that power series over an integral domain
form an integral domain.
## Implementation notes
Because of its definition,
`PowerSeries R := MvPowerSeries Unit R`.
a lot of proofs and properties from the multivariate case
can be ported to the single variable case.
However, it means that formal power series are indexed by `Unit →₀ ℕ`,
which is of course canonically isomorphic to `ℕ`.
We then build some glue to treat formal power series as if they were indexed by `ℕ`.
Occasionally this leads to proofs that are uglier than expected.
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
/-- Formal power series over a coefficient type `R` -/
def PowerSeries (R : Type*) :=
MvPowerSeries Unit R
#align power_series PowerSeries
namespace PowerSeries
open Finsupp (single)
variable {R : Type*}
section
-- Porting note: not available in Lean 4
-- local reducible PowerSeries
/--
`R⟦X⟧` is notation for `PowerSeries R`,
the semiring of formal power series in one variable over a semiring `R`.
-/
scoped notation:9000 R "⟦X⟧" => PowerSeries R
instance [Inhabited R] : Inhabited R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [Zero R] : Zero R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [AddMonoid R] : AddMonoid R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [AddGroup R] : AddGroup R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [AddCommMonoid R] : AddCommMonoid R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [AddCommGroup R] : AddCommGroup R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [Semiring R] : Semiring R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [CommSemiring R] : CommSemiring R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [Ring R] : Ring R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [CommRing R] : CommRing R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance [Nontrivial R] : Nontrivial R⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R A⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S]
[IsScalarTower R S A] : IsScalarTower R S A⟦X⟧ :=
Pi.isScalarTower
instance {A} [Semiring A] [CommSemiring R] [Algebra R A] : Algebra R A⟦X⟧ := by
dsimp only [PowerSeries]
infer_instance
end
section Semiring
variable (R) [Semiring R]
/-- The `n`th coefficient of a formal power series. -/
def coeff (n : ℕ) : R⟦X⟧ →ₗ[R] R :=
MvPowerSeries.coeff R (single () n)
#align power_series.coeff PowerSeries.coeff
/-- The `n`th monomial with coefficient `a` as formal power series. -/
def monomial (n : ℕ) : R →ₗ[R] R⟦X⟧ :=
MvPowerSeries.monomial R (single () n)
#align power_series.monomial PowerSeries.monomial
variable {R}
theorem coeff_def {s : Unit →₀ ℕ} {n : ℕ} (h : s () = n) : coeff R n = MvPowerSeries.coeff R s := by
erw [coeff, ← h, ← Finsupp.unique_single s]
#align power_series.coeff_def PowerSeries.coeff_def
/-- Two formal power series are equal if all their coefficients are equal. -/
@[ext]
theorem ext {φ ψ : R⟦X⟧} (h : ∀ n, coeff R n φ = coeff R n ψ) : φ = ψ :=
MvPowerSeries.ext fun n => by
rw [← coeff_def]
· apply h
rfl
#align power_series.ext PowerSeries.ext
/-- Two formal power series are equal if all their coefficients are equal. -/
theorem ext_iff {φ ψ : R⟦X⟧} : φ = ψ ↔ ∀ n, coeff R n φ = coeff R n ψ :=
⟨fun h n => congr_arg (coeff R n) h, ext⟩
#align power_series.ext_iff PowerSeries.ext_iff
instance [Subsingleton R] : Subsingleton R⟦X⟧ := by
simp only [subsingleton_iff, ext_iff]
exact fun _ _ _ ↦ (subsingleton_iff).mp (by infer_instance) _ _
/-- Constructor for formal power series. -/
def mk {R} (f : ℕ → R) : R⟦X⟧ := fun s => f (s ())
#align power_series.mk PowerSeries.mk
@[simp]
theorem coeff_mk (n : ℕ) (f : ℕ → R) : coeff R n (mk f) = f n :=
congr_arg f Finsupp.single_eq_same
#align power_series.coeff_mk PowerSeries.coeff_mk
theorem coeff_monomial (m n : ℕ) (a : R) : coeff R m (monomial R n a) = if m = n then a else 0 :=
calc
coeff R m (monomial R n a) = _ := MvPowerSeries.coeff_monomial _ _ _
_ = if m = n then a else 0 := by simp only [Finsupp.unique_single_eq_iff]
#align power_series.coeff_monomial PowerSeries.coeff_monomial
theorem monomial_eq_mk (n : ℕ) (a : R) : monomial R n a = mk fun m => if m = n then a else 0 :=
ext fun m => by rw [coeff_monomial, coeff_mk]
#align power_series.monomial_eq_mk PowerSeries.monomial_eq_mk
@[simp]
theorem coeff_monomial_same (n : ℕ) (a : R) : coeff R n (monomial R n a) = a :=
MvPowerSeries.coeff_monomial_same _ _
#align power_series.coeff_monomial_same PowerSeries.coeff_monomial_same
@[simp]
theorem coeff_comp_monomial (n : ℕ) : (coeff R n).comp (monomial R n) = LinearMap.id :=
LinearMap.ext <| coeff_monomial_same n
#align power_series.coeff_comp_monomial PowerSeries.coeff_comp_monomial
variable (R)
/-- The constant coefficient of a formal power series. -/
def constantCoeff : R⟦X⟧ →+* R :=
MvPowerSeries.constantCoeff Unit R
#align power_series.constant_coeff PowerSeries.constantCoeff
/-- The constant formal power series. -/
def C : R →+* R⟦X⟧ :=
MvPowerSeries.C Unit R
set_option linter.uppercaseLean3 false in
#align power_series.C PowerSeries.C
variable {R}
/-- The variable of the formal power series ring. -/
def X : R⟦X⟧ :=
MvPowerSeries.X ()
set_option linter.uppercaseLean3 false in
#align power_series.X PowerSeries.X
theorem commute_X (φ : R⟦X⟧) : Commute φ X :=
MvPowerSeries.commute_X _ _
set_option linter.uppercaseLean3 false in
#align power_series.commute_X PowerSeries.commute_X
@[simp]
theorem coeff_zero_eq_constantCoeff : ⇑(coeff R 0) = constantCoeff R := by
rw [coeff, Finsupp.single_zero]
rfl
#align power_series.coeff_zero_eq_constant_coeff PowerSeries.coeff_zero_eq_constantCoeff
theorem coeff_zero_eq_constantCoeff_apply (φ : R⟦X⟧) : coeff R 0 φ = constantCoeff R φ := by
rw [coeff_zero_eq_constantCoeff]
#align power_series.coeff_zero_eq_constant_coeff_apply PowerSeries.coeff_zero_eq_constantCoeff_apply
@[simp]
theorem monomial_zero_eq_C : ⇑(monomial R 0) = C R := by
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [monomial, Finsupp.single_zero, MvPowerSeries.monomial_zero_eq_C]
set_option linter.uppercaseLean3 false in
#align power_series.monomial_zero_eq_C PowerSeries.monomial_zero_eq_C
theorem monomial_zero_eq_C_apply (a : R) : monomial R 0 a = C R a := by simp
set_option linter.uppercaseLean3 false in
#align power_series.monomial_zero_eq_C_apply PowerSeries.monomial_zero_eq_C_apply
theorem coeff_C (n : ℕ) (a : R) : coeff R n (C R a : R⟦X⟧) = if n = 0 then a else 0 := by
rw [← monomial_zero_eq_C_apply, coeff_monomial]
set_option linter.uppercaseLean3 false in
#align power_series.coeff_C PowerSeries.coeff_C
@[simp]
| Mathlib/RingTheory/PowerSeries/Basic.lean | 255 | 256 | theorem coeff_zero_C (a : R) : coeff R 0 (C R a) = a := by |
rw [coeff_C, if_pos rfl]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
/-!
# Measure spaces
The definition of a measure and a measure space are in `MeasureTheory.MeasureSpaceDef`, with
only a few basic properties. This file provides many more properties of these objects.
This separation allows the measurability tactic to import only the file `MeasureSpaceDef`, and to
be available in `MeasureSpace` (through `MeasurableSpace`).
Given a measurable space `α`, a measure on `α` is a function that sends measurable sets to the
extended nonnegative reals that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint
sets is equal to the measure of the individual sets.
Every measure can be canonically extended to an outer measure, so that it assigns values to
all subsets, not just the measurable subsets. On the other hand, a measure that is countably
additive on measurable sets can be restricted to measurable sets to obtain a measure.
In this file a measure is defined to be an outer measure that is countably additive on
measurable sets, with the additional assumption that the outer measure is the canonical
extension of the restricted measure.
Measures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.
Given a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding
outer measure (so `s` might not be measurable). We can then define the completion of `μ` as the
measure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`
on the null sets.
## Main statements
* `completion` is the completion of a measure to all null measurable sets.
* `Measure.ofMeasurable` and `OuterMeasure.toMeasure` are two important ways to define a measure.
## Implementation notes
Given `μ : Measure α`, `μ s` is the value of the *outer measure* applied to `s`.
This conveniently allows us to apply the measure to sets without proving that they are measurable.
We get countable subadditivity for all sets, but only countable additivity for measurable sets.
You often don't want to define a measure via its constructor.
Two ways that are sometimes more convenient:
* `Measure.ofMeasurable` is a way to define a measure by only giving its value on measurable sets
and proving the properties (1) and (2) mentioned above.
* `OuterMeasure.toMeasure` is a way of obtaining a measure from an outer measure by showing that
all measurable sets in the measurable space are Carathéodory measurable.
To prove that two measures are equal, there are multiple options:
* `ext`: two measures are equal if they are equal on all measurable sets.
* `ext_of_generateFrom_of_iUnion`: two measures are equal if they are equal on a π-system generating
the measurable sets, if the π-system contains a spanning increasing sequence of sets where the
measures take finite value (in particular the measures are σ-finite). This is a special case of
the more general `ext_of_generateFrom_of_cover`
* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system
generating the measurable sets. This is a special case of `ext_of_generateFrom_of_iUnion` using
`C ∪ {univ}`, but is easier to work with.
A `MeasureSpace` is a class that is a measurable space with a canonical measure.
The measure is denoted `volume`.
## References
* <https://en.wikipedia.org/wiki/Measure_(mathematics)>
* <https://en.wikipedia.org/wiki/Complete_measure>
* <https://en.wikipedia.org/wiki/Almost_everywhere>
## Tags
measure, almost everywhere, measure space, completion, null set, null measurable set
-/
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
/-- See also `MeasureTheory.ae_restrict_uIoc_iff`. -/
theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
#align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff
theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀ h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union MeasureTheory.measure_union
theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀' h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union' MeasureTheory.measure_union'
theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s :=
measure_inter_add_diff₀ _ ht.nullMeasurableSet
#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff
theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s :=
(add_comm _ _).trans (measure_inter_add_diff s ht)
#align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter
theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←
measure_inter_add_diff s ht]
ac_rfl
#align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter
theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]
#align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter'
lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) :
μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by
simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs)
lemma measure_symmDiff_le (s t u : Set α) :
μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) :=
le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u))
theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ :=
measure_add_measure_compl₀ h.nullMeasurableSet
#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl
theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)
(hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion]
exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2
#align measure_theory.measure_bUnion₀ MeasureTheory.measure_biUnion₀
theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)
(h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=
measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet
#align measure_theory.measure_bUnion MeasureTheory.measure_biUnion
theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ))
(h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h]
#align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀
theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)
(h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion hs hd h]
#align measure_theory.measure_sUnion MeasureTheory.measure_sUnion
theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by
rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]
exact measure_biUnion₀ s.countable_toSet hd hm
#align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_biUnion_finset₀
theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)
(hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) :=
measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet
#align measure_theory.measure_bUnion_finset MeasureTheory.measure_biUnion_finset
/-- The measure of an a.e. disjoint union (even uncountable) of null-measurable sets is at least
the sum of the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ)
(As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by
rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff]
intro s
simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i]
gcongr
exact iUnion_subset fun _ ↦ Subset.rfl
/-- The measure of a disjoint union (even uncountable) of measurable sets is at least the sum of
the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))
(As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=
tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet)
(fun _ _ h ↦ Disjoint.aedisjoint (As_disj h))
#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_iUnion_of_disjoint
/-- If `s` is a countable set, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
#align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton
lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) :
μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by
rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs]
/-- If `s` is a `Finset`, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b ∈ s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by
simp only [← measure_biUnion_finset (pairwiseDisjoint_fiber f s) hf,
Finset.set_biUnion_preimage_singleton]
#align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton
theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ :=
measure_congr <| diff_ae_eq_self.2 h
#align measure_theory.measure_diff_null' MeasureTheory.measure_diff_null'
theorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \ s) = μ (s ∪ t) := by
rw [← measure_union' disjoint_sdiff_right hs, union_diff_self]
#align measure_theory.measure_add_diff MeasureTheory.measure_add_diff
theorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) :
μ (s \ t) = μ (s ∪ t) - μ t :=
Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm]
#align measure_theory.measure_diff' MeasureTheory.measure_diff'
theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) :
μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h]
#align measure_theory.measure_diff MeasureTheory.measure_diff
theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) :=
tsub_le_iff_left.2 <| (measure_le_inter_add_diff μ s₁ s₂).trans <| by
gcongr; apply inter_subset_right
#align measure_theory.le_measure_diff MeasureTheory.le_measure_diff
/-- If the measure of the symmetric difference of two sets is finite,
then one has infinite measure if and only if the other one does. -/
theorem measure_eq_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s = ∞ ↔ μ t = ∞ := by
suffices h : ∀ u v, μ (u ∆ v) ≠ ∞ → μ u = ∞ → μ v = ∞
from ⟨h s t hμst, h t s (symmDiff_comm s t ▸ hμst)⟩
intro u v hμuv hμu
by_contra! hμv
apply hμuv
rw [Set.symmDiff_def, eq_top_iff]
calc
∞ = μ u - μ v := (WithTop.sub_eq_top_iff.2 ⟨hμu, hμv⟩).symm
_ ≤ μ (u \ v) := le_measure_diff
_ ≤ μ (u \ v ∪ v \ u) := measure_mono subset_union_left
/-- If the measure of the symmetric difference of two sets is finite,
then one has finite measure if and only if the other one does. -/
theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ :=
(measure_eq_top_iff_of_symmDiff hμst).ne
theorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞}
(h : μ t < μ s + ε) : μ (t \ s) < ε := by
rw [measure_diff hst hs hs']; rw [add_comm] at h
exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h
#align measure_theory.measure_diff_lt_of_lt_add MeasureTheory.measure_diff_lt_of_lt_add
theorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} :
μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by rw [measure_diff hst hs hs', tsub_le_iff_left]
#align measure_theory.measure_diff_le_iff_le_add MeasureTheory.measure_diff_le_iff_le_add
theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) :
μ s = μ t := measure_congr <|
EventuallyLE.antisymm (HasSubset.Subset.eventuallyLE hst) (ae_le_set.mpr h_nulldiff)
#align measure_theory.measure_eq_measure_of_null_diff MeasureTheory.measure_eq_measure_of_null_diff
theorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃)
(h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := by
have le12 : μ s₁ ≤ μ s₂ := measure_mono h12
have le23 : μ s₂ ≤ μ s₃ := measure_mono h23
have key : μ s₃ ≤ μ s₁ :=
calc
μ s₃ = μ (s₃ \ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)]
_ ≤ μ (s₃ \ s₁) + μ s₁ := measure_union_le _ _
_ = μ s₁ := by simp only [h_nulldiff, zero_add]
exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩
#align measure_theory.measure_eq_measure_of_between_null_diff MeasureTheory.measure_eq_measure_of_between_null_diff
theorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1
#align measure_theory.measure_eq_measure_smaller_of_between_null_diff MeasureTheory.measure_eq_measure_smaller_of_between_null_diff
theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₂ = μ s₃ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2
#align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff
lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) :
μ sᶜ = μ Set.univ - μ s := by
rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs]
theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s :=
measure_compl₀ h₁.nullMeasurableSet h_fin
#align measure_theory.measure_compl MeasureTheory.measure_compl
lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null']; rwa [← diff_eq]
lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null ht]
@[simp]
theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by
rw [ae_le_set]
refine
⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>
eventuallyLE_antisymm_iff.mpr
⟨by rwa [ae_le_set, union_diff_left],
HasSubset.Subset.eventuallyLE subset_union_left⟩⟩
#align measure_theory.union_ae_eq_left_iff_ae_subset MeasureTheory.union_ae_eq_left_iff_ae_subset
@[simp]
theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by
rw [union_comm, union_ae_eq_left_iff_ae_subset]
#align measure_theory.union_ae_eq_right_iff_ae_subset MeasureTheory.union_ae_eq_right_iff_ae_subset
theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t := by
refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩
replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁)
replace ht : μ s ≠ ∞ := h₂ ▸ ht
rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self]
#align measure_theory.ae_eq_of_ae_subset_of_measure_ge MeasureTheory.ae_eq_of_ae_subset_of_measure_ge
/-- If `s ⊆ t`, `μ t ≤ μ s`, `μ t ≠ ∞`, and `s` is measurable, then `s =ᵐ[μ] t`. -/
theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t :=
ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht
#align measure_theory.ae_eq_of_subset_of_measure_ge MeasureTheory.ae_eq_of_subset_of_measure_ge
theorem measure_iUnion_congr_of_subset [Countable β] {s : β → Set α} {t : β → Set α}
(hsub : ∀ b, s b ⊆ t b) (h_le : ∀ b, μ (t b) ≤ μ (s b)) : μ (⋃ b, s b) = μ (⋃ b, t b) := by
rcases Classical.em (∃ b, μ (t b) = ∞) with (⟨b, hb⟩ | htop)
· calc
μ (⋃ b, s b) = ∞ := top_unique (hb ▸ (h_le b).trans <| measure_mono <| subset_iUnion _ _)
_ = μ (⋃ b, t b) := Eq.symm <| top_unique <| hb ▸ measure_mono (subset_iUnion _ _)
push_neg at htop
refine le_antisymm (measure_mono (iUnion_mono hsub)) ?_
set M := toMeasurable μ
have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) := by
refine fun b => ae_eq_of_subset_of_measure_ge inter_subset_left ?_ ?_ ?_
· calc
μ (M (t b)) = μ (t b) := measure_toMeasurable _
_ ≤ μ (s b) := h_le b
_ ≤ μ (M (t b) ∩ M (⋃ b, s b)) :=
measure_mono <|
subset_inter ((hsub b).trans <| subset_toMeasurable _ _)
((subset_iUnion _ _).trans <| subset_toMeasurable _ _)
· exact (measurableSet_toMeasurable _ _).inter (measurableSet_toMeasurable _ _)
· rw [measure_toMeasurable]
exact htop b
calc
μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (iUnion_mono fun b => subset_toMeasurable _ _)
_ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := measure_congr (EventuallyEq.countable_iUnion H).symm
_ ≤ μ (M (⋃ b, s b)) := measure_mono (iUnion_subset fun b => inter_subset_right)
_ = μ (⋃ b, s b) := measure_toMeasurable _
#align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_iUnion_congr_of_subset
theorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁)
(ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) := by
rw [union_eq_iUnion, union_eq_iUnion]
exact measure_iUnion_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩)
#align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset
@[simp]
theorem measure_iUnion_toMeasurable [Countable β] (s : β → Set α) :
μ (⋃ b, toMeasurable μ (s b)) = μ (⋃ b, s b) :=
Eq.symm <|
measure_iUnion_congr_of_subset (fun _b => subset_toMeasurable _ _) fun _b =>
(measure_toMeasurable _).le
#align measure_theory.measure_Union_to_measurable MeasureTheory.measure_iUnion_toMeasurable
theorem measure_biUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) :
μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) := by
haveI := hc.toEncodable
simp only [biUnion_eq_iUnion, measure_iUnion_toMeasurable]
#align measure_theory.measure_bUnion_to_measurable MeasureTheory.measure_biUnion_toMeasurable
@[simp]
theorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl
le_rfl
#align measure_theory.measure_to_measurable_union MeasureTheory.measure_toMeasurable_union
@[simp]
theorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _)
(measure_toMeasurable _).le
#align measure_theory.measure_union_to_measurable MeasureTheory.measure_union_toMeasurable
theorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α}
(h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) :
(∑ i ∈ s, μ (t i)) ≤ μ (univ : Set α) := by
rw [← measure_biUnion_finset H h]
exact measure_mono (subset_univ _)
#align measure_theory.sum_measure_le_measure_univ MeasureTheory.sum_measure_le_measure_univ
theorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : Pairwise (Disjoint on s)) : (∑' i, μ (s i)) ≤ μ (univ : Set α) := by
rw [ENNReal.tsum_eq_iSup_sum]
exact iSup_le fun s =>
sum_measure_le_measure_univ (fun i _hi => hs i) fun i _hi j _hj hij => H hij
#align measure_theory.tsum_measure_le_measure_univ MeasureTheory.tsum_measure_le_measure_univ
/-- Pigeonhole principle for measure spaces: if `∑' i, μ (s i) > μ univ`, then
one of the intersections `s i ∩ s j` is not empty. -/
theorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α}
(μ : Measure α) {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ i j, i ≠ j ∧ (s i ∩ s j).Nonempty := by
contrapose! H
apply tsum_measure_le_measure_univ hs
intro i j hij
exact disjoint_iff_inter_eq_empty.mpr (H i j hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure
/-- Pigeonhole principle for measure spaces: if `s` is a `Finset` and
`∑ i ∈ s, μ (t i) > μ univ`, then one of the intersections `t i ∩ t j` is not empty. -/
theorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α)
{s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i))
(H : μ (univ : Set α) < ∑ i ∈ s, μ (t i)) :
∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by
contrapose! H
apply sum_measure_le_measure_univ h
intro i hi j hj hij
exact disjoint_iff_inter_eq_empty.mpr (H i hi j hj hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_sum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_sum_measure
/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,
then `s` intersects `t`. Version assuming that `t` is measurable. -/
theorem nonempty_inter_of_measure_lt_add {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(ht : MeasurableSet t) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [← Set.not_disjoint_iff_nonempty_inter]
contrapose! h
calc
μ s + μ t = μ (s ∪ t) := (measure_union h ht).symm
_ ≤ μ u := measure_mono (union_subset h's h't)
#align measure_theory.nonempty_inter_of_measure_lt_add MeasureTheory.nonempty_inter_of_measure_lt_add
/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,
then `s` intersects `t`. Version assuming that `s` is measurable. -/
theorem nonempty_inter_of_measure_lt_add' {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(hs : MeasurableSet s) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [add_comm] at h
rw [inter_comm]
exact nonempty_inter_of_measure_lt_add μ hs h't h's h
#align measure_theory.nonempty_inter_of_measure_lt_add' MeasureTheory.nonempty_inter_of_measure_lt_add'
/-- Continuity from below: the measure of the union of a directed sequence of (not necessarily
-measurable) sets is the supremum of the measures. -/
theorem measure_iUnion_eq_iSup [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s) :
μ (⋃ i, s i) = ⨆ i, μ (s i) := by
cases nonempty_encodable ι
-- WLOG, `ι = ℕ`
generalize ht : Function.extend Encodable.encode s ⊥ = t
replace hd : Directed (· ⊆ ·) t := ht ▸ hd.extend_bot Encodable.encode_injective
suffices μ (⋃ n, t n) = ⨆ n, μ (t n) by
simp only [← ht, Function.apply_extend μ, ← iSup_eq_iUnion,
iSup_extend_bot Encodable.encode_injective, (· ∘ ·), Pi.bot_apply, bot_eq_empty,
measure_empty] at this
exact this.trans (iSup_extend_bot Encodable.encode_injective _)
clear! ι
-- The `≥` inequality is trivial
refine le_antisymm ?_ (iSup_le fun i => measure_mono <| subset_iUnion _ _)
-- Choose `T n ⊇ t n` of the same measure, put `Td n = disjointed T`
set T : ℕ → Set α := fun n => toMeasurable μ (t n)
set Td : ℕ → Set α := disjointed T
have hm : ∀ n, MeasurableSet (Td n) :=
MeasurableSet.disjointed fun n => measurableSet_toMeasurable _ _
calc
μ (⋃ n, t n) ≤ μ (⋃ n, T n) := measure_mono (iUnion_mono fun i => subset_toMeasurable _ _)
_ = μ (⋃ n, Td n) := by rw [iUnion_disjointed]
_ ≤ ∑' n, μ (Td n) := measure_iUnion_le _
_ = ⨆ I : Finset ℕ, ∑ n ∈ I, μ (Td n) := ENNReal.tsum_eq_iSup_sum
_ ≤ ⨆ n, μ (t n) := iSup_le fun I => by
rcases hd.finset_le I with ⟨N, hN⟩
calc
(∑ n ∈ I, μ (Td n)) = μ (⋃ n ∈ I, Td n) :=
(measure_biUnion_finset ((disjoint_disjointed T).set_pairwise I) fun n _ => hm n).symm
_ ≤ μ (⋃ n ∈ I, T n) := measure_mono (iUnion₂_mono fun n _hn => disjointed_subset _ _)
_ = μ (⋃ n ∈ I, t n) := measure_biUnion_toMeasurable I.countable_toSet _
_ ≤ μ (t N) := measure_mono (iUnion₂_subset hN)
_ ≤ ⨆ n, μ (t n) := le_iSup (μ ∘ t) N
#align measure_theory.measure_Union_eq_supr MeasureTheory.measure_iUnion_eq_iSup
/-- Continuity from below: the measure of the union of a sequence of
(not necessarily measurable) sets is the supremum of the measures of the partial unions. -/
theorem measure_iUnion_eq_iSup' {α ι : Type*} [MeasurableSpace α] {μ : Measure α}
[Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)]
{f : ι → Set α} : μ (⋃ i, f i) = ⨆ i, μ (Accumulate f i) := by
have hd : Directed (· ⊆ ·) (Accumulate f) := by
intro i j
rcases directed_of (· ≤ ·) i j with ⟨k, rik, rjk⟩
exact ⟨k, biUnion_subset_biUnion_left fun l rli ↦ le_trans rli rik,
biUnion_subset_biUnion_left fun l rlj ↦ le_trans rlj rjk⟩
rw [← iUnion_accumulate]
exact measure_iUnion_eq_iSup hd
theorem measure_biUnion_eq_iSup {s : ι → Set α} {t : Set ι} (ht : t.Countable)
(hd : DirectedOn ((· ⊆ ·) on s) t) : μ (⋃ i ∈ t, s i) = ⨆ i ∈ t, μ (s i) := by
haveI := ht.toEncodable
rw [biUnion_eq_iUnion, measure_iUnion_eq_iSup hd.directed_val, ← iSup_subtype'']
#align measure_theory.measure_bUnion_eq_supr MeasureTheory.measure_biUnion_eq_iSup
/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable
sets is the infimum of the measures. -/
theorem measure_iInter_eq_iInf [Countable ι] {s : ι → Set α} (h : ∀ i, MeasurableSet (s i))
(hd : Directed (· ⊇ ·) s) (hfin : ∃ i, μ (s i) ≠ ∞) : μ (⋂ i, s i) = ⨅ i, μ (s i) := by
rcases hfin with ⟨k, hk⟩
have : ∀ t ⊆ s k, μ t ≠ ∞ := fun t ht => ne_top_of_le_ne_top hk (measure_mono ht)
rw [← ENNReal.sub_sub_cancel hk (iInf_le _ k), ENNReal.sub_iInf, ←
ENNReal.sub_sub_cancel hk (measure_mono (iInter_subset _ k)), ←
measure_diff (iInter_subset _ k) (MeasurableSet.iInter h) (this _ (iInter_subset _ k)),
diff_iInter, measure_iUnion_eq_iSup]
· congr 1
refine le_antisymm (iSup_mono' fun i => ?_) (iSup_mono fun i => ?_)
· rcases hd i k with ⟨j, hji, hjk⟩
use j
rw [← measure_diff hjk (h _) (this _ hjk)]
gcongr
· rw [tsub_le_iff_right, ← measure_union, Set.union_comm]
· exact measure_mono (diff_subset_iff.1 Subset.rfl)
· apply disjoint_sdiff_left
· apply h i
· exact hd.mono_comp _ fun _ _ => diff_subset_diff_right
#align measure_theory.measure_Inter_eq_infi MeasureTheory.measure_iInter_eq_iInf
/-- Continuity from above: the measure of the intersection of a sequence of
measurable sets is the infimum of the measures of the partial intersections. -/
theorem measure_iInter_eq_iInf' {α ι : Type*} [MeasurableSpace α] {μ : Measure α}
[Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)]
{f : ι → Set α} (h : ∀ i, MeasurableSet (f i)) (hfin : ∃ i, μ (f i) ≠ ∞) :
μ (⋂ i, f i) = ⨅ i, μ (⋂ j ≤ i, f j) := by
let s := fun i ↦ ⋂ j ≤ i, f j
have iInter_eq : ⋂ i, f i = ⋂ i, s i := by
ext x; simp [s]; constructor
· exact fun h _ j _ ↦ h j
· intro h i
rcases directed_of (· ≤ ·) i i with ⟨j, rij, -⟩
exact h j i rij
have ms : ∀ i, MeasurableSet (s i) :=
fun i ↦ MeasurableSet.biInter (countable_univ.mono <| subset_univ _) fun i _ ↦ h i
have hd : Directed (· ⊇ ·) s := by
intro i j
rcases directed_of (· ≤ ·) i j with ⟨k, rik, rjk⟩
exact ⟨k, biInter_subset_biInter_left fun j rji ↦ le_trans rji rik,
biInter_subset_biInter_left fun i rij ↦ le_trans rij rjk⟩
have hfin' : ∃ i, μ (s i) ≠ ∞ := by
rcases hfin with ⟨i, hi⟩
rcases directed_of (· ≤ ·) i i with ⟨j, rij, -⟩
exact ⟨j, ne_top_of_le_ne_top hi <| measure_mono <| biInter_subset_of_mem rij⟩
exact iInter_eq ▸ measure_iInter_eq_iInf ms hd hfin'
/-- Continuity from below: the measure of the union of an increasing sequence of (not necessarily
measurable) sets is the limit of the measures. -/
theorem tendsto_measure_iUnion [Preorder ι] [IsDirected ι (· ≤ ·)] [Countable ι]
{s : ι → Set α} (hm : Monotone s) : Tendsto (μ ∘ s) atTop (𝓝 (μ (⋃ n, s n))) := by
rw [measure_iUnion_eq_iSup hm.directed_le]
exact tendsto_atTop_iSup fun n m hnm => measure_mono <| hm hnm
#align measure_theory.tendsto_measure_Union MeasureTheory.tendsto_measure_iUnion
/-- Continuity from below: the measure of the union of a sequence of (not necessarily measurable)
sets is the limit of the measures of the partial unions. -/
theorem tendsto_measure_iUnion' {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Countable ι]
[Preorder ι] [IsDirected ι (· ≤ ·)] {f : ι → Set α} :
Tendsto (fun i ↦ μ (Accumulate f i)) atTop (𝓝 (μ (⋃ i, f i))) := by
rw [measure_iUnion_eq_iSup']
exact tendsto_atTop_iSup fun i j hij ↦ by gcongr
/-- Continuity from above: the measure of the intersection of a decreasing sequence of measurable
sets is the limit of the measures. -/
theorem tendsto_measure_iInter [Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)] {s : ι → Set α}
(hs : ∀ n, MeasurableSet (s n)) (hm : Antitone s) (hf : ∃ i, μ (s i) ≠ ∞) :
Tendsto (μ ∘ s) atTop (𝓝 (μ (⋂ n, s n))) := by
rw [measure_iInter_eq_iInf hs hm.directed_ge hf]
exact tendsto_atTop_iInf fun n m hnm => measure_mono <| hm hnm
#align measure_theory.tendsto_measure_Inter MeasureTheory.tendsto_measure_iInter
/-- Continuity from above: the measure of the intersection of a sequence of measurable
sets such that one has finite measure is the limit of the measures of the partial intersections. -/
theorem tendsto_measure_iInter' {α ι : Type*} [MeasurableSpace α] {μ : Measure α} [Countable ι]
[Preorder ι] [IsDirected ι (· ≤ ·)] {f : ι → Set α} (hm : ∀ i, MeasurableSet (f i))
(hf : ∃ i, μ (f i) ≠ ∞) :
Tendsto (fun i ↦ μ (⋂ j ∈ {j | j ≤ i}, f j)) atTop (𝓝 (μ (⋂ i, f i))) := by
rw [measure_iInter_eq_iInf' hm hf]
exact tendsto_atTop_iInf
fun i j hij ↦ measure_mono <| biInter_subset_biInter_left fun k hki ↦ le_trans hki hij
/-- The measure of the intersection of a decreasing sequence of measurable
sets indexed by a linear order with first countable topology is the limit of the measures. -/
theorem tendsto_measure_biInter_gt {ι : Type*} [LinearOrder ι] [TopologicalSpace ι]
[OrderTopology ι] [DenselyOrdered ι] [FirstCountableTopology ι] {s : ι → Set α}
{a : ι} (hs : ∀ r > a, MeasurableSet (s r)) (hm : ∀ i j, a < i → i ≤ j → s i ⊆ s j)
(hf : ∃ r > a, μ (s r) ≠ ∞) : Tendsto (μ ∘ s) (𝓝[Ioi a] a) (𝓝 (μ (⋂ r > a, s r))) := by
refine tendsto_order.2 ⟨fun l hl => ?_, fun L hL => ?_⟩
· filter_upwards [self_mem_nhdsWithin (s := Ioi a)] with r hr using hl.trans_le
(measure_mono (biInter_subset_of_mem hr))
obtain ⟨u, u_anti, u_pos, u_lim⟩ :
∃ u : ℕ → ι, StrictAnti u ∧ (∀ n : ℕ, a < u n) ∧ Tendsto u atTop (𝓝 a) := by
rcases hf with ⟨r, ar, _⟩
rcases exists_seq_strictAnti_tendsto' ar with ⟨w, w_anti, w_mem, w_lim⟩
exact ⟨w, w_anti, fun n => (w_mem n).1, w_lim⟩
have A : Tendsto (μ ∘ s ∘ u) atTop (𝓝 (μ (⋂ n, s (u n)))) := by
refine tendsto_measure_iInter (fun n => hs _ (u_pos n)) ?_ ?_
· intro m n hmn
exact hm _ _ (u_pos n) (u_anti.antitone hmn)
· rcases hf with ⟨r, rpos, hr⟩
obtain ⟨n, hn⟩ : ∃ n : ℕ, u n < r := ((tendsto_order.1 u_lim).2 r rpos).exists
refine ⟨n, ne_of_lt (lt_of_le_of_lt ?_ hr.lt_top)⟩
exact measure_mono (hm _ _ (u_pos n) hn.le)
have B : ⋂ n, s (u n) = ⋂ r > a, s r := by
apply Subset.antisymm
· simp only [subset_iInter_iff, gt_iff_lt]
intro r rpos
obtain ⟨n, hn⟩ : ∃ n, u n < r := ((tendsto_order.1 u_lim).2 _ rpos).exists
exact Subset.trans (iInter_subset _ n) (hm (u n) r (u_pos n) hn.le)
· simp only [subset_iInter_iff, gt_iff_lt]
intro n
apply biInter_subset_of_mem
exact u_pos n
rw [B] at A
obtain ⟨n, hn⟩ : ∃ n, μ (s (u n)) < L := ((tendsto_order.1 A).2 _ hL).exists
have : Ioc a (u n) ∈ 𝓝[>] a := Ioc_mem_nhdsWithin_Ioi ⟨le_rfl, u_pos n⟩
filter_upwards [this] with r hr using lt_of_le_of_lt (measure_mono (hm _ _ hr.1 hr.2)) hn
#align measure_theory.tendsto_measure_bInter_gt MeasureTheory.tendsto_measure_biInter_gt
/-- One direction of the **Borel-Cantelli lemma** (sometimes called the "*first* Borel-Cantelli
lemma"): if (sᵢ) is a sequence of sets such that `∑ μ sᵢ` is finite, then the limit superior of the
`sᵢ` is a null set.
Note: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),
see `ProbabilityTheory.measure_limsup_eq_one`. -/
theorem measure_limsup_eq_zero {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :
μ (limsup s atTop) = 0 := by
-- First we replace the sequence `sₙ` with a sequence of measurable sets `tₙ ⊇ sₙ` of the same
-- measure.
set t : ℕ → Set α := fun n => toMeasurable μ (s n)
have ht : (∑' i, μ (t i)) ≠ ∞ := by simpa only [t, measure_toMeasurable] using hs
suffices μ (limsup t atTop) = 0 by
have A : s ≤ t := fun n => subset_toMeasurable μ (s n)
-- TODO default args fail
exact measure_mono_null (limsup_le_limsup (eventually_of_forall (Pi.le_def.mp A))) this
-- Next we unfold `limsup` for sets and replace equality with an inequality
simp only [limsup_eq_iInf_iSup_of_nat', Set.iInf_eq_iInter, Set.iSup_eq_iUnion, ←
nonpos_iff_eq_zero]
-- Finally, we estimate `μ (⋃ i, t (i + n))` by `∑ i', μ (t (i + n))`
refine
le_of_tendsto_of_tendsto'
(tendsto_measure_iInter
(fun i => MeasurableSet.iUnion fun b => measurableSet_toMeasurable _ _) ?_
⟨0, ne_top_of_le_ne_top ht (measure_iUnion_le t)⟩)
(ENNReal.tendsto_sum_nat_add (μ ∘ t) ht) fun n => measure_iUnion_le _
intro n m hnm x
simp only [Set.mem_iUnion]
exact fun ⟨i, hi⟩ => ⟨i + (m - n), by simpa only [add_assoc, tsub_add_cancel_of_le hnm] using hi⟩
#align measure_theory.measure_limsup_eq_zero MeasureTheory.measure_limsup_eq_zero
theorem measure_liminf_eq_zero {s : ℕ → Set α} (h : (∑' i, μ (s i)) ≠ ∞) :
μ (liminf s atTop) = 0 := by
rw [← le_zero_iff]
have : liminf s atTop ≤ limsup s atTop := liminf_le_limsup
exact (μ.mono this).trans (by simp [measure_limsup_eq_zero h])
#align measure_theory.measure_liminf_eq_zero MeasureTheory.measure_liminf_eq_zero
-- Need to specify `α := Set α` below because of diamond; see #19041
theorem limsup_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}
(h : ∀ n, s n =ᵐ[μ] t) : limsup (α := Set α) s atTop =ᵐ[μ] t := by
simp_rw [ae_eq_set] at h ⊢
constructor
· rw [atTop.limsup_sdiff s t]
apply measure_limsup_eq_zero
simp [h]
· rw [atTop.sdiff_limsup s t]
apply measure_liminf_eq_zero
simp [h]
#align measure_theory.limsup_ae_eq_of_forall_ae_eq MeasureTheory.limsup_ae_eq_of_forall_ae_eq
-- Need to specify `α := Set α` above because of diamond; see #19041
theorem liminf_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}
(h : ∀ n, s n =ᵐ[μ] t) : liminf (α := Set α) s atTop =ᵐ[μ] t := by
simp_rw [ae_eq_set] at h ⊢
constructor
· rw [atTop.liminf_sdiff s t]
apply measure_liminf_eq_zero
simp [h]
· rw [atTop.sdiff_liminf s t]
apply measure_limsup_eq_zero
simp [h]
#align measure_theory.liminf_ae_eq_of_forall_ae_eq MeasureTheory.liminf_ae_eq_of_forall_ae_eq
theorem measure_if {x : β} {t : Set β} {s : Set α} :
μ (if x ∈ t then s else ∅) = indicator t (fun _ => μ s) x := by split_ifs with h <;> simp [h]
#align measure_theory.measure_if MeasureTheory.measure_if
end
section OuterMeasure
variable [ms : MeasurableSpace α] {s t : Set α}
/-- Obtain a measure by giving an outer measure where all sets in the σ-algebra are
Carathéodory measurable. -/
def OuterMeasure.toMeasure (m : OuterMeasure α) (h : ms ≤ m.caratheodory) : Measure α :=
Measure.ofMeasurable (fun s _ => m s) m.empty fun _f hf hd =>
m.iUnion_eq_of_caratheodory (fun i => h _ (hf i)) hd
#align measure_theory.outer_measure.to_measure MeasureTheory.OuterMeasure.toMeasure
theorem le_toOuterMeasure_caratheodory (μ : Measure α) : ms ≤ μ.toOuterMeasure.caratheodory :=
fun _s hs _t => (measure_inter_add_diff _ hs).symm
#align measure_theory.le_to_outer_measure_caratheodory MeasureTheory.le_toOuterMeasure_caratheodory
@[simp]
theorem toMeasure_toOuterMeasure (m : OuterMeasure α) (h : ms ≤ m.caratheodory) :
(m.toMeasure h).toOuterMeasure = m.trim :=
rfl
#align measure_theory.to_measure_to_outer_measure MeasureTheory.toMeasure_toOuterMeasure
@[simp]
theorem toMeasure_apply (m : OuterMeasure α) (h : ms ≤ m.caratheodory) {s : Set α}
(hs : MeasurableSet s) : m.toMeasure h s = m s :=
m.trim_eq hs
#align measure_theory.to_measure_apply MeasureTheory.toMeasure_apply
theorem le_toMeasure_apply (m : OuterMeasure α) (h : ms ≤ m.caratheodory) (s : Set α) :
m s ≤ m.toMeasure h s :=
m.le_trim s
#align measure_theory.le_to_measure_apply MeasureTheory.le_toMeasure_apply
theorem toMeasure_apply₀ (m : OuterMeasure α) (h : ms ≤ m.caratheodory) {s : Set α}
(hs : NullMeasurableSet s (m.toMeasure h)) : m.toMeasure h s = m s := by
refine le_antisymm ?_ (le_toMeasure_apply _ _ _)
rcases hs.exists_measurable_subset_ae_eq with ⟨t, hts, htm, heq⟩
calc
m.toMeasure h s = m.toMeasure h t := measure_congr heq.symm
_ = m t := toMeasure_apply m h htm
_ ≤ m s := m.mono hts
#align measure_theory.to_measure_apply₀ MeasureTheory.toMeasure_apply₀
@[simp]
theorem toOuterMeasure_toMeasure {μ : Measure α} :
μ.toOuterMeasure.toMeasure (le_toOuterMeasure_caratheodory _) = μ :=
Measure.ext fun _s => μ.toOuterMeasure.trim_eq
#align measure_theory.to_outer_measure_to_measure MeasureTheory.toOuterMeasure_toMeasure
@[simp]
theorem boundedBy_measure (μ : Measure α) : OuterMeasure.boundedBy μ = μ.toOuterMeasure :=
μ.toOuterMeasure.boundedBy_eq_self
#align measure_theory.bounded_by_measure MeasureTheory.boundedBy_measure
end OuterMeasure
section
/- Porting note: These variables are wrapped by an anonymous section because they interrupt
synthesizing instances in `MeasureSpace` section. -/
variable {m0 : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ]
variable {μ μ₁ μ₂ μ₃ ν ν' ν₁ ν₂ : Measure α} {s s' t : Set α}
namespace Measure
/-- If `u` is a superset of `t` with the same (finite) measure (both sets possibly non-measurable),
then for any measurable set `s` one also has `μ (t ∩ s) = μ (u ∩ s)`. -/
theorem measure_inter_eq_of_measure_eq {s t u : Set α} (hs : MeasurableSet s) (h : μ t = μ u)
(htu : t ⊆ u) (ht_ne_top : μ t ≠ ∞) : μ (t ∩ s) = μ (u ∩ s) := by
rw [h] at ht_ne_top
refine le_antisymm (by gcongr) ?_
have A : μ (u ∩ s) + μ (u \ s) ≤ μ (t ∩ s) + μ (u \ s) :=
calc
μ (u ∩ s) + μ (u \ s) = μ u := measure_inter_add_diff _ hs
_ = μ t := h.symm
_ = μ (t ∩ s) + μ (t \ s) := (measure_inter_add_diff _ hs).symm
_ ≤ μ (t ∩ s) + μ (u \ s) := by gcongr
have B : μ (u \ s) ≠ ∞ := (lt_of_le_of_lt (measure_mono diff_subset) ht_ne_top.lt_top).ne
exact ENNReal.le_of_add_le_add_right B A
#align measure_theory.measure.measure_inter_eq_of_measure_eq MeasureTheory.Measure.measure_inter_eq_of_measure_eq
/-- The measurable superset `toMeasurable μ t` of `t` (which has the same measure as `t`)
satisfies, for any measurable set `s`, the equality `μ (toMeasurable μ t ∩ s) = μ (u ∩ s)`.
Here, we require that the measure of `t` is finite. The conclusion holds without this assumption
when the measure is s-finite (for example when it is σ-finite),
see `measure_toMeasurable_inter_of_sFinite`. -/
theorem measure_toMeasurable_inter {s t : Set α} (hs : MeasurableSet s) (ht : μ t ≠ ∞) :
μ (toMeasurable μ t ∩ s) = μ (t ∩ s) :=
(measure_inter_eq_of_measure_eq hs (measure_toMeasurable t).symm (subset_toMeasurable μ t)
ht).symm
#align measure_theory.measure.measure_to_measurable_inter MeasureTheory.Measure.measure_toMeasurable_inter
/-! ### The `ℝ≥0∞`-module of measures -/
instance instZero [MeasurableSpace α] : Zero (Measure α) :=
⟨{ toOuterMeasure := 0
m_iUnion := fun _f _hf _hd => tsum_zero.symm
trim_le := OuterMeasure.trim_zero.le }⟩
#align measure_theory.measure.has_zero MeasureTheory.Measure.instZero
@[simp]
theorem zero_toOuterMeasure {_m : MeasurableSpace α} : (0 : Measure α).toOuterMeasure = 0 :=
rfl
#align measure_theory.measure.zero_to_outer_measure MeasureTheory.Measure.zero_toOuterMeasure
@[simp, norm_cast]
theorem coe_zero {_m : MeasurableSpace α} : ⇑(0 : Measure α) = 0 :=
rfl
#align measure_theory.measure.coe_zero MeasureTheory.Measure.coe_zero
@[nontriviality]
lemma apply_eq_zero_of_isEmpty [IsEmpty α] {_ : MeasurableSpace α} (μ : Measure α) (s : Set α) :
μ s = 0 := by
rw [eq_empty_of_isEmpty s, measure_empty]
instance instSubsingleton [IsEmpty α] {m : MeasurableSpace α} : Subsingleton (Measure α) :=
⟨fun μ ν => by ext1 s _; rw [apply_eq_zero_of_isEmpty, apply_eq_zero_of_isEmpty]⟩
#align measure_theory.measure.subsingleton MeasureTheory.Measure.instSubsingleton
theorem eq_zero_of_isEmpty [IsEmpty α] {_m : MeasurableSpace α} (μ : Measure α) : μ = 0 :=
Subsingleton.elim μ 0
#align measure_theory.measure.eq_zero_of_is_empty MeasureTheory.Measure.eq_zero_of_isEmpty
instance instInhabited [MeasurableSpace α] : Inhabited (Measure α) :=
⟨0⟩
#align measure_theory.measure.inhabited MeasureTheory.Measure.instInhabited
instance instAdd [MeasurableSpace α] : Add (Measure α) :=
⟨fun μ₁ μ₂ =>
{ toOuterMeasure := μ₁.toOuterMeasure + μ₂.toOuterMeasure
m_iUnion := fun s hs hd =>
show μ₁ (⋃ i, s i) + μ₂ (⋃ i, s i) = ∑' i, (μ₁ (s i) + μ₂ (s i)) by
rw [ENNReal.tsum_add, measure_iUnion hd hs, measure_iUnion hd hs]
trim_le := by rw [OuterMeasure.trim_add, μ₁.trimmed, μ₂.trimmed] }⟩
#align measure_theory.measure.has_add MeasureTheory.Measure.instAdd
@[simp]
theorem add_toOuterMeasure {_m : MeasurableSpace α} (μ₁ μ₂ : Measure α) :
(μ₁ + μ₂).toOuterMeasure = μ₁.toOuterMeasure + μ₂.toOuterMeasure :=
rfl
#align measure_theory.measure.add_to_outer_measure MeasureTheory.Measure.add_toOuterMeasure
@[simp, norm_cast]
theorem coe_add {_m : MeasurableSpace α} (μ₁ μ₂ : Measure α) : ⇑(μ₁ + μ₂) = μ₁ + μ₂ :=
rfl
#align measure_theory.measure.coe_add MeasureTheory.Measure.coe_add
theorem add_apply {_m : MeasurableSpace α} (μ₁ μ₂ : Measure α) (s : Set α) :
(μ₁ + μ₂) s = μ₁ s + μ₂ s :=
rfl
#align measure_theory.measure.add_apply MeasureTheory.Measure.add_apply
section SMul
variable [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
variable [SMul R' ℝ≥0∞] [IsScalarTower R' ℝ≥0∞ ℝ≥0∞]
instance instSMul [MeasurableSpace α] : SMul R (Measure α) :=
⟨fun c μ =>
{ toOuterMeasure := c • μ.toOuterMeasure
m_iUnion := fun s hs hd => by
simp only [OuterMeasure.smul_apply, coe_toOuterMeasure, ENNReal.tsum_const_smul,
measure_iUnion hd hs]
trim_le := by rw [OuterMeasure.trim_smul, μ.trimmed] }⟩
#align measure_theory.measure.has_smul MeasureTheory.Measure.instSMul
@[simp]
theorem smul_toOuterMeasure {_m : MeasurableSpace α} (c : R) (μ : Measure α) :
(c • μ).toOuterMeasure = c • μ.toOuterMeasure :=
rfl
#align measure_theory.measure.smul_to_outer_measure MeasureTheory.Measure.smul_toOuterMeasure
@[simp, norm_cast]
theorem coe_smul {_m : MeasurableSpace α} (c : R) (μ : Measure α) : ⇑(c • μ) = c • ⇑μ :=
rfl
#align measure_theory.measure.coe_smul MeasureTheory.Measure.coe_smul
@[simp]
theorem smul_apply {_m : MeasurableSpace α} (c : R) (μ : Measure α) (s : Set α) :
(c • μ) s = c • μ s :=
rfl
#align measure_theory.measure.smul_apply MeasureTheory.Measure.smul_apply
instance instSMulCommClass [SMulCommClass R R' ℝ≥0∞] [MeasurableSpace α] :
SMulCommClass R R' (Measure α) :=
⟨fun _ _ _ => ext fun _ _ => smul_comm _ _ _⟩
#align measure_theory.measure.smul_comm_class MeasureTheory.Measure.instSMulCommClass
instance instIsScalarTower [SMul R R'] [IsScalarTower R R' ℝ≥0∞] [MeasurableSpace α] :
IsScalarTower R R' (Measure α) :=
⟨fun _ _ _ => ext fun _ _ => smul_assoc _ _ _⟩
#align measure_theory.measure.is_scalar_tower MeasureTheory.Measure.instIsScalarTower
instance instIsCentralScalar [SMul Rᵐᵒᵖ ℝ≥0∞] [IsCentralScalar R ℝ≥0∞] [MeasurableSpace α] :
IsCentralScalar R (Measure α) :=
⟨fun _ _ => ext fun _ _ => op_smul_eq_smul _ _⟩
#align measure_theory.measure.is_central_scalar MeasureTheory.Measure.instIsCentralScalar
end SMul
instance instNoZeroSMulDivisors [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[NoZeroSMulDivisors R ℝ≥0∞] : NoZeroSMulDivisors R (Measure α) where
eq_zero_or_eq_zero_of_smul_eq_zero h := by simpa [Ne, ext_iff', forall_or_left] using h
instance instMulAction [Monoid R] [MulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[MeasurableSpace α] : MulAction R (Measure α) :=
Injective.mulAction _ toOuterMeasure_injective smul_toOuterMeasure
#align measure_theory.measure.mul_action MeasureTheory.Measure.instMulAction
instance instAddCommMonoid [MeasurableSpace α] : AddCommMonoid (Measure α) :=
toOuterMeasure_injective.addCommMonoid toOuterMeasure zero_toOuterMeasure add_toOuterMeasure
fun _ _ => smul_toOuterMeasure _ _
#align measure_theory.measure.add_comm_monoid MeasureTheory.Measure.instAddCommMonoid
/-- Coercion to function as an additive monoid homomorphism. -/
def coeAddHom {_ : MeasurableSpace α} : Measure α →+ Set α → ℝ≥0∞ where
toFun := (⇑)
map_zero' := coe_zero
map_add' := coe_add
#align measure_theory.measure.coe_add_hom MeasureTheory.Measure.coeAddHom
@[simp]
theorem coe_finset_sum {_m : MeasurableSpace α} (I : Finset ι) (μ : ι → Measure α) :
⇑(∑ i ∈ I, μ i) = ∑ i ∈ I, ⇑(μ i) := map_sum coeAddHom μ I
#align measure_theory.measure.coe_finset_sum MeasureTheory.Measure.coe_finset_sum
theorem finset_sum_apply {m : MeasurableSpace α} (I : Finset ι) (μ : ι → Measure α) (s : Set α) :
(∑ i ∈ I, μ i) s = ∑ i ∈ I, μ i s := by rw [coe_finset_sum, Finset.sum_apply]
#align measure_theory.measure.finset_sum_apply MeasureTheory.Measure.finset_sum_apply
instance instDistribMulAction [Monoid R] [DistribMulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[MeasurableSpace α] : DistribMulAction R (Measure α) :=
Injective.distribMulAction ⟨⟨toOuterMeasure, zero_toOuterMeasure⟩, add_toOuterMeasure⟩
toOuterMeasure_injective smul_toOuterMeasure
#align measure_theory.measure.distrib_mul_action MeasureTheory.Measure.instDistribMulAction
instance instModule [Semiring R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] [MeasurableSpace α] :
Module R (Measure α) :=
Injective.module R ⟨⟨toOuterMeasure, zero_toOuterMeasure⟩, add_toOuterMeasure⟩
toOuterMeasure_injective smul_toOuterMeasure
#align measure_theory.measure.module MeasureTheory.Measure.instModule
@[simp]
theorem coe_nnreal_smul_apply {_m : MeasurableSpace α} (c : ℝ≥0) (μ : Measure α) (s : Set α) :
(c • μ) s = c * μ s :=
rfl
#align measure_theory.measure.coe_nnreal_smul_apply MeasureTheory.Measure.coe_nnreal_smul_apply
@[simp]
theorem nnreal_smul_coe_apply {_m : MeasurableSpace α} (c : ℝ≥0) (μ : Measure α) (s : Set α) :
c • μ s = c * μ s := by
rfl
theorem ae_smul_measure_iff {p : α → Prop} {c : ℝ≥0∞} (hc : c ≠ 0) :
(∀ᵐ x ∂c • μ, p x) ↔ ∀ᵐ x ∂μ, p x := by
simp only [ae_iff, Algebra.id.smul_eq_mul, smul_apply, or_iff_right_iff_imp, mul_eq_zero]
simp only [IsEmpty.forall_iff, hc]
#align measure_theory.measure.ae_smul_measure_iff MeasureTheory.Measure.ae_smul_measure_iff
theorem measure_eq_left_of_subset_of_measure_add_eq {s t : Set α} (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t)
(h'' : (μ + ν) s = (μ + ν) t) : μ s = μ t := by
refine le_antisymm (measure_mono h') ?_
have : μ t + ν t ≤ μ s + ν t :=
calc
μ t + ν t = μ s + ν s := h''.symm
_ ≤ μ s + ν t := by gcongr
apply ENNReal.le_of_add_le_add_right _ this
exact ne_top_of_le_ne_top h (le_add_left le_rfl)
#align measure_theory.measure.measure_eq_left_of_subset_of_measure_add_eq MeasureTheory.Measure.measure_eq_left_of_subset_of_measure_add_eq
theorem measure_eq_right_of_subset_of_measure_add_eq {s t : Set α} (h : (μ + ν) t ≠ ∞) (h' : s ⊆ t)
(h'' : (μ + ν) s = (μ + ν) t) : ν s = ν t := by
rw [add_comm] at h'' h
exact measure_eq_left_of_subset_of_measure_add_eq h h' h''
#align measure_theory.measure.measure_eq_right_of_subset_of_measure_add_eq MeasureTheory.Measure.measure_eq_right_of_subset_of_measure_add_eq
theorem measure_toMeasurable_add_inter_left {s t : Set α} (hs : MeasurableSet s)
(ht : (μ + ν) t ≠ ∞) : μ (toMeasurable (μ + ν) t ∩ s) = μ (t ∩ s) := by
refine (measure_inter_eq_of_measure_eq hs ?_ (subset_toMeasurable _ _) ?_).symm
· refine
measure_eq_left_of_subset_of_measure_add_eq ?_ (subset_toMeasurable _ _)
(measure_toMeasurable t).symm
rwa [measure_toMeasurable t]
· simp only [not_or, ENNReal.add_eq_top, Pi.add_apply, Ne, coe_add] at ht
exact ht.1
#align measure_theory.measure.measure_to_measurable_add_inter_left MeasureTheory.Measure.measure_toMeasurable_add_inter_left
theorem measure_toMeasurable_add_inter_right {s t : Set α} (hs : MeasurableSet s)
(ht : (μ + ν) t ≠ ∞) : ν (toMeasurable (μ + ν) t ∩ s) = ν (t ∩ s) := by
rw [add_comm] at ht ⊢
exact measure_toMeasurable_add_inter_left hs ht
#align measure_theory.measure.measure_to_measurable_add_inter_right MeasureTheory.Measure.measure_toMeasurable_add_inter_right
/-! ### The complete lattice of measures -/
/-- Measures are partially ordered. -/
instance instPartialOrder [MeasurableSpace α] : PartialOrder (Measure α) where
le m₁ m₂ := ∀ s, m₁ s ≤ m₂ s
le_refl m s := le_rfl
le_trans m₁ m₂ m₃ h₁ h₂ s := le_trans (h₁ s) (h₂ s)
le_antisymm m₁ m₂ h₁ h₂ := ext fun s _ => le_antisymm (h₁ s) (h₂ s)
#align measure_theory.measure.partial_order MeasureTheory.Measure.instPartialOrder
theorem toOuterMeasure_le : μ₁.toOuterMeasure ≤ μ₂.toOuterMeasure ↔ μ₁ ≤ μ₂ := .rfl
#align measure_theory.measure.to_outer_measure_le MeasureTheory.Measure.toOuterMeasure_le
theorem le_iff : μ₁ ≤ μ₂ ↔ ∀ s, MeasurableSet s → μ₁ s ≤ μ₂ s := outerMeasure_le_iff
#align measure_theory.measure.le_iff MeasureTheory.Measure.le_iff
theorem le_intro (h : ∀ s, MeasurableSet s → s.Nonempty → μ₁ s ≤ μ₂ s) : μ₁ ≤ μ₂ :=
le_iff.2 fun s hs ↦ s.eq_empty_or_nonempty.elim (by rintro rfl; simp) (h s hs)
theorem le_iff' : μ₁ ≤ μ₂ ↔ ∀ s, μ₁ s ≤ μ₂ s := .rfl
#align measure_theory.measure.le_iff' MeasureTheory.Measure.le_iff'
theorem lt_iff : μ < ν ↔ μ ≤ ν ∧ ∃ s, MeasurableSet s ∧ μ s < ν s :=
lt_iff_le_not_le.trans <|
and_congr Iff.rfl <| by simp only [le_iff, not_forall, not_le, exists_prop]
#align measure_theory.measure.lt_iff MeasureTheory.Measure.lt_iff
theorem lt_iff' : μ < ν ↔ μ ≤ ν ∧ ∃ s, μ s < ν s :=
lt_iff_le_not_le.trans <| and_congr Iff.rfl <| by simp only [le_iff', not_forall, not_le]
#align measure_theory.measure.lt_iff' MeasureTheory.Measure.lt_iff'
instance covariantAddLE [MeasurableSpace α] :
CovariantClass (Measure α) (Measure α) (· + ·) (· ≤ ·) :=
⟨fun _ν _μ₁ _μ₂ hμ s => add_le_add_left (hμ s) _⟩
#align measure_theory.measure.covariant_add_le MeasureTheory.Measure.covariantAddLE
protected theorem le_add_left (h : μ ≤ ν) : μ ≤ ν' + ν := fun s => le_add_left (h s)
#align measure_theory.measure.le_add_left MeasureTheory.Measure.le_add_left
protected theorem le_add_right (h : μ ≤ ν) : μ ≤ ν + ν' := fun s => le_add_right (h s)
#align measure_theory.measure.le_add_right MeasureTheory.Measure.le_add_right
section sInf
variable {m : Set (Measure α)}
theorem sInf_caratheodory (s : Set α) (hs : MeasurableSet s) :
MeasurableSet[(sInf (toOuterMeasure '' m)).caratheodory] s := by
rw [OuterMeasure.sInf_eq_boundedBy_sInfGen]
refine OuterMeasure.boundedBy_caratheodory fun t => ?_
simp only [OuterMeasure.sInfGen, le_iInf_iff, forall_mem_image, measure_eq_iInf t,
coe_toOuterMeasure]
intro μ hμ u htu _hu
have hm : ∀ {s t}, s ⊆ t → OuterMeasure.sInfGen (toOuterMeasure '' m) s ≤ μ t := by
intro s t hst
rw [OuterMeasure.sInfGen_def, iInf_image]
exact iInf₂_le_of_le μ hμ <| measure_mono hst
rw [← measure_inter_add_diff u hs]
exact add_le_add (hm <| inter_subset_inter_left _ htu) (hm <| diff_subset_diff_left htu)
#align measure_theory.measure.Inf_caratheodory MeasureTheory.Measure.sInf_caratheodory
instance [MeasurableSpace α] : InfSet (Measure α) :=
⟨fun m => (sInf (toOuterMeasure '' m)).toMeasure <| sInf_caratheodory⟩
theorem sInf_apply (hs : MeasurableSet s) : sInf m s = sInf (toOuterMeasure '' m) s :=
toMeasure_apply _ _ hs
#align measure_theory.measure.Inf_apply MeasureTheory.Measure.sInf_apply
private theorem measure_sInf_le (h : μ ∈ m) : sInf m ≤ μ :=
have : sInf (toOuterMeasure '' m) ≤ μ.toOuterMeasure := sInf_le (mem_image_of_mem _ h)
le_iff.2 fun s hs => by rw [sInf_apply hs]; exact this s
private theorem measure_le_sInf (h : ∀ μ' ∈ m, μ ≤ μ') : μ ≤ sInf m :=
have : μ.toOuterMeasure ≤ sInf (toOuterMeasure '' m) :=
le_sInf <| forall_mem_image.2 fun μ hμ ↦ toOuterMeasure_le.2 <| h _ hμ
le_iff.2 fun s hs => by rw [sInf_apply hs]; exact this s
instance instCompleteSemilatticeInf [MeasurableSpace α] : CompleteSemilatticeInf (Measure α) :=
{ (by infer_instance : PartialOrder (Measure α)),
(by infer_instance : InfSet (Measure α)) with
sInf_le := fun _s _a => measure_sInf_le
le_sInf := fun _s _a => measure_le_sInf }
#align measure_theory.measure.complete_semilattice_Inf MeasureTheory.Measure.instCompleteSemilatticeInf
instance instCompleteLattice [MeasurableSpace α] : CompleteLattice (Measure α) :=
{ completeLatticeOfCompleteSemilatticeInf (Measure α) with
top :=
{ toOuterMeasure := ⊤,
m_iUnion := by
intro f _ _
refine (measure_iUnion_le _).antisymm ?_
if hne : (⋃ i, f i).Nonempty then
rw [OuterMeasure.top_apply hne]
exact le_top
else
simp_all [Set.not_nonempty_iff_eq_empty]
trim_le := le_top },
le_top := fun μ => toOuterMeasure_le.mp le_top
bot := 0
bot_le := fun _a _s => bot_le }
#align measure_theory.measure.complete_lattice MeasureTheory.Measure.instCompleteLattice
end sInf
@[simp]
theorem _root_.MeasureTheory.OuterMeasure.toMeasure_top :
(⊤ : OuterMeasure α).toMeasure (by rw [OuterMeasure.top_caratheodory]; exact le_top) =
(⊤ : Measure α) :=
toOuterMeasure_toMeasure (μ := ⊤)
#align measure_theory.outer_measure.to_measure_top MeasureTheory.OuterMeasure.toMeasure_top
@[simp]
theorem toOuterMeasure_top [MeasurableSpace α] :
(⊤ : Measure α).toOuterMeasure = (⊤ : OuterMeasure α) :=
rfl
#align measure_theory.measure.to_outer_measure_top MeasureTheory.Measure.toOuterMeasure_top
@[simp]
theorem top_add : ⊤ + μ = ⊤ :=
top_unique <| Measure.le_add_right le_rfl
#align measure_theory.measure.top_add MeasureTheory.Measure.top_add
@[simp]
theorem add_top : μ + ⊤ = ⊤ :=
top_unique <| Measure.le_add_left le_rfl
#align measure_theory.measure.add_top MeasureTheory.Measure.add_top
protected theorem zero_le {_m0 : MeasurableSpace α} (μ : Measure α) : 0 ≤ μ :=
bot_le
#align measure_theory.measure.zero_le MeasureTheory.Measure.zero_le
theorem nonpos_iff_eq_zero' : μ ≤ 0 ↔ μ = 0 :=
μ.zero_le.le_iff_eq
#align measure_theory.measure.nonpos_iff_eq_zero' MeasureTheory.Measure.nonpos_iff_eq_zero'
@[simp]
theorem measure_univ_eq_zero : μ univ = 0 ↔ μ = 0 :=
⟨fun h => bot_unique fun s => (h ▸ measure_mono (subset_univ s) : μ s ≤ 0), fun h =>
h.symm ▸ rfl⟩
#align measure_theory.measure.measure_univ_eq_zero MeasureTheory.Measure.measure_univ_eq_zero
theorem measure_univ_ne_zero : μ univ ≠ 0 ↔ μ ≠ 0 :=
measure_univ_eq_zero.not
#align measure_theory.measure.measure_univ_ne_zero MeasureTheory.Measure.measure_univ_ne_zero
instance [NeZero μ] : NeZero (μ univ) := ⟨measure_univ_ne_zero.2 <| NeZero.ne μ⟩
@[simp]
theorem measure_univ_pos : 0 < μ univ ↔ μ ≠ 0 :=
pos_iff_ne_zero.trans measure_univ_ne_zero
#align measure_theory.measure.measure_univ_pos MeasureTheory.Measure.measure_univ_pos
/-! ### Pushforward and pullback -/
/-- Lift a linear map between `OuterMeasure` spaces such that for each measure `μ` every measurable
set is caratheodory-measurable w.r.t. `f μ` to a linear map between `Measure` spaces. -/
def liftLinear {m0 : MeasurableSpace α} (f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β)
(hf : ∀ μ : Measure α, ‹_› ≤ (f μ.toOuterMeasure).caratheodory) :
Measure α →ₗ[ℝ≥0∞] Measure β where
toFun μ := (f μ.toOuterMeasure).toMeasure (hf μ)
map_add' μ₁ μ₂ := ext fun s hs => by
simp only [map_add, coe_add, Pi.add_apply, toMeasure_apply, add_toOuterMeasure,
OuterMeasure.coe_add, hs]
map_smul' c μ := ext fun s hs => by
simp only [LinearMap.map_smulₛₗ, coe_smul, Pi.smul_apply,
toMeasure_apply, smul_toOuterMeasure (R := ℝ≥0∞), OuterMeasure.coe_smul (R := ℝ≥0∞),
smul_apply, hs]
#align measure_theory.measure.lift_linear MeasureTheory.Measure.liftLinear
lemma liftLinear_apply₀ {f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β} (hf) {s : Set β}
(hs : NullMeasurableSet s (liftLinear f hf μ)) : liftLinear f hf μ s = f μ.toOuterMeasure s :=
toMeasure_apply₀ _ (hf μ) hs
@[simp]
theorem liftLinear_apply {f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β} (hf) {s : Set β}
(hs : MeasurableSet s) : liftLinear f hf μ s = f μ.toOuterMeasure s :=
toMeasure_apply _ (hf μ) hs
#align measure_theory.measure.lift_linear_apply MeasureTheory.Measure.liftLinear_apply
theorem le_liftLinear_apply {f : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β} (hf) (s : Set β) :
f μ.toOuterMeasure s ≤ liftLinear f hf μ s :=
le_toMeasure_apply _ (hf μ) s
#align measure_theory.measure.le_lift_linear_apply MeasureTheory.Measure.le_liftLinear_apply
/-- The pushforward of a measure as a linear map. It is defined to be `0` if `f` is not
a measurable function. -/
def mapₗ [MeasurableSpace α] (f : α → β) : Measure α →ₗ[ℝ≥0∞] Measure β :=
if hf : Measurable f then
liftLinear (OuterMeasure.map f) fun μ _s hs t =>
le_toOuterMeasure_caratheodory μ _ (hf hs) (f ⁻¹' t)
else 0
#align measure_theory.measure.mapₗ MeasureTheory.Measure.mapₗ
theorem mapₗ_congr {f g : α → β} (hf : Measurable f) (hg : Measurable g) (h : f =ᵐ[μ] g) :
mapₗ f μ = mapₗ g μ := by
ext1 s hs
simpa only [mapₗ, hf, hg, hs, dif_pos, liftLinear_apply, OuterMeasure.map_apply]
using measure_congr (h.preimage s)
#align measure_theory.measure.mapₗ_congr MeasureTheory.Measure.mapₗ_congr
/-- The pushforward of a measure. It is defined to be `0` if `f` is not an almost everywhere
measurable function. -/
irreducible_def map [MeasurableSpace α] (f : α → β) (μ : Measure α) : Measure β :=
if hf : AEMeasurable f μ then mapₗ (hf.mk f) μ else 0
#align measure_theory.measure.map MeasureTheory.Measure.map
theorem mapₗ_mk_apply_of_aemeasurable {f : α → β} (hf : AEMeasurable f μ) :
mapₗ (hf.mk f) μ = map f μ := by simp [map, hf]
#align measure_theory.measure.mapₗ_mk_apply_of_ae_measurable MeasureTheory.Measure.mapₗ_mk_apply_of_aemeasurable
theorem mapₗ_apply_of_measurable {f : α → β} (hf : Measurable f) (μ : Measure α) :
mapₗ f μ = map f μ := by
simp only [← mapₗ_mk_apply_of_aemeasurable hf.aemeasurable]
exact mapₗ_congr hf hf.aemeasurable.measurable_mk hf.aemeasurable.ae_eq_mk
#align measure_theory.measure.mapₗ_apply_of_measurable MeasureTheory.Measure.mapₗ_apply_of_measurable
@[simp]
theorem map_add (μ ν : Measure α) {f : α → β} (hf : Measurable f) :
(μ + ν).map f = μ.map f + ν.map f := by simp [← mapₗ_apply_of_measurable hf]
#align measure_theory.measure.map_add MeasureTheory.Measure.map_add
@[simp]
theorem map_zero (f : α → β) : (0 : Measure α).map f = 0 := by
by_cases hf : AEMeasurable f (0 : Measure α) <;> simp [map, hf]
#align measure_theory.measure.map_zero MeasureTheory.Measure.map_zero
@[simp]
theorem map_of_not_aemeasurable {f : α → β} {μ : Measure α} (hf : ¬AEMeasurable f μ) :
μ.map f = 0 := by simp [map, hf]
#align measure_theory.measure.map_of_not_ae_measurable MeasureTheory.Measure.map_of_not_aemeasurable
theorem map_congr {f g : α → β} (h : f =ᵐ[μ] g) : Measure.map f μ = Measure.map g μ := by
by_cases hf : AEMeasurable f μ
· have hg : AEMeasurable g μ := hf.congr h
simp only [← mapₗ_mk_apply_of_aemeasurable hf, ← mapₗ_mk_apply_of_aemeasurable hg]
exact
mapₗ_congr hf.measurable_mk hg.measurable_mk (hf.ae_eq_mk.symm.trans (h.trans hg.ae_eq_mk))
· have hg : ¬AEMeasurable g μ := by simpa [← aemeasurable_congr h] using hf
simp [map_of_not_aemeasurable, hf, hg]
#align measure_theory.measure.map_congr MeasureTheory.Measure.map_congr
@[simp]
protected theorem map_smul (c : ℝ≥0∞) (μ : Measure α) (f : α → β) :
(c • μ).map f = c • μ.map f := by
rcases eq_or_ne c 0 with (rfl | hc); · simp
by_cases hf : AEMeasurable f μ
· have hfc : AEMeasurable f (c • μ) :=
⟨hf.mk f, hf.measurable_mk, (ae_smul_measure_iff hc).2 hf.ae_eq_mk⟩
simp only [← mapₗ_mk_apply_of_aemeasurable hf, ← mapₗ_mk_apply_of_aemeasurable hfc,
LinearMap.map_smulₛₗ, RingHom.id_apply]
congr 1
apply mapₗ_congr hfc.measurable_mk hf.measurable_mk
exact EventuallyEq.trans ((ae_smul_measure_iff hc).1 hfc.ae_eq_mk.symm) hf.ae_eq_mk
· have hfc : ¬AEMeasurable f (c • μ) := by
intro hfc
exact hf ⟨hfc.mk f, hfc.measurable_mk, (ae_smul_measure_iff hc).1 hfc.ae_eq_mk⟩
simp [map_of_not_aemeasurable hf, map_of_not_aemeasurable hfc]
#align measure_theory.measure.map_smul MeasureTheory.Measure.map_smul
@[simp]
protected theorem map_smul_nnreal (c : ℝ≥0) (μ : Measure α) (f : α → β) :
(c • μ).map f = c • μ.map f :=
μ.map_smul (c : ℝ≥0∞) f
#align measure_theory.measure.map_smul_nnreal MeasureTheory.Measure.map_smul_nnreal
variable {f : α → β}
lemma map_apply₀ {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
(hs : NullMeasurableSet s (map f μ)) : μ.map f s = μ (f ⁻¹' s) := by
rw [map, dif_pos hf, mapₗ, dif_pos hf.measurable_mk] at hs ⊢
rw [liftLinear_apply₀ _ hs, measure_congr (hf.ae_eq_mk.preimage s)]
rfl
/-- We can evaluate the pushforward on measurable sets. For non-measurable sets, see
`MeasureTheory.Measure.le_map_apply` and `MeasurableEquiv.map_apply`. -/
@[simp]
theorem map_apply_of_aemeasurable (hf : AEMeasurable f μ) {s : Set β} (hs : MeasurableSet s) :
μ.map f s = μ (f ⁻¹' s) := map_apply₀ hf hs.nullMeasurableSet
#align measure_theory.measure.map_apply_of_ae_measurable MeasureTheory.Measure.map_apply_of_aemeasurable
@[simp]
theorem map_apply (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
μ.map f s = μ (f ⁻¹' s) :=
map_apply_of_aemeasurable hf.aemeasurable hs
#align measure_theory.measure.map_apply MeasureTheory.Measure.map_apply
theorem map_toOuterMeasure (hf : AEMeasurable f μ) :
(μ.map f).toOuterMeasure = (OuterMeasure.map f μ.toOuterMeasure).trim := by
rw [← trimmed, OuterMeasure.trim_eq_trim_iff]
intro s hs
simp [hf, hs]
#align measure_theory.measure.map_to_outer_measure MeasureTheory.Measure.map_toOuterMeasure
@[simp] lemma map_eq_zero_iff (hf : AEMeasurable f μ) : μ.map f = 0 ↔ μ = 0 := by
simp_rw [← measure_univ_eq_zero, map_apply_of_aemeasurable hf .univ, preimage_univ]
@[simp] lemma mapₗ_eq_zero_iff (hf : Measurable f) : Measure.mapₗ f μ = 0 ↔ μ = 0 := by
rw [mapₗ_apply_of_measurable hf, map_eq_zero_iff hf.aemeasurable]
lemma map_ne_zero_iff (hf : AEMeasurable f μ) : μ.map f ≠ 0 ↔ μ ≠ 0 := (map_eq_zero_iff hf).not
lemma mapₗ_ne_zero_iff (hf : Measurable f) : Measure.mapₗ f μ ≠ 0 ↔ μ ≠ 0 :=
(mapₗ_eq_zero_iff hf).not
@[simp]
theorem map_id : map id μ = μ :=
ext fun _ => map_apply measurable_id
#align measure_theory.measure.map_id MeasureTheory.Measure.map_id
@[simp]
theorem map_id' : map (fun x => x) μ = μ :=
map_id
#align measure_theory.measure.map_id' MeasureTheory.Measure.map_id'
theorem map_map {g : β → γ} {f : α → β} (hg : Measurable g) (hf : Measurable f) :
(μ.map f).map g = μ.map (g ∘ f) :=
ext fun s hs => by simp [hf, hg, hs, hg hs, hg.comp hf, ← preimage_comp]
#align measure_theory.measure.map_map MeasureTheory.Measure.map_map
@[mono]
theorem map_mono {f : α → β} (h : μ ≤ ν) (hf : Measurable f) : μ.map f ≤ ν.map f :=
le_iff.2 fun s hs ↦ by simp [hf.aemeasurable, hs, h _]
#align measure_theory.measure.map_mono MeasureTheory.Measure.map_mono
/-- Even if `s` is not measurable, we can bound `map f μ s` from below.
See also `MeasurableEquiv.map_apply`. -/
theorem le_map_apply {f : α → β} (hf : AEMeasurable f μ) (s : Set β) : μ (f ⁻¹' s) ≤ μ.map f s :=
calc
μ (f ⁻¹' s) ≤ μ (f ⁻¹' toMeasurable (μ.map f) s) := by gcongr; apply subset_toMeasurable
_ = μ.map f (toMeasurable (μ.map f) s) :=
(map_apply_of_aemeasurable hf <| measurableSet_toMeasurable _ _).symm
_ = μ.map f s := measure_toMeasurable _
#align measure_theory.measure.le_map_apply MeasureTheory.Measure.le_map_apply
theorem le_map_apply_image {f : α → β} (hf : AEMeasurable f μ) (s : Set α) :
μ s ≤ μ.map f (f '' s) :=
(measure_mono (subset_preimage_image f s)).trans (le_map_apply hf _)
/-- Even if `s` is not measurable, `map f μ s = 0` implies that `μ (f ⁻¹' s) = 0`. -/
theorem preimage_null_of_map_null {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
(hs : μ.map f s = 0) : μ (f ⁻¹' s) = 0 :=
nonpos_iff_eq_zero.mp <| (le_map_apply hf s).trans_eq hs
#align measure_theory.measure.preimage_null_of_map_null MeasureTheory.Measure.preimage_null_of_map_null
theorem tendsto_ae_map {f : α → β} (hf : AEMeasurable f μ) : Tendsto f (ae μ) (ae (μ.map f)) :=
fun _ hs => preimage_null_of_map_null hf hs
#align measure_theory.measure.tendsto_ae_map MeasureTheory.Measure.tendsto_ae_map
/-- Pullback of a `Measure` as a linear map. If `f` sends each measurable set to a measurable
set, then for each measurable set `s` we have `comapₗ f μ s = μ (f '' s)`.
If the linearity is not needed, please use `comap` instead, which works for a larger class of
functions. -/
def comapₗ [MeasurableSpace α] (f : α → β) : Measure β →ₗ[ℝ≥0∞] Measure α :=
if hf : Injective f ∧ ∀ s, MeasurableSet s → MeasurableSet (f '' s) then
liftLinear (OuterMeasure.comap f) fun μ s hs t => by
simp only [OuterMeasure.comap_apply, image_inter hf.1, image_diff hf.1]
apply le_toOuterMeasure_caratheodory
exact hf.2 s hs
else 0
#align measure_theory.measure.comapₗ MeasureTheory.Measure.comapₗ
theorem comapₗ_apply {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)
(hfi : Injective f) (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β)
(hs : MeasurableSet s) : comapₗ f μ s = μ (f '' s) := by
rw [comapₗ, dif_pos, liftLinear_apply _ hs, OuterMeasure.comap_apply, coe_toOuterMeasure]
exact ⟨hfi, hf⟩
#align measure_theory.measure.comapₗ_apply MeasureTheory.Measure.comapₗ_apply
/-- Pullback of a `Measure`. If `f` sends each measurable set to a null-measurable set,
then for each measurable set `s` we have `comap f μ s = μ (f '' s)`. -/
def comap [MeasurableSpace α] (f : α → β) (μ : Measure β) : Measure α :=
if hf : Injective f ∧ ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ then
(OuterMeasure.comap f μ.toOuterMeasure).toMeasure fun s hs t => by
simp only [OuterMeasure.comap_apply, image_inter hf.1, image_diff hf.1]
exact (measure_inter_add_diff₀ _ (hf.2 s hs)).symm
else 0
#align measure_theory.measure.comap MeasureTheory.Measure.comap
theorem comap_apply₀ [MeasurableSpace α] (f : α → β) (μ : Measure β) (hfi : Injective f)
(hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)
(hs : NullMeasurableSet s (comap f μ)) : comap f μ s = μ (f '' s) := by
rw [comap, dif_pos (And.intro hfi hf)] at hs ⊢
rw [toMeasure_apply₀ _ _ hs, OuterMeasure.comap_apply, coe_toOuterMeasure]
#align measure_theory.measure.comap_apply₀ MeasureTheory.Measure.comap_apply₀
theorem le_comap_apply {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β) (μ : Measure β)
(hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ) (s : Set α) :
μ (f '' s) ≤ comap f μ s := by
rw [comap, dif_pos (And.intro hfi hf)]
exact le_toMeasure_apply _ _ _
#align measure_theory.measure.le_comap_apply MeasureTheory.Measure.le_comap_apply
theorem comap_apply {β} [MeasurableSpace α] {_mβ : MeasurableSpace β} (f : α → β)
(hfi : Injective f) (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β)
(hs : MeasurableSet s) : comap f μ s = μ (f '' s) :=
comap_apply₀ f μ hfi (fun s hs => (hf s hs).nullMeasurableSet) hs.nullMeasurableSet
#align measure_theory.measure.comap_apply MeasureTheory.Measure.comap_apply
theorem comapₗ_eq_comap {β} [MeasurableSpace α] {_mβ : MeasurableSpace β} (f : α → β)
(hfi : Injective f) (hf : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) (μ : Measure β)
(hs : MeasurableSet s) : comapₗ f μ s = comap f μ s :=
(comapₗ_apply f hfi hf μ hs).trans (comap_apply f hfi hf μ hs).symm
#align measure_theory.measure.comapₗ_eq_comap MeasureTheory.Measure.comapₗ_eq_comap
theorem measure_image_eq_zero_of_comap_eq_zero {β} [MeasurableSpace α] {_mβ : MeasurableSpace β}
(f : α → β) (μ : Measure β) (hfi : Injective f)
(hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ) {s : Set α} (hs : comap f μ s = 0) :
μ (f '' s) = 0 :=
le_antisymm ((le_comap_apply f μ hfi hf s).trans hs.le) (zero_le _)
#align measure_theory.measure.measure_image_eq_zero_of_comap_eq_zero MeasureTheory.Measure.measure_image_eq_zero_of_comap_eq_zero
theorem ae_eq_image_of_ae_eq_comap {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)
(μ : Measure β) (hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)
{s t : Set α} (hst : s =ᵐ[comap f μ] t) : f '' s =ᵐ[μ] f '' t := by
rw [EventuallyEq, ae_iff] at hst ⊢
have h_eq_α : { a : α | ¬s a = t a } = s \ t ∪ t \ s := by
ext1 x
simp only [eq_iff_iff, mem_setOf_eq, mem_union, mem_diff]
tauto
have h_eq_β : { a : β | ¬(f '' s) a = (f '' t) a } = f '' s \ f '' t ∪ f '' t \ f '' s := by
ext1 x
simp only [eq_iff_iff, mem_setOf_eq, mem_union, mem_diff]
tauto
rw [← Set.image_diff hfi, ← Set.image_diff hfi, ← Set.image_union] at h_eq_β
rw [h_eq_β]
rw [h_eq_α] at hst
exact measure_image_eq_zero_of_comap_eq_zero f μ hfi hf hst
#align measure_theory.measure.ae_eq_image_of_ae_eq_comap MeasureTheory.Measure.ae_eq_image_of_ae_eq_comap
theorem NullMeasurableSet.image {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β)
(μ : Measure β) (hfi : Injective f) (hf : ∀ s, MeasurableSet s → NullMeasurableSet (f '' s) μ)
{s : Set α} (hs : NullMeasurableSet s (μ.comap f)) : NullMeasurableSet (f '' s) μ := by
refine ⟨toMeasurable μ (f '' toMeasurable (μ.comap f) s), measurableSet_toMeasurable _ _, ?_⟩
refine EventuallyEq.trans ?_ (NullMeasurableSet.toMeasurable_ae_eq ?_).symm
swap
· exact hf _ (measurableSet_toMeasurable _ _)
have h : toMeasurable (comap f μ) s =ᵐ[comap f μ] s :=
NullMeasurableSet.toMeasurable_ae_eq hs
exact ae_eq_image_of_ae_eq_comap f μ hfi hf h.symm
#align measure_theory.measure.null_measurable_set.image MeasureTheory.Measure.NullMeasurableSet.image
theorem comap_preimage {β} [MeasurableSpace α] {mβ : MeasurableSpace β} (f : α → β) (μ : Measure β)
{s : Set β} (hf : Injective f) (hf' : Measurable f)
(h : ∀ t, MeasurableSet t → NullMeasurableSet (f '' t) μ) (hs : MeasurableSet s) :
μ.comap f (f ⁻¹' s) = μ (s ∩ range f) := by
rw [comap_apply₀ _ _ hf h (hf' hs).nullMeasurableSet, image_preimage_eq_inter_range]
#align measure_theory.measure.comap_preimage MeasureTheory.Measure.comap_preimage
section Sum
/-- Sum of an indexed family of measures. -/
noncomputable def sum (f : ι → Measure α) : Measure α :=
(OuterMeasure.sum fun i => (f i).toOuterMeasure).toMeasure <|
le_trans (le_iInf fun _ => le_toOuterMeasure_caratheodory _)
(OuterMeasure.le_sum_caratheodory _)
#align measure_theory.measure.sum MeasureTheory.Measure.sum
theorem le_sum_apply (f : ι → Measure α) (s : Set α) : ∑' i, f i s ≤ sum f s :=
le_toMeasure_apply _ _ _
#align measure_theory.measure.le_sum_apply MeasureTheory.Measure.le_sum_apply
@[simp]
theorem sum_apply (f : ι → Measure α) {s : Set α} (hs : MeasurableSet s) :
sum f s = ∑' i, f i s :=
toMeasure_apply _ _ hs
#align measure_theory.measure.sum_apply MeasureTheory.Measure.sum_apply
theorem sum_apply₀ (f : ι → Measure α) {s : Set α} (hs : NullMeasurableSet s (sum f)) :
sum f s = ∑' i, f i s := by
apply le_antisymm ?_ (le_sum_apply _ _)
rcases hs.exists_measurable_subset_ae_eq with ⟨t, ts, t_meas, ht⟩
calc
sum f s = sum f t := measure_congr ht.symm
_ = ∑' i, f i t := sum_apply _ t_meas
_ ≤ ∑' i, f i s := ENNReal.tsum_le_tsum fun i ↦ measure_mono ts
/-! For the next theorem, the countability assumption is necessary. For a counterexample, consider
an uncountable space, with a distinguished point `x₀`, and the sigma-algebra made of countable sets
not containing `x₀`, and their complements. All points but `x₀` are measurable.
Consider the sum of the Dirac masses at points different from `x₀`, and `s = x₀`. For any Dirac mass
`δ_x`, we have `δ_x (x₀) = 0`, so `∑' x, δ_x (x₀) = 0`. On the other hand, the measure `sum δ_x`
gives mass one to each point different from `x₀`, so it gives infinite mass to any measurable set
containing `x₀` (as such a set is uncountable), and by outer regularity one get `sum δ_x {x₀} = ∞`.
-/
theorem sum_apply_of_countable [Countable ι] (f : ι → Measure α) (s : Set α) :
sum f s = ∑' i, f i s := by
apply le_antisymm ?_ (le_sum_apply _ _)
rcases exists_measurable_superset_forall_eq f s with ⟨t, hst, htm, ht⟩
calc
sum f s ≤ sum f t := measure_mono hst
_ = ∑' i, f i t := sum_apply _ htm
_ = ∑' i, f i s := by simp [ht]
theorem le_sum (μ : ι → Measure α) (i : ι) : μ i ≤ sum μ :=
le_iff.2 fun s hs ↦ by simpa only [sum_apply μ hs] using ENNReal.le_tsum i
#align measure_theory.measure.le_sum MeasureTheory.Measure.le_sum
@[simp]
theorem sum_apply_eq_zero [Countable ι] {μ : ι → Measure α} {s : Set α} :
sum μ s = 0 ↔ ∀ i, μ i s = 0 := by
simp [sum_apply_of_countable]
#align measure_theory.measure.sum_apply_eq_zero MeasureTheory.Measure.sum_apply_eq_zero
theorem sum_apply_eq_zero' {μ : ι → Measure α} {s : Set α} (hs : MeasurableSet s) :
sum μ s = 0 ↔ ∀ i, μ i s = 0 := by simp [hs]
#align measure_theory.measure.sum_apply_eq_zero' MeasureTheory.Measure.sum_apply_eq_zero'
@[simp]
lemma sum_zero : Measure.sum (fun (_ : ι) ↦ (0 : Measure α)) = 0 := by
ext s hs
simp [Measure.sum_apply _ hs]
theorem sum_sum {ι' : Type*} (μ : ι → ι' → Measure α) :
(sum fun n => sum (μ n)) = sum (fun (p : ι × ι') ↦ μ p.1 p.2) := by
ext1 s hs
simp [sum_apply _ hs, ENNReal.tsum_prod']
theorem sum_comm {ι' : Type*} (μ : ι → ι' → Measure α) :
(sum fun n => sum (μ n)) = sum fun m => sum fun n => μ n m := by
ext1 s hs
simp_rw [sum_apply _ hs]
rw [ENNReal.tsum_comm]
#align measure_theory.measure.sum_comm MeasureTheory.Measure.sum_comm
theorem ae_sum_iff [Countable ι] {μ : ι → Measure α} {p : α → Prop} :
(∀ᵐ x ∂sum μ, p x) ↔ ∀ i, ∀ᵐ x ∂μ i, p x :=
sum_apply_eq_zero
#align measure_theory.measure.ae_sum_iff MeasureTheory.Measure.ae_sum_iff
theorem ae_sum_iff' {μ : ι → Measure α} {p : α → Prop} (h : MeasurableSet { x | p x }) :
(∀ᵐ x ∂sum μ, p x) ↔ ∀ i, ∀ᵐ x ∂μ i, p x :=
sum_apply_eq_zero' h.compl
#align measure_theory.measure.ae_sum_iff' MeasureTheory.Measure.ae_sum_iff'
@[simp]
theorem sum_fintype [Fintype ι] (μ : ι → Measure α) : sum μ = ∑ i, μ i := by
ext1 s hs
simp only [sum_apply, finset_sum_apply, hs, tsum_fintype]
#align measure_theory.measure.sum_fintype MeasureTheory.Measure.sum_fintype
theorem sum_coe_finset (s : Finset ι) (μ : ι → Measure α) :
(sum fun i : s => μ i) = ∑ i ∈ s, μ i := by rw [sum_fintype, Finset.sum_coe_sort s μ]
#align measure_theory.measure.sum_coe_finset MeasureTheory.Measure.sum_coe_finset
@[simp]
theorem ae_sum_eq [Countable ι] (μ : ι → Measure α) : ae (sum μ) = ⨆ i, ae (μ i) :=
Filter.ext fun _ => ae_sum_iff.trans mem_iSup.symm
#align measure_theory.measure.ae_sum_eq MeasureTheory.Measure.ae_sum_eq
theorem sum_bool (f : Bool → Measure α) : sum f = f true + f false := by
rw [sum_fintype, Fintype.sum_bool]
#align measure_theory.measure.sum_bool MeasureTheory.Measure.sum_bool
theorem sum_cond (μ ν : Measure α) : (sum fun b => cond b μ ν) = μ + ν :=
sum_bool _
#align measure_theory.measure.sum_cond MeasureTheory.Measure.sum_cond
@[simp]
theorem sum_of_empty [IsEmpty ι] (μ : ι → Measure α) : sum μ = 0 := by
rw [← measure_univ_eq_zero, sum_apply _ MeasurableSet.univ, tsum_empty]
#align measure_theory.measure.sum_of_empty MeasureTheory.Measure.sum_of_empty
theorem sum_add_sum_compl (s : Set ι) (μ : ι → Measure α) :
((sum fun i : s => μ i) + sum fun i : ↥sᶜ => μ i) = sum μ := by
ext1 t ht
simp only [add_apply, sum_apply _ ht]
exact tsum_add_tsum_compl (f := fun i => μ i t) ENNReal.summable ENNReal.summable
#align measure_theory.measure.sum_add_sum_compl MeasureTheory.Measure.sum_add_sum_compl
theorem sum_congr {μ ν : ℕ → Measure α} (h : ∀ n, μ n = ν n) : sum μ = sum ν :=
congr_arg sum (funext h)
#align measure_theory.measure.sum_congr MeasureTheory.Measure.sum_congr
theorem sum_add_sum {ι : Type*} (μ ν : ι → Measure α) : sum μ + sum ν = sum fun n => μ n + ν n := by
ext1 s hs
simp only [add_apply, sum_apply _ hs, Pi.add_apply, coe_add,
tsum_add ENNReal.summable ENNReal.summable]
#align measure_theory.measure.sum_add_sum MeasureTheory.Measure.sum_add_sum
@[simp] lemma sum_comp_equiv {ι ι' : Type*} (e : ι' ≃ ι) (m : ι → Measure α) :
sum (m ∘ e) = sum m := by
ext s hs
simpa [hs, sum_apply] using e.tsum_eq (fun n ↦ m n s)
@[simp] lemma sum_extend_zero {ι ι' : Type*} {f : ι → ι'} (hf : Injective f) (m : ι → Measure α) :
sum (Function.extend f m 0) = sum m := by
ext s hs
simp [*, Function.apply_extend (fun μ : Measure α ↦ μ s)]
end Sum
/-! ### Absolute continuity -/
/-- We say that `μ` is absolutely continuous with respect to `ν`, or that `μ` is dominated by `ν`,
if `ν(A) = 0` implies that `μ(A) = 0`. -/
def AbsolutelyContinuous {_m0 : MeasurableSpace α} (μ ν : Measure α) : Prop :=
∀ ⦃s : Set α⦄, ν s = 0 → μ s = 0
#align measure_theory.measure.absolutely_continuous MeasureTheory.Measure.AbsolutelyContinuous
@[inherit_doc MeasureTheory.Measure.AbsolutelyContinuous]
scoped[MeasureTheory] infixl:50 " ≪ " => MeasureTheory.Measure.AbsolutelyContinuous
theorem absolutelyContinuous_of_le (h : μ ≤ ν) : μ ≪ ν := fun s hs =>
nonpos_iff_eq_zero.1 <| hs ▸ le_iff'.1 h s
#align measure_theory.measure.absolutely_continuous_of_le MeasureTheory.Measure.absolutelyContinuous_of_le
alias _root_.LE.le.absolutelyContinuous := absolutelyContinuous_of_le
#align has_le.le.absolutely_continuous LE.le.absolutelyContinuous
theorem absolutelyContinuous_of_eq (h : μ = ν) : μ ≪ ν :=
h.le.absolutelyContinuous
#align measure_theory.measure.absolutely_continuous_of_eq MeasureTheory.Measure.absolutelyContinuous_of_eq
alias _root_.Eq.absolutelyContinuous := absolutelyContinuous_of_eq
#align eq.absolutely_continuous Eq.absolutelyContinuous
namespace AbsolutelyContinuous
theorem mk (h : ∀ ⦃s : Set α⦄, MeasurableSet s → ν s = 0 → μ s = 0) : μ ≪ ν := by
intro s hs
rcases exists_measurable_superset_of_null hs with ⟨t, h1t, h2t, h3t⟩
exact measure_mono_null h1t (h h2t h3t)
#align measure_theory.measure.absolutely_continuous.mk MeasureTheory.Measure.AbsolutelyContinuous.mk
@[refl]
protected theorem refl {_m0 : MeasurableSpace α} (μ : Measure α) : μ ≪ μ :=
rfl.absolutelyContinuous
#align measure_theory.measure.absolutely_continuous.refl MeasureTheory.Measure.AbsolutelyContinuous.refl
protected theorem rfl : μ ≪ μ := fun _s hs => hs
#align measure_theory.measure.absolutely_continuous.rfl MeasureTheory.Measure.AbsolutelyContinuous.rfl
instance instIsRefl [MeasurableSpace α] : IsRefl (Measure α) (· ≪ ·) :=
⟨fun _ => AbsolutelyContinuous.rfl⟩
#align measure_theory.measure.absolutely_continuous.is_refl MeasureTheory.Measure.AbsolutelyContinuous.instIsRefl
@[simp]
protected lemma zero (μ : Measure α) : 0 ≪ μ := fun s _ ↦ by simp
@[trans]
protected theorem trans (h1 : μ₁ ≪ μ₂) (h2 : μ₂ ≪ μ₃) : μ₁ ≪ μ₃ := fun _s hs => h1 <| h2 hs
#align measure_theory.measure.absolutely_continuous.trans MeasureTheory.Measure.AbsolutelyContinuous.trans
@[mono]
protected theorem map (h : μ ≪ ν) {f : α → β} (hf : Measurable f) : μ.map f ≪ ν.map f :=
AbsolutelyContinuous.mk fun s hs => by simpa [hf, hs] using @h _
#align measure_theory.measure.absolutely_continuous.map MeasureTheory.Measure.AbsolutelyContinuous.map
protected theorem smul [Monoid R] [DistribMulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
(h : μ ≪ ν) (c : R) : c • μ ≪ ν := fun s hνs => by
simp only [h hνs, smul_eq_mul, smul_apply, smul_zero]
#align measure_theory.measure.absolutely_continuous.smul MeasureTheory.Measure.AbsolutelyContinuous.smul
protected lemma add (h1 : μ₁ ≪ ν) (h2 : μ₂ ≪ ν') : μ₁ + μ₂ ≪ ν + ν' := by
intro s hs
simp only [coe_add, Pi.add_apply, add_eq_zero] at hs ⊢
exact ⟨h1 hs.1, h2 hs.2⟩
lemma add_left_iff {μ₁ μ₂ ν : Measure α} :
μ₁ + μ₂ ≪ ν ↔ μ₁ ≪ ν ∧ μ₂ ≪ ν := by
refine ⟨fun h ↦ ?_, fun h ↦ (h.1.add h.2).trans ?_⟩
· have : ∀ s, ν s = 0 → μ₁ s = 0 ∧ μ₂ s = 0 := by intro s hs0; simpa using h hs0
exact ⟨fun s hs0 ↦ (this s hs0).1, fun s hs0 ↦ (this s hs0).2⟩
· have : ν + ν = 2 • ν := by ext; simp [two_mul]
rw [this]
exact AbsolutelyContinuous.rfl.smul 2
lemma add_right (h1 : μ ≪ ν) (ν' : Measure α) : μ ≪ ν + ν' := by
intro s hs
simp only [coe_add, Pi.add_apply, add_eq_zero] at hs ⊢
exact h1 hs.1
end AbsolutelyContinuous
@[simp]
lemma absolutelyContinuous_zero_iff : μ ≪ 0 ↔ μ = 0 :=
⟨fun h ↦ measure_univ_eq_zero.mp (h rfl), fun h ↦ h.symm ▸ AbsolutelyContinuous.zero _⟩
alias absolutelyContinuous_refl := AbsolutelyContinuous.refl
alias absolutelyContinuous_rfl := AbsolutelyContinuous.rfl
lemma absolutelyContinuous_sum_left {μs : ι → Measure α} (hμs : ∀ i, μs i ≪ ν) :
Measure.sum μs ≪ ν :=
AbsolutelyContinuous.mk fun s hs hs0 ↦ by simp [sum_apply _ hs, fun i ↦ hμs i hs0]
lemma absolutelyContinuous_sum_right {μs : ι → Measure α} (i : ι) (hνμ : ν ≪ μs i) :
ν ≪ Measure.sum μs := by
refine AbsolutelyContinuous.mk fun s hs hs0 ↦ ?_
simp only [sum_apply _ hs, ENNReal.tsum_eq_zero] at hs0
exact hνμ (hs0 i)
theorem absolutelyContinuous_of_le_smul {μ' : Measure α} {c : ℝ≥0∞} (hμ'_le : μ' ≤ c • μ) :
μ' ≪ μ :=
(Measure.absolutelyContinuous_of_le hμ'_le).trans (Measure.AbsolutelyContinuous.rfl.smul c)
#align measure_theory.measure.absolutely_continuous_of_le_smul MeasureTheory.Measure.absolutelyContinuous_of_le_smul
lemma smul_absolutelyContinuous {c : ℝ≥0∞} : c • μ ≪ μ := absolutelyContinuous_of_le_smul le_rfl
lemma absolutelyContinuous_smul {c : ℝ≥0∞} (hc : c ≠ 0) : μ ≪ c • μ := by
simp [AbsolutelyContinuous, hc]
theorem ae_le_iff_absolutelyContinuous : ae μ ≤ ae ν ↔ μ ≪ ν :=
⟨fun h s => by
rw [measure_zero_iff_ae_nmem, measure_zero_iff_ae_nmem]
exact fun hs => h hs, fun h s hs => h hs⟩
#align measure_theory.measure.ae_le_iff_absolutely_continuous MeasureTheory.Measure.ae_le_iff_absolutelyContinuous
alias ⟨_root_.LE.le.absolutelyContinuous_of_ae, AbsolutelyContinuous.ae_le⟩ :=
ae_le_iff_absolutelyContinuous
#align has_le.le.absolutely_continuous_of_ae LE.le.absolutelyContinuous_of_ae
#align measure_theory.measure.absolutely_continuous.ae_le MeasureTheory.Measure.AbsolutelyContinuous.ae_le
alias ae_mono' := AbsolutelyContinuous.ae_le
#align measure_theory.measure.ae_mono' MeasureTheory.Measure.ae_mono'
theorem AbsolutelyContinuous.ae_eq (h : μ ≪ ν) {f g : α → δ} (h' : f =ᵐ[ν] g) : f =ᵐ[μ] g :=
h.ae_le h'
#align measure_theory.measure.absolutely_continuous.ae_eq MeasureTheory.Measure.AbsolutelyContinuous.ae_eq
protected theorem _root_.MeasureTheory.AEDisjoint.of_absolutelyContinuous
(h : AEDisjoint μ s t) {ν : Measure α} (h' : ν ≪ μ) :
AEDisjoint ν s t := h' h
protected theorem _root_.MeasureTheory.AEDisjoint.of_le
(h : AEDisjoint μ s t) {ν : Measure α} (h' : ν ≤ μ) :
AEDisjoint ν s t :=
h.of_absolutelyContinuous (Measure.absolutelyContinuous_of_le h')
/-! ### Quasi measure preserving maps (a.k.a. non-singular maps) -/
/-- A map `f : α → β` is said to be *quasi measure preserving* (a.k.a. non-singular) w.r.t. measures
`μa` and `μb` if it is measurable and `μb s = 0` implies `μa (f ⁻¹' s) = 0`. -/
structure QuasiMeasurePreserving {m0 : MeasurableSpace α} (f : α → β)
(μa : Measure α := by volume_tac)
(μb : Measure β := by volume_tac) : Prop where
protected measurable : Measurable f
protected absolutelyContinuous : μa.map f ≪ μb
#align measure_theory.measure.quasi_measure_preserving MeasureTheory.Measure.QuasiMeasurePreserving
#align measure_theory.measure.quasi_measure_preserving.measurable MeasureTheory.Measure.QuasiMeasurePreserving.measurable
#align measure_theory.measure.quasi_measure_preserving.absolutely_continuous MeasureTheory.Measure.QuasiMeasurePreserving.absolutelyContinuous
namespace QuasiMeasurePreserving
protected theorem id {_m0 : MeasurableSpace α} (μ : Measure α) : QuasiMeasurePreserving id μ μ :=
⟨measurable_id, map_id.absolutelyContinuous⟩
#align measure_theory.measure.quasi_measure_preserving.id MeasureTheory.Measure.QuasiMeasurePreserving.id
variable {μa μa' : Measure α} {μb μb' : Measure β} {μc : Measure γ} {f : α → β}
protected theorem _root_.Measurable.quasiMeasurePreserving
{_m0 : MeasurableSpace α} (hf : Measurable f) (μ : Measure α) :
QuasiMeasurePreserving f μ (μ.map f) :=
⟨hf, AbsolutelyContinuous.rfl⟩
#align measurable.quasi_measure_preserving Measurable.quasiMeasurePreserving
theorem mono_left (h : QuasiMeasurePreserving f μa μb) (ha : μa' ≪ μa) :
QuasiMeasurePreserving f μa' μb :=
⟨h.1, (ha.map h.1).trans h.2⟩
#align measure_theory.measure.quasi_measure_preserving.mono_left MeasureTheory.Measure.QuasiMeasurePreserving.mono_left
theorem mono_right (h : QuasiMeasurePreserving f μa μb) (ha : μb ≪ μb') :
QuasiMeasurePreserving f μa μb' :=
⟨h.1, h.2.trans ha⟩
#align measure_theory.measure.quasi_measure_preserving.mono_right MeasureTheory.Measure.QuasiMeasurePreserving.mono_right
@[mono]
theorem mono (ha : μa' ≪ μa) (hb : μb ≪ μb') (h : QuasiMeasurePreserving f μa μb) :
QuasiMeasurePreserving f μa' μb' :=
(h.mono_left ha).mono_right hb
#align measure_theory.measure.quasi_measure_preserving.mono MeasureTheory.Measure.QuasiMeasurePreserving.mono
protected theorem comp {g : β → γ} {f : α → β} (hg : QuasiMeasurePreserving g μb μc)
(hf : QuasiMeasurePreserving f μa μb) : QuasiMeasurePreserving (g ∘ f) μa μc :=
⟨hg.measurable.comp hf.measurable, by
rw [← map_map hg.1 hf.1]
exact (hf.2.map hg.1).trans hg.2⟩
#align measure_theory.measure.quasi_measure_preserving.comp MeasureTheory.Measure.QuasiMeasurePreserving.comp
protected theorem iterate {f : α → α} (hf : QuasiMeasurePreserving f μa μa) :
∀ n, QuasiMeasurePreserving f^[n] μa μa
| 0 => QuasiMeasurePreserving.id μa
| n + 1 => (hf.iterate n).comp hf
#align measure_theory.measure.quasi_measure_preserving.iterate MeasureTheory.Measure.QuasiMeasurePreserving.iterate
protected theorem aemeasurable (hf : QuasiMeasurePreserving f μa μb) : AEMeasurable f μa :=
hf.1.aemeasurable
#align measure_theory.measure.quasi_measure_preserving.ae_measurable MeasureTheory.Measure.QuasiMeasurePreserving.aemeasurable
theorem ae_map_le (h : QuasiMeasurePreserving f μa μb) : ae (μa.map f) ≤ ae μb :=
h.2.ae_le
#align measure_theory.measure.quasi_measure_preserving.ae_map_le MeasureTheory.Measure.QuasiMeasurePreserving.ae_map_le
theorem tendsto_ae (h : QuasiMeasurePreserving f μa μb) : Tendsto f (ae μa) (ae μb) :=
(tendsto_ae_map h.aemeasurable).mono_right h.ae_map_le
#align measure_theory.measure.quasi_measure_preserving.tendsto_ae MeasureTheory.Measure.QuasiMeasurePreserving.tendsto_ae
theorem ae (h : QuasiMeasurePreserving f μa μb) {p : β → Prop} (hg : ∀ᵐ x ∂μb, p x) :
∀ᵐ x ∂μa, p (f x) :=
h.tendsto_ae hg
#align measure_theory.measure.quasi_measure_preserving.ae MeasureTheory.Measure.QuasiMeasurePreserving.ae
theorem ae_eq (h : QuasiMeasurePreserving f μa μb) {g₁ g₂ : β → δ} (hg : g₁ =ᵐ[μb] g₂) :
g₁ ∘ f =ᵐ[μa] g₂ ∘ f :=
h.ae hg
#align measure_theory.measure.quasi_measure_preserving.ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.ae_eq
theorem preimage_null (h : QuasiMeasurePreserving f μa μb) {s : Set β} (hs : μb s = 0) :
μa (f ⁻¹' s) = 0 :=
preimage_null_of_map_null h.aemeasurable (h.2 hs)
#align measure_theory.measure.quasi_measure_preserving.preimage_null MeasureTheory.Measure.QuasiMeasurePreserving.preimage_null
theorem preimage_mono_ae {s t : Set β} (hf : QuasiMeasurePreserving f μa μb) (h : s ≤ᵐ[μb] t) :
f ⁻¹' s ≤ᵐ[μa] f ⁻¹' t :=
eventually_map.mp <|
Eventually.filter_mono (tendsto_ae_map hf.aemeasurable) (Eventually.filter_mono hf.ae_map_le h)
#align measure_theory.measure.quasi_measure_preserving.preimage_mono_ae MeasureTheory.Measure.QuasiMeasurePreserving.preimage_mono_ae
theorem preimage_ae_eq {s t : Set β} (hf : QuasiMeasurePreserving f μa μb) (h : s =ᵐ[μb] t) :
f ⁻¹' s =ᵐ[μa] f ⁻¹' t :=
EventuallyLE.antisymm (hf.preimage_mono_ae h.le) (hf.preimage_mono_ae h.symm.le)
#align measure_theory.measure.quasi_measure_preserving.preimage_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.preimage_ae_eq
theorem preimage_iterate_ae_eq {s : Set α} {f : α → α} (hf : QuasiMeasurePreserving f μ μ) (k : ℕ)
(hs : f ⁻¹' s =ᵐ[μ] s) : f^[k] ⁻¹' s =ᵐ[μ] s := by
induction' k with k ih; · rfl
rw [iterate_succ, preimage_comp]
exact EventuallyEq.trans (hf.preimage_ae_eq ih) hs
#align measure_theory.measure.quasi_measure_preserving.preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.preimage_iterate_ae_eq
theorem image_zpow_ae_eq {s : Set α} {e : α ≃ α} (he : QuasiMeasurePreserving e μ μ)
(he' : QuasiMeasurePreserving e.symm μ μ) (k : ℤ) (hs : e '' s =ᵐ[μ] s) :
(⇑(e ^ k)) '' s =ᵐ[μ] s := by
rw [Equiv.image_eq_preimage]
obtain ⟨k, rfl | rfl⟩ := k.eq_nat_or_neg
· replace hs : (⇑e⁻¹) ⁻¹' s =ᵐ[μ] s := by rwa [Equiv.image_eq_preimage] at hs
replace he' : (⇑e⁻¹)^[k] ⁻¹' s =ᵐ[μ] s := he'.preimage_iterate_ae_eq k hs
rwa [Equiv.Perm.iterate_eq_pow e⁻¹ k, inv_pow e k] at he'
· rw [zpow_neg, zpow_natCast]
replace hs : e ⁻¹' s =ᵐ[μ] s := by
convert he.preimage_ae_eq hs.symm
rw [Equiv.preimage_image]
replace he : (⇑e)^[k] ⁻¹' s =ᵐ[μ] s := he.preimage_iterate_ae_eq k hs
rwa [Equiv.Perm.iterate_eq_pow e k] at he
#align measure_theory.measure.quasi_measure_preserving.image_zpow_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.image_zpow_ae_eq
-- Need to specify `α := Set α` below because of diamond; see #19041
theorem limsup_preimage_iterate_ae_eq {f : α → α} (hf : QuasiMeasurePreserving f μ μ)
(hs : f ⁻¹' s =ᵐ[μ] s) : limsup (α := Set α) (fun n => (preimage f)^[n] s) atTop =ᵐ[μ] s :=
haveI : ∀ n, (preimage f)^[n] s =ᵐ[μ] s := by
intro n
induction' n with n ih
· rfl
simpa only [iterate_succ', comp_apply] using ae_eq_trans (hf.ae_eq ih) hs
(limsup_ae_eq_of_forall_ae_eq (fun n => (preimage f)^[n] s) this).trans (ae_eq_refl _)
#align measure_theory.measure.quasi_measure_preserving.limsup_preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.limsup_preimage_iterate_ae_eq
-- Need to specify `α := Set α` below because of diamond; see #19041
theorem liminf_preimage_iterate_ae_eq {f : α → α} (hf : QuasiMeasurePreserving f μ μ)
(hs : f ⁻¹' s =ᵐ[μ] s) : liminf (α := Set α) (fun n => (preimage f)^[n] s) atTop =ᵐ[μ] s := by
rw [← ae_eq_set_compl_compl, @Filter.liminf_compl (Set α)]
rw [← ae_eq_set_compl_compl, ← preimage_compl] at hs
convert hf.limsup_preimage_iterate_ae_eq hs
ext1 n
simp only [← Set.preimage_iterate_eq, comp_apply, preimage_compl]
#align measure_theory.measure.quasi_measure_preserving.liminf_preimage_iterate_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.liminf_preimage_iterate_ae_eq
/-- By replacing a measurable set that is almost invariant with the `limsup` of its preimages, we
obtain a measurable set that is almost equal and strictly invariant.
(The `liminf` would work just as well.) -/
theorem exists_preimage_eq_of_preimage_ae {f : α → α} (h : QuasiMeasurePreserving f μ μ)
(hs : MeasurableSet s) (hs' : f ⁻¹' s =ᵐ[μ] s) :
∃ t : Set α, MeasurableSet t ∧ t =ᵐ[μ] s ∧ f ⁻¹' t = t :=
⟨limsup (fun n => (preimage f)^[n] s) atTop,
MeasurableSet.measurableSet_limsup fun n =>
preimage_iterate_eq ▸ h.measurable.iterate n hs,
h.limsup_preimage_iterate_ae_eq hs',
Filter.CompleteLatticeHom.apply_limsup_iterate (CompleteLatticeHom.setPreimage f) s⟩
#align measure_theory.measure.quasi_measure_preserving.exists_preimage_eq_of_preimage_ae MeasureTheory.Measure.QuasiMeasurePreserving.exists_preimage_eq_of_preimage_ae
open Pointwise
@[to_additive]
theorem smul_ae_eq_of_ae_eq {G α : Type*} [Group G] [MulAction G α] [MeasurableSpace α]
{s t : Set α} {μ : Measure α} (g : G)
(h_qmp : QuasiMeasurePreserving (g⁻¹ • · : α → α) μ μ)
(h_ae_eq : s =ᵐ[μ] t) : (g • s : Set α) =ᵐ[μ] (g • t : Set α) := by
simpa only [← preimage_smul_inv] using h_qmp.ae_eq h_ae_eq
#align measure_theory.measure.quasi_measure_preserving.smul_ae_eq_of_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.smul_ae_eq_of_ae_eq
#align measure_theory.measure.quasi_measure_preserving.vadd_ae_eq_of_ae_eq MeasureTheory.Measure.QuasiMeasurePreserving.vadd_ae_eq_of_ae_eq
end QuasiMeasurePreserving
section Pointwise
open Pointwise
@[to_additive]
theorem pairwise_aedisjoint_of_aedisjoint_forall_ne_one {G α : Type*} [Group G] [MulAction G α]
[MeasurableSpace α] {μ : Measure α} {s : Set α}
(h_ae_disjoint : ∀ g ≠ (1 : G), AEDisjoint μ (g • s) s)
(h_qmp : ∀ g : G, QuasiMeasurePreserving (g • ·) μ μ) :
Pairwise (AEDisjoint μ on fun g : G => g • s) := by
intro g₁ g₂ hg
let g := g₂⁻¹ * g₁
replace hg : g ≠ 1 := by
rw [Ne, inv_mul_eq_one]
exact hg.symm
have : (g₂⁻¹ • ·) ⁻¹' (g • s ∩ s) = g₁ • s ∩ g₂ • s := by
rw [preimage_eq_iff_eq_image (MulAction.bijective g₂⁻¹), image_smul, smul_set_inter, smul_smul,
smul_smul, inv_mul_self, one_smul]
change μ (g₁ • s ∩ g₂ • s) = 0
exact this ▸ (h_qmp g₂⁻¹).preimage_null (h_ae_disjoint g hg)
#align measure_theory.measure.pairwise_ae_disjoint_of_ae_disjoint_forall_ne_one MeasureTheory.Measure.pairwise_aedisjoint_of_aedisjoint_forall_ne_one
#align measure_theory.measure.pairwise_ae_disjoint_of_ae_disjoint_forall_ne_zero MeasureTheory.Measure.pairwise_aedisjoint_of_aedisjoint_forall_ne_zero
end Pointwise
/-! ### The `cofinite` filter -/
/-- The filter of sets `s` such that `sᶜ` has finite measure. -/
def cofinite {m0 : MeasurableSpace α} (μ : Measure α) : Filter α :=
comk (μ · < ∞) (by simp) (fun t ht s hs ↦ (measure_mono hs).trans_lt ht) fun s hs t ht ↦
(measure_union_le s t).trans_lt <| ENNReal.add_lt_top.2 ⟨hs, ht⟩
#align measure_theory.measure.cofinite MeasureTheory.Measure.cofinite
theorem mem_cofinite : s ∈ μ.cofinite ↔ μ sᶜ < ∞ :=
Iff.rfl
#align measure_theory.measure.mem_cofinite MeasureTheory.Measure.mem_cofinite
theorem compl_mem_cofinite : sᶜ ∈ μ.cofinite ↔ μ s < ∞ := by rw [mem_cofinite, compl_compl]
#align measure_theory.measure.compl_mem_cofinite MeasureTheory.Measure.compl_mem_cofinite
theorem eventually_cofinite {p : α → Prop} : (∀ᶠ x in μ.cofinite, p x) ↔ μ { x | ¬p x } < ∞ :=
Iff.rfl
#align measure_theory.measure.eventually_cofinite MeasureTheory.Measure.eventually_cofinite
end Measure
open Measure
open MeasureTheory
protected theorem _root_.AEMeasurable.nullMeasurable {f : α → β} (h : AEMeasurable f μ) :
NullMeasurable f μ :=
let ⟨_g, hgm, hg⟩ := h; hgm.nullMeasurable.congr hg.symm
#align ae_measurable.null_measurable AEMeasurable.nullMeasurable
lemma _root_.AEMeasurable.nullMeasurableSet_preimage {f : α → β} {s : Set β}
(hf : AEMeasurable f μ) (hs : MeasurableSet s) : NullMeasurableSet (f ⁻¹' s) μ :=
hf.nullMeasurable hs
/-- The preimage of a null measurable set under a (quasi) measure preserving map is a null
measurable set. -/
theorem NullMeasurableSet.preimage {ν : Measure β} {f : α → β} {t : Set β}
(ht : NullMeasurableSet t ν) (hf : QuasiMeasurePreserving f μ ν) :
NullMeasurableSet (f ⁻¹' t) μ :=
⟨f ⁻¹' toMeasurable ν t, hf.measurable (measurableSet_toMeasurable _ _),
hf.ae_eq ht.toMeasurable_ae_eq.symm⟩
#align measure_theory.null_measurable_set.preimage MeasureTheory.NullMeasurableSet.preimage
theorem NullMeasurableSet.mono_ac (h : NullMeasurableSet s μ) (hle : ν ≪ μ) :
NullMeasurableSet s ν :=
h.preimage <| (QuasiMeasurePreserving.id μ).mono_left hle
#align measure_theory.null_measurable_set.mono_ac MeasureTheory.NullMeasurableSet.mono_ac
theorem NullMeasurableSet.mono (h : NullMeasurableSet s μ) (hle : ν ≤ μ) : NullMeasurableSet s ν :=
h.mono_ac hle.absolutelyContinuous
#align measure_theory.null_measurable_set.mono MeasureTheory.NullMeasurableSet.mono
theorem AEDisjoint.preimage {ν : Measure β} {f : α → β} {s t : Set β} (ht : AEDisjoint ν s t)
(hf : QuasiMeasurePreserving f μ ν) : AEDisjoint μ (f ⁻¹' s) (f ⁻¹' t) :=
hf.preimage_null ht
#align measure_theory.ae_disjoint.preimage MeasureTheory.AEDisjoint.preimage
@[simp]
theorem ae_eq_bot : ae μ = ⊥ ↔ μ = 0 := by
rw [← empty_mem_iff_bot, mem_ae_iff, compl_empty, measure_univ_eq_zero]
#align measure_theory.ae_eq_bot MeasureTheory.ae_eq_bot
@[simp]
theorem ae_neBot : (ae μ).NeBot ↔ μ ≠ 0 :=
neBot_iff.trans (not_congr ae_eq_bot)
#align measure_theory.ae_ne_bot MeasureTheory.ae_neBot
instance Measure.ae.neBot [NeZero μ] : (ae μ).NeBot := ae_neBot.2 <| NeZero.ne μ
@[simp]
theorem ae_zero {_m0 : MeasurableSpace α} : ae (0 : Measure α) = ⊥ :=
ae_eq_bot.2 rfl
#align measure_theory.ae_zero MeasureTheory.ae_zero
@[mono]
theorem ae_mono (h : μ ≤ ν) : ae μ ≤ ae ν :=
h.absolutelyContinuous.ae_le
#align measure_theory.ae_mono MeasureTheory.ae_mono
theorem mem_ae_map_iff {f : α → β} (hf : AEMeasurable f μ) {s : Set β} (hs : MeasurableSet s) :
s ∈ ae (μ.map f) ↔ f ⁻¹' s ∈ ae μ := by
simp only [mem_ae_iff, map_apply_of_aemeasurable hf hs.compl, preimage_compl]
#align measure_theory.mem_ae_map_iff MeasureTheory.mem_ae_map_iff
theorem mem_ae_of_mem_ae_map {f : α → β} (hf : AEMeasurable f μ) {s : Set β}
(hs : s ∈ ae (μ.map f)) : f ⁻¹' s ∈ ae μ :=
(tendsto_ae_map hf).eventually hs
#align measure_theory.mem_ae_of_mem_ae_map MeasureTheory.mem_ae_of_mem_ae_map
theorem ae_map_iff {f : α → β} (hf : AEMeasurable f μ) {p : β → Prop}
(hp : MeasurableSet { x | p x }) : (∀ᵐ y ∂μ.map f, p y) ↔ ∀ᵐ x ∂μ, p (f x) :=
mem_ae_map_iff hf hp
#align measure_theory.ae_map_iff MeasureTheory.ae_map_iff
theorem ae_of_ae_map {f : α → β} (hf : AEMeasurable f μ) {p : β → Prop} (h : ∀ᵐ y ∂μ.map f, p y) :
∀ᵐ x ∂μ, p (f x) :=
mem_ae_of_mem_ae_map hf h
#align measure_theory.ae_of_ae_map MeasureTheory.ae_of_ae_map
theorem ae_map_mem_range {m0 : MeasurableSpace α} (f : α → β) (hf : MeasurableSet (range f))
(μ : Measure α) : ∀ᵐ x ∂μ.map f, x ∈ range f := by
by_cases h : AEMeasurable f μ
· change range f ∈ ae (μ.map f)
rw [mem_ae_map_iff h hf]
filter_upwards using mem_range_self
· simp [map_of_not_aemeasurable h]
#align measure_theory.ae_map_mem_range MeasureTheory.ae_map_mem_range
section Intervals
theorem biSup_measure_Iic [Preorder α] {s : Set α} (hsc : s.Countable)
(hst : ∀ x : α, ∃ y ∈ s, x ≤ y) (hdir : DirectedOn (· ≤ ·) s) :
⨆ x ∈ s, μ (Iic x) = μ univ := by
rw [← measure_biUnion_eq_iSup hsc]
· congr
simp only [← bex_def] at hst
exact iUnion₂_eq_univ_iff.2 hst
· exact directedOn_iff_directed.2 (hdir.directed_val.mono_comp _ fun x y => Iic_subset_Iic.2)
#align measure_theory.bsupr_measure_Iic MeasureTheory.biSup_measure_Iic
theorem tendsto_measure_Ico_atTop [SemilatticeSup α] [NoMaxOrder α]
[(atTop : Filter α).IsCountablyGenerated] (μ : Measure α) (a : α) :
Tendsto (fun x => μ (Ico a x)) atTop (𝓝 (μ (Ici a))) := by
haveI : Nonempty α := ⟨a⟩
have h_mono : Monotone fun x => μ (Ico a x) := fun i j hij => by simp only; gcongr
convert tendsto_atTop_iSup h_mono
obtain ⟨xs, hxs_mono, hxs_tendsto⟩ := exists_seq_monotone_tendsto_atTop_atTop α
have h_Ici : Ici a = ⋃ n, Ico a (xs n) := by
ext1 x
simp only [mem_Ici, mem_iUnion, mem_Ico, exists_and_left, iff_self_and]
intro
obtain ⟨y, hxy⟩ := NoMaxOrder.exists_gt x
obtain ⟨n, hn⟩ := tendsto_atTop_atTop.mp hxs_tendsto y
exact ⟨n, hxy.trans_le (hn n le_rfl)⟩
rw [h_Ici, measure_iUnion_eq_iSup, iSup_eq_iSup_subseq_of_monotone h_mono hxs_tendsto]
exact Monotone.directed_le fun i j hij => Ico_subset_Ico_right (hxs_mono hij)
#align measure_theory.tendsto_measure_Ico_at_top MeasureTheory.tendsto_measure_Ico_atTop
theorem tendsto_measure_Ioc_atBot [SemilatticeInf α] [NoMinOrder α]
[(atBot : Filter α).IsCountablyGenerated] (μ : Measure α) (a : α) :
Tendsto (fun x => μ (Ioc x a)) atBot (𝓝 (μ (Iic a))) := by
haveI : Nonempty α := ⟨a⟩
have h_mono : Antitone fun x => μ (Ioc x a) := fun i j hij => by simp only; gcongr
convert tendsto_atBot_iSup h_mono
obtain ⟨xs, hxs_mono, hxs_tendsto⟩ := exists_seq_antitone_tendsto_atTop_atBot α
have h_Iic : Iic a = ⋃ n, Ioc (xs n) a := by
ext1 x
simp only [mem_Iic, mem_iUnion, mem_Ioc, exists_and_right, iff_and_self]
intro
obtain ⟨y, hxy⟩ := NoMinOrder.exists_lt x
obtain ⟨n, hn⟩ := tendsto_atTop_atBot.mp hxs_tendsto y
exact ⟨n, (hn n le_rfl).trans_lt hxy⟩
rw [h_Iic, measure_iUnion_eq_iSup, iSup_eq_iSup_subseq_of_antitone h_mono hxs_tendsto]
exact Monotone.directed_le fun i j hij => Ioc_subset_Ioc_left (hxs_mono hij)
#align measure_theory.tendsto_measure_Ioc_at_bot MeasureTheory.tendsto_measure_Ioc_atBot
theorem tendsto_measure_Iic_atTop [SemilatticeSup α] [(atTop : Filter α).IsCountablyGenerated]
(μ : Measure α) : Tendsto (fun x => μ (Iic x)) atTop (𝓝 (μ univ)) := by
cases isEmpty_or_nonempty α
· have h1 : ∀ x : α, Iic x = ∅ := fun x => Subsingleton.elim _ _
have h2 : (univ : Set α) = ∅ := Subsingleton.elim _ _
simp_rw [h1, h2]
exact tendsto_const_nhds
have h_mono : Monotone fun x => μ (Iic x) := fun i j hij => by simp only; gcongr
convert tendsto_atTop_iSup h_mono
obtain ⟨xs, hxs_mono, hxs_tendsto⟩ := exists_seq_monotone_tendsto_atTop_atTop α
have h_univ : (univ : Set α) = ⋃ n, Iic (xs n) := by
ext1 x
simp only [mem_univ, mem_iUnion, mem_Iic, true_iff_iff]
obtain ⟨n, hn⟩ := tendsto_atTop_atTop.mp hxs_tendsto x
exact ⟨n, hn n le_rfl⟩
rw [h_univ, measure_iUnion_eq_iSup, iSup_eq_iSup_subseq_of_monotone h_mono hxs_tendsto]
exact Monotone.directed_le fun i j hij => Iic_subset_Iic.mpr (hxs_mono hij)
#align measure_theory.tendsto_measure_Iic_at_top MeasureTheory.tendsto_measure_Iic_atTop
theorem tendsto_measure_Ici_atBot [SemilatticeInf α] [h : (atBot : Filter α).IsCountablyGenerated]
(μ : Measure α) : Tendsto (fun x => μ (Ici x)) atBot (𝓝 (μ univ)) :=
@tendsto_measure_Iic_atTop αᵒᵈ _ _ h μ
#align measure_theory.tendsto_measure_Ici_at_bot MeasureTheory.tendsto_measure_Ici_atBot
variable [PartialOrder α] {a b : α}
theorem Iio_ae_eq_Iic' (ha : μ {a} = 0) : Iio a =ᵐ[μ] Iic a := by
rw [← Iic_diff_right, diff_ae_eq_self, measure_mono_null Set.inter_subset_right ha]
#align measure_theory.Iio_ae_eq_Iic' MeasureTheory.Iio_ae_eq_Iic'
theorem Ioi_ae_eq_Ici' (ha : μ {a} = 0) : Ioi a =ᵐ[μ] Ici a :=
Iio_ae_eq_Iic' (α := αᵒᵈ) ha
#align measure_theory.Ioi_ae_eq_Ici' MeasureTheory.Ioi_ae_eq_Ici'
theorem Ioo_ae_eq_Ioc' (hb : μ {b} = 0) : Ioo a b =ᵐ[μ] Ioc a b :=
(ae_eq_refl _).inter (Iio_ae_eq_Iic' hb)
#align measure_theory.Ioo_ae_eq_Ioc' MeasureTheory.Ioo_ae_eq_Ioc'
theorem Ioc_ae_eq_Icc' (ha : μ {a} = 0) : Ioc a b =ᵐ[μ] Icc a b :=
(Ioi_ae_eq_Ici' ha).inter (ae_eq_refl _)
#align measure_theory.Ioc_ae_eq_Icc' MeasureTheory.Ioc_ae_eq_Icc'
theorem Ioo_ae_eq_Ico' (ha : μ {a} = 0) : Ioo a b =ᵐ[μ] Ico a b :=
(Ioi_ae_eq_Ici' ha).inter (ae_eq_refl _)
#align measure_theory.Ioo_ae_eq_Ico' MeasureTheory.Ioo_ae_eq_Ico'
theorem Ioo_ae_eq_Icc' (ha : μ {a} = 0) (hb : μ {b} = 0) : Ioo a b =ᵐ[μ] Icc a b :=
(Ioi_ae_eq_Ici' ha).inter (Iio_ae_eq_Iic' hb)
#align measure_theory.Ioo_ae_eq_Icc' MeasureTheory.Ioo_ae_eq_Icc'
theorem Ico_ae_eq_Icc' (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Icc a b :=
(ae_eq_refl _).inter (Iio_ae_eq_Iic' hb)
#align measure_theory.Ico_ae_eq_Icc' MeasureTheory.Ico_ae_eq_Icc'
theorem Ico_ae_eq_Ioc' (ha : μ {a} = 0) (hb : μ {b} = 0) : Ico a b =ᵐ[μ] Ioc a b :=
(Ioo_ae_eq_Ico' ha).symm.trans (Ioo_ae_eq_Ioc' hb)
#align measure_theory.Ico_ae_eq_Ioc' MeasureTheory.Ico_ae_eq_Ioc'
end Intervals
end
end MeasureTheory
namespace MeasurableEmbedding
open MeasureTheory Measure
variable {m0 : MeasurableSpace α} {m1 : MeasurableSpace β} {f : α → β} (hf : MeasurableEmbedding f)
nonrec theorem map_apply (μ : Measure α) (s : Set β) : μ.map f s = μ (f ⁻¹' s) := by
refine le_antisymm ?_ (le_map_apply hf.measurable.aemeasurable s)
set t := f '' toMeasurable μ (f ⁻¹' s) ∪ (range f)ᶜ
have htm : MeasurableSet t :=
(hf.measurableSet_image.2 <| measurableSet_toMeasurable _ _).union
hf.measurableSet_range.compl
have hst : s ⊆ t := by
rw [subset_union_compl_iff_inter_subset, ← image_preimage_eq_inter_range]
exact image_subset _ (subset_toMeasurable _ _)
have hft : f ⁻¹' t = toMeasurable μ (f ⁻¹' s) := by
rw [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,
hf.injective.preimage_image]
calc
μ.map f s ≤ μ.map f t := by gcongr
_ = μ (f ⁻¹' s) := by rw [map_apply hf.measurable htm, hft, measure_toMeasurable]
#align measurable_embedding.map_apply MeasurableEmbedding.map_apply
lemma comap_add (μ ν : Measure β) : (μ + ν).comap f = μ.comap f + ν.comap f := by
ext s hs
simp only [← comapₗ_eq_comap _ hf.injective (fun _ ↦ hf.measurableSet_image.mpr) _ hs,
_root_.map_add, add_apply]
end MeasurableEmbedding
namespace MeasurableEquiv
/-! Interactions of measurable equivalences and measures -/
open Equiv MeasureTheory.Measure
variable [MeasurableSpace α] [MeasurableSpace β] {μ : Measure α} {ν : Measure β}
/-- If we map a measure along a measurable equivalence, we can compute the measure on all sets
(not just the measurable ones). -/
protected theorem map_apply (f : α ≃ᵐ β) (s : Set β) : μ.map f s = μ (f ⁻¹' s) :=
f.measurableEmbedding.map_apply _ _
#align measurable_equiv.map_apply MeasurableEquiv.map_apply
lemma comap_symm (e : α ≃ᵐ β) : μ.comap e.symm = μ.map e := by
ext s hs
rw [e.map_apply, Measure.comap_apply _ e.symm.injective _ _ hs, image_symm]
exact fun t ht ↦ e.symm.measurableSet_image.mpr ht
lemma map_symm (e : β ≃ᵐ α) : μ.map e.symm = μ.comap e := by
rw [← comap_symm, symm_symm]
@[simp]
theorem map_symm_map (e : α ≃ᵐ β) : (μ.map e).map e.symm = μ := by
simp [map_map e.symm.measurable e.measurable]
#align measurable_equiv.map_symm_map MeasurableEquiv.map_symm_map
@[simp]
theorem map_map_symm (e : α ≃ᵐ β) : (ν.map e.symm).map e = ν := by
simp [map_map e.measurable e.symm.measurable]
#align measurable_equiv.map_map_symm MeasurableEquiv.map_map_symm
theorem map_measurableEquiv_injective (e : α ≃ᵐ β) : Injective (Measure.map e) := by
intro μ₁ μ₂ hμ
apply_fun Measure.map e.symm at hμ
simpa [map_symm_map e] using hμ
#align measurable_equiv.map_measurable_equiv_injective MeasurableEquiv.map_measurableEquiv_injective
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 2,217 | 2,218 | theorem map_apply_eq_iff_map_symm_apply_eq (e : α ≃ᵐ β) : μ.map e = ν ↔ ν.map e.symm = μ := by |
rw [← (map_measurableEquiv_injective e).eq_iff, map_map_symm, eq_comm]
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Polynomial.Eval
#align_import data.polynomial.degree.lemmas from "leanprover-community/mathlib"@"728baa2f54e6062c5879a3e397ac6bac323e506f"
/-!
# Theory of degrees of polynomials
Some of the main results include
- `natDegree_comp_le` : The degree of the composition is at most the product of degrees
-/
noncomputable section
open Polynomial
open Finsupp Finset
namespace Polynomial
universe u v w
variable {R : Type u} {S : Type v} {ι : Type w} {a b : R} {m n : ℕ}
section Semiring
variable [Semiring R] {p q r : R[X]}
section Degree
theorem natDegree_comp_le : natDegree (p.comp q) ≤ natDegree p * natDegree q :=
letI := Classical.decEq R
if h0 : p.comp q = 0 then by rw [h0, natDegree_zero]; exact Nat.zero_le _
else
WithBot.coe_le_coe.1 <|
calc
↑(natDegree (p.comp q)) = degree (p.comp q) := (degree_eq_natDegree h0).symm
_ = _ := congr_arg degree comp_eq_sum_left
_ ≤ _ := degree_sum_le _ _
_ ≤ _ :=
Finset.sup_le fun n hn =>
calc
degree (C (coeff p n) * q ^ n) ≤ degree (C (coeff p n)) + degree (q ^ n) :=
degree_mul_le _ _
_ ≤ natDegree (C (coeff p n)) + n • degree q :=
(add_le_add degree_le_natDegree (degree_pow_le _ _))
_ ≤ natDegree (C (coeff p n)) + n • ↑(natDegree q) :=
(add_le_add_left (nsmul_le_nsmul_right (@degree_le_natDegree _ _ q) n) _)
_ = (n * natDegree q : ℕ) := by
rw [natDegree_C, Nat.cast_zero, zero_add, nsmul_eq_mul];
simp
_ ≤ (natDegree p * natDegree q : ℕ) :=
WithBot.coe_le_coe.2 <|
mul_le_mul_of_nonneg_right (le_natDegree_of_ne_zero (mem_support_iff.1 hn))
(Nat.zero_le _)
#align polynomial.nat_degree_comp_le Polynomial.natDegree_comp_le
theorem degree_pos_of_root {p : R[X]} (hp : p ≠ 0) (h : IsRoot p a) : 0 < degree p :=
lt_of_not_ge fun hlt => by
have := eq_C_of_degree_le_zero hlt
rw [IsRoot, this, eval_C] at h
simp only [h, RingHom.map_zero] at this
exact hp this
#align polynomial.degree_pos_of_root Polynomial.degree_pos_of_root
theorem natDegree_le_iff_coeff_eq_zero : p.natDegree ≤ n ↔ ∀ N : ℕ, n < N → p.coeff N = 0 := by
simp_rw [natDegree_le_iff_degree_le, degree_le_iff_coeff_zero, Nat.cast_lt]
#align polynomial.nat_degree_le_iff_coeff_eq_zero Polynomial.natDegree_le_iff_coeff_eq_zero
theorem natDegree_add_le_iff_left {n : ℕ} (p q : R[X]) (qn : q.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ p.natDegree ≤ n := by
refine ⟨fun h => ?_, fun h => natDegree_add_le_of_degree_le h qn⟩
refine natDegree_le_iff_coeff_eq_zero.mpr fun m hm => ?_
convert natDegree_le_iff_coeff_eq_zero.mp h m hm using 1
rw [coeff_add, natDegree_le_iff_coeff_eq_zero.mp qn _ hm, add_zero]
#align polynomial.nat_degree_add_le_iff_left Polynomial.natDegree_add_le_iff_left
theorem natDegree_add_le_iff_right {n : ℕ} (p q : R[X]) (pn : p.natDegree ≤ n) :
(p + q).natDegree ≤ n ↔ q.natDegree ≤ n := by
rw [add_comm]
exact natDegree_add_le_iff_left _ _ pn
#align polynomial.nat_degree_add_le_iff_right Polynomial.natDegree_add_le_iff_right
theorem natDegree_C_mul_le (a : R) (f : R[X]) : (C a * f).natDegree ≤ f.natDegree :=
calc
(C a * f).natDegree ≤ (C a).natDegree + f.natDegree := natDegree_mul_le
_ = 0 + f.natDegree := by rw [natDegree_C a]
_ = f.natDegree := zero_add _
set_option linter.uppercaseLean3 false in
#align polynomial.nat_degree_C_mul_le Polynomial.natDegree_C_mul_le
| Mathlib/Algebra/Polynomial/Degree/Lemmas.lean | 98 | 102 | theorem natDegree_mul_C_le (f : R[X]) (a : R) : (f * C a).natDegree ≤ f.natDegree :=
calc
(f * C a).natDegree ≤ f.natDegree + (C a).natDegree := natDegree_mul_le
_ = f.natDegree + 0 := by | rw [natDegree_C a]
_ = f.natDegree := add_zero _
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Johannes Hölzl, Scott Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Regular.SMul
#align_import data.polynomial.monic from "leanprover-community/mathlib"@"cbdf7b565832144d024caa5a550117c6df0204a5"
/-!
# Theory of monic polynomials
We give several tools for proving that polynomials are monic, e.g.
`Monic.mul`, `Monic.map`, `Monic.pow`.
-/
noncomputable section
open Finset
open Polynomial
namespace Polynomial
universe u v y
variable {R : Type u} {S : Type v} {a b : R} {m n : ℕ} {ι : Type y}
section Semiring
variable [Semiring R] {p q r : R[X]}
theorem monic_zero_iff_subsingleton : Monic (0 : R[X]) ↔ Subsingleton R :=
subsingleton_iff_zero_eq_one
#align polynomial.monic_zero_iff_subsingleton Polynomial.monic_zero_iff_subsingleton
theorem not_monic_zero_iff : ¬Monic (0 : R[X]) ↔ (0 : R) ≠ 1 :=
(monic_zero_iff_subsingleton.trans subsingleton_iff_zero_eq_one.symm).not
#align polynomial.not_monic_zero_iff Polynomial.not_monic_zero_iff
theorem monic_zero_iff_subsingleton' :
Monic (0 : R[X]) ↔ (∀ f g : R[X], f = g) ∧ ∀ a b : R, a = b :=
Polynomial.monic_zero_iff_subsingleton.trans
⟨by
intro
simp [eq_iff_true_of_subsingleton], fun h => subsingleton_iff.mpr h.2⟩
#align polynomial.monic_zero_iff_subsingleton' Polynomial.monic_zero_iff_subsingleton'
theorem Monic.as_sum (hp : p.Monic) :
p = X ^ p.natDegree + ∑ i ∈ range p.natDegree, C (p.coeff i) * X ^ i := by
conv_lhs => rw [p.as_sum_range_C_mul_X_pow, sum_range_succ_comm]
suffices C (p.coeff p.natDegree) = 1 by rw [this, one_mul]
exact congr_arg C hp
#align polynomial.monic.as_sum Polynomial.Monic.as_sum
theorem ne_zero_of_ne_zero_of_monic (hp : p ≠ 0) (hq : Monic q) : q ≠ 0 := by
rintro rfl
rw [Monic.def, leadingCoeff_zero] at hq
rw [← mul_one p, ← C_1, ← hq, C_0, mul_zero] at hp
exact hp rfl
#align polynomial.ne_zero_of_ne_zero_of_monic Polynomial.ne_zero_of_ne_zero_of_monic
theorem Monic.map [Semiring S] (f : R →+* S) (hp : Monic p) : Monic (p.map f) := by
unfold Monic
nontriviality
have : f p.leadingCoeff ≠ 0 := by
rw [show _ = _ from hp, f.map_one]
exact one_ne_zero
rw [Polynomial.leadingCoeff, coeff_map]
suffices p.coeff (p.map f).natDegree = 1 by simp [this]
rwa [natDegree_eq_of_degree_eq (degree_map_eq_of_leadingCoeff_ne_zero f this)]
#align polynomial.monic.map Polynomial.Monic.map
theorem monic_C_mul_of_mul_leadingCoeff_eq_one {b : R} (hp : b * p.leadingCoeff = 1) :
Monic (C b * p) := by
unfold Monic
nontriviality
rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp]
set_option linter.uppercaseLean3 false in
#align polynomial.monic_C_mul_of_mul_leading_coeff_eq_one Polynomial.monic_C_mul_of_mul_leadingCoeff_eq_one
theorem monic_mul_C_of_leadingCoeff_mul_eq_one {b : R} (hp : p.leadingCoeff * b = 1) :
Monic (p * C b) := by
unfold Monic
nontriviality
rw [leadingCoeff_mul' _] <;> simp [leadingCoeff_C b, hp]
set_option linter.uppercaseLean3 false in
#align polynomial.monic_mul_C_of_leading_coeff_mul_eq_one Polynomial.monic_mul_C_of_leadingCoeff_mul_eq_one
theorem monic_of_degree_le (n : ℕ) (H1 : degree p ≤ n) (H2 : coeff p n = 1) : Monic p :=
Decidable.byCases
(fun H : degree p < n => eq_of_zero_eq_one (H2 ▸ (coeff_eq_zero_of_degree_lt H).symm) _ _)
fun H : ¬degree p < n => by
rwa [Monic, Polynomial.leadingCoeff, natDegree, (lt_or_eq_of_le H1).resolve_left H]
#align polynomial.monic_of_degree_le Polynomial.monic_of_degree_le
theorem monic_X_pow_add {n : ℕ} (H : degree p ≤ n) : Monic (X ^ (n + 1) + p) :=
have H1 : degree p < (n + 1 : ℕ) := lt_of_le_of_lt H (WithBot.coe_lt_coe.2 (Nat.lt_succ_self n))
monic_of_degree_le (n + 1)
(le_trans (degree_add_le _ _) (max_le (degree_X_pow_le _) (le_of_lt H1)))
(by rw [coeff_add, coeff_X_pow, if_pos rfl, coeff_eq_zero_of_degree_lt H1, add_zero])
set_option linter.uppercaseLean3 false in
#align polynomial.monic_X_pow_add Polynomial.monic_X_pow_add
variable (a) in
theorem monic_X_pow_add_C {n : ℕ} (h : n ≠ 0) : (X ^ n + C a).Monic := by
obtain ⟨k, rfl⟩ := Nat.exists_eq_succ_of_ne_zero h
exact monic_X_pow_add <| degree_C_le.trans Nat.WithBot.coe_nonneg
theorem monic_X_add_C (x : R) : Monic (X + C x) :=
pow_one (X : R[X]) ▸ monic_X_pow_add_C x one_ne_zero
set_option linter.uppercaseLean3 false in
#align polynomial.monic_X_add_C Polynomial.monic_X_add_C
| Mathlib/Algebra/Polynomial/Monic.lean | 117 | 125 | theorem Monic.mul (hp : Monic p) (hq : Monic q) : Monic (p * q) :=
letI := Classical.decEq R
if h0 : (0 : R) = 1 then
haveI := subsingleton_of_zero_eq_one h0
Subsingleton.elim _ _
else by
have : p.leadingCoeff * q.leadingCoeff ≠ 0 := by |
simp [Monic.def.1 hp, Monic.def.1 hq, Ne.symm h0]
rw [Monic.def, leadingCoeff_mul' this, Monic.def.1 hp, Monic.def.1 hq, one_mul]
|
/-
Copyright (c) 2024 Xavier Roblot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Xavier Roblot
-/
import Mathlib.RingTheory.FractionalIdeal.Basic
import Mathlib.RingTheory.Ideal.Norm
/-!
# Fractional ideal norms
This file defines the absolute ideal norm of a fractional ideal `I : FractionalIdeal R⁰ K` where
`K` is a fraction field of `R`. The norm is defined by
`FractionalIdeal.absNorm I = Ideal.absNorm I.num / |Algebra.norm ℤ I.den|` where `I.num` is an
ideal of `R` and `I.den` an element of `R⁰` such that `I.den • I = I.num`.
## Main definitions and results
* `FractionalIdeal.absNorm`: the norm as a zero preserving morphism with values in `ℚ`.
* `FractionalIdeal.absNorm_eq'`: the value of the norm does not depend on the choice of
`I.num` and `I.den`.
* `FractionalIdeal.abs_det_basis_change`: the norm is given by the determinant
of the basis change matrix.
* `FractionalIdeal.absNorm_span_singleton`: the norm of a principal fractional ideal is the
norm of its generator
-/
namespace FractionalIdeal
open scoped Pointwise nonZeroDivisors
variable {R : Type*} [CommRing R] [IsDedekindDomain R] [Module.Free ℤ R] [Module.Finite ℤ R]
variable {K : Type*} [CommRing K] [Algebra R K] [IsFractionRing R K]
theorem absNorm_div_norm_eq_absNorm_div_norm {I : FractionalIdeal R⁰ K} (a : R⁰) (I₀ : Ideal R)
(h : a • (I : Submodule R K) = Submodule.map (Algebra.linearMap R K) I₀) :
(Ideal.absNorm I.num : ℚ) / |Algebra.norm ℤ (I.den:R)| =
(Ideal.absNorm I₀ : ℚ) / |Algebra.norm ℤ (a:R)| := by
rw [div_eq_div_iff]
· replace h := congr_arg (I.den • ·) h
have h' := congr_arg (a • ·) (den_mul_self_eq_num I)
dsimp only at h h'
rw [smul_comm] at h
rw [h, Submonoid.smul_def, Submonoid.smul_def, ← Submodule.ideal_span_singleton_smul,
← Submodule.ideal_span_singleton_smul, ← Submodule.map_smul'', ← Submodule.map_smul'',
(LinearMap.map_injective ?_).eq_iff, smul_eq_mul, smul_eq_mul] at h'
· simp_rw [← Int.cast_natAbs, ← Nat.cast_mul, ← Ideal.absNorm_span_singleton]
rw [← _root_.map_mul, ← _root_.map_mul, mul_comm, ← h', mul_comm]
· exact LinearMap.ker_eq_bot.mpr (IsFractionRing.injective R K)
all_goals simpa [Algebra.norm_eq_zero_iff] using nonZeroDivisors.coe_ne_zero _
/-- The absolute norm of the fractional ideal `I` extending by multiplicativity the absolute norm
on (integral) ideals. -/
noncomputable def absNorm : FractionalIdeal R⁰ K →*₀ ℚ where
toFun I := (Ideal.absNorm I.num : ℚ) / |Algebra.norm ℤ (I.den : R)|
map_zero' := by
dsimp only
rw [num_zero_eq, Submodule.zero_eq_bot, Ideal.absNorm_bot, Nat.cast_zero, zero_div]
exact IsFractionRing.injective R K
map_one' := by
dsimp only
rw [absNorm_div_norm_eq_absNorm_div_norm 1 ⊤ (by simp [Submodule.one_eq_range]),
Ideal.absNorm_top, Nat.cast_one, OneMemClass.coe_one, _root_.map_one, abs_one, Int.cast_one,
one_div_one]
map_mul' I J := by
dsimp only
rw [absNorm_div_norm_eq_absNorm_div_norm (I.den * J.den) (I.num * J.num) (by
have : Algebra.linearMap R K = (IsScalarTower.toAlgHom R R K).toLinearMap := rfl
rw [coe_mul, this, Submodule.map_mul, ← this, ← den_mul_self_eq_num, ← den_mul_self_eq_num]
exact Submodule.mul_smul_mul_eq_smul_mul_smul _ _ _ _),
Submonoid.coe_mul, _root_.map_mul, _root_.map_mul, Nat.cast_mul, div_mul_div_comm,
Int.cast_abs, Int.cast_abs, Int.cast_abs, ← abs_mul, Int.cast_mul]
theorem absNorm_eq (I : FractionalIdeal R⁰ K) :
absNorm I = (Ideal.absNorm I.num : ℚ) / |Algebra.norm ℤ (I.den : R)| := rfl
theorem absNorm_eq' {I : FractionalIdeal R⁰ K} (a : R⁰) (I₀ : Ideal R)
(h : a • (I : Submodule R K) = Submodule.map (Algebra.linearMap R K) I₀) :
absNorm I = (Ideal.absNorm I₀ : ℚ) / |Algebra.norm ℤ (a:R)| := by
rw [absNorm, ← absNorm_div_norm_eq_absNorm_div_norm a I₀ h, MonoidWithZeroHom.coe_mk,
ZeroHom.coe_mk]
theorem absNorm_nonneg (I : FractionalIdeal R⁰ K) : 0 ≤ absNorm I := by dsimp [absNorm]; positivity
theorem absNorm_bot : absNorm (⊥ : FractionalIdeal R⁰ K) = 0 := absNorm.map_zero'
theorem absNorm_one : absNorm (1 : FractionalIdeal R⁰ K) = 1 := by convert absNorm.map_one'
theorem absNorm_eq_zero_iff [NoZeroDivisors K] {I : FractionalIdeal R⁰ K} :
absNorm I = 0 ↔ I = 0 := by
refine ⟨fun h ↦ zero_of_num_eq_bot zero_not_mem_nonZeroDivisors ?_, fun h ↦ h ▸ absNorm_bot⟩
rw [absNorm_eq, div_eq_zero_iff] at h
refine Ideal.absNorm_eq_zero_iff.mp <| Nat.cast_eq_zero.mp <| h.resolve_right ?_
simpa [Algebra.norm_eq_zero_iff] using nonZeroDivisors.coe_ne_zero _
theorem coeIdeal_absNorm (I₀ : Ideal R) :
absNorm (I₀ : FractionalIdeal R⁰ K) = Ideal.absNorm I₀ := by
rw [absNorm_eq' 1 I₀ (by rw [one_smul]; rfl), OneMemClass.coe_one, _root_.map_one, abs_one,
Int.cast_one, _root_.div_one]
section IsLocalization
variable [IsLocalization (Algebra.algebraMapSubmonoid R ℤ⁰) K] [Algebra ℚ K]
| Mathlib/RingTheory/FractionalIdeal/Norm.lean | 106 | 128 | theorem abs_det_basis_change [NoZeroDivisors K] {ι : Type*} [Fintype ι]
[DecidableEq ι] (b : Basis ι ℤ R) (I : FractionalIdeal R⁰ K) (bI : Basis ι ℤ I) :
|(b.localizationLocalization ℚ ℤ⁰ K).det ((↑) ∘ bI)| = absNorm I := by |
have := IsFractionRing.nontrivial R K
let b₀ : Basis ι ℚ K := b.localizationLocalization ℚ ℤ⁰ K
let bI.num : Basis ι ℤ I.num := bI.map
((equivNum (nonZeroDivisors.coe_ne_zero _)).restrictScalars ℤ)
rw [absNorm_eq, ← Ideal.natAbs_det_basis_change b I.num bI.num, Int.cast_natAbs, Int.cast_abs,
Int.cast_abs, Basis.det_apply, Basis.det_apply]
change _ = |algebraMap ℤ ℚ _| / _
rw [RingHom.map_det, show RingHom.mapMatrix (algebraMap ℤ ℚ) (b.toMatrix ((↑) ∘ bI.num)) =
b₀.toMatrix ((algebraMap R K (den I : R)) • ((↑) ∘ bI)) by
ext : 2
simp_rw [bI.num, RingHom.mapMatrix_apply, Matrix.map_apply, Basis.toMatrix_apply,
← Basis.localizationLocalization_repr_algebraMap ℚ ℤ⁰ K, Function.comp_apply,
Basis.map_apply, LinearEquiv.restrictScalars_apply, equivNum_apply, Submonoid.smul_def,
Algebra.smul_def]
rfl]
rw [Basis.toMatrix_smul, Matrix.det_mul, abs_mul, ← Algebra.norm_eq_matrix_det,
Algebra.norm_localization ℤ ℤ⁰, show (Algebra.norm ℤ (den I: R) : ℚ) =
algebraMap ℤ ℚ (Algebra.norm ℤ (den I: R)) by rfl, mul_div_assoc, mul_div_cancel₀ _ (by
rw [ne_eq, abs_eq_zero, IsFractionRing.to_map_eq_zero_iff, Algebra.norm_eq_zero_iff_of_basis b]
exact nonZeroDivisors.coe_ne_zero _)]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Jeremy Avigad
-/
import Mathlib.Order.Filter.Lift
import Mathlib.Topology.Defs.Filter
#align_import topology.basic from "leanprover-community/mathlib"@"e354e865255654389cc46e6032160238df2e0f40"
/-!
# Basic theory of topological spaces.
The main definition is the type class `TopologicalSpace X` which endows a type `X` with a topology.
Then `Set X` gets predicates `IsOpen`, `IsClosed` and functions `interior`, `closure` and
`frontier`. Each point `x` of `X` gets a neighborhood filter `𝓝 x`. A filter `F` on `X` has
`x` as a cluster point if `ClusterPt x F : 𝓝 x ⊓ F ≠ ⊥`. A map `f : α → X` clusters at `x`
along `F : Filter α` if `MapClusterPt x F f : ClusterPt x (map f F)`. In particular
the notion of cluster point of a sequence `u` is `MapClusterPt x atTop u`.
For topological spaces `X` and `Y`, a function `f : X → Y` and a point `x : X`,
`ContinuousAt f x` means `f` is continuous at `x`, and global continuity is
`Continuous f`. There is also a version of continuity `PContinuous` for
partially defined functions.
## Notation
The following notation is introduced elsewhere and it heavily used in this file.
* `𝓝 x`: the filter `nhds x` of neighborhoods of a point `x`;
* `𝓟 s`: the principal filter of a set `s`;
* `𝓝[s] x`: the filter `nhdsWithin x s` of neighborhoods of a point `x` within a set `s`;
* `𝓝[≠] x`: the filter `nhdsWithin x {x}ᶜ` of punctured neighborhoods of `x`.
## Implementation notes
Topology in mathlib heavily uses filters (even more than in Bourbaki). See explanations in
<https://leanprover-community.github.io/theories/topology.html>.
## References
* [N. Bourbaki, *General Topology*][bourbaki1966]
* [I. M. James, *Topologies and Uniformities*][james1999]
## Tags
topological space, interior, closure, frontier, neighborhood, continuity, continuous function
-/
noncomputable section
open Set Filter
universe u v w x
/-!
### Topological spaces
-/
/-- A constructor for topologies by specifying the closed sets,
and showing that they satisfy the appropriate conditions. -/
def TopologicalSpace.ofClosed {X : Type u} (T : Set (Set X)) (empty_mem : ∅ ∈ T)
(sInter_mem : ∀ A, A ⊆ T → ⋂₀ A ∈ T)
(union_mem : ∀ A, A ∈ T → ∀ B, B ∈ T → A ∪ B ∈ T) : TopologicalSpace X where
IsOpen X := Xᶜ ∈ T
isOpen_univ := by simp [empty_mem]
isOpen_inter s t hs ht := by simpa only [compl_inter] using union_mem sᶜ hs tᶜ ht
isOpen_sUnion s hs := by
simp only [Set.compl_sUnion]
exact sInter_mem (compl '' s) fun z ⟨y, hy, hz⟩ => hz ▸ hs y hy
#align topological_space.of_closed TopologicalSpace.ofClosed
section TopologicalSpace
variable {X : Type u} {Y : Type v} {ι : Sort w} {α β : Type*}
{x : X} {s s₁ s₂ t : Set X} {p p₁ p₂ : X → Prop}
open Topology
lemma isOpen_mk {p h₁ h₂ h₃} : IsOpen[⟨p, h₁, h₂, h₃⟩] s ↔ p s := Iff.rfl
#align is_open_mk isOpen_mk
@[ext]
protected theorem TopologicalSpace.ext :
∀ {f g : TopologicalSpace X}, IsOpen[f] = IsOpen[g] → f = g
| ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl
#align topological_space_eq TopologicalSpace.ext
section
variable [TopologicalSpace X]
end
protected theorem TopologicalSpace.ext_iff {t t' : TopologicalSpace X} :
t = t' ↔ ∀ s, IsOpen[t] s ↔ IsOpen[t'] s :=
⟨fun h s => h ▸ Iff.rfl, fun h => by ext; exact h _⟩
#align topological_space_eq_iff TopologicalSpace.ext_iff
theorem isOpen_fold {t : TopologicalSpace X} : t.IsOpen s = IsOpen[t] s :=
rfl
#align is_open_fold isOpen_fold
variable [TopologicalSpace X]
theorem isOpen_iUnion {f : ι → Set X} (h : ∀ i, IsOpen (f i)) : IsOpen (⋃ i, f i) :=
isOpen_sUnion (forall_mem_range.2 h)
#align is_open_Union isOpen_iUnion
theorem isOpen_biUnion {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋃ i ∈ s, f i) :=
isOpen_iUnion fun i => isOpen_iUnion fun hi => h i hi
#align is_open_bUnion isOpen_biUnion
theorem IsOpen.union (h₁ : IsOpen s₁) (h₂ : IsOpen s₂) : IsOpen (s₁ ∪ s₂) := by
rw [union_eq_iUnion]; exact isOpen_iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩)
#align is_open.union IsOpen.union
lemma isOpen_iff_of_cover {f : α → Set X} (ho : ∀ i, IsOpen (f i)) (hU : (⋃ i, f i) = univ) :
IsOpen s ↔ ∀ i, IsOpen (f i ∩ s) := by
refine ⟨fun h i ↦ (ho i).inter h, fun h ↦ ?_⟩
rw [← s.inter_univ, inter_comm, ← hU, iUnion_inter]
exact isOpen_iUnion fun i ↦ h i
@[simp] theorem isOpen_empty : IsOpen (∅ : Set X) := by
rw [← sUnion_empty]; exact isOpen_sUnion fun a => False.elim
#align is_open_empty isOpen_empty
theorem Set.Finite.isOpen_sInter {s : Set (Set X)} (hs : s.Finite) :
(∀ t ∈ s, IsOpen t) → IsOpen (⋂₀ s) :=
Finite.induction_on hs (fun _ => by rw [sInter_empty]; exact isOpen_univ) fun _ _ ih h => by
simp only [sInter_insert, forall_mem_insert] at h ⊢
exact h.1.inter (ih h.2)
#align is_open_sInter Set.Finite.isOpen_sInter
theorem Set.Finite.isOpen_biInter {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
sInter_image f s ▸ (hs.image _).isOpen_sInter (forall_mem_image.2 h)
#align is_open_bInter Set.Finite.isOpen_biInter
theorem isOpen_iInter_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsOpen (s i)) :
IsOpen (⋂ i, s i) :=
(finite_range _).isOpen_sInter (forall_mem_range.2 h)
#align is_open_Inter isOpen_iInter_of_finite
theorem isOpen_biInter_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsOpen (f i)) :
IsOpen (⋂ i ∈ s, f i) :=
s.finite_toSet.isOpen_biInter h
#align is_open_bInter_finset isOpen_biInter_finset
@[simp] -- Porting note: added `simp`
theorem isOpen_const {p : Prop} : IsOpen { _x : X | p } := by by_cases p <;> simp [*]
#align is_open_const isOpen_const
theorem IsOpen.and : IsOpen { x | p₁ x } → IsOpen { x | p₂ x } → IsOpen { x | p₁ x ∧ p₂ x } :=
IsOpen.inter
#align is_open.and IsOpen.and
@[simp] theorem isOpen_compl_iff : IsOpen sᶜ ↔ IsClosed s :=
⟨fun h => ⟨h⟩, fun h => h.isOpen_compl⟩
#align is_open_compl_iff isOpen_compl_iff
theorem TopologicalSpace.ext_iff_isClosed {t₁ t₂ : TopologicalSpace X} :
t₁ = t₂ ↔ ∀ s, IsClosed[t₁] s ↔ IsClosed[t₂] s := by
rw [TopologicalSpace.ext_iff, compl_surjective.forall]
simp only [@isOpen_compl_iff _ _ t₁, @isOpen_compl_iff _ _ t₂]
alias ⟨_, TopologicalSpace.ext_isClosed⟩ := TopologicalSpace.ext_iff_isClosed
-- Porting note (#10756): new lemma
theorem isClosed_const {p : Prop} : IsClosed { _x : X | p } := ⟨isOpen_const (p := ¬p)⟩
@[simp] theorem isClosed_empty : IsClosed (∅ : Set X) := isClosed_const
#align is_closed_empty isClosed_empty
@[simp] theorem isClosed_univ : IsClosed (univ : Set X) := isClosed_const
#align is_closed_univ isClosed_univ
theorem IsClosed.union : IsClosed s₁ → IsClosed s₂ → IsClosed (s₁ ∪ s₂) := by
simpa only [← isOpen_compl_iff, compl_union] using IsOpen.inter
#align is_closed.union IsClosed.union
theorem isClosed_sInter {s : Set (Set X)} : (∀ t ∈ s, IsClosed t) → IsClosed (⋂₀ s) := by
simpa only [← isOpen_compl_iff, compl_sInter, sUnion_image] using isOpen_biUnion
#align is_closed_sInter isClosed_sInter
theorem isClosed_iInter {f : ι → Set X} (h : ∀ i, IsClosed (f i)) : IsClosed (⋂ i, f i) :=
isClosed_sInter <| forall_mem_range.2 h
#align is_closed_Inter isClosed_iInter
theorem isClosed_biInter {s : Set α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋂ i ∈ s, f i) :=
isClosed_iInter fun i => isClosed_iInter <| h i
#align is_closed_bInter isClosed_biInter
@[simp]
theorem isClosed_compl_iff {s : Set X} : IsClosed sᶜ ↔ IsOpen s := by
rw [← isOpen_compl_iff, compl_compl]
#align is_closed_compl_iff isClosed_compl_iff
alias ⟨_, IsOpen.isClosed_compl⟩ := isClosed_compl_iff
#align is_open.is_closed_compl IsOpen.isClosed_compl
theorem IsOpen.sdiff (h₁ : IsOpen s) (h₂ : IsClosed t) : IsOpen (s \ t) :=
IsOpen.inter h₁ h₂.isOpen_compl
#align is_open.sdiff IsOpen.sdiff
theorem IsClosed.inter (h₁ : IsClosed s₁) (h₂ : IsClosed s₂) : IsClosed (s₁ ∩ s₂) := by
rw [← isOpen_compl_iff] at *
rw [compl_inter]
exact IsOpen.union h₁ h₂
#align is_closed.inter IsClosed.inter
theorem IsClosed.sdiff (h₁ : IsClosed s) (h₂ : IsOpen t) : IsClosed (s \ t) :=
IsClosed.inter h₁ (isClosed_compl_iff.mpr h₂)
#align is_closed.sdiff IsClosed.sdiff
theorem Set.Finite.isClosed_biUnion {s : Set α} {f : α → Set X} (hs : s.Finite)
(h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact hs.isOpen_biInter h
#align is_closed_bUnion Set.Finite.isClosed_biUnion
lemma isClosed_biUnion_finset {s : Finset α} {f : α → Set X} (h : ∀ i ∈ s, IsClosed (f i)) :
IsClosed (⋃ i ∈ s, f i) :=
s.finite_toSet.isClosed_biUnion h
theorem isClosed_iUnion_of_finite [Finite ι] {s : ι → Set X} (h : ∀ i, IsClosed (s i)) :
IsClosed (⋃ i, s i) := by
simp only [← isOpen_compl_iff, compl_iUnion] at *
exact isOpen_iInter_of_finite h
#align is_closed_Union isClosed_iUnion_of_finite
theorem isClosed_imp {p q : X → Prop} (hp : IsOpen { x | p x }) (hq : IsClosed { x | q x }) :
IsClosed { x | p x → q x } := by
simpa only [imp_iff_not_or] using hp.isClosed_compl.union hq
#align is_closed_imp isClosed_imp
theorem IsClosed.not : IsClosed { a | p a } → IsOpen { a | ¬p a } :=
isOpen_compl_iff.mpr
#align is_closed.not IsClosed.not
/-!
### Interior of a set
-/
theorem mem_interior : x ∈ interior s ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t := by
simp only [interior, mem_sUnion, mem_setOf_eq, and_assoc, and_left_comm]
#align mem_interior mem_interiorₓ
@[simp]
theorem isOpen_interior : IsOpen (interior s) :=
isOpen_sUnion fun _ => And.left
#align is_open_interior isOpen_interior
theorem interior_subset : interior s ⊆ s :=
sUnion_subset fun _ => And.right
#align interior_subset interior_subset
theorem interior_maximal (h₁ : t ⊆ s) (h₂ : IsOpen t) : t ⊆ interior s :=
subset_sUnion_of_mem ⟨h₂, h₁⟩
#align interior_maximal interior_maximal
theorem IsOpen.interior_eq (h : IsOpen s) : interior s = s :=
interior_subset.antisymm (interior_maximal (Subset.refl s) h)
#align is_open.interior_eq IsOpen.interior_eq
theorem interior_eq_iff_isOpen : interior s = s ↔ IsOpen s :=
⟨fun h => h ▸ isOpen_interior, IsOpen.interior_eq⟩
#align interior_eq_iff_is_open interior_eq_iff_isOpen
theorem subset_interior_iff_isOpen : s ⊆ interior s ↔ IsOpen s := by
simp only [interior_eq_iff_isOpen.symm, Subset.antisymm_iff, interior_subset, true_and]
#align subset_interior_iff_is_open subset_interior_iff_isOpen
theorem IsOpen.subset_interior_iff (h₁ : IsOpen s) : s ⊆ interior t ↔ s ⊆ t :=
⟨fun h => Subset.trans h interior_subset, fun h₂ => interior_maximal h₂ h₁⟩
#align is_open.subset_interior_iff IsOpen.subset_interior_iff
theorem subset_interior_iff : t ⊆ interior s ↔ ∃ U, IsOpen U ∧ t ⊆ U ∧ U ⊆ s :=
⟨fun h => ⟨interior s, isOpen_interior, h, interior_subset⟩, fun ⟨_U, hU, htU, hUs⟩ =>
htU.trans (interior_maximal hUs hU)⟩
#align subset_interior_iff subset_interior_iff
lemma interior_subset_iff : interior s ⊆ t ↔ ∀ U, IsOpen U → U ⊆ s → U ⊆ t := by
simp [interior]
@[mono, gcongr]
theorem interior_mono (h : s ⊆ t) : interior s ⊆ interior t :=
interior_maximal (Subset.trans interior_subset h) isOpen_interior
#align interior_mono interior_mono
@[simp]
theorem interior_empty : interior (∅ : Set X) = ∅ :=
isOpen_empty.interior_eq
#align interior_empty interior_empty
@[simp]
theorem interior_univ : interior (univ : Set X) = univ :=
isOpen_univ.interior_eq
#align interior_univ interior_univ
@[simp]
theorem interior_eq_univ : interior s = univ ↔ s = univ :=
⟨fun h => univ_subset_iff.mp <| h.symm.trans_le interior_subset, fun h => h.symm ▸ interior_univ⟩
#align interior_eq_univ interior_eq_univ
@[simp]
theorem interior_interior : interior (interior s) = interior s :=
isOpen_interior.interior_eq
#align interior_interior interior_interior
@[simp]
theorem interior_inter : interior (s ∩ t) = interior s ∩ interior t :=
(Monotone.map_inf_le (fun _ _ ↦ interior_mono) s t).antisymm <|
interior_maximal (inter_subset_inter interior_subset interior_subset) <|
isOpen_interior.inter isOpen_interior
#align interior_inter interior_inter
theorem Set.Finite.interior_biInter {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
hs.induction_on (by simp) <| by intros; simp [*]
theorem Set.Finite.interior_sInter {S : Set (Set X)} (hS : S.Finite) :
interior (⋂₀ S) = ⋂ s ∈ S, interior s := by
rw [sInter_eq_biInter, hS.interior_biInter]
@[simp]
theorem Finset.interior_iInter {ι : Type*} (s : Finset ι) (f : ι → Set X) :
interior (⋂ i ∈ s, f i) = ⋂ i ∈ s, interior (f i) :=
s.finite_toSet.interior_biInter f
#align finset.interior_Inter Finset.interior_iInter
@[simp]
theorem interior_iInter_of_finite [Finite ι] (f : ι → Set X) :
interior (⋂ i, f i) = ⋂ i, interior (f i) := by
rw [← sInter_range, (finite_range f).interior_sInter, biInter_range]
#align interior_Inter interior_iInter_of_finite
theorem interior_union_isClosed_of_interior_empty (h₁ : IsClosed s)
(h₂ : interior t = ∅) : interior (s ∪ t) = interior s :=
have : interior (s ∪ t) ⊆ s := fun x ⟨u, ⟨(hu₁ : IsOpen u), (hu₂ : u ⊆ s ∪ t)⟩, (hx₁ : x ∈ u)⟩ =>
by_contradiction fun hx₂ : x ∉ s =>
have : u \ s ⊆ t := fun x ⟨h₁, h₂⟩ => Or.resolve_left (hu₂ h₁) h₂
have : u \ s ⊆ interior t := by rwa [(IsOpen.sdiff hu₁ h₁).subset_interior_iff]
have : u \ s ⊆ ∅ := by rwa [h₂] at this
this ⟨hx₁, hx₂⟩
Subset.antisymm (interior_maximal this isOpen_interior) (interior_mono subset_union_left)
#align interior_union_is_closed_of_interior_empty interior_union_isClosed_of_interior_empty
theorem isOpen_iff_forall_mem_open : IsOpen s ↔ ∀ x ∈ s, ∃ t, t ⊆ s ∧ IsOpen t ∧ x ∈ t := by
rw [← subset_interior_iff_isOpen]
simp only [subset_def, mem_interior]
#align is_open_iff_forall_mem_open isOpen_iff_forall_mem_open
theorem interior_iInter_subset (s : ι → Set X) : interior (⋂ i, s i) ⊆ ⋂ i, interior (s i) :=
subset_iInter fun _ => interior_mono <| iInter_subset _ _
#align interior_Inter_subset interior_iInter_subset
theorem interior_iInter₂_subset (p : ι → Sort*) (s : ∀ i, p i → Set X) :
interior (⋂ (i) (j), s i j) ⊆ ⋂ (i) (j), interior (s i j) :=
(interior_iInter_subset _).trans <| iInter_mono fun _ => interior_iInter_subset _
#align interior_Inter₂_subset interior_iInter₂_subset
theorem interior_sInter_subset (S : Set (Set X)) : interior (⋂₀ S) ⊆ ⋂ s ∈ S, interior s :=
calc
interior (⋂₀ S) = interior (⋂ s ∈ S, s) := by rw [sInter_eq_biInter]
_ ⊆ ⋂ s ∈ S, interior s := interior_iInter₂_subset _ _
#align interior_sInter_subset interior_sInter_subset
theorem Filter.HasBasis.lift'_interior {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) : (l.lift' interior).HasBasis p fun i => interior (s i) :=
h.lift' fun _ _ ↦ interior_mono
theorem Filter.lift'_interior_le (l : Filter X) : l.lift' interior ≤ l := fun _s hs ↦
mem_of_superset (mem_lift' hs) interior_subset
theorem Filter.HasBasis.lift'_interior_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) (ho : ∀ i, p i → IsOpen (s i)) : l.lift' interior = l :=
le_antisymm l.lift'_interior_le <| h.lift'_interior.ge_iff.2 fun i hi ↦ by
simpa only [(ho i hi).interior_eq] using h.mem_of_mem hi
/-!
### Closure of a set
-/
@[simp]
theorem isClosed_closure : IsClosed (closure s) :=
isClosed_sInter fun _ => And.left
#align is_closed_closure isClosed_closure
theorem subset_closure : s ⊆ closure s :=
subset_sInter fun _ => And.right
#align subset_closure subset_closure
theorem not_mem_of_not_mem_closure {P : X} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
#align not_mem_of_not_mem_closure not_mem_of_not_mem_closure
theorem closure_minimal (h₁ : s ⊆ t) (h₂ : IsClosed t) : closure s ⊆ t :=
sInter_subset_of_mem ⟨h₂, h₁⟩
#align closure_minimal closure_minimal
theorem Disjoint.closure_left (hd : Disjoint s t) (ht : IsOpen t) :
Disjoint (closure s) t :=
disjoint_compl_left.mono_left <| closure_minimal hd.subset_compl_right ht.isClosed_compl
#align disjoint.closure_left Disjoint.closure_left
theorem Disjoint.closure_right (hd : Disjoint s t) (hs : IsOpen s) :
Disjoint s (closure t) :=
(hd.symm.closure_left hs).symm
#align disjoint.closure_right Disjoint.closure_right
theorem IsClosed.closure_eq (h : IsClosed s) : closure s = s :=
Subset.antisymm (closure_minimal (Subset.refl s) h) subset_closure
#align is_closed.closure_eq IsClosed.closure_eq
theorem IsClosed.closure_subset (hs : IsClosed s) : closure s ⊆ s :=
closure_minimal (Subset.refl _) hs
#align is_closed.closure_subset IsClosed.closure_subset
theorem IsClosed.closure_subset_iff (h₁ : IsClosed t) : closure s ⊆ t ↔ s ⊆ t :=
⟨Subset.trans subset_closure, fun h => closure_minimal h h₁⟩
#align is_closed.closure_subset_iff IsClosed.closure_subset_iff
theorem IsClosed.mem_iff_closure_subset (hs : IsClosed s) :
x ∈ s ↔ closure ({x} : Set X) ⊆ s :=
(hs.closure_subset_iff.trans Set.singleton_subset_iff).symm
#align is_closed.mem_iff_closure_subset IsClosed.mem_iff_closure_subset
@[mono, gcongr]
theorem closure_mono (h : s ⊆ t) : closure s ⊆ closure t :=
closure_minimal (Subset.trans h subset_closure) isClosed_closure
#align closure_mono closure_mono
theorem monotone_closure (X : Type*) [TopologicalSpace X] : Monotone (@closure X _) := fun _ _ =>
closure_mono
#align monotone_closure monotone_closure
theorem diff_subset_closure_iff : s \ t ⊆ closure t ↔ s ⊆ closure t := by
rw [diff_subset_iff, union_eq_self_of_subset_left subset_closure]
#align diff_subset_closure_iff diff_subset_closure_iff
theorem closure_inter_subset_inter_closure (s t : Set X) :
closure (s ∩ t) ⊆ closure s ∩ closure t :=
(monotone_closure X).map_inf_le s t
#align closure_inter_subset_inter_closure closure_inter_subset_inter_closure
theorem isClosed_of_closure_subset (h : closure s ⊆ s) : IsClosed s := by
rw [subset_closure.antisymm h]; exact isClosed_closure
#align is_closed_of_closure_subset isClosed_of_closure_subset
theorem closure_eq_iff_isClosed : closure s = s ↔ IsClosed s :=
⟨fun h => h ▸ isClosed_closure, IsClosed.closure_eq⟩
#align closure_eq_iff_is_closed closure_eq_iff_isClosed
theorem closure_subset_iff_isClosed : closure s ⊆ s ↔ IsClosed s :=
⟨isClosed_of_closure_subset, IsClosed.closure_subset⟩
#align closure_subset_iff_is_closed closure_subset_iff_isClosed
@[simp]
theorem closure_empty : closure (∅ : Set X) = ∅ :=
isClosed_empty.closure_eq
#align closure_empty closure_empty
@[simp]
theorem closure_empty_iff (s : Set X) : closure s = ∅ ↔ s = ∅ :=
⟨subset_eq_empty subset_closure, fun h => h.symm ▸ closure_empty⟩
#align closure_empty_iff closure_empty_iff
@[simp]
theorem closure_nonempty_iff : (closure s).Nonempty ↔ s.Nonempty := by
simp only [nonempty_iff_ne_empty, Ne, closure_empty_iff]
#align closure_nonempty_iff closure_nonempty_iff
alias ⟨Set.Nonempty.of_closure, Set.Nonempty.closure⟩ := closure_nonempty_iff
#align set.nonempty.of_closure Set.Nonempty.of_closure
#align set.nonempty.closure Set.Nonempty.closure
@[simp]
theorem closure_univ : closure (univ : Set X) = univ :=
isClosed_univ.closure_eq
#align closure_univ closure_univ
@[simp]
theorem closure_closure : closure (closure s) = closure s :=
isClosed_closure.closure_eq
#align closure_closure closure_closure
theorem closure_eq_compl_interior_compl : closure s = (interior sᶜ)ᶜ := by
rw [interior, closure, compl_sUnion, compl_image_set_of]
simp only [compl_subset_compl, isOpen_compl_iff]
#align closure_eq_compl_interior_compl closure_eq_compl_interior_compl
@[simp]
theorem closure_union : closure (s ∪ t) = closure s ∪ closure t := by
simp [closure_eq_compl_interior_compl, compl_inter]
#align closure_union closure_union
theorem Set.Finite.closure_biUnion {ι : Type*} {s : Set ι} (hs : s.Finite) (f : ι → Set X) :
closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) := by
simp [closure_eq_compl_interior_compl, hs.interior_biInter]
theorem Set.Finite.closure_sUnion {S : Set (Set X)} (hS : S.Finite) :
closure (⋃₀ S) = ⋃ s ∈ S, closure s := by
rw [sUnion_eq_biUnion, hS.closure_biUnion]
@[simp]
theorem Finset.closure_biUnion {ι : Type*} (s : Finset ι) (f : ι → Set X) :
closure (⋃ i ∈ s, f i) = ⋃ i ∈ s, closure (f i) :=
s.finite_toSet.closure_biUnion f
#align finset.closure_bUnion Finset.closure_biUnion
@[simp]
theorem closure_iUnion_of_finite [Finite ι] (f : ι → Set X) :
closure (⋃ i, f i) = ⋃ i, closure (f i) := by
rw [← sUnion_range, (finite_range _).closure_sUnion, biUnion_range]
#align closure_Union closure_iUnion_of_finite
theorem interior_subset_closure : interior s ⊆ closure s :=
Subset.trans interior_subset subset_closure
#align interior_subset_closure interior_subset_closure
@[simp]
theorem interior_compl : interior sᶜ = (closure s)ᶜ := by
simp [closure_eq_compl_interior_compl]
#align interior_compl interior_compl
@[simp]
theorem closure_compl : closure sᶜ = (interior s)ᶜ := by
simp [closure_eq_compl_interior_compl]
#align closure_compl closure_compl
theorem mem_closure_iff :
x ∈ closure s ↔ ∀ o, IsOpen o → x ∈ o → (o ∩ s).Nonempty :=
⟨fun h o oo ao =>
by_contradiction fun os =>
have : s ⊆ oᶜ := fun x xs xo => os ⟨x, xo, xs⟩
closure_minimal this (isClosed_compl_iff.2 oo) h ao,
fun H _ ⟨h₁, h₂⟩ =>
by_contradiction fun nc =>
let ⟨_, hc, hs⟩ := H _ h₁.isOpen_compl nc
hc (h₂ hs)⟩
#align mem_closure_iff mem_closure_iff
theorem closure_inter_open_nonempty_iff (h : IsOpen t) :
(closure s ∩ t).Nonempty ↔ (s ∩ t).Nonempty :=
⟨fun ⟨_x, hxcs, hxt⟩ => inter_comm t s ▸ mem_closure_iff.1 hxcs t h hxt, fun h =>
h.mono <| inf_le_inf_right t subset_closure⟩
#align closure_inter_open_nonempty_iff closure_inter_open_nonempty_iff
theorem Filter.le_lift'_closure (l : Filter X) : l ≤ l.lift' closure :=
le_lift'.2 fun _ h => mem_of_superset h subset_closure
#align filter.le_lift'_closure Filter.le_lift'_closure
theorem Filter.HasBasis.lift'_closure {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) : (l.lift' closure).HasBasis p fun i => closure (s i) :=
h.lift' (monotone_closure X)
#align filter.has_basis.lift'_closure Filter.HasBasis.lift'_closure
theorem Filter.HasBasis.lift'_closure_eq_self {l : Filter X} {p : ι → Prop} {s : ι → Set X}
(h : l.HasBasis p s) (hc : ∀ i, p i → IsClosed (s i)) : l.lift' closure = l :=
le_antisymm (h.ge_iff.2 fun i hi => (hc i hi).closure_eq ▸ mem_lift' (h.mem_of_mem hi))
l.le_lift'_closure
#align filter.has_basis.lift'_closure_eq_self Filter.HasBasis.lift'_closure_eq_self
@[simp]
theorem Filter.lift'_closure_eq_bot {l : Filter X} : l.lift' closure = ⊥ ↔ l = ⊥ :=
⟨fun h => bot_unique <| h ▸ l.le_lift'_closure, fun h =>
h.symm ▸ by rw [lift'_bot (monotone_closure _), closure_empty, principal_empty]⟩
#align filter.lift'_closure_eq_bot Filter.lift'_closure_eq_bot
theorem dense_iff_closure_eq : Dense s ↔ closure s = univ :=
eq_univ_iff_forall.symm
#align dense_iff_closure_eq dense_iff_closure_eq
alias ⟨Dense.closure_eq, _⟩ := dense_iff_closure_eq
#align dense.closure_eq Dense.closure_eq
theorem interior_eq_empty_iff_dense_compl : interior s = ∅ ↔ Dense sᶜ := by
rw [dense_iff_closure_eq, closure_compl, compl_univ_iff]
#align interior_eq_empty_iff_dense_compl interior_eq_empty_iff_dense_compl
theorem Dense.interior_compl (h : Dense s) : interior sᶜ = ∅ :=
interior_eq_empty_iff_dense_compl.2 <| by rwa [compl_compl]
#align dense.interior_compl Dense.interior_compl
/-- The closure of a set `s` is dense if and only if `s` is dense. -/
@[simp]
theorem dense_closure : Dense (closure s) ↔ Dense s := by
rw [Dense, Dense, closure_closure]
#align dense_closure dense_closure
protected alias ⟨_, Dense.closure⟩ := dense_closure
alias ⟨Dense.of_closure, _⟩ := dense_closure
#align dense.of_closure Dense.of_closure
#align dense.closure Dense.closure
@[simp]
theorem dense_univ : Dense (univ : Set X) := fun _ => subset_closure trivial
#align dense_univ dense_univ
/-- A set is dense if and only if it has a nonempty intersection with each nonempty open set. -/
theorem dense_iff_inter_open :
Dense s ↔ ∀ U, IsOpen U → U.Nonempty → (U ∩ s).Nonempty := by
constructor <;> intro h
· rintro U U_op ⟨x, x_in⟩
exact mem_closure_iff.1 (h _) U U_op x_in
· intro x
rw [mem_closure_iff]
intro U U_op x_in
exact h U U_op ⟨_, x_in⟩
#align dense_iff_inter_open dense_iff_inter_open
alias ⟨Dense.inter_open_nonempty, _⟩ := dense_iff_inter_open
#align dense.inter_open_nonempty Dense.inter_open_nonempty
theorem Dense.exists_mem_open (hs : Dense s) {U : Set X} (ho : IsOpen U)
(hne : U.Nonempty) : ∃ x ∈ s, x ∈ U :=
let ⟨x, hx⟩ := hs.inter_open_nonempty U ho hne
⟨x, hx.2, hx.1⟩
#align dense.exists_mem_open Dense.exists_mem_open
theorem Dense.nonempty_iff (hs : Dense s) : s.Nonempty ↔ Nonempty X :=
⟨fun ⟨x, _⟩ => ⟨x⟩, fun ⟨x⟩ =>
let ⟨y, hy⟩ := hs.inter_open_nonempty _ isOpen_univ ⟨x, trivial⟩
⟨y, hy.2⟩⟩
#align dense.nonempty_iff Dense.nonempty_iff
theorem Dense.nonempty [h : Nonempty X] (hs : Dense s) : s.Nonempty :=
hs.nonempty_iff.2 h
#align dense.nonempty Dense.nonempty
@[mono]
theorem Dense.mono (h : s₁ ⊆ s₂) (hd : Dense s₁) : Dense s₂ := fun x =>
closure_mono h (hd x)
#align dense.mono Dense.mono
/-- Complement to a singleton is dense if and only if the singleton is not an open set. -/
theorem dense_compl_singleton_iff_not_open :
Dense ({x}ᶜ : Set X) ↔ ¬IsOpen ({x} : Set X) := by
constructor
· intro hd ho
exact (hd.inter_open_nonempty _ ho (singleton_nonempty _)).ne_empty (inter_compl_self _)
· refine fun ho => dense_iff_inter_open.2 fun U hU hne => inter_compl_nonempty_iff.2 fun hUx => ?_
obtain rfl : U = {x} := eq_singleton_iff_nonempty_unique_mem.2 ⟨hne, hUx⟩
exact ho hU
#align dense_compl_singleton_iff_not_open dense_compl_singleton_iff_not_open
/-!
### Frontier of a set
-/
@[simp]
theorem closure_diff_interior (s : Set X) : closure s \ interior s = frontier s :=
rfl
#align closure_diff_interior closure_diff_interior
/-- Interior and frontier are disjoint. -/
lemma disjoint_interior_frontier : Disjoint (interior s) (frontier s) := by
rw [disjoint_iff_inter_eq_empty, ← closure_diff_interior, diff_eq,
← inter_assoc, inter_comm, ← inter_assoc, compl_inter_self, empty_inter]
@[simp]
theorem closure_diff_frontier (s : Set X) : closure s \ frontier s = interior s := by
rw [frontier, diff_diff_right_self, inter_eq_self_of_subset_right interior_subset_closure]
#align closure_diff_frontier closure_diff_frontier
@[simp]
theorem self_diff_frontier (s : Set X) : s \ frontier s = interior s := by
rw [frontier, diff_diff_right, diff_eq_empty.2 subset_closure,
inter_eq_self_of_subset_right interior_subset, empty_union]
#align self_diff_frontier self_diff_frontier
theorem frontier_eq_closure_inter_closure : frontier s = closure s ∩ closure sᶜ := by
rw [closure_compl, frontier, diff_eq]
#align frontier_eq_closure_inter_closure frontier_eq_closure_inter_closure
theorem frontier_subset_closure : frontier s ⊆ closure s :=
diff_subset
#align frontier_subset_closure frontier_subset_closure
theorem IsClosed.frontier_subset (hs : IsClosed s) : frontier s ⊆ s :=
frontier_subset_closure.trans hs.closure_eq.subset
#align is_closed.frontier_subset IsClosed.frontier_subset
theorem frontier_closure_subset : frontier (closure s) ⊆ frontier s :=
diff_subset_diff closure_closure.subset <| interior_mono subset_closure
#align frontier_closure_subset frontier_closure_subset
theorem frontier_interior_subset : frontier (interior s) ⊆ frontier s :=
diff_subset_diff (closure_mono interior_subset) interior_interior.symm.subset
#align frontier_interior_subset frontier_interior_subset
/-- The complement of a set has the same frontier as the original set. -/
@[simp]
theorem frontier_compl (s : Set X) : frontier sᶜ = frontier s := by
simp only [frontier_eq_closure_inter_closure, compl_compl, inter_comm]
#align frontier_compl frontier_compl
@[simp]
theorem frontier_univ : frontier (univ : Set X) = ∅ := by simp [frontier]
#align frontier_univ frontier_univ
@[simp]
theorem frontier_empty : frontier (∅ : Set X) = ∅ := by simp [frontier]
#align frontier_empty frontier_empty
theorem frontier_inter_subset (s t : Set X) :
frontier (s ∩ t) ⊆ frontier s ∩ closure t ∪ closure s ∩ frontier t := by
simp only [frontier_eq_closure_inter_closure, compl_inter, closure_union]
refine (inter_subset_inter_left _ (closure_inter_subset_inter_closure s t)).trans_eq ?_
simp only [inter_union_distrib_left, union_inter_distrib_right, inter_assoc,
inter_comm (closure t)]
#align frontier_inter_subset frontier_inter_subset
theorem frontier_union_subset (s t : Set X) :
frontier (s ∪ t) ⊆ frontier s ∩ closure tᶜ ∪ closure sᶜ ∩ frontier t := by
simpa only [frontier_compl, ← compl_union] using frontier_inter_subset sᶜ tᶜ
#align frontier_union_subset frontier_union_subset
theorem IsClosed.frontier_eq (hs : IsClosed s) : frontier s = s \ interior s := by
rw [frontier, hs.closure_eq]
#align is_closed.frontier_eq IsClosed.frontier_eq
theorem IsOpen.frontier_eq (hs : IsOpen s) : frontier s = closure s \ s := by
rw [frontier, hs.interior_eq]
#align is_open.frontier_eq IsOpen.frontier_eq
theorem IsOpen.inter_frontier_eq (hs : IsOpen s) : s ∩ frontier s = ∅ := by
rw [hs.frontier_eq, inter_diff_self]
#align is_open.inter_frontier_eq IsOpen.inter_frontier_eq
/-- The frontier of a set is closed. -/
theorem isClosed_frontier : IsClosed (frontier s) := by
rw [frontier_eq_closure_inter_closure]; exact IsClosed.inter isClosed_closure isClosed_closure
#align is_closed_frontier isClosed_frontier
/-- The frontier of a closed set has no interior point. -/
theorem interior_frontier (h : IsClosed s) : interior (frontier s) = ∅ := by
have A : frontier s = s \ interior s := h.frontier_eq
have B : interior (frontier s) ⊆ interior s := by rw [A]; exact interior_mono diff_subset
have C : interior (frontier s) ⊆ frontier s := interior_subset
have : interior (frontier s) ⊆ interior s ∩ (s \ interior s) :=
subset_inter B (by simpa [A] using C)
rwa [inter_diff_self, subset_empty_iff] at this
#align interior_frontier interior_frontier
theorem closure_eq_interior_union_frontier (s : Set X) : closure s = interior s ∪ frontier s :=
(union_diff_cancel interior_subset_closure).symm
#align closure_eq_interior_union_frontier closure_eq_interior_union_frontier
theorem closure_eq_self_union_frontier (s : Set X) : closure s = s ∪ frontier s :=
(union_diff_cancel' interior_subset subset_closure).symm
#align closure_eq_self_union_frontier closure_eq_self_union_frontier
theorem Disjoint.frontier_left (ht : IsOpen t) (hd : Disjoint s t) : Disjoint (frontier s) t :=
subset_compl_iff_disjoint_right.1 <|
frontier_subset_closure.trans <| closure_minimal (disjoint_left.1 hd) <| isClosed_compl_iff.2 ht
#align disjoint.frontier_left Disjoint.frontier_left
theorem Disjoint.frontier_right (hs : IsOpen s) (hd : Disjoint s t) : Disjoint s (frontier t) :=
(hd.symm.frontier_left hs).symm
#align disjoint.frontier_right Disjoint.frontier_right
theorem frontier_eq_inter_compl_interior :
frontier s = (interior s)ᶜ ∩ (interior sᶜ)ᶜ := by
rw [← frontier_compl, ← closure_compl, ← diff_eq, closure_diff_interior]
#align frontier_eq_inter_compl_interior frontier_eq_inter_compl_interior
theorem compl_frontier_eq_union_interior :
(frontier s)ᶜ = interior s ∪ interior sᶜ := by
rw [frontier_eq_inter_compl_interior]
simp only [compl_inter, compl_compl]
#align compl_frontier_eq_union_interior compl_frontier_eq_union_interior
/-!
### Neighborhoods
-/
theorem nhds_def' (x : X) : 𝓝 x = ⨅ (s : Set X) (_ : IsOpen s) (_ : x ∈ s), 𝓟 s := by
simp only [nhds_def, mem_setOf_eq, @and_comm (x ∈ _), iInf_and]
#align nhds_def' nhds_def'
/-- The open sets containing `x` are a basis for the neighborhood filter. See `nhds_basis_opens'`
for a variant using open neighborhoods instead. -/
theorem nhds_basis_opens (x : X) :
(𝓝 x).HasBasis (fun s : Set X => x ∈ s ∧ IsOpen s) fun s => s := by
rw [nhds_def]
exact hasBasis_biInf_principal
(fun s ⟨has, hs⟩ t ⟨hat, ht⟩ =>
⟨s ∩ t, ⟨⟨has, hat⟩, IsOpen.inter hs ht⟩, ⟨inter_subset_left, inter_subset_right⟩⟩)
⟨univ, ⟨mem_univ x, isOpen_univ⟩⟩
#align nhds_basis_opens nhds_basis_opens
theorem nhds_basis_closeds (x : X) : (𝓝 x).HasBasis (fun s : Set X => x ∉ s ∧ IsClosed s) compl :=
⟨fun t => (nhds_basis_opens x).mem_iff.trans <|
compl_surjective.exists.trans <| by simp only [isOpen_compl_iff, mem_compl_iff]⟩
#align nhds_basis_closeds nhds_basis_closeds
@[simp]
theorem lift'_nhds_interior (x : X) : (𝓝 x).lift' interior = 𝓝 x :=
(nhds_basis_opens x).lift'_interior_eq_self fun _ ↦ And.right
theorem Filter.HasBasis.nhds_interior {x : X} {p : ι → Prop} {s : ι → Set X}
(h : (𝓝 x).HasBasis p s) : (𝓝 x).HasBasis p (interior <| s ·) :=
lift'_nhds_interior x ▸ h.lift'_interior
/-- A filter lies below the neighborhood filter at `x` iff it contains every open set around `x`. -/
theorem le_nhds_iff {f} : f ≤ 𝓝 x ↔ ∀ s : Set X, x ∈ s → IsOpen s → s ∈ f := by simp [nhds_def]
#align le_nhds_iff le_nhds_iff
/-- To show a filter is above the neighborhood filter at `x`, it suffices to show that it is above
the principal filter of some open set `s` containing `x`. -/
theorem nhds_le_of_le {f} (h : x ∈ s) (o : IsOpen s) (sf : 𝓟 s ≤ f) : 𝓝 x ≤ f := by
rw [nhds_def]; exact iInf₂_le_of_le s ⟨h, o⟩ sf
#align nhds_le_of_le nhds_le_of_le
theorem mem_nhds_iff : s ∈ 𝓝 x ↔ ∃ t ⊆ s, IsOpen t ∧ x ∈ t :=
(nhds_basis_opens x).mem_iff.trans <| exists_congr fun _ =>
⟨fun h => ⟨h.2, h.1.2, h.1.1⟩, fun h => ⟨⟨h.2.2, h.2.1⟩, h.1⟩⟩
#align mem_nhds_iff mem_nhds_iffₓ
/-- A predicate is true in a neighborhood of `x` iff it is true for all the points in an open set
containing `x`. -/
theorem eventually_nhds_iff {p : X → Prop} :
(∀ᶠ x in 𝓝 x, p x) ↔ ∃ t : Set X, (∀ x ∈ t, p x) ∧ IsOpen t ∧ x ∈ t :=
mem_nhds_iff.trans <| by simp only [subset_def, exists_prop, mem_setOf_eq]
#align eventually_nhds_iff eventually_nhds_iff
theorem mem_interior_iff_mem_nhds : x ∈ interior s ↔ s ∈ 𝓝 x :=
mem_interior.trans mem_nhds_iff.symm
#align mem_interior_iff_mem_nhds mem_interior_iff_mem_nhds
theorem map_nhds {f : X → α} :
map f (𝓝 x) = ⨅ s ∈ { s : Set X | x ∈ s ∧ IsOpen s }, 𝓟 (f '' s) :=
((nhds_basis_opens x).map f).eq_biInf
#align map_nhds map_nhds
theorem mem_of_mem_nhds : s ∈ 𝓝 x → x ∈ s := fun H =>
let ⟨_t, ht, _, hs⟩ := mem_nhds_iff.1 H; ht hs
#align mem_of_mem_nhds mem_of_mem_nhds
/-- If a predicate is true in a neighborhood of `x`, then it is true for `x`. -/
theorem Filter.Eventually.self_of_nhds {p : X → Prop} (h : ∀ᶠ y in 𝓝 x, p y) : p x :=
mem_of_mem_nhds h
#align filter.eventually.self_of_nhds Filter.Eventually.self_of_nhds
theorem IsOpen.mem_nhds (hs : IsOpen s) (hx : x ∈ s) : s ∈ 𝓝 x :=
mem_nhds_iff.2 ⟨s, Subset.refl _, hs, hx⟩
#align is_open.mem_nhds IsOpen.mem_nhds
protected theorem IsOpen.mem_nhds_iff (hs : IsOpen s) : s ∈ 𝓝 x ↔ x ∈ s :=
⟨mem_of_mem_nhds, fun hx => mem_nhds_iff.2 ⟨s, Subset.rfl, hs, hx⟩⟩
#align is_open.mem_nhds_iff IsOpen.mem_nhds_iff
theorem IsClosed.compl_mem_nhds (hs : IsClosed s) (hx : x ∉ s) : sᶜ ∈ 𝓝 x :=
hs.isOpen_compl.mem_nhds (mem_compl hx)
#align is_closed.compl_mem_nhds IsClosed.compl_mem_nhds
theorem IsOpen.eventually_mem (hs : IsOpen s) (hx : x ∈ s) :
∀ᶠ x in 𝓝 x, x ∈ s :=
IsOpen.mem_nhds hs hx
#align is_open.eventually_mem IsOpen.eventually_mem
/-- The open neighborhoods of `x` are a basis for the neighborhood filter. See `nhds_basis_opens`
for a variant using open sets around `x` instead. -/
theorem nhds_basis_opens' (x : X) :
(𝓝 x).HasBasis (fun s : Set X => s ∈ 𝓝 x ∧ IsOpen s) fun x => x := by
convert nhds_basis_opens x using 2
exact and_congr_left_iff.2 IsOpen.mem_nhds_iff
#align nhds_basis_opens' nhds_basis_opens'
/-- If `U` is a neighborhood of each point of a set `s` then it is a neighborhood of `s`:
it contains an open set containing `s`. -/
theorem exists_open_set_nhds {U : Set X} (h : ∀ x ∈ s, U ∈ 𝓝 x) :
∃ V : Set X, s ⊆ V ∧ IsOpen V ∧ V ⊆ U :=
⟨interior U, fun x hx => mem_interior_iff_mem_nhds.2 <| h x hx, isOpen_interior, interior_subset⟩
#align exists_open_set_nhds exists_open_set_nhds
/-- If `U` is a neighborhood of each point of a set `s` then it is a neighborhood of s:
it contains an open set containing `s`. -/
theorem exists_open_set_nhds' {U : Set X} (h : U ∈ ⨆ x ∈ s, 𝓝 x) :
∃ V : Set X, s ⊆ V ∧ IsOpen V ∧ V ⊆ U :=
exists_open_set_nhds (by simpa using h)
#align exists_open_set_nhds' exists_open_set_nhds'
/-- If a predicate is true in a neighbourhood of `x`, then for `y` sufficiently close
to `x` this predicate is true in a neighbourhood of `y`. -/
theorem Filter.Eventually.eventually_nhds {p : X → Prop} (h : ∀ᶠ y in 𝓝 x, p y) :
∀ᶠ y in 𝓝 x, ∀ᶠ x in 𝓝 y, p x :=
let ⟨t, htp, hto, ha⟩ := eventually_nhds_iff.1 h
eventually_nhds_iff.2 ⟨t, fun _x hx => eventually_nhds_iff.2 ⟨t, htp, hto, hx⟩, hto, ha⟩
#align filter.eventually.eventually_nhds Filter.Eventually.eventually_nhds
@[simp]
theorem eventually_eventually_nhds {p : X → Prop} :
(∀ᶠ y in 𝓝 x, ∀ᶠ x in 𝓝 y, p x) ↔ ∀ᶠ x in 𝓝 x, p x :=
⟨fun h => h.self_of_nhds, fun h => h.eventually_nhds⟩
#align eventually_eventually_nhds eventually_eventually_nhds
@[simp]
theorem frequently_frequently_nhds {p : X → Prop} :
(∃ᶠ x' in 𝓝 x, ∃ᶠ x'' in 𝓝 x', p x'') ↔ ∃ᶠ x in 𝓝 x, p x := by
rw [← not_iff_not]
simp only [not_frequently, eventually_eventually_nhds]
#align frequently_frequently_nhds frequently_frequently_nhds
@[simp]
theorem eventually_mem_nhds : (∀ᶠ x' in 𝓝 x, s ∈ 𝓝 x') ↔ s ∈ 𝓝 x :=
eventually_eventually_nhds
#align eventually_mem_nhds eventually_mem_nhds
@[simp]
theorem nhds_bind_nhds : (𝓝 x).bind 𝓝 = 𝓝 x :=
Filter.ext fun _ => eventually_eventually_nhds
#align nhds_bind_nhds nhds_bind_nhds
@[simp]
theorem eventually_eventuallyEq_nhds {f g : X → α} :
(∀ᶠ y in 𝓝 x, f =ᶠ[𝓝 y] g) ↔ f =ᶠ[𝓝 x] g :=
eventually_eventually_nhds
#align eventually_eventually_eq_nhds eventually_eventuallyEq_nhds
theorem Filter.EventuallyEq.eq_of_nhds {f g : X → α} (h : f =ᶠ[𝓝 x] g) : f x = g x :=
h.self_of_nhds
#align filter.eventually_eq.eq_of_nhds Filter.EventuallyEq.eq_of_nhds
@[simp]
theorem eventually_eventuallyLE_nhds [LE α] {f g : X → α} :
(∀ᶠ y in 𝓝 x, f ≤ᶠ[𝓝 y] g) ↔ f ≤ᶠ[𝓝 x] g :=
eventually_eventually_nhds
#align eventually_eventually_le_nhds eventually_eventuallyLE_nhds
/-- If two functions are equal in a neighbourhood of `x`, then for `y` sufficiently close
to `x` these functions are equal in a neighbourhood of `y`. -/
theorem Filter.EventuallyEq.eventuallyEq_nhds {f g : X → α} (h : f =ᶠ[𝓝 x] g) :
∀ᶠ y in 𝓝 x, f =ᶠ[𝓝 y] g :=
h.eventually_nhds
#align filter.eventually_eq.eventually_eq_nhds Filter.EventuallyEq.eventuallyEq_nhds
/-- If `f x ≤ g x` in a neighbourhood of `x`, then for `y` sufficiently close to `x` we have
`f x ≤ g x` in a neighbourhood of `y`. -/
theorem Filter.EventuallyLE.eventuallyLE_nhds [LE α] {f g : X → α} (h : f ≤ᶠ[𝓝 x] g) :
∀ᶠ y in 𝓝 x, f ≤ᶠ[𝓝 y] g :=
h.eventually_nhds
#align filter.eventually_le.eventually_le_nhds Filter.EventuallyLE.eventuallyLE_nhds
theorem all_mem_nhds (x : X) (P : Set X → Prop) (hP : ∀ s t, s ⊆ t → P s → P t) :
(∀ s ∈ 𝓝 x, P s) ↔ ∀ s, IsOpen s → x ∈ s → P s :=
((nhds_basis_opens x).forall_iff hP).trans <| by simp only [@and_comm (x ∈ _), and_imp]
#align all_mem_nhds all_mem_nhds
theorem all_mem_nhds_filter (x : X) (f : Set X → Set α) (hf : ∀ s t, s ⊆ t → f s ⊆ f t)
(l : Filter α) : (∀ s ∈ 𝓝 x, f s ∈ l) ↔ ∀ s, IsOpen s → x ∈ s → f s ∈ l :=
all_mem_nhds _ _ fun s t ssubt h => mem_of_superset h (hf s t ssubt)
#align all_mem_nhds_filter all_mem_nhds_filter
theorem tendsto_nhds {f : α → X} {l : Filter α} :
Tendsto f l (𝓝 x) ↔ ∀ s, IsOpen s → x ∈ s → f ⁻¹' s ∈ l :=
all_mem_nhds_filter _ _ (fun _ _ h => preimage_mono h) _
#align tendsto_nhds tendsto_nhds
theorem tendsto_atTop_nhds [Nonempty α] [SemilatticeSup α] {f : α → X} :
Tendsto f atTop (𝓝 x) ↔ ∀ U : Set X, x ∈ U → IsOpen U → ∃ N, ∀ n, N ≤ n → f n ∈ U :=
(atTop_basis.tendsto_iff (nhds_basis_opens x)).trans <| by
simp only [and_imp, exists_prop, true_and_iff, mem_Ici, ge_iff_le]
#align tendsto_at_top_nhds tendsto_atTop_nhds
theorem tendsto_const_nhds {f : Filter α} : Tendsto (fun _ : α => x) f (𝓝 x) :=
tendsto_nhds.mpr fun _ _ ha => univ_mem' fun _ => ha
#align tendsto_const_nhds tendsto_const_nhds
theorem tendsto_atTop_of_eventually_const {ι : Type*} [SemilatticeSup ι] [Nonempty ι]
{u : ι → X} {i₀ : ι} (h : ∀ i ≥ i₀, u i = x) : Tendsto u atTop (𝓝 x) :=
Tendsto.congr' (EventuallyEq.symm (eventually_atTop.mpr ⟨i₀, h⟩)) tendsto_const_nhds
#align tendsto_at_top_of_eventually_const tendsto_atTop_of_eventually_const
theorem tendsto_atBot_of_eventually_const {ι : Type*} [SemilatticeInf ι] [Nonempty ι]
{u : ι → X} {i₀ : ι} (h : ∀ i ≤ i₀, u i = x) : Tendsto u atBot (𝓝 x) :=
Tendsto.congr' (EventuallyEq.symm (eventually_atBot.mpr ⟨i₀, h⟩)) tendsto_const_nhds
#align tendsto_at_bot_of_eventually_const tendsto_atBot_of_eventually_const
theorem pure_le_nhds : pure ≤ (𝓝 : X → Filter X) := fun _ _ hs => mem_pure.2 <| mem_of_mem_nhds hs
#align pure_le_nhds pure_le_nhds
theorem tendsto_pure_nhds (f : α → X) (a : α) : Tendsto f (pure a) (𝓝 (f a)) :=
(tendsto_pure_pure f a).mono_right (pure_le_nhds _)
#align tendsto_pure_nhds tendsto_pure_nhds
theorem OrderTop.tendsto_atTop_nhds [PartialOrder α] [OrderTop α] (f : α → X) :
Tendsto f atTop (𝓝 (f ⊤)) :=
(tendsto_atTop_pure f).mono_right (pure_le_nhds _)
#align order_top.tendsto_at_top_nhds OrderTop.tendsto_atTop_nhds
@[simp]
instance nhds_neBot : NeBot (𝓝 x) :=
neBot_of_le (pure_le_nhds x)
#align nhds_ne_bot nhds_neBot
theorem tendsto_nhds_of_eventually_eq {l : Filter α} {f : α → X} (h : ∀ᶠ x' in l, f x' = x) :
Tendsto f l (𝓝 x) :=
tendsto_const_nhds.congr' (.symm h)
theorem Filter.EventuallyEq.tendsto {l : Filter α} {f : α → X} (hf : f =ᶠ[l] fun _ ↦ x) :
Tendsto f l (𝓝 x) :=
tendsto_nhds_of_eventually_eq hf
/-!
### Cluster points
In this section we define [cluster points](https://en.wikipedia.org/wiki/Limit_point)
(also known as limit points and accumulation points) of a filter and of a sequence.
-/
theorem ClusterPt.neBot {F : Filter X} (h : ClusterPt x F) : NeBot (𝓝 x ⊓ F) :=
h
#align cluster_pt.ne_bot ClusterPt.neBot
theorem Filter.HasBasis.clusterPt_iff {ιX ιF} {pX : ιX → Prop} {sX : ιX → Set X} {pF : ιF → Prop}
{sF : ιF → Set X} {F : Filter X} (hX : (𝓝 x).HasBasis pX sX) (hF : F.HasBasis pF sF) :
ClusterPt x F ↔ ∀ ⦃i⦄, pX i → ∀ ⦃j⦄, pF j → (sX i ∩ sF j).Nonempty :=
hX.inf_basis_neBot_iff hF
#align filter.has_basis.cluster_pt_iff Filter.HasBasis.clusterPt_iff
theorem clusterPt_iff {F : Filter X} :
ClusterPt x F ↔ ∀ ⦃U : Set X⦄, U ∈ 𝓝 x → ∀ ⦃V⦄, V ∈ F → (U ∩ V).Nonempty :=
inf_neBot_iff
#align cluster_pt_iff clusterPt_iff
theorem clusterPt_iff_not_disjoint {F : Filter X} :
ClusterPt x F ↔ ¬Disjoint (𝓝 x) F := by
rw [disjoint_iff, ClusterPt, neBot_iff]
/-- `x` is a cluster point of a set `s` if every neighbourhood of `x` meets `s` on a nonempty
set. See also `mem_closure_iff_clusterPt`. -/
theorem clusterPt_principal_iff :
ClusterPt x (𝓟 s) ↔ ∀ U ∈ 𝓝 x, (U ∩ s).Nonempty :=
inf_principal_neBot_iff
#align cluster_pt_principal_iff clusterPt_principal_iff
theorem clusterPt_principal_iff_frequently :
ClusterPt x (𝓟 s) ↔ ∃ᶠ y in 𝓝 x, y ∈ s := by
simp only [clusterPt_principal_iff, frequently_iff, Set.Nonempty, exists_prop, mem_inter_iff]
#align cluster_pt_principal_iff_frequently clusterPt_principal_iff_frequently
theorem ClusterPt.of_le_nhds {f : Filter X} (H : f ≤ 𝓝 x) [NeBot f] : ClusterPt x f := by
rwa [ClusterPt, inf_eq_right.mpr H]
#align cluster_pt.of_le_nhds ClusterPt.of_le_nhds
theorem ClusterPt.of_le_nhds' {f : Filter X} (H : f ≤ 𝓝 x) (_hf : NeBot f) :
ClusterPt x f :=
ClusterPt.of_le_nhds H
#align cluster_pt.of_le_nhds' ClusterPt.of_le_nhds'
theorem ClusterPt.of_nhds_le {f : Filter X} (H : 𝓝 x ≤ f) : ClusterPt x f := by
simp only [ClusterPt, inf_eq_left.mpr H, nhds_neBot]
#align cluster_pt.of_nhds_le ClusterPt.of_nhds_le
theorem ClusterPt.mono {f g : Filter X} (H : ClusterPt x f) (h : f ≤ g) : ClusterPt x g :=
NeBot.mono H <| inf_le_inf_left _ h
#align cluster_pt.mono ClusterPt.mono
theorem ClusterPt.of_inf_left {f g : Filter X} (H : ClusterPt x <| f ⊓ g) : ClusterPt x f :=
H.mono inf_le_left
#align cluster_pt.of_inf_left ClusterPt.of_inf_left
theorem ClusterPt.of_inf_right {f g : Filter X} (H : ClusterPt x <| f ⊓ g) :
ClusterPt x g :=
H.mono inf_le_right
#align cluster_pt.of_inf_right ClusterPt.of_inf_right
theorem Ultrafilter.clusterPt_iff {f : Ultrafilter X} : ClusterPt x f ↔ ↑f ≤ 𝓝 x :=
⟨f.le_of_inf_neBot', fun h => ClusterPt.of_le_nhds h⟩
#align ultrafilter.cluster_pt_iff Ultrafilter.clusterPt_iff
theorem clusterPt_iff_ultrafilter {f : Filter X} : ClusterPt x f ↔
∃ u : Ultrafilter X, u ≤ f ∧ u ≤ 𝓝 x := by
simp_rw [ClusterPt, ← le_inf_iff, exists_ultrafilter_iff, inf_comm]
theorem mapClusterPt_def {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ClusterPt x (map u F) := Iff.rfl
theorem mapClusterPt_iff {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ∀ s ∈ 𝓝 x, ∃ᶠ a in F, u a ∈ s := by
simp_rw [MapClusterPt, ClusterPt, inf_neBot_iff_frequently_left, frequently_map]
rfl
#align map_cluster_pt_iff mapClusterPt_iff
theorem mapClusterPt_iff_ultrafilter {ι : Type*} (x : X) (F : Filter ι) (u : ι → X) :
MapClusterPt x F u ↔ ∃ U : Ultrafilter ι, U ≤ F ∧ Tendsto u U (𝓝 x) := by
simp_rw [MapClusterPt, ClusterPt, ← Filter.push_pull', map_neBot_iff, tendsto_iff_comap,
← le_inf_iff, exists_ultrafilter_iff, inf_comm]
theorem mapClusterPt_comp {X α β : Type*} {x : X} [TopologicalSpace X] {F : Filter α} {φ : α → β}
{u : β → X} : MapClusterPt x F (u ∘ φ) ↔ MapClusterPt x (map φ F) u := Iff.rfl
theorem mapClusterPt_of_comp {F : Filter α} {φ : β → α} {p : Filter β}
{u : α → X} [NeBot p] (h : Tendsto φ p F) (H : Tendsto (u ∘ φ) p (𝓝 x)) :
MapClusterPt x F u := by
have :=
calc
map (u ∘ φ) p = map u (map φ p) := map_map
_ ≤ map u F := map_mono h
have : map (u ∘ φ) p ≤ 𝓝 x ⊓ map u F := le_inf H this
exact neBot_of_le this
#align map_cluster_pt_of_comp mapClusterPt_of_comp
theorem acc_iff_cluster (x : X) (F : Filter X) : AccPt x F ↔ ClusterPt x (𝓟 {x}ᶜ ⊓ F) := by
rw [AccPt, nhdsWithin, ClusterPt, inf_assoc]
#align acc_iff_cluster acc_iff_cluster
/-- `x` is an accumulation point of a set `C` iff it is a cluster point of `C ∖ {x}`. -/
theorem acc_principal_iff_cluster (x : X) (C : Set X) :
AccPt x (𝓟 C) ↔ ClusterPt x (𝓟 (C \ {x})) := by
rw [acc_iff_cluster, inf_principal, inter_comm, diff_eq]
#align acc_principal_iff_cluster acc_principal_iff_cluster
/-- `x` is an accumulation point of a set `C` iff every neighborhood
of `x` contains a point of `C` other than `x`. -/
theorem accPt_iff_nhds (x : X) (C : Set X) : AccPt x (𝓟 C) ↔ ∀ U ∈ 𝓝 x, ∃ y ∈ U ∩ C, y ≠ x := by
simp [acc_principal_iff_cluster, clusterPt_principal_iff, Set.Nonempty, exists_prop, and_assoc,
@and_comm (¬_ = x)]
#align acc_pt_iff_nhds accPt_iff_nhds
/-- `x` is an accumulation point of a set `C` iff
there are points near `x` in `C` and different from `x`. -/
theorem accPt_iff_frequently (x : X) (C : Set X) : AccPt x (𝓟 C) ↔ ∃ᶠ y in 𝓝 x, y ≠ x ∧ y ∈ C := by
simp [acc_principal_iff_cluster, clusterPt_principal_iff_frequently, and_comm]
#align acc_pt_iff_frequently accPt_iff_frequently
/-- If `x` is an accumulation point of `F` and `F ≤ G`, then
`x` is an accumulation point of `D`. -/
theorem AccPt.mono {F G : Filter X} (h : AccPt x F) (hFG : F ≤ G) : AccPt x G :=
NeBot.mono h (inf_le_inf_left _ hFG)
#align acc_pt.mono AccPt.mono
/-!
### Interior, closure and frontier in terms of neighborhoods
-/
theorem interior_eq_nhds' : interior s = { x | s ∈ 𝓝 x } :=
Set.ext fun x => by simp only [mem_interior, mem_nhds_iff, mem_setOf_eq]
#align interior_eq_nhds' interior_eq_nhds'
theorem interior_eq_nhds : interior s = { x | 𝓝 x ≤ 𝓟 s } :=
interior_eq_nhds'.trans <| by simp only [le_principal_iff]
#align interior_eq_nhds interior_eq_nhds
@[simp]
theorem interior_mem_nhds : interior s ∈ 𝓝 x ↔ s ∈ 𝓝 x :=
⟨fun h => mem_of_superset h interior_subset, fun h =>
IsOpen.mem_nhds isOpen_interior (mem_interior_iff_mem_nhds.2 h)⟩
#align interior_mem_nhds interior_mem_nhds
theorem interior_setOf_eq {p : X → Prop} : interior { x | p x } = { x | ∀ᶠ y in 𝓝 x, p y } :=
interior_eq_nhds'
#align interior_set_of_eq interior_setOf_eq
theorem isOpen_setOf_eventually_nhds {p : X → Prop} : IsOpen { x | ∀ᶠ y in 𝓝 x, p y } := by
simp only [← interior_setOf_eq, isOpen_interior]
#align is_open_set_of_eventually_nhds isOpen_setOf_eventually_nhds
theorem subset_interior_iff_nhds {V : Set X} : s ⊆ interior V ↔ ∀ x ∈ s, V ∈ 𝓝 x := by
simp_rw [subset_def, mem_interior_iff_mem_nhds]
#align subset_interior_iff_nhds subset_interior_iff_nhds
theorem isOpen_iff_nhds : IsOpen s ↔ ∀ x ∈ s, 𝓝 x ≤ 𝓟 s :=
calc
IsOpen s ↔ s ⊆ interior s := subset_interior_iff_isOpen.symm
_ ↔ ∀ x ∈ s, 𝓝 x ≤ 𝓟 s := by simp_rw [interior_eq_nhds, subset_def, mem_setOf]
#align is_open_iff_nhds isOpen_iff_nhds
theorem TopologicalSpace.ext_iff_nhds {t t' : TopologicalSpace X} :
t = t' ↔ ∀ x, @nhds _ t x = @nhds _ t' x :=
⟨fun H x ↦ congrFun (congrArg _ H) _, fun H ↦ by ext; simp_rw [@isOpen_iff_nhds _ _ _, H]⟩
alias ⟨_, TopologicalSpace.ext_nhds⟩ := TopologicalSpace.ext_iff_nhds
theorem isOpen_iff_mem_nhds : IsOpen s ↔ ∀ x ∈ s, s ∈ 𝓝 x :=
isOpen_iff_nhds.trans <| forall_congr' fun _ => imp_congr_right fun _ => le_principal_iff
#align is_open_iff_mem_nhds isOpen_iff_mem_nhds
/-- A set `s` is open iff for every point `x` in `s` and every `y` close to `x`, `y` is in `s`. -/
theorem isOpen_iff_eventually : IsOpen s ↔ ∀ x, x ∈ s → ∀ᶠ y in 𝓝 x, y ∈ s :=
isOpen_iff_mem_nhds
#align is_open_iff_eventually isOpen_iff_eventually
theorem isOpen_iff_ultrafilter :
IsOpen s ↔ ∀ x ∈ s, ∀ (l : Ultrafilter X), ↑l ≤ 𝓝 x → s ∈ l := by
simp_rw [isOpen_iff_mem_nhds, ← mem_iff_ultrafilter]
#align is_open_iff_ultrafilter isOpen_iff_ultrafilter
theorem isOpen_singleton_iff_nhds_eq_pure (x : X) : IsOpen ({x} : Set X) ↔ 𝓝 x = pure x := by
constructor
· intro h
apply le_antisymm _ (pure_le_nhds x)
rw [le_pure_iff]
exact h.mem_nhds (mem_singleton x)
· intro h
simp [isOpen_iff_nhds, h]
#align is_open_singleton_iff_nhds_eq_pure isOpen_singleton_iff_nhds_eq_pure
theorem isOpen_singleton_iff_punctured_nhds (x : X) : IsOpen ({x} : Set X) ↔ 𝓝[≠] x = ⊥ := by
rw [isOpen_singleton_iff_nhds_eq_pure, nhdsWithin, ← mem_iff_inf_principal_compl, ← le_pure_iff,
nhds_neBot.le_pure_iff]
#align is_open_singleton_iff_punctured_nhds isOpen_singleton_iff_punctured_nhds
theorem mem_closure_iff_frequently : x ∈ closure s ↔ ∃ᶠ x in 𝓝 x, x ∈ s := by
rw [Filter.Frequently, Filter.Eventually, ← mem_interior_iff_mem_nhds,
closure_eq_compl_interior_compl, mem_compl_iff, compl_def]
#align mem_closure_iff_frequently mem_closure_iff_frequently
alias ⟨_, Filter.Frequently.mem_closure⟩ := mem_closure_iff_frequently
#align filter.frequently.mem_closure Filter.Frequently.mem_closure
/-- A set `s` is closed iff for every point `x`, if there is a point `y` close to `x` that belongs
to `s` then `x` is in `s`. -/
theorem isClosed_iff_frequently : IsClosed s ↔ ∀ x, (∃ᶠ y in 𝓝 x, y ∈ s) → x ∈ s := by
rw [← closure_subset_iff_isClosed]
refine forall_congr' fun x => ?_
rw [mem_closure_iff_frequently]
#align is_closed_iff_frequently isClosed_iff_frequently
/-- The set of cluster points of a filter is closed. In particular, the set of limit points
of a sequence is closed. -/
theorem isClosed_setOf_clusterPt {f : Filter X} : IsClosed { x | ClusterPt x f } := by
simp only [ClusterPt, inf_neBot_iff_frequently_left, setOf_forall, imp_iff_not_or]
refine isClosed_iInter fun p => IsClosed.union ?_ ?_ <;> apply isClosed_compl_iff.2
exacts [isOpen_setOf_eventually_nhds, isOpen_const]
#align is_closed_set_of_cluster_pt isClosed_setOf_clusterPt
theorem mem_closure_iff_clusterPt : x ∈ closure s ↔ ClusterPt x (𝓟 s) :=
mem_closure_iff_frequently.trans clusterPt_principal_iff_frequently.symm
#align mem_closure_iff_cluster_pt mem_closure_iff_clusterPt
theorem mem_closure_iff_nhds_ne_bot : x ∈ closure s ↔ 𝓝 x ⊓ 𝓟 s ≠ ⊥ :=
mem_closure_iff_clusterPt.trans neBot_iff
#align mem_closure_iff_nhds_ne_bot mem_closure_iff_nhds_ne_bot
@[deprecated (since := "2024-01-28")]
alias mem_closure_iff_nhds_neBot := mem_closure_iff_nhds_ne_bot
theorem mem_closure_iff_nhdsWithin_neBot : x ∈ closure s ↔ NeBot (𝓝[s] x) :=
mem_closure_iff_clusterPt
#align mem_closure_iff_nhds_within_ne_bot mem_closure_iff_nhdsWithin_neBot
lemma not_mem_closure_iff_nhdsWithin_eq_bot : x ∉ closure s ↔ 𝓝[s] x = ⊥ := by
rw [mem_closure_iff_nhdsWithin_neBot, not_neBot]
/-- If `x` is not an isolated point of a topological space, then `{x}ᶜ` is dense in the whole
space. -/
theorem dense_compl_singleton (x : X) [NeBot (𝓝[≠] x)] : Dense ({x}ᶜ : Set X) := by
intro y
rcases eq_or_ne y x with (rfl | hne)
· rwa [mem_closure_iff_nhdsWithin_neBot]
· exact subset_closure hne
#align dense_compl_singleton dense_compl_singleton
/-- If `x` is not an isolated point of a topological space, then the closure of `{x}ᶜ` is the whole
space. -/
-- Porting note (#10618): was a `@[simp]` lemma but `simp` can prove it
theorem closure_compl_singleton (x : X) [NeBot (𝓝[≠] x)] : closure {x}ᶜ = (univ : Set X) :=
(dense_compl_singleton x).closure_eq
#align closure_compl_singleton closure_compl_singleton
/-- If `x` is not an isolated point of a topological space, then the interior of `{x}` is empty. -/
@[simp]
theorem interior_singleton (x : X) [NeBot (𝓝[≠] x)] : interior {x} = (∅ : Set X) :=
interior_eq_empty_iff_dense_compl.2 (dense_compl_singleton x)
#align interior_singleton interior_singleton
theorem not_isOpen_singleton (x : X) [NeBot (𝓝[≠] x)] : ¬IsOpen ({x} : Set X) :=
dense_compl_singleton_iff_not_open.1 (dense_compl_singleton x)
#align not_is_open_singleton not_isOpen_singleton
theorem closure_eq_cluster_pts : closure s = { a | ClusterPt a (𝓟 s) } :=
Set.ext fun _ => mem_closure_iff_clusterPt
#align closure_eq_cluster_pts closure_eq_cluster_pts
theorem mem_closure_iff_nhds : x ∈ closure s ↔ ∀ t ∈ 𝓝 x, (t ∩ s).Nonempty :=
mem_closure_iff_clusterPt.trans clusterPt_principal_iff
#align mem_closure_iff_nhds mem_closure_iff_nhds
theorem mem_closure_iff_nhds' : x ∈ closure s ↔ ∀ t ∈ 𝓝 x, ∃ y : s, ↑y ∈ t := by
simp only [mem_closure_iff_nhds, Set.inter_nonempty_iff_exists_right, SetCoe.exists, exists_prop]
#align mem_closure_iff_nhds' mem_closure_iff_nhds'
theorem mem_closure_iff_comap_neBot :
x ∈ closure s ↔ NeBot (comap ((↑) : s → X) (𝓝 x)) := by
simp_rw [mem_closure_iff_nhds, comap_neBot_iff, Set.inter_nonempty_iff_exists_right,
SetCoe.exists, exists_prop]
#align mem_closure_iff_comap_ne_bot mem_closure_iff_comap_neBot
theorem mem_closure_iff_nhds_basis' {p : ι → Prop} {s : ι → Set X} (h : (𝓝 x).HasBasis p s) :
x ∈ closure t ↔ ∀ i, p i → (s i ∩ t).Nonempty :=
mem_closure_iff_clusterPt.trans <|
(h.clusterPt_iff (hasBasis_principal _)).trans <| by simp only [exists_prop, forall_const]
#align mem_closure_iff_nhds_basis' mem_closure_iff_nhds_basis'
theorem mem_closure_iff_nhds_basis {p : ι → Prop} {s : ι → Set X} (h : (𝓝 x).HasBasis p s) :
x ∈ closure t ↔ ∀ i, p i → ∃ y ∈ t, y ∈ s i :=
(mem_closure_iff_nhds_basis' h).trans <| by
simp only [Set.Nonempty, mem_inter_iff, exists_prop, and_comm]
#align mem_closure_iff_nhds_basis mem_closure_iff_nhds_basis
theorem clusterPt_iff_forall_mem_closure {F : Filter X} :
ClusterPt x F ↔ ∀ s ∈ F, x ∈ closure s := by
simp_rw [ClusterPt, inf_neBot_iff, mem_closure_iff_nhds]
rw [forall₂_swap]
theorem clusterPt_iff_lift'_closure {F : Filter X} :
ClusterPt x F ↔ pure x ≤ (F.lift' closure) := by
simp_rw [clusterPt_iff_forall_mem_closure,
(hasBasis_pure _).le_basis_iff F.basis_sets.lift'_closure, id, singleton_subset_iff, true_and,
exists_const]
theorem clusterPt_iff_lift'_closure' {F : Filter X} :
ClusterPt x F ↔ (F.lift' closure ⊓ pure x).NeBot := by
rw [clusterPt_iff_lift'_closure, ← Ultrafilter.coe_pure, inf_comm, Ultrafilter.inf_neBot_iff]
@[simp]
| Mathlib/Topology/Basic.lean | 1,326 | 1,328 | theorem clusterPt_lift'_closure_iff {F : Filter X} :
ClusterPt x (F.lift' closure) ↔ ClusterPt x F := by |
simp [clusterPt_iff_lift'_closure, lift'_lift'_assoc (monotone_closure X) (monotone_closure X)]
|
/-
Copyright (c) 2019 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.MeanValue
#align_import analysis.calculus.extend_deriv from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Extending differentiability to the boundary
We investigate how differentiable functions inside a set extend to differentiable functions
on the boundary. For this, it suffices that the function and its derivative admit limits there.
A general version of this statement is given in `has_fderiv_at_boundary_of_tendsto_fderiv`.
One-dimensional versions, in which one wants to obtain differentiability at the left endpoint or
the right endpoint of an interval, are given in
`has_deriv_at_interval_left_endpoint_of_tendsto_deriv` and
`has_deriv_at_interval_right_endpoint_of_tendsto_deriv`. These versions are formulated in terms
of the one-dimensional derivative `deriv ℝ f`.
-/
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] {F : Type*} [NormedAddCommGroup F]
[NormedSpace ℝ F]
open Filter Set Metric ContinuousLinearMap
open scoped Topology
attribute [local mono] Set.prod_mono
/-- If a function `f` is differentiable in a convex open set and continuous on its closure, and its
derivative converges to a limit `f'` at a point on the boundary, then `f` is differentiable there
with derivative `f'`. -/
theorem has_fderiv_at_boundary_of_tendsto_fderiv {f : E → F} {s : Set E} {x : E} {f' : E →L[ℝ] F}
(f_diff : DifferentiableOn ℝ f s) (s_conv : Convex ℝ s) (s_open : IsOpen s)
(f_cont : ∀ y ∈ closure s, ContinuousWithinAt f s y)
(h : Tendsto (fun y => fderiv ℝ f y) (𝓝[s] x) (𝓝 f')) :
HasFDerivWithinAt f f' (closure s) x := by
classical
-- one can assume without loss of generality that `x` belongs to the closure of `s`, as the
-- statement is empty otherwise
by_cases hx : x ∉ closure s
· rw [← closure_closure] at hx; exact hasFDerivWithinAt_of_nmem_closure hx
push_neg at hx
rw [HasFDerivWithinAt, hasFDerivAtFilter_iff_isLittleO, Asymptotics.isLittleO_iff]
/- One needs to show that `‖f y - f x - f' (y - x)‖ ≤ ε ‖y - x‖` for `y` close to `x` in
`closure s`, where `ε` is an arbitrary positive constant. By continuity of the functions, it
suffices to prove this for nearby points inside `s`. In a neighborhood of `x`, the derivative
of `f` is arbitrarily close to `f'` by assumption. The mean value inequality completes the
proof. -/
intro ε ε_pos
obtain ⟨δ, δ_pos, hδ⟩ : ∃ δ > 0, ∀ y ∈ s, dist y x < δ → ‖fderiv ℝ f y - f'‖ < ε := by
simpa [dist_zero_right] using tendsto_nhdsWithin_nhds.1 h ε ε_pos
set B := ball x δ
suffices ∀ y ∈ B ∩ closure s, ‖f y - f x - (f' y - f' x)‖ ≤ ε * ‖y - x‖ from
mem_nhdsWithin_iff.2 ⟨δ, δ_pos, fun y hy => by simpa using this y hy⟩
suffices
∀ p : E × E,
p ∈ closure ((B ∩ s) ×ˢ (B ∩ s)) → ‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ by
rw [closure_prod_eq] at this
intro y y_in
apply this ⟨x, y⟩
have : B ∩ closure s ⊆ closure (B ∩ s) := isOpen_ball.inter_closure
exact ⟨this ⟨mem_ball_self δ_pos, hx⟩, this y_in⟩
have key : ∀ p : E × E, p ∈ (B ∩ s) ×ˢ (B ∩ s) →
‖f p.2 - f p.1 - (f' p.2 - f' p.1)‖ ≤ ε * ‖p.2 - p.1‖ := by
rintro ⟨u, v⟩ ⟨u_in, v_in⟩
have conv : Convex ℝ (B ∩ s) := (convex_ball _ _).inter s_conv
have diff : DifferentiableOn ℝ f (B ∩ s) := f_diff.mono inter_subset_right
have bound : ∀ z ∈ B ∩ s, ‖fderivWithin ℝ f (B ∩ s) z - f'‖ ≤ ε := by
intro z z_in
have h := hδ z
have : fderivWithin ℝ f (B ∩ s) z = fderiv ℝ f z := by
have op : IsOpen (B ∩ s) := isOpen_ball.inter s_open
rw [DifferentiableAt.fderivWithin _ (op.uniqueDiffOn z z_in)]
exact (diff z z_in).differentiableAt (IsOpen.mem_nhds op z_in)
rw [← this] at h
exact le_of_lt (h z_in.2 z_in.1)
simpa using conv.norm_image_sub_le_of_norm_fderivWithin_le' diff bound u_in v_in
rintro ⟨u, v⟩ uv_in
have f_cont' : ∀ y ∈ closure s, ContinuousWithinAt (f - ⇑f') s y := by
intro y y_in
exact Tendsto.sub (f_cont y y_in) f'.cont.continuousWithinAt
refine ContinuousWithinAt.closure_le uv_in ?_ ?_ key
all_goals
-- common start for both continuity proofs
have : (B ∩ s) ×ˢ (B ∩ s) ⊆ s ×ˢ s := by mono <;> exact inter_subset_right
obtain ⟨u_in, v_in⟩ : u ∈ closure s ∧ v ∈ closure s := by
simpa [closure_prod_eq] using closure_mono this uv_in
apply ContinuousWithinAt.mono _ this
simp only [ContinuousWithinAt]
· rw [nhdsWithin_prod_eq]
have : ∀ u v, f v - f u - (f' v - f' u) = f v - f' v - (f u - f' u) := by intros; abel
simp only [this]
exact
Tendsto.comp continuous_norm.continuousAt
((Tendsto.comp (f_cont' v v_in) tendsto_snd).sub <|
Tendsto.comp (f_cont' u u_in) tendsto_fst)
· apply tendsto_nhdsWithin_of_tendsto_nhds
rw [nhds_prod_eq]
exact
tendsto_const_nhds.mul
(Tendsto.comp continuous_norm.continuousAt <| tendsto_snd.sub tendsto_fst)
#align has_fderiv_at_boundary_of_tendsto_fderiv has_fderiv_at_boundary_of_tendsto_fderiv
/-- If a function is differentiable on the right of a point `a : ℝ`, continuous at `a`, and
its derivative also converges at `a`, then `f` is differentiable on the right at `a`. -/
theorem has_deriv_at_interval_left_endpoint_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ} {f : ℝ → E}
(f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a) (hs : s ∈ 𝓝[>] a)
(f_lim' : Tendsto (fun x => deriv f x) (𝓝[>] a) (𝓝 e)) : HasDerivWithinAt f e (Ici a) a := by
/- This is a specialization of `has_fderiv_at_boundary_of_tendsto_fderiv`. To be in the setting of
this theorem, we need to work on an open interval with closure contained in `s ∪ {a}`, that we
call `t = (a, b)`. Then, we check all the assumptions of this theorem and we apply it. -/
obtain ⟨b, ab : a < b, sab : Ioc a b ⊆ s⟩ := mem_nhdsWithin_Ioi_iff_exists_Ioc_subset.1 hs
let t := Ioo a b
have ts : t ⊆ s := Subset.trans Ioo_subset_Ioc_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo a b
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc a b := closure_Ioo ab.ne
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨lt_of_le_of_ne hy.1 (Ne.symm h), hy.2⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Ioi_self f_lim')
-- now we can apply `has_fderiv_at_boundary_of_differentiable`
have : HasDerivWithinAt f e (Icc a b) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem (Icc_mem_nhdsWithin_Ici <| left_mem_Ico.2 ab)
#align has_deriv_at_interval_left_endpoint_of_tendsto_deriv has_deriv_at_interval_left_endpoint_of_tendsto_deriv
/-- If a function is differentiable on the left of a point `a : ℝ`, continuous at `a`, and
its derivative also converges at `a`, then `f` is differentiable on the left at `a`. -/
| Mathlib/Analysis/Calculus/FDeriv/Extend.lean | 145 | 175 | theorem has_deriv_at_interval_right_endpoint_of_tendsto_deriv {s : Set ℝ} {e : E} {a : ℝ}
{f : ℝ → E} (f_diff : DifferentiableOn ℝ f s) (f_lim : ContinuousWithinAt f s a)
(hs : s ∈ 𝓝[<] a) (f_lim' : Tendsto (fun x => deriv f x) (𝓝[<] a) (𝓝 e)) :
HasDerivWithinAt f e (Iic a) a := by |
/- This is a specialization of `has_fderiv_at_boundary_of_differentiable`. To be in the setting of
this theorem, we need to work on an open interval with closure contained in `s ∪ {a}`, that we
call `t = (b, a)`. Then, we check all the assumptions of this theorem and we apply it. -/
obtain ⟨b, ba, sab⟩ : ∃ b ∈ Iio a, Ico b a ⊆ s := mem_nhdsWithin_Iio_iff_exists_Ico_subset.1 hs
let t := Ioo b a
have ts : t ⊆ s := Subset.trans Ioo_subset_Ico_self sab
have t_diff : DifferentiableOn ℝ f t := f_diff.mono ts
have t_conv : Convex ℝ t := convex_Ioo b a
have t_open : IsOpen t := isOpen_Ioo
have t_closure : closure t = Icc b a := closure_Ioo (ne_of_lt ba)
have t_cont : ∀ y ∈ closure t, ContinuousWithinAt f t y := by
rw [t_closure]
intro y hy
by_cases h : y = a
· rw [h]; exact f_lim.mono ts
· have : y ∈ s := sab ⟨hy.1, lt_of_le_of_ne hy.2 h⟩
exact (f_diff.continuousOn y this).mono ts
have t_diff' : Tendsto (fun x => fderiv ℝ f x) (𝓝[t] a) (𝓝 (smulRight (1 : ℝ →L[ℝ] ℝ) e)) := by
simp only [deriv_fderiv.symm]
exact Tendsto.comp
(isBoundedBilinearMap_smulRight : IsBoundedBilinearMap ℝ _).continuous_right.continuousAt
(tendsto_nhdsWithin_mono_left Ioo_subset_Iio_self f_lim')
-- now we can apply `has_fderiv_at_boundary_of_differentiable`
have : HasDerivWithinAt f e (Icc b a) a := by
rw [hasDerivWithinAt_iff_hasFDerivWithinAt, ← t_closure]
exact has_fderiv_at_boundary_of_tendsto_fderiv t_diff t_conv t_open t_cont t_diff'
exact this.mono_of_mem (Icc_mem_nhdsWithin_Iic <| right_mem_Ioc.2 ba)
|
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro
-/
import Mathlib.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"
/-!
# Additional theorems and definitions about the `Vector` type
This file introduces the infix notation `::ᵥ` for `Vector.cons`.
-/
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
/-- Two `v w : Vector α n` are equal iff they are equal at every single index. -/
@[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
/-- The empty `Vector` is a `Subsingleton`. -/
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]
theorem toList_map {β : Type*} (v : Vector α n) (f : α → β) :
(v.map f).toList = v.toList.map f := by cases v; rfl
#align vector.to_list_map Vector.toList_map
@[simp]
theorem head_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) : (v.map f).head = f v.head := by
obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v
rw [h, map_cons, head_cons, head_cons]
#align vector.head_map Vector.head_map
@[simp]
theorem tail_map {β : Type*} (v : Vector α (n + 1)) (f : α → β) :
(v.map f).tail = v.tail.map f := by
obtain ⟨a, v', h⟩ := Vector.exists_eq_cons v
rw [h, map_cons, tail_cons, tail_cons]
#align vector.tail_map Vector.tail_map
theorem get_eq_get (v : Vector α n) (i : Fin n) :
v.get i = v.toList.get (Fin.cast v.toList_length.symm i) :=
rfl
#align vector.nth_eq_nth_le Vector.get_eq_getₓ
@[simp]
theorem get_replicate (a : α) (i : Fin n) : (Vector.replicate n a).get i = a := by
apply List.get_replicate
#align vector.nth_repeat Vector.get_replicate
@[simp]
theorem get_map {β : Type*} (v : Vector α n) (f : α → β) (i : Fin n) :
(v.map f).get i = f (v.get i) := by
cases v; simp [Vector.map, get_eq_get]; rfl
#align vector.nth_map Vector.get_map
@[simp]
theorem map₂_nil (f : α → β → γ) : Vector.map₂ f nil nil = nil :=
rfl
@[simp]
theorem map₂_cons (hd₁ : α) (tl₁ : Vector α n) (hd₂ : β) (tl₂ : Vector β n) (f : α → β → γ) :
Vector.map₂ f (hd₁ ::ᵥ tl₁) (hd₂ ::ᵥ tl₂) = f hd₁ hd₂ ::ᵥ (Vector.map₂ f tl₁ tl₂) :=
rfl
@[simp]
theorem get_ofFn {n} (f : Fin n → α) (i) : get (ofFn f) i = f i := by
conv_rhs => erw [← List.get_ofFn f ⟨i, by simp⟩]
simp only [get_eq_get]
congr <;> simp [Fin.heq_ext_iff]
#align vector.nth_of_fn Vector.get_ofFn
@[simp]
theorem ofFn_get (v : Vector α n) : ofFn (get v) = v := by
rcases v with ⟨l, rfl⟩
apply toList_injective
dsimp
simpa only [toList_ofFn] using List.ofFn_get _
#align vector.of_fn_nth Vector.ofFn_get
/-- The natural equivalence between length-`n` vectors and functions from `Fin n`. -/
def _root_.Equiv.vectorEquivFin (α : Type*) (n : ℕ) : Vector α n ≃ (Fin n → α) :=
⟨Vector.get, Vector.ofFn, Vector.ofFn_get, fun f => funext <| Vector.get_ofFn f⟩
#align equiv.vector_equiv_fin Equiv.vectorEquivFin
theorem get_tail (x : Vector α n) (i) : x.tail.get i = x.get ⟨i.1 + 1, by omega⟩ := by
cases' i with i ih; dsimp
rcases x with ⟨_ | _, h⟩ <;> try rfl
rw [List.length] at h
rw [← h] at ih
contradiction
#align vector.nth_tail Vector.get_tail
@[simp]
theorem get_tail_succ : ∀ (v : Vector α n.succ) (i : Fin n), get (tail v) i = get v i.succ
| ⟨a :: l, e⟩, ⟨i, h⟩ => by simp [get_eq_get]; rfl
#align vector.nth_tail_succ Vector.get_tail_succ
@[simp]
theorem tail_val : ∀ v : Vector α n.succ, v.tail.val = v.val.tail
| ⟨_ :: _, _⟩ => rfl
#align vector.tail_val Vector.tail_val
/-- The `tail` of a `nil` vector is `nil`. -/
@[simp]
theorem tail_nil : (@nil α).tail = nil :=
rfl
#align vector.tail_nil Vector.tail_nil
/-- The `tail` of a vector made up of one element is `nil`. -/
@[simp]
theorem singleton_tail : ∀ (v : Vector α 1), v.tail = Vector.nil
| ⟨[_], _⟩ => rfl
#align vector.singleton_tail Vector.singleton_tail
@[simp]
theorem tail_ofFn {n : ℕ} (f : Fin n.succ → α) : tail (ofFn f) = ofFn fun i => f i.succ :=
(ofFn_get _).symm.trans <| by
congr
funext i
rw [get_tail, get_ofFn]
rfl
#align vector.tail_of_fn Vector.tail_ofFn
@[simp]
theorem toList_empty (v : Vector α 0) : v.toList = [] :=
List.length_eq_zero.mp v.2
#align vector.to_list_empty Vector.toList_empty
/-- The list that makes up a `Vector` made up of a single element,
retrieved via `toList`, is equal to the list of that single element. -/
@[simp]
theorem toList_singleton (v : Vector α 1) : v.toList = [v.head] := by
rw [← v.cons_head_tail]
simp only [toList_cons, toList_nil, head_cons, eq_self_iff_true, and_self_iff, singleton_tail]
#align vector.to_list_singleton Vector.toList_singleton
@[simp]
theorem empty_toList_eq_ff (v : Vector α (n + 1)) : v.toList.isEmpty = false :=
match v with
| ⟨_ :: _, _⟩ => rfl
#align vector.empty_to_list_eq_ff Vector.empty_toList_eq_ff
theorem not_empty_toList (v : Vector α (n + 1)) : ¬v.toList.isEmpty := by
simp only [empty_toList_eq_ff, Bool.coe_sort_false, not_false_iff]
#align vector.not_empty_to_list Vector.not_empty_toList
/-- Mapping under `id` does not change a vector. -/
@[simp]
theorem map_id {n : ℕ} (v : Vector α n) : Vector.map id v = v :=
Vector.eq _ _ (by simp only [List.map_id, Vector.toList_map])
#align vector.map_id Vector.map_id
theorem nodup_iff_injective_get {v : Vector α n} : v.toList.Nodup ↔ Function.Injective v.get := by
cases' v with l hl
subst hl
exact List.nodup_iff_injective_get
#align vector.nodup_iff_nth_inj Vector.nodup_iff_injective_get
theorem head?_toList : ∀ v : Vector α n.succ, (toList v).head? = some (head v)
| ⟨_ :: _, _⟩ => rfl
#align vector.head'_to_list Vector.head?_toList
/-- Reverse a vector. -/
def reverse (v : Vector α n) : Vector α n :=
⟨v.toList.reverse, by simp⟩
#align vector.reverse Vector.reverse
/-- The `List` of a vector after a `reverse`, retrieved by `toList` is equal
to the `List.reverse` after retrieving a vector's `toList`. -/
theorem toList_reverse {v : Vector α n} : v.reverse.toList = v.toList.reverse :=
rfl
#align vector.to_list_reverse Vector.toList_reverse
@[simp]
theorem reverse_reverse {v : Vector α n} : v.reverse.reverse = v := by
cases v
simp [Vector.reverse]
#align vector.reverse_reverse Vector.reverse_reverse
@[simp]
theorem get_zero : ∀ v : Vector α n.succ, get v 0 = head v
| ⟨_ :: _, _⟩ => rfl
#align vector.nth_zero Vector.get_zero
@[simp]
theorem head_ofFn {n : ℕ} (f : Fin n.succ → α) : head (ofFn f) = f 0 := by
rw [← get_zero, get_ofFn]
#align vector.head_of_fn Vector.head_ofFn
--@[simp] Porting note (#10618): simp can prove it
theorem get_cons_zero (a : α) (v : Vector α n) : get (a ::ᵥ v) 0 = a := by simp [get_zero]
#align vector.nth_cons_zero Vector.get_cons_zero
/-- Accessing the nth element of a vector made up
of one element `x : α` is `x` itself. -/
@[simp]
theorem get_cons_nil : ∀ {ix : Fin 1} (x : α), get (x ::ᵥ nil) ix = x
| ⟨0, _⟩, _ => rfl
#align vector.nth_cons_nil Vector.get_cons_nil
@[simp]
theorem get_cons_succ (a : α) (v : Vector α n) (i : Fin n) : get (a ::ᵥ v) i.succ = get v i := by
rw [← get_tail_succ, tail_cons]
#align vector.nth_cons_succ Vector.get_cons_succ
/-- The last element of a `Vector`, given that the vector is at least one element. -/
def last (v : Vector α (n + 1)) : α :=
v.get (Fin.last n)
#align vector.last Vector.last
/-- The last element of a `Vector`, given that the vector is at least one element. -/
theorem last_def {v : Vector α (n + 1)} : v.last = v.get (Fin.last n) :=
rfl
#align vector.last_def Vector.last_def
/-- The `last` element of a vector is the `head` of the `reverse` vector. -/
theorem reverse_get_zero {v : Vector α (n + 1)} : v.reverse.head = v.last := by
rw [← get_zero, last_def, get_eq_get, get_eq_get]
simp_rw [toList_reverse]
rw [← Option.some_inj, Fin.cast, Fin.cast, ← List.get?_eq_get, ← List.get?_eq_get,
List.get?_reverse]
· congr
simp
· simp
#align vector.reverse_nth_zero Vector.reverse_get_zero
section Scan
variable {β : Type*}
variable (f : β → α → β) (b : β)
variable (v : Vector α n)
/-- Construct a `Vector β (n + 1)` from a `Vector α n` by scanning `f : β → α → β`
from the "left", that is, from 0 to `Fin.last n`, using `b : β` as the starting value.
-/
def scanl : Vector β (n + 1) :=
⟨List.scanl f b v.toList, by rw [List.length_scanl, toList_length]⟩
#align vector.scanl Vector.scanl
/-- Providing an empty vector to `scanl` gives the starting value `b : β`. -/
@[simp]
theorem scanl_nil : scanl f b nil = b ::ᵥ nil :=
rfl
#align vector.scanl_nil Vector.scanl_nil
/-- The recursive step of `scanl` splits a vector `x ::ᵥ v : Vector α (n + 1)`
into the provided starting value `b : β` and the recursed `scanl`
`f b x : β` as the starting value.
This lemma is the `cons` version of `scanl_get`.
-/
@[simp]
theorem scanl_cons (x : α) : scanl f b (x ::ᵥ v) = b ::ᵥ scanl f (f b x) v := by
simp only [scanl, toList_cons, List.scanl]; dsimp
simp only [cons]; rfl
#align vector.scanl_cons Vector.scanl_cons
/-- The underlying `List` of a `Vector` after a `scanl` is the `List.scanl`
of the underlying `List` of the original `Vector`.
-/
@[simp]
theorem scanl_val : ∀ {v : Vector α n}, (scanl f b v).val = List.scanl f b v.val
| _ => rfl
#align vector.scanl_val Vector.scanl_val
/-- The `toList` of a `Vector` after a `scanl` is the `List.scanl`
of the `toList` of the original `Vector`.
-/
@[simp]
theorem toList_scanl : (scanl f b v).toList = List.scanl f b v.toList :=
rfl
#align vector.to_list_scanl Vector.toList_scanl
/-- The recursive step of `scanl` splits a vector made up of a single element
`x ::ᵥ nil : Vector α 1` into a `Vector` of the provided starting value `b : β`
and the mapped `f b x : β` as the last value.
-/
@[simp]
theorem scanl_singleton (v : Vector α 1) : scanl f b v = b ::ᵥ f b v.head ::ᵥ nil := by
rw [← cons_head_tail v]
simp only [scanl_cons, scanl_nil, head_cons, singleton_tail]
#align vector.scanl_singleton Vector.scanl_singleton
/-- The first element of `scanl` of a vector `v : Vector α n`,
retrieved via `head`, is the starting value `b : β`.
-/
@[simp]
| Mathlib/Data/Vector/Basic.lean | 366 | 372 | theorem scanl_head : (scanl f b v).head = b := by |
cases n
· have : v = nil := by simp only [Nat.zero_eq, eq_iff_true_of_subsingleton]
simp only [this, scanl_nil, head_cons]
· rw [← cons_head_tail v]
simp only [← get_zero, get_eq_get, toList_scanl, toList_cons, List.scanl, Fin.val_zero,
List.get]
|
/-
Copyright (c) 2020 Aaron Anderson, Jalex Stark. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark
-/
import Mathlib.LinearAlgebra.Matrix.Charpoly.Coeff
import Mathlib.FieldTheory.Finite.Basic
import Mathlib.Data.Matrix.CharP
#align_import linear_algebra.matrix.charpoly.finite_field from "leanprover-community/mathlib"@"b95b8c7a484a298228805c72c142f6b062eb0d70"
/-!
# Results on characteristic polynomials and traces over finite fields.
-/
noncomputable section
open Polynomial Matrix
open scoped Polynomial
variable {n : Type*} [DecidableEq n] [Fintype n]
@[simp]
theorem FiniteField.Matrix.charpoly_pow_card {K : Type*} [Field K] [Fintype K] (M : Matrix n n K) :
(M ^ Fintype.card K).charpoly = M.charpoly := by
cases (isEmpty_or_nonempty n).symm
· cases' CharP.exists K with p hp; letI := hp
rcases FiniteField.card K p with ⟨⟨k, kpos⟩, ⟨hp, hk⟩⟩
haveI : Fact p.Prime := ⟨hp⟩
dsimp at hk; rw [hk]
apply (frobenius_inj K[X] p).iterate k
repeat' rw [iterate_frobenius (R := K[X])]; rw [← hk]
rw [← FiniteField.expand_card]
unfold charpoly
rw [AlgHom.map_det, ← coe_detMonoidHom, ← (detMonoidHom : Matrix n n K[X] →* K[X]).map_pow]
apply congr_arg det
refine matPolyEquiv.injective ?_
rw [AlgEquiv.map_pow, matPolyEquiv_charmatrix, hk, sub_pow_char_pow_of_commute, ← C_pow]
· exact (id (matPolyEquiv_eq_X_pow_sub_C (p ^ k) M) : _)
· exact (C M).commute_X
· exact congr_arg _ (Subsingleton.elim _ _)
#align finite_field.matrix.charpoly_pow_card FiniteField.Matrix.charpoly_pow_card
@[simp]
theorem ZMod.charpoly_pow_card {p : ℕ} [Fact p.Prime] (M : Matrix n n (ZMod p)) :
(M ^ p).charpoly = M.charpoly := by
have h := FiniteField.Matrix.charpoly_pow_card M
rwa [ZMod.card] at h
#align zmod.charpoly_pow_card ZMod.charpoly_pow_card
theorem FiniteField.trace_pow_card {K : Type*} [Field K] [Fintype K] (M : Matrix n n K) :
trace (M ^ Fintype.card K) = trace M ^ Fintype.card K := by
cases isEmpty_or_nonempty n
· simp [Matrix.trace]
rw [Matrix.trace_eq_neg_charpoly_coeff, Matrix.trace_eq_neg_charpoly_coeff,
FiniteField.Matrix.charpoly_pow_card, FiniteField.pow_card]
#align finite_field.trace_pow_card FiniteField.trace_pow_card
| Mathlib/LinearAlgebra/Matrix/Charpoly/FiniteField.lean | 61 | 62 | theorem ZMod.trace_pow_card {p : ℕ} [Fact p.Prime] (M : Matrix n n (ZMod p)) :
trace (M ^ p) = trace M ^ p := by | have h := FiniteField.trace_pow_card M; rwa [ZMod.card] at h
|
/-
Copyright (c) 2018 Kenny Lau. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kenny Lau, Chris Hughes, Anne Baanen
-/
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"
/-!
# Determinant of a matrix
This file defines the determinant of a matrix, `Matrix.det`, and its essential properties.
## Main definitions
- `Matrix.det`: the determinant of a square matrix, as a sum over permutations
- `Matrix.detRowAlternating`: the determinant, as an `AlternatingMap` in the rows of the matrix
## Main results
- `det_mul`: the determinant of `A * B` is the product of determinants
- `det_zero_of_row_eq`: the determinant is zero if there is a repeated row
- `det_block_diagonal`: the determinant of a block diagonal matrix is a product
of the blocks' determinants
## Implementation notes
It is possible to configure `simp` to compute determinants. See the file
`test/matrix.lean` for some examples.
-/
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)
/-- `det` is an `AlternatingMap` in the rows of the matrix. -/
def detRowAlternating : (n → R) [⋀^n]→ₗ[R] R :=
MultilinearMap.alternatization ((MultilinearMap.mkPiAlgebra R n R).compLinearMap LinearMap.proj)
#align matrix.det_row_alternating Matrix.detRowAlternating
/-- The determinant of a matrix given by the Leibniz formula. -/
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
/-- If `n` has only one element, the determinant of an `n` by `n` matrix is just that element.
Although `Unique` implies `DecidableEq` and `Fintype`, the instances might
not be syntactically equal. Thus, we need to fill in the args explicitly. -/
@[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
/-- The determinant of a matrix, as a monoid homomorphism. -/
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
/-- On square matrices, `mul_comm` applies under `det`. -/
theorem det_mul_comm (M N : Matrix m m R) : det (M * N) = det (N * M) := by
rw [det_mul, det_mul, mul_comm]
#align matrix.det_mul_comm Matrix.det_mul_comm
/-- On square matrices, `mul_left_comm` applies under `det`. -/
theorem det_mul_left_comm (M N P : Matrix m m R) : det (M * (N * P)) = det (N * (M * P)) := by
rw [← Matrix.mul_assoc, ← Matrix.mul_assoc, det_mul, det_mul_comm M N, ← det_mul]
#align matrix.det_mul_left_comm Matrix.det_mul_left_comm
/-- On square matrices, `mul_right_comm` applies under `det`. -/
theorem det_mul_right_comm (M N P : Matrix m m R) : det (M * N * P) = det (M * P * N) := by
rw [Matrix.mul_assoc, Matrix.mul_assoc, det_mul, det_mul_comm N P, ← det_mul]
#align matrix.det_mul_right_comm Matrix.det_mul_right_comm
-- TODO(mathlib4#6607): fix elaboration so that the ascription isn't needed
theorem det_units_conj (M : (Matrix m m R)ˣ) (N : Matrix m m R) :
det ((M : Matrix _ _ _) * N * (↑M⁻¹ : Matrix _ _ _)) = det N := by
rw [det_mul_right_comm, Units.mul_inv, one_mul]
#align matrix.det_units_conj Matrix.det_units_conj
-- TODO(mathlib4#6607): fix elaboration so that the ascription isn't needed
theorem det_units_conj' (M : (Matrix m m R)ˣ) (N : Matrix m m R) :
det ((↑M⁻¹ : Matrix _ _ _) * N * (↑M : Matrix _ _ _)) = det N :=
det_units_conj M⁻¹ N
#align matrix.det_units_conj' Matrix.det_units_conj'
/-- Transposing a matrix preserves the determinant. -/
@[simp]
theorem det_transpose (M : Matrix n n R) : Mᵀ.det = M.det := by
rw [det_apply', det_apply']
refine Fintype.sum_bijective _ inv_involutive.bijective _ _ ?_
intro σ
rw [sign_inv]
congr 1
apply Fintype.prod_equiv σ
intros
simp
#align matrix.det_transpose Matrix.det_transpose
/-- Permuting the columns changes the sign of the determinant. -/
theorem det_permute (σ : Perm n) (M : Matrix n n R) :
(M.submatrix σ id).det = Perm.sign σ * M.det :=
((detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_perm M σ).trans (by simp [Units.smul_def])
#align matrix.det_permute Matrix.det_permute
/-- Permuting the rows changes the sign of the determinant. -/
theorem det_permute' (σ : Perm n) (M : Matrix n n R) :
(M.submatrix id σ).det = Perm.sign σ * M.det := by
rw [← det_transpose, transpose_submatrix, det_permute, det_transpose]
/-- Permuting rows and columns with the same equivalence has no effect. -/
@[simp]
theorem det_submatrix_equiv_self (e : n ≃ m) (A : Matrix m m R) :
det (A.submatrix e e) = det A := by
rw [det_apply', det_apply']
apply Fintype.sum_equiv (Equiv.permCongr e)
intro σ
rw [Equiv.Perm.sign_permCongr e σ]
congr 1
apply Fintype.prod_equiv e
intro i
rw [Equiv.permCongr_apply, Equiv.symm_apply_apply, submatrix_apply]
#align matrix.det_submatrix_equiv_self Matrix.det_submatrix_equiv_self
/-- Reindexing both indices along the same equivalence preserves the determinant.
For the `simp` version of this lemma, see `det_submatrix_equiv_self`; this one is unsuitable because
`Matrix.reindex_apply` unfolds `reindex` first.
-/
theorem det_reindex_self (e : m ≃ n) (A : Matrix m m R) : det (reindex e e A) = det A :=
det_submatrix_equiv_self e.symm A
#align matrix.det_reindex_self Matrix.det_reindex_self
theorem det_smul (A : Matrix n n R) (c : R) : det (c • A) = c ^ Fintype.card n * det A :=
calc
det (c • A) = det ((diagonal fun _ => c) * A) := by rw [smul_eq_diagonal_mul]
_ = det (diagonal fun _ => c) * det A := det_mul _ _
_ = c ^ Fintype.card n * det A := by simp [card_univ]
#align matrix.det_smul Matrix.det_smul
@[simp]
theorem det_smul_of_tower {α} [Monoid α] [DistribMulAction α R] [IsScalarTower α R R]
[SMulCommClass α R R] (c : α) (A : Matrix n n R) :
det (c • A) = c ^ Fintype.card n • det A := by
rw [← smul_one_smul R c A, det_smul, smul_pow, one_pow, smul_mul_assoc, one_mul]
#align matrix.det_smul_of_tower Matrix.det_smul_of_tower
theorem det_neg (A : Matrix n n R) : det (-A) = (-1) ^ Fintype.card n * det A := by
rw [← det_smul, neg_one_smul]
#align matrix.det_neg Matrix.det_neg
/-- A variant of `Matrix.det_neg` with scalar multiplication by `Units ℤ` instead of multiplication
by `R`. -/
theorem det_neg_eq_smul (A : Matrix n n R) :
det (-A) = (-1 : Units ℤ) ^ Fintype.card n • det A := by
rw [← det_smul_of_tower, Units.neg_smul, one_smul]
#align matrix.det_neg_eq_smul Matrix.det_neg_eq_smul
/-- Multiplying each row by a fixed `v i` multiplies the determinant by
the product of the `v`s. -/
theorem det_mul_row (v : n → R) (A : Matrix n n R) :
det (of fun i j => v j * A i j) = (∏ i, v i) * det A :=
calc
det (of fun i j => v j * A i j) = det (A * diagonal v) :=
congr_arg det <| by
ext
simp [mul_comm]
_ = (∏ i, v i) * det A := by rw [det_mul, det_diagonal, mul_comm]
#align matrix.det_mul_row Matrix.det_mul_row
/-- Multiplying each column by a fixed `v j` multiplies the determinant by
the product of the `v`s. -/
theorem det_mul_column (v : n → R) (A : Matrix n n R) :
det (of fun i j => v i * A i j) = (∏ i, v i) * det A :=
MultilinearMap.map_smul_univ _ v A
#align matrix.det_mul_column Matrix.det_mul_column
@[simp]
theorem det_pow (M : Matrix m m R) (n : ℕ) : det (M ^ n) = det M ^ n :=
(detMonoidHom : Matrix m m R →* R).map_pow M n
#align matrix.det_pow Matrix.det_pow
section HomMap
variable {S : Type w} [CommRing S]
theorem _root_.RingHom.map_det (f : R →+* S) (M : Matrix n n R) :
f M.det = Matrix.det (f.mapMatrix M) := by
simp [Matrix.det_apply', map_sum f, map_prod f]
#align ring_hom.map_det RingHom.map_det
theorem _root_.RingEquiv.map_det (f : R ≃+* S) (M : Matrix n n R) :
f M.det = Matrix.det (f.mapMatrix M) :=
f.toRingHom.map_det _
#align ring_equiv.map_det RingEquiv.map_det
theorem _root_.AlgHom.map_det [Algebra R S] {T : Type z} [CommRing T] [Algebra R T] (f : S →ₐ[R] T)
(M : Matrix n n S) : f M.det = Matrix.det (f.mapMatrix M) :=
f.toRingHom.map_det _
#align alg_hom.map_det AlgHom.map_det
theorem _root_.AlgEquiv.map_det [Algebra R S] {T : Type z} [CommRing T] [Algebra R T]
(f : S ≃ₐ[R] T) (M : Matrix n n S) : f M.det = Matrix.det (f.mapMatrix M) :=
f.toAlgHom.map_det _
#align alg_equiv.map_det AlgEquiv.map_det
end HomMap
@[simp]
theorem det_conjTranspose [StarRing R] (M : Matrix m m R) : det Mᴴ = star (det M) :=
((starRingEnd R).map_det _).symm.trans <| congr_arg star M.det_transpose
#align matrix.det_conj_transpose Matrix.det_conjTranspose
section DetZero
/-!
### `det_zero` section
Prove that a matrix with a repeated column has determinant equal to zero.
-/
theorem det_eq_zero_of_row_eq_zero {A : Matrix n n R} (i : n) (h : ∀ j, A i j = 0) : det A = 0 :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_coord_zero i (funext h)
#align matrix.det_eq_zero_of_row_eq_zero Matrix.det_eq_zero_of_row_eq_zero
theorem det_eq_zero_of_column_eq_zero {A : Matrix n n R} (j : n) (h : ∀ i, A i j = 0) :
det A = 0 := by
rw [← det_transpose]
exact det_eq_zero_of_row_eq_zero j h
#align matrix.det_eq_zero_of_column_eq_zero Matrix.det_eq_zero_of_column_eq_zero
variable {M : Matrix n n R} {i j : n}
/-- If a matrix has a repeated row, the determinant will be zero. -/
theorem det_zero_of_row_eq (i_ne_j : i ≠ j) (hij : M i = M j) : M.det = 0 :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_eq_zero_of_eq M hij i_ne_j
#align matrix.det_zero_of_row_eq Matrix.det_zero_of_row_eq
/-- If a matrix has a repeated column, the determinant will be zero. -/
theorem det_zero_of_column_eq (i_ne_j : i ≠ j) (hij : ∀ k, M k i = M k j) : M.det = 0 := by
rw [← det_transpose, det_zero_of_row_eq i_ne_j]
exact funext hij
#align matrix.det_zero_of_column_eq Matrix.det_zero_of_column_eq
/-- If we repeat a row of a matrix, we get a matrix of determinant zero. -/
theorem det_updateRow_eq_zero (h : i ≠ j) :
(M.updateRow j (M i)).det = 0 := det_zero_of_row_eq h (by simp [h])
/-- If we repeat a column of a matrix, we get a matrix of determinant zero. -/
theorem det_updateColumn_eq_zero (h : i ≠ j) :
(M.updateColumn j (fun k ↦ M k i)).det = 0 := det_zero_of_column_eq h (by simp [h])
end DetZero
theorem det_updateRow_add (M : Matrix n n R) (j : n) (u v : n → R) :
det (updateRow M j <| u + v) = det (updateRow M j u) + det (updateRow M j v) :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_add M j u v
#align matrix.det_update_row_add Matrix.det_updateRow_add
theorem det_updateColumn_add (M : Matrix n n R) (j : n) (u v : n → R) :
det (updateColumn M j <| u + v) = det (updateColumn M j u) + det (updateColumn M j v) := by
rw [← det_transpose, ← updateRow_transpose, det_updateRow_add]
simp [updateRow_transpose, det_transpose]
#align matrix.det_update_column_add Matrix.det_updateColumn_add
theorem det_updateRow_smul (M : Matrix n n R) (j : n) (s : R) (u : n → R) :
det (updateRow M j <| s • u) = s * det (updateRow M j u) :=
(detRowAlternating : (n → R) [⋀^n]→ₗ[R] R).map_smul M j s u
#align matrix.det_update_row_smul Matrix.det_updateRow_smul
theorem det_updateColumn_smul (M : Matrix n n R) (j : n) (s : R) (u : n → R) :
det (updateColumn M j <| s • u) = s * det (updateColumn M j u) := by
rw [← det_transpose, ← updateRow_transpose, det_updateRow_smul]
simp [updateRow_transpose, det_transpose]
#align matrix.det_update_column_smul Matrix.det_updateColumn_smul
theorem det_updateRow_smul' (M : Matrix n n R) (j : n) (s : R) (u : n → R) :
det (updateRow (s • M) j u) = s ^ (Fintype.card n - 1) * det (updateRow M j u) :=
MultilinearMap.map_update_smul _ M j s u
#align matrix.det_update_row_smul' Matrix.det_updateRow_smul'
theorem det_updateColumn_smul' (M : Matrix n n R) (j : n) (s : R) (u : n → R) :
det (updateColumn (s • M) j u) = s ^ (Fintype.card n - 1) * det (updateColumn M j u) := by
rw [← det_transpose, ← updateRow_transpose, transpose_smul, det_updateRow_smul']
simp [updateRow_transpose, det_transpose]
#align matrix.det_update_column_smul' Matrix.det_updateColumn_smul'
theorem det_updateRow_sum_aux (M : Matrix n n R) {j : n} (s : Finset n) (hj : j ∉ s) (c : n → R)
(a : R) :
(M.updateRow j (a • M j + ∑ k ∈ s, (c k) • M k)).det = a • M.det := by
induction s using Finset.induction_on with
| empty => rw [Finset.sum_empty, add_zero, smul_eq_mul, det_updateRow_smul, updateRow_eq_self]
| @insert k _ hk h_ind =>
have h : k ≠ j := fun h ↦ (h ▸ hj) (Finset.mem_insert_self _ _)
rw [Finset.sum_insert hk, add_comm ((c k) • M k), ← add_assoc, det_updateRow_add,
det_updateRow_smul, det_updateRow_eq_zero h, mul_zero, add_zero, h_ind]
exact fun h ↦ hj (Finset.mem_insert_of_mem h)
/-- If we replace a row of a matrix by a linear combination of its rows, then the determinant is
multiplied by the coefficient of that row. -/
theorem det_updateRow_sum (A : Matrix n n R) (j : n) (c : n → R) :
(A.updateRow j (∑ k, (c k) • A k)).det = (c j) • A.det := by
convert det_updateRow_sum_aux A (Finset.univ.erase j) (Finset.univ.not_mem_erase j) c (c j)
rw [← Finset.univ.add_sum_erase _ (Finset.mem_univ j)]
/-- If we replace a column of a matrix by a linear combination of its columns, then the determinant
is multiplied by the coefficient of that column. -/
theorem det_updateColumn_sum (A : Matrix n n R) (j : n) (c : n → R) :
(A.updateColumn j (fun k ↦ ∑ i, (c i) • A k i)).det = (c j) • A.det := by
rw [← det_transpose, ← updateRow_transpose, ← det_transpose A]
convert det_updateRow_sum A.transpose j c
simp only [smul_eq_mul, Finset.sum_apply, Pi.smul_apply, transpose_apply]
section DetEq
/-! ### `det_eq` section
Lemmas showing the determinant is invariant under a variety of operations.
-/
theorem det_eq_of_eq_mul_det_one {A B : Matrix n n R} (C : Matrix n n R) (hC : det C = 1)
(hA : A = B * C) : det A = det B :=
calc
det A = det (B * C) := congr_arg _ hA
_ = det B * det C := det_mul _ _
_ = det B := by rw [hC, mul_one]
#align matrix.det_eq_of_eq_mul_det_one Matrix.det_eq_of_eq_mul_det_one
theorem det_eq_of_eq_det_one_mul {A B : Matrix n n R} (C : Matrix n n R) (hC : det C = 1)
(hA : A = C * B) : det A = det B :=
calc
det A = det (C * B) := congr_arg _ hA
_ = det C * det B := det_mul _ _
_ = det B := by rw [hC, one_mul]
#align matrix.det_eq_of_eq_det_one_mul Matrix.det_eq_of_eq_det_one_mul
theorem det_updateRow_add_self (A : Matrix n n R) {i j : n} (hij : i ≠ j) :
det (updateRow A i (A i + A j)) = det A := by
simp [det_updateRow_add,
det_zero_of_row_eq hij (updateRow_self.trans (updateRow_ne hij.symm).symm)]
#align matrix.det_update_row_add_self Matrix.det_updateRow_add_self
theorem det_updateColumn_add_self (A : Matrix n n R) {i j : n} (hij : i ≠ j) :
det (updateColumn A i fun k => A k i + A k j) = det A := by
rw [← det_transpose, ← updateRow_transpose, ← det_transpose A]
exact det_updateRow_add_self Aᵀ hij
#align matrix.det_update_column_add_self Matrix.det_updateColumn_add_self
theorem det_updateRow_add_smul_self (A : Matrix n n R) {i j : n} (hij : i ≠ j) (c : R) :
det (updateRow A i (A i + c • A j)) = det A := by
simp [det_updateRow_add, det_updateRow_smul,
det_zero_of_row_eq hij (updateRow_self.trans (updateRow_ne hij.symm).symm)]
#align matrix.det_update_row_add_smul_self Matrix.det_updateRow_add_smul_self
theorem det_updateColumn_add_smul_self (A : Matrix n n R) {i j : n} (hij : i ≠ j) (c : R) :
det (updateColumn A i fun k => A k i + c • A k j) = det A := by
rw [← det_transpose, ← updateRow_transpose, ← det_transpose A]
exact det_updateRow_add_smul_self Aᵀ hij c
#align matrix.det_update_column_add_smul_self Matrix.det_updateColumn_add_smul_self
theorem det_eq_of_forall_row_eq_smul_add_const_aux {A B : Matrix n n R} {s : Finset n} :
∀ (c : n → R) (_ : ∀ i, i ∉ s → c i = 0) (k : n) (_ : k ∉ s)
(_: ∀ i j, A i j = B i j + c i * B k j), det A = det B := by
induction s using Finset.induction_on generalizing B with
| empty =>
rintro c hs k - A_eq
have : ∀ i, c i = 0 := by
intro i
specialize hs i
contrapose! hs
simp [hs]
congr
ext i j
rw [A_eq, this, zero_mul, add_zero]
| @insert i s _hi ih =>
intro c hs k hk A_eq
have hAi : A i = B i + c i • B k := funext (A_eq i)
rw [@ih (updateRow B i (A i)) (Function.update c i 0), hAi, det_updateRow_add_smul_self]
· exact mt (fun h => show k ∈ insert i s from h ▸ Finset.mem_insert_self _ _) hk
· intro i' hi'
rw [Function.update_apply]
split_ifs with hi'i
· rfl
· exact hs i' fun h => hi' ((Finset.mem_insert.mp h).resolve_left hi'i)
· exact k
· exact fun h => hk (Finset.mem_insert_of_mem h)
· intro i' j'
rw [updateRow_apply, Function.update_apply]
split_ifs with hi'i
· simp [hi'i]
rw [A_eq, updateRow_ne fun h : k = i => hk <| h ▸ Finset.mem_insert_self k s]
#align matrix.det_eq_of_forall_row_eq_smul_add_const_aux Matrix.det_eq_of_forall_row_eq_smul_add_const_aux
/-- If you add multiples of row `B k` to other rows, the determinant doesn't change. -/
theorem det_eq_of_forall_row_eq_smul_add_const {A B : Matrix n n R} (c : n → R) (k : n)
(hk : c k = 0) (A_eq : ∀ i j, A i j = B i j + c i * B k j) : det A = det B :=
det_eq_of_forall_row_eq_smul_add_const_aux c
(fun i =>
not_imp_comm.mp fun hi =>
Finset.mem_erase.mpr
⟨mt (fun h : i = k => show c i = 0 from h.symm ▸ hk) hi, Finset.mem_univ i⟩)
k (Finset.not_mem_erase k Finset.univ) A_eq
#align matrix.det_eq_of_forall_row_eq_smul_add_const Matrix.det_eq_of_forall_row_eq_smul_add_const
theorem det_eq_of_forall_row_eq_smul_add_pred_aux {n : ℕ} (k : Fin (n + 1)) :
∀ (c : Fin n → R) (_hc : ∀ i : Fin n, k < i.succ → c i = 0)
{M N : Matrix (Fin n.succ) (Fin n.succ) R} (_h0 : ∀ j, M 0 j = N 0 j)
(_hsucc : ∀ (i : Fin n) (j), M i.succ j = N i.succ j + c i * M (Fin.castSucc i) j),
det M = det N := by
refine Fin.induction ?_ (fun k ih => ?_) k <;> intro c hc M N h0 hsucc
· congr
ext i j
refine Fin.cases (h0 j) (fun i => ?_) i
rw [hsucc, hc i (Fin.succ_pos _), zero_mul, add_zero]
set M' := updateRow M k.succ (N k.succ) with hM'
have hM : M = updateRow M' k.succ (M' k.succ + c k • M (Fin.castSucc k)) := by
ext i j
by_cases hi : i = k.succ
· simp [hi, hM', hsucc, updateRow_self]
rw [updateRow_ne hi, hM', updateRow_ne hi]
have k_ne_succ : (Fin.castSucc k) ≠ k.succ := (Fin.castSucc_lt_succ k).ne
have M_k : M (Fin.castSucc k) = M' (Fin.castSucc k) := (updateRow_ne k_ne_succ).symm
rw [hM, M_k, det_updateRow_add_smul_self M' k_ne_succ.symm, ih (Function.update c k 0)]
· intro i hi
rw [Fin.lt_iff_val_lt_val, Fin.coe_castSucc, Fin.val_succ, Nat.lt_succ_iff] at hi
rw [Function.update_apply]
split_ifs with hik
· rfl
exact hc _ (Fin.succ_lt_succ_iff.mpr (lt_of_le_of_ne hi (Ne.symm hik)))
· rwa [hM', updateRow_ne (Fin.succ_ne_zero _).symm]
intro i j
rw [Function.update_apply]
split_ifs with hik
· rw [zero_mul, add_zero, hM', hik, updateRow_self]
rw [hM', updateRow_ne ((Fin.succ_injective _).ne hik), hsucc]
by_cases hik2 : k < i
· simp [hc i (Fin.succ_lt_succ_iff.mpr hik2)]
rw [updateRow_ne]
apply ne_of_lt
rwa [Fin.lt_iff_val_lt_val, Fin.coe_castSucc, Fin.val_succ, Nat.lt_succ_iff, ← not_lt]
#align matrix.det_eq_of_forall_row_eq_smul_add_pred_aux Matrix.det_eq_of_forall_row_eq_smul_add_pred_aux
/-- If you add multiples of previous rows to the next row, the determinant doesn't change. -/
theorem det_eq_of_forall_row_eq_smul_add_pred {n : ℕ} {A B : Matrix (Fin (n + 1)) (Fin (n + 1)) R}
(c : Fin n → R) (A_zero : ∀ j, A 0 j = B 0 j)
(A_succ : ∀ (i : Fin n) (j), A i.succ j = B i.succ j + c i * A (Fin.castSucc i) j) :
det A = det B :=
det_eq_of_forall_row_eq_smul_add_pred_aux (Fin.last _) c
(fun _ hi => absurd hi (not_lt_of_ge (Fin.le_last _))) A_zero A_succ
#align matrix.det_eq_of_forall_row_eq_smul_add_pred Matrix.det_eq_of_forall_row_eq_smul_add_pred
/-- If you add multiples of previous columns to the next columns, the determinant doesn't change. -/
theorem det_eq_of_forall_col_eq_smul_add_pred {n : ℕ} {A B : Matrix (Fin (n + 1)) (Fin (n + 1)) R}
(c : Fin n → R) (A_zero : ∀ i, A i 0 = B i 0)
(A_succ : ∀ (i) (j : Fin n), A i j.succ = B i j.succ + c j * A i (Fin.castSucc j)) :
det A = det B := by
rw [← det_transpose A, ← det_transpose B]
exact det_eq_of_forall_row_eq_smul_add_pred c A_zero fun i j => A_succ j i
#align matrix.det_eq_of_forall_col_eq_smul_add_pred Matrix.det_eq_of_forall_col_eq_smul_add_pred
end DetEq
@[simp]
theorem det_blockDiagonal {o : Type*} [Fintype o] [DecidableEq o] (M : o → Matrix n n R) :
(blockDiagonal M).det = ∏ k, (M k).det := by
-- Rewrite the determinants as a sum over permutations.
simp_rw [det_apply']
-- The right hand side is a product of sums, rewrite it as a sum of products.
rw [Finset.prod_sum]
simp_rw [Finset.prod_attach_univ, Finset.univ_pi_univ]
-- We claim that the only permutations contributing to the sum are those that
-- preserve their second component.
let preserving_snd : Finset (Equiv.Perm (n × o)) :=
Finset.univ.filter fun σ => ∀ x, (σ x).snd = x.snd
have mem_preserving_snd :
∀ {σ : Equiv.Perm (n × o)}, σ ∈ preserving_snd ↔ ∀ x, (σ x).snd = x.snd := fun {σ} =>
Finset.mem_filter.trans ⟨fun h => h.2, fun h => ⟨Finset.mem_univ _, h⟩⟩
rw [← Finset.sum_subset (Finset.subset_univ preserving_snd) _]
-- And that these are in bijection with `o → Equiv.Perm m`.
· refine (Finset.sum_bij (fun σ _ => prodCongrLeft fun k ↦ σ k (mem_univ k)) ?_ ?_ ?_ ?_).symm
· intro σ _
rw [mem_preserving_snd]
rintro ⟨-, x⟩
simp only [prodCongrLeft_apply]
· intro σ _ σ' _ eq
ext x hx k
simp only at eq
have :
∀ k x,
prodCongrLeft (fun k => σ k (Finset.mem_univ _)) (k, x) =
prodCongrLeft (fun k => σ' k (Finset.mem_univ _)) (k, x) :=
fun k x => by rw [eq]
simp only [prodCongrLeft_apply, Prod.mk.inj_iff] at this
exact (this k x).1
· intro σ hσ
rw [mem_preserving_snd] at hσ
have hσ' : ∀ x, (σ⁻¹ x).snd = x.snd := by
intro x
conv_rhs => rw [← Perm.apply_inv_self σ x, hσ]
have mk_apply_eq : ∀ k x, ((σ (x, k)).fst, k) = σ (x, k) := by
intro k x
ext
· simp only
· simp only [hσ]
have mk_inv_apply_eq : ∀ k x, ((σ⁻¹ (x, k)).fst, k) = σ⁻¹ (x, k) := by
intro k x
conv_lhs => rw [← Perm.apply_inv_self σ (x, k)]
ext
· simp only [apply_inv_self]
· simp only [hσ']
refine ⟨fun k _ => ⟨fun x => (σ (x, k)).fst, fun x => (σ⁻¹ (x, k)).fst, ?_, ?_⟩, ?_, ?_⟩
· intro x
simp only [mk_apply_eq, inv_apply_self]
· intro x
simp only [mk_inv_apply_eq, apply_inv_self]
· apply Finset.mem_univ
· ext ⟨k, x⟩
· simp only [coe_fn_mk, prodCongrLeft_apply]
· simp only [prodCongrLeft_apply, hσ]
· intro σ _
rw [Finset.prod_mul_distrib, ← Finset.univ_product_univ, Finset.prod_product_right]
simp only [sign_prodCongrLeft, Units.coe_prod, Int.cast_prod, blockDiagonal_apply_eq,
prodCongrLeft_apply]
· intro σ _ hσ
rw [mem_preserving_snd] at hσ
obtain ⟨⟨k, x⟩, hkx⟩ := not_forall.mp hσ
rw [Finset.prod_eq_zero (Finset.mem_univ (k, x)), mul_zero]
rw [blockDiagonal_apply_ne]
exact hkx
#align matrix.det_block_diagonal Matrix.det_blockDiagonal
/-- The determinant of a 2×2 block matrix with the lower-left block equal to zero is the product of
the determinants of the diagonal blocks. For the generalization to any number of blocks, see
`Matrix.det_of_upper_triangular`. -/
@[simp]
| Mathlib/LinearAlgebra/Matrix/Determinant/Basic.lean | 671 | 719 | theorem det_fromBlocks_zero₂₁ (A : Matrix m m R) (B : Matrix m n R) (D : Matrix n n R) :
(Matrix.fromBlocks A B 0 D).det = A.det * D.det := by |
classical
simp_rw [det_apply']
convert Eq.symm <|
sum_subset (β := R) (subset_univ ((sumCongrHom m n).range : Set (Perm (Sum m n))).toFinset) ?_
· simp_rw [sum_mul_sum, ← sum_product', univ_product_univ]
refine sum_nbij (fun σ ↦ σ.fst.sumCongr σ.snd) ?_ ?_ ?_ ?_
· intro σ₁₂ _
simp only
erw [Set.mem_toFinset, MonoidHom.mem_range]
use σ₁₂
simp only [sumCongrHom_apply]
· intro σ₁ _ σ₂ _
dsimp only
intro h
have h2 : ∀ x, Perm.sumCongr σ₁.fst σ₁.snd x = Perm.sumCongr σ₂.fst σ₂.snd x :=
DFunLike.congr_fun h
simp only [Sum.map_inr, Sum.map_inl, Perm.sumCongr_apply, Sum.forall, Sum.inl.injEq,
Sum.inr.injEq] at h2
ext x
· exact h2.left x
· exact h2.right x
· intro σ hσ
erw [Set.mem_toFinset, MonoidHom.mem_range] at hσ
obtain ⟨σ₁₂, hσ₁₂⟩ := hσ
use σ₁₂
rw [← hσ₁₂]
simp
· simp only [forall_prop_of_true, Prod.forall, mem_univ]
intro σ₁ σ₂
rw [Fintype.prod_sum_type]
simp_rw [Equiv.sumCongr_apply, Sum.map_inr, Sum.map_inl, fromBlocks_apply₁₁,
fromBlocks_apply₂₂]
rw [mul_mul_mul_comm]
congr
rw [sign_sumCongr, Units.val_mul, Int.cast_mul]
· rintro σ - hσn
have h1 : ¬∀ x, ∃ y, Sum.inl y = σ (Sum.inl x) := by
rw [Set.mem_toFinset] at hσn
-- Porting note: golfed
simpa only [Set.MapsTo, Set.mem_range, forall_exists_index, forall_apply_eq_imp_iff] using
mt mem_sumCongrHom_range_of_perm_mapsTo_inl hσn
obtain ⟨a, ha⟩ := not_forall.mp h1
cases' hx : σ (Sum.inl a) with a2 b
· have hn := (not_exists.mp ha) a2
exact absurd hx.symm hn
· rw [Finset.prod_eq_zero (Finset.mem_univ (Sum.inl a)), mul_zero]
rw [hx, fromBlocks_apply₂₁, zero_apply]
|
/-
Copyright (c) 2022 Yakov Pechersky. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yakov Pechersky
-/
import Mathlib.Data.List.Infix
#align_import data.list.rdrop from "leanprover-community/mathlib"@"26f081a2fb920140ed5bc5cc5344e84bcc7cb2b2"
/-!
# Dropping or taking from lists on the right
Taking or removing element from the tail end of a list
## Main definitions
- `rdrop n`: drop `n : ℕ` elements from the tail
- `rtake n`: take `n : ℕ` elements from the tail
- `rdropWhile p`: remove all the elements from the tail of a list until it finds the first element
for which `p : α → Bool` returns false. This element and everything before is returned.
- `rtakeWhile p`: Returns the longest terminal segment of a list for which `p : α → Bool` returns
true.
## Implementation detail
The two predicate-based methods operate by performing the regular "from-left" operation on
`List.reverse`, followed by another `List.reverse`, so they are not the most performant.
The other two rely on `List.length l` so they still traverse the list twice. One could construct
another function that takes a `L : ℕ` and use `L - n`. Under a proof condition that
`L = l.length`, the function would do the right thing.
-/
-- Make sure we don't import algebra
assert_not_exists Monoid
variable {α : Type*} (p : α → Bool) (l : List α) (n : ℕ)
namespace List
/-- Drop `n` elements from the tail end of a list. -/
def rdrop : List α :=
l.take (l.length - n)
#align list.rdrop List.rdrop
@[simp]
theorem rdrop_nil : rdrop ([] : List α) n = [] := by simp [rdrop]
#align list.rdrop_nil List.rdrop_nil
@[simp]
theorem rdrop_zero : rdrop l 0 = l := by simp [rdrop]
#align list.rdrop_zero List.rdrop_zero
theorem rdrop_eq_reverse_drop_reverse : l.rdrop n = reverse (l.reverse.drop n) := by
rw [rdrop]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· simp [take_append]
· simp [take_append_eq_append_take, IH]
#align list.rdrop_eq_reverse_drop_reverse List.rdrop_eq_reverse_drop_reverse
@[simp]
theorem rdrop_concat_succ (x : α) : rdrop (l ++ [x]) (n + 1) = rdrop l n := by
simp [rdrop_eq_reverse_drop_reverse]
#align list.rdrop_concat_succ List.rdrop_concat_succ
/-- Take `n` elements from the tail end of a list. -/
def rtake : List α :=
l.drop (l.length - n)
#align list.rtake List.rtake
@[simp]
theorem rtake_nil : rtake ([] : List α) n = [] := by simp [rtake]
#align list.rtake_nil List.rtake_nil
@[simp]
theorem rtake_zero : rtake l 0 = [] := by simp [rtake]
#align list.rtake_zero List.rtake_zero
theorem rtake_eq_reverse_take_reverse : l.rtake n = reverse (l.reverse.take n) := by
rw [rtake]
induction' l using List.reverseRecOn with xs x IH generalizing n
· simp
· cases n
· exact drop_length _
· simp [drop_append_eq_append_drop, IH]
#align list.rtake_eq_reverse_take_reverse List.rtake_eq_reverse_take_reverse
@[simp]
theorem rtake_concat_succ (x : α) : rtake (l ++ [x]) (n + 1) = rtake l n ++ [x] := by
simp [rtake_eq_reverse_take_reverse]
#align list.rtake_concat_succ List.rtake_concat_succ
/-- Drop elements from the tail end of a list that satisfy `p : α → Bool`.
Implemented naively via `List.reverse` -/
def rdropWhile : List α :=
reverse (l.reverse.dropWhile p)
#align list.rdrop_while List.rdropWhile
@[simp]
theorem rdropWhile_nil : rdropWhile p ([] : List α) = [] := by simp [rdropWhile, dropWhile]
#align list.rdrop_while_nil List.rdropWhile_nil
theorem rdropWhile_concat (x : α) :
rdropWhile p (l ++ [x]) = if p x then rdropWhile p l else l ++ [x] := by
simp only [rdropWhile, dropWhile, reverse_append, reverse_singleton, singleton_append]
split_ifs with h <;> simp [h]
#align list.rdrop_while_concat List.rdropWhile_concat
@[simp]
theorem rdropWhile_concat_pos (x : α) (h : p x) : rdropWhile p (l ++ [x]) = rdropWhile p l := by
rw [rdropWhile_concat, if_pos h]
#align list.rdrop_while_concat_pos List.rdropWhile_concat_pos
@[simp]
theorem rdropWhile_concat_neg (x : α) (h : ¬p x) : rdropWhile p (l ++ [x]) = l ++ [x] := by
rw [rdropWhile_concat, if_neg h]
#align list.rdrop_while_concat_neg List.rdropWhile_concat_neg
theorem rdropWhile_singleton (x : α) : rdropWhile p [x] = if p x then [] else [x] := by
rw [← nil_append [x], rdropWhile_concat, rdropWhile_nil]
#align list.rdrop_while_singleton List.rdropWhile_singleton
theorem rdropWhile_last_not (hl : l.rdropWhile p ≠ []) : ¬p ((rdropWhile p l).getLast hl) := by
simp_rw [rdropWhile]
rw [getLast_reverse]
exact dropWhile_nthLe_zero_not _ _ _
#align list.rdrop_while_last_not List.rdropWhile_last_not
theorem rdropWhile_prefix : l.rdropWhile p <+: l := by
rw [← reverse_suffix, rdropWhile, reverse_reverse]
exact dropWhile_suffix _
#align list.rdrop_while_prefix List.rdropWhile_prefix
variable {p} {l}
@[simp]
theorem rdropWhile_eq_nil_iff : rdropWhile p l = [] ↔ ∀ x ∈ l, p x := by simp [rdropWhile]
#align list.rdrop_while_eq_nil_iff List.rdropWhile_eq_nil_iff
-- it is in this file because it requires `List.Infix`
@[simp]
| Mathlib/Data/List/DropRight.lean | 144 | 160 | theorem dropWhile_eq_self_iff : dropWhile p l = l ↔ ∀ hl : 0 < l.length, ¬p (l.get ⟨0, hl⟩) := by |
cases' l with hd tl
· simp only [dropWhile, true_iff]
intro h
by_contra
rwa [length_nil, lt_self_iff_false] at h
· rw [dropWhile]
refine ⟨fun h => ?_, fun h => ?_⟩
· intro _ H
rw [get] at H
refine (cons_ne_self hd tl) (Sublist.antisymm ?_ (sublist_cons _ _))
rw [← h]
simp only [H]
exact List.IsSuffix.sublist (dropWhile_suffix p)
· have := h (by simp only [length, Nat.succ_pos])
rw [get] at this
simp_rw [this]
|
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes
-/
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Data.Fintype.Card
import Mathlib.Data.Set.Finite
import Mathlib.Data.Set.Pointwise.SMul
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.GroupTheory.GroupAction.Group
#align_import group_theory.group_action.basic from "leanprover-community/mathlib"@"d30d31261cdb4d2f5e612eabc3c4bf45556350d5"
/-!
# Basic properties of group actions
This file primarily concerns itself with orbits, stabilizers, and other objects defined in terms of
actions. Despite this file being called `basic`, low-level helper lemmas for algebraic manipulation
of `•` belong elsewhere.
## Main definitions
* `MulAction.orbit`
* `MulAction.fixedPoints`
* `MulAction.fixedBy`
* `MulAction.stabilizer`
-/
universe u v
open Pointwise
open Function
namespace MulAction
variable (M : Type u) [Monoid M] (α : Type v) [MulAction M α]
section Orbit
variable {α}
/-- The orbit of an element under an action. -/
@[to_additive "The orbit of an element under an action."]
def orbit (a : α) :=
Set.range fun m : M => m • a
#align mul_action.orbit MulAction.orbit
#align add_action.orbit AddAction.orbit
variable {M}
@[to_additive]
theorem mem_orbit_iff {a₁ a₂ : α} : a₂ ∈ orbit M a₁ ↔ ∃ x : M, x • a₁ = a₂ :=
Iff.rfl
#align mul_action.mem_orbit_iff MulAction.mem_orbit_iff
#align add_action.mem_orbit_iff AddAction.mem_orbit_iff
@[to_additive (attr := simp)]
theorem mem_orbit (a : α) (m : M) : m • a ∈ orbit M a :=
⟨m, rfl⟩
#align mul_action.mem_orbit MulAction.mem_orbit
#align add_action.mem_orbit AddAction.mem_orbit
@[to_additive (attr := simp)]
theorem mem_orbit_self (a : α) : a ∈ orbit M a :=
⟨1, by simp [MulAction.one_smul]⟩
#align mul_action.mem_orbit_self MulAction.mem_orbit_self
#align add_action.mem_orbit_self AddAction.mem_orbit_self
@[to_additive]
theorem orbit_nonempty (a : α) : Set.Nonempty (orbit M a) :=
Set.range_nonempty _
#align mul_action.orbit_nonempty MulAction.orbit_nonempty
#align add_action.orbit_nonempty AddAction.orbit_nonempty
@[to_additive]
theorem mapsTo_smul_orbit (m : M) (a : α) : Set.MapsTo (m • ·) (orbit M a) (orbit M a) :=
Set.range_subset_iff.2 fun m' => ⟨m * m', mul_smul _ _ _⟩
#align mul_action.maps_to_smul_orbit MulAction.mapsTo_smul_orbit
#align add_action.maps_to_vadd_orbit AddAction.mapsTo_vadd_orbit
@[to_additive]
theorem smul_orbit_subset (m : M) (a : α) : m • orbit M a ⊆ orbit M a :=
(mapsTo_smul_orbit m a).image_subset
#align mul_action.smul_orbit_subset MulAction.smul_orbit_subset
#align add_action.vadd_orbit_subset AddAction.vadd_orbit_subset
@[to_additive]
theorem orbit_smul_subset (m : M) (a : α) : orbit M (m • a) ⊆ orbit M a :=
Set.range_subset_iff.2 fun m' => mul_smul m' m a ▸ mem_orbit _ _
#align mul_action.orbit_smul_subset MulAction.orbit_smul_subset
#align add_action.orbit_vadd_subset AddAction.orbit_vadd_subset
@[to_additive]
instance {a : α} : MulAction M (orbit M a) where
smul m := (mapsTo_smul_orbit m a).restrict _ _ _
one_smul m := Subtype.ext (one_smul M (m : α))
mul_smul m m' a' := Subtype.ext (mul_smul m m' (a' : α))
@[to_additive (attr := simp)]
theorem orbit.coe_smul {a : α} {m : M} {a' : orbit M a} : ↑(m • a') = m • (a' : α) :=
rfl
#align mul_action.orbit.coe_smul MulAction.orbit.coe_smul
#align add_action.orbit.coe_vadd AddAction.orbit.coe_vadd
@[to_additive]
lemma orbit_submonoid_subset (S : Submonoid M) (a : α) : orbit S a ⊆ orbit M a := by
rintro b ⟨g, rfl⟩
exact mem_orbit _ _
@[to_additive]
lemma mem_orbit_of_mem_orbit_submonoid {S : Submonoid M} {a b : α} (h : a ∈ orbit S b) :
a ∈ orbit M b :=
orbit_submonoid_subset S _ h
variable (M)
@[to_additive]
theorem orbit_eq_univ [IsPretransitive M α] (a : α) : orbit M a = Set.univ :=
(surjective_smul M a).range_eq
#align mul_action.orbit_eq_univ MulAction.orbit_eq_univ
#align add_action.orbit_eq_univ AddAction.orbit_eq_univ
end Orbit
section FixedPoints
/-- The set of elements fixed under the whole action. -/
@[to_additive "The set of elements fixed under the whole action."]
def fixedPoints : Set α :=
{ a : α | ∀ m : M, m • a = a }
#align mul_action.fixed_points MulAction.fixedPoints
#align add_action.fixed_points AddAction.fixedPoints
variable {M}
/-- `fixedBy m` is the set of elements fixed by `m`. -/
@[to_additive "`fixedBy m` is the set of elements fixed by `m`."]
def fixedBy (m : M) : Set α :=
{ x | m • x = x }
#align mul_action.fixed_by MulAction.fixedBy
#align add_action.fixed_by AddAction.fixedBy
variable (M)
@[to_additive]
theorem fixed_eq_iInter_fixedBy : fixedPoints M α = ⋂ m : M, fixedBy α m :=
Set.ext fun _ =>
⟨fun hx => Set.mem_iInter.2 fun m => hx m, fun hx m => (Set.mem_iInter.1 hx m : _)⟩
#align mul_action.fixed_eq_Inter_fixed_by MulAction.fixed_eq_iInter_fixedBy
#align add_action.fixed_eq_Inter_fixed_by AddAction.fixed_eq_iInter_fixedBy
variable {M α}
@[to_additive (attr := simp)]
theorem mem_fixedPoints {a : α} : a ∈ fixedPoints M α ↔ ∀ m : M, m • a = a :=
Iff.rfl
#align mul_action.mem_fixed_points MulAction.mem_fixedPoints
#align add_action.mem_fixed_points AddAction.mem_fixedPoints
@[to_additive (attr := simp)]
theorem mem_fixedBy {m : M} {a : α} : a ∈ fixedBy α m ↔ m • a = a :=
Iff.rfl
#align mul_action.mem_fixed_by MulAction.mem_fixedBy
#align add_action.mem_fixed_by AddAction.mem_fixedBy
@[to_additive]
theorem mem_fixedPoints' {a : α} : a ∈ fixedPoints M α ↔ ∀ a', a' ∈ orbit M a → a' = a :=
⟨fun h _ h₁ =>
let ⟨m, hm⟩ := mem_orbit_iff.1 h₁
hm ▸ h m,
fun h _ => h _ (mem_orbit _ _)⟩
#align mul_action.mem_fixed_points' MulAction.mem_fixedPoints'
#align add_action.mem_fixed_points' AddAction.mem_fixedPoints'
@[to_additive mem_fixedPoints_iff_card_orbit_eq_one]
theorem mem_fixedPoints_iff_card_orbit_eq_one {a : α} [Fintype (orbit M a)] :
a ∈ fixedPoints M α ↔ Fintype.card (orbit M a) = 1 := by
rw [Fintype.card_eq_one_iff, mem_fixedPoints]
constructor
· exact fun h => ⟨⟨a, mem_orbit_self _⟩, fun ⟨a, ⟨x, hx⟩⟩ => Subtype.eq <| by simp [h x, hx.symm]⟩
· intro h x
rcases h with ⟨⟨z, hz⟩, hz₁⟩
calc
x • a = z := Subtype.mk.inj (hz₁ ⟨x • a, mem_orbit _ _⟩)
_ = a := (Subtype.mk.inj (hz₁ ⟨a, mem_orbit_self _⟩)).symm
#align mul_action.mem_fixed_points_iff_card_orbit_eq_one MulAction.mem_fixedPoints_iff_card_orbit_eq_one
#align add_action.mem_fixed_points_iff_card_orbit_eq_zero AddAction.mem_fixedPoints_iff_card_orbit_eq_one
end FixedPoints
section Stabilizers
variable {α}
/-- The stabilizer of a point `a` as a submonoid of `M`. -/
@[to_additive "The stabilizer of a point `a` as an additive submonoid of `M`."]
def stabilizerSubmonoid (a : α) : Submonoid M where
carrier := { m | m • a = a }
one_mem' := one_smul _ a
mul_mem' {m m'} (ha : m • a = a) (hb : m' • a = a) :=
show (m * m') • a = a by rw [← smul_smul, hb, ha]
#align mul_action.stabilizer.submonoid MulAction.stabilizerSubmonoid
#align add_action.stabilizer.add_submonoid AddAction.stabilizerAddSubmonoid
variable {M}
@[to_additive]
instance [DecidableEq α] (a : α) : DecidablePred (· ∈ stabilizerSubmonoid M a) :=
fun _ => inferInstanceAs <| Decidable (_ = _)
@[to_additive (attr := simp)]
theorem mem_stabilizerSubmonoid_iff {a : α} {m : M} : m ∈ stabilizerSubmonoid M a ↔ m • a = a :=
Iff.rfl
#align mul_action.mem_stabilizer_submonoid_iff MulAction.mem_stabilizerSubmonoid_iff
#align add_action.mem_stabilizer_add_submonoid_iff AddAction.mem_stabilizerAddSubmonoid_iff
end Stabilizers
end MulAction
section FixedPoints
variable (M : Type u) (α : Type v) [Monoid M]
section Monoid
variable [Monoid α] [MulDistribMulAction M α]
/-- The submonoid of elements fixed under the whole action. -/
def FixedPoints.submonoid : Submonoid α where
carrier := MulAction.fixedPoints M α
one_mem' := smul_one
mul_mem' ha hb _ := by rw [smul_mul', ha, hb]
@[simp]
lemma FixedPoints.mem_submonoid (a : α) : a ∈ submonoid M α ↔ ∀ m : M, m • a = a :=
Iff.rfl
end Monoid
section Group
namespace FixedPoints
variable [Group α] [MulDistribMulAction M α]
/-- The subgroup of elements fixed under the whole action. -/
def subgroup : Subgroup α where
__ := submonoid M α
inv_mem' ha _ := by rw [smul_inv', ha]
/-- The notation for `FixedPoints.subgroup`, chosen to resemble `αᴹ`. -/
scoped notation α "^*" M:51 => FixedPoints.subgroup M α
@[simp]
lemma mem_subgroup (a : α) : a ∈ α^*M ↔ ∀ m : M, m • a = a :=
Iff.rfl
@[simp]
lemma subgroup_toSubmonoid : (α^*M).toSubmonoid = submonoid M α :=
rfl
end FixedPoints
end Group
section AddMonoid
variable [AddMonoid α] [DistribMulAction M α]
/-- The additive submonoid of elements fixed under the whole action. -/
def FixedPoints.addSubmonoid : AddSubmonoid α where
carrier := MulAction.fixedPoints M α
zero_mem' := smul_zero
add_mem' ha hb _ := by rw [smul_add, ha, hb]
@[simp]
lemma FixedPoints.mem_addSubmonoid (a : α) : a ∈ addSubmonoid M α ↔ ∀ m : M, m • a = a :=
Iff.rfl
end AddMonoid
section AddGroup
variable [AddGroup α] [DistribMulAction M α]
/-- The additive subgroup of elements fixed under the whole action. -/
def FixedPoints.addSubgroup : AddSubgroup α where
__ := addSubmonoid M α
neg_mem' ha _ := by rw [smul_neg, ha]
/-- The notation for `FixedPoints.addSubgroup`, chosen to resemble `αᴹ`. -/
notation α "^+" M:51 => FixedPoints.addSubgroup M α
@[simp]
lemma FixedPoints.mem_addSubgroup (a : α) : a ∈ α^+M ↔ ∀ m : M, m • a = a :=
Iff.rfl
@[simp]
lemma FixedPoints.addSubgroup_toAddSubmonoid : (α^+M).toAddSubmonoid = addSubmonoid M α :=
rfl
end AddGroup
end FixedPoints
/-- `smul` by a `k : M` over a ring is injective, if `k` is not a zero divisor.
The general theory of such `k` is elaborated by `IsSMulRegular`.
The typeclass that restricts all terms of `M` to have this property is `NoZeroSMulDivisors`. -/
theorem smul_cancel_of_non_zero_divisor {M R : Type*} [Monoid M] [NonUnitalNonAssocRing R]
[DistribMulAction M R] (k : M) (h : ∀ x : R, k • x = 0 → x = 0) {a b : R} (h' : k • a = k • b) :
a = b := by
rw [← sub_eq_zero]
refine h _ ?_
rw [smul_sub, h', sub_self]
#align smul_cancel_of_non_zero_divisor smul_cancel_of_non_zero_divisor
namespace MulAction
variable {G α β : Type*} [Group G] [MulAction G α] [MulAction G β]
section Orbit
@[to_additive (attr := simp)]
theorem smul_orbit (g : G) (a : α) : g • orbit G a = orbit G a :=
(smul_orbit_subset g a).antisymm <|
calc
orbit G a = g • g⁻¹ • orbit G a := (smul_inv_smul _ _).symm
_ ⊆ g • orbit G a := Set.image_subset _ (smul_orbit_subset _ _)
#align mul_action.smul_orbit MulAction.smul_orbit
#align add_action.vadd_orbit AddAction.vadd_orbit
@[to_additive (attr := simp)]
theorem orbit_smul (g : G) (a : α) : orbit G (g • a) = orbit G a :=
(orbit_smul_subset g a).antisymm <|
calc
orbit G a = orbit G (g⁻¹ • g • a) := by rw [inv_smul_smul]
_ ⊆ orbit G (g • a) := orbit_smul_subset _ _
#align mul_action.orbit_smul MulAction.orbit_smul
#align add_action.orbit_vadd AddAction.orbit_vadd
/-- The action of a group on an orbit is transitive. -/
@[to_additive "The action of an additive group on an orbit is transitive."]
instance (a : α) : IsPretransitive G (orbit G a) :=
⟨by
rintro ⟨_, g, rfl⟩ ⟨_, h, rfl⟩
use h * g⁻¹
ext1
simp [mul_smul]⟩
@[to_additive]
theorem orbit_eq_iff {a b : α} : orbit G a = orbit G b ↔ a ∈ orbit G b :=
⟨fun h => h ▸ mem_orbit_self _, fun ⟨_, hc⟩ => hc ▸ orbit_smul _ _⟩
#align mul_action.orbit_eq_iff MulAction.orbit_eq_iff
#align add_action.orbit_eq_iff AddAction.orbit_eq_iff
@[to_additive]
theorem mem_orbit_smul (g : G) (a : α) : a ∈ orbit G (g • a) := by
simp only [orbit_smul, mem_orbit_self]
#align mul_action.mem_orbit_smul MulAction.mem_orbit_smul
#align add_action.mem_orbit_vadd AddAction.mem_orbit_vadd
@[to_additive]
theorem smul_mem_orbit_smul (g h : G) (a : α) : g • a ∈ orbit G (h • a) := by
simp only [orbit_smul, mem_orbit]
#align mul_action.smul_mem_orbit_smul MulAction.smul_mem_orbit_smul
#align add_action.vadd_mem_orbit_vadd AddAction.vadd_mem_orbit_vadd
@[to_additive]
lemma orbit_subgroup_subset (H : Subgroup G) (a : α) : orbit H a ⊆ orbit G a :=
orbit_submonoid_subset H.toSubmonoid a
@[to_additive]
lemma mem_orbit_of_mem_orbit_subgroup {H : Subgroup G} {a b : α} (h : a ∈ orbit H b) :
a ∈ orbit G b :=
orbit_subgroup_subset H _ h
@[to_additive]
lemma mem_orbit_symm {a₁ a₂ : α} : a₁ ∈ orbit G a₂ ↔ a₂ ∈ orbit G a₁ := by
simp_rw [← orbit_eq_iff, eq_comm]
@[to_additive]
lemma mem_subgroup_orbit_iff {H : Subgroup G} {x : α} {a b : orbit G x} :
a ∈ MulAction.orbit H b ↔ (a : α) ∈ MulAction.orbit H (b : α) := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h with ⟨g, rfl⟩
simp_rw [Submonoid.smul_def, Subgroup.coe_toSubmonoid, orbit.coe_smul, ← Submonoid.smul_def]
exact MulAction.mem_orbit _ g
· rcases h with ⟨g, h⟩
simp_rw [Submonoid.smul_def, Subgroup.coe_toSubmonoid, ← orbit.coe_smul,
← Submonoid.smul_def, ← Subtype.ext_iff] at h
subst h
exact MulAction.mem_orbit _ g
variable (G α)
/-- The relation 'in the same orbit'. -/
@[to_additive "The relation 'in the same orbit'."]
def orbitRel : Setoid α where
r a b := a ∈ orbit G b
iseqv :=
⟨mem_orbit_self, fun {a b} => by simp [orbit_eq_iff.symm, eq_comm], fun {a b} => by
simp (config := { contextual := true }) [orbit_eq_iff.symm, eq_comm]⟩
#align mul_action.orbit_rel MulAction.orbitRel
#align add_action.orbit_rel AddAction.orbitRel
variable {G α}
@[to_additive]
theorem orbitRel_apply {a b : α} : (orbitRel G α).Rel a b ↔ a ∈ orbit G b :=
Iff.rfl
#align mul_action.orbit_rel_apply MulAction.orbitRel_apply
#align add_action.orbit_rel_apply AddAction.orbitRel_apply
@[to_additive]
lemma orbitRel_r_apply {a b : α} : (orbitRel G _).r a b ↔ a ∈ orbit G b :=
Iff.rfl
@[to_additive]
lemma orbitRel_subgroup_le (H : Subgroup G) : orbitRel H α ≤ orbitRel G α :=
Setoid.le_def.2 mem_orbit_of_mem_orbit_subgroup
/-- When you take a set `U` in `α`, push it down to the quotient, and pull back, you get the union
of the orbit of `U` under `G`. -/
@[to_additive
"When you take a set `U` in `α`, push it down to the quotient, and pull back, you get the
union of the orbit of `U` under `G`."]
theorem quotient_preimage_image_eq_union_mul (U : Set α) :
letI := orbitRel G α
Quotient.mk' ⁻¹' (Quotient.mk' '' U) = ⋃ g : G, (g • ·) '' U := by
letI := orbitRel G α
set f : α → Quotient (MulAction.orbitRel G α) := Quotient.mk'
ext a
constructor
· rintro ⟨b, hb, hab⟩
obtain ⟨g, rfl⟩ := Quotient.exact hab
rw [Set.mem_iUnion]
exact ⟨g⁻¹, g • a, hb, inv_smul_smul g a⟩
· intro hx
rw [Set.mem_iUnion] at hx
obtain ⟨g, u, hu₁, hu₂⟩ := hx
rw [Set.mem_preimage, Set.mem_image]
refine ⟨g⁻¹ • a, ?_, by simp only [f, Quotient.eq']; use g⁻¹⟩
rw [← hu₂]
convert hu₁
simp only [inv_smul_smul]
#align mul_action.quotient_preimage_image_eq_union_mul MulAction.quotient_preimage_image_eq_union_mul
#align add_action.quotient_preimage_image_eq_union_add AddAction.quotient_preimage_image_eq_union_add
@[to_additive]
theorem disjoint_image_image_iff {U V : Set α} :
letI := orbitRel G α
Disjoint (Quotient.mk' '' U) (Quotient.mk' '' V) ↔ ∀ x ∈ U, ∀ g : G, g • x ∉ V := by
letI := orbitRel G α
set f : α → Quotient (MulAction.orbitRel G α) := Quotient.mk'
refine
⟨fun h a a_in_U g g_in_V =>
h.le_bot ⟨⟨a, a_in_U, Quotient.sound ⟨g⁻¹, ?_⟩⟩, ⟨g • a, g_in_V, rfl⟩⟩, ?_⟩
· simp
· intro h
rw [Set.disjoint_left]
rintro _ ⟨b, hb₁, hb₂⟩ ⟨c, hc₁, hc₂⟩
obtain ⟨g, rfl⟩ := Quotient.exact (hc₂.trans hb₂.symm)
exact h b hb₁ g hc₁
#align mul_action.disjoint_image_image_iff MulAction.disjoint_image_image_iff
#align add_action.disjoint_image_image_iff AddAction.disjoint_image_image_iff
@[to_additive]
theorem image_inter_image_iff (U V : Set α) :
letI := orbitRel G α
Quotient.mk' '' U ∩ Quotient.mk' '' V = ∅ ↔ ∀ x ∈ U, ∀ g : G, g • x ∉ V :=
Set.disjoint_iff_inter_eq_empty.symm.trans disjoint_image_image_iff
#align mul_action.image_inter_image_iff MulAction.image_inter_image_iff
#align add_action.image_inter_image_iff AddAction.image_inter_image_iff
variable (G α)
/-- The quotient by `MulAction.orbitRel`, given a name to enable dot notation. -/
@[to_additive (attr := reducible)
"The quotient by `AddAction.orbitRel`, given a name to enable dot notation."]
def orbitRel.Quotient : Type _ :=
_root_.Quotient <| orbitRel G α
#align mul_action.orbit_rel.quotient MulAction.orbitRel.Quotient
#align add_action.orbit_rel.quotient AddAction.orbitRel.Quotient
/-- An action is pretransitive if and only if the quotient by `MulAction.orbitRel` is a
subsingleton. -/
@[to_additive "An additive action is pretransitive if and only if the quotient by
`AddAction.orbitRel` is a subsingleton."]
theorem pretransitive_iff_subsingleton_quotient :
IsPretransitive G α ↔ Subsingleton (orbitRel.Quotient G α) := by
refine ⟨fun _ ↦ ⟨fun a b ↦ ?_⟩, fun _ ↦ ⟨fun a b ↦ ?_⟩⟩
· refine Quot.inductionOn a (fun x ↦ ?_)
exact Quot.inductionOn b (fun y ↦ Quot.sound <| exists_smul_eq G y x)
· have h : Quotient.mk (orbitRel G α) b = ⟦a⟧ := Subsingleton.elim _ _
exact Quotient.eq_rel.mp h
/-- If `α` is non-empty, an action is pretransitive if and only if the quotient has exactly one
element. -/
@[to_additive "If `α` is non-empty, an additive action is pretransitive if and only if the
quotient has exactly one element."]
theorem pretransitive_iff_unique_quotient_of_nonempty [Nonempty α] :
IsPretransitive G α ↔ Nonempty (Unique <| orbitRel.Quotient G α) := by
rw [unique_iff_subsingleton_and_nonempty, pretransitive_iff_subsingleton_quotient, iff_self_and]
exact fun _ ↦ (nonempty_quotient_iff _).mpr inferInstance
variable {G α}
/-- The orbit corresponding to an element of the quotient by `MulAction.orbitRel` -/
@[to_additive "The orbit corresponding to an element of the quotient by `AddAction.orbitRel`"]
nonrec def orbitRel.Quotient.orbit (x : orbitRel.Quotient G α) : Set α :=
Quotient.liftOn' x (orbit G) fun _ _ => MulAction.orbit_eq_iff.2
#align mul_action.orbit_rel.quotient.orbit MulAction.orbitRel.Quotient.orbit
#align add_action.orbit_rel.quotient.orbit AddAction.orbitRel.Quotient.orbit
@[to_additive (attr := simp)]
theorem orbitRel.Quotient.orbit_mk (a : α) :
orbitRel.Quotient.orbit (Quotient.mk'' a : orbitRel.Quotient G α) = MulAction.orbit G a :=
rfl
#align mul_action.orbit_rel.quotient.orbit_mk MulAction.orbitRel.Quotient.orbit_mk
#align add_action.orbit_rel.quotient.orbit_mk AddAction.orbitRel.Quotient.orbit_mk
@[to_additive]
theorem orbitRel.Quotient.mem_orbit {a : α} {x : orbitRel.Quotient G α} :
a ∈ x.orbit ↔ Quotient.mk'' a = x := by
induction x using Quotient.inductionOn'
rw [Quotient.eq'']
rfl
#align mul_action.orbit_rel.quotient.mem_orbit MulAction.orbitRel.Quotient.mem_orbit
#align add_action.orbit_rel.quotient.mem_orbit AddAction.orbitRel.Quotient.mem_orbit
/-- Note that `hφ = Quotient.out_eq'` is a useful choice here. -/
@[to_additive "Note that `hφ = Quotient.out_eq'` is a useful choice here."]
theorem orbitRel.Quotient.orbit_eq_orbit_out (x : orbitRel.Quotient G α)
{φ : orbitRel.Quotient G α → α} (hφ : letI := orbitRel G α; RightInverse φ Quotient.mk') :
orbitRel.Quotient.orbit x = MulAction.orbit G (φ x) := by
conv_lhs => rw [← hφ x]
rfl
#align mul_action.orbit_rel.quotient.orbit_eq_orbit_out MulAction.orbitRel.Quotient.orbit_eq_orbit_out
#align add_action.orbit_rel.quotient.orbit_eq_orbit_out AddAction.orbitRel.Quotient.orbit_eq_orbit_out
@[to_additive]
lemma orbitRel.Quotient.orbit_injective :
Injective (orbitRel.Quotient.orbit : orbitRel.Quotient G α → Set α) := by
intro x y h
simp_rw [orbitRel.Quotient.orbit_eq_orbit_out _ Quotient.out_eq', orbit_eq_iff,
← orbitRel_r_apply] at h
simpa [← Quotient.eq''] using h
@[to_additive (attr := simp)]
lemma orbitRel.Quotient.orbit_inj {x y : orbitRel.Quotient G α} : x.orbit = y.orbit ↔ x = y :=
orbitRel.Quotient.orbit_injective.eq_iff
@[to_additive]
lemma orbitRel.quotient_eq_of_quotient_subgroup_eq {H : Subgroup G} {a b : α}
(h : (⟦a⟧ : orbitRel.Quotient H α) = ⟦b⟧) : (⟦a⟧ : orbitRel.Quotient G α) = ⟦b⟧ := by
rw [@Quotient.eq] at h ⊢
exact mem_orbit_of_mem_orbit_subgroup h
@[to_additive]
lemma orbitRel.quotient_eq_of_quotient_subgroup_eq' {H : Subgroup G} {a b : α}
(h : (Quotient.mk'' a : orbitRel.Quotient H α) = Quotient.mk'' b) :
(Quotient.mk'' a : orbitRel.Quotient G α) = Quotient.mk'' b :=
orbitRel.quotient_eq_of_quotient_subgroup_eq h
@[to_additive]
nonrec lemma orbitRel.Quotient.orbit_nonempty (x : orbitRel.Quotient G α) :
Set.Nonempty x.orbit := by
rw [orbitRel.Quotient.orbit_eq_orbit_out x Quotient.out_eq']
exact orbit_nonempty _
@[to_additive]
nonrec lemma orbitRel.Quotient.mapsTo_smul_orbit (g : G) (x : orbitRel.Quotient G α) :
Set.MapsTo (g • ·) x.orbit x.orbit := by
rw [orbitRel.Quotient.orbit_eq_orbit_out x Quotient.out_eq']
exact mapsTo_smul_orbit g x.out'
@[to_additive]
instance (x : orbitRel.Quotient G α) : MulAction G x.orbit where
smul g := (orbitRel.Quotient.mapsTo_smul_orbit g x).restrict _ _ _
one_smul a := Subtype.ext (one_smul G (a : α))
mul_smul g g' a' := Subtype.ext (mul_smul g g' (a' : α))
@[to_additive (attr := simp)]
lemma orbitRel.Quotient.orbit.coe_smul {g : G} {x : orbitRel.Quotient G α} {a : x.orbit} :
↑(g • a) = g • (a : α) :=
rfl
@[to_additive]
instance (x : orbitRel.Quotient G α) : IsPretransitive G x.orbit where
exists_smul_eq := by
induction x using Quotient.inductionOn'
rintro ⟨y, yh⟩ ⟨z, zh⟩
rw [orbitRel.Quotient.mem_orbit, Quotient.eq''] at yh zh
rcases yh with ⟨g, rfl⟩
rcases zh with ⟨h, rfl⟩
refine ⟨h * g⁻¹, ?_⟩
ext
simp [mul_smul]
@[to_additive (attr := norm_cast, simp)]
lemma orbitRel.Quotient.mem_subgroup_orbit_iff {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} : (a : α) ∈ MulAction.orbit H (b : α) ↔ a ∈ MulAction.orbit H b := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h with ⟨g, h⟩
simp_rw [Submonoid.smul_def, Subgroup.coe_toSubmonoid, ← orbit.coe_smul,
← Submonoid.smul_def, ← Subtype.ext_iff] at h
subst h
exact MulAction.mem_orbit _ g
· rcases h with ⟨g, rfl⟩
simp_rw [Submonoid.smul_def, Subgroup.coe_toSubmonoid, orbit.coe_smul, ← Submonoid.smul_def]
exact MulAction.mem_orbit _ g
@[to_additive]
lemma orbitRel.Quotient.subgroup_quotient_eq_iff {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} : (⟦a⟧ : orbitRel.Quotient H x.orbit) = ⟦b⟧ ↔
(⟦↑a⟧ : orbitRel.Quotient H α) = ⟦↑b⟧ := by
simp_rw [← @Quotient.mk''_eq_mk, Quotient.eq'']
exact orbitRel.Quotient.mem_subgroup_orbit_iff.symm
@[to_additive]
lemma orbitRel.Quotient.mem_subgroup_orbit_iff' {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} {c : α} (h : (⟦a⟧ : orbitRel.Quotient H x.orbit) = ⟦b⟧) :
(a : α) ∈ MulAction.orbit H c ↔ (b : α) ∈ MulAction.orbit H c := by
simp_rw [mem_orbit_symm (a₂ := c)]
convert Iff.rfl using 2
rw [orbit_eq_iff]
suffices hb : ↑b ∈ orbitRel.Quotient.orbit (⟦a⟧ : orbitRel.Quotient H x.orbit) by
rw [orbitRel.Quotient.orbit_eq_orbit_out (⟦a⟧ : orbitRel.Quotient H x.orbit) Quotient.out_eq']
at hb
rw [orbitRel.Quotient.mem_subgroup_orbit_iff]
convert hb using 1
rw [orbit_eq_iff, ← orbitRel_r_apply, ← Quotient.eq'', Quotient.out_eq', @Quotient.mk''_eq_mk]
rw [orbitRel.Quotient.mem_orbit, h, @Quotient.mk''_eq_mk]
variable (G) (α)
local notation "Ω" => orbitRel.Quotient G α
/-- Decomposition of a type `X` as a disjoint union of its orbits under a group action.
This version is expressed in terms of `MulAction.orbitRel.Quotient.orbit` instead of
`MulAction.orbit`, to avoid mentioning `Quotient.out'`. -/
@[to_additive
"Decomposition of a type `X` as a disjoint union of its orbits under an additive group action.
This version is expressed in terms of `AddAction.orbitRel.Quotient.orbit` instead of
`AddAction.orbit`, to avoid mentioning `Quotient.out'`. "]
def selfEquivSigmaOrbits' : α ≃ Σω : Ω, ω.orbit :=
letI := orbitRel G α
calc
α ≃ Σω : Ω, { a // Quotient.mk' a = ω } := (Equiv.sigmaFiberEquiv Quotient.mk').symm
_ ≃ Σω : Ω, ω.orbit :=
Equiv.sigmaCongrRight fun _ =>
Equiv.subtypeEquivRight fun _ => orbitRel.Quotient.mem_orbit.symm
#align mul_action.self_equiv_sigma_orbits' MulAction.selfEquivSigmaOrbits'
#align add_action.self_equiv_sigma_orbits' AddAction.selfEquivSigmaOrbits'
/-- Decomposition of a type `X` as a disjoint union of its orbits under a group action. -/
@[to_additive
"Decomposition of a type `X` as a disjoint union of its orbits under an additive group
action."]
def selfEquivSigmaOrbits : α ≃ Σω : Ω, orbit G ω.out' :=
(selfEquivSigmaOrbits' G α).trans <|
Equiv.sigmaCongrRight fun _ =>
Equiv.Set.ofEq <| orbitRel.Quotient.orbit_eq_orbit_out _ Quotient.out_eq'
#align mul_action.self_equiv_sigma_orbits MulAction.selfEquivSigmaOrbits
#align add_action.self_equiv_sigma_orbits AddAction.selfEquivSigmaOrbits
end Orbit
section Stabilizer
variable (G)
/-- The stabilizer of an element under an action, i.e. what sends the element to itself.
A subgroup. -/
@[to_additive
"The stabilizer of an element under an action, i.e. what sends the element to itself.
An additive subgroup."]
def stabilizer (a : α) : Subgroup G :=
{ stabilizerSubmonoid G a with
inv_mem' := fun {m} (ha : m • a = a) => show m⁻¹ • a = a by rw [inv_smul_eq_iff, ha] }
#align mul_action.stabilizer MulAction.stabilizer
#align add_action.stabilizer AddAction.stabilizer
variable {G}
@[to_additive]
instance [DecidableEq α] (a : α) : DecidablePred (· ∈ stabilizer G a) :=
fun _ => inferInstanceAs <| Decidable (_ = _)
@[to_additive (attr := simp)]
theorem mem_stabilizer_iff {a : α} {g : G} : g ∈ stabilizer G a ↔ g • a = a :=
Iff.rfl
#align mul_action.mem_stabilizer_iff MulAction.mem_stabilizer_iff
#align add_action.mem_stabilizer_iff AddAction.mem_stabilizer_iff
@[to_additive]
lemma le_stabilizer_smul_left [SMul α β] [IsScalarTower G α β] (a : α) (b : β) :
stabilizer G a ≤ stabilizer G (a • b) := by
simp_rw [SetLike.le_def, mem_stabilizer_iff, ← smul_assoc]; rintro a h; rw [h]
@[to_additive]
lemma le_stabilizer_smul_right [SMul α β] [SMulCommClass G α β] (a : α) (b : β) :
stabilizer G b ≤ stabilizer G (a • b) := by
simp_rw [SetLike.le_def, mem_stabilizer_iff, smul_comm]; rintro a h; rw [h]
@[to_additive (attr := simp)]
lemma stabilizer_smul_eq_left [SMul α β] [IsScalarTower G α β] (a : α) (b : β)
(h : Injective (· • b : α → β)) : stabilizer G (a • b) = stabilizer G a := by
refine (le_stabilizer_smul_left _ _).antisymm' fun a ha ↦ ?_
simpa only [mem_stabilizer_iff, ← smul_assoc, h.eq_iff] using ha
@[to_additive (attr := simp)]
lemma stabilizer_smul_eq_right [Group α] [MulAction α β] [SMulCommClass G α β] (a : α) (b : β) :
stabilizer G (a • b) = stabilizer G b :=
(le_stabilizer_smul_right _ _).antisymm' <| (le_stabilizer_smul_right a⁻¹ _).trans_eq <| by
rw [inv_smul_smul]
@[to_additive (attr := simp)]
lemma stabilizer_mul_eq_left [Group α] [IsScalarTower G α α] (a b : α) :
stabilizer G (a * b) = stabilizer G a := stabilizer_smul_eq_left a _ <| mul_left_injective _
@[to_additive (attr := simp)]
lemma stabilizer_mul_eq_right [Group α] [SMulCommClass G α α] (a b : α) :
stabilizer G (a * b) = stabilizer G b := stabilizer_smul_eq_right a _
/-- If the stabilizer of `a` is `S`, then the stabilizer of `g • a` is `gSg⁻¹`. -/
theorem stabilizer_smul_eq_stabilizer_map_conj (g : G) (a : α) :
stabilizer G (g • a) = (stabilizer G a).map (MulAut.conj g).toMonoidHom := by
ext h
rw [mem_stabilizer_iff, ← smul_left_cancel_iff g⁻¹, smul_smul, smul_smul, smul_smul, mul_left_inv,
one_smul, ← mem_stabilizer_iff, Subgroup.mem_map_equiv, MulAut.conj_symm_apply]
#align mul_action.stabilizer_smul_eq_stabilizer_map_conj MulAction.stabilizer_smul_eq_stabilizer_map_conj
/-- A bijection between the stabilizers of two elements in the same orbit. -/
noncomputable def stabilizerEquivStabilizerOfOrbitRel {a b : α} (h : (orbitRel G α).Rel a b) :
stabilizer G a ≃* stabilizer G b :=
let g : G := Classical.choose h
have hg : g • b = a := Classical.choose_spec h
have this : stabilizer G a = (stabilizer G b).map (MulAut.conj g).toMonoidHom := by
rw [← hg, stabilizer_smul_eq_stabilizer_map_conj]
(MulEquiv.subgroupCongr this).trans ((MulAut.conj g).subgroupMap <| stabilizer G b).symm
#align mul_action.stabilizer_equiv_stabilizer_of_orbit_rel MulAction.stabilizerEquivStabilizerOfOrbitRel
end Stabilizer
end MulAction
namespace AddAction
variable {G α : Type*} [AddGroup G] [AddAction G α]
/-- If the stabilizer of `x` is `S`, then the stabilizer of `g +ᵥ x` is `g + S + (-g)`. -/
theorem stabilizer_vadd_eq_stabilizer_map_conj (g : G) (a : α) :
stabilizer G (g +ᵥ a) = (stabilizer G a).map (AddAut.conj g).toAddMonoidHom := by
ext h
rw [mem_stabilizer_iff, ← vadd_left_cancel_iff (-g), vadd_vadd, vadd_vadd, vadd_vadd,
add_left_neg, zero_vadd, ← mem_stabilizer_iff, AddSubgroup.mem_map_equiv,
AddAut.conj_symm_apply]
#align add_action.stabilizer_vadd_eq_stabilizer_map_conj AddAction.stabilizer_vadd_eq_stabilizer_map_conj
/-- A bijection between the stabilizers of two elements in the same orbit. -/
noncomputable def stabilizerEquivStabilizerOfOrbitRel {a b : α} (h : (orbitRel G α).Rel a b) :
stabilizer G a ≃+ stabilizer G b :=
let g : G := Classical.choose h
have hg : g +ᵥ b = a := Classical.choose_spec h
have this : stabilizer G a = (stabilizer G b).map (AddAut.conj g).toAddMonoidHom := by
rw [← hg, stabilizer_vadd_eq_stabilizer_map_conj]
(AddEquiv.addSubgroupCongr this).trans ((AddAut.conj g).addSubgroupMap <| stabilizer G b).symm
#align add_action.stabilizer_equiv_stabilizer_of_orbit_rel AddAction.stabilizerEquivStabilizerOfOrbitRel
end AddAction
attribute [to_additive existing] MulAction.stabilizer_smul_eq_stabilizer_map_conj
attribute [to_additive existing] MulAction.stabilizerEquivStabilizerOfOrbitRel
theorem Equiv.swap_mem_stabilizer {α : Type*} [DecidableEq α] {S : Set α} {a b : α} :
Equiv.swap a b ∈ MulAction.stabilizer (Equiv.Perm α) S ↔ (a ∈ S ↔ b ∈ S) := by
rw [MulAction.mem_stabilizer_iff, Set.ext_iff, ← swap_inv]
simp_rw [Set.mem_inv_smul_set_iff, Perm.smul_def, swap_apply_def]
exact ⟨fun h ↦ by simpa [Iff.comm] using h a, by intros; split_ifs <;> simp [*]⟩
namespace MulAction
variable {G : Type*} [Group G] {α : Type*} [MulAction G α]
/-- To prove inclusion of a *subgroup* in a stabilizer, it is enough to prove inclusions.-/
| Mathlib/GroupTheory/GroupAction/Basic.lean | 790 | 805 | theorem le_stabilizer_iff_smul_le (s : Set α) (H : Subgroup G) :
H ≤ stabilizer G s ↔ ∀ g ∈ H, g • s ⊆ s := by |
constructor
· intro hyp g hg
apply Eq.subset
rw [← mem_stabilizer_iff]
exact hyp hg
· intro hyp g hg
rw [mem_stabilizer_iff]
apply subset_antisymm (hyp g hg)
intro x hx
use g⁻¹ • x
constructor
· apply hyp g⁻¹ (inv_mem hg)
simp only [Set.smul_mem_smul_set_iff, hx]
· simp only [smul_inv_smul]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.Restrict
/-!
# Classes of measures
We introduce the following typeclasses for measures:
* `IsProbabilityMeasure μ`: `μ univ = 1`;
* `IsFiniteMeasure μ`: `μ univ < ∞`;
* `SigmaFinite μ`: there exists a countable collection of sets that cover `univ`
where `μ` is finite;
* `SFinite μ`: the measure `μ` can be written as a countable sum of finite measures;
* `IsLocallyFiniteMeasure μ` : `∀ x, ∃ s ∈ 𝓝 x, μ s < ∞`;
* `NoAtoms μ` : `∀ x, μ {x} = 0`; possibly should be redefined as
`∀ s, 0 < μ s → ∃ t ⊆ s, 0 < μ t ∧ μ t < μ s`.
-/
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter Function MeasurableSpace ENNReal
variable {α β δ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] {μ ν ν₁ ν₂: Measure α}
{s t : Set α}
section IsFiniteMeasure
/-- A measure `μ` is called finite if `μ univ < ∞`. -/
class IsFiniteMeasure (μ : Measure α) : Prop where
measure_univ_lt_top : μ univ < ∞
#align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure
#align measure_theory.is_finite_measure.measure_univ_lt_top MeasureTheory.IsFiniteMeasure.measure_univ_lt_top
theorem not_isFiniteMeasure_iff : ¬IsFiniteMeasure μ ↔ μ Set.univ = ∞ := by
refine ⟨fun h => ?_, fun h => fun h' => h'.measure_univ_lt_top.ne h⟩
by_contra h'
exact h ⟨lt_top_iff_ne_top.mpr h'⟩
#align measure_theory.not_is_finite_measure_iff MeasureTheory.not_isFiniteMeasure_iff
instance Restrict.isFiniteMeasure (μ : Measure α) [hs : Fact (μ s < ∞)] :
IsFiniteMeasure (μ.restrict s) :=
⟨by simpa using hs.elim⟩
#align measure_theory.restrict.is_finite_measure MeasureTheory.Restrict.isFiniteMeasure
theorem measure_lt_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s < ∞ :=
(measure_mono (subset_univ s)).trans_lt IsFiniteMeasure.measure_univ_lt_top
#align measure_theory.measure_lt_top MeasureTheory.measure_lt_top
instance isFiniteMeasureRestrict (μ : Measure α) (s : Set α) [h : IsFiniteMeasure μ] :
IsFiniteMeasure (μ.restrict s) :=
⟨by simpa using measure_lt_top μ s⟩
#align measure_theory.is_finite_measure_restrict MeasureTheory.isFiniteMeasureRestrict
theorem measure_ne_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s ≠ ∞ :=
ne_of_lt (measure_lt_top μ s)
#align measure_theory.measure_ne_top MeasureTheory.measure_ne_top
theorem measure_compl_le_add_of_le_add [IsFiniteMeasure μ] (hs : MeasurableSet s)
(ht : MeasurableSet t) {ε : ℝ≥0∞} (h : μ s ≤ μ t + ε) : μ tᶜ ≤ μ sᶜ + ε := by
rw [measure_compl ht (measure_ne_top μ _), measure_compl hs (measure_ne_top μ _),
tsub_le_iff_right]
calc
μ univ = μ univ - μ s + μ s := (tsub_add_cancel_of_le <| measure_mono s.subset_univ).symm
_ ≤ μ univ - μ s + (μ t + ε) := add_le_add_left h _
_ = _ := by rw [add_right_comm, add_assoc]
#align measure_theory.measure_compl_le_add_of_le_add MeasureTheory.measure_compl_le_add_of_le_add
theorem measure_compl_le_add_iff [IsFiniteMeasure μ] (hs : MeasurableSet s) (ht : MeasurableSet t)
{ε : ℝ≥0∞} : μ sᶜ ≤ μ tᶜ + ε ↔ μ t ≤ μ s + ε :=
⟨fun h => compl_compl s ▸ compl_compl t ▸ measure_compl_le_add_of_le_add hs.compl ht.compl h,
measure_compl_le_add_of_le_add ht hs⟩
#align measure_theory.measure_compl_le_add_iff MeasureTheory.measure_compl_le_add_iff
/-- The measure of the whole space with respect to a finite measure, considered as `ℝ≥0`. -/
def measureUnivNNReal (μ : Measure α) : ℝ≥0 :=
(μ univ).toNNReal
#align measure_theory.measure_univ_nnreal MeasureTheory.measureUnivNNReal
@[simp]
theorem coe_measureUnivNNReal (μ : Measure α) [IsFiniteMeasure μ] :
↑(measureUnivNNReal μ) = μ univ :=
ENNReal.coe_toNNReal (measure_ne_top μ univ)
#align measure_theory.coe_measure_univ_nnreal MeasureTheory.coe_measureUnivNNReal
instance isFiniteMeasureZero : IsFiniteMeasure (0 : Measure α) :=
⟨by simp⟩
#align measure_theory.is_finite_measure_zero MeasureTheory.isFiniteMeasureZero
instance (priority := 50) isFiniteMeasureOfIsEmpty [IsEmpty α] : IsFiniteMeasure μ := by
rw [eq_zero_of_isEmpty μ]
infer_instance
#align measure_theory.is_finite_measure_of_is_empty MeasureTheory.isFiniteMeasureOfIsEmpty
@[simp]
theorem measureUnivNNReal_zero : measureUnivNNReal (0 : Measure α) = 0 :=
rfl
#align measure_theory.measure_univ_nnreal_zero MeasureTheory.measureUnivNNReal_zero
instance isFiniteMeasureAdd [IsFiniteMeasure μ] [IsFiniteMeasure ν] : IsFiniteMeasure (μ + ν) where
measure_univ_lt_top := by
rw [Measure.coe_add, Pi.add_apply, ENNReal.add_lt_top]
exact ⟨measure_lt_top _ _, measure_lt_top _ _⟩
#align measure_theory.is_finite_measure_add MeasureTheory.isFiniteMeasureAdd
instance isFiniteMeasureSMulNNReal [IsFiniteMeasure μ] {r : ℝ≥0} : IsFiniteMeasure (r • μ) where
measure_univ_lt_top := ENNReal.mul_lt_top ENNReal.coe_ne_top (measure_ne_top _ _)
#align measure_theory.is_finite_measure_smul_nnreal MeasureTheory.isFiniteMeasureSMulNNReal
instance IsFiniteMeasure.average : IsFiniteMeasure ((μ univ)⁻¹ • μ) where
measure_univ_lt_top := by
rw [smul_apply, smul_eq_mul, ← ENNReal.div_eq_inv_mul]
exact ENNReal.div_self_le_one.trans_lt ENNReal.one_lt_top
instance isFiniteMeasureSMulOfNNRealTower {R} [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0∞]
[IsScalarTower R ℝ≥0∞ ℝ≥0∞] [IsFiniteMeasure μ] {r : R} : IsFiniteMeasure (r • μ) := by
rw [← smul_one_smul ℝ≥0 r μ]
infer_instance
#align measure_theory.is_finite_measure_smul_of_nnreal_tower MeasureTheory.isFiniteMeasureSMulOfNNRealTower
theorem isFiniteMeasure_of_le (μ : Measure α) [IsFiniteMeasure μ] (h : ν ≤ μ) : IsFiniteMeasure ν :=
{ measure_univ_lt_top := (h Set.univ).trans_lt (measure_lt_top _ _) }
#align measure_theory.is_finite_measure_of_le MeasureTheory.isFiniteMeasure_of_le
@[instance]
theorem Measure.isFiniteMeasure_map {m : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ]
(f : α → β) : IsFiniteMeasure (μ.map f) := by
by_cases hf : AEMeasurable f μ
· constructor
rw [map_apply_of_aemeasurable hf MeasurableSet.univ]
exact measure_lt_top μ _
· rw [map_of_not_aemeasurable hf]
exact MeasureTheory.isFiniteMeasureZero
#align measure_theory.measure.is_finite_measure_map MeasureTheory.Measure.isFiniteMeasure_map
@[simp]
theorem measureUnivNNReal_eq_zero [IsFiniteMeasure μ] : measureUnivNNReal μ = 0 ↔ μ = 0 := by
rw [← MeasureTheory.Measure.measure_univ_eq_zero, ← coe_measureUnivNNReal]
norm_cast
#align measure_theory.measure_univ_nnreal_eq_zero MeasureTheory.measureUnivNNReal_eq_zero
| Mathlib/MeasureTheory/Measure/Typeclasses.lean | 148 | 150 | theorem measureUnivNNReal_pos [IsFiniteMeasure μ] (hμ : μ ≠ 0) : 0 < measureUnivNNReal μ := by |
contrapose! hμ
simpa [measureUnivNNReal_eq_zero, Nat.le_zero] using hμ
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro, Floris van Doorn
-/
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Order.Bounded
import Mathlib.SetTheory.Cardinal.PartENat
import Mathlib.SetTheory.Ordinal.Principal
import Mathlib.Tactic.Linarith
#align_import set_theory.cardinal.ordinal from "leanprover-community/mathlib"@"7c2ce0c2da15516b4e65d0c9e254bb6dc93abd1f"
/-!
# Cardinals and ordinals
Relationships between cardinals and ordinals, properties of cardinals that are proved
using ordinals.
## Main definitions
* The function `Cardinal.aleph'` gives the cardinals listed by their ordinal
index, and is the inverse of `Cardinal.aleph/idx`.
`aleph' n = n`, `aleph' ω = ℵ₀`, `aleph' (ω + 1) = succ ℵ₀`, etc.
It is an order isomorphism between ordinals and cardinals.
* The function `Cardinal.aleph` gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ℵ₀`, `aleph 1 = succ ℵ₀` is the first
uncountable cardinal, and so on. The notation `ω_` combines the latter with `Cardinal.ord`,
giving an enumeration of (infinite) initial ordinals.
Thus `ω_ 0 = ω` and `ω₁ = ω_ 1` is the first uncountable ordinal.
* The function `Cardinal.beth` enumerates the Beth cardinals. `beth 0 = ℵ₀`,
`beth (succ o) = 2 ^ beth o`, and for a limit ordinal `o`, `beth o` is the supremum of `beth a`
for `a < o`.
## Main Statements
* `Cardinal.mul_eq_max` and `Cardinal.add_eq_max` state that the product (resp. sum) of two infinite
cardinals is just their maximum. Several variations around this fact are also given.
* `Cardinal.mk_list_eq_mk` : when `α` is infinite, `α` and `List α` have the same cardinality.
* simp lemmas for inequalities between `bit0 a` and `bit1 b` are registered, making `simp`
able to prove inequalities about numeral cardinals.
## Tags
cardinal arithmetic (for infinite cardinals)
-/
noncomputable section
open Function Set Cardinal Equiv Order Ordinal
open scoped Classical
universe u v w
namespace Cardinal
section UsingOrdinals
theorem ord_isLimit {c} (co : ℵ₀ ≤ c) : (ord c).IsLimit := by
refine ⟨fun h => aleph0_ne_zero ?_, fun a => lt_imp_lt_of_le_imp_le fun h => ?_⟩
· rw [← Ordinal.le_zero, ord_le] at h
simpa only [card_zero, nonpos_iff_eq_zero] using co.trans h
· rw [ord_le] at h ⊢
rwa [← @add_one_of_aleph0_le (card a), ← card_succ]
rw [← ord_le, ← le_succ_of_isLimit, ord_le]
· exact co.trans h
· rw [ord_aleph0]
exact omega_isLimit
#align cardinal.ord_is_limit Cardinal.ord_isLimit
theorem noMaxOrder {c} (h : ℵ₀ ≤ c) : NoMaxOrder c.ord.out.α :=
Ordinal.out_no_max_of_succ_lt (ord_isLimit h).2
/-! ### Aleph cardinals -/
section aleph
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `alephIdx n = n`, `alephIdx ω = ω`,
`alephIdx ℵ₁ = ω + 1` and so on.)
In this definition, we register additionally that this function is an initial segment,
i.e., it is order preserving and its range is an initial segment of the ordinals.
For the basic function version, see `alephIdx`.
For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/
def alephIdx.initialSeg : @InitialSeg Cardinal Ordinal (· < ·) (· < ·) :=
@RelEmbedding.collapse Cardinal Ordinal (· < ·) (· < ·) _ Cardinal.ord.orderEmbedding.ltEmbedding
#align cardinal.aleph_idx.initial_seg Cardinal.alephIdx.initialSeg
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `alephIdx n = n`, `alephIdx ω = ω`,
`alephIdx ℵ₁ = ω + 1` and so on.)
For an upgraded version stating that the range is everything, see `AlephIdx.rel_iso`. -/
def alephIdx : Cardinal → Ordinal :=
alephIdx.initialSeg
#align cardinal.aleph_idx Cardinal.alephIdx
@[simp]
theorem alephIdx.initialSeg_coe : (alephIdx.initialSeg : Cardinal → Ordinal) = alephIdx :=
rfl
#align cardinal.aleph_idx.initial_seg_coe Cardinal.alephIdx.initialSeg_coe
@[simp]
theorem alephIdx_lt {a b} : alephIdx a < alephIdx b ↔ a < b :=
alephIdx.initialSeg.toRelEmbedding.map_rel_iff
#align cardinal.aleph_idx_lt Cardinal.alephIdx_lt
@[simp]
theorem alephIdx_le {a b} : alephIdx a ≤ alephIdx b ↔ a ≤ b := by
rw [← not_lt, ← not_lt, alephIdx_lt]
#align cardinal.aleph_idx_le Cardinal.alephIdx_le
theorem alephIdx.init {a b} : b < alephIdx a → ∃ c, alephIdx c = b :=
alephIdx.initialSeg.init
#align cardinal.aleph_idx.init Cardinal.alephIdx.init
/-- The `aleph'` index function, which gives the ordinal index of a cardinal.
(The `aleph'` part is because unlike `aleph` this counts also the
finite stages. So `alephIdx n = n`, `alephIdx ℵ₀ = ω`,
`alephIdx ℵ₁ = ω + 1` and so on.)
In this version, we register additionally that this function is an order isomorphism
between cardinals and ordinals.
For the basic function version, see `alephIdx`. -/
def alephIdx.relIso : @RelIso Cardinal.{u} Ordinal.{u} (· < ·) (· < ·) :=
@RelIso.ofSurjective Cardinal.{u} Ordinal.{u} (· < ·) (· < ·) alephIdx.initialSeg.{u} <|
(InitialSeg.eq_or_principal alephIdx.initialSeg.{u}).resolve_right fun ⟨o, e⟩ => by
have : ∀ c, alephIdx c < o := fun c => (e _).2 ⟨_, rfl⟩
refine Ordinal.inductionOn o ?_ this; intro α r _ h
let s := ⨆ a, invFun alephIdx (Ordinal.typein r a)
apply (lt_succ s).not_le
have I : Injective.{u+2, u+2} alephIdx := alephIdx.initialSeg.toEmbedding.injective
simpa only [typein_enum, leftInverse_invFun I (succ s)] using
le_ciSup
(Cardinal.bddAbove_range.{u, u} fun a : α => invFun alephIdx (Ordinal.typein r a))
(Ordinal.enum r _ (h (succ s)))
#align cardinal.aleph_idx.rel_iso Cardinal.alephIdx.relIso
@[simp]
theorem alephIdx.relIso_coe : (alephIdx.relIso : Cardinal → Ordinal) = alephIdx :=
rfl
#align cardinal.aleph_idx.rel_iso_coe Cardinal.alephIdx.relIso_coe
@[simp]
theorem type_cardinal : @type Cardinal (· < ·) _ = Ordinal.univ.{u, u + 1} := by
rw [Ordinal.univ_id]; exact Quotient.sound ⟨alephIdx.relIso⟩
#align cardinal.type_cardinal Cardinal.type_cardinal
@[simp]
theorem mk_cardinal : #Cardinal = univ.{u, u + 1} := by
simpa only [card_type, card_univ] using congr_arg card type_cardinal
#align cardinal.mk_cardinal Cardinal.mk_cardinal
/-- The `aleph'` function gives the cardinals listed by their ordinal
index, and is the inverse of `aleph_idx`.
`aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = succ ℵ₀`, etc.
In this version, we register additionally that this function is an order isomorphism
between ordinals and cardinals.
For the basic function version, see `aleph'`. -/
def Aleph'.relIso :=
Cardinal.alephIdx.relIso.symm
#align cardinal.aleph'.rel_iso Cardinal.Aleph'.relIso
/-- The `aleph'` function gives the cardinals listed by their ordinal
index, and is the inverse of `aleph_idx`.
`aleph' n = n`, `aleph' ω = ω`, `aleph' (ω + 1) = succ ℵ₀`, etc. -/
def aleph' : Ordinal → Cardinal :=
Aleph'.relIso
#align cardinal.aleph' Cardinal.aleph'
@[simp]
theorem aleph'.relIso_coe : (Aleph'.relIso : Ordinal → Cardinal) = aleph' :=
rfl
#align cardinal.aleph'.rel_iso_coe Cardinal.aleph'.relIso_coe
@[simp]
theorem aleph'_lt {o₁ o₂ : Ordinal} : aleph' o₁ < aleph' o₂ ↔ o₁ < o₂ :=
Aleph'.relIso.map_rel_iff
#align cardinal.aleph'_lt Cardinal.aleph'_lt
@[simp]
theorem aleph'_le {o₁ o₂ : Ordinal} : aleph' o₁ ≤ aleph' o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph'_lt
#align cardinal.aleph'_le Cardinal.aleph'_le
@[simp]
theorem aleph'_alephIdx (c : Cardinal) : aleph' c.alephIdx = c :=
Cardinal.alephIdx.relIso.toEquiv.symm_apply_apply c
#align cardinal.aleph'_aleph_idx Cardinal.aleph'_alephIdx
@[simp]
theorem alephIdx_aleph' (o : Ordinal) : (aleph' o).alephIdx = o :=
Cardinal.alephIdx.relIso.toEquiv.apply_symm_apply o
#align cardinal.aleph_idx_aleph' Cardinal.alephIdx_aleph'
@[simp]
theorem aleph'_zero : aleph' 0 = 0 := by
rw [← nonpos_iff_eq_zero, ← aleph'_alephIdx 0, aleph'_le]
apply Ordinal.zero_le
#align cardinal.aleph'_zero Cardinal.aleph'_zero
@[simp]
theorem aleph'_succ {o : Ordinal} : aleph' (succ o) = succ (aleph' o) := by
apply (succ_le_of_lt <| aleph'_lt.2 <| lt_succ o).antisymm' (Cardinal.alephIdx_le.1 <| _)
rw [alephIdx_aleph', succ_le_iff, ← aleph'_lt, aleph'_alephIdx]
apply lt_succ
#align cardinal.aleph'_succ Cardinal.aleph'_succ
@[simp]
theorem aleph'_nat : ∀ n : ℕ, aleph' n = n
| 0 => aleph'_zero
| n + 1 => show aleph' (succ n) = n.succ by rw [aleph'_succ, aleph'_nat n, nat_succ]
#align cardinal.aleph'_nat Cardinal.aleph'_nat
theorem aleph'_le_of_limit {o : Ordinal} (l : o.IsLimit) {c} :
aleph' o ≤ c ↔ ∀ o' < o, aleph' o' ≤ c :=
⟨fun h o' h' => (aleph'_le.2 <| h'.le).trans h, fun h => by
rw [← aleph'_alephIdx c, aleph'_le, limit_le l]
intro x h'
rw [← aleph'_le, aleph'_alephIdx]
exact h _ h'⟩
#align cardinal.aleph'_le_of_limit Cardinal.aleph'_le_of_limit
theorem aleph'_limit {o : Ordinal} (ho : o.IsLimit) : aleph' o = ⨆ a : Iio o, aleph' a := by
refine le_antisymm ?_ (ciSup_le' fun i => aleph'_le.2 (le_of_lt i.2))
rw [aleph'_le_of_limit ho]
exact fun a ha => le_ciSup (bddAbove_of_small _) (⟨a, ha⟩ : Iio o)
#align cardinal.aleph'_limit Cardinal.aleph'_limit
@[simp]
theorem aleph'_omega : aleph' ω = ℵ₀ :=
eq_of_forall_ge_iff fun c => by
simp only [aleph'_le_of_limit omega_isLimit, lt_omega, exists_imp, aleph0_le]
exact forall_swap.trans (forall_congr' fun n => by simp only [forall_eq, aleph'_nat])
#align cardinal.aleph'_omega Cardinal.aleph'_omega
/-- `aleph'` and `aleph_idx` form an equivalence between `Ordinal` and `Cardinal` -/
@[simp]
def aleph'Equiv : Ordinal ≃ Cardinal :=
⟨aleph', alephIdx, alephIdx_aleph', aleph'_alephIdx⟩
#align cardinal.aleph'_equiv Cardinal.aleph'Equiv
/-- The `aleph` function gives the infinite cardinals listed by their
ordinal index. `aleph 0 = ℵ₀`, `aleph 1 = succ ℵ₀` is the first
uncountable cardinal, and so on. -/
def aleph (o : Ordinal) : Cardinal :=
aleph' (ω + o)
#align cardinal.aleph Cardinal.aleph
@[simp]
theorem aleph_lt {o₁ o₂ : Ordinal} : aleph o₁ < aleph o₂ ↔ o₁ < o₂ :=
aleph'_lt.trans (add_lt_add_iff_left _)
#align cardinal.aleph_lt Cardinal.aleph_lt
@[simp]
theorem aleph_le {o₁ o₂ : Ordinal} : aleph o₁ ≤ aleph o₂ ↔ o₁ ≤ o₂ :=
le_iff_le_iff_lt_iff_lt.2 aleph_lt
#align cardinal.aleph_le Cardinal.aleph_le
@[simp]
theorem max_aleph_eq (o₁ o₂ : Ordinal) : max (aleph o₁) (aleph o₂) = aleph (max o₁ o₂) := by
rcases le_total (aleph o₁) (aleph o₂) with h | h
· rw [max_eq_right h, max_eq_right (aleph_le.1 h)]
· rw [max_eq_left h, max_eq_left (aleph_le.1 h)]
#align cardinal.max_aleph_eq Cardinal.max_aleph_eq
@[simp]
theorem aleph_succ {o : Ordinal} : aleph (succ o) = succ (aleph o) := by
rw [aleph, add_succ, aleph'_succ, aleph]
#align cardinal.aleph_succ Cardinal.aleph_succ
@[simp]
theorem aleph_zero : aleph 0 = ℵ₀ := by rw [aleph, add_zero, aleph'_omega]
#align cardinal.aleph_zero Cardinal.aleph_zero
theorem aleph_limit {o : Ordinal} (ho : o.IsLimit) : aleph o = ⨆ a : Iio o, aleph a := by
apply le_antisymm _ (ciSup_le' _)
· rw [aleph, aleph'_limit (ho.add _)]
refine ciSup_mono' (bddAbove_of_small _) ?_
rintro ⟨i, hi⟩
cases' lt_or_le i ω with h h
· rcases lt_omega.1 h with ⟨n, rfl⟩
use ⟨0, ho.pos⟩
simpa using (nat_lt_aleph0 n).le
· exact ⟨⟨_, (sub_lt_of_le h).2 hi⟩, aleph'_le.2 (le_add_sub _ _)⟩
· exact fun i => aleph_le.2 (le_of_lt i.2)
#align cardinal.aleph_limit Cardinal.aleph_limit
theorem aleph0_le_aleph' {o : Ordinal} : ℵ₀ ≤ aleph' o ↔ ω ≤ o := by rw [← aleph'_omega, aleph'_le]
#align cardinal.aleph_0_le_aleph' Cardinal.aleph0_le_aleph'
theorem aleph0_le_aleph (o : Ordinal) : ℵ₀ ≤ aleph o := by
rw [aleph, aleph0_le_aleph']
apply Ordinal.le_add_right
#align cardinal.aleph_0_le_aleph Cardinal.aleph0_le_aleph
theorem aleph'_pos {o : Ordinal} (ho : 0 < o) : 0 < aleph' o := by rwa [← aleph'_zero, aleph'_lt]
#align cardinal.aleph'_pos Cardinal.aleph'_pos
theorem aleph_pos (o : Ordinal) : 0 < aleph o :=
aleph0_pos.trans_le (aleph0_le_aleph o)
#align cardinal.aleph_pos Cardinal.aleph_pos
@[simp]
theorem aleph_toNat (o : Ordinal) : toNat (aleph o) = 0 :=
toNat_apply_of_aleph0_le <| aleph0_le_aleph o
#align cardinal.aleph_to_nat Cardinal.aleph_toNat
@[simp]
theorem aleph_toPartENat (o : Ordinal) : toPartENat (aleph o) = ⊤ :=
toPartENat_apply_of_aleph0_le <| aleph0_le_aleph o
#align cardinal.aleph_to_part_enat Cardinal.aleph_toPartENat
instance nonempty_out_aleph (o : Ordinal) : Nonempty (aleph o).ord.out.α := by
rw [out_nonempty_iff_ne_zero, ← ord_zero]
exact fun h => (ord_injective h).not_gt (aleph_pos o)
#align cardinal.nonempty_out_aleph Cardinal.nonempty_out_aleph
theorem ord_aleph_isLimit (o : Ordinal) : (aleph o).ord.IsLimit :=
ord_isLimit <| aleph0_le_aleph _
#align cardinal.ord_aleph_is_limit Cardinal.ord_aleph_isLimit
instance (o : Ordinal) : NoMaxOrder (aleph o).ord.out.α :=
out_no_max_of_succ_lt (ord_aleph_isLimit o).2
theorem exists_aleph {c : Cardinal} : ℵ₀ ≤ c ↔ ∃ o, c = aleph o :=
⟨fun h =>
⟨alephIdx c - ω, by
rw [aleph, Ordinal.add_sub_cancel_of_le, aleph'_alephIdx]
rwa [← aleph0_le_aleph', aleph'_alephIdx]⟩,
fun ⟨o, e⟩ => e.symm ▸ aleph0_le_aleph _⟩
#align cardinal.exists_aleph Cardinal.exists_aleph
theorem aleph'_isNormal : IsNormal (ord ∘ aleph') :=
⟨fun o => ord_lt_ord.2 <| aleph'_lt.2 <| lt_succ o, fun o l a => by
simp [ord_le, aleph'_le_of_limit l]⟩
#align cardinal.aleph'_is_normal Cardinal.aleph'_isNormal
theorem aleph_isNormal : IsNormal (ord ∘ aleph) :=
aleph'_isNormal.trans <| add_isNormal ω
#align cardinal.aleph_is_normal Cardinal.aleph_isNormal
theorem succ_aleph0 : succ ℵ₀ = aleph 1 := by rw [← aleph_zero, ← aleph_succ, Ordinal.succ_zero]
#align cardinal.succ_aleph_0 Cardinal.succ_aleph0
theorem aleph0_lt_aleph_one : ℵ₀ < aleph 1 := by
rw [← succ_aleph0]
apply lt_succ
#align cardinal.aleph_0_lt_aleph_one Cardinal.aleph0_lt_aleph_one
theorem countable_iff_lt_aleph_one {α : Type*} (s : Set α) : s.Countable ↔ #s < aleph 1 := by
rw [← succ_aleph0, lt_succ_iff, le_aleph0_iff_set_countable]
#align cardinal.countable_iff_lt_aleph_one Cardinal.countable_iff_lt_aleph_one
/-- Ordinals that are cardinals are unbounded. -/
theorem ord_card_unbounded : Unbounded (· < ·) { b : Ordinal | b.card.ord = b } :=
unbounded_lt_iff.2 fun a =>
⟨_,
⟨by
dsimp
rw [card_ord], (lt_ord_succ_card a).le⟩⟩
#align cardinal.ord_card_unbounded Cardinal.ord_card_unbounded
theorem eq_aleph'_of_eq_card_ord {o : Ordinal} (ho : o.card.ord = o) : ∃ a, (aleph' a).ord = o :=
⟨Cardinal.alephIdx.relIso o.card, by simpa using ho⟩
#align cardinal.eq_aleph'_of_eq_card_ord Cardinal.eq_aleph'_of_eq_card_ord
/-- `ord ∘ aleph'` enumerates the ordinals that are cardinals. -/
theorem ord_aleph'_eq_enum_card : ord ∘ aleph' = enumOrd { b : Ordinal | b.card.ord = b } := by
rw [← eq_enumOrd _ ord_card_unbounded, range_eq_iff]
exact
⟨aleph'_isNormal.strictMono,
⟨fun a => by
dsimp
rw [card_ord], fun b hb => eq_aleph'_of_eq_card_ord hb⟩⟩
#align cardinal.ord_aleph'_eq_enum_card Cardinal.ord_aleph'_eq_enum_card
/-- Infinite ordinals that are cardinals are unbounded. -/
theorem ord_card_unbounded' : Unbounded (· < ·) { b : Ordinal | b.card.ord = b ∧ ω ≤ b } :=
(unbounded_lt_inter_le ω).2 ord_card_unbounded
#align cardinal.ord_card_unbounded' Cardinal.ord_card_unbounded'
theorem eq_aleph_of_eq_card_ord {o : Ordinal} (ho : o.card.ord = o) (ho' : ω ≤ o) :
∃ a, (aleph a).ord = o := by
cases' eq_aleph'_of_eq_card_ord ho with a ha
use a - ω
unfold aleph
rwa [Ordinal.add_sub_cancel_of_le]
rwa [← aleph0_le_aleph', ← ord_le_ord, ha, ord_aleph0]
#align cardinal.eq_aleph_of_eq_card_ord Cardinal.eq_aleph_of_eq_card_ord
/-- `ord ∘ aleph` enumerates the infinite ordinals that are cardinals. -/
theorem ord_aleph_eq_enum_card :
ord ∘ aleph = enumOrd { b : Ordinal | b.card.ord = b ∧ ω ≤ b } := by
rw [← eq_enumOrd _ ord_card_unbounded']
use aleph_isNormal.strictMono
rw [range_eq_iff]
refine ⟨fun a => ⟨?_, ?_⟩, fun b hb => eq_aleph_of_eq_card_ord hb.1 hb.2⟩
· rw [Function.comp_apply, card_ord]
· rw [← ord_aleph0, Function.comp_apply, ord_le_ord]
exact aleph0_le_aleph _
#align cardinal.ord_aleph_eq_enum_card Cardinal.ord_aleph_eq_enum_card
end aleph
/-! ### Beth cardinals -/
section beth
/-- Beth numbers are defined so that `beth 0 = ℵ₀`, `beth (succ o) = 2 ^ (beth o)`, and when `o` is
a limit ordinal, `beth o` is the supremum of `beth o'` for `o' < o`.
Assuming the generalized continuum hypothesis, which is undecidable in ZFC, `beth o = aleph o` for
every `o`. -/
def beth (o : Ordinal.{u}) : Cardinal.{u} :=
limitRecOn o aleph0 (fun _ x => (2 : Cardinal) ^ x) fun a _ IH => ⨆ b : Iio a, IH b.1 b.2
#align cardinal.beth Cardinal.beth
@[simp]
theorem beth_zero : beth 0 = aleph0 :=
limitRecOn_zero _ _ _
#align cardinal.beth_zero Cardinal.beth_zero
@[simp]
theorem beth_succ (o : Ordinal) : beth (succ o) = 2 ^ beth o :=
limitRecOn_succ _ _ _ _
#align cardinal.beth_succ Cardinal.beth_succ
theorem beth_limit {o : Ordinal} : o.IsLimit → beth o = ⨆ a : Iio o, beth a :=
limitRecOn_limit _ _ _ _
#align cardinal.beth_limit Cardinal.beth_limit
theorem beth_strictMono : StrictMono beth := by
intro a b
induction' b using Ordinal.induction with b IH generalizing a
intro h
rcases zero_or_succ_or_limit b with (rfl | ⟨c, rfl⟩ | hb)
· exact (Ordinal.not_lt_zero a h).elim
· rw [lt_succ_iff] at h
rw [beth_succ]
apply lt_of_le_of_lt _ (cantor _)
rcases eq_or_lt_of_le h with (rfl | h)
· rfl
exact (IH c (lt_succ c) h).le
· apply (cantor _).trans_le
rw [beth_limit hb, ← beth_succ]
exact le_ciSup (bddAbove_of_small _) (⟨_, hb.succ_lt h⟩ : Iio b)
#align cardinal.beth_strict_mono Cardinal.beth_strictMono
theorem beth_mono : Monotone beth :=
beth_strictMono.monotone
#align cardinal.beth_mono Cardinal.beth_mono
@[simp]
theorem beth_lt {o₁ o₂ : Ordinal} : beth o₁ < beth o₂ ↔ o₁ < o₂ :=
beth_strictMono.lt_iff_lt
#align cardinal.beth_lt Cardinal.beth_lt
@[simp]
theorem beth_le {o₁ o₂ : Ordinal} : beth o₁ ≤ beth o₂ ↔ o₁ ≤ o₂ :=
beth_strictMono.le_iff_le
#align cardinal.beth_le Cardinal.beth_le
theorem aleph_le_beth (o : Ordinal) : aleph o ≤ beth o := by
induction o using limitRecOn with
| H₁ => simp
| H₂ o h =>
rw [aleph_succ, beth_succ, succ_le_iff]
exact (cantor _).trans_le (power_le_power_left two_ne_zero h)
| H₃ o ho IH =>
rw [aleph_limit ho, beth_limit ho]
exact ciSup_mono (bddAbove_of_small _) fun x => IH x.1 x.2
#align cardinal.aleph_le_beth Cardinal.aleph_le_beth
theorem aleph0_le_beth (o : Ordinal) : ℵ₀ ≤ beth o :=
(aleph0_le_aleph o).trans <| aleph_le_beth o
#align cardinal.aleph_0_le_beth Cardinal.aleph0_le_beth
theorem beth_pos (o : Ordinal) : 0 < beth o :=
aleph0_pos.trans_le <| aleph0_le_beth o
#align cardinal.beth_pos Cardinal.beth_pos
theorem beth_ne_zero (o : Ordinal) : beth o ≠ 0 :=
(beth_pos o).ne'
#align cardinal.beth_ne_zero Cardinal.beth_ne_zero
theorem beth_normal : IsNormal.{u} fun o => (beth o).ord :=
(isNormal_iff_strictMono_limit _).2
⟨ord_strictMono.comp beth_strictMono, fun o ho a ha => by
rw [beth_limit ho, ord_le]
exact ciSup_le' fun b => ord_le.1 (ha _ b.2)⟩
#align cardinal.beth_normal Cardinal.beth_normal
end beth
/-! ### Properties of `mul` -/
section mulOrdinals
/-- If `α` is an infinite type, then `α × α` and `α` have the same cardinality. -/
theorem mul_eq_self {c : Cardinal} (h : ℵ₀ ≤ c) : c * c = c := by
refine le_antisymm ?_ (by simpa only [mul_one] using mul_le_mul_left' (one_le_aleph0.trans h) c)
-- the only nontrivial part is `c * c ≤ c`. We prove it inductively.
refine Acc.recOn (Cardinal.lt_wf.apply c) (fun c _ => Quotient.inductionOn c fun α IH ol => ?_) h
-- consider the minimal well-order `r` on `α` (a type with cardinality `c`).
rcases ord_eq α with ⟨r, wo, e⟩
letI := linearOrderOfSTO r
haveI : IsWellOrder α (· < ·) := wo
-- Define an order `s` on `α × α` by writing `(a, b) < (c, d)` if `max a b < max c d`, or
-- the max are equal and `a < c`, or the max are equal and `a = c` and `b < d`.
let g : α × α → α := fun p => max p.1 p.2
let f : α × α ↪ Ordinal × α × α :=
⟨fun p : α × α => (typein (· < ·) (g p), p), fun p q => congr_arg Prod.snd⟩
let s := f ⁻¹'o Prod.Lex (· < ·) (Prod.Lex (· < ·) (· < ·))
-- this is a well order on `α × α`.
haveI : IsWellOrder _ s := (RelEmbedding.preimage _ _).isWellOrder
/- it suffices to show that this well order is smaller than `r`
if it were larger, then `r` would be a strict prefix of `s`. It would be contained in
`β × β` for some `β` of cardinality `< c`. By the inductive assumption, this set has the
same cardinality as `β` (or it is finite if `β` is finite), so it is `< c`, which is a
contradiction. -/
suffices type s ≤ type r by exact card_le_card this
refine le_of_forall_lt fun o h => ?_
rcases typein_surj s h with ⟨p, rfl⟩
rw [← e, lt_ord]
refine lt_of_le_of_lt
(?_ : _ ≤ card (succ (typein (· < ·) (g p))) * card (succ (typein (· < ·) (g p)))) ?_
· have : { q | s q p } ⊆ insert (g p) { x | x < g p } ×ˢ insert (g p) { x | x < g p } := by
intro q h
simp only [s, f, Preimage, ge_iff_le, Embedding.coeFn_mk, Prod.lex_def, typein_lt_typein,
typein_inj, mem_setOf_eq] at h
exact max_le_iff.1 (le_iff_lt_or_eq.2 <| h.imp_right And.left)
suffices H : (insert (g p) { x | r x (g p) } : Set α) ≃ Sum { x | r x (g p) } PUnit from
⟨(Set.embeddingOfSubset _ _ this).trans
((Equiv.Set.prod _ _).trans (H.prodCongr H)).toEmbedding⟩
refine (Equiv.Set.insert ?_).trans ((Equiv.refl _).sumCongr punitEquivPUnit)
apply @irrefl _ r
cases' lt_or_le (card (succ (typein (· < ·) (g p)))) ℵ₀ with qo qo
· exact (mul_lt_aleph0 qo qo).trans_le ol
· suffices (succ (typein LT.lt (g p))).card < ⟦α⟧ from (IH _ this qo).trans_lt this
rw [← lt_ord]
apply (ord_isLimit ol).2
rw [mk'_def, e]
apply typein_lt_type
#align cardinal.mul_eq_self Cardinal.mul_eq_self
end mulOrdinals
end UsingOrdinals
/-! Properties of `mul`, not requiring ordinals -/
section mul
/-- If `α` and `β` are infinite types, then the cardinality of `α × β` is the maximum
of the cardinalities of `α` and `β`. -/
theorem mul_eq_max {a b : Cardinal} (ha : ℵ₀ ≤ a) (hb : ℵ₀ ≤ b) : a * b = max a b :=
le_antisymm
(mul_eq_self (ha.trans (le_max_left a b)) ▸
mul_le_mul' (le_max_left _ _) (le_max_right _ _)) <|
max_le (by simpa only [mul_one] using mul_le_mul_left' (one_le_aleph0.trans hb) a)
(by simpa only [one_mul] using mul_le_mul_right' (one_le_aleph0.trans ha) b)
#align cardinal.mul_eq_max Cardinal.mul_eq_max
@[simp]
theorem mul_mk_eq_max {α β : Type u} [Infinite α] [Infinite β] : #α * #β = max #α #β :=
mul_eq_max (aleph0_le_mk α) (aleph0_le_mk β)
#align cardinal.mul_mk_eq_max Cardinal.mul_mk_eq_max
@[simp]
theorem aleph_mul_aleph (o₁ o₂ : Ordinal) : aleph o₁ * aleph o₂ = aleph (max o₁ o₂) := by
rw [Cardinal.mul_eq_max (aleph0_le_aleph o₁) (aleph0_le_aleph o₂), max_aleph_eq]
#align cardinal.aleph_mul_aleph Cardinal.aleph_mul_aleph
@[simp]
theorem aleph0_mul_eq {a : Cardinal} (ha : ℵ₀ ≤ a) : ℵ₀ * a = a :=
(mul_eq_max le_rfl ha).trans (max_eq_right ha)
#align cardinal.aleph_0_mul_eq Cardinal.aleph0_mul_eq
@[simp]
theorem mul_aleph0_eq {a : Cardinal} (ha : ℵ₀ ≤ a) : a * ℵ₀ = a :=
(mul_eq_max ha le_rfl).trans (max_eq_left ha)
#align cardinal.mul_aleph_0_eq Cardinal.mul_aleph0_eq
-- Porting note (#10618): removed `simp`, `simp` can prove it
theorem aleph0_mul_mk_eq {α : Type*} [Infinite α] : ℵ₀ * #α = #α :=
aleph0_mul_eq (aleph0_le_mk α)
#align cardinal.aleph_0_mul_mk_eq Cardinal.aleph0_mul_mk_eq
-- Porting note (#10618): removed `simp`, `simp` can prove it
theorem mk_mul_aleph0_eq {α : Type*} [Infinite α] : #α * ℵ₀ = #α :=
mul_aleph0_eq (aleph0_le_mk α)
#align cardinal.mk_mul_aleph_0_eq Cardinal.mk_mul_aleph0_eq
@[simp]
theorem aleph0_mul_aleph (o : Ordinal) : ℵ₀ * aleph o = aleph o :=
aleph0_mul_eq (aleph0_le_aleph o)
#align cardinal.aleph_0_mul_aleph Cardinal.aleph0_mul_aleph
@[simp]
theorem aleph_mul_aleph0 (o : Ordinal) : aleph o * ℵ₀ = aleph o :=
mul_aleph0_eq (aleph0_le_aleph o)
#align cardinal.aleph_mul_aleph_0 Cardinal.aleph_mul_aleph0
theorem mul_lt_of_lt {a b c : Cardinal} (hc : ℵ₀ ≤ c) (h1 : a < c) (h2 : b < c) : a * b < c :=
(mul_le_mul' (le_max_left a b) (le_max_right a b)).trans_lt <|
(lt_or_le (max a b) ℵ₀).elim (fun h => (mul_lt_aleph0 h h).trans_le hc) fun h => by
rw [mul_eq_self h]
exact max_lt h1 h2
#align cardinal.mul_lt_of_lt Cardinal.mul_lt_of_lt
theorem mul_le_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) : a * b ≤ max a b := by
convert mul_le_mul' (le_max_left a b) (le_max_right a b) using 1
rw [mul_eq_self]
exact h.trans (le_max_left a b)
#align cardinal.mul_le_max_of_aleph_0_le_left Cardinal.mul_le_max_of_aleph0_le_left
theorem mul_eq_max_of_aleph0_le_left {a b : Cardinal} (h : ℵ₀ ≤ a) (h' : b ≠ 0) :
a * b = max a b := by
rcases le_or_lt ℵ₀ b with hb | hb
· exact mul_eq_max h hb
refine (mul_le_max_of_aleph0_le_left h).antisymm ?_
have : b ≤ a := hb.le.trans h
rw [max_eq_left this]
convert mul_le_mul_left' (one_le_iff_ne_zero.mpr h') a
rw [mul_one]
#align cardinal.mul_eq_max_of_aleph_0_le_left Cardinal.mul_eq_max_of_aleph0_le_left
theorem mul_le_max_of_aleph0_le_right {a b : Cardinal} (h : ℵ₀ ≤ b) : a * b ≤ max a b := by
simpa only [mul_comm b, max_comm b] using mul_le_max_of_aleph0_le_left h
#align cardinal.mul_le_max_of_aleph_0_le_right Cardinal.mul_le_max_of_aleph0_le_right
theorem mul_eq_max_of_aleph0_le_right {a b : Cardinal} (h' : a ≠ 0) (h : ℵ₀ ≤ b) :
a * b = max a b := by
rw [mul_comm, max_comm]
exact mul_eq_max_of_aleph0_le_left h h'
#align cardinal.mul_eq_max_of_aleph_0_le_right Cardinal.mul_eq_max_of_aleph0_le_right
| Mathlib/SetTheory/Cardinal/Ordinal.lean | 637 | 640 | theorem mul_eq_max' {a b : Cardinal} (h : ℵ₀ ≤ a * b) : a * b = max a b := by |
rcases aleph0_le_mul_iff.mp h with ⟨ha, hb, ha' | hb'⟩
· exact mul_eq_max_of_aleph0_le_left ha' hb
· exact mul_eq_max_of_aleph0_le_right ha hb'
|
/-
Copyright (c) 2022 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Data.Int.Range
import Mathlib.Data.ZMod.Basic
import Mathlib.NumberTheory.MulChar.Basic
#align_import number_theory.legendre_symbol.zmod_char from "leanprover-community/mathlib"@"70fd9563a21e7b963887c9360bd29b2393e6225a"
/-!
# Quadratic characters on ℤ/nℤ
This file defines some quadratic characters on the rings ℤ/4ℤ and ℤ/8ℤ.
We set them up to be of type `MulChar (ZMod n) ℤ`, where `n` is `4` or `8`.
## Tags
quadratic character, zmod
-/
/-!
### Quadratic characters mod 4 and 8
We define the primitive quadratic characters `χ₄`on `ZMod 4`
and `χ₈`, `χ₈'` on `ZMod 8`.
-/
namespace ZMod
section QuadCharModP
/-- Define the nontrivial quadratic character on `ZMod 4`, `χ₄`.
It corresponds to the extension `ℚ(√-1)/ℚ`. -/
@[simps]
def χ₄ : MulChar (ZMod 4) ℤ where
toFun := (![0, 1, 0, -1] : ZMod 4 → ℤ)
map_one' := rfl
map_mul' := by decide
map_nonunit' := by decide
#align zmod.χ₄ ZMod.χ₄
/-- `χ₄` takes values in `{0, 1, -1}` -/
theorem isQuadratic_χ₄ : χ₄.IsQuadratic := by
intro a
-- Porting note (#11043): was `decide!`
fin_cases a
all_goals decide
#align zmod.is_quadratic_χ₄ ZMod.isQuadratic_χ₄
/-- The value of `χ₄ n`, for `n : ℕ`, depends only on `n % 4`. -/
theorem χ₄_nat_mod_four (n : ℕ) : χ₄ n = χ₄ (n % 4 : ℕ) := by rw [← ZMod.natCast_mod n 4]
#align zmod.χ₄_nat_mod_four ZMod.χ₄_nat_mod_four
/-- The value of `χ₄ n`, for `n : ℤ`, depends only on `n % 4`. -/
theorem χ₄_int_mod_four (n : ℤ) : χ₄ n = χ₄ (n % 4 : ℤ) := by
rw [← ZMod.intCast_mod n 4]
norm_cast
#align zmod.χ₄_int_mod_four ZMod.χ₄_int_mod_four
/-- An explicit description of `χ₄` on integers / naturals -/
theorem χ₄_int_eq_if_mod_four (n : ℤ) :
χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 := by
have help : ∀ m : ℤ, 0 ≤ m → m < 4 → χ₄ m = if m % 2 = 0 then 0 else if m = 1 then 1 else -1 := by
decide
rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 4), ← ZMod.intCast_mod n 4]
exact help (n % 4) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num))
#align zmod.χ₄_int_eq_if_mod_four ZMod.χ₄_int_eq_if_mod_four
theorem χ₄_nat_eq_if_mod_four (n : ℕ) :
χ₄ n = if n % 2 = 0 then 0 else if n % 4 = 1 then 1 else -1 :=
mod_cast χ₄_int_eq_if_mod_four n
#align zmod.χ₄_nat_eq_if_mod_four ZMod.χ₄_nat_eq_if_mod_four
/-- Alternative description of `χ₄ n` for odd `n : ℕ` in terms of powers of `-1` -/
theorem χ₄_eq_neg_one_pow {n : ℕ} (hn : n % 2 = 1) : χ₄ n = (-1) ^ (n / 2) := by
rw [χ₄_nat_eq_if_mod_four]
simp only [hn, Nat.one_ne_zero, if_false]
conv_rhs => -- Porting note: was `nth_rw`
arg 2; rw [← Nat.div_add_mod n 4]
enter [1, 1, 1]; rw [(by norm_num : 4 = 2 * 2)]
rw [mul_assoc, add_comm, Nat.add_mul_div_left _ _ (by norm_num : 0 < 2), pow_add, pow_mul,
neg_one_sq, one_pow, mul_one]
have help : ∀ m : ℕ, m < 4 → m % 2 = 1 → ite (m = 1) (1 : ℤ) (-1) = (-1) ^ (m / 2) := by decide
exact
help (n % 4) (Nat.mod_lt n (by norm_num))
((Nat.mod_mod_of_dvd n (by decide : 2 ∣ 4)).trans hn)
#align zmod.χ₄_eq_neg_one_pow ZMod.χ₄_eq_neg_one_pow
/-- If `n % 4 = 1`, then `χ₄ n = 1`. -/
theorem χ₄_nat_one_mod_four {n : ℕ} (hn : n % 4 = 1) : χ₄ n = 1 := by
rw [χ₄_nat_mod_four, hn]
rfl
#align zmod.χ₄_nat_one_mod_four ZMod.χ₄_nat_one_mod_four
/-- If `n % 4 = 3`, then `χ₄ n = -1`. -/
theorem χ₄_nat_three_mod_four {n : ℕ} (hn : n % 4 = 3) : χ₄ n = -1 := by
rw [χ₄_nat_mod_four, hn]
rfl
#align zmod.χ₄_nat_three_mod_four ZMod.χ₄_nat_three_mod_four
/-- If `n % 4 = 1`, then `χ₄ n = 1`. -/
theorem χ₄_int_one_mod_four {n : ℤ} (hn : n % 4 = 1) : χ₄ n = 1 := by
rw [χ₄_int_mod_four, hn]
rfl
#align zmod.χ₄_int_one_mod_four ZMod.χ₄_int_one_mod_four
/-- If `n % 4 = 3`, then `χ₄ n = -1`. -/
theorem χ₄_int_three_mod_four {n : ℤ} (hn : n % 4 = 3) : χ₄ n = -1 := by
rw [χ₄_int_mod_four, hn]
rfl
#align zmod.χ₄_int_three_mod_four ZMod.χ₄_int_three_mod_four
/-- If `n % 4 = 1`, then `(-1)^(n/2) = 1`. -/
theorem neg_one_pow_div_two_of_one_mod_four {n : ℕ} (hn : n % 4 = 1) : (-1 : ℤ) ^ (n / 2) = 1 := by
rw [← χ₄_eq_neg_one_pow (Nat.odd_of_mod_four_eq_one hn), ← natCast_mod, hn]
rfl
#align zmod.neg_one_pow_div_two_of_one_mod_four ZMod.neg_one_pow_div_two_of_one_mod_four
/-- If `n % 4 = 3`, then `(-1)^(n/2) = -1`. -/
theorem neg_one_pow_div_two_of_three_mod_four {n : ℕ} (hn : n % 4 = 3) :
(-1 : ℤ) ^ (n / 2) = -1 := by
rw [← χ₄_eq_neg_one_pow (Nat.odd_of_mod_four_eq_three hn), ← natCast_mod, hn]
rfl
#align zmod.neg_one_pow_div_two_of_three_mod_four ZMod.neg_one_pow_div_two_of_three_mod_four
/-- Define the first primitive quadratic character on `ZMod 8`, `χ₈`.
It corresponds to the extension `ℚ(√2)/ℚ`. -/
@[simps]
def χ₈ : MulChar (ZMod 8) ℤ where
toFun := (![0, 1, 0, -1, 0, -1, 0, 1] : ZMod 8 → ℤ)
map_one' := rfl
map_mul' := by decide
map_nonunit' := by decide
#align zmod.χ₈ ZMod.χ₈
/-- `χ₈` takes values in `{0, 1, -1}` -/
theorem isQuadratic_χ₈ : χ₈.IsQuadratic := by
intro a
-- Porting note: was `decide!`
fin_cases a
all_goals decide
#align zmod.is_quadratic_χ₈ ZMod.isQuadratic_χ₈
/-- The value of `χ₈ n`, for `n : ℕ`, depends only on `n % 8`. -/
theorem χ₈_nat_mod_eight (n : ℕ) : χ₈ n = χ₈ (n % 8 : ℕ) := by rw [← ZMod.natCast_mod n 8]
#align zmod.χ₈_nat_mod_eight ZMod.χ₈_nat_mod_eight
/-- The value of `χ₈ n`, for `n : ℤ`, depends only on `n % 8`. -/
theorem χ₈_int_mod_eight (n : ℤ) : χ₈ n = χ₈ (n % 8 : ℤ) := by
rw [← ZMod.intCast_mod n 8]
norm_cast
#align zmod.χ₈_int_mod_eight ZMod.χ₈_int_mod_eight
/-- An explicit description of `χ₈` on integers / naturals -/
theorem χ₈_int_eq_if_mod_eight (n : ℤ) :
χ₈ n = if n % 2 = 0 then 0 else if n % 8 = 1 ∨ n % 8 = 7 then 1 else -1 := by
have help :
∀ m : ℤ, 0 ≤ m → m < 8 → χ₈ m = if m % 2 = 0 then 0 else if m = 1 ∨ m = 7 then 1 else -1 := by
decide
rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 8), ← ZMod.intCast_mod n 8]
exact help (n % 8) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num))
#align zmod.χ₈_int_eq_if_mod_eight ZMod.χ₈_int_eq_if_mod_eight
theorem χ₈_nat_eq_if_mod_eight (n : ℕ) :
χ₈ n = if n % 2 = 0 then 0 else if n % 8 = 1 ∨ n % 8 = 7 then 1 else -1 :=
mod_cast χ₈_int_eq_if_mod_eight n
#align zmod.χ₈_nat_eq_if_mod_eight ZMod.χ₈_nat_eq_if_mod_eight
/-- Define the second primitive quadratic character on `ZMod 8`, `χ₈'`.
It corresponds to the extension `ℚ(√-2)/ℚ`. -/
@[simps]
def χ₈' : MulChar (ZMod 8) ℤ where
toFun := (![0, 1, 0, 1, 0, -1, 0, -1] : ZMod 8 → ℤ)
map_one' := rfl
map_mul' := by decide
map_nonunit' := by decide
#align zmod.χ₈' ZMod.χ₈'
/-- `χ₈'` takes values in `{0, 1, -1}` -/
theorem isQuadratic_χ₈' : χ₈'.IsQuadratic := by
intro a
-- Porting note: was `decide!`
fin_cases a
all_goals decide
#align zmod.is_quadratic_χ₈' ZMod.isQuadratic_χ₈'
/-- An explicit description of `χ₈'` on integers / naturals -/
theorem χ₈'_int_eq_if_mod_eight (n : ℤ) :
χ₈' n = if n % 2 = 0 then 0 else if n % 8 = 1 ∨ n % 8 = 3 then 1 else -1 := by
have help :
∀ m : ℤ, 0 ≤ m → m < 8 → χ₈' m = if m % 2 = 0 then 0 else if m = 1 ∨ m = 3 then 1 else -1 := by
decide
rw [← Int.emod_emod_of_dvd n (by decide : (2 : ℤ) ∣ 8), ← ZMod.intCast_mod n 8]
exact help (n % 8) (Int.emod_nonneg n (by norm_num)) (Int.emod_lt n (by norm_num))
#align zmod.χ₈'_int_eq_if_mod_eight ZMod.χ₈'_int_eq_if_mod_eight
theorem χ₈'_nat_eq_if_mod_eight (n : ℕ) :
χ₈' n = if n % 2 = 0 then 0 else if n % 8 = 1 ∨ n % 8 = 3 then 1 else -1 :=
mod_cast χ₈'_int_eq_if_mod_eight n
#align zmod.χ₈'_nat_eq_if_mod_eight ZMod.χ₈'_nat_eq_if_mod_eight
/-- The relation between `χ₄`, `χ₈` and `χ₈'` -/
| Mathlib/NumberTheory/LegendreSymbol/ZModChar.lean | 208 | 211 | theorem χ₈'_eq_χ₄_mul_χ₈ (a : ZMod 8) : χ₈' a = χ₄ (cast a) * χ₈ a := by |
-- Porting note: was `decide!`
fin_cases a
all_goals decide
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Julian Kuelshammer
-/
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.GroupPower.IterateHom
import Mathlib.Algebra.GroupWithZero.Divisibility
import Mathlib.Data.Int.ModEq
import Mathlib.Data.Set.Pointwise.Basic
import Mathlib.Dynamics.PeriodicPts
import Mathlib.GroupTheory.Index
import Mathlib.Order.Interval.Finset.Nat
import Mathlib.Order.Interval.Set.Infinite
#align_import group_theory.order_of_element from "leanprover-community/mathlib"@"d07245fd37786daa997af4f1a73a49fa3b748408"
/-!
# Order of an element
This file defines the order of an element of a finite group. For a finite group `G` the order of
`x ∈ G` is the minimal `n ≥ 1` such that `x ^ n = 1`.
## Main definitions
* `IsOfFinOrder` is a predicate on an element `x` of a monoid `G` saying that `x` is of finite
order.
* `IsOfFinAddOrder` is the additive analogue of `IsOfFinOrder`.
* `orderOf x` defines the order of an element `x` of a monoid `G`, by convention its value is `0`
if `x` has infinite order.
* `addOrderOf` is the additive analogue of `orderOf`.
## Tags
order of an element
-/
open Function Fintype Nat Pointwise Subgroup Submonoid
variable {G H A α β : Type*}
section Monoid
variable [Monoid G] {a b x y : G} {n m : ℕ}
section IsOfFinOrder
-- Porting note(#12129): additional beta reduction needed
@[to_additive]
theorem isPeriodicPt_mul_iff_pow_eq_one (x : G) : IsPeriodicPt (x * ·) n 1 ↔ x ^ n = 1 := by
rw [IsPeriodicPt, IsFixedPt, mul_left_iterate]; beta_reduce; rw [mul_one]
#align is_periodic_pt_mul_iff_pow_eq_one isPeriodicPt_mul_iff_pow_eq_one
#align is_periodic_pt_add_iff_nsmul_eq_zero isPeriodicPt_add_iff_nsmul_eq_zero
/-- `IsOfFinOrder` is a predicate on an element `x` of a monoid to be of finite order, i.e. there
exists `n ≥ 1` such that `x ^ n = 1`. -/
@[to_additive "`IsOfFinAddOrder` is a predicate on an element `a` of an
additive monoid to be of finite order, i.e. there exists `n ≥ 1` such that `n • a = 0`."]
def IsOfFinOrder (x : G) : Prop :=
(1 : G) ∈ periodicPts (x * ·)
#align is_of_fin_order IsOfFinOrder
#align is_of_fin_add_order IsOfFinAddOrder
theorem isOfFinAddOrder_ofMul_iff : IsOfFinAddOrder (Additive.ofMul x) ↔ IsOfFinOrder x :=
Iff.rfl
#align is_of_fin_add_order_of_mul_iff isOfFinAddOrder_ofMul_iff
theorem isOfFinOrder_ofAdd_iff {α : Type*} [AddMonoid α] {x : α} :
IsOfFinOrder (Multiplicative.ofAdd x) ↔ IsOfFinAddOrder x := Iff.rfl
#align is_of_fin_order_of_add_iff isOfFinOrder_ofAdd_iff
@[to_additive]
theorem isOfFinOrder_iff_pow_eq_one : IsOfFinOrder x ↔ ∃ n, 0 < n ∧ x ^ n = 1 := by
simp [IsOfFinOrder, mem_periodicPts, isPeriodicPt_mul_iff_pow_eq_one]
#align is_of_fin_order_iff_pow_eq_one isOfFinOrder_iff_pow_eq_one
#align is_of_fin_add_order_iff_nsmul_eq_zero isOfFinAddOrder_iff_nsmul_eq_zero
@[to_additive] alias ⟨IsOfFinOrder.exists_pow_eq_one, _⟩ := isOfFinOrder_iff_pow_eq_one
@[to_additive]
lemma isOfFinOrder_iff_zpow_eq_one {G} [Group G] {x : G} :
IsOfFinOrder x ↔ ∃ (n : ℤ), n ≠ 0 ∧ x ^ n = 1 := by
rw [isOfFinOrder_iff_pow_eq_one]
refine ⟨fun ⟨n, hn, hn'⟩ ↦ ⟨n, Int.natCast_ne_zero_iff_pos.mpr hn, zpow_natCast x n ▸ hn'⟩,
fun ⟨n, hn, hn'⟩ ↦ ⟨n.natAbs, Int.natAbs_pos.mpr hn, ?_⟩⟩
cases' (Int.natAbs_eq_iff (a := n)).mp rfl with h h
· rwa [h, zpow_natCast] at hn'
· rwa [h, zpow_neg, inv_eq_one, zpow_natCast] at hn'
/-- See also `injective_pow_iff_not_isOfFinOrder`. -/
@[to_additive "See also `injective_nsmul_iff_not_isOfFinAddOrder`."]
theorem not_isOfFinOrder_of_injective_pow {x : G} (h : Injective fun n : ℕ => x ^ n) :
¬IsOfFinOrder x := by
simp_rw [isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
intro n hn_pos hnx
rw [← pow_zero x] at hnx
rw [h hnx] at hn_pos
exact irrefl 0 hn_pos
#align not_is_of_fin_order_of_injective_pow not_isOfFinOrder_of_injective_pow
#align not_is_of_fin_add_order_of_injective_nsmul not_isOfFinAddOrder_of_injective_nsmul
lemma IsOfFinOrder.pow {n : ℕ} : IsOfFinOrder a → IsOfFinOrder (a ^ n) := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨m, hm, ha⟩
exact ⟨m, hm, by simp [pow_right_comm _ n, ha]⟩
/-- Elements of finite order are of finite order in submonoids. -/
@[to_additive "Elements of finite order are of finite order in submonoids."]
theorem Submonoid.isOfFinOrder_coe {H : Submonoid G} {x : H} :
IsOfFinOrder (x : G) ↔ IsOfFinOrder x := by
rw [isOfFinOrder_iff_pow_eq_one, isOfFinOrder_iff_pow_eq_one]
norm_cast
#align is_of_fin_order_iff_coe Submonoid.isOfFinOrder_coe
#align is_of_fin_add_order_iff_coe AddSubmonoid.isOfFinAddOrder_coe
/-- The image of an element of finite order has finite order. -/
@[to_additive "The image of an element of finite additive order has finite additive order."]
theorem MonoidHom.isOfFinOrder [Monoid H] (f : G →* H) {x : G} (h : IsOfFinOrder x) :
IsOfFinOrder <| f x :=
isOfFinOrder_iff_pow_eq_one.mpr <| by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact ⟨n, npos, by rw [← f.map_pow, hn, f.map_one]⟩
#align monoid_hom.is_of_fin_order MonoidHom.isOfFinOrder
#align add_monoid_hom.is_of_fin_order AddMonoidHom.isOfFinAddOrder
/-- If a direct product has finite order then so does each component. -/
@[to_additive "If a direct product has finite additive order then so does each component."]
theorem IsOfFinOrder.apply {η : Type*} {Gs : η → Type*} [∀ i, Monoid (Gs i)] {x : ∀ i, Gs i}
(h : IsOfFinOrder x) : ∀ i, IsOfFinOrder (x i) := by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact fun _ => isOfFinOrder_iff_pow_eq_one.mpr ⟨n, npos, (congr_fun hn.symm _).symm⟩
#align is_of_fin_order.apply IsOfFinOrder.apply
#align is_of_fin_add_order.apply IsOfFinAddOrder.apply
/-- 1 is of finite order in any monoid. -/
@[to_additive "0 is of finite order in any additive monoid."]
theorem isOfFinOrder_one : IsOfFinOrder (1 : G) :=
isOfFinOrder_iff_pow_eq_one.mpr ⟨1, Nat.one_pos, one_pow 1⟩
#align is_of_fin_order_one isOfFinOrder_one
#align is_of_fin_order_zero isOfFinAddOrder_zero
/-- The submonoid generated by an element is a group if that element has finite order. -/
@[to_additive "The additive submonoid generated by an element is
an additive group if that element has finite order."]
noncomputable abbrev IsOfFinOrder.groupPowers (hx : IsOfFinOrder x) :
Group (Submonoid.powers x) := by
obtain ⟨hpos, hx⟩ := hx.exists_pow_eq_one.choose_spec
exact Submonoid.groupPowers hpos hx
end IsOfFinOrder
/-- `orderOf x` is the order of the element `x`, i.e. the `n ≥ 1`, s.t. `x ^ n = 1` if it exists.
Otherwise, i.e. if `x` is of infinite order, then `orderOf x` is `0` by convention. -/
@[to_additive
"`addOrderOf a` is the order of the element `a`, i.e. the `n ≥ 1`, s.t. `n • a = 0` if it
exists. Otherwise, i.e. if `a` is of infinite order, then `addOrderOf a` is `0` by convention."]
noncomputable def orderOf (x : G) : ℕ :=
minimalPeriod (x * ·) 1
#align order_of orderOf
#align add_order_of addOrderOf
@[simp]
theorem addOrderOf_ofMul_eq_orderOf (x : G) : addOrderOf (Additive.ofMul x) = orderOf x :=
rfl
#align add_order_of_of_mul_eq_order_of addOrderOf_ofMul_eq_orderOf
@[simp]
lemma orderOf_ofAdd_eq_addOrderOf {α : Type*} [AddMonoid α] (a : α) :
orderOf (Multiplicative.ofAdd a) = addOrderOf a := rfl
#align order_of_of_add_eq_add_order_of orderOf_ofAdd_eq_addOrderOf
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x :=
minimalPeriod_pos_of_mem_periodicPts h
#align order_of_pos' IsOfFinOrder.orderOf_pos
#align add_order_of_pos' IsOfFinAddOrder.addOrderOf_pos
@[to_additive addOrderOf_nsmul_eq_zero]
theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by
convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1)
-- Porting note(#12129): additional beta reduction needed in the middle of the rewrite
rw [orderOf, mul_left_iterate]; beta_reduce; rw [mul_one]
#align pow_order_of_eq_one pow_orderOf_eq_one
#align add_order_of_nsmul_eq_zero addOrderOf_nsmul_eq_zero
@[to_additive]
theorem orderOf_eq_zero (h : ¬IsOfFinOrder x) : orderOf x = 0 := by
rwa [orderOf, minimalPeriod, dif_neg]
#align order_of_eq_zero orderOf_eq_zero
#align add_order_of_eq_zero addOrderOf_eq_zero
@[to_additive]
theorem orderOf_eq_zero_iff : orderOf x = 0 ↔ ¬IsOfFinOrder x :=
⟨fun h H ↦ H.orderOf_pos.ne' h, orderOf_eq_zero⟩
#align order_of_eq_zero_iff orderOf_eq_zero_iff
#align add_order_of_eq_zero_iff addOrderOf_eq_zero_iff
@[to_additive]
theorem orderOf_eq_zero_iff' : orderOf x = 0 ↔ ∀ n : ℕ, 0 < n → x ^ n ≠ 1 := by
simp_rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
#align order_of_eq_zero_iff' orderOf_eq_zero_iff'
#align add_order_of_eq_zero_iff' addOrderOf_eq_zero_iff'
@[to_additive]
theorem orderOf_eq_iff {n} (h : 0 < n) :
orderOf x = n ↔ x ^ n = 1 ∧ ∀ m, m < n → 0 < m → x ^ m ≠ 1 := by
simp_rw [Ne, ← isPeriodicPt_mul_iff_pow_eq_one, orderOf, minimalPeriod]
split_ifs with h1
· classical
rw [find_eq_iff]
simp only [h, true_and]
push_neg
rfl
· rw [iff_false_left h.ne]
rintro ⟨h', -⟩
exact h1 ⟨n, h, h'⟩
#align order_of_eq_iff orderOf_eq_iff
#align add_order_of_eq_iff addOrderOf_eq_iff
/-- A group element has finite order iff its order is positive. -/
@[to_additive
"A group element has finite additive order iff its order is positive."]
theorem orderOf_pos_iff : 0 < orderOf x ↔ IsOfFinOrder x := by
rw [iff_not_comm.mp orderOf_eq_zero_iff, pos_iff_ne_zero]
#align order_of_pos_iff orderOf_pos_iff
#align add_order_of_pos_iff addOrderOf_pos_iff
@[to_additive]
theorem IsOfFinOrder.mono [Monoid β] {y : β} (hx : IsOfFinOrder x) (h : orderOf y ∣ orderOf x) :
IsOfFinOrder y := by rw [← orderOf_pos_iff] at hx ⊢; exact Nat.pos_of_dvd_of_pos h hx
#align is_of_fin_order.mono IsOfFinOrder.mono
#align is_of_fin_add_order.mono IsOfFinAddOrder.mono
@[to_additive]
theorem pow_ne_one_of_lt_orderOf' (n0 : n ≠ 0) (h : n < orderOf x) : x ^ n ≠ 1 := fun j =>
not_isPeriodicPt_of_pos_of_lt_minimalPeriod n0 h ((isPeriodicPt_mul_iff_pow_eq_one x).mpr j)
#align pow_ne_one_of_lt_order_of' pow_ne_one_of_lt_orderOf'
#align nsmul_ne_zero_of_lt_add_order_of' nsmul_ne_zero_of_lt_addOrderOf'
@[to_additive]
theorem orderOf_le_of_pow_eq_one (hn : 0 < n) (h : x ^ n = 1) : orderOf x ≤ n :=
IsPeriodicPt.minimalPeriod_le hn (by rwa [isPeriodicPt_mul_iff_pow_eq_one])
#align order_of_le_of_pow_eq_one orderOf_le_of_pow_eq_one
#align add_order_of_le_of_nsmul_eq_zero addOrderOf_le_of_nsmul_eq_zero
@[to_additive (attr := simp)]
theorem orderOf_one : orderOf (1 : G) = 1 := by
rw [orderOf, ← minimalPeriod_id (x := (1:G)), ← one_mul_eq_id]
#align order_of_one orderOf_one
#align order_of_zero addOrderOf_zero
@[to_additive (attr := simp) AddMonoid.addOrderOf_eq_one_iff]
theorem orderOf_eq_one_iff : orderOf x = 1 ↔ x = 1 := by
rw [orderOf, minimalPeriod_eq_one_iff_isFixedPt, IsFixedPt, mul_one]
#align order_of_eq_one_iff orderOf_eq_one_iff
#align add_monoid.order_of_eq_one_iff AddMonoid.addOrderOf_eq_one_iff
@[to_additive (attr := simp) mod_addOrderOf_nsmul]
lemma pow_mod_orderOf (x : G) (n : ℕ) : x ^ (n % orderOf x) = x ^ n :=
calc
x ^ (n % orderOf x) = x ^ (n % orderOf x + orderOf x * (n / orderOf x)) := by
simp [pow_add, pow_mul, pow_orderOf_eq_one]
_ = x ^ n := by rw [Nat.mod_add_div]
#align pow_eq_mod_order_of pow_mod_orderOf
#align nsmul_eq_mod_add_order_of mod_addOrderOf_nsmul
@[to_additive]
theorem orderOf_dvd_of_pow_eq_one (h : x ^ n = 1) : orderOf x ∣ n :=
IsPeriodicPt.minimalPeriod_dvd ((isPeriodicPt_mul_iff_pow_eq_one _).mpr h)
#align order_of_dvd_of_pow_eq_one orderOf_dvd_of_pow_eq_one
#align add_order_of_dvd_of_nsmul_eq_zero addOrderOf_dvd_of_nsmul_eq_zero
@[to_additive]
theorem orderOf_dvd_iff_pow_eq_one {n : ℕ} : orderOf x ∣ n ↔ x ^ n = 1 :=
⟨fun h => by rw [← pow_mod_orderOf, Nat.mod_eq_zero_of_dvd h, _root_.pow_zero],
orderOf_dvd_of_pow_eq_one⟩
#align order_of_dvd_iff_pow_eq_one orderOf_dvd_iff_pow_eq_one
#align add_order_of_dvd_iff_nsmul_eq_zero addOrderOf_dvd_iff_nsmul_eq_zero
@[to_additive addOrderOf_smul_dvd]
theorem orderOf_pow_dvd (n : ℕ) : orderOf (x ^ n) ∣ orderOf x := by
rw [orderOf_dvd_iff_pow_eq_one, pow_right_comm, pow_orderOf_eq_one, one_pow]
#align order_of_pow_dvd orderOf_pow_dvd
#align add_order_of_smul_dvd addOrderOf_smul_dvd
@[to_additive]
lemma pow_injOn_Iio_orderOf : (Set.Iio <| orderOf x).InjOn (x ^ ·) := by
simpa only [mul_left_iterate, mul_one]
using iterate_injOn_Iio_minimalPeriod (f := (x * ·)) (x := 1)
#align pow_injective_of_lt_order_of pow_injOn_Iio_orderOf
#align nsmul_injective_of_lt_add_order_of nsmul_injOn_Iio_addOrderOf
@[to_additive]
protected lemma IsOfFinOrder.mem_powers_iff_mem_range_orderOf [DecidableEq G]
(hx : IsOfFinOrder x) :
y ∈ Submonoid.powers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
Finset.mem_range_iff_mem_finset_range_of_mod_eq' hx.orderOf_pos <| pow_mod_orderOf _
#align mem_powers_iff_mem_range_order_of' IsOfFinOrder.mem_powers_iff_mem_range_orderOf
#align mem_multiples_iff_mem_range_add_order_of' IsOfFinAddOrder.mem_multiples_iff_mem_range_addOrderOf
@[to_additive]
protected lemma IsOfFinOrder.powers_eq_image_range_orderOf [DecidableEq G] (hx : IsOfFinOrder x) :
(Submonoid.powers x : Set G) = (Finset.range (orderOf x)).image (x ^ ·) :=
Set.ext fun _ ↦ hx.mem_powers_iff_mem_range_orderOf
@[deprecated (since := "2024-02-21")]
alias IsOfFinAddOrder.powers_eq_image_range_orderOf :=
IsOfFinAddOrder.multiples_eq_image_range_addOrderOf
@[to_additive]
theorem pow_eq_one_iff_modEq : x ^ n = 1 ↔ n ≡ 0 [MOD orderOf x] := by
rw [modEq_zero_iff_dvd, orderOf_dvd_iff_pow_eq_one]
#align pow_eq_one_iff_modeq pow_eq_one_iff_modEq
#align nsmul_eq_zero_iff_modeq nsmul_eq_zero_iff_modEq
@[to_additive]
theorem orderOf_map_dvd {H : Type*} [Monoid H] (ψ : G →* H) (x : G) :
orderOf (ψ x) ∣ orderOf x := by
apply orderOf_dvd_of_pow_eq_one
rw [← map_pow, pow_orderOf_eq_one]
apply map_one
#align order_of_map_dvd orderOf_map_dvd
#align add_order_of_map_dvd addOrderOf_map_dvd
@[to_additive]
theorem exists_pow_eq_self_of_coprime (h : n.Coprime (orderOf x)) : ∃ m : ℕ, (x ^ n) ^ m = x := by
by_cases h0 : orderOf x = 0
· rw [h0, coprime_zero_right] at h
exact ⟨1, by rw [h, pow_one, pow_one]⟩
by_cases h1 : orderOf x = 1
· exact ⟨0, by rw [orderOf_eq_one_iff.mp h1, one_pow, one_pow]⟩
obtain ⟨m, h⟩ := exists_mul_emod_eq_one_of_coprime h (one_lt_iff_ne_zero_and_ne_one.mpr ⟨h0, h1⟩)
exact ⟨m, by rw [← pow_mul, ← pow_mod_orderOf, h, pow_one]⟩
#align exists_pow_eq_self_of_coprime exists_pow_eq_self_of_coprime
#align exists_nsmul_eq_self_of_coprime exists_nsmul_eq_self_of_coprime
/-- If `x^n = 1`, but `x^(n/p) ≠ 1` for all prime factors `p` of `n`,
then `x` has order `n` in `G`. -/
@[to_additive addOrderOf_eq_of_nsmul_and_div_prime_nsmul "If `n * x = 0`, but `n/p * x ≠ 0` for
all prime factors `p` of `n`, then `x` has order `n` in `G`."]
theorem orderOf_eq_of_pow_and_pow_div_prime (hn : 0 < n) (hx : x ^ n = 1)
(hd : ∀ p : ℕ, p.Prime → p ∣ n → x ^ (n / p) ≠ 1) : orderOf x = n := by
-- Let `a` be `n/(orderOf x)`, and show `a = 1`
cases' exists_eq_mul_right_of_dvd (orderOf_dvd_of_pow_eq_one hx) with a ha
suffices a = 1 by simp [this, ha]
-- Assume `a` is not one...
by_contra h
have a_min_fac_dvd_p_sub_one : a.minFac ∣ n := by
obtain ⟨b, hb⟩ : ∃ b : ℕ, a = b * a.minFac := exists_eq_mul_left_of_dvd a.minFac_dvd
rw [hb, ← mul_assoc] at ha
exact Dvd.intro_left (orderOf x * b) ha.symm
-- Use the minimum prime factor of `a` as `p`.
refine hd a.minFac (Nat.minFac_prime h) a_min_fac_dvd_p_sub_one ?_
rw [← orderOf_dvd_iff_pow_eq_one, Nat.dvd_div_iff a_min_fac_dvd_p_sub_one, ha, mul_comm,
Nat.mul_dvd_mul_iff_left (IsOfFinOrder.orderOf_pos _)]
· exact Nat.minFac_dvd a
· rw [isOfFinOrder_iff_pow_eq_one]
exact Exists.intro n (id ⟨hn, hx⟩)
#align order_of_eq_of_pow_and_pow_div_prime orderOf_eq_of_pow_and_pow_div_prime
#align add_order_of_eq_of_nsmul_and_div_prime_nsmul addOrderOf_eq_of_nsmul_and_div_prime_nsmul
@[to_additive]
theorem orderOf_eq_orderOf_iff {H : Type*} [Monoid H] {y : H} :
orderOf x = orderOf y ↔ ∀ n : ℕ, x ^ n = 1 ↔ y ^ n = 1 := by
simp_rw [← isPeriodicPt_mul_iff_pow_eq_one, ← minimalPeriod_eq_minimalPeriod_iff, orderOf]
#align order_of_eq_order_of_iff orderOf_eq_orderOf_iff
#align add_order_of_eq_add_order_of_iff addOrderOf_eq_addOrderOf_iff
/-- An injective homomorphism of monoids preserves orders of elements. -/
@[to_additive "An injective homomorphism of additive monoids preserves orders of elements."]
theorem orderOf_injective {H : Type*} [Monoid H] (f : G →* H) (hf : Function.Injective f) (x : G) :
orderOf (f x) = orderOf x := by
simp_rw [orderOf_eq_orderOf_iff, ← f.map_pow, ← f.map_one, hf.eq_iff, forall_const]
#align order_of_injective orderOf_injective
#align add_order_of_injective addOrderOf_injective
/-- A multiplicative equivalence preserves orders of elements. -/
@[to_additive (attr := simp) "An additive equivalence preserves orders of elements."]
lemma MulEquiv.orderOf_eq {H : Type*} [Monoid H] (e : G ≃* H) (x : G) :
orderOf (e x) = orderOf x :=
orderOf_injective e e.injective x
@[to_additive]
theorem Function.Injective.isOfFinOrder_iff [Monoid H] {f : G →* H} (hf : Injective f) :
IsOfFinOrder (f x) ↔ IsOfFinOrder x := by
rw [← orderOf_pos_iff, orderOf_injective f hf x, ← orderOf_pos_iff]
@[to_additive (attr := norm_cast, simp)]
theorem orderOf_submonoid {H : Submonoid G} (y : H) : orderOf (y : G) = orderOf y :=
orderOf_injective H.subtype Subtype.coe_injective y
#align order_of_submonoid orderOf_submonoid
#align order_of_add_submonoid addOrderOf_addSubmonoid
@[to_additive]
theorem orderOf_units {y : Gˣ} : orderOf (y : G) = orderOf y :=
orderOf_injective (Units.coeHom G) Units.ext y
#align order_of_units orderOf_units
#align order_of_add_units addOrderOf_addUnits
/-- If the order of `x` is finite, then `x` is a unit with inverse `x ^ (orderOf x - 1)`. -/
@[simps]
noncomputable
def IsOfFinOrder.unit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : Mˣ :=
⟨x, x ^ (orderOf x - 1),
by rw [← _root_.pow_succ', tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one],
by rw [← _root_.pow_succ, tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one]⟩
lemma IsOfFinOrder.isUnit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : IsUnit x := ⟨hx.unit, rfl⟩
variable (x)
@[to_additive]
theorem orderOf_pow' (h : n ≠ 0) : orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [← minimalPeriod_iterate_eq_div_gcd h, mul_left_iterate]
#align order_of_pow' orderOf_pow'
#align add_order_of_nsmul' addOrderOf_nsmul'
@[to_additive]
lemma orderOf_pow_of_dvd {x : G} {n : ℕ} (hn : n ≠ 0) (dvd : n ∣ orderOf x) :
orderOf (x ^ n) = orderOf x / n := by rw [orderOf_pow' _ hn, Nat.gcd_eq_right dvd]
@[to_additive]
lemma orderOf_pow_orderOf_div {x : G} {n : ℕ} (hx : orderOf x ≠ 0) (hn : n ∣ orderOf x) :
orderOf (x ^ (orderOf x / n)) = n := by
rw [orderOf_pow_of_dvd _ (Nat.div_dvd_of_dvd hn), Nat.div_div_self hn hx]
rw [← Nat.div_mul_cancel hn] at hx; exact left_ne_zero_of_mul hx
variable (n)
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pow (h : IsOfFinOrder x) :
orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [← minimalPeriod_iterate_eq_div_gcd' h, mul_left_iterate]
#align order_of_pow'' IsOfFinOrder.orderOf_pow
#align add_order_of_nsmul'' IsOfFinAddOrder.addOrderOf_nsmul
@[to_additive]
lemma Nat.Coprime.orderOf_pow (h : (orderOf y).Coprime m) : orderOf (y ^ m) = orderOf y := by
by_cases hg : IsOfFinOrder y
· rw [hg.orderOf_pow y m , h.gcd_eq_one, Nat.div_one]
· rw [m.coprime_zero_left.1 (orderOf_eq_zero hg ▸ h), pow_one]
#align order_of_pow_coprime Nat.Coprime.orderOf_pow
#align add_order_of_nsmul_coprime Nat.Coprime.addOrderOf_nsmul
@[to_additive]
lemma IsOfFinOrder.natCard_powers_le_orderOf (ha : IsOfFinOrder a) :
Nat.card (powers a : Set G) ≤ orderOf a := by
classical
simpa [ha.powers_eq_image_range_orderOf, Finset.card_range, Nat.Iio_eq_range]
using Finset.card_image_le (s := Finset.range (orderOf a))
@[to_additive]
lemma IsOfFinOrder.finite_powers (ha : IsOfFinOrder a) : (powers a : Set G).Finite := by
classical rw [ha.powers_eq_image_range_orderOf]; exact Finset.finite_toSet _
namespace Commute
variable {x} (h : Commute x y)
@[to_additive]
theorem orderOf_mul_dvd_lcm : orderOf (x * y) ∣ Nat.lcm (orderOf x) (orderOf y) := by
rw [orderOf, ← comp_mul_left]
exact Function.Commute.minimalPeriod_of_comp_dvd_lcm h.function_commute_mul_left
#align commute.order_of_mul_dvd_lcm Commute.orderOf_mul_dvd_lcm
#align add_commute.order_of_add_dvd_lcm AddCommute.addOrderOf_add_dvd_lcm
@[to_additive]
theorem orderOf_dvd_lcm_mul : orderOf y ∣ Nat.lcm (orderOf x) (orderOf (x * y)) := by
by_cases h0 : orderOf x = 0
· rw [h0, lcm_zero_left]
apply dvd_zero
conv_lhs =>
rw [← one_mul y, ← pow_orderOf_eq_one x, ← succ_pred_eq_of_pos (Nat.pos_of_ne_zero h0),
_root_.pow_succ, mul_assoc]
exact
(((Commute.refl x).mul_right h).pow_left _).orderOf_mul_dvd_lcm.trans
(lcm_dvd_iff.2 ⟨(orderOf_pow_dvd _).trans (dvd_lcm_left _ _), dvd_lcm_right _ _⟩)
#align commute.order_of_dvd_lcm_mul Commute.orderOf_dvd_lcm_mul
#align add_commute.order_of_dvd_lcm_add AddCommute.addOrderOf_dvd_lcm_add
@[to_additive addOrderOf_add_dvd_mul_addOrderOf]
theorem orderOf_mul_dvd_mul_orderOf : orderOf (x * y) ∣ orderOf x * orderOf y :=
dvd_trans h.orderOf_mul_dvd_lcm (lcm_dvd_mul _ _)
#align commute.order_of_mul_dvd_mul_order_of Commute.orderOf_mul_dvd_mul_orderOf
#align add_commute.add_order_of_add_dvd_mul_add_order_of AddCommute.addOrderOf_add_dvd_mul_addOrderOf
@[to_additive addOrderOf_add_eq_mul_addOrderOf_of_coprime]
theorem orderOf_mul_eq_mul_orderOf_of_coprime (hco : (orderOf x).Coprime (orderOf y)) :
orderOf (x * y) = orderOf x * orderOf y := by
rw [orderOf, ← comp_mul_left]
exact h.function_commute_mul_left.minimalPeriod_of_comp_eq_mul_of_coprime hco
#align commute.order_of_mul_eq_mul_order_of_of_coprime Commute.orderOf_mul_eq_mul_orderOf_of_coprime
#align add_commute.add_order_of_add_eq_mul_add_order_of_of_coprime AddCommute.addOrderOf_add_eq_mul_addOrderOf_of_coprime
/-- Commuting elements of finite order are closed under multiplication. -/
@[to_additive "Commuting elements of finite additive order are closed under addition."]
theorem isOfFinOrder_mul (hx : IsOfFinOrder x) (hy : IsOfFinOrder y) : IsOfFinOrder (x * y) :=
orderOf_pos_iff.mp <|
pos_of_dvd_of_pos h.orderOf_mul_dvd_mul_orderOf <| mul_pos hx.orderOf_pos hy.orderOf_pos
#align commute.is_of_fin_order_mul Commute.isOfFinOrder_mul
#align add_commute.is_of_fin_order_add AddCommute.isOfFinAddOrder_add
/-- If each prime factor of `orderOf x` has higher multiplicity in `orderOf y`, and `x` commutes
with `y`, then `x * y` has the same order as `y`. -/
@[to_additive addOrderOf_add_eq_right_of_forall_prime_mul_dvd
"If each prime factor of
`addOrderOf x` has higher multiplicity in `addOrderOf y`, and `x` commutes with `y`,
then `x + y` has the same order as `y`."]
theorem orderOf_mul_eq_right_of_forall_prime_mul_dvd (hy : IsOfFinOrder y)
(hdvd : ∀ p : ℕ, p.Prime → p ∣ orderOf x → p * orderOf x ∣ orderOf y) :
orderOf (x * y) = orderOf y := by
have hoy := hy.orderOf_pos
have hxy := dvd_of_forall_prime_mul_dvd hdvd
apply orderOf_eq_of_pow_and_pow_div_prime hoy <;> simp only [Ne, ← orderOf_dvd_iff_pow_eq_one]
· exact h.orderOf_mul_dvd_lcm.trans (lcm_dvd hxy dvd_rfl)
refine fun p hp hpy hd => hp.ne_one ?_
rw [← Nat.dvd_one, ← mul_dvd_mul_iff_right hoy.ne', one_mul, ← dvd_div_iff hpy]
refine (orderOf_dvd_lcm_mul h).trans (lcm_dvd ((dvd_div_iff hpy).2 ?_) hd)
by_cases h : p ∣ orderOf x
exacts [hdvd p hp h, (hp.coprime_iff_not_dvd.2 h).mul_dvd_of_dvd_of_dvd hpy hxy]
#align commute.order_of_mul_eq_right_of_forall_prime_mul_dvd Commute.orderOf_mul_eq_right_of_forall_prime_mul_dvd
#align add_commute.add_order_of_add_eq_right_of_forall_prime_mul_dvd AddCommute.addOrderOf_add_eq_right_of_forall_prime_mul_dvd
end Commute
section PPrime
variable {x n} {p : ℕ} [hp : Fact p.Prime]
@[to_additive]
theorem orderOf_eq_prime (hg : x ^ p = 1) (hg1 : x ≠ 1) : orderOf x = p :=
minimalPeriod_eq_prime ((isPeriodicPt_mul_iff_pow_eq_one _).mpr hg)
(by rwa [IsFixedPt, mul_one])
#align order_of_eq_prime orderOf_eq_prime
#align add_order_of_eq_prime addOrderOf_eq_prime
@[to_additive addOrderOf_eq_prime_pow]
theorem orderOf_eq_prime_pow (hnot : ¬x ^ p ^ n = 1) (hfin : x ^ p ^ (n + 1) = 1) :
orderOf x = p ^ (n + 1) := by
apply minimalPeriod_eq_prime_pow <;> rwa [isPeriodicPt_mul_iff_pow_eq_one]
#align order_of_eq_prime_pow orderOf_eq_prime_pow
#align add_order_of_eq_prime_pow addOrderOf_eq_prime_pow
@[to_additive exists_addOrderOf_eq_prime_pow_iff]
theorem exists_orderOf_eq_prime_pow_iff :
(∃ k : ℕ, orderOf x = p ^ k) ↔ ∃ m : ℕ, x ^ (p : ℕ) ^ m = 1 :=
⟨fun ⟨k, hk⟩ => ⟨k, by rw [← hk, pow_orderOf_eq_one]⟩, fun ⟨_, hm⟩ => by
obtain ⟨k, _, hk⟩ := (Nat.dvd_prime_pow hp.elim).mp (orderOf_dvd_of_pow_eq_one hm)
exact ⟨k, hk⟩⟩
#align exists_order_of_eq_prime_pow_iff exists_orderOf_eq_prime_pow_iff
#align exists_add_order_of_eq_prime_pow_iff exists_addOrderOf_eq_prime_pow_iff
end PPrime
end Monoid
section CancelMonoid
variable [LeftCancelMonoid G] {x y : G} {a : G} {m n : ℕ}
@[to_additive]
theorem pow_eq_pow_iff_modEq : x ^ n = x ^ m ↔ n ≡ m [MOD orderOf x] := by
wlog hmn : m ≤ n generalizing m n
· rw [eq_comm, ModEq.comm, this (le_of_not_le hmn)]
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn
rw [← mul_one (x ^ m), pow_add, mul_left_cancel_iff, pow_eq_one_iff_modEq]
exact ⟨fun h => Nat.ModEq.add_left _ h, fun h => Nat.ModEq.add_left_cancel' _ h⟩
#align pow_eq_pow_iff_modeq pow_eq_pow_iff_modEq
#align nsmul_eq_nsmul_iff_modeq nsmul_eq_nsmul_iff_modEq
@[to_additive (attr := simp)]
lemma injective_pow_iff_not_isOfFinOrder : Injective (fun n : ℕ ↦ x ^ n) ↔ ¬IsOfFinOrder x := by
refine ⟨fun h => not_isOfFinOrder_of_injective_pow h, fun h n m hnm => ?_⟩
rwa [pow_eq_pow_iff_modEq, orderOf_eq_zero_iff.mpr h, modEq_zero_iff] at hnm
#align injective_pow_iff_not_is_of_fin_order injective_pow_iff_not_isOfFinOrder
#align injective_nsmul_iff_not_is_of_fin_add_order injective_nsmul_iff_not_isOfFinAddOrder
@[to_additive]
lemma pow_inj_mod {n m : ℕ} : x ^ n = x ^ m ↔ n % orderOf x = m % orderOf x := pow_eq_pow_iff_modEq
#align pow_inj_mod pow_inj_mod
#align nsmul_inj_mod nsmul_inj_mod
@[to_additive]
theorem pow_inj_iff_of_orderOf_eq_zero (h : orderOf x = 0) {n m : ℕ} : x ^ n = x ^ m ↔ n = m := by
rw [pow_eq_pow_iff_modEq, h, modEq_zero_iff]
#align pow_inj_iff_of_order_of_eq_zero pow_inj_iff_of_orderOf_eq_zero
#align nsmul_inj_iff_of_add_order_of_eq_zero nsmul_inj_iff_of_addOrderOf_eq_zero
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
{ y : G | ¬IsOfFinOrder y }.Infinite := by
let s := { n | 0 < n }.image fun n : ℕ => x ^ n
have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
apply h
rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
obtain ⟨m, hm, hm'⟩ := contra
exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
suffices s.Infinite by exact this.mono hs
contrapose! h
have : ¬Injective fun n : ℕ => x ^ n := by
have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
contrapose! this
exact Set.injOn_of_injective this
rwa [injective_pow_iff_not_isOfFinOrder, Classical.not_not] at this
#align infinite_not_is_of_fin_order infinite_not_isOfFinOrder
#align infinite_not_is_of_fin_add_order infinite_not_isOfFinAddOrder
@[to_additive (attr := simp)]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
(fun n ↦ by simp [mem_powers_iff])
refine isOfFinOrder_iff_pow_eq_one.2 ⟨n - m, tsub_pos_iff_lt.2 hmn, ?_⟩
rw [← mul_left_cancel_iff (a := a ^ m), ← pow_add, add_tsub_cancel_of_le hmn.le, ha, mul_one]
@[to_additive (attr := simp)]
lemma infinite_powers : (powers a : Set G).Infinite ↔ ¬ IsOfFinOrder a := finite_powers.not
/-- The equivalence between `Fin (orderOf x)` and `Submonoid.powers x`, sending `i` to `x ^ i`."-/
@[to_additive "The equivalence between `Fin (addOrderOf a)` and
`AddSubmonoid.multiples a`, sending `i` to `i • a`."]
noncomputable def finEquivPowers (x : G) (hx : IsOfFinOrder x) : Fin (orderOf x) ≃ powers x :=
Equiv.ofBijective (fun n ↦ ⟨x ^ (n : ℕ), ⟨n, rfl⟩⟩) ⟨fun ⟨_, h₁⟩ ⟨_, h₂⟩ ij ↦
Fin.ext (pow_injOn_Iio_orderOf h₁ h₂ (Subtype.mk_eq_mk.1 ij)), fun ⟨_, i, rfl⟩ ↦
⟨⟨i % orderOf x, mod_lt _ hx.orderOf_pos⟩, Subtype.eq <| pow_mod_orderOf _ _⟩⟩
#align fin_equiv_powers finEquivPowers
#align fin_equiv_multiples finEquivMultiples
-- This lemma has always been bad, but the linter only noticed after leanprover/lean4#2644.
@[to_additive (attr := simp, nolint simpNF)]
lemma finEquivPowers_apply (x : G) (hx) {n : Fin (orderOf x)} :
finEquivPowers x hx n = ⟨x ^ (n : ℕ), n, rfl⟩ := rfl
#align fin_equiv_powers_apply finEquivPowers_apply
#align fin_equiv_multiples_apply finEquivMultiples_apply
-- This lemma has always been bad, but the linter only noticed after leanprover/lean4#2644.
@[to_additive (attr := simp, nolint simpNF)]
lemma finEquivPowers_symm_apply (x : G) (hx) (n : ℕ) {hn : ∃ m : ℕ, x ^ m = x ^ n} :
(finEquivPowers x hx).symm ⟨x ^ n, hn⟩ = ⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
rw [Equiv.symm_apply_eq, finEquivPowers_apply, Subtype.mk_eq_mk, ← pow_mod_orderOf, Fin.val_mk]
#align fin_equiv_powers_symm_apply finEquivPowers_symm_apply
#align fin_equiv_multiples_symm_apply finEquivMultiples_symm_apply
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive "See also `addOrder_eq_card_multiples`."]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
classical
by_cases ha : IsOfFinOrder a
· exact (Nat.card_congr (finEquivPowers _ ha).symm).trans <| by simp
· have := (infinite_powers.2 ha).to_subtype
rw [orderOf_eq_zero ha, Nat.card_eq_zero_of_infinite]
end CancelMonoid
section Group
variable [Group G] {x y : G} {i : ℤ}
/-- Inverses of elements of finite order have finite order. -/
@[to_additive (attr := simp) "Inverses of elements of finite additive order
have finite additive order."]
theorem isOfFinOrder_inv_iff {x : G} : IsOfFinOrder x⁻¹ ↔ IsOfFinOrder x := by
simp [isOfFinOrder_iff_pow_eq_one]
#align is_of_fin_order_inv_iff isOfFinOrder_inv_iff
#align is_of_fin_order_neg_iff isOfFinAddOrder_neg_iff
@[to_additive] alias ⟨IsOfFinOrder.of_inv, IsOfFinOrder.inv⟩ := isOfFinOrder_inv_iff
#align is_of_fin_order.inv IsOfFinOrder.inv
#align is_of_fin_add_order.neg IsOfFinAddOrder.neg
@[to_additive]
| Mathlib/GroupTheory/OrderOfElement.lean | 669 | 673 | theorem orderOf_dvd_iff_zpow_eq_one : (orderOf x : ℤ) ∣ i ↔ x ^ i = 1 := by |
rcases Int.eq_nat_or_neg i with ⟨i, rfl | rfl⟩
· rw [Int.natCast_dvd_natCast, orderOf_dvd_iff_pow_eq_one, zpow_natCast]
· rw [dvd_neg, Int.natCast_dvd_natCast, zpow_neg, inv_eq_one, zpow_natCast,
orderOf_dvd_iff_pow_eq_one]
|
/-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.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"
/-!
# Multilinear maps
We define multilinear maps as maps from `∀ (i : ι), M₁ i` to `M₂` which are linear in each
coordinate. Here, `M₁ i` and `M₂` are modules over a ring `R`, and `ι` is an arbitrary type
(although some statements will require it to be a fintype). This space, denoted by
`MultilinearMap R M₁ M₂`, inherits a module structure by pointwise addition and multiplication.
## Main definitions
* `MultilinearMap R M₁ M₂` is the space of multilinear maps from `∀ (i : ι), M₁ i` to `M₂`.
* `f.map_smul` is the multiplicativity of the multilinear map `f` along each coordinate.
* `f.map_add` is the additivity of the multilinear map `f` along each coordinate.
* `f.map_smul_univ` expresses the multiplicativity of `f` over all coordinates at the same time,
writing `f (fun i => c i • m i)` as `(∏ i, c i) • f m`.
* `f.map_add_univ` expresses the additivity of `f` over all coordinates at the same time, writing
`f (m + m')` as the sum over all subsets `s` of `ι` of `f (s.piecewise m m')`.
* `f.map_sum` expresses `f (Σ_{j₁} g₁ j₁, ..., Σ_{jₙ} gₙ jₙ)` as the sum of
`f (g₁ (r 1), ..., gₙ (r n))` where `r` ranges over all possible functions.
We also register isomorphisms corresponding to currying or uncurrying variables, transforming a
multilinear function `f` on `n+1` variables into a linear function taking values in multilinear
functions in `n` variables, and into a multilinear function in `n` variables taking values in linear
functions. These operations are called `f.curryLeft` and `f.curryRight` respectively
(with inverses `f.uncurryLeft` and `f.uncurryRight`). These operations induce linear equivalences
between spaces of multilinear functions in `n+1` variables and spaces of linear functions into
multilinear functions in `n` variables (resp. multilinear functions in `n` variables taking values
in linear functions), called respectively `multilinearCurryLeftEquiv` and
`multilinearCurryRightEquiv`.
## Implementation notes
Expressing that a map is linear along the `i`-th coordinate when all other coordinates are fixed
can be done in two (equivalent) different ways:
* fixing a vector `m : ∀ (j : ι - i), M₁ j.val`, and then choosing separately the `i`-th coordinate
* fixing a vector `m : ∀j, M₁ j`, and then modifying its `i`-th coordinate
The second way is more artificial as the value of `m` at `i` is not relevant, but it has the
advantage of avoiding subtype inclusion issues. This is the definition we use, based on
`Function.update` that allows to change the value of `m` at `i`.
Note that the use of `Function.update` requires a `DecidableEq ι` term to appear somewhere in the
statement of `MultilinearMap.map_add'` and `MultilinearMap.map_smul'`. Three possible choices
are:
1. Requiring `DecidableEq ι` as an argument to `MultilinearMap` (as we did originally).
2. Using `Classical.decEq ι` in the statement of `map_add'` and `map_smul'`.
3. Quantifying over all possible `DecidableEq ι` instances in the statement of `map_add'` and
`map_smul'`.
Option 1 works fine, but puts unnecessary constraints on the user (the zero map certainly does not
need decidability). Option 2 looks great at first, but in the common case when `ι = Fin n` it
introduces non-defeq decidability instance diamonds within the context of proving `map_add'` and
`map_smul'`, of the form `Fin.decidableEq n = Classical.decEq (Fin n)`. Option 3 of course does
something similar, but of the form `Fin.decidableEq n = _inst`, which is much easier to clean up
since `_inst` is a free variable and so the equality can just be substituted.
-/
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'}
/-- Multilinear maps over the ring `R`, from `∀ i, M₁ i` to `M₂` where `M₁ i` and `M₂` are modules
over `R`. -/
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
/-- The underlying multivariate function of a multilinear map. -/
toFun : (∀ i, M₁ i) → M₂
/-- A multilinear map is additive in every argument. -/
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)
/-- A multilinear map is compatible with scalar multiplication in every argument. -/
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
section SMul
variable {R' A : Type*} [Monoid R'] [Semiring A] [∀ i, Module A (M₁ i)] [DistribMulAction R' M₂]
[Module A M₂] [SMulCommClass A R' M₂]
instance : SMul R' (MultilinearMap A M₁ M₂) :=
⟨fun c f =>
⟨fun m => c • f m, fun m i x y => by simp [smul_add], fun l i x d => by
simp [← smul_comm x c (_ : M₂)]⟩⟩
@[simp]
theorem smul_apply (f : MultilinearMap A M₁ M₂) (c : R') (m : ∀ i, M₁ i) : (c • f) m = c • f m :=
rfl
#align multilinear_map.smul_apply MultilinearMap.smul_apply
theorem coe_smul (c : R') (f : MultilinearMap A M₁ M₂) : ⇑(c • f) = c • (⇑ f) :=
rfl
#align multilinear_map.coe_smul MultilinearMap.coe_smul
end SMul
instance addCommMonoid : AddCommMonoid (MultilinearMap R M₁ M₂) :=
coe_injective.addCommMonoid _ rfl (fun _ _ => rfl) fun _ _ => rfl
#align multilinear_map.add_comm_monoid MultilinearMap.addCommMonoid
/-- Coercion of a multilinear map to a function as an additive monoid homomorphism. -/
@[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
| Mathlib/LinearAlgebra/Multilinear/Basic.lean | 243 | 244 | 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
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Patrick Massot, Yury Kudryashov
-/
import Mathlib.Tactic.ApplyFun
import Mathlib.Topology.UniformSpace.Basic
import Mathlib.Topology.Separation
#align_import topology.uniform_space.separation from "leanprover-community/mathlib"@"0c1f285a9f6e608ae2bdffa3f993eafb01eba829"
/-!
# Hausdorff properties of uniform spaces. Separation quotient.
Two points of a topological space are called `Inseparable`,
if their neighborhoods filter are equal.
Equivalently, `Inseparable x y` means that any open set that contains `x` must contain `y`
and vice versa.
In a uniform space, points `x` and `y` are inseparable
if and only if `(x, y)` belongs to all entourages,
see `inseparable_iff_ker_uniformity`.
A uniform space is a regular topological space,
hence separation axioms `T0Space`, `T1Space`, `T2Space`, and `T3Space`
are equivalent for uniform spaces,
and Lean typeclass search can automatically convert from one assumption to another.
We say that a uniform space is *separated*, if it satisfies these axioms.
If you need an `Iff` statement (e.g., to rewrite),
then see `R1Space.t0Space_iff_t2Space` and `RegularSpace.t0Space_iff_t3Space`.
In this file we prove several facts
that relate `Inseparable` and `Specializes` to the uniformity filter.
Most of them are simple corollaries of `Filter.HasBasis.inseparable_iff_uniformity`
for different filter bases of `𝓤 α`.
Then we study the Kolmogorov quotient `SeparationQuotient X` of a uniform space.
For a general topological space,
this quotient is defined as the quotient by `Inseparable` equivalence relation.
It is the maximal T₀ quotient of a topological space.
In case of a uniform space, we equip this quotient with a `UniformSpace` structure
that agrees with the quotient topology.
We also prove that the quotient map induces uniformity on the original space.
Finally, we turn `SeparationQuotient` into a functor
(not in terms of `CategoryTheory.Functor` to avoid extra imports)
by defining `SeparationQuotient.lift'` and `SeparationQuotient.map` operations.
## Main definitions
* `SeparationQuotient.instUniformSpace`: uniform space structure on `SeparationQuotient α`,
where `α` is a uniform space;
* `SeparationQuotient.lift'`: given a map `f : α → β`
from a uniform space to a separated uniform space,
lift it to a map `SeparationQuotient α → β`;
if the original map is not uniformly continuous, then returns a constant map.
* `SeparationQuotient.map`: given a map `f : α → β` between uniform spaces,
returns a map `SeparationQuotient α → SeparationQuotient β`.
If the original map is not uniformly continuous, then returns a constant map.
Otherwise, `SeparationQuotient.map f (SeparationQuotient.mk x) = SeparationQuotient.mk (f x)`.
## Main results
* `SeparationQuotient.uniformity_eq`: the uniformity filter on `SeparationQuotient α`
is the push forward of the uniformity filter on `α`.
* `SeparationQuotient.comap_mk_uniformity`: the quotient map `α → SeparationQuotient α`
induces uniform space structure on the original space.
* `SeparationQuotient.uniformContinuous_lift'`: factoring a uniformly continuous map through the
separation quotient gives a uniformly continuous map.
* `SeparationQuotient.uniformContinuous_map`: maps induced between separation quotients are
uniformly continuous.
## Implementation notes
This files used to contain definitions of `separationRel α` and `UniformSpace.SeparationQuotient α`.
These definitions were equal (but not definitionally equal)
to `{x : α × α | Inseparable x.1 x.2}` and `SeparationQuotient α`, respectively,
and were added to the library before their geneeralizations to topological spaces.
In #10644, we migrated from these definitions
to more general `Inseparable` and `SeparationQuotient`.
## TODO
Definitions `SeparationQuotient.lift'` and `SeparationQuotient.map`
rely on `UniformSpace` structures in the domain and in the codomain.
We should generalize them to topological spaces.
This generalization will drop `UniformContinuous` assumptions in some lemmas,
and add these assumptions in other lemmas,
so it was not done in #10644 to keep it reasonably sized.
## Keywords
uniform space, separated space, Hausdorff space, separation quotient
-/
open Filter Set Function Topology Uniformity UniformSpace
open scoped Classical
noncomputable section
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
variable [UniformSpace α] [UniformSpace β] [UniformSpace γ]
/-!
### Separated uniform spaces
-/
instance (priority := 100) UniformSpace.to_regularSpace : RegularSpace α :=
.of_hasBasis
(fun _ ↦ nhds_basis_uniformity' uniformity_hasBasis_closed)
fun a _V hV ↦ isClosed_ball a hV.2
#align uniform_space.to_regular_space UniformSpace.to_regularSpace
#align separation_rel Inseparable
#noalign separated_equiv
#align separation_rel_iff_specializes specializes_iff_inseparable
#noalign separation_rel_iff_inseparable
theorem Filter.HasBasis.specializes_iff_uniformity {ι : Sort*} {p : ι → Prop} {s : ι → Set (α × α)}
(h : (𝓤 α).HasBasis p s) {x y : α} : x ⤳ y ↔ ∀ i, p i → (x, y) ∈ s i :=
(nhds_basis_uniformity h).specializes_iff
theorem Filter.HasBasis.inseparable_iff_uniformity {ι : Sort*} {p : ι → Prop} {s : ι → Set (α × α)}
(h : (𝓤 α).HasBasis p s) {x y : α} : Inseparable x y ↔ ∀ i, p i → (x, y) ∈ s i :=
specializes_iff_inseparable.symm.trans h.specializes_iff_uniformity
#align filter.has_basis.mem_separation_rel Filter.HasBasis.inseparable_iff_uniformity
theorem inseparable_iff_ker_uniformity {x y : α} : Inseparable x y ↔ (x, y) ∈ (𝓤 α).ker :=
(𝓤 α).basis_sets.inseparable_iff_uniformity
protected theorem Inseparable.nhds_le_uniformity {x y : α} (h : Inseparable x y) :
𝓝 (x, y) ≤ 𝓤 α := by
rw [h.prod rfl]
apply nhds_le_uniformity
theorem inseparable_iff_clusterPt_uniformity {x y : α} :
Inseparable x y ↔ ClusterPt (x, y) (𝓤 α) := by
refine ⟨fun h ↦ .of_nhds_le h.nhds_le_uniformity, fun h ↦ ?_⟩
simp_rw [uniformity_hasBasis_closed.inseparable_iff_uniformity, isClosed_iff_clusterPt]
exact fun U ⟨hU, hUc⟩ ↦ hUc _ <| h.mono <| le_principal_iff.2 hU
#align separated_space T0Space
theorem t0Space_iff_uniformity :
T0Space α ↔ ∀ x y, (∀ r ∈ 𝓤 α, (x, y) ∈ r) → x = y := by
simp only [t0Space_iff_inseparable, inseparable_iff_ker_uniformity, mem_ker, id]
#align separated_def t0Space_iff_uniformity
| Mathlib/Topology/UniformSpace/Separation.lean | 155 | 157 | theorem t0Space_iff_uniformity' :
T0Space α ↔ Pairwise fun x y ↦ ∃ r ∈ 𝓤 α, (x, y) ∉ r := by |
simp [t0Space_iff_not_inseparable, inseparable_iff_ker_uniformity]
|
/-
Copyright (c) 2020 Kexing Ying and Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, Kevin Buzzard, Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.GroupWithZero.Finset
import Mathlib.Algebra.Group.FiniteSupport
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Set.Subsingleton
#align_import algebra.big_operators.finprod from "leanprover-community/mathlib"@"d6fad0e5bf2d6f48da9175d25c3dc5706b3834ce"
/-!
# Finite products and sums over types and sets
We define products and sums over types and subsets of types, with no finiteness hypotheses.
All infinite products and sums are defined to be junk values (i.e. one or zero).
This approach is sometimes easier to use than `Finset.sum`,
when issues arise with `Finset` and `Fintype` being data.
## Main definitions
We use the following variables:
* `α`, `β` - types with no structure;
* `s`, `t` - sets
* `M`, `N` - additive or multiplicative commutative monoids
* `f`, `g` - functions
Definitions in this file:
* `finsum f : M` : the sum of `f x` as `x` ranges over the support of `f`, if it's finite.
Zero otherwise.
* `finprod f : M` : the product of `f x` as `x` ranges over the multiplicative support of `f`, if
it's finite. One otherwise.
## Notation
* `∑ᶠ i, f i` and `∑ᶠ i : α, f i` for `finsum f`
* `∏ᶠ i, f i` and `∏ᶠ i : α, f i` for `finprod f`
This notation works for functions `f : p → M`, where `p : Prop`, so the following works:
* `∑ᶠ i ∈ s, f i`, where `f : α → M`, `s : Set α` : sum over the set `s`;
* `∑ᶠ n < 5, f n`, where `f : ℕ → M` : same as `f 0 + f 1 + f 2 + f 3 + f 4`;
* `∏ᶠ (n >= -2) (hn : n < 3), f n`, where `f : ℤ → M` : same as `f (-2) * f (-1) * f 0 * f 1 * f 2`.
## Implementation notes
`finsum` and `finprod` is "yet another way of doing finite sums and products in Lean". However
experiments in the wild (e.g. with matroids) indicate that it is a helpful approach in settings
where the user is not interested in computability and wants to do reasoning without running into
typeclass diamonds caused by the constructive finiteness used in definitions such as `Finset` and
`Fintype`. By sticking solely to `Set.Finite` we avoid these problems. We are aware that there are
other solutions but for beginner mathematicians this approach is easier in practice.
Another application is the construction of a partition of unity from a collection of “bump”
function. In this case the finite set depends on the point and it's convenient to have a definition
that does not mention the set explicitly.
The first arguments in all definitions and lemmas is the codomain of the function of the big
operator. This is necessary for the heuristic in `@[to_additive]`.
See the documentation of `to_additive.attr` for more information.
We did not add `IsFinite (X : Type) : Prop`, because it is simply `Nonempty (Fintype X)`.
## Tags
finsum, finprod, finite sum, finite product
-/
open Function Set
/-!
### Definition and relation to `Finset.sum` and `Finset.prod`
-/
-- Porting note: Used to be section Sort
section sort
variable {G M N : Type*} {α β ι : Sort*} [CommMonoid M] [CommMonoid N]
section
/- Note: we use classical logic only for these definitions, to ensure that we do not write lemmas
with `Classical.dec` in their statement. -/
open scoped Classical
/-- Sum of `f x` as `x` ranges over the elements of the support of `f`, if it's finite. Zero
otherwise. -/
noncomputable irreducible_def finsum (lemma := finsum_def') [AddCommMonoid M] (f : α → M) : M :=
if h : (support (f ∘ PLift.down)).Finite then ∑ i ∈ h.toFinset, f i.down else 0
#align finsum finsum
/-- Product of `f x` as `x` ranges over the elements of the multiplicative support of `f`, if it's
finite. One otherwise. -/
@[to_additive existing]
noncomputable irreducible_def finprod (lemma := finprod_def') (f : α → M) : M :=
if h : (mulSupport (f ∘ PLift.down)).Finite then ∏ i ∈ h.toFinset, f i.down else 1
#align finprod finprod
attribute [to_additive existing] finprod_def'
end
open Batteries.ExtendedBinder
/-- `∑ᶠ x, f x` is notation for `finsum f`. It is the sum of `f x`, where `x` ranges over the
support of `f`, if it's finite, zero otherwise. Taking the sum over multiple arguments or
conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x`-/
notation3"∑ᶠ "(...)", "r:67:(scoped f => finsum f) => r
/-- `∏ᶠ x, f x` is notation for `finprod f`. It is the product of `f x`, where `x` ranges over the
multiplicative support of `f`, if it's finite, one otherwise. Taking the product over multiple
arguments or conditions is possible, e.g. `∏ᶠ (x) (y), f x y` and `∏ᶠ (x) (h: x ∈ s), f x`-/
notation3"∏ᶠ "(...)", "r:67:(scoped f => finprod f) => r
-- Porting note: The following ports the lean3 notation for this file, but is currently very fickle.
-- syntax (name := bigfinsum) "∑ᶠ" extBinders ", " term:67 : term
-- macro_rules (kind := bigfinsum)
-- | `(∑ᶠ $x:ident, $p) => `(finsum (fun $x:ident ↦ $p))
-- | `(∑ᶠ $x:ident : $t, $p) => `(finsum (fun $x:ident : $t ↦ $p))
-- | `(∑ᶠ $x:ident $b:binderPred, $p) =>
-- `(finsum fun $x => (finsum (α := satisfies_binder_pred% $x $b) (fun _ => $p)))
-- | `(∑ᶠ ($x:ident) ($h:ident : $t), $p) =>
-- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p))
-- | `(∑ᶠ ($x:ident : $_) ($h:ident : $t), $p) =>
-- `(finsum fun ($x) => finsum (α := $t) (fun $h => $p))
-- | `(∑ᶠ ($x:ident) ($y:ident), $p) =>
-- `(finsum fun $x => (finsum fun $y => $p))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum (α := $t) fun $h => $p)))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum fun $z => $p)))
-- | `(∑ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) =>
-- `(finsum fun $x => (finsum fun $y => (finsum fun $z => (finsum (α := $t) fun $h => $p))))
--
--
-- syntax (name := bigfinprod) "∏ᶠ " extBinders ", " term:67 : term
-- macro_rules (kind := bigfinprod)
-- | `(∏ᶠ $x:ident, $p) => `(finprod (fun $x:ident ↦ $p))
-- | `(∏ᶠ $x:ident : $t, $p) => `(finprod (fun $x:ident : $t ↦ $p))
-- | `(∏ᶠ $x:ident $b:binderPred, $p) =>
-- `(finprod fun $x => (finprod (α := satisfies_binder_pred% $x $b) (fun _ => $p)))
-- | `(∏ᶠ ($x:ident) ($h:ident : $t), $p) =>
-- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p))
-- | `(∏ᶠ ($x:ident : $_) ($h:ident : $t), $p) =>
-- `(finprod fun ($x) => finprod (α := $t) (fun $h => $p))
-- | `(∏ᶠ ($x:ident) ($y:ident), $p) =>
-- `(finprod fun $x => (finprod fun $y => $p))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($h:ident : $t), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod (α := $t) fun $h => $p)))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod fun $z => $p)))
-- | `(∏ᶠ ($x:ident) ($y:ident) ($z:ident) ($h:ident : $t), $p) =>
-- `(finprod fun $x => (finprod fun $y => (finprod fun $z =>
-- (finprod (α := $t) fun $h => $p))))
@[to_additive]
theorem finprod_eq_prod_plift_of_mulSupport_toFinset_subset {f : α → M}
(hf : (mulSupport (f ∘ PLift.down)).Finite) {s : Finset (PLift α)} (hs : hf.toFinset ⊆ s) :
∏ᶠ i, f i = ∏ i ∈ s, f i.down := by
rw [finprod, dif_pos]
refine Finset.prod_subset hs fun x _ hxf => ?_
rwa [hf.mem_toFinset, nmem_mulSupport] at hxf
#align finprod_eq_prod_plift_of_mul_support_to_finset_subset finprod_eq_prod_plift_of_mulSupport_toFinset_subset
#align finsum_eq_sum_plift_of_support_to_finset_subset finsum_eq_sum_plift_of_support_toFinset_subset
@[to_additive]
theorem finprod_eq_prod_plift_of_mulSupport_subset {f : α → M} {s : Finset (PLift α)}
(hs : mulSupport (f ∘ PLift.down) ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i.down :=
finprod_eq_prod_plift_of_mulSupport_toFinset_subset (s.finite_toSet.subset hs) fun x hx => by
rw [Finite.mem_toFinset] at hx
exact hs hx
#align finprod_eq_prod_plift_of_mul_support_subset finprod_eq_prod_plift_of_mulSupport_subset
#align finsum_eq_sum_plift_of_support_subset finsum_eq_sum_plift_of_support_subset
@[to_additive (attr := simp)]
theorem finprod_one : (∏ᶠ _ : α, (1 : M)) = 1 := by
have : (mulSupport fun x : PLift α => (fun _ => 1 : α → M) x.down) ⊆ (∅ : Finset (PLift α)) :=
fun x h => by simp at h
rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_empty]
#align finprod_one finprod_one
#align finsum_zero finsum_zero
@[to_additive]
theorem finprod_of_isEmpty [IsEmpty α] (f : α → M) : ∏ᶠ i, f i = 1 := by
rw [← finprod_one]
congr
simp [eq_iff_true_of_subsingleton]
#align finprod_of_is_empty finprod_of_isEmpty
#align finsum_of_is_empty finsum_of_isEmpty
@[to_additive (attr := simp)]
theorem finprod_false (f : False → M) : ∏ᶠ i, f i = 1 :=
finprod_of_isEmpty _
#align finprod_false finprod_false
#align finsum_false finsum_false
@[to_additive]
theorem finprod_eq_single (f : α → M) (a : α) (ha : ∀ x, x ≠ a → f x = 1) :
∏ᶠ x, f x = f a := by
have : mulSupport (f ∘ PLift.down) ⊆ ({PLift.up a} : Finset (PLift α)) := by
intro x
contrapose
simpa [PLift.eq_up_iff_down_eq] using ha x.down
rw [finprod_eq_prod_plift_of_mulSupport_subset this, Finset.prod_singleton]
#align finprod_eq_single finprod_eq_single
#align finsum_eq_single finsum_eq_single
@[to_additive]
theorem finprod_unique [Unique α] (f : α → M) : ∏ᶠ i, f i = f default :=
finprod_eq_single f default fun _x hx => (hx <| Unique.eq_default _).elim
#align finprod_unique finprod_unique
#align finsum_unique finsum_unique
@[to_additive (attr := simp)]
theorem finprod_true (f : True → M) : ∏ᶠ i, f i = f trivial :=
@finprod_unique M True _ ⟨⟨trivial⟩, fun _ => rfl⟩ f
#align finprod_true finprod_true
#align finsum_true finsum_true
@[to_additive]
theorem finprod_eq_dif {p : Prop} [Decidable p] (f : p → M) :
∏ᶠ i, f i = if h : p then f h else 1 := by
split_ifs with h
· haveI : Unique p := ⟨⟨h⟩, fun _ => rfl⟩
exact finprod_unique f
· haveI : IsEmpty p := ⟨h⟩
exact finprod_of_isEmpty f
#align finprod_eq_dif finprod_eq_dif
#align finsum_eq_dif finsum_eq_dif
@[to_additive]
theorem finprod_eq_if {p : Prop} [Decidable p] {x : M} : ∏ᶠ _ : p, x = if p then x else 1 :=
finprod_eq_dif fun _ => x
#align finprod_eq_if finprod_eq_if
#align finsum_eq_if finsum_eq_if
@[to_additive]
theorem finprod_congr {f g : α → M} (h : ∀ x, f x = g x) : finprod f = finprod g :=
congr_arg _ <| funext h
#align finprod_congr finprod_congr
#align finsum_congr finsum_congr
@[to_additive (attr := congr)]
theorem finprod_congr_Prop {p q : Prop} {f : p → M} {g : q → M} (hpq : p = q)
(hfg : ∀ h : q, f (hpq.mpr h) = g h) : finprod f = finprod g := by
subst q
exact finprod_congr hfg
#align finprod_congr_Prop finprod_congr_Prop
#align finsum_congr_Prop finsum_congr_Prop
/-- To prove a property of a finite product, it suffices to prove that the property is
multiplicative and holds on the factors. -/
@[to_additive
"To prove a property of a finite sum, it suffices to prove that the property is
additive and holds on the summands."]
theorem finprod_induction {f : α → M} (p : M → Prop) (hp₀ : p 1)
(hp₁ : ∀ x y, p x → p y → p (x * y)) (hp₂ : ∀ i, p (f i)) : p (∏ᶠ i, f i) := by
rw [finprod]
split_ifs
exacts [Finset.prod_induction _ _ hp₁ hp₀ fun i _ => hp₂ _, hp₀]
#align finprod_induction finprod_induction
#align finsum_induction finsum_induction
theorem finprod_nonneg {R : Type*} [OrderedCommSemiring R] {f : α → R} (hf : ∀ x, 0 ≤ f x) :
0 ≤ ∏ᶠ x, f x :=
finprod_induction (fun x => 0 ≤ x) zero_le_one (fun _ _ => mul_nonneg) hf
#align finprod_nonneg finprod_nonneg
@[to_additive finsum_nonneg]
theorem one_le_finprod' {M : Type*} [OrderedCommMonoid M] {f : α → M} (hf : ∀ i, 1 ≤ f i) :
1 ≤ ∏ᶠ i, f i :=
finprod_induction _ le_rfl (fun _ _ => one_le_mul) hf
#align one_le_finprod' one_le_finprod'
#align finsum_nonneg finsum_nonneg
@[to_additive]
theorem MonoidHom.map_finprod_plift (f : M →* N) (g : α → M)
(h : (mulSupport <| g ∘ PLift.down).Finite) : f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) := by
rw [finprod_eq_prod_plift_of_mulSupport_subset h.coe_toFinset.ge,
finprod_eq_prod_plift_of_mulSupport_subset, map_prod]
rw [h.coe_toFinset]
exact mulSupport_comp_subset f.map_one (g ∘ PLift.down)
#align monoid_hom.map_finprod_plift MonoidHom.map_finprod_plift
#align add_monoid_hom.map_finsum_plift AddMonoidHom.map_finsum_plift
@[to_additive]
theorem MonoidHom.map_finprod_Prop {p : Prop} (f : M →* N) (g : p → M) :
f (∏ᶠ x, g x) = ∏ᶠ x, f (g x) :=
f.map_finprod_plift g (Set.toFinite _)
#align monoid_hom.map_finprod_Prop MonoidHom.map_finprod_Prop
#align add_monoid_hom.map_finsum_Prop AddMonoidHom.map_finsum_Prop
@[to_additive]
theorem MonoidHom.map_finprod_of_preimage_one (f : M →* N) (hf : ∀ x, f x = 1 → x = 1) (g : α → M) :
f (∏ᶠ i, g i) = ∏ᶠ i, f (g i) := by
by_cases hg : (mulSupport <| g ∘ PLift.down).Finite; · exact f.map_finprod_plift g hg
rw [finprod, dif_neg, f.map_one, finprod, dif_neg]
exacts [Infinite.mono (fun x hx => mt (hf (g x.down)) hx) hg, hg]
#align monoid_hom.map_finprod_of_preimage_one MonoidHom.map_finprod_of_preimage_one
#align add_monoid_hom.map_finsum_of_preimage_zero AddMonoidHom.map_finsum_of_preimage_zero
@[to_additive]
theorem MonoidHom.map_finprod_of_injective (g : M →* N) (hg : Injective g) (f : α → M) :
g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.map_finprod_of_preimage_one (fun _ => (hg.eq_iff' g.map_one).mp) f
#align monoid_hom.map_finprod_of_injective MonoidHom.map_finprod_of_injective
#align add_monoid_hom.map_finsum_of_injective AddMonoidHom.map_finsum_of_injective
@[to_additive]
theorem MulEquiv.map_finprod (g : M ≃* N) (f : α → M) : g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.toMonoidHom.map_finprod_of_injective (EquivLike.injective g) f
#align mul_equiv.map_finprod MulEquiv.map_finprod
#align add_equiv.map_finsum AddEquiv.map_finsum
/-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is
infinite. For a more usual version assuming `(support f).Finite` instead, see `finsum_smul'`. -/
theorem finsum_smul {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M]
(f : ι → R) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
· exact ((smulAddHom R M).flip x).map_finsum_of_injective (smul_left_injective R hx) _
#align finsum_smul finsum_smul
/-- The `NoZeroSMulDivisors` makes sure that the result holds even when the support of `f` is
infinite. For a more usual version assuming `(support f).Finite` instead, see `smul_finsum'`. -/
theorem smul_finsum {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M]
(c : R) (f : ι → M) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i := by
rcases eq_or_ne c 0 with (rfl | hc)
· simp
· exact (smulAddHom R M c).map_finsum_of_injective (smul_right_injective M hc) _
#align smul_finsum smul_finsum
@[to_additive]
theorem finprod_inv_distrib [DivisionCommMonoid G] (f : α → G) : (∏ᶠ x, (f x)⁻¹) = (∏ᶠ x, f x)⁻¹ :=
((MulEquiv.inv G).map_finprod f).symm
#align finprod_inv_distrib finprod_inv_distrib
#align finsum_neg_distrib finsum_neg_distrib
end sort
-- Porting note: Used to be section Type
section type
variable {α β ι G M N : Type*} [CommMonoid M] [CommMonoid N]
@[to_additive]
theorem finprod_eq_mulIndicator_apply (s : Set α) (f : α → M) (a : α) :
∏ᶠ _ : a ∈ s, f a = mulIndicator s f a := by
classical convert finprod_eq_if (M := M) (p := a ∈ s) (x := f a)
#align finprod_eq_mul_indicator_apply finprod_eq_mulIndicator_apply
#align finsum_eq_indicator_apply finsum_eq_indicator_apply
@[to_additive (attr := simp)]
theorem finprod_mem_mulSupport (f : α → M) (a : α) : ∏ᶠ _ : f a ≠ 1, f a = f a := by
rw [← mem_mulSupport, finprod_eq_mulIndicator_apply, mulIndicator_mulSupport]
#align finprod_mem_mul_support finprod_mem_mulSupport
#align finsum_mem_support finsum_mem_support
@[to_additive]
theorem finprod_mem_def (s : Set α) (f : α → M) : ∏ᶠ a ∈ s, f a = ∏ᶠ a, mulIndicator s f a :=
finprod_congr <| finprod_eq_mulIndicator_apply s f
#align finprod_mem_def finprod_mem_def
#align finsum_mem_def finsum_mem_def
@[to_additive]
theorem finprod_eq_prod_of_mulSupport_subset (f : α → M) {s : Finset α} (h : mulSupport f ⊆ s) :
∏ᶠ i, f i = ∏ i ∈ s, f i := by
have A : mulSupport (f ∘ PLift.down) = Equiv.plift.symm '' mulSupport f := by
rw [mulSupport_comp_eq_preimage]
exact (Equiv.plift.symm.image_eq_preimage _).symm
have : mulSupport (f ∘ PLift.down) ⊆ s.map Equiv.plift.symm.toEmbedding := by
rw [A, Finset.coe_map]
exact image_subset _ h
rw [finprod_eq_prod_plift_of_mulSupport_subset this]
simp only [Finset.prod_map, Equiv.coe_toEmbedding]
congr
#align finprod_eq_prod_of_mul_support_subset finprod_eq_prod_of_mulSupport_subset
#align finsum_eq_sum_of_support_subset finsum_eq_sum_of_support_subset
@[to_additive]
theorem finprod_eq_prod_of_mulSupport_toFinset_subset (f : α → M) (hf : (mulSupport f).Finite)
{s : Finset α} (h : hf.toFinset ⊆ s) : ∏ᶠ i, f i = ∏ i ∈ s, f i :=
finprod_eq_prod_of_mulSupport_subset _ fun _ hx => h <| hf.mem_toFinset.2 hx
#align finprod_eq_prod_of_mul_support_to_finset_subset finprod_eq_prod_of_mulSupport_toFinset_subset
#align finsum_eq_sum_of_support_to_finset_subset finsum_eq_sum_of_support_toFinset_subset
@[to_additive]
theorem finprod_eq_finset_prod_of_mulSupport_subset (f : α → M) {s : Finset α}
(h : mulSupport f ⊆ (s : Set α)) : ∏ᶠ i, f i = ∏ i ∈ s, f i :=
haveI h' : (s.finite_toSet.subset h).toFinset ⊆ s := by
simpa [← Finset.coe_subset, Set.coe_toFinset]
finprod_eq_prod_of_mulSupport_toFinset_subset _ _ h'
#align finprod_eq_finset_prod_of_mul_support_subset finprod_eq_finset_prod_of_mulSupport_subset
#align finsum_eq_finset_sum_of_support_subset finsum_eq_finset_sum_of_support_subset
@[to_additive]
theorem finprod_def (f : α → M) [Decidable (mulSupport f).Finite] :
∏ᶠ i : α, f i = if h : (mulSupport f).Finite then ∏ i ∈ h.toFinset, f i else 1 := by
split_ifs with h
· exact finprod_eq_prod_of_mulSupport_toFinset_subset _ h (Finset.Subset.refl _)
· rw [finprod, dif_neg]
rw [mulSupport_comp_eq_preimage]
exact mt (fun hf => hf.of_preimage Equiv.plift.surjective) h
#align finprod_def finprod_def
#align finsum_def finsum_def
@[to_additive]
theorem finprod_of_infinite_mulSupport {f : α → M} (hf : (mulSupport f).Infinite) :
∏ᶠ i, f i = 1 := by classical rw [finprod_def, dif_neg hf]
#align finprod_of_infinite_mul_support finprod_of_infinite_mulSupport
#align finsum_of_infinite_support finsum_of_infinite_support
@[to_additive]
theorem finprod_eq_prod (f : α → M) (hf : (mulSupport f).Finite) :
∏ᶠ i : α, f i = ∏ i ∈ hf.toFinset, f i := by classical rw [finprod_def, dif_pos hf]
#align finprod_eq_prod finprod_eq_prod
#align finsum_eq_sum finsum_eq_sum
@[to_additive]
theorem finprod_eq_prod_of_fintype [Fintype α] (f : α → M) : ∏ᶠ i : α, f i = ∏ i, f i :=
finprod_eq_prod_of_mulSupport_toFinset_subset _ (Set.toFinite _) <| Finset.subset_univ _
#align finprod_eq_prod_of_fintype finprod_eq_prod_of_fintype
#align finsum_eq_sum_of_fintype finsum_eq_sum_of_fintype
@[to_additive]
theorem finprod_cond_eq_prod_of_cond_iff (f : α → M) {p : α → Prop} {t : Finset α}
(h : ∀ {x}, f x ≠ 1 → (p x ↔ x ∈ t)) : (∏ᶠ (i) (_ : p i), f i) = ∏ i ∈ t, f i := by
set s := { x | p x }
have : mulSupport (s.mulIndicator f) ⊆ t := by
rw [Set.mulSupport_mulIndicator]
intro x hx
exact (h hx.2).1 hx.1
erw [finprod_mem_def, finprod_eq_prod_of_mulSupport_subset _ this]
refine Finset.prod_congr rfl fun x hx => mulIndicator_apply_eq_self.2 fun hxs => ?_
contrapose! hxs
exact (h hxs).2 hx
#align finprod_cond_eq_prod_of_cond_iff finprod_cond_eq_prod_of_cond_iff
#align finsum_cond_eq_sum_of_cond_iff finsum_cond_eq_sum_of_cond_iff
@[to_additive]
theorem finprod_cond_ne (f : α → M) (a : α) [DecidableEq α] (hf : (mulSupport f).Finite) :
(∏ᶠ (i) (_ : i ≠ a), f i) = ∏ i ∈ hf.toFinset.erase a, f i := by
apply finprod_cond_eq_prod_of_cond_iff
intro x hx
rw [Finset.mem_erase, Finite.mem_toFinset, mem_mulSupport]
exact ⟨fun h => And.intro h hx, fun h => h.1⟩
#align finprod_cond_ne finprod_cond_ne
#align finsum_cond_ne finsum_cond_ne
@[to_additive]
theorem finprod_mem_eq_prod_of_inter_mulSupport_eq (f : α → M) {s : Set α} {t : Finset α}
(h : s ∩ mulSupport f = t.toSet ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i :=
finprod_cond_eq_prod_of_cond_iff _ <| by
intro x hxf
rw [← mem_mulSupport] at hxf
refine ⟨fun hx => ?_, fun hx => ?_⟩
· refine ((mem_inter_iff x t (mulSupport f)).mp ?_).1
rw [← Set.ext_iff.mp h x, mem_inter_iff]
exact ⟨hx, hxf⟩
· refine ((mem_inter_iff x s (mulSupport f)).mp ?_).1
rw [Set.ext_iff.mp h x, mem_inter_iff]
exact ⟨hx, hxf⟩
#align finprod_mem_eq_prod_of_inter_mul_support_eq finprod_mem_eq_prod_of_inter_mulSupport_eq
#align finsum_mem_eq_sum_of_inter_support_eq finsum_mem_eq_sum_of_inter_support_eq
@[to_additive]
theorem finprod_mem_eq_prod_of_subset (f : α → M) {s : Set α} {t : Finset α}
(h₁ : s ∩ mulSupport f ⊆ t) (h₂ : ↑t ⊆ s) : ∏ᶠ i ∈ s, f i = ∏ i ∈ t, f i :=
finprod_cond_eq_prod_of_cond_iff _ fun hx => ⟨fun h => h₁ ⟨h, hx⟩, fun h => h₂ h⟩
#align finprod_mem_eq_prod_of_subset finprod_mem_eq_prod_of_subset
#align finsum_mem_eq_sum_of_subset finsum_mem_eq_sum_of_subset
@[to_additive]
theorem finprod_mem_eq_prod (f : α → M) {s : Set α} (hf : (s ∩ mulSupport f).Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ hf.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp [inter_assoc]
#align finprod_mem_eq_prod finprod_mem_eq_prod
#align finsum_mem_eq_sum finsum_mem_eq_sum
@[to_additive]
theorem finprod_mem_eq_prod_filter (f : α → M) (s : Set α) [DecidablePred (· ∈ s)]
(hf : (mulSupport f).Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ Finset.filter (· ∈ s) hf.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by
ext x
simp [and_comm]
#align finprod_mem_eq_prod_filter finprod_mem_eq_prod_filter
#align finsum_mem_eq_sum_filter finsum_mem_eq_sum_filter
@[to_additive]
theorem finprod_mem_eq_toFinset_prod (f : α → M) (s : Set α) [Fintype s] :
∏ᶠ i ∈ s, f i = ∏ i ∈ s.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by simp_rw [coe_toFinset s]
#align finprod_mem_eq_to_finset_prod finprod_mem_eq_toFinset_prod
#align finsum_mem_eq_to_finset_sum finsum_mem_eq_toFinset_sum
@[to_additive]
theorem finprod_mem_eq_finite_toFinset_prod (f : α → M) {s : Set α} (hs : s.Finite) :
∏ᶠ i ∈ s, f i = ∏ i ∈ hs.toFinset, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ <| by rw [hs.coe_toFinset]
#align finprod_mem_eq_finite_to_finset_prod finprod_mem_eq_finite_toFinset_prod
#align finsum_mem_eq_finite_to_finset_sum finsum_mem_eq_finite_toFinset_sum
@[to_additive]
theorem finprod_mem_finset_eq_prod (f : α → M) (s : Finset α) : ∏ᶠ i ∈ s, f i = ∏ i ∈ s, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl
#align finprod_mem_finset_eq_prod finprod_mem_finset_eq_prod
#align finsum_mem_finset_eq_sum finsum_mem_finset_eq_sum
@[to_additive]
theorem finprod_mem_coe_finset (f : α → M) (s : Finset α) :
(∏ᶠ i ∈ (s : Set α), f i) = ∏ i ∈ s, f i :=
finprod_mem_eq_prod_of_inter_mulSupport_eq _ rfl
#align finprod_mem_coe_finset finprod_mem_coe_finset
#align finsum_mem_coe_finset finsum_mem_coe_finset
@[to_additive]
theorem finprod_mem_eq_one_of_infinite {f : α → M} {s : Set α} (hs : (s ∩ mulSupport f).Infinite) :
∏ᶠ i ∈ s, f i = 1 := by
rw [finprod_mem_def]
apply finprod_of_infinite_mulSupport
rwa [← mulSupport_mulIndicator] at hs
#align finprod_mem_eq_one_of_infinite finprod_mem_eq_one_of_infinite
#align finsum_mem_eq_zero_of_infinite finsum_mem_eq_zero_of_infinite
@[to_additive]
theorem finprod_mem_eq_one_of_forall_eq_one {f : α → M} {s : Set α} (h : ∀ x ∈ s, f x = 1) :
∏ᶠ i ∈ s, f i = 1 := by simp (config := { contextual := true }) [h]
#align finprod_mem_eq_one_of_forall_eq_one finprod_mem_eq_one_of_forall_eq_one
#align finsum_mem_eq_zero_of_forall_eq_zero finsum_mem_eq_zero_of_forall_eq_zero
@[to_additive]
theorem finprod_mem_inter_mulSupport (f : α → M) (s : Set α) :
∏ᶠ i ∈ s ∩ mulSupport f, f i = ∏ᶠ i ∈ s, f i := by
rw [finprod_mem_def, finprod_mem_def, mulIndicator_inter_mulSupport]
#align finprod_mem_inter_mul_support finprod_mem_inter_mulSupport
#align finsum_mem_inter_support finsum_mem_inter_support
@[to_additive]
theorem finprod_mem_inter_mulSupport_eq (f : α → M) (s t : Set α)
(h : s ∩ mulSupport f = t ∩ mulSupport f) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by
rw [← finprod_mem_inter_mulSupport, h, finprod_mem_inter_mulSupport]
#align finprod_mem_inter_mul_support_eq finprod_mem_inter_mulSupport_eq
#align finsum_mem_inter_support_eq finsum_mem_inter_support_eq
@[to_additive]
theorem finprod_mem_inter_mulSupport_eq' (f : α → M) (s t : Set α)
(h : ∀ x ∈ mulSupport f, x ∈ s ↔ x ∈ t) : ∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, f i := by
apply finprod_mem_inter_mulSupport_eq
ext x
exact and_congr_left (h x)
#align finprod_mem_inter_mul_support_eq' finprod_mem_inter_mulSupport_eq'
#align finsum_mem_inter_support_eq' finsum_mem_inter_support_eq'
@[to_additive]
theorem finprod_mem_univ (f : α → M) : ∏ᶠ i ∈ @Set.univ α, f i = ∏ᶠ i : α, f i :=
finprod_congr fun _ => finprod_true _
#align finprod_mem_univ finprod_mem_univ
#align finsum_mem_univ finsum_mem_univ
variable {f g : α → M} {a b : α} {s t : Set α}
@[to_additive]
theorem finprod_mem_congr (h₀ : s = t) (h₁ : ∀ x ∈ t, f x = g x) :
∏ᶠ i ∈ s, f i = ∏ᶠ i ∈ t, g i :=
h₀.symm ▸ finprod_congr fun i => finprod_congr_Prop rfl (h₁ i)
#align finprod_mem_congr finprod_mem_congr
#align finsum_mem_congr finsum_mem_congr
@[to_additive]
theorem finprod_eq_one_of_forall_eq_one {f : α → M} (h : ∀ x, f x = 1) : ∏ᶠ i, f i = 1 := by
simp (config := { contextual := true }) [h]
#align finprod_eq_one_of_forall_eq_one finprod_eq_one_of_forall_eq_one
#align finsum_eq_zero_of_forall_eq_zero finsum_eq_zero_of_forall_eq_zero
@[to_additive finsum_pos']
theorem one_lt_finprod' {M : Type*} [OrderedCancelCommMonoid M] {f : ι → M}
(h : ∀ i, 1 ≤ f i) (h' : ∃ i, 1 < f i) (hf : (mulSupport f).Finite) : 1 < ∏ᶠ i, f i := by
rcases h' with ⟨i, hi⟩
rw [finprod_eq_prod _ hf]
refine Finset.one_lt_prod' (fun i _ ↦ h i) ⟨i, ?_, hi⟩
simpa only [Finite.mem_toFinset, mem_mulSupport] using ne_of_gt hi
/-!
### Distributivity w.r.t. addition, subtraction, and (scalar) multiplication
-/
/-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i * g i` equals
the product of `f i` multiplied by the product of `g i`. -/
@[to_additive
"If the additive supports of `f` and `g` are finite, then the sum of `f i + g i`
equals the sum of `f i` plus the sum of `g i`."]
theorem finprod_mul_distrib (hf : (mulSupport f).Finite) (hg : (mulSupport g).Finite) :
∏ᶠ i, f i * g i = (∏ᶠ i, f i) * ∏ᶠ i, g i := by
classical
rw [finprod_eq_prod_of_mulSupport_toFinset_subset f hf Finset.subset_union_left,
finprod_eq_prod_of_mulSupport_toFinset_subset g hg Finset.subset_union_right, ←
Finset.prod_mul_distrib]
refine finprod_eq_prod_of_mulSupport_subset _ ?_
simp only [Finset.coe_union, Finite.coe_toFinset, mulSupport_subset_iff,
mem_union, mem_mulSupport]
intro x
contrapose!
rintro ⟨hf, hg⟩
simp [hf, hg]
#align finprod_mul_distrib finprod_mul_distrib
#align finsum_add_distrib finsum_add_distrib
/-- If the multiplicative supports of `f` and `g` are finite, then the product of `f i / g i`
equals the product of `f i` divided by the product of `g i`. -/
@[to_additive
"If the additive supports of `f` and `g` are finite, then the sum of `f i - g i`
equals the sum of `f i` minus the sum of `g i`."]
theorem finprod_div_distrib [DivisionCommMonoid G] {f g : α → G} (hf : (mulSupport f).Finite)
(hg : (mulSupport g).Finite) : ∏ᶠ i, f i / g i = (∏ᶠ i, f i) / ∏ᶠ i, g i := by
simp only [div_eq_mul_inv, finprod_mul_distrib hf ((mulSupport_inv g).symm.rec hg),
finprod_inv_distrib]
#align finprod_div_distrib finprod_div_distrib
#align finsum_sub_distrib finsum_sub_distrib
/-- A more general version of `finprod_mem_mul_distrib` that only requires `s ∩ mulSupport f` and
`s ∩ mulSupport g` rather than `s` to be finite. -/
@[to_additive
"A more general version of `finsum_mem_add_distrib` that only requires `s ∩ support f`
and `s ∩ support g` rather than `s` to be finite."]
theorem finprod_mem_mul_distrib' (hf : (s ∩ mulSupport f).Finite) (hg : (s ∩ mulSupport g).Finite) :
∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i := by
rw [← mulSupport_mulIndicator] at hf hg
simp only [finprod_mem_def, mulIndicator_mul, finprod_mul_distrib hf hg]
#align finprod_mem_mul_distrib' finprod_mem_mul_distrib'
#align finsum_mem_add_distrib' finsum_mem_add_distrib'
/-- The product of the constant function `1` over any set equals `1`. -/
@[to_additive "The sum of the constant function `0` over any set equals `0`."]
theorem finprod_mem_one (s : Set α) : (∏ᶠ i ∈ s, (1 : M)) = 1 := by simp
#align finprod_mem_one finprod_mem_one
#align finsum_mem_zero finsum_mem_zero
/-- If a function `f` equals `1` on a set `s`, then the product of `f i` over `i ∈ s` equals `1`. -/
@[to_additive
"If a function `f` equals `0` on a set `s`, then the product of `f i` over `i ∈ s`
equals `0`."]
theorem finprod_mem_of_eqOn_one (hf : s.EqOn f 1) : ∏ᶠ i ∈ s, f i = 1 := by
rw [← finprod_mem_one s]
exact finprod_mem_congr rfl hf
#align finprod_mem_of_eq_on_one finprod_mem_of_eqOn_one
#align finsum_mem_of_eq_on_zero finsum_mem_of_eqOn_zero
/-- If the product of `f i` over `i ∈ s` is not equal to `1`, then there is some `x ∈ s` such that
`f x ≠ 1`. -/
@[to_additive
"If the product of `f i` over `i ∈ s` is not equal to `0`, then there is some `x ∈ s`
such that `f x ≠ 0`."]
theorem exists_ne_one_of_finprod_mem_ne_one (h : ∏ᶠ i ∈ s, f i ≠ 1) : ∃ x ∈ s, f x ≠ 1 := by
by_contra! h'
exact h (finprod_mem_of_eqOn_one h')
#align exists_ne_one_of_finprod_mem_ne_one exists_ne_one_of_finprod_mem_ne_one
#align exists_ne_zero_of_finsum_mem_ne_zero exists_ne_zero_of_finsum_mem_ne_zero
/-- Given a finite set `s`, the product of `f i * g i` over `i ∈ s` equals the product of `f i`
over `i ∈ s` times the product of `g i` over `i ∈ s`. -/
@[to_additive
"Given a finite set `s`, the sum of `f i + g i` over `i ∈ s` equals the sum of `f i`
over `i ∈ s` plus the sum of `g i` over `i ∈ s`."]
theorem finprod_mem_mul_distrib (hs : s.Finite) :
∏ᶠ i ∈ s, f i * g i = (∏ᶠ i ∈ s, f i) * ∏ᶠ i ∈ s, g i :=
finprod_mem_mul_distrib' (hs.inter_of_left _) (hs.inter_of_left _)
#align finprod_mem_mul_distrib finprod_mem_mul_distrib
#align finsum_mem_add_distrib finsum_mem_add_distrib
@[to_additive]
theorem MonoidHom.map_finprod {f : α → M} (g : M →* N) (hf : (mulSupport f).Finite) :
g (∏ᶠ i, f i) = ∏ᶠ i, g (f i) :=
g.map_finprod_plift f <| hf.preimage Equiv.plift.injective.injOn
#align monoid_hom.map_finprod MonoidHom.map_finprod
#align add_monoid_hom.map_finsum AddMonoidHom.map_finsum
@[to_additive]
theorem finprod_pow (hf : (mulSupport f).Finite) (n : ℕ) : (∏ᶠ i, f i) ^ n = ∏ᶠ i, f i ^ n :=
(powMonoidHom n).map_finprod hf
#align finprod_pow finprod_pow
#align finsum_nsmul finsum_nsmul
/-- See also `finsum_smul` for a version that works even when the support of `f` is not finite,
but with slightly stronger typeclass requirements. -/
theorem finsum_smul' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] {f : ι → R}
(hf : (support f).Finite) (x : M) : (∑ᶠ i, f i) • x = ∑ᶠ i, f i • x :=
((smulAddHom R M).flip x).map_finsum hf
/-- See also `smul_finsum` for a version that works even when the support of `f` is not finite,
but with slightly stronger typeclass requirements. -/
theorem smul_finsum' {R M : Type*} [Semiring R] [AddCommMonoid M] [Module R M] (c : R) {f : ι → M}
(hf : (support f).Finite) : (c • ∑ᶠ i, f i) = ∑ᶠ i, c • f i :=
(smulAddHom R M c).map_finsum hf
/-- A more general version of `MonoidHom.map_finprod_mem` that requires `s ∩ mulSupport f` rather
than `s` to be finite. -/
@[to_additive
"A more general version of `AddMonoidHom.map_finsum_mem` that requires
`s ∩ support f` rather than `s` to be finite."]
theorem MonoidHom.map_finprod_mem' {f : α → M} (g : M →* N) (h₀ : (s ∩ mulSupport f).Finite) :
g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) := by
rw [g.map_finprod]
· simp only [g.map_finprod_Prop]
· simpa only [finprod_eq_mulIndicator_apply, mulSupport_mulIndicator]
#align monoid_hom.map_finprod_mem' MonoidHom.map_finprod_mem'
#align add_monoid_hom.map_finsum_mem' AddMonoidHom.map_finsum_mem'
/-- Given a monoid homomorphism `g : M →* N` and a function `f : α → M`, the value of `g` at the
product of `f i` over `i ∈ s` equals the product of `g (f i)` over `s`. -/
@[to_additive
"Given an additive monoid homomorphism `g : M →* N` and a function `f : α → M`, the
value of `g` at the sum of `f i` over `i ∈ s` equals the sum of `g (f i)` over `s`."]
theorem MonoidHom.map_finprod_mem (f : α → M) (g : M →* N) (hs : s.Finite) :
g (∏ᶠ j ∈ s, f j) = ∏ᶠ i ∈ s, g (f i) :=
g.map_finprod_mem' (hs.inter_of_left _)
#align monoid_hom.map_finprod_mem MonoidHom.map_finprod_mem
#align add_monoid_hom.map_finsum_mem AddMonoidHom.map_finsum_mem
@[to_additive]
theorem MulEquiv.map_finprod_mem (g : M ≃* N) (f : α → M) {s : Set α} (hs : s.Finite) :
g (∏ᶠ i ∈ s, f i) = ∏ᶠ i ∈ s, g (f i) :=
g.toMonoidHom.map_finprod_mem f hs
#align mul_equiv.map_finprod_mem MulEquiv.map_finprod_mem
#align add_equiv.map_finsum_mem AddEquiv.map_finsum_mem
@[to_additive]
theorem finprod_mem_inv_distrib [DivisionCommMonoid G] (f : α → G) (hs : s.Finite) :
(∏ᶠ x ∈ s, (f x)⁻¹) = (∏ᶠ x ∈ s, f x)⁻¹ :=
((MulEquiv.inv G).map_finprod_mem f hs).symm
#align finprod_mem_inv_distrib finprod_mem_inv_distrib
#align finsum_mem_neg_distrib finsum_mem_neg_distrib
/-- Given a finite set `s`, the product of `f i / g i` over `i ∈ s` equals the product of `f i`
over `i ∈ s` divided by the product of `g i` over `i ∈ s`. -/
@[to_additive
"Given a finite set `s`, the sum of `f i / g i` over `i ∈ s` equals the sum of `f i`
over `i ∈ s` minus the sum of `g i` over `i ∈ s`."]
| Mathlib/Algebra/BigOperators/Finprod.lean | 754 | 756 | theorem finprod_mem_div_distrib [DivisionCommMonoid G] (f g : α → G) (hs : s.Finite) :
∏ᶠ i ∈ s, f i / g i = (∏ᶠ i ∈ s, f i) / ∏ᶠ i ∈ s, g i := by |
simp only [div_eq_mul_inv, finprod_mem_mul_distrib hs, finprod_mem_inv_distrib g hs]
|
/-
Copyright (c) 2014 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Jeremy Avigad
-/
import Mathlib.Algebra.Order.Ring.Nat
#align_import data.nat.dist from "leanprover-community/mathlib"@"d50b12ae8e2bd910d08a94823976adae9825718b"
/-!
# Distance function on ℕ
This file defines a simple distance function on naturals from truncated subtraction.
-/
namespace Nat
/-- Distance (absolute value of difference) between natural numbers. -/
def dist (n m : ℕ) :=
n - m + (m - n)
#align nat.dist Nat.dist
-- Should be aligned to `Nat.dist.eq_def`, but that is generated on demand and isn't present yet.
#noalign nat.dist.def
theorem dist_comm (n m : ℕ) : dist n m = dist m n := by simp [dist, add_comm]
#align nat.dist_comm Nat.dist_comm
@[simp]
theorem dist_self (n : ℕ) : dist n n = 0 := by simp [dist, tsub_self]
#align nat.dist_self Nat.dist_self
theorem eq_of_dist_eq_zero {n m : ℕ} (h : dist n m = 0) : n = m :=
have : n - m = 0 := Nat.eq_zero_of_add_eq_zero_right h
have : n ≤ m := tsub_eq_zero_iff_le.mp this
have : m - n = 0 := Nat.eq_zero_of_add_eq_zero_left h
have : m ≤ n := tsub_eq_zero_iff_le.mp this
le_antisymm ‹n ≤ m› ‹m ≤ n›
#align nat.eq_of_dist_eq_zero Nat.eq_of_dist_eq_zero
theorem dist_eq_zero {n m : ℕ} (h : n = m) : dist n m = 0 := by rw [h, dist_self]
#align nat.dist_eq_zero Nat.dist_eq_zero
theorem dist_eq_sub_of_le {n m : ℕ} (h : n ≤ m) : dist n m = m - n := by
rw [dist, tsub_eq_zero_iff_le.mpr h, zero_add]
#align nat.dist_eq_sub_of_le Nat.dist_eq_sub_of_le
theorem dist_eq_sub_of_le_right {n m : ℕ} (h : m ≤ n) : dist n m = n - m := by
rw [dist_comm]; apply dist_eq_sub_of_le h
#align nat.dist_eq_sub_of_le_right Nat.dist_eq_sub_of_le_right
theorem dist_tri_left (n m : ℕ) : m ≤ dist n m + n :=
le_trans le_tsub_add (add_le_add_right (Nat.le_add_left _ _) _)
#align nat.dist_tri_left Nat.dist_tri_left
theorem dist_tri_right (n m : ℕ) : m ≤ n + dist n m := by rw [add_comm]; apply dist_tri_left
#align nat.dist_tri_right Nat.dist_tri_right
theorem dist_tri_left' (n m : ℕ) : n ≤ dist n m + m := by rw [dist_comm]; apply dist_tri_left
#align nat.dist_tri_left' Nat.dist_tri_left'
theorem dist_tri_right' (n m : ℕ) : n ≤ m + dist n m := by rw [dist_comm]; apply dist_tri_right
#align nat.dist_tri_right' Nat.dist_tri_right'
theorem dist_zero_right (n : ℕ) : dist n 0 = n :=
Eq.trans (dist_eq_sub_of_le_right (zero_le n)) (tsub_zero n)
#align nat.dist_zero_right Nat.dist_zero_right
theorem dist_zero_left (n : ℕ) : dist 0 n = n :=
Eq.trans (dist_eq_sub_of_le (zero_le n)) (tsub_zero n)
#align nat.dist_zero_left Nat.dist_zero_left
theorem dist_add_add_right (n k m : ℕ) : dist (n + k) (m + k) = dist n m :=
calc
dist (n + k) (m + k) = n + k - (m + k) + (m + k - (n + k)) := rfl
_ = n - m + (m + k - (n + k)) := by rw [@add_tsub_add_eq_tsub_right]
_ = n - m + (m - n) := by rw [@add_tsub_add_eq_tsub_right]
#align nat.dist_add_add_right Nat.dist_add_add_right
| Mathlib/Data/Nat/Dist.lean | 81 | 82 | theorem dist_add_add_left (k n m : ℕ) : dist (k + n) (k + m) = dist n m := by |
rw [add_comm k n, add_comm k m]; apply dist_add_add_right
|
/-
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Yury Kudryashov
-/
import Mathlib.Analysis.Normed.Group.InfiniteSum
import Mathlib.Analysis.Normed.MulAction
import Mathlib.Topology.Algebra.Order.LiminfLimsup
import Mathlib.Topology.PartialHomeomorph
#align_import analysis.asymptotics.asymptotics from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Asymptotics
We introduce these relations:
* `IsBigOWith c l f g` : "f is big O of g along l with constant c";
* `f =O[l] g` : "f is big O of g along l";
* `f =o[l] g` : "f is little o of g along l".
Here `l` is any filter on the domain of `f` and `g`, which are assumed to be the same. The codomains
of `f` and `g` do not need to be the same; all that is needed that there is a norm associated with
these types, and it is the norm that is compared asymptotically.
The relation `IsBigOWith c` is introduced to factor out common algebraic arguments in the proofs of
similar properties of `IsBigO` and `IsLittleO`. Usually proofs outside of this file should use
`IsBigO` instead.
Often the ranges of `f` and `g` will be the real numbers, in which case the norm is the absolute
value. In general, we have
`f =O[l] g ↔ (fun x ↦ ‖f x‖) =O[l] (fun x ↦ ‖g x‖)`,
and similarly for `IsLittleO`. But our setup allows us to use the notions e.g. with functions
to the integers, rationals, complex numbers, or any normed vector space without mentioning the
norm explicitly.
If `f` and `g` are functions to a normed field like the reals or complex numbers and `g` is always
nonzero, we have
`f =o[l] g ↔ Tendsto (fun x ↦ f x / (g x)) l (𝓝 0)`.
In fact, the right-to-left direction holds without the hypothesis on `g`, and in the other direction
it suffices to assume that `f` is zero wherever `g` is. (This generalization is useful in defining
the Fréchet derivative.)
-/
open Filter Set
open scoped Classical
open Topology Filter NNReal
namespace Asymptotics
set_option linter.uppercaseLean3 false
variable {α : Type*} {β : Type*} {E : Type*} {F : Type*} {G : Type*} {E' : Type*}
{F' : Type*} {G' : Type*} {E'' : Type*} {F'' : Type*} {G'' : Type*} {E''' : Type*}
{R : Type*} {R' : Type*} {𝕜 : Type*} {𝕜' : Type*}
variable [Norm E] [Norm F] [Norm G]
variable [SeminormedAddCommGroup E'] [SeminormedAddCommGroup F'] [SeminormedAddCommGroup G']
[NormedAddCommGroup E''] [NormedAddCommGroup F''] [NormedAddCommGroup G''] [SeminormedRing R]
[SeminormedAddGroup E''']
[SeminormedRing R']
variable [NormedDivisionRing 𝕜] [NormedDivisionRing 𝕜']
variable {c c' c₁ c₂ : ℝ} {f : α → E} {g : α → F} {k : α → G}
variable {f' : α → E'} {g' : α → F'} {k' : α → G'}
variable {f'' : α → E''} {g'' : α → F''} {k'' : α → G''}
variable {l l' : Filter α}
section Defs
/-! ### Definitions -/
/-- This version of the Landau notation `IsBigOWith C l f g` where `f` and `g` are two functions on
a type `α` and `l` is a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by `C * ‖g‖`.
In other words, `‖f‖ / ‖g‖` is eventually bounded by `C`, modulo division by zero issues that are
avoided by this definition. Probably you want to use `IsBigO` instead of this relation. -/
irreducible_def IsBigOWith (c : ℝ) (l : Filter α) (f : α → E) (g : α → F) : Prop :=
∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖
#align asymptotics.is_O_with Asymptotics.IsBigOWith
/-- Definition of `IsBigOWith`. We record it in a lemma as `IsBigOWith` is irreducible. -/
theorem isBigOWith_iff : IsBigOWith c l f g ↔ ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by rw [IsBigOWith_def]
#align asymptotics.is_O_with_iff Asymptotics.isBigOWith_iff
alias ⟨IsBigOWith.bound, IsBigOWith.of_bound⟩ := isBigOWith_iff
#align asymptotics.is_O_with.bound Asymptotics.IsBigOWith.bound
#align asymptotics.is_O_with.of_bound Asymptotics.IsBigOWith.of_bound
/-- The Landau notation `f =O[l] g` where `f` and `g` are two functions on a type `α` and `l` is
a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by a constant multiple of `‖g‖`.
In other words, `‖f‖ / ‖g‖` is eventually bounded, modulo division by zero issues that are avoided
by this definition. -/
irreducible_def IsBigO (l : Filter α) (f : α → E) (g : α → F) : Prop :=
∃ c : ℝ, IsBigOWith c l f g
#align asymptotics.is_O Asymptotics.IsBigO
@[inherit_doc]
notation:100 f " =O[" l "] " g:100 => IsBigO l f g
/-- Definition of `IsBigO` in terms of `IsBigOWith`. We record it in a lemma as `IsBigO` is
irreducible. -/
theorem isBigO_iff_isBigOWith : f =O[l] g ↔ ∃ c : ℝ, IsBigOWith c l f g := by rw [IsBigO_def]
#align asymptotics.is_O_iff_is_O_with Asymptotics.isBigO_iff_isBigOWith
/-- Definition of `IsBigO` in terms of filters. -/
theorem isBigO_iff : f =O[l] g ↔ ∃ c : ℝ, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by
simp only [IsBigO_def, IsBigOWith_def]
#align asymptotics.is_O_iff Asymptotics.isBigO_iff
/-- Definition of `IsBigO` in terms of filters, with a positive constant. -/
theorem isBigO_iff' {g : α → E'''} :
f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by
refine ⟨fun h => ?mp, fun h => ?mpr⟩
case mp =>
rw [isBigO_iff] at h
obtain ⟨c, hc⟩ := h
refine ⟨max c 1, zero_lt_one.trans_le (le_max_right _ _), ?_⟩
filter_upwards [hc] with x hx
apply hx.trans
gcongr
exact le_max_left _ _
case mpr =>
rw [isBigO_iff]
obtain ⟨c, ⟨_, hc⟩⟩ := h
exact ⟨c, hc⟩
/-- Definition of `IsBigO` in terms of filters, with the constant in the lower bound. -/
theorem isBigO_iff'' {g : α → E'''} :
f =O[l] g ↔ ∃ c > 0, ∀ᶠ x in l, c * ‖f x‖ ≤ ‖g x‖ := by
refine ⟨fun h => ?mp, fun h => ?mpr⟩
case mp =>
rw [isBigO_iff'] at h
obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h
refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩
filter_upwards [hc] with x hx
rwa [inv_mul_le_iff (by positivity)]
case mpr =>
rw [isBigO_iff']
obtain ⟨c, ⟨hc_pos, hc⟩⟩ := h
refine ⟨c⁻¹, ⟨by positivity, ?_⟩⟩
filter_upwards [hc] with x hx
rwa [← inv_inv c, inv_mul_le_iff (by positivity)] at hx
theorem IsBigO.of_bound (c : ℝ) (h : ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖) : f =O[l] g :=
isBigO_iff.2 ⟨c, h⟩
#align asymptotics.is_O.of_bound Asymptotics.IsBigO.of_bound
theorem IsBigO.of_bound' (h : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖) : f =O[l] g :=
IsBigO.of_bound 1 <| by
simp_rw [one_mul]
exact h
#align asymptotics.is_O.of_bound' Asymptotics.IsBigO.of_bound'
theorem IsBigO.bound : f =O[l] g → ∃ c : ℝ, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ :=
isBigO_iff.1
#align asymptotics.is_O.bound Asymptotics.IsBigO.bound
/-- The Landau notation `f =o[l] g` where `f` and `g` are two functions on a type `α` and `l` is
a filter on `α`, means that eventually for `l`, `‖f‖` is bounded by an arbitrarily small constant
multiple of `‖g‖`. In other words, `‖f‖ / ‖g‖` tends to `0` along `l`, modulo division by zero
issues that are avoided by this definition. -/
irreducible_def IsLittleO (l : Filter α) (f : α → E) (g : α → F) : Prop :=
∀ ⦃c : ℝ⦄, 0 < c → IsBigOWith c l f g
#align asymptotics.is_o Asymptotics.IsLittleO
@[inherit_doc]
notation:100 f " =o[" l "] " g:100 => IsLittleO l f g
/-- Definition of `IsLittleO` in terms of `IsBigOWith`. -/
theorem isLittleO_iff_forall_isBigOWith : f =o[l] g ↔ ∀ ⦃c : ℝ⦄, 0 < c → IsBigOWith c l f g := by
rw [IsLittleO_def]
#align asymptotics.is_o_iff_forall_is_O_with Asymptotics.isLittleO_iff_forall_isBigOWith
alias ⟨IsLittleO.forall_isBigOWith, IsLittleO.of_isBigOWith⟩ := isLittleO_iff_forall_isBigOWith
#align asymptotics.is_o.forall_is_O_with Asymptotics.IsLittleO.forall_isBigOWith
#align asymptotics.is_o.of_is_O_with Asymptotics.IsLittleO.of_isBigOWith
/-- Definition of `IsLittleO` in terms of filters. -/
theorem isLittleO_iff : f =o[l] g ↔ ∀ ⦃c : ℝ⦄, 0 < c → ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ := by
simp only [IsLittleO_def, IsBigOWith_def]
#align asymptotics.is_o_iff Asymptotics.isLittleO_iff
alias ⟨IsLittleO.bound, IsLittleO.of_bound⟩ := isLittleO_iff
#align asymptotics.is_o.bound Asymptotics.IsLittleO.bound
#align asymptotics.is_o.of_bound Asymptotics.IsLittleO.of_bound
theorem IsLittleO.def (h : f =o[l] g) (hc : 0 < c) : ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖ :=
isLittleO_iff.1 h hc
#align asymptotics.is_o.def Asymptotics.IsLittleO.def
theorem IsLittleO.def' (h : f =o[l] g) (hc : 0 < c) : IsBigOWith c l f g :=
isBigOWith_iff.2 <| isLittleO_iff.1 h hc
#align asymptotics.is_o.def' Asymptotics.IsLittleO.def'
theorem IsLittleO.eventuallyLE (h : f =o[l] g) : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖ := by
simpa using h.def zero_lt_one
end Defs
/-! ### Conversions -/
theorem IsBigOWith.isBigO (h : IsBigOWith c l f g) : f =O[l] g := by rw [IsBigO_def]; exact ⟨c, h⟩
#align asymptotics.is_O_with.is_O Asymptotics.IsBigOWith.isBigO
theorem IsLittleO.isBigOWith (hgf : f =o[l] g) : IsBigOWith 1 l f g :=
hgf.def' zero_lt_one
#align asymptotics.is_o.is_O_with Asymptotics.IsLittleO.isBigOWith
theorem IsLittleO.isBigO (hgf : f =o[l] g) : f =O[l] g :=
hgf.isBigOWith.isBigO
#align asymptotics.is_o.is_O Asymptotics.IsLittleO.isBigO
theorem IsBigO.isBigOWith : f =O[l] g → ∃ c : ℝ, IsBigOWith c l f g :=
isBigO_iff_isBigOWith.1
#align asymptotics.is_O.is_O_with Asymptotics.IsBigO.isBigOWith
theorem IsBigOWith.weaken (h : IsBigOWith c l f g') (hc : c ≤ c') : IsBigOWith c' l f g' :=
IsBigOWith.of_bound <|
mem_of_superset h.bound fun x hx =>
calc
‖f x‖ ≤ c * ‖g' x‖ := hx
_ ≤ _ := by gcongr
#align asymptotics.is_O_with.weaken Asymptotics.IsBigOWith.weaken
theorem IsBigOWith.exists_pos (h : IsBigOWith c l f g') :
∃ c' > 0, IsBigOWith c' l f g' :=
⟨max c 1, lt_of_lt_of_le zero_lt_one (le_max_right c 1), h.weaken <| le_max_left c 1⟩
#align asymptotics.is_O_with.exists_pos Asymptotics.IsBigOWith.exists_pos
theorem IsBigO.exists_pos (h : f =O[l] g') : ∃ c > 0, IsBigOWith c l f g' :=
let ⟨_c, hc⟩ := h.isBigOWith
hc.exists_pos
#align asymptotics.is_O.exists_pos Asymptotics.IsBigO.exists_pos
theorem IsBigOWith.exists_nonneg (h : IsBigOWith c l f g') :
∃ c' ≥ 0, IsBigOWith c' l f g' :=
let ⟨c, cpos, hc⟩ := h.exists_pos
⟨c, le_of_lt cpos, hc⟩
#align asymptotics.is_O_with.exists_nonneg Asymptotics.IsBigOWith.exists_nonneg
theorem IsBigO.exists_nonneg (h : f =O[l] g') : ∃ c ≥ 0, IsBigOWith c l f g' :=
let ⟨_c, hc⟩ := h.isBigOWith
hc.exists_nonneg
#align asymptotics.is_O.exists_nonneg Asymptotics.IsBigO.exists_nonneg
/-- `f = O(g)` if and only if `IsBigOWith c f g` for all sufficiently large `c`. -/
theorem isBigO_iff_eventually_isBigOWith : f =O[l] g' ↔ ∀ᶠ c in atTop, IsBigOWith c l f g' :=
isBigO_iff_isBigOWith.trans
⟨fun ⟨c, hc⟩ => mem_atTop_sets.2 ⟨c, fun _c' hc' => hc.weaken hc'⟩, fun h => h.exists⟩
#align asymptotics.is_O_iff_eventually_is_O_with Asymptotics.isBigO_iff_eventually_isBigOWith
/-- `f = O(g)` if and only if `∀ᶠ x in l, ‖f x‖ ≤ c * ‖g x‖` for all sufficiently large `c`. -/
theorem isBigO_iff_eventually : f =O[l] g' ↔ ∀ᶠ c in atTop, ∀ᶠ x in l, ‖f x‖ ≤ c * ‖g' x‖ :=
isBigO_iff_eventually_isBigOWith.trans <| by simp only [IsBigOWith_def]
#align asymptotics.is_O_iff_eventually Asymptotics.isBigO_iff_eventually
theorem IsBigO.exists_mem_basis {ι} {p : ι → Prop} {s : ι → Set α} (h : f =O[l] g')
(hb : l.HasBasis p s) :
∃ c > 0, ∃ i : ι, p i ∧ ∀ x ∈ s i, ‖f x‖ ≤ c * ‖g' x‖ :=
flip Exists.imp h.exists_pos fun c h => by
simpa only [isBigOWith_iff, hb.eventually_iff, exists_prop] using h
#align asymptotics.is_O.exists_mem_basis Asymptotics.IsBigO.exists_mem_basis
theorem isBigOWith_inv (hc : 0 < c) : IsBigOWith c⁻¹ l f g ↔ ∀ᶠ x in l, c * ‖f x‖ ≤ ‖g x‖ := by
simp only [IsBigOWith_def, ← div_eq_inv_mul, le_div_iff' hc]
#align asymptotics.is_O_with_inv Asymptotics.isBigOWith_inv
-- We prove this lemma with strange assumptions to get two lemmas below automatically
theorem isLittleO_iff_nat_mul_le_aux (h₀ : (∀ x, 0 ≤ ‖f x‖) ∨ ∀ x, 0 ≤ ‖g x‖) :
f =o[l] g ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f x‖ ≤ ‖g x‖ := by
constructor
· rintro H (_ | n)
· refine (H.def one_pos).mono fun x h₀' => ?_
rw [Nat.cast_zero, zero_mul]
refine h₀.elim (fun hf => (hf x).trans ?_) fun hg => hg x
rwa [one_mul] at h₀'
· have : (0 : ℝ) < n.succ := Nat.cast_pos.2 n.succ_pos
exact (isBigOWith_inv this).1 (H.def' <| inv_pos.2 this)
· refine fun H => isLittleO_iff.2 fun ε ε0 => ?_
rcases exists_nat_gt ε⁻¹ with ⟨n, hn⟩
have hn₀ : (0 : ℝ) < n := (inv_pos.2 ε0).trans hn
refine ((isBigOWith_inv hn₀).2 (H n)).bound.mono fun x hfg => ?_
refine hfg.trans (mul_le_mul_of_nonneg_right (inv_le_of_inv_le ε0 hn.le) ?_)
refine h₀.elim (fun hf => nonneg_of_mul_nonneg_right ((hf x).trans hfg) ?_) fun h => h x
exact inv_pos.2 hn₀
#align asymptotics.is_o_iff_nat_mul_le_aux Asymptotics.isLittleO_iff_nat_mul_le_aux
theorem isLittleO_iff_nat_mul_le : f =o[l] g' ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f x‖ ≤ ‖g' x‖ :=
isLittleO_iff_nat_mul_le_aux (Or.inr fun _x => norm_nonneg _)
#align asymptotics.is_o_iff_nat_mul_le Asymptotics.isLittleO_iff_nat_mul_le
theorem isLittleO_iff_nat_mul_le' : f' =o[l] g ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖f' x‖ ≤ ‖g x‖ :=
isLittleO_iff_nat_mul_le_aux (Or.inl fun _x => norm_nonneg _)
#align asymptotics.is_o_iff_nat_mul_le' Asymptotics.isLittleO_iff_nat_mul_le'
/-! ### Subsingleton -/
@[nontriviality]
theorem isLittleO_of_subsingleton [Subsingleton E'] : f' =o[l] g' :=
IsLittleO.of_bound fun c hc => by simp [Subsingleton.elim (f' _) 0, mul_nonneg hc.le]
#align asymptotics.is_o_of_subsingleton Asymptotics.isLittleO_of_subsingleton
@[nontriviality]
theorem isBigO_of_subsingleton [Subsingleton E'] : f' =O[l] g' :=
isLittleO_of_subsingleton.isBigO
#align asymptotics.is_O_of_subsingleton Asymptotics.isBigO_of_subsingleton
section congr
variable {f₁ f₂ : α → E} {g₁ g₂ : α → F}
/-! ### Congruence -/
theorem isBigOWith_congr (hc : c₁ = c₂) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) :
IsBigOWith c₁ l f₁ g₁ ↔ IsBigOWith c₂ l f₂ g₂ := by
simp only [IsBigOWith_def]
subst c₂
apply Filter.eventually_congr
filter_upwards [hf, hg] with _ e₁ e₂
rw [e₁, e₂]
#align asymptotics.is_O_with_congr Asymptotics.isBigOWith_congr
theorem IsBigOWith.congr' (h : IsBigOWith c₁ l f₁ g₁) (hc : c₁ = c₂) (hf : f₁ =ᶠ[l] f₂)
(hg : g₁ =ᶠ[l] g₂) : IsBigOWith c₂ l f₂ g₂ :=
(isBigOWith_congr hc hf hg).mp h
#align asymptotics.is_O_with.congr' Asymptotics.IsBigOWith.congr'
theorem IsBigOWith.congr (h : IsBigOWith c₁ l f₁ g₁) (hc : c₁ = c₂) (hf : ∀ x, f₁ x = f₂ x)
(hg : ∀ x, g₁ x = g₂ x) : IsBigOWith c₂ l f₂ g₂ :=
h.congr' hc (univ_mem' hf) (univ_mem' hg)
#align asymptotics.is_O_with.congr Asymptotics.IsBigOWith.congr
theorem IsBigOWith.congr_left (h : IsBigOWith c l f₁ g) (hf : ∀ x, f₁ x = f₂ x) :
IsBigOWith c l f₂ g :=
h.congr rfl hf fun _ => rfl
#align asymptotics.is_O_with.congr_left Asymptotics.IsBigOWith.congr_left
theorem IsBigOWith.congr_right (h : IsBigOWith c l f g₁) (hg : ∀ x, g₁ x = g₂ x) :
IsBigOWith c l f g₂ :=
h.congr rfl (fun _ => rfl) hg
#align asymptotics.is_O_with.congr_right Asymptotics.IsBigOWith.congr_right
theorem IsBigOWith.congr_const (h : IsBigOWith c₁ l f g) (hc : c₁ = c₂) : IsBigOWith c₂ l f g :=
h.congr hc (fun _ => rfl) fun _ => rfl
#align asymptotics.is_O_with.congr_const Asymptotics.IsBigOWith.congr_const
theorem isBigO_congr (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₁ =O[l] g₁ ↔ f₂ =O[l] g₂ := by
simp only [IsBigO_def]
exact exists_congr fun c => isBigOWith_congr rfl hf hg
#align asymptotics.is_O_congr Asymptotics.isBigO_congr
theorem IsBigO.congr' (h : f₁ =O[l] g₁) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₂ =O[l] g₂ :=
(isBigO_congr hf hg).mp h
#align asymptotics.is_O.congr' Asymptotics.IsBigO.congr'
theorem IsBigO.congr (h : f₁ =O[l] g₁) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) :
f₂ =O[l] g₂ :=
h.congr' (univ_mem' hf) (univ_mem' hg)
#align asymptotics.is_O.congr Asymptotics.IsBigO.congr
theorem IsBigO.congr_left (h : f₁ =O[l] g) (hf : ∀ x, f₁ x = f₂ x) : f₂ =O[l] g :=
h.congr hf fun _ => rfl
#align asymptotics.is_O.congr_left Asymptotics.IsBigO.congr_left
theorem IsBigO.congr_right (h : f =O[l] g₁) (hg : ∀ x, g₁ x = g₂ x) : f =O[l] g₂ :=
h.congr (fun _ => rfl) hg
#align asymptotics.is_O.congr_right Asymptotics.IsBigO.congr_right
theorem isLittleO_congr (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₁ =o[l] g₁ ↔ f₂ =o[l] g₂ := by
simp only [IsLittleO_def]
exact forall₂_congr fun c _hc => isBigOWith_congr (Eq.refl c) hf hg
#align asymptotics.is_o_congr Asymptotics.isLittleO_congr
theorem IsLittleO.congr' (h : f₁ =o[l] g₁) (hf : f₁ =ᶠ[l] f₂) (hg : g₁ =ᶠ[l] g₂) : f₂ =o[l] g₂ :=
(isLittleO_congr hf hg).mp h
#align asymptotics.is_o.congr' Asymptotics.IsLittleO.congr'
theorem IsLittleO.congr (h : f₁ =o[l] g₁) (hf : ∀ x, f₁ x = f₂ x) (hg : ∀ x, g₁ x = g₂ x) :
f₂ =o[l] g₂ :=
h.congr' (univ_mem' hf) (univ_mem' hg)
#align asymptotics.is_o.congr Asymptotics.IsLittleO.congr
theorem IsLittleO.congr_left (h : f₁ =o[l] g) (hf : ∀ x, f₁ x = f₂ x) : f₂ =o[l] g :=
h.congr hf fun _ => rfl
#align asymptotics.is_o.congr_left Asymptotics.IsLittleO.congr_left
theorem IsLittleO.congr_right (h : f =o[l] g₁) (hg : ∀ x, g₁ x = g₂ x) : f =o[l] g₂ :=
h.congr (fun _ => rfl) hg
#align asymptotics.is_o.congr_right Asymptotics.IsLittleO.congr_right
@[trans]
theorem _root_.Filter.EventuallyEq.trans_isBigO {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂)
(h : f₂ =O[l] g) : f₁ =O[l] g :=
h.congr' hf.symm EventuallyEq.rfl
#align filter.eventually_eq.trans_is_O Filter.EventuallyEq.trans_isBigO
instance transEventuallyEqIsBigO :
@Trans (α → E) (α → E) (α → F) (· =ᶠ[l] ·) (· =O[l] ·) (· =O[l] ·) where
trans := Filter.EventuallyEq.trans_isBigO
@[trans]
theorem _root_.Filter.EventuallyEq.trans_isLittleO {f₁ f₂ : α → E} {g : α → F} (hf : f₁ =ᶠ[l] f₂)
(h : f₂ =o[l] g) : f₁ =o[l] g :=
h.congr' hf.symm EventuallyEq.rfl
#align filter.eventually_eq.trans_is_o Filter.EventuallyEq.trans_isLittleO
instance transEventuallyEqIsLittleO :
@Trans (α → E) (α → E) (α → F) (· =ᶠ[l] ·) (· =o[l] ·) (· =o[l] ·) where
trans := Filter.EventuallyEq.trans_isLittleO
@[trans]
theorem IsBigO.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =O[l] g₁) (hg : g₁ =ᶠ[l] g₂) :
f =O[l] g₂ :=
h.congr' EventuallyEq.rfl hg
#align asymptotics.is_O.trans_eventually_eq Asymptotics.IsBigO.trans_eventuallyEq
instance transIsBigOEventuallyEq :
@Trans (α → E) (α → F) (α → F) (· =O[l] ·) (· =ᶠ[l] ·) (· =O[l] ·) where
trans := IsBigO.trans_eventuallyEq
@[trans]
theorem IsLittleO.trans_eventuallyEq {f : α → E} {g₁ g₂ : α → F} (h : f =o[l] g₁)
(hg : g₁ =ᶠ[l] g₂) : f =o[l] g₂ :=
h.congr' EventuallyEq.rfl hg
#align asymptotics.is_o.trans_eventually_eq Asymptotics.IsLittleO.trans_eventuallyEq
instance transIsLittleOEventuallyEq :
@Trans (α → E) (α → F) (α → F) (· =o[l] ·) (· =ᶠ[l] ·) (· =o[l] ·) where
trans := IsLittleO.trans_eventuallyEq
end congr
/-! ### Filter operations and transitivity -/
theorem IsBigOWith.comp_tendsto (hcfg : IsBigOWith c l f g) {k : β → α} {l' : Filter β}
(hk : Tendsto k l' l) : IsBigOWith c l' (f ∘ k) (g ∘ k) :=
IsBigOWith.of_bound <| hk hcfg.bound
#align asymptotics.is_O_with.comp_tendsto Asymptotics.IsBigOWith.comp_tendsto
theorem IsBigO.comp_tendsto (hfg : f =O[l] g) {k : β → α} {l' : Filter β} (hk : Tendsto k l' l) :
(f ∘ k) =O[l'] (g ∘ k) :=
isBigO_iff_isBigOWith.2 <| hfg.isBigOWith.imp fun _c h => h.comp_tendsto hk
#align asymptotics.is_O.comp_tendsto Asymptotics.IsBigO.comp_tendsto
theorem IsLittleO.comp_tendsto (hfg : f =o[l] g) {k : β → α} {l' : Filter β} (hk : Tendsto k l' l) :
(f ∘ k) =o[l'] (g ∘ k) :=
IsLittleO.of_isBigOWith fun _c cpos => (hfg.forall_isBigOWith cpos).comp_tendsto hk
#align asymptotics.is_o.comp_tendsto Asymptotics.IsLittleO.comp_tendsto
@[simp]
theorem isBigOWith_map {k : β → α} {l : Filter β} :
IsBigOWith c (map k l) f g ↔ IsBigOWith c l (f ∘ k) (g ∘ k) := by
simp only [IsBigOWith_def]
exact eventually_map
#align asymptotics.is_O_with_map Asymptotics.isBigOWith_map
@[simp]
theorem isBigO_map {k : β → α} {l : Filter β} : f =O[map k l] g ↔ (f ∘ k) =O[l] (g ∘ k) := by
simp only [IsBigO_def, isBigOWith_map]
#align asymptotics.is_O_map Asymptotics.isBigO_map
@[simp]
theorem isLittleO_map {k : β → α} {l : Filter β} : f =o[map k l] g ↔ (f ∘ k) =o[l] (g ∘ k) := by
simp only [IsLittleO_def, isBigOWith_map]
#align asymptotics.is_o_map Asymptotics.isLittleO_map
theorem IsBigOWith.mono (h : IsBigOWith c l' f g) (hl : l ≤ l') : IsBigOWith c l f g :=
IsBigOWith.of_bound <| hl h.bound
#align asymptotics.is_O_with.mono Asymptotics.IsBigOWith.mono
theorem IsBigO.mono (h : f =O[l'] g) (hl : l ≤ l') : f =O[l] g :=
isBigO_iff_isBigOWith.2 <| h.isBigOWith.imp fun _c h => h.mono hl
#align asymptotics.is_O.mono Asymptotics.IsBigO.mono
theorem IsLittleO.mono (h : f =o[l'] g) (hl : l ≤ l') : f =o[l] g :=
IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).mono hl
#align asymptotics.is_o.mono Asymptotics.IsLittleO.mono
theorem IsBigOWith.trans (hfg : IsBigOWith c l f g) (hgk : IsBigOWith c' l g k) (hc : 0 ≤ c) :
IsBigOWith (c * c') l f k := by
simp only [IsBigOWith_def] at *
filter_upwards [hfg, hgk] with x hx hx'
calc
‖f x‖ ≤ c * ‖g x‖ := hx
_ ≤ c * (c' * ‖k x‖) := by gcongr
_ = c * c' * ‖k x‖ := (mul_assoc _ _ _).symm
#align asymptotics.is_O_with.trans Asymptotics.IsBigOWith.trans
@[trans]
theorem IsBigO.trans {f : α → E} {g : α → F'} {k : α → G} (hfg : f =O[l] g) (hgk : g =O[l] k) :
f =O[l] k :=
let ⟨_c, cnonneg, hc⟩ := hfg.exists_nonneg
let ⟨_c', hc'⟩ := hgk.isBigOWith
(hc.trans hc' cnonneg).isBigO
#align asymptotics.is_O.trans Asymptotics.IsBigO.trans
instance transIsBigOIsBigO :
@Trans (α → E) (α → F') (α → G) (· =O[l] ·) (· =O[l] ·) (· =O[l] ·) where
trans := IsBigO.trans
theorem IsLittleO.trans_isBigOWith (hfg : f =o[l] g) (hgk : IsBigOWith c l g k) (hc : 0 < c) :
f =o[l] k := by
simp only [IsLittleO_def] at *
intro c' c'pos
have : 0 < c' / c := div_pos c'pos hc
exact ((hfg this).trans hgk this.le).congr_const (div_mul_cancel₀ _ hc.ne')
#align asymptotics.is_o.trans_is_O_with Asymptotics.IsLittleO.trans_isBigOWith
@[trans]
theorem IsLittleO.trans_isBigO {f : α → E} {g : α → F} {k : α → G'} (hfg : f =o[l] g)
(hgk : g =O[l] k) : f =o[l] k :=
let ⟨_c, cpos, hc⟩ := hgk.exists_pos
hfg.trans_isBigOWith hc cpos
#align asymptotics.is_o.trans_is_O Asymptotics.IsLittleO.trans_isBigO
instance transIsLittleOIsBigO :
@Trans (α → E) (α → F) (α → G') (· =o[l] ·) (· =O[l] ·) (· =o[l] ·) where
trans := IsLittleO.trans_isBigO
theorem IsBigOWith.trans_isLittleO (hfg : IsBigOWith c l f g) (hgk : g =o[l] k) (hc : 0 < c) :
f =o[l] k := by
simp only [IsLittleO_def] at *
intro c' c'pos
have : 0 < c' / c := div_pos c'pos hc
exact (hfg.trans (hgk this) hc.le).congr_const (mul_div_cancel₀ _ hc.ne')
#align asymptotics.is_O_with.trans_is_o Asymptotics.IsBigOWith.trans_isLittleO
@[trans]
theorem IsBigO.trans_isLittleO {f : α → E} {g : α → F'} {k : α → G} (hfg : f =O[l] g)
(hgk : g =o[l] k) : f =o[l] k :=
let ⟨_c, cpos, hc⟩ := hfg.exists_pos
hc.trans_isLittleO hgk cpos
#align asymptotics.is_O.trans_is_o Asymptotics.IsBigO.trans_isLittleO
instance transIsBigOIsLittleO :
@Trans (α → E) (α → F') (α → G) (· =O[l] ·) (· =o[l] ·) (· =o[l] ·) where
trans := IsBigO.trans_isLittleO
@[trans]
theorem IsLittleO.trans {f : α → E} {g : α → F} {k : α → G} (hfg : f =o[l] g) (hgk : g =o[l] k) :
f =o[l] k :=
hfg.trans_isBigOWith hgk.isBigOWith one_pos
#align asymptotics.is_o.trans Asymptotics.IsLittleO.trans
instance transIsLittleOIsLittleO :
@Trans (α → E) (α → F) (α → G) (· =o[l] ·) (· =o[l] ·) (· =o[l] ·) where
trans := IsLittleO.trans
theorem _root_.Filter.Eventually.trans_isBigO {f : α → E} {g : α → F'} {k : α → G}
(hfg : ∀ᶠ x in l, ‖f x‖ ≤ ‖g x‖) (hgk : g =O[l] k) : f =O[l] k :=
(IsBigO.of_bound' hfg).trans hgk
#align filter.eventually.trans_is_O Filter.Eventually.trans_isBigO
theorem _root_.Filter.Eventually.isBigO {f : α → E} {g : α → ℝ} {l : Filter α}
(hfg : ∀ᶠ x in l, ‖f x‖ ≤ g x) : f =O[l] g :=
IsBigO.of_bound' <| hfg.mono fun _x hx => hx.trans <| Real.le_norm_self _
#align filter.eventually.is_O Filter.Eventually.isBigO
section
variable (l)
theorem isBigOWith_of_le' (hfg : ∀ x, ‖f x‖ ≤ c * ‖g x‖) : IsBigOWith c l f g :=
IsBigOWith.of_bound <| univ_mem' hfg
#align asymptotics.is_O_with_of_le' Asymptotics.isBigOWith_of_le'
theorem isBigOWith_of_le (hfg : ∀ x, ‖f x‖ ≤ ‖g x‖) : IsBigOWith 1 l f g :=
isBigOWith_of_le' l fun x => by
rw [one_mul]
exact hfg x
#align asymptotics.is_O_with_of_le Asymptotics.isBigOWith_of_le
theorem isBigO_of_le' (hfg : ∀ x, ‖f x‖ ≤ c * ‖g x‖) : f =O[l] g :=
(isBigOWith_of_le' l hfg).isBigO
#align asymptotics.is_O_of_le' Asymptotics.isBigO_of_le'
theorem isBigO_of_le (hfg : ∀ x, ‖f x‖ ≤ ‖g x‖) : f =O[l] g :=
(isBigOWith_of_le l hfg).isBigO
#align asymptotics.is_O_of_le Asymptotics.isBigO_of_le
end
theorem isBigOWith_refl (f : α → E) (l : Filter α) : IsBigOWith 1 l f f :=
isBigOWith_of_le l fun _ => le_rfl
#align asymptotics.is_O_with_refl Asymptotics.isBigOWith_refl
theorem isBigO_refl (f : α → E) (l : Filter α) : f =O[l] f :=
(isBigOWith_refl f l).isBigO
#align asymptotics.is_O_refl Asymptotics.isBigO_refl
theorem _root_.Filter.EventuallyEq.isBigO {f₁ f₂ : α → E} (hf : f₁ =ᶠ[l] f₂) : f₁ =O[l] f₂ :=
hf.trans_isBigO (isBigO_refl _ _)
theorem IsBigOWith.trans_le (hfg : IsBigOWith c l f g) (hgk : ∀ x, ‖g x‖ ≤ ‖k x‖) (hc : 0 ≤ c) :
IsBigOWith c l f k :=
(hfg.trans (isBigOWith_of_le l hgk) hc).congr_const <| mul_one c
#align asymptotics.is_O_with.trans_le Asymptotics.IsBigOWith.trans_le
theorem IsBigO.trans_le (hfg : f =O[l] g') (hgk : ∀ x, ‖g' x‖ ≤ ‖k x‖) : f =O[l] k :=
hfg.trans (isBigO_of_le l hgk)
#align asymptotics.is_O.trans_le Asymptotics.IsBigO.trans_le
theorem IsLittleO.trans_le (hfg : f =o[l] g) (hgk : ∀ x, ‖g x‖ ≤ ‖k x‖) : f =o[l] k :=
hfg.trans_isBigOWith (isBigOWith_of_le _ hgk) zero_lt_one
#align asymptotics.is_o.trans_le Asymptotics.IsLittleO.trans_le
theorem isLittleO_irrefl' (h : ∃ᶠ x in l, ‖f' x‖ ≠ 0) : ¬f' =o[l] f' := by
intro ho
rcases ((ho.bound one_half_pos).and_frequently h).exists with ⟨x, hle, hne⟩
rw [one_div, ← div_eq_inv_mul] at hle
exact (half_lt_self (lt_of_le_of_ne (norm_nonneg _) hne.symm)).not_le hle
#align asymptotics.is_o_irrefl' Asymptotics.isLittleO_irrefl'
theorem isLittleO_irrefl (h : ∃ᶠ x in l, f'' x ≠ 0) : ¬f'' =o[l] f'' :=
isLittleO_irrefl' <| h.mono fun _x => norm_ne_zero_iff.mpr
#align asymptotics.is_o_irrefl Asymptotics.isLittleO_irrefl
theorem IsBigO.not_isLittleO (h : f'' =O[l] g') (hf : ∃ᶠ x in l, f'' x ≠ 0) :
¬g' =o[l] f'' := fun h' =>
isLittleO_irrefl hf (h.trans_isLittleO h')
#align asymptotics.is_O.not_is_o Asymptotics.IsBigO.not_isLittleO
theorem IsLittleO.not_isBigO (h : f'' =o[l] g') (hf : ∃ᶠ x in l, f'' x ≠ 0) :
¬g' =O[l] f'' := fun h' =>
isLittleO_irrefl hf (h.trans_isBigO h')
#align asymptotics.is_o.not_is_O Asymptotics.IsLittleO.not_isBigO
section Bot
variable (c f g)
@[simp]
theorem isBigOWith_bot : IsBigOWith c ⊥ f g :=
IsBigOWith.of_bound <| trivial
#align asymptotics.is_O_with_bot Asymptotics.isBigOWith_bot
@[simp]
theorem isBigO_bot : f =O[⊥] g :=
(isBigOWith_bot 1 f g).isBigO
#align asymptotics.is_O_bot Asymptotics.isBigO_bot
@[simp]
theorem isLittleO_bot : f =o[⊥] g :=
IsLittleO.of_isBigOWith fun c _ => isBigOWith_bot c f g
#align asymptotics.is_o_bot Asymptotics.isLittleO_bot
end Bot
@[simp]
theorem isBigOWith_pure {x} : IsBigOWith c (pure x) f g ↔ ‖f x‖ ≤ c * ‖g x‖ :=
isBigOWith_iff
#align asymptotics.is_O_with_pure Asymptotics.isBigOWith_pure
theorem IsBigOWith.sup (h : IsBigOWith c l f g) (h' : IsBigOWith c l' f g) :
IsBigOWith c (l ⊔ l') f g :=
IsBigOWith.of_bound <| mem_sup.2 ⟨h.bound, h'.bound⟩
#align asymptotics.is_O_with.sup Asymptotics.IsBigOWith.sup
theorem IsBigOWith.sup' (h : IsBigOWith c l f g') (h' : IsBigOWith c' l' f g') :
IsBigOWith (max c c') (l ⊔ l') f g' :=
IsBigOWith.of_bound <|
mem_sup.2 ⟨(h.weaken <| le_max_left c c').bound, (h'.weaken <| le_max_right c c').bound⟩
#align asymptotics.is_O_with.sup' Asymptotics.IsBigOWith.sup'
theorem IsBigO.sup (h : f =O[l] g') (h' : f =O[l'] g') : f =O[l ⊔ l'] g' :=
let ⟨_c, hc⟩ := h.isBigOWith
let ⟨_c', hc'⟩ := h'.isBigOWith
(hc.sup' hc').isBigO
#align asymptotics.is_O.sup Asymptotics.IsBigO.sup
theorem IsLittleO.sup (h : f =o[l] g) (h' : f =o[l'] g) : f =o[l ⊔ l'] g :=
IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).sup (h'.forall_isBigOWith cpos)
#align asymptotics.is_o.sup Asymptotics.IsLittleO.sup
@[simp]
theorem isBigO_sup : f =O[l ⊔ l'] g' ↔ f =O[l] g' ∧ f =O[l'] g' :=
⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩
#align asymptotics.is_O_sup Asymptotics.isBigO_sup
@[simp]
theorem isLittleO_sup : f =o[l ⊔ l'] g ↔ f =o[l] g ∧ f =o[l'] g :=
⟨fun h => ⟨h.mono le_sup_left, h.mono le_sup_right⟩, fun h => h.1.sup h.2⟩
#align asymptotics.is_o_sup Asymptotics.isLittleO_sup
theorem isBigOWith_insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E} {g' : α → F}
(h : ‖g x‖ ≤ C * ‖g' x‖) : IsBigOWith C (𝓝[insert x s] x) g g' ↔
IsBigOWith C (𝓝[s] x) g g' := by
simp_rw [IsBigOWith_def, nhdsWithin_insert, eventually_sup, eventually_pure, h, true_and_iff]
#align asymptotics.is_O_with_insert Asymptotics.isBigOWith_insert
protected theorem IsBigOWith.insert [TopologicalSpace α] {x : α} {s : Set α} {C : ℝ} {g : α → E}
{g' : α → F} (h1 : IsBigOWith C (𝓝[s] x) g g') (h2 : ‖g x‖ ≤ C * ‖g' x‖) :
IsBigOWith C (𝓝[insert x s] x) g g' :=
(isBigOWith_insert h2).mpr h1
#align asymptotics.is_O_with.insert Asymptotics.IsBigOWith.insert
theorem isLittleO_insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'} {g' : α → F'}
(h : g x = 0) : g =o[𝓝[insert x s] x] g' ↔ g =o[𝓝[s] x] g' := by
simp_rw [IsLittleO_def]
refine forall_congr' fun c => forall_congr' fun hc => ?_
rw [isBigOWith_insert]
rw [h, norm_zero]
exact mul_nonneg hc.le (norm_nonneg _)
#align asymptotics.is_o_insert Asymptotics.isLittleO_insert
protected theorem IsLittleO.insert [TopologicalSpace α] {x : α} {s : Set α} {g : α → E'}
{g' : α → F'} (h1 : g =o[𝓝[s] x] g') (h2 : g x = 0) : g =o[𝓝[insert x s] x] g' :=
(isLittleO_insert h2).mpr h1
#align asymptotics.is_o.insert Asymptotics.IsLittleO.insert
/-! ### Simplification : norm, abs -/
section NormAbs
variable {u v : α → ℝ}
@[simp]
theorem isBigOWith_norm_right : (IsBigOWith c l f fun x => ‖g' x‖) ↔ IsBigOWith c l f g' := by
simp only [IsBigOWith_def, norm_norm]
#align asymptotics.is_O_with_norm_right Asymptotics.isBigOWith_norm_right
@[simp]
theorem isBigOWith_abs_right : (IsBigOWith c l f fun x => |u x|) ↔ IsBigOWith c l f u :=
@isBigOWith_norm_right _ _ _ _ _ _ f u l
#align asymptotics.is_O_with_abs_right Asymptotics.isBigOWith_abs_right
alias ⟨IsBigOWith.of_norm_right, IsBigOWith.norm_right⟩ := isBigOWith_norm_right
#align asymptotics.is_O_with.of_norm_right Asymptotics.IsBigOWith.of_norm_right
#align asymptotics.is_O_with.norm_right Asymptotics.IsBigOWith.norm_right
alias ⟨IsBigOWith.of_abs_right, IsBigOWith.abs_right⟩ := isBigOWith_abs_right
#align asymptotics.is_O_with.of_abs_right Asymptotics.IsBigOWith.of_abs_right
#align asymptotics.is_O_with.abs_right Asymptotics.IsBigOWith.abs_right
@[simp]
theorem isBigO_norm_right : (f =O[l] fun x => ‖g' x‖) ↔ f =O[l] g' := by
simp only [IsBigO_def]
exact exists_congr fun _ => isBigOWith_norm_right
#align asymptotics.is_O_norm_right Asymptotics.isBigO_norm_right
@[simp]
theorem isBigO_abs_right : (f =O[l] fun x => |u x|) ↔ f =O[l] u :=
@isBigO_norm_right _ _ ℝ _ _ _ _ _
#align asymptotics.is_O_abs_right Asymptotics.isBigO_abs_right
alias ⟨IsBigO.of_norm_right, IsBigO.norm_right⟩ := isBigO_norm_right
#align asymptotics.is_O.of_norm_right Asymptotics.IsBigO.of_norm_right
#align asymptotics.is_O.norm_right Asymptotics.IsBigO.norm_right
alias ⟨IsBigO.of_abs_right, IsBigO.abs_right⟩ := isBigO_abs_right
#align asymptotics.is_O.of_abs_right Asymptotics.IsBigO.of_abs_right
#align asymptotics.is_O.abs_right Asymptotics.IsBigO.abs_right
@[simp]
theorem isLittleO_norm_right : (f =o[l] fun x => ‖g' x‖) ↔ f =o[l] g' := by
simp only [IsLittleO_def]
exact forall₂_congr fun _ _ => isBigOWith_norm_right
#align asymptotics.is_o_norm_right Asymptotics.isLittleO_norm_right
@[simp]
theorem isLittleO_abs_right : (f =o[l] fun x => |u x|) ↔ f =o[l] u :=
@isLittleO_norm_right _ _ ℝ _ _ _ _ _
#align asymptotics.is_o_abs_right Asymptotics.isLittleO_abs_right
alias ⟨IsLittleO.of_norm_right, IsLittleO.norm_right⟩ := isLittleO_norm_right
#align asymptotics.is_o.of_norm_right Asymptotics.IsLittleO.of_norm_right
#align asymptotics.is_o.norm_right Asymptotics.IsLittleO.norm_right
alias ⟨IsLittleO.of_abs_right, IsLittleO.abs_right⟩ := isLittleO_abs_right
#align asymptotics.is_o.of_abs_right Asymptotics.IsLittleO.of_abs_right
#align asymptotics.is_o.abs_right Asymptotics.IsLittleO.abs_right
@[simp]
theorem isBigOWith_norm_left : IsBigOWith c l (fun x => ‖f' x‖) g ↔ IsBigOWith c l f' g := by
simp only [IsBigOWith_def, norm_norm]
#align asymptotics.is_O_with_norm_left Asymptotics.isBigOWith_norm_left
@[simp]
theorem isBigOWith_abs_left : IsBigOWith c l (fun x => |u x|) g ↔ IsBigOWith c l u g :=
@isBigOWith_norm_left _ _ _ _ _ _ g u l
#align asymptotics.is_O_with_abs_left Asymptotics.isBigOWith_abs_left
alias ⟨IsBigOWith.of_norm_left, IsBigOWith.norm_left⟩ := isBigOWith_norm_left
#align asymptotics.is_O_with.of_norm_left Asymptotics.IsBigOWith.of_norm_left
#align asymptotics.is_O_with.norm_left Asymptotics.IsBigOWith.norm_left
alias ⟨IsBigOWith.of_abs_left, IsBigOWith.abs_left⟩ := isBigOWith_abs_left
#align asymptotics.is_O_with.of_abs_left Asymptotics.IsBigOWith.of_abs_left
#align asymptotics.is_O_with.abs_left Asymptotics.IsBigOWith.abs_left
@[simp]
theorem isBigO_norm_left : (fun x => ‖f' x‖) =O[l] g ↔ f' =O[l] g := by
simp only [IsBigO_def]
exact exists_congr fun _ => isBigOWith_norm_left
#align asymptotics.is_O_norm_left Asymptotics.isBigO_norm_left
@[simp]
theorem isBigO_abs_left : (fun x => |u x|) =O[l] g ↔ u =O[l] g :=
@isBigO_norm_left _ _ _ _ _ g u l
#align asymptotics.is_O_abs_left Asymptotics.isBigO_abs_left
alias ⟨IsBigO.of_norm_left, IsBigO.norm_left⟩ := isBigO_norm_left
#align asymptotics.is_O.of_norm_left Asymptotics.IsBigO.of_norm_left
#align asymptotics.is_O.norm_left Asymptotics.IsBigO.norm_left
alias ⟨IsBigO.of_abs_left, IsBigO.abs_left⟩ := isBigO_abs_left
#align asymptotics.is_O.of_abs_left Asymptotics.IsBigO.of_abs_left
#align asymptotics.is_O.abs_left Asymptotics.IsBigO.abs_left
@[simp]
theorem isLittleO_norm_left : (fun x => ‖f' x‖) =o[l] g ↔ f' =o[l] g := by
simp only [IsLittleO_def]
exact forall₂_congr fun _ _ => isBigOWith_norm_left
#align asymptotics.is_o_norm_left Asymptotics.isLittleO_norm_left
@[simp]
theorem isLittleO_abs_left : (fun x => |u x|) =o[l] g ↔ u =o[l] g :=
@isLittleO_norm_left _ _ _ _ _ g u l
#align asymptotics.is_o_abs_left Asymptotics.isLittleO_abs_left
alias ⟨IsLittleO.of_norm_left, IsLittleO.norm_left⟩ := isLittleO_norm_left
#align asymptotics.is_o.of_norm_left Asymptotics.IsLittleO.of_norm_left
#align asymptotics.is_o.norm_left Asymptotics.IsLittleO.norm_left
alias ⟨IsLittleO.of_abs_left, IsLittleO.abs_left⟩ := isLittleO_abs_left
#align asymptotics.is_o.of_abs_left Asymptotics.IsLittleO.of_abs_left
#align asymptotics.is_o.abs_left Asymptotics.IsLittleO.abs_left
theorem isBigOWith_norm_norm :
(IsBigOWith c l (fun x => ‖f' x‖) fun x => ‖g' x‖) ↔ IsBigOWith c l f' g' :=
isBigOWith_norm_left.trans isBigOWith_norm_right
#align asymptotics.is_O_with_norm_norm Asymptotics.isBigOWith_norm_norm
theorem isBigOWith_abs_abs :
(IsBigOWith c l (fun x => |u x|) fun x => |v x|) ↔ IsBigOWith c l u v :=
isBigOWith_abs_left.trans isBigOWith_abs_right
#align asymptotics.is_O_with_abs_abs Asymptotics.isBigOWith_abs_abs
alias ⟨IsBigOWith.of_norm_norm, IsBigOWith.norm_norm⟩ := isBigOWith_norm_norm
#align asymptotics.is_O_with.of_norm_norm Asymptotics.IsBigOWith.of_norm_norm
#align asymptotics.is_O_with.norm_norm Asymptotics.IsBigOWith.norm_norm
alias ⟨IsBigOWith.of_abs_abs, IsBigOWith.abs_abs⟩ := isBigOWith_abs_abs
#align asymptotics.is_O_with.of_abs_abs Asymptotics.IsBigOWith.of_abs_abs
#align asymptotics.is_O_with.abs_abs Asymptotics.IsBigOWith.abs_abs
theorem isBigO_norm_norm : ((fun x => ‖f' x‖) =O[l] fun x => ‖g' x‖) ↔ f' =O[l] g' :=
isBigO_norm_left.trans isBigO_norm_right
#align asymptotics.is_O_norm_norm Asymptotics.isBigO_norm_norm
theorem isBigO_abs_abs : ((fun x => |u x|) =O[l] fun x => |v x|) ↔ u =O[l] v :=
isBigO_abs_left.trans isBigO_abs_right
#align asymptotics.is_O_abs_abs Asymptotics.isBigO_abs_abs
alias ⟨IsBigO.of_norm_norm, IsBigO.norm_norm⟩ := isBigO_norm_norm
#align asymptotics.is_O.of_norm_norm Asymptotics.IsBigO.of_norm_norm
#align asymptotics.is_O.norm_norm Asymptotics.IsBigO.norm_norm
alias ⟨IsBigO.of_abs_abs, IsBigO.abs_abs⟩ := isBigO_abs_abs
#align asymptotics.is_O.of_abs_abs Asymptotics.IsBigO.of_abs_abs
#align asymptotics.is_O.abs_abs Asymptotics.IsBigO.abs_abs
theorem isLittleO_norm_norm : ((fun x => ‖f' x‖) =o[l] fun x => ‖g' x‖) ↔ f' =o[l] g' :=
isLittleO_norm_left.trans isLittleO_norm_right
#align asymptotics.is_o_norm_norm Asymptotics.isLittleO_norm_norm
theorem isLittleO_abs_abs : ((fun x => |u x|) =o[l] fun x => |v x|) ↔ u =o[l] v :=
isLittleO_abs_left.trans isLittleO_abs_right
#align asymptotics.is_o_abs_abs Asymptotics.isLittleO_abs_abs
alias ⟨IsLittleO.of_norm_norm, IsLittleO.norm_norm⟩ := isLittleO_norm_norm
#align asymptotics.is_o.of_norm_norm Asymptotics.IsLittleO.of_norm_norm
#align asymptotics.is_o.norm_norm Asymptotics.IsLittleO.norm_norm
alias ⟨IsLittleO.of_abs_abs, IsLittleO.abs_abs⟩ := isLittleO_abs_abs
#align asymptotics.is_o.of_abs_abs Asymptotics.IsLittleO.of_abs_abs
#align asymptotics.is_o.abs_abs Asymptotics.IsLittleO.abs_abs
end NormAbs
/-! ### Simplification: negate -/
@[simp]
theorem isBigOWith_neg_right : (IsBigOWith c l f fun x => -g' x) ↔ IsBigOWith c l f g' := by
simp only [IsBigOWith_def, norm_neg]
#align asymptotics.is_O_with_neg_right Asymptotics.isBigOWith_neg_right
alias ⟨IsBigOWith.of_neg_right, IsBigOWith.neg_right⟩ := isBigOWith_neg_right
#align asymptotics.is_O_with.of_neg_right Asymptotics.IsBigOWith.of_neg_right
#align asymptotics.is_O_with.neg_right Asymptotics.IsBigOWith.neg_right
@[simp]
theorem isBigO_neg_right : (f =O[l] fun x => -g' x) ↔ f =O[l] g' := by
simp only [IsBigO_def]
exact exists_congr fun _ => isBigOWith_neg_right
#align asymptotics.is_O_neg_right Asymptotics.isBigO_neg_right
alias ⟨IsBigO.of_neg_right, IsBigO.neg_right⟩ := isBigO_neg_right
#align asymptotics.is_O.of_neg_right Asymptotics.IsBigO.of_neg_right
#align asymptotics.is_O.neg_right Asymptotics.IsBigO.neg_right
@[simp]
theorem isLittleO_neg_right : (f =o[l] fun x => -g' x) ↔ f =o[l] g' := by
simp only [IsLittleO_def]
exact forall₂_congr fun _ _ => isBigOWith_neg_right
#align asymptotics.is_o_neg_right Asymptotics.isLittleO_neg_right
alias ⟨IsLittleO.of_neg_right, IsLittleO.neg_right⟩ := isLittleO_neg_right
#align asymptotics.is_o.of_neg_right Asymptotics.IsLittleO.of_neg_right
#align asymptotics.is_o.neg_right Asymptotics.IsLittleO.neg_right
@[simp]
theorem isBigOWith_neg_left : IsBigOWith c l (fun x => -f' x) g ↔ IsBigOWith c l f' g := by
simp only [IsBigOWith_def, norm_neg]
#align asymptotics.is_O_with_neg_left Asymptotics.isBigOWith_neg_left
alias ⟨IsBigOWith.of_neg_left, IsBigOWith.neg_left⟩ := isBigOWith_neg_left
#align asymptotics.is_O_with.of_neg_left Asymptotics.IsBigOWith.of_neg_left
#align asymptotics.is_O_with.neg_left Asymptotics.IsBigOWith.neg_left
@[simp]
theorem isBigO_neg_left : (fun x => -f' x) =O[l] g ↔ f' =O[l] g := by
simp only [IsBigO_def]
exact exists_congr fun _ => isBigOWith_neg_left
#align asymptotics.is_O_neg_left Asymptotics.isBigO_neg_left
alias ⟨IsBigO.of_neg_left, IsBigO.neg_left⟩ := isBigO_neg_left
#align asymptotics.is_O.of_neg_left Asymptotics.IsBigO.of_neg_left
#align asymptotics.is_O.neg_left Asymptotics.IsBigO.neg_left
@[simp]
theorem isLittleO_neg_left : (fun x => -f' x) =o[l] g ↔ f' =o[l] g := by
simp only [IsLittleO_def]
exact forall₂_congr fun _ _ => isBigOWith_neg_left
#align asymptotics.is_o_neg_left Asymptotics.isLittleO_neg_left
alias ⟨IsLittleO.of_neg_left, IsLittleO.neg_left⟩ := isLittleO_neg_left
#align asymptotics.is_o.of_neg_left Asymptotics.IsLittleO.of_neg_left
#align asymptotics.is_o.neg_left Asymptotics.IsLittleO.neg_left
/-! ### Product of functions (right) -/
theorem isBigOWith_fst_prod : IsBigOWith 1 l f' fun x => (f' x, g' x) :=
isBigOWith_of_le l fun _x => le_max_left _ _
#align asymptotics.is_O_with_fst_prod Asymptotics.isBigOWith_fst_prod
theorem isBigOWith_snd_prod : IsBigOWith 1 l g' fun x => (f' x, g' x) :=
isBigOWith_of_le l fun _x => le_max_right _ _
#align asymptotics.is_O_with_snd_prod Asymptotics.isBigOWith_snd_prod
theorem isBigO_fst_prod : f' =O[l] fun x => (f' x, g' x) :=
isBigOWith_fst_prod.isBigO
#align asymptotics.is_O_fst_prod Asymptotics.isBigO_fst_prod
theorem isBigO_snd_prod : g' =O[l] fun x => (f' x, g' x) :=
isBigOWith_snd_prod.isBigO
#align asymptotics.is_O_snd_prod Asymptotics.isBigO_snd_prod
theorem isBigO_fst_prod' {f' : α → E' × F'} : (fun x => (f' x).1) =O[l] f' := by
simpa [IsBigO_def, IsBigOWith_def] using isBigO_fst_prod (E' := E') (F' := F')
#align asymptotics.is_O_fst_prod' Asymptotics.isBigO_fst_prod'
theorem isBigO_snd_prod' {f' : α → E' × F'} : (fun x => (f' x).2) =O[l] f' := by
simpa [IsBigO_def, IsBigOWith_def] using isBigO_snd_prod (E' := E') (F' := F')
#align asymptotics.is_O_snd_prod' Asymptotics.isBigO_snd_prod'
section
variable (f' k')
theorem IsBigOWith.prod_rightl (h : IsBigOWith c l f g') (hc : 0 ≤ c) :
IsBigOWith c l f fun x => (g' x, k' x) :=
(h.trans isBigOWith_fst_prod hc).congr_const (mul_one c)
#align asymptotics.is_O_with.prod_rightl Asymptotics.IsBigOWith.prod_rightl
theorem IsBigO.prod_rightl (h : f =O[l] g') : f =O[l] fun x => (g' x, k' x) :=
let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg
(hc.prod_rightl k' cnonneg).isBigO
#align asymptotics.is_O.prod_rightl Asymptotics.IsBigO.prod_rightl
theorem IsLittleO.prod_rightl (h : f =o[l] g') : f =o[l] fun x => (g' x, k' x) :=
IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).prod_rightl k' cpos.le
#align asymptotics.is_o.prod_rightl Asymptotics.IsLittleO.prod_rightl
theorem IsBigOWith.prod_rightr (h : IsBigOWith c l f g') (hc : 0 ≤ c) :
IsBigOWith c l f fun x => (f' x, g' x) :=
(h.trans isBigOWith_snd_prod hc).congr_const (mul_one c)
#align asymptotics.is_O_with.prod_rightr Asymptotics.IsBigOWith.prod_rightr
theorem IsBigO.prod_rightr (h : f =O[l] g') : f =O[l] fun x => (f' x, g' x) :=
let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg
(hc.prod_rightr f' cnonneg).isBigO
#align asymptotics.is_O.prod_rightr Asymptotics.IsBigO.prod_rightr
theorem IsLittleO.prod_rightr (h : f =o[l] g') : f =o[l] fun x => (f' x, g' x) :=
IsLittleO.of_isBigOWith fun _c cpos => (h.forall_isBigOWith cpos).prod_rightr f' cpos.le
#align asymptotics.is_o.prod_rightr Asymptotics.IsLittleO.prod_rightr
end
theorem IsBigOWith.prod_left_same (hf : IsBigOWith c l f' k') (hg : IsBigOWith c l g' k') :
IsBigOWith c l (fun x => (f' x, g' x)) k' := by
rw [isBigOWith_iff] at *; filter_upwards [hf, hg] with x using max_le
#align asymptotics.is_O_with.prod_left_same Asymptotics.IsBigOWith.prod_left_same
theorem IsBigOWith.prod_left (hf : IsBigOWith c l f' k') (hg : IsBigOWith c' l g' k') :
IsBigOWith (max c c') l (fun x => (f' x, g' x)) k' :=
(hf.weaken <| le_max_left c c').prod_left_same (hg.weaken <| le_max_right c c')
#align asymptotics.is_O_with.prod_left Asymptotics.IsBigOWith.prod_left
theorem IsBigOWith.prod_left_fst (h : IsBigOWith c l (fun x => (f' x, g' x)) k') :
IsBigOWith c l f' k' :=
(isBigOWith_fst_prod.trans h zero_le_one).congr_const <| one_mul c
#align asymptotics.is_O_with.prod_left_fst Asymptotics.IsBigOWith.prod_left_fst
theorem IsBigOWith.prod_left_snd (h : IsBigOWith c l (fun x => (f' x, g' x)) k') :
IsBigOWith c l g' k' :=
(isBigOWith_snd_prod.trans h zero_le_one).congr_const <| one_mul c
#align asymptotics.is_O_with.prod_left_snd Asymptotics.IsBigOWith.prod_left_snd
theorem isBigOWith_prod_left :
IsBigOWith c l (fun x => (f' x, g' x)) k' ↔ IsBigOWith c l f' k' ∧ IsBigOWith c l g' k' :=
⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left_same h.2⟩
#align asymptotics.is_O_with_prod_left Asymptotics.isBigOWith_prod_left
theorem IsBigO.prod_left (hf : f' =O[l] k') (hg : g' =O[l] k') : (fun x => (f' x, g' x)) =O[l] k' :=
let ⟨_c, hf⟩ := hf.isBigOWith
let ⟨_c', hg⟩ := hg.isBigOWith
(hf.prod_left hg).isBigO
#align asymptotics.is_O.prod_left Asymptotics.IsBigO.prod_left
theorem IsBigO.prod_left_fst : (fun x => (f' x, g' x)) =O[l] k' → f' =O[l] k' :=
IsBigO.trans isBigO_fst_prod
#align asymptotics.is_O.prod_left_fst Asymptotics.IsBigO.prod_left_fst
theorem IsBigO.prod_left_snd : (fun x => (f' x, g' x)) =O[l] k' → g' =O[l] k' :=
IsBigO.trans isBigO_snd_prod
#align asymptotics.is_O.prod_left_snd Asymptotics.IsBigO.prod_left_snd
@[simp]
theorem isBigO_prod_left : (fun x => (f' x, g' x)) =O[l] k' ↔ f' =O[l] k' ∧ g' =O[l] k' :=
⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left h.2⟩
#align asymptotics.is_O_prod_left Asymptotics.isBigO_prod_left
theorem IsLittleO.prod_left (hf : f' =o[l] k') (hg : g' =o[l] k') :
(fun x => (f' x, g' x)) =o[l] k' :=
IsLittleO.of_isBigOWith fun _c hc =>
(hf.forall_isBigOWith hc).prod_left_same (hg.forall_isBigOWith hc)
#align asymptotics.is_o.prod_left Asymptotics.IsLittleO.prod_left
theorem IsLittleO.prod_left_fst : (fun x => (f' x, g' x)) =o[l] k' → f' =o[l] k' :=
IsBigO.trans_isLittleO isBigO_fst_prod
#align asymptotics.is_o.prod_left_fst Asymptotics.IsLittleO.prod_left_fst
theorem IsLittleO.prod_left_snd : (fun x => (f' x, g' x)) =o[l] k' → g' =o[l] k' :=
IsBigO.trans_isLittleO isBigO_snd_prod
#align asymptotics.is_o.prod_left_snd Asymptotics.IsLittleO.prod_left_snd
@[simp]
theorem isLittleO_prod_left : (fun x => (f' x, g' x)) =o[l] k' ↔ f' =o[l] k' ∧ g' =o[l] k' :=
⟨fun h => ⟨h.prod_left_fst, h.prod_left_snd⟩, fun h => h.1.prod_left h.2⟩
#align asymptotics.is_o_prod_left Asymptotics.isLittleO_prod_left
theorem IsBigOWith.eq_zero_imp (h : IsBigOWith c l f'' g'') : ∀ᶠ x in l, g'' x = 0 → f'' x = 0 :=
Eventually.mono h.bound fun x hx hg => norm_le_zero_iff.1 <| by simpa [hg] using hx
#align asymptotics.is_O_with.eq_zero_imp Asymptotics.IsBigOWith.eq_zero_imp
theorem IsBigO.eq_zero_imp (h : f'' =O[l] g'') : ∀ᶠ x in l, g'' x = 0 → f'' x = 0 :=
let ⟨_C, hC⟩ := h.isBigOWith
hC.eq_zero_imp
#align asymptotics.is_O.eq_zero_imp Asymptotics.IsBigO.eq_zero_imp
/-! ### Addition and subtraction -/
section add_sub
variable {f₁ f₂ : α → E'} {g₁ g₂ : α → F'}
theorem IsBigOWith.add (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : IsBigOWith c₂ l f₂ g) :
IsBigOWith (c₁ + c₂) l (fun x => f₁ x + f₂ x) g := by
rw [IsBigOWith_def] at *
filter_upwards [h₁, h₂] with x hx₁ hx₂ using
calc
‖f₁ x + f₂ x‖ ≤ c₁ * ‖g x‖ + c₂ * ‖g x‖ := norm_add_le_of_le hx₁ hx₂
_ = (c₁ + c₂) * ‖g x‖ := (add_mul _ _ _).symm
#align asymptotics.is_O_with.add Asymptotics.IsBigOWith.add
theorem IsBigO.add (h₁ : f₁ =O[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g :=
let ⟨_c₁, hc₁⟩ := h₁.isBigOWith
let ⟨_c₂, hc₂⟩ := h₂.isBigOWith
(hc₁.add hc₂).isBigO
#align asymptotics.is_O.add Asymptotics.IsBigO.add
theorem IsLittleO.add (h₁ : f₁ =o[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x + f₂ x) =o[l] g :=
IsLittleO.of_isBigOWith fun c cpos =>
((h₁.forall_isBigOWith <| half_pos cpos).add (h₂.forall_isBigOWith <|
half_pos cpos)).congr_const (add_halves c)
#align asymptotics.is_o.add Asymptotics.IsLittleO.add
theorem IsLittleO.add_add (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =o[l] g₂) :
(fun x => f₁ x + f₂ x) =o[l] fun x => ‖g₁ x‖ + ‖g₂ x‖ := by
refine (h₁.trans_le fun x => ?_).add (h₂.trans_le ?_) <;> simp [abs_of_nonneg, add_nonneg]
#align asymptotics.is_o.add_add Asymptotics.IsLittleO.add_add
theorem IsBigO.add_isLittleO (h₁ : f₁ =O[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x + f₂ x) =O[l] g :=
h₁.add h₂.isBigO
#align asymptotics.is_O.add_is_o Asymptotics.IsBigO.add_isLittleO
theorem IsLittleO.add_isBigO (h₁ : f₁ =o[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x + f₂ x) =O[l] g :=
h₁.isBigO.add h₂
#align asymptotics.is_o.add_is_O Asymptotics.IsLittleO.add_isBigO
theorem IsBigOWith.add_isLittleO (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : f₂ =o[l] g) (hc : c₁ < c₂) :
IsBigOWith c₂ l (fun x => f₁ x + f₂ x) g :=
(h₁.add (h₂.forall_isBigOWith (sub_pos.2 hc))).congr_const (add_sub_cancel _ _)
#align asymptotics.is_O_with.add_is_o Asymptotics.IsBigOWith.add_isLittleO
theorem IsLittleO.add_isBigOWith (h₁ : f₁ =o[l] g) (h₂ : IsBigOWith c₁ l f₂ g) (hc : c₁ < c₂) :
IsBigOWith c₂ l (fun x => f₁ x + f₂ x) g :=
(h₂.add_isLittleO h₁ hc).congr_left fun _ => add_comm _ _
#align asymptotics.is_o.add_is_O_with Asymptotics.IsLittleO.add_isBigOWith
theorem IsBigOWith.sub (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : IsBigOWith c₂ l f₂ g) :
IsBigOWith (c₁ + c₂) l (fun x => f₁ x - f₂ x) g := by
simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left
#align asymptotics.is_O_with.sub Asymptotics.IsBigOWith.sub
theorem IsBigOWith.sub_isLittleO (h₁ : IsBigOWith c₁ l f₁ g) (h₂ : f₂ =o[l] g) (hc : c₁ < c₂) :
IsBigOWith c₂ l (fun x => f₁ x - f₂ x) g := by
simpa only [sub_eq_add_neg] using h₁.add_isLittleO h₂.neg_left hc
#align asymptotics.is_O_with.sub_is_o Asymptotics.IsBigOWith.sub_isLittleO
theorem IsBigO.sub (h₁ : f₁ =O[l] g) (h₂ : f₂ =O[l] g) : (fun x => f₁ x - f₂ x) =O[l] g := by
simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left
#align asymptotics.is_O.sub Asymptotics.IsBigO.sub
theorem IsLittleO.sub (h₁ : f₁ =o[l] g) (h₂ : f₂ =o[l] g) : (fun x => f₁ x - f₂ x) =o[l] g := by
simpa only [sub_eq_add_neg] using h₁.add h₂.neg_left
#align asymptotics.is_o.sub Asymptotics.IsLittleO.sub
end add_sub
/-!
### Lemmas about `IsBigO (f₁ - f₂) g l` / `IsLittleO (f₁ - f₂) g l` treated as a binary relation
-/
section IsBigOOAsRel
variable {f₁ f₂ f₃ : α → E'}
theorem IsBigOWith.symm (h : IsBigOWith c l (fun x => f₁ x - f₂ x) g) :
IsBigOWith c l (fun x => f₂ x - f₁ x) g :=
h.neg_left.congr_left fun _x => neg_sub _ _
#align asymptotics.is_O_with.symm Asymptotics.IsBigOWith.symm
theorem isBigOWith_comm :
IsBigOWith c l (fun x => f₁ x - f₂ x) g ↔ IsBigOWith c l (fun x => f₂ x - f₁ x) g :=
⟨IsBigOWith.symm, IsBigOWith.symm⟩
#align asymptotics.is_O_with_comm Asymptotics.isBigOWith_comm
theorem IsBigO.symm (h : (fun x => f₁ x - f₂ x) =O[l] g) : (fun x => f₂ x - f₁ x) =O[l] g :=
h.neg_left.congr_left fun _x => neg_sub _ _
#align asymptotics.is_O.symm Asymptotics.IsBigO.symm
theorem isBigO_comm : (fun x => f₁ x - f₂ x) =O[l] g ↔ (fun x => f₂ x - f₁ x) =O[l] g :=
⟨IsBigO.symm, IsBigO.symm⟩
#align asymptotics.is_O_comm Asymptotics.isBigO_comm
theorem IsLittleO.symm (h : (fun x => f₁ x - f₂ x) =o[l] g) : (fun x => f₂ x - f₁ x) =o[l] g := by
simpa only [neg_sub] using h.neg_left
#align asymptotics.is_o.symm Asymptotics.IsLittleO.symm
theorem isLittleO_comm : (fun x => f₁ x - f₂ x) =o[l] g ↔ (fun x => f₂ x - f₁ x) =o[l] g :=
⟨IsLittleO.symm, IsLittleO.symm⟩
#align asymptotics.is_o_comm Asymptotics.isLittleO_comm
theorem IsBigOWith.triangle (h₁ : IsBigOWith c l (fun x => f₁ x - f₂ x) g)
(h₂ : IsBigOWith c' l (fun x => f₂ x - f₃ x) g) :
IsBigOWith (c + c') l (fun x => f₁ x - f₃ x) g :=
(h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _
#align asymptotics.is_O_with.triangle Asymptotics.IsBigOWith.triangle
theorem IsBigO.triangle (h₁ : (fun x => f₁ x - f₂ x) =O[l] g)
(h₂ : (fun x => f₂ x - f₃ x) =O[l] g) : (fun x => f₁ x - f₃ x) =O[l] g :=
(h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _
#align asymptotics.is_O.triangle Asymptotics.IsBigO.triangle
theorem IsLittleO.triangle (h₁ : (fun x => f₁ x - f₂ x) =o[l] g)
(h₂ : (fun x => f₂ x - f₃ x) =o[l] g) : (fun x => f₁ x - f₃ x) =o[l] g :=
(h₁.add h₂).congr_left fun _x => sub_add_sub_cancel _ _ _
#align asymptotics.is_o.triangle Asymptotics.IsLittleO.triangle
theorem IsBigO.congr_of_sub (h : (fun x => f₁ x - f₂ x) =O[l] g) : f₁ =O[l] g ↔ f₂ =O[l] g :=
⟨fun h' => (h'.sub h).congr_left fun _x => sub_sub_cancel _ _, fun h' =>
(h.add h').congr_left fun _x => sub_add_cancel _ _⟩
#align asymptotics.is_O.congr_of_sub Asymptotics.IsBigO.congr_of_sub
theorem IsLittleO.congr_of_sub (h : (fun x => f₁ x - f₂ x) =o[l] g) : f₁ =o[l] g ↔ f₂ =o[l] g :=
⟨fun h' => (h'.sub h).congr_left fun _x => sub_sub_cancel _ _, fun h' =>
(h.add h').congr_left fun _x => sub_add_cancel _ _⟩
#align asymptotics.is_o.congr_of_sub Asymptotics.IsLittleO.congr_of_sub
end IsBigOOAsRel
/-! ### Zero, one, and other constants -/
section ZeroConst
variable (g g' l)
theorem isLittleO_zero : (fun _x => (0 : E')) =o[l] g' :=
IsLittleO.of_bound fun c hc =>
univ_mem' fun x => by simpa using mul_nonneg hc.le (norm_nonneg <| g' x)
#align asymptotics.is_o_zero Asymptotics.isLittleO_zero
theorem isBigOWith_zero (hc : 0 ≤ c) : IsBigOWith c l (fun _x => (0 : E')) g' :=
IsBigOWith.of_bound <| univ_mem' fun x => by simpa using mul_nonneg hc (norm_nonneg <| g' x)
#align asymptotics.is_O_with_zero Asymptotics.isBigOWith_zero
theorem isBigOWith_zero' : IsBigOWith 0 l (fun _x => (0 : E')) g :=
IsBigOWith.of_bound <| univ_mem' fun x => by simp
#align asymptotics.is_O_with_zero' Asymptotics.isBigOWith_zero'
theorem isBigO_zero : (fun _x => (0 : E')) =O[l] g :=
isBigO_iff_isBigOWith.2 ⟨0, isBigOWith_zero' _ _⟩
#align asymptotics.is_O_zero Asymptotics.isBigO_zero
theorem isBigO_refl_left : (fun x => f' x - f' x) =O[l] g' :=
(isBigO_zero g' l).congr_left fun _x => (sub_self _).symm
#align asymptotics.is_O_refl_left Asymptotics.isBigO_refl_left
theorem isLittleO_refl_left : (fun x => f' x - f' x) =o[l] g' :=
(isLittleO_zero g' l).congr_left fun _x => (sub_self _).symm
#align asymptotics.is_o_refl_left Asymptotics.isLittleO_refl_left
variable {g g' l}
@[simp]
theorem isBigOWith_zero_right_iff : (IsBigOWith c l f'' fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 := by
simp only [IsBigOWith_def, exists_prop, true_and_iff, norm_zero, mul_zero,
norm_le_zero_iff, EventuallyEq, Pi.zero_apply]
#align asymptotics.is_O_with_zero_right_iff Asymptotics.isBigOWith_zero_right_iff
@[simp]
theorem isBigO_zero_right_iff : (f'' =O[l] fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 :=
⟨fun h =>
let ⟨_c, hc⟩ := h.isBigOWith
isBigOWith_zero_right_iff.1 hc,
fun h => (isBigOWith_zero_right_iff.2 h : IsBigOWith 1 _ _ _).isBigO⟩
#align asymptotics.is_O_zero_right_iff Asymptotics.isBigO_zero_right_iff
@[simp]
theorem isLittleO_zero_right_iff : (f'' =o[l] fun _x => (0 : F')) ↔ f'' =ᶠ[l] 0 :=
⟨fun h => isBigO_zero_right_iff.1 h.isBigO,
fun h => IsLittleO.of_isBigOWith fun _c _hc => isBigOWith_zero_right_iff.2 h⟩
#align asymptotics.is_o_zero_right_iff Asymptotics.isLittleO_zero_right_iff
theorem isBigOWith_const_const (c : E) {c' : F''} (hc' : c' ≠ 0) (l : Filter α) :
IsBigOWith (‖c‖ / ‖c'‖) l (fun _x : α => c) fun _x => c' := by
simp only [IsBigOWith_def]
apply univ_mem'
intro x
rw [mem_setOf, div_mul_cancel₀ _ (norm_ne_zero_iff.mpr hc')]
#align asymptotics.is_O_with_const_const Asymptotics.isBigOWith_const_const
theorem isBigO_const_const (c : E) {c' : F''} (hc' : c' ≠ 0) (l : Filter α) :
(fun _x : α => c) =O[l] fun _x => c' :=
(isBigOWith_const_const c hc' l).isBigO
#align asymptotics.is_O_const_const Asymptotics.isBigO_const_const
@[simp]
theorem isBigO_const_const_iff {c : E''} {c' : F''} (l : Filter α) [l.NeBot] :
((fun _x : α => c) =O[l] fun _x => c') ↔ c' = 0 → c = 0 := by
rcases eq_or_ne c' 0 with (rfl | hc')
· simp [EventuallyEq]
· simp [hc', isBigO_const_const _ hc']
#align asymptotics.is_O_const_const_iff Asymptotics.isBigO_const_const_iff
@[simp]
theorem isBigO_pure {x} : f'' =O[pure x] g'' ↔ g'' x = 0 → f'' x = 0 :=
calc
f'' =O[pure x] g'' ↔ (fun _y : α => f'' x) =O[pure x] fun _ => g'' x := isBigO_congr rfl rfl
_ ↔ g'' x = 0 → f'' x = 0 := isBigO_const_const_iff _
#align asymptotics.is_O_pure Asymptotics.isBigO_pure
end ZeroConst
@[simp]
theorem isBigOWith_principal {s : Set α} : IsBigOWith c (𝓟 s) f g ↔ ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖ := by
rw [IsBigOWith_def, eventually_principal]
#align asymptotics.is_O_with_principal Asymptotics.isBigOWith_principal
theorem isBigO_principal {s : Set α} : f =O[𝓟 s] g ↔ ∃ c, ∀ x ∈ s, ‖f x‖ ≤ c * ‖g x‖ := by
simp_rw [isBigO_iff, eventually_principal]
#align asymptotics.is_O_principal Asymptotics.isBigO_principal
@[simp]
theorem isLittleO_principal {s : Set α} : f'' =o[𝓟 s] g' ↔ ∀ x ∈ s, f'' x = 0 := by
refine ⟨fun h x hx ↦ norm_le_zero_iff.1 ?_, fun h ↦ ?_⟩
· simp only [isLittleO_iff, isBigOWith_principal] at h
have : Tendsto (fun c : ℝ => c * ‖g' x‖) (𝓝[>] 0) (𝓝 0) :=
((continuous_id.mul continuous_const).tendsto' _ _ (zero_mul _)).mono_left
inf_le_left
apply le_of_tendsto_of_tendsto tendsto_const_nhds this
apply eventually_nhdsWithin_iff.2 (eventually_of_forall (fun c hc ↦ ?_))
exact eventually_principal.1 (h hc) x hx
· apply (isLittleO_zero g' _).congr' ?_ EventuallyEq.rfl
exact fun x hx ↦ (h x hx).symm
@[simp]
theorem isBigOWith_top : IsBigOWith c ⊤ f g ↔ ∀ x, ‖f x‖ ≤ c * ‖g x‖ := by
rw [IsBigOWith_def, eventually_top]
#align asymptotics.is_O_with_top Asymptotics.isBigOWith_top
@[simp]
theorem isBigO_top : f =O[⊤] g ↔ ∃ C, ∀ x, ‖f x‖ ≤ C * ‖g x‖ := by
simp_rw [isBigO_iff, eventually_top]
#align asymptotics.is_O_top Asymptotics.isBigO_top
@[simp]
theorem isLittleO_top : f'' =o[⊤] g' ↔ ∀ x, f'' x = 0 := by
simp only [← principal_univ, isLittleO_principal, mem_univ, forall_true_left]
#align asymptotics.is_o_top Asymptotics.isLittleO_top
section
variable (F)
variable [One F] [NormOneClass F]
theorem isBigOWith_const_one (c : E) (l : Filter α) :
IsBigOWith ‖c‖ l (fun _x : α => c) fun _x => (1 : F) := by simp [isBigOWith_iff]
#align asymptotics.is_O_with_const_one Asymptotics.isBigOWith_const_one
theorem isBigO_const_one (c : E) (l : Filter α) : (fun _x : α => c) =O[l] fun _x => (1 : F) :=
(isBigOWith_const_one F c l).isBigO
#align asymptotics.is_O_const_one Asymptotics.isBigO_const_one
theorem isLittleO_const_iff_isLittleO_one {c : F''} (hc : c ≠ 0) :
(f =o[l] fun _x => c) ↔ f =o[l] fun _x => (1 : F) :=
⟨fun h => h.trans_isBigOWith (isBigOWith_const_one _ _ _) (norm_pos_iff.2 hc),
fun h => h.trans_isBigO <| isBigO_const_const _ hc _⟩
#align asymptotics.is_o_const_iff_is_o_one Asymptotics.isLittleO_const_iff_isLittleO_one
@[simp]
theorem isLittleO_one_iff : f' =o[l] (fun _x => 1 : α → F) ↔ Tendsto f' l (𝓝 0) := by
simp only [isLittleO_iff, norm_one, mul_one, Metric.nhds_basis_closedBall.tendsto_right_iff,
Metric.mem_closedBall, dist_zero_right]
#align asymptotics.is_o_one_iff Asymptotics.isLittleO_one_iff
@[simp]
theorem isBigO_one_iff : f =O[l] (fun _x => 1 : α → F) ↔
IsBoundedUnder (· ≤ ·) l fun x => ‖f x‖ := by
simp only [isBigO_iff, norm_one, mul_one, IsBoundedUnder, IsBounded, eventually_map]
#align asymptotics.is_O_one_iff Asymptotics.isBigO_one_iff
alias ⟨_, _root_.Filter.IsBoundedUnder.isBigO_one⟩ := isBigO_one_iff
#align filter.is_bounded_under.is_O_one Filter.IsBoundedUnder.isBigO_one
@[simp]
theorem isLittleO_one_left_iff : (fun _x => 1 : α → F) =o[l] f ↔ Tendsto (fun x => ‖f x‖) l atTop :=
calc
(fun _x => 1 : α → F) =o[l] f ↔ ∀ n : ℕ, ∀ᶠ x in l, ↑n * ‖(1 : F)‖ ≤ ‖f x‖ :=
isLittleO_iff_nat_mul_le_aux <| Or.inl fun _x => by simp only [norm_one, zero_le_one]
_ ↔ ∀ n : ℕ, True → ∀ᶠ x in l, ‖f x‖ ∈ Ici (n : ℝ) := by
simp only [norm_one, mul_one, true_imp_iff, mem_Ici]
_ ↔ Tendsto (fun x => ‖f x‖) l atTop :=
atTop_hasCountableBasis_of_archimedean.1.tendsto_right_iff.symm
#align asymptotics.is_o_one_left_iff Asymptotics.isLittleO_one_left_iff
theorem _root_.Filter.Tendsto.isBigO_one {c : E'} (h : Tendsto f' l (𝓝 c)) :
f' =O[l] (fun _x => 1 : α → F) :=
h.norm.isBoundedUnder_le.isBigO_one F
#align filter.tendsto.is_O_one Filter.Tendsto.isBigO_one
theorem IsBigO.trans_tendsto_nhds (hfg : f =O[l] g') {y : F'} (hg : Tendsto g' l (𝓝 y)) :
f =O[l] (fun _x => 1 : α → F) :=
hfg.trans <| hg.isBigO_one F
#align asymptotics.is_O.trans_tendsto_nhds Asymptotics.IsBigO.trans_tendsto_nhds
/-- The condition `f = O[𝓝[≠] a] 1` is equivalent to `f = O[𝓝 a] 1`. -/
lemma isBigO_one_nhds_ne_iff [TopologicalSpace α] {a : α} :
f =O[𝓝[≠] a] (fun _ ↦ 1 : α → F) ↔ f =O[𝓝 a] (fun _ ↦ 1 : α → F) := by
refine ⟨fun h ↦ ?_, fun h ↦ h.mono nhdsWithin_le_nhds⟩
simp only [isBigO_one_iff, IsBoundedUnder, IsBounded, eventually_map] at h ⊢
obtain ⟨c, hc⟩ := h
use max c ‖f a‖
filter_upwards [eventually_nhdsWithin_iff.mp hc] with b hb
rcases eq_or_ne b a with rfl | hb'
· apply le_max_right
· exact (hb hb').trans (le_max_left ..)
end
theorem isLittleO_const_iff {c : F''} (hc : c ≠ 0) :
(f'' =o[l] fun _x => c) ↔ Tendsto f'' l (𝓝 0) :=
(isLittleO_const_iff_isLittleO_one ℝ hc).trans (isLittleO_one_iff _)
#align asymptotics.is_o_const_iff Asymptotics.isLittleO_const_iff
theorem isLittleO_id_const {c : F''} (hc : c ≠ 0) : (fun x : E'' => x) =o[𝓝 0] fun _x => c :=
(isLittleO_const_iff hc).mpr (continuous_id.tendsto 0)
#align asymptotics.is_o_id_const Asymptotics.isLittleO_id_const
theorem _root_.Filter.IsBoundedUnder.isBigO_const (h : IsBoundedUnder (· ≤ ·) l (norm ∘ f))
{c : F''} (hc : c ≠ 0) : f =O[l] fun _x => c :=
(h.isBigO_one ℝ).trans (isBigO_const_const _ hc _)
#align filter.is_bounded_under.is_O_const Filter.IsBoundedUnder.isBigO_const
theorem isBigO_const_of_tendsto {y : E''} (h : Tendsto f'' l (𝓝 y)) {c : F''} (hc : c ≠ 0) :
f'' =O[l] fun _x => c :=
h.norm.isBoundedUnder_le.isBigO_const hc
#align asymptotics.is_O_const_of_tendsto Asymptotics.isBigO_const_of_tendsto
theorem IsBigO.isBoundedUnder_le {c : F} (h : f =O[l] fun _x => c) :
IsBoundedUnder (· ≤ ·) l (norm ∘ f) :=
let ⟨c', hc'⟩ := h.bound
⟨c' * ‖c‖, eventually_map.2 hc'⟩
#align asymptotics.is_O.is_bounded_under_le Asymptotics.IsBigO.isBoundedUnder_le
theorem isBigO_const_of_ne {c : F''} (hc : c ≠ 0) :
(f =O[l] fun _x => c) ↔ IsBoundedUnder (· ≤ ·) l (norm ∘ f) :=
⟨fun h => h.isBoundedUnder_le, fun h => h.isBigO_const hc⟩
#align asymptotics.is_O_const_of_ne Asymptotics.isBigO_const_of_ne
theorem isBigO_const_iff {c : F''} : (f'' =O[l] fun _x => c) ↔
(c = 0 → f'' =ᶠ[l] 0) ∧ IsBoundedUnder (· ≤ ·) l fun x => ‖f'' x‖ := by
refine ⟨fun h => ⟨fun hc => isBigO_zero_right_iff.1 (by rwa [← hc]), h.isBoundedUnder_le⟩, ?_⟩
rintro ⟨hcf, hf⟩
rcases eq_or_ne c 0 with (hc | hc)
exacts [(hcf hc).trans_isBigO (isBigO_zero _ _), hf.isBigO_const hc]
#align asymptotics.is_O_const_iff Asymptotics.isBigO_const_iff
theorem isBigO_iff_isBoundedUnder_le_div (h : ∀ᶠ x in l, g'' x ≠ 0) :
f =O[l] g'' ↔ IsBoundedUnder (· ≤ ·) l fun x => ‖f x‖ / ‖g'' x‖ := by
simp only [isBigO_iff, IsBoundedUnder, IsBounded, eventually_map]
exact
exists_congr fun c =>
eventually_congr <| h.mono fun x hx => (div_le_iff <| norm_pos_iff.2 hx).symm
#align asymptotics.is_O_iff_is_bounded_under_le_div Asymptotics.isBigO_iff_isBoundedUnder_le_div
/-- `(fun x ↦ c) =O[l] f` if and only if `f` is bounded away from zero. -/
theorem isBigO_const_left_iff_pos_le_norm {c : E''} (hc : c ≠ 0) :
(fun _x => c) =O[l] f' ↔ ∃ b, 0 < b ∧ ∀ᶠ x in l, b ≤ ‖f' x‖ := by
constructor
· intro h
rcases h.exists_pos with ⟨C, hC₀, hC⟩
refine ⟨‖c‖ / C, div_pos (norm_pos_iff.2 hc) hC₀, ?_⟩
exact hC.bound.mono fun x => (div_le_iff' hC₀).2
· rintro ⟨b, hb₀, hb⟩
refine IsBigO.of_bound (‖c‖ / b) (hb.mono fun x hx => ?_)
rw [div_mul_eq_mul_div, mul_div_assoc]
exact le_mul_of_one_le_right (norm_nonneg _) ((one_le_div hb₀).2 hx)
#align asymptotics.is_O_const_left_iff_pos_le_norm Asymptotics.isBigO_const_left_iff_pos_le_norm
theorem IsBigO.trans_tendsto (hfg : f'' =O[l] g'') (hg : Tendsto g'' l (𝓝 0)) :
Tendsto f'' l (𝓝 0) :=
(isLittleO_one_iff ℝ).1 <| hfg.trans_isLittleO <| (isLittleO_one_iff ℝ).2 hg
#align asymptotics.is_O.trans_tendsto Asymptotics.IsBigO.trans_tendsto
theorem IsLittleO.trans_tendsto (hfg : f'' =o[l] g'') (hg : Tendsto g'' l (𝓝 0)) :
Tendsto f'' l (𝓝 0) :=
hfg.isBigO.trans_tendsto hg
#align asymptotics.is_o.trans_tendsto Asymptotics.IsLittleO.trans_tendsto
/-! ### Multiplication by a constant -/
theorem isBigOWith_const_mul_self (c : R) (f : α → R) (l : Filter α) :
IsBigOWith ‖c‖ l (fun x => c * f x) f :=
isBigOWith_of_le' _ fun _x => norm_mul_le _ _
#align asymptotics.is_O_with_const_mul_self Asymptotics.isBigOWith_const_mul_self
theorem isBigO_const_mul_self (c : R) (f : α → R) (l : Filter α) : (fun x => c * f x) =O[l] f :=
(isBigOWith_const_mul_self c f l).isBigO
#align asymptotics.is_O_const_mul_self Asymptotics.isBigO_const_mul_self
theorem IsBigOWith.const_mul_left {f : α → R} (h : IsBigOWith c l f g) (c' : R) :
IsBigOWith (‖c'‖ * c) l (fun x => c' * f x) g :=
(isBigOWith_const_mul_self c' f l).trans h (norm_nonneg c')
#align asymptotics.is_O_with.const_mul_left Asymptotics.IsBigOWith.const_mul_left
theorem IsBigO.const_mul_left {f : α → R} (h : f =O[l] g) (c' : R) : (fun x => c' * f x) =O[l] g :=
let ⟨_c, hc⟩ := h.isBigOWith
(hc.const_mul_left c').isBigO
#align asymptotics.is_O.const_mul_left Asymptotics.IsBigO.const_mul_left
theorem isBigOWith_self_const_mul' (u : Rˣ) (f : α → R) (l : Filter α) :
IsBigOWith ‖(↑u⁻¹ : R)‖ l f fun x => ↑u * f x :=
(isBigOWith_const_mul_self ↑u⁻¹ (fun x ↦ ↑u * f x) l).congr_left
fun x ↦ u.inv_mul_cancel_left (f x)
#align asymptotics.is_O_with_self_const_mul' Asymptotics.isBigOWith_self_const_mul'
theorem isBigOWith_self_const_mul (c : 𝕜) (hc : c ≠ 0) (f : α → 𝕜) (l : Filter α) :
IsBigOWith ‖c‖⁻¹ l f fun x => c * f x :=
(isBigOWith_self_const_mul' (Units.mk0 c hc) f l).congr_const <| norm_inv c
#align asymptotics.is_O_with_self_const_mul Asymptotics.isBigOWith_self_const_mul
theorem isBigO_self_const_mul' {c : R} (hc : IsUnit c) (f : α → R) (l : Filter α) :
f =O[l] fun x => c * f x :=
let ⟨u, hu⟩ := hc
hu ▸ (isBigOWith_self_const_mul' u f l).isBigO
#align asymptotics.is_O_self_const_mul' Asymptotics.isBigO_self_const_mul'
theorem isBigO_self_const_mul (c : 𝕜) (hc : c ≠ 0) (f : α → 𝕜) (l : Filter α) :
f =O[l] fun x => c * f x :=
isBigO_self_const_mul' (IsUnit.mk0 c hc) f l
#align asymptotics.is_O_self_const_mul Asymptotics.isBigO_self_const_mul
theorem isBigO_const_mul_left_iff' {f : α → R} {c : R} (hc : IsUnit c) :
(fun x => c * f x) =O[l] g ↔ f =O[l] g :=
⟨(isBigO_self_const_mul' hc f l).trans, fun h => h.const_mul_left c⟩
#align asymptotics.is_O_const_mul_left_iff' Asymptotics.isBigO_const_mul_left_iff'
theorem isBigO_const_mul_left_iff {f : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) :
(fun x => c * f x) =O[l] g ↔ f =O[l] g :=
isBigO_const_mul_left_iff' <| IsUnit.mk0 c hc
#align asymptotics.is_O_const_mul_left_iff Asymptotics.isBigO_const_mul_left_iff
theorem IsLittleO.const_mul_left {f : α → R} (h : f =o[l] g) (c : R) : (fun x => c * f x) =o[l] g :=
(isBigO_const_mul_self c f l).trans_isLittleO h
#align asymptotics.is_o.const_mul_left Asymptotics.IsLittleO.const_mul_left
theorem isLittleO_const_mul_left_iff' {f : α → R} {c : R} (hc : IsUnit c) :
(fun x => c * f x) =o[l] g ↔ f =o[l] g :=
⟨(isBigO_self_const_mul' hc f l).trans_isLittleO, fun h => h.const_mul_left c⟩
#align asymptotics.is_o_const_mul_left_iff' Asymptotics.isLittleO_const_mul_left_iff'
theorem isLittleO_const_mul_left_iff {f : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) :
(fun x => c * f x) =o[l] g ↔ f =o[l] g :=
isLittleO_const_mul_left_iff' <| IsUnit.mk0 c hc
#align asymptotics.is_o_const_mul_left_iff Asymptotics.isLittleO_const_mul_left_iff
theorem IsBigOWith.of_const_mul_right {g : α → R} {c : R} (hc' : 0 ≤ c')
(h : IsBigOWith c' l f fun x => c * g x) : IsBigOWith (c' * ‖c‖) l f g :=
h.trans (isBigOWith_const_mul_self c g l) hc'
#align asymptotics.is_O_with.of_const_mul_right Asymptotics.IsBigOWith.of_const_mul_right
theorem IsBigO.of_const_mul_right {g : α → R} {c : R} (h : f =O[l] fun x => c * g x) : f =O[l] g :=
let ⟨_c, cnonneg, hc⟩ := h.exists_nonneg
(hc.of_const_mul_right cnonneg).isBigO
#align asymptotics.is_O.of_const_mul_right Asymptotics.IsBigO.of_const_mul_right
theorem IsBigOWith.const_mul_right' {g : α → R} {u : Rˣ} {c' : ℝ} (hc' : 0 ≤ c')
(h : IsBigOWith c' l f g) : IsBigOWith (c' * ‖(↑u⁻¹ : R)‖) l f fun x => ↑u * g x :=
h.trans (isBigOWith_self_const_mul' _ _ _) hc'
#align asymptotics.is_O_with.const_mul_right' Asymptotics.IsBigOWith.const_mul_right'
theorem IsBigOWith.const_mul_right {g : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) {c' : ℝ} (hc' : 0 ≤ c')
(h : IsBigOWith c' l f g) : IsBigOWith (c' * ‖c‖⁻¹) l f fun x => c * g x :=
h.trans (isBigOWith_self_const_mul c hc g l) hc'
#align asymptotics.is_O_with.const_mul_right Asymptotics.IsBigOWith.const_mul_right
theorem IsBigO.const_mul_right' {g : α → R} {c : R} (hc : IsUnit c) (h : f =O[l] g) :
f =O[l] fun x => c * g x :=
h.trans (isBigO_self_const_mul' hc g l)
#align asymptotics.is_O.const_mul_right' Asymptotics.IsBigO.const_mul_right'
theorem IsBigO.const_mul_right {g : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) (h : f =O[l] g) :
f =O[l] fun x => c * g x :=
h.const_mul_right' <| IsUnit.mk0 c hc
#align asymptotics.is_O.const_mul_right Asymptotics.IsBigO.const_mul_right
theorem isBigO_const_mul_right_iff' {g : α → R} {c : R} (hc : IsUnit c) :
(f =O[l] fun x => c * g x) ↔ f =O[l] g :=
⟨fun h => h.of_const_mul_right, fun h => h.const_mul_right' hc⟩
#align asymptotics.is_O_const_mul_right_iff' Asymptotics.isBigO_const_mul_right_iff'
theorem isBigO_const_mul_right_iff {g : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) :
(f =O[l] fun x => c * g x) ↔ f =O[l] g :=
isBigO_const_mul_right_iff' <| IsUnit.mk0 c hc
#align asymptotics.is_O_const_mul_right_iff Asymptotics.isBigO_const_mul_right_iff
theorem IsLittleO.of_const_mul_right {g : α → R} {c : R} (h : f =o[l] fun x => c * g x) :
f =o[l] g :=
h.trans_isBigO (isBigO_const_mul_self c g l)
#align asymptotics.is_o.of_const_mul_right Asymptotics.IsLittleO.of_const_mul_right
theorem IsLittleO.const_mul_right' {g : α → R} {c : R} (hc : IsUnit c) (h : f =o[l] g) :
f =o[l] fun x => c * g x :=
h.trans_isBigO (isBigO_self_const_mul' hc g l)
#align asymptotics.is_o.const_mul_right' Asymptotics.IsLittleO.const_mul_right'
theorem IsLittleO.const_mul_right {g : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) (h : f =o[l] g) :
f =o[l] fun x => c * g x :=
h.const_mul_right' <| IsUnit.mk0 c hc
#align asymptotics.is_o.const_mul_right Asymptotics.IsLittleO.const_mul_right
theorem isLittleO_const_mul_right_iff' {g : α → R} {c : R} (hc : IsUnit c) :
(f =o[l] fun x => c * g x) ↔ f =o[l] g :=
⟨fun h => h.of_const_mul_right, fun h => h.const_mul_right' hc⟩
#align asymptotics.is_o_const_mul_right_iff' Asymptotics.isLittleO_const_mul_right_iff'
theorem isLittleO_const_mul_right_iff {g : α → 𝕜} {c : 𝕜} (hc : c ≠ 0) :
(f =o[l] fun x => c * g x) ↔ f =o[l] g :=
isLittleO_const_mul_right_iff' <| IsUnit.mk0 c hc
#align asymptotics.is_o_const_mul_right_iff Asymptotics.isLittleO_const_mul_right_iff
/-! ### Multiplication -/
theorem IsBigOWith.mul {f₁ f₂ : α → R} {g₁ g₂ : α → 𝕜} {c₁ c₂ : ℝ} (h₁ : IsBigOWith c₁ l f₁ g₁)
(h₂ : IsBigOWith c₂ l f₂ g₂) :
IsBigOWith (c₁ * c₂) l (fun x => f₁ x * f₂ x) fun x => g₁ x * g₂ x := by
simp only [IsBigOWith_def] at *
filter_upwards [h₁, h₂] with _ hx₁ hx₂
apply le_trans (norm_mul_le _ _)
convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1
rw [norm_mul, mul_mul_mul_comm]
#align asymptotics.is_O_with.mul Asymptotics.IsBigOWith.mul
theorem IsBigO.mul {f₁ f₂ : α → R} {g₁ g₂ : α → 𝕜} (h₁ : f₁ =O[l] g₁) (h₂ : f₂ =O[l] g₂) :
(fun x => f₁ x * f₂ x) =O[l] fun x => g₁ x * g₂ x :=
let ⟨_c, hc⟩ := h₁.isBigOWith
let ⟨_c', hc'⟩ := h₂.isBigOWith
(hc.mul hc').isBigO
#align asymptotics.is_O.mul Asymptotics.IsBigO.mul
theorem IsBigO.mul_isLittleO {f₁ f₂ : α → R} {g₁ g₂ : α → 𝕜} (h₁ : f₁ =O[l] g₁) (h₂ : f₂ =o[l] g₂) :
(fun x => f₁ x * f₂ x) =o[l] fun x => g₁ x * g₂ x := by
simp only [IsLittleO_def] at *
intro c cpos
rcases h₁.exists_pos with ⟨c', c'pos, hc'⟩
exact (hc'.mul (h₂ (div_pos cpos c'pos))).congr_const (mul_div_cancel₀ _ (ne_of_gt c'pos))
#align asymptotics.is_O.mul_is_o Asymptotics.IsBigO.mul_isLittleO
theorem IsLittleO.mul_isBigO {f₁ f₂ : α → R} {g₁ g₂ : α → 𝕜} (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =O[l] g₂) :
(fun x => f₁ x * f₂ x) =o[l] fun x => g₁ x * g₂ x := by
simp only [IsLittleO_def] at *
intro c cpos
rcases h₂.exists_pos with ⟨c', c'pos, hc'⟩
exact ((h₁ (div_pos cpos c'pos)).mul hc').congr_const (div_mul_cancel₀ _ (ne_of_gt c'pos))
#align asymptotics.is_o.mul_is_O Asymptotics.IsLittleO.mul_isBigO
theorem IsLittleO.mul {f₁ f₂ : α → R} {g₁ g₂ : α → 𝕜} (h₁ : f₁ =o[l] g₁) (h₂ : f₂ =o[l] g₂) :
(fun x => f₁ x * f₂ x) =o[l] fun x => g₁ x * g₂ x :=
h₁.mul_isBigO h₂.isBigO
#align asymptotics.is_o.mul Asymptotics.IsLittleO.mul
theorem IsBigOWith.pow' {f : α → R} {g : α → 𝕜} (h : IsBigOWith c l f g) :
∀ n : ℕ, IsBigOWith (Nat.casesOn n ‖(1 : R)‖ fun n => c ^ (n + 1))
l (fun x => f x ^ n) fun x => g x ^ n
| 0 => by simpa using isBigOWith_const_const (1 : R) (one_ne_zero' 𝕜) l
| 1 => by simpa
| n + 2 => by simpa [pow_succ] using (IsBigOWith.pow' h (n + 1)).mul h
#align asymptotics.is_O_with.pow' Asymptotics.IsBigOWith.pow'
theorem IsBigOWith.pow [NormOneClass R] {f : α → R} {g : α → 𝕜} (h : IsBigOWith c l f g) :
∀ n : ℕ, IsBigOWith (c ^ n) l (fun x => f x ^ n) fun x => g x ^ n
| 0 => by simpa using h.pow' 0
| n + 1 => h.pow' (n + 1)
#align asymptotics.is_O_with.pow Asymptotics.IsBigOWith.pow
theorem IsBigOWith.of_pow {n : ℕ} {f : α → 𝕜} {g : α → R} (h : IsBigOWith c l (f ^ n) (g ^ n))
(hn : n ≠ 0) (hc : c ≤ c' ^ n) (hc' : 0 ≤ c') : IsBigOWith c' l f g :=
IsBigOWith.of_bound <| (h.weaken hc).bound.mono fun x hx ↦
le_of_pow_le_pow_left hn (by positivity) <|
calc
‖f x‖ ^ n = ‖f x ^ n‖ := (norm_pow _ _).symm
_ ≤ c' ^ n * ‖g x ^ n‖ := hx
_ ≤ c' ^ n * ‖g x‖ ^ n := by gcongr; exact norm_pow_le' _ hn.bot_lt
_ = (c' * ‖g x‖) ^ n := (mul_pow _ _ _).symm
#align asymptotics.is_O_with.of_pow Asymptotics.IsBigOWith.of_pow
theorem IsBigO.pow {f : α → R} {g : α → 𝕜} (h : f =O[l] g) (n : ℕ) :
(fun x => f x ^ n) =O[l] fun x => g x ^ n :=
let ⟨_C, hC⟩ := h.isBigOWith
isBigO_iff_isBigOWith.2 ⟨_, hC.pow' n⟩
#align asymptotics.is_O.pow Asymptotics.IsBigO.pow
theorem IsBigO.of_pow {f : α → 𝕜} {g : α → R} {n : ℕ} (hn : n ≠ 0) (h : (f ^ n) =O[l] (g ^ n)) :
f =O[l] g := by
rcases h.exists_pos with ⟨C, _hC₀, hC⟩
obtain ⟨c : ℝ, hc₀ : 0 ≤ c, hc : C ≤ c ^ n⟩ :=
((eventually_ge_atTop _).and <| (tendsto_pow_atTop hn).eventually_ge_atTop C).exists
exact (hC.of_pow hn hc hc₀).isBigO
#align asymptotics.is_O.of_pow Asymptotics.IsBigO.of_pow
theorem IsLittleO.pow {f : α → R} {g : α → 𝕜} (h : f =o[l] g) {n : ℕ} (hn : 0 < n) :
(fun x => f x ^ n) =o[l] fun x => g x ^ n := by
obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hn.ne'; clear hn
induction' n with n ihn
· simpa only [Nat.zero_eq, ← Nat.one_eq_succ_zero, pow_one]
· convert ihn.mul h <;> simp [pow_succ]
#align asymptotics.is_o.pow Asymptotics.IsLittleO.pow
theorem IsLittleO.of_pow {f : α → 𝕜} {g : α → R} {n : ℕ} (h : (f ^ n) =o[l] (g ^ n)) (hn : n ≠ 0) :
f =o[l] g :=
IsLittleO.of_isBigOWith fun _c hc => (h.def' <| pow_pos hc _).of_pow hn le_rfl hc.le
#align asymptotics.is_o.of_pow Asymptotics.IsLittleO.of_pow
/-! ### Inverse -/
theorem IsBigOWith.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : IsBigOWith c l f g)
(h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : IsBigOWith c l (fun x => (g x)⁻¹) fun x => (f x)⁻¹ := by
refine IsBigOWith.of_bound (h.bound.mp (h₀.mono fun x h₀ hle => ?_))
rcases eq_or_ne (f x) 0 with hx | hx
· simp only [hx, h₀ hx, inv_zero, norm_zero, mul_zero, le_rfl]
· have hc : 0 < c := pos_of_mul_pos_left ((norm_pos_iff.2 hx).trans_le hle) (norm_nonneg _)
replace hle := inv_le_inv_of_le (norm_pos_iff.2 hx) hle
simpa only [norm_inv, mul_inv, ← div_eq_inv_mul, div_le_iff hc] using hle
#align asymptotics.is_O_with.inv_rev Asymptotics.IsBigOWith.inv_rev
theorem IsBigO.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : f =O[l] g)
(h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : (fun x => (g x)⁻¹) =O[l] fun x => (f x)⁻¹ :=
let ⟨_c, hc⟩ := h.isBigOWith
(hc.inv_rev h₀).isBigO
#align asymptotics.is_O.inv_rev Asymptotics.IsBigO.inv_rev
theorem IsLittleO.inv_rev {f : α → 𝕜} {g : α → 𝕜'} (h : f =o[l] g)
(h₀ : ∀ᶠ x in l, f x = 0 → g x = 0) : (fun x => (g x)⁻¹) =o[l] fun x => (f x)⁻¹ :=
IsLittleO.of_isBigOWith fun _c hc => (h.def' hc).inv_rev h₀
#align asymptotics.is_o.inv_rev Asymptotics.IsLittleO.inv_rev
/-! ### Scalar multiplication -/
section SMulConst
variable [Module R E'] [BoundedSMul R E']
theorem IsBigOWith.const_smul_self (c' : R) :
IsBigOWith (‖c'‖) l (fun x => c' • f' x) f' :=
isBigOWith_of_le' _ fun _ => norm_smul_le _ _
theorem IsBigO.const_smul_self (c' : R) : (fun x => c' • f' x) =O[l] f' :=
(IsBigOWith.const_smul_self _).isBigO
theorem IsBigOWith.const_smul_left (h : IsBigOWith c l f' g) (c' : R) :
IsBigOWith (‖c'‖ * c) l (fun x => c' • f' x) g :=
.trans (.const_smul_self _) h (norm_nonneg _)
theorem IsBigO.const_smul_left (h : f' =O[l] g) (c : R) : (c • f') =O[l] g :=
let ⟨_b, hb⟩ := h.isBigOWith
(hb.const_smul_left _).isBigO
#align asymptotics.is_O.const_smul_left Asymptotics.IsBigO.const_smul_left
theorem IsLittleO.const_smul_left (h : f' =o[l] g) (c : R) : (c • f') =o[l] g :=
(IsBigO.const_smul_self _).trans_isLittleO h
#align asymptotics.is_o.const_smul_left Asymptotics.IsLittleO.const_smul_left
variable [Module 𝕜 E'] [BoundedSMul 𝕜 E']
theorem isBigO_const_smul_left {c : 𝕜} (hc : c ≠ 0) : (fun x => c • f' x) =O[l] g ↔ f' =O[l] g := by
have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc
rw [← isBigO_norm_left]
simp only [norm_smul]
rw [isBigO_const_mul_left_iff cne0, isBigO_norm_left]
#align asymptotics.is_O_const_smul_left Asymptotics.isBigO_const_smul_left
theorem isLittleO_const_smul_left {c : 𝕜} (hc : c ≠ 0) :
(fun x => c • f' x) =o[l] g ↔ f' =o[l] g := by
have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc
rw [← isLittleO_norm_left]
simp only [norm_smul]
rw [isLittleO_const_mul_left_iff cne0, isLittleO_norm_left]
#align asymptotics.is_o_const_smul_left Asymptotics.isLittleO_const_smul_left
theorem isBigO_const_smul_right {c : 𝕜} (hc : c ≠ 0) :
(f =O[l] fun x => c • f' x) ↔ f =O[l] f' := by
have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc
rw [← isBigO_norm_right]
simp only [norm_smul]
rw [isBigO_const_mul_right_iff cne0, isBigO_norm_right]
#align asymptotics.is_O_const_smul_right Asymptotics.isBigO_const_smul_right
theorem isLittleO_const_smul_right {c : 𝕜} (hc : c ≠ 0) :
(f =o[l] fun x => c • f' x) ↔ f =o[l] f' := by
have cne0 : ‖c‖ ≠ 0 := norm_ne_zero_iff.mpr hc
rw [← isLittleO_norm_right]
simp only [norm_smul]
rw [isLittleO_const_mul_right_iff cne0, isLittleO_norm_right]
#align asymptotics.is_o_const_smul_right Asymptotics.isLittleO_const_smul_right
end SMulConst
section SMul
variable [Module R E'] [BoundedSMul R E'] [Module 𝕜' F'] [BoundedSMul 𝕜' F']
variable {k₁ : α → R} {k₂ : α → 𝕜'}
theorem IsBigOWith.smul (h₁ : IsBigOWith c l k₁ k₂) (h₂ : IsBigOWith c' l f' g') :
IsBigOWith (c * c') l (fun x => k₁ x • f' x) fun x => k₂ x • g' x := by
simp only [IsBigOWith_def] at *
filter_upwards [h₁, h₂] with _ hx₁ hx₂
apply le_trans (norm_smul_le _ _)
convert mul_le_mul hx₁ hx₂ (norm_nonneg _) (le_trans (norm_nonneg _) hx₁) using 1
rw [norm_smul, mul_mul_mul_comm]
#align asymptotics.is_O_with.smul Asymptotics.IsBigOWith.smul
theorem IsBigO.smul (h₁ : k₁ =O[l] k₂) (h₂ : f' =O[l] g') :
(fun x => k₁ x • f' x) =O[l] fun x => k₂ x • g' x := by
obtain ⟨c₁, h₁⟩ := h₁.isBigOWith
obtain ⟨c₂, h₂⟩ := h₂.isBigOWith
exact (h₁.smul h₂).isBigO
#align asymptotics.is_O.smul Asymptotics.IsBigO.smul
theorem IsBigO.smul_isLittleO (h₁ : k₁ =O[l] k₂) (h₂ : f' =o[l] g') :
(fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x := by
simp only [IsLittleO_def] at *
intro c cpos
rcases h₁.exists_pos with ⟨c', c'pos, hc'⟩
exact (hc'.smul (h₂ (div_pos cpos c'pos))).congr_const (mul_div_cancel₀ _ (ne_of_gt c'pos))
#align asymptotics.is_O.smul_is_o Asymptotics.IsBigO.smul_isLittleO
theorem IsLittleO.smul_isBigO (h₁ : k₁ =o[l] k₂) (h₂ : f' =O[l] g') :
(fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x := by
simp only [IsLittleO_def] at *
intro c cpos
rcases h₂.exists_pos with ⟨c', c'pos, hc'⟩
exact ((h₁ (div_pos cpos c'pos)).smul hc').congr_const (div_mul_cancel₀ _ (ne_of_gt c'pos))
#align asymptotics.is_o.smul_is_O Asymptotics.IsLittleO.smul_isBigO
theorem IsLittleO.smul (h₁ : k₁ =o[l] k₂) (h₂ : f' =o[l] g') :
(fun x => k₁ x • f' x) =o[l] fun x => k₂ x • g' x :=
h₁.smul_isBigO h₂.isBigO
#align asymptotics.is_o.smul Asymptotics.IsLittleO.smul
end SMul
/-! ### Sum -/
section Sum
variable {ι : Type*} {A : ι → α → E'} {C : ι → ℝ} {s : Finset ι}
theorem IsBigOWith.sum (h : ∀ i ∈ s, IsBigOWith (C i) l (A i) g) :
IsBigOWith (∑ i ∈ s, C i) l (fun x => ∑ i ∈ s, A i x) g := by
induction' s using Finset.induction_on with i s is IH
· simp only [isBigOWith_zero', Finset.sum_empty, forall_true_iff]
· simp only [is, Finset.sum_insert, not_false_iff]
exact (h _ (Finset.mem_insert_self i s)).add (IH fun j hj => h _ (Finset.mem_insert_of_mem hj))
#align asymptotics.is_O_with.sum Asymptotics.IsBigOWith.sum
theorem IsBigO.sum (h : ∀ i ∈ s, A i =O[l] g) : (fun x => ∑ i ∈ s, A i x) =O[l] g := by
simp only [IsBigO_def] at *
choose! C hC using h
exact ⟨_, IsBigOWith.sum hC⟩
#align asymptotics.is_O.sum Asymptotics.IsBigO.sum
theorem IsLittleO.sum (h : ∀ i ∈ s, A i =o[l] g') : (fun x => ∑ i ∈ s, A i x) =o[l] g' := by
induction' s using Finset.induction_on with i s is IH
· simp only [isLittleO_zero, Finset.sum_empty, forall_true_iff]
· simp only [is, Finset.sum_insert, not_false_iff]
exact (h _ (Finset.mem_insert_self i s)).add (IH fun j hj => h _ (Finset.mem_insert_of_mem hj))
#align asymptotics.is_o.sum Asymptotics.IsLittleO.sum
end Sum
/-! ### Relation between `f = o(g)` and `f / g → 0` -/
theorem IsLittleO.tendsto_div_nhds_zero {f g : α → 𝕜} (h : f =o[l] g) :
Tendsto (fun x => f x / g x) l (𝓝 0) :=
(isLittleO_one_iff 𝕜).mp <| by
calc
(fun x => f x / g x) =o[l] fun x => g x / g x := by
simpa only [div_eq_mul_inv] using h.mul_isBigO (isBigO_refl _ _)
_ =O[l] fun _x => (1 : 𝕜) := isBigO_of_le _ fun x => by simp [div_self_le_one]
#align asymptotics.is_o.tendsto_div_nhds_zero Asymptotics.IsLittleO.tendsto_div_nhds_zero
theorem IsLittleO.tendsto_inv_smul_nhds_zero [Module 𝕜 E'] [BoundedSMul 𝕜 E']
{f : α → E'} {g : α → 𝕜}
{l : Filter α} (h : f =o[l] g) : Tendsto (fun x => (g x)⁻¹ • f x) l (𝓝 0) := by
simpa only [div_eq_inv_mul, ← norm_inv, ← norm_smul, ← tendsto_zero_iff_norm_tendsto_zero] using
h.norm_norm.tendsto_div_nhds_zero
#align asymptotics.is_o.tendsto_inv_smul_nhds_zero Asymptotics.IsLittleO.tendsto_inv_smul_nhds_zero
theorem isLittleO_iff_tendsto' {f g : α → 𝕜} (hgf : ∀ᶠ x in l, g x = 0 → f x = 0) :
f =o[l] g ↔ Tendsto (fun x => f x / g x) l (𝓝 0) :=
⟨IsLittleO.tendsto_div_nhds_zero, fun h =>
(((isLittleO_one_iff _).mpr h).mul_isBigO (isBigO_refl g l)).congr'
(hgf.mono fun _x => div_mul_cancel_of_imp) (eventually_of_forall fun _x => one_mul _)⟩
#align asymptotics.is_o_iff_tendsto' Asymptotics.isLittleO_iff_tendsto'
theorem isLittleO_iff_tendsto {f g : α → 𝕜} (hgf : ∀ x, g x = 0 → f x = 0) :
f =o[l] g ↔ Tendsto (fun x => f x / g x) l (𝓝 0) :=
isLittleO_iff_tendsto' (eventually_of_forall hgf)
#align asymptotics.is_o_iff_tendsto Asymptotics.isLittleO_iff_tendsto
alias ⟨_, isLittleO_of_tendsto'⟩ := isLittleO_iff_tendsto'
#align asymptotics.is_o_of_tendsto' Asymptotics.isLittleO_of_tendsto'
alias ⟨_, isLittleO_of_tendsto⟩ := isLittleO_iff_tendsto
#align asymptotics.is_o_of_tendsto Asymptotics.isLittleO_of_tendsto
theorem isLittleO_const_left_of_ne {c : E''} (hc : c ≠ 0) :
(fun _x => c) =o[l] g ↔ Tendsto (fun x => ‖g x‖) l atTop := by
simp only [← isLittleO_one_left_iff ℝ]
exact ⟨(isBigO_const_const (1 : ℝ) hc l).trans_isLittleO,
(isBigO_const_one ℝ c l).trans_isLittleO⟩
#align asymptotics.is_o_const_left_of_ne Asymptotics.isLittleO_const_left_of_ne
@[simp]
theorem isLittleO_const_left {c : E''} :
(fun _x => c) =o[l] g'' ↔ c = 0 ∨ Tendsto (norm ∘ g'') l atTop := by
rcases eq_or_ne c 0 with (rfl | hc)
· simp only [isLittleO_zero, eq_self_iff_true, true_or_iff]
· simp only [hc, false_or_iff, isLittleO_const_left_of_ne hc]; rfl
#align asymptotics.is_o_const_left Asymptotics.isLittleO_const_left
@[simp 1001] -- Porting note: increase priority so that this triggers before `isLittleO_const_left`
theorem isLittleO_const_const_iff [NeBot l] {d : E''} {c : F''} :
((fun _x => d) =o[l] fun _x => c) ↔ d = 0 := by
have : ¬Tendsto (Function.const α ‖c‖) l atTop :=
not_tendsto_atTop_of_tendsto_nhds tendsto_const_nhds
simp only [isLittleO_const_left, or_iff_left_iff_imp]
exact fun h => (this h).elim
#align asymptotics.is_o_const_const_iff Asymptotics.isLittleO_const_const_iff
@[simp]
theorem isLittleO_pure {x} : f'' =o[pure x] g'' ↔ f'' x = 0 :=
calc
f'' =o[pure x] g'' ↔ (fun _y : α => f'' x) =o[pure x] fun _ => g'' x := isLittleO_congr rfl rfl
_ ↔ f'' x = 0 := isLittleO_const_const_iff
#align asymptotics.is_o_pure Asymptotics.isLittleO_pure
theorem isLittleO_const_id_cobounded (c : F'') :
(fun _ => c) =o[Bornology.cobounded E''] id :=
isLittleO_const_left.2 <| .inr tendsto_norm_cobounded_atTop
#align asymptotics.is_o_const_id_comap_norm_at_top Asymptotics.isLittleO_const_id_cobounded
theorem isLittleO_const_id_atTop (c : E'') : (fun _x : ℝ => c) =o[atTop] id :=
isLittleO_const_left.2 <| Or.inr tendsto_abs_atTop_atTop
#align asymptotics.is_o_const_id_at_top Asymptotics.isLittleO_const_id_atTop
theorem isLittleO_const_id_atBot (c : E'') : (fun _x : ℝ => c) =o[atBot] id :=
isLittleO_const_left.2 <| Or.inr tendsto_abs_atBot_atTop
#align asymptotics.is_o_const_id_at_bot Asymptotics.isLittleO_const_id_atBot
/-!
### Eventually (u / v) * v = u
If `u` and `v` are linked by an `IsBigOWith` relation, then we
eventually have `(u / v) * v = u`, even if `v` vanishes.
-/
section EventuallyMulDivCancel
variable {u v : α → 𝕜}
theorem IsBigOWith.eventually_mul_div_cancel (h : IsBigOWith c l u v) : u / v * v =ᶠ[l] u :=
Eventually.mono h.bound fun y hy => div_mul_cancel_of_imp fun hv => by simpa [hv] using hy
#align asymptotics.is_O_with.eventually_mul_div_cancel Asymptotics.IsBigOWith.eventually_mul_div_cancel
/-- If `u = O(v)` along `l`, then `(u / v) * v = u` eventually at `l`. -/
theorem IsBigO.eventually_mul_div_cancel (h : u =O[l] v) : u / v * v =ᶠ[l] u :=
let ⟨_c, hc⟩ := h.isBigOWith
hc.eventually_mul_div_cancel
#align asymptotics.is_O.eventually_mul_div_cancel Asymptotics.IsBigO.eventually_mul_div_cancel
/-- If `u = o(v)` along `l`, then `(u / v) * v = u` eventually at `l`. -/
theorem IsLittleO.eventually_mul_div_cancel (h : u =o[l] v) : u / v * v =ᶠ[l] u :=
(h.forall_isBigOWith zero_lt_one).eventually_mul_div_cancel
#align asymptotics.is_o.eventually_mul_div_cancel Asymptotics.IsLittleO.eventually_mul_div_cancel
end EventuallyMulDivCancel
/-! ### Equivalent definitions of the form `∃ φ, u =ᶠ[l] φ * v` in a `NormedField`. -/
section ExistsMulEq
variable {u v : α → 𝕜}
/-- If `‖φ‖` is eventually bounded by `c`, and `u =ᶠ[l] φ * v`, then we have `IsBigOWith c u v l`.
This does not require any assumptions on `c`, which is why we keep this version along with
`IsBigOWith_iff_exists_eq_mul`. -/
theorem isBigOWith_of_eq_mul {u v : α → R} (φ : α → R) (hφ : ∀ᶠ x in l, ‖φ x‖ ≤ c)
(h : u =ᶠ[l] φ * v) :
IsBigOWith c l u v := by
simp only [IsBigOWith_def]
refine h.symm.rw (fun x a => ‖a‖ ≤ c * ‖v x‖) (hφ.mono fun x hx => ?_)
simp only [Pi.mul_apply]
refine (norm_mul_le _ _).trans ?_
gcongr
#align asymptotics.is_O_with_of_eq_mul Asymptotics.isBigOWith_of_eq_mul
theorem isBigOWith_iff_exists_eq_mul (hc : 0 ≤ c) :
IsBigOWith c l u v ↔ ∃ φ : α → 𝕜, (∀ᶠ x in l, ‖φ x‖ ≤ c) ∧ u =ᶠ[l] φ * v := by
constructor
· intro h
use fun x => u x / v x
refine ⟨Eventually.mono h.bound fun y hy => ?_, h.eventually_mul_div_cancel.symm⟩
simpa using div_le_of_nonneg_of_le_mul (norm_nonneg _) hc hy
· rintro ⟨φ, hφ, h⟩
exact isBigOWith_of_eq_mul φ hφ h
#align asymptotics.is_O_with_iff_exists_eq_mul Asymptotics.isBigOWith_iff_exists_eq_mul
theorem IsBigOWith.exists_eq_mul (h : IsBigOWith c l u v) (hc : 0 ≤ c) :
∃ φ : α → 𝕜, (∀ᶠ x in l, ‖φ x‖ ≤ c) ∧ u =ᶠ[l] φ * v :=
(isBigOWith_iff_exists_eq_mul hc).mp h
#align asymptotics.is_O_with.exists_eq_mul Asymptotics.IsBigOWith.exists_eq_mul
theorem isBigO_iff_exists_eq_mul :
u =O[l] v ↔ ∃ φ : α → 𝕜, l.IsBoundedUnder (· ≤ ·) (norm ∘ φ) ∧ u =ᶠ[l] φ * v := by
constructor
· rintro h
rcases h.exists_nonneg with ⟨c, hnnc, hc⟩
rcases hc.exists_eq_mul hnnc with ⟨φ, hφ, huvφ⟩
exact ⟨φ, ⟨c, hφ⟩, huvφ⟩
· rintro ⟨φ, ⟨c, hφ⟩, huvφ⟩
exact isBigO_iff_isBigOWith.2 ⟨c, isBigOWith_of_eq_mul φ hφ huvφ⟩
#align asymptotics.is_O_iff_exists_eq_mul Asymptotics.isBigO_iff_exists_eq_mul
alias ⟨IsBigO.exists_eq_mul, _⟩ := isBigO_iff_exists_eq_mul
#align asymptotics.is_O.exists_eq_mul Asymptotics.IsBigO.exists_eq_mul
theorem isLittleO_iff_exists_eq_mul :
u =o[l] v ↔ ∃ φ : α → 𝕜, Tendsto φ l (𝓝 0) ∧ u =ᶠ[l] φ * v := by
constructor
· exact fun h => ⟨fun x => u x / v x, h.tendsto_div_nhds_zero, h.eventually_mul_div_cancel.symm⟩
· simp only [IsLittleO_def]
rintro ⟨φ, hφ, huvφ⟩ c hpos
rw [NormedAddCommGroup.tendsto_nhds_zero] at hφ
exact isBigOWith_of_eq_mul _ ((hφ c hpos).mono fun x => le_of_lt) huvφ
#align asymptotics.is_o_iff_exists_eq_mul Asymptotics.isLittleO_iff_exists_eq_mul
alias ⟨IsLittleO.exists_eq_mul, _⟩ := isLittleO_iff_exists_eq_mul
#align asymptotics.is_o.exists_eq_mul Asymptotics.IsLittleO.exists_eq_mul
end ExistsMulEq
/-! ### Miscellaneous lemmas -/
theorem div_isBoundedUnder_of_isBigO {α : Type*} {l : Filter α} {f g : α → 𝕜} (h : f =O[l] g) :
IsBoundedUnder (· ≤ ·) l fun x => ‖f x / g x‖ := by
obtain ⟨c, h₀, hc⟩ := h.exists_nonneg
refine ⟨c, eventually_map.2 (hc.bound.mono fun x hx => ?_)⟩
rw [norm_div]
exact div_le_of_nonneg_of_le_mul (norm_nonneg _) h₀ hx
#align asymptotics.div_is_bounded_under_of_is_O Asymptotics.div_isBoundedUnder_of_isBigO
theorem isBigO_iff_div_isBoundedUnder {α : Type*} {l : Filter α} {f g : α → 𝕜}
(hgf : ∀ᶠ x in l, g x = 0 → f x = 0) :
f =O[l] g ↔ IsBoundedUnder (· ≤ ·) l fun x => ‖f x / g x‖ := by
refine ⟨div_isBoundedUnder_of_isBigO, fun h => ?_⟩
obtain ⟨c, hc⟩ := h
simp only [eventually_map, norm_div] at hc
refine IsBigO.of_bound c (hc.mp <| hgf.mono fun x hx₁ hx₂ => ?_)
by_cases hgx : g x = 0
· simp [hx₁ hgx, hgx]
· exact (div_le_iff (norm_pos_iff.2 hgx)).mp hx₂
#align asymptotics.is_O_iff_div_is_bounded_under Asymptotics.isBigO_iff_div_isBoundedUnder
theorem isBigO_of_div_tendsto_nhds {α : Type*} {l : Filter α} {f g : α → 𝕜}
(hgf : ∀ᶠ x in l, g x = 0 → f x = 0) (c : 𝕜) (H : Filter.Tendsto (f / g) l (𝓝 c)) :
f =O[l] g :=
(isBigO_iff_div_isBoundedUnder hgf).2 <| H.norm.isBoundedUnder_le
#align asymptotics.is_O_of_div_tendsto_nhds Asymptotics.isBigO_of_div_tendsto_nhds
theorem IsLittleO.tendsto_zero_of_tendsto {α E 𝕜 : Type*} [NormedAddCommGroup E] [NormedField 𝕜]
{u : α → E} {v : α → 𝕜} {l : Filter α} {y : 𝕜} (huv : u =o[l] v) (hv : Tendsto v l (𝓝 y)) :
Tendsto u l (𝓝 0) := by
suffices h : u =o[l] fun _x => (1 : 𝕜) by
rwa [isLittleO_one_iff] at h
exact huv.trans_isBigO (hv.isBigO_one 𝕜)
#align asymptotics.is_o.tendsto_zero_of_tendsto Asymptotics.IsLittleO.tendsto_zero_of_tendsto
theorem isLittleO_pow_pow {m n : ℕ} (h : m < n) : (fun x : 𝕜 => x ^ n) =o[𝓝 0] fun x => x ^ m := by
rcases lt_iff_exists_add.1 h with ⟨p, hp0 : 0 < p, rfl⟩
suffices (fun x : 𝕜 => x ^ m * x ^ p) =o[𝓝 0] fun x => x ^ m * 1 ^ p by
simpa only [pow_add, one_pow, mul_one]
exact IsBigO.mul_isLittleO (isBigO_refl _ _)
(IsLittleO.pow ((isLittleO_one_iff _).2 tendsto_id) hp0)
#align asymptotics.is_o_pow_pow Asymptotics.isLittleO_pow_pow
theorem isLittleO_norm_pow_norm_pow {m n : ℕ} (h : m < n) :
(fun x : E' => ‖x‖ ^ n) =o[𝓝 0] fun x => ‖x‖ ^ m :=
(isLittleO_pow_pow h).comp_tendsto tendsto_norm_zero
#align asymptotics.is_o_norm_pow_norm_pow Asymptotics.isLittleO_norm_pow_norm_pow
theorem isLittleO_pow_id {n : ℕ} (h : 1 < n) : (fun x : 𝕜 => x ^ n) =o[𝓝 0] fun x => x := by
convert isLittleO_pow_pow h (𝕜 := 𝕜)
simp only [pow_one]
#align asymptotics.is_o_pow_id Asymptotics.isLittleO_pow_id
theorem isLittleO_norm_pow_id {n : ℕ} (h : 1 < n) :
(fun x : E' => ‖x‖ ^ n) =o[𝓝 0] fun x => x := by
have := @isLittleO_norm_pow_norm_pow E' _ _ _ h
simp only [pow_one] at this
exact isLittleO_norm_right.mp this
#align asymptotics.is_o_norm_pow_id Asymptotics.isLittleO_norm_pow_id
theorem IsBigO.eq_zero_of_norm_pow_within {f : E'' → F''} {s : Set E''} {x₀ : E''} {n : ℕ}
(h : f =O[𝓝[s] x₀] fun x => ‖x - x₀‖ ^ n) (hx₀ : x₀ ∈ s) (hn : n ≠ 0) : f x₀ = 0 :=
mem_of_mem_nhdsWithin hx₀ h.eq_zero_imp <| by simp_rw [sub_self, norm_zero, zero_pow hn]
#align asymptotics.is_O.eq_zero_of_norm_pow_within Asymptotics.IsBigO.eq_zero_of_norm_pow_within
theorem IsBigO.eq_zero_of_norm_pow {f : E'' → F''} {x₀ : E''} {n : ℕ}
(h : f =O[𝓝 x₀] fun x => ‖x - x₀‖ ^ n) (hn : n ≠ 0) : f x₀ = 0 := by
rw [← nhdsWithin_univ] at h
exact h.eq_zero_of_norm_pow_within (mem_univ _) hn
#align asymptotics.is_O.eq_zero_of_norm_pow Asymptotics.IsBigO.eq_zero_of_norm_pow
theorem isLittleO_pow_sub_pow_sub (x₀ : E') {n m : ℕ} (h : n < m) :
(fun x => ‖x - x₀‖ ^ m) =o[𝓝 x₀] fun x => ‖x - x₀‖ ^ n :=
haveI : Tendsto (fun x => ‖x - x₀‖) (𝓝 x₀) (𝓝 0) := by
apply tendsto_norm_zero.comp
rw [← sub_self x₀]
exact tendsto_id.sub tendsto_const_nhds
(isLittleO_pow_pow h).comp_tendsto this
#align asymptotics.is_o_pow_sub_pow_sub Asymptotics.isLittleO_pow_sub_pow_sub
theorem isLittleO_pow_sub_sub (x₀ : E') {m : ℕ} (h : 1 < m) :
(fun x => ‖x - x₀‖ ^ m) =o[𝓝 x₀] fun x => x - x₀ := by
simpa only [isLittleO_norm_right, pow_one] using isLittleO_pow_sub_pow_sub x₀ h
#align asymptotics.is_o_pow_sub_sub Asymptotics.isLittleO_pow_sub_sub
theorem IsBigOWith.right_le_sub_of_lt_one {f₁ f₂ : α → E'} (h : IsBigOWith c l f₁ f₂) (hc : c < 1) :
IsBigOWith (1 / (1 - c)) l f₂ fun x => f₂ x - f₁ x :=
IsBigOWith.of_bound <|
mem_of_superset h.bound fun x hx => by
simp only [mem_setOf_eq] at hx ⊢
rw [mul_comm, one_div, ← div_eq_mul_inv, _root_.le_div_iff, mul_sub, mul_one, mul_comm]
· exact le_trans (sub_le_sub_left hx _) (norm_sub_norm_le _ _)
· exact sub_pos.2 hc
#align asymptotics.is_O_with.right_le_sub_of_lt_1 Asymptotics.IsBigOWith.right_le_sub_of_lt_one
theorem IsBigOWith.right_le_add_of_lt_one {f₁ f₂ : α → E'} (h : IsBigOWith c l f₁ f₂) (hc : c < 1) :
IsBigOWith (1 / (1 - c)) l f₂ fun x => f₁ x + f₂ x :=
(h.neg_right.right_le_sub_of_lt_one hc).neg_right.of_neg_left.congr rfl (fun x ↦ rfl) fun x ↦ by
rw [neg_sub, sub_neg_eq_add]
#align asymptotics.is_O_with.right_le_add_of_lt_1 Asymptotics.IsBigOWith.right_le_add_of_lt_one
-- 2024-01-31
@[deprecated] alias IsBigOWith.right_le_sub_of_lt_1 := IsBigOWith.right_le_sub_of_lt_one
@[deprecated] alias IsBigOWith.right_le_add_of_lt_1 := IsBigOWith.right_le_add_of_lt_one
theorem IsLittleO.right_isBigO_sub {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) :
f₂ =O[l] fun x => f₂ x - f₁ x :=
((h.def' one_half_pos).right_le_sub_of_lt_one one_half_lt_one).isBigO
#align asymptotics.is_o.right_is_O_sub Asymptotics.IsLittleO.right_isBigO_sub
theorem IsLittleO.right_isBigO_add {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) :
f₂ =O[l] fun x => f₁ x + f₂ x :=
((h.def' one_half_pos).right_le_add_of_lt_one one_half_lt_one).isBigO
#align asymptotics.is_o.right_is_O_add Asymptotics.IsLittleO.right_isBigO_add
theorem IsLittleO.right_isBigO_add' {f₁ f₂ : α → E'} (h : f₁ =o[l] f₂) :
f₂ =O[l] (f₂ + f₁) :=
add_comm f₁ f₂ ▸ h.right_isBigO_add
/-- If `f x = O(g x)` along `cofinite`, then there exists a positive constant `C` such that
`‖f x‖ ≤ C * ‖g x‖` whenever `g x ≠ 0`. -/
theorem bound_of_isBigO_cofinite (h : f =O[cofinite] g'') :
∃ C > 0, ∀ ⦃x⦄, g'' x ≠ 0 → ‖f x‖ ≤ C * ‖g'' x‖ := by
rcases h.exists_pos with ⟨C, C₀, hC⟩
rw [IsBigOWith_def, eventually_cofinite] at hC
rcases (hC.toFinset.image fun x => ‖f x‖ / ‖g'' x‖).exists_le with ⟨C', hC'⟩
have : ∀ x, C * ‖g'' x‖ < ‖f x‖ → ‖f x‖ / ‖g'' x‖ ≤ C' := by simpa using hC'
refine ⟨max C C', lt_max_iff.2 (Or.inl C₀), fun x h₀ => ?_⟩
rw [max_mul_of_nonneg _ _ (norm_nonneg _), le_max_iff, or_iff_not_imp_left, not_le]
exact fun hx => (div_le_iff (norm_pos_iff.2 h₀)).1 (this _ hx)
#align asymptotics.bound_of_is_O_cofinite Asymptotics.bound_of_isBigO_cofinite
theorem isBigO_cofinite_iff (h : ∀ x, g'' x = 0 → f'' x = 0) :
f'' =O[cofinite] g'' ↔ ∃ C, ∀ x, ‖f'' x‖ ≤ C * ‖g'' x‖ :=
⟨fun h' =>
let ⟨C, _C₀, hC⟩ := bound_of_isBigO_cofinite h'
⟨C, fun x => if hx : g'' x = 0 then by simp [h _ hx, hx] else hC hx⟩,
fun h => (isBigO_top.2 h).mono le_top⟩
#align asymptotics.is_O_cofinite_iff Asymptotics.isBigO_cofinite_iff
theorem bound_of_isBigO_nat_atTop {f : ℕ → E} {g'' : ℕ → E''} (h : f =O[atTop] g'') :
∃ C > 0, ∀ ⦃x⦄, g'' x ≠ 0 → ‖f x‖ ≤ C * ‖g'' x‖ :=
bound_of_isBigO_cofinite <| by rwa [Nat.cofinite_eq_atTop]
#align asymptotics.bound_of_is_O_nat_at_top Asymptotics.bound_of_isBigO_nat_atTop
| Mathlib/Analysis/Asymptotics/Asymptotics.lean | 2,189 | 2,191 | theorem isBigO_nat_atTop_iff {f : ℕ → E''} {g : ℕ → F''} (h : ∀ x, g x = 0 → f x = 0) :
f =O[atTop] g ↔ ∃ C, ∀ x, ‖f x‖ ≤ C * ‖g x‖ := by |
rw [← Nat.cofinite_eq_atTop, isBigO_cofinite_iff h]
|
/-
Copyright (c) 2023 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.LinearAlgebra.Dual
import Mathlib.LinearAlgebra.TensorProduct.Tower
#align_import linear_algebra.bilinear_form.tensor_product from "leanprover-community/mathlib"@"f0c8bf9245297a541f468be517f1bde6195105e9"
/-!
# The bilinear form on a tensor product
## Main definitions
* `LinearMap.BilinForm.tensorDistrib (B₁ ⊗ₜ B₂)`: the bilinear form on `M₁ ⊗ M₂` constructed by
applying `B₁` on `M₁` and `B₂` on `M₂`.
* `LinearMap.BilinForm.tensorDistribEquiv`: `BilinForm.tensorDistrib` as an equivalence on finite
free modules.
-/
suppress_compilation
universe u v w uι uR uA uM₁ uM₂
variable {ι : Type uι} {R : Type uR} {A : Type uA} {M₁ : Type uM₁} {M₂ : Type uM₂}
open TensorProduct
namespace LinearMap
namespace BilinForm
open LinearMap (BilinForm)
section CommSemiring
variable [CommSemiring R] [CommSemiring A]
variable [AddCommMonoid M₁] [AddCommMonoid M₂]
variable [Algebra R A] [Module R M₁] [Module A M₁]
variable [SMulCommClass R A M₁] [SMulCommClass A R M₁] [IsScalarTower R A M₁]
variable [Module R M₂]
variable (R A) in
/-- The tensor product of two bilinear forms injects into bilinear forms on tensor products.
Note this is heterobasic; the bilinear form on the left can take values in an (commutative) algebra
over the ring in which the right bilinear form is valued. -/
def tensorDistrib : BilinForm A M₁ ⊗[R] BilinForm R M₂ →ₗ[A] BilinForm A (M₁ ⊗[R] M₂) :=
((TensorProduct.AlgebraTensorModule.tensorTensorTensorComm R A M₁ M₂ M₁ M₂).dualMap
≪≫ₗ (TensorProduct.lift.equiv A (M₁ ⊗[R] M₂) (M₁ ⊗[R] M₂) A).symm).toLinearMap
∘ₗ TensorProduct.AlgebraTensorModule.dualDistrib R _ _ _
∘ₗ (TensorProduct.AlgebraTensorModule.congr
(TensorProduct.lift.equiv A M₁ M₁ A)
(TensorProduct.lift.equiv R _ _ _)).toLinearMap
#align bilin_form.tensor_distrib LinearMap.BilinForm.tensorDistrib
-- TODO: make the RHS `MulOpposite.op (B₂ m₂ m₂') • B₁ m₁ m₁'` so that this has a nicer defeq for
-- `R = A` of `B₁ m₁ m₁' * B₂ m₂ m₂'`, as it did before the generalization in #6306.
@[simp]
theorem tensorDistrib_tmul (B₁ : BilinForm A M₁) (B₂ : BilinForm R M₂) (m₁ : M₁) (m₂ : M₂)
(m₁' : M₁) (m₂' : M₂) :
tensorDistrib R A (B₁ ⊗ₜ B₂) (m₁ ⊗ₜ m₂) (m₁' ⊗ₜ m₂')
= B₂ m₂ m₂' • B₁ m₁ m₁' :=
rfl
#align bilin_form.tensor_distrib_tmul LinearMap.BilinForm.tensorDistrib_tmulₓ
/-- The tensor product of two bilinear forms, a shorthand for dot notation. -/
protected abbrev tmul (B₁ : BilinForm A M₁) (B₂ : BilinForm R M₂) : BilinForm A (M₁ ⊗[R] M₂) :=
tensorDistrib R A (B₁ ⊗ₜ[R] B₂)
#align bilin_form.tmul LinearMap.BilinForm.tmul
attribute [local ext] TensorProduct.ext in
/-- A tensor product of symmetric bilinear forms is symmetric. -/
lemma _root_.LinearMap.IsSymm.tmul {B₁ : BilinForm A M₁} {B₂ : BilinForm R M₂}
(hB₁ : B₁.IsSymm) (hB₂ : B₂.IsSymm) : (B₁.tmul B₂).IsSymm := by
rw [LinearMap.isSymm_iff_eq_flip]
ext x₁ x₂ y₁ y₂
exact congr_arg₂ (HSMul.hSMul) (hB₂ x₂ y₂) (hB₁ x₁ y₁)
variable (A) in
/-- The base change of a bilinear form. -/
protected def baseChange (B : BilinForm R M₂) : BilinForm A (A ⊗[R] M₂) :=
BilinForm.tmul (R := R) (A := A) (M₁ := A) (M₂ := M₂) (LinearMap.mul A A) B
@[simp]
theorem baseChange_tmul (B₂ : BilinForm R M₂) (a : A) (m₂ : M₂)
(a' : A) (m₂' : M₂) :
B₂.baseChange A (a ⊗ₜ m₂) (a' ⊗ₜ m₂') = (B₂ m₂ m₂') • (a * a') :=
rfl
variable (A) in
/-- The base change of a symmetric bilinear form is symmetric. -/
lemma IsSymm.baseChange {B₂ : BilinForm R M₂} (hB₂ : B₂.IsSymm) : (B₂.baseChange A).IsSymm :=
IsSymm.tmul mul_comm hB₂
end CommSemiring
section CommRing
variable [CommRing R]
variable [AddCommGroup M₁] [AddCommGroup M₂]
variable [Module R M₁] [Module R M₂]
variable [Module.Free R M₁] [Module.Finite R M₁]
variable [Module.Free R M₂] [Module.Finite R M₂]
variable [Nontrivial R]
variable (R) in
/-- `tensorDistrib` as an equivalence. -/
noncomputable def tensorDistribEquiv :
BilinForm R M₁ ⊗[R] BilinForm R M₂ ≃ₗ[R] BilinForm R (M₁ ⊗[R] M₂) :=
-- the same `LinearEquiv`s as from `tensorDistrib`,
-- but with the inner linear map also as an equiv
TensorProduct.congr (TensorProduct.lift.equiv R _ _ _) (TensorProduct.lift.equiv R _ _ _) ≪≫ₗ
TensorProduct.dualDistribEquiv R (M₁ ⊗ M₁) (M₂ ⊗ M₂) ≪≫ₗ
(TensorProduct.tensorTensorTensorComm R _ _ _ _).dualMap ≪≫ₗ
(TensorProduct.lift.equiv R _ _ _).symm
#align bilin_form.tensor_distrib_equiv LinearMap.BilinForm.tensorDistribEquiv
-- this is a dsimp lemma
@[simp, nolint simpNF]
theorem tensorDistribEquiv_tmul (B₁ : BilinForm R M₁) (B₂ : BilinForm R M₂) (m₁ : M₁) (m₂ : M₂)
(m₁' : M₁) (m₂' : M₂) :
tensorDistribEquiv R (M₁ := M₁) (M₂ := M₂) (B₁ ⊗ₜ[R] B₂) (m₁ ⊗ₜ m₂) (m₁' ⊗ₜ m₂')
= B₁ m₁ m₁' * B₂ m₂ m₂' :=
rfl
variable (R M₁ M₂) in
-- TODO: make this `rfl`
@[simp]
| Mathlib/LinearAlgebra/BilinearForm/TensorProduct.lean | 131 | 135 | theorem tensorDistribEquiv_toLinearMap :
(tensorDistribEquiv R (M₁ := M₁) (M₂ := M₂)).toLinearMap = tensorDistrib R R := by |
ext B₁ B₂ : 3
ext
exact mul_comm _ _
|
/-
Copyright (c) 2018 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Jens Wagemaker, Aaron Anderson
-/
import Mathlib.Algebra.BigOperators.Associated
import Mathlib.Algebra.GCDMonoid.Basic
import Mathlib.Data.Finsupp.Multiset
import Mathlib.Data.Nat.Factors
import Mathlib.RingTheory.Noetherian
import Mathlib.RingTheory.Multiplicity
#align_import ring_theory.unique_factorization_domain from "leanprover-community/mathlib"@"570e9f4877079b3a923135b3027ac3be8695ab8c"
/-!
# Unique factorization
## Main Definitions
* `WfDvdMonoid` holds for `Monoid`s for which a strict divisibility relation is
well-founded.
* `UniqueFactorizationMonoid` holds for `WfDvdMonoid`s where
`Irreducible` is equivalent to `Prime`
## To do
* set up the complete lattice structure on `FactorSet`.
-/
variable {α : Type*}
local infixl:50 " ~ᵤ " => Associated
/-- Well-foundedness of the strict version of |, which is equivalent to the descending chain
condition on divisibility and to the ascending chain condition on
principal ideals in an integral domain.
-/
class WfDvdMonoid (α : Type*) [CommMonoidWithZero α] : Prop where
wellFounded_dvdNotUnit : WellFounded (@DvdNotUnit α _)
#align wf_dvd_monoid WfDvdMonoid
export WfDvdMonoid (wellFounded_dvdNotUnit)
-- see Note [lower instance priority]
instance (priority := 100) IsNoetherianRing.wfDvdMonoid [CommRing α] [IsDomain α]
[IsNoetherianRing α] : WfDvdMonoid α :=
⟨by
convert InvImage.wf (fun a => Ideal.span ({a} : Set α)) (wellFounded_submodule_gt _ _)
ext
exact Ideal.span_singleton_lt_span_singleton.symm⟩
#align is_noetherian_ring.wf_dvd_monoid IsNoetherianRing.wfDvdMonoid
namespace WfDvdMonoid
variable [CommMonoidWithZero α]
open Associates Nat
theorem of_wfDvdMonoid_associates (_ : WfDvdMonoid (Associates α)) : WfDvdMonoid α :=
⟨(mk_surjective.wellFounded_iff mk_dvdNotUnit_mk_iff.symm).2 wellFounded_dvdNotUnit⟩
#align wf_dvd_monoid.of_wf_dvd_monoid_associates WfDvdMonoid.of_wfDvdMonoid_associates
variable [WfDvdMonoid α]
instance wfDvdMonoid_associates : WfDvdMonoid (Associates α) :=
⟨(mk_surjective.wellFounded_iff mk_dvdNotUnit_mk_iff.symm).1 wellFounded_dvdNotUnit⟩
#align wf_dvd_monoid.wf_dvd_monoid_associates WfDvdMonoid.wfDvdMonoid_associates
theorem wellFounded_associates : WellFounded ((· < ·) : Associates α → Associates α → Prop) :=
Subrelation.wf dvdNotUnit_of_lt wellFounded_dvdNotUnit
#align wf_dvd_monoid.well_founded_associates WfDvdMonoid.wellFounded_associates
-- Porting note: elab_as_elim can only be global and cannot be changed on an imported decl
-- attribute [local elab_as_elim] WellFounded.fix
theorem exists_irreducible_factor {a : α} (ha : ¬IsUnit a) (ha0 : a ≠ 0) :
∃ i, Irreducible i ∧ i ∣ a :=
let ⟨b, hs, hr⟩ := wellFounded_dvdNotUnit.has_min { b | b ∣ a ∧ ¬IsUnit b } ⟨a, dvd_rfl, ha⟩
⟨b,
⟨hs.2, fun c d he =>
let h := dvd_trans ⟨d, he⟩ hs.1
or_iff_not_imp_left.2 fun hc =>
of_not_not fun hd => hr c ⟨h, hc⟩ ⟨ne_zero_of_dvd_ne_zero ha0 h, d, hd, he⟩⟩,
hs.1⟩
#align wf_dvd_monoid.exists_irreducible_factor WfDvdMonoid.exists_irreducible_factor
@[elab_as_elim]
theorem induction_on_irreducible {P : α → Prop} (a : α) (h0 : P 0) (hu : ∀ u : α, IsUnit u → P u)
(hi : ∀ a i : α, a ≠ 0 → Irreducible i → P a → P (i * a)) : P a :=
haveI := Classical.dec
wellFounded_dvdNotUnit.fix
(fun a ih =>
if ha0 : a = 0 then ha0.substr h0
else
if hau : IsUnit a then hu a hau
else
let ⟨i, hii, b, hb⟩ := exists_irreducible_factor hau ha0
let hb0 : b ≠ 0 := ne_zero_of_dvd_ne_zero ha0 ⟨i, mul_comm i b ▸ hb⟩
hb.symm ▸ hi b i hb0 hii <| ih b ⟨hb0, i, hii.1, mul_comm i b ▸ hb⟩)
a
#align wf_dvd_monoid.induction_on_irreducible WfDvdMonoid.induction_on_irreducible
theorem exists_factors (a : α) :
a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ Associated f.prod a :=
induction_on_irreducible a (fun h => (h rfl).elim)
(fun u hu _ => ⟨0, fun _ h => False.elim (Multiset.not_mem_zero _ h), hu.unit, one_mul _⟩)
fun a i ha0 hi ih _ =>
let ⟨s, hs⟩ := ih ha0
⟨i ::ₘ s, fun b H => (Multiset.mem_cons.1 H).elim (fun h => h.symm ▸ hi) (hs.1 b), by
rw [s.prod_cons i]
exact hs.2.mul_left i⟩
#align wf_dvd_monoid.exists_factors WfDvdMonoid.exists_factors
theorem not_unit_iff_exists_factors_eq (a : α) (hn0 : a ≠ 0) :
¬IsUnit a ↔ ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ f.prod = a ∧ f ≠ ∅ :=
⟨fun hnu => by
obtain ⟨f, hi, u, rfl⟩ := exists_factors a hn0
obtain ⟨b, h⟩ := Multiset.exists_mem_of_ne_zero fun h : f = 0 => hnu <| by simp [h]
classical
refine ⟨(f.erase b).cons (b * u), fun a ha => ?_, ?_, Multiset.cons_ne_zero⟩
· obtain rfl | ha := Multiset.mem_cons.1 ha
exacts [Associated.irreducible ⟨u, rfl⟩ (hi b h), hi a (Multiset.mem_of_mem_erase ha)]
· rw [Multiset.prod_cons, mul_comm b, mul_assoc, Multiset.prod_erase h, mul_comm],
fun ⟨f, hi, he, hne⟩ =>
let ⟨b, h⟩ := Multiset.exists_mem_of_ne_zero hne
not_isUnit_of_not_isUnit_dvd (hi b h).not_unit <| he ▸ Multiset.dvd_prod h⟩
#align wf_dvd_monoid.not_unit_iff_exists_factors_eq WfDvdMonoid.not_unit_iff_exists_factors_eq
theorem isRelPrime_of_no_irreducible_factors {x y : α} (nonzero : ¬(x = 0 ∧ y = 0))
(H : ∀ z : α, Irreducible z → z ∣ x → ¬z ∣ y) : IsRelPrime x y :=
isRelPrime_of_no_nonunits_factors nonzero fun _z znu znz zx zy ↦
have ⟨i, h1, h2⟩ := exists_irreducible_factor znu znz
H i h1 (h2.trans zx) (h2.trans zy)
end WfDvdMonoid
theorem WfDvdMonoid.of_wellFounded_associates [CancelCommMonoidWithZero α]
(h : WellFounded ((· < ·) : Associates α → Associates α → Prop)) : WfDvdMonoid α :=
WfDvdMonoid.of_wfDvdMonoid_associates
⟨by
convert h
ext
exact Associates.dvdNotUnit_iff_lt⟩
#align wf_dvd_monoid.of_well_founded_associates WfDvdMonoid.of_wellFounded_associates
theorem WfDvdMonoid.iff_wellFounded_associates [CancelCommMonoidWithZero α] :
WfDvdMonoid α ↔ WellFounded ((· < ·) : Associates α → Associates α → Prop) :=
⟨by apply WfDvdMonoid.wellFounded_associates, WfDvdMonoid.of_wellFounded_associates⟩
#align wf_dvd_monoid.iff_well_founded_associates WfDvdMonoid.iff_wellFounded_associates
theorem WfDvdMonoid.max_power_factor' [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α}
(h : a₀ ≠ 0) (hx : ¬IsUnit x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a := by
obtain ⟨a, ⟨n, rfl⟩, hm⟩ := wellFounded_dvdNotUnit.has_min
{a | ∃ n, x ^ n * a = a₀} ⟨a₀, 0, by rw [pow_zero, one_mul]⟩
refine ⟨n, a, ?_, rfl⟩; rintro ⟨d, rfl⟩
exact hm d ⟨n + 1, by rw [pow_succ, mul_assoc]⟩
⟨(right_ne_zero_of_mul <| right_ne_zero_of_mul h), x, hx, mul_comm _ _⟩
theorem WfDvdMonoid.max_power_factor [CommMonoidWithZero α] [WfDvdMonoid α] {a₀ x : α}
(h : a₀ ≠ 0) (hx : Irreducible x) : ∃ (n : ℕ) (a : α), ¬x ∣ a ∧ a₀ = x ^ n * a :=
max_power_factor' h hx.not_unit
theorem multiplicity.finite_of_not_isUnit [CancelCommMonoidWithZero α] [WfDvdMonoid α]
{a b : α} (ha : ¬IsUnit a) (hb : b ≠ 0) : multiplicity.Finite a b := by
obtain ⟨n, c, ndvd, rfl⟩ := WfDvdMonoid.max_power_factor' hb ha
exact ⟨n, by rwa [pow_succ, mul_dvd_mul_iff_left (left_ne_zero_of_mul hb)]⟩
section Prio
-- set_option default_priority 100
-- see Note [default priority]
/-- unique factorization monoids.
These are defined as `CancelCommMonoidWithZero`s with well-founded strict divisibility
relations, but this is equivalent to more familiar definitions:
Each element (except zero) is uniquely represented as a multiset of irreducible factors.
Uniqueness is only up to associated elements.
Each element (except zero) is non-uniquely represented as a multiset
of prime factors.
To define a UFD using the definition in terms of multisets
of irreducible factors, use the definition `of_exists_unique_irreducible_factors`
To define a UFD using the definition in terms of multisets
of prime factors, use the definition `of_exists_prime_factors`
-/
class UniqueFactorizationMonoid (α : Type*) [CancelCommMonoidWithZero α] extends WfDvdMonoid α :
Prop where
protected irreducible_iff_prime : ∀ {a : α}, Irreducible a ↔ Prime a
#align unique_factorization_monoid UniqueFactorizationMonoid
/-- Can't be an instance because it would cause a loop `ufm → WfDvdMonoid → ufm → ...`. -/
theorem ufm_of_decomposition_of_wfDvdMonoid [CancelCommMonoidWithZero α] [WfDvdMonoid α]
[DecompositionMonoid α] : UniqueFactorizationMonoid α :=
{ ‹WfDvdMonoid α› with irreducible_iff_prime := irreducible_iff_prime }
#align ufm_of_gcd_of_wf_dvd_monoid ufm_of_decomposition_of_wfDvdMonoid
@[deprecated] alias ufm_of_gcd_of_wfDvdMonoid := ufm_of_decomposition_of_wfDvdMonoid
instance Associates.ufm [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α] :
UniqueFactorizationMonoid (Associates α) :=
{ (WfDvdMonoid.wfDvdMonoid_associates : WfDvdMonoid (Associates α)) with
irreducible_iff_prime := by
rw [← Associates.irreducible_iff_prime_iff]
apply UniqueFactorizationMonoid.irreducible_iff_prime }
#align associates.ufm Associates.ufm
end Prio
namespace UniqueFactorizationMonoid
variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α]
theorem exists_prime_factors (a : α) :
a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a := by
simp_rw [← UniqueFactorizationMonoid.irreducible_iff_prime]
apply WfDvdMonoid.exists_factors a
#align unique_factorization_monoid.exists_prime_factors UniqueFactorizationMonoid.exists_prime_factors
instance : DecompositionMonoid α where
primal a := by
obtain rfl | ha := eq_or_ne a 0; · exact isPrimal_zero
obtain ⟨f, hf, u, rfl⟩ := exists_prime_factors a ha
exact ((Submonoid.isPrimal α).multiset_prod_mem f (hf · ·|>.isPrimal)).mul u.isUnit.isPrimal
lemma exists_prime_iff :
(∃ (p : α), Prime p) ↔ ∃ (x : α), x ≠ 0 ∧ ¬ IsUnit x := by
refine ⟨fun ⟨p, hp⟩ ↦ ⟨p, hp.ne_zero, hp.not_unit⟩, fun ⟨x, hx₀, hxu⟩ ↦ ?_⟩
obtain ⟨f, hf, -⟩ := WfDvdMonoid.exists_irreducible_factor hxu hx₀
exact ⟨f, UniqueFactorizationMonoid.irreducible_iff_prime.mp hf⟩
@[elab_as_elim]
theorem induction_on_prime {P : α → Prop} (a : α) (h₁ : P 0) (h₂ : ∀ x : α, IsUnit x → P x)
(h₃ : ∀ a p : α, a ≠ 0 → Prime p → P a → P (p * a)) : P a := by
simp_rw [← UniqueFactorizationMonoid.irreducible_iff_prime] at h₃
exact WfDvdMonoid.induction_on_irreducible a h₁ h₂ h₃
#align unique_factorization_monoid.induction_on_prime UniqueFactorizationMonoid.induction_on_prime
end UniqueFactorizationMonoid
theorem prime_factors_unique [CancelCommMonoidWithZero α] :
∀ {f g : Multiset α},
(∀ x ∈ f, Prime x) → (∀ x ∈ g, Prime x) → f.prod ~ᵤ g.prod → Multiset.Rel Associated f g := by
classical
intro f
induction' f using Multiset.induction_on with p f ih
· intros g _ hg h
exact Multiset.rel_zero_left.2 <|
Multiset.eq_zero_of_forall_not_mem fun x hx =>
have : IsUnit g.prod := by simpa [associated_one_iff_isUnit] using h.symm
(hg x hx).not_unit <|
isUnit_iff_dvd_one.2 <| (Multiset.dvd_prod hx).trans (isUnit_iff_dvd_one.1 this)
· intros g hf hg hfg
let ⟨b, hbg, hb⟩ :=
(exists_associated_mem_of_dvd_prod (hf p (by simp)) fun q hq => hg _ hq) <|
hfg.dvd_iff_dvd_right.1 (show p ∣ (p ::ₘ f).prod by simp)
haveI := Classical.decEq α
rw [← Multiset.cons_erase hbg]
exact
Multiset.Rel.cons hb
(ih (fun q hq => hf _ (by simp [hq]))
(fun {q} (hq : q ∈ g.erase b) => hg q (Multiset.mem_of_mem_erase hq))
(Associated.of_mul_left
(by rwa [← Multiset.prod_cons, ← Multiset.prod_cons, Multiset.cons_erase hbg]) hb
(hf p (by simp)).ne_zero))
#align prime_factors_unique prime_factors_unique
namespace UniqueFactorizationMonoid
variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α]
theorem factors_unique {f g : Multiset α} (hf : ∀ x ∈ f, Irreducible x)
(hg : ∀ x ∈ g, Irreducible x) (h : f.prod ~ᵤ g.prod) : Multiset.Rel Associated f g :=
prime_factors_unique (fun x hx => UniqueFactorizationMonoid.irreducible_iff_prime.mp (hf x hx))
(fun x hx => UniqueFactorizationMonoid.irreducible_iff_prime.mp (hg x hx)) h
#align unique_factorization_monoid.factors_unique UniqueFactorizationMonoid.factors_unique
end UniqueFactorizationMonoid
/-- If an irreducible has a prime factorization,
then it is an associate of one of its prime factors. -/
theorem prime_factors_irreducible [CancelCommMonoidWithZero α] {a : α} {f : Multiset α}
(ha : Irreducible a) (pfa : (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a) : ∃ p, a ~ᵤ p ∧ f = {p} := by
haveI := Classical.decEq α
refine @Multiset.induction_on _
(fun g => (g.prod ~ᵤ a) → (∀ b ∈ g, Prime b) → ∃ p, a ~ᵤ p ∧ g = {p}) f ?_ ?_ pfa.2 pfa.1
· intro h; exact (ha.not_unit (associated_one_iff_isUnit.1 (Associated.symm h))).elim
· rintro p s _ ⟨u, hu⟩ hs
use p
have hs0 : s = 0 := by
by_contra hs0
obtain ⟨q, hq⟩ := Multiset.exists_mem_of_ne_zero hs0
apply (hs q (by simp [hq])).2.1
refine (ha.isUnit_or_isUnit (?_ : _ = p * ↑u * (s.erase q).prod * _)).resolve_left ?_
· rw [mul_right_comm _ _ q, mul_assoc, ← Multiset.prod_cons, Multiset.cons_erase hq, ← hu,
mul_comm, mul_comm p _, mul_assoc]
simp
apply mt isUnit_of_mul_isUnit_left (mt isUnit_of_mul_isUnit_left _)
apply (hs p (Multiset.mem_cons_self _ _)).2.1
simp only [mul_one, Multiset.prod_cons, Multiset.prod_zero, hs0] at *
exact ⟨Associated.symm ⟨u, hu⟩, rfl⟩
#align prime_factors_irreducible prime_factors_irreducible
section ExistsPrimeFactors
variable [CancelCommMonoidWithZero α]
variable (pf : ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a)
theorem WfDvdMonoid.of_exists_prime_factors : WfDvdMonoid α :=
⟨by
classical
refine RelHomClass.wellFounded
(RelHom.mk ?_ ?_ : (DvdNotUnit : α → α → Prop) →r ((· < ·) : ℕ∞ → ℕ∞ → Prop)) wellFounded_lt
· intro a
by_cases h : a = 0
· exact ⊤
exact ↑(Multiset.card (Classical.choose (pf a h)))
rintro a b ⟨ane0, ⟨c, hc, b_eq⟩⟩
rw [dif_neg ane0]
by_cases h : b = 0
· simp [h, lt_top_iff_ne_top]
· rw [dif_neg h]
erw [WithTop.coe_lt_coe]
have cne0 : c ≠ 0 := by
refine mt (fun con => ?_) h
rw [b_eq, con, mul_zero]
calc
Multiset.card (Classical.choose (pf a ane0)) <
_ + Multiset.card (Classical.choose (pf c cne0)) :=
lt_add_of_pos_right _
(Multiset.card_pos.mpr fun con => hc (associated_one_iff_isUnit.mp ?_))
_ = Multiset.card (Classical.choose (pf a ane0) + Classical.choose (pf c cne0)) :=
(Multiset.card_add _ _).symm
_ = Multiset.card (Classical.choose (pf b h)) :=
Multiset.card_eq_card_of_rel
(prime_factors_unique ?_ (Classical.choose_spec (pf _ h)).1 ?_)
· convert (Classical.choose_spec (pf c cne0)).2.symm
rw [con, Multiset.prod_zero]
· intro x hadd
rw [Multiset.mem_add] at hadd
cases' hadd with h h <;> apply (Classical.choose_spec (pf _ _)).1 _ h <;> assumption
· rw [Multiset.prod_add]
trans a * c
· apply Associated.mul_mul <;> apply (Classical.choose_spec (pf _ _)).2 <;> assumption
· rw [← b_eq]
apply (Classical.choose_spec (pf _ _)).2.symm; assumption⟩
#align wf_dvd_monoid.of_exists_prime_factors WfDvdMonoid.of_exists_prime_factors
theorem irreducible_iff_prime_of_exists_prime_factors {p : α} : Irreducible p ↔ Prime p := by
by_cases hp0 : p = 0
· simp [hp0]
refine ⟨fun h => ?_, Prime.irreducible⟩
obtain ⟨f, hf⟩ := pf p hp0
obtain ⟨q, hq, rfl⟩ := prime_factors_irreducible h hf
rw [hq.prime_iff]
exact hf.1 q (Multiset.mem_singleton_self _)
#align irreducible_iff_prime_of_exists_prime_factors irreducible_iff_prime_of_exists_prime_factors
theorem UniqueFactorizationMonoid.of_exists_prime_factors : UniqueFactorizationMonoid α :=
{ WfDvdMonoid.of_exists_prime_factors pf with
irreducible_iff_prime := irreducible_iff_prime_of_exists_prime_factors pf }
#align unique_factorization_monoid.of_exists_prime_factors UniqueFactorizationMonoid.of_exists_prime_factors
end ExistsPrimeFactors
theorem UniqueFactorizationMonoid.iff_exists_prime_factors [CancelCommMonoidWithZero α] :
UniqueFactorizationMonoid α ↔
∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Prime b) ∧ f.prod ~ᵤ a :=
⟨fun h => @UniqueFactorizationMonoid.exists_prime_factors _ _ h,
UniqueFactorizationMonoid.of_exists_prime_factors⟩
#align unique_factorization_monoid.iff_exists_prime_factors UniqueFactorizationMonoid.iff_exists_prime_factors
section
variable {β : Type*} [CancelCommMonoidWithZero α] [CancelCommMonoidWithZero β]
theorem MulEquiv.uniqueFactorizationMonoid (e : α ≃* β) (hα : UniqueFactorizationMonoid α) :
UniqueFactorizationMonoid β := by
rw [UniqueFactorizationMonoid.iff_exists_prime_factors] at hα ⊢
intro a ha
obtain ⟨w, hp, u, h⟩ :=
hα (e.symm a) fun h =>
ha <| by
convert← map_zero e
simp [← h]
exact
⟨w.map e, fun b hb =>
let ⟨c, hc, he⟩ := Multiset.mem_map.1 hb
he ▸ e.prime_iff.1 (hp c hc),
Units.map e.toMonoidHom u,
by
erw [Multiset.prod_hom, ← e.map_mul, h]
simp⟩
#align mul_equiv.unique_factorization_monoid MulEquiv.uniqueFactorizationMonoid
theorem MulEquiv.uniqueFactorizationMonoid_iff (e : α ≃* β) :
UniqueFactorizationMonoid α ↔ UniqueFactorizationMonoid β :=
⟨e.uniqueFactorizationMonoid, e.symm.uniqueFactorizationMonoid⟩
#align mul_equiv.unique_factorization_monoid_iff MulEquiv.uniqueFactorizationMonoid_iff
end
theorem irreducible_iff_prime_of_exists_unique_irreducible_factors [CancelCommMonoidWithZero α]
(eif : ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ f.prod ~ᵤ a)
(uif :
∀ f g : Multiset α,
(∀ x ∈ f, Irreducible x) →
(∀ x ∈ g, Irreducible x) → f.prod ~ᵤ g.prod → Multiset.Rel Associated f g)
(p : α) : Irreducible p ↔ Prime p :=
letI := Classical.decEq α
⟨ fun hpi =>
⟨hpi.ne_zero, hpi.1, fun a b ⟨x, hx⟩ =>
if hab0 : a * b = 0 then
(eq_zero_or_eq_zero_of_mul_eq_zero hab0).elim (fun ha0 => by simp [ha0]) fun hb0 => by
simp [hb0]
else by
have hx0 : x ≠ 0 := fun hx0 => by simp_all
have ha0 : a ≠ 0 := left_ne_zero_of_mul hab0
have hb0 : b ≠ 0 := right_ne_zero_of_mul hab0
cases' eif x hx0 with fx hfx
cases' eif a ha0 with fa hfa
cases' eif b hb0 with fb hfb
have h : Multiset.Rel Associated (p ::ₘ fx) (fa + fb) := by
apply uif
· exact fun i hi => (Multiset.mem_cons.1 hi).elim (fun hip => hip.symm ▸ hpi) (hfx.1 _)
· exact fun i hi => (Multiset.mem_add.1 hi).elim (hfa.1 _) (hfb.1 _)
calc
Multiset.prod (p ::ₘ fx) ~ᵤ a * b := by
rw [hx, Multiset.prod_cons]; exact hfx.2.mul_left _
_ ~ᵤ fa.prod * fb.prod := hfa.2.symm.mul_mul hfb.2.symm
_ = _ := by rw [Multiset.prod_add]
exact
let ⟨q, hqf, hq⟩ := Multiset.exists_mem_of_rel_of_mem h (Multiset.mem_cons_self p _)
(Multiset.mem_add.1 hqf).elim
(fun hqa =>
Or.inl <| hq.dvd_iff_dvd_left.2 <| hfa.2.dvd_iff_dvd_right.1 (Multiset.dvd_prod hqa))
fun hqb =>
Or.inr <| hq.dvd_iff_dvd_left.2 <| hfb.2.dvd_iff_dvd_right.1 (Multiset.dvd_prod hqb)⟩,
Prime.irreducible⟩
#align irreducible_iff_prime_of_exists_unique_irreducible_factors irreducible_iff_prime_of_exists_unique_irreducible_factors
theorem UniqueFactorizationMonoid.of_exists_unique_irreducible_factors [CancelCommMonoidWithZero α]
(eif : ∀ a : α, a ≠ 0 → ∃ f : Multiset α, (∀ b ∈ f, Irreducible b) ∧ f.prod ~ᵤ a)
(uif :
∀ f g : Multiset α,
(∀ x ∈ f, Irreducible x) →
(∀ x ∈ g, Irreducible x) → f.prod ~ᵤ g.prod → Multiset.Rel Associated f g) :
UniqueFactorizationMonoid α :=
UniqueFactorizationMonoid.of_exists_prime_factors
(by
convert eif using 7
simp_rw [irreducible_iff_prime_of_exists_unique_irreducible_factors eif uif])
#align unique_factorization_monoid.of_exists_unique_irreducible_factors UniqueFactorizationMonoid.of_exists_unique_irreducible_factors
namespace UniqueFactorizationMonoid
variable [CancelCommMonoidWithZero α]
variable [UniqueFactorizationMonoid α]
open Classical in
/-- Noncomputably determines the multiset of prime factors. -/
noncomputable def factors (a : α) : Multiset α :=
if h : a = 0 then 0 else Classical.choose (UniqueFactorizationMonoid.exists_prime_factors a h)
#align unique_factorization_monoid.factors UniqueFactorizationMonoid.factors
theorem factors_prod {a : α} (ane0 : a ≠ 0) : Associated (factors a).prod a := by
rw [factors, dif_neg ane0]
exact (Classical.choose_spec (exists_prime_factors a ane0)).2
#align unique_factorization_monoid.factors_prod UniqueFactorizationMonoid.factors_prod
@[simp]
theorem factors_zero : factors (0 : α) = 0 := by simp [factors]
#align unique_factorization_monoid.factors_zero UniqueFactorizationMonoid.factors_zero
theorem ne_zero_of_mem_factors {p a : α} (h : p ∈ factors a) : a ≠ 0 := by
rintro rfl
simp at h
#align unique_factorization_monoid.ne_zero_of_mem_factors UniqueFactorizationMonoid.ne_zero_of_mem_factors
theorem dvd_of_mem_factors {p a : α} (h : p ∈ factors a) : p ∣ a :=
dvd_trans (Multiset.dvd_prod h) (Associated.dvd (factors_prod (ne_zero_of_mem_factors h)))
#align unique_factorization_monoid.dvd_of_mem_factors UniqueFactorizationMonoid.dvd_of_mem_factors
theorem prime_of_factor {a : α} (x : α) (hx : x ∈ factors a) : Prime x := by
have ane0 := ne_zero_of_mem_factors hx
rw [factors, dif_neg ane0] at hx
exact (Classical.choose_spec (UniqueFactorizationMonoid.exists_prime_factors a ane0)).1 x hx
#align unique_factorization_monoid.prime_of_factor UniqueFactorizationMonoid.prime_of_factor
theorem irreducible_of_factor {a : α} : ∀ x : α, x ∈ factors a → Irreducible x := fun x h =>
(prime_of_factor x h).irreducible
#align unique_factorization_monoid.irreducible_of_factor UniqueFactorizationMonoid.irreducible_of_factor
@[simp]
theorem factors_one : factors (1 : α) = 0 := by
nontriviality α using factors
rw [← Multiset.rel_zero_right]
refine factors_unique irreducible_of_factor (fun x hx => (Multiset.not_mem_zero x hx).elim) ?_
rw [Multiset.prod_zero]
exact factors_prod one_ne_zero
#align unique_factorization_monoid.factors_one UniqueFactorizationMonoid.factors_one
theorem exists_mem_factors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) :
p ∣ a → ∃ q ∈ factors a, p ~ᵤ q := fun ⟨b, hb⟩ =>
have hb0 : b ≠ 0 := fun hb0 => by simp_all
have : Multiset.Rel Associated (p ::ₘ factors b) (factors a) :=
factors_unique
(fun x hx => (Multiset.mem_cons.1 hx).elim (fun h => h.symm ▸ hp) (irreducible_of_factor _))
irreducible_of_factor
(Associated.symm <|
calc
Multiset.prod (factors a) ~ᵤ a := factors_prod ha0
_ = p * b := hb
_ ~ᵤ Multiset.prod (p ::ₘ factors b) := by
rw [Multiset.prod_cons]; exact (factors_prod hb0).symm.mul_left _
)
Multiset.exists_mem_of_rel_of_mem this (by simp)
#align unique_factorization_monoid.exists_mem_factors_of_dvd UniqueFactorizationMonoid.exists_mem_factors_of_dvd
theorem exists_mem_factors {x : α} (hx : x ≠ 0) (h : ¬IsUnit x) : ∃ p, p ∈ factors x := by
obtain ⟨p', hp', hp'x⟩ := WfDvdMonoid.exists_irreducible_factor h hx
obtain ⟨p, hp, _⟩ := exists_mem_factors_of_dvd hx hp' hp'x
exact ⟨p, hp⟩
#align unique_factorization_monoid.exists_mem_factors UniqueFactorizationMonoid.exists_mem_factors
open Classical in
theorem factors_mul {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
Multiset.Rel Associated (factors (x * y)) (factors x + factors y) := by
refine
factors_unique irreducible_of_factor
(fun a ha =>
(Multiset.mem_add.mp ha).by_cases (irreducible_of_factor _) (irreducible_of_factor _))
((factors_prod (mul_ne_zero hx hy)).trans ?_)
rw [Multiset.prod_add]
exact (Associated.mul_mul (factors_prod hx) (factors_prod hy)).symm
#align unique_factorization_monoid.factors_mul UniqueFactorizationMonoid.factors_mul
theorem factors_pow {x : α} (n : ℕ) :
Multiset.Rel Associated (factors (x ^ n)) (n • factors x) := by
match n with
| 0 => rw [zero_smul, pow_zero, factors_one, Multiset.rel_zero_right]
| n+1 =>
by_cases h0 : x = 0
· simp [h0, zero_pow n.succ_ne_zero, smul_zero]
· rw [pow_succ', succ_nsmul']
refine Multiset.Rel.trans _ (factors_mul h0 (pow_ne_zero n h0)) ?_
refine Multiset.Rel.add ?_ <| factors_pow n
exact Multiset.rel_refl_of_refl_on fun y _ => Associated.refl _
#align unique_factorization_monoid.factors_pow UniqueFactorizationMonoid.factors_pow
@[simp]
theorem factors_pos (x : α) (hx : x ≠ 0) : 0 < factors x ↔ ¬IsUnit x := by
constructor
· intro h hx
obtain ⟨p, hp⟩ := Multiset.exists_mem_of_ne_zero h.ne'
exact (prime_of_factor _ hp).not_unit (isUnit_of_dvd_unit (dvd_of_mem_factors hp) hx)
· intro h
obtain ⟨p, hp⟩ := exists_mem_factors hx h
exact
bot_lt_iff_ne_bot.mpr
(mt Multiset.eq_zero_iff_forall_not_mem.mp (not_forall.mpr ⟨p, not_not.mpr hp⟩))
#align unique_factorization_monoid.factors_pos UniqueFactorizationMonoid.factors_pos
open Multiset in
theorem factors_pow_count_prod [DecidableEq α] {x : α} (hx : x ≠ 0) :
(∏ p ∈ (factors x).toFinset, p ^ (factors x).count p) ~ᵤ x :=
calc
_ = prod (∑ a ∈ toFinset (factors x), count a (factors x) • {a}) := by
simp only [prod_sum, prod_nsmul, prod_singleton]
_ = prod (factors x) := by rw [toFinset_sum_count_nsmul_eq (factors x)]
_ ~ᵤ x := factors_prod hx
end UniqueFactorizationMonoid
namespace UniqueFactorizationMonoid
variable [CancelCommMonoidWithZero α] [NormalizationMonoid α]
variable [UniqueFactorizationMonoid α]
/-- Noncomputably determines the multiset of prime factors. -/
noncomputable def normalizedFactors (a : α) : Multiset α :=
Multiset.map normalize <| factors a
#align unique_factorization_monoid.normalized_factors UniqueFactorizationMonoid.normalizedFactors
/-- An arbitrary choice of factors of `x : M` is exactly the (unique) normalized set of factors,
if `M` has a trivial group of units. -/
@[simp]
theorem factors_eq_normalizedFactors {M : Type*} [CancelCommMonoidWithZero M]
[UniqueFactorizationMonoid M] [Unique Mˣ] (x : M) : factors x = normalizedFactors x := by
unfold normalizedFactors
convert (Multiset.map_id (factors x)).symm
ext p
exact normalize_eq p
#align unique_factorization_monoid.factors_eq_normalized_factors UniqueFactorizationMonoid.factors_eq_normalizedFactors
theorem normalizedFactors_prod {a : α} (ane0 : a ≠ 0) :
Associated (normalizedFactors a).prod a := by
rw [normalizedFactors, factors, dif_neg ane0]
refine Associated.trans ?_ (Classical.choose_spec (exists_prime_factors a ane0)).2
rw [← Associates.mk_eq_mk_iff_associated, ← Associates.prod_mk, ← Associates.prod_mk,
Multiset.map_map]
congr 2
ext
rw [Function.comp_apply, Associates.mk_normalize]
#align unique_factorization_monoid.normalized_factors_prod UniqueFactorizationMonoid.normalizedFactors_prod
theorem prime_of_normalized_factor {a : α} : ∀ x : α, x ∈ normalizedFactors a → Prime x := by
rw [normalizedFactors, factors]
split_ifs with ane0; · simp
intro x hx; rcases Multiset.mem_map.1 hx with ⟨y, ⟨hy, rfl⟩⟩
rw [(normalize_associated _).prime_iff]
exact (Classical.choose_spec (UniqueFactorizationMonoid.exists_prime_factors a ane0)).1 y hy
#align unique_factorization_monoid.prime_of_normalized_factor UniqueFactorizationMonoid.prime_of_normalized_factor
theorem irreducible_of_normalized_factor {a : α} :
∀ x : α, x ∈ normalizedFactors a → Irreducible x := fun x h =>
(prime_of_normalized_factor x h).irreducible
#align unique_factorization_monoid.irreducible_of_normalized_factor UniqueFactorizationMonoid.irreducible_of_normalized_factor
theorem normalize_normalized_factor {a : α} :
∀ x : α, x ∈ normalizedFactors a → normalize x = x := by
rw [normalizedFactors, factors]
split_ifs with h; · simp
intro x hx
obtain ⟨y, _, rfl⟩ := Multiset.mem_map.1 hx
apply normalize_idem
#align unique_factorization_monoid.normalize_normalized_factor UniqueFactorizationMonoid.normalize_normalized_factor
theorem normalizedFactors_irreducible {a : α} (ha : Irreducible a) :
normalizedFactors a = {normalize a} := by
obtain ⟨p, a_assoc, hp⟩ :=
prime_factors_irreducible ha ⟨prime_of_normalized_factor, normalizedFactors_prod ha.ne_zero⟩
have p_mem : p ∈ normalizedFactors a := by
rw [hp]
exact Multiset.mem_singleton_self _
convert hp
rwa [← normalize_normalized_factor p p_mem, normalize_eq_normalize_iff, dvd_dvd_iff_associated]
#align unique_factorization_monoid.normalized_factors_irreducible UniqueFactorizationMonoid.normalizedFactors_irreducible
theorem normalizedFactors_eq_of_dvd (a : α) :
∀ᵉ (p ∈ normalizedFactors a) (q ∈ normalizedFactors a), p ∣ q → p = q := by
intro p hp q hq hdvd
convert normalize_eq_normalize hdvd
((prime_of_normalized_factor _ hp).irreducible.dvd_symm
(prime_of_normalized_factor _ hq).irreducible hdvd) <;>
apply (normalize_normalized_factor _ ‹_›).symm
#align unique_factorization_monoid.normalized_factors_eq_of_dvd UniqueFactorizationMonoid.normalizedFactors_eq_of_dvd
theorem exists_mem_normalizedFactors_of_dvd {a p : α} (ha0 : a ≠ 0) (hp : Irreducible p) :
p ∣ a → ∃ q ∈ normalizedFactors a, p ~ᵤ q := fun ⟨b, hb⟩ =>
have hb0 : b ≠ 0 := fun hb0 => by simp_all
have : Multiset.Rel Associated (p ::ₘ normalizedFactors b) (normalizedFactors a) :=
factors_unique
(fun x hx =>
(Multiset.mem_cons.1 hx).elim (fun h => h.symm ▸ hp) (irreducible_of_normalized_factor _))
irreducible_of_normalized_factor
(Associated.symm <|
calc
Multiset.prod (normalizedFactors a) ~ᵤ a := normalizedFactors_prod ha0
_ = p * b := hb
_ ~ᵤ Multiset.prod (p ::ₘ normalizedFactors b) := by
rw [Multiset.prod_cons]
exact (normalizedFactors_prod hb0).symm.mul_left _
)
Multiset.exists_mem_of_rel_of_mem this (by simp)
#align unique_factorization_monoid.exists_mem_normalized_factors_of_dvd UniqueFactorizationMonoid.exists_mem_normalizedFactors_of_dvd
theorem exists_mem_normalizedFactors {x : α} (hx : x ≠ 0) (h : ¬IsUnit x) :
∃ p, p ∈ normalizedFactors x := by
obtain ⟨p', hp', hp'x⟩ := WfDvdMonoid.exists_irreducible_factor h hx
obtain ⟨p, hp, _⟩ := exists_mem_normalizedFactors_of_dvd hx hp' hp'x
exact ⟨p, hp⟩
#align unique_factorization_monoid.exists_mem_normalized_factors UniqueFactorizationMonoid.exists_mem_normalizedFactors
@[simp]
theorem normalizedFactors_zero : normalizedFactors (0 : α) = 0 := by
simp [normalizedFactors, factors]
#align unique_factorization_monoid.normalized_factors_zero UniqueFactorizationMonoid.normalizedFactors_zero
@[simp]
theorem normalizedFactors_one : normalizedFactors (1 : α) = 0 := by
cases' subsingleton_or_nontrivial α with h h
· dsimp [normalizedFactors, factors]
simp [Subsingleton.elim (1:α) 0]
· rw [← Multiset.rel_zero_right]
apply factors_unique irreducible_of_normalized_factor
· intro x hx
exfalso
apply Multiset.not_mem_zero x hx
· apply normalizedFactors_prod one_ne_zero
#align unique_factorization_monoid.normalized_factors_one UniqueFactorizationMonoid.normalizedFactors_one
@[simp]
theorem normalizedFactors_mul {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
normalizedFactors (x * y) = normalizedFactors x + normalizedFactors y := by
have h : (normalize : α → α) = Associates.out ∘ Associates.mk := by
ext
rw [Function.comp_apply, Associates.out_mk]
rw [← Multiset.map_id' (normalizedFactors (x * y)), ← Multiset.map_id' (normalizedFactors x), ←
Multiset.map_id' (normalizedFactors y), ← Multiset.map_congr rfl normalize_normalized_factor, ←
Multiset.map_congr rfl normalize_normalized_factor, ←
Multiset.map_congr rfl normalize_normalized_factor, ← Multiset.map_add, h, ←
Multiset.map_map Associates.out, eq_comm, ← Multiset.map_map Associates.out]
refine congr rfl ?_
apply Multiset.map_mk_eq_map_mk_of_rel
apply factors_unique
· intro x hx
rcases Multiset.mem_add.1 hx with (hx | hx) <;> exact irreducible_of_normalized_factor x hx
· exact irreducible_of_normalized_factor
· rw [Multiset.prod_add]
exact
((normalizedFactors_prod hx).mul_mul (normalizedFactors_prod hy)).trans
(normalizedFactors_prod (mul_ne_zero hx hy)).symm
#align unique_factorization_monoid.normalized_factors_mul UniqueFactorizationMonoid.normalizedFactors_mul
@[simp]
theorem normalizedFactors_pow {x : α} (n : ℕ) :
normalizedFactors (x ^ n) = n • normalizedFactors x := by
induction' n with n ih
· simp
by_cases h0 : x = 0
· simp [h0, zero_pow n.succ_ne_zero, smul_zero]
rw [pow_succ', succ_nsmul', normalizedFactors_mul h0 (pow_ne_zero _ h0), ih]
#align unique_factorization_monoid.normalized_factors_pow UniqueFactorizationMonoid.normalizedFactors_pow
theorem _root_.Irreducible.normalizedFactors_pow {p : α} (hp : Irreducible p) (k : ℕ) :
normalizedFactors (p ^ k) = Multiset.replicate k (normalize p) := by
rw [UniqueFactorizationMonoid.normalizedFactors_pow, normalizedFactors_irreducible hp,
Multiset.nsmul_singleton]
#align irreducible.normalized_factors_pow Irreducible.normalizedFactors_pow
theorem normalizedFactors_prod_eq (s : Multiset α) (hs : ∀ a ∈ s, Irreducible a) :
normalizedFactors s.prod = s.map normalize := by
induction' s using Multiset.induction with a s ih
· rw [Multiset.prod_zero, normalizedFactors_one, Multiset.map_zero]
· have ia := hs a (Multiset.mem_cons_self a _)
have ib := fun b h => hs b (Multiset.mem_cons_of_mem h)
obtain rfl | ⟨b, hb⟩ := s.empty_or_exists_mem
· rw [Multiset.cons_zero, Multiset.prod_singleton, Multiset.map_singleton,
normalizedFactors_irreducible ia]
haveI := nontrivial_of_ne b 0 (ib b hb).ne_zero
rw [Multiset.prod_cons, Multiset.map_cons,
normalizedFactors_mul ia.ne_zero (Multiset.prod_ne_zero fun h => (ib 0 h).ne_zero rfl),
normalizedFactors_irreducible ia, ih ib, Multiset.singleton_add]
#align unique_factorization_monoid.normalized_factors_prod_eq UniqueFactorizationMonoid.normalizedFactors_prod_eq
theorem dvd_iff_normalizedFactors_le_normalizedFactors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
x ∣ y ↔ normalizedFactors x ≤ normalizedFactors y := by
constructor
· rintro ⟨c, rfl⟩
simp [hx, right_ne_zero_of_mul hy]
· rw [← (normalizedFactors_prod hx).dvd_iff_dvd_left, ←
(normalizedFactors_prod hy).dvd_iff_dvd_right]
apply Multiset.prod_dvd_prod_of_le
#align unique_factorization_monoid.dvd_iff_normalized_factors_le_normalized_factors UniqueFactorizationMonoid.dvd_iff_normalizedFactors_le_normalizedFactors
theorem associated_iff_normalizedFactors_eq_normalizedFactors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
x ~ᵤ y ↔ normalizedFactors x = normalizedFactors y := by
refine
⟨fun h => ?_, fun h =>
(normalizedFactors_prod hx).symm.trans (_root_.trans (by rw [h]) (normalizedFactors_prod hy))⟩
apply le_antisymm <;> rw [← dvd_iff_normalizedFactors_le_normalizedFactors]
all_goals simp [*, h.dvd, h.symm.dvd]
#align unique_factorization_monoid.associated_iff_normalized_factors_eq_normalized_factors UniqueFactorizationMonoid.associated_iff_normalizedFactors_eq_normalizedFactors
theorem normalizedFactors_of_irreducible_pow {p : α} (hp : Irreducible p) (k : ℕ) :
normalizedFactors (p ^ k) = Multiset.replicate k (normalize p) := by
rw [normalizedFactors_pow, normalizedFactors_irreducible hp, Multiset.nsmul_singleton]
#align unique_factorization_monoid.normalized_factors_of_irreducible_pow UniqueFactorizationMonoid.normalizedFactors_of_irreducible_pow
theorem zero_not_mem_normalizedFactors (x : α) : (0 : α) ∉ normalizedFactors x := fun h =>
Prime.ne_zero (prime_of_normalized_factor _ h) rfl
#align unique_factorization_monoid.zero_not_mem_normalized_factors UniqueFactorizationMonoid.zero_not_mem_normalizedFactors
theorem dvd_of_mem_normalizedFactors {a p : α} (H : p ∈ normalizedFactors a) : p ∣ a := by
by_cases hcases : a = 0
· rw [hcases]
exact dvd_zero p
· exact dvd_trans (Multiset.dvd_prod H) (Associated.dvd (normalizedFactors_prod hcases))
#align unique_factorization_monoid.dvd_of_mem_normalized_factors UniqueFactorizationMonoid.dvd_of_mem_normalizedFactors
theorem mem_normalizedFactors_iff [Unique αˣ] {p x : α} (hx : x ≠ 0) :
p ∈ normalizedFactors x ↔ Prime p ∧ p ∣ x := by
constructor
· intro h
exact ⟨prime_of_normalized_factor p h, dvd_of_mem_normalizedFactors h⟩
· rintro ⟨hprime, hdvd⟩
obtain ⟨q, hqmem, hqeq⟩ := exists_mem_normalizedFactors_of_dvd hx hprime.irreducible hdvd
rw [associated_iff_eq] at hqeq
exact hqeq ▸ hqmem
theorem exists_associated_prime_pow_of_unique_normalized_factor {p r : α}
(h : ∀ {m}, m ∈ normalizedFactors r → m = p) (hr : r ≠ 0) : ∃ i : ℕ, Associated (p ^ i) r := by
use Multiset.card.toFun (normalizedFactors r)
have := UniqueFactorizationMonoid.normalizedFactors_prod hr
rwa [Multiset.eq_replicate_of_mem fun b => h, Multiset.prod_replicate] at this
#align unique_factorization_monoid.exists_associated_prime_pow_of_unique_normalized_factor UniqueFactorizationMonoid.exists_associated_prime_pow_of_unique_normalized_factor
theorem normalizedFactors_prod_of_prime [Nontrivial α] [Unique αˣ] {m : Multiset α}
(h : ∀ p ∈ m, Prime p) : normalizedFactors m.prod = m := by
simpa only [← Multiset.rel_eq, ← associated_eq_eq] using
prime_factors_unique prime_of_normalized_factor h
(normalizedFactors_prod (m.prod_ne_zero_of_prime h))
#align unique_factorization_monoid.normalized_factors_prod_of_prime UniqueFactorizationMonoid.normalizedFactors_prod_of_prime
theorem mem_normalizedFactors_eq_of_associated {a b c : α} (ha : a ∈ normalizedFactors c)
(hb : b ∈ normalizedFactors c) (h : Associated a b) : a = b := by
rw [← normalize_normalized_factor a ha, ← normalize_normalized_factor b hb,
normalize_eq_normalize_iff]
exact Associated.dvd_dvd h
#align unique_factorization_monoid.mem_normalized_factors_eq_of_associated UniqueFactorizationMonoid.mem_normalizedFactors_eq_of_associated
@[simp]
theorem normalizedFactors_pos (x : α) (hx : x ≠ 0) : 0 < normalizedFactors x ↔ ¬IsUnit x := by
constructor
· intro h hx
obtain ⟨p, hp⟩ := Multiset.exists_mem_of_ne_zero h.ne'
exact
(prime_of_normalized_factor _ hp).not_unit
(isUnit_of_dvd_unit (dvd_of_mem_normalizedFactors hp) hx)
· intro h
obtain ⟨p, hp⟩ := exists_mem_normalizedFactors hx h
exact
bot_lt_iff_ne_bot.mpr
(mt Multiset.eq_zero_iff_forall_not_mem.mp (not_forall.mpr ⟨p, not_not.mpr hp⟩))
#align unique_factorization_monoid.normalized_factors_pos UniqueFactorizationMonoid.normalizedFactors_pos
theorem dvdNotUnit_iff_normalizedFactors_lt_normalizedFactors {x y : α} (hx : x ≠ 0) (hy : y ≠ 0) :
DvdNotUnit x y ↔ normalizedFactors x < normalizedFactors y := by
constructor
· rintro ⟨_, c, hc, rfl⟩
simp only [hx, right_ne_zero_of_mul hy, normalizedFactors_mul, Ne, not_false_iff,
lt_add_iff_pos_right, normalizedFactors_pos, hc]
· intro h
exact
dvdNotUnit_of_dvd_of_not_dvd
((dvd_iff_normalizedFactors_le_normalizedFactors hx hy).mpr h.le)
(mt (dvd_iff_normalizedFactors_le_normalizedFactors hy hx).mp h.not_le)
#align unique_factorization_monoid.dvd_not_unit_iff_normalized_factors_lt_normalized_factors UniqueFactorizationMonoid.dvdNotUnit_iff_normalizedFactors_lt_normalizedFactors
theorem normalizedFactors_multiset_prod (s : Multiset α) (hs : 0 ∉ s) :
normalizedFactors (s.prod) = (s.map normalizedFactors).sum := by
cases subsingleton_or_nontrivial α
· obtain rfl : s = 0 := by
apply Multiset.eq_zero_of_forall_not_mem
intro _
convert hs
simp
induction s using Multiset.induction with
| empty => simp
| cons _ _ IH =>
rw [Multiset.prod_cons, Multiset.map_cons, Multiset.sum_cons, normalizedFactors_mul, IH]
· exact fun h ↦ hs (Multiset.mem_cons_of_mem h)
· exact fun h ↦ hs (h ▸ Multiset.mem_cons_self _ _)
· apply Multiset.prod_ne_zero
exact fun h ↦ hs (Multiset.mem_cons_of_mem h)
end UniqueFactorizationMonoid
namespace UniqueFactorizationMonoid
open scoped Classical
open Multiset Associates
variable [CancelCommMonoidWithZero α] [UniqueFactorizationMonoid α]
/-- Noncomputably defines a `normalizationMonoid` structure on a `UniqueFactorizationMonoid`. -/
protected noncomputable def normalizationMonoid : NormalizationMonoid α :=
normalizationMonoidOfMonoidHomRightInverse
{ toFun := fun a : Associates α =>
if a = 0 then 0
else
((normalizedFactors a).map
(Classical.choose mk_surjective.hasRightInverse : Associates α → α)).prod
map_one' := by nontriviality α; simp
map_mul' := fun x y => by
by_cases hx : x = 0
· simp [hx]
by_cases hy : y = 0
· simp [hy]
simp [hx, hy] }
(by
intro x
dsimp
by_cases hx : x = 0
· simp [hx]
have h : Associates.mkMonoidHom ∘ Classical.choose mk_surjective.hasRightInverse =
(id : Associates α → Associates α) := by
ext x
rw [Function.comp_apply, mkMonoidHom_apply,
Classical.choose_spec mk_surjective.hasRightInverse x]
rfl
rw [if_neg hx, ← mkMonoidHom_apply, MonoidHom.map_multiset_prod, map_map, h, map_id, ←
associated_iff_eq]
apply normalizedFactors_prod hx)
#align unique_factorization_monoid.normalization_monoid UniqueFactorizationMonoid.normalizationMonoid
end UniqueFactorizationMonoid
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
/-- Euclid's lemma: if `a ∣ b * c` and `a` and `c` have no common prime factors, `a ∣ b`.
Compare `IsCoprime.dvd_of_dvd_mul_left`. -/
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
/-- Euclid's lemma: if `a ∣ b * c` and `a` and `b` have no common prime factors, `a ∣ c`.
Compare `IsCoprime.dvd_of_dvd_mul_right`. -/
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
/-- If `a ≠ 0, b` are elements of a unique factorization domain, then dividing
out their common factor `c'` gives `a'` and `b'` with no factors in common. -/
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 multiplicity
variable [NormalizationMonoid R]
variable [DecidableRel (Dvd.dvd : R → R → Prop)]
open multiplicity Multiset
theorem le_multiplicity_iff_replicate_le_normalizedFactors {a b : R} {n : ℕ} (ha : Irreducible a)
(hb : b ≠ 0) :
↑n ≤ multiplicity a b ↔ replicate n (normalize a) ≤ normalizedFactors b := by
rw [← pow_dvd_iff_le_multiplicity]
revert b
induction' n with n ih; · simp
intro b hb
constructor
· rintro ⟨c, rfl⟩
rw [Ne, pow_succ', mul_assoc, mul_eq_zero, not_or] at hb
rw [pow_succ', mul_assoc, normalizedFactors_mul hb.1 hb.2, replicate_succ,
normalizedFactors_irreducible ha, singleton_add, cons_le_cons_iff, ← ih hb.2]
apply Dvd.intro _ rfl
· rw [Multiset.le_iff_exists_add]
rintro ⟨u, hu⟩
rw [← (normalizedFactors_prod hb).dvd_iff_dvd_right, hu, prod_add, prod_replicate]
exact (Associated.pow_pow <| associated_normalize a).dvd.trans (Dvd.intro u.prod rfl)
#align unique_factorization_monoid.le_multiplicity_iff_replicate_le_normalized_factors UniqueFactorizationMonoid.le_multiplicity_iff_replicate_le_normalizedFactors
/-- The multiplicity of an irreducible factor of a nonzero element is exactly the number of times
the normalized factor occurs in the `normalizedFactors`.
See also `count_normalizedFactors_eq` which expands the definition of `multiplicity`
to produce a specification for `count (normalizedFactors _) _`..
-/
theorem multiplicity_eq_count_normalizedFactors [DecidableEq R] {a b : R} (ha : Irreducible a)
(hb : b ≠ 0) : multiplicity a b = (normalizedFactors b).count (normalize a) := by
apply le_antisymm
· apply PartENat.le_of_lt_add_one
rw [← Nat.cast_one, ← Nat.cast_add, lt_iff_not_ge, ge_iff_le,
le_multiplicity_iff_replicate_le_normalizedFactors ha hb, ← le_count_iff_replicate_le]
simp
rw [le_multiplicity_iff_replicate_le_normalizedFactors ha hb, ← le_count_iff_replicate_le]
#align unique_factorization_monoid.multiplicity_eq_count_normalized_factors UniqueFactorizationMonoid.multiplicity_eq_count_normalizedFactors
/-- The number of times an irreducible factor `p` appears in `normalizedFactors x` is defined by
the number of times it divides `x`.
See also `multiplicity_eq_count_normalizedFactors` if `n` is given by `multiplicity p x`.
-/
theorem count_normalizedFactors_eq [DecidableEq R] {p x : R} (hp : Irreducible p)
(hnorm : normalize p = p) {n : ℕ} (hle : p ^ n ∣ x) (hlt : ¬p ^ (n + 1) ∣ x) :
(normalizedFactors x).count p = n := by
letI : DecidableRel ((· ∣ ·) : R → R → Prop) := fun _ _ => Classical.propDecidable _
by_cases hx0 : x = 0
· simp [hx0] at hlt
rw [← PartENat.natCast_inj]
convert (multiplicity_eq_count_normalizedFactors hp hx0).symm
· exact hnorm.symm
exact (multiplicity.eq_coe_iff.mpr ⟨hle, hlt⟩).symm
#align unique_factorization_monoid.count_normalized_factors_eq UniqueFactorizationMonoid.count_normalizedFactors_eq
/-- The number of times an irreducible factor `p` appears in `normalizedFactors x` is defined by
the number of times it divides `x`. This is a slightly more general version of
`UniqueFactorizationMonoid.count_normalizedFactors_eq` that allows `p = 0`.
See also `multiplicity_eq_count_normalizedFactors` if `n` is given by `multiplicity p x`.
-/
theorem count_normalizedFactors_eq' [DecidableEq R] {p x : R} (hp : p = 0 ∨ Irreducible p)
(hnorm : normalize p = p) {n : ℕ} (hle : p ^ n ∣ x) (hlt : ¬p ^ (n + 1) ∣ x) :
(normalizedFactors x).count p = n := by
rcases hp with (rfl | hp)
· cases n
· exact count_eq_zero.2 (zero_not_mem_normalizedFactors _)
· rw [zero_pow (Nat.succ_ne_zero _)] at hle hlt
exact absurd hle hlt
· exact count_normalizedFactors_eq hp hnorm hle hlt
#align unique_factorization_monoid.count_normalized_factors_eq' UniqueFactorizationMonoid.count_normalizedFactors_eq'
/-- Deprecated. Use `WfDvdMonoid.max_power_factor` instead. -/
@[deprecated WfDvdMonoid.max_power_factor]
theorem max_power_factor {a₀ x : R} (h : a₀ ≠ 0) (hx : Irreducible x) :
∃ n : ℕ, ∃ a : R, ¬x ∣ a ∧ a₀ = x ^ n * a := WfDvdMonoid.max_power_factor h hx
#align unique_factorization_monoid.max_power_factor UniqueFactorizationMonoid.max_power_factor
end multiplicity
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
/-- If `P` holds for units and powers of primes,
and `P x ∧ P y` for coprime `x, y` implies `P (x * y)`,
then `P` holds on a product of powers of distinct primes. -/
-- @[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
/-- If `P` holds for `0`, units and powers of primes,
and `P x ∧ P y` for coprime `x, y` implies `P (x * y)`,
then `P` holds on all `a : α`. -/
@[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
/-- If `f` maps `p ^ i` to `(f p) ^ i` for primes `p`, and `f`
is multiplicative on coprime elements, then `f` is multiplicative on all products of primes. -/
-- @[elab_as_elim] Porting note: commented out
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]
#align unique_factorization_monoid.multiplicative_prime_power UniqueFactorizationMonoid.multiplicative_prime_power
/-- If `f` maps `p ^ i` to `(f p) ^ i` for primes `p`, and `f`
is multiplicative on coprime elements, then `f` is multiplicative everywhere. -/
theorem multiplicative_of_coprime (f : α → β) (a b : α) (h0 : f 0 = 0)
(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 (a * b) = f a * f b := by
letI := Classical.decEq α
by_cases ha0 : a = 0
· rw [ha0, zero_mul, h0, zero_mul]
by_cases hb0 : b = 0
· rw [hb0, mul_zero, h0, mul_zero]
by_cases hf1 : f 1 = 0
· calc
f (a * b) = f (a * b * 1) := by rw [mul_one]
_ = 0 := by simp only [h1 isUnit_one, hf1, mul_zero]
_ = f a * f (b * 1) := by simp only [h1 isUnit_one, hf1, mul_zero]
_ = f a * f b := by rw [mul_one]
haveI : Nontrivial α := ⟨⟨_, _, ha0⟩⟩
letI : NormalizationMonoid α := UniqueFactorizationMonoid.normalizationMonoid
suffices
f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset,
p ^ ((normalizedFactors a).count p + (normalizedFactors b).count p)) =
f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset,
p ^ (normalizedFactors a).count p) *
f (∏ p ∈ (normalizedFactors a).toFinset ∪ (normalizedFactors b).toFinset,
p ^ (normalizedFactors b).count p) by
obtain ⟨ua, a_eq⟩ := normalizedFactors_prod ha0
obtain ⟨ub, b_eq⟩ := normalizedFactors_prod hb0
rw [← a_eq, ← b_eq, mul_right_comm (Multiset.prod (normalizedFactors a)) ua
(Multiset.prod (normalizedFactors b) * ub), h1 ua.isUnit, h1 ub.isUnit, h1 ua.isUnit, ←
mul_assoc, h1 ub.isUnit, mul_right_comm _ (f ua), ← mul_assoc]
congr
rw [← (normalizedFactors a).map_id, ← (normalizedFactors b).map_id,
Finset.prod_multiset_map_count, Finset.prod_multiset_map_count,
Finset.prod_subset (Finset.subset_union_left (s₂:=(normalizedFactors b).toFinset)),
Finset.prod_subset (Finset.subset_union_right (s₂:=(normalizedFactors b).toFinset)), ←
Finset.prod_mul_distrib]
· simp_rw [id, ← pow_add, this]
all_goals simp only [Multiset.mem_toFinset]
· intro p _ hpb
simp [hpb]
· intro p _ hpa
simp [hpa]
refine multiplicative_prime_power _ _ _ ?_ ?_ @h1 @hpr @hcp
all_goals simp only [Multiset.mem_toFinset, Finset.mem_union]
· rintro p (hpa | hpb) <;> apply prime_of_normalized_factor <;> assumption
· rintro p (hp | hp) q (hq | hq) hdvd <;>
rw [← normalize_normalized_factor _ hp, ← normalize_normalized_factor _ hq] <;>
exact
normalize_eq_normalize hdvd
((prime_of_normalized_factor _ hp).irreducible.dvd_symm
(prime_of_normalized_factor _ hq).irreducible hdvd)
#align unique_factorization_monoid.multiplicative_of_coprime UniqueFactorizationMonoid.multiplicative_of_coprime
end Multiplicative
end UniqueFactorizationMonoid
namespace Associates
open UniqueFactorizationMonoid Associated Multiset
variable [CancelCommMonoidWithZero α]
/-- `FactorSet α` representation elements of unique factorization domain as multisets.
`Multiset α` produced by `normalizedFactors` are only unique up to associated elements, while the
multisets in `FactorSet α` are unique by equality and restricted to irreducible elements. This
gives us a representation of each element as a unique multisets (or the added ⊤ for 0), which has a
complete lattice structure. Infimum is the greatest common divisor and supremum is the least common
multiple.
-/
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
/-- Evaluates the product of a `FactorSet` to be the product of the corresponding multiset,
or `0` if there is none. -/
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
section count
variable [DecidableEq (Associates α)]
/-- `bcount p s` is the multiplicity of `p` in the FactorSet `s` (with bundled `p`)-/
def bcount (p : { a : Associates α // Irreducible a }) :
FactorSet α → ℕ
| ⊤ => 0
| WithTop.some s => s.count p
#align associates.bcount Associates.bcount
variable [∀ p : Associates α, Decidable (Irreducible p)] {p : Associates α}
/-- `count p s` is the multiplicity of the irreducible `p` in the FactorSet `s`.
If `p` is not irreducible, `count p s` is defined to be `0`. -/
def count (p : Associates α) : FactorSet α → ℕ :=
if hp : Irreducible p then bcount ⟨p, hp⟩ else 0
#align associates.count Associates.count
@[simp]
theorem count_some (hp : Irreducible p) (s : Multiset _) :
count p (WithTop.some s) = s.count ⟨p, hp⟩ := by
simp only [count, dif_pos hp, bcount]
#align associates.count_some Associates.count_some
@[simp]
theorem count_zero (hp : Irreducible p) : count p (0 : FactorSet α) = 0 := by
simp only [count, dif_pos hp, bcount, Multiset.count_zero]
#align associates.count_zero Associates.count_zero
theorem count_reducible (hp : ¬Irreducible p) : count p = 0 := dif_neg hp
#align associates.count_reducible Associates.count_reducible
end count
section Mem
/-- membership in a FactorSet (bundled version) -/
def BfactorSetMem : { a : Associates α // Irreducible a } → FactorSet α → Prop
| _, ⊤ => True
| p, some l => p ∈ l
#align associates.bfactor_set_mem Associates.BfactorSetMem
/-- `FactorSetMem p s` is the predicate that the irreducible `p` is a member of
`s : FactorSet α`.
If `p` is not irreducible, `p` is not a member of any `FactorSet`. -/
def FactorSetMem (p : Associates α) (s : FactorSet α) : Prop :=
letI : Decidable (Irreducible p) := Classical.dec _
if hp : Irreducible p then BfactorSetMem ⟨p, hp⟩ s else False
#align associates.factor_set_mem Associates.FactorSetMem
instance : Membership (Associates α) (FactorSet α) :=
⟨FactorSetMem⟩
@[simp]
theorem factorSetMem_eq_mem (p : Associates α) (s : FactorSet α) : FactorSetMem p s = (p ∈ s) :=
rfl
#align associates.factor_set_mem_eq_mem Associates.factorSetMem_eq_mem
theorem mem_factorSet_top {p : Associates α} {hp : Irreducible p} : p ∈ (⊤ : FactorSet α) := by
dsimp only [Membership.mem]; dsimp only [FactorSetMem]; split_ifs; exact trivial
#align associates.mem_factor_set_top Associates.mem_factorSet_top
| Mathlib/RingTheory/UniqueFactorizationDomain.lean | 1,360 | 1,363 | theorem mem_factorSet_some {p : Associates α} {hp : Irreducible p}
{l : Multiset { a : Associates α // Irreducible a }} :
p ∈ (l : FactorSet α) ↔ Subtype.mk p hp ∈ l := by |
dsimp only [Membership.mem]; dsimp only [FactorSetMem]; split_ifs; rfl
|
/-
Copyright (c) 2017 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Tim Baumann, Stephen Morgan, Scott Morrison, Floris van Doorn
-/
import Mathlib.CategoryTheory.Functor.FullyFaithful
import Mathlib.CategoryTheory.FullSubcategory
import Mathlib.CategoryTheory.Whiskering
import Mathlib.CategoryTheory.EssentialImage
import Mathlib.Tactic.CategoryTheory.Slice
#align_import category_theory.equivalence from "leanprover-community/mathlib"@"9aba7801eeecebb61f58a5763c2b6dd1b47dc6ef"
/-!
# Equivalence of categories
An equivalence of categories `C` and `D` is a pair of functors `F : C ⥤ D` and `G : D ⥤ C` such
that `η : 𝟭 C ≅ F ⋙ G` and `ε : G ⋙ F ≅ 𝟭 D`. In many situations, equivalences are a better
notion of "sameness" of categories than the stricter isomorphism of categories.
Recall that one way to express that two functors `F : C ⥤ D` and `G : D ⥤ C` are adjoint is using
two natural transformations `η : 𝟭 C ⟶ F ⋙ G` and `ε : G ⋙ F ⟶ 𝟭 D`, called the unit and the
counit, such that the compositions `F ⟶ FGF ⟶ F` and `G ⟶ GFG ⟶ G` are the identity. Unfortunately,
it is not the case that the natural isomorphisms `η` and `ε` in the definition of an equivalence
automatically give an adjunction. However, it is true that
* if one of the two compositions is the identity, then so is the other, and
* given an equivalence of categories, it is always possible to refine `η` in such a way that the
identities are satisfied.
For this reason, in mathlib we define an equivalence to be a "half-adjoint equivalence", which is
a tuple `(F, G, η, ε)` as in the first paragraph such that the composite `F ⟶ FGF ⟶ F` is the
identity. By the remark above, this already implies that the tuple is an "adjoint equivalence",
i.e., that the composite `G ⟶ GFG ⟶ G` is also the identity.
We also define essentially surjective functors and show that a functor is an equivalence if and only
if it is full, faithful and essentially surjective.
## Main definitions
* `Equivalence`: bundled (half-)adjoint equivalences of categories
* `Functor.EssSurj`: type class on a functor `F` containing the data of the preimages
and the isomorphisms `F.obj (preimage d) ≅ d`.
* `Functor.IsEquivalence`: type class on a functor `F` which is full, faithful and
essentially surjective.
## Main results
* `Equivalence.mk`: upgrade an equivalence to a (half-)adjoint equivalence
* `isEquivalence_iff_of_iso`: when `F` and `G` are isomorphic functors,
`F` is an equivalence iff `G` is.
* `Functor.asEquivalenceFunctor`: construction of an equivalence of categories from
a functor `F` which satisfies the property `F.IsEquivalence` (i.e. `F` is full, faithful
and essentially surjective).
## Notations
We write `C ≌ D` (`\backcong`, not to be confused with `≅`/`\cong`) for a bundled equivalence.
-/
namespace CategoryTheory
open CategoryTheory.Functor NatIso Category
-- declare the `v`'s first; see `CategoryTheory.Category` for an explanation
universe v₁ v₂ v₃ u₁ u₂ u₃
/-- We define an equivalence as a (half)-adjoint equivalence, a pair of functors with
a unit and counit which are natural isomorphisms and the triangle law `Fη ≫ εF = 1`, or in other
words the composite `F ⟶ FGF ⟶ F` is the identity.
In `unit_inverse_comp`, we show that this is actually an adjoint equivalence, i.e., that the
composite `G ⟶ GFG ⟶ G` is also the identity.
The triangle equation is written as a family of equalities between morphisms, it is more
complicated if we write it as an equality of natural transformations, because then we would have
to insert natural transformations like `F ⟶ F1`.
See <https://stacks.math.columbia.edu/tag/001J>
-/
@[ext]
structure Equivalence (C : Type u₁) (D : Type u₂) [Category.{v₁} C] [Category.{v₂} D] where mk' ::
/-- A functor in one direction -/
functor : C ⥤ D
/-- A functor in the other direction -/
inverse : D ⥤ C
/-- The composition `functor ⋙ inverse` is isomorphic to the identity -/
unitIso : 𝟭 C ≅ functor ⋙ inverse
/-- The composition `inverse ⋙ functor` is also isomorphic to the identity -/
counitIso : inverse ⋙ functor ≅ 𝟭 D
/-- The natural isomorphisms compose to the identity. -/
functor_unitIso_comp :
∀ X : C, functor.map (unitIso.hom.app X) ≫ counitIso.hom.app (functor.obj X) =
𝟙 (functor.obj X) := by aesop_cat
#align category_theory.equivalence CategoryTheory.Equivalence
#align category_theory.equivalence.unit_iso CategoryTheory.Equivalence.unitIso
#align category_theory.equivalence.counit_iso CategoryTheory.Equivalence.counitIso
#align category_theory.equivalence.functor_unit_iso_comp CategoryTheory.Equivalence.functor_unitIso_comp
/-- We infix the usual notation for an equivalence -/
infixr:10 " ≌ " => Equivalence
variable {C : Type u₁} [Category.{v₁} C] {D : Type u₂} [Category.{v₂} D]
namespace Equivalence
/-- The unit of an equivalence of categories. -/
abbrev unit (e : C ≌ D) : 𝟭 C ⟶ e.functor ⋙ e.inverse :=
e.unitIso.hom
#align category_theory.equivalence.unit CategoryTheory.Equivalence.unit
/-- The counit of an equivalence of categories. -/
abbrev counit (e : C ≌ D) : e.inverse ⋙ e.functor ⟶ 𝟭 D :=
e.counitIso.hom
#align category_theory.equivalence.counit CategoryTheory.Equivalence.counit
/-- The inverse of the unit of an equivalence of categories. -/
abbrev unitInv (e : C ≌ D) : e.functor ⋙ e.inverse ⟶ 𝟭 C :=
e.unitIso.inv
#align category_theory.equivalence.unit_inv CategoryTheory.Equivalence.unitInv
/-- The inverse of the counit of an equivalence of categories. -/
abbrev counitInv (e : C ≌ D) : 𝟭 D ⟶ e.inverse ⋙ e.functor :=
e.counitIso.inv
#align category_theory.equivalence.counit_inv CategoryTheory.Equivalence.counitInv
/- While these abbreviations are convenient, they also cause some trouble,
preventing structure projections from unfolding. -/
@[simp]
theorem Equivalence_mk'_unit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unit = unit_iso.hom :=
rfl
#align category_theory.equivalence.equivalence_mk'_unit CategoryTheory.Equivalence.Equivalence_mk'_unit
@[simp]
theorem Equivalence_mk'_counit (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counit = counit_iso.hom :=
rfl
#align category_theory.equivalence.equivalence_mk'_counit CategoryTheory.Equivalence.Equivalence_mk'_counit
@[simp]
theorem Equivalence_mk'_unitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).unitInv = unit_iso.inv :=
rfl
#align category_theory.equivalence.equivalence_mk'_unit_inv CategoryTheory.Equivalence.Equivalence_mk'_unitInv
@[simp]
theorem Equivalence_mk'_counitInv (functor inverse unit_iso counit_iso f) :
(⟨functor, inverse, unit_iso, counit_iso, f⟩ : C ≌ D).counitInv = counit_iso.inv :=
rfl
#align category_theory.equivalence.equivalence_mk'_counit_inv CategoryTheory.Equivalence.Equivalence_mk'_counitInv
@[reassoc (attr := simp)]
theorem functor_unit_comp (e : C ≌ D) (X : C) :
e.functor.map (e.unit.app X) ≫ e.counit.app (e.functor.obj X) = 𝟙 (e.functor.obj X) :=
e.functor_unitIso_comp X
#align category_theory.equivalence.functor_unit_comp CategoryTheory.Equivalence.functor_unit_comp
@[reassoc (attr := simp)]
theorem counitInv_functor_comp (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) ≫ e.functor.map (e.unitInv.app X) = 𝟙 (e.functor.obj X) := by
erw [Iso.inv_eq_inv (e.functor.mapIso (e.unitIso.app X) ≪≫ e.counitIso.app (e.functor.obj X))
(Iso.refl _)]
exact e.functor_unit_comp X
#align category_theory.equivalence.counit_inv_functor_comp CategoryTheory.Equivalence.counitInv_functor_comp
theorem counitInv_app_functor (e : C ≌ D) (X : C) :
e.counitInv.app (e.functor.obj X) = e.functor.map (e.unit.app X) := by
symm
erw [← Iso.comp_hom_eq_id (e.counitIso.app _), functor_unit_comp]
rfl
#align category_theory.equivalence.counit_inv_app_functor CategoryTheory.Equivalence.counitInv_app_functor
theorem counit_app_functor (e : C ≌ D) (X : C) :
e.counit.app (e.functor.obj X) = e.functor.map (e.unitInv.app X) := by
erw [← Iso.hom_comp_eq_id (e.functor.mapIso (e.unitIso.app X)), functor_unit_comp]
rfl
#align category_theory.equivalence.counit_app_functor CategoryTheory.Equivalence.counit_app_functor
/-- The other triangle equality. The proof follows the following proof in Globular:
http://globular.science/1905.001 -/
@[reassoc (attr := simp)]
theorem unit_inverse_comp (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) ≫ e.inverse.map (e.counit.app Y) = 𝟙 (e.inverse.obj Y) := by
rw [← id_comp (e.inverse.map _), ← map_id e.inverse, ← counitInv_functor_comp, map_comp]
dsimp
rw [← Iso.hom_inv_id_assoc (e.unitIso.app _) (e.inverse.map (e.functor.map _)), app_hom, app_inv]
slice_lhs 2 3 => erw [e.unit.naturality]
slice_lhs 1 2 => erw [e.unit.naturality]
slice_lhs 4 4 =>
rw [← Iso.hom_inv_id_assoc (e.inverse.mapIso (e.counitIso.app _)) (e.unitInv.app _)]
slice_lhs 3 4 =>
erw [← map_comp e.inverse, e.counit.naturality]
erw [(e.counitIso.app _).hom_inv_id, map_id]
erw [id_comp]
slice_lhs 2 3 => erw [← map_comp e.inverse, e.counitIso.inv.naturality, map_comp]
slice_lhs 3 4 => erw [e.unitInv.naturality]
slice_lhs 4 5 => erw [← map_comp (e.functor ⋙ e.inverse), (e.unitIso.app _).hom_inv_id, map_id]
erw [id_comp]
slice_lhs 3 4 => erw [← e.unitInv.naturality]
slice_lhs 2 3 =>
erw [← map_comp e.inverse, ← e.counitIso.inv.naturality, (e.counitIso.app _).hom_inv_id,
map_id]
erw [id_comp, (e.unitIso.app _).hom_inv_id]; rfl
#align category_theory.equivalence.unit_inverse_comp CategoryTheory.Equivalence.unit_inverse_comp
@[reassoc (attr := simp)]
theorem inverse_counitInv_comp (e : C ≌ D) (Y : D) :
e.inverse.map (e.counitInv.app Y) ≫ e.unitInv.app (e.inverse.obj Y) = 𝟙 (e.inverse.obj Y) := by
erw [Iso.inv_eq_inv (e.unitIso.app (e.inverse.obj Y) ≪≫ e.inverse.mapIso (e.counitIso.app Y))
(Iso.refl _)]
exact e.unit_inverse_comp Y
#align category_theory.equivalence.inverse_counit_inv_comp CategoryTheory.Equivalence.inverse_counitInv_comp
theorem unit_app_inverse (e : C ≌ D) (Y : D) :
e.unit.app (e.inverse.obj Y) = e.inverse.map (e.counitInv.app Y) := by
erw [← Iso.comp_hom_eq_id (e.inverse.mapIso (e.counitIso.app Y)), unit_inverse_comp]
dsimp
#align category_theory.equivalence.unit_app_inverse CategoryTheory.Equivalence.unit_app_inverse
theorem unitInv_app_inverse (e : C ≌ D) (Y : D) :
e.unitInv.app (e.inverse.obj Y) = e.inverse.map (e.counit.app Y) := by
symm
erw [← Iso.hom_comp_eq_id (e.unitIso.app _), unit_inverse_comp]
rfl
#align category_theory.equivalence.unit_inv_app_inverse CategoryTheory.Equivalence.unitInv_app_inverse
@[reassoc, simp]
theorem fun_inv_map (e : C ≌ D) (X Y : D) (f : X ⟶ Y) :
e.functor.map (e.inverse.map f) = e.counit.app X ≫ f ≫ e.counitInv.app Y :=
(NatIso.naturality_2 e.counitIso f).symm
#align category_theory.equivalence.fun_inv_map CategoryTheory.Equivalence.fun_inv_map
@[reassoc, simp]
theorem inv_fun_map (e : C ≌ D) (X Y : C) (f : X ⟶ Y) :
e.inverse.map (e.functor.map f) = e.unitInv.app X ≫ f ≫ e.unit.app Y :=
(NatIso.naturality_1 e.unitIso f).symm
#align category_theory.equivalence.inv_fun_map CategoryTheory.Equivalence.inv_fun_map
section
-- In this section we convert an arbitrary equivalence to a half-adjoint equivalence.
variable {F : C ⥤ D} {G : D ⥤ C} (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D)
/-- If `η : 𝟭 C ≅ F ⋙ G` is part of a (not necessarily half-adjoint) equivalence, we can upgrade it
to a refined natural isomorphism `adjointifyη η : 𝟭 C ≅ F ⋙ G` which exhibits the properties
required for a half-adjoint equivalence. See `Equivalence.mk`. -/
def adjointifyη : 𝟭 C ≅ F ⋙ G := by
calc
𝟭 C ≅ F ⋙ G := η
_ ≅ F ⋙ 𝟭 D ⋙ G := isoWhiskerLeft F (leftUnitor G).symm
_ ≅ F ⋙ (G ⋙ F) ⋙ G := isoWhiskerLeft F (isoWhiskerRight ε.symm G)
_ ≅ F ⋙ G ⋙ F ⋙ G := isoWhiskerLeft F (associator G F G)
_ ≅ (F ⋙ G) ⋙ F ⋙ G := (associator F G (F ⋙ G)).symm
_ ≅ 𝟭 C ⋙ F ⋙ G := isoWhiskerRight η.symm (F ⋙ G)
_ ≅ F ⋙ G := leftUnitor (F ⋙ G)
#align category_theory.equivalence.adjointify_η CategoryTheory.Equivalence.adjointifyη
@[reassoc]
theorem adjointify_η_ε (X : C) :
F.map ((adjointifyη η ε).hom.app X) ≫ ε.hom.app (F.obj X) = 𝟙 (F.obj X) := by
dsimp [adjointifyη,Trans.trans]
simp only [comp_id, assoc, map_comp]
have := ε.hom.naturality (F.map (η.inv.app X)); dsimp at this; rw [this]; clear this
rw [← assoc _ _ (F.map _)]
have := ε.hom.naturality (ε.inv.app <| F.obj X); dsimp at this; rw [this]; clear this
have := (ε.app <| F.obj X).hom_inv_id; dsimp at this; rw [this]; clear this
rw [id_comp]; have := (F.mapIso <| η.app X).hom_inv_id; dsimp at this; rw [this]
#align category_theory.equivalence.adjointify_η_ε CategoryTheory.Equivalence.adjointify_η_ε
end
/-- Every equivalence of categories consisting of functors `F` and `G` such that `F ⋙ G` and
`G ⋙ F` are naturally isomorphic to identity functors can be transformed into a half-adjoint
equivalence without changing `F` or `G`. -/
protected def mk (F : C ⥤ D) (G : D ⥤ C) (η : 𝟭 C ≅ F ⋙ G) (ε : G ⋙ F ≅ 𝟭 D) : C ≌ D :=
⟨F, G, adjointifyη η ε, ε, adjointify_η_ε η ε⟩
#align category_theory.equivalence.mk CategoryTheory.Equivalence.mk
/-- Equivalence of categories is reflexive. -/
@[refl, simps]
def refl : C ≌ C :=
⟨𝟭 C, 𝟭 C, Iso.refl _, Iso.refl _, fun _ => Category.id_comp _⟩
#align category_theory.equivalence.refl CategoryTheory.Equivalence.refl
instance : Inhabited (C ≌ C) :=
⟨refl⟩
/-- Equivalence of categories is symmetric. -/
@[symm, simps]
def symm (e : C ≌ D) : D ≌ C :=
⟨e.inverse, e.functor, e.counitIso.symm, e.unitIso.symm, e.inverse_counitInv_comp⟩
#align category_theory.equivalence.symm CategoryTheory.Equivalence.symm
variable {E : Type u₃} [Category.{v₃} E]
/-- Equivalence of categories is transitive. -/
@[trans, simps]
def trans (e : C ≌ D) (f : D ≌ E) : C ≌ E where
functor := e.functor ⋙ f.functor
inverse := f.inverse ⋙ e.inverse
unitIso := by
refine Iso.trans e.unitIso ?_
exact isoWhiskerLeft e.functor (isoWhiskerRight f.unitIso e.inverse)
counitIso := by
refine Iso.trans ?_ f.counitIso
exact isoWhiskerLeft f.inverse (isoWhiskerRight e.counitIso f.functor)
-- We wouldn't have needed to give this proof if we'd used `Equivalence.mk`,
-- but we choose to avoid using that here, for the sake of good structure projection `simp`
-- lemmas.
functor_unitIso_comp X := by
dsimp
rw [← f.functor.map_comp_assoc, e.functor.map_comp, ← counitInv_app_functor, fun_inv_map,
Iso.inv_hom_id_app_assoc, assoc, Iso.inv_hom_id_app, counit_app_functor, ← Functor.map_comp]
erw [comp_id, Iso.hom_inv_id_app, Functor.map_id]
#align category_theory.equivalence.trans CategoryTheory.Equivalence.trans
/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic
functor. -/
def funInvIdAssoc (e : C ≌ D) (F : C ⥤ E) : e.functor ⋙ e.inverse ⋙ F ≅ F :=
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.unitIso.symm F ≪≫ F.leftUnitor
#align category_theory.equivalence.fun_inv_id_assoc CategoryTheory.Equivalence.funInvIdAssoc
@[simp]
theorem funInvIdAssoc_hom_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
(funInvIdAssoc e F).hom.app X = F.map (e.unitInv.app X) := by
dsimp [funInvIdAssoc]
aesop_cat
#align category_theory.equivalence.fun_inv_id_assoc_hom_app CategoryTheory.Equivalence.funInvIdAssoc_hom_app
@[simp]
theorem funInvIdAssoc_inv_app (e : C ≌ D) (F : C ⥤ E) (X : C) :
(funInvIdAssoc e F).inv.app X = F.map (e.unit.app X) := by
dsimp [funInvIdAssoc]
aesop_cat
#align category_theory.equivalence.fun_inv_id_assoc_inv_app CategoryTheory.Equivalence.funInvIdAssoc_inv_app
/-- Composing a functor with both functors of an equivalence yields a naturally isomorphic
functor. -/
def invFunIdAssoc (e : C ≌ D) (F : D ⥤ E) : e.inverse ⋙ e.functor ⋙ F ≅ F :=
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight e.counitIso F ≪≫ F.leftUnitor
#align category_theory.equivalence.inv_fun_id_assoc CategoryTheory.Equivalence.invFunIdAssoc
@[simp]
theorem invFunIdAssoc_hom_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
(invFunIdAssoc e F).hom.app X = F.map (e.counit.app X) := by
dsimp [invFunIdAssoc]
aesop_cat
#align category_theory.equivalence.inv_fun_id_assoc_hom_app CategoryTheory.Equivalence.invFunIdAssoc_hom_app
@[simp]
theorem invFunIdAssoc_inv_app (e : C ≌ D) (F : D ⥤ E) (X : D) :
(invFunIdAssoc e F).inv.app X = F.map (e.counitInv.app X) := by
dsimp [invFunIdAssoc]
aesop_cat
#align category_theory.equivalence.inv_fun_id_assoc_inv_app CategoryTheory.Equivalence.invFunIdAssoc_inv_app
/-- If `C` is equivalent to `D`, then `C ⥤ E` is equivalent to `D ⥤ E`. -/
@[simps! functor inverse unitIso counitIso]
def congrLeft (e : C ≌ D) : C ⥤ E ≌ D ⥤ E :=
Equivalence.mk ((whiskeringLeft _ _ _).obj e.inverse) ((whiskeringLeft _ _ _).obj e.functor)
(NatIso.ofComponents fun F => (e.funInvIdAssoc F).symm)
(NatIso.ofComponents fun F => e.invFunIdAssoc F)
#align category_theory.equivalence.congr_left CategoryTheory.Equivalence.congrLeft
/-- If `C` is equivalent to `D`, then `E ⥤ C` is equivalent to `E ⥤ D`. -/
@[simps! functor inverse unitIso counitIso]
def congrRight (e : C ≌ D) : E ⥤ C ≌ E ⥤ D :=
Equivalence.mk ((whiskeringRight _ _ _).obj e.functor) ((whiskeringRight _ _ _).obj e.inverse)
(NatIso.ofComponents
fun F => F.rightUnitor.symm ≪≫ isoWhiskerLeft F e.unitIso ≪≫ Functor.associator _ _ _)
(NatIso.ofComponents
fun F => Functor.associator _ _ _ ≪≫ isoWhiskerLeft F e.counitIso ≪≫ F.rightUnitor)
#align category_theory.equivalence.congr_right CategoryTheory.Equivalence.congrRight
section CancellationLemmas
variable (e : C ≌ D)
/- We need special forms of `cancel_natIso_hom_right(_assoc)` and
`cancel_natIso_inv_right(_assoc)` for units and counits, because neither `simp` or `rw` will apply
those lemmas in this setting without providing `e.unitIso` (or similar) as an explicit argument.
We also provide the lemmas for length four compositions, since they're occasionally useful.
(e.g. in proving that equivalences take monos to monos) -/
@[simp]
theorem cancel_unit_right {X Y : C} (f f' : X ⟶ Y) :
f ≫ e.unit.app Y = f' ≫ e.unit.app Y ↔ f = f' := by simp only [cancel_mono]
#align category_theory.equivalence.cancel_unit_right CategoryTheory.Equivalence.cancel_unit_right
@[simp]
theorem cancel_unitInv_right {X Y : C} (f f' : X ⟶ e.inverse.obj (e.functor.obj Y)) :
f ≫ e.unitInv.app Y = f' ≫ e.unitInv.app Y ↔ f = f' := by simp only [cancel_mono]
#align category_theory.equivalence.cancel_unit_inv_right CategoryTheory.Equivalence.cancel_unitInv_right
@[simp]
| Mathlib/CategoryTheory/Equivalence.lean | 395 | 396 | theorem cancel_counit_right {X Y : D} (f f' : X ⟶ e.functor.obj (e.inverse.obj Y)) :
f ≫ e.counit.app Y = f' ≫ e.counit.app Y ↔ f = f' := by | simp only [cancel_mono]
|
/-
Copyright (c) 2020 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Fintype.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineMap
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.Tactic.FinCases
#align_import linear_algebra.affine_space.combination from "leanprover-community/mathlib"@"2de9c37fa71dde2f1c6feff19876dd6a7b1519f0"
/-!
# Affine combinations of points
This file defines affine combinations of points.
## Main definitions
* `weightedVSubOfPoint` is a general weighted combination of
subtractions with an explicit base point, yielding a vector.
* `weightedVSub` uses an arbitrary choice of base point and is intended
to be used when the sum of weights is 0, in which case the result is
independent of the choice of base point.
* `affineCombination` adds the weighted combination to the arbitrary
base point, yielding a point rather than a vector, and is intended
to be used when the sum of weights is 1, in which case the result is
independent of the choice of base point.
These definitions are for sums over a `Finset`; versions for a
`Fintype` may be obtained using `Finset.univ`, while versions for a
`Finsupp` may be obtained using `Finsupp.support`.
## References
* https://en.wikipedia.org/wiki/Affine_space
-/
noncomputable section
open Affine
namespace Finset
theorem univ_fin2 : (univ : Finset (Fin 2)) = {0, 1} := by
ext x
fin_cases x <;> simp
#align finset.univ_fin2 Finset.univ_fin2
variable {k : Type*} {V : Type*} {P : Type*} [Ring k] [AddCommGroup V] [Module k V]
variable [S : AffineSpace V P]
variable {ι : Type*} (s : Finset ι)
variable {ι₂ : Type*} (s₂ : Finset ι₂)
/-- A weighted sum of the results of subtracting a base point from the
given points, as a linear map on the weights. The main cases of
interest are where the sum of the weights is 0, in which case the sum
is independent of the choice of base point, and where the sum of the
weights is 1, in which case the sum added to the base point is
independent of the choice of base point. -/
def weightedVSubOfPoint (p : ι → P) (b : P) : (ι → k) →ₗ[k] V :=
∑ i ∈ s, (LinearMap.proj i : (ι → k) →ₗ[k] k).smulRight (p i -ᵥ b)
#align finset.weighted_vsub_of_point Finset.weightedVSubOfPoint
@[simp]
theorem weightedVSubOfPoint_apply (w : ι → k) (p : ι → P) (b : P) :
s.weightedVSubOfPoint p b w = ∑ i ∈ s, w i • (p i -ᵥ b) := by
simp [weightedVSubOfPoint, LinearMap.sum_apply]
#align finset.weighted_vsub_of_point_apply Finset.weightedVSubOfPoint_apply
/-- The value of `weightedVSubOfPoint`, where the given points are equal. -/
@[simp (high)]
theorem weightedVSubOfPoint_apply_const (w : ι → k) (p : P) (b : P) :
s.weightedVSubOfPoint (fun _ => p) b w = (∑ i ∈ s, w i) • (p -ᵥ b) := by
rw [weightedVSubOfPoint_apply, sum_smul]
#align finset.weighted_vsub_of_point_apply_const Finset.weightedVSubOfPoint_apply_const
/-- `weightedVSubOfPoint` gives equal results for two families of weights and two families of
points that are equal on `s`. -/
theorem weightedVSubOfPoint_congr {w₁ w₂ : ι → k} (hw : ∀ i ∈ s, w₁ i = w₂ i) {p₁ p₂ : ι → P}
(hp : ∀ i ∈ s, p₁ i = p₂ i) (b : P) :
s.weightedVSubOfPoint p₁ b w₁ = s.weightedVSubOfPoint p₂ b w₂ := by
simp_rw [weightedVSubOfPoint_apply]
refine sum_congr rfl fun i hi => ?_
rw [hw i hi, hp i hi]
#align finset.weighted_vsub_of_point_congr Finset.weightedVSubOfPoint_congr
/-- Given a family of points, if we use a member of the family as a base point, the
`weightedVSubOfPoint` does not depend on the value of the weights at this point. -/
theorem weightedVSubOfPoint_eq_of_weights_eq (p : ι → P) (j : ι) (w₁ w₂ : ι → k)
(hw : ∀ i, i ≠ j → w₁ i = w₂ i) :
s.weightedVSubOfPoint p (p j) w₁ = s.weightedVSubOfPoint p (p j) w₂ := by
simp only [Finset.weightedVSubOfPoint_apply]
congr
ext i
rcases eq_or_ne i j with h | h
· simp [h]
· simp [hw i h]
#align finset.weighted_vsub_of_point_eq_of_weights_eq Finset.weightedVSubOfPoint_eq_of_weights_eq
/-- The weighted sum is independent of the base point when the sum of
the weights is 0. -/
theorem weightedVSubOfPoint_eq_of_sum_eq_zero (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 0)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w = s.weightedVSubOfPoint p b₂ w := by
apply eq_of_sub_eq_zero
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← sum_sub_distrib]
conv_lhs =>
congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, zero_smul]
#align finset.weighted_vsub_of_point_eq_of_sum_eq_zero Finset.weightedVSubOfPoint_eq_of_sum_eq_zero
/-- The weighted sum, added to the base point, is independent of the
base point when the sum of the weights is 1. -/
theorem weightedVSubOfPoint_vadd_eq_of_sum_eq_one (w : ι → k) (p : ι → P) (h : ∑ i ∈ s, w i = 1)
(b₁ b₂ : P) : s.weightedVSubOfPoint p b₁ w +ᵥ b₁ = s.weightedVSubOfPoint p b₂ w +ᵥ b₂ := by
erw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, ← @vsub_eq_zero_iff_eq V,
vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, ← add_sub_assoc, add_comm, add_sub_assoc, ←
sum_sub_distrib]
conv_lhs =>
congr
· skip
· congr
· skip
· ext
rw [← smul_sub, vsub_sub_vsub_cancel_left]
rw [← sum_smul, h, one_smul, vsub_add_vsub_cancel, vsub_self]
#align finset.weighted_vsub_of_point_vadd_eq_of_sum_eq_one Finset.weightedVSubOfPoint_vadd_eq_of_sum_eq_one
/-- The weighted sum is unaffected by removing the base point, if
present, from the set of points. -/
@[simp (high)]
theorem weightedVSubOfPoint_erase [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(s.erase i).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_erase
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_erase Finset.weightedVSubOfPoint_erase
/-- The weighted sum is unaffected by adding the base point, whether
or not present, to the set of points. -/
@[simp (high)]
theorem weightedVSubOfPoint_insert [DecidableEq ι] (w : ι → k) (p : ι → P) (i : ι) :
(insert i s).weightedVSubOfPoint p (p i) w = s.weightedVSubOfPoint p (p i) w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
apply sum_insert_zero
rw [vsub_self, smul_zero]
#align finset.weighted_vsub_of_point_insert Finset.weightedVSubOfPoint_insert
/-- The weighted sum is unaffected by changing the weights to the
corresponding indicator function and adding points to the set. -/
theorem weightedVSubOfPoint_indicator_subset (w : ι → k) (p : ι → P) (b : P) {s₁ s₂ : Finset ι}
(h : s₁ ⊆ s₂) :
s₁.weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint p b (Set.indicator (↑s₁) w) := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply]
exact Eq.symm <|
sum_indicator_subset_of_eq_zero w (fun i wi => wi • (p i -ᵥ b : V)) h fun i => zero_smul k _
#align finset.weighted_vsub_of_point_indicator_subset Finset.weightedVSubOfPoint_indicator_subset
/-- A weighted sum, over the image of an embedding, equals a weighted
sum with the same points and weights over the original
`Finset`. -/
theorem weightedVSubOfPoint_map (e : ι₂ ↪ ι) (w : ι → k) (p : ι → P) (b : P) :
(s₂.map e).weightedVSubOfPoint p b w = s₂.weightedVSubOfPoint (p ∘ e) b (w ∘ e) := by
simp_rw [weightedVSubOfPoint_apply]
exact Finset.sum_map _ _ _
#align finset.weighted_vsub_of_point_map Finset.weightedVSubOfPoint_map
/-- A weighted sum of pairwise subtractions, expressed as a subtraction of two
`weightedVSubOfPoint` expressions. -/
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 179 | 182 | theorem sum_smul_vsub_eq_weightedVSubOfPoint_sub (w : ι → k) (p₁ p₂ : ι → P) (b : P) :
(∑ i ∈ s, w i • (p₁ i -ᵥ p₂ i)) =
s.weightedVSubOfPoint p₁ b w - s.weightedVSubOfPoint p₂ b w := by |
simp_rw [weightedVSubOfPoint_apply, ← sum_sub_distrib, ← smul_sub, vsub_sub_vsub_cancel_right]
|
/-
Copyright (c) 2021 Rémy Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémy Degenne
-/
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Lp
import Mathlib.MeasureTheory.Integral.Bochner
import Mathlib.Order.Filter.IndicatorFunction
import Mathlib.MeasureTheory.Function.StronglyMeasurable.Inner
import Mathlib.MeasureTheory.Function.LpSeminorm.Trim
#align_import measure_theory.function.conditional_expectation.ae_measurable from "leanprover-community/mathlib"@"d8bbb04e2d2a44596798a9207ceefc0fb236e41e"
/-! # Functions a.e. measurable with respect to a sub-σ-algebra
A function `f` verifies `AEStronglyMeasurable' m f μ` if it is `μ`-a.e. equal to
an `m`-strongly measurable function. This is similar to `AEStronglyMeasurable`, but the
`MeasurableSpace` structures used for the measurability statement and for the measure are
different.
We define `lpMeas F 𝕜 m p μ`, the subspace of `Lp F p μ` containing functions `f` verifying
`AEStronglyMeasurable' m f μ`, i.e. functions which are `μ`-a.e. equal to an `m`-strongly
measurable function.
## Main statements
We define an `IsometryEquiv` between `lpMeasSubgroup` and the `Lp` space corresponding to the
measure `μ.trim hm`. As a consequence, the completeness of `Lp` implies completeness of `lpMeas`.
`Lp.induction_stronglyMeasurable` (see also `Memℒp.induction_stronglyMeasurable`):
To prove something for an `Lp` function a.e. strongly measurable with respect to a
sub-σ-algebra `m` in a normed space, it suffices to show that
* the property holds for (multiples of) characteristic functions which are measurable w.r.t. `m`;
* is closed under addition;
* the set of functions in `Lp` strongly measurable w.r.t. `m` for which the property holds is
closed.
-/
set_option linter.uppercaseLean3 false
open TopologicalSpace Filter
open scoped ENNReal MeasureTheory
namespace MeasureTheory
/-- A function `f` verifies `AEStronglyMeasurable' m f μ` if it is `μ`-a.e. equal to
an `m`-strongly measurable function. This is similar to `AEStronglyMeasurable`, but the
`MeasurableSpace` structures used for the measurability statement and for the measure are
different. -/
def AEStronglyMeasurable' {α β} [TopologicalSpace β] (m : MeasurableSpace α)
{_ : MeasurableSpace α} (f : α → β) (μ : Measure α) : Prop :=
∃ g : α → β, StronglyMeasurable[m] g ∧ f =ᵐ[μ] g
#align measure_theory.ae_strongly_measurable' MeasureTheory.AEStronglyMeasurable'
namespace AEStronglyMeasurable'
variable {α β 𝕜 : Type*} {m m0 : MeasurableSpace α} {μ : Measure α} [TopologicalSpace β]
{f g : α → β}
theorem congr (hf : AEStronglyMeasurable' m f μ) (hfg : f =ᵐ[μ] g) :
AEStronglyMeasurable' m g μ := by
obtain ⟨f', hf'_meas, hff'⟩ := hf; exact ⟨f', hf'_meas, hfg.symm.trans hff'⟩
#align measure_theory.ae_strongly_measurable'.congr MeasureTheory.AEStronglyMeasurable'.congr
theorem mono {m'} (hf : AEStronglyMeasurable' m f μ) (hm : m ≤ m') :
AEStronglyMeasurable' m' f μ :=
let ⟨f', hf'_meas, hff'⟩ := hf; ⟨f', hf'_meas.mono hm, hff'⟩
theorem add [Add β] [ContinuousAdd β] (hf : AEStronglyMeasurable' m f μ)
(hg : AEStronglyMeasurable' m g μ) : AEStronglyMeasurable' m (f + g) μ := by
rcases hf with ⟨f', h_f'_meas, hff'⟩
rcases hg with ⟨g', h_g'_meas, hgg'⟩
exact ⟨f' + g', h_f'_meas.add h_g'_meas, hff'.add hgg'⟩
#align measure_theory.ae_strongly_measurable'.add MeasureTheory.AEStronglyMeasurable'.add
theorem neg [AddGroup β] [TopologicalAddGroup β] {f : α → β} (hfm : AEStronglyMeasurable' m f μ) :
AEStronglyMeasurable' m (-f) μ := by
rcases hfm with ⟨f', hf'_meas, hf_ae⟩
refine ⟨-f', hf'_meas.neg, hf_ae.mono fun x hx => ?_⟩
simp_rw [Pi.neg_apply]
rw [hx]
#align measure_theory.ae_strongly_measurable'.neg MeasureTheory.AEStronglyMeasurable'.neg
theorem sub [AddGroup β] [TopologicalAddGroup β] {f g : α → β} (hfm : AEStronglyMeasurable' m f μ)
(hgm : AEStronglyMeasurable' m g μ) : AEStronglyMeasurable' m (f - g) μ := by
rcases hfm with ⟨f', hf'_meas, hf_ae⟩
rcases hgm with ⟨g', hg'_meas, hg_ae⟩
refine ⟨f' - g', hf'_meas.sub hg'_meas, hf_ae.mp (hg_ae.mono fun x hx1 hx2 => ?_)⟩
simp_rw [Pi.sub_apply]
rw [hx1, hx2]
#align measure_theory.ae_strongly_measurable'.sub MeasureTheory.AEStronglyMeasurable'.sub
theorem const_smul [SMul 𝕜 β] [ContinuousConstSMul 𝕜 β] (c : 𝕜) (hf : AEStronglyMeasurable' m f μ) :
AEStronglyMeasurable' m (c • f) μ := by
rcases hf with ⟨f', h_f'_meas, hff'⟩
refine ⟨c • f', h_f'_meas.const_smul c, ?_⟩
exact EventuallyEq.fun_comp hff' fun x => c • x
#align measure_theory.ae_strongly_measurable'.const_smul MeasureTheory.AEStronglyMeasurable'.const_smul
theorem const_inner {𝕜 β} [RCLike 𝕜] [NormedAddCommGroup β] [InnerProductSpace 𝕜 β] {f : α → β}
(hfm : AEStronglyMeasurable' m f μ) (c : β) :
AEStronglyMeasurable' m (fun x => (inner c (f x) : 𝕜)) μ := by
rcases hfm with ⟨f', hf'_meas, hf_ae⟩
refine
⟨fun x => (inner c (f' x) : 𝕜), (@stronglyMeasurable_const _ _ m _ c).inner hf'_meas,
hf_ae.mono fun x hx => ?_⟩
dsimp only
rw [hx]
#align measure_theory.ae_strongly_measurable'.const_inner MeasureTheory.AEStronglyMeasurable'.const_inner
/-- An `m`-strongly measurable function almost everywhere equal to `f`. -/
noncomputable def mk (f : α → β) (hfm : AEStronglyMeasurable' m f μ) : α → β :=
hfm.choose
#align measure_theory.ae_strongly_measurable'.mk MeasureTheory.AEStronglyMeasurable'.mk
theorem stronglyMeasurable_mk {f : α → β} (hfm : AEStronglyMeasurable' m f μ) :
StronglyMeasurable[m] (hfm.mk f) :=
hfm.choose_spec.1
#align measure_theory.ae_strongly_measurable'.stronglyMeasurable_mk MeasureTheory.AEStronglyMeasurable'.stronglyMeasurable_mk
theorem ae_eq_mk {f : α → β} (hfm : AEStronglyMeasurable' m f μ) : f =ᵐ[μ] hfm.mk f :=
hfm.choose_spec.2
#align measure_theory.ae_strongly_measurable'.ae_eq_mk MeasureTheory.AEStronglyMeasurable'.ae_eq_mk
theorem continuous_comp {γ} [TopologicalSpace γ] {f : α → β} {g : β → γ} (hg : Continuous g)
(hf : AEStronglyMeasurable' m f μ) : AEStronglyMeasurable' m (g ∘ f) μ :=
⟨fun x => g (hf.mk _ x),
@Continuous.comp_stronglyMeasurable _ _ _ m _ _ _ _ hg hf.stronglyMeasurable_mk,
hf.ae_eq_mk.mono fun x hx => by rw [Function.comp_apply, hx]⟩
#align measure_theory.ae_strongly_measurable'.continuous_comp MeasureTheory.AEStronglyMeasurable'.continuous_comp
end AEStronglyMeasurable'
theorem aeStronglyMeasurable'_of_aeStronglyMeasurable'_trim {α β} {m m0 m0' : MeasurableSpace α}
[TopologicalSpace β] (hm0 : m0 ≤ m0') {μ : Measure α} {f : α → β}
(hf : AEStronglyMeasurable' m f (μ.trim hm0)) : AEStronglyMeasurable' m f μ := by
obtain ⟨g, hg_meas, hfg⟩ := hf; exact ⟨g, hg_meas, ae_eq_of_ae_eq_trim hfg⟩
#align measure_theory.ae_strongly_measurable'_of_ae_strongly_measurable'_trim MeasureTheory.aeStronglyMeasurable'_of_aeStronglyMeasurable'_trim
theorem StronglyMeasurable.aeStronglyMeasurable' {α β} {m _ : MeasurableSpace α}
[TopologicalSpace β] {μ : Measure α} {f : α → β} (hf : StronglyMeasurable[m] f) :
AEStronglyMeasurable' m f μ :=
⟨f, hf, ae_eq_refl _⟩
#align measure_theory.strongly_measurable.ae_strongly_measurable' MeasureTheory.StronglyMeasurable.aeStronglyMeasurable'
theorem ae_eq_trim_iff_of_aeStronglyMeasurable' {α β} [TopologicalSpace β] [MetrizableSpace β]
{m m0 : MeasurableSpace α} {μ : Measure α} {f g : α → β} (hm : m ≤ m0)
(hfm : AEStronglyMeasurable' m f μ) (hgm : AEStronglyMeasurable' m g μ) :
hfm.mk f =ᵐ[μ.trim hm] hgm.mk g ↔ f =ᵐ[μ] g :=
(ae_eq_trim_iff hm hfm.stronglyMeasurable_mk hgm.stronglyMeasurable_mk).trans
⟨fun h => hfm.ae_eq_mk.trans (h.trans hgm.ae_eq_mk.symm), fun h =>
hfm.ae_eq_mk.symm.trans (h.trans hgm.ae_eq_mk)⟩
#align measure_theory.ae_eq_trim_iff_of_ae_strongly_measurable' MeasureTheory.ae_eq_trim_iff_of_aeStronglyMeasurable'
theorem AEStronglyMeasurable.comp_ae_measurable' {α β γ : Type*} [TopologicalSpace β]
{mα : MeasurableSpace α} {_ : MeasurableSpace γ} {f : α → β} {μ : Measure γ} {g : γ → α}
(hf : AEStronglyMeasurable f (μ.map g)) (hg : AEMeasurable g μ) :
AEStronglyMeasurable' (mα.comap g) (f ∘ g) μ :=
⟨hf.mk f ∘ g, hf.stronglyMeasurable_mk.comp_measurable (measurable_iff_comap_le.mpr le_rfl),
ae_eq_comp hg hf.ae_eq_mk⟩
#align measure_theory.ae_strongly_measurable.comp_ae_measurable' MeasureTheory.AEStronglyMeasurable.comp_ae_measurable'
/-- If the restriction to a set `s` of a σ-algebra `m` is included in the restriction to `s` of
another σ-algebra `m₂` (hypothesis `hs`), the set `s` is `m` measurable and a function `f` almost
everywhere supported on `s` is `m`-ae-strongly-measurable, then `f` is also
`m₂`-ae-strongly-measurable. -/
theorem AEStronglyMeasurable'.aeStronglyMeasurable'_of_measurableSpace_le_on {α E}
{m m₂ m0 : MeasurableSpace α} {μ : Measure α} [TopologicalSpace E] [Zero E] (hm : m ≤ m0)
{s : Set α} {f : α → E} (hs_m : MeasurableSet[m] s)
(hs : ∀ t, MeasurableSet[m] (s ∩ t) → MeasurableSet[m₂] (s ∩ t))
(hf : AEStronglyMeasurable' m f μ) (hf_zero : f =ᵐ[μ.restrict sᶜ] 0) :
AEStronglyMeasurable' m₂ f μ := by
have h_ind_eq : s.indicator (hf.mk f) =ᵐ[μ] f := by
refine Filter.EventuallyEq.trans ?_ <|
indicator_ae_eq_of_restrict_compl_ae_eq_zero (hm _ hs_m) hf_zero
filter_upwards [hf.ae_eq_mk] with x hx
by_cases hxs : x ∈ s
· simp [hxs, hx]
· simp [hxs]
suffices StronglyMeasurable[m₂] (s.indicator (hf.mk f)) from
AEStronglyMeasurable'.congr this.aeStronglyMeasurable' h_ind_eq
have hf_ind : StronglyMeasurable[m] (s.indicator (hf.mk f)) :=
hf.stronglyMeasurable_mk.indicator hs_m
exact
hf_ind.stronglyMeasurable_of_measurableSpace_le_on hs_m hs fun x hxs =>
Set.indicator_of_not_mem hxs _
#align measure_theory.ae_strongly_measurable'.ae_strongly_measurable'_of_measurable_space_le_on MeasureTheory.AEStronglyMeasurable'.aeStronglyMeasurable'_of_measurableSpace_le_on
variable {α E' F F' 𝕜 : Type*} {p : ℝ≥0∞} [RCLike 𝕜]
-- 𝕜 for ℝ or ℂ
-- E' for an inner product space on which we compute integrals
[NormedAddCommGroup E']
[InnerProductSpace 𝕜 E'] [CompleteSpace E'] [NormedSpace ℝ E']
-- F for a Lp submodule
[NormedAddCommGroup F]
[NormedSpace 𝕜 F]
-- F' for integrals on a Lp submodule
[NormedAddCommGroup F']
[NormedSpace 𝕜 F'] [NormedSpace ℝ F'] [CompleteSpace F']
section LpMeas
/-! ## The subset `lpMeas` of `Lp` functions a.e. measurable with respect to a sub-sigma-algebra -/
variable (F)
/-- `lpMeasSubgroup F m p μ` is the subspace of `Lp F p μ` containing functions `f` verifying
`AEStronglyMeasurable' m f μ`, i.e. functions which are `μ`-a.e. equal to
an `m`-strongly measurable function. -/
def lpMeasSubgroup (m : MeasurableSpace α) [MeasurableSpace α] (p : ℝ≥0∞) (μ : Measure α) :
AddSubgroup (Lp F p μ) where
carrier := {f : Lp F p μ | AEStronglyMeasurable' m f μ}
zero_mem' := ⟨(0 : α → F), @stronglyMeasurable_zero _ _ m _ _, Lp.coeFn_zero _ _ _⟩
add_mem' {f g} hf hg := (hf.add hg).congr (Lp.coeFn_add f g).symm
neg_mem' {f} hf := AEStronglyMeasurable'.congr hf.neg (Lp.coeFn_neg f).symm
#align measure_theory.Lp_meas_subgroup MeasureTheory.lpMeasSubgroup
variable (𝕜)
/-- `lpMeas F 𝕜 m p μ` is the subspace of `Lp F p μ` containing functions `f` verifying
`AEStronglyMeasurable' m f μ`, i.e. functions which are `μ`-a.e. equal to
an `m`-strongly measurable function. -/
def lpMeas (m : MeasurableSpace α) [MeasurableSpace α] (p : ℝ≥0∞) (μ : Measure α) :
Submodule 𝕜 (Lp F p μ) where
carrier := {f : Lp F p μ | AEStronglyMeasurable' m f μ}
zero_mem' := ⟨(0 : α → F), @stronglyMeasurable_zero _ _ m _ _, Lp.coeFn_zero _ _ _⟩
add_mem' {f g} hf hg := (hf.add hg).congr (Lp.coeFn_add f g).symm
smul_mem' c f hf := (hf.const_smul c).congr (Lp.coeFn_smul c f).symm
#align measure_theory.Lp_meas MeasureTheory.lpMeas
variable {F 𝕜}
theorem mem_lpMeasSubgroup_iff_aeStronglyMeasurable' {m m0 : MeasurableSpace α} {μ : Measure α}
{f : Lp F p μ} : f ∈ lpMeasSubgroup F m p μ ↔ AEStronglyMeasurable' m f μ := by
rw [← AddSubgroup.mem_carrier, lpMeasSubgroup, Set.mem_setOf_eq]
#align measure_theory.mem_Lp_meas_subgroup_iff_ae_strongly_measurable' MeasureTheory.mem_lpMeasSubgroup_iff_aeStronglyMeasurable'
theorem mem_lpMeas_iff_aeStronglyMeasurable' {m m0 : MeasurableSpace α} {μ : Measure α}
{f : Lp F p μ} : f ∈ lpMeas F 𝕜 m p μ ↔ AEStronglyMeasurable' m f μ := by
rw [← SetLike.mem_coe, ← Submodule.mem_carrier, lpMeas, Set.mem_setOf_eq]
#align measure_theory.mem_Lp_meas_iff_ae_strongly_measurable' MeasureTheory.mem_lpMeas_iff_aeStronglyMeasurable'
theorem lpMeas.aeStronglyMeasurable' {m _ : MeasurableSpace α} {μ : Measure α}
(f : lpMeas F 𝕜 m p μ) : AEStronglyMeasurable' (β := F) m f μ :=
mem_lpMeas_iff_aeStronglyMeasurable'.mp f.mem
#align measure_theory.Lp_meas.ae_strongly_measurable' MeasureTheory.lpMeas.aeStronglyMeasurable'
theorem mem_lpMeas_self {m0 : MeasurableSpace α} (μ : Measure α) (f : Lp F p μ) :
f ∈ lpMeas F 𝕜 m0 p μ :=
mem_lpMeas_iff_aeStronglyMeasurable'.mpr (Lp.aestronglyMeasurable f)
#align measure_theory.mem_Lp_meas_self MeasureTheory.mem_lpMeas_self
theorem lpMeasSubgroup_coe {m _ : MeasurableSpace α} {μ : Measure α} {f : lpMeasSubgroup F m p μ} :
(f : _ → _) = (f : Lp F p μ) :=
rfl
#align measure_theory.Lp_meas_subgroup_coe MeasureTheory.lpMeasSubgroup_coe
theorem lpMeas_coe {m _ : MeasurableSpace α} {μ : Measure α} {f : lpMeas F 𝕜 m p μ} :
(f : _ → _) = (f : Lp F p μ) :=
rfl
#align measure_theory.Lp_meas_coe MeasureTheory.lpMeas_coe
theorem mem_lpMeas_indicatorConstLp {m m0 : MeasurableSpace α} (hm : m ≤ m0) {μ : Measure α}
{s : Set α} (hs : MeasurableSet[m] s) (hμs : μ s ≠ ∞) {c : F} :
indicatorConstLp p (hm s hs) hμs c ∈ lpMeas F 𝕜 m p μ :=
⟨s.indicator fun _ : α => c, (@stronglyMeasurable_const _ _ m _ _).indicator hs,
indicatorConstLp_coeFn⟩
#align measure_theory.mem_Lp_meas_indicator_const_Lp MeasureTheory.mem_lpMeas_indicatorConstLp
section CompleteSubspace
/-! ## The subspace `lpMeas` is complete.
We define an `IsometryEquiv` between `lpMeasSubgroup` and the `Lp` space corresponding to the
measure `μ.trim hm`. As a consequence, the completeness of `Lp` implies completeness of
`lpMeasSubgroup` (and `lpMeas`). -/
variable {ι : Type*} {m m0 : MeasurableSpace α} {μ : Measure α}
/-- If `f` belongs to `lpMeasSubgroup F m p μ`, then the measurable function it is almost
everywhere equal to (given by `AEMeasurable.mk`) belongs to `ℒp` for the measure `μ.trim hm`. -/
theorem memℒp_trim_of_mem_lpMeasSubgroup (hm : m ≤ m0) (f : Lp F p μ)
(hf_meas : f ∈ lpMeasSubgroup F m p μ) :
Memℒp (mem_lpMeasSubgroup_iff_aeStronglyMeasurable'.mp hf_meas).choose p (μ.trim hm) := by
have hf : AEStronglyMeasurable' m f μ :=
mem_lpMeasSubgroup_iff_aeStronglyMeasurable'.mp hf_meas
let g := hf.choose
obtain ⟨hg, hfg⟩ := hf.choose_spec
change Memℒp g p (μ.trim hm)
refine ⟨hg.aestronglyMeasurable, ?_⟩
have h_snorm_fg : snorm g p (μ.trim hm) = snorm f p μ := by
rw [snorm_trim hm hg]
exact snorm_congr_ae hfg.symm
rw [h_snorm_fg]
exact Lp.snorm_lt_top f
#align measure_theory.mem_ℒp_trim_of_mem_Lp_meas_subgroup MeasureTheory.memℒp_trim_of_mem_lpMeasSubgroup
/-- If `f` belongs to `Lp` for the measure `μ.trim hm`, then it belongs to the subgroup
`lpMeasSubgroup F m p μ`. -/
theorem mem_lpMeasSubgroup_toLp_of_trim (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) :
(memℒp_of_memℒp_trim hm (Lp.memℒp f)).toLp f ∈ lpMeasSubgroup F m p μ := by
let hf_mem_ℒp := memℒp_of_memℒp_trim hm (Lp.memℒp f)
rw [mem_lpMeasSubgroup_iff_aeStronglyMeasurable']
refine AEStronglyMeasurable'.congr ?_ (Memℒp.coeFn_toLp hf_mem_ℒp).symm
refine aeStronglyMeasurable'_of_aeStronglyMeasurable'_trim hm ?_
exact Lp.aestronglyMeasurable f
#align measure_theory.mem_Lp_meas_subgroup_to_Lp_of_trim MeasureTheory.mem_lpMeasSubgroup_toLp_of_trim
variable (F p μ)
/-- Map from `lpMeasSubgroup` to `Lp F p (μ.trim hm)`. -/
noncomputable def lpMeasSubgroupToLpTrim (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) :
Lp F p (μ.trim hm) :=
Memℒp.toLp (mem_lpMeasSubgroup_iff_aeStronglyMeasurable'.mp f.mem).choose
-- Porting note: had to replace `f` with `f.1` here.
(memℒp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem)
#align measure_theory.Lp_meas_subgroup_to_Lp_trim MeasureTheory.lpMeasSubgroupToLpTrim
variable (𝕜)
/-- Map from `lpMeas` to `Lp F p (μ.trim hm)`. -/
noncomputable def lpMeasToLpTrim (hm : m ≤ m0) (f : lpMeas F 𝕜 m p μ) : Lp F p (μ.trim hm) :=
Memℒp.toLp (mem_lpMeas_iff_aeStronglyMeasurable'.mp f.mem).choose
-- Porting note: had to replace `f` with `f.1` here.
(memℒp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem)
#align measure_theory.Lp_meas_to_Lp_trim MeasureTheory.lpMeasToLpTrim
variable {𝕜}
/-- Map from `Lp F p (μ.trim hm)` to `lpMeasSubgroup`, inverse of
`lpMeasSubgroupToLpTrim`. -/
noncomputable def lpTrimToLpMeasSubgroup (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) :
lpMeasSubgroup F m p μ :=
⟨(memℒp_of_memℒp_trim hm (Lp.memℒp f)).toLp f, mem_lpMeasSubgroup_toLp_of_trim hm f⟩
#align measure_theory.Lp_trim_to_Lp_meas_subgroup MeasureTheory.lpTrimToLpMeasSubgroup
variable (𝕜)
/-- Map from `Lp F p (μ.trim hm)` to `lpMeas`, inverse of `Lp_meas_to_Lp_trim`. -/
noncomputable def lpTrimToLpMeas (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) : lpMeas F 𝕜 m p μ :=
⟨(memℒp_of_memℒp_trim hm (Lp.memℒp f)).toLp f, mem_lpMeasSubgroup_toLp_of_trim hm f⟩
#align measure_theory.Lp_trim_to_Lp_meas MeasureTheory.lpTrimToLpMeas
variable {F 𝕜 p μ}
theorem lpMeasSubgroupToLpTrim_ae_eq (hm : m ≤ m0) (f : lpMeasSubgroup F m p μ) :
lpMeasSubgroupToLpTrim F p μ hm f =ᵐ[μ] f :=
-- Porting note: replaced `(↑f)` with `f.1` here.
(ae_eq_of_ae_eq_trim (Memℒp.coeFn_toLp (memℒp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem))).trans
(mem_lpMeasSubgroup_iff_aeStronglyMeasurable'.mp f.mem).choose_spec.2.symm
#align measure_theory.Lp_meas_subgroup_to_Lp_trim_ae_eq MeasureTheory.lpMeasSubgroupToLpTrim_ae_eq
theorem lpTrimToLpMeasSubgroup_ae_eq (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) :
lpTrimToLpMeasSubgroup F p μ hm f =ᵐ[μ] f :=
-- Porting note: filled in the argument
Memℒp.coeFn_toLp (memℒp_of_memℒp_trim hm (Lp.memℒp f))
#align measure_theory.Lp_trim_to_Lp_meas_subgroup_ae_eq MeasureTheory.lpTrimToLpMeasSubgroup_ae_eq
theorem lpMeasToLpTrim_ae_eq (hm : m ≤ m0) (f : lpMeas F 𝕜 m p μ) :
lpMeasToLpTrim F 𝕜 p μ hm f =ᵐ[μ] f :=
-- Porting note: replaced `(↑f)` with `f.1` here.
(ae_eq_of_ae_eq_trim (Memℒp.coeFn_toLp (memℒp_trim_of_mem_lpMeasSubgroup hm f.1 f.mem))).trans
(mem_lpMeasSubgroup_iff_aeStronglyMeasurable'.mp f.mem).choose_spec.2.symm
#align measure_theory.Lp_meas_to_Lp_trim_ae_eq MeasureTheory.lpMeasToLpTrim_ae_eq
theorem lpTrimToLpMeas_ae_eq (hm : m ≤ m0) (f : Lp F p (μ.trim hm)) :
lpTrimToLpMeas F 𝕜 p μ hm f =ᵐ[μ] f :=
-- Porting note: filled in the argument
Memℒp.coeFn_toLp (memℒp_of_memℒp_trim hm (Lp.memℒp f))
#align measure_theory.Lp_trim_to_Lp_meas_ae_eq MeasureTheory.lpTrimToLpMeas_ae_eq
/-- `lpTrimToLpMeasSubgroup` is a right inverse of `lpMeasSubgroupToLpTrim`. -/
theorem lpMeasSubgroupToLpTrim_right_inv (hm : m ≤ m0) :
Function.RightInverse (lpTrimToLpMeasSubgroup F p μ hm) (lpMeasSubgroupToLpTrim F p μ hm) := by
intro f
ext1
refine
ae_eq_trim_of_stronglyMeasurable hm (Lp.stronglyMeasurable _) (Lp.stronglyMeasurable _) ?_
exact (lpMeasSubgroupToLpTrim_ae_eq hm _).trans (lpTrimToLpMeasSubgroup_ae_eq hm _)
#align measure_theory.Lp_meas_subgroup_to_Lp_trim_right_inv MeasureTheory.lpMeasSubgroupToLpTrim_right_inv
/-- `lpTrimToLpMeasSubgroup` is a left inverse of `lpMeasSubgroupToLpTrim`. -/
| Mathlib/MeasureTheory/Function/ConditionalExpectation/AEMeasurable.lean | 387 | 393 | theorem lpMeasSubgroupToLpTrim_left_inv (hm : m ≤ m0) :
Function.LeftInverse (lpTrimToLpMeasSubgroup F p μ hm) (lpMeasSubgroupToLpTrim F p μ hm) := by |
intro f
ext1
ext1
rw [← lpMeasSubgroup_coe]
exact (lpTrimToLpMeasSubgroup_ae_eq hm _).trans (lpMeasSubgroupToLpTrim_ae_eq hm _)
|
/-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Patrick Massot, Sébastien Gouëzel
-/
import Mathlib.Order.Interval.Set.Disjoint
import Mathlib.MeasureTheory.Integral.SetIntegral
import Mathlib.MeasureTheory.Measure.Lebesgue.Basic
#align_import measure_theory.integral.interval_integral from "leanprover-community/mathlib"@"fd5edc43dc4f10b85abfe544b88f82cf13c5f844"
/-!
# Integral over an interval
In this file we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ` if `a ≤ b` and
`-∫ x in Ioc b a, f x ∂μ` if `b ≤ a`.
## Implementation notes
### Avoiding `if`, `min`, and `max`
In order to avoid `if`s in the definition, we define `IntervalIntegrable f μ a b` as
`integrable_on f (Ioc a b) μ ∧ integrable_on f (Ioc b a) μ`. For any `a`, `b` one of these
intervals is empty and the other coincides with `Set.uIoc a b = Set.Ioc (min a b) (max a b)`.
Similarly, we define `∫ x in a..b, f x ∂μ` to be `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`.
Again, for any `a`, `b` one of these integrals is zero, and the other gives the expected result.
This way some properties can be translated from integrals over sets without dealing with
the cases `a ≤ b` and `b ≤ a` separately.
### Choice of the interval
We use integral over `Set.uIoc a b = Set.Ioc (min a b) (max a b)` instead of one of the other
three possible intervals with the same endpoints for two reasons:
* this way `∫ x in a..b, f x ∂μ + ∫ x in b..c, f x ∂μ = ∫ x in a..c, f x ∂μ` holds whenever
`f` is integrable on each interval; in particular, it works even if the measure `μ` has an atom
at `b`; this rules out `Set.Ioo` and `Set.Icc` intervals;
* with this definition for a probability measure `μ`, the integral `∫ x in a..b, 1 ∂μ` equals
the difference $F_μ(b)-F_μ(a)$, where $F_μ(a)=μ(-∞, a]$ is the
[cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function)
of `μ`.
## Tags
integral
-/
noncomputable section
open scoped Classical
open MeasureTheory Set Filter Function
open scoped Classical Topology Filter ENNReal Interval NNReal
variable {ι 𝕜 E F A : Type*} [NormedAddCommGroup E]
/-!
### Integrability on an interval
-/
/-- A function `f` is called *interval integrable* with respect to a measure `μ` on an unordered
interval `a..b` if it is integrable on both intervals `(a, b]` and `(b, a]`. One of these
intervals is always empty, so this property is equivalent to `f` being integrable on
`(min a b, max a b]`. -/
def IntervalIntegrable (f : ℝ → E) (μ : Measure ℝ) (a b : ℝ) : Prop :=
IntegrableOn f (Ioc a b) μ ∧ IntegrableOn f (Ioc b a) μ
#align interval_integrable IntervalIntegrable
/-!
## Basic iff's for `IntervalIntegrable`
-/
section
variable {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
/-- A function is interval integrable with respect to a given measure `μ` on `a..b` if and
only if it is integrable on `uIoc a b` with respect to `μ`. This is an equivalent
definition of `IntervalIntegrable`. -/
theorem intervalIntegrable_iff : IntervalIntegrable f μ a b ↔ IntegrableOn f (Ι a b) μ := by
rw [uIoc_eq_union, integrableOn_union, IntervalIntegrable]
#align interval_integrable_iff intervalIntegrable_iff
/-- If a function is interval integrable with respect to a given measure `μ` on `a..b` then
it is integrable on `uIoc a b` with respect to `μ`. -/
theorem IntervalIntegrable.def' (h : IntervalIntegrable f μ a b) : IntegrableOn f (Ι a b) μ :=
intervalIntegrable_iff.mp h
#align interval_integrable.def IntervalIntegrable.def'
theorem intervalIntegrable_iff_integrableOn_Ioc_of_le (hab : a ≤ b) :
IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioc a b) μ := by
rw [intervalIntegrable_iff, uIoc_of_le hab]
#align interval_integrable_iff_integrable_Ioc_of_le intervalIntegrable_iff_integrableOn_Ioc_of_le
theorem intervalIntegrable_iff' [NoAtoms μ] :
IntervalIntegrable f μ a b ↔ IntegrableOn f (uIcc a b) μ := by
rw [intervalIntegrable_iff, ← Icc_min_max, uIoc, integrableOn_Icc_iff_integrableOn_Ioc]
#align interval_integrable_iff' intervalIntegrable_iff'
theorem intervalIntegrable_iff_integrableOn_Icc_of_le {f : ℝ → E} {a b : ℝ} (hab : a ≤ b)
{μ : Measure ℝ} [NoAtoms μ] : IntervalIntegrable f μ a b ↔ IntegrableOn f (Icc a b) μ := by
rw [intervalIntegrable_iff_integrableOn_Ioc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioc]
#align interval_integrable_iff_integrable_Icc_of_le intervalIntegrable_iff_integrableOn_Icc_of_le
theorem intervalIntegrable_iff_integrableOn_Ico_of_le [NoAtoms μ] (hab : a ≤ b) :
IntervalIntegrable f μ a b ↔ IntegrableOn f (Ico a b) μ := by
rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ico]
theorem intervalIntegrable_iff_integrableOn_Ioo_of_le [NoAtoms μ] (hab : a ≤ b) :
IntervalIntegrable f μ a b ↔ IntegrableOn f (Ioo a b) μ := by
rw [intervalIntegrable_iff_integrableOn_Icc_of_le hab, integrableOn_Icc_iff_integrableOn_Ioo]
/-- If a function is integrable with respect to a given measure `μ` then it is interval integrable
with respect to `μ` on `uIcc a b`. -/
theorem MeasureTheory.Integrable.intervalIntegrable (hf : Integrable f μ) :
IntervalIntegrable f μ a b :=
⟨hf.integrableOn, hf.integrableOn⟩
#align measure_theory.integrable.interval_integrable MeasureTheory.Integrable.intervalIntegrable
theorem MeasureTheory.IntegrableOn.intervalIntegrable (hf : IntegrableOn f [[a, b]] μ) :
IntervalIntegrable f μ a b :=
⟨MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc),
MeasureTheory.IntegrableOn.mono_set hf (Ioc_subset_Icc_self.trans Icc_subset_uIcc')⟩
#align measure_theory.integrable_on.interval_integrable MeasureTheory.IntegrableOn.intervalIntegrable
theorem intervalIntegrable_const_iff {c : E} :
IntervalIntegrable (fun _ => c) μ a b ↔ c = 0 ∨ μ (Ι a b) < ∞ := by
simp only [intervalIntegrable_iff, integrableOn_const]
#align interval_integrable_const_iff intervalIntegrable_const_iff
@[simp]
theorem intervalIntegrable_const [IsLocallyFiniteMeasure μ] {c : E} :
IntervalIntegrable (fun _ => c) μ a b :=
intervalIntegrable_const_iff.2 <| Or.inr measure_Ioc_lt_top
#align interval_integrable_const intervalIntegrable_const
end
/-!
## Basic properties of interval integrability
- interval integrability is symmetric, reflexive, transitive
- monotonicity and strong measurability of the interval integral
- if `f` is interval integrable, so are its absolute value and norm
- arithmetic properties
-/
namespace IntervalIntegrable
section
variable {f : ℝ → E} {a b c d : ℝ} {μ ν : Measure ℝ}
@[symm]
nonrec theorem symm (h : IntervalIntegrable f μ a b) : IntervalIntegrable f μ b a :=
h.symm
#align interval_integrable.symm IntervalIntegrable.symm
@[refl, simp] -- Porting note: added `simp`
theorem refl : IntervalIntegrable f μ a a := by constructor <;> simp
#align interval_integrable.refl IntervalIntegrable.refl
@[trans]
theorem trans {a b c : ℝ} (hab : IntervalIntegrable f μ a b) (hbc : IntervalIntegrable f μ b c) :
IntervalIntegrable f μ a c :=
⟨(hab.1.union hbc.1).mono_set Ioc_subset_Ioc_union_Ioc,
(hbc.2.union hab.2).mono_set Ioc_subset_Ioc_union_Ioc⟩
#align interval_integrable.trans IntervalIntegrable.trans
theorem trans_iterate_Ico {a : ℕ → ℝ} {m n : ℕ} (hmn : m ≤ n)
(hint : ∀ k ∈ Ico m n, IntervalIntegrable f μ (a k) (a <| k + 1)) :
IntervalIntegrable f μ (a m) (a n) := by
revert hint
refine Nat.le_induction ?_ ?_ n hmn
· simp
· intro p hp IH h
exact (IH fun k hk => h k (Ico_subset_Ico_right p.le_succ hk)).trans (h p (by simp [hp]))
#align interval_integrable.trans_iterate_Ico IntervalIntegrable.trans_iterate_Ico
theorem trans_iterate {a : ℕ → ℝ} {n : ℕ}
(hint : ∀ k < n, IntervalIntegrable f μ (a k) (a <| k + 1)) :
IntervalIntegrable f μ (a 0) (a n) :=
trans_iterate_Ico bot_le fun k hk => hint k hk.2
#align interval_integrable.trans_iterate IntervalIntegrable.trans_iterate
theorem neg (h : IntervalIntegrable f μ a b) : IntervalIntegrable (-f) μ a b :=
⟨h.1.neg, h.2.neg⟩
#align interval_integrable.neg IntervalIntegrable.neg
theorem norm (h : IntervalIntegrable f μ a b) : IntervalIntegrable (fun x => ‖f x‖) μ a b :=
⟨h.1.norm, h.2.norm⟩
#align interval_integrable.norm IntervalIntegrable.norm
theorem intervalIntegrable_norm_iff {f : ℝ → E} {μ : Measure ℝ} {a b : ℝ}
(hf : AEStronglyMeasurable f (μ.restrict (Ι a b))) :
IntervalIntegrable (fun t => ‖f t‖) μ a b ↔ IntervalIntegrable f μ a b := by
simp_rw [intervalIntegrable_iff, IntegrableOn]; exact integrable_norm_iff hf
#align interval_integrable.interval_integrable_norm_iff IntervalIntegrable.intervalIntegrable_norm_iff
theorem abs {f : ℝ → ℝ} (h : IntervalIntegrable f μ a b) :
IntervalIntegrable (fun x => |f x|) μ a b :=
h.norm
#align interval_integrable.abs IntervalIntegrable.abs
theorem mono (hf : IntervalIntegrable f ν a b) (h1 : [[c, d]] ⊆ [[a, b]]) (h2 : μ ≤ ν) :
IntervalIntegrable f μ c d :=
intervalIntegrable_iff.mpr <| hf.def'.mono (uIoc_subset_uIoc_of_uIcc_subset_uIcc h1) h2
#align interval_integrable.mono IntervalIntegrable.mono
theorem mono_measure (hf : IntervalIntegrable f ν a b) (h : μ ≤ ν) : IntervalIntegrable f μ a b :=
hf.mono Subset.rfl h
#align interval_integrable.mono_measure IntervalIntegrable.mono_measure
theorem mono_set (hf : IntervalIntegrable f μ a b) (h : [[c, d]] ⊆ [[a, b]]) :
IntervalIntegrable f μ c d :=
hf.mono h le_rfl
#align interval_integrable.mono_set IntervalIntegrable.mono_set
theorem mono_set_ae (hf : IntervalIntegrable f μ a b) (h : Ι c d ≤ᵐ[μ] Ι a b) :
IntervalIntegrable f μ c d :=
intervalIntegrable_iff.mpr <| hf.def'.mono_set_ae h
#align interval_integrable.mono_set_ae IntervalIntegrable.mono_set_ae
theorem mono_set' (hf : IntervalIntegrable f μ a b) (hsub : Ι c d ⊆ Ι a b) :
IntervalIntegrable f μ c d :=
hf.mono_set_ae <| eventually_of_forall hsub
#align interval_integrable.mono_set' IntervalIntegrable.mono_set'
theorem mono_fun [NormedAddCommGroup F] {g : ℝ → F} (hf : IntervalIntegrable f μ a b)
(hgm : AEStronglyMeasurable g (μ.restrict (Ι a b)))
(hle : (fun x => ‖g x‖) ≤ᵐ[μ.restrict (Ι a b)] fun x => ‖f x‖) : IntervalIntegrable g μ a b :=
intervalIntegrable_iff.2 <| hf.def'.integrable.mono hgm hle
#align interval_integrable.mono_fun IntervalIntegrable.mono_fun
theorem mono_fun' {g : ℝ → ℝ} (hg : IntervalIntegrable g μ a b)
(hfm : AEStronglyMeasurable f (μ.restrict (Ι a b)))
(hle : (fun x => ‖f x‖) ≤ᵐ[μ.restrict (Ι a b)] g) : IntervalIntegrable f μ a b :=
intervalIntegrable_iff.2 <| hg.def'.integrable.mono' hfm hle
#align interval_integrable.mono_fun' IntervalIntegrable.mono_fun'
protected theorem aestronglyMeasurable (h : IntervalIntegrable f μ a b) :
AEStronglyMeasurable f (μ.restrict (Ioc a b)) :=
h.1.aestronglyMeasurable
#align interval_integrable.ae_strongly_measurable IntervalIntegrable.aestronglyMeasurable
protected theorem aestronglyMeasurable' (h : IntervalIntegrable f μ a b) :
AEStronglyMeasurable f (μ.restrict (Ioc b a)) :=
h.2.aestronglyMeasurable
#align interval_integrable.ae_strongly_measurable' IntervalIntegrable.aestronglyMeasurable'
end
variable [NormedRing A] {f g : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
theorem smul [NormedField 𝕜] [NormedSpace 𝕜 E] {f : ℝ → E} {a b : ℝ} {μ : Measure ℝ}
(h : IntervalIntegrable f μ a b) (r : 𝕜) : IntervalIntegrable (r • f) μ a b :=
⟨h.1.smul r, h.2.smul r⟩
#align interval_integrable.smul IntervalIntegrable.smul
@[simp]
theorem add (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) :
IntervalIntegrable (fun x => f x + g x) μ a b :=
⟨hf.1.add hg.1, hf.2.add hg.2⟩
#align interval_integrable.add IntervalIntegrable.add
@[simp]
theorem sub (hf : IntervalIntegrable f μ a b) (hg : IntervalIntegrable g μ a b) :
IntervalIntegrable (fun x => f x - g x) μ a b :=
⟨hf.1.sub hg.1, hf.2.sub hg.2⟩
#align interval_integrable.sub IntervalIntegrable.sub
theorem sum (s : Finset ι) {f : ι → ℝ → E} (h : ∀ i ∈ s, IntervalIntegrable (f i) μ a b) :
IntervalIntegrable (∑ i ∈ s, f i) μ a b :=
⟨integrable_finset_sum' s fun i hi => (h i hi).1, integrable_finset_sum' s fun i hi => (h i hi).2⟩
#align interval_integrable.sum IntervalIntegrable.sum
theorem mul_continuousOn {f g : ℝ → A} (hf : IntervalIntegrable f μ a b)
(hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => f x * g x) μ a b := by
rw [intervalIntegrable_iff] at hf ⊢
exact hf.mul_continuousOn_of_subset hg measurableSet_Ioc isCompact_uIcc Ioc_subset_Icc_self
#align interval_integrable.mul_continuous_on IntervalIntegrable.mul_continuousOn
theorem continuousOn_mul {f g : ℝ → A} (hf : IntervalIntegrable f μ a b)
(hg : ContinuousOn g [[a, b]]) : IntervalIntegrable (fun x => g x * f x) μ a b := by
rw [intervalIntegrable_iff] at hf ⊢
exact hf.continuousOn_mul_of_subset hg isCompact_uIcc measurableSet_Ioc Ioc_subset_Icc_self
#align interval_integrable.continuous_on_mul IntervalIntegrable.continuousOn_mul
@[simp]
theorem const_mul {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) :
IntervalIntegrable (fun x => c * f x) μ a b :=
hf.continuousOn_mul continuousOn_const
#align interval_integrable.const_mul IntervalIntegrable.const_mul
@[simp]
theorem mul_const {f : ℝ → A} (hf : IntervalIntegrable f μ a b) (c : A) :
IntervalIntegrable (fun x => f x * c) μ a b :=
hf.mul_continuousOn continuousOn_const
#align interval_integrable.mul_const IntervalIntegrable.mul_const
@[simp]
theorem div_const {𝕜 : Type*} {f : ℝ → 𝕜} [NormedField 𝕜] (h : IntervalIntegrable f μ a b)
(c : 𝕜) : IntervalIntegrable (fun x => f x / c) μ a b := by
simpa only [div_eq_mul_inv] using mul_const h c⁻¹
#align interval_integrable.div_const IntervalIntegrable.div_const
theorem comp_mul_left (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (c * x)) volume (a / c) (b / c) := by
rcases eq_or_ne c 0 with (hc | hc); · rw [hc]; simp
rw [intervalIntegrable_iff'] at hf ⊢
have A : MeasurableEmbedding fun x => x * c⁻¹ :=
(Homeomorph.mulRight₀ _ (inv_ne_zero hc)).closedEmbedding.measurableEmbedding
rw [← Real.smul_map_volume_mul_right (inv_ne_zero hc), IntegrableOn, Measure.restrict_smul,
integrable_smul_measure (by simpa : ENNReal.ofReal |c⁻¹| ≠ 0) ENNReal.ofReal_ne_top,
← IntegrableOn, MeasurableEmbedding.integrableOn_map_iff A]
convert hf using 1
· ext; simp only [comp_apply]; congr 1; field_simp
· rw [preimage_mul_const_uIcc (inv_ne_zero hc)]; field_simp [hc]
#align interval_integrable.comp_mul_left IntervalIntegrable.comp_mul_left
-- Porting note (#10756): new lemma
theorem comp_mul_left_iff {c : ℝ} (hc : c ≠ 0) :
IntervalIntegrable (fun x ↦ f (c * x)) volume (a / c) (b / c) ↔
IntervalIntegrable f volume a b :=
⟨fun h ↦ by simpa [hc] using h.comp_mul_left c⁻¹, (comp_mul_left · c)⟩
theorem comp_mul_right (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (x * c)) volume (a / c) (b / c) := by
simpa only [mul_comm] using comp_mul_left hf c
#align interval_integrable.comp_mul_right IntervalIntegrable.comp_mul_right
theorem comp_add_right (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (x + c)) volume (a - c) (b - c) := by
wlog h : a ≤ b generalizing a b
· exact IntervalIntegrable.symm (this hf.symm (le_of_not_le h))
rw [intervalIntegrable_iff'] at hf ⊢
have A : MeasurableEmbedding fun x => x + c :=
(Homeomorph.addRight c).closedEmbedding.measurableEmbedding
rw [← map_add_right_eq_self volume c] at hf
convert (MeasurableEmbedding.integrableOn_map_iff A).mp hf using 1
rw [preimage_add_const_uIcc]
#align interval_integrable.comp_add_right IntervalIntegrable.comp_add_right
theorem comp_add_left (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (c + x)) volume (a - c) (b - c) := by
simpa only [add_comm] using IntervalIntegrable.comp_add_right hf c
#align interval_integrable.comp_add_left IntervalIntegrable.comp_add_left
theorem comp_sub_right (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (x - c)) volume (a + c) (b + c) := by
simpa only [sub_neg_eq_add] using IntervalIntegrable.comp_add_right hf (-c)
#align interval_integrable.comp_sub_right IntervalIntegrable.comp_sub_right
theorem iff_comp_neg :
IntervalIntegrable f volume a b ↔ IntervalIntegrable (fun x => f (-x)) volume (-a) (-b) := by
rw [← comp_mul_left_iff (neg_ne_zero.2 one_ne_zero)]; simp [div_neg]
#align interval_integrable.iff_comp_neg IntervalIntegrable.iff_comp_neg
theorem comp_sub_left (hf : IntervalIntegrable f volume a b) (c : ℝ) :
IntervalIntegrable (fun x => f (c - x)) volume (c - a) (c - b) := by
simpa only [neg_sub, ← sub_eq_add_neg] using iff_comp_neg.mp (hf.comp_add_left c)
#align interval_integrable.comp_sub_left IntervalIntegrable.comp_sub_left
end IntervalIntegrable
/-!
## Continuous functions are interval integrable
-/
section
variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ]
theorem ContinuousOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : ContinuousOn u (uIcc a b)) :
IntervalIntegrable u μ a b :=
(ContinuousOn.integrableOn_Icc hu).intervalIntegrable
#align continuous_on.interval_integrable ContinuousOn.intervalIntegrable
theorem ContinuousOn.intervalIntegrable_of_Icc {u : ℝ → E} {a b : ℝ} (h : a ≤ b)
(hu : ContinuousOn u (Icc a b)) : IntervalIntegrable u μ a b :=
ContinuousOn.intervalIntegrable ((uIcc_of_le h).symm ▸ hu)
#align continuous_on.interval_integrable_of_Icc ContinuousOn.intervalIntegrable_of_Icc
/-- A continuous function on `ℝ` is `IntervalIntegrable` with respect to any locally finite measure
`ν` on ℝ. -/
theorem Continuous.intervalIntegrable {u : ℝ → E} (hu : Continuous u) (a b : ℝ) :
IntervalIntegrable u μ a b :=
hu.continuousOn.intervalIntegrable
#align continuous.interval_integrable Continuous.intervalIntegrable
end
/-!
## Monotone and antitone functions are integral integrable
-/
section
variable {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] [ConditionallyCompleteLinearOrder E]
[OrderTopology E] [SecondCountableTopology E]
theorem MonotoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : MonotoneOn u (uIcc a b)) :
IntervalIntegrable u μ a b := by
rw [intervalIntegrable_iff]
exact (hu.integrableOn_isCompact isCompact_uIcc).mono_set Ioc_subset_Icc_self
#align monotone_on.interval_integrable MonotoneOn.intervalIntegrable
theorem AntitoneOn.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : AntitoneOn u (uIcc a b)) :
IntervalIntegrable u μ a b :=
hu.dual_right.intervalIntegrable
#align antitone_on.interval_integrable AntitoneOn.intervalIntegrable
theorem Monotone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Monotone u) :
IntervalIntegrable u μ a b :=
(hu.monotoneOn _).intervalIntegrable
#align monotone.interval_integrable Monotone.intervalIntegrable
theorem Antitone.intervalIntegrable {u : ℝ → E} {a b : ℝ} (hu : Antitone u) :
IntervalIntegrable u μ a b :=
(hu.antitoneOn _).intervalIntegrable
#align antitone.interval_integrable Antitone.intervalIntegrable
end
/-- Let `l'` be a measurably generated filter; let `l` be a of filter such that each `s ∈ l'`
eventually includes `Ioc u v` as both `u` and `v` tend to `l`. Let `μ` be a measure finite at `l'`.
Suppose that `f : ℝ → E` has a finite limit at `l' ⊓ ae μ`. Then `f` is interval integrable on
`u..v` provided that both `u` and `v` tend to `l`.
Typeclass instances allow Lean to find `l'` based on `l` but not vice versa, so
`apply Tendsto.eventually_intervalIntegrable_ae` will generate goals `Filter ℝ` and
`TendstoIxxClass Ioc ?m_1 l'`. -/
theorem Filter.Tendsto.eventually_intervalIntegrable_ae {f : ℝ → E} {μ : Measure ℝ}
{l l' : Filter ℝ} (hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l']
[IsMeasurablyGenerated l'] (hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f (l' ⊓ ae μ) (𝓝 c))
{u v : ι → ℝ} {lt : Filter ι} (hu : Tendsto u lt l) (hv : Tendsto v lt l) :
∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) :=
have := (hf.integrableAtFilter_ae hfm hμ).eventually
((hu.Ioc hv).eventually this).and <| (hv.Ioc hu).eventually this
#align filter.tendsto.eventually_interval_integrable_ae Filter.Tendsto.eventually_intervalIntegrable_ae
/-- Let `l'` be a measurably generated filter; let `l` be a of filter such that each `s ∈ l'`
eventually includes `Ioc u v` as both `u` and `v` tend to `l`. Let `μ` be a measure finite at `l'`.
Suppose that `f : ℝ → E` has a finite limit at `l`. Then `f` is interval integrable on `u..v`
provided that both `u` and `v` tend to `l`.
Typeclass instances allow Lean to find `l'` based on `l` but not vice versa, so
`apply Tendsto.eventually_intervalIntegrable` will generate goals `Filter ℝ` and
`TendstoIxxClass Ioc ?m_1 l'`. -/
theorem Filter.Tendsto.eventually_intervalIntegrable {f : ℝ → E} {μ : Measure ℝ} {l l' : Filter ℝ}
(hfm : StronglyMeasurableAtFilter f l' μ) [TendstoIxxClass Ioc l l'] [IsMeasurablyGenerated l']
(hμ : μ.FiniteAtFilter l') {c : E} (hf : Tendsto f l' (𝓝 c)) {u v : ι → ℝ} {lt : Filter ι}
(hu : Tendsto u lt l) (hv : Tendsto v lt l) : ∀ᶠ t in lt, IntervalIntegrable f μ (u t) (v t) :=
(hf.mono_left inf_le_left).eventually_intervalIntegrable_ae hfm hμ hu hv
#align filter.tendsto.eventually_interval_integrable Filter.Tendsto.eventually_intervalIntegrable
/-!
### Interval integral: definition and basic properties
In this section we define `∫ x in a..b, f x ∂μ` as `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`
and prove some basic properties.
-/
variable [CompleteSpace E] [NormedSpace ℝ E]
/-- The interval integral `∫ x in a..b, f x ∂μ` is defined
as `∫ x in Ioc a b, f x ∂μ - ∫ x in Ioc b a, f x ∂μ`. If `a ≤ b`, then it equals
`∫ x in Ioc a b, f x ∂μ`, otherwise it equals `-∫ x in Ioc b a, f x ∂μ`. -/
def intervalIntegral (f : ℝ → E) (a b : ℝ) (μ : Measure ℝ) : E :=
(∫ x in Ioc a b, f x ∂μ) - ∫ x in Ioc b a, f x ∂μ
#align interval_integral intervalIntegral
notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => f)" ∂"μ:70 => intervalIntegral r a b μ
notation3"∫ "(...)" in "a".."b", "r:60:(scoped f => intervalIntegral f a b volume) => r
namespace intervalIntegral
section Basic
variable {a b : ℝ} {f g : ℝ → E} {μ : Measure ℝ}
@[simp]
| Mathlib/MeasureTheory/Integral/IntervalIntegral.lean | 485 | 485 | theorem integral_zero : (∫ _ in a..b, (0 : E) ∂μ) = 0 := by | simp [intervalIntegral]
|
/-
Copyright (c) 2024 Peter Nelson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Peter Nelson
-/
import Mathlib.Data.Matroid.Restrict
/-!
# Some constructions of matroids
This file defines some very elementary examples of matroids, namely those with at most one base.
## Main definitions
* `emptyOn α` is the matroid on `α` with empty ground set.
For `E : Set α`, ...
* `loopyOn E` is the matroid on `E` whose elements are all loops, or equivalently in which `∅`
is the only base.
* `freeOn E` is the 'free matroid' whose ground set `E` is the only base.
* For `I ⊆ E`, `uniqueBaseOn I E` is the matroid with ground set `E` in which `I` is the only base.
## Implementation details
To avoid the tedious process of certifying the matroid axioms for each of these easy examples,
we bootstrap the definitions starting with `emptyOn α` (which `simp` can prove is a matroid)
and then construct the other examples using duality and restriction.
-/
variable {α : Type*} {M : Matroid α} {E B I X R J : Set α}
namespace Matroid
open Set
section EmptyOn
/-- The `Matroid α` with empty ground set. -/
def emptyOn (α : Type*) : Matroid α where
E := ∅
Base := (· = ∅)
Indep := (· = ∅)
indep_iff' := by simp [subset_empty_iff]
exists_base := ⟨∅, rfl⟩
base_exchange := by rintro _ _ rfl; simp
maximality := by rintro _ _ _ rfl -; exact ⟨∅, by simp [mem_maximals_iff]⟩
subset_ground := by simp
@[simp] theorem emptyOn_ground : (emptyOn α).E = ∅ := rfl
@[simp] theorem emptyOn_base_iff : (emptyOn α).Base B ↔ B = ∅ := Iff.rfl
@[simp] theorem emptyOn_indep_iff : (emptyOn α).Indep I ↔ I = ∅ := Iff.rfl
theorem ground_eq_empty_iff : (M.E = ∅) ↔ M = emptyOn α := by
simp only [emptyOn, eq_iff_indep_iff_indep_forall, iff_self_and]
exact fun h ↦ by simp [h, subset_empty_iff]
@[simp] theorem emptyOn_dual_eq : (emptyOn α)✶ = emptyOn α := by
rw [← ground_eq_empty_iff]; rfl
@[simp] theorem restrict_empty (M : Matroid α) : M ↾ (∅ : Set α) = emptyOn α := by
simp [← ground_eq_empty_iff]
theorem eq_emptyOn_or_nonempty (M : Matroid α) : M = emptyOn α ∨ Matroid.Nonempty M := by
rw [← ground_eq_empty_iff]
exact M.E.eq_empty_or_nonempty.elim Or.inl (fun h ↦ Or.inr ⟨h⟩)
theorem eq_emptyOn [IsEmpty α] (M : Matroid α) : M = emptyOn α := by
rw [← ground_eq_empty_iff]
exact M.E.eq_empty_of_isEmpty
instance finite_emptyOn (α : Type*) : (emptyOn α).Finite :=
⟨finite_empty⟩
end EmptyOn
section LoopyOn
/-- The `Matroid α` with ground set `E` whose only base is `∅` -/
def loopyOn (E : Set α) : Matroid α := emptyOn α ↾ E
@[simp] theorem loopyOn_ground (E : Set α) : (loopyOn E).E = E := rfl
@[simp] theorem loopyOn_empty (α : Type*) : loopyOn (∅ : Set α) = emptyOn α := by
rw [← ground_eq_empty_iff, loopyOn_ground]
@[simp] theorem loopyOn_indep_iff : (loopyOn E).Indep I ↔ I = ∅ := by
simp only [loopyOn, restrict_indep_iff, emptyOn_indep_iff, and_iff_left_iff_imp]
rintro rfl; apply empty_subset
theorem eq_loopyOn_iff : M = loopyOn E ↔ M.E = E ∧ ∀ X ⊆ M.E, M.Indep X → X = ∅ := by
simp only [eq_iff_indep_iff_indep_forall, loopyOn_ground, loopyOn_indep_iff, and_congr_right_iff]
rintro rfl
refine ⟨fun h I hI ↦ (h I hI).1, fun h I hIE ↦ ⟨h I hIE, by rintro rfl; simp⟩⟩
@[simp] theorem loopyOn_base_iff : (loopyOn E).Base B ↔ B = ∅ := by
simp only [base_iff_maximal_indep, loopyOn_indep_iff, forall_eq, and_iff_left_iff_imp]
exact fun h _ ↦ h
@[simp] theorem loopyOn_basis_iff : (loopyOn E).Basis I X ↔ I = ∅ ∧ X ⊆ E :=
⟨fun h ↦ ⟨loopyOn_indep_iff.mp h.indep, h.subset_ground⟩,
by rintro ⟨rfl, hX⟩; rw [basis_iff]; simp⟩
instance : FiniteRk (loopyOn E) :=
⟨⟨∅, loopyOn_base_iff.2 rfl, finite_empty⟩⟩
theorem Finite.loopyOn_finite (hE : E.Finite) : Matroid.Finite (loopyOn E) :=
⟨hE⟩
@[simp] theorem loopyOn_restrict (E R : Set α) : (loopyOn E) ↾ R = loopyOn R := by
refine eq_of_indep_iff_indep_forall rfl ?_
simp only [restrict_ground_eq, restrict_indep_iff, loopyOn_indep_iff, and_iff_left_iff_imp]
exact fun _ h _ ↦ h
theorem empty_base_iff : M.Base ∅ ↔ M = loopyOn M.E := by
simp only [base_iff_maximal_indep, empty_indep, empty_subset, eq_comm (a := ∅), true_implies,
true_and, eq_iff_indep_iff_indep_forall, loopyOn_ground, loopyOn_indep_iff]
exact ⟨fun h I _ ↦ ⟨h I, by rintro rfl; simp⟩, fun h I hI ↦ (h I hI.subset_ground).1 hI⟩
| Mathlib/Data/Matroid/Constructions.lean | 123 | 124 | theorem eq_loopyOn_or_rkPos (M : Matroid α) : M = loopyOn M.E ∨ RkPos M := by |
rw [← empty_base_iff, rkPos_iff_empty_not_base]; apply em
|
/-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yury Kudryashov
-/
import Mathlib.Analysis.NormedSpace.Real
import Mathlib.Analysis.Seminorm
import Mathlib.Topology.MetricSpace.HausdorffDistance
#align_import analysis.normed_space.riesz_lemma from "leanprover-community/mathlib"@"f2ce6086713c78a7f880485f7917ea547a215982"
/-!
# Applications of the Hausdorff distance in normed spaces
Riesz's lemma, stated for a normed space over a normed field: for any
closed proper subspace `F` of `E`, there is a nonzero `x` such that `‖x - F‖`
is at least `r * ‖x‖` for any `r < 1`. This is `riesz_lemma`.
In a nontrivially normed field (with an element `c` of norm `> 1`) and any `R > ‖c‖`, one can
guarantee `‖x‖ ≤ R` and `‖x - y‖ ≥ 1` for any `y` in `F`. This is `riesz_lemma_of_norm_lt`.
A further lemma, `Metric.closedBall_infDist_compl_subset_closure`, finds a *closed* ball within
the closure of a set `s` of optimal distance from a point in `x` to the frontier of `s`.
-/
open Set Metric
open Topology
variable {𝕜 : Type*} [NormedField 𝕜]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E]
variable {F : Type*} [SeminormedAddCommGroup F] [NormedSpace ℝ F]
/-- Riesz's lemma, which usually states that it is possible to find a
vector with norm 1 whose distance to a closed proper subspace is
arbitrarily close to 1. The statement here is in terms of multiples of
norms, since in general the existence of an element of norm exactly 1
is not guaranteed. For a variant giving an element with norm in `[1, R]`, see
`riesz_lemma_of_norm_lt`. -/
theorem riesz_lemma {F : Subspace 𝕜 E} (hFc : IsClosed (F : Set E)) (hF : ∃ x : E, x ∉ F) {r : ℝ}
(hr : r < 1) : ∃ x₀ : E, x₀ ∉ F ∧ ∀ y ∈ F, r * ‖x₀‖ ≤ ‖x₀ - y‖ := by
classical
obtain ⟨x, hx⟩ : ∃ x : E, x ∉ F := hF
let d := Metric.infDist x F
have hFn : (F : Set E).Nonempty := ⟨_, F.zero_mem⟩
have hdp : 0 < d :=
lt_of_le_of_ne Metric.infDist_nonneg fun heq =>
hx ((hFc.mem_iff_infDist_zero hFn).2 heq.symm)
let r' := max r 2⁻¹
have hr' : r' < 1 := by
simp only [r', ge_iff_le, max_lt_iff, hr, true_and]
norm_num
have hlt : 0 < r' := lt_of_lt_of_le (by norm_num) (le_max_right r 2⁻¹)
have hdlt : d < d / r' := (lt_div_iff hlt).mpr ((mul_lt_iff_lt_one_right hdp).2 hr')
obtain ⟨y₀, hy₀F, hxy₀⟩ : ∃ y ∈ F, dist x y < d / r' := (Metric.infDist_lt_iff hFn).mp hdlt
have x_ne_y₀ : x - y₀ ∉ F := by
by_contra h
have : x - y₀ + y₀ ∈ F := F.add_mem h hy₀F
simp only [neg_add_cancel_right, sub_eq_add_neg] at this
exact hx this
refine ⟨x - y₀, x_ne_y₀, fun y hy => le_of_lt ?_⟩
have hy₀y : y₀ + y ∈ F := F.add_mem hy₀F hy
calc
r * ‖x - y₀‖ ≤ r' * ‖x - y₀‖ := by gcongr; apply le_max_left
_ < d := by
rw [← dist_eq_norm]
exact (lt_div_iff' hlt).1 hxy₀
_ ≤ dist x (y₀ + y) := Metric.infDist_le_dist_of_mem hy₀y
_ = ‖x - y₀ - y‖ := by rw [sub_sub, dist_eq_norm]
#align riesz_lemma riesz_lemma
/--
A version of Riesz lemma: given a strict closed subspace `F`, one may find an element of norm `≤ R`
which is at distance at least `1` of every element of `F`. Here, `R` is any given constant
strictly larger than the norm of an element of norm `> 1`. For a version without an `R`, see
`riesz_lemma`.
Since we are considering a general nontrivially normed field, there may be a gap in possible norms
(for instance no element of norm in `(1,2)`). Hence, we can not allow `R` arbitrarily close to `1`,
and require `R > ‖c‖` for some `c : 𝕜` with norm `> 1`.
-/
theorem riesz_lemma_of_norm_lt {c : 𝕜} (hc : 1 < ‖c‖) {R : ℝ} (hR : ‖c‖ < R) {F : Subspace 𝕜 E}
(hFc : IsClosed (F : Set E)) (hF : ∃ x : E, x ∉ F) :
∃ x₀ : E, ‖x₀‖ ≤ R ∧ ∀ y ∈ F, 1 ≤ ‖x₀ - y‖ := by
have Rpos : 0 < R := (norm_nonneg _).trans_lt hR
have : ‖c‖ / R < 1 := by
rw [div_lt_iff Rpos]
simpa using hR
rcases riesz_lemma hFc hF this with ⟨x, xF, hx⟩
have x0 : x ≠ 0 := fun H => by simp [H] at xF
obtain ⟨d, d0, dxlt, ledx, -⟩ :
∃ d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < R ∧ R / ‖c‖ ≤ ‖d • x‖ ∧ ‖d‖⁻¹ ≤ R⁻¹ * ‖c‖ * ‖x‖ :=
rescale_to_shell hc Rpos x0
refine ⟨d • x, dxlt.le, fun y hy => ?_⟩
set y' := d⁻¹ • y
have yy' : y = d • y' := by simp [y', smul_smul, mul_inv_cancel d0]
calc
1 = ‖c‖ / R * (R / ‖c‖) := by field_simp [Rpos.ne', (zero_lt_one.trans hc).ne']
_ ≤ ‖c‖ / R * ‖d • x‖ := by gcongr
_ = ‖d‖ * (‖c‖ / R * ‖x‖) := by
simp only [norm_smul]
ring
_ ≤ ‖d‖ * ‖x - y'‖ := by gcongr; exact hx y' (by simp [Submodule.smul_mem _ _ hy])
_ = ‖d • x - y‖ := by rw [yy', ← smul_sub, norm_smul]
#align riesz_lemma_of_norm_lt riesz_lemma_of_norm_lt
| Mathlib/Analysis/NormedSpace/RieszLemma.lean | 108 | 114 | theorem Metric.closedBall_infDist_compl_subset_closure {x : F} {s : Set F} (hx : x ∈ s) :
closedBall x (infDist x sᶜ) ⊆ closure s := by |
rcases eq_or_ne (infDist x sᶜ) 0 with h₀ | h₀
· rw [h₀, closedBall_zero']
exact closure_mono (singleton_subset_iff.2 hx)
· rw [← closure_ball x h₀]
exact closure_mono ball_infDist_compl_subset
|
/-
Copyright (c) 2021 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Algebra.Order.Group.Instances
import Mathlib.Analysis.Convex.Segment
import Mathlib.Tactic.GCongr
#align_import analysis.convex.star from "leanprover-community/mathlib"@"9003f28797c0664a49e4179487267c494477d853"
/-!
# Star-convex sets
This files defines star-convex sets (aka star domains, star-shaped set, radially convex set).
A set is star-convex at `x` if every segment from `x` to a point in the set is contained in the set.
This is the prototypical example of a contractible set in homotopy theory (by scaling every point
towards `x`), but has wider uses.
Note that this has nothing to do with star rings, `Star` and co.
## Main declarations
* `StarConvex 𝕜 x s`: `s` is star-convex at `x` with scalars `𝕜`.
## Implementation notes
Instead of saying that a set is star-convex, we say a set is star-convex *at a point*. This has the
advantage of allowing us to talk about convexity as being "everywhere star-convexity" and of making
the union of star-convex sets be star-convex.
Incidentally, this choice means we don't need to assume a set is nonempty for it to be star-convex.
Concretely, the empty set is star-convex at every point.
## TODO
Balanced sets are star-convex.
The closure of a star-convex set is star-convex.
Star-convex sets are contractible.
A nonempty open star-convex set in `ℝ^n` is diffeomorphic to the entire space.
-/
open Set
open Convex Pointwise
variable {𝕜 E F : Type*}
section OrderedSemiring
variable [OrderedSemiring 𝕜]
section AddCommMonoid
variable [AddCommMonoid E] [AddCommMonoid F]
section SMul
variable (𝕜) [SMul 𝕜 E] [SMul 𝕜 F] (x : E) (s : Set E)
/-- Star-convexity of sets. `s` is star-convex at `x` if every segment from `x` to a point in `s` is
contained in `s`. -/
def StarConvex : Prop :=
∀ ⦃y : E⦄, y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • x + b • y ∈ s
#align star_convex StarConvex
variable {𝕜 x s} {t : Set E}
theorem starConvex_iff_segment_subset : StarConvex 𝕜 x s ↔ ∀ ⦃y⦄, y ∈ s → [x -[𝕜] y] ⊆ s := by
constructor
· rintro h y hy z ⟨a, b, ha, hb, hab, rfl⟩
exact h hy ha hb hab
· rintro h y hy a b ha hb hab
exact h hy ⟨a, b, ha, hb, hab, rfl⟩
#align star_convex_iff_segment_subset starConvex_iff_segment_subset
theorem StarConvex.segment_subset (h : StarConvex 𝕜 x s) {y : E} (hy : y ∈ s) : [x -[𝕜] y] ⊆ s :=
starConvex_iff_segment_subset.1 h hy
#align star_convex.segment_subset StarConvex.segment_subset
theorem StarConvex.openSegment_subset (h : StarConvex 𝕜 x s) {y : E} (hy : y ∈ s) :
openSegment 𝕜 x y ⊆ s :=
(openSegment_subset_segment 𝕜 x y).trans (h.segment_subset hy)
#align star_convex.open_segment_subset StarConvex.openSegment_subset
/-- Alternative definition of star-convexity, in terms of pointwise set operations. -/
theorem starConvex_iff_pointwise_add_subset :
StarConvex 𝕜 x s ↔ ∀ ⦃a b : 𝕜⦄, 0 ≤ a → 0 ≤ b → a + b = 1 → a • {x} + b • s ⊆ s := by
refine
⟨?_, fun h y hy a b ha hb hab =>
h ha hb hab (add_mem_add (smul_mem_smul_set <| mem_singleton _) ⟨_, hy, rfl⟩)⟩
rintro hA a b ha hb hab w ⟨au, ⟨u, rfl : u = x, rfl⟩, bv, ⟨v, hv, rfl⟩, rfl⟩
exact hA hv ha hb hab
#align star_convex_iff_pointwise_add_subset starConvex_iff_pointwise_add_subset
theorem starConvex_empty (x : E) : StarConvex 𝕜 x ∅ := fun _ hy => hy.elim
#align star_convex_empty starConvex_empty
theorem starConvex_univ (x : E) : StarConvex 𝕜 x univ := fun _ _ _ _ _ _ _ => trivial
#align star_convex_univ starConvex_univ
theorem StarConvex.inter (hs : StarConvex 𝕜 x s) (ht : StarConvex 𝕜 x t) : StarConvex 𝕜 x (s ∩ t) :=
fun _ hy _ _ ha hb hab => ⟨hs hy.left ha hb hab, ht hy.right ha hb hab⟩
#align star_convex.inter StarConvex.inter
theorem starConvex_sInter {S : Set (Set E)} (h : ∀ s ∈ S, StarConvex 𝕜 x s) :
StarConvex 𝕜 x (⋂₀ S) := fun _ hy _ _ ha hb hab s hs => h s hs (hy s hs) ha hb hab
#align star_convex_sInter starConvex_sInter
theorem starConvex_iInter {ι : Sort*} {s : ι → Set E} (h : ∀ i, StarConvex 𝕜 x (s i)) :
StarConvex 𝕜 x (⋂ i, s i) :=
sInter_range s ▸ starConvex_sInter <| forall_mem_range.2 h
#align star_convex_Inter starConvex_iInter
theorem StarConvex.union (hs : StarConvex 𝕜 x s) (ht : StarConvex 𝕜 x t) :
StarConvex 𝕜 x (s ∪ t) := by
rintro y (hy | hy) a b ha hb hab
· exact Or.inl (hs hy ha hb hab)
· exact Or.inr (ht hy ha hb hab)
#align star_convex.union StarConvex.union
theorem starConvex_iUnion {ι : Sort*} {s : ι → Set E} (hs : ∀ i, StarConvex 𝕜 x (s i)) :
StarConvex 𝕜 x (⋃ i, s i) := by
rintro y hy a b ha hb hab
rw [mem_iUnion] at hy ⊢
obtain ⟨i, hy⟩ := hy
exact ⟨i, hs i hy ha hb hab⟩
#align star_convex_Union starConvex_iUnion
theorem starConvex_sUnion {S : Set (Set E)} (hS : ∀ s ∈ S, StarConvex 𝕜 x s) :
StarConvex 𝕜 x (⋃₀ S) := by
rw [sUnion_eq_iUnion]
exact starConvex_iUnion fun s => hS _ s.2
#align star_convex_sUnion starConvex_sUnion
theorem StarConvex.prod {y : F} {s : Set E} {t : Set F} (hs : StarConvex 𝕜 x s)
(ht : StarConvex 𝕜 y t) : StarConvex 𝕜 (x, y) (s ×ˢ t) := fun _ hy _ _ ha hb hab =>
⟨hs hy.1 ha hb hab, ht hy.2 ha hb hab⟩
#align star_convex.prod StarConvex.prod
theorem starConvex_pi {ι : Type*} {E : ι → Type*} [∀ i, AddCommMonoid (E i)] [∀ i, SMul 𝕜 (E i)]
{x : ∀ i, E i} {s : Set ι} {t : ∀ i, Set (E i)} (ht : ∀ ⦃i⦄, i ∈ s → StarConvex 𝕜 (x i) (t i)) :
StarConvex 𝕜 x (s.pi t) := fun _ hy _ _ ha hb hab i hi => ht hi (hy i hi) ha hb hab
#align star_convex_pi starConvex_pi
end SMul
section Module
variable [Module 𝕜 E] [Module 𝕜 F] {x y z : E} {s : Set E}
theorem StarConvex.mem (hs : StarConvex 𝕜 x s) (h : s.Nonempty) : x ∈ s := by
obtain ⟨y, hy⟩ := h
convert hs hy zero_le_one le_rfl (add_zero 1)
rw [one_smul, zero_smul, add_zero]
#align star_convex.mem StarConvex.mem
| Mathlib/Analysis/Convex/Star.lean | 164 | 174 | theorem starConvex_iff_forall_pos (hx : x ∈ s) : StarConvex 𝕜 x s ↔
∀ ⦃y⦄, y ∈ s → ∀ ⦃a b : 𝕜⦄, 0 < a → 0 < b → a + b = 1 → a • x + b • y ∈ s := by |
refine ⟨fun h y hy a b ha hb hab => h hy ha.le hb.le hab, ?_⟩
intro h y hy a b ha hb hab
obtain rfl | ha := ha.eq_or_lt
· rw [zero_add] at hab
rwa [hab, one_smul, zero_smul, zero_add]
obtain rfl | hb := hb.eq_or_lt
· rw [add_zero] at hab
rwa [hab, one_smul, zero_smul, add_zero]
exact h hy ha hb hab
|
/-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.LinearAlgebra.Finsupp
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Ideal.Prod
import Mathlib.RingTheory.Ideal.MinimalPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Sober
#align_import algebraic_geometry.prime_spectrum.basic from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
/-!
# Prime spectrum of a commutative (semi)ring
The prime spectrum of a commutative (semi)ring is the type of all prime ideals.
It is naturally endowed with a topology: the Zariski topology.
(It is also naturally endowed with a sheaf of rings,
which is constructed in `AlgebraicGeometry.StructureSheaf`.)
## Main definitions
* `PrimeSpectrum R`: The prime spectrum of a commutative (semi)ring `R`,
i.e., the set of all prime ideals of `R`.
* `zeroLocus s`: The zero locus of a subset `s` of `R`
is the subset of `PrimeSpectrum R` consisting of all prime ideals that contain `s`.
* `vanishingIdeal t`: The vanishing ideal of a subset `t` of `PrimeSpectrum R`
is the intersection of points in `t` (viewed as prime ideals).
## Conventions
We denote subsets of (semi)rings with `s`, `s'`, etc...
whereas we denote subsets of prime spectra with `t`, `t'`, etc...
## Inspiration/contributors
The contents of this file draw inspiration from <https://github.com/ramonfmir/lean-scheme>
which has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,
and Chris Hughes (on an earlier repository).
-/
noncomputable section
open scoped Classical
universe u v
variable (R : Type u) (S : Type v)
/-- The prime spectrum of a commutative (semi)ring `R` is the type of all prime ideals of `R`.
It is naturally endowed with a topology (the Zariski topology),
and a sheaf of commutative rings (see `AlgebraicGeometry.StructureSheaf`).
It is a fundamental building block in algebraic geometry. -/
@[ext]
structure PrimeSpectrum [CommSemiring R] where
asIdeal : Ideal R
IsPrime : asIdeal.IsPrime
#align prime_spectrum PrimeSpectrum
attribute [instance] PrimeSpectrum.IsPrime
namespace PrimeSpectrum
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
instance [Nontrivial R] : Nonempty <| PrimeSpectrum R :=
let ⟨I, hI⟩ := Ideal.exists_maximal R
⟨⟨I, hI.isPrime⟩⟩
/-- The prime spectrum of the zero ring is empty. -/
instance [Subsingleton R] : IsEmpty (PrimeSpectrum R) :=
⟨fun x ↦ x.IsPrime.ne_top <| SetLike.ext' <| Subsingleton.eq_univ_of_nonempty x.asIdeal.nonempty⟩
#noalign prime_spectrum.punit
variable (R S)
/-- The map from the direct sum of prime spectra to the prime spectrum of a direct product. -/
@[simp]
def primeSpectrumProdOfSum : Sum (PrimeSpectrum R) (PrimeSpectrum S) → PrimeSpectrum (R × S)
| Sum.inl ⟨I, _⟩ => ⟨Ideal.prod I ⊤, Ideal.isPrime_ideal_prod_top⟩
| Sum.inr ⟨J, _⟩ => ⟨Ideal.prod ⊤ J, Ideal.isPrime_ideal_prod_top'⟩
#align prime_spectrum.prime_spectrum_prod_of_sum PrimeSpectrum.primeSpectrumProdOfSum
/-- The prime spectrum of `R × S` is in bijection with the disjoint unions of the prime spectrum of
`R` and the prime spectrum of `S`. -/
noncomputable def primeSpectrumProd :
PrimeSpectrum (R × S) ≃ Sum (PrimeSpectrum R) (PrimeSpectrum S) :=
Equiv.symm <|
Equiv.ofBijective (primeSpectrumProdOfSum R S) (by
constructor
· rintro (⟨I, hI⟩ | ⟨J, hJ⟩) (⟨I', hI'⟩ | ⟨J', hJ'⟩) h <;>
simp only [mk.injEq, Ideal.prod.ext_iff, primeSpectrumProdOfSum] at h
· simp only [h]
· exact False.elim (hI.ne_top h.left)
· exact False.elim (hJ.ne_top h.right)
· simp only [h]
· rintro ⟨I, hI⟩
rcases (Ideal.ideal_prod_prime I).mp hI with (⟨p, ⟨hp, rfl⟩⟩ | ⟨p, ⟨hp, rfl⟩⟩)
· exact ⟨Sum.inl ⟨p, hp⟩, rfl⟩
· exact ⟨Sum.inr ⟨p, hp⟩, rfl⟩)
#align prime_spectrum.prime_spectrum_prod PrimeSpectrum.primeSpectrumProd
variable {R S}
@[simp]
theorem primeSpectrumProd_symm_inl_asIdeal (x : PrimeSpectrum R) :
((primeSpectrumProd R S).symm <| Sum.inl x).asIdeal = Ideal.prod x.asIdeal ⊤ := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inl_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inl_asIdeal
@[simp]
theorem primeSpectrumProd_symm_inr_asIdeal (x : PrimeSpectrum S) :
((primeSpectrumProd R S).symm <| Sum.inr x).asIdeal = Ideal.prod ⊤ x.asIdeal := by
cases x
rfl
#align prime_spectrum.prime_spectrum_prod_symm_inr_as_ideal PrimeSpectrum.primeSpectrumProd_symm_inr_asIdeal
/-- The zero locus of a set `s` of elements of a commutative (semi)ring `R` is the set of all
prime ideals of the ring that contain the set `s`.
An element `f` of `R` can be thought of as a dependent function on the prime spectrum of `R`.
At a point `x` (a prime ideal) the function (i.e., element) `f` takes values in the quotient ring
`R` modulo the prime ideal `x`. In this manner, `zeroLocus s` is exactly the subset of
`PrimeSpectrum R` where all "functions" in `s` vanish simultaneously.
-/
def zeroLocus (s : Set R) : Set (PrimeSpectrum R) :=
{ x | s ⊆ x.asIdeal }
#align prime_spectrum.zero_locus PrimeSpectrum.zeroLocus
@[simp]
theorem mem_zeroLocus (x : PrimeSpectrum R) (s : Set R) : x ∈ zeroLocus s ↔ s ⊆ x.asIdeal :=
Iff.rfl
#align prime_spectrum.mem_zero_locus PrimeSpectrum.mem_zeroLocus
@[simp]
| Mathlib/AlgebraicGeometry/PrimeSpectrum/Basic.lean | 147 | 149 | theorem zeroLocus_span (s : Set R) : zeroLocus (Ideal.span s : Set R) = zeroLocus s := by |
ext x
exact (Submodule.gi R R).gc s x.asIdeal
|
/-
Copyright (c) 2020 Johan Commelin, Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Robert Y. Lewis
-/
import Mathlib.Algebra.MvPolynomial.Rename
import Mathlib.Algebra.MvPolynomial.Variables
#align_import data.mv_polynomial.monad from "leanprover-community/mathlib"@"2f5b500a507264de86d666a5f87ddb976e2d8de4"
/-!
# Monad operations on `MvPolynomial`
This file defines two monadic operations on `MvPolynomial`. Given `p : MvPolynomial σ R`,
* `MvPolynomial.bind₁` and `MvPolynomial.join₁` operate on the variable type `σ`.
* `MvPolynomial.bind₂` and `MvPolynomial.join₂` operate on the coefficient type `R`.
- `MvPolynomial.bind₁ f φ` with `f : σ → MvPolynomial τ R` and `φ : MvPolynomial σ R`,
is the polynomial `φ(f 1, ..., f i, ...) : MvPolynomial τ R`.
- `MvPolynomial.join₁ φ` with `φ : MvPolynomial (MvPolynomial σ R) R` collapses `φ` to
a `MvPolynomial σ R`, by evaluating `φ` under the map `X f ↦ f` for `f : MvPolynomial σ R`.
In other words, if you have a polynomial `φ` in a set of variables indexed by a polynomial ring,
you evaluate the polynomial in these indexing polynomials.
- `MvPolynomial.bind₂ f φ` with `f : R →+* MvPolynomial σ S` and `φ : MvPolynomial σ R`
is the `MvPolynomial σ S` obtained from `φ` by mapping the coefficients of `φ` through `f`
and considering the resulting polynomial as polynomial expression in `MvPolynomial σ R`.
- `MvPolynomial.join₂ φ` with `φ : MvPolynomial σ (MvPolynomial σ R)` collapses `φ` to
a `MvPolynomial σ R`, by considering `φ` as polynomial expression in `MvPolynomial σ R`.
These operations themselves have algebraic structure: `MvPolynomial.bind₁`
and `MvPolynomial.join₁` are algebra homs and
`MvPolynomial.bind₂` and `MvPolynomial.join₂` are ring homs.
They interact in convenient ways with `MvPolynomial.rename`, `MvPolynomial.map`,
`MvPolynomial.vars`, and other polynomial operations.
Indeed, `MvPolynomial.rename` is the "map" operation for the (`bind₁`, `join₁`) pair,
whereas `MvPolynomial.map` is the "map" operation for the other pair.
## Implementation notes
We add a `LawfulMonad` instance for the (`bind₁`, `join₁`) pair.
The second pair cannot be instantiated as a `Monad`,
since it is not a monad in `Type` but in `CommRingCat` (or rather `CommSemiRingCat`).
-/
noncomputable section
namespace MvPolynomial
open Finsupp
variable {σ : Type*} {τ : Type*}
variable {R S T : Type*} [CommSemiring R] [CommSemiring S] [CommSemiring T]
/--
`bind₁` is the "left hand side" bind operation on `MvPolynomial`, operating on the variable type.
Given a polynomial `p : MvPolynomial σ R` and a map `f : σ → MvPolynomial τ R` taking variables
in `p` to polynomials in the variable type `τ`, `bind₁ f p` replaces each variable in `p` with
its value under `f`, producing a new polynomial in `τ`. The coefficient type remains the same.
This operation is an algebra hom.
-/
def bind₁ (f : σ → MvPolynomial τ R) : MvPolynomial σ R →ₐ[R] MvPolynomial τ R :=
aeval f
#align mv_polynomial.bind₁ MvPolynomial.bind₁
/-- `bind₂` is the "right hand side" bind operation on `MvPolynomial`,
operating on the coefficient type.
Given a polynomial `p : MvPolynomial σ R` and
a map `f : R → MvPolynomial σ S` taking coefficients in `p` to polynomials over a new ring `S`,
`bind₂ f p` replaces each coefficient in `p` with its value under `f`,
producing a new polynomial over `S`.
The variable type remains the same. This operation is a ring hom.
-/
def bind₂ (f : R →+* MvPolynomial σ S) : MvPolynomial σ R →+* MvPolynomial σ S :=
eval₂Hom f X
#align mv_polynomial.bind₂ MvPolynomial.bind₂
/--
`join₁` is the monadic join operation corresponding to `MvPolynomial.bind₁`. Given a polynomial `p`
with coefficients in `R` whose variables are polynomials in `σ` with coefficients in `R`,
`join₁ p` collapses `p` to a polynomial with variables in `σ` and coefficients in `R`.
This operation is an algebra hom.
-/
def join₁ : MvPolynomial (MvPolynomial σ R) R →ₐ[R] MvPolynomial σ R :=
aeval id
#align mv_polynomial.join₁ MvPolynomial.join₁
/--
`join₂` is the monadic join operation corresponding to `MvPolynomial.bind₂`. Given a polynomial `p`
with variables in `σ` whose coefficients are polynomials in `σ` with coefficients in `R`,
`join₂ p` collapses `p` to a polynomial with variables in `σ` and coefficients in `R`.
This operation is a ring hom.
-/
def join₂ : MvPolynomial σ (MvPolynomial σ R) →+* MvPolynomial σ R :=
eval₂Hom (RingHom.id _) X
#align mv_polynomial.join₂ MvPolynomial.join₂
@[simp]
theorem aeval_eq_bind₁ (f : σ → MvPolynomial τ R) : aeval f = bind₁ f :=
rfl
#align mv_polynomial.aeval_eq_bind₁ MvPolynomial.aeval_eq_bind₁
@[simp]
theorem eval₂Hom_C_eq_bind₁ (f : σ → MvPolynomial τ R) : eval₂Hom C f = bind₁ f :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_polynomial.eval₂_hom_C_eq_bind₁ MvPolynomial.eval₂Hom_C_eq_bind₁
@[simp]
theorem eval₂Hom_eq_bind₂ (f : R →+* MvPolynomial σ S) : eval₂Hom f X = bind₂ f :=
rfl
#align mv_polynomial.eval₂_hom_eq_bind₂ MvPolynomial.eval₂Hom_eq_bind₂
section
variable (σ R)
@[simp]
theorem aeval_id_eq_join₁ : aeval id = @join₁ σ R _ :=
rfl
#align mv_polynomial.aeval_id_eq_join₁ MvPolynomial.aeval_id_eq_join₁
theorem eval₂Hom_C_id_eq_join₁ (φ : MvPolynomial (MvPolynomial σ R) R) :
eval₂Hom C id φ = join₁ φ :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_polynomial.eval₂_hom_C_id_eq_join₁ MvPolynomial.eval₂Hom_C_id_eq_join₁
@[simp]
theorem eval₂Hom_id_X_eq_join₂ : eval₂Hom (RingHom.id _) X = @join₂ σ R _ :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_polynomial.eval₂_hom_id_X_eq_join₂ MvPolynomial.eval₂Hom_id_X_eq_join₂
end
-- In this file, we don't want to use these simp lemmas,
-- because we first need to show how these new definitions interact
-- and the proofs fall back on unfolding the definitions and call simp afterwards
attribute [-simp]
aeval_eq_bind₁ eval₂Hom_C_eq_bind₁ eval₂Hom_eq_bind₂ aeval_id_eq_join₁ eval₂Hom_id_X_eq_join₂
@[simp]
theorem bind₁_X_right (f : σ → MvPolynomial τ R) (i : σ) : bind₁ f (X i) = f i :=
aeval_X f i
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₁_X_right MvPolynomial.bind₁_X_right
@[simp]
theorem bind₂_X_right (f : R →+* MvPolynomial σ S) (i : σ) : bind₂ f (X i) = X i :=
eval₂Hom_X' f X i
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₂_X_right MvPolynomial.bind₂_X_right
@[simp]
theorem bind₁_X_left : bind₁ (X : σ → MvPolynomial σ R) = AlgHom.id R _ := by
ext1 i
simp
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₁_X_left MvPolynomial.bind₁_X_left
variable (f : σ → MvPolynomial τ R)
theorem bind₁_C_right (f : σ → MvPolynomial τ R) (x) : bind₁ f (C x) = C x := algHom_C _ _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₁_C_right MvPolynomial.bind₁_C_right
@[simp]
theorem bind₂_C_right (f : R →+* MvPolynomial σ S) (r : R) : bind₂ f (C r) = f r :=
eval₂Hom_C f X r
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₂_C_right MvPolynomial.bind₂_C_right
@[simp]
theorem bind₂_C_left : bind₂ (C : R →+* MvPolynomial σ R) = RingHom.id _ := by ext : 2 <;> simp
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₂_C_left MvPolynomial.bind₂_C_left
@[simp]
theorem bind₂_comp_C (f : R →+* MvPolynomial σ S) : (bind₂ f).comp C = f :=
RingHom.ext <| bind₂_C_right _
set_option linter.uppercaseLean3 false in
#align mv_polynomial.bind₂_comp_C MvPolynomial.bind₂_comp_C
@[simp]
| Mathlib/Algebra/MvPolynomial/Monad.lean | 190 | 191 | theorem join₂_map (f : R →+* MvPolynomial σ S) (φ : MvPolynomial σ R) :
join₂ (map f φ) = bind₂ f φ := by | simp only [join₂, bind₂, eval₂Hom_map_hom, RingHom.id_comp]
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Mario Carneiro
-/
import Mathlib.Init.Order.LinearOrder
import Mathlib.Data.Prod.Basic
import Mathlib.Data.Subtype
import Mathlib.Tactic.Spread
import Mathlib.Tactic.Convert
import Mathlib.Tactic.SimpRw
import Mathlib.Tactic.Cases
import Mathlib.Order.Notation
#align_import order.basic from "leanprover-community/mathlib"@"90df25ded755a2cf9651ea850d1abe429b1e4eb1"
/-!
# Basic definitions about `≤` and `<`
This file proves basic results about orders, provides extensive dot notation, defines useful order
classes and allows to transfer order instances.
## Type synonyms
* `OrderDual α` : A type synonym reversing the meaning of all inequalities, with notation `αᵒᵈ`.
* `AsLinearOrder α`: A type synonym to promote `PartialOrder α` to `LinearOrder α` using
`IsTotal α (≤)`.
### Transferring orders
- `Order.Preimage`, `Preorder.lift`: Transfers a (pre)order on `β` to an order on `α`
using a function `f : α → β`.
- `PartialOrder.lift`, `LinearOrder.lift`: Transfers a partial (resp., linear) order on `β` to a
partial (resp., linear) order on `α` using an injective function `f`.
### Extra class
* `DenselyOrdered`: An order with no gap, i.e. for any two elements `a < b` there exists `c` such
that `a < c < b`.
## Notes
`≤` and `<` are highly favored over `≥` and `>` in mathlib. The reason is that we can formulate all
lemmas using `≤`/`<`, and `rw` has trouble unifying `≤` and `≥`. Hence choosing one direction spares
us useless duplication. This is enforced by a linter. See Note [nolint_ge] for more infos.
Dot notation is particularly useful on `≤` (`LE.le`) and `<` (`LT.lt`). To that end, we
provide many aliases to dot notation-less lemmas. For example, `le_trans` is aliased with
`LE.le.trans` and can be used to construct `hab.trans hbc : a ≤ c` when `hab : a ≤ b`,
`hbc : b ≤ c`, `lt_of_le_of_lt` is aliased as `LE.le.trans_lt` and can be used to construct
`hab.trans hbc : a < c` when `hab : a ≤ b`, `hbc : b < c`.
## TODO
- expand module docs
- automatic construction of dual definitions / theorems
## Tags
preorder, order, partial order, poset, linear order, chain
-/
open Function
variable {ι α β : Type*} {π : ι → Type*}
section Preorder
variable [Preorder α] {a b c : α}
theorem le_trans' : b ≤ c → a ≤ b → a ≤ c :=
flip le_trans
#align le_trans' le_trans'
theorem lt_trans' : b < c → a < b → a < c :=
flip lt_trans
#align lt_trans' lt_trans'
theorem lt_of_le_of_lt' : b ≤ c → a < b → a < c :=
flip lt_of_lt_of_le
#align lt_of_le_of_lt' lt_of_le_of_lt'
theorem lt_of_lt_of_le' : b < c → a ≤ b → a < c :=
flip lt_of_le_of_lt
#align lt_of_lt_of_le' lt_of_lt_of_le'
end Preorder
section PartialOrder
variable [PartialOrder α] {a b : α}
theorem ge_antisymm : a ≤ b → b ≤ a → b = a :=
flip le_antisymm
#align ge_antisymm ge_antisymm
theorem lt_of_le_of_ne' : a ≤ b → b ≠ a → a < b := fun h₁ h₂ ↦ lt_of_le_of_ne h₁ h₂.symm
#align lt_of_le_of_ne' lt_of_le_of_ne'
theorem Ne.lt_of_le : a ≠ b → a ≤ b → a < b :=
flip lt_of_le_of_ne
#align ne.lt_of_le Ne.lt_of_le
theorem Ne.lt_of_le' : b ≠ a → a ≤ b → a < b :=
flip lt_of_le_of_ne'
#align ne.lt_of_le' Ne.lt_of_le'
end PartialOrder
attribute [simp] le_refl
attribute [ext] LE
alias LE.le.trans := le_trans
alias LE.le.trans' := le_trans'
alias LE.le.trans_lt := lt_of_le_of_lt
alias LE.le.trans_lt' := lt_of_le_of_lt'
alias LE.le.antisymm := le_antisymm
alias LE.le.antisymm' := ge_antisymm
alias LE.le.lt_of_ne := lt_of_le_of_ne
alias LE.le.lt_of_ne' := lt_of_le_of_ne'
alias LE.le.lt_of_not_le := lt_of_le_not_le
alias LE.le.lt_or_eq := lt_or_eq_of_le
alias LE.le.lt_or_eq_dec := Decidable.lt_or_eq_of_le
alias LT.lt.le := le_of_lt
alias LT.lt.trans := lt_trans
alias LT.lt.trans' := lt_trans'
alias LT.lt.trans_le := lt_of_lt_of_le
alias LT.lt.trans_le' := lt_of_lt_of_le'
alias LT.lt.ne := ne_of_lt
#align has_lt.lt.ne LT.lt.ne
alias LT.lt.asymm := lt_asymm
alias LT.lt.not_lt := lt_asymm
alias Eq.le := le_of_eq
#align eq.le Eq.le
-- Porting note: no `decidable_classical` linter
-- attribute [nolint decidable_classical] LE.le.lt_or_eq_dec
section
variable [Preorder α] {a b c : α}
@[simp]
theorem lt_self_iff_false (x : α) : x < x ↔ False :=
⟨lt_irrefl x, False.elim⟩
#align lt_self_iff_false lt_self_iff_false
#align le_of_le_of_eq le_of_le_of_eq
#align le_of_eq_of_le le_of_eq_of_le
#align lt_of_lt_of_eq lt_of_lt_of_eq
#align lt_of_eq_of_lt lt_of_eq_of_lt
theorem le_of_le_of_eq' : b ≤ c → a = b → a ≤ c :=
flip le_of_eq_of_le
#align le_of_le_of_eq' le_of_le_of_eq'
theorem le_of_eq_of_le' : b = c → a ≤ b → a ≤ c :=
flip le_of_le_of_eq
#align le_of_eq_of_le' le_of_eq_of_le'
theorem lt_of_lt_of_eq' : b < c → a = b → a < c :=
flip lt_of_eq_of_lt
#align lt_of_lt_of_eq' lt_of_lt_of_eq'
theorem lt_of_eq_of_lt' : b = c → a < b → a < c :=
flip lt_of_lt_of_eq
#align lt_of_eq_of_lt' lt_of_eq_of_lt'
alias LE.le.trans_eq := le_of_le_of_eq
alias LE.le.trans_eq' := le_of_le_of_eq'
alias LT.lt.trans_eq := lt_of_lt_of_eq
alias LT.lt.trans_eq' := lt_of_lt_of_eq'
alias Eq.trans_le := le_of_eq_of_le
#align eq.trans_le Eq.trans_le
alias Eq.trans_ge := le_of_eq_of_le'
#align eq.trans_ge Eq.trans_ge
alias Eq.trans_lt := lt_of_eq_of_lt
#align eq.trans_lt Eq.trans_lt
alias Eq.trans_gt := lt_of_eq_of_lt'
#align eq.trans_gt Eq.trans_gt
end
namespace Eq
variable [Preorder α] {x y z : α}
/-- If `x = y` then `y ≤ x`. Note: this lemma uses `y ≤ x` instead of `x ≥ y`, because `le` is used
almost exclusively in mathlib. -/
protected theorem ge (h : x = y) : y ≤ x :=
h.symm.le
#align eq.ge Eq.ge
theorem not_lt (h : x = y) : ¬x < y := fun h' ↦ h'.ne h
#align eq.not_lt Eq.not_lt
theorem not_gt (h : x = y) : ¬y < x :=
h.symm.not_lt
#align eq.not_gt Eq.not_gt
end Eq
section
variable [Preorder α] {a b : α}
@[simp] lemma le_of_subsingleton [Subsingleton α] : a ≤ b := (Subsingleton.elim a b).le
-- Making this a @[simp] lemma causes confluences problems downstream.
lemma not_lt_of_subsingleton [Subsingleton α] : ¬a < b := (Subsingleton.elim a b).not_lt
end
namespace LE.le
-- see Note [nolint_ge]
-- Porting note: linter not found @[nolint ge_or_gt]
protected theorem ge [LE α] {x y : α} (h : x ≤ y) : y ≥ x :=
h
#align has_le.le.ge LE.le.ge
section PartialOrder
variable [PartialOrder α] {a b : α}
theorem lt_iff_ne (h : a ≤ b) : a < b ↔ a ≠ b :=
⟨fun h ↦ h.ne, h.lt_of_ne⟩
#align has_le.le.lt_iff_ne LE.le.lt_iff_ne
theorem gt_iff_ne (h : a ≤ b) : a < b ↔ b ≠ a :=
⟨fun h ↦ h.ne.symm, h.lt_of_ne'⟩
#align has_le.le.gt_iff_ne LE.le.gt_iff_ne
theorem not_lt_iff_eq (h : a ≤ b) : ¬a < b ↔ a = b :=
h.lt_iff_ne.not_left
#align has_le.le.not_lt_iff_eq LE.le.not_lt_iff_eq
theorem not_gt_iff_eq (h : a ≤ b) : ¬a < b ↔ b = a :=
h.gt_iff_ne.not_left
#align has_le.le.not_gt_iff_eq LE.le.not_gt_iff_eq
theorem le_iff_eq (h : a ≤ b) : b ≤ a ↔ b = a :=
⟨fun h' ↦ h'.antisymm h, Eq.le⟩
#align has_le.le.le_iff_eq LE.le.le_iff_eq
theorem ge_iff_eq (h : a ≤ b) : b ≤ a ↔ a = b :=
⟨h.antisymm, Eq.ge⟩
#align has_le.le.ge_iff_eq LE.le.ge_iff_eq
end PartialOrder
theorem lt_or_le [LinearOrder α] {a b : α} (h : a ≤ b) (c : α) : a < c ∨ c ≤ b :=
((lt_or_ge a c).imp id) fun hc ↦ le_trans hc h
#align has_le.le.lt_or_le LE.le.lt_or_le
theorem le_or_lt [LinearOrder α] {a b : α} (h : a ≤ b) (c : α) : a ≤ c ∨ c < b :=
((le_or_gt a c).imp id) fun hc ↦ lt_of_lt_of_le hc h
#align has_le.le.le_or_lt LE.le.le_or_lt
theorem le_or_le [LinearOrder α] {a b : α} (h : a ≤ b) (c : α) : a ≤ c ∨ c ≤ b :=
(h.le_or_lt c).elim Or.inl fun h ↦ Or.inr <| le_of_lt h
#align has_le.le.le_or_le LE.le.le_or_le
end LE.le
namespace LT.lt
-- see Note [nolint_ge]
-- Porting note: linter not found @[nolint ge_or_gt]
protected theorem gt [LT α] {x y : α} (h : x < y) : y > x :=
h
#align has_lt.lt.gt LT.lt.gt
protected theorem false [Preorder α] {x : α} : x < x → False :=
lt_irrefl x
#align has_lt.lt.false LT.lt.false
theorem ne' [Preorder α] {x y : α} (h : x < y) : y ≠ x :=
h.ne.symm
#align has_lt.lt.ne' LT.lt.ne'
theorem lt_or_lt [LinearOrder α] {x y : α} (h : x < y) (z : α) : x < z ∨ z < y :=
(lt_or_ge z y).elim Or.inr fun hz ↦ Or.inl <| h.trans_le hz
#align has_lt.lt.lt_or_lt LT.lt.lt_or_lt
end LT.lt
-- see Note [nolint_ge]
-- Porting note: linter not found @[nolint ge_or_gt]
protected theorem GE.ge.le [LE α] {x y : α} (h : x ≥ y) : y ≤ x :=
h
#align ge.le GE.ge.le
-- see Note [nolint_ge]
-- Porting note: linter not found @[nolint ge_or_gt]
protected theorem GT.gt.lt [LT α] {x y : α} (h : x > y) : y < x :=
h
#align gt.lt GT.gt.lt
-- see Note [nolint_ge]
-- Porting note: linter not found @[nolint ge_or_gt]
theorem ge_of_eq [Preorder α] {a b : α} (h : a = b) : a ≥ b :=
h.ge
#align ge_of_eq ge_of_eq
#align ge_iff_le ge_iff_le
#align gt_iff_lt gt_iff_lt
theorem not_le_of_lt [Preorder α] {a b : α} (h : a < b) : ¬b ≤ a :=
(le_not_le_of_lt h).right
#align not_le_of_lt not_le_of_lt
alias LT.lt.not_le := not_le_of_lt
theorem not_lt_of_le [Preorder α] {a b : α} (h : a ≤ b) : ¬b < a := fun hba ↦ hba.not_le h
#align not_lt_of_le not_lt_of_le
alias LE.le.not_lt := not_lt_of_le
theorem ne_of_not_le [Preorder α] {a b : α} (h : ¬a ≤ b) : a ≠ b := fun hab ↦ h (le_of_eq hab)
#align ne_of_not_le ne_of_not_le
-- See Note [decidable namespace]
protected theorem Decidable.le_iff_eq_or_lt [PartialOrder α] [@DecidableRel α (· ≤ ·)] {a b : α} :
a ≤ b ↔ a = b ∨ a < b :=
Decidable.le_iff_lt_or_eq.trans or_comm
#align decidable.le_iff_eq_or_lt Decidable.le_iff_eq_or_lt
theorem le_iff_eq_or_lt [PartialOrder α] {a b : α} : a ≤ b ↔ a = b ∨ a < b :=
le_iff_lt_or_eq.trans or_comm
#align le_iff_eq_or_lt le_iff_eq_or_lt
theorem lt_iff_le_and_ne [PartialOrder α] {a b : α} : a < b ↔ a ≤ b ∧ a ≠ b :=
⟨fun h ↦ ⟨le_of_lt h, ne_of_lt h⟩, fun ⟨h1, h2⟩ ↦ h1.lt_of_ne h2⟩
#align lt_iff_le_and_ne lt_iff_le_and_ne
theorem eq_iff_not_lt_of_le [PartialOrder α] {x y : α} : x ≤ y → y = x ↔ ¬x < y := by
rw [lt_iff_le_and_ne, not_and, Classical.not_not, eq_comm]
#align eq_iff_not_lt_of_le eq_iff_not_lt_of_le
-- See Note [decidable namespace]
protected theorem Decidable.eq_iff_le_not_lt [PartialOrder α] [@DecidableRel α (· ≤ ·)] {a b : α} :
a = b ↔ a ≤ b ∧ ¬a < b :=
⟨fun h ↦ ⟨h.le, h ▸ lt_irrefl _⟩, fun ⟨h₁, h₂⟩ ↦
h₁.antisymm <| Decidable.by_contradiction fun h₃ ↦ h₂ (h₁.lt_of_not_le h₃)⟩
#align decidable.eq_iff_le_not_lt Decidable.eq_iff_le_not_lt
theorem eq_iff_le_not_lt [PartialOrder α] {a b : α} : a = b ↔ a ≤ b ∧ ¬a < b :=
haveI := Classical.dec
Decidable.eq_iff_le_not_lt
#align eq_iff_le_not_lt eq_iff_le_not_lt
theorem eq_or_lt_of_le [PartialOrder α] {a b : α} (h : a ≤ b) : a = b ∨ a < b :=
h.lt_or_eq.symm
#align eq_or_lt_of_le eq_or_lt_of_le
theorem eq_or_gt_of_le [PartialOrder α] {a b : α} (h : a ≤ b) : b = a ∨ a < b :=
h.lt_or_eq.symm.imp Eq.symm id
#align eq_or_gt_of_le eq_or_gt_of_le
theorem gt_or_eq_of_le [PartialOrder α] {a b : α} (h : a ≤ b) : a < b ∨ b = a :=
(eq_or_gt_of_le h).symm
#align gt_or_eq_of_le gt_or_eq_of_le
alias LE.le.eq_or_lt_dec := Decidable.eq_or_lt_of_le
alias LE.le.eq_or_lt := eq_or_lt_of_le
alias LE.le.eq_or_gt := eq_or_gt_of_le
alias LE.le.gt_or_eq := gt_or_eq_of_le
-- Porting note: no `decidable_classical` linter
-- attribute [nolint decidable_classical] LE.le.eq_or_lt_dec
theorem eq_of_le_of_not_lt [PartialOrder α] {a b : α} (hab : a ≤ b) (hba : ¬a < b) : a = b :=
hab.eq_or_lt.resolve_right hba
#align eq_of_le_of_not_lt eq_of_le_of_not_lt
theorem eq_of_ge_of_not_gt [PartialOrder α] {a b : α} (hab : a ≤ b) (hba : ¬a < b) : b = a :=
(hab.eq_or_lt.resolve_right hba).symm
#align eq_of_ge_of_not_gt eq_of_ge_of_not_gt
alias LE.le.eq_of_not_lt := eq_of_le_of_not_lt
alias LE.le.eq_of_not_gt := eq_of_ge_of_not_gt
theorem Ne.le_iff_lt [PartialOrder α] {a b : α} (h : a ≠ b) : a ≤ b ↔ a < b :=
⟨fun h' ↦ lt_of_le_of_ne h' h, fun h ↦ h.le⟩
#align ne.le_iff_lt Ne.le_iff_lt
theorem Ne.not_le_or_not_le [PartialOrder α] {a b : α} (h : a ≠ b) : ¬a ≤ b ∨ ¬b ≤ a :=
not_and_or.1 <| le_antisymm_iff.not.1 h
#align ne.not_le_or_not_le Ne.not_le_or_not_le
-- See Note [decidable namespace]
protected theorem Decidable.ne_iff_lt_iff_le [PartialOrder α] [DecidableEq α] {a b : α} :
(a ≠ b ↔ a < b) ↔ a ≤ b :=
⟨fun h ↦ Decidable.byCases le_of_eq (le_of_lt ∘ h.mp), fun h ↦ ⟨lt_of_le_of_ne h, ne_of_lt⟩⟩
#align decidable.ne_iff_lt_iff_le Decidable.ne_iff_lt_iff_le
@[simp]
theorem ne_iff_lt_iff_le [PartialOrder α] {a b : α} : (a ≠ b ↔ a < b) ↔ a ≤ b :=
haveI := Classical.dec
Decidable.ne_iff_lt_iff_le
#align ne_iff_lt_iff_le ne_iff_lt_iff_le
-- Variant of `min_def` with the branches reversed.
theorem min_def' [LinearOrder α] (a b : α) : min a b = if b ≤ a then b else a := by
rw [min_def]
rcases lt_trichotomy a b with (lt | eq | gt)
· rw [if_pos lt.le, if_neg (not_le.mpr lt)]
· rw [if_pos eq.le, if_pos eq.ge, eq]
· rw [if_neg (not_le.mpr gt.gt), if_pos gt.le]
#align min_def' min_def'
-- Variant of `min_def` with the branches reversed.
-- This is sometimes useful as it used to be the default.
theorem max_def' [LinearOrder α] (a b : α) : max a b = if b ≤ a then a else b := by
rw [max_def]
rcases lt_trichotomy a b with (lt | eq | gt)
· rw [if_pos lt.le, if_neg (not_le.mpr lt)]
· rw [if_pos eq.le, if_pos eq.ge, eq]
· rw [if_neg (not_le.mpr gt.gt), if_pos gt.le]
#align max_def' max_def'
theorem lt_of_not_le [LinearOrder α] {a b : α} (h : ¬b ≤ a) : a < b :=
((le_total _ _).resolve_right h).lt_of_not_le h
#align lt_of_not_le lt_of_not_le
theorem lt_iff_not_le [LinearOrder α] {x y : α} : x < y ↔ ¬y ≤ x :=
⟨not_le_of_lt, lt_of_not_le⟩
#align lt_iff_not_le lt_iff_not_le
theorem Ne.lt_or_lt [LinearOrder α] {x y : α} (h : x ≠ y) : x < y ∨ y < x :=
lt_or_gt_of_ne h
#align ne.lt_or_lt Ne.lt_or_lt
/-- A version of `ne_iff_lt_or_gt` with LHS and RHS reversed. -/
@[simp]
theorem lt_or_lt_iff_ne [LinearOrder α] {x y : α} : x < y ∨ y < x ↔ x ≠ y :=
ne_iff_lt_or_gt.symm
#align lt_or_lt_iff_ne lt_or_lt_iff_ne
theorem not_lt_iff_eq_or_lt [LinearOrder α] {a b : α} : ¬a < b ↔ a = b ∨ b < a :=
not_lt.trans <| Decidable.le_iff_eq_or_lt.trans <| or_congr eq_comm Iff.rfl
#align not_lt_iff_eq_or_lt not_lt_iff_eq_or_lt
theorem exists_ge_of_linear [LinearOrder α] (a b : α) : ∃ c, a ≤ c ∧ b ≤ c :=
match le_total a b with
| Or.inl h => ⟨_, h, le_rfl⟩
| Or.inr h => ⟨_, le_rfl, h⟩
#align exists_ge_of_linear exists_ge_of_linear
lemma exists_forall_ge_and [LinearOrder α] {p q : α → Prop} :
(∃ i, ∀ j ≥ i, p j) → (∃ i, ∀ j ≥ i, q j) → ∃ i, ∀ j ≥ i, p j ∧ q j
| ⟨a, ha⟩, ⟨b, hb⟩ =>
let ⟨c, hac, hbc⟩ := exists_ge_of_linear a b
⟨c, fun _d hcd ↦ ⟨ha _ $ hac.trans hcd, hb _ $ hbc.trans hcd⟩⟩
#align exists_forall_ge_and exists_forall_ge_and
theorem lt_imp_lt_of_le_imp_le {β} [LinearOrder α] [Preorder β] {a b : α} {c d : β}
(H : a ≤ b → c ≤ d) (h : d < c) : b < a :=
lt_of_not_le fun h' ↦ (H h').not_lt h
#align lt_imp_lt_of_le_imp_le lt_imp_lt_of_le_imp_le
theorem le_imp_le_iff_lt_imp_lt {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β} :
a ≤ b → c ≤ d ↔ d < c → b < a :=
⟨lt_imp_lt_of_le_imp_le, le_imp_le_of_lt_imp_lt⟩
#align le_imp_le_iff_lt_imp_lt le_imp_le_iff_lt_imp_lt
theorem lt_iff_lt_of_le_iff_le' {β} [Preorder α] [Preorder β] {a b : α} {c d : β}
(H : a ≤ b ↔ c ≤ d) (H' : b ≤ a ↔ d ≤ c) : b < a ↔ d < c :=
lt_iff_le_not_le.trans <| (and_congr H' (not_congr H)).trans lt_iff_le_not_le.symm
#align lt_iff_lt_of_le_iff_le' lt_iff_lt_of_le_iff_le'
theorem lt_iff_lt_of_le_iff_le {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β}
(H : a ≤ b ↔ c ≤ d) : b < a ↔ d < c :=
not_le.symm.trans <| (not_congr H).trans <| not_le
#align lt_iff_lt_of_le_iff_le lt_iff_lt_of_le_iff_le
theorem le_iff_le_iff_lt_iff_lt {β} [LinearOrder α] [LinearOrder β] {a b : α} {c d : β} :
(a ≤ b ↔ c ≤ d) ↔ (b < a ↔ d < c) :=
⟨lt_iff_lt_of_le_iff_le, fun H ↦ not_lt.symm.trans <| (not_congr H).trans <| not_lt⟩
#align le_iff_le_iff_lt_iff_lt le_iff_le_iff_lt_iff_lt
theorem eq_of_forall_le_iff [PartialOrder α] {a b : α} (H : ∀ c, c ≤ a ↔ c ≤ b) : a = b :=
((H _).1 le_rfl).antisymm ((H _).2 le_rfl)
#align eq_of_forall_le_iff eq_of_forall_le_iff
theorem le_of_forall_le [Preorder α] {a b : α} (H : ∀ c, c ≤ a → c ≤ b) : a ≤ b :=
H _ le_rfl
#align le_of_forall_le le_of_forall_le
theorem le_of_forall_le' [Preorder α] {a b : α} (H : ∀ c, a ≤ c → b ≤ c) : b ≤ a :=
H _ le_rfl
#align le_of_forall_le' le_of_forall_le'
theorem le_of_forall_lt [LinearOrder α] {a b : α} (H : ∀ c, c < a → c < b) : a ≤ b :=
le_of_not_lt fun h ↦ lt_irrefl _ (H _ h)
#align le_of_forall_lt le_of_forall_lt
theorem forall_lt_iff_le [LinearOrder α] {a b : α} : (∀ ⦃c⦄, c < a → c < b) ↔ a ≤ b :=
⟨le_of_forall_lt, fun h _ hca ↦ lt_of_lt_of_le hca h⟩
#align forall_lt_iff_le forall_lt_iff_le
theorem le_of_forall_lt' [LinearOrder α] {a b : α} (H : ∀ c, a < c → b < c) : b ≤ a :=
le_of_not_lt fun h ↦ lt_irrefl _ (H _ h)
#align le_of_forall_lt' le_of_forall_lt'
theorem forall_lt_iff_le' [LinearOrder α] {a b : α} : (∀ ⦃c⦄, a < c → b < c) ↔ b ≤ a :=
⟨le_of_forall_lt', fun h _ hac ↦ lt_of_le_of_lt h hac⟩
#align forall_lt_iff_le' forall_lt_iff_le'
theorem eq_of_forall_ge_iff [PartialOrder α] {a b : α} (H : ∀ c, a ≤ c ↔ b ≤ c) : a = b :=
((H _).2 le_rfl).antisymm ((H _).1 le_rfl)
#align eq_of_forall_ge_iff eq_of_forall_ge_iff
theorem eq_of_forall_lt_iff [LinearOrder α] {a b : α} (h : ∀ c, c < a ↔ c < b) : a = b :=
(le_of_forall_lt fun _ ↦ (h _).1).antisymm <| le_of_forall_lt fun _ ↦ (h _).2
#align eq_of_forall_lt_iff eq_of_forall_lt_iff
theorem eq_of_forall_gt_iff [LinearOrder α] {a b : α} (h : ∀ c, a < c ↔ b < c) : a = b :=
(le_of_forall_lt' fun _ ↦ (h _).2).antisymm <| le_of_forall_lt' fun _ ↦ (h _).1
#align eq_of_forall_gt_iff eq_of_forall_gt_iff
/-- A symmetric relation implies two values are equal, when it implies they're less-equal. -/
theorem rel_imp_eq_of_rel_imp_le [PartialOrder β] (r : α → α → Prop) [IsSymm α r] {f : α → β}
(h : ∀ a b, r a b → f a ≤ f b) {a b : α} : r a b → f a = f b := fun hab ↦
le_antisymm (h a b hab) (h b a <| symm hab)
#align rel_imp_eq_of_rel_imp_le rel_imp_eq_of_rel_imp_le
/-- monotonicity of `≤` with respect to `→` -/
theorem le_implies_le_of_le_of_le {a b c d : α} [Preorder α] (hca : c ≤ a) (hbd : b ≤ d) :
a ≤ b → c ≤ d :=
fun hab ↦ (hca.trans hab).trans hbd
#align le_implies_le_of_le_of_le le_implies_le_of_le_of_le
section PartialOrder
variable [PartialOrder α]
/-- To prove commutativity of a binary operation `○`, we only to check `a ○ b ≤ b ○ a` for all `a`,
`b`. -/
theorem commutative_of_le {f : β → β → α} (comm : ∀ a b, f a b ≤ f b a) : ∀ a b, f a b = f b a :=
fun _ _ ↦ (comm _ _).antisymm <| comm _ _
#align commutative_of_le commutative_of_le
/-- To prove associativity of a commutative binary operation `○`, we only to check
`(a ○ b) ○ c ≤ a ○ (b ○ c)` for all `a`, `b`, `c`. -/
theorem associative_of_commutative_of_le {f : α → α → α} (comm : Commutative f)
(assoc : ∀ a b c, f (f a b) c ≤ f a (f b c)) : Associative f := fun a b c ↦
le_antisymm (assoc _ _ _) <| by
rw [comm, comm b, comm _ c, comm a]
exact assoc _ _ _
#align associative_of_commutative_of_le associative_of_commutative_of_le
end PartialOrder
@[ext]
theorem Preorder.toLE_injective : Function.Injective (@Preorder.toLE α) :=
fun A B h ↦ match A, B with
| { lt := A_lt, lt_iff_le_not_le := A_iff, .. },
{ lt := B_lt, lt_iff_le_not_le := B_iff, .. } => by
cases h
have : A_lt = B_lt := by
funext a b
show (LT.mk A_lt).lt a b = (LT.mk B_lt).lt a b
rw [A_iff, B_iff]
cases this
congr
#align preorder.to_has_le_injective Preorder.toLE_injective
@[ext]
theorem PartialOrder.toPreorder_injective :
Function.Injective (@PartialOrder.toPreorder α) := fun A B h ↦ by
cases A
cases B
cases h
congr
#align partial_order.to_preorder_injective PartialOrder.toPreorder_injective
@[ext]
theorem LinearOrder.toPartialOrder_injective :
Function.Injective (@LinearOrder.toPartialOrder α) :=
fun A B h ↦ match A, B with
| { le := A_le, lt := A_lt,
decidableLE := A_decidableLE, decidableEq := A_decidableEq, decidableLT := A_decidableLT
min := A_min, max := A_max, min_def := A_min_def, max_def := A_max_def,
compare := A_compare, compare_eq_compareOfLessAndEq := A_compare_canonical, .. },
{ le := B_le, lt := B_lt,
decidableLE := B_decidableLE, decidableEq := B_decidableEq, decidableLT := B_decidableLT
min := B_min, max := B_max, min_def := B_min_def, max_def := B_max_def,
compare := B_compare, compare_eq_compareOfLessAndEq := B_compare_canonical, .. } => by
cases h
obtain rfl : A_decidableLE = B_decidableLE := Subsingleton.elim _ _
obtain rfl : A_decidableEq = B_decidableEq := Subsingleton.elim _ _
obtain rfl : A_decidableLT = B_decidableLT := Subsingleton.elim _ _
have : A_min = B_min := by
funext a b
exact (A_min_def _ _).trans (B_min_def _ _).symm
cases this
have : A_max = B_max := by
funext a b
exact (A_max_def _ _).trans (B_max_def _ _).symm
cases this
have : A_compare = B_compare := by
funext a b
exact (A_compare_canonical _ _).trans (B_compare_canonical _ _).symm
congr
#align linear_order.to_partial_order_injective LinearOrder.toPartialOrder_injective
theorem Preorder.ext {A B : Preorder α}
(H : ∀ x y : α, (haveI := A; x ≤ y) ↔ x ≤ y) : A = B := by
ext x y
exact H x y
#align preorder.ext Preorder.ext
theorem PartialOrder.ext {A B : PartialOrder α}
(H : ∀ x y : α, (haveI := A; x ≤ y) ↔ x ≤ y) : A = B := by
ext x y
exact H x y
#align partial_order.ext PartialOrder.ext
theorem LinearOrder.ext {A B : LinearOrder α}
(H : ∀ x y : α, (haveI := A; x ≤ y) ↔ x ≤ y) : A = B := by
ext x y
exact H x y
#align linear_order.ext LinearOrder.ext
/-- Given a relation `R` on `β` and a function `f : α → β`, the preimage relation on `α` is defined
by `x ≤ y ↔ f x ≤ f y`. It is the unique relation on `α` making `f` a `RelEmbedding` (assuming `f`
is injective). -/
@[simp]
def Order.Preimage (f : α → β) (s : β → β → Prop) (x y : α) : Prop :=
s (f x) (f y)
#align order.preimage Order.Preimage
@[inherit_doc]
infixl:80 " ⁻¹'o " => Order.Preimage
/-- The preimage of a decidable order is decidable. -/
instance Order.Preimage.decidable (f : α → β) (s : β → β → Prop) [H : DecidableRel s] :
DecidableRel (f ⁻¹'o s) := fun _ _ ↦ H _ _
#align order.preimage.decidable Order.Preimage.decidable
section ltByCases
variable [LinearOrder α] {P : Sort*} {x y : α}
@[simp]
lemma ltByCases_lt (h : x < y) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P} :
ltByCases x y h₁ h₂ h₃ = h₁ h := dif_pos h
@[simp]
lemma ltByCases_gt (h : y < x) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P} :
ltByCases x y h₁ h₂ h₃ = h₃ h := (dif_neg h.not_lt).trans (dif_pos h)
@[simp]
lemma ltByCases_eq (h : x = y) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P} :
ltByCases x y h₁ h₂ h₃ = h₂ h := (dif_neg h.not_lt).trans (dif_neg h.not_gt)
lemma ltByCases_not_lt (h : ¬ x < y) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P}
(p : ¬ y < x → x = y := fun h' => (le_antisymm (le_of_not_gt h') (le_of_not_gt h))) :
ltByCases x y h₁ h₂ h₃ = if h' : y < x then h₃ h' else h₂ (p h') := dif_neg h
lemma ltByCases_not_gt (h : ¬ y < x) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P}
(p : ¬ x < y → x = y := fun h' => (le_antisymm (le_of_not_gt h) (le_of_not_gt h'))) :
ltByCases x y h₁ h₂ h₃ = if h' : x < y then h₁ h' else h₂ (p h') :=
dite_congr rfl (fun _ => rfl) (fun _ => dif_neg h)
lemma ltByCases_ne (h : x ≠ y) {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P}
(p : ¬ x < y → y < x := fun h' => h.lt_or_lt.resolve_left h') :
ltByCases x y h₁ h₂ h₃ = if h' : x < y then h₁ h' else h₃ (p h') :=
dite_congr rfl (fun _ => rfl) (fun _ => dif_pos _)
lemma ltByCases_comm {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P}
(p : y = x → x = y := fun h' => h'.symm) :
ltByCases x y h₁ h₂ h₃ = ltByCases y x h₃ (h₂ ∘ p) h₁ := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· rw [ltByCases_lt h, ltByCases_gt h]
· rw [ltByCases_eq h, ltByCases_eq h.symm, comp_apply]
· rw [ltByCases_lt h, ltByCases_gt h]
lemma eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt {x' y' : α}
(ltc : (x < y) ↔ (x' < y')) (gtc : (y < x) ↔ (y' < x')) :
x = y ↔ x' = y' := by simp_rw [eq_iff_le_not_lt, ← not_lt, ltc, gtc]
lemma ltByCases_rec {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P} (p : P)
(hlt : (h : x < y) → h₁ h = p) (heq : (h : x = y) → h₂ h = p)
(hgt : (h : y < x) → h₃ h = p) :
ltByCases x y h₁ h₂ h₃ = p :=
ltByCases x y
(fun h => ltByCases_lt h ▸ hlt h)
(fun h => ltByCases_eq h ▸ heq h)
(fun h => ltByCases_gt h ▸ hgt h)
lemma ltByCases_eq_iff {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P} {p : P} :
ltByCases x y h₁ h₂ h₃ = p ↔ (∃ h, h₁ h = p) ∨ (∃ h, h₂ h = p) ∨ (∃ h, h₃ h = p) := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· simp only [ltByCases_lt, exists_prop_of_true, h, h.not_lt, not_false_eq_true,
exists_prop_of_false, or_false, h.ne]
· simp only [h, lt_self_iff_false, ltByCases_eq, not_false_eq_true,
exists_prop_of_false, exists_prop_of_true, or_false, false_or]
· simp only [ltByCases_gt, exists_prop_of_true, h, h.not_lt, not_false_eq_true,
exists_prop_of_false, false_or, h.ne']
lemma ltByCases_congr {x' y' : α} {h₁ : x < y → P} {h₂ : x = y → P} {h₃ : y < x → P}
{h₁' : x' < y' → P} {h₂' : x' = y' → P} {h₃' : y' < x' → P} (ltc : (x < y) ↔ (x' < y'))
(gtc : (y < x) ↔ (y' < x')) (hh'₁ : ∀ (h : x' < y'), h₁ (ltc.mpr h) = h₁' h)
(hh'₂ : ∀ (h : x' = y'), h₂ ((eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt ltc gtc).mpr h) = h₂' h)
(hh'₃ : ∀ (h : y' < x'), h₃ (gtc.mpr h) = h₃' h) :
ltByCases x y h₁ h₂ h₃ = ltByCases x' y' h₁' h₂' h₃' := by
refine ltByCases_rec _ (fun h => ?_) (fun h => ?_) (fun h => ?_)
· rw [ltByCases_lt (ltc.mp h), hh'₁]
· rw [eq_iff_eq_of_lt_iff_lt_of_gt_iff_gt ltc gtc] at h
rw [ltByCases_eq h, hh'₂]
· rw [ltByCases_gt (gtc.mp h), hh'₃]
/-- Perform a case-split on the ordering of `x` and `y` in a decidable linear order,
non-dependently. -/
abbrev ltTrichotomy (x y : α) (p q r : P) := ltByCases x y (fun _ => p) (fun _ => q) (fun _ => r)
variable {p q r s : P}
@[simp]
lemma ltTrichotomy_lt (h : x < y) : ltTrichotomy x y p q r = p := ltByCases_lt h
@[simp]
lemma ltTrichotomy_gt (h : y < x) : ltTrichotomy x y p q r = r := ltByCases_gt h
@[simp]
lemma ltTrichotomy_eq (h : x = y) : ltTrichotomy x y p q r = q := ltByCases_eq h
lemma ltTrichotomy_not_lt (h : ¬ x < y) :
ltTrichotomy x y p q r = if y < x then r else q := ltByCases_not_lt h
lemma ltTrichotomy_not_gt (h : ¬ y < x) :
ltTrichotomy x y p q r = if x < y then p else q := ltByCases_not_gt h
lemma ltTrichotomy_ne (h : x ≠ y) :
ltTrichotomy x y p q r = if x < y then p else r := ltByCases_ne h
lemma ltTrichotomy_comm : ltTrichotomy x y p q r = ltTrichotomy y x r q p := ltByCases_comm
lemma ltTrichotomy_self {p : P} : ltTrichotomy x y p p p = p :=
ltByCases_rec p (fun _ => rfl) (fun _ => rfl) (fun _ => rfl)
lemma ltTrichotomy_eq_iff : ltTrichotomy x y p q r = s ↔
(x < y ∧ p = s) ∨ (x = y ∧ q = s) ∨ (y < x ∧ r = s) := by
refine ltByCases x y (fun h => ?_) (fun h => ?_) (fun h => ?_)
· simp only [ltTrichotomy_lt, false_and, true_and, or_false, h, h.not_lt, h.ne]
· simp only [ltTrichotomy_eq, false_and, true_and, or_false, false_or, h, lt_irrefl]
· simp only [ltTrichotomy_gt, false_and, true_and, false_or, h, h.not_lt, h.ne']
lemma ltTrichotomy_congr {x' y' : α} {p' q' r' : P} (ltc : (x < y) ↔ (x' < y'))
(gtc : (y < x) ↔ (y' < x')) (hh'₁ : x' < y' → p = p')
(hh'₂ : x' = y' → q = q') (hh'₃ : y' < x' → r = r') :
ltTrichotomy x y p q r = ltTrichotomy x' y' p' q' r' :=
ltByCases_congr ltc gtc hh'₁ hh'₂ hh'₃
end ltByCases
/-! ### Order dual -/
/-- Type synonym to equip a type with the dual order: `≤` means `≥` and `<` means `>`. `αᵒᵈ` is
notation for `OrderDual α`. -/
def OrderDual (α : Type*) : Type _ :=
α
#align order_dual OrderDual
@[inherit_doc]
notation:max α "ᵒᵈ" => OrderDual α
namespace OrderDual
instance (α : Type*) [h : Nonempty α] : Nonempty αᵒᵈ :=
h
instance (α : Type*) [h : Subsingleton α] : Subsingleton αᵒᵈ :=
h
instance (α : Type*) [LE α] : LE αᵒᵈ :=
⟨fun x y : α ↦ y ≤ x⟩
instance (α : Type*) [LT α] : LT αᵒᵈ :=
⟨fun x y : α ↦ y < x⟩
instance instPreorder (α : Type*) [Preorder α] : Preorder αᵒᵈ where
le_refl := fun _ ↦ le_refl _
le_trans := fun _ _ _ hab hbc ↦ hbc.trans hab
lt_iff_le_not_le := fun _ _ ↦ lt_iff_le_not_le
instance instPartialOrder (α : Type*) [PartialOrder α] : PartialOrder αᵒᵈ where
__ := inferInstanceAs (Preorder αᵒᵈ)
le_antisymm := fun a b hab hba ↦ @le_antisymm α _ a b hba hab
instance instLinearOrder (α : Type*) [LinearOrder α] : LinearOrder αᵒᵈ where
__ := inferInstanceAs (PartialOrder αᵒᵈ)
le_total := fun a b : α ↦ le_total b a
max := fun a b ↦ (min a b : α)
min := fun a b ↦ (max a b : α)
min_def := fun a b ↦ show (max .. : α) = _ by rw [max_comm, max_def]; rfl
max_def := fun a b ↦ show (min .. : α) = _ by rw [min_comm, min_def]; rfl
decidableLE := (inferInstance : DecidableRel (fun a b : α ↦ b ≤ a))
decidableLT := (inferInstance : DecidableRel (fun a b : α ↦ b < a))
#align order_dual.linear_order OrderDual.instLinearOrder
instance : ∀ [Inhabited α], Inhabited αᵒᵈ := fun [x : Inhabited α] => x
theorem Preorder.dual_dual (α : Type*) [H : Preorder α] : OrderDual.instPreorder αᵒᵈ = H :=
Preorder.ext fun _ _ ↦ Iff.rfl
#align order_dual.preorder.dual_dual OrderDual.Preorder.dual_dual
theorem instPartialOrder.dual_dual (α : Type*) [H : PartialOrder α] :
OrderDual.instPartialOrder αᵒᵈ = H :=
PartialOrder.ext fun _ _ ↦ Iff.rfl
#align order_dual.partial_order.dual_dual OrderDual.instPartialOrder.dual_dual
theorem instLinearOrder.dual_dual (α : Type*) [H : LinearOrder α] :
OrderDual.instLinearOrder αᵒᵈ = H :=
LinearOrder.ext fun _ _ ↦ Iff.rfl
#align order_dual.linear_order.dual_dual OrderDual.instLinearOrder.dual_dual
end OrderDual
/-! ### `HasCompl` -/
instance Prop.hasCompl : HasCompl Prop :=
⟨Not⟩
#align Prop.has_compl Prop.hasCompl
instance Pi.hasCompl [∀ i, HasCompl (π i)] : HasCompl (∀ i, π i) :=
⟨fun x i ↦ (x i)ᶜ⟩
#align pi.has_compl Pi.hasCompl
theorem Pi.compl_def [∀ i, HasCompl (π i)] (x : ∀ i, π i) :
xᶜ = fun i ↦ (x i)ᶜ :=
rfl
#align pi.compl_def Pi.compl_def
@[simp]
theorem Pi.compl_apply [∀ i, HasCompl (π i)] (x : ∀ i, π i) (i : ι) :
xᶜ i = (x i)ᶜ :=
rfl
#align pi.compl_apply Pi.compl_apply
instance IsIrrefl.compl (r) [IsIrrefl α r] : IsRefl α rᶜ :=
⟨@irrefl α r _⟩
#align is_irrefl.compl IsIrrefl.compl
instance IsRefl.compl (r) [IsRefl α r] : IsIrrefl α rᶜ :=
⟨fun a ↦ not_not_intro (refl a)⟩
#align is_refl.compl IsRefl.compl
/-! ### Order instances on the function space -/
instance Pi.hasLe [∀ i, LE (π i)] :
LE (∀ i, π i) where le x y := ∀ i, x i ≤ y i
#align pi.has_le Pi.hasLe
theorem Pi.le_def [∀ i, LE (π i)] {x y : ∀ i, π i} :
x ≤ y ↔ ∀ i, x i ≤ y i :=
Iff.rfl
#align pi.le_def Pi.le_def
instance Pi.preorder [∀ i, Preorder (π i)] : Preorder (∀ i, π i) where
__ := inferInstanceAs (LE (∀ i, π i))
le_refl := fun a i ↦ le_refl (a i)
le_trans := fun a b c h₁ h₂ i ↦ le_trans (h₁ i) (h₂ i)
#align pi.preorder Pi.preorder
theorem Pi.lt_def [∀ i, Preorder (π i)] {x y : ∀ i, π i} :
x < y ↔ x ≤ y ∧ ∃ i, x i < y i := by
simp (config := { contextual := true }) [lt_iff_le_not_le, Pi.le_def]
#align pi.lt_def Pi.lt_def
instance Pi.partialOrder [∀ i, PartialOrder (π i)] : PartialOrder (∀ i, π i) where
__ := Pi.preorder
le_antisymm := fun _ _ h1 h2 ↦ funext fun b ↦ (h1 b).antisymm (h2 b)
#align pi.partial_order Pi.partialOrder
namespace Sum
variable {α₁ α₂ : Type*} [LE β]
@[simp]
lemma elim_le_elim_iff {u₁ v₁ : α₁ → β} {u₂ v₂ : α₂ → β} :
Sum.elim u₁ u₂ ≤ Sum.elim v₁ v₂ ↔ u₁ ≤ v₁ ∧ u₂ ≤ v₂ :=
Sum.forall
lemma const_le_elim_iff {b : β} {v₁ : α₁ → β} {v₂ : α₂ → β} :
Function.const _ b ≤ Sum.elim v₁ v₂ ↔ Function.const _ b ≤ v₁ ∧ Function.const _ b ≤ v₂ :=
elim_const_const b ▸ elim_le_elim_iff ..
lemma elim_le_const_iff {b : β} {u₁ : α₁ → β} {u₂ : α₂ → β} :
Sum.elim u₁ u₂ ≤ Function.const _ b ↔ u₁ ≤ Function.const _ b ∧ u₂ ≤ Function.const _ b :=
elim_const_const b ▸ elim_le_elim_iff ..
end Sum
section Pi
/-- A function `a` is strongly less than a function `b` if `a i < b i` for all `i`. -/
def StrongLT [∀ i, LT (π i)] (a b : ∀ i, π i) : Prop :=
∀ i, a i < b i
#align strong_lt StrongLT
@[inherit_doc]
local infixl:50 " ≺ " => StrongLT
variable [∀ i, Preorder (π i)] {a b c : ∀ i, π i}
theorem le_of_strongLT (h : a ≺ b) : a ≤ b := fun _ ↦ (h _).le
#align le_of_strong_lt le_of_strongLT
theorem lt_of_strongLT [Nonempty ι] (h : a ≺ b) : a < b := by
inhabit ι
exact Pi.lt_def.2 ⟨le_of_strongLT h, default, h _⟩
#align lt_of_strong_lt lt_of_strongLT
theorem strongLT_of_strongLT_of_le (hab : a ≺ b) (hbc : b ≤ c) : a ≺ c := fun _ ↦
(hab _).trans_le <| hbc _
#align strong_lt_of_strong_lt_of_le strongLT_of_strongLT_of_le
theorem strongLT_of_le_of_strongLT (hab : a ≤ b) (hbc : b ≺ c) : a ≺ c := fun _ ↦
(hab _).trans_lt <| hbc _
#align strong_lt_of_le_of_strong_lt strongLT_of_le_of_strongLT
alias StrongLT.le := le_of_strongLT
#align strong_lt.le StrongLT.le
alias StrongLT.lt := lt_of_strongLT
#align strong_lt.lt StrongLT.lt
alias StrongLT.trans_le := strongLT_of_strongLT_of_le
#align strong_lt.trans_le StrongLT.trans_le
alias LE.le.trans_strongLT := strongLT_of_le_of_strongLT
end Pi
section Function
variable [DecidableEq ι] [∀ i, Preorder (π i)] {x y : ∀ i, π i} {i : ι} {a b : π i}
theorem le_update_iff : x ≤ Function.update y i a ↔ x i ≤ a ∧ ∀ (j) (_ : j ≠ i), x j ≤ y j :=
Function.forall_update_iff _ fun j z ↦ x j ≤ z
#align le_update_iff le_update_iff
theorem update_le_iff : Function.update x i a ≤ y ↔ a ≤ y i ∧ ∀ (j) (_ : j ≠ i), x j ≤ y j :=
Function.forall_update_iff _ fun j z ↦ z ≤ y j
#align update_le_iff update_le_iff
theorem update_le_update_iff :
Function.update x i a ≤ Function.update y i b ↔ a ≤ b ∧ ∀ (j) (_ : j ≠ i), x j ≤ y j := by
simp (config := { contextual := true }) [update_le_iff]
#align update_le_update_iff update_le_update_iff
@[simp]
theorem update_le_update_iff' : update x i a ≤ update x i b ↔ a ≤ b := by
simp [update_le_update_iff]
#align update_le_update_iff' update_le_update_iff'
@[simp]
theorem update_lt_update_iff : update x i a < update x i b ↔ a < b :=
lt_iff_lt_of_le_iff_le' update_le_update_iff' update_le_update_iff'
#align update_lt_update_iff update_lt_update_iff
@[simp]
theorem le_update_self_iff : x ≤ update x i a ↔ x i ≤ a := by simp [le_update_iff]
#align le_update_self_iff le_update_self_iff
@[simp]
theorem update_le_self_iff : update x i a ≤ x ↔ a ≤ x i := by simp [update_le_iff]
#align update_le_self_iff update_le_self_iff
@[simp]
theorem lt_update_self_iff : x < update x i a ↔ x i < a := by simp [lt_iff_le_not_le]
#align lt_update_self_iff lt_update_self_iff
@[simp]
theorem update_lt_self_iff : update x i a < x ↔ a < x i := by simp [lt_iff_le_not_le]
#align update_lt_self_iff update_lt_self_iff
end Function
instance Pi.sdiff [∀ i, SDiff (π i)] : SDiff (∀ i, π i) :=
⟨fun x y i ↦ x i \ y i⟩
#align pi.has_sdiff Pi.sdiff
theorem Pi.sdiff_def [∀ i, SDiff (π i)] (x y : ∀ i, π i) :
x \ y = fun i ↦ x i \ y i :=
rfl
#align pi.sdiff_def Pi.sdiff_def
@[simp]
theorem Pi.sdiff_apply [∀ i, SDiff (π i)] (x y : ∀ i, π i) (i : ι) :
(x \ y) i = x i \ y i :=
rfl
#align pi.sdiff_apply Pi.sdiff_apply
namespace Function
variable [Preorder α] [Nonempty β] {a b : α}
@[simp]
| Mathlib/Order/Basic.lean | 1,038 | 1,038 | theorem const_le_const : const β a ≤ const β b ↔ a ≤ b := by | simp [Pi.le_def]
|
/-
Copyright (c) 2022 Yaël Dillies. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yaël Dillies
-/
import Mathlib.Order.Antichain
import Mathlib.Order.UpperLower.Basic
import Mathlib.Order.Interval.Set.Basic
import Mathlib.Order.RelIso.Set
#align_import order.minimal from "leanprover-community/mathlib"@"59694bd07f0a39c5beccba34bd9f413a160782bf"
/-!
# Minimal/maximal elements of a set
This file defines minimal and maximal of a set with respect to an arbitrary relation.
## Main declarations
* `maximals r s`: Maximal elements of `s` with respect to `r`.
* `minimals r s`: Minimal elements of `s` with respect to `r`.
## TODO
Do we need a `Finset` version?
-/
open Function Set
variable {α : Type*} (r r₁ r₂ : α → α → Prop) (s t : Set α) (a b : α)
/-- Turns a set into an antichain by keeping only the "maximal" elements. -/
def maximals : Set α :=
{ a ∈ s | ∀ ⦃b⦄, b ∈ s → r a b → r b a }
#align maximals maximals
/-- Turns a set into an antichain by keeping only the "minimal" elements. -/
def minimals : Set α :=
{ a ∈ s | ∀ ⦃b⦄, b ∈ s → r b a → r a b }
#align minimals minimals
theorem maximals_subset : maximals r s ⊆ s :=
sep_subset _ _
#align maximals_subset maximals_subset
theorem minimals_subset : minimals r s ⊆ s :=
sep_subset _ _
#align minimals_subset minimals_subset
@[simp]
theorem maximals_empty : maximals r ∅ = ∅ :=
sep_empty _
#align maximals_empty maximals_empty
@[simp]
theorem minimals_empty : minimals r ∅ = ∅ :=
sep_empty _
#align minimals_empty minimals_empty
@[simp]
theorem maximals_singleton : maximals r {a} = {a} :=
(maximals_subset _ _).antisymm <|
singleton_subset_iff.2 <|
⟨rfl, by
rintro b (rfl : b = a)
exact id⟩
#align maximals_singleton maximals_singleton
@[simp]
theorem minimals_singleton : minimals r {a} = {a} :=
maximals_singleton _ _
#align minimals_singleton minimals_singleton
theorem maximals_swap : maximals (swap r) s = minimals r s :=
rfl
#align maximals_swap maximals_swap
theorem minimals_swap : minimals (swap r) s = maximals r s :=
rfl
#align minimals_swap minimals_swap
section IsAntisymm
variable {r s t a b} [IsAntisymm α r]
theorem eq_of_mem_maximals (ha : a ∈ maximals r s) (hb : b ∈ s) (h : r a b) : a = b :=
antisymm h <| ha.2 hb h
#align eq_of_mem_maximals eq_of_mem_maximals
theorem eq_of_mem_minimals (ha : a ∈ minimals r s) (hb : b ∈ s) (h : r b a) : a = b :=
antisymm (ha.2 hb h) h
#align eq_of_mem_minimals eq_of_mem_minimals
set_option autoImplicit true
theorem mem_maximals_iff : x ∈ maximals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r x y → x = y := by
simp only [maximals, Set.mem_sep_iff, and_congr_right_iff]
refine fun _ ↦ ⟨fun h y hys hxy ↦ antisymm hxy (h hys hxy), fun h y hys hxy ↦ ?_⟩
convert hxy <;> rw [h hys hxy]
theorem mem_maximals_setOf_iff : x ∈ maximals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r x y → x = y :=
mem_maximals_iff
theorem mem_minimals_iff : x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ∈ s → r y x → x = y :=
@mem_maximals_iff _ _ _ (IsAntisymm.swap r) _
theorem mem_minimals_setOf_iff : x ∈ minimals r (setOf P) ↔ P x ∧ ∀ ⦃y⦄, P y → r y x → x = y :=
mem_minimals_iff
/-- This theorem can't be used to rewrite without specifying `rlt`, since `rlt` would have to be
guessed. See `mem_minimals_iff_forall_ssubset_not_mem` and `mem_minimals_iff_forall_lt_not_mem`
for `⊆` and `≤` versions. -/
theorem mem_minimals_iff_forall_lt_not_mem' (rlt : α → α → Prop) [IsNonstrictStrictOrder α r rlt] :
x ∈ minimals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, rlt y x → y ∉ s := by
simp [minimals, right_iff_left_not_left_of r rlt, not_imp_not, imp.swap (a := _ ∈ _)]
theorem mem_maximals_iff_forall_lt_not_mem' (rlt : α → α → Prop) [IsNonstrictStrictOrder α r rlt] :
x ∈ maximals r s ↔ x ∈ s ∧ ∀ ⦃y⦄, rlt x y → y ∉ s := by
simp [maximals, right_iff_left_not_left_of r rlt, not_imp_not, imp.swap (a := _ ∈ _)]
theorem minimals_eq_minimals_of_subset_of_forall [IsTrans α r] (hts : t ⊆ s)
(h : ∀ x ∈ s, ∃ y ∈ t, r y x) : minimals r s = minimals r t := by
refine Set.ext fun a ↦ ⟨fun ⟨has, hmin⟩ ↦ ⟨?_,fun b hbt ↦ hmin (hts hbt)⟩,
fun ⟨hat, hmin⟩ ↦ ⟨hts hat, fun b hbs hba ↦ ?_⟩⟩
· obtain ⟨a', ha', haa'⟩ := h _ has
rwa [antisymm (hmin (hts ha') haa') haa']
obtain ⟨b', hb't, hb'b⟩ := h b hbs
rwa [antisymm (hmin hb't (Trans.trans hb'b hba)) (Trans.trans hb'b hba)]
theorem maximals_eq_maximals_of_subset_of_forall [IsTrans α r] (hts : t ⊆ s)
(h : ∀ x ∈ s, ∃ y ∈ t, r x y) : maximals r s = maximals r t :=
@minimals_eq_minimals_of_subset_of_forall _ _ _ _ (IsAntisymm.swap r) (IsTrans.swap r) hts h
variable (r s)
theorem maximals_antichain : IsAntichain r (maximals r s) := fun _a ha _b hb hab h =>
hab <| eq_of_mem_maximals ha hb.1 h
#align maximals_antichain maximals_antichain
theorem minimals_antichain : IsAntichain r (minimals r s) :=
haveI := IsAntisymm.swap r
(maximals_antichain _ _).swap
#align minimals_antichain minimals_antichain
end IsAntisymm
set_option autoImplicit true
theorem mem_minimals_iff_forall_ssubset_not_mem (s : Set (Set α)) :
x ∈ minimals (· ⊆ ·) s ↔ x ∈ s ∧ ∀ ⦃y⦄, y ⊂ x → y ∉ s :=
mem_minimals_iff_forall_lt_not_mem' (· ⊂ ·)
theorem mem_minimals_iff_forall_lt_not_mem [PartialOrder α] {s : Set α} :
x ∈ minimals (· ≤ ·) s ↔ x ∈ s ∧ ∀ ⦃y⦄, y < x → y ∉ s :=
mem_minimals_iff_forall_lt_not_mem' (· < ·)
theorem mem_maximals_iff_forall_ssubset_not_mem {s : Set (Set α)} :
x ∈ maximals (· ⊆ ·) s ↔ x ∈ s ∧ ∀ ⦃y⦄, x ⊂ y → y ∉ s :=
mem_maximals_iff_forall_lt_not_mem' (· ⊂ ·)
theorem mem_maximals_iff_forall_lt_not_mem [PartialOrder α] {s : Set α} :
x ∈ maximals (· ≤ ·) s ↔ x ∈ s ∧ ∀ ⦃y⦄, x < y → y ∉ s :=
mem_maximals_iff_forall_lt_not_mem' (· < ·)
-- Porting note (#10756): new theorem
theorem maximals_of_symm [IsSymm α r] : maximals r s = s :=
sep_eq_self_iff_mem_true.2 fun _ _ _ _ => symm
-- Porting note (#10756): new theorem
theorem minimals_of_symm [IsSymm α r] : minimals r s = s :=
sep_eq_self_iff_mem_true.2 fun _ _ _ _ => symm
theorem maximals_eq_minimals [IsSymm α r] : maximals r s = minimals r s := by
rw [minimals_of_symm, maximals_of_symm]
#align maximals_eq_minimals maximals_eq_minimals
variable {r r₁ r₂ s t a}
-- Porting note (#11215): TODO: use `h.induction_on`
| Mathlib/Order/Minimal.lean | 180 | 182 | theorem Set.Subsingleton.maximals_eq (h : s.Subsingleton) : maximals r s = s := by |
rcases h.eq_empty_or_singleton with (rfl | ⟨x, rfl⟩)
exacts [minimals_empty _, maximals_singleton _ _]
|
/-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Patrick Massot
-/
import Mathlib.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"
/-!
# (Pre)images of intervals
In this file we prove a bunch of trivial lemmas like “if we add `a` to all points of `[b, c]`,
then we get `[a + b, a + c]`”. For the functions `x ↦ x ± a`, `x ↦ a ± x`, and `x ↦ -x` we prove
lemmas about preimages and images of all intervals. We also prove a few lemmas about images under
`x ↦ a * x`, `x ↦ x * a` and `x ↦ x⁻¹`.
-/
open Interval Pointwise
variable {α : Type*}
namespace Set
/-! ### Binary pointwise operations
Note that the subset operations below only cover the cases with the largest possible intervals on
the LHS: to conclude that `Ioo a b * Ioo c d ⊆ Ioo (a * c) (c * d)`, you can use monotonicity of `*`
and `Set.Ico_mul_Ioc_subset`.
TODO: repeat these lemmas for the generality of `mul_le_mul` (which assumes nonnegativity), which
the unprimed names have been reserved for
-/
section ContravariantLE
variable [Mul α] [Preorder α]
variable [CovariantClass α α (· * ·) (· ≤ ·)] [CovariantClass α α (Function.swap HMul.hMul) LE.le]
@[to_additive Icc_add_Icc_subset]
theorem Icc_mul_Icc_subset' (a b c d : α) : Icc a b * Icc c d ⊆ Icc (a * c) (b * d) := by
rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩
exact ⟨mul_le_mul' hya hzc, mul_le_mul' hyb hzd⟩
@[to_additive Iic_add_Iic_subset]
theorem Iic_mul_Iic_subset' (a b : α) : Iic a * Iic b ⊆ Iic (a * b) := by
rintro x ⟨y, hya, z, hzb, rfl⟩
exact mul_le_mul' hya hzb
@[to_additive Ici_add_Ici_subset]
theorem Ici_mul_Ici_subset' (a b : α) : Ici a * Ici b ⊆ Ici (a * b) := by
rintro x ⟨y, hya, z, hzb, rfl⟩
exact mul_le_mul' hya hzb
end ContravariantLE
section ContravariantLT
variable [Mul α] [PartialOrder α]
variable [CovariantClass α α (· * ·) (· < ·)] [CovariantClass α α (Function.swap HMul.hMul) LT.lt]
@[to_additive Icc_add_Ico_subset]
theorem Icc_mul_Ico_subset' (a b c d : α) : Icc a b * Ico c d ⊆ Ico (a * c) (b * d) := by
haveI := covariantClass_le_of_lt
rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩
exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_le_of_lt hyb hzd⟩
@[to_additive Ico_add_Icc_subset]
| Mathlib/Data/Set/Pointwise/Interval.lean | 74 | 77 | theorem Ico_mul_Icc_subset' (a b c d : α) : Ico a b * Icc c d ⊆ Ico (a * c) (b * d) := by |
haveI := covariantClass_le_of_lt
rintro x ⟨y, ⟨hya, hyb⟩, z, ⟨hzc, hzd⟩, rfl⟩
exact ⟨mul_le_mul' hya hzc, mul_lt_mul_of_lt_of_le hyb hzd⟩
|
/-
Copyright (c) 2021 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov, Alex Kontorovich, Heather Macbeth
-/
import Mathlib.MeasureTheory.Group.Action
import Mathlib.MeasureTheory.Integral.SetIntegral
import Mathlib.MeasureTheory.Group.Pointwise
#align_import measure_theory.group.fundamental_domain from "leanprover-community/mathlib"@"3b52265189f3fb43aa631edffce5d060fafaf82f"
/-!
# Fundamental domain of a group action
A set `s` is said to be a *fundamental domain* of an action of a group `G` on a measurable space `α`
with respect to a measure `μ` if
* `s` is a measurable set;
* the sets `g • s` over all `g : G` cover almost all points of the whole space;
* the sets `g • s`, are pairwise a.e. disjoint, i.e., `μ (g₁ • s ∩ g₂ • s) = 0` whenever `g₁ ≠ g₂`;
we require this for `g₂ = 1` in the definition, then deduce it for any two `g₁ ≠ g₂`.
In this file we prove that in case of a countable group `G` and a measure preserving action, any two
fundamental domains have the same measure, and for a `G`-invariant function, its integrals over any
two fundamental domains are equal to each other.
We also generate additive versions of all theorems in this file using the `to_additive` attribute.
* We define the `HasFundamentalDomain` typeclass, in particular to be able to define the `covolume`
of a quotient of `α` by a group `G`, which under reasonable conditions does not depend on the choice
of fundamental domain.
* We define the `QuotientMeasureEqMeasurePreimage` typeclass to describe a situation in which a
measure `μ` on `α ⧸ G` can be computed by taking a measure `ν` on `α` of the intersection of the
pullback with a fundamental domain.
## Main declarations
* `MeasureTheory.IsFundamentalDomain`: Predicate for a set to be a fundamental domain of the
action of a group
* `MeasureTheory.fundamentalFrontier`: Fundamental frontier of a set under the action of a group.
Elements of `s` that belong to some other translate of `s`.
* `MeasureTheory.fundamentalInterior`: Fundamental interior of a set under the action of a group.
Elements of `s` that do not belong to any other translate of `s`.
-/
open scoped ENNReal Pointwise Topology NNReal ENNReal MeasureTheory
open MeasureTheory MeasureTheory.Measure Set Function TopologicalSpace Filter
namespace MeasureTheory
/-- A measurable set `s` is a *fundamental domain* for an additive action of an additive group `G`
on a measurable space `α` with respect to a measure `α` if the sets `g +ᵥ s`, `g : G`, are pairwise
a.e. disjoint and cover the whole space. -/
structure IsAddFundamentalDomain (G : Type*) {α : Type*} [Zero G] [VAdd G α] [MeasurableSpace α]
(s : Set α) (μ : Measure α := by volume_tac) : Prop where
protected nullMeasurableSet : NullMeasurableSet s μ
protected ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g +ᵥ x ∈ s
protected aedisjoint : Pairwise <| (AEDisjoint μ on fun g : G => g +ᵥ s)
#align measure_theory.is_add_fundamental_domain MeasureTheory.IsAddFundamentalDomain
/-- A measurable set `s` is a *fundamental domain* for an action of a group `G` on a measurable
space `α` with respect to a measure `α` if the sets `g • s`, `g : G`, are pairwise a.e. disjoint and
cover the whole space. -/
@[to_additive IsAddFundamentalDomain]
structure IsFundamentalDomain (G : Type*) {α : Type*} [One G] [SMul G α] [MeasurableSpace α]
(s : Set α) (μ : Measure α := by volume_tac) : Prop where
protected nullMeasurableSet : NullMeasurableSet s μ
protected ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g • x ∈ s
protected aedisjoint : Pairwise <| (AEDisjoint μ on fun g : G => g • s)
#align measure_theory.is_fundamental_domain MeasureTheory.IsFundamentalDomain
variable {G H α β E : Type*}
namespace IsFundamentalDomain
variable [Group G] [Group H] [MulAction G α] [MeasurableSpace α] [MulAction H β] [MeasurableSpace β]
[NormedAddCommGroup E] {s t : Set α} {μ : Measure α}
/-- If for each `x : α`, exactly one of `g • x`, `g : G`, belongs to a measurable set `s`, then `s`
is a fundamental domain for the action of `G` on `α`. -/
@[to_additive "If for each `x : α`, exactly one of `g +ᵥ x`, `g : G`, belongs to a measurable set
`s`, then `s` is a fundamental domain for the additive action of `G` on `α`."]
theorem mk' (h_meas : NullMeasurableSet s μ) (h_exists : ∀ x : α, ∃! g : G, g • x ∈ s) :
IsFundamentalDomain G s μ where
nullMeasurableSet := h_meas
ae_covers := eventually_of_forall fun x => (h_exists x).exists
aedisjoint a b hab := Disjoint.aedisjoint <| disjoint_left.2 fun x hxa hxb => by
rw [mem_smul_set_iff_inv_smul_mem] at hxa hxb
exact hab (inv_injective <| (h_exists x).unique hxa hxb)
#align measure_theory.is_fundamental_domain.mk' MeasureTheory.IsFundamentalDomain.mk'
#align measure_theory.is_add_fundamental_domain.mk' MeasureTheory.IsAddFundamentalDomain.mk'
/-- For `s` to be a fundamental domain, it's enough to check
`MeasureTheory.AEDisjoint (g • s) s` for `g ≠ 1`. -/
@[to_additive "For `s` to be a fundamental domain, it's enough to check
`MeasureTheory.AEDisjoint (g +ᵥ s) s` for `g ≠ 0`."]
theorem mk'' (h_meas : NullMeasurableSet s μ) (h_ae_covers : ∀ᵐ x ∂μ, ∃ g : G, g • x ∈ s)
(h_ae_disjoint : ∀ g, g ≠ (1 : G) → AEDisjoint μ (g • s) s)
(h_qmp : ∀ g : G, QuasiMeasurePreserving ((g • ·) : α → α) μ μ) :
IsFundamentalDomain G s μ where
nullMeasurableSet := h_meas
ae_covers := h_ae_covers
aedisjoint := pairwise_aedisjoint_of_aedisjoint_forall_ne_one h_ae_disjoint h_qmp
#align measure_theory.is_fundamental_domain.mk'' MeasureTheory.IsFundamentalDomain.mk''
#align measure_theory.is_add_fundamental_domain.mk'' MeasureTheory.IsAddFundamentalDomain.mk''
/-- If a measurable space has a finite measure `μ` and a countable group `G` acts
quasi-measure-preservingly, then to show that a set `s` is a fundamental domain, it is sufficient
to check that its translates `g • s` are (almost) disjoint and that the sum `∑' g, μ (g • s)` is
sufficiently large. -/
@[to_additive
"If a measurable space has a finite measure `μ` and a countable additive group `G` acts
quasi-measure-preservingly, then to show that a set `s` is a fundamental domain, it is sufficient
to check that its translates `g +ᵥ s` are (almost) disjoint and that the sum `∑' g, μ (g +ᵥ s)` is
sufficiently large."]
theorem mk_of_measure_univ_le [IsFiniteMeasure μ] [Countable G] (h_meas : NullMeasurableSet s μ)
(h_ae_disjoint : ∀ g ≠ (1 : G), AEDisjoint μ (g • s) s)
(h_qmp : ∀ g : G, QuasiMeasurePreserving (g • · : α → α) μ μ)
(h_measure_univ_le : μ (univ : Set α) ≤ ∑' g : G, μ (g • s)) : IsFundamentalDomain G s μ :=
have aedisjoint : Pairwise (AEDisjoint μ on fun g : G => g • s) :=
pairwise_aedisjoint_of_aedisjoint_forall_ne_one h_ae_disjoint h_qmp
{ nullMeasurableSet := h_meas
aedisjoint
ae_covers := by
replace h_meas : ∀ g : G, NullMeasurableSet (g • s) μ := fun g => by
rw [← inv_inv g, ← preimage_smul]; exact h_meas.preimage (h_qmp g⁻¹)
have h_meas' : NullMeasurableSet {a | ∃ g : G, g • a ∈ s} μ := by
rw [← iUnion_smul_eq_setOf_exists]; exact .iUnion h_meas
rw [ae_iff_measure_eq h_meas', ← iUnion_smul_eq_setOf_exists]
refine le_antisymm (measure_mono <| subset_univ _) ?_
rw [measure_iUnion₀ aedisjoint h_meas]
exact h_measure_univ_le }
#align measure_theory.is_fundamental_domain.mk_of_measure_univ_le MeasureTheory.IsFundamentalDomain.mk_of_measure_univ_le
#align measure_theory.is_add_fundamental_domain.mk_of_measure_univ_le MeasureTheory.IsAddFundamentalDomain.mk_of_measure_univ_le
@[to_additive]
theorem iUnion_smul_ae_eq (h : IsFundamentalDomain G s μ) : ⋃ g : G, g • s =ᵐ[μ] univ :=
eventuallyEq_univ.2 <| h.ae_covers.mono fun _ ⟨g, hg⟩ =>
mem_iUnion.2 ⟨g⁻¹, _, hg, inv_smul_smul _ _⟩
#align measure_theory.is_fundamental_domain.Union_smul_ae_eq MeasureTheory.IsFundamentalDomain.iUnion_smul_ae_eq
#align measure_theory.is_add_fundamental_domain.Union_vadd_ae_eq MeasureTheory.IsAddFundamentalDomain.iUnion_vadd_ae_eq
@[to_additive]
theorem measure_ne_zero [MeasurableSpace G] [Countable G] [MeasurableSMul G α]
[SMulInvariantMeasure G α μ] (hμ : μ ≠ 0) (h : IsFundamentalDomain G s μ) :
μ s ≠ 0 := by
have hc := measure_univ_pos.mpr hμ
contrapose! hc
rw [← measure_congr h.iUnion_smul_ae_eq]
refine le_trans (measure_iUnion_le _) ?_
simp_rw [measure_smul, hc, tsum_zero, le_refl]
@[to_additive]
theorem mono (h : IsFundamentalDomain G s μ) {ν : Measure α} (hle : ν ≪ μ) :
IsFundamentalDomain G s ν :=
⟨h.1.mono_ac hle, hle h.2, h.aedisjoint.mono fun _ _ h => hle h⟩
#align measure_theory.is_fundamental_domain.mono MeasureTheory.IsFundamentalDomain.mono
#align measure_theory.is_add_fundamental_domain.mono MeasureTheory.IsAddFundamentalDomain.mono
@[to_additive]
theorem preimage_of_equiv {ν : Measure β} (h : IsFundamentalDomain G s μ) {f : β → α}
(hf : QuasiMeasurePreserving f ν μ) {e : G → H} (he : Bijective e)
(hef : ∀ g, Semiconj f (e g • ·) (g • ·)) : IsFundamentalDomain H (f ⁻¹' s) ν where
nullMeasurableSet := h.nullMeasurableSet.preimage hf
ae_covers := (hf.ae h.ae_covers).mono fun x ⟨g, hg⟩ => ⟨e g, by rwa [mem_preimage, hef g x]⟩
aedisjoint a b hab := by
lift e to G ≃ H using he
have : (e.symm a⁻¹)⁻¹ ≠ (e.symm b⁻¹)⁻¹ := by simp [hab]
have := (h.aedisjoint this).preimage hf
simp only [Semiconj] at hef
simpa only [onFun, ← preimage_smul_inv, preimage_preimage, ← hef, e.apply_symm_apply, inv_inv]
using this
#align measure_theory.is_fundamental_domain.preimage_of_equiv MeasureTheory.IsFundamentalDomain.preimage_of_equiv
#align measure_theory.is_add_fundamental_domain.preimage_of_equiv MeasureTheory.IsAddFundamentalDomain.preimage_of_equiv
@[to_additive]
theorem image_of_equiv {ν : Measure β} (h : IsFundamentalDomain G s μ) (f : α ≃ β)
(hf : QuasiMeasurePreserving f.symm ν μ) (e : H ≃ G)
(hef : ∀ g, Semiconj f (e g • ·) (g • ·)) : IsFundamentalDomain H (f '' s) ν := by
rw [f.image_eq_preimage]
refine h.preimage_of_equiv hf e.symm.bijective fun g x => ?_
rcases f.surjective x with ⟨x, rfl⟩
rw [← hef _ _, f.symm_apply_apply, f.symm_apply_apply, e.apply_symm_apply]
#align measure_theory.is_fundamental_domain.image_of_equiv MeasureTheory.IsFundamentalDomain.image_of_equiv
#align measure_theory.is_add_fundamental_domain.image_of_equiv MeasureTheory.IsAddFundamentalDomain.image_of_equiv
@[to_additive]
theorem pairwise_aedisjoint_of_ac {ν} (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) :
Pairwise fun g₁ g₂ : G => AEDisjoint ν (g₁ • s) (g₂ • s) :=
h.aedisjoint.mono fun _ _ H => hν H
#align measure_theory.is_fundamental_domain.pairwise_ae_disjoint_of_ac MeasureTheory.IsFundamentalDomain.pairwise_aedisjoint_of_ac
#align measure_theory.is_add_fundamental_domain.pairwise_ae_disjoint_of_ac MeasureTheory.IsAddFundamentalDomain.pairwise_aedisjoint_of_ac
@[to_additive]
theorem smul_of_comm {G' : Type*} [Group G'] [MulAction G' α] [MeasurableSpace G']
[MeasurableSMul G' α] [SMulInvariantMeasure G' α μ] [SMulCommClass G' G α]
(h : IsFundamentalDomain G s μ) (g : G') : IsFundamentalDomain G (g • s) μ :=
h.image_of_equiv (MulAction.toPerm g) (measurePreserving_smul _ _).quasiMeasurePreserving
(Equiv.refl _) <| smul_comm g
#align measure_theory.is_fundamental_domain.smul_of_comm MeasureTheory.IsFundamentalDomain.smul_of_comm
#align measure_theory.is_add_fundamental_domain.vadd_of_comm MeasureTheory.IsAddFundamentalDomain.vadd_of_comm
variable [MeasurableSpace G] [MeasurableSMul G α] [SMulInvariantMeasure G α μ]
@[to_additive]
theorem nullMeasurableSet_smul (h : IsFundamentalDomain G s μ) (g : G) :
NullMeasurableSet (g • s) μ :=
h.nullMeasurableSet.smul g
#align measure_theory.is_fundamental_domain.null_measurable_set_smul MeasureTheory.IsFundamentalDomain.nullMeasurableSet_smul
#align measure_theory.is_add_fundamental_domain.null_measurable_set_vadd MeasureTheory.IsAddFundamentalDomain.nullMeasurableSet_vadd
@[to_additive]
theorem restrict_restrict (h : IsFundamentalDomain G s μ) (g : G) (t : Set α) :
(μ.restrict t).restrict (g • s) = μ.restrict (g • s ∩ t) :=
restrict_restrict₀ ((h.nullMeasurableSet_smul g).mono restrict_le_self)
#align measure_theory.is_fundamental_domain.restrict_restrict MeasureTheory.IsFundamentalDomain.restrict_restrict
#align measure_theory.is_add_fundamental_domain.restrict_restrict MeasureTheory.IsAddFundamentalDomain.restrict_restrict
@[to_additive]
theorem smul (h : IsFundamentalDomain G s μ) (g : G) : IsFundamentalDomain G (g • s) μ :=
h.image_of_equiv (MulAction.toPerm g) (measurePreserving_smul _ _).quasiMeasurePreserving
⟨fun g' => g⁻¹ * g' * g, fun g' => g * g' * g⁻¹, fun g' => by simp [mul_assoc], fun g' => by
simp [mul_assoc]⟩
fun g' x => by simp [smul_smul, mul_assoc]
#align measure_theory.is_fundamental_domain.smul MeasureTheory.IsFundamentalDomain.smul
#align measure_theory.is_add_fundamental_domain.vadd MeasureTheory.IsAddFundamentalDomain.vadd
variable [Countable G] {ν : Measure α}
@[to_additive]
theorem sum_restrict_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) :
(sum fun g : G => ν.restrict (g • s)) = ν := by
rw [← restrict_iUnion_ae (h.aedisjoint.mono fun i j h => hν h) fun g =>
(h.nullMeasurableSet_smul g).mono_ac hν,
restrict_congr_set (hν h.iUnion_smul_ae_eq), restrict_univ]
#align measure_theory.is_fundamental_domain.sum_restrict_of_ac MeasureTheory.IsFundamentalDomain.sum_restrict_of_ac
#align measure_theory.is_add_fundamental_domain.sum_restrict_of_ac MeasureTheory.IsAddFundamentalDomain.sum_restrict_of_ac
@[to_additive]
theorem lintegral_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂ν = ∑' g : G, ∫⁻ x in g • s, f x ∂ν := by
rw [← lintegral_sum_measure, h.sum_restrict_of_ac hν]
#align measure_theory.is_fundamental_domain.lintegral_eq_tsum_of_ac MeasureTheory.IsFundamentalDomain.lintegral_eq_tsum_of_ac
#align measure_theory.is_add_fundamental_domain.lintegral_eq_tsum_of_ac MeasureTheory.IsAddFundamentalDomain.lintegral_eq_tsum_of_ac
@[to_additive]
theorem sum_restrict (h : IsFundamentalDomain G s μ) : (sum fun g : G => μ.restrict (g • s)) = μ :=
h.sum_restrict_of_ac (refl _)
#align measure_theory.is_fundamental_domain.sum_restrict MeasureTheory.IsFundamentalDomain.sum_restrict
#align measure_theory.is_add_fundamental_domain.sum_restrict MeasureTheory.IsAddFundamentalDomain.sum_restrict
@[to_additive]
theorem lintegral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ :=
h.lintegral_eq_tsum_of_ac (refl _) f
#align measure_theory.is_fundamental_domain.lintegral_eq_tsum MeasureTheory.IsFundamentalDomain.lintegral_eq_tsum
#align measure_theory.is_add_fundamental_domain.lintegral_eq_tsum MeasureTheory.IsAddFundamentalDomain.lintegral_eq_tsum
@[to_additive]
theorem lintegral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in s, f (g⁻¹ • x) ∂μ :=
calc
∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ := h.lintegral_eq_tsum f
_ = ∑' g : G, ∫⁻ x in g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm
_ = ∑' g : G, ∫⁻ x in s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => Eq.symm <|
(measurePreserving_smul g⁻¹ μ).set_lintegral_comp_emb (measurableEmbedding_const_smul _) _ _
#align measure_theory.is_fundamental_domain.lintegral_eq_tsum' MeasureTheory.IsFundamentalDomain.lintegral_eq_tsum'
#align measure_theory.is_add_fundamental_domain.lintegral_eq_tsum' MeasureTheory.IsAddFundamentalDomain.lintegral_eq_tsum'
@[to_additive] lemma lintegral_eq_tsum'' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) :
∫⁻ x, f x ∂μ = ∑' g : G, ∫⁻ x in s, f (g • x) ∂μ :=
(lintegral_eq_tsum' h f).trans ((Equiv.inv G).tsum_eq (fun g ↦ ∫⁻ (x : α) in s, f (g • x) ∂μ))
@[to_additive]
theorem set_lintegral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) (t : Set α) :
∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ :=
calc
∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in g • s, f x ∂μ.restrict t :=
h.lintegral_eq_tsum_of_ac restrict_le_self.absolutelyContinuous _
_ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ := by simp only [h.restrict_restrict, inter_comm]
#align measure_theory.is_fundamental_domain.set_lintegral_eq_tsum MeasureTheory.IsFundamentalDomain.set_lintegral_eq_tsum
#align measure_theory.is_add_fundamental_domain.set_lintegral_eq_tsum MeasureTheory.IsAddFundamentalDomain.set_lintegral_eq_tsum
@[to_additive]
theorem set_lintegral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → ℝ≥0∞) (t : Set α) :
∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ :=
calc
∫⁻ x in t, f x ∂μ = ∑' g : G, ∫⁻ x in t ∩ g • s, f x ∂μ := h.set_lintegral_eq_tsum f t
_ = ∑' g : G, ∫⁻ x in t ∩ g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm
_ = ∑' g : G, ∫⁻ x in g⁻¹ • (g • t ∩ s), f x ∂μ := by simp only [smul_set_inter, inv_smul_smul]
_ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := tsum_congr fun g => Eq.symm <|
(measurePreserving_smul g⁻¹ μ).set_lintegral_comp_emb (measurableEmbedding_const_smul _) _ _
#align measure_theory.is_fundamental_domain.set_lintegral_eq_tsum' MeasureTheory.IsFundamentalDomain.set_lintegral_eq_tsum'
#align measure_theory.is_add_fundamental_domain.set_lintegral_eq_tsum' MeasureTheory.IsAddFundamentalDomain.set_lintegral_eq_tsum'
@[to_additive]
theorem measure_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (t : Set α) :
ν t = ∑' g : G, ν (t ∩ g • s) := by
have H : ν.restrict t ≪ μ := Measure.restrict_le_self.absolutelyContinuous.trans hν
simpa only [set_lintegral_one, Pi.one_def,
Measure.restrict_apply₀ ((h.nullMeasurableSet_smul _).mono_ac H), inter_comm] using
h.lintegral_eq_tsum_of_ac H 1
#align measure_theory.is_fundamental_domain.measure_eq_tsum_of_ac MeasureTheory.IsFundamentalDomain.measure_eq_tsum_of_ac
#align measure_theory.is_add_fundamental_domain.measure_eq_tsum_of_ac MeasureTheory.IsAddFundamentalDomain.measure_eq_tsum_of_ac
@[to_additive]
theorem measure_eq_tsum' (h : IsFundamentalDomain G s μ) (t : Set α) :
μ t = ∑' g : G, μ (t ∩ g • s) :=
h.measure_eq_tsum_of_ac AbsolutelyContinuous.rfl t
#align measure_theory.is_fundamental_domain.measure_eq_tsum' MeasureTheory.IsFundamentalDomain.measure_eq_tsum'
#align measure_theory.is_add_fundamental_domain.measure_eq_tsum' MeasureTheory.IsAddFundamentalDomain.measure_eq_tsum'
@[to_additive]
theorem measure_eq_tsum (h : IsFundamentalDomain G s μ) (t : Set α) :
μ t = ∑' g : G, μ (g • t ∩ s) := by
simpa only [set_lintegral_one] using h.set_lintegral_eq_tsum' (fun _ => 1) t
#align measure_theory.is_fundamental_domain.measure_eq_tsum MeasureTheory.IsFundamentalDomain.measure_eq_tsum
#align measure_theory.is_add_fundamental_domain.measure_eq_tsum MeasureTheory.IsAddFundamentalDomain.measure_eq_tsum
@[to_additive]
theorem measure_zero_of_invariant (h : IsFundamentalDomain G s μ) (t : Set α)
(ht : ∀ g : G, g • t = t) (hts : μ (t ∩ s) = 0) : μ t = 0 := by
rw [measure_eq_tsum h]; simp [ht, hts]
#align measure_theory.is_fundamental_domain.measure_zero_of_invariant MeasureTheory.IsFundamentalDomain.measure_zero_of_invariant
#align measure_theory.is_add_fundamental_domain.measure_zero_of_invariant MeasureTheory.IsAddFundamentalDomain.measure_zero_of_invariant
/-- Given a measure space with an action of a finite group `G`, the measure of any `G`-invariant set
is determined by the measure of its intersection with a fundamental domain for the action of `G`. -/
@[to_additive measure_eq_card_smul_of_vadd_ae_eq_self "Given a measure space with an action of a
finite additive group `G`, the measure of any `G`-invariant set is determined by the measure of
its intersection with a fundamental domain for the action of `G`."]
theorem measure_eq_card_smul_of_smul_ae_eq_self [Finite G] (h : IsFundamentalDomain G s μ)
(t : Set α) (ht : ∀ g : G, (g • t : Set α) =ᵐ[μ] t) : μ t = Nat.card G • μ (t ∩ s) := by
haveI : Fintype G := Fintype.ofFinite G
rw [h.measure_eq_tsum]
replace ht : ∀ g : G, (g • t ∩ s : Set α) =ᵐ[μ] (t ∩ s : Set α) := fun g =>
ae_eq_set_inter (ht g) (ae_eq_refl s)
simp_rw [measure_congr (ht _), tsum_fintype, Finset.sum_const, Nat.card_eq_fintype_card,
Finset.card_univ]
#align measure_theory.is_fundamental_domain.measure_eq_card_smul_of_smul_ae_eq_self MeasureTheory.IsFundamentalDomain.measure_eq_card_smul_of_smul_ae_eq_self
#align measure_theory.is_add_fundamental_domain.measure_eq_card_smul_of_vadd_ae_eq_self MeasureTheory.IsAddFundamentalDomain.measure_eq_card_smul_of_vadd_ae_eq_self
@[to_additive]
protected theorem set_lintegral_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ)
(f : α → ℝ≥0∞) (hf : ∀ (g : G) (x), f (g • x) = f x) :
∫⁻ x in s, f x ∂μ = ∫⁻ x in t, f x ∂μ :=
calc
∫⁻ x in s, f x ∂μ = ∑' g : G, ∫⁻ x in s ∩ g • t, f x ∂μ := ht.set_lintegral_eq_tsum _ _
_ = ∑' g : G, ∫⁻ x in g • t ∩ s, f (g⁻¹ • x) ∂μ := by simp only [hf, inter_comm]
_ = ∫⁻ x in t, f x ∂μ := (hs.set_lintegral_eq_tsum' _ _).symm
#align measure_theory.is_fundamental_domain.set_lintegral_eq MeasureTheory.IsFundamentalDomain.set_lintegral_eq
#align measure_theory.is_add_fundamental_domain.set_lintegral_eq MeasureTheory.IsAddFundamentalDomain.set_lintegral_eq
@[to_additive]
theorem measure_set_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) {A : Set α}
(hA₀ : MeasurableSet A) (hA : ∀ g : G, (fun x => g • x) ⁻¹' A = A) : μ (A ∩ s) = μ (A ∩ t) := by
have : ∫⁻ x in s, A.indicator 1 x ∂μ = ∫⁻ x in t, A.indicator 1 x ∂μ := by
refine hs.set_lintegral_eq ht (Set.indicator A fun _ => 1) fun g x ↦ ?_
convert (Set.indicator_comp_right (g • · : α → α) (g := fun _ ↦ (1 : ℝ≥0∞))).symm
rw [hA g]
simpa [Measure.restrict_apply hA₀, lintegral_indicator _ hA₀] using this
#align measure_theory.is_fundamental_domain.measure_set_eq MeasureTheory.IsFundamentalDomain.measure_set_eq
#align measure_theory.is_add_fundamental_domain.measure_set_eq MeasureTheory.IsAddFundamentalDomain.measure_set_eq
/-- If `s` and `t` are two fundamental domains of the same action, then their measures are equal. -/
@[to_additive "If `s` and `t` are two fundamental domains of the same action, then their measures
are equal."]
protected theorem measure_eq (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ) :
μ s = μ t := by
simpa only [set_lintegral_one] using hs.set_lintegral_eq ht (fun _ => 1) fun _ _ => rfl
#align measure_theory.is_fundamental_domain.measure_eq MeasureTheory.IsFundamentalDomain.measure_eq
#align measure_theory.is_add_fundamental_domain.measure_eq MeasureTheory.IsAddFundamentalDomain.measure_eq
@[to_additive]
protected theorem aEStronglyMeasurable_on_iff {β : Type*} [TopologicalSpace β]
[PseudoMetrizableSpace β] (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ)
{f : α → β} (hf : ∀ (g : G) (x), f (g • x) = f x) :
AEStronglyMeasurable f (μ.restrict s) ↔ AEStronglyMeasurable f (μ.restrict t) :=
calc
AEStronglyMeasurable f (μ.restrict s) ↔
AEStronglyMeasurable f (Measure.sum fun g : G => μ.restrict (g • t ∩ s)) := by
simp only [← ht.restrict_restrict,
ht.sum_restrict_of_ac restrict_le_self.absolutelyContinuous]
_ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g • (g⁻¹ • s ∩ t))) := by
simp only [smul_set_inter, inter_comm, smul_inv_smul, aestronglyMeasurable_sum_measure_iff]
_ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g⁻¹ • (g⁻¹⁻¹ • s ∩ t))) :=
inv_surjective.forall
_ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g⁻¹ • (g • s ∩ t))) := by simp only [inv_inv]
_ ↔ ∀ g : G, AEStronglyMeasurable f (μ.restrict (g • s ∩ t)) := by
refine forall_congr' fun g => ?_
have he : MeasurableEmbedding (g⁻¹ • · : α → α) := measurableEmbedding_const_smul _
rw [← image_smul, ← ((measurePreserving_smul g⁻¹ μ).restrict_image_emb he
_).aestronglyMeasurable_comp_iff he]
simp only [(· ∘ ·), hf]
_ ↔ AEStronglyMeasurable f (μ.restrict t) := by
simp only [← aestronglyMeasurable_sum_measure_iff, ← hs.restrict_restrict,
hs.sum_restrict_of_ac restrict_le_self.absolutelyContinuous]
#align measure_theory.is_fundamental_domain.ae_strongly_measurable_on_iff MeasureTheory.IsFundamentalDomain.aEStronglyMeasurable_on_iff
#align measure_theory.is_add_fundamental_domain.ae_strongly_measurable_on_iff MeasureTheory.IsAddFundamentalDomain.aEStronglyMeasurable_on_iff
@[to_additive]
protected theorem hasFiniteIntegral_on_iff (hs : IsFundamentalDomain G s μ)
(ht : IsFundamentalDomain G t μ) {f : α → E} (hf : ∀ (g : G) (x), f (g • x) = f x) :
HasFiniteIntegral f (μ.restrict s) ↔ HasFiniteIntegral f (μ.restrict t) := by
dsimp only [HasFiniteIntegral]
rw [hs.set_lintegral_eq ht]
intro g x; rw [hf]
#align measure_theory.is_fundamental_domain.has_finite_integral_on_iff MeasureTheory.IsFundamentalDomain.hasFiniteIntegral_on_iff
#align measure_theory.is_add_fundamental_domain.has_finite_integral_on_iff MeasureTheory.IsAddFundamentalDomain.hasFiniteIntegral_on_iff
@[to_additive]
protected theorem integrableOn_iff (hs : IsFundamentalDomain G s μ) (ht : IsFundamentalDomain G t μ)
{f : α → E} (hf : ∀ (g : G) (x), f (g • x) = f x) : IntegrableOn f s μ ↔ IntegrableOn f t μ :=
and_congr (hs.aEStronglyMeasurable_on_iff ht hf) (hs.hasFiniteIntegral_on_iff ht hf)
#align measure_theory.is_fundamental_domain.integrable_on_iff MeasureTheory.IsFundamentalDomain.integrableOn_iff
#align measure_theory.is_add_fundamental_domain.integrable_on_iff MeasureTheory.IsAddFundamentalDomain.integrableOn_iff
variable [NormedSpace ℝ E] [CompleteSpace E]
@[to_additive]
theorem integral_eq_tsum_of_ac (h : IsFundamentalDomain G s μ) (hν : ν ≪ μ) (f : α → E)
(hf : Integrable f ν) : ∫ x, f x ∂ν = ∑' g : G, ∫ x in g • s, f x ∂ν := by
rw [← MeasureTheory.integral_sum_measure, h.sum_restrict_of_ac hν]
rw [h.sum_restrict_of_ac hν]
exact hf
#align measure_theory.is_fundamental_domain.integral_eq_tsum_of_ac MeasureTheory.IsFundamentalDomain.integral_eq_tsum_of_ac
#align measure_theory.is_add_fundamental_domain.integral_eq_tsum_of_ac MeasureTheory.IsAddFundamentalDomain.integral_eq_tsum_of_ac
@[to_additive]
theorem integral_eq_tsum (h : IsFundamentalDomain G s μ) (f : α → E) (hf : Integrable f μ) :
∫ x, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ :=
integral_eq_tsum_of_ac h (by rfl) f hf
#align measure_theory.is_fundamental_domain.integral_eq_tsum MeasureTheory.IsFundamentalDomain.integral_eq_tsum
#align measure_theory.is_add_fundamental_domain.integral_eq_tsum MeasureTheory.IsAddFundamentalDomain.integral_eq_tsum
@[to_additive]
theorem integral_eq_tsum' (h : IsFundamentalDomain G s μ) (f : α → E) (hf : Integrable f μ) :
∫ x, f x ∂μ = ∑' g : G, ∫ x in s, f (g⁻¹ • x) ∂μ :=
calc
∫ x, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ := h.integral_eq_tsum f hf
_ = ∑' g : G, ∫ x in g⁻¹ • s, f x ∂μ := ((Equiv.inv G).tsum_eq _).symm
_ = ∑' g : G, ∫ x in s, f (g⁻¹ • x) ∂μ := tsum_congr fun g =>
(measurePreserving_smul g⁻¹ μ).setIntegral_image_emb (measurableEmbedding_const_smul _) _ _
#align measure_theory.is_fundamental_domain.integral_eq_tsum' MeasureTheory.IsFundamentalDomain.integral_eq_tsum'
#align measure_theory.is_add_fundamental_domain.integral_eq_tsum' MeasureTheory.IsAddFundamentalDomain.integral_eq_tsum'
@[to_additive] lemma integral_eq_tsum'' (h : IsFundamentalDomain G s μ)
(f : α → E) (hf : Integrable f μ) : ∫ x, f x ∂μ = ∑' g : G, ∫ x in s, f (g • x) ∂μ :=
(integral_eq_tsum' h f hf).trans ((Equiv.inv G).tsum_eq (fun g ↦ ∫ (x : α) in s, f (g • x) ∂μ))
@[to_additive]
| Mathlib/MeasureTheory/Group/FundamentalDomain.lean | 457 | 463 | theorem setIntegral_eq_tsum (h : IsFundamentalDomain G s μ) {f : α → E} {t : Set α}
(hf : IntegrableOn f t μ) : ∫ x in t, f x ∂μ = ∑' g : G, ∫ x in t ∩ g • s, f x ∂μ :=
calc
∫ x in t, f x ∂μ = ∑' g : G, ∫ x in g • s, f x ∂μ.restrict t :=
h.integral_eq_tsum_of_ac restrict_le_self.absolutelyContinuous f hf
_ = ∑' g : G, ∫ x in t ∩ g • s, f x ∂μ := by |
simp only [h.restrict_restrict, measure_smul, inter_comm]
|
/-
Copyright (c) 2015, 2017 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Robert Y. Lewis, Johannes Hölzl, Mario Carneiro, Sébastien Gouëzel
-/
import Mathlib.Topology.EMetricSpace.Basic
import Mathlib.Topology.Bornology.Constructions
import Mathlib.Data.Set.Pointwise.Interval
import Mathlib.Topology.Order.DenselyOrdered
/-!
## Pseudo-metric spaces
This file defines pseudo-metric spaces: these differ from metric spaces by not imposing the
condition `dist x y = 0 → x = y`.
Many definitions and theorems expected on (pseudo-)metric spaces are already introduced on uniform
spaces and topological spaces. For example: open and closed sets, compactness, completeness,
continuity and uniform continuity.
## Main definitions
* `Dist α`: Endows a space `α` with a function `dist a b`.
* `PseudoMetricSpace α`: A space endowed with a distance function, which can
be zero even if the two elements are non-equal.
* `Metric.ball x ε`: The set of all points `y` with `dist y x < ε`.
* `Metric.Bounded s`: Whether a subset of a `PseudoMetricSpace` is bounded.
* `MetricSpace α`: A `PseudoMetricSpace` with the guarantee `dist x y = 0 → x = y`.
Additional useful definitions:
* `nndist a b`: `dist` as a function to the non-negative reals.
* `Metric.closedBall x ε`: The set of all points `y` with `dist y x ≤ ε`.
* `Metric.sphere x ε`: The set of all points `y` with `dist y x = ε`.
TODO (anyone): Add "Main results" section.
## Tags
pseudo_metric, dist
-/
open Set Filter TopologicalSpace Bornology
open scoped ENNReal NNReal Uniformity Topology
universe u v w
variable {α : Type u} {β : Type v} {X ι : Type*}
theorem UniformSpace.ofDist_aux (ε : ℝ) (hε : 0 < ε) : ∃ δ > (0 : ℝ), ∀ x < δ, ∀ y < δ, x + y < ε :=
⟨ε / 2, half_pos hε, fun _x hx _y hy => add_halves ε ▸ add_lt_add hx hy⟩
/-- Construct a uniform structure from a distance function and metric space axioms -/
def UniformSpace.ofDist (dist : α → α → ℝ) (dist_self : ∀ x : α, dist x x = 0)
(dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : UniformSpace α :=
.ofFun dist dist_self dist_comm dist_triangle ofDist_aux
#align uniform_space_of_dist UniformSpace.ofDist
-- Porting note: dropped the `dist_self` argument
/-- Construct a bornology from a distance function and metric space axioms. -/
abbrev Bornology.ofDist {α : Type*} (dist : α → α → ℝ) (dist_comm : ∀ x y, dist x y = dist y x)
(dist_triangle : ∀ x y z, dist x z ≤ dist x y + dist y z) : Bornology α :=
Bornology.ofBounded { s : Set α | ∃ C, ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → dist x y ≤ C }
⟨0, fun x hx y => hx.elim⟩ (fun s ⟨c, hc⟩ t h => ⟨c, fun x hx y hy => hc (h hx) (h hy)⟩)
(fun s hs t ht => by
rcases s.eq_empty_or_nonempty with rfl | ⟨x, hx⟩
· rwa [empty_union]
rcases t.eq_empty_or_nonempty with rfl | ⟨y, hy⟩
· rwa [union_empty]
rsuffices ⟨C, hC⟩ : ∃ C, ∀ z ∈ s ∪ t, dist x z ≤ C
· refine ⟨C + C, fun a ha b hb => (dist_triangle a x b).trans ?_⟩
simpa only [dist_comm] using add_le_add (hC _ ha) (hC _ hb)
rcases hs with ⟨Cs, hs⟩; rcases ht with ⟨Ct, ht⟩
refine ⟨max Cs (dist x y + Ct), fun z hz => hz.elim
(fun hz => (hs hx hz).trans (le_max_left _ _))
(fun hz => (dist_triangle x y z).trans <|
(add_le_add le_rfl (ht hy hz)).trans (le_max_right _ _))⟩)
fun z => ⟨dist z z, forall_eq.2 <| forall_eq.2 le_rfl⟩
#align bornology.of_dist Bornology.ofDistₓ
/-- The distance function (given an ambient metric space on `α`), which returns
a nonnegative real number `dist x y` given `x y : α`. -/
@[ext]
class Dist (α : Type*) where
dist : α → α → ℝ
#align has_dist Dist
export Dist (dist)
-- the uniform structure and the emetric space structure are embedded in the metric space structure
-- to avoid instance diamond issues. See Note [forgetful inheritance].
/-- This is an internal lemma used inside the default of `PseudoMetricSpace.edist`. -/
private theorem dist_nonneg' {α} {x y : α} (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z) : 0 ≤ dist x y :=
have : 0 ≤ 2 * dist x y :=
calc 0 = dist x x := (dist_self _).symm
_ ≤ dist x y + dist y x := dist_triangle _ _ _
_ = 2 * dist x y := by rw [two_mul, dist_comm]
nonneg_of_mul_nonneg_right this two_pos
#noalign pseudo_metric_space.edist_dist_tac -- Porting note (#11215): TODO: restore
/-- Pseudo metric and Metric spaces
A pseudo metric space is endowed with a distance for which the requirement `d(x,y)=0 → x = y` might
not hold. A metric space is a pseudo metric space such that `d(x,y)=0 → x = y`.
Each pseudo metric space induces a canonical `UniformSpace` and hence a canonical
`TopologicalSpace` This is enforced in the type class definition, by extending the `UniformSpace`
structure. When instantiating a `PseudoMetricSpace` structure, the uniformity fields are not
necessary, they will be filled in by default. In the same way, each (pseudo) metric space induces a
(pseudo) emetric space structure. It is included in the structure, but filled in by default.
-/
class PseudoMetricSpace (α : Type u) extends Dist α : Type u where
dist_self : ∀ x : α, dist x x = 0
dist_comm : ∀ x y : α, dist x y = dist y x
dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z
edist : α → α → ℝ≥0∞ := fun x y => ENNReal.ofNNReal ⟨dist x y, dist_nonneg' _ ‹_› ‹_› ‹_›⟩
edist_dist : ∀ x y : α, edist x y = ENNReal.ofReal (dist x y)
-- Porting note (#11215): TODO: add := by _
toUniformSpace : UniformSpace α := .ofDist dist dist_self dist_comm dist_triangle
uniformity_dist : 𝓤 α = ⨅ ε > 0, 𝓟 { p : α × α | dist p.1 p.2 < ε } := by intros; rfl
toBornology : Bornology α := Bornology.ofDist dist dist_comm dist_triangle
cobounded_sets : (Bornology.cobounded α).sets =
{ s | ∃ C : ℝ, ∀ x ∈ sᶜ, ∀ y ∈ sᶜ, dist x y ≤ C } := by intros; rfl
#align pseudo_metric_space PseudoMetricSpace
/-- Two pseudo metric space structures with the same distance function coincide. -/
@[ext]
theorem PseudoMetricSpace.ext {α : Type*} {m m' : PseudoMetricSpace α}
(h : m.toDist = m'.toDist) : m = m' := by
cases' m with d _ _ _ ed hed U hU B hB
cases' m' with d' _ _ _ ed' hed' U' hU' B' hB'
obtain rfl : d = d' := h
congr
· ext x y : 2
rw [hed, hed']
· exact UniformSpace.ext (hU.trans hU'.symm)
· ext : 2
rw [← Filter.mem_sets, ← Filter.mem_sets, hB, hB']
#align pseudo_metric_space.ext PseudoMetricSpace.ext
variable [PseudoMetricSpace α]
attribute [instance] PseudoMetricSpace.toUniformSpace PseudoMetricSpace.toBornology
-- see Note [lower instance priority]
instance (priority := 200) PseudoMetricSpace.toEDist : EDist α :=
⟨PseudoMetricSpace.edist⟩
#align pseudo_metric_space.to_has_edist PseudoMetricSpace.toEDist
/-- Construct a pseudo-metric space structure whose underlying topological space structure
(definitionally) agrees which a pre-existing topology which is compatible with a given distance
function. -/
def PseudoMetricSpace.ofDistTopology {α : Type u} [TopologicalSpace α] (dist : α → α → ℝ)
(dist_self : ∀ x : α, dist x x = 0) (dist_comm : ∀ x y : α, dist x y = dist y x)
(dist_triangle : ∀ x y z : α, dist x z ≤ dist x y + dist y z)
(H : ∀ s : Set α, IsOpen s ↔ ∀ x ∈ s, ∃ ε > 0, ∀ y, dist x y < ε → y ∈ s) :
PseudoMetricSpace α :=
{ dist := dist
dist_self := dist_self
dist_comm := dist_comm
dist_triangle := dist_triangle
edist_dist := fun x y => by exact ENNReal.coe_nnreal_eq _
toUniformSpace :=
(UniformSpace.ofDist dist dist_self dist_comm dist_triangle).replaceTopology <|
TopologicalSpace.ext_iff.2 fun s ↦ (H s).trans <| forall₂_congr fun x _ ↦
((UniformSpace.hasBasis_ofFun (exists_gt (0 : ℝ)) dist dist_self dist_comm dist_triangle
UniformSpace.ofDist_aux).comap (Prod.mk x)).mem_iff.symm
uniformity_dist := rfl
toBornology := Bornology.ofDist dist dist_comm dist_triangle
cobounded_sets := rfl }
#align pseudo_metric_space.of_dist_topology PseudoMetricSpace.ofDistTopology
@[simp]
theorem dist_self (x : α) : dist x x = 0 :=
PseudoMetricSpace.dist_self x
#align dist_self dist_self
theorem dist_comm (x y : α) : dist x y = dist y x :=
PseudoMetricSpace.dist_comm x y
#align dist_comm dist_comm
theorem edist_dist (x y : α) : edist x y = ENNReal.ofReal (dist x y) :=
PseudoMetricSpace.edist_dist x y
#align edist_dist edist_dist
theorem dist_triangle (x y z : α) : dist x z ≤ dist x y + dist y z :=
PseudoMetricSpace.dist_triangle x y z
#align dist_triangle dist_triangle
theorem dist_triangle_left (x y z : α) : dist x y ≤ dist z x + dist z y := by
rw [dist_comm z]; apply dist_triangle
#align dist_triangle_left dist_triangle_left
theorem dist_triangle_right (x y z : α) : dist x y ≤ dist x z + dist y z := by
rw [dist_comm y]; apply dist_triangle
#align dist_triangle_right dist_triangle_right
theorem dist_triangle4 (x y z w : α) : dist x w ≤ dist x y + dist y z + dist z w :=
calc
dist x w ≤ dist x z + dist z w := dist_triangle x z w
_ ≤ dist x y + dist y z + dist z w := add_le_add_right (dist_triangle x y z) _
#align dist_triangle4 dist_triangle4
theorem dist_triangle4_left (x₁ y₁ x₂ y₂ : α) :
dist x₂ y₂ ≤ dist x₁ y₁ + (dist x₁ x₂ + dist y₁ y₂) := by
rw [add_left_comm, dist_comm x₁, ← add_assoc]
apply dist_triangle4
#align dist_triangle4_left dist_triangle4_left
theorem dist_triangle4_right (x₁ y₁ x₂ y₂ : α) :
dist x₁ y₁ ≤ dist x₁ x₂ + dist y₁ y₂ + dist x₂ y₂ := by
rw [add_right_comm, dist_comm y₁]
apply dist_triangle4
#align dist_triangle4_right dist_triangle4_right
/-- The triangle (polygon) inequality for sequences of points; `Finset.Ico` version. -/
theorem dist_le_Ico_sum_dist (f : ℕ → α) {m n} (h : m ≤ n) :
dist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, dist (f i) (f (i + 1)) := by
induction n, h using Nat.le_induction with
| base => rw [Finset.Ico_self, Finset.sum_empty, dist_self]
| succ n hle ihn =>
calc
dist (f m) (f (n + 1)) ≤ dist (f m) (f n) + dist (f n) (f (n + 1)) := dist_triangle _ _ _
_ ≤ (∑ i ∈ Finset.Ico m n, _) + _ := add_le_add ihn le_rfl
_ = ∑ i ∈ Finset.Ico m (n + 1), _ := by
{ rw [Nat.Ico_succ_right_eq_insert_Ico hle, Finset.sum_insert, add_comm]; simp }
#align dist_le_Ico_sum_dist dist_le_Ico_sum_dist
/-- The triangle (polygon) inequality for sequences of points; `Finset.range` version. -/
theorem dist_le_range_sum_dist (f : ℕ → α) (n : ℕ) :
dist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, dist (f i) (f (i + 1)) :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_dist f (Nat.zero_le n)
#align dist_le_range_sum_dist dist_le_range_sum_dist
/-- A version of `dist_le_Ico_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_Ico_sum_of_dist_le {f : ℕ → α} {m n} (hmn : m ≤ n) {d : ℕ → ℝ}
(hd : ∀ {k}, m ≤ k → k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f m) (f n) ≤ ∑ i ∈ Finset.Ico m n, d i :=
le_trans (dist_le_Ico_sum_dist f hmn) <|
Finset.sum_le_sum fun _k hk => hd (Finset.mem_Ico.1 hk).1 (Finset.mem_Ico.1 hk).2
#align dist_le_Ico_sum_of_dist_le dist_le_Ico_sum_of_dist_le
/-- A version of `dist_le_range_sum_dist` with each intermediate distance replaced
with an upper estimate. -/
theorem dist_le_range_sum_of_dist_le {f : ℕ → α} (n : ℕ) {d : ℕ → ℝ}
(hd : ∀ {k}, k < n → dist (f k) (f (k + 1)) ≤ d k) :
dist (f 0) (f n) ≤ ∑ i ∈ Finset.range n, d i :=
Nat.Ico_zero_eq_range ▸ dist_le_Ico_sum_of_dist_le (zero_le n) fun _ => hd
#align dist_le_range_sum_of_dist_le dist_le_range_sum_of_dist_le
theorem swap_dist : Function.swap (@dist α _) = dist := by funext x y; exact dist_comm _ _
#align swap_dist swap_dist
theorem abs_dist_sub_le (x y z : α) : |dist x z - dist y z| ≤ dist x y :=
abs_sub_le_iff.2
⟨sub_le_iff_le_add.2 (dist_triangle _ _ _), sub_le_iff_le_add.2 (dist_triangle_left _ _ _)⟩
#align abs_dist_sub_le abs_dist_sub_le
theorem dist_nonneg {x y : α} : 0 ≤ dist x y :=
dist_nonneg' dist dist_self dist_comm dist_triangle
#align dist_nonneg dist_nonneg
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension for the `positivity` tactic: distances are nonnegative. -/
@[positivity Dist.dist _ _]
def evalDist : PositivityExt where eval {u α} _zα _pα e := do
match u, α, e with
| 0, ~q(ℝ), ~q(@Dist.dist $β $inst $a $b) =>
let _inst ← synthInstanceQ q(PseudoMetricSpace $β)
assertInstancesCommute
pure (.nonnegative q(dist_nonneg))
| _, _, _ => throwError "not dist"
end Mathlib.Meta.Positivity
example {x y : α} : 0 ≤ dist x y := by positivity
@[simp] theorem abs_dist {a b : α} : |dist a b| = dist a b := abs_of_nonneg dist_nonneg
#align abs_dist abs_dist
/-- A version of `Dist` that takes value in `ℝ≥0`. -/
class NNDist (α : Type*) where
nndist : α → α → ℝ≥0
#align has_nndist NNDist
export NNDist (nndist)
-- see Note [lower instance priority]
/-- Distance as a nonnegative real number. -/
instance (priority := 100) PseudoMetricSpace.toNNDist : NNDist α :=
⟨fun a b => ⟨dist a b, dist_nonneg⟩⟩
#align pseudo_metric_space.to_has_nndist PseudoMetricSpace.toNNDist
/-- Express `dist` in terms of `nndist`-/
theorem dist_nndist (x y : α) : dist x y = nndist x y := rfl
#align dist_nndist dist_nndist
@[simp, norm_cast]
theorem coe_nndist (x y : α) : ↑(nndist x y) = dist x y := rfl
#align coe_nndist coe_nndist
/-- Express `edist` in terms of `nndist`-/
theorem edist_nndist (x y : α) : edist x y = nndist x y := by
rw [edist_dist, dist_nndist, ENNReal.ofReal_coe_nnreal]
#align edist_nndist edist_nndist
/-- Express `nndist` in terms of `edist`-/
theorem nndist_edist (x y : α) : nndist x y = (edist x y).toNNReal := by
simp [edist_nndist]
#align nndist_edist nndist_edist
@[simp, norm_cast]
theorem coe_nnreal_ennreal_nndist (x y : α) : ↑(nndist x y) = edist x y :=
(edist_nndist x y).symm
#align coe_nnreal_ennreal_nndist coe_nnreal_ennreal_nndist
@[simp, norm_cast]
theorem edist_lt_coe {x y : α} {c : ℝ≥0} : edist x y < c ↔ nndist x y < c := by
rw [edist_nndist, ENNReal.coe_lt_coe]
#align edist_lt_coe edist_lt_coe
@[simp, norm_cast]
theorem edist_le_coe {x y : α} {c : ℝ≥0} : edist x y ≤ c ↔ nndist x y ≤ c := by
rw [edist_nndist, ENNReal.coe_le_coe]
#align edist_le_coe edist_le_coe
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_lt_top {α : Type*} [PseudoMetricSpace α] (x y : α) : edist x y < ⊤ :=
(edist_dist x y).symm ▸ ENNReal.ofReal_lt_top
#align edist_lt_top edist_lt_top
/-- In a pseudometric space, the extended distance is always finite-/
theorem edist_ne_top (x y : α) : edist x y ≠ ⊤ :=
(edist_lt_top x y).ne
#align edist_ne_top edist_ne_top
/-- `nndist x x` vanishes-/
@[simp] theorem nndist_self (a : α) : nndist a a = 0 := NNReal.coe_eq_zero.1 (dist_self a)
#align nndist_self nndist_self
-- Porting note: `dist_nndist` and `coe_nndist` moved up
@[simp, norm_cast]
theorem dist_lt_coe {x y : α} {c : ℝ≥0} : dist x y < c ↔ nndist x y < c :=
Iff.rfl
#align dist_lt_coe dist_lt_coe
@[simp, norm_cast]
theorem dist_le_coe {x y : α} {c : ℝ≥0} : dist x y ≤ c ↔ nndist x y ≤ c :=
Iff.rfl
#align dist_le_coe dist_le_coe
@[simp]
theorem edist_lt_ofReal {x y : α} {r : ℝ} : edist x y < ENNReal.ofReal r ↔ dist x y < r := by
rw [edist_dist, ENNReal.ofReal_lt_ofReal_iff_of_nonneg dist_nonneg]
#align edist_lt_of_real edist_lt_ofReal
@[simp]
theorem edist_le_ofReal {x y : α} {r : ℝ} (hr : 0 ≤ r) :
edist x y ≤ ENNReal.ofReal r ↔ dist x y ≤ r := by
rw [edist_dist, ENNReal.ofReal_le_ofReal_iff hr]
#align edist_le_of_real edist_le_ofReal
/-- Express `nndist` in terms of `dist`-/
theorem nndist_dist (x y : α) : nndist x y = Real.toNNReal (dist x y) := by
rw [dist_nndist, Real.toNNReal_coe]
#align nndist_dist nndist_dist
theorem nndist_comm (x y : α) : nndist x y = nndist y x := NNReal.eq <| dist_comm x y
#align nndist_comm nndist_comm
/-- Triangle inequality for the nonnegative distance-/
theorem nndist_triangle (x y z : α) : nndist x z ≤ nndist x y + nndist y z :=
dist_triangle _ _ _
#align nndist_triangle nndist_triangle
theorem nndist_triangle_left (x y z : α) : nndist x y ≤ nndist z x + nndist z y :=
dist_triangle_left _ _ _
#align nndist_triangle_left nndist_triangle_left
theorem nndist_triangle_right (x y z : α) : nndist x y ≤ nndist x z + nndist y z :=
dist_triangle_right _ _ _
#align nndist_triangle_right nndist_triangle_right
/-- Express `dist` in terms of `edist`-/
theorem dist_edist (x y : α) : dist x y = (edist x y).toReal := by
rw [edist_dist, ENNReal.toReal_ofReal dist_nonneg]
#align dist_edist dist_edist
namespace Metric
-- instantiate pseudometric space as a topology
variable {x y z : α} {δ ε ε₁ ε₂ : ℝ} {s : Set α}
/-- `ball x ε` is the set of all points `y` with `dist y x < ε` -/
def ball (x : α) (ε : ℝ) : Set α :=
{ y | dist y x < ε }
#align metric.ball Metric.ball
@[simp]
theorem mem_ball : y ∈ ball x ε ↔ dist y x < ε :=
Iff.rfl
#align metric.mem_ball Metric.mem_ball
theorem mem_ball' : y ∈ ball x ε ↔ dist x y < ε := by rw [dist_comm, mem_ball]
#align metric.mem_ball' Metric.mem_ball'
theorem pos_of_mem_ball (hy : y ∈ ball x ε) : 0 < ε :=
dist_nonneg.trans_lt hy
#align metric.pos_of_mem_ball Metric.pos_of_mem_ball
| Mathlib/Topology/MetricSpace/PseudoMetric.lean | 418 | 419 | theorem mem_ball_self (h : 0 < ε) : x ∈ ball x ε := by |
rwa [mem_ball, dist_self]
|
/-
Copyright (c) 2018 Robert Y. Lewis. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Robert Y. Lewis
-/
import Mathlib.Algebra.Order.Field.Power
import Mathlib.NumberTheory.Padics.PadicVal
#align_import number_theory.padics.padic_norm from "leanprover-community/mathlib"@"92ca63f0fb391a9ca5f22d2409a6080e786d99f7"
/-!
# p-adic norm
This file defines the `p`-adic norm on `ℚ`.
The `p`-adic valuation on `ℚ` is the difference of the multiplicities of `p` in the numerator and
denominator of `q`. This function obeys the standard properties of a valuation, with the appropriate
assumptions on `p`.
The valuation induces a norm on `ℚ`. This norm is a nonarchimedean absolute value.
It takes values in {0} ∪ {1/p^k | k ∈ ℤ}.
## Implementation notes
Much, but not all, of this file assumes that `p` is prime. This assumption is inferred automatically
by taking `[Fact p.Prime]` as a type class argument.
## References
* [F. Q. Gouvêa, *p-adic numbers*][gouvea1997]
* [R. Y. Lewis, *A formal proof of Hensel's lemma over the p-adic integers*][lewis2019]
* <https://en.wikipedia.org/wiki/P-adic_number>
## Tags
p-adic, p adic, padic, norm, valuation
-/
/-- If `q ≠ 0`, the `p`-adic norm of a rational `q` is `p ^ (-padicValRat p q)`.
If `q = 0`, the `p`-adic norm of `q` is `0`. -/
def padicNorm (p : ℕ) (q : ℚ) : ℚ :=
if q = 0 then 0 else (p : ℚ) ^ (-padicValRat p q)
#align padic_norm padicNorm
namespace padicNorm
open padicValRat
variable {p : ℕ}
/-- Unfolds the definition of the `p`-adic norm of `q` when `q ≠ 0`. -/
@[simp]
protected theorem eq_zpow_of_nonzero {q : ℚ} (hq : q ≠ 0) :
padicNorm p q = (p : ℚ) ^ (-padicValRat p q) := by simp [hq, padicNorm]
#align padic_norm.eq_zpow_of_nonzero padicNorm.eq_zpow_of_nonzero
/-- The `p`-adic norm is nonnegative. -/
protected theorem nonneg (q : ℚ) : 0 ≤ padicNorm p q :=
if hq : q = 0 then by simp [hq, padicNorm]
else by
unfold padicNorm
split_ifs
apply zpow_nonneg
exact mod_cast Nat.zero_le _
#align padic_norm.nonneg padicNorm.nonneg
/-- The `p`-adic norm of `0` is `0`. -/
@[simp]
protected theorem zero : padicNorm p 0 = 0 := by simp [padicNorm]
#align padic_norm.zero padicNorm.zero
/-- The `p`-adic norm of `1` is `1`. -/
-- @[simp] -- Porting note (#10618): simp can prove this
protected theorem one : padicNorm p 1 = 1 := by simp [padicNorm]
#align padic_norm.one padicNorm.one
/-- The `p`-adic norm of `p` is `p⁻¹` if `p > 1`.
See also `padicNorm.padicNorm_p_of_prime` for a version assuming `p` is prime. -/
theorem padicNorm_p (hp : 1 < p) : padicNorm p p = (p : ℚ)⁻¹ := by
simp [padicNorm, (pos_of_gt hp).ne', padicValNat.self hp]
#align padic_norm.padic_norm_p padicNorm.padicNorm_p
/-- The `p`-adic norm of `p` is `p⁻¹` if `p` is prime.
See also `padicNorm.padicNorm_p` for a version assuming `1 < p`. -/
@[simp]
theorem padicNorm_p_of_prime [Fact p.Prime] : padicNorm p p = (p : ℚ)⁻¹ :=
padicNorm_p <| Nat.Prime.one_lt Fact.out
#align padic_norm.padic_norm_p_of_prime padicNorm.padicNorm_p_of_prime
/-- The `p`-adic norm of `q` is `1` if `q` is prime and not equal to `p`. -/
theorem padicNorm_of_prime_of_ne {q : ℕ} [p_prime : Fact p.Prime] [q_prime : Fact q.Prime]
(neq : p ≠ q) : padicNorm p q = 1 := by
have p : padicValRat p q = 0 := mod_cast padicValNat_primes neq
rw [padicNorm, p]
simp [q_prime.1.ne_zero]
#align padic_norm.padic_norm_of_prime_of_ne padicNorm.padicNorm_of_prime_of_ne
/-- The `p`-adic norm of `p` is less than `1` if `1 < p`.
See also `padicNorm.padicNorm_p_lt_one_of_prime` for a version assuming `p` is prime. -/
| Mathlib/NumberTheory/Padics/PadicNorm.lean | 104 | 106 | theorem padicNorm_p_lt_one (hp : 1 < p) : padicNorm p p < 1 := by |
rw [padicNorm_p hp, inv_lt_one_iff]
exact mod_cast Or.inr hp
|
/-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Localization.Integer
import Mathlib.RingTheory.Localization.Submodule
import Mathlib.RingTheory.Nilpotent.Lemmas
import Mathlib.RingTheory.RingHomProperties
import Mathlib.Data.Set.Subsingleton
#align_import ring_theory.local_properties from "leanprover-community/mathlib"@"a7c017d750512a352b623b1824d75da5998457d0"
/-!
# Local properties of commutative rings
In this file, we provide the proofs of various local properties.
## Naming Conventions
* `localization_P` : `P` holds for `S⁻¹R` if `P` holds for `R`.
* `P_of_localization_maximal` : `P` holds for `R` if `P` holds for `Rₘ` for all maximal `m`.
* `P_of_localization_prime` : `P` holds for `R` if `P` holds for `Rₘ` for all prime `m`.
* `P_ofLocalizationSpan` : `P` holds for `R` if given a spanning set `{fᵢ}`, `P` holds for all
`R_{fᵢ}`.
## Main results
The following properties are covered:
* The triviality of an ideal or an element:
`ideal_eq_bot_of_localization`, `eq_zero_of_localization`
* `isReduced` : `localization_isReduced`, `isReduced_of_localization_maximal`.
* `finite`: `localization_finite`, `finite_ofLocalizationSpan`
* `finiteType`: `localization_finiteType`, `finiteType_ofLocalizationSpan`
-/
open scoped Pointwise Classical
universe u
variable {R S : Type u} [CommRing R] [CommRing S] (M : Submonoid R)
variable (N : Submonoid S) (R' S' : Type u) [CommRing R'] [CommRing S'] (f : R →+* S)
variable [Algebra R R'] [Algebra S S']
section Properties
section CommRing
variable (P : ∀ (R : Type u) [CommRing R], Prop)
/-- A property `P` of comm rings is said to be preserved by localization
if `P` holds for `M⁻¹R` whenever `P` holds for `R`. -/
def LocalizationPreserves : Prop :=
∀ {R : Type u} [hR : CommRing R] (M : Submonoid R) (S : Type u) [hS : CommRing S] [Algebra R S]
[IsLocalization M S], @P R hR → @P S hS
#align localization_preserves LocalizationPreserves
/-- A property `P` of comm rings satisfies `OfLocalizationMaximal`
if `P` holds for `R` whenever `P` holds for `Rₘ` for all maximal ideal `m`. -/
def OfLocalizationMaximal : Prop :=
∀ (R : Type u) [CommRing R],
(∀ (J : Ideal R) (_ : J.IsMaximal), P (Localization.AtPrime J)) → P R
#align of_localization_maximal OfLocalizationMaximal
end CommRing
section RingHom
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S] (_ : R →+* S), Prop)
/-- A property `P` of ring homs is said to be preserved by localization
if `P` holds for `M⁻¹R →+* M⁻¹S` whenever `P` holds for `R →+* S`. -/
def RingHom.LocalizationPreserves :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (M : Submonoid R) (R' S' : Type u)
[CommRing R'] [CommRing S'] [Algebra R R'] [Algebra S S'] [IsLocalization M R']
[IsLocalization (M.map f) S'],
P f → P (IsLocalization.map S' f (Submonoid.le_comap_map M) : R' →+* S')
#align ring_hom.localization_preserves RingHom.LocalizationPreserves
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpan`
if `P` holds for `R →+* S` whenever there exists a finite set `{ r }` that spans `R` such that
`P` holds for `Rᵣ →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationSpan` via
`RingHom.ofLocalizationSpan_iff_finite`, but this is easier to prove. -/
def RingHom.OfLocalizationFiniteSpan :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Finset R)
(_ : Ideal.span (s : Set R) = ⊤) (_ : ∀ r : s, P (Localization.awayMap f r)), P f
#align ring_hom.of_localization_finite_span RingHom.OfLocalizationFiniteSpan
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpan`
if `P` holds for `R →+* S` whenever there exists a set `{ r }` that spans `R` such that
`P` holds for `Rᵣ →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationFiniteSpan` via
`RingHom.ofLocalizationSpan_iff_finite`, but this has less restrictions when applying. -/
def RingHom.OfLocalizationSpan :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Set R) (_ : Ideal.span s = ⊤)
(_ : ∀ r : s, P (Localization.awayMap f r)), P f
#align ring_hom.of_localization_span RingHom.OfLocalizationSpan
/-- A property `P` of ring homs satisfies `RingHom.HoldsForLocalizationAway`
if `P` holds for each localization map `R →+* Rᵣ`. -/
def RingHom.HoldsForLocalizationAway : Prop :=
∀ ⦃R : Type u⦄ (S : Type u) [CommRing R] [CommRing S] [Algebra R S] (r : R)
[IsLocalization.Away r S], P (algebraMap R S)
#align ring_hom.holds_for_localization_away RingHom.HoldsForLocalizationAway
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpanTarget`
if `P` holds for `R →+* S` whenever there exists a finite set `{ r }` that spans `S` such that
`P` holds for `R →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationSpanTarget` via
`RingHom.ofLocalizationSpanTarget_iff_finite`, but this is easier to prove. -/
def RingHom.OfLocalizationFiniteSpanTarget : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Finset S)
(_ : Ideal.span (s : Set S) = ⊤)
(_ : ∀ r : s, P ((algebraMap S (Localization.Away (r : S))).comp f)), P f
#align ring_hom.of_localization_finite_span_target RingHom.OfLocalizationFiniteSpanTarget
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationSpanTarget`
if `P` holds for `R →+* S` whenever there exists a set `{ r }` that spans `S` such that
`P` holds for `R →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationFiniteSpanTarget` via
`RingHom.ofLocalizationSpanTarget_iff_finite`, but this has less restrictions when applying. -/
def RingHom.OfLocalizationSpanTarget : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Set S) (_ : Ideal.span s = ⊤)
(_ : ∀ r : s, P ((algebraMap S (Localization.Away (r : S))).comp f)), P f
#align ring_hom.of_localization_span_target RingHom.OfLocalizationSpanTarget
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationPrime`
if `P` holds for `R` whenever `P` holds for `Rₘ` for all prime ideals `p`. -/
def RingHom.OfLocalizationPrime : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S),
(∀ (J : Ideal S) (_ : J.IsPrime), P (Localization.localRingHom _ J f rfl)) → P f
#align ring_hom.of_localization_prime RingHom.OfLocalizationPrime
/-- A property of ring homs is local if it is preserved by localizations and compositions, and for
each `{ r }` that spans `S`, we have `P (R →+* S) ↔ ∀ r, P (R →+* Sᵣ)`. -/
structure RingHom.PropertyIsLocal : Prop where
LocalizationPreserves : RingHom.LocalizationPreserves @P
OfLocalizationSpanTarget : RingHom.OfLocalizationSpanTarget @P
StableUnderComposition : RingHom.StableUnderComposition @P
HoldsForLocalizationAway : RingHom.HoldsForLocalizationAway @P
#align ring_hom.property_is_local RingHom.PropertyIsLocal
theorem RingHom.ofLocalizationSpan_iff_finite :
RingHom.OfLocalizationSpan @P ↔ RingHom.OfLocalizationFiniteSpan @P := by
delta RingHom.OfLocalizationSpan RingHom.OfLocalizationFiniteSpan
apply forall₅_congr
-- TODO: Using `refine` here breaks `resetI`.
intros
constructor
· intro h s; exact h s
· intro h s hs hs'
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
#align ring_hom.of_localization_span_iff_finite RingHom.ofLocalizationSpan_iff_finite
theorem RingHom.ofLocalizationSpanTarget_iff_finite :
RingHom.OfLocalizationSpanTarget @P ↔ RingHom.OfLocalizationFiniteSpanTarget @P := by
delta RingHom.OfLocalizationSpanTarget RingHom.OfLocalizationFiniteSpanTarget
apply forall₅_congr
-- TODO: Using `refine` here breaks `resetI`.
intros
constructor
· intro h s; exact h s
· intro h s hs hs'
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
#align ring_hom.of_localization_span_target_iff_finite RingHom.ofLocalizationSpanTarget_iff_finite
variable {P f R' S'}
theorem RingHom.PropertyIsLocal.respectsIso (hP : RingHom.PropertyIsLocal @P) :
RingHom.RespectsIso @P := by
apply hP.StableUnderComposition.respectsIso
introv
letI := e.toRingHom.toAlgebra
-- Porting note: was `apply_with hP.holds_for_localization_away { instances := ff }`
have : IsLocalization.Away (1 : R) S := by
apply IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.bijective
exact RingHom.PropertyIsLocal.HoldsForLocalizationAway hP S (1 : R)
#align ring_hom.property_is_local.respects_iso RingHom.PropertyIsLocal.respectsIso
-- Almost all arguments are implicit since this is not intended to use mid-proof.
theorem RingHom.LocalizationPreserves.away (H : RingHom.LocalizationPreserves @P) (r : R)
[IsLocalization.Away r R'] [IsLocalization.Away (f r) S'] (hf : P f) :
P (IsLocalization.Away.map R' S' f r) := by
have : IsLocalization ((Submonoid.powers r).map f) S' := by rw [Submonoid.map_powers]; assumption
exact H f (Submonoid.powers r) R' S' hf
#align ring_hom.localization_preserves.away RingHom.LocalizationPreserves.away
theorem RingHom.PropertyIsLocal.ofLocalizationSpan (hP : RingHom.PropertyIsLocal @P) :
RingHom.OfLocalizationSpan @P := by
introv R hs hs'
apply_fun Ideal.map f at hs
rw [Ideal.map_span, Ideal.map_top] at hs
apply hP.OfLocalizationSpanTarget _ _ hs
rintro ⟨_, r, hr, rfl⟩
convert hP.StableUnderComposition
_ _ (hP.HoldsForLocalizationAway (Localization.Away r) r) (hs' ⟨r, hr⟩) using 1
exact (IsLocalization.map_comp _).symm
#align ring_hom.property_is_local.of_localization_span RingHom.PropertyIsLocal.ofLocalizationSpan
lemma RingHom.OfLocalizationSpanTarget.ofIsLocalization
(hP : RingHom.OfLocalizationSpanTarget P) (hP' : RingHom.RespectsIso P)
{R S : Type u} [CommRing R] [CommRing S] (f : R →+* S) (s : Set S) (hs : Ideal.span s = ⊤)
(hT : ∀ r : s, ∃ (T : Type u) (_ : CommRing T) (_ : Algebra S T)
(_ : IsLocalization.Away (r : S) T), P ((algebraMap S T).comp f)) : P f := by
apply hP _ s hs
intros r
obtain ⟨T, _, _, _, hT⟩ := hT r
convert hP'.1 _
(Localization.algEquiv (R := S) (Submonoid.powers (r : S)) T).symm.toRingEquiv hT
rw [← RingHom.comp_assoc, RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
AlgEquiv.toRingEquiv_toRingHom, Localization.coe_algEquiv_symm, IsLocalization.map_comp,
RingHom.comp_id]
end RingHom
end Properties
section Ideal
open scoped nonZeroDivisors
/-- Let `I J : Ideal R`. If the localization of `I` at each maximal ideal `P` is included in
the localization of `J` at `P`, then `I ≤ J`. -/
theorem Ideal.le_of_localization_maximal {I J : Ideal R}
(h : ∀ (P : Ideal R) (hP : P.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime P)) I ≤
Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
I ≤ J := by
intro x hx
suffices J.colon (Ideal.span {x}) = ⊤ by
simpa using Submodule.mem_colon.mp
(show (1 : R) ∈ J.colon (Ideal.span {x}) from this.symm ▸ Submodule.mem_top) x
(Ideal.mem_span_singleton_self x)
refine Not.imp_symm (J.colon (Ideal.span {x})).exists_le_maximal ?_
push_neg
intro P hP le
obtain ⟨⟨⟨a, ha⟩, ⟨s, hs⟩⟩, eq⟩ :=
(IsLocalization.mem_map_algebraMap_iff P.primeCompl _).mp (h P hP (Ideal.mem_map_of_mem _ hx))
rw [← _root_.map_mul, ← sub_eq_zero, ← map_sub] at eq
obtain ⟨⟨m, hm⟩, eq⟩ := (IsLocalization.map_eq_zero_iff P.primeCompl _ _).mp eq
refine hs ((hP.isPrime.mem_or_mem (le (Ideal.mem_colon_singleton.mpr ?_))).resolve_right hm)
simp only [Subtype.coe_mk, mul_sub, sub_eq_zero, mul_comm x s, mul_left_comm] at eq
simpa only [mul_assoc, eq] using J.mul_mem_left m ha
#align ideal.le_of_localization_maximal Ideal.le_of_localization_maximal
/-- Let `I J : Ideal R`. If the localization of `I` at each maximal ideal `P` is equal to
the localization of `J` at `P`, then `I = J`. -/
theorem Ideal.eq_of_localization_maximal {I J : Ideal R}
(h : ∀ (P : Ideal R) (_ : P.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime P)) I =
Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
I = J :=
le_antisymm (Ideal.le_of_localization_maximal fun P hP => (h P hP).le)
(Ideal.le_of_localization_maximal fun P hP => (h P hP).ge)
#align ideal.eq_of_localization_maximal Ideal.eq_of_localization_maximal
/-- An ideal is trivial if its localization at every maximal ideal is trivial. -/
theorem ideal_eq_bot_of_localization' (I : Ideal R)
(h : ∀ (J : Ideal R) (hJ : J.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime J)) I = ⊥) :
I = ⊥ :=
Ideal.eq_of_localization_maximal fun P hP => by simpa using h P hP
#align ideal_eq_bot_of_localization' ideal_eq_bot_of_localization'
-- TODO: This proof should work for all modules, once we have enough material on submodules of
-- localized modules.
/-- An ideal is trivial if its localization at every maximal ideal is trivial. -/
theorem ideal_eq_bot_of_localization (I : Ideal R)
(h : ∀ (J : Ideal R) (hJ : J.IsMaximal),
IsLocalization.coeSubmodule (Localization.AtPrime J) I = ⊥) :
I = ⊥ :=
ideal_eq_bot_of_localization' _ fun P hP =>
(Ideal.map_eq_bot_iff_le_ker _).mpr fun x hx => by
rw [RingHom.mem_ker, ← Submodule.mem_bot R, ← h P hP, IsLocalization.mem_coeSubmodule]
exact ⟨x, hx, rfl⟩
#align ideal_eq_bot_of_localization ideal_eq_bot_of_localization
theorem eq_zero_of_localization (r : R)
(h : ∀ (J : Ideal R) (hJ : J.IsMaximal), algebraMap R (Localization.AtPrime J) r = 0) :
r = 0 := by
rw [← Ideal.span_singleton_eq_bot]
apply ideal_eq_bot_of_localization
intro J hJ
delta IsLocalization.coeSubmodule
erw [Submodule.map_span, Submodule.span_eq_bot]
rintro _ ⟨_, h', rfl⟩
cases Set.mem_singleton_iff.mpr h'
exact h J hJ
#align eq_zero_of_localization eq_zero_of_localization
end Ideal
section Reduced
| Mathlib/RingTheory/LocalProperties.lean | 307 | 324 | theorem localization_isReduced : LocalizationPreserves fun R hR => IsReduced R := by |
introv R _ _
constructor
rintro x ⟨_ | n, e⟩
· simpa using congr_arg (· * x) e
obtain ⟨⟨y, m⟩, hx⟩ := IsLocalization.surj M x
dsimp only at hx
let hx' := congr_arg (· ^ n.succ) hx
simp only [mul_pow, e, zero_mul, ← RingHom.map_pow] at hx'
rw [← (algebraMap R S).map_zero] at hx'
obtain ⟨m', hm'⟩ := (IsLocalization.eq_iff_exists M S).mp hx'
apply_fun (· * (m' : R) ^ n) at hm'
simp only [mul_assoc, zero_mul, mul_zero] at hm'
rw [← mul_left_comm, ← pow_succ', ← mul_pow] at hm'
replace hm' := IsNilpotent.eq_zero ⟨_, hm'.symm⟩
rw [← (IsLocalization.map_units S m).mul_left_inj, hx, zero_mul,
IsLocalization.map_eq_zero_iff M]
exact ⟨m', by rw [← hm', mul_comm]⟩
|
/-
Copyright (c) 2021 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov
-/
import Mathlib.MeasureTheory.Integral.IntervalIntegral
import Mathlib.Analysis.Calculus.Deriv.ZPow
import Mathlib.Analysis.NormedSpace.Pointwise
import Mathlib.Analysis.SpecialFunctions.NonIntegrable
import Mathlib.Analysis.Analytic.Basic
#align_import measure_theory.integral.circle_integral from "leanprover-community/mathlib"@"3bce8d800a6f2b8f63fe1e588fd76a9ff4adcebe"
/-!
# Integral over a circle in `ℂ`
In this file we define `∮ z in C(c, R), f z` to be the integral $\oint_{|z-c|=|R|} f(z)\,dz$ and
prove some properties of this integral. We give definition and prove most lemmas for a function
`f : ℂ → E`, where `E` is a complex Banach space. For this reason,
some lemmas use, e.g., `(z - c)⁻¹ • f z` instead of `f z / (z - c)`.
## Main definitions
* `circleMap c R`: the exponential map $θ ↦ c + R e^{θi}$;
* `CircleIntegrable f c R`: a function `f : ℂ → E` is integrable on the circle with center `c` and
radius `R` if `f ∘ circleMap c R` is integrable on `[0, 2π]`;
* `circleIntegral f c R`: the integral $\oint_{|z-c|=|R|} f(z)\,dz$, defined as
$\int_{0}^{2π}(c + Re^{θ i})' f(c+Re^{θ i})\,dθ$;
* `cauchyPowerSeries f c R`: the power series that is equal to
$\sum_{n=0}^{\infty} \oint_{|z-c|=R} \left(\frac{w-c}{z - c}\right)^n \frac{1}{z-c}f(z)\,dz$ at
`w - c`. The coefficients of this power series depend only on `f ∘ circleMap c R`, and the power
series converges to `f w` if `f` is differentiable on the closed ball `Metric.closedBall c R`
and `w` belongs to the corresponding open ball.
## Main statements
* `hasFPowerSeriesOn_cauchy_integral`: for any circle integrable function `f`, the power series
`cauchyPowerSeries f c R`, `R > 0`, converges to the Cauchy integral
`(2 * π * I : ℂ)⁻¹ • ∮ z in C(c, R), (z - w)⁻¹ • f z` on the open disc `Metric.ball c R`;
* `circleIntegral.integral_sub_zpow_of_undef`, `circleIntegral.integral_sub_zpow_of_ne`, and
`circleIntegral.integral_sub_inv_of_mem_ball`: formulas for `∮ z in C(c, R), (z - w) ^ n`,
`n : ℤ`. These lemmas cover the following cases:
- `circleIntegral.integral_sub_zpow_of_undef`, `n < 0` and `|w - c| = |R|`: in this case the
function is not integrable, so the integral is equal to its default value (zero);
- `circleIntegral.integral_sub_zpow_of_ne`, `n ≠ -1`: in the cases not covered by the previous
lemma, we have `(z - w) ^ n = ((z - w) ^ (n + 1) / (n + 1))'`, thus the integral equals zero;
- `circleIntegral.integral_sub_inv_of_mem_ball`, `n = -1`, `|w - c| < R`: in this case the
integral is equal to `2πi`.
The case `n = -1`, `|w -c| > R` is not covered by these lemmas. While it is possible to construct
an explicit primitive, it is easier to apply Cauchy theorem, so we postpone the proof till we have
this theorem (see #10000).
## Notation
- `∮ z in C(c, R), f z`: notation for the integral $\oint_{|z-c|=|R|} f(z)\,dz$, defined as
$\int_{0}^{2π}(c + Re^{θ i})' f(c+Re^{θ i})\,dθ$.
## Tags
integral, circle, Cauchy integral
-/
variable {E : Type*} [NormedAddCommGroup E]
noncomputable section
open scoped Real NNReal Interval Pointwise Topology
open Complex MeasureTheory TopologicalSpace Metric Function Set Filter Asymptotics
/-!
### `circleMap`, a parametrization of a circle
-/
/-- The exponential map $θ ↦ c + R e^{θi}$. The range of this map is the circle in `ℂ` with center
`c` and radius `|R|`. -/
def circleMap (c : ℂ) (R : ℝ) : ℝ → ℂ := fun θ => c + R * exp (θ * I)
#align circle_map circleMap
/-- `circleMap` is `2π`-periodic. -/
theorem periodic_circleMap (c : ℂ) (R : ℝ) : Periodic (circleMap c R) (2 * π) := fun θ => by
simp [circleMap, add_mul, exp_periodic _]
#align periodic_circle_map periodic_circleMap
theorem Set.Countable.preimage_circleMap {s : Set ℂ} (hs : s.Countable) (c : ℂ) {R : ℝ}
(hR : R ≠ 0) : (circleMap c R ⁻¹' s).Countable :=
show (((↑) : ℝ → ℂ) ⁻¹' ((· * I) ⁻¹'
(exp ⁻¹' ((R * ·) ⁻¹' ((c + ·) ⁻¹' s))))).Countable from
(((hs.preimage (add_right_injective _)).preimage <|
mul_right_injective₀ <| ofReal_ne_zero.2 hR).preimage_cexp.preimage <|
mul_left_injective₀ I_ne_zero).preimage ofReal_injective
#align set.countable.preimage_circle_map Set.Countable.preimage_circleMap
@[simp]
theorem circleMap_sub_center (c : ℂ) (R : ℝ) (θ : ℝ) : circleMap c R θ - c = circleMap 0 R θ := by
simp [circleMap]
#align circle_map_sub_center circleMap_sub_center
theorem circleMap_zero (R θ : ℝ) : circleMap 0 R θ = R * exp (θ * I) :=
zero_add _
#align circle_map_zero circleMap_zero
@[simp]
theorem abs_circleMap_zero (R : ℝ) (θ : ℝ) : abs (circleMap 0 R θ) = |R| := by simp [circleMap]
#align abs_circle_map_zero abs_circleMap_zero
| Mathlib/MeasureTheory/Integral/CircleIntegral.lean | 117 | 117 | theorem circleMap_mem_sphere' (c : ℂ) (R : ℝ) (θ : ℝ) : circleMap c R θ ∈ sphere c |R| := by | simp
|
/-
Copyright (c) 2021 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.GroupTheory.Subsemigroup.Center
#align_import group_theory.submonoid.center from "leanprover-community/mathlib"@"6cb77a8eaff0ddd100e87b1591c6d3ad319514ff"
/-!
# Centers of monoids
## Main definitions
* `Submonoid.center`: the center of a monoid
* `AddSubmonoid.center`: the center of an additive monoid
We provide `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in
other files.
-/
namespace Submonoid
section MulOneClass
variable (M : Type*) [MulOneClass M]
/-- The center of a multiplication with unit `M` is the set of elements that commute with everything
in `M` -/
@[to_additive
"The center of an addition with zero `M` is the set of elements that commute with everything
in `M`"]
def center : Submonoid M where
carrier := Set.center M
one_mem' := Set.one_mem_center M
mul_mem' := Set.mul_mem_center
#align submonoid.center Submonoid.center
#align add_submonoid.center AddSubmonoid.center
@[to_additive]
theorem coe_center : ↑(center M) = Set.center M :=
rfl
#align submonoid.coe_center Submonoid.coe_center
#align add_submonoid.coe_center AddSubmonoid.coe_center
@[to_additive (attr := simp) AddSubmonoid.center_toAddSubsemigroup]
theorem center_toSubsemigroup : (center M).toSubsemigroup = Subsemigroup.center M :=
rfl
#align submonoid.center_to_subsemigroup Submonoid.center_toSubsemigroup
variable {M}
/-- The center of a multiplication with unit is commutative and associative.
This is not an instance as it forms an non-defeq diamond with `Submonoid.toMonoid` in the `npow`
field. -/
@[to_additive "The center of an addition with zero is commutative and associative."]
abbrev center.commMonoid' : CommMonoid (center M) :=
{ (center M).toMulOneClass, Subsemigroup.center.commSemigroup with }
end MulOneClass
section Monoid
variable {M} [Monoid M]
/-- The center of a monoid is commutative. -/
@[to_additive]
instance center.commMonoid : CommMonoid (center M) :=
{ (center M).toMonoid, Subsemigroup.center.commSemigroup with }
-- no instance diamond, unlike the primed version
example : center.commMonoid.toMonoid = Submonoid.toMonoid (center M) := by
with_reducible_and_instances rfl
@[to_additive]
| Mathlib/GroupTheory/Submonoid/Center.lean | 79 | 81 | theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by |
rw [← Semigroup.mem_center_iff]
exact Iff.rfl
|
/-
Copyright (c) 2019 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Data.Finsupp.Encodable
import Mathlib.LinearAlgebra.Pi
import Mathlib.LinearAlgebra.Span
import Mathlib.Data.Set.Countable
#align_import linear_algebra.finsupp from "leanprover-community/mathlib"@"9d684a893c52e1d6692a504a118bfccbae04feeb"
/-!
# Properties of the module `α →₀ M`
Given an `R`-module `M`, the `R`-module structure on `α →₀ M` is defined in
`Data.Finsupp.Basic`.
In this file we define `Finsupp.supported s` to be the set `{f : α →₀ M | f.support ⊆ s}`
interpreted as a submodule of `α →₀ M`. We also define `LinearMap` versions of various maps:
* `Finsupp.lsingle a : M →ₗ[R] ι →₀ M`: `Finsupp.single a` as a linear map;
* `Finsupp.lapply a : (ι →₀ M) →ₗ[R] M`: the map `fun f ↦ f a` as a linear map;
* `Finsupp.lsubtypeDomain (s : Set α) : (α →₀ M) →ₗ[R] (s →₀ M)`: restriction to a subtype as a
linear map;
* `Finsupp.restrictDom`: `Finsupp.filter` as a linear map to `Finsupp.supported s`;
* `Finsupp.lsum`: `Finsupp.sum` or `Finsupp.liftAddHom` as a `LinearMap`;
* `Finsupp.total α M R (v : ι → M)`: sends `l : ι → R` to the linear combination of `v i` with
coefficients `l i`;
* `Finsupp.totalOn`: a restricted version of `Finsupp.total` with domain `Finsupp.supported R R s`
and codomain `Submodule.span R (v '' s)`;
* `Finsupp.supportedEquivFinsupp`: a linear equivalence between the functions `α →₀ M` supported
on `s` and the functions `s →₀ M`;
* `Finsupp.lmapDomain`: a linear map version of `Finsupp.mapDomain`;
* `Finsupp.domLCongr`: a `LinearEquiv` version of `Finsupp.domCongr`;
* `Finsupp.congr`: if the sets `s` and `t` are equivalent, then `supported M R s` is equivalent to
`supported M R t`;
* `Finsupp.lcongr`: a `LinearEquiv`alence between `α →₀ M` and `β →₀ N` constructed using
`e : α ≃ β` and `e' : M ≃ₗ[R] N`.
## Tags
function with finite support, module, linear algebra
-/
noncomputable section
open Set LinearMap Submodule
namespace Finsupp
section SMul
variable {α : Type*} {β : Type*} {R : Type*} {M : Type*} {M₂ : Type*}
theorem smul_sum [Zero β] [AddCommMonoid M] [DistribSMul R M] {v : α →₀ β} {c : R} {h : α → β → M} :
c • v.sum h = v.sum fun a b => c • h a b :=
Finset.smul_sum
#align finsupp.smul_sum Finsupp.smul_sum
@[simp]
theorem sum_smul_index_linearMap' [Semiring R] [AddCommMonoid M] [Module R M] [AddCommMonoid M₂]
[Module R M₂] {v : α →₀ M} {c : R} {h : α → M →ₗ[R] M₂} :
((c • v).sum fun a => h a) = c • v.sum fun a => h a := by
rw [Finsupp.sum_smul_index', Finsupp.smul_sum]
· simp only [map_smul]
· intro i
exact (h i).map_zero
#align finsupp.sum_smul_index_linear_map' Finsupp.sum_smul_index_linearMap'
end SMul
section LinearEquivFunOnFinite
variable (R : Type*) {S : Type*} (M : Type*) (α : Type*)
variable [Finite α] [AddCommMonoid M] [Semiring R] [Module R M]
/-- Given `Finite α`, `linearEquivFunOnFinite R` is the natural `R`-linear equivalence between
`α →₀ β` and `α → β`. -/
@[simps apply]
noncomputable def linearEquivFunOnFinite : (α →₀ M) ≃ₗ[R] α → M :=
{ equivFunOnFinite with
toFun := (⇑)
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
#align finsupp.linear_equiv_fun_on_finite Finsupp.linearEquivFunOnFinite
@[simp]
theorem linearEquivFunOnFinite_single [DecidableEq α] (x : α) (m : M) :
(linearEquivFunOnFinite R M α) (single x m) = Pi.single x m :=
equivFunOnFinite_single x m
#align finsupp.linear_equiv_fun_on_finite_single Finsupp.linearEquivFunOnFinite_single
@[simp]
theorem linearEquivFunOnFinite_symm_single [DecidableEq α] (x : α) (m : M) :
(linearEquivFunOnFinite R M α).symm (Pi.single x m) = single x m :=
equivFunOnFinite_symm_single x m
#align finsupp.linear_equiv_fun_on_finite_symm_single Finsupp.linearEquivFunOnFinite_symm_single
@[simp]
theorem linearEquivFunOnFinite_symm_coe (f : α →₀ M) : (linearEquivFunOnFinite R M α).symm f = f :=
(linearEquivFunOnFinite R M α).symm_apply_apply f
#align finsupp.linear_equiv_fun_on_finite_symm_coe Finsupp.linearEquivFunOnFinite_symm_coe
end LinearEquivFunOnFinite
section LinearEquiv.finsuppUnique
variable (R : Type*) {S : Type*} (M : Type*)
variable [AddCommMonoid M] [Semiring R] [Module R M]
variable (α : Type*) [Unique α]
/-- If `α` has a unique term, then the type of finitely supported functions `α →₀ M` is
`R`-linearly equivalent to `M`. -/
noncomputable def LinearEquiv.finsuppUnique : (α →₀ M) ≃ₗ[R] M :=
{ Finsupp.equivFunOnFinite.trans (Equiv.funUnique α M) with
map_add' := fun _ _ => rfl
map_smul' := fun _ _ => rfl }
#align finsupp.linear_equiv.finsupp_unique Finsupp.LinearEquiv.finsuppUnique
variable {R M}
@[simp]
theorem LinearEquiv.finsuppUnique_apply (f : α →₀ M) :
LinearEquiv.finsuppUnique R M α f = f default :=
rfl
#align finsupp.linear_equiv.finsupp_unique_apply Finsupp.LinearEquiv.finsuppUnique_apply
variable {α}
@[simp]
theorem LinearEquiv.finsuppUnique_symm_apply [Unique α] (m : M) :
(LinearEquiv.finsuppUnique R M α).symm m = Finsupp.single default m := by
ext; simp [LinearEquiv.finsuppUnique, Equiv.funUnique, single, Pi.single,
equivFunOnFinite, Function.update]
#align finsupp.linear_equiv.finsupp_unique_symm_apply Finsupp.LinearEquiv.finsuppUnique_symm_apply
end LinearEquiv.finsuppUnique
variable {α : Type*} {M : Type*} {N : Type*} {P : Type*} {R : Type*} {S : Type*}
variable [Semiring R] [Semiring S] [AddCommMonoid M] [Module R M]
variable [AddCommMonoid N] [Module R N]
variable [AddCommMonoid P] [Module R P]
/-- Interpret `Finsupp.single a` as a linear map. -/
def lsingle (a : α) : M →ₗ[R] α →₀ M :=
{ Finsupp.singleAddHom a with map_smul' := fun _ _ => (smul_single _ _ _).symm }
#align finsupp.lsingle Finsupp.lsingle
/-- Two `R`-linear maps from `Finsupp X M` which agree on each `single x y` agree everywhere. -/
theorem lhom_ext ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a b, φ (single a b) = ψ (single a b)) : φ = ψ :=
LinearMap.toAddMonoidHom_injective <| addHom_ext h
#align finsupp.lhom_ext Finsupp.lhom_ext
/-- Two `R`-linear maps from `Finsupp X M` which agree on each `single x y` agree everywhere.
We formulate this fact using equality of linear maps `φ.comp (lsingle a)` and `ψ.comp (lsingle a)`
so that the `ext` tactic can apply a type-specific extensionality lemma to prove equality of these
maps. E.g., if `M = R`, then it suffices to verify `φ (single a 1) = ψ (single a 1)`. -/
-- Porting note: The priority should be higher than `LinearMap.ext`.
@[ext high]
theorem lhom_ext' ⦃φ ψ : (α →₀ M) →ₗ[R] N⦄ (h : ∀ a, φ.comp (lsingle a) = ψ.comp (lsingle a)) :
φ = ψ :=
lhom_ext fun a => LinearMap.congr_fun (h a)
#align finsupp.lhom_ext' Finsupp.lhom_ext'
/-- Interpret `fun f : α →₀ M ↦ f a` as a linear map. -/
def lapply (a : α) : (α →₀ M) →ₗ[R] M :=
{ Finsupp.applyAddHom a with map_smul' := fun _ _ => rfl }
#align finsupp.lapply Finsupp.lapply
section CompatibleSMul
variable (R S M N ι : Type*)
variable [Semiring S] [AddCommMonoid M] [AddCommMonoid N] [Module S M] [Module S N]
instance _root_.LinearMap.CompatibleSMul.finsupp_dom [SMulZeroClass R M] [DistribSMul R N]
[LinearMap.CompatibleSMul M N R S] : LinearMap.CompatibleSMul (ι →₀ M) N R S where
map_smul f r m := by
conv_rhs => rw [← sum_single m, map_finsupp_sum, smul_sum]
erw [← sum_single (r • m), sum_mapRange_index single_zero, map_finsupp_sum]
congr; ext i m; exact (f.comp <| lsingle i).map_smul_of_tower r m
instance _root_.LinearMap.CompatibleSMul.finsupp_cod [SMul R M] [SMulZeroClass R N]
[LinearMap.CompatibleSMul M N R S] : LinearMap.CompatibleSMul M (ι →₀ N) R S where
map_smul f r m := by ext i; apply ((lapply i).comp f).map_smul_of_tower
end CompatibleSMul
/-- Forget that a function is finitely supported.
This is the linear version of `Finsupp.toFun`. -/
@[simps]
def lcoeFun : (α →₀ M) →ₗ[R] α → M where
toFun := (⇑)
map_add' x y := by
ext
simp
map_smul' x y := by
ext
simp
#align finsupp.lcoe_fun Finsupp.lcoeFun
section LSubtypeDomain
variable (s : Set α)
/-- Interpret `Finsupp.subtypeDomain s` as a linear map. -/
def lsubtypeDomain : (α →₀ M) →ₗ[R] s →₀ M where
toFun := subtypeDomain fun x => x ∈ s
map_add' _ _ := subtypeDomain_add
map_smul' _ _ := ext fun _ => rfl
#align finsupp.lsubtype_domain Finsupp.lsubtypeDomain
theorem lsubtypeDomain_apply (f : α →₀ M) :
(lsubtypeDomain s : (α →₀ M) →ₗ[R] s →₀ M) f = subtypeDomain (fun x => x ∈ s) f :=
rfl
#align finsupp.lsubtype_domain_apply Finsupp.lsubtypeDomain_apply
end LSubtypeDomain
@[simp]
theorem lsingle_apply (a : α) (b : M) : (lsingle a : M →ₗ[R] α →₀ M) b = single a b :=
rfl
#align finsupp.lsingle_apply Finsupp.lsingle_apply
@[simp]
theorem lapply_apply (a : α) (f : α →₀ M) : (lapply a : (α →₀ M) →ₗ[R] M) f = f a :=
rfl
#align finsupp.lapply_apply Finsupp.lapply_apply
@[simp]
theorem lapply_comp_lsingle_same (a : α) : lapply a ∘ₗ lsingle a = (.id : M →ₗ[R] M) := by ext; simp
@[simp]
theorem lapply_comp_lsingle_of_ne (a a' : α) (h : a ≠ a') :
lapply a ∘ₗ lsingle a' = (0 : M →ₗ[R] M) := by ext; simp [h.symm]
@[simp]
theorem ker_lsingle (a : α) : ker (lsingle a : M →ₗ[R] α →₀ M) = ⊥ :=
ker_eq_bot_of_injective (single_injective a)
#align finsupp.ker_lsingle Finsupp.ker_lsingle
theorem lsingle_range_le_ker_lapply (s t : Set α) (h : Disjoint s t) :
⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) ≤
⨅ a ∈ t, ker (lapply a : (α →₀ M) →ₗ[R] M) := by
refine iSup_le fun a₁ => iSup_le fun h₁ => range_le_iff_comap.2 ?_
simp only [(ker_comp _ _).symm, eq_top_iff, SetLike.le_def, mem_ker, comap_iInf, mem_iInf]
intro b _ a₂ h₂
have : a₁ ≠ a₂ := fun eq => h.le_bot ⟨h₁, eq.symm ▸ h₂⟩
exact single_eq_of_ne this
#align finsupp.lsingle_range_le_ker_lapply Finsupp.lsingle_range_le_ker_lapply
theorem iInf_ker_lapply_le_bot : ⨅ a, ker (lapply a : (α →₀ M) →ₗ[R] M) ≤ ⊥ := by
simp only [SetLike.le_def, mem_iInf, mem_ker, mem_bot, lapply_apply]
exact fun a h => Finsupp.ext h
#align finsupp.infi_ker_lapply_le_bot Finsupp.iInf_ker_lapply_le_bot
theorem iSup_lsingle_range : ⨆ a, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M) = ⊤ := by
refine eq_top_iff.2 <| SetLike.le_def.2 fun f _ => ?_
rw [← sum_single f]
exact sum_mem fun a _ => Submodule.mem_iSup_of_mem a ⟨_, rfl⟩
#align finsupp.supr_lsingle_range Finsupp.iSup_lsingle_range
theorem disjoint_lsingle_lsingle (s t : Set α) (hs : Disjoint s t) :
Disjoint (⨆ a ∈ s, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M))
(⨆ a ∈ t, LinearMap.range (lsingle a : M →ₗ[R] α →₀ M)) := by
-- Porting note: 2 placeholders are added to prevent timeout.
refine
(Disjoint.mono
(lsingle_range_le_ker_lapply s sᶜ ?_)
(lsingle_range_le_ker_lapply t tᶜ ?_))
?_
· apply disjoint_compl_right
· apply disjoint_compl_right
rw [disjoint_iff_inf_le]
refine le_trans (le_iInf fun i => ?_) iInf_ker_lapply_le_bot
classical
by_cases his : i ∈ s
· by_cases hit : i ∈ t
· exact (hs.le_bot ⟨his, hit⟩).elim
exact inf_le_of_right_le (iInf_le_of_le i <| iInf_le _ hit)
exact inf_le_of_left_le (iInf_le_of_le i <| iInf_le _ his)
#align finsupp.disjoint_lsingle_lsingle Finsupp.disjoint_lsingle_lsingle
theorem span_single_image (s : Set M) (a : α) :
Submodule.span R (single a '' s) = (Submodule.span R s).map (lsingle a : M →ₗ[R] α →₀ M) := by
rw [← span_image]; rfl
#align finsupp.span_single_image Finsupp.span_single_image
variable (M R)
/-- `Finsupp.supported M R s` is the `R`-submodule of all `p : α →₀ M` such that `p.support ⊆ s`. -/
def supported (s : Set α) : Submodule R (α →₀ M) where
carrier := { p | ↑p.support ⊆ s }
add_mem' {p q} hp hq := by
classical
refine Subset.trans (Subset.trans (Finset.coe_subset.2 support_add) ?_) (union_subset hp hq)
rw [Finset.coe_union]
zero_mem' := by
simp only [subset_def, Finset.mem_coe, Set.mem_setOf_eq, mem_support_iff, zero_apply]
intro h ha
exact (ha rfl).elim
smul_mem' a p hp := Subset.trans (Finset.coe_subset.2 support_smul) hp
#align finsupp.supported Finsupp.supported
variable {M}
theorem mem_supported {s : Set α} (p : α →₀ M) : p ∈ supported M R s ↔ ↑p.support ⊆ s :=
Iff.rfl
#align finsupp.mem_supported Finsupp.mem_supported
theorem mem_supported' {s : Set α} (p : α →₀ M) :
p ∈ supported M R s ↔ ∀ x ∉ s, p x = 0 := by
haveI := Classical.decPred fun x : α => x ∈ s; simp [mem_supported, Set.subset_def, not_imp_comm]
#align finsupp.mem_supported' Finsupp.mem_supported'
theorem mem_supported_support (p : α →₀ M) : p ∈ Finsupp.supported M R (p.support : Set α) := by
rw [Finsupp.mem_supported]
#align finsupp.mem_supported_support Finsupp.mem_supported_support
theorem single_mem_supported {s : Set α} {a : α} (b : M) (h : a ∈ s) :
single a b ∈ supported M R s :=
Set.Subset.trans support_single_subset (Finset.singleton_subset_set_iff.2 h)
#align finsupp.single_mem_supported Finsupp.single_mem_supported
theorem supported_eq_span_single (s : Set α) :
supported R R s = span R ((fun i => single i 1) '' s) := by
refine (span_eq_of_le _ ?_ (SetLike.le_def.2 fun l hl => ?_)).symm
· rintro _ ⟨_, hp, rfl⟩
exact single_mem_supported R 1 hp
· rw [← l.sum_single]
refine sum_mem fun i il => ?_
-- Porting note: Needed to help this convert quite a bit replacing underscores
convert smul_mem (M := α →₀ R) (x := single i 1) (span R ((fun i => single i 1) '' s)) (l i) ?_
· simp [span]
· apply subset_span
apply Set.mem_image_of_mem _ (hl il)
#align finsupp.supported_eq_span_single Finsupp.supported_eq_span_single
variable (M)
/-- Interpret `Finsupp.filter s` as a linear map from `α →₀ M` to `supported M R s`. -/
def restrictDom (s : Set α) [DecidablePred (· ∈ s)] : (α →₀ M) →ₗ[R] supported M R s :=
LinearMap.codRestrict _
{ toFun := filter (· ∈ s)
map_add' := fun _ _ => filter_add
map_smul' := fun _ _ => filter_smul } fun l =>
(mem_supported' _ _).2 fun _ => filter_apply_neg (· ∈ s) l
#align finsupp.restrict_dom Finsupp.restrictDom
variable {M R}
section
@[simp]
theorem restrictDom_apply (s : Set α) (l : α →₀ M) [DecidablePred (· ∈ s)]:
(restrictDom M R s l : α →₀ M) = Finsupp.filter (· ∈ s) l := rfl
#align finsupp.restrict_dom_apply Finsupp.restrictDom_apply
end
theorem restrictDom_comp_subtype (s : Set α) [DecidablePred (· ∈ s)] :
(restrictDom M R s).comp (Submodule.subtype _) = LinearMap.id := by
ext l a
by_cases h : a ∈ s <;> simp [h]
exact ((mem_supported' R l.1).1 l.2 a h).symm
#align finsupp.restrict_dom_comp_subtype Finsupp.restrictDom_comp_subtype
theorem range_restrictDom (s : Set α) [DecidablePred (· ∈ s)] :
LinearMap.range (restrictDom M R s) = ⊤ :=
range_eq_top.2 <|
Function.RightInverse.surjective <| LinearMap.congr_fun (restrictDom_comp_subtype s)
#align finsupp.range_restrict_dom Finsupp.range_restrictDom
theorem supported_mono {s t : Set α} (st : s ⊆ t) : supported M R s ≤ supported M R t := fun _ h =>
Set.Subset.trans h st
#align finsupp.supported_mono Finsupp.supported_mono
@[simp]
theorem supported_empty : supported M R (∅ : Set α) = ⊥ :=
eq_bot_iff.2 fun l h => (Submodule.mem_bot R).2 <| by ext; simp_all [mem_supported']
#align finsupp.supported_empty Finsupp.supported_empty
@[simp]
theorem supported_univ : supported M R (Set.univ : Set α) = ⊤ :=
eq_top_iff.2 fun _ _ => Set.subset_univ _
#align finsupp.supported_univ Finsupp.supported_univ
theorem supported_iUnion {δ : Type*} (s : δ → Set α) :
supported M R (⋃ i, s i) = ⨆ i, supported M R (s i) := by
refine le_antisymm ?_ (iSup_le fun i => supported_mono <| Set.subset_iUnion _ _)
haveI := Classical.decPred fun x => x ∈ ⋃ i, s i
suffices
LinearMap.range ((Submodule.subtype _).comp (restrictDom M R (⋃ i, s i))) ≤
⨆ i, supported M R (s i) by
rwa [LinearMap.range_comp, range_restrictDom, Submodule.map_top, range_subtype] at this
rw [range_le_iff_comap, eq_top_iff]
rintro l ⟨⟩
-- Porting note: Was ported as `induction l using Finsupp.induction`
refine Finsupp.induction l ?_ ?_
· exact zero_mem _
· refine fun x a l _ _ => add_mem ?_
by_cases h : ∃ i, x ∈ s i <;> simp [h]
cases' h with i hi
exact le_iSup (fun i => supported M R (s i)) i (single_mem_supported R _ hi)
#align finsupp.supported_Union Finsupp.supported_iUnion
theorem supported_union (s t : Set α) :
supported M R (s ∪ t) = supported M R s ⊔ supported M R t := by
erw [Set.union_eq_iUnion, supported_iUnion, iSup_bool_eq]; rfl
#align finsupp.supported_union Finsupp.supported_union
theorem supported_iInter {ι : Type*} (s : ι → Set α) :
supported M R (⋂ i, s i) = ⨅ i, supported M R (s i) :=
Submodule.ext fun x => by simp [mem_supported, subset_iInter_iff]
#align finsupp.supported_Inter Finsupp.supported_iInter
theorem supported_inter (s t : Set α) :
supported M R (s ∩ t) = supported M R s ⊓ supported M R t := by
rw [Set.inter_eq_iInter, supported_iInter, iInf_bool_eq]; rfl
#align finsupp.supported_inter Finsupp.supported_inter
theorem disjoint_supported_supported {s t : Set α} (h : Disjoint s t) :
Disjoint (supported M R s) (supported M R t) :=
disjoint_iff.2 <| by rw [← supported_inter, disjoint_iff_inter_eq_empty.1 h, supported_empty]
#align finsupp.disjoint_supported_supported Finsupp.disjoint_supported_supported
theorem disjoint_supported_supported_iff [Nontrivial M] {s t : Set α} :
Disjoint (supported M R s) (supported M R t) ↔ Disjoint s t := by
refine ⟨fun h => Set.disjoint_left.mpr fun x hx1 hx2 => ?_, disjoint_supported_supported⟩
rcases exists_ne (0 : M) with ⟨y, hy⟩
have := h.le_bot ⟨single_mem_supported R y hx1, single_mem_supported R y hx2⟩
rw [mem_bot, single_eq_zero] at this
exact hy this
#align finsupp.disjoint_supported_supported_iff Finsupp.disjoint_supported_supported_iff
/-- Interpret `Finsupp.restrictSupportEquiv` as a linear equivalence between
`supported M R s` and `s →₀ M`. -/
def supportedEquivFinsupp (s : Set α) : supported M R s ≃ₗ[R] s →₀ M := by
let F : supported M R s ≃ (s →₀ M) := restrictSupportEquiv s M
refine F.toLinearEquiv ?_
have :
(F : supported M R s → ↥s →₀ M) =
(lsubtypeDomain s : (α →₀ M) →ₗ[R] s →₀ M).comp (Submodule.subtype (supported M R s)) :=
rfl
rw [this]
exact LinearMap.isLinear _
#align finsupp.supported_equiv_finsupp Finsupp.supportedEquivFinsupp
section LSum
variable (S)
variable [Module S N] [SMulCommClass R S N]
/-- Lift a family of linear maps `M →ₗ[R] N` indexed by `x : α` to a linear map from `α →₀ M` to
`N` using `Finsupp.sum`. This is an upgraded version of `Finsupp.liftAddHom`.
See note [bundled maps over different rings] for why separate `R` and `S` semirings are used.
-/
def lsum : (α → M →ₗ[R] N) ≃ₗ[S] (α →₀ M) →ₗ[R] N where
toFun F :=
{ toFun := fun d => d.sum fun i => F i
map_add' := (liftAddHom (α := α) (M := M) (N := N) fun x => (F x).toAddMonoidHom).map_add
map_smul' := fun c f => by simp [sum_smul_index', smul_sum] }
invFun F x := F.comp (lsingle x)
left_inv F := by
ext x y
simp
right_inv F := by
ext x y
simp
map_add' F G := by
ext x y
simp
map_smul' F G := by
ext x y
simp
#align finsupp.lsum Finsupp.lsum
@[simp]
theorem coe_lsum (f : α → M →ₗ[R] N) : (lsum S f : (α →₀ M) → N) = fun d => d.sum fun i => f i :=
rfl
#align finsupp.coe_lsum Finsupp.coe_lsum
theorem lsum_apply (f : α → M →ₗ[R] N) (l : α →₀ M) : Finsupp.lsum S f l = l.sum fun b => f b :=
rfl
#align finsupp.lsum_apply Finsupp.lsum_apply
theorem lsum_single (f : α → M →ₗ[R] N) (i : α) (m : M) :
Finsupp.lsum S f (Finsupp.single i m) = f i m :=
Finsupp.sum_single_index (f i).map_zero
#align finsupp.lsum_single Finsupp.lsum_single
@[simp] theorem lsum_comp_lsingle (f : α → M →ₗ[R] N) (i : α) :
Finsupp.lsum S f ∘ₗ lsingle i = f i := by ext; simp
theorem lsum_symm_apply (f : (α →₀ M) →ₗ[R] N) (x : α) : (lsum S).symm f x = f.comp (lsingle x) :=
rfl
#align finsupp.lsum_symm_apply Finsupp.lsum_symm_apply
end LSum
section
variable (M) (R) (X : Type*) (S)
variable [Module S M] [SMulCommClass R S M]
/-- A slight rearrangement from `lsum` gives us
the bijection underlying the free-forgetful adjunction for R-modules.
-/
noncomputable def lift : (X → M) ≃+ ((X →₀ R) →ₗ[R] M) :=
(AddEquiv.arrowCongr (Equiv.refl X) (ringLmapEquivSelf R ℕ M).toAddEquiv.symm).trans
(lsum _ : _ ≃ₗ[ℕ] _).toAddEquiv
#align finsupp.lift Finsupp.lift
@[simp]
theorem lift_symm_apply (f) (x) : ((lift M R X).symm f) x = f (single x 1) :=
rfl
#align finsupp.lift_symm_apply Finsupp.lift_symm_apply
@[simp]
theorem lift_apply (f) (g) : ((lift M R X) f) g = g.sum fun x r => r • f x :=
rfl
#align finsupp.lift_apply Finsupp.lift_apply
/-- Given compatible `S` and `R`-module structures on `M` and a type `X`, the set of functions
`X → M` is `S`-linearly equivalent to the `R`-linear maps from the free `R`-module
on `X` to `M`. -/
noncomputable def llift : (X → M) ≃ₗ[S] (X →₀ R) →ₗ[R] M :=
{ lift M R X with
map_smul' := by
intros
dsimp
ext
simp only [coe_comp, Function.comp_apply, lsingle_apply, lift_apply, Pi.smul_apply,
sum_single_index, zero_smul, one_smul, LinearMap.smul_apply] }
#align finsupp.llift Finsupp.llift
@[simp]
theorem llift_apply (f : X → M) (x : X →₀ R) : llift M R S X f x = lift M R X f x :=
rfl
#align finsupp.llift_apply Finsupp.llift_apply
@[simp]
theorem llift_symm_apply (f : (X →₀ R) →ₗ[R] M) (x : X) :
(llift M R S X).symm f x = f (single x 1) :=
rfl
#align finsupp.llift_symm_apply Finsupp.llift_symm_apply
end
section LMapDomain
variable {α' : Type*} {α'' : Type*} (M R)
/-- Interpret `Finsupp.mapDomain` as a linear map. -/
def lmapDomain (f : α → α') : (α →₀ M) →ₗ[R] α' →₀ M where
toFun := mapDomain f
map_add' _ _ := mapDomain_add
map_smul' := mapDomain_smul
#align finsupp.lmap_domain Finsupp.lmapDomain
@[simp]
theorem lmapDomain_apply (f : α → α') (l : α →₀ M) :
(lmapDomain M R f : (α →₀ M) →ₗ[R] α' →₀ M) l = mapDomain f l :=
rfl
#align finsupp.lmap_domain_apply Finsupp.lmapDomain_apply
@[simp]
theorem lmapDomain_id : (lmapDomain M R _root_.id : (α →₀ M) →ₗ[R] α →₀ M) = LinearMap.id :=
LinearMap.ext fun _ => mapDomain_id
#align finsupp.lmap_domain_id Finsupp.lmapDomain_id
theorem lmapDomain_comp (f : α → α') (g : α' → α'') :
lmapDomain M R (g ∘ f) = (lmapDomain M R g).comp (lmapDomain M R f) :=
LinearMap.ext fun _ => mapDomain_comp
#align finsupp.lmap_domain_comp Finsupp.lmapDomain_comp
theorem supported_comap_lmapDomain (f : α → α') (s : Set α') :
supported M R (f ⁻¹' s) ≤ (supported M R s).comap (lmapDomain M R f) := by
classical
intro l (hl : (l.support : Set α) ⊆ f ⁻¹' s)
show ↑(mapDomain f l).support ⊆ s
rw [← Set.image_subset_iff, ← Finset.coe_image] at hl
exact Set.Subset.trans mapDomain_support hl
#align finsupp.supported_comap_lmap_domain Finsupp.supported_comap_lmapDomain
| Mathlib/LinearAlgebra/Finsupp.lean | 590 | 607 | theorem lmapDomain_supported (f : α → α') (s : Set α) :
(supported M R s).map (lmapDomain M R f) = supported M R (f '' s) := by |
classical
cases isEmpty_or_nonempty α
· simp [s.eq_empty_of_isEmpty]
refine
le_antisymm
(map_le_iff_le_comap.2 <|
le_trans (supported_mono <| Set.subset_preimage_image _ _)
(supported_comap_lmapDomain M R _ _))
?_
intro l hl
refine ⟨(lmapDomain M R (Function.invFunOn f s) : (α' →₀ M) →ₗ[R] α →₀ M) l, fun x hx => ?_, ?_⟩
· rcases Finset.mem_image.1 (mapDomain_support hx) with ⟨c, hc, rfl⟩
exact Function.invFunOn_mem (by simpa using hl hc)
· rw [← LinearMap.comp_apply, ← lmapDomain_comp]
refine (mapDomain_congr fun c hc => ?_).trans mapDomain_id
exact Function.invFunOn_eq (by simpa using hl hc)
|
/-
Copyright (c) 2019 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon
-/
import Mathlib.Control.Monad.Basic
import Mathlib.Control.Monad.Writer
import Mathlib.Init.Control.Lawful
#align_import control.monad.cont from "leanprover-community/mathlib"@"d6814c584384ddf2825ff038e868451a7c956f31"
/-!
# Continuation Monad
Monad encapsulating continuation passing programming style, similar to
Haskell's `Cont`, `ContT` and `MonadCont`:
<http://hackage.haskell.org/package/mtl-2.2.2/docs/Control-Monad-Cont.html>
-/
universe u v w u₀ u₁ v₀ v₁
structure MonadCont.Label (α : Type w) (m : Type u → Type v) (β : Type u) where
apply : α → m β
#align monad_cont.label MonadCont.Label
def MonadCont.goto {α β} {m : Type u → Type v} (f : MonadCont.Label α m β) (x : α) :=
f.apply x
#align monad_cont.goto MonadCont.goto
class MonadCont (m : Type u → Type v) where
callCC : ∀ {α β}, (MonadCont.Label α m β → m α) → m α
#align monad_cont MonadCont
open MonadCont
class LawfulMonadCont (m : Type u → Type v) [Monad m] [MonadCont m]
extends LawfulMonad m : Prop where
callCC_bind_right {α ω γ} (cmd : m α) (next : Label ω m γ → α → m ω) :
(callCC fun f => cmd >>= next f) = cmd >>= fun x => callCC fun f => next f x
callCC_bind_left {α} (β) (x : α) (dead : Label α m β → β → m α) :
(callCC fun f : Label α m β => goto f x >>= dead f) = pure x
callCC_dummy {α β} (dummy : m α) : (callCC fun _ : Label α m β => dummy) = dummy
#align is_lawful_monad_cont LawfulMonadCont
export LawfulMonadCont (callCC_bind_right callCC_bind_left callCC_dummy)
def ContT (r : Type u) (m : Type u → Type v) (α : Type w) :=
(α → m r) → m r
#align cont_t ContT
abbrev Cont (r : Type u) (α : Type w) :=
ContT r id α
#align cont Cont
namespace ContT
export MonadCont (Label goto)
variable {r : Type u} {m : Type u → Type v} {α β γ ω : Type w}
def run : ContT r m α → (α → m r) → m r :=
id
#align cont_t.run ContT.run
def map (f : m r → m r) (x : ContT r m α) : ContT r m α :=
f ∘ x
#align cont_t.map ContT.map
theorem run_contT_map_contT (f : m r → m r) (x : ContT r m α) : run (map f x) = f ∘ run x :=
rfl
#align cont_t.run_cont_t_map_cont_t ContT.run_contT_map_contT
def withContT (f : (β → m r) → α → m r) (x : ContT r m α) : ContT r m β := fun g => x <| f g
#align cont_t.with_cont_t ContT.withContT
theorem run_withContT (f : (β → m r) → α → m r) (x : ContT r m α) :
run (withContT f x) = run x ∘ f :=
rfl
#align cont_t.run_with_cont_t ContT.run_withContT
@[ext]
protected theorem ext {x y : ContT r m α} (h : ∀ f, x.run f = y.run f) : x = y := by
unfold ContT; ext; apply h
#align cont_t.ext ContT.ext
instance : Monad (ContT r m) where
pure x f := f x
bind x f g := x fun i => f i g
instance : LawfulMonad (ContT r m) := LawfulMonad.mk'
(id_map := by intros; rfl)
(pure_bind := by intros; ext; rfl)
(bind_assoc := by intros; ext; rfl)
def monadLift [Monad m] {α} : m α → ContT r m α := fun x f => x >>= f
#align cont_t.monad_lift ContT.monadLift
instance [Monad m] : MonadLift m (ContT r m) where
monadLift := ContT.monadLift
theorem monadLift_bind [Monad m] [LawfulMonad m] {α β} (x : m α) (f : α → m β) :
(monadLift (x >>= f) : ContT r m β) = monadLift x >>= monadLift ∘ f := by
ext
simp only [monadLift, MonadLift.monadLift, (· ∘ ·), (· >>= ·), bind_assoc, id, run,
ContT.monadLift]
#align cont_t.monad_lift_bind ContT.monadLift_bind
instance : MonadCont (ContT r m) where
callCC f g := f ⟨fun x _ => g x⟩ g
instance : LawfulMonadCont (ContT r m) where
callCC_bind_right := by intros; ext; rfl
callCC_bind_left := by intros; ext; rfl
callCC_dummy := by intros; ext; rfl
instance (ε) [MonadExcept ε m] : MonadExcept ε (ContT r m) where
throw e _ := throw e
tryCatch act h f := tryCatch (act f) fun e => h e f
end ContT
variable {m : Type u → Type v} [Monad m]
def ExceptT.mkLabel {α β ε} : Label (Except.{u, u} ε α) m β → Label α (ExceptT ε m) β
| ⟨f⟩ => ⟨fun a => monadLift <| f (Except.ok a)⟩
#align except_t.mk_label ExceptTₓ.mkLabel
theorem ExceptT.goto_mkLabel {α β ε : Type _} (x : Label (Except.{u, u} ε α) m β) (i : α) :
goto (ExceptT.mkLabel x) i = ExceptT.mk (Except.ok <$> goto x (Except.ok i)) := by
cases x; rfl
#align except_t.goto_mk_label ExceptTₓ.goto_mkLabel
nonrec def ExceptT.callCC {ε} [MonadCont m] {α β : Type _}
(f : Label α (ExceptT ε m) β → ExceptT ε m α) : ExceptT ε m α :=
ExceptT.mk (callCC fun x : Label _ m β => ExceptT.run <| f (ExceptT.mkLabel x))
#align except_t.call_cc ExceptTₓ.callCC
instance {ε} [MonadCont m] : MonadCont (ExceptT ε m) where
callCC := ExceptT.callCC
instance {ε} [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (ExceptT ε m) where
callCC_bind_right := by
intros; simp only [callCC, ExceptT.callCC, ExceptT.run_bind, callCC_bind_right]; ext
dsimp
congr with ⟨⟩ <;> simp [ExceptT.bindCont, @callCC_dummy m _]
callCC_bind_left := by
intros
simp only [callCC, ExceptT.callCC, ExceptT.goto_mkLabel, map_eq_bind_pure_comp, Function.comp,
ExceptT.run_bind, ExceptT.run_mk, bind_assoc, pure_bind, @callCC_bind_left m _]
ext; rfl
callCC_dummy := by intros; simp only [callCC, ExceptT.callCC, @callCC_dummy m _]; ext; rfl
def OptionT.mkLabel {α β} : Label (Option.{u} α) m β → Label α (OptionT m) β
| ⟨f⟩ => ⟨fun a => monadLift <| f (some a)⟩
#align option_t.mk_label OptionTₓ.mkLabel
theorem OptionT.goto_mkLabel {α β : Type _} (x : Label (Option.{u} α) m β) (i : α) :
goto (OptionT.mkLabel x) i = OptionT.mk (goto x (some i) >>= fun a => pure (some a)) :=
rfl
#align option_t.goto_mk_label OptionTₓ.goto_mkLabel
nonrec def OptionT.callCC [MonadCont m] {α β : Type _} (f : Label α (OptionT m) β → OptionT m α) :
OptionT m α :=
OptionT.mk (callCC fun x : Label _ m β => OptionT.run <| f (OptionT.mkLabel x) : m (Option α))
#align option_t.call_cc OptionTₓ.callCC
instance [MonadCont m] : MonadCont (OptionT m) where
callCC := OptionT.callCC
instance [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (OptionT m) where
callCC_bind_right := by
intros; simp only [callCC, OptionT.callCC, OptionT.run_bind, callCC_bind_right]; ext
dsimp
congr with ⟨⟩ <;> simp [@callCC_dummy m _]
callCC_bind_left := by
intros;
simp only [callCC, OptionT.callCC, OptionT.goto_mkLabel, OptionT.run_bind, OptionT.run_mk,
bind_assoc, pure_bind, @callCC_bind_left m _]
ext; rfl
callCC_dummy := by intros; simp only [callCC, OptionT.callCC, @callCC_dummy m _]; ext; rfl
/- Porting note: In Lean 3, `One ω` is required for `MonadLift (WriterT ω m)`. In Lean 4,
`EmptyCollection ω` or `Monoid ω` is required. So we give definitions for the both
instances. -/
def WriterT.mkLabel {α β ω} [EmptyCollection ω] : Label (α × ω) m β → Label α (WriterT ω m) β
| ⟨f⟩ => ⟨fun a => monadLift <| f (a, ∅)⟩
def WriterT.mkLabel' {α β ω} [Monoid ω] : Label (α × ω) m β → Label α (WriterT ω m) β
| ⟨f⟩ => ⟨fun a => monadLift <| f (a, 1)⟩
#align writer_t.mk_label WriterTₓ.mkLabel'
theorem WriterT.goto_mkLabel {α β ω : Type _} [EmptyCollection ω] (x : Label (α × ω) m β) (i : α) :
goto (WriterT.mkLabel x) i = monadLift (goto x (i, ∅)) := by cases x; rfl
theorem WriterT.goto_mkLabel' {α β ω : Type _} [Monoid ω] (x : Label (α × ω) m β) (i : α) :
goto (WriterT.mkLabel' x) i = monadLift (goto x (i, 1)) := by cases x; rfl
#align writer_t.goto_mk_label WriterTₓ.goto_mkLabel'
nonrec def WriterT.callCC [MonadCont m] {α β ω : Type _} [EmptyCollection ω]
(f : Label α (WriterT ω m) β → WriterT ω m α) : WriterT ω m α :=
WriterT.mk <| callCC (WriterT.run ∘ f ∘ WriterT.mkLabel : Label (α × ω) m β → m (α × ω))
def WriterT.callCC' [MonadCont m] {α β ω : Type _} [Monoid ω]
(f : Label α (WriterT ω m) β → WriterT ω m α) : WriterT ω m α :=
WriterT.mk <|
MonadCont.callCC (WriterT.run ∘ f ∘ WriterT.mkLabel' : Label (α × ω) m β → m (α × ω))
#align writer_t.call_cc WriterTₓ.callCC'
instance (ω) [Monad m] [EmptyCollection ω] [MonadCont m] : MonadCont (WriterT ω m) where
callCC := WriterT.callCC
instance (ω) [Monad m] [Monoid ω] [MonadCont m] : MonadCont (WriterT ω m) where
callCC := WriterT.callCC'
def StateT.mkLabel {α β σ : Type u} : Label (α × σ) m (β × σ) → Label α (StateT σ m) β
| ⟨f⟩ => ⟨fun a => StateT.mk (fun s => f (a, s))⟩
#align state_t.mk_label StateTₓ.mkLabel
theorem StateT.goto_mkLabel {α β σ : Type u} (x : Label (α × σ) m (β × σ)) (i : α) :
goto (StateT.mkLabel x) i = StateT.mk (fun s => goto x (i, s)) := by cases x; rfl
#align state_t.goto_mk_label StateTₓ.goto_mkLabel
nonrec def StateT.callCC {σ} [MonadCont m] {α β : Type _}
(f : Label α (StateT σ m) β → StateT σ m α) : StateT σ m α :=
StateT.mk (fun r => callCC fun f' => (f <| StateT.mkLabel f').run r)
#align state_t.call_cc StateTₓ.callCC
instance {σ} [MonadCont m] : MonadCont (StateT σ m) where
callCC := StateT.callCC
instance {σ} [MonadCont m] [LawfulMonadCont m] : LawfulMonadCont (StateT σ m) where
callCC_bind_right := by
intros
simp only [callCC, StateT.callCC, StateT.run_bind, callCC_bind_right]; ext; rfl
callCC_bind_left := by
intros;
simp only [callCC, StateT.callCC, StateT.goto_mkLabel, StateT.run_bind, StateT.run_mk,
callCC_bind_left]; ext; rfl
callCC_dummy := by
intros;
simp only [callCC, StateT.callCC, @callCC_dummy m _]
ext; rfl
def ReaderT.mkLabel {α β} (ρ) : Label α m β → Label α (ReaderT ρ m) β
| ⟨f⟩ => ⟨monadLift ∘ f⟩
#align reader_t.mk_label ReaderTₓ.mkLabel
| Mathlib/Control/Monad/Cont.lean | 249 | 250 | theorem ReaderT.goto_mkLabel {α ρ β} (x : Label α m β) (i : α) :
goto (ReaderT.mkLabel ρ x) i = monadLift (goto x i) := by | cases x; rfl
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.NullMeasurable
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.Topology.Algebra.Order.LiminfLimsup
#align_import measure_theory.measure.measure_space from "leanprover-community/mathlib"@"343e80208d29d2d15f8050b929aa50fe4ce71b55"
/-!
# Measure spaces
The definition of a measure and a measure space are in `MeasureTheory.MeasureSpaceDef`, with
only a few basic properties. This file provides many more properties of these objects.
This separation allows the measurability tactic to import only the file `MeasureSpaceDef`, and to
be available in `MeasureSpace` (through `MeasurableSpace`).
Given a measurable space `α`, a measure on `α` is a function that sends measurable sets to the
extended nonnegative reals that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is countably additive. This means that the measure of a countable union of pairwise disjoint
sets is equal to the measure of the individual sets.
Every measure can be canonically extended to an outer measure, so that it assigns values to
all subsets, not just the measurable subsets. On the other hand, a measure that is countably
additive on measurable sets can be restricted to measurable sets to obtain a measure.
In this file a measure is defined to be an outer measure that is countably additive on
measurable sets, with the additional assumption that the outer measure is the canonical
extension of the restricted measure.
Measures on `α` form a complete lattice, and are closed under scalar multiplication with `ℝ≥0∞`.
Given a measure, the null sets are the sets where `μ s = 0`, where `μ` denotes the corresponding
outer measure (so `s` might not be measurable). We can then define the completion of `μ` as the
measure on the least `σ`-algebra that also contains all null sets, by defining the measure to be `0`
on the null sets.
## Main statements
* `completion` is the completion of a measure to all null measurable sets.
* `Measure.ofMeasurable` and `OuterMeasure.toMeasure` are two important ways to define a measure.
## Implementation notes
Given `μ : Measure α`, `μ s` is the value of the *outer measure* applied to `s`.
This conveniently allows us to apply the measure to sets without proving that they are measurable.
We get countable subadditivity for all sets, but only countable additivity for measurable sets.
You often don't want to define a measure via its constructor.
Two ways that are sometimes more convenient:
* `Measure.ofMeasurable` is a way to define a measure by only giving its value on measurable sets
and proving the properties (1) and (2) mentioned above.
* `OuterMeasure.toMeasure` is a way of obtaining a measure from an outer measure by showing that
all measurable sets in the measurable space are Carathéodory measurable.
To prove that two measures are equal, there are multiple options:
* `ext`: two measures are equal if they are equal on all measurable sets.
* `ext_of_generateFrom_of_iUnion`: two measures are equal if they are equal on a π-system generating
the measurable sets, if the π-system contains a spanning increasing sequence of sets where the
measures take finite value (in particular the measures are σ-finite). This is a special case of
the more general `ext_of_generateFrom_of_cover`
* `ext_of_generate_finite`: two finite measures are equal if they are equal on a π-system
generating the measurable sets. This is a special case of `ext_of_generateFrom_of_iUnion` using
`C ∪ {univ}`, but is easier to work with.
A `MeasureSpace` is a class that is a measurable space with a canonical measure.
The measure is denoted `volume`.
## References
* <https://en.wikipedia.org/wiki/Measure_(mathematics)>
* <https://en.wikipedia.org/wiki/Complete_measure>
* <https://en.wikipedia.org/wiki/Almost_everywhere>
## Tags
measure, almost everywhere, measure space, completion, null set, null measurable set
-/
noncomputable section
open Set
open Filter hiding map
open Function MeasurableSpace
open scoped Classical symmDiff
open Topology Filter ENNReal NNReal Interval MeasureTheory
variable {α β γ δ ι R R' : Type*}
namespace MeasureTheory
section
variable {m : MeasurableSpace α} {μ μ₁ μ₂ : Measure α} {s s₁ s₂ t : Set α}
instance ae_isMeasurablyGenerated : IsMeasurablyGenerated (ae μ) :=
⟨fun _s hs =>
let ⟨t, hst, htm, htμ⟩ := exists_measurable_superset_of_null hs
⟨tᶜ, compl_mem_ae_iff.2 htμ, htm.compl, compl_subset_comm.1 hst⟩⟩
#align measure_theory.ae_is_measurably_generated MeasureTheory.ae_isMeasurablyGenerated
/-- See also `MeasureTheory.ae_restrict_uIoc_iff`. -/
theorem ae_uIoc_iff [LinearOrder α] {a b : α} {P : α → Prop} :
(∀ᵐ x ∂μ, x ∈ Ι a b → P x) ↔ (∀ᵐ x ∂μ, x ∈ Ioc a b → P x) ∧ ∀ᵐ x ∂μ, x ∈ Ioc b a → P x := by
simp only [uIoc_eq_union, mem_union, or_imp, eventually_and]
#align measure_theory.ae_uIoc_iff MeasureTheory.ae_uIoc_iff
theorem measure_union (hd : Disjoint s₁ s₂) (h : MeasurableSet s₂) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀ h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union MeasureTheory.measure_union
theorem measure_union' (hd : Disjoint s₁ s₂) (h : MeasurableSet s₁) : μ (s₁ ∪ s₂) = μ s₁ + μ s₂ :=
measure_union₀' h.nullMeasurableSet hd.aedisjoint
#align measure_theory.measure_union' MeasureTheory.measure_union'
theorem measure_inter_add_diff (s : Set α) (ht : MeasurableSet t) : μ (s ∩ t) + μ (s \ t) = μ s :=
measure_inter_add_diff₀ _ ht.nullMeasurableSet
#align measure_theory.measure_inter_add_diff MeasureTheory.measure_inter_add_diff
theorem measure_diff_add_inter (s : Set α) (ht : MeasurableSet t) : μ (s \ t) + μ (s ∩ t) = μ s :=
(add_comm _ _).trans (measure_inter_add_diff s ht)
#align measure_theory.measure_diff_add_inter MeasureTheory.measure_diff_add_inter
theorem measure_union_add_inter (s : Set α) (ht : MeasurableSet t) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [← measure_inter_add_diff (s ∪ t) ht, Set.union_inter_cancel_right, union_diff_right, ←
measure_inter_add_diff s ht]
ac_rfl
#align measure_theory.measure_union_add_inter MeasureTheory.measure_union_add_inter
theorem measure_union_add_inter' (hs : MeasurableSet s) (t : Set α) :
μ (s ∪ t) + μ (s ∩ t) = μ s + μ t := by
rw [union_comm, inter_comm, measure_union_add_inter t hs, add_comm]
#align measure_theory.measure_union_add_inter' MeasureTheory.measure_union_add_inter'
lemma measure_symmDiff_eq (hs : MeasurableSet s) (ht : MeasurableSet t) :
μ (s ∆ t) = μ (s \ t) + μ (t \ s) := by
simpa only [symmDiff_def, sup_eq_union] using measure_union disjoint_sdiff_sdiff (ht.diff hs)
lemma measure_symmDiff_le (s t u : Set α) :
μ (s ∆ u) ≤ μ (s ∆ t) + μ (t ∆ u) :=
le_trans (μ.mono <| symmDiff_triangle s t u) (measure_union_le (s ∆ t) (t ∆ u))
theorem measure_add_measure_compl (h : MeasurableSet s) : μ s + μ sᶜ = μ univ :=
measure_add_measure_compl₀ h.nullMeasurableSet
#align measure_theory.measure_add_measure_compl MeasureTheory.measure_add_measure_compl
theorem measure_biUnion₀ {s : Set β} {f : β → Set α} (hs : s.Countable)
(hd : s.Pairwise (AEDisjoint μ on f)) (h : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) := by
haveI := hs.toEncodable
rw [biUnion_eq_iUnion]
exact measure_iUnion₀ (hd.on_injective Subtype.coe_injective fun x => x.2) fun x => h x x.2
#align measure_theory.measure_bUnion₀ MeasureTheory.measure_biUnion₀
theorem measure_biUnion {s : Set β} {f : β → Set α} (hs : s.Countable) (hd : s.PairwiseDisjoint f)
(h : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑' p : s, μ (f p) :=
measure_biUnion₀ hs hd.aedisjoint fun b hb => (h b hb).nullMeasurableSet
#align measure_theory.measure_bUnion MeasureTheory.measure_biUnion
theorem measure_sUnion₀ {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise (AEDisjoint μ))
(h : ∀ s ∈ S, NullMeasurableSet s μ) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion₀ hs hd h]
#align measure_theory.measure_sUnion₀ MeasureTheory.measure_sUnion₀
theorem measure_sUnion {S : Set (Set α)} (hs : S.Countable) (hd : S.Pairwise Disjoint)
(h : ∀ s ∈ S, MeasurableSet s) : μ (⋃₀ S) = ∑' s : S, μ s := by
rw [sUnion_eq_biUnion, measure_biUnion hs hd h]
#align measure_theory.measure_sUnion MeasureTheory.measure_sUnion
theorem measure_biUnion_finset₀ {s : Finset ι} {f : ι → Set α}
(hd : Set.Pairwise (↑s) (AEDisjoint μ on f)) (hm : ∀ b ∈ s, NullMeasurableSet (f b) μ) :
μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) := by
rw [← Finset.sum_attach, Finset.attach_eq_univ, ← tsum_fintype]
exact measure_biUnion₀ s.countable_toSet hd hm
#align measure_theory.measure_bUnion_finset₀ MeasureTheory.measure_biUnion_finset₀
theorem measure_biUnion_finset {s : Finset ι} {f : ι → Set α} (hd : PairwiseDisjoint (↑s) f)
(hm : ∀ b ∈ s, MeasurableSet (f b)) : μ (⋃ b ∈ s, f b) = ∑ p ∈ s, μ (f p) :=
measure_biUnion_finset₀ hd.aedisjoint fun b hb => (hm b hb).nullMeasurableSet
#align measure_theory.measure_bUnion_finset MeasureTheory.measure_biUnion_finset
/-- The measure of an a.e. disjoint union (even uncountable) of null-measurable sets is at least
the sum of the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint₀ {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, NullMeasurableSet (As i) μ)
(As_disj : Pairwise (AEDisjoint μ on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) := by
rw [ENNReal.tsum_eq_iSup_sum, iSup_le_iff]
intro s
simp only [← measure_biUnion_finset₀ (fun _i _hi _j _hj hij => As_disj hij) fun i _ => As_mble i]
gcongr
exact iUnion_subset fun _ ↦ Subset.rfl
/-- The measure of a disjoint union (even uncountable) of measurable sets is at least the sum of
the measures of the sets. -/
theorem tsum_meas_le_meas_iUnion_of_disjoint {ι : Type*} [MeasurableSpace α] (μ : Measure α)
{As : ι → Set α} (As_mble : ∀ i : ι, MeasurableSet (As i))
(As_disj : Pairwise (Disjoint on As)) : (∑' i, μ (As i)) ≤ μ (⋃ i, As i) :=
tsum_meas_le_meas_iUnion_of_disjoint₀ μ (fun i ↦ (As_mble i).nullMeasurableSet)
(fun _ _ h ↦ Disjoint.aedisjoint (As_disj h))
#align measure_theory.tsum_meas_le_meas_Union_of_disjoint MeasureTheory.tsum_meas_le_meas_iUnion_of_disjoint
/-- If `s` is a countable set, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem tsum_measure_preimage_singleton {s : Set β} (hs : s.Countable) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑' b : s, μ (f ⁻¹' {↑b})) = μ (f ⁻¹' s) := by
rw [← Set.biUnion_preimage_singleton, measure_biUnion hs (pairwiseDisjoint_fiber f s) hf]
#align measure_theory.tsum_measure_preimage_singleton MeasureTheory.tsum_measure_preimage_singleton
lemma measure_preimage_eq_zero_iff_of_countable {s : Set β} {f : α → β} (hs : s.Countable) :
μ (f ⁻¹' s) = 0 ↔ ∀ x ∈ s, μ (f ⁻¹' {x}) = 0 := by
rw [← biUnion_preimage_singleton, measure_biUnion_null_iff hs]
/-- If `s` is a `Finset`, then the measure of its preimage can be found as the sum of measures
of the fibers `f ⁻¹' {y}`. -/
theorem sum_measure_preimage_singleton (s : Finset β) {f : α → β}
(hf : ∀ y ∈ s, MeasurableSet (f ⁻¹' {y})) : (∑ b ∈ s, μ (f ⁻¹' {b})) = μ (f ⁻¹' ↑s) := by
simp only [← measure_biUnion_finset (pairwiseDisjoint_fiber f s) hf,
Finset.set_biUnion_preimage_singleton]
#align measure_theory.sum_measure_preimage_singleton MeasureTheory.sum_measure_preimage_singleton
theorem measure_diff_null' (h : μ (s₁ ∩ s₂) = 0) : μ (s₁ \ s₂) = μ s₁ :=
measure_congr <| diff_ae_eq_self.2 h
#align measure_theory.measure_diff_null' MeasureTheory.measure_diff_null'
theorem measure_add_diff (hs : MeasurableSet s) (t : Set α) : μ s + μ (t \ s) = μ (s ∪ t) := by
rw [← measure_union' disjoint_sdiff_right hs, union_diff_self]
#align measure_theory.measure_add_diff MeasureTheory.measure_add_diff
theorem measure_diff' (s : Set α) (hm : MeasurableSet t) (h_fin : μ t ≠ ∞) :
μ (s \ t) = μ (s ∪ t) - μ t :=
Eq.symm <| ENNReal.sub_eq_of_add_eq h_fin <| by rw [add_comm, measure_add_diff hm, union_comm]
#align measure_theory.measure_diff' MeasureTheory.measure_diff'
theorem measure_diff (h : s₂ ⊆ s₁) (h₂ : MeasurableSet s₂) (h_fin : μ s₂ ≠ ∞) :
μ (s₁ \ s₂) = μ s₁ - μ s₂ := by rw [measure_diff' _ h₂ h_fin, union_eq_self_of_subset_right h]
#align measure_theory.measure_diff MeasureTheory.measure_diff
theorem le_measure_diff : μ s₁ - μ s₂ ≤ μ (s₁ \ s₂) :=
tsub_le_iff_left.2 <| (measure_le_inter_add_diff μ s₁ s₂).trans <| by
gcongr; apply inter_subset_right
#align measure_theory.le_measure_diff MeasureTheory.le_measure_diff
/-- If the measure of the symmetric difference of two sets is finite,
then one has infinite measure if and only if the other one does. -/
theorem measure_eq_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s = ∞ ↔ μ t = ∞ := by
suffices h : ∀ u v, μ (u ∆ v) ≠ ∞ → μ u = ∞ → μ v = ∞
from ⟨h s t hμst, h t s (symmDiff_comm s t ▸ hμst)⟩
intro u v hμuv hμu
by_contra! hμv
apply hμuv
rw [Set.symmDiff_def, eq_top_iff]
calc
∞ = μ u - μ v := (WithTop.sub_eq_top_iff.2 ⟨hμu, hμv⟩).symm
_ ≤ μ (u \ v) := le_measure_diff
_ ≤ μ (u \ v ∪ v \ u) := measure_mono subset_union_left
/-- If the measure of the symmetric difference of two sets is finite,
then one has finite measure if and only if the other one does. -/
theorem measure_ne_top_iff_of_symmDiff (hμst : μ (s ∆ t) ≠ ∞) : μ s ≠ ∞ ↔ μ t ≠ ∞ :=
(measure_eq_top_iff_of_symmDiff hμst).ne
theorem measure_diff_lt_of_lt_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞}
(h : μ t < μ s + ε) : μ (t \ s) < ε := by
rw [measure_diff hst hs hs']; rw [add_comm] at h
exact ENNReal.sub_lt_of_lt_add (measure_mono hst) h
#align measure_theory.measure_diff_lt_of_lt_add MeasureTheory.measure_diff_lt_of_lt_add
theorem measure_diff_le_iff_le_add (hs : MeasurableSet s) (hst : s ⊆ t) (hs' : μ s ≠ ∞) {ε : ℝ≥0∞} :
μ (t \ s) ≤ ε ↔ μ t ≤ μ s + ε := by rw [measure_diff hst hs hs', tsub_le_iff_left]
#align measure_theory.measure_diff_le_iff_le_add MeasureTheory.measure_diff_le_iff_le_add
theorem measure_eq_measure_of_null_diff {s t : Set α} (hst : s ⊆ t) (h_nulldiff : μ (t \ s) = 0) :
μ s = μ t := measure_congr <|
EventuallyLE.antisymm (HasSubset.Subset.eventuallyLE hst) (ae_le_set.mpr h_nulldiff)
#align measure_theory.measure_eq_measure_of_null_diff MeasureTheory.measure_eq_measure_of_null_diff
theorem measure_eq_measure_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂) (h23 : s₂ ⊆ s₃)
(h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ ∧ μ s₂ = μ s₃ := by
have le12 : μ s₁ ≤ μ s₂ := measure_mono h12
have le23 : μ s₂ ≤ μ s₃ := measure_mono h23
have key : μ s₃ ≤ μ s₁ :=
calc
μ s₃ = μ (s₃ \ s₁ ∪ s₁) := by rw [diff_union_of_subset (h12.trans h23)]
_ ≤ μ (s₃ \ s₁) + μ s₁ := measure_union_le _ _
_ = μ s₁ := by simp only [h_nulldiff, zero_add]
exact ⟨le12.antisymm (le23.trans key), le23.antisymm (key.trans le12)⟩
#align measure_theory.measure_eq_measure_of_between_null_diff MeasureTheory.measure_eq_measure_of_between_null_diff
theorem measure_eq_measure_smaller_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₁ = μ s₂ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).1
#align measure_theory.measure_eq_measure_smaller_of_between_null_diff MeasureTheory.measure_eq_measure_smaller_of_between_null_diff
theorem measure_eq_measure_larger_of_between_null_diff {s₁ s₂ s₃ : Set α} (h12 : s₁ ⊆ s₂)
(h23 : s₂ ⊆ s₃) (h_nulldiff : μ (s₃ \ s₁) = 0) : μ s₂ = μ s₃ :=
(measure_eq_measure_of_between_null_diff h12 h23 h_nulldiff).2
#align measure_theory.measure_eq_measure_larger_of_between_null_diff MeasureTheory.measure_eq_measure_larger_of_between_null_diff
lemma measure_compl₀ (h : NullMeasurableSet s μ) (hs : μ s ≠ ∞) :
μ sᶜ = μ Set.univ - μ s := by
rw [← measure_add_measure_compl₀ h, ENNReal.add_sub_cancel_left hs]
theorem measure_compl (h₁ : MeasurableSet s) (h_fin : μ s ≠ ∞) : μ sᶜ = μ univ - μ s :=
measure_compl₀ h₁.nullMeasurableSet h_fin
#align measure_theory.measure_compl MeasureTheory.measure_compl
lemma measure_inter_conull' (ht : μ (s \ t) = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null']; rwa [← diff_eq]
lemma measure_inter_conull (ht : μ tᶜ = 0) : μ (s ∩ t) = μ s := by
rw [← diff_compl, measure_diff_null ht]
@[simp]
theorem union_ae_eq_left_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] s ↔ t ≤ᵐ[μ] s := by
rw [ae_le_set]
refine
⟨fun h => by simpa only [union_diff_left] using (ae_eq_set.mp h).1, fun h =>
eventuallyLE_antisymm_iff.mpr
⟨by rwa [ae_le_set, union_diff_left],
HasSubset.Subset.eventuallyLE subset_union_left⟩⟩
#align measure_theory.union_ae_eq_left_iff_ae_subset MeasureTheory.union_ae_eq_left_iff_ae_subset
@[simp]
theorem union_ae_eq_right_iff_ae_subset : (s ∪ t : Set α) =ᵐ[μ] t ↔ s ≤ᵐ[μ] t := by
rw [union_comm, union_ae_eq_left_iff_ae_subset]
#align measure_theory.union_ae_eq_right_iff_ae_subset MeasureTheory.union_ae_eq_right_iff_ae_subset
theorem ae_eq_of_ae_subset_of_measure_ge (h₁ : s ≤ᵐ[μ] t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t := by
refine eventuallyLE_antisymm_iff.mpr ⟨h₁, ae_le_set.mpr ?_⟩
replace h₂ : μ t = μ s := h₂.antisymm (measure_mono_ae h₁)
replace ht : μ s ≠ ∞ := h₂ ▸ ht
rw [measure_diff' t hsm ht, measure_congr (union_ae_eq_left_iff_ae_subset.mpr h₁), h₂, tsub_self]
#align measure_theory.ae_eq_of_ae_subset_of_measure_ge MeasureTheory.ae_eq_of_ae_subset_of_measure_ge
/-- If `s ⊆ t`, `μ t ≤ μ s`, `μ t ≠ ∞`, and `s` is measurable, then `s =ᵐ[μ] t`. -/
theorem ae_eq_of_subset_of_measure_ge (h₁ : s ⊆ t) (h₂ : μ t ≤ μ s) (hsm : MeasurableSet s)
(ht : μ t ≠ ∞) : s =ᵐ[μ] t :=
ae_eq_of_ae_subset_of_measure_ge (HasSubset.Subset.eventuallyLE h₁) h₂ hsm ht
#align measure_theory.ae_eq_of_subset_of_measure_ge MeasureTheory.ae_eq_of_subset_of_measure_ge
theorem measure_iUnion_congr_of_subset [Countable β] {s : β → Set α} {t : β → Set α}
(hsub : ∀ b, s b ⊆ t b) (h_le : ∀ b, μ (t b) ≤ μ (s b)) : μ (⋃ b, s b) = μ (⋃ b, t b) := by
rcases Classical.em (∃ b, μ (t b) = ∞) with (⟨b, hb⟩ | htop)
· calc
μ (⋃ b, s b) = ∞ := top_unique (hb ▸ (h_le b).trans <| measure_mono <| subset_iUnion _ _)
_ = μ (⋃ b, t b) := Eq.symm <| top_unique <| hb ▸ measure_mono (subset_iUnion _ _)
push_neg at htop
refine le_antisymm (measure_mono (iUnion_mono hsub)) ?_
set M := toMeasurable μ
have H : ∀ b, (M (t b) ∩ M (⋃ b, s b) : Set α) =ᵐ[μ] M (t b) := by
refine fun b => ae_eq_of_subset_of_measure_ge inter_subset_left ?_ ?_ ?_
· calc
μ (M (t b)) = μ (t b) := measure_toMeasurable _
_ ≤ μ (s b) := h_le b
_ ≤ μ (M (t b) ∩ M (⋃ b, s b)) :=
measure_mono <|
subset_inter ((hsub b).trans <| subset_toMeasurable _ _)
((subset_iUnion _ _).trans <| subset_toMeasurable _ _)
· exact (measurableSet_toMeasurable _ _).inter (measurableSet_toMeasurable _ _)
· rw [measure_toMeasurable]
exact htop b
calc
μ (⋃ b, t b) ≤ μ (⋃ b, M (t b)) := measure_mono (iUnion_mono fun b => subset_toMeasurable _ _)
_ = μ (⋃ b, M (t b) ∩ M (⋃ b, s b)) := measure_congr (EventuallyEq.countable_iUnion H).symm
_ ≤ μ (M (⋃ b, s b)) := measure_mono (iUnion_subset fun b => inter_subset_right)
_ = μ (⋃ b, s b) := measure_toMeasurable _
#align measure_theory.measure_Union_congr_of_subset MeasureTheory.measure_iUnion_congr_of_subset
theorem measure_union_congr_of_subset {t₁ t₂ : Set α} (hs : s₁ ⊆ s₂) (hsμ : μ s₂ ≤ μ s₁)
(ht : t₁ ⊆ t₂) (htμ : μ t₂ ≤ μ t₁) : μ (s₁ ∪ t₁) = μ (s₂ ∪ t₂) := by
rw [union_eq_iUnion, union_eq_iUnion]
exact measure_iUnion_congr_of_subset (Bool.forall_bool.2 ⟨ht, hs⟩) (Bool.forall_bool.2 ⟨htμ, hsμ⟩)
#align measure_theory.measure_union_congr_of_subset MeasureTheory.measure_union_congr_of_subset
@[simp]
theorem measure_iUnion_toMeasurable [Countable β] (s : β → Set α) :
μ (⋃ b, toMeasurable μ (s b)) = μ (⋃ b, s b) :=
Eq.symm <|
measure_iUnion_congr_of_subset (fun _b => subset_toMeasurable _ _) fun _b =>
(measure_toMeasurable _).le
#align measure_theory.measure_Union_to_measurable MeasureTheory.measure_iUnion_toMeasurable
theorem measure_biUnion_toMeasurable {I : Set β} (hc : I.Countable) (s : β → Set α) :
μ (⋃ b ∈ I, toMeasurable μ (s b)) = μ (⋃ b ∈ I, s b) := by
haveI := hc.toEncodable
simp only [biUnion_eq_iUnion, measure_iUnion_toMeasurable]
#align measure_theory.measure_bUnion_to_measurable MeasureTheory.measure_biUnion_toMeasurable
@[simp]
theorem measure_toMeasurable_union : μ (toMeasurable μ s ∪ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset (subset_toMeasurable _ _) (measure_toMeasurable _).le Subset.rfl
le_rfl
#align measure_theory.measure_to_measurable_union MeasureTheory.measure_toMeasurable_union
@[simp]
theorem measure_union_toMeasurable : μ (s ∪ toMeasurable μ t) = μ (s ∪ t) :=
Eq.symm <|
measure_union_congr_of_subset Subset.rfl le_rfl (subset_toMeasurable _ _)
(measure_toMeasurable _).le
#align measure_theory.measure_union_to_measurable MeasureTheory.measure_union_toMeasurable
theorem sum_measure_le_measure_univ {s : Finset ι} {t : ι → Set α}
(h : ∀ i ∈ s, MeasurableSet (t i)) (H : Set.PairwiseDisjoint (↑s) t) :
(∑ i ∈ s, μ (t i)) ≤ μ (univ : Set α) := by
rw [← measure_biUnion_finset H h]
exact measure_mono (subset_univ _)
#align measure_theory.sum_measure_le_measure_univ MeasureTheory.sum_measure_le_measure_univ
theorem tsum_measure_le_measure_univ {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : Pairwise (Disjoint on s)) : (∑' i, μ (s i)) ≤ μ (univ : Set α) := by
rw [ENNReal.tsum_eq_iSup_sum]
exact iSup_le fun s =>
sum_measure_le_measure_univ (fun i _hi => hs i) fun i _hi j _hj hij => H hij
#align measure_theory.tsum_measure_le_measure_univ MeasureTheory.tsum_measure_le_measure_univ
/-- Pigeonhole principle for measure spaces: if `∑' i, μ (s i) > μ univ`, then
one of the intersections `s i ∩ s j` is not empty. -/
theorem exists_nonempty_inter_of_measure_univ_lt_tsum_measure {m : MeasurableSpace α}
(μ : Measure α) {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i))
(H : μ (univ : Set α) < ∑' i, μ (s i)) : ∃ i j, i ≠ j ∧ (s i ∩ s j).Nonempty := by
contrapose! H
apply tsum_measure_le_measure_univ hs
intro i j hij
exact disjoint_iff_inter_eq_empty.mpr (H i j hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_tsum_measure
/-- Pigeonhole principle for measure spaces: if `s` is a `Finset` and
`∑ i ∈ s, μ (t i) > μ univ`, then one of the intersections `t i ∩ t j` is not empty. -/
theorem exists_nonempty_inter_of_measure_univ_lt_sum_measure {m : MeasurableSpace α} (μ : Measure α)
{s : Finset ι} {t : ι → Set α} (h : ∀ i ∈ s, MeasurableSet (t i))
(H : μ (univ : Set α) < ∑ i ∈ s, μ (t i)) :
∃ i ∈ s, ∃ j ∈ s, ∃ _h : i ≠ j, (t i ∩ t j).Nonempty := by
contrapose! H
apply sum_measure_le_measure_univ h
intro i hi j hj hij
exact disjoint_iff_inter_eq_empty.mpr (H i hi j hj hij)
#align measure_theory.exists_nonempty_inter_of_measure_univ_lt_sum_measure MeasureTheory.exists_nonempty_inter_of_measure_univ_lt_sum_measure
/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,
then `s` intersects `t`. Version assuming that `t` is measurable. -/
theorem nonempty_inter_of_measure_lt_add {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(ht : MeasurableSet t) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [← Set.not_disjoint_iff_nonempty_inter]
contrapose! h
calc
μ s + μ t = μ (s ∪ t) := (measure_union h ht).symm
_ ≤ μ u := measure_mono (union_subset h's h't)
#align measure_theory.nonempty_inter_of_measure_lt_add MeasureTheory.nonempty_inter_of_measure_lt_add
/-- If two sets `s` and `t` are included in a set `u`, and `μ s + μ t > μ u`,
then `s` intersects `t`. Version assuming that `s` is measurable. -/
theorem nonempty_inter_of_measure_lt_add' {m : MeasurableSpace α} (μ : Measure α) {s t u : Set α}
(hs : MeasurableSet s) (h's : s ⊆ u) (h't : t ⊆ u) (h : μ u < μ s + μ t) :
(s ∩ t).Nonempty := by
rw [add_comm] at h
rw [inter_comm]
exact nonempty_inter_of_measure_lt_add μ hs h't h's h
#align measure_theory.nonempty_inter_of_measure_lt_add' MeasureTheory.nonempty_inter_of_measure_lt_add'
/-- Continuity from below: the measure of the union of a directed sequence of (not necessarily
-measurable) sets is the supremum of the measures. -/
theorem measure_iUnion_eq_iSup [Countable ι] {s : ι → Set α} (hd : Directed (· ⊆ ·) s) :
μ (⋃ i, s i) = ⨆ i, μ (s i) := by
cases nonempty_encodable ι
-- WLOG, `ι = ℕ`
generalize ht : Function.extend Encodable.encode s ⊥ = t
replace hd : Directed (· ⊆ ·) t := ht ▸ hd.extend_bot Encodable.encode_injective
suffices μ (⋃ n, t n) = ⨆ n, μ (t n) by
simp only [← ht, Function.apply_extend μ, ← iSup_eq_iUnion,
iSup_extend_bot Encodable.encode_injective, (· ∘ ·), Pi.bot_apply, bot_eq_empty,
measure_empty] at this
exact this.trans (iSup_extend_bot Encodable.encode_injective _)
clear! ι
-- The `≥` inequality is trivial
refine le_antisymm ?_ (iSup_le fun i => measure_mono <| subset_iUnion _ _)
-- Choose `T n ⊇ t n` of the same measure, put `Td n = disjointed T`
set T : ℕ → Set α := fun n => toMeasurable μ (t n)
set Td : ℕ → Set α := disjointed T
have hm : ∀ n, MeasurableSet (Td n) :=
MeasurableSet.disjointed fun n => measurableSet_toMeasurable _ _
calc
μ (⋃ n, t n) ≤ μ (⋃ n, T n) := measure_mono (iUnion_mono fun i => subset_toMeasurable _ _)
_ = μ (⋃ n, Td n) := by rw [iUnion_disjointed]
_ ≤ ∑' n, μ (Td n) := measure_iUnion_le _
_ = ⨆ I : Finset ℕ, ∑ n ∈ I, μ (Td n) := ENNReal.tsum_eq_iSup_sum
_ ≤ ⨆ n, μ (t n) := iSup_le fun I => by
rcases hd.finset_le I with ⟨N, hN⟩
calc
(∑ n ∈ I, μ (Td n)) = μ (⋃ n ∈ I, Td n) :=
(measure_biUnion_finset ((disjoint_disjointed T).set_pairwise I) fun n _ => hm n).symm
_ ≤ μ (⋃ n ∈ I, T n) := measure_mono (iUnion₂_mono fun n _hn => disjointed_subset _ _)
_ = μ (⋃ n ∈ I, t n) := measure_biUnion_toMeasurable I.countable_toSet _
_ ≤ μ (t N) := measure_mono (iUnion₂_subset hN)
_ ≤ ⨆ n, μ (t n) := le_iSup (μ ∘ t) N
#align measure_theory.measure_Union_eq_supr MeasureTheory.measure_iUnion_eq_iSup
/-- Continuity from below: the measure of the union of a sequence of
(not necessarily measurable) sets is the supremum of the measures of the partial unions. -/
theorem measure_iUnion_eq_iSup' {α ι : Type*} [MeasurableSpace α] {μ : Measure α}
[Countable ι] [Preorder ι] [IsDirected ι (· ≤ ·)]
{f : ι → Set α} : μ (⋃ i, f i) = ⨆ i, μ (Accumulate f i) := by
have hd : Directed (· ⊆ ·) (Accumulate f) := by
intro i j
rcases directed_of (· ≤ ·) i j with ⟨k, rik, rjk⟩
exact ⟨k, biUnion_subset_biUnion_left fun l rli ↦ le_trans rli rik,
biUnion_subset_biUnion_left fun l rlj ↦ le_trans rlj rjk⟩
rw [← iUnion_accumulate]
exact measure_iUnion_eq_iSup hd
| Mathlib/MeasureTheory/Measure/MeasureSpace.lean | 518 | 521 | theorem measure_biUnion_eq_iSup {s : ι → Set α} {t : Set ι} (ht : t.Countable)
(hd : DirectedOn ((· ⊆ ·) on s) t) : μ (⋃ i ∈ t, s i) = ⨆ i ∈ t, μ (s i) := by |
haveI := ht.toEncodable
rw [biUnion_eq_iUnion, measure_iUnion_eq_iSup hd.directed_val, ← iSup_subtype'']
|
/-
Copyright (c) 2024 Miyahara Kō. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Miyahara Kō
-/
import Mathlib.Data.List.Range
import Mathlib.Algebra.Order.Ring.Nat
/-!
# iterate
Proves various lemmas about `List.iterate`.
-/
variable {α : Type*}
namespace List
@[simp]
theorem length_iterate (f : α → α) (a : α) (n : ℕ) : length (iterate f a n) = n := by
induction n generalizing a <;> simp [*]
@[simp]
| Mathlib/Data/List/Iterate.lean | 25 | 26 | theorem iterate_eq_nil {f : α → α} {a : α} {n : ℕ} : iterate f a n = [] ↔ n = 0 := by |
rw [← length_eq_zero, length_iterate]
|
/-
Copyright (c) 2014 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, Leonardo de Moura
-/
import Mathlib.Init.ZeroOne
import Mathlib.Data.Set.Defs
import Mathlib.Order.Basic
import Mathlib.Order.SymmDiff
import Mathlib.Tactic.Tauto
import Mathlib.Tactic.ByContra
import Mathlib.Util.Delaborators
#align_import data.set.basic from "leanprover-community/mathlib"@"001ffdc42920050657fd45bd2b8bfbec8eaaeb29"
/-!
# Basic properties of sets
Sets in Lean are homogeneous; all their elements have the same type. Sets whose elements
have type `X` are thus defined as `Set X := X → Prop`. Note that this function need not
be decidable. The definition is in the core library.
This file provides some basic definitions related to sets and functions not present in the core
library, as well as extra lemmas for functions in the core library (empty set, univ, union,
intersection, insert, singleton, set-theoretic difference, complement, and powerset).
Note that a set is a term, not a type. There is a coercion from `Set α` to `Type*` sending
`s` to the corresponding subtype `↥s`.
See also the file `SetTheory/ZFC.lean`, which contains an encoding of ZFC set theory in Lean.
## Main definitions
Notation used here:
- `f : α → β` is a function,
- `s : Set α` and `s₁ s₂ : Set α` are subsets of `α`
- `t : Set β` is a subset of `β`.
Definitions in the file:
* `Nonempty s : Prop` : the predicate `s ≠ ∅`. Note that this is the preferred way to express the
fact that `s` has an element (see the Implementation Notes).
* `inclusion s₁ s₂ : ↥s₁ → ↥s₂` : the map `↥s₁ → ↥s₂` induced by an inclusion `s₁ ⊆ s₂`.
## Notation
* `sᶜ` for the complement of `s`
## Implementation notes
* `s.Nonempty` is to be preferred to `s ≠ ∅` or `∃ x, x ∈ s`. It has the advantage that
the `s.Nonempty` dot notation can be used.
* For `s : Set α`, do not use `Subtype s`. Instead use `↥s` or `(s : Type*)` or `s`.
## Tags
set, sets, subset, subsets, union, intersection, insert, singleton, complement, powerset
-/
/-! ### Set coercion to a type -/
open Function
universe u v w x
namespace Set
variable {α : Type u} {s t : Set α}
instance instBooleanAlgebraSet : BooleanAlgebra (Set α) :=
{ (inferInstance : BooleanAlgebra (α → Prop)) with
sup := (· ∪ ·),
le := (· ≤ ·),
lt := fun s t => s ⊆ t ∧ ¬t ⊆ s,
inf := (· ∩ ·),
bot := ∅,
compl := (·ᶜ),
top := univ,
sdiff := (· \ ·) }
instance : HasSSubset (Set α) :=
⟨(· < ·)⟩
@[simp]
theorem top_eq_univ : (⊤ : Set α) = univ :=
rfl
#align set.top_eq_univ Set.top_eq_univ
@[simp]
theorem bot_eq_empty : (⊥ : Set α) = ∅ :=
rfl
#align set.bot_eq_empty Set.bot_eq_empty
@[simp]
theorem sup_eq_union : ((· ⊔ ·) : Set α → Set α → Set α) = (· ∪ ·) :=
rfl
#align set.sup_eq_union Set.sup_eq_union
@[simp]
theorem inf_eq_inter : ((· ⊓ ·) : Set α → Set α → Set α) = (· ∩ ·) :=
rfl
#align set.inf_eq_inter Set.inf_eq_inter
@[simp]
theorem le_eq_subset : ((· ≤ ·) : Set α → Set α → Prop) = (· ⊆ ·) :=
rfl
#align set.le_eq_subset Set.le_eq_subset
@[simp]
theorem lt_eq_ssubset : ((· < ·) : Set α → Set α → Prop) = (· ⊂ ·) :=
rfl
#align set.lt_eq_ssubset Set.lt_eq_ssubset
theorem le_iff_subset : s ≤ t ↔ s ⊆ t :=
Iff.rfl
#align set.le_iff_subset Set.le_iff_subset
theorem lt_iff_ssubset : s < t ↔ s ⊂ t :=
Iff.rfl
#align set.lt_iff_ssubset Set.lt_iff_ssubset
alias ⟨_root_.LE.le.subset, _root_.HasSubset.Subset.le⟩ := le_iff_subset
#align has_subset.subset.le HasSubset.Subset.le
alias ⟨_root_.LT.lt.ssubset, _root_.HasSSubset.SSubset.lt⟩ := lt_iff_ssubset
#align has_ssubset.ssubset.lt HasSSubset.SSubset.lt
instance PiSetCoe.canLift (ι : Type u) (α : ι → Type v) [∀ i, Nonempty (α i)] (s : Set ι) :
CanLift (∀ i : s, α i) (∀ i, α i) (fun f i => f i) fun _ => True :=
PiSubtype.canLift ι α s
#align set.pi_set_coe.can_lift Set.PiSetCoe.canLift
instance PiSetCoe.canLift' (ι : Type u) (α : Type v) [Nonempty α] (s : Set ι) :
CanLift (s → α) (ι → α) (fun f i => f i) fun _ => True :=
PiSetCoe.canLift ι (fun _ => α) s
#align set.pi_set_coe.can_lift' Set.PiSetCoe.canLift'
end Set
section SetCoe
variable {α : Type u}
instance (s : Set α) : CoeTC s α := ⟨fun x => x.1⟩
theorem Set.coe_eq_subtype (s : Set α) : ↥s = { x // x ∈ s } :=
rfl
#align set.coe_eq_subtype Set.coe_eq_subtype
@[simp]
theorem Set.coe_setOf (p : α → Prop) : ↥{ x | p x } = { x // p x } :=
rfl
#align set.coe_set_of Set.coe_setOf
-- Porting note (#10618): removed `simp` because `simp` can prove it
theorem SetCoe.forall {s : Set α} {p : s → Prop} : (∀ x : s, p x) ↔ ∀ (x) (h : x ∈ s), p ⟨x, h⟩ :=
Subtype.forall
#align set_coe.forall SetCoe.forall
-- Porting note (#10618): removed `simp` because `simp` can prove it
theorem SetCoe.exists {s : Set α} {p : s → Prop} :
(∃ x : s, p x) ↔ ∃ (x : _) (h : x ∈ s), p ⟨x, h⟩ :=
Subtype.exists
#align set_coe.exists SetCoe.exists
theorem SetCoe.exists' {s : Set α} {p : ∀ x, x ∈ s → Prop} :
(∃ (x : _) (h : x ∈ s), p x h) ↔ ∃ x : s, p x.1 x.2 :=
(@SetCoe.exists _ _ fun x => p x.1 x.2).symm
#align set_coe.exists' SetCoe.exists'
theorem SetCoe.forall' {s : Set α} {p : ∀ x, x ∈ s → Prop} :
(∀ (x) (h : x ∈ s), p x h) ↔ ∀ x : s, p x.1 x.2 :=
(@SetCoe.forall _ _ fun x => p x.1 x.2).symm
#align set_coe.forall' SetCoe.forall'
@[simp]
theorem set_coe_cast :
∀ {s t : Set α} (H' : s = t) (H : ↥s = ↥t) (x : s), cast H x = ⟨x.1, H' ▸ x.2⟩
| _, _, rfl, _, _ => rfl
#align set_coe_cast set_coe_cast
theorem SetCoe.ext {s : Set α} {a b : s} : (a : α) = b → a = b :=
Subtype.eq
#align set_coe.ext SetCoe.ext
theorem SetCoe.ext_iff {s : Set α} {a b : s} : (↑a : α) = ↑b ↔ a = b :=
Iff.intro SetCoe.ext fun h => h ▸ rfl
#align set_coe.ext_iff SetCoe.ext_iff
end SetCoe
/-- See also `Subtype.prop` -/
theorem Subtype.mem {α : Type*} {s : Set α} (p : s) : (p : α) ∈ s :=
p.prop
#align subtype.mem Subtype.mem
/-- Duplicate of `Eq.subset'`, which currently has elaboration problems. -/
theorem Eq.subset {α} {s t : Set α} : s = t → s ⊆ t :=
fun h₁ _ h₂ => by rw [← h₁]; exact h₂
#align eq.subset Eq.subset
namespace Set
variable {α : Type u} {β : Type v} {γ : Type w} {ι : Sort x} {a b : α} {s s₁ s₂ t t₁ t₂ u : Set α}
instance : Inhabited (Set α) :=
⟨∅⟩
theorem ext_iff {s t : Set α} : s = t ↔ ∀ x, x ∈ s ↔ x ∈ t :=
⟨fun h x => by rw [h], ext⟩
#align set.ext_iff Set.ext_iff
@[trans]
theorem mem_of_mem_of_subset {x : α} {s t : Set α} (hx : x ∈ s) (h : s ⊆ t) : x ∈ t :=
h hx
#align set.mem_of_mem_of_subset Set.mem_of_mem_of_subset
theorem forall_in_swap {p : α → β → Prop} : (∀ a ∈ s, ∀ (b), p a b) ↔ ∀ (b), ∀ a ∈ s, p a b := by
tauto
#align set.forall_in_swap Set.forall_in_swap
/-! ### Lemmas about `mem` and `setOf` -/
theorem mem_setOf {a : α} {p : α → Prop} : a ∈ { x | p x } ↔ p a :=
Iff.rfl
#align set.mem_set_of Set.mem_setOf
/-- If `h : a ∈ {x | p x}` then `h.out : p x`. These are definitionally equal, but this can
nevertheless be useful for various reasons, e.g. to apply further projection notation or in an
argument to `simp`. -/
theorem _root_.Membership.mem.out {p : α → Prop} {a : α} (h : a ∈ { x | p x }) : p a :=
h
#align has_mem.mem.out Membership.mem.out
theorem nmem_setOf_iff {a : α} {p : α → Prop} : a ∉ { x | p x } ↔ ¬p a :=
Iff.rfl
#align set.nmem_set_of_iff Set.nmem_setOf_iff
@[simp]
theorem setOf_mem_eq {s : Set α} : { x | x ∈ s } = s :=
rfl
#align set.set_of_mem_eq Set.setOf_mem_eq
theorem setOf_set {s : Set α} : setOf s = s :=
rfl
#align set.set_of_set Set.setOf_set
theorem setOf_app_iff {p : α → Prop} {x : α} : { x | p x } x ↔ p x :=
Iff.rfl
#align set.set_of_app_iff Set.setOf_app_iff
theorem mem_def {a : α} {s : Set α} : a ∈ s ↔ s a :=
Iff.rfl
#align set.mem_def Set.mem_def
theorem setOf_bijective : Bijective (setOf : (α → Prop) → Set α) :=
bijective_id
#align set.set_of_bijective Set.setOf_bijective
theorem subset_setOf {p : α → Prop} {s : Set α} : s ⊆ setOf p ↔ ∀ x, x ∈ s → p x :=
Iff.rfl
theorem setOf_subset {p : α → Prop} {s : Set α} : setOf p ⊆ s ↔ ∀ x, p x → x ∈ s :=
Iff.rfl
@[simp]
theorem setOf_subset_setOf {p q : α → Prop} : { a | p a } ⊆ { a | q a } ↔ ∀ a, p a → q a :=
Iff.rfl
#align set.set_of_subset_set_of Set.setOf_subset_setOf
theorem setOf_and {p q : α → Prop} : { a | p a ∧ q a } = { a | p a } ∩ { a | q a } :=
rfl
#align set.set_of_and Set.setOf_and
theorem setOf_or {p q : α → Prop} : { a | p a ∨ q a } = { a | p a } ∪ { a | q a } :=
rfl
#align set.set_of_or Set.setOf_or
/-! ### Subset and strict subset relations -/
instance : IsRefl (Set α) (· ⊆ ·) :=
show IsRefl (Set α) (· ≤ ·) by infer_instance
instance : IsTrans (Set α) (· ⊆ ·) :=
show IsTrans (Set α) (· ≤ ·) by infer_instance
instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊆ ·) :=
show Trans (· ≤ ·) (· ≤ ·) (· ≤ ·) by infer_instance
instance : IsAntisymm (Set α) (· ⊆ ·) :=
show IsAntisymm (Set α) (· ≤ ·) by infer_instance
instance : IsIrrefl (Set α) (· ⊂ ·) :=
show IsIrrefl (Set α) (· < ·) by infer_instance
instance : IsTrans (Set α) (· ⊂ ·) :=
show IsTrans (Set α) (· < ·) by infer_instance
instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) :=
show Trans (· < ·) (· < ·) (· < ·) by infer_instance
instance : Trans ((· ⊂ ·) : Set α → Set α → Prop) (· ⊆ ·) (· ⊂ ·) :=
show Trans (· < ·) (· ≤ ·) (· < ·) by infer_instance
instance : Trans ((· ⊆ ·) : Set α → Set α → Prop) (· ⊂ ·) (· ⊂ ·) :=
show Trans (· ≤ ·) (· < ·) (· < ·) by infer_instance
instance : IsAsymm (Set α) (· ⊂ ·) :=
show IsAsymm (Set α) (· < ·) by infer_instance
instance : IsNonstrictStrictOrder (Set α) (· ⊆ ·) (· ⊂ ·) :=
⟨fun _ _ => Iff.rfl⟩
-- TODO(Jeremy): write a tactic to unfold specific instances of generic notation?
theorem subset_def : (s ⊆ t) = ∀ x, x ∈ s → x ∈ t :=
rfl
#align set.subset_def Set.subset_def
theorem ssubset_def : (s ⊂ t) = (s ⊆ t ∧ ¬t ⊆ s) :=
rfl
#align set.ssubset_def Set.ssubset_def
@[refl]
theorem Subset.refl (a : Set α) : a ⊆ a := fun _ => id
#align set.subset.refl Set.Subset.refl
theorem Subset.rfl {s : Set α} : s ⊆ s :=
Subset.refl s
#align set.subset.rfl Set.Subset.rfl
@[trans]
theorem Subset.trans {a b c : Set α} (ab : a ⊆ b) (bc : b ⊆ c) : a ⊆ c := fun _ h => bc <| ab h
#align set.subset.trans Set.Subset.trans
@[trans]
theorem mem_of_eq_of_mem {x y : α} {s : Set α} (hx : x = y) (h : y ∈ s) : x ∈ s :=
hx.symm ▸ h
#align set.mem_of_eq_of_mem Set.mem_of_eq_of_mem
theorem Subset.antisymm {a b : Set α} (h₁ : a ⊆ b) (h₂ : b ⊆ a) : a = b :=
Set.ext fun _ => ⟨@h₁ _, @h₂ _⟩
#align set.subset.antisymm Set.Subset.antisymm
theorem Subset.antisymm_iff {a b : Set α} : a = b ↔ a ⊆ b ∧ b ⊆ a :=
⟨fun e => ⟨e.subset, e.symm.subset⟩, fun ⟨h₁, h₂⟩ => Subset.antisymm h₁ h₂⟩
#align set.subset.antisymm_iff Set.Subset.antisymm_iff
-- an alternative name
theorem eq_of_subset_of_subset {a b : Set α} : a ⊆ b → b ⊆ a → a = b :=
Subset.antisymm
#align set.eq_of_subset_of_subset Set.eq_of_subset_of_subset
theorem mem_of_subset_of_mem {s₁ s₂ : Set α} {a : α} (h : s₁ ⊆ s₂) : a ∈ s₁ → a ∈ s₂ :=
@h _
#align set.mem_of_subset_of_mem Set.mem_of_subset_of_mem
theorem not_mem_subset (h : s ⊆ t) : a ∉ t → a ∉ s :=
mt <| mem_of_subset_of_mem h
#align set.not_mem_subset Set.not_mem_subset
theorem not_subset : ¬s ⊆ t ↔ ∃ a ∈ s, a ∉ t := by
simp only [subset_def, not_forall, exists_prop]
#align set.not_subset Set.not_subset
lemma eq_of_forall_subset_iff (h : ∀ u, s ⊆ u ↔ t ⊆ u) : s = t := eq_of_forall_ge_iff h
/-! ### Definition of strict subsets `s ⊂ t` and basic properties. -/
protected theorem eq_or_ssubset_of_subset (h : s ⊆ t) : s = t ∨ s ⊂ t :=
eq_or_lt_of_le h
#align set.eq_or_ssubset_of_subset Set.eq_or_ssubset_of_subset
theorem exists_of_ssubset {s t : Set α} (h : s ⊂ t) : ∃ x ∈ t, x ∉ s :=
not_subset.1 h.2
#align set.exists_of_ssubset Set.exists_of_ssubset
protected theorem ssubset_iff_subset_ne {s t : Set α} : s ⊂ t ↔ s ⊆ t ∧ s ≠ t :=
@lt_iff_le_and_ne (Set α) _ s t
#align set.ssubset_iff_subset_ne Set.ssubset_iff_subset_ne
theorem ssubset_iff_of_subset {s t : Set α} (h : s ⊆ t) : s ⊂ t ↔ ∃ x ∈ t, x ∉ s :=
⟨exists_of_ssubset, fun ⟨_, hxt, hxs⟩ => ⟨h, fun h => hxs <| h hxt⟩⟩
#align set.ssubset_iff_of_subset Set.ssubset_iff_of_subset
protected theorem ssubset_of_ssubset_of_subset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊂ s₂)
(hs₂s₃ : s₂ ⊆ s₃) : s₁ ⊂ s₃ :=
⟨Subset.trans hs₁s₂.1 hs₂s₃, fun hs₃s₁ => hs₁s₂.2 (Subset.trans hs₂s₃ hs₃s₁)⟩
#align set.ssubset_of_ssubset_of_subset Set.ssubset_of_ssubset_of_subset
protected theorem ssubset_of_subset_of_ssubset {s₁ s₂ s₃ : Set α} (hs₁s₂ : s₁ ⊆ s₂)
(hs₂s₃ : s₂ ⊂ s₃) : s₁ ⊂ s₃ :=
⟨Subset.trans hs₁s₂ hs₂s₃.1, fun hs₃s₁ => hs₂s₃.2 (Subset.trans hs₃s₁ hs₁s₂)⟩
#align set.ssubset_of_subset_of_ssubset Set.ssubset_of_subset_of_ssubset
theorem not_mem_empty (x : α) : ¬x ∈ (∅ : Set α) :=
id
#align set.not_mem_empty Set.not_mem_empty
-- Porting note (#10618): removed `simp` because `simp` can prove it
theorem not_not_mem : ¬a ∉ s ↔ a ∈ s :=
not_not
#align set.not_not_mem Set.not_not_mem
/-! ### Non-empty sets -/
-- Porting note: we seem to need parentheses at `(↥s)`,
-- even if we increase the right precedence of `↥` in `Mathlib.Tactic.Coe`.
-- Porting note: removed `simp` as it is competing with `nonempty_subtype`.
-- @[simp]
theorem nonempty_coe_sort {s : Set α} : Nonempty (↥s) ↔ s.Nonempty :=
nonempty_subtype
#align set.nonempty_coe_sort Set.nonempty_coe_sort
alias ⟨_, Nonempty.coe_sort⟩ := nonempty_coe_sort
#align set.nonempty.coe_sort Set.Nonempty.coe_sort
theorem nonempty_def : s.Nonempty ↔ ∃ x, x ∈ s :=
Iff.rfl
#align set.nonempty_def Set.nonempty_def
theorem nonempty_of_mem {x} (h : x ∈ s) : s.Nonempty :=
⟨x, h⟩
#align set.nonempty_of_mem Set.nonempty_of_mem
theorem Nonempty.not_subset_empty : s.Nonempty → ¬s ⊆ ∅
| ⟨_, hx⟩, hs => hs hx
#align set.nonempty.not_subset_empty Set.Nonempty.not_subset_empty
/-- Extract a witness from `s.Nonempty`. This function might be used instead of case analysis
on the argument. Note that it makes a proof depend on the `Classical.choice` axiom. -/
protected noncomputable def Nonempty.some (h : s.Nonempty) : α :=
Classical.choose h
#align set.nonempty.some Set.Nonempty.some
protected theorem Nonempty.some_mem (h : s.Nonempty) : h.some ∈ s :=
Classical.choose_spec h
#align set.nonempty.some_mem Set.Nonempty.some_mem
theorem Nonempty.mono (ht : s ⊆ t) (hs : s.Nonempty) : t.Nonempty :=
hs.imp ht
#align set.nonempty.mono Set.Nonempty.mono
theorem nonempty_of_not_subset (h : ¬s ⊆ t) : (s \ t).Nonempty :=
let ⟨x, xs, xt⟩ := not_subset.1 h
⟨x, xs, xt⟩
#align set.nonempty_of_not_subset Set.nonempty_of_not_subset
theorem nonempty_of_ssubset (ht : s ⊂ t) : (t \ s).Nonempty :=
nonempty_of_not_subset ht.2
#align set.nonempty_of_ssubset Set.nonempty_of_ssubset
theorem Nonempty.of_diff (h : (s \ t).Nonempty) : s.Nonempty :=
h.imp fun _ => And.left
#align set.nonempty.of_diff Set.Nonempty.of_diff
theorem nonempty_of_ssubset' (ht : s ⊂ t) : t.Nonempty :=
(nonempty_of_ssubset ht).of_diff
#align set.nonempty_of_ssubset' Set.nonempty_of_ssubset'
theorem Nonempty.inl (hs : s.Nonempty) : (s ∪ t).Nonempty :=
hs.imp fun _ => Or.inl
#align set.nonempty.inl Set.Nonempty.inl
theorem Nonempty.inr (ht : t.Nonempty) : (s ∪ t).Nonempty :=
ht.imp fun _ => Or.inr
#align set.nonempty.inr Set.Nonempty.inr
@[simp]
theorem union_nonempty : (s ∪ t).Nonempty ↔ s.Nonempty ∨ t.Nonempty :=
exists_or
#align set.union_nonempty Set.union_nonempty
theorem Nonempty.left (h : (s ∩ t).Nonempty) : s.Nonempty :=
h.imp fun _ => And.left
#align set.nonempty.left Set.Nonempty.left
theorem Nonempty.right (h : (s ∩ t).Nonempty) : t.Nonempty :=
h.imp fun _ => And.right
#align set.nonempty.right Set.Nonempty.right
theorem inter_nonempty : (s ∩ t).Nonempty ↔ ∃ x, x ∈ s ∧ x ∈ t :=
Iff.rfl
#align set.inter_nonempty Set.inter_nonempty
| Mathlib/Data/Set/Basic.lean | 492 | 493 | theorem inter_nonempty_iff_exists_left : (s ∩ t).Nonempty ↔ ∃ x ∈ s, x ∈ t := by |
simp_rw [inter_nonempty]
|
/-
Copyright (c) 2019 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Kenny Lau
-/
import Mathlib.Algebra.MvPolynomial.Basic
import Mathlib.Data.Finset.PiAntidiagonal
import Mathlib.LinearAlgebra.StdBasis
import Mathlib.Tactic.Linarith
#align_import ring_theory.power_series.basic from "leanprover-community/mathlib"@"2d5739b61641ee4e7e53eca5688a08f66f2e6a60"
/-!
# Formal (multivariate) power series
This file defines multivariate formal power series
and develops the basic properties of these objects.
A formal power series is to a polynomial like an infinite sum is to a finite sum.
We provide the natural inclusion from multivariate polynomials to multivariate formal power series.
## Note
This file sets up the (semi)ring structure on multivariate power series:
additional results are in:
* `Mathlib.RingTheory.MvPowerSeries.Inverse` : invertibility,
formal power series over a local ring form a local ring;
* `Mathlib.RingTheory.MvPowerSeries.Trunc`: truncation of power series.
In `Mathlib.RingTheory.PowerSeries.Basic`, formal power series in one variable
will be obtained as a particular case, defined by
`PowerSeries R := MvPowerSeries Unit R`.
See that file for a specific description.
## Implementation notes
In this file we define multivariate formal power series with
variables indexed by `σ` and coefficients in `R` as
`MvPowerSeries σ R := (σ →₀ ℕ) → R`.
Unfortunately there is not yet enough API to show that they are the completion
of the ring of multivariate polynomials. However, we provide most of the infrastructure
that is needed to do this. Once I-adic completion (topological or algebraic) is available
it should not be hard to fill in the details.
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
/-- Multivariate formal power series, where `σ` is the index set of the variables
and `R` is the coefficient ring. -/
def MvPowerSeries (σ : Type*) (R : Type*) :=
(σ →₀ ℕ) → R
#align mv_power_series MvPowerSeries
namespace MvPowerSeries
open Finsupp
variable {σ R : Type*}
instance [Inhabited R] : Inhabited (MvPowerSeries σ R) :=
⟨fun _ => default⟩
instance [Zero R] : Zero (MvPowerSeries σ R) :=
Pi.instZero
instance [AddMonoid R] : AddMonoid (MvPowerSeries σ R) :=
Pi.addMonoid
instance [AddGroup R] : AddGroup (MvPowerSeries σ R) :=
Pi.addGroup
instance [AddCommMonoid R] : AddCommMonoid (MvPowerSeries σ R) :=
Pi.addCommMonoid
instance [AddCommGroup R] : AddCommGroup (MvPowerSeries σ R) :=
Pi.addCommGroup
instance [Nontrivial R] : Nontrivial (MvPowerSeries σ R) :=
Function.nontrivial
instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R (MvPowerSeries σ A) :=
Pi.module _ _ _
instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S]
[IsScalarTower R S A] : IsScalarTower R S (MvPowerSeries σ A) :=
Pi.isScalarTower
section Semiring
variable (R) [Semiring R]
/-- The `n`th monomial as multivariate formal power series:
it is defined as the `R`-linear map from `R` to the semi-ring
of multivariate formal power series associating to each `a`
the map sending `n : σ →₀ ℕ` to the value `a`
and sending all other `x : σ →₀ ℕ` different from `n` to `0`. -/
def monomial (n : σ →₀ ℕ) : R →ₗ[R] MvPowerSeries σ R :=
letI := Classical.decEq σ
LinearMap.stdBasis R (fun _ ↦ R) n
#align mv_power_series.monomial MvPowerSeries.monomial
/-- The `n`th coefficient of a multivariate formal power series. -/
def coeff (n : σ →₀ ℕ) : MvPowerSeries σ R →ₗ[R] R :=
LinearMap.proj n
#align mv_power_series.coeff MvPowerSeries.coeff
variable {R}
/-- Two multivariate formal power series are equal if all their coefficients are equal. -/
@[ext]
theorem ext {φ ψ} (h : ∀ n : σ →₀ ℕ, coeff R n φ = coeff R n ψ) : φ = ψ :=
funext h
#align mv_power_series.ext MvPowerSeries.ext
/-- Two multivariate formal power series are equal
if and only if all their coefficients are equal. -/
theorem ext_iff {φ ψ : MvPowerSeries σ R} : φ = ψ ↔ ∀ n : σ →₀ ℕ, coeff R n φ = coeff R n ψ :=
Function.funext_iff
#align mv_power_series.ext_iff MvPowerSeries.ext_iff
theorem monomial_def [DecidableEq σ] (n : σ →₀ ℕ) :
(monomial R n) = LinearMap.stdBasis R (fun _ ↦ R) n := by
rw [monomial]
-- unify the `Decidable` arguments
convert rfl
#align mv_power_series.monomial_def MvPowerSeries.monomial_def
theorem coeff_monomial [DecidableEq σ] (m n : σ →₀ ℕ) (a : R) :
coeff R m (monomial R n a) = if m = n then a else 0 := by
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [coeff, monomial_def, LinearMap.proj_apply (i := m)]
dsimp only
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [LinearMap.stdBasis_apply, Function.update_apply, Pi.zero_apply]
#align mv_power_series.coeff_monomial MvPowerSeries.coeff_monomial
@[simp]
theorem coeff_monomial_same (n : σ →₀ ℕ) (a : R) : coeff R n (monomial R n a) = a := by
classical
rw [monomial_def]
exact LinearMap.stdBasis_same R (fun _ ↦ R) n a
#align mv_power_series.coeff_monomial_same MvPowerSeries.coeff_monomial_same
theorem coeff_monomial_ne {m n : σ →₀ ℕ} (h : m ≠ n) (a : R) : coeff R m (monomial R n a) = 0 := by
classical
rw [monomial_def]
exact LinearMap.stdBasis_ne R (fun _ ↦ R) _ _ h a
#align mv_power_series.coeff_monomial_ne MvPowerSeries.coeff_monomial_ne
theorem eq_of_coeff_monomial_ne_zero {m n : σ →₀ ℕ} {a : R} (h : coeff R m (monomial R n a) ≠ 0) :
m = n :=
by_contra fun h' => h <| coeff_monomial_ne h' a
#align mv_power_series.eq_of_coeff_monomial_ne_zero MvPowerSeries.eq_of_coeff_monomial_ne_zero
@[simp]
theorem coeff_comp_monomial (n : σ →₀ ℕ) : (coeff R n).comp (monomial R n) = LinearMap.id :=
LinearMap.ext <| coeff_monomial_same n
#align mv_power_series.coeff_comp_monomial MvPowerSeries.coeff_comp_monomial
-- Porting note (#10618): simp can prove this.
-- @[simp]
theorem coeff_zero (n : σ →₀ ℕ) : coeff R n (0 : MvPowerSeries σ R) = 0 :=
rfl
#align mv_power_series.coeff_zero MvPowerSeries.coeff_zero
variable (m n : σ →₀ ℕ) (φ ψ : MvPowerSeries σ R)
instance : One (MvPowerSeries σ R) :=
⟨monomial R (0 : σ →₀ ℕ) 1⟩
theorem coeff_one [DecidableEq σ] : coeff R n (1 : MvPowerSeries σ R) = if n = 0 then 1 else 0 :=
coeff_monomial _ _ _
#align mv_power_series.coeff_one MvPowerSeries.coeff_one
theorem coeff_zero_one : coeff R (0 : σ →₀ ℕ) 1 = 1 :=
coeff_monomial_same 0 1
#align mv_power_series.coeff_zero_one MvPowerSeries.coeff_zero_one
theorem monomial_zero_one : monomial R (0 : σ →₀ ℕ) 1 = 1 :=
rfl
#align mv_power_series.monomial_zero_one MvPowerSeries.monomial_zero_one
instance : AddMonoidWithOne (MvPowerSeries σ R) :=
{ show AddMonoid (MvPowerSeries σ R) by infer_instance with
natCast := fun n => monomial R 0 n
natCast_zero := by simp [Nat.cast]
natCast_succ := by simp [Nat.cast, monomial_zero_one]
one := 1 }
instance : Mul (MvPowerSeries σ R) :=
letI := Classical.decEq σ
⟨fun φ ψ n => ∑ p ∈ antidiagonal n, coeff R p.1 φ * coeff R p.2 ψ⟩
theorem coeff_mul [DecidableEq σ] :
coeff R n (φ * ψ) = ∑ p ∈ antidiagonal n, coeff R p.1 φ * coeff R p.2 ψ := by
refine Finset.sum_congr ?_ fun _ _ => rfl
rw [Subsingleton.elim (Classical.decEq σ) ‹DecidableEq σ›]
#align mv_power_series.coeff_mul MvPowerSeries.coeff_mul
protected theorem zero_mul : (0 : MvPowerSeries σ R) * φ = 0 :=
ext fun n => by classical simp [coeff_mul]
#align mv_power_series.zero_mul MvPowerSeries.zero_mul
protected theorem mul_zero : φ * 0 = 0 :=
ext fun n => by classical simp [coeff_mul]
#align mv_power_series.mul_zero MvPowerSeries.mul_zero
theorem coeff_monomial_mul (a : R) :
coeff R m (monomial R n a * φ) = if n ≤ m then a * coeff R (m - n) φ else 0 := by
classical
have :
∀ p ∈ antidiagonal m,
coeff R (p : (σ →₀ ℕ) × (σ →₀ ℕ)).1 (monomial R n a) * coeff R p.2 φ ≠ 0 → p.1 = n :=
fun p _ hp => eq_of_coeff_monomial_ne_zero (left_ne_zero_of_mul hp)
rw [coeff_mul, ← Finset.sum_filter_of_ne this, Finset.filter_fst_eq_antidiagonal _ n,
Finset.sum_ite_index]
simp only [Finset.sum_singleton, coeff_monomial_same, Finset.sum_empty]
#align mv_power_series.coeff_monomial_mul MvPowerSeries.coeff_monomial_mul
theorem coeff_mul_monomial (a : R) :
coeff R m (φ * monomial R n a) = if n ≤ m then coeff R (m - n) φ * a else 0 := by
classical
have :
∀ p ∈ antidiagonal m,
coeff R (p : (σ →₀ ℕ) × (σ →₀ ℕ)).1 φ * coeff R p.2 (monomial R n a) ≠ 0 → p.2 = n :=
fun p _ hp => eq_of_coeff_monomial_ne_zero (right_ne_zero_of_mul hp)
rw [coeff_mul, ← Finset.sum_filter_of_ne this, Finset.filter_snd_eq_antidiagonal _ n,
Finset.sum_ite_index]
simp only [Finset.sum_singleton, coeff_monomial_same, Finset.sum_empty]
#align mv_power_series.coeff_mul_monomial MvPowerSeries.coeff_mul_monomial
theorem coeff_add_monomial_mul (a : R) :
coeff R (m + n) (monomial R m a * φ) = a * coeff R n φ := by
rw [coeff_monomial_mul, if_pos, add_tsub_cancel_left]
exact le_add_right le_rfl
#align mv_power_series.coeff_add_monomial_mul MvPowerSeries.coeff_add_monomial_mul
theorem coeff_add_mul_monomial (a : R) :
coeff R (m + n) (φ * monomial R n a) = coeff R m φ * a := by
rw [coeff_mul_monomial, if_pos, add_tsub_cancel_right]
exact le_add_left le_rfl
#align mv_power_series.coeff_add_mul_monomial MvPowerSeries.coeff_add_mul_monomial
@[simp]
theorem commute_monomial {a : R} {n} :
Commute φ (monomial R n a) ↔ ∀ m, Commute (coeff R m φ) a := by
refine ext_iff.trans ⟨fun h m => ?_, fun h m => ?_⟩
· have := h (m + n)
rwa [coeff_add_mul_monomial, add_comm, coeff_add_monomial_mul] at this
· rw [coeff_mul_monomial, coeff_monomial_mul]
split_ifs <;> [apply h; rfl]
#align mv_power_series.commute_monomial MvPowerSeries.commute_monomial
protected theorem one_mul : (1 : MvPowerSeries σ R) * φ = φ :=
ext fun n => by simpa using coeff_add_monomial_mul 0 n φ 1
#align mv_power_series.one_mul MvPowerSeries.one_mul
protected theorem mul_one : φ * 1 = φ :=
ext fun n => by simpa using coeff_add_mul_monomial n 0 φ 1
#align mv_power_series.mul_one MvPowerSeries.mul_one
protected theorem mul_add (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : φ₁ * (φ₂ + φ₃) = φ₁ * φ₂ + φ₁ * φ₃ :=
ext fun n => by
classical simp only [coeff_mul, mul_add, Finset.sum_add_distrib, LinearMap.map_add]
#align mv_power_series.mul_add MvPowerSeries.mul_add
protected theorem add_mul (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : (φ₁ + φ₂) * φ₃ = φ₁ * φ₃ + φ₂ * φ₃ :=
ext fun n => by
classical simp only [coeff_mul, add_mul, Finset.sum_add_distrib, LinearMap.map_add]
#align mv_power_series.add_mul MvPowerSeries.add_mul
protected theorem mul_assoc (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : φ₁ * φ₂ * φ₃ = φ₁ * (φ₂ * φ₃) := by
ext1 n
classical
simp only [coeff_mul, Finset.sum_mul, Finset.mul_sum, Finset.sum_sigma']
apply Finset.sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l + j), (l, j)⟩)
(fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i + k, l), (i, k)⟩) <;> aesop (add simp [add_assoc, mul_assoc])
#align mv_power_series.mul_assoc MvPowerSeries.mul_assoc
instance : Semiring (MvPowerSeries σ R) :=
{ inferInstanceAs (AddMonoidWithOne (MvPowerSeries σ R)),
inferInstanceAs (Mul (MvPowerSeries σ R)),
inferInstanceAs (AddCommMonoid (MvPowerSeries σ R)) with
mul_one := MvPowerSeries.mul_one
one_mul := MvPowerSeries.one_mul
mul_assoc := MvPowerSeries.mul_assoc
mul_zero := MvPowerSeries.mul_zero
zero_mul := MvPowerSeries.zero_mul
left_distrib := MvPowerSeries.mul_add
right_distrib := MvPowerSeries.add_mul }
end Semiring
instance [CommSemiring R] : CommSemiring (MvPowerSeries σ R) :=
{ show Semiring (MvPowerSeries σ R) by infer_instance with
mul_comm := fun φ ψ =>
ext fun n => by
classical
simpa only [coeff_mul, mul_comm] using
sum_antidiagonal_swap n fun a b => coeff R a φ * coeff R b ψ }
instance [Ring R] : Ring (MvPowerSeries σ R) :=
{ inferInstanceAs (Semiring (MvPowerSeries σ R)),
inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with }
instance [CommRing R] : CommRing (MvPowerSeries σ R) :=
{ inferInstanceAs (CommSemiring (MvPowerSeries σ R)),
inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with }
section Semiring
variable [Semiring R]
theorem monomial_mul_monomial (m n : σ →₀ ℕ) (a b : R) :
monomial R m a * monomial R n b = monomial R (m + n) (a * b) := by
classical
ext k
simp only [coeff_mul_monomial, coeff_monomial]
split_ifs with h₁ h₂ h₃ h₃ h₂ <;> try rfl
· rw [← h₂, tsub_add_cancel_of_le h₁] at h₃
exact (h₃ rfl).elim
· rw [h₃, add_tsub_cancel_right] at h₂
exact (h₂ rfl).elim
· exact zero_mul b
· rw [h₂] at h₁
exact (h₁ <| le_add_left le_rfl).elim
#align mv_power_series.monomial_mul_monomial MvPowerSeries.monomial_mul_monomial
variable (σ) (R)
/-- The constant multivariate formal power series. -/
def C : R →+* MvPowerSeries σ R :=
{ monomial R (0 : σ →₀ ℕ) with
map_one' := rfl
map_mul' := fun a b => (monomial_mul_monomial 0 0 a b).symm
map_zero' := (monomial R (0 : _)).map_zero }
set_option linter.uppercaseLean3 false in
#align mv_power_series.C MvPowerSeries.C
variable {σ} {R}
@[simp]
theorem monomial_zero_eq_C : ⇑(monomial R (0 : σ →₀ ℕ)) = C σ R :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_power_series.monomial_zero_eq_C MvPowerSeries.monomial_zero_eq_C
theorem monomial_zero_eq_C_apply (a : R) : monomial R (0 : σ →₀ ℕ) a = C σ R a :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_power_series.monomial_zero_eq_C_apply MvPowerSeries.monomial_zero_eq_C_apply
theorem coeff_C [DecidableEq σ] (n : σ →₀ ℕ) (a : R) :
coeff R n (C σ R a) = if n = 0 then a else 0 :=
coeff_monomial _ _ _
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_C MvPowerSeries.coeff_C
theorem coeff_zero_C (a : R) : coeff R (0 : σ →₀ ℕ) (C σ R a) = a :=
coeff_monomial_same 0 a
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_zero_C MvPowerSeries.coeff_zero_C
/-- The variables of the multivariate formal power series ring. -/
def X (s : σ) : MvPowerSeries σ R :=
monomial R (single s 1) 1
set_option linter.uppercaseLean3 false in
#align mv_power_series.X MvPowerSeries.X
theorem coeff_X [DecidableEq σ] (n : σ →₀ ℕ) (s : σ) :
coeff R n (X s : MvPowerSeries σ R) = if n = single s 1 then 1 else 0 :=
coeff_monomial _ _ _
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_X MvPowerSeries.coeff_X
theorem coeff_index_single_X [DecidableEq σ] (s t : σ) :
coeff R (single t 1) (X s : MvPowerSeries σ R) = if t = s then 1 else 0 := by
simp only [coeff_X, single_left_inj (one_ne_zero : (1 : ℕ) ≠ 0)]
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_index_single_X MvPowerSeries.coeff_index_single_X
@[simp]
theorem coeff_index_single_self_X (s : σ) : coeff R (single s 1) (X s : MvPowerSeries σ R) = 1 :=
coeff_monomial_same _ _
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_index_single_self_X MvPowerSeries.coeff_index_single_self_X
theorem coeff_zero_X (s : σ) : coeff R (0 : σ →₀ ℕ) (X s : MvPowerSeries σ R) = 0 := by
classical
rw [coeff_X, if_neg]
intro h
exact one_ne_zero (single_eq_zero.mp h.symm)
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_zero_X MvPowerSeries.coeff_zero_X
theorem commute_X (φ : MvPowerSeries σ R) (s : σ) : Commute φ (X s) :=
φ.commute_monomial.mpr fun _m => Commute.one_right _
set_option linter.uppercaseLean3 false in
#align mv_power_series.commute_X MvPowerSeries.commute_X
theorem X_def (s : σ) : X s = monomial R (single s 1) 1 :=
rfl
set_option linter.uppercaseLean3 false in
#align mv_power_series.X_def MvPowerSeries.X_def
theorem X_pow_eq (s : σ) (n : ℕ) : (X s : MvPowerSeries σ R) ^ n = monomial R (single s n) 1 := by
induction' n with n ih
· simp
· rw [pow_succ, ih, Finsupp.single_add, X, monomial_mul_monomial, one_mul]
set_option linter.uppercaseLean3 false in
#align mv_power_series.X_pow_eq MvPowerSeries.X_pow_eq
theorem coeff_X_pow [DecidableEq σ] (m : σ →₀ ℕ) (s : σ) (n : ℕ) :
coeff R m ((X s : MvPowerSeries σ R) ^ n) = if m = single s n then 1 else 0 := by
rw [X_pow_eq s n, coeff_monomial]
set_option linter.uppercaseLean3 false in
#align mv_power_series.coeff_X_pow MvPowerSeries.coeff_X_pow
@[simp]
| Mathlib/RingTheory/MvPowerSeries/Basic.lean | 426 | 427 | theorem coeff_mul_C (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) (a : R) :
coeff R n (φ * C σ R a) = coeff R n φ * a := by | simpa using coeff_add_mul_monomial n 0 φ a
|
/-
Copyright (c) 2022 Violeta Hernández Palacios. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Violeta Hernández Palacios
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
import Mathlib.Tactic.TFAE
import Mathlib.Topology.Order.Monotone
#align_import set_theory.ordinal.topology from "leanprover-community/mathlib"@"740acc0e6f9adf4423f92a485d0456fc271482da"
/-!
### Topology of ordinals
We prove some miscellaneous results involving the order topology of ordinals.
### Main results
* `Ordinal.isClosed_iff_sup` / `Ordinal.isClosed_iff_bsup`: A set of ordinals is closed iff it's
closed under suprema.
* `Ordinal.isNormal_iff_strictMono_and_continuous`: A characterization of normal ordinal
functions.
* `Ordinal.enumOrd_isNormal_iff_isClosed`: The function enumerating the ordinals of a set is
normal iff the set is closed.
-/
noncomputable section
universe u v
open Cardinal Order Topology
namespace Ordinal
variable {s : Set Ordinal.{u}} {a : Ordinal.{u}}
instance : TopologicalSpace Ordinal.{u} := Preorder.topology Ordinal.{u}
instance : OrderTopology Ordinal.{u} := ⟨rfl⟩
theorem isOpen_singleton_iff : IsOpen ({a} : Set Ordinal) ↔ ¬IsLimit a := by
refine ⟨fun h ⟨h₀, hsucc⟩ => ?_, fun ha => ?_⟩
· obtain ⟨b, c, hbc, hbc'⟩ :=
(mem_nhds_iff_exists_Ioo_subset' ⟨0, Ordinal.pos_iff_ne_zero.2 h₀⟩ ⟨_, lt_succ a⟩).1
(h.mem_nhds rfl)
have hba := hsucc b hbc.1
exact hba.ne (hbc' ⟨lt_succ b, hba.trans hbc.2⟩)
· rcases zero_or_succ_or_limit a with (rfl | ⟨b, rfl⟩ | ha')
· rw [← bot_eq_zero, ← Set.Iic_bot, ← Iio_succ]
exact isOpen_Iio
· rw [← Set.Icc_self, Icc_succ_left, ← Ioo_succ_right]
exact isOpen_Ioo
· exact (ha ha').elim
#align ordinal.is_open_singleton_iff Ordinal.isOpen_singleton_iff
-- Porting note (#11215): TODO: generalize to a `SuccOrder`
theorem nhds_right' (a : Ordinal) : 𝓝[>] a = ⊥ := (covBy_succ a).nhdsWithin_Ioi
-- todo: generalize to a `SuccOrder`
theorem nhds_left'_eq_nhds_ne (a : Ordinal) : 𝓝[<] a = 𝓝[≠] a := by
rw [← nhds_left'_sup_nhds_right', nhds_right', sup_bot_eq]
-- todo: generalize to a `SuccOrder`
theorem nhds_left_eq_nhds (a : Ordinal) : 𝓝[≤] a = 𝓝 a := by
rw [← nhds_left_sup_nhds_right', nhds_right', sup_bot_eq]
-- todo: generalize to a `SuccOrder`
theorem nhdsBasis_Ioc (h : a ≠ 0) : (𝓝 a).HasBasis (· < a) (Set.Ioc · a) :=
nhds_left_eq_nhds a ▸ nhdsWithin_Iic_basis' ⟨0, h.bot_lt⟩
-- todo: generalize to a `SuccOrder`
theorem nhds_eq_pure : 𝓝 a = pure a ↔ ¬IsLimit a :=
(isOpen_singleton_iff_nhds_eq_pure _).symm.trans isOpen_singleton_iff
-- todo: generalize `Ordinal.IsLimit` and this lemma to a `SuccOrder`
theorem isOpen_iff : IsOpen s ↔ ∀ o ∈ s, IsLimit o → ∃ a < o, Set.Ioo a o ⊆ s := by
refine isOpen_iff_mem_nhds.trans <| forall₂_congr fun o ho => ?_
by_cases ho' : IsLimit o
· simp only [(nhdsBasis_Ioc ho'.1).mem_iff, ho', true_implies]
refine exists_congr fun a => and_congr_right fun ha => ?_
simp only [← Set.Ioo_insert_right ha, Set.insert_subset_iff, ho, true_and]
· simp [nhds_eq_pure.2 ho', ho, ho']
#align ordinal.is_open_iff Ordinal.isOpen_iff
open List Set in
theorem mem_closure_tfae (a : Ordinal.{u}) (s : Set Ordinal) :
TFAE [a ∈ closure s,
a ∈ closure (s ∩ Iic a),
(s ∩ Iic a).Nonempty ∧ sSup (s ∩ Iic a) = a,
∃ t, t ⊆ s ∧ t.Nonempty ∧ BddAbove t ∧ sSup t = a,
∃ (o : Ordinal.{u}), o ≠ 0 ∧ ∃ (f : ∀ x < o, Ordinal),
(∀ x hx, f x hx ∈ s) ∧ bsup.{u, u} o f = a,
∃ (ι : Type u), Nonempty ι ∧ ∃ f : ι → Ordinal, (∀ i, f i ∈ s) ∧ sup.{u, u} f = a] := by
tfae_have 1 → 2
· simp only [mem_closure_iff_nhdsWithin_neBot, inter_comm s, nhdsWithin_inter', nhds_left_eq_nhds]
exact id
tfae_have 2 → 3
· intro h
rcases (s ∩ Iic a).eq_empty_or_nonempty with he | hne
· simp [he] at h
· refine ⟨hne, (isLUB_of_mem_closure ?_ h).csSup_eq hne⟩
exact fun x hx => hx.2
tfae_have 3 → 4
· exact fun h => ⟨_, inter_subset_left, h.1, bddAbove_Iic.mono inter_subset_right, h.2⟩
tfae_have 4 → 5
· rintro ⟨t, hts, hne, hbdd, rfl⟩
have hlub : IsLUB t (sSup t) := isLUB_csSup hne hbdd
let ⟨y, hyt⟩ := hne
classical
refine ⟨succ (sSup t), succ_ne_zero _, fun x _ => if x ∈ t then x else y, fun x _ => ?_, ?_⟩
· simp only
split_ifs with h <;> exact hts ‹_›
· refine le_antisymm (bsup_le fun x _ => ?_) (csSup_le hne fun x hx => ?_)
· split_ifs <;> exact hlub.1 ‹_›
· refine (if_pos hx).symm.trans_le (le_bsup _ _ <| (hlub.1 hx).trans_lt (lt_succ _))
tfae_have 5 → 6
· rintro ⟨o, h₀, f, hfs, rfl⟩
exact ⟨_, out_nonempty_iff_ne_zero.2 h₀, familyOfBFamily o f, fun _ => hfs _ _, rfl⟩
tfae_have 6 → 1
· rintro ⟨ι, hne, f, hfs, rfl⟩
rw [sup, iSup]
exact closure_mono (range_subset_iff.2 hfs) <| csSup_mem_closure (range_nonempty f)
(bddAbove_range.{u, u} f)
tfae_finish
theorem mem_closure_iff_sup :
a ∈ closure s ↔
∃ (ι : Type u) (_ : Nonempty ι) (f : ι → Ordinal), (∀ i, f i ∈ s) ∧ sup.{u, u} f = a :=
((mem_closure_tfae a s).out 0 5).trans <| by simp only [exists_prop]
#align ordinal.mem_closure_iff_sup Ordinal.mem_closure_iff_sup
theorem mem_closed_iff_sup (hs : IsClosed s) :
a ∈ s ↔ ∃ (ι : Type u) (_hι : Nonempty ι) (f : ι → Ordinal),
(∀ i, f i ∈ s) ∧ sup.{u, u} f = a := by
rw [← mem_closure_iff_sup, hs.closure_eq]
#align ordinal.mem_closed_iff_sup Ordinal.mem_closed_iff_sup
theorem mem_closure_iff_bsup :
a ∈ closure s ↔
∃ (o : Ordinal) (_ho : o ≠ 0) (f : ∀ a < o, Ordinal),
(∀ i hi, f i hi ∈ s) ∧ bsup.{u, u} o f = a :=
((mem_closure_tfae a s).out 0 4).trans <| by simp only [exists_prop]
#align ordinal.mem_closure_iff_bsup Ordinal.mem_closure_iff_bsup
theorem mem_closed_iff_bsup (hs : IsClosed s) :
a ∈ s ↔
∃ (o : Ordinal) (_ho : o ≠ 0) (f : ∀ a < o, Ordinal),
(∀ i hi, f i hi ∈ s) ∧ bsup.{u, u} o f = a := by
rw [← mem_closure_iff_bsup, hs.closure_eq]
#align ordinal.mem_closed_iff_bsup Ordinal.mem_closed_iff_bsup
theorem isClosed_iff_sup :
IsClosed s ↔
∀ {ι : Type u}, Nonempty ι → ∀ f : ι → Ordinal, (∀ i, f i ∈ s) → sup.{u, u} f ∈ s := by
use fun hs ι hι f hf => (mem_closed_iff_sup hs).2 ⟨ι, hι, f, hf, rfl⟩
rw [← closure_subset_iff_isClosed]
intro h x hx
rcases mem_closure_iff_sup.1 hx with ⟨ι, hι, f, hf, rfl⟩
exact h hι f hf
#align ordinal.is_closed_iff_sup Ordinal.isClosed_iff_sup
theorem isClosed_iff_bsup :
IsClosed s ↔
∀ {o : Ordinal}, o ≠ 0 → ∀ f : ∀ a < o, Ordinal,
(∀ i hi, f i hi ∈ s) → bsup.{u, u} o f ∈ s := by
rw [isClosed_iff_sup]
refine ⟨fun H o ho f hf => H (out_nonempty_iff_ne_zero.2 ho) _ ?_, fun H ι hι f hf => ?_⟩
· exact fun i => hf _ _
· rw [← bsup_eq_sup]
apply H (type_ne_zero_iff_nonempty.2 hι)
exact fun i hi => hf _
#align ordinal.is_closed_iff_bsup Ordinal.isClosed_iff_bsup
theorem isLimit_of_mem_frontier (ha : a ∈ frontier s) : IsLimit a := by
simp only [frontier_eq_closure_inter_closure, Set.mem_inter_iff, mem_closure_iff] at ha
by_contra h
rw [← isOpen_singleton_iff] at h
rcases ha.1 _ h rfl with ⟨b, hb, hb'⟩
rcases ha.2 _ h rfl with ⟨c, hc, hc'⟩
rw [Set.mem_singleton_iff] at *
subst hb; subst hc
exact hc' hb'
#align ordinal.is_limit_of_mem_frontier Ordinal.isLimit_of_mem_frontier
| Mathlib/SetTheory/Ordinal/Topology.lean | 185 | 205 | theorem isNormal_iff_strictMono_and_continuous (f : Ordinal.{u} → Ordinal.{u}) :
IsNormal f ↔ StrictMono f ∧ Continuous f := by |
refine ⟨fun h => ⟨h.strictMono, ?_⟩, ?_⟩
· rw [continuous_def]
intro s hs
rw [isOpen_iff] at *
intro o ho ho'
rcases hs _ ho (h.isLimit ho') with ⟨a, ha, has⟩
rw [← IsNormal.bsup_eq.{u, u} h ho', lt_bsup] at ha
rcases ha with ⟨b, hb, hab⟩
exact
⟨b, hb, fun c hc =>
Set.mem_preimage.2 (has ⟨hab.trans (h.strictMono hc.1), h.strictMono hc.2⟩)⟩
· rw [isNormal_iff_strictMono_limit]
rintro ⟨h, h'⟩
refine ⟨h, fun o ho a h => ?_⟩
suffices o ∈ f ⁻¹' Set.Iic a from Set.mem_preimage.1 this
rw [mem_closed_iff_sup (IsClosed.preimage h' (@isClosed_Iic _ _ _ _ a))]
exact
⟨_, out_nonempty_iff_ne_zero.2 ho.1, typein (· < ·), fun i => h _ (typein_lt_self i),
sup_typein_limit ho.2⟩
|
/-
Copyright (c) 2021 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Topology.Separation
#align_import topology.sober from "leanprover-community/mathlib"@"0a0ec35061ed9960bf0e7ffb0335f44447b58977"
/-!
# Sober spaces
A quasi-sober space is a topological space where every
irreducible closed subset has a generic point.
A sober space is a quasi-sober space where every irreducible closed subset
has a *unique* generic point. This is if and only if the space is T0, and thus sober spaces can be
stated via `[QuasiSober α] [T0Space α]`.
## Main definition
* `IsGenericPoint` : `x` is the generic point of `S` if `S` is the closure of `x`.
* `QuasiSober` : A space is quasi-sober if every irreducible closed subset has a generic point.
-/
open Set
variable {α β : Type*} [TopologicalSpace α] [TopologicalSpace β]
section genericPoint
/-- `x` is a generic point of `S` if `S` is the closure of `x`. -/
def IsGenericPoint (x : α) (S : Set α) : Prop :=
closure ({x} : Set α) = S
#align is_generic_point IsGenericPoint
theorem isGenericPoint_def {x : α} {S : Set α} : IsGenericPoint x S ↔ closure ({x} : Set α) = S :=
Iff.rfl
#align is_generic_point_def isGenericPoint_def
theorem IsGenericPoint.def {x : α} {S : Set α} (h : IsGenericPoint x S) :
closure ({x} : Set α) = S :=
h
#align is_generic_point.def IsGenericPoint.def
theorem isGenericPoint_closure {x : α} : IsGenericPoint x (closure ({x} : Set α)) :=
refl _
#align is_generic_point_closure isGenericPoint_closure
variable {x y : α} {S U Z : Set α}
theorem isGenericPoint_iff_specializes : IsGenericPoint x S ↔ ∀ y, x ⤳ y ↔ y ∈ S := by
simp only [specializes_iff_mem_closure, IsGenericPoint, Set.ext_iff]
#align is_generic_point_iff_specializes isGenericPoint_iff_specializes
namespace IsGenericPoint
theorem specializes_iff_mem (h : IsGenericPoint x S) : x ⤳ y ↔ y ∈ S :=
isGenericPoint_iff_specializes.1 h y
#align is_generic_point.specializes_iff_mem IsGenericPoint.specializes_iff_mem
protected theorem specializes (h : IsGenericPoint x S) (h' : y ∈ S) : x ⤳ y :=
h.specializes_iff_mem.2 h'
#align is_generic_point.specializes IsGenericPoint.specializes
protected theorem mem (h : IsGenericPoint x S) : x ∈ S :=
h.specializes_iff_mem.1 specializes_rfl
#align is_generic_point.mem IsGenericPoint.mem
protected theorem isClosed (h : IsGenericPoint x S) : IsClosed S :=
h.def ▸ isClosed_closure
#align is_generic_point.is_closed IsGenericPoint.isClosed
protected theorem isIrreducible (h : IsGenericPoint x S) : IsIrreducible S :=
h.def ▸ isIrreducible_singleton.closure
#align is_generic_point.is_irreducible IsGenericPoint.isIrreducible
protected theorem inseparable (h : IsGenericPoint x S) (h' : IsGenericPoint y S) :
Inseparable x y :=
(h.specializes h'.mem).antisymm (h'.specializes h.mem)
/-- In a T₀ space, each set has at most one generic point. -/
protected theorem eq [T0Space α] (h : IsGenericPoint x S) (h' : IsGenericPoint y S) : x = y :=
(h.inseparable h').eq
#align is_generic_point.eq IsGenericPoint.eq
theorem mem_open_set_iff (h : IsGenericPoint x S) (hU : IsOpen U) : x ∈ U ↔ (S ∩ U).Nonempty :=
⟨fun h' => ⟨x, h.mem, h'⟩, fun ⟨_y, hyS, hyU⟩ => (h.specializes hyS).mem_open hU hyU⟩
#align is_generic_point.mem_open_set_iff IsGenericPoint.mem_open_set_iff
theorem disjoint_iff (h : IsGenericPoint x S) (hU : IsOpen U) : Disjoint S U ↔ x ∉ U := by
rw [h.mem_open_set_iff hU, ← not_disjoint_iff_nonempty_inter, Classical.not_not]
#align is_generic_point.disjoint_iff IsGenericPoint.disjoint_iff
theorem mem_closed_set_iff (h : IsGenericPoint x S) (hZ : IsClosed Z) : x ∈ Z ↔ S ⊆ Z := by
rw [← h.def, hZ.closure_subset_iff, singleton_subset_iff]
#align is_generic_point.mem_closed_set_iff IsGenericPoint.mem_closed_set_iff
protected theorem image (h : IsGenericPoint x S) {f : α → β} (hf : Continuous f) :
IsGenericPoint (f x) (closure (f '' S)) := by
rw [isGenericPoint_def, ← h.def, ← image_singleton, closure_image_closure hf]
#align is_generic_point.image IsGenericPoint.image
end IsGenericPoint
theorem isGenericPoint_iff_forall_closed (hS : IsClosed S) (hxS : x ∈ S) :
IsGenericPoint x S ↔ ∀ Z : Set α, IsClosed Z → x ∈ Z → S ⊆ Z := by
have : closure {x} ⊆ S := closure_minimal (singleton_subset_iff.2 hxS) hS
simp_rw [IsGenericPoint, subset_antisymm_iff, this, true_and_iff, closure, subset_sInter_iff,
mem_setOf_eq, and_imp, singleton_subset_iff]
#align is_generic_point_iff_forall_closed isGenericPoint_iff_forall_closed
end genericPoint
section Sober
/-- A space is sober if every irreducible closed subset has a generic point. -/
@[mk_iff]
class QuasiSober (α : Type*) [TopologicalSpace α] : Prop where
sober : ∀ {S : Set α}, IsIrreducible S → IsClosed S → ∃ x, IsGenericPoint x S
#align quasi_sober QuasiSober
/-- A generic point of the closure of an irreducible space. -/
noncomputable def IsIrreducible.genericPoint [QuasiSober α] {S : Set α} (hS : IsIrreducible S) :
α :=
(QuasiSober.sober hS.closure isClosed_closure).choose
#align is_irreducible.generic_point IsIrreducible.genericPoint
theorem IsIrreducible.genericPoint_spec [QuasiSober α] {S : Set α} (hS : IsIrreducible S) :
IsGenericPoint hS.genericPoint (closure S) :=
(QuasiSober.sober hS.closure isClosed_closure).choose_spec
#align is_irreducible.generic_point_spec IsIrreducible.genericPoint_spec
@[simp]
theorem IsIrreducible.genericPoint_closure_eq [QuasiSober α] {S : Set α} (hS : IsIrreducible S) :
closure ({hS.genericPoint} : Set α) = closure S :=
hS.genericPoint_spec
#align is_irreducible.generic_point_closure_eq IsIrreducible.genericPoint_closure_eq
variable (α)
/-- A generic point of a sober irreducible space. -/
noncomputable def genericPoint [QuasiSober α] [IrreducibleSpace α] : α :=
(IrreducibleSpace.isIrreducible_univ α).genericPoint
#align generic_point genericPoint
theorem genericPoint_spec [QuasiSober α] [IrreducibleSpace α] :
IsGenericPoint (genericPoint α) ⊤ := by
simpa using (IrreducibleSpace.isIrreducible_univ α).genericPoint_spec
#align generic_point_spec genericPoint_spec
@[simp]
theorem genericPoint_closure [QuasiSober α] [IrreducibleSpace α] :
closure ({genericPoint α} : Set α) = ⊤ :=
genericPoint_spec α
#align generic_point_closure genericPoint_closure
variable {α}
theorem genericPoint_specializes [QuasiSober α] [IrreducibleSpace α] (x : α) : genericPoint α ⤳ x :=
(IsIrreducible.genericPoint_spec _).specializes (by simp)
#align generic_point_specializes genericPoint_specializes
attribute [local instance] specializationOrder
/-- The closed irreducible subsets of a sober space bijects with the points of the space. -/
noncomputable def irreducibleSetEquivPoints [QuasiSober α] [T0Space α] :
{ s : Set α | IsIrreducible s ∧ IsClosed s } ≃o α where
toFun s := s.prop.1.genericPoint
invFun x := ⟨closure ({x} : Set α), isIrreducible_singleton.closure, isClosed_closure⟩
left_inv s := Subtype.eq <| Eq.trans s.prop.1.genericPoint_spec <|
closure_eq_iff_isClosed.mpr s.2.2
right_inv x := isIrreducible_singleton.closure.genericPoint_spec.eq
(by rw [closure_closure]; exact isGenericPoint_closure)
map_rel_iff' := by
rintro ⟨s, hs⟩ ⟨t, ht⟩
refine specializes_iff_closure_subset.trans ?_
simp [hs.2.closure_eq, ht.2.closure_eq]
#align irreducible_set_equiv_points irreducibleSetEquivPoints
theorem ClosedEmbedding.quasiSober {f : α → β} (hf : ClosedEmbedding f) [QuasiSober β] :
QuasiSober α where
sober hS hS' := by
have hS'' := hS.image f hf.continuous.continuousOn
obtain ⟨x, hx⟩ := QuasiSober.sober hS'' (hf.isClosedMap _ hS')
obtain ⟨y, -, rfl⟩ := hx.mem
use y
apply image_injective.mpr hf.inj
rw [← hx.def, ← hf.closure_image_eq, image_singleton]
#align closed_embedding.quasi_sober ClosedEmbedding.quasiSober
theorem OpenEmbedding.quasiSober {f : α → β} (hf : OpenEmbedding f) [QuasiSober β] :
QuasiSober α where
sober hS hS' := by
have hS'' := hS.image f hf.continuous.continuousOn
obtain ⟨x, hx⟩ := QuasiSober.sober hS''.closure isClosed_closure
obtain ⟨T, hT, rfl⟩ := hf.toInducing.isClosed_iff.mp hS'
rw [image_preimage_eq_inter_range] at hx hS''
have hxT : x ∈ T := by
rw [← hT.closure_eq]
exact closure_mono inter_subset_left hx.mem
obtain ⟨y, rfl⟩ : x ∈ range f := by
rw [hx.mem_open_set_iff hf.isOpen_range]
refine Nonempty.mono ?_ hS''.1
simpa using subset_closure
use y
change _ = _
rw [hf.toEmbedding.closure_eq_preimage_closure_image, image_singleton, show _ = _ from hx]
apply image_injective.mpr hf.inj
ext z
simp only [image_preimage_eq_inter_range, mem_inter_iff, and_congr_left_iff]
exact fun hy => ⟨fun h => hT.closure_eq ▸ closure_mono inter_subset_left h,
fun h => subset_closure ⟨h, hy⟩⟩
#align open_embedding.quasi_sober OpenEmbedding.quasiSober
/-- A space is quasi sober if it can be covered by open quasi sober subsets. -/
| Mathlib/Topology/Sober.lean | 218 | 240 | theorem quasiSober_of_open_cover (S : Set (Set α)) (hS : ∀ s : S, IsOpen (s : Set α))
[hS' : ∀ s : S, QuasiSober s] (hS'' : ⋃₀ S = ⊤) : QuasiSober α := by |
rw [quasiSober_iff]
intro t h h'
obtain ⟨x, hx⟩ := h.1
obtain ⟨U, hU, hU'⟩ : x ∈ ⋃₀ S := by
rw [hS'']
trivial
haveI : QuasiSober U := hS' ⟨U, hU⟩
have H : IsPreirreducible ((↑) ⁻¹' t : Set U) :=
h.2.preimage (hS ⟨U, hU⟩).openEmbedding_subtype_val
replace H : IsIrreducible ((↑) ⁻¹' t : Set U) := ⟨⟨⟨x, hU'⟩, by simpa using hx⟩, H⟩
use H.genericPoint
have := continuous_subtype_val.closure_preimage_subset _ H.genericPoint_spec.mem
rw [h'.closure_eq] at this
apply le_antisymm
· apply h'.closure_subset_iff.mpr
simpa using this
rw [← image_singleton, ← closure_image_closure continuous_subtype_val, H.genericPoint_spec.def]
refine (subset_closure_inter_of_isPreirreducible_of_isOpen h.2 (hS ⟨U, hU⟩) ⟨x, hx, hU'⟩).trans
(closure_mono ?_)
rw [inter_comm t, ← Subtype.image_preimage_coe]
exact Set.image_subset _ subset_closure
|
/-
Copyright (c) 2020 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca
-/
import Mathlib.Algebra.NeZero
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.Lifts
import Mathlib.Algebra.Polynomial.Splits
import Mathlib.RingTheory.RootsOfUnity.Complex
import Mathlib.NumberTheory.ArithmeticFunction
import Mathlib.RingTheory.RootsOfUnity.Basic
import Mathlib.FieldTheory.RatFunc.AsPolynomial
#align_import ring_theory.polynomial.cyclotomic.basic from "leanprover-community/mathlib"@"7fdeecc0d03cd40f7a165e6cf00a4d2286db599f"
/-!
# Cyclotomic polynomials.
For `n : ℕ` and an integral domain `R`, we define a modified version of the `n`-th cyclotomic
polynomial with coefficients in `R`, denoted `cyclotomic' n R`, as `∏ (X - μ)`, where `μ` varies
over the primitive `n`th roots of unity. If there is a primitive `n`th root of unity in `R` then
this the standard definition. We then define the standard cyclotomic polynomial `cyclotomic n R`
with coefficients in any ring `R`.
## Main definition
* `cyclotomic n R` : the `n`-th cyclotomic polynomial with coefficients in `R`.
## Main results
* `Polynomial.degree_cyclotomic` : The degree of `cyclotomic n` is `totient n`.
* `Polynomial.prod_cyclotomic_eq_X_pow_sub_one` : `X ^ n - 1 = ∏ (cyclotomic i)`, where `i`
divides `n`.
* `Polynomial.cyclotomic_eq_prod_X_pow_sub_one_pow_moebius` : The Möbius inversion formula for
`cyclotomic n R` over an abstract fraction field for `R[X]`.
## Implementation details
Our definition of `cyclotomic' n R` makes sense in any integral domain `R`, but the interesting
results hold if there is a primitive `n`-th root of unity in `R`. In particular, our definition is
not the standard one unless there is a primitive `n`th root of unity in `R`. For example,
`cyclotomic' 3 ℤ = 1`, since there are no primitive cube roots of unity in `ℤ`. The main example is
`R = ℂ`, we decided to work in general since the difficulties are essentially the same.
To get the standard cyclotomic polynomials, we use `unique_int_coeff_of_cycl`, with `R = ℂ`,
to get a polynomial with integer coefficients and then we map it to `R[X]`, for any ring `R`.
-/
open scoped Polynomial
noncomputable section
universe u
namespace Polynomial
section Cyclotomic'
section IsDomain
variable {R : Type*} [CommRing R] [IsDomain R]
/-- The modified `n`-th cyclotomic polynomial with coefficients in `R`, it is the usual cyclotomic
polynomial if there is a primitive `n`-th root of unity in `R`. -/
def cyclotomic' (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : R[X] :=
∏ μ ∈ primitiveRoots n R, (X - C μ)
#align polynomial.cyclotomic' Polynomial.cyclotomic'
/-- The zeroth modified cyclotomic polyomial is `1`. -/
@[simp]
theorem cyclotomic'_zero (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 0 R = 1 := by
simp only [cyclotomic', Finset.prod_empty, primitiveRoots_zero]
#align polynomial.cyclotomic'_zero Polynomial.cyclotomic'_zero
/-- The first modified cyclotomic polyomial is `X - 1`. -/
@[simp]
theorem cyclotomic'_one (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' 1 R = X - 1 := by
simp only [cyclotomic', Finset.prod_singleton, RingHom.map_one,
IsPrimitiveRoot.primitiveRoots_one]
#align polynomial.cyclotomic'_one Polynomial.cyclotomic'_one
/-- The second modified cyclotomic polyomial is `X + 1` if the characteristic of `R` is not `2`. -/
@[simp]
theorem cyclotomic'_two (R : Type*) [CommRing R] [IsDomain R] (p : ℕ) [CharP R p] (hp : p ≠ 2) :
cyclotomic' 2 R = X + 1 := by
rw [cyclotomic']
have prim_root_two : primitiveRoots 2 R = {(-1 : R)} := by
simp only [Finset.eq_singleton_iff_unique_mem, mem_primitiveRoots two_pos]
exact ⟨IsPrimitiveRoot.neg_one p hp, fun x => IsPrimitiveRoot.eq_neg_one_of_two_right⟩
simp only [prim_root_two, Finset.prod_singleton, RingHom.map_neg, RingHom.map_one, sub_neg_eq_add]
#align polynomial.cyclotomic'_two Polynomial.cyclotomic'_two
/-- `cyclotomic' n R` is monic. -/
theorem cyclotomic'.monic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
(cyclotomic' n R).Monic :=
monic_prod_of_monic _ _ fun _ _ => monic_X_sub_C _
#align polynomial.cyclotomic'.monic Polynomial.cyclotomic'.monic
/-- `cyclotomic' n R` is different from `0`. -/
theorem cyclotomic'_ne_zero (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] : cyclotomic' n R ≠ 0 :=
(cyclotomic'.monic n R).ne_zero
#align polynomial.cyclotomic'_ne_zero Polynomial.cyclotomic'_ne_zero
/-- The natural degree of `cyclotomic' n R` is `totient n` if there is a primitive root of
unity in `R`. -/
theorem natDegree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
(cyclotomic' n R).natDegree = Nat.totient n := by
rw [cyclotomic']
rw [natDegree_prod (primitiveRoots n R) fun z : R => X - C z]
· simp only [IsPrimitiveRoot.card_primitiveRoots h, mul_one, natDegree_X_sub_C, Nat.cast_id,
Finset.sum_const, nsmul_eq_mul]
intro z _
exact X_sub_C_ne_zero z
#align polynomial.nat_degree_cyclotomic' Polynomial.natDegree_cyclotomic'
/-- The degree of `cyclotomic' n R` is `totient n` if there is a primitive root of unity in `R`. -/
theorem degree_cyclotomic' {ζ : R} {n : ℕ} (h : IsPrimitiveRoot ζ n) :
(cyclotomic' n R).degree = Nat.totient n := by
simp only [degree_eq_natDegree (cyclotomic'_ne_zero n R), natDegree_cyclotomic' h]
#align polynomial.degree_cyclotomic' Polynomial.degree_cyclotomic'
/-- The roots of `cyclotomic' n R` are the primitive `n`-th roots of unity. -/
| Mathlib/RingTheory/Polynomial/Cyclotomic/Basic.lean | 124 | 126 | theorem roots_of_cyclotomic (n : ℕ) (R : Type*) [CommRing R] [IsDomain R] :
(cyclotomic' n R).roots = (primitiveRoots n R).val := by |
rw [cyclotomic']; exact roots_prod_X_sub_C (primitiveRoots n R)
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl, Mario Carneiro
-/
import Mathlib.MeasureTheory.Measure.Restrict
/-!
# Classes of measures
We introduce the following typeclasses for measures:
* `IsProbabilityMeasure μ`: `μ univ = 1`;
* `IsFiniteMeasure μ`: `μ univ < ∞`;
* `SigmaFinite μ`: there exists a countable collection of sets that cover `univ`
where `μ` is finite;
* `SFinite μ`: the measure `μ` can be written as a countable sum of finite measures;
* `IsLocallyFiniteMeasure μ` : `∀ x, ∃ s ∈ 𝓝 x, μ s < ∞`;
* `NoAtoms μ` : `∀ x, μ {x} = 0`; possibly should be redefined as
`∀ s, 0 < μ s → ∃ t ⊆ s, 0 < μ t ∧ μ t < μ s`.
-/
open scoped ENNReal NNReal Topology
open Set MeasureTheory Measure Filter Function MeasurableSpace ENNReal
variable {α β δ ι : Type*}
namespace MeasureTheory
variable {m0 : MeasurableSpace α} [MeasurableSpace β] {μ ν ν₁ ν₂: Measure α}
{s t : Set α}
section IsFiniteMeasure
/-- A measure `μ` is called finite if `μ univ < ∞`. -/
class IsFiniteMeasure (μ : Measure α) : Prop where
measure_univ_lt_top : μ univ < ∞
#align measure_theory.is_finite_measure MeasureTheory.IsFiniteMeasure
#align measure_theory.is_finite_measure.measure_univ_lt_top MeasureTheory.IsFiniteMeasure.measure_univ_lt_top
theorem not_isFiniteMeasure_iff : ¬IsFiniteMeasure μ ↔ μ Set.univ = ∞ := by
refine ⟨fun h => ?_, fun h => fun h' => h'.measure_univ_lt_top.ne h⟩
by_contra h'
exact h ⟨lt_top_iff_ne_top.mpr h'⟩
#align measure_theory.not_is_finite_measure_iff MeasureTheory.not_isFiniteMeasure_iff
instance Restrict.isFiniteMeasure (μ : Measure α) [hs : Fact (μ s < ∞)] :
IsFiniteMeasure (μ.restrict s) :=
⟨by simpa using hs.elim⟩
#align measure_theory.restrict.is_finite_measure MeasureTheory.Restrict.isFiniteMeasure
theorem measure_lt_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s < ∞ :=
(measure_mono (subset_univ s)).trans_lt IsFiniteMeasure.measure_univ_lt_top
#align measure_theory.measure_lt_top MeasureTheory.measure_lt_top
instance isFiniteMeasureRestrict (μ : Measure α) (s : Set α) [h : IsFiniteMeasure μ] :
IsFiniteMeasure (μ.restrict s) :=
⟨by simpa using measure_lt_top μ s⟩
#align measure_theory.is_finite_measure_restrict MeasureTheory.isFiniteMeasureRestrict
theorem measure_ne_top (μ : Measure α) [IsFiniteMeasure μ] (s : Set α) : μ s ≠ ∞ :=
ne_of_lt (measure_lt_top μ s)
#align measure_theory.measure_ne_top MeasureTheory.measure_ne_top
theorem measure_compl_le_add_of_le_add [IsFiniteMeasure μ] (hs : MeasurableSet s)
(ht : MeasurableSet t) {ε : ℝ≥0∞} (h : μ s ≤ μ t + ε) : μ tᶜ ≤ μ sᶜ + ε := by
rw [measure_compl ht (measure_ne_top μ _), measure_compl hs (measure_ne_top μ _),
tsub_le_iff_right]
calc
μ univ = μ univ - μ s + μ s := (tsub_add_cancel_of_le <| measure_mono s.subset_univ).symm
_ ≤ μ univ - μ s + (μ t + ε) := add_le_add_left h _
_ = _ := by rw [add_right_comm, add_assoc]
#align measure_theory.measure_compl_le_add_of_le_add MeasureTheory.measure_compl_le_add_of_le_add
theorem measure_compl_le_add_iff [IsFiniteMeasure μ] (hs : MeasurableSet s) (ht : MeasurableSet t)
{ε : ℝ≥0∞} : μ sᶜ ≤ μ tᶜ + ε ↔ μ t ≤ μ s + ε :=
⟨fun h => compl_compl s ▸ compl_compl t ▸ measure_compl_le_add_of_le_add hs.compl ht.compl h,
measure_compl_le_add_of_le_add ht hs⟩
#align measure_theory.measure_compl_le_add_iff MeasureTheory.measure_compl_le_add_iff
/-- The measure of the whole space with respect to a finite measure, considered as `ℝ≥0`. -/
def measureUnivNNReal (μ : Measure α) : ℝ≥0 :=
(μ univ).toNNReal
#align measure_theory.measure_univ_nnreal MeasureTheory.measureUnivNNReal
@[simp]
theorem coe_measureUnivNNReal (μ : Measure α) [IsFiniteMeasure μ] :
↑(measureUnivNNReal μ) = μ univ :=
ENNReal.coe_toNNReal (measure_ne_top μ univ)
#align measure_theory.coe_measure_univ_nnreal MeasureTheory.coe_measureUnivNNReal
instance isFiniteMeasureZero : IsFiniteMeasure (0 : Measure α) :=
⟨by simp⟩
#align measure_theory.is_finite_measure_zero MeasureTheory.isFiniteMeasureZero
instance (priority := 50) isFiniteMeasureOfIsEmpty [IsEmpty α] : IsFiniteMeasure μ := by
rw [eq_zero_of_isEmpty μ]
infer_instance
#align measure_theory.is_finite_measure_of_is_empty MeasureTheory.isFiniteMeasureOfIsEmpty
@[simp]
theorem measureUnivNNReal_zero : measureUnivNNReal (0 : Measure α) = 0 :=
rfl
#align measure_theory.measure_univ_nnreal_zero MeasureTheory.measureUnivNNReal_zero
instance isFiniteMeasureAdd [IsFiniteMeasure μ] [IsFiniteMeasure ν] : IsFiniteMeasure (μ + ν) where
measure_univ_lt_top := by
rw [Measure.coe_add, Pi.add_apply, ENNReal.add_lt_top]
exact ⟨measure_lt_top _ _, measure_lt_top _ _⟩
#align measure_theory.is_finite_measure_add MeasureTheory.isFiniteMeasureAdd
instance isFiniteMeasureSMulNNReal [IsFiniteMeasure μ] {r : ℝ≥0} : IsFiniteMeasure (r • μ) where
measure_univ_lt_top := ENNReal.mul_lt_top ENNReal.coe_ne_top (measure_ne_top _ _)
#align measure_theory.is_finite_measure_smul_nnreal MeasureTheory.isFiniteMeasureSMulNNReal
instance IsFiniteMeasure.average : IsFiniteMeasure ((μ univ)⁻¹ • μ) where
measure_univ_lt_top := by
rw [smul_apply, smul_eq_mul, ← ENNReal.div_eq_inv_mul]
exact ENNReal.div_self_le_one.trans_lt ENNReal.one_lt_top
instance isFiniteMeasureSMulOfNNRealTower {R} [SMul R ℝ≥0] [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0 ℝ≥0∞]
[IsScalarTower R ℝ≥0∞ ℝ≥0∞] [IsFiniteMeasure μ] {r : R} : IsFiniteMeasure (r • μ) := by
rw [← smul_one_smul ℝ≥0 r μ]
infer_instance
#align measure_theory.is_finite_measure_smul_of_nnreal_tower MeasureTheory.isFiniteMeasureSMulOfNNRealTower
theorem isFiniteMeasure_of_le (μ : Measure α) [IsFiniteMeasure μ] (h : ν ≤ μ) : IsFiniteMeasure ν :=
{ measure_univ_lt_top := (h Set.univ).trans_lt (measure_lt_top _ _) }
#align measure_theory.is_finite_measure_of_le MeasureTheory.isFiniteMeasure_of_le
@[instance]
theorem Measure.isFiniteMeasure_map {m : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ]
(f : α → β) : IsFiniteMeasure (μ.map f) := by
by_cases hf : AEMeasurable f μ
· constructor
rw [map_apply_of_aemeasurable hf MeasurableSet.univ]
exact measure_lt_top μ _
· rw [map_of_not_aemeasurable hf]
exact MeasureTheory.isFiniteMeasureZero
#align measure_theory.measure.is_finite_measure_map MeasureTheory.Measure.isFiniteMeasure_map
@[simp]
theorem measureUnivNNReal_eq_zero [IsFiniteMeasure μ] : measureUnivNNReal μ = 0 ↔ μ = 0 := by
rw [← MeasureTheory.Measure.measure_univ_eq_zero, ← coe_measureUnivNNReal]
norm_cast
#align measure_theory.measure_univ_nnreal_eq_zero MeasureTheory.measureUnivNNReal_eq_zero
theorem measureUnivNNReal_pos [IsFiniteMeasure μ] (hμ : μ ≠ 0) : 0 < measureUnivNNReal μ := by
contrapose! hμ
simpa [measureUnivNNReal_eq_zero, Nat.le_zero] using hμ
#align measure_theory.measure_univ_nnreal_pos MeasureTheory.measureUnivNNReal_pos
/-- `le_of_add_le_add_left` is normally applicable to `OrderedCancelAddCommMonoid`,
but it holds for measures with the additional assumption that μ is finite. -/
theorem Measure.le_of_add_le_add_left [IsFiniteMeasure μ] (A2 : μ + ν₁ ≤ μ + ν₂) : ν₁ ≤ ν₂ :=
fun S => ENNReal.le_of_add_le_add_left (MeasureTheory.measure_ne_top μ S) (A2 S)
#align measure_theory.measure.le_of_add_le_add_left MeasureTheory.Measure.le_of_add_le_add_left
theorem summable_measure_toReal [hμ : IsFiniteMeasure μ] {f : ℕ → Set α}
(hf₁ : ∀ i : ℕ, MeasurableSet (f i)) (hf₂ : Pairwise (Disjoint on f)) :
Summable fun x => (μ (f x)).toReal := by
apply ENNReal.summable_toReal
rw [← MeasureTheory.measure_iUnion hf₂ hf₁]
exact ne_of_lt (measure_lt_top _ _)
#align measure_theory.summable_measure_to_real MeasureTheory.summable_measure_toReal
theorem ae_eq_univ_iff_measure_eq [IsFiniteMeasure μ] (hs : NullMeasurableSet s μ) :
s =ᵐ[μ] univ ↔ μ s = μ univ := by
refine ⟨measure_congr, fun h => ?_⟩
obtain ⟨t, -, ht₁, ht₂⟩ := hs.exists_measurable_subset_ae_eq
exact
ht₂.symm.trans
(ae_eq_of_subset_of_measure_ge (subset_univ t) (Eq.le ((measure_congr ht₂).trans h).symm) ht₁
(measure_ne_top μ univ))
#align measure_theory.ae_eq_univ_iff_measure_eq MeasureTheory.ae_eq_univ_iff_measure_eq
theorem ae_iff_measure_eq [IsFiniteMeasure μ] {p : α → Prop}
(hp : NullMeasurableSet { a | p a } μ) : (∀ᵐ a ∂μ, p a) ↔ μ { a | p a } = μ univ := by
rw [← ae_eq_univ_iff_measure_eq hp, eventuallyEq_univ, eventually_iff]
#align measure_theory.ae_iff_measure_eq MeasureTheory.ae_iff_measure_eq
theorem ae_mem_iff_measure_eq [IsFiniteMeasure μ] {s : Set α} (hs : NullMeasurableSet s μ) :
(∀ᵐ a ∂μ, a ∈ s) ↔ μ s = μ univ :=
ae_iff_measure_eq hs
#align measure_theory.ae_mem_iff_measure_eq MeasureTheory.ae_mem_iff_measure_eq
lemma tendsto_measure_biUnion_Ici_zero_of_pairwise_disjoint
{X : Type*} [MeasurableSpace X] {μ : Measure X} [IsFiniteMeasure μ]
{Es : ℕ → Set X} (Es_mble : ∀ i, MeasurableSet (Es i))
(Es_disj : Pairwise fun n m ↦ Disjoint (Es n) (Es m)) :
Tendsto (μ ∘ fun n ↦ ⋃ i ≥ n, Es i) atTop (𝓝 0) := by
have decr : Antitone fun n ↦ ⋃ i ≥ n, Es i :=
fun n m hnm ↦ biUnion_mono (fun _ hi ↦ le_trans hnm hi) (fun _ _ ↦ subset_rfl)
have nothing : ⋂ n, ⋃ i ≥ n, Es i = ∅ := by
apply subset_antisymm _ (empty_subset _)
intro x hx
simp only [ge_iff_le, mem_iInter, mem_iUnion, exists_prop] at hx
obtain ⟨j, _, x_in_Es_j⟩ := hx 0
obtain ⟨k, k_gt_j, x_in_Es_k⟩ := hx (j+1)
have oops := (Es_disj (Nat.ne_of_lt k_gt_j)).ne_of_mem x_in_Es_j x_in_Es_k
contradiction
have key :=
tendsto_measure_iInter (μ := μ) (fun n ↦ by measurability) decr ⟨0, measure_ne_top _ _⟩
simp only [ge_iff_le, nothing, measure_empty] at key
convert key
open scoped symmDiff
theorem abs_toReal_measure_sub_le_measure_symmDiff'
(hs : MeasurableSet s) (ht : MeasurableSet t) (hs' : μ s ≠ ∞) (ht' : μ t ≠ ∞) :
|(μ s).toReal - (μ t).toReal| ≤ (μ (s ∆ t)).toReal := by
have hst : μ (s \ t) ≠ ∞ := (measure_lt_top_of_subset diff_subset hs').ne
have hts : μ (t \ s) ≠ ∞ := (measure_lt_top_of_subset diff_subset ht').ne
suffices (μ s).toReal - (μ t).toReal = (μ (s \ t)).toReal - (μ (t \ s)).toReal by
rw [this, measure_symmDiff_eq hs ht, ENNReal.toReal_add hst hts]
convert abs_sub (μ (s \ t)).toReal (μ (t \ s)).toReal <;> simp
rw [measure_diff' s ht ht', measure_diff' t hs hs',
ENNReal.toReal_sub_of_le measure_le_measure_union_right (measure_union_ne_top hs' ht'),
ENNReal.toReal_sub_of_le measure_le_measure_union_right (measure_union_ne_top ht' hs'),
union_comm t s]
abel
theorem abs_toReal_measure_sub_le_measure_symmDiff [IsFiniteMeasure μ]
(hs : MeasurableSet s) (ht : MeasurableSet t) :
|(μ s).toReal - (μ t).toReal| ≤ (μ (s ∆ t)).toReal :=
abs_toReal_measure_sub_le_measure_symmDiff' hs ht (measure_ne_top μ s) (measure_ne_top μ t)
end IsFiniteMeasure
section IsProbabilityMeasure
/-- A measure `μ` is called a probability measure if `μ univ = 1`. -/
class IsProbabilityMeasure (μ : Measure α) : Prop where
measure_univ : μ univ = 1
#align measure_theory.is_probability_measure MeasureTheory.IsProbabilityMeasure
#align measure_theory.is_probability_measure.measure_univ MeasureTheory.IsProbabilityMeasure.measure_univ
export MeasureTheory.IsProbabilityMeasure (measure_univ)
attribute [simp] IsProbabilityMeasure.measure_univ
lemma isProbabilityMeasure_iff : IsProbabilityMeasure μ ↔ μ univ = 1 :=
⟨fun _ ↦ measure_univ, IsProbabilityMeasure.mk⟩
instance (priority := 100) IsProbabilityMeasure.toIsFiniteMeasure (μ : Measure α)
[IsProbabilityMeasure μ] : IsFiniteMeasure μ :=
⟨by simp only [measure_univ, ENNReal.one_lt_top]⟩
#align measure_theory.is_probability_measure.to_is_finite_measure MeasureTheory.IsProbabilityMeasure.toIsFiniteMeasure
theorem IsProbabilityMeasure.ne_zero (μ : Measure α) [IsProbabilityMeasure μ] : μ ≠ 0 :=
mt measure_univ_eq_zero.2 <| by simp [measure_univ]
#align measure_theory.is_probability_measure.ne_zero MeasureTheory.IsProbabilityMeasure.ne_zero
instance (priority := 100) IsProbabilityMeasure.neZero (μ : Measure α) [IsProbabilityMeasure μ] :
NeZero μ := ⟨IsProbabilityMeasure.ne_zero μ⟩
-- Porting note: no longer an `instance` because `inferInstance` can find it now
theorem IsProbabilityMeasure.ae_neBot [IsProbabilityMeasure μ] : NeBot (ae μ) := inferInstance
#align measure_theory.is_probability_measure.ae_ne_bot MeasureTheory.IsProbabilityMeasure.ae_neBot
theorem prob_add_prob_compl [IsProbabilityMeasure μ] (h : MeasurableSet s) : μ s + μ sᶜ = 1 :=
(measure_add_measure_compl h).trans measure_univ
#align measure_theory.prob_add_prob_compl MeasureTheory.prob_add_prob_compl
theorem prob_le_one [IsProbabilityMeasure μ] : μ s ≤ 1 :=
(measure_mono <| Set.subset_univ _).trans_eq measure_univ
#align measure_theory.prob_le_one MeasureTheory.prob_le_one
-- Porting note: made an `instance`, using `NeZero`
instance isProbabilityMeasureSMul [IsFiniteMeasure μ] [NeZero μ] :
IsProbabilityMeasure ((μ univ)⁻¹ • μ) :=
⟨ENNReal.inv_mul_cancel (NeZero.ne (μ univ)) (measure_ne_top _ _)⟩
#align measure_theory.is_probability_measure_smul MeasureTheory.isProbabilityMeasureSMulₓ
variable [IsProbabilityMeasure μ] {p : α → Prop} {f : β → α}
theorem isProbabilityMeasure_map {f : α → β} (hf : AEMeasurable f μ) :
IsProbabilityMeasure (map f μ) :=
⟨by simp [map_apply_of_aemeasurable, hf]⟩
#align measure_theory.is_probability_measure_map MeasureTheory.isProbabilityMeasure_map
@[simp]
theorem one_le_prob_iff : 1 ≤ μ s ↔ μ s = 1 :=
⟨fun h => le_antisymm prob_le_one h, fun h => h ▸ le_refl _⟩
#align measure_theory.one_le_prob_iff MeasureTheory.one_le_prob_iff
/-- Note that this is not quite as useful as it looks because the measure takes values in `ℝ≥0∞`.
Thus the subtraction appearing is the truncated subtraction of `ℝ≥0∞`, rather than the
better-behaved subtraction of `ℝ`. -/
lemma prob_compl_eq_one_sub₀ (h : NullMeasurableSet s μ) : μ sᶜ = 1 - μ s := by
rw [measure_compl₀ h (measure_ne_top _ _), measure_univ]
/-- Note that this is not quite as useful as it looks because the measure takes values in `ℝ≥0∞`.
Thus the subtraction appearing is the truncated subtraction of `ℝ≥0∞`, rather than the
better-behaved subtraction of `ℝ`. -/
theorem prob_compl_eq_one_sub (hs : MeasurableSet s) : μ sᶜ = 1 - μ s :=
prob_compl_eq_one_sub₀ hs.nullMeasurableSet
#align measure_theory.prob_compl_eq_one_sub MeasureTheory.prob_compl_eq_one_sub
lemma prob_compl_lt_one_sub_of_lt_prob {p : ℝ≥0∞} (hμs : p < μ s) (s_mble : MeasurableSet s) :
μ sᶜ < 1 - p := by
rw [prob_compl_eq_one_sub s_mble]
apply ENNReal.sub_lt_of_sub_lt prob_le_one (Or.inl one_ne_top)
convert hμs
exact ENNReal.sub_sub_cancel one_ne_top (lt_of_lt_of_le hμs prob_le_one).le
lemma prob_compl_le_one_sub_of_le_prob {p : ℝ≥0∞} (hμs : p ≤ μ s) (s_mble : MeasurableSet s) :
μ sᶜ ≤ 1 - p := by
simpa [prob_compl_eq_one_sub s_mble] using tsub_le_tsub_left hμs 1
@[simp] lemma prob_compl_eq_zero_iff₀ (hs : NullMeasurableSet s μ) : μ sᶜ = 0 ↔ μ s = 1 := by
rw [prob_compl_eq_one_sub₀ hs, tsub_eq_zero_iff_le, one_le_prob_iff]
@[simp] lemma prob_compl_eq_zero_iff (hs : MeasurableSet s) : μ sᶜ = 0 ↔ μ s = 1 :=
prob_compl_eq_zero_iff₀ hs.nullMeasurableSet
#align measure_theory.prob_compl_eq_zero_iff MeasureTheory.prob_compl_eq_zero_iff
@[simp] lemma prob_compl_eq_one_iff₀ (hs : NullMeasurableSet s μ) : μ sᶜ = 1 ↔ μ s = 0 := by
rw [← prob_compl_eq_zero_iff₀ hs.compl, compl_compl]
@[simp] lemma prob_compl_eq_one_iff (hs : MeasurableSet s) : μ sᶜ = 1 ↔ μ s = 0 :=
prob_compl_eq_one_iff₀ hs.nullMeasurableSet
#align measure_theory.prob_compl_eq_one_iff MeasureTheory.prob_compl_eq_one_iff
lemma mem_ae_iff_prob_eq_one₀ (hs : NullMeasurableSet s μ) : s ∈ ae μ ↔ μ s = 1 :=
mem_ae_iff.trans <| prob_compl_eq_zero_iff₀ hs
lemma mem_ae_iff_prob_eq_one (hs : MeasurableSet s) : s ∈ ae μ ↔ μ s = 1 :=
mem_ae_iff.trans <| prob_compl_eq_zero_iff hs
lemma ae_iff_prob_eq_one (hp : Measurable p) : (∀ᵐ a ∂μ, p a) ↔ μ {a | p a} = 1 :=
mem_ae_iff_prob_eq_one hp.setOf
lemma isProbabilityMeasure_comap (hf : Injective f) (hf' : ∀ᵐ a ∂μ, a ∈ range f)
(hf'' : ∀ s, MeasurableSet s → MeasurableSet (f '' s)) :
IsProbabilityMeasure (μ.comap f) where
measure_univ := by
rw [comap_apply _ hf hf'' _ MeasurableSet.univ,
← mem_ae_iff_prob_eq_one (hf'' _ MeasurableSet.univ)]
simpa
protected lemma _root_.MeasurableEmbedding.isProbabilityMeasure_comap (hf : MeasurableEmbedding f)
(hf' : ∀ᵐ a ∂μ, a ∈ range f) : IsProbabilityMeasure (μ.comap f) :=
isProbabilityMeasure_comap hf.injective hf' hf.measurableSet_image'
instance isProbabilityMeasure_map_up :
IsProbabilityMeasure (μ.map ULift.up) := isProbabilityMeasure_map measurable_up.aemeasurable
instance isProbabilityMeasure_comap_down : IsProbabilityMeasure (μ.comap ULift.down) :=
MeasurableEquiv.ulift.measurableEmbedding.isProbabilityMeasure_comap <| ae_of_all _ <| by
simp [Function.Surjective.range_eq <| EquivLike.surjective _]
end IsProbabilityMeasure
section NoAtoms
/-- Measure `μ` *has no atoms* if the measure of each singleton is zero.
NB: Wikipedia assumes that for any measurable set `s` with positive `μ`-measure,
there exists a measurable `t ⊆ s` such that `0 < μ t < μ s`. While this implies `μ {x} = 0`,
the converse is not true. -/
class NoAtoms {m0 : MeasurableSpace α} (μ : Measure α) : Prop where
measure_singleton : ∀ x, μ {x} = 0
#align measure_theory.has_no_atoms MeasureTheory.NoAtoms
#align measure_theory.has_no_atoms.measure_singleton MeasureTheory.NoAtoms.measure_singleton
export MeasureTheory.NoAtoms (measure_singleton)
attribute [simp] measure_singleton
variable [NoAtoms μ]
theorem _root_.Set.Subsingleton.measure_zero (hs : s.Subsingleton) (μ : Measure α) [NoAtoms μ] :
μ s = 0 :=
hs.induction_on (p := fun s => μ s = 0) measure_empty measure_singleton
#align set.subsingleton.measure_zero Set.Subsingleton.measure_zero
theorem Measure.restrict_singleton' {a : α} : μ.restrict {a} = 0 := by
simp only [measure_singleton, Measure.restrict_eq_zero]
#align measure_theory.measure.restrict_singleton' MeasureTheory.Measure.restrict_singleton'
instance Measure.restrict.instNoAtoms (s : Set α) : NoAtoms (μ.restrict s) := by
refine ⟨fun x => ?_⟩
obtain ⟨t, hxt, ht1, ht2⟩ := exists_measurable_superset_of_null (measure_singleton x : μ {x} = 0)
apply measure_mono_null hxt
rw [Measure.restrict_apply ht1]
apply measure_mono_null inter_subset_left ht2
#align measure_theory.measure.restrict.has_no_atoms MeasureTheory.Measure.restrict.instNoAtoms
theorem _root_.Set.Countable.measure_zero (h : s.Countable) (μ : Measure α) [NoAtoms μ] :
μ s = 0 := by
rw [← biUnion_of_singleton s, measure_biUnion_null_iff h]
simp
#align set.countable.measure_zero Set.Countable.measure_zero
theorem _root_.Set.Countable.ae_not_mem (h : s.Countable) (μ : Measure α) [NoAtoms μ] :
∀ᵐ x ∂μ, x ∉ s := by
simpa only [ae_iff, Classical.not_not] using h.measure_zero μ
#align set.countable.ae_not_mem Set.Countable.ae_not_mem
lemma _root_.Set.Countable.measure_restrict_compl (h : s.Countable) (μ : Measure α) [NoAtoms μ] :
μ.restrict sᶜ = μ :=
restrict_eq_self_of_ae_mem <| h.ae_not_mem μ
@[simp]
lemma restrict_compl_singleton (a : α) : μ.restrict ({a}ᶜ) = μ :=
(countable_singleton _).measure_restrict_compl μ
theorem _root_.Set.Finite.measure_zero (h : s.Finite) (μ : Measure α) [NoAtoms μ] : μ s = 0 :=
h.countable.measure_zero μ
#align set.finite.measure_zero Set.Finite.measure_zero
theorem _root_.Finset.measure_zero (s : Finset α) (μ : Measure α) [NoAtoms μ] : μ s = 0 :=
s.finite_toSet.measure_zero μ
#align finset.measure_zero Finset.measure_zero
theorem insert_ae_eq_self (a : α) (s : Set α) : (insert a s : Set α) =ᵐ[μ] s :=
union_ae_eq_right.2 <| measure_mono_null diff_subset (measure_singleton _)
#align measure_theory.insert_ae_eq_self MeasureTheory.insert_ae_eq_self
section
variable [PartialOrder α] {a b : α}
theorem Iio_ae_eq_Iic : Iio a =ᵐ[μ] Iic a :=
Iio_ae_eq_Iic' (measure_singleton a)
#align measure_theory.Iio_ae_eq_Iic MeasureTheory.Iio_ae_eq_Iic
theorem Ioi_ae_eq_Ici : Ioi a =ᵐ[μ] Ici a :=
Ioi_ae_eq_Ici' (measure_singleton a)
#align measure_theory.Ioi_ae_eq_Ici MeasureTheory.Ioi_ae_eq_Ici
theorem Ioo_ae_eq_Ioc : Ioo a b =ᵐ[μ] Ioc a b :=
Ioo_ae_eq_Ioc' (measure_singleton b)
#align measure_theory.Ioo_ae_eq_Ioc MeasureTheory.Ioo_ae_eq_Ioc
theorem Ioc_ae_eq_Icc : Ioc a b =ᵐ[μ] Icc a b :=
Ioc_ae_eq_Icc' (measure_singleton a)
#align measure_theory.Ioc_ae_eq_Icc MeasureTheory.Ioc_ae_eq_Icc
theorem Ioo_ae_eq_Ico : Ioo a b =ᵐ[μ] Ico a b :=
Ioo_ae_eq_Ico' (measure_singleton a)
#align measure_theory.Ioo_ae_eq_Ico MeasureTheory.Ioo_ae_eq_Ico
theorem Ioo_ae_eq_Icc : Ioo a b =ᵐ[μ] Icc a b :=
Ioo_ae_eq_Icc' (measure_singleton a) (measure_singleton b)
#align measure_theory.Ioo_ae_eq_Icc MeasureTheory.Ioo_ae_eq_Icc
theorem Ico_ae_eq_Icc : Ico a b =ᵐ[μ] Icc a b :=
Ico_ae_eq_Icc' (measure_singleton b)
#align measure_theory.Ico_ae_eq_Icc MeasureTheory.Ico_ae_eq_Icc
theorem Ico_ae_eq_Ioc : Ico a b =ᵐ[μ] Ioc a b :=
Ico_ae_eq_Ioc' (measure_singleton a) (measure_singleton b)
#align measure_theory.Ico_ae_eq_Ioc MeasureTheory.Ico_ae_eq_Ioc
theorem restrict_Iio_eq_restrict_Iic : μ.restrict (Iio a) = μ.restrict (Iic a) :=
restrict_congr_set Iio_ae_eq_Iic
theorem restrict_Ioi_eq_restrict_Ici : μ.restrict (Ioi a) = μ.restrict (Ici a) :=
restrict_congr_set Ioi_ae_eq_Ici
theorem restrict_Ioo_eq_restrict_Ioc : μ.restrict (Ioo a b) = μ.restrict (Ioc a b) :=
restrict_congr_set Ioo_ae_eq_Ioc
theorem restrict_Ioc_eq_restrict_Icc : μ.restrict (Ioc a b) = μ.restrict (Icc a b) :=
restrict_congr_set Ioc_ae_eq_Icc
theorem restrict_Ioo_eq_restrict_Ico : μ.restrict (Ioo a b) = μ.restrict (Ico a b) :=
restrict_congr_set Ioo_ae_eq_Ico
theorem restrict_Ioo_eq_restrict_Icc : μ.restrict (Ioo a b) = μ.restrict (Icc a b) :=
restrict_congr_set Ioo_ae_eq_Icc
theorem restrict_Ico_eq_restrict_Icc : μ.restrict (Ico a b) = μ.restrict (Icc a b) :=
restrict_congr_set Ico_ae_eq_Icc
theorem restrict_Ico_eq_restrict_Ioc : μ.restrict (Ico a b) = μ.restrict (Ioc a b) :=
restrict_congr_set Ico_ae_eq_Ioc
end
open Interval
theorem uIoc_ae_eq_interval [LinearOrder α] {a b : α} : Ι a b =ᵐ[μ] [[a, b]] :=
Ioc_ae_eq_Icc
#align measure_theory.uIoc_ae_eq_interval MeasureTheory.uIoc_ae_eq_interval
end NoAtoms
theorem ite_ae_eq_of_measure_zero {γ} (f : α → γ) (g : α → γ) (s : Set α) [DecidablePred (· ∈ s)]
(hs_zero : μ s = 0) :
(fun x => ite (x ∈ s) (f x) (g x)) =ᵐ[μ] g := by
have h_ss : sᶜ ⊆ { a : α | ite (a ∈ s) (f a) (g a) = g a } := fun x hx => by
simp [(Set.mem_compl_iff _ _).mp hx]
refine measure_mono_null ?_ hs_zero
conv_rhs => rw [← compl_compl s]
rwa [Set.compl_subset_compl]
#align measure_theory.ite_ae_eq_of_measure_zero MeasureTheory.ite_ae_eq_of_measure_zero
theorem ite_ae_eq_of_measure_compl_zero {γ} (f : α → γ) (g : α → γ)
(s : Set α) [DecidablePred (· ∈ s)] (hs_zero : μ sᶜ = 0) :
(fun x => ite (x ∈ s) (f x) (g x)) =ᵐ[μ] f := by
rw [← mem_ae_iff] at hs_zero
filter_upwards [hs_zero]
intros
split_ifs
rfl
#align measure_theory.ite_ae_eq_of_measure_compl_zero MeasureTheory.ite_ae_eq_of_measure_compl_zero
namespace Measure
/-- A measure is called finite at filter `f` if it is finite at some set `s ∈ f`.
Equivalently, it is eventually finite at `s` in `f.small_sets`. -/
def FiniteAtFilter {_m0 : MeasurableSpace α} (μ : Measure α) (f : Filter α) : Prop :=
∃ s ∈ f, μ s < ∞
#align measure_theory.measure.finite_at_filter MeasureTheory.Measure.FiniteAtFilter
theorem finiteAtFilter_of_finite {_m0 : MeasurableSpace α} (μ : Measure α) [IsFiniteMeasure μ]
(f : Filter α) : μ.FiniteAtFilter f :=
⟨univ, univ_mem, measure_lt_top μ univ⟩
#align measure_theory.measure.finite_at_filter_of_finite MeasureTheory.Measure.finiteAtFilter_of_finite
theorem FiniteAtFilter.exists_mem_basis {f : Filter α} (hμ : FiniteAtFilter μ f) {p : ι → Prop}
{s : ι → Set α} (hf : f.HasBasis p s) : ∃ i, p i ∧ μ (s i) < ∞ :=
(hf.exists_iff fun {_s _t} hst ht => (measure_mono hst).trans_lt ht).1 hμ
#align measure_theory.measure.finite_at_filter.exists_mem_basis MeasureTheory.Measure.FiniteAtFilter.exists_mem_basis
theorem finiteAtBot {m0 : MeasurableSpace α} (μ : Measure α) : μ.FiniteAtFilter ⊥ :=
⟨∅, mem_bot, by simp only [measure_empty, zero_lt_top]⟩
#align measure_theory.measure.finite_at_bot MeasureTheory.Measure.finiteAtBot
/-- `μ` has finite spanning sets in `C` if there is a countable sequence of sets in `C` that have
finite measures. This structure is a type, which is useful if we want to record extra properties
about the sets, such as that they are monotone.
`SigmaFinite` is defined in terms of this: `μ` is σ-finite if there exists a sequence of
finite spanning sets in the collection of all measurable sets. -/
-- Porting note(#5171): this linter isn't ported yet.
-- @[nolint has_nonempty_instance]
structure FiniteSpanningSetsIn {m0 : MeasurableSpace α} (μ : Measure α) (C : Set (Set α)) where
protected set : ℕ → Set α
protected set_mem : ∀ i, set i ∈ C
protected finite : ∀ i, μ (set i) < ∞
protected spanning : ⋃ i, set i = univ
#align measure_theory.measure.finite_spanning_sets_in MeasureTheory.Measure.FiniteSpanningSetsIn
#align measure_theory.measure.finite_spanning_sets_in.set MeasureTheory.Measure.FiniteSpanningSetsIn.set
#align measure_theory.measure.finite_spanning_sets_in.set_mem MeasureTheory.Measure.FiniteSpanningSetsIn.set_mem
#align measure_theory.measure.finite_spanning_sets_in.finite MeasureTheory.Measure.FiniteSpanningSetsIn.finite
#align measure_theory.measure.finite_spanning_sets_in.spanning MeasureTheory.Measure.FiniteSpanningSetsIn.spanning
end Measure
open Measure
section SFinite
/-- A measure is called s-finite if it is a countable sum of finite measures. -/
class SFinite (μ : Measure α) : Prop where
out' : ∃ m : ℕ → Measure α, (∀ n, IsFiniteMeasure (m n)) ∧ μ = Measure.sum m
/-- A sequence of finite measures such that `μ = sum (sFiniteSeq μ)` (see `sum_sFiniteSeq`). -/
noncomputable
def sFiniteSeq (μ : Measure α) [h : SFinite μ] : ℕ → Measure α := h.1.choose
instance isFiniteMeasure_sFiniteSeq [h : SFinite μ] (n : ℕ) : IsFiniteMeasure (sFiniteSeq μ n) :=
h.1.choose_spec.1 n
lemma sum_sFiniteSeq (μ : Measure α) [h : SFinite μ] : sum (sFiniteSeq μ) = μ :=
h.1.choose_spec.2.symm
instance : SFinite (0 : Measure α) := ⟨fun _ ↦ 0, inferInstance, by rw [Measure.sum_zero]⟩
@[simp]
lemma sFiniteSeq_zero (n : ℕ) : sFiniteSeq (0 : Measure α) n = 0 := by
ext s hs
have h : ∑' n, sFiniteSeq (0 : Measure α) n s = 0 := by
simp [← Measure.sum_apply _ hs, sum_sFiniteSeq]
simp only [ENNReal.tsum_eq_zero] at h
exact h n
/-- A countable sum of finite measures is s-finite.
This lemma is superseeded by the instance below. -/
lemma sfinite_sum_of_countable [Countable ι]
(m : ι → Measure α) [∀ n, IsFiniteMeasure (m n)] : SFinite (Measure.sum m) := by
classical
obtain ⟨f, hf⟩ : ∃ f : ι → ℕ, Function.Injective f := Countable.exists_injective_nat ι
refine ⟨_, fun n ↦ ?_, (sum_extend_zero hf m).symm⟩
rcases em (n ∈ range f) with ⟨i, rfl⟩ | hn
· rw [hf.extend_apply]
infer_instance
· rw [Function.extend_apply' _ _ _ hn, Pi.zero_apply]
infer_instance
instance [Countable ι] (m : ι → Measure α) [∀ n, SFinite (m n)] : SFinite (Measure.sum m) := by
change SFinite (Measure.sum (fun i ↦ m i))
simp_rw [← sum_sFiniteSeq (m _), Measure.sum_sum]
apply sfinite_sum_of_countable
instance [SFinite μ] [SFinite ν] : SFinite (μ + ν) := by
refine ⟨fun n ↦ sFiniteSeq μ n + sFiniteSeq ν n, inferInstance, ?_⟩
ext s hs
simp only [Measure.add_apply, sum_apply _ hs]
rw [tsum_add ENNReal.summable ENNReal.summable, ← sum_apply _ hs, ← sum_apply _ hs,
sum_sFiniteSeq, sum_sFiniteSeq]
instance [SFinite μ] (s : Set α) : SFinite (μ.restrict s) :=
⟨fun n ↦ (sFiniteSeq μ n).restrict s, fun n ↦ inferInstance,
by rw [← restrict_sum_of_countable, sum_sFiniteSeq]⟩
end SFinite
/-- A measure `μ` is called σ-finite if there is a countable collection of sets
`{ A i | i ∈ ℕ }` such that `μ (A i) < ∞` and `⋃ i, A i = s`. -/
class SigmaFinite {m0 : MeasurableSpace α} (μ : Measure α) : Prop where
out' : Nonempty (μ.FiniteSpanningSetsIn univ)
#align measure_theory.sigma_finite MeasureTheory.SigmaFinite
#align measure_theory.sigma_finite.out' MeasureTheory.SigmaFinite.out'
theorem sigmaFinite_iff : SigmaFinite μ ↔ Nonempty (μ.FiniteSpanningSetsIn univ) :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
#align measure_theory.sigma_finite_iff MeasureTheory.sigmaFinite_iff
theorem SigmaFinite.out (h : SigmaFinite μ) : Nonempty (μ.FiniteSpanningSetsIn univ) :=
h.1
#align measure_theory.sigma_finite.out MeasureTheory.SigmaFinite.out
/-- If `μ` is σ-finite it has finite spanning sets in the collection of all measurable sets. -/
def Measure.toFiniteSpanningSetsIn (μ : Measure α) [h : SigmaFinite μ] :
μ.FiniteSpanningSetsIn { s | MeasurableSet s } where
set n := toMeasurable μ (h.out.some.set n)
set_mem n := measurableSet_toMeasurable _ _
finite n := by
rw [measure_toMeasurable]
exact h.out.some.finite n
spanning := eq_univ_of_subset (iUnion_mono fun n => subset_toMeasurable _ _) h.out.some.spanning
#align measure_theory.measure.to_finite_spanning_sets_in MeasureTheory.Measure.toFiniteSpanningSetsIn
/-- A noncomputable way to get a monotone collection of sets that span `univ` and have finite
measure using `Classical.choose`. This definition satisfies monotonicity in addition to all other
properties in `SigmaFinite`. -/
def spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) : Set α :=
Accumulate μ.toFiniteSpanningSetsIn.set i
#align measure_theory.spanning_sets MeasureTheory.spanningSets
theorem monotone_spanningSets (μ : Measure α) [SigmaFinite μ] : Monotone (spanningSets μ) :=
monotone_accumulate
#align measure_theory.monotone_spanning_sets MeasureTheory.monotone_spanningSets
theorem measurable_spanningSets (μ : Measure α) [SigmaFinite μ] (i : ℕ) :
MeasurableSet (spanningSets μ i) :=
MeasurableSet.iUnion fun j => MeasurableSet.iUnion fun _ => μ.toFiniteSpanningSetsIn.set_mem j
#align measure_theory.measurable_spanning_sets MeasureTheory.measurable_spanningSets
theorem measure_spanningSets_lt_top (μ : Measure α) [SigmaFinite μ] (i : ℕ) :
μ (spanningSets μ i) < ∞ :=
measure_biUnion_lt_top (finite_le_nat i) fun j _ => (μ.toFiniteSpanningSetsIn.finite j).ne
#align measure_theory.measure_spanning_sets_lt_top MeasureTheory.measure_spanningSets_lt_top
theorem iUnion_spanningSets (μ : Measure α) [SigmaFinite μ] : ⋃ i : ℕ, spanningSets μ i = univ := by
simp_rw [spanningSets, iUnion_accumulate, μ.toFiniteSpanningSetsIn.spanning]
#align measure_theory.Union_spanning_sets MeasureTheory.iUnion_spanningSets
theorem isCountablySpanning_spanningSets (μ : Measure α) [SigmaFinite μ] :
IsCountablySpanning (range (spanningSets μ)) :=
⟨spanningSets μ, mem_range_self, iUnion_spanningSets μ⟩
#align measure_theory.is_countably_spanning_spanning_sets MeasureTheory.isCountablySpanning_spanningSets
open scoped Classical in
/-- `spanningSetsIndex μ x` is the least `n : ℕ` such that `x ∈ spanningSets μ n`. -/
noncomputable def spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) : ℕ :=
Nat.find <| iUnion_eq_univ_iff.1 (iUnion_spanningSets μ) x
#align measure_theory.spanning_sets_index MeasureTheory.spanningSetsIndex
open scoped Classical in
theorem measurable_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] :
Measurable (spanningSetsIndex μ) :=
measurable_find _ <| measurable_spanningSets μ
#align measure_theory.measurable_spanning_sets_index MeasureTheory.measurable_spanningSetsIndex
open scoped Classical in
theorem preimage_spanningSetsIndex_singleton (μ : Measure α) [SigmaFinite μ] (n : ℕ) :
spanningSetsIndex μ ⁻¹' {n} = disjointed (spanningSets μ) n :=
preimage_find_eq_disjointed _ _ _
#align measure_theory.preimage_spanning_sets_index_singleton MeasureTheory.preimage_spanningSetsIndex_singleton
theorem spanningSetsIndex_eq_iff (μ : Measure α) [SigmaFinite μ] {x : α} {n : ℕ} :
spanningSetsIndex μ x = n ↔ x ∈ disjointed (spanningSets μ) n := by
convert Set.ext_iff.1 (preimage_spanningSetsIndex_singleton μ n) x
#align measure_theory.spanning_sets_index_eq_iff MeasureTheory.spanningSetsIndex_eq_iff
theorem mem_disjointed_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) :
x ∈ disjointed (spanningSets μ) (spanningSetsIndex μ x) :=
(spanningSetsIndex_eq_iff μ).1 rfl
#align measure_theory.mem_disjointed_spanning_sets_index MeasureTheory.mem_disjointed_spanningSetsIndex
theorem mem_spanningSetsIndex (μ : Measure α) [SigmaFinite μ] (x : α) :
x ∈ spanningSets μ (spanningSetsIndex μ x) :=
disjointed_subset _ _ (mem_disjointed_spanningSetsIndex μ x)
#align measure_theory.mem_spanning_sets_index MeasureTheory.mem_spanningSetsIndex
theorem mem_spanningSets_of_index_le (μ : Measure α) [SigmaFinite μ] (x : α) {n : ℕ}
(hn : spanningSetsIndex μ x ≤ n) : x ∈ spanningSets μ n :=
monotone_spanningSets μ hn (mem_spanningSetsIndex μ x)
#align measure_theory.mem_spanning_sets_of_index_le MeasureTheory.mem_spanningSets_of_index_le
theorem eventually_mem_spanningSets (μ : Measure α) [SigmaFinite μ] (x : α) :
∀ᶠ n in atTop, x ∈ spanningSets μ n :=
eventually_atTop.2 ⟨spanningSetsIndex μ x, fun _ => mem_spanningSets_of_index_le μ x⟩
#align measure_theory.eventually_mem_spanning_sets MeasureTheory.eventually_mem_spanningSets
theorem sum_restrict_disjointed_spanningSets (μ : Measure α) [SigmaFinite μ] :
sum (fun n ↦ μ.restrict (disjointed (spanningSets μ) n)) = μ := by
rw [← restrict_iUnion (disjoint_disjointed _)
(MeasurableSet.disjointed (measurable_spanningSets _)),
iUnion_disjointed, iUnion_spanningSets, restrict_univ]
instance (priority := 100) [SigmaFinite μ] : SFinite μ := by
have : ∀ n, Fact (μ (disjointed (spanningSets μ) n) < ∞) :=
fun n ↦ ⟨(measure_mono (disjointed_subset _ _)).trans_lt (measure_spanningSets_lt_top μ n)⟩
exact ⟨⟨fun n ↦ μ.restrict (disjointed (spanningSets μ) n), fun n ↦ by infer_instance,
(sum_restrict_disjointed_spanningSets μ).symm⟩⟩
namespace Measure
/-- A set in a σ-finite space has zero measure if and only if its intersection with
all members of the countable family of finite measure spanning sets has zero measure. -/
| Mathlib/MeasureTheory/Measure/Typeclasses.lean | 727 | 731 | theorem forall_measure_inter_spanningSets_eq_zero [MeasurableSpace α] {μ : Measure α}
[SigmaFinite μ] (s : Set α) : (∀ n, μ (s ∩ spanningSets μ n) = 0) ↔ μ s = 0 := by |
nth_rw 2 [show s = ⋃ n, s ∩ spanningSets μ n by
rw [← inter_iUnion, iUnion_spanningSets, inter_univ] ]
rw [measure_iUnion_null_iff]
|
/-
Copyright (c) 2017 Johannes Hölzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes Hölzl
-/
import Mathlib.Algebra.BigOperators.Group.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Multiset
import Mathlib.Tactic.NormNum.Basic
import Mathlib.Tactic.Positivity.Core
#align_import algebra.big_operators.order from "leanprover-community/mathlib"@"65a1391a0106c9204fe45bc73a039f056558cb83"
/-!
# Big operators on a finset in ordered groups
This file contains the results concerning the interaction of multiset big operators with ordered
groups/monoids.
-/
open Function
variable {ι α β M N G k R : Type*}
namespace Finset
section OrderedCommMonoid
variable [CommMonoid M] [OrderedCommMonoid N]
/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map
submultiplicative on `{x | p x}`, i.e., `p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be
a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∏ x ∈ s, g x) ≤ ∏ x ∈ s, f (g x)`. -/
@[to_additive le_sum_nonempty_of_subadditive_on_pred]
theorem le_prod_nonempty_of_submultiplicative_on_pred (f : M → N) (p : M → Prop)
(h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))
(g : ι → M) (s : Finset ι) (hs_nonempty : s.Nonempty) (hs : ∀ i ∈ s, p (g i)) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
refine le_trans
(Multiset.le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul _ ?_ ?_) ?_
· simp [hs_nonempty.ne_empty]
· exact Multiset.forall_mem_map_iff.mpr hs
rw [Multiset.map_map]
rfl
#align finset.le_prod_nonempty_of_submultiplicative_on_pred Finset.le_prod_nonempty_of_submultiplicative_on_pred
#align finset.le_sum_nonempty_of_subadditive_on_pred Finset.le_sum_nonempty_of_subadditive_on_pred
/-- Let `{x | p x}` be an additive subsemigroup of an additive commutative monoid `M`. Let
`f : M → N` be a map subadditive on `{x | p x}`, i.e., `p x → p y → f (x + y) ≤ f x + f y`. Let
`g i`, `i ∈ s`, be a nonempty finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_nonempty_of_subadditive_on_pred
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y` and `g i`, `i ∈ s`, is a
nonempty finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_nonempty_of_subadditive]
theorem le_prod_nonempty_of_submultiplicative (f : M → N) (h_mul : ∀ x y, f (x * y) ≤ f x * f y)
{s : Finset ι} (hs : s.Nonempty) (g : ι → M) : f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) :=
le_prod_nonempty_of_submultiplicative_on_pred f (fun _ ↦ True) (fun x y _ _ ↦ h_mul x y)
(fun _ _ _ _ ↦ trivial) g s hs fun _ _ ↦ trivial
#align finset.le_prod_nonempty_of_submultiplicative Finset.le_prod_nonempty_of_submultiplicative
#align finset.le_sum_nonempty_of_subadditive Finset.le_sum_nonempty_of_subadditive
/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y` and `g i`, `i ∈ s`, is a
nonempty finite family of elements of `M`, then `f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_nonempty_of_subadditive
/-- Let `{x | p x}` be a subsemigroup of a commutative monoid `M`. Let `f : M → N` be a map
such that `f 1 = 1` and `f` is submultiplicative on `{x | p x}`, i.e.,
`p x → p y → f (x * y) ≤ f x * f y`. Let `g i`, `i ∈ s`, be a finite family of elements of `M` such
that `∀ i ∈ s, p (g i)`. Then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_of_subadditive_on_pred]
theorem le_prod_of_submultiplicative_on_pred (f : M → N) (p : M → Prop) (h_one : f 1 = 1)
(h_mul : ∀ x y, p x → p y → f (x * y) ≤ f x * f y) (hp_mul : ∀ x y, p x → p y → p (x * y))
(g : ι → M) {s : Finset ι} (hs : ∀ i ∈ s, p (g i)) : f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
rcases eq_empty_or_nonempty s with (rfl | hs_nonempty)
· simp [h_one]
· exact le_prod_nonempty_of_submultiplicative_on_pred f p h_mul hp_mul g s hs_nonempty hs
#align finset.le_prod_of_submultiplicative_on_pred Finset.le_prod_of_submultiplicative_on_pred
#align finset.le_sum_of_subadditive_on_pred Finset.le_sum_of_subadditive_on_pred
/-- Let `{x | p x}` be a subsemigroup of a commutative additive monoid `M`. Let `f : M → N` be a map
such that `f 0 = 0` and `f` is subadditive on `{x | p x}`, i.e. `p x → p y → f (x + y) ≤ f x + f y`.
Let `g i`, `i ∈ s`, be a finite family of elements of `M` such that `∀ i ∈ s, p (g i)`. Then
`f (∑ x ∈ s, g x) ≤ ∑ x ∈ s, f (g x)`. -/
add_decl_doc le_sum_of_subadditive_on_pred
/-- If `f : M → N` is a submultiplicative function, `f (x * y) ≤ f x * f y`, `f 1 = 1`, and `g i`,
`i ∈ s`, is a finite family of elements of `M`, then `f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i)`. -/
@[to_additive le_sum_of_subadditive]
theorem le_prod_of_submultiplicative (f : M → N) (h_one : f 1 = 1)
(h_mul : ∀ x y, f (x * y) ≤ f x * f y) (s : Finset ι) (g : ι → M) :
f (∏ i ∈ s, g i) ≤ ∏ i ∈ s, f (g i) := by
refine le_trans (Multiset.le_prod_of_submultiplicative f h_one h_mul _) ?_
rw [Multiset.map_map]
rfl
#align finset.le_prod_of_submultiplicative Finset.le_prod_of_submultiplicative
#align finset.le_sum_of_subadditive Finset.le_sum_of_subadditive
/-- If `f : M → N` is a subadditive function, `f (x + y) ≤ f x + f y`, `f 0 = 0`, and `g i`,
`i ∈ s`, is a finite family of elements of `M`, then `f (∑ i ∈ s, g i) ≤ ∑ i ∈ s, f (g i)`. -/
add_decl_doc le_sum_of_subadditive
variable {f g : ι → N} {s t : Finset ι}
/-- In an ordered commutative monoid, if each factor `f i` of one finite product is less than or
equal to the corresponding factor `g i` of another finite product, then
`∏ i ∈ s, f i ≤ ∏ i ∈ s, g i`. -/
@[to_additive sum_le_sum]
theorem prod_le_prod' (h : ∀ i ∈ s, f i ≤ g i) : ∏ i ∈ s, f i ≤ ∏ i ∈ s, g i :=
Multiset.prod_map_le_prod_map f g h
#align finset.prod_le_prod' Finset.prod_le_prod'
#align finset.sum_le_sum Finset.sum_le_sum
/-- In an ordered additive commutative monoid, if each summand `f i` of one finite sum is less than
or equal to the corresponding summand `g i` of another finite sum, then
`∑ i ∈ s, f i ≤ ∑ i ∈ s, g i`. -/
add_decl_doc sum_le_sum
/-- In an ordered commutative monoid, if each factor `f i` of one finite product is less than or
equal to the corresponding factor `g i` of another finite product, then `s.prod f ≤ s.prod g`.
This is a variant (beta-reduced) version of the standard lemma `Finset.prod_le_prod'`, convenient
for the `gcongr` tactic. -/
@[to_additive (attr := gcongr) GCongr.sum_le_sum]
theorem _root_.GCongr.prod_le_prod' (h : ∀ i ∈ s, f i ≤ g i) : s.prod f ≤ s.prod g :=
s.prod_le_prod' h
/-- In an ordered additive commutative monoid, if each summand `f i` of one finite sum is less than
or equal to the corresponding summand `g i` of another finite sum, then `s.sum f ≤ s.sum g`.
This is a variant (beta-reduced) version of the standard lemma `Finset.sum_le_sum`, convenient
for the `gcongr` tactic. -/
add_decl_doc GCongr.sum_le_sum
@[to_additive sum_nonneg]
theorem one_le_prod' (h : ∀ i ∈ s, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
le_trans (by rw [prod_const_one]) (prod_le_prod' h)
#align finset.one_le_prod' Finset.one_le_prod'
#align finset.sum_nonneg Finset.sum_nonneg
@[to_additive Finset.sum_nonneg']
theorem one_le_prod'' (h : ∀ i : ι, 1 ≤ f i) : 1 ≤ ∏ i ∈ s, f i :=
Finset.one_le_prod' fun i _ ↦ h i
#align finset.one_le_prod'' Finset.one_le_prod''
#align finset.sum_nonneg' Finset.sum_nonneg'
@[to_additive sum_nonpos]
theorem prod_le_one' (h : ∀ i ∈ s, f i ≤ 1) : ∏ i ∈ s, f i ≤ 1 :=
(prod_le_prod' h).trans_eq (by rw [prod_const_one])
#align finset.prod_le_one' Finset.prod_le_one'
#align finset.sum_nonpos Finset.sum_nonpos
@[to_additive sum_le_sum_of_subset_of_nonneg]
theorem prod_le_prod_of_subset_of_one_le' (h : s ⊆ t) (hf : ∀ i ∈ t, i ∉ s → 1 ≤ f i) :
∏ i ∈ s, f i ≤ ∏ i ∈ t, f i := by
classical calc
∏ i ∈ s, f i ≤ (∏ i ∈ t \ s, f i) * ∏ i ∈ s, f i :=
le_mul_of_one_le_left' <| one_le_prod' <| by simpa only [mem_sdiff, and_imp]
_ = ∏ i ∈ t \ s ∪ s, f i := (prod_union sdiff_disjoint).symm
_ = ∏ i ∈ t, f i := by rw [sdiff_union_of_subset h]
#align finset.prod_le_prod_of_subset_of_one_le' Finset.prod_le_prod_of_subset_of_one_le'
#align finset.sum_le_sum_of_subset_of_nonneg Finset.sum_le_sum_of_subset_of_nonneg
@[to_additive sum_mono_set_of_nonneg]
theorem prod_mono_set_of_one_le' (hf : ∀ x, 1 ≤ f x) : Monotone fun s ↦ ∏ x ∈ s, f x :=
fun _ _ hst ↦ prod_le_prod_of_subset_of_one_le' hst fun x _ _ ↦ hf x
#align finset.prod_mono_set_of_one_le' Finset.prod_mono_set_of_one_le'
#align finset.sum_mono_set_of_nonneg Finset.sum_mono_set_of_nonneg
@[to_additive sum_le_univ_sum_of_nonneg]
theorem prod_le_univ_prod_of_one_le' [Fintype ι] {s : Finset ι} (w : ∀ x, 1 ≤ f x) :
∏ x ∈ s, f x ≤ ∏ x, f x :=
prod_le_prod_of_subset_of_one_le' (subset_univ s) fun a _ _ ↦ w a
#align finset.prod_le_univ_prod_of_one_le' Finset.prod_le_univ_prod_of_one_le'
#align finset.sum_le_univ_sum_of_nonneg Finset.sum_le_univ_sum_of_nonneg
-- Porting note (#11215): TODO -- The two next lemmas give the same lemma in additive version
@[to_additive sum_eq_zero_iff_of_nonneg]
theorem prod_eq_one_iff_of_one_le' :
(∀ i ∈ s, 1 ≤ f i) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) := by
classical
refine Finset.induction_on s
(fun _ ↦ ⟨fun _ _ h ↦ False.elim (Finset.not_mem_empty _ h), fun _ ↦ rfl⟩) ?_
intro a s ha ih H
have : ∀ i ∈ s, 1 ≤ f i := fun _ ↦ H _ ∘ mem_insert_of_mem
rw [prod_insert ha, mul_eq_one_iff' (H _ <| mem_insert_self _ _) (one_le_prod' this),
forall_mem_insert, ih this]
#align finset.prod_eq_one_iff_of_one_le' Finset.prod_eq_one_iff_of_one_le'
#align finset.sum_eq_zero_iff_of_nonneg Finset.sum_eq_zero_iff_of_nonneg
@[to_additive sum_eq_zero_iff_of_nonpos]
theorem prod_eq_one_iff_of_le_one' :
(∀ i ∈ s, f i ≤ 1) → ((∏ i ∈ s, f i) = 1 ↔ ∀ i ∈ s, f i = 1) :=
@prod_eq_one_iff_of_one_le' _ Nᵒᵈ _ _ _
#align finset.prod_eq_one_iff_of_le_one' Finset.prod_eq_one_iff_of_le_one'
@[to_additive single_le_sum]
theorem single_le_prod' (hf : ∀ i ∈ s, 1 ≤ f i) {a} (h : a ∈ s) : f a ≤ ∏ x ∈ s, f x :=
calc
f a = ∏ i ∈ {a}, f i := (prod_singleton _ _).symm
_ ≤ ∏ i ∈ s, f i :=
prod_le_prod_of_subset_of_one_le' (singleton_subset_iff.2 h) fun i hi _ ↦ hf i hi
#align finset.single_le_prod' Finset.single_le_prod'
#align finset.single_le_sum Finset.single_le_sum
@[to_additive]
lemma mul_le_prod {i j : ι} (hf : ∀ i ∈ s, 1 ≤ f i) (hi : i ∈ s) (hj : j ∈ s) (hne : i ≠ j) :
f i * f j ≤ ∏ k ∈ s, f k :=
calc
f i * f j = ∏ k ∈ .cons i {j} (by simpa), f k := by rw [prod_cons, prod_singleton]
_ ≤ ∏ k ∈ s, f k := by
refine prod_le_prod_of_subset_of_one_le' ?_ fun k hk _ ↦ hf k hk
simp [cons_subset, *]
@[to_additive sum_le_card_nsmul]
theorem prod_le_pow_card (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, f x ≤ n) :
s.prod f ≤ n ^ s.card := by
refine (Multiset.prod_le_pow_card (s.val.map f) n ?_).trans ?_
· simpa using h
· simp
#align finset.prod_le_pow_card Finset.prod_le_pow_card
#align finset.sum_le_card_nsmul Finset.sum_le_card_nsmul
@[to_additive card_nsmul_le_sum]
theorem pow_card_le_prod (s : Finset ι) (f : ι → N) (n : N) (h : ∀ x ∈ s, n ≤ f x) :
n ^ s.card ≤ s.prod f := @Finset.prod_le_pow_card _ Nᵒᵈ _ _ _ _ h
#align finset.pow_card_le_prod Finset.pow_card_le_prod
#align finset.card_nsmul_le_sum Finset.card_nsmul_le_sum
theorem card_biUnion_le_card_mul [DecidableEq β] (s : Finset ι) (f : ι → Finset β) (n : ℕ)
(h : ∀ a ∈ s, (f a).card ≤ n) : (s.biUnion f).card ≤ s.card * n :=
card_biUnion_le.trans <| sum_le_card_nsmul _ _ _ h
#align finset.card_bUnion_le_card_mul Finset.card_biUnion_le_card_mul
variable {ι' : Type*} [DecidableEq ι']
-- Porting note: Mathport warning: expanding binder collection (y «expr ∉ » t)
@[to_additive sum_fiberwise_le_sum_of_sum_fiber_nonneg]
theorem prod_fiberwise_le_prod_of_one_le_prod_fiber' {t : Finset ι'} {g : ι → ι'} {f : ι → N}
(h : ∀ y ∉ t, (1 : N) ≤ ∏ x ∈ s.filter fun x ↦ g x = y, f x) :
(∏ y ∈ t, ∏ x ∈ s.filter fun x ↦ g x = y, f x) ≤ ∏ x ∈ s, f x :=
calc
(∏ y ∈ t, ∏ x ∈ s.filter fun x ↦ g x = y, f x) ≤
∏ y ∈ t ∪ s.image g, ∏ x ∈ s.filter fun x ↦ g x = y, f x :=
prod_le_prod_of_subset_of_one_le' subset_union_left fun y _ ↦ h y
_ = ∏ x ∈ s, f x :=
prod_fiberwise_of_maps_to (fun _ hx ↦ mem_union.2 <| Or.inr <| mem_image_of_mem _ hx) _
#align finset.prod_fiberwise_le_prod_of_one_le_prod_fiber' Finset.prod_fiberwise_le_prod_of_one_le_prod_fiber'
#align finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg Finset.sum_fiberwise_le_sum_of_sum_fiber_nonneg
-- Porting note: Mathport warning: expanding binder collection (y «expr ∉ » t)
@[to_additive sum_le_sum_fiberwise_of_sum_fiber_nonpos]
theorem prod_le_prod_fiberwise_of_prod_fiber_le_one' {t : Finset ι'} {g : ι → ι'} {f : ι → N}
(h : ∀ y ∉ t, ∏ x ∈ s.filter fun x ↦ g x = y, f x ≤ 1) :
∏ x ∈ s, f x ≤ ∏ y ∈ t, ∏ x ∈ s.filter fun x ↦ g x = y, f x :=
@prod_fiberwise_le_prod_of_one_le_prod_fiber' _ Nᵒᵈ _ _ _ _ _ _ _ h
#align finset.prod_le_prod_fiberwise_of_prod_fiber_le_one' Finset.prod_le_prod_fiberwise_of_prod_fiber_le_one'
#align finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos Finset.sum_le_sum_fiberwise_of_sum_fiber_nonpos
end OrderedCommMonoid
theorem abs_sum_le_sum_abs {G : Type*} [LinearOrderedAddCommGroup G] (f : ι → G) (s : Finset ι) :
|∑ i ∈ s, f i| ≤ ∑ i ∈ s, |f i| := le_sum_of_subadditive _ abs_zero abs_add s f
#align finset.abs_sum_le_sum_abs Finset.abs_sum_le_sum_abs
theorem abs_sum_of_nonneg {G : Type*} [LinearOrderedAddCommGroup G] {f : ι → G} {s : Finset ι}
(hf : ∀ i ∈ s, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by
rw [abs_of_nonneg (Finset.sum_nonneg hf)]
#align finset.abs_sum_of_nonneg Finset.abs_sum_of_nonneg
| Mathlib/Algebra/Order/BigOperators/Group/Finset.lean | 272 | 274 | theorem abs_sum_of_nonneg' {G : Type*} [LinearOrderedAddCommGroup G] {f : ι → G} {s : Finset ι}
(hf : ∀ i, 0 ≤ f i) : |∑ i ∈ s, f i| = ∑ i ∈ s, f i := by |
rw [abs_of_nonneg (Finset.sum_nonneg' hf)]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.