Context stringlengths 295 65.3k | file_name stringlengths 21 74 | start int64 14 1.41k | end int64 20 1.41k | theorem stringlengths 27 1.42k | proof stringlengths 0 4.57k |
|---|---|---|---|---|---|
/-
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.Logic.Equiv.PartialEquiv
import Mathlib.Topology.Homeomorph.Lemmas
import Mathlib.Topology.Sets.Opens
/-!
# Partial homeomorphisms
This file defines homeomorphisms between open subsets of topological spaces. An element `e` of
`PartialHomeomorph X Y` is an extension of `PartialEquiv X Y`, i.e., it is a pair of functions
`e.toFun` and `e.invFun`, inverse of each other on the sets `e.source` and `e.target`.
Additionally, we require that these sets are open, and that the functions are continuous on them.
Equivalently, they are homeomorphisms there.
As in equivs, we register a coercion to functions, and we use `e x` and `e.symm x` throughout
instead of `e.toFun x` and `e.invFun x`.
## Main definitions
* `Homeomorph.toPartialHomeomorph`: associating a partial homeomorphism to a homeomorphism, with
`source = target = Set.univ`;
* `PartialHomeomorph.symm`: the inverse of a partial homeomorphism
* `PartialHomeomorph.trans`: the composition of two partial homeomorphisms
* `PartialHomeomorph.refl`: the identity partial homeomorphism
* `PartialHomeomorph.const`: a partial homeomorphism which is a constant map,
whose source and target are necessarily singleton sets
* `PartialHomeomorph.ofSet`: the identity on a set `s`
* `PartialHomeomorph.restr s`: restrict a partial homeomorphism `e` to `e.source β© interior s`
* `PartialHomeomorph.EqOnSource`: equivalence relation describing the "right" notion of equality
for partial homeomorphisms
* `PartialHomeomorph.prod`: the product of two partial homeomorphisms,
as a partial homeomorphism on the product space
* `PartialHomeomorph.pi`: the product of a finite family of partial homeomorphisms
* `PartialHomeomorph.disjointUnion`: combine two partial homeomorphisms with disjoint sources
and disjoint targets
* `PartialHomeomorph.lift_openEmbedding`: extend a partial homeomorphism `X β Y`
under an open embedding `X β X'`, to a partial homeomorphism `X' β Z`.
(This is used to define the disjoint union of charted spaces.)
## Implementation notes
Most statements are copied from their `PartialEquiv` versions, although some care is required
especially when restricting to subsets, as these should be open subsets.
For design notes, see `PartialEquiv.lean`.
### Local coding conventions
If a lemma deals with the intersection of a set with either source or target of a `PartialEquiv`,
then it should use `e.source β© s` or `e.target β© t`, not `s β© e.source` or `t β© e.target`.
-/
open Function Set Filter Topology
variable {X X' : Type*} {Y Y' : Type*} {Z Z' : Type*}
[TopologicalSpace X] [TopologicalSpace X'] [TopologicalSpace Y] [TopologicalSpace Y']
[TopologicalSpace Z] [TopologicalSpace Z']
/-- Partial homeomorphisms, defined on open subsets of the space -/
structure PartialHomeomorph (X : Type*) (Y : Type*) [TopologicalSpace X]
[TopologicalSpace Y] extends PartialEquiv X Y where
open_source : IsOpen source
open_target : IsOpen target
continuousOn_toFun : ContinuousOn toFun source
continuousOn_invFun : ContinuousOn invFun target
namespace PartialHomeomorph
variable (e : PartialHomeomorph X Y)
/-! Basic properties; inverse (symm instance) -/
section Basic
/-- Coercion of a partial homeomorphisms to a function. We don't use `e.toFun` because it is
actually `e.toPartialEquiv.toFun`, so `simp` will apply lemmas about `toPartialEquiv`.
While we may want to switch to this behavior later, doing it mid-port will break a lot of proofs. -/
@[coe] def toFun' : X β Y := e.toFun
/-- Coercion of a `PartialHomeomorph` to function.
Note that a `PartialHomeomorph` is not `DFunLike`. -/
instance : CoeFun (PartialHomeomorph X Y) fun _ => X β Y :=
β¨fun e => e.toFun'β©
/-- The inverse of a partial homeomorphism -/
@[symm]
protected def symm : PartialHomeomorph Y X where
toPartialEquiv := e.toPartialEquiv.symm
open_source := e.open_target
open_target := e.open_source
continuousOn_toFun := e.continuousOn_invFun
continuousOn_invFun := e.continuousOn_toFun
/-- See Note [custom simps projection]. We need to specify this projection explicitly in this case,
because it is a composition of multiple projections. -/
def Simps.apply (e : PartialHomeomorph X Y) : X β Y := e
/-- See Note [custom simps projection] -/
def Simps.symm_apply (e : PartialHomeomorph X Y) : Y β X := e.symm
initialize_simps_projections PartialHomeomorph (toFun β apply, invFun β symm_apply)
protected theorem continuousOn : ContinuousOn e e.source :=
e.continuousOn_toFun
theorem continuousOn_symm : ContinuousOn e.symm e.target :=
e.continuousOn_invFun
@[simp, mfld_simps]
theorem mk_coe (e : PartialEquiv X Y) (a b c d) : (PartialHomeomorph.mk e a b c d : X β Y) = e :=
rfl
@[simp, mfld_simps]
theorem mk_coe_symm (e : PartialEquiv X Y) (a b c d) :
((PartialHomeomorph.mk e a b c d).symm : Y β X) = e.symm :=
rfl
theorem toPartialEquiv_injective :
Injective (toPartialEquiv : PartialHomeomorph X Y β PartialEquiv X Y)
| β¨_, _, _, _, _β©, β¨_, _, _, _, _β©, rfl => rfl
/- Register a few simp lemmas to make sure that `simp` puts the application of a local
homeomorphism in its normal form, i.e., in terms of its coercion to a function. -/
@[simp, mfld_simps]
theorem toFun_eq_coe (e : PartialHomeomorph X Y) : e.toFun = e :=
rfl
@[simp, mfld_simps]
theorem invFun_eq_coe (e : PartialHomeomorph X Y) : e.invFun = e.symm :=
rfl
@[simp, mfld_simps]
theorem coe_coe : (e.toPartialEquiv : X β Y) = e :=
rfl
@[simp, mfld_simps]
theorem coe_coe_symm : (e.toPartialEquiv.symm : Y β X) = e.symm :=
rfl
@[simp, mfld_simps]
theorem map_source {x : X} (h : x β e.source) : e x β e.target :=
e.map_source' h
/-- Variant of `map_source`, stated for images of subsets of `source`. -/
lemma map_source'' : e '' e.source β e.target :=
fun _ β¨_, hx, hexβ© β¦ mem_of_eq_of_mem (id hex.symm) (e.map_source' hx)
@[simp, mfld_simps]
theorem map_target {x : Y} (h : x β e.target) : e.symm x β e.source :=
e.map_target' h
@[simp, mfld_simps]
theorem left_inv {x : X} (h : x β e.source) : e.symm (e x) = x :=
e.left_inv' h
@[simp, mfld_simps]
theorem right_inv {x : Y} (h : x β e.target) : e (e.symm x) = x :=
e.right_inv' h
theorem eq_symm_apply {x : X} {y : Y} (hx : x β e.source) (hy : y β e.target) :
x = e.symm y β e x = y :=
e.toPartialEquiv.eq_symm_apply hx hy
protected theorem mapsTo : MapsTo e e.source e.target := fun _ => e.map_source
protected theorem symm_mapsTo : MapsTo e.symm e.target e.source :=
e.symm.mapsTo
protected theorem leftInvOn : LeftInvOn e.symm e e.source := fun _ => e.left_inv
protected theorem rightInvOn : RightInvOn e.symm e e.target := fun _ => e.right_inv
protected theorem invOn : InvOn e.symm e e.source e.target :=
β¨e.leftInvOn, e.rightInvOnβ©
protected theorem injOn : InjOn e e.source :=
e.leftInvOn.injOn
protected theorem bijOn : BijOn e e.source e.target :=
e.invOn.bijOn e.mapsTo e.symm_mapsTo
protected theorem surjOn : SurjOn e e.source e.target :=
e.bijOn.surjOn
end Basic
/-- Interpret a `Homeomorph` as a `PartialHomeomorph` by restricting it
to an open set `s` in the domain and to `t` in the codomain. -/
@[simps! -fullyApplied apply symm_apply toPartialEquiv,
simps! -isSimp source target]
def _root_.Homeomorph.toPartialHomeomorphOfImageEq (e : X ββ Y) (s : Set X) (hs : IsOpen s)
(t : Set Y) (h : e '' s = t) : PartialHomeomorph X Y where
toPartialEquiv := e.toPartialEquivOfImageEq s t h
open_source := hs
open_target := by simpa [β h]
continuousOn_toFun := e.continuous.continuousOn
continuousOn_invFun := e.symm.continuous.continuousOn
/-- A homeomorphism induces a partial homeomorphism on the whole space -/
@[simps! (config := mfld_cfg)]
def _root_.Homeomorph.toPartialHomeomorph (e : X ββ Y) : PartialHomeomorph X Y :=
e.toPartialHomeomorphOfImageEq univ isOpen_univ univ <| by rw [image_univ, e.surjective.range_eq]
/-- Replace `toPartialEquiv` field to provide better definitional equalities. -/
def replaceEquiv (e : PartialHomeomorph X Y) (e' : PartialEquiv X Y) (h : e.toPartialEquiv = e') :
PartialHomeomorph X Y where
toPartialEquiv := e'
open_source := h βΈ e.open_source
open_target := h βΈ e.open_target
continuousOn_toFun := h βΈ e.continuousOn_toFun
continuousOn_invFun := h βΈ e.continuousOn_invFun
theorem replaceEquiv_eq_self (e' : PartialEquiv X Y)
(h : e.toPartialEquiv = e') : e.replaceEquiv e' h = e := by
cases e
subst e'
rfl
theorem source_preimage_target : e.source β e β»ΒΉ' e.target :=
e.mapsTo
theorem eventually_left_inverse {x} (hx : x β e.source) :
βαΆ y in π x, e.symm (e y) = y :=
(e.open_source.eventually_mem hx).mono e.left_inv'
theorem eventually_left_inverse' {x} (hx : x β e.target) :
βαΆ y in π (e.symm x), e.symm (e y) = y :=
e.eventually_left_inverse (e.map_target hx)
theorem eventually_right_inverse {x} (hx : x β e.target) :
βαΆ y in π x, e (e.symm y) = y :=
(e.open_target.eventually_mem hx).mono e.right_inv'
theorem eventually_right_inverse' {x} (hx : x β e.source) :
βαΆ y in π (e x), e (e.symm y) = y :=
e.eventually_right_inverse (e.map_source hx)
theorem eventually_ne_nhdsWithin {x} (hx : x β e.source) :
βαΆ x' in π[β ] x, e x' β e x :=
eventually_nhdsWithin_iff.2 <|
(e.eventually_left_inverse hx).mono fun x' hx' =>
mt fun h => by rw [mem_singleton_iff, β e.left_inv hx, β h, hx']
theorem nhdsWithin_source_inter {x} (hx : x β e.source) (s : Set X) : π[e.source β© s] x = π[s] x :=
nhdsWithin_inter_of_mem (mem_nhdsWithin_of_mem_nhds <| IsOpen.mem_nhds e.open_source hx)
theorem nhdsWithin_target_inter {x} (hx : x β e.target) (s : Set Y) : π[e.target β© s] x = π[s] x :=
e.symm.nhdsWithin_source_inter hx s
theorem image_eq_target_inter_inv_preimage {s : Set X} (h : s β e.source) :
e '' s = e.target β© e.symm β»ΒΉ' s :=
e.toPartialEquiv.image_eq_target_inter_inv_preimage h
theorem image_source_inter_eq' (s : Set X) : e '' (e.source β© s) = e.target β© e.symm β»ΒΉ' s :=
e.toPartialEquiv.image_source_inter_eq' s
theorem image_source_inter_eq (s : Set X) :
e '' (e.source β© s) = e.target β© e.symm β»ΒΉ' (e.source β© s) :=
e.toPartialEquiv.image_source_inter_eq s
theorem symm_image_eq_source_inter_preimage {s : Set Y} (h : s β e.target) :
e.symm '' s = e.source β© e β»ΒΉ' s :=
e.symm.image_eq_target_inter_inv_preimage h
theorem symm_image_target_inter_eq (s : Set Y) :
e.symm '' (e.target β© s) = e.source β© e β»ΒΉ' (e.target β© s) :=
e.symm.image_source_inter_eq _
theorem source_inter_preimage_inv_preimage (s : Set X) :
e.source β© e β»ΒΉ' (e.symm β»ΒΉ' s) = e.source β© s :=
e.toPartialEquiv.source_inter_preimage_inv_preimage s
theorem target_inter_inv_preimage_preimage (s : Set Y) :
e.target β© e.symm β»ΒΉ' (e β»ΒΉ' s) = e.target β© s :=
e.symm.source_inter_preimage_inv_preimage _
theorem source_inter_preimage_target_inter (s : Set Y) :
e.source β© e β»ΒΉ' (e.target β© s) = e.source β© e β»ΒΉ' s :=
e.toPartialEquiv.source_inter_preimage_target_inter s
theorem image_source_eq_target : e '' e.source = e.target :=
e.toPartialEquiv.image_source_eq_target
theorem symm_image_target_eq_source : e.symm '' e.target = e.source :=
e.symm.image_source_eq_target
/-- Two partial homeomorphisms are equal when they have equal `toFun`, `invFun` and `source`.
It is not sufficient to have equal `toFun` and `source`, as this only determines `invFun` on
the target. This would only be true for a weaker notion of equality, arguably the right one,
called `EqOnSource`. -/
@[ext]
protected theorem ext (e' : PartialHomeomorph X Y) (h : β x, e x = e' x)
(hinv : β x, e.symm x = e'.symm x) (hs : e.source = e'.source) : e = e' :=
toPartialEquiv_injective (PartialEquiv.ext h hinv hs)
@[simp, mfld_simps]
theorem symm_toPartialEquiv : e.symm.toPartialEquiv = e.toPartialEquiv.symm :=
rfl
-- The following lemmas are already simp via `PartialEquiv`
theorem symm_source : e.symm.source = e.target :=
rfl
theorem symm_target : e.symm.target = e.source :=
rfl
@[simp, mfld_simps] theorem symm_symm : e.symm.symm = e := rfl
theorem symm_bijective : Function.Bijective
(PartialHomeomorph.symm : PartialHomeomorph X Y β PartialHomeomorph Y X) :=
Function.bijective_iff_has_inverse.mpr β¨_, symm_symm, symm_symmβ©
/-- A partial homeomorphism is continuous at any point of its source -/
protected theorem continuousAt {x : X} (h : x β e.source) : ContinuousAt e x :=
(e.continuousOn x h).continuousAt (e.open_source.mem_nhds h)
/-- A partial homeomorphism inverse is continuous at any point of its target -/
theorem continuousAt_symm {x : Y} (h : x β e.target) : ContinuousAt e.symm x :=
e.symm.continuousAt h
theorem tendsto_symm {x} (hx : x β e.source) : Tendsto e.symm (π (e x)) (π x) := by
simpa only [ContinuousAt, e.left_inv hx] using e.continuousAt_symm (e.map_source hx)
theorem map_nhds_eq {x} (hx : x β e.source) : map e (π x) = π (e x) :=
le_antisymm (e.continuousAt hx) <|
le_map_of_right_inverse (e.eventually_right_inverse' hx) (e.tendsto_symm hx)
theorem symm_map_nhds_eq {x} (hx : x β e.source) : map e.symm (π (e x)) = π x :=
(e.symm.map_nhds_eq <| e.map_source hx).trans <| by rw [e.left_inv hx]
theorem image_mem_nhds {x} (hx : x β e.source) {s : Set X} (hs : s β π x) : e '' s β π (e x) :=
e.map_nhds_eq hx βΈ Filter.image_mem_map hs
theorem map_nhdsWithin_eq {x} (hx : x β e.source) (s : Set X) :
map e (π[s] x) = π[e '' (e.source β© s)] e x :=
calc
map e (π[s] x) = map e (π[e.source β© s] x) :=
congr_arg (map e) (e.nhdsWithin_source_inter hx _).symm
_ = π[e '' (e.source β© s)] e x :=
(e.leftInvOn.mono inter_subset_left).map_nhdsWithin_eq (e.left_inv hx)
(e.continuousAt_symm (e.map_source hx)).continuousWithinAt
(e.continuousAt hx).continuousWithinAt
theorem map_nhdsWithin_preimage_eq {x} (hx : x β e.source) (s : Set Y) :
map e (π[e β»ΒΉ' s] x) = π[s] e x := by
rw [e.map_nhdsWithin_eq hx, e.image_source_inter_eq', e.target_inter_inv_preimage_preimage,
e.nhdsWithin_target_inter (e.map_source hx)]
theorem eventually_nhds {x : X} (p : Y β Prop) (hx : x β e.source) :
(βαΆ y in π (e x), p y) β βαΆ x in π x, p (e x) :=
Iff.trans (by rw [e.map_nhds_eq hx]) eventually_map
theorem eventually_nhds' {x : X} (p : X β Prop) (hx : x β e.source) :
(βαΆ y in π (e x), p (e.symm y)) β βαΆ x in π x, p x := by
rw [e.eventually_nhds _ hx]
refine eventually_congr ((e.eventually_left_inverse hx).mono fun y hy => ?_)
rw [hy]
theorem eventually_nhdsWithin {x : X} (p : Y β Prop) {s : Set X}
(hx : x β e.source) : (βαΆ y in π[e.symm β»ΒΉ' s] e x, p y) β βαΆ x in π[s] x, p (e x) := by
refine Iff.trans ?_ eventually_map
rw [e.map_nhdsWithin_eq hx, e.image_source_inter_eq', e.nhdsWithin_target_inter (e.mapsTo hx)]
theorem eventually_nhdsWithin' {x : X} (p : X β Prop) {s : Set X}
(hx : x β e.source) : (βαΆ y in π[e.symm β»ΒΉ' s] e x, p (e.symm y)) β βαΆ x in π[s] x, p x := by
rw [e.eventually_nhdsWithin _ hx]
refine eventually_congr <|
(eventually_nhdsWithin_of_eventually_nhds <| e.eventually_left_inverse hx).mono fun y hy => ?_
rw [hy]
/-- This lemma is useful in the manifold library in the case that `e` is a chart. It states that
locally around `e x` the set `e.symm β»ΒΉ' s` is the same as the set intersected with the target
of `e` and some other neighborhood of `f x` (which will be the source of a chart on `Z`). -/
theorem preimage_eventuallyEq_target_inter_preimage_inter {e : PartialHomeomorph X Y} {s : Set X}
{t : Set Z} {x : X} {f : X β Z} (hf : ContinuousWithinAt f s x) (hxe : x β e.source)
(ht : t β π (f x)) :
e.symm β»ΒΉ' s =αΆ [π (e x)] (e.target β© e.symm β»ΒΉ' (s β© f β»ΒΉ' t) : Set Y) := by
rw [eventuallyEq_set, e.eventually_nhds _ hxe]
filter_upwards [e.open_source.mem_nhds hxe,
mem_nhdsWithin_iff_eventually.mp (hf.preimage_mem_nhdsWithin ht)]
intro y hy hyu
simp_rw [mem_inter_iff, mem_preimage, mem_inter_iff, e.mapsTo hy, true_and, iff_self_and,
e.left_inv hy, iff_true_intro hyu]
theorem isOpen_inter_preimage {s : Set Y} (hs : IsOpen s) : IsOpen (e.source β© e β»ΒΉ' s) :=
e.continuousOn.isOpen_inter_preimage e.open_source hs
theorem isOpen_inter_preimage_symm {s : Set X} (hs : IsOpen s) : IsOpen (e.target β© e.symm β»ΒΉ' s) :=
e.symm.continuousOn.isOpen_inter_preimage e.open_target hs
/-- A partial homeomorphism is an open map on its source:
the image of an open subset of the source is open. -/
lemma isOpen_image_of_subset_source {s : Set X} (hs : IsOpen s) (hse : s β e.source) :
IsOpen (e '' s) := by
rw [(image_eq_target_inter_inv_preimage (e := e) hse)]
exact e.continuousOn_invFun.isOpen_inter_preimage e.open_target hs
/-- The image of the restriction of an open set to the source is open. -/
theorem isOpen_image_source_inter {s : Set X} (hs : IsOpen s) :
IsOpen (e '' (e.source β© s)) :=
e.isOpen_image_of_subset_source (e.open_source.inter hs) inter_subset_left
/-- The inverse of a partial homeomorphism `e` is an open map on `e.target`. -/
lemma isOpen_image_symm_of_subset_target {t : Set Y} (ht : IsOpen t) (hte : t β e.target) :
IsOpen (e.symm '' t) :=
isOpen_image_of_subset_source e.symm ht (e.symm_source βΈ hte)
lemma isOpen_symm_image_iff_of_subset_target {t : Set Y} (hs : t β e.target) :
IsOpen (e.symm '' t) β IsOpen t := by
refine β¨fun h β¦ ?_, fun h β¦ e.symm.isOpen_image_of_subset_source h hsβ©
have hs' : e.symm '' t β e.source := by
rw [e.symm_image_eq_source_inter_preimage hs]
apply Set.inter_subset_left
rw [β e.image_symm_image_of_subset_target hs]
exact e.isOpen_image_of_subset_source h hs'
theorem isOpen_image_iff_of_subset_source {s : Set X} (hs : s β e.source) :
IsOpen (e '' s) β IsOpen s := by
rw [β e.symm.isOpen_symm_image_iff_of_subset_target hs, e.symm_symm]
section IsImage
/-!
### `PartialHomeomorph.IsImage` relation
We say that `t : Set Y` is an image of `s : Set X` under a partial homeomorphism `e` if any of the
following equivalent conditions hold:
* `e '' (e.source β© s) = e.target β© t`;
* `e.source β© e β»ΒΉ t = e.source β© s`;
* `β x β e.source, e x β t β x β s` (this one is used in the definition).
This definition is a restatement of `PartialEquiv.IsImage` for partial homeomorphisms.
In this section we transfer API about `PartialEquiv.IsImage` to partial homeomorphisms and
add a few `PartialHomeomorph`-specific lemmas like `PartialHomeomorph.IsImage.closure`.
-/
/-- We say that `t : Set Y` is an image of `s : Set X` under a partial homeomorphism `e`
if any of the following equivalent conditions hold:
* `e '' (e.source β© s) = e.target β© t`;
* `e.source β© e β»ΒΉ t = e.source β© s`;
* `β x β e.source, e x β t β x β s` (this one is used in the definition).
-/
def IsImage (s : Set X) (t : Set Y) : Prop :=
β β¦xβ¦, x β e.source β (e x β t β x β s)
namespace IsImage
variable {e} {s : Set X} {t : Set Y} {x : X} {y : Y}
theorem toPartialEquiv (h : e.IsImage s t) : e.toPartialEquiv.IsImage s t :=
h
theorem apply_mem_iff (h : e.IsImage s t) (hx : x β e.source) : e x β t β x β s :=
h hx
protected theorem symm (h : e.IsImage s t) : e.symm.IsImage t s :=
h.toPartialEquiv.symm
theorem symm_apply_mem_iff (h : e.IsImage s t) (hy : y β e.target) : e.symm y β s β y β t :=
h.symm hy
@[simp]
theorem symm_iff : e.symm.IsImage t s β e.IsImage s t :=
β¨fun h => h.symm, fun h => h.symmβ©
protected theorem mapsTo (h : e.IsImage s t) : MapsTo e (e.source β© s) (e.target β© t) :=
h.toPartialEquiv.mapsTo
theorem symm_mapsTo (h : e.IsImage s t) : MapsTo e.symm (e.target β© t) (e.source β© s) :=
h.symm.mapsTo
theorem image_eq (h : e.IsImage s t) : e '' (e.source β© s) = e.target β© t :=
h.toPartialEquiv.image_eq
theorem symm_image_eq (h : e.IsImage s t) : e.symm '' (e.target β© t) = e.source β© s :=
h.symm.image_eq
theorem iff_preimage_eq : e.IsImage s t β e.source β© e β»ΒΉ' t = e.source β© s :=
PartialEquiv.IsImage.iff_preimage_eq
alias β¨preimage_eq, of_preimage_eqβ© := iff_preimage_eq
theorem iff_symm_preimage_eq : e.IsImage s t β e.target β© e.symm β»ΒΉ' s = e.target β© t :=
symm_iff.symm.trans iff_preimage_eq
alias β¨symm_preimage_eq, of_symm_preimage_eqβ© := iff_symm_preimage_eq
| Mathlib/Topology/PartialHomeomorph.lean | 492 | 494 | theorem iff_symm_preimage_eq' :
e.IsImage s t β e.target β© e.symm β»ΒΉ' (e.source β© s) = e.target β© t := by | rw [iff_symm_preimage_eq, β image_source_inter_eq, β image_source_inter_eq'] |
/-
Copyright (c) 2018 Michael Jendrusch. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Jendrusch, Kim Morrison, Bhavik Mehta, Jakob von Raumer
-/
import Mathlib.CategoryTheory.EqToHom
import Mathlib.CategoryTheory.Functor.Trifunctor
import Mathlib.CategoryTheory.Products.Basic
/-!
# Monoidal categories
A monoidal category is a category equipped with a tensor product, unitors, and an associator.
In the definition, we provide the tensor product as a pair of functions
* `tensorObj : C β C β C`
* `tensorHom : (Xβ βΆ Yβ) β (Xβ βΆ Yβ) β ((Xβ β Xβ) βΆ (Yβ β Yβ))`
and allow use of the overloaded notation `β` for both.
The unitors and associator are provided componentwise.
The tensor product can be expressed as a functor via `tensor : C Γ C β₯€ C`.
The unitors and associator are gathered together as natural
isomorphisms in `leftUnitor_nat_iso`, `rightUnitor_nat_iso` and `associator_nat_iso`.
Some consequences of the definition are proved in other files after proving the coherence theorem,
e.g. `(Ξ»_ (π_ C)).hom = (Ο_ (π_ C)).hom` in `CategoryTheory.Monoidal.CoherenceLemmas`.
## Implementation notes
In the definition of monoidal categories, we also provide the whiskering operators:
* `whiskerLeft (X : C) {Yβ Yβ : C} (f : Yβ βΆ Yβ) : X β Yβ βΆ X β Yβ`, denoted by `X β f`,
* `whiskerRight {Xβ Xβ : C} (f : Xβ βΆ Xβ) (Y : C) : Xβ β Y βΆ Xβ β Y`, denoted by `f β· Y`.
These are products of an object and a morphism (the terminology "whiskering"
is borrowed from 2-category theory). The tensor product of morphisms `tensorHom` can be defined
in terms of the whiskerings. There are two possible such definitions, which are related by
the exchange property of the whiskerings. These two definitions are accessed by `tensorHom_def`
and `tensorHom_def'`. By default, `tensorHom` is defined so that `tensorHom_def` holds
definitionally.
If you want to provide `tensorHom` and define `whiskerLeft` and `whiskerRight` in terms of it,
you can use the alternative constructor `CategoryTheory.MonoidalCategory.ofTensorHom`.
The whiskerings are useful when considering simp-normal forms of morphisms in monoidal categories.
### Simp-normal form for morphisms
Rewriting involving associators and unitors could be very complicated. We try to ease this
complexity by putting carefully chosen simp lemmas that rewrite any morphisms into the simp-normal
form defined below. Rewriting into simp-normal form is especially useful in preprocessing
performed by the `coherence` tactic.
The simp-normal form of morphisms is defined to be an expression that has the minimal number of
parentheses. More precisely,
1. it is a composition of morphisms like `fβ β« fβ β« fβ β« fβ β« fβ
` such that each `fα΅’` is
either a structural morphisms (morphisms made up only of identities, associators, unitors)
or non-structural morphisms, and
2. each non-structural morphism in the composition is of the form `Xβ β Xβ β Xβ β f β· Xβ β· Xβ
`,
where each `Xα΅’` is a object that is not the identity or a tensor and `f` is a non-structural
morphisms that is not the identity or a composite.
Note that `Xβ β Xβ β Xβ β f β· Xβ β· Xβ
` is actually `Xβ β (Xβ β (Xβ β ((f β· Xβ) β· Xβ
)))`.
Currently, the simp lemmas don't rewrite `π X β f` and `f β π Y` into `X β f` and `f β· Y`,
respectively, since it requires a huge refactoring. We hope to add these simp lemmas soon.
## References
* Tensor categories, Etingof, Gelaki, Nikshych, Ostrik,
http://www-math.mit.edu/~etingof/egnobookfinal.pdf
* <https://stacks.math.columbia.edu/tag/0FFK>.
-/
universe v u
open CategoryTheory.Category
open CategoryTheory.Iso
namespace CategoryTheory
/-- Auxiliary structure to carry only the data fields of (and provide notation for)
`MonoidalCategory`. -/
class MonoidalCategoryStruct (C : Type u) [π : Category.{v} C] where
/-- curried tensor product of objects -/
tensorObj : C β C β C
/-- left whiskering for morphisms -/
whiskerLeft (X : C) {Yβ Yβ : C} (f : Yβ βΆ Yβ) : tensorObj X Yβ βΆ tensorObj X Yβ
/-- right whiskering for morphisms -/
whiskerRight {Xβ Xβ : C} (f : Xβ βΆ Xβ) (Y : C) : tensorObj Xβ Y βΆ tensorObj Xβ Y
/-- Tensor product of identity maps is the identity: `(π Xβ β π Xβ) = π (Xβ β Xβ)` -/
-- By default, it is defined in terms of whiskerings.
tensorHom {Xβ Yβ Xβ Yβ : C} (f : Xβ βΆ Yβ) (g : Xβ βΆ Yβ) : (tensorObj Xβ Xβ βΆ tensorObj Yβ Yβ) :=
whiskerRight f Xβ β« whiskerLeft Yβ g
/-- The tensor unity in the monoidal structure `π_ C` -/
tensorUnit (C) : C
/-- The associator isomorphism `(X β Y) β Z β X β (Y β Z)` -/
associator : β X Y Z : C, tensorObj (tensorObj X Y) Z β
tensorObj X (tensorObj Y Z)
/-- The left unitor: `π_ C β X β X` -/
leftUnitor : β X : C, tensorObj tensorUnit X β
X
/-- The right unitor: `X β π_ C β X` -/
rightUnitor : β X : C, tensorObj X tensorUnit β
X
namespace MonoidalCategory
export MonoidalCategoryStruct
(tensorObj whiskerLeft whiskerRight tensorHom tensorUnit associator leftUnitor rightUnitor)
end MonoidalCategory
namespace MonoidalCategory
/-- Notation for `tensorObj`, the tensor product of objects in a monoidal category -/
scoped infixr:70 " β " => MonoidalCategoryStruct.tensorObj
/-- Notation for the `whiskerLeft` operator of monoidal categories -/
scoped infixr:81 " β " => MonoidalCategoryStruct.whiskerLeft
/-- Notation for the `whiskerRight` operator of monoidal categories -/
scoped infixl:81 " β· " => MonoidalCategoryStruct.whiskerRight
/-- Notation for `tensorHom`, the tensor product of morphisms in a monoidal category -/
scoped infixr:70 " β " => MonoidalCategoryStruct.tensorHom
/-- Notation for `tensorUnit`, the two-sided identity of `β` -/
scoped notation "π_ " C:arg => MonoidalCategoryStruct.tensorUnit C
/-- Notation for the monoidal `associator`: `(X β Y) β Z β X β (Y β Z)` -/
scoped notation "Ξ±_" => MonoidalCategoryStruct.associator
/-- Notation for the `leftUnitor`: `π_C β X β X` -/
scoped notation "Ξ»_" => MonoidalCategoryStruct.leftUnitor
/-- Notation for the `rightUnitor`: `X β π_C β X` -/
scoped notation "Ο_" => MonoidalCategoryStruct.rightUnitor
/-- The property that the pentagon relation is satisfied by four objects
in a category equipped with a `MonoidalCategoryStruct`. -/
def Pentagon {C : Type u} [Category.{v} C] [MonoidalCategoryStruct C]
(Yβ Yβ Yβ Yβ : C) : Prop :=
(Ξ±_ Yβ Yβ Yβ).hom β· Yβ β« (Ξ±_ Yβ (Yβ β Yβ) Yβ).hom β« Yβ β (Ξ±_ Yβ Yβ Yβ).hom =
(Ξ±_ (Yβ β Yβ) Yβ Yβ).hom β« (Ξ±_ Yβ Yβ (Yβ β Yβ)).hom
end MonoidalCategory
open MonoidalCategory
/--
In a monoidal category, we can take the tensor product of objects, `X β Y` and of morphisms `f β g`.
Tensor product does not need to be strictly associative on objects, but there is a
specified associator, `Ξ±_ X Y Z : (X β Y) β Z β
X β (Y β Z)`. There is a tensor unit `π_ C`,
with specified left and right unitor isomorphisms `Ξ»_ X : π_ C β X β
X` and `Ο_ X : X β π_ C β
X`.
These associators and unitors satisfy the pentagon and triangle equations. -/
@[stacks 0FFK]
-- Porting note: The Mathport did not translate the temporary notation
class MonoidalCategory (C : Type u) [π : Category.{v} C] extends MonoidalCategoryStruct C where
tensorHom_def {Xβ Yβ Xβ Yβ : C} (f : Xβ βΆ Yβ) (g : Xβ βΆ Yβ) :
f β g = (f β· Xβ) β« (Yβ β g) := by
aesop_cat
/-- Tensor product of identity maps is the identity: `(π Xβ β π Xβ) = π (Xβ β Xβ)` -/
tensor_id : β Xβ Xβ : C, π Xβ β π Xβ = π (Xβ β Xβ) := by aesop_cat
/--
Tensor product of compositions is composition of tensor products:
`(fβ β« gβ) β (fβ β« gβ) = (fβ β fβ) β« (gβ β gβ)`
-/
tensor_comp :
β {Xβ Yβ Zβ Xβ Yβ Zβ : C} (fβ : Xβ βΆ Yβ) (fβ : Xβ βΆ Yβ) (gβ : Yβ βΆ Zβ) (gβ : Yβ βΆ Zβ),
(fβ β« gβ) β (fβ β« gβ) = (fβ β fβ) β« (gβ β gβ) := by
aesop_cat
whiskerLeft_id : β (X Y : C), X β π Y = π (X β Y) := by
aesop_cat
id_whiskerRight : β (X Y : C), π X β· Y = π (X β Y) := by
aesop_cat
/-- Naturality of the associator isomorphism: `(fβ β fβ) β fβ β fβ β (fβ β fβ)` -/
associator_naturality :
β {Xβ Xβ Xβ Yβ Yβ Yβ : C} (fβ : Xβ βΆ Yβ) (fβ : Xβ βΆ Yβ) (fβ : Xβ βΆ Yβ),
((fβ β fβ) β fβ) β« (Ξ±_ Yβ Yβ Yβ).hom = (Ξ±_ Xβ Xβ Xβ).hom β« (fβ β (fβ β fβ)) := by
aesop_cat
/--
Naturality of the left unitor, commutativity of `π_ C β X βΆ π_ C β Y βΆ Y` and `π_ C β X βΆ X βΆ Y`
-/
leftUnitor_naturality :
β {X Y : C} (f : X βΆ Y), π_ _ β f β« (Ξ»_ Y).hom = (Ξ»_ X).hom β« f := by
aesop_cat
/--
Naturality of the right unitor: commutativity of `X β π_ C βΆ Y β π_ C βΆ Y` and `X β π_ C βΆ X βΆ Y`
-/
rightUnitor_naturality :
β {X Y : C} (f : X βΆ Y), f β· π_ _ β« (Ο_ Y).hom = (Ο_ X).hom β« f := by
aesop_cat
/--
The pentagon identity relating the isomorphism between `X β (Y β (Z β W))` and `((X β Y) β Z) β W`
-/
pentagon :
β W X Y Z : C,
(Ξ±_ W X Y).hom β· Z β« (Ξ±_ W (X β Y) Z).hom β« W β (Ξ±_ X Y Z).hom =
(Ξ±_ (W β X) Y Z).hom β« (Ξ±_ W X (Y β Z)).hom := by
aesop_cat
/--
The identity relating the isomorphisms between `X β (π_ C β Y)`, `(X β π_ C) β Y` and `X β Y`
-/
triangle :
β X Y : C, (Ξ±_ X (π_ _) Y).hom β« X β (Ξ»_ Y).hom = (Ο_ X).hom β· Y := by
aesop_cat
attribute [reassoc] MonoidalCategory.tensorHom_def
attribute [reassoc, simp] MonoidalCategory.whiskerLeft_id
attribute [reassoc, simp] MonoidalCategory.id_whiskerRight
attribute [reassoc] MonoidalCategory.tensor_comp
attribute [simp] MonoidalCategory.tensor_comp
attribute [reassoc] MonoidalCategory.associator_naturality
attribute [reassoc] MonoidalCategory.leftUnitor_naturality
attribute [reassoc] MonoidalCategory.rightUnitor_naturality
attribute [reassoc (attr := simp)] MonoidalCategory.pentagon
attribute [reassoc (attr := simp)] MonoidalCategory.triangle
namespace MonoidalCategory
variable {C : Type u} [π : Category.{v} C] [MonoidalCategory C]
@[simp]
theorem id_tensorHom (X : C) {Yβ Yβ : C} (f : Yβ βΆ Yβ) :
π X β f = X β f := by
simp [tensorHom_def]
@[simp]
theorem tensorHom_id {Xβ Xβ : C} (f : Xβ βΆ Xβ) (Y : C) :
f β π Y = f β· Y := by
simp [tensorHom_def]
@[reassoc, simp]
theorem whiskerLeft_comp (W : C) {X Y Z : C} (f : X βΆ Y) (g : Y βΆ Z) :
W β (f β« g) = W β f β« W β g := by
simp only [β id_tensorHom, β tensor_comp, comp_id]
@[reassoc, simp]
theorem id_whiskerLeft {X Y : C} (f : X βΆ Y) :
π_ C β f = (Ξ»_ X).hom β« f β« (Ξ»_ Y).inv := by
rw [β assoc, β leftUnitor_naturality]; simp [id_tensorHom]
@[reassoc, simp]
theorem tensor_whiskerLeft (X Y : C) {Z Z' : C} (f : Z βΆ Z') :
(X β Y) β f = (Ξ±_ X Y Z).hom β« X β Y β f β« (Ξ±_ X Y Z').inv := by
simp only [β id_tensorHom, β tensorHom_id]
rw [β assoc, β associator_naturality]
simp
@[reassoc, simp]
theorem comp_whiskerRight {W X Y : C} (f : W βΆ X) (g : X βΆ Y) (Z : C) :
(f β« g) β· Z = f β· Z β« g β· Z := by
simp only [β tensorHom_id, β tensor_comp, id_comp]
@[reassoc, simp]
theorem whiskerRight_id {X Y : C} (f : X βΆ Y) :
f β· π_ C = (Ο_ X).hom β« f β« (Ο_ Y).inv := by
rw [β assoc, β rightUnitor_naturality]; simp [tensorHom_id]
@[reassoc, simp]
theorem whiskerRight_tensor {X X' : C} (f : X βΆ X') (Y Z : C) :
f β· (Y β Z) = (Ξ±_ X Y Z).inv β« f β· Y β· Z β« (Ξ±_ X' Y Z).hom := by
simp only [β id_tensorHom, β tensorHom_id]
rw [associator_naturality]
simp [tensor_id]
@[reassoc, simp]
theorem whisker_assoc (X : C) {Y Y' : C} (f : Y βΆ Y') (Z : C) :
(X β f) β· Z = (Ξ±_ X Y Z).hom β« X β f β· Z β« (Ξ±_ X Y' Z).inv := by
simp only [β id_tensorHom, β tensorHom_id]
rw [β assoc, β associator_naturality]
simp
@[reassoc]
theorem whisker_exchange {W X Y Z : C} (f : W βΆ X) (g : Y βΆ Z) :
W β g β« f β· Z = f β· Y β« X β g := by
simp only [β id_tensorHom, β tensorHom_id, β tensor_comp, id_comp, comp_id]
@[reassoc]
theorem tensorHom_def' {Xβ Yβ Xβ Yβ : C} (f : Xβ βΆ Yβ) (g : Xβ βΆ Yβ) :
f β g = Xβ β g β« f β· Yβ :=
whisker_exchange f g βΈ tensorHom_def f g
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv (X : C) {Y Z : C} (f : Y β
Z) :
X β f.hom β« X β f.inv = π (X β Y) := by
rw [β whiskerLeft_comp, hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight {X Y : C} (f : X β
Y) (Z : C) :
f.hom β· Z β« f.inv β· Z = π (X β Z) := by
rw [β comp_whiskerRight, hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom (X : C) {Y Z : C} (f : Y β
Z) :
X β f.inv β« X β f.hom = π (X β Z) := by
rw [β whiskerLeft_comp, inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight {X Y : C} (f : X β
Y) (Z : C) :
f.inv β· Z β« f.hom β· Z = π (Y β Z) := by
rw [β comp_whiskerRight, inv_hom_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_hom_inv' (X : C) {Y Z : C} (f : Y βΆ Z) [IsIso f] :
X β f β« X β inv f = π (X β Y) := by
rw [β whiskerLeft_comp, IsIso.hom_inv_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem hom_inv_whiskerRight' {X Y : C} (f : X βΆ Y) [IsIso f] (Z : C) :
f β· Z β« inv f β· Z = π (X β Z) := by
rw [β comp_whiskerRight, IsIso.hom_inv_id, id_whiskerRight]
@[reassoc (attr := simp)]
theorem whiskerLeft_inv_hom' (X : C) {Y Z : C} (f : Y βΆ Z) [IsIso f] :
X β inv f β« X β f = π (X β Z) := by
rw [β whiskerLeft_comp, IsIso.inv_hom_id, whiskerLeft_id]
@[reassoc (attr := simp)]
theorem inv_hom_whiskerRight' {X Y : C} (f : X βΆ Y) [IsIso f] (Z : C) :
inv f β· Z β« f β· Z = π (Y β Z) := by
rw [β comp_whiskerRight, IsIso.inv_hom_id, id_whiskerRight]
/-- The left whiskering of an isomorphism is an isomorphism. -/
@[simps]
def whiskerLeftIso (X : C) {Y Z : C} (f : Y β
Z) : X β Y β
X β Z where
hom := X β f.hom
inv := X β f.inv
instance whiskerLeft_isIso (X : C) {Y Z : C} (f : Y βΆ Z) [IsIso f] : IsIso (X β f) :=
(whiskerLeftIso X (asIso f)).isIso_hom
@[simp]
theorem inv_whiskerLeft (X : C) {Y Z : C} (f : Y βΆ Z) [IsIso f] :
inv (X β f) = X β inv f := by
aesop_cat
@[simp]
lemma whiskerLeftIso_refl (W X : C) :
whiskerLeftIso W (Iso.refl X) = Iso.refl (W β X) :=
Iso.ext (whiskerLeft_id W X)
@[simp]
lemma whiskerLeftIso_trans (W : C) {X Y Z : C} (f : X β
Y) (g : Y β
Z) :
whiskerLeftIso W (f βͺβ« g) = whiskerLeftIso W f βͺβ« whiskerLeftIso W g :=
Iso.ext (whiskerLeft_comp W f.hom g.hom)
@[simp]
lemma whiskerLeftIso_symm (W : C) {X Y : C} (f : X β
Y) :
(whiskerLeftIso W f).symm = whiskerLeftIso W f.symm := rfl
/-- The right whiskering of an isomorphism is an isomorphism. -/
@[simps!]
def whiskerRightIso {X Y : C} (f : X β
Y) (Z : C) : X β Z β
Y β Z where
hom := f.hom β· Z
inv := f.inv β· Z
instance whiskerRight_isIso {X Y : C} (f : X βΆ Y) (Z : C) [IsIso f] : IsIso (f β· Z) :=
(whiskerRightIso (asIso f) Z).isIso_hom
@[simp]
theorem inv_whiskerRight {X Y : C} (f : X βΆ Y) (Z : C) [IsIso f] :
inv (f β· Z) = inv f β· Z := by
aesop_cat
@[simp]
lemma whiskerRightIso_refl (X W : C) :
whiskerRightIso (Iso.refl X) W = Iso.refl (X β W) :=
Iso.ext (id_whiskerRight X W)
@[simp]
lemma whiskerRightIso_trans {X Y Z : C} (f : X β
Y) (g : Y β
Z) (W : C) :
whiskerRightIso (f βͺβ« g) W = whiskerRightIso f W βͺβ« whiskerRightIso g W :=
Iso.ext (comp_whiskerRight f.hom g.hom W)
@[simp]
lemma whiskerRightIso_symm {X Y : C} (f : X β
Y) (W : C) :
(whiskerRightIso f W).symm = whiskerRightIso f.symm W := rfl
/-- The tensor product of two isomorphisms is an isomorphism. -/
@[simps]
def tensorIso {X Y X' Y' : C} (f : X β
Y)
(g : X' β
Y') : X β X' β
Y β Y' where
hom := f.hom β g.hom
inv := f.inv β g.inv
hom_inv_id := by rw [β tensor_comp, Iso.hom_inv_id, Iso.hom_inv_id, β tensor_id]
inv_hom_id := by rw [β tensor_comp, Iso.inv_hom_id, Iso.inv_hom_id, β tensor_id]
/-- Notation for `tensorIso`, the tensor product of isomorphisms -/
scoped infixr:70 " β " => tensorIso
theorem tensorIso_def {X Y X' Y' : C} (f : X β
Y) (g : X' β
Y') :
f β g = whiskerRightIso f X' βͺβ« whiskerLeftIso Y g :=
Iso.ext (tensorHom_def f.hom g.hom)
theorem tensorIso_def' {X Y X' Y' : C} (f : X β
Y) (g : X' β
Y') :
f β g = whiskerLeftIso X g βͺβ« whiskerRightIso f Y' :=
Iso.ext (tensorHom_def' f.hom g.hom)
instance tensor_isIso {W X Y Z : C} (f : W βΆ X) [IsIso f] (g : Y βΆ Z) [IsIso g] : IsIso (f β g) :=
(asIso f β asIso g).isIso_hom
@[simp]
theorem inv_tensor {W X Y Z : C} (f : W βΆ X) [IsIso f] (g : Y βΆ Z) [IsIso g] :
inv (f β g) = inv f β inv g := by
simp [tensorHom_def ,whisker_exchange]
variable {W X Y Z : C}
theorem whiskerLeft_dite {P : Prop} [Decidable P]
(X : C) {Y Z : C} (f : P β (Y βΆ Z)) (f' : Β¬P β (Y βΆ Z)) :
X β (if h : P then f h else f' h) = if h : P then X β f h else X β f' h := by
split_ifs <;> rfl
theorem dite_whiskerRight {P : Prop} [Decidable P]
{X Y : C} (f : P β (X βΆ Y)) (f' : Β¬P β (X βΆ Y)) (Z : C) :
(if h : P then f h else f' h) β· Z = if h : P then f h β· Z else f' h β· Z := by
split_ifs <;> rfl
theorem tensor_dite {P : Prop} [Decidable P] {W X Y Z : C} (f : W βΆ X) (g : P β (Y βΆ Z))
(g' : Β¬P β (Y βΆ Z)) : (f β if h : P then g h else g' h) =
if h : P then f β g h else f β g' h := by split_ifs <;> rfl
theorem dite_tensor {P : Prop} [Decidable P] {W X Y Z : C} (f : W βΆ X) (g : P β (Y βΆ Z))
(g' : Β¬P β (Y βΆ Z)) : (if h : P then g h else g' h) β f =
if h : P then g h β f else g' h β f := by split_ifs <;> rfl
@[simp]
theorem whiskerLeft_eqToHom (X : C) {Y Z : C} (f : Y = Z) :
X β eqToHom f = eqToHom (congr_argβ tensorObj rfl f) := by
cases f
simp only [whiskerLeft_id, eqToHom_refl]
@[simp]
theorem eqToHom_whiskerRight {X Y : C} (f : X = Y) (Z : C) :
eqToHom f β· Z = eqToHom (congr_argβ tensorObj f rfl) := by
cases f
simp only [id_whiskerRight, eqToHom_refl]
@[reassoc]
theorem associator_naturality_left {X X' : C} (f : X βΆ X') (Y Z : C) :
f β· Y β· Z β« (Ξ±_ X' Y Z).hom = (Ξ±_ X Y Z).hom β« f β· (Y β Z) := by simp
@[reassoc]
theorem associator_inv_naturality_left {X X' : C} (f : X βΆ X') (Y Z : C) :
f β· (Y β Z) β« (Ξ±_ X' Y Z).inv = (Ξ±_ X Y Z).inv β« f β· Y β· Z := by simp
@[reassoc]
theorem whiskerRight_tensor_symm {X X' : C} (f : X βΆ X') (Y Z : C) :
f β· Y β· Z = (Ξ±_ X Y Z).hom β« f β· (Y β Z) β« (Ξ±_ X' Y Z).inv := by simp
@[reassoc]
theorem associator_naturality_middle (X : C) {Y Y' : C} (f : Y βΆ Y') (Z : C) :
(X β f) β· Z β« (Ξ±_ X Y' Z).hom = (Ξ±_ X Y Z).hom β« X β f β· Z := by simp
@[reassoc]
theorem associator_inv_naturality_middle (X : C) {Y Y' : C} (f : Y βΆ Y') (Z : C) :
X β f β· Z β« (Ξ±_ X Y' Z).inv = (Ξ±_ X Y Z).inv β« (X β f) β· Z := by simp
@[reassoc]
theorem whisker_assoc_symm (X : C) {Y Y' : C} (f : Y βΆ Y') (Z : C) :
X β f β· Z = (Ξ±_ X Y Z).inv β« (X β f) β· Z β« (Ξ±_ X Y' Z).hom := by simp
@[reassoc]
theorem associator_naturality_right (X Y : C) {Z Z' : C} (f : Z βΆ Z') :
(X β Y) β f β« (Ξ±_ X Y Z').hom = (Ξ±_ X Y Z).hom β« X β Y β f := by simp
@[reassoc]
theorem associator_inv_naturality_right (X Y : C) {Z Z' : C} (f : Z βΆ Z') :
X β Y β f β« (Ξ±_ X Y Z').inv = (Ξ±_ X Y Z).inv β« (X β Y) β f := by simp
@[reassoc]
theorem tensor_whiskerLeft_symm (X Y : C) {Z Z' : C} (f : Z βΆ Z') :
X β Y β f = (Ξ±_ X Y Z).inv β« (X β Y) β f β« (Ξ±_ X Y Z').hom := by simp
@[reassoc]
theorem leftUnitor_inv_naturality {X Y : C} (f : X βΆ Y) :
f β« (Ξ»_ Y).inv = (Ξ»_ X).inv β« _ β f := by simp
@[reassoc]
theorem id_whiskerLeft_symm {X X' : C} (f : X βΆ X') :
f = (Ξ»_ X).inv β« π_ C β f β« (Ξ»_ X').hom := by
simp only [id_whiskerLeft, assoc, inv_hom_id, comp_id, inv_hom_id_assoc]
@[reassoc]
theorem rightUnitor_inv_naturality {X X' : C} (f : X βΆ X') :
f β« (Ο_ X').inv = (Ο_ X).inv β« f β· _ := by simp
@[reassoc]
theorem whiskerRight_id_symm {X Y : C} (f : X βΆ Y) :
f = (Ο_ X).inv β« f β· π_ C β« (Ο_ Y).hom := by
simp
theorem whiskerLeft_iff {X Y : C} (f g : X βΆ Y) : π_ C β f = π_ C β g β f = g := by simp
theorem whiskerRight_iff {X Y : C} (f g : X βΆ Y) : f β· π_ C = g β· π_ C β f = g := by simp
/-! The lemmas in the next section are true by coherence,
but we prove them directly as they are used in proving the coherence theorem. -/
section
@[reassoc (attr := simp)]
theorem pentagon_inv :
W β (Ξ±_ X Y Z).inv β« (Ξ±_ W (X β Y) Z).inv β« (Ξ±_ W X Y).inv β· Z =
(Ξ±_ W X (Y β Z)).inv β« (Ξ±_ (W β X) Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_inv_inv_hom_hom_inv :
(Ξ±_ W (X β Y) Z).inv β« (Ξ±_ W X Y).inv β· Z β« (Ξ±_ (W β X) Y Z).hom =
W β (Ξ±_ X Y Z).hom β« (Ξ±_ W X (Y β Z)).inv := by
rw [β cancel_epi (W β (Ξ±_ X Y Z).inv), β cancel_mono (Ξ±_ (W β X) Y Z).inv]
simp
@[reassoc (attr := simp)]
theorem pentagon_inv_hom_hom_hom_inv :
(Ξ±_ (W β X) Y Z).inv β« (Ξ±_ W X Y).hom β· Z β« (Ξ±_ W (X β Y) Z).hom =
(Ξ±_ W X (Y β Z)).hom β« W β (Ξ±_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_inv :
W β (Ξ±_ X Y Z).hom β« (Ξ±_ W X (Y β Z)).inv β« (Ξ±_ (W β X) Y Z).inv =
(Ξ±_ W (X β Y) Z).inv β« (Ξ±_ W X Y).inv β· Z := by
simp [β cancel_epi (W β (Ξ±_ X Y Z).inv)]
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_hom_hom :
(Ξ±_ (W β X) Y Z).hom β« (Ξ±_ W X (Y β Z)).hom β« W β (Ξ±_ X Y Z).inv =
(Ξ±_ W X Y).hom β· Z β« (Ξ±_ W (X β Y) Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem pentagon_hom_inv_inv_inv_hom :
(Ξ±_ W X (Y β Z)).hom β« W β (Ξ±_ X Y Z).inv β« (Ξ±_ W (X β Y) Z).inv =
(Ξ±_ (W β X) Y Z).inv β« (Ξ±_ W X Y).hom β· Z := by
rw [β cancel_epi (Ξ±_ W X (Y β Z)).inv, β cancel_mono ((Ξ±_ W X Y).inv β· Z)]
simp
@[reassoc (attr := simp)]
theorem pentagon_hom_hom_inv_inv_hom :
(Ξ±_ W (X β Y) Z).hom β« W β (Ξ±_ X Y Z).hom β« (Ξ±_ W X (Y β Z)).inv =
(Ξ±_ W X Y).inv β· Z β« (Ξ±_ (W β X) Y Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Category.lean | 543 | 546 | theorem pentagon_inv_hom_hom_hom_hom :
(Ξ±_ W X Y).inv β· Z β« (Ξ±_ (W β X) Y Z).hom β« (Ξ±_ W X (Y β Z)).hom =
(Ξ±_ W (X β Y) Z).hom β« W β (Ξ±_ X Y Z).hom := by | simp [β cancel_epi ((Ξ±_ W X Y).hom β· Z)] |
/-
Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz, Bryan Gin-ge Chen, YaΓ«l Dillies
-/
import Mathlib.Order.BooleanAlgebra
import Mathlib.Logic.Equiv.Basic
/-!
# Symmetric difference and bi-implication
This file defines the symmetric difference and bi-implication operators in (co-)Heyting algebras.
## Examples
Some examples are
* The symmetric difference of two sets is the set of elements that are in either but not both.
* The symmetric difference on propositions is `Xor'`.
* The symmetric difference on `Bool` is `Bool.xor`.
* The equivalence of propositions. Two propositions are equivalent if they imply each other.
* The symmetric difference translates to addition when considering a Boolean algebra as a Boolean
ring.
## Main declarations
* `symmDiff`: The symmetric difference operator, defined as `(a \ b) β (b \ a)`
* `bihimp`: The bi-implication operator, defined as `(b β¨ a) β (a β¨ b)`
In generalized Boolean algebras, the symmetric difference operator is:
* `symmDiff_comm`: commutative, and
* `symmDiff_assoc`: associative.
## Notations
* `a β b`: `symmDiff a b`
* `a β b`: `bihimp a b`
## References
The proof of associativity follows the note "Associativity of the Symmetric Difference of Sets: A
Proof from the Book" by John McCuan:
* <https://people.math.gatech.edu/~mccuan/courses/4317/symmetricdifference.pdf>
## Tags
boolean ring, generalized boolean algebra, boolean algebra, symmetric difference, bi-implication,
Heyting
-/
assert_not_exists RelIso
open Function OrderDual
variable {ΞΉ Ξ± Ξ² : Type*} {Ο : ΞΉ β Type*}
/-- The symmetric difference operator on a type with `β` and `\` is `(A \ B) β (B \ A)`. -/
def symmDiff [Max Ξ±] [SDiff Ξ±] (a b : Ξ±) : Ξ± :=
a \ b β b \ a
/-- The Heyting bi-implication is `(b β¨ a) β (a β¨ b)`. This generalizes equivalence of
propositions. -/
def bihimp [Min Ξ±] [HImp Ξ±] (a b : Ξ±) : Ξ± :=
(b β¨ a) β (a β¨ b)
/-- Notation for symmDiff -/
scoped[symmDiff] infixl:100 " β " => symmDiff
/-- Notation for bihimp -/
scoped[symmDiff] infixl:100 " β " => bihimp
open scoped symmDiff
theorem symmDiff_def [Max Ξ±] [SDiff Ξ±] (a b : Ξ±) : a β b = a \ b β b \ a :=
rfl
theorem bihimp_def [Min Ξ±] [HImp Ξ±] (a b : Ξ±) : a β b = (b β¨ a) β (a β¨ b) :=
rfl
theorem symmDiff_eq_Xor' (p q : Prop) : p β q = Xor' p q :=
rfl
@[simp]
theorem bihimp_iff_iff {p q : Prop} : p β q β (p β q) :=
iff_iff_implies_and_implies.symm.trans Iff.comm
@[simp]
theorem Bool.symmDiff_eq_xor : β p q : Bool, p β q = xor p q := by decide
section GeneralizedCoheytingAlgebra
variable [GeneralizedCoheytingAlgebra Ξ±] (a b c : Ξ±)
@[simp]
theorem toDual_symmDiff : toDual (a β b) = toDual a β toDual b :=
rfl
@[simp]
theorem ofDual_bihimp (a b : Ξ±α΅α΅) : ofDual (a β b) = ofDual a β ofDual b :=
rfl
theorem symmDiff_comm : a β b = b β a := by simp only [symmDiff, sup_comm]
instance symmDiff_isCommutative : Std.Commutative (Ξ± := Ξ±) (Β· β Β·) :=
β¨symmDiff_commβ©
@[simp]
theorem symmDiff_self : a β a = β₯ := by rw [symmDiff, sup_idem, sdiff_self]
@[simp]
theorem symmDiff_bot : a β β₯ = a := by rw [symmDiff, sdiff_bot, bot_sdiff, sup_bot_eq]
@[simp]
theorem bot_symmDiff : β₯ β a = a := by rw [symmDiff_comm, symmDiff_bot]
@[simp]
theorem symmDiff_eq_bot {a b : Ξ±} : a β b = β₯ β a = b := by
simp_rw [symmDiff, sup_eq_bot_iff, sdiff_eq_bot_iff, le_antisymm_iff]
theorem symmDiff_of_le {a b : Ξ±} (h : a β€ b) : a β b = b \ a := by
rw [symmDiff, sdiff_eq_bot_iff.2 h, bot_sup_eq]
theorem symmDiff_of_ge {a b : Ξ±} (h : b β€ a) : a β b = a \ b := by
rw [symmDiff, sdiff_eq_bot_iff.2 h, sup_bot_eq]
theorem symmDiff_le {a b c : Ξ±} (ha : a β€ b β c) (hb : b β€ a β c) : a β b β€ c :=
sup_le (sdiff_le_iff.2 ha) <| sdiff_le_iff.2 hb
theorem symmDiff_le_iff {a b c : Ξ±} : a β b β€ c β a β€ b β c β§ b β€ a β c := by
simp_rw [symmDiff, sup_le_iff, sdiff_le_iff]
@[simp]
theorem symmDiff_le_sup {a b : Ξ±} : a β b β€ a β b :=
sup_le_sup sdiff_le sdiff_le
theorem symmDiff_eq_sup_sdiff_inf : a β b = (a β b) \ (a β b) := by simp [sup_sdiff, symmDiff]
theorem Disjoint.symmDiff_eq_sup {a b : Ξ±} (h : Disjoint a b) : a β b = a β b := by
rw [symmDiff, h.sdiff_eq_left, h.sdiff_eq_right]
theorem symmDiff_sdiff : a β b \ c = a \ (b β c) β b \ (a β c) := by
rw [symmDiff, sup_sdiff_distrib, sdiff_sdiff_left, sdiff_sdiff_left]
@[simp]
theorem symmDiff_sdiff_inf : a β b \ (a β b) = a β b := by
rw [symmDiff_sdiff]
simp [symmDiff]
@[simp]
theorem symmDiff_sdiff_eq_sup : a β (b \ a) = a β b := by
rw [symmDiff, sdiff_idem]
exact
le_antisymm (sup_le_sup sdiff_le sdiff_le)
(sup_le le_sdiff_sup <| le_sdiff_sup.trans <| sup_le le_sup_right le_sdiff_sup)
@[simp]
theorem sdiff_symmDiff_eq_sup : (a \ b) β b = a β b := by
rw [symmDiff_comm, symmDiff_sdiff_eq_sup, sup_comm]
@[simp]
theorem symmDiff_sup_inf : a β b β a β b = a β b := by
refine le_antisymm (sup_le symmDiff_le_sup inf_le_sup) ?_
rw [sup_inf_left, symmDiff]
refine sup_le (le_inf le_sup_right ?_) (le_inf ?_ le_sup_right)
Β· rw [sup_right_comm]
exact le_sup_of_le_left le_sdiff_sup
Β· rw [sup_assoc]
exact le_sup_of_le_right le_sdiff_sup
@[simp]
theorem inf_sup_symmDiff : a β b β a β b = a β b := by rw [sup_comm, symmDiff_sup_inf]
@[simp]
theorem symmDiff_symmDiff_inf : a β b β (a β b) = a β b := by
rw [β symmDiff_sdiff_inf a, sdiff_symmDiff_eq_sup, symmDiff_sup_inf]
@[simp]
theorem inf_symmDiff_symmDiff : (a β b) β (a β b) = a β b := by
rw [symmDiff_comm, symmDiff_symmDiff_inf]
theorem symmDiff_triangle : a β c β€ a β b β b β c := by
refine (sup_le_sup (sdiff_triangle a b c) <| sdiff_triangle _ b _).trans_eq ?_
rw [sup_comm (c \ b), sup_sup_sup_comm, symmDiff, symmDiff]
theorem le_symmDiff_sup_right (a b : Ξ±) : a β€ (a β b) β b := by
convert symmDiff_triangle a b β₯ <;> rw [symmDiff_bot]
theorem le_symmDiff_sup_left (a b : Ξ±) : b β€ (a β b) β a :=
symmDiff_comm a b βΈ le_symmDiff_sup_right ..
end GeneralizedCoheytingAlgebra
section GeneralizedHeytingAlgebra
variable [GeneralizedHeytingAlgebra Ξ±] (a b c : Ξ±)
@[simp]
theorem toDual_bihimp : toDual (a β b) = toDual a β toDual b :=
rfl
@[simp]
theorem ofDual_symmDiff (a b : Ξ±α΅α΅) : ofDual (a β b) = ofDual a β ofDual b :=
rfl
theorem bihimp_comm : a β b = b β a := by simp only [(Β· β Β·), inf_comm]
instance bihimp_isCommutative : Std.Commutative (Ξ± := Ξ±) (Β· β Β·) :=
β¨bihimp_commβ©
@[simp]
theorem bihimp_self : a β a = β€ := by rw [bihimp, inf_idem, himp_self]
@[simp]
theorem bihimp_top : a β β€ = a := by rw [bihimp, himp_top, top_himp, inf_top_eq]
@[simp]
| Mathlib/Order/SymmDiff.lean | 218 | 219 | theorem top_bihimp : β€ β a = a := by | rw [bihimp_comm, bihimp_top] |
/-
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.Quaternion
import Mathlib.Tactic.Ring
/-!
# Basis on a quaternion-like algebra
## Main definitions
* `QuaternionAlgebra.Basis A cβ cβ cβ`: a basis for a subspace of an `R`-algebra `A` that has the
same algebra structure as `β[R,cβ,cβ,cβ]`.
* `QuaternionAlgebra.Basis.self R`: the canonical basis for `β[R,cβ,cβ,cβ]`.
* `QuaternionAlgebra.Basis.compHom b f`: transform a basis `b` by an AlgHom `f`.
* `QuaternionAlgebra.lift`: Define an `AlgHom` out of `β[R,cβ,cβ,cβ]` by its action on the basis
elements `i`, `j`, and `k`. In essence, this is a universal property. Analogous to `Complex.lift`,
but takes a bundled `QuaternionAlgebra.Basis` instead of just a `Subtype` as the amount of
data / proves is non-negligible.
-/
open Quaternion
namespace QuaternionAlgebra
/-- A quaternion basis contains the information both sufficient and necessary to construct an
`R`-algebra homomorphism from `β[R,cβ,cβ,cβ]` to `A`; or equivalently, a surjective
`R`-algebra homomorphism from `β[R,cβ,cβ,cβ]` to an `R`-subalgebra of `A`.
Note that for definitional convenience, `k` is provided as a field even though `i_mul_j` fully
determines it. -/
structure Basis {R : Type*} (A : Type*) [CommRing R] [Ring A] [Algebra R A] (cβ cβ cβ : R) where
/-- The first imaginary unit -/
i : A
/-- The second imaginary unit -/
j : A
/-- The third imaginary unit -/
k : A
i_mul_i : i * i = cβ β’ (1 : A) + cβ β’ i
j_mul_j : j * j = cβ β’ (1 : A)
i_mul_j : i * j = k
j_mul_i : j * i = cβ β’ j - k
variable {R : Type*} {A B : Type*} [CommRing R] [Ring A] [Ring B] [Algebra R A] [Algebra R B]
variable {cβ cβ cβ : R}
namespace Basis
/-- Since `k` is redundant, it is not necessary to show `qβ.k = qβ.k` when showing `qβ = qβ`. -/
@[ext]
protected theorem ext β¦qβ qβ : Basis A cβ cβ cββ¦ (hi : qβ.i = qβ.i)
(hj : qβ.j = qβ.j) : qβ = qβ := by
cases qβ; rename_i qβ_i_mul_j _
cases qβ; rename_i qβ_i_mul_j _
congr
rw [β qβ_i_mul_j, β qβ_i_mul_j]
congr
variable (R) in
/-- There is a natural quaternionic basis for the `QuaternionAlgebra`. -/
@[simps i j k]
protected def self : Basis β[R,cβ,cβ,cβ] cβ cβ cβ where
i := β¨0, 1, 0, 0β©
i_mul_i := by ext <;> simp
j := β¨0, 0, 1, 0β©
j_mul_j := by ext <;> simp
k := β¨0, 0, 0, 1β©
i_mul_j := by ext <;> simp
j_mul_i := by ext <;> simp
instance : Inhabited (Basis β[R,cβ,cβ,cβ] cβ cβ cβ) :=
β¨Basis.self Rβ©
variable (q : Basis A cβ cβ cβ)
attribute [simp] i_mul_i j_mul_j i_mul_j j_mul_i
@[simp]
theorem i_mul_k : q.i * q.k = cβ β’ q.j + cβ β’ q.k := by
rw [β i_mul_j, β mul_assoc, i_mul_i, add_mul, smul_mul_assoc, one_mul, smul_mul_assoc]
@[simp]
theorem k_mul_i : q.k * q.i = -cβ β’ q.j := by
rw [β i_mul_j, mul_assoc, j_mul_i, mul_sub, i_mul_k, neg_smul, mul_smul_comm, i_mul_j]
linear_combination (norm := module)
@[simp]
theorem k_mul_j : q.k * q.j = cβ β’ q.i := by
rw [β i_mul_j, mul_assoc, j_mul_j, mul_smul_comm, mul_one]
@[simp]
theorem j_mul_k : q.j * q.k = (cβ * cβ) β’ 1 - cβ β’ q.i := by
rw [β i_mul_j, β mul_assoc, j_mul_i, sub_mul, smul_mul_assoc, j_mul_j, β smul_assoc, k_mul_j]
rfl
@[simp]
theorem k_mul_k : q.k * q.k = -((cβ * cβ) β’ (1 : A)) := by
rw [β i_mul_j, mul_assoc, β mul_assoc q.j _ _, j_mul_i, β i_mul_j, β mul_assoc, mul_sub, β
mul_assoc, i_mul_i, add_mul, smul_mul_assoc, one_mul, sub_mul, smul_mul_assoc, mul_smul_comm,
smul_mul_assoc, mul_assoc, j_mul_j, add_mul, smul_mul_assoc, j_mul_j, smul_smul,
smul_mul_assoc, mul_assoc, j_mul_j]
linear_combination (norm := module)
/-- Intermediate result used to define `QuaternionAlgebra.Basis.liftHom`. -/
def lift (x : β[R,cβ,cβ,cβ]) : A :=
algebraMap R _ x.re + x.imI β’ q.i + x.imJ β’ q.j + x.imK β’ q.k
theorem lift_zero : q.lift (0 : β[R,cβ,cβ,cβ]) = 0 := by simp [lift]
| Mathlib/Algebra/QuaternionBasis.lean | 114 | 114 | theorem lift_one : q.lift (1 : β[R,cβ,cβ,cβ]) = 1 := by | simp [lift] |
/-
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, Eric Wieser
-/
import Mathlib.Algebra.GroupWithZero.Action.Pointwise.Set
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Algebra.Order.Module.Pointwise
import Mathlib.Data.Real.Archimedean
/-!
# Pointwise operations on sets of reals
This file relates `sInf (a β’ s)`/`sSup (a β’ s)` with `a β’ sInf s`/`a β’ sSup s` for `s : Set β`.
From these, it relates `β¨
i, a β’ f i` / `β¨ i, a β’ f i` with `a β’ (β¨
i, f i)` / `a β’ (β¨ i, f i)`,
and provides lemmas about distributing `*` over `β¨
` and `β¨`.
## TODO
This is true more generally for conditionally complete linear order whose default value is `0`. We
don't have those yet.
-/
assert_not_exists Finset
open Set
open Pointwise
variable {ΞΉ : Sort*} {Ξ± : Type*} [Field Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±]
section MulActionWithZero
variable [MulActionWithZero Ξ± β] [OrderedSMul Ξ± β] {a : Ξ±}
| Mathlib/Data/Real/Pointwise.lean | 37 | 46 | theorem Real.sInf_smul_of_nonneg (ha : 0 β€ a) (s : Set β) : sInf (a β’ s) = a β’ sInf s := by | obtain rfl | hs := s.eq_empty_or_nonempty
Β· rw [smul_set_empty, Real.sInf_empty, smul_zero]
obtain rfl | ha' := ha.eq_or_lt
Β· rw [zero_smul_set hs, zero_smul]
exact csInf_singleton 0
by_cases h : BddBelow s
Β· exact ((OrderIso.smulRight ha').map_csInf' hs h).symm
Β· rw [Real.sInf_of_not_bddBelow (mt (bddBelow_smul_iff_of_pos ha').1 h),
Real.sInf_of_not_bddBelow h, smul_zero] |
/-
Copyright (c) 2024 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.MeasureTheory.Integral.PeakFunction
import Mathlib.Analysis.SpecialFunctions.Gaussian.FourierTransform
/-!
# Fourier inversion formula
In a finite-dimensional real inner product space, we show the Fourier inversion formula, i.e.,
`πβ» (π f) v = f v` if `f` and `π f` are integrable, and `f` is continuous at `v`. This is proved
in `MeasureTheory.Integrable.fourier_inversion`. See also `Continuous.fourier_inversion`
giving `πβ» (π f) = f` under an additional continuity assumption for `f`.
We use the following proof. A naΓ―ve computation gives
`πβ» (π f) v
= β«_w exp (2 I Ο βͺw, vβ«) π f (w) dw
= β«_w exp (2 I Ο βͺw, vβ«) β«_x, exp (-2 I Ο βͺw, xβ«) f x dx) dw
= β«_x (β«_ w, exp (2 I Ο βͺw, v - xβ« dw) f x dx `
However, the Fubini step does not make sense for lack of integrability, and the middle integral
`β«_ w, exp (2 I Ο βͺw, v - xβ« dw` (which one would like to be a Dirac at `v - x`) is not defined.
To gain integrability, one multiplies with a Gaussian function `exp (-cβ»ΒΉ βwβ^2)`, with a large
(but finite) `c`. As this function converges pointwise to `1` when `c β β`, we get
`β«_w exp (2 I Ο βͺw, vβ«) π f (w) dw = lim_c β«_w exp (-cβ»ΒΉ βwβ^2 + 2 I Ο βͺw, vβ«) π f (w) dw`.
One can perform Fubini on the right hand side for fixed `c`, writing the integral as
`β«_x (β«_w exp (-cβ»ΒΉβwβ^2 + 2 I Ο βͺw, v - xβ« dw)) f x dx`.
The middle factor is the Fourier transform of a more and more flat function
(converging to the constant `1`), hence it becomes more and more concentrated, around the
point `v`. (Morally, it converges to the Dirac at `v`). Moreover, it has integral one.
Therefore, multiplying by `f` and integrating, one gets a term converging to `f v` as `c β β`.
Since it also converges to `πβ» (π f) v`, this proves the result.
To check the concentration property of the middle factor and the fact that it has integral one, we
rely on the explicit computation of the Fourier transform of Gaussians.
-/
open Filter MeasureTheory Complex Module Metric Real Bornology
open scoped Topology FourierTransform RealInnerProductSpace Complex
variable {V E : Type*} [NormedAddCommGroup V] [InnerProductSpace β V]
[MeasurableSpace V] [BorelSpace V] [FiniteDimensional β V]
[NormedAddCommGroup E] [NormedSpace β E] {f : V β E}
namespace Real
lemma tendsto_integral_cexp_sq_smul (hf : Integrable f) :
Tendsto (fun (c : β) β¦ (β« v : V, cexp (- cβ»ΒΉ * βvβ^2) β’ f v))
atTop (π (β« v : V, f v)) := by
apply tendsto_integral_filter_of_dominated_convergence _ _ _ hf.norm
Β· filter_upwards with v
nth_rewrite 2 [show f v = cexp (- (0 : β) * βvβ^2) β’ f v by simp]
apply (Tendsto.cexp _).smul_const
exact tendsto_inv_atTop_zero.ofReal.neg.mul_const _
Β· filter_upwards with c using
AEStronglyMeasurable.smul (Continuous.aestronglyMeasurable (by fun_prop)) hf.1
Β· filter_upwards [Ici_mem_atTop (0 : β)] with c (hc : 0 β€ c)
filter_upwards with v
simp only [ofReal_inv, neg_mul, norm_smul]
norm_cast
conv_rhs => rw [β one_mul (βf vβ)]
gcongr
simp only [norm_eq_abs, abs_exp, exp_le_one_iff, Left.neg_nonpos_iff]
positivity
variable [CompleteSpace E]
lemma tendsto_integral_gaussian_smul (hf : Integrable f) (h'f : Integrable (π f)) (v : V) :
Tendsto (fun (c : β) β¦
β« w : V, ((Ο * c) ^ (finrank β V / 2 : β) * cexp (-Ο ^ 2 * c * βv - wβ ^ 2)) β’ f w)
atTop (π (πβ» (π f) v)) := by
have A : Tendsto (fun (c : β) β¦ (β« w : V, cexp (- cβ»ΒΉ * βwβ^2 + 2 * Ο * I * βͺv, wβ«)
β’ (π f) w)) atTop (π (πβ» (π f) v)) := by
have : Integrable (fun w β¦ π βͺw, vβ« β’ (π f) w) := by
have B : Continuous fun p : V Γ V => (- innerβ V) p.1 p.2 := continuous_inner.neg
simpa using
(VectorFourier.fourierIntegral_convergent_iff Real.continuous_fourierChar B v).2 h'f
convert tendsto_integral_cexp_sq_smul this using 4 with c w
Β· rw [Submonoid.smul_def, Real.fourierChar_apply, smul_smul, β Complex.exp_add, real_inner_comm]
congr 3
simp only [ofReal_mul, ofReal_ofNat]
ring
Β· simp [fourierIntegralInv_eq]
have B : Tendsto (fun (c : β) β¦ (β« w : V,
π (fun w β¦ cexp (- cβ»ΒΉ * βwβ^2 + 2 * Ο * I * βͺv, wβ«)) w β’ f w)) atTop
(π (πβ» (π f) v)) := by
apply A.congr'
filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c)
have J : Integrable (fun w β¦ cexp (- cβ»ΒΉ * βwβ^2 + 2 * Ο * I * βͺv, wβ«)) :=
GaussianFourier.integrable_cexp_neg_mul_sq_norm_add (by simpa) _ _
simpa using (VectorFourier.integral_fourierIntegral_smul_eq_flip (L := innerβ V)
Real.continuous_fourierChar continuous_inner J hf).symm
apply B.congr'
filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c)
congr with w
rw [fourierIntegral_gaussian_innerProductSpace' (by simpa)]
congr
Β· simp
Β· simp; ring
lemma tendsto_integral_gaussian_smul' (hf : Integrable f) {v : V} (h'f : ContinuousAt f v) :
Tendsto (fun (c : β) β¦
β« w : V, ((Ο * c : β) ^ (finrank β V / 2 : β) * cexp (-Ο ^ 2 * c * βv - wβ ^ 2)) β’ f w)
atTop (π (f v)) := by
let Ο : V β β := fun w β¦ Ο ^ (finrank β V / 2 : β) * Real.exp (-Ο^2 * βwβ^2)
have A : Tendsto (fun (c : β) β¦ β« w : V, (c ^ finrank β V * Ο (c β’ (v - w))) β’ f w)
atTop (π (f v)) := by
apply tendsto_integral_comp_smul_smul_of_integrable'
Β· exact fun x β¦ by positivity
Β· rw [integral_const_mul, GaussianFourier.integral_rexp_neg_mul_sq_norm (by positivity)]
nth_rewrite 2 [β pow_one Ο]
rw [β rpow_natCast, β rpow_natCast, β rpow_sub pi_pos, β rpow_mul pi_nonneg,
β rpow_add pi_pos]
ring_nf
exact rpow_zero _
Β· have A : Tendsto (fun (w : V) β¦ Ο^2 * βwβ^2) (cobounded V) atTop := by
rw [tendsto_const_mul_atTop_of_pos (by positivity)]
apply (tendsto_pow_atTop two_ne_zero).comp tendsto_norm_cobounded_atTop
have B := tendsto_rpow_mul_exp_neg_mul_atTop_nhds_zero (finrank β V / 2) 1
zero_lt_one |>.comp A |>.const_mul (Ο ^ (-finrank β V / 2 : β))
rw [mul_zero] at B
convert B using 2 with x
simp only [neg_mul, one_mul, Function.comp_apply, β mul_assoc, β rpow_natCast, Ο]
congr 1
rw [mul_rpow (by positivity) (by positivity), β rpow_mul pi_nonneg,
β rpow_mul (norm_nonneg _), β mul_assoc, β rpow_add pi_pos, mul_comm]
congr <;> ring
Β· exact hf
Β· exact h'f
have B : Tendsto
(fun (c : β) β¦ β« w : V, ((c^(1/2 : β)) ^ finrank β V * Ο ((c^(1/2 : β)) β’ (v - w))) β’ f w)
atTop (π (f v)) :=
A.comp (tendsto_rpow_atTop (by norm_num))
apply B.congr'
filter_upwards [Ioi_mem_atTop 0] with c (hc : 0 < c)
congr with w
rw [β coe_smul]
congr
rw [ofReal_mul, ofReal_mul, ofReal_exp, β mul_assoc]
congr
Β· rw [mul_cpow_ofReal_nonneg pi_nonneg hc.le, β rpow_natCast, β rpow_mul hc.le, mul_comm,
ofReal_cpow pi_nonneg, ofReal_cpow hc.le]
simp [div_eq_inv_mul]
Β· norm_cast
simp only [one_div, norm_smul, Real.norm_eq_abs, mul_pow, sq_abs, neg_mul, neg_inj,
β rpow_natCast, β rpow_mul hc.le, mul_assoc]
norm_num
end Real
variable [CompleteSpace E]
/-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product
space is integrable, and its Fourier transform `π f` is also integrable, then `πβ» (π f) = f` at
continuity points of `f`. -/
theorem MeasureTheory.Integrable.fourier_inversion
(hf : Integrable f) (h'f : Integrable (π f)) {v : V}
(hv : ContinuousAt f v) : πβ» (π f) v = f v :=
tendsto_nhds_unique (Real.tendsto_integral_gaussian_smul hf h'f v)
(Real.tendsto_integral_gaussian_smul' hf hv)
/-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product
space is continuous, integrable, and its Fourier transform `π f` is also integrable,
then `πβ» (π f) = f`. -/
theorem Continuous.fourier_inversion (h : Continuous f)
(hf : Integrable f) (h'f : Integrable (π f)) :
πβ» (π f) = f := by
ext v
exact hf.fourier_inversion h'f h.continuousAt
/-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product
space is integrable, and its Fourier transform `π f` is also integrable, then `π (πβ» f) = f` at
continuity points of `f`. -/
theorem MeasureTheory.Integrable.fourier_inversion_inv
(hf : Integrable f) (h'f : Integrable (π f)) {v : V}
(hv : ContinuousAt f v) : π (πβ» f) v = f v := by
rw [fourierIntegralInv_comm]
exact fourier_inversion hf h'f hv
/-- **Fourier inversion formula**: If a function `f` on a finite-dimensional real inner product
space is continuous, integrable, and its Fourier transform `π f` is also integrable,
then `π (πβ» f) = f`. -/
| Mathlib/Analysis/Fourier/Inversion.lean | 186 | 190 | theorem Continuous.fourier_inversion_inv (h : Continuous f)
(hf : Integrable f) (h'f : Integrable (π f)) :
π (πβ» f) = f := by | ext v
exact hf.fourier_inversion_inv h'f h.continuousAt |
/-
Copyright (c) 2022 SΓ©bastien GouΓ«zel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SΓ©bastien GouΓ«zel
-/
import Mathlib.Probability.IdentDistrib
import Mathlib.Probability.Independence.Integrable
import Mathlib.MeasureTheory.Integral.DominatedConvergence
import Mathlib.Analysis.SpecificLimits.FloorPow
import Mathlib.Analysis.PSeries
import Mathlib.Analysis.Asymptotics.SpecificAsymptotics
/-!
# The strong law of large numbers
We prove the strong law of large numbers, in `ProbabilityTheory.strong_law_ae`:
If `X n` is a sequence of independent identically distributed integrable random
variables, then `β i β range n, X i / n` converges almost surely to `πΌ[X 0]`.
We give here the strong version, due to Etemadi, that only requires pairwise independence.
This file also contains the Lα΅ version of the strong law of large numbers provided by
`ProbabilityTheory.strong_law_Lp` which shows `β i β range n, X i / n` converges in Lα΅ to
`πΌ[X 0]` provided `X n` is independent identically distributed and is Lα΅.
## Implementation
The main point is to prove the result for real-valued random variables, as the general case
of Banach-space valued random variables follows from this case and approximation by simple
functions. The real version is given in `ProbabilityTheory.strong_law_ae_real`.
We follow the proof by Etemadi
[Etemadi, *An elementary proof of the strong law of large numbers*][etemadi_strong_law],
which goes as follows.
It suffices to prove the result for nonnegative `X`, as one can prove the general result by
splitting a general `X` into its positive part and negative part.
Consider `Xβ` a sequence of nonnegative integrable identically distributed pairwise independent
random variables. Let `Yβ` be the truncation of `Xβ` up to `n`. We claim that
* Almost surely, `Xβ = Yβ` for all but finitely many indices. Indeed, `β β (Xβ β Yβ)` is bounded by
`1 + πΌ[X]` (see `sum_prob_mem_Ioc_le` and `tsum_prob_mem_Ioi_lt_top`).
* Let `c > 1`. Along the sequence `n = c ^ k`, then `(β_{i=0}^{n-1} Yα΅’ - πΌ[Yα΅’])/n` converges almost
surely to `0`. This follows from a variance control, as
```
β_k β (|β_{i=0}^{c^k - 1} Yα΅’ - πΌ[Yα΅’]| > c^k Ξ΅)
β€ β_k (c^k Ξ΅)^{-2} β_{i=0}^{c^k - 1} Var[Yα΅’] (by Markov inequality)
β€ β_i (C/i^2) Var[Yα΅’] (as β_{c^k > i} 1/(c^k)^2 β€ C/i^2)
β€ β_i (C/i^2) πΌ[Yα΅’^2]
β€ 2C πΌ[X^2] (see `sum_variance_truncation_le`)
```
* As `πΌ[Yα΅’]` converges to `πΌ[X]`, it follows from the two previous items and CesΓ ro that, along
the sequence `n = c^k`, one has `(β_{i=0}^{n-1} Xα΅’) / n β πΌ[X]` almost surely.
* To generalize it to all indices, we use the fact that `β_{i=0}^{n-1} Xα΅’` is nondecreasing and
that, if `c` is close enough to `1`, the gap between `c^k` and `c^(k+1)` is small.
-/
noncomputable section
open MeasureTheory Filter Finset Asymptotics
open Set (indicator)
open scoped Topology MeasureTheory ProbabilityTheory ENNReal NNReal
open scoped Function -- required for scoped `on` notation
namespace ProbabilityTheory
/-! ### Prerequisites on truncations -/
section Truncation
variable {Ξ± : Type*}
/-- Truncating a real-valued function to the interval `(-A, A]`. -/
def truncation (f : Ξ± β β) (A : β) :=
indicator (Set.Ioc (-A) A) id β f
variable {m : MeasurableSpace Ξ±} {ΞΌ : Measure Ξ±} {f : Ξ± β β}
theorem _root_.MeasureTheory.AEStronglyMeasurable.truncation (hf : AEStronglyMeasurable f ΞΌ)
{A : β} : AEStronglyMeasurable (truncation f A) ΞΌ := by
apply AEStronglyMeasurable.comp_aemeasurable _ hf.aemeasurable
exact (stronglyMeasurable_id.indicator measurableSet_Ioc).aestronglyMeasurable
theorem abs_truncation_le_bound (f : Ξ± β β) (A : β) (x : Ξ±) : |truncation f A x| β€ |A| := by
simp only [truncation, Set.indicator, Set.mem_Icc, id, Function.comp_apply]
split_ifs with h
Β· exact abs_le_abs h.2 (neg_le.2 h.1.le)
Β· simp [abs_nonneg]
@[simp]
theorem truncation_zero (f : Ξ± β β) : truncation f 0 = 0 := by simp [truncation]; rfl
theorem abs_truncation_le_abs_self (f : Ξ± β β) (A : β) (x : Ξ±) : |truncation f A x| β€ |f x| := by
simp only [truncation, indicator, Set.mem_Icc, id, Function.comp_apply]
split_ifs
Β· exact le_rfl
Β· simp [abs_nonneg]
theorem truncation_eq_self {f : Ξ± β β} {A : β} {x : Ξ±} (h : |f x| < A) :
truncation f A x = f x := by
simp only [truncation, indicator, Set.mem_Icc, id, Function.comp_apply, ite_eq_left_iff]
intro H
apply H.elim
simp [(abs_lt.1 h).1, (abs_lt.1 h).2.le]
theorem truncation_eq_of_nonneg {f : Ξ± β β} {A : β} (h : β x, 0 β€ f x) :
truncation f A = indicator (Set.Ioc 0 A) id β f := by
ext x
rcases (h x).lt_or_eq with (hx | hx)
Β· simp only [truncation, indicator, hx, Set.mem_Ioc, id, Function.comp_apply]
by_cases h'x : f x β€ A
Β· have : -A < f x := by linarith [h x]
simp only [this, true_and]
Β· simp only [h'x, and_false]
Β· simp only [truncation, indicator, hx, id, Function.comp_apply, ite_self]
theorem truncation_nonneg {f : Ξ± β β} (A : β) {x : Ξ±} (h : 0 β€ f x) : 0 β€ truncation f A x :=
Set.indicator_apply_nonneg fun _ => h
theorem _root_.MeasureTheory.AEStronglyMeasurable.memLp_truncation [IsFiniteMeasure ΞΌ]
(hf : AEStronglyMeasurable f ΞΌ) {A : β} {p : ββ₯0β} : MemLp (truncation f A) p ΞΌ :=
MemLp.of_bound hf.truncation |A| (Eventually.of_forall fun _ => abs_truncation_le_bound _ _ _)
theorem _root_.MeasureTheory.AEStronglyMeasurable.integrable_truncation [IsFiniteMeasure ΞΌ]
(hf : AEStronglyMeasurable f ΞΌ) {A : β} : Integrable (truncation f A) ΞΌ := by
rw [β memLp_one_iff_integrable]; exact hf.memLp_truncation
theorem moment_truncation_eq_intervalIntegral (hf : AEStronglyMeasurable f ΞΌ) {A : β} (hA : 0 β€ A)
{n : β} (hn : n β 0) : β« x, truncation f A x ^ n βΞΌ = β« y in -A..A, y ^ n βMeasure.map f ΞΌ := by
have M : MeasurableSet (Set.Ioc (-A) A) := measurableSet_Ioc
change β« x, (fun z => indicator (Set.Ioc (-A) A) id z ^ n) (f x) βΞΌ = _
rw [β integral_map (f := fun z => _ ^ n) hf.aemeasurable, intervalIntegral.integral_of_le,
β integral_indicator M]
Β· simp only [indicator, zero_pow hn, id, ite_pow]
Β· linarith
Β· exact ((measurable_id.indicator M).pow_const n).aestronglyMeasurable
theorem moment_truncation_eq_intervalIntegral_of_nonneg (hf : AEStronglyMeasurable f ΞΌ) {A : β}
{n : β} (hn : n β 0) (h'f : 0 β€ f) :
β« x, truncation f A x ^ n βΞΌ = β« y in (0)..A, y ^ n βMeasure.map f ΞΌ := by
have M : MeasurableSet (Set.Ioc 0 A) := measurableSet_Ioc
have M' : MeasurableSet (Set.Ioc A 0) := measurableSet_Ioc
rw [truncation_eq_of_nonneg h'f]
change β« x, (fun z => indicator (Set.Ioc 0 A) id z ^ n) (f x) βΞΌ = _
rcases le_or_lt 0 A with (hA | hA)
Β· rw [β integral_map (f := fun z => _ ^ n) hf.aemeasurable, intervalIntegral.integral_of_le hA,
β integral_indicator M]
Β· simp only [indicator, zero_pow hn, id, ite_pow]
Β· exact ((measurable_id.indicator M).pow_const n).aestronglyMeasurable
Β· rw [β integral_map (f := fun z => _ ^ n) hf.aemeasurable, intervalIntegral.integral_of_ge hA.le,
β integral_indicator M']
Β· simp only [Set.Ioc_eq_empty_of_le hA.le, zero_pow hn, Set.indicator_empty, integral_zero,
zero_eq_neg]
apply integral_eq_zero_of_ae
have : βα΅ x βMeasure.map f ΞΌ, (0 : β) β€ x :=
(ae_map_iff hf.aemeasurable measurableSet_Ici).2 (Eventually.of_forall h'f)
filter_upwards [this] with x hx
simp only [indicator, Set.mem_Ioc, Pi.zero_apply, ite_eq_right_iff, and_imp]
intro _ h''x
have : x = 0 := by linarith
simp [this, zero_pow hn]
Β· exact ((measurable_id.indicator M).pow_const n).aestronglyMeasurable
theorem integral_truncation_eq_intervalIntegral (hf : AEStronglyMeasurable f ΞΌ) {A : β}
(hA : 0 β€ A) : β« x, truncation f A x βΞΌ = β« y in -A..A, y βMeasure.map f ΞΌ := by
simpa using moment_truncation_eq_intervalIntegral hf hA one_ne_zero
theorem integral_truncation_eq_intervalIntegral_of_nonneg (hf : AEStronglyMeasurable f ΞΌ) {A : β}
(h'f : 0 β€ f) : β« x, truncation f A x βΞΌ = β« y in (0)..A, y βMeasure.map f ΞΌ := by
simpa using moment_truncation_eq_intervalIntegral_of_nonneg hf one_ne_zero h'f
theorem integral_truncation_le_integral_of_nonneg (hf : Integrable f ΞΌ) (h'f : 0 β€ f) {A : β} :
β« x, truncation f A x βΞΌ β€ β« x, f x βΞΌ := by
apply integral_mono_of_nonneg
(Eventually.of_forall fun x => ?_) hf (Eventually.of_forall fun x => ?_)
Β· exact truncation_nonneg _ (h'f x)
Β· calc
truncation f A x β€ |truncation f A x| := le_abs_self _
_ β€ |f x| := abs_truncation_le_abs_self _ _ _
_ = f x := abs_of_nonneg (h'f x)
/-- If a function is integrable, then the integral of its truncated versions converges to the
integral of the whole function. -/
theorem tendsto_integral_truncation {f : Ξ± β β} (hf : Integrable f ΞΌ) :
Tendsto (fun A => β« x, truncation f A x βΞΌ) atTop (π (β« x, f x βΞΌ)) := by
refine tendsto_integral_filter_of_dominated_convergence (fun x => abs (f x)) ?_ ?_ ?_ ?_
Β· exact Eventually.of_forall fun A β¦ hf.aestronglyMeasurable.truncation
Β· filter_upwards with A
filter_upwards with x
rw [Real.norm_eq_abs]
exact abs_truncation_le_abs_self _ _ _
Β· exact hf.abs
Β· filter_upwards with x
apply tendsto_const_nhds.congr' _
filter_upwards [Ioi_mem_atTop (abs (f x))] with A hA
exact (truncation_eq_self hA).symm
theorem IdentDistrib.truncation {Ξ² : Type*} [MeasurableSpace Ξ²] {Ξ½ : Measure Ξ²} {f : Ξ± β β}
{g : Ξ² β β} (h : IdentDistrib f g ΞΌ Ξ½) {A : β} :
IdentDistrib (truncation f A) (truncation g A) ΞΌ Ξ½ :=
h.comp (measurable_id.indicator measurableSet_Ioc)
end Truncation
section StrongLawAeReal
variable {Ξ© : Type*} [MeasureSpace Ξ©] [IsProbabilityMeasure (β : Measure Ξ©)]
section MomentEstimates
theorem sum_prob_mem_Ioc_le {X : Ξ© β β} (hint : Integrable X) (hnonneg : 0 β€ X) {K : β} {N : β}
(hKN : K β€ N) :
β j β range K, β {Ο | X Ο β Set.Ioc (j : β) N} β€ ENNReal.ofReal (πΌ[X] + 1) := by
let Ο : Measure β := Measure.map X β
haveI : IsProbabilityMeasure Ο := isProbabilityMeasure_map hint.aemeasurable
have A : β j β range K, β« _ in j..N, (1 : β) βΟ β€ πΌ[X] + 1 :=
calc
β j β range K, β« _ in j..N, (1 : β) βΟ =
β j β range K, β i β Ico j N, β« _ in i..(i + 1 : β), (1 : β) βΟ := by
apply sum_congr rfl fun j hj => ?_
rw [intervalIntegral.sum_integral_adjacent_intervals_Ico ((mem_range.1 hj).le.trans hKN)]
intro k _
exact continuous_const.intervalIntegrable _ _
_ = β i β range N, β j β range (min (i + 1) K), β« _ in i..(i + 1 : β), (1 : β) βΟ := by
simp_rw [sum_sigma']
refine sum_nbij' (fun p β¦ β¨p.2, p.1β©) (fun p β¦ β¨p.2, p.1β©) ?_ ?_ ?_ ?_ ?_ <;>
aesop (add simp Nat.lt_succ_iff)
_ β€ β i β range N, (i + 1) * β« _ in i..(i + 1 : β), (1 : β) βΟ := by
apply sum_le_sum fun i _ => ?_
simp only [Nat.cast_add, Nat.cast_one, sum_const, card_range, nsmul_eq_mul, Nat.cast_min]
refine mul_le_mul_of_nonneg_right (min_le_left _ _) ?_
apply intervalIntegral.integral_nonneg
Β· simp only [le_add_iff_nonneg_right, zero_le_one]
Β· simp only [zero_le_one, imp_true_iff]
_ β€ β i β range N, β« x in i..(i + 1 : β), x + 1 βΟ := by
apply sum_le_sum fun i _ => ?_
have I : (i : β) β€ (i + 1 : β) := by
simp only [Nat.cast_add, Nat.cast_one, le_add_iff_nonneg_right, zero_le_one]
simp_rw [intervalIntegral.integral_of_le I, β integral_const_mul]
apply setIntegral_mono_on
Β· exact continuous_const.integrableOn_Ioc
Β· exact (continuous_id.add continuous_const).integrableOn_Ioc
Β· exact measurableSet_Ioc
Β· intro x hx
simp only [Nat.cast_add, Nat.cast_one, Set.mem_Ioc] at hx
simp [hx.1.le]
_ = β« x in (0)..N, x + 1 βΟ := by
rw [intervalIntegral.sum_integral_adjacent_intervals fun k _ => ?_]
Β· norm_cast
Β· exact (continuous_id.add continuous_const).intervalIntegrable _ _
_ = β« x in (0)..N, x βΟ + β« x in (0)..N, 1 βΟ := by
rw [intervalIntegral.integral_add]
Β· exact continuous_id.intervalIntegrable _ _
Β· exact continuous_const.intervalIntegrable _ _
_ = πΌ[truncation X N] + β« x in (0)..N, 1 βΟ := by
rw [integral_truncation_eq_intervalIntegral_of_nonneg hint.1 hnonneg]
_ β€ πΌ[X] + β« x in (0)..N, 1 βΟ :=
(add_le_add_right (integral_truncation_le_integral_of_nonneg hint hnonneg) _)
_ β€ πΌ[X] + 1 := by
refine add_le_add le_rfl ?_
rw [intervalIntegral.integral_of_le (Nat.cast_nonneg _)]
simp only [integral_const, measureReal_restrict_apply', measurableSet_Ioc, Set.univ_inter,
Algebra.id.smul_eq_mul, mul_one]
rw [β ENNReal.toReal_one]
exact ENNReal.toReal_mono ENNReal.one_ne_top prob_le_one
have B : β a b, β {Ο | X Ο β Set.Ioc a b} = ENNReal.ofReal (β« _ in Set.Ioc a b, (1 : β) βΟ) := by
intro a b
rw [ofReal_setIntegral_one Ο _,
Measure.map_apply_of_aemeasurable hint.aemeasurable measurableSet_Ioc]
rfl
calc
β j β range K, β {Ο | X Ο β Set.Ioc (j : β) N} =
β j β range K, ENNReal.ofReal (β« _ in Set.Ioc (j : β) N, (1 : β) βΟ) := by simp_rw [B]
_ = ENNReal.ofReal (β j β range K, β« _ in Set.Ioc (j : β) N, (1 : β) βΟ) := by
simp [ENNReal.ofReal_sum_of_nonneg]
_ = ENNReal.ofReal (β j β range K, β« _ in (j : β)..N, (1 : β) βΟ) := by
congr 1
refine sum_congr rfl fun j hj => ?_
rw [intervalIntegral.integral_of_le (Nat.cast_le.2 ((mem_range.1 hj).le.trans hKN))]
_ β€ ENNReal.ofReal (πΌ[X] + 1) := ENNReal.ofReal_le_ofReal A
theorem tsum_prob_mem_Ioi_lt_top {X : Ξ© β β} (hint : Integrable X) (hnonneg : 0 β€ X) :
(β' j : β, β {Ο | X Ο β Set.Ioi (j : β)}) < β := by
suffices β K : β, β j β range K, β {Ο | X Ο β Set.Ioi (j : β)} β€ ENNReal.ofReal (πΌ[X] + 1) from
(le_of_tendsto_of_tendsto (ENNReal.tendsto_nat_tsum _) tendsto_const_nhds
(Eventually.of_forall this)).trans_lt ENNReal.ofReal_lt_top
intro K
have A : Tendsto (fun N : β => β j β range K, β {Ο | X Ο β Set.Ioc (j : β) N}) atTop
(π (β j β range K, β {Ο | X Ο β Set.Ioi (j : β)})) := by
refine tendsto_finset_sum _ fun i _ => ?_
have : {Ο | X Ο β Set.Ioi (i : β)} = β N : β, {Ο | X Ο β Set.Ioc (i : β) N} := by
apply Set.Subset.antisymm _ _
Β· intro Ο hΟ
obtain β¨N, hNβ© : β N : β, X Ο β€ N := exists_nat_ge (X Ο)
exact Set.mem_iUnion.2 β¨N, hΟ, hNβ©
Β· simp +contextual only [Set.mem_Ioc, Set.mem_Ioi,
Set.iUnion_subset_iff, Set.setOf_subset_setOf, imp_true_iff]
rw [this]
apply tendsto_measure_iUnion_atTop
intro m n hmn x hx
exact β¨hx.1, hx.2.trans (Nat.cast_le.2 hmn)β©
apply le_of_tendsto_of_tendsto A tendsto_const_nhds
filter_upwards [Ici_mem_atTop K] with N hN
exact sum_prob_mem_Ioc_le hint hnonneg hN
theorem sum_variance_truncation_le {X : Ξ© β β} (hint : Integrable X) (hnonneg : 0 β€ X) (K : β) :
β j β range K, ((j : β) ^ 2)β»ΒΉ * πΌ[truncation X j ^ 2] β€ 2 * πΌ[X] := by
set Y := fun n : β => truncation X n
let Ο : Measure β := Measure.map X β
have Y2 : β n, πΌ[Y n ^ 2] = β« x in (0)..n, x ^ 2 βΟ := by
intro n
change πΌ[fun x => Y n x ^ 2] = _
rw [moment_truncation_eq_intervalIntegral_of_nonneg hint.1 two_ne_zero hnonneg]
calc
β j β range K, ((j : β) ^ 2)β»ΒΉ * πΌ[Y j ^ 2] =
β j β range K, ((j : β) ^ 2)β»ΒΉ * β« x in (0)..j, x ^ 2 βΟ := by simp_rw [Y2]
_ = β j β range K, ((j : β) ^ 2)β»ΒΉ * β k β range j, β« x in k..(k + 1 : β), x ^ 2 βΟ := by
congr 1 with j
congr 1
rw [intervalIntegral.sum_integral_adjacent_intervals]
Β· norm_cast
intro k _
exact (continuous_id.pow _).intervalIntegrable _ _
_ = β k β range K, (β j β Ioo k K, ((j : β) ^ 2)β»ΒΉ) * β« x in k..(k + 1 : β), x ^ 2 βΟ := by
simp_rw [mul_sum, sum_mul, sum_sigma']
refine sum_nbij' (fun p β¦ β¨p.2, p.1β©) (fun p β¦ β¨p.2, p.1β©) ?_ ?_ ?_ ?_ ?_ <;>
aesop (add unsafe lt_trans)
_ β€ β k β range K, 2 / (k + 1 : β) * β« x in k..(k + 1 : β), x ^ 2 βΟ := by
apply sum_le_sum fun k _ => ?_
refine mul_le_mul_of_nonneg_right (sum_Ioo_inv_sq_le _ _) ?_
refine intervalIntegral.integral_nonneg_of_forall ?_ fun u => sq_nonneg _
simp only [Nat.cast_add, Nat.cast_one, le_add_iff_nonneg_right, zero_le_one]
_ β€ β k β range K, β« x in k..(k + 1 : β), 2 * x βΟ := by
apply sum_le_sum fun k _ => ?_
have Ik : (k : β) β€ (k + 1 : β) := by simp
rw [β intervalIntegral.integral_const_mul, intervalIntegral.integral_of_le Ik,
intervalIntegral.integral_of_le Ik]
refine setIntegral_mono_on ?_ ?_ measurableSet_Ioc fun x hx => ?_
Β· apply Continuous.integrableOn_Ioc
exact continuous_const.mul (continuous_pow 2)
Β· apply Continuous.integrableOn_Ioc
exact continuous_const.mul continuous_id'
Β· calc
β2 / (βk + β1) * x ^ 2 = x / (k + 1) * (2 * x) := by ring
_ β€ 1 * (2 * x) :=
(mul_le_mul_of_nonneg_right (by
convert (div_le_one _).2 hx.2
Β· norm_cast
simp only [Nat.cast_add, Nat.cast_one]
linarith only [show (0 : β) β€ k from Nat.cast_nonneg k])
(mul_nonneg zero_le_two ((Nat.cast_nonneg k).trans hx.1.le)))
_ = 2 * x := by rw [one_mul]
_ = 2 * β« x in (0 : β)..K, x βΟ := by
rw [intervalIntegral.sum_integral_adjacent_intervals fun k _ => ?_]
swap; Β· exact (continuous_const.mul continuous_id').intervalIntegrable _ _
rw [intervalIntegral.integral_const_mul]
norm_cast
_ β€ 2 * πΌ[X] := mul_le_mul_of_nonneg_left (by
rw [β integral_truncation_eq_intervalIntegral_of_nonneg hint.1 hnonneg]
exact integral_truncation_le_integral_of_nonneg hint hnonneg) zero_le_two
end MomentEstimates
/-! Proof of the strong law of large numbers (almost sure version, assuming only
pairwise independence) for nonnegative random variables, following Etemadi's proof. -/
section StrongLawNonneg
variable (X : β β Ξ© β β) (hint : Integrable (X 0))
(hindep : Pairwise (IndepFun on X)) (hident : β i, IdentDistrib (X i) (X 0))
(hnonneg : β i Ο, 0 β€ X i Ο)
include hint hindep hident hnonneg in
/-- The truncation of `Xα΅’` up to `i` satisfies the strong law of large numbers (with respect to
the truncated expectation) along the sequence `c^n`, for any `c > 1`, up to a given `Ξ΅ > 0`.
This follows from a variance control. -/
theorem strong_law_aux1 {c : β} (c_one : 1 < c) {Ξ΅ : β} (Ξ΅pos : 0 < Ξ΅) : βα΅ Ο, βαΆ n : β in atTop,
|β i β range βc ^ nββ, truncation (X i) i Ο - πΌ[β i β range βc ^ nββ, truncation (X i) i]| <
Ξ΅ * βc ^ nββ := by
/- Let `S n = β i β range n, Y i` where `Y i = truncation (X i) i`. We should show that
`|S k - πΌ[S k]| / k β€ Ξ΅` along the sequence of powers of `c`. For this, we apply Borel-Cantelli:
it suffices to show that the converse probabilities are summable. From Chebyshev inequality,
this will follow from a variance control `β' Var[S (c^i)] / (c^i)^2 < β`. This is checked in
`I2` using pairwise independence to expand the variance of the sum as the sum of the variances,
and then a straightforward but tedious computation (essentially boiling down to the fact that
the sum of `1/(c ^ i)^2` beyond a threshold `j` is comparable to `1/j^2`).
Note that we have written `c^i` in the above proof sketch, but rigorously one should put integer
parts everywhere, making things more painful. We write `u i = βc^iββ` for brevity. -/
have c_pos : 0 < c := zero_lt_one.trans c_one
have hX : β i, AEStronglyMeasurable (X i) β := fun i =>
(hident i).symm.aestronglyMeasurable_snd hint.1
have A : β i, StronglyMeasurable (indicator (Set.Ioc (-i : β) i) id) := fun i =>
stronglyMeasurable_id.indicator measurableSet_Ioc
set Y := fun n : β => truncation (X n) n
set S := fun n => β i β range n, Y i with hS
let u : β β β := fun n => βc ^ nββ
have u_mono : Monotone u := fun i j hij => Nat.floor_mono (pow_right_monoβ c_one.le hij)
have I1 : β K, β j β range K, ((j : β) ^ 2)β»ΒΉ * Var[Y j] β€ 2 * πΌ[X 0] := by
intro K
calc
β j β range K, ((j : β) ^ 2)β»ΒΉ * Var[Y j] β€
β j β range K, ((j : β) ^ 2)β»ΒΉ * πΌ[truncation (X 0) j ^ 2] := by
apply sum_le_sum fun j _ => ?_
refine mul_le_mul_of_nonneg_left ?_ (inv_nonneg.2 (sq_nonneg _))
rw [(hident j).truncation.variance_eq]
exact variance_le_expectation_sq (hX 0).truncation
_ β€ 2 * πΌ[X 0] := sum_variance_truncation_le hint (hnonneg 0) K
let C := c ^ 5 * (c - 1)β»ΒΉ ^ 3 * (2 * πΌ[X 0])
have I2 : β N, β i β range N, ((u i : β) ^ 2)β»ΒΉ * Var[S (u i)] β€ C := by
intro N
calc
β i β range N, ((u i : β) ^ 2)β»ΒΉ * Var[S (u i)] =
β i β range N, ((u i : β) ^ 2)β»ΒΉ * β j β range (u i), Var[Y j] := by
congr 1 with i
congr 1
rw [hS, IndepFun.variance_sum]
Β· intro j _
exact (hident j).aestronglyMeasurable_fst.memLp_truncation
Β· intro k _ l _ hkl
exact (hindep hkl).comp (A k).measurable (A l).measurable
_ = β j β range (u (N - 1)), (β i β range N with j < u i, ((u i : β) ^ 2)β»ΒΉ) * Var[Y j] := by
simp_rw [mul_sum, sum_mul, sum_sigma']
refine sum_nbij' (fun p β¦ β¨p.2, p.1β©) (fun p β¦ β¨p.2, p.1β©) ?_ ?_ ?_ ?_ ?_
Β· simp only [mem_sigma, mem_range, filter_congr_decidable, mem_filter, and_imp,
Sigma.forall]
exact fun a b haN hb β¦ β¨hb.trans_le <| u_mono <| Nat.le_pred_of_lt haN, haN, hbβ©
all_goals simp
_ β€ β j β range (u (N - 1)), c ^ 5 * (c - 1)β»ΒΉ ^ 3 / βj ^ 2 * Var[Y j] := by
apply sum_le_sum fun j hj => ?_
rcases eq_zero_or_pos j with (rfl | hj)
Β· simp only [Nat.cast_zero, zero_pow, Ne, Nat.one_ne_zero,
not_false_iff, div_zero, zero_mul]
simp only [Y, Nat.cast_zero, truncation_zero, variance_zero, mul_zero, le_rfl]
apply mul_le_mul_of_nonneg_right _ (variance_nonneg _ _)
convert sum_div_nat_floor_pow_sq_le_div_sq N (Nat.cast_pos.2 hj) c_one using 2
Β· simp only [u, Nat.cast_lt]
Β· simp only [Y, S, u, C, one_div]
_ = c ^ 5 * (c - 1)β»ΒΉ ^ 3 * β j β range (u (N - 1)), ((j : β) ^ 2)β»ΒΉ * Var[Y j] := by
simp_rw [mul_sum, div_eq_mul_inv, mul_assoc]
_ β€ c ^ 5 * (c - 1)β»ΒΉ ^ 3 * (2 * πΌ[X 0]) := by
apply mul_le_mul_of_nonneg_left (I1 _)
apply mul_nonneg (pow_nonneg c_pos.le _)
exact pow_nonneg (inv_nonneg.2 (sub_nonneg.2 c_one.le)) _
have I3 : β N, β i β range N, β {Ο | (u i * Ξ΅ : β) β€ |S (u i) Ο - πΌ[S (u i)]|} β€
ENNReal.ofReal (Ξ΅β»ΒΉ ^ 2 * C) := by
intro N
calc
β i β range N, β {Ο | (u i * Ξ΅ : β) β€ |S (u i) Ο - πΌ[S (u i)]|} β€
β i β range N, ENNReal.ofReal (Var[S (u i)] / (u i * Ξ΅) ^ 2) := by
refine sum_le_sum fun i _ => ?_
apply meas_ge_le_variance_div_sq
Β· exact memLp_finset_sum' _ fun j _ => (hident j).aestronglyMeasurable_fst.memLp_truncation
Β· apply mul_pos (Nat.cast_pos.2 _) Ξ΅pos
refine zero_lt_one.trans_le ?_
apply Nat.le_floor
rw [Nat.cast_one]
apply one_le_powβ c_one.le
_ = ENNReal.ofReal (β i β range N, Var[S (u i)] / (u i * Ξ΅) ^ 2) := by
rw [ENNReal.ofReal_sum_of_nonneg fun i _ => ?_]
exact div_nonneg (variance_nonneg _ _) (sq_nonneg _)
_ β€ ENNReal.ofReal (Ξ΅β»ΒΉ ^ 2 * C) := by
apply ENNReal.ofReal_le_ofReal
-- Porting note: do most of the rewrites under `conv` so as not to expand `variance`
conv_lhs =>
enter [2, i]
rw [div_eq_inv_mul, β inv_pow, mul_inv, mul_comm _ Ξ΅β»ΒΉ, mul_pow, mul_assoc]
rw [β mul_sum]
refine mul_le_mul_of_nonneg_left ?_ (sq_nonneg _)
conv_lhs => enter [2, i]; rw [inv_pow]
exact I2 N
have I4 : (β' i, β {Ο | (u i * Ξ΅ : β) β€ |S (u i) Ο - πΌ[S (u i)]|}) < β :=
(le_of_tendsto_of_tendsto' (ENNReal.tendsto_nat_tsum _) tendsto_const_nhds I3).trans_lt
ENNReal.ofReal_lt_top
filter_upwards [ae_eventually_not_mem I4.ne] with Ο hΟ
simp_rw [S, not_le, mul_comm, sum_apply] at hΟ
convert hΟ; simp only [Y, S, u, C, sum_apply]
include hint hindep hident hnonneg in
/-- The truncation of `Xα΅’` up to `i` satisfies the strong law of large numbers
(with respect to the truncated expectation) along the sequence
`c^n`, for any `c > 1`. This follows from `strong_law_aux1` by varying `Ξ΅`. -/
theorem strong_law_aux2 {c : β} (c_one : 1 < c) :
βα΅ Ο, (fun n : β => β i β range βc ^ nββ, truncation (X i) i Ο -
πΌ[β i β range βc ^ nββ, truncation (X i) i]) =o[atTop] fun n : β => (βc ^ nββ : β) := by
obtain β¨v, -, v_pos, v_limβ© :
β v : β β β, StrictAnti v β§ (β n : β, 0 < v n) β§ Tendsto v atTop (π 0) :=
exists_seq_strictAnti_tendsto (0 : β)
have := fun i => strong_law_aux1 X hint hindep hident hnonneg c_one (v_pos i)
filter_upwards [ae_all_iff.2 this] with Ο hΟ
apply Asymptotics.isLittleO_iff.2 fun Ξ΅ Ξ΅pos => ?_
obtain β¨i, hiβ© : β i, v i < Ξ΅ := ((tendsto_order.1 v_lim).2 Ξ΅ Ξ΅pos).exists
filter_upwards [hΟ i] with n hn
simp only [Real.norm_eq_abs, abs_abs, Nat.abs_cast]
exact hn.le.trans (mul_le_mul_of_nonneg_right hi.le (Nat.cast_nonneg _))
include hint hident in
/-- The expectation of the truncated version of `Xα΅’` behaves asymptotically like the whole
expectation. This follows from convergence and CesΓ ro averaging. -/
theorem strong_law_aux3 :
(fun n => πΌ[β i β range n, truncation (X i) i] - n * πΌ[X 0]) =o[atTop] ((β) : β β β) := by
have A : Tendsto (fun i => πΌ[truncation (X i) i]) atTop (π πΌ[X 0]) := by
convert (tendsto_integral_truncation hint).comp tendsto_natCast_atTop_atTop using 1
ext i
exact (hident i).truncation.integral_eq
convert Asymptotics.isLittleO_sum_range_of_tendsto_zero (tendsto_sub_nhds_zero_iff.2 A) using 1
ext1 n
simp only [sum_sub_distrib, sum_const, card_range, nsmul_eq_mul, sum_apply, sub_left_inj]
rw [integral_finset_sum _ fun i _ => ?_]
exact ((hident i).symm.integrable_snd hint).1.integrable_truncation
include hint hindep hident hnonneg in
/-- The truncation of `Xα΅’` up to `i` satisfies the strong law of large numbers
(with respect to the original expectation) along the sequence
`c^n`, for any `c > 1`. This follows from the version from the truncated expectation, and the
fact that the truncated and the original expectations have the same asymptotic behavior. -/
theorem strong_law_aux4 {c : β} (c_one : 1 < c) :
βα΅ Ο, (fun n : β => β i β range βc ^ nββ, truncation (X i) i Ο - βc ^ nββ * πΌ[X 0]) =o[atTop]
fun n : β => (βc ^ nββ : β) := by
filter_upwards [strong_law_aux2 X hint hindep hident hnonneg c_one] with Ο hΟ
have A : Tendsto (fun n : β => βc ^ nββ) atTop atTop :=
tendsto_nat_floor_atTop.comp (tendsto_pow_atTop_atTop_of_one_lt c_one)
convert hΟ.add ((strong_law_aux3 X hint hident).comp_tendsto A) using 1
ext1 n
simp
include hint hident hnonneg in
/-- The truncated and non-truncated versions of `Xα΅’` have the same asymptotic behavior, as they
almost surely coincide at all but finitely many steps. This follows from a probability computation
and Borel-Cantelli. -/
theorem strong_law_aux5 :
βα΅ Ο, (fun n : β => β i β range n, truncation (X i) i Ο - β i β range n, X i Ο) =o[atTop]
fun n : β => (n : β) := by
have A : (β' j : β, β {Ο | X j Ο β Set.Ioi (j : β)}) < β := by
convert tsum_prob_mem_Ioi_lt_top hint (hnonneg 0) using 2
ext1 j
exact (hident j).measure_mem_eq measurableSet_Ioi
have B : βα΅ Ο, Tendsto (fun n : β => truncation (X n) n Ο - X n Ο) atTop (π 0) := by
filter_upwards [ae_eventually_not_mem A.ne] with Ο hΟ
apply tendsto_const_nhds.congr' _
filter_upwards [hΟ, Ioi_mem_atTop 0] with n hn npos
simp only [truncation, indicator, Set.mem_Ioc, id, Function.comp_apply]
split_ifs with h
Β· exact (sub_self _).symm
Β· have : -(n : β) < X n Ο := by
apply lt_of_lt_of_le _ (hnonneg n Ο)
simpa only [Right.neg_neg_iff, Nat.cast_pos] using npos
simp only [this, true_and, not_le] at h
exact (hn h).elim
filter_upwards [B] with Ο hΟ
convert isLittleO_sum_range_of_tendsto_zero hΟ using 1
ext n
rw [sum_sub_distrib]
include hint hindep hident hnonneg in
/-- `Xα΅’` satisfies the strong law of large numbers along the sequence
`c^n`, for any `c > 1`. This follows from the version for the truncated `Xα΅’`, and the fact that
`Xα΅’` and its truncated version have the same asymptotic behavior. -/
theorem strong_law_aux6 {c : β} (c_one : 1 < c) :
βα΅ Ο, Tendsto (fun n : β => (β i β range βc ^ nββ, X i Ο) / βc ^ nββ) atTop (π πΌ[X 0]) := by
have H : β n : β, (0 : β) < βc ^ nββ := by
intro n
refine zero_lt_one.trans_le ?_
simp only [Nat.one_le_cast, Nat.one_le_floor_iff, one_le_powβ c_one.le]
filter_upwards [strong_law_aux4 X hint hindep hident hnonneg c_one,
strong_law_aux5 X hint hident hnonneg] with Ο hΟ h'Ο
rw [β tendsto_sub_nhds_zero_iff, β Asymptotics.isLittleO_one_iff β]
have L : (fun n : β => β i β range βc ^ nββ, X i Ο - βc ^ nββ * πΌ[X 0]) =o[atTop] fun n =>
(βc ^ nββ : β) := by
have A : Tendsto (fun n : β => βc ^ nββ) atTop atTop :=
tendsto_nat_floor_atTop.comp (tendsto_pow_atTop_atTop_of_one_lt c_one)
convert hΟ.sub (h'Ο.comp_tendsto A) using 1
ext1 n
simp only [Function.comp_apply, sub_sub_sub_cancel_left]
convert L.mul_isBigO (isBigO_refl (fun n : β => (βc ^ nββ : β)β»ΒΉ) atTop) using 1 <;>
(ext1 n; field_simp [(H n).ne'])
include hint hindep hident hnonneg in
/-- `Xα΅’` satisfies the strong law of large numbers along all integers. This follows from the
corresponding fact along the sequences `c^n`, and the fact that any integer can be sandwiched
between `c^n` and `c^(n+1)` with comparably small error if `c` is close enough to `1`
(which is formalized in `tendsto_div_of_monotone_of_tendsto_div_floor_pow`). -/
theorem strong_law_aux7 :
βα΅ Ο, Tendsto (fun n : β => (β i β range n, X i Ο) / n) atTop (π πΌ[X 0]) := by
obtain β¨c, -, cone, climβ© :
β c : β β β, StrictAnti c β§ (β n : β, 1 < c n) β§ Tendsto c atTop (π 1) :=
exists_seq_strictAnti_tendsto (1 : β)
have : β k, βα΅ Ο,
Tendsto (fun n : β => (β i β range βc k ^ nββ, X i Ο) / βc k ^ nββ) atTop (π πΌ[X 0]) :=
fun k => strong_law_aux6 X hint hindep hident hnonneg (cone k)
filter_upwards [ae_all_iff.2 this] with Ο hΟ
apply tendsto_div_of_monotone_of_tendsto_div_floor_pow _ _ _ c cone clim _
Β· intro m n hmn
exact sum_le_sum_of_subset_of_nonneg (range_mono hmn) fun i _ _ => hnonneg i Ο
Β· exact hΟ
end StrongLawNonneg
/-- **Strong law of large numbers**, almost sure version: if `X n` is a sequence of independent
identically distributed integrable real-valued random variables, then `β i β range n, X i / n`
converges almost surely to `πΌ[X 0]`. We give here the strong version, due to Etemadi, that only
requires pairwise independence. Superseded by `strong_law_ae`, which works for random variables
taking values in any Banach space. -/
| Mathlib/Probability/StrongLaw.lean | 605 | 617 | theorem strong_law_ae_real {Ξ© : Type*} {m : MeasurableSpace Ξ©} {ΞΌ : Measure Ξ©}
(X : β β Ξ© β β) (hint : Integrable (X 0) ΞΌ)
(hindep : Pairwise ((IndepFun Β· Β· ΞΌ) on X))
(hident : β i, IdentDistrib (X i) (X 0) ΞΌ ΞΌ) :
βα΅ Ο βΞΌ, Tendsto (fun n : β => (β i β range n, X i Ο) / n) atTop (π ΞΌ[X 0]) := by | let mΞ© : MeasureSpace Ξ© := β¨ΞΌβ©
-- first get rid of the trivial case where the space is not a probability space
by_cases h : βα΅ Ο, X 0 Ο = 0
Β· have I : βα΅ Ο, β i, X i Ο = 0 := by
rw [ae_all_iff]
intro i
exact (hident i).symm.ae_snd (p := fun x β¦ x = 0) measurableSet_eq h
filter_upwards [I] with Ο hΟ |
/-
Copyright (c) 2018 SΓ©bastien GouΓ«zel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SΓ©bastien GouΓ«zel
-/
import Mathlib.Data.Fintype.Lattice
import Mathlib.Data.Fintype.Sum
import Mathlib.Topology.Homeomorph.Lemmas
import Mathlib.Topology.MetricSpace.Antilipschitz
/-!
# Isometries
We define isometries, i.e., maps between emetric spaces that preserve
the edistance (on metric spaces, these are exactly the maps that preserve distances),
and prove their basic properties. We also introduce isometric bijections.
Since a lot of elementary properties don't require `eq_of_dist_eq_zero` we start setting up the
theory for `PseudoMetricSpace` and we specialize to `MetricSpace` when needed.
-/
open Topology
noncomputable section
universe u v w
variable {ΞΉ : Type*} {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w}
open Function Set
open scoped Topology ENNReal
/-- An isometry (also known as isometric embedding) is a map preserving the edistance
between pseudoemetric spaces, or equivalently the distance between pseudometric space. -/
def Isometry [PseudoEMetricSpace Ξ±] [PseudoEMetricSpace Ξ²] (f : Ξ± β Ξ²) : Prop :=
β x1 x2 : Ξ±, edist (f x1) (f x2) = edist x1 x2
/-- On pseudometric spaces, a map is an isometry if and only if it preserves nonnegative
distances. -/
theorem isometry_iff_nndist_eq [PseudoMetricSpace Ξ±] [PseudoMetricSpace Ξ²] {f : Ξ± β Ξ²} :
Isometry f β β x y, nndist (f x) (f y) = nndist x y := by
simp only [Isometry, edist_nndist, ENNReal.coe_inj]
/-- On pseudometric spaces, a map is an isometry if and only if it preserves distances. -/
| Mathlib/Topology/MetricSpace/Isometry.lean | 46 | 48 | theorem isometry_iff_dist_eq [PseudoMetricSpace Ξ±] [PseudoMetricSpace Ξ²] {f : Ξ± β Ξ²} :
Isometry f β β x y, dist (f x) (f y) = dist x y := by | simp only [isometry_iff_nndist_eq, β coe_nndist, NNReal.coe_inj] |
/-
Copyright (c) 2022 MarΓa InΓ©s de Frutos-FernΓ‘ndez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: MarΓa InΓ©s de Frutos-FernΓ‘ndez
-/
import Mathlib.Order.Filter.Cofinite
import Mathlib.RingTheory.DedekindDomain.Ideal
import Mathlib.RingTheory.UniqueFactorizationDomain.Finite
/-!
# Factorization of ideals and fractional ideals of Dedekind domains
Every nonzero ideal `I` of a Dedekind domain `R` can be factored as a product `β_v v^{n_v}` over the
maximal ideals of `R`, where the exponents `n_v` are natural numbers.
Similarly, every nonzero fractional ideal `I` of a Dedekind domain `R` can be factored as a product
`β_v v^{n_v}` over the maximal ideals of `R`, where the exponents `n_v` are integers. We define
`FractionalIdeal.count K v I` (abbreviated as `val_v(I)` in the documentation) to be `n_v`, and we
prove some of its properties. If `I = 0`, we define `val_v(I) = 0`.
## Main definitions
- `FractionalIdeal.count` : If `I` is a nonzero fractional ideal, `a β R`, and `J` is an ideal of
`R` such that `I = aβ»ΒΉJ`, then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we
set `val_v(I) = 0`.
## Main results
- `Ideal.finite_factors` : Only finitely many maximal ideals of `R` divide a given nonzero ideal.
- `Ideal.finprod_heightOneSpectrum_factorization` : The ideal `I` equals the finprod
`β_v v^(val_v(I))`, where `val_v(I)` denotes the multiplicity of `v` in the factorization of `I`
and `v` runs over the maximal ideals of `R`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization` : If `I` is a nonzero fractional ideal,
`a β R`, and `J` is an ideal of `R` such that `I = aβ»ΒΉJ`, then `I` is equal to the product
`β_v v^(val_v(J) - val_v(a))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization'` : If `I` is a nonzero fractional
ideal, then `I` is equal to the product `β_v v^(val_v(I))`.
- `FractionalIdeal.finprod_heightOneSpectrum_factorization_principal` : For a nonzero `k = r/s β K`,
the fractional ideal `(k)` is equal to the product `β_v v^(val_v(r) - val_v(s))`.
- `FractionalIdeal.finite_factors` : If `I β 0`, then `val_v(I) = 0` for all but finitely many
maximal ideals of `R`.
## Implementation notes
Since we are only interested in the factorization of nonzero fractional ideals, we define
`val_v(0) = 0` so that every `val_v` is in `β€` and we can avoid having to use `WithTop β€`.
## Tags
dedekind domain, fractional ideal, ideal, factorization
-/
noncomputable section
open scoped nonZeroDivisors
open Set Function UniqueFactorizationMonoid IsDedekindDomain IsDedekindDomain.HeightOneSpectrum
variable {R : Type*} [CommRing R] {K : Type*} [Field K] [Algebra R K] [IsFractionRing R K]
/-! ### Factorization of ideals of Dedekind domains -/
variable [IsDedekindDomain R] (v : HeightOneSpectrum R)
open scoped Classical in
/-- Given a maximal ideal `v` and an ideal `I` of `R`, `maxPowDividing` returns the maximal
power of `v` dividing `I`. -/
def IsDedekindDomain.HeightOneSpectrum.maxPowDividing (I : Ideal R) : Ideal R :=
v.asIdeal ^ (Associates.mk v.asIdeal).count (Associates.mk I).factors
/-- Only finitely many maximal ideals of `R` divide a given nonzero ideal. -/
theorem Ideal.finite_factors {I : Ideal R} (hI : I β 0) :
{v : HeightOneSpectrum R | v.asIdeal β£ I}.Finite := by
rw [β Set.finite_coe_iff, Set.coe_setOf]
haveI h_fin := fintypeSubtypeDvd I hI
refine
Finite.of_injective (fun v => (β¨(v : HeightOneSpectrum R).asIdeal, v.2β© : { x // x β£ I })) ?_
intro v w hvw
simp? at hvw says simp only [Subtype.mk.injEq] at hvw
exact Subtype.coe_injective (HeightOneSpectrum.ext hvw)
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that the
multiplicity of `v` in the factorization of `I`, denoted `val_v(I)`, is nonzero. -/
theorem Associates.finite_factors {I : Ideal R} (hI : I β 0) :
βαΆ v : HeightOneSpectrum R in Filter.cofinite,
((Associates.mk v.asIdeal).count (Associates.mk I).factors : β€) = 0 := by
have h_supp : {v : HeightOneSpectrum R | Β¬((Associates.mk v.asIdeal).count
(Associates.mk I).factors : β€) = 0} = {v : HeightOneSpectrum R | v.asIdeal β£ I} := by
ext v
simp_rw [Int.natCast_eq_zero]
exact Associates.count_ne_zero_iff_dvd hI v.irreducible
rw [Filter.eventually_cofinite, h_supp]
exact Ideal.finite_factors hI
namespace Ideal
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^(val_v(I))` is not the unit ideal. -/
theorem finite_mulSupport {I : Ideal R} (hI : I β 0) :
(mulSupport fun v : HeightOneSpectrum R => v.maxPowDividing I).Finite :=
haveI h_subset : {v : HeightOneSpectrum R | v.maxPowDividing I β 1} β
{v : HeightOneSpectrum R |
((Associates.mk v.asIdeal).count (Associates.mk I).factors : β€) β 0} := by
intro v hv h_zero
have hv' : v.maxPowDividing I = 1 := by
rw [IsDedekindDomain.HeightOneSpectrum.maxPowDividing, Int.natCast_eq_zero.mp h_zero,
pow_zero _]
exact hv hv'
Finite.subset (Filter.eventually_cofinite.mp (Associates.finite_factors hI)) h_subset
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^(val_v(I))`, regarded as a fractional ideal, is not `(1)`. -/
theorem finite_mulSupport_coe {I : Ideal R} (hI : I β 0) :
(mulSupport fun v : HeightOneSpectrum R => (v.asIdeal : FractionalIdeal Rβ° K) ^
((Associates.mk v.asIdeal).count (Associates.mk I).factors : β€)).Finite := by
rw [mulSupport]
simp_rw [Ne, zpow_natCast, β FractionalIdeal.coeIdeal_pow, FractionalIdeal.coeIdeal_eq_one]
exact finite_mulSupport hI
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, there are finitely many maximal ideals `v` such that
`v^-(val_v(I))` is not the unit ideal. -/
theorem finite_mulSupport_inv {I : Ideal R} (hI : I β 0) :
(mulSupport fun v : HeightOneSpectrum R => (v.asIdeal : FractionalIdeal Rβ° K) ^
(-((Associates.mk v.asIdeal).count (Associates.mk I).factors : β€))).Finite := by
rw [mulSupport]
simp_rw [zpow_neg, Ne, inv_eq_one]
exact finite_mulSupport_coe hI
open scoped Classical in
/-- For every nonzero ideal `I` of `v`, `v^(val_v(I) + 1)` does not divide `β_v v^(val_v(I))`. -/
theorem finprod_not_dvd (I : Ideal R) (hI : I β 0) :
Β¬v.asIdeal ^ ((Associates.mk v.asIdeal).count (Associates.mk I).factors + 1) β£
βαΆ v : HeightOneSpectrum R, v.maxPowDividing I := by
have hf := finite_mulSupport hI
have h_ne_zero : v.maxPowDividing I β 0 := pow_ne_zero _ v.ne_bot
rw [β mul_finprod_cond_ne v hf, pow_add, pow_one, finprod_cond_ne _ _ hf]
intro h_contr
have hv_prime : Prime v.asIdeal := Ideal.prime_of_isPrime v.ne_bot v.isPrime
obtain β¨w, hw, hvw'β© :=
Prime.exists_mem_finset_dvd hv_prime ((mul_dvd_mul_iff_left h_ne_zero).mp h_contr)
have hw_prime : Prime w.asIdeal := Ideal.prime_of_isPrime w.ne_bot w.isPrime
have hvw := Prime.dvd_of_dvd_pow hv_prime hvw'
rw [Prime.dvd_prime_iff_associated hv_prime hw_prime, associated_iff_eq] at hvw
exact (Finset.mem_erase.mp hw).1 (HeightOneSpectrum.ext hvw.symm)
end Ideal
theorem Associates.finprod_ne_zero (I : Ideal R) :
Associates.mk (βαΆ v : HeightOneSpectrum R, v.maxPowDividing I) β 0 := by
classical
rw [Associates.mk_ne_zero, finprod_def]
split_ifs
Β· rw [Finset.prod_ne_zero_iff]
intro v _
apply pow_ne_zero _ v.ne_bot
Β· exact one_ne_zero
namespace Ideal
open scoped Classical in
/-- The multiplicity of `v` in `β_v v^(val_v(I))` equals `val_v(I)`. -/
theorem finprod_count (I : Ideal R) (hI : I β 0) : (Associates.mk v.asIdeal).count
(Associates.mk (βαΆ v : HeightOneSpectrum R, v.maxPowDividing I)).factors =
(Associates.mk v.asIdeal).count (Associates.mk I).factors := by
have h_ne_zero := Associates.finprod_ne_zero I
have hv : Irreducible (Associates.mk v.asIdeal) := v.associates_irreducible
have h_dvd := finprod_mem_dvd v (Ideal.finite_mulSupport hI)
have h_not_dvd := Ideal.finprod_not_dvd v I hI
simp only [IsDedekindDomain.HeightOneSpectrum.maxPowDividing] at h_dvd h_ne_zero h_not_dvd
rw [β Associates.mk_dvd_mk] at h_dvd h_not_dvd
simp only [Associates.dvd_eq_le] at h_dvd h_not_dvd
rw [Associates.mk_pow, Associates.prime_pow_dvd_iff_le h_ne_zero hv] at h_dvd h_not_dvd
rw [not_le] at h_not_dvd
apply Nat.eq_of_le_of_lt_succ h_dvd h_not_dvd
/-- The ideal `I` equals the finprod `β_v v^(val_v(I))`. -/
theorem finprod_heightOneSpectrum_factorization {I : Ideal R} (hI : I β 0) :
βαΆ v : HeightOneSpectrum R, v.maxPowDividing I = I := by
rw [β associated_iff_eq, β Associates.mk_eq_mk_iff_associated]
classical
apply Associates.eq_of_eq_counts
Β· apply Associates.finprod_ne_zero I
Β· apply Associates.mk_ne_zero.mpr hI
intro v hv
obtain β¨J, hJvβ© := Associates.exists_rep v
rw [β hJv, Associates.irreducible_mk] at hv
rw [β hJv]
apply Ideal.finprod_count
β¨J, Ideal.isPrime_of_prime (irreducible_iff_prime.mp hv), Irreducible.ne_zero hvβ© I hI
variable (K)
open scoped Classical in
/-- The ideal `I` equals the finprod `β_v v^(val_v(I))`, when both sides are regarded as fractional
ideals of `R`. -/
theorem finprod_heightOneSpectrum_factorization_coe {I : Ideal R} (hI : I β 0) :
(βαΆ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal Rβ° K) ^
((Associates.mk v.asIdeal).count (Associates.mk I).factors : β€)) = I := by
conv_rhs => rw [β Ideal.finprod_heightOneSpectrum_factorization hI]
rw [FractionalIdeal.coeIdeal_finprod Rβ° K (le_refl _)]
simp_rw [IsDedekindDomain.HeightOneSpectrum.maxPowDividing, FractionalIdeal.coeIdeal_pow,
zpow_natCast]
end Ideal
/-! ### Factorization of fractional ideals of Dedekind domains -/
namespace FractionalIdeal
open Int IsLocalization
open scoped Classical in
/-- If `I` is a nonzero fractional ideal, `a β R`, and `J` is an ideal of `R` such that
`I = aβ»ΒΉJ`, then `I` is equal to the product `β_v v^(val_v(J) - val_v(a))`. -/
theorem finprod_heightOneSpectrum_factorization {I : FractionalIdeal Rβ° K} (hI : I β 0) {a : R}
{J : Ideal R} (haJ : I = spanSingleton Rβ° ((algebraMap R K) a)β»ΒΉ * βJ) :
βαΆ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal Rβ° K) ^
((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : β€) = I := by
have hJ_ne_zero : J β 0 := ideal_factor_ne_zero hI haJ
have hJ := Ideal.finprod_heightOneSpectrum_factorization_coe K hJ_ne_zero
have ha_ne_zero : Ideal.span {a} β 0 := constant_factor_ne_zero hI haJ
have ha := Ideal.finprod_heightOneSpectrum_factorization_coe K ha_ne_zero
rw [haJ, β div_spanSingleton, div_eq_mul_inv, β coeIdeal_span_singleton, β hJ, β ha,
β finprod_inv_distrib]
simp_rw [β zpow_neg]
rw [β finprod_mul_distrib (Ideal.finite_mulSupport_coe hJ_ne_zero)
(Ideal.finite_mulSupport_inv ha_ne_zero)]
apply finprod_congr
intro v
rw [β zpow_addβ ((@coeIdeal_ne_zero R _ K _ _ _ _).mpr v.ne_bot), sub_eq_add_neg]
open scoped Classical in
/-- For a nonzero `k = r/s β K`, the fractional ideal `(k)` is equal to the product
`β_v v^(val_v(r) - val_v(s))`. -/
theorem finprod_heightOneSpectrum_factorization_principal_fraction {n : R} (hn : n β 0) (d : β₯Rβ°) :
βαΆ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal Rβ° K) ^
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {n} : Ideal R)).factors -
(Associates.mk v.asIdeal).count (Associates.mk ((Ideal.span {(βd : R)}) :
Ideal R)).factors : β€) = spanSingleton Rβ° (mk' K n d) := by
have hd_ne_zero : (algebraMap R K) (d : R) β 0 :=
map_ne_zero_of_mem_nonZeroDivisors _ (IsFractionRing.injective R K) d.property
have h0 : spanSingleton Rβ° (mk' K n d) β 0 := by
rw [spanSingleton_ne_zero_iff, IsFractionRing.mk'_eq_div, ne_eq, div_eq_zero_iff, not_or]
exact β¨(map_ne_zero_iff (algebraMap R K) (IsFractionRing.injective R K)).mpr hn, hd_ne_zeroβ©
have hI : spanSingleton Rβ° (mk' K n d) =
spanSingleton Rβ° ((algebraMap R K) d)β»ΒΉ * β(Ideal.span {n} : Ideal R) := by
rw [coeIdeal_span_singleton, spanSingleton_mul_spanSingleton]
apply congr_arg
rw [IsFractionRing.mk'_eq_div, div_eq_mul_inv, mul_comm]
exact finprod_heightOneSpectrum_factorization h0 hI
open Classical in
/-- For a nonzero `k = r/s β K`, the fractional ideal `(k)` is equal to the product
`β_v v^(val_v(r) - val_v(s))`. -/
theorem finprod_heightOneSpectrum_factorization_principal {I : FractionalIdeal Rβ° K} (hI : I β 0)
(k : K) (hk : I = spanSingleton Rβ° k) :
βαΆ v : HeightOneSpectrum R, (v.asIdeal : FractionalIdeal Rβ° K) ^
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {choose
(mk'_surjective Rβ° k)} : Ideal R)).factors -
(Associates.mk v.asIdeal).count (Associates.mk ((Ideal.span {(β(choose
(choose_spec (mk'_surjective Rβ° k)) : β₯Rβ°) : R)}) : Ideal R)).factors : β€) = I := by
set n : R := choose (mk'_surjective Rβ° k)
set d : β₯Rβ° := choose (choose_spec (mk'_surjective Rβ° k))
have hnd : mk' K n d = k := choose_spec (choose_spec (mk'_surjective Rβ° k))
have hn0 : n β 0 := by
by_contra h
rw [β hnd, h, IsFractionRing.mk'_eq_div, map_zero, zero_div, spanSingleton_zero] at hk
exact hI hk
rw [finprod_heightOneSpectrum_factorization_principal_fraction hn0 d, hk, hnd]
variable (K)
open Classical in
/-- If `I` is a nonzero fractional ideal, `a β R`, and `J` is an ideal of `R` such that `I = aβ»ΒΉJ`,
then we define `val_v(I)` as `(val_v(J) - val_v(a))`. If `I = 0`, we set `val_v(I) = 0`. -/
def count (I : FractionalIdeal Rβ° K) : β€ :=
dite (I = 0) (fun _ : I = 0 => 0) fun _ : Β¬I = 0 =>
let a := choose (exists_eq_spanSingleton_mul I)
let J := choose (choose_spec (exists_eq_spanSingleton_mul I))
((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : β€)
/-- val_v(0) = 0. -/
lemma count_zero : count K v (0 : FractionalIdeal Rβ° K) = 0 := by simp only [count, dif_pos]
open Classical in
lemma count_ne_zero {I : FractionalIdeal Rβ° K} (hI : I β 0) :
count K v I = ((Associates.mk v.asIdeal).count (Associates.mk
(choose (choose_spec (exists_eq_spanSingleton_mul I)))).factors -
(Associates.mk v.asIdeal).count
(Associates.mk (Ideal.span {choose (exists_eq_spanSingleton_mul I)})).factors : β€) := by
simp only [count, dif_neg hI]
open Classical in
/-- `val_v(I)` does not depend on the choice of `a` and `J` used to represent `I`. -/
theorem count_well_defined {I : FractionalIdeal Rβ° K} (hI : I β 0) {a : R}
{J : Ideal R} (h_aJ : I = spanSingleton Rβ° ((algebraMap R K) a)β»ΒΉ * βJ) :
count K v I = ((Associates.mk v.asIdeal).count (Associates.mk J).factors -
(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {a})).factors : β€) := by
set aβ := choose (exists_eq_spanSingleton_mul I)
set Jβ := choose (choose_spec (exists_eq_spanSingleton_mul I))
have h_aβJβ : I = spanSingleton Rβ° ((algebraMap R K) aβ)β»ΒΉ * βJβ :=
(choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).2
have h_aβ_ne_zero : aβ β 0 := (choose_spec (choose_spec (exists_eq_spanSingleton_mul I))).1
have h_Jβ_ne_zero : Jβ β 0 := ideal_factor_ne_zero hI h_aβJβ
have h_a_ne_zero : Ideal.span {a} β 0 := constant_factor_ne_zero hI h_aJ
have h_J_ne_zero : J β 0 := ideal_factor_ne_zero hI h_aJ
have h_aβ' : spanSingleton Rβ° ((algebraMap R K) aβ) β 0 := by
rw [ne_eq, spanSingleton_eq_zero_iff, β (algebraMap R K).map_zero,
Injective.eq_iff (IsLocalization.injective K (le_refl Rβ°))]
exact h_aβ_ne_zero
have h_a' : spanSingleton Rβ° ((algebraMap R K) a) β 0 := by
rw [ne_eq, spanSingleton_eq_zero_iff, β (algebraMap R K).map_zero,
Injective.eq_iff (IsLocalization.injective K (le_refl Rβ°))]
rw [ne_eq, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot] at h_a_ne_zero
exact h_a_ne_zero
have hv : Irreducible (Associates.mk v.asIdeal) := by
exact Associates.irreducible_mk.mpr v.irreducible
rw [h_aβJβ, β div_spanSingleton, β div_spanSingleton, div_eq_div_iff h_aβ' h_a',
β coeIdeal_span_singleton, β coeIdeal_span_singleton, β coeIdeal_mul, β coeIdeal_mul] at h_aJ
rw [count, dif_neg hI, sub_eq_sub_iff_add_eq_add, β Int.natCast_add, β Int.natCast_add,
natCast_inj, β Associates.count_mul _ _ hv, β Associates.count_mul _ _ hv, Associates.mk_mul_mk,
Associates.mk_mul_mk, coeIdeal_injective h_aJ]
Β· rw [ne_eq, Associates.mk_eq_zero]; exact h_J_ne_zero
Β· rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]
exact h_aβ_ne_zero
Β· rw [ne_eq, Associates.mk_eq_zero]; exact h_Jβ_ne_zero
Β· rw [ne_eq, Associates.mk_eq_zero]; exact h_a_ne_zero
/-- For nonzero `I, I'`, `val_v(I*I') = val_v(I) + val_v(I')`. -/
theorem count_mul {I I' : FractionalIdeal Rβ° K} (hI : I β 0) (hI' : I' β 0) :
count K v (I * I') = count K v I + count K v I' := by
classical
have hv : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
obtain β¨a, J, ha, haJβ© := exists_eq_spanSingleton_mul I
have ha_ne_zero : Associates.mk (Ideal.span {a} : Ideal R) β 0 := by
rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha
have hJ_ne_zero : Associates.mk J β 0 := Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI haJ)
obtain β¨a', J', ha', haJ'β© := exists_eq_spanSingleton_mul I'
have ha'_ne_zero : Associates.mk (Ideal.span {a'} : Ideal R) β 0 := by
rw [ne_eq, Associates.mk_eq_zero, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]; exact ha'
have hJ'_ne_zero : Associates.mk J' β 0 :=
Associates.mk_ne_zero.mpr (ideal_factor_ne_zero hI' haJ')
have h_prod : I * I' = spanSingleton Rβ° ((algebraMap R K) (a * a'))β»ΒΉ * β(J * J') := by
rw [haJ, haJ', mul_assoc, mul_comm (J : FractionalIdeal Rβ° K), mul_assoc, β mul_assoc,
spanSingleton_mul_spanSingleton, coeIdeal_mul, RingHom.map_mul, mul_inv,
mul_comm (J : FractionalIdeal Rβ° K)]
rw [count_well_defined K v hI haJ, count_well_defined K v hI' haJ',
count_well_defined K v (mul_ne_zero hI hI') h_prod, β Associates.mk_mul_mk,
Associates.count_mul hJ_ne_zero hJ'_ne_zero hv, β Ideal.span_singleton_mul_span_singleton,
β Associates.mk_mul_mk, Associates.count_mul ha_ne_zero ha'_ne_zero hv]
push_cast
ring
/-- For nonzero `I, I'`, `val_v(I*I') = val_v(I) + val_v(I')`. If `I` or `I'` is zero, then
`val_v(I*I') = 0`. -/
theorem count_mul' (I I' : FractionalIdeal Rβ° K) [Decidable (I β 0 β§ I' β 0)] :
count K v (I * I') = if I β 0 β§ I' β 0 then count K v I + count K v I' else 0 := by
split_ifs with h
Β· exact count_mul K v h.1 h.2
Β· push_neg at h
by_cases hI : I = 0
Β· rw [hI, MulZeroClass.zero_mul, count, dif_pos (Eq.refl _)]
Β· rw [h hI, MulZeroClass.mul_zero, count, dif_pos (Eq.refl _)]
/-- val_v(1) = 0. -/
theorem count_one : count K v (1 : FractionalIdeal Rβ° K) = 0 := by
have h1 : (1 : FractionalIdeal Rβ° K) =
spanSingleton Rβ° ((algebraMap R K) 1)β»ΒΉ * β(1 : Ideal R) := by
rw [(algebraMap R K).map_one, Ideal.one_eq_top, coeIdeal_top, mul_one, inv_one,
spanSingleton_one]
rw [count_well_defined K v one_ne_zero h1, Ideal.span_singleton_one, Ideal.one_eq_top, sub_self]
theorem count_prod {ΞΉ} (s : Finset ΞΉ) (I : ΞΉ β FractionalIdeal Rβ° K) (hS : β i β s, I i β 0) :
count K v (β i β s, I i) = β i β s, count K v (I i) := by
classical
induction' s using Finset.induction with i s hi hrec
Β· rw [Finset.prod_empty, Finset.sum_empty, count_one]
Β· have hS' : β i β s, I i β 0 := fun j hj => hS j (Finset.mem_insert_of_mem hj)
have hS0 : β i β s, I i β 0 := Finset.prod_ne_zero_iff.mpr hS'
have hi0 : I i β 0 := hS i (Finset.mem_insert_self i s)
rw [Finset.prod_insert hi, Finset.sum_insert hi, count_mul K v hi0 hS0, hrec hS']
/-- For every `n β β` and every ideal `I`, `val_v(I^n) = n*val_v(I)`. -/
theorem count_pow (n : β) (I : FractionalIdeal Rβ° K) :
count K v (I ^ n) = n * count K v I := by
induction' n with n h
Β· rw [pow_zero, ofNat_zero, MulZeroClass.zero_mul, count_one]
Β· classical rw [pow_succ, count_mul']
by_cases hI : I = 0
Β· have h_neg : Β¬(I ^ n β 0 β§ I β 0) := by
rw [not_and', not_not, ne_eq]
intro h
exact absurd hI h
rw [if_neg h_neg, hI, count_zero, MulZeroClass.mul_zero]
Β· rw [if_pos (And.intro (pow_ne_zero n hI) hI), h, Nat.cast_add,
Nat.cast_one]
ring
/-- `val_v(v) = 1`, when `v` is regarded as a fractional ideal. -/
theorem count_self : count K v (v.asIdeal : FractionalIdeal Rβ° K) = 1 := by
have hv : (v.asIdeal : FractionalIdeal Rβ° K) β 0 := coeIdeal_ne_zero.mpr v.ne_bot
have h_self : (v.asIdeal : FractionalIdeal Rβ° K) =
spanSingleton Rβ° ((algebraMap R K) 1)β»ΒΉ * βv.asIdeal := by
rw [(algebraMap R K).map_one, inv_one, spanSingleton_one, one_mul]
have hv_irred : Irreducible (Associates.mk v.asIdeal) := by apply v.associates_irreducible
classical rw [count_well_defined K v hv h_self, Associates.count_self hv_irred,
Ideal.span_singleton_one, β Ideal.one_eq_top, Associates.mk_one, Associates.factors_one,
Associates.count_zero hv_irred, ofNat_zero, sub_zero, ofNat_one]
/-- `val_v(v^n) = n` for every `n β β`. -/
| Mathlib/RingTheory/DedekindDomain/Factorization.lean | 412 | 420 | theorem count_pow_self (n : β) :
count K v ((v.asIdeal : FractionalIdeal Rβ° K) ^ n) = n := by | rw [count_pow, count_self, mul_one]
/-- `val_v(Iβ»βΏ) = -val_v(IβΏ)` for every `n β β€`. -/
theorem count_neg_zpow (n : β€) (I : FractionalIdeal Rβ° K) :
count K v (I ^ (-n)) = - count K v (I ^ n) := by
by_cases hI : I = 0
Β· by_cases hn : n = 0 |
/-
Copyright (c) 2022 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.Algebra.Group.Embedding
import Mathlib.Algebra.MonoidAlgebra.Defs
import Mathlib.LinearAlgebra.Finsupp.Supported
import Mathlib.Algebra.Group.Pointwise.Finset.Basic
/-!
# Lemmas about the support of a finitely supported function
-/
open scoped Pointwise
universe uβ uβ uβ
namespace MonoidAlgebra
open Finset Finsupp
variable {k : Type uβ} {G : Type uβ} [Semiring k]
| Mathlib/Algebra/MonoidAlgebra/Support.lean | 25 | 30 | theorem support_mul [Mul G] [DecidableEq G] (a b : MonoidAlgebra k G) :
(a * b).support β a.support * b.support := by | rw [MonoidAlgebra.mul_def]
exact support_sum.trans <| biUnion_subset.2 fun _x hx β¦
support_sum.trans <| biUnion_subset.2 fun _y hy β¦
support_single_subset.trans <| singleton_subset_iff.2 <| mem_imageβ_of_mem hx hy |
/-
Copyright (c) 2021 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import Mathlib.Data.Nat.Factorial.Basic
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Set.Finite.Range
import Mathlib.Logic.Equiv.Embedding
/-!
# Number of embeddings
This file establishes the cardinality of `Ξ± βͺ Ξ²` in full generality.
-/
local notation "|" x "|" => Finset.card x
local notation "β" x "β" => Fintype.card x
open Function
open Nat
namespace Fintype
theorem card_embedding_eq_of_unique {Ξ± Ξ² : Type*} [Unique Ξ±] [Fintype Ξ²] [Fintype (Ξ± βͺ Ξ²)] :
βΞ± βͺ Ξ²β = βΞ²β :=
card_congr Equiv.uniqueEmbeddingEquivResult
-- Establishes the cardinality of the type of all injections between two finite types.
-- Porting note: `induction Ξ± using Fintype.induction_empty_option` can't work with the `Fintype Ξ±`
-- instance so instead we make an ugly refine and `dsimp` a lot.
@[simp]
| Mathlib/Data/Fintype/CardEmbedding.lean | 36 | 50 | theorem card_embedding_eq {Ξ± Ξ² : Type*} [Fintype Ξ±] [Fintype Ξ²] [emb : Fintype (Ξ± βͺ Ξ²)] :
βΞ± βͺ Ξ²β = βΞ²β.descFactorial βΞ±β := by | rw [Subsingleton.elim emb Embedding.fintype]
refine Fintype.induction_empty_option (P := fun t β¦ βt βͺ Ξ²β = βΞ²β.descFactorial βtβ)
(fun Ξ±β Ξ±β hβ e ih β¦ ?_) (?_) (fun Ξ³ h ih β¦ ?_) Ξ± <;> dsimp only at * <;> clear! Ξ±
Β· letI := Fintype.ofEquiv _ e.symm
rw [β card_congr (Equiv.embeddingCongr e (Equiv.refl Ξ²)), ih, card_congr e]
Β· rw [card_pempty, Nat.descFactorial_zero, card_eq_one_iff]
exact β¨Embedding.ofIsEmpty, fun x β¦ DFunLike.ext _ _ isEmptyElimβ©
Β· classical
rw [card_option, Nat.descFactorial_succ, card_congr (Embedding.optionEmbeddingEquiv Ξ³ Ξ²),
card_sigma, β ih]
simp only [Fintype.card_compl_set, Fintype.card_range, Finset.sum_const, Finset.card_univ,
Nat.nsmul_eq_mul, mul_comm] |
/-
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.BigOperators.Group.Finset.Indicator
import Mathlib.Algebra.Module.BigOperators
import Mathlib.LinearAlgebra.AffineSpace.AffineSubspace.Basic
import Mathlib.LinearAlgebra.Finsupp.LinearCombination
import Mathlib.Tactic.FinCases
/-!
# 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
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)
@[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]
/-- 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]
lemma weightedVSubOfPoint_vadd (s : Finset ΞΉ) (w : ΞΉ β k) (p : ΞΉ β P) (b : P) (v : V) :
s.weightedVSubOfPoint (v +α΅₯ p) b w = s.weightedVSubOfPoint p (-v +α΅₯ b) w := by
simp [vadd_vsub_assoc, vsub_vadd_eq_vsub_sub, add_comm]
lemma weightedVSubOfPoint_smul {G : Type*} [Group G] [DistribMulAction G V] [SMulCommClass G k V]
(s : Finset ΞΉ) (w : ΞΉ β k) (p : ΞΉ β V) (b : V) (a : G) :
s.weightedVSubOfPoint (a β’ p) b w = a β’ s.weightedVSubOfPoint p (aβ»ΒΉ β’ b) w := by
simp [smul_sum, smul_sub, smul_comm a (w _)]
/-- `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]
/-- 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]
/-- 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]
/-- 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
rw [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]
/-- 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]
/-- 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]
/-- 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 _
/-- 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 _ _ _
/-- A weighted sum of pairwise subtractions, expressed as a subtraction of two
`weightedVSubOfPoint` expressions. -/
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]
/-- A weighted sum of pairwise subtractions, where the point on the right is constant,
expressed as a subtraction involving a `weightedVSubOfPoint` expression. -/
theorem sum_smul_vsub_const_eq_weightedVSubOfPoint_sub (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ b : P) :
(β i β s, w i β’ (pβ i -α΅₯ pβ)) = s.weightedVSubOfPoint pβ b w - (β i β s, w i) β’ (pβ -α΅₯ b) := by
rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const]
/-- A weighted sum of pairwise subtractions, where the point on the left is constant,
expressed as a subtraction involving a `weightedVSubOfPoint` expression. -/
theorem sum_smul_const_vsub_eq_sub_weightedVSubOfPoint (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ b : P) :
(β i β s, w i β’ (pβ -α΅₯ pβ i)) = (β i β s, w i) β’ (pβ -α΅₯ b) - s.weightedVSubOfPoint pβ b w := by
rw [sum_smul_vsub_eq_weightedVSubOfPoint_sub, weightedVSubOfPoint_apply_const]
/-- A weighted sum may be split into such sums over two subsets. -/
theorem weightedVSubOfPoint_sdiff [DecidableEq ΞΉ] {sβ : Finset ΞΉ} (h : sβ β s) (w : ΞΉ β k)
(p : ΞΉ β P) (b : P) :
(s \ sβ).weightedVSubOfPoint p b w + sβ.weightedVSubOfPoint p b w =
s.weightedVSubOfPoint p b w := by
simp_rw [weightedVSubOfPoint_apply, sum_sdiff h]
/-- A weighted sum may be split into a subtraction of such sums over two subsets. -/
theorem weightedVSubOfPoint_sdiff_sub [DecidableEq ΞΉ] {sβ : Finset ΞΉ} (h : sβ β s) (w : ΞΉ β k)
(p : ΞΉ β P) (b : P) :
(s \ sβ).weightedVSubOfPoint p b w - sβ.weightedVSubOfPoint p b (-w) =
s.weightedVSubOfPoint p b w := by
rw [map_neg, sub_neg_eq_add, s.weightedVSubOfPoint_sdiff h]
/-- A weighted sum over `s.subtype pred` equals one over `{x β s | pred x}`. -/
theorem weightedVSubOfPoint_subtype_eq_filter (w : ΞΉ β k) (p : ΞΉ β P) (b : P) (pred : ΞΉ β Prop)
[DecidablePred pred] :
((s.subtype pred).weightedVSubOfPoint (fun i => p i) b fun i => w i) =
{x β s | pred x}.weightedVSubOfPoint p b w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, β sum_subtype_eq_sum_filter]
/-- A weighted sum over `{x β s | pred x}` equals one over `s` if all the weights at indices in `s`
not satisfying `pred` are zero. -/
theorem weightedVSubOfPoint_filter_of_ne (w : ΞΉ β k) (p : ΞΉ β P) (b : P) {pred : ΞΉ β Prop}
[DecidablePred pred] (h : β i β s, w i β 0 β pred i) :
{x β s | pred x}.weightedVSubOfPoint p b w = s.weightedVSubOfPoint p b w := by
rw [weightedVSubOfPoint_apply, weightedVSubOfPoint_apply, sum_filter_of_ne]
intro i hi hne
refine h i hi ?_
intro hw
simp [hw] at hne
/-- A constant multiplier of the weights in `weightedVSubOfPoint` may be moved outside the
sum. -/
theorem weightedVSubOfPoint_const_smul (w : ΞΉ β k) (p : ΞΉ β P) (b : P) (c : k) :
s.weightedVSubOfPoint p b (c β’ w) = c β’ s.weightedVSubOfPoint p b w := by
simp_rw [weightedVSubOfPoint_apply, smul_sum, Pi.smul_apply, smul_smul, smul_eq_mul]
/-- A weighted sum of the results of subtracting a default base point
from the given points, as a linear map on the weights. This is
intended to be used when the sum of the weights is 0; that condition
is specified as a hypothesis on those lemmas that require it. -/
def weightedVSub (p : ΞΉ β P) : (ΞΉ β k) ββ[k] V :=
s.weightedVSubOfPoint p (Classical.choice S.nonempty)
/-- Applying `weightedVSub` with given weights. This is for the case
where a result involving a default base point is OK (for example, when
that base point will cancel out later); a more typical use case for
`weightedVSub` would involve selecting a preferred base point with
`weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero` and then
using `weightedVSubOfPoint_apply`. -/
theorem weightedVSub_apply (w : ΞΉ β k) (p : ΞΉ β P) :
s.weightedVSub p w = β i β s, w i β’ (p i -α΅₯ Classical.choice S.nonempty) := by
simp [weightedVSub, LinearMap.sum_apply]
/-- `weightedVSub` gives the sum of the results of subtracting any
base point, when the sum of the weights is 0. -/
theorem weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero (w : ΞΉ β k) (p : ΞΉ β P)
(h : β i β s, w i = 0) (b : P) : s.weightedVSub p w = s.weightedVSubOfPoint p b w :=
s.weightedVSubOfPoint_eq_of_sum_eq_zero w p h _ _
/-- The value of `weightedVSub`, where the given points are equal and the sum of the weights
is 0. -/
@[simp]
theorem weightedVSub_apply_const (w : ΞΉ β k) (p : P) (h : β i β s, w i = 0) :
s.weightedVSub (fun _ => p) w = 0 := by
rw [weightedVSub, weightedVSubOfPoint_apply_const, h, zero_smul]
/-- The `weightedVSub` for an empty set is 0. -/
@[simp]
theorem weightedVSub_empty (w : ΞΉ β k) (p : ΞΉ β P) : (β
: Finset ΞΉ).weightedVSub p w = (0 : V) := by
simp [weightedVSub_apply]
lemma weightedVSub_vadd {s : Finset ΞΉ} {w : ΞΉ β k} (h : β i β s, w i = 0) (p : ΞΉ β P) (v : V) :
s.weightedVSub (v +α΅₯ p) w = s.weightedVSub p w := by
rw [weightedVSub, weightedVSubOfPoint_vadd,
weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero _ _ _ h]
lemma weightedVSub_smul {G : Type*} [Group G] [DistribMulAction G V] [SMulCommClass G k V]
{s : Finset ΞΉ} {w : ΞΉ β k} (h : β i β s, w i = 0) (p : ΞΉ β V) (a : G) :
s.weightedVSub (a β’ p) w = a β’ s.weightedVSub p w := by
rw [weightedVSub, weightedVSubOfPoint_smul,
weightedVSub_eq_weightedVSubOfPoint_of_sum_eq_zero _ _ _ h]
/-- `weightedVSub` gives equal results for two families of weights and two families of points
that are equal on `s`. -/
theorem weightedVSub_congr {wβ wβ : ΞΉ β k} (hw : β i β s, wβ i = wβ i) {pβ pβ : ΞΉ β P}
(hp : β i β s, pβ i = pβ i) : s.weightedVSub pβ wβ = s.weightedVSub pβ wβ :=
s.weightedVSubOfPoint_congr hw hp _
/-- The weighted sum is unaffected by changing the weights to the
corresponding indicator function and adding points to the set. -/
theorem weightedVSub_indicator_subset (w : ΞΉ β k) (p : ΞΉ β P) {sβ sβ : Finset ΞΉ} (h : sβ β sβ) :
sβ.weightedVSub p w = sβ.weightedVSub p (Set.indicator (βsβ) w) :=
weightedVSubOfPoint_indicator_subset _ _ _ h
/-- A weighted subtraction, over the image of an embedding, equals a
weighted subtraction with the same points and weights over the
original `Finset`. -/
theorem weightedVSub_map (e : ΞΉβ βͺ ΞΉ) (w : ΞΉ β k) (p : ΞΉ β P) :
(sβ.map e).weightedVSub p w = sβ.weightedVSub (p β e) (w β e) :=
sβ.weightedVSubOfPoint_map _ _ _ _
/-- A weighted sum of pairwise subtractions, expressed as a subtraction of two `weightedVSub`
expressions. -/
theorem sum_smul_vsub_eq_weightedVSub_sub (w : ΞΉ β k) (pβ pβ : ΞΉ β P) :
(β i β s, w i β’ (pβ i -α΅₯ pβ i)) = s.weightedVSub pβ w - s.weightedVSub pβ w :=
s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _
/-- A weighted sum of pairwise subtractions, where the point on the right is constant and the
sum of the weights is 0. -/
theorem sum_smul_vsub_const_eq_weightedVSub (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ : P)
(h : β i β s, w i = 0) : (β i β s, w i β’ (pβ i -α΅₯ pβ)) = s.weightedVSub pβ w := by
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, sub_zero]
/-- A weighted sum of pairwise subtractions, where the point on the left is constant and the
sum of the weights is 0. -/
theorem sum_smul_const_vsub_eq_neg_weightedVSub (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ : P)
(h : β i β s, w i = 0) : (β i β s, w i β’ (pβ -α΅₯ pβ i)) = -s.weightedVSub pβ w := by
rw [sum_smul_vsub_eq_weightedVSub_sub, s.weightedVSub_apply_const _ _ h, zero_sub]
/-- A weighted sum may be split into such sums over two subsets. -/
theorem weightedVSub_sdiff [DecidableEq ΞΉ] {sβ : Finset ΞΉ} (h : sβ β s) (w : ΞΉ β k) (p : ΞΉ β P) :
(s \ sβ).weightedVSub p w + sβ.weightedVSub p w = s.weightedVSub p w :=
s.weightedVSubOfPoint_sdiff h _ _ _
/-- A weighted sum may be split into a subtraction of such sums over two subsets. -/
theorem weightedVSub_sdiff_sub [DecidableEq ΞΉ] {sβ : Finset ΞΉ} (h : sβ β s) (w : ΞΉ β k)
(p : ΞΉ β P) : (s \ sβ).weightedVSub p w - sβ.weightedVSub p (-w) = s.weightedVSub p w :=
s.weightedVSubOfPoint_sdiff_sub h _ _ _
/-- A weighted sum over `s.subtype pred` equals one over `{x β s | pred x}`. -/
theorem weightedVSub_subtype_eq_filter (w : ΞΉ β k) (p : ΞΉ β P) (pred : ΞΉ β Prop)
[DecidablePred pred] :
((s.subtype pred).weightedVSub (fun i => p i) fun i => w i) =
{x β s | pred x}.weightedVSub p w :=
s.weightedVSubOfPoint_subtype_eq_filter _ _ _ _
/-- A weighted sum over `{x β s | pred x}` equals one over `s` if all the weights at indices in `s`
not satisfying `pred` are zero. -/
theorem weightedVSub_filter_of_ne (w : ΞΉ β k) (p : ΞΉ β P) {pred : ΞΉ β Prop} [DecidablePred pred]
(h : β i β s, w i β 0 β pred i) : {x β s | pred x}.weightedVSub p w = s.weightedVSub p w :=
s.weightedVSubOfPoint_filter_of_ne _ _ _ h
/-- A constant multiplier of the weights in `weightedVSub_of` may be moved outside the sum. -/
theorem weightedVSub_const_smul (w : ΞΉ β k) (p : ΞΉ β P) (c : k) :
s.weightedVSub p (c β’ w) = c β’ s.weightedVSub p w :=
s.weightedVSubOfPoint_const_smul _ _ _ _
instance : AffineSpace (ΞΉ β k) (ΞΉ β k) := Pi.instAddTorsor
variable (k)
/-- A weighted sum of the results of subtracting a default base point
from the given points, added to that base point, as an affine map on
the weights. This is intended to be used when the sum of the weights
is 1, in which case it is an affine combination (barycenter) of the
points with the given weights; that condition is specified as a
hypothesis on those lemmas that require it. -/
def affineCombination (p : ΞΉ β P) : (ΞΉ β k) βα΅[k] P where
toFun w := s.weightedVSubOfPoint p (Classical.choice S.nonempty) w +α΅₯ Classical.choice S.nonempty
linear := s.weightedVSub p
map_vadd' wβ wβ := by simp_rw [vadd_vadd, weightedVSub, vadd_eq_add, LinearMap.map_add]
/-- The linear map corresponding to `affineCombination` is
`weightedVSub`. -/
@[simp]
theorem affineCombination_linear (p : ΞΉ β P) :
(s.affineCombination k p).linear = s.weightedVSub p :=
rfl
variable {k}
/-- Applying `affineCombination` with given weights. This is for the
case where a result involving a default base point is OK (for example,
when that base point will cancel out later); a more typical use case
for `affineCombination` would involve selecting a preferred base
point with
`affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one` and
then using `weightedVSubOfPoint_apply`. -/
theorem affineCombination_apply (w : ΞΉ β k) (p : ΞΉ β P) :
(s.affineCombination k p) w =
s.weightedVSubOfPoint p (Classical.choice S.nonempty) w +α΅₯ Classical.choice S.nonempty :=
rfl
/-- The value of `affineCombination`, where the given points are equal. -/
@[simp]
theorem affineCombination_apply_const (w : ΞΉ β k) (p : P) (h : β i β s, w i = 1) :
s.affineCombination k (fun _ => p) w = p := by
rw [affineCombination_apply, s.weightedVSubOfPoint_apply_const, h, one_smul, vsub_vadd]
/-- `affineCombination` gives equal results for two families of weights and two families of
points that are equal on `s`. -/
theorem affineCombination_congr {wβ wβ : ΞΉ β k} (hw : β i β s, wβ i = wβ i) {pβ pβ : ΞΉ β P}
(hp : β i β s, pβ i = pβ i) : s.affineCombination k pβ wβ = s.affineCombination k pβ wβ := by
simp_rw [affineCombination_apply, s.weightedVSubOfPoint_congr hw hp]
/-- `affineCombination` gives the sum with any base point, when the
sum of the weights is 1. -/
theorem affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one (w : ΞΉ β k) (p : ΞΉ β P)
(h : β i β s, w i = 1) (b : P) :
s.affineCombination k p w = s.weightedVSubOfPoint p b w +α΅₯ b :=
s.weightedVSubOfPoint_vadd_eq_of_sum_eq_one w p h _ _
/-- Adding a `weightedVSub` to an `affineCombination`. -/
theorem weightedVSub_vadd_affineCombination (wβ wβ : ΞΉ β k) (p : ΞΉ β P) :
s.weightedVSub p wβ +α΅₯ s.affineCombination k p wβ = s.affineCombination k p (wβ + wβ) := by
rw [β vadd_eq_add, AffineMap.map_vadd, affineCombination_linear]
/-- Subtracting two `affineCombination`s. -/
theorem affineCombination_vsub (wβ wβ : ΞΉ β k) (p : ΞΉ β P) :
s.affineCombination k p wβ -α΅₯ s.affineCombination k p wβ = s.weightedVSub p (wβ - wβ) := by
rw [β AffineMap.linearMap_vsub, affineCombination_linear, vsub_eq_sub]
theorem attach_affineCombination_of_injective [DecidableEq P] (s : Finset P) (w : P β k) (f : s β P)
(hf : Function.Injective f) :
s.attach.affineCombination k f (w β f) = (image f univ).affineCombination k id w := by
simp only [affineCombination, weightedVSubOfPoint_apply, id, vadd_right_cancel_iff,
Function.comp_apply, AffineMap.coe_mk]
let gβ : s β V := fun i => w (f i) β’ (f i -α΅₯ Classical.choice S.nonempty)
let gβ : P β V := fun i => w i β’ (i -α΅₯ Classical.choice S.nonempty)
change univ.sum gβ = (image f univ).sum gβ
have hgf : gβ = gβ β f := by
ext
simp [gβ, gβ]
rw [hgf, sum_image]
Β· simp only [gβ, gβ,Function.comp_apply]
Β· exact fun _ _ _ _ hxy => hf hxy
theorem attach_affineCombination_coe (s : Finset P) (w : P β k) :
s.attach.affineCombination k ((β) : s β P) (w β (β)) = s.affineCombination k id w := by
classical rw [attach_affineCombination_of_injective s w ((β) : s β P) Subtype.coe_injective,
univ_eq_attach, attach_image_val]
/-- Viewing a module as an affine space modelled on itself, a `weightedVSub` is just a linear
combination. -/
@[simp]
theorem weightedVSub_eq_linear_combination {ΞΉ} (s : Finset ΞΉ) {w : ΞΉ β k} {p : ΞΉ β V}
(hw : s.sum w = 0) : s.weightedVSub p w = β i β s, w i β’ p i := by
simp [s.weightedVSub_apply, vsub_eq_sub, smul_sub, β Finset.sum_smul, hw]
/-- Viewing a module as an affine space modelled on itself, affine combinations are just linear
combinations. -/
@[simp]
theorem affineCombination_eq_linear_combination (s : Finset ΞΉ) (p : ΞΉ β V) (w : ΞΉ β k)
(hw : β i β s, w i = 1) : s.affineCombination k p w = β i β s, w i β’ p i := by
simp [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p hw 0]
/-- An `affineCombination` equals a point if that point is in the set
and has weight 1 and the other points in the set have weight 0. -/
@[simp]
theorem affineCombination_of_eq_one_of_eq_zero (w : ΞΉ β k) (p : ΞΉ β P) {i : ΞΉ} (his : i β s)
(hwi : w i = 1) (hw0 : β i2 β s, i2 β i β w i2 = 0) : s.affineCombination k p w = p i := by
have h1 : β i β s, w i = 1 := hwi βΈ sum_eq_single i hw0 fun h => False.elim (h his)
rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h1 (p i),
weightedVSubOfPoint_apply]
convert zero_vadd V (p i)
refine sum_eq_zero ?_
intro i2 hi2
by_cases h : i2 = i
Β· simp [h]
Β· simp [hw0 i2 hi2 h]
/-- An affine combination is unaffected by changing the weights to the
corresponding indicator function and adding points to the set. -/
theorem affineCombination_indicator_subset (w : ΞΉ β k) (p : ΞΉ β P) {sβ sβ : Finset ΞΉ}
(h : sβ β sβ) :
sβ.affineCombination k p w = sβ.affineCombination k p (Set.indicator (βsβ) w) := by
rw [affineCombination_apply, affineCombination_apply,
weightedVSubOfPoint_indicator_subset _ _ _ h]
/-- An affine combination, over the image of an embedding, equals an
affine combination with the same points and weights over the original
`Finset`. -/
theorem affineCombination_map (e : ΞΉβ βͺ ΞΉ) (w : ΞΉ β k) (p : ΞΉ β P) :
(sβ.map e).affineCombination k p w = sβ.affineCombination k (p β e) (w β e) := by
simp_rw [affineCombination_apply, weightedVSubOfPoint_map]
/-- A weighted sum of pairwise subtractions, expressed as a subtraction of two `affineCombination`
expressions. -/
theorem sum_smul_vsub_eq_affineCombination_vsub (w : ΞΉ β k) (pβ pβ : ΞΉ β P) :
(β i β s, w i β’ (pβ i -α΅₯ pβ i)) =
s.affineCombination k pβ w -α΅₯ s.affineCombination k pβ w := by
simp_rw [affineCombination_apply, vadd_vsub_vadd_cancel_right]
exact s.sum_smul_vsub_eq_weightedVSubOfPoint_sub _ _ _ _
/-- A weighted sum of pairwise subtractions, where the point on the right is constant and the
sum of the weights is 1. -/
theorem sum_smul_vsub_const_eq_affineCombination_vsub (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ : P)
(h : β i β s, w i = 1) : (β i β s, w i β’ (pβ i -α΅₯ pβ)) = s.affineCombination k pβ w -α΅₯ pβ := by
rw [sum_smul_vsub_eq_affineCombination_vsub, affineCombination_apply_const _ _ _ h]
/-- A weighted sum of pairwise subtractions, where the point on the left is constant and the
sum of the weights is 1. -/
theorem sum_smul_const_vsub_eq_vsub_affineCombination (w : ΞΉ β k) (pβ : ΞΉ β P) (pβ : P)
(h : β i β s, w i = 1) : (β i β s, w i β’ (pβ -α΅₯ pβ i)) = pβ -α΅₯ s.affineCombination k pβ w := by
rw [sum_smul_vsub_eq_affineCombination_vsub, affineCombination_apply_const _ _ _ h]
/-- A weighted sum may be split into a subtraction of affine combinations over two subsets. -/
theorem affineCombination_sdiff_sub [DecidableEq ΞΉ] {sβ : Finset ΞΉ} (h : sβ β s) (w : ΞΉ β k)
(p : ΞΉ β P) :
(s \ sβ).affineCombination k p w -α΅₯ sβ.affineCombination k p (-w) = s.weightedVSub p w := by
simp_rw [affineCombination_apply, vadd_vsub_vadd_cancel_right]
exact s.weightedVSub_sdiff_sub h _ _
/-- If a weighted sum is zero and one of the weights is `-1`, the corresponding point is
the affine combination of the other points with the given weights. -/
theorem affineCombination_eq_of_weightedVSub_eq_zero_of_eq_neg_one {w : ΞΉ β k} {p : ΞΉ β P}
(hw : s.weightedVSub p w = (0 : V)) {i : ΞΉ} [DecidablePred (Β· β i)] (his : i β s)
(hwi : w i = -1) : {x β s | x β i}.affineCombination k p w = p i := by
classical
rw [β @vsub_eq_zero_iff_eq V, β hw,
β s.affineCombination_sdiff_sub (singleton_subset_iff.2 his), sdiff_singleton_eq_erase,
β filter_ne']
congr
refine (affineCombination_of_eq_one_of_eq_zero _ _ _ (mem_singleton_self _) ?_ ?_).symm
Β· simp [hwi]
Β· simp
/-- An affine combination over `s.subtype pred` equals one over `{x β s | pred x}`. -/
theorem affineCombination_subtype_eq_filter (w : ΞΉ β k) (p : ΞΉ β P) (pred : ΞΉ β Prop)
[DecidablePred pred] :
((s.subtype pred).affineCombination k (fun i => p i) fun i => w i) =
{x β s | pred x}.affineCombination k p w := by
rw [affineCombination_apply, affineCombination_apply, weightedVSubOfPoint_subtype_eq_filter]
/-- An affine combination over `{x β s | pred x}` equals one over `s` if all the weights at indices
in `s` not satisfying `pred` are zero. -/
theorem affineCombination_filter_of_ne (w : ΞΉ β k) (p : ΞΉ β P) {pred : ΞΉ β Prop}
[DecidablePred pred] (h : β i β s, w i β 0 β pred i) :
{x β s | pred x}.affineCombination k p w = s.affineCombination k p w := by
rw [affineCombination_apply, affineCombination_apply,
s.weightedVSubOfPoint_filter_of_ne _ _ _ h]
/-- Suppose an indexed family of points is given, along with a subset
of the index type. A vector can be expressed as
`weightedVSubOfPoint` using a `Finset` lying within that subset and
with a given sum of weights if and only if it can be expressed as
`weightedVSubOfPoint` with that sum of weights for the
corresponding indexed family whose index type is the subtype
corresponding to that subset. -/
theorem eq_weightedVSubOfPoint_subset_iff_eq_weightedVSubOfPoint_subtype {v : V} {x : k} {s : Set ΞΉ}
{p : ΞΉ β P} {b : P} :
(β fs : Finset ΞΉ, βfs β s β§ β w : ΞΉ β k, β i β fs, w i = x β§
v = fs.weightedVSubOfPoint p b w) β
β (fs : Finset s) (w : s β k), β i β fs, w i = x β§
v = fs.weightedVSubOfPoint (fun i : s => p i) b w := by
classical
simp_rw [weightedVSubOfPoint_apply]
constructor
Β· rintro β¨fs, hfs, w, rfl, rflβ©
exact β¨fs.subtype s, fun i => w i, sum_subtype_of_mem _ hfs, (sum_subtype_of_mem _ hfs).symmβ©
Β· rintro β¨fs, w, rfl, rflβ©
refine
β¨fs.map (Function.Embedding.subtype _), map_subtype_subset _, fun i =>
if h : i β s then w β¨i, hβ© else 0, ?_, ?_β© <;>
simp
variable (k)
/-- Suppose an indexed family of points is given, along with a subset
of the index type. A vector can be expressed as `weightedVSub` using
a `Finset` lying within that subset and with sum of weights 0 if and
only if it can be expressed as `weightedVSub` with sum of weights 0
for the corresponding indexed family whose index type is the subtype
corresponding to that subset. -/
theorem eq_weightedVSub_subset_iff_eq_weightedVSub_subtype {v : V} {s : Set ΞΉ} {p : ΞΉ β P} :
(β fs : Finset ΞΉ, βfs β s β§ β w : ΞΉ β k, β i β fs, w i = 0 β§
v = fs.weightedVSub p w) β
β (fs : Finset s) (w : s β k), β i β fs, w i = 0 β§
v = fs.weightedVSub (fun i : s => p i) w :=
eq_weightedVSubOfPoint_subset_iff_eq_weightedVSubOfPoint_subtype
variable (V)
/-- Suppose an indexed family of points is given, along with a subset
of the index type. A point can be expressed as an
`affineCombination` using a `Finset` lying within that subset and
with sum of weights 1 if and only if it can be expressed an
`affineCombination` with sum of weights 1 for the corresponding
indexed family whose index type is the subtype corresponding to that
subset. -/
theorem eq_affineCombination_subset_iff_eq_affineCombination_subtype {p0 : P} {s : Set ΞΉ}
{p : ΞΉ β P} :
(β fs : Finset ΞΉ, βfs β s β§ β w : ΞΉ β k, β i β fs, w i = 1 β§
p0 = fs.affineCombination k p w) β
β (fs : Finset s) (w : s β k), β i β fs, w i = 1 β§
p0 = fs.affineCombination k (fun i : s => p i) w := by
simp_rw [affineCombination_apply, eq_vadd_iff_vsub_eq]
exact eq_weightedVSubOfPoint_subset_iff_eq_weightedVSubOfPoint_subtype
variable {k V}
/-- Affine maps commute with affine combinations. -/
theorem map_affineCombination {Vβ Pβ : Type*} [AddCommGroup Vβ] [Module k Vβ] [AffineSpace Vβ Pβ]
(p : ΞΉ β P) (w : ΞΉ β k) (hw : s.sum w = 1) (f : P βα΅[k] Pβ) :
f (s.affineCombination k p w) = s.affineCombination k (f β p) w := by
have b := Classical.choice (inferInstance : AffineSpace V P).nonempty
have bβ := Classical.choice (inferInstance : AffineSpace Vβ Pβ).nonempty
rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p hw b,
s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w (f β p) hw bβ, β
s.weightedVSubOfPoint_vadd_eq_of_sum_eq_one w (f β p) hw (f b) bβ]
simp only [weightedVSubOfPoint_apply, RingHom.id_apply, AffineMap.map_vadd,
LinearMap.map_smulββ, AffineMap.linearMap_vsub, map_sum, Function.comp_apply]
/-- The value of `affineCombination`, where the given points take only two values. -/
lemma affineCombination_apply_eq_lineMap_sum [DecidableEq ΞΉ] (w : ΞΉ β k) (p : ΞΉ β P)
(pβ pβ : P) (s' : Finset ΞΉ) (h : β i β s, w i = 1) (hpβ : β i β s β© s', p i = pβ)
(hpβ : β i β s \ s', p i = pβ) :
s.affineCombination k p w = AffineMap.lineMap pβ pβ (β i β s β© s', w i) := by
rw [s.affineCombination_eq_weightedVSubOfPoint_vadd_of_sum_eq_one w p h pβ,
weightedVSubOfPoint_apply, β s.sum_inter_add_sum_diff s', AffineMap.lineMap_apply,
vadd_right_cancel_iff, sum_smul]
convert add_zero _ with i hi
Β· convert Finset.sum_const_zero with i hi
simp [hpβ i hi]
Β· exact (hpβ i hi).symm
variable (k)
/-- Weights for expressing a single point as an affine combination. -/
def affineCombinationSingleWeights [DecidableEq ΞΉ] (i : ΞΉ) : ΞΉ β k :=
Pi.single i 1
@[simp]
theorem affineCombinationSingleWeights_apply_self [DecidableEq ΞΉ] (i : ΞΉ) :
affineCombinationSingleWeights k i i = 1 := Pi.single_eq_same _ _
@[simp]
theorem affineCombinationSingleWeights_apply_of_ne [DecidableEq ΞΉ] {i j : ΞΉ} (h : j β i) :
affineCombinationSingleWeights k i j = 0 := Pi.single_eq_of_ne h _
@[simp]
theorem sum_affineCombinationSingleWeights [DecidableEq ΞΉ] {i : ΞΉ} (h : i β s) :
β j β s, affineCombinationSingleWeights k i j = 1 := by
rw [β affineCombinationSingleWeights_apply_self k i]
exact sum_eq_single_of_mem i h fun j _ hj => affineCombinationSingleWeights_apply_of_ne k hj
/-- Weights for expressing the subtraction of two points as a `weightedVSub`. -/
def weightedVSubVSubWeights [DecidableEq ΞΉ] (i j : ΞΉ) : ΞΉ β k :=
affineCombinationSingleWeights k i - affineCombinationSingleWeights k j
@[simp]
theorem weightedVSubVSubWeights_self [DecidableEq ΞΉ] (i : ΞΉ) :
weightedVSubVSubWeights k i i = 0 := by simp [weightedVSubVSubWeights]
@[simp]
theorem weightedVSubVSubWeights_apply_left [DecidableEq ΞΉ] {i j : ΞΉ} (h : i β j) :
weightedVSubVSubWeights k i j i = 1 := by simp [weightedVSubVSubWeights, h]
@[simp]
theorem weightedVSubVSubWeights_apply_right [DecidableEq ΞΉ] {i j : ΞΉ} (h : i β j) :
weightedVSubVSubWeights k i j j = -1 := by simp [weightedVSubVSubWeights, h.symm]
@[simp]
theorem weightedVSubVSubWeights_apply_of_ne [DecidableEq ΞΉ] {i j t : ΞΉ} (hi : t β i) (hj : t β j) :
weightedVSubVSubWeights k i j t = 0 := by simp [weightedVSubVSubWeights, hi, hj]
@[simp]
theorem sum_weightedVSubVSubWeights [DecidableEq ΞΉ] {i j : ΞΉ} (hi : i β s) (hj : j β s) :
β t β s, weightedVSubVSubWeights k i j t = 0 := by
simp_rw [weightedVSubVSubWeights, Pi.sub_apply, sum_sub_distrib]
simp [hi, hj]
variable {k}
/-- Weights for expressing `lineMap` as an affine combination. -/
def affineCombinationLineMapWeights [DecidableEq ΞΉ] (i j : ΞΉ) (c : k) : ΞΉ β k :=
c β’ weightedVSubVSubWeights k j i + affineCombinationSingleWeights k i
@[simp]
theorem affineCombinationLineMapWeights_self [DecidableEq ΞΉ] (i : ΞΉ) (c : k) :
affineCombinationLineMapWeights i i c = affineCombinationSingleWeights k i := by
simp [affineCombinationLineMapWeights]
@[simp]
theorem affineCombinationLineMapWeights_apply_left [DecidableEq ΞΉ] {i j : ΞΉ} (h : i β j) (c : k) :
affineCombinationLineMapWeights i j c i = 1 - c := by
simp [affineCombinationLineMapWeights, h.symm, sub_eq_neg_add]
@[simp]
theorem affineCombinationLineMapWeights_apply_right [DecidableEq ΞΉ] {i j : ΞΉ} (h : i β j) (c : k) :
affineCombinationLineMapWeights i j c j = c := by
simp [affineCombinationLineMapWeights, h.symm]
@[simp]
theorem affineCombinationLineMapWeights_apply_of_ne [DecidableEq ΞΉ] {i j t : ΞΉ} (hi : t β i)
(hj : t β j) (c : k) : affineCombinationLineMapWeights i j c t = 0 := by
simp [affineCombinationLineMapWeights, hi, hj]
@[simp]
theorem sum_affineCombinationLineMapWeights [DecidableEq ΞΉ] {i j : ΞΉ} (hi : i β s) (hj : j β s)
(c : k) : β t β s, affineCombinationLineMapWeights i j c t = 1 := by
simp_rw [affineCombinationLineMapWeights, Pi.add_apply, sum_add_distrib]
simp [hi, hj, β mul_sum]
variable (k)
/-- An affine combination with `affineCombinationSingleWeights` gives the specified point. -/
@[simp]
| Mathlib/LinearAlgebra/AffineSpace/Combination.lean | 690 | 693 | theorem affineCombination_affineCombinationSingleWeights [DecidableEq ΞΉ] (p : ΞΉ β P) {i : ΞΉ}
(hi : i β s) : s.affineCombination k p (affineCombinationSingleWeights k i) = p i := by | refine s.affineCombination_of_eq_one_of_eq_zero _ _ hi (by simp) ?_
rintro j - hj |
/-
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 Batteries.Tactic.Congr
import Mathlib.Data.Option.Basic
import Mathlib.Data.Prod.Basic
import Mathlib.Data.Set.Subsingleton
import Mathlib.Data.Set.SymmDiff
import Mathlib.Data.Set.Inclusion
/-!
# Images and preimages of sets
## Main definitions
* `preimage f t : Set Ξ±` : the preimage fβ»ΒΉ(t) (written `f β»ΒΉ' t` in Lean) of a subset of Ξ².
* `range f : Set Ξ²` : the image of `univ` under `f`.
Also works for `{p : Prop} (f : p β Ξ±)` (unlike `image`)
## Notation
* `f β»ΒΉ' t` for `Set.preimage f t`
* `f '' s` for `Set.image f s`
## Tags
set, sets, image, preimage, pre-image, range
-/
assert_not_exists WithTop OrderIso
universe u v
open Function Set
namespace Set
variable {Ξ± Ξ² Ξ³ : Type*} {ΞΉ : Sort*}
/-! ### Inverse image -/
section Preimage
variable {f : Ξ± β Ξ²} {g : Ξ² β Ξ³}
@[simp]
theorem preimage_empty : f β»ΒΉ' β
= β
:=
rfl
theorem preimage_congr {f g : Ξ± β Ξ²} {s : Set Ξ²} (h : β x : Ξ±, f x = g x) : f β»ΒΉ' s = g β»ΒΉ' s := by
congr with x
simp [h]
@[gcongr]
theorem preimage_mono {s t : Set Ξ²} (h : s β t) : f β»ΒΉ' s β f β»ΒΉ' t := fun _ hx => h hx
@[simp, mfld_simps]
theorem preimage_univ : f β»ΒΉ' univ = univ :=
rfl
theorem subset_preimage_univ {s : Set Ξ±} : s β f β»ΒΉ' univ :=
subset_univ _
@[simp, mfld_simps]
theorem preimage_inter {s t : Set Ξ²} : f β»ΒΉ' (s β© t) = f β»ΒΉ' s β© f β»ΒΉ' t :=
rfl
@[simp]
theorem preimage_union {s t : Set Ξ²} : f β»ΒΉ' (s βͺ t) = f β»ΒΉ' s βͺ f β»ΒΉ' t :=
rfl
@[simp]
theorem preimage_compl {s : Set Ξ²} : f β»ΒΉ' sαΆ = (f β»ΒΉ' s)αΆ :=
rfl
@[simp]
theorem preimage_diff (f : Ξ± β Ξ²) (s t : Set Ξ²) : f β»ΒΉ' (s \ t) = f β»ΒΉ' s \ f β»ΒΉ' t :=
rfl
open scoped symmDiff in
@[simp]
lemma preimage_symmDiff {f : Ξ± β Ξ²} (s t : Set Ξ²) : f β»ΒΉ' (s β t) = (f β»ΒΉ' s) β (f β»ΒΉ' t) :=
rfl
@[simp]
theorem preimage_ite (f : Ξ± β Ξ²) (s tβ tβ : Set Ξ²) :
f β»ΒΉ' s.ite tβ tβ = (f β»ΒΉ' s).ite (f β»ΒΉ' tβ) (f β»ΒΉ' tβ) :=
rfl
@[simp]
theorem preimage_setOf_eq {p : Ξ± β Prop} {f : Ξ² β Ξ±} : f β»ΒΉ' { a | p a } = { a | p (f a) } :=
rfl
@[simp]
theorem preimage_id_eq : preimage (id : Ξ± β Ξ±) = id :=
rfl
@[mfld_simps]
theorem preimage_id {s : Set Ξ±} : id β»ΒΉ' s = s :=
rfl
@[simp, mfld_simps]
theorem preimage_id' {s : Set Ξ±} : (fun x => x) β»ΒΉ' s = s :=
rfl
@[simp]
theorem preimage_const_of_mem {b : Ξ²} {s : Set Ξ²} (h : b β s) : (fun _ : Ξ± => b) β»ΒΉ' s = univ :=
eq_univ_of_forall fun _ => h
@[simp]
theorem preimage_const_of_not_mem {b : Ξ²} {s : Set Ξ²} (h : b β s) : (fun _ : Ξ± => b) β»ΒΉ' s = β
:=
eq_empty_of_subset_empty fun _ hx => h hx
theorem preimage_const (b : Ξ²) (s : Set Ξ²) [Decidable (b β s)] :
(fun _ : Ξ± => b) β»ΒΉ' s = if b β s then univ else β
:= by
split_ifs with hb
exacts [preimage_const_of_mem hb, preimage_const_of_not_mem hb]
/-- If preimage of each singleton under `f : Ξ± β Ξ²` is either empty or the whole type,
then `f` is a constant. -/
lemma exists_eq_const_of_preimage_singleton [Nonempty Ξ²] {f : Ξ± β Ξ²}
(hf : β b : Ξ², f β»ΒΉ' {b} = β
β¨ f β»ΒΉ' {b} = univ) : β b, f = const Ξ± b := by
rcases em (β b, f β»ΒΉ' {b} = univ) with β¨b, hbβ© | hf'
Β· exact β¨b, funext fun x β¦ eq_univ_iff_forall.1 hb xβ©
Β· have : β x b, f x β b := fun x b β¦
eq_empty_iff_forall_not_mem.1 ((hf b).resolve_right fun h β¦ hf' β¨b, hβ©) x
exact β¨Classical.arbitrary Ξ², funext fun x β¦ absurd rfl (this x _)β©
theorem preimage_comp {s : Set Ξ³} : g β f β»ΒΉ' s = f β»ΒΉ' (g β»ΒΉ' s) :=
rfl
theorem preimage_comp_eq : preimage (g β f) = preimage f β preimage g :=
rfl
theorem preimage_iterate_eq {f : Ξ± β Ξ±} {n : β} : Set.preimage f^[n] = (Set.preimage f)^[n] := by
induction n with
| zero => simp
| succ n ih => rw [iterate_succ, iterate_succ', preimage_comp_eq, ih]
theorem preimage_preimage {g : Ξ² β Ξ³} {f : Ξ± β Ξ²} {s : Set Ξ³} :
f β»ΒΉ' (g β»ΒΉ' s) = (fun x => g (f x)) β»ΒΉ' s :=
preimage_comp.symm
theorem eq_preimage_subtype_val_iff {p : Ξ± β Prop} {s : Set (Subtype p)} {t : Set Ξ±} :
s = Subtype.val β»ΒΉ' t β β (x) (h : p x), (β¨x, hβ© : Subtype p) β s β x β t :=
β¨fun s_eq x h => by
rw [s_eq]
simp, fun h => ext fun β¨x, hxβ© => by simp [h]β©
theorem nonempty_of_nonempty_preimage {s : Set Ξ²} {f : Ξ± β Ξ²} (hf : (f β»ΒΉ' s).Nonempty) :
s.Nonempty :=
let β¨x, hxβ© := hf
β¨f x, hxβ©
@[simp] theorem preimage_singleton_true (p : Ξ± β Prop) : p β»ΒΉ' {True} = {a | p a} := by ext; simp
@[simp] theorem preimage_singleton_false (p : Ξ± β Prop) : p β»ΒΉ' {False} = {a | Β¬p a} := by ext; simp
theorem preimage_subtype_coe_eq_compl {s u v : Set Ξ±} (hsuv : s β u βͺ v)
(H : s β© (u β© v) = β
) : ((β) : s β Ξ±) β»ΒΉ' u = ((β) β»ΒΉ' v)αΆ := by
ext β¨x, x_in_sβ©
constructor
Β· intro x_in_u x_in_v
exact eq_empty_iff_forall_not_mem.mp H x β¨x_in_s, β¨x_in_u, x_in_vβ©β©
Β· intro hx
exact Or.elim (hsuv x_in_s) id fun hx' => hx.elim hx'
lemma preimage_subset {s t} (hs : s β f '' t) (hf : Set.InjOn f (f β»ΒΉ' s)) : f β»ΒΉ' s β t := by
rintro a ha
obtain β¨b, hb, hbaβ© := hs ha
rwa [hf ha _ hba.symm]
simpa [hba]
end Preimage
/-! ### Image of a set under a function -/
section Image
variable {f : Ξ± β Ξ²} {s t : Set Ξ±}
theorem image_eta (f : Ξ± β Ξ²) : f '' s = (fun x => f x) '' s :=
rfl
theorem _root_.Function.Injective.mem_set_image {f : Ξ± β Ξ²} (hf : Injective f) {s : Set Ξ±} {a : Ξ±} :
f a β f '' s β a β s :=
β¨fun β¨_, hb, Eqβ© => hf Eq βΈ hb, mem_image_of_mem fβ©
lemma preimage_subset_of_surjOn {t : Set Ξ²} (hf : Injective f) (h : SurjOn f s t) :
f β»ΒΉ' t β s := fun _ hx β¦
hf.mem_set_image.1 <| h hx
theorem forall_mem_image {f : Ξ± β Ξ²} {s : Set Ξ±} {p : Ξ² β Prop} :
(β y β f '' s, p y) β β β¦xβ¦, x β s β p (f x) := by simp
theorem exists_mem_image {f : Ξ± β Ξ²} {s : Set Ξ±} {p : Ξ² β Prop} :
(β y β f '' s, p y) β β x β s, p (f x) := by simp
@[congr]
theorem image_congr {f g : Ξ± β Ξ²} {s : Set Ξ±} (h : β a β s, f a = g a) : f '' s = g '' s := by
aesop
/-- A common special case of `image_congr` -/
theorem image_congr' {f g : Ξ± β Ξ²} {s : Set Ξ±} (h : β x : Ξ±, f x = g x) : f '' s = g '' s :=
image_congr fun x _ => h x
@[gcongr]
lemma image_mono (h : s β t) : f '' s β f '' t := by
rintro - β¨a, ha, rflβ©; exact mem_image_of_mem f (h ha)
theorem image_comp (f : Ξ² β Ξ³) (g : Ξ± β Ξ²) (a : Set Ξ±) : f β g '' a = f '' (g '' a) := by aesop
theorem image_comp_eq {g : Ξ² β Ξ³} : image (g β f) = image g β image f := by ext; simp
/-- A variant of `image_comp`, useful for rewriting -/
theorem image_image (g : Ξ² β Ξ³) (f : Ξ± β Ξ²) (s : Set Ξ±) : g '' (f '' s) = (fun x => g (f x)) '' s :=
(image_comp g f s).symm
theorem image_comm {Ξ²'} {f : Ξ² β Ξ³} {g : Ξ± β Ξ²} {f' : Ξ± β Ξ²'} {g' : Ξ²' β Ξ³}
(h_comm : β a, f (g a) = g' (f' a)) : (s.image g).image f = (s.image f').image g' := by
simp_rw [image_image, h_comm]
theorem _root_.Function.Semiconj.set_image {f : Ξ± β Ξ²} {ga : Ξ± β Ξ±} {gb : Ξ² β Ξ²}
(h : Function.Semiconj f ga gb) : Function.Semiconj (image f) (image ga) (image gb) := fun _ =>
image_comm h
theorem _root_.Function.Commute.set_image {f g : Ξ± β Ξ±} (h : Function.Commute f g) :
Function.Commute (image f) (image g) :=
Function.Semiconj.set_image h
/-- Image is monotone with respect to `β`. See `Set.monotone_image` for the statement in
terms of `β€`. -/
@[gcongr]
theorem image_subset {a b : Set Ξ±} (f : Ξ± β Ξ²) (h : a β b) : f '' a β f '' b := by
simp only [subset_def, mem_image]
exact fun x => fun β¨w, h1, h2β© => β¨w, h h1, h2β©
/-- `Set.image` is monotone. See `Set.image_subset` for the statement in terms of `β`. -/
lemma monotone_image {f : Ξ± β Ξ²} : Monotone (image f) := fun _ _ => image_subset _
theorem image_union (f : Ξ± β Ξ²) (s t : Set Ξ±) : f '' (s βͺ t) = f '' s βͺ f '' t :=
ext fun x =>
β¨by rintro β¨a, h | h, rflβ© <;> [left; right] <;> exact β¨_, h, rflβ©, by
rintro (β¨a, h, rflβ© | β¨a, h, rflβ©) <;> refine β¨_, ?_, rflβ©
Β· exact mem_union_left t h
Β· exact mem_union_right s hβ©
@[simp]
theorem image_empty (f : Ξ± β Ξ²) : f '' β
= β
:= by
ext
simp
theorem image_inter_subset (f : Ξ± β Ξ²) (s t : Set Ξ±) : f '' (s β© t) β f '' s β© f '' t :=
subset_inter (image_subset _ inter_subset_left) (image_subset _ inter_subset_right)
theorem image_inter_on {f : Ξ± β Ξ²} {s t : Set Ξ±} (h : β x β t, β y β s, f x = f y β x = y) :
f '' (s β© t) = f '' s β© f '' t :=
(image_inter_subset _ _ _).antisymm
fun b β¨β¨aβ, haβ, hββ©, β¨aβ, haβ, hββ©β© β¦
have : aβ = aβ := h _ haβ _ haβ (by simp [*])
β¨aβ, β¨haβ, this βΈ haββ©, hββ©
theorem image_inter {f : Ξ± β Ξ²} {s t : Set Ξ±} (H : Injective f) : f '' (s β© t) = f '' s β© f '' t :=
image_inter_on fun _ _ _ _ h => H h
theorem image_univ_of_surjective {ΞΉ : Type*} {f : ΞΉ β Ξ²} (H : Surjective f) : f '' univ = univ :=
eq_univ_of_forall <| by simpa [image]
@[simp]
theorem image_singleton {f : Ξ± β Ξ²} {a : Ξ±} : f '' {a} = {f a} := by
ext
simp [image, eq_comm]
@[simp]
theorem Nonempty.image_const {s : Set Ξ±} (hs : s.Nonempty) (a : Ξ²) : (fun _ => a) '' s = {a} :=
ext fun _ =>
β¨fun β¨_, _, hβ© => h βΈ mem_singleton _, fun h =>
(eq_of_mem_singleton h).symm βΈ hs.imp fun _ hy => β¨hy, rflβ©β©
@[simp, mfld_simps]
theorem image_eq_empty {Ξ± Ξ²} {f : Ξ± β Ξ²} {s : Set Ξ±} : f '' s = β
β s = β
:= by
simp only [eq_empty_iff_forall_not_mem]
exact β¨fun H a ha => H _ β¨_, ha, rflβ©, fun H b β¨_, ha, _β© => H _ haβ©
theorem preimage_compl_eq_image_compl [BooleanAlgebra Ξ±] (S : Set Ξ±) :
HasCompl.compl β»ΒΉ' S = HasCompl.compl '' S :=
Set.ext fun x =>
β¨fun h => β¨xαΆ, h, compl_compl xβ©, fun h =>
Exists.elim h fun _ hy => (compl_eq_comm.mp hy.2).symm.subst hy.1β©
theorem mem_compl_image [BooleanAlgebra Ξ±] (t : Ξ±) (S : Set Ξ±) :
t β HasCompl.compl '' S β tαΆ β S := by
simp [β preimage_compl_eq_image_compl]
@[simp]
theorem image_id_eq : image (id : Ξ± β Ξ±) = id := by ext; simp
/-- A variant of `image_id` -/
@[simp]
theorem image_id' (s : Set Ξ±) : (fun x => x) '' s = s := by
ext
simp
theorem image_id (s : Set Ξ±) : id '' s = s := by simp
lemma image_iterate_eq {f : Ξ± β Ξ±} {n : β} : image (f^[n]) = (image f)^[n] := by
induction n with
| zero => simp
| succ n ih => rw [iterate_succ', iterate_succ', β ih, image_comp_eq]
| Mathlib/Data/Set/Image.lean | 318 | 323 | theorem compl_compl_image [BooleanAlgebra Ξ±] (S : Set Ξ±) :
HasCompl.compl '' (HasCompl.compl '' S) = S := by | rw [β image_comp, compl_comp_compl, image_id]
theorem image_insert_eq {f : Ξ± β Ξ²} {a : Ξ±} {s : Set Ξ±} :
f '' insert a s = insert (f a) (f '' s) := by |
/-
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.Analysis.RCLike.Basic
import Mathlib.Dynamics.BirkhoffSum.Average
/-!
# Birkhoff average in a normed space
In this file we prove some lemmas about the Birkhoff average (`birkhoffAverage`)
of a function which takes values in a normed space over `β` or `β`.
At the time of writing, all lemmas in this file
are motivated by the proof of the von Neumann Mean Ergodic Theorem,
see `LinearIsometry.tendsto_birkhoffAverage_orthogonalProjection`.
-/
open Function Set Filter
open scoped Topology ENNReal Uniformity
section
variable {Ξ± E : Type*}
/-- The Birkhoff averages of a function `g` over the orbit of a fixed point `x` of `f`
tend to `g x` as `N β β`. In fact, they are equal to `g x` for all `N β 0`,
see `Function.IsFixedPt.birkhoffAverage_eq`.
TODO: add a version for a periodic orbit. -/
theorem Function.IsFixedPt.tendsto_birkhoffAverage
(R : Type*) [DivisionSemiring R] [CharZero R]
[AddCommMonoid E] [TopologicalSpace E] [Module R E]
{f : Ξ± β Ξ±} {x : Ξ±} (h : f.IsFixedPt x) (g : Ξ± β E) :
Tendsto (birkhoffAverage R f g Β· x) atTop (π (g x)) :=
tendsto_const_nhds.congr' <| (eventually_ne_atTop 0).mono fun _n hn β¦
(h.birkhoffAverage_eq R g hn).symm
variable [NormedAddCommGroup E]
theorem dist_birkhoffSum_apply_birkhoffSum (f : Ξ± β Ξ±) (g : Ξ± β E) (n : β) (x : Ξ±) :
dist (birkhoffSum f g n (f x)) (birkhoffSum f g n x) = dist (g (f^[n] x)) (g x) := by
simp only [dist_eq_norm, birkhoffSum_apply_sub_birkhoffSum]
theorem dist_birkhoffSum_birkhoffSum_le (f : Ξ± β Ξ±) (g : Ξ± β E) (n : β) (x y : Ξ±) :
dist (birkhoffSum f g n x) (birkhoffSum f g n y) β€
β k β Finset.range n, dist (g (f^[k] x)) (g (f^[k] y)) :=
dist_sum_sum_le _ _ _
variable (π : Type*) [RCLike π] [Module π E] [IsBoundedSMul π E]
theorem dist_birkhoffAverage_birkhoffAverage (f : Ξ± β Ξ±) (g : Ξ± β E) (n : β) (x y : Ξ±) :
dist (birkhoffAverage π f g n x) (birkhoffAverage π f g n y) =
dist (birkhoffSum f g n x) (birkhoffSum f g n y) / n := by
simp [birkhoffAverage, dist_smulβ, div_eq_inv_mul]
theorem dist_birkhoffAverage_birkhoffAverage_le (f : Ξ± β Ξ±) (g : Ξ± β E) (n : β) (x y : Ξ±) :
dist (birkhoffAverage π f g n x) (birkhoffAverage π f g n y) β€
(β k β Finset.range n, dist (g (f^[k] x)) (g (f^[k] y))) / n :=
(dist_birkhoffAverage_birkhoffAverage _ _ _ _ _ _).trans_le <| by
gcongr; apply dist_birkhoffSum_birkhoffSum_le
theorem dist_birkhoffAverage_apply_birkhoffAverage (f : Ξ± β Ξ±) (g : Ξ± β E) (n : β) (x : Ξ±) :
dist (birkhoffAverage π f g n (f x)) (birkhoffAverage π f g n x) =
dist (g (f^[n] x)) (g x) / n := by
simp [dist_birkhoffAverage_birkhoffAverage, dist_birkhoffSum_apply_birkhoffSum]
/-- If a function `g` is bounded along the positive orbit of `x` under `f`,
then the difference between Birkhoff averages of `g`
along the orbit of `f x` and along the orbit of `x`
tends to zero.
See also `tendsto_birkhoffAverage_apply_sub_birkhoffAverage'`. -/
theorem tendsto_birkhoffAverage_apply_sub_birkhoffAverage {f : Ξ± β Ξ±} {g : Ξ± β E} {x : Ξ±}
(h : Bornology.IsBounded (range (g <| f^[Β·] x))) :
Tendsto (fun n β¦ birkhoffAverage π f g n (f x) - birkhoffAverage π f g n x) atTop (π 0) := by
rcases Metric.isBounded_range_iff.1 h with β¨C, hCβ©
have : Tendsto (fun n : β β¦ C / n) atTop (π 0) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
refine squeeze_zero_norm (fun n β¦ ?_) this
rw [β dist_eq_norm, dist_birkhoffAverage_apply_birkhoffAverage]
gcongr
exact hC n 0
/-- If a function `g` is bounded,
then the difference between Birkhoff averages of `g`
along the orbit of `f x` and along the orbit of `x`
tends to zero.
See also `tendsto_birkhoffAverage_apply_sub_birkhoffAverage`. -/
theorem tendsto_birkhoffAverage_apply_sub_birkhoffAverage' {g : Ξ± β E}
(h : Bornology.IsBounded (range g)) (f : Ξ± β Ξ±) (x : Ξ±) :
Tendsto (fun n β¦ birkhoffAverage π f g n (f x) - birkhoffAverage π f g n x) atTop (π 0) :=
tendsto_birkhoffAverage_apply_sub_birkhoffAverage _ <| h.subset <| range_comp_subset_range _ _
end
variable (π : Type*) {X E : Type*}
[PseudoEMetricSpace X] [RCLike π] [NormedAddCommGroup E] [NormedSpace π E]
{f : X β X} {g : X β E} {l : X β E}
/-- If `f` is a non-strictly contracting map (i.e., it is Lipschitz with constant `1`)
and `g` is a uniformly continuous, then the Birkhoff averages of `g` along orbits of `f`
is a uniformly equicontinuous family of functions. -/
| Mathlib/Dynamics/BirkhoffSum/NormedSpace.lean | 106 | 122 | theorem uniformEquicontinuous_birkhoffAverage (hf : LipschitzWith 1 f) (hg : UniformContinuous g) :
UniformEquicontinuous (birkhoffAverage π f g) := by | refine Metric.uniformity_basis_dist_le.uniformEquicontinuous_iff_right.2 fun Ξ΅ hΞ΅ β¦ ?_
rcases (uniformity_basis_edist_le.uniformContinuous_iff Metric.uniformity_basis_dist_le).1 hg Ξ΅ hΞ΅
with β¨Ξ΄, hΞ΄β, hδΡβ©
refine mem_uniformity_edist.2 β¨Ξ΄, hΞ΄β, fun {x y} h n β¦ ?_β©
calc
dist (birkhoffAverage π f g n x) (birkhoffAverage π f g n y)
β€ (β k β Finset.range n, dist (g (f^[k] x)) (g (f^[k] y))) / n :=
dist_birkhoffAverage_birkhoffAverage_le ..
_ β€ (β _k β Finset.range n, Ξ΅) / n := by
gcongr
refine hδΡ _ _ ?_
simpa using (hf.iterate _).edist_le_mul_of_le h.le
_ = n * Ξ΅ / n := by simp
_ β€ Ξ΅ := by
rcases eq_or_ne n 0 with hn | hn <;> field_simp [hn, hΞ΅.le, mul_div_cancel_leftβ] |
/-
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.Comma.Over.Pullback
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Assoc
/-!
# 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
/-- The diagonal morphism `X βΆ Ξ_{X/Y}` for a morphism `f : X βΆ Y`. -/
def diagonal : X βΆ diagonalObj f :=
pullback.lift (π _) (π _) rfl
@[reassoc (attr := simp)]
theorem diagonal_fst : diagonal f β« pullback.fst _ _ = π _ :=
pullback.lift_fst _ _ _
@[reassoc (attr := simp)]
theorem diagonal_snd : diagonal f β« pullback.snd _ _ = π _ :=
pullback.lift_snd _ _ _
instance : IsSplitMono (diagonal f) :=
β¨β¨β¨pullback.fst _ _, diagonal_fst fβ©β©β©
instance : IsSplitEpi (pullback.fst f f) :=
β¨β¨β¨diagonal f, diagonal_fst fβ©β©β©
instance : IsSplitEpi (pullback.snd f f) :=
β¨β¨β¨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
lemma isIso_diagonal_iff : IsIso (diagonal f) β Mono f :=
β¨fun H β¦ β¨fun _ _ e β¦ by rw [β lift_fst _ _ e, (cancel_epi (g := fst f f) (h := snd f f)
(diagonal f)).mp (by simp), lift_snd]β©, fun _ β¦ inferInstanceβ©
/-- The two projections `Ξ_{X/Y} βΆ X` form a kernel pair for `f : X βΆ Y`. -/
theorem diagonal_isKernelPair : IsKernelPair f (pullback.fst f f) (pullback.snd f f) :=
IsPullback.of_hasPullback f f
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 (diagonal f)
(map (iβ β« snd f i) (iβ β« snd f i) f f (iβ β« fst f i) (iβ β« fst f i) 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]
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_snd_fst :
(pullback.snd (diagonal f)
(map (iβ β« snd f i) (iβ β« snd f i) f f (iβ β« fst f i) (iβ β« fst f i) 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]
variable [HasPullback iβ iβ]
/-- The underlying map of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.hom :
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β :=
pullback.lift (pullback.snd _ _ β« pullback.fst _ _) (pullback.snd _ _ β« pullback.snd _ _) (by
ext
Β· simp only [Category.assoc, pullback_diagonal_map_snd_fst_fst,
pullback_diagonal_map_snd_snd_fst]
Β· simp only [Category.assoc, condition])
/-- The underlying inverse of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.inv : pullback iβ iβ βΆ
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.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])
/-- 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 := pullbackDiagonalMapIso.hom f i iβ iβ
inv := pullbackDiagonalMapIso.inv f i iβ iβ
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Diagonal.lean | 158 | 161 | theorem pullbackDiagonalMapIso.hom_fst :
(pullbackDiagonalMapIso f i iβ iβ).hom β« pullback.fst _ _ =
pullback.snd _ _ β« pullback.fst _ _ := by | delta pullbackDiagonalMapIso |
/-
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.MeasureTheory.Function.AEEqFun.DomAct
import Mathlib.MeasureTheory.Function.LpSpace.Indicator
/-!
# Action of `Mα΅α΅α΅` on `Lα΅` spaces
In this file we define action of `Mα΅α΅α΅` on `MeasureTheory.Lp E p ΞΌ`
If `f : Ξ± β E` is a function representing an equivalence class in `Lα΅(Ξ±, E)`, `M` acts on `Ξ±`,
and `c : M`, then `(.mk c : Mα΅α΅α΅) β’ [f]` is represented by the function `a β¦ f (c β’ a)`.
We also prove basic properties of this action.
-/
open MeasureTheory Filter
open scoped ENNReal
namespace DomMulAct
variable {M N Ξ± E : Type*} [MeasurableSpace M] [MeasurableSpace N]
[MeasurableSpace Ξ±] [NormedAddCommGroup E] {ΞΌ : MeasureTheory.Measure Ξ±} {p : ββ₯0β}
section SMul
variable [SMul M Ξ±] [SMulInvariantMeasure M Ξ± ΞΌ] [MeasurableSMul M Ξ±]
@[to_additive]
instance : SMul Mα΅α΅α΅ (Lp E p ΞΌ) where
smul c f := Lp.compMeasurePreserving (mk.symm c β’ Β·) (measurePreserving_smul _ _) f
@[to_additive (attr := simp)]
theorem smul_Lp_val (c : Mα΅α΅α΅) (f : Lp E p ΞΌ) : (c β’ f).1 = c β’ f.1 := rfl
@[to_additive]
theorem smul_Lp_ae_eq (c : Mα΅α΅α΅) (f : Lp E p ΞΌ) : c β’ f =α΅[ΞΌ] (f <| mk.symm c β’ Β·) :=
Lp.coeFn_compMeasurePreserving _ _
@[to_additive]
theorem mk_smul_toLp (c : M) {f : Ξ± β E} (hf : MemLp f p ΞΌ) :
mk c β’ hf.toLp f =
(hf.comp_measurePreserving <| measurePreserving_smul c ΞΌ).toLp (f <| c β’ Β·) :=
rfl
@[to_additive (attr := simp)]
theorem smul_Lp_const [IsFiniteMeasure ΞΌ] (c : Mα΅α΅α΅) (a : E) :
c β’ Lp.const p ΞΌ a = Lp.const p ΞΌ a :=
rfl
@[to_additive]
theorem mk_smul_indicatorConstLp (c : M)
{s : Set Ξ±} (hs : MeasurableSet s) (hΞΌs : ΞΌ s β β) (b : E) :
mk c β’ indicatorConstLp p hs hΞΌs b =
indicatorConstLp p (hs.preimage <| measurable_const_smul c)
(by rwa [SMulInvariantMeasure.measure_preimage_smul c hs]) b :=
rfl
instance [SMul N Ξ±] [SMulCommClass M N Ξ±] [SMulInvariantMeasure N Ξ± ΞΌ] [MeasurableSMul N Ξ±] :
SMulCommClass Mα΅α΅α΅ Nα΅α΅α΅ (Lp E p ΞΌ) :=
Subtype.val_injective.smulCommClass (fun _ _ β¦ rfl) fun _ _ β¦ rfl
instance {π : Type*} [NormedRing π] [Module π E] [IsBoundedSMul π E] :
SMulCommClass Mα΅α΅α΅ π (Lp E p ΞΌ) :=
Subtype.val_injective.smulCommClass (fun _ _ β¦ rfl) fun _ _ β¦ rfl
instance {π : Type*} [NormedRing π] [Module π E] [IsBoundedSMul π E] :
SMulCommClass π Mα΅α΅α΅ (Lp E p ΞΌ) :=
.symm _ _ _
-- We don't have a typeclass for additive versions of the next few lemmas
-- Should we add `AddDistribAddAction` with `to_additive` both from `MulDistribMulAction`
-- and `DistribMulAction`?
@[to_additive]
| Mathlib/MeasureTheory/Function/LpSpace/DomAct/Basic.lean | 78 | 79 | theorem smul_Lp_add (c : Mα΅α΅α΅) : β f g : Lp E p ΞΌ, c β’ (f + g) = c β’ f + c β’ g := by | rintro β¨β¨β©, _β© β¨β¨β©, _β©; rfl |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.Algebra.Algebra.Basic
import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Polynomial.Degree.Lemmas
import Mathlib.Algebra.Polynomial.Eval.Algebra
import Mathlib.Tactic.Abel
/-!
# The Pochhammer polynomials
We define and prove some basic relations about
`ascPochhammer S n : S[X] := X * (X + 1) * ... * (X + n - 1)`
which is also known as the rising factorial and about
`descPochhammer R n : R[X] := X * (X - 1) * ... * (X - n + 1)`
which is also known as the falling factorial. Versions of this definition
that are focused on `Nat` can be found in `Data.Nat.Factorial` as `Nat.ascFactorial` and
`Nat.descFactorial`.
## Implementation
As with many other families of polynomials, even though the coefficients are always in `β` or `β€` ,
we define the polynomial with coefficients in any `[Semiring S]` or `[Ring R]`.
In an integral domain `S`, we show that `ascPochhammer S n` is zero iff
`n` is a sufficiently large non-positive integer.
## TODO
There is lots more in this direction:
* q-factorials, q-binomials, q-Pochhammer.
-/
universe u v
open Polynomial
section Semiring
variable (S : Type u) [Semiring S]
/-- `ascPochhammer S n` is the polynomial `X * (X + 1) * ... * (X + n - 1)`,
with coefficients in the semiring `S`.
-/
noncomputable def ascPochhammer : β β S[X]
| 0 => 1
| n + 1 => X * (ascPochhammer n).comp (X + 1)
@[simp]
theorem ascPochhammer_zero : ascPochhammer S 0 = 1 :=
rfl
@[simp]
theorem ascPochhammer_one : ascPochhammer S 1 = X := by simp [ascPochhammer]
theorem ascPochhammer_succ_left (n : β) :
ascPochhammer S (n + 1) = X * (ascPochhammer S n).comp (X + 1) := by
rw [ascPochhammer]
theorem monic_ascPochhammer (n : β) [Nontrivial S] [NoZeroDivisors S] :
Monic <| ascPochhammer S n := by
induction' n with n hn
Β· simp
Β· have : leadingCoeff (X + 1 : S[X]) = 1 := leadingCoeff_X_add_C 1
rw [ascPochhammer_succ_left, Monic.def, leadingCoeff_mul,
leadingCoeff_comp (ne_zero_of_eq_one <| natDegree_X_add_C 1 : natDegree (X + 1) β 0), hn,
monic_X, one_mul, one_mul, this, one_pow]
section
variable {S} {T : Type v} [Semiring T]
@[simp]
theorem ascPochhammer_map (f : S β+* T) (n : β) :
(ascPochhammer S n).map f = ascPochhammer T n := by
induction n with
| zero => simp
| succ n ih => simp [ih, ascPochhammer_succ_left, map_comp]
theorem ascPochhammer_evalβ (f : S β+* T) (n : β) (t : T) :
(ascPochhammer T n).eval t = (ascPochhammer S n).evalβ f t := by
rw [β ascPochhammer_map f]
exact eval_map f t
theorem ascPochhammer_eval_comp {R : Type*} [CommSemiring R] (n : β) (p : R[X]) [Algebra R S]
(x : S) : ((ascPochhammer S n).comp (p.map (algebraMap R S))).eval x =
(ascPochhammer S n).eval (p.evalβ (algebraMap R S) x) := by
rw [ascPochhammer_evalβ (algebraMap R S), β evalβ_comp', β ascPochhammer_map (algebraMap R S),
β map_comp, eval_map]
end
@[simp, norm_cast]
theorem ascPochhammer_eval_cast (n k : β) :
(((ascPochhammer β n).eval k : β) : S) = ((ascPochhammer S n).eval k : S) := by
rw [β ascPochhammer_map (algebraMap β S), eval_map, β eq_natCast (algebraMap β S),
evalβ_at_natCast,Nat.cast_id]
theorem ascPochhammer_eval_zero {n : β} : (ascPochhammer S n).eval 0 = if n = 0 then 1 else 0 := by
cases n
Β· simp
Β· simp [X_mul, Nat.succ_ne_zero, ascPochhammer_succ_left]
theorem ascPochhammer_zero_eval_zero : (ascPochhammer S 0).eval 0 = 1 := by simp
@[simp]
| Mathlib/RingTheory/Polynomial/Pochhammer.lean | 110 | 113 | theorem ascPochhammer_ne_zero_eval_zero {n : β} (h : n β 0) : (ascPochhammer S n).eval 0 = 0 := by | simp [ascPochhammer_eval_zero, h]
theorem ascPochhammer_succ_right (n : β) : |
/-
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.Family
import Mathlib.Tactic.Abel
/-!
# Natural operations on ordinals
The goal of this file is to define natural addition and multiplication on ordinals, also known as
the Hessenberg sum and product, and provide a basic API. The natural addition of two ordinals
`a β― b` is recursively defined as the least ordinal greater than `a' β― b` and `a β― b'` for `a' < a`
and `b' < b`. The natural multiplication `a ⨳ b` is likewise recursively defined as the least
ordinal such that `a ⨳ b ⯠a' ⨳ b'` is greater than `a' ⨳ b ⯠a ⨳ b'` for any `a' < a` and
`b' < b`.
These operations form a rich algebraic structure: they're commutative, associative, preserve order,
have the usual `0` and `1` from ordinals, and distribute over one another.
Moreover, these operations are the addition and multiplication of ordinals when viewed as
combinatorial `Game`s. This makes them particularly useful for game theory.
Finally, both operations admit simple, intuitive descriptions in terms of the Cantor normal form.
The natural addition of two ordinals corresponds to adding their Cantor normal forms as if they were
polynomials in `Ο`. Likewise, their natural multiplication corresponds to multiplying the Cantor
normal forms as polynomials.
## Implementation notes
Given the rich algebraic structure of these two operations, we choose to create a type synonym
`NatOrdinal`, where we provide the appropriate instances. However, to avoid casting back and forth
between both types, we attempt to prove and state most results on `Ordinal`.
## Todo
- Prove the characterizations of natural addition and multiplication in terms of the Cantor normal
form.
-/
universe u v
open Function Order Set
noncomputable section
/-! ### Basic casts between `Ordinal` and `NatOrdinal` -/
/-- A type synonym for ordinals with natural addition and multiplication. -/
def NatOrdinal : Type _ :=
Ordinal deriving Zero, Inhabited, One, WellFoundedRelation
-- The `LinearOrder, `SuccOrder` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
instance NatOrdinal.instLinearOrder : LinearOrder NatOrdinal := Ordinal.instLinearOrder
instance NatOrdinal.instSuccOrder : SuccOrder NatOrdinal := Ordinal.instSuccOrder
instance NatOrdinal.instOrderBot : OrderBot NatOrdinal := Ordinal.instOrderBot
instance NatOrdinal.instNoMaxOrder : NoMaxOrder NatOrdinal := Ordinal.instNoMaxOrder
instance NatOrdinal.instZeroLEOneClass : ZeroLEOneClass NatOrdinal := Ordinal.instZeroLEOneClass
instance NatOrdinal.instNeZeroOne : NeZero (1 : NatOrdinal) := Ordinal.instNeZeroOne
instance NatOrdinal.uncountable : Uncountable NatOrdinal :=
Ordinal.uncountable
/-- The identity function between `Ordinal` and `NatOrdinal`. -/
@[match_pattern]
def Ordinal.toNatOrdinal : Ordinal βo NatOrdinal :=
OrderIso.refl _
/-- The identity function between `NatOrdinal` and `Ordinal`. -/
@[match_pattern]
def NatOrdinal.toOrdinal : NatOrdinal βo Ordinal :=
OrderIso.refl _
namespace NatOrdinal
open Ordinal
@[simp]
theorem toOrdinal_symm_eq : NatOrdinal.toOrdinal.symm = Ordinal.toNatOrdinal :=
rfl
@[simp]
theorem toOrdinal_toNatOrdinal (a : NatOrdinal) : a.toOrdinal.toNatOrdinal = a :=
rfl
theorem lt_wf : @WellFounded NatOrdinal (Β· < Β·) :=
Ordinal.lt_wf
instance : WellFoundedLT NatOrdinal :=
Ordinal.wellFoundedLT
instance : ConditionallyCompleteLinearOrderBot NatOrdinal :=
WellFoundedLT.conditionallyCompleteLinearOrderBot _
@[simp] theorem bot_eq_zero : (β₯ : NatOrdinal) = 0 := rfl
@[simp] theorem toOrdinal_zero : toOrdinal 0 = 0 := rfl
@[simp] theorem toOrdinal_one : toOrdinal 1 = 1 := rfl
@[simp] theorem toOrdinal_eq_zero {a} : toOrdinal a = 0 β a = 0 := Iff.rfl
@[simp] theorem toOrdinal_eq_one {a} : toOrdinal a = 1 β a = 1 := Iff.rfl
@[simp]
theorem toOrdinal_max (a b : NatOrdinal) : toOrdinal (max a b) = max (toOrdinal a) (toOrdinal b) :=
rfl
@[simp]
theorem toOrdinal_min (a b : NatOrdinal) : toOrdinal (min a b) = min (toOrdinal a) (toOrdinal b) :=
rfl
theorem succ_def (a : NatOrdinal) : succ a = toNatOrdinal (toOrdinal a + 1) :=
rfl
@[simp]
theorem zero_le (o : NatOrdinal) : 0 β€ o :=
Ordinal.zero_le o
theorem not_lt_zero (o : NatOrdinal) : Β¬ o < 0 :=
Ordinal.not_lt_zero o
@[simp]
theorem lt_one_iff_zero {o : NatOrdinal} : o < 1 β o = 0 :=
Ordinal.lt_one_iff_zero
/-- A recursor for `NatOrdinal`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {Ξ² : NatOrdinal β Sort*} (h : β a, Ξ² (toNatOrdinal a)) : β a, Ξ² a := fun a =>
h (toOrdinal a)
/-- `Ordinal.induction` but for `NatOrdinal`. -/
theorem induction {p : NatOrdinal β Prop} : β (i) (_ : β j, (β k, k < j β p k) β p j), p i :=
Ordinal.induction
instance small_Iio (a : NatOrdinal.{u}) : Small.{u} (Set.Iio a) := Ordinal.small_Iio a
instance small_Iic (a : NatOrdinal.{u}) : Small.{u} (Set.Iic a) := Ordinal.small_Iic a
instance small_Ico (a b : NatOrdinal.{u}) : Small.{u} (Set.Ico a b) := Ordinal.small_Ico a b
instance small_Icc (a b : NatOrdinal.{u}) : Small.{u} (Set.Icc a b) := Ordinal.small_Icc a b
instance small_Ioo (a b : NatOrdinal.{u}) : Small.{u} (Set.Ioo a b) := Ordinal.small_Ioo a b
instance small_Ioc (a b : NatOrdinal.{u}) : Small.{u} (Set.Ioc a b) := Ordinal.small_Ioc a b
end NatOrdinal
namespace Ordinal
variable {a b c : Ordinal.{u}}
@[simp] theorem toNatOrdinal_symm_eq : toNatOrdinal.symm = NatOrdinal.toOrdinal := rfl
@[simp] theorem toNatOrdinal_toOrdinal (a : Ordinal) : a.toNatOrdinal.toOrdinal = a := rfl
@[simp] theorem toNatOrdinal_zero : toNatOrdinal 0 = 0 := rfl
@[simp] theorem toNatOrdinal_one : toNatOrdinal 1 = 1 := rfl
@[simp] theorem toNatOrdinal_eq_zero (a) : toNatOrdinal a = 0 β a = 0 := Iff.rfl
@[simp] theorem toNatOrdinal_eq_one (a) : toNatOrdinal a = 1 β a = 1 := Iff.rfl
@[simp]
theorem toNatOrdinal_max (a b : Ordinal) :
toNatOrdinal (max a b) = max (toNatOrdinal a) (toNatOrdinal b) :=
rfl
@[simp]
theorem toNatOrdinal_min (a b : Ordinal) :
toNatOrdinal (min a b) = min (toNatOrdinal a) (toNatOrdinal b) :=
rfl
/-! We place the definitions of `nadd` and `nmul` before actually developing their API, as this
guarantees we only need to open the `NaturalOps` locale once. -/
/-- Natural addition on ordinals `a β― b`, also known as the Hessenberg sum, is recursively defined
as the least ordinal greater than `a' β― b` and `a β― b'` for all `a' < a` and `b' < b`. In contrast
to normal ordinal addition, it is commutative.
Natural addition can equivalently be characterized as the ordinal resulting from adding up
corresponding coefficients in the Cantor normal forms of `a` and `b`. -/
noncomputable def nadd (a b : Ordinal.{u}) : Ordinal.{u} :=
max (β¨ x : Iio a, succ (nadd x.1 b)) (β¨ x : Iio b, succ (nadd a x.1))
termination_by (a, b)
decreasing_by all_goals cases x; decreasing_tactic
@[inherit_doc]
scoped[NaturalOps] infixl:65 " β― " => Ordinal.nadd
open NaturalOps
/-- Natural multiplication on ordinals `a ⨳ b`, also known as the Hessenberg product, is recursively
defined as the least ordinal such that `a ⨳ b ⯠a' ⨳ b'` is greater than `a' ⨳ b ⯠a ⨳ b'` for all
`a' < a` and `b < b'`. In contrast to normal ordinal multiplication, it is commutative and
distributive (over natural addition).
Natural multiplication can equivalently be characterized as the ordinal resulting from multiplying
the Cantor normal forms of `a` and `b` as if they were polynomials in `Ο`. Addition of exponents is
done via natural addition. -/
noncomputable def nmul (a b : Ordinal.{u}) : Ordinal.{u} :=
sInf {c | β a' < a, β b' < b, nmul a' b β― nmul a b' < c β― nmul a' b'}
termination_by (a, b)
@[inherit_doc]
scoped[NaturalOps] infixl:70 " ⨳ " => Ordinal.nmul
/-! ### Natural addition -/
theorem lt_nadd_iff : a < b β― c β (β b' < b, a β€ b' β― c) β¨ β c' < c, a β€ b β― c' := by
rw [nadd]
simp [Ordinal.lt_iSup_iff]
theorem nadd_le_iff : b β― c β€ a β (β b' < b, b' β― c < a) β§ β c' < c, b β― c' < a := by
rw [β not_lt, lt_nadd_iff]
simp
theorem nadd_lt_nadd_left (h : b < c) (a) : a β― b < a β― c :=
lt_nadd_iff.2 (Or.inr β¨b, h, le_rflβ©)
theorem nadd_lt_nadd_right (h : b < c) (a) : b β― a < c β― a :=
lt_nadd_iff.2 (Or.inl β¨b, h, le_rflβ©)
theorem nadd_le_nadd_left (h : b β€ c) (a) : a β― b β€ a β― c := by
rcases lt_or_eq_of_le h with (h | rfl)
Β· exact (nadd_lt_nadd_left h a).le
Β· exact le_rfl
theorem nadd_le_nadd_right (h : b β€ c) (a) : b β― a β€ c β― a := by
rcases lt_or_eq_of_le h with (h | rfl)
Β· exact (nadd_lt_nadd_right h a).le
Β· exact le_rfl
variable (a b)
theorem nadd_comm (a b) : a β― b = b β― a := by
rw [nadd, nadd, max_comm]
congr <;> ext x <;> cases x <;> apply congr_arg _ (nadd_comm _ _)
termination_by (a, b)
@[deprecated "blsub will soon be deprecated" (since := "2024-11-18")]
theorem blsub_nadd_of_mono {f : β c < a β― b, Ordinal.{max u v}}
(hf : β {i j} (hi hj), i β€ j β f i hi β€ f j hj) :
blsub.{u,v} _ f =
max (blsub.{u, v} a fun a' ha' => f (a' β― b) <| nadd_lt_nadd_right ha' b)
(blsub.{u, v} b fun b' hb' => f (a β― b') <| nadd_lt_nadd_left hb' a) := by
apply (blsub_le_iff.2 fun i h => _).antisymm (max_le _ _)
Β· intro i h
rcases lt_nadd_iff.1 h with (β¨a', ha', hiβ© | β¨b', hb', hiβ©)
Β· exact lt_max_of_lt_left ((hf h (nadd_lt_nadd_right ha' b) hi).trans_lt (lt_blsub _ _ ha'))
Β· exact lt_max_of_lt_right ((hf h (nadd_lt_nadd_left hb' a) hi).trans_lt (lt_blsub _ _ hb'))
all_goals
apply blsub_le_of_brange_subset.{u, u, v}
rintro c β¨d, hd, rflβ©
apply mem_brange_self
private theorem iSup_nadd_of_monotone {a b} (f : Ordinal.{u} β Ordinal.{u}) (h : Monotone f) :
β¨ x : Iio (a β― b), f x = max (β¨ a' : Iio a, f (a'.1 β― b)) (β¨ b' : Iio b, f (a β― b'.1)) := by
apply (max_le _ _).antisymm'
Β· rw [Ordinal.iSup_le_iff]
rintro β¨i, hiβ©
obtain β¨x, hx, hiβ© | β¨x, hx, hiβ© := lt_nadd_iff.1 hi
Β· exact le_max_of_le_left ((h hi).trans <| Ordinal.le_iSup (fun x : Iio a β¦ _) β¨x, hxβ©)
Β· exact le_max_of_le_right ((h hi).trans <| Ordinal.le_iSup (fun x : Iio b β¦ _) β¨x, hxβ©)
all_goals
apply csSup_le_csSup' (bddAbove_of_small _)
rintro _ β¨β¨c, hcβ©, rflβ©
refine mem_range_self (β¨_, ?_β© : Iio _)
apply_rules [nadd_lt_nadd_left, nadd_lt_nadd_right]
theorem nadd_assoc (a b c) : a β― b β― c = a β― (b β― c) := by
unfold nadd
rw [iSup_nadd_of_monotone fun a' β¦ succ (a' β― c), iSup_nadd_of_monotone fun b' β¦ succ (a β― b'),
max_assoc]
Β· congr <;> ext x <;> cases x <;> apply congr_arg _ (nadd_assoc _ _ _)
Β· exact succ_mono.comp fun x y h β¦ nadd_le_nadd_left h _
Β· exact succ_mono.comp fun x y h β¦ nadd_le_nadd_right h _
termination_by (a, b, c)
@[simp]
theorem nadd_zero (a : Ordinal) : a β― 0 = a := by
rw [nadd, ciSup_of_empty fun _ : Iio 0 β¦ _, sup_bot_eq]
convert iSup_succ a
rename_i x
cases x
exact nadd_zero _
termination_by a
@[simp]
theorem zero_nadd : 0 β― a = a := by rw [nadd_comm, nadd_zero]
@[simp]
theorem nadd_one (a : Ordinal) : a β― 1 = succ a := by
rw [nadd, ciSup_unique (s := fun _ : Iio 1 β¦ _), Iio_one_default_eq, nadd_zero,
max_eq_right_iff, Ordinal.iSup_le_iff]
rintro β¨i, hiβ©
rwa [nadd_one, succ_le_succ_iff, succ_le_iff]
termination_by a
@[simp]
theorem one_nadd : 1 β― a = succ a := by rw [nadd_comm, nadd_one]
theorem nadd_succ : a β― succ b = succ (a β― b) := by rw [β nadd_one (a β― b), nadd_assoc, nadd_one]
| Mathlib/SetTheory/Ordinal/NaturalOps.lean | 300 | 305 | theorem succ_nadd : succ a β― b = succ (a β― b) := by | rw [β one_nadd (a β― b), β nadd_assoc, one_nadd]
@[simp]
theorem nadd_nat (n : β) : a β― n = a + n := by
induction' n with n hn
Β· simp |
/-
Copyright (c) 2018 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Johannes HΓΆlzl
-/
import Mathlib.MeasureTheory.Integral.Lebesgue.Countable
import Mathlib.MeasureTheory.Measure.Decomposition.Exhaustion
import Mathlib.MeasureTheory.Measure.Prod
/-!
# Measure with a given density with respect to another measure
For a measure `ΞΌ` on `Ξ±` and a function `f : Ξ± β ββ₯0β`, we define a new measure `ΞΌ.withDensity f`.
On a measurable set `s`, that measure has value `β«β» a in s, f a βΞΌ`.
An important result about `withDensity` is the Radon-Nikodym theorem. It states that, given measures
`ΞΌ, Ξ½`, if `HaveLebesgueDecomposition ΞΌ Ξ½` then `ΞΌ` is absolutely continuous with respect to
`Ξ½` if and only if there exists a measurable function `f : Ξ± β ββ₯0β` such that
`ΞΌ = Ξ½.withDensity f`.
See `MeasureTheory.Measure.absolutelyContinuous_iff_withDensity_rnDeriv_eq`.
-/
open Set hiding restrict restrict_apply
open Filter ENNReal NNReal MeasureTheory.Measure
namespace MeasureTheory
variable {Ξ± : Type*} {m0 : MeasurableSpace Ξ±} {ΞΌ : Measure Ξ±}
/-- Given a measure `ΞΌ : Measure Ξ±` and a function `f : Ξ± β ββ₯0β`, `ΞΌ.withDensity f` is the
measure such that for a measurable set `s` we have `ΞΌ.withDensity f s = β«β» a in s, f a βΞΌ`. -/
noncomputable
def Measure.withDensity {m : MeasurableSpace Ξ±} (ΞΌ : Measure Ξ±) (f : Ξ± β ββ₯0β) : Measure Ξ± :=
Measure.ofMeasurable (fun s _ => β«β» a in s, f a βΞΌ) (by simp) fun _ hs hd =>
lintegral_iUnion hs hd _
@[simp]
theorem withDensity_apply (f : Ξ± β ββ₯0β) {s : Set Ξ±} (hs : MeasurableSet s) :
ΞΌ.withDensity f s = β«β» a in s, f a βΞΌ :=
Measure.ofMeasurable_apply s hs
theorem withDensity_apply_le (f : Ξ± β ββ₯0β) (s : Set Ξ±) :
β«β» a in s, f a βΞΌ β€ ΞΌ.withDensity f s := by
let t := toMeasurable (ΞΌ.withDensity f) s
calc
β«β» a in s, f a βΞΌ β€ β«β» a in t, f a βΞΌ :=
lintegral_mono_set (subset_toMeasurable (withDensity ΞΌ f) s)
_ = ΞΌ.withDensity f t :=
(withDensity_apply f (measurableSet_toMeasurable (withDensity ΞΌ f) s)).symm
_ = ΞΌ.withDensity f s := measure_toMeasurable s
/-! In the next theorem, the s-finiteness assumption is necessary. Here is a counterexample
without this assumption. Let `Ξ±` be an uncountable space, let `xβ` be some fixed point, and consider
the Ο-algebra made of those sets which are countable and do not contain `xβ`, and of their
complements. This is the Ο-algebra generated by the sets `{x}` for `x β xβ`. Define a measure equal
to `+β` on nonempty sets. Let `s = {xβ}` and `f` the indicator of `sαΆ`. Then
* `β«β» a in s, f a βΞΌ = 0`. Indeed, consider a simple function `g β€ f`. It vanishes on `s`. Then
`β«β» a in s, g a βΞΌ = 0`. Taking the supremum over `g` gives the claim.
* `ΞΌ.withDensity f s = +β`. Indeed, this is the infimum of `ΞΌ.withDensity f t` over measurable sets
`t` containing `s`. As `s` is not measurable, such a set `t` contains a point `x β xβ`. Then
`ΞΌ.withDensity f t β₯ ΞΌ.withDensity f {x} = β«β» a in {x}, f a βΞΌ = ΞΌ {x} = +β`.
One checks that `ΞΌ.withDensity f = ΞΌ`, while `ΞΌ.restrict s` gives zero mass to sets not
containing `xβ`, and infinite mass to those that contain it. -/
theorem withDensity_apply' [SFinite ΞΌ] (f : Ξ± β ββ₯0β) (s : Set Ξ±) :
ΞΌ.withDensity f s = β«β» a in s, f a βΞΌ := by
apply le_antisymm ?_ (withDensity_apply_le f s)
let t := toMeasurable ΞΌ s
calc
ΞΌ.withDensity f s β€ ΞΌ.withDensity f t := measure_mono (subset_toMeasurable ΞΌ s)
_ = β«β» a in t, f a βΞΌ := withDensity_apply f (measurableSet_toMeasurable ΞΌ s)
_ = β«β» a in s, f a βΞΌ := by congr 1; exact restrict_toMeasurable_of_sFinite s
@[simp]
lemma withDensity_zero_left (f : Ξ± β ββ₯0β) : (0 : Measure Ξ±).withDensity f = 0 := by
ext s hs
rw [withDensity_apply _ hs]
simp
theorem withDensity_congr_ae {f g : Ξ± β ββ₯0β} (h : f =α΅[ΞΌ] g) :
ΞΌ.withDensity f = ΞΌ.withDensity g := by
refine Measure.ext fun s hs => ?_
rw [withDensity_apply _ hs, withDensity_apply _ hs]
exact lintegral_congr_ae (ae_restrict_of_ae h)
lemma withDensity_mono {f g : Ξ± β ββ₯0β} (hfg : f β€α΅[ΞΌ] g) :
ΞΌ.withDensity f β€ ΞΌ.withDensity g := by
refine le_iff.2 fun s hs β¦ ?_
rw [withDensity_apply _ hs, withDensity_apply _ hs]
refine setLIntegral_mono_ae' hs ?_
filter_upwards [hfg] with x h_le using fun _ β¦ h_le
theorem withDensity_add_left {f : Ξ± β ββ₯0β} (hf : Measurable f) (g : Ξ± β ββ₯0β) :
ΞΌ.withDensity (f + g) = ΞΌ.withDensity f + ΞΌ.withDensity g := by
refine Measure.ext fun s hs => ?_
rw [withDensity_apply _ hs, Measure.add_apply, withDensity_apply _ hs, withDensity_apply _ hs,
β lintegral_add_left hf]
simp only [Pi.add_apply]
theorem withDensity_add_right (f : Ξ± β ββ₯0β) {g : Ξ± β ββ₯0β} (hg : Measurable g) :
ΞΌ.withDensity (f + g) = ΞΌ.withDensity f + ΞΌ.withDensity g := by
simpa only [add_comm] using withDensity_add_left hg f
theorem withDensity_add_measure {m : MeasurableSpace Ξ±} (ΞΌ Ξ½ : Measure Ξ±) (f : Ξ± β ββ₯0β) :
(ΞΌ + Ξ½).withDensity f = ΞΌ.withDensity f + Ξ½.withDensity f := by
ext1 s hs
simp only [withDensity_apply f hs, restrict_add, lintegral_add_measure, Measure.add_apply]
theorem withDensity_sum {ΞΉ : Type*} {m : MeasurableSpace Ξ±} (ΞΌ : ΞΉ β Measure Ξ±) (f : Ξ± β ββ₯0β) :
(sum ΞΌ).withDensity f = sum fun n => (ΞΌ n).withDensity f := by
ext1 s hs
simp_rw [sum_apply _ hs, withDensity_apply f hs, restrict_sum ΞΌ hs, lintegral_sum_measure]
theorem withDensity_smul (r : ββ₯0β) {f : Ξ± β ββ₯0β} (hf : Measurable f) :
ΞΌ.withDensity (r β’ f) = r β’ ΞΌ.withDensity f := by
refine Measure.ext fun s hs => ?_
rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
smul_eq_mul, β lintegral_const_mul r hf]
simp only [Pi.smul_apply, smul_eq_mul]
theorem withDensity_smul' (r : ββ₯0β) (f : Ξ± β ββ₯0β) (hr : r β β) :
ΞΌ.withDensity (r β’ f) = r β’ ΞΌ.withDensity f := by
refine Measure.ext fun s hs => ?_
rw [withDensity_apply _ hs, Measure.coe_smul, Pi.smul_apply, withDensity_apply _ hs,
smul_eq_mul, β lintegral_const_mul' r f hr]
simp only [Pi.smul_apply, smul_eq_mul]
theorem withDensity_smul_measure (r : ββ₯0β) (f : Ξ± β ββ₯0β) :
(r β’ ΞΌ).withDensity f = r β’ ΞΌ.withDensity f := by
ext s hs
simp [withDensity_apply, hs]
theorem isFiniteMeasure_withDensity {f : Ξ± β ββ₯0β} (hf : β«β» a, f a βΞΌ β β) :
IsFiniteMeasure (ΞΌ.withDensity f) :=
{ measure_univ_lt_top := by
rwa [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ, lt_top_iff_ne_top] }
theorem withDensity_absolutelyContinuous {m : MeasurableSpace Ξ±} (ΞΌ : Measure Ξ±) (f : Ξ± β ββ₯0β) :
ΞΌ.withDensity f βͺ ΞΌ := by
refine AbsolutelyContinuous.mk fun s hsβ hsβ => ?_
rw [withDensity_apply _ hsβ]
exact setLIntegral_measure_zero _ _ hsβ
@[simp]
theorem withDensity_zero : ΞΌ.withDensity 0 = 0 := by
ext1 s hs
simp [withDensity_apply _ hs]
@[simp]
theorem withDensity_one : ΞΌ.withDensity 1 = ΞΌ := by
ext1 s hs
simp [withDensity_apply _ hs]
@[simp]
theorem withDensity_const (c : ββ₯0β) : ΞΌ.withDensity (fun _ β¦ c) = c β’ ΞΌ := by
ext1 s hs
simp [withDensity_apply _ hs]
theorem withDensity_tsum {ΞΉ : Type*} [Countable ΞΉ] {f : ΞΉ β Ξ± β ββ₯0β} (h : β i, Measurable (f i)) :
ΞΌ.withDensity (β' n, f n) = sum fun n => ΞΌ.withDensity (f n) := by
ext1 s hs
simp_rw [sum_apply _ hs, withDensity_apply _ hs]
change β«β» x in s, (β' n, f n) x βΞΌ = β' i, β«β» x, f i x βΞΌ.restrict s
rw [β lintegral_tsum fun i => (h i).aemeasurable]
exact lintegral_congr fun x => tsum_apply (Pi.summable.2 fun _ => ENNReal.summable)
| Mathlib/MeasureTheory/Measure/WithDensity.lean | 170 | 172 | theorem withDensity_indicator {s : Set Ξ±} (hs : MeasurableSet s) (f : Ξ± β ββ₯0β) :
ΞΌ.withDensity (s.indicator f) = (ΞΌ.restrict s).withDensity f := by | ext1 t ht |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle SΓΆnne, SΓ©bastien GouΓ«zel,
RΓ©my Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Qq
/-! # Power function on `β`
We construct the power functions `x ^ y`, where `x` and `y` are real numbers.
-/
noncomputable section
open Real ComplexConjugate Finset Set
/-
## Definitions
-/
namespace Real
variable {x y z : β}
/-- The real power function `x ^ y`, defined as the real part of the complex power function.
For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for
`y β 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex
determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (Ο y)`. -/
noncomputable def rpow (x y : β) :=
((x : β) ^ (y : β)).re
noncomputable instance : Pow β β := β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x y : β) : rpow x y = x ^ y := rfl
theorem rpow_def (x y : β) : x ^ y = ((x : β) ^ (y : β)).re := rfl
theorem rpow_def_of_nonneg {x : β} (hx : 0 β€ x) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by
simp only [rpow_def, Complex.cpow_def]; split_ifs <;>
simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul,
(Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero]
theorem rpow_def_of_pos {x : β} (hx : 0 < x) (y : β) : x ^ y = exp (log x * y) := by
rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
theorem exp_mul (x y : β) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp]
@[simp, norm_cast]
theorem rpow_intCast (x : β) (n : β€) : x ^ (n : β) = x ^ n := by
simp only [rpow_def, β Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast,
Complex.ofReal_re]
@[simp, norm_cast]
theorem rpow_natCast (x : β) (n : β) : x ^ (n : β) = x ^ n := by simpa using rpow_intCast x n
@[simp]
theorem exp_one_rpow (x : β) : exp 1 ^ x = exp x := by rw [β exp_mul, one_mul]
@[simp] lemma exp_one_pow (n : β) : exp 1 ^ n = exp n := by rw [β rpow_natCast, exp_one_rpow]
theorem rpow_eq_zero_iff_of_nonneg (hx : 0 β€ x) : x ^ y = 0 β x = 0 β§ y β 0 := by
simp only [rpow_def_of_nonneg hx]
split_ifs <;> simp [*, exp_ne_zero]
@[simp]
lemma rpow_eq_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y = 0 β x = 0 := by
simp [rpow_eq_zero_iff_of_nonneg, *]
@[simp]
lemma rpow_ne_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y β 0 β x β 0 :=
Real.rpow_eq_zero hx hy |>.not
open Real
theorem rpow_def_of_neg {x : β} (hx : x < 0) (y : β) : x ^ y = exp (log x * y) * cos (y * Ο) := by
rw [rpow_def, Complex.cpow_def, if_neg]
Β· have : Complex.log x * y = β(log (-x) * y) + β(y * Ο) * Complex.I := by
simp only [Complex.log, Complex.norm_real, norm_eq_abs, abs_of_neg hx, log_neg_eq_log,
Complex.arg_ofReal_of_neg hx, Complex.ofReal_mul]
ring
rw [this, Complex.exp_add_mul_I, β Complex.ofReal_exp, β Complex.ofReal_cos, β
Complex.ofReal_sin, mul_add, β Complex.ofReal_mul, β mul_assoc, β Complex.ofReal_mul,
Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im,
Real.log_neg_eq_log]
ring
Β· rw [Complex.ofReal_eq_zero]
exact ne_of_lt hx
theorem rpow_def_of_nonpos {x : β} (hx : x β€ 0) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * Ο) := by
split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
@[bound]
theorem rpow_pos_of_pos {x : β} (hx : 0 < x) (y : β) : 0 < x ^ y := by
rw [rpow_def_of_pos hx]; apply exp_pos
@[simp]
theorem rpow_zero (x : β) : x ^ (0 : β) = 1 := by simp [rpow_def]
theorem rpow_zero_pos (x : β) : 0 < x ^ (0 : β) := by simp
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : β) ^ x = 0 := by simp [rpow_def, *]
theorem zero_rpow_eq_iff {x : β} {a : β} : 0 ^ x = a β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
constructor
Β· intro hyp
simp only [rpow_def, Complex.ofReal_zero] at hyp
by_cases h : x = 0
Β· subst h
simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp
exact Or.inr β¨rfl, hyp.symmβ©
Β· rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp
exact Or.inl β¨h, hyp.symmβ©
Β· rintro (β¨h, rflβ© | β¨rfl, rflβ©)
Β· exact zero_rpow h
Β· exact rpow_zero _
theorem eq_zero_rpow_iff {x : β} {a : β} : a = 0 ^ x β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
rw [β zero_rpow_eq_iff, eq_comm]
@[simp]
theorem rpow_one (x : β) : x ^ (1 : β) = x := by simp [rpow_def]
@[simp]
theorem one_rpow (x : β) : (1 : β) ^ x = 1 := by simp [rpow_def]
| Mathlib/Analysis/SpecialFunctions/Pow/Real.lean | 131 | 131 | theorem zero_rpow_le_one (x : β) : (0 : β) ^ x β€ 1 := by | |
/-
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, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Polynomial.Reverse
import Mathlib.Algebra.Regular.SMul
/-!
# 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
theorem not_monic_zero_iff : Β¬Monic (0 : R[X]) β (0 : R) β 1 :=
(monic_zero_iff_subsingleton.trans subsingleton_iff_zero_eq_one.symm).not
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β©
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
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
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)]
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]
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]
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]
theorem monic_X_pow_add {n : β} (H : degree p < n) : Monic (X ^ n + p) :=
monic_of_degree_le n
(le_trans (degree_add_le _ _) (max_le (degree_X_pow_le _) (le_of_lt H)))
(by rw [coeff_add, coeff_X_pow, if_pos rfl, coeff_eq_zero_of_degree_lt H, add_zero])
variable (a) in
theorem monic_X_pow_add_C {n : β} (h : n β 0) : (X ^ n + C a).Monic :=
monic_X_pow_add <| (lt_of_le_of_lt degree_C_le
(by simp only [Nat.cast_pos, Nat.pos_iff_ne_zero, ne_eq, h, not_false_eq_true]))
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
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]
theorem Monic.pow (hp : Monic p) : β n : β, Monic (p ^ n)
| 0 => monic_one
| n + 1 => by
rw [pow_succ]
exact (Monic.pow hp n).mul hp
theorem Monic.add_of_left (hp : Monic p) (hpq : degree q < degree p) : Monic (p + q) := by
rwa [Monic, add_comm, leadingCoeff_add_of_degree_lt hpq]
theorem Monic.add_of_right (hq : Monic q) (hpq : degree p < degree q) : Monic (p + q) := by
rwa [Monic, leadingCoeff_add_of_degree_lt hpq]
theorem Monic.of_mul_monic_left (hp : p.Monic) (hpq : (p * q).Monic) : q.Monic := by
contrapose! hpq
rw [Monic.def] at hpq β’
rwa [leadingCoeff_monic_mul hp]
theorem Monic.of_mul_monic_right (hq : q.Monic) (hpq : (p * q).Monic) : p.Monic := by
contrapose! hpq
rw [Monic.def] at hpq β’
rwa [leadingCoeff_mul_monic hq]
namespace Monic
lemma comp (hp : p.Monic) (hq : q.Monic) (h : q.natDegree β 0) : (p.comp q).Monic := by
nontriviality R
have : (p.comp q).natDegree = p.natDegree * q.natDegree :=
natDegree_comp_eq_of_mul_ne_zero <| by simp [hp.leadingCoeff, hq.leadingCoeff]
rw [Monic.def, Polynomial.leadingCoeff, this, coeff_comp_degree_mul_degree h, hp.leadingCoeff,
hq.leadingCoeff, one_pow, mul_one]
lemma comp_X_add_C (hp : p.Monic) (r : R) : (p.comp (X + C r)).Monic := by
nontriviality R
refine hp.comp (monic_X_add_C _) fun ha β¦ ?_
rw [natDegree_X_add_C] at ha
exact one_ne_zero ha
@[simp]
theorem natDegree_eq_zero_iff_eq_one (hp : p.Monic) : p.natDegree = 0 β p = 1 := by
constructor <;> intro h
swap
Β· rw [h]
exact natDegree_one
have : p = C (p.coeff 0) := by
rw [β Polynomial.degree_le_zero_iff]
rwa [Polynomial.natDegree_eq_zero_iff_degree_le_zero] at h
rw [this]
rw [β h, β Polynomial.leadingCoeff, Monic.def.1 hp, C_1]
@[simp]
theorem degree_le_zero_iff_eq_one (hp : p.Monic) : p.degree β€ 0 β p = 1 := by
rw [β hp.natDegree_eq_zero_iff_eq_one, natDegree_eq_zero_iff_degree_le_zero]
theorem natDegree_mul (hp : p.Monic) (hq : q.Monic) :
(p * q).natDegree = p.natDegree + q.natDegree := by
nontriviality R
apply natDegree_mul'
simp [hp.leadingCoeff, hq.leadingCoeff]
theorem degree_mul_comm (hp : p.Monic) (q : R[X]) : (p * q).degree = (q * p).degree := by
by_cases h : q = 0
Β· simp [h]
rw [degree_mul', hp.degree_mul]
Β· exact add_comm _ _
Β· rwa [hp.leadingCoeff, one_mul, leadingCoeff_ne_zero]
nonrec theorem natDegree_mul' (hp : p.Monic) (hq : q β 0) :
(p * q).natDegree = p.natDegree + q.natDegree := by
rw [natDegree_mul']
simpa [hp.leadingCoeff, leadingCoeff_ne_zero]
theorem natDegree_mul_comm (hp : p.Monic) (q : R[X]) : (p * q).natDegree = (q * p).natDegree := by
by_cases h : q = 0
Β· simp [h]
rw [hp.natDegree_mul' h, Polynomial.natDegree_mul', add_comm]
simpa [hp.leadingCoeff, leadingCoeff_ne_zero]
theorem not_dvd_of_natDegree_lt (hp : Monic p) (h0 : q β 0) (hl : natDegree q < natDegree p) :
Β¬p β£ q := by
rintro β¨r, rflβ©
rw [hp.natDegree_mul' <| right_ne_zero_of_mul h0] at hl
exact hl.not_le (Nat.le_add_right _ _)
theorem not_dvd_of_degree_lt (hp : Monic p) (h0 : q β 0) (hl : degree q < degree p) : Β¬p β£ q :=
Monic.not_dvd_of_natDegree_lt hp h0 <| natDegree_lt_natDegree h0 hl
theorem nextCoeff_mul (hp : Monic p) (hq : Monic q) :
nextCoeff (p * q) = nextCoeff p + nextCoeff q := by
nontriviality
simp only [β coeff_one_reverse]
rw [reverse_mul] <;> simp [hp.leadingCoeff, hq.leadingCoeff, mul_coeff_one, add_comm]
theorem nextCoeff_pow (hp : p.Monic) (n : β) : (p ^ n).nextCoeff = n β’ p.nextCoeff := by
induction n with
| zero => rw [pow_zero, zero_smul, β map_one (f := C), nextCoeff_C_eq_zero]
| succ n ih => rw [pow_succ, (hp.pow n).nextCoeff_mul hp, ih, succ_nsmul]
theorem eq_one_of_map_eq_one {S : Type*} [Semiring S] [Nontrivial S] (f : R β+* S) (hp : p.Monic)
(map_eq : p.map f = 1) : p = 1 := by
nontriviality R
have hdeg : p.degree = 0 := by
rw [β degree_map_eq_of_leadingCoeff_ne_zero f _, map_eq, degree_one]
Β· rw [hp.leadingCoeff, f.map_one]
exact one_ne_zero
have hndeg : p.natDegree = 0 :=
WithBot.coe_eq_coe.mp ((degree_eq_natDegree hp.ne_zero).symm.trans hdeg)
convert eq_C_of_degree_eq_zero hdeg
rw [β hndeg, β Polynomial.leadingCoeff, hp.leadingCoeff, C.map_one]
theorem natDegree_pow (hp : p.Monic) (n : β) : (p ^ n).natDegree = n * p.natDegree := by
induction n with
| zero => simp
| succ n hn => rw [pow_succ, (hp.pow n).natDegree_mul hp, hn, Nat.succ_mul, add_comm]
end Monic
@[simp]
theorem natDegree_pow_X_add_C [Nontrivial R] (n : β) (r : R) : ((X + C r) ^ n).natDegree = n := by
rw [(monic_X_add_C r).natDegree_pow, natDegree_X_add_C, mul_one]
theorem Monic.eq_one_of_isUnit (hm : Monic p) (hpu : IsUnit p) : p = 1 := by
nontriviality R
obtain β¨q, hβ© := hpu.exists_right_inv
have := hm.natDegree_mul' (right_ne_zero_of_mul_eq_one h)
rw [h, natDegree_one, eq_comm, add_eq_zero] at this
exact hm.natDegree_eq_zero_iff_eq_one.mp this.1
theorem Monic.isUnit_iff (hm : p.Monic) : IsUnit p β p = 1 :=
β¨hm.eq_one_of_isUnit, fun h => h.symm βΈ isUnit_oneβ©
theorem eq_of_monic_of_associated (hp : p.Monic) (hq : q.Monic) (hpq : Associated p q) : p = q := by
obtain β¨u, rflβ© := hpq
rw [(hp.of_mul_monic_left hq).eq_one_of_isUnit u.isUnit, mul_one]
end Semiring
section CommSemiring
variable [CommSemiring R] {p : R[X]}
theorem monic_multiset_prod_of_monic (t : Multiset ΞΉ) (f : ΞΉ β R[X]) (ht : β i β t, Monic (f i)) :
Monic (t.map f).prod := by
revert ht
refine t.induction_on ?_ ?_; Β· simp
intro a t ih ht
rw [Multiset.map_cons, Multiset.prod_cons]
exact (ht _ (Multiset.mem_cons_self _ _)).mul (ih fun _ hi => ht _ (Multiset.mem_cons_of_mem hi))
theorem monic_prod_of_monic (s : Finset ΞΉ) (f : ΞΉ β R[X]) (hs : β i β s, Monic (f i)) :
Monic (β i β s, f i) :=
monic_multiset_prod_of_monic s.1 f hs
theorem monic_finprod_of_monic (Ξ± : Type*) (f : Ξ± β R[X])
(hf : β i β Function.mulSupport f, Monic (f i)) :
Monic (finprod f) := by
classical
rw [finprod_def]
split_ifs
Β· exact monic_prod_of_monic _ _ fun a ha => hf a ((Set.Finite.mem_toFinset _).mp ha)
Β· exact monic_one
theorem Monic.nextCoeff_multiset_prod (t : Multiset ΞΉ) (f : ΞΉ β R[X]) (h : β i β t, Monic (f i)) :
nextCoeff (t.map f).prod = (t.map fun i => nextCoeff (f i)).sum := by
revert h
refine Multiset.induction_on t ?_ fun a t ih ht => ?_
Β· simp only [Multiset.not_mem_zero, forall_prop_of_true, forall_prop_of_false, Multiset.map_zero,
Multiset.prod_zero, Multiset.sum_zero, not_false_iff, forall_true_iff]
rw [β C_1]
rw [nextCoeff_C_eq_zero]
Β· rw [Multiset.map_cons, Multiset.prod_cons, Multiset.map_cons, Multiset.sum_cons,
Monic.nextCoeff_mul, ih]
exacts [fun i hi => ht i (Multiset.mem_cons_of_mem hi), ht a (Multiset.mem_cons_self _ _),
monic_multiset_prod_of_monic _ _ fun b bs => ht _ (Multiset.mem_cons_of_mem bs)]
theorem Monic.nextCoeff_prod (s : Finset ΞΉ) (f : ΞΉ β R[X]) (h : β i β s, Monic (f i)) :
nextCoeff (β i β s, f i) = β i β s, nextCoeff (f i) :=
Monic.nextCoeff_multiset_prod s.1 f h
variable [NoZeroDivisors R] {p q : R[X]}
lemma irreducible_of_monic (hp : p.Monic) (hp1 : p β 1) :
Irreducible p β β f g : R[X], f.Monic β g.Monic β f * g = p β f = 1 β¨ g = 1 := by
refine
β¨fun h f g hf hg hp => (h.2 hp.symm).imp hf.eq_one_of_isUnit hg.eq_one_of_isUnit, fun h =>
β¨hp1 β hp.eq_one_of_isUnit, fun f g hfg =>
(h (g * C f.leadingCoeff) (f * C g.leadingCoeff) ?_ ?_ ?_).symm.imp
(isUnit_of_mul_eq_one f _)
(isUnit_of_mul_eq_one g _)β©β©
Β· rwa [Monic, leadingCoeff_mul, leadingCoeff_C, β leadingCoeff_mul, mul_comm, β hfg, β Monic]
Β· rwa [Monic, leadingCoeff_mul, leadingCoeff_C, β leadingCoeff_mul, β hfg, β Monic]
Β· rw [mul_mul_mul_comm, β C_mul, β leadingCoeff_mul, β hfg, hp.leadingCoeff, C_1, mul_one,
mul_comm, β hfg]
lemma Monic.irreducible_iff_natDegree (hp : p.Monic) :
Irreducible p β
p β 1 β§ β f g : R[X], f.Monic β g.Monic β f * g = p β f.natDegree = 0 β¨ g.natDegree = 0 := by
by_cases hp1 : p = 1; Β· simp [hp1]
rw [irreducible_of_monic hp hp1, and_iff_right hp1]
refine forallβ_congr fun a b ha hb => ?_
rw [ha.natDegree_eq_zero_iff_eq_one, hb.natDegree_eq_zero_iff_eq_one]
lemma Monic.irreducible_iff_natDegree' (hp : p.Monic) : Irreducible p β p β 1 β§
β f g : R[X], f.Monic β g.Monic β f * g = p β g.natDegree β Ioc 0 (p.natDegree / 2) := by
simp_rw [hp.irreducible_iff_natDegree, mem_Ioc, Nat.le_div_iff_mul_le zero_lt_two, mul_two]
apply and_congr_right'
constructor <;> intro h f g hf hg he <;> subst he
Β· rw [hf.natDegree_mul hg, add_le_add_iff_right]
exact fun ha => (h f g hf hg rfl).elim (ha.1.trans_le ha.2).ne' ha.1.ne'
Β· simp_rw [hf.natDegree_mul hg, pos_iff_ne_zero] at h
contrapose! h
obtain hl | hl := le_total f.natDegree g.natDegree
Β· exact β¨g, f, hg, hf, mul_comm g f, h.1, add_le_add_left hl _β©
Β· exact β¨f, g, hf, hg, rfl, h.2, add_le_add_right hl _β©
/-- Alternate phrasing of `Polynomial.Monic.irreducible_iff_natDegree'` where we only have to check
one divisor at a time. -/
lemma Monic.irreducible_iff_lt_natDegree_lt {p : R[X]} (hp : p.Monic) (hp1 : p β 1) :
Irreducible p β β q, Monic q β natDegree q β Finset.Ioc 0 (natDegree p / 2) β Β¬ q β£ p := by
rw [hp.irreducible_iff_natDegree', and_iff_right hp1]
constructor
Β· rintro h g hg hdg β¨f, rflβ©
exact h f g (hg.of_mul_monic_left hp) hg (mul_comm f g) hdg
Β· rintro h f g - hg rfl hdg
exact h g hg hdg (dvd_mul_left g f)
lemma Monic.not_irreducible_iff_exists_add_mul_eq_coeff (hm : p.Monic) (hnd : p.natDegree = 2) :
Β¬Irreducible p β β cβ cβ, p.coeff 0 = cβ * cβ β§ p.coeff 1 = cβ + cβ := by
cases subsingleton_or_nontrivial R
Β· simp [natDegree_of_subsingleton] at hnd
rw [hm.irreducible_iff_natDegree', and_iff_right, hnd]
Β· push_neg
constructor
Β· rintro β¨a, b, ha, hb, rfl, hdbβ©
simp only [zero_lt_two, Nat.div_self, Nat.Ioc_succ_singleton, zero_add, mem_singleton] at hdb
have hda := hnd
rw [ha.natDegree_mul hb, hdb] at hda
use a.coeff 0, b.coeff 0, mul_coeff_zero a b
simpa only [nextCoeff, hnd, add_right_cancel hda, hdb] using ha.nextCoeff_mul hb
Β· rintro β¨cβ, cβ, hmul, haddβ©
refine
β¨X + C cβ, X + C cβ, monic_X_add_C _, monic_X_add_C _, ?_, ?_β©
Β· rw [p.as_sum_range_C_mul_X_pow, hnd, Finset.sum_range_succ, Finset.sum_range_succ,
Finset.sum_range_one, β hnd, hm.coeff_natDegree, hnd, hmul, hadd, C_mul, C_add, C_1]
ring
Β· rw [mem_Ioc, natDegree_X_add_C _]
simp
Β· rintro rfl
simp [natDegree_one] at hnd
end CommSemiring
section Semiring
variable [Semiring R]
@[simp]
theorem Monic.natDegree_map [Semiring S] [Nontrivial S] {P : R[X]} (hmo : P.Monic) (f : R β+* S) :
(P.map f).natDegree = P.natDegree := by
refine le_antisymm natDegree_map_le (le_natDegree_of_ne_zero ?_)
rw [coeff_map, Monic.coeff_natDegree hmo, RingHom.map_one]
exact one_ne_zero
@[simp]
theorem Monic.degree_map [Semiring S] [Nontrivial S] {P : R[X]} (hmo : P.Monic) (f : R β+* S) :
(P.map f).degree = P.degree := by
by_cases hP : P = 0
Β· simp [hP]
Β· refine le_antisymm degree_map_le ?_
rw [degree_eq_natDegree hP]
refine le_degree_of_ne_zero ?_
rw [coeff_map, Monic.coeff_natDegree hmo, RingHom.map_one]
exact one_ne_zero
section Injective
open Function
variable [Semiring S] {f : R β+* S}
theorem degree_map_eq_of_injective (hf : Injective f) (p : R[X]) : degree (p.map f) = degree p :=
letI := Classical.decEq R
if h : p = 0 then by simp [h]
else
degree_map_eq_of_leadingCoeff_ne_zero _
(by rw [β f.map_zero]; exact mt hf.eq_iff.1 (mt leadingCoeff_eq_zero.1 h))
theorem natDegree_map_eq_of_injective (hf : Injective f) (p : R[X]) :
natDegree (p.map f) = natDegree p :=
natDegree_eq_of_degree_eq (degree_map_eq_of_injective hf p)
theorem leadingCoeff_map' (hf : Injective f) (p : R[X]) :
leadingCoeff (p.map f) = f (leadingCoeff p) := by
unfold leadingCoeff
rw [coeff_map, natDegree_map_eq_of_injective hf p]
| Mathlib/Algebra/Polynomial/Monic.lean | 405 | 411 | theorem nextCoeff_map (hf : Injective f) (p : R[X]) : (p.map f).nextCoeff = f p.nextCoeff := by | unfold nextCoeff
rw [natDegree_map_eq_of_injective hf]
split_ifs <;> simp [*]
theorem leadingCoeff_of_injective (hf : Injective f) (p : R[X]) :
leadingCoeff (p.map f) = f (leadingCoeff p) := by |
/-
Copyright (c) 2023 Josha Dekker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Josha Dekker
-/
import Mathlib.Topology.Bases
import Mathlib.Order.Filter.CountableInter
import Mathlib.Topology.Compactness.SigmaCompact
/-!
# LindelΓΆf sets and LindelΓΆf spaces
## Main definitions
We define the following properties for sets in a topological space:
* `IsLindelof s`: Two definitions are possible here. The more standard definition is that
every open cover that contains `s` contains a countable subcover. We choose for the equivalent
definition where we require that every nontrivial filter on `s` with the countable intersection
property has a clusterpoint. Equivalence is established in `isLindelof_iff_countable_subcover`.
* `LindelofSpace X`: `X` is LindelΓΆf if it is LindelΓΆf as a set.
* `NonLindelofSpace`: a space that is not a LindΓ«lof space, e.g. the Long Line.
## Main results
* `isLindelof_iff_countable_subcover`: A set is LindelΓΆf iff every open cover has a
countable subcover.
## Implementation details
* This API is mainly based on the API for IsCompact and follows notation and style as much
as possible.
-/
open Set Filter Topology TopologicalSpace
universe u v
variable {X : Type u} {Y : Type v} {ΞΉ : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X}
section Lindelof
/-- A set `s` is LindelΓΆf if every nontrivial filter `f` with the countable intersection
property that contains `s`, has a clusterpoint in `s`. The filter-free definition is given by
`isLindelof_iff_countable_subcover`. -/
def IsLindelof (s : Set X) :=
β β¦fβ¦ [NeBot f] [CountableInterFilter f], f β€ π s β β x β s, ClusterPt x f
/-- The complement to a LindelΓΆf set belongs to a filter `f` with the countable intersection
property if it belongs to each filter `π x β f`, `x β s`. -/
theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f]
(hf : β x β s, sαΆ β π x β f) : sαΆ β f := by
contrapose! hf
simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf β’
exact hs inf_le_right
/-- The complement to a LindelΓΆf set belongs to a filter `f` with the countable intersection
property if each `x β s` has a neighborhood `t` within `s` such that `tαΆ` belongs to `f`. -/
theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X}
[CountableInterFilter f] (hf : β x β s, β t β π[s] x, tαΆ β f) : sαΆ β f := by
refine hs.compl_mem_sets fun x hx β¦ ?_
rw [β disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left]
exact hf x hx
/-- If `p : Set X β Prop` is stable under restriction and union, and each point `x`
of a LindelΓΆf set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/
@[elab_as_elim]
theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X β Prop}
(hmono : β β¦s tβ¦, s β t β p t β p s)
(hcountable_union : β (S : Set (Set X)), S.Countable β (β s β S, p s) β p (ββ S))
(hnhds : β x β s, β t β π[s] x, p t) : p s := by
let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub β¦ hmono hsub ht)
have : sαΆ β f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds)
rwa [β compl_compl s]
/-- The intersection of a LindelΓΆf set and a closed set is a LindelΓΆf set. -/
theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s β© t) := by
intro f hnf _ hstf
rw [β inf_principal, le_inf_iff] at hstf
obtain β¨x, hsx, hxβ© : β x β s, ClusterPt x f := hs hstf.1
have hxt : x β t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2
exact β¨x, β¨hsx, hxtβ©, hxβ©
/-- The intersection of a closed set and a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.inter_left (ht : IsLindelof t) (hs : IsClosed s) : IsLindelof (s β© t) :=
inter_comm t s βΈ ht.inter_right hs
/-- The set difference of a LindelΓΆf set and an open set is a LindelΓΆf set. -/
theorem IsLindelof.diff (hs : IsLindelof s) (ht : IsOpen t) : IsLindelof (s \ t) :=
hs.inter_right (isClosed_compl_iff.mpr ht)
/-- A closed subset of a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.of_isClosed_subset (hs : IsLindelof s) (ht : IsClosed t) (h : t β s) :
IsLindelof t := inter_eq_self_of_subset_right h βΈ hs.inter_right ht
/-- A continuous image of a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.image_of_continuousOn {f : X β Y} (hs : IsLindelof s) (hf : ContinuousOn f s) :
IsLindelof (f '' s) := by
intro l lne _ ls
have : NeBot (l.comap f β π s) :=
comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls)
obtain β¨x, hxs, hxβ© : β x β s, ClusterPt x (l.comap f β π s) := @hs _ this _ inf_le_right
haveI := hx.neBot
use f x, mem_image_of_mem f hxs
have : Tendsto f (π x β (comap f l β π s)) (π (f x) β l) := by
convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1
rw [nhdsWithin]
ac_rfl
exact this.neBot
/-- A continuous image of a LindelΓΆf set is a LindelΓΆf set within the codomain. -/
theorem IsLindelof.image {f : X β Y} (hs : IsLindelof s) (hf : Continuous f) :
IsLindelof (f '' s) := hs.image_of_continuousOn hf.continuousOn
/-- A filter with the countable intersection property that is finer than the principal filter on
a LindelΓΆf set `s` contains any open set that contains all clusterpoints of `s`. -/
theorem IsLindelof.adherence_nhdset {f : Filter X} [CountableInterFilter f] (hs : IsLindelof s)
(hfβ : f β€ π s) (htβ : IsOpen t) (htβ : β x β s, ClusterPt x f β x β t) : t β f :=
(eq_or_neBot _).casesOn mem_of_eq_bot fun _ β¦
let β¨x, hx, hfxβ© := @hs (f β π tαΆ) _ _ <| inf_le_of_left_le hfβ
have : x β t := htβ x hx hfx.of_inf_left
have : tαΆ β© t β π[tαΆ] x := inter_mem_nhdsWithin _ (htβ.mem_nhds this)
have A : π[tαΆ] x = β₯ := empty_mem_iff_bot.1 <| compl_inter_self t βΈ this
have : π[tαΆ] x β β₯ := hfx.of_inf_right.ne
absurd A this
/-- For every open cover of a LindelΓΆf set, there exists a countable subcover. -/
theorem IsLindelof.elim_countable_subcover {ΞΉ : Type v} (hs : IsLindelof s) (U : ΞΉ β Set X)
(hUo : β i, IsOpen (U i)) (hsU : s β β i, U i) :
β r : Set ΞΉ, r.Countable β§ (s β β i β r, U i) := by
have hmono : β β¦s t : Set Xβ¦, s β t β (β r : Set ΞΉ, r.Countable β§ t β β i β r, U i)
β (β r : Set ΞΉ, r.Countable β§ s β β i β r, U i) := by
intro _ _ hst β¨r, β¨hrcountable, hsubβ©β©
exact β¨r, hrcountable, Subset.trans hst hsubβ©
have hcountable_union : β (S : Set (Set X)), S.Countable
β (β s β S, β r : Set ΞΉ, r.Countable β§ (s β β i β r, U i))
β β r : Set ΞΉ, r.Countable β§ (ββ S β β i β r, U i) := by
intro S hS hsr
choose! r hr using hsr
refine β¨β s β S, r s, hS.biUnion_iff.mpr (fun s hs β¦ (hr s hs).1), ?_β©
refine sUnion_subset ?h.right.h
simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and']
exact fun i is x hx β¦ mem_biUnion is ((hr i is).2 hx)
have h_nhds : β x β s, β t β π[s] x, β r : Set ΞΉ, r.Countable β§ (t β β i β r, U i) := by
intro x hx
let β¨i, hiβ© := mem_iUnion.1 (hsU hx)
refine β¨U i, mem_nhdsWithin_of_mem_nhds ((hUo i).mem_nhds hi), {i}, by simp, ?_β©
simp only [mem_singleton_iff, iUnion_iUnion_eq_left]
exact Subset.refl _
exact hs.induction_on hmono hcountable_union h_nhds
theorem IsLindelof.elim_nhds_subcover' (hs : IsLindelof s) (U : β x β s, Set X)
(hU : β x (hx : x β s), U x βΉx β sβΊ β π x) :
β t : Set s, t.Countable β§ s β β x β t, U (x : s) x.2 := by
have := hs.elim_countable_subcover (fun x : s β¦ interior (U x x.2)) (fun _ β¦ isOpen_interior)
fun x hx β¦
mem_iUnion.2 β¨β¨x, hxβ©, mem_interior_iff_mem_nhds.2 <| hU _ _β©
rcases this with β¨r, β¨hr, hsβ©β©
use r, hr
apply Subset.trans hs
apply iUnionβ_subset
intro i hi
apply Subset.trans interior_subset
exact subset_iUnion_of_subset i (subset_iUnion_of_subset hi (Subset.refl _))
theorem IsLindelof.elim_nhds_subcover (hs : IsLindelof s) (U : X β Set X)
(hU : β x β s, U x β π x) :
β t : Set X, t.Countable β§ (β x β t, x β s) β§ s β β x β t, U x := by
let β¨t, β¨htc, htsubβ©β© := hs.elim_nhds_subcover' (fun x _ β¦ U x) hU
refine β¨βt, Countable.image htc Subtype.val, ?_β©
constructor
Β· intro _
simp only [mem_image, Subtype.exists, exists_and_right, exists_eq_right, forall_exists_index]
tauto
Β· have : β x β t, U βx = β x β Subtype.val '' t, U x := biUnion_image.symm
rwa [β this]
/-- For every nonempty open cover of a LindelΓΆf set, there exists a subcover indexed by β. -/
theorem IsLindelof.indexed_countable_subcover {ΞΉ : Type v} [Nonempty ΞΉ]
(hs : IsLindelof s) (U : ΞΉ β Set X) (hUo : β i, IsOpen (U i)) (hsU : s β β i, U i) :
β f : β β ΞΉ, s β β n, U (f n) := by
obtain β¨c, β¨c_count, c_covβ©β© := hs.elim_countable_subcover U hUo hsU
rcases c.eq_empty_or_nonempty with rfl | c_nonempty
Β· simp only [mem_empty_iff_false, iUnion_of_empty, iUnion_empty] at c_cov
simp only [subset_eq_empty c_cov rfl, empty_subset, exists_const]
obtain β¨f, f_surjβ© := (Set.countable_iff_exists_surjective c_nonempty).mp c_count
refine β¨fun x β¦ f x, c_cov.trans <| iUnionβ_subset_iff.mpr (?_ : β i β c, U i β β n, U (f n))β©
intro x hx
obtain β¨n, hnβ© := f_surj β¨x, hxβ©
exact subset_iUnion_of_subset n <| subset_of_eq (by rw [hn])
/-- The neighborhood filter of a LindelΓΆf set is disjoint with a filter `l` with the countable
intersection property if and only if the neighborhood filter of each point of this set
is disjoint with `l`. -/
theorem IsLindelof.disjoint_nhdsSet_left {l : Filter X} [CountableInterFilter l]
(hs : IsLindelof s) :
Disjoint (πΛ’ s) l β β x β s, Disjoint (π x) l := by
refine β¨fun h x hx β¦ h.mono_left <| nhds_le_nhdsSet hx, fun H β¦ ?_β©
choose! U hxU hUl using fun x hx β¦ (nhds_basis_opens x).disjoint_iff_left.1 (H x hx)
choose hxU hUo using hxU
rcases hs.elim_nhds_subcover U fun x hx β¦ (hUo x hx).mem_nhds (hxU x hx) with β¨t, htc, hts, hstβ©
refine (hasBasis_nhdsSet _).disjoint_iff_left.2
β¨β x β t, U x, β¨isOpen_biUnion fun x hx β¦ hUo x (hts x hx), hstβ©, ?_β©
rw [compl_iUnionβ]
exact (countable_bInter_mem htc).mpr (fun i hi β¦ hUl _ (hts _ hi))
/-- A filter `l` with the countable intersection property is disjoint with the neighborhood
filter of a LindelΓΆf set if and only if it is disjoint with the neighborhood filter of each point
of this set. -/
theorem IsLindelof.disjoint_nhdsSet_right {l : Filter X} [CountableInterFilter l]
(hs : IsLindelof s) : Disjoint l (πΛ’ s) β β x β s, Disjoint l (π x) := by
simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left
/-- For every family of closed sets whose intersection avoids a LindelΓΆ set,
there exists a countable subfamily whose intersection avoids this LindelΓΆf set. -/
theorem IsLindelof.elim_countable_subfamily_closed {ΞΉ : Type v} (hs : IsLindelof s)
(t : ΞΉ β Set X) (htc : β i, IsClosed (t i)) (hst : (s β© β i, t i) = β
) :
β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i) = β
:= by
let U := tαΆ
have hUo : β i, IsOpen (U i) := by simp only [U, Pi.compl_apply, isOpen_compl_iff]; exact htc
have hsU : s β β i, U i := by
simp only [U, Pi.compl_apply]
rw [β compl_iInter]
apply disjoint_compl_left_iff_subset.mp
simp only [compl_iInter, compl_iUnion, compl_compl]
apply Disjoint.symm
exact disjoint_iff_inter_eq_empty.mpr hst
rcases hs.elim_countable_subcover U hUo hsU with β¨u, β¨hucount, husubβ©β©
use u, hucount
rw [β disjoint_compl_left_iff_subset] at husub
simp only [U, Pi.compl_apply, compl_iUnion, compl_compl] at husub
exact disjoint_iff_inter_eq_empty.mp (Disjoint.symm husub)
/-- To show that a LindelΓΆf set intersects the intersection of a family of closed sets,
it is sufficient to show that it intersects every countable subfamily. -/
theorem IsLindelof.inter_iInter_nonempty {ΞΉ : Type v} (hs : IsLindelof s) (t : ΞΉ β Set X)
(htc : β i, IsClosed (t i)) (hst : β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i).Nonempty) :
(s β© β i, t i).Nonempty := by
contrapose! hst
rcases hs.elim_countable_subfamily_closed t htc hst with β¨u, β¨_, husubβ©β©
exact β¨u, fun _ β¦ husubβ©
/-- For every open cover of a LindelΓΆf set, there exists a countable subcover. -/
theorem IsLindelof.elim_countable_subcover_image {b : Set ΞΉ} {c : ΞΉ β Set X} (hs : IsLindelof s)
(hcβ : β i β b, IsOpen (c i)) (hcβ : s β β i β b, c i) :
β b', b' β b β§ Set.Countable b' β§ s β β i β b', c i := by
simp only [Subtype.forall', biUnion_eq_iUnion] at hcβ hcβ
rcases hs.elim_countable_subcover (fun i β¦ c i : b β Set X) hcβ hcβ with β¨d, hdβ©
refine β¨Subtype.val '' d, by simp, Countable.image hd.1 Subtype.val, ?_β©
rw [biUnion_image]
exact hd.2
/-- A set `s` is LindelΓΆf if for every open cover of `s`, there exists a countable subcover. -/
theorem isLindelof_of_countable_subcover
(h : β {ΞΉ : Type u} (U : ΞΉ β Set X), (β i, IsOpen (U i)) β (s β β i, U i) β
β t : Set ΞΉ, t.Countable β§ s β β i β t, U i) :
IsLindelof s := fun f hf hfs β¦ by
contrapose! h
simp only [ClusterPt, not_neBot, β disjoint_iff, SetCoe.forall',
(nhds_basis_opens _).disjoint_iff_left] at h
choose fsub U hU hUf using h
refine β¨s, U, fun x β¦ (hU x).2, fun x hx β¦ mem_iUnion.2 β¨β¨x, hxβ©, (hU _).1 β©, ?_β©
intro t ht h
have uinf := f.sets_of_superset (le_principal_iff.1 fsub) h
have uninf : β i β t, (U i)αΆ β f := (countable_bInter_mem ht).mpr (fun _ _ β¦ hUf _)
rw [β compl_iUnionβ] at uninf
have uninf := compl_not_mem uninf
simp only [compl_compl] at uninf
contradiction
/-- A set `s` is LindelΓΆf if for every family of closed sets whose intersection avoids `s`,
there exists a countable subfamily whose intersection avoids `s`. -/
theorem isLindelof_of_countable_subfamily_closed
(h :
β {ΞΉ : Type u} (t : ΞΉ β Set X), (β i, IsClosed (t i)) β (s β© β i, t i) = β
β
β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i) = β
) :
IsLindelof s :=
isLindelof_of_countable_subcover fun U hUo hsU β¦ by
rw [β disjoint_compl_right_iff_subset, compl_iUnion, disjoint_iff] at hsU
rcases h (fun i β¦ (U i)αΆ) (fun i β¦ (hUo _).isClosed_compl) hsU with β¨t, htβ©
refine β¨t, ?_β©
rwa [β disjoint_compl_right_iff_subset, compl_iUnionβ, disjoint_iff]
/-- A set `s` is LindelΓΆf if and only if
for every open cover of `s`, there exists a countable subcover. -/
theorem isLindelof_iff_countable_subcover :
IsLindelof s β β {ΞΉ : Type u} (U : ΞΉ β Set X),
(β i, IsOpen (U i)) β (s β β i, U i) β β t : Set ΞΉ, t.Countable β§ s β β i β t, U i :=
β¨fun hs β¦ hs.elim_countable_subcover, isLindelof_of_countable_subcoverβ©
/-- A set `s` is LindelΓΆf if and only if
for every family of closed sets whose intersection avoids `s`,
there exists a countable subfamily whose intersection avoids `s`. -/
theorem isLindelof_iff_countable_subfamily_closed :
IsLindelof s β β {ΞΉ : Type u} (t : ΞΉ β Set X),
(β i, IsClosed (t i)) β (s β© β i, t i) = β
β β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i) = β
:=
β¨fun hs β¦ hs.elim_countable_subfamily_closed, isLindelof_of_countable_subfamily_closedβ©
/-- The empty set is a Lindelof set. -/
@[simp]
theorem isLindelof_empty : IsLindelof (β
: Set X) := fun _f hnf _ hsf β¦
Not.elim hnf.ne <| empty_mem_iff_bot.1 <| le_principal_iff.1 hsf
/-- A singleton set is a Lindelof set. -/
@[simp]
theorem isLindelof_singleton {x : X} : IsLindelof ({x} : Set X) := fun _ hf _ hfa β¦
β¨x, rfl, ClusterPt.of_le_nhds'
(hfa.trans <| by simpa only [principal_singleton] using pure_le_nhds x) hfβ©
theorem Set.Subsingleton.isLindelof (hs : s.Subsingleton) : IsLindelof s :=
Subsingleton.induction_on hs isLindelof_empty fun _ β¦ isLindelof_singleton
theorem Set.Countable.isLindelof_biUnion {s : Set ΞΉ} {f : ΞΉ β Set X} (hs : s.Countable)
(hf : β i β s, IsLindelof (f i)) : IsLindelof (β i β s, f i) := by
apply isLindelof_of_countable_subcover
intro i U hU hUcover
have hiU : β i β s, f i β β i, U i :=
fun _ is β¦ _root_.subset_trans (subset_biUnion_of_mem is) hUcover
have iSets := fun i is β¦ (hf i is).elim_countable_subcover U hU (hiU i is)
choose! r hr using iSets
use β i β s, r i
constructor
Β· refine (Countable.biUnion_iff hs).mpr ?h.left.a
exact fun s hs β¦ (hr s hs).1
Β· refine iUnionβ_subset ?h.right.h
intro i is
simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and']
intro x hx
exact mem_biUnion is ((hr i is).2 hx)
theorem Set.Finite.isLindelof_biUnion {s : Set ΞΉ} {f : ΞΉ β Set X} (hs : s.Finite)
(hf : β i β s, IsLindelof (f i)) : IsLindelof (β i β s, f i) :=
Set.Countable.isLindelof_biUnion (countable hs) hf
theorem Finset.isLindelof_biUnion (s : Finset ΞΉ) {f : ΞΉ β Set X} (hf : β i β s, IsLindelof (f i)) :
IsLindelof (β i β s, f i) :=
s.finite_toSet.isLindelof_biUnion hf
theorem isLindelof_accumulate {K : β β Set X} (hK : β n, IsLindelof (K n)) (n : β) :
IsLindelof (Accumulate K n) :=
(finite_le_nat n).isLindelof_biUnion fun k _ => hK k
theorem Set.Countable.isLindelof_sUnion {S : Set (Set X)} (hf : S.Countable)
(hc : β s β S, IsLindelof s) : IsLindelof (ββ S) := by
rw [sUnion_eq_biUnion]; exact hf.isLindelof_biUnion hc
theorem Set.Finite.isLindelof_sUnion {S : Set (Set X)} (hf : S.Finite)
(hc : β s β S, IsLindelof s) : IsLindelof (ββ S) := by
rw [sUnion_eq_biUnion]; exact hf.isLindelof_biUnion hc
theorem isLindelof_iUnion {ΞΉ : Sort*} {f : ΞΉ β Set X} [Countable ΞΉ] (h : β i, IsLindelof (f i)) :
IsLindelof (β i, f i) := (countable_range f).isLindelof_sUnion <| forall_mem_range.2 h
theorem Set.Countable.isLindelof (hs : s.Countable) : IsLindelof s :=
biUnion_of_singleton s βΈ hs.isLindelof_biUnion fun _ _ => isLindelof_singleton
theorem Set.Finite.isLindelof (hs : s.Finite) : IsLindelof s :=
biUnion_of_singleton s βΈ hs.isLindelof_biUnion fun _ _ => isLindelof_singleton
| Mathlib/Topology/Compactness/Lindelof.lean | 364 | 369 | theorem IsLindelof.countable_of_discrete [DiscreteTopology X] (hs : IsLindelof s) :
s.Countable := by | have : β x : X, ({x} : Set X) β π x := by simp [nhds_discrete]
rcases hs.elim_nhds_subcover (fun x => {x}) fun x _ => this x with β¨t, ht, _, hssubtβ©
rw [biUnion_of_singleton] at hssubt
exact ht.mono hssubt |
/-
Copyright (c) 2020 Bhavik Mehta. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bhavik Mehta
-/
import Mathlib.CategoryTheory.Closed.Cartesian
import Mathlib.CategoryTheory.Limits.Preserves.Shapes.BinaryProducts
import Mathlib.CategoryTheory.Adjunction.FullyFaithful
/-!
# Cartesian closed functors
Define the exponential comparison morphisms for a functor which preserves binary products, and use
them to define a cartesian closed functor: one which (naturally) preserves exponentials.
Define the Frobenius morphism, and show it is an isomorphism iff the exponential comparison is an
isomorphism.
## TODO
Some of the results here are true more generally for closed objects and for closed monoidal
categories, and these could be generalised.
## References
https://ncatlab.org/nlab/show/cartesian+closed+functor
https://ncatlab.org/nlab/show/Frobenius+reciprocity
## Tags
Frobenius reciprocity, cartesian closed functor
-/
noncomputable section
namespace CategoryTheory
open Category CartesianClosed MonoidalCategory ChosenFiniteProducts TwoSquare
universe v u u'
variable {C : Type u} [Category.{v} C]
variable {D : Type u'} [Category.{v} D]
variable [ChosenFiniteProducts C] [ChosenFiniteProducts D]
variable (F : C β₯€ D) {L : D β₯€ C}
/-- The Frobenius morphism for an adjunction `L β£ F` at `A` is given by the morphism
L(FA β¨― B) βΆ LFA β¨― LB βΆ A β¨― LB
natural in `B`, where the first morphism is the product comparison and the latter uses the counit
of the adjunction.
We will show that if `C` and `D` are cartesian closed, then this morphism is an isomorphism for all
`A` iff `F` is a cartesian closed functor, i.e. it preserves exponentials.
-/
def frobeniusMorphism (h : L β£ F) (A : C) : TwoSquare (tensorLeft (F.obj A)) L L (tensorLeft A) :=
prodComparisonNatTrans L (F.obj A) β« whiskerLeft _ ((curriedTensor C).map (h.counit.app _))
/-- If `F` is full and faithful and has a left adjoint `L` which preserves binary products, then the
Frobenius morphism is an isomorphism.
-/
instance frobeniusMorphism_iso_of_preserves_binary_products (h : L β£ F) (A : C)
[Limits.PreservesLimitsOfShape (Discrete Limits.WalkingPair) L] [F.Full] [F.Faithful] :
IsIso (frobeniusMorphism F h A).natTrans :=
suffices β (X : D), IsIso ((frobeniusMorphism F h A).natTrans.app X) from
NatIso.isIso_of_isIso_app _
fun B β¦ by dsimp [frobeniusMorphism]; infer_instance
variable [CartesianClosed C] [CartesianClosed D]
variable [Limits.PreservesLimitsOfShape (Discrete Limits.WalkingPair) F]
/-- The exponential comparison map.
`F` is a cartesian closed functor if this is an iso for all `A`.
-/
def expComparison (A : C) : TwoSquare (exp A) F F (exp (F.obj A)) :=
mateEquiv (exp.adjunction A) (exp.adjunction (F.obj A)) (prodComparisonNatIso F A).inv
theorem expComparison_ev (A B : C) :
F.obj A β ((expComparison F A).natTrans.app B) β« (exp.ev (F.obj A)).app (F.obj B) =
inv (prodComparison F _ _) β« F.map ((exp.ev _).app _) := by
convert mateEquiv_counit _ _ (prodComparisonNatIso F A).inv B using 2
apply IsIso.inv_eq_of_hom_inv_id -- Porting note: was `ext`
simp only [prodComparisonNatTrans_app, prodComparisonNatIso_inv, asIso_inv, NatIso.isIso_inv_app,
IsIso.hom_inv_id]
theorem coev_expComparison (A B : C) :
F.map ((exp.coev A).app B) β« (expComparison F A).natTrans.app (A β B) =
(exp.coev _).app (F.obj B) β« (exp (F.obj A)).map (inv (prodComparison F A B)) := by
convert unit_mateEquiv _ _ (prodComparisonNatIso F A).inv B using 3
apply IsIso.inv_eq_of_hom_inv_id -- Porting note (https://github.com/leanprover-community/mathlib4/issues/11041): was `ext`
dsimp
simp
theorem uncurry_expComparison (A B : C) :
CartesianClosed.uncurry ((expComparison F A).natTrans.app B) =
inv (prodComparison F _ _) β« F.map ((exp.ev _).app _) := by
rw [uncurry_eq, expComparison_ev]
/-- The exponential comparison map is natural in `A`. -/
theorem expComparison_whiskerLeft {A A' : C} (f : A' βΆ A) :
(expComparison F A).whiskerBottom (pre (F.map f)) =
(expComparison F A').whiskerTop (pre f) := by
unfold expComparison pre
have vcomp1 := mateEquiv_conjugateEquiv_vcomp
(exp.adjunction A) (exp.adjunction (F.obj A)) (exp.adjunction (F.obj A'))
((prodComparisonNatIso F A).inv) (((curriedTensor D).map (F.map f)))
have vcomp2 := conjugateEquiv_mateEquiv_vcomp
(exp.adjunction A) (exp.adjunction A') (exp.adjunction (F.obj A'))
(((curriedTensor C).map f)) ((prodComparisonNatIso F A').inv)
rw [β vcomp1, β vcomp2]
unfold TwoSquare.whiskerLeft TwoSquare.whiskerRight
congr 1
apply congr_arg
ext B
simp only [Functor.comp_obj, tensorLeft_obj, prodComparisonNatIso_inv, asIso_inv,
NatTrans.comp_app, whiskerLeft_app, curriedTensor_map_app, NatIso.isIso_inv_app,
whiskerRight_app, IsIso.eq_inv_comp, prodComparisonNatTrans_app]
rw [β prodComparison_inv_natural_whiskerRight F f]
simp
/-- The functor `F` is cartesian closed (ie preserves exponentials) if each natural transformation
`exp_comparison F A` is an isomorphism
-/
class CartesianClosedFunctor : Prop where
comparison_iso : β A, IsIso (expComparison F A).natTrans
attribute [instance] CartesianClosedFunctor.comparison_iso
theorem frobeniusMorphism_mate (h : L β£ F) (A : C) :
conjugateEquiv (h.comp (exp.adjunction A)) ((exp.adjunction (F.obj A)).comp h)
(frobeniusMorphism F h A).natTrans = (expComparison F A).natTrans := by
unfold expComparison frobeniusMorphism
have conjeq := iterated_mateEquiv_conjugateEquiv h h
(exp.adjunction (F.obj A)) (exp.adjunction A)
(prodComparisonNatTrans L (F.obj A) β« whiskerLeft L ((curriedTensor C).map (h.counit.app A)))
rw [β conjeq]
congr 1
apply congr_arg
ext B
unfold mateEquiv
simp only [Functor.comp_obj, tensorLeft_obj, Functor.id_obj, Equiv.coe_fn_mk, whiskerLeft_comp,
whiskerLeft_twice, whiskerRight_comp, assoc, NatTrans.comp_app, whiskerLeft_app,
curriedTensor_obj_obj, whiskerRight_app, prodComparisonNatTrans_app, curriedTensor_map_app,
Functor.comp_map, tensorLeft_map, prodComparisonNatIso_inv, asIso_inv, NatIso.isIso_inv_app]
rw [β F.map_comp, β F.map_comp]
simp only [Functor.map_comp]
apply IsIso.eq_inv_of_inv_hom_id
simp only [assoc, Functor.associator_inv_app, Functor.associator_hom_app, Functor.comp_obj,
curriedTensor_obj_obj, tensorLeft_obj, Functor.map_id, id_comp]
rw [prodComparison_natural_whiskerLeft, prodComparison_natural_whiskerRight_assoc]
slice_lhs 2 3 => rw [β prodComparison_comp]
simp only [assoc]
unfold prodComparison
have Ξ·lemma : (h.unit.app (F.obj A β F.obj B) β«
lift ((L β F).map (fst _ _)) ((L β F).map (snd _ _))) =
(h.unit.app (F.obj A)) β (h.unit.app (F.obj B)) := by
ext <;> simp
slice_lhs 1 2 => rw [Ξ·lemma]
simp only [Functor.id_obj, Functor.comp_obj, assoc, β whisker_exchange, β tensorHom_def']
ext <;> simp
/--
If the exponential comparison transformation (at `A`) is an isomorphism, then the Frobenius morphism
at `A` is an isomorphism.
-/
| Mathlib/CategoryTheory/Closed/Functor.lean | 166 | 168 | theorem frobeniusMorphism_iso_of_expComparison_iso (h : L β£ F) (A : C)
[i : IsIso (expComparison F A).natTrans] : IsIso (frobeniusMorphism F h A).natTrans := by | rw [β frobeniusMorphism_mate F h] at i |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Patrick Stevens
-/
import Mathlib.Algebra.BigOperators.Intervals
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
/-!
# Sums of binomial coefficients
This file includes variants of the binomial theorem and other results on sums of binomial
coefficients. Theorems whose proofs depend on such sums may also go in this file for import
reasons.
-/
open Nat Finset
variable {R : Type*}
namespace Commute
variable [Semiring R] {x y : R}
/-- A version of the **binomial theorem** for commuting elements in noncommutative semirings. -/
theorem add_pow (h : Commute x y) (n : β) :
(x + y) ^ n = β m β range (n + 1), x ^ m * y ^ (n - m) * n.choose m := by
let t : β β β β R := fun n m β¦ x ^ m * y ^ (n - m) * n.choose m
change (x + y) ^ n = β m β range (n + 1), t n m
have h_first : β n, t n 0 = y ^ n := fun n β¦ by
simp only [t, choose_zero_right, pow_zero, cast_one, mul_one, one_mul, tsub_zero]
have h_last : β n, t n n.succ = 0 := fun n β¦ by
simp only [t, choose_succ_self, cast_zero, mul_zero]
have h_middle :
β n i : β, i β range n.succ β (t n.succ i.succ) = x * t n i + y * t n i.succ := by
intro n i h_mem
have h_le : i β€ n := le_of_lt_succ (mem_range.mp h_mem)
dsimp only [t]
rw [choose_succ_succ, cast_add, mul_add]
congr 1
Β· rw [pow_succ' x, succ_sub_succ, mul_assoc, mul_assoc, mul_assoc]
Β· rw [β mul_assoc y, β mul_assoc y, (h.symm.pow_right i.succ).eq]
by_cases h_eq : i = n
Β· rw [h_eq, choose_succ_self, cast_zero, mul_zero, mul_zero]
Β· rw [succ_sub (lt_of_le_of_ne h_le h_eq)]
rw [pow_succ' y, mul_assoc, mul_assoc, mul_assoc, mul_assoc]
induction n with
| zero =>
rw [pow_zero, sum_range_succ, range_zero, sum_empty, zero_add]
dsimp only [t]
rw [pow_zero, pow_zero, choose_self, cast_one, mul_one, mul_one]
| succ n ih =>
rw [sum_range_succ', h_first, sum_congr rfl (h_middle n), sum_add_distrib, add_assoc,
pow_succ' (x + y), ih, add_mul, mul_sum, mul_sum]
congr 1
rw [sum_range_succ', sum_range_succ, h_first, h_last, mul_zero, add_zero, _root_.pow_succ']
/-- A version of `Commute.add_pow` that avoids β-subtraction by summing over the antidiagonal and
also with the binomial coefficient applied via scalar action of β. -/
theorem add_pow' (h : Commute x y) (n : β) :
(x + y) ^ n = β m β antidiagonal n, n.choose m.1 β’ (x ^ m.1 * y ^ m.2) := by
simp_rw [Nat.sum_antidiagonal_eq_sum_range_succ fun m p β¦ n.choose m β’ (x ^ m * y ^ p),
nsmul_eq_mul, cast_comm, h.add_pow]
end Commute
/-- The **binomial theorem** -/
theorem add_pow [CommSemiring R] (x y : R) (n : β) :
(x + y) ^ n = β m β range (n + 1), x ^ m * y ^ (n - m) * n.choose m :=
(Commute.all x y).add_pow n
/-- A special case of the **binomial theorem** -/
theorem sub_pow [CommRing R] (x y : R) (n : β) :
(x - y) ^ n = β m β range (n + 1), (-1) ^ (m + n) * x ^ m * y ^ (n - m) * n.choose m := by
rw [sub_eq_add_neg, add_pow]
congr! 1 with m hm
have : (-1 : R) ^ (n - m) = (-1) ^ (n + m) := by
rw [mem_range] at hm
simp [show n + m = n - m + 2 * m by omega, pow_add]
rw [neg_pow, this]
ring
namespace Nat
/-- The sum of entries in a row of Pascal's triangle -/
theorem sum_range_choose (n : β) : (β m β range (n + 1), n.choose m) = 2 ^ n := by
have := (add_pow 1 1 n).symm
simpa [one_add_one_eq_two] using this
| Mathlib/Data/Nat/Choose/Sum.lean | 94 | 115 | theorem sum_range_choose_halfway (m : β) : (β i β range (m + 1), (2 * m + 1).choose i) = 4 ^ m :=
have : (β i β range (m + 1), (2 * m + 1).choose (2 * m + 1 - i)) =
β i β range (m + 1), (2 * m + 1).choose i :=
sum_congr rfl fun i hi β¦ choose_symm <| by linarith [mem_range.1 hi]
mul_right_injectiveβ two_ne_zero <|
calc
(2 * β i β range (m + 1), (2 * m + 1).choose i) =
(β i β range (m + 1), (2 * m + 1).choose i) +
β i β range (m + 1), (2 * m + 1).choose (2 * m + 1 - i) := by | rw [two_mul, this]
_ = (β i β range (m + 1), (2 * m + 1).choose i) +
β i β Ico (m + 1) (2 * m + 2), (2 * m + 1).choose i := by
rw [range_eq_Ico, sum_Ico_reflect _ _ (by omega)]
congr
omega
_ = β i β range (2 * m + 2), (2 * m + 1).choose i := sum_range_add_sum_Ico _ (by omega)
_ = 2 ^ (2 * m + 1) := sum_range_choose (2 * m + 1)
_ = 2 * 4 ^ m := by rw [pow_succ, pow_mul, mul_comm]; rfl
theorem choose_middle_le_pow (n : β) : (2 * n + 1).choose n β€ 4 ^ n := by
have t : (2 * n + 1).choose n β€ β i β range (n + 1), (2 * n + 1).choose i :=
single_le_sum (fun x _ β¦ by omega) (self_mem_range_succ n)
simpa [sum_range_choose_halfway n] using t |
/-
Copyright (c) 2021 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Eric Rodriguez
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Algebra.Group.ConjFinite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.Subgroup.Center
/-!
# Class Equation
This file establishes the class equation for finite groups.
## Main statements
* `Group.card_center_add_sum_card_noncenter_eq_card`: The **class equation** for finite groups.
The cardinality of a group is equal to the size of its center plus the sum of the size of all its
nontrivial conjugacy classes. Also `Group.nat_card_center_add_sum_card_noncenter_eq_card`.
-/
open MulAction ConjClasses
variable (G : Type*) [Group G]
/-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/
theorem sum_conjClasses_card_eq_card [Fintype <| ConjClasses G] [Fintype G]
[β x : ConjClasses G, Fintype x.carrier] :
β x : ConjClasses G, x.carrier.toFinset.card = Fintype.card G := by
suffices (Ξ£ x : ConjClasses G, x.carrier) β G by simpa using (Fintype.card_congr this)
simpa [carrier_eq_preimage_mk] using Equiv.sigmaFiberEquiv ConjClasses.mk
/-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/
theorem Group.sum_card_conj_classes_eq_card [Finite G] :
βαΆ x : ConjClasses G, x.carrier.ncard = Nat.card G := by
classical
cases nonempty_fintype G
rw [Nat.card_eq_fintype_card, β sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype]
simp [Set.ncard_eq_toFinset_card']
/-- The **class equation** for finite groups. The cardinality of a group is equal to the size
of its center plus the sum of the size of all its nontrivial conjugacy classes. -/
| Mathlib/GroupTheory/ClassEquation.lean | 47 | 70 | theorem Group.nat_card_center_add_sum_card_noncenter_eq_card [Finite G] :
Nat.card (Subgroup.center G) + βαΆ x β noncenter G, Nat.card x.carrier = Nat.card G := by | classical
cases nonempty_fintype G
rw [@Nat.card_eq_fintype_card G, β sum_conjClasses_card_eq_card, β
Finset.sum_sdiff (ConjClasses.noncenter G).toFinset.subset_univ]
simp only [Nat.card_eq_fintype_card, Set.toFinset_card]
congr 1
swap
Β· convert finsum_cond_eq_sum_of_cond_iff _ _
simp [Set.mem_toFinset]
calc
Fintype.card (Subgroup.center G) = Fintype.card ((noncenter G)αΆ : Set _) :=
Fintype.card_congr ((mk_bijOn G).equiv _)
_ = Finset.card (Finset.univ \ (noncenter G).toFinset) := by
rw [β Set.toFinset_card, Set.toFinset_compl, Finset.compl_eq_univ_sdiff]
_ = _ := ?_
rw [Finset.card_eq_sum_ones]
refine Finset.sum_congr rfl ?_
rintro β¨gβ© hg
simp only [noncenter, Set.not_subsingleton_iff, Set.toFinset_setOf, Finset.mem_univ, true_and,
forall_true_left, Finset.mem_sdiff, Finset.mem_filter, Set.not_nontrivial_iff] at hg
rw [eq_comm, β Set.toFinset_card, Finset.card_eq_one]
exact β¨g, Finset.coe_injective <| by simpa using hg.eq_singleton_of_mem mem_carrier_mkβ© |
/-
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, Jeremy Avigad
-/
import Mathlib.Algebra.Group.Basic
import Mathlib.Algebra.Notation.Pi
import Mathlib.Data.Set.Lattice
import Mathlib.Order.Filter.Defs
/-!
# Theory of filters on sets
A *filter* on a type `Ξ±` is a collection of sets of `Ξ±` which contains the whole `Ξ±`,
is upwards-closed, and is stable under intersection. They are mostly used to
abstract two related kinds of ideas:
* *limits*, including finite or infinite limits of sequences, finite or infinite limits of functions
at a point or at infinity, etc...
* *things happening eventually*, including things happening for large enough `n : β`, or near enough
a point `x`, or for close enough pairs of points, or things happening almost everywhere in the
sense of measure theory. Dually, filters can also express the idea of *things happening often*:
for arbitrarily large `n`, or at a point in any neighborhood of given a point etc...
## Main definitions
In this file, we endow `Filter Ξ±` it with a complete lattice structure.
This structure is lifted from the lattice structure on `Set (Set X)` using the Galois
insertion which maps a filter to its elements in one direction, and an arbitrary set of sets to
the smallest filter containing it in the other direction.
We also prove `Filter` is a monadic functor, with a push-forward operation
`Filter.map` and a pull-back operation `Filter.comap` that form a Galois connections for the
order on filters.
The examples of filters appearing in the description of the two motivating ideas are:
* `(Filter.atTop : Filter β)` : made of sets of `β` containing `{n | n β₯ N}` for some `N`
* `π x` : made of neighborhoods of `x` in a topological space (defined in topology.basic)
* `π€ X` : made of entourages of a uniform space (those space are generalizations of metric spaces
defined in `Mathlib/Topology/UniformSpace/Basic.lean`)
* `MeasureTheory.ae` : made of sets whose complement has zero measure with respect to `ΞΌ`
(defined in `Mathlib/MeasureTheory/OuterMeasure/AE`)
The predicate "happening eventually" is `Filter.Eventually`, and "happening often" is
`Filter.Frequently`, whose definitions are immediate after `Filter` is defined (but they come
rather late in this file in order to immediately relate them to the lattice structure).
## Notations
* `βαΆ x in f, p x` : `f.Eventually p`;
* `βαΆ x in f, p x` : `f.Frequently p`;
* `f =αΆ [l] g` : `βαΆ x in l, f x = g x`;
* `f β€αΆ [l] g` : `βαΆ x in l, f x β€ g x`;
* `π s` : `Filter.Principal s`, localized in `Filter`.
## References
* [N. Bourbaki, *General Topology*][bourbaki1966]
Important note: Bourbaki requires that a filter on `X` cannot contain all sets of `X`, which
we do *not* require. This gives `Filter X` better formal properties, in particular a bottom element
`β₯` for its lattice structure, at the cost of including the assumption
`[NeBot f]` in a number of lemmas and definitions.
-/
assert_not_exists OrderedSemiring Fintype
open Function Set Order
open scoped symmDiff
universe u v w x y
namespace Filter
variable {Ξ± : Type u} {f g : Filter Ξ±} {s t : Set Ξ±}
instance inhabitedMem : Inhabited { s : Set Ξ± // s β f } :=
β¨β¨univ, f.univ_setsβ©β©
theorem filter_eq_iff : f = g β f.sets = g.sets :=
β¨congr_arg _, filter_eqβ©
@[simp] theorem sets_subset_sets : f.sets β g.sets β g β€ f := .rfl
@[simp] theorem sets_ssubset_sets : f.sets β g.sets β g < f := .rfl
/-- An extensionality lemma that is useful for filters with good lemmas about `sαΆ β f` (e.g.,
`Filter.comap`, `Filter.coprod`, `Filter.Coprod`, `Filter.cofinite`). -/
protected theorem coext (h : β s, sαΆ β f β sαΆ β g) : f = g :=
Filter.ext <| compl_surjective.forall.2 h
instance : Trans (Β· β Β·) ((Β· β Β·) : Set Ξ± β Filter Ξ± β Prop) (Β· β Β·) where
trans hβ hβ := mem_of_superset hβ hβ
instance : Trans Membership.mem (Β· β Β·) (Membership.mem : Filter Ξ± β Set Ξ± β Prop) where
trans hβ hβ := mem_of_superset hβ hβ
@[simp]
theorem inter_mem_iff {s t : Set Ξ±} : s β© t β f β s β f β§ t β f :=
β¨fun h => β¨mem_of_superset h inter_subset_left, mem_of_superset h inter_subset_rightβ©,
and_imp.2 inter_memβ©
theorem diff_mem {s t : Set Ξ±} (hs : s β f) (ht : tαΆ β f) : s \ t β f :=
inter_mem hs ht
theorem congr_sets (h : { x | x β s β x β t } β f) : s β f β t β f :=
β¨fun hs => mp_mem hs (mem_of_superset h fun _ => Iff.mp), fun hs =>
mp_mem hs (mem_of_superset h fun _ => Iff.mpr)β©
lemma copy_eq {S} (hmem : β s, s β S β s β f) : f.copy S hmem = f := Filter.ext hmem
/-- Weaker version of `Filter.biInter_mem` that assumes `Subsingleton Ξ²` rather than `Finite Ξ²`. -/
theorem biInter_mem' {Ξ² : Type v} {s : Ξ² β Set Ξ±} {is : Set Ξ²} (hf : is.Subsingleton) :
(β i β is, s i) β f β β i β is, s i β f := by
apply Subsingleton.induction_on hf <;> simp
/-- Weaker version of `Filter.iInter_mem` that assumes `Subsingleton Ξ²` rather than `Finite Ξ²`. -/
theorem iInter_mem' {Ξ² : Sort v} {s : Ξ² β Set Ξ±} [Subsingleton Ξ²] :
(β i, s i) β f β β i, s i β f := by
rw [β sInter_range, sInter_eq_biInter, biInter_mem' (subsingleton_range s), forall_mem_range]
theorem exists_mem_subset_iff : (β t β f, t β s) β s β f :=
β¨fun β¨_, ht, tsβ© => mem_of_superset ht ts, fun hs => β¨s, hs, Subset.rflβ©β©
theorem monotone_mem {f : Filter Ξ±} : Monotone fun s => s β f := fun _ _ hst h =>
mem_of_superset h hst
theorem exists_mem_and_iff {P : Set Ξ± β Prop} {Q : Set Ξ± β Prop} (hP : Antitone P)
(hQ : Antitone Q) : ((β u β f, P u) β§ β u β f, Q u) β β u β f, P u β§ Q u := by
constructor
Β· rintro β¨β¨u, huf, hPuβ©, v, hvf, hQvβ©
exact
β¨u β© v, inter_mem huf hvf, hP inter_subset_left hPu, hQ inter_subset_right hQvβ©
Β· rintro β¨u, huf, hPu, hQuβ©
exact β¨β¨u, huf, hPuβ©, u, huf, hQuβ©
theorem forall_in_swap {Ξ² : Type*} {p : Set Ξ± β Ξ² β Prop} :
(β a β f, β (b), p a b) β β (b), β a β f, p a b :=
Set.forall_in_swap
end Filter
namespace Filter
variable {Ξ± : Type u} {Ξ² : Type v} {Ξ³ : Type w} {Ξ΄ : Type*} {ΞΉ : Sort x}
theorem mem_principal_self (s : Set Ξ±) : s β π s := Subset.rfl
section Lattice
variable {f g : Filter Ξ±} {s t : Set Ξ±}
protected theorem not_le : Β¬f β€ g β β s β g, s β f := by simp_rw [le_def, not_forall, exists_prop]
/-- `GenerateSets g s`: `s` is in the filter closure of `g`. -/
inductive GenerateSets (g : Set (Set Ξ±)) : Set Ξ± β Prop
| basic {s : Set Ξ±} : s β g β GenerateSets g s
| univ : GenerateSets g univ
| superset {s t : Set Ξ±} : GenerateSets g s β s β t β GenerateSets g t
| inter {s t : Set Ξ±} : GenerateSets g s β GenerateSets g t β GenerateSets g (s β© t)
/-- `generate g` is the largest filter containing the sets `g`. -/
def generate (g : Set (Set Ξ±)) : Filter Ξ± where
sets := {s | GenerateSets g s}
univ_sets := GenerateSets.univ
sets_of_superset := GenerateSets.superset
inter_sets := GenerateSets.inter
lemma mem_generate_of_mem {s : Set <| Set Ξ±} {U : Set Ξ±} (h : U β s) :
U β generate s := GenerateSets.basic h
theorem le_generate_iff {s : Set (Set Ξ±)} {f : Filter Ξ±} : f β€ generate s β s β f.sets :=
Iff.intro (fun h _ hu => h <| GenerateSets.basic <| hu) fun h _ hu =>
hu.recOn (fun h' => h h') univ_mem (fun _ hxy hx => mem_of_superset hx hxy) fun _ _ hx hy =>
inter_mem hx hy
@[simp] lemma generate_singleton (s : Set Ξ±) : generate {s} = π s :=
le_antisymm (fun _t ht β¦ mem_of_superset (mem_generate_of_mem <| mem_singleton _) ht) <|
le_generate_iff.2 <| singleton_subset_iff.2 Subset.rfl
/-- `mkOfClosure s hs` constructs a filter on `Ξ±` whose elements set is exactly
`s : Set (Set Ξ±)`, provided one gives the assumption `hs : (generate s).sets = s`. -/
protected def mkOfClosure (s : Set (Set Ξ±)) (hs : (generate s).sets = s) : Filter Ξ± where
sets := s
univ_sets := hs βΈ univ_mem
sets_of_superset := hs βΈ mem_of_superset
inter_sets := hs βΈ inter_mem
theorem mkOfClosure_sets {s : Set (Set Ξ±)} {hs : (generate s).sets = s} :
Filter.mkOfClosure s hs = generate s :=
Filter.ext fun u =>
show u β (Filter.mkOfClosure s hs).sets β u β (generate s).sets from hs.symm βΈ Iff.rfl
/-- Galois insertion from sets of sets into filters. -/
def giGenerate (Ξ± : Type*) :
@GaloisInsertion (Set (Set Ξ±)) (Filter Ξ±)α΅α΅ _ _ Filter.generate Filter.sets where
gc _ _ := le_generate_iff
le_l_u _ _ h := GenerateSets.basic h
choice s hs := Filter.mkOfClosure s (le_antisymm hs <| le_generate_iff.1 <| le_rfl)
choice_eq _ _ := mkOfClosure_sets
theorem mem_inf_iff {f g : Filter Ξ±} {s : Set Ξ±} : s β f β g β β tβ β f, β tβ β g, s = tβ β© tβ :=
Iff.rfl
theorem mem_inf_of_left {f g : Filter Ξ±} {s : Set Ξ±} (h : s β f) : s β f β g :=
β¨s, h, univ, univ_mem, (inter_univ s).symmβ©
theorem mem_inf_of_right {f g : Filter Ξ±} {s : Set Ξ±} (h : s β g) : s β f β g :=
β¨univ, univ_mem, s, h, (univ_inter s).symmβ©
theorem inter_mem_inf {Ξ± : Type u} {f g : Filter Ξ±} {s t : Set Ξ±} (hs : s β f) (ht : t β g) :
s β© t β f β g :=
β¨s, hs, t, ht, rflβ©
theorem mem_inf_of_inter {f g : Filter Ξ±} {s t u : Set Ξ±} (hs : s β f) (ht : t β g)
(h : s β© t β u) : u β f β g :=
mem_of_superset (inter_mem_inf hs ht) h
theorem mem_inf_iff_superset {f g : Filter Ξ±} {s : Set Ξ±} :
s β f β g β β tβ β f, β tβ β g, tβ β© tβ β s :=
β¨fun β¨tβ, hβ, tβ, hβ, Eqβ© => β¨tβ, hβ, tβ, hβ, Eq βΈ Subset.rflβ©, fun β¨_, hβ, _, hβ, subβ© =>
mem_inf_of_inter hβ hβ subβ©
section CompleteLattice
/-- Complete lattice structure on `Filter Ξ±`. -/
instance instCompleteLatticeFilter : CompleteLattice (Filter Ξ±) where
inf a b := min a b
sup a b := max a b
le_sup_left _ _ _ h := h.1
le_sup_right _ _ _ h := h.2
sup_le _ _ _ hβ hβ _ h := β¨hβ h, hβ hβ©
inf_le_left _ _ _ := mem_inf_of_left
inf_le_right _ _ _ := mem_inf_of_right
le_inf := fun _ _ _ hβ hβ _s β¨_a, ha, _b, hb, hsβ© => hs.symm βΈ inter_mem (hβ ha) (hβ hb)
le_sSup _ _ hβ _ hβ := hβ hβ
sSup_le _ _ hβ _ hβ _ hβ := hβ _ hβ hβ
sInf_le _ _ hβ _ hβ := by rw [β Filter.sSup_lowerBounds]; exact fun _ hβ β¦ hβ hβ hβ
le_sInf _ _ hβ _ hβ := by rw [β Filter.sSup_lowerBounds] at hβ; exact hβ hβ
le_top _ _ := univ_mem'
bot_le _ _ _ := trivial
instance : Inhabited (Filter Ξ±) := β¨β₯β©
end CompleteLattice
theorem NeBot.ne {f : Filter Ξ±} (hf : NeBot f) : f β β₯ := hf.ne'
@[simp] theorem not_neBot {f : Filter Ξ±} : Β¬f.NeBot β f = β₯ := neBot_iff.not_left
theorem NeBot.mono {f g : Filter Ξ±} (hf : NeBot f) (hg : f β€ g) : NeBot g :=
β¨ne_bot_of_le_ne_bot hf.1 hgβ©
theorem neBot_of_le {f g : Filter Ξ±} [hf : NeBot f] (hg : f β€ g) : NeBot g :=
hf.mono hg
@[simp] theorem sup_neBot {f g : Filter Ξ±} : NeBot (f β g) β NeBot f β¨ NeBot g := by
simp only [neBot_iff, not_and_or, Ne, sup_eq_bot_iff]
theorem not_disjoint_self_iff : Β¬Disjoint f f β f.NeBot := by rw [disjoint_self, neBot_iff]
theorem bot_sets_eq : (β₯ : Filter Ξ±).sets = univ := rfl
/-- Either `f = β₯` or `Filter.NeBot f`. This is a version of `eq_or_ne` that uses `Filter.NeBot`
as the second alternative, to be used as an instance. -/
theorem eq_or_neBot (f : Filter Ξ±) : f = β₯ β¨ NeBot f := (eq_or_ne f β₯).imp_right NeBot.mk
theorem sup_sets_eq {f g : Filter Ξ±} : (f β g).sets = f.sets β© g.sets :=
(giGenerate Ξ±).gc.u_inf
theorem sSup_sets_eq {s : Set (Filter Ξ±)} : (sSup s).sets = β f β s, (f : Filter Ξ±).sets :=
(giGenerate Ξ±).gc.u_sInf
theorem iSup_sets_eq {f : ΞΉ β Filter Ξ±} : (iSup f).sets = β i, (f i).sets :=
(giGenerate Ξ±).gc.u_iInf
theorem generate_empty : Filter.generate β
= (β€ : Filter Ξ±) :=
(giGenerate Ξ±).gc.l_bot
theorem generate_univ : Filter.generate univ = (β₯ : Filter Ξ±) :=
bot_unique fun _ _ => GenerateSets.basic (mem_univ _)
theorem generate_union {s t : Set (Set Ξ±)} :
Filter.generate (s βͺ t) = Filter.generate s β Filter.generate t :=
(giGenerate Ξ±).gc.l_sup
theorem generate_iUnion {s : ΞΉ β Set (Set Ξ±)} :
Filter.generate (β i, s i) = β¨
i, Filter.generate (s i) :=
(giGenerate Ξ±).gc.l_iSup
@[simp]
theorem mem_sup {f g : Filter Ξ±} {s : Set Ξ±} : s β f β g β s β f β§ s β g :=
Iff.rfl
theorem union_mem_sup {f g : Filter Ξ±} {s t : Set Ξ±} (hs : s β f) (ht : t β g) : s βͺ t β f β g :=
β¨mem_of_superset hs subset_union_left, mem_of_superset ht subset_union_rightβ©
@[simp]
theorem mem_iSup {x : Set Ξ±} {f : ΞΉ β Filter Ξ±} : x β iSup f β β i, x β f i := by
simp only [β Filter.mem_sets, iSup_sets_eq, mem_iInter]
@[simp]
theorem iSup_neBot {f : ΞΉ β Filter Ξ±} : (β¨ i, f i).NeBot β β i, (f i).NeBot := by
simp [neBot_iff]
theorem iInf_eq_generate (s : ΞΉ β Filter Ξ±) : iInf s = generate (β i, (s i).sets) :=
eq_of_forall_le_iff fun _ β¦ by simp [le_generate_iff]
theorem mem_iInf_of_mem {f : ΞΉ β Filter Ξ±} (i : ΞΉ) {s} (hs : s β f i) : s β β¨
i, f i :=
iInf_le f i hs
@[simp]
theorem le_principal_iff {s : Set Ξ±} {f : Filter Ξ±} : f β€ π s β s β f :=
β¨fun h => h Subset.rfl, fun hs _ ht => mem_of_superset hs htβ©
theorem Iic_principal (s : Set Ξ±) : Iic (π s) = { l | s β l } :=
Set.ext fun _ => le_principal_iff
theorem principal_mono {s t : Set Ξ±} : π s β€ π t β s β t := by
simp only [le_principal_iff, mem_principal]
@[gcongr] alias β¨_, _root_.GCongr.filter_principal_monoβ© := principal_mono
@[mono]
theorem monotone_principal : Monotone (π : Set Ξ± β Filter Ξ±) := fun _ _ => principal_mono.2
@[simp] theorem principal_eq_iff_eq {s t : Set Ξ±} : π s = π t β s = t := by
simp only [le_antisymm_iff, le_principal_iff, mem_principal]; rfl
@[simp] theorem join_principal_eq_sSup {s : Set (Filter Ξ±)} : join (π s) = sSup s := rfl
@[simp] theorem principal_univ : π (univ : Set Ξ±) = β€ :=
top_unique <| by simp only [le_principal_iff, mem_top, eq_self_iff_true]
@[simp]
theorem principal_empty : π (β
: Set Ξ±) = β₯ :=
bot_unique fun _ _ => empty_subset _
theorem generate_eq_biInf (S : Set (Set Ξ±)) : generate S = β¨
s β S, π s :=
eq_of_forall_le_iff fun f => by simp [le_generate_iff, le_principal_iff, subset_def]
/-! ### Lattice equations -/
theorem empty_mem_iff_bot {f : Filter Ξ±} : β
β f β f = β₯ :=
β¨fun h => bot_unique fun s _ => mem_of_superset h (empty_subset s), fun h => h.symm βΈ mem_botβ©
theorem nonempty_of_mem {f : Filter Ξ±} [hf : NeBot f] {s : Set Ξ±} (hs : s β f) : s.Nonempty :=
s.eq_empty_or_nonempty.elim (fun h => absurd hs (h.symm βΈ mt empty_mem_iff_bot.mp hf.1)) id
theorem NeBot.nonempty_of_mem {f : Filter Ξ±} (hf : NeBot f) {s : Set Ξ±} (hs : s β f) : s.Nonempty :=
@Filter.nonempty_of_mem Ξ± f hf s hs
@[simp]
theorem empty_not_mem (f : Filter Ξ±) [NeBot f] : Β¬β
β f := fun h => (nonempty_of_mem h).ne_empty rfl
theorem nonempty_of_neBot (f : Filter Ξ±) [NeBot f] : Nonempty Ξ± :=
nonempty_of_exists <| nonempty_of_mem (univ_mem : univ β f)
theorem compl_not_mem {f : Filter Ξ±} {s : Set Ξ±} [NeBot f] (h : s β f) : sαΆ β f := fun hsc =>
(nonempty_of_mem (inter_mem h hsc)).ne_empty <| inter_compl_self s
theorem filter_eq_bot_of_isEmpty [IsEmpty Ξ±] (f : Filter Ξ±) : f = β₯ :=
empty_mem_iff_bot.mp <| univ_mem' isEmptyElim
protected lemma disjoint_iff {f g : Filter Ξ±} : Disjoint f g β β s β f, β t β g, Disjoint s t := by
simp only [disjoint_iff, β empty_mem_iff_bot, mem_inf_iff, inf_eq_inter, bot_eq_empty,
@eq_comm _ β
]
theorem disjoint_of_disjoint_of_mem {f g : Filter Ξ±} {s t : Set Ξ±} (h : Disjoint s t) (hs : s β f)
(ht : t β g) : Disjoint f g :=
Filter.disjoint_iff.mpr β¨s, hs, t, ht, hβ©
theorem NeBot.not_disjoint (hf : f.NeBot) (hs : s β f) (ht : t β f) : Β¬Disjoint s t := fun h =>
not_disjoint_self_iff.2 hf <| Filter.disjoint_iff.2 β¨s, hs, t, ht, hβ©
theorem inf_eq_bot_iff {f g : Filter Ξ±} : f β g = β₯ β β U β f, β V β g, U β© V = β
:= by
simp only [β disjoint_iff, Filter.disjoint_iff, Set.disjoint_iff_inter_eq_empty]
/-- There is exactly one filter on an empty type. -/
instance unique [IsEmpty Ξ±] : Unique (Filter Ξ±) where
default := β₯
uniq := filter_eq_bot_of_isEmpty
theorem NeBot.nonempty (f : Filter Ξ±) [hf : f.NeBot] : Nonempty Ξ± :=
not_isEmpty_iff.mp fun _ β¦ hf.ne (Subsingleton.elim _ _)
/-- There are only two filters on a `Subsingleton`: `β₯` and `β€`. If the type is empty, then they are
equal. -/
theorem eq_top_of_neBot [Subsingleton Ξ±] (l : Filter Ξ±) [NeBot l] : l = β€ := by
refine top_unique fun s hs => ?_
obtain rfl : s = univ := Subsingleton.eq_univ_of_nonempty (nonempty_of_mem hs)
exact univ_mem
theorem forall_mem_nonempty_iff_neBot {f : Filter Ξ±} :
(β s : Set Ξ±, s β f β s.Nonempty) β NeBot f :=
β¨fun h => β¨fun hf => not_nonempty_empty (h β
<| hf.symm βΈ mem_bot)β©, @nonempty_of_mem _ _β©
instance instNeBotTop [Nonempty Ξ±] : NeBot (β€ : Filter Ξ±) :=
forall_mem_nonempty_iff_neBot.1 fun s hs => by rwa [mem_top.1 hs, β nonempty_iff_univ_nonempty]
instance instNontrivialFilter [Nonempty Ξ±] : Nontrivial (Filter Ξ±) :=
β¨β¨β€, β₯, instNeBotTop.neβ©β©
theorem nontrivial_iff_nonempty : Nontrivial (Filter Ξ±) β Nonempty Ξ± :=
β¨fun _ =>
by_contra fun h' =>
haveI := not_nonempty_iff.1 h'
not_subsingleton (Filter Ξ±) inferInstance,
@Filter.instNontrivialFilter Ξ±β©
theorem eq_sInf_of_mem_iff_exists_mem {S : Set (Filter Ξ±)} {l : Filter Ξ±}
(h : β {s}, s β l β β f β S, s β f) : l = sInf S :=
le_antisymm (le_sInf fun f hf _ hs => h.2 β¨f, hf, hsβ©)
fun _ hs => let β¨_, hf, hsβ© := h.1 hs; (sInf_le hf) hs
theorem eq_iInf_of_mem_iff_exists_mem {f : ΞΉ β Filter Ξ±} {l : Filter Ξ±}
(h : β {s}, s β l β β i, s β f i) : l = iInf f :=
eq_sInf_of_mem_iff_exists_mem <| h.trans (exists_range_iff (p := (_ β Β·))).symm
theorem eq_biInf_of_mem_iff_exists_mem {f : ΞΉ β Filter Ξ±} {p : ΞΉ β Prop} {l : Filter Ξ±}
(h : β {s}, s β l β β i, p i β§ s β f i) : l = β¨
(i) (_ : p i), f i := by
rw [iInf_subtype']
exact eq_iInf_of_mem_iff_exists_mem fun {_} => by simp only [Subtype.exists, h, exists_prop]
theorem iInf_sets_eq {f : ΞΉ β Filter Ξ±} (h : Directed (Β· β₯ Β·) f) [ne : Nonempty ΞΉ] :
(iInf f).sets = β i, (f i).sets :=
let β¨iβ© := ne
let u :=
{ sets := β i, (f i).sets
univ_sets := mem_iUnion.2 β¨i, univ_memβ©
sets_of_superset := by
simp only [mem_iUnion, exists_imp]
exact fun i hx hxy => β¨i, mem_of_superset hx hxyβ©
inter_sets := by
simp only [mem_iUnion, exists_imp]
intro x y a hx b hy
rcases h a b with β¨c, ha, hbβ©
exact β¨c, inter_mem (ha hx) (hb hy)β© }
have : u = iInf f := eq_iInf_of_mem_iff_exists_mem mem_iUnion
congr_arg Filter.sets this.symm
theorem mem_iInf_of_directed {f : ΞΉ β Filter Ξ±} (h : Directed (Β· β₯ Β·) f) [Nonempty ΞΉ] (s) :
s β iInf f β β i, s β f i := by
simp only [β Filter.mem_sets, iInf_sets_eq h, mem_iUnion]
theorem mem_biInf_of_directed {f : Ξ² β Filter Ξ±} {s : Set Ξ²} (h : DirectedOn (f β»ΒΉ'o (Β· β₯ Β·)) s)
(ne : s.Nonempty) {t : Set Ξ±} : (t β β¨
i β s, f i) β β i β s, t β f i := by
haveI := ne.to_subtype
simp_rw [iInf_subtype', mem_iInf_of_directed h.directed_val, Subtype.exists, exists_prop]
theorem biInf_sets_eq {f : Ξ² β Filter Ξ±} {s : Set Ξ²} (h : DirectedOn (f β»ΒΉ'o (Β· β₯ Β·)) s)
(ne : s.Nonempty) : (β¨
i β s, f i).sets = β i β s, (f i).sets :=
ext fun t => by simp [mem_biInf_of_directed h ne]
@[simp]
theorem sup_join {fβ fβ : Filter (Filter Ξ±)} : join fβ β join fβ = join (fβ β fβ) :=
Filter.ext fun x => by simp only [mem_sup, mem_join]
@[simp]
theorem iSup_join {ΞΉ : Sort w} {f : ΞΉ β Filter (Filter Ξ±)} : β¨ x, join (f x) = join (β¨ x, f x) :=
Filter.ext fun x => by simp only [mem_iSup, mem_join]
instance : DistribLattice (Filter Ξ±) :=
{ Filter.instCompleteLatticeFilter with
le_sup_inf := by
intro x y z s
simp only [and_assoc, mem_inf_iff, mem_sup, exists_prop, exists_imp, and_imp]
rintro hs tβ htβ tβ htβ rfl
exact
β¨tβ, x.sets_of_superset hs inter_subset_left, htβ, tβ,
x.sets_of_superset hs inter_subset_right, htβ, rflβ© }
/-- If `f : ΞΉ β Filter Ξ±` is directed, `ΞΉ` is not empty, and `β i, f i β β₯`, then `iInf f β β₯`.
See also `iInf_neBot_of_directed` for a version assuming `Nonempty Ξ±` instead of `Nonempty ΞΉ`. -/
theorem iInf_neBot_of_directed' {f : ΞΉ β Filter Ξ±} [Nonempty ΞΉ] (hd : Directed (Β· β₯ Β·) f) :
(β i, NeBot (f i)) β NeBot (iInf f) :=
not_imp_not.1 <| by simpa only [not_forall, not_neBot, β empty_mem_iff_bot,
mem_iInf_of_directed hd] using id
/-- If `f : ΞΉ β Filter Ξ±` is directed, `Ξ±` is not empty, and `β i, f i β β₯`, then `iInf f β β₯`.
See also `iInf_neBot_of_directed'` for a version assuming `Nonempty ΞΉ` instead of `Nonempty Ξ±`. -/
| Mathlib/Order/Filter/Basic.lean | 479 | 480 | theorem iInf_neBot_of_directed {f : ΞΉ β Filter Ξ±} [hn : Nonempty Ξ±] (hd : Directed (Β· β₯ Β·) f)
(hb : β i, NeBot (f i)) : NeBot (iInf f) := by | |
/-
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.MeasureTheory.Constructions.BorelSpace.Order
import Mathlib.MeasureTheory.MeasurableSpace.Prod
import Mathlib.MeasureTheory.Measure.Typeclasses.NoAtoms
import Mathlib.Topology.Instances.Real.Lemmas
/-!
# Borel (measurable) spaces β, ββ₯0, ββ₯0β
## Main statements
* `borel_eq_generateFrom_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic):
the Borel sigma algebra on β is generated by intervals with rational endpoints;
* `isPiSystem_Ixx_rat` (where Ixx is one of {Ioo, Ioi, Iio, Ici, Iic):
intervals with rational endpoints form a pi system on β;
* `measurable_real_toNNReal`, `measurable_coe_nnreal_real`, `measurable_coe_nnreal_ennreal`,
`ENNReal.measurable_ofReal`, `ENNReal.measurable_toReal`:
measurability of various coercions between β, ββ₯0, and ββ₯0β;
* `Measurable.real_toNNReal`, `Measurable.coe_nnreal_real`, `Measurable.coe_nnreal_ennreal`,
`Measurable.ennreal_ofReal`, `Measurable.ennreal_toNNReal`, `Measurable.ennreal_toReal`:
measurability of functions composed with various coercions between β, ββ₯0, and ββ₯0β
(also similar results for a.e.-measurability);
* `Measurable.ennreal*` : measurability of special cases for arithmetic operations on `ββ₯0β`.
-/
open Set Filter MeasureTheory MeasurableSpace
open scoped Topology NNReal ENNReal
universe u v w x y
variable {Ξ± Ξ² Ξ³ Ξ΄ : Type*} {ΞΉ : Sort y} {s t u : Set Ξ±}
namespace Real
theorem borel_eq_generateFrom_Ioo_rat :
borel β = .generateFrom (β (a : β) (b : β) (_ : a < b), {Ioo (a : β) (b : β)}) :=
isTopologicalBasis_Ioo_rat.borel_eq_generateFrom
| Mathlib/MeasureTheory/Constructions/BorelSpace/Real.lean | 44 | 54 | theorem borel_eq_generateFrom_Iio_rat : borel β = .generateFrom (β a : β, {Iio (a : β)}) := by | rw [borel_eq_generateFrom_Iio]
refine le_antisymm
(generateFrom_le ?_)
(generateFrom_mono <| iUnion_subset fun q β¦ singleton_subset_iff.mpr <| mem_range_self _)
rintro _ β¨a, rflβ©
have : IsLUB (range ((β) : β β β) β© Iio a) a := by
simp [isLUB_iff_le_iff, mem_upperBounds, β le_iff_forall_rat_lt_imp_le]
rw [β this.biUnion_Iio_eq, β image_univ, β image_inter_preimage, univ_inter, biUnion_image]
exact MeasurableSet.biUnion (to_countable _)
fun b _ => GenerateMeasurable.basic (Iio (b : β)) (by simp) |
/-
Copyright (c) 2024 Ira Fesefeldt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ira Fesefeldt
-/
import Mathlib.SetTheory.Ordinal.Arithmetic
/-!
# Ordinal Approximants for the Fixed points on complete lattices
This file sets up the ordinal-indexed approximation theory of fixed points
of a monotone function in a complete lattice [Cousot1979].
The proof follows loosely the one from [Echenique2005].
However, the proof given here is not constructive as we use the non-constructive axiomatization of
ordinals from mathlib. It still allows an approximation scheme indexed over the ordinals.
## Main definitions
* `OrdinalApprox.lfpApprox`: The ordinal-indexed approximation of the least fixed point
greater or equal than an initial value of a bundled monotone function.
* `OrdinalApprox.gfpApprox`: The ordinal-indexed approximation of the greatest fixed point
less or equal than an initial value of a bundled monotone function.
## Main theorems
* `OrdinalApprox.lfp_mem_range_lfpApprox`: The ordinal-indexed approximation of
the least fixed point eventually reaches the least fixed point
* `OrdinalApprox.gfp_mem_range_gfpApprox`: The ordinal-indexed approximation of
the greatest fixed point eventually reaches the greatest fixed point
## References
* [F. Echenique, *A short and constructive proof of Tarskiβs fixed-point theorem*][Echenique2005]
* [P. Cousot & R. Cousot, *Constructive Versions of Tarski's Fixed Point Theorems*][Cousot1979]
## Tags
fixed point, complete lattice, monotone function, ordinals, approximation
-/
namespace Cardinal
universe u
variable {Ξ± : Type u}
variable (g : Ordinal β Ξ±)
open Cardinal Ordinal SuccOrder Function Set
theorem not_injective_limitation_set : Β¬ InjOn g (Iio (ord <| succ #Ξ±)) := by
intro h_inj
have h := lift_mk_le_lift_mk_of_injective <| injOn_iff_injective.1 h_inj
have mk_initialSeg_subtype :
#(Iio (ord <| succ #Ξ±)) = lift.{u + 1} (succ #Ξ±) := by
simpa only [coe_setOf, card_typein, card_ord] using mk_Iio_ordinal (ord <| succ #Ξ±)
rw [mk_initialSeg_subtype, lift_lift, lift_le] at h
exact not_le_of_lt (Order.lt_succ #Ξ±) h
end Cardinal
namespace OrdinalApprox
universe u
variable {Ξ± : Type u}
variable [CompleteLattice Ξ±] (f : Ξ± βo Ξ±) (x : Ξ±)
open Function fixedPoints Cardinal Order OrderHom
set_option linter.unusedVariables false in
/-- The ordinal-indexed sequence approximating the least fixed point greater than
an initial value `x`. It is defined in such a way that we have `lfpApprox 0 x = x` and
`lfpApprox a x = β¨ b < a, f (lfpApprox b x)`. -/
def lfpApprox (a : Ordinal.{u}) : Ξ± :=
sSup ({ f (lfpApprox b) | (b : Ordinal) (h : b < a) } βͺ {x})
termination_by a
decreasing_by exact h
theorem lfpApprox_monotone : Monotone (lfpApprox f x) := by
intros a b h
rw [lfpApprox, lfpApprox]
refine sSup_le_sSup ?h
apply sup_le_sup_right
simp only [exists_prop, Set.le_eq_subset, Set.setOf_subset_setOf, forall_exists_index, and_imp,
forall_apply_eq_imp_iffβ]
intros a' h'
use a'
exact β¨lt_of_lt_of_le h' h, rflβ©
theorem le_lfpApprox {a : Ordinal} : x β€ lfpApprox f x a := by
rw [lfpApprox]
apply le_sSup
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, true_or]
theorem lfpApprox_add_one (h : x β€ f x) (a : Ordinal) :
lfpApprox f x (a+1) = f (lfpApprox f x a) := by
apply le_antisymm
Β· conv => left; rw [lfpApprox]
apply sSup_le
simp only [Ordinal.add_one_eq_succ, lt_succ_iff, exists_prop, Set.union_singleton,
Set.mem_insert_iff, Set.mem_setOf_eq, forall_eq_or_imp, forall_exists_index, and_imp,
forall_apply_eq_imp_iffβ]
apply And.intro
Β· apply le_trans h
apply Monotone.imp f.monotone
exact le_lfpApprox f x
Β· intros a' h
apply f.2; apply lfpApprox_monotone; exact h
Β· conv => right; rw [lfpApprox]
apply le_sSup
simp only [Ordinal.add_one_eq_succ, lt_succ_iff, exists_prop]
rw [Set.mem_union]
apply Or.inl
simp only [Set.mem_setOf_eq]
use a
theorem lfpApprox_mono_left : Monotone (lfpApprox : (Ξ± βo Ξ±) β _) := by
intro f g h x a
induction a using Ordinal.induction with
| h i ih =>
rw [lfpApprox, lfpApprox]
apply sSup_le
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, sSup_insert,
forall_eq_or_imp, le_sup_left, forall_exists_index, and_imp, forall_apply_eq_imp_iffβ,
true_and]
intro i' h_lt
apply le_sup_of_le_right
apply le_sSup_of_le
Β· use i'
Β· apply le_trans (h _)
simp only [OrderHom.toFun_eq_coe]
exact g.monotone (ih i' h_lt)
theorem lfpApprox_mono_mid : Monotone (lfpApprox f) := by
intro xβ xβ h a
induction a using Ordinal.induction with
| h i ih =>
rw [lfpApprox, lfpApprox]
apply sSup_le
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq, sSup_insert,
forall_eq_or_imp, forall_exists_index, and_imp, forall_apply_eq_imp_iffβ]
constructor
Β· exact le_sup_of_le_left h
Β· intro i' h_i'
apply le_sup_of_le_right
apply le_sSup_of_le
Β· use i'
Β· exact f.monotone (ih i' h_i')
/-- The approximations of the least fixed point stabilize at a fixed point of `f` -/
| Mathlib/SetTheory/Ordinal/FixedPointApproximants.lean | 148 | 161 | theorem lfpApprox_eq_of_mem_fixedPoints {a b : Ordinal} (h_init : x β€ f x) (h_ab : a β€ b)
(h : lfpApprox f x a β fixedPoints f) : lfpApprox f x b = lfpApprox f x a := by | rw [mem_fixedPoints_iff] at h
induction b using Ordinal.induction with | h b IH =>
apply le_antisymm
Β· conv => left; rw [lfpApprox]
apply sSup_le
simp only [exists_prop, Set.union_singleton, Set.mem_insert_iff, Set.mem_setOf_eq,
forall_eq_or_imp, forall_exists_index, and_imp, forall_apply_eq_imp_iffβ]
apply And.intro (le_lfpApprox f x)
intro a' ha'b
by_cases haa : a' < a
Β· rw [β lfpApprox_add_one f x h_init]
apply lfpApprox_monotone |
/-
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.Data.List.Nodup
import Mathlib.Data.List.Lattice
import Batteries.Data.List.Pairwise
/-!
# Erasure of duplicates in a list
This file proves basic results about `List.dedup` (definition in `Data.List.Defs`).
`dedup l` returns `l` without its duplicates. It keeps the earliest (that is, rightmost)
occurrence of each.
## Tags
duplicate, multiplicity, nodup, `nub`
-/
universe u
namespace List
variable {Ξ± Ξ² : Type*} [DecidableEq Ξ±]
@[simp]
theorem dedup_nil : dedup [] = ([] : List Ξ±) :=
rfl
theorem dedup_cons_of_mem' {a : Ξ±} {l : List Ξ±} (h : a β dedup l) : dedup (a :: l) = dedup l :=
pwFilter_cons_of_neg <| by simpa only [forall_mem_ne, not_not] using h
theorem dedup_cons_of_not_mem' {a : Ξ±} {l : List Ξ±} (h : a β dedup l) :
dedup (a :: l) = a :: dedup l :=
pwFilter_cons_of_pos <| by simpa only [forall_mem_ne] using h
@[simp]
theorem mem_dedup {a : Ξ±} {l : List Ξ±} : a β dedup l β a β l := by
have := not_congr (@forall_mem_pwFilter Ξ± (Β· β Β·) _ ?_ a l)
Β· simpa only [dedup, forall_mem_ne, not_not] using this
Β· intros x y z xz
exact not_and_or.1 <| mt (fun h β¦ h.1.trans h.2) xz
@[simp]
theorem dedup_cons_of_mem {a : Ξ±} {l : List Ξ±} (h : a β l) : dedup (a :: l) = dedup l :=
dedup_cons_of_mem' <| mem_dedup.2 h
@[simp]
theorem dedup_cons_of_not_mem {a : Ξ±} {l : List Ξ±} (h : a β l) : dedup (a :: l) = a :: dedup l :=
dedup_cons_of_not_mem' <| mt mem_dedup.1 h
theorem dedup_sublist : β l : List Ξ±, dedup l <+ l :=
pwFilter_sublist
theorem dedup_subset : β l : List Ξ±, dedup l β l :=
pwFilter_subset
theorem subset_dedup (l : List Ξ±) : l β dedup l := fun _ => mem_dedup.2
theorem nodup_dedup : β l : List Ξ±, Nodup (dedup l) :=
pairwise_pwFilter
theorem headI_dedup [Inhabited Ξ±] (l : List Ξ±) :
l.dedup.headI = if l.headI β l.tail then l.tail.dedup.headI else l.headI :=
match l with
| [] => rfl
| a :: l => by by_cases ha : a β l <;> simp [ha, List.dedup_cons_of_mem]
theorem tail_dedup [Inhabited Ξ±] (l : List Ξ±) :
l.dedup.tail = if l.headI β l.tail then l.tail.dedup.tail else l.tail.dedup :=
match l with
| [] => rfl
| a :: l => by by_cases ha : a β l <;> simp [ha, List.dedup_cons_of_mem]
theorem dedup_eq_self {l : List Ξ±} : dedup l = l β Nodup l :=
pwFilter_eq_self
theorem dedup_eq_cons (l : List Ξ±) (a : Ξ±) (l' : List Ξ±) :
l.dedup = a :: l' β a β l β§ a β l' β§ l.dedup.tail = l' := by
refine β¨fun h => ?_, fun h => ?_β©
Β· refine β¨mem_dedup.1 (h.symm βΈ mem_cons_self), fun ha => ?_, by rw [h, tail_cons]β©
have := count_pos_iff.2 ha
have : count a l.dedup β€ 1 := nodup_iff_count_le_one.1 (nodup_dedup l) a
rw [h, count_cons_self] at this
omega
Β· have := @List.cons_head!_tail Ξ± β¨aβ© _ (ne_nil_of_mem (mem_dedup.2 h.1))
have hal : a β l.dedup := mem_dedup.2 h.1
rw [β this, mem_cons, or_iff_not_imp_right] at hal
exact this βΈ h.2.2.symm βΈ cons_eq_cons.2 β¨(hal (h.2.2.symm βΈ h.2.1)).symm, rflβ©
@[simp]
theorem dedup_eq_nil (l : List Ξ±) : l.dedup = [] β l = [] := by
induction l with
| nil => exact Iff.rfl
| cons a l hl =>
by_cases h : a β l
Β· simp only [List.dedup_cons_of_mem h, hl, List.ne_nil_of_mem h, reduceCtorEq]
Β· simp only [List.dedup_cons_of_not_mem h, List.cons_ne_nil]
protected theorem Nodup.dedup {l : List Ξ±} (h : l.Nodup) : l.dedup = l :=
List.dedup_eq_self.2 h
@[simp]
theorem dedup_idem {l : List Ξ±} : dedup (dedup l) = dedup l :=
pwFilter_idem
theorem dedup_append (lβ lβ : List Ξ±) : dedup (lβ ++ lβ) = lβ βͺ dedup lβ := by
induction lβ with | nil => rfl | cons a lβ IH => ?_
simp only [cons_union] at *
rw [β IH, cons_append]
by_cases h : a β dedup (lβ ++ lβ)
Β· rw [dedup_cons_of_mem' h, insert_of_mem h]
Β· rw [dedup_cons_of_not_mem' h, insert_of_not_mem h]
theorem dedup_map_of_injective [DecidableEq Ξ²] {f : Ξ± β Ξ²} (hf : Function.Injective f)
(xs : List Ξ±) :
(xs.map f).dedup = xs.dedup.map f := by
induction xs with
| nil => simp
| cons x xs ih =>
rw [map_cons]
by_cases h : x β xs
Β· rw [dedup_cons_of_mem h, dedup_cons_of_mem (mem_map_of_mem h), ih]
Β· rw [dedup_cons_of_not_mem h, dedup_cons_of_not_mem <| (mem_map_of_injective hf).not.mpr h, ih,
map_cons]
/-- Note that the weaker `List.Subset.dedup_append_left` is proved later. -/
theorem Subset.dedup_append_right {xs ys : List Ξ±} (h : xs β ys) :
dedup (xs ++ ys) = dedup ys := by
rw [List.dedup_append, Subset.union_eq_right (List.Subset.trans h <| subset_dedup _)]
| Mathlib/Data/List/Dedup.lean | 135 | 140 | theorem Disjoint.union_eq {xs ys : List Ξ±} (h : Disjoint xs ys) :
xs βͺ ys = xs.dedup ++ ys := by | induction xs with
| nil => simp
| cons x xs ih =>
rw [cons_union] |
/-
Copyright (c) 2022 MarΓa InΓ©s de Frutos-FernΓ‘ndez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: MarΓa InΓ©s de Frutos-FernΓ‘ndez
-/
import Mathlib.RingTheory.DedekindDomain.Ideal
import Mathlib.RingTheory.Valuation.ExtendToLocalization
import Mathlib.Topology.Algebra.Valued.ValuedField
import Mathlib.Topology.Algebra.Valued.WithVal
/-!
# Adic valuations on Dedekind domains
Given a Dedekind domain `R` of Krull dimension 1 and a maximal ideal `v` of `R`, we define the
`v`-adic valuation on `R` and its extension to the field of fractions `K` of `R`.
We prove several properties of this valuation, including the existence of uniformizers.
We define the completion of `K` with respect to the `v`-adic valuation, denoted
`v.adicCompletion`, and its ring of integers, denoted `v.adicCompletionIntegers`.
## Main definitions
- `IsDedekindDomain.HeightOneSpectrum.intValuation v` is the `v`-adic valuation on `R`.
- `IsDedekindDomain.HeightOneSpectrum.valuation v` is the `v`-adic valuation on `K`.
- `IsDedekindDomain.HeightOneSpectrum.adicCompletion v` is the completion of `K` with respect
to its `v`-adic valuation.
- `IsDedekindDomain.HeightOneSpectrum.adicCompletionIntegers v` is the ring of integers of
`v.adicCompletion`.
## Main results
- `IsDedekindDomain.HeightOneSpectrum.intValuation_le_one` : The `v`-adic valuation on `R` is
bounded above by 1.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_lt_one_iff_dvd` : The `v`-adic valuation of
`r β R` is less than 1 if and only if `v` divides the ideal `(r)`.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_le_pow_iff_dvd` : The `v`-adic valuation of
`r β R` is less than or equal to `Multiplicative.ofAdd (-n)` if and only if `vβΏ` divides the
ideal `(r)`.
- `IsDedekindDomain.HeightOneSpectrum.intValuation_exists_uniformizer` : There exists `Ο β R`
with `v`-adic valuation `Multiplicative.ofAdd (-1)`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_of_mk'` : The `v`-adic valuation of `r/s β K`
is the valuation of `r` divided by the valuation of `s`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_of_algebraMap` : The `v`-adic valuation on `K`
extends the `v`-adic valuation on `R`.
- `IsDedekindDomain.HeightOneSpectrum.valuation_exists_uniformizer` : There exists `Ο β K` with
`v`-adic valuation `Multiplicative.ofAdd (-1)`.
## Implementation notes
We are only interested in Dedekind domains with Krull dimension 1.
## References
* [G. J. Janusz, *Algebraic Number Fields*][janusz1996]
* [J.W.S. Cassels, A. FrΓΆhlich, *Algebraic Number Theory*][cassels1967algebraic]
* [J. Neukirch, *Algebraic Number Theory*][Neukirch1992]
## Tags
dedekind domain, dedekind ring, adic valuation
-/
noncomputable section
open scoped Multiplicative
open Multiplicative IsDedekindDomain
variable {R : Type*} [CommRing R] [IsDedekindDomain R] {K S : Type*} [Field K] [CommSemiring S]
[Algebra R K] [IsFractionRing R K] (v : HeightOneSpectrum R)
namespace IsDedekindDomain.HeightOneSpectrum
/-! ### Adic valuations on the Dedekind domain R -/
open scoped Classical in
/-- The additive `v`-adic valuation of `r β R` is the exponent of `v` in the factorization of the
ideal `(r)`, if `r` is nonzero, or infinity, if `r = 0`. `intValuationDef` is the corresponding
multiplicative valuation. -/
def intValuationDef (r : R) : β€ββ :=
if r = 0 then 0
else
β(Multiplicative.ofAdd
(-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : β€))
theorem intValuationDef_if_pos {r : R} (hr : r = 0) : v.intValuationDef r = 0 :=
if_pos hr
@[simp]
theorem intValuationDef_zero : v.intValuationDef 0 = 0 :=
if_pos rfl
open scoped Classical in
theorem intValuationDef_if_neg {r : R} (hr : r β 0) :
v.intValuationDef r =
Multiplicative.ofAdd
(-(Associates.mk v.asIdeal).count (Associates.mk (Ideal.span {r} : Ideal R)).factors : β€) :=
if_neg hr
/-- Nonzero elements have nonzero adic valuation. -/
theorem intValuation_ne_zero (x : R) (hx : x β 0) : v.intValuationDef x β 0 := by
rw [intValuationDef, if_neg hx]
exact WithZero.coe_ne_zero
/-- Nonzero divisors have nonzero valuation. -/
theorem intValuation_ne_zero' (x : nonZeroDivisors R) : v.intValuationDef x β 0 :=
v.intValuation_ne_zero x (nonZeroDivisors.coe_ne_zero x)
/-- Nonzero divisors have valuation greater than zero. -/
theorem intValuation_zero_le (x : nonZeroDivisors R) : 0 < v.intValuationDef x := by
rw [v.intValuationDef_if_neg (nonZeroDivisors.coe_ne_zero x)]
exact WithZero.zero_lt_coe _
/-- The `v`-adic valuation on `R` is bounded above by 1. -/
theorem intValuation_le_one (x : R) : v.intValuationDef x β€ 1 := by
rw [intValuationDef]
by_cases hx : x = 0
Β· rw [if_pos hx]; exact WithZero.zero_le 1
Β· rw [if_neg hx, β WithZero.coe_one, β ofAdd_zero, WithZero.coe_le_coe, ofAdd_le,
Right.neg_nonpos_iff]
exact Int.natCast_nonneg _
/-- The `v`-adic valuation of `r β R` is less than 1 if and only if `v` divides the ideal `(r)`. -/
theorem intValuation_lt_one_iff_dvd (r : R) :
v.intValuationDef r < 1 β v.asIdeal β£ Ideal.span {r} := by
classical
rw [intValuationDef]
split_ifs with hr
Β· simp [hr]
Β· rw [β WithZero.coe_one, β ofAdd_zero, WithZero.coe_lt_coe, ofAdd_lt, neg_lt_zero, β
Int.ofNat_zero, Int.ofNat_lt, zero_lt_iff]
have h : (Ideal.span {r} : Ideal R) β 0 := by
rw [Ne, Ideal.zero_eq_bot, Ideal.span_singleton_eq_bot]
exact hr
apply Associates.count_ne_zero_iff_dvd h (by apply v.irreducible)
/-- The `v`-adic valuation of `r β R` is less than `Multiplicative.ofAdd (-n)` if and only if
`vβΏ` divides the ideal `(r)`. -/
theorem intValuation_le_pow_iff_dvd (r : R) (n : β) :
v.intValuationDef r β€ Multiplicative.ofAdd (-(n : β€)) β v.asIdeal ^ n β£ Ideal.span {r} := by
classical
rw [intValuationDef]
split_ifs with hr
Β· simp_rw [hr, Ideal.dvd_span_singleton, zero_le', Submodule.zero_mem]
Β· rw [WithZero.coe_le_coe, ofAdd_le, neg_le_neg_iff, Int.ofNat_le, Ideal.dvd_span_singleton, β
Associates.le_singleton_iff,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hr)
(by apply v.associates_irreducible)]
/-- The `v`-adic valuation of `0 : R` equals 0. -/
theorem intValuation.map_zero' : v.intValuationDef 0 = 0 :=
v.intValuationDef_if_pos (Eq.refl 0)
/-- The `v`-adic valuation of `1 : R` equals 1. -/
theorem intValuation.map_one' : v.intValuationDef 1 = 1 := by
classical
rw [v.intValuationDef_if_neg (zero_ne_one.symm : (1 : R) β 0), Ideal.span_singleton_one, β
Ideal.one_eq_top, Associates.mk_one, Associates.factors_one,
Associates.count_zero (by apply v.associates_irreducible), Int.ofNat_zero, neg_zero, ofAdd_zero,
WithZero.coe_one]
/-- The `v`-adic valuation of a product equals the product of the valuations. -/
theorem intValuation.map_mul' (x y : R) :
v.intValuationDef (x * y) = v.intValuationDef x * v.intValuationDef y := by
classical
simp only [intValuationDef]
by_cases hx : x = 0
Β· rw [hx, zero_mul, if_pos (Eq.refl _), zero_mul]
Β· by_cases hy : y = 0
Β· rw [hy, mul_zero, if_pos (Eq.refl _), mul_zero]
Β· rw [if_neg hx, if_neg hy, if_neg (mul_ne_zero hx hy), β WithZero.coe_mul, WithZero.coe_inj, β
ofAdd_add, β Ideal.span_singleton_mul_span_singleton, β Associates.mk_mul_mk, β neg_add,
Associates.count_mul (by apply Associates.mk_ne_zero'.mpr hx)
(by apply Associates.mk_ne_zero'.mpr hy) (by apply v.associates_irreducible)]
rfl
theorem intValuation.le_max_iff_min_le {a b c : β} :
Multiplicative.ofAdd (-c : β€) β€
max (Multiplicative.ofAdd (-a : β€)) (Multiplicative.ofAdd (-b : β€)) β
min a b β€ c := by
rw [le_max_iff, ofAdd_le, ofAdd_le, neg_le_neg_iff, neg_le_neg_iff, Int.ofNat_le, Int.ofNat_le, β
min_le_iff]
/-- The `v`-adic valuation of a sum is bounded above by the maximum of the valuations. -/
theorem intValuation.map_add_le_max' (x y : R) :
v.intValuationDef (x + y) β€ max (v.intValuationDef x) (v.intValuationDef y) := by
classical
by_cases hx : x = 0
Β· rw [hx, zero_add]
conv_rhs => rw [intValuationDef, if_pos (Eq.refl _)]
rw [max_eq_right (WithZero.zero_le (v.intValuationDef y))]
Β· by_cases hy : y = 0
Β· rw [hy, add_zero]
conv_rhs => rw [max_comm, intValuationDef, if_pos (Eq.refl _)]
rw [max_eq_right (WithZero.zero_le (v.intValuationDef x))]
Β· by_cases hxy : x + y = 0
Β· rw [intValuationDef, if_pos hxy]; exact zero_le'
Β· rw [v.intValuationDef_if_neg hxy, v.intValuationDef_if_neg hx, v.intValuationDef_if_neg hy,
WithZero.le_max_iff, intValuation.le_max_iff_min_le]
set nmin :=
min ((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span { x })).factors)
((Associates.mk v.asIdeal).count (Associates.mk (Ideal.span { y })).factors)
have h_dvd_x : x β v.asIdeal ^ nmin := by
rw [β Associates.le_singleton_iff x nmin _,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hx) _]
Β· exact min_le_left _ _
apply v.associates_irreducible
have h_dvd_y : y β v.asIdeal ^ nmin := by
rw [β Associates.le_singleton_iff y nmin _,
Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hy) _]
Β· exact min_le_right _ _
apply v.associates_irreducible
have h_dvd_xy : Associates.mk v.asIdeal ^ nmin β€ Associates.mk (Ideal.span {x + y}) := by
rw [Associates.le_singleton_iff]
exact Ideal.add_mem (v.asIdeal ^ nmin) h_dvd_x h_dvd_y
rw [Associates.prime_pow_dvd_iff_le (Associates.mk_ne_zero'.mpr hxy) _] at h_dvd_xy
Β· exact h_dvd_xy
apply v.associates_irreducible
/-- The `v`-adic valuation on `R`. -/
@[simps]
def intValuation : Valuation R β€ββ where
toFun := v.intValuationDef
map_zero' := intValuation.map_zero' v
map_one' := intValuation.map_one' v
map_mul' := intValuation.map_mul' v
map_add_le_max' := intValuation.map_add_le_max' v
theorem intValuation_apply {r : R} (v : IsDedekindDomain.HeightOneSpectrum R) :
intValuation v r = intValuationDef v r := rfl
/-- There exists `Ο β R` with `v`-adic valuation `Multiplicative.ofAdd (-1)`. -/
theorem intValuation_exists_uniformizer :
β Ο : R, v.intValuationDef Ο = Multiplicative.ofAdd (-1 : β€) := by
classical
have hv : _root_.Irreducible (Associates.mk v.asIdeal) := v.associates_irreducible
have hlt : v.asIdeal ^ 2 < v.asIdeal := by
rw [β Ideal.dvdNotUnit_iff_lt]
exact
β¨v.ne_bot, v.asIdeal, (not_congr Ideal.isUnit_iff).mpr (Ideal.IsPrime.ne_top v.isPrime),
sq v.asIdealβ©
obtain β¨Ο, mem, nmemβ© := SetLike.exists_of_lt hlt
have hΟ : Associates.mk (Ideal.span {Ο}) β 0 := by
rw [Associates.mk_ne_zero']
intro h
rw [h] at nmem
exact nmem (Submodule.zero_mem (v.asIdeal ^ 2))
use Ο
rw [intValuationDef, if_neg (Associates.mk_ne_zero'.mp hΟ), WithZero.coe_inj]
apply congr_arg
rw [neg_inj, β Int.ofNat_one, Int.natCast_inj]
rw [β Ideal.dvd_span_singleton, β Associates.mk_le_mk_iff_dvd] at mem nmem
rw [β pow_one (Associates.mk v.asIdeal), Associates.prime_pow_dvd_iff_le hΟ hv] at mem
rw [Associates.mk_pow, Associates.prime_pow_dvd_iff_le hΟ hv, not_le] at nmem
exact Nat.eq_of_le_of_lt_succ mem nmem
/-- The `I`-adic valuation of a generator of `I` equals `(-1 : β€ββ)` -/
theorem intValuation_singleton {r : R} (hr : r β 0) (hv : v.asIdeal = Ideal.span {r}) :
v.intValuation r = Multiplicative.ofAdd (-1 : β€) := by
classical
rw [intValuation_apply, v.intValuationDef_if_neg hr, β hv, Associates.count_self, Int.ofNat_one,
ofAdd_neg, WithZero.coe_inv]
apply v.associates_irreducible
/-! ### Adic valuations on the field of fractions `K` -/
variable (K) in
/-- The `v`-adic valuation of `x β K` is the valuation of `r` divided by the valuation of `s`,
where `r` and `s` are chosen so that `x = r/s`. -/
def valuation (v : HeightOneSpectrum R) : Valuation K β€ββ :=
v.intValuation.extendToLocalization
(fun r hr => Set.mem_compl <| v.intValuation_ne_zero' β¨r, hrβ©) K
theorem valuation_def (x : K) :
v.valuation K x =
v.intValuation.extendToLocalization
(fun r hr => Set.mem_compl (v.intValuation_ne_zero' β¨r, hrβ©)) K x :=
rfl
/-- The `v`-adic valuation of `r/s β K` is the valuation of `r` divided by the valuation of `s`. -/
theorem valuation_of_mk' {r : R} {s : nonZeroDivisors R} :
v.valuation K (IsLocalization.mk' K r s) = v.intValuation r / v.intValuation s := by
rw [valuation_def, Valuation.extendToLocalization_mk', div_eq_mul_inv]
open scoped algebraMap in
/-- The `v`-adic valuation on `K` extends the `v`-adic valuation on `R`. -/
theorem valuation_of_algebraMap (r : R) : v.valuation K r = v.intValuation r := by
rw [valuation_def, Valuation.extendToLocalization_apply_map_apply]
open scoped algebraMap in
lemma valuation_eq_intValuationDef (r : R) : v.valuation K r = v.intValuationDef r :=
Valuation.extendToLocalization_apply_map_apply ..
open scoped algebraMap in
/-- The `v`-adic valuation on `R` is bounded above by 1. -/
| Mathlib/RingTheory/DedekindDomain/AdicValuation.lean | 290 | 291 | theorem valuation_le_one (r : R) : v.valuation K r β€ 1 := by | rw [valuation_of_algebraMap]; exact v.intValuation_le_one r |
/-
Copyright (c) 2019 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Module.Submodule.Equiv
import Mathlib.Algebra.Module.Equiv.Basic
import Mathlib.Algebra.Module.Rat
import Mathlib.Data.Bracket
import Mathlib.Tactic.Abel
/-!
# Lie algebras
This file defines Lie rings and Lie algebras over a commutative ring together with their
modules, morphisms and equivalences, as well as various lemmas to make these definitions usable.
## Main definitions
* `LieRing`
* `LieAlgebra`
* `LieRingModule`
* `LieModule`
* `LieHom`
* `LieEquiv`
* `LieModuleHom`
* `LieModuleEquiv`
## Notation
Working over a fixed commutative ring `R`, we introduce the notations:
* `L βββ
Rβ L'` for a morphism of Lie algebras,
* `L βββ
Rβ L'` for an equivalence of Lie algebras,
* `M βββ
R,Lβ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,
* `M βββ
R,Lβ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`.
## Implementation notes
Lie algebras are defined as modules with a compatible Lie ring structure and thus, like modules,
are partially unbundled.
## References
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975)
## Tags
lie bracket, jacobi identity, lie ring, lie algebra, lie module
-/
universe u v w wβ wβ
open Function
/-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the
Jacobi identity. -/
class LieRing (L : Type v) extends AddCommGroup L, Bracket L L where
/-- A Lie ring bracket is additive in its first component. -/
protected add_lie : β x y z : L, β
x + y, zβ = β
x, zβ + β
y, zβ
/-- A Lie ring bracket is additive in its second component. -/
protected lie_add : β x y z : L, β
x, y + zβ = β
x, yβ + β
x, zβ
/-- A Lie ring bracket vanishes on the diagonal in L Γ L. -/
protected lie_self : β x : L, β
x, xβ = 0
/-- A Lie ring bracket satisfies a Leibniz / Jacobi identity. -/
protected leibniz_lie : β x y z : L, β
x, β
y, zββ = β
β
x, yβ, zβ + β
y, β
x, zββ
/-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi
identity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/
@[ext] class LieAlgebra (R : Type u) (L : Type v) [CommRing R] [LieRing L] extends Module R L where
/-- A Lie algebra bracket is compatible with scalar multiplication in its second argument.
The compatibility in the first argument is not a class property, but follows since every
Lie algebra has a natural Lie module action on itself, see `LieModule`. -/
protected lie_smul : β (t : R) (x y : L), β
x, t β’ yβ = t β’ β
x, yβ
/-- A Lie ring module is an additive group, together with an additive action of a
Lie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms.
(For representations of Lie *algebras* see `LieModule`.) -/
class LieRingModule (L : Type v) (M : Type w) [LieRing L] [AddCommGroup M] extends Bracket L M where
/-- A Lie ring module bracket is additive in its first component. -/
protected add_lie : β (x y : L) (m : M), β
x + y, mβ = β
x, mβ + β
y, mβ
/-- A Lie ring module bracket is additive in its second component. -/
protected lie_add : β (x : L) (m n : M), β
x, m + nβ = β
x, mβ + β
x, nβ
/-- A Lie ring module bracket satisfies a Leibniz / Jacobi identity. -/
protected leibniz_lie : β (x y : L) (m : M), β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ
/-- A Lie module is a module over a commutative ring, together with a linear action of a Lie
algebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/
class LieModule (R : Type u) (L : Type v) (M : Type w) [CommRing R] [LieRing L] [LieAlgebra R L]
[AddCommGroup M] [Module R M] [LieRingModule L M] : Prop where
/-- A Lie module bracket is compatible with scalar multiplication in its first argument. -/
protected smul_lie : β (t : R) (x : L) (m : M), β
t β’ x, mβ = t β’ β
x, mβ
/-- A Lie module bracket is compatible with scalar multiplication in its second argument. -/
protected lie_smul : β (t : R) (x : L) (m : M), β
x, t β’ mβ = t β’ β
x, mβ
/-- A tower of Lie bracket actions encapsulates the Leibniz rule for Lie bracket actions.
More precisely, it does so in a relative setting:
Let `Lβ` and `Lβ` be two types with Lie bracket actions on a type `M` endowed with an addition,
and additionally assume a Lie bracket action of `Lβ` on `Lβ`.
Then the Leibniz rule asserts for all `x : Lβ`, `y : Lβ`, and `m : M` that
`β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ` holds.
Common examples include the case where `Lβ` is a Lie subalgebra of `Lβ`
and the case where `Lβ` is a Lie ideal of `Lβ`. -/
class IsLieTower (Lβ Lβ M : Type*) [Bracket Lβ Lβ] [Bracket Lβ M] [Bracket Lβ M] [Add M] where
protected leibniz_lie (x : Lβ) (y : Lβ) (m : M) : β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ
section IsLieTower
variable {Lβ Lβ M : Type*} [Bracket Lβ Lβ] [Bracket Lβ M] [Bracket Lβ M]
lemma leibniz_lie [Add M] [IsLieTower Lβ Lβ M] (x : Lβ) (y : Lβ) (m : M) :
β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ := IsLieTower.leibniz_lie x y m
lemma lie_swap_lie [Bracket Lβ Lβ] [AddCommGroup M] [IsLieTower Lβ Lβ M] [IsLieTower Lβ Lβ M]
(x : Lβ) (y : Lβ) (m : M) : β
β
x, yβ, mβ = -β
β
y, xβ, mβ := by
have h1 := leibniz_lie x y m
have h2 := leibniz_lie y x m
convert congr($h1.symm - $h2) using 1 <;> simp only [add_sub_cancel_right, sub_add_cancel_right]
end IsLieTower
section BasicProperties
theorem LieAlgebra.toModule_injective (L : Type*) [LieRing L] :
Function.Injective (@LieAlgebra.toModule _ _ _ _ : LieAlgebra β L β Module β L) := by
rintro β¨hββ© β¨hββ© heq
congr
instance (L : Type*) [LieRing L] : Subsingleton (LieAlgebra β L) :=
LieAlgebra.toModule_injective L |>.subsingleton
variable {R : Type u} {L : Type v} {M : Type w} {N : Type wβ}
variable [CommRing R] [LieRing L] [LieAlgebra R L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N]
variable (t : R) (x y z : L) (m n : M)
@[simp]
theorem add_lie : β
x + y, mβ = β
x, mβ + β
y, mβ :=
LieRingModule.add_lie x y m
@[simp]
theorem lie_add : β
x, m + nβ = β
x, mβ + β
x, nβ :=
LieRingModule.lie_add x m n
@[simp]
theorem smul_lie : β
t β’ x, mβ = t β’ β
x, mβ :=
LieModule.smul_lie t x m
@[simp]
theorem lie_smul : β
x, t β’ mβ = t β’ β
x, mβ :=
LieModule.lie_smul t x m
instance : IsLieTower L L M where
leibniz_lie x y m := LieRingModule.leibniz_lie x y m
@[simp]
theorem lie_zero : β
x, 0β = (0 : M) :=
(AddMonoidHom.mk' _ (lie_add x)).map_zero
@[simp]
theorem zero_lie : β
(0 : L), mβ = 0 :=
(AddMonoidHom.mk' (fun x : L => β
x, mβ) fun x y => add_lie x y m).map_zero
@[simp]
theorem lie_self : β
x, xβ = 0 :=
LieRing.lie_self x
instance lieRingSelfModule : LieRingModule L L :=
{ (inferInstance : LieRing L) with }
@[simp]
theorem lie_skew : -β
y, xβ = β
x, yβ := by
have h : β
x + y, xβ + β
x + y, yβ = 0 := by rw [β lie_add]; apply lie_self
simpa [neg_eq_iff_add_eq_zero] using h
/-- Every Lie algebra is a module over itself. -/
instance lieAlgebraSelfModule : LieModule R L L where
smul_lie t x m := by rw [β lie_skew, β lie_skew x m, LieAlgebra.lie_smul, smul_neg]
lie_smul := by apply LieAlgebra.lie_smul
@[simp]
theorem neg_lie : β
-x, mβ = -β
x, mβ := by
rw [β sub_eq_zero, sub_neg_eq_add, β add_lie]
simp
@[simp]
theorem lie_neg : β
x, -mβ = -β
x, mβ := by
rw [β sub_eq_zero, sub_neg_eq_add, β lie_add]
simp
@[simp]
theorem sub_lie : β
x - y, mβ = β
x, mβ - β
y, mβ := by simp [sub_eq_add_neg]
@[simp]
theorem lie_sub : β
x, m - nβ = β
x, mβ - β
x, nβ := by simp [sub_eq_add_neg]
@[simp]
theorem nsmul_lie (n : β) : β
n β’ x, mβ = n β’ β
x, mβ :=
AddMonoidHom.map_nsmul
{ toFun := fun x : L => β
x, mβ, map_zero' := zero_lie m, map_add' := fun _ _ => add_lie _ _ _ }
_ _
@[simp]
theorem lie_nsmul (n : β) : β
x, n β’ mβ = n β’ β
x, mβ :=
AddMonoidHom.map_nsmul
{ toFun := fun m : M => β
x, mβ, map_zero' := lie_zero x, map_add' := fun _ _ => lie_add _ _ _}
_ _
theorem zsmul_lie (a : β€) : β
a β’ x, mβ = a β’ β
x, mβ :=
AddMonoidHom.map_zsmul
{ toFun := fun x : L => β
x, mβ, map_zero' := zero_lie m, map_add' := fun _ _ => add_lie _ _ _ }
_ _
theorem lie_zsmul (a : β€) : β
x, a β’ mβ = a β’ β
x, mβ :=
AddMonoidHom.map_zsmul
{ toFun := fun m : M => β
x, mβ, map_zero' := lie_zero x, map_add' := fun _ _ => lie_add _ _ _ }
_ _
@[simp]
lemma lie_lie : β
β
x, yβ, mβ = β
x, β
y, mββ - β
y, β
x, mββ := by rw [leibniz_lie, add_sub_cancel_right]
theorem lie_jacobi : β
x, β
y, zββ + β
y, β
z, xββ + β
z, β
x, yββ = 0 := by
rw [β neg_neg β
x, yβ, lie_neg z, lie_skew y x, β lie_skew, lie_lie]
abel
instance LieRing.instLieAlgebra : LieAlgebra β€ L where lie_smul n x y := lie_zsmul x y n
instance : LieModule β€ L M where
smul_lie n x m := zsmul_lie x m n
lie_smul n x m := lie_zsmul x m n
instance LinearMap.instLieRingModule : LieRingModule L (M ββ[R] N) where
bracket x f :=
{ toFun := fun m => β
x, f mβ - f β
x, mβ
map_add' := fun m n => by
simp only [lie_add, LinearMap.map_add]
abel
map_smul' := fun t m => by
simp only [smul_sub, LinearMap.map_smul, lie_smul, RingHom.id_apply] }
add_lie x y f := by
ext n
simp only [add_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.add_apply, LinearMap.map_add]
abel
lie_add x f g := by
ext n
simp only [LinearMap.coe_mk, AddHom.coe_mk, lie_add, LinearMap.add_apply]
abel
leibniz_lie x y f := by
ext n
simp only [lie_lie, LinearMap.coe_mk, AddHom.coe_mk, LinearMap.map_sub, LinearMap.add_apply,
lie_sub]
abel
@[simp]
theorem LieHom.lie_apply (f : M ββ[R] N) (x : L) (m : M) : β
x, fβ m = β
x, f mβ - f β
x, mβ :=
rfl
instance LinearMap.instLieModule : LieModule R L (M ββ[R] N) where
smul_lie t x f := by
ext n
simp only [smul_sub, smul_lie, LinearMap.smul_apply, LieHom.lie_apply, LinearMap.map_smul]
lie_smul t x f := by
ext n
simp only [smul_sub, LinearMap.smul_apply, LieHom.lie_apply, lie_smul]
/-- We could avoid defining this by instead defining a `LieRingModule L R` instance with a zero
bracket and relying on `LinearMap.instLieRingModule`. We do not do this because in the case that
`L = R` we would have a non-defeq diamond via `Ring.instBracket`. -/
instance Module.Dual.instLieRingModule : LieRingModule L (M ββ[R] R) where
bracket := fun x f β¦
{ toFun := fun m β¦ - f β
x, mβ
map_add' := by simp [-neg_add_rev, neg_add]
map_smul' := by simp }
add_lie := fun x y m β¦ by ext n; simp [-neg_add_rev, neg_add]
lie_add := fun x m n β¦ by ext p; simp [-neg_add_rev, neg_add]
leibniz_lie := fun x m n β¦ by ext p; simp
@[simp] lemma Module.Dual.lie_apply (f : M ββ[R] R) : β
x, fβ m = - f β
x, mβ := rfl
instance Module.Dual.instLieModule : LieModule R L (M ββ[R] R) where
smul_lie := fun t x m β¦ by ext n; simp
lie_smul := fun t x m β¦ by ext n; simp
variable (L) in
/-- It is sometimes useful to regard a `LieRing` as a `NonUnitalNonAssocRing`. -/
def LieRing.toNonUnitalNonAssocRing : NonUnitalNonAssocRing L :=
{ mul := Bracket.bracket
left_distrib := lie_add
right_distrib := add_lie
zero_mul := zero_lie
mul_zero := lie_zero }
variable {ΞΉ ΞΊ : Type*}
theorem sum_lie (s : Finset ΞΉ) (f : ΞΉ β L) (a : L) : β
β i β s, f i, aβ = β i β s, β
f i, aβ :=
let _i := LieRing.toNonUnitalNonAssocRing L
s.sum_mul f a
theorem lie_sum (s : Finset ΞΉ) (f : ΞΉ β L) (a : L) : β
a, β i β s, f iβ = β i β s, β
a, f iβ :=
let _i := LieRing.toNonUnitalNonAssocRing L
s.mul_sum f a
theorem sum_lie_sum {ΞΊ : Type*} (s : Finset ΞΉ) (t : Finset ΞΊ) (f : ΞΉ β L) (g : ΞΊ β L) :
β
(β i β s, f i), β j β t, g jβ = β i β s, β j β t, β
f i, g jβ :=
let _i := LieRing.toNonUnitalNonAssocRing L
s.sum_mul_sum t f g
end BasicProperties
/-- A morphism of Lie algebras (denoted as `Lβ βββ
Rβ Lβ`)
is a linear map respecting the bracket operations. -/
structure LieHom (R L L' : Type*) [CommRing R] [LieRing L] [LieAlgebra R L]
[LieRing L'] [LieAlgebra R L'] extends L ββ[R] L' where
/-- A morphism of Lie algebras is compatible with brackets. -/
map_lie' : β {x y : L}, toFun β
x, yβ = β
toFun x, toFun yβ
@[inherit_doc]
notation:25 L " βββ
" R:25 "β " L':0 => LieHom R L L'
namespace LieHom
variable {R : Type u} {Lβ : Type v} {Lβ : Type w} {Lβ : Type wβ}
variable [CommRing R]
variable [LieRing Lβ] [LieAlgebra R Lβ]
variable [LieRing Lβ] [LieAlgebra R Lβ]
variable [LieRing Lβ] [LieAlgebra R Lβ]
attribute [coe] LieHom.toLinearMap
instance : Coe (Lβ βββ
Rβ Lβ) (Lβ ββ[R] Lβ) :=
β¨LieHom.toLinearMapβ©
instance : FunLike (Lβ βββ
Rβ Lβ) Lβ Lβ where
coe f := f.toFun
coe_injective' x y h := by
cases x; cases y; simp at h; simp [h]
initialize_simps_projections LieHom (toFun β apply)
@[simp, norm_cast]
theorem coe_toLinearMap (f : Lβ βββ
Rβ Lβ) : β(f : Lβ ββ[R] Lβ) = f :=
rfl
@[simp]
theorem toFun_eq_coe (f : Lβ βββ
Rβ Lβ) : f.toFun = βf :=
rfl
@[simp]
theorem map_smul (f : Lβ βββ
Rβ Lβ) (c : R) (x : Lβ) : f (c β’ x) = c β’ f x :=
LinearMap.map_smul (f : Lβ ββ[R] Lβ) c x
@[simp]
theorem map_add (f : Lβ βββ
Rβ Lβ) (x y : Lβ) : f (x + y) = f x + f y :=
LinearMap.map_add (f : Lβ ββ[R] Lβ) x y
@[simp]
theorem map_sub (f : Lβ βββ
Rβ Lβ) (x y : Lβ) : f (x - y) = f x - f y :=
LinearMap.map_sub (f : Lβ ββ[R] Lβ) x y
@[simp]
theorem map_neg (f : Lβ βββ
Rβ Lβ) (x : Lβ) : f (-x) = -f x :=
LinearMap.map_neg (f : Lβ ββ[R] Lβ) x
@[simp]
theorem map_lie (f : Lβ βββ
Rβ Lβ) (x y : Lβ) : f β
x, yβ = β
f x, f yβ :=
LieHom.map_lie' f
@[simp]
theorem map_zero (f : Lβ βββ
Rβ Lβ) : f 0 = 0 :=
(f : Lβ ββ[R] Lβ).map_zero
/-- The identity map is a morphism of Lie algebras. -/
def id : Lβ βββ
Rβ Lβ :=
{ (LinearMap.id : Lβ ββ[R] Lβ) with map_lie' := rfl }
@[simp, norm_cast]
theorem coe_id : β(id : Lβ βββ
Rβ Lβ) = _root_.id :=
rfl
theorem id_apply (x : Lβ) : (id : Lβ βββ
Rβ Lβ) x = x :=
rfl
/-- The constant 0 map is a Lie algebra morphism. -/
instance : Zero (Lβ βββ
Rβ Lβ) :=
β¨{ (0 : Lβ ββ[R] Lβ) with map_lie' := by simp }β©
@[norm_cast, simp]
theorem coe_zero : ((0 : Lβ βββ
Rβ Lβ) : Lβ β Lβ) = 0 :=
rfl
theorem zero_apply (x : Lβ) : (0 : Lβ βββ
Rβ Lβ) x = 0 :=
rfl
/-- The identity map is a Lie algebra morphism. -/
instance : One (Lβ βββ
Rβ Lβ) :=
β¨idβ©
@[simp]
theorem coe_one : ((1 : Lβ βββ
Rβ Lβ) : Lβ β Lβ) = _root_.id :=
rfl
theorem one_apply (x : Lβ) : (1 : Lβ βββ
Rβ Lβ) x = x :=
rfl
instance : Inhabited (Lβ βββ
Rβ Lβ) :=
β¨0β©
| Mathlib/Algebra/Lie/Basic.lean | 412 | 414 | theorem coe_injective : @Function.Injective (Lβ βββ
Rβ Lβ) (Lβ β Lβ) (β) := by | rintro β¨β¨β¨f, _β©, _β©, _β© β¨β¨β¨g, _β©, _β©, _β© h
congr |
/-
Copyright (c) 2023 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn, Heather Macbeth
-/
import Mathlib.MeasureTheory.Constructions.Pi
/-!
# Marginals of multivariate functions
In this file, we define a convenient way to compute integrals of multivariate functions, especially
if you want to write expressions where you integrate only over some of the variables that the
function depends on. This is common in induction arguments involving integrals of multivariate
functions.
This constructions allows working with iterated integrals and applying Tonelli's theorem
and Fubini's theorem, without using measurable equivalences by changing the representation of your
space (e.g. `((ΞΉ β ΞΉ') β β) β (ΞΉ β β) Γ (ΞΉ' β β)`).
## Main Definitions
* Assume that `β i : ΞΉ, X i` is a product of measurable spaces with measures `ΞΌ i` on `X i`,
`f : (β i, X i) β ββ₯0β` is a function and `s : Finset ΞΉ`.
Then `lmarginal ΞΌ s f` or `β«β―β«β»_s, f βΞΌ` is the function that integrates `f`
over all variables in `s`. It returns a function that still takes the same variables as `f`,
but is constant in the variables in `s`. Mathematically, if `s = {iβ, ..., iβ}`,
then `lmarginal ΞΌ s f` is the expression
$$
\vec{x}\mapsto \int\!\!\cdots\!\!\int f(\vec{x}[\vec{y}])dy_{i_1}\cdots dy_{i_k}.
$$
where $\vec{x}[\vec{y}]$ is the vector $\vec{x}$ with $x_{i_j}$ replaced by $y_{i_j}$ for all
$1 \le j \le k$.
If `f` is the distribution of a random variable, this is the marginal distribution of all
variables not in `s` (but not the most general notion, since we only consider product measures
here).
Note that the notation `β«β―β«β»_s, f βΞΌ` is not a binder, and returns a function.
## Main Results
* `lmarginal_union` is the analogue of Tonelli's theorem for iterated integrals. It states that
for measurable functions `f` and disjoint finsets `s` and `t` we have
`β«β―β«β»_s βͺ t, f βΞΌ = β«β―β«β»_s, β«β―β«β»_t, f βΞΌ βΞΌ`.
## Implementation notes
The function `f` can have an arbitrary product as its domain (even infinite products), but the
set `s` of integration variables is a `Finset`. We are assuming that the function `f` is measurable
for most of this file. Note that asking whether it is `AEMeasurable` is not even well-posed,
since there is no well-behaved measure on the domain of `f`.
## TODO
* Define the marginal function for functions taking values in a Banach space.
-/
open scoped ENNReal
open Set Function Equiv Finset
noncomputable section
namespace MeasureTheory
section LMarginal
variable {Ξ΄ Ξ΄' : Type*} {X : Ξ΄ β Type*} [β i, MeasurableSpace (X i)]
variable {ΞΌ : β i, Measure (X i)} [DecidableEq Ξ΄]
variable {s t : Finset Ξ΄} {f : (β i, X i) β ββ₯0β} {x : β i, X i}
/-- Integrate `f(xβ,β¦,xβ)` over all variables `xα΅’` where `i β s`. Return a function in the
remaining variables (it will be constant in the `xα΅’` for `i β s`).
This is the marginal distribution of all variables not in `s` when the considered measure
is the product measure. -/
def lmarginal (ΞΌ : β i, Measure (X i)) (s : Finset Ξ΄) (f : (β i, X i) β ββ₯0β)
(x : β i, X i) : ββ₯0β :=
β«β» y : β i : s, X i, f (updateFinset x s y) βMeasure.pi fun i : s => ΞΌ i
-- Note: this notation is not a binder. This is more convenient since it returns a function.
@[inherit_doc]
notation "β«β―β«β»_" s ", " f " β" ΞΌ:70 => lmarginal ΞΌ s f
@[inherit_doc]
notation "β«β―β«β»_" s ", " f => lmarginal (fun _ β¦ volume) s f
variable (ΞΌ)
theorem _root_.Measurable.lmarginal [β i, SigmaFinite (ΞΌ i)] (hf : Measurable f) :
Measurable (β«β―β«β»_s, f βΞΌ) := by
refine Measurable.lintegral_prod_right ?_
refine hf.comp ?_
rw [measurable_pi_iff]; intro i
by_cases hi : i β s
Β· simpa [hi, updateFinset] using measurable_pi_iff.1 measurable_snd _
Β· simpa [hi, updateFinset] using measurable_pi_iff.1 measurable_fst _
@[simp] theorem lmarginal_empty (f : (β i, X i) β ββ₯0β) : β«β―β«β»_β
, f βΞΌ = f := by
ext1 x
simp_rw [lmarginal, Measure.pi_of_empty fun i : (β
: Finset Ξ΄) => ΞΌ i]
apply lintegral_dirac'
exact Subsingleton.measurable
/-- The marginal distribution is independent of the variables in `s`. -/
theorem lmarginal_congr {x y : β i, X i} (f : (β i, X i) β ββ₯0β)
(h : β i β s, x i = y i) :
(β«β―β«β»_s, f βΞΌ) x = (β«β―β«β»_s, f βΞΌ) y := by
dsimp [lmarginal, updateFinset_def]; rcongr; exact h _ βΉ_βΊ
theorem lmarginal_update_of_mem {i : Ξ΄} (hi : i β s)
(f : (β i, X i) β ββ₯0β) (x : β i, X i) (y : X i) :
(β«β―β«β»_s, f βΞΌ) (Function.update x i y) = (β«β―β«β»_s, f βΞΌ) x := by
apply lmarginal_congr
intro j hj
have : j β i := by rintro rfl; exact hj hi
apply update_of_ne this
variable {ΞΌ} in
theorem lmarginal_singleton (f : (β i, X i) β ββ₯0β) (i : Ξ΄) :
β«β―β«β»_{i}, f βΞΌ = fun x => β«β» xα΅’, f (Function.update x i xα΅’) βΞΌ i := by
let Ξ± : Type _ := ({i} : Finset Ξ΄)
let e := (MeasurableEquiv.piUnique fun j : Ξ± β¦ X j).symm
ext1 x
calc (β«β―β«β»_{i}, f βΞΌ) x
= β«β» (y : X (default : Ξ±)), f (updateFinset x {i} (e y)) βΞΌ (default : Ξ±) := by
simp_rw [lmarginal,
measurePreserving_piUnique (fun j : ({i} : Finset Ξ΄) β¦ ΞΌ j) |>.symm _
|>.lintegral_map_equiv, e, Ξ±]
_ = β«β» xα΅’, f (Function.update x i xα΅’) βΞΌ i := by simp [update_eq_updateFinset]; rfl
variable {ΞΌ} in
@[gcongr]
theorem lmarginal_mono {f g : (β i, X i) β ββ₯0β} (hfg : f β€ g) : β«β―β«β»_s, f βΞΌ β€ β«β―β«β»_s, g βΞΌ :=
fun _ => lintegral_mono fun _ => hfg _
variable [β i, SigmaFinite (ΞΌ i)]
theorem lmarginal_union (f : (β i, X i) β ββ₯0β) (hf : Measurable f)
(hst : Disjoint s t) : β«β―β«β»_s βͺ t, f βΞΌ = β«β―β«β»_s, β«β―β«β»_t, f βΞΌ βΞΌ := by
ext1 x
let e := MeasurableEquiv.piFinsetUnion X hst
calc (β«β―β«β»_s βͺ t, f βΞΌ) x
= β«β» (y : (i : β₯(s βͺ t)) β X i), f (updateFinset x (s βͺ t) y)
β.pi fun i' : β₯(s βͺ t) β¦ ΞΌ i' := rfl
_ = β«β» (y : ((i : s) β X i) Γ ((j : t) β X j)), f (updateFinset x (s βͺ t) _)
β(Measure.pi fun i : s β¦ ΞΌ i).prod (.pi fun j : t β¦ ΞΌ j) := by
rw [measurePreserving_piFinsetUnion hst ΞΌ |>.lintegral_map_equiv]
_ = β«β» (y : (i : s) β X i), β«β» (z : (j : t) β X j), f (updateFinset x (s βͺ t) (e (y, z)))
β.pi fun j : t β¦ ΞΌ j β.pi fun i : s β¦ ΞΌ i := by
apply lintegral_prod
apply Measurable.aemeasurable
exact hf.comp <| measurable_updateFinset.comp e.measurable
_ = (β«β―β«β»_s, β«β―β«β»_t, f βΞΌ βΞΌ) x := by
simp_rw [lmarginal, updateFinset_updateFinset hst]
rfl
theorem lmarginal_union' (f : (β i, X i) β ββ₯0β) (hf : Measurable f) {s t : Finset Ξ΄}
(hst : Disjoint s t) : β«β―β«β»_s βͺ t, f βΞΌ = β«β―β«β»_t, β«β―β«β»_s, f βΞΌ βΞΌ := by
rw [Finset.union_comm, lmarginal_union ΞΌ f hf hst.symm]
variable {ΞΌ}
/-- Peel off a single integral from a `lmarginal` integral at the beginning (compare with
`lmarginal_insert'`, which peels off an integral at the end). -/
theorem lmarginal_insert (f : (β i, X i) β ββ₯0β) (hf : Measurable f) {i : Ξ΄}
(hi : i β s) (x : β i, X i) :
(β«β―β«β»_insert i s, f βΞΌ) x = β«β» xα΅’, (β«β―β«β»_s, f βΞΌ) (Function.update x i xα΅’) βΞΌ i := by
rw [Finset.insert_eq, lmarginal_union ΞΌ f hf (Finset.disjoint_singleton_left.mpr hi),
lmarginal_singleton]
/-- Peel off a single integral from a `lmarginal` integral at the beginning (compare with
`lmarginal_erase'`, which peels off an integral at the end). -/
| Mathlib/MeasureTheory/Integral/Marginal.lean | 171 | 175 | theorem lmarginal_erase (f : (β i, X i) β ββ₯0β) (hf : Measurable f) {i : Ξ΄}
(hi : i β s) (x : β i, X i) :
(β«β―β«β»_s, f βΞΌ) x = β«β» xα΅’, (β«β―β«β»_(erase s i), f βΞΌ) (Function.update x i xα΅’) βΞΌ i := by | simpa [insert_erase hi] using lmarginal_insert _ hf (not_mem_erase i s) x |
/-
Copyright (c) 2022 Mantas BakΕ‘ys. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mantas BakΕ‘ys
-/
import Mathlib.Algebra.Order.Module.OrderedSMul
import Mathlib.Algebra.Order.Module.Synonym
import Mathlib.Data.Prod.Lex
import Mathlib.Data.Set.Image
import Mathlib.Data.Finset.Max
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Order.Monotone.Monovary
import Mathlib.Tactic.Abel
/-!
# Rearrangement inequality
This file proves the rearrangement inequality and deduces the conditions for equality and strict
inequality.
The rearrangement inequality tells you that for two functions `f g : ΞΉ β Ξ±`, the sum
`β i, f i * g (Ο i)` is maximized over all `Ο : Perm ΞΉ` when `g β Ο` monovaries with `f` and
minimized when `g β Ο` antivaries with `f`.
The inequality also tells you that `β i, f i * g (Ο i) = β i, f i * g i` if and only if `g β Ο`
monovaries with `f` when `g` monovaries with `f`. The above equality also holds if and only if
`g β Ο` antivaries with `f` when `g` antivaries with `f`.
From the above two statements, we deduce that the inequality is strict if and only if `g β Ο` does
not monovary with `f` when `g` monovaries with `f`. Analogously, the inequality is strict if and
only if `g β Ο` does not antivary with `f` when `g` antivaries with `f`.
## Implementation notes
In fact, we don't need much compatibility between the addition and multiplication of `Ξ±`, so we can
actually decouple them by replacing multiplication with scalar multiplication and making `f` and `g`
land in different types.
As a bonus, this makes the dual statement trivial. The multiplication versions are provided for
convenience.
The case for `Monotone`/`Antitone` pairs of functions over a `LinearOrder` is not deduced in this
file because it is easily deducible from the `Monovary` API.
## TODO
Add equality cases for when the permute function is injective. This comes from the following fact:
If `Monovary f g`, `Injective g` and `Ο` is a permutation, then `Monovary f (g β Ο) β Ο = 1`.
-/
open Equiv Equiv.Perm Finset Function OrderDual
variable {ΞΉ Ξ± Ξ² : Type*} [Semiring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±] [ExistsAddOfLE Ξ±]
[AddCommMonoid Ξ²] [LinearOrder Ξ²] [IsOrderedCancelAddMonoid Ξ²] [Module Ξ± Ξ²]
/-! ### Scalar multiplication versions -/
section SMul
/-! #### Weak rearrangement inequality -/
section weak_inequality
variable [PosSMulMono Ξ± Ξ²] {s : Finset ΞΉ} {Ο : Perm ΞΉ} {f : ΞΉ β Ξ±} {g : ΞΉ β Ξ²}
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is maximized when
`f` and `g` monovary together on `s`. Stated by permuting the entries of `g`. -/
theorem MonovaryOn.sum_smul_comp_perm_le_sum_smul (hfg : MonovaryOn f g s)
(hΟ : {x | Ο x β x} β s) : β i β s, f i β’ g (Ο i) β€ β i β s, f i β’ g i := by
classical
revert hΟ Ο hfg
apply Finset.induction_on_max_value (fun i β¦ toLex (g i, f i))
(p := fun t β¦ β {Ο : Perm ΞΉ}, MonovaryOn f g t β {x | Ο x β x} β t β
β i β t, f i β’ g (Ο i) β€ β i β t, f i β’ g i) s
Β· simp only [le_rfl, Finset.sum_empty, imp_true_iff]
intro a s has hamax hind Ο hfg hΟ
set Ο : Perm ΞΉ := Ο.trans (swap a (Ο a)) with hΟ
have hΟs : {x | Ο x β x} β s := by
intro x hx
simp only [Ο, Ne, Set.mem_setOf_eq, Equiv.coe_trans, Equiv.swap_comp_apply] at hx
split_ifs at hx with hβ hβ
Β· obtain rfl | hax := eq_or_ne x a
Β· contradiction
Β· exact mem_of_mem_insert_of_ne (hΟ fun h β¦ hax <| h.symm.trans hβ) hax
Β· exact (hx <| Ο.injective hβ.symm).elim
Β· exact mem_of_mem_insert_of_ne (hΟ hx) (ne_of_apply_ne _ hβ)
specialize hind (hfg.subset <| subset_insert _ _) hΟs
simp_rw [sum_insert has]
refine le_trans ?_ (add_le_add_left hind _)
obtain hΟa | hΟa := eq_or_ne a (Ο a)
Β· rw [hΟ, β hΟa, swap_self, trans_refl]
have h1s : Οβ»ΒΉ a β s := by
rw [Ne, β inv_eq_iff_eq] at hΟa
refine mem_of_mem_insert_of_ne (hΟ fun h β¦ hΟa ?_) hΟa
rwa [apply_inv_self, eq_comm] at h
simp only [β s.sum_erase_add _ h1s, add_comm]
rw [β add_assoc, β add_assoc]
simp only [hΟ, swap_apply_left, Function.comp_apply, Equiv.coe_trans, apply_inv_self]
refine add_le_add (smul_add_smul_le_smul_add_smul' ?_ ?_) (sum_congr rfl fun x hx β¦ ?_).le
Β· specialize hamax (Οβ»ΒΉ a) h1s
rw [Prod.Lex.toLex_le_toLex] at hamax
rcases hamax with hamax | hamax
Β· exact hfg (mem_insert_of_mem h1s) (mem_insert_self _ _) hamax
Β· exact hamax.2
Β· specialize hamax (Ο a) (mem_of_mem_insert_of_ne (hΟ <| Ο.injective.ne hΟa.symm) hΟa.symm)
rw [Prod.Lex.toLex_le_toLex] at hamax
rcases hamax with hamax | hamax
Β· exact hamax.le
Β· exact hamax.1.le
Β· rw [mem_erase, Ne, eq_inv_iff_eq] at hx
rw [swap_apply_of_ne_of_ne hx.1 (Ο.injective.ne _)]
rintro rfl
exact has hx.2
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when
`f` and `g` antivary together on `s`. Stated by permuting the entries of `g`. -/
theorem AntivaryOn.sum_smul_le_sum_smul_comp_perm (hfg : AntivaryOn f g s)
(hΟ : {x | Ο x β x} β s) : β i β s, f i β’ g i β€ β i β s, f i β’ g (Ο i) :=
hfg.dual_right.sum_smul_comp_perm_le_sum_smul hΟ
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is maximized when
`f` and `g` monovary together on `s`. Stated by permuting the entries of `f`. -/
theorem MonovaryOn.sum_comp_perm_smul_le_sum_smul (hfg : MonovaryOn f g s)
(hΟ : {x | Ο x β x} β s) : β i β s, f (Ο i) β’ g i β€ β i β s, f i β’ g i := by
convert hfg.sum_smul_comp_perm_le_sum_smul
(show { x | Οβ»ΒΉ x β x } β s by simp only [set_support_inv_eq, hΟ]) using 1
exact Ο.sum_comp' s (fun i j β¦ f i β’ g j) hΟ
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when
`f` and `g` antivary together on `s`. Stated by permuting the entries of `f`. -/
theorem AntivaryOn.sum_smul_le_sum_comp_perm_smul (hfg : AntivaryOn f g s)
(hΟ : {x | Ο x β x} β s) : β i β s, f i β’ g i β€ β i β s, f (Ο i) β’ g i :=
hfg.dual_right.sum_comp_perm_smul_le_sum_smul hΟ
variable [Fintype ΞΉ]
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is maximized when
`f` and `g` monovary together. Stated by permuting the entries of `g`. -/
theorem Monovary.sum_smul_comp_perm_le_sum_smul (hfg : Monovary f g) :
β i, f i β’ g (Ο i) β€ β i, f i β’ g i :=
(hfg.monovaryOn _).sum_smul_comp_perm_le_sum_smul fun _ _ β¦ mem_univ _
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when
`f` and `g` antivary together. Stated by permuting the entries of `g`. -/
theorem Antivary.sum_smul_le_sum_smul_comp_perm (hfg : Antivary f g) :
β i, f i β’ g i β€ β i, f i β’ g (Ο i) :=
(hfg.antivaryOn _).sum_smul_le_sum_smul_comp_perm fun _ _ β¦ mem_univ _
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is maximized when
`f` and `g` monovary together. Stated by permuting the entries of `f`. -/
theorem Monovary.sum_comp_perm_smul_le_sum_smul (hfg : Monovary f g) :
β i, f (Ο i) β’ g i β€ β i, f i β’ g i :=
(hfg.monovaryOn _).sum_comp_perm_smul_le_sum_smul fun _ _ β¦ mem_univ _
/-- **Rearrangement Inequality**: Pointwise scalar multiplication of `f` and `g` is minimized when
`f` and `g` antivary together. Stated by permuting the entries of `f`. -/
theorem Antivary.sum_smul_le_sum_comp_perm_smul (hfg : Antivary f g) :
β i, f i β’ g i β€ β i, f (Ο i) β’ g i :=
(hfg.antivaryOn _).sum_smul_le_sum_comp_perm_smul fun _ _ β¦ mem_univ _
end weak_inequality
/-! #### Equality case of the rearrangement inequality -/
section equality_case
variable [PosSMulStrictMono Ξ± Ξ²] {s : Finset ΞΉ} {Ο : Perm ΞΉ} {f : ΞΉ β Ξ±} {g : ΞΉ β Ξ²}
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which monovary together on `s`, is unchanged by a permutation if and only if `f` and `g β Ο`
monovary together on `s`. Stated by permuting the entries of `g`. -/
theorem MonovaryOn.sum_smul_comp_perm_eq_sum_smul_iff (hfg : MonovaryOn f g s)
(hΟ : {x | Ο x β x} β s) :
β i β s, f i β’ g (Ο i) = β i β s, f i β’ g i β MonovaryOn f (g β Ο) s := by
classical
refine β¨not_imp_not.1 fun h β¦ ?_, fun h β¦ (hfg.sum_smul_comp_perm_le_sum_smul hΟ).antisymm ?_β©
Β· rw [MonovaryOn] at h
push_neg at h
obtain β¨x, hx, y, hy, hgxy, hfxyβ© := h
set Ο : Perm ΞΉ := (Equiv.swap x y).trans Ο
have hΟs : {x | Ο x β x} β s := by
refine (set_support_mul_subset Ο <| swap x y).trans (Set.union_subset hΟ fun z hz β¦ ?_)
obtain β¨_, rfl | rflβ© := swap_apply_ne_self_iff.1 hz <;> assumption
refine ((hfg.sum_smul_comp_perm_le_sum_smul hΟs).trans_lt' ?_).ne
obtain rfl | hxy := eq_or_ne x y
Β· cases lt_irrefl _ hfxy
simp only [Ο, β s.sum_erase_add _ hx,
β (s.erase x).sum_erase_add _ (mem_erase.2 β¨hxy.symm, hyβ©),
add_assoc, Equiv.coe_trans, Function.comp_apply, swap_apply_right, swap_apply_left]
refine add_lt_add_of_le_of_lt (Finset.sum_congr rfl fun z hz β¦ ?_).le
(smul_add_smul_lt_smul_add_smul hfxy hgxy)
simp_rw [mem_erase] at hz
rw [swap_apply_of_ne_of_ne hz.2.1 hz.1]
Β· convert h.sum_smul_comp_perm_le_sum_smul ((set_support_inv_eq _).subset.trans hΟ) using 1
simp_rw [Function.comp_apply, apply_inv_self]
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which antivary together on `s`, is unchanged by a permutation if and only if `f` and `g β Ο`
antivary together on `s`. Stated by permuting the entries of `g`. -/
theorem AntivaryOn.sum_smul_comp_perm_eq_sum_smul_iff (hfg : AntivaryOn f g s)
(hΟ : {x | Ο x β x} β s) :
β i β s, f i β’ g (Ο i) = β i β s, f i β’ g i β AntivaryOn f (g β Ο) s :=
(hfg.dual_right.sum_smul_comp_perm_eq_sum_smul_iff hΟ).trans monovaryOn_toDual_right
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which monovary together on `s`, is unchanged by a permutation if and only if `f β Ο` and `g`
monovary together on `s`. Stated by permuting the entries of `f`. -/
theorem MonovaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : MonovaryOn f g s)
(hΟ : {x | Ο x β x} β s) :
β i β s, f (Ο i) β’ g i = β i β s, f i β’ g i β MonovaryOn (f β Ο) g s := by
have hΟinv : { x | Οβ»ΒΉ x β x } β s := (set_support_inv_eq _).subset.trans hΟ
refine (Iff.trans ?_ <| hfg.sum_smul_comp_perm_eq_sum_smul_iff hΟinv).trans
β¨fun h β¦ ?_, fun h β¦ ?_β©
Β· apply eq_iff_eq_cancel_right.2
rw [Ο.sum_comp' s (fun i j β¦ f i β’ g j) hΟ]
congr
Β· convert h.comp_right Ο
Β· rw [comp_assoc, inv_def, symm_comp_self, comp_id]
Β· rw [Ο.eq_preimage_iff_image_eq, Set.image_perm hΟ]
Β· convert h.comp_right Ο.symm
Β· rw [comp_assoc, self_comp_symm, comp_id]
Β· rw [Ο.symm.eq_preimage_iff_image_eq]
exact Set.image_perm hΟinv
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which antivary together on `s`, is unchanged by a permutation if and only if `f β Ο` and `g`
antivary together on `s`. Stated by permuting the entries of `f`. -/
theorem AntivaryOn.sum_comp_perm_smul_eq_sum_smul_iff (hfg : AntivaryOn f g s)
(hΟ : {x | Ο x β x} β s) :
β i β s, f (Ο i) β’ g i = β i β s, f i β’ g i β AntivaryOn (f β Ο) g s :=
(hfg.dual_right.sum_comp_perm_smul_eq_sum_smul_iff hΟ).trans monovaryOn_toDual_right
variable [Fintype ΞΉ]
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which monovary together, is unchanged by a permutation if and only if `f` and `g β Ο` monovary
together. Stated by permuting the entries of `g`. -/
theorem Monovary.sum_smul_comp_perm_eq_sum_smul_iff (hfg : Monovary f g) :
β i, f i β’ g (Ο i) = β i, f i β’ g i β Monovary f (g β Ο) := by
simp [(hfg.monovaryOn _).sum_smul_comp_perm_eq_sum_smul_iff fun _ _ β¦ mem_univ _]
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and
`g`, which monovary together, is unchanged by a permutation if and only if `f β Ο` and `g` monovary
together. Stated by permuting the entries of `g`. -/
| Mathlib/Algebra/Order/Rearrangement.lean | 243 | 247 | theorem Monovary.sum_comp_perm_smul_eq_sum_smul_iff (hfg : Monovary f g) :
β i, f (Ο i) β’ g i = β i, f i β’ g i β Monovary (f β Ο) g := by | simp [(hfg.monovaryOn _).sum_comp_perm_smul_eq_sum_smul_iff fun _ _ β¦ mem_univ _]
/-- **Equality case of the Rearrangement Inequality**: Pointwise scalar multiplication of `f` and |
/-
Copyright (c) 2022 Julian Kuelshammer. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Julian Kuelshammer
-/
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.Algebra.BigOperators.NatAntidiagonal
import Mathlib.Data.Nat.Choose.Central
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.GCongr
import Mathlib.Tactic.Positivity
/-!
# Catalan numbers
The Catalan numbers (http://oeis.org/A000108) are probably the most ubiquitous sequence of integers
in mathematics. They enumerate several important objects like binary trees, Dyck paths, and
triangulations of convex polygons.
## Main definitions
* `catalan n`: the `n`th Catalan number, defined recursively as
`catalan (n + 1) = β i : Fin n.succ, catalan i * catalan (n - i)`.
## Main results
* `catalan_eq_centralBinom_div`: The explicit formula for the Catalan number using the central
binomial coefficient, `catalan n = Nat.centralBinom n / (n + 1)`.
* `treesOfNumNodesEq_card_eq_catalan`: The number of binary trees with `n` internal nodes
is `catalan n`
## Implementation details
The proof of `catalan_eq_centralBinom_div` follows https://math.stackexchange.com/questions/3304415
## TODO
* Prove that the Catalan numbers enumerate many interesting objects.
* Provide the many variants of Catalan numbers, e.g. associated to complex reflection groups,
Fuss-Catalan, etc.
-/
open Finset
open Finset.antidiagonal (fst_le snd_le)
/-- The recursive definition of the sequence of Catalan numbers:
`catalan (n + 1) = β i : Fin n.succ, catalan i * catalan (n - i)` -/
def catalan : β β β
| 0 => 1
| n + 1 =>
β i : Fin n.succ,
catalan i * catalan (n - i)
@[simp]
theorem catalan_zero : catalan 0 = 1 := by rw [catalan]
theorem catalan_succ (n : β) : catalan (n + 1) = β i : Fin n.succ, catalan i * catalan (n - i) := by
rw [catalan]
theorem catalan_succ' (n : β) :
catalan (n + 1) = β ij β antidiagonal n, catalan ij.1 * catalan ij.2 := by
rw [catalan_succ, Nat.sum_antidiagonal_eq_sum_range_succ (fun x y => catalan x * catalan y) n,
sum_range]
@[simp]
theorem catalan_one : catalan 1 = 1 := by simp [catalan_succ]
/-- A helper sequence that can be used to prove the equality of the recursive and the explicit
definition using a telescoping sum argument. -/
private def gosperCatalan (n j : β) : β :=
Nat.centralBinom j * Nat.centralBinom (n - j) * (2 * j - n) / (2 * n * (n + 1))
private theorem gosper_trick {n i : β} (h : i β€ n) :
gosperCatalan (n + 1) (i + 1) - gosperCatalan (n + 1) i =
Nat.centralBinom i / (i + 1) * Nat.centralBinom (n - i) / (n - i + 1) := by
have lβ : (i : β) + 1 β 0 := by norm_cast
have lβ : (n : β) - i + 1 β 0 := by norm_cast
have hβ := (mul_div_cancel_leftβ (β(Nat.centralBinom (i + 1))) lβ).symm
have hβ := (mul_div_cancel_leftβ (β(Nat.centralBinom (n - i + 1))) lβ).symm
have hβ : ((i : β) + 1) * (i + 1).centralBinom = 2 * (2 * i + 1) * i.centralBinom :=
mod_cast Nat.succ_mul_centralBinom_succ i
have hβ :
((n : β) - i + 1) * (n - i + 1).centralBinom = 2 * (2 * (n - i) + 1) * (n - i).centralBinom :=
mod_cast Nat.succ_mul_centralBinom_succ (n - i)
simp only [gosperCatalan]
push_cast
rw [show n + 1 - i = n - i + 1 by rw [Nat.add_comm (n - i) 1, β (Nat.add_sub_assoc h 1),
add_comm]]
rw [hβ, hβ, hβ, hβ]
field_simp
ring
private theorem gosper_catalan_sub_eq_central_binom_div (n : β) : gosperCatalan (n + 1) (n + 1) -
gosperCatalan (n + 1) 0 = Nat.centralBinom (n + 1) / (n + 2) := by
have : (n : β) + 1 β 0 := by norm_cast
have : (n : β) + 1 + 1 β 0 := by norm_cast
have h : (n : β) + 2 β 0 := by norm_cast
simp only [gosperCatalan, Nat.sub_zero, Nat.centralBinom_zero, Nat.sub_self]
field_simp
ring
theorem catalan_eq_centralBinom_div (n : β) : catalan n = n.centralBinom / (n + 1) := by
suffices (catalan n : β) = Nat.centralBinom n / (n + 1) by
have h := Nat.succ_dvd_centralBinom n
exact mod_cast this
induction n using Nat.caseStrongRecOn with
| zero => simp
| ind d hd =>
simp_rw [catalan_succ, Nat.cast_sum, Nat.cast_mul]
trans (β i : Fin d.succ, Nat.centralBinom i / (i + 1) *
(Nat.centralBinom (d - i) / (d - i + 1)) : β)
Β· congr
ext1 x
have m_le_d : x.val β€ d := by omega
have d_minus_x_le_d : (d - x.val) β€ d := tsub_le_self
rw [hd _ m_le_d, hd _ d_minus_x_le_d]
norm_cast
Β· trans (β i : Fin d.succ, (gosperCatalan (d + 1) (i + 1) - gosperCatalan (d + 1) i))
Β· refine sum_congr rfl fun i _ => ?_
rw [gosper_trick i.is_le, mul_div]
Β· rw [β sum_range fun i => gosperCatalan (d + 1) (i + 1) - gosperCatalan (d + 1) i,
sum_range_sub, Nat.succ_eq_add_one]
rw [gosper_catalan_sub_eq_central_binom_div d]
norm_cast
theorem succ_mul_catalan_eq_centralBinom (n : β) : (n + 1) * catalan n = n.centralBinom :=
(Nat.eq_mul_of_div_eq_right n.succ_dvd_centralBinom (catalan_eq_centralBinom_div n).symm).symm
theorem catalan_two : catalan 2 = 2 := by
norm_num [catalan_eq_centralBinom_div, Nat.centralBinom, Nat.choose]
theorem catalan_three : catalan 3 = 5 := by
norm_num [catalan_eq_centralBinom_div, Nat.centralBinom, Nat.choose]
namespace Tree
/-- Given two finsets, find all trees that can be formed with
left child in `a` and right child in `b` -/
abbrev pairwiseNode (a b : Finset (Tree Unit)) : Finset (Tree Unit) :=
(a ΓΛ’ b).map β¨fun x => x.1 β³ x.2, fun β¨xβ, xββ© β¨yβ, yββ© => fun h => by simpa using hβ©
/-- A Finset of all trees with `n` nodes. See `mem_treesOfNodesEq` -/
def treesOfNumNodesEq : β β Finset (Tree Unit)
| 0 => {nil}
| n + 1 =>
(antidiagonal n).attach.biUnion fun ijh =>
pairwiseNode (treesOfNumNodesEq ijh.1.1) (treesOfNumNodesEq ijh.1.2)
decreasing_by
Β· simp_wf; have := fst_le ijh.2; omega
Β· simp_wf; have := snd_le ijh.2; omega
@[simp]
theorem treesOfNumNodesEq_zero : treesOfNumNodesEq 0 = {nil} := by rw [treesOfNumNodesEq]
theorem treesOfNumNodesEq_succ (n : β) :
treesOfNumNodesEq (n + 1) =
(antidiagonal n).biUnion fun ij =>
pairwiseNode (treesOfNumNodesEq ij.1) (treesOfNumNodesEq ij.2) := by
rw [treesOfNumNodesEq]
ext
simp
@[simp]
theorem mem_treesOfNumNodesEq {x : Tree Unit} {n : β} :
x β treesOfNumNodesEq n β x.numNodes = n := by
induction x using Tree.unitRecOn generalizing n <;> cases n <;>
simp [treesOfNumNodesEq_succ, *]
theorem mem_treesOfNumNodesEq_numNodes (x : Tree Unit) : x β treesOfNumNodesEq x.numNodes :=
mem_treesOfNumNodesEq.mpr rfl
@[simp, norm_cast]
theorem coe_treesOfNumNodesEq (n : β) :
β(treesOfNumNodesEq n) = { x : Tree Unit | x.numNodes = n } :=
Set.ext (by simp)
| Mathlib/Combinatorics/Enumerative/Catalan.lean | 181 | 187 | theorem treesOfNumNodesEq_card_eq_catalan (n : β) : #(treesOfNumNodesEq n) = catalan n := by | induction n using Nat.case_strong_induction_on with
| hz => simp
| hi n ih =>
rw [treesOfNumNodesEq_succ, card_biUnion, catalan_succ']
Β· apply sum_congr rfl
rintro β¨i, jβ© H |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle SΓΆnne, Benjamin Davidson
-/
import Mathlib.Analysis.SpecialFunctions.Complex.Arg
import Mathlib.Analysis.SpecialFunctions.Log.Basic
/-!
# The complex `log` function
Basic properties, relationship with `exp`.
-/
noncomputable section
namespace Complex
open Set Filter Bornology
open scoped Real Topology ComplexConjugate
/-- Inverse of the `exp` function. Returns values such that `(log x).im > - Ο` and `(log x).im β€ Ο`.
`log 0 = 0` -/
@[pp_nodot]
noncomputable def log (x : β) : β :=
Real.log βxβ + arg x * I
theorem log_re (x : β) : x.log.re = Real.log βxβ := by simp [log]
theorem log_im (x : β) : x.log.im = x.arg := by simp [log]
theorem neg_pi_lt_log_im (x : β) : -Ο < (log x).im := by simp only [log_im, neg_pi_lt_arg]
theorem log_im_le_pi (x : β) : (log x).im β€ Ο := by simp only [log_im, arg_le_pi]
theorem exp_log {x : β} (hx : x β 0) : exp (log x) = x := by
rw [log, exp_add_mul_I, β ofReal_sin, sin_arg, β ofReal_cos, cos_arg hx, β ofReal_exp,
Real.exp_log (norm_pos_iff.mpr hx), mul_add, ofReal_div, ofReal_div,
mul_div_cancelβ _ (ofReal_ne_zero.2 <| norm_ne_zero_iff.mpr hx), β mul_assoc,
mul_div_cancelβ _ (ofReal_ne_zero.2 <| norm_ne_zero_iff.mpr hx), re_add_im]
@[simp]
theorem range_exp : Set.range exp = {0}αΆ :=
Set.ext fun x =>
β¨by
rintro β¨x, rflβ©
exact exp_ne_zero x, fun hx => β¨log x, exp_log hxβ©β©
theorem log_exp {x : β} (hxβ : -Ο < x.im) (hxβ : x.im β€ Ο) : log (exp x) = x := by
rw [log, norm_exp, Real.log_exp, exp_eq_exp_re_mul_sin_add_cos, β ofReal_exp,
arg_mul_cos_add_sin_mul_I (Real.exp_pos _) β¨hxβ, hxββ©, re_add_im]
theorem exp_inj_of_neg_pi_lt_of_le_pi {x y : β} (hxβ : -Ο < x.im) (hxβ : x.im β€ Ο) (hyβ : -Ο < y.im)
(hyβ : y.im β€ Ο) (hxy : exp x = exp y) : x = y := by
rw [β log_exp hxβ hxβ, β log_exp hyβ hyβ, hxy]
theorem ofReal_log {x : β} (hx : 0 β€ x) : (x.log : β) = log x :=
Complex.ext (by rw [log_re, ofReal_re, Complex.norm_of_nonneg hx])
(by rw [ofReal_im, log_im, arg_ofReal_of_nonneg hx])
@[simp, norm_cast]
lemma natCast_log {n : β} : Real.log n = log n := ofReal_natCast n βΈ ofReal_log n.cast_nonneg
@[simp]
lemma ofNat_log {n : β} [n.AtLeastTwo] :
Real.log ofNat(n) = log (OfNat.ofNat n) :=
natCast_log
theorem log_ofReal_re (x : β) : (log (x : β)).re = Real.log x := by simp [log_re]
theorem log_ofReal_mul {r : β} (hr : 0 < r) {x : β} (hx : x β 0) :
log (r * x) = Real.log r + log x := by
replace hx := norm_ne_zero_iff.mpr hx
simp_rw [log, norm_mul, norm_real, arg_real_mul _ hr, Real.norm_of_nonneg hr.le,
Real.log_mul hr.ne' hx, ofReal_add, add_assoc]
theorem log_mul_ofReal (r : β) (hr : 0 < r) (x : β) (hx : x β 0) :
log (x * r) = Real.log r + log x := by rw [mul_comm, log_ofReal_mul hr hx]
lemma log_mul_eq_add_log_iff {x y : β} (hxβ : x β 0) (hyβ : y β 0) :
log (x * y) = log x + log y β arg x + arg y β Set.Ioc (-Ο) Ο := by
refine Complex.ext_iff.trans <| Iff.trans ?_ <| arg_mul_eq_add_arg_iff hxβ hyβ
simp_rw [add_re, add_im, log_re, log_im, norm_mul,
Real.log_mul (norm_ne_zero_iff.mpr hxβ) (norm_ne_zero_iff.mpr hyβ), true_and]
alias β¨_, log_mulβ© := log_mul_eq_add_log_iff
@[simp]
theorem log_zero : log 0 = 0 := by simp [log]
@[simp]
| Mathlib/Analysis/SpecialFunctions/Complex/Log.lean | 93 | 94 | theorem log_one : log 1 = 0 := by | simp [log] |
/-
Copyright (c) 2019 Oliver Nash. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Oliver Nash
-/
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Module.Submodule.Equiv
import Mathlib.Algebra.Module.Equiv.Basic
import Mathlib.Algebra.Module.Rat
import Mathlib.Data.Bracket
import Mathlib.Tactic.Abel
/-!
# Lie algebras
This file defines Lie rings and Lie algebras over a commutative ring together with their
modules, morphisms and equivalences, as well as various lemmas to make these definitions usable.
## Main definitions
* `LieRing`
* `LieAlgebra`
* `LieRingModule`
* `LieModule`
* `LieHom`
* `LieEquiv`
* `LieModuleHom`
* `LieModuleEquiv`
## Notation
Working over a fixed commutative ring `R`, we introduce the notations:
* `L βββ
Rβ L'` for a morphism of Lie algebras,
* `L βββ
Rβ L'` for an equivalence of Lie algebras,
* `M βββ
R,Lβ N` for a morphism of Lie algebra modules `M`, `N` over a Lie algebra `L`,
* `M βββ
R,Lβ N` for an equivalence of Lie algebra modules `M`, `N` over a Lie algebra `L`.
## Implementation notes
Lie algebras are defined as modules with a compatible Lie ring structure and thus, like modules,
are partially unbundled.
## References
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 1--3*](bourbaki1975)
## Tags
lie bracket, jacobi identity, lie ring, lie algebra, lie module
-/
universe u v w wβ wβ
open Function
/-- A Lie ring is an additive group with compatible product, known as the bracket, satisfying the
Jacobi identity. -/
class LieRing (L : Type v) extends AddCommGroup L, Bracket L L where
/-- A Lie ring bracket is additive in its first component. -/
protected add_lie : β x y z : L, β
x + y, zβ = β
x, zβ + β
y, zβ
/-- A Lie ring bracket is additive in its second component. -/
protected lie_add : β x y z : L, β
x, y + zβ = β
x, yβ + β
x, zβ
/-- A Lie ring bracket vanishes on the diagonal in L Γ L. -/
protected lie_self : β x : L, β
x, xβ = 0
/-- A Lie ring bracket satisfies a Leibniz / Jacobi identity. -/
protected leibniz_lie : β x y z : L, β
x, β
y, zββ = β
β
x, yβ, zβ + β
y, β
x, zββ
/-- A Lie algebra is a module with compatible product, known as the bracket, satisfying the Jacobi
identity. Forgetting the scalar multiplication, every Lie algebra is a Lie ring. -/
@[ext] class LieAlgebra (R : Type u) (L : Type v) [CommRing R] [LieRing L] extends Module R L where
/-- A Lie algebra bracket is compatible with scalar multiplication in its second argument.
The compatibility in the first argument is not a class property, but follows since every
Lie algebra has a natural Lie module action on itself, see `LieModule`. -/
protected lie_smul : β (t : R) (x y : L), β
x, t β’ yβ = t β’ β
x, yβ
/-- A Lie ring module is an additive group, together with an additive action of a
Lie ring on this group, such that the Lie bracket acts as the commutator of endomorphisms.
(For representations of Lie *algebras* see `LieModule`.) -/
class LieRingModule (L : Type v) (M : Type w) [LieRing L] [AddCommGroup M] extends Bracket L M where
/-- A Lie ring module bracket is additive in its first component. -/
protected add_lie : β (x y : L) (m : M), β
x + y, mβ = β
x, mβ + β
y, mβ
/-- A Lie ring module bracket is additive in its second component. -/
protected lie_add : β (x : L) (m n : M), β
x, m + nβ = β
x, mβ + β
x, nβ
/-- A Lie ring module bracket satisfies a Leibniz / Jacobi identity. -/
protected leibniz_lie : β (x y : L) (m : M), β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ
/-- A Lie module is a module over a commutative ring, together with a linear action of a Lie
algebra on this module, such that the Lie bracket acts as the commutator of endomorphisms. -/
class LieModule (R : Type u) (L : Type v) (M : Type w) [CommRing R] [LieRing L] [LieAlgebra R L]
[AddCommGroup M] [Module R M] [LieRingModule L M] : Prop where
/-- A Lie module bracket is compatible with scalar multiplication in its first argument. -/
protected smul_lie : β (t : R) (x : L) (m : M), β
t β’ x, mβ = t β’ β
x, mβ
/-- A Lie module bracket is compatible with scalar multiplication in its second argument. -/
protected lie_smul : β (t : R) (x : L) (m : M), β
x, t β’ mβ = t β’ β
x, mβ
/-- A tower of Lie bracket actions encapsulates the Leibniz rule for Lie bracket actions.
More precisely, it does so in a relative setting:
Let `Lβ` and `Lβ` be two types with Lie bracket actions on a type `M` endowed with an addition,
and additionally assume a Lie bracket action of `Lβ` on `Lβ`.
Then the Leibniz rule asserts for all `x : Lβ`, `y : Lβ`, and `m : M` that
`β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ` holds.
Common examples include the case where `Lβ` is a Lie subalgebra of `Lβ`
and the case where `Lβ` is a Lie ideal of `Lβ`. -/
class IsLieTower (Lβ Lβ M : Type*) [Bracket Lβ Lβ] [Bracket Lβ M] [Bracket Lβ M] [Add M] where
protected leibniz_lie (x : Lβ) (y : Lβ) (m : M) : β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ
section IsLieTower
variable {Lβ Lβ M : Type*} [Bracket Lβ Lβ] [Bracket Lβ M] [Bracket Lβ M]
lemma leibniz_lie [Add M] [IsLieTower Lβ Lβ M] (x : Lβ) (y : Lβ) (m : M) :
β
x, β
y, mββ = β
β
x, yβ, mβ + β
y, β
x, mββ := IsLieTower.leibniz_lie x y m
lemma lie_swap_lie [Bracket Lβ Lβ] [AddCommGroup M] [IsLieTower Lβ Lβ M] [IsLieTower Lβ Lβ M]
(x : Lβ) (y : Lβ) (m : M) : β
β
x, yβ, mβ = -β
β
y, xβ, mβ := by
have h1 := leibniz_lie x y m
have h2 := leibniz_lie y x m
convert congr($h1.symm - $h2) using 1 <;> simp only [add_sub_cancel_right, sub_add_cancel_right]
end IsLieTower
section BasicProperties
theorem LieAlgebra.toModule_injective (L : Type*) [LieRing L] :
Function.Injective (@LieAlgebra.toModule _ _ _ _ : LieAlgebra β L β Module β L) := by
rintro β¨hββ© β¨hββ© heq
congr
instance (L : Type*) [LieRing L] : Subsingleton (LieAlgebra β L) :=
LieAlgebra.toModule_injective L |>.subsingleton
variable {R : Type u} {L : Type v} {M : Type w} {N : Type wβ}
variable [CommRing R] [LieRing L] [LieAlgebra R L]
variable [AddCommGroup M] [Module R M] [LieRingModule L M] [LieModule R L M]
variable [AddCommGroup N] [Module R N] [LieRingModule L N] [LieModule R L N]
variable (t : R) (x y z : L) (m n : M)
@[simp]
theorem add_lie : β
x + y, mβ = β
x, mβ + β
y, mβ :=
LieRingModule.add_lie x y m
@[simp]
theorem lie_add : β
x, m + nβ = β
x, mβ + β
x, nβ :=
LieRingModule.lie_add x m n
@[simp]
theorem smul_lie : β
t β’ x, mβ = t β’ β
x, mβ :=
LieModule.smul_lie t x m
@[simp]
theorem lie_smul : β
x, t β’ mβ = t β’ β
x, mβ :=
LieModule.lie_smul t x m
instance : IsLieTower L L M where
leibniz_lie x y m := LieRingModule.leibniz_lie x y m
@[simp]
theorem lie_zero : β
x, 0β = (0 : M) :=
(AddMonoidHom.mk' _ (lie_add x)).map_zero
@[simp]
theorem zero_lie : β
(0 : L), mβ = 0 :=
(AddMonoidHom.mk' (fun x : L => β
x, mβ) fun x y => add_lie x y m).map_zero
@[simp]
theorem lie_self : β
x, xβ = 0 :=
LieRing.lie_self x
instance lieRingSelfModule : LieRingModule L L :=
{ (inferInstance : LieRing L) with }
@[simp]
| Mathlib/Algebra/Lie/Basic.lean | 176 | 176 | theorem lie_skew : -β
y, xβ = β
x, yβ := by | |
/-
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.Data.Sigma.Basic
import Mathlib.Algebra.Order.Ring.Nat
/-!
# A computable model of ZFA without infinity
In this file we define finite hereditary lists. This is useful for calculations in naive set theory.
We distinguish two kinds of ZFA lists:
* Atoms. Directly correspond to an element of the original type.
* Proper ZFA lists. Can be thought of (but aren't implemented) as a list of ZFA lists (not
necessarily proper).
For example, `Lists β` contains stuff like `23`, `[]`, `[37]`, `[1, [[2], 3], 4]`.
## Implementation note
As we want to be able to append both atoms and proper ZFA lists to proper ZFA lists, it's handy that
atoms and proper ZFA lists belong to the same type, even though atoms of `Ξ±` could be modelled as
`Ξ±` directly. But we don't want to be able to append anything to atoms.
This calls for a two-steps definition of ZFA lists:
* First, define ZFA prelists as atoms and proper ZFA prelists. Those proper ZFA prelists are defined
by inductive appending of (not necessarily proper) ZFA lists.
* Second, define ZFA lists by rubbing out the distinction between atoms and proper lists.
## Main declarations
* `Lists' Ξ± false`: Atoms as ZFA prelists. Basically a copy of `Ξ±`.
* `Lists' Ξ± true`: Proper ZFA prelists. Defined inductively from the empty ZFA prelist
(`Lists'.nil`) and from appending a ZFA prelist to a proper ZFA prelist (`Lists'.cons a l`).
* `Lists Ξ±`: ZFA lists. Sum of the atoms and proper ZFA prelists.
* `Finsets Ξ±`: ZFA sets. Defined as `Lists` quotiented by `Lists.Equiv`, the extensional
equivalence.
-/
variable {Ξ± : Type*}
/-- Prelists, helper type to define `Lists`. `Lists' Ξ± false` are the "atoms", a copy of `Ξ±`.
`Lists' Ξ± true` are the "proper" ZFA prelists, inductively defined from the empty ZFA prelist and
from appending a ZFA prelist to a proper ZFA prelist. It is made so that you can't append anything
to an atom while having only one appending function for appending both atoms and proper ZFC prelists
to a proper ZFA prelist. -/
inductive Lists'.{u} (Ξ± : Type u) : Bool β Type u
| atom : Ξ± β Lists' Ξ± false
| nil : Lists' Ξ± true
| cons' {b} : Lists' Ξ± b β Lists' Ξ± true β Lists' Ξ± true
deriving DecidableEq
compile_inductive% Lists'
/-- Hereditarily finite list, aka ZFA list. A ZFA list is either an "atom" (`b = false`),
corresponding to an element of `Ξ±`, or a "proper" ZFA list, inductively defined from the empty ZFA
list and from appending a ZFA list to a proper ZFA list. -/
def Lists (Ξ± : Type*) :=
Ξ£b, Lists' Ξ± b
namespace Lists'
instance [Inhabited Ξ±] : β b, Inhabited (Lists' Ξ± b)
| true => β¨nilβ©
| false => β¨atom defaultβ©
/-- Appending a ZFA list to a proper ZFA prelist. -/
def cons : Lists Ξ± β Lists' Ξ± true β Lists' Ξ± true
| β¨_, aβ©, l => cons' a l
/-- Converts a ZFA prelist to a `List` of ZFA lists. Atoms are sent to `[]`. -/
@[simp]
def toList : β {b}, Lists' Ξ± b β List (Lists Ξ±)
| _, atom _ => []
| _, nil => []
| _, cons' a l => β¨_, aβ© :: l.toList
@[simp]
theorem toList_cons (a : Lists Ξ±) (l) : toList (cons a l) = a :: l.toList := rfl
/-- Converts a `List` of ZFA lists to a proper ZFA prelist. -/
@[simp]
def ofList : List (Lists Ξ±) β Lists' Ξ± true
| [] => nil
| a :: l => cons a (ofList l)
@[simp]
theorem to_ofList (l : List (Lists Ξ±)) : toList (ofList l) = l := by induction l <;> simp [*]
@[simp]
theorem of_toList : β l : Lists' Ξ± true, ofList (toList l) = l :=
suffices
β (b) (h : true = b) (l : Lists' Ξ± b),
let l' : Lists' Ξ± true := by rw [h]; exact l
ofList (toList l') = l'
from this _ rfl
fun b h l => by
induction l with
| atom => cases h
| nil => simp
| cons' b a _ IH => simpa [cons] using IH rfl
end Lists'
mutual
/-- Equivalence of ZFA lists. Defined inductively. -/
inductive Lists.Equiv : Lists Ξ± β Lists Ξ± β Prop
| refl (l) : Lists.Equiv l l
| antisymm {lβ lβ : Lists' Ξ± true} :
Lists'.Subset lβ lβ β Lists'.Subset lβ lβ β Lists.Equiv β¨_, lββ© β¨_, lββ©
/-- Subset relation for ZFA lists. Defined inductively. -/
inductive Lists'.Subset : Lists' Ξ± true β Lists' Ξ± true β Prop
| nil {l} : Lists'.Subset Lists'.nil l
| cons {a a' l l'} :
Lists.Equiv a a' β
a' β Lists'.toList l' β Lists'.Subset l l' β Lists'.Subset (Lists'.cons a l) l'
end
local infixl:50 " ~ " => Lists.Equiv
namespace Lists'
instance : HasSubset (Lists' Ξ± true) :=
β¨Lists'.Subsetβ©
/-- ZFA prelist membership. A ZFA list is in a ZFA prelist if some element of this ZFA prelist is
equivalent as a ZFA list to this ZFA list. -/
instance {b} : Membership (Lists Ξ±) (Lists' Ξ± b) :=
β¨fun l a => β a' β l.toList, a ~ a'β©
theorem mem_def {b a} {l : Lists' Ξ± b} : a β l β β a' β l.toList, a ~ a' :=
Iff.rfl
@[simp]
theorem mem_cons {a y l} : a β @cons Ξ± y l β a ~ y β¨ a β l := by
simp [mem_def, or_and_right, exists_or]
theorem cons_subset {a} {lβ lβ : Lists' Ξ± true} : Lists'.cons a lβ β lβ β a β lβ β§ lβ β lβ := by
refine β¨fun h => ?_, fun β¨β¨a', m, eβ©, sβ© => Subset.cons e m sβ©
generalize h' : Lists'.cons a lβ = lβ' at h
obtain - | @β¨a', _, _, _, e, m, sβ© := h
Β· cases a
cases h'
cases a; cases a'; cases h'; exact β¨β¨_, m, eβ©, sβ©
theorem ofList_subset {lβ lβ : List (Lists Ξ±)} (h : lβ β lβ) :
Lists'.ofList lβ β Lists'.ofList lβ := by
induction lβ with
| nil => exact Subset.nil
| cons _ _ lβ_ih =>
refine Subset.cons (Lists.Equiv.refl _) ?_ (lβ_ih (List.subset_of_cons_subset h))
simp only [List.cons_subset] at h; simp [h]
@[refl]
theorem Subset.refl {l : Lists' Ξ± true} : l β l := by
rw [β Lists'.of_toList l]; exact ofList_subset (List.Subset.refl _)
theorem subset_nil {l : Lists' Ξ± true} : l β Lists'.nil β l = Lists'.nil := by
rw [β of_toList l]
induction toList l <;> intro h
Β· rfl
Β· rcases cons_subset.1 h with β¨β¨_, β¨β©, _β©, _β©
theorem mem_of_subset' {a} : β {lβ lβ : Lists' Ξ± true} (_ : lβ β lβ) (_ : a β lβ.toList), a β lβ
| nil, _, Lists'.Subset.nil, h => by cases h
| cons' a0 l0, lβ, s, h => by
obtain - | β¨e, m, sβ© := s
simp only [toList, Sigma.eta, List.find?, List.mem_cons] at h
rcases h with (rfl | h)
Β· exact β¨_, m, eβ©
Β· exact mem_of_subset' s h
theorem subset_def {lβ lβ : Lists' Ξ± true} : lβ β lβ β β a β lβ.toList, a β lβ :=
β¨fun H _ => mem_of_subset' H, fun H => by
rw [β of_toList lβ]
revert H; induction' toList lβ with h t t_ih <;> intro H
Β· exact Subset.nil
Β· simp only [ofList, List.find?, List.mem_cons, forall_eq_or_imp] at *
exact cons_subset.2 β¨H.1, t_ih H.2β©β©
end Lists'
namespace Lists
/-- Sends `a : Ξ±` to the corresponding atom in `Lists Ξ±`. -/
@[match_pattern]
def atom (a : Ξ±) : Lists Ξ± :=
β¨_, Lists'.atom aβ©
/-- Converts a proper ZFA prelist to a ZFA list. -/
@[match_pattern]
def of' (l : Lists' Ξ± true) : Lists Ξ± :=
β¨_, lβ©
/-- Converts a ZFA list to a `List` of ZFA lists. Atoms are sent to `[]`. -/
@[simp]
def toList : Lists Ξ± β List (Lists Ξ±)
| β¨_, lβ© => l.toList
/-- Predicate stating that a ZFA list is proper. -/
def IsList (l : Lists Ξ±) : Prop :=
l.1
/-- Converts a `List` of ZFA lists to a ZFA list. -/
def ofList (l : List (Lists Ξ±)) : Lists Ξ± :=
of' (Lists'.ofList l)
theorem isList_toList (l : List (Lists Ξ±)) : IsList (ofList l) :=
Eq.refl _
theorem to_ofList (l : List (Lists Ξ±)) : toList (ofList l) = l := by simp [ofList, of']
theorem of_toList : β {l : Lists Ξ±}, IsList l β ofList (toList l) = l
| β¨true, lβ©, _ => by simp_all [ofList, of']
instance : Inhabited (Lists Ξ±) :=
β¨of' Lists'.nilβ©
instance [DecidableEq Ξ±] : DecidableEq (Lists Ξ±) := by unfold Lists; infer_instance
instance [SizeOf Ξ±] : SizeOf (Lists Ξ±) := by unfold Lists; infer_instance
/-- A recursion principle for pairs of ZFA lists and proper ZFA prelists. -/
def inductionMut (C : Lists Ξ± β Sort*) (D : Lists' Ξ± true β Sort*)
(C0 : β a, C (atom a)) (C1 : β l, D l β C (of' l))
(D0 : D Lists'.nil) (D1 : β a l, C a β D l β D (Lists'.cons a l)) :
PProd (β l, C l) (β l, D l) := by
suffices
β {b} (l : Lists' Ξ± b),
PProd (C β¨_, lβ©)
(match b, l with
| true, l => D l
| false, _ => PUnit)
by exact β¨fun β¨b, lβ© => (this _).1, fun l => (this l).2β©
intros b l
induction' l with a b a l IHβ IH
Β· exact β¨C0 _, β¨β©β©
Β· exact β¨C1 _ D0, D0β©
Β· have : D (Lists'.cons' a l) := D1 β¨_, _β© _ IHβ.1 IH.2
exact β¨C1 _ this, thisβ©
/-- Membership of ZFA list. A ZFA list belongs to a proper ZFA list if it belongs to the latter as a
proper ZFA prelist. An atom has no members. -/
def mem (a : Lists Ξ±) : Lists Ξ± β Prop
| β¨false, _β© => False
| β¨_, lβ© => a β l
instance : Membership (Lists Ξ±) (Lists Ξ±) where
mem ls l := mem l ls
theorem isList_of_mem {a : Lists Ξ±} : β {l : Lists Ξ±}, a β l β IsList l
| β¨_, Lists'.nilβ©, _ => rfl
| β¨_, Lists'.cons' _ _β©, _ => rfl
theorem Equiv.antisymm_iff {lβ lβ : Lists' Ξ± true} : of' lβ ~ of' lβ β lβ β lβ β§ lβ β lβ := by
refine β¨fun h => ?_, fun β¨hβ, hββ© => Equiv.antisymm hβ hββ©
obtain - | β¨hβ, hββ© := h
Β· simp [Lists'.Subset.refl]
Β· exact β¨hβ, hββ©
attribute [refl] Equiv.refl
theorem equiv_atom {a} {l : Lists Ξ±} : atom a ~ l β atom a = l :=
β¨fun h => by cases h; rfl, fun h => h βΈ Equiv.refl _β©
@[symm]
theorem Equiv.symm {lβ lβ : Lists Ξ±} (h : lβ ~ lβ) : lβ ~ lβ := by
obtain - | β¨hβ, hββ© := h <;> [rfl; exact Equiv.antisymm hβ hβ]
theorem Equiv.trans : β {lβ lβ lβ : Lists Ξ±}, lβ ~ lβ β lβ ~ lβ β lβ ~ lβ := by
let trans := fun lβ : Lists Ξ± => β β¦lβ lββ¦, lβ ~ lβ β lβ ~ lβ β lβ ~ lβ
suffices PProd (β lβ, trans lβ) (β (l : Lists' Ξ± true), β l' β l.toList, trans l') by exact this.1
apply inductionMut
Β· intro a lβ lβ hβ hβ
rwa [β equiv_atom.1 hβ] at hβ
Β· intro lβ IH lβ lβ hβ hβ
obtain - | lβ := id hβ
Β· exact hβ
obtain - | lβ := id hβ
Β· exact hβ
obtain β¨hlβ, hrββ© := Equiv.antisymm_iff.1 hβ
obtain β¨hlβ, hrββ© := Equiv.antisymm_iff.1 hβ
apply Equiv.antisymm_iff.2; constructor <;> apply Lists'.subset_def.2
Β· intro aβ mβ
rcases Lists'.mem_of_subset' hlβ mβ with β¨aβ, mβ, eβββ©
rcases Lists'.mem_of_subset' hlβ mβ with β¨aβ, mβ, eβββ©
exact β¨aβ, mβ, IH _ mβ eββ eβββ©
Β· intro aβ mβ
rcases Lists'.mem_of_subset' hrβ mβ with β¨aβ, mβ, eβββ©
rcases Lists'.mem_of_subset' hrβ mβ with β¨aβ, mβ, eβββ©
exact β¨aβ, mβ, (IH _ mβ eββ.symm eββ.symm).symmβ©
Β· rintro _ β¨β©
Β· intro a l IHβ IHβ
simpa using β¨IHβ, IHββ©
instance instSetoidLists : Setoid (Lists Ξ±) :=
β¨(Β· ~ Β·), Equiv.refl, @Equiv.symm _, @Equiv.trans _β©
section Decidable
| Mathlib/SetTheory/Lists.lean | 304 | 305 | theorem sizeof_pos {b} (l : Lists' Ξ± b) : 0 < SizeOf.sizeOf l := by | cases l <;> simp only [Lists'.atom.sizeOf_spec, Lists'.nil.sizeOf_spec, Lists'.cons'.sizeOf_spec, |
/-
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
/-!
# 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
/-- The type of angles -/
def Angle : Type :=
AddCircle (2 * Ο)
-- The `NormedAddCommGroup, Inhabited` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
namespace Angle
instance : NormedAddCommGroup Angle :=
inferInstanceAs (NormedAddCommGroup (AddCircle (2 * Ο)))
instance : Inhabited Angle :=
inferInstanceAs (Inhabited (AddCircle (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'
/-- Coercion `β β Angle` as an additive homomorphism. -/
def coeHom : β β+ Angle :=
QuotientAddGroup.mk' _
@[simp]
theorem coe_coeHom : (coeHom : β β Angle) = ((β) : β β Angle) :=
rfl
/-- 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
@[simp]
theorem coe_zero : β(0 : β) = (0 : Angle) :=
rfl
@[simp]
theorem coe_add (x y : β) : β(x + y : β) = (βx + βy : Angle) :=
rfl
@[simp]
theorem coe_neg (x : β) : β(-x : β) = -(βx : Angle) :=
rfl
@[simp]
theorem coe_sub (x y : β) : β(x - y : β) = (βx - βy : Angle) :=
rfl
theorem coe_nsmul (n : β) (x : β) : β(n β’ x : β) = n β’ (βx : Angle) :=
rfl
theorem coe_zsmul (z : β€) (x : β) : β(z β’ x : β) = z β’ (βx : Angle) :=
rfl
theorem coe_eq_zero_iff {x : β} : (x : Angle) = 0 β β n : β€, n β’ (2 * Ο) = x :=
AddCircle.coe_eq_zero_iff (2 * Ο)
@[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
@[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
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]
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]
@[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]β©
@[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]
@[simp]
theorem two_nsmul_coe_div_two (ΞΈ : β) : (2 : β) β’ (β(ΞΈ / 2) : Angle) = ΞΈ := by
rw [β coe_nsmul, two_nsmul, add_halves]
@[simp]
theorem two_zsmul_coe_div_two (ΞΈ : β) : (2 : β€) β’ (β(ΞΈ / 2) : Angle) = ΞΈ := by
rw [β coe_zsmul, two_zsmul, add_halves]
theorem two_nsmul_neg_pi_div_two : (2 : β) β’ (β(-Ο / 2) : Angle) = Ο := by
rw [two_nsmul_coe_div_two, coe_neg, neg_coe_pi]
theorem two_zsmul_neg_pi_div_two : (2 : β€) β’ (β(-Ο / 2) : Angle) = Ο := by
rw [two_zsmul, β two_nsmul, two_nsmul_neg_pi_div_two]
theorem sub_coe_pi_eq_add_coe_pi (ΞΈ : Angle) : ΞΈ - Ο = ΞΈ + Ο := by
rw [sub_eq_add_neg, neg_coe_pi]
@[simp]
theorem two_nsmul_coe_pi : (2 : β) β’ (Ο : Angle) = 0 := by simp [β natCast_mul_eq_nsmul]
@[simp]
theorem two_zsmul_coe_pi : (2 : β€) β’ (Ο : Angle) = 0 := by simp [β intCast_mul_eq_zsmul]
@[simp]
theorem coe_pi_add_coe_pi : (Ο : Real.Angle) + Ο = 0 := by rw [β two_nsmul, two_nsmul_coe_pi]
theorem zsmul_eq_iff {Ο ΞΈ : Angle} {z : β€} (hz : z β 0) :
z β’ Ο = z β’ ΞΈ β β k : Fin z.natAbs, Ο = ΞΈ + (k : β) β’ (2 * Ο / z : β) :=
QuotientAddGroup.zmultiples_zsmul_eq_zsmul_iff hz
theorem nsmul_eq_iff {Ο ΞΈ : Angle} {n : β} (hz : n β 0) :
n β’ Ο = n β’ ΞΈ β β k : Fin n, Ο = ΞΈ + (k : β) β’ (2 * Ο / n : β) :=
QuotientAddGroup.zmultiples_nsmul_eq_nsmul_iff hz
theorem two_zsmul_eq_iff {Ο ΞΈ : Angle} : (2 : β€) β’ Ο = (2 : β€) β’ ΞΈ β Ο = ΞΈ β¨ Ο = ΞΈ + βΟ := by
have : Int.natAbs 2 = 2 := rfl
rw [zsmul_eq_iff two_ne_zero, this, Fin.exists_fin_two, Fin.val_zero,
Fin.val_one, zero_smul, add_zero, one_smul, Int.cast_two,
mul_div_cancel_leftβ (_ : β) two_ne_zero]
theorem two_nsmul_eq_iff {Ο ΞΈ : Angle} : (2 : β) β’ Ο = (2 : β) β’ ΞΈ β Ο = ΞΈ β¨ Ο = ΞΈ + βΟ := by
simp_rw [β natCast_zsmul, Nat.cast_ofNat, two_zsmul_eq_iff]
theorem two_nsmul_eq_zero_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
convert two_nsmul_eq_iff <;> simp
theorem two_nsmul_ne_zero_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β two_nsmul_eq_zero_iff]
theorem two_zsmul_eq_zero_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
simp_rw [two_zsmul, β two_nsmul, two_nsmul_eq_zero_iff]
theorem two_zsmul_ne_zero_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β two_zsmul_eq_zero_iff]
theorem eq_neg_self_iff {ΞΈ : Angle} : ΞΈ = -ΞΈ β ΞΈ = 0 β¨ ΞΈ = Ο := by
rw [β add_eq_zero_iff_eq_neg, β two_nsmul, two_nsmul_eq_zero_iff]
theorem ne_neg_self_iff {ΞΈ : Angle} : ΞΈ β -ΞΈ β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β eq_neg_self_iff.not]
theorem neg_eq_self_iff {ΞΈ : Angle} : -ΞΈ = ΞΈ β ΞΈ = 0 β¨ ΞΈ = Ο := by rw [eq_comm, eq_neg_self_iff]
theorem neg_ne_self_iff {ΞΈ : Angle} : -ΞΈ β ΞΈ β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β neg_eq_self_iff.not]
theorem two_nsmul_eq_pi_iff {ΞΈ : Angle} : (2 : β) β’ ΞΈ = Ο β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
have h : (Ο : Angle) = ((2 : β) β’ (Ο / 2 : β):) := by rw [two_nsmul, add_halves]
nth_rw 1 [h]
rw [coe_nsmul, two_nsmul_eq_iff]
-- Porting note: `congr` didn't simplify the goal of iff of `Or`s
convert Iff.rfl
rw [add_comm, β coe_add, β sub_eq_zero, β coe_sub, neg_div, β neg_sub, sub_neg_eq_add, add_assoc,
add_halves, β two_mul, coe_neg, coe_two_pi, neg_zero]
theorem two_zsmul_eq_pi_iff {ΞΈ : Angle} : (2 : β€) β’ ΞΈ = Ο β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [two_zsmul, β two_nsmul, two_nsmul_eq_pi_iff]
theorem cos_eq_iff_coe_eq_or_eq_neg {ΞΈ Ο : β} :
cos ΞΈ = cos Ο β (ΞΈ : Angle) = Ο β¨ (ΞΈ : Angle) = -Ο := by
constructor
Β· intro Hcos
rw [β sub_eq_zero, cos_sub_cos, mul_eq_zero, mul_eq_zero, neg_eq_zero,
eq_false (two_ne_zero' β), false_or, sin_eq_zero_iff, sin_eq_zero_iff] at Hcos
rcases Hcos with (β¨n, hnβ© | β¨n, hnβ©)
Β· right
rw [eq_div_iff_mul_eq (two_ne_zero' β), β sub_eq_iff_eq_add] at hn
rw [β hn, coe_sub, eq_neg_iff_add_eq_zero, sub_add_cancel, mul_assoc, intCast_mul_eq_zsmul,
mul_comm, coe_two_pi, zsmul_zero]
Β· left
rw [eq_div_iff_mul_eq (two_ne_zero' β), eq_sub_iff_add_eq] at hn
rw [β hn, coe_add, mul_assoc, intCast_mul_eq_zsmul, mul_comm, coe_two_pi, zsmul_zero,
zero_add]
Β· rw [angle_eq_iff_two_pi_dvd_sub, β coe_neg, angle_eq_iff_two_pi_dvd_sub]
rintro (β¨k, Hβ© | β¨k, Hβ©)
Β· rw [β sub_eq_zero, cos_sub_cos, H, mul_assoc 2 Ο k, mul_div_cancel_leftβ _ (two_ne_zero' β),
mul_comm Ο _, sin_int_mul_pi, mul_zero]
rw [β sub_eq_zero, cos_sub_cos, β sub_neg_eq_add, H, mul_assoc 2 Ο k,
mul_div_cancel_leftβ _ (two_ne_zero' β), mul_comm Ο _, sin_int_mul_pi, mul_zero,
zero_mul]
theorem sin_eq_iff_coe_eq_or_add_eq_pi {ΞΈ Ο : β} :
sin ΞΈ = sin Ο β (ΞΈ : Angle) = Ο β¨ (ΞΈ : Angle) + Ο = Ο := by
constructor
Β· intro Hsin
rw [β cos_pi_div_two_sub, β cos_pi_div_two_sub] at Hsin
rcases cos_eq_iff_coe_eq_or_eq_neg.mp Hsin with h | h
Β· left
rw [coe_sub, coe_sub] at h
exact sub_right_inj.1 h
right
rw [coe_sub, coe_sub, eq_neg_iff_add_eq_zero, add_sub, sub_add_eq_add_sub, β coe_add,
add_halves, sub_sub, sub_eq_zero] at h
exact h.symm
Β· rw [angle_eq_iff_two_pi_dvd_sub, β eq_sub_iff_add_eq, β coe_sub, angle_eq_iff_two_pi_dvd_sub]
rintro (β¨k, Hβ© | β¨k, Hβ©)
Β· rw [β sub_eq_zero, sin_sub_sin, H, mul_assoc 2 Ο k, mul_div_cancel_leftβ _ (two_ne_zero' β),
mul_comm Ο _, sin_int_mul_pi, mul_zero, zero_mul]
have H' : ΞΈ + Ο = 2 * k * Ο + Ο := by
rwa [β sub_add, sub_add_eq_add_sub, sub_eq_iff_eq_add, mul_assoc, mul_comm Ο _, β
mul_assoc] at H
rw [β sub_eq_zero, sin_sub_sin, H', add_div, mul_assoc 2 _ Ο,
mul_div_cancel_leftβ _ (two_ne_zero' β), cos_add_pi_div_two, sin_int_mul_pi, neg_zero,
mul_zero]
theorem cos_sin_inj {ΞΈ Ο : β} (Hcos : cos ΞΈ = cos Ο) (Hsin : sin ΞΈ = sin Ο) : (ΞΈ : Angle) = Ο := by
rcases cos_eq_iff_coe_eq_or_eq_neg.mp Hcos with hc | hc; Β· exact hc
rcases sin_eq_iff_coe_eq_or_add_eq_pi.mp Hsin with hs | hs; Β· exact hs
rw [eq_neg_iff_add_eq_zero, hs] at hc
obtain β¨n, hnβ© : β n, n β’ _ = _ := QuotientAddGroup.leftRel_apply.mp (Quotient.exact' hc)
rw [β neg_one_mul, add_zero, β sub_eq_zero, zsmul_eq_mul, β mul_assoc, β sub_mul, mul_eq_zero,
eq_false (ne_of_gt pi_pos), or_false, sub_neg_eq_add, β Int.cast_zero, β Int.cast_one,
β Int.cast_ofNat, β Int.cast_mul, β Int.cast_add, Int.cast_inj] at hn
have : (n * 2 + 1) % (2 : β€) = 0 % (2 : β€) := congr_arg (Β· % (2 : β€)) hn
rw [add_comm, Int.add_mul_emod_self_right] at this
exact absurd this one_ne_zero
/-- The sine of a `Real.Angle`. -/
def sin (ΞΈ : Angle) : β :=
sin_periodic.lift ΞΈ
@[simp]
theorem sin_coe (x : β) : sin (x : Angle) = Real.sin x :=
rfl
@[continuity]
theorem continuous_sin : Continuous sin :=
Real.continuous_sin.quotient_liftOn' _
/-- The cosine of a `Real.Angle`. -/
def cos (ΞΈ : Angle) : β :=
cos_periodic.lift ΞΈ
@[simp]
theorem cos_coe (x : β) : cos (x : Angle) = Real.cos x :=
rfl
@[continuity]
theorem continuous_cos : Continuous cos :=
Real.continuous_cos.quotient_liftOn' _
theorem cos_eq_real_cos_iff_eq_or_eq_neg {ΞΈ : Angle} {Ο : β} :
cos ΞΈ = Real.cos Ο β ΞΈ = Ο β¨ ΞΈ = -Ο := by
induction ΞΈ using Real.Angle.induction_on
exact cos_eq_iff_coe_eq_or_eq_neg
theorem cos_eq_iff_eq_or_eq_neg {ΞΈ Ο : Angle} : cos ΞΈ = cos Ο β ΞΈ = Ο β¨ ΞΈ = -Ο := by
induction Ο using Real.Angle.induction_on
exact cos_eq_real_cos_iff_eq_or_eq_neg
theorem sin_eq_real_sin_iff_eq_or_add_eq_pi {ΞΈ : Angle} {Ο : β} :
sin ΞΈ = Real.sin Ο β ΞΈ = Ο β¨ ΞΈ + Ο = Ο := by
induction ΞΈ using Real.Angle.induction_on
exact sin_eq_iff_coe_eq_or_add_eq_pi
theorem sin_eq_iff_eq_or_add_eq_pi {ΞΈ Ο : Angle} : sin ΞΈ = sin Ο β ΞΈ = Ο β¨ ΞΈ + Ο = Ο := by
induction Ο using Real.Angle.induction_on
exact sin_eq_real_sin_iff_eq_or_add_eq_pi
@[simp]
theorem sin_zero : sin (0 : Angle) = 0 := by rw [β coe_zero, sin_coe, Real.sin_zero]
theorem sin_coe_pi : sin (Ο : Angle) = 0 := by rw [sin_coe, Real.sin_pi]
theorem sin_eq_zero_iff {ΞΈ : Angle} : sin ΞΈ = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
nth_rw 1 [β sin_zero]
rw [sin_eq_iff_eq_or_add_eq_pi]
simp
theorem sin_ne_zero_iff {ΞΈ : Angle} : sin ΞΈ β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β sin_eq_zero_iff]
@[simp]
theorem sin_neg (ΞΈ : Angle) : sin (-ΞΈ) = -sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_neg _
theorem sin_antiperiodic : Function.Antiperiodic sin (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_antiperiodic _
@[simp]
theorem sin_add_pi (ΞΈ : Angle) : sin (ΞΈ + Ο) = -sin ΞΈ :=
sin_antiperiodic ΞΈ
@[simp]
theorem sin_sub_pi (ΞΈ : Angle) : sin (ΞΈ - Ο) = -sin ΞΈ :=
sin_antiperiodic.sub_eq ΞΈ
@[simp]
theorem cos_zero : cos (0 : Angle) = 1 := by rw [β coe_zero, cos_coe, Real.cos_zero]
theorem cos_coe_pi : cos (Ο : Angle) = -1 := by rw [cos_coe, Real.cos_pi]
@[simp]
theorem cos_neg (ΞΈ : Angle) : cos (-ΞΈ) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_neg _
theorem cos_antiperiodic : Function.Antiperiodic cos (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_antiperiodic _
@[simp]
theorem cos_add_pi (ΞΈ : Angle) : cos (ΞΈ + Ο) = -cos ΞΈ :=
cos_antiperiodic ΞΈ
@[simp]
theorem cos_sub_pi (ΞΈ : Angle) : cos (ΞΈ - Ο) = -cos ΞΈ :=
cos_antiperiodic.sub_eq ΞΈ
theorem cos_eq_zero_iff {ΞΈ : Angle} : cos ΞΈ = 0 β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [β cos_pi_div_two, β cos_coe, cos_eq_iff_eq_or_eq_neg, β coe_neg, β neg_div]
theorem sin_add (ΞΈβ ΞΈβ : Real.Angle) : sin (ΞΈβ + ΞΈβ) = sin ΞΈβ * cos ΞΈβ + cos ΞΈβ * sin ΞΈβ := by
induction ΞΈβ using Real.Angle.induction_on
induction ΞΈβ using Real.Angle.induction_on
exact Real.sin_add _ _
theorem cos_add (ΞΈβ ΞΈβ : Real.Angle) : cos (ΞΈβ + ΞΈβ) = cos ΞΈβ * cos ΞΈβ - sin ΞΈβ * sin ΞΈβ := by
induction ΞΈβ using Real.Angle.induction_on
induction ΞΈβ using Real.Angle.induction_on
exact Real.cos_add _ _
@[simp]
theorem cos_sq_add_sin_sq (ΞΈ : Real.Angle) : cos ΞΈ ^ 2 + sin ΞΈ ^ 2 = 1 := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_sq_add_sin_sq _
theorem sin_add_pi_div_two (ΞΈ : Angle) : sin (ΞΈ + β(Ο / 2)) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_add_pi_div_two _
theorem sin_sub_pi_div_two (ΞΈ : Angle) : sin (ΞΈ - β(Ο / 2)) = -cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_sub_pi_div_two _
theorem sin_pi_div_two_sub (ΞΈ : Angle) : sin (β(Ο / 2) - ΞΈ) = cos ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.sin_pi_div_two_sub _
theorem cos_add_pi_div_two (ΞΈ : Angle) : cos (ΞΈ + β(Ο / 2)) = -sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_add_pi_div_two _
theorem cos_sub_pi_div_two (ΞΈ : Angle) : cos (ΞΈ - β(Ο / 2)) = sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_sub_pi_div_two _
theorem cos_pi_div_two_sub (ΞΈ : Angle) : cos (β(Ο / 2) - ΞΈ) = sin ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact Real.cos_pi_div_two_sub _
theorem abs_sin_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) :
|sin ΞΈ| = |sin Ο| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· rw [sin_add_pi, abs_neg]
theorem abs_sin_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) :
|sin ΞΈ| = |sin Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_sin_eq_of_two_nsmul_eq h
theorem abs_cos_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) :
|cos ΞΈ| = |cos Ο| := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· rw [cos_add_pi, abs_neg]
theorem abs_cos_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) :
|cos ΞΈ| = |cos Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_cos_eq_of_two_nsmul_eq h
@[simp]
theorem coe_toIcoMod (ΞΈ Ο : β) : β(toIcoMod two_pi_pos Ο ΞΈ) = (ΞΈ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine β¨-toIcoDiv two_pi_pos Ο ΞΈ, ?_β©
rw [toIcoMod_sub_self, zsmul_eq_mul, mul_comm]
@[simp]
theorem coe_toIocMod (ΞΈ Ο : β) : β(toIocMod two_pi_pos Ο ΞΈ) = (ΞΈ : Angle) := by
rw [angle_eq_iff_two_pi_dvd_sub]
refine β¨-toIocDiv two_pi_pos Ο ΞΈ, ?_β©
rw [toIocMod_sub_self, zsmul_eq_mul, mul_comm]
/-- Convert a `Real.Angle` to a real number in the interval `Ioc (-Ο) Ο`. -/
def toReal (ΞΈ : Angle) : β :=
(toIocMod_periodic two_pi_pos (-Ο)).lift ΞΈ
theorem toReal_coe (ΞΈ : β) : (ΞΈ : Angle).toReal = toIocMod two_pi_pos (-Ο) ΞΈ :=
rfl
theorem toReal_coe_eq_self_iff {ΞΈ : β} : (ΞΈ : Angle).toReal = ΞΈ β -Ο < ΞΈ β§ ΞΈ β€ Ο := by
rw [toReal_coe, toIocMod_eq_self two_pi_pos]
ring_nf
rfl
theorem toReal_coe_eq_self_iff_mem_Ioc {ΞΈ : β} : (ΞΈ : Angle).toReal = ΞΈ β ΞΈ β Set.Ioc (-Ο) Ο := by
rw [toReal_coe_eq_self_iff, β Set.mem_Ioc]
theorem toReal_injective : Function.Injective toReal := by
intro ΞΈ Ο h
induction ΞΈ using Real.Angle.induction_on
induction Ο using Real.Angle.induction_on
simpa [toReal_coe, toIocMod_eq_toIocMod, zsmul_eq_mul, mul_comm _ (2 * Ο), β
angle_eq_iff_two_pi_dvd_sub, eq_comm] using h
@[simp]
theorem toReal_inj {ΞΈ Ο : Angle} : ΞΈ.toReal = Ο.toReal β ΞΈ = Ο :=
toReal_injective.eq_iff
@[simp]
theorem coe_toReal (ΞΈ : Angle) : (ΞΈ.toReal : Angle) = ΞΈ := by
induction ΞΈ using Real.Angle.induction_on
exact coe_toIocMod _ _
theorem neg_pi_lt_toReal (ΞΈ : Angle) : -Ο < ΞΈ.toReal := by
induction ΞΈ using Real.Angle.induction_on
exact left_lt_toIocMod _ _ _
theorem toReal_le_pi (ΞΈ : Angle) : ΞΈ.toReal β€ Ο := by
induction ΞΈ using Real.Angle.induction_on
convert toIocMod_le_right two_pi_pos _ _
ring
theorem abs_toReal_le_pi (ΞΈ : Angle) : |ΞΈ.toReal| β€ Ο :=
abs_le.2 β¨(neg_pi_lt_toReal _).le, toReal_le_pi _β©
theorem toReal_mem_Ioc (ΞΈ : Angle) : ΞΈ.toReal β Set.Ioc (-Ο) Ο :=
β¨neg_pi_lt_toReal _, toReal_le_pi _β©
@[simp]
theorem toIocMod_toReal (ΞΈ : Angle) : toIocMod two_pi_pos (-Ο) ΞΈ.toReal = ΞΈ.toReal := by
induction ΞΈ using Real.Angle.induction_on
rw [toReal_coe]
exact toIocMod_toIocMod _ _ _ _
@[simp]
theorem toReal_zero : (0 : Angle).toReal = 0 := by
rw [β coe_zero, toReal_coe_eq_self_iff]
exact β¨Left.neg_neg_iff.2 Real.pi_pos, Real.pi_pos.leβ©
@[simp]
theorem toReal_eq_zero_iff {ΞΈ : Angle} : ΞΈ.toReal = 0 β ΞΈ = 0 := by
nth_rw 1 [β toReal_zero]
exact toReal_inj
@[simp]
theorem toReal_pi : (Ο : Angle).toReal = Ο := by
rw [toReal_coe_eq_self_iff]
exact β¨Left.neg_lt_self Real.pi_pos, le_refl _β©
@[simp]
theorem toReal_eq_pi_iff {ΞΈ : Angle} : ΞΈ.toReal = Ο β ΞΈ = Ο := by rw [β toReal_inj, toReal_pi]
theorem pi_ne_zero : (Ο : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_pi, toReal_zero]
exact Real.pi_ne_zero
@[simp]
theorem toReal_pi_div_two : ((Ο / 2 : β) : Angle).toReal = Ο / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
@[simp]
theorem toReal_eq_pi_div_two_iff {ΞΈ : Angle} : ΞΈ.toReal = Ο / 2 β ΞΈ = (Ο / 2 : β) := by
rw [β toReal_inj, toReal_pi_div_two]
@[simp]
theorem toReal_neg_pi_div_two : ((-Ο / 2 : β) : Angle).toReal = -Ο / 2 :=
toReal_coe_eq_self_iff.2 <| by constructor <;> linarith [pi_pos]
@[simp]
theorem toReal_eq_neg_pi_div_two_iff {ΞΈ : Angle} : ΞΈ.toReal = -Ο / 2 β ΞΈ = (-Ο / 2 : β) := by
rw [β toReal_inj, toReal_neg_pi_div_two]
theorem pi_div_two_ne_zero : ((Ο / 2 : β) : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_pi_div_two, toReal_zero]
exact div_ne_zero Real.pi_ne_zero two_ne_zero
theorem neg_pi_div_two_ne_zero : ((-Ο / 2 : β) : Angle) β 0 := by
rw [β toReal_injective.ne_iff, toReal_neg_pi_div_two, toReal_zero]
exact div_ne_zero (neg_ne_zero.2 Real.pi_ne_zero) two_ne_zero
theorem abs_toReal_coe_eq_self_iff {ΞΈ : β} : |(ΞΈ : Angle).toReal| = ΞΈ β 0 β€ ΞΈ β§ ΞΈ β€ Ο :=
β¨fun h => h βΈ β¨abs_nonneg _, abs_toReal_le_pi _β©, fun h =>
(toReal_coe_eq_self_iff.2 β¨(Left.neg_neg_iff.2 Real.pi_pos).trans_le h.1, h.2β©).symm βΈ
abs_eq_self.2 h.1β©
theorem abs_toReal_neg_coe_eq_self_iff {ΞΈ : β} : |(-ΞΈ : Angle).toReal| = ΞΈ β 0 β€ ΞΈ β§ ΞΈ β€ Ο := by
refine β¨fun h => h βΈ β¨abs_nonneg _, abs_toReal_le_pi _β©, fun h => ?_β©
by_cases hnegpi : ΞΈ = Ο; Β· simp [hnegpi, Real.pi_pos.le]
rw [β coe_neg,
toReal_coe_eq_self_iff.2
β¨neg_lt_neg (lt_of_le_of_ne h.2 hnegpi), (neg_nonpos.2 h.1).trans Real.pi_pos.leβ©,
abs_neg, abs_eq_self.2 h.1]
theorem abs_toReal_eq_pi_div_two_iff {ΞΈ : Angle} :
|ΞΈ.toReal| = Ο / 2 β ΞΈ = (Ο / 2 : β) β¨ ΞΈ = (-Ο / 2 : β) := by
rw [abs_eq (div_nonneg Real.pi_pos.le two_pos.le), β neg_div, toReal_eq_pi_div_two_iff,
toReal_eq_neg_pi_div_two_iff]
theorem nsmul_toReal_eq_mul {n : β} (h : n β 0) {ΞΈ : Angle} :
(n β’ ΞΈ).toReal = n * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / n) (Ο / n) := by
nth_rw 1 [β coe_toReal ΞΈ]
have h' : 0 < (n : β) := mod_cast Nat.pos_of_ne_zero h
rw [β coe_nsmul, nsmul_eq_mul, toReal_coe_eq_self_iff, Set.mem_Ioc, div_lt_iffβ' h',
le_div_iffβ' h']
theorem two_nsmul_toReal_eq_two_mul {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / 2) (Ο / 2) :=
mod_cast nsmul_toReal_eq_mul two_ne_zero
theorem two_zsmul_toReal_eq_two_mul {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal β ΞΈ.toReal β Set.Ioc (-Ο / 2) (Ο / 2) := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul]
theorem toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff {ΞΈ : β} {k : β€} :
(ΞΈ : Angle).toReal = ΞΈ - 2 * k * Ο β ΞΈ β Set.Ioc ((2 * k - 1 : β) * Ο) ((2 * k + 1) * Ο) := by
rw [β sub_zero (ΞΈ : Angle), β zsmul_zero k, β coe_two_pi, β coe_zsmul, β coe_sub, zsmul_eq_mul, β
mul_assoc, mul_comm (k : β), toReal_coe_eq_self_iff, Set.mem_Ioc]
exact β¨fun h => β¨by linarith, by linarithβ©, fun h => β¨by linarith, by linarithβ©β©
theorem toReal_coe_eq_self_sub_two_pi_iff {ΞΈ : β} :
(ΞΈ : Angle).toReal = ΞΈ - 2 * Ο β ΞΈ β Set.Ioc Ο (3 * Ο) := by
convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff ΞΈ 1 <;> norm_num
theorem toReal_coe_eq_self_add_two_pi_iff {ΞΈ : β} :
(ΞΈ : Angle).toReal = ΞΈ + 2 * Ο β ΞΈ β Set.Ioc (-3 * Ο) (-Ο) := by
convert @toReal_coe_eq_self_sub_two_mul_int_mul_pi_iff ΞΈ (-1) using 2 <;> norm_num
theorem two_nsmul_toReal_eq_two_mul_sub_two_pi {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal - 2 * Ο β Ο / 2 < ΞΈ.toReal := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [β coe_nsmul, two_nsmul, β two_mul, toReal_coe_eq_self_sub_two_pi_iff, Set.mem_Ioc]
exact
β¨fun h => by linarith, fun h =>
β¨(div_lt_iffβ' (zero_lt_two' β)).1 h, by linarith [pi_pos, toReal_le_pi ΞΈ]β©β©
theorem two_zsmul_toReal_eq_two_mul_sub_two_pi {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal - 2 * Ο β Ο / 2 < ΞΈ.toReal := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul_sub_two_pi]
theorem two_nsmul_toReal_eq_two_mul_add_two_pi {ΞΈ : Angle} :
((2 : β) β’ ΞΈ).toReal = 2 * ΞΈ.toReal + 2 * Ο β ΞΈ.toReal β€ -Ο / 2 := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [β coe_nsmul, two_nsmul, β two_mul, toReal_coe_eq_self_add_two_pi_iff, Set.mem_Ioc]
refine
β¨fun h => by linarith, fun h =>
β¨by linarith [pi_pos, neg_pi_lt_toReal ΞΈ], (le_div_iffβ' (zero_lt_two' β)).1 hβ©β©
theorem two_zsmul_toReal_eq_two_mul_add_two_pi {ΞΈ : Angle} :
((2 : β€) β’ ΞΈ).toReal = 2 * ΞΈ.toReal + 2 * Ο β ΞΈ.toReal β€ -Ο / 2 := by
rw [two_zsmul, β two_nsmul, two_nsmul_toReal_eq_two_mul_add_two_pi]
@[simp]
theorem sin_toReal (ΞΈ : Angle) : Real.sin ΞΈ.toReal = sin ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, sin_coe]
@[simp]
theorem cos_toReal (ΞΈ : Angle) : Real.cos ΞΈ.toReal = cos ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, cos_coe]
theorem cos_nonneg_iff_abs_toReal_le_pi_div_two {ΞΈ : Angle} : 0 β€ cos ΞΈ β |ΞΈ.toReal| β€ Ο / 2 := by
nth_rw 1 [β coe_toReal ΞΈ]
rw [abs_le, cos_coe]
refine β¨fun h => ?_, cos_nonneg_of_mem_Iccβ©
by_contra hn
rw [not_and_or, not_le, not_le] at hn
refine (not_lt.2 h) ?_
rcases hn with (hn | hn)
Β· rw [β Real.cos_neg]
refine cos_neg_of_pi_div_two_lt_of_lt (by linarith) ?_
linarith [neg_pi_lt_toReal ΞΈ]
Β· refine cos_neg_of_pi_div_two_lt_of_lt hn ?_
linarith [toReal_le_pi ΞΈ]
theorem cos_pos_iff_abs_toReal_lt_pi_div_two {ΞΈ : Angle} : 0 < cos ΞΈ β |ΞΈ.toReal| < Ο / 2 := by
rw [lt_iff_le_and_ne, lt_iff_le_and_ne, cos_nonneg_iff_abs_toReal_le_pi_div_two, β
and_congr_right]
rintro -
rw [Ne, Ne, not_iff_not, @eq_comm β 0, abs_toReal_eq_pi_div_two_iff, cos_eq_zero_iff]
theorem cos_neg_iff_pi_div_two_lt_abs_toReal {ΞΈ : Angle} : cos ΞΈ < 0 β Ο / 2 < |ΞΈ.toReal| := by
rw [β not_le, β not_le, not_iff_not, cos_nonneg_iff_abs_toReal_le_pi_div_two]
theorem abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β) β’ ΞΈ + (2 : β) β’ Ο = Ο) : |cos ΞΈ| = |sin Ο| := by
rw [β eq_sub_iff_add_eq, β two_nsmul_coe_div_two, β nsmul_sub, two_nsmul_eq_iff] at h
rcases h with (rfl | rfl) <;> simp [cos_pi_div_two_sub]
theorem abs_cos_eq_abs_sin_of_two_zsmul_add_two_zsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β€) β’ ΞΈ + (2 : β€) β’ Ο = Ο) : |cos ΞΈ| = |sin Ο| := by
simp_rw [two_zsmul, β two_nsmul] at h
exact abs_cos_eq_abs_sin_of_two_nsmul_add_two_nsmul_eq_pi h
/-- The tangent of a `Real.Angle`. -/
def tan (ΞΈ : Angle) : β :=
sin ΞΈ / cos ΞΈ
theorem tan_eq_sin_div_cos (ΞΈ : Angle) : tan ΞΈ = sin ΞΈ / cos ΞΈ :=
rfl
@[simp]
theorem tan_coe (x : β) : tan (x : Angle) = Real.tan x := by
rw [tan, sin_coe, cos_coe, Real.tan_eq_sin_div_cos]
@[simp]
theorem tan_zero : tan (0 : Angle) = 0 := by rw [β coe_zero, tan_coe, Real.tan_zero]
theorem tan_coe_pi : tan (Ο : Angle) = 0 := by rw [tan_coe, Real.tan_pi]
theorem tan_periodic : Function.Periodic tan (Ο : Angle) := by
intro ΞΈ
induction ΞΈ using Real.Angle.induction_on
rw [β coe_add, tan_coe, tan_coe]
exact Real.tan_periodic _
@[simp]
theorem tan_add_pi (ΞΈ : Angle) : tan (ΞΈ + Ο) = tan ΞΈ :=
tan_periodic ΞΈ
@[simp]
theorem tan_sub_pi (ΞΈ : Angle) : tan (ΞΈ - Ο) = tan ΞΈ :=
tan_periodic.sub_eq ΞΈ
@[simp]
theorem tan_toReal (ΞΈ : Angle) : Real.tan ΞΈ.toReal = tan ΞΈ := by
conv_rhs => rw [β coe_toReal ΞΈ, tan_coe]
theorem tan_eq_of_two_nsmul_eq {ΞΈ Ο : Angle} (h : (2 : β) β’ ΞΈ = (2 : β) β’ Ο) : tan ΞΈ = tan Ο := by
rw [two_nsmul_eq_iff] at h
rcases h with (rfl | rfl)
Β· rfl
Β· exact tan_add_pi _
theorem tan_eq_of_two_zsmul_eq {ΞΈ Ο : Angle} (h : (2 : β€) β’ ΞΈ = (2 : β€) β’ Ο) : tan ΞΈ = tan Ο := by
simp_rw [two_zsmul, β two_nsmul] at h
exact tan_eq_of_two_nsmul_eq h
theorem tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β) β’ ΞΈ + (2 : β) β’ Ο = Ο) : tan Ο = (tan ΞΈ)β»ΒΉ := by
induction ΞΈ using Real.Angle.induction_on
induction Ο using Real.Angle.induction_on
rw [β smul_add, β coe_add, β coe_nsmul, two_nsmul, β two_mul, angle_eq_iff_two_pi_dvd_sub] at h
rcases h with β¨k, hβ©
rw [sub_eq_iff_eq_add, β mul_inv_cancel_leftβ two_ne_zero Ο, mul_assoc, β mul_add,
mul_right_inj' (two_ne_zero' β), β eq_sub_iff_add_eq', mul_inv_cancel_leftβ two_ne_zero Ο,
inv_mul_eq_div, mul_comm] at h
rw [tan_coe, tan_coe, β tan_pi_div_two_sub, h, add_sub_assoc, add_comm]
exact Real.tan_periodic.int_mul _ _
theorem tan_eq_inv_of_two_zsmul_add_two_zsmul_eq_pi {ΞΈ Ο : Angle}
(h : (2 : β€) β’ ΞΈ + (2 : β€) β’ Ο = Ο) : tan Ο = (tan ΞΈ)β»ΒΉ := by
simp_rw [two_zsmul, β two_nsmul] at h
exact tan_eq_inv_of_two_nsmul_add_two_nsmul_eq_pi h
/-- The sign of a `Real.Angle` is `0` if the angle is `0` or `Ο`, `1` if the angle is strictly
between `0` and `Ο` and `-1` is the angle is strictly between `-Ο` and `0`. It is defined as the
sign of the sine of the angle. -/
def sign (ΞΈ : Angle) : SignType :=
SignType.sign (sin ΞΈ)
@[simp]
theorem sign_zero : (0 : Angle).sign = 0 := by
rw [sign, sin_zero, _root_.sign_zero]
@[simp]
theorem sign_coe_pi : (Ο : Angle).sign = 0 := by rw [sign, sin_coe_pi, _root_.sign_zero]
@[simp]
theorem sign_neg (ΞΈ : Angle) : (-ΞΈ).sign = -ΞΈ.sign := by
simp_rw [sign, sin_neg, Left.sign_neg]
theorem sign_antiperiodic : Function.Antiperiodic sign (Ο : Angle) := fun ΞΈ => by
rw [sign, sign, sin_add_pi, Left.sign_neg]
@[simp]
theorem sign_add_pi (ΞΈ : Angle) : (ΞΈ + Ο).sign = -ΞΈ.sign :=
sign_antiperiodic ΞΈ
@[simp]
theorem sign_pi_add (ΞΈ : Angle) : ((Ο : Angle) + ΞΈ).sign = -ΞΈ.sign := by rw [add_comm, sign_add_pi]
@[simp]
theorem sign_sub_pi (ΞΈ : Angle) : (ΞΈ - Ο).sign = -ΞΈ.sign :=
sign_antiperiodic.sub_eq ΞΈ
@[simp]
theorem sign_pi_sub (ΞΈ : Angle) : ((Ο : Angle) - ΞΈ).sign = ΞΈ.sign := by
simp [sign_antiperiodic.sub_eq']
theorem sign_eq_zero_iff {ΞΈ : Angle} : ΞΈ.sign = 0 β ΞΈ = 0 β¨ ΞΈ = Ο := by
rw [sign, _root_.sign_eq_zero_iff, sin_eq_zero_iff]
theorem sign_ne_zero_iff {ΞΈ : Angle} : ΞΈ.sign β 0 β ΞΈ β 0 β§ ΞΈ β Ο := by
rw [β not_or, β sign_eq_zero_iff]
theorem toReal_neg_iff_sign_neg {ΞΈ : Angle} : ΞΈ.toReal < 0 β ΞΈ.sign = -1 := by
rw [sign, β sin_toReal, sign_eq_neg_one_iff]
rcases lt_trichotomy ΞΈ.toReal 0 with (h | h | h)
Β· exact β¨fun _ => Real.sin_neg_of_neg_of_neg_pi_lt h (neg_pi_lt_toReal ΞΈ), fun _ => hβ©
Β· simp [h]
Β· exact
β¨fun hn => False.elim (h.asymm hn), fun hn =>
False.elim (hn.not_le (sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi ΞΈ)))β©
theorem toReal_nonneg_iff_sign_nonneg {ΞΈ : Angle} : 0 β€ ΞΈ.toReal β 0 β€ ΞΈ.sign := by
rcases lt_trichotomy ΞΈ.toReal 0 with (h | h | h)
Β· refine β¨fun hn => False.elim (h.not_le hn), fun hn => ?_β©
rw [toReal_neg_iff_sign_neg.1 h] at hn
exact False.elim (hn.not_lt (by decide))
Β· simp [h, sign, β sin_toReal]
Β· refine β¨fun _ => ?_, fun _ => h.leβ©
rw [sign, β sin_toReal, sign_nonneg_iff]
exact sin_nonneg_of_nonneg_of_le_pi h.le (toReal_le_pi ΞΈ)
@[simp]
theorem sign_toReal {ΞΈ : Angle} (h : ΞΈ β Ο) : SignType.sign ΞΈ.toReal = ΞΈ.sign := by
rcases lt_trichotomy ΞΈ.toReal 0 with (ht | ht | ht)
Β· simp [ht, toReal_neg_iff_sign_neg.1 ht]
Β· simp [sign, ht, β sin_toReal]
Β· rw [sign, β sin_toReal, sign_pos ht,
sign_pos
(sin_pos_of_pos_of_lt_pi ht ((toReal_le_pi ΞΈ).lt_of_ne (toReal_eq_pi_iff.not.2 h)))]
| Mathlib/Analysis/SpecialFunctions/Trigonometric/Angle.lean | 768 | 771 | theorem coe_abs_toReal_of_sign_nonneg {ΞΈ : Angle} (h : 0 β€ ΞΈ.sign) : β|ΞΈ.toReal| = ΞΈ := by | rw [abs_eq_self.2 (toReal_nonneg_iff_sign_nonneg.2 h), coe_toReal]
theorem neg_coe_abs_toReal_of_sign_nonpos {ΞΈ : Angle} (h : ΞΈ.sign β€ 0) : -β|ΞΈ.toReal| = ΞΈ := by |
/-
Copyright (c) 2023 Jon Eugster. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Dagur Asgeirsson, Boris Bolvig Kjær, Jon Eugster, Sina Hazratpour
-/
import Mathlib.CategoryTheory.Sites.Coherent.ReflectsPreregular
import Mathlib.Topology.Category.CompHaus.EffectiveEpi
import Mathlib.Topology.Category.Profinite.Limits
import Mathlib.Topology.Category.Stonean.Basic
/-!
# Effective epimorphisms in `Profinite`
This file proves that `EffectiveEpi`, `Epi` and `Surjective` are all equivalent in `Profinite`.
As a consequence we deduce from the material in
`Mathlib.Topology.Category.CompHausLike.EffectiveEpi` that `Profinite` is `Preregular`
and `Precoherent`.
We also prove that for a finite family of morphisms in `Profinite` with fixed
target, the conditions jointly surjective, jointly epimorphic and effective epimorphic are all
equivalent.
-/
universe u
open CategoryTheory Limits
namespace Profinite
open List in
theorem effectiveEpi_tfae
{B X : Profinite.{u}} (Ο : X βΆ B) :
TFAE
[ EffectiveEpi Ο
, Epi Ο
, Function.Surjective Ο
] := by
tfae_have 1 β 2 := fun _ β¦ inferInstance
tfae_have 2 β 3 := epi_iff_surjective Ο
tfae_have 3 β 1 := fun hΟ β¦ β¨β¨CompHausLike.effectiveEpiStruct Ο hΟβ©β©
tfae_finish
instance : profiniteToCompHaus.PreservesEffectiveEpis where
preserves f h :=
((CompHaus.effectiveEpi_tfae _).out 0 2).mpr (((Profinite.effectiveEpi_tfae _).out 0 2).mp h)
instance : profiniteToCompHaus.ReflectsEffectiveEpis where
reflects f h :=
((Profinite.effectiveEpi_tfae f).out 0 2).mpr (((CompHaus.effectiveEpi_tfae _).out 0 2).mp h)
/--
An effective presentation of an `X : Profinite` with respect to the inclusion functor from `Stonean`
-/
noncomputable def profiniteToCompHausEffectivePresentation (X : CompHaus) :
profiniteToCompHaus.EffectivePresentation X where
p := Stonean.toProfinite.obj X.presentation
f := CompHaus.presentation.Ο X
effectiveEpi := ((CompHaus.effectiveEpi_tfae _).out 0 1).mpr (inferInstance : Epi _)
instance : profiniteToCompHaus.EffectivelyEnough where
presentation X := β¨profiniteToCompHausEffectivePresentation Xβ©
instance : Preregular Profinite.{u} := profiniteToCompHaus.reflects_preregular
example : Precoherent Profinite.{u} := inferInstance
-- TODO: prove this for `Type*`
open List in
| Mathlib/Topology/Category/Profinite/EffectiveEpi.lean | 69 | 82 | theorem effectiveEpiFamily_tfae
{Ξ± : Type} [Finite Ξ±] {B : Profinite.{u}}
(X : Ξ± β Profinite.{u}) (Ο : (a : Ξ±) β (X a βΆ B)) :
TFAE
[ EffectiveEpiFamily X Ο
, Epi (Sigma.desc Ο)
, β b : B, β (a : Ξ±) (x : X a), Ο a x = b
] := by | tfae_have 2 β 1
| _ => by
simpa [β effectiveEpi_desc_iff_effectiveEpiFamily, (effectiveEpi_tfae (Sigma.desc Ο)).out 0 1]
tfae_have 1 β 2 := fun _ β¦ inferInstance
tfae_have 3 β 1 := by
erw [((CompHaus.effectiveEpiFamily_tfae |
/-
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.Family
import Mathlib.Tactic.Abel
/-!
# Natural operations on ordinals
The goal of this file is to define natural addition and multiplication on ordinals, also known as
the Hessenberg sum and product, and provide a basic API. The natural addition of two ordinals
`a β― b` is recursively defined as the least ordinal greater than `a' β― b` and `a β― b'` for `a' < a`
and `b' < b`. The natural multiplication `a ⨳ b` is likewise recursively defined as the least
ordinal such that `a ⨳ b ⯠a' ⨳ b'` is greater than `a' ⨳ b ⯠a ⨳ b'` for any `a' < a` and
`b' < b`.
These operations form a rich algebraic structure: they're commutative, associative, preserve order,
have the usual `0` and `1` from ordinals, and distribute over one another.
Moreover, these operations are the addition and multiplication of ordinals when viewed as
combinatorial `Game`s. This makes them particularly useful for game theory.
Finally, both operations admit simple, intuitive descriptions in terms of the Cantor normal form.
The natural addition of two ordinals corresponds to adding their Cantor normal forms as if they were
polynomials in `Ο`. Likewise, their natural multiplication corresponds to multiplying the Cantor
normal forms as polynomials.
## Implementation notes
Given the rich algebraic structure of these two operations, we choose to create a type synonym
`NatOrdinal`, where we provide the appropriate instances. However, to avoid casting back and forth
between both types, we attempt to prove and state most results on `Ordinal`.
## Todo
- Prove the characterizations of natural addition and multiplication in terms of the Cantor normal
form.
-/
universe u v
open Function Order Set
noncomputable section
/-! ### Basic casts between `Ordinal` and `NatOrdinal` -/
/-- A type synonym for ordinals with natural addition and multiplication. -/
def NatOrdinal : Type _ :=
Ordinal deriving Zero, Inhabited, One, WellFoundedRelation
-- The `LinearOrder, `SuccOrder` instances should be constructed by a deriving handler.
-- https://github.com/leanprover-community/mathlib4/issues/380
instance NatOrdinal.instLinearOrder : LinearOrder NatOrdinal := Ordinal.instLinearOrder
instance NatOrdinal.instSuccOrder : SuccOrder NatOrdinal := Ordinal.instSuccOrder
instance NatOrdinal.instOrderBot : OrderBot NatOrdinal := Ordinal.instOrderBot
instance NatOrdinal.instNoMaxOrder : NoMaxOrder NatOrdinal := Ordinal.instNoMaxOrder
instance NatOrdinal.instZeroLEOneClass : ZeroLEOneClass NatOrdinal := Ordinal.instZeroLEOneClass
instance NatOrdinal.instNeZeroOne : NeZero (1 : NatOrdinal) := Ordinal.instNeZeroOne
instance NatOrdinal.uncountable : Uncountable NatOrdinal :=
Ordinal.uncountable
/-- The identity function between `Ordinal` and `NatOrdinal`. -/
@[match_pattern]
def Ordinal.toNatOrdinal : Ordinal βo NatOrdinal :=
OrderIso.refl _
/-- The identity function between `NatOrdinal` and `Ordinal`. -/
@[match_pattern]
def NatOrdinal.toOrdinal : NatOrdinal βo Ordinal :=
OrderIso.refl _
namespace NatOrdinal
open Ordinal
@[simp]
theorem toOrdinal_symm_eq : NatOrdinal.toOrdinal.symm = Ordinal.toNatOrdinal :=
rfl
@[simp]
theorem toOrdinal_toNatOrdinal (a : NatOrdinal) : a.toOrdinal.toNatOrdinal = a :=
rfl
theorem lt_wf : @WellFounded NatOrdinal (Β· < Β·) :=
Ordinal.lt_wf
instance : WellFoundedLT NatOrdinal :=
Ordinal.wellFoundedLT
instance : ConditionallyCompleteLinearOrderBot NatOrdinal :=
WellFoundedLT.conditionallyCompleteLinearOrderBot _
@[simp] theorem bot_eq_zero : (β₯ : NatOrdinal) = 0 := rfl
@[simp] theorem toOrdinal_zero : toOrdinal 0 = 0 := rfl
@[simp] theorem toOrdinal_one : toOrdinal 1 = 1 := rfl
@[simp] theorem toOrdinal_eq_zero {a} : toOrdinal a = 0 β a = 0 := Iff.rfl
@[simp] theorem toOrdinal_eq_one {a} : toOrdinal a = 1 β a = 1 := Iff.rfl
@[simp]
theorem toOrdinal_max (a b : NatOrdinal) : toOrdinal (max a b) = max (toOrdinal a) (toOrdinal b) :=
rfl
@[simp]
theorem toOrdinal_min (a b : NatOrdinal) : toOrdinal (min a b) = min (toOrdinal a) (toOrdinal b) :=
rfl
theorem succ_def (a : NatOrdinal) : succ a = toNatOrdinal (toOrdinal a + 1) :=
rfl
@[simp]
theorem zero_le (o : NatOrdinal) : 0 β€ o :=
Ordinal.zero_le o
theorem not_lt_zero (o : NatOrdinal) : Β¬ o < 0 :=
Ordinal.not_lt_zero o
@[simp]
theorem lt_one_iff_zero {o : NatOrdinal} : o < 1 β o = 0 :=
Ordinal.lt_one_iff_zero
/-- A recursor for `NatOrdinal`. Use as `induction x`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {Ξ² : NatOrdinal β Sort*} (h : β a, Ξ² (toNatOrdinal a)) : β a, Ξ² a := fun a =>
h (toOrdinal a)
/-- `Ordinal.induction` but for `NatOrdinal`. -/
theorem induction {p : NatOrdinal β Prop} : β (i) (_ : β j, (β k, k < j β p k) β p j), p i :=
Ordinal.induction
instance small_Iio (a : NatOrdinal.{u}) : Small.{u} (Set.Iio a) := Ordinal.small_Iio a
instance small_Iic (a : NatOrdinal.{u}) : Small.{u} (Set.Iic a) := Ordinal.small_Iic a
instance small_Ico (a b : NatOrdinal.{u}) : Small.{u} (Set.Ico a b) := Ordinal.small_Ico a b
instance small_Icc (a b : NatOrdinal.{u}) : Small.{u} (Set.Icc a b) := Ordinal.small_Icc a b
instance small_Ioo (a b : NatOrdinal.{u}) : Small.{u} (Set.Ioo a b) := Ordinal.small_Ioo a b
instance small_Ioc (a b : NatOrdinal.{u}) : Small.{u} (Set.Ioc a b) := Ordinal.small_Ioc a b
end NatOrdinal
namespace Ordinal
variable {a b c : Ordinal.{u}}
@[simp] theorem toNatOrdinal_symm_eq : toNatOrdinal.symm = NatOrdinal.toOrdinal := rfl
@[simp] theorem toNatOrdinal_toOrdinal (a : Ordinal) : a.toNatOrdinal.toOrdinal = a := rfl
@[simp] theorem toNatOrdinal_zero : toNatOrdinal 0 = 0 := rfl
@[simp] theorem toNatOrdinal_one : toNatOrdinal 1 = 1 := rfl
@[simp] theorem toNatOrdinal_eq_zero (a) : toNatOrdinal a = 0 β a = 0 := Iff.rfl
@[simp] theorem toNatOrdinal_eq_one (a) : toNatOrdinal a = 1 β a = 1 := Iff.rfl
@[simp]
theorem toNatOrdinal_max (a b : Ordinal) :
toNatOrdinal (max a b) = max (toNatOrdinal a) (toNatOrdinal b) :=
rfl
@[simp]
theorem toNatOrdinal_min (a b : Ordinal) :
toNatOrdinal (min a b) = min (toNatOrdinal a) (toNatOrdinal b) :=
rfl
/-! We place the definitions of `nadd` and `nmul` before actually developing their API, as this
guarantees we only need to open the `NaturalOps` locale once. -/
/-- Natural addition on ordinals `a β― b`, also known as the Hessenberg sum, is recursively defined
as the least ordinal greater than `a' β― b` and `a β― b'` for all `a' < a` and `b' < b`. In contrast
to normal ordinal addition, it is commutative.
Natural addition can equivalently be characterized as the ordinal resulting from adding up
corresponding coefficients in the Cantor normal forms of `a` and `b`. -/
noncomputable def nadd (a b : Ordinal.{u}) : Ordinal.{u} :=
max (β¨ x : Iio a, succ (nadd x.1 b)) (β¨ x : Iio b, succ (nadd a x.1))
termination_by (a, b)
decreasing_by all_goals cases x; decreasing_tactic
@[inherit_doc]
scoped[NaturalOps] infixl:65 " β― " => Ordinal.nadd
open NaturalOps
/-- Natural multiplication on ordinals `a ⨳ b`, also known as the Hessenberg product, is recursively
defined as the least ordinal such that `a ⨳ b ⯠a' ⨳ b'` is greater than `a' ⨳ b ⯠a ⨳ b'` for all
`a' < a` and `b < b'`. In contrast to normal ordinal multiplication, it is commutative and
distributive (over natural addition).
Natural multiplication can equivalently be characterized as the ordinal resulting from multiplying
the Cantor normal forms of `a` and `b` as if they were polynomials in `Ο`. Addition of exponents is
done via natural addition. -/
noncomputable def nmul (a b : Ordinal.{u}) : Ordinal.{u} :=
sInf {c | β a' < a, β b' < b, nmul a' b β― nmul a b' < c β― nmul a' b'}
termination_by (a, b)
@[inherit_doc]
scoped[NaturalOps] infixl:70 " ⨳ " => Ordinal.nmul
/-! ### Natural addition -/
theorem lt_nadd_iff : a < b β― c β (β b' < b, a β€ b' β― c) β¨ β c' < c, a β€ b β― c' := by
rw [nadd]
simp [Ordinal.lt_iSup_iff]
theorem nadd_le_iff : b β― c β€ a β (β b' < b, b' β― c < a) β§ β c' < c, b β― c' < a := by
rw [β not_lt, lt_nadd_iff]
simp
theorem nadd_lt_nadd_left (h : b < c) (a) : a β― b < a β― c :=
lt_nadd_iff.2 (Or.inr β¨b, h, le_rflβ©)
theorem nadd_lt_nadd_right (h : b < c) (a) : b β― a < c β― a :=
lt_nadd_iff.2 (Or.inl β¨b, h, le_rflβ©)
theorem nadd_le_nadd_left (h : b β€ c) (a) : a β― b β€ a β― c := by
rcases lt_or_eq_of_le h with (h | rfl)
Β· exact (nadd_lt_nadd_left h a).le
Β· exact le_rfl
theorem nadd_le_nadd_right (h : b β€ c) (a) : b β― a β€ c β― a := by
rcases lt_or_eq_of_le h with (h | rfl)
Β· exact (nadd_lt_nadd_right h a).le
Β· exact le_rfl
variable (a b)
theorem nadd_comm (a b) : a β― b = b β― a := by
rw [nadd, nadd, max_comm]
congr <;> ext x <;> cases x <;> apply congr_arg _ (nadd_comm _ _)
termination_by (a, b)
@[deprecated "blsub will soon be deprecated" (since := "2024-11-18")]
theorem blsub_nadd_of_mono {f : β c < a β― b, Ordinal.{max u v}}
(hf : β {i j} (hi hj), i β€ j β f i hi β€ f j hj) :
blsub.{u,v} _ f =
max (blsub.{u, v} a fun a' ha' => f (a' β― b) <| nadd_lt_nadd_right ha' b)
(blsub.{u, v} b fun b' hb' => f (a β― b') <| nadd_lt_nadd_left hb' a) := by
apply (blsub_le_iff.2 fun i h => _).antisymm (max_le _ _)
Β· intro i h
rcases lt_nadd_iff.1 h with (β¨a', ha', hiβ© | β¨b', hb', hiβ©)
Β· exact lt_max_of_lt_left ((hf h (nadd_lt_nadd_right ha' b) hi).trans_lt (lt_blsub _ _ ha'))
Β· exact lt_max_of_lt_right ((hf h (nadd_lt_nadd_left hb' a) hi).trans_lt (lt_blsub _ _ hb'))
all_goals
apply blsub_le_of_brange_subset.{u, u, v}
rintro c β¨d, hd, rflβ©
apply mem_brange_self
private theorem iSup_nadd_of_monotone {a b} (f : Ordinal.{u} β Ordinal.{u}) (h : Monotone f) :
β¨ x : Iio (a β― b), f x = max (β¨ a' : Iio a, f (a'.1 β― b)) (β¨ b' : Iio b, f (a β― b'.1)) := by
apply (max_le _ _).antisymm'
Β· rw [Ordinal.iSup_le_iff]
rintro β¨i, hiβ©
obtain β¨x, hx, hiβ© | β¨x, hx, hiβ© := lt_nadd_iff.1 hi
Β· exact le_max_of_le_left ((h hi).trans <| Ordinal.le_iSup (fun x : Iio a β¦ _) β¨x, hxβ©)
Β· exact le_max_of_le_right ((h hi).trans <| Ordinal.le_iSup (fun x : Iio b β¦ _) β¨x, hxβ©)
all_goals
apply csSup_le_csSup' (bddAbove_of_small _)
rintro _ β¨β¨c, hcβ©, rflβ©
refine mem_range_self (β¨_, ?_β© : Iio _)
apply_rules [nadd_lt_nadd_left, nadd_lt_nadd_right]
theorem nadd_assoc (a b c) : a β― b β― c = a β― (b β― c) := by
unfold nadd
rw [iSup_nadd_of_monotone fun a' β¦ succ (a' β― c), iSup_nadd_of_monotone fun b' β¦ succ (a β― b'),
max_assoc]
Β· congr <;> ext x <;> cases x <;> apply congr_arg _ (nadd_assoc _ _ _)
Β· exact succ_mono.comp fun x y h β¦ nadd_le_nadd_left h _
Β· exact succ_mono.comp fun x y h β¦ nadd_le_nadd_right h _
termination_by (a, b, c)
@[simp]
theorem nadd_zero (a : Ordinal) : a β― 0 = a := by
rw [nadd, ciSup_of_empty fun _ : Iio 0 β¦ _, sup_bot_eq]
convert iSup_succ a
rename_i x
cases x
exact nadd_zero _
termination_by a
@[simp]
theorem zero_nadd : 0 β― a = a := by rw [nadd_comm, nadd_zero]
@[simp]
theorem nadd_one (a : Ordinal) : a β― 1 = succ a := by
rw [nadd, ciSup_unique (s := fun _ : Iio 1 β¦ _), Iio_one_default_eq, nadd_zero,
max_eq_right_iff, Ordinal.iSup_le_iff]
rintro β¨i, hiβ©
rwa [nadd_one, succ_le_succ_iff, succ_le_iff]
termination_by a
@[simp]
theorem one_nadd : 1 β― a = succ a := by rw [nadd_comm, nadd_one]
theorem nadd_succ : a β― succ b = succ (a β― b) := by rw [β nadd_one (a β― b), nadd_assoc, nadd_one]
theorem succ_nadd : succ a β― b = succ (a β― b) := by rw [β one_nadd (a β― b), β nadd_assoc, one_nadd]
@[simp]
theorem nadd_nat (n : β) : a β― n = a + n := by
induction' n with n hn
Β· simp
Β· rw [Nat.cast_succ, add_one_eq_succ, nadd_succ, add_succ, hn]
@[simp]
| Mathlib/SetTheory/Ordinal/NaturalOps.lean | 309 | 309 | theorem nat_nadd (n : β) : βn β― a = a + n := by | rw [nadd_comm, nadd_nat] |
/-
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.Data.Matrix.Kronecker
import Mathlib.LinearAlgebra.FiniteDimensional.Basic
import Mathlib.LinearAlgebra.Matrix.Adjugate
import Mathlib.LinearAlgebra.Matrix.SemiringInverse
import Mathlib.LinearAlgebra.Matrix.ToLin
import Mathlib.LinearAlgebra.Matrix.Trace
/-!
# 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]
theorem invOf_eq [Invertible A.det] [Invertible A] : β
A = β
A.det β’ A.adjugate := by
letI := invertibleOfDetInvertible A
convert (rfl : β
A = _)
/-- `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]
/-- `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]
/-- If `A` has a constructive inverse, produce one for `A.det`. -/
def detInvertibleOfInvertible [Invertible A] : Invertible A.det :=
detInvertibleOfLeftInverse A (β
A) (invOf_mul_self _)
theorem det_invOf [Invertible A] [Invertible A.det] : (β
A).det = β
A.det := by
letI := detInvertibleOfInvertible A
convert (rfl : _ = β
A.det)
/-- 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 _ _
/-- 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)
/-- 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]
@[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)
variable {A B}
theorem isUnit_det_of_left_inverse (h : B * A = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfLeftInverse _ _ h)
theorem isUnit_det_of_right_inverse (h : A * B = 1) : IsUnit A.det :=
@isUnit_of_invertible _ _ _ (detInvertibleOfRightInverse _ _ h)
theorem det_ne_zero_of_left_inverse [Nontrivial Ξ±] (h : B * A = 1) : A.det β 0 :=
(isUnit_det_of_left_inverse h).ne_zero
theorem det_ne_zero_of_right_inverse [Nontrivial Ξ±] (h : A * B = 1) : A.det β 0 :=
(isUnit_det_of_right_inverse h).ne_zero
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
/-! ### 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
theorem nonsing_inv_apply_not_isUnit (h : Β¬IsUnit A.det) : Aβ»ΒΉ = 0 := by
rw [inv_def, Ring.inverse_non_unit _ h, zero_smul]
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]
/-- 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]
/-- 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]
/-- The nonsingular inverse is the same as the general `Ring.inverse`. -/
theorem nonsing_inv_eq_ringInverse : 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]
@[deprecated (since := "2025-04-22")]
alias nonsing_inv_eq_ring_inverse := nonsing_inv_eq_ringInverse
theorem transpose_nonsing_inv : Aβ»ΒΉα΅ = Aα΅β»ΒΉ := by
rw [inv_def, inv_def, transpose_smul, det_transpose, adjugate_transpose]
theorem conjTranspose_nonsing_inv [StarRing Ξ±] : Aβ»ΒΉα΄΄ = Aα΄΄β»ΒΉ := by
rw [inv_def, inv_def, conjTranspose_smul, det_conjTranspose, adjugate_conjTranspose,
Ring.inverse_star]
/-- 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]
/-- 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]
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]
@[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]
@[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]
@[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]
@[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]
@[simp]
theorem mul_inv_of_invertible [Invertible A] : A * Aβ»ΒΉ = 1 :=
mul_nonsing_inv A (isUnit_det_of_invertible A)
@[simp]
theorem inv_mul_of_invertible [Invertible A] : Aβ»ΒΉ * A = 1 :=
nonsing_inv_mul A (isUnit_det_of_invertible A)
@[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)
@[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)
@[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)
@[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)
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]β©
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]β©
lemma inv_mulVec_eq_vec {A : Matrix n n Ξ±} [Invertible A]
{u v : n β Ξ±} (hM : u = A.mulVec v) : Aβ»ΒΉ.mulVec u = v := by
rw [hM, Matrix.mulVec_mulVec, Matrix.inv_mul_of_invertible, Matrix.one_mulVec]
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 Ξ±]
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
section Semiring
variable {R : Type*} [Semiring R]
theorem vecMul_surjective_iff_exists_left_inverse
[DecidableEq n] [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
[DecidableEq m] [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 [DecidableEq m] {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 A.row β IsUnit A := by
rw [β col_transpose, β mulVec_injective_iff, β coe_mulVecLin, mulVecLin_transpose,
β vecMul_injective_iff_isUnit, coe_vecMulLinear]
theorem linearIndependent_cols_iff_isUnit {A : Matrix m m K} :
LinearIndependent K A.col β IsUnit A := by
rw [β row_transpose, linearIndependent_rows_iff_isUnit, isUnit_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 A.row :=
linearIndependent_rows_iff_isUnit.2 <| isUnit_of_invertible A
theorem linearIndependent_cols_of_invertible (A : Matrix m m K) [Invertible A] :
LinearIndependent K A.col :=
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)
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]
@[simp]
| Mathlib/LinearAlgebra/Matrix/NonsingularInverse.lean | 407 | 409 | theorem det_nonsing_inv : Aβ»ΒΉ.det = Ring.inverse A.det := by | by_cases h : IsUnit A.det
Β· cases h.nonempty_invertible |
/-
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
/-!
# 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
/-- `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
/--
`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
/--
`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
@[simp]
theorem aeval_eq_bindβ (f : Ο β MvPolynomial Ο R) : aeval f = bindβ f :=
rfl
@[simp]
theorem evalβHom_C_eq_bindβ (f : Ο β MvPolynomial Ο R) : evalβHom C f = bindβ f :=
rfl
@[simp]
theorem evalβHom_eq_bindβ (f : R β+* MvPolynomial Ο S) : evalβHom f X = bindβ f :=
rfl
section
variable (Ο R)
@[simp]
theorem aeval_id_eq_joinβ : aeval id = @joinβ Ο R _ :=
rfl
theorem evalβHom_C_id_eq_joinβ (Ο : MvPolynomial (MvPolynomial Ο R) R) :
evalβHom C id Ο = joinβ Ο :=
rfl
@[simp]
theorem evalβHom_id_X_eq_joinβ : evalβHom (RingHom.id _) X = @joinβ Ο R _ :=
rfl
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
@[simp]
theorem bindβ_X_right (f : R β+* MvPolynomial Ο S) (i : Ο) : bindβ f (X i) = X i :=
evalβHom_X' f X i
@[simp]
theorem bindβ_X_left : bindβ (X : Ο β MvPolynomial Ο R) = AlgHom.id R _ := by
ext1 i
simp
variable (f : Ο β MvPolynomial Ο R)
theorem bindβ_C_right (f : Ο β MvPolynomial Ο R) (x) : bindβ f (C x) = C x := algHom_C _ _
@[simp]
theorem bindβ_C_right (f : R β+* MvPolynomial Ο S) (r : R) : bindβ f (C r) = f r :=
evalβHom_C f X r
@[simp]
theorem bindβ_C_left : bindβ (C : R β+* MvPolynomial Ο R) = RingHom.id _ := by ext : 2 <;> simp
@[simp]
theorem bindβ_comp_C (f : R β+* MvPolynomial Ο S) : (bindβ f).comp C = f :=
RingHom.ext <| bindβ_C_right _
@[simp]
theorem joinβ_map (f : R β+* MvPolynomial Ο S) (Ο : MvPolynomial Ο R) :
joinβ (map f Ο) = bindβ f Ο := by simp only [joinβ, bindβ, evalβHom_map_hom, RingHom.id_comp]
@[simp]
theorem joinβ_comp_map (f : R β+* MvPolynomial Ο S) : joinβ.comp (map f) = bindβ f :=
RingHom.ext <| joinβ_map _
theorem aeval_id_rename (f : Ο β MvPolynomial Ο R) (p : MvPolynomial Ο R) :
aeval id (rename f p) = aeval f p := by rw [aeval_rename, Function.id_comp]
@[simp]
theorem joinβ_rename (f : Ο β MvPolynomial Ο R) (Ο : MvPolynomial Ο R) :
joinβ (rename f Ο) = bindβ f Ο :=
aeval_id_rename _ _
@[simp]
theorem bindβ_id : bindβ (@id (MvPolynomial Ο R)) = joinβ :=
rfl
@[simp]
theorem bindβ_id : bindβ (RingHom.id (MvPolynomial Ο R)) = joinβ :=
rfl
theorem bindβ_bindβ {Ο
: Type*} (f : Ο β MvPolynomial Ο R) (g : Ο β MvPolynomial Ο
R)
(Ο : MvPolynomial Ο R) : (bindβ g) (bindβ f Ο) = bindβ (fun i => bindβ g (f i)) Ο := by
simp [bindβ, β comp_aeval]
theorem bindβ_comp_bindβ {Ο
: Type*} (f : Ο β MvPolynomial Ο R) (g : Ο β MvPolynomial Ο
R) :
(bindβ g).comp (bindβ f) = bindβ fun i => bindβ g (f i) := by
ext1
apply bindβ_bindβ
theorem bindβ_comp_bindβ (f : R β+* MvPolynomial Ο S) (g : S β+* MvPolynomial Ο T) :
(bindβ g).comp (bindβ f) = bindβ ((bindβ g).comp f) := by ext : 2 <;> simp
theorem bindβ_bindβ (f : R β+* MvPolynomial Ο S) (g : S β+* MvPolynomial Ο T)
(Ο : MvPolynomial Ο R) : (bindβ g) (bindβ f Ο) = bindβ ((bindβ g).comp f) Ο :=
RingHom.congr_fun (bindβ_comp_bindβ f g) Ο
theorem rename_comp_bindβ {Ο
: Type*} (f : Ο β MvPolynomial Ο R) (g : Ο β Ο
) :
(rename g).comp (bindβ f) = bindβ fun i => rename g <| f i := by
ext1 i
simp
theorem rename_bindβ {Ο
: Type*} (f : Ο β MvPolynomial Ο R) (g : Ο β Ο
) (Ο : MvPolynomial Ο R) :
rename g (bindβ f Ο) = bindβ (fun i => rename g <| f i) Ο :=
AlgHom.congr_fun (rename_comp_bindβ f g) Ο
theorem map_bindβ (f : R β+* MvPolynomial Ο S) (g : S β+* T) (Ο : MvPolynomial Ο R) :
map g (bindβ f Ο) = bindβ ((map g).comp f) Ο := by
simp only [bindβ, evalβ_comp_right, coe_evalβHom, evalβ_map]
congr 1 with : 1
simp only [Function.comp_apply, map_X]
theorem bindβ_comp_rename {Ο
: Type*} (f : Ο β MvPolynomial Ο
R) (g : Ο β Ο) :
(bindβ f).comp (rename g) = bindβ (f β g) := by
ext1 i
simp
theorem bindβ_rename {Ο
: Type*} (f : Ο β MvPolynomial Ο
R) (g : Ο β Ο) (Ο : MvPolynomial Ο R) :
bindβ f (rename g Ο) = bindβ (f β g) Ο :=
AlgHom.congr_fun (bindβ_comp_rename f g) Ο
theorem bindβ_map (f : S β+* MvPolynomial Ο T) (g : R β+* S) (Ο : MvPolynomial Ο R) :
bindβ f (map g Ο) = bindβ (f.comp g) Ο := by simp [bindβ]
@[simp]
theorem map_comp_C (f : R β+* S) : (map f).comp (C : R β+* MvPolynomial Ο R) = C.comp f := by
ext1
apply map_C
-- mixing the two monad structures
theorem hom_bindβ (f : MvPolynomial Ο R β+* S) (g : Ο β MvPolynomial Ο R) (Ο : MvPolynomial Ο R) :
f (bindβ g Ο) = evalβHom (f.comp C) (fun i => f (g i)) Ο := by
rw [bindβ, map_aeval, algebraMap_eq]
theorem map_bindβ (f : R β+* S) (g : Ο β MvPolynomial Ο R) (Ο : MvPolynomial Ο R) :
map f (bindβ g Ο) = bindβ (fun i : Ο => (map f) (g i)) (map f Ο) := by
rw [hom_bindβ, map_comp_C, β evalβHom_map_hom]
rfl
@[simp]
theorem evalβHom_comp_C (f : R β+* S) (g : Ο β S) : (evalβHom f g).comp C = f := by
ext1 r
exact evalβ_C f g r
theorem evalβHom_bindβ (f : R β+* S) (g : Ο β S) (h : Ο β MvPolynomial Ο R) (Ο : MvPolynomial Ο R) :
evalβHom f g (bindβ h Ο) = evalβHom f (fun i => evalβHom f g (h i)) Ο := by
rw [hom_bindβ, evalβHom_comp_C]
theorem aeval_bindβ [Algebra R S] (f : Ο β S) (g : Ο β MvPolynomial Ο R) (Ο : MvPolynomial Ο R) :
aeval f (bindβ g Ο) = aeval (fun i => aeval f (g i)) Ο :=
evalβHom_bindβ _ _ _ _
theorem aeval_comp_bindβ [Algebra R S] (f : Ο β S) (g : Ο β MvPolynomial Ο R) :
(aeval f).comp (bindβ g) = aeval fun i => aeval f (g i) := by
ext1
apply aeval_bindβ
theorem evalβHom_comp_bindβ (f : S β+* T) (g : Ο β T) (h : R β+* MvPolynomial Ο S) :
(evalβHom f g).comp (bindβ h) = evalβHom ((evalβHom f g).comp h) g := by ext : 2 <;> simp
theorem evalβHom_bindβ (f : S β+* T) (g : Ο β T) (h : R β+* MvPolynomial Ο S)
(Ο : MvPolynomial Ο R) : evalβHom f g (bindβ h Ο) = evalβHom ((evalβHom f g).comp h) g Ο :=
RingHom.congr_fun (evalβHom_comp_bindβ f g h) Ο
theorem aeval_bindβ [Algebra S T] (f : Ο β T) (g : R β+* MvPolynomial Ο S) (Ο : MvPolynomial Ο R) :
aeval f (bindβ g Ο) = evalβHom ((β(aeval f : _ ββ[S] _) : _ β+* _).comp g) f Ο :=
evalβHom_bindβ _ _ _ _
alias evalβHom_C_left := evalβHom_C_eq_bindβ
| Mathlib/Algebra/MvPolynomial/Monad.lean | 273 | 275 | theorem bindβ_monomial (f : Ο β MvPolynomial Ο R) (d : Ο ββ β) (r : R) :
bindβ f (monomial d r) = C r * β i β d.support, f i ^ d i := by | simp only [monomial_eq, map_mul, bindβ_C_right, Finsupp.prod, map_prod, |
/-
Copyright (c) 2020 Riccardo Brasca. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Riccardo Brasca, Johan Commelin
-/
import Mathlib.Algebra.GCDMonoid.IntegrallyClosed
import Mathlib.FieldTheory.Finite.Basic
import Mathlib.FieldTheory.Minpoly.IsIntegrallyClosed
import Mathlib.RingTheory.RootsOfUnity.PrimitiveRoots
import Mathlib.RingTheory.UniqueFactorizationDomain.Nat
/-!
# Minimal polynomial of roots of unity
We gather several results about minimal polynomial of root of unity.
## Main results
* `IsPrimitiveRoot.totient_le_degree_minpoly`: The degree of the minimal polynomial of an `n`-th
primitive root of unity is at least `totient n`.
-/
open minpoly Polynomial
open scoped Polynomial
namespace IsPrimitiveRoot
section CommRing
variable {n : β} {K : Type*} [CommRing K] {ΞΌ : K} (h : IsPrimitiveRoot ΞΌ n)
include h
/-- `ΞΌ` is integral over `β€`. -/
-- Porting note: `hpos` was in the `variable` line, with an `omit` in mathlib3 just after this
-- declaration. For some reason, in Lean4, `hpos` gets included also in the declarations below,
-- even if it is not used in the proof.
| Mathlib/RingTheory/RootsOfUnity/Minpoly.lean | 40 | 45 | theorem isIntegral (hpos : 0 < n) : IsIntegral β€ ΞΌ := by | use X ^ n - 1
constructor
Β· exact monic_X_pow_sub_C 1 (ne_of_lt hpos).symm
Β· simp only [((IsPrimitiveRoot.iff_def ΞΌ n).mp h).left, evalβ_one, evalβ_X_pow, evalβ_sub,
sub_self] |
/-
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.Algebra.EuclideanDomain.Int
import Mathlib.Data.Nat.Prime.Int
import Mathlib.Data.ZMod.Basic
import Mathlib.RingTheory.PrincipalIdealDomain
/-!
# Coprimality and vanishing
We show that for prime `p`, the image of an integer `a` in `ZMod p` vanishes if and only if
`a` and `p` are not coprime.
-/
assert_not_exists TwoSidedIdeal
namespace ZMod
/-- If `p` is a prime and `a` is an integer, then `a : ZMod p` is zero if and only if
`gcd a p β 1`. -/
| Mathlib/Data/ZMod/Coprime.lean | 24 | 28 | theorem eq_zero_iff_gcd_ne_one {a : β€} {p : β} [pp : Fact p.Prime] :
(a : ZMod p) = 0 β a.gcd p β 1 := by | rw [Ne, Int.gcd_comm, β Int.isCoprime_iff_gcd_eq_one,
(Nat.prime_iff_prime_int.1 pp.1).coprime_iff_not_dvd, Classical.not_not,
intCast_zmod_eq_zero_iff_dvd] |
/-
Copyright (c) 2021 Kexing Ying. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kexing Ying, RΓ©my Degenne
-/
import Mathlib.Probability.Process.Adapted
import Mathlib.MeasureTheory.Constructions.BorelSpace.Order
/-!
# Stopping times, stopped processes and stopped values
Definition and properties of stopping times.
## Main definitions
* `MeasureTheory.IsStoppingTime`: a stopping time with respect to some filtration `f` is a
function `Ο` such that for all `i`, the preimage of `{j | j β€ i}` along `Ο` is
`f i`-measurable
* `MeasureTheory.IsStoppingTime.measurableSpace`: the Ο-algebra associated with a stopping time
## Main results
* `ProgMeasurable.stoppedProcess`: the stopped process of a progressively measurable process is
progressively measurable.
* `memLp_stoppedProcess`: if a process belongs to `βp` at every time in `β`, then its stopped
process belongs to `βp` as well.
## Tags
stopping time, stochastic process
-/
open Filter Order TopologicalSpace
open scoped MeasureTheory NNReal ENNReal Topology
namespace MeasureTheory
variable {Ξ© Ξ² ΞΉ : Type*} {m : MeasurableSpace Ξ©}
/-! ### Stopping times -/
/-- A stopping time with respect to some filtration `f` is a function
`Ο` such that for all `i`, the preimage of `{j | j β€ i}` along `Ο` is measurable
with respect to `f i`.
Intuitively, the stopping time `Ο` describes some stopping rule such that at time
`i`, we may determine it with the information we have at time `i`. -/
def IsStoppingTime [Preorder ΞΉ] (f : Filtration ΞΉ m) (Ο : Ξ© β ΞΉ) :=
β i : ΞΉ, MeasurableSet[f i] <| {Ο | Ο Ο β€ i}
theorem isStoppingTime_const [Preorder ΞΉ] (f : Filtration ΞΉ m) (i : ΞΉ) :
IsStoppingTime f fun _ => i := fun j => by simp only [MeasurableSet.const]
section MeasurableSet
section Preorder
variable [Preorder ΞΉ] {f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ}
protected theorem IsStoppingTime.measurableSet_le (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο β€ i} :=
hΟ i
theorem IsStoppingTime.measurableSet_lt_of_pred [PredOrder ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο < i} := by
by_cases hi_min : IsMin i
Β· suffices {Ο : Ξ© | Ο Ο < i} = β
by rw [this]; exact @MeasurableSet.empty _ (f i)
ext1 Ο
simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false]
rw [isMin_iff_forall_not_lt] at hi_min
exact hi_min (Ο Ο)
have : {Ο : Ξ© | Ο Ο < i} = Ο β»ΒΉ' Set.Iic (pred i) := by ext; simp [Iic_pred_of_not_isMin hi_min]
rw [this]
exact f.mono (pred_le i) _ (hΟ.measurableSet_le <| pred i)
end Preorder
section CountableStoppingTime
namespace IsStoppingTime
variable [PartialOrder ΞΉ] {Ο : Ξ© β ΞΉ} {f : Filtration ΞΉ m}
protected theorem measurableSet_eq_of_countable_range (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) (i : ΞΉ) : MeasurableSet[f i] {Ο | Ο Ο = i} := by
have : {Ο | Ο Ο = i} = {Ο | Ο Ο β€ i} \ β (j β Set.range Ο) (_ : j < i), {Ο | Ο Ο β€ j} := by
ext1 a
simp only [Set.mem_setOf_eq, Set.mem_range, Set.iUnion_exists, Set.iUnion_iUnion_eq',
Set.mem_diff, Set.mem_iUnion, exists_prop, not_exists, not_and, not_le]
constructor <;> intro h
Β· simp only [h, lt_iff_le_not_le, le_refl, and_imp, imp_self, imp_true_iff, and_self_iff]
Β· exact h.1.eq_or_lt.resolve_right fun h_lt => h.2 a h_lt le_rfl
rw [this]
refine (hΟ.measurableSet_le i).diff ?_
refine MeasurableSet.biUnion h_countable fun j _ => ?_
classical
rw [Set.iUnion_eq_if]
split_ifs with hji
Β· exact f.mono hji.le _ (hΟ.measurableSet_le j)
Β· exact @MeasurableSet.empty _ (f i)
protected theorem measurableSet_eq_of_countable [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο = i} :=
hΟ.measurableSet_eq_of_countable_range (Set.to_countable _) i
protected theorem measurableSet_lt_of_countable_range (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) (i : ΞΉ) : MeasurableSet[f i] {Ο | Ο Ο < i} := by
have : {Ο | Ο Ο < i} = {Ο | Ο Ο β€ i} \ {Ο | Ο Ο = i} := by ext1 Ο; simp [lt_iff_le_and_ne]
rw [this]
exact (hΟ.measurableSet_le i).diff (hΟ.measurableSet_eq_of_countable_range h_countable i)
protected theorem measurableSet_lt_of_countable [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο < i} :=
hΟ.measurableSet_lt_of_countable_range (Set.to_countable _) i
protected theorem measurableSet_ge_of_countable_range {ΞΉ} [LinearOrder ΞΉ] {Ο : Ξ© β ΞΉ}
{f : Filtration ΞΉ m} (hΟ : IsStoppingTime f Ο) (h_countable : (Set.range Ο).Countable) (i : ΞΉ) :
MeasurableSet[f i] {Ο | i β€ Ο Ο} := by
have : {Ο | i β€ Ο Ο} = {Ο | Ο Ο < i}αΆ := by
ext1 Ο; simp only [Set.mem_setOf_eq, Set.mem_compl_iff, not_lt]
rw [this]
exact (hΟ.measurableSet_lt_of_countable_range h_countable i).compl
protected theorem measurableSet_ge_of_countable {ΞΉ} [LinearOrder ΞΉ] {Ο : Ξ© β ΞΉ} {f : Filtration ΞΉ m}
[Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) : MeasurableSet[f i] {Ο | i β€ Ο Ο} :=
hΟ.measurableSet_ge_of_countable_range (Set.to_countable _) i
end IsStoppingTime
end CountableStoppingTime
section LinearOrder
variable [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ}
theorem IsStoppingTime.measurableSet_gt (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | i < Ο Ο} := by
have : {Ο | i < Ο Ο} = {Ο | Ο Ο β€ i}αΆ := by
ext1 Ο; simp only [Set.mem_setOf_eq, Set.mem_compl_iff, not_le]
rw [this]
exact (hΟ.measurableSet_le i).compl
section TopologicalSpace
variable [TopologicalSpace ΞΉ] [OrderTopology ΞΉ] [FirstCountableTopology ΞΉ]
/-- Auxiliary lemma for `MeasureTheory.IsStoppingTime.measurableSet_lt`. -/
theorem IsStoppingTime.measurableSet_lt_of_isLUB (hΟ : IsStoppingTime f Ο) (i : ΞΉ)
(h_lub : IsLUB (Set.Iio i) i) : MeasurableSet[f i] {Ο | Ο Ο < i} := by
by_cases hi_min : IsMin i
Β· suffices {Ο | Ο Ο < i} = β
by rw [this]; exact @MeasurableSet.empty _ (f i)
ext1 Ο
simp only [Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false]
exact isMin_iff_forall_not_lt.mp hi_min (Ο Ο)
obtain β¨seq, -, -, h_tendsto, h_boundβ© :
β seq : β β ΞΉ, Monotone seq β§ (β j, seq j β€ i) β§ Tendsto seq atTop (π i) β§ β j, seq j < i :=
h_lub.exists_seq_monotone_tendsto (not_isMin_iff.mp hi_min)
have h_Ioi_eq_Union : Set.Iio i = β j, {k | k β€ seq j} := by
ext1 k
simp only [Set.mem_Iio, Set.mem_iUnion, Set.mem_setOf_eq]
refine β¨fun hk_lt_i => ?_, fun h_exists_k_le_seq => ?_β©
Β· rw [tendsto_atTop'] at h_tendsto
have h_nhds : Set.Ici k β π i :=
mem_nhds_iff.mpr β¨Set.Ioi k, Set.Ioi_subset_Ici le_rfl, isOpen_Ioi, hk_lt_iβ©
obtain β¨a, haβ© : β a : β, β b : β, b β₯ a β k β€ seq b := h_tendsto (Set.Ici k) h_nhds
exact β¨a, ha a le_rflβ©
Β· obtain β¨j, hk_seq_jβ© := h_exists_k_le_seq
exact hk_seq_j.trans_lt (h_bound j)
have h_lt_eq_preimage : {Ο | Ο Ο < i} = Ο β»ΒΉ' Set.Iio i := by
ext1 Ο; simp only [Set.mem_setOf_eq, Set.mem_preimage, Set.mem_Iio]
rw [h_lt_eq_preimage, h_Ioi_eq_Union]
simp only [Set.preimage_iUnion, Set.preimage_setOf_eq]
exact MeasurableSet.iUnion fun n => f.mono (h_bound n).le _ (hΟ.measurableSet_le (seq n))
theorem IsStoppingTime.measurableSet_lt (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο < i} := by
obtain β¨i', hi'_lubβ© : β i', IsLUB (Set.Iio i) i' := exists_lub_Iio i
rcases lub_Iio_eq_self_or_Iio_eq_Iic i hi'_lub with hi'_eq_i | h_Iio_eq_Iic
Β· rw [β hi'_eq_i] at hi'_lub β’
exact hΟ.measurableSet_lt_of_isLUB i' hi'_lub
Β· have h_lt_eq_preimage : {Ο : Ξ© | Ο Ο < i} = Ο β»ΒΉ' Set.Iio i := rfl
rw [h_lt_eq_preimage, h_Iio_eq_Iic]
exact f.mono (lub_Iio_le i hi'_lub) _ (hΟ.measurableSet_le i')
theorem IsStoppingTime.measurableSet_ge (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | i β€ Ο Ο} := by
have : {Ο | i β€ Ο Ο} = {Ο | Ο Ο < i}αΆ := by
ext1 Ο; simp only [Set.mem_setOf_eq, Set.mem_compl_iff, not_lt]
rw [this]
exact (hΟ.measurableSet_lt i).compl
theorem IsStoppingTime.measurableSet_eq (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[f i] {Ο | Ο Ο = i} := by
have : {Ο | Ο Ο = i} = {Ο | Ο Ο β€ i} β© {Ο | Ο Ο β₯ i} := by
ext1 Ο; simp only [Set.mem_setOf_eq, Set.mem_inter_iff, le_antisymm_iff]
rw [this]
exact (hΟ.measurableSet_le i).inter (hΟ.measurableSet_ge i)
theorem IsStoppingTime.measurableSet_eq_le (hΟ : IsStoppingTime f Ο) {i j : ΞΉ} (hle : i β€ j) :
MeasurableSet[f j] {Ο | Ο Ο = i} :=
f.mono hle _ <| hΟ.measurableSet_eq i
theorem IsStoppingTime.measurableSet_lt_le (hΟ : IsStoppingTime f Ο) {i j : ΞΉ} (hle : i β€ j) :
MeasurableSet[f j] {Ο | Ο Ο < i} :=
f.mono hle _ <| hΟ.measurableSet_lt i
end TopologicalSpace
end LinearOrder
section Countable
theorem isStoppingTime_of_measurableSet_eq [Preorder ΞΉ] [Countable ΞΉ] {f : Filtration ΞΉ m}
{Ο : Ξ© β ΞΉ} (hΟ : β i, MeasurableSet[f i] {Ο | Ο Ο = i}) : IsStoppingTime f Ο := by
intro i
rw [show {Ο | Ο Ο β€ i} = β k β€ i, {Ο | Ο Ο = k} by ext; simp]
refine MeasurableSet.biUnion (Set.to_countable _) fun k hk => ?_
exact f.mono hk _ (hΟ k)
end Countable
end MeasurableSet
namespace IsStoppingTime
protected theorem max [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο Ο : Ξ© β ΞΉ} (hΟ : IsStoppingTime f Ο)
(hΟ : IsStoppingTime f Ο) : IsStoppingTime f fun Ο => max (Ο Ο) (Ο Ο) := by
intro i
simp_rw [max_le_iff, Set.setOf_and]
exact (hΟ i).inter (hΟ i)
protected theorem max_const [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ}
(hΟ : IsStoppingTime f Ο) (i : ΞΉ) : IsStoppingTime f fun Ο => max (Ο Ο) i :=
hΟ.max (isStoppingTime_const f i)
protected theorem min [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο Ο : Ξ© β ΞΉ} (hΟ : IsStoppingTime f Ο)
(hΟ : IsStoppingTime f Ο) : IsStoppingTime f fun Ο => min (Ο Ο) (Ο Ο) := by
intro i
simp_rw [min_le_iff, Set.setOf_or]
exact (hΟ i).union (hΟ i)
protected theorem min_const [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ}
(hΟ : IsStoppingTime f Ο) (i : ΞΉ) : IsStoppingTime f fun Ο => min (Ο Ο) i :=
hΟ.min (isStoppingTime_const f i)
theorem add_const [AddGroup ΞΉ] [Preorder ΞΉ] [AddRightMono ΞΉ]
[AddLeftMono ΞΉ] {f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ} (hΟ : IsStoppingTime f Ο)
{i : ΞΉ} (hi : 0 β€ i) : IsStoppingTime f fun Ο => Ο Ο + i := by
intro j
simp_rw [β le_sub_iff_add_le]
exact f.mono (sub_le_self j hi) _ (hΟ (j - i))
theorem add_const_nat {f : Filtration β m} {Ο : Ξ© β β} (hΟ : IsStoppingTime f Ο) {i : β} :
IsStoppingTime f fun Ο => Ο Ο + i := by
refine isStoppingTime_of_measurableSet_eq fun j => ?_
by_cases hij : i β€ j
Β· simp_rw [eq_comm, β Nat.sub_eq_iff_eq_add hij, eq_comm]
exact f.mono (j.sub_le i) _ (hΟ.measurableSet_eq (j - i))
Β· rw [not_le] at hij
convert @MeasurableSet.empty _ (f.1 j)
ext Ο
simp only [Set.mem_empty_iff_false, iff_false, Set.mem_setOf]
omega
-- generalize to certain countable type?
theorem add {f : Filtration β m} {Ο Ο : Ξ© β β} (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) :
IsStoppingTime f (Ο + Ο) := by
intro i
rw [(_ : {Ο | (Ο + Ο) Ο β€ i} = β k β€ i, {Ο | Ο Ο = k} β© {Ο | Ο Ο + k β€ i})]
Β· exact MeasurableSet.iUnion fun k =>
MeasurableSet.iUnion fun hk => (hΟ.measurableSet_eq_le hk).inter (hΟ.add_const_nat i)
ext Ο
simp only [Pi.add_apply, Set.mem_setOf_eq, Set.mem_iUnion, Set.mem_inter_iff, exists_prop]
refine β¨fun h => β¨Ο Ο, by omega, rfl, hβ©, ?_β©
rintro β¨j, hj, rfl, hβ©
assumption
section Preorder
variable [Preorder ΞΉ] {f : Filtration ΞΉ m} {Ο Ο : Ξ© β ΞΉ}
/-- The associated Ο-algebra with a stopping time. -/
protected def measurableSpace (hΟ : IsStoppingTime f Ο) : MeasurableSpace Ξ© where
MeasurableSet' s := β i : ΞΉ, MeasurableSet[f i] (s β© {Ο | Ο Ο β€ i})
measurableSet_empty i := (Set.empty_inter {Ο | Ο Ο β€ i}).symm βΈ @MeasurableSet.empty _ (f i)
measurableSet_compl s hs i := by
rw [(_ : sαΆ β© {Ο | Ο Ο β€ i} = (sαΆ βͺ {Ο | Ο Ο β€ i}αΆ) β© {Ο | Ο Ο β€ i})]
Β· refine MeasurableSet.inter ?_ ?_
Β· rw [β Set.compl_inter]
exact (hs i).compl
Β· exact hΟ i
Β· rw [Set.union_inter_distrib_right]
simp only [Set.compl_inter_self, Set.union_empty]
measurableSet_iUnion s hs i := by
rw [forall_swap] at hs
rw [Set.iUnion_inter]
exact MeasurableSet.iUnion (hs i)
protected theorem measurableSet (hΟ : IsStoppingTime f Ο) (s : Set Ξ©) :
MeasurableSet[hΟ.measurableSpace] s β β i : ΞΉ, MeasurableSet[f i] (s β© {Ο | Ο Ο β€ i}) :=
Iff.rfl
theorem measurableSpace_mono (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) (hle : Ο β€ Ο) :
hΟ.measurableSpace β€ hΟ.measurableSpace := by
intro s hs i
rw [(_ : s β© {Ο | Ο Ο β€ i} = s β© {Ο | Ο Ο β€ i} β© {Ο | Ο Ο β€ i})]
Β· exact (hs i).inter (hΟ i)
Β· ext
simp only [Set.mem_inter_iff, iff_self_and, and_congr_left_iff, Set.mem_setOf_eq]
intro hle' _
exact le_trans (hle _) hle'
theorem measurableSpace_le_of_countable [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) :
hΟ.measurableSpace β€ m := by
intro s hs
change β i, MeasurableSet[f i] (s β© {Ο | Ο Ο β€ i}) at hs
rw [(_ : s = β i, s β© {Ο | Ο Ο β€ i})]
Β· exact MeasurableSet.iUnion fun i => f.le i _ (hs i)
Β· ext Ο; constructor <;> rw [Set.mem_iUnion]
Β· exact fun hx => β¨Ο Ο, hx, le_rflβ©
Β· rintro β¨_, hx, _β©
exact hx
theorem measurableSpace_le [IsCountablyGenerated (atTop : Filter ΞΉ)] [IsDirected ΞΉ (Β· β€ Β·)]
(hΟ : IsStoppingTime f Ο) : hΟ.measurableSpace β€ m := by
intro s hs
cases isEmpty_or_nonempty ΞΉ
Β· haveI : IsEmpty Ξ© := β¨fun Ο => IsEmpty.false (Ο Ο)β©
apply Subsingleton.measurableSet
Β· change β i, MeasurableSet[f i] (s β© {Ο | Ο Ο β€ i}) at hs
obtain β¨seq : β β ΞΉ, h_seq_tendstoβ© := (atTop : Filter ΞΉ).exists_seq_tendsto
rw [(_ : s = β n, s β© {Ο | Ο Ο β€ seq n})]
Β· exact MeasurableSet.iUnion fun i => f.le (seq i) _ (hs (seq i))
Β· ext Ο; constructor <;> rw [Set.mem_iUnion]
Β· intro hx
suffices β i, Ο Ο β€ seq i from β¨this.choose, hx, this.choose_specβ©
rw [tendsto_atTop] at h_seq_tendsto
exact (h_seq_tendsto (Ο Ο)).exists
Β· rintro β¨_, hx, _β©
exact hx
@[deprecated (since := "2024-12-25")] alias measurableSpace_le' := measurableSpace_le
example {f : Filtration β m} {Ο : Ξ© β β} (hΟ : IsStoppingTime f Ο) : hΟ.measurableSpace β€ m :=
hΟ.measurableSpace_le
example {f : Filtration β m} {Ο : Ξ© β β} (hΟ : IsStoppingTime f Ο) : hΟ.measurableSpace β€ m :=
hΟ.measurableSpace_le
@[simp]
theorem measurableSpace_const (f : Filtration ΞΉ m) (i : ΞΉ) :
(isStoppingTime_const f i).measurableSpace = f i := by
ext1 s
change MeasurableSet[(isStoppingTime_const f i).measurableSpace] s β MeasurableSet[f i] s
rw [IsStoppingTime.measurableSet]
constructor <;> intro h
Β· specialize h i
simpa only [le_refl, Set.setOf_true, Set.inter_univ] using h
Β· intro j
by_cases hij : i β€ j
Β· simp only [hij, Set.setOf_true, Set.inter_univ]
exact f.mono hij _ h
Β· simp only [hij, Set.setOf_false, Set.inter_empty, @MeasurableSet.empty _ (f.1 j)]
theorem measurableSet_inter_eq_iff (hΟ : IsStoppingTime f Ο) (s : Set Ξ©) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] (s β© {Ο | Ο Ο = i}) β
MeasurableSet[f i] (s β© {Ο | Ο Ο = i}) := by
have : β j, {Ο : Ξ© | Ο Ο = i} β© {Ο : Ξ© | Ο Ο β€ j} = {Ο : Ξ© | Ο Ο = i} β© {_Ο | i β€ j} := by
intro j
ext1 Ο
simp only [Set.mem_inter_iff, Set.mem_setOf_eq, and_congr_right_iff]
intro hxi
rw [hxi]
constructor <;> intro h
Β· specialize h i
simpa only [Set.inter_assoc, this, le_refl, Set.setOf_true, Set.inter_univ] using h
Β· intro j
rw [Set.inter_assoc, this]
by_cases hij : i β€ j
Β· simp only [hij, Set.setOf_true, Set.inter_univ]
exact f.mono hij _ h
Β· simp [hij]
theorem measurableSpace_le_of_le_const (hΟ : IsStoppingTime f Ο) {i : ΞΉ} (hΟ_le : β Ο, Ο Ο β€ i) :
hΟ.measurableSpace β€ f i :=
(measurableSpace_mono hΟ _ hΟ_le).trans (measurableSpace_const _ _).le
theorem measurableSpace_le_of_le (hΟ : IsStoppingTime f Ο) {n : ΞΉ} (hΟ_le : β Ο, Ο Ο β€ n) :
hΟ.measurableSpace β€ m :=
(hΟ.measurableSpace_le_of_le_const hΟ_le).trans (f.le n)
theorem le_measurableSpace_of_const_le (hΟ : IsStoppingTime f Ο) {i : ΞΉ} (hΟ_le : β Ο, i β€ Ο Ο) :
f i β€ hΟ.measurableSpace :=
(measurableSpace_const _ _).symm.le.trans (measurableSpace_mono _ hΟ hΟ_le)
end Preorder
instance sigmaFinite_stopping_time {ΞΉ} [SemilatticeSup ΞΉ] [OrderBot ΞΉ]
[(Filter.atTop : Filter ΞΉ).IsCountablyGenerated] {ΞΌ : Measure Ξ©} {f : Filtration ΞΉ m}
{Ο : Ξ© β ΞΉ} [SigmaFiniteFiltration ΞΌ f] (hΟ : IsStoppingTime f Ο) :
SigmaFinite (ΞΌ.trim hΟ.measurableSpace_le) := by
refine @sigmaFiniteTrim_mono _ _ ?_ _ _ _ ?_ ?_
Β· exact f β₯
Β· exact hΟ.le_measurableSpace_of_const_le fun _ => bot_le
Β· infer_instance
instance sigmaFinite_stopping_time_of_le {ΞΉ} [SemilatticeSup ΞΉ] [OrderBot ΞΉ] {ΞΌ : Measure Ξ©}
{f : Filtration ΞΉ m} {Ο : Ξ© β ΞΉ} [SigmaFiniteFiltration ΞΌ f] (hΟ : IsStoppingTime f Ο) {n : ΞΉ}
(hΟ_le : β Ο, Ο Ο β€ n) : SigmaFinite (ΞΌ.trim (hΟ.measurableSpace_le_of_le hΟ_le)) := by
refine @sigmaFiniteTrim_mono _ _ ?_ _ _ _ ?_ ?_
Β· exact f β₯
Β· exact hΟ.le_measurableSpace_of_const_le fun _ => bot_le
Β· infer_instance
section LinearOrder
variable [LinearOrder ΞΉ] {f : Filtration ΞΉ m} {Ο Ο : Ξ© β ΞΉ}
protected theorem measurableSet_le' (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο β€ i} := by
intro j
have : {Ο : Ξ© | Ο Ο β€ i} β© {Ο : Ξ© | Ο Ο β€ j} = {Ο : Ξ© | Ο Ο β€ min i j} := by
ext1 Ο; simp only [Set.mem_inter_iff, Set.mem_setOf_eq, le_min_iff]
rw [this]
exact f.mono (min_le_right i j) _ (hΟ _)
protected theorem measurableSet_gt' (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | i < Ο Ο} := by
have : {Ο : Ξ© | i < Ο Ο} = {Ο : Ξ© | Ο Ο β€ i}αΆ := by ext1 Ο; simp
rw [this]
exact (hΟ.measurableSet_le' i).compl
protected theorem measurableSet_eq' [TopologicalSpace ΞΉ] [OrderTopology ΞΉ]
[FirstCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο = i} := by
rw [β Set.univ_inter {Ο | Ο Ο = i}, measurableSet_inter_eq_iff, Set.univ_inter]
exact hΟ.measurableSet_eq i
protected theorem measurableSet_ge' [TopologicalSpace ΞΉ] [OrderTopology ΞΉ]
[FirstCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | i β€ Ο Ο} := by
have : {Ο | i β€ Ο Ο} = {Ο | Ο Ο = i} βͺ {Ο | i < Ο Ο} := by
ext1 Ο
simp only [le_iff_lt_or_eq, Set.mem_setOf_eq, Set.mem_union]
rw [@eq_comm _ i, or_comm]
rw [this]
exact (hΟ.measurableSet_eq' i).union (hΟ.measurableSet_gt' i)
protected theorem measurableSet_lt' [TopologicalSpace ΞΉ] [OrderTopology ΞΉ]
[FirstCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο < i} := by
have : {Ο | Ο Ο < i} = {Ο | Ο Ο β€ i} \ {Ο | Ο Ο = i} := by
ext1 Ο
simp only [lt_iff_le_and_ne, Set.mem_setOf_eq, Set.mem_diff]
rw [this]
exact (hΟ.measurableSet_le' i).diff (hΟ.measurableSet_eq' i)
section Countable
protected theorem measurableSet_eq_of_countable_range' (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο = i} := by
rw [β Set.univ_inter {Ο | Ο Ο = i}, measurableSet_inter_eq_iff, Set.univ_inter]
exact hΟ.measurableSet_eq_of_countable_range h_countable i
protected theorem measurableSet_eq_of_countable' [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο = i} :=
hΟ.measurableSet_eq_of_countable_range' (Set.to_countable _) i
protected theorem measurableSet_ge_of_countable_range' (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | i β€ Ο Ο} := by
have : {Ο | i β€ Ο Ο} = {Ο | Ο Ο = i} βͺ {Ο | i < Ο Ο} := by
ext1 Ο
simp only [le_iff_lt_or_eq, Set.mem_setOf_eq, Set.mem_union]
rw [@eq_comm _ i, or_comm]
rw [this]
exact (hΟ.measurableSet_eq_of_countable_range' h_countable i).union (hΟ.measurableSet_gt' i)
protected theorem measurableSet_ge_of_countable' [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | i β€ Ο Ο} :=
hΟ.measurableSet_ge_of_countable_range' (Set.to_countable _) i
protected theorem measurableSet_lt_of_countable_range' (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο < i} := by
have : {Ο | Ο Ο < i} = {Ο | Ο Ο β€ i} \ {Ο | Ο Ο = i} := by
ext1 Ο
simp only [lt_iff_le_and_ne, Set.mem_setOf_eq, Set.mem_diff]
rw [this]
exact (hΟ.measurableSet_le' i).diff (hΟ.measurableSet_eq_of_countable_range' h_countable i)
protected theorem measurableSet_lt_of_countable' [Countable ΞΉ] (hΟ : IsStoppingTime f Ο) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο < i} :=
hΟ.measurableSet_lt_of_countable_range' (Set.to_countable _) i
protected theorem measurableSpace_le_of_countable_range (hΟ : IsStoppingTime f Ο)
(h_countable : (Set.range Ο).Countable) : hΟ.measurableSpace β€ m := by
intro s hs
change β i, MeasurableSet[f i] (s β© {Ο | Ο Ο β€ i}) at hs
rw [(_ : s = β i β Set.range Ο, s β© {Ο | Ο Ο β€ i})]
Β· exact MeasurableSet.biUnion h_countable fun i _ => f.le i _ (hs i)
Β· ext Ο
constructor <;> rw [Set.mem_iUnion]
Β· exact fun hx => β¨Ο Ο, by simpa using hxβ©
Β· rintro β¨i, hxβ©
simp only [Set.mem_range, Set.iUnion_exists, Set.mem_iUnion, Set.mem_inter_iff,
Set.mem_setOf_eq, exists_prop, exists_and_right] at hx
exact hx.2.1
end Countable
protected theorem measurable [TopologicalSpace ΞΉ] [MeasurableSpace ΞΉ] [BorelSpace ΞΉ]
[OrderTopology ΞΉ] [SecondCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) :
Measurable[hΟ.measurableSpace] Ο :=
@measurable_of_Iic ΞΉ Ξ© _ _ _ hΟ.measurableSpace _ _ _ _ fun i => hΟ.measurableSet_le' i
protected theorem measurable_of_le [TopologicalSpace ΞΉ] [MeasurableSpace ΞΉ] [BorelSpace ΞΉ]
[OrderTopology ΞΉ] [SecondCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) {i : ΞΉ}
(hΟ_le : β Ο, Ο Ο β€ i) : Measurable[f i] Ο :=
hΟ.measurable.mono (measurableSpace_le_of_le_const _ hΟ_le) le_rfl
theorem measurableSpace_min (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) :
(hΟ.min hΟ).measurableSpace = hΟ.measurableSpace β hΟ.measurableSpace := by
refine le_antisymm ?_ ?_
Β· exact le_inf (measurableSpace_mono _ hΟ fun _ => min_le_left _ _)
(measurableSpace_mono _ hΟ fun _ => min_le_right _ _)
Β· intro s
change MeasurableSet[hΟ.measurableSpace] s β§ MeasurableSet[hΟ.measurableSpace] s β
MeasurableSet[(hΟ.min hΟ).measurableSpace] s
simp_rw [IsStoppingTime.measurableSet]
have : β i, {Ο | min (Ο Ο) (Ο Ο) β€ i} = {Ο | Ο Ο β€ i} βͺ {Ο | Ο Ο β€ i} := by
intro i; ext1 Ο; simp
simp_rw [this, Set.inter_union_distrib_left]
exact fun h i => (h.left i).union (h.right i)
theorem measurableSet_min_iff (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) (s : Set Ξ©) :
MeasurableSet[(hΟ.min hΟ).measurableSpace] s β
MeasurableSet[hΟ.measurableSpace] s β§ MeasurableSet[hΟ.measurableSpace] s := by
rw [measurableSpace_min hΟ hΟ]; rfl
theorem measurableSpace_min_const (hΟ : IsStoppingTime f Ο) {i : ΞΉ} :
(hΟ.min_const i).measurableSpace = hΟ.measurableSpace β f i := by
rw [hΟ.measurableSpace_min (isStoppingTime_const _ i), measurableSpace_const]
theorem measurableSet_min_const_iff (hΟ : IsStoppingTime f Ο) (s : Set Ξ©) {i : ΞΉ} :
MeasurableSet[(hΟ.min_const i).measurableSpace] s β
MeasurableSet[hΟ.measurableSpace] s β§ MeasurableSet[f i] s := by
rw [measurableSpace_min_const hΟ]; apply MeasurableSpace.measurableSet_inf
theorem measurableSet_inter_le [TopologicalSpace ΞΉ] [SecondCountableTopology ΞΉ] [OrderTopology ΞΉ]
[MeasurableSpace ΞΉ] [BorelSpace ΞΉ] (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο)
(s : Set Ξ©) (hs : MeasurableSet[hΟ.measurableSpace] s) :
MeasurableSet[(hΟ.min hΟ).measurableSpace] (s β© {Ο | Ο Ο β€ Ο Ο}) := by
simp_rw [IsStoppingTime.measurableSet] at hs β’
intro i
have : s β© {Ο | Ο Ο β€ Ο Ο} β© {Ο | min (Ο Ο) (Ο Ο) β€ i} =
s β© {Ο | Ο Ο β€ i} β© {Ο | min (Ο Ο) (Ο Ο) β€ i} β©
{Ο | min (Ο Ο) i β€ min (min (Ο Ο) (Ο Ο)) i} := by
ext1 Ο
simp only [min_le_iff, Set.mem_inter_iff, Set.mem_setOf_eq, le_min_iff, le_refl, true_and,
true_or]
by_cases hΟi : Ο Ο β€ i
Β· simp only [hΟi, true_or, and_true, and_congr_right_iff]
intro
constructor <;> intro h
Β· exact Or.inl h
Β· rcases h with h | h
Β· exact h
Β· exact hΟi.trans h
simp only [hΟi, false_or, and_false, false_and, iff_false, not_and, not_le, and_imp]
refine fun _ hΟ_le_Ο => lt_of_lt_of_le ?_ hΟ_le_Ο
rw [β not_le]
exact hΟi
rw [this]
refine ((hs i).inter ((hΟ.min hΟ) i)).inter ?_
apply @measurableSet_le _ _ _ _ _ (Filtration.seq f i) _ _ _ _ _ ?_ ?_
Β· exact (hΟ.min_const i).measurable_of_le fun _ => min_le_right _ _
Β· exact ((hΟ.min hΟ).min_const i).measurable_of_le fun _ => min_le_right _ _
theorem measurableSet_inter_le_iff [TopologicalSpace ΞΉ] [SecondCountableTopology ΞΉ]
[OrderTopology ΞΉ] [MeasurableSpace ΞΉ] [BorelSpace ΞΉ] (hΟ : IsStoppingTime f Ο)
(hΟ : IsStoppingTime f Ο) (s : Set Ξ©) :
MeasurableSet[hΟ.measurableSpace] (s β© {Ο | Ο Ο β€ Ο Ο}) β
MeasurableSet[(hΟ.min hΟ).measurableSpace] (s β© {Ο | Ο Ο β€ Ο Ο}) := by
constructor <;> intro h
Β· have : s β© {Ο | Ο Ο β€ Ο Ο} = s β© {Ο | Ο Ο β€ Ο Ο} β© {Ο | Ο Ο β€ Ο Ο} := by
rw [Set.inter_assoc, Set.inter_self]
rw [this]
exact measurableSet_inter_le _ hΟ _ h
Β· rw [measurableSet_min_iff hΟ hΟ] at h
exact h.1
theorem measurableSet_inter_le_const_iff (hΟ : IsStoppingTime f Ο) (s : Set Ξ©) (i : ΞΉ) :
MeasurableSet[hΟ.measurableSpace] (s β© {Ο | Ο Ο β€ i}) β
MeasurableSet[(hΟ.min_const i).measurableSpace] (s β© {Ο | Ο Ο β€ i}) := by
rw [IsStoppingTime.measurableSet_min_iff hΟ (isStoppingTime_const _ i),
IsStoppingTime.measurableSpace_const, IsStoppingTime.measurableSet]
refine β¨fun h => β¨h, ?_β©, fun h j => h.1 jβ©
specialize h i
rwa [Set.inter_assoc, Set.inter_self] at h
theorem measurableSet_le_stopping_time [TopologicalSpace ΞΉ] [SecondCountableTopology ΞΉ]
[OrderTopology ΞΉ] [MeasurableSpace ΞΉ] [BorelSpace ΞΉ] (hΟ : IsStoppingTime f Ο)
(hΟ : IsStoppingTime f Ο) : MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο β€ Ο Ο} := by
rw [hΟ.measurableSet]
intro j
have : {Ο | Ο Ο β€ Ο Ο} β© {Ο | Ο Ο β€ j} = {Ο | min (Ο Ο) j β€ min (Ο Ο) j} β© {Ο | Ο Ο β€ j} := by
ext1 Ο
simp only [Set.mem_inter_iff, Set.mem_setOf_eq, min_le_iff, le_min_iff, le_refl,
and_congr_left_iff]
intro h
simp only [h, or_self_iff, and_true]
rw [Iff.comm, or_iff_left_iff_imp]
exact h.trans
rw [this]
refine MeasurableSet.inter ?_ (hΟ.measurableSet_le j)
apply @measurableSet_le _ _ _ _ _ (Filtration.seq f j) _ _ _ _ _ ?_ ?_
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
theorem measurableSet_stopping_time_le [TopologicalSpace ΞΉ] [SecondCountableTopology ΞΉ]
[OrderTopology ΞΉ] [MeasurableSpace ΞΉ] [BorelSpace ΞΉ] (hΟ : IsStoppingTime f Ο)
(hΟ : IsStoppingTime f Ο) : MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο β€ Ο Ο} := by
suffices MeasurableSet[(hΟ.min hΟ).measurableSpace] {Ο : Ξ© | Ο Ο β€ Ο Ο} by
rw [measurableSet_min_iff hΟ hΟ] at this; exact this.2
rw [β Set.univ_inter {Ο : Ξ© | Ο Ο β€ Ο Ο}, β hΟ.measurableSet_inter_le_iff hΟ, Set.univ_inter]
exact measurableSet_le_stopping_time hΟ hΟ
theorem measurableSet_eq_stopping_time [AddGroup ΞΉ] [TopologicalSpace ΞΉ] [MeasurableSpace ΞΉ]
[BorelSpace ΞΉ] [OrderTopology ΞΉ] [MeasurableSingletonClass ΞΉ] [SecondCountableTopology ΞΉ]
[MeasurableSubβ ΞΉ] (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο = Ο Ο} := by
rw [hΟ.measurableSet]
intro j
have : {Ο | Ο Ο = Ο Ο} β© {Ο | Ο Ο β€ j} =
{Ο | min (Ο Ο) j = min (Ο Ο) j} β© {Ο | Ο Ο β€ j} β© {Ο | Ο Ο β€ j} := by
ext1 Ο
simp only [Set.mem_inter_iff, Set.mem_setOf_eq]
refine β¨fun h => β¨β¨?_, h.2β©, ?_β©, fun h => β¨?_, h.1.2β©β©
Β· rw [h.1]
Β· rw [β h.1]; exact h.2
Β· obtain β¨h', hΟ_leβ© := h
obtain β¨h_eq, hΟ_leβ© := h'
rwa [min_eq_left hΟ_le, min_eq_left hΟ_le] at h_eq
rw [this]
refine
MeasurableSet.inter (MeasurableSet.inter ?_ (hΟ.measurableSet_le j)) (hΟ.measurableSet_le j)
apply measurableSet_eq_fun
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
theorem measurableSet_eq_stopping_time_of_countable [Countable ΞΉ] [TopologicalSpace ΞΉ]
[MeasurableSpace ΞΉ] [BorelSpace ΞΉ] [OrderTopology ΞΉ] [MeasurableSingletonClass ΞΉ]
[SecondCountableTopology ΞΉ] (hΟ : IsStoppingTime f Ο) (hΟ : IsStoppingTime f Ο) :
MeasurableSet[hΟ.measurableSpace] {Ο | Ο Ο = Ο Ο} := by
rw [hΟ.measurableSet]
intro j
have : {Ο | Ο Ο = Ο Ο} β© {Ο | Ο Ο β€ j} =
{Ο | min (Ο Ο) j = min (Ο Ο) j} β© {Ο | Ο Ο β€ j} β© {Ο | Ο Ο β€ j} := by
ext1 Ο
simp only [Set.mem_inter_iff, Set.mem_setOf_eq]
refine β¨fun h => β¨β¨?_, h.2β©, ?_β©, fun h => β¨?_, h.1.2β©β©
Β· rw [h.1]
Β· rw [β h.1]; exact h.2
Β· obtain β¨h', hΟ_leβ© := h
obtain β¨h_eq, hΟ_leβ© := h'
rwa [min_eq_left hΟ_le, min_eq_left hΟ_le] at h_eq
rw [this]
refine
MeasurableSet.inter (MeasurableSet.inter ?_ (hΟ.measurableSet_le j)) (hΟ.measurableSet_le j)
apply measurableSet_eq_fun_of_countable
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
Β· exact (hΟ.min_const j).measurable_of_le fun _ => min_le_right _ _
end LinearOrder
end IsStoppingTime
section LinearOrder
/-! ## Stopped value and stopped process -/
/-- Given a map `u : ΞΉ β Ξ© β E`, its stopped value with respect to the stopping
time `Ο` is the map `x β¦ u (Ο Ο) Ο`. -/
def stoppedValue (u : ΞΉ β Ξ© β Ξ²) (Ο : Ξ© β ΞΉ) : Ξ© β Ξ² := fun Ο => u (Ο Ο) Ο
theorem stoppedValue_const (u : ΞΉ β Ξ© β Ξ²) (i : ΞΉ) : (stoppedValue u fun _ => i) = u i :=
rfl
variable [LinearOrder ΞΉ]
/-- Given a map `u : ΞΉ β Ξ© β E`, the stopped process with respect to `Ο` is `u i Ο` if
`i β€ Ο Ο`, and `u (Ο Ο) Ο` otherwise.
Intuitively, the stopped process stops evolving once the stopping time has occurred. -/
def stoppedProcess (u : ΞΉ β Ξ© β Ξ²) (Ο : Ξ© β ΞΉ) : ΞΉ β Ξ© β Ξ² := fun i Ο => u (min i (Ο Ο)) Ο
| Mathlib/Probability/Process/Stopping.lean | 703 | 724 | theorem stoppedProcess_eq_stoppedValue {u : ΞΉ β Ξ© β Ξ²} {Ο : Ξ© β ΞΉ} :
stoppedProcess u Ο = fun i => stoppedValue u fun Ο => min i (Ο Ο) :=
rfl
theorem stoppedValue_stoppedProcess {u : ΞΉ β Ξ© β Ξ²} {Ο Ο : Ξ© β ΞΉ} :
stoppedValue (stoppedProcess u Ο) Ο = stoppedValue u fun Ο => min (Ο Ο) (Ο Ο) :=
rfl
theorem stoppedProcess_eq_of_le {u : ΞΉ β Ξ© β Ξ²} {Ο : Ξ© β ΞΉ} {i : ΞΉ} {Ο : Ξ©} (h : i β€ Ο Ο) :
stoppedProcess u Ο i Ο = u i Ο := by | simp [stoppedProcess, min_eq_left h]
theorem stoppedProcess_eq_of_ge {u : ΞΉ β Ξ© β Ξ²} {Ο : Ξ© β ΞΉ} {i : ΞΉ} {Ο : Ξ©} (h : Ο Ο β€ i) :
stoppedProcess u Ο i Ο = u (Ο Ο) Ο := by simp [stoppedProcess, min_eq_right h]
section ProgMeasurable
variable [MeasurableSpace ΞΉ] [TopologicalSpace ΞΉ] [OrderTopology ΞΉ] [SecondCountableTopology ΞΉ]
[BorelSpace ΞΉ] [TopologicalSpace Ξ²] {u : ΞΉ β Ξ© β Ξ²} {Ο : Ξ© β ΞΉ} {f : Filtration ΞΉ m}
theorem progMeasurable_min_stopping_time [MetrizableSpace ΞΉ] (hΟ : IsStoppingTime f Ο) :
ProgMeasurable f fun i Ο => min i (Ο Ο) := by
intro i |
/-
Copyright (c) 2023 SΓ©bastien GouΓ«zel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SΓ©bastien GouΓ«zel
-/
import Mathlib.Analysis.Calculus.Deriv.Comp
import Mathlib.Analysis.Calculus.Deriv.Add
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Slope
/-!
# Line derivatives
We define the line derivative of a function `f : E β F`, at a point `x : E` along a vector `v : E`,
as the element `f' : F` such that `f (x + t β’ v) = f x + t β’ f' + o (t)` as `t` tends to `0` in
the scalar field `π`, if it exists. It is denoted by `lineDeriv π f x v`.
This notion is generally less well behaved than the full FrΓ©chet derivative (for instance, the
composition of functions which are line-differentiable is not line-differentiable in general).
The FrΓ©chet derivative should therefore be favored over this one in general, although the line
derivative may sometimes prove handy.
The line derivative in direction `v` is also called the Gateaux derivative in direction `v`,
although the term "Gateaux derivative" is sometimes reserved for the situation where there is
such a derivative in all directions, for the map `v β¦ lineDeriv π f x v` (which doesn't have to be
linear in general).
## Main definition and results
We mimic the definitions and statements for the FrΓ©chet derivative and the one-dimensional
derivative. We define in particular the following objects:
* `LineDifferentiableWithinAt π f s x v`
* `LineDifferentiableAt π f x v`
* `HasLineDerivWithinAt π f f' s x v`
* `HasLineDerivAt π f s x v`
* `lineDerivWithin π f s x v`
* `lineDeriv π f x v`
and develop about them a basic API inspired by the one for the FrΓ©chet derivative.
We depart from the FrΓ©chet derivative in two places, as the dependence of the following predicates
on the direction would make them barely usable:
* We do not define an analogue of the predicate `UniqueDiffOn`;
* We do not define `LineDifferentiableOn` nor `LineDifferentiable`.
-/
noncomputable section
open scoped Topology Filter ENNReal NNReal
open Filter Asymptotics Set
variable {π : Type*} [NontriviallyNormedField π]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace π F]
section Module
/-!
Results that do not rely on a topological structure on `E`
-/
variable (π)
variable {E : Type*} [AddCommGroup E] [Module π E]
/-- `f` has the derivative `f'` at the point `x` along the direction `v` in the set `s`.
That is, `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0` and `x + t v β s`.
Note that this definition is less well behaved than the total FrΓ©chet derivative, which
should generally be favored over this one. -/
def HasLineDerivWithinAt (f : E β F) (f' : F) (s : Set E) (x : E) (v : E) :=
HasDerivWithinAt (fun t β¦ f (x + t β’ v)) f' ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- `f` has the derivative `f'` at the point `x` along the direction `v`.
That is, `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0`.
Note that this definition is less well behaved than the total FrΓ©chet derivative, which
should generally be favored over this one. -/
def HasLineDerivAt (f : E β F) (f' : F) (x : E) (v : E) :=
HasDerivAt (fun t β¦ f (x + t β’ v)) f' (0 : π)
/-- `f` is line-differentiable at the point `x` in the direction `v` in the set `s` if there
exists `f'` such that `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0` and `x + t v β s`.
-/
def LineDifferentiableWithinAt (f : E β F) (s : Set E) (x : E) (v : E) : Prop :=
DifferentiableWithinAt π (fun t β¦ f (x + t β’ v)) ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- `f` is line-differentiable at the point `x` in the direction `v` if there
exists `f'` such that `f (x + t v) = f x + t β’ f' + o (t)` when `t` tends to `0`. -/
def LineDifferentiableAt (f : E β F) (x : E) (v : E) : Prop :=
DifferentiableAt π (fun t β¦ f (x + t β’ v)) (0 : π)
/-- Line derivative of `f` at the point `x` in the direction `v` within the set `s`, if it exists.
Zero otherwise.
If the line derivative exists (i.e., `β f', HasLineDerivWithinAt π f f' s x v`), then
`f (x + t v) = f x + t lineDerivWithin π f s x v + o (t)` when `t` tends to `0` and `x + t v β s`.
-/
def lineDerivWithin (f : E β F) (s : Set E) (x : E) (v : E) : F :=
derivWithin (fun t β¦ f (x + t β’ v)) ((fun t β¦ x + t β’ v) β»ΒΉ' s) (0 : π)
/-- Line derivative of `f` at the point `x` in the direction `v`, if it exists. Zero otherwise.
If the line derivative exists (i.e., `β f', HasLineDerivAt π f f' x v`), then
`f (x + t v) = f x + t lineDeriv π f x v + o (t)` when `t` tends to `0`.
-/
def lineDeriv (f : E β F) (x : E) (v : E) : F :=
deriv (fun t β¦ f (x + t β’ v)) (0 : π)
variable {π}
variable {f fβ : E β F} {f' fβ' fβ' : F} {s t : Set E} {x v : E}
lemma HasLineDerivWithinAt.mono (hf : HasLineDerivWithinAt π f f' s x v) (hst : t β s) :
HasLineDerivWithinAt π f f' t x v :=
HasDerivWithinAt.mono hf (preimage_mono hst)
lemma HasLineDerivAt.hasLineDerivWithinAt (hf : HasLineDerivAt π f f' x v) (s : Set E) :
HasLineDerivWithinAt π f f' s x v :=
HasDerivAt.hasDerivWithinAt hf
lemma HasLineDerivWithinAt.lineDifferentiableWithinAt (hf : HasLineDerivWithinAt π f f' s x v) :
LineDifferentiableWithinAt π f s x v :=
HasDerivWithinAt.differentiableWithinAt hf
theorem HasLineDerivAt.lineDifferentiableAt (hf : HasLineDerivAt π f f' x v) :
LineDifferentiableAt π f x v :=
HasDerivAt.differentiableAt hf
theorem LineDifferentiableWithinAt.hasLineDerivWithinAt (h : LineDifferentiableWithinAt π f s x v) :
HasLineDerivWithinAt π f (lineDerivWithin π f s x v) s x v :=
DifferentiableWithinAt.hasDerivWithinAt h
theorem LineDifferentiableAt.hasLineDerivAt (h : LineDifferentiableAt π f x v) :
HasLineDerivAt π f (lineDeriv π f x v) x v :=
DifferentiableAt.hasDerivAt h
@[simp] lemma hasLineDerivWithinAt_univ :
HasLineDerivWithinAt π f f' univ x v β HasLineDerivAt π f f' x v := by
simp only [HasLineDerivWithinAt, HasLineDerivAt, preimage_univ, hasDerivWithinAt_univ]
theorem lineDerivWithin_zero_of_not_lineDifferentiableWithinAt
(h : Β¬LineDifferentiableWithinAt π f s x v) :
lineDerivWithin π f s x v = 0 :=
derivWithin_zero_of_not_differentiableWithinAt h
theorem lineDeriv_zero_of_not_lineDifferentiableAt (h : Β¬LineDifferentiableAt π f x v) :
lineDeriv π f x v = 0 :=
deriv_zero_of_not_differentiableAt h
theorem hasLineDerivAt_iff_isLittleO_nhds_zero :
HasLineDerivAt π f f' x v β
(fun t : π => f (x + t β’ v) - f x - t β’ f') =o[π 0] fun t => t := by
simp only [HasLineDerivAt, hasDerivAt_iff_isLittleO_nhds_zero, zero_add, zero_smul, add_zero]
theorem HasLineDerivAt.unique (hβ : HasLineDerivAt π f fβ' x v) (hβ : HasLineDerivAt π f fβ' x v) :
fβ' = fβ' :=
HasDerivAt.unique hβ hβ
protected theorem HasLineDerivAt.lineDeriv (h : HasLineDerivAt π f f' x v) :
lineDeriv π f x v = f' := by
rw [h.unique h.lineDifferentiableAt.hasLineDerivAt]
theorem lineDifferentiableWithinAt_univ :
LineDifferentiableWithinAt π f univ x v β LineDifferentiableAt π f x v := by
simp only [LineDifferentiableWithinAt, LineDifferentiableAt, preimage_univ,
differentiableWithinAt_univ]
theorem LineDifferentiableAt.lineDifferentiableWithinAt (h : LineDifferentiableAt π f x v) :
LineDifferentiableWithinAt π f s x v :=
(differentiableWithinAt_univ.2 h).mono (subset_univ _)
@[simp]
| Mathlib/Analysis/Calculus/LineDeriv/Basic.lean | 170 | 171 | theorem lineDerivWithin_univ : lineDerivWithin π f univ x v = lineDeriv π f x v := by | simp [lineDerivWithin, lineDeriv] |
/-
Copyright (c) 2023 RΓ©my Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: RΓ©my Degenne
-/
import Mathlib.Probability.ConditionalProbability
import Mathlib.Probability.Kernel.Basic
import Mathlib.Probability.Kernel.Composition.MeasureComp
import Mathlib.Tactic.Peel
import Mathlib.MeasureTheory.MeasurableSpace.Pi
/-!
# Independence with respect to a kernel and a measure
A family of sets of sets `Ο : ΞΉ β Set (Set Ξ©)` is independent with respect to a kernel
`ΞΊ : Kernel Ξ± Ξ©` and a measure `ΞΌ` on `Ξ±` if for any finite set of indices `s = {i_1, ..., i_n}`,
for any sets `f i_1 β Ο i_1, ..., f i_n β Ο i_n`, then for `ΞΌ`-almost every `a : Ξ±`,
`ΞΊ a (β i in s, f i) = β i β s, ΞΊ a (f i)`.
This notion of independence is a generalization of both independence and conditional independence.
For conditional independence, `ΞΊ` is the conditional kernel `ProbabilityTheory.condExpKernel` and
`ΞΌ` is the ambient measure. For (non-conditional) independence, `ΞΊ = Kernel.const Unit ΞΌ` and the
measure is the Dirac measure on `Unit`.
The main purpose of this file is to prove only once the properties that hold for both conditional
and non-conditional independence.
## Main definitions
* `ProbabilityTheory.Kernel.iIndepSets`: independence of a family of sets of sets.
Variant for two sets of sets: `ProbabilityTheory.Kernel.IndepSets`.
* `ProbabilityTheory.Kernel.iIndep`: independence of a family of Ο-algebras. Variant for two
Ο-algebras: `Indep`.
* `ProbabilityTheory.Kernel.iIndepSet`: independence of a family of sets. Variant for two sets:
`ProbabilityTheory.Kernel.IndepSet`.
* `ProbabilityTheory.Kernel.iIndepFun`: independence of a family of functions (random variables).
Variant for two functions: `ProbabilityTheory.Kernel.IndepFun`.
See the file `Mathlib/Probability/Kernel/Basic.lean` for a more detailed discussion of these
definitions in the particular case of the usual independence notion.
## Main statements
* `ProbabilityTheory.Kernel.iIndepSets.iIndep`: if Ο-systems are independent as sets of sets,
then the measurable space structures they generate are independent.
* `ProbabilityTheory.Kernel.IndepSets.Indep`: variant with two Ο-systems.
-/
open Set MeasureTheory MeasurableSpace
open scoped MeasureTheory ENNReal
namespace ProbabilityTheory.Kernel
variable {Ξ± Ξ© ΞΉ : Type*}
section Definitions
variable {_mΞ± : MeasurableSpace Ξ±}
/-- A family of sets of sets `Ο : ΞΉ β Set (Set Ξ©)` is independent with respect to a kernel `ΞΊ` and
a measure `ΞΌ` if for any finite set of indices `s = {i_1, ..., i_n}`, for any sets
`f i_1 β Ο i_1, ..., f i_n β Ο i_n`, then `βα΅ a βΞΌ, ΞΊ a (β i in s, f i) = β i β s, ΞΊ a (f i)`.
It will be used for families of pi_systems. -/
def iIndepSets {_mΞ© : MeasurableSpace Ξ©}
(Ο : ΞΉ β Set (Set Ξ©)) (ΞΊ : Kernel Ξ± Ξ©) (ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
β (s : Finset ΞΉ) {f : ΞΉ β Set Ξ©} (_H : β i, i β s β f i β Ο i),
βα΅ a βΞΌ, ΞΊ a (β i β s, f i) = β i β s, ΞΊ a (f i)
/-- Two sets of sets `sβ, sβ` are independent with respect to a kernel `ΞΊ` and a measure `ΞΌ` if for
any sets `tβ β sβ, tβ β sβ`, then `βα΅ a βΞΌ, ΞΊ a (tβ β© tβ) = ΞΊ a (tβ) * ΞΊ a (tβ)` -/
def IndepSets {_mΞ© : MeasurableSpace Ξ©}
(s1 s2 : Set (Set Ξ©)) (ΞΊ : Kernel Ξ± Ξ©) (ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
β t1 t2 : Set Ξ©, t1 β s1 β t2 β s2 β (βα΅ a βΞΌ, ΞΊ a (t1 β© t2) = ΞΊ a t1 * ΞΊ a t2)
/-- A family of measurable space structures (i.e. of Ο-algebras) is independent with respect to a
kernel `ΞΊ` and a measure `ΞΌ` if the family of sets of measurable sets they define is independent. -/
def iIndep (m : ΞΉ β MeasurableSpace Ξ©) {_mΞ© : MeasurableSpace Ξ©} (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
iIndepSets (fun x β¦ {s | MeasurableSet[m x] s}) ΞΊ ΞΌ
/-- Two measurable space structures (or Ο-algebras) `mβ, mβ` are independent with respect to a
kernel `ΞΊ` and a measure `ΞΌ` if for any sets `tβ β mβ, tβ β mβ`,
`βα΅ a βΞΌ, ΞΊ a (tβ β© tβ) = ΞΊ a (tβ) * ΞΊ a (tβ)` -/
def Indep (mβ mβ : MeasurableSpace Ξ©) {_mΞ© : MeasurableSpace Ξ©} (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
IndepSets {s | MeasurableSet[mβ] s} {s | MeasurableSet[mβ] s} ΞΊ ΞΌ
/-- A family of sets is independent if the family of measurable space structures they generate is
independent. For a set `s`, the generated measurable space has measurable sets `β
, s, sαΆ, univ`. -/
def iIndepSet {_mΞ© : MeasurableSpace Ξ©} (s : ΞΉ β Set Ξ©) (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
iIndep (m := fun i β¦ generateFrom {s i}) ΞΊ ΞΌ
/-- Two sets are independent if the two measurable space structures they generate are independent.
For a set `s`, the generated measurable space structure has measurable sets `β
, s, sαΆ, univ`. -/
def IndepSet {_mΞ© : MeasurableSpace Ξ©} (s t : Set Ξ©) (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
Indep (generateFrom {s}) (generateFrom {t}) ΞΊ ΞΌ
/-- A family of functions defined on the same space `Ξ©` and taking values in possibly different
spaces, each with a measurable space structure, is independent if the family of measurable space
structures they generate on `Ξ©` is independent. For a function `g` with codomain having measurable
space structure `m`, the generated measurable space structure is `MeasurableSpace.comap g m`. -/
def iIndepFun {_mΞ© : MeasurableSpace Ξ©} {Ξ² : ΞΉ β Type*} [m : β x : ΞΉ, MeasurableSpace (Ξ² x)]
(f : β x : ΞΉ, Ξ© β Ξ² x) (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
iIndep (m := fun x β¦ MeasurableSpace.comap (f x) (m x)) ΞΊ ΞΌ
/-- Two functions are independent if the two measurable space structures they generate are
independent. For a function `f` with codomain having measurable space structure `m`, the generated
measurable space structure is `MeasurableSpace.comap f m`. -/
def IndepFun {Ξ² Ξ³} {_mΞ© : MeasurableSpace Ξ©} [mΞ² : MeasurableSpace Ξ²] [mΞ³ : MeasurableSpace Ξ³]
(f : Ξ© β Ξ²) (g : Ξ© β Ξ³) (ΞΊ : Kernel Ξ± Ξ©)
(ΞΌ : Measure Ξ± := by volume_tac) : Prop :=
Indep (MeasurableSpace.comap f mΞ²) (MeasurableSpace.comap g mΞ³) ΞΊ ΞΌ
end Definitions
section ByDefinition
variable {Ξ² : ΞΉ β Type*} {mΞ² : β i, MeasurableSpace (Ξ² i)}
{_mΞ± : MeasurableSpace Ξ±} {m : ΞΉ β MeasurableSpace Ξ©} {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ Ξ· : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±}
{Ο : ΞΉ β Set (Set Ξ©)} {s : ΞΉ β Set Ξ©} {S : Finset ΞΉ} {f : β x : ΞΉ, Ξ© β Ξ² x}
{s1 s2 : Set (Set Ξ©)}
@[simp] lemma iIndepSets_zero_right : iIndepSets Ο ΞΊ 0 := by simp [iIndepSets]
@[simp] lemma indepSets_zero_right : IndepSets s1 s2 ΞΊ 0 := by simp [IndepSets]
@[simp] lemma indepSets_zero_left : IndepSets s1 s2 (0 : Kernel Ξ± Ξ©) ΞΌ := by simp [IndepSets]
@[simp] lemma iIndep_zero_right : iIndep m ΞΊ 0 := by simp [iIndep]
@[simp] lemma indep_zero_right {mβ mβ : MeasurableSpace Ξ©} {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} : Indep mβ mβ ΞΊ 0 := by simp [Indep]
@[simp] lemma indep_zero_left {mβ mβ : MeasurableSpace Ξ©} {_mΞ© : MeasurableSpace Ξ©} :
Indep mβ mβ (0 : Kernel Ξ± Ξ©) ΞΌ := by simp [Indep]
@[simp] lemma iIndepSet_zero_right : iIndepSet s ΞΊ 0 := by simp [iIndepSet]
@[simp] lemma indepSet_zero_right {s t : Set Ξ©} : IndepSet s t ΞΊ 0 := by simp [IndepSet]
@[simp] lemma indepSet_zero_left {s t : Set Ξ©} : IndepSet s t (0 : Kernel Ξ± Ξ©) ΞΌ := by
simp [IndepSet]
@[simp] lemma iIndepFun_zero_right {Ξ² : ΞΉ β Type*} {m : β x : ΞΉ, MeasurableSpace (Ξ² x)}
{f : β x : ΞΉ, Ξ© β Ξ² x} : iIndepFun f ΞΊ 0 := by simp [iIndepFun]
@[simp] lemma indepFun_zero_right {Ξ² Ξ³} [MeasurableSpace Ξ²] [MeasurableSpace Ξ³]
{f : Ξ© β Ξ²} {g : Ξ© β Ξ³} : IndepFun f g ΞΊ 0 := by simp [IndepFun]
@[simp] lemma indepFun_zero_left {Ξ² Ξ³} [MeasurableSpace Ξ²] [MeasurableSpace Ξ³]
{f : Ξ© β Ξ²} {g : Ξ© β Ξ³} : IndepFun f g (0 : Kernel Ξ± Ξ©) ΞΌ := by simp [IndepFun]
lemma iIndepSets_congr (h : ΞΊ =α΅[ΞΌ] Ξ·) : iIndepSets Ο ΞΊ ΞΌ β iIndepSets Ο Ξ· ΞΌ := by
peel 3
refine β¨fun h' β¦ ?_, fun h' β¦ ?_β© <;>
Β· filter_upwards [h, h'] with a ha h'a
simpa [ha] using h'a
alias β¨iIndepSets.congr, _β© := iIndepSets_congr
lemma indepSets_congr (h : ΞΊ =α΅[ΞΌ] Ξ·) : IndepSets s1 s2 ΞΊ ΞΌ β IndepSets s1 s2 Ξ· ΞΌ := by
peel 4
refine β¨fun h' β¦ ?_, fun h' β¦ ?_β© <;>
Β· filter_upwards [h, h'] with a ha h'a
simpa [ha] using h'a
alias β¨IndepSets.congr, _β© := indepSets_congr
lemma iIndep_congr (h : ΞΊ =α΅[ΞΌ] Ξ·) : iIndep m ΞΊ ΞΌ β iIndep m Ξ· ΞΌ :=
iIndepSets_congr h
alias β¨iIndep.congr, _β© := iIndep_congr
lemma indep_congr {mβ mβ : MeasurableSpace Ξ©} {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ Ξ· : Kernel Ξ± Ξ©} (h : ΞΊ =α΅[ΞΌ] Ξ·) : Indep mβ mβ ΞΊ ΞΌ β Indep mβ mβ Ξ· ΞΌ :=
indepSets_congr h
alias β¨Indep.congr, _β© := indep_congr
lemma iIndepSet_congr (h : ΞΊ =α΅[ΞΌ] Ξ·) : iIndepSet s ΞΊ ΞΌ β iIndepSet s Ξ· ΞΌ :=
iIndep_congr h
alias β¨iIndepSet.congr, _β© := iIndepSet_congr
lemma indepSet_congr {s t : Set Ξ©} (h : ΞΊ =α΅[ΞΌ] Ξ·) : IndepSet s t ΞΊ ΞΌ β IndepSet s t Ξ· ΞΌ :=
indep_congr h
alias β¨indepSet.congr, _β© := indepSet_congr
lemma iIndepFun_congr {Ξ² : ΞΉ β Type*} {m : β x : ΞΉ, MeasurableSpace (Ξ² x)}
{f : β x : ΞΉ, Ξ© β Ξ² x} (h : ΞΊ =α΅[ΞΌ] Ξ·) : iIndepFun f ΞΊ ΞΌ β iIndepFun f Ξ· ΞΌ :=
iIndep_congr h
alias β¨iIndepFun.congr, _β© := iIndepFun_congr
lemma indepFun_congr {Ξ² Ξ³} [MeasurableSpace Ξ²] [MeasurableSpace Ξ³]
{f : Ξ© β Ξ²} {g : Ξ© β Ξ³} (h : ΞΊ =α΅[ΞΌ] Ξ·) : IndepFun f g ΞΊ ΞΌ β IndepFun f g Ξ· ΞΌ :=
indep_congr h
alias β¨IndepFun.congr, _β© := indepFun_congr
lemma iIndepSets.meas_biInter (h : iIndepSets Ο ΞΊ ΞΌ) (s : Finset ΞΉ)
{f : ΞΉ β Set Ξ©} (hf : β i, i β s β f i β Ο i) :
βα΅ a βΞΌ, ΞΊ a (β i β s, f i) = β i β s, ΞΊ a (f i) := h s hf
lemma iIndepSets.ae_isProbabilityMeasure (h : iIndepSets Ο ΞΊ ΞΌ) :
βα΅ a βΞΌ, IsProbabilityMeasure (ΞΊ a) := by
filter_upwards [h.meas_biInter β
(f := fun _ β¦ Set.univ) (by simp)] with a ha
exact β¨by simpa using haβ©
lemma iIndepSets.meas_iInter [Fintype ΞΉ] (h : iIndepSets Ο ΞΊ ΞΌ) (hs : β i, s i β Ο i) :
βα΅ a βΞΌ, ΞΊ a (β i, s i) = β i, ΞΊ a (s i) := by
filter_upwards [h.meas_biInter Finset.univ (fun _i _ β¦ hs _)] with a ha using by simp [β ha]
lemma iIndep.iIndepSets' (hΞΌ : iIndep m ΞΊ ΞΌ) :
iIndepSets (fun x β¦ {s | MeasurableSet[m x] s}) ΞΊ ΞΌ := hΞΌ
lemma iIndep.ae_isProbabilityMeasure (h : iIndep m ΞΊ ΞΌ) :
βα΅ a βΞΌ, IsProbabilityMeasure (ΞΊ a) :=
h.iIndepSets'.ae_isProbabilityMeasure
lemma iIndep.meas_biInter (hΞΌ : iIndep m ΞΊ ΞΌ) (hs : β i, i β S β MeasurableSet[m i] (s i)) :
βα΅ a βΞΌ, ΞΊ a (β i β S, s i) = β i β S, ΞΊ a (s i) := hΞΌ _ hs
lemma iIndep.meas_iInter [Fintype ΞΉ] (h : iIndep m ΞΊ ΞΌ) (hs : β i, MeasurableSet[m i] (s i)) :
βα΅ a βΞΌ, ΞΊ a (β i, s i) = β i, ΞΊ a (s i) := by
filter_upwards [h.meas_biInter (fun i (_ : i β Finset.univ) β¦ hs _)] with a ha
simp [β ha]
@[nontriviality, simp]
lemma iIndepSets.of_subsingleton [Subsingleton ΞΉ] {m : ΞΉ β Set (Set Ξ©)} {ΞΊ : Kernel Ξ± Ξ©}
[IsMarkovKernel ΞΊ] : iIndepSets m ΞΊ ΞΌ := by
rintro s f hf
obtain rfl | β¨i, rflβ© : s = β
β¨ β i, s = {i} := by
simpa using (subsingleton_of_subsingleton (s := s.toSet)).eq_empty_or_singleton
all_goals simp
@[nontriviality, simp]
lemma iIndep.of_subsingleton [Subsingleton ΞΉ] {m : ΞΉ β MeasurableSpace Ξ©} {ΞΊ : Kernel Ξ± Ξ©}
[IsMarkovKernel ΞΊ] : iIndep m ΞΊ ΞΌ := by simp [iIndep]
@[nontriviality, simp]
lemma iIndepFun.of_subsingleton [Subsingleton ΞΉ] {Ξ² : ΞΉ β Type*} {m : β i, MeasurableSpace (Ξ² i)}
{f : β i, Ξ© β Ξ² i} [IsMarkovKernel ΞΊ] : iIndepFun f ΞΊ ΞΌ := by
simp [iIndepFun]
protected lemma iIndepFun.iIndep (hf : iIndepFun f ΞΊ ΞΌ) :
iIndep (fun x β¦ (mΞ² x).comap (f x)) ΞΊ ΞΌ := hf
lemma iIndepFun.ae_isProbabilityMeasure (h : iIndepFun f ΞΊ ΞΌ) :
βα΅ a βΞΌ, IsProbabilityMeasure (ΞΊ a) :=
h.iIndep.ae_isProbabilityMeasure
lemma iIndepFun.meas_biInter (hf : iIndepFun f ΞΊ ΞΌ)
(hs : β i, i β S β MeasurableSet[(mΞ² i).comap (f i)] (s i)) :
βα΅ a βΞΌ, ΞΊ a (β i β S, s i) = β i β S, ΞΊ a (s i) := hf.iIndep.meas_biInter hs
lemma iIndepFun.meas_iInter [Fintype ΞΉ] (hf : iIndepFun f ΞΊ ΞΌ)
(hs : β i, MeasurableSet[(mΞ² i).comap (f i)] (s i)) :
βα΅ a βΞΌ, ΞΊ a (β i, s i) = β i, ΞΊ a (s i) := hf.iIndep.meas_iInter hs
lemma IndepFun.meas_inter {Ξ² Ξ³ : Type*} [mΞ² : MeasurableSpace Ξ²] [mΞ³ : MeasurableSpace Ξ³]
{f : Ξ© β Ξ²} {g : Ξ© β Ξ³} (hfg : IndepFun f g ΞΊ ΞΌ)
{s t : Set Ξ©} (hs : MeasurableSet[mΞ².comap f] s) (ht : MeasurableSet[mΞ³.comap g] t) :
βα΅ a βΞΌ, ΞΊ a (s β© t) = ΞΊ a s * ΞΊ a t := hfg _ _ hs ht
end ByDefinition
section Indep
variable {_mΞ± : MeasurableSpace Ξ±}
@[symm]
theorem IndepSets.symm {_mΞ© : MeasurableSpace Ξ©} {ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±}
{sβ sβ : Set (Set Ξ©)} (h : IndepSets sβ sβ ΞΊ ΞΌ) :
IndepSets sβ sβ ΞΊ ΞΌ := by
intros t1 t2 ht1 ht2
filter_upwards [h t2 t1 ht2 ht1] with a ha
rwa [Set.inter_comm, mul_comm]
@[symm]
theorem Indep.symm {mβ mβ : MeasurableSpace Ξ©} {_mΞ© : MeasurableSpace Ξ©} {ΞΊ : Kernel Ξ± Ξ©}
{ΞΌ : Measure Ξ±} (h : Indep mβ mβ ΞΊ ΞΌ) :
Indep mβ mβ ΞΊ ΞΌ :=
IndepSets.symm h
theorem indep_bot_right (m' : MeasurableSpace Ξ©) {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±} [IsZeroOrMarkovKernel ΞΊ] :
Indep m' β₯ ΞΊ ΞΌ := by
intros s t _ ht
rw [Set.mem_setOf_eq, MeasurableSpace.measurableSet_bot_iff] at ht
rcases eq_zero_or_isMarkovKernel ΞΊ with rfl| h
Β· simp
refine Filter.Eventually.of_forall (fun a β¦ ?_)
rcases ht with ht | ht
Β· rw [ht, Set.inter_empty, measure_empty, mul_zero]
Β· rw [ht, Set.inter_univ, measure_univ, mul_one]
| Mathlib/Probability/Independence/Kernel.lean | 304 | 327 | theorem indep_bot_left (m' : MeasurableSpace Ξ©) {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±} [IsZeroOrMarkovKernel ΞΊ] :
Indep β₯ m' ΞΊ ΞΌ := (indep_bot_right m').symm
theorem indepSet_empty_right {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±} [IsZeroOrMarkovKernel ΞΊ] (s : Set Ξ©) :
IndepSet s β
ΞΊ ΞΌ := by | simp only [IndepSet, generateFrom_singleton_empty]
exact indep_bot_right _
theorem indepSet_empty_left {_mΞ© : MeasurableSpace Ξ©} {ΞΊ : Kernel Ξ± Ξ©}
{ΞΌ : Measure Ξ±} [IsZeroOrMarkovKernel ΞΊ] (s : Set Ξ©) :
IndepSet β
s ΞΊ ΞΌ :=
(indepSet_empty_right s).symm
theorem indepSets_of_indepSets_of_le_left {sβ sβ sβ : Set (Set Ξ©)} {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±} (h_indep : IndepSets sβ sβ ΞΊ ΞΌ) (h31 : sβ β sβ) :
IndepSets sβ sβ ΞΊ ΞΌ :=
fun t1 t2 ht1 ht2 => h_indep t1 t2 (Set.mem_of_subset_of_mem h31 ht1) ht2
theorem indepSets_of_indepSets_of_le_right {sβ sβ sβ : Set (Set Ξ©)} {_mΞ© : MeasurableSpace Ξ©}
{ΞΊ : Kernel Ξ± Ξ©} {ΞΌ : Measure Ξ±} (h_indep : IndepSets sβ sβ ΞΊ ΞΌ) (h32 : sβ β sβ) :
IndepSets sβ sβ ΞΊ ΞΌ :=
fun t1 t2 ht1 ht2 => h_indep t1 t2 ht1 (Set.mem_of_subset_of_mem h32 ht2) |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Kim Morrison, Ainsley Pahljina
-/
import Mathlib.RingTheory.Fintype
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Zify
/-!
# The Lucas-Lehmer test for Mersenne primes.
We define `lucasLehmerResidue : Ξ p : β, ZMod (2^p - 1)`, and
prove `lucasLehmerResidue p = 0 β Prime (mersenne p)`.
We construct a `norm_num` extension to calculate this residue to certify primality of Mersenne
primes using `lucas_lehmer_sufficiency`.
## TODO
- Show reverse implication.
- Speed up the calculations using `n β‘ (n % 2^p) + (n / 2^p) [MOD 2^p - 1]`.
- Find some bigger primes!
## History
This development began as a student project by Ainsley Pahljina,
and was then cleaned up for mathlib by Kim Morrison.
The tactic for certified computation of Lucas-Lehmer residues was provided by Mario Carneiro.
This tactic was ported by Thomas Murrills to Lean 4, and then it was converted to a `norm_num`
extension and made to use kernel reductions by Kyle Miller.
-/
assert_not_exists TwoSidedIdeal
/-- The Mersenne numbers, 2^p - 1. -/
def mersenne (p : β) : β :=
2 ^ p - 1
theorem strictMono_mersenne : StrictMono mersenne := fun m n h β¦
(Nat.sub_lt_sub_iff_right <| Nat.one_le_pow _ _ two_pos).2 <| by gcongr; norm_num1
@[simp]
theorem mersenne_lt_mersenne {p q : β} : mersenne p < mersenne q β p < q :=
strictMono_mersenne.lt_iff_lt
@[gcongr] protected alias β¨_, GCongr.mersenne_lt_mersenneβ© := mersenne_lt_mersenne
@[simp]
theorem mersenne_le_mersenne {p q : β} : mersenne p β€ mersenne q β p β€ q :=
strictMono_mersenne.le_iff_le
@[gcongr] protected alias β¨_, GCongr.mersenne_le_mersenneβ© := mersenne_le_mersenne
@[simp] theorem mersenne_zero : mersenne 0 = 0 := rfl
@[simp] lemma mersenne_odd : β {p : β}, Odd (mersenne p) β p β 0
| 0 => by simp
| p + 1 => by
simpa using Nat.Even.sub_odd (one_le_powβ one_le_two)
(even_two.pow_of_ne_zero p.succ_ne_zero) odd_one
@[simp] theorem mersenne_pos {p : β} : 0 < mersenne p β 0 < p := mersenne_lt_mersenne (p := 0)
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
alias β¨_, mersenne_pos_of_posβ© := mersenne_pos
/-- Extension for the `positivity` tactic: `mersenne`. -/
@[positivity mersenne _]
def evalMersenne : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(mersenne $a) =>
let ra β core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa => pure (.positive q(mersenne_pos_of_pos $pa))
| _ => pure (.nonnegative q(Nat.zero_le (mersenne $a)))
| _, _, _ => throwError "not mersenne"
end Mathlib.Meta.Positivity
@[simp]
theorem one_lt_mersenne {p : β} : 1 < mersenne p β 1 < p :=
mersenne_lt_mersenne (p := 1)
@[simp]
theorem succ_mersenne (k : β) : mersenne k + 1 = 2 ^ k := by
rw [mersenne, tsub_add_cancel_of_le]
exact one_le_powβ (by norm_num)
namespace LucasLehmer
open Nat
/-!
We now define three(!) different versions of the recurrence
`s (i+1) = (s i)^2 - 2`.
These versions take values either in `β€`, in `ZMod (2^p - 1)`, or
in `β€` but applying `% (2^p - 1)` at each step.
They are each useful at different points in the proof,
so we take a moment setting up the lemmas relating them.
-/
/-- The recurrence `s (i+1) = (s i)^2 - 2` in `β€`. -/
def s : β β β€
| 0 => 4
| i + 1 => s i ^ 2 - 2
/-- The recurrence `s (i+1) = (s i)^2 - 2` in `ZMod (2^p - 1)`. -/
def sZMod (p : β) : β β ZMod (2 ^ p - 1)
| 0 => 4
| i + 1 => sZMod p i ^ 2 - 2
/-- The recurrence `s (i+1) = ((s i)^2 - 2) % (2^p - 1)` in `β€`. -/
def sMod (p : β) : β β β€
| 0 => 4 % (2 ^ p - 1)
| i + 1 => (sMod p i ^ 2 - 2) % (2 ^ p - 1)
theorem mersenne_int_pos {p : β} (hp : p β 0) : (0 : β€) < 2 ^ p - 1 :=
sub_pos.2 <| mod_cast Nat.one_lt_two_pow hp
theorem mersenne_int_ne_zero (p : β) (hp : p β 0) : (2 ^ p - 1 : β€) β 0 :=
(mersenne_int_pos hp).ne'
theorem sMod_nonneg (p : β) (hp : p β 0) (i : β) : 0 β€ sMod p i := by
cases i <;> dsimp [sMod]
Β· exact sup_eq_right.mp rfl
Β· apply Int.emod_nonneg
exact mersenne_int_ne_zero p hp
theorem sMod_mod (p i : β) : sMod p i % (2 ^ p - 1) = sMod p i := by cases i <;> simp [sMod]
theorem sMod_lt (p : β) (hp : p β 0) (i : β) : sMod p i < 2 ^ p - 1 := by
rw [β sMod_mod]
refine (Int.emod_lt_abs _ (mersenne_int_ne_zero p hp)).trans_eq ?_
exact abs_of_nonneg (mersenne_int_pos hp).le
| Mathlib/NumberTheory/LucasLehmer.lean | 145 | 145 | theorem sZMod_eq_s (p' : β) (i : β) : sZMod (p' + 2) i = (s i : ZMod (2 ^ (p' + 2) - 1)) := by | |
/-
Copyright (c) 2021 Filippo A. E. Nuccio. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Filippo A. E. Nuccio, Eric Wieser
-/
import Mathlib.Data.Matrix.Basic
import Mathlib.Data.Matrix.Block
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.Trace
import Mathlib.LinearAlgebra.TensorProduct.Basic
import Mathlib.LinearAlgebra.TensorProduct.Associator
import Mathlib.RingTheory.TensorProduct.Basic
/-!
# Kronecker product of matrices
This defines the [Kronecker product](https://en.wikipedia.org/wiki/Kronecker_product).
## Main definitions
* `Matrix.kroneckerMap`: A generalization of the Kronecker product: given a map `f : Ξ± β Ξ² β Ξ³`
and matrices `A` and `B` with coefficients in `Ξ±` and `Ξ²`, respectively, it is defined as the
matrix with coefficients in `Ξ³` such that
`kroneckerMap f A B (iβ, iβ) (jβ, jβ) = f (A iβ jβ) (B iβ jβ)`.
* `Matrix.kroneckerMapBilinear`: when `f` is bilinear, so is `kroneckerMap f`.
## Specializations
* `Matrix.kronecker`: An alias of `kroneckerMap (*)`. Prefer using the notation.
* `Matrix.kroneckerBilinear`: `Matrix.kronecker` is bilinear
* `Matrix.kroneckerTMul`: An alias of `kroneckerMap (ββ)`. Prefer using the notation.
* `Matrix.kroneckerTMulBilinear`: `Matrix.kroneckerTMul` is bilinear
## Notations
These require `open Kronecker`:
* `A ββ B` for `kroneckerMap (*) A B`. Lemmas about this notation use the token `kronecker`.
* `A βββ B` and `A βββ[R] B` for `kroneckerMap (ββ) A B`.
Lemmas about this notation use the token `kroneckerTMul`.
-/
namespace Matrix
open scoped RightActions
variable {R Ξ± Ξ±' Ξ² Ξ²' Ξ³ Ξ³' : Type*}
variable {l m n p : Type*} {q r : Type*} {l' m' n' p' : Type*}
section KroneckerMap
/-- Produce a matrix with `f` applied to every pair of elements from `A` and `B`. -/
def kroneckerMap (f : Ξ± β Ξ² β Ξ³) (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) : Matrix (l Γ n) (m Γ p) Ξ³ :=
of fun (i : l Γ n) (j : m Γ p) => f (A i.1 j.1) (B i.2 j.2)
-- TODO: set as an equation lemma for `kroneckerMap`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem kroneckerMap_apply (f : Ξ± β Ξ² β Ξ³) (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) (i j) :
kroneckerMap f A B i j = f (A i.1 j.1) (B i.2 j.2) :=
rfl
theorem kroneckerMap_transpose (f : Ξ± β Ξ² β Ξ³) (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f Aα΅ Bα΅ = (kroneckerMap f A B)α΅ :=
ext fun _ _ => rfl
theorem kroneckerMap_map_left (f : Ξ±' β Ξ² β Ξ³) (g : Ξ± β Ξ±') (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f (A.map g) B = kroneckerMap (fun a b => f (g a) b) A B :=
ext fun _ _ => rfl
theorem kroneckerMap_map_right (f : Ξ± β Ξ²' β Ξ³) (g : Ξ² β Ξ²') (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f A (B.map g) = kroneckerMap (fun a b => f a (g b)) A B :=
ext fun _ _ => rfl
theorem kroneckerMap_map (f : Ξ± β Ξ² β Ξ³) (g : Ξ³ β Ξ³') (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
(kroneckerMap f A B).map g = kroneckerMap (fun a b => g (f a b)) A B :=
ext fun _ _ => rfl
@[simp]
theorem kroneckerMap_zero_left [Zero Ξ±] [Zero Ξ³] (f : Ξ± β Ξ² β Ξ³) (hf : β b, f 0 b = 0)
(B : Matrix n p Ξ²) : kroneckerMap f (0 : Matrix l m Ξ±) B = 0 :=
ext fun _ _ => hf _
@[simp]
theorem kroneckerMap_zero_right [Zero Ξ²] [Zero Ξ³] (f : Ξ± β Ξ² β Ξ³) (hf : β a, f a 0 = 0)
(A : Matrix l m Ξ±) : kroneckerMap f A (0 : Matrix n p Ξ²) = 0 :=
ext fun _ _ => hf _
theorem kroneckerMap_add_left [Add Ξ±] [Add Ξ³] (f : Ξ± β Ξ² β Ξ³)
(hf : β aβ aβ b, f (aβ + aβ) b = f aβ b + f aβ b) (Aβ Aβ : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f (Aβ + Aβ) B = kroneckerMap f Aβ B + kroneckerMap f Aβ B :=
ext fun _ _ => hf _ _ _
theorem kroneckerMap_add_right [Add Ξ²] [Add Ξ³] (f : Ξ± β Ξ² β Ξ³)
(hf : β a bβ bβ, f a (bβ + bβ) = f a bβ + f a bβ) (A : Matrix l m Ξ±) (Bβ Bβ : Matrix n p Ξ²) :
kroneckerMap f A (Bβ + Bβ) = kroneckerMap f A Bβ + kroneckerMap f A Bβ :=
ext fun _ _ => hf _ _ _
theorem kroneckerMap_smul_left [SMul R Ξ±] [SMul R Ξ³] (f : Ξ± β Ξ² β Ξ³) (r : R)
(hf : β a b, f (r β’ a) b = r β’ f a b) (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f (r β’ A) B = r β’ kroneckerMap f A B :=
ext fun _ _ => hf _ _
theorem kroneckerMap_smul_right [SMul R Ξ²] [SMul R Ξ³] (f : Ξ± β Ξ² β Ξ³) (r : R)
(hf : β a b, f a (r β’ b) = r β’ f a b) (A : Matrix l m Ξ±) (B : Matrix n p Ξ²) :
kroneckerMap f A (r β’ B) = r β’ kroneckerMap f A B :=
ext fun _ _ => hf _ _
theorem kroneckerMap_stdBasisMatrix_stdBasisMatrix
[Zero Ξ±] [Zero Ξ²] [Zero Ξ³] [DecidableEq l] [DecidableEq m] [DecidableEq n] [DecidableEq p]
(iβ : l) (jβ : m) (iβ : n) (jβ : p)
(f : Ξ± β Ξ² β Ξ³) (hfβ : β b, f 0 b = 0) (hfβ : β a, f a 0 = 0) (a : Ξ±) (b : Ξ²) :
kroneckerMap f (stdBasisMatrix iβ jβ a) (stdBasisMatrix iβ jβ b) =
stdBasisMatrix (iβ, iβ) (jβ, jβ) (f a b) := by
ext β¨iβ', iβ'β© β¨jβ', jβ'β©
dsimp [stdBasisMatrix]
aesop
theorem kroneckerMap_diagonal_diagonal [Zero Ξ±] [Zero Ξ²] [Zero Ξ³] [DecidableEq m] [DecidableEq n]
(f : Ξ± β Ξ² β Ξ³) (hfβ : β b, f 0 b = 0) (hfβ : β a, f a 0 = 0) (a : m β Ξ±) (b : n β Ξ²) :
kroneckerMap f (diagonal a) (diagonal b) = diagonal fun mn => f (a mn.1) (b mn.2) := by
ext β¨iβ, iββ© β¨jβ, jββ©
simp [diagonal, apply_ite f, ite_and, ite_apply, apply_ite (f (a iβ)), hfβ, hfβ]
theorem kroneckerMap_diagonal_right [Zero Ξ²] [Zero Ξ³] [DecidableEq n] (f : Ξ± β Ξ² β Ξ³)
(hf : β a, f a 0 = 0) (A : Matrix l m Ξ±) (b : n β Ξ²) :
kroneckerMap f A (diagonal b) = blockDiagonal fun i => A.map fun a => f a (b i) := by
ext β¨iβ, iββ© β¨jβ, jββ©
simp [diagonal, blockDiagonal, apply_ite (f (A iβ jβ)), hf]
| Mathlib/Data/Matrix/Kronecker.lean | 132 | 136 | theorem kroneckerMap_diagonal_left [Zero Ξ±] [Zero Ξ³] [DecidableEq l] (f : Ξ± β Ξ² β Ξ³)
(hf : β b, f 0 b = 0) (a : l β Ξ±) (B : Matrix m n Ξ²) :
kroneckerMap f (diagonal a) B =
Matrix.reindex (Equiv.prodComm _ _) (Equiv.prodComm _ _)
(blockDiagonal fun i => B.map fun b => f (a i) b) := by | |
/-
Copyright (c) 2023 RΓ©my Degenne. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: RΓ©my Degenne
-/
import Mathlib.Probability.Kernel.Composition.MeasureComp
import Mathlib.Probability.Kernel.CondDistrib
import Mathlib.Probability.ConditionalProbability
/-!
# Kernel associated with a conditional expectation
We define `condExpKernel ΞΌ m`, a kernel from `Ξ©` to `Ξ©` such that for all integrable functions `f`,
`ΞΌ[f | m] =α΅[ΞΌ] fun Ο => β« y, f y β(condExpKernel ΞΌ m Ο)`.
This kernel is defined if `Ξ©` is a standard Borel space. In general, `ΞΌβ¦s | mβ§` maps a measurable
set `s` to a function `Ξ© β ββ₯0β`, and for all `s` that map is unique up to a `ΞΌ`-null set. For all
`a`, the map from sets to `ββ₯0β` that we obtain that way verifies some of the properties of a
measure, but the fact that the `ΞΌ`-null set depends on `s` can prevent us from finding versions of
the conditional expectation that combine into a true measure. The standard Borel space assumption
on `Ξ©` allows us to do so.
## Main definitions
* `condExpKernel ΞΌ m`: kernel such that `ΞΌ[f | m] =α΅[ΞΌ] fun Ο => β« y, f y β(condExpKernel ΞΌ m Ο)`.
## Main statements
* `condExp_ae_eq_integral_condExpKernel`: `ΞΌ[f | m] =α΅[ΞΌ] fun Ο => β« y, f y β(condExpKernel ΞΌ m Ο)`.
-/
open MeasureTheory Set Filter TopologicalSpace
open scoped ENNReal MeasureTheory ProbabilityTheory
namespace ProbabilityTheory
section AuxLemmas
variable {Ξ© F : Type*} {m mΞ© : MeasurableSpace Ξ©} {ΞΌ : Measure Ξ©} {f : Ξ© β F}
| Mathlib/Probability/Kernel/Condexp.lean | 44 | 49 | theorem _root_.MeasureTheory.AEStronglyMeasurable.comp_snd_map_prod_id [TopologicalSpace F]
(hm : m β€ mΞ©) (hf : AEStronglyMeasurable f ΞΌ) :
AEStronglyMeasurable[m.prod mΞ©] (fun x : Ξ© Γ Ξ© => f x.2)
(@Measure.map Ξ© (Ξ© Γ Ξ©) mΞ© (m.prod mΞ©) (fun Ο => (id Ο, id Ο)) ΞΌ) := by | rw [β aestronglyMeasurable_comp_snd_map_prodMk_iff (measurable_id'' hm)] at hf
simp_rw [id] at hf β’ |
/-
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.RingTheory.LocalProperties.Basic
/-!
# The meta properties of surjective ring homomorphisms.
## Main results
Let `R` be a commutative ring, `M` be a submonoid of `R`.
* `surjective_localizationPreserves` : `Mβ»ΒΉR β+* Mβ»ΒΉS` is surjective if `R β+* S` is surjective.
* `surjective_ofLocalizationSpan` : `R β+* S` is surjective if there exists a set `{ r }` that
spans `R` such that `Rα΅£ β+* Sα΅£` is surjective.
* `surjective_localRingHom_of_surjective` : A surjective ring homomorphism `R β+* S` induces a
surjective homomorphism `R_{fβ»ΒΉ(P)} β+* S_P` for every prime ideal `P` of `S`.
-/
namespace RingHom
open scoped TensorProduct
open TensorProduct Algebra.TensorProduct
universe u
local notation "surjective" => fun {X Y : Type _} [CommRing X] [CommRing Y] => fun f : X β+* Y =>
Function.Surjective f
| Mathlib/RingTheory/RingHom/Surjective.lean | 36 | 45 | theorem surjective_stableUnderComposition : StableUnderComposition surjective := by | introv R hf hg; exact hg.comp hf
theorem surjective_respectsIso : RespectsIso surjective := by
apply surjective_stableUnderComposition.respectsIso
intros _ _ _ _ e
exact e.surjective
theorem surjective_isStableUnderBaseChange : IsStableUnderBaseChange surjective := by
refine IsStableUnderBaseChange.mk _ surjective_respectsIso ?_ |
/-
Copyright (c) 2023 Richard M. Hill. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Richard M. Hill
-/
import Mathlib.RingTheory.PowerSeries.Trunc
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.Derivation.Basic
/-!
# Definitions
In this file we define an operation `derivative` (formal differentiation)
on the ring of formal power series in one variable (over an arbitrary commutative semiring).
Under suitable assumptions, we prove that two power series are equal if their derivatives
are equal and their constant terms are equal. This will give us a simple tool for proving
power series identities. For example, one can easily prove the power series identity
$\exp ( \log (1+X)) = 1+X$ by differentiating twice.
## Main Definition
- `PowerSeries.derivative R : Derivation R Rβ¦Xβ§ Rβ¦Xβ§` the formal derivative operation.
This is abbreviated `dβdX R`.
-/
namespace PowerSeries
open Polynomial Derivation Nat
section CommutativeSemiring
variable {R} [CommSemiring R]
/--
The formal derivative of a power series in one variable.
This is defined here as a function, but will be packaged as a
derivation `derivative` on `Rβ¦Xβ§`.
-/
noncomputable def derivativeFun (f : Rβ¦Xβ§) : Rβ¦Xβ§ := mk fun n β¦ coeff R (n + 1) f * (n + 1)
theorem coeff_derivativeFun (f : Rβ¦Xβ§) (n : β) :
coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by
rw [derivativeFun, coeff_mk]
| Mathlib/RingTheory/PowerSeries/Derivative.lean | 45 | 47 | theorem derivativeFun_coe (f : R[X]) : (f : Rβ¦Xβ§).derivativeFun = derivative f := by | ext
rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative] |
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez, Eric Wieser
-/
import Mathlib.Data.List.Chain
/-!
# Destuttering of Lists
This file proves theorems about `List.destutter` (in `Data.List.Defs`), which greedily removes all
non-related items that are adjacent in a list, e.g. `[2, 2, 3, 3, 2].destutter (β ) = [2, 3, 2]`.
Note that we make no guarantees of being the longest sublist with this property; e.g.,
`[123, 1, 2, 5, 543, 1000].destutter (<) = [123, 543, 1000]`, but a longer ascending chain could be
`[1, 2, 5, 543, 1000]`.
## Main statements
* `List.destutter_sublist`: `l.destutter` is a sublist of `l`.
* `List.destutter_is_chain'`: `l.destutter` satisfies `Chain' R`.
* Analogies of these theorems for `List.destutter'`, which is the `destutter` equivalent of `Chain`.
## Tags
adjacent, chain, duplicates, remove, list, stutter, destutter
-/
open Function
variable {Ξ± Ξ² : Type*} (l lβ lβ : List Ξ±) (R : Ξ± β Ξ± β Prop) [DecidableRel R] {a b : Ξ±}
variable {Rβ : Ξ² β Ξ² β Prop} [DecidableRel Rβ]
namespace List
@[simp]
theorem destutter'_nil : destutter' R a [] = [a] :=
rfl
theorem destutter'_cons :
(b :: l).destutter' R a = if R a b then a :: destutter' R b l else destutter' R a l :=
rfl
variable {R}
@[simp]
theorem destutter'_cons_pos (h : R b a) : (a :: l).destutter' R b = b :: l.destutter' R a := by
rw [destutter', if_pos h]
@[simp]
theorem destutter'_cons_neg (h : Β¬R b a) : (a :: l).destutter' R b = l.destutter' R b := by
rw [destutter', if_neg h]
variable (R)
@[simp]
theorem destutter'_singleton : [b].destutter' R a = if R a b then [a, b] else [a] := by
split_ifs with h <;> simp! [h]
| Mathlib/Data/List/Destutter.lean | 60 | 61 | theorem destutter'_sublist (a) : l.destutter' R a <+ a :: l := by | induction' l with b l hl generalizing a |
/-
Copyright (c) 2020 Aaron Anderson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Aaron Anderson, Jalex Stark, Kyle Miller, Lu-Ming Zhang
-/
import Mathlib.Combinatorics.SimpleGraph.Basic
import Mathlib.Combinatorics.SimpleGraph.Connectivity.WalkCounting
import Mathlib.LinearAlgebra.Matrix.Trace
import Mathlib.LinearAlgebra.Matrix.Symmetric
/-!
# Adjacency Matrices
This module defines the adjacency matrix of a graph, and provides theorems connecting graph
properties to computational properties of the matrix.
## Main definitions
* `Matrix.IsAdjMatrix`: `A : Matrix V V Ξ±` is qualified as an "adjacency matrix" if
(1) every entry of `A` is `0` or `1`,
(2) `A` is symmetric,
(3) every diagonal entry of `A` is `0`.
* `Matrix.IsAdjMatrix.to_graph`: for `A : Matrix V V Ξ±` and `h : A.IsAdjMatrix`,
`h.to_graph` is the simple graph induced by `A`.
* `Matrix.compl`: for `A : Matrix V V Ξ±`, `A.compl` is supposed to be
the adjacency matrix of the complement graph of the graph induced by `A`.
* `SimpleGraph.adjMatrix`: the adjacency matrix of a `SimpleGraph`.
* `SimpleGraph.adjMatrix_pow_apply_eq_card_walk`: each entry of the `n`th power of
a graph's adjacency matrix counts the number of length-`n` walks between the corresponding
pair of vertices.
-/
open Matrix
open Finset Matrix SimpleGraph
variable {V Ξ± : Type*}
namespace Matrix
/-- `A : Matrix V V Ξ±` is qualified as an "adjacency matrix" if
(1) every entry of `A` is `0` or `1`,
(2) `A` is symmetric,
(3) every diagonal entry of `A` is `0`. -/
structure IsAdjMatrix [Zero Ξ±] [One Ξ±] (A : Matrix V V Ξ±) : Prop where
zero_or_one : β i j, A i j = 0 β¨ A i j = 1 := by aesop
symm : A.IsSymm := by aesop
apply_diag : β i, A i i = 0 := by aesop
namespace IsAdjMatrix
variable {A : Matrix V V Ξ±}
@[simp]
theorem apply_diag_ne [MulZeroOneClass Ξ±] [Nontrivial Ξ±] (h : IsAdjMatrix A) (i : V) :
Β¬A i i = 1 := by simp [h.apply_diag i]
@[simp]
theorem apply_ne_one_iff [MulZeroOneClass Ξ±] [Nontrivial Ξ±] (h : IsAdjMatrix A) (i j : V) :
Β¬A i j = 1 β A i j = 0 := by obtain h | h := h.zero_or_one i j <;> simp [h]
@[simp]
theorem apply_ne_zero_iff [MulZeroOneClass Ξ±] [Nontrivial Ξ±] (h : IsAdjMatrix A) (i j : V) :
Β¬A i j = 0 β A i j = 1 := by rw [β apply_ne_one_iff h, Classical.not_not]
/-- For `A : Matrix V V Ξ±` and `h : IsAdjMatrix A`,
`h.toGraph` is the simple graph whose adjacency matrix is `A`. -/
@[simps]
def toGraph [MulZeroOneClass Ξ±] [Nontrivial Ξ±] (h : IsAdjMatrix A) : SimpleGraph V where
Adj i j := A i j = 1
symm i j hij := by simp only; rwa [h.symm.apply i j]
loopless i := by simp [h]
instance [MulZeroOneClass Ξ±] [Nontrivial Ξ±] [DecidableEq Ξ±] (h : IsAdjMatrix A) :
DecidableRel h.toGraph.Adj := by
simp only [toGraph]
infer_instance
end IsAdjMatrix
/-- For `A : Matrix V V Ξ±`, `A.compl` is supposed to be the adjacency matrix of
the complement graph of the graph induced by `A.adjMatrix`. -/
def compl [Zero Ξ±] [One Ξ±] [DecidableEq Ξ±] [DecidableEq V] (A : Matrix V V Ξ±) : Matrix V V Ξ± :=
fun i j => ite (i = j) 0 (ite (A i j = 0) 1 0)
section Compl
variable [DecidableEq Ξ±] [DecidableEq V] (A : Matrix V V Ξ±)
@[simp]
theorem compl_apply_diag [Zero Ξ±] [One Ξ±] (i : V) : A.compl i i = 0 := by simp [compl]
@[simp]
theorem compl_apply [Zero Ξ±] [One Ξ±] (i j : V) : A.compl i j = 0 β¨ A.compl i j = 1 := by
unfold compl
split_ifs <;> simp
@[simp]
theorem isSymm_compl [Zero Ξ±] [One Ξ±] (h : A.IsSymm) : A.compl.IsSymm := by
ext
simp [compl, h.apply, eq_comm]
@[simp]
theorem isAdjMatrix_compl [Zero Ξ±] [One Ξ±] (h : A.IsSymm) : IsAdjMatrix A.compl :=
{ symm := by simp [h] }
namespace IsAdjMatrix
variable {A}
@[simp]
theorem compl [Zero Ξ±] [One Ξ±] (h : IsAdjMatrix A) : IsAdjMatrix A.compl :=
isAdjMatrix_compl A h.symm
theorem toGraph_compl_eq [MulZeroOneClass Ξ±] [Nontrivial Ξ±] (h : IsAdjMatrix A) :
h.compl.toGraph = h.toGraphαΆ := by
ext v w
rcases h.zero_or_one v w with h | h <;> by_cases hvw : v = w <;> simp [Matrix.compl, h, hvw]
end IsAdjMatrix
end Compl
end Matrix
open Matrix
namespace SimpleGraph
variable (G : SimpleGraph V) [DecidableRel G.Adj]
variable (Ξ±) in
/-- `adjMatrix G Ξ±` is the matrix `A` such that `A i j = (1 : Ξ±)` if `i` and `j` are
adjacent in the simple graph `G`, and otherwise `A i j = 0`. -/
def adjMatrix [Zero Ξ±] [One Ξ±] : Matrix V V Ξ± :=
of fun i j => if G.Adj i j then (1 : Ξ±) else 0
-- TODO: set as an equation lemma for `adjMatrix`, see https://github.com/leanprover-community/mathlib4/pull/3024
@[simp]
theorem adjMatrix_apply (v w : V) [Zero Ξ±] [One Ξ±] :
G.adjMatrix Ξ± v w = if G.Adj v w then 1 else 0 :=
rfl
@[simp]
theorem transpose_adjMatrix [Zero Ξ±] [One Ξ±] : (G.adjMatrix Ξ±)α΅ = G.adjMatrix Ξ± := by
ext
simp [adj_comm]
@[simp]
theorem isSymm_adjMatrix [Zero Ξ±] [One Ξ±] : (G.adjMatrix Ξ±).IsSymm :=
transpose_adjMatrix G
variable (Ξ±)
/-- The adjacency matrix of `G` is an adjacency matrix. -/
@[simp]
theorem isAdjMatrix_adjMatrix [Zero Ξ±] [One Ξ±] : (G.adjMatrix Ξ±).IsAdjMatrix :=
{ zero_or_one := fun i j => by by_cases h : G.Adj i j <;> simp [h] }
/-- The graph induced by the adjacency matrix of `G` is `G` itself. -/
theorem toGraph_adjMatrix_eq [MulZeroOneClass Ξ±] [Nontrivial Ξ±] :
(G.isAdjMatrix_adjMatrix Ξ±).toGraph = G := by
ext
simp only [IsAdjMatrix.toGraph_adj, adjMatrix_apply, ite_eq_left_iff, zero_ne_one]
apply Classical.not_not
variable {Ξ±}
/-- The sum of the identity, the adjacency matrix, and its complement is the all-ones matrix. -/
theorem one_add_adjMatrix_add_compl_adjMatrix_eq_allOnes [DecidableEq V] [DecidableEq Ξ±]
[AddMonoidWithOne Ξ±] : 1 + G.adjMatrix Ξ± + (G.adjMatrix Ξ±).compl = Matrix.of fun _ _ β¦ 1 := by
ext i j
unfold Matrix.compl
rw [of_apply, add_apply, adjMatrix_apply, add_apply, adjMatrix_apply, one_apply]
by_cases h : G.Adj i j
Β· aesop
Β· split_ifs <;> simp_all
variable [Fintype V]
@[simp]
theorem adjMatrix_dotProduct [NonAssocSemiring Ξ±] (v : V) (vec : V β Ξ±) :
dotProduct (G.adjMatrix Ξ± v) vec = β u β G.neighborFinset v, vec u := by
simp [neighborFinset_eq_filter, dotProduct, sum_filter]
@[simp]
theorem dotProduct_adjMatrix [NonAssocSemiring Ξ±] (v : V) (vec : V β Ξ±) :
dotProduct vec (G.adjMatrix Ξ± v) = β u β G.neighborFinset v, vec u := by
simp [neighborFinset_eq_filter, dotProduct, sum_filter, Finset.sum_apply]
@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring Ξ±] (v : V) (vec : V β Ξ±) :
(G.adjMatrix Ξ± *α΅₯ vec) v = β u β G.neighborFinset v, vec u := by
rw [mulVec, adjMatrix_dotProduct]
@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring Ξ±] (v : V) (vec : V β Ξ±) :
(vec α΅₯* G.adjMatrix Ξ±) v = β u β G.neighborFinset v, vec u := by
simp only [β dotProduct_adjMatrix, vecMul]
refine congr rfl ?_; ext x
rw [β transpose_apply (adjMatrix Ξ± G) x v, transpose_adjMatrix]
@[simp]
| Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean | 210 | 212 | theorem adjMatrix_mul_apply [NonAssocSemiring Ξ±] (M : Matrix V V Ξ±) (v w : V) :
(G.adjMatrix Ξ± * M) v w = β u β G.neighborFinset v, M u w := by | simp [mul_apply, neighborFinset_eq_filter, sum_filter] |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle SΓΆnne, SΓ©bastien GouΓ«zel,
RΓ©my Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Complex
import Qq
/-! # Power function on `β`
We construct the power functions `x ^ y`, where `x` and `y` are real numbers.
-/
noncomputable section
open Real ComplexConjugate Finset Set
/-
## Definitions
-/
namespace Real
variable {x y z : β}
/-- The real power function `x ^ y`, defined as the real part of the complex power function.
For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`, one sets `0 ^ 0=1` and `0 ^ y=0` for
`y β 0`. For `x < 0`, the definition is somewhat arbitrary as it depends on the choice of a complex
determination of the logarithm. With our conventions, it is equal to `exp (y log x) cos (Ο y)`. -/
noncomputable def rpow (x y : β) :=
((x : β) ^ (y : β)).re
noncomputable instance : Pow β β := β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x y : β) : rpow x y = x ^ y := rfl
theorem rpow_def (x y : β) : x ^ y = ((x : β) ^ (y : β)).re := rfl
theorem rpow_def_of_nonneg {x : β} (hx : 0 β€ x) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) := by
simp only [rpow_def, Complex.cpow_def]; split_ifs <;>
simp_all [(Complex.ofReal_log hx).symm, -Complex.ofReal_mul,
(Complex.ofReal_mul _ _).symm, Complex.exp_ofReal_re, Complex.ofReal_eq_zero]
theorem rpow_def_of_pos {x : β} (hx : 0 < x) (y : β) : x ^ y = exp (log x * y) := by
rw [rpow_def_of_nonneg (le_of_lt hx), if_neg (ne_of_gt hx)]
theorem exp_mul (x y : β) : exp (x * y) = exp x ^ y := by rw [rpow_def_of_pos (exp_pos _), log_exp]
@[simp, norm_cast]
theorem rpow_intCast (x : β) (n : β€) : x ^ (n : β) = x ^ n := by
simp only [rpow_def, β Complex.ofReal_zpow, Complex.cpow_intCast, Complex.ofReal_intCast,
Complex.ofReal_re]
@[simp, norm_cast]
theorem rpow_natCast (x : β) (n : β) : x ^ (n : β) = x ^ n := by simpa using rpow_intCast x n
@[simp]
theorem exp_one_rpow (x : β) : exp 1 ^ x = exp x := by rw [β exp_mul, one_mul]
@[simp] lemma exp_one_pow (n : β) : exp 1 ^ n = exp n := by rw [β rpow_natCast, exp_one_rpow]
theorem rpow_eq_zero_iff_of_nonneg (hx : 0 β€ x) : x ^ y = 0 β x = 0 β§ y β 0 := by
simp only [rpow_def_of_nonneg hx]
split_ifs <;> simp [*, exp_ne_zero]
@[simp]
lemma rpow_eq_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y = 0 β x = 0 := by
simp [rpow_eq_zero_iff_of_nonneg, *]
@[simp]
lemma rpow_ne_zero (hx : 0 β€ x) (hy : y β 0) : x ^ y β 0 β x β 0 :=
Real.rpow_eq_zero hx hy |>.not
open Real
theorem rpow_def_of_neg {x : β} (hx : x < 0) (y : β) : x ^ y = exp (log x * y) * cos (y * Ο) := by
rw [rpow_def, Complex.cpow_def, if_neg]
Β· have : Complex.log x * y = β(log (-x) * y) + β(y * Ο) * Complex.I := by
simp only [Complex.log, Complex.norm_real, norm_eq_abs, abs_of_neg hx, log_neg_eq_log,
Complex.arg_ofReal_of_neg hx, Complex.ofReal_mul]
ring
rw [this, Complex.exp_add_mul_I, β Complex.ofReal_exp, β Complex.ofReal_cos, β
Complex.ofReal_sin, mul_add, β Complex.ofReal_mul, β mul_assoc, β Complex.ofReal_mul,
Complex.add_re, Complex.ofReal_re, Complex.mul_re, Complex.I_re, Complex.ofReal_im,
Real.log_neg_eq_log]
ring
Β· rw [Complex.ofReal_eq_zero]
exact ne_of_lt hx
theorem rpow_def_of_nonpos {x : β} (hx : x β€ 0) (y : β) :
x ^ y = if x = 0 then if y = 0 then 1 else 0 else exp (log x * y) * cos (y * Ο) := by
split_ifs with h <;> simp [rpow_def, *]; exact rpow_def_of_neg (lt_of_le_of_ne hx h) _
@[bound]
theorem rpow_pos_of_pos {x : β} (hx : 0 < x) (y : β) : 0 < x ^ y := by
rw [rpow_def_of_pos hx]; apply exp_pos
@[simp]
theorem rpow_zero (x : β) : x ^ (0 : β) = 1 := by simp [rpow_def]
theorem rpow_zero_pos (x : β) : 0 < x ^ (0 : β) := by simp
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : β) ^ x = 0 := by simp [rpow_def, *]
theorem zero_rpow_eq_iff {x : β} {a : β} : 0 ^ x = a β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
constructor
Β· intro hyp
simp only [rpow_def, Complex.ofReal_zero] at hyp
by_cases h : x = 0
Β· subst h
simp only [Complex.one_re, Complex.ofReal_zero, Complex.cpow_zero] at hyp
exact Or.inr β¨rfl, hyp.symmβ©
Β· rw [Complex.zero_cpow (Complex.ofReal_ne_zero.mpr h)] at hyp
exact Or.inl β¨h, hyp.symmβ©
Β· rintro (β¨h, rflβ© | β¨rfl, rflβ©)
Β· exact zero_rpow h
Β· exact rpow_zero _
theorem eq_zero_rpow_iff {x : β} {a : β} : a = 0 ^ x β x β 0 β§ a = 0 β¨ x = 0 β§ a = 1 := by
rw [β zero_rpow_eq_iff, eq_comm]
@[simp]
theorem rpow_one (x : β) : x ^ (1 : β) = x := by simp [rpow_def]
@[simp]
theorem one_rpow (x : β) : (1 : β) ^ x = 1 := by simp [rpow_def]
theorem zero_rpow_le_one (x : β) : (0 : β) ^ x β€ 1 := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
theorem zero_rpow_nonneg (x : β) : 0 β€ (0 : β) ^ x := by
by_cases h : x = 0 <;> simp [h, zero_le_one]
@[bound]
theorem rpow_nonneg {x : β} (hx : 0 β€ x) (y : β) : 0 β€ x ^ y := by
rw [rpow_def_of_nonneg hx]; split_ifs <;>
simp only [zero_le_one, le_refl, le_of_lt (exp_pos _)]
theorem abs_rpow_of_nonneg {x y : β} (hx_nonneg : 0 β€ x) : |x ^ y| = |x| ^ y := by
have h_rpow_nonneg : 0 β€ x ^ y := Real.rpow_nonneg hx_nonneg _
rw [abs_eq_self.mpr hx_nonneg, abs_eq_self.mpr h_rpow_nonneg]
@[bound]
theorem abs_rpow_le_abs_rpow (x y : β) : |x ^ y| β€ |x| ^ y := by
rcases le_or_lt 0 x with hx | hx
Β· rw [abs_rpow_of_nonneg hx]
Β· rw [abs_of_neg hx, rpow_def_of_neg hx, rpow_def_of_pos (neg_pos.2 hx), log_neg_eq_log, abs_mul,
abs_of_pos (exp_pos _)]
exact mul_le_of_le_one_right (exp_pos _).le (abs_cos_le_one _)
theorem abs_rpow_le_exp_log_mul (x y : β) : |x ^ y| β€ exp (log x * y) := by
refine (abs_rpow_le_abs_rpow x y).trans ?_
by_cases hx : x = 0
Β· by_cases hy : y = 0 <;> simp [hx, hy, zero_le_one]
Β· rw [rpow_def_of_pos (abs_pos.2 hx), log_abs]
lemma rpow_inv_log (hxβ : 0 < x) (hxβ : x β 1) : x ^ (log x)β»ΒΉ = exp 1 := by
rw [rpow_def_of_pos hxβ, mul_inv_cancelβ]
exact log_ne_zero.2 β¨hxβ.ne', hxβ, (hxβ.trans' <| by norm_num).ne'β©
/-- See `Real.rpow_inv_log` for the equality when `x β 1` is strictly positive. -/
lemma rpow_inv_log_le_exp_one : x ^ (log x)β»ΒΉ β€ exp 1 := by
calc
_ β€ |x ^ (log x)β»ΒΉ| := le_abs_self _
_ β€ |x| ^ (log x)β»ΒΉ := abs_rpow_le_abs_rpow ..
rw [β log_abs]
obtain hx | hx := (abs_nonneg x).eq_or_gt
Β· simp [hx]
Β· rw [rpow_def_of_pos hx]
gcongr
exact mul_inv_le_one
theorem norm_rpow_of_nonneg {x y : β} (hx_nonneg : 0 β€ x) : βx ^ yβ = βxβ ^ y := by
simp_rw [Real.norm_eq_abs]
exact abs_rpow_of_nonneg hx_nonneg
variable {w x y z : β}
theorem rpow_add (hx : 0 < x) (y z : β) : x ^ (y + z) = x ^ y * x ^ z := by
simp only [rpow_def_of_pos hx, mul_add, exp_add]
theorem rpow_add' (hx : 0 β€ x) (h : y + z β 0) : x ^ (y + z) = x ^ y * x ^ z := by
rcases hx.eq_or_lt with (rfl | pos)
Β· rw [zero_rpow h, zero_eq_mul]
have : y β 0 β¨ z β 0 := not_and_or.1 fun β¨hy, hzβ© => h <| hy.symm βΈ hz.symm βΈ zero_add 0
exact this.imp zero_rpow zero_rpow
Β· exact rpow_add pos _ _
/-- Variant of `Real.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (hx : 0 β€ x) (hw : w β 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [β h, rpow_add' hx]; rwa [h]
theorem rpow_add_of_nonneg (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
rcases hy.eq_or_lt with (rfl | hy)
Β· rw [zero_add, rpow_zero, one_mul]
exact rpow_add' hx (ne_of_gt <| add_pos_of_pos_of_nonneg hy hz)
/-- For `0 β€ x`, the only problematic case in the equality `x ^ y * x ^ z = x ^ (y + z)` is for
`x = 0` and `y + z = 0`, where the right hand side is `1` while the left hand side can vanish.
The inequality is always true, though, and given in this lemma. -/
theorem le_rpow_add {x : β} (hx : 0 β€ x) (y z : β) : x ^ y * x ^ z β€ x ^ (y + z) := by
rcases le_iff_eq_or_lt.1 hx with (H | pos)
Β· by_cases h : y + z = 0
Β· simp only [H.symm, h, rpow_zero]
calc
(0 : β) ^ y * 0 ^ z β€ 1 * 1 :=
mul_le_mul (zero_rpow_le_one y) (zero_rpow_le_one z) (zero_rpow_nonneg z) zero_le_one
_ = 1 := by simp
Β· simp [rpow_add', β H, h]
Β· simp [rpow_add pos]
theorem rpow_sum_of_pos {ΞΉ : Type*} {a : β} (ha : 0 < a) (f : ΞΉ β β) (s : Finset ΞΉ) :
(a ^ β x β s, f x) = β x β s, a ^ f x :=
map_sum (β¨β¨fun (x : β) => (a ^ x : β), rpow_zero aβ©, rpow_add haβ© : β β+ (Additive β)) f s
theorem rpow_sum_of_nonneg {ΞΉ : Type*} {a : β} (ha : 0 β€ a) {s : Finset ΞΉ} {f : ΞΉ β β}
(h : β x β s, 0 β€ f x) : (a ^ β x β s, f x) = β x β s, a ^ f x := by
induction' s using Finset.cons_induction with i s hi ihs
Β· rw [sum_empty, Finset.prod_empty, rpow_zero]
Β· rw [forall_mem_cons] at h
rw [sum_cons, prod_cons, β ihs h.2, rpow_add_of_nonneg ha h.1 (sum_nonneg h.2)]
theorem rpow_neg {x : β} (hx : 0 β€ x) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by
simp only [rpow_def_of_nonneg hx]; split_ifs <;> simp_all [exp_neg]
theorem rpow_sub {x : β} (hx : 0 < x) (y z : β) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg, rpow_add hx, rpow_neg (le_of_lt hx), div_eq_mul_inv]
theorem rpow_sub' {x : β} (hx : 0 β€ x) {y z : β} (h : y - z β 0) : x ^ (y - z) = x ^ y / x ^ z := by
simp only [sub_eq_add_neg] at h β’
simp only [rpow_add' hx h, rpow_neg hx, div_eq_mul_inv]
protected theorem _root_.HasCompactSupport.rpow_const {Ξ± : Type*} [TopologicalSpace Ξ±] {f : Ξ± β β}
(hf : HasCompactSupport f) {r : β} (hr : r β 0) : HasCompactSupport (fun x β¦ f x ^ r) :=
hf.comp_left (g := (Β· ^ r)) (Real.zero_rpow hr)
end Real
/-!
## Comparing real and complex powers
-/
namespace Complex
theorem ofReal_cpow {x : β} (hx : 0 β€ x) (y : β) : ((x ^ y : β) : β) = (x : β) ^ (y : β) := by
simp only [Real.rpow_def_of_nonneg hx, Complex.cpow_def, ofReal_eq_zero]; split_ifs <;>
simp [Complex.ofReal_log hx]
theorem ofReal_cpow_of_nonpos {x : β} (hx : x β€ 0) (y : β) :
(x : β) ^ y = (-x : β) ^ y * exp (Ο * I * y) := by
rcases hx.eq_or_lt with (rfl | hlt)
Β· rcases eq_or_ne y 0 with (rfl | hy) <;> simp [*]
have hne : (x : β) β 0 := ofReal_ne_zero.mpr hlt.ne
rw [cpow_def_of_ne_zero hne, cpow_def_of_ne_zero (neg_ne_zero.2 hne), β exp_add, β add_mul, log,
log, norm_neg, arg_ofReal_of_neg hlt, β ofReal_neg, arg_ofReal_of_nonneg (neg_nonneg.2 hx),
ofReal_zero, zero_mul, add_zero]
lemma cpow_ofReal (x : β) (y : β) :
x ^ (y : β) = β(βxβ ^ y) * (Real.cos (arg x * y) + Real.sin (arg x * y) * I) := by
rcases eq_or_ne x 0 with rfl | hx
Β· simp [ofReal_cpow le_rfl]
Β· rw [cpow_def_of_ne_zero hx, exp_eq_exp_re_mul_sin_add_cos, mul_comm (log x)]
norm_cast
rw [re_ofReal_mul, im_ofReal_mul, log_re, log_im, mul_comm y, mul_comm y, Real.exp_mul,
Real.exp_log]
rwa [norm_pos_iff]
lemma cpow_ofReal_re (x : β) (y : β) : (x ^ (y : β)).re = βxβ ^ y * Real.cos (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.cos]
lemma cpow_ofReal_im (x : β) (y : β) : (x ^ (y : β)).im = βxβ ^ y * Real.sin (arg x * y) := by
rw [cpow_ofReal]; generalize arg x * y = z; simp [Real.sin]
theorem norm_cpow_of_ne_zero {z : β} (hz : z β 0) (w : β) :
βz ^ wβ = βzβ ^ w.re / Real.exp (arg z * im w) := by
rw [cpow_def_of_ne_zero hz, norm_exp, mul_re, log_re, log_im, Real.exp_sub,
Real.rpow_def_of_pos (norm_pos_iff.mpr hz)]
theorem norm_cpow_of_imp {z w : β} (h : z = 0 β w.re = 0 β w = 0) :
βz ^ wβ = βzβ ^ w.re / Real.exp (arg z * im w) := by
rcases ne_or_eq z 0 with (hz | rfl) <;> [exact norm_cpow_of_ne_zero hz w; rw [norm_zero]]
rcases eq_or_ne w.re 0 with hw | hw
Β· simp [hw, h rfl hw]
Β· rw [Real.zero_rpow hw, zero_div, zero_cpow, norm_zero]
exact ne_of_apply_ne re hw
theorem norm_cpow_le (z w : β) : βz ^ wβ β€ βzβ ^ w.re / Real.exp (arg z * im w) := by
by_cases h : z = 0 β w.re = 0 β w = 0
Β· exact (norm_cpow_of_imp h).le
Β· push_neg at h
simp [h]
@[simp]
theorem norm_cpow_real (x : β) (y : β) : βx ^ (y : β)β = βxβ ^ y := by
rw [norm_cpow_of_imp] <;> simp
@[simp]
theorem norm_cpow_inv_nat (x : β) (n : β) : βx ^ (nβ»ΒΉ : β)β = βxβ ^ (nβ»ΒΉ : β) := by
rw [β norm_cpow_real]; simp
theorem norm_cpow_eq_rpow_re_of_pos {x : β} (hx : 0 < x) (y : β) : β(x : β) ^ yβ = x ^ y.re := by
rw [norm_cpow_of_ne_zero (ofReal_ne_zero.mpr hx.ne'), arg_ofReal_of_nonneg hx.le,
zero_mul, Real.exp_zero, div_one, Complex.norm_of_nonneg hx.le]
theorem norm_cpow_eq_rpow_re_of_nonneg {x : β} (hx : 0 β€ x) {y : β} (hy : re y β 0) :
β(x : β) ^ yβ = x ^ re y := by
rw [norm_cpow_of_imp] <;> simp [*, arg_ofReal_of_nonneg, abs_of_nonneg]
@[deprecated (since := "2025-02-17")] alias abs_cpow_of_ne_zero := norm_cpow_of_ne_zero
@[deprecated (since := "2025-02-17")] alias abs_cpow_of_imp := norm_cpow_of_imp
@[deprecated (since := "2025-02-17")] alias abs_cpow_le := norm_cpow_le
@[deprecated (since := "2025-02-17")] alias abs_cpow_real := norm_cpow_real
@[deprecated (since := "2025-02-17")] alias abs_cpow_inv_nat := norm_cpow_inv_nat
@[deprecated (since := "2025-02-17")] alias abs_cpow_eq_rpow_re_of_pos :=
norm_cpow_eq_rpow_re_of_pos
@[deprecated (since := "2025-02-17")] alias abs_cpow_eq_rpow_re_of_nonneg :=
norm_cpow_eq_rpow_re_of_nonneg
open Filter in
lemma norm_ofReal_cpow_eventually_eq_atTop (c : β) :
(fun t : β β¦ β(t : β) ^ cβ) =αΆ [atTop] fun t β¦ t ^ c.re := by
filter_upwards [eventually_gt_atTop 0] with t ht
rw [norm_cpow_eq_rpow_re_of_pos ht]
lemma norm_natCast_cpow_of_re_ne_zero (n : β) {s : β} (hs : s.re β 0) :
β(n : β) ^ sβ = (n : β) ^ (s.re) := by
rw [β ofReal_natCast, norm_cpow_eq_rpow_re_of_nonneg n.cast_nonneg hs]
lemma norm_natCast_cpow_of_pos {n : β} (hn : 0 < n) (s : β) :
β(n : β) ^ sβ = (n : β) ^ (s.re) := by
rw [β ofReal_natCast, norm_cpow_eq_rpow_re_of_pos (Nat.cast_pos.mpr hn) _]
lemma norm_natCast_cpow_pos_of_pos {n : β} (hn : 0 < n) (s : β) : 0 < β(n : β) ^ sβ :=
(norm_natCast_cpow_of_pos hn _).symm βΈ Real.rpow_pos_of_pos (Nat.cast_pos.mpr hn) _
theorem cpow_mul_ofReal_nonneg {x : β} (hx : 0 β€ x) (y : β) (z : β) :
(x : β) ^ (βy * z) = (β(x ^ y) : β) ^ z := by
rw [cpow_mul, ofReal_cpow hx]
Β· rw [β ofReal_log hx, β ofReal_mul, ofReal_im, neg_lt_zero]; exact Real.pi_pos
Β· rw [β ofReal_log hx, β ofReal_mul, ofReal_im]; exact Real.pi_pos.le
end Complex
/-! ### Positivity extension -/
namespace Mathlib.Meta.Positivity
open Lean Meta Qq
/-- Extension for the `positivity` tactic: exponentiation by a real number is positive (namely 1)
when the exponent is zero. The other cases are done in `evalRpow`. -/
@[positivity (_ : β) ^ (0 : β)]
def evalRpowZero : PositivityExt where eval {u Ξ±} _ _ e := do
match u, Ξ±, e with
| 0, ~q(β), ~q($a ^ (0 : β)) =>
assertInstancesCommute
pure (.positive q(Real.rpow_zero_pos $a))
| _, _, _ => throwError "not Real.rpow"
/-- Extension for the `positivity` tactic: exponentiation by a real number is nonnegative when
the base is nonnegative and positive when the base is positive. -/
@[positivity (_ : β) ^ (_ : β)]
def evalRpow : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q($a ^ ($b : β)) =>
let ra β core q(inferInstance) q(inferInstance) a
assertInstancesCommute
match ra with
| .positive pa =>
pure (.positive q(Real.rpow_pos_of_pos $pa $b))
| .nonnegative pa =>
pure (.nonnegative q(Real.rpow_nonneg $pa $b))
| _ => pure .none
| _, _, _ => throwError "not Real.rpow"
end Mathlib.Meta.Positivity
/-!
## Further algebraic properties of `rpow`
-/
namespace Real
variable {x y z : β} {n : β}
theorem rpow_mul {x : β} (hx : 0 β€ x) (y z : β) : x ^ (y * z) = (x ^ y) ^ z := by
rw [β Complex.ofReal_inj, Complex.ofReal_cpow (rpow_nonneg hx _),
Complex.ofReal_cpow hx, Complex.ofReal_mul, Complex.cpow_mul, Complex.ofReal_cpow hx] <;>
simp only [(Complex.ofReal_mul _ _).symm, (Complex.ofReal_log hx).symm, Complex.ofReal_im,
neg_lt_zero, pi_pos, le_of_lt pi_pos]
lemma rpow_pow_comm {x : β} (hx : 0 β€ x) (y : β) (n : β) : (x ^ y) ^ n = (x ^ n) ^ y := by
simp_rw [β rpow_natCast, β rpow_mul hx, mul_comm y]
lemma rpow_zpow_comm {x : β} (hx : 0 β€ x) (y : β) (n : β€) : (x ^ y) ^ n = (x ^ n) ^ y := by
simp_rw [β rpow_intCast, β rpow_mul hx, mul_comm y]
lemma rpow_add_intCast {x : β} (hx : x β 0) (y : β) (n : β€) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_def, rpow_def, Complex.ofReal_add,
Complex.cpow_add _ _ (Complex.ofReal_ne_zero.mpr hx), Complex.ofReal_intCast,
Complex.cpow_intCast, β Complex.ofReal_zpow, mul_comm, Complex.re_ofReal_mul, mul_comm]
lemma rpow_add_natCast {x : β} (hx : x β 0) (y : β) (n : β) : x ^ (y + n) = x ^ y * x ^ n := by
simpa using rpow_add_intCast hx y n
lemma rpow_sub_intCast {x : β} (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_add_intCast hx y (-n)
lemma rpow_sub_natCast {x : β} (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
simpa using rpow_sub_intCast hx y n
lemma rpow_add_intCast' (hx : 0 β€ x) {n : β€} (h : y + n β 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_intCast]
lemma rpow_add_natCast' (hx : 0 β€ x) (h : y + n β 0) : x ^ (y + n) = x ^ y * x ^ n := by
rw [rpow_add' hx h, rpow_natCast]
lemma rpow_sub_intCast' (hx : 0 β€ x) {n : β€} (h : y - n β 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_intCast]
lemma rpow_sub_natCast' (hx : 0 β€ x) (h : y - n β 0) : x ^ (y - n) = x ^ y / x ^ n := by
rw [rpow_sub' hx h, rpow_natCast]
theorem rpow_add_one {x : β} (hx : x β 0) (y : β) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
theorem rpow_sub_one {x : β} (hx : x β 0) (y : β) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (hx : 0 β€ x) (h : y + 1 β 0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_one_add' (hx : 0 β€ x) (h : 1 + y β 0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' hx h, rpow_one]
lemma rpow_sub_one' (hx : 0 β€ x) (h : y - 1 β 0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' hx h, rpow_one]
lemma rpow_one_sub' (hx : 0 β€ x) (h : 1 - y β 0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' hx h, rpow_one]
@[simp]
theorem rpow_two (x : β) : x ^ (2 : β) = x ^ 2 := by
rw [β rpow_natCast]
simp only [Nat.cast_ofNat]
theorem rpow_neg_one (x : β) : x ^ (-1 : β) = xβ»ΒΉ := by
suffices H : x ^ ((-1 : β€) : β) = xβ»ΒΉ by rwa [Int.cast_neg, Int.cast_one] at H
simp only [rpow_intCast, zpow_one, zpow_neg]
theorem mul_rpow (hx : 0 β€ x) (hy : 0 β€ y) : (x * y) ^ z = x ^ z * y ^ z := by
iterate 2 rw [Real.rpow_def_of_nonneg]; split_ifs with h_ifs <;> simp_all
Β· rw [log_mul βΉ_βΊ βΉ_βΊ, add_mul, exp_add, rpow_def_of_pos (hy.lt_of_ne' βΉ_βΊ)]
all_goals positivity
theorem inv_rpow (hx : 0 β€ x) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ := by
simp only [β rpow_neg_one, β rpow_mul hx, mul_comm]
theorem div_rpow (hx : 0 β€ x) (hy : 0 β€ y) (z : β) : (x / y) ^ z = x ^ z / y ^ z := by
simp only [div_eq_mul_inv, mul_rpow hx (inv_nonneg.2 hy), inv_rpow hy]
theorem log_rpow {x : β} (hx : 0 < x) (y : β) : log (x ^ y) = y * log x := by
apply exp_injective
rw [exp_log (rpow_pos_of_pos hx y), β exp_log hx, mul_comm, rpow_def_of_pos (exp_pos (log x)) y]
theorem mul_log_eq_log_iff {x y z : β} (hx : 0 < x) (hz : 0 < z) :
y * log x = log z β x ^ y = z :=
β¨fun h β¦ log_injOn_pos (rpow_pos_of_pos hx _) hz <| log_rpow hx _ |>.trans h,
by rintro rfl; rw [log_rpow hx]β©
@[simp] lemma rpow_rpow_inv (hx : 0 β€ x) (hy : y β 0) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul hx, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow (hx : 0 β€ x) (hy : y β 0) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul hx, inv_mul_cancelβ hy, rpow_one]
theorem pow_rpow_inv_natCast (hx : 0 β€ x) (hn : n β 0) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
have hn0 : (n : β) β 0 := Nat.cast_ne_zero.2 hn
rw [β rpow_natCast, β rpow_mul hx, mul_inv_cancelβ hn0, rpow_one]
theorem rpow_inv_natCast_pow (hx : 0 β€ x) (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
have hn0 : (n : β) β 0 := Nat.cast_ne_zero.2 hn
rw [β rpow_natCast, β rpow_mul hx, inv_mul_cancelβ hn0, rpow_one]
lemma rpow_natCast_mul (hx : 0 β€ x) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_mul_natCast (hx : 0 β€ x) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_natCast]
lemma rpow_intCast_mul (hx : 0 β€ x) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul hx, rpow_intCast]
lemma rpow_mul_intCast (hx : 0 β€ x) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul hx, rpow_intCast]
/-! Note: lemmas about `(β i β s, f i ^ r)` such as `Real.finset_prod_rpow` are proved
in `Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean` instead. -/
/-!
## Order and monotonicity
-/
@[gcongr, bound]
theorem rpow_lt_rpow (hx : 0 β€ x) (hxy : x < y) (hz : 0 < z) : x ^ z < y ^ z := by
rw [le_iff_eq_or_lt] at hx; rcases hx with hx | hx
Β· rw [β hx, zero_rpow (ne_of_gt hz)]
exact rpow_pos_of_pos (by rwa [β hx] at hxy) _
Β· rw [rpow_def_of_pos hx, rpow_def_of_pos (lt_trans hx hxy), exp_lt_exp]
exact mul_lt_mul_of_pos_right (log_lt_log hx hxy) hz
theorem strictMonoOn_rpow_Ici_of_exponent_pos {r : β} (hr : 0 < r) :
StrictMonoOn (fun (x : β) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_lt_rpow ha hab hr
@[gcongr, bound]
theorem rpow_le_rpow {x y z : β} (h : 0 β€ x) (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z := by
rcases eq_or_lt_of_le hβ with (rfl | hβ'); Β· rfl
rcases eq_or_lt_of_le hβ with (rfl | hβ'); Β· simp
exact le_of_lt (rpow_lt_rpow h hβ' hβ')
theorem monotoneOn_rpow_Ici_of_exponent_nonneg {r : β} (hr : 0 β€ r) :
MonotoneOn (fun (x : β) => x ^ r) (Set.Ici 0) :=
fun _ ha _ _ hab => rpow_le_rpow ha hab hr
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z := by
have := hx.trans hxy
rw [β inv_lt_invβ, β rpow_neg, β rpow_neg]
on_goal 1 => refine rpow_lt_rpow ?_ hxy (neg_pos.2 hz)
all_goals positivity
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x β€ y) (hz : z β€ 0) : y ^ z β€ x ^ z := by
have := hx.trans_le hxy
rw [β inv_le_invβ, β rpow_neg, β rpow_neg]
on_goal 1 => refine rpow_le_rpow ?_ hxy (neg_nonneg.2 hz)
all_goals positivity
theorem rpow_lt_rpow_iff (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ z < y ^ z β x < y :=
β¨lt_imp_lt_of_le_imp_le fun h => rpow_le_rpow hy h (le_of_lt hz), fun h => rpow_lt_rpow hx h hzβ©
theorem rpow_le_rpow_iff (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff hy hx hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z β y < x :=
β¨lt_imp_lt_of_le_imp_le fun h β¦ rpow_le_rpow_of_nonpos hx h hz.le,
fun h β¦ rpow_lt_rpow_of_neg hy h hzβ©
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z β€ y ^ z β y β€ x :=
le_iff_le_iff_lt_iff_lt.2 <| rpow_lt_rpow_iff_of_neg hy hx hz
lemma le_rpow_inv_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
rw [β rpow_le_rpow_iff hx _ hz, rpow_inv_rpow] <;> positivity
lemma rpow_inv_le_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
rw [β rpow_le_rpow_iff _ hy hz, rpow_inv_rpow] <;> positivity
lemma lt_rpow_inv_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^ z < y :=
lt_iff_lt_of_le_iff_le <| rpow_inv_le_iff_of_pos hy hx hz
lemma rpow_inv_lt_iff_of_pos (hx : 0 β€ x) (hy : 0 β€ y) (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z :=
lt_iff_lt_of_le_iff_le <| le_rpow_inv_iff_of_pos hy hx hz
theorem le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x β€ y ^ zβ»ΒΉ β y β€ x ^ z := by
rw [β rpow_le_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x < y ^ zβ»ΒΉ β y < x ^ z := by
rw [β rpow_lt_rpow_iff_of_neg _ hx hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ zβ»ΒΉ < y β y ^ z < x := by
rw [β rpow_lt_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) :
x ^ zβ»ΒΉ β€ y β y ^ z β€ x := by
rw [β rpow_le_rpow_iff_of_neg hy _ hz, rpow_inv_rpow _ hz.ne] <;> positivity
theorem rpow_lt_rpow_of_exponent_lt (hx : 1 < x) (hyz : y < z) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos (lt_trans zero_lt_one hx)]
rw [exp_lt_exp]; exact mul_lt_mul_of_pos_left hyz (log_pos hx)
@[gcongr]
theorem rpow_le_rpow_of_exponent_le (hx : 1 β€ x) (hyz : y β€ z) : x ^ y β€ x ^ z := by
repeat' rw [rpow_def_of_pos (lt_of_lt_of_le zero_lt_one hx)]
rw [exp_le_exp]; exact mul_le_mul_of_nonneg_left hyz (log_nonneg hx)
theorem rpow_lt_rpow_of_exponent_neg {x y z : β} (hy : 0 < y) (hxy : y < x) (hz : z < 0) :
x ^ z < y ^ z := by
have hx : 0 < x := hy.trans hxy
rw [β neg_neg z, Real.rpow_neg (le_of_lt hx) (-z), Real.rpow_neg (le_of_lt hy) (-z),
inv_lt_invβ (rpow_pos_of_pos hx _) (rpow_pos_of_pos hy _)]
exact Real.rpow_lt_rpow (by positivity) hxy <| neg_pos_of_neg hz
theorem strictAntiOn_rpow_Ioi_of_exponent_neg {r : β} (hr : r < 0) :
StrictAntiOn (fun (x : β) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_lt_rpow_of_exponent_neg ha hab hr
theorem rpow_le_rpow_of_exponent_nonpos {x y : β} (hy : 0 < y) (hxy : y β€ x) (hz : z β€ 0) :
x ^ z β€ y ^ z := by
rcases ne_or_eq z 0 with hz_zero | rfl
case inl =>
rcases ne_or_eq x y with hxy' | rfl
case inl =>
exact le_of_lt <| rpow_lt_rpow_of_exponent_neg hy (Ne.lt_of_le (id (Ne.symm hxy')) hxy)
(Ne.lt_of_le hz_zero hz)
case inr => simp
case inr => simp
theorem antitoneOn_rpow_Ioi_of_exponent_nonpos {r : β} (hr : r β€ 0) :
AntitoneOn (fun (x : β) => x ^ r) (Set.Ioi 0) :=
fun _ ha _ _ hab => rpow_le_rpow_of_exponent_nonpos ha hab hr
@[simp]
theorem rpow_le_rpow_left_iff (hx : 1 < x) : x ^ y β€ x ^ z β y β€ z := by
have x_pos : 0 < x := lt_trans zero_lt_one hx
rw [β log_le_log_iff (rpow_pos_of_pos x_pos y) (rpow_pos_of_pos x_pos z), log_rpow x_pos,
log_rpow x_pos, mul_le_mul_right (log_pos hx)]
@[simp]
theorem rpow_lt_rpow_left_iff (hx : 1 < x) : x ^ y < x ^ z β y < z := by
rw [lt_iff_not_le, rpow_le_rpow_left_iff hx, lt_iff_not_le]
theorem rpow_lt_rpow_of_exponent_gt (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) : x ^ y < x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_lt_exp]; exact mul_lt_mul_of_neg_left hyz (log_neg hx0 hx1)
theorem rpow_le_rpow_of_exponent_ge (hx0 : 0 < x) (hx1 : x β€ 1) (hyz : z β€ y) : x ^ y β€ x ^ z := by
repeat' rw [rpow_def_of_pos hx0]
rw [exp_le_exp]; exact mul_le_mul_of_nonpos_left hyz (log_nonpos (le_of_lt hx0) hx1)
@[simp]
theorem rpow_le_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y β€ x ^ z β z β€ y := by
rw [β log_le_log_iff (rpow_pos_of_pos hx0 y) (rpow_pos_of_pos hx0 z), log_rpow hx0, log_rpow hx0,
mul_le_mul_right_of_neg (log_neg hx0 hx1)]
@[simp]
theorem rpow_lt_rpow_left_iff_of_base_lt_one (hx0 : 0 < x) (hx1 : x < 1) :
x ^ y < x ^ z β z < y := by
rw [lt_iff_not_le, rpow_le_rpow_left_iff_of_base_lt_one hx0 hx1, lt_iff_not_le]
theorem rpow_lt_one {x z : β} (hx1 : 0 β€ x) (hx2 : x < 1) (hz : 0 < z) : x ^ z < 1 := by
rw [β one_rpow z]
exact rpow_lt_rpow hx1 hx2 hz
theorem rpow_le_one {x z : β} (hx1 : 0 β€ x) (hx2 : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 := by
rw [β one_rpow z]
exact rpow_le_rpow hx1 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 := by
convert rpow_lt_rpow_of_exponent_lt hx hz
exact (rpow_zero x).symm
| Mathlib/Analysis/SpecialFunctions/Pow/Real.lean | 663 | 666 | theorem rpow_le_one_of_one_le_of_nonpos {x z : β} (hx : 1 β€ x) (hz : z β€ 0) : x ^ z β€ 1 := by | convert rpow_le_rpow_of_exponent_le hx hz
exact (rpow_zero x).symm |
/-
Copyright (c) 2023 Peter Nelson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Peter Nelson
-/
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.Data.Set.Finite.Powerset
/-!
# Noncomputable Set Cardinality
We define the cardinality of set `s` as a term `Set.encard s : ββ` and a term `Set.ncard s : β`.
The latter takes the junk value of zero if `s` is infinite. Both functions are noncomputable, and
are defined in terms of `ENat.card` (which takes a type as its argument); this file can be seen
as an API for the same function in the special case where the type is a coercion of a `Set`,
allowing for smoother interactions with the `Set` API.
`Set.encard` never takes junk values, so is more mathematically natural than `Set.ncard`, even
though it takes values in a less convenient type. It is probably the right choice in settings where
one is concerned with the cardinalities of sets that may or may not be infinite.
`Set.ncard` has a nicer codomain, but when using it, `Set.Finite` hypotheses are normally needed to
make sure its values are meaningful. More generally, `Set.ncard` is intended to be used over the
obvious alternative `Finset.card` when finiteness is 'propositional' rather than 'structural'.
When working with sets that are finite by virtue of their definition, then `Finset.card` probably
makes more sense. One setting where `Set.ncard` works nicely is in a type `Ξ±` with `[Finite Ξ±]`,
where every set is automatically finite. In this setting, we use default arguments and a simple
tactic so that finiteness goals are discharged automatically in `Set.ncard` theorems.
## Main Definitions
* `Set.encard s` is the cardinality of the set `s` as an extended natural number, with value `β€` if
`s` is infinite.
* `Set.ncard s` is the cardinality of the set `s` as a natural number, provided `s` is Finite.
If `s` is Infinite, then `Set.ncard s = 0`.
* `toFinite_tac` is a tactic that tries to synthesize a `Set.Finite s` argument with
`Set.toFinite`. This will work for `s : Set Ξ±` where there is a `Finite Ξ±` instance.
## Implementation Notes
The theorems in this file are very similar to those in `Data.Finset.Card`, but with `Set` operations
instead of `Finset`. We first prove all the theorems for `Set.encard`, and then derive most of the
`Set.ncard` results as a consequence. Things are done this way to avoid reliance on the `Finset` API
for theorems about infinite sets, and to allow for a refactor that removes or modifies `Set.ncard`
in the future.
Nearly all the theorems for `Set.ncard` require finiteness of one or more of their arguments. We
provide this assumption with a default argument of the form `(hs : s.Finite := by toFinite_tac)`,
where `toFinite_tac` will find an `s.Finite` term in the cases where `s` is a set in a `Finite`
type.
Often, where there are two set arguments `s` and `t`, the finiteness of one follows from the other
in the context of the theorem, in which case we only include the ones that are needed, and derive
the other inside the proof. A few of the theorems, such as `ncard_union_le` do not require
finiteness arguments; they are true by coincidence due to junk values.
-/
namespace Set
variable {Ξ± Ξ² : Type*} {s t : Set Ξ±}
/-- The cardinality of a set as a term in `ββ` -/
noncomputable def encard (s : Set Ξ±) : ββ := ENat.card s
@[simp] theorem encard_univ_coe (s : Set Ξ±) : encard (univ : Set s) = encard s := by
rw [encard, encard, ENat.card_congr (Equiv.Set.univ βs)]
theorem encard_univ (Ξ± : Type*) :
encard (univ : Set Ξ±) = ENat.card Ξ± := by
rw [encard, ENat.card_congr (Equiv.Set.univ Ξ±)]
theorem Finite.encard_eq_coe_toFinset_card (h : s.Finite) : s.encard = h.toFinset.card := by
have := h.fintype
rw [encard, ENat.card_eq_coe_fintype_card, toFinite_toFinset, toFinset_card]
theorem encard_eq_coe_toFinset_card (s : Set Ξ±) [Fintype s] : encard s = s.toFinset.card := by
have h := toFinite s
rw [h.encard_eq_coe_toFinset_card, toFinite_toFinset]
@[simp] theorem toENat_cardinalMk (s : Set Ξ±) : (Cardinal.mk s).toENat = s.encard := rfl
theorem toENat_cardinalMk_subtype (P : Ξ± β Prop) :
(Cardinal.mk {x // P x}).toENat = {x | P x}.encard :=
rfl
@[simp] theorem coe_fintypeCard (s : Set Ξ±) [Fintype s] : Fintype.card s = s.encard := by
simp [encard_eq_coe_toFinset_card]
@[simp, norm_cast] theorem encard_coe_eq_coe_finsetCard (s : Finset Ξ±) :
encard (s : Set Ξ±) = s.card := by
rw [Finite.encard_eq_coe_toFinset_card (Finset.finite_toSet s)]; simp
@[simp] theorem Infinite.encard_eq {s : Set Ξ±} (h : s.Infinite) : s.encard = β€ := by
have := h.to_subtype
rw [encard, ENat.card_eq_top_of_infinite]
@[simp] theorem encard_eq_zero : s.encard = 0 β s = β
:= by
rw [encard, ENat.card_eq_zero_iff_empty, isEmpty_subtype, eq_empty_iff_forall_not_mem]
@[simp] theorem encard_empty : (β
: Set Ξ±).encard = 0 := by
rw [encard_eq_zero]
theorem nonempty_of_encard_ne_zero (h : s.encard β 0) : s.Nonempty := by
rwa [nonempty_iff_ne_empty, Ne, β encard_eq_zero]
theorem encard_ne_zero : s.encard β 0 β s.Nonempty := by
rw [ne_eq, encard_eq_zero, nonempty_iff_ne_empty]
@[simp] theorem encard_pos : 0 < s.encard β s.Nonempty := by
rw [pos_iff_ne_zero, encard_ne_zero]
protected alias β¨_, Nonempty.encard_posβ© := encard_pos
@[simp] theorem encard_singleton (e : Ξ±) : ({e} : Set Ξ±).encard = 1 := by
rw [encard, ENat.card_eq_coe_fintype_card, Fintype.card_ofSubsingleton, Nat.cast_one]
theorem encard_union_eq (h : Disjoint s t) : (s βͺ t).encard = s.encard + t.encard := by
classical
simp [encard, ENat.card_congr (Equiv.Set.union h)]
theorem encard_insert_of_not_mem {a : Ξ±} (has : a β s) : (insert a s).encard = s.encard + 1 := by
rw [β union_singleton, encard_union_eq (by simpa), encard_singleton]
theorem Finite.encard_lt_top (h : s.Finite) : s.encard < β€ := by
induction s, h using Set.Finite.induction_on with
| empty => simp
| insert hat _ ht' =>
rw [encard_insert_of_not_mem hat]
exact lt_tsub_iff_right.1 ht'
theorem Finite.encard_eq_coe (h : s.Finite) : s.encard = ENat.toNat s.encard :=
(ENat.coe_toNat h.encard_lt_top.ne).symm
theorem Finite.exists_encard_eq_coe (h : s.Finite) : β (n : β), s.encard = n :=
β¨_, h.encard_eq_coeβ©
@[simp] theorem encard_lt_top_iff : s.encard < β€ β s.Finite :=
β¨fun h β¦ by_contra fun h' β¦ h.ne (Infinite.encard_eq h'), Finite.encard_lt_topβ©
@[simp] theorem encard_eq_top_iff : s.encard = β€ β s.Infinite := by
rw [β not_iff_not, β Ne, β lt_top_iff_ne_top, encard_lt_top_iff, not_infinite]
alias β¨_, encard_eq_topβ© := encard_eq_top_iff
theorem encard_ne_top_iff : s.encard β β€ β s.Finite := by
simp
theorem finite_of_encard_le_coe {k : β} (h : s.encard β€ k) : s.Finite := by
rw [β encard_lt_top_iff]; exact h.trans_lt (WithTop.coe_lt_top _)
theorem finite_of_encard_eq_coe {k : β} (h : s.encard = k) : s.Finite :=
finite_of_encard_le_coe h.le
theorem encard_le_coe_iff {k : β} : s.encard β€ k β s.Finite β§ β (nβ : β), s.encard = nβ β§ nβ β€ k :=
β¨fun h β¦ β¨finite_of_encard_le_coe h, by rwa [ENat.le_coe_iff] at hβ©,
fun β¨_,β¨nβ,hs, hleβ©β© β¦ by rwa [hs, Nat.cast_le]β©
@[simp]
theorem encard_prod : (s ΓΛ’ t).encard = s.encard * t.encard := by
simp [Set.encard, ENat.card_congr (Equiv.Set.prod ..)]
section Lattice
theorem encard_le_encard (h : s β t) : s.encard β€ t.encard := by
rw [β union_diff_cancel h, encard_union_eq disjoint_sdiff_right]; exact le_self_add
@[deprecated (since := "2025-01-05")] alias encard_le_card := encard_le_encard
theorem encard_mono {Ξ± : Type*} : Monotone (encard : Set Ξ± β ββ) :=
fun _ _ β¦ encard_le_encard
theorem encard_diff_add_encard_of_subset (h : s β t) : (t \ s).encard + s.encard = t.encard := by
rw [β encard_union_eq disjoint_sdiff_left, diff_union_self, union_eq_self_of_subset_right h]
@[simp] theorem one_le_encard_iff_nonempty : 1 β€ s.encard β s.Nonempty := by
rw [nonempty_iff_ne_empty, Ne, β encard_eq_zero, ENat.one_le_iff_ne_zero]
theorem encard_diff_add_encard_inter (s t : Set Ξ±) :
(s \ t).encard + (s β© t).encard = s.encard := by
rw [β encard_union_eq (disjoint_of_subset_right inter_subset_right disjoint_sdiff_left),
diff_union_inter]
theorem encard_union_add_encard_inter (s t : Set Ξ±) :
(s βͺ t).encard + (s β© t).encard = s.encard + t.encard := by
rw [β diff_union_self, encard_union_eq disjoint_sdiff_left, add_right_comm,
encard_diff_add_encard_inter]
theorem encard_eq_encard_iff_encard_diff_eq_encard_diff (h : (s β© t).Finite) :
s.encard = t.encard β (s \ t).encard = (t \ s).encard := by
rw [β encard_diff_add_encard_inter s t, β encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_right_inj h.encard_lt_top.ne]
theorem encard_le_encard_iff_encard_diff_le_encard_diff (h : (s β© t).Finite) :
s.encard β€ t.encard β (s \ t).encard β€ (t \ s).encard := by
rw [β encard_diff_add_encard_inter s t, β encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_le_add_iff_right h.encard_lt_top.ne]
theorem encard_lt_encard_iff_encard_diff_lt_encard_diff (h : (s β© t).Finite) :
s.encard < t.encard β (s \ t).encard < (t \ s).encard := by
rw [β encard_diff_add_encard_inter s t, β encard_diff_add_encard_inter t s, inter_comm t s,
WithTop.add_lt_add_iff_right h.encard_lt_top.ne]
theorem encard_union_le (s t : Set Ξ±) : (s βͺ t).encard β€ s.encard + t.encard := by
rw [β encard_union_add_encard_inter]; exact le_self_add
theorem finite_iff_finite_of_encard_eq_encard (h : s.encard = t.encard) : s.Finite β t.Finite := by
rw [β encard_lt_top_iff, β encard_lt_top_iff, h]
theorem infinite_iff_infinite_of_encard_eq_encard (h : s.encard = t.encard) :
s.Infinite β t.Infinite := by rw [β encard_eq_top_iff, h, encard_eq_top_iff]
theorem Finite.finite_of_encard_le {s : Set Ξ±} {t : Set Ξ²} (hs : s.Finite)
(h : t.encard β€ s.encard) : t.Finite :=
encard_lt_top_iff.1 (h.trans_lt hs.encard_lt_top)
lemma Finite.eq_of_subset_of_encard_le' (ht : t.Finite) (hst : s β t) (hts : t.encard β€ s.encard) :
s = t := by
rw [β zero_add (a := encard s), β encard_diff_add_encard_of_subset hst] at hts
have hdiff := WithTop.le_of_add_le_add_right (ht.subset hst).encard_lt_top.ne hts
rw [nonpos_iff_eq_zero, encard_eq_zero, diff_eq_empty] at hdiff
exact hst.antisymm hdiff
theorem Finite.eq_of_subset_of_encard_le (hs : s.Finite) (hst : s β t)
(hts : t.encard β€ s.encard) : s = t :=
(hs.finite_of_encard_le hts).eq_of_subset_of_encard_le' hst hts
theorem Finite.encard_lt_encard (hs : s.Finite) (h : s β t) : s.encard < t.encard :=
(encard_mono h.subset).lt_of_ne fun he β¦ h.ne (hs.eq_of_subset_of_encard_le h.subset he.symm.le)
theorem encard_strictMono [Finite Ξ±] : StrictMono (encard : Set Ξ± β ββ) :=
fun _ _ h β¦ (toFinite _).encard_lt_encard h
theorem encard_diff_add_encard (s t : Set Ξ±) : (s \ t).encard + t.encard = (s βͺ t).encard := by
rw [β encard_union_eq disjoint_sdiff_left, diff_union_self]
theorem encard_le_encard_diff_add_encard (s t : Set Ξ±) : s.encard β€ (s \ t).encard + t.encard :=
(encard_mono subset_union_left).trans_eq (encard_diff_add_encard _ _).symm
theorem tsub_encard_le_encard_diff (s t : Set Ξ±) : s.encard - t.encard β€ (s \ t).encard := by
rw [tsub_le_iff_left, add_comm]; apply encard_le_encard_diff_add_encard
theorem encard_add_encard_compl (s : Set Ξ±) : s.encard + sαΆ.encard = (univ : Set Ξ±).encard := by
rw [β encard_union_eq disjoint_compl_right, union_compl_self]
end Lattice
section InsertErase
variable {a b : Ξ±}
theorem encard_insert_le (s : Set Ξ±) (x : Ξ±) : (insert x s).encard β€ s.encard + 1 := by
rw [β union_singleton, β encard_singleton x]; apply encard_union_le
theorem encard_singleton_inter (s : Set Ξ±) (x : Ξ±) : ({x} β© s).encard β€ 1 := by
rw [β encard_singleton x]; exact encard_le_encard inter_subset_left
theorem encard_diff_singleton_add_one (h : a β s) :
(s \ {a}).encard + 1 = s.encard := by
rw [β encard_insert_of_not_mem (fun h β¦ h.2 rfl), insert_diff_singleton, insert_eq_of_mem h]
theorem encard_diff_singleton_of_mem (h : a β s) :
(s \ {a}).encard = s.encard - 1 := by
rw [β encard_diff_singleton_add_one h, β WithTop.add_right_inj WithTop.one_ne_top,
tsub_add_cancel_of_le (self_le_add_left _ _)]
theorem encard_tsub_one_le_encard_diff_singleton (s : Set Ξ±) (x : Ξ±) :
s.encard - 1 β€ (s \ {x}).encard := by
rw [β encard_singleton x]; apply tsub_encard_le_encard_diff
theorem encard_exchange (ha : a β s) (hb : b β s) : (insert a (s \ {b})).encard = s.encard := by
rw [encard_insert_of_not_mem, encard_diff_singleton_add_one hb]
simp_all only [not_true, mem_diff, mem_singleton_iff, false_and, not_false_eq_true]
theorem encard_exchange' (ha : a β s) (hb : b β s) : (insert a s \ {b}).encard = s.encard := by
rw [β insert_diff_singleton_comm (by rintro rfl; exact ha hb), encard_exchange ha hb]
theorem encard_eq_add_one_iff {k : ββ} :
s.encard = k + 1 β (β a t, Β¬a β t β§ insert a t = s β§ t.encard = k) := by
refine β¨fun h β¦ ?_, ?_β©
Β· obtain β¨a, haβ© := nonempty_of_encard_ne_zero (s := s) (by simp [h])
refine β¨a, s \ {a}, fun h β¦ h.2 rfl, by rwa [insert_diff_singleton, insert_eq_of_mem], ?_β©
rw [β WithTop.add_right_inj WithTop.one_ne_top, β h,
encard_diff_singleton_add_one ha]
rintro β¨a, t, h, rfl, rflβ©
rw [encard_insert_of_not_mem h]
/-- Every set is either empty, infinite, or can have its `encard` reduced by a removal. Intended
for well-founded induction on the value of `encard`. -/
theorem eq_empty_or_encard_eq_top_or_encard_diff_singleton_lt (s : Set Ξ±) :
s = β
β¨ s.encard = β€ β¨ β a β s, (s \ {a}).encard < s.encard := by
refine s.eq_empty_or_nonempty.elim Or.inl (Or.inr β fun β¨a,haβ© β¦
(s.finite_or_infinite.elim (fun hfin β¦ Or.inr β¨a, ha, ?_β©) (Or.inl β Infinite.encard_eq)))
rw [β encard_diff_singleton_add_one ha]; nth_rw 1 [β add_zero (encard _)]
exact WithTop.add_lt_add_left hfin.diff.encard_lt_top.ne zero_lt_one
end InsertErase
section SmallSets
theorem encard_pair {x y : Ξ±} (hne : x β y) : ({x, y} : Set Ξ±).encard = 2 := by
rw [encard_insert_of_not_mem (by simpa), β one_add_one_eq_two,
WithTop.add_right_inj WithTop.one_ne_top, encard_singleton]
theorem encard_eq_one : s.encard = 1 β β x, s = {x} := by
refine β¨fun h β¦ ?_, fun β¨x, hxβ© β¦ by rw [hx, encard_singleton]β©
obtain β¨x, hxβ© := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
exact β¨x, ((finite_singleton x).eq_of_subset_of_encard_le (by simpa) (by simp [h])).symmβ©
theorem encard_le_one_iff_eq : s.encard β€ 1 β s = β
β¨ β x, s = {x} := by
rw [le_iff_lt_or_eq, lt_iff_not_le, ENat.one_le_iff_ne_zero, not_not, encard_eq_zero,
encard_eq_one]
theorem encard_le_one_iff : s.encard β€ 1 β β a b, a β s β b β s β a = b := by
rw [encard_le_one_iff_eq, or_iff_not_imp_left, β Ne, β nonempty_iff_ne_empty]
refine β¨fun h a b has hbs β¦ ?_,
fun h β¨x, hxβ© β¦ β¨x, ((singleton_subset_iff.2 hx).antisymm' (fun y hy β¦ h _ _ hy hx))β©β©
obtain β¨x, rflβ© := h β¨_, hasβ©
rw [(has : a = x), (hbs : b = x)]
theorem encard_le_one_iff_subsingleton : s.encard β€ 1 β s.Subsingleton := by
rw [encard_le_one_iff, Set.Subsingleton]
tauto
theorem one_lt_encard_iff_nontrivial : 1 < s.encard β s.Nontrivial := by
rw [β not_iff_not, not_lt, Set.not_nontrivial_iff, β encard_le_one_iff_subsingleton]
theorem one_lt_encard_iff : 1 < s.encard β β a b, a β s β§ b β s β§ a β b := by
rw [β not_iff_not, not_exists, not_lt, encard_le_one_iff]; aesop
theorem exists_ne_of_one_lt_encard (h : 1 < s.encard) (a : Ξ±) : β b β s, b β a := by
by_contra! h'
obtain β¨b, b', hb, hb', hneβ© := one_lt_encard_iff.1 h
apply hne
rw [h' b hb, h' b' hb']
theorem encard_eq_two : s.encard = 2 β β x y, x β y β§ s = {x, y} := by
refine β¨fun h β¦ ?_, fun β¨x, y, hne, hsβ© β¦ by rw [hs, encard_pair hne]β©
obtain β¨x, hxβ© := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
rw [β insert_eq_of_mem hx, β insert_diff_singleton, encard_insert_of_not_mem (fun h β¦ h.2 rfl),
β one_add_one_eq_two, WithTop.add_right_inj (WithTop.one_ne_top), encard_eq_one] at h
obtain β¨y, hβ© := h
refine β¨x, y, by rintro rfl; exact (h.symm.subset rfl).2 rfl, ?_β©
rw [β h, insert_diff_singleton, insert_eq_of_mem hx]
theorem encard_eq_three {Ξ± : Type u_1} {s : Set Ξ±} :
encard s = 3 β β x y z, x β y β§ x β z β§ y β z β§ s = {x, y, z} := by
refine β¨fun h β¦ ?_, fun β¨x, y, z, hxy, hyz, hxz, hsβ© β¦ ?_β©
Β· obtain β¨x, hxβ© := nonempty_of_encard_ne_zero (s := s) (by rw [h]; simp)
rw [β insert_eq_of_mem hx, β insert_diff_singleton,
encard_insert_of_not_mem (fun h β¦ h.2 rfl), (by exact rfl : (3 : ββ) = 2 + 1),
WithTop.add_right_inj WithTop.one_ne_top, encard_eq_two] at h
obtain β¨y, z, hne, hsβ© := h
refine β¨x, y, z, ?_, ?_, hne, ?_β©
Β· rintro rfl; exact (hs.symm.subset (Or.inl rfl)).2 rfl
Β· rintro rfl; exact (hs.symm.subset (Or.inr rfl)).2 rfl
rw [β hs, insert_diff_singleton, insert_eq_of_mem hx]
rw [hs, encard_insert_of_not_mem, encard_insert_of_not_mem, encard_singleton] <;> aesop
theorem Nat.encard_range (k : β) : {i | i < k}.encard = k := by
convert encard_coe_eq_coe_finsetCard (Finset.range k) using 1
Β· rw [Finset.coe_range, Iio_def]
rw [Finset.card_range]
end SmallSets
theorem Finite.eq_insert_of_subset_of_encard_eq_succ (hs : s.Finite) (h : s β t)
(hst : t.encard = s.encard + 1) : β a, t = insert a s := by
rw [β encard_diff_add_encard_of_subset h, add_comm, WithTop.add_left_inj hs.encard_lt_top.ne,
encard_eq_one] at hst
obtain β¨x, hxβ© := hst; use x; rw [β diff_union_of_subset h, hx, singleton_union]
theorem exists_subset_encard_eq {k : ββ} (hk : k β€ s.encard) : β t, t β s β§ t.encard = k := by
revert hk
refine ENat.nat_induction k (fun _ β¦ β¨β
, empty_subset _, by simpβ©) (fun n IH hle β¦ ?_) ?_
Β· obtain β¨tβ, htβs, htββ© := IH (le_trans (by simp) hle)
simp only [Nat.cast_succ] at *
have hne : tβ β s := by
rintro rfl; rw [htβ, β Nat.cast_one, β Nat.cast_add, Nat.cast_le] at hle; simp at hle
obtain β¨x, hxβ© := exists_of_ssubset (htβs.ssubset_of_ne hne)
exact β¨insert x tβ, insert_subset hx.1 htβs, by rw [encard_insert_of_not_mem hx.2, htβ]β©
simp only [top_le_iff, encard_eq_top_iff]
exact fun _ hi β¦ β¨s, Subset.rfl, hiβ©
theorem exists_superset_subset_encard_eq {k : ββ}
(hst : s β t) (hsk : s.encard β€ k) (hkt : k β€ t.encard) :
β r, s β r β§ r β t β§ r.encard = k := by
obtain (hs | hs) := eq_or_ne s.encard β€
Β· rw [hs, top_le_iff] at hsk; subst hsk; exact β¨s, Subset.rfl, hst, hsβ©
obtain β¨k, rflβ© := exists_add_of_le hsk
obtain β¨k', hk'β© := exists_add_of_le hkt
have hk : k β€ encard (t \ s) := by
rw [β encard_diff_add_encard_of_subset hst, add_comm] at hkt
exact WithTop.le_of_add_le_add_right hs hkt
obtain β¨r', hr', rflβ© := exists_subset_encard_eq hk
refine β¨s βͺ r', subset_union_left, union_subset hst (hr'.trans diff_subset), ?_β©
rw [encard_union_eq (disjoint_of_subset_right hr' disjoint_sdiff_right)]
section Function
variable {s : Set Ξ±} {t : Set Ξ²} {f : Ξ± β Ξ²}
theorem InjOn.encard_image (h : InjOn f s) : (f '' s).encard = s.encard := by
rw [encard, ENat.card_image_of_injOn h, encard]
theorem encard_congr (e : s β t) : s.encard = t.encard := by
rw [β encard_univ_coe, β encard_univ_coe t, encard_univ, encard_univ, ENat.card_congr e]
theorem _root_.Function.Injective.encard_image (hf : f.Injective) (s : Set Ξ±) :
(f '' s).encard = s.encard :=
hf.injOn.encard_image
theorem _root_.Function.Embedding.encard_le (e : s βͺ t) : s.encard β€ t.encard := by
rw [β encard_univ_coe, β e.injective.encard_image, β Subtype.coe_injective.encard_image]
exact encard_mono (by simp)
theorem encard_image_le (f : Ξ± β Ξ²) (s : Set Ξ±) : (f '' s).encard β€ s.encard := by
obtain (h | h) := isEmpty_or_nonempty Ξ±
Β· rw [s.eq_empty_of_isEmpty]; simp
rw [β (f.invFunOn_injOn_image s).encard_image]
apply encard_le_encard
exact f.invFunOn_image_image_subset s
theorem Finite.injOn_of_encard_image_eq (hs : s.Finite) (h : (f '' s).encard = s.encard) :
InjOn f s := by
obtain (h' | hne) := isEmpty_or_nonempty Ξ±
Β· rw [s.eq_empty_of_isEmpty]; simp
rw [β (f.invFunOn_injOn_image s).encard_image] at h
rw [injOn_iff_invFunOn_image_image_eq_self]
exact hs.eq_of_subset_of_encard_le' (f.invFunOn_image_image_subset s) h.symm.le
theorem encard_preimage_of_injective_subset_range (hf : f.Injective) (ht : t β range f) :
(f β»ΒΉ' t).encard = t.encard := by
rw [β hf.encard_image, image_preimage_eq_inter_range, inter_eq_self_of_subset_left ht]
lemma encard_preimage_of_bijective (hf : f.Bijective) (t : Set Ξ²) : (f β»ΒΉ' t).encard = t.encard :=
encard_preimage_of_injective_subset_range hf.injective (by simp [hf.surjective.range_eq])
theorem encard_le_encard_of_injOn (hf : MapsTo f s t) (f_inj : InjOn f s) :
s.encard β€ t.encard := by
rw [β f_inj.encard_image]; apply encard_le_encard; rintro _ β¨x, hx, rflβ©; exact hf hx
theorem Finite.exists_injOn_of_encard_le [Nonempty Ξ²] {s : Set Ξ±} {t : Set Ξ²} (hs : s.Finite)
(hle : s.encard β€ t.encard) : β (f : Ξ± β Ξ²), s β f β»ΒΉ' t β§ InjOn f s := by
classical
obtain (rfl | h | β¨a, has, -β©) := s.eq_empty_or_encard_eq_top_or_encard_diff_singleton_lt
Β· simp
Β· exact (encard_ne_top_iff.mpr hs h).elim
obtain β¨b, hbtβ© := encard_pos.1 ((encard_pos.2 β¨_, hasβ©).trans_le hle)
have hle' : (s \ {a}).encard β€ (t \ {b}).encard := by
rwa [β WithTop.add_le_add_iff_right WithTop.one_ne_top,
encard_diff_singleton_add_one has, encard_diff_singleton_add_one hbt]
obtain β¨fβ, hfβs, hinjβ© := exists_injOn_of_encard_le hs.diff hle'
simp only [preimage_diff, subset_def, mem_diff, mem_singleton_iff, mem_preimage, and_imp] at hfβs
use Function.update fβ a b
rw [β insert_eq_of_mem has, β insert_diff_singleton, injOn_insert (fun h β¦ h.2 rfl)]
simp only [mem_diff, mem_singleton_iff, not_true, and_false, insert_diff_singleton, subset_def,
mem_insert_iff, mem_preimage, ne_eq, Function.update_apply, forall_eq_or_imp, ite_true, and_imp,
mem_image, ite_eq_left_iff, not_exists, not_and, not_forall, exists_prop, and_iff_right hbt]
refine β¨?_, ?_, fun x hxs hxa β¦ β¨hxa, (hfβs x hxs hxa).2β©β©
Β· rintro x hx; split_ifs with h
Β· assumption
Β· exact (hfβs x hx h).1
exact InjOn.congr hinj (fun x β¨_, hxaβ© β¦ by rwa [Function.update_of_ne])
termination_by encard s
theorem Finite.exists_bijOn_of_encard_eq [Nonempty Ξ²] (hs : s.Finite) (h : s.encard = t.encard) :
β (f : Ξ± β Ξ²), BijOn f s t := by
obtain β¨f, hf, hinjβ© := hs.exists_injOn_of_encard_le h.le; use f
convert hinj.bijOn_image
rw [(hs.image f).eq_of_subset_of_encard_le (image_subset_iff.mpr hf)
(h.symm.trans hinj.encard_image.symm).le]
end Function
section ncard
open Nat
/-- A tactic (for use in default params) that applies `Set.toFinite` to synthesize a `Set.Finite`
term. -/
syntax "toFinite_tac" : tactic
macro_rules
| `(tactic| toFinite_tac) => `(tactic| apply Set.toFinite)
/-- A tactic useful for transferring proofs for `encard` to their corresponding `card` statements -/
syntax "to_encard_tac" : tactic
macro_rules
| `(tactic| to_encard_tac) => `(tactic|
simp only [β Nat.cast_le (Ξ± := ββ), β Nat.cast_inj (R := ββ), Nat.cast_add, Nat.cast_one])
/-- The cardinality of `s : Set Ξ±` . Has the junk value `0` if `s` is infinite -/
noncomputable def ncard (s : Set Ξ±) : β := ENat.toNat s.encard
theorem ncard_def (s : Set Ξ±) : s.ncard = ENat.toNat s.encard := rfl
theorem Finite.cast_ncard_eq (hs : s.Finite) : s.ncard = s.encard := by
rwa [ncard, ENat.coe_toNat_eq_self, ne_eq, encard_eq_top_iff, Set.Infinite, not_not]
lemma ncard_le_encard (s : Set Ξ±) : s.ncard β€ s.encard := ENat.coe_toNat_le_self _
theorem Nat.card_coe_set_eq (s : Set Ξ±) : Nat.card s = s.ncard := by
obtain (h | h) := s.finite_or_infinite
Β· have := h.fintype
rw [ncard, h.encard_eq_coe_toFinset_card, Nat.card_eq_fintype_card,
toFinite_toFinset, toFinset_card, ENat.toNat_coe]
have := infinite_coe_iff.2 h
rw [ncard, h.encard_eq, Nat.card_eq_zero_of_infinite, ENat.toNat_top]
theorem ncard_eq_toFinset_card (s : Set Ξ±) (hs : s.Finite := by toFinite_tac) :
s.ncard = hs.toFinset.card := by
rw [β Nat.card_coe_set_eq, @Nat.card_eq_fintype_card _ hs.fintype,
@Finite.card_toFinset _ _ hs.fintype hs]
theorem ncard_eq_toFinset_card' (s : Set Ξ±) [Fintype s] :
s.ncard = s.toFinset.card := by
simp [β Nat.card_coe_set_eq, Nat.card_eq_fintype_card]
lemma cast_ncard {s : Set Ξ±} (hs : s.Finite) :
(s.ncard : Cardinal) = Cardinal.mk s := @Nat.cast_card _ hs
theorem encard_le_coe_iff_finite_ncard_le {k : β} : s.encard β€ k β s.Finite β§ s.ncard β€ k := by
rw [encard_le_coe_iff, and_congr_right_iff]
exact fun hfin β¦ β¨fun β¨nβ, hnβ, hleβ© β¦ by rwa [ncard_def, hnβ, ENat.toNat_coe],
fun h β¦ β¨s.ncard, by rw [hfin.cast_ncard_eq], hβ©β©
theorem Infinite.ncard (hs : s.Infinite) : s.ncard = 0 := by
rw [β Nat.card_coe_set_eq, @Nat.card_eq_zero_of_infinite _ hs.to_subtype]
@[gcongr]
theorem ncard_le_ncard (hst : s β t) (ht : t.Finite := by toFinite_tac) :
s.ncard β€ t.ncard := by
rw [β Nat.cast_le (Ξ± := ββ), ht.cast_ncard_eq, (ht.subset hst).cast_ncard_eq]
exact encard_mono hst
theorem ncard_mono [Finite Ξ±] : @Monotone (Set Ξ±) _ _ _ ncard := fun _ _ β¦ ncard_le_ncard
@[simp] theorem ncard_eq_zero (hs : s.Finite := by toFinite_tac) :
s.ncard = 0 β s = β
:= by
rw [β Nat.cast_inj (R := ββ), hs.cast_ncard_eq, Nat.cast_zero, encard_eq_zero]
@[simp, norm_cast] theorem ncard_coe_Finset (s : Finset Ξ±) : (s : Set Ξ±).ncard = s.card := by
rw [ncard_eq_toFinset_card _, Finset.finite_toSet_toFinset]
theorem ncard_univ (Ξ± : Type*) : (univ : Set Ξ±).ncard = Nat.card Ξ± := by
rcases finite_or_infinite Ξ± with h | h
Β· have hft := Fintype.ofFinite Ξ±
rw [ncard_eq_toFinset_card, Finite.toFinset_univ, Finset.card_univ, Nat.card_eq_fintype_card]
rw [Nat.card_eq_zero_of_infinite, Infinite.ncard]
exact infinite_univ
@[simp] theorem ncard_empty (Ξ± : Type*) : (β
: Set Ξ±).ncard = 0 := by
rw [ncard_eq_zero]
theorem ncard_pos (hs : s.Finite := by toFinite_tac) : 0 < s.ncard β s.Nonempty := by
rw [pos_iff_ne_zero, Ne, ncard_eq_zero hs, nonempty_iff_ne_empty]
protected alias β¨_, Nonempty.ncard_posβ© := ncard_pos
theorem ncard_ne_zero_of_mem {a : Ξ±} (h : a β s) (hs : s.Finite := by toFinite_tac) : s.ncard β 0 :=
((ncard_pos hs).mpr β¨a, hβ©).ne.symm
theorem finite_of_ncard_ne_zero (hs : s.ncard β 0) : s.Finite :=
s.finite_or_infinite.elim id fun h β¦ (hs h.ncard).elim
theorem finite_of_ncard_pos (hs : 0 < s.ncard) : s.Finite :=
finite_of_ncard_ne_zero hs.ne.symm
theorem nonempty_of_ncard_ne_zero (hs : s.ncard β 0) : s.Nonempty := by
rw [nonempty_iff_ne_empty]; rintro rfl; simp at hs
@[simp] theorem ncard_singleton (a : Ξ±) : ({a} : Set Ξ±).ncard = 1 := by
simp [ncard]
| Mathlib/Data/Set/Card.lean | 580 | 584 | theorem ncard_singleton_inter (a : Ξ±) (s : Set Ξ±) : ({a} β© s).ncard β€ 1 := by | rw [β Nat.cast_le (Ξ± := ββ), (toFinite _).cast_ncard_eq, Nat.cast_one]
apply encard_singleton_inter
@[simp] |
/-
Copyright (c) 2017 Mario Carneiro. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mario Carneiro, Floris van Doorn, Violeta HernΓ‘ndez Palacios
-/
import Mathlib.SetTheory.Ordinal.Family
/-! # Ordinal exponential
In this file we define the power function and the logarithm function on ordinals. The two are
related by the lemma `Ordinal.opow_le_iff_le_log : b ^ c β€ x β c β€ log b x` for nontrivial inputs
`b`, `c`.
-/
noncomputable section
open Function Set Equiv Order
open scoped Cardinal Ordinal
universe u v w
namespace Ordinal
/-- The ordinal exponential, defined by transfinite recursion.
We call this `opow` in theorems in order to disambiguate from other exponentials. -/
instance instPow : Pow Ordinal Ordinal :=
β¨fun a b β¦ if a = 0 then 1 - b else
limitRecOn b 1 (fun _ x β¦ x * a) fun o _ f β¦ β¨ x : Iio o, f x.1 x.2β©
private theorem opow_of_ne_zero {a b : Ordinal} (h : a β 0) : a ^ b =
limitRecOn b 1 (fun _ x β¦ x * a) fun o _ f β¦ β¨ x : Iio o, f x.1 x.2 :=
if_neg h
/-- `0 ^ a = 1` if `a = 0` and `0 ^ a = 0` otherwise. -/
theorem zero_opow' (a : Ordinal) : 0 ^ a = 1 - a :=
if_pos rfl
theorem zero_opow_le (a : Ordinal) : (0 : Ordinal) ^ a β€ 1 := by
rw [zero_opow']
exact sub_le_self 1 a
@[simp]
theorem zero_opow {a : Ordinal} (a0 : a β 0) : (0 : Ordinal) ^ a = 0 := by
rwa [zero_opow', Ordinal.sub_eq_zero_iff_le, one_le_iff_ne_zero]
@[simp]
theorem opow_zero (a : Ordinal) : a ^ (0 : Ordinal) = 1 := by
obtain rfl | h := eq_or_ne a 0
Β· rw [zero_opow', Ordinal.sub_zero]
Β· rw [opow_of_ne_zero h, limitRecOn_zero]
@[simp]
theorem opow_succ (a b : Ordinal) : a ^ succ b = a ^ b * a := by
obtain rfl | h := eq_or_ne a 0
Β· rw [zero_opow (succ_ne_zero b), mul_zero]
Β· rw [opow_of_ne_zero h, opow_of_ne_zero h, limitRecOn_succ]
theorem opow_limit {a b : Ordinal} (ha : a β 0) (hb : IsLimit b) :
a ^ b = β¨ x : Iio b, a ^ x.1 := by
simp_rw [opow_of_ne_zero ha, limitRecOn_limit _ _ _ _ hb]
theorem opow_le_of_limit {a b c : Ordinal} (a0 : a β 0) (h : IsLimit b) :
a ^ b β€ c β β b' < b, a ^ b' β€ c := by
rw [opow_limit a0 h, Ordinal.iSup_le_iff, Subtype.forall]
rfl
theorem lt_opow_of_limit {a b c : Ordinal} (b0 : b β 0) (h : IsLimit c) :
a < b ^ c β β c' < c, a < b ^ c' := by
rw [β not_iff_not, not_exists]
simp only [not_lt, opow_le_of_limit b0 h, exists_prop, not_and]
@[simp]
theorem opow_one (a : Ordinal) : a ^ (1 : Ordinal) = a := by
rw [β succ_zero, opow_succ]
simp only [opow_zero, one_mul]
@[simp]
theorem one_opow (a : Ordinal) : (1 : Ordinal) ^ a = 1 := by
induction a using limitRecOn with
| zero => simp only [opow_zero]
| succ _ ih =>
simp only [opow_succ, ih, mul_one]
| isLimit b l IH =>
refine eq_of_forall_ge_iff fun c => ?_
rw [opow_le_of_limit Ordinal.one_ne_zero l]
exact β¨fun H => by simpa only [opow_zero] using H 0 l.pos, fun H b' h => by rwa [IH _ h]β©
theorem opow_pos {a : Ordinal} (b : Ordinal) (a0 : 0 < a) : 0 < a ^ b := by
have h0 : 0 < a ^ (0 : Ordinal) := by simp only [opow_zero, zero_lt_one]
induction b using limitRecOn with
| zero => exact h0
| succ b IH =>
rw [opow_succ]
exact mul_pos IH a0
| isLimit b l _ =>
exact (lt_opow_of_limit (Ordinal.pos_iff_ne_zero.1 a0) l).2 β¨0, l.pos, h0β©
theorem opow_ne_zero {a : Ordinal} (b : Ordinal) (a0 : a β 0) : a ^ b β 0 :=
Ordinal.pos_iff_ne_zero.1 <| opow_pos b <| Ordinal.pos_iff_ne_zero.2 a0
@[simp]
theorem opow_eq_zero {a b : Ordinal} : a ^ b = 0 β a = 0 β§ b β 0 := by
obtain rfl | ha := eq_or_ne a 0
Β· obtain rfl | hb := eq_or_ne b 0
Β· simp
Β· simp [hb]
Β· simp [opow_ne_zero b ha, ha]
@[simp, norm_cast]
theorem opow_natCast (a : Ordinal) (n : β) : a ^ (n : Ordinal) = a ^ n := by
induction n with
| zero => rw [Nat.cast_zero, opow_zero, pow_zero]
| succ n IH => rw [Nat.cast_succ, add_one_eq_succ, opow_succ, pow_succ, IH]
theorem isNormal_opow {a : Ordinal} (h : 1 < a) : IsNormal (a ^ Β·) :=
have a0 : 0 < a := zero_lt_one.trans h
β¨fun b => by simpa only [mul_one, opow_succ] using (mul_lt_mul_iff_left (opow_pos b a0)).2 h,
fun _ l _ => opow_le_of_limit (ne_of_gt a0) lβ©
theorem opow_lt_opow_iff_right {a b c : Ordinal} (a1 : 1 < a) : a ^ b < a ^ c β b < c :=
(isNormal_opow a1).lt_iff
theorem opow_le_opow_iff_right {a b c : Ordinal} (a1 : 1 < a) : a ^ b β€ a ^ c β b β€ c :=
(isNormal_opow a1).le_iff
theorem opow_right_inj {a b c : Ordinal} (a1 : 1 < a) : a ^ b = a ^ c β b = c :=
(isNormal_opow a1).inj
theorem isLimit_opow {a b : Ordinal} (a1 : 1 < a) : IsLimit b β IsLimit (a ^ b) :=
(isNormal_opow a1).isLimit
theorem isLimit_opow_left {a b : Ordinal} (l : IsLimit a) (hb : b β 0) : IsLimit (a ^ b) := by
rcases zero_or_succ_or_limit b with (e | β¨b, rflβ© | l')
Β· exact absurd e hb
Β· rw [opow_succ]
exact isLimit_mul (opow_pos _ l.pos) l
Β· exact isLimit_opow l.one_lt l'
theorem opow_le_opow_right {a b c : Ordinal} (hβ : 0 < a) (hβ : b β€ c) : a ^ b β€ a ^ c := by
rcases lt_or_eq_of_le (one_le_iff_pos.2 hβ) with hβ | hβ
Β· exact (opow_le_opow_iff_right hβ).2 hβ
Β· subst a
-- Porting note: `le_refl` is required.
simp only [one_opow, le_refl]
theorem opow_le_opow_left {a b : Ordinal} (c : Ordinal) (ab : a β€ b) : a ^ c β€ b ^ c := by
by_cases a0 : a = 0
-- Porting note: `le_refl` is required.
Β· subst a
by_cases c0 : c = 0
Β· subst c
simp only [opow_zero, le_refl]
Β· simp only [zero_opow c0, Ordinal.zero_le]
Β· induction c using limitRecOn with
| zero => simp only [opow_zero, le_refl]
| succ c IH =>
simpa only [opow_succ] using mul_le_mul' IH ab
| isLimit c l IH =>
exact
(opow_le_of_limit a0 l).2 fun b' h =>
(IH _ h).trans (opow_le_opow_right ((Ordinal.pos_iff_ne_zero.2 a0).trans_le ab) h.le)
theorem opow_le_opow {a b c d : Ordinal} (hac : a β€ c) (hbd : b β€ d) (hc : 0 < c) : a ^ b β€ c ^ d :=
(opow_le_opow_left b hac).trans (opow_le_opow_right hc hbd)
theorem left_le_opow (a : Ordinal) {b : Ordinal} (b1 : 0 < b) : a β€ a ^ b := by
nth_rw 1 [β opow_one a]
rcases le_or_gt a 1 with a1 | a1
Β· rcases lt_or_eq_of_le a1 with a0 | a1
Β· rw [lt_one_iff_zero] at a0
rw [a0, zero_opow Ordinal.one_ne_zero]
exact Ordinal.zero_le _
rw [a1, one_opow, one_opow]
rwa [opow_le_opow_iff_right a1, one_le_iff_pos]
theorem left_lt_opow {a b : Ordinal} (ha : 1 < a) (hb : 1 < b) : a < a ^ b := by
conv_lhs => rw [β opow_one a]
rwa [opow_lt_opow_iff_right ha]
theorem right_le_opow {a : Ordinal} (b : Ordinal) (a1 : 1 < a) : b β€ a ^ b :=
(isNormal_opow a1).le_apply
theorem opow_lt_opow_left_of_succ {a b c : Ordinal} (ab : a < b) : a ^ succ c < b ^ succ c := by
rw [opow_succ, opow_succ]
exact
(mul_le_mul_right' (opow_le_opow_left c ab.le) a).trans_lt
(mul_lt_mul_of_pos_left ab (opow_pos c ((Ordinal.zero_le a).trans_lt ab)))
theorem opow_add (a b c : Ordinal) : a ^ (b + c) = a ^ b * a ^ c := by
rcases eq_or_ne a 0 with (rfl | a0)
Β· rcases eq_or_ne c 0 with (rfl | c0)
Β· simp
have : b + c β 0 := ((Ordinal.pos_iff_ne_zero.2 c0).trans_le (le_add_left _ _)).ne'
simp only [zero_opow c0, zero_opow this, mul_zero]
rcases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with (rfl | a1)
Β· simp only [one_opow, mul_one]
induction c using limitRecOn with
| zero => simp
| succ c IH =>
rw [add_succ, opow_succ, IH, opow_succ, mul_assoc]
| isLimit c l IH =>
refine
eq_of_forall_ge_iff fun d =>
(((isNormal_opow a1).trans (isNormal_add_right b)).limit_le l).trans ?_
dsimp only [Function.comp_def]
simp +contextual only [IH]
exact
(((isNormal_mul_right <| opow_pos b (Ordinal.pos_iff_ne_zero.2 a0)).trans
(isNormal_opow a1)).limit_le
l).symm
theorem opow_one_add (a b : Ordinal) : a ^ (1 + b) = a * a ^ b := by rw [opow_add, opow_one]
theorem opow_dvd_opow (a : Ordinal) {b c : Ordinal} (h : b β€ c) : a ^ b β£ a ^ c :=
β¨a ^ (c - b), by rw [β opow_add, Ordinal.add_sub_cancel_of_le h]β©
theorem opow_dvd_opow_iff {a b c : Ordinal} (a1 : 1 < a) : a ^ b β£ a ^ c β b β€ c :=
β¨fun h =>
le_of_not_lt fun hn =>
not_le_of_lt ((opow_lt_opow_iff_right a1).2 hn) <|
le_of_dvd (opow_ne_zero _ <| one_le_iff_ne_zero.1 <| a1.le) h,
opow_dvd_opow _β©
theorem opow_mul (a b c : Ordinal) : a ^ (b * c) = (a ^ b) ^ c := by
by_cases b0 : b = 0; Β· simp only [b0, zero_mul, opow_zero, one_opow]
by_cases a0 : a = 0
Β· subst a
by_cases c0 : c = 0
Β· simp only [c0, mul_zero, opow_zero]
simp only [zero_opow b0, zero_opow c0, zero_opow (mul_ne_zero b0 c0)]
rcases eq_or_lt_of_le (one_le_iff_ne_zero.2 a0) with a1 | a1
Β· subst a1
simp only [one_opow]
induction c using limitRecOn with
| zero => simp only [mul_zero, opow_zero]
| succ c IH =>
rw [mul_succ, opow_add, IH, opow_succ]
| isLimit c l IH =>
refine
eq_of_forall_ge_iff fun d =>
(((isNormal_opow a1).trans (isNormal_mul_right (Ordinal.pos_iff_ne_zero.2 b0))).limit_le
l).trans
?_
dsimp only [Function.comp_def]
simp +contextual only [IH]
exact (opow_le_of_limit (opow_ne_zero _ a0) l).symm
theorem opow_mul_add_pos {b v : Ordinal} (hb : b β 0) (u : Ordinal) (hv : v β 0) (w : Ordinal) :
0 < b ^ u * v + w :=
(opow_pos u <| Ordinal.pos_iff_ne_zero.2 hb).trans_le <|
(le_mul_left _ <| Ordinal.pos_iff_ne_zero.2 hv).trans <| le_add_right _ _
theorem opow_mul_add_lt_opow_mul_succ {b u w : Ordinal} (v : Ordinal) (hw : w < b ^ u) :
b ^ u * v + w < b ^ u * succ v := by
rwa [mul_succ, add_lt_add_iff_left]
theorem opow_mul_add_lt_opow_succ {b u v w : Ordinal} (hvb : v < b) (hw : w < b ^ u) :
b ^ u * v + w < b ^ succ u := by
convert (opow_mul_add_lt_opow_mul_succ v hw).trans_le
(mul_le_mul_left' (succ_le_of_lt hvb) _) using 1
exact opow_succ b u
/-! ### Ordinal logarithm -/
/-- The ordinal logarithm is the solution `u` to the equation `x = b ^ u * v + w` where `v < b` and
`w < b ^ u`. -/
@[pp_nodot]
def log (b : Ordinal) (x : Ordinal) : Ordinal :=
if 1 < b then pred (sInf { o | x < b ^ o }) else 0
/-- The set in the definition of `log` is nonempty. -/
private theorem log_nonempty {b x : Ordinal} (h : 1 < b) : { o : Ordinal | x < b ^ o }.Nonempty :=
β¨_, succ_le_iff.1 (right_le_opow _ h)β©
theorem log_def {b : Ordinal} (h : 1 < b) (x : Ordinal) : log b x = pred (sInf { o | x < b ^ o }) :=
if_pos h
theorem log_of_left_le_one {b : Ordinal} (h : b β€ 1) (x : Ordinal) : log b x = 0 :=
if_neg h.not_lt
@[simp]
| Mathlib/SetTheory/Ordinal/Exponential.lean | 284 | 291 | theorem log_zero_left : β b, log 0 b = 0 :=
log_of_left_le_one zero_le_one
@[simp]
theorem log_zero_right (b : Ordinal) : log b 0 = 0 := by | obtain hb | hb := lt_or_le 1 b
Β· rw [log_def hb, β Ordinal.le_zero, pred_le, succ_zero]
apply csInf_le' |
/-
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, Anne Baanen
-/
import Mathlib.Algebra.BigOperators.Finsupp.Basic
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.GroupWithZero.Associated
/-!
# Products of associated, prime, and irreducible elements.
This file contains some theorems relating definitions in `Algebra.Associated`
and products of multisets, finsets, and finsupps.
-/
assert_not_exists Field
variable {Ξ± Ξ² Ξ³ Ξ΄ : Type*}
-- the same local notation used in `Algebra.Associated`
local infixl:50 " ~α΅€ " => Associated
namespace Prime
variable [CommMonoidWithZero Ξ±] {p : Ξ±}
theorem exists_mem_multiset_dvd (hp : Prime p) {s : Multiset Ξ±} : p β£ s.prod β β a β s, p β£ a :=
Multiset.induction_on s (fun h => (hp.not_dvd_one h).elim) fun a s ih h =>
have : p β£ a * s.prod := by simpa using h
match hp.dvd_or_dvd this with
| Or.inl h => β¨a, Multiset.mem_cons_self a s, hβ©
| Or.inr h =>
let β¨a, has, hβ© := ih h
β¨a, Multiset.mem_cons_of_mem has, hβ©
theorem exists_mem_multiset_map_dvd (hp : Prime p) {s : Multiset Ξ²} {f : Ξ² β Ξ±} :
p β£ (s.map f).prod β β a β s, p β£ f a := fun h => by
simpa only [exists_prop, Multiset.mem_map, exists_exists_and_eq_and] using
hp.exists_mem_multiset_dvd h
theorem exists_mem_finset_dvd (hp : Prime p) {s : Finset Ξ²} {f : Ξ² β Ξ±} :
p β£ s.prod f β β i β s, p β£ f i :=
hp.exists_mem_multiset_map_dvd
end Prime
theorem Prod.associated_iff {M N : Type*} [Monoid M] [Monoid N] {x z : M Γ N} :
x ~α΅€ z β x.1 ~α΅€ z.1 β§ x.2 ~α΅€ z.2 :=
β¨fun β¨u, huβ© => β¨β¨(MulEquiv.prodUnits.toFun u).1, (Prod.eq_iff_fst_eq_snd_eq.1 hu).1β©,
β¨(MulEquiv.prodUnits.toFun u).2, (Prod.eq_iff_fst_eq_snd_eq.1 hu).2β©β©,
fun β¨β¨uβ, hββ©, β¨uβ, hββ©β© =>
β¨MulEquiv.prodUnits.invFun (uβ, uβ), Prod.eq_iff_fst_eq_snd_eq.2 β¨hβ, hββ©β©β©
theorem Associated.prod {M : Type*} [CommMonoid M] {ΞΉ : Type*} (s : Finset ΞΉ) (f : ΞΉ β M)
(g : ΞΉ β M) (h : β i, i β s β (f i) ~α΅€ (g i)) : (β i β s, f i) ~α΅€ (β i β s, g i) := by
induction s using Finset.induction with
| empty =>
simp only [Finset.prod_empty]
rfl
| insert j s hjs IH =>
classical
convert_to (β i β insert j s, f i) ~α΅€ (β i β insert j s, g i)
rw [Finset.prod_insert hjs, Finset.prod_insert hjs]
exact Associated.mul_mul (h j (Finset.mem_insert_self j s))
(IH (fun i hi β¦ h i (Finset.mem_insert_of_mem hi)))
theorem exists_associated_mem_of_dvd_prod [CancelCommMonoidWithZero Ξ±] {p : Ξ±} (hp : Prime p)
{s : Multiset Ξ±} : (β r β s, Prime r) β p β£ s.prod β β q β s, p ~α΅€ q :=
Multiset.induction_on s (by simp [mt isUnit_iff_dvd_one.2 hp.not_unit]) fun a s ih hs hps => by
rw [Multiset.prod_cons] at hps
rcases hp.dvd_or_dvd hps with h | h
Β· have hap := hs a (Multiset.mem_cons.2 (Or.inl rfl))
exact β¨a, Multiset.mem_cons_self a _, hp.associated_of_dvd hap hβ©
Β· rcases ih (fun r hr => hs _ (Multiset.mem_cons.2 (Or.inr hr))) h with β¨q, hqβ, hqββ©
exact β¨q, Multiset.mem_cons.2 (Or.inr hqβ), hqββ©
open Submonoid in
/-- Let x, y β Ξ±. If x * y can be written as a product of units and prime elements, then x can be
written as a product of units and prime elements. -/
| Mathlib/Algebra/BigOperators/Associated.lean | 82 | 100 | theorem divisor_closure_eq_closure [CancelCommMonoidWithZero Ξ±]
(x y : Ξ±) (hxy : x * y β closure { r : Ξ± | IsUnit r β¨ Prime r}) :
x β closure { r : Ξ± | IsUnit r β¨ Prime r} := by | obtain β¨m, hm, hprodβ© := exists_multiset_of_mem_closure hxy
induction m using Multiset.induction generalizing x y with
| empty =>
apply subset_closure
simp only [Set.mem_setOf]
simp only [Multiset.prod_zero] at hprod
left; exact isUnit_of_mul_eq_one _ _ hprod.symm
| cons c s hind =>
simp only [Multiset.mem_cons, forall_eq_or_imp, Set.mem_setOf] at hm
simp only [Multiset.prod_cons] at hprod
simp only [Set.mem_setOf_eq] at hind
obtain β¨haβ | haβ, hsβ© := hm
Β· rcases haβ.exists_right_inv with β¨k, hkβ©
refine hind x (y*k) ?_ hs ?_
Β· simp only [β mul_assoc, β hprod, β Multiset.prod_cons, mul_comm]
refine multiset_prod_mem _ _ (Multiset.forall_mem_cons.2 β¨subset_closure (Set.mem_def.2 ?_), |
/-
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, Kim Morrison, Jens Wagemaker
-/
import Mathlib.Algebra.Field.IsField
import Mathlib.Algebra.Polynomial.Inductions
import Mathlib.Algebra.Polynomial.Monic
import Mathlib.Algebra.Ring.Regular
import Mathlib.RingTheory.Multiplicity
import Mathlib.Data.Nat.Lattice
/-!
# Division of univariate polynomials
The main defs are `divByMonic` and `modByMonic`.
The compatibility between these is given by `modByMonic_add_div`.
We also define `rootMultiplicity`.
-/
noncomputable section
open Polynomial
open Finset
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {A : Type z} {a b : R} {n : β}
section Semiring
variable [Semiring R]
theorem X_dvd_iff {f : R[X]} : X β£ f β f.coeff 0 = 0 :=
β¨fun β¨g, hfgβ© => by rw [hfg, coeff_X_mul_zero], fun hf =>
β¨f.divX, by rw [β add_zero (X * f.divX), β C_0, β hf, X_mul_divX_add]β©β©
theorem X_pow_dvd_iff {f : R[X]} {n : β} : X ^ n β£ f β β d < n, f.coeff d = 0 :=
β¨fun β¨g, hgfβ© d hd => by
simp only [hgf, coeff_X_pow_mul', ite_eq_right_iff, not_le_of_lt hd, IsEmpty.forall_iff],
fun hd => by
induction n with
| zero => simp [pow_zero, one_dvd]
| succ n hn =>
obtain β¨g, hgfβ© := hn fun d : β => fun H : d < n => hd _ (Nat.lt_succ_of_lt H)
have := coeff_X_pow_mul g n 0
rw [zero_add, β hgf, hd n (Nat.lt_succ_self n)] at this
obtain β¨k, hgkβ© := Polynomial.X_dvd_iff.mpr this.symm
use k
rwa [pow_succ, mul_assoc, β hgk]β©
variable {p q : R[X]}
theorem finiteMultiplicity_of_degree_pos_of_monic (hp : (0 : WithBot β) < degree p) (hmp : Monic p)
(hq : q β 0) : FiniteMultiplicity p q :=
have zn0 : (0 : R) β 1 :=
haveI := Nontrivial.of_polynomial_ne hq
zero_ne_one
β¨natDegree q, fun β¨r, hrβ© => by
have hp0 : p β 0 := fun hp0 => by simp [hp0] at hp
have hr0 : r β 0 := fun hr0 => by subst hr0; simp [hq] at hr
have hpn1 : leadingCoeff p ^ (natDegree q + 1) = 1 := by simp [show _ = _ from hmp]
have hpn0' : leadingCoeff p ^ (natDegree q + 1) β 0 := hpn1.symm βΈ zn0.symm
have hpnr0 : leadingCoeff (p ^ (natDegree q + 1)) * leadingCoeff r β 0 := by
simp only [leadingCoeff_pow' hpn0', leadingCoeff_eq_zero, hpn1, one_pow, one_mul, Ne,
hr0, not_false_eq_true]
have hnp : 0 < natDegree p := Nat.cast_lt.1 <| by
rw [β degree_eq_natDegree hp0]; exact hp
have := congr_arg natDegree hr
rw [natDegree_mul' hpnr0, natDegree_pow' hpn0', add_mul, add_assoc] at this
exact
ne_of_lt
(lt_add_of_le_of_pos (le_mul_of_one_le_right (Nat.zero_le _) hnp)
(add_pos_of_pos_of_nonneg (by rwa [one_mul]) (Nat.zero_le _)))
thisβ©
@[deprecated (since := "2024-11-30")]
alias multiplicity_finite_of_degree_pos_of_monic := finiteMultiplicity_of_degree_pos_of_monic
end Semiring
section Ring
variable [Ring R] {p q : R[X]}
theorem div_wf_lemma (h : degree q β€ degree p β§ p β 0) (hq : Monic q) :
degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p :=
have hp : leadingCoeff p β 0 := mt leadingCoeff_eq_zero.1 h.2
have hq0 : q β 0 := hq.ne_zero_of_polynomial_ne h.2
have hlt : natDegree q β€ natDegree p :=
(Nat.cast_le (Ξ± := WithBot β)).1
(by rw [β degree_eq_natDegree h.2, β degree_eq_natDegree hq0]; exact h.1)
degree_sub_lt
(by
rw [hq.degree_mul_comm, hq.degree_mul, degree_C_mul_X_pow _ hp, degree_eq_natDegree h.2,
degree_eq_natDegree hq0, β Nat.cast_add, tsub_add_cancel_of_le hlt])
h.2 (by rw [leadingCoeff_monic_mul hq, leadingCoeff_mul_X_pow, leadingCoeff_C])
/-- See `divByMonic`. -/
noncomputable def divModByMonicAux : β (_p : R[X]) {q : R[X]}, Monic q β R[X] Γ R[X]
| p, q, hq =>
letI := Classical.decEq R
if h : degree q β€ degree p β§ p β 0 then
let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q)
have _wf := div_wf_lemma h hq
let dm := divModByMonicAux (p - q * z) hq
β¨z + dm.1, dm.2β©
else β¨0, pβ©
termination_by p => p
/-- `divByMonic`, denoted as `p /β q`, gives the quotient of `p` by a monic polynomial `q`. -/
def divByMonic (p q : R[X]) : R[X] :=
letI := Classical.decEq R
if hq : Monic q then (divModByMonicAux p hq).1 else 0
/-- `modByMonic`, denoted as `p %β q`, gives the remainder of `p` by a monic polynomial `q`. -/
def modByMonic (p q : R[X]) : R[X] :=
letI := Classical.decEq R
if hq : Monic q then (divModByMonicAux p hq).2 else p
@[inherit_doc]
infixl:70 " /β " => divByMonic
@[inherit_doc]
infixl:70 " %β " => modByMonic
theorem degree_modByMonic_lt [Nontrivial R] :
β (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %β q) < degree q
| p, q, hq =>
letI := Classical.decEq R
if h : degree q β€ degree p β§ p β 0 then by
have _wf := div_wf_lemma β¨h.1, h.2β© hq
have :=
degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
unfold modByMonic at this β’
unfold divModByMonicAux
dsimp
rw [dif_pos hq] at this β’
rw [if_pos h]
exact this
else
Or.casesOn (not_and_or.1 h)
(by
unfold modByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_neg h]
exact lt_of_not_ge)
(by
intro hp
unfold modByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_neg h, Classical.not_not.1 hp]
exact lt_of_le_of_ne bot_le (Ne.symm (mt degree_eq_bot.1 hq.ne_zero)))
termination_by p => p
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q β 1) :
natDegree (p %β q) < q.natDegree := by
by_cases hpq : p %β q = 0
Β· rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
contrapose! hq
exact eq_one_of_monic_natDegree_zero hmq hq
Β· haveI := Nontrivial.of_polynomial_ne hpq
exact natDegree_lt_natDegree hpq (degree_modByMonic_lt p hmq)
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %β p = 0 := by
classical
unfold modByMonic divModByMonicAux
dsimp
by_cases hp : Monic p
Β· rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl)), Prod.snd_zero]
Β· rw [dif_neg hp]
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /β p = 0 := by
classical
unfold divByMonic divModByMonicAux
dsimp
by_cases hp : Monic p
Β· rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl)), Prod.fst_zero]
Β· rw [dif_neg hp]
@[simp]
theorem modByMonic_zero (p : R[X]) : p %β 0 = p :=
letI := Classical.decEq R
if h : Monic (0 : R[X]) then by
haveI := monic_zero_iff_subsingleton.mp h
simp [eq_iff_true_of_subsingleton]
else by unfold modByMonic divModByMonicAux; rw [dif_neg h]
@[simp]
theorem divByMonic_zero (p : R[X]) : p /β 0 = 0 :=
letI := Classical.decEq R
if h : Monic (0 : R[X]) then by
haveI := monic_zero_iff_subsingleton.mp h
simp [eq_iff_true_of_subsingleton]
else by unfold divByMonic divModByMonicAux; rw [dif_neg h]
theorem divByMonic_eq_of_not_monic (p : R[X]) (hq : Β¬Monic q) : p /β q = 0 :=
dif_neg hq
theorem modByMonic_eq_of_not_monic (p : R[X]) (hq : Β¬Monic q) : p %β q = p :=
dif_neg hq
theorem modByMonic_eq_self_iff [Nontrivial R] (hq : Monic q) : p %β q = p β degree p < degree q :=
β¨fun h => h βΈ degree_modByMonic_lt _ hq, fun h => by
classical
have : Β¬degree q β€ degree p := not_le_of_gt h
unfold modByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]β©
theorem degree_modByMonic_le (p : R[X]) {q : R[X]} (hq : Monic q) : degree (p %β q) β€ degree q := by
nontriviality R
exact (degree_modByMonic_lt _ hq).le
theorem degree_modByMonic_le_left : degree (p %β q) β€ degree p := by
nontriviality R
by_cases hq : q.Monic
Β· cases lt_or_ge (degree p) (degree q)
Β· rw [(modByMonic_eq_self_iff hq).mpr βΉ_βΊ]
Β· exact (degree_modByMonic_le p hq).trans βΉ_βΊ
Β· rw [modByMonic_eq_of_not_monic p hq]
theorem natDegree_modByMonic_le (p : Polynomial R) {g : Polynomial R} (hg : g.Monic) :
natDegree (p %β g) β€ g.natDegree :=
natDegree_le_natDegree (degree_modByMonic_le p hg)
theorem natDegree_modByMonic_le_left : natDegree (p %β q) β€ natDegree p :=
natDegree_le_natDegree degree_modByMonic_le_left
theorem X_dvd_sub_C : X β£ p - C (p.coeff 0) := by
simp [X_dvd_iff, coeff_C]
theorem modByMonic_eq_sub_mul_div :
β (p : R[X]) {q : R[X]} (_hq : Monic q), p %β q = p - q * (p /β q)
| p, q, hq =>
letI := Classical.decEq R
if h : degree q β€ degree p β§ p β 0 then by
have _wf := div_wf_lemma h hq
have ih := modByMonic_eq_sub_mul_div
(p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
unfold modByMonic divByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_pos h]
rw [modByMonic, dif_pos hq] at ih
refine ih.trans ?_
unfold divByMonic
rw [dif_pos hq, dif_pos hq, if_pos h, mul_add, sub_add_eq_sub_sub]
else by
unfold modByMonic divByMonic divModByMonicAux
dsimp
rw [dif_pos hq, if_neg h, dif_pos hq, if_neg h, mul_zero, sub_zero]
termination_by p => p
theorem modByMonic_add_div (p : R[X]) {q : R[X]} (hq : Monic q) : p %β q + q * (p /β q) = p :=
eq_sub_iff_add_eq.1 (modByMonic_eq_sub_mul_div p hq)
theorem divByMonic_eq_zero_iff [Nontrivial R] (hq : Monic q) : p /β q = 0 β degree p < degree q :=
β¨fun h => by
have := modByMonic_add_div p hq
rwa [h, mul_zero, add_zero, modByMonic_eq_self_iff hq] at this,
fun h => by
classical
have : Β¬degree q β€ degree p := not_le_of_gt h
unfold divByMonic divModByMonicAux; dsimp; rw [dif_pos hq, if_neg (mt And.left this)]β©
theorem degree_add_divByMonic (hq : Monic q) (h : degree q β€ degree p) :
degree q + degree (p /β q) = degree p := by
nontriviality R
have hdiv0 : p /β q β 0 := by rwa [Ne, divByMonic_eq_zero_iff hq, not_lt]
have hlc : leadingCoeff q * leadingCoeff (p /β q) β 0 := by
rwa [Monic.def.1 hq, one_mul, Ne, leadingCoeff_eq_zero]
have hmod : degree (p %β q) < degree (q * (p /β q)) :=
calc
degree (p %β q) < degree q := degree_modByMonic_lt _ hq
_ β€ _ := by
rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero, degree_eq_natDegree hdiv0, β
Nat.cast_add, Nat.cast_le]
exact Nat.le_add_right _ _
calc
degree q + degree (p /β q) = degree (q * (p /β q)) := Eq.symm (degree_mul' hlc)
_ = degree (p %β q + q * (p /β q)) := (degree_add_eq_right_of_degree_lt hmod).symm
_ = _ := congr_arg _ (modByMonic_add_div _ hq)
theorem degree_divByMonic_le (p q : R[X]) : degree (p /β q) β€ degree p :=
letI := Classical.decEq R
if hp0 : p = 0 then by simp only [hp0, zero_divByMonic, le_refl]
else
if hq : Monic q then
if h : degree q β€ degree p then by
haveI := Nontrivial.of_polynomial_ne hp0
rw [β degree_add_divByMonic hq h, degree_eq_natDegree hq.ne_zero,
degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 (not_lt.2 h))]
exact WithBot.coe_le_coe.2 (Nat.le_add_left _ _)
else by
unfold divByMonic divModByMonicAux
simp [dif_pos hq, h, if_false, degree_zero, bot_le]
else (divByMonic_eq_of_not_monic p hq).symm βΈ bot_le
theorem degree_divByMonic_lt (p : R[X]) {q : R[X]} (hq : Monic q) (hp0 : p β 0)
(h0q : 0 < degree q) : degree (p /β q) < degree p :=
if hpq : degree p < degree q then by
haveI := Nontrivial.of_polynomial_ne hp0
rw [(divByMonic_eq_zero_iff hq).2 hpq, degree_eq_natDegree hp0]
exact WithBot.bot_lt_coe _
else by
haveI := Nontrivial.of_polynomial_ne hp0
rw [β degree_add_divByMonic hq (not_lt.1 hpq), degree_eq_natDegree hq.ne_zero,
degree_eq_natDegree (mt (divByMonic_eq_zero_iff hq).1 hpq)]
exact
Nat.cast_lt.2
(Nat.lt_add_of_pos_left (Nat.cast_lt.1 <|
by simpa [degree_eq_natDegree hq.ne_zero] using h0q))
theorem natDegree_divByMonic (f : R[X]) {g : R[X]} (hg : g.Monic) :
natDegree (f /β g) = natDegree f - natDegree g := by
nontriviality R
by_cases hfg : f /β g = 0
Β· rw [hfg, natDegree_zero]
rw [divByMonic_eq_zero_iff hg] at hfg
rw [tsub_eq_zero_iff_le.mpr (natDegree_le_natDegree <| le_of_lt hfg)]
have hgf := hfg
rw [divByMonic_eq_zero_iff hg] at hgf
push_neg at hgf
have := degree_add_divByMonic hg hgf
have hf : f β 0 := by
intro hf
apply hfg
rw [hf, zero_divByMonic]
rw [degree_eq_natDegree hf, degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hfg,
β Nat.cast_add, Nat.cast_inj] at this
rw [β this, add_tsub_cancel_left]
theorem div_modByMonic_unique {f g} (q r : R[X]) (hg : Monic g)
(h : r + g * q = f β§ degree r < degree g) : f /β g = q β§ f %β g = r := by
nontriviality R
have hβ : r - f %β g = -g * (q - f /β g) :=
eq_of_sub_eq_zero
(by
rw [β sub_eq_zero_of_eq (h.1.trans (modByMonic_add_div f hg).symm)]
simp [mul_add, mul_comm, sub_eq_add_neg, add_comm, add_left_comm, add_assoc])
have hβ : degree (r - f %β g) = degree (g * (q - f /β g)) := by simp [hβ]
have hβ : degree (r - f %β g) < degree g :=
calc
degree (r - f %β g) β€ max (degree r) (degree (f %β g)) := degree_sub_le _ _
_ < degree g := max_lt_iff.2 β¨h.2, degree_modByMonic_lt _ hgβ©
have hβ
: q - f /β g = 0 :=
_root_.by_contradiction fun hqf =>
not_le_of_gt hβ <|
calc
degree g β€ degree g + degree (q - f /β g) := by
rw [degree_eq_natDegree hg.ne_zero, degree_eq_natDegree hqf]
norm_cast
exact Nat.le_add_right _ _
_ = degree (r - f %β g) := by rw [hβ, degree_mul']; simpa [Monic.def.1 hg]
exact β¨Eq.symm <| eq_of_sub_eq_zero hβ
, Eq.symm <| eq_of_sub_eq_zero <| by simpa [hβ
] using hββ©
theorem map_mod_divByMonic [Ring S] (f : R β+* S) (hq : Monic q) :
(p /β q).map f = p.map f /β q.map f β§ (p %β q).map f = p.map f %β q.map f := by
nontriviality S
haveI : Nontrivial R := f.domain_nontrivial
have : map f p /β map f q = map f (p /β q) β§ map f p %β map f q = map f (p %β q) :=
div_modByMonic_unique ((p /β q).map f) _ (hq.map f)
β¨Eq.symm <| by rw [β Polynomial.map_mul, β Polynomial.map_add, modByMonic_add_div _ hq],
calc
_ β€ degree (p %β q) := degree_map_le
_ < degree q := degree_modByMonic_lt _ hq
_ = _ :=
Eq.symm <|
degree_map_eq_of_leadingCoeff_ne_zero _
(by rw [Monic.def.1 hq, f.map_one]; exact one_ne_zero)β©
exact β¨this.1.symm, this.2.symmβ©
theorem map_divByMonic [Ring S] (f : R β+* S) (hq : Monic q) :
(p /β q).map f = p.map f /β q.map f :=
(map_mod_divByMonic f hq).1
theorem map_modByMonic [Ring S] (f : R β+* S) (hq : Monic q) :
(p %β q).map f = p.map f %β q.map f :=
(map_mod_divByMonic f hq).2
theorem modByMonic_eq_zero_iff_dvd (hq : Monic q) : p %β q = 0 β q β£ p :=
β¨fun h => by rw [β modByMonic_add_div p hq, h, zero_add]; exact dvd_mul_right _ _, fun h => by
nontriviality R
obtain β¨r, hrβ© := exists_eq_mul_right_of_dvd h
by_contra hpq0
have hmod : p %β q = q * (r - p /β q) := by rw [modByMonic_eq_sub_mul_div _ hq, mul_sub, β hr]
have : degree (q * (r - p /β q)) < degree q := hmod βΈ degree_modByMonic_lt _ hq
have hrpq0 : leadingCoeff (r - p /β q) β 0 := fun h =>
hpq0 <|
leadingCoeff_eq_zero.1
(by rw [hmod, leadingCoeff_eq_zero.1 h, mul_zero, leadingCoeff_zero])
have hlc : leadingCoeff q * leadingCoeff (r - p /β q) β 0 := by rwa [Monic.def.1 hq, one_mul]
rw [degree_mul' hlc, degree_eq_natDegree hq.ne_zero,
degree_eq_natDegree (mt leadingCoeff_eq_zero.2 hrpq0)] at this
exact not_lt_of_ge (Nat.le_add_right _ _) (WithBot.coe_lt_coe.1 this)β©
/-- See `Polynomial.mul_self_modByMonic` for the other multiplication order. That version, unlike
this one, requires commutativity. -/
@[simp]
lemma self_mul_modByMonic (hq : q.Monic) : (q * p) %β q = 0 := by
rw [modByMonic_eq_zero_iff_dvd hq]
exact dvd_mul_right q p
theorem map_dvd_map [Ring S] (f : R β+* S) (hf : Function.Injective f) {x y : R[X]}
(hx : x.Monic) : x.map f β£ y.map f β x β£ y := by
rw [β modByMonic_eq_zero_iff_dvd hx, β modByMonic_eq_zero_iff_dvd (hx.map f), β
map_modByMonic f hx]
exact
β¨fun H => map_injective f hf <| by rw [H, Polynomial.map_zero], fun H => by
rw [H, Polynomial.map_zero]β©
@[simp]
| Mathlib/Algebra/Polynomial/Div.lean | 417 | 422 | theorem modByMonic_one (p : R[X]) : p %β 1 = 0 :=
(modByMonic_eq_zero_iff_dvd (by convert monic_one (R := R))).2 (one_dvd _)
@[simp]
theorem divByMonic_one (p : R[X]) : p /β 1 = p := by | conv_rhs => rw [β modByMonic_add_div p monic_one]; simp |
/-
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.Algebra.Polynomial.Cardinal
import Mathlib.RingTheory.Algebraic.Basic
/-!
### Cardinality of algebraic numbers
In this file, we prove variants of the following result: the cardinality of algebraic numbers under
an R-algebra is at most `#R[X] * β΅β`.
Although this can be used to prove that real or complex transcendental numbers exist, a more direct
proof is given by `Liouville.transcendental`.
-/
universe u v
open Cardinal Polynomial Set
open Cardinal Polynomial
namespace Algebraic
theorem infinite_of_charZero (R A : Type*) [CommRing R] [Ring A] [Algebra R A]
[CharZero A] : { x : A | IsAlgebraic R x }.Infinite := by
letI := MulActionWithZero.nontrivial R A
exact infinite_of_injective_forall_mem Nat.cast_injective isAlgebraic_nat
theorem aleph0_le_cardinalMk_of_charZero (R A : Type*) [CommRing R] [Ring A]
[Algebra R A] [CharZero A] : β΅β β€ #{ x : A // IsAlgebraic R x } :=
infinite_iff.1 (Set.infinite_coe_iff.2 <| infinite_of_charZero R A)
@[deprecated (since := "2024-11-10")]
alias aleph0_le_cardinal_mk_of_charZero := aleph0_le_cardinalMk_of_charZero
section lift
variable (R : Type u) (A : Type v) [CommRing R] [CommRing A] [IsDomain A] [Algebra R A]
[NoZeroSMulDivisors R A]
| Mathlib/Algebra/AlgebraicCard.lean | 45 | 54 | theorem cardinalMk_lift_le_mul :
Cardinal.lift.{u} #{ x : A // IsAlgebraic R x } β€ Cardinal.lift.{v} #R[X] * β΅β := by | rw [β mk_uLift, β mk_uLift]
choose g hgβ hgβ using fun x : { x : A | IsAlgebraic R x } => x.coe_prop
refine lift_mk_le_lift_mk_mul_of_lift_mk_preimage_le g fun f => ?_
rw [lift_le_aleph0, le_aleph0_iff_set_countable]
suffices MapsTo (β) (g β»ΒΉ' {f}) (f.rootSet A) from
this.countable_of_injOn Subtype.coe_injective.injOn (f.rootSet_finite A).countable
rintro x (rfl : g x = f)
exact mem_rootSet.2 β¨hgβ x, hgβ xβ© |
/-
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.Topology.Order.Basic
/-!
# Set neighborhoods of intervals
In this file we prove basic theorems about `πΛ’ s`,
where `s` is one of the intervals
`Set.Ici`, `Set.Iic`, `Set.Ioi`, `Set.Iio`, `Set.Ico`, `Set.Ioc`, `Set.Ioo`, and `Set.Icc`.
First, we prove lemmas in terms of filter equalities.
Then we prove lemmas about `s β πΛ’ t`, where both `s` and `t` are intervals.
Finally, we prove a few lemmas about filter bases of `πΛ’ (Iic a)` and `πΛ’ (Ici a)`.
-/
open Set Filter OrderDual
open scoped Topology
section OrderClosedTopology
variable {Ξ± : Type*} [LinearOrder Ξ±] [TopologicalSpace Ξ±] [OrderClosedTopology Ξ±] {a b c d : Ξ±}
/-!
# Formulae for `πΛ’` of intervals
-/
@[simp] theorem nhdsSet_Ioi : πΛ’ (Ioi a) = π (Ioi a) := isOpen_Ioi.nhdsSet_eq
@[simp] theorem nhdsSet_Iio : πΛ’ (Iio a) = π (Iio a) := isOpen_Iio.nhdsSet_eq
@[simp] theorem nhdsSet_Ioo : πΛ’ (Ioo a b) = π (Ioo a b) := isOpen_Ioo.nhdsSet_eq
theorem nhdsSet_Ici : πΛ’ (Ici a) = π a β π (Ioi a) := by
rw [β Ioi_insert, nhdsSet_insert, nhdsSet_Ioi]
theorem nhdsSet_Iic : πΛ’ (Iic a) = π a β π (Iio a) := nhdsSet_Ici (Ξ± := Ξ±α΅α΅)
theorem nhdsSet_Ico (h : a < b) : πΛ’ (Ico a b) = π a β π (Ioo a b) := by
rw [β Ioo_insert_left h, nhdsSet_insert, nhdsSet_Ioo]
| Mathlib/Topology/Order/NhdsSet.lean | 44 | 45 | theorem nhdsSet_Ioc (h : a < b) : πΛ’ (Ioc a b) = π b β π (Ioo a b) := by | rw [β Ioo_insert_right h, nhdsSet_insert, nhdsSet_Ioo] |
/-
Copyright (c) 2022 Eric Wieser. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Wieser
-/
import Mathlib.Algebra.Order.Floor.Semiring
import Mathlib.Data.Nat.Log
/-!
# Integer logarithms in a field with respect to a natural base
This file defines two `β€`-valued analogs of the logarithm of `r : R` with base `b : β`:
* `Int.log b r`: Lower logarithm, or floor **log**. Greatest `k` such that `βb^k β€ r`.
* `Int.clog b r`: Upper logarithm, or **c**eil **log**. Least `k` such that `r β€ βb^k`.
Note that `Int.log` gives the position of the left-most non-zero digit:
```lean
#eval (Int.log 10 (0.09 : β), Int.log 10 (0.10 : β), Int.log 10 (0.11 : β))
-- (-2, -1, -1)
#eval (Int.log 10 (9 : β), Int.log 10 (10 : β), Int.log 10 (11 : β))
-- (0, 1, 1)
```
which means it can be used for computing digit expansions
```lean
import Data.Fin.VecNotation
import Mathlib.Data.Rat.Floor
def digits (b : β) (q : β) (n : β) : β :=
βq * ((b : β) ^ (n - Int.log b q))ββ % b
#eval digits 10 (1/7) β ((β) : Fin 8 β β)
-- ![1, 4, 2, 8, 5, 7, 1, 4]
```
## Main results
* For `Int.log`:
* `Int.zpow_log_le_self`, `Int.lt_zpow_succ_log_self`: the bounds formed by `Int.log`,
`(b : R) ^ log b r β€ r < (b : R) ^ (log b r + 1)`.
* `Int.zpow_log_gi`: the galois coinsertion between `zpow` and `Int.log`.
* For `Int.clog`:
* `Int.zpow_pred_clog_lt_self`, `Int.self_le_zpow_clog`: the bounds formed by `Int.clog`,
`(b : R) ^ (clog b r - 1) < r β€ (b : R) ^ clog b r`.
* `Int.clog_zpow_gi`: the galois insertion between `Int.clog` and `zpow`.
* `Int.neg_log_inv_eq_clog`, `Int.neg_clog_inv_eq_log`: the link between the two definitions.
-/
assert_not_exists Finset
variable {R : Type*} [Semifield R] [LinearOrder R] [IsStrictOrderedRing R] [FloorSemiring R]
namespace Int
/-- The greatest power of `b` such that `b ^ log b r β€ r`. -/
def log (b : β) (r : R) : β€ :=
if 1 β€ r then Nat.log b βrββ else -Nat.clog b βrβ»ΒΉββ
omit [IsStrictOrderedRing R] in
theorem log_of_one_le_right (b : β) {r : R} (hr : 1 β€ r) : log b r = Nat.log b βrββ :=
if_pos hr
theorem log_of_right_le_one (b : β) {r : R} (hr : r β€ 1) : log b r = -Nat.clog b βrβ»ΒΉββ := by
obtain rfl | hr := hr.eq_or_lt
Β· rw [log, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right, Nat.clog_one_right,
Int.ofNat_zero, neg_zero]
Β· exact if_neg hr.not_le
@[simp, norm_cast]
theorem log_natCast (b : β) (n : β) : log b (n : R) = Nat.log b n := by
cases n
Β· simp [log_of_right_le_one]
Β· rw [log_of_one_le_right, Nat.floor_natCast]
simp
@[simp]
theorem log_ofNat (b : β) (n : β) [n.AtLeastTwo] :
log b (ofNat(n) : R) = Nat.log b ofNat(n) :=
log_natCast b n
theorem log_of_left_le_one {b : β} (hb : b β€ 1) (r : R) : log b r = 0 := by
rcases le_total 1 r with h | h
Β· rw [log_of_one_le_right _ h, Nat.log_of_left_le_one hb, Int.ofNat_zero]
Β· rw [log_of_right_le_one _ h, Nat.clog_of_left_le_one hb, Int.ofNat_zero, neg_zero]
theorem log_of_right_le_zero (b : β) {r : R} (hr : r β€ 0) : log b r = 0 := by
rw [log_of_right_le_one _ (hr.trans zero_le_one),
Nat.clog_of_right_le_one ((Nat.ceil_eq_zero.mpr <| inv_nonpos.2 hr).trans_le zero_le_one),
Int.ofNat_zero, neg_zero]
theorem zpow_log_le_self {b : β} {r : R} (hb : 1 < b) (hr : 0 < r) : (b : R) ^ log b r β€ r := by
rcases le_total 1 r with hr1 | hr1
Β· rw [log_of_one_le_right _ hr1]
rw [zpow_natCast, β Nat.cast_pow, β Nat.le_floor_iff hr.le]
exact Nat.pow_log_le_self b (Nat.floor_pos.mpr hr1).ne'
Β· rw [log_of_right_le_one _ hr1, zpow_neg, zpow_natCast, β Nat.cast_pow]
exact inv_le_of_inv_leβ hr (Nat.ceil_le.1 <| Nat.le_pow_clog hb _)
theorem lt_zpow_succ_log_self {b : β} (hb : 1 < b) (r : R) : r < (b : R) ^ (log b r + 1) := by
rcases le_or_lt r 0 with hr | hr
Β· rw [log_of_right_le_zero _ hr, zero_add, zpow_one]
exact hr.trans_lt (zero_lt_one.trans_le <| mod_cast hb.le)
rcases le_or_lt 1 r with hr1 | hr1
Β· rw [log_of_one_le_right _ hr1]
rw [Int.ofNat_add_one_out, zpow_natCast, β Nat.cast_pow]
apply Nat.lt_of_floor_lt
exact Nat.lt_pow_succ_log_self hb _
Β· rw [log_of_right_le_one _ hr1.le]
have hcri : 1 < rβ»ΒΉ := (one_lt_invβ hr).2 hr1
have : 1 β€ Nat.clog b βrβ»ΒΉββ :=
Nat.succ_le_of_lt (Nat.clog_pos hb <| Nat.one_lt_cast.1 <| hcri.trans_le (Nat.le_ceil _))
rw [neg_add_eq_sub, β neg_sub, β Int.ofNat_one, β Int.ofNat_sub this, zpow_neg, zpow_natCast,
lt_inv_commβ hr (pow_pos (Nat.cast_pos.mpr <| zero_lt_one.trans hb) _), β Nat.cast_pow]
refine Nat.lt_ceil.1 ?_
exact Nat.pow_pred_clog_lt_self hb <| Nat.one_lt_cast.1 <| hcri.trans_le <| Nat.le_ceil _
@[simp]
theorem log_zero_right (b : β) : log b (0 : R) = 0 :=
log_of_right_le_zero b le_rfl
@[simp]
theorem log_one_right (b : β) : log b (1 : R) = 0 := by
rw [log_of_one_le_right _ le_rfl, Nat.floor_one, Nat.log_one_right, Int.ofNat_zero]
omit [IsStrictOrderedRing R] in
@[simp]
theorem log_zero_left (r : R) : log 0 r = 0 := by
simp only [log, Nat.log_zero_left, Nat.cast_zero, Nat.clog_zero_left, neg_zero, ite_self]
omit [IsStrictOrderedRing R] in
@[simp]
theorem log_one_left (r : R) : log 1 r = 0 := by
by_cases hr : 1 β€ r
Β· simp_all only [log, βreduceIte, Nat.log_one_left, Nat.cast_zero]
Β· simp only [log, Nat.log_one_left, Nat.cast_zero, Nat.clog_one_left, neg_zero, ite_self]
theorem log_zpow {b : β} (hb : 1 < b) (z : β€) : log b (b ^ z : R) = z := by
obtain β¨n, rfl | rflβ© := Int.eq_nat_or_neg z
Β· rw [log_of_one_le_right _ (one_le_zpowβ (mod_cast hb.le) <| Int.natCast_nonneg _), zpow_natCast,
β Nat.cast_pow, Nat.floor_natCast, Nat.log_pow hb]
Β· rw [log_of_right_le_one _ (zpow_le_one_of_nonposβ (mod_cast hb.le) <|
neg_nonpos.2 (Int.natCast_nonneg _)),
zpow_neg, inv_inv, zpow_natCast, β Nat.cast_pow, Nat.ceil_natCast, Nat.clog_pow _ _ hb]
@[mono]
theorem log_mono_right {b : β} {rβ rβ : R} (hβ : 0 < rβ) (h : rβ β€ rβ) : log b rβ β€ log b rβ := by
rcases le_total rβ 1 with hβ | hβ <;> rcases le_total rβ 1 with hβ | hβ
Β· rw [log_of_right_le_one _ hβ, log_of_right_le_one _ hβ, neg_le_neg_iff, Int.ofNat_le]
exact Nat.clog_mono_right _ (Nat.ceil_mono <| inv_antiβ hβ h)
Β· rw [log_of_right_le_one _ hβ, log_of_one_le_right _ hβ]
exact (neg_nonpos.mpr (Int.natCast_nonneg _)).trans (Int.natCast_nonneg _)
Β· obtain rfl := le_antisymm h (hβ.trans hβ)
rfl
Β· rw [log_of_one_le_right _ hβ, log_of_one_le_right _ hβ, Int.ofNat_le]
exact Nat.log_mono_right (Nat.floor_mono h)
variable (R) in
/-- Over suitable subtypes, `zpow` and `Int.log` form a galois coinsertion -/
def zpowLogGi {b : β} (hb : 1 < b) :
GaloisCoinsertion
(fun z : β€ =>
Subtype.mk ((b : R) ^ z) <| zpow_pos (mod_cast zero_lt_one.trans hb) z)
fun r : Set.Ioi (0 : R) => Int.log b (r : R) :=
GaloisCoinsertion.monotoneIntro (fun rβ _ => log_mono_right rβ.2)
(fun _ _ hz => Subtype.coe_le_coe.mp <| (zpow_right_strictMonoβ <| mod_cast hb).monotone hz)
(fun r => Subtype.coe_le_coe.mp <| zpow_log_le_self hb r.2) fun _ => log_zpow (R := R) hb _
/-- `zpow b` and `Int.log b` (almost) form a Galois connection. -/
theorem lt_zpow_iff_log_lt {b : β} (hb : 1 < b) {x : β€} {r : R} (hr : 0 < r) :
r < (b : R) ^ x β log b r < x :=
@GaloisConnection.lt_iff_lt _ _ _ _ _ _ (zpowLogGi R hb).gc x β¨r, hrβ©
/-- `zpow b` and `Int.log b` (almost) form a Galois connection. -/
theorem zpow_le_iff_le_log {b : β} (hb : 1 < b) {x : β€} {r : R} (hr : 0 < r) :
(b : R) ^ x β€ r β x β€ log b r :=
@GaloisConnection.le_iff_le _ _ _ _ _ _ (zpowLogGi R hb).gc x β¨r, hrβ©
/-- The least power of `b` such that `r β€ b ^ log b r`. -/
def clog (b : β) (r : R) : β€ :=
if 1 β€ r then Nat.clog b βrββ else -Nat.log b βrβ»ΒΉββ
omit [IsStrictOrderedRing R] in
theorem clog_of_one_le_right (b : β) {r : R} (hr : 1 β€ r) : clog b r = Nat.clog b βrββ :=
if_pos hr
theorem clog_of_right_le_one (b : β) {r : R} (hr : r β€ 1) : clog b r = -Nat.log b βrβ»ΒΉββ := by
obtain rfl | hr := hr.eq_or_lt
Β· rw [clog, if_pos hr, inv_one, Nat.ceil_one, Nat.floor_one, Nat.log_one_right,
Nat.clog_one_right, Int.ofNat_zero, neg_zero]
Β· exact if_neg hr.not_le
theorem clog_of_right_le_zero (b : β) {r : R} (hr : r β€ 0) : clog b r = 0 := by
rw [clog, if_neg (hr.trans_lt zero_lt_one).not_le, neg_eq_zero, Int.natCast_eq_zero,
Nat.log_eq_zero_iff]
rcases le_or_lt b 1 with hb | hb
Β· exact Or.inr hb
Β· refine Or.inl (lt_of_le_of_lt ?_ hb)
exact Nat.floor_le_one_of_le_one ((inv_nonpos.2 hr).trans zero_le_one)
@[simp]
theorem clog_inv (b : β) (r : R) : clog b rβ»ΒΉ = -log b r := by
rcases lt_or_le 0 r with hrp | hrp
Β· obtain hr | hr := le_total 1 r
Β· rw [clog_of_right_le_one _ (inv_le_one_of_one_leβ hr), log_of_one_le_right _ hr, inv_inv]
Β· rw [clog_of_one_le_right _ ((one_le_invβ hrp).2 hr), log_of_right_le_one _ hr, neg_neg]
Β· rw [clog_of_right_le_zero _ (inv_nonpos.mpr hrp), log_of_right_le_zero _ hrp, neg_zero]
@[simp]
theorem log_inv (b : β) (r : R) : log b rβ»ΒΉ = -clog b r := by
rw [β inv_inv r, clog_inv, neg_neg, inv_inv]
-- note this is useful for writing in reverse
theorem neg_log_inv_eq_clog (b : β) (r : R) : -log b rβ»ΒΉ = clog b r := by rw [log_inv, neg_neg]
theorem neg_clog_inv_eq_log (b : β) (r : R) : -clog b rβ»ΒΉ = log b r := by rw [clog_inv, neg_neg]
@[simp, norm_cast]
theorem clog_natCast (b : β) (n : β) : clog b (n : R) = Nat.clog b n := by
rcases n with - | n
Β· simp [clog_of_right_le_one]
Β· rw [clog_of_one_le_right, (Nat.ceil_eq_iff (Nat.succ_ne_zero n)).mpr] <;> simp
@[simp]
theorem clog_ofNat (b : β) (n : β) [n.AtLeastTwo] :
clog b (ofNat(n) : R) = Nat.clog b ofNat(n) :=
clog_natCast b n
| Mathlib/Data/Int/Log.lean | 228 | 228 | theorem clog_of_left_le_one {b : β} (hb : b β€ 1) (r : R) : clog b r = 0 := by | |
/-
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, Devon Tuma
-/
import Mathlib.Topology.Instances.ENNReal.Lemmas
import Mathlib.MeasureTheory.Measure.Dirac
/-!
# Probability mass functions
This file is about probability mass functions or discrete probability measures:
a function `Ξ± β ββ₯0β` such that the values have (infinite) sum `1`.
Construction of monadic `pure` and `bind` is found in `ProbabilityMassFunction/Monad.lean`,
other constructions of `PMF`s are found in `ProbabilityMassFunction/Constructions.lean`.
Given `p : PMF Ξ±`, `PMF.toOuterMeasure` constructs an `OuterMeasure` on `Ξ±`,
by assigning each set the sum of the probabilities of each of its elements.
Under this outer measure, every set is CarathΓ©odory-measurable,
so we can further extend this to a `Measure` on `Ξ±`, see `PMF.toMeasure`.
`PMF.toMeasure.isProbabilityMeasure` shows this associated measure is a probability measure.
Conversely, given a probability measure `ΞΌ` on a measurable space `Ξ±` with all singleton sets
measurable, `ΞΌ.toPMF` constructs a `PMF` on `Ξ±`, setting the probability mass of a point `x`
to be the measure of the singleton set `{x}`.
## Tags
probability mass function, discrete probability measure
-/
noncomputable section
variable {Ξ± : Type*}
open NNReal ENNReal MeasureTheory
/-- A probability mass function, or discrete probability measures is a function `Ξ± β ββ₯0β` such
that the values have (infinite) sum `1`. -/
def PMF.{u} (Ξ± : Type u) : Type u :=
{ f : Ξ± β ββ₯0β // HasSum f 1 }
namespace PMF
instance instFunLike : FunLike (PMF Ξ±) Ξ± ββ₯0β where
coe p a := p.1 a
coe_injective' _ _ h := Subtype.eq h
@[ext]
protected theorem ext {p q : PMF Ξ±} (h : β x, p x = q x) : p = q :=
DFunLike.ext p q h
theorem hasSum_coe_one (p : PMF Ξ±) : HasSum p 1 :=
p.2
@[simp]
theorem tsum_coe (p : PMF Ξ±) : β' a, p a = 1 :=
p.hasSum_coe_one.tsum_eq
theorem tsum_coe_ne_top (p : PMF Ξ±) : β' a, p a β β :=
p.tsum_coe.symm βΈ ENNReal.one_ne_top
theorem tsum_coe_indicator_ne_top (p : PMF Ξ±) (s : Set Ξ±) : β' a, s.indicator p a β β :=
ne_of_lt (lt_of_le_of_lt
(ENNReal.tsum_le_tsum (fun _ => Set.indicator_apply_le fun _ => le_rfl))
(lt_of_le_of_ne le_top p.tsum_coe_ne_top))
@[simp]
theorem coe_ne_zero (p : PMF Ξ±) : βp β 0 := fun hp =>
zero_ne_one ((tsum_zero.symm.trans (tsum_congr fun x => symm (congr_fun hp x))).trans p.tsum_coe)
/-- The support of a `PMF` is the set where it is nonzero. -/
def support (p : PMF Ξ±) : Set Ξ± :=
Function.support p
@[simp]
theorem mem_support_iff (p : PMF Ξ±) (a : Ξ±) : a β p.support β p a β 0 := Iff.rfl
@[simp]
theorem support_nonempty (p : PMF Ξ±) : p.support.Nonempty :=
Function.support_nonempty_iff.2 p.coe_ne_zero
@[simp]
theorem support_countable (p : PMF Ξ±) : p.support.Countable :=
Summable.countable_support_ennreal (tsum_coe_ne_top p)
theorem apply_eq_zero_iff (p : PMF Ξ±) (a : Ξ±) : p a = 0 β a β p.support := by
rw [mem_support_iff, Classical.not_not]
theorem apply_pos_iff (p : PMF Ξ±) (a : Ξ±) : 0 < p a β a β p.support :=
pos_iff_ne_zero.trans (p.mem_support_iff a).symm
theorem apply_eq_one_iff (p : PMF Ξ±) (a : Ξ±) : p a = 1 β p.support = {a} := by
refine β¨fun h => Set.Subset.antisymm (fun a' ha' => by_contra fun ha => ?_)
fun a' ha' => ha'.symm βΈ (p.mem_support_iff a).2 fun ha => zero_ne_one <| ha.symm.trans h,
fun h => _root_.trans (symm <| tsum_eq_single a
fun a' ha' => (p.apply_eq_zero_iff a').2 (h.symm βΈ ha')) p.tsum_coeβ©
suffices 1 < β' a, p a from ne_of_lt this p.tsum_coe.symm
classical
have : 0 < β' b, ite (b = a) 0 (p b) := lt_of_le_of_ne' zero_le'
(ENNReal.summable.tsum_ne_zero_iff.2
β¨a', ite_ne_left_iff.2 β¨ha, Ne.symm <| (p.mem_support_iff a').2 ha'β©β©)
calc
1 = 1 + 0 := (add_zero 1).symm
_ < p a + β' b, ite (b = a) 0 (p b) :=
(ENNReal.add_lt_add_of_le_of_lt ENNReal.one_ne_top (le_of_eq h.symm) this)
_ = ite (a = a) (p a) 0 + β' b, ite (b = a) 0 (p b) := by rw [eq_self_iff_true, if_true]
_ = (β' b, ite (b = a) (p b) 0) + β' b, ite (b = a) 0 (p b) := by
congr
exact symm (tsum_eq_single a fun b hb => if_neg hb)
_ = β' b, (ite (b = a) (p b) 0 + ite (b = a) 0 (p b)) := ENNReal.tsum_add.symm
_ = β' b, p b := tsum_congr fun b => by split_ifs <;> simp only [zero_add, add_zero, le_rfl]
theorem coe_le_one (p : PMF Ξ±) (a : Ξ±) : p a β€ 1 := by
classical
refine hasSum_le (fun b => ?_) (hasSum_ite_eq a (p a)) (hasSum_coe_one p)
split_ifs with h <;> simp only [h, zero_le', le_rfl]
theorem apply_ne_top (p : PMF Ξ±) (a : Ξ±) : p a β β :=
ne_of_lt (lt_of_le_of_lt (p.coe_le_one a) ENNReal.one_lt_top)
theorem apply_lt_top (p : PMF Ξ±) (a : Ξ±) : p a < β :=
lt_of_le_of_ne le_top (p.apply_ne_top a)
section OuterMeasure
open MeasureTheory MeasureTheory.OuterMeasure
/-- Construct an `OuterMeasure` from a `PMF`, by assigning measure to each set `s : Set Ξ±` equal
to the sum of `p x` for each `x β Ξ±`. -/
def toOuterMeasure (p : PMF Ξ±) : OuterMeasure Ξ± :=
OuterMeasure.sum fun x : Ξ± => p x β’ dirac x
variable (p : PMF Ξ±) (s : Set Ξ±)
theorem toOuterMeasure_apply : p.toOuterMeasure s = β' x, s.indicator p x :=
tsum_congr fun x => smul_dirac_apply (p x) x s
@[simp]
theorem toOuterMeasure_caratheodory : p.toOuterMeasure.caratheodory = β€ := by
refine eq_top_iff.2 <| le_trans (le_sInf fun x hx => ?_) (le_sum_caratheodory _)
have β¨y, hyβ© := hx
exact
((le_of_eq (dirac_caratheodory y).symm).trans (le_smul_caratheodory _ _)).trans (le_of_eq hy)
@[simp]
theorem toOuterMeasure_apply_finset (s : Finset Ξ±) : p.toOuterMeasure s = β x β s, p x := by
refine (toOuterMeasure_apply p s).trans ((tsum_eq_sum (s := s) ?_).trans ?_)
Β· exact fun x hx => Set.indicator_of_not_mem (Finset.mem_coe.not.2 hx) _
Β· exact Finset.sum_congr rfl fun x hx => Set.indicator_of_mem (Finset.mem_coe.2 hx) _
theorem toOuterMeasure_apply_singleton (a : Ξ±) : p.toOuterMeasure {a} = p a := by
refine (p.toOuterMeasure_apply {a}).trans ((tsum_eq_single a fun b hb => ?_).trans ?_)
Β· classical exact ite_eq_right_iff.2 fun hb' => False.elim <| hb hb'
Β· classical exact ite_eq_left_iff.2 fun ha' => False.elim <| ha' rfl
theorem toOuterMeasure_injective : (toOuterMeasure : PMF Ξ± β OuterMeasure Ξ±).Injective :=
fun p q h => PMF.ext fun x => (p.toOuterMeasure_apply_singleton x).symm.trans
((congr_fun (congr_arg _ h) _).trans <| q.toOuterMeasure_apply_singleton x)
@[simp]
theorem toOuterMeasure_inj {p q : PMF Ξ±} : p.toOuterMeasure = q.toOuterMeasure β p = q :=
toOuterMeasure_injective.eq_iff
| Mathlib/Probability/ProbabilityMassFunction/Basic.lean | 166 | 170 | theorem toOuterMeasure_apply_eq_zero_iff : p.toOuterMeasure s = 0 β Disjoint p.support s := by | rw [toOuterMeasure_apply, ENNReal.tsum_eq_zero]
exact funext_iff.symm.trans Set.indicator_eq_zero'
theorem toOuterMeasure_apply_eq_one_iff : p.toOuterMeasure s = 1 β p.support β s := by |
/-
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.Topology.Continuous
import Mathlib.Topology.Defs.Induced
/-!
# Ordering on topologies and (co)induced topologies
Topologies on a fixed type `Ξ±` are ordered, by reverse inclusion. That is, for topologies `tβ` and
`tβ` on `Ξ±`, we write `tβ β€ tβ` if every set open in `tβ` is also open in `tβ`. (One also calls
`tβ` *finer* than `tβ`, and `tβ` *coarser* than `tβ`.)
Any function `f : Ξ± β Ξ²` induces
* `TopologicalSpace.induced f : TopologicalSpace Ξ² β TopologicalSpace Ξ±`;
* `TopologicalSpace.coinduced f : TopologicalSpace Ξ± β TopologicalSpace Ξ²`.
Continuity, the ordering on topologies and (co)induced topologies are related as follows:
* The identity map `(Ξ±, tβ) β (Ξ±, tβ)` is continuous iff `tβ β€ tβ`.
* A map `f : (Ξ±, t) β (Ξ², u)` is continuous
* iff `t β€ TopologicalSpace.induced f u` (`continuous_iff_le_induced`)
* iff `TopologicalSpace.coinduced f t β€ u` (`continuous_iff_coinduced_le`).
Topologies on `Ξ±` form a complete lattice, with `β₯` the discrete topology and `β€` the indiscrete
topology.
For a function `f : Ξ± β Ξ²`, `(TopologicalSpace.coinduced f, TopologicalSpace.induced f)` is a Galois
connection between topologies on `Ξ±` and topologies on `Ξ²`.
## Implementation notes
There is a Galois insertion between topologies on `Ξ±` (with the inclusion ordering) and all
collections of sets in `Ξ±`. The complete lattice structure on topologies on `Ξ±` is defined as the
reverse of the one obtained via this Galois insertion. More precisely, we use the corresponding
Galois coinsertion between topologies on `Ξ±` (with the reversed inclusion ordering) and collections
of sets in `Ξ±` (with the reversed inclusion ordering).
## Tags
finer, coarser, induced topology, coinduced topology
-/
open Function Set Filter Topology
universe u v w
namespace TopologicalSpace
variable {Ξ± : Type u}
/-- The open sets of the least topology containing a collection of basic sets. -/
inductive GenerateOpen (g : Set (Set Ξ±)) : Set Ξ± β Prop
| basic : β s β g, GenerateOpen g s
| univ : GenerateOpen g univ
| inter : β s t, GenerateOpen g s β GenerateOpen g t β GenerateOpen g (s β© t)
| sUnion : β S : Set (Set Ξ±), (β s β S, GenerateOpen g s) β GenerateOpen g (ββ S)
/-- The smallest topological space containing the collection `g` of basic sets -/
def generateFrom (g : Set (Set Ξ±)) : TopologicalSpace Ξ± where
IsOpen := GenerateOpen g
isOpen_univ := GenerateOpen.univ
isOpen_inter := GenerateOpen.inter
isOpen_sUnion := GenerateOpen.sUnion
theorem isOpen_generateFrom_of_mem {g : Set (Set Ξ±)} {s : Set Ξ±} (hs : s β g) :
IsOpen[generateFrom g] s :=
GenerateOpen.basic s hs
theorem nhds_generateFrom {g : Set (Set Ξ±)} {a : Ξ±} :
@nhds Ξ± (generateFrom g) a = β¨
s β { s | a β s β§ s β g }, π s := by
letI := generateFrom g
rw [nhds_def]
refine le_antisymm (biInf_mono fun s β¨as, sgβ© => β¨as, .basic _ sgβ©) <| le_iInfβ ?_
rintro s β¨ha, hsβ©
induction hs with
| basic _ hs => exact iInfβ_le _ β¨ha, hsβ©
| univ => exact le_top.trans_eq principal_univ.symm
| inter _ _ _ _ hs ht => exact (le_inf (hs ha.1) (ht ha.2)).trans_eq inf_principal
| sUnion _ _ hS =>
let β¨t, htS, hatβ© := ha
exact (hS t htS hat).trans (principal_mono.2 <| subset_sUnion_of_mem htS)
lemma tendsto_nhds_generateFrom_iff {Ξ² : Type*} {m : Ξ± β Ξ²} {f : Filter Ξ±} {g : Set (Set Ξ²)}
{b : Ξ²} : Tendsto m f (@nhds Ξ² (generateFrom g) b) β β s β g, b β s β m β»ΒΉ' s β f := by
simp only [nhds_generateFrom, @forall_swap (b β _), tendsto_iInf, mem_setOf_eq, and_imp,
tendsto_principal]; rfl
/-- Construct a topology on Ξ± given the filter of neighborhoods of each point of Ξ±. -/
protected def mkOfNhds (n : Ξ± β Filter Ξ±) : TopologicalSpace Ξ± where
IsOpen s := β a β s, s β n a
isOpen_univ _ _ := univ_mem
isOpen_inter := fun _s _t hs ht x β¨hxs, hxtβ© => inter_mem (hs x hxs) (ht x hxt)
isOpen_sUnion := fun _s hs _a β¨x, hx, hxaβ© =>
mem_of_superset (hs x hx _ hxa) (subset_sUnion_of_mem hx)
theorem nhds_mkOfNhds_of_hasBasis {n : Ξ± β Filter Ξ±} {ΞΉ : Ξ± β Sort*} {p : β a, ΞΉ a β Prop}
{s : β a, ΞΉ a β Set Ξ±} (hb : β a, (n a).HasBasis (p a) (s a))
(hpure : β a i, p a i β a β s a i) (hopen : β a i, p a i β βαΆ x in n a, s a i β n x) (a : Ξ±) :
@nhds Ξ± (.mkOfNhds n) a = n a := by
let t : TopologicalSpace Ξ± := .mkOfNhds n
apply le_antisymm
Β· intro U hU
replace hpure : pure β€ n := fun x β¦ (hb x).ge_iff.2 (hpure x)
refine mem_nhds_iff.2 β¨{x | U β n x}, fun x hx β¦ hpure x hx, fun x hx β¦ ?_, hUβ©
rcases (hb x).mem_iff.1 hx with β¨i, hpi, hiβ©
exact (hopen x i hpi).mono fun y hy β¦ mem_of_superset hy hi
Β· exact (nhds_basis_opens a).ge_iff.2 fun U β¨haU, hUoβ© β¦ hUo a haU
theorem nhds_mkOfNhds (n : Ξ± β Filter Ξ±) (a : Ξ±) (hβ : pure β€ n)
(hβ : β a, β s β n a, βαΆ y in n a, s β n y) :
@nhds Ξ± (TopologicalSpace.mkOfNhds n) a = n a :=
nhds_mkOfNhds_of_hasBasis (fun a β¦ (n a).basis_sets) hβ hβ _
theorem nhds_mkOfNhds_single [DecidableEq Ξ±] {aβ : Ξ±} {l : Filter Ξ±} (h : pure aβ β€ l) (b : Ξ±) :
@nhds Ξ± (TopologicalSpace.mkOfNhds (update pure aβ l)) b =
(update pure aβ l : Ξ± β Filter Ξ±) b := by
refine nhds_mkOfNhds _ _ (le_update_iff.mpr β¨h, fun _ _ => le_rflβ©) fun a s hs => ?_
rcases eq_or_ne a aβ with (rfl | ha)
Β· filter_upwards [hs] with b hb
rcases eq_or_ne b a with (rfl | hb)
Β· exact hs
Β· rwa [update_of_ne hb]
Β· simpa only [update_of_ne ha, mem_pure, eventually_pure] using hs
theorem nhds_mkOfNhds_filterBasis (B : Ξ± β FilterBasis Ξ±) (a : Ξ±) (hβ : β x, β n β B x, x β n)
(hβ : β x, β n β B x, β nβ β B x, β x' β nβ, β nβ β B x', nβ β n) :
@nhds Ξ± (TopologicalSpace.mkOfNhds fun x => (B x).filter) a = (B a).filter :=
nhds_mkOfNhds_of_hasBasis (fun a β¦ (B a).hasBasis) hβ hβ a
section Lattice
variable {Ξ± : Type u} {Ξ² : Type v}
/-- The ordering on topologies on the type `Ξ±`. `t β€ s` if every set open in `s` is also open in `t`
(`t` is finer than `s`). -/
instance : PartialOrder (TopologicalSpace Ξ±) :=
{ PartialOrder.lift (fun t => OrderDual.toDual IsOpen[t]) (fun _ _ => TopologicalSpace.ext) with
le := fun s t => β U, IsOpen[t] U β IsOpen[s] U }
protected theorem le_def {Ξ±} {t s : TopologicalSpace Ξ±} : t β€ s β IsOpen[s] β€ IsOpen[t] :=
Iff.rfl
theorem le_generateFrom_iff_subset_isOpen {g : Set (Set Ξ±)} {t : TopologicalSpace Ξ±} :
t β€ generateFrom g β g β { s | IsOpen[t] s } :=
β¨fun ht s hs => ht _ <| .basic s hs, fun hg _s hs =>
hs.recOn (fun _ h => hg h) isOpen_univ (fun _ _ _ _ => IsOpen.inter) fun _ _ => isOpen_sUnionβ©
/-- If `s` equals the collection of open sets in the topology it generates, then `s` defines a
topology. -/
protected def mkOfClosure (s : Set (Set Ξ±)) (hs : { u | GenerateOpen s u } = s) :
TopologicalSpace Ξ± where
IsOpen u := u β s
isOpen_univ := hs βΈ TopologicalSpace.GenerateOpen.univ
isOpen_inter := hs βΈ TopologicalSpace.GenerateOpen.inter
isOpen_sUnion := hs βΈ TopologicalSpace.GenerateOpen.sUnion
theorem mkOfClosure_sets {s : Set (Set Ξ±)} {hs : { u | GenerateOpen s u } = s} :
TopologicalSpace.mkOfClosure s hs = generateFrom s :=
TopologicalSpace.ext hs.symm
theorem gc_generateFrom (Ξ±) :
GaloisConnection (fun t : TopologicalSpace Ξ± => OrderDual.toDual { s | IsOpen[t] s })
(generateFrom β OrderDual.ofDual) := fun _ _ =>
le_generateFrom_iff_subset_isOpen.symm
/-- The Galois coinsertion between `TopologicalSpace Ξ±` and `(Set (Set Ξ±))α΅α΅` whose lower part sends
a topology to its collection of open subsets, and whose upper part sends a collection of subsets
of `Ξ±` to the topology they generate. -/
def gciGenerateFrom (Ξ± : Type*) :
GaloisCoinsertion (fun t : TopologicalSpace Ξ± => OrderDual.toDual { s | IsOpen[t] s })
(generateFrom β OrderDual.ofDual) where
gc := gc_generateFrom Ξ±
u_l_le _ s hs := TopologicalSpace.GenerateOpen.basic s hs
choice g hg := TopologicalSpace.mkOfClosure g
(Subset.antisymm hg <| le_generateFrom_iff_subset_isOpen.1 <| le_rfl)
choice_eq _ _ := mkOfClosure_sets
/-- Topologies on `Ξ±` form a complete lattice, with `β₯` the discrete topology
and `β€` the indiscrete topology. The infimum of a collection of topologies
is the topology generated by all their open sets, while the supremum is the
topology whose open sets are those sets open in every member of the collection. -/
instance : CompleteLattice (TopologicalSpace Ξ±) := (gciGenerateFrom Ξ±).liftCompleteLattice
@[mono, gcongr]
theorem generateFrom_anti {Ξ±} {gβ gβ : Set (Set Ξ±)} (h : gβ β gβ) :
generateFrom gβ β€ generateFrom gβ :=
(gc_generateFrom _).monotone_u h
theorem generateFrom_setOf_isOpen (t : TopologicalSpace Ξ±) :
generateFrom { s | IsOpen[t] s } = t :=
(gciGenerateFrom Ξ±).u_l_eq t
theorem leftInverse_generateFrom :
LeftInverse generateFrom fun t : TopologicalSpace Ξ± => { s | IsOpen[t] s } :=
(gciGenerateFrom Ξ±).u_l_leftInverse
theorem generateFrom_surjective : Surjective (generateFrom : Set (Set Ξ±) β TopologicalSpace Ξ±) :=
(gciGenerateFrom Ξ±).u_surjective
theorem setOf_isOpen_injective : Injective fun t : TopologicalSpace Ξ± => { s | IsOpen[t] s } :=
(gciGenerateFrom Ξ±).l_injective
end Lattice
end TopologicalSpace
section Lattice
variable {Ξ± : Type*} {t tβ tβ : TopologicalSpace Ξ±} {s : Set Ξ±}
theorem IsOpen.mono (hs : IsOpen[tβ] s) (h : tβ β€ tβ) : IsOpen[tβ] s := h s hs
theorem IsClosed.mono (hs : IsClosed[tβ] s) (h : tβ β€ tβ) : IsClosed[tβ] s :=
(@isOpen_compl_iff Ξ± s tβ).mp <| hs.isOpen_compl.mono h
theorem closure.mono (h : tβ β€ tβ) : closure[tβ] s β closure[tβ] s :=
@closure_minimal _ tβ s (@closure _ tβ s) subset_closure (IsClosed.mono isClosed_closure h)
theorem isOpen_implies_isOpen_iff : (β s, IsOpen[tβ] s β IsOpen[tβ] s) β tβ β€ tβ :=
Iff.rfl
/-- The only open sets in the indiscrete topology are the empty set and the whole space. -/
theorem TopologicalSpace.isOpen_top_iff {Ξ±} (U : Set Ξ±) : IsOpen[β€] U β U = β
β¨ U = univ :=
β¨fun h => by
induction h with
| basic _ h => exact False.elim h
| univ => exact .inr rfl
| inter _ _ _ _ hβ hβ =>
rcases hβ with (rfl | rfl) <;> rcases hβ with (rfl | rfl) <;> simp
| sUnion _ _ ih => exact sUnion_mem_empty_univ ih, by
rintro (rfl | rfl)
exacts [@isOpen_empty _ β€, @isOpen_univ _ β€]β©
/-- A topological space is discrete if every set is open, that is,
its topology equals the discrete topology `β₯`. -/
class DiscreteTopology (Ξ± : Type*) [t : TopologicalSpace Ξ±] : Prop where
/-- The `TopologicalSpace` structure on a type with discrete topology is equal to `β₯`. -/
eq_bot : t = β₯
theorem discreteTopology_bot (Ξ± : Type*) : @DiscreteTopology Ξ± β₯ :=
@DiscreteTopology.mk Ξ± β₯ rfl
section DiscreteTopology
variable [TopologicalSpace Ξ±] [DiscreteTopology Ξ±] {Ξ² : Type*}
@[simp]
theorem isOpen_discrete (s : Set Ξ±) : IsOpen s := (@DiscreteTopology.eq_bot Ξ± _).symm βΈ trivial
@[simp] theorem isClosed_discrete (s : Set Ξ±) : IsClosed s := β¨isOpen_discrete _β©
theorem closure_discrete (s : Set Ξ±) : closure s = s := (isClosed_discrete _).closure_eq
@[simp] theorem dense_discrete {s : Set Ξ±} : Dense s β s = univ := by simp [dense_iff_closure_eq]
@[simp]
theorem denseRange_discrete {ΞΉ : Type*} {f : ΞΉ β Ξ±} : DenseRange f β Surjective f := by
rw [DenseRange, dense_discrete, range_eq_univ]
@[nontriviality, continuity, fun_prop]
theorem continuous_of_discreteTopology [TopologicalSpace Ξ²] {f : Ξ± β Ξ²} : Continuous f :=
continuous_def.2 fun _ _ => isOpen_discrete _
/-- A function to a discrete topological space is continuous if and only if the preimage of every
singleton is open. -/
theorem continuous_discrete_rng {Ξ±} [TopologicalSpace Ξ±] [TopologicalSpace Ξ²] [DiscreteTopology Ξ²]
{f : Ξ± β Ξ²} : Continuous f β β b : Ξ², IsOpen (f β»ΒΉ' {b}) :=
β¨fun h _ => (isOpen_discrete _).preimage h, fun h => β¨fun s _ => by
rw [β biUnion_of_singleton s, preimage_iUnionβ]
exact isOpen_biUnion fun _ _ => h _β©β©
@[simp]
theorem nhds_discrete (Ξ± : Type*) [TopologicalSpace Ξ±] [DiscreteTopology Ξ±] : @nhds Ξ± _ = pure :=
le_antisymm (fun _ s hs => (isOpen_discrete s).mem_nhds hs) pure_le_nhds
theorem mem_nhds_discrete {x : Ξ±} {s : Set Ξ±} :
s β π x β x β s := by rw [nhds_discrete, mem_pure]
end DiscreteTopology
theorem le_of_nhds_le_nhds (h : β x, @nhds Ξ± tβ x β€ @nhds Ξ± tβ x) : tβ β€ tβ := fun s => by
rw [@isOpen_iff_mem_nhds _ tβ, @isOpen_iff_mem_nhds _ tβ]
exact fun hs a ha => h _ (hs _ ha)
theorem eq_bot_of_singletons_open {t : TopologicalSpace Ξ±} (h : β x, IsOpen[t] {x}) : t = β₯ :=
bot_unique fun s _ => biUnion_of_singleton s βΈ isOpen_biUnion fun x _ => h x
theorem forall_open_iff_discrete {X : Type*} [TopologicalSpace X] :
(β s : Set X, IsOpen s) β DiscreteTopology X :=
β¨fun h => β¨eq_bot_of_singletons_open fun _ => h _β©, @isOpen_discrete _ _β©
theorem discreteTopology_iff_forall_isClosed [TopologicalSpace Ξ±] :
DiscreteTopology Ξ± β β s : Set Ξ±, IsClosed s :=
forall_open_iff_discrete.symm.trans <| compl_surjective.forall.trans <| forall_congr' fun _ β¦
isOpen_compl_iff
theorem singletons_open_iff_discrete {X : Type*} [TopologicalSpace X] :
(β a : X, IsOpen ({a} : Set X)) β DiscreteTopology X :=
β¨fun h => β¨eq_bot_of_singletons_open hβ©, fun a _ => @isOpen_discrete _ _ a _β©
theorem DiscreteTopology.of_finite_of_isClosed_singleton [TopologicalSpace Ξ±] [Finite Ξ±]
(h : β a : Ξ±, IsClosed {a}) : DiscreteTopology Ξ± :=
discreteTopology_iff_forall_isClosed.mpr fun s β¦
s.iUnion_of_singleton_coe βΈ isClosed_iUnion_of_finite fun _ β¦ h _
theorem discreteTopology_iff_singleton_mem_nhds [TopologicalSpace Ξ±] :
DiscreteTopology Ξ± β β x : Ξ±, {x} β π x := by
simp only [β singletons_open_iff_discrete, isOpen_iff_mem_nhds, mem_singleton_iff, forall_eq]
/-- This lemma characterizes discrete topological spaces as those whose singletons are
neighbourhoods. -/
theorem discreteTopology_iff_nhds [TopologicalSpace Ξ±] :
DiscreteTopology Ξ± β β x : Ξ±, π x = pure x := by
simp [discreteTopology_iff_singleton_mem_nhds, le_pure_iff]
apply forall_congr' (fun x β¦ ?_)
simp [le_antisymm_iff, pure_le_nhds x]
theorem discreteTopology_iff_nhds_ne [TopologicalSpace Ξ±] :
DiscreteTopology Ξ± β β x : Ξ±, π[β ] x = β₯ := by
simp only [discreteTopology_iff_singleton_mem_nhds, nhdsWithin, inf_principal_eq_bot, compl_compl]
/-- If the codomain of a continuous injective function has discrete topology,
then so does the domain.
See also `Embedding.discreteTopology` for an important special case. -/
theorem DiscreteTopology.of_continuous_injective
{Ξ² : Type*} [TopologicalSpace Ξ±] [TopologicalSpace Ξ²] [DiscreteTopology Ξ²] {f : Ξ± β Ξ²}
(hc : Continuous f) (hinj : Injective f) : DiscreteTopology Ξ± :=
forall_open_iff_discrete.1 fun s β¦ hinj.preimage_image s βΈ (isOpen_discrete _).preimage hc
end Lattice
section GaloisConnection
variable {Ξ± Ξ² Ξ³ : Type*}
theorem isOpen_induced_iff [t : TopologicalSpace Ξ²] {s : Set Ξ±} {f : Ξ± β Ξ²} :
IsOpen[t.induced f] s β β t, IsOpen t β§ f β»ΒΉ' t = s :=
Iff.rfl
theorem isClosed_induced_iff [t : TopologicalSpace Ξ²] {s : Set Ξ±} {f : Ξ± β Ξ²} :
IsClosed[t.induced f] s β β t, IsClosed t β§ f β»ΒΉ' t = s := by
letI := t.induced f
simp only [β isOpen_compl_iff, isOpen_induced_iff]
exact compl_surjective.exists.trans (by simp only [preimage_compl, compl_inj_iff])
theorem isOpen_coinduced {t : TopologicalSpace Ξ±} {s : Set Ξ²} {f : Ξ± β Ξ²} :
IsOpen[t.coinduced f] s β IsOpen (f β»ΒΉ' s) :=
Iff.rfl
theorem isClosed_coinduced {t : TopologicalSpace Ξ±} {s : Set Ξ²} {f : Ξ± β Ξ²} :
IsClosed[t.coinduced f] s β IsClosed (f β»ΒΉ' s) := by
simp only [β isOpen_compl_iff, isOpen_coinduced (f := f), preimage_compl]
theorem preimage_nhds_coinduced [TopologicalSpace Ξ±] {Ο : Ξ± β Ξ²} {s : Set Ξ²} {a : Ξ±}
(hs : s β @nhds Ξ² (TopologicalSpace.coinduced Ο βΉ_βΊ) (Ο a)) : Ο β»ΒΉ' s β π a := by
letI := TopologicalSpace.coinduced Ο βΉ_βΊ
rcases mem_nhds_iff.mp hs with β¨V, hVs, V_op, mem_Vβ©
exact mem_nhds_iff.mpr β¨Ο β»ΒΉ' V, Set.preimage_mono hVs, V_op, mem_Vβ©
variable {t tβ tβ : TopologicalSpace Ξ±} {t' : TopologicalSpace Ξ²} {f : Ξ± β Ξ²} {g : Ξ² β Ξ±}
theorem Continuous.coinduced_le (h : Continuous[t, t'] f) : t.coinduced f β€ t' :=
(@continuous_def Ξ± Ξ² t t').1 h
theorem coinduced_le_iff_le_induced {f : Ξ± β Ξ²} {tΞ± : TopologicalSpace Ξ±}
{tΞ² : TopologicalSpace Ξ²} : tΞ±.coinduced f β€ tΞ² β tΞ± β€ tΞ².induced f :=
β¨fun h _s β¨_t, ht, hstβ© => hst βΈ h _ ht, fun h s hs => h _ β¨s, hs, rflβ©β©
theorem Continuous.le_induced (h : Continuous[t, t'] f) : t β€ t'.induced f :=
coinduced_le_iff_le_induced.1 h.coinduced_le
theorem gc_coinduced_induced (f : Ξ± β Ξ²) :
GaloisConnection (TopologicalSpace.coinduced f) (TopologicalSpace.induced f) := fun _ _ =>
coinduced_le_iff_le_induced
theorem induced_mono (h : tβ β€ tβ) : tβ.induced g β€ tβ.induced g :=
(gc_coinduced_induced g).monotone_u h
theorem coinduced_mono (h : tβ β€ tβ) : tβ.coinduced f β€ tβ.coinduced f :=
(gc_coinduced_induced f).monotone_l h
@[simp]
theorem induced_top : (β€ : TopologicalSpace Ξ±).induced g = β€ :=
(gc_coinduced_induced g).u_top
@[simp]
theorem induced_inf : (tβ β tβ).induced g = tβ.induced g β tβ.induced g :=
(gc_coinduced_induced g).u_inf
@[simp]
theorem induced_iInf {ΞΉ : Sort w} {t : ΞΉ β TopologicalSpace Ξ±} :
(β¨
i, t i).induced g = β¨
i, (t i).induced g :=
(gc_coinduced_induced g).u_iInf
@[simp]
theorem induced_sInf {s : Set (TopologicalSpace Ξ±)} :
TopologicalSpace.induced g (sInf s) = sInf (TopologicalSpace.induced g '' s) := by
rw [sInf_eq_iInf', sInf_image', induced_iInf]
@[simp]
theorem coinduced_bot : (β₯ : TopologicalSpace Ξ±).coinduced f = β₯ :=
(gc_coinduced_induced f).l_bot
@[simp]
theorem coinduced_sup : (tβ β tβ).coinduced f = tβ.coinduced f β tβ.coinduced f :=
(gc_coinduced_induced f).l_sup
@[simp]
theorem coinduced_iSup {ΞΉ : Sort w} {t : ΞΉ β TopologicalSpace Ξ±} :
(β¨ i, t i).coinduced f = β¨ i, (t i).coinduced f :=
(gc_coinduced_induced f).l_iSup
@[simp]
theorem coinduced_sSup {s : Set (TopologicalSpace Ξ±)} :
TopologicalSpace.coinduced f (sSup s) = sSup ((TopologicalSpace.coinduced f) '' s) := by
rw [sSup_eq_iSup', sSup_image', coinduced_iSup]
theorem induced_id [t : TopologicalSpace Ξ±] : t.induced id = t :=
TopologicalSpace.ext <|
funext fun s => propext <| β¨fun β¨_, hs, hβ© => h βΈ hs, fun hs => β¨s, hs, rflβ©β©
theorem induced_compose {tΞ³ : TopologicalSpace Ξ³} {f : Ξ± β Ξ²} {g : Ξ² β Ξ³} :
(tΞ³.induced g).induced f = tΞ³.induced (g β f) :=
TopologicalSpace.ext <|
funext fun _ => propext
β¨fun β¨_, β¨s, hs, hββ©, hββ© => hβ βΈ hβ βΈ β¨s, hs, rflβ©,
fun β¨s, hs, hβ© => β¨preimage g s, β¨s, hs, rflβ©, h βΈ rflβ©β©
theorem induced_const [t : TopologicalSpace Ξ±] {x : Ξ±} : (t.induced fun _ : Ξ² => x) = β€ :=
le_antisymm le_top (@continuous_const Ξ² Ξ± β€ t x).le_induced
theorem coinduced_id [t : TopologicalSpace Ξ±] : t.coinduced id = t :=
TopologicalSpace.ext rfl
theorem coinduced_compose [tΞ± : TopologicalSpace Ξ±] {f : Ξ± β Ξ²} {g : Ξ² β Ξ³} :
(tΞ±.coinduced f).coinduced g = tΞ±.coinduced (g β f) :=
TopologicalSpace.ext rfl
theorem Equiv.induced_symm {Ξ± Ξ² : Type*} (e : Ξ± β Ξ²) :
TopologicalSpace.induced e.symm = TopologicalSpace.coinduced e := by
ext t U
rw [isOpen_induced_iff, isOpen_coinduced]
simp only [e.symm.preimage_eq_iff_eq_image, exists_eq_right, β preimage_equiv_eq_image_symm]
theorem Equiv.coinduced_symm {Ξ± Ξ² : Type*} (e : Ξ± β Ξ²) :
TopologicalSpace.coinduced e.symm = TopologicalSpace.induced e :=
e.symm.induced_symm.symm
end GaloisConnection
-- constructions using the complete lattice structure
section Constructions
open TopologicalSpace
variable {Ξ± : Type u} {Ξ² : Type v}
instance inhabitedTopologicalSpace {Ξ± : Type u} : Inhabited (TopologicalSpace Ξ±) :=
β¨β₯β©
instance (priority := 100) Subsingleton.uniqueTopologicalSpace [Subsingleton Ξ±] :
Unique (TopologicalSpace Ξ±) where
default := β₯
uniq t :=
eq_bot_of_singletons_open fun x =>
Subsingleton.set_cases (@isOpen_empty _ t) (@isOpen_univ _ t) ({x} : Set Ξ±)
instance (priority := 100) Subsingleton.discreteTopology [t : TopologicalSpace Ξ±] [Subsingleton Ξ±] :
DiscreteTopology Ξ± :=
β¨Unique.eq_default tβ©
instance : TopologicalSpace Empty := β₯
instance : DiscreteTopology Empty := β¨rflβ©
instance : TopologicalSpace PEmpty := β₯
instance : DiscreteTopology PEmpty := β¨rflβ©
instance : TopologicalSpace PUnit := β₯
instance : DiscreteTopology PUnit := β¨rflβ©
instance : TopologicalSpace Bool := β₯
instance : DiscreteTopology Bool := β¨rflβ©
instance : TopologicalSpace β := β₯
instance : DiscreteTopology β := β¨rflβ©
instance : TopologicalSpace β€ := β₯
instance : DiscreteTopology β€ := β¨rflβ©
instance {n} : TopologicalSpace (Fin n) := β₯
instance {n} : DiscreteTopology (Fin n) := β¨rflβ©
instance sierpinskiSpace : TopologicalSpace Prop :=
generateFrom {{True}}
/-- See also `continuous_of_discreteTopology`, which works for `IsEmpty Ξ±`. -/
theorem continuous_empty_function [TopologicalSpace Ξ±] [TopologicalSpace Ξ²] [IsEmpty Ξ²]
(f : Ξ± β Ξ²) : Continuous f :=
letI := Function.isEmpty f
continuous_of_discreteTopology
theorem le_generateFrom {t : TopologicalSpace Ξ±} {g : Set (Set Ξ±)} (h : β s β g, IsOpen s) :
t β€ generateFrom g :=
le_generateFrom_iff_subset_isOpen.2 h
theorem induced_generateFrom_eq {Ξ± Ξ²} {b : Set (Set Ξ²)} {f : Ξ± β Ξ²} :
(generateFrom b).induced f = generateFrom (preimage f '' b) :=
le_antisymm (le_generateFrom <| forall_mem_image.2 fun s hs => β¨s, GenerateOpen.basic _ hs, rflβ©)
(coinduced_le_iff_le_induced.1 <| le_generateFrom fun _s hs => .basic _ (mem_image_of_mem _ hs))
theorem le_induced_generateFrom {Ξ± Ξ²} [t : TopologicalSpace Ξ±] {b : Set (Set Ξ²)} {f : Ξ± β Ξ²}
(h : β a : Set Ξ², a β b β IsOpen (f β»ΒΉ' a)) : t β€ induced f (generateFrom b) := by
rw [induced_generateFrom_eq]
apply le_generateFrom
simp only [mem_image, and_imp, forall_apply_eq_imp_iffβ, exists_imp]
exact h
lemma generateFrom_insert_of_generateOpen {Ξ± : Type*} {s : Set (Set Ξ±)} {t : Set Ξ±}
(ht : GenerateOpen s t) : generateFrom (insert t s) = generateFrom s := by
refine le_antisymm (generateFrom_anti <| subset_insert t s) (le_generateFrom ?_)
rintro t (rfl | h)
Β· exact ht
Β· exact isOpen_generateFrom_of_mem h
@[simp]
lemma generateFrom_insert_univ {Ξ± : Type*} {s : Set (Set Ξ±)} :
generateFrom (insert univ s) = generateFrom s :=
generateFrom_insert_of_generateOpen .univ
@[simp]
lemma generateFrom_insert_empty {Ξ± : Type*} {s : Set (Set Ξ±)} :
generateFrom (insert β
s) = generateFrom s := by
rw [β sUnion_empty]
exact generateFrom_insert_of_generateOpen (.sUnion β
(fun s_1 a β¦ False.elim a))
/-- This construction is left adjoint to the operation sending a topology on `Ξ±`
to its neighborhood filter at a fixed point `a : Ξ±`. -/
def nhdsAdjoint (a : Ξ±) (f : Filter Ξ±) : TopologicalSpace Ξ± where
IsOpen s := a β s β s β f
isOpen_univ _ := univ_mem
isOpen_inter := fun _s _t hs ht β¨has, hatβ© => inter_mem (hs has) (ht hat)
isOpen_sUnion := fun _k hk β¨u, hu, hauβ© => mem_of_superset (hk u hu hau) (subset_sUnion_of_mem hu)
theorem gc_nhds (a : Ξ±) : GaloisConnection (nhdsAdjoint a) fun t => @nhds Ξ± t a := fun f t => by
rw [le_nhds_iff]
exact β¨fun H s hs has => H _ has hs, fun H s has hs => H _ hs hasβ©
theorem nhds_mono {tβ tβ : TopologicalSpace Ξ±} {a : Ξ±} (h : tβ β€ tβ) :
@nhds Ξ± tβ a β€ @nhds Ξ± tβ a :=
(gc_nhds a).monotone_u h
theorem le_iff_nhds {Ξ± : Type*} (t t' : TopologicalSpace Ξ±) :
t β€ t' β β x, @nhds Ξ± t x β€ @nhds Ξ± t' x :=
β¨fun h _ => nhds_mono h, le_of_nhds_le_nhdsβ©
theorem isOpen_singleton_nhdsAdjoint {Ξ± : Type*} {a b : Ξ±} (f : Filter Ξ±) (hb : b β a) :
IsOpen[nhdsAdjoint a f] {b} := fun h β¦
absurd h hb.symm
theorem nhds_nhdsAdjoint_same (a : Ξ±) (f : Filter Ξ±) :
@nhds Ξ± (nhdsAdjoint a f) a = pure a β f := by
let _ := nhdsAdjoint a f
apply le_antisymm
Β· rintro t β¨hat : a β t, htf : t β fβ©
exact IsOpen.mem_nhds (fun _ β¦ htf) hat
Β· exact sup_le (pure_le_nhds _) ((gc_nhds a).le_u_l f)
theorem nhds_nhdsAdjoint_of_ne {a b : Ξ±} (f : Filter Ξ±) (h : b β a) :
@nhds Ξ± (nhdsAdjoint a f) b = pure b :=
let _ := nhdsAdjoint a f
(isOpen_singleton_iff_nhds_eq_pure _).1 <| isOpen_singleton_nhdsAdjoint f h
theorem nhds_nhdsAdjoint [DecidableEq Ξ±] (a : Ξ±) (f : Filter Ξ±) :
@nhds Ξ± (nhdsAdjoint a f) = update pure a (pure a β f) :=
eq_update_iff.2 β¨nhds_nhdsAdjoint_same .., fun _ β¦ nhds_nhdsAdjoint_of_ne _β©
theorem le_nhdsAdjoint_iff' {a : Ξ±} {f : Filter Ξ±} {t : TopologicalSpace Ξ±} :
t β€ nhdsAdjoint a f β @nhds Ξ± t a β€ pure a β f β§ β b β a, @nhds Ξ± t b = pure b := by
classical
simp_rw [le_iff_nhds, nhds_nhdsAdjoint, forall_update_iff, (pure_le_nhds _).le_iff_eq]
theorem le_nhdsAdjoint_iff {Ξ± : Type*} (a : Ξ±) (f : Filter Ξ±) (t : TopologicalSpace Ξ±) :
t β€ nhdsAdjoint a f β @nhds Ξ± t a β€ pure a β f β§ β b β a, IsOpen[t] {b} := by
simp only [le_nhdsAdjoint_iff', @isOpen_singleton_iff_nhds_eq_pure Ξ± t]
theorem nhds_iInf {ΞΉ : Sort*} {t : ΞΉ β TopologicalSpace Ξ±} {a : Ξ±} :
@nhds Ξ± (iInf t) a = β¨
i, @nhds Ξ± (t i) a :=
(gc_nhds a).u_iInf
theorem nhds_sInf {s : Set (TopologicalSpace Ξ±)} {a : Ξ±} :
@nhds Ξ± (sInf s) a = β¨
t β s, @nhds Ξ± t a :=
(gc_nhds a).u_sInf
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: timeouts without `bβ := tβ`
theorem nhds_inf {tβ tβ : TopologicalSpace Ξ±} {a : Ξ±} :
@nhds Ξ± (tβ β tβ) a = @nhds Ξ± tβ a β @nhds Ξ± tβ a :=
(gc_nhds a).u_inf (bβ := tβ)
theorem nhds_top {a : Ξ±} : @nhds Ξ± β€ a = β€ :=
(gc_nhds a).u_top
theorem isOpen_sup {tβ tβ : TopologicalSpace Ξ±} {s : Set Ξ±} :
IsOpen[tβ β tβ] s β IsOpen[tβ] s β§ IsOpen[tβ] s :=
Iff.rfl
open TopologicalSpace
variable {Ξ³ : Type*} {f : Ξ± β Ξ²} {ΞΉ : Sort*}
theorem continuous_iff_coinduced_le {tβ : TopologicalSpace Ξ±} {tβ : TopologicalSpace Ξ²} :
Continuous[tβ, tβ] f β coinduced f tβ β€ tβ :=
continuous_def
theorem continuous_iff_le_induced {tβ : TopologicalSpace Ξ±} {tβ : TopologicalSpace Ξ²} :
Continuous[tβ, tβ] f β tβ β€ induced f tβ :=
Iff.trans continuous_iff_coinduced_le (gc_coinduced_induced f _ _)
lemma continuous_generateFrom_iff {t : TopologicalSpace Ξ±} {b : Set (Set Ξ²)} :
Continuous[t, generateFrom b] f β β s β b, IsOpen (f β»ΒΉ' s) := by
rw [continuous_iff_coinduced_le, le_generateFrom_iff_subset_isOpen]
simp only [isOpen_coinduced, preimage_id', subset_def, mem_setOf]
@[continuity, fun_prop]
theorem continuous_induced_dom {t : TopologicalSpace Ξ²} : Continuous[induced f t, t] f :=
continuous_iff_le_induced.2 le_rfl
theorem continuous_induced_rng {g : Ξ³ β Ξ±} {tβ : TopologicalSpace Ξ²} {tβ : TopologicalSpace Ξ³} :
Continuous[tβ, induced f tβ] g β Continuous[tβ, tβ] (f β g) := by
simp only [continuous_iff_le_induced, induced_compose]
theorem continuous_coinduced_rng {t : TopologicalSpace Ξ±} :
Continuous[t, coinduced f t] f :=
continuous_iff_coinduced_le.2 le_rfl
theorem continuous_coinduced_dom {g : Ξ² β Ξ³} {tβ : TopologicalSpace Ξ±} {tβ : TopologicalSpace Ξ³} :
Continuous[coinduced f tβ, tβ] g β Continuous[tβ, tβ] (g β f) := by
simp only [continuous_iff_coinduced_le, coinduced_compose]
| Mathlib/Topology/Order.lean | 644 | 646 | theorem continuous_le_dom {tβ tβ : TopologicalSpace Ξ±} {tβ : TopologicalSpace Ξ²} (hβ : tβ β€ tβ)
(hβ : Continuous[tβ, tβ] f) : Continuous[tβ, tβ] f := by | rw [continuous_iff_le_induced] at hβ β’ |
/-
Copyright (c) 2019 Jeremy Avigad. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jeremy Avigad, SΓ©bastien GouΓ«zel, Yury Kudryashov
-/
import Mathlib.Analysis.Calculus.FDeriv.Linear
import Mathlib.Analysis.Calculus.FDeriv.Comp
/-!
# Additive operations on derivatives
For detailed documentation of the FrΓ©chet derivative,
see the module docstring of `Analysis/Calculus/FDeriv/Basic.lean`.
This file contains the usual formulas (and existence assertions) for the derivative of
* sum of finitely many functions
* multiplication of a function by a scalar constant
* negative of a function
* subtraction of two functions
-/
open Filter Asymptotics ContinuousLinearMap
noncomputable section
section
variable {π : Type*} [NontriviallyNormedField π]
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace π E]
variable {F : Type*} [NormedAddCommGroup F] [NormedSpace π F]
variable {f g : E β F}
variable {f' g' : E βL[π] F}
variable {x : E}
variable {s : Set E}
variable {L : Filter E}
section ConstSMul
variable {R : Type*} [Semiring R] [Module R F] [SMulCommClass π R F] [ContinuousConstSMul R F]
/-! ### Derivative of a function multiplied by a constant -/
@[fun_prop]
theorem HasStrictFDerivAt.const_smul (h : HasStrictFDerivAt f f' x) (c : R) :
HasStrictFDerivAt (fun x => c β’ f x) (c β’ f') x :=
(c β’ (1 : F βL[π] F)).hasStrictFDerivAt.comp x h
theorem HasFDerivAtFilter.const_smul (h : HasFDerivAtFilter f f' x L) (c : R) :
HasFDerivAtFilter (fun x => c β’ f x) (c β’ f') x L :=
(c β’ (1 : F βL[π] F)).hasFDerivAtFilter.comp x h tendsto_map
@[fun_prop]
nonrec theorem HasFDerivWithinAt.const_smul (h : HasFDerivWithinAt f f' s x) (c : R) :
HasFDerivWithinAt (fun x => c β’ f x) (c β’ f') s x :=
h.const_smul c
@[fun_prop]
nonrec theorem HasFDerivAt.const_smul (h : HasFDerivAt f f' x) (c : R) :
HasFDerivAt (fun x => c β’ f x) (c β’ f') x :=
h.const_smul c
@[fun_prop]
theorem DifferentiableWithinAt.const_smul (h : DifferentiableWithinAt π f s x) (c : R) :
DifferentiableWithinAt π (fun y => c β’ f y) s x :=
(h.hasFDerivWithinAt.const_smul c).differentiableWithinAt
@[fun_prop]
theorem DifferentiableAt.const_smul (h : DifferentiableAt π f x) (c : R) :
DifferentiableAt π (fun y => c β’ f y) x :=
(h.hasFDerivAt.const_smul c).differentiableAt
@[fun_prop]
theorem DifferentiableOn.const_smul (h : DifferentiableOn π f s) (c : R) :
DifferentiableOn π (fun y => c β’ f y) s := fun x hx => (h x hx).const_smul c
@[fun_prop]
theorem Differentiable.const_smul (h : Differentiable π f) (c : R) :
Differentiable π fun y => c β’ f y := fun x => (h x).const_smul c
theorem fderivWithin_const_smul (hxs : UniqueDiffWithinAt π s x)
(h : DifferentiableWithinAt π f s x) (c : R) :
fderivWithin π (fun y => c β’ f y) s x = c β’ fderivWithin π f s x :=
(h.hasFDerivWithinAt.const_smul c).fderivWithin hxs
/-- Version of `fderivWithin_const_smul` written with `c β’ f` instead of `fun y β¦ c β’ f y`. -/
theorem fderivWithin_const_smul' (hxs : UniqueDiffWithinAt π s x)
(h : DifferentiableWithinAt π f s x) (c : R) :
fderivWithin π (c β’ f) s x = c β’ fderivWithin π f s x :=
fderivWithin_const_smul hxs h c
theorem fderiv_const_smul (h : DifferentiableAt π f x) (c : R) :
fderiv π (fun y => c β’ f y) x = c β’ fderiv π f x :=
(h.hasFDerivAt.const_smul c).fderiv
/-- Version of `fderiv_const_smul` written with `c β’ f` instead of `fun y β¦ c β’ f y`. -/
theorem fderiv_const_smul' (h : DifferentiableAt π f x) (c : R) :
fderiv π (c β’ f) x = c β’ fderiv π f x :=
(h.hasFDerivAt.const_smul c).fderiv
end ConstSMul
section Add
/-! ### Derivative of the sum of two functions -/
@[fun_prop]
nonrec theorem HasStrictFDerivAt.add (hf : HasStrictFDerivAt f f' x)
(hg : HasStrictFDerivAt g g' x) : HasStrictFDerivAt (fun y => f y + g y) (f' + g') x :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun y => by
simp only [LinearMap.sub_apply, LinearMap.add_apply, map_sub, map_add, add_apply]
abel
theorem HasFDerivAtFilter.add (hf : HasFDerivAtFilter f f' x L)
(hg : HasFDerivAtFilter g g' x L) : HasFDerivAtFilter (fun y => f y + g y) (f' + g') x L :=
.of_isLittleO <| (hf.isLittleO.add hg.isLittleO).congr_left fun _ => by
simp only [LinearMap.sub_apply, LinearMap.add_apply, map_sub, map_add, add_apply]
abel
@[fun_prop]
nonrec theorem HasFDerivWithinAt.add (hf : HasFDerivWithinAt f f' s x)
(hg : HasFDerivWithinAt g g' s x) : HasFDerivWithinAt (fun y => f y + g y) (f' + g') s x :=
hf.add hg
@[fun_prop]
nonrec theorem HasFDerivAt.add (hf : HasFDerivAt f f' x) (hg : HasFDerivAt g g' x) :
HasFDerivAt (fun x => f x + g x) (f' + g') x :=
hf.add hg
@[fun_prop]
theorem DifferentiableWithinAt.add (hf : DifferentiableWithinAt π f s x)
(hg : DifferentiableWithinAt π g s x) : DifferentiableWithinAt π (fun y => f y + g y) s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).differentiableWithinAt
@[simp, fun_prop]
theorem DifferentiableAt.add (hf : DifferentiableAt π f x) (hg : DifferentiableAt π g x) :
DifferentiableAt π (fun y => f y + g y) x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).differentiableAt
@[fun_prop]
theorem DifferentiableOn.add (hf : DifferentiableOn π f s) (hg : DifferentiableOn π g s) :
DifferentiableOn π (fun y => f y + g y) s := fun x hx => (hf x hx).add (hg x hx)
@[simp, fun_prop]
theorem Differentiable.add (hf : Differentiable π f) (hg : Differentiable π g) :
Differentiable π fun y => f y + g y := fun x => (hf x).add (hg x)
theorem fderivWithin_add (hxs : UniqueDiffWithinAt π s x) (hf : DifferentiableWithinAt π f s x)
(hg : DifferentiableWithinAt π g s x) :
fderivWithin π (fun y => f y + g y) s x = fderivWithin π f s x + fderivWithin π g s x :=
(hf.hasFDerivWithinAt.add hg.hasFDerivWithinAt).fderivWithin hxs
/-- Version of `fderivWithin_add` where the function is written as `f + g` instead
of `fun y β¦ f y + g y`. -/
theorem fderivWithin_add' (hxs : UniqueDiffWithinAt π s x) (hf : DifferentiableWithinAt π f s x)
(hg : DifferentiableWithinAt π g s x) :
fderivWithin π (f + g) s x = fderivWithin π f s x + fderivWithin π g s x :=
fderivWithin_add hxs hf hg
theorem fderiv_add (hf : DifferentiableAt π f x) (hg : DifferentiableAt π g x) :
fderiv π (fun y => f y + g y) x = fderiv π f x + fderiv π g x :=
(hf.hasFDerivAt.add hg.hasFDerivAt).fderiv
/-- Version of `fderiv_add` where the function is written as `f + g` instead
of `fun y β¦ f y + g y`. -/
theorem fderiv_add' (hf : DifferentiableAt π f x) (hg : DifferentiableAt π g x) :
fderiv π (f + g) x = fderiv π f x + fderiv π g x :=
fderiv_add hf hg
@[simp]
theorem hasFDerivAtFilter_add_const_iff (c : F) :
HasFDerivAtFilter (f Β· + c) f' x L β HasFDerivAtFilter f f' x L := by
simp [hasFDerivAtFilter_iff_isLittleOTVS]
alias β¨_, HasFDerivAtFilter.add_constβ© := hasFDerivAtFilter_add_const_iff
@[simp]
theorem hasStrictFDerivAt_add_const_iff (c : F) :
HasStrictFDerivAt (f Β· + c) f' x β HasStrictFDerivAt f f' x := by
simp [hasStrictFDerivAt_iff_isLittleO]
@[fun_prop]
alias β¨_, HasStrictFDerivAt.add_constβ© := hasStrictFDerivAt_add_const_iff
@[simp]
theorem hasFDerivWithinAt_add_const_iff (c : F) :
HasFDerivWithinAt (f Β· + c) f' s x β HasFDerivWithinAt f f' s x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias β¨_, HasFDerivWithinAt.add_constβ© := hasFDerivWithinAt_add_const_iff
@[simp]
theorem hasFDerivAt_add_const_iff (c : F) : HasFDerivAt (f Β· + c) f' x β HasFDerivAt f f' x :=
hasFDerivAtFilter_add_const_iff c
@[fun_prop]
alias β¨_, HasFDerivAt.add_constβ© := hasFDerivAt_add_const_iff
@[simp]
theorem differentiableWithinAt_add_const_iff (c : F) :
DifferentiableWithinAt π (fun y => f y + c) s x β DifferentiableWithinAt π f s x :=
exists_congr fun _ β¦ hasFDerivWithinAt_add_const_iff c
@[fun_prop]
alias β¨_, DifferentiableWithinAt.add_constβ© := differentiableWithinAt_add_const_iff
@[simp]
theorem differentiableAt_add_const_iff (c : F) :
DifferentiableAt π (fun y => f y + c) x β DifferentiableAt π f x :=
exists_congr fun _ β¦ hasFDerivAt_add_const_iff c
@[fun_prop]
alias β¨_, DifferentiableAt.add_constβ© := differentiableAt_add_const_iff
@[simp]
theorem differentiableOn_add_const_iff (c : F) :
DifferentiableOn π (fun y => f y + c) s β DifferentiableOn π f s :=
forallβ_congr fun _ _ β¦ differentiableWithinAt_add_const_iff c
@[fun_prop]
alias β¨_, DifferentiableOn.add_constβ© := differentiableOn_add_const_iff
@[simp]
theorem differentiable_add_const_iff (c : F) :
(Differentiable π fun y => f y + c) β Differentiable π f :=
forall_congr' fun _ β¦ differentiableAt_add_const_iff c
@[fun_prop]
alias β¨_, Differentiable.add_constβ© := differentiable_add_const_iff
@[simp]
theorem fderivWithin_add_const (c : F) :
fderivWithin π (fun y => f y + c) s x = fderivWithin π f s x := by
classical simp [fderivWithin]
@[simp]
| Mathlib/Analysis/Calculus/FDeriv/Add.lean | 240 | 242 | theorem fderiv_add_const (c : F) : fderiv π (fun y => f y + c) x = fderiv π f x := by | simp only [β fderivWithin_univ, fderivWithin_add_const] |
/-
Copyright (c) 2021 SΓ©bastien GouΓ«zel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: SΓ©bastien GouΓ«zel
-/
import Mathlib.Data.Matrix.Basis
import Mathlib.Data.Matrix.DMatrix
import Mathlib.LinearAlgebra.Matrix.Determinant.Basic
import Mathlib.LinearAlgebra.Matrix.Reindex
import Mathlib.Tactic.FieldSimp
/-!
# Transvections
Transvections are matrices of the form `1 + stdBasisMatrix i j c`, where `stdBasisMatrix i j c`
is the basic matrix with a `c` at position `(i, j)`. Multiplying by such a transvection on the left
(resp. on the right) amounts to adding `c` times the `j`-th row to the `i`-th row
(resp `c` times the `i`-th column to the `j`-th column). Therefore, they are useful to present
algorithms operating on rows and columns.
Transvections are a special case of *elementary matrices* (according to most references, these also
contain the matrices exchanging rows, and the matrices multiplying a row by a constant).
We show that, over a field, any matrix can be written as `L * D * L'`, where `L` and `L'` are
products of transvections and `D` is diagonal. In other words, one can reduce a matrix to diagonal
form by operations on its rows and columns, a variant of Gauss' pivot algorithm.
## Main definitions and results
* `transvection i j c` is the matrix equal to `1 + stdBasisMatrix i j c`.
* `TransvectionStruct n R` is a structure containing the data of `i, j, c` and a proof that
`i β j`. These are often easier to manipulate than straight matrices, especially in inductive
arguments.
* `exists_list_transvec_mul_diagonal_mul_list_transvec` states that any matrix `M` over a field can
be written in the form `t_1 * ... * t_k * D * t'_1 * ... * t'_l`, where `D` is diagonal and
the `t_i`, `t'_j` are transvections.
* `diagonal_transvection_induction` shows that a property which is true for diagonal matrices and
transvections, and invariant under product, is true for all matrices.
* `diagonal_transvection_induction_of_det_ne_zero` is the same statement over invertible matrices.
## Implementation details
The proof of the reduction results is done inductively on the size of the matrices, reducing an
`(r + 1) Γ (r + 1)` matrix to a matrix whose last row and column are zeroes, except possibly for
the last diagonal entry. This step is done as follows.
If all the coefficients on the last row and column are zero, there is nothing to do. Otherwise,
one can put a nonzero coefficient in the last diagonal entry by a row or column operation, and then
subtract this last diagonal entry from the other entries in the last row and column to make them
vanish.
This step is done in the type `Fin r β Unit`, where `Fin r` is useful to choose arbitrarily some
order in which we cancel the coefficients, and the sum structure is useful to use the formalism of
block matrices.
To proceed with the induction, we reindex our matrices to reduce to the above situation.
-/
universe uβ uβ
namespace Matrix
variable (n p : Type*) (R : Type uβ) {π : Type*} [Field π]
variable [DecidableEq n] [DecidableEq p]
variable [CommRing R]
section Transvection
variable {R n} (i j : n)
/-- The transvection matrix `transvection i j c` is equal to the identity plus `c` at position
`(i, j)`. Multiplying by it on the left (as in `transvection i j c * M`) corresponds to adding
`c` times the `j`-th row of `M` to its `i`-th row. Multiplying by it on the right corresponds
to adding `c` times the `i`-th column to the `j`-th column. -/
def transvection (c : R) : Matrix n n R :=
1 + Matrix.stdBasisMatrix i j c
@[simp]
theorem transvection_zero : transvection i j (0 : R) = 1 := by simp [transvection]
section
/-- A transvection matrix is obtained from the identity by adding `c` times the `j`-th row to
the `i`-th row. -/
theorem updateRow_eq_transvection [Finite n] (c : R) :
updateRow (1 : Matrix n n R) i ((1 : Matrix n n R) i + c β’ (1 : Matrix n n R) j) =
transvection i j c := by
cases nonempty_fintype n
ext a b
by_cases ha : i = a
Β· by_cases hb : j = b
Β· simp only [ha, updateRow_self, Pi.add_apply, one_apply, Pi.smul_apply, hb, βreduceIte,
smul_eq_mul, mul_one, transvection, add_apply, StdBasisMatrix.apply_same]
Β· simp only [ha, updateRow_self, Pi.add_apply, one_apply, Pi.smul_apply, hb, βreduceIte,
smul_eq_mul, mul_zero, add_zero, transvection, add_apply, and_false, not_false_eq_true,
StdBasisMatrix.apply_of_ne]
Β· simp only [updateRow_ne, transvection, ha, Ne.symm ha, StdBasisMatrix.apply_of_ne, add_zero,
Algebra.id.smul_eq_mul, Ne, not_false_iff, DMatrix.add_apply, Pi.smul_apply,
mul_zero, false_and, add_apply]
variable [Fintype n]
theorem transvection_mul_transvection_same (h : i β j) (c d : R) :
transvection i j c * transvection i j d = transvection i j (c + d) := by
simp [transvection, Matrix.add_mul, Matrix.mul_add, h, h.symm, add_smul, add_assoc,
stdBasisMatrix_add]
@[simp]
theorem transvection_mul_apply_same (b : n) (c : R) (M : Matrix n n R) :
(transvection i j c * M) i b = M i b + c * M j b := by simp [transvection, Matrix.add_mul]
@[simp]
theorem mul_transvection_apply_same (a : n) (c : R) (M : Matrix n n R) :
(M * transvection i j c) a j = M a j + c * M a i := by
simp [transvection, Matrix.mul_add, mul_comm]
@[simp]
theorem transvection_mul_apply_of_ne (a b : n) (ha : a β i) (c : R) (M : Matrix n n R) :
(transvection i j c * M) a b = M a b := by simp [transvection, Matrix.add_mul, ha]
@[simp]
theorem mul_transvection_apply_of_ne (a b : n) (hb : b β j) (c : R) (M : Matrix n n R) :
(M * transvection i j c) a b = M a b := by simp [transvection, Matrix.mul_add, hb]
@[simp]
theorem det_transvection_of_ne (h : i β j) (c : R) : det (transvection i j c) = 1 := by
rw [β updateRow_eq_transvection i j, det_updateRow_add_smul_self _ h, det_one]
end
variable (R n)
/-- A structure containing all the information from which one can build a nontrivial transvection.
This structure is easier to manipulate than transvections as one has a direct access to all the
relevant fields. -/
structure TransvectionStruct where
(i j : n)
hij : i β j
c : R
instance [Nontrivial n] : Nonempty (TransvectionStruct n R) := by
choose x y hxy using exists_pair_ne n
exact β¨β¨x, y, hxy, 0β©β©
namespace TransvectionStruct
variable {R n}
/-- Associating to a `transvection_struct` the corresponding transvection matrix. -/
def toMatrix (t : TransvectionStruct n R) : Matrix n n R :=
transvection t.i t.j t.c
@[simp]
theorem toMatrix_mk (i j : n) (hij : i β j) (c : R) :
TransvectionStruct.toMatrix β¨i, j, hij, cβ© = transvection i j c :=
rfl
@[simp]
protected theorem det [Fintype n] (t : TransvectionStruct n R) : det t.toMatrix = 1 :=
det_transvection_of_ne _ _ t.hij _
@[simp]
theorem det_toMatrix_prod [Fintype n] (L : List (TransvectionStruct n π)) :
det (L.map toMatrix).prod = 1 := by
induction L with
| nil => simp
| cons _ _ IH => simp [IH]
/-- The inverse of a `TransvectionStruct`, designed so that `t.inv.toMatrix` is the inverse of
`t.toMatrix`. -/
@[simps]
protected def inv (t : TransvectionStruct n R) : TransvectionStruct n R where
i := t.i
j := t.j
hij := t.hij
c := -t.c
section
variable [Fintype n]
theorem inv_mul (t : TransvectionStruct n R) : t.inv.toMatrix * t.toMatrix = 1 := by
rcases t with β¨_, _, t_hijβ©
simp [toMatrix, transvection_mul_transvection_same, t_hij]
theorem mul_inv (t : TransvectionStruct n R) : t.toMatrix * t.inv.toMatrix = 1 := by
rcases t with β¨_, _, t_hijβ©
simp [toMatrix, transvection_mul_transvection_same, t_hij]
theorem reverse_inv_prod_mul_prod (L : List (TransvectionStruct n R)) :
(L.reverse.map (toMatrix β TransvectionStruct.inv)).prod * (L.map toMatrix).prod = 1 := by
induction L with
| nil => simp
| cons t L IH =>
suffices
(L.reverse.map (toMatrix β TransvectionStruct.inv)).prod * (t.inv.toMatrix * t.toMatrix) *
(L.map toMatrix).prod = 1
by simpa [Matrix.mul_assoc]
simpa [inv_mul] using IH
theorem prod_mul_reverse_inv_prod (L : List (TransvectionStruct n R)) :
(L.map toMatrix).prod * (L.reverse.map (toMatrix β TransvectionStruct.inv)).prod = 1 := by
induction L with
| nil => simp
| cons t L IH =>
suffices
t.toMatrix *
((L.map toMatrix).prod * (L.reverse.map (toMatrix β TransvectionStruct.inv)).prod) *
t.inv.toMatrix = 1
by simpa [Matrix.mul_assoc]
simp_rw [IH, Matrix.mul_one, t.mul_inv]
/-- `M` is a scalar matrix if it commutes with every nontrivial transvection (elementary matrix). -/
theorem _root_.Matrix.mem_range_scalar_of_commute_transvectionStruct {M : Matrix n n R}
(hM : β t : TransvectionStruct n R, Commute t.toMatrix M) :
M β Set.range (Matrix.scalar n) := by
refine mem_range_scalar_of_commute_stdBasisMatrix ?_
intro i j hij
simpa [transvection, mul_add, add_mul] using (hM β¨i, j, hij, 1β©).eq
theorem _root_.Matrix.mem_range_scalar_iff_commute_transvectionStruct {M : Matrix n n R} :
M β Set.range (Matrix.scalar n) β β t : TransvectionStruct n R, Commute t.toMatrix M := by
refine β¨fun h t => ?_, mem_range_scalar_of_commute_transvectionStructβ©
rw [mem_range_scalar_iff_commute_stdBasisMatrix] at h
refine (Commute.one_left M).add_left ?_
convert (h _ _ t.hij).smul_left t.c using 1
rw [smul_stdBasisMatrix, smul_eq_mul, mul_one]
end
open Sum
/-- Given a `TransvectionStruct` on `n`, define the corresponding `TransvectionStruct` on `n β p`
using the identity on `p`. -/
def sumInl (t : TransvectionStruct n R) : TransvectionStruct (n β p) R where
i := inl t.i
j := inl t.j
hij := by simp [t.hij]
c := t.c
theorem toMatrix_sumInl (t : TransvectionStruct n R) :
(t.sumInl p).toMatrix = fromBlocks t.toMatrix 0 0 1 := by
cases t
ext a b
rcases a with a | a <;> rcases b with b | b
Β· by_cases h : a = b <;> simp [TransvectionStruct.sumInl, transvection, h, stdBasisMatrix]
Β· simp [TransvectionStruct.sumInl, transvection]
Β· simp [TransvectionStruct.sumInl, transvection]
Β· by_cases h : a = b <;> simp [TransvectionStruct.sumInl, transvection, h]
@[simp]
theorem sumInl_toMatrix_prod_mul [Fintype n] [Fintype p] (M : Matrix n n R)
(L : List (TransvectionStruct n R)) (N : Matrix p p R) :
(L.map (toMatrix β sumInl p)).prod * fromBlocks M 0 0 N =
fromBlocks ((L.map toMatrix).prod * M) 0 0 N := by
induction L with
| nil => simp
| cons t L IH => simp [Matrix.mul_assoc, IH, toMatrix_sumInl, fromBlocks_multiply]
@[simp]
theorem mul_sumInl_toMatrix_prod [Fintype n] [Fintype p] (M : Matrix n n R)
(L : List (TransvectionStruct n R)) (N : Matrix p p R) :
fromBlocks M 0 0 N * (L.map (toMatrix β sumInl p)).prod =
fromBlocks (M * (L.map toMatrix).prod) 0 0 N := by
induction L generalizing M N with
| nil => simp
| cons t L IH => simp [IH, toMatrix_sumInl, fromBlocks_multiply]
variable {p}
/-- Given a `TransvectionStruct` on `n` and an equivalence between `n` and `p`, define the
corresponding `TransvectionStruct` on `p`. -/
def reindexEquiv (e : n β p) (t : TransvectionStruct n R) : TransvectionStruct p R where
i := e t.i
j := e t.j
hij := by simp [t.hij]
c := t.c
variable [Fintype n] [Fintype p]
theorem toMatrix_reindexEquiv (e : n β p) (t : TransvectionStruct n R) :
(t.reindexEquiv e).toMatrix = reindexAlgEquiv R _ e t.toMatrix := by
rcases t with β¨t_i, t_j, _β©
ext a b
simp only [reindexEquiv, transvection, mul_boole, Algebra.id.smul_eq_mul, toMatrix_mk,
submatrix_apply, reindex_apply, DMatrix.add_apply, Pi.smul_apply, reindexAlgEquiv_apply]
by_cases ha : e t_i = a <;> by_cases hb : e t_j = b <;> by_cases hab : a = b <;>
simp [ha, hb, hab, β e.apply_eq_iff_eq_symm_apply, stdBasisMatrix]
theorem toMatrix_reindexEquiv_prod (e : n β p) (L : List (TransvectionStruct n R)) :
(L.map (toMatrix β reindexEquiv e)).prod = reindexAlgEquiv R _ e (L.map toMatrix).prod := by
induction L with
| nil => simp
| cons t L IH =>
simp only [toMatrix_reindexEquiv, IH, Function.comp_apply, List.prod_cons,
reindexAlgEquiv_apply, List.map]
exact (reindexAlgEquiv_mul R _ _ _ _).symm
end TransvectionStruct
end Transvection
/-!
# Reducing matrices by left and right multiplication by transvections
In this section, we show that any matrix can be reduced to diagonal form by left and right
multiplication by transvections (or, equivalently, by elementary operations on lines and columns).
The main step is to kill the last row and column of a matrix in `Fin r β Unit` with nonzero last
coefficient, by subtracting this coefficient from the other ones. The list of these operations is
recorded in `list_transvec_col M` and `list_transvec_row M`. We have to analyze inductively how
these operations affect the coefficients in the last row and the last column to conclude that they
have the desired effect.
Once this is done, one concludes the reduction by induction on the size
of the matrices, through a suitable reindexing to identify any fintype with `Fin r β Unit`.
-/
namespace Pivot
variable {R} {r : β} (M : Matrix (Fin r β Unit) (Fin r β Unit) π)
open Unit Sum Fin TransvectionStruct
/-- A list of transvections such that multiplying on the left with these transvections will replace
the last column with zeroes. -/
def listTransvecCol : List (Matrix (Fin r β Unit) (Fin r β Unit) π) :=
List.ofFn fun i : Fin r =>
transvection (inl i) (inr unit) <| -M (inl i) (inr unit) / M (inr unit) (inr unit)
/-- A list of transvections such that multiplying on the right with these transvections will replace
the last row with zeroes. -/
def listTransvecRow : List (Matrix (Fin r β Unit) (Fin r β Unit) π) :=
List.ofFn fun i : Fin r =>
transvection (inr unit) (inl i) <| -M (inr unit) (inl i) / M (inr unit) (inr unit)
@[simp]
theorem length_listTransvecCol : (listTransvecCol M).length = r := by simp [listTransvecCol]
theorem listTransvecCol_getElem {i : β} (h : i < (listTransvecCol M).length) :
(listTransvecCol M)[i] =
letI i' : Fin r := β¨i, length_listTransvecCol M βΈ hβ©
transvection (inl i') (inr unit) <| -M (inl i') (inr unit) / M (inr unit) (inr unit) := by
simp [listTransvecCol]
@[simp]
theorem length_listTransvecRow : (listTransvecRow M).length = r := by simp [listTransvecRow]
theorem listTransvecRow_getElem {i : β} (h : i < (listTransvecRow M).length) :
(listTransvecRow M)[i] =
letI i' : Fin r := β¨i, length_listTransvecRow M βΈ hβ©
transvection (inr unit) (inl i') <| -M (inr unit) (inl i') / M (inr unit) (inr unit) := by
simp [listTransvecRow, Fin.cast]
/-- Multiplying by some of the matrices in `listTransvecCol M` does not change the last row. -/
theorem listTransvecCol_mul_last_row_drop (i : Fin r β Unit) {k : β} (hk : k β€ r) :
(((listTransvecCol M).drop k).prod * M) (inr unit) i = M (inr unit) i := by
induction hk using Nat.decreasingInduction with
| of_succ n hn IH =>
have hn' : n < (listTransvecCol M).length := by simpa [listTransvecCol] using hn
rw [List.drop_eq_getElem_cons hn']
simpa [listTransvecCol, Matrix.mul_assoc]
| self =>
simp only [length_listTransvecCol, le_refl, List.drop_eq_nil_of_le, List.prod_nil,
Matrix.one_mul]
/-- Multiplying by all the matrices in `listTransvecCol M` does not change the last row. -/
| Mathlib/LinearAlgebra/Matrix/Transvection.lean | 371 | 380 | theorem listTransvecCol_mul_last_row (i : Fin r β Unit) :
((listTransvecCol M).prod * M) (inr unit) i = M (inr unit) i := by | simpa using listTransvecCol_mul_last_row_drop M i (zero_le _)
/-- Multiplying by all the matrices in `listTransvecCol M` kills all the coefficients in the
last column but the last one. -/
theorem listTransvecCol_mul_last_col (hM : M (inr unit) (inr unit) β 0) (i : Fin r) :
((listTransvecCol M).prod * M) (inl i) (inr unit) = 0 := by
suffices H :
β k : β, |
/-
Copyright (c) 2020 Simon Hudon. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Simon Hudon, YaΓ«l Dillies
-/
import Mathlib.Order.Interval.Set.Defs
import Mathlib.Order.Monotone.Basic
import Mathlib.Tactic.Bound.Attribute
import Mathlib.Tactic.Contrapose
import Mathlib.Tactic.Monotonicity.Attr
/-!
# Natural number logarithms
This file defines two `β`-valued analogs of the logarithm of `n` with base `b`:
* `log b n`: Lower logarithm, or floor **log**. Greatest `k` such that `b^k β€ n`.
* `clog b n`: Upper logarithm, or **c**eil **log**. Least `k` such that `n β€ b^k`.
These are interesting because, for `1 < b`, `Nat.log b` and `Nat.clog b` are respectively right and
left adjoints of `Nat.pow b`. See `pow_le_iff_le_log` and `le_pow_iff_clog_le`.
-/
assert_not_exists OrderTop
namespace Nat
/-! ### Floor logarithm -/
/-- `log b n`, is the logarithm of natural number `n` in base `b`. It returns the largest `k : β`
such that `b^k β€ n`, so if `b^k = n`, it returns exactly `k`. -/
@[pp_nodot]
def log (b : β) : β β β
| n => if h : b β€ n β§ 1 < b then log b (n / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : n / b < n := div_lt_self ((Nat.zero_lt_one.trans h.2).trans_le h.1) h.2
decreasing_trivial
@[simp]
theorem log_eq_zero_iff {b n : β} : log b n = 0 β n < b β¨ b β€ 1 := by
rw [log, dite_eq_right_iff]
simp only [Nat.add_eq_zero_iff, Nat.one_ne_zero, and_false, imp_false, not_and_or, not_le, not_lt]
theorem log_of_lt {b n : β} (hb : n < b) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inl hb)
theorem log_of_left_le_one {b : β} (hb : b β€ 1) (n) : log b n = 0 :=
log_eq_zero_iff.2 (Or.inr hb)
@[simp]
theorem log_pos_iff {b n : β} : 0 < log b n β b β€ n β§ 1 < b := by
rw [Nat.pos_iff_ne_zero, Ne, log_eq_zero_iff, not_or, not_lt, not_le]
@[bound]
theorem log_pos {b n : β} (hb : 1 < b) (hbn : b β€ n) : 0 < log b n :=
log_pos_iff.2 β¨hbn, hbβ©
theorem log_of_one_lt_of_le {b n : β} (h : 1 < b) (hn : b β€ n) : log b n = log b (n / b) + 1 := by
rw [log]
exact if_pos β¨hn, hβ©
@[simp] lemma log_zero_left : β n, log 0 n = 0 := log_of_left_le_one <| Nat.zero_le _
@[simp]
theorem log_zero_right (b : β) : log b 0 = 0 :=
log_eq_zero_iff.2 (le_total 1 b)
@[simp]
theorem log_one_left : β n, log 1 n = 0 :=
log_of_left_le_one le_rfl
@[simp]
theorem log_one_right (b : β) : log b 1 = 0 :=
log_eq_zero_iff.2 (lt_or_le _ _)
/-- `pow b` and `log b` (almost) form a Galois connection. See also `Nat.pow_le_of_le_log` and
`Nat.le_log_of_pow_le` for individual implications under weaker assumptions. -/
theorem pow_le_iff_le_log {b : β} (hb : 1 < b) {x y : β} (hy : y β 0) :
b ^ x β€ y β x β€ log b y := by
induction y using Nat.strong_induction_on generalizing x with | h y ih => ?_
cases x with
| zero => dsimp; omega
| succ x =>
rw [log]; split_ifs with h
Β· have b_pos : 0 < b := lt_of_succ_lt hb
rw [Nat.add_le_add_iff_right, β ih (y / b) (div_lt_self
(Nat.pos_iff_ne_zero.2 hy) hb) (Nat.div_pos h.1 b_pos).ne', le_div_iff_mul_le b_pos,
pow_succ', Nat.mul_comm]
Β· exact iff_of_false (fun hby => h β¨(le_self_pow x.succ_ne_zero _).trans hby, hbβ©)
(not_succ_le_zero _)
theorem lt_pow_iff_log_lt {b : β} (hb : 1 < b) {x y : β} (hy : y β 0) : y < b ^ x β log b y < x :=
lt_iff_lt_of_le_iff_le (pow_le_iff_le_log hb hy)
theorem pow_le_of_le_log {b x y : β} (hy : y β 0) (h : x β€ log b y) : b ^ x β€ y := by
refine (le_or_lt b 1).elim (fun hb => ?_) fun hb => (pow_le_iff_le_log hb hy).2 h
rw [log_of_left_le_one hb, Nat.le_zero] at h
rwa [h, Nat.pow_zero, one_le_iff_ne_zero]
theorem le_log_of_pow_le {b x y : β} (hb : 1 < b) (h : b ^ x β€ y) : x β€ log b y := by
rcases ne_or_eq y 0 with (hy | rfl)
exacts [(pow_le_iff_le_log hb hy).1 h, (h.not_lt (Nat.pow_pos (Nat.zero_lt_one.trans hb))).elim]
theorem pow_log_le_self (b : β) {x : β} (hx : x β 0) : b ^ log b x β€ x :=
pow_le_of_le_log hx le_rfl
theorem log_lt_of_lt_pow {b x y : β} (hy : y β 0) : y < b ^ x β log b y < x :=
lt_imp_lt_of_le_imp_le (pow_le_of_le_log hy)
theorem lt_pow_of_log_lt {b x y : β} (hb : 1 < b) : log b y < x β y < b ^ x :=
lt_imp_lt_of_le_imp_le (le_log_of_pow_le hb)
lemma log_lt_self (b : β) {x : β} (hx : x β 0) : log b x < x :=
match le_or_lt b 1 with
| .inl h => log_of_left_le_one h x βΈ Nat.pos_iff_ne_zero.2 hx
| .inr h => log_lt_of_lt_pow hx <| Nat.lt_pow_self h
lemma log_le_self (b x : β) : log b x β€ x :=
if hx : x = 0 then by simp [hx]
else (log_lt_self b hx).le
theorem lt_pow_succ_log_self {b : β} (hb : 1 < b) (x : β) : x < b ^ (log b x).succ :=
lt_pow_of_log_lt hb (lt_succ_self _)
theorem log_eq_iff {b m n : β} (h : m β 0 β¨ 1 < b β§ n β 0) :
log b n = m β b ^ m β€ n β§ n < b ^ (m + 1) := by
rcases em (1 < b β§ n β 0) with (β¨hb, hnβ© | hbn)
Β· rw [le_antisymm_iff, β Nat.lt_succ_iff, β pow_le_iff_le_log, β lt_pow_iff_log_lt,
and_comm] <;> assumption
have hm : m β 0 := h.resolve_right hbn
rw [not_and_or, not_lt, Ne, not_not] at hbn
rcases hbn with (hb | rfl)
Β· obtain rfl | rfl := le_one_iff_eq_zero_or_eq_one.1 hb
any_goals
simp only [ne_eq, zero_eq, reduceSucc, lt_self_iff_false, not_lt_zero, false_and, or_false]
at h
simp [h, eq_comm (a := 0), Nat.zero_pow (Nat.pos_iff_ne_zero.2 _)] <;> omega
Β· simp [@eq_comm _ 0, hm]
theorem log_eq_of_pow_le_of_lt_pow {b m n : β} (hβ : b ^ m β€ n) (hβ : n < b ^ (m + 1)) :
log b n = m := by
rcases eq_or_ne m 0 with (rfl | hm)
Β· rw [Nat.pow_one] at hβ
exact log_of_lt hβ
Β· exact (log_eq_iff (Or.inl hm)).2 β¨hβ, hββ©
theorem log_pow {b : β} (hb : 1 < b) (x : β) : log b (b ^ x) = x :=
log_eq_of_pow_le_of_lt_pow le_rfl (Nat.pow_lt_pow_right hb x.lt_succ_self)
theorem log_eq_one_iff' {b n : β} : log b n = 1 β b β€ n β§ n < b * b := by
rw [log_eq_iff (Or.inl Nat.one_ne_zero), Nat.pow_add, Nat.pow_one]
theorem log_eq_one_iff {b n : β} : log b n = 1 β n < b * b β§ 1 < b β§ b β€ n :=
log_eq_one_iff'.trans
β¨fun h => β¨h.2, lt_mul_self_iff.1 (h.1.trans_lt h.2), h.1β©, fun h => β¨h.2.2, h.1β©β©
theorem log_mul_base {b n : β} (hb : 1 < b) (hn : n β 0) : log b (n * b) = log b n + 1 := by
apply log_eq_of_pow_le_of_lt_pow <;> rw [pow_succ', Nat.mul_comm b]
exacts [Nat.mul_le_mul_right _ (pow_log_le_self _ hn),
(Nat.mul_lt_mul_right (Nat.zero_lt_one.trans hb)).2 (lt_pow_succ_log_self hb _)]
theorem pow_log_le_add_one (b : β) : β x, b ^ log b x β€ x + 1
| 0 => by rw [log_zero_right, Nat.pow_zero]
| x + 1 => (pow_log_le_self b x.succ_ne_zero).trans (x + 1).le_succ
theorem log_monotone {b : β} : Monotone (log b) := by
refine monotone_nat_of_le_succ fun n => ?_
rcases le_or_lt b 1 with hb | hb
Β· rw [log_of_left_le_one hb]
exact zero_le _
Β· exact le_log_of_pow_le hb (pow_log_le_add_one _ _)
@[mono]
theorem log_mono_right {b n m : β} (h : n β€ m) : log b n β€ log b m :=
log_monotone h
@[mono]
theorem log_anti_left {b c n : β} (hc : 1 < c) (hb : c β€ b) : log b n β€ log c n := by
rcases eq_or_ne n 0 with (rfl | hn); Β· rw [log_zero_right, log_zero_right]
apply le_log_of_pow_le hc
calc
c ^ log b n β€ b ^ log b n := Nat.pow_le_pow_left hb _
_ β€ n := pow_log_le_self _ hn
theorem log_antitone_left {n : β} : AntitoneOn (fun b => log b n) (Set.Ioi 1) := fun _ hc _ _ hb =>
log_anti_left (Set.mem_Iio.1 hc) hb
@[simp]
theorem log_div_base (b n : β) : log b (n / b) = log b n - 1 := by
rcases le_or_lt b 1 with hb | hb
Β· rw [log_of_left_le_one hb, log_of_left_le_one hb, Nat.zero_sub]
rcases lt_or_le n b with h | h
Β· rw [div_eq_of_lt h, log_of_lt h, log_zero_right]
rw [log_of_one_lt_of_le hb h, Nat.add_sub_cancel_right]
@[simp]
theorem log_div_mul_self (b n : β) : log b (n / b * b) = log b n := by
rcases le_or_lt b 1 with hb | hb
Β· rw [log_of_left_le_one hb, log_of_left_le_one hb]
rcases lt_or_le n b with h | h
Β· rw [div_eq_of_lt h, Nat.zero_mul, log_zero_right, log_of_lt h]
rw [log_mul_base hb (Nat.div_pos h (by omega)).ne', log_div_base,
Nat.sub_add_cancel (succ_le_iff.2 <| log_pos hb h)]
theorem add_pred_div_lt {b n : β} (hb : 1 < b) (hn : 2 β€ n) : (n + b - 1) / b < n := by
rw [div_lt_iff_lt_mul (by omega), β succ_le_iff, β pred_eq_sub_one,
succ_pred_eq_of_pos (by omega)]
exact Nat.add_le_mul hn hb
lemma log2_eq_log_two {n : β} : Nat.log2 n = Nat.log 2 n := by
rcases eq_or_ne n 0 with rfl | hn
Β· rw [log2_zero, log_zero_right]
apply eq_of_forall_le_iff
intro m
rw [Nat.le_log2 hn, β Nat.pow_le_iff_le_log Nat.one_lt_two hn]
/-! ### Ceil logarithm -/
/-- `clog b n`, is the upper logarithm of natural number `n` in base `b`. It returns the smallest
`k : β` such that `n β€ b^k`, so if `b^k = n`, it returns exactly `k`. -/
@[pp_nodot]
def clog (b : β) : β β β
| n => if h : 1 < b β§ 1 < n then clog b ((n + b - 1) / b) + 1 else 0
decreasing_by
-- putting this in the def triggers the `unusedHavesSuffices` linter:
-- https://github.com/leanprover-community/batteries/issues/428
have : (n + b - 1) / b < n := add_pred_div_lt h.1 h.2
decreasing_trivial
theorem clog_of_left_le_one {b : β} (hb : b β€ 1) (n : β) : clog b n = 0 := by
rw [clog, dif_neg fun h : 1 < b β§ 1 < n => h.1.not_le hb]
theorem clog_of_right_le_one {n : β} (hn : n β€ 1) (b : β) : clog b n = 0 := by
rw [clog, dif_neg fun h : 1 < b β§ 1 < n => h.2.not_le hn]
@[simp] lemma clog_zero_left (n : β) : clog 0 n = 0 := clog_of_left_le_one (Nat.zero_le _) _
@[simp] lemma clog_zero_right (b : β) : clog b 0 = 0 := clog_of_right_le_one (Nat.zero_le _) _
@[simp]
theorem clog_one_left (n : β) : clog 1 n = 0 :=
clog_of_left_le_one le_rfl _
@[simp]
theorem clog_one_right (b : β) : clog b 1 = 0 :=
clog_of_right_le_one le_rfl _
| Mathlib/Data/Nat/Log.lean | 251 | 252 | theorem clog_of_two_le {b n : β} (hb : 1 < b) (hn : 2 β€ n) :
clog b n = clog b ((n + b - 1) / b) + 1 := by | rw [clog, dif_pos (β¨hb, hnβ© : 1 < b β§ 1 < n)] |
/-
Copyright (c) 2023 Josha Dekker. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Josha Dekker
-/
import Mathlib.Topology.Bases
import Mathlib.Order.Filter.CountableInter
import Mathlib.Topology.Compactness.SigmaCompact
/-!
# LindelΓΆf sets and LindelΓΆf spaces
## Main definitions
We define the following properties for sets in a topological space:
* `IsLindelof s`: Two definitions are possible here. The more standard definition is that
every open cover that contains `s` contains a countable subcover. We choose for the equivalent
definition where we require that every nontrivial filter on `s` with the countable intersection
property has a clusterpoint. Equivalence is established in `isLindelof_iff_countable_subcover`.
* `LindelofSpace X`: `X` is LindelΓΆf if it is LindelΓΆf as a set.
* `NonLindelofSpace`: a space that is not a LindΓ«lof space, e.g. the Long Line.
## Main results
* `isLindelof_iff_countable_subcover`: A set is LindelΓΆf iff every open cover has a
countable subcover.
## Implementation details
* This API is mainly based on the API for IsCompact and follows notation and style as much
as possible.
-/
open Set Filter Topology TopologicalSpace
universe u v
variable {X : Type u} {Y : Type v} {ΞΉ : Type*}
variable [TopologicalSpace X] [TopologicalSpace Y] {s t : Set X}
section Lindelof
/-- A set `s` is LindelΓΆf if every nontrivial filter `f` with the countable intersection
property that contains `s`, has a clusterpoint in `s`. The filter-free definition is given by
`isLindelof_iff_countable_subcover`. -/
def IsLindelof (s : Set X) :=
β β¦fβ¦ [NeBot f] [CountableInterFilter f], f β€ π s β β x β s, ClusterPt x f
/-- The complement to a LindelΓΆf set belongs to a filter `f` with the countable intersection
property if it belongs to each filter `π x β f`, `x β s`. -/
theorem IsLindelof.compl_mem_sets (hs : IsLindelof s) {f : Filter X} [CountableInterFilter f]
(hf : β x β s, sαΆ β π x β f) : sαΆ β f := by
contrapose! hf
simp only [not_mem_iff_inf_principal_compl, compl_compl, inf_assoc] at hf β’
exact hs inf_le_right
/-- The complement to a LindelΓΆf set belongs to a filter `f` with the countable intersection
property if each `x β s` has a neighborhood `t` within `s` such that `tαΆ` belongs to `f`. -/
theorem IsLindelof.compl_mem_sets_of_nhdsWithin (hs : IsLindelof s) {f : Filter X}
[CountableInterFilter f] (hf : β x β s, β t β π[s] x, tαΆ β f) : sαΆ β f := by
refine hs.compl_mem_sets fun x hx β¦ ?_
rw [β disjoint_principal_right, disjoint_right_comm, (basis_sets _).disjoint_iff_left]
exact hf x hx
/-- If `p : Set X β Prop` is stable under restriction and union, and each point `x`
of a LindelΓΆf set `s` has a neighborhood `t` within `s` such that `p t`, then `p s` holds. -/
@[elab_as_elim]
theorem IsLindelof.induction_on (hs : IsLindelof s) {p : Set X β Prop}
(hmono : β β¦s tβ¦, s β t β p t β p s)
(hcountable_union : β (S : Set (Set X)), S.Countable β (β s β S, p s) β p (ββ S))
(hnhds : β x β s, β t β π[s] x, p t) : p s := by
let f : Filter X := ofCountableUnion p hcountable_union (fun t ht _ hsub β¦ hmono hsub ht)
have : sαΆ β f := hs.compl_mem_sets_of_nhdsWithin (by simpa [f] using hnhds)
rwa [β compl_compl s]
/-- The intersection of a LindelΓΆf set and a closed set is a LindelΓΆf set. -/
theorem IsLindelof.inter_right (hs : IsLindelof s) (ht : IsClosed t) : IsLindelof (s β© t) := by
intro f hnf _ hstf
rw [β inf_principal, le_inf_iff] at hstf
obtain β¨x, hsx, hxβ© : β x β s, ClusterPt x f := hs hstf.1
have hxt : x β t := ht.mem_of_nhdsWithin_neBot <| hx.mono hstf.2
exact β¨x, β¨hsx, hxtβ©, hxβ©
/-- The intersection of a closed set and a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.inter_left (ht : IsLindelof t) (hs : IsClosed s) : IsLindelof (s β© t) :=
inter_comm t s βΈ ht.inter_right hs
/-- The set difference of a LindelΓΆf set and an open set is a LindelΓΆf set. -/
theorem IsLindelof.diff (hs : IsLindelof s) (ht : IsOpen t) : IsLindelof (s \ t) :=
hs.inter_right (isClosed_compl_iff.mpr ht)
/-- A closed subset of a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.of_isClosed_subset (hs : IsLindelof s) (ht : IsClosed t) (h : t β s) :
IsLindelof t := inter_eq_self_of_subset_right h βΈ hs.inter_right ht
/-- A continuous image of a LindelΓΆf set is a LindelΓΆf set. -/
theorem IsLindelof.image_of_continuousOn {f : X β Y} (hs : IsLindelof s) (hf : ContinuousOn f s) :
IsLindelof (f '' s) := by
intro l lne _ ls
have : NeBot (l.comap f β π s) :=
comap_inf_principal_neBot_of_image_mem lne (le_principal_iff.1 ls)
obtain β¨x, hxs, hxβ© : β x β s, ClusterPt x (l.comap f β π s) := @hs _ this _ inf_le_right
haveI := hx.neBot
use f x, mem_image_of_mem f hxs
have : Tendsto f (π x β (comap f l β π s)) (π (f x) β l) := by
convert (hf x hxs).inf (@tendsto_comap _ _ f l) using 1
rw [nhdsWithin]
ac_rfl
exact this.neBot
/-- A continuous image of a LindelΓΆf set is a LindelΓΆf set within the codomain. -/
theorem IsLindelof.image {f : X β Y} (hs : IsLindelof s) (hf : Continuous f) :
IsLindelof (f '' s) := hs.image_of_continuousOn hf.continuousOn
/-- A filter with the countable intersection property that is finer than the principal filter on
a LindelΓΆf set `s` contains any open set that contains all clusterpoints of `s`. -/
theorem IsLindelof.adherence_nhdset {f : Filter X} [CountableInterFilter f] (hs : IsLindelof s)
(hfβ : f β€ π s) (htβ : IsOpen t) (htβ : β x β s, ClusterPt x f β x β t) : t β f :=
(eq_or_neBot _).casesOn mem_of_eq_bot fun _ β¦
let β¨x, hx, hfxβ© := @hs (f β π tαΆ) _ _ <| inf_le_of_left_le hfβ
have : x β t := htβ x hx hfx.of_inf_left
have : tαΆ β© t β π[tαΆ] x := inter_mem_nhdsWithin _ (htβ.mem_nhds this)
have A : π[tαΆ] x = β₯ := empty_mem_iff_bot.1 <| compl_inter_self t βΈ this
have : π[tαΆ] x β β₯ := hfx.of_inf_right.ne
absurd A this
/-- For every open cover of a LindelΓΆf set, there exists a countable subcover. -/
theorem IsLindelof.elim_countable_subcover {ΞΉ : Type v} (hs : IsLindelof s) (U : ΞΉ β Set X)
(hUo : β i, IsOpen (U i)) (hsU : s β β i, U i) :
β r : Set ΞΉ, r.Countable β§ (s β β i β r, U i) := by
have hmono : β β¦s t : Set Xβ¦, s β t β (β r : Set ΞΉ, r.Countable β§ t β β i β r, U i)
β (β r : Set ΞΉ, r.Countable β§ s β β i β r, U i) := by
intro _ _ hst β¨r, β¨hrcountable, hsubβ©β©
exact β¨r, hrcountable, Subset.trans hst hsubβ©
have hcountable_union : β (S : Set (Set X)), S.Countable
β (β s β S, β r : Set ΞΉ, r.Countable β§ (s β β i β r, U i))
β β r : Set ΞΉ, r.Countable β§ (ββ S β β i β r, U i) := by
intro S hS hsr
choose! r hr using hsr
refine β¨β s β S, r s, hS.biUnion_iff.mpr (fun s hs β¦ (hr s hs).1), ?_β©
refine sUnion_subset ?h.right.h
simp only [mem_iUnion, exists_prop, iUnion_exists, biUnion_and']
exact fun i is x hx β¦ mem_biUnion is ((hr i is).2 hx)
have h_nhds : β x β s, β t β π[s] x, β r : Set ΞΉ, r.Countable β§ (t β β i β r, U i) := by
intro x hx
let β¨i, hiβ© := mem_iUnion.1 (hsU hx)
refine β¨U i, mem_nhdsWithin_of_mem_nhds ((hUo i).mem_nhds hi), {i}, by simp, ?_β©
simp only [mem_singleton_iff, iUnion_iUnion_eq_left]
exact Subset.refl _
exact hs.induction_on hmono hcountable_union h_nhds
theorem IsLindelof.elim_nhds_subcover' (hs : IsLindelof s) (U : β x β s, Set X)
(hU : β x (hx : x β s), U x βΉx β sβΊ β π x) :
β t : Set s, t.Countable β§ s β β x β t, U (x : s) x.2 := by
have := hs.elim_countable_subcover (fun x : s β¦ interior (U x x.2)) (fun _ β¦ isOpen_interior)
fun x hx β¦
mem_iUnion.2 β¨β¨x, hxβ©, mem_interior_iff_mem_nhds.2 <| hU _ _β©
rcases this with β¨r, β¨hr, hsβ©β©
use r, hr
apply Subset.trans hs
apply iUnionβ_subset
intro i hi
apply Subset.trans interior_subset
exact subset_iUnion_of_subset i (subset_iUnion_of_subset hi (Subset.refl _))
theorem IsLindelof.elim_nhds_subcover (hs : IsLindelof s) (U : X β Set X)
(hU : β x β s, U x β π x) :
β t : Set X, t.Countable β§ (β x β t, x β s) β§ s β β x β t, U x := by
let β¨t, β¨htc, htsubβ©β© := hs.elim_nhds_subcover' (fun x _ β¦ U x) hU
refine β¨βt, Countable.image htc Subtype.val, ?_β©
constructor
Β· intro _
simp only [mem_image, Subtype.exists, exists_and_right, exists_eq_right, forall_exists_index]
tauto
Β· have : β x β t, U βx = β x β Subtype.val '' t, U x := biUnion_image.symm
rwa [β this]
/-- For every nonempty open cover of a LindelΓΆf set, there exists a subcover indexed by β. -/
theorem IsLindelof.indexed_countable_subcover {ΞΉ : Type v} [Nonempty ΞΉ]
(hs : IsLindelof s) (U : ΞΉ β Set X) (hUo : β i, IsOpen (U i)) (hsU : s β β i, U i) :
β f : β β ΞΉ, s β β n, U (f n) := by
obtain β¨c, β¨c_count, c_covβ©β© := hs.elim_countable_subcover U hUo hsU
rcases c.eq_empty_or_nonempty with rfl | c_nonempty
Β· simp only [mem_empty_iff_false, iUnion_of_empty, iUnion_empty] at c_cov
simp only [subset_eq_empty c_cov rfl, empty_subset, exists_const]
obtain β¨f, f_surjβ© := (Set.countable_iff_exists_surjective c_nonempty).mp c_count
refine β¨fun x β¦ f x, c_cov.trans <| iUnionβ_subset_iff.mpr (?_ : β i β c, U i β β n, U (f n))β©
intro x hx
obtain β¨n, hnβ© := f_surj β¨x, hxβ©
exact subset_iUnion_of_subset n <| subset_of_eq (by rw [hn])
/-- The neighborhood filter of a LindelΓΆf set is disjoint with a filter `l` with the countable
intersection property if and only if the neighborhood filter of each point of this set
is disjoint with `l`. -/
theorem IsLindelof.disjoint_nhdsSet_left {l : Filter X} [CountableInterFilter l]
(hs : IsLindelof s) :
Disjoint (πΛ’ s) l β β x β s, Disjoint (π x) l := by
refine β¨fun h x hx β¦ h.mono_left <| nhds_le_nhdsSet hx, fun H β¦ ?_β©
choose! U hxU hUl using fun x hx β¦ (nhds_basis_opens x).disjoint_iff_left.1 (H x hx)
choose hxU hUo using hxU
rcases hs.elim_nhds_subcover U fun x hx β¦ (hUo x hx).mem_nhds (hxU x hx) with β¨t, htc, hts, hstβ©
refine (hasBasis_nhdsSet _).disjoint_iff_left.2
β¨β x β t, U x, β¨isOpen_biUnion fun x hx β¦ hUo x (hts x hx), hstβ©, ?_β©
rw [compl_iUnionβ]
exact (countable_bInter_mem htc).mpr (fun i hi β¦ hUl _ (hts _ hi))
/-- A filter `l` with the countable intersection property is disjoint with the neighborhood
filter of a LindelΓΆf set if and only if it is disjoint with the neighborhood filter of each point
of this set. -/
theorem IsLindelof.disjoint_nhdsSet_right {l : Filter X} [CountableInterFilter l]
(hs : IsLindelof s) : Disjoint l (πΛ’ s) β β x β s, Disjoint l (π x) := by
simpa only [disjoint_comm] using hs.disjoint_nhdsSet_left
/-- For every family of closed sets whose intersection avoids a LindelΓΆ set,
there exists a countable subfamily whose intersection avoids this LindelΓΆf set. -/
theorem IsLindelof.elim_countable_subfamily_closed {ΞΉ : Type v} (hs : IsLindelof s)
(t : ΞΉ β Set X) (htc : β i, IsClosed (t i)) (hst : (s β© β i, t i) = β
) :
β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i) = β
:= by
let U := tαΆ
have hUo : β i, IsOpen (U i) := by simp only [U, Pi.compl_apply, isOpen_compl_iff]; exact htc
have hsU : s β β i, U i := by
simp only [U, Pi.compl_apply]
rw [β compl_iInter]
apply disjoint_compl_left_iff_subset.mp
simp only [compl_iInter, compl_iUnion, compl_compl]
apply Disjoint.symm
exact disjoint_iff_inter_eq_empty.mpr hst
rcases hs.elim_countable_subcover U hUo hsU with β¨u, β¨hucount, husubβ©β©
use u, hucount
rw [β disjoint_compl_left_iff_subset] at husub
simp only [U, Pi.compl_apply, compl_iUnion, compl_compl] at husub
exact disjoint_iff_inter_eq_empty.mp (Disjoint.symm husub)
/-- To show that a LindelΓΆf set intersects the intersection of a family of closed sets,
it is sufficient to show that it intersects every countable subfamily. -/
| Mathlib/Topology/Compactness/Lindelof.lean | 237 | 242 | theorem IsLindelof.inter_iInter_nonempty {ΞΉ : Type v} (hs : IsLindelof s) (t : ΞΉ β Set X)
(htc : β i, IsClosed (t i)) (hst : β u : Set ΞΉ, u.Countable β§ (s β© β i β u, t i).Nonempty) :
(s β© β i, t i).Nonempty := by | contrapose! hst
rcases hs.elim_countable_subfamily_closed t htc hst with β¨u, β¨_, husubβ©β©
exact β¨u, fun _ β¦ husubβ© |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle SΓΆnne, SΓ©bastien GouΓ«zel,
RΓ©my Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Power function on `ββ₯0` and `ββ₯0β`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +β]` (a.k.a. `ββ₯0β`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open Real NNReal ENNReal ComplexConjugate Finset Function Set
namespace NNReal
variable {x : ββ₯0} {w y z : β}
/-- The nonnegative real power function `x^y`, defined for `x : ββ₯0` and `y : β` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y β 0`. -/
noncomputable def rpow (x : ββ₯0) (y : β) : ββ₯0 :=
β¨(x : β) ^ y, Real.rpow_nonneg x.2 yβ©
noncomputable instance : Pow ββ₯0 β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0) (y : β) : rpow x y = x ^ y :=
rfl
@[simp, norm_cast]
theorem coe_rpow (x : ββ₯0) (y : β) : ((x ^ y : ββ₯0) : β) = (x : β) ^ y :=
rfl
@[simp]
theorem rpow_zero (x : ββ₯0) : x ^ (0 : β) = 1 :=
NNReal.eq <| Real.rpow_zero _
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0} {y : β} : x ^ y = 0 β x = 0 β§ y β 0 := by
rw [β NNReal.coe_inj, coe_rpow, β NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
lemma rpow_eq_zero (hy : y β 0) : x ^ y = 0 β x = 0 := by simp [hy]
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : ββ₯0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
@[simp]
theorem rpow_one (x : ββ₯0) : x ^ (1 : β) = x :=
NNReal.eq <| Real.rpow_one _
lemma rpow_neg (x : ββ₯0) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.rpow_neg x.2 _
@[simp, norm_cast]
lemma rpow_natCast (x : ββ₯0) (n : β) : x ^ (n : β) = x ^ n :=
NNReal.eq <| by simpa only [coe_rpow, coe_pow] using Real.rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ββ₯0) (n : β€) : x ^ (n : β) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
theorem rpow_add {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) _ _
theorem rpow_add' (h : y + z β 0) (x : ββ₯0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
lemma rpow_add_intCast (hx : x β 0) (y : β) (n : β€) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast (mod_cast hx) _ _
lemma rpow_add_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast (mod_cast hx) _ _
lemma rpow_sub_intCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast (mod_cast hx) _ _
lemma rpow_sub_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast (mod_cast hx) _ _
lemma rpow_add_intCast' {n : β€} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast' (mod_cast x.2) h
lemma rpow_add_natCast' {n : β} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast' (mod_cast x.2) h
lemma rpow_sub_intCast' {n : β€} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast' (mod_cast x.2) h
lemma rpow_sub_natCast' {n : β} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast' (mod_cast x.2) h
lemma rpow_add_one (hx : x β 0) (y : β) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
lemma rpow_sub_one (hx : x β 0) (y : β) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (h : y + 1 β 0) (x : ββ₯0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' h, rpow_one]
lemma rpow_one_add' (h : 1 + y β 0) (x : ββ₯0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' h, rpow_one]
theorem rpow_add_of_nonneg (x : ββ₯0) {y z : β} (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
ext; exact Real.rpow_add_of_nonneg x.2 hy hz
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ββ₯0) (hw : w β 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [β h, rpow_add']; rwa [h]
theorem rpow_mul (x : ββ₯0) (y z : β) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
lemma rpow_natCast_mul (x : ββ₯0) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_natCast]
lemma rpow_mul_natCast (x : ββ₯0) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_natCast]
lemma rpow_intCast_mul (x : ββ₯0) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_intCast]
lemma rpow_mul_intCast (x : ββ₯0) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_intCast]
theorem rpow_neg_one (x : ββ₯0) : x ^ (-1 : β) = xβ»ΒΉ := by simp [rpow_neg]
theorem rpow_sub {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) y z
theorem rpow_sub' (h : y - z β 0) (x : ββ₯0) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub' x.2 h
lemma rpow_sub_one' (h : y - 1 β 0) (x : ββ₯0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' h, rpow_one]
lemma rpow_one_sub' (h : 1 - y β 0) (x : ββ₯0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' h, rpow_one]
theorem rpow_inv_rpow_self {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ (1 / y) = x := by
field_simp [β rpow_mul]
theorem rpow_self_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ (1 / y)) ^ y = x := by
field_simp [β rpow_mul]
theorem inv_rpow (x : ββ₯0) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.inv_rpow x.2 y
theorem div_rpow (x y : ββ₯0) (z : β) : (x / y) ^ z = x ^ z / y ^ z :=
NNReal.eq <| Real.div_rpow x.2 y.2 z
theorem sqrt_eq_rpow (x : ββ₯0) : sqrt x = x ^ (1 / (2 : β)) := by
refine NNReal.eq ?_
push_cast
exact Real.sqrt_eq_rpow x.1
@[simp]
lemma rpow_ofNat (x : ββ₯0) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (OfNat.ofNat n : β) :=
rpow_natCast x n
theorem rpow_two (x : ββ₯0) : x ^ (2 : β) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow {x y : ββ₯0} {z : β} : (x * y) ^ z = x ^ z * y ^ z :=
NNReal.eq <| Real.mul_rpow x.2 y.2
/-- `rpow` as a `MonoidHom` -/
@[simps]
def rpowMonoidHom (r : β) : ββ₯0 β* ββ₯0 where
toFun := (Β· ^ r)
map_one' := one_rpow _
map_mul' _x _y := mul_rpow
/-- `rpow` variant of `List.prod_map_pow` for `ββ₯0` -/
theorem list_prod_map_rpow (l : List ββ₯0) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r :=
l.prod_hom (rpowMonoidHom r)
theorem list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β list_prod_map_rpow, List.map_map]; rfl
/-- `rpow` version of `Multiset.prod_map_pow` for `ββ₯0`. -/
lemma multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r :=
s.prod_hom' (rpowMonoidHom r) _
/-- `rpow` version of `Finset.prod_pow` for `ββ₯0`. -/
lemma finset_prod_rpow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
multiset_prod_map_rpow _ _ _
-- note: these don't really belong here, but they're much easier to prove in terms of the above
section Real
/-- `rpow` version of `List.prod_map_pow` for `Real`. -/
theorem _root_.Real.list_prod_map_rpow (l : List β) (hl : β x β l, (0 : β) β€ x) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r := by
lift l to List ββ₯0 using hl
have := congr_arg ((β) : ββ₯0 β β) (NNReal.list_prod_map_rpow l r)
push_cast at this
rw [List.map_map] at this β’
exact mod_cast this
theorem _root_.Real.list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β β)
(hl : β i β l, (0 : β) β€ f i) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β Real.list_prod_map_rpow (l.map f) _ r, List.map_map]
Β· rfl
simpa using hl
/-- `rpow` version of `Multiset.prod_map_pow`. -/
theorem _root_.Real.multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β β)
(hs : β i β s, (0 : β) β€ f i) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r := by
induction' s using Quotient.inductionOn with l
simpa using Real.list_prod_map_rpow' l f hs r
/-- `rpow` version of `Finset.prod_pow`. -/
theorem _root_.Real.finset_prod_rpow
{ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β β) (hs : β i β s, 0 β€ f i) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
Real.multiset_prod_map_rpow s.val f hs r
end Real
@[gcongr] theorem rpow_le_rpow {x y : ββ₯0} {z : β} (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z :=
Real.rpow_le_rpow x.2 hβ hβ
@[gcongr] theorem rpow_lt_rpow {x y : ββ₯0} {z : β} (hβ : x < y) (hβ : 0 < z) : x ^ z < y ^ z :=
Real.rpow_lt_rpow x.2 hβ hβ
theorem rpow_lt_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z < y ^ z β x < y :=
Real.rpow_lt_rpow_iff x.2 y.2 hz
theorem rpow_le_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
Real.rpow_le_rpow_iff x.2 y.2 hz
theorem le_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem rpow_inv_le_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem lt_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^z < y := by
simp only [β not_le, rpow_inv_le_iff hz]
theorem rpow_inv_lt_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z := by
simp only [β not_le, le_rpow_inv_iff hz]
section
variable {y : ββ₯0}
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z :=
Real.rpow_lt_rpow_of_neg hx hxy hz
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x β€ y) (hz : z β€ 0) : y ^ z β€ x ^ z :=
Real.rpow_le_rpow_of_nonpos hx hxy hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z β y < x :=
Real.rpow_lt_rpow_iff_of_neg hx hy hz
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z β€ y ^ z β y β€ x :=
Real.rpow_le_rpow_iff_of_neg hx hy hz
lemma le_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y :=
Real.le_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_le_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z :=
Real.rpow_inv_le_iff_of_pos x.2 hy hz
lemma lt_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x < y ^ zβ»ΒΉ β x ^ z < y :=
Real.lt_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_lt_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ < y β x < y ^ z :=
Real.rpow_inv_lt_iff_of_pos x.2 hy hz
lemma le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x β€ y ^ zβ»ΒΉ β y β€ x ^ z :=
Real.le_rpow_inv_iff_of_neg hx hy hz
lemma lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x < y ^ zβ»ΒΉ β y < x ^ z :=
Real.lt_rpow_inv_iff_of_neg hx hy hz
lemma rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ < y β y ^ z < x :=
Real.rpow_inv_lt_iff_of_neg hx hy hz
lemma rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ β€ y β y ^ z β€ x :=
Real.rpow_inv_le_iff_of_neg hx hy hz
end
@[gcongr] theorem rpow_lt_rpow_of_exponent_lt {x : ββ₯0} {y z : β} (hx : 1 < x) (hyz : y < z) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_lt hx hyz
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ββ₯0} {y z : β} (hx : 1 β€ x) (hyz : y β€ z) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_le hx hyz
theorem rpow_lt_rpow_of_exponent_gt {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz
theorem rpow_le_rpow_of_exponent_ge {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x β€ 1) (hyz : z β€ y) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_ge hx0 hx1 hyz
theorem rpow_pos {p : β} {x : ββ₯0} (hx_pos : 0 < x) : 0 < x ^ p := by
have rpow_pos_of_nonneg : β {p : β}, 0 < p β 0 < x ^ p := by
intro p hp_pos
rw [β zero_rpow hp_pos.ne']
exact rpow_lt_rpow hx_pos hp_pos
rcases lt_trichotomy (0 : β) p with (hp_pos | rfl | hp_neg)
Β· exact rpow_pos_of_nonneg hp_pos
Β· simp only [zero_lt_one, rpow_zero]
Β· rw [β neg_neg p, rpow_neg, inv_pos]
exact rpow_pos_of_nonneg (neg_pos.mpr hp_neg)
theorem rpow_lt_one {x : ββ₯0} {z : β} (hx1 : x < 1) (hz : 0 < z) : x ^ z < 1 :=
Real.rpow_lt_one (coe_nonneg x) hx1 hz
theorem rpow_le_one {x : ββ₯0} {z : β} (hx2 : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 :=
Real.rpow_le_one x.2 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x : ββ₯0} {z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 :=
Real.rpow_lt_one_of_one_lt_of_neg hx hz
theorem rpow_le_one_of_one_le_of_nonpos {x : ββ₯0} {z : β} (hx : 1 β€ x) (hz : z β€ 0) : x ^ z β€ 1 :=
Real.rpow_le_one_of_one_le_of_nonpos hx hz
theorem one_lt_rpow {x : ββ₯0} {z : β} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z :=
Real.one_lt_rpow hx hz
theorem one_le_rpow {x : ββ₯0} {z : β} (h : 1 β€ x) (hβ : 0 β€ z) : 1 β€ x ^ z :=
Real.one_le_rpow h hβ
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z :=
Real.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz
theorem one_le_rpow_of_pos_of_le_one_of_nonpos {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x β€ 1)
(hz : z β€ 0) : 1 β€ x ^ z :=
Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 hz
theorem rpow_le_self_of_le_one {x : ββ₯0} {z : β} (hx : x β€ 1) (h_one_le : 1 β€ z) : x ^ z β€ x := by
rcases eq_bot_or_bot_lt x with (rfl | (h : 0 < x))
Β· have : z β 0 := by linarith
simp [this]
nth_rw 2 [β NNReal.rpow_one x]
exact NNReal.rpow_le_rpow_of_exponent_ge h hx h_one_le
theorem rpow_left_injective {x : β} (hx : x β 0) : Function.Injective fun y : ββ₯0 => y ^ x :=
fun y z hyz => by simpa only [rpow_inv_rpow_self hx] using congr_arg (fun y => y ^ (1 / x)) hyz
theorem rpow_eq_rpow_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ z = y ^ z β x = y :=
(rpow_left_injective hz).eq_iff
theorem rpow_left_surjective {x : β} (hx : x β 0) : Function.Surjective fun y : ββ₯0 => y ^ x :=
fun y => β¨y ^ xβ»ΒΉ, by simp_rw [β rpow_mul, inv_mul_cancelβ hx, rpow_one]β©
theorem rpow_left_bijective {x : β} (hx : x β 0) : Function.Bijective fun y : ββ₯0 => y ^ x :=
β¨rpow_left_injective hx, rpow_left_surjective hxβ©
theorem eq_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x = y ^ zβ»ΒΉ β x ^ z = y := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
theorem rpow_inv_eq_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ zβ»ΒΉ = y β x = y ^ z := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
@[simp] lemma rpow_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul, inv_mul_cancelβ hy, rpow_one]
theorem pow_rpow_inv_natCast (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
rw [β NNReal.coe_inj, coe_rpow, NNReal.coe_pow]
exact Real.pow_rpow_inv_natCast x.2 hn
theorem rpow_inv_natCast_pow (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
rw [β NNReal.coe_inj, NNReal.coe_pow, coe_rpow]
exact Real.rpow_inv_natCast_pow x.2 hn
theorem _root_.Real.toNNReal_rpow_of_nonneg {x y : β} (hx : 0 β€ x) :
Real.toNNReal (x ^ y) = Real.toNNReal x ^ y := by
nth_rw 1 [β Real.coe_toNNReal x hx]
rw [β NNReal.coe_rpow, Real.toNNReal_coe]
theorem strictMono_rpow_of_pos {z : β} (h : 0 < z) : StrictMono fun x : ββ₯0 => x ^ z :=
fun x y hxy => by simp only [NNReal.rpow_lt_rpow hxy h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : β} (h : 0 β€ z) : Monotone fun x : ββ₯0 => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 βΈ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ββ₯0 => x ^ y` into an order isomorphism when `y : β` is positive,
where the inverse is `fun x : ββ₯0 => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : β) (hy : 0 < y) : ββ₯0 βo ββ₯0 :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [β rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_eq (y : β) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]; rfl
theorem _root_.Real.nnnorm_rpow_of_nonneg {x y : β} (hx : 0 β€ x) : βx ^ yββ = βxββ ^ y := by
ext; exact Real.norm_rpow_of_nonneg hx
end NNReal
namespace ENNReal
/-- The real power function `x^y` on extended nonnegative reals, defined for `x : ββ₯0β` and
`y : β` as the restriction of the real power function if `0 < x < β€`, and with the natural values
for `0` and `β€` (i.e., `0 ^ x = 0` for `x > 0`, `1` for `x = 0` and `β€` for `x < 0`, and
`β€ ^ x = 1 / 0 ^ x`). -/
noncomputable def rpow : ββ₯0β β β β ββ₯0β
| some x, y => if x = 0 β§ y < 0 then β€ else (x ^ y : ββ₯0)
| none, y => if 0 < y then β€ else if y = 0 then 1 else 0
noncomputable instance : Pow ββ₯0β β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0β) (y : β) : rpow x y = x ^ y :=
rfl
@[simp]
theorem rpow_zero {x : ββ₯0β} : x ^ (0 : β) = 1 := by
cases x <;>
Β· dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp [lt_irrefl]
theorem top_rpow_def (y : β) : (β€ : ββ₯0β) ^ y = if 0 < y then β€ else if y = 0 then 1 else 0 :=
rfl
@[simp]
theorem top_rpow_of_pos {y : β} (h : 0 < y) : (β€ : ββ₯0β) ^ y = β€ := by simp [top_rpow_def, h]
@[simp]
theorem top_rpow_of_neg {y : β} (h : y < 0) : (β€ : ββ₯0β) ^ y = 0 := by
simp [top_rpow_def, asymm h, ne_of_lt h]
@[simp]
theorem zero_rpow_of_pos {y : β} (h : 0 < y) : (0 : ββ₯0β) ^ y = 0 := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [h, asymm h, ne_of_gt h]
@[simp]
theorem zero_rpow_of_neg {y : β} (h : y < 0) : (0 : ββ₯0β) ^ y = β€ := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [h, ne_of_gt h]
theorem zero_rpow_def (y : β) : (0 : ββ₯0β) ^ y = if 0 < y then 0 else if y = 0 then 1 else β€ := by
rcases lt_trichotomy (0 : β) y with (H | rfl | H)
Β· simp [H, ne_of_gt, zero_rpow_of_pos, lt_irrefl]
Β· simp [lt_irrefl]
Β· simp [H, asymm H, ne_of_lt, zero_rpow_of_neg]
@[simp]
theorem zero_rpow_mul_self (y : β) : (0 : ββ₯0β) ^ y * (0 : ββ₯0β) ^ y = (0 : ββ₯0β) ^ y := by
rw [zero_rpow_def]
split_ifs
exacts [zero_mul _, one_mul _, top_mul_top]
@[norm_cast]
theorem coe_rpow_of_ne_zero {x : ββ₯0} (h : x β 0) (y : β) : (β(x ^ y) : ββ₯0β) = x ^ y := by
rw [β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp [h]
@[norm_cast]
theorem coe_rpow_of_nonneg (x : ββ₯0) {y : β} (h : 0 β€ y) : β(x ^ y) = (x : ββ₯0β) ^ y := by
by_cases hx : x = 0
Β· rcases le_iff_eq_or_lt.1 h with (H | H)
Β· simp [hx, H.symm]
Β· simp [hx, zero_rpow_of_pos H, NNReal.zero_rpow (ne_of_gt H)]
Β· exact coe_rpow_of_ne_zero hx _
theorem coe_rpow_def (x : ββ₯0) (y : β) :
(x : ββ₯0β) ^ y = if x = 0 β§ y < 0 then β€ else β(x ^ y) :=
rfl
theorem rpow_ofNNReal {M : ββ₯0} {P : β} (hP : 0 β€ P) : (M : ββ₯0β) ^ P = β(M ^ P) := by
rw [ENNReal.coe_rpow_of_nonneg _ hP, β ENNReal.rpow_eq_pow]
@[simp]
theorem rpow_one (x : ββ₯0β) : x ^ (1 : β) = x := by
cases x
Β· exact dif_pos zero_lt_one
Β· change ite _ _ _ = _
simp only [NNReal.rpow_one, some_eq_coe, ite_eq_right_iff, top_ne_coe, and_imp]
exact fun _ => zero_le_one.not_lt
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0β) ^ x = 1 := by
rw [β coe_one, β coe_rpow_of_ne_zero one_ne_zero]
simp
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0β} {y : β} : x ^ y = 0 β x = 0 β§ 0 < y β¨ x = β€ β§ y < 0 := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
lemma rpow_eq_zero_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = 0 β x = 0 := by
simp [hy, hy.not_lt]
@[simp]
theorem rpow_eq_top_iff {x : ββ₯0β} {y : β} : x ^ y = β€ β x = 0 β§ y < 0 β¨ x = β€ β§ 0 < y := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
theorem rpow_eq_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = β€ β x = β€ := by
simp [rpow_eq_top_iff, hy, asymm hy]
lemma rpow_lt_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y < β β x < β := by
simp only [lt_top_iff_ne_top, Ne, rpow_eq_top_iff_of_pos hy]
theorem rpow_eq_top_of_nonneg (x : ββ₯0β) {y : β} (hy0 : 0 β€ y) : x ^ y = β€ β x = β€ := by
rw [ENNReal.rpow_eq_top_iff]
rintro (h|h)
Β· exfalso
rw [lt_iff_not_ge] at h
exact h.right hy0
Β· exact h.left
theorem rpow_ne_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y β β€ :=
mt (ENNReal.rpow_eq_top_of_nonneg x hy0) h
theorem rpow_lt_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y < β€ :=
lt_top_iff_ne_top.mpr (ENNReal.rpow_ne_top_of_nonneg hy0 h)
theorem rpow_add {x : ββ₯0β} (y z : β) (hx : x β 0) (h'x : x β β€) : x ^ (y + z) = x ^ y * x ^ z := by
cases x with
| top => exact (h'x rfl).elim
| coe x =>
have : x β 0 := fun h => by simp [h] at hx
simp [β coe_rpow_of_ne_zero this, NNReal.rpow_add this]
theorem rpow_add_of_nonneg {x : ββ₯0β} (y z : β) (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
induction x using recTopCoe
Β· rcases hy.eq_or_lt with rfl|hy
Β· rw [rpow_zero, one_mul, zero_add]
rcases hz.eq_or_lt with rfl|hz
Β· rw [rpow_zero, mul_one, add_zero]
simp [top_rpow_of_pos, hy, hz, add_pos hy hz]
simp [β coe_rpow_of_nonneg, hy, hz, add_nonneg hy hz, NNReal.rpow_add_of_nonneg _ hy hz]
| Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean | 587 | 590 | theorem rpow_neg (x : ββ₯0β) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by | cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;> |
/-
Copyright (c) 2022 Eric Rodriguez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Eric Rodriguez
-/
import Mathlib.Algebra.GroupWithZero.Units.Lemmas
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.Ring.Cast
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Tactic.DeriveFintype
/-!
# Sign function
This file defines the sign function for types with zero and a decidable less-than relation, and
proves some basic theorems about it.
-/
-- Don't generate unnecessary `sizeOf_spec` lemmas which the `simpNF` linter will complain about.
set_option genSizeOfSpec false in
/-- The type of signs. -/
inductive SignType
| zero
| neg
| pos
deriving DecidableEq, Inhabited, Fintype
namespace SignType
instance : Zero SignType :=
β¨zeroβ©
instance : One SignType :=
β¨posβ©
instance : Neg SignType :=
β¨fun s =>
match s with
| neg => pos
| zero => zero
| pos => negβ©
@[simp]
theorem zero_eq_zero : zero = 0 :=
rfl
@[simp]
theorem neg_eq_neg_one : neg = -1 :=
rfl
@[simp]
theorem pos_eq_one : pos = 1 :=
rfl
instance : Mul SignType :=
β¨fun x y =>
match x with
| neg => -y
| zero => zero
| pos => yβ©
/-- The less-than-or-equal relation on signs. -/
protected inductive LE : SignType β SignType β Prop
| of_neg (a) : SignType.LE neg a
| zero : SignType.LE zero zero
| of_pos (a) : SignType.LE a pos
instance : LE SignType :=
β¨SignType.LEβ©
instance LE.decidableRel : DecidableRel SignType.LE := fun a b => by
cases a <;> cases b <;> first | exact isTrue (by constructor)| exact isFalse (by rintro β¨_β©)
instance decidableEq : DecidableEq SignType := fun a b => by
cases a <;> cases b <;> first | exact isTrue (by constructor)| exact isFalse (by rintro β¨_β©)
private lemma mul_comm : β (a b : SignType), a * b = b * a := by rintro β¨β© β¨β© <;> rfl
private lemma mul_assoc : β (a b c : SignType), (a * b) * c = a * (b * c) := by
rintro β¨β© β¨β© β¨β© <;> rfl
/- We can define a `Field` instance on `SignType`, but it's not mathematically sensible,
so we only define the `CommGroupWithZero`. -/
instance : CommGroupWithZero SignType where
zero := 0
one := 1
mul := (Β· * Β·)
inv := id
mul_zero a := by cases a <;> rfl
zero_mul a := by cases a <;> rfl
mul_one a := by cases a <;> rfl
one_mul a := by cases a <;> rfl
mul_inv_cancel a ha := by cases a <;> trivial
mul_comm := mul_comm
mul_assoc := mul_assoc
exists_pair_ne := β¨0, 1, by rintro β¨_β©β©
inv_zero := rfl
private lemma le_antisymm (a b : SignType) (_ : a β€ b) (_ : b β€ a) : a = b := by
cases a <;> cases b <;> trivial
private lemma le_trans (a b c : SignType) (_ : a β€ b) (_ : b β€ c) : a β€ c := by
cases a <;> cases b <;> cases c <;> tauto
instance : LinearOrder SignType where
le := (Β· β€ Β·)
le_refl a := by cases a <;> constructor
le_total a b := by cases a <;> cases b <;> first | left; constructor | right; constructor
le_antisymm := le_antisymm
le_trans := le_trans
toDecidableLE := LE.decidableRel
toDecidableEq := SignType.decidableEq
instance : BoundedOrder SignType where
top := 1
le_top := LE.of_pos
bot := -1
bot_le :=
#adaptation_note /-- https://github.com/leanprover/lean4/pull/6053
Added `by exact`, but don't understand why it was needed. -/
by exact LE.of_neg
instance : HasDistribNeg SignType :=
{ neg_neg := fun x => by cases x <;> rfl
neg_mul := fun x y => by cases x <;> cases y <;> rfl
mul_neg := fun x y => by cases x <;> cases y <;> rfl }
/-- `SignType` is equivalent to `Fin 3`. -/
def fin3Equiv : SignType β* Fin 3 where
toFun a :=
match a with
| 0 => β¨0, by simpβ©
| 1 => β¨1, by simpβ©
| -1 => β¨2, by simpβ©
invFun a :=
match a with
| β¨0, _β© => 0
| β¨1, _β© => 1
| β¨2, _β© => -1
left_inv a := by cases a <;> rfl
right_inv a :=
match a with
| β¨0, _β© => by simp
| β¨1, _β© => by simp
| β¨2, _β© => by simp
map_mul' a b := by
cases a <;> cases b <;> rfl
section CaseBashing
theorem nonneg_iff {a : SignType} : 0 β€ a β a = 0 β¨ a = 1 := by decide +revert
theorem nonneg_iff_ne_neg_one {a : SignType} : 0 β€ a β a β -1 := by decide +revert
theorem neg_one_lt_iff {a : SignType} : -1 < a β 0 β€ a := by decide +revert
theorem nonpos_iff {a : SignType} : a β€ 0 β a = -1 β¨ a = 0 := by decide +revert
theorem nonpos_iff_ne_one {a : SignType} : a β€ 0 β a β 1 := by decide +revert
theorem lt_one_iff {a : SignType} : a < 1 β a β€ 0 := by decide +revert
@[simp]
theorem neg_iff {a : SignType} : a < 0 β a = -1 := by decide +revert
@[simp]
theorem le_neg_one_iff {a : SignType} : a β€ -1 β a = -1 :=
le_bot_iff
@[simp]
theorem pos_iff {a : SignType} : 0 < a β a = 1 := by decide +revert
@[simp]
theorem one_le_iff {a : SignType} : 1 β€ a β a = 1 :=
top_le_iff
@[simp]
theorem neg_one_le (a : SignType) : -1 β€ a :=
bot_le
@[simp]
theorem le_one (a : SignType) : a β€ 1 :=
le_top
@[simp]
theorem not_lt_neg_one (a : SignType) : Β¬a < -1 :=
not_lt_bot
@[simp]
theorem not_one_lt (a : SignType) : Β¬1 < a :=
not_top_lt
@[simp]
theorem self_eq_neg_iff (a : SignType) : a = -a β a = 0 := by decide +revert
@[simp]
theorem neg_eq_self_iff (a : SignType) : -a = a β a = 0 := by decide +revert
@[simp]
theorem neg_one_lt_one : (-1 : SignType) < 1 :=
bot_lt_top
end CaseBashing
section cast
variable {Ξ± : Type*} [Zero Ξ±] [One Ξ±] [Neg Ξ±]
/-- Turn a `SignType` into zero, one, or minus one. This is a coercion instance. -/
@[coe]
def cast : SignType β Ξ±
| zero => 0
| pos => 1
| neg => -1
/-- This is a `CoeTail` since the type on the right (trivially) determines the type on the left.
`outParam`-wise it could be a `Coe`, but we don't want to try applying this instance for a
coercion to any `Ξ±`.
-/
instance : CoeTail SignType Ξ± :=
β¨castβ©
/-- Casting out of `SignType` respects composition with functions preserving `0, 1, -1`. -/
lemma map_cast' {Ξ² : Type*} [One Ξ²] [Neg Ξ²] [Zero Ξ²]
(f : Ξ± β Ξ²) (hβ : f 1 = 1) (hβ : f 0 = 0) (hβ : f (-1) = -1) (s : SignType) :
f s = s := by
cases s <;> simp only [SignType.cast, hβ, hβ, hβ]
/-- Casting out of `SignType` respects composition with suitable bundled homomorphism types. -/
lemma map_cast {Ξ± Ξ² F : Type*} [AddGroupWithOne Ξ±] [One Ξ²] [SubtractionMonoid Ξ²]
[FunLike F Ξ± Ξ²] [AddMonoidHomClass F Ξ± Ξ²] [OneHomClass F Ξ± Ξ²] (f : F) (s : SignType) :
f s = s := by
apply map_cast' <;> simp
@[simp]
theorem coe_zero : β(0 : SignType) = (0 : Ξ±) :=
rfl
@[simp]
theorem coe_one : β(1 : SignType) = (1 : Ξ±) :=
rfl
@[simp]
theorem coe_neg_one : β(-1 : SignType) = (-1 : Ξ±) :=
rfl
@[simp, norm_cast]
lemma coe_neg {Ξ± : Type*} [One Ξ±] [SubtractionMonoid Ξ±] (s : SignType) :
(β(-s) : Ξ±) = -βs := by
cases s <;> simp
/-- Casting `SignType β β€ β Ξ±` is the same as casting directly `SignType β Ξ±`. -/
@[simp, norm_cast]
lemma intCast_cast {Ξ± : Type*} [AddGroupWithOne Ξ±] (s : SignType) : ((s : β€) : Ξ±) = s :=
map_cast' _ Int.cast_one Int.cast_zero (@Int.cast_one Ξ± _ βΈ Int.cast_neg 1) _
end cast
/-- `SignType.cast` as a `MulWithZeroHom`. -/
@[simps]
def castHom {Ξ±} [MulZeroOneClass Ξ±] [HasDistribNeg Ξ±] : SignType β*β Ξ± where
toFun := cast
map_zero' := rfl
map_one' := rfl
map_mul' x y := by cases x <;> cases y <;> simp [zero_eq_zero, pos_eq_one, neg_eq_neg_one]
theorem univ_eq : (Finset.univ : Finset SignType) = {0, -1, 1} := by
decide
theorem range_eq {Ξ±} (f : SignType β Ξ±) : Set.range f = {f zero, f neg, f pos} := by
classical rw [β Fintype.coe_image_univ, univ_eq]
classical simp [Finset.coe_insert]
@[simp, norm_cast] lemma coe_mul {Ξ±} [MulZeroOneClass Ξ±] [HasDistribNeg Ξ±] (a b : SignType) :
β(a * b) = (a : Ξ±) * b :=
map_mul SignType.castHom _ _
@[simp, norm_cast] lemma coe_pow {Ξ±} [MonoidWithZero Ξ±] [HasDistribNeg Ξ±] (a : SignType) (k : β) :
β(a ^ k) = (a : Ξ±) ^ k :=
map_pow SignType.castHom _ _
@[simp, norm_cast] lemma coe_zpow {Ξ±} [GroupWithZero Ξ±] [HasDistribNeg Ξ±] (a : SignType) (k : β€) :
β(a ^ k) = (a : Ξ±) ^ k :=
map_zpowβ SignType.castHom _ _
end SignType
-- The lemma `exists_signed_sum` needs explicit universe handling in its statement.
universe u
variable {Ξ± : Type u}
open SignType
section Preorder
variable [Zero Ξ±] [Preorder Ξ±] [DecidableLT Ξ±] {a : Ξ±}
/-- The sign of an element is 1 if it's positive, -1 if negative, 0 otherwise. -/
def SignType.sign : Ξ± βo SignType :=
β¨fun a => if 0 < a then 1 else if a < 0 then -1 else 0, fun a b h => by
dsimp
split_ifs with hβ hβ hβ hβ _ _ hβ hβ <;> try constructor
Β· cases lt_irrefl 0 (hβ.trans <| h.trans_lt hβ)
Β· cases hβ (hβ.trans_le h)
Β· cases hβ (h.trans_lt hβ)β©
theorem sign_apply : sign a = ite (0 < a) 1 (ite (a < 0) (-1) 0) :=
rfl
@[simp]
theorem sign_zero : sign (0 : Ξ±) = 0 := by simp [sign_apply]
@[simp]
theorem sign_pos (ha : 0 < a) : sign a = 1 := by rwa [sign_apply, if_pos]
@[simp]
theorem sign_neg (ha : a < 0) : sign a = -1 := by rwa [sign_apply, if_neg <| asymm ha, if_pos]
theorem sign_eq_one_iff : sign a = 1 β 0 < a := by
refine β¨fun h => ?_, fun h => sign_pos hβ©
by_contra hn
rw [sign_apply, if_neg hn] at h
split_ifs at h
theorem sign_eq_neg_one_iff : sign a = -1 β a < 0 := by
refine β¨fun h => ?_, fun h => sign_neg hβ©
rw [sign_apply] at h
split_ifs at h
assumption
end Preorder
section LinearOrder
variable [Zero Ξ±] [LinearOrder Ξ±] {a : Ξ±}
/-- `SignType.sign` respects strictly monotone zero-preserving maps. -/
lemma StrictMono.sign_comp {Ξ² F : Type*} [Zero Ξ²] [Preorder Ξ²] [DecidableLT Ξ²]
[FunLike F Ξ± Ξ²] [ZeroHomClass F Ξ± Ξ²] {f : F} (hf : StrictMono f) (a : Ξ±) :
sign (f a) = sign a := by
simp only [sign_apply, β map_zero f, hf.lt_iff_lt]
@[simp]
theorem sign_eq_zero_iff : sign a = 0 β a = 0 := by
refine β¨fun h => ?_, fun h => h.symm βΈ sign_zeroβ©
rw [sign_apply] at h
split_ifs at h with h_1 h_2
cases h
exact (le_of_not_lt h_1).eq_of_not_lt h_2
theorem sign_ne_zero : sign a β 0 β a β 0 :=
sign_eq_zero_iff.not
@[simp]
theorem sign_nonneg_iff : 0 β€ sign a β 0 β€ a := by
rcases lt_trichotomy 0 a with (h | h | h)
Β· simp [h, h.le]
Β· simp [β h]
Β· simp [h, h.not_le]
@[simp]
theorem sign_nonpos_iff : sign a β€ 0 β a β€ 0 := by
rcases lt_trichotomy 0 a with (h | h | h)
Β· simp [h, h.not_le]
Β· simp [β h]
Β· simp [h, h.le]
end LinearOrder
section OrderedSemiring
variable [Semiring Ξ±] [PartialOrder Ξ±] [IsOrderedRing Ξ±] [DecidableLT Ξ±] [Nontrivial Ξ±]
theorem sign_one : sign (1 : Ξ±) = 1 :=
sign_pos zero_lt_one
end OrderedSemiring
section OrderedRing
@[simp]
lemma sign_intCast {Ξ± : Type*} [Ring Ξ±] [PartialOrder Ξ±] [IsOrderedRing Ξ±]
[Nontrivial Ξ±] [DecidableLT Ξ±] (n : β€) :
sign (n : Ξ±) = sign n := by
simp only [sign_apply, Int.cast_pos, Int.cast_lt_zero]
end OrderedRing
section LinearOrderedRing
variable [Ring Ξ±] [LinearOrder Ξ±] [IsStrictOrderedRing Ξ±]
theorem sign_mul (x y : Ξ±) : sign (x * y) = sign x * sign y := by
rcases lt_trichotomy x 0 with (hx | hx | hx) <;> rcases lt_trichotomy y 0 with (hy | hy | hy) <;>
simp [hx, hy, mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
@[simp] theorem sign_mul_abs (x : Ξ±) : (sign x * |x| : Ξ±) = x := by
rcases lt_trichotomy x 0 with hx | rfl | hx <;> simp [*, abs_of_pos, abs_of_neg]
@[simp] theorem abs_mul_sign (x : Ξ±) : (|x| * sign x : Ξ±) = x := by
rcases lt_trichotomy x 0 with hx | rfl | hx <;> simp [*, abs_of_pos, abs_of_neg]
@[simp]
| Mathlib/Data/Sign.lean | 405 | 409 | theorem sign_mul_self (x : Ξ±) : sign x * x = |x| := by | rcases lt_trichotomy x 0 with hx | rfl | hx <;> simp [*, abs_of_pos, abs_of_neg]
@[simp]
theorem self_mul_sign (x : Ξ±) : x * sign x = |x| := by |
/-
Copyright (c) 2023 Richard M. Hill. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Richard M. Hill
-/
import Mathlib.RingTheory.PowerSeries.Trunc
import Mathlib.RingTheory.PowerSeries.Inverse
import Mathlib.RingTheory.Derivation.Basic
/-!
# Definitions
In this file we define an operation `derivative` (formal differentiation)
on the ring of formal power series in one variable (over an arbitrary commutative semiring).
Under suitable assumptions, we prove that two power series are equal if their derivatives
are equal and their constant terms are equal. This will give us a simple tool for proving
power series identities. For example, one can easily prove the power series identity
$\exp ( \log (1+X)) = 1+X$ by differentiating twice.
## Main Definition
- `PowerSeries.derivative R : Derivation R Rβ¦Xβ§ Rβ¦Xβ§` the formal derivative operation.
This is abbreviated `dβdX R`.
-/
namespace PowerSeries
open Polynomial Derivation Nat
section CommutativeSemiring
variable {R} [CommSemiring R]
/--
The formal derivative of a power series in one variable.
This is defined here as a function, but will be packaged as a
derivation `derivative` on `Rβ¦Xβ§`.
-/
noncomputable def derivativeFun (f : Rβ¦Xβ§) : Rβ¦Xβ§ := mk fun n β¦ coeff R (n + 1) f * (n + 1)
theorem coeff_derivativeFun (f : Rβ¦Xβ§) (n : β) :
coeff R n f.derivativeFun = coeff R (n + 1) f * (n + 1) := by
rw [derivativeFun, coeff_mk]
theorem derivativeFun_coe (f : R[X]) : (f : Rβ¦Xβ§).derivativeFun = derivative f := by
ext
rw [coeff_derivativeFun, coeff_coe, coeff_coe, coeff_derivative]
theorem derivativeFun_add (f g : Rβ¦Xβ§) :
derivativeFun (f + g) = derivativeFun f + derivativeFun g := by
ext
rw [coeff_derivativeFun, map_add, map_add, coeff_derivativeFun,
coeff_derivativeFun, add_mul]
| Mathlib/RingTheory/PowerSeries/Derivative.lean | 55 | 58 | theorem derivativeFun_C (r : R) : derivativeFun (C R r) = 0 := by | ext n
-- Note that `map_zero` didn't get picked up, apparently due to a missing `FunLike.coe`
rw [coeff_derivativeFun, coeff_succ_C, zero_mul, (coeff R n).map_zero] |
/-
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, Mario Carneiro
-/
import Mathlib.Algebra.Field.IsField
import Mathlib.Data.Fin.VecNotation
import Mathlib.Data.Nat.Choose.Sum
import Mathlib.LinearAlgebra.Finsupp.LinearCombination
import Mathlib.RingTheory.Ideal.Maximal
import Mathlib.Tactic.FinCases
/-!
# Ideals over a ring
This file contains an assortment of definitions and results for `Ideal R`,
the type of (left) ideals over a ring `R`.
Note that over commutative rings, left ideals and two-sided ideals are equivalent.
## Implementation notes
`Ideal R` is implemented using `Submodule R R`, where `β’` is interpreted as `*`.
## TODO
Support right ideals, and two-sided ideals over non-commutative rings.
-/
variable {ΞΉ Ξ± Ξ² F : Type*}
open Set Function
open Pointwise
section Semiring
namespace Ideal
variable {Ξ± : ΞΉ β Type*} [Ξ i, Semiring (Ξ± i)] (I : Ξ i, Ideal (Ξ± i))
section Pi
/-- `Ξ α΅’ Iα΅’` as an ideal of `Ξ α΅’ Rα΅’`. -/
def pi : Ideal (Ξ i, Ξ± i) where
carrier := { x | β i, x i β I i }
zero_mem' i := (I i).zero_mem
add_mem' ha hb i := (I i).add_mem (ha i) (hb i)
smul_mem' a _b hb i := (I i).mul_mem_left (a i) (hb i)
theorem mem_pi (x : Ξ i, Ξ± i) : x β pi I β β i, x i β I i :=
Iff.rfl
instance (priority := low) [β i, (I i).IsTwoSided] : (pi I).IsTwoSided :=
β¨fun _b hb i β¦ mul_mem_right _ _ (hb i)β©
end Pi
section Commute
variable {Ξ± : Type*} [Semiring Ξ±] (I : Ideal Ξ±) {a b : Ξ±}
theorem add_pow_mem_of_pow_mem_of_le_of_commute {m n k : β}
(ha : a ^ m β I) (hb : b ^ n β I) (hk : m + n β€ k + 1)
(hab : Commute a b) :
(a + b) ^ k β I := by
simp_rw [hab.add_pow, β Nat.cast_comm]
apply I.sum_mem
intro c _
apply mul_mem_left
by_cases h : m β€ c
Β· rw [hab.pow_pow]
exact I.mul_mem_left _ (I.pow_mem_of_pow_mem ha h)
Β· refine I.mul_mem_left _ (I.pow_mem_of_pow_mem hb ?_)
omega
theorem add_pow_add_pred_mem_of_pow_mem_of_commute {m n : β}
(ha : a ^ m β I) (hb : b ^ n β I) (hab : Commute a b) :
(a + b) ^ (m + n - 1) β I :=
I.add_pow_mem_of_pow_mem_of_le_of_commute ha hb (by rw [β Nat.sub_le_iff_le_add]) hab
end Commute
end Ideal
end Semiring
section CommSemiring
variable {a b : Ξ±}
-- A separate namespace definition is needed because the variables were historically in a different
-- order.
namespace Ideal
variable [CommSemiring Ξ±] (I : Ideal Ξ±)
theorem add_pow_mem_of_pow_mem_of_le {m n k : β}
(ha : a ^ m β I) (hb : b ^ n β I) (hk : m + n β€ k + 1) :
(a + b) ^ k β I :=
I.add_pow_mem_of_pow_mem_of_le_of_commute ha hb hk (Commute.all ..)
theorem add_pow_add_pred_mem_of_pow_mem {m n : β}
(ha : a ^ m β I) (hb : b ^ n β I) :
(a + b) ^ (m + n - 1) β I :=
I.add_pow_add_pred_mem_of_pow_mem_of_commute ha hb (Commute.all ..)
theorem pow_multiset_sum_mem_span_pow [DecidableEq Ξ±] (s : Multiset Ξ±) (n : β) :
s.sum ^ (Multiset.card s * n + 1) β
span ((s.map fun (x : Ξ±) β¦ x ^ (n + 1)).toFinset : Set Ξ±) := by
induction' s using Multiset.induction_on with a s hs
Β· simp
simp only [Finset.coe_insert, Multiset.map_cons, Multiset.toFinset_cons, Multiset.sum_cons,
Multiset.card_cons, add_pow]
refine Submodule.sum_mem _ ?_
intro c _hc
rw [mem_span_insert]
by_cases h : n + 1 β€ c
Β· refine β¨a ^ (c - (n + 1)) * s.sum ^ ((Multiset.card s + 1) * n + 1 - c) *
((Multiset.card s + 1) * n + 1).choose c, 0, Submodule.zero_mem _, ?_β©
rw [mul_comm _ (a ^ (n + 1))]
simp_rw [β mul_assoc]
rw [β pow_add, add_zero, add_tsub_cancel_of_le h]
Β· use 0
simp_rw [zero_mul, zero_add]
refine β¨_, ?_, rflβ©
replace h : c β€ n := Nat.lt_succ_iff.mp (not_le.mp h)
have : (Multiset.card s + 1) * n + 1 - c = Multiset.card s * n + 1 + (n - c) := by
rw [add_mul, one_mul, add_assoc, add_comm n 1, β add_assoc, add_tsub_assoc_of_le h]
rw [this, pow_add]
simp_rw [mul_assoc, mul_comm (s.sum ^ (Multiset.card s * n + 1)), β mul_assoc]
exact mul_mem_left _ _ hs
theorem sum_pow_mem_span_pow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β Ξ±) (n : β) :
(β i β s, f i) ^ (s.card * n + 1) β span ((fun i => f i ^ (n + 1)) '' s) := by
classical
simpa only [Multiset.card_map, Multiset.map_map, comp_apply, Multiset.toFinset_map,
Finset.coe_image, Finset.val_toFinset] using pow_multiset_sum_mem_span_pow (s.1.map f) n
theorem span_pow_eq_top (s : Set Ξ±) (hs : span s = β€) (n : β) :
span ((fun (x : Ξ±) => x ^ n) '' s) = β€ := by
rw [eq_top_iff_one]
rcases n with - | n
Β· obtain rfl | β¨x, hxβ© := eq_empty_or_nonempty s
Β· rw [Set.image_empty, hs]
trivial
Β· exact subset_span β¨_, hx, pow_zero _β©
rw [eq_top_iff_one, span, Finsupp.mem_span_iff_linearCombination] at hs
rcases hs with β¨f, hfβ©
have hf : (f.support.sum fun a => f a * a) = 1 := hf -- Porting note: was `change ... at hf`
have := sum_pow_mem_span_pow f.support (fun a => f a * a) n
rw [hf, one_pow] at this
refine span_le.mpr ?_ this
rintro _ hx
simp_rw [Set.mem_image] at hx
rcases hx with β¨x, _, rflβ©
have : span ({(x : Ξ±) ^ (n + 1)} : Set Ξ±) β€ span ((fun x : Ξ± => x ^ (n + 1)) '' s) := by
rw [span_le, Set.singleton_subset_iff]
exact subset_span β¨x, x.prop, rflβ©
refine this ?_
rw [mul_pow, mem_span_singleton]
exact β¨f x ^ (n + 1), mul_comm _ _β©
theorem span_range_pow_eq_top (s : Set Ξ±) (hs : span s = β€) (n : s β β) :
span (Set.range fun x β¦ x.1 ^ n x) = β€ := by
have β¨t, hts, memβ© := Submodule.mem_span_finite_of_mem_span ((eq_top_iff_one _).mp hs)
refine top_unique ((span_pow_eq_top _ ((eq_top_iff_one _).mpr mem) <|
t.attach.sup fun x β¦ n β¨x, hts x.2β©).ge.trans <| span_le.mpr ?_)
rintro _ β¨x, hxt, rflβ©
rw [β Nat.sub_add_cancel (Finset.le_sup <| t.mem_attach β¨x, hxtβ©)]
simp_rw [pow_add]
exact mul_mem_left _ _ (subset_span β¨_, rflβ©)
theorem prod_mem {ΞΉ : Type*} {f : ΞΉ β Ξ±} {s : Finset ΞΉ}
(I : Ideal Ξ±) {i : ΞΉ} (hi : i β s) (hfi : f i β I) :
β i β s, f i β I := by
classical
rw [Finset.prod_eq_prod_diff_singleton_mul hi]
exact Ideal.mul_mem_left _ _ hfi
end Ideal
end CommSemiring
section DivisionSemiring
variable {K : Type*} [DivisionSemiring K] (I : Ideal K)
namespace Ideal
variable (K) in
/-- A bijection between (left) ideals of a division ring and `{0, 1}`, sending `β₯` to `0`
and `β€` to `1`. -/
def equivFinTwo [DecidableEq (Ideal K)] : Ideal K β Fin 2 where
toFun := fun I β¦ if I = β₯ then 0 else 1
invFun := ![β₯, β€]
left_inv := fun I β¦ by rcases eq_bot_or_top I with rfl | rfl <;> simp
right_inv := fun i β¦ by fin_cases i <;> simp
instance : Finite (Ideal K) := let _i := Classical.decEq (Ideal K); β¨equivFinTwo Kβ©
/-- Ideals of a `DivisionSemiring` are a simple order. Thanks to the way abbreviations work,
this automatically gives an `IsSimpleModule K` instance. -/
instance isSimpleOrder : IsSimpleOrder (Ideal K) :=
β¨eq_bot_or_topβ©
end Ideal
end DivisionSemiring
-- TODO: consider moving the lemmas below out of the `Ring` namespace since they are
-- about `CommSemiring`s.
namespace Ring
variable {R : Type*} [CommSemiring R]
| Mathlib/RingTheory/Ideal/Basic.lean | 218 | 221 | theorem exists_not_isUnit_of_not_isField [Nontrivial R] (hf : Β¬IsField R) :
β (x : R) (_hx : x β (0 : R)), Β¬IsUnit x := by | have : Β¬_ := fun h => hf β¨exists_pair_ne R, mul_comm, hβ©
simp_rw [isUnit_iff_exists_inv] |
/-
Copyright (c) 2022 Joseph Myers. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joseph Myers
-/
import Mathlib.Analysis.Convex.Between
import Mathlib.Analysis.Normed.Group.AddTorsor
import Mathlib.Analysis.Normed.Module.Convex
/-!
# Sides of affine subspaces
This file defines notions of two points being on the same or opposite sides of an affine subspace.
## Main definitions
* `s.WSameSide x y`: The points `x` and `y` are weakly on the same side of the affine
subspace `s`.
* `s.SSameSide x y`: The points `x` and `y` are strictly on the same side of the affine
subspace `s`.
* `s.WOppSide x y`: The points `x` and `y` are weakly on opposite sides of the affine
subspace `s`.
* `s.SOppSide x y`: The points `x` and `y` are strictly on opposite sides of the affine
subspace `s`.
-/
variable {R V V' P P' : Type*}
open AffineEquiv AffineMap
namespace AffineSubspace
section StrictOrderedCommRing
variable [CommRing R] [PartialOrder R] [IsStrictOrderedRing R]
[AddCommGroup V] [Module R V] [AddTorsor V P]
variable [AddCommGroup V'] [Module R V'] [AddTorsor V' P']
/-- The points `x` and `y` are weakly on the same side of `s`. -/
def WSameSide (s : AffineSubspace R P) (x y : P) : Prop :=
βα΅ (pβ β s) (pβ β s), SameRay R (x -α΅₯ pβ) (y -α΅₯ pβ)
/-- The points `x` and `y` are strictly on the same side of `s`. -/
def SSameSide (s : AffineSubspace R P) (x y : P) : Prop :=
s.WSameSide x y β§ x β s β§ y β s
/-- The points `x` and `y` are weakly on opposite sides of `s`. -/
def WOppSide (s : AffineSubspace R P) (x y : P) : Prop :=
βα΅ (pβ β s) (pβ β s), SameRay R (x -α΅₯ pβ) (pβ -α΅₯ y)
/-- The points `x` and `y` are strictly on opposite sides of `s`. -/
def SOppSide (s : AffineSubspace R P) (x y : P) : Prop :=
s.WOppSide x y β§ x β s β§ y β s
theorem WSameSide.map {s : AffineSubspace R P} {x y : P} (h : s.WSameSide x y) (f : P βα΅[R] P') :
(s.map f).WSameSide (f x) (f y) := by
rcases h with β¨pβ, hpβ, pβ, hpβ, hβ©
refine β¨f pβ, mem_map_of_mem f hpβ, f pβ, mem_map_of_mem f hpβ, ?_β©
simp_rw [β linearMap_vsub]
exact h.map f.linear
theorem _root_.Function.Injective.wSameSide_map_iff {s : AffineSubspace R P} {x y : P}
{f : P βα΅[R] P'} (hf : Function.Injective f) :
(s.map f).WSameSide (f x) (f y) β s.WSameSide x y := by
refine β¨fun h => ?_, fun h => h.map _β©
rcases h with β¨fpβ, hfpβ, fpβ, hfpβ, hβ©
rw [mem_map] at hfpβ hfpβ
rcases hfpβ with β¨pβ, hpβ, rflβ©
rcases hfpβ with β¨pβ, hpβ, rflβ©
refine β¨pβ, hpβ, pβ, hpβ, ?_β©
simp_rw [β linearMap_vsub, (f.linear_injective_iff.2 hf).sameRay_map_iff] at h
exact h
theorem _root_.Function.Injective.sSameSide_map_iff {s : AffineSubspace R P} {x y : P}
{f : P βα΅[R] P'} (hf : Function.Injective f) :
(s.map f).SSameSide (f x) (f y) β s.SSameSide x y := by
simp_rw [SSameSide, hf.wSameSide_map_iff, mem_map_iff_mem_of_injective hf]
@[simp]
theorem _root_.AffineEquiv.wSameSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P βα΅[R] P') :
(s.map βf).WSameSide (f x) (f y) β s.WSameSide x y :=
(show Function.Injective f.toAffineMap from f.injective).wSameSide_map_iff
@[simp]
theorem _root_.AffineEquiv.sSameSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P βα΅[R] P') :
(s.map βf).SSameSide (f x) (f y) β s.SSameSide x y :=
(show Function.Injective f.toAffineMap from f.injective).sSameSide_map_iff
theorem WOppSide.map {s : AffineSubspace R P} {x y : P} (h : s.WOppSide x y) (f : P βα΅[R] P') :
(s.map f).WOppSide (f x) (f y) := by
rcases h with β¨pβ, hpβ, pβ, hpβ, hβ©
refine β¨f pβ, mem_map_of_mem f hpβ, f pβ, mem_map_of_mem f hpβ, ?_β©
simp_rw [β linearMap_vsub]
exact h.map f.linear
theorem _root_.Function.Injective.wOppSide_map_iff {s : AffineSubspace R P} {x y : P}
{f : P βα΅[R] P'} (hf : Function.Injective f) :
(s.map f).WOppSide (f x) (f y) β s.WOppSide x y := by
refine β¨fun h => ?_, fun h => h.map _β©
rcases h with β¨fpβ, hfpβ, fpβ, hfpβ, hβ©
rw [mem_map] at hfpβ hfpβ
rcases hfpβ with β¨pβ, hpβ, rflβ©
rcases hfpβ with β¨pβ, hpβ, rflβ©
refine β¨pβ, hpβ, pβ, hpβ, ?_β©
simp_rw [β linearMap_vsub, (f.linear_injective_iff.2 hf).sameRay_map_iff] at h
exact h
theorem _root_.Function.Injective.sOppSide_map_iff {s : AffineSubspace R P} {x y : P}
{f : P βα΅[R] P'} (hf : Function.Injective f) :
(s.map f).SOppSide (f x) (f y) β s.SOppSide x y := by
simp_rw [SOppSide, hf.wOppSide_map_iff, mem_map_iff_mem_of_injective hf]
@[simp]
theorem _root_.AffineEquiv.wOppSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P βα΅[R] P') :
(s.map βf).WOppSide (f x) (f y) β s.WOppSide x y :=
(show Function.Injective f.toAffineMap from f.injective).wOppSide_map_iff
@[simp]
theorem _root_.AffineEquiv.sOppSide_map_iff {s : AffineSubspace R P} {x y : P} (f : P βα΅[R] P') :
(s.map βf).SOppSide (f x) (f y) β s.SOppSide x y :=
(show Function.Injective f.toAffineMap from f.injective).sOppSide_map_iff
theorem WSameSide.nonempty {s : AffineSubspace R P} {x y : P} (h : s.WSameSide x y) :
(s : Set P).Nonempty :=
β¨h.choose, h.choose_spec.leftβ©
theorem SSameSide.nonempty {s : AffineSubspace R P} {x y : P} (h : s.SSameSide x y) :
(s : Set P).Nonempty :=
β¨h.1.choose, h.1.choose_spec.leftβ©
theorem WOppSide.nonempty {s : AffineSubspace R P} {x y : P} (h : s.WOppSide x y) :
(s : Set P).Nonempty :=
β¨h.choose, h.choose_spec.leftβ©
theorem SOppSide.nonempty {s : AffineSubspace R P} {x y : P} (h : s.SOppSide x y) :
(s : Set P).Nonempty :=
β¨h.1.choose, h.1.choose_spec.leftβ©
theorem SSameSide.wSameSide {s : AffineSubspace R P} {x y : P} (h : s.SSameSide x y) :
s.WSameSide x y :=
h.1
theorem SSameSide.left_not_mem {s : AffineSubspace R P} {x y : P} (h : s.SSameSide x y) : x β s :=
h.2.1
theorem SSameSide.right_not_mem {s : AffineSubspace R P} {x y : P} (h : s.SSameSide x y) : y β s :=
h.2.2
theorem SOppSide.wOppSide {s : AffineSubspace R P} {x y : P} (h : s.SOppSide x y) :
s.WOppSide x y :=
h.1
theorem SOppSide.left_not_mem {s : AffineSubspace R P} {x y : P} (h : s.SOppSide x y) : x β s :=
h.2.1
theorem SOppSide.right_not_mem {s : AffineSubspace R P} {x y : P} (h : s.SOppSide x y) : y β s :=
h.2.2
theorem wSameSide_comm {s : AffineSubspace R P} {x y : P} : s.WSameSide x y β s.WSameSide y x :=
β¨fun β¨pβ, hpβ, pβ, hpβ, hβ© => β¨pβ, hpβ, pβ, hpβ, h.symmβ©,
fun β¨pβ, hpβ, pβ, hpβ, hβ© => β¨pβ, hpβ, pβ, hpβ, h.symmβ©β©
alias β¨WSameSide.symm, _β© := wSameSide_comm
theorem sSameSide_comm {s : AffineSubspace R P} {x y : P} : s.SSameSide x y β s.SSameSide y x := by
rw [SSameSide, SSameSide, wSameSide_comm, and_comm (b := x β s)]
alias β¨SSameSide.symm, _β© := sSameSide_comm
theorem wOppSide_comm {s : AffineSubspace R P} {x y : P} : s.WOppSide x y β s.WOppSide y x := by
constructor
Β· rintro β¨pβ, hpβ, pβ, hpβ, hβ©
refine β¨pβ, hpβ, pβ, hpβ, ?_β©
rwa [SameRay.sameRay_comm, β sameRay_neg_iff, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev]
Β· rintro β¨pβ, hpβ, pβ, hpβ, hβ©
refine β¨pβ, hpβ, pβ, hpβ, ?_β©
rwa [SameRay.sameRay_comm, β sameRay_neg_iff, neg_vsub_eq_vsub_rev, neg_vsub_eq_vsub_rev]
alias β¨WOppSide.symm, _β© := wOppSide_comm
theorem sOppSide_comm {s : AffineSubspace R P} {x y : P} : s.SOppSide x y β s.SOppSide y x := by
rw [SOppSide, SOppSide, wOppSide_comm, and_comm (b := x β s)]
alias β¨SOppSide.symm, _β© := sOppSide_comm
theorem not_wSameSide_bot (x y : P) : Β¬(β₯ : AffineSubspace R P).WSameSide x y :=
fun β¨_, h, _β© => h.elim
theorem not_sSameSide_bot (x y : P) : Β¬(β₯ : AffineSubspace R P).SSameSide x y :=
fun h => not_wSameSide_bot x y h.wSameSide
theorem not_wOppSide_bot (x y : P) : Β¬(β₯ : AffineSubspace R P).WOppSide x y :=
fun β¨_, h, _β© => h.elim
theorem not_sOppSide_bot (x y : P) : Β¬(β₯ : AffineSubspace R P).SOppSide x y :=
fun h => not_wOppSide_bot x y h.wOppSide
@[simp]
theorem wSameSide_self_iff {s : AffineSubspace R P} {x : P} :
s.WSameSide x x β (s : Set P).Nonempty :=
β¨fun h => h.nonempty, fun β¨p, hpβ© => β¨p, hp, p, hp, SameRay.rflβ©β©
theorem sSameSide_self_iff {s : AffineSubspace R P} {x : P} :
s.SSameSide x x β (s : Set P).Nonempty β§ x β s :=
β¨fun β¨h, hx, _β© => β¨wSameSide_self_iff.1 h, hxβ©, fun β¨h, hxβ© => β¨wSameSide_self_iff.2 h, hx, hxβ©β©
theorem wSameSide_of_left_mem {s : AffineSubspace R P} {x : P} (y : P) (hx : x β s) :
s.WSameSide x y := by
refine β¨x, hx, x, hx, ?_β©
rw [vsub_self]
apply SameRay.zero_left
theorem wSameSide_of_right_mem {s : AffineSubspace R P} (x : P) {y : P} (hy : y β s) :
s.WSameSide x y :=
(wSameSide_of_left_mem x hy).symm
theorem wOppSide_of_left_mem {s : AffineSubspace R P} {x : P} (y : P) (hx : x β s) :
s.WOppSide x y := by
refine β¨x, hx, x, hx, ?_β©
rw [vsub_self]
apply SameRay.zero_left
theorem wOppSide_of_right_mem {s : AffineSubspace R P} (x : P) {y : P} (hy : y β s) :
s.WOppSide x y :=
(wOppSide_of_left_mem x hy).symm
theorem wSameSide_vadd_left_iff {s : AffineSubspace R P} {x y : P} {v : V} (hv : v β s.direction) :
s.WSameSide (v +α΅₯ x) y β s.WSameSide x y := by
constructor
Β· rintro β¨pβ, hpβ, pβ, hpβ, hβ©
refine
β¨-v +α΅₯ pβ, AffineSubspace.vadd_mem_of_mem_direction (Submodule.neg_mem _ hv) hpβ, pβ, hpβ, ?_β©
rwa [vsub_vadd_eq_vsub_sub, sub_neg_eq_add, add_comm, β vadd_vsub_assoc]
Β· rintro β¨pβ, hpβ, pβ, hpβ, hβ©
refine β¨v +α΅₯ pβ, AffineSubspace.vadd_mem_of_mem_direction hv hpβ, pβ, hpβ, ?_β©
rwa [vadd_vsub_vadd_cancel_left]
theorem wSameSide_vadd_right_iff {s : AffineSubspace R P} {x y : P} {v : V} (hv : v β s.direction) :
s.WSameSide x (v +α΅₯ y) β s.WSameSide x y := by
rw [wSameSide_comm, wSameSide_vadd_left_iff hv, wSameSide_comm]
theorem sSameSide_vadd_left_iff {s : AffineSubspace R P} {x y : P} {v : V} (hv : v β s.direction) :
s.SSameSide (v +α΅₯ x) y β s.SSameSide x y := by
rw [SSameSide, SSameSide, wSameSide_vadd_left_iff hv, vadd_mem_iff_mem_of_mem_direction hv]
| Mathlib/Analysis/Convex/Side.lean | 248 | 252 | theorem sSameSide_vadd_right_iff {s : AffineSubspace R P} {x y : P} {v : V} (hv : v β s.direction) :
s.SSameSide x (v +α΅₯ y) β s.SSameSide x y := by | rw [sSameSide_comm, sSameSide_vadd_left_iff hv, sSameSide_comm]
theorem wOppSide_vadd_left_iff {s : AffineSubspace R P} {x y : P} {v : V} (hv : v β s.direction) : |
/-
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.Order.Compact
import Mathlib.Topology.MetricSpace.ProperSpace
import Mathlib.Topology.MetricSpace.Cauchy
import Mathlib.Topology.EMetricSpace.Diam
/-!
## Boundedness in (pseudo)-metric spaces
This file contains one definition, and various results on boundedness in pseudo-metric spaces.
* `Metric.diam s` : The `iSup` of the distances of members of `s`.
Defined in terms of `EMetric.diam`, for better handling of the case when it should be infinite.
* `isBounded_iff_subset_closedBall`: a non-empty set is bounded if and only if
it is included in some closed ball
* describing the cobounded filter, relating to the cocompact filter
* `IsCompact.isBounded`: compact sets are bounded
* `TotallyBounded.isBounded`: totally bounded sets are bounded
* `isCompact_iff_isClosed_bounded`, the **HeineβBorel theorem**:
in a proper space, a set is compact if and only if it is closed and bounded.
* `cobounded_eq_cocompact`: in a proper space, cobounded and compact sets are the same
diameter of a subset, and its relation to boundedness
## Tags
metric, pseudo_metric, bounded, diameter, Heine-Borel theorem
-/
assert_not_exists Basis
open Set Filter Bornology
open scoped ENNReal Uniformity Topology Pointwise
universe u v w
variable {Ξ± : Type u} {Ξ² : Type v} {X ΞΉ : Type*}
variable [PseudoMetricSpace Ξ±]
namespace Metric
section Bounded
variable {x : Ξ±} {s t : Set Ξ±} {r : β}
/-- Closed balls are bounded -/
theorem isBounded_closedBall : IsBounded (closedBall x r) :=
isBounded_iff.2 β¨r + r, fun y hy z hz =>
calc dist y z β€ dist y x + dist z x := dist_triangle_right _ _ _
_ β€ r + r := add_le_add hy hzβ©
/-- Open balls are bounded -/
theorem isBounded_ball : IsBounded (ball x r) :=
isBounded_closedBall.subset ball_subset_closedBall
/-- Spheres are bounded -/
theorem isBounded_sphere : IsBounded (sphere x r) :=
isBounded_closedBall.subset sphere_subset_closedBall
/-- Given a point, a bounded subset is included in some ball around this point -/
theorem isBounded_iff_subset_closedBall (c : Ξ±) : IsBounded s β β r, s β closedBall c r :=
β¨fun h β¦ (isBounded_iff.1 (h.insert c)).imp fun _r hr _x hx β¦ hr (.inr hx) (mem_insert _ _),
fun β¨_r, hrβ© β¦ isBounded_closedBall.subset hrβ©
theorem _root_.Bornology.IsBounded.subset_closedBall (h : IsBounded s) (c : Ξ±) :
β r, s β closedBall c r :=
(isBounded_iff_subset_closedBall c).1 h
theorem _root_.Bornology.IsBounded.subset_ball_lt (h : IsBounded s) (a : β) (c : Ξ±) :
β r, a < r β§ s β ball c r :=
let β¨r, hrβ© := h.subset_closedBall c
β¨max r a + 1, (le_max_right _ _).trans_lt (lt_add_one _), hr.trans <| closedBall_subset_ball <|
(le_max_left _ _).trans_lt (lt_add_one _)β©
theorem _root_.Bornology.IsBounded.subset_ball (h : IsBounded s) (c : Ξ±) : β r, s β ball c r :=
(h.subset_ball_lt 0 c).imp fun _ β¦ And.right
theorem isBounded_iff_subset_ball (c : Ξ±) : IsBounded s β β r, s β ball c r :=
β¨(IsBounded.subset_ball Β· c), fun β¨_r, hrβ© β¦ isBounded_ball.subset hrβ©
theorem _root_.Bornology.IsBounded.subset_closedBall_lt (h : IsBounded s) (a : β) (c : Ξ±) :
β r, a < r β§ s β closedBall c r :=
let β¨r, har, hrβ© := h.subset_ball_lt a c
β¨r, har, hr.trans ball_subset_closedBallβ©
theorem isBounded_closure_of_isBounded (h : IsBounded s) : IsBounded (closure s) :=
let β¨C, hβ© := isBounded_iff.1 h
isBounded_iff.2 β¨C, fun _a ha _b hb => isClosed_Iic.closure_subset <|
map_mem_closureβ continuous_dist ha hb hβ©
protected theorem _root_.Bornology.IsBounded.closure (h : IsBounded s) : IsBounded (closure s) :=
isBounded_closure_of_isBounded h
@[simp]
theorem isBounded_closure_iff : IsBounded (closure s) β IsBounded s :=
β¨fun h => h.subset subset_closure, fun h => h.closureβ©
theorem hasBasis_cobounded_compl_closedBall (c : Ξ±) :
(cobounded Ξ±).HasBasis (fun _ β¦ True) (fun r β¦ (closedBall c r)αΆ) :=
β¨compl_surjective.forall.2 fun _ β¦ (isBounded_iff_subset_closedBall c).trans <| by simpβ©
theorem hasAntitoneBasis_cobounded_compl_closedBall (c : Ξ±) :
(cobounded Ξ±).HasAntitoneBasis (fun r β¦ (closedBall c r)αΆ) :=
β¨Metric.hasBasis_cobounded_compl_closedBall _, fun _ _ hr _ β¦ by simpa using hr.trans_ltβ©
theorem hasBasis_cobounded_compl_ball (c : Ξ±) :
(cobounded Ξ±).HasBasis (fun _ β¦ True) (fun r β¦ (ball c r)αΆ) :=
β¨compl_surjective.forall.2 fun _ β¦ (isBounded_iff_subset_ball c).trans <| by simpβ©
theorem hasAntitoneBasis_cobounded_compl_ball (c : Ξ±) :
(cobounded Ξ±).HasAntitoneBasis (fun r β¦ (ball c r)αΆ) :=
β¨Metric.hasBasis_cobounded_compl_ball _, fun _ _ hr _ β¦ by simpa using hr.transβ©
@[simp]
theorem comap_dist_right_atTop (c : Ξ±) : comap (dist Β· c) atTop = cobounded Ξ± :=
(atTop_basis.comap _).eq_of_same_basis <| by
simpa only [compl_def, mem_ball, not_lt] using hasBasis_cobounded_compl_ball c
@[simp]
theorem comap_dist_left_atTop (c : Ξ±) : comap (dist c) atTop = cobounded Ξ± := by
simpa only [dist_comm _ c] using comap_dist_right_atTop c
@[simp]
theorem tendsto_dist_right_atTop_iff (c : Ξ±) {f : Ξ² β Ξ±} {l : Filter Ξ²} :
Tendsto (fun x β¦ dist (f x) c) l atTop β Tendsto f l (cobounded Ξ±) := by
rw [β comap_dist_right_atTop c, tendsto_comap_iff, Function.comp_def]
@[simp]
theorem tendsto_dist_left_atTop_iff (c : Ξ±) {f : Ξ² β Ξ±} {l : Filter Ξ²} :
Tendsto (fun x β¦ dist c (f x)) l atTop β Tendsto f l (cobounded Ξ±) := by
simp only [dist_comm c, tendsto_dist_right_atTop_iff]
theorem tendsto_dist_right_cobounded_atTop (c : Ξ±) : Tendsto (dist Β· c) (cobounded Ξ±) atTop :=
tendsto_iff_comap.2 (comap_dist_right_atTop c).ge
theorem tendsto_dist_left_cobounded_atTop (c : Ξ±) : Tendsto (dist c) (cobounded Ξ±) atTop :=
tendsto_iff_comap.2 (comap_dist_left_atTop c).ge
/-- A totally bounded set is bounded -/
theorem _root_.TotallyBounded.isBounded {s : Set Ξ±} (h : TotallyBounded s) : IsBounded s :=
-- We cover the totally bounded set by finitely many balls of radius 1,
-- and then argue that a finite union of bounded sets is bounded
let β¨_t, fint, subsβ© := (totallyBounded_iff.mp h) 1 zero_lt_one
((isBounded_biUnion fint).2 fun _ _ => isBounded_ball).subset subs
/-- A compact set is bounded -/
theorem _root_.IsCompact.isBounded {s : Set Ξ±} (h : IsCompact s) : IsBounded s :=
-- A compact set is totally bounded, thus bounded
h.totallyBounded.isBounded
theorem cobounded_le_cocompact : cobounded Ξ± β€ cocompact Ξ± :=
hasBasis_cocompact.ge_iff.2 fun _s hs β¦ hs.isBounded
theorem isCobounded_iff_closedBall_compl_subset {s : Set Ξ±} (c : Ξ±) :
IsCobounded s β β (r : β), (Metric.closedBall c r)αΆ β s := by
rw [β isBounded_compl_iff, isBounded_iff_subset_closedBall c]
apply exists_congr
intro r
rw [compl_subset_comm]
theorem _root_.Bornology.IsCobounded.closedBall_compl_subset {s : Set Ξ±} (hs : IsCobounded s)
(c : Ξ±) : β (r : β), (Metric.closedBall c r)αΆ β s :=
(isCobounded_iff_closedBall_compl_subset c).mp hs
theorem closedBall_compl_subset_of_mem_cocompact {s : Set Ξ±} (hs : s β cocompact Ξ±) (c : Ξ±) :
β (r : β), (Metric.closedBall c r)αΆ β s :=
IsCobounded.closedBall_compl_subset (cobounded_le_cocompact hs) c
theorem mem_cocompact_of_closedBall_compl_subset [ProperSpace Ξ±] (c : Ξ±)
(h : β r, (closedBall c r)αΆ β s) : s β cocompact Ξ± := by
rcases h with β¨r, hβ©
rw [Filter.mem_cocompact]
exact β¨closedBall c r, isCompact_closedBall c r, hβ©
theorem mem_cocompact_iff_closedBall_compl_subset [ProperSpace Ξ±] (c : Ξ±) :
s β cocompact Ξ± β β r, (closedBall c r)αΆ β s :=
β¨(closedBall_compl_subset_of_mem_cocompact Β· _), mem_cocompact_of_closedBall_compl_subset _β©
/-- Characterization of the boundedness of the range of a function -/
theorem isBounded_range_iff {f : Ξ² β Ξ±} : IsBounded (range f) β β C, β x y, dist (f x) (f y) β€ C :=
isBounded_iff.trans <| by simp only [forall_mem_range]
theorem isBounded_image_iff {f : Ξ² β Ξ±} {s : Set Ξ²} :
IsBounded (f '' s) β β C, β x β s, β y β s, dist (f x) (f y) β€ C :=
isBounded_iff.trans <| by simp only [forall_mem_image]
theorem isBounded_range_of_tendsto_cofinite_uniformity {f : Ξ² β Ξ±}
(hf : Tendsto (Prod.map f f) (.cofinite ΓΛ’ .cofinite) (π€ Ξ±)) : IsBounded (range f) := by
rcases (hasBasis_cofinite.prod_self.tendsto_iff uniformity_basis_dist).1 hf 1 zero_lt_one with
β¨s, hsf, hs1β©
rw [β image_union_image_compl_eq_range]
refine (hsf.image f).isBounded.union (isBounded_image_iff.2 β¨1, fun x hx y hy β¦ ?_β©)
exact le_of_lt (hs1 (x, y) β¨hx, hyβ©)
theorem isBounded_range_of_cauchy_map_cofinite {f : Ξ² β Ξ±} (hf : Cauchy (map f cofinite)) :
IsBounded (range f) :=
isBounded_range_of_tendsto_cofinite_uniformity <| (cauchy_map_iff.1 hf).2
theorem _root_.CauchySeq.isBounded_range {f : β β Ξ±} (hf : CauchySeq f) : IsBounded (range f) :=
isBounded_range_of_cauchy_map_cofinite <| by rwa [Nat.cofinite_eq_atTop]
theorem isBounded_range_of_tendsto_cofinite {f : Ξ² β Ξ±} {a : Ξ±} (hf : Tendsto f cofinite (π a)) :
IsBounded (range f) :=
isBounded_range_of_tendsto_cofinite_uniformity <|
(hf.prodMap hf).mono_right <| nhds_prod_eq.symm.trans_le (nhds_le_uniformity a)
/-- In a compact space, all sets are bounded -/
theorem isBounded_of_compactSpace [CompactSpace Ξ±] : IsBounded s :=
isCompact_univ.isBounded.subset (subset_univ _)
theorem isBounded_range_of_tendsto (u : β β Ξ±) {x : Ξ±} (hu : Tendsto u atTop (π x)) :
IsBounded (range u) :=
hu.cauchySeq.isBounded_range
theorem disjoint_nhds_cobounded (x : Ξ±) : Disjoint (π x) (cobounded Ξ±) :=
disjoint_of_disjoint_of_mem disjoint_compl_right (ball_mem_nhds _ one_pos) isBounded_ball
theorem disjoint_cobounded_nhds (x : Ξ±) : Disjoint (cobounded Ξ±) (π x) :=
(disjoint_nhds_cobounded x).symm
theorem disjoint_nhdsSet_cobounded {s : Set Ξ±} (hs : IsCompact s) : Disjoint (πΛ’ s) (cobounded Ξ±) :=
hs.disjoint_nhdsSet_left.2 fun _ _ β¦ disjoint_nhds_cobounded _
theorem disjoint_cobounded_nhdsSet {s : Set Ξ±} (hs : IsCompact s) : Disjoint (cobounded Ξ±) (πΛ’ s) :=
(disjoint_nhdsSet_cobounded hs).symm
theorem exists_isBounded_image_of_tendsto {Ξ± Ξ² : Type*} [PseudoMetricSpace Ξ²]
{l : Filter Ξ±} {f : Ξ± β Ξ²} {x : Ξ²} (hf : Tendsto f l (π x)) :
β s β l, IsBounded (f '' s) :=
(l.basis_sets.map f).disjoint_iff_left.mp <| (disjoint_nhds_cobounded x).mono_left hf
/-- If a function is continuous within a set `s` at every point of a compact set `k`, then it is
bounded on some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt
[TopologicalSpace Ξ²] {k s : Set Ξ²} {f : Ξ² β Ξ±} (hk : IsCompact k)
(hf : β x β k, ContinuousWithinAt f s x) :
β t, k β t β§ IsOpen t β§ IsBounded (f '' (t β© s)) := by
have : Disjoint (πΛ’ k β π s) (comap f (cobounded Ξ±)) := by
rw [disjoint_assoc, inf_comm, hk.disjoint_nhdsSet_left]
exact fun x hx β¦ disjoint_left_comm.2 <|
tendsto_comap.disjoint (disjoint_cobounded_nhds _) (hf x hx)
rcases ((((hasBasis_nhdsSet _).inf_principal _)).disjoint_iff ((basis_sets _).comap _)).1 this
with β¨U, β¨hUo, hkUβ©, t, ht, hdβ©
refine β¨U, hkU, hUo, (isBounded_compl_iff.2 ht).subset ?_β©
rwa [image_subset_iff, preimage_compl, subset_compl_iff_disjoint_right]
/-- If a function is continuous at every point of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt [TopologicalSpace Ξ²]
{k : Set Ξ²} {f : Ξ² β Ξ±} (hk : IsCompact k) (hf : β x β k, ContinuousAt f x) :
β t, k β t β§ IsOpen t β§ IsBounded (f '' t) := by
simp_rw [β continuousWithinAt_univ] at hf
simpa only [inter_univ] using
exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk hf
/-- If a function is continuous on a set `s` containing a compact set `k`, then it is bounded on
some open neighborhood of `k` in `s`. -/
theorem exists_isOpen_isBounded_image_inter_of_isCompact_of_continuousOn [TopologicalSpace Ξ²]
{k s : Set Ξ²} {f : Ξ² β Ξ±} (hk : IsCompact k) (hks : k β s) (hf : ContinuousOn f s) :
β t, k β t β§ IsOpen t β§ IsBounded (f '' (t β© s)) :=
exists_isOpen_isBounded_image_inter_of_isCompact_of_forall_continuousWithinAt hk fun x hx =>
hf x (hks hx)
/-- If a function is continuous on a neighborhood of a compact set `k`, then it is bounded on
some open neighborhood of `k`. -/
theorem exists_isOpen_isBounded_image_of_isCompact_of_continuousOn [TopologicalSpace Ξ²]
{k s : Set Ξ²} {f : Ξ² β Ξ±} (hk : IsCompact k) (hs : IsOpen s) (hks : k β s)
(hf : ContinuousOn f s) : β t, k β t β§ IsOpen t β§ IsBounded (f '' t) :=
exists_isOpen_isBounded_image_of_isCompact_of_forall_continuousAt hk fun _x hx =>
hf.continuousAt (hs.mem_nhds (hks hx))
/-- The **HeineβBorel theorem**: In a proper space, a closed bounded set is compact. -/
theorem isCompact_of_isClosed_isBounded [ProperSpace Ξ±] (hc : IsClosed s) (hb : IsBounded s) :
IsCompact s := by
rcases eq_empty_or_nonempty s with (rfl | β¨x, -β©)
Β· exact isCompact_empty
Β· rcases hb.subset_closedBall x with β¨r, hrβ©
exact (isCompact_closedBall x r).of_isClosed_subset hc hr
/-- The **HeineβBorel theorem**: In a proper space, the closure of a bounded set is compact. -/
theorem _root_.Bornology.IsBounded.isCompact_closure [ProperSpace Ξ±] (h : IsBounded s) :
IsCompact (closure s) :=
isCompact_of_isClosed_isBounded isClosed_closure h.closure
-- TODO: assume `[MetricSpace Ξ±]` instead of `[PseudoMetricSpace Ξ±] [T2Space Ξ±]`
/-- The **HeineβBorel theorem**:
In a proper Hausdorff space, a set is compact if and only if it is closed and bounded. -/
theorem isCompact_iff_isClosed_bounded [T2Space Ξ±] [ProperSpace Ξ±] :
IsCompact s β IsClosed s β§ IsBounded s :=
β¨fun h => β¨h.isClosed, h.isBoundedβ©, fun h => isCompact_of_isClosed_isBounded h.1 h.2β©
theorem compactSpace_iff_isBounded_univ [ProperSpace Ξ±] :
CompactSpace Ξ± β IsBounded (univ : Set Ξ±) :=
β¨@isBounded_of_compactSpace Ξ± _ _, fun hb => β¨isCompact_of_isClosed_isBounded isClosed_univ hbβ©β©
section CompactIccSpace
variable [Preorder Ξ±] [CompactIccSpace Ξ±]
theorem _root_.totallyBounded_Icc (a b : Ξ±) : TotallyBounded (Icc a b) :=
isCompact_Icc.totallyBounded
theorem _root_.totallyBounded_Ico (a b : Ξ±) : TotallyBounded (Ico a b) :=
(totallyBounded_Icc a b).subset Ico_subset_Icc_self
theorem _root_.totallyBounded_Ioc (a b : Ξ±) : TotallyBounded (Ioc a b) :=
(totallyBounded_Icc a b).subset Ioc_subset_Icc_self
theorem _root_.totallyBounded_Ioo (a b : Ξ±) : TotallyBounded (Ioo a b) :=
(totallyBounded_Icc a b).subset Ioo_subset_Icc_self
theorem isBounded_Icc (a b : Ξ±) : IsBounded (Icc a b) :=
(totallyBounded_Icc a b).isBounded
theorem isBounded_Ico (a b : Ξ±) : IsBounded (Ico a b) :=
(totallyBounded_Ico a b).isBounded
theorem isBounded_Ioc (a b : Ξ±) : IsBounded (Ioc a b) :=
(totallyBounded_Ioc a b).isBounded
theorem isBounded_Ioo (a b : Ξ±) : IsBounded (Ioo a b) :=
(totallyBounded_Ioo a b).isBounded
/-- In a pseudo metric space with a conditionally complete linear order such that the order and the
metric structure give the same topology, any order-bounded set is metric-bounded. -/
theorem isBounded_of_bddAbove_of_bddBelow {s : Set Ξ±} (hβ : BddAbove s) (hβ : BddBelow s) :
IsBounded s :=
let β¨u, huβ© := hβ
let β¨l, hlβ© := hβ
(isBounded_Icc l u).subset (fun _x hx => mem_Icc.mpr β¨hl hx, hu hxβ©)
end CompactIccSpace
end Bounded
section Diam
variable {s : Set Ξ±} {x y z : Ξ±}
/-- The diameter of a set in a metric space. To get controllable behavior even when the diameter
should be infinite, we express it in terms of the `EMetric.diam` -/
noncomputable def diam (s : Set Ξ±) : β :=
ENNReal.toReal (EMetric.diam s)
/-- The diameter of a set is always nonnegative -/
theorem diam_nonneg : 0 β€ diam s :=
ENNReal.toReal_nonneg
theorem diam_subsingleton (hs : s.Subsingleton) : diam s = 0 := by
simp only [diam, EMetric.diam_subsingleton hs, ENNReal.toReal_zero]
/-- The empty set has zero diameter -/
@[simp]
theorem diam_empty : diam (β
: Set Ξ±) = 0 :=
diam_subsingleton subsingleton_empty
/-- A singleton has zero diameter -/
@[simp]
theorem diam_singleton : diam ({x} : Set Ξ±) = 0 :=
diam_subsingleton subsingleton_singleton
@[to_additive (attr := simp)]
theorem diam_one [One Ξ±] : diam (1 : Set Ξ±) = 0 :=
diam_singleton
-- Does not work as a simp-lemma, since {x, y} reduces to (insert y {x})
theorem diam_pair : diam ({x, y} : Set Ξ±) = dist x y := by
simp only [diam, EMetric.diam_pair, dist_edist]
-- Does not work as a simp-lemma, since {x, y, z} reduces to (insert z (insert y {x}))
theorem diam_triple :
Metric.diam ({x, y, z} : Set Ξ±) = max (max (dist x y) (dist x z)) (dist y z) := by
simp only [Metric.diam, EMetric.diam_triple, dist_edist]
rw [ENNReal.toReal_max, ENNReal.toReal_max] <;> apply_rules [ne_of_lt, edist_lt_top, max_lt]
/-- If the distance between any two points in a set is bounded by some constant `C`,
then `ENNReal.ofReal C` bounds the emetric diameter of this set. -/
theorem ediam_le_of_forall_dist_le {C : β} (h : β x β s, β y β s, dist x y β€ C) :
EMetric.diam s β€ ENNReal.ofReal C :=
EMetric.diam_le fun x hx y hy => (edist_dist x y).symm βΈ ENNReal.ofReal_le_ofReal (h x hx y hy)
/-- If the distance between any two points in a set is bounded by some non-negative constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le {C : β} (hβ : 0 β€ C) (h : β x β s, β y β s, dist x y β€ C) :
diam s β€ C :=
ENNReal.toReal_le_of_le_ofReal hβ (ediam_le_of_forall_dist_le h)
/-- If the distance between any two points in a nonempty set is bounded by some constant,
this constant bounds the diameter. -/
theorem diam_le_of_forall_dist_le_of_nonempty (hs : s.Nonempty) {C : β}
(h : β x β s, β y β s, dist x y β€ C) : diam s β€ C :=
have hβ : 0 β€ C :=
let β¨x, hxβ© := hs
le_trans dist_nonneg (h x hx x hx)
diam_le_of_forall_dist_le hβ h
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem' (h : EMetric.diam s β β€) (hx : x β s) (hy : y β s) :
dist x y β€ diam s := by
rw [diam, dist_edist]
exact ENNReal.toReal_mono h <| EMetric.edist_le_diam_of_mem hx hy
/-- Characterize the boundedness of a set in terms of the finiteness of its emetric.diameter. -/
theorem isBounded_iff_ediam_ne_top : IsBounded s β EMetric.diam s β β€ :=
isBounded_iff.trans <| Iff.intro
(fun β¨_C, hCβ© => ne_top_of_le_ne_top ENNReal.ofReal_ne_top <| ediam_le_of_forall_dist_le hC)
fun h => β¨diam s, fun _x hx _y hy => dist_le_diam_of_mem' h hx hyβ©
alias β¨_root_.Bornology.IsBounded.ediam_ne_top, _β© := isBounded_iff_ediam_ne_top
theorem ediam_eq_top_iff_unbounded : EMetric.diam s = β€ β Β¬IsBounded s :=
isBounded_iff_ediam_ne_top.not_left.symm
theorem ediam_univ_eq_top_iff_noncompact [ProperSpace Ξ±] :
EMetric.diam (univ : Set Ξ±) = β β NoncompactSpace Ξ± := by
rw [β not_compactSpace_iff, compactSpace_iff_isBounded_univ, isBounded_iff_ediam_ne_top,
Classical.not_not]
@[simp]
theorem ediam_univ_of_noncompact [ProperSpace Ξ±] [NoncompactSpace Ξ±] :
EMetric.diam (univ : Set Ξ±) = β :=
ediam_univ_eq_top_iff_noncompact.mpr βΉ_βΊ
@[simp]
theorem diam_univ_of_noncompact [ProperSpace Ξ±] [NoncompactSpace Ξ±] : diam (univ : Set Ξ±) = 0 := by
simp [diam]
/-- The distance between two points in a set is controlled by the diameter of the set. -/
theorem dist_le_diam_of_mem (h : IsBounded s) (hx : x β s) (hy : y β s) : dist x y β€ diam s :=
dist_le_diam_of_mem' h.ediam_ne_top hx hy
theorem ediam_of_unbounded (h : Β¬IsBounded s) : EMetric.diam s = β := ediam_eq_top_iff_unbounded.2 h
/-- An unbounded set has zero diameter. If you would prefer to get the value β, use `EMetric.diam`.
This lemma makes it possible to avoid side conditions in some situations -/
theorem diam_eq_zero_of_unbounded (h : Β¬IsBounded s) : diam s = 0 := by
rw [diam, ediam_of_unbounded h, ENNReal.toReal_top]
/-- If `s β t`, then the diameter of `s` is bounded by that of `t`, provided `t` is bounded. -/
theorem diam_mono {s t : Set Ξ±} (h : s β t) (ht : IsBounded t) : diam s β€ diam t :=
ENNReal.toReal_mono ht.ediam_ne_top <| EMetric.diam_mono h
/-- The diameter of a union is controlled by the sum of the diameters, and the distance between
any two points in each of the sets. This lemma is true without any side condition, since it is
obviously true if `s βͺ t` is unbounded. -/
theorem diam_union {t : Set Ξ±} (xs : x β s) (yt : y β t) :
diam (s βͺ t) β€ diam s + dist x y + diam t := by
simp only [diam, dist_edist]
refine (ENNReal.toReal_le_add' (EMetric.diam_union xs yt) ?_ ?_).trans
(add_le_add_right ENNReal.toReal_add_le _)
Β· simp only [ENNReal.add_eq_top, edist_ne_top, or_false]
exact fun h β¦ top_unique <| h βΈ EMetric.diam_mono subset_union_left
Β· exact fun h β¦ top_unique <| h βΈ EMetric.diam_mono subset_union_right
/-- If two sets intersect, the diameter of the union is bounded by the sum of the diameters. -/
theorem diam_union' {t : Set Ξ±} (h : (s β© t).Nonempty) : diam (s βͺ t) β€ diam s + diam t := by
rcases h with β¨x, β¨xs, xtβ©β©
simpa using diam_union xs xt
theorem diam_le_of_subset_closedBall {r : β} (hr : 0 β€ r) (h : s β closedBall x r) :
diam s β€ 2 * r :=
diam_le_of_forall_dist_le (mul_nonneg zero_le_two hr) fun a ha b hb =>
calc
dist a b β€ dist a x + dist b x := dist_triangle_right _ _ _
_ β€ r + r := add_le_add (h ha) (h hb)
_ = 2 * r := by simp [mul_two, mul_comm]
/-- The diameter of a closed ball of radius `r` is at most `2 r`. -/
theorem diam_closedBall {r : β} (h : 0 β€ r) : diam (closedBall x r) β€ 2 * r :=
diam_le_of_subset_closedBall h Subset.rfl
/-- The diameter of a ball of radius `r` is at most `2 r`. -/
theorem diam_ball {r : β} (h : 0 β€ r) : diam (ball x r) β€ 2 * r :=
diam_le_of_subset_closedBall h ball_subset_closedBall
/-- If a family of complete sets with diameter tending to `0` is such that each finite intersection
is nonempty, then the total intersection is also nonempty. -/
theorem _root_.IsComplete.nonempty_iInter_of_nonempty_biInter {s : β β Set Ξ±}
(h0 : IsComplete (s 0)) (hs : β n, IsClosed (s n)) (h's : β n, IsBounded (s n))
(h : β N, (β n β€ N, s n).Nonempty) (h' : Tendsto (fun n => diam (s n)) atTop (π 0)) :
(β n, s n).Nonempty := by
let u N := (h N).some
have I : β n N, n β€ N β u N β s n := by
intro n N hn
apply mem_of_subset_of_mem _ (h N).choose_spec
intro x hx
simp only [mem_iInter] at hx
exact hx n hn
have : CauchySeq u := by
apply cauchySeq_of_le_tendsto_0 _ _ h'
intro m n N hm hn
exact dist_le_diam_of_mem (h's N) (I _ _ hm) (I _ _ hn)
obtain β¨x, -, xlimβ© : β x β s 0, Tendsto (fun n : β => u n) atTop (π x) :=
cauchySeq_tendsto_of_isComplete h0 (fun n => I 0 n (zero_le _)) this
refine β¨x, mem_iInter.2 fun n => ?_β©
apply (hs n).mem_of_tendsto xlim
filter_upwards [Ici_mem_atTop n] with p hp
exact I n p hp
/-- In a complete space, if a family of closed sets with diameter tending to `0` is such that each
finite intersection is nonempty, then the total intersection is also nonempty. -/
theorem nonempty_iInter_of_nonempty_biInter [CompleteSpace Ξ±] {s : β β Set Ξ±}
(hs : β n, IsClosed (s n)) (h's : β n, IsBounded (s n)) (h : β N, (β n β€ N, s n).Nonempty)
(h' : Tendsto (fun n => diam (s n)) atTop (π 0)) : (β n, s n).Nonempty :=
(hs 0).isComplete.nonempty_iInter_of_nonempty_biInter hs h's h h'
end Diam
end Metric
namespace Mathlib.Meta.Positivity
open Lean Meta Qq Function
/-- Extension for the `positivity` tactic: the diameter of a set is always nonnegative. -/
@[positivity Metric.diam _]
def evalDiam : PositivityExt where eval {u Ξ±} _zΞ± _pΞ± e := do
match u, Ξ±, e with
| 0, ~q(β), ~q(@Metric.diam _ $inst $s) =>
assertInstancesCommute
pure (.nonnegative q(Metric.diam_nonneg))
| _, _, _ => throwError "not β Β· β"
end Mathlib.Meta.Positivity
open Metric
| Mathlib/Topology/MetricSpace/Bounded.lean | 531 | 537 | theorem Metric.cobounded_eq_cocompact [ProperSpace Ξ±] : cobounded Ξ± = cocompact Ξ± := by | nontriviality Ξ±; inhabit Ξ±
exact cobounded_le_cocompact.antisymm <| (hasBasis_cobounded_compl_closedBall default).ge_iff.2
fun _ _ β¦ (isCompact_closedBall _ _).compl_mem_cocompact
theorem tendsto_dist_right_cocompact_atTop [ProperSpace Ξ±] (x : Ξ±) :
Tendsto (dist Β· x) (cocompact Ξ±) atTop := |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Joey van Langen, Casper Putz
-/
import Mathlib.Algebra.CharP.Algebra
import Mathlib.Algebra.CharP.Reduced
import Mathlib.Algebra.Field.ZMod
import Mathlib.Data.Nat.Prime.Int
import Mathlib.Data.ZMod.ValMinAbs
import Mathlib.LinearAlgebra.FreeModule.Finite.Matrix
import Mathlib.FieldTheory.Finiteness
import Mathlib.FieldTheory.Perfect
import Mathlib.FieldTheory.Separable
import Mathlib.RingTheory.IntegralDomain
/-!
# Finite fields
This file contains basic results about finite fields.
Throughout most of this file, `K` denotes a finite field
and `q` is notation for the cardinality of `K`.
See `RingTheory.IntegralDomain` for the fact that the unit group of a finite field is a
cyclic group, as well as the fact that every finite integral domain is a field
(`Fintype.fieldOfDomain`).
## Main results
1. `Fintype.card_units`: The unit group of a finite field has cardinality `q - 1`.
2. `sum_pow_units`: The sum of `x^i`, where `x` ranges over the units of `K`, is
- `q-1` if `q-1 β£ i`
- `0` otherwise
3. `FiniteField.card`: The cardinality `q` is a power of the characteristic of `K`.
See `FiniteField.card'` for a variant.
## Notation
Throughout most of this file, `K` denotes a finite field
and `q` is notation for the cardinality of `K`.
## Implementation notes
While `Fintype KΛ£` can be inferred from `Fintype K` in the presence of `DecidableEq K`,
in this file we take the `Fintype KΛ£` argument directly to reduce the chance of typeclass
diamonds, as `Fintype` carries data.
-/
variable {K : Type*} {R : Type*}
local notation "q" => Fintype.card K
open Finset
open scoped Polynomial
namespace FiniteField
section Polynomial
variable [CommRing R] [IsDomain R]
open Polynomial
/-- The cardinality of a field is at most `n` times the cardinality of the image of a degree `n`
polynomial -/
theorem card_image_polynomial_eval [DecidableEq R] [Fintype R] {p : R[X]} (hp : 0 < p.degree) :
Fintype.card R β€ natDegree p * #(univ.image fun x => eval x p) :=
Finset.card_le_mul_card_image _ _ (fun a _ =>
calc
_ = #(p - C a).roots.toFinset :=
congr_arg card (by simp [Finset.ext_iff, β mem_roots_sub_C hp])
_ β€ Multiset.card (p - C a).roots := Multiset.toFinset_card_le _
_ β€ _ := card_roots_sub_C' hp)
/-- If `f` and `g` are quadratic polynomials, then the `f.eval a + g.eval b = 0` has a solution. -/
theorem exists_root_sum_quadratic [Fintype R] {f g : R[X]} (hf2 : degree f = 2) (hg2 : degree g = 2)
(hR : Fintype.card R % 2 = 1) : β a b, f.eval a + g.eval b = 0 :=
letI := Classical.decEq R
suffices Β¬Disjoint (univ.image fun x : R => eval x f)
(univ.image fun x : R => eval x (-g)) by
simp only [disjoint_left, mem_image] at this
push_neg at this
rcases this with β¨x, β¨a, _, haβ©, β¨b, _, hbβ©β©
exact β¨a, b, by rw [ha, β hb, eval_neg, neg_add_cancel]β©
fun hd : Disjoint _ _ =>
lt_irrefl (2 * #((univ.image fun x : R => eval x f) βͺ univ.image fun x : R => eval x (-g))) <|
calc 2 * #((univ.image fun x : R => eval x f) βͺ univ.image fun x : R => eval x (-g))
β€ 2 * Fintype.card R := Nat.mul_le_mul_left _ (Finset.card_le_univ _)
_ = Fintype.card R + Fintype.card R := two_mul _
_ < natDegree f * #(univ.image fun x : R => eval x f) +
natDegree (-g) * #(univ.image fun x : R => eval x (-g)) :=
(add_lt_add_of_lt_of_le
(lt_of_le_of_ne (card_image_polynomial_eval (by rw [hf2]; decide))
(mt (congr_arg (Β· % 2)) (by simp [natDegree_eq_of_degree_eq_some hf2, hR])))
(card_image_polynomial_eval (by rw [degree_neg, hg2]; decide)))
_ = 2 * #((univ.image fun x : R => eval x f) βͺ univ.image fun x : R => eval x (-g)) := by
rw [card_union_of_disjoint hd]
simp [natDegree_eq_of_degree_eq_some hf2, natDegree_eq_of_degree_eq_some hg2, mul_add]
end Polynomial
theorem prod_univ_units_id_eq_neg_one [CommRing K] [IsDomain K] [Fintype KΛ£] :
β x : KΛ£, x = (-1 : KΛ£) := by
classical
have : (β x β (@univ KΛ£ _).erase (-1), x) = 1 :=
prod_involution (fun x _ => xβ»ΒΉ) (by simp)
(fun a => by simp +contextual [Units.inv_eq_self_iff])
(fun a => by simp [@inv_eq_iff_eq_inv _ _ a]) (by simp)
rw [β insert_erase (mem_univ (-1 : KΛ£)), prod_insert (not_mem_erase _ _), this, mul_one]
theorem card_cast_subgroup_card_ne_zero [Ring K] [NoZeroDivisors K] [Nontrivial K]
(G : Subgroup KΛ£) [Fintype G] : (Fintype.card G : K) β 0 := by
let n := Fintype.card G
intro nzero
have β¨p, char_pβ© := CharP.exists K
have hd : p β£ n := (CharP.cast_eq_zero_iff K p n).mp nzero
cases CharP.char_is_prime_or_zero K p with
| inr pzero =>
exact (Fintype.card_pos).ne' <| Nat.eq_zero_of_zero_dvd <| pzero βΈ hd
| inl pprime =>
have fact_pprime := Fact.mk pprime
-- G has an element x of order p by Cauchy's theorem
have β¨x, hxβ© := exists_prime_orderOf_dvd_card p hd
-- F has an element u (= ββx) of order p
let u := ((x : KΛ£) : K)
have hu : orderOf u = p := by rwa [orderOf_units, Subgroup.orderOf_coe]
-- u ^ p = 1 implies (u - 1) ^ p = 0 and hence u = 1 ...
have h : u = 1 := by
rw [β sub_left_inj, sub_self 1]
apply pow_eq_zero (n := p)
rw [sub_pow_char_of_commute, one_pow, β hu, pow_orderOf_eq_one, sub_self]
exact Commute.one_right u
-- ... meaning x didn't have order p after all, contradiction
apply pprime.one_lt.ne
rw [β hu, h, orderOf_one]
/-- The sum of a nontrivial subgroup of the units of a field is zero. -/
theorem sum_subgroup_units_eq_zero [Ring K] [NoZeroDivisors K]
{G : Subgroup KΛ£} [Fintype G] (hg : G β β₯) :
β x : G, (x.val : K) = 0 := by
rw [Subgroup.ne_bot_iff_exists_ne_one] at hg
rcases hg with β¨a, haβ©
-- The action of a on G as an embedding
let a_mul_emb : G βͺ G := mulLeftEmbedding a
-- ... and leaves G unchanged
have h_unchanged : Finset.univ.map a_mul_emb = Finset.univ := by simp
-- Therefore the sum of x over a G is the sum of a x over G
have h_sum_map := Finset.univ.sum_map a_mul_emb fun x => ((x : KΛ£) : K)
-- ... and the former is the sum of x over G.
-- By algebraic manipulation, we have Ξ£ G, x = β G, a x = a β G, x
simp only [h_unchanged, mulLeftEmbedding_apply, Subgroup.coe_mul, Units.val_mul, β mul_sum,
a_mul_emb] at h_sum_map
-- thus one of (a - 1) or β G, x is zero
have hzero : (((a : KΛ£) : K) - 1) = 0 β¨ β x : β₯G, ((x : KΛ£) : K) = 0 := by
rw [β mul_eq_zero, sub_mul, β h_sum_map, one_mul, sub_self]
apply Or.resolve_left hzero
contrapose! ha
ext
rwa [β sub_eq_zero]
/-- The sum of a subgroup of the units of a field is 1 if the subgroup is trivial and 1 otherwise -/
@[simp]
theorem sum_subgroup_units [Ring K] [NoZeroDivisors K]
{G : Subgroup KΛ£} [Fintype G] [Decidable (G = β₯)] :
β x : G, (x.val : K) = if G = β₯ then 1 else 0 := by
by_cases G_bot : G = β₯
Β· subst G_bot
simp only [univ_unique, sum_singleton, βreduceIte, Units.val_eq_one, OneMemClass.coe_eq_one]
rw [Set.default_coe_singleton]
rfl
Β· simp only [G_bot, ite_false]
exact sum_subgroup_units_eq_zero G_bot
@[simp]
theorem sum_subgroup_pow_eq_zero [CommRing K] [NoZeroDivisors K]
{G : Subgroup KΛ£} [Fintype G] {k : β} (k_pos : k β 0) (k_lt_card_G : k < Fintype.card G) :
β x : G, ((x : KΛ£) : K) ^ k = 0 := by
rw [β Nat.card_eq_fintype_card] at k_lt_card_G
nontriviality K
have := NoZeroDivisors.to_isDomain K
rcases (exists_pow_ne_one_of_isCyclic k_pos k_lt_card_G) with β¨a, haβ©
rw [Finset.sum_eq_multiset_sum]
have h_multiset_map :
Finset.univ.val.map (fun x : G => ((x : KΛ£) : K) ^ k) =
Finset.univ.val.map (fun x : G => ((x : KΛ£) : K) ^ k * ((a : KΛ£) : K) ^ k) := by
simp_rw [β mul_pow]
have as_comp :
(fun x : β₯G => (((x : KΛ£) : K) * ((a : KΛ£) : K)) ^ k)
= (fun x : β₯G => ((x : KΛ£) : K) ^ k) β fun x : β₯G => x * a := by
funext x
simp only [Function.comp_apply, Subgroup.coe_mul, Units.val_mul]
rw [as_comp, β Multiset.map_map]
congr
rw [eq_comm]
exact Multiset.map_univ_val_equiv (Equiv.mulRight a)
have h_multiset_map_sum : (Multiset.map (fun x : G => ((x : KΛ£) : K) ^ k) Finset.univ.val).sum =
(Multiset.map (fun x : G => ((x : KΛ£) : K) ^ k * ((a : KΛ£) : K) ^ k) Finset.univ.val).sum := by
rw [h_multiset_map]
rw [Multiset.sum_map_mul_right] at h_multiset_map_sum
have hzero : (((a : KΛ£) : K) ^ k - 1 : K)
* (Multiset.map (fun i : G => (i.val : K) ^ k) Finset.univ.val).sum = 0 := by
rw [sub_mul, mul_comm, β h_multiset_map_sum, one_mul, sub_self]
rw [mul_eq_zero] at hzero
refine hzero.resolve_left fun h => ha ?_
ext
rw [β sub_eq_zero]
simp_rw [SubmonoidClass.coe_pow, Units.val_pow_eq_pow_val, OneMemClass.coe_one, Units.val_one, h]
section
variable [GroupWithZero K] [Fintype K]
theorem pow_card_sub_one_eq_one (a : K) (ha : a β 0) : a ^ (q - 1) = 1 := by
calc
a ^ (Fintype.card K - 1) = (Units.mk0 a ha ^ (Fintype.card K - 1) : KΛ£).1 := by
rw [Units.val_pow_eq_pow_val, Units.val_mk0]
_ = 1 := by
classical
rw [β Fintype.card_units, pow_card_eq_one]
rfl
| Mathlib/FieldTheory/Finite/Basic.lean | 225 | 228 | theorem pow_card (a : K) : a ^ q = a := by | by_cases h : a = 0; Β· rw [h]; apply zero_pow Fintype.card_ne_zero
rw [β Nat.succ_pred_eq_of_pos Fintype.card_pos, pow_succ, Nat.pred_eq_sub_one,
pow_card_sub_one_eq_one a h, one_mul] |
/-
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, Floris van Doorn
-/
import Mathlib.Analysis.Calculus.ContDiff.Operations
import Mathlib.Data.Finset.Sym
import Mathlib.Data.Nat.Choose.Cast
import Mathlib.Data.Nat.Choose.Multinomial
/-!
# Bounds on higher derivatives
`norm_iteratedFDeriv_comp_le` gives the bound `n! * C * D ^ n` for the `n`-th derivative
of `g β f` assuming that the derivatives of `g` are bounded by `C` and the `i`-th
derivative of `f` is bounded by `D ^ i`.
-/
noncomputable section
open scoped NNReal Nat
universe u uD uE uF uG
open Set Fin Filter Function
variable {π : Type*} [NontriviallyNormedField π] {D : Type uD} [NormedAddCommGroup D]
[NormedSpace π D] {E : Type uE} [NormedAddCommGroup E] [NormedSpace π E] {F : Type uF}
[NormedAddCommGroup F] [NormedSpace π F] {G : Type uG} [NormedAddCommGroup G] [NormedSpace π G]
{s sβ t u : Set E}
/-!## Quantitative bounds -/
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear. This lemma is an auxiliary version
assuming all spaces live in the same universe, to enable an induction. Use instead
`ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear` that removes this assumption. -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_aux {Du Eu Fu Gu : Type u}
[NormedAddCommGroup Du] [NormedSpace π Du] [NormedAddCommGroup Eu] [NormedSpace π Eu]
[NormedAddCommGroup Fu] [NormedSpace π Fu] [NormedAddCommGroup Gu] [NormedSpace π Gu]
(B : Eu βL[π] Fu βL[π] Gu) {f : Du β Eu} {g : Du β Fu} {n : β} {s : Set Du} {x : Du}
(hf : ContDiffOn π n f s) (hg : ContDiffOn π n g s) (hs : UniqueDiffOn π s) (hx : x β s) :
βiteratedFDerivWithin π n (fun y => B (f y) (g y)) s xβ β€
βBβ * β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ := by
/- We argue by induction on `n`. The bound is trivial for `n = 0`. For `n + 1`, we write
the `(n+1)`-th derivative as the `n`-th derivative of the derivative `B f g' + B f' g`,
and apply the inductive assumption to each of those two terms. For this induction to make sense,
the spaces of linear maps that appear in the induction should be in the same universe as the
original spaces, which explains why we assume in the lemma that all spaces live in the same
universe. -/
induction' n with n IH generalizing Eu Fu Gu
Β· simp only [norm_iteratedFDerivWithin_zero, zero_add, Finset.range_one,
Finset.sum_singleton, Nat.choose_self, Nat.cast_one, one_mul, Nat.sub_zero, β mul_assoc]
apply B.le_opNormβ
Β· have In : (n : WithTop ββ) + 1 β€ n.succ := by simp only [Nat.cast_succ, le_refl]
-- Porting note: the next line is a hack allowing Lean to find the operator norm instance.
let norm := @ContinuousLinearMap.hasOpNorm _ _ Eu ((Du βL[π] Fu) βL[π] Du βL[π] Gu) _ _ _ _ _ _
(RingHom.id π)
have I1 :
βiteratedFDerivWithin π n (fun y : Du => B.precompR Du (f y) (fderivWithin π g s y)) s xβ β€
βBβ * β i β Finset.range (n + 1), n.choose i * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n + 1 - i) g s xβ := by
calc
βiteratedFDerivWithin π n (fun y : Du => B.precompR Du (f y) (fderivWithin π g s y)) s xβ β€
βB.precompR Duβ * β i β Finset.range (n + 1),
n.choose i * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) (fderivWithin π g s) s xβ :=
IH _ (hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In)
_ β€ βBβ * β i β Finset.range (n + 1), n.choose i * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) (fderivWithin π g s) s xβ :=
mul_le_mul_of_nonneg_right (B.norm_precompR_le Du) (by positivity)
_ = _ := by
congr 1
apply Finset.sum_congr rfl fun i hi => ?_
rw [Nat.succ_sub (Nat.lt_succ_iff.1 (Finset.mem_range.1 hi)),
β norm_iteratedFDerivWithin_fderivWithin hs hx]
-- Porting note: the next line is a hack allowing Lean to find the operator norm instance.
let norm := @ContinuousLinearMap.hasOpNorm _ _ (Du βL[π] Eu) (Fu βL[π] Du βL[π] Gu) _ _ _ _ _ _
(RingHom.id π)
have I2 :
βiteratedFDerivWithin π n (fun y : Du => B.precompL Du (fderivWithin π f s y) (g y)) s xβ β€
βBβ * β i β Finset.range (n + 1), n.choose i * βiteratedFDerivWithin π (i + 1) f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ :=
calc
βiteratedFDerivWithin π n (fun y : Du => B.precompL Du (fderivWithin π f s y) (g y)) s xβ β€
βB.precompL Duβ * β i β Finset.range (n + 1),
n.choose i * βiteratedFDerivWithin π i (fderivWithin π f s) s xβ *
βiteratedFDerivWithin π (n - i) g s xβ :=
IH _ (hf.fderivWithin hs In) (hg.of_le (Nat.cast_le.2 (Nat.le_succ n)))
_ β€ βBβ * β i β Finset.range (n + 1),
n.choose i * βiteratedFDerivWithin π i (fderivWithin π f s) s xβ *
βiteratedFDerivWithin π (n - i) g s xβ :=
mul_le_mul_of_nonneg_right (B.norm_precompL_le Du) (by positivity)
_ = _ := by
congr 1
apply Finset.sum_congr rfl fun i _ => ?_
rw [β norm_iteratedFDerivWithin_fderivWithin hs hx]
have J : iteratedFDerivWithin π n
(fun y : Du => fderivWithin π (fun y : Du => B (f y) (g y)) s y) s x =
iteratedFDerivWithin π n (fun y => B.precompR Du (f y)
(fderivWithin π g s y) + B.precompL Du (fderivWithin π f s y) (g y)) s x := by
apply iteratedFDerivWithin_congr (fun y hy => ?_) hx
have L : (1 : WithTop ββ) β€ n.succ := by
simpa only [ENat.coe_one, Nat.one_le_cast] using Nat.succ_pos n
exact B.fderivWithin_of_bilinear (hf.differentiableOn L y hy) (hg.differentiableOn L y hy)
(hs y hy)
rw [β norm_iteratedFDerivWithin_fderivWithin hs hx, J]
have A : ContDiffOn π n (fun y => B.precompR Du (f y) (fderivWithin π g s y)) s :=
(B.precompR Du).isBoundedBilinearMap.contDiff.compβ_contDiffOn
(hf.of_le (Nat.cast_le.2 (Nat.le_succ n))) (hg.fderivWithin hs In)
have A' : ContDiffOn π n (fun y => B.precompL Du (fderivWithin π f s y) (g y)) s :=
(B.precompL Du).isBoundedBilinearMap.contDiff.compβ_contDiffOn (hf.fderivWithin hs In)
(hg.of_le (Nat.cast_le.2 (Nat.le_succ n)))
rw [iteratedFDerivWithin_add_apply' (A.contDiffWithinAt hx) (A'.contDiffWithinAt hx) hs hx]
apply (norm_add_le _ _).trans ((add_le_add I1 I2).trans (le_of_eq ?_))
simp_rw [β mul_add, mul_assoc]
congr 1
exact (Finset.sum_choose_succ_mul
(fun i j => βiteratedFDerivWithin π i f s xβ * βiteratedFDerivWithin π j g s xβ) n).symm
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear:
`βD^n (x β¦ B (f x) (g x))β β€ βBβ β_{k β€ n} n.choose k βD^k fβ βD^{n-k} gβ` -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear (B : E βL[π] F βL[π] G)
{f : D β E} {g : D β F} {N : WithTop ββ} {s : Set D} {x : D} (hf : ContDiffOn π N f s)
(hg : ContDiffOn π N g s) (hs : UniqueDiffOn π s) (hx : x β s) {n : β} (hn : n β€ N) :
βiteratedFDerivWithin π n (fun y => B (f y) (g y)) s xβ β€
βBβ * β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ := by
/- We reduce the bound to the case where all spaces live in the same universe (in which we
already have proved the result), by using linear isometries between the spaces and their `ULift`
to a common universe. These linear isometries preserve the norm of the iterated derivative. -/
let Du : Type max uD uE uF uG := ULift.{max uE uF uG, uD} D
let Eu : Type max uD uE uF uG := ULift.{max uD uF uG, uE} E
let Fu : Type max uD uE uF uG := ULift.{max uD uE uG, uF} F
let Gu : Type max uD uE uF uG := ULift.{max uD uE uF, uG} G
have isoD : Du ββα΅’[π] D := LinearIsometryEquiv.ulift π D
have isoE : Eu ββα΅’[π] E := LinearIsometryEquiv.ulift π E
have isoF : Fu ββα΅’[π] F := LinearIsometryEquiv.ulift π F
have isoG : Gu ββα΅’[π] G := LinearIsometryEquiv.ulift π G
-- lift `f` and `g` to versions `fu` and `gu` on the lifted spaces.
let fu : Du β Eu := isoE.symm β f β isoD
let gu : Du β Fu := isoF.symm β g β isoD
-- lift the bilinear map `B` to a bilinear map `Bu` on the lifted spaces.
let Buβ : Eu βL[π] Fu βL[π] G := ((B.comp (isoE : Eu βL[π] E)).flip.comp (isoF : Fu βL[π] F)).flip
let Bu : Eu βL[π] Fu βL[π] Gu :=
ContinuousLinearMap.compL π Eu (Fu βL[π] G) (Fu βL[π] Gu)
(ContinuousLinearMap.compL π Fu G Gu (isoG.symm : G βL[π] Gu)) Buβ
have hBu : Bu = ContinuousLinearMap.compL π Eu (Fu βL[π] G) (Fu βL[π] Gu)
(ContinuousLinearMap.compL π Fu G Gu (isoG.symm : G βL[π] Gu)) Buβ := rfl
have Bu_eq : (fun y => Bu (fu y) (gu y)) = isoG.symm β (fun y => B (f y) (g y)) β isoD := by
ext1 y
simp [Du, Eu, Fu, Gu, hBu, Buβ, fu, gu]
-- All norms are preserved by the lifting process.
have Bu_le : βBuβ β€ βBβ := by
refine ContinuousLinearMap.opNorm_le_bound _ (norm_nonneg B) fun y => ?_
refine ContinuousLinearMap.opNorm_le_bound _ (by positivity) fun x => ?_
simp only [Du, Eu, Fu, Gu, hBu, Buβ, compL_apply, coe_comp', Function.comp_apply,
ContinuousLinearEquiv.coe_coe, LinearIsometryEquiv.coe_coe, flip_apply,
LinearIsometryEquiv.norm_map]
calc
βB (isoE y) (isoF x)β β€ βB (isoE y)β * βisoF xβ := ContinuousLinearMap.le_opNorm _ _
_ β€ βBβ * βisoE yβ * βisoF xβ := by gcongr; apply ContinuousLinearMap.le_opNorm
_ = βBβ * βyβ * βxβ := by simp only [LinearIsometryEquiv.norm_map]
let su := isoD β»ΒΉ' s
have hsu : UniqueDiffOn π su := isoD.toContinuousLinearEquiv.uniqueDiffOn_preimage_iff.2 hs
let xu := isoD.symm x
have hxu : xu β su := by
simpa only [xu, su, Set.mem_preimage, LinearIsometryEquiv.apply_symm_apply] using hx
have xu_x : isoD xu = x := by simp only [xu, LinearIsometryEquiv.apply_symm_apply]
have hfu : ContDiffOn π n fu su :=
isoE.symm.contDiff.comp_contDiffOn
((hf.of_le hn).comp_continuousLinearMap (isoD : Du βL[π] D))
have hgu : ContDiffOn π n gu su :=
isoF.symm.contDiff.comp_contDiffOn
((hg.of_le hn).comp_continuousLinearMap (isoD : Du βL[π] D))
have Nfu : β i, βiteratedFDerivWithin π i fu su xuβ = βiteratedFDerivWithin π i f s xβ := by
intro i
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [β xu_x] at hx
have Ngu : β i, βiteratedFDerivWithin π i gu su xuβ = βiteratedFDerivWithin π i g s xβ := by
intro i
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [β xu_x] at hx
have NBu :
βiteratedFDerivWithin π n (fun y => Bu (fu y) (gu y)) su xuβ =
βiteratedFDerivWithin π n (fun y => B (f y) (g y)) s xβ := by
rw [Bu_eq]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hsu hxu]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ hs, xu_x]
rwa [β xu_x] at hx
-- state the bound for the lifted objects, and deduce the original bound from it.
have : βiteratedFDerivWithin π n (fun y => Bu (fu y) (gu y)) su xuβ β€
βBuβ * β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i fu su xuβ *
βiteratedFDerivWithin π (n - i) gu su xuβ :=
Bu.norm_iteratedFDerivWithin_le_of_bilinear_aux hfu hgu hsu hxu
simp only [Nfu, Ngu, NBu] at this
exact this.trans (mul_le_mul_of_nonneg_right Bu_le (by positivity))
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear:
`βD^n (x β¦ B (f x) (g x))β β€ βBβ β_{k β€ n} n.choose k βD^k fβ βD^{n-k} gβ` -/
theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear (B : E βL[π] F βL[π] G) {f : D β E}
{g : D β F} {N : WithTop ββ} (hf : ContDiff π N f) (hg : ContDiff π N g) (x : D) {n : β}
(hn : n β€ N) :
βiteratedFDeriv π n (fun y => B (f y) (g y)) xβ β€ βBβ * β i β Finset.range (n + 1),
(n.choose i : β) * βiteratedFDeriv π i f xβ * βiteratedFDeriv π (n - i) g xβ := by
simp_rw [β iteratedFDerivWithin_univ]
exact B.norm_iteratedFDerivWithin_le_of_bilinear hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ
(mem_univ x) hn
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` within a set in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear of norm at most `1`:
`βD^n (x β¦ B (f x) (g x))β β€ β_{k β€ n} n.choose k βD^k fβ βD^{n-k} gβ` -/
theorem ContinuousLinearMap.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
(B : E βL[π] F βL[π] G) {f : D β E} {g : D β F} {N : WithTop ββ} {s : Set D} {x : D}
(hf : ContDiffOn π N f s) (hg : ContDiffOn π N g s) (hs : UniqueDiffOn π s) (hx : x β s) {n : β}
(hn : n β€ N) (hB : βBβ β€ 1) : βiteratedFDerivWithin π n (fun y => B (f y) (g y)) s xβ β€
β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ := by
apply (B.norm_iteratedFDerivWithin_le_of_bilinear hf hg hs hx hn).trans
exact mul_le_of_le_one_left (by positivity) hB
/-- Bounding the norm of the iterated derivative of `B (f x) (g x)` in terms of the
iterated derivatives of `f` and `g` when `B` is bilinear of norm at most `1`:
`βD^n (x β¦ B (f x) (g x))β β€ β_{k β€ n} n.choose k βD^k fβ βD^{n-k} gβ` -/
theorem ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one (B : E βL[π] F βL[π] G)
{f : D β E} {g : D β F} {N : WithTop ββ} (hf : ContDiff π N f) (hg : ContDiff π N g)
(x : D) {n : β} (hn : n β€ N) (hB : βBβ β€ 1) :
βiteratedFDeriv π n (fun y => B (f y) (g y)) xβ β€
β i β Finset.range (n + 1),
(n.choose i : β) * βiteratedFDeriv π i f xβ * βiteratedFDeriv π (n - i) g xβ := by
simp_rw [β iteratedFDerivWithin_univ]
exact B.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf.contDiffOn hg.contDiffOn
uniqueDiffOn_univ (mem_univ x) hn hB
section
variable {π' : Type*} [NormedField π'] [NormedAlgebra π π'] [NormedSpace π' F]
[IsScalarTower π π' F]
theorem norm_iteratedFDerivWithin_smul_le {f : E β π'} {g : E β F} {N : WithTop ββ}
(hf : ContDiffOn π N f s) (hg : ContDiffOn π N g s) (hs : UniqueDiffOn π s) {x : E} (hx : x β s)
{n : β} (hn : n β€ N) : βiteratedFDerivWithin π n (fun y => f y β’ g y) s xβ β€
β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ :=
(ContinuousLinearMap.lsmul π π' :
π' βL[π] F βL[π] F).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
hf hg hs hx hn ContinuousLinearMap.opNorm_lsmul_le
theorem norm_iteratedFDeriv_smul_le {f : E β π'} {g : E β F} {N : WithTop ββ} (hf : ContDiff π N f)
(hg : ContDiff π N g) (x : E) {n : β} (hn : n β€ N) :
βiteratedFDeriv π n (fun y => f y β’ g y) xβ β€ β i β Finset.range (n + 1),
(n.choose i : β) * βiteratedFDeriv π i f xβ * βiteratedFDeriv π (n - i) g xβ :=
(ContinuousLinearMap.lsmul π π' : π' βL[π] F βL[π] F).norm_iteratedFDeriv_le_of_bilinear_of_le_one
hf hg x hn ContinuousLinearMap.opNorm_lsmul_le
end
section
variable {ΞΉ : Type*} {A : Type*} [NormedRing A] [NormedAlgebra π A] {A' : Type*} [NormedCommRing A']
[NormedAlgebra π A']
theorem norm_iteratedFDerivWithin_mul_le {f : E β A} {g : E β A} {N : WithTop ββ}
(hf : ContDiffOn π N f s) (hg : ContDiffOn π N g s) (hs : UniqueDiffOn π s)
{x : E} (hx : x β s) {n : β} (hn : n β€ N) :
βiteratedFDerivWithin π n (fun y => f y * g y) s xβ β€
β i β Finset.range (n + 1), (n.choose i : β) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ :=
(ContinuousLinearMap.mul π A :
A βL[π] A βL[π] A).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
hf hg hs hx hn (ContinuousLinearMap.opNorm_mul_le _ _)
theorem norm_iteratedFDeriv_mul_le {f : E β A} {g : E β A} {N : WithTop ββ} (hf : ContDiff π N f)
(hg : ContDiff π N g) (x : E) {n : β} (hn : n β€ N) :
βiteratedFDeriv π n (fun y => f y * g y) xβ β€ β i β Finset.range (n + 1),
(n.choose i : β) * βiteratedFDeriv π i f xβ * βiteratedFDeriv π (n - i) g xβ := by
simp_rw [β iteratedFDerivWithin_univ]
exact norm_iteratedFDerivWithin_mul_le
hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ (mem_univ x) hn
-- TODO: Add `norm_iteratedFDeriv[Within]_list_prod_le` for non-commutative `NormedRing A`.
theorem norm_iteratedFDerivWithin_prod_le [DecidableEq ΞΉ] [NormOneClass A'] {u : Finset ΞΉ}
{f : ΞΉ β E β A'} {N : WithTop ββ} (hf : β i β u, ContDiffOn π N (f i) s)
(hs : UniqueDiffOn π s) {x : E} (hx : x β s) {n : β} (hn : n β€ N) :
βiteratedFDerivWithin π n (β j β u, f j Β·) s xβ β€
β p β u.sym n, (p : Multiset ΞΉ).multinomial *
β j β u, βiteratedFDerivWithin π (Multiset.count j p) (f j) s xβ := by
induction u using Finset.induction generalizing n with
| empty =>
cases n with
| zero => simp [Sym.eq_nil_of_card_zero]
| succ n => simp [iteratedFDerivWithin_succ_const]
| insert i u hi IH =>
conv => lhs; simp only [Finset.prod_insert hi]
simp only [Finset.mem_insert, forall_eq_or_imp] at hf
refine le_trans (norm_iteratedFDerivWithin_mul_le hf.1 (contDiffOn_prod hf.2) hs hx hn) ?_
rw [β Finset.sum_coe_sort (Finset.sym _ _)]
rw [Finset.sum_equiv (Finset.symInsertEquiv hi) (t := Finset.univ)
(g := (fun v β¦ v.multinomial *
β j β insert i u, βiteratedFDerivWithin π (v.count j) (f j) s xβ) β
Sym.toMultiset β Subtype.val β (Finset.symInsertEquiv hi).symm)
(by simp) (by simp only [β comp_apply (g := Finset.symInsertEquiv hi), comp_assoc]; simp)]
rw [β Finset.univ_sigma_univ, Finset.sum_sigma, Finset.sum_range]
simp only [comp_apply, Finset.symInsertEquiv_symm_apply_coe]
refine Finset.sum_le_sum ?_
intro m _
specialize IH hf.2 (n := n - m) (le_trans (by exact_mod_cast n.sub_le m) hn)
refine le_trans (mul_le_mul_of_nonneg_left IH (by simp [mul_nonneg])) ?_
rw [Finset.mul_sum, β Finset.sum_coe_sort]
refine Finset.sum_le_sum ?_
simp only [Finset.mem_univ, forall_true_left, Subtype.forall, Finset.mem_sym_iff]
intro p hp
refine le_of_eq ?_
rw [Finset.prod_insert hi]
have hip : i β p := mt (hp i) hi
rw [Sym.count_coe_fill_self_of_not_mem hip, Sym.multinomial_coe_fill_of_not_mem hip]
suffices β j β u, βiteratedFDerivWithin π (Multiset.count j p) (f j) s xβ =
β j β u, βiteratedFDerivWithin π (Multiset.count j (Sym.fill i m p)) (f j) s xβ by
rw [this, Nat.cast_mul]
ring
refine Finset.prod_congr rfl ?_
intro j hj
have hji : j β i := mt (Β· βΈ hj) hi
rw [Sym.count_coe_fill_of_ne hji]
theorem norm_iteratedFDeriv_prod_le [DecidableEq ΞΉ] [NormOneClass A'] {u : Finset ΞΉ}
{f : ΞΉ β E β A'} {N : WithTop ββ} (hf : β i β u, ContDiff π N (f i)) {x : E} {n : β}
(hn : n β€ N) :
βiteratedFDeriv π n (β j β u, f j Β·) xβ β€
β p β u.sym n, (p : Multiset ΞΉ).multinomial *
β j β u, βiteratedFDeriv π ((p : Multiset ΞΉ).count j) (f j) xβ := by
simpa [iteratedFDerivWithin_univ] using
norm_iteratedFDerivWithin_prod_le (fun i hi β¦ (hf i hi).contDiffOn) uniqueDiffOn_univ
(mem_univ x) hn
end
/-- If the derivatives within a set of `g` at `f x` are bounded by `C`, and the `i`-th derivative
within a set of `f` at `x` is bounded by `D^i` for all `1 β€ i β€ n`, then the `n`-th derivative
of `g β f` is bounded by `n! * C * D^n`.
This lemma proves this estimate assuming additionally that two of the spaces live in the same
universe, to make an induction possible. Use instead `norm_iteratedFDerivWithin_comp_le` that
removes this assumption. -/
theorem norm_iteratedFDerivWithin_comp_le_aux {Fu Gu : Type u} [NormedAddCommGroup Fu]
[NormedSpace π Fu] [NormedAddCommGroup Gu] [NormedSpace π Gu] {g : Fu β Gu} {f : E β Fu} {n : β}
{s : Set E} {t : Set Fu} {x : E} (hg : ContDiffOn π n g t) (hf : ContDiffOn π n f s)
(ht : UniqueDiffOn π t) (hs : UniqueDiffOn π s) (hst : MapsTo f s t) (hx : x β s) {C : β}
{D : β} (hC : β i, i β€ n β βiteratedFDerivWithin π i g t (f x)β β€ C)
(hD : β i, 1 β€ i β i β€ n β βiteratedFDerivWithin π i f s xβ β€ D ^ i) :
βiteratedFDerivWithin π n (g β f) s xβ β€ n ! * C * D ^ n := by
/- We argue by induction on `n`, using that `D^(n+1) (g β f) = D^n (g ' β f β¬ f')`. The successive
derivatives of `g' β f` are controlled thanks to the inductive assumption, and those of `f'` are
controlled by assumption.
As composition of linear maps is a bilinear map, one may use
`ContinuousLinearMap.norm_iteratedFDeriv_le_of_bilinear_of_le_one` to get from these a bound
on `D^n (g ' β f β¬ f')`. -/
induction' n using Nat.case_strong_induction_on with n IH generalizing Gu
Β· simpa [norm_iteratedFDerivWithin_zero, Nat.factorial_zero, algebraMap.coe_one, one_mul,
pow_zero, mul_one, comp_apply] using hC 0 le_rfl
have M : (n : WithTop ββ) < n.succ := Nat.cast_lt.2 n.lt_succ_self
have Cnonneg : 0 β€ C := (norm_nonneg _).trans (hC 0 bot_le)
have Dnonneg : 0 β€ D := by
have : 1 β€ n + 1 := by simp only [le_add_iff_nonneg_left, zero_le']
simpa only [pow_one] using (norm_nonneg _).trans (hD 1 le_rfl this)
-- use the inductive assumption to bound the derivatives of `g' β f`.
have I : β i β Finset.range (n + 1),
βiteratedFDerivWithin π i (fderivWithin π g t β f) s xβ β€ i ! * C * D ^ i := by
intro i hi
simp only [Finset.mem_range_succ_iff] at hi
apply IH i hi
Β· apply hg.fderivWithin ht
simp only [Nat.cast_succ]
exact add_le_add_right (Nat.cast_le.2 hi) _
Β· apply hf.of_le (Nat.cast_le.2 (hi.trans n.le_succ))
Β· intro j hj
have : βiteratedFDerivWithin π j (fderivWithin π g t) t (f x)β =
βiteratedFDerivWithin π (j + 1) g t (f x)β := by
rw [iteratedFDerivWithin_succ_eq_comp_right ht (hst hx), comp_apply,
LinearIsometryEquiv.norm_map]
rw [this]
exact hC (j + 1) (add_le_add (hj.trans hi) le_rfl)
Β· intro j hj h'j
exact hD j hj (h'j.trans (hi.trans n.le_succ))
-- reformulate `hD` as a bound for the derivatives of `f'`.
have J : β i, βiteratedFDerivWithin π (n - i) (fderivWithin π f s) s xβ β€ D ^ (n - i + 1) := by
intro i
have : βiteratedFDerivWithin π (n - i) (fderivWithin π f s) s xβ =
βiteratedFDerivWithin π (n - i + 1) f s xβ := by
rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply, LinearIsometryEquiv.norm_map]
rw [this]
apply hD
Β· simp only [le_add_iff_nonneg_left, zero_le']
Β· apply Nat.succ_le_succ tsub_le_self
-- Now put these together: first, notice that we have to bound `D^n (g' β f β¬ f')`.
calc
βiteratedFDerivWithin π (n + 1) (g β f) s xβ =
βiteratedFDerivWithin π n (fun y : E => fderivWithin π (g β f) s y) s xβ := by
rw [iteratedFDerivWithin_succ_eq_comp_right hs hx, comp_apply,
LinearIsometryEquiv.norm_map]
_ = βiteratedFDerivWithin π n (fun y : E => ContinuousLinearMap.compL π E Fu Gu
(fderivWithin π g t (f y)) (fderivWithin π f s y)) s xβ := by
have L : (1 : WithTop ββ) β€ n.succ := by
simpa only [ENat.coe_one, Nat.one_le_cast] using n.succ_pos
congr 1
refine iteratedFDerivWithin_congr (fun y hy => ?_) hx _
apply fderivWithin_comp _ _ _ hst (hs y hy)
Β· exact hg.differentiableOn L _ (hst hy)
Β· exact hf.differentiableOn L _ hy
-- bound it using the fact that the composition of linear maps is a bilinear operation,
-- for which we have bounds for the`n`-th derivative.
_ β€ β i β Finset.range (n + 1),
(n.choose i : β) * βiteratedFDerivWithin π i (fderivWithin π g t β f) s xβ *
βiteratedFDerivWithin π (n - i) (fderivWithin π f s) s xβ := by
have A : ContDiffOn π n (fderivWithin π g t β f) s := by
apply ContDiffOn.comp _ (hf.of_le M.le) hst
apply hg.fderivWithin ht
simp only [Nat.cast_succ, le_refl]
have B : ContDiffOn π n (fderivWithin π f s) s := by
apply hf.fderivWithin hs
simp only [Nat.cast_succ, le_refl]
exact (ContinuousLinearMap.compL π E Fu Gu).norm_iteratedFDerivWithin_le_of_bilinear_of_le_one
A B hs hx le_rfl (ContinuousLinearMap.norm_compL_le π E Fu Gu)
-- bound each of the terms using the estimates on previous derivatives (that use the inductive
-- assumption for `g' β f`).
_ β€ β i β Finset.range (n + 1), (n.choose i : β) * (i ! * C * D ^ i) * D ^ (n - i + 1) := by
gcongr with i hi
Β· exact I i hi
Β· exact J i
-- We are left with trivial algebraic manipulations to see that this is smaller than
-- the claimed bound.
_ = β i β Finset.range (n + 1),
(n ! : β) * ((i ! : β)β»ΒΉ * i !) * C * (D ^ i * D ^ (n - i + 1)) * ((n - i)! : β)β»ΒΉ := by
congr! 1 with i hi
simp only [Nat.cast_choose β (Finset.mem_range_succ_iff.1 hi), div_eq_inv_mul, mul_inv]
ring
_ = β i β Finset.range (n + 1), (n ! : β) * 1 * C * D ^ (n + 1) * ((n - i)! : β)β»ΒΉ := by
congr! with i hi
Β· apply inv_mul_cancelβ
simpa only [Ne, Nat.cast_eq_zero] using i.factorial_ne_zero
Β· rw [β pow_add]
congr 1
rw [Nat.add_succ, Nat.succ_inj]
exact Nat.add_sub_of_le (Finset.mem_range_succ_iff.1 hi)
_ β€ β i β Finset.range (n + 1), (n ! : β) * 1 * C * D ^ (n + 1) * 1 := by
gcongr with i
apply inv_le_one_of_one_leβ
simpa only [Nat.one_le_cast] using (n - i).factorial_pos
_ = (n + 1)! * C * D ^ (n + 1) := by
simp only [mul_assoc, mul_one, Finset.sum_const, Finset.card_range, nsmul_eq_mul,
Nat.factorial_succ, Nat.cast_mul]
/-- If the derivatives within a set of `g` at `f x` are bounded by `C`, and the `i`-th derivative
within a set of `f` at `x` is bounded by `D^i` for all `1 β€ i β€ n`, then the `n`-th derivative
of `g β f` is bounded by `n! * C * D^n`. -/
theorem norm_iteratedFDerivWithin_comp_le {g : F β G} {f : E β F} {n : β} {s : Set E} {t : Set F}
{x : E} {N : WithTop ββ} (hg : ContDiffOn π N g t) (hf : ContDiffOn π N f s) (hn : n β€ N)
(ht : UniqueDiffOn π t) (hs : UniqueDiffOn π s) (hst : MapsTo f s t) (hx : x β s) {C : β}
{D : β} (hC : β i, i β€ n β βiteratedFDerivWithin π i g t (f x)β β€ C)
(hD : β i, 1 β€ i β i β€ n β βiteratedFDerivWithin π i f s xβ β€ D ^ i) :
βiteratedFDerivWithin π n (g β f) s xβ β€ n ! * C * D ^ n := by
/- We reduce the bound to the case where all spaces live in the same universe (in which we
already have proved the result), by using linear isometries between the spaces and their `ULift`
to a common universe. These linear isometries preserve the norm of the iterated derivative. -/
let Fu : Type max uF uG := ULift.{uG, uF} F
let Gu : Type max uF uG := ULift.{uF, uG} G
have isoF : Fu ββα΅’[π] F := LinearIsometryEquiv.ulift π F
have isoG : Gu ββα΅’[π] G := LinearIsometryEquiv.ulift π G
-- lift `f` and `g` to versions `fu` and `gu` on the lifted spaces.
let fu : E β Fu := isoF.symm β f
let gu : Fu β Gu := isoG.symm β g β isoF
let tu := isoF β»ΒΉ' t
have htu : UniqueDiffOn π tu := isoF.toContinuousLinearEquiv.uniqueDiffOn_preimage_iff.2 ht
have hstu : MapsTo fu s tu := fun y hy β¦ by
simpa only [fu, tu, mem_preimage, comp_apply, LinearIsometryEquiv.apply_symm_apply] using hst hy
have Ffu : isoF (fu x) = f x := by
simp only [fu, comp_apply, LinearIsometryEquiv.apply_symm_apply]
-- All norms are preserved by the lifting process.
have hfu : ContDiffOn π n fu s := isoF.symm.contDiff.comp_contDiffOn (hf.of_le hn)
have hgu : ContDiffOn π n gu tu :=
isoG.symm.contDiff.comp_contDiffOn
((hg.of_le hn).comp_continuousLinearMap (isoF : Fu βL[π] F))
have Nfu : β i, βiteratedFDerivWithin π i fu s xβ = βiteratedFDerivWithin π i f s xβ := fun i β¦ by
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hs hx]
simp_rw [β Nfu] at hD
have Ngu : β i,
βiteratedFDerivWithin π i gu tu (fu x)β = βiteratedFDerivWithin π i g t (f x)β := fun i β¦ by
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ htu (hstu hx)]
rw [LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_right _ _ ht, Ffu]
rw [Ffu]
exact hst hx
simp_rw [β Ngu] at hC
have Nfgu :
βiteratedFDerivWithin π n (g β f) s xβ = βiteratedFDerivWithin π n (gu β fu) s xβ := by
have : gu β fu = isoG.symm β g β f := by
ext x
simp only [fu, gu, comp_apply, LinearIsometryEquiv.map_eq_iff,
LinearIsometryEquiv.apply_symm_apply]
rw [this, LinearIsometryEquiv.norm_iteratedFDerivWithin_comp_left _ _ hs hx]
-- deduce the required bound from the one for `gu β fu`.
rw [Nfgu]
exact norm_iteratedFDerivWithin_comp_le_aux hgu hfu htu hs hstu hx hC hD
/-- If the derivatives of `g` at `f x` are bounded by `C`, and the `i`-th derivative
of `f` at `x` is bounded by `D^i` for all `1 β€ i β€ n`, then the `n`-th derivative
of `g β f` is bounded by `n! * C * D^n`. -/
theorem norm_iteratedFDeriv_comp_le {g : F β G} {f : E β F} {n : β} {N : WithTop ββ}
(hg : ContDiff π N g) (hf : ContDiff π N f) (hn : n β€ N) (x : E) {C : β} {D : β}
(hC : β i, i β€ n β βiteratedFDeriv π i g (f x)β β€ C)
(hD : β i, 1 β€ i β i β€ n β βiteratedFDeriv π i f xβ β€ D ^ i) :
βiteratedFDeriv π n (g β f) xβ β€ n ! * C * D ^ n := by
simp_rw [β iteratedFDerivWithin_univ] at hC hD β’
exact norm_iteratedFDerivWithin_comp_le hg.contDiffOn hf.contDiffOn hn uniqueDiffOn_univ
uniqueDiffOn_univ (mapsTo_univ _ _) (mem_univ x) hC hD
section Apply
theorem norm_iteratedFDerivWithin_clm_apply {f : E β F βL[π] G} {g : E β F} {s : Set E} {x : E}
{N : WithTop ββ} {n : β} (hf : ContDiffOn π N f s) (hg : ContDiffOn π N g s)
(hs : UniqueDiffOn π s) (hx : x β s) (hn : n β€ N) :
βiteratedFDerivWithin π n (fun y => (f y) (g y)) s xβ β€
β i β Finset.range (n + 1), β(n.choose i) * βiteratedFDerivWithin π i f s xβ *
βiteratedFDerivWithin π (n - i) g s xβ := by
let B : (F βL[π] G) βL[π] F βL[π] G := ContinuousLinearMap.flip (ContinuousLinearMap.apply π G)
have hB : βBβ β€ 1 := by
simp only [B, ContinuousLinearMap.opNorm_flip, ContinuousLinearMap.apply]
refine ContinuousLinearMap.opNorm_le_bound _ zero_le_one fun f => ?_
simp only [ContinuousLinearMap.coe_id', id, one_mul]
rfl
exact B.norm_iteratedFDerivWithin_le_of_bilinear_of_le_one hf hg hs hx hn hB
| Mathlib/Analysis/Calculus/ContDiff/Bounds.lean | 537 | 548 | theorem norm_iteratedFDeriv_clm_apply {f : E β F βL[π] G} {g : E β F} {N : WithTop ββ} {n : β}
(hf : ContDiff π N f) (hg : ContDiff π N g) (x : E) (hn : n β€ N) :
βiteratedFDeriv π n (fun y : E => (f y) (g y)) xβ β€ β i β Finset.range (n + 1),
β(n.choose i) * βiteratedFDeriv π i f xβ * βiteratedFDeriv π (n - i) g xβ := by | simp only [β iteratedFDerivWithin_univ]
exact norm_iteratedFDerivWithin_clm_apply hf.contDiffOn hg.contDiffOn uniqueDiffOn_univ
(Set.mem_univ x) hn
theorem norm_iteratedFDerivWithin_clm_apply_const {f : E β F βL[π] G} {c : F} {s : Set E} {x : E}
{N : WithTop ββ} {n : β} (hf : ContDiffWithinAt π N f s x) (hs : UniqueDiffOn π s)
(hx : x β s) (hn : n β€ N) :
βiteratedFDerivWithin π n (fun y : E => (f y) c) s xβ β€ |
/-
Copyright (c) 2018 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot, Johannes HΓΆlzl, YaΓ«l Dillies
-/
import Mathlib.Analysis.Normed.Group.Seminorm
import Mathlib.Data.NNReal.Basic
import Mathlib.Topology.Algebra.Support
import Mathlib.Topology.MetricSpace.Basic
import Mathlib.Topology.Order.Real
/-!
# Normed (semi)groups
In this file we define 10 classes:
* `Norm`, `NNNorm`: auxiliary classes endowing a type `Ξ±` with a function `norm : Ξ± β β`
(notation: `βxβ`) and `nnnorm : Ξ± β ββ₯0` (notation: `βxββ`), respectively;
* `Seminormed...Group`: A seminormed (additive) (commutative) group is an (additive) (commutative)
group with a norm and a compatible pseudometric space structure:
`β x y, dist x y = βx / yβ` or `β x y, dist x y = βx - yβ`, depending on the group operation.
* `Normed...Group`: A normed (additive) (commutative) group is an (additive) (commutative) group
with a norm and a compatible metric space structure.
We also prove basic properties of (semi)normed groups and provide some instances.
## Notes
The current convention `dist x y = βx - yβ` means that the distance is invariant under right
addition, but actions in mathlib are usually from the left. This means we might want to change it to
`dist x y = β-x + yβ`.
The normed group hierarchy would lend itself well to a mixin design (that is, having
`SeminormedGroup` and `SeminormedAddGroup` not extend `Group` and `AddGroup`), but we choose not
to for performance concerns.
## Tags
normed group
-/
variable {π Ξ± ΞΉ ΞΊ E F G : Type*}
open Filter Function Metric Bornology
open ENNReal Filter NNReal Uniformity Pointwise Topology
/-- Auxiliary class, endowing a type `E` with a function `norm : E β β` with notation `βxβ`. This
class is designed to be extended in more interesting classes specifying the properties of the norm.
-/
@[notation_class]
class Norm (E : Type*) where
/-- the `β`-valued norm function. -/
norm : E β β
/-- Auxiliary class, endowing a type `Ξ±` with a function `nnnorm : Ξ± β ββ₯0` with notation `βxββ`. -/
@[notation_class]
class NNNorm (E : Type*) where
/-- the `ββ₯0`-valued norm function. -/
nnnorm : E β ββ₯0
/-- Auxiliary class, endowing a type `Ξ±` with a function `enorm : Ξ± β ββ₯0β` with notation `βxββ`. -/
@[notation_class]
class ENorm (E : Type*) where
/-- the `ββ₯0β`-valued norm function. -/
enorm : E β ββ₯0β
export Norm (norm)
export NNNorm (nnnorm)
export ENorm (enorm)
@[inherit_doc] notation "β" e "β" => norm e
@[inherit_doc] notation "β" e "ββ" => nnnorm e
@[inherit_doc] notation "β" e "ββ" => enorm e
section ENorm
variable {E : Type*} [NNNorm E] {x : E} {r : ββ₯0}
instance NNNorm.toENorm : ENorm E where enorm := (βΒ·ββ : E β ββ₯0β)
lemma enorm_eq_nnnorm (x : E) : βxββ = βxββ := rfl
@[simp] lemma toNNReal_enorm (x : E) : βxββ.toNNReal = βxββ := rfl
@[simp, norm_cast] lemma coe_le_enorm : r β€ βxββ β r β€ βxββ := by simp [enorm]
@[simp, norm_cast] lemma enorm_le_coe : βxββ β€ r β βxββ β€ r := by simp [enorm]
@[simp, norm_cast] lemma coe_lt_enorm : r < βxββ β r < βxββ := by simp [enorm]
@[simp, norm_cast] lemma enorm_lt_coe : βxββ < r β βxββ < r := by simp [enorm]
@[simp] lemma enorm_ne_top : βxββ β β := by simp [enorm]
@[simp] lemma enorm_lt_top : βxββ < β := by simp [enorm]
end ENorm
/-- A type `E` equipped with a continuous map `βΒ·ββ : E β ββ₯0β`
NB. We do not demand that the topology is somehow defined by the enorm:
for ββ₯0β (the motivating example behind this definition), this is not true. -/
class ContinuousENorm (E : Type*) [TopologicalSpace E] extends ENorm E where
continuous_enorm : Continuous enorm
/-- An enormed monoid is an additive monoid endowed with a continuous enorm. -/
class ENormedAddMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, AddMonoid E where
enorm_eq_zero : β x : E, βxββ = 0 β x = 0
protected enorm_add_le : β x y : E, βx + yββ β€ βxββ + βyββ
/-- An enormed monoid is a monoid endowed with a continuous enorm. -/
@[to_additive]
class ENormedMonoid (E : Type*) [TopologicalSpace E] extends ContinuousENorm E, Monoid E where
enorm_eq_zero : β x : E, βxββ = 0 β x = 1
enorm_mul_le : β x y : E, βx * yββ β€ βxββ + βyββ
/-- An enormed commutative monoid is an additive commutative monoid
endowed with a continuous enorm.
We don't have `ENormedAddCommMonoid` extend `EMetricSpace`, since the canonical instance `ββ₯0β`
is not an `EMetricSpace`. This is because `ββ₯0β` carries the order topology, which is distinct from
the topology coming from `edist`. -/
class ENormedAddCommMonoid (E : Type*) [TopologicalSpace E]
extends ENormedAddMonoid E, AddCommMonoid E where
/-- An enormed commutative monoid is a commutative monoid endowed with a continuous enorm. -/
@[to_additive]
class ENormedCommMonoid (E : Type*) [TopologicalSpace E] extends ENormedMonoid E, CommMonoid E where
/-- A seminormed group is an additive group endowed with a norm for which `dist x y = βx - yβ`
defines a pseudometric space structure. -/
class SeminormedAddGroup (E : Type*) extends Norm E, AddGroup E, PseudoMetricSpace E where
dist := fun x y => βx - yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx - yβ := by aesop
/-- A seminormed group is a group endowed with a norm for which `dist x y = βx / yβ` defines a
pseudometric space structure. -/
@[to_additive]
class SeminormedGroup (E : Type*) extends Norm E, Group E, PseudoMetricSpace E where
dist := fun x y => βx / yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx / yβ := by aesop
/-- A normed group is an additive group endowed with a norm for which `dist x y = βx - yβ` defines a
metric space structure. -/
class NormedAddGroup (E : Type*) extends Norm E, AddGroup E, MetricSpace E where
dist := fun x y => βx - yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx - yβ := by aesop
/-- A normed group is a group endowed with a norm for which `dist x y = βx / yβ` defines a metric
space structure. -/
@[to_additive]
class NormedGroup (E : Type*) extends Norm E, Group E, MetricSpace E where
dist := fun x y => βx / yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx / yβ := by aesop
/-- A seminormed group is an additive group endowed with a norm for which `dist x y = βx - yβ`
defines a pseudometric space structure. -/
class SeminormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E,
PseudoMetricSpace E where
dist := fun x y => βx - yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx - yβ := by aesop
/-- A seminormed group is a group endowed with a norm for which `dist x y = βx / yβ`
defines a pseudometric space structure. -/
@[to_additive]
class SeminormedCommGroup (E : Type*) extends Norm E, CommGroup E, PseudoMetricSpace E where
dist := fun x y => βx / yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx / yβ := by aesop
/-- A normed group is an additive group endowed with a norm for which `dist x y = βx - yβ` defines a
metric space structure. -/
class NormedAddCommGroup (E : Type*) extends Norm E, AddCommGroup E, MetricSpace E where
dist := fun x y => βx - yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx - yβ := by aesop
/-- A normed group is a group endowed with a norm for which `dist x y = βx / yβ` defines a metric
space structure. -/
@[to_additive]
class NormedCommGroup (E : Type*) extends Norm E, CommGroup E, MetricSpace E where
dist := fun x y => βx / yβ
/-- The distance function is induced by the norm. -/
dist_eq : β x y, dist x y = βx / yβ := by aesop
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedGroup.toSeminormedGroup [NormedGroup E] : SeminormedGroup E :=
{ βΉNormedGroup EβΊ with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedCommGroup.toSeminormedCommGroup [NormedCommGroup E] :
SeminormedCommGroup E :=
{ βΉNormedCommGroup EβΊ with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) SeminormedCommGroup.toSeminormedGroup [SeminormedCommGroup E] :
SeminormedGroup E :=
{ βΉSeminormedCommGroup EβΊ with }
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) NormedCommGroup.toNormedGroup [NormedCommGroup E] : NormedGroup E :=
{ βΉNormedCommGroup EβΊ with }
-- See note [reducible non-instances]
/-- Construct a `NormedGroup` from a `SeminormedGroup` satisfying `β x, βxβ = 0 β x = 1`. This
avoids having to go back to the `(Pseudo)MetricSpace` level when declaring a `NormedGroup`
instance as a special case of a more general `SeminormedGroup` instance. -/
@[to_additive "Construct a `NormedAddGroup` from a `SeminormedAddGroup`
satisfying `β x, βxβ = 0 β x = 0`. This avoids having to go back to the `(Pseudo)MetricSpace`
level when declaring a `NormedAddGroup` instance as a special case of a more general
`SeminormedAddGroup` instance."]
abbrev NormedGroup.ofSeparation [SeminormedGroup E] (h : β x : E, βxβ = 0 β x = 1) :
NormedGroup E where
dist_eq := βΉSeminormedGroup EβΊ.dist_eq
toMetricSpace :=
{ eq_of_dist_eq_zero := fun hxy =>
div_eq_one.1 <| h _ <| (βΉSeminormedGroup EβΊ.dist_eq _ _).symm.trans hxy }
-- See note [reducible non-instances]
/-- Construct a `NormedCommGroup` from a `SeminormedCommGroup` satisfying
`β x, βxβ = 0 β x = 1`. This avoids having to go back to the `(Pseudo)MetricSpace` level when
declaring a `NormedCommGroup` instance as a special case of a more general `SeminormedCommGroup`
instance. -/
@[to_additive "Construct a `NormedAddCommGroup` from a
`SeminormedAddCommGroup` satisfying `β x, βxβ = 0 β x = 0`. This avoids having to go back to the
`(Pseudo)MetricSpace` level when declaring a `NormedAddCommGroup` instance as a special case
of a more general `SeminormedAddCommGroup` instance."]
abbrev NormedCommGroup.ofSeparation [SeminormedCommGroup E] (h : β x : E, βxβ = 0 β x = 1) :
NormedCommGroup E :=
{ βΉSeminormedCommGroup EβΊ, NormedGroup.ofSeparation h with }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant distance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant distance."]
abbrev SeminormedGroup.ofMulDist [Norm E] [Group E] [PseudoMetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist x y β€ dist (x * z) (y * z)) :
SeminormedGroup E where
dist_eq x y := by
rw [hβ]; apply le_antisymm
Β· simpa only [div_eq_mul_inv, β mul_inv_cancel y] using hβ _ _ _
Β· simpa only [div_mul_cancel, one_mul] using hβ (x / y) 1 y
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedGroup.ofMulDist' [Norm E] [Group E] [PseudoMetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist (x * z) (y * z) β€ dist x y) :
SeminormedGroup E where
dist_eq x y := by
rw [hβ]; apply le_antisymm
Β· simpa only [div_mul_cancel, one_mul] using hβ (x / y) 1 y
Β· simpa only [div_eq_mul_inv, β mul_inv_cancel y] using hβ _ _ _
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedCommGroup.ofMulDist [Norm E] [CommGroup E] [PseudoMetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist x y β€ dist (x * z) (y * z)) :
SeminormedCommGroup E :=
{ SeminormedGroup.ofMulDist hβ hβ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a seminormed group from a translation-invariant pseudodistance."]
abbrev SeminormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [PseudoMetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist (x * z) (y * z) β€ dist x y) :
SeminormedCommGroup E :=
{ SeminormedGroup.ofMulDist' hβ hβ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant distance. -/
@[to_additive
"Construct a normed group from a translation-invariant distance."]
abbrev NormedGroup.ofMulDist [Norm E] [Group E] [MetricSpace E] (hβ : β x : E, βxβ = dist x 1)
(hβ : β x y z : E, dist x y β€ dist (x * z) (y * z)) : NormedGroup E :=
{ SeminormedGroup.ofMulDist hβ hβ with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedGroup.ofMulDist' [Norm E] [Group E] [MetricSpace E] (hβ : β x : E, βxβ = dist x 1)
(hβ : β x y z : E, dist (x * z) (y * z) β€ dist x y) : NormedGroup E :=
{ SeminormedGroup.ofMulDist' hβ hβ with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedCommGroup.ofMulDist [Norm E] [CommGroup E] [MetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist x y β€ dist (x * z) (y * z)) :
NormedCommGroup E :=
{ NormedGroup.ofMulDist hβ hβ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a multiplication-invariant pseudodistance. -/
@[to_additive
"Construct a normed group from a translation-invariant pseudodistance."]
abbrev NormedCommGroup.ofMulDist' [Norm E] [CommGroup E] [MetricSpace E]
(hβ : β x : E, βxβ = dist x 1) (hβ : β x y z : E, dist (x * z) (y * z) β€ dist x y) :
NormedCommGroup E :=
{ NormedGroup.ofMulDist' hβ hβ with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the
pseudometric space structure from the seminorm properties. Note that in most cases this instance
creates bad definitional equalities (e.g., it does not take into account a possibly existing
`UniformSpace` instance on `E`). -/
@[to_additive
"Construct a seminormed group from a seminorm, i.e., registering the pseudodistance
and the pseudometric space structure from the seminorm properties. Note that in most cases this
instance creates bad definitional equalities (e.g., it does not take into account a possibly
existing `UniformSpace` instance on `E`)."]
abbrev GroupSeminorm.toSeminormedGroup [Group E] (f : GroupSeminorm E) : SeminormedGroup E where
dist x y := f (x / y)
norm := f
dist_eq _ _ := rfl
dist_self x := by simp only [div_self', map_one_eq_zero]
dist_triangle := le_map_div_add_map_div f
dist_comm := map_div_rev f
-- See note [reducible non-instances]
/-- Construct a seminormed group from a seminorm, i.e., registering the pseudodistance and the
pseudometric space structure from the seminorm properties. Note that in most cases this instance
creates bad definitional equalities (e.g., it does not take into account a possibly existing
`UniformSpace` instance on `E`). -/
@[to_additive
"Construct a seminormed group from a seminorm, i.e., registering the pseudodistance
and the pseudometric space structure from the seminorm properties. Note that in most cases this
instance creates bad definitional equalities (e.g., it does not take into account a possibly
existing `UniformSpace` instance on `E`)."]
abbrev GroupSeminorm.toSeminormedCommGroup [CommGroup E] (f : GroupSeminorm E) :
SeminormedCommGroup E :=
{ f.toSeminormedGroup with
mul_comm := mul_comm }
-- See note [reducible non-instances]
/-- Construct a normed group from a norm, i.e., registering the distance and the metric space
structure from the norm properties. Note that in most cases this instance creates bad definitional
equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on
`E`). -/
@[to_additive
"Construct a normed group from a norm, i.e., registering the distance and the metric
space structure from the norm properties. Note that in most cases this instance creates bad
definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace`
instance on `E`)."]
abbrev GroupNorm.toNormedGroup [Group E] (f : GroupNorm E) : NormedGroup E :=
{ f.toGroupSeminorm.toSeminormedGroup with
eq_of_dist_eq_zero := fun h => div_eq_one.1 <| eq_one_of_map_eq_zero f h }
-- See note [reducible non-instances]
/-- Construct a normed group from a norm, i.e., registering the distance and the metric space
structure from the norm properties. Note that in most cases this instance creates bad definitional
equalities (e.g., it does not take into account a possibly existing `UniformSpace` instance on
`E`). -/
@[to_additive
"Construct a normed group from a norm, i.e., registering the distance and the metric
space structure from the norm properties. Note that in most cases this instance creates bad
definitional equalities (e.g., it does not take into account a possibly existing `UniformSpace`
instance on `E`)."]
abbrev GroupNorm.toNormedCommGroup [CommGroup E] (f : GroupNorm E) : NormedCommGroup E :=
{ f.toNormedGroup with
mul_comm := mul_comm }
section SeminormedGroup
variable [SeminormedGroup E] [SeminormedGroup F] [SeminormedGroup G] {s : Set E}
{a aβ aβ b c : E} {r rβ rβ : β}
@[to_additive]
theorem dist_eq_norm_div (a b : E) : dist a b = βa / bβ :=
SeminormedGroup.dist_eq _ _
@[to_additive]
theorem dist_eq_norm_div' (a b : E) : dist a b = βb / aβ := by rw [dist_comm, dist_eq_norm_div]
alias dist_eq_norm := dist_eq_norm_sub
alias dist_eq_norm' := dist_eq_norm_sub'
@[to_additive of_forall_le_norm]
lemma DiscreteTopology.of_forall_le_norm' (hpos : 0 < r) (hr : β x : E, x β 1 β r β€ βxβ) :
DiscreteTopology E :=
.of_forall_le_dist hpos fun x y hne β¦ by
simp only [dist_eq_norm_div]
exact hr _ (div_ne_one.2 hne)
@[to_additive (attr := simp)]
theorem dist_one_right (a : E) : dist a 1 = βaβ := by rw [dist_eq_norm_div, div_one]
@[to_additive]
theorem inseparable_one_iff_norm {a : E} : Inseparable a 1 β βaβ = 0 := by
rw [Metric.inseparable_iff, dist_one_right]
@[to_additive]
lemma dist_one_left (a : E) : dist 1 a = βaβ := by rw [dist_comm, dist_one_right]
@[to_additive (attr := simp)]
lemma dist_one : dist (1 : E) = norm := funext dist_one_left
@[to_additive]
theorem norm_div_rev (a b : E) : βa / bβ = βb / aβ := by
simpa only [dist_eq_norm_div] using dist_comm a b
@[to_additive (attr := simp) norm_neg]
theorem norm_inv' (a : E) : βaβ»ΒΉβ = βaβ := by simpa using norm_div_rev 1 a
@[to_additive (attr := simp) norm_abs_zsmul]
theorem norm_zpow_abs (a : E) (n : β€) : βa ^ |n|β = βa ^ nβ := by
rcases le_total 0 n with hn | hn <;> simp [hn, abs_of_nonneg, abs_of_nonpos]
@[to_additive (attr := simp) norm_natAbs_smul]
theorem norm_pow_natAbs (a : E) (n : β€) : βa ^ n.natAbsβ = βa ^ nβ := by
rw [β zpow_natCast, β Int.abs_eq_natAbs, norm_zpow_abs]
@[to_additive norm_isUnit_zsmul]
theorem norm_zpow_isUnit (a : E) {n : β€} (hn : IsUnit n) : βa ^ nβ = βaβ := by
rw [β norm_pow_natAbs, Int.isUnit_iff_natAbs_eq.mp hn, pow_one]
@[simp]
theorem norm_units_zsmul {E : Type*} [SeminormedAddGroup E] (n : β€Λ£) (a : E) : βn β’ aβ = βaβ :=
norm_isUnit_zsmul a n.isUnit
open scoped symmDiff in
@[to_additive]
theorem dist_mulIndicator (s t : Set Ξ±) (f : Ξ± β E) (x : Ξ±) :
dist (s.mulIndicator f x) (t.mulIndicator f x) = β(s β t).mulIndicator f xβ := by
rw [dist_eq_norm_div, Set.apply_mulIndicator_symmDiff norm_inv']
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_add_le "**Triangle inequality** for the norm."]
theorem norm_mul_le' (a b : E) : βa * bβ β€ βaβ + βbβ := by
simpa [dist_eq_norm_div] using dist_triangle a 1 bβ»ΒΉ
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_add_le_of_le "**Triangle inequality** for the norm."]
theorem norm_mul_le_of_le' (hβ : βaββ β€ rβ) (hβ : βaββ β€ rβ) : βaβ * aββ β€ rβ + rβ :=
(norm_mul_le' aβ aβ).trans <| add_le_add hβ hβ
/-- **Triangle inequality** for the norm. -/
@[to_additive norm_addβ_le "**Triangle inequality** for the norm."]
lemma norm_mulβ_le' : βa * b * cβ β€ βaβ + βbβ + βcβ := norm_mul_le_of_le' (norm_mul_le' _ _) le_rfl
@[to_additive]
lemma norm_div_le_norm_div_add_norm_div (a b c : E) : βa / cβ β€ βa / bβ + βb / cβ := by
simpa only [dist_eq_norm_div] using dist_triangle a b c
@[to_additive (attr := simp) norm_nonneg]
theorem norm_nonneg' (a : E) : 0 β€ βaβ := by
rw [β dist_one_right]
exact dist_nonneg
attribute [bound] norm_nonneg
@[to_additive (attr := simp) abs_norm]
theorem abs_norm' (z : E) : |βzβ| = βzβ := abs_of_nonneg <| norm_nonneg' _
@[to_additive (attr := simp) norm_zero]
theorem norm_one' : β(1 : E)β = 0 := by rw [β dist_one_right, dist_self]
@[to_additive]
theorem ne_one_of_norm_ne_zero : βaβ β 0 β a β 1 :=
mt <| by
rintro rfl
exact norm_one'
@[to_additive (attr := nontriviality) norm_of_subsingleton]
theorem norm_of_subsingleton' [Subsingleton E] (a : E) : βaβ = 0 := by
rw [Subsingleton.elim a 1, norm_one']
@[to_additive zero_lt_one_add_norm_sq]
theorem zero_lt_one_add_norm_sq' (x : E) : 0 < 1 + βxβ ^ 2 := by
positivity
@[to_additive]
theorem norm_div_le (a b : E) : βa / bβ β€ βaβ + βbβ := by
simpa [dist_eq_norm_div] using dist_triangle a 1 b
attribute [bound] norm_sub_le
@[to_additive]
theorem norm_div_le_of_le {rβ rβ : β} (Hβ : βaββ β€ rβ) (Hβ : βaββ β€ rβ) : βaβ / aββ β€ rβ + rβ :=
(norm_div_le aβ aβ).trans <| add_le_add Hβ Hβ
@[to_additive dist_le_norm_add_norm]
theorem dist_le_norm_add_norm' (a b : E) : dist a b β€ βaβ + βbβ := by
rw [dist_eq_norm_div]
apply norm_div_le
@[to_additive abs_norm_sub_norm_le]
theorem abs_norm_sub_norm_le' (a b : E) : |βaβ - βbβ| β€ βa / bβ := by
simpa [dist_eq_norm_div] using abs_dist_sub_le a b 1
@[to_additive norm_sub_norm_le]
theorem norm_sub_norm_le' (a b : E) : βaβ - βbβ β€ βa / bβ :=
(le_abs_self _).trans (abs_norm_sub_norm_le' a b)
@[to_additive (attr := bound)]
theorem norm_sub_le_norm_mul (a b : E) : βaβ - βbβ β€ βa * bβ := by
simpa using norm_mul_le' (a * b) (bβ»ΒΉ)
@[to_additive dist_norm_norm_le]
theorem dist_norm_norm_le' (a b : E) : dist βaβ βbβ β€ βa / bβ :=
abs_norm_sub_norm_le' a b
@[to_additive]
theorem norm_le_norm_add_norm_div' (u v : E) : βuβ β€ βvβ + βu / vβ := by
rw [add_comm]
refine (norm_mul_le' _ _).trans_eq' ?_
rw [div_mul_cancel]
@[to_additive]
theorem norm_le_norm_add_norm_div (u v : E) : βvβ β€ βuβ + βu / vβ := by
rw [norm_div_rev]
exact norm_le_norm_add_norm_div' v u
alias norm_le_insert' := norm_le_norm_add_norm_sub'
alias norm_le_insert := norm_le_norm_add_norm_sub
@[to_additive]
theorem norm_le_mul_norm_add (u v : E) : βuβ β€ βu * vβ + βvβ :=
calc
βuβ = βu * v / vβ := by rw [mul_div_cancel_right]
_ β€ βu * vβ + βvβ := norm_div_le _ _
/-- An analogue of `norm_le_mul_norm_add` for the multiplication from the left. -/
@[to_additive "An analogue of `norm_le_add_norm_add` for the addition from the left."]
theorem norm_le_mul_norm_add' (u v : E) : βvβ β€ βu * vβ + βuβ :=
calc
βvβ = βuβ»ΒΉ * (u * v)β := by rw [β mul_assoc, inv_mul_cancel, one_mul]
_ β€ βuβ»ΒΉβ + βu * vβ := norm_mul_le' uβ»ΒΉ (u * v)
_ = βu * vβ + βuβ := by rw [norm_inv', add_comm]
@[to_additive]
lemma norm_mul_eq_norm_right {x : E} (y : E) (h : βxβ = 0) : βx * yβ = βyβ := by
apply le_antisymm ?_ ?_
Β· simpa [h] using norm_mul_le' x y
Β· simpa [h] using norm_le_mul_norm_add' x y
@[to_additive]
lemma norm_mul_eq_norm_left (x : E) {y : E} (h : βyβ = 0) : βx * yβ = βxβ := by
apply le_antisymm ?_ ?_
Β· simpa [h] using norm_mul_le' x y
Β· simpa [h] using norm_le_mul_norm_add x y
@[to_additive]
lemma norm_div_eq_norm_right {x : E} (y : E) (h : βxβ = 0) : βx / yβ = βyβ := by
apply le_antisymm ?_ ?_
Β· simpa [h] using norm_div_le x y
Β· simpa [h, norm_div_rev x y] using norm_sub_norm_le' y x
@[to_additive]
lemma norm_div_eq_norm_left (x : E) {y : E} (h : βyβ = 0) : βx / yβ = βxβ := by
apply le_antisymm ?_ ?_
Β· simpa [h] using norm_div_le x y
Β· simpa [h] using norm_sub_norm_le' x y
@[to_additive ball_eq]
theorem ball_eq' (y : E) (Ξ΅ : β) : ball y Ξ΅ = { x | βx / yβ < Ξ΅ } :=
Set.ext fun a => by simp [dist_eq_norm_div]
@[to_additive]
theorem ball_one_eq (r : β) : ball (1 : E) r = { x | βxβ < r } :=
Set.ext fun a => by simp
@[to_additive mem_ball_iff_norm]
theorem mem_ball_iff_norm'' : b β ball a r β βb / aβ < r := by rw [mem_ball, dist_eq_norm_div]
@[to_additive mem_ball_iff_norm']
theorem mem_ball_iff_norm''' : b β ball a r β βa / bβ < r := by rw [mem_ball', dist_eq_norm_div]
@[to_additive]
theorem mem_ball_one_iff : a β ball (1 : E) r β βaβ < r := by rw [mem_ball, dist_one_right]
@[to_additive mem_closedBall_iff_norm]
theorem mem_closedBall_iff_norm'' : b β closedBall a r β βb / aβ β€ r := by
rw [mem_closedBall, dist_eq_norm_div]
@[to_additive]
theorem mem_closedBall_one_iff : a β closedBall (1 : E) r β βaβ β€ r := by
rw [mem_closedBall, dist_one_right]
@[to_additive mem_closedBall_iff_norm']
theorem mem_closedBall_iff_norm''' : b β closedBall a r β βa / bβ β€ r := by
rw [mem_closedBall', dist_eq_norm_div]
@[to_additive norm_le_of_mem_closedBall]
theorem norm_le_of_mem_closedBall' (h : b β closedBall a r) : βbβ β€ βaβ + r :=
(norm_le_norm_add_norm_div' _ _).trans <| add_le_add_left (by rwa [β dist_eq_norm_div]) _
@[to_additive norm_le_norm_add_const_of_dist_le]
theorem norm_le_norm_add_const_of_dist_le' : dist a b β€ r β βaβ β€ βbβ + r :=
norm_le_of_mem_closedBall'
@[to_additive norm_lt_of_mem_ball]
theorem norm_lt_of_mem_ball' (h : b β ball a r) : βbβ < βaβ + r :=
(norm_le_norm_add_norm_div' _ _).trans_lt <| add_lt_add_left (by rwa [β dist_eq_norm_div]) _
@[to_additive]
theorem norm_div_sub_norm_div_le_norm_div (u v w : E) : βu / wβ - βv / wβ β€ βu / vβ := by
simpa only [div_div_div_cancel_right] using norm_sub_norm_le' (u / w) (v / w)
@[to_additive (attr := simp 1001) mem_sphere_iff_norm]
-- Porting note: increase priority so the left-hand side doesn't reduce
theorem mem_sphere_iff_norm' : b β sphere a r β βb / aβ = r := by simp [dist_eq_norm_div]
@[to_additive] -- `simp` can prove this
theorem mem_sphere_one_iff_norm : a β sphere (1 : E) r β βaβ = r := by simp [dist_eq_norm_div]
@[to_additive (attr := simp) norm_eq_of_mem_sphere]
theorem norm_eq_of_mem_sphere' (x : sphere (1 : E) r) : β(x : E)β = r :=
mem_sphere_one_iff_norm.mp x.2
@[to_additive]
theorem ne_one_of_mem_sphere (hr : r β 0) (x : sphere (1 : E) r) : (x : E) β 1 :=
ne_one_of_norm_ne_zero <| by rwa [norm_eq_of_mem_sphere' x]
@[to_additive ne_zero_of_mem_unit_sphere]
theorem ne_one_of_mem_unit_sphere (x : sphere (1 : E) 1) : (x : E) β 1 :=
ne_one_of_mem_sphere one_ne_zero _
variable (E)
/-- The norm of a seminormed group as a group seminorm. -/
@[to_additive "The norm of a seminormed group as an additive group seminorm."]
def normGroupSeminorm : GroupSeminorm E :=
β¨norm, norm_one', norm_mul_le', norm_inv'β©
@[to_additive (attr := simp)]
theorem coe_normGroupSeminorm : β(normGroupSeminorm E) = norm :=
rfl
variable {E}
@[to_additive]
theorem NormedCommGroup.tendsto_nhds_one {f : Ξ± β E} {l : Filter Ξ±} :
Tendsto f l (π 1) β β Ξ΅ > 0, βαΆ x in l, βf xβ < Ξ΅ :=
Metric.tendsto_nhds.trans <| by simp only [dist_one_right]
@[to_additive]
theorem NormedCommGroup.tendsto_nhds_nhds {f : E β F} {x : E} {y : F} :
Tendsto f (π x) (π y) β β Ξ΅ > 0, β Ξ΄ > 0, β x', βx' / xβ < Ξ΄ β βf x' / yβ < Ξ΅ := by
simp_rw [Metric.tendsto_nhds_nhds, dist_eq_norm_div]
@[to_additive]
theorem NormedCommGroup.nhds_basis_norm_lt (x : E) :
(π x).HasBasis (fun Ξ΅ : β => 0 < Ξ΅) fun Ξ΅ => { y | βy / xβ < Ξ΅ } := by
simp_rw [β ball_eq']
exact Metric.nhds_basis_ball
@[to_additive]
theorem NormedCommGroup.nhds_one_basis_norm_lt :
(π (1 : E)).HasBasis (fun Ξ΅ : β => 0 < Ξ΅) fun Ξ΅ => { y | βyβ < Ξ΅ } := by
convert NormedCommGroup.nhds_basis_norm_lt (1 : E)
simp
@[to_additive]
theorem NormedCommGroup.uniformity_basis_dist :
(π€ E).HasBasis (fun Ξ΅ : β => 0 < Ξ΅) fun Ξ΅ => { p : E Γ E | βp.fst / p.sndβ < Ξ΅ } := by
convert Metric.uniformity_basis_dist (Ξ± := E) using 1
simp [dist_eq_norm_div]
open Finset
variable [FunLike π E F]
section NNNorm
-- See note [lower instance priority]
@[to_additive]
instance (priority := 100) SeminormedGroup.toNNNorm : NNNorm E :=
β¨fun a => β¨βaβ, norm_nonneg' aβ©β©
@[to_additive (attr := simp, norm_cast) coe_nnnorm]
theorem coe_nnnorm' (a : E) : (βaββ : β) = βaβ := rfl
@[to_additive (attr := simp) coe_comp_nnnorm]
theorem coe_comp_nnnorm' : (toReal : ββ₯0 β β) β (nnnorm : E β ββ₯0) = norm :=
rfl
@[to_additive (attr := simp) norm_toNNReal]
theorem norm_toNNReal' : βaβ.toNNReal = βaββ :=
@Real.toNNReal_coe βaββ
@[to_additive (attr := simp) toReal_enorm]
lemma toReal_enorm' (x : E) : βxββ.toReal = βxβ := by simp [enorm]
@[to_additive (attr := simp) ofReal_norm]
lemma ofReal_norm' (x : E) : .ofReal βxβ = βxββ := by
simp [enorm, ENNReal.ofReal, Real.toNNReal, nnnorm]
@[to_additive enorm_eq_iff_norm_eq]
theorem enorm'_eq_iff_norm_eq {x : E} {y : F} : βxββ = βyββ β βxβ = βyβ := by
simp only [β ofReal_norm']
refine β¨fun h β¦ ?_, fun h β¦ by congrβ©
exact (Real.toNNReal_eq_toNNReal_iff (norm_nonneg' _) (norm_nonneg' _)).mp (ENNReal.coe_inj.mp h)
@[to_additive enorm_le_iff_norm_le]
| Mathlib/Analysis/Normed/Group/Basic.lean | 714 | 716 | theorem enorm'_le_iff_norm_le {x : E} {y : F} : βxββ β€ βyββ β βxβ β€ βyβ := by | simp only [β ofReal_norm']
refine β¨fun h β¦ ?_, fun h β¦ by gcongrβ© |
/-
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, Violeta HernΓ‘ndez Palacios, Grayson Burton, Floris van Doorn
-/
import Mathlib.Order.Antisymmetrization
import Mathlib.Order.Hom.WithTopBot
import Mathlib.Order.Interval.Set.OrdConnected
import Mathlib.Order.Interval.Set.WithBotTop
/-!
# The covering relation
This file proves properties of the covering relation in an order.
We say that `b` *covers* `a` if `a < b` and there is no element in between.
We say that `b` *weakly covers* `a` if `a β€ b` and there is no element between `a` and `b`.
In a partial order this is equivalent to `a β b β¨ a = b`,
in a preorder this is equivalent to `a β b β¨ (a β€ b β§ b β€ a)`
## Notation
* `a β b` means that `b` covers `a`.
* `a β©Ώ b` means that `b` weakly covers `a`.
-/
open Set OrderDual
variable {Ξ± Ξ² : Type*}
section WeaklyCovers
section Preorder
variable [Preorder Ξ±] [Preorder Ξ²] {a b c : Ξ±}
theorem WCovBy.le (h : a β©Ώ b) : a β€ b :=
h.1
theorem WCovBy.refl (a : Ξ±) : a β©Ώ a :=
β¨le_rfl, fun _ hc => hc.not_ltβ©
@[simp] lemma WCovBy.rfl : a β©Ώ a := WCovBy.refl a
protected theorem Eq.wcovBy (h : a = b) : a β©Ώ b :=
h βΈ WCovBy.rfl
theorem wcovBy_of_le_of_le (h1 : a β€ b) (h2 : b β€ a) : a β©Ώ b :=
β¨h1, fun _ hac hcb => (hac.trans hcb).not_le h2β©
alias LE.le.wcovBy_of_le := wcovBy_of_le_of_le
theorem AntisymmRel.wcovBy (h : AntisymmRel (Β· β€ Β·) a b) : a β©Ώ b :=
wcovBy_of_le_of_le h.1 h.2
theorem WCovBy.wcovBy_iff_le (hab : a β©Ώ b) : b β©Ώ a β b β€ a :=
β¨fun h => h.le, fun h => h.wcovBy_of_le hab.leβ©
theorem wcovBy_of_eq_or_eq (hab : a β€ b) (h : β c, a β€ c β c β€ b β c = a β¨ c = b) : a β©Ώ b :=
β¨hab, fun c ha hb => (h c ha.le hb.le).elim ha.ne' hb.neβ©
theorem AntisymmRel.trans_wcovBy (hab : AntisymmRel (Β· β€ Β·) a b) (hbc : b β©Ώ c) : a β©Ώ c :=
β¨hab.1.trans hbc.le, fun _ had hdc => hbc.2 (hab.2.trans_lt had) hdcβ©
theorem wcovBy_congr_left (hab : AntisymmRel (Β· β€ Β·) a b) : a β©Ώ c β b β©Ώ c :=
β¨hab.symm.trans_wcovBy, hab.trans_wcovByβ©
theorem WCovBy.trans_antisymm_rel (hab : a β©Ώ b) (hbc : AntisymmRel (Β· β€ Β·) b c) : a β©Ώ c :=
β¨hab.le.trans hbc.1, fun _ had hdc => hab.2 had <| hdc.trans_le hbc.2β©
theorem wcovBy_congr_right (hab : AntisymmRel (Β· β€ Β·) a b) : c β©Ώ a β c β©Ώ b :=
β¨fun h => h.trans_antisymm_rel hab, fun h => h.trans_antisymm_rel hab.symmβ©
/-- If `a β€ b`, then `b` does not cover `a` iff there's an element in between. -/
theorem not_wcovBy_iff (h : a β€ b) : Β¬a β©Ώ b β β c, a < c β§ c < b := by
simp_rw [WCovBy, h, true_and, not_forall, exists_prop, not_not]
instance WCovBy.isRefl : IsRefl Ξ± (Β· β©Ώ Β·) :=
β¨WCovBy.reflβ©
theorem WCovBy.Ioo_eq (h : a β©Ώ b) : Ioo a b = β
:=
eq_empty_iff_forall_not_mem.2 fun _ hx => h.2 hx.1 hx.2
theorem wcovBy_iff_Ioo_eq : a β©Ώ b β a β€ b β§ Ioo a b = β
:=
and_congr_right' <| by simp [eq_empty_iff_forall_not_mem]
lemma WCovBy.of_le_of_le (hac : a β©Ώ c) (hab : a β€ b) (hbc : b β€ c) : b β©Ώ c :=
β¨hbc, fun _x hbx hxc β¦ hac.2 (hab.trans_lt hbx) hxcβ©
lemma WCovBy.of_le_of_le' (hac : a β©Ώ c) (hab : a β€ b) (hbc : b β€ c) : a β©Ώ b :=
β¨hab, fun _x hax hxb β¦ hac.2 hax <| hxb.trans_le hbcβ©
theorem WCovBy.of_image (f : Ξ± βͺo Ξ²) (h : f a β©Ώ f b) : a β©Ώ b :=
β¨f.le_iff_le.mp h.le, fun _ hac hcb => h.2 (f.lt_iff_lt.mpr hac) (f.lt_iff_lt.mpr hcb)β©
theorem WCovBy.image (f : Ξ± βͺo Ξ²) (hab : a β©Ώ b) (h : (range f).OrdConnected) : f a β©Ώ f b := by
refine β¨f.monotone hab.le, fun c ha hb => ?_β©
obtain β¨c, rflβ© := h.out (mem_range_self _) (mem_range_self _) β¨ha.le, hb.leβ©
rw [f.lt_iff_lt] at ha hb
exact hab.2 ha hb
theorem Set.OrdConnected.apply_wcovBy_apply_iff (f : Ξ± βͺo Ξ²) (h : (range f).OrdConnected) :
f a β©Ώ f b β a β©Ώ b :=
β¨fun h2 => h2.of_image f, fun hab => hab.image f hβ©
@[simp]
theorem apply_wcovBy_apply_iff {E : Type*} [EquivLike E Ξ± Ξ²] [OrderIsoClass E Ξ± Ξ²] (e : E) :
e a β©Ώ e b β a β©Ώ b :=
(ordConnected_range (e : Ξ± βo Ξ²)).apply_wcovBy_apply_iff ((e : Ξ± βo Ξ²) : Ξ± βͺo Ξ²)
@[simp]
theorem toDual_wcovBy_toDual_iff : toDual b β©Ώ toDual a β a β©Ώ b :=
and_congr_right' <| forall_congr' fun _ => forall_swap
@[simp]
theorem ofDual_wcovBy_ofDual_iff {a b : Ξ±α΅α΅} : ofDual a β©Ώ ofDual b β b β©Ώ a :=
and_congr_right' <| forall_congr' fun _ => forall_swap
alias β¨_, WCovBy.toDualβ© := toDual_wcovBy_toDual_iff
alias β¨_, WCovBy.ofDualβ© := ofDual_wcovBy_ofDual_iff
theorem OrderEmbedding.wcovBy_of_apply {Ξ± Ξ² : Type*} [Preorder Ξ±] [Preorder Ξ²]
(f : Ξ± βͺo Ξ²) {x y : Ξ±} (h : f x β©Ώ f y) : x β©Ώ y := by
use f.le_iff_le.1 h.1
intro a
rw [β f.lt_iff_lt, β f.lt_iff_lt]
apply h.2
theorem OrderIso.map_wcovBy {Ξ± Ξ² : Type*} [Preorder Ξ±] [Preorder Ξ²]
(f : Ξ± βo Ξ²) {x y : Ξ±} : f x β©Ώ f y β x β©Ώ y := by
use f.toOrderEmbedding.wcovBy_of_apply
conv_lhs => rw [β f.symm_apply_apply x, β f.symm_apply_apply y]
exact f.symm.toOrderEmbedding.wcovBy_of_apply
end Preorder
section PartialOrder
variable [PartialOrder Ξ±] {a b c : Ξ±}
theorem WCovBy.eq_or_eq (h : a β©Ώ b) (h2 : a β€ c) (h3 : c β€ b) : c = a β¨ c = b := by
rcases h2.eq_or_lt with (h2 | h2); Β· exact Or.inl h2.symm
rcases h3.eq_or_lt with (h3 | h3); Β· exact Or.inr h3
exact (h.2 h2 h3).elim
/-- An `iff` version of `WCovBy.eq_or_eq` and `wcovBy_of_eq_or_eq`. -/
theorem wcovBy_iff_le_and_eq_or_eq : a β©Ώ b β a β€ b β§ β c, a β€ c β c β€ b β c = a β¨ c = b :=
β¨fun h => β¨h.le, fun _ => h.eq_or_eqβ©, And.rec wcovBy_of_eq_or_eqβ©
theorem WCovBy.le_and_le_iff (h : a β©Ώ b) : a β€ c β§ c β€ b β c = a β¨ c = b := by
refine β¨fun h2 => h.eq_or_eq h2.1 h2.2, ?_β©; rintro (rfl | rfl)
exacts [β¨le_rfl, h.leβ©, β¨h.le, le_rflβ©]
theorem WCovBy.Icc_eq (h : a β©Ώ b) : Icc a b = {a, b} := by
ext c
exact h.le_and_le_iff
theorem WCovBy.Ico_subset (h : a β©Ώ b) : Ico a b β {a} := by
rw [β Icc_diff_right, h.Icc_eq, diff_singleton_subset_iff, pair_comm]
| Mathlib/Order/Cover.lean | 162 | 165 | theorem WCovBy.Ioc_subset (h : a β©Ώ b) : Ioc a b β {b} := by | rw [β Icc_diff_left, h.Icc_eq, diff_singleton_subset_iff]
end PartialOrder |
/-
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.Comma.Over.Pullback
import Mathlib.CategoryTheory.Limits.Shapes.KernelPair
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.CommSq
import Mathlib.CategoryTheory.Limits.Shapes.Pullback.Assoc
/-!
# 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
/-- The diagonal morphism `X βΆ Ξ_{X/Y}` for a morphism `f : X βΆ Y`. -/
def diagonal : X βΆ diagonalObj f :=
pullback.lift (π _) (π _) rfl
@[reassoc (attr := simp)]
theorem diagonal_fst : diagonal f β« pullback.fst _ _ = π _ :=
pullback.lift_fst _ _ _
@[reassoc (attr := simp)]
theorem diagonal_snd : diagonal f β« pullback.snd _ _ = π _ :=
pullback.lift_snd _ _ _
instance : IsSplitMono (diagonal f) :=
β¨β¨β¨pullback.fst _ _, diagonal_fst fβ©β©β©
instance : IsSplitEpi (pullback.fst f f) :=
β¨β¨β¨diagonal f, diagonal_fst fβ©β©β©
instance : IsSplitEpi (pullback.snd f f) :=
β¨β¨β¨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
lemma isIso_diagonal_iff : IsIso (diagonal f) β Mono f :=
β¨fun H β¦ β¨fun _ _ e β¦ by rw [β lift_fst _ _ e, (cancel_epi (g := fst f f) (h := snd f f)
(diagonal f)).mp (by simp), lift_snd]β©, fun _ β¦ inferInstanceβ©
/-- The two projections `Ξ_{X/Y} βΆ X` form a kernel pair for `f : X βΆ Y`. -/
theorem diagonal_isKernelPair : IsKernelPair f (pullback.fst f f) (pullback.snd f f) :=
IsPullback.of_hasPullback f f
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 (diagonal f)
(map (iβ β« snd f i) (iβ β« snd f i) f f (iβ β« fst f i) (iβ β« fst f i) 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]
@[reassoc (attr := simp)]
theorem pullback_diagonal_map_snd_snd_fst :
(pullback.snd (diagonal f)
(map (iβ β« snd f i) (iβ β« snd f i) f f (iβ β« fst f i) (iβ β« fst f i) 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]
variable [HasPullback iβ iβ]
/-- The underlying map of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.hom :
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β :=
pullback.lift (pullback.snd _ _ β« pullback.fst _ _) (pullback.snd _ _ β« pullback.snd _ _) (by
ext
Β· simp only [Category.assoc, pullback_diagonal_map_snd_fst_fst,
pullback_diagonal_map_snd_snd_fst]
Β· simp only [Category.assoc, condition])
/-- The underlying inverse of `pullbackDiagonalIso` -/
abbrev pullbackDiagonalMapIso.inv : pullback iβ iβ βΆ
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.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])
/-- 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 := pullbackDiagonalMapIso.hom f i iβ iβ
inv := pullbackDiagonalMapIso.inv f i iβ iβ
@[reassoc (attr := simp)]
theorem pullbackDiagonalMapIso.hom_fst :
(pullbackDiagonalMapIso f i iβ iβ).hom β« pullback.fst _ _ =
pullback.snd _ _ β« pullback.fst _ _ := by
delta pullbackDiagonalMapIso
simp only [limit.lift_Ο, PullbackCone.mk_pt, PullbackCone.mk_Ο_app]
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Limits/Shapes/Diagonal.lean | 165 | 168 | theorem pullbackDiagonalMapIso.hom_snd :
(pullbackDiagonalMapIso f i iβ iβ).hom β« pullback.snd _ _ =
pullback.snd _ _ β« pullback.snd _ _ := by | delta pullbackDiagonalMapIso |
/-
Copyright (c) 2022 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, YaΓ«l Dillies
-/
import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
/-!
# Integral average of a function
In this file we define `MeasureTheory.average ΞΌ f` (notation: `β¨ x, f x βΞΌ`) to be the average
value of `f` with respect to measure `ΞΌ`. It is defined as `β« x, f x β((ΞΌ univ)β»ΒΉ β’ ΞΌ)`, so it
is equal to zero if `f` is not integrable or if `ΞΌ` is an infinite measure. If `ΞΌ` is a probability
measure, then the average of any function is equal to its integral.
For the average on a set, we use `β¨ x in s, f x βΞΌ` (notation for `β¨ x, f x β(ΞΌ.restrict s)`). For
average w.r.t. the volume, one can omit `βvolume`.
Both have a version for the Lebesgue integral rather than Bochner.
We prove several version of the first moment method: An integrable function is below/above its
average on a set of positive measure:
* `measure_le_setLAverage_pos` for the Lebesgue integral
* `measure_le_setAverage_pos` for the Bochner integral
## Implementation notes
The average is defined as an integral over `(ΞΌ univ)β»ΒΉ β’ ΞΌ` so that all theorems about Bochner
integrals work for the average without modifications. For theorems that require integrability of a
function, we provide a convenience lemma `MeasureTheory.Integrable.to_average`.
## Tags
integral, center mass, average value
-/
open ENNReal MeasureTheory MeasureTheory.Measure Metric Set Filter TopologicalSpace Function
open scoped Topology ENNReal Convex
variable {Ξ± E F : Type*} {m0 : MeasurableSpace Ξ±} [NormedAddCommGroup E] [NormedSpace β E]
[NormedAddCommGroup F] [NormedSpace β F] [CompleteSpace F] {ΞΌ Ξ½ : Measure Ξ±}
{s t : Set Ξ±}
/-!
### Average value of a function w.r.t. a measure
The (Bochner, Lebesgue) average value of a function `f` w.r.t. a measure `ΞΌ` (notation:
`β¨ x, f x βΞΌ`, `β¨β» x, f x βΞΌ`) is defined as the (Bochner, Lebesgue) integral divided by the total
measure, so it is equal to zero if `ΞΌ` is an infinite measure, and (typically) equal to infinity if
`f` is not integrable. If `ΞΌ` is a probability measure, then the average of any function is equal to
its integral.
-/
namespace MeasureTheory
section ENNReal
variable (ΞΌ) {f g : Ξ± β ββ₯0β}
/-- Average value of an `ββ₯0β`-valued function `f` w.r.t. a measure `ΞΌ`, denoted `β¨β» x, f x βΞΌ`.
It is equal to `(ΞΌ univ)β»ΒΉ * β«β» x, f x βΞΌ`, so it takes value zero if `ΞΌ` is an infinite measure. If
`ΞΌ` is a probability measure, then the average of any function is equal to its integral.
For the average on a set, use `β¨β» x in s, f x βΞΌ`, defined as `β¨β» x, f x β(ΞΌ.restrict s)`. For the
average w.r.t. the volume, one can omit `βvolume`. -/
noncomputable def laverage (f : Ξ± β ββ₯0β) := β«β» x, f x β(ΞΌ univ)β»ΒΉ β’ ΞΌ
/-- Average value of an `ββ₯0β`-valued function `f` w.r.t. a measure `ΞΌ`.
It is equal to `(ΞΌ univ)β»ΒΉ * β«β» x, f x βΞΌ`, so it takes value zero if `ΞΌ` is an infinite measure. If
`ΞΌ` is a probability measure, then the average of any function is equal to its integral.
For the average on a set, use `β¨β» x in s, f x βΞΌ`, defined as `β¨β» x, f x β(ΞΌ.restrict s)`. For the
average w.r.t. the volume, one can omit `βvolume`. -/
notation3 "β¨β» "(...)", "r:60:(scoped f => f)" β"ΞΌ:70 => laverage ΞΌ r
/-- Average value of an `ββ₯0β`-valued function `f` w.r.t. to the standard measure.
It is equal to `(volume univ)β»ΒΉ * β«β» x, f x`, so it takes value zero if the space has infinite
measure. In a probability space, the average of any function is equal to its integral.
For the average on a set, use `β¨β» x in s, f x`, defined as `β¨β» x, f x β(volume.restrict s)`. -/
notation3 "β¨β» "(...)", "r:60:(scoped f => laverage volume f) => r
/-- Average value of an `ββ₯0β`-valued function `f` w.r.t. a measure `ΞΌ` on a set `s`.
It is equal to `(ΞΌ s)β»ΒΉ * β«β» x, f x βΞΌ`, so it takes value zero if `s` has infinite measure. If `s`
has measure `1`, then the average of any function is equal to its integral.
For the average w.r.t. the volume, one can omit `βvolume`. -/
notation3 "β¨β» "(...)" in "s", "r:60:(scoped f => f)" β"ΞΌ:70 => laverage (Measure.restrict ΞΌ s) r
/-- Average value of an `ββ₯0β`-valued function `f` w.r.t. to the standard measure on a set `s`.
It is equal to `(volume s)β»ΒΉ * β«β» x, f x`, so it takes value zero if `s` has infinite measure. If
`s` has measure `1`, then the average of any function is equal to its integral. -/
notation3 (prettyPrint := false)
"β¨β» "(...)" in "s", "r:60:(scoped f => laverage Measure.restrict volume s f) => r
@[simp]
theorem laverage_zero : β¨β» _x, (0 : ββ₯0β) βΞΌ = 0 := by rw [laverage, lintegral_zero]
@[simp]
theorem laverage_zero_measure (f : Ξ± β ββ₯0β) : β¨β» x, f x β(0 : Measure Ξ±) = 0 := by simp [laverage]
theorem laverage_eq' (f : Ξ± β ββ₯0β) : β¨β» x, f x βΞΌ = β«β» x, f x β(ΞΌ univ)β»ΒΉ β’ ΞΌ := rfl
theorem laverage_eq (f : Ξ± β ββ₯0β) : β¨β» x, f x βΞΌ = (β«β» x, f x βΞΌ) / ΞΌ univ := by
rw [laverage_eq', lintegral_smul_measure, ENNReal.div_eq_inv_mul, smul_eq_mul]
theorem laverage_eq_lintegral [IsProbabilityMeasure ΞΌ] (f : Ξ± β ββ₯0β) :
β¨β» x, f x βΞΌ = β«β» x, f x βΞΌ := by rw [laverage, measure_univ, inv_one, one_smul]
@[simp]
theorem measure_mul_laverage [IsFiniteMeasure ΞΌ] (f : Ξ± β ββ₯0β) :
ΞΌ univ * β¨β» x, f x βΞΌ = β«β» x, f x βΞΌ := by
rcases eq_or_ne ΞΌ 0 with hΞΌ | hΞΌ
Β· rw [hΞΌ, lintegral_zero_measure, laverage_zero_measure, mul_zero]
Β· rw [laverage_eq, ENNReal.mul_div_cancel (measure_univ_ne_zero.2 hΞΌ) (measure_ne_top _ _)]
theorem setLAverage_eq (f : Ξ± β ββ₯0β) (s : Set Ξ±) :
β¨β» x in s, f x βΞΌ = (β«β» x in s, f x βΞΌ) / ΞΌ s := by rw [laverage_eq, restrict_apply_univ]
@[deprecated (since := "2025-04-22")] alias setLaverage_eq := setLAverage_eq
theorem setLAverage_eq' (f : Ξ± β ββ₯0β) (s : Set Ξ±) :
β¨β» x in s, f x βΞΌ = β«β» x, f x β(ΞΌ s)β»ΒΉ β’ ΞΌ.restrict s := by
simp only [laverage_eq', restrict_apply_univ]
@[deprecated (since := "2025-04-22")] alias setLaverage_eq' := setLAverage_eq'
variable {ΞΌ}
theorem laverage_congr {f g : Ξ± β ββ₯0β} (h : f =α΅[ΞΌ] g) : β¨β» x, f x βΞΌ = β¨β» x, g x βΞΌ := by
simp only [laverage_eq, lintegral_congr_ae h]
theorem setLAverage_congr (h : s =α΅[ΞΌ] t) : β¨β» x in s, f x βΞΌ = β¨β» x in t, f x βΞΌ := by
simp only [setLAverage_eq, setLIntegral_congr h, measure_congr h]
@[deprecated (since := "2025-04-22")] alias setLaverage_congr := setLAverage_congr
theorem setLAverage_congr_fun (hs : MeasurableSet s) (h : βα΅ x βΞΌ, x β s β f x = g x) :
β¨β» x in s, f x βΞΌ = β¨β» x in s, g x βΞΌ := by
simp only [laverage_eq, setLIntegral_congr_fun hs h]
@[deprecated (since := "2025-04-22")] alias setLaverage_congr_fun := setLAverage_congr_fun
theorem laverage_lt_top (hf : β«β» x, f x βΞΌ β β) : β¨β» x, f x βΞΌ < β := by
obtain rfl | hΞΌ := eq_or_ne ΞΌ 0
Β· simp
Β· rw [laverage_eq]
exact div_lt_top hf (measure_univ_ne_zero.2 hΞΌ)
theorem setLAverage_lt_top : β«β» x in s, f x βΞΌ β β β β¨β» x in s, f x βΞΌ < β :=
laverage_lt_top
@[deprecated (since := "2025-04-22")] alias setLaverage_lt_top := setLAverage_lt_top
theorem laverage_add_measure :
β¨β» x, f x β(ΞΌ + Ξ½) =
ΞΌ univ / (ΞΌ univ + Ξ½ univ) * β¨β» x, f x βΞΌ + Ξ½ univ / (ΞΌ univ + Ξ½ univ) * β¨β» x, f x βΞ½ := by
by_cases hΞΌ : IsFiniteMeasure ΞΌ; swap
Β· rw [not_isFiniteMeasure_iff] at hΞΌ
simp [laverage_eq, hΞΌ]
by_cases hΞ½ : IsFiniteMeasure Ξ½; swap
Β· rw [not_isFiniteMeasure_iff] at hΞ½
simp [laverage_eq, hΞ½]
haveI := hΞΌ; haveI := hΞ½
simp only [β ENNReal.mul_div_right_comm, measure_mul_laverage, β ENNReal.add_div,
β lintegral_add_measure, β Measure.add_apply, β laverage_eq]
theorem measure_mul_setLAverage (f : Ξ± β ββ₯0β) (h : ΞΌ s β β) :
ΞΌ s * β¨β» x in s, f x βΞΌ = β«β» x in s, f x βΞΌ := by
have := Fact.mk h.lt_top
rw [β measure_mul_laverage, restrict_apply_univ]
@[deprecated (since := "2025-04-22")] alias measure_mul_setLaverage := measure_mul_setLAverage
theorem laverage_union (hd : AEDisjoint ΞΌ s t) (ht : NullMeasurableSet t ΞΌ) :
β¨β» x in s βͺ t, f x βΞΌ =
ΞΌ s / (ΞΌ s + ΞΌ t) * β¨β» x in s, f x βΞΌ + ΞΌ t / (ΞΌ s + ΞΌ t) * β¨β» x in t, f x βΞΌ := by
rw [restrict_unionβ hd ht, laverage_add_measure, restrict_apply_univ, restrict_apply_univ]
theorem laverage_union_mem_openSegment (hd : AEDisjoint ΞΌ s t) (ht : NullMeasurableSet t ΞΌ)
(hsβ : ΞΌ s β 0) (htβ : ΞΌ t β 0) (hsΞΌ : ΞΌ s β β) (htΞΌ : ΞΌ t β β) :
β¨β» x in s βͺ t, f x βΞΌ β openSegment ββ₯0β (β¨β» x in s, f x βΞΌ) (β¨β» x in t, f x βΞΌ) := by
refine
β¨ΞΌ s / (ΞΌ s + ΞΌ t), ΞΌ t / (ΞΌ s + ΞΌ t), ENNReal.div_pos hsβ <| add_ne_top.2 β¨hsΞΌ, htΞΌβ©,
ENNReal.div_pos htβ <| add_ne_top.2 β¨hsΞΌ, htΞΌβ©, ?_, (laverage_union hd ht).symmβ©
rw [β ENNReal.add_div,
ENNReal.div_self (add_eq_zero.not.2 fun h => hsβ h.1) (add_ne_top.2 β¨hsΞΌ, htΞΌβ©)]
theorem laverage_union_mem_segment (hd : AEDisjoint ΞΌ s t) (ht : NullMeasurableSet t ΞΌ)
(hsΞΌ : ΞΌ s β β) (htΞΌ : ΞΌ t β β) :
β¨β» x in s βͺ t, f x βΞΌ β [β¨β» x in s, f x βΞΌ -[ββ₯0β] β¨β» x in t, f x βΞΌ] := by
by_cases hsβ : ΞΌ s = 0
Β· rw [β ae_eq_empty] at hsβ
rw [restrict_congr_set (hsβ.union EventuallyEq.rfl), empty_union]
exact right_mem_segment _ _ _
Β· refine
β¨ΞΌ s / (ΞΌ s + ΞΌ t), ΞΌ t / (ΞΌ s + ΞΌ t), zero_le _, zero_le _, ?_, (laverage_union hd ht).symmβ©
rw [β ENNReal.add_div,
ENNReal.div_self (add_eq_zero.not.2 fun h => hsβ h.1) (add_ne_top.2 β¨hsΞΌ, htΞΌβ©)]
theorem laverage_mem_openSegment_compl_self [IsFiniteMeasure ΞΌ] (hs : NullMeasurableSet s ΞΌ)
(hsβ : ΞΌ s β 0) (hscβ : ΞΌ sαΆ β 0) :
β¨β» x, f x βΞΌ β openSegment ββ₯0β (β¨β» x in s, f x βΞΌ) (β¨β» x in sαΆ, f x βΞΌ) := by
simpa only [union_compl_self, restrict_univ] using
laverage_union_mem_openSegment aedisjoint_compl_right hs.compl hsβ hscβ (measure_ne_top _ _)
(measure_ne_top _ _)
@[simp]
theorem laverage_const (ΞΌ : Measure Ξ±) [IsFiniteMeasure ΞΌ] [h : NeZero ΞΌ] (c : ββ₯0β) :
β¨β» _x, c βΞΌ = c := by
simp only [laverage, lintegral_const, measure_univ, mul_one]
theorem setLAverage_const (hsβ : ΞΌ s β 0) (hs : ΞΌ s β β) (c : ββ₯0β) : β¨β» _x in s, c βΞΌ = c := by
simp only [setLAverage_eq, lintegral_const, Measure.restrict_apply, MeasurableSet.univ,
univ_inter, div_eq_mul_inv, mul_assoc, ENNReal.mul_inv_cancel hsβ hs, mul_one]
@[deprecated (since := "2025-04-22")] alias setLaverage_const := setLAverage_const
theorem laverage_one [IsFiniteMeasure ΞΌ] [NeZero ΞΌ] : β¨β» _x, (1 : ββ₯0β) βΞΌ = 1 :=
laverage_const _ _
theorem setLAverage_one (hsβ : ΞΌ s β 0) (hs : ΞΌ s β β) : β¨β» _x in s, (1 : ββ₯0β) βΞΌ = 1 :=
setLAverage_const hsβ hs _
@[deprecated (since := "2025-04-22")] alias setLaverage_one := setLAverage_one
@[simp]
theorem laverage_mul_measure_univ (ΞΌ : Measure Ξ±) [IsFiniteMeasure ΞΌ] (f : Ξ± β ββ₯0β) :
(β¨β» (a : Ξ±), f a βΞΌ) * ΞΌ univ = β«β» x, f x βΞΌ := by
obtain rfl | hΞΌ := eq_or_ne ΞΌ 0
Β· simp
Β· rw [laverage_eq, ENNReal.div_mul_cancel (measure_univ_ne_zero.2 hΞΌ) (measure_ne_top _ _)]
theorem lintegral_laverage (ΞΌ : Measure Ξ±) [IsFiniteMeasure ΞΌ] (f : Ξ± β ββ₯0β) :
β«β» _x, β¨β» a, f a βΞΌ βΞΌ = β«β» x, f x βΞΌ := by
simp
theorem setLIntegral_setLAverage (ΞΌ : Measure Ξ±) [IsFiniteMeasure ΞΌ] (f : Ξ± β ββ₯0β) (s : Set Ξ±) :
β«β» _x in s, β¨β» a in s, f a βΞΌ βΞΌ = β«β» x in s, f x βΞΌ :=
lintegral_laverage _ _
@[deprecated (since := "2025-04-22")] alias setLintegral_setLaverage := setLIntegral_setLAverage
end ENNReal
section NormedAddCommGroup
variable (ΞΌ)
variable {f g : Ξ± β E}
/-- Average value of a function `f` w.r.t. a measure `ΞΌ`, denoted `β¨ x, f x βΞΌ`.
It is equal to `(ΞΌ.real univ)β»ΒΉ β’ β« x, f x βΞΌ`, so it takes value zero if `f` is not integrable or
if `ΞΌ` is an infinite measure. If `ΞΌ` is a probability measure, then the average of any function is
equal to its integral.
For the average on a set, use `β¨ x in s, f x βΞΌ`, defined as `β¨ x, f x β(ΞΌ.restrict s)`. For the
average w.r.t. the volume, one can omit `βvolume`. -/
noncomputable def average (f : Ξ± β E) :=
β« x, f x β(ΞΌ univ)β»ΒΉ β’ ΞΌ
/-- Average value of a function `f` w.r.t. a measure `ΞΌ`.
It is equal to `(ΞΌ.real univ)β»ΒΉ β’ β« x, f x βΞΌ`, so it takes value zero if `f` is not integrable or
if `ΞΌ` is an infinite measure. If `ΞΌ` is a probability measure, then the average of any function is
equal to its integral.
For the average on a set, use `β¨ x in s, f x βΞΌ`, defined as `β¨ x, f x β(ΞΌ.restrict s)`. For the
average w.r.t. the volume, one can omit `βvolume`. -/
notation3 "β¨ "(...)", "r:60:(scoped f => f)" β"ΞΌ:70 => average ΞΌ r
/-- Average value of a function `f` w.r.t. to the standard measure.
It is equal to `(volume.real univ)β»ΒΉ * β« x, f x`, so it takes value zero if `f` is not integrable
or if the space has infinite measure. In a probability space, the average of any function is equal
to its integral.
For the average on a set, use `β¨ x in s, f x`, defined as `β¨ x, f x β(volume.restrict s)`. -/
notation3 "β¨ "(...)", "r:60:(scoped f => average volume f) => r
/-- Average value of a function `f` w.r.t. a measure `ΞΌ` on a set `s`.
It is equal to `(ΞΌ.real s)β»ΒΉ * β« x, f x βΞΌ`, so it takes value zero if `f` is not integrable on
`s` or if `s` has infinite measure. If `s` has measure `1`, then the average of any function is
equal to its integral.
For the average w.r.t. the volume, one can omit `βvolume`. -/
notation3 "β¨ "(...)" in "s", "r:60:(scoped f => f)" β"ΞΌ:70 => average (Measure.restrict ΞΌ s) r
/-- Average value of a function `f` w.r.t. to the standard measure on a set `s`.
It is equal to `(volume.real s)β»ΒΉ * β« x, f x`, so it takes value zero `f` is not integrable on `s`
or if `s` has infinite measure. If `s` has measure `1`, then the average of any function is equal to
its integral. -/
notation3 "β¨ "(...)" in "s", "r:60:(scoped f => average (Measure.restrict volume s) f) => r
@[simp]
theorem average_zero : β¨ _, (0 : E) βΞΌ = 0 := by rw [average, integral_zero]
@[simp]
theorem average_zero_measure (f : Ξ± β E) : β¨ x, f x β(0 : Measure Ξ±) = 0 := by
rw [average, smul_zero, integral_zero_measure]
@[simp]
theorem average_neg (f : Ξ± β E) : β¨ x, -f x βΞΌ = -β¨ x, f x βΞΌ :=
integral_neg f
theorem average_eq' (f : Ξ± β E) : β¨ x, f x βΞΌ = β« x, f x β(ΞΌ univ)β»ΒΉ β’ ΞΌ :=
rfl
theorem average_eq (f : Ξ± β E) : β¨ x, f x βΞΌ = (ΞΌ.real univ)β»ΒΉ β’ β« x, f x βΞΌ := by
rw [average_eq', integral_smul_measure, ENNReal.toReal_inv, measureReal_def]
theorem average_eq_integral [IsProbabilityMeasure ΞΌ] (f : Ξ± β E) : β¨ x, f x βΞΌ = β« x, f x βΞΌ := by
rw [average, measure_univ, inv_one, one_smul]
@[simp]
theorem measure_smul_average [IsFiniteMeasure ΞΌ] (f : Ξ± β E) :
ΞΌ.real univ β’ β¨ x, f x βΞΌ = β« x, f x βΞΌ := by
rcases eq_or_ne ΞΌ 0 with hΞΌ | hΞΌ
Β· rw [hΞΌ, integral_zero_measure, average_zero_measure, smul_zero]
Β· rw [average_eq, smul_inv_smulβ]
refine (ENNReal.toReal_pos ?_ <| measure_ne_top _ _).ne'
rwa [Ne, measure_univ_eq_zero]
theorem setAverage_eq (f : Ξ± β E) (s : Set Ξ±) :
β¨ x in s, f x βΞΌ = (ΞΌ.real s)β»ΒΉ β’ β« x in s, f x βΞΌ := by
rw [average_eq, measureReal_restrict_apply_univ]
theorem setAverage_eq' (f : Ξ± β E) (s : Set Ξ±) :
β¨ x in s, f x βΞΌ = β« x, f x β(ΞΌ s)β»ΒΉ β’ ΞΌ.restrict s := by
simp only [average_eq', restrict_apply_univ]
variable {ΞΌ}
| Mathlib/MeasureTheory/Integral/Average.lean | 341 | 347 | theorem average_congr {f g : Ξ± β E} (h : f =α΅[ΞΌ] g) : β¨ x, f x βΞΌ = β¨ x, g x βΞΌ := by | simp only [average_eq, integral_congr_ae h]
theorem setAverage_congr (h : s =α΅[ΞΌ] t) : β¨ x in s, f x βΞΌ = β¨ x in t, f x βΞΌ := by
simp only [setAverage_eq, setIntegral_congr_set h, measureReal_congr h]
theorem setAverage_congr_fun (hs : MeasurableSet s) (h : βα΅ x βΞΌ, x β s β f x = g x) : |
/-
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, Devon Tuma
-/
import Mathlib.Probability.ProbabilityMassFunction.Monad
import Mathlib.Control.ULiftable
/-!
# Specific Constructions of Probability Mass Functions
This file gives a number of different `PMF` constructions for common probability distributions.
`map` and `seq` allow pushing a `PMF Ξ±` along a function `f : Ξ± β Ξ²` (or distribution of
functions `f : PMF (Ξ± β Ξ²)`) to get a `PMF Ξ²`.
`ofFinset` and `ofFintype` simplify the construction of a `PMF Ξ±` from a function `f : Ξ± β ββ₯0β`,
by allowing the "sum equals 1" constraint to be in terms of `Finset.sum` instead of `tsum`.
`normalize` constructs a `PMF Ξ±` by normalizing a function `f : Ξ± β ββ₯0β` by its sum,
and `filter` uses this to filter the support of a `PMF` and re-normalize the new distribution.
`bernoulli` represents the bernoulli distribution on `Bool`.
-/
universe u v
namespace PMF
noncomputable section
variable {Ξ± Ξ² Ξ³ : Type*}
open NNReal ENNReal Finset MeasureTheory
section Map
/-- The functorial action of a function on a `PMF`. -/
def map (f : Ξ± β Ξ²) (p : PMF Ξ±) : PMF Ξ² :=
bind p (pure β f)
variable (f : Ξ± β Ξ²) (p : PMF Ξ±) (b : Ξ²)
theorem monad_map_eq_map {Ξ± Ξ² : Type u} (f : Ξ± β Ξ²) (p : PMF Ξ±) : f <$> p = p.map f := rfl
open scoped Classical in
@[simp]
theorem map_apply : (map f p) b = β' a, if b = f a then p a else 0 := by simp [map]
@[simp]
theorem support_map : (map f p).support = f '' p.support :=
Set.ext fun b => by simp [map, @eq_comm Ξ² b]
theorem mem_support_map_iff : b β (map f p).support β β a β p.support, f a = b := by simp
theorem bind_pure_comp : bind p (pure β f) = map f p := rfl
theorem map_id : map id p = p :=
bind_pure _
theorem map_comp (g : Ξ² β Ξ³) : (p.map f).map g = p.map (g β f) := by simp [map, Function.comp_def]
theorem pure_map (a : Ξ±) : (pure a).map f = pure (f a) :=
pure_bind _ _
theorem map_bind (q : Ξ± β PMF Ξ²) (f : Ξ² β Ξ³) : (p.bind q).map f = p.bind fun a => (q a).map f :=
bind_bind _ _ _
@[simp]
theorem bind_map (p : PMF Ξ±) (f : Ξ± β Ξ²) (q : Ξ² β PMF Ξ³) : (p.map f).bind q = p.bind (q β f) :=
(bind_bind _ _ _).trans (congr_arg _ (funext fun _ => pure_bind _ _))
@[simp]
theorem map_const : p.map (Function.const Ξ± b) = pure b := by
simp only [map, Function.comp_def, bind_const, Function.const]
section Measure
variable (s : Set Ξ²)
@[simp]
theorem toOuterMeasure_map_apply : (p.map f).toOuterMeasure s = p.toOuterMeasure (f β»ΒΉ' s) := by
simp [map, Set.indicator, toOuterMeasure_apply p (f β»ΒΉ' s)]
rfl
variable {mΞ± : MeasurableSpace Ξ±} {mΞ² : MeasurableSpace Ξ²}
@[simp]
theorem toMeasure_map_apply (hf : Measurable f)
(hs : MeasurableSet s) : (p.map f).toMeasure s = p.toMeasure (f β»ΒΉ' s) := by
rw [toMeasure_apply_eq_toOuterMeasure_apply _ s hs,
toMeasure_apply_eq_toOuterMeasure_apply _ (f β»ΒΉ' s) (measurableSet_preimage hf hs)]
exact toOuterMeasure_map_apply f p s
@[simp]
lemma toMeasure_map (p : PMF Ξ±) (hf : Measurable f) : p.toMeasure.map f = (p.map f).toMeasure := by
ext s hs : 1; rw [PMF.toMeasure_map_apply _ _ _ hf hs, Measure.map_apply hf hs]
end Measure
end Map
section Seq
/-- The monadic sequencing operation for `PMF`. -/
def seq (q : PMF (Ξ± β Ξ²)) (p : PMF Ξ±) : PMF Ξ² :=
q.bind fun m => p.bind fun a => pure (m a)
variable (q : PMF (Ξ± β Ξ²)) (p : PMF Ξ±) (b : Ξ²)
theorem monad_seq_eq_seq {Ξ± Ξ² : Type u} (q : PMF (Ξ± β Ξ²)) (p : PMF Ξ±) : q <*> p = q.seq p := rfl
open scoped Classical in
@[simp]
theorem seq_apply : (seq q p) b = β' (f : Ξ± β Ξ²) (a : Ξ±), if b = f a then q f * p a else 0 := by
simp only [seq, mul_boole, bind_apply, pure_apply]
refine tsum_congr fun f => ENNReal.tsum_mul_left.symm.trans (tsum_congr fun a => ?_)
simpa only [mul_zero] using mul_ite (b = f a) (q f) (p a) 0
@[simp]
theorem support_seq : (seq q p).support = β f β q.support, f '' p.support :=
Set.ext fun b => by simp [-mem_support_iff, seq, @eq_comm Ξ² b]
| Mathlib/Probability/ProbabilityMassFunction/Constructions.lean | 125 | 128 | theorem mem_support_seq_iff : b β (seq q p).support β β f β q.support, b β f '' p.support := by | simp
end Seq |
/-
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, Kim Morrison, Jens Wagemaker, Johan Commelin
-/
import Mathlib.Algebra.Polynomial.BigOperators
import Mathlib.Algebra.Polynomial.RingDivision
import Mathlib.Data.Set.Finite.Lemmas
import Mathlib.RingTheory.Coprime.Lemmas
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.SetTheory.Cardinal.Order
/-!
# Theory of univariate polynomials
We define the multiset of roots of a polynomial, and prove basic results about it.
## Main definitions
* `Polynomial.roots p`: The multiset containing all the roots of `p`, including their
multiplicities.
* `Polynomial.rootSet p E`: The set of distinct roots of `p` in an algebra `E`.
## Main statements
* `Polynomial.C_leadingCoeff_mul_prod_multiset_X_sub_C`: If a polynomial has as many roots as its
degree, it can be written as the product of its leading coefficient with `β (X - a)` where `a`
ranges through its roots.
-/
assert_not_exists Ideal
open Multiset Finset
noncomputable section
namespace Polynomial
universe u v w z
variable {R : Type u} {S : Type v} {T : Type w} {a b : R} {n : β}
section CommRing
variable [CommRing R] [IsDomain R] {p q : R[X]}
section Roots
/-- `roots p` noncomputably gives a multiset containing all the roots of `p`,
including their multiplicities. -/
noncomputable def roots (p : R[X]) : Multiset R :=
haveI := Classical.decEq R
haveI := Classical.dec (p = 0)
if h : p = 0 then β
else Classical.choose (exists_multiset_roots h)
theorem roots_def [DecidableEq R] (p : R[X]) [Decidable (p = 0)] :
p.roots = if h : p = 0 then β
else Classical.choose (exists_multiset_roots h) := by
rename_i iR ip0
obtain rfl := Subsingleton.elim iR (Classical.decEq R)
obtain rfl := Subsingleton.elim ip0 (Classical.dec (p = 0))
rfl
@[simp]
theorem roots_zero : (0 : R[X]).roots = 0 :=
dif_pos rfl
theorem card_roots (hp0 : p β 0) : (Multiset.card (roots p) : WithBot β) β€ degree p := by
classical
unfold roots
rw [dif_neg hp0]
exact (Classical.choose_spec (exists_multiset_roots hp0)).1
theorem card_roots' (p : R[X]) : Multiset.card p.roots β€ natDegree p := by
by_cases hp0 : p = 0
Β· simp [hp0]
exact WithBot.coe_le_coe.1 (le_trans (card_roots hp0) (le_of_eq <| degree_eq_natDegree hp0))
theorem card_roots_sub_C {p : R[X]} {a : R} (hp0 : 0 < degree p) :
(Multiset.card (p - C a).roots : WithBot β) β€ degree p :=
calc
(Multiset.card (p - C a).roots : WithBot β) β€ degree (p - C a) :=
card_roots <| mt sub_eq_zero.1 fun h => not_le_of_gt hp0 <| h.symm βΈ degree_C_le
_ = degree p := by rw [sub_eq_add_neg, β C_neg]; exact degree_add_C hp0
theorem card_roots_sub_C' {p : R[X]} {a : R} (hp0 : 0 < degree p) :
Multiset.card (p - C a).roots β€ natDegree p :=
WithBot.coe_le_coe.1
(le_trans (card_roots_sub_C hp0)
(le_of_eq <| degree_eq_natDegree fun h => by simp_all [lt_irrefl]))
@[simp]
theorem count_roots [DecidableEq R] (p : R[X]) : p.roots.count a = rootMultiplicity a p := by
classical
by_cases hp : p = 0
Β· simp [hp]
rw [roots_def, dif_neg hp]
exact (Classical.choose_spec (exists_multiset_roots hp)).2 a
@[simp]
theorem mem_roots' : a β p.roots β p β 0 β§ IsRoot p a := by
classical
rw [β count_pos, count_roots p, rootMultiplicity_pos']
theorem mem_roots (hp : p β 0) : a β p.roots β IsRoot p a :=
mem_roots'.trans <| and_iff_right hp
theorem ne_zero_of_mem_roots (h : a β p.roots) : p β 0 :=
(mem_roots'.1 h).1
theorem isRoot_of_mem_roots (h : a β p.roots) : IsRoot p a :=
(mem_roots'.1 h).2
theorem mem_roots_map_of_injective [Semiring S] {p : S[X]} {f : S β+* R}
(hf : Function.Injective f) {x : R} (hp : p β 0) : x β (p.map f).roots β p.evalβ f x = 0 := by
rw [mem_roots ((Polynomial.map_ne_zero_iff hf).mpr hp), IsRoot, eval_map]
lemma mem_roots_iff_aeval_eq_zero {x : R} (w : p β 0) : x β roots p β aeval x p = 0 := by
rw [aeval_def, β mem_roots_map_of_injective (FaithfulSMul.algebraMap_injective _ _) w,
Algebra.id.map_eq_id, map_id]
theorem card_le_degree_of_subset_roots {p : R[X]} {Z : Finset R} (h : Z.val β p.roots) :
#Z β€ p.natDegree :=
(Multiset.card_le_card (Finset.val_le_iff_val_subset.2 h)).trans (Polynomial.card_roots' p)
theorem finite_setOf_isRoot {p : R[X]} (hp : p β 0) : Set.Finite { x | IsRoot p x } := by
classical
simpa only [β Finset.setOf_mem, Multiset.mem_toFinset, mem_roots hp]
using p.roots.toFinset.finite_toSet
theorem eq_zero_of_infinite_isRoot (p : R[X]) (h : Set.Infinite { x | IsRoot p x }) : p = 0 :=
not_imp_comm.mp finite_setOf_isRoot h
theorem exists_max_root [LinearOrder R] (p : R[X]) (hp : p β 0) : β xβ, β x, p.IsRoot x β x β€ xβ :=
Set.exists_upper_bound_image _ _ <| finite_setOf_isRoot hp
theorem exists_min_root [LinearOrder R] (p : R[X]) (hp : p β 0) : β xβ, β x, p.IsRoot x β xβ β€ x :=
Set.exists_lower_bound_image _ _ <| finite_setOf_isRoot hp
theorem eq_of_infinite_eval_eq (p q : R[X]) (h : Set.Infinite { x | eval x p = eval x q }) :
p = q := by
rw [β sub_eq_zero]
apply eq_zero_of_infinite_isRoot
simpa only [IsRoot, eval_sub, sub_eq_zero]
theorem roots_mul {p q : R[X]} (hpq : p * q β 0) : (p * q).roots = p.roots + q.roots := by
classical
exact Multiset.ext.mpr fun r => by
rw [count_add, count_roots, count_roots, count_roots, rootMultiplicity_mul hpq]
theorem roots.le_of_dvd (h : q β 0) : p β£ q β roots p β€ roots q := by
rintro β¨k, rflβ©
exact Multiset.le_iff_exists_add.mpr β¨k.roots, roots_mul hβ©
theorem mem_roots_sub_C' {p : R[X]} {a x : R} : x β (p - C a).roots β p β C a β§ p.eval x = a := by
rw [mem_roots', IsRoot.def, sub_ne_zero, eval_sub, sub_eq_zero, eval_C]
theorem mem_roots_sub_C {p : R[X]} {a x : R} (hp0 : 0 < degree p) :
x β (p - C a).roots β p.eval x = a :=
mem_roots_sub_C'.trans <| and_iff_right fun hp => hp0.not_le <| hp.symm βΈ degree_C_le
@[simp]
theorem roots_X_sub_C (r : R) : roots (X - C r) = {r} := by
classical
ext s
rw [count_roots, rootMultiplicity_X_sub_C, count_singleton]
@[simp]
theorem roots_X_add_C (r : R) : roots (X + C r) = {-r} := by simpa using roots_X_sub_C (-r)
@[simp]
theorem roots_X : roots (X : R[X]) = {0} := by rw [β roots_X_sub_C, C_0, sub_zero]
@[simp]
theorem roots_C (x : R) : (C x).roots = 0 := by
classical exact
if H : x = 0 then by rw [H, C_0, roots_zero]
else
Multiset.ext.mpr fun r => (by
rw [count_roots, count_zero, rootMultiplicity_eq_zero (not_isRoot_C _ _ H)])
@[simp]
theorem roots_one : (1 : R[X]).roots = β
:=
roots_C 1
@[simp]
theorem roots_C_mul (p : R[X]) (ha : a β 0) : (C a * p).roots = p.roots := by
by_cases hp : p = 0 <;>
simp only [roots_mul, *, Ne, mul_eq_zero, C_eq_zero, or_self_iff, not_false_iff, roots_C,
zero_add, mul_zero]
@[simp]
theorem roots_smul_nonzero (p : R[X]) (ha : a β 0) : (a β’ p).roots = p.roots := by
rw [smul_eq_C_mul, roots_C_mul _ ha]
@[simp]
lemma roots_neg (p : R[X]) : (-p).roots = p.roots := by
rw [β neg_one_smul R p, roots_smul_nonzero p (neg_ne_zero.mpr one_ne_zero)]
@[simp]
theorem roots_C_mul_X_sub_C_of_IsUnit (b : R) (a : RΛ£) : (C (a : R) * X - C b).roots =
{aβ»ΒΉ * b} := by
rw [β roots_C_mul _ (Units.ne_zero aβ»ΒΉ), mul_sub, β mul_assoc, β C_mul, β C_mul,
Units.inv_mul, C_1, one_mul]
exact roots_X_sub_C (aβ»ΒΉ * b)
@[simp]
theorem roots_C_mul_X_add_C_of_IsUnit (b : R) (a : RΛ£) : (C (a : R) * X + C b).roots =
{-(aβ»ΒΉ * b)} := by
rw [β sub_neg_eq_add, β C_neg, roots_C_mul_X_sub_C_of_IsUnit, mul_neg]
theorem roots_list_prod (L : List R[X]) :
(0 : R[X]) β L β L.prod.roots = (L : Multiset R[X]).bind roots :=
List.recOn L (fun _ => roots_one) fun hd tl ih H => by
rw [List.mem_cons, not_or] at H
rw [List.prod_cons, roots_mul (mul_ne_zero (Ne.symm H.1) <| List.prod_ne_zero H.2), β
Multiset.cons_coe, Multiset.cons_bind, ih H.2]
theorem roots_multiset_prod (m : Multiset R[X]) : (0 : R[X]) β m β m.prod.roots = m.bind roots := by
rcases m with β¨Lβ©
simpa only [Multiset.prod_coe, quot_mk_to_coe''] using roots_list_prod L
theorem roots_prod {ΞΉ : Type*} (f : ΞΉ β R[X]) (s : Finset ΞΉ) :
s.prod f β 0 β (s.prod f).roots = s.val.bind fun i => roots (f i) := by
rcases s with β¨m, hmβ©
simpa [Multiset.prod_eq_zero_iff, Multiset.bind_map] using roots_multiset_prod (m.map f)
@[simp]
theorem roots_pow (p : R[X]) (n : β) : (p ^ n).roots = n β’ p.roots := by
induction n with
| zero => rw [pow_zero, roots_one, zero_smul, empty_eq_zero]
| succ n ihn =>
rcases eq_or_ne p 0 with (rfl | hp)
Β· rw [zero_pow n.succ_ne_zero, roots_zero, smul_zero]
Β· rw [pow_succ, roots_mul (mul_ne_zero (pow_ne_zero _ hp) hp), ihn, add_smul, one_smul]
theorem roots_X_pow (n : β) : (X ^ n : R[X]).roots = n β’ ({0} : Multiset R) := by
rw [roots_pow, roots_X]
theorem roots_C_mul_X_pow (ha : a β 0) (n : β) :
Polynomial.roots (C a * X ^ n) = n β’ ({0} : Multiset R) := by
rw [roots_C_mul _ ha, roots_X_pow]
@[simp]
theorem roots_monomial (ha : a β 0) (n : β) : (monomial n a).roots = n β’ ({0} : Multiset R) := by
rw [β C_mul_X_pow_eq_monomial, roots_C_mul_X_pow ha]
theorem roots_prod_X_sub_C (s : Finset R) : (s.prod fun a => X - C a).roots = s.val := by
apply (roots_prod (fun a => X - C a) s ?_).trans
Β· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
Β· refine prod_ne_zero_iff.mpr (fun a _ => X_sub_C_ne_zero a)
@[simp]
theorem roots_multiset_prod_X_sub_C (s : Multiset R) : (s.map fun a => X - C a).prod.roots = s := by
rw [roots_multiset_prod, Multiset.bind_map]
Β· simp_rw [roots_X_sub_C]
rw [Multiset.bind_singleton, Multiset.map_id']
Β· rw [Multiset.mem_map]
rintro β¨a, -, hβ©
exact X_sub_C_ne_zero a h
theorem card_roots_X_pow_sub_C {n : β} (hn : 0 < n) (a : R) :
Multiset.card (roots ((X : R[X]) ^ n - C a)) β€ n :=
WithBot.coe_le_coe.1 <|
calc
(Multiset.card (roots ((X : R[X]) ^ n - C a)) : WithBot β) β€ degree ((X : R[X]) ^ n - C a) :=
card_roots (X_pow_sub_C_ne_zero hn a)
_ = n := degree_X_pow_sub_C hn a
section NthRoots
/-- `nthRoots n a` noncomputably returns the solutions to `x ^ n = a`. -/
def nthRoots (n : β) (a : R) : Multiset R :=
roots ((X : R[X]) ^ n - C a)
@[simp]
theorem mem_nthRoots {n : β} (hn : 0 < n) {a x : R} : x β nthRoots n a β x ^ n = a := by
rw [nthRoots, mem_roots (X_pow_sub_C_ne_zero hn a), IsRoot.def, eval_sub, eval_C, eval_pow,
eval_X, sub_eq_zero]
@[simp]
theorem nthRoots_zero (r : R) : nthRoots 0 r = 0 := by
simp only [empty_eq_zero, pow_zero, nthRoots, β C_1, β C_sub, roots_C]
@[simp]
theorem nthRoots_zero_right {R} [CommRing R] [IsDomain R] (n : β) :
nthRoots n (0 : R) = Multiset.replicate n 0 := by
rw [nthRoots, C.map_zero, sub_zero, roots_pow, roots_X, Multiset.nsmul_singleton]
theorem card_nthRoots (n : β) (a : R) : Multiset.card (nthRoots n a) β€ n := by
classical exact
(if hn : n = 0 then
if h : (X : R[X]) ^ n - C a = 0 then by
simp [Nat.zero_le, nthRoots, roots, h, dif_pos rfl, empty_eq_zero, Multiset.card_zero]
else
WithBot.coe_le_coe.1
(le_trans (card_roots h)
(by
rw [hn, pow_zero, β C_1, β RingHom.map_sub]
exact degree_C_le))
else by
rw [β Nat.cast_le (Ξ± := WithBot β)]
rw [β degree_X_pow_sub_C (Nat.pos_of_ne_zero hn) a]
exact card_roots (X_pow_sub_C_ne_zero (Nat.pos_of_ne_zero hn) a))
@[simp]
theorem nthRoots_two_eq_zero_iff {r : R} : nthRoots 2 r = 0 β Β¬IsSquare r := by
simp_rw [isSquare_iff_exists_sq, eq_zero_iff_forall_not_mem, mem_nthRoots (by norm_num : 0 < 2),
β not_exists, eq_comm]
/-- The multiset `nthRoots βn a` as a Finset. Previously `nthRootsFinset n` was defined to be
`nthRoots n (1 : R)` as a Finset. That situation can be recovered by setting `a` to be `(1 : R)` -/
def nthRootsFinset (n : β) {R : Type*} (a : R) [CommRing R] [IsDomain R] : Finset R :=
haveI := Classical.decEq R
Multiset.toFinset (nthRoots n a)
lemma nthRootsFinset_def (n : β) {R : Type*} (a : R) [CommRing R] [IsDomain R] [DecidableEq R] :
nthRootsFinset n a = Multiset.toFinset (nthRoots n a) := by
unfold nthRootsFinset
convert rfl
@[simp]
theorem mem_nthRootsFinset {n : β} (h : 0 < n) (a : R) {x : R} :
x β nthRootsFinset n a β x ^ (n : β) = a := by
classical
rw [nthRootsFinset_def, mem_toFinset, mem_nthRoots h]
@[simp]
theorem nthRootsFinset_zero (a : R) : nthRootsFinset 0 a = β
:= by
classical simp [nthRootsFinset_def]
theorem map_mem_nthRootsFinset {S F : Type*} [CommRing S] [IsDomain S] [FunLike F R S]
[MonoidHomClass F R S] {a : R} {x : R} (hx : x β nthRootsFinset n a) (f : F) :
f x β nthRootsFinset n (f a) := by
by_cases hn : n = 0
Β· simp [hn] at hx
Β· rw [mem_nthRootsFinset <| Nat.pos_of_ne_zero hn, β map_pow, (mem_nthRootsFinset
(Nat.pos_of_ne_zero hn) a).1 hx]
theorem map_mem_nthRootsFinset_one {S F : Type*} [CommRing S] [IsDomain S] [FunLike F R S]
[RingHomClass F R S] {x : R} (hx : x β nthRootsFinset n 1) (f : F) :
f x β nthRootsFinset n 1 := by
rw [β (map_one f)]
exact map_mem_nthRootsFinset hx _
theorem mul_mem_nthRootsFinset
{Ξ·β Ξ·β : R} {aβ aβ : R} (hΞ·β : Ξ·β β nthRootsFinset n aβ) (hΞ·β : Ξ·β β nthRootsFinset n aβ) :
Ξ·β * Ξ·β β nthRootsFinset n (aβ * aβ) := by
cases n with
| zero =>
simp only [nthRootsFinset_zero, not_mem_empty] at hΞ·β
| succ n =>
rw [mem_nthRootsFinset n.succ_pos] at hΞ·β hΞ·β β’
rw [mul_pow, hΞ·β, hΞ·β]
theorem ne_zero_of_mem_nthRootsFinset {Ξ· : R} {a : R} (ha : a β 0) (hΞ· : Ξ· β nthRootsFinset n a) :
Ξ· β 0 := by
nontriviality R
rintro rfl
cases n with
| zero =>
simp only [nthRootsFinset_zero, not_mem_empty] at hΞ·
| succ n =>
rw [mem_nthRootsFinset n.succ_pos, zero_pow n.succ_ne_zero] at hΞ·
exact ha hΞ·.symm
theorem one_mem_nthRootsFinset (hn : 0 < n) : 1 β nthRootsFinset n (1 : R) := by
rw [mem_nthRootsFinset hn, one_pow]
end NthRoots
theorem zero_of_eval_zero [Infinite R] (p : R[X]) (h : β x, p.eval x = 0) : p = 0 := by
classical
by_contra hp
refine @Fintype.false R _ ?_
exact β¨p.roots.toFinset, fun x => Multiset.mem_toFinset.mpr ((mem_roots hp).mpr (h _))β©
theorem funext [Infinite R] {p q : R[X]} (ext : β r : R, p.eval r = q.eval r) : p = q := by
rw [β sub_eq_zero]
apply zero_of_eval_zero
intro x
rw [eval_sub, sub_eq_zero, ext]
variable [CommRing T]
/-- Given a polynomial `p` with coefficients in a ring `T` and a `T`-algebra `S`, `aroots p S` is
the multiset of roots of `p` regarded as a polynomial over `S`. -/
noncomputable abbrev aroots (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] : Multiset S :=
(p.map (algebraMap T S)).roots
theorem aroots_def (p : T[X]) (S) [CommRing S] [IsDomain S] [Algebra T S] :
p.aroots S = (p.map (algebraMap T S)).roots :=
rfl
theorem mem_aroots' [CommRing S] [IsDomain S] [Algebra T S] {p : T[X]} {a : S} :
a β p.aroots S β p.map (algebraMap T S) β 0 β§ aeval a p = 0 := by
rw [mem_roots', IsRoot.def, β evalβ_eq_eval_map, aeval_def]
theorem mem_aroots [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {p : T[X]} {a : S} : a β p.aroots S β p β 0 β§ aeval a p = 0 := by
rw [mem_aroots', Polynomial.map_ne_zero_iff]
exact FaithfulSMul.algebraMap_injective T S
theorem aroots_mul [CommRing S] [IsDomain S] [Algebra T S]
[NoZeroSMulDivisors T S] {p q : T[X]} (hpq : p * q β 0) :
(p * q).aroots S = p.aroots S + q.aroots S := by
suffices map (algebraMap T S) p * map (algebraMap T S) q β 0 by
rw [aroots_def, Polynomial.map_mul, roots_mul this]
rwa [β Polynomial.map_mul, Polynomial.map_ne_zero_iff
(FaithfulSMul.algebraMap_injective T S)]
@[simp]
theorem aroots_X_sub_C [CommRing S] [IsDomain S] [Algebra T S]
(r : T) : aroots (X - C r) S = {algebraMap T S r} := by
rw [aroots_def, Polynomial.map_sub, map_X, map_C, roots_X_sub_C]
@[simp]
theorem aroots_X [CommRing S] [IsDomain S] [Algebra T S] :
aroots (X : T[X]) S = {0} := by
rw [aroots_def, map_X, roots_X]
@[simp]
theorem aroots_C [CommRing S] [IsDomain S] [Algebra T S] (a : T) : (C a).aroots S = 0 := by
rw [aroots_def, map_C, roots_C]
@[simp]
| Mathlib/Algebra/Polynomial/Roots.lean | 428 | 434 | theorem aroots_zero (S) [CommRing S] [IsDomain S] [Algebra T S] : (0 : T[X]).aroots S = 0 := by | rw [β C_0, aroots_C]
@[simp]
theorem aroots_one [CommRing S] [IsDomain S] [Algebra T S] :
(1 : T[X]).aroots S = 0 :=
aroots_C 1 |
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, YaΓ«l Dillies
-/
import Mathlib.Order.Cover
import Mathlib.Order.Interval.Finset.Defs
/-!
# Intervals as finsets
This file provides basic results about all the `Finset.Ixx`, which are defined in
`Order.Interval.Finset.Defs`.
In addition, it shows that in a locally finite order `β€` and `<` are the transitive closures of,
respectively, `β©Ώ` and `β`, which then leads to a characterization of monotone and strictly
functions whose domain is a locally finite order. In particular, this file proves:
* `le_iff_transGen_wcovBy`: `β€` is the transitive closure of `β©Ώ`
* `lt_iff_transGen_covBy`: `<` is the transitive closure of `β`
* `monotone_iff_forall_wcovBy`: Characterization of monotone functions
* `strictMono_iff_forall_covBy`: Characterization of strictly monotone functions
## TODO
This file was originally only about `Finset.Ico a b` where `a b : β`. No care has yet been taken to
generalize these lemmas properly and many lemmas about `Icc`, `Ioc`, `Ioo` are missing. In general,
what's to do is taking the lemmas in `Data.X.Intervals` and abstract away the concrete structure.
Complete the API. See
https://github.com/leanprover-community/mathlib/pull/14448#discussion_r906109235
for some ideas.
-/
assert_not_exists MonoidWithZero Finset.sum
open Function OrderDual
open FinsetInterval
variable {ΞΉ Ξ± : Type*} {a aβ aβ b bβ bβ c x : Ξ±}
namespace Finset
section Preorder
variable [Preorder Ξ±]
section LocallyFiniteOrder
variable [LocallyFiniteOrder Ξ±]
@[simp]
theorem nonempty_Icc : (Icc a b).Nonempty β a β€ b := by
rw [β coe_nonempty, coe_Icc, Set.nonempty_Icc]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias β¨_, Aesop.nonempty_Icc_of_leβ© := nonempty_Icc
@[simp]
theorem nonempty_Ico : (Ico a b).Nonempty β a < b := by
rw [β coe_nonempty, coe_Ico, Set.nonempty_Ico]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias β¨_, Aesop.nonempty_Ico_of_ltβ© := nonempty_Ico
@[simp]
theorem nonempty_Ioc : (Ioc a b).Nonempty β a < b := by
rw [β coe_nonempty, coe_Ioc, Set.nonempty_Ioc]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias β¨_, Aesop.nonempty_Ioc_of_ltβ© := nonempty_Ioc
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem nonempty_Ioo [DenselyOrdered Ξ±] : (Ioo a b).Nonempty β a < b := by
rw [β coe_nonempty, coe_Ioo, Set.nonempty_Ioo]
@[simp]
theorem Icc_eq_empty_iff : Icc a b = β
β Β¬a β€ b := by
rw [β coe_eq_empty, coe_Icc, Set.Icc_eq_empty_iff]
@[simp]
theorem Ico_eq_empty_iff : Ico a b = β
β Β¬a < b := by
rw [β coe_eq_empty, coe_Ico, Set.Ico_eq_empty_iff]
@[simp]
theorem Ioc_eq_empty_iff : Ioc a b = β
β Β¬a < b := by
rw [β coe_eq_empty, coe_Ioc, Set.Ioc_eq_empty_iff]
-- TODO: This is nonsense. A locally finite order is never densely ordered
@[simp]
theorem Ioo_eq_empty_iff [DenselyOrdered Ξ±] : Ioo a b = β
β Β¬a < b := by
rw [β coe_eq_empty, coe_Ioo, Set.Ioo_eq_empty_iff]
alias β¨_, Icc_eq_emptyβ© := Icc_eq_empty_iff
alias β¨_, Ico_eq_emptyβ© := Ico_eq_empty_iff
alias β¨_, Ioc_eq_emptyβ© := Ioc_eq_empty_iff
@[simp]
theorem Ioo_eq_empty (h : Β¬a < b) : Ioo a b = β
:=
eq_empty_iff_forall_not_mem.2 fun _ hx => h ((mem_Ioo.1 hx).1.trans (mem_Ioo.1 hx).2)
@[simp]
theorem Icc_eq_empty_of_lt (h : b < a) : Icc a b = β
:=
Icc_eq_empty h.not_le
@[simp]
theorem Ico_eq_empty_of_le (h : b β€ a) : Ico a b = β
:=
Ico_eq_empty h.not_lt
@[simp]
theorem Ioc_eq_empty_of_le (h : b β€ a) : Ioc a b = β
:=
Ioc_eq_empty h.not_lt
@[simp]
theorem Ioo_eq_empty_of_le (h : b β€ a) : Ioo a b = β
:=
Ioo_eq_empty h.not_lt
theorem left_mem_Icc : a β Icc a b β a β€ b := by simp only [mem_Icc, true_and, le_rfl]
theorem left_mem_Ico : a β Ico a b β a < b := by simp only [mem_Ico, true_and, le_refl]
theorem right_mem_Icc : b β Icc a b β a β€ b := by simp only [mem_Icc, and_true, le_rfl]
theorem right_mem_Ioc : b β Ioc a b β a < b := by simp only [mem_Ioc, and_true, le_rfl]
theorem left_not_mem_Ioc : a β Ioc a b := fun h => lt_irrefl _ (mem_Ioc.1 h).1
theorem left_not_mem_Ioo : a β Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).1
theorem right_not_mem_Ico : b β Ico a b := fun h => lt_irrefl _ (mem_Ico.1 h).2
theorem right_not_mem_Ioo : b β Ioo a b := fun h => lt_irrefl _ (mem_Ioo.1 h).2
@[gcongr]
theorem Icc_subset_Icc (ha : aβ β€ aβ) (hb : bβ β€ bβ) : Icc aβ bβ β Icc aβ bβ := by
simpa [β coe_subset] using Set.Icc_subset_Icc ha hb
@[gcongr]
theorem Ico_subset_Ico (ha : aβ β€ aβ) (hb : bβ β€ bβ) : Ico aβ bβ β Ico aβ bβ := by
simpa [β coe_subset] using Set.Ico_subset_Ico ha hb
@[gcongr]
theorem Ioc_subset_Ioc (ha : aβ β€ aβ) (hb : bβ β€ bβ) : Ioc aβ bβ β Ioc aβ bβ := by
simpa [β coe_subset] using Set.Ioc_subset_Ioc ha hb
@[gcongr]
theorem Ioo_subset_Ioo (ha : aβ β€ aβ) (hb : bβ β€ bβ) : Ioo aβ bβ β Ioo aβ bβ := by
simpa [β coe_subset] using Set.Ioo_subset_Ioo ha hb
@[gcongr]
theorem Icc_subset_Icc_left (h : aβ β€ aβ) : Icc aβ b β Icc aβ b :=
Icc_subset_Icc h le_rfl
@[gcongr]
theorem Ico_subset_Ico_left (h : aβ β€ aβ) : Ico aβ b β Ico aβ b :=
Ico_subset_Ico h le_rfl
@[gcongr]
theorem Ioc_subset_Ioc_left (h : aβ β€ aβ) : Ioc aβ b β Ioc aβ b :=
Ioc_subset_Ioc h le_rfl
@[gcongr]
theorem Ioo_subset_Ioo_left (h : aβ β€ aβ) : Ioo aβ b β Ioo aβ b :=
Ioo_subset_Ioo h le_rfl
@[gcongr]
theorem Icc_subset_Icc_right (h : bβ β€ bβ) : Icc a bβ β Icc a bβ :=
Icc_subset_Icc le_rfl h
@[gcongr]
theorem Ico_subset_Ico_right (h : bβ β€ bβ) : Ico a bβ β Ico a bβ :=
Ico_subset_Ico le_rfl h
@[gcongr]
theorem Ioc_subset_Ioc_right (h : bβ β€ bβ) : Ioc a bβ β Ioc a bβ :=
Ioc_subset_Ioc le_rfl h
@[gcongr]
theorem Ioo_subset_Ioo_right (h : bβ β€ bβ) : Ioo a bβ β Ioo a bβ :=
Ioo_subset_Ioo le_rfl h
theorem Ico_subset_Ioo_left (h : aβ < aβ) : Ico aβ b β Ioo aβ b := by
rw [β coe_subset, coe_Ico, coe_Ioo]
exact Set.Ico_subset_Ioo_left h
theorem Ioc_subset_Ioo_right (h : bβ < bβ) : Ioc a bβ β Ioo a bβ := by
rw [β coe_subset, coe_Ioc, coe_Ioo]
exact Set.Ioc_subset_Ioo_right h
theorem Icc_subset_Ico_right (h : bβ < bβ) : Icc a bβ β Ico a bβ := by
rw [β coe_subset, coe_Icc, coe_Ico]
exact Set.Icc_subset_Ico_right h
theorem Ioo_subset_Ico_self : Ioo a b β Ico a b := by
rw [β coe_subset, coe_Ioo, coe_Ico]
exact Set.Ioo_subset_Ico_self
theorem Ioo_subset_Ioc_self : Ioo a b β Ioc a b := by
rw [β coe_subset, coe_Ioo, coe_Ioc]
exact Set.Ioo_subset_Ioc_self
theorem Ico_subset_Icc_self : Ico a b β Icc a b := by
rw [β coe_subset, coe_Ico, coe_Icc]
exact Set.Ico_subset_Icc_self
theorem Ioc_subset_Icc_self : Ioc a b β Icc a b := by
rw [β coe_subset, coe_Ioc, coe_Icc]
exact Set.Ioc_subset_Icc_self
theorem Ioo_subset_Icc_self : Ioo a b β Icc a b :=
Ioo_subset_Ico_self.trans Ico_subset_Icc_self
theorem Icc_subset_Icc_iff (hβ : aβ β€ bβ) : Icc aβ bβ β Icc aβ bβ β aβ β€ aβ β§ bβ β€ bβ := by
rw [β coe_subset, coe_Icc, coe_Icc, Set.Icc_subset_Icc_iff hβ]
theorem Icc_subset_Ioo_iff (hβ : aβ β€ bβ) : Icc aβ bβ β Ioo aβ bβ β aβ < aβ β§ bβ < bβ := by
rw [β coe_subset, coe_Icc, coe_Ioo, Set.Icc_subset_Ioo_iff hβ]
theorem Icc_subset_Ico_iff (hβ : aβ β€ bβ) : Icc aβ bβ β Ico aβ bβ β aβ β€ aβ β§ bβ < bβ := by
rw [β coe_subset, coe_Icc, coe_Ico, Set.Icc_subset_Ico_iff hβ]
theorem Icc_subset_Ioc_iff (hβ : aβ β€ bβ) : Icc aβ bβ β Ioc aβ bβ β aβ < aβ β§ bβ β€ bβ :=
(Icc_subset_Ico_iff hβ.dual).trans and_comm
--TODO: `Ico_subset_Ioo_iff`, `Ioc_subset_Ioo_iff`
theorem Icc_ssubset_Icc_left (hI : aβ β€ bβ) (ha : aβ < aβ) (hb : bβ β€ bβ) :
Icc aβ bβ β Icc aβ bβ := by
rw [β coe_ssubset, coe_Icc, coe_Icc]
exact Set.Icc_ssubset_Icc_left hI ha hb
theorem Icc_ssubset_Icc_right (hI : aβ β€ bβ) (ha : aβ β€ aβ) (hb : bβ < bβ) :
Icc aβ bβ β Icc aβ bβ := by
rw [β coe_ssubset, coe_Icc, coe_Icc]
exact Set.Icc_ssubset_Icc_right hI ha hb
@[simp]
theorem Ioc_disjoint_Ioc_of_le {d : Ξ±} (hbc : b β€ c) : Disjoint (Ioc a b) (Ioc c d) :=
disjoint_left.2 fun _ h1 h2 β¦ not_and_of_not_left _
((mem_Ioc.1 h1).2.trans hbc).not_lt (mem_Ioc.1 h2)
variable (a)
theorem Ico_self : Ico a a = β
:=
Ico_eq_empty <| lt_irrefl _
theorem Ioc_self : Ioc a a = β
:=
Ioc_eq_empty <| lt_irrefl _
theorem Ioo_self : Ioo a a = β
:=
Ioo_eq_empty <| lt_irrefl _
variable {a}
/-- A set with upper and lower bounds in a locally finite order is a fintype -/
def _root_.Set.fintypeOfMemBounds {s : Set Ξ±} [DecidablePred (Β· β s)] (ha : a β lowerBounds s)
(hb : b β upperBounds s) : Fintype s :=
Set.fintypeSubset (Set.Icc a b) fun _ hx => β¨ha hx, hb hxβ©
section Filter
theorem Ico_filter_lt_of_le_left [DecidablePred (Β· < c)] (hca : c β€ a) :
{x β Ico a b | x < c} = β
:=
filter_false_of_mem fun _ hx => (hca.trans (mem_Ico.1 hx).1).not_lt
theorem Ico_filter_lt_of_right_le [DecidablePred (Β· < c)] (hbc : b β€ c) :
{x β Ico a b | x < c} = Ico a b :=
filter_true_of_mem fun _ hx => (mem_Ico.1 hx).2.trans_le hbc
theorem Ico_filter_lt_of_le_right [DecidablePred (Β· < c)] (hcb : c β€ b) :
{x β Ico a b | x < c} = Ico a c := by
ext x
rw [mem_filter, mem_Ico, mem_Ico, and_right_comm]
exact and_iff_left_of_imp fun h => h.2.trans_le hcb
theorem Ico_filter_le_of_le_left {a b c : Ξ±} [DecidablePred (c β€ Β·)] (hca : c β€ a) :
{x β Ico a b | c β€ x} = Ico a b :=
filter_true_of_mem fun _ hx => hca.trans (mem_Ico.1 hx).1
theorem Ico_filter_le_of_right_le {a b : Ξ±} [DecidablePred (b β€ Β·)] :
{x β Ico a b | b β€ x} = β
:=
filter_false_of_mem fun _ hx => (mem_Ico.1 hx).2.not_le
theorem Ico_filter_le_of_left_le {a b c : Ξ±} [DecidablePred (c β€ Β·)] (hac : a β€ c) :
{x β Ico a b | c β€ x} = Ico c b := by
ext x
rw [mem_filter, mem_Ico, mem_Ico, and_comm, and_left_comm]
exact and_iff_right_of_imp fun h => hac.trans h.1
theorem Icc_filter_lt_of_lt_right {a b c : Ξ±} [DecidablePred (Β· < c)] (h : b < c) :
{x β Icc a b | x < c} = Icc a b :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Icc.1 hx).2 h
theorem Ioc_filter_lt_of_lt_right {a b c : Ξ±} [DecidablePred (Β· < c)] (h : b < c) :
{x β Ioc a b | x < c} = Ioc a b :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Ioc.1 hx).2 h
theorem Iic_filter_lt_of_lt_right {Ξ±} [Preorder Ξ±] [LocallyFiniteOrderBot Ξ±] {a c : Ξ±}
[DecidablePred (Β· < c)] (h : a < c) : {x β Iic a | x < c} = Iic a :=
filter_true_of_mem fun _ hx => lt_of_le_of_lt (mem_Iic.1 hx) h
variable (a b) [Fintype Ξ±]
theorem filter_lt_lt_eq_Ioo [DecidablePred fun j => a < j β§ j < b] :
({j | a < j β§ j < b} : Finset _) = Ioo a b := by ext; simp
theorem filter_lt_le_eq_Ioc [DecidablePred fun j => a < j β§ j β€ b] :
({j | a < j β§ j β€ b} : Finset _) = Ioc a b := by ext; simp
theorem filter_le_lt_eq_Ico [DecidablePred fun j => a β€ j β§ j < b] :
({j | a β€ j β§ j < b} : Finset _) = Ico a b := by ext; simp
theorem filter_le_le_eq_Icc [DecidablePred fun j => a β€ j β§ j β€ b] :
({j | a β€ j β§ j β€ b} : Finset _) = Icc a b := by ext; simp
end Filter
end LocallyFiniteOrder
section LocallyFiniteOrderTop
variable [LocallyFiniteOrderTop Ξ±]
@[simp]
theorem Ioi_eq_empty : Ioi a = β
β IsMax a := by
rw [β coe_eq_empty, coe_Ioi, Set.Ioi_eq_empty_iff]
@[simp] alias β¨_, _root_.IsMax.finsetIoi_eqβ© := Ioi_eq_empty
@[simp] lemma Ioi_nonempty : (Ioi a).Nonempty β Β¬ IsMax a := by simp [nonempty_iff_ne_empty]
theorem Ioi_top [OrderTop Ξ±] : Ioi (β€ : Ξ±) = β
:= Ioi_eq_empty.mpr isMax_top
@[simp]
theorem Ici_bot [OrderBot Ξ±] [Fintype Ξ±] : Ici (β₯ : Ξ±) = univ := by
ext a; simp only [mem_Ici, bot_le, mem_univ]
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma nonempty_Ici : (Ici a).Nonempty := β¨a, mem_Ici.2 le_rflβ©
lemma nonempty_Ioi : (Ioi a).Nonempty β Β¬ IsMax a := by simp [Finset.Nonempty]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias β¨_, Aesop.nonempty_Ioi_of_not_isMaxβ© := nonempty_Ioi
@[simp]
theorem Ici_subset_Ici : Ici a β Ici b β b β€ a := by
simp [β coe_subset]
@[gcongr]
alias β¨_, _root_.GCongr.Finset.Ici_subset_Iciβ© := Ici_subset_Ici
@[simp]
theorem Ici_ssubset_Ici : Ici a β Ici b β b < a := by
simp [β coe_ssubset]
@[gcongr]
alias β¨_, _root_.GCongr.Finset.Ici_ssubset_Iciβ© := Ici_ssubset_Ici
@[gcongr]
theorem Ioi_subset_Ioi (h : a β€ b) : Ioi b β Ioi a := by
simpa [β coe_subset] using Set.Ioi_subset_Ioi h
@[gcongr]
theorem Ioi_ssubset_Ioi (h : a < b) : Ioi b β Ioi a := by
simpa [β coe_ssubset] using Set.Ioi_ssubset_Ioi h
variable [LocallyFiniteOrder Ξ±]
theorem Icc_subset_Ici_self : Icc a b β Ici a := by
simpa [β coe_subset] using Set.Icc_subset_Ici_self
theorem Ico_subset_Ici_self : Ico a b β Ici a := by
simpa [β coe_subset] using Set.Ico_subset_Ici_self
theorem Ioc_subset_Ioi_self : Ioc a b β Ioi a := by
simpa [β coe_subset] using Set.Ioc_subset_Ioi_self
theorem Ioo_subset_Ioi_self : Ioo a b β Ioi a := by
simpa [β coe_subset] using Set.Ioo_subset_Ioi_self
theorem Ioc_subset_Ici_self : Ioc a b β Ici a :=
Ioc_subset_Icc_self.trans Icc_subset_Ici_self
theorem Ioo_subset_Ici_self : Ioo a b β Ici a :=
Ioo_subset_Ico_self.trans Ico_subset_Ici_self
end LocallyFiniteOrderTop
section LocallyFiniteOrderBot
variable [LocallyFiniteOrderBot Ξ±]
@[simp]
theorem Iio_eq_empty : Iio a = β
β IsMin a := Ioi_eq_empty (Ξ± := Ξ±α΅α΅)
@[simp] alias β¨_, _root_.IsMin.finsetIio_eqβ© := Iio_eq_empty
@[simp] lemma Iio_nonempty : (Iio a).Nonempty β Β¬ IsMin a := by simp [nonempty_iff_ne_empty]
theorem Iio_bot [OrderBot Ξ±] : Iio (β₯ : Ξ±) = β
:= Iio_eq_empty.mpr isMin_bot
@[simp]
theorem Iic_top [OrderTop Ξ±] [Fintype Ξ±] : Iic (β€ : Ξ±) = univ := by
ext a; simp only [mem_Iic, le_top, mem_univ]
@[simp, aesop safe apply (rule_sets := [finsetNonempty])]
lemma nonempty_Iic : (Iic a).Nonempty := β¨a, mem_Iic.2 le_rflβ©
lemma nonempty_Iio : (Iio a).Nonempty β Β¬ IsMin a := by simp [Finset.Nonempty]
@[aesop safe apply (rule_sets := [finsetNonempty])]
alias β¨_, Aesop.nonempty_Iio_of_not_isMinβ© := nonempty_Iio
@[simp]
theorem Iic_subset_Iic : Iic a β Iic b β a β€ b := by
simp [β coe_subset]
@[gcongr]
alias β¨_, _root_.GCongr.Finset.Iic_subset_Iicβ© := Iic_subset_Iic
@[simp]
theorem Iic_ssubset_Iic : Iic a β Iic b β a < b := by
simp [β coe_ssubset]
@[gcongr]
alias β¨_, _root_.GCongr.Finset.Iic_ssubset_Iicβ© := Iic_ssubset_Iic
@[gcongr]
theorem Iio_subset_Iio (h : a β€ b) : Iio a β Iio b := by
simpa [β coe_subset] using Set.Iio_subset_Iio h
@[gcongr]
theorem Iio_ssubset_Iio (h : a < b) : Iio a β Iio b := by
simpa [β coe_ssubset] using Set.Iio_ssubset_Iio h
variable [LocallyFiniteOrder Ξ±]
theorem Icc_subset_Iic_self : Icc a b β Iic b := by
simpa [β coe_subset] using Set.Icc_subset_Iic_self
theorem Ioc_subset_Iic_self : Ioc a b β Iic b := by
simpa [β coe_subset] using Set.Ioc_subset_Iic_self
theorem Ico_subset_Iio_self : Ico a b β Iio b := by
simpa [β coe_subset] using Set.Ico_subset_Iio_self
theorem Ioo_subset_Iio_self : Ioo a b β Iio b := by
simpa [β coe_subset] using Set.Ioo_subset_Iio_self
theorem Ico_subset_Iic_self : Ico a b β Iic b :=
Ico_subset_Icc_self.trans Icc_subset_Iic_self
theorem Ioo_subset_Iic_self : Ioo a b β Iic b :=
Ioo_subset_Ioc_self.trans Ioc_subset_Iic_self
theorem Iic_disjoint_Ioc (h : a β€ b) : Disjoint (Iic a) (Ioc b c) :=
disjoint_left.2 fun _ hax hbcx β¦ (mem_Iic.1 hax).not_lt <| lt_of_le_of_lt h (mem_Ioc.1 hbcx).1
/-- An equivalence between `Finset.Iic a` and `Set.Iic a`. -/
def _root_.Equiv.IicFinsetSet (a : Ξ±) : Iic a β Set.Iic a where
toFun b := β¨b.1, coe_Iic a βΈ mem_coe.2 b.2β©
invFun b := β¨b.1, by rw [β mem_coe, coe_Iic a]; exact b.2β©
left_inv := fun _ β¦ rfl
right_inv := fun _ β¦ rfl
end LocallyFiniteOrderBot
section LocallyFiniteOrderTop
variable [LocallyFiniteOrderTop Ξ±] {a : Ξ±}
theorem Ioi_subset_Ici_self : Ioi a β Ici a := by
simpa [β coe_subset] using Set.Ioi_subset_Ici_self
theorem _root_.BddBelow.finite {s : Set Ξ±} (hs : BddBelow s) : s.Finite :=
let β¨a, haβ© := hs
(Ici a).finite_toSet.subset fun _ hx => mem_Ici.2 <| ha hx
theorem _root_.Set.Infinite.not_bddBelow {s : Set Ξ±} : s.Infinite β Β¬BddBelow s :=
mt BddBelow.finite
variable [Fintype Ξ±]
theorem filter_lt_eq_Ioi [DecidablePred (a < Β·)] : ({x | a < x} : Finset _) = Ioi a := by ext; simp
theorem filter_le_eq_Ici [DecidablePred (a β€ Β·)] : ({x | a β€ x} : Finset _) = Ici a := by ext; simp
end LocallyFiniteOrderTop
section LocallyFiniteOrderBot
variable [LocallyFiniteOrderBot Ξ±] {a : Ξ±}
theorem Iio_subset_Iic_self : Iio a β Iic a := by
simpa [β coe_subset] using Set.Iio_subset_Iic_self
theorem _root_.BddAbove.finite {s : Set Ξ±} (hs : BddAbove s) : s.Finite :=
hs.dual.finite
theorem _root_.Set.Infinite.not_bddAbove {s : Set Ξ±} : s.Infinite β Β¬BddAbove s :=
mt BddAbove.finite
variable [Fintype Ξ±]
theorem filter_gt_eq_Iio [DecidablePred (Β· < a)] : ({x | x < a} : Finset _) = Iio a := by ext; simp
theorem filter_ge_eq_Iic [DecidablePred (Β· β€ a)] : ({x | x β€ a} : Finset _) = Iic a := by ext; simp
end LocallyFiniteOrderBot
section LocallyFiniteOrder
variable [LocallyFiniteOrder Ξ±]
@[simp]
theorem Icc_bot [OrderBot Ξ±] : Icc (β₯ : Ξ±) a = Iic a := rfl
@[simp]
theorem Icc_top [OrderTop Ξ±] : Icc a (β€ : Ξ±) = Ici a := rfl
@[simp]
theorem Ico_bot [OrderBot Ξ±] : Ico (β₯ : Ξ±) a = Iio a := rfl
@[simp]
theorem Ioc_top [OrderTop Ξ±] : Ioc a (β€ : Ξ±) = Ioi a := rfl
theorem Icc_bot_top [BoundedOrder Ξ±] [Fintype Ξ±] : Icc (β₯ : Ξ±) (β€ : Ξ±) = univ := by
rw [Icc_bot, Iic_top]
end LocallyFiniteOrder
variable [LocallyFiniteOrderTop Ξ±] [LocallyFiniteOrderBot Ξ±]
theorem disjoint_Ioi_Iio (a : Ξ±) : Disjoint (Ioi a) (Iio a) :=
disjoint_left.2 fun _ hab hba => (mem_Ioi.1 hab).not_lt <| mem_Iio.1 hba
end Preorder
section PartialOrder
variable [PartialOrder Ξ±] [LocallyFiniteOrder Ξ±] {a b c : Ξ±}
@[simp]
theorem Icc_self (a : Ξ±) : Icc a a = {a} := by rw [β coe_eq_singleton, coe_Icc, Set.Icc_self]
@[simp]
theorem Icc_eq_singleton_iff : Icc a b = {c} β a = c β§ b = c := by
rw [β coe_eq_singleton, coe_Icc, Set.Icc_eq_singleton_iff]
theorem Ico_disjoint_Ico_consecutive (a b c : Ξ±) : Disjoint (Ico a b) (Ico b c) :=
disjoint_left.2 fun _ hab hbc => (mem_Ico.mp hab).2.not_le (mem_Ico.mp hbc).1
@[simp]
theorem Ici_top [OrderTop Ξ±] : Ici (β€ : Ξ±) = {β€} := Icc_eq_singleton_iff.2 β¨rfl, rflβ©
@[simp]
theorem Iic_bot [OrderBot Ξ±] : Iic (β₯ : Ξ±) = {β₯} := Icc_eq_singleton_iff.2 β¨rfl, rflβ©
section DecidableEq
variable [DecidableEq Ξ±]
@[simp]
theorem Icc_erase_left (a b : Ξ±) : (Icc a b).erase a = Ioc a b := by simp [β coe_inj]
@[simp]
theorem Icc_erase_right (a b : Ξ±) : (Icc a b).erase b = Ico a b := by simp [β coe_inj]
@[simp]
theorem Ico_erase_left (a b : Ξ±) : (Ico a b).erase a = Ioo a b := by simp [β coe_inj]
@[simp]
theorem Ioc_erase_right (a b : Ξ±) : (Ioc a b).erase b = Ioo a b := by simp [β coe_inj]
@[simp]
theorem Icc_diff_both (a b : Ξ±) : Icc a b \ {a, b} = Ioo a b := by simp [β coe_inj]
@[simp]
theorem Ico_insert_right (h : a β€ b) : insert b (Ico a b) = Icc a b := by
rw [β coe_inj, coe_insert, coe_Icc, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ico_union_right h]
@[simp]
theorem Ioc_insert_left (h : a β€ b) : insert a (Ioc a b) = Icc a b := by
rw [β coe_inj, coe_insert, coe_Ioc, coe_Icc, Set.insert_eq, Set.union_comm, Set.Ioc_union_left h]
@[simp]
theorem Ioo_insert_left (h : a < b) : insert a (Ioo a b) = Ico a b := by
rw [β coe_inj, coe_insert, coe_Ioo, coe_Ico, Set.insert_eq, Set.union_comm, Set.Ioo_union_left h]
@[simp]
theorem Ioo_insert_right (h : a < b) : insert b (Ioo a b) = Ioc a b := by
rw [β coe_inj, coe_insert, coe_Ioo, coe_Ioc, Set.insert_eq, Set.union_comm, Set.Ioo_union_right h]
@[simp]
theorem Icc_diff_Ico_self (h : a β€ b) : Icc a b \ Ico a b = {b} := by simp [β coe_inj, h]
@[simp]
theorem Icc_diff_Ioc_self (h : a β€ b) : Icc a b \ Ioc a b = {a} := by simp [β coe_inj, h]
@[simp]
theorem Icc_diff_Ioo_self (h : a β€ b) : Icc a b \ Ioo a b = {a, b} := by simp [β coe_inj, h]
@[simp]
theorem Ico_diff_Ioo_self (h : a < b) : Ico a b \ Ioo a b = {a} := by simp [β coe_inj, h]
@[simp]
theorem Ioc_diff_Ioo_self (h : a < b) : Ioc a b \ Ioo a b = {b} := by simp [β coe_inj, h]
@[simp]
theorem Ico_inter_Ico_consecutive (a b c : Ξ±) : Ico a b β© Ico b c = β
:=
(Ico_disjoint_Ico_consecutive a b c).eq_bot
end DecidableEq
-- Those lemmas are purposefully the other way around
/-- `Finset.cons` version of `Finset.Ico_insert_right`. -/
theorem Icc_eq_cons_Ico (h : a β€ b) : Icc a b = (Ico a b).cons b right_not_mem_Ico := by
classical rw [cons_eq_insert, Ico_insert_right h]
/-- `Finset.cons` version of `Finset.Ioc_insert_left`. -/
theorem Icc_eq_cons_Ioc (h : a β€ b) : Icc a b = (Ioc a b).cons a left_not_mem_Ioc := by
classical rw [cons_eq_insert, Ioc_insert_left h]
/-- `Finset.cons` version of `Finset.Ioo_insert_right`. -/
theorem Ioc_eq_cons_Ioo (h : a < b) : Ioc a b = (Ioo a b).cons b right_not_mem_Ioo := by
classical rw [cons_eq_insert, Ioo_insert_right h]
/-- `Finset.cons` version of `Finset.Ioo_insert_left`. -/
theorem Ico_eq_cons_Ioo (h : a < b) : Ico a b = (Ioo a b).cons a left_not_mem_Ioo := by
classical rw [cons_eq_insert, Ioo_insert_left h]
theorem Ico_filter_le_left {a b : Ξ±} [DecidablePred (Β· β€ a)] (hab : a < b) :
{x β Ico a b | x β€ a} = {a} := by
ext x
rw [mem_filter, mem_Ico, mem_singleton, and_right_comm, β le_antisymm_iff, eq_comm]
exact and_iff_left_of_imp fun h => h.le.trans_lt hab
theorem card_Ico_eq_card_Icc_sub_one (a b : Ξ±) : #(Ico a b) = #(Icc a b) - 1 := by
classical
by_cases h : a β€ b
Β· rw [Icc_eq_cons_Ico h, card_cons]
exact (Nat.add_sub_cancel _ _).symm
Β· rw [Ico_eq_empty fun h' => h h'.le, Icc_eq_empty h, card_empty, Nat.zero_sub]
theorem card_Ioc_eq_card_Icc_sub_one (a b : Ξ±) : #(Ioc a b) = #(Icc a b) - 1 :=
@card_Ico_eq_card_Icc_sub_one Ξ±α΅α΅ _ _ _ _
theorem card_Ioo_eq_card_Ico_sub_one (a b : Ξ±) : #(Ioo a b) = #(Ico a b) - 1 := by
classical
by_cases h : a < b
Β· rw [Ico_eq_cons_Ioo h, card_cons]
exact (Nat.add_sub_cancel _ _).symm
Β· rw [Ioo_eq_empty h, Ico_eq_empty h, card_empty, Nat.zero_sub]
theorem card_Ioo_eq_card_Ioc_sub_one (a b : Ξ±) : #(Ioo a b) = #(Ioc a b) - 1 :=
@card_Ioo_eq_card_Ico_sub_one Ξ±α΅α΅ _ _ _ _
theorem card_Ioo_eq_card_Icc_sub_two (a b : Ξ±) : #(Ioo a b) = #(Icc a b) - 2 := by
rw [card_Ioo_eq_card_Ico_sub_one, card_Ico_eq_card_Icc_sub_one]
rfl
end PartialOrder
section Prod
variable {Ξ² : Type*}
section sectL
lemma uIcc_map_sectL [Lattice Ξ±] [Lattice Ξ²] [LocallyFiniteOrder Ξ±] [LocallyFiniteOrder Ξ²]
[DecidableLE (Ξ± Γ Ξ²)] (a b : Ξ±) (c : Ξ²) :
(uIcc a b).map (.sectL _ c) = uIcc (a, c) (b, c) := by
aesop (add safe forward [le_antisymm])
variable [Preorder Ξ±] [PartialOrder Ξ²] [LocallyFiniteOrder Ξ±] [LocallyFiniteOrder Ξ²]
[DecidableLE (Ξ± Γ Ξ²)] (a b : Ξ±) (c : Ξ²)
lemma Icc_map_sectL : (Icc a b).map (.sectL _ c) = Icc (a, c) (b, c) := by
aesop (add safe forward [le_antisymm])
lemma Ioc_map_sectL : (Ioc a b).map (.sectL _ c) = Ioc (a, c) (b, c) := by
aesop (add safe forward [le_antisymm, le_of_lt])
lemma Ico_map_sectL : (Ico a b).map (.sectL _ c) = Ico (a, c) (b, c) := by
aesop (add safe forward [le_antisymm, le_of_lt])
lemma Ioo_map_sectL : (Ioo a b).map (.sectL _ c) = Ioo (a, c) (b, c) := by
aesop (add safe forward [le_antisymm, le_of_lt])
end sectL
section sectR
lemma uIcc_map_sectR [Lattice Ξ±] [Lattice Ξ²] [LocallyFiniteOrder Ξ±] [LocallyFiniteOrder Ξ²]
[DecidableLE (Ξ± Γ Ξ²)] (c : Ξ±) (a b : Ξ²) :
(uIcc a b).map (.sectR c _) = uIcc (c, a) (c, b) := by
aesop (add safe forward [le_antisymm])
variable [PartialOrder Ξ±] [Preorder Ξ²] [LocallyFiniteOrder Ξ±] [LocallyFiniteOrder Ξ²]
[DecidableLE (Ξ± Γ Ξ²)] (c : Ξ±) (a b : Ξ²)
lemma Icc_map_sectR : (Icc a b).map (.sectR c _) = Icc (c, a) (c, b) := by
aesop (add safe forward [le_antisymm])
lemma Ioc_map_sectR : (Ioc a b).map (.sectR c _) = Ioc (c, a) (c, b) := by
aesop (add safe forward [le_antisymm, le_of_lt])
lemma Ico_map_sectR : (Ico a b).map (.sectR c _) = Ico (c, a) (c, b) := by
aesop (add safe forward [le_antisymm, le_of_lt])
lemma Ioo_map_sectR : (Ioo a b).map (.sectR c _) = Ioo (c, a) (c, b) := by
aesop (add safe forward [le_antisymm, le_of_lt])
end sectR
end Prod
section BoundedPartialOrder
variable [PartialOrder Ξ±]
section OrderTop
variable [LocallyFiniteOrderTop Ξ±]
@[simp]
theorem Ici_erase [DecidableEq Ξ±] (a : Ξ±) : (Ici a).erase a = Ioi a := by
ext
simp_rw [Finset.mem_erase, mem_Ici, mem_Ioi, lt_iff_le_and_ne, and_comm, ne_comm]
@[simp]
theorem Ioi_insert [DecidableEq Ξ±] (a : Ξ±) : insert a (Ioi a) = Ici a := by
ext
simp_rw [Finset.mem_insert, mem_Ici, mem_Ioi, le_iff_lt_or_eq, or_comm, eq_comm]
theorem not_mem_Ioi_self {b : Ξ±} : b β Ioi b := fun h => lt_irrefl _ (mem_Ioi.1 h)
-- Purposefully written the other way around
/-- `Finset.cons` version of `Finset.Ioi_insert`. -/
theorem Ici_eq_cons_Ioi (a : Ξ±) : Ici a = (Ioi a).cons a not_mem_Ioi_self := by
classical rw [cons_eq_insert, Ioi_insert]
theorem card_Ioi_eq_card_Ici_sub_one (a : Ξ±) : #(Ioi a) = #(Ici a) - 1 := by
rw [Ici_eq_cons_Ioi, card_cons, Nat.add_sub_cancel_right]
end OrderTop
section OrderBot
variable [LocallyFiniteOrderBot Ξ±]
@[simp]
theorem Iic_erase [DecidableEq Ξ±] (b : Ξ±) : (Iic b).erase b = Iio b := by
ext
simp_rw [Finset.mem_erase, mem_Iic, mem_Iio, lt_iff_le_and_ne, and_comm]
@[simp]
theorem Iio_insert [DecidableEq Ξ±] (b : Ξ±) : insert b (Iio b) = Iic b := by
ext
simp_rw [Finset.mem_insert, mem_Iic, mem_Iio, le_iff_lt_or_eq, or_comm]
theorem not_mem_Iio_self {b : Ξ±} : b β Iio b := fun h => lt_irrefl _ (mem_Iio.1 h)
-- Purposefully written the other way around
/-- `Finset.cons` version of `Finset.Iio_insert`. -/
theorem Iic_eq_cons_Iio (b : Ξ±) : Iic b = (Iio b).cons b not_mem_Iio_self := by
classical rw [cons_eq_insert, Iio_insert]
theorem card_Iio_eq_card_Iic_sub_one (a : Ξ±) : #(Iio a) = #(Iic a) - 1 := by
rw [Iic_eq_cons_Iio, card_cons, Nat.add_sub_cancel_right]
end OrderBot
end BoundedPartialOrder
section SemilatticeSup
variable [SemilatticeSup Ξ±] [LocallyFiniteOrderBot Ξ±]
-- TODO: Why does `id_eq` simplify the LHS here but not the LHS of `Finset.sup_Iic`?
lemma sup'_Iic (a : Ξ±) : (Iic a).sup' nonempty_Iic id = a :=
le_antisymm (sup'_le _ _ fun _ β¦ mem_Iic.1) <| le_sup' (f := id) <| mem_Iic.2 <| le_refl a
@[simp] lemma sup_Iic [OrderBot Ξ±] (a : Ξ±) : (Iic a).sup id = a :=
le_antisymm (Finset.sup_le fun _ β¦ mem_Iic.1) <| le_sup (f := id) <| mem_Iic.2 <| le_refl a
lemma image_subset_Iic_sup [OrderBot Ξ±] [DecidableEq Ξ±] (f : ΞΉ β Ξ±) (s : Finset ΞΉ) :
s.image f β Iic (s.sup f) := by
refine fun i hi β¦ mem_Iic.2 ?_
obtain β¨j, hj, rflβ© := mem_image.1 hi
exact le_sup hj
lemma subset_Iic_sup_id [OrderBot Ξ±] (s : Finset Ξ±) : s β Iic (s.sup id) :=
fun _ h β¦ mem_Iic.2 <| le_sup (f := id) h
end SemilatticeSup
section SemilatticeInf
variable [SemilatticeInf Ξ±] [LocallyFiniteOrderTop Ξ±]
lemma inf'_Ici (a : Ξ±) : (Ici a).inf' nonempty_Ici id = a :=
ge_antisymm (le_inf' _ _ fun _ β¦ mem_Ici.1) <| inf'_le (f := id) <| mem_Ici.2 <| le_refl a
@[simp] lemma inf_Ici [OrderTop Ξ±] (a : Ξ±) : (Ici a).inf id = a :=
le_antisymm (inf_le (f := id) <| mem_Ici.2 <| le_refl a) <| Finset.le_inf fun _ β¦ mem_Ici.1
end SemilatticeInf
section LinearOrder
variable [LinearOrder Ξ±]
section LocallyFiniteOrder
variable [LocallyFiniteOrder Ξ±]
theorem Ico_subset_Ico_iff {aβ bβ aβ bβ : Ξ±} (h : aβ < bβ) :
Ico aβ bβ β Ico aβ bβ β aβ β€ aβ β§ bβ β€ bβ := by
rw [β coe_subset, coe_Ico, coe_Ico, Set.Ico_subset_Ico_iff h]
theorem Ico_union_Ico_eq_Ico {a b c : Ξ±} (hab : a β€ b) (hbc : b β€ c) :
Ico a b βͺ Ico b c = Ico a c := by
rw [β coe_inj, coe_union, coe_Ico, coe_Ico, coe_Ico, Set.Ico_union_Ico_eq_Ico hab hbc]
@[simp]
theorem Ioc_union_Ioc_eq_Ioc {a b c : Ξ±} (hβ : a β€ b) (hβ : b β€ c) :
Ioc a b βͺ Ioc b c = Ioc a c := by
rw [β coe_inj, coe_union, coe_Ioc, coe_Ioc, coe_Ioc, Set.Ioc_union_Ioc_eq_Ioc hβ hβ]
theorem Ico_subset_Ico_union_Ico {a b c : Ξ±} : Ico a c β Ico a b βͺ Ico b c := by
rw [β coe_subset, coe_union, coe_Ico, coe_Ico, coe_Ico]
exact Set.Ico_subset_Ico_union_Ico
theorem Ico_union_Ico' {a b c d : Ξ±} (hcb : c β€ b) (had : a β€ d) :
Ico a b βͺ Ico c d = Ico (min a c) (max b d) := by
rw [β coe_inj, coe_union, coe_Ico, coe_Ico, coe_Ico, Set.Ico_union_Ico' hcb had]
theorem Ico_union_Ico {a b c d : Ξ±} (hβ : min a b β€ max c d) (hβ : min c d β€ max a b) :
Ico a b βͺ Ico c d = Ico (min a c) (max b d) := by
rw [β coe_inj, coe_union, coe_Ico, coe_Ico, coe_Ico, Set.Ico_union_Ico hβ hβ]
| Mathlib/Order/Interval/Finset/Basic.lean | 842 | 845 | theorem Ico_inter_Ico {a b c d : Ξ±} : Ico a b β© Ico c d = Ico (max a c) (min b d) := by | rw [β coe_inj, coe_inter, coe_Ico, coe_Ico, coe_Ico, Set.Ico_inter_Ico]
theorem Ioc_inter_Ioc {a b c d : Ξ±} : Ioc a b β© Ioc c d = Ioc (max a c) (min b d) := by |
/-
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.Analysis.SpecialFunctions.Trigonometric.Arctan
import Mathlib.Geometry.Euclidean.Angle.Unoriented.Affine
/-!
# Right-angled triangles
This file proves basic geometrical results about distances and angles in (possibly degenerate)
right-angled triangles in real inner product spaces and Euclidean affine spaces.
## Implementation notes
Results in this file are generally given in a form with only those non-degeneracy conditions
needed for the particular result, rather than requiring affine independence of the points of a
triangle unnecessarily.
## References
* https://en.wikipedia.org/wiki/Pythagorean_theorem
-/
noncomputable section
open scoped EuclideanGeometry
open scoped Real
open scoped RealInnerProductSpace
namespace InnerProductGeometry
variable {V : Type*} [NormedAddCommGroup V] [InnerProductSpace β V]
/-- Pythagorean theorem, if-and-only-if vector angle form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
βx + yβ * βx + yβ = βxβ * βxβ + βyβ * βyβ β angle x y = Ο / 2 := by
rw [norm_add_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
/-- Pythagorean theorem, vector angle form. -/
theorem norm_add_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = Ο / 2) :
βx + yβ * βx + yβ = βxβ * βxβ + βyβ * βyβ :=
(norm_add_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
/-- Pythagorean theorem, subtracting vectors, if-and-only-if vector angle form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two (x y : V) :
βx - yβ * βx - yβ = βxβ * βxβ + βyβ * βyβ β angle x y = Ο / 2 := by
rw [norm_sub_sq_eq_norm_sq_add_norm_sq_iff_real_inner_eq_zero]
exact inner_eq_zero_iff_angle_eq_pi_div_two x y
/-- Pythagorean theorem, subtracting vectors, vector angle form. -/
theorem norm_sub_sq_eq_norm_sq_add_norm_sq' (x y : V) (h : angle x y = Ο / 2) :
βx - yβ * βx - yβ = βxβ * βxβ + βyβ * βyβ :=
(norm_sub_sq_eq_norm_sq_add_norm_sq_iff_angle_eq_pi_div_two x y).2 h
/-- An angle in a right-angled triangle expressed using `arccos`. -/
theorem angle_add_eq_arccos_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
angle x (x + y) = Real.arccos (βxβ / βx + yβ) := by
rw [angle, inner_add_right, h, add_zero, real_inner_self_eq_norm_mul_norm]
by_cases hx : βxβ = 0; Β· simp [hx]
rw [div_mul_eq_div_div, mul_self_div_self]
/-- An angle in a right-angled triangle expressed using `arcsin`. -/
theorem angle_add_eq_arcsin_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0 β¨ y β 0) :
angle x (x + y) = Real.arcsin (βyβ / βx + yβ) := by
have hxy : βx + yβ ^ 2 β 0 := by
rw [pow_two, norm_add_sq_eq_norm_sq_add_norm_sq_real h, ne_comm]
refine ne_of_lt ?_
rcases h0 with (h0 | h0)
Β· exact
Left.add_pos_of_pos_of_nonneg (mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)
Β· exact
Left.add_pos_of_nonneg_of_pos (mul_self_nonneg _) (mul_self_pos.2 (norm_ne_zero_iff.2 h0))
rw [angle_add_eq_arccos_of_inner_eq_zero h,
Real.arccos_eq_arcsin (div_nonneg (norm_nonneg _) (norm_nonneg _)), div_pow, one_sub_div hxy]
nth_rw 1 [pow_two]
rw [norm_add_sq_eq_norm_sq_add_norm_sq_real h, pow_two, add_sub_cancel_left, β pow_two, β div_pow,
Real.sqrt_sq (div_nonneg (norm_nonneg _) (norm_nonneg _))]
/-- An angle in a right-angled triangle expressed using `arctan`. -/
theorem angle_add_eq_arctan_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0) :
angle x (x + y) = Real.arctan (βyβ / βxβ) := by
rw [angle_add_eq_arcsin_of_inner_eq_zero h (Or.inl h0), Real.arctan_eq_arcsin, β
div_mul_eq_div_div, norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
nth_rw 3 [β Real.sqrt_sq (norm_nonneg x)]
rw_mod_cast [β Real.sqrt_mul (sq_nonneg _), div_pow, pow_two, pow_two, mul_add, mul_one, mul_div,
mul_comm (βxβ * βxβ), β mul_div, div_self (mul_self_pos.2 (norm_ne_zero_iff.2 h0)).ne', mul_one]
/-- An angle in a non-degenerate right-angled triangle is positive. -/
theorem angle_add_pos_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x = 0 β¨ y β 0) :
0 < angle x (x + y) := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_pos,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
by_cases hx : x = 0; Β· simp [hx]
rw [div_lt_one (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg (mul_self_pos.2
(norm_ne_zero_iff.2 hx)) (mul_self_nonneg _))), Real.lt_sqrt (norm_nonneg _), pow_two]
simpa [hx] using h0
/-- An angle in a right-angled triangle is at most `Ο / 2`. -/
theorem angle_add_le_pi_div_two_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
angle x (x + y) β€ Ο / 2 := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_le_pi_div_two]
exact div_nonneg (norm_nonneg _) (norm_nonneg _)
/-- An angle in a non-degenerate right-angled triangle is less than `Ο / 2`. -/
theorem angle_add_lt_pi_div_two_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0) :
angle x (x + y) < Ο / 2 := by
rw [angle_add_eq_arccos_of_inner_eq_zero h, Real.arccos_lt_pi_div_two,
norm_add_eq_sqrt_iff_real_inner_eq_zero.2 h]
exact div_pos (norm_pos_iff.2 h0) (Real.sqrt_pos.2 (Left.add_pos_of_pos_of_nonneg
(mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)))
/-- The cosine of an angle in a right-angled triangle as a ratio of sides. -/
theorem cos_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
Real.cos (angle x (x + y)) = βxβ / βx + yβ := by
rw [angle_add_eq_arccos_of_inner_eq_zero h,
Real.cos_arccos (le_trans (by norm_num) (div_nonneg (norm_nonneg _) (norm_nonneg _)))
(div_le_one_of_leβ _ (norm_nonneg _))]
rw [mul_self_le_mul_self_iff (norm_nonneg _) (norm_nonneg _),
norm_add_sq_eq_norm_sq_add_norm_sq_real h]
exact le_add_of_nonneg_right (mul_self_nonneg _)
/-- The sine of an angle in a right-angled triangle as a ratio of sides. -/
theorem sin_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0 β¨ y β 0) :
Real.sin (angle x (x + y)) = βyβ / βx + yβ := by
rw [angle_add_eq_arcsin_of_inner_eq_zero h h0,
Real.sin_arcsin (le_trans (by norm_num) (div_nonneg (norm_nonneg _) (norm_nonneg _)))
(div_le_one_of_leβ _ (norm_nonneg _))]
rw [mul_self_le_mul_self_iff (norm_nonneg _) (norm_nonneg _),
norm_add_sq_eq_norm_sq_add_norm_sq_real h]
exact le_add_of_nonneg_left (mul_self_nonneg _)
/-- The tangent of an angle in a right-angled triangle as a ratio of sides. -/
theorem tan_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
Real.tan (angle x (x + y)) = βyβ / βxβ := by
by_cases h0 : x = 0; Β· simp [h0]
rw [angle_add_eq_arctan_of_inner_eq_zero h h0, Real.tan_arctan]
/-- The cosine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
adjacent side. -/
theorem cos_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
Real.cos (angle x (x + y)) * βx + yβ = βxβ := by
rw [cos_angle_add_of_inner_eq_zero h]
by_cases hxy : βx + yβ = 0
Β· have h' := norm_add_sq_eq_norm_sq_add_norm_sq_real h
rw [hxy, zero_mul, eq_comm,
add_eq_zero_iff_of_nonneg (mul_self_nonneg βxβ) (mul_self_nonneg βyβ), mul_self_eq_zero] at h'
simp [h'.1]
Β· exact div_mul_cancelβ _ hxy
/-- The sine of an angle in a right-angled triangle multiplied by the hypotenuse equals the
opposite side. -/
theorem sin_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
Real.sin (angle x (x + y)) * βx + yβ = βyβ := by
by_cases h0 : x = 0 β§ y = 0; Β· simp [h0]
rw [not_and_or] at h0
rw [sin_angle_add_of_inner_eq_zero h h0, div_mul_cancelβ]
rw [β mul_self_ne_zero, norm_add_sq_eq_norm_sq_add_norm_sq_real h]
refine (ne_of_lt ?_).symm
rcases h0 with (h0 | h0)
Β· exact Left.add_pos_of_pos_of_nonneg (mul_self_pos.2 (norm_ne_zero_iff.2 h0)) (mul_self_nonneg _)
Β· exact Left.add_pos_of_nonneg_of_pos (mul_self_nonneg _) (mul_self_pos.2 (norm_ne_zero_iff.2 h0))
/-- The tangent of an angle in a right-angled triangle multiplied by the adjacent side equals
the opposite side. -/
theorem tan_angle_add_mul_norm_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0 β¨ y = 0) :
Real.tan (angle x (x + y)) * βxβ = βyβ := by
rw [tan_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0) <;> simp [h0]
/-- A side of a right-angled triangle divided by the cosine of the adjacent angle equals the
hypotenuse. -/
theorem norm_div_cos_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0 β¨ y = 0) :
βxβ / Real.cos (angle x (x + y)) = βx + yβ := by
rw [cos_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0)
Β· rw [div_div_eq_mul_div, mul_comm, div_eq_mul_inv, mul_inv_cancel_rightβ (norm_ne_zero_iff.2 h0)]
Β· simp [h0]
/-- A side of a right-angled triangle divided by the sine of the opposite angle equals the
hypotenuse. -/
theorem norm_div_sin_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x = 0 β¨ y β 0) :
βyβ / Real.sin (angle x (x + y)) = βx + yβ := by
rcases h0 with (h0 | h0); Β· simp [h0]
rw [sin_angle_add_of_inner_eq_zero h (Or.inr h0), div_div_eq_mul_div, mul_comm, div_eq_mul_inv,
mul_inv_cancel_rightβ (norm_ne_zero_iff.2 h0)]
/-- A side of a right-angled triangle divided by the tangent of the opposite angle equals the
adjacent side. -/
theorem norm_div_tan_angle_add_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x = 0 β¨ y β 0) :
βyβ / Real.tan (angle x (x + y)) = βxβ := by
rw [tan_angle_add_of_inner_eq_zero h]
rcases h0 with (h0 | h0)
Β· simp [h0]
Β· rw [div_div_eq_mul_div, mul_comm, div_eq_mul_inv, mul_inv_cancel_rightβ (norm_ne_zero_iff.2 h0)]
/-- An angle in a right-angled triangle expressed using `arccos`, version subtracting vectors. -/
theorem angle_sub_eq_arccos_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
angle x (x - y) = Real.arccos (βxβ / βx - yβ) := by
rw [β neg_eq_zero, β inner_neg_right] at h
rw [sub_eq_add_neg, angle_add_eq_arccos_of_inner_eq_zero h]
/-- An angle in a right-angled triangle expressed using `arcsin`, version subtracting vectors. -/
theorem angle_sub_eq_arcsin_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0 β¨ y β 0) :
angle x (x - y) = Real.arcsin (βyβ / βx - yβ) := by
rw [β neg_eq_zero, β inner_neg_right] at h
rw [or_comm, β neg_ne_zero, or_comm] at h0
rw [sub_eq_add_neg, angle_add_eq_arcsin_of_inner_eq_zero h h0, norm_neg]
/-- An angle in a right-angled triangle expressed using `arctan`, version subtracting vectors. -/
theorem angle_sub_eq_arctan_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x β 0) :
angle x (x - y) = Real.arctan (βyβ / βxβ) := by
rw [β neg_eq_zero, β inner_neg_right] at h
rw [sub_eq_add_neg, angle_add_eq_arctan_of_inner_eq_zero h h0, norm_neg]
/-- An angle in a non-degenerate right-angled triangle is positive, version subtracting
vectors. -/
theorem angle_sub_pos_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) (h0 : x = 0 β¨ y β 0) :
0 < angle x (x - y) := by
rw [β neg_eq_zero, β inner_neg_right] at h
rw [β neg_ne_zero] at h0
rw [sub_eq_add_neg]
exact angle_add_pos_of_inner_eq_zero h h0
/-- An angle in a right-angled triangle is at most `Ο / 2`, version subtracting vectors. -/
| Mathlib/Geometry/Euclidean/Angle/Unoriented/RightAngle.lean | 232 | 236 | theorem angle_sub_le_pi_div_two_of_inner_eq_zero {x y : V} (h : βͺx, yβ« = 0) :
angle x (x - y) β€ Ο / 2 := by | rw [β neg_eq_zero, β inner_neg_right] at h
rw [sub_eq_add_neg]
exact angle_add_le_pi_div_two_of_inner_eq_zero h |
/-
Copyright (c) 2024 Thomas Browning, Junyan Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Thomas Browning, Junyan Xu
-/
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.FixedPoints
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Data.Set.Finite.Basic
/-!
# Subgroups generated by transpositions
This file studies subgroups generated by transpositions.
## Main results
- `swap_mem_closure_isSwap` : If a subgroup is generated by transpositions, then a transposition
`swap x y` lies in the subgroup if and only if `x` lies in the same orbit as `y`.
- `mem_closure_isSwap` : If a subgroup is generated by transpositions, then a permutation `f`
lies in the subgroup if and only if `f` has finite support and `f x` always lies in the same
orbit as `x`.
-/
open Equiv List MulAction Pointwise Set Subgroup
variable {G Ξ± : Type*} [Group G] [MulAction G Ξ±]
/-- If the support of each element in a generating set of a permutation group is finite,
then the support of every element in the group is finite. -/
theorem finite_compl_fixedBy_closure_iff {S : Set G} :
(β g β closure S, (fixedBy Ξ± g)αΆ.Finite) β β g β S, (fixedBy Ξ± g)αΆ.Finite :=
β¨fun h g hg β¦ h g (subset_closure hg), fun h g hg β¦ by
refine closure_induction h (by simp) (fun g g' _ _ hg hg' β¦ (hg.union hg').subset ?_)
(by simp) hg
simp_rw [β compl_inter, compl_subset_compl, fixedBy_mul]β©
/-- Given a symmetric generating set of a permutation group, if T is a nonempty proper subset of
an orbit, then there exists a generator that sends some element of T into the complement of T. -/
theorem exists_smul_not_mem_of_subset_orbit_closure (S : Set G) (T : Set Ξ±) {a : Ξ±}
(hS : β g β S, gβ»ΒΉ β S) (subset : T β orbit (closure S) a) (not_mem : a β T)
(nonempty : T.Nonempty) : β Ο β S, β a β T, Ο β’ a β T := by
have key0 : Β¬ closure S β€ stabilizer G T := by
have β¨b, hbβ© := nonempty
obtain β¨Ο, rflβ© := subset hb
contrapose! not_mem with h
exact smul_mem_smul_set_iff.mp ((h Ο.2).symm βΈ hb)
contrapose! key0
refine (closure_le _).mpr fun Ο hΟ β¦ ?_
simp_rw [SetLike.mem_coe, mem_stabilizer_iff, Set.ext_iff, mem_smul_set_iff_inv_smul_mem]
exact fun a β¦ β¨fun h β¦ smul_inv_smul Ο a βΈ key0 Ο hΟ (Οβ»ΒΉ β’ a) h, key0 Οβ»ΒΉ (hS Ο hΟ) aβ©
variable [DecidableEq Ξ±]
theorem finite_compl_fixedBy_swap {x y : Ξ±} : (fixedBy Ξ± (swap x y))αΆ.Finite :=
Set.Finite.subset (s := {x, y}) (by simp)
(compl_subset_comm.mp fun z h β¦ by apply swap_apply_of_ne_of_ne <;> rintro rfl <;> simp at h)
theorem Equiv.Perm.IsSwap.finite_compl_fixedBy {Ο : Perm Ξ±} (h : Ο.IsSwap) :
(fixedBy Ξ± Ο)αΆ.Finite := by
obtain β¨x, y, -, rflβ© := h
exact finite_compl_fixedBy_swap
-- this result cannot be moved to Perm/Basic since Perm/Basic is not allowed to import Submonoid
theorem SubmonoidClass.swap_mem_trans {a b c : Ξ±} {C} [SetLike C (Perm Ξ±)]
[SubmonoidClass C (Perm Ξ±)] (M : C) (hab : swap a b β M) (hbc : swap b c β M) :
swap a c β M := by
obtain rfl | hab' := eq_or_ne a b
Β· exact hbc
obtain rfl | hac := eq_or_ne a c
Β· exact swap_self a βΈ one_mem M
rw [swap_comm, β swap_mul_swap_mul_swap hab' hac]
exact mul_mem (mul_mem hbc hab) hbc
/-- If a subgroup is generated by transpositions, then a transposition `swap x y` lies in the
subgroup if and only if `x` lies in the same orbit as `y`. -/
theorem swap_mem_closure_isSwap {S : Set (Perm Ξ±)} (hS : β f β S, f.IsSwap) {x y : Ξ±} :
swap x y β closure S β x β orbit (closure S) y := by
refine β¨fun h β¦ β¨β¨swap x y, hβ©, swap_apply_right x yβ©, fun hf β¦ ?_β©
by_contra h
have := exists_smul_not_mem_of_subset_orbit_closure S {x | swap x y β closure S}
(fun f hf β¦ ?_) (fun z hz β¦ ?_) h β¨y, ?_β©
Β· obtain β¨Ο, hΟ, a, ha, hΟaβ© := this
obtain β¨z, w, hzw, rflβ© := hS Ο hΟ
have := ne_of_mem_of_not_mem ha hΟa
rw [Perm.smul_def, ne_comm, swap_apply_ne_self_iff, and_iff_right hzw] at this
refine hΟa (SubmonoidClass.swap_mem_trans (closure S) ?_ ha)
obtain rfl | rfl := this <;> simpa [swap_comm] using subset_closure hΟ
Β· obtain β¨x, y, -, rflβ© := hS f hf; rwa [swap_inv]
Β· exact orbit_eq_iff.mpr hf βΈ β¨β¨swap z y, hzβ©, swap_apply_right z yβ©
Β· rw [mem_setOf, swap_self]; apply one_mem
/-- If a subgroup is generated by transpositions, then a permutation `f` lies in the subgroup if
and only if `f` has finite support and `f x` always lies in the same orbit as `x`. -/
theorem mem_closure_isSwap {S : Set (Perm Ξ±)} (hS : β f β S, f.IsSwap) {f : Perm Ξ±} :
f β closure S β (fixedBy Ξ± f)αΆ.Finite β§ β x, f x β orbit (closure S) x := by
refine β¨fun hf β¦ β¨?_, fun x β¦ mem_orbit_iff.mpr β¨β¨f, hfβ©, rflβ©β©, ?_β©
Β· exact finite_compl_fixedBy_closure_iff.mpr (fun f hf β¦ (hS f hf).finite_compl_fixedBy) _ hf
rintro β¨fin, hfβ©
set supp := (fixedBy Ξ± f)αΆ with supp_eq
suffices h : (fixedBy Ξ± f)αΆ β supp β f β closure S from h supp_eq.symm.subset
clear_value supp; clear supp_eq; revert f
apply fin.induction_on ..
Β· rintro f - emp; convert (closure S).one_mem; ext; by_contra h; exact emp h
rintro a s - - ih f hf supp_subset
refine (mul_mem_cancel_left ((swap_mem_closure_isSwap hS).2 (hf a))).1
(ih (fun b β¦ ?_) fun b hb β¦ ?_)
Β· rw [Perm.mul_apply, swap_apply_def]; split_ifs with h1 h2
Β· rw [β orbit_eq_iff.mpr (hf b), h1, orbit_eq_iff.mpr (hf a)]; apply mem_orbit_self
Β· rw [β orbit_eq_iff.mpr (hf b), h2]; apply hf
Β· exact hf b
Β· contrapose! hb
simp_rw [not_mem_compl_iff, mem_fixedBy, Perm.smul_def, Perm.mul_apply, swap_apply_def,
apply_eq_iff_eq]
by_cases hb' : f b = b
Β· rw [hb']; split_ifs with h <;> simp only [h]
simp [show b = a by simpa [hb] using supp_subset hb']
/-- A permutation is a product of transpositions if and only if it has finite support. -/
theorem mem_closure_isSwap' {f : Perm Ξ±} :
f β closure {Ο : Perm Ξ± | Ο.IsSwap} β (fixedBy Ξ± f)αΆ.Finite := by
refine (mem_closure_isSwap fun _ β¦ id).trans
(and_iff_left fun x β¦ β¨β¨swap x (f x), ?_β©, swap_apply_left x (f x)β©)
by_cases h : x = f x
Β· rw [β h, swap_self]
apply Subgroup.one_mem
Β· exact subset_closure β¨x, f x, h, rflβ©
/-- A transitive permutation group generated by transpositions must be the whole symmetric group -/
| Mathlib/GroupTheory/Perm/ClosureSwap.lean | 132 | 138 | theorem closure_of_isSwap_of_isPretransitive [Finite Ξ±] {S : Set (Perm Ξ±)} (hS : β Ο β S, Ο.IsSwap)
[MulAction.IsPretransitive (Subgroup.closure S) Ξ±] : Subgroup.closure S = β€ := by | simp [eq_top_iff', mem_closure_isSwap hS, orbit_eq_univ, Set.toFinite]
/-- A transitive permutation group generated by transpositions must be the whole symmetric group -/
theorem surjective_of_isSwap_of_isPretransitive [Finite Ξ±] (S : Set G)
(hS1 : β Ο β S, Perm.IsSwap (MulAction.toPermHom G Ξ± Ο)) (hS2 : Subgroup.closure S = β€) |
/-
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.Algebra.Order.Group.Nat
import Mathlib.Data.List.Defs
import Mathlib.Data.Set.Function
/-!
# iterate
Proves various lemmas about `List.iterate`.
-/
variable {Ξ± : Type*}
namespace List
@[simp]
| Mathlib/Data/List/Iterate.lean | 21 | 22 | theorem length_iterate (f : Ξ± β Ξ±) (a : Ξ±) (n : β) : length (iterate f a n) = n := by | induction n generalizing a <;> simp [*] |
/-
Copyright (c) 2018 Chris Hughes. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Chris Hughes, Abhimanyu Pallavi Sudhir, Jean Lo, Calle SΓΆnne, SΓ©bastien GouΓ«zel,
RΓ©my Degenne, David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.Pow.Real
/-!
# Power function on `ββ₯0` and `ββ₯0β`
We construct the power functions `x ^ y` where
* `x` is a nonnegative real number and `y` is a real number;
* `x` is a number from `[0, +β]` (a.k.a. `ββ₯0β`) and `y` is a real number.
We also prove basic properties of these functions.
-/
noncomputable section
open Real NNReal ENNReal ComplexConjugate Finset Function Set
namespace NNReal
variable {x : ββ₯0} {w y z : β}
/-- The nonnegative real power function `x^y`, defined for `x : ββ₯0` and `y : β` as the
restriction of the real power function. For `x > 0`, it is equal to `exp (y log x)`. For `x = 0`,
one sets `0 ^ 0 = 1` and `0 ^ y = 0` for `y β 0`. -/
noncomputable def rpow (x : ββ₯0) (y : β) : ββ₯0 :=
β¨(x : β) ^ y, Real.rpow_nonneg x.2 yβ©
noncomputable instance : Pow ββ₯0 β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0) (y : β) : rpow x y = x ^ y :=
rfl
@[simp, norm_cast]
theorem coe_rpow (x : ββ₯0) (y : β) : ((x ^ y : ββ₯0) : β) = (x : β) ^ y :=
rfl
@[simp]
theorem rpow_zero (x : ββ₯0) : x ^ (0 : β) = 1 :=
NNReal.eq <| Real.rpow_zero _
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0} {y : β} : x ^ y = 0 β x = 0 β§ y β 0 := by
rw [β NNReal.coe_inj, coe_rpow, β NNReal.coe_eq_zero]
exact Real.rpow_eq_zero_iff_of_nonneg x.2
lemma rpow_eq_zero (hy : y β 0) : x ^ y = 0 β x = 0 := by simp [hy]
@[simp]
theorem zero_rpow {x : β} (h : x β 0) : (0 : ββ₯0) ^ x = 0 :=
NNReal.eq <| Real.zero_rpow h
@[simp]
theorem rpow_one (x : ββ₯0) : x ^ (1 : β) = x :=
NNReal.eq <| Real.rpow_one _
lemma rpow_neg (x : ββ₯0) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.rpow_neg x.2 _
@[simp, norm_cast]
lemma rpow_natCast (x : ββ₯0) (n : β) : x ^ (n : β) = x ^ n :=
NNReal.eq <| by simpa only [coe_rpow, coe_pow] using Real.rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ββ₯0) (n : β€) : x ^ (n : β) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0) ^ x = 1 :=
NNReal.eq <| Real.one_rpow _
theorem rpow_add {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) _ _
theorem rpow_add' (h : y + z β 0) (x : ββ₯0) : x ^ (y + z) = x ^ y * x ^ z :=
NNReal.eq <| Real.rpow_add' x.2 h
lemma rpow_add_intCast (hx : x β 0) (y : β) (n : β€) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast (mod_cast hx) _ _
lemma rpow_add_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast (mod_cast hx) _ _
lemma rpow_sub_intCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast (mod_cast hx) _ _
lemma rpow_sub_natCast (hx : x β 0) (y : β) (n : β) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast (mod_cast hx) _ _
lemma rpow_add_intCast' {n : β€} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_intCast' (mod_cast x.2) h
lemma rpow_add_natCast' {n : β} (h : y + n β 0) (x : ββ₯0) : x ^ (y + n) = x ^ y * x ^ n := by
ext; exact Real.rpow_add_natCast' (mod_cast x.2) h
lemma rpow_sub_intCast' {n : β€} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_intCast' (mod_cast x.2) h
lemma rpow_sub_natCast' {n : β} (h : y - n β 0) (x : ββ₯0) : x ^ (y - n) = x ^ y / x ^ n := by
ext; exact Real.rpow_sub_natCast' (mod_cast x.2) h
lemma rpow_add_one (hx : x β 0) (y : β) : x ^ (y + 1) = x ^ y * x := by
simpa using rpow_add_natCast hx y 1
lemma rpow_sub_one (hx : x β 0) (y : β) : x ^ (y - 1) = x ^ y / x := by
simpa using rpow_sub_natCast hx y 1
lemma rpow_add_one' (h : y + 1 β 0) (x : ββ₯0) : x ^ (y + 1) = x ^ y * x := by
rw [rpow_add' h, rpow_one]
lemma rpow_one_add' (h : 1 + y β 0) (x : ββ₯0) : x ^ (1 + y) = x * x ^ y := by
rw [rpow_add' h, rpow_one]
theorem rpow_add_of_nonneg (x : ββ₯0) {y z : β} (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
ext; exact Real.rpow_add_of_nonneg x.2 hy hz
/-- Variant of `NNReal.rpow_add'` that avoids having to prove `y + z = w` twice. -/
lemma rpow_of_add_eq (x : ββ₯0) (hw : w β 0) (h : y + z = w) : x ^ w = x ^ y * x ^ z := by
rw [β h, rpow_add']; rwa [h]
theorem rpow_mul (x : ββ₯0) (y z : β) : x ^ (y * z) = (x ^ y) ^ z :=
NNReal.eq <| Real.rpow_mul x.2 y z
lemma rpow_natCast_mul (x : ββ₯0) (n : β) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_natCast]
lemma rpow_mul_natCast (x : ββ₯0) (y : β) (n : β) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_natCast]
lemma rpow_intCast_mul (x : ββ₯0) (n : β€) (z : β) : x ^ (n * z) = (x ^ n) ^ z := by
rw [rpow_mul, rpow_intCast]
lemma rpow_mul_intCast (x : ββ₯0) (y : β) (n : β€) : x ^ (y * n) = (x ^ y) ^ n := by
rw [rpow_mul, rpow_intCast]
theorem rpow_neg_one (x : ββ₯0) : x ^ (-1 : β) = xβ»ΒΉ := by simp [rpow_neg]
theorem rpow_sub {x : ββ₯0} (hx : x β 0) (y z : β) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub ((NNReal.coe_pos.trans pos_iff_ne_zero).mpr hx) y z
theorem rpow_sub' (h : y - z β 0) (x : ββ₯0) : x ^ (y - z) = x ^ y / x ^ z :=
NNReal.eq <| Real.rpow_sub' x.2 h
lemma rpow_sub_one' (h : y - 1 β 0) (x : ββ₯0) : x ^ (y - 1) = x ^ y / x := by
rw [rpow_sub' h, rpow_one]
lemma rpow_one_sub' (h : 1 - y β 0) (x : ββ₯0) : x ^ (1 - y) = x / x ^ y := by
rw [rpow_sub' h, rpow_one]
theorem rpow_inv_rpow_self {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ (1 / y) = x := by
field_simp [β rpow_mul]
theorem rpow_self_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ (1 / y)) ^ y = x := by
field_simp [β rpow_mul]
theorem inv_rpow (x : ββ₯0) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ :=
NNReal.eq <| Real.inv_rpow x.2 y
theorem div_rpow (x y : ββ₯0) (z : β) : (x / y) ^ z = x ^ z / y ^ z :=
NNReal.eq <| Real.div_rpow x.2 y.2 z
theorem sqrt_eq_rpow (x : ββ₯0) : sqrt x = x ^ (1 / (2 : β)) := by
refine NNReal.eq ?_
push_cast
exact Real.sqrt_eq_rpow x.1
@[simp]
lemma rpow_ofNat (x : ββ₯0) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (OfNat.ofNat n : β) :=
rpow_natCast x n
theorem rpow_two (x : ββ₯0) : x ^ (2 : β) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow {x y : ββ₯0} {z : β} : (x * y) ^ z = x ^ z * y ^ z :=
NNReal.eq <| Real.mul_rpow x.2 y.2
/-- `rpow` as a `MonoidHom` -/
@[simps]
def rpowMonoidHom (r : β) : ββ₯0 β* ββ₯0 where
toFun := (Β· ^ r)
map_one' := one_rpow _
map_mul' _x _y := mul_rpow
/-- `rpow` variant of `List.prod_map_pow` for `ββ₯0` -/
theorem list_prod_map_rpow (l : List ββ₯0) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r :=
l.prod_hom (rpowMonoidHom r)
theorem list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β list_prod_map_rpow, List.map_map]; rfl
/-- `rpow` version of `Multiset.prod_map_pow` for `ββ₯0`. -/
lemma multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r :=
s.prod_hom' (rpowMonoidHom r) _
/-- `rpow` version of `Finset.prod_pow` for `ββ₯0`. -/
lemma finset_prod_rpow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
multiset_prod_map_rpow _ _ _
-- note: these don't really belong here, but they're much easier to prove in terms of the above
section Real
/-- `rpow` version of `List.prod_map_pow` for `Real`. -/
theorem _root_.Real.list_prod_map_rpow (l : List β) (hl : β x β l, (0 : β) β€ x) (r : β) :
(l.map (Β· ^ r)).prod = l.prod ^ r := by
lift l to List ββ₯0 using hl
have := congr_arg ((β) : ββ₯0 β β) (NNReal.list_prod_map_rpow l r)
push_cast at this
rw [List.map_map] at this β’
exact mod_cast this
theorem _root_.Real.list_prod_map_rpow' {ΞΉ} (l : List ΞΉ) (f : ΞΉ β β)
(hl : β i β l, (0 : β) β€ f i) (r : β) :
(l.map (f Β· ^ r)).prod = (l.map f).prod ^ r := by
rw [β Real.list_prod_map_rpow (l.map f) _ r, List.map_map]
Β· rfl
simpa using hl
/-- `rpow` version of `Multiset.prod_map_pow`. -/
theorem _root_.Real.multiset_prod_map_rpow {ΞΉ} (s : Multiset ΞΉ) (f : ΞΉ β β)
(hs : β i β s, (0 : β) β€ f i) (r : β) :
(s.map (f Β· ^ r)).prod = (s.map f).prod ^ r := by
induction' s using Quotient.inductionOn with l
simpa using Real.list_prod_map_rpow' l f hs r
/-- `rpow` version of `Finset.prod_pow`. -/
theorem _root_.Real.finset_prod_rpow
{ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β β) (hs : β i β s, 0 β€ f i) (r : β) :
(β i β s, f i ^ r) = (β i β s, f i) ^ r :=
Real.multiset_prod_map_rpow s.val f hs r
end Real
@[gcongr] theorem rpow_le_rpow {x y : ββ₯0} {z : β} (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z :=
Real.rpow_le_rpow x.2 hβ hβ
@[gcongr] theorem rpow_lt_rpow {x y : ββ₯0} {z : β} (hβ : x < y) (hβ : 0 < z) : x ^ z < y ^ z :=
Real.rpow_lt_rpow x.2 hβ hβ
theorem rpow_lt_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z < y ^ z β x < y :=
Real.rpow_lt_rpow_iff x.2 y.2 hz
theorem rpow_le_rpow_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
Real.rpow_le_rpow_iff x.2 y.2 hz
theorem le_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem rpow_inv_le_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
rw [β rpow_le_rpow_iff hz, β one_div, rpow_self_rpow_inv hz.ne']
theorem lt_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^z < y := by
simp only [β not_le, rpow_inv_le_iff hz]
theorem rpow_inv_lt_iff {x y : ββ₯0} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z := by
simp only [β not_le, le_rpow_inv_iff hz]
section
variable {y : ββ₯0}
lemma rpow_lt_rpow_of_neg (hx : 0 < x) (hxy : x < y) (hz : z < 0) : y ^ z < x ^ z :=
Real.rpow_lt_rpow_of_neg hx hxy hz
lemma rpow_le_rpow_of_nonpos (hx : 0 < x) (hxy : x β€ y) (hz : z β€ 0) : y ^ z β€ x ^ z :=
Real.rpow_le_rpow_of_nonpos hx hxy hz
lemma rpow_lt_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z < y ^ z β y < x :=
Real.rpow_lt_rpow_iff_of_neg hx hy hz
lemma rpow_le_rpow_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ z β€ y ^ z β y β€ x :=
Real.rpow_le_rpow_iff_of_neg hx hy hz
lemma le_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y :=
Real.le_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_le_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z :=
Real.rpow_inv_le_iff_of_pos x.2 hy hz
lemma lt_rpow_inv_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x < y ^ zβ»ΒΉ β x ^ z < y :=
Real.lt_rpow_inv_iff_of_pos x.2 hy hz
lemma rpow_inv_lt_iff_of_pos (hy : 0 β€ y) (hz : 0 < z) (x : ββ₯0) : x ^ zβ»ΒΉ < y β x < y ^ z :=
Real.rpow_inv_lt_iff_of_pos x.2 hy hz
lemma le_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x β€ y ^ zβ»ΒΉ β y β€ x ^ z :=
Real.le_rpow_inv_iff_of_neg hx hy hz
lemma lt_rpow_inv_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x < y ^ zβ»ΒΉ β y < x ^ z :=
Real.lt_rpow_inv_iff_of_neg hx hy hz
lemma rpow_inv_lt_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ < y β y ^ z < x :=
Real.rpow_inv_lt_iff_of_neg hx hy hz
lemma rpow_inv_le_iff_of_neg (hx : 0 < x) (hy : 0 < y) (hz : z < 0) : x ^ zβ»ΒΉ β€ y β y ^ z β€ x :=
Real.rpow_inv_le_iff_of_neg hx hy hz
end
@[gcongr] theorem rpow_lt_rpow_of_exponent_lt {x : ββ₯0} {y z : β} (hx : 1 < x) (hyz : y < z) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_lt hx hyz
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ββ₯0} {y z : β} (hx : 1 β€ x) (hyz : y β€ z) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_le hx hyz
theorem rpow_lt_rpow_of_exponent_gt {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z :=
Real.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz
theorem rpow_le_rpow_of_exponent_ge {x : ββ₯0} {y z : β} (hx0 : 0 < x) (hx1 : x β€ 1) (hyz : z β€ y) :
x ^ y β€ x ^ z :=
Real.rpow_le_rpow_of_exponent_ge hx0 hx1 hyz
theorem rpow_pos {p : β} {x : ββ₯0} (hx_pos : 0 < x) : 0 < x ^ p := by
have rpow_pos_of_nonneg : β {p : β}, 0 < p β 0 < x ^ p := by
intro p hp_pos
rw [β zero_rpow hp_pos.ne']
exact rpow_lt_rpow hx_pos hp_pos
rcases lt_trichotomy (0 : β) p with (hp_pos | rfl | hp_neg)
Β· exact rpow_pos_of_nonneg hp_pos
Β· simp only [zero_lt_one, rpow_zero]
Β· rw [β neg_neg p, rpow_neg, inv_pos]
exact rpow_pos_of_nonneg (neg_pos.mpr hp_neg)
theorem rpow_lt_one {x : ββ₯0} {z : β} (hx1 : x < 1) (hz : 0 < z) : x ^ z < 1 :=
Real.rpow_lt_one (coe_nonneg x) hx1 hz
theorem rpow_le_one {x : ββ₯0} {z : β} (hx2 : x β€ 1) (hz : 0 β€ z) : x ^ z β€ 1 :=
Real.rpow_le_one x.2 hx2 hz
theorem rpow_lt_one_of_one_lt_of_neg {x : ββ₯0} {z : β} (hx : 1 < x) (hz : z < 0) : x ^ z < 1 :=
Real.rpow_lt_one_of_one_lt_of_neg hx hz
theorem rpow_le_one_of_one_le_of_nonpos {x : ββ₯0} {z : β} (hx : 1 β€ x) (hz : z β€ 0) : x ^ z β€ 1 :=
Real.rpow_le_one_of_one_le_of_nonpos hx hz
theorem one_lt_rpow {x : ββ₯0} {z : β} (hx : 1 < x) (hz : 0 < z) : 1 < x ^ z :=
Real.one_lt_rpow hx hz
theorem one_le_rpow {x : ββ₯0} {z : β} (h : 1 β€ x) (hβ : 0 β€ z) : 1 β€ x ^ z :=
Real.one_le_rpow h hβ
theorem one_lt_rpow_of_pos_of_lt_one_of_neg {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x < 1)
(hz : z < 0) : 1 < x ^ z :=
Real.one_lt_rpow_of_pos_of_lt_one_of_neg hx1 hx2 hz
theorem one_le_rpow_of_pos_of_le_one_of_nonpos {x : ββ₯0} {z : β} (hx1 : 0 < x) (hx2 : x β€ 1)
(hz : z β€ 0) : 1 β€ x ^ z :=
Real.one_le_rpow_of_pos_of_le_one_of_nonpos hx1 hx2 hz
theorem rpow_le_self_of_le_one {x : ββ₯0} {z : β} (hx : x β€ 1) (h_one_le : 1 β€ z) : x ^ z β€ x := by
rcases eq_bot_or_bot_lt x with (rfl | (h : 0 < x))
Β· have : z β 0 := by linarith
simp [this]
nth_rw 2 [β NNReal.rpow_one x]
exact NNReal.rpow_le_rpow_of_exponent_ge h hx h_one_le
theorem rpow_left_injective {x : β} (hx : x β 0) : Function.Injective fun y : ββ₯0 => y ^ x :=
fun y z hyz => by simpa only [rpow_inv_rpow_self hx] using congr_arg (fun y => y ^ (1 / x)) hyz
theorem rpow_eq_rpow_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ z = y ^ z β x = y :=
(rpow_left_injective hz).eq_iff
theorem rpow_left_surjective {x : β} (hx : x β 0) : Function.Surjective fun y : ββ₯0 => y ^ x :=
fun y => β¨y ^ xβ»ΒΉ, by simp_rw [β rpow_mul, inv_mul_cancelβ hx, rpow_one]β©
theorem rpow_left_bijective {x : β} (hx : x β 0) : Function.Bijective fun y : ββ₯0 => y ^ x :=
β¨rpow_left_injective hx, rpow_left_surjective hxβ©
theorem eq_rpow_inv_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x = y ^ zβ»ΒΉ β x ^ z = y := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
theorem rpow_inv_eq_iff {x y : ββ₯0} {z : β} (hz : z β 0) : x ^ zβ»ΒΉ = y β x = y ^ z := by
rw [β rpow_eq_rpow_iff hz, β one_div, rpow_self_rpow_inv hz]
@[simp] lemma rpow_rpow_inv {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ y) ^ yβ»ΒΉ = x := by
rw [β rpow_mul, mul_inv_cancelβ hy, rpow_one]
@[simp] lemma rpow_inv_rpow {y : β} (hy : y β 0) (x : ββ₯0) : (x ^ yβ»ΒΉ) ^ y = x := by
rw [β rpow_mul, inv_mul_cancelβ hy, rpow_one]
theorem pow_rpow_inv_natCast (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ n) ^ (nβ»ΒΉ : β) = x := by
rw [β NNReal.coe_inj, coe_rpow, NNReal.coe_pow]
exact Real.pow_rpow_inv_natCast x.2 hn
theorem rpow_inv_natCast_pow (x : ββ₯0) {n : β} (hn : n β 0) : (x ^ (nβ»ΒΉ : β)) ^ n = x := by
rw [β NNReal.coe_inj, NNReal.coe_pow, coe_rpow]
exact Real.rpow_inv_natCast_pow x.2 hn
theorem _root_.Real.toNNReal_rpow_of_nonneg {x y : β} (hx : 0 β€ x) :
Real.toNNReal (x ^ y) = Real.toNNReal x ^ y := by
nth_rw 1 [β Real.coe_toNNReal x hx]
rw [β NNReal.coe_rpow, Real.toNNReal_coe]
theorem strictMono_rpow_of_pos {z : β} (h : 0 < z) : StrictMono fun x : ββ₯0 => x ^ z :=
fun x y hxy => by simp only [NNReal.rpow_lt_rpow hxy h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : β} (h : 0 β€ z) : Monotone fun x : ββ₯0 => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 βΈ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ββ₯0 => x ^ y` into an order isomorphism when `y : β` is positive,
where the inverse is `fun x : ββ₯0 => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : β) (hy : 0 < y) : ββ₯0 βo ββ₯0 :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [β rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_eq (y : β) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]; rfl
theorem _root_.Real.nnnorm_rpow_of_nonneg {x y : β} (hx : 0 β€ x) : βx ^ yββ = βxββ ^ y := by
ext; exact Real.norm_rpow_of_nonneg hx
end NNReal
namespace ENNReal
/-- The real power function `x^y` on extended nonnegative reals, defined for `x : ββ₯0β` and
`y : β` as the restriction of the real power function if `0 < x < β€`, and with the natural values
for `0` and `β€` (i.e., `0 ^ x = 0` for `x > 0`, `1` for `x = 0` and `β€` for `x < 0`, and
`β€ ^ x = 1 / 0 ^ x`). -/
noncomputable def rpow : ββ₯0β β β β ββ₯0β
| some x, y => if x = 0 β§ y < 0 then β€ else (x ^ y : ββ₯0)
| none, y => if 0 < y then β€ else if y = 0 then 1 else 0
noncomputable instance : Pow ββ₯0β β :=
β¨rpowβ©
@[simp]
theorem rpow_eq_pow (x : ββ₯0β) (y : β) : rpow x y = x ^ y :=
rfl
@[simp]
theorem rpow_zero {x : ββ₯0β} : x ^ (0 : β) = 1 := by
cases x <;>
Β· dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp [lt_irrefl]
theorem top_rpow_def (y : β) : (β€ : ββ₯0β) ^ y = if 0 < y then β€ else if y = 0 then 1 else 0 :=
rfl
@[simp]
theorem top_rpow_of_pos {y : β} (h : 0 < y) : (β€ : ββ₯0β) ^ y = β€ := by simp [top_rpow_def, h]
@[simp]
theorem top_rpow_of_neg {y : β} (h : y < 0) : (β€ : ββ₯0β) ^ y = 0 := by
simp [top_rpow_def, asymm h, ne_of_lt h]
@[simp]
theorem zero_rpow_of_pos {y : β} (h : 0 < y) : (0 : ββ₯0β) ^ y = 0 := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [h, asymm h, ne_of_gt h]
@[simp]
theorem zero_rpow_of_neg {y : β} (h : y < 0) : (0 : ββ₯0β) ^ y = β€ := by
rw [β ENNReal.coe_zero, β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), rpow, Pow.pow]
simp [h, ne_of_gt h]
theorem zero_rpow_def (y : β) : (0 : ββ₯0β) ^ y = if 0 < y then 0 else if y = 0 then 1 else β€ := by
rcases lt_trichotomy (0 : β) y with (H | rfl | H)
Β· simp [H, ne_of_gt, zero_rpow_of_pos, lt_irrefl]
Β· simp [lt_irrefl]
Β· simp [H, asymm H, ne_of_lt, zero_rpow_of_neg]
@[simp]
theorem zero_rpow_mul_self (y : β) : (0 : ββ₯0β) ^ y * (0 : ββ₯0β) ^ y = (0 : ββ₯0β) ^ y := by
rw [zero_rpow_def]
split_ifs
exacts [zero_mul _, one_mul _, top_mul_top]
@[norm_cast]
theorem coe_rpow_of_ne_zero {x : ββ₯0} (h : x β 0) (y : β) : (β(x ^ y) : ββ₯0β) = x ^ y := by
rw [β ENNReal.some_eq_coe]
dsimp only [(Β· ^ Β·), Pow.pow, rpow]
simp [h]
@[norm_cast]
theorem coe_rpow_of_nonneg (x : ββ₯0) {y : β} (h : 0 β€ y) : β(x ^ y) = (x : ββ₯0β) ^ y := by
by_cases hx : x = 0
Β· rcases le_iff_eq_or_lt.1 h with (H | H)
Β· simp [hx, H.symm]
Β· simp [hx, zero_rpow_of_pos H, NNReal.zero_rpow (ne_of_gt H)]
Β· exact coe_rpow_of_ne_zero hx _
theorem coe_rpow_def (x : ββ₯0) (y : β) :
(x : ββ₯0β) ^ y = if x = 0 β§ y < 0 then β€ else β(x ^ y) :=
rfl
theorem rpow_ofNNReal {M : ββ₯0} {P : β} (hP : 0 β€ P) : (M : ββ₯0β) ^ P = β(M ^ P) := by
rw [ENNReal.coe_rpow_of_nonneg _ hP, β ENNReal.rpow_eq_pow]
@[simp]
theorem rpow_one (x : ββ₯0β) : x ^ (1 : β) = x := by
cases x
Β· exact dif_pos zero_lt_one
Β· change ite _ _ _ = _
simp only [NNReal.rpow_one, some_eq_coe, ite_eq_right_iff, top_ne_coe, and_imp]
exact fun _ => zero_le_one.not_lt
@[simp]
theorem one_rpow (x : β) : (1 : ββ₯0β) ^ x = 1 := by
rw [β coe_one, β coe_rpow_of_ne_zero one_ne_zero]
simp
@[simp]
theorem rpow_eq_zero_iff {x : ββ₯0β} {y : β} : x ^ y = 0 β x = 0 β§ 0 < y β¨ x = β€ β§ y < 0 := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
lemma rpow_eq_zero_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = 0 β x = 0 := by
simp [hy, hy.not_lt]
@[simp]
theorem rpow_eq_top_iff {x : ββ₯0β} {y : β} : x ^ y = β€ β x = 0 β§ y < 0 β¨ x = β€ β§ 0 < y := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [H, top_rpow_of_neg, top_rpow_of_pos, le_of_lt]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, H, zero_rpow_of_neg, zero_rpow_of_pos, le_of_lt]
Β· simp [β coe_rpow_of_ne_zero h, h]
theorem rpow_eq_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y = β€ β x = β€ := by
simp [rpow_eq_top_iff, hy, asymm hy]
lemma rpow_lt_top_iff_of_pos {x : ββ₯0β} {y : β} (hy : 0 < y) : x ^ y < β β x < β := by
simp only [lt_top_iff_ne_top, Ne, rpow_eq_top_iff_of_pos hy]
theorem rpow_eq_top_of_nonneg (x : ββ₯0β) {y : β} (hy0 : 0 β€ y) : x ^ y = β€ β x = β€ := by
rw [ENNReal.rpow_eq_top_iff]
rintro (h|h)
Β· exfalso
rw [lt_iff_not_ge] at h
exact h.right hy0
Β· exact h.left
theorem rpow_ne_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y β β€ :=
mt (ENNReal.rpow_eq_top_of_nonneg x hy0) h
theorem rpow_lt_top_of_nonneg {x : ββ₯0β} {y : β} (hy0 : 0 β€ y) (h : x β β€) : x ^ y < β€ :=
lt_top_iff_ne_top.mpr (ENNReal.rpow_ne_top_of_nonneg hy0 h)
theorem rpow_add {x : ββ₯0β} (y z : β) (hx : x β 0) (h'x : x β β€) : x ^ (y + z) = x ^ y * x ^ z := by
cases x with
| top => exact (h'x rfl).elim
| coe x =>
have : x β 0 := fun h => by simp [h] at hx
simp [β coe_rpow_of_ne_zero this, NNReal.rpow_add this]
theorem rpow_add_of_nonneg {x : ββ₯0β} (y z : β) (hy : 0 β€ y) (hz : 0 β€ z) :
x ^ (y + z) = x ^ y * x ^ z := by
induction x using recTopCoe
Β· rcases hy.eq_or_lt with rfl|hy
Β· rw [rpow_zero, one_mul, zero_add]
rcases hz.eq_or_lt with rfl|hz
Β· rw [rpow_zero, mul_one, add_zero]
simp [top_rpow_of_pos, hy, hz, add_pos hy hz]
simp [β coe_rpow_of_nonneg, hy, hz, add_nonneg hy hz, NNReal.rpow_add_of_nonneg _ hy hz]
theorem rpow_neg (x : ββ₯0β) (y : β) : x ^ (-y) = (x ^ y)β»ΒΉ := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [top_rpow_of_pos, top_rpow_of_neg, H, neg_pos.mpr]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (H | H | H) <;>
simp [h, zero_rpow_of_pos, zero_rpow_of_neg, H, neg_pos.mpr]
Β· have A : x ^ y β 0 := by simp [h]
simp [β coe_rpow_of_ne_zero h, β coe_inv A, NNReal.rpow_neg]
theorem rpow_sub {x : ββ₯0β} (y z : β) (hx : x β 0) (h'x : x β β€) : x ^ (y - z) = x ^ y / x ^ z := by
rw [sub_eq_add_neg, rpow_add _ _ hx h'x, rpow_neg, div_eq_mul_inv]
theorem rpow_neg_one (x : ββ₯0β) : x ^ (-1 : β) = xβ»ΒΉ := by simp [rpow_neg]
theorem rpow_mul (x : ββ₯0β) (y z : β) : x ^ (y * z) = (x ^ y) ^ z := by
cases x with
| top =>
rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
| coe x =>
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [h, Hy, Hz, zero_rpow_of_neg, zero_rpow_of_pos, top_rpow_of_neg, top_rpow_of_pos,
mul_pos_of_neg_of_neg, mul_neg_of_neg_of_pos, mul_neg_of_pos_of_neg]
Β· have : x ^ y β 0 := by simp [h]
simp [β coe_rpow_of_ne_zero, h, this, NNReal.rpow_mul]
@[simp, norm_cast]
theorem rpow_natCast (x : ββ₯0β) (n : β) : x ^ (n : β) = x ^ n := by
cases x
Β· cases n <;> simp [top_rpow_of_pos (Nat.cast_add_one_pos _), top_pow (Nat.succ_ne_zero _)]
Β· simp [β coe_rpow_of_nonneg _ (Nat.cast_nonneg n)]
@[simp]
lemma rpow_ofNat (x : ββ₯0β) (n : β) [n.AtLeastTwo] :
x ^ (ofNat(n) : β) = x ^ (OfNat.ofNat n) :=
rpow_natCast x n
@[simp, norm_cast]
lemma rpow_intCast (x : ββ₯0β) (n : β€) : x ^ (n : β) = x ^ n := by
cases n <;> simp only [Int.ofNat_eq_coe, Int.cast_natCast, rpow_natCast, zpow_natCast,
Int.cast_negSucc, rpow_neg, zpow_negSucc]
theorem rpow_two (x : ββ₯0β) : x ^ (2 : β) = x ^ 2 := rpow_ofNat x 2
theorem mul_rpow_eq_ite (x y : ββ₯0β) (z : β) :
(x * y) ^ z = if (x = 0 β§ y = β€ β¨ x = β€ β§ y = 0) β§ z < 0 then β€ else x ^ z * y ^ z := by
rcases eq_or_ne z 0 with (rfl | hz); Β· simp
replace hz := hz.lt_or_lt
wlog hxy : x β€ y
Β· convert this y x z hz (le_of_not_le hxy) using 2 <;> simp only [mul_comm, and_comm, or_comm]
rcases eq_or_ne x 0 with (rfl | hx0)
Β· induction y <;> rcases hz with hz | hz <;> simp [*, hz.not_lt]
rcases eq_or_ne y 0 with (rfl | hy0)
Β· exact (hx0 (bot_unique hxy)).elim
induction x
Β· rcases hz with hz | hz <;> simp [hz, top_unique hxy]
induction y
Β· rw [ne_eq, coe_eq_zero] at hx0
rcases hz with hz | hz <;> simp [*]
simp only [*, if_false]
norm_cast at *
rw [β coe_rpow_of_ne_zero (mul_ne_zero hx0 hy0), NNReal.mul_rpow]
norm_cast
theorem mul_rpow_of_ne_top {x y : ββ₯0β} (hx : x β β€) (hy : y β β€) (z : β) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
@[norm_cast]
theorem coe_mul_rpow (x y : ββ₯0) (z : β) : ((x : ββ₯0β) * y) ^ z = (x : ββ₯0β) ^ z * (y : ββ₯0β) ^ z :=
mul_rpow_of_ne_top coe_ne_top coe_ne_top z
theorem prod_coe_rpow {ΞΉ} (s : Finset ΞΉ) (f : ΞΉ β ββ₯0) (r : β) :
β i β s, (f i : ββ₯0β) ^ r = ((β i β s, f i : ββ₯0) : ββ₯0β) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert _ _ hi ih => simp_rw [prod_insert hi, ih, β coe_mul_rpow, coe_mul]
theorem mul_rpow_of_ne_zero {x y : ββ₯0β} (hx : x β 0) (hy : y β 0) (z : β) :
(x * y) ^ z = x ^ z * y ^ z := by simp [*, mul_rpow_eq_ite]
theorem mul_rpow_of_nonneg (x y : ββ₯0β) {z : β} (hz : 0 β€ z) : (x * y) ^ z = x ^ z * y ^ z := by
simp [hz.not_lt, mul_rpow_eq_ite]
theorem prod_rpow_of_ne_top {ΞΉ} {s : Finset ΞΉ} {f : ΞΉ β ββ₯0β} (hf : β i β s, f i β β) (r : β) :
β i β s, f i ^ r = (β i β s, f i) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert i s hi ih =>
have h2f : β i β s, f i β β := fun i hi β¦ hf i <| mem_insert_of_mem hi
rw [prod_insert hi, prod_insert hi, ih h2f, β mul_rpow_of_ne_top <| hf i <| mem_insert_self ..]
apply prod_ne_top h2f
theorem prod_rpow_of_nonneg {ΞΉ} {s : Finset ΞΉ} {f : ΞΉ β ββ₯0β} {r : β} (hr : 0 β€ r) :
β i β s, f i ^ r = (β i β s, f i) ^ r := by
classical
induction s using Finset.induction with
| empty => simp
| insert _ _ hi ih => simp_rw [prod_insert hi, ih, β mul_rpow_of_nonneg _ _ hr]
theorem inv_rpow (x : ββ₯0β) (y : β) : xβ»ΒΉ ^ y = (x ^ y)β»ΒΉ := by
rcases eq_or_ne y 0 with (rfl | hy); Β· simp only [rpow_zero, inv_one]
replace hy := hy.lt_or_lt
rcases eq_or_ne x 0 with (rfl | h0); Β· cases hy <;> simp [*]
rcases eq_or_ne x β€ with (rfl | h_top); Β· cases hy <;> simp [*]
apply ENNReal.eq_inv_of_mul_eq_one_left
rw [β mul_rpow_of_ne_zero (ENNReal.inv_ne_zero.2 h_top) h0, ENNReal.inv_mul_cancel h0 h_top,
one_rpow]
theorem div_rpow_of_nonneg (x y : ββ₯0β) {z : β} (hz : 0 β€ z) : (x / y) ^ z = x ^ z / y ^ z := by
rw [div_eq_mul_inv, mul_rpow_of_nonneg _ _ hz, inv_rpow, div_eq_mul_inv]
theorem strictMono_rpow_of_pos {z : β} (h : 0 < z) : StrictMono fun x : ββ₯0β => x ^ z := by
intro x y hxy
lift x to ββ₯0 using ne_top_of_lt hxy
rcases eq_or_ne y β with (rfl | hy)
Β· simp only [top_rpow_of_pos h, β coe_rpow_of_nonneg _ h.le, coe_lt_top]
Β· lift y to ββ₯0 using hy
simp only [β coe_rpow_of_nonneg _ h.le, NNReal.rpow_lt_rpow (coe_lt_coe.1 hxy) h, coe_lt_coe]
theorem monotone_rpow_of_nonneg {z : β} (h : 0 β€ z) : Monotone fun x : ββ₯0β => x ^ z :=
h.eq_or_lt.elim (fun h0 => h0 βΈ by simp only [rpow_zero, monotone_const]) fun h0 =>
(strictMono_rpow_of_pos h0).monotone
/-- Bundles `fun x : ββ₯0β => x ^ y` into an order isomorphism when `y : β` is positive,
where the inverse is `fun x : ββ₯0β => x ^ (1 / y)`. -/
@[simps! apply]
def orderIsoRpow (y : β) (hy : 0 < y) : ββ₯0β βo ββ₯0β :=
(strictMono_rpow_of_pos hy).orderIsoOfRightInverse (fun x => x ^ y) (fun x => x ^ (1 / y))
fun x => by
dsimp
rw [β rpow_mul, one_div_mul_cancel hy.ne.symm, rpow_one]
theorem orderIsoRpow_symm_apply (y : β) (hy : 0 < y) :
(orderIsoRpow y hy).symm = orderIsoRpow (1 / y) (one_div_pos.2 hy) := by
simp only [orderIsoRpow, one_div_one_div]
rfl
@[gcongr] theorem rpow_le_rpow {x y : ββ₯0β} {z : β} (hβ : x β€ y) (hβ : 0 β€ z) : x ^ z β€ y ^ z :=
monotone_rpow_of_nonneg hβ hβ
@[gcongr] theorem rpow_lt_rpow {x y : ββ₯0β} {z : β} (hβ : x < y) (hβ : 0 < z) : x ^ z < y ^ z :=
strictMono_rpow_of_pos hβ hβ
theorem rpow_le_rpow_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ z β€ y ^ z β x β€ y :=
(strictMono_rpow_of_pos hz).le_iff_le
theorem rpow_lt_rpow_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ z < y ^ z β x < y :=
(strictMono_rpow_of_pos hz).lt_iff_lt
theorem le_rpow_inv_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x β€ y ^ zβ»ΒΉ β x ^ z β€ y := by
nth_rw 1 [β rpow_one x]
nth_rw 1 [β @mul_inv_cancelβ _ _ z hz.ne']
rw [rpow_mul, @rpow_le_rpow_iff _ _ zβ»ΒΉ (by simp [hz])]
theorem rpow_inv_lt_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ < y β x < y ^ z := by
simp only [β not_le, le_rpow_inv_iff hz]
theorem lt_rpow_inv_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x < y ^ zβ»ΒΉ β x ^ z < y := by
nth_rw 1 [β rpow_one x]
nth_rw 1 [β @mul_inv_cancelβ _ _ z (ne_of_lt hz).symm]
rw [rpow_mul, @rpow_lt_rpow_iff _ _ zβ»ΒΉ (by simp [hz])]
theorem rpow_inv_le_iff {x y : ββ₯0β} {z : β} (hz : 0 < z) : x ^ zβ»ΒΉ β€ y β x β€ y ^ z := by
nth_rw 1 [β ENNReal.rpow_one y]
nth_rw 1 [β @mul_inv_cancelβ _ _ z hz.ne.symm]
rw [ENNReal.rpow_mul, ENNReal.rpow_le_rpow_iff (inv_pos.2 hz)]
theorem rpow_lt_rpow_of_exponent_lt {x : ββ₯0β} {y z : β} (hx : 1 < x) (hx' : x β β€) (hyz : y < z) :
x ^ y < x ^ z := by
lift x to ββ₯0 using hx'
rw [one_lt_coe_iff] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_trans zero_lt_one hx)),
NNReal.rpow_lt_rpow_of_exponent_lt hx hyz]
@[gcongr] theorem rpow_le_rpow_of_exponent_le {x : ββ₯0β} {y z : β} (hx : 1 β€ x) (hyz : y β€ z) :
x ^ y β€ x ^ z := by
cases x
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, top_rpow_of_neg, top_rpow_of_pos, le_refl] <;>
linarith
Β· simp only [one_le_coe_iff, some_eq_coe] at hx
simp [β coe_rpow_of_ne_zero (ne_of_gt (lt_of_lt_of_le zero_lt_one hx)),
NNReal.rpow_le_rpow_of_exponent_le hx hyz]
theorem rpow_lt_rpow_of_exponent_gt {x : ββ₯0β} {y z : β} (hx0 : 0 < x) (hx1 : x < 1) (hyz : z < y) :
x ^ y < x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_lt_of_le hx1 le_top)
simp only [coe_lt_one_iff, coe_pos] at hx0 hx1
simp [β coe_rpow_of_ne_zero (ne_of_gt hx0), NNReal.rpow_lt_rpow_of_exponent_gt hx0 hx1 hyz]
theorem rpow_le_rpow_of_exponent_ge {x : ββ₯0β} {y z : β} (hx1 : x β€ 1) (hyz : z β€ y) :
x ^ y β€ x ^ z := by
lift x to ββ₯0 using ne_of_lt (lt_of_le_of_lt hx1 coe_lt_top)
by_cases h : x = 0
Β· rcases lt_trichotomy y 0 with (Hy | Hy | Hy) <;>
rcases lt_trichotomy z 0 with (Hz | Hz | Hz) <;>
simp [Hy, Hz, h, zero_rpow_of_neg, zero_rpow_of_pos, le_refl] <;>
linarith
Β· rw [coe_le_one_iff] at hx1
simp [β coe_rpow_of_ne_zero h,
NNReal.rpow_le_rpow_of_exponent_ge (bot_lt_iff_ne_bot.mpr h) hx1 hyz]
theorem rpow_le_self_of_le_one {x : ββ₯0β} {z : β} (hx : x β€ 1) (h_one_le : 1 β€ z) : x ^ z β€ x := by
nth_rw 2 [β ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_ge hx h_one_le
theorem le_rpow_self_of_one_le {x : ββ₯0β} {z : β} (hx : 1 β€ x) (h_one_le : 1 β€ z) : x β€ x ^ z := by
nth_rw 1 [β ENNReal.rpow_one x]
exact ENNReal.rpow_le_rpow_of_exponent_le hx h_one_le
theorem rpow_pos_of_nonneg {p : β} {x : ββ₯0β} (hx_pos : 0 < x) (hp_nonneg : 0 β€ p) : 0 < x ^ p := by
by_cases hp_zero : p = 0
Β· simp [hp_zero, zero_lt_one]
Β· rw [β Ne] at hp_zero
have hp_pos := lt_of_le_of_ne hp_nonneg hp_zero.symm
rw [β zero_rpow_of_pos hp_pos]
exact rpow_lt_rpow hx_pos hp_pos
| Mathlib/Analysis/SpecialFunctions/Pow/NNReal.lean | 815 | 818 | theorem rpow_pos {p : β} {x : ββ₯0β} (hx_pos : 0 < x) (hx_ne_top : x β β€) : 0 < x ^ p := by | rcases lt_or_le 0 p with hp_pos | hp_nonpos
Β· exact rpow_pos_of_nonneg hx_pos (le_of_lt hp_pos)
Β· rw [β neg_neg p, rpow_neg, ENNReal.inv_pos] |
/-
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 Aesop
import Mathlib.Order.BoundedOrder.Lattice
/-!
# Disjointness and complements
This file defines `Disjoint`, `Codisjoint`, and the `IsCompl` predicate.
## Main declarations
* `Disjoint x y`: two elements of a lattice are disjoint if their `inf` is the bottom element.
* `Codisjoint x y`: two elements of a lattice are codisjoint if their `join` is the top element.
* `IsCompl x y`: In a bounded lattice, predicate for "`x` is a complement of `y`". Note that in a
non distributive lattice, an element can have several complements.
* `ComplementedLattice Ξ±`: Typeclass stating that any element of a lattice has a complement.
-/
open Function
variable {Ξ± : Type*}
section Disjoint
section PartialOrderBot
variable [PartialOrder Ξ±] [OrderBot Ξ±] {a b c d : Ξ±}
/-- Two elements of a lattice are disjoint if their inf is the bottom element.
(This generalizes disjoint sets, viewed as members of the subset lattice.)
Note that we define this without reference to `β`, as this allows us to talk about orders where
the infimum is not unique, or where implementing `Inf` would require additional `Decidable`
arguments. -/
def Disjoint (a b : Ξ±) : Prop :=
β β¦xβ¦, x β€ a β x β€ b β x β€ β₯
@[simp]
theorem disjoint_of_subsingleton [Subsingleton Ξ±] : Disjoint a b :=
fun x _ _ β¦ le_of_eq (Subsingleton.elim x β₯)
theorem disjoint_comm : Disjoint a b β Disjoint b a :=
forall_congr' fun _ β¦ forall_swap
@[symm]
theorem Disjoint.symm β¦a b : Ξ±β¦ : Disjoint a b β Disjoint b a :=
disjoint_comm.1
theorem symmetric_disjoint : Symmetric (Disjoint : Ξ± β Ξ± β Prop) :=
Disjoint.symm
@[simp]
theorem disjoint_bot_left : Disjoint β₯ a := fun _ hbot _ β¦ hbot
@[simp]
theorem disjoint_bot_right : Disjoint a β₯ := fun _ _ hbot β¦ hbot
theorem Disjoint.mono (hβ : a β€ b) (hβ : c β€ d) : Disjoint b d β Disjoint a c :=
fun h _ ha hc β¦ h (ha.trans hβ) (hc.trans hβ)
theorem Disjoint.mono_left (h : a β€ b) : Disjoint b c β Disjoint a c :=
Disjoint.mono h le_rfl
theorem Disjoint.mono_right : b β€ c β Disjoint a c β Disjoint a b :=
Disjoint.mono le_rfl
@[simp]
theorem disjoint_self : Disjoint a a β a = β₯ :=
β¨fun hd β¦ bot_unique <| hd le_rfl le_rfl, fun h _ ha _ β¦ ha.trans_eq hβ©
/- TODO: Rename `Disjoint.eq_bot` to `Disjoint.inf_eq` and `Disjoint.eq_bot_of_self` to
`Disjoint.eq_bot` -/
alias β¨Disjoint.eq_bot_of_self, _β© := disjoint_self
theorem Disjoint.ne (ha : a β β₯) (hab : Disjoint a b) : a β b :=
fun h β¦ ha <| disjoint_self.1 <| by rwa [β h] at hab
theorem Disjoint.eq_bot_of_le (hab : Disjoint a b) (h : a β€ b) : a = β₯ :=
eq_bot_iff.2 <| hab le_rfl h
theorem Disjoint.eq_bot_of_ge (hab : Disjoint a b) : b β€ a β b = β₯ :=
hab.symm.eq_bot_of_le
lemma Disjoint.eq_iff (hab : Disjoint a b) : a = b β a = β₯ β§ b = β₯ := by aesop
lemma Disjoint.ne_iff (hab : Disjoint a b) : a β b β a β β₯ β¨ b β β₯ :=
hab.eq_iff.not.trans not_and_or
theorem disjoint_of_le_iff_left_eq_bot (h : a β€ b) :
Disjoint a b β a = β₯ :=
β¨fun hd β¦ hd.eq_bot_of_le h, fun h β¦ h βΈ disjoint_bot_leftβ©
end PartialOrderBot
section PartialBoundedOrder
variable [PartialOrder Ξ±] [BoundedOrder Ξ±] {a : Ξ±}
@[simp]
theorem disjoint_top : Disjoint a β€ β a = β₯ :=
β¨fun h β¦ bot_unique <| h le_rfl le_top, fun h _ ha _ β¦ ha.trans_eq hβ©
@[simp]
theorem top_disjoint : Disjoint β€ a β a = β₯ :=
β¨fun h β¦ bot_unique <| h le_top le_rfl, fun h _ _ ha β¦ ha.trans_eq hβ©
end PartialBoundedOrder
section SemilatticeInfBot
variable [SemilatticeInf Ξ±] [OrderBot Ξ±] {a b c : Ξ±}
theorem disjoint_iff_inf_le : Disjoint a b β a β b β€ β₯ :=
β¨fun hd β¦ hd inf_le_left inf_le_right, fun h _ ha hb β¦ (le_inf ha hb).trans hβ©
theorem disjoint_iff : Disjoint a b β a β b = β₯ :=
disjoint_iff_inf_le.trans le_bot_iff
theorem Disjoint.le_bot : Disjoint a b β a β b β€ β₯ :=
disjoint_iff_inf_le.mp
theorem Disjoint.eq_bot : Disjoint a b β a β b = β₯ :=
bot_unique β Disjoint.le_bot
theorem disjoint_assoc : Disjoint (a β b) c β Disjoint a (b β c) := by
rw [disjoint_iff_inf_le, disjoint_iff_inf_le, inf_assoc]
theorem disjoint_left_comm : Disjoint a (b β c) β Disjoint b (a β c) := by
simp_rw [disjoint_iff_inf_le, inf_left_comm]
theorem disjoint_right_comm : Disjoint (a β b) c β Disjoint (a β c) b := by
simp_rw [disjoint_iff_inf_le, inf_right_comm]
variable (c)
theorem Disjoint.inf_left (h : Disjoint a b) : Disjoint (a β c) b :=
h.mono_left inf_le_left
theorem Disjoint.inf_left' (h : Disjoint a b) : Disjoint (c β a) b :=
h.mono_left inf_le_right
theorem Disjoint.inf_right (h : Disjoint a b) : Disjoint a (b β c) :=
h.mono_right inf_le_left
theorem Disjoint.inf_right' (h : Disjoint a b) : Disjoint a (c β b) :=
h.mono_right inf_le_right
variable {c}
theorem Disjoint.of_disjoint_inf_of_le (h : Disjoint (a β b) c) (hle : a β€ c) : Disjoint a b :=
disjoint_iff.2 <| h.eq_bot_of_le <| inf_le_of_left_le hle
theorem Disjoint.of_disjoint_inf_of_le' (h : Disjoint (a β b) c) (hle : b β€ c) : Disjoint a b :=
disjoint_iff.2 <| h.eq_bot_of_le <| inf_le_of_right_le hle
end SemilatticeInfBot
theorem Disjoint.right_lt_sup_of_left_ne_bot [SemilatticeSup Ξ±] [OrderBot Ξ±] {a b : Ξ±}
(h : Disjoint a b) (ha : a β β₯) : b < a β b :=
le_sup_right.lt_of_ne fun eq β¦ ha (le_bot_iff.mp <| h le_rfl <| sup_eq_right.mp eq.symm)
section DistribLatticeBot
variable [DistribLattice Ξ±] [OrderBot Ξ±] {a b c : Ξ±}
@[simp]
theorem disjoint_sup_left : Disjoint (a β b) c β Disjoint a c β§ Disjoint b c := by
simp only [disjoint_iff, inf_sup_right, sup_eq_bot_iff]
@[simp]
theorem disjoint_sup_right : Disjoint a (b β c) β Disjoint a b β§ Disjoint a c := by
simp only [disjoint_iff, inf_sup_left, sup_eq_bot_iff]
theorem Disjoint.sup_left (ha : Disjoint a c) (hb : Disjoint b c) : Disjoint (a β b) c :=
disjoint_sup_left.2 β¨ha, hbβ©
theorem Disjoint.sup_right (hb : Disjoint a b) (hc : Disjoint a c) : Disjoint a (b β c) :=
disjoint_sup_right.2 β¨hb, hcβ©
theorem Disjoint.left_le_of_le_sup_right (h : a β€ b β c) (hd : Disjoint a c) : a β€ b :=
le_of_inf_le_sup_le (le_trans hd.le_bot bot_le) <| sup_le h le_sup_right
theorem Disjoint.left_le_of_le_sup_left (h : a β€ c β b) (hd : Disjoint a c) : a β€ b :=
hd.left_le_of_le_sup_right <| by rwa [sup_comm]
end DistribLatticeBot
end Disjoint
section Codisjoint
section PartialOrderTop
variable [PartialOrder Ξ±] [OrderTop Ξ±] {a b c d : Ξ±}
/-- Two elements of a lattice are codisjoint if their sup is the top element.
Note that we define this without reference to `β`, as this allows us to talk about orders where
the supremum is not unique, or where implement `Sup` would require additional `Decidable`
arguments. -/
def Codisjoint (a b : Ξ±) : Prop :=
β β¦xβ¦, a β€ x β b β€ x β β€ β€ x
theorem codisjoint_comm : Codisjoint a b β Codisjoint b a :=
forall_congr' fun _ β¦ forall_swap
@[deprecated (since := "2024-11-23")] alias Codisjoint_comm := codisjoint_comm
@[symm]
theorem Codisjoint.symm β¦a b : Ξ±β¦ : Codisjoint a b β Codisjoint b a :=
codisjoint_comm.1
theorem symmetric_codisjoint : Symmetric (Codisjoint : Ξ± β Ξ± β Prop) :=
Codisjoint.symm
@[simp]
theorem codisjoint_top_left : Codisjoint β€ a := fun _ htop _ β¦ htop
@[simp]
theorem codisjoint_top_right : Codisjoint a β€ := fun _ _ htop β¦ htop
theorem Codisjoint.mono (hβ : a β€ b) (hβ : c β€ d) : Codisjoint a c β Codisjoint b d :=
fun h _ ha hc β¦ h (hβ.trans ha) (hβ.trans hc)
theorem Codisjoint.mono_left (h : a β€ b) : Codisjoint a c β Codisjoint b c :=
Codisjoint.mono h le_rfl
theorem Codisjoint.mono_right : b β€ c β Codisjoint a b β Codisjoint a c :=
Codisjoint.mono le_rfl
@[simp]
theorem codisjoint_self : Codisjoint a a β a = β€ :=
β¨fun hd β¦ top_unique <| hd le_rfl le_rfl, fun h _ ha _ β¦ h.symm.trans_le haβ©
/- TODO: Rename `Codisjoint.eq_top` to `Codisjoint.sup_eq` and `Codisjoint.eq_top_of_self` to
`Codisjoint.eq_top` -/
alias β¨Codisjoint.eq_top_of_self, _β© := codisjoint_self
theorem Codisjoint.ne (ha : a β β€) (hab : Codisjoint a b) : a β b :=
fun h β¦ ha <| codisjoint_self.1 <| by rwa [β h] at hab
theorem Codisjoint.eq_top_of_le (hab : Codisjoint a b) (h : b β€ a) : a = β€ :=
eq_top_iff.2 <| hab le_rfl h
theorem Codisjoint.eq_top_of_ge (hab : Codisjoint a b) : a β€ b β b = β€ :=
hab.symm.eq_top_of_le
lemma Codisjoint.eq_iff (hab : Codisjoint a b) : a = b β a = β€ β§ b = β€ := by aesop
lemma Codisjoint.ne_iff (hab : Codisjoint a b) : a β b β a β β€ β¨ b β β€ :=
hab.eq_iff.not.trans not_and_or
end PartialOrderTop
section PartialBoundedOrder
variable [PartialOrder Ξ±] [BoundedOrder Ξ±] {a b : Ξ±}
@[simp]
theorem codisjoint_bot : Codisjoint a β₯ β a = β€ :=
β¨fun h β¦ top_unique <| h le_rfl bot_le, fun h _ ha _ β¦ h.symm.trans_le haβ©
@[simp]
theorem bot_codisjoint : Codisjoint β₯ a β a = β€ :=
β¨fun h β¦ top_unique <| h bot_le le_rfl, fun h _ _ ha β¦ h.symm.trans_le haβ©
lemma Codisjoint.ne_bot_of_ne_top (h : Codisjoint a b) (ha : a β β€) : b β β₯ := by
rintro rfl; exact ha <| by simpa using h
lemma Codisjoint.ne_bot_of_ne_top' (h : Codisjoint a b) (hb : b β β€) : a β β₯ := by
rintro rfl; exact hb <| by simpa using h
end PartialBoundedOrder
section SemilatticeSupTop
variable [SemilatticeSup Ξ±] [OrderTop Ξ±] {a b c : Ξ±}
theorem codisjoint_iff_le_sup : Codisjoint a b β β€ β€ a β b :=
@disjoint_iff_inf_le Ξ±α΅α΅ _ _ _ _
theorem codisjoint_iff : Codisjoint a b β a β b = β€ :=
@disjoint_iff Ξ±α΅α΅ _ _ _ _
theorem Codisjoint.top_le : Codisjoint a b β β€ β€ a β b :=
@Disjoint.le_bot Ξ±α΅α΅ _ _ _ _
theorem Codisjoint.eq_top : Codisjoint a b β a β b = β€ :=
@Disjoint.eq_bot Ξ±α΅α΅ _ _ _ _
theorem codisjoint_assoc : Codisjoint (a β b) c β Codisjoint a (b β c) :=
@disjoint_assoc Ξ±α΅α΅ _ _ _ _ _
theorem codisjoint_left_comm : Codisjoint a (b β c) β Codisjoint b (a β c) :=
@disjoint_left_comm Ξ±α΅α΅ _ _ _ _ _
theorem codisjoint_right_comm : Codisjoint (a β b) c β Codisjoint (a β c) b :=
@disjoint_right_comm Ξ±α΅α΅ _ _ _ _ _
variable (c)
theorem Codisjoint.sup_left (h : Codisjoint a b) : Codisjoint (a β c) b :=
h.mono_left le_sup_left
theorem Codisjoint.sup_left' (h : Codisjoint a b) : Codisjoint (c β a) b :=
h.mono_left le_sup_right
theorem Codisjoint.sup_right (h : Codisjoint a b) : Codisjoint a (b β c) :=
h.mono_right le_sup_left
theorem Codisjoint.sup_right' (h : Codisjoint a b) : Codisjoint a (c β b) :=
h.mono_right le_sup_right
variable {c}
theorem Codisjoint.of_codisjoint_sup_of_le (h : Codisjoint (a β b) c) (hle : c β€ a) :
Codisjoint a b :=
@Disjoint.of_disjoint_inf_of_le Ξ±α΅α΅ _ _ _ _ _ h hle
theorem Codisjoint.of_codisjoint_sup_of_le' (h : Codisjoint (a β b) c) (hle : c β€ b) :
Codisjoint a b :=
@Disjoint.of_disjoint_inf_of_le' Ξ±α΅α΅ _ _ _ _ _ h hle
end SemilatticeSupTop
section DistribLatticeTop
variable [DistribLattice Ξ±] [OrderTop Ξ±] {a b c : Ξ±}
@[simp]
theorem codisjoint_inf_left : Codisjoint (a β b) c β Codisjoint a c β§ Codisjoint b c := by
simp only [codisjoint_iff, sup_inf_right, inf_eq_top_iff]
@[simp]
theorem codisjoint_inf_right : Codisjoint a (b β c) β Codisjoint a b β§ Codisjoint a c := by
simp only [codisjoint_iff, sup_inf_left, inf_eq_top_iff]
theorem Codisjoint.inf_left (ha : Codisjoint a c) (hb : Codisjoint b c) : Codisjoint (a β b) c :=
codisjoint_inf_left.2 β¨ha, hbβ©
theorem Codisjoint.inf_right (hb : Codisjoint a b) (hc : Codisjoint a c) : Codisjoint a (b β c) :=
codisjoint_inf_right.2 β¨hb, hcβ©
theorem Codisjoint.left_le_of_le_inf_right (h : a β b β€ c) (hd : Codisjoint b c) : a β€ c :=
@Disjoint.left_le_of_le_sup_right Ξ±α΅α΅ _ _ _ _ _ h hd.symm
theorem Codisjoint.left_le_of_le_inf_left (h : b β a β€ c) (hd : Codisjoint b c) : a β€ c :=
hd.left_le_of_le_inf_right <| by rwa [inf_comm]
end DistribLatticeTop
end Codisjoint
open OrderDual
theorem Disjoint.dual [PartialOrder Ξ±] [OrderBot Ξ±] {a b : Ξ±} :
Disjoint a b β Codisjoint (toDual a) (toDual b) :=
id
theorem Codisjoint.dual [PartialOrder Ξ±] [OrderTop Ξ±] {a b : Ξ±} :
Codisjoint a b β Disjoint (toDual a) (toDual b) :=
id
@[simp]
theorem disjoint_toDual_iff [PartialOrder Ξ±] [OrderTop Ξ±] {a b : Ξ±} :
Disjoint (toDual a) (toDual b) β Codisjoint a b :=
Iff.rfl
@[simp]
theorem disjoint_ofDual_iff [PartialOrder Ξ±] [OrderBot Ξ±] {a b : Ξ±α΅α΅} :
Disjoint (ofDual a) (ofDual b) β Codisjoint a b :=
Iff.rfl
@[simp]
theorem codisjoint_toDual_iff [PartialOrder Ξ±] [OrderBot Ξ±] {a b : Ξ±} :
Codisjoint (toDual a) (toDual b) β Disjoint a b :=
Iff.rfl
@[simp]
theorem codisjoint_ofDual_iff [PartialOrder Ξ±] [OrderTop Ξ±] {a b : Ξ±α΅α΅} :
Codisjoint (ofDual a) (ofDual b) β Disjoint a b :=
Iff.rfl
section DistribLattice
variable [DistribLattice Ξ±] [BoundedOrder Ξ±] {a b c : Ξ±}
theorem Disjoint.le_of_codisjoint (hab : Disjoint a b) (hbc : Codisjoint b c) : a β€ c := by
rw [β @inf_top_eq _ _ _ a, β @bot_sup_eq _ _ _ c, β hab.eq_bot, β hbc.eq_top, sup_inf_right]
exact inf_le_inf_right _ le_sup_left
end DistribLattice
section IsCompl
/-- Two elements `x` and `y` are complements of each other if `x β y = β€` and `x β y = β₯`. -/
structure IsCompl [PartialOrder Ξ±] [BoundedOrder Ξ±] (x y : Ξ±) : Prop where
/-- If `x` and `y` are to be complementary in an order, they should be disjoint. -/
protected disjoint : Disjoint x y
/-- If `x` and `y` are to be complementary in an order, they should be codisjoint. -/
protected codisjoint : Codisjoint x y
theorem isCompl_iff [PartialOrder Ξ±] [BoundedOrder Ξ±] {a b : Ξ±} :
IsCompl a b β Disjoint a b β§ Codisjoint a b :=
β¨fun h β¦ β¨h.1, h.2β©, fun h β¦ β¨h.1, h.2β©β©
namespace IsCompl
section BoundedPartialOrder
variable [PartialOrder Ξ±] [BoundedOrder Ξ±] {x y : Ξ±}
@[symm]
protected theorem symm (h : IsCompl x y) : IsCompl y x :=
β¨h.1.symm, h.2.symmβ©
lemma _root_.isCompl_comm : IsCompl x y β IsCompl y x := β¨IsCompl.symm, IsCompl.symmβ©
theorem dual (h : IsCompl x y) : IsCompl (toDual x) (toDual y) :=
β¨h.2, h.1β©
theorem ofDual {a b : Ξ±α΅α΅} (h : IsCompl a b) : IsCompl (ofDual a) (ofDual b) :=
β¨h.2, h.1β©
end BoundedPartialOrder
section BoundedLattice
variable [Lattice Ξ±] [BoundedOrder Ξ±] {x y : Ξ±}
theorem of_le (hβ : x β y β€ β₯) (hβ : β€ β€ x β y) : IsCompl x y :=
β¨disjoint_iff_inf_le.mpr hβ, codisjoint_iff_le_sup.mpr hββ©
theorem of_eq (hβ : x β y = β₯) (hβ : x β y = β€) : IsCompl x y :=
β¨disjoint_iff.mpr hβ, codisjoint_iff.mpr hββ©
theorem inf_eq_bot (h : IsCompl x y) : x β y = β₯ :=
h.disjoint.eq_bot
theorem sup_eq_top (h : IsCompl x y) : x β y = β€ :=
h.codisjoint.eq_top
end BoundedLattice
variable [DistribLattice Ξ±] [BoundedOrder Ξ±] {a b x y z : Ξ±}
theorem inf_left_le_of_le_sup_right (h : IsCompl x y) (hle : a β€ b β y) : a β x β€ b :=
calc
a β x β€ (b β y) β x := inf_le_inf hle le_rfl
_ = b β x β y β x := inf_sup_right _ _ _
_ = b β x := by rw [h.symm.inf_eq_bot, sup_bot_eq]
_ β€ b := inf_le_left
theorem le_sup_right_iff_inf_left_le {a b} (h : IsCompl x y) : a β€ b β y β a β x β€ b :=
β¨h.inf_left_le_of_le_sup_right, h.symm.dual.inf_left_le_of_le_sup_rightβ©
theorem inf_left_eq_bot_iff (h : IsCompl y z) : x β y = β₯ β x β€ z := by
rw [β le_bot_iff, β h.le_sup_right_iff_inf_left_le, bot_sup_eq]
theorem inf_right_eq_bot_iff (h : IsCompl y z) : x β z = β₯ β x β€ y :=
h.symm.inf_left_eq_bot_iff
theorem disjoint_left_iff (h : IsCompl y z) : Disjoint x y β x β€ z := by
rw [disjoint_iff]
exact h.inf_left_eq_bot_iff
theorem disjoint_right_iff (h : IsCompl y z) : Disjoint x z β x β€ y :=
h.symm.disjoint_left_iff
theorem le_left_iff (h : IsCompl x y) : z β€ x β Disjoint z y :=
h.disjoint_right_iff.symm
theorem le_right_iff (h : IsCompl x y) : z β€ y β Disjoint z x :=
h.symm.le_left_iff
theorem left_le_iff (h : IsCompl x y) : x β€ z β Codisjoint z y :=
h.dual.le_left_iff
theorem right_le_iff (h : IsCompl x y) : y β€ z β Codisjoint z x :=
h.symm.left_le_iff
protected theorem Antitone {x' y'} (h : IsCompl x y) (h' : IsCompl x' y') (hx : x β€ x') : y' β€ y :=
h'.right_le_iff.2 <| h.symm.codisjoint.mono_right hx
theorem right_unique (hxy : IsCompl x y) (hxz : IsCompl x z) : y = z :=
le_antisymm (hxz.Antitone hxy <| le_refl x) (hxy.Antitone hxz <| le_refl x)
theorem left_unique (hxz : IsCompl x z) (hyz : IsCompl y z) : x = y :=
hxz.symm.right_unique hyz.symm
theorem sup_inf {x' y'} (h : IsCompl x y) (h' : IsCompl x' y') : IsCompl (x β x') (y β y') :=
of_eq
(by rw [inf_sup_right, β inf_assoc, h.inf_eq_bot, bot_inf_eq, bot_sup_eq, inf_left_comm,
h'.inf_eq_bot, inf_bot_eq])
(by rw [sup_inf_left, sup_comm x, sup_assoc, h.sup_eq_top, sup_top_eq, top_inf_eq,
sup_assoc, sup_left_comm, h'.sup_eq_top, sup_top_eq])
theorem inf_sup {x' y'} (h : IsCompl x y) (h' : IsCompl x' y') : IsCompl (x β x') (y β y') :=
(h.symm.sup_inf h'.symm).symm
end IsCompl
namespace Prod
variable {Ξ² : Type*} [PartialOrder Ξ±] [PartialOrder Ξ²]
protected theorem disjoint_iff [OrderBot Ξ±] [OrderBot Ξ²] {x y : Ξ± Γ Ξ²} :
Disjoint x y β Disjoint x.1 y.1 β§ Disjoint x.2 y.2 := by
constructor
Β· intro h
refine β¨fun a hx hy β¦ (@h (a, β₯) β¨hx, ?_β© β¨hy, ?_β©).1,
fun b hx hy β¦ (@h (β₯, b) β¨?_, hxβ© β¨?_, hyβ©).2β©
all_goals exact bot_le
Β· rintro β¨ha, hbβ© z hza hzb
exact β¨ha hza.1 hzb.1, hb hza.2 hzb.2β©
protected theorem codisjoint_iff [OrderTop Ξ±] [OrderTop Ξ²] {x y : Ξ± Γ Ξ²} :
Codisjoint x y β Codisjoint x.1 y.1 β§ Codisjoint x.2 y.2 :=
@Prod.disjoint_iff Ξ±α΅α΅ Ξ²α΅α΅ _ _ _ _ _ _
protected theorem isCompl_iff [BoundedOrder Ξ±] [BoundedOrder Ξ²] {x y : Ξ± Γ Ξ²} :
IsCompl x y β IsCompl x.1 y.1 β§ IsCompl x.2 y.2 := by
simp_rw [isCompl_iff, Prod.disjoint_iff, Prod.codisjoint_iff, and_and_and_comm]
end Prod
section
variable [Lattice Ξ±] [BoundedOrder Ξ±] {a b x : Ξ±}
@[simp]
theorem isCompl_toDual_iff : IsCompl (toDual a) (toDual b) β IsCompl a b :=
β¨IsCompl.ofDual, IsCompl.dualβ©
@[simp]
theorem isCompl_ofDual_iff {a b : Ξ±α΅α΅} : IsCompl (ofDual a) (ofDual b) β IsCompl a b :=
β¨IsCompl.dual, IsCompl.ofDualβ©
theorem isCompl_bot_top : IsCompl (β₯ : Ξ±) β€ :=
IsCompl.of_eq (bot_inf_eq _) (sup_top_eq _)
theorem isCompl_top_bot : IsCompl (β€ : Ξ±) β₯ :=
IsCompl.of_eq (inf_bot_eq _) (top_sup_eq _)
| Mathlib/Order/Disjoint.lean | 548 | 550 | theorem eq_top_of_isCompl_bot (h : IsCompl x β₯) : x = β€ := by | rw [β sup_bot_eq x, h.sup_eq_top]
theorem eq_top_of_bot_isCompl (h : IsCompl β₯ x) : x = β€ := |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.CategoryTheory.Monoidal.NaturalTransformation
import Mathlib.CategoryTheory.Monoidal.Opposite
import Mathlib.Tactic.CategoryTheory.Monoidal.Basic
import Mathlib.CategoryTheory.CommSq
/-!
# Braided and symmetric monoidal categories
The basic definitions of braided monoidal categories, and symmetric monoidal categories,
as well as braided functors.
## Implementation note
We make `BraidedCategory` another typeclass, but then have `SymmetricCategory` extend this.
The rationale is that we are not carrying any additional data, just requiring a property.
## Future work
* Construct the Drinfeld center of a monoidal category as a braided monoidal category.
* Say something about pseudo-natural transformations.
## References
* [Pavel Etingof, Shlomo Gelaki, Dmitri Nikshych, Victor Ostrik, *Tensor categories*][egno15]
-/
universe v vβ vβ vβ u uβ uβ uβ
namespace CategoryTheory
open Category MonoidalCategory Functor.LaxMonoidal Functor.OplaxMonoidal Functor.Monoidal
/-- A braided monoidal category is a monoidal category equipped with a braiding isomorphism
`Ξ²_ X Y : X β Y β
Y β X`
which is natural in both arguments,
and also satisfies the two hexagon identities.
-/
class BraidedCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where
/-- The braiding natural isomorphism. -/
braiding : β X Y : C, X β Y β
Y β X
braiding_naturality_right :
β (X : C) {Y Z : C} (f : Y βΆ Z),
X β f β« (braiding X Z).hom = (braiding X Y).hom β« f β· X := by
aesop_cat
braiding_naturality_left :
β {X Y : C} (f : X βΆ Y) (Z : C),
f β· Z β« (braiding Y Z).hom = (braiding X Z).hom β« Z β f := by
aesop_cat
/-- The first hexagon identity. -/
hexagon_forward :
β X Y Z : C,
(Ξ±_ X Y Z).hom β« (braiding X (Y β Z)).hom β« (Ξ±_ Y Z X).hom =
((braiding X Y).hom β· Z) β« (Ξ±_ Y X Z).hom β« (Y β (braiding X Z).hom) := by
aesop_cat
/-- The second hexagon identity. -/
hexagon_reverse :
β X Y Z : C,
(Ξ±_ X Y Z).inv β« (braiding (X β Y) Z).hom β« (Ξ±_ Z X Y).inv =
(X β (braiding Y Z).hom) β« (Ξ±_ X Z Y).inv β« ((braiding X Z).hom β· Y) := by
aesop_cat
attribute [reassoc (attr := simp)]
BraidedCategory.braiding_naturality_left
BraidedCategory.braiding_naturality_right
attribute [reassoc] BraidedCategory.hexagon_forward BraidedCategory.hexagon_reverse
open BraidedCategory
@[inherit_doc]
notation "Ξ²_" => BraidedCategory.braiding
namespace BraidedCategory
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] [BraidedCategory.{v} C]
@[simp, reassoc]
theorem braiding_tensor_left (X Y Z : C) :
(Ξ²_ (X β Y) Z).hom =
(Ξ±_ X Y Z).hom β« X β (Ξ²_ Y Z).hom β« (Ξ±_ X Z Y).inv β«
(Ξ²_ X Z).hom β· Y β« (Ξ±_ Z X Y).hom := by
apply (cancel_epi (Ξ±_ X Y Z).inv).1
apply (cancel_mono (Ξ±_ Z X Y).inv).1
simp [hexagon_reverse]
@[simp, reassoc]
theorem braiding_tensor_right (X Y Z : C) :
(Ξ²_ X (Y β Z)).hom =
(Ξ±_ X Y Z).inv β« (Ξ²_ X Y).hom β· Z β« (Ξ±_ Y X Z).hom β«
Y β (Ξ²_ X Z).hom β« (Ξ±_ Y Z X).inv := by
apply (cancel_epi (Ξ±_ X Y Z).hom).1
apply (cancel_mono (Ξ±_ Y Z X).hom).1
simp [hexagon_forward]
@[simp, reassoc]
theorem braiding_inv_tensor_left (X Y Z : C) :
(Ξ²_ (X β Y) Z).inv =
(Ξ±_ Z X Y).inv β« (Ξ²_ X Z).inv β· Y β« (Ξ±_ X Z Y).hom β«
X β (Ξ²_ Y Z).inv β« (Ξ±_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[simp, reassoc]
theorem braiding_inv_tensor_right (X Y Z : C) :
(Ξ²_ X (Y β Z)).inv =
(Ξ±_ Y Z X).hom β« Y β (Ξ²_ X Z).inv β« (Ξ±_ Y X Z).inv β«
(Ξ²_ X Y).inv β· Z β« (Ξ±_ X Y Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
theorem braiding_naturality {X X' Y Y' : C} (f : X βΆ Y) (g : X' βΆ Y') :
(f β g) β« (braiding Y Y').hom = (braiding X X').hom β« (g β f) := by
rw [tensorHom_def' f g, tensorHom_def g f]
simp_rw [Category.assoc, braiding_naturality_left, braiding_naturality_right_assoc]
@[reassoc (attr := simp)]
theorem braiding_inv_naturality_right (X : C) {Y Z : C} (f : Y βΆ Z) :
X β f β« (Ξ²_ Z X).inv = (Ξ²_ Y X).inv β« f β· X :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality_left f X
@[reassoc (attr := simp)]
theorem braiding_inv_naturality_left {X Y : C} (f : X βΆ Y) (Z : C) :
f β· Z β« (Ξ²_ Z Y).inv = (Ξ²_ Z X).inv β« Z β f :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality_right Z f
@[reassoc (attr := simp)]
theorem braiding_inv_naturality {X X' Y Y' : C} (f : X βΆ Y) (g : X' βΆ Y') :
(f β g) β« (Ξ²_ Y' Y).inv = (Ξ²_ X' X).inv β« (g β f) :=
CommSq.w <| .vert_inv <| .mk <| braiding_naturality g f
/-- In a braided monoidal category, the functors `tensorLeft X` and
`tensorRight X` are isomorphic. -/
@[simps]
def tensorLeftIsoTensorRight (X : C) :
tensorLeft X β
tensorRight X where
hom := { app Y := (Ξ²_ X Y).hom }
inv := { app Y := (Ξ²_ X Y).inv }
@[reassoc]
theorem yang_baxter (X Y Z : C) :
(Ξ±_ X Y Z).inv β« (Ξ²_ X Y).hom β· Z β« (Ξ±_ Y X Z).hom β«
Y β (Ξ²_ X Z).hom β« (Ξ±_ Y Z X).inv β« (Ξ²_ Y Z).hom β· X β« (Ξ±_ Z Y X).hom =
X β (Ξ²_ Y Z).hom β« (Ξ±_ X Z Y).inv β« (Ξ²_ X Z).hom β· Y β«
(Ξ±_ Z X Y).hom β« Z β (Ξ²_ X Y).hom := by
rw [β braiding_tensor_right_assoc X Y Z, β cancel_mono (Ξ±_ Z Y X).inv]
repeat rw [assoc]
rw [Iso.hom_inv_id, comp_id, β braiding_naturality_right, braiding_tensor_right]
theorem yang_baxter' (X Y Z : C) :
(Ξ²_ X Y).hom β· Z ββ« Y β (Ξ²_ X Z).hom ββ« (Ξ²_ Y Z).hom β· X =
π _ ββ« (X β (Ξ²_ Y Z).hom ββ« (Ξ²_ X Z).hom β· Y ββ« Z β (Ξ²_ X Y).hom) ββ« π _ := by
rw [β cancel_epi (Ξ±_ X Y Z).inv, β cancel_mono (Ξ±_ Z Y X).hom]
convert yang_baxter X Y Z using 1
all_goals monoidal
theorem yang_baxter_iso (X Y Z : C) :
(Ξ±_ X Y Z).symm βͺβ« whiskerRightIso (Ξ²_ X Y) Z βͺβ« Ξ±_ Y X Z βͺβ«
whiskerLeftIso Y (Ξ²_ X Z) βͺβ« (Ξ±_ Y Z X).symm βͺβ«
whiskerRightIso (Ξ²_ Y Z) X βͺβ« (Ξ±_ Z Y X) =
whiskerLeftIso X (Ξ²_ Y Z) βͺβ« (Ξ±_ X Z Y).symm βͺβ«
whiskerRightIso (Ξ²_ X Z) Y βͺβ« Ξ±_ Z X Y βͺβ«
whiskerLeftIso Z (Ξ²_ X Y) := Iso.ext (yang_baxter X Y Z)
theorem hexagon_forward_iso (X Y Z : C) :
Ξ±_ X Y Z βͺβ« Ξ²_ X (Y β Z) βͺβ« Ξ±_ Y Z X =
whiskerRightIso (Ξ²_ X Y) Z βͺβ« Ξ±_ Y X Z βͺβ« whiskerLeftIso Y (Ξ²_ X Z) :=
Iso.ext (hexagon_forward X Y Z)
theorem hexagon_reverse_iso (X Y Z : C) :
(Ξ±_ X Y Z).symm βͺβ« Ξ²_ (X β Y) Z βͺβ« (Ξ±_ Z X Y).symm =
whiskerLeftIso X (Ξ²_ Y Z) βͺβ« (Ξ±_ X Z Y).symm βͺβ« whiskerRightIso (Ξ²_ X Z) Y :=
Iso.ext (hexagon_reverse X Y Z)
@[reassoc]
theorem hexagon_forward_inv (X Y Z : C) :
(Ξ±_ Y Z X).inv β« (Ξ²_ X (Y β Z)).inv β« (Ξ±_ X Y Z).inv =
Y β (Ξ²_ X Z).inv β« (Ξ±_ Y X Z).inv β« (Ξ²_ X Y).inv β· Z := by
simp
@[reassoc]
theorem hexagon_reverse_inv (X Y Z : C) :
(Ξ±_ Z X Y).hom β« (Ξ²_ (X β Y) Z).inv β« (Ξ±_ X Y Z).hom =
(Ξ²_ X Z).inv β· Y β« (Ξ±_ X Z Y).hom β« X β (Ξ²_ Y Z).inv := by
simp
end BraidedCategory
/--
Verifying the axioms for a braiding by checking that the candidate braiding is sent to a braiding
by a faithful monoidal functor.
-/
def braidedCategoryOfFaithful {C D : Type*} [Category C] [Category D] [MonoidalCategory C]
[MonoidalCategory D] (F : C β₯€ D) [F.Monoidal] [F.Faithful] [BraidedCategory D]
(Ξ² : β X Y : C, X β Y β
Y β X)
(w : β X Y, ΞΌ F _ _ β« F.map (Ξ² X Y).hom = (Ξ²_ _ _).hom β« ΞΌ F _ _) : BraidedCategory C where
braiding := Ξ²
braiding_naturality_left := by
intros
apply F.map_injective
refine (cancel_epi (ΞΌ F ?_ ?_)).1 ?_
rw [Functor.map_comp, β ΞΌ_natural_left_assoc, w, Functor.map_comp,
reassoc_of% w, braiding_naturality_left_assoc, ΞΌ_natural_right]
braiding_naturality_right := by
intros
apply F.map_injective
refine (cancel_epi (ΞΌ F ?_ ?_)).1 ?_
rw [Functor.map_comp, β ΞΌ_natural_right_assoc, w, Functor.map_comp,
reassoc_of% w, braiding_naturality_right_assoc, ΞΌ_natural_left]
hexagon_forward := by
intros
apply F.map_injective
refine (cancel_epi (ΞΌ F _ _)).1 ?_
refine (cancel_epi (ΞΌ F _ _ β· _)).1 ?_
rw [Functor.map_comp, Functor.map_comp, Functor.map_comp, Functor.map_comp, β
ΞΌ_natural_left_assoc, β comp_whiskerRight_assoc, w,
comp_whiskerRight_assoc, Functor.LaxMonoidal.associativity_assoc,
Functor.LaxMonoidal.associativity_assoc, β ΞΌ_natural_right, β
MonoidalCategory.whiskerLeft_comp_assoc, w, MonoidalCategory.whiskerLeft_comp_assoc,
reassoc_of% w, braiding_naturality_right_assoc,
Functor.LaxMonoidal.associativity, hexagon_forward_assoc]
hexagon_reverse := by
intros
apply F.map_injective
refine (cancel_epi (ΞΌ F _ _)).1 ?_
refine (cancel_epi (_ β ΞΌ F _ _)).1 ?_
rw [Functor.map_comp, Functor.map_comp, Functor.map_comp, Functor.map_comp, β
ΞΌ_natural_right_assoc, β MonoidalCategory.whiskerLeft_comp_assoc, w,
MonoidalCategory.whiskerLeft_comp_assoc, Functor.LaxMonoidal.associativity_inv_assoc,
Functor.LaxMonoidal.associativity_inv_assoc, β ΞΌ_natural_left,
β comp_whiskerRight_assoc, w, comp_whiskerRight_assoc, reassoc_of% w,
braiding_naturality_left_assoc, Functor.LaxMonoidal.associativity_inv, hexagon_reverse_assoc]
/-- Pull back a braiding along a fully faithful monoidal functor. -/
noncomputable def braidedCategoryOfFullyFaithful {C D : Type*} [Category C] [Category D]
[MonoidalCategory C] [MonoidalCategory D] (F : C β₯€ D) [F.Monoidal] [F.Full]
[F.Faithful] [BraidedCategory D] : BraidedCategory C :=
braidedCategoryOfFaithful F
(fun X Y => F.preimageIso
((ΞΌIso F _ _).symm βͺβ« Ξ²_ (F.obj X) (F.obj Y) βͺβ« (ΞΌIso F _ _)))
(by simp)
section
/-!
We now establish how the braiding interacts with the unitors.
I couldn't find a detailed proof in print, but this is discussed in:
* Proposition 1 of AndrΓ© Joyal and Ross Street,
"Braided monoidal categories", Macquarie Math Reports 860081 (1986).
* Proposition 2.1 of AndrΓ© Joyal and Ross Street,
"Braided tensor categories" , Adv. Math. 102 (1993), 20β78.
* Exercise 8.1.6 of Etingof, Gelaki, Nikshych, Ostrik,
"Tensor categories", vol 25, Mathematical Surveys and Monographs (2015), AMS.
-/
variable {C : Type uβ} [Category.{vβ} C] [MonoidalCategory C] [BraidedCategory C]
theorem braiding_leftUnitor_auxβ (X : C) :
(Ξ±_ (π_ C) (π_ C) X).hom β«
(π_ C β (Ξ²_ X (π_ C)).inv) β« (Ξ±_ _ X _).inv β« ((Ξ»_ X).hom β· _) =
((Ξ»_ _).hom β· X) β« (Ξ²_ X (π_ C)).inv := by
monoidal
theorem braiding_leftUnitor_auxβ (X : C) :
((Ξ²_ X (π_ C)).hom β· π_ C) β« ((Ξ»_ X).hom β· π_ C) = (Ο_ X).hom β· π_ C :=
calc
((Ξ²_ X (π_ C)).hom β· π_ C) β« ((Ξ»_ X).hom β· π_ C) =
((Ξ²_ X (π_ C)).hom β· π_ C) β« (Ξ±_ _ _ _).hom β« (Ξ±_ _ _ _).inv β« ((Ξ»_ X).hom β· π_ C) := by
monoidal
_ = ((Ξ²_ X (π_ C)).hom β· π_ C) β« (Ξ±_ _ _ _).hom β« (_ β (Ξ²_ X _).hom) β«
(_ β (Ξ²_ X _).inv) β« (Ξ±_ _ _ _).inv β« ((Ξ»_ X).hom β· π_ C) := by simp
_ = (Ξ±_ _ _ _).hom β« (Ξ²_ _ _).hom β« (Ξ±_ _ _ _).hom β« (_ β (Ξ²_ X _).inv) β« (Ξ±_ _ _ _).inv β«
((Ξ»_ X).hom β· π_ C) := by simp
_ = (Ξ±_ _ _ _).hom β« (Ξ²_ _ _).hom β« ((Ξ»_ _).hom β· X) β« (Ξ²_ X _).inv := by
rw [braiding_leftUnitor_auxβ]
_ = (Ξ±_ _ _ _).hom β« (_ β (Ξ»_ _).hom) β« (Ξ²_ _ _).hom β« (Ξ²_ X _).inv := by
(slice_lhs 2 3 => rw [β braiding_naturality_right]); simp only [assoc]
_ = (Ξ±_ _ _ _).hom β« (_ β (Ξ»_ _).hom) := by rw [Iso.hom_inv_id, comp_id]
_ = (Ο_ X).hom β· π_ C := by rw [triangle]
@[reassoc]
theorem braiding_leftUnitor (X : C) : (Ξ²_ X (π_ C)).hom β« (Ξ»_ X).hom = (Ο_ X).hom := by
rw [β whiskerRight_iff, comp_whiskerRight, braiding_leftUnitor_auxβ]
theorem braiding_rightUnitor_auxβ (X : C) :
(Ξ±_ X (π_ C) (π_ C)).inv β«
((Ξ²_ (π_ C) X).inv β· π_ C) β« (Ξ±_ _ X _).hom β« (_ β (Ο_ X).hom) =
(X β (Ο_ _).hom) β« (Ξ²_ (π_ C) X).inv := by
monoidal
theorem braiding_rightUnitor_auxβ (X : C) :
(π_ C β (Ξ²_ (π_ C) X).hom) β« (π_ C β (Ο_ X).hom) = π_ C β (Ξ»_ X).hom :=
calc
(π_ C β (Ξ²_ (π_ C) X).hom) β« (π_ C β (Ο_ X).hom) =
(π_ C β (Ξ²_ (π_ C) X).hom) β« (Ξ±_ _ _ _).inv β« (Ξ±_ _ _ _).hom β« (π_ C β (Ο_ X).hom) := by
monoidal
_ = (π_ C β (Ξ²_ (π_ C) X).hom) β« (Ξ±_ _ _ _).inv β« ((Ξ²_ _ X).hom β· _) β«
((Ξ²_ _ X).inv β· _) β« (Ξ±_ _ _ _).hom β« (π_ C β (Ο_ X).hom) := by
simp
_ = (Ξ±_ _ _ _).inv β« (Ξ²_ _ _).hom β« (Ξ±_ _ _ _).inv β« ((Ξ²_ _ X).inv β· _) β« (Ξ±_ _ _ _).hom β«
(π_ C β (Ο_ X).hom) := by
(slice_lhs 1 3 => rw [β hexagon_reverse]); simp only [assoc]
_ = (Ξ±_ _ _ _).inv β« (Ξ²_ _ _).hom β« (X β (Ο_ _).hom) β« (Ξ²_ _ X).inv := by simp
_ = (Ξ±_ _ _ _).inv β« ((Ο_ _).hom β· _) β« (Ξ²_ _ X).hom β« (Ξ²_ _ _).inv := by
(slice_lhs 2 3 => rw [β braiding_naturality_left]); simp only [assoc]
_ = (Ξ±_ _ _ _).inv β« ((Ο_ _).hom β· _) := by rw [Iso.hom_inv_id, comp_id]
_ = π_ C β (Ξ»_ X).hom := by rw [triangle_assoc_comp_right]
@[reassoc]
theorem braiding_rightUnitor (X : C) : (Ξ²_ (π_ C) X).hom β« (Ο_ X).hom = (Ξ»_ X).hom := by
rw [β whiskerLeft_iff, MonoidalCategory.whiskerLeft_comp, braiding_rightUnitor_auxβ]
@[reassoc, simp]
theorem braiding_tensorUnit_left (X : C) : (Ξ²_ (π_ C) X).hom = (Ξ»_ X).hom β« (Ο_ X).inv := by
simp [β braiding_rightUnitor]
@[reassoc, simp]
theorem braiding_inv_tensorUnit_left (X : C) : (Ξ²_ (π_ C) X).inv = (Ο_ X).hom β« (Ξ»_ X).inv := by
rw [Iso.inv_ext]
rw [braiding_tensorUnit_left]
monoidal
@[reassoc]
| Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean | 332 | 333 | theorem leftUnitor_inv_braiding (X : C) : (Ξ»_ X).inv β« (Ξ²_ (π_ C) X).hom = (Ο_ X).inv := by | simp |
/-
Copyright (c) 2019 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison, Jakob von Raumer
-/
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
import Mathlib.CategoryTheory.Limits.Shapes.Kernels
/-!
# Biproducts and binary biproducts
We introduce the notion of (finite) biproducts.
Binary biproducts are defined in `CategoryTheory.Limits.Shapes.BinaryBiproducts`.
These are slightly unusual relative to the other shapes in the library,
as they are simultaneously limits and colimits.
(Zero objects are similar; they are "biterminal".)
For results about biproducts in preadditive categories see
`CategoryTheory.Preadditive.Biproducts`.
For biproducts indexed by a `Fintype J`, a `bicone` consists of a cone point `X`
and morphisms `Ο j : X βΆ F j` and `ΞΉ j : F j βΆ X` for each `j`,
such that `ΞΉ j β« Ο j'` is the identity when `j = j'` and zero otherwise.
## Notation
As `β` is already taken for the sum of types, we introduce the notation `X β Y` for
a binary biproduct. We introduce `β¨ f` for the indexed biproduct.
## Implementation notes
Prior to https://github.com/leanprover-community/mathlib3/pull/14046,
`HasFiniteBiproducts` required a `DecidableEq` instance on the indexing type.
As this had no pay-off (everything about limits is non-constructive in mathlib),
and occasional cost
(constructing decidability instances appropriate for constructions involving the indexing type),
we made everything classical.
-/
noncomputable section
universe w w' v u
open CategoryTheory Functor
namespace CategoryTheory.Limits
variable {J : Type w}
universe uC' uC uD' uD
variable {C : Type uC} [Category.{uC'} C] [HasZeroMorphisms C]
variable {D : Type uD} [Category.{uD'} D] [HasZeroMorphisms D]
open scoped Classical in
/-- A `c : Bicone F` is:
* an object `c.pt` and
* morphisms `Ο j : pt βΆ F j` and `ΞΉ j : F j βΆ pt` for each `j`,
* such that `ΞΉ j β« Ο j'` is the identity when `j = j'` and zero otherwise.
-/
structure Bicone (F : J β C) where
pt : C
Ο : β j, pt βΆ F j
ΞΉ : β j, F j βΆ pt
ΞΉ_Ο : β j j', ΞΉ j β« Ο j' =
if h : j = j' then eqToHom (congrArg F h) else 0 := by aesop
attribute [inherit_doc Bicone] Bicone.pt Bicone.Ο Bicone.ΞΉ Bicone.ΞΉ_Ο
@[reassoc (attr := simp)]
theorem bicone_ΞΉ_Ο_self {F : J β C} (B : Bicone F) (j : J) : B.ΞΉ j β« B.Ο j = π (F j) := by
simpa using B.ΞΉ_Ο j j
@[reassoc (attr := simp)]
theorem bicone_ΞΉ_Ο_ne {F : J β C} (B : Bicone F) {j j' : J} (h : j β j') : B.ΞΉ j β« B.Ο j' = 0 := by
simpa [h] using B.ΞΉ_Ο j j'
variable {F : J β C}
/-- A bicone morphism between two bicones for the same diagram is a morphism of the bicone points
which commutes with the cone and cocone legs. -/
structure BiconeMorphism {F : J β C} (A B : Bicone F) where
/-- A morphism between the two vertex objects of the bicones -/
hom : A.pt βΆ B.pt
/-- The triangle consisting of the two natural transformations and `hom` commutes -/
wΟ : β j : J, hom β« B.Ο j = A.Ο j := by aesop_cat
/-- The triangle consisting of the two natural transformations and `hom` commutes -/
wΞΉ : β j : J, A.ΞΉ j β« hom = B.ΞΉ j := by aesop_cat
attribute [reassoc (attr := simp)] BiconeMorphism.wΞΉ BiconeMorphism.wΟ
/-- The category of bicones on a given diagram. -/
@[simps]
instance Bicone.category : Category (Bicone F) where
Hom A B := BiconeMorphism A B
comp f g := { hom := f.hom β« g.hom }
id B := { hom := π B.pt }
-- Porting note: if we do not have `simps` automatically generate the lemma for simplifying
-- the `hom` field of a category, we need to write the `ext` lemma in terms of the categorical
-- morphism, rather than the underlying structure.
@[ext]
theorem BiconeMorphism.ext {c c' : Bicone F} (f g : c βΆ c') (w : f.hom = g.hom) : f = g := by
cases f
cases g
congr
namespace Bicones
/-- To give an isomorphism between cocones, it suffices to give an
isomorphism between their vertices which commutes with the cocone
maps. -/
@[aesop apply safe (rule_sets := [CategoryTheory]), simps]
def ext {c c' : Bicone F} (Ο : c.pt β
c'.pt)
(wΞΉ : β j, c.ΞΉ j β« Ο.hom = c'.ΞΉ j := by aesop_cat)
(wΟ : β j, Ο.hom β« c'.Ο j = c.Ο j := by aesop_cat) : c β
c' where
hom := { hom := Ο.hom }
inv :=
{ hom := Ο.inv
wΞΉ := fun j => Ο.comp_inv_eq.mpr (wΞΉ j).symm
wΟ := fun j => Ο.inv_comp_eq.mpr (wΟ j).symm }
variable (F) in
/-- A functor `G : C β₯€ D` sends bicones over `F` to bicones over `G.obj β F` functorially. -/
@[simps]
def functoriality (G : C β₯€ D) [Functor.PreservesZeroMorphisms G] :
Bicone F β₯€ Bicone (G.obj β F) where
obj A :=
{ pt := G.obj A.pt
Ο := fun j => G.map (A.Ο j)
ΞΉ := fun j => G.map (A.ΞΉ j)
ΞΉ_Ο := fun i j => (Functor.map_comp _ _ _).symm.trans <| by
rw [A.ΞΉ_Ο]
aesop_cat }
map f :=
{ hom := G.map f.hom
wΟ := fun j => by simp [-BiconeMorphism.wΟ, β f.wΟ j]
wΞΉ := fun j => by simp [-BiconeMorphism.wΞΉ, β f.wΞΉ j] }
variable (G : C β₯€ D)
instance functoriality_full [G.PreservesZeroMorphisms] [G.Full] [G.Faithful] :
(functoriality F G).Full where
map_surjective t :=
β¨{ hom := G.preimage t.hom
wΞΉ := fun j => G.map_injective (by simpa using t.wΞΉ j)
wΟ := fun j => G.map_injective (by simpa using t.wΟ j) }, by aesop_catβ©
instance functoriality_faithful [G.PreservesZeroMorphisms] [G.Faithful] :
(functoriality F G).Faithful where
map_injective {_X} {_Y} f g h :=
BiconeMorphism.ext f g <| G.map_injective <| congr_arg BiconeMorphism.hom h
end Bicones
namespace Bicone
attribute [local aesop safe tactic (rule_sets := [CategoryTheory])]
CategoryTheory.Discrete.discreteCases
-- Porting note: would it be okay to use this more generally?
attribute [local aesop safe cases (rule_sets := [CategoryTheory])] Eq
/-- Extract the cone from a bicone. -/
def toConeFunctor : Bicone F β₯€ Cone (Discrete.functor F) where
obj B := { pt := B.pt, Ο := { app := fun j => B.Ο j.as } }
map {_ _} F := { hom := F.hom, w := fun _ => F.wΟ _ }
/-- A shorthand for `toConeFunctor.obj` -/
abbrev toCone (B : Bicone F) : Cone (Discrete.functor F) := toConeFunctor.obj B
-- TODO Consider changing this API to `toFan (B : Bicone F) : Fan F`.
@[simp] theorem toCone_pt (B : Bicone F) : B.toCone.pt = B.pt := rfl
@[simp] theorem toCone_Ο_app (B : Bicone F) (j : Discrete J) : B.toCone.Ο.app j = B.Ο j.as := rfl
theorem toCone_Ο_app_mk (B : Bicone F) (j : J) : B.toCone.Ο.app β¨jβ© = B.Ο j := rfl
@[simp] theorem toCone_proj (B : Bicone F) (j : J) : Fan.proj B.toCone j = B.Ο j := rfl
/-- Extract the cocone from a bicone. -/
def toCoconeFunctor : Bicone F β₯€ Cocone (Discrete.functor F) where
obj B := { pt := B.pt, ΞΉ := { app := fun j => B.ΞΉ j.as } }
map {_ _} F := { hom := F.hom, w := fun _ => F.wΞΉ _ }
/-- A shorthand for `toCoconeFunctor.obj` -/
abbrev toCocone (B : Bicone F) : Cocone (Discrete.functor F) := toCoconeFunctor.obj B
@[simp] theorem toCocone_pt (B : Bicone F) : B.toCocone.pt = B.pt := rfl
@[simp]
theorem toCocone_ΞΉ_app (B : Bicone F) (j : Discrete J) : B.toCocone.ΞΉ.app j = B.ΞΉ j.as := rfl
@[simp] theorem toCocone_inj (B : Bicone F) (j : J) : Cofan.inj B.toCocone j = B.ΞΉ j := rfl
theorem toCocone_ΞΉ_app_mk (B : Bicone F) (j : J) : B.toCocone.ΞΉ.app β¨jβ© = B.ΞΉ j := rfl
open scoped Classical in
/-- We can turn any limit cone over a discrete collection of objects into a bicone. -/
@[simps]
def ofLimitCone {f : J β C} {t : Cone (Discrete.functor f)} (ht : IsLimit t) : Bicone f where
pt := t.pt
Ο j := t.Ο.app β¨jβ©
ΞΉ j := ht.lift (Fan.mk _ fun j' => if h : j = j' then eqToHom (congr_arg f h) else 0)
ΞΉ_Ο j j' := by simp
open scoped Classical in
theorem ΞΉ_of_isLimit {f : J β C} {t : Bicone f} (ht : IsLimit t.toCone) (j : J) :
t.ΞΉ j = ht.lift (Fan.mk _ fun j' => if h : j = j' then eqToHom (congr_arg f h) else 0) :=
ht.hom_ext fun j' => by
rw [ht.fac]
simp [t.ΞΉ_Ο]
open scoped Classical in
/-- We can turn any colimit cocone over a discrete collection of objects into a bicone. -/
@[simps]
def ofColimitCocone {f : J β C} {t : Cocone (Discrete.functor f)} (ht : IsColimit t) :
Bicone f where
pt := t.pt
Ο j := ht.desc (Cofan.mk _ fun j' => if h : j' = j then eqToHom (congr_arg f h) else 0)
ΞΉ j := t.ΞΉ.app β¨jβ©
ΞΉ_Ο j j' := by simp
open scoped Classical in
theorem Ο_of_isColimit {f : J β C} {t : Bicone f} (ht : IsColimit t.toCocone) (j : J) :
t.Ο j = ht.desc (Cofan.mk _ fun j' => if h : j' = j then eqToHom (congr_arg f h) else 0) :=
ht.hom_ext fun j' => by
rw [ht.fac]
simp [t.ΞΉ_Ο]
/-- Structure witnessing that a bicone is both a limit cone and a colimit cocone. -/
structure IsBilimit {F : J β C} (B : Bicone F) where
isLimit : IsLimit B.toCone
isColimit : IsColimit B.toCocone
attribute [inherit_doc IsBilimit] IsBilimit.isLimit IsBilimit.isColimit
attribute [simp] IsBilimit.mk.injEq
attribute [local ext] Bicone.IsBilimit
instance subsingleton_isBilimit {f : J β C} {c : Bicone f} : Subsingleton c.IsBilimit :=
β¨fun _ _ => Bicone.IsBilimit.ext (Subsingleton.elim _ _) (Subsingleton.elim _ _)β©
section Whisker
variable {K : Type w'}
/-- Whisker a bicone with an equivalence between the indexing types. -/
@[simps]
def whisker {f : J β C} (c : Bicone f) (g : K β J) : Bicone (f β g) where
pt := c.pt
Ο k := c.Ο (g k)
ΞΉ k := c.ΞΉ (g k)
ΞΉ_Ο k k' := by
simp only [c.ΞΉ_Ο]
split_ifs with h h' h' <;> simp [Equiv.apply_eq_iff_eq g] at h h' <;> tauto
/-- Taking the cone of a whiskered bicone results in a cone isomorphic to one gained
by whiskering the cone and postcomposing with a suitable isomorphism. -/
def whiskerToCone {f : J β C} (c : Bicone f) (g : K β J) :
(c.whisker g).toCone β
(Cones.postcompose (Discrete.functorComp f g).inv).obj
(c.toCone.whisker (Discrete.functor (Discrete.mk β g))) :=
Cones.ext (Iso.refl _) (by simp)
/-- Taking the cocone of a whiskered bicone results in a cone isomorphic to one gained
by whiskering the cocone and precomposing with a suitable isomorphism. -/
def whiskerToCocone {f : J β C} (c : Bicone f) (g : K β J) :
(c.whisker g).toCocone β
(Cocones.precompose (Discrete.functorComp f g).hom).obj
(c.toCocone.whisker (Discrete.functor (Discrete.mk β g))) :=
Cocones.ext (Iso.refl _) (by simp)
/-- Whiskering a bicone with an equivalence between types preserves being a bilimit bicone. -/
noncomputable def whiskerIsBilimitIff {f : J β C} (c : Bicone f) (g : K β J) :
(c.whisker g).IsBilimit β c.IsBilimit := by
refine equivOfSubsingletonOfSubsingleton (fun hc => β¨?_, ?_β©) fun hc => β¨?_, ?_β©
Β· let this := IsLimit.ofIsoLimit hc.isLimit (Bicone.whiskerToCone c g)
let this := (IsLimit.postcomposeHomEquiv (Discrete.functorComp f g).symm _) this
exact IsLimit.ofWhiskerEquivalence (Discrete.equivalence g) this
Β· let this := IsColimit.ofIsoColimit hc.isColimit (Bicone.whiskerToCocone c g)
let this := (IsColimit.precomposeHomEquiv (Discrete.functorComp f g) _) this
exact IsColimit.ofWhiskerEquivalence (Discrete.equivalence g) this
Β· apply IsLimit.ofIsoLimit _ (Bicone.whiskerToCone c g).symm
apply (IsLimit.postcomposeHomEquiv (Discrete.functorComp f g).symm _).symm _
exact IsLimit.whiskerEquivalence hc.isLimit (Discrete.equivalence g)
Β· apply IsColimit.ofIsoColimit _ (Bicone.whiskerToCocone c g).symm
apply (IsColimit.precomposeHomEquiv (Discrete.functorComp f g) _).symm _
exact IsColimit.whiskerEquivalence hc.isColimit (Discrete.equivalence g)
end Whisker
end Bicone
/-- A bicone over `F : J β C`, which is both a limit cone and a colimit cocone. -/
structure LimitBicone (F : J β C) where
bicone : Bicone F
isBilimit : bicone.IsBilimit
attribute [inherit_doc LimitBicone] LimitBicone.bicone LimitBicone.isBilimit
/-- `HasBiproduct F` expresses the mere existence of a bicone which is
simultaneously a limit and a colimit of the diagram `F`. -/
class HasBiproduct (F : J β C) : Prop where mk' ::
exists_biproduct : Nonempty (LimitBicone F)
attribute [inherit_doc HasBiproduct] HasBiproduct.exists_biproduct
theorem HasBiproduct.mk {F : J β C} (d : LimitBicone F) : HasBiproduct F :=
β¨Nonempty.intro dβ©
/-- Use the axiom of choice to extract explicit `BiproductData F` from `HasBiproduct F`. -/
def getBiproductData (F : J β C) [HasBiproduct F] : LimitBicone F :=
Classical.choice HasBiproduct.exists_biproduct
/-- A bicone for `F` which is both a limit cone and a colimit cocone. -/
def biproduct.bicone (F : J β C) [HasBiproduct F] : Bicone F :=
(getBiproductData F).bicone
/-- `biproduct.bicone F` is a bilimit bicone. -/
def biproduct.isBilimit (F : J β C) [HasBiproduct F] : (biproduct.bicone F).IsBilimit :=
(getBiproductData F).isBilimit
/-- `biproduct.bicone F` is a limit cone. -/
def biproduct.isLimit (F : J β C) [HasBiproduct F] : IsLimit (biproduct.bicone F).toCone :=
(getBiproductData F).isBilimit.isLimit
/-- `biproduct.bicone F` is a colimit cocone. -/
def biproduct.isColimit (F : J β C) [HasBiproduct F] : IsColimit (biproduct.bicone F).toCocone :=
(getBiproductData F).isBilimit.isColimit
instance (priority := 100) hasProduct_of_hasBiproduct [HasBiproduct F] : HasProduct F :=
HasLimit.mk
{ cone := (biproduct.bicone F).toCone
isLimit := biproduct.isLimit F }
instance (priority := 100) hasCoproduct_of_hasBiproduct [HasBiproduct F] : HasCoproduct F :=
HasColimit.mk
{ cocone := (biproduct.bicone F).toCocone
isColimit := biproduct.isColimit F }
variable (J C)
/-- `C` has biproducts of shape `J` if we have
a limit and a colimit, with the same cone points,
of every function `F : J β C`. -/
class HasBiproductsOfShape : Prop where
has_biproduct : β F : J β C, HasBiproduct F
attribute [instance 100] HasBiproductsOfShape.has_biproduct
/-- `HasFiniteBiproducts C` represents a choice of biproduct for every family of objects in `C`
indexed by a finite type. -/
class HasFiniteBiproducts : Prop where
out : β n, HasBiproductsOfShape (Fin n) C
attribute [inherit_doc HasFiniteBiproducts] HasFiniteBiproducts.out
variable {J}
theorem hasBiproductsOfShape_of_equiv {K : Type w'} [HasBiproductsOfShape K C] (e : J β K) :
HasBiproductsOfShape J C :=
β¨fun F =>
let β¨β¨hβ©β© := HasBiproductsOfShape.has_biproduct (F β e.symm)
let β¨c, hcβ© := h
HasBiproduct.mk <| by
simpa only [Function.comp_def, e.symm_apply_apply] using
LimitBicone.mk (c.whisker e) ((c.whiskerIsBilimitIff _).2 hc)β©
instance (priority := 100) hasBiproductsOfShape_finite [HasFiniteBiproducts C] [Finite J] :
HasBiproductsOfShape J C := by
rcases Finite.exists_equiv_fin J with β¨n, β¨eβ©β©
haveI : HasBiproductsOfShape (Fin n) C := HasFiniteBiproducts.out n
exact hasBiproductsOfShape_of_equiv C e
instance (priority := 100) hasFiniteProducts_of_hasFiniteBiproducts [HasFiniteBiproducts C] :
HasFiniteProducts C where
out _ := β¨fun _ => hasLimit_of_iso Discrete.natIsoFunctor.symmβ©
instance (priority := 100) hasFiniteCoproducts_of_hasFiniteBiproducts [HasFiniteBiproducts C] :
HasFiniteCoproducts C where
out _ := β¨fun _ => hasColimit_of_iso Discrete.natIsoFunctorβ©
instance (priority := 100) hasProductsOfShape_of_hasBiproductsOfShape [HasBiproductsOfShape J C] :
HasProductsOfShape J C where
has_limit _ := hasLimit_of_iso Discrete.natIsoFunctor.symm
instance (priority := 100) hasCoproductsOfShape_of_hasBiproductsOfShape [HasBiproductsOfShape J C] :
HasCoproductsOfShape J C where
has_colimit _ := hasColimit_of_iso Discrete.natIsoFunctor
variable {C}
/-- The isomorphism between the specified limit and the specified colimit for
a functor with a bilimit. -/
def biproductIso (F : J β C) [HasBiproduct F] : Limits.piObj F β
Limits.sigmaObj F :=
(IsLimit.conePointUniqueUpToIso (limit.isLimit _) (biproduct.isLimit F)).trans <|
IsColimit.coconePointUniqueUpToIso (biproduct.isColimit F) (colimit.isColimit _)
variable {J : Type w} {K : Type*}
variable {C : Type u} [Category.{v} C] [HasZeroMorphisms C]
/-- `biproduct f` computes the biproduct of a family of elements `f`. (It is defined as an
abbreviation for `limit (Discrete.functor f)`, so for most facts about `biproduct f`, you will
just use general facts about limits and colimits.) -/
abbrev biproduct (f : J β C) [HasBiproduct f] : C :=
(biproduct.bicone f).pt
@[inherit_doc biproduct]
notation "β¨ " f:20 => biproduct f
/-- The projection onto a summand of a biproduct. -/
abbrev biproduct.Ο (f : J β C) [HasBiproduct f] (b : J) : β¨ f βΆ f b :=
(biproduct.bicone f).Ο b
@[simp]
theorem biproduct.bicone_Ο (f : J β C) [HasBiproduct f] (b : J) :
(biproduct.bicone f).Ο b = biproduct.Ο f b := rfl
/-- The inclusion into a summand of a biproduct. -/
abbrev biproduct.ΞΉ (f : J β C) [HasBiproduct f] (b : J) : f b βΆ β¨ f :=
(biproduct.bicone f).ΞΉ b
@[simp]
theorem biproduct.bicone_ΞΉ (f : J β C) [HasBiproduct f] (b : J) :
(biproduct.bicone f).ΞΉ b = biproduct.ΞΉ f b := rfl
/-- Note that as this lemma has an `if` in the statement, we include a `DecidableEq` argument.
This means you may not be able to `simp` using this lemma unless you `open scoped Classical`. -/
@[reassoc]
theorem biproduct.ΞΉ_Ο [DecidableEq J] (f : J β C) [HasBiproduct f] (j j' : J) :
biproduct.ΞΉ f j β« biproduct.Ο f j' = if h : j = j' then eqToHom (congr_arg f h) else 0 := by
convert (biproduct.bicone f).ΞΉ_Ο j j'
@[reassoc] -- Porting note: both versions proven by simp
theorem biproduct.ΞΉ_Ο_self (f : J β C) [HasBiproduct f] (j : J) :
biproduct.ΞΉ f j β« biproduct.Ο f j = π _ := by simp [biproduct.ΞΉ_Ο]
@[reassoc (attr := simp)]
theorem biproduct.ΞΉ_Ο_ne (f : J β C) [HasBiproduct f] {j j' : J} (h : j β j') :
biproduct.ΞΉ f j β« biproduct.Ο f j' = 0 := by simp [biproduct.ΞΉ_Ο, h]
-- The `simpNF` linter incorrectly identifies these as simp lemmas that could never apply.
-- It seems the side condition `w` is not applied by `simpNF`.
-- https://github.com/leanprover-community/mathlib4/issues/5049
-- They are used by `simp` in `biproduct.whiskerEquiv` below.
@[reassoc (attr := simp, nolint simpNF)]
theorem biproduct.eqToHom_comp_ΞΉ (f : J β C) [HasBiproduct f] {j j' : J} (w : j = j') :
eqToHom (by simp [w]) β« biproduct.ΞΉ f j' = biproduct.ΞΉ f j := by
cases w
simp
-- The `simpNF` linter incorrectly identifies these as simp lemmas that could never apply.
-- It seems the side condition `w` is not applied by `simpNF`.
-- https://github.com/leanprover-community/mathlib4/issues/5049
-- They are used by `simp` in `biproduct.whiskerEquiv` below.
@[reassoc (attr := simp, nolint simpNF)]
theorem biproduct.Ο_comp_eqToHom (f : J β C) [HasBiproduct f] {j j' : J} (w : j = j') :
biproduct.Ο f j β« eqToHom (by simp [w]) = biproduct.Ο f j' := by
cases w
simp
/-- Given a collection of maps into the summands, we obtain a map into the biproduct. -/
abbrev biproduct.lift {f : J β C} [HasBiproduct f] {P : C} (p : β b, P βΆ f b) : P βΆ β¨ f :=
(biproduct.isLimit f).lift (Fan.mk P p)
/-- Given a collection of maps out of the summands, we obtain a map out of the biproduct. -/
abbrev biproduct.desc {f : J β C} [HasBiproduct f] {P : C} (p : β b, f b βΆ P) : β¨ f βΆ P :=
(biproduct.isColimit f).desc (Cofan.mk P p)
@[reassoc (attr := simp)]
theorem biproduct.lift_Ο {f : J β C} [HasBiproduct f] {P : C} (p : β b, P βΆ f b) (j : J) :
biproduct.lift p β« biproduct.Ο f j = p j := (biproduct.isLimit f).fac _ β¨jβ©
@[reassoc (attr := simp)]
theorem biproduct.ΞΉ_desc {f : J β C} [HasBiproduct f] {P : C} (p : β b, f b βΆ P) (j : J) :
biproduct.ΞΉ f j β« biproduct.desc p = p j := (biproduct.isColimit f).fac _ β¨jβ©
/-- Given a collection of maps between corresponding summands of a pair of biproducts
indexed by the same type, we obtain a map between the biproducts. -/
abbrev biproduct.map {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β b, f b βΆ g b) :
β¨ f βΆ β¨ g :=
IsLimit.map (biproduct.bicone f).toCone (biproduct.isLimit g)
(Discrete.natTrans (fun j => p j.as))
/-- An alternative to `biproduct.map` constructed via colimits.
This construction only exists in order to show it is equal to `biproduct.map`. -/
abbrev biproduct.map' {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β b, f b βΆ g b) :
β¨ f βΆ β¨ g :=
IsColimit.map (biproduct.isColimit f) (biproduct.bicone g).toCocone
(Discrete.natTrans fun j => p j.as)
-- We put this at slightly higher priority than `biproduct.hom_ext'`,
-- to get the matrix indices in the "right" order.
@[ext 1001]
theorem biproduct.hom_ext {f : J β C} [HasBiproduct f] {Z : C} (g h : Z βΆ β¨ f)
(w : β j, g β« biproduct.Ο f j = h β« biproduct.Ο f j) : g = h :=
(biproduct.isLimit f).hom_ext fun j => w j.as
@[ext]
theorem biproduct.hom_ext' {f : J β C} [HasBiproduct f] {Z : C} (g h : β¨ f βΆ Z)
(w : β j, biproduct.ΞΉ f j β« g = biproduct.ΞΉ f j β« h) : g = h :=
(biproduct.isColimit f).hom_ext fun j => w j.as
/-- The canonical isomorphism between the chosen biproduct and the chosen product. -/
def biproduct.isoProduct (f : J β C) [HasBiproduct f] : β¨ f β
βαΆ f :=
IsLimit.conePointUniqueUpToIso (biproduct.isLimit f) (limit.isLimit _)
@[simp]
theorem biproduct.isoProduct_hom {f : J β C} [HasBiproduct f] :
(biproduct.isoProduct f).hom = Pi.lift (biproduct.Ο f) :=
limit.hom_ext fun j => by simp [biproduct.isoProduct]
@[simp]
theorem biproduct.isoProduct_inv {f : J β C} [HasBiproduct f] :
(biproduct.isoProduct f).inv = biproduct.lift (Pi.Ο f) :=
biproduct.hom_ext _ _ fun j => by simp [Iso.inv_comp_eq]
/-- The canonical isomorphism between the chosen biproduct and the chosen coproduct. -/
def biproduct.isoCoproduct (f : J β C) [HasBiproduct f] : β¨ f β
β f :=
IsColimit.coconePointUniqueUpToIso (biproduct.isColimit f) (colimit.isColimit _)
@[simp]
theorem biproduct.isoCoproduct_inv {f : J β C} [HasBiproduct f] :
(biproduct.isoCoproduct f).inv = Sigma.desc (biproduct.ΞΉ f) :=
colimit.hom_ext fun j => by simp [biproduct.isoCoproduct]
@[simp]
theorem biproduct.isoCoproduct_hom {f : J β C} [HasBiproduct f] :
(biproduct.isoCoproduct f).hom = biproduct.desc (Sigma.ΞΉ f) :=
biproduct.hom_ext' _ _ fun j => by simp [β Iso.eq_comp_inv]
/-- If a category has biproducts of a shape `J`, its `colim` and `lim` functor on diagrams over `J`
are isomorphic. -/
@[simps!]
def HasBiproductsOfShape.colimIsoLim [HasBiproductsOfShape J C] :
colim (J := Discrete J) (C := C) β
lim :=
NatIso.ofComponents (fun F => (Sigma.isoColimit F).symm βͺβ«
(biproduct.isoCoproduct _).symm βͺβ« biproduct.isoProduct _ βͺβ« Pi.isoLimit F)
fun Ξ· => colimit.hom_ext fun β¨iβ© => limit.hom_ext fun β¨jβ© => by
classical
by_cases h : i = j <;>
simp_all [h, Sigma.isoColimit, Pi.isoLimit, biproduct.ΞΉ_Ο, biproduct.ΞΉ_Ο_assoc]
theorem biproduct.map_eq_map' {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β b, f b βΆ g b) :
biproduct.map p = biproduct.map' p := by
classical
ext
dsimp
simp only [Discrete.natTrans_app, Limits.IsColimit.ΞΉ_map_assoc, Limits.IsLimit.map_Ο,
Category.assoc, β Bicone.toCone_Ο_app_mk, β biproduct.bicone_Ο, β Bicone.toCocone_ΞΉ_app_mk,
β biproduct.bicone_ΞΉ]
dsimp
rw [biproduct.ΞΉ_Ο_assoc, biproduct.ΞΉ_Ο]
split_ifs with h
Β· subst h; simp
Β· simp
@[reassoc (attr := simp)]
theorem biproduct.map_Ο {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
(j : J) : biproduct.map p β« biproduct.Ο g j = biproduct.Ο f j β« p j :=
Limits.IsLimit.map_Ο _ _ _ (Discrete.mk j)
@[reassoc (attr := simp)]
theorem biproduct.ΞΉ_map {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
(j : J) : biproduct.ΞΉ f j β« biproduct.map p = p j β« biproduct.ΞΉ g j := by
rw [biproduct.map_eq_map']
apply
Limits.IsColimit.ΞΉ_map (biproduct.isColimit f) (biproduct.bicone g).toCocone
(Discrete.natTrans fun j => p j.as) (Discrete.mk j)
@[reassoc (attr := simp)]
theorem biproduct.map_desc {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
{P : C} (k : β j, g j βΆ P) :
biproduct.map p β« biproduct.desc k = biproduct.desc fun j => p j β« k j := by
ext; simp
@[reassoc (attr := simp)]
theorem biproduct.lift_map {f g : J β C} [HasBiproduct f] [HasBiproduct g] {P : C}
(k : β j, P βΆ f j) (p : β j, f j βΆ g j) :
biproduct.lift k β« biproduct.map p = biproduct.lift fun j => k j β« p j := by
ext; simp
/-- Given a collection of isomorphisms between corresponding summands of a pair of biproducts
indexed by the same type, we obtain an isomorphism between the biproducts. -/
@[simps]
def biproduct.mapIso {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β b, f b β
g b) :
β¨ f β
β¨ g where
hom := biproduct.map fun b => (p b).hom
inv := biproduct.map fun b => (p b).inv
instance biproduct.map_epi {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
[β j, Epi (p j)] : Epi (biproduct.map p) := by
classical
have : biproduct.map p =
(biproduct.isoCoproduct _).hom β« Sigma.map p β« (biproduct.isoCoproduct _).inv := by
ext
simp only [map_Ο, isoCoproduct_hom, isoCoproduct_inv, Category.assoc, ΞΉ_desc_assoc,
ΞΉ_colimMap_assoc, Discrete.functor_obj_eq_as, Discrete.natTrans_app, colimit.ΞΉ_desc_assoc,
Cofan.mk_pt, Cofan.mk_ΞΉ_app, ΞΉ_Ο, ΞΉ_Ο_assoc]
split
all_goals simp_all
rw [this]
infer_instance
instance Pi.map_epi {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
[β j, Epi (p j)] : Epi (Pi.map p) := by
rw [show Pi.map p = (biproduct.isoProduct _).inv β« biproduct.map p β«
(biproduct.isoProduct _).hom by aesop]
infer_instance
instance biproduct.map_mono {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
[β j, Mono (p j)] : Mono (biproduct.map p) := by
rw [show biproduct.map p = (biproduct.isoProduct _).hom β« Pi.map p β«
(biproduct.isoProduct _).inv by aesop]
infer_instance
instance Sigma.map_mono {f g : J β C} [HasBiproduct f] [HasBiproduct g] (p : β j, f j βΆ g j)
[β j, Mono (p j)] : Mono (Sigma.map p) := by
rw [show Sigma.map p = (biproduct.isoCoproduct _).inv β« biproduct.map p β«
(biproduct.isoCoproduct _).hom by aesop]
infer_instance
/-- Two biproducts which differ by an equivalence in the indexing type,
and up to isomorphism in the factors, are isomorphic.
Unfortunately there are two natural ways to define each direction of this isomorphism
(because it is true for both products and coproducts separately).
We give the alternative definitions as lemmas below. -/
@[simps]
def biproduct.whiskerEquiv {f : J β C} {g : K β C} (e : J β K) (w : β j, g (e j) β
f j)
[HasBiproduct f] [HasBiproduct g] : β¨ f β
β¨ g where
hom := biproduct.desc fun j => (w j).inv β« biproduct.ΞΉ g (e j)
inv := biproduct.desc fun k => eqToHom (by simp) β« (w (e.symm k)).hom β« biproduct.ΞΉ f _
lemma biproduct.whiskerEquiv_hom_eq_lift {f : J β C} {g : K β C} (e : J β K)
(w : β j, g (e j) β
f j) [HasBiproduct f] [HasBiproduct g] :
(biproduct.whiskerEquiv e w).hom =
biproduct.lift fun k => biproduct.Ο f (e.symm k) β« (w _).inv β« eqToHom (by simp) := by
simp only [whiskerEquiv_hom]
ext k j
by_cases h : k = e j
Β· subst h
simp
Β· simp only [ΞΉ_desc_assoc, Category.assoc, ne_eq, lift_Ο]
rw [biproduct.ΞΉ_Ο_ne, biproduct.ΞΉ_Ο_ne_assoc]
Β· simp
Β· rintro rfl
simp at h
Β· exact Ne.symm h
lemma biproduct.whiskerEquiv_inv_eq_lift {f : J β C} {g : K β C} (e : J β K)
(w : β j, g (e j) β
f j) [HasBiproduct f] [HasBiproduct g] :
(biproduct.whiskerEquiv e w).inv =
biproduct.lift fun j => biproduct.Ο g (e j) β« (w j).hom := by
simp only [whiskerEquiv_inv]
ext j k
by_cases h : k = e j
Β· subst h
simp only [ΞΉ_desc_assoc, β eqToHom_iso_hom_naturality_assoc w (e.symm_apply_apply j).symm,
Equiv.symm_apply_apply, eqToHom_comp_ΞΉ, Category.assoc, bicone_ΞΉ_Ο_self, Category.comp_id,
lift_Ο, bicone_ΞΉ_Ο_self_assoc]
Β· simp only [ΞΉ_desc_assoc, Category.assoc, ne_eq, lift_Ο]
rw [biproduct.ΞΉ_Ο_ne, biproduct.ΞΉ_Ο_ne_assoc]
Β· simp
Β· exact h
Β· rintro rfl
simp at h
attribute [local simp] Sigma.forall in
instance {ΞΉ} (f : ΞΉ β Type*) (g : (i : ΞΉ) β (f i) β C)
[β i, HasBiproduct (g i)] [HasBiproduct fun i => β¨ g i] :
HasBiproduct fun p : Ξ£ i, f i => g p.1 p.2 where
exists_biproduct := Nonempty.intro
{ bicone :=
{ pt := β¨ fun i => β¨ g i
ΞΉ := fun X => biproduct.ΞΉ (g X.1) X.2 β« biproduct.ΞΉ (fun i => β¨ g i) X.1
Ο := fun X => biproduct.Ο (fun i => β¨ g i) X.1 β« biproduct.Ο (g X.1) X.2
ΞΉ_Ο := fun β¨j, xβ© β¨j', yβ© => by
split_ifs with h
Β· obtain β¨rfl, rflβ© := h
simp
Β· simp only [Sigma.mk.inj_iff, not_and] at h
by_cases w : j = j'
Β· cases w
simp only [heq_eq_eq, forall_true_left] at h
simp [biproduct.ΞΉ_Ο_ne _ h]
Β· simp [biproduct.ΞΉ_Ο_ne_assoc _ w] }
isBilimit :=
{ isLimit := mkFanLimit _
(fun s => biproduct.lift fun b => biproduct.lift fun c => s.proj β¨b, cβ©)
isColimit := mkCofanColimit _
(fun s => biproduct.desc fun b => biproduct.desc fun c => s.inj β¨b, cβ©) } }
/-- An iterated biproduct is a biproduct over a sigma type. -/
@[simps]
def biproductBiproductIso {ΞΉ} (f : ΞΉ β Type*) (g : (i : ΞΉ) β (f i) β C)
[β i, HasBiproduct (g i)] [HasBiproduct fun i => β¨ g i] :
(β¨ fun i => β¨ g i) β
(β¨ fun p : Ξ£ i, f i => g p.1 p.2) where
hom := biproduct.lift fun β¨i, xβ© => biproduct.Ο _ i β« biproduct.Ο _ x
inv := biproduct.lift fun i => biproduct.lift fun x => biproduct.Ο _ (β¨i, xβ© : Ξ£ i, f i)
section ΟKernel
section
variable (f : J β C) [HasBiproduct f]
variable (p : J β Prop) [HasBiproduct (Subtype.restrict p f)]
/-- The canonical morphism from the biproduct over a restricted index type to the biproduct of
the full index type. -/
def biproduct.fromSubtype : β¨ Subtype.restrict p f βΆ β¨ f :=
biproduct.desc fun j => biproduct.ΞΉ _ j.val
/-- The canonical morphism from a biproduct to the biproduct over a restriction of its index
type. -/
def biproduct.toSubtype : β¨ f βΆ β¨ Subtype.restrict p f :=
biproduct.lift fun _ => biproduct.Ο _ _
@[reassoc (attr := simp)]
theorem biproduct.fromSubtype_Ο [DecidablePred p] (j : J) :
biproduct.fromSubtype f p β« biproduct.Ο f j =
if h : p j then biproduct.Ο (Subtype.restrict p f) β¨j, hβ© else 0 := by
classical
ext i; dsimp
rw [biproduct.fromSubtype, biproduct.ΞΉ_desc_assoc, biproduct.ΞΉ_Ο]
by_cases h : p j
Β· rw [dif_pos h, biproduct.ΞΉ_Ο]
split_ifs with hβ hβ hβ
exacts [rfl, False.elim (hβ (Subtype.ext hβ)), False.elim (hβ (congr_arg Subtype.val hβ)), rfl]
Β· rw [dif_neg h, dif_neg (show (i : J) β j from fun hβ => h (hβ βΈ i.2)), comp_zero]
theorem biproduct.fromSubtype_eq_lift [DecidablePred p] :
biproduct.fromSubtype f p =
biproduct.lift fun j => if h : p j then biproduct.Ο (Subtype.restrict p f) β¨j, hβ© else 0 :=
biproduct.hom_ext _ _ (by simp)
@[reassoc] -- Porting note: both version solved using simp
theorem biproduct.fromSubtype_Ο_subtype (j : Subtype p) :
biproduct.fromSubtype f p β« biproduct.Ο f j = biproduct.Ο (Subtype.restrict p f) j := by
classical
ext
rw [biproduct.fromSubtype, biproduct.ΞΉ_desc_assoc, biproduct.ΞΉ_Ο, biproduct.ΞΉ_Ο]
split_ifs with hβ hβ hβ
exacts [rfl, False.elim (hβ (Subtype.ext hβ)), False.elim (hβ (congr_arg Subtype.val hβ)), rfl]
@[reassoc (attr := simp)]
theorem biproduct.toSubtype_Ο (j : Subtype p) :
biproduct.toSubtype f p β« biproduct.Ο (Subtype.restrict p f) j = biproduct.Ο f j :=
biproduct.lift_Ο _ _
@[reassoc (attr := simp)]
theorem biproduct.ΞΉ_toSubtype [DecidablePred p] (j : J) :
biproduct.ΞΉ f j β« biproduct.toSubtype f p =
if h : p j then biproduct.ΞΉ (Subtype.restrict p f) β¨j, hβ© else 0 := by
classical
ext i
rw [biproduct.toSubtype, Category.assoc, biproduct.lift_Ο, biproduct.ΞΉ_Ο]
by_cases h : p j
Β· rw [dif_pos h, biproduct.ΞΉ_Ο]
split_ifs with hβ hβ hβ
exacts [rfl, False.elim (hβ (Subtype.ext hβ)), False.elim (hβ (congr_arg Subtype.val hβ)), rfl]
Β· rw [dif_neg h, dif_neg (show j β i from fun hβ => h (hβ.symm βΈ i.2)), zero_comp]
theorem biproduct.toSubtype_eq_desc [DecidablePred p] :
biproduct.toSubtype f p =
biproduct.desc fun j => if h : p j then biproduct.ΞΉ (Subtype.restrict p f) β¨j, hβ© else 0 :=
biproduct.hom_ext' _ _ (by simp)
@[reassoc]
| Mathlib/CategoryTheory/Limits/Shapes/Biproducts.lean | 770 | 779 | theorem biproduct.ΞΉ_toSubtype_subtype (j : Subtype p) :
biproduct.ΞΉ f j β« biproduct.toSubtype f p = biproduct.ΞΉ (Subtype.restrict p f) j := by | classical
ext
rw [biproduct.toSubtype, Category.assoc, biproduct.lift_Ο, biproduct.ΞΉ_Ο, biproduct.ΞΉ_Ο]
split_ifs with hβ hβ hβ
exacts [rfl, False.elim (hβ (Subtype.ext hβ)), False.elim (hβ (congr_arg Subtype.val hβ)), rfl]
@[reassoc (attr := simp)]
theorem biproduct.ΞΉ_fromSubtype (j : Subtype p) : |
/-
Copyright (c) 2024 MarΓa InΓ©s de Frutos-FernΓ‘ndez. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: MarΓa InΓ©s de Frutos-FernΓ‘ndez
-/
import Mathlib.Data.NNReal.Defs
import Mathlib.RingTheory.Valuation.Basic
/-!
# Rank one valuations
We define rank one valuations.
## Main Definitions
* `RankOne` : A valuation `v` has rank one if it is nontrivial and its image is contained in `ββ₯0`.
Note that this class contains the data of the inclusion of the codomain of `v` into `ββ₯0`.
## Tags
valuation, rank one
-/
noncomputable section
open Function Multiplicative
open scoped NNReal
variable {R : Type*} [Ring R] {Ξβ : Type*} [LinearOrderedCommGroupWithZero Ξβ]
namespace Valuation
/-- A valuation has rank one if it is nontrivial and its image is contained in `ββ₯0`.
Note that this class includes the data of an inclusion morphism `Ξβ β ββ₯0`. -/
class RankOne (v : Valuation R Ξβ) where
/-- The inclusion morphism from `Ξβ` to `ββ₯0`. -/
hom : Ξβ β*β ββ₯0
strictMono' : StrictMono hom
nontrivial' : β r : R, v r β 0 β§ v r β 1
namespace RankOne
variable (v : Valuation R Ξβ) [RankOne v]
lemma strictMono : StrictMono (hom v) := strictMono'
lemma nontrivial : β r : R, v r β 0 β§ v r β 1 := nontrivial'
/-- If `v` is a rank one valuation and `x : Ξβ` has image `0` under `RankOne.hom v`, then
`x = 0`. -/
| Mathlib/RingTheory/Valuation/RankOne.lean | 51 | 55 | theorem zero_of_hom_zero {x : Ξβ} (hx : hom v x = 0) : x = 0 := by | refine (eq_of_le_of_not_lt (zero_le' (a := x)) fun h_lt β¦ ?_).symm
have hs := strictMono v h_lt
rw [map_zero, hx] at hs
exact hs.false |
/-
Copyright (c) 2021 Bryan Gin-ge Chen. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Bryan Gin-ge Chen, YaΓ«l Dillies
-/
import Mathlib.Algebra.Group.Idempotent
import Mathlib.Algebra.Ring.Equiv
import Mathlib.Algebra.Ring.PUnit
import Mathlib.Order.Hom.BoundedLattice
import Mathlib.Tactic.Abel
import Mathlib.Tactic.Ring
/-!
# Boolean rings
A Boolean ring is a ring where multiplication is idempotent. They are equivalent to Boolean
algebras.
## Main declarations
* `BooleanRing`: a typeclass for rings where multiplication is idempotent.
* `BooleanRing.toBooleanAlgebra`: Turn a Boolean ring into a Boolean algebra.
* `BooleanAlgebra.toBooleanRing`: Turn a Boolean algebra into a Boolean ring.
* `AsBoolAlg`: Type-synonym for the Boolean algebra associated to a Boolean ring.
* `AsBoolRing`: Type-synonym for the Boolean ring associated to a Boolean algebra.
## Implementation notes
We provide two ways of turning a Boolean algebra/ring into a Boolean ring/algebra:
* Instances on the same type accessible in locales `BooleanAlgebraOfBooleanRing` and
`BooleanRingOfBooleanAlgebra`.
* Type-synonyms `AsBoolAlg` and `AsBoolRing`.
At this point in time, it is not clear the first way is useful, but we keep it for educational
purposes and because it is easier than dealing with
`ofBoolAlg`/`toBoolAlg`/`ofBoolRing`/`toBoolRing` explicitly.
## Tags
boolean ring, boolean algebra
-/
open scoped symmDiff
variable {Ξ± Ξ² Ξ³ : Type*}
/-- A Boolean ring is a ring where multiplication is idempotent. -/
class BooleanRing (Ξ±) extends Ring Ξ± where
/-- Multiplication in a boolean ring is idempotent. -/
isIdempotentElem (a : Ξ±) : IsIdempotentElem a
namespace BooleanRing
variable [BooleanRing Ξ±] (a b : Ξ±)
@[scoped simp]
lemma mul_self : a * a = a := IsIdempotentElem.eq (isIdempotentElem a)
instance : Std.IdempotentOp (Ξ± := Ξ±) (Β· * Β·) :=
β¨BooleanRing.mul_selfβ©
@[scoped simp]
theorem add_self : a + a = 0 := by
have : a + a = a + a + (a + a) :=
calc
a + a = (a + a) * (a + a) := by rw [mul_self]
_ = a * a + a * a + (a * a + a * a) := by rw [add_mul, mul_add]
_ = a + a + (a + a) := by rw [mul_self]
rwa [right_eq_add] at this
@[scoped simp]
theorem neg_eq : -a = a :=
calc
-a = -a + 0 := by rw [add_zero]
_ = -a + -a + a := by rw [β neg_add_cancel, add_assoc]
_ = a := by rw [add_self, zero_add]
theorem add_eq_zero' : a + b = 0 β a = b :=
calc
a + b = 0 β a = -b := add_eq_zero_iff_eq_neg
_ β a = b := by rw [neg_eq]
@[simp]
| Mathlib/Algebra/Ring/BooleanRing.lean | 84 | 87 | theorem mul_add_mul : a * b + b * a = 0 := by | have : a + b = a + b + (a * b + b * a) :=
calc
a + b = (a + b) * (a + b) := by rw [mul_self] |
/-
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, Patrick Massot, Casper Putz, Anne Baanen
-/
import Mathlib.Algebra.Algebra.Subalgebra.Tower
import Mathlib.Data.Finite.Sum
import Mathlib.Data.Matrix.Block
import Mathlib.Data.Matrix.Notation
import Mathlib.LinearAlgebra.Basis.Basic
import Mathlib.LinearAlgebra.Basis.Fin
import Mathlib.LinearAlgebra.Basis.Prod
import Mathlib.LinearAlgebra.Basis.SMul
import Mathlib.LinearAlgebra.Matrix.StdBasis
import Mathlib.RingTheory.AlgebraTower
import Mathlib.RingTheory.Ideal.Span
/-!
# Linear maps and matrices
This file defines the maps to send matrices to a linear map,
and to send linear maps between modules with a finite bases
to matrices. This defines a linear equivalence between linear maps
between finite-dimensional vector spaces and matrices indexed by
the respective bases.
## Main definitions
In the list below, and in all this file, `R` is a commutative ring (semiring
is sometimes enough), `M` and its variations are `R`-modules, `ΞΉ`, `ΞΊ`, `n` and `m` are finite
types used for indexing.
* `LinearMap.toMatrix`: given bases `vβ : ΞΉ β Mβ` and `vβ : ΞΊ β Mβ`,
the `R`-linear equivalence from `Mβ ββ[R] Mβ` to `Matrix ΞΊ ΞΉ R`
* `Matrix.toLin`: the inverse of `LinearMap.toMatrix`
* `LinearMap.toMatrix'`: the `R`-linear equivalence from `(m β R) ββ[R] (n β R)`
to `Matrix m n R` (with the standard basis on `m β R` and `n β R`)
* `Matrix.toLin'`: the inverse of `LinearMap.toMatrix'`
* `algEquivMatrix`: given a basis indexed by `n`, the `R`-algebra equivalence between
`R`-endomorphisms of `M` and `Matrix n n R`
## Issues
This file was originally written without attention to non-commutative rings,
and so mostly only works in the commutative setting. This should be fixed.
In particular, `Matrix.mulVec` gives us a linear equivalence
`Matrix m n R ββ[R] (n β R) ββ[Rα΅α΅α΅] (m β R)`
while `Matrix.vecMul` gives us a linear equivalence
`Matrix m n R ββ[Rα΅α΅α΅] (m β R) ββ[R] (n β R)`.
At present, the first equivalence is developed in detail but only for commutative rings
(and we omit the distinction between `Rα΅α΅α΅` and `R`),
while the second equivalence is developed only in brief, but for not-necessarily-commutative rings.
Naming is slightly inconsistent between the two developments.
In the original (commutative) development `linear` is abbreviated to `lin`,
although this is not consistent with the rest of mathlib.
In the new (non-commutative) development `linear` is not abbreviated, and declarations use `_right`
to indicate they use the right action of matrices on vectors (via `Matrix.vecMul`).
When the two developments are made uniform, the names should be made uniform, too,
by choosing between `linear` and `lin` consistently,
and (presumably) adding `_left` where necessary.
## Tags
linear_map, matrix, linear_equiv, diagonal, det, trace
-/
noncomputable section
open LinearMap Matrix Set Submodule
section ToMatrixRight
variable {R : Type*} [Semiring R]
variable {l m n : Type*}
/-- `Matrix.vecMul M` is a linear map. -/
def Matrix.vecMulLinear [Fintype m] (M : Matrix m n R) : (m β R) ββ[R] n β R where
toFun x := x α΅₯* M
map_add' _ _ := funext fun _ β¦ add_dotProduct _ _ _
map_smul' _ _ := funext fun _ β¦ smul_dotProduct _ _ _
@[simp] theorem Matrix.vecMulLinear_apply [Fintype m] (M : Matrix m n R) (x : m β R) :
M.vecMulLinear x = x α΅₯* M := rfl
theorem Matrix.coe_vecMulLinear [Fintype m] (M : Matrix m n R) :
(M.vecMulLinear : _ β _) = M.vecMul := rfl
variable [Fintype m]
theorem range_vecMulLinear (M : Matrix m n R) :
LinearMap.range M.vecMulLinear = span R (range M.row) := by
letI := Classical.decEq m
simp_rw [range_eq_map, β iSup_range_single, Submodule.map_iSup, range_eq_map, β
Ideal.span_singleton_one, Ideal.span, Submodule.map_span, image_image, image_singleton,
Matrix.vecMulLinear_apply, iSup_span, range_eq_iUnion, iUnion_singleton_eq_range,
LinearMap.single, LinearMap.coe_mk, AddHom.coe_mk, row_def]
unfold vecMul
simp_rw [single_dotProduct, one_mul]
theorem Matrix.vecMul_injective_iff {R : Type*} [Ring R] {M : Matrix m n R} :
Function.Injective M.vecMul β LinearIndependent R M.row := by
rw [β coe_vecMulLinear]
simp only [β LinearMap.ker_eq_bot, Fintype.linearIndependent_iff, Submodule.eq_bot_iff,
LinearMap.mem_ker, vecMulLinear_apply, row_def]
refine β¨fun h c h0 β¦ congr_fun <| h c ?_, fun h c h0 β¦ funext <| h c ?_β©
Β· rw [β h0]
ext i
simp [vecMul, dotProduct]
Β· rw [β h0]
ext j
simp [vecMul, dotProduct]
lemma Matrix.linearIndependent_rows_of_isUnit {R : Type*} [Ring R] {A : Matrix m m R}
[DecidableEq m] (ha : IsUnit A) : LinearIndependent R A.row := by
rw [β Matrix.vecMul_injective_iff]
exact Matrix.vecMul_injective_of_isUnit ha
section
variable [DecidableEq m]
/-- Linear maps `(m β R) ββ[R] (n β R)` are linearly equivalent over `Rα΅α΅α΅` to `Matrix m n R`,
by having matrices act by right multiplication.
-/
def LinearMap.toMatrixRight' : ((m β R) ββ[R] n β R) ββ[Rα΅α΅α΅] Matrix m n R where
toFun f i j := f (single R (fun _ β¦ R) i 1) j
invFun := Matrix.vecMulLinear
right_inv M := by
ext i j
simp
left_inv f := by
apply (Pi.basisFun R m).ext
intro j; ext i
simp
map_add' f g := by
ext i j
simp only [Pi.add_apply, LinearMap.add_apply, Matrix.add_apply]
map_smul' c f := by
ext i j
simp only [Pi.smul_apply, LinearMap.smul_apply, RingHom.id_apply, Matrix.smul_apply]
/-- A `Matrix m n R` is linearly equivalent over `Rα΅α΅α΅` to a linear map `(m β R) ββ[R] (n β R)`,
by having matrices act by right multiplication. -/
abbrev Matrix.toLinearMapRight' [DecidableEq m] : Matrix m n R ββ[Rα΅α΅α΅] (m β R) ββ[R] n β R :=
LinearEquiv.symm LinearMap.toMatrixRight'
@[simp]
theorem Matrix.toLinearMapRight'_apply (M : Matrix m n R) (v : m β R) :
(Matrix.toLinearMapRight') M v = v α΅₯* M := rfl
@[simp]
theorem Matrix.toLinearMapRight'_mul [Fintype l] [DecidableEq l] (M : Matrix l m R)
(N : Matrix m n R) :
Matrix.toLinearMapRight' (M * N) =
(Matrix.toLinearMapRight' N).comp (Matrix.toLinearMapRight' M) :=
LinearMap.ext fun _x β¦ (vecMul_vecMul _ M N).symm
theorem Matrix.toLinearMapRight'_mul_apply [Fintype l] [DecidableEq l] (M : Matrix l m R)
(N : Matrix m n R) (x) :
Matrix.toLinearMapRight' (M * N) x =
Matrix.toLinearMapRight' N (Matrix.toLinearMapRight' M x) :=
(vecMul_vecMul _ M N).symm
@[simp]
theorem Matrix.toLinearMapRight'_one :
Matrix.toLinearMapRight' (1 : Matrix m m R) = LinearMap.id := by
ext
simp [Module.End.one_apply]
/-- If `M` and `M'` are each other's inverse matrices, they provide an equivalence between `n β A`
and `m β A` corresponding to `M.vecMul` and `M'.vecMul`. -/
@[simps]
def Matrix.toLinearEquivRight'OfInv [Fintype n] [DecidableEq n] {M : Matrix m n R}
{M' : Matrix n m R} (hMM' : M * M' = 1) (hM'M : M' * M = 1) : (n β R) ββ[R] m β R :=
{ LinearMap.toMatrixRight'.symm M' with
toFun := Matrix.toLinearMapRight' M'
invFun := Matrix.toLinearMapRight' M
left_inv := fun x β¦ by
rw [β Matrix.toLinearMapRight'_mul_apply, hM'M, Matrix.toLinearMapRight'_one, id_apply]
right_inv := fun x β¦ by
rw [β Matrix.toLinearMapRight'_mul_apply, hMM', Matrix.toLinearMapRight'_one, id_apply] }
end
end ToMatrixRight
/-!
From this point on, we only work with commutative rings,
and fail to distinguish between `Rα΅α΅α΅` and `R`.
This should eventually be remedied.
-/
section mulVec
variable {R : Type*} [CommSemiring R]
variable {k l m n : Type*}
/-- `Matrix.mulVec M` is a linear map. -/
def Matrix.mulVecLin [Fintype n] (M : Matrix m n R) : (n β R) ββ[R] m β R where
toFun := M.mulVec
map_add' _ _ := funext fun _ β¦ dotProduct_add _ _ _
map_smul' _ _ := funext fun _ β¦ dotProduct_smul _ _ _
theorem Matrix.coe_mulVecLin [Fintype n] (M : Matrix m n R) :
(M.mulVecLin : _ β _) = M.mulVec := rfl
@[simp]
theorem Matrix.mulVecLin_apply [Fintype n] (M : Matrix m n R) (v : n β R) :
M.mulVecLin v = M *α΅₯ v :=
rfl
@[simp]
theorem Matrix.mulVecLin_zero [Fintype n] : Matrix.mulVecLin (0 : Matrix m n R) = 0 :=
LinearMap.ext zero_mulVec
@[simp]
theorem Matrix.mulVecLin_add [Fintype n] (M N : Matrix m n R) :
(M + N).mulVecLin = M.mulVecLin + N.mulVecLin :=
LinearMap.ext fun _ β¦ add_mulVec _ _ _
@[simp] theorem Matrix.mulVecLin_transpose [Fintype m] (M : Matrix m n R) :
Mα΅.mulVecLin = M.vecMulLinear := by
ext; simp [mulVec_transpose]
@[simp] theorem Matrix.vecMulLinear_transpose [Fintype n] (M : Matrix m n R) :
Mα΅.vecMulLinear = M.mulVecLin := by
ext; simp [vecMul_transpose]
theorem Matrix.mulVecLin_submatrix [Fintype n] [Fintype l] (fβ : m β k) (eβ : n β l)
(M : Matrix k l R) :
(M.submatrix fβ eβ).mulVecLin = funLeft R R fβ ββ M.mulVecLin ββ funLeft _ _ eβ.symm :=
LinearMap.ext fun _ β¦ submatrix_mulVec_equiv _ _ _ _
/-- A variant of `Matrix.mulVecLin_submatrix` that keeps around `LinearEquiv`s. -/
theorem Matrix.mulVecLin_reindex [Fintype n] [Fintype l] (eβ : k β m) (eβ : l β n)
(M : Matrix k l R) :
(reindex eβ eβ M).mulVecLin =
β(LinearEquiv.funCongrLeft R R eβ.symm) ββ
M.mulVecLin ββ β(LinearEquiv.funCongrLeft R R eβ) :=
Matrix.mulVecLin_submatrix _ _ _
variable [Fintype n]
@[simp]
theorem Matrix.mulVecLin_one [DecidableEq n] :
Matrix.mulVecLin (1 : Matrix n n R) = LinearMap.id := by
ext; simp [Matrix.one_apply, Pi.single_apply, eq_comm]
@[simp]
theorem Matrix.mulVecLin_mul [Fintype m] (M : Matrix l m R) (N : Matrix m n R) :
Matrix.mulVecLin (M * N) = (Matrix.mulVecLin M).comp (Matrix.mulVecLin N) :=
LinearMap.ext fun _ β¦ (mulVec_mulVec _ _ _).symm
theorem Matrix.ker_mulVecLin_eq_bot_iff {M : Matrix m n R} :
(LinearMap.ker M.mulVecLin) = β₯ β β v, M *α΅₯ v = 0 β v = 0 := by
simp only [Submodule.eq_bot_iff, LinearMap.mem_ker, Matrix.mulVecLin_apply]
theorem Matrix.range_mulVecLin (M : Matrix m n R) :
LinearMap.range M.mulVecLin = span R (range M.col) := by
rw [β vecMulLinear_transpose, range_vecMulLinear, row_transpose]
theorem Matrix.mulVec_injective_iff {R : Type*} [CommRing R] {M : Matrix m n R} :
Function.Injective M.mulVec β LinearIndependent R M.col := by
change Function.Injective (fun x β¦ _) β _
simp_rw [β M.vecMul_transpose, vecMul_injective_iff, row_transpose]
lemma Matrix.linearIndependent_cols_of_isUnit {R : Type*} [CommRing R] [Fintype m]
{A : Matrix m m R} [DecidableEq m] (ha : IsUnit A) :
LinearIndependent R A.col := by
rw [β Matrix.mulVec_injective_iff]
exact Matrix.mulVec_injective_of_isUnit ha
end mulVec
section ToMatrix'
variable {R : Type*} [CommSemiring R]
variable {k l m n : Type*} [DecidableEq n] [Fintype n]
/-- Linear maps `(n β R) ββ[R] (m β R)` are linearly equivalent to `Matrix m n R`. -/
def LinearMap.toMatrix' : ((n β R) ββ[R] m β R) ββ[R] Matrix m n R where
toFun f := of fun i j β¦ f (Pi.single j 1) i
invFun := Matrix.mulVecLin
right_inv M := by
ext i j
simp only [Matrix.mulVec_single_one, Matrix.mulVecLin_apply, of_apply, transpose_apply]
left_inv f := by
apply (Pi.basisFun R n).ext
intro j; ext i
simp only [Pi.basisFun_apply, Matrix.mulVec_single_one,
Matrix.mulVecLin_apply, of_apply, transpose_apply]
map_add' f g := by
ext i j
simp only [Pi.add_apply, LinearMap.add_apply, of_apply, Matrix.add_apply]
map_smul' c f := by
ext i j
simp only [Pi.smul_apply, LinearMap.smul_apply, RingHom.id_apply, of_apply, Matrix.smul_apply]
/-- A `Matrix m n R` is linearly equivalent to a linear map `(n β R) ββ[R] (m β R)`.
Note that the forward-direction does not require `DecidableEq` and is `Matrix.vecMulLin`. -/
def Matrix.toLin' : Matrix m n R ββ[R] (n β R) ββ[R] m β R :=
LinearMap.toMatrix'.symm
theorem Matrix.toLin'_apply' (M : Matrix m n R) : Matrix.toLin' M = M.mulVecLin :=
rfl
@[simp]
theorem LinearMap.toMatrix'_symm :
(LinearMap.toMatrix'.symm : Matrix m n R ββ[R] _) = Matrix.toLin' :=
rfl
@[simp]
theorem Matrix.toLin'_symm :
(Matrix.toLin'.symm : ((n β R) ββ[R] m β R) ββ[R] _) = LinearMap.toMatrix' :=
rfl
@[simp]
theorem LinearMap.toMatrix'_toLin' (M : Matrix m n R) : LinearMap.toMatrix' (Matrix.toLin' M) = M :=
LinearMap.toMatrix'.apply_symm_apply M
@[simp]
theorem Matrix.toLin'_toMatrix' (f : (n β R) ββ[R] m β R) :
Matrix.toLin' (LinearMap.toMatrix' f) = f :=
Matrix.toLin'.apply_symm_apply f
@[simp]
theorem LinearMap.toMatrix'_apply (f : (n β R) ββ[R] m β R) (i j) :
LinearMap.toMatrix' f i j = f (fun j' β¦ if j' = j then 1 else 0) i := by
simp only [LinearMap.toMatrix', LinearEquiv.coe_mk, of_apply]
congr! with i
split_ifs with h
Β· rw [h, Pi.single_eq_same]
apply Pi.single_eq_of_ne h
@[simp]
theorem Matrix.toLin'_apply (M : Matrix m n R) (v : n β R) : Matrix.toLin' M v = M *α΅₯ v :=
rfl
@[simp]
theorem Matrix.toLin'_one : Matrix.toLin' (1 : Matrix n n R) = LinearMap.id :=
Matrix.mulVecLin_one
@[simp]
theorem LinearMap.toMatrix'_id : LinearMap.toMatrix' (LinearMap.id : (n β R) ββ[R] n β R) = 1 := by
ext
rw [Matrix.one_apply, LinearMap.toMatrix'_apply, id_apply]
@[simp]
theorem LinearMap.toMatrix'_one : LinearMap.toMatrix' (1 : (n β R) ββ[R] n β R) = 1 :=
LinearMap.toMatrix'_id
@[simp]
theorem Matrix.toLin'_mul [Fintype m] [DecidableEq m] (M : Matrix l m R) (N : Matrix m n R) :
Matrix.toLin' (M * N) = (Matrix.toLin' M).comp (Matrix.toLin' N) :=
Matrix.mulVecLin_mul _ _
@[simp]
theorem Matrix.toLin'_submatrix [Fintype l] [DecidableEq l] (fβ : m β k) (eβ : n β l)
(M : Matrix k l R) :
Matrix.toLin' (M.submatrix fβ eβ) =
funLeft R R fβ ββ (Matrix.toLin' M) ββ funLeft _ _ eβ.symm :=
Matrix.mulVecLin_submatrix _ _ _
/-- A variant of `Matrix.toLin'_submatrix` that keeps around `LinearEquiv`s. -/
theorem Matrix.toLin'_reindex [Fintype l] [DecidableEq l] (eβ : k β m) (eβ : l β n)
(M : Matrix k l R) :
Matrix.toLin' (reindex eβ eβ M) =
β(LinearEquiv.funCongrLeft R R eβ.symm) ββ (Matrix.toLin' M) ββ
β(LinearEquiv.funCongrLeft R R eβ) :=
Matrix.mulVecLin_reindex _ _ _
/-- Shortcut lemma for `Matrix.toLin'_mul` and `LinearMap.comp_apply` -/
theorem Matrix.toLin'_mul_apply [Fintype m] [DecidableEq m] (M : Matrix l m R) (N : Matrix m n R)
(x) : Matrix.toLin' (M * N) x = Matrix.toLin' M (Matrix.toLin' N x) := by
rw [Matrix.toLin'_mul, LinearMap.comp_apply]
theorem LinearMap.toMatrix'_comp [Fintype l] [DecidableEq l] (f : (n β R) ββ[R] m β R)
(g : (l β R) ββ[R] n β R) :
LinearMap.toMatrix' (f.comp g) = LinearMap.toMatrix' f * LinearMap.toMatrix' g := by
suffices f.comp g = Matrix.toLin' (LinearMap.toMatrix' f * LinearMap.toMatrix' g) by
rw [this, LinearMap.toMatrix'_toLin']
rw [Matrix.toLin'_mul, Matrix.toLin'_toMatrix', Matrix.toLin'_toMatrix']
theorem LinearMap.toMatrix'_mul [Fintype m] [DecidableEq m] (f g : (m β R) ββ[R] m β R) :
LinearMap.toMatrix' (f * g) = LinearMap.toMatrix' f * LinearMap.toMatrix' g :=
LinearMap.toMatrix'_comp f g
@[simp]
theorem LinearMap.toMatrix'_algebraMap (x : R) :
LinearMap.toMatrix' (algebraMap R (Module.End R (n β R)) x) = scalar n x := by
simp [Module.algebraMap_end_eq_smul_id, smul_eq_diagonal_mul]
theorem Matrix.ker_toLin'_eq_bot_iff {M : Matrix n n R} :
LinearMap.ker (Matrix.toLin' M) = β₯ β β v, M *α΅₯ v = 0 β v = 0 :=
Matrix.ker_mulVecLin_eq_bot_iff
theorem Matrix.range_toLin' (M : Matrix m n R) :
LinearMap.range (Matrix.toLin' M) = span R (range M.col) :=
Matrix.range_mulVecLin _
/-- If `M` and `M'` are each other's inverse matrices, they provide an equivalence between `m β A`
and `n β A` corresponding to `M.mulVec` and `M'.mulVec`. -/
@[simps]
def Matrix.toLin'OfInv [Fintype m] [DecidableEq m] {M : Matrix m n R} {M' : Matrix n m R}
(hMM' : M * M' = 1) (hM'M : M' * M = 1) : (m β R) ββ[R] n β R :=
{ Matrix.toLin' M' with
toFun := Matrix.toLin' M'
invFun := Matrix.toLin' M
left_inv := fun x β¦ by rw [β Matrix.toLin'_mul_apply, hMM', Matrix.toLin'_one, id_apply]
right_inv := fun x β¦ by
rw [β Matrix.toLin'_mul_apply, hM'M, Matrix.toLin'_one, id_apply] }
/-- Linear maps `(n β R) ββ[R] (n β R)` are algebra equivalent to `Matrix n n R`. -/
def LinearMap.toMatrixAlgEquiv' : ((n β R) ββ[R] n β R) ββ[R] Matrix n n R :=
AlgEquiv.ofLinearEquiv LinearMap.toMatrix' LinearMap.toMatrix'_one LinearMap.toMatrix'_mul
/-- A `Matrix n n R` is algebra equivalent to a linear map `(n β R) ββ[R] (n β R)`. -/
def Matrix.toLinAlgEquiv' : Matrix n n R ββ[R] (n β R) ββ[R] n β R :=
LinearMap.toMatrixAlgEquiv'.symm
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_symm :
(LinearMap.toMatrixAlgEquiv'.symm : Matrix n n R ββ[R] _) = Matrix.toLinAlgEquiv' :=
rfl
@[simp]
theorem Matrix.toLinAlgEquiv'_symm :
(Matrix.toLinAlgEquiv'.symm : ((n β R) ββ[R] n β R) ββ[R] _) = LinearMap.toMatrixAlgEquiv' :=
rfl
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_toLinAlgEquiv' (M : Matrix n n R) :
LinearMap.toMatrixAlgEquiv' (Matrix.toLinAlgEquiv' M) = M :=
LinearMap.toMatrixAlgEquiv'.apply_symm_apply M
@[simp]
theorem Matrix.toLinAlgEquiv'_toMatrixAlgEquiv' (f : (n β R) ββ[R] n β R) :
Matrix.toLinAlgEquiv' (LinearMap.toMatrixAlgEquiv' f) = f :=
Matrix.toLinAlgEquiv'.apply_symm_apply f
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_apply (f : (n β R) ββ[R] n β R) (i j) :
LinearMap.toMatrixAlgEquiv' f i j = f (fun j' β¦ if j' = j then 1 else 0) i := by
simp [LinearMap.toMatrixAlgEquiv']
@[simp]
theorem Matrix.toLinAlgEquiv'_apply (M : Matrix n n R) (v : n β R) :
Matrix.toLinAlgEquiv' M v = M *α΅₯ v :=
rfl
theorem Matrix.toLinAlgEquiv'_one : Matrix.toLinAlgEquiv' (1 : Matrix n n R) = LinearMap.id :=
Matrix.toLin'_one
@[simp]
theorem LinearMap.toMatrixAlgEquiv'_id :
LinearMap.toMatrixAlgEquiv' (LinearMap.id : (n β R) ββ[R] n β R) = 1 :=
LinearMap.toMatrix'_id
theorem LinearMap.toMatrixAlgEquiv'_comp (f g : (n β R) ββ[R] n β R) :
LinearMap.toMatrixAlgEquiv' (f.comp g) =
LinearMap.toMatrixAlgEquiv' f * LinearMap.toMatrixAlgEquiv' g :=
LinearMap.toMatrix'_comp _ _
theorem LinearMap.toMatrixAlgEquiv'_mul (f g : (n β R) ββ[R] n β R) :
LinearMap.toMatrixAlgEquiv' (f * g) =
LinearMap.toMatrixAlgEquiv' f * LinearMap.toMatrixAlgEquiv' g :=
LinearMap.toMatrixAlgEquiv'_comp f g
end ToMatrix'
section ToMatrix
section Finite
variable {R : Type*} [CommSemiring R]
variable {l m n : Type*} [Fintype n] [Finite m] [DecidableEq n]
variable {Mβ Mβ : Type*} [AddCommMonoid Mβ] [AddCommMonoid Mβ] [Module R Mβ] [Module R Mβ]
variable (vβ : Basis n R Mβ) (vβ : Basis m R Mβ)
/-- Given bases of two modules `Mβ` and `Mβ` over a commutative ring `R`, we get a linear
equivalence between linear maps `Mβ ββ Mβ` and matrices over `R` indexed by the bases. -/
def LinearMap.toMatrix : (Mβ ββ[R] Mβ) ββ[R] Matrix m n R :=
LinearEquiv.trans (LinearEquiv.arrowCongr vβ.equivFun vβ.equivFun) LinearMap.toMatrix'
/-- `LinearMap.toMatrix'` is a particular case of `LinearMap.toMatrix`, for the standard basis
`Pi.basisFun R n`. -/
theorem LinearMap.toMatrix_eq_toMatrix' :
LinearMap.toMatrix (Pi.basisFun R n) (Pi.basisFun R n) = LinearMap.toMatrix' :=
rfl
/-- Given bases of two modules `Mβ` and `Mβ` over a commutative ring `R`, we get a linear
equivalence between matrices over `R` indexed by the bases and linear maps `Mβ ββ Mβ`. -/
def Matrix.toLin : Matrix m n R ββ[R] Mβ ββ[R] Mβ :=
(LinearMap.toMatrix vβ vβ).symm
/-- `Matrix.toLin'` is a particular case of `Matrix.toLin`, for the standard basis
`Pi.basisFun R n`. -/
theorem Matrix.toLin_eq_toLin' : Matrix.toLin (Pi.basisFun R n) (Pi.basisFun R m) = Matrix.toLin' :=
rfl
@[simp]
theorem LinearMap.toMatrix_symm : (LinearMap.toMatrix vβ vβ).symm = Matrix.toLin vβ vβ :=
rfl
@[simp]
theorem Matrix.toLin_symm : (Matrix.toLin vβ vβ).symm = LinearMap.toMatrix vβ vβ :=
rfl
@[simp]
theorem Matrix.toLin_toMatrix (f : Mβ ββ[R] Mβ) :
Matrix.toLin vβ vβ (LinearMap.toMatrix vβ vβ f) = f := by
rw [β Matrix.toLin_symm, LinearEquiv.apply_symm_apply]
@[simp]
theorem LinearMap.toMatrix_toLin (M : Matrix m n R) :
LinearMap.toMatrix vβ vβ (Matrix.toLin vβ vβ M) = M := by
rw [β Matrix.toLin_symm, LinearEquiv.symm_apply_apply]
theorem LinearMap.toMatrix_apply (f : Mβ ββ[R] Mβ) (i : m) (j : n) :
LinearMap.toMatrix vβ vβ f i j = vβ.repr (f (vβ j)) i := by
rw [LinearMap.toMatrix, LinearEquiv.trans_apply, LinearMap.toMatrix'_apply,
LinearEquiv.arrowCongr_apply, Basis.equivFun_symm_apply, Finset.sum_eq_single j, if_pos rfl,
one_smul, Basis.equivFun_apply]
Β· intro j' _ hj'
rw [if_neg hj', zero_smul]
Β· intro hj
have := Finset.mem_univ j
contradiction
theorem LinearMap.toMatrix_transpose_apply (f : Mβ ββ[R] Mβ) (j : n) :
(LinearMap.toMatrix vβ vβ f)α΅ j = vβ.repr (f (vβ j)) :=
funext fun i β¦ f.toMatrix_apply _ _ i j
theorem LinearMap.toMatrix_apply' (f : Mβ ββ[R] Mβ) (i : m) (j : n) :
LinearMap.toMatrix vβ vβ f i j = vβ.repr (f (vβ j)) i :=
LinearMap.toMatrix_apply vβ vβ f i j
theorem LinearMap.toMatrix_transpose_apply' (f : Mβ ββ[R] Mβ) (j : n) :
(LinearMap.toMatrix vβ vβ f)α΅ j = vβ.repr (f (vβ j)) :=
LinearMap.toMatrix_transpose_apply vβ vβ f j
/-- This will be a special case of `LinearMap.toMatrix_id_eq_basis_toMatrix`. -/
theorem LinearMap.toMatrix_id : LinearMap.toMatrix vβ vβ id = 1 := by
ext i j
simp [LinearMap.toMatrix_apply, Matrix.one_apply, Finsupp.single_apply, eq_comm]
@[simp]
theorem LinearMap.toMatrix_one : LinearMap.toMatrix vβ vβ 1 = 1 :=
LinearMap.toMatrix_id vβ
@[simp]
lemma LinearMap.toMatrix_singleton {ΞΉ : Type*} [Unique ΞΉ] (f : R ββ[R] R) (i j : ΞΉ) :
f.toMatrix (.singleton ΞΉ R) (.singleton ΞΉ R) i j = f 1 := by
simp [toMatrix, Subsingleton.elim j default]
@[simp]
theorem Matrix.toLin_one : Matrix.toLin vβ vβ 1 = LinearMap.id := by
rw [β LinearMap.toMatrix_id vβ, Matrix.toLin_toMatrix]
theorem LinearMap.toMatrix_reindexRange [DecidableEq Mβ] (f : Mβ ββ[R] Mβ) (k : m) (i : n) :
LinearMap.toMatrix vβ.reindexRange vβ.reindexRange f β¨vβ k, Set.mem_range_self kβ©
β¨vβ i, Set.mem_range_self iβ© =
LinearMap.toMatrix vβ vβ f k i := by
simp_rw [LinearMap.toMatrix_apply, Basis.reindexRange_self, Basis.reindexRange_repr]
@[simp]
theorem LinearMap.toMatrix_algebraMap (x : R) :
LinearMap.toMatrix vβ vβ (algebraMap R (Module.End R Mβ) x) = scalar n x := by
simp [Module.algebraMap_end_eq_smul_id, LinearMap.toMatrix_id, smul_eq_diagonal_mul]
theorem LinearMap.toMatrix_mulVec_repr (f : Mβ ββ[R] Mβ) (x : Mβ) :
LinearMap.toMatrix vβ vβ f *α΅₯ vβ.repr x = vβ.repr (f x) := by
ext i
rw [β Matrix.toLin'_apply, LinearMap.toMatrix, LinearEquiv.trans_apply, Matrix.toLin'_toMatrix',
LinearEquiv.arrowCongr_apply, vβ.equivFun_apply]
congr
exact vβ.equivFun.symm_apply_apply x
@[simp]
theorem LinearMap.toMatrix_basis_equiv [Fintype l] [DecidableEq l] (b : Basis l R Mβ)
(b' : Basis l R Mβ) :
LinearMap.toMatrix b' b (b'.equiv b (Equiv.refl l) : Mβ ββ[R] Mβ) = 1 := by
ext i j
simp [LinearMap.toMatrix_apply, Matrix.one_apply, Finsupp.single_apply, eq_comm]
theorem LinearMap.toMatrix_smulBasis_left {G} [Group G] [DistribMulAction G Mβ]
[SMulCommClass G R Mβ] (g : G) (f : Mβ ββ[R] Mβ) :
LinearMap.toMatrix (g β’ vβ) vβ f =
LinearMap.toMatrix vβ vβ (f ββ DistribMulAction.toLinearMap _ _ g) := by
ext
rw [LinearMap.toMatrix_apply, LinearMap.toMatrix_apply]
dsimp
theorem LinearMap.toMatrix_smulBasis_right {G} [Group G] [DistribMulAction G Mβ]
[SMulCommClass G R Mβ] (g : G) (f : Mβ ββ[R] Mβ) :
LinearMap.toMatrix vβ (g β’ vβ) f =
LinearMap.toMatrix vβ vβ (DistribMulAction.toLinearMap _ _ gβ»ΒΉ ββ f) := by
ext
rw [LinearMap.toMatrix_apply, LinearMap.toMatrix_apply]
dsimp
end Finite
variable {R : Type*} [CommSemiring R]
variable {l m n : Type*} [Fintype n] [Fintype m] [DecidableEq n]
variable {Mβ Mβ : Type*} [AddCommMonoid Mβ] [AddCommMonoid Mβ] [Module R Mβ] [Module R Mβ]
variable (vβ : Basis n R Mβ) (vβ : Basis m R Mβ)
theorem Matrix.toLin_apply (M : Matrix m n R) (v : Mβ) :
Matrix.toLin vβ vβ M v = β j, (M *α΅₯ vβ.repr v) j β’ vβ j :=
show vβ.equivFun.symm (Matrix.toLin' M (vβ.repr v)) = _ by
rw [Matrix.toLin'_apply, vβ.equivFun_symm_apply]
@[simp]
theorem Matrix.toLin_self (M : Matrix m n R) (i : n) :
Matrix.toLin vβ vβ M (vβ i) = β j, M j i β’ vβ j := by
rw [Matrix.toLin_apply, Finset.sum_congr rfl fun j _hj β¦ ?_]
rw [Basis.repr_self, Matrix.mulVec, dotProduct, Finset.sum_eq_single i, Finsupp.single_eq_same,
mul_one]
Β· intro i' _ i'_ne
rw [Finsupp.single_eq_of_ne i'_ne.symm, mul_zero]
Β· intros
have := Finset.mem_univ i
contradiction
variable {Mβ : Type*} [AddCommMonoid Mβ] [Module R Mβ] (vβ : Basis l R Mβ)
theorem LinearMap.toMatrix_comp [Finite l] [DecidableEq m] (f : Mβ ββ[R] Mβ) (g : Mβ ββ[R] Mβ) :
LinearMap.toMatrix vβ vβ (f.comp g) =
LinearMap.toMatrix vβ vβ f * LinearMap.toMatrix vβ vβ g := by
simp_rw [LinearMap.toMatrix, LinearEquiv.trans_apply, LinearEquiv.arrowCongr_comp _ vβ.equivFun,
LinearMap.toMatrix'_comp]
| Mathlib/LinearAlgebra/Matrix/ToLin.lean | 636 | 640 | theorem LinearMap.toMatrix_mul (f g : Mβ ββ[R] Mβ) :
LinearMap.toMatrix vβ vβ (f * g) = LinearMap.toMatrix vβ vβ f * LinearMap.toMatrix vβ vβ g := by | rw [Module.End.mul_eq_comp, LinearMap.toMatrix_comp vβ vβ vβ f g]
lemma LinearMap.toMatrix_pow (f : Mβ ββ[R] Mβ) (k : β) : |
/-
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, Kenny Lau, Johan Commelin, Mario Carneiro, Kevin Buzzard,
Amelia Livingston, Yury Kudryashov
-/
import Mathlib.Algebra.BigOperators.Group.Multiset.Defs
import Mathlib.Algebra.FreeMonoid.Basic
import Mathlib.Algebra.Group.Idempotent
import Mathlib.Algebra.Group.Nat.Hom
import Mathlib.Algebra.Group.Submonoid.MulOpposite
import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Data.Fintype.EquivFin
import Mathlib.Data.Int.Basic
/-!
# Submonoids: membership criteria
In this file we prove various facts about membership in a submonoid:
* `pow_mem`, `nsmul_mem`: if `x β S` where `S` is a multiplicative (resp., additive) submonoid and
`n` is a natural number, then `x^n` (resp., `n β’ x`) belongs to `S`;
* `mem_iSup_of_directed`, `coe_iSup_of_directed`, `mem_sSup_of_directedOn`,
`coe_sSup_of_directedOn`: the supremum of a directed collection of submonoid is their union.
* `sup_eq_range`, `mem_sup`: supremum of two submonoids `S`, `T` of a commutative monoid is the set
of products;
* `closure_singleton_eq`, `mem_closure_singleton`, `mem_closure_pair`: the multiplicative (resp.,
additive) closure of `{x}` consists of powers (resp., natural multiples) of `x`, and a similar
result holds for the closure of `{x, y}`.
## Tags
submonoid, submonoids
-/
assert_not_exists MonoidWithZero
variable {M A B : Type*}
section Assoc
variable [Monoid M] [SetLike B M] [SubmonoidClass B M] {S : B}
end Assoc
section NonAssoc
variable [MulOneClass M]
open Set
namespace Submonoid
-- TODO: this section can be generalized to `[SubmonoidClass B M] [CompleteLattice B]`
-- such that `CompleteLattice.LE` coincides with `SetLike.LE`
@[to_additive]
theorem mem_iSup_of_directed {ΞΉ} [hΞΉ : Nonempty ΞΉ] {S : ΞΉ β Submonoid M} (hS : Directed (Β· β€ Β·) S)
{x : M} : (x β β¨ i, S i) β β i, x β S i := by
refine β¨?_, fun β¨i, hiβ© β¦ le_iSup S i hiβ©
suffices x β closure (β i, (S i : Set M)) β β i, x β S i by
simpa only [closure_iUnion, closure_eq (S _)] using this
refine closure_induction (fun _ β¦ mem_iUnion.1) ?_ ?_
Β· exact hΞΉ.elim fun i β¦ β¨i, (S i).one_memβ©
Β· rintro x y - - β¨i, hiβ© β¨j, hjβ©
rcases hS i j with β¨k, hki, hkjβ©
exact β¨k, (S k).mul_mem (hki hi) (hkj hj)β©
@[to_additive]
theorem coe_iSup_of_directed {ΞΉ} [Nonempty ΞΉ] {S : ΞΉ β Submonoid M} (hS : Directed (Β· β€ Β·) S) :
((β¨ i, S i : Submonoid M) : Set M) = β i, S i :=
Set.ext fun x β¦ by simp [mem_iSup_of_directed hS]
@[to_additive]
theorem mem_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty)
(hS : DirectedOn (Β· β€ Β·) S) {x : M} : x β sSup S β β s β S, x β s := by
haveI : Nonempty S := Sne.to_subtype
simp [sSup_eq_iSup', mem_iSup_of_directed hS.directed_val, SetCoe.exists, Subtype.coe_mk]
@[to_additive]
theorem coe_sSup_of_directedOn {S : Set (Submonoid M)} (Sne : S.Nonempty)
(hS : DirectedOn (Β· β€ Β·) S) : (β(sSup S) : Set M) = β s β S, βs :=
Set.ext fun x => by simp [mem_sSup_of_directedOn Sne hS]
@[to_additive]
| Mathlib/Algebra/Group/Submonoid/Membership.lean | 84 | 88 | theorem mem_sup_left {S T : Submonoid M} : β {x : M}, x β S β x β S β T := by | rw [β SetLike.le_def]
exact le_sup_left
@[to_additive] |
/-
Copyright (c) 2017 Johannes HΓΆlzl. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johannes HΓΆlzl
-/
import Mathlib.Data.Set.Function
import Mathlib.Logic.Pairwise
import Mathlib.Logic.Relation
/-!
# Relations holding pairwise
This file develops pairwise relations and defines pairwise disjoint indexed sets.
We also prove many basic facts about `Pairwise`. It is possible that an intermediate file,
with more imports than `Logic.Pairwise` but not importing `Data.Set.Function` would be appropriate
to hold many of these basic facts.
## Main declarations
* `Set.PairwiseDisjoint`: `s.PairwiseDisjoint f` states that images under `f` of distinct elements
of `s` are either equal or `Disjoint`.
## Notes
The spelling `s.PairwiseDisjoint id` is preferred over `s.Pairwise Disjoint` to permit dot notation
on `Set.PairwiseDisjoint`, even though the latter unfolds to something nicer.
-/
open Function Order Set
variable {Ξ± Ξ² Ξ³ ΞΉ ΞΉ' : Type*} {r p : Ξ± β Ξ± β Prop}
section Pairwise
variable {f g : ΞΉ β Ξ±} {s t : Set Ξ±} {a b : Ξ±}
theorem pairwise_on_bool (hr : Symmetric r) {a b : Ξ±} :
Pairwise (r on fun c => cond c a b) β r a b := by simpa [Pairwise, Function.onFun] using @hr a b
theorem pairwise_disjoint_on_bool [PartialOrder Ξ±] [OrderBot Ξ±] {a b : Ξ±} :
Pairwise (Disjoint on fun c => cond c a b) β Disjoint a b :=
pairwise_on_bool Disjoint.symm
theorem Symmetric.pairwise_on [LinearOrder ΞΉ] (hr : Symmetric r) (f : ΞΉ β Ξ±) :
Pairwise (r on f) β β β¦m nβ¦, m < n β r (f m) (f n) :=
β¨fun h _m _n hmn => h hmn.ne, fun h _m _n hmn => hmn.lt_or_lt.elim (@h _ _) fun h' => hr (h h')β©
theorem pairwise_disjoint_on [PartialOrder Ξ±] [OrderBot Ξ±] [LinearOrder ΞΉ] (f : ΞΉ β Ξ±) :
Pairwise (Disjoint on f) β β β¦m nβ¦, m < n β Disjoint (f m) (f n) :=
Symmetric.pairwise_on Disjoint.symm f
theorem pairwise_disjoint_mono [PartialOrder Ξ±] [OrderBot Ξ±] (hs : Pairwise (Disjoint on f))
(h : g β€ f) : Pairwise (Disjoint on g) :=
hs.mono fun i j hij => Disjoint.mono (h i) (h j) hij
theorem Pairwise.disjoint_extend_bot [PartialOrder Ξ³] [OrderBot Ξ³]
{e : Ξ± β Ξ²} {f : Ξ± β Ξ³} (hf : Pairwise (Disjoint on f)) (he : FactorsThrough f e) :
Pairwise (Disjoint on extend e f β₯) := by
intro bβ bβ hne
rcases em (β aβ, e aβ = bβ) with β¨aβ, rflβ© | hbβ
Β· rcases em (β aβ, e aβ = bβ) with β¨aβ, rflβ© | hbβ
Β· simpa only [onFun, he.extend_apply] using hf (ne_of_apply_ne e hne)
Β· simpa only [onFun, extend_apply' _ _ _ hbβ] using disjoint_bot_right
Β· simpa only [onFun, extend_apply' _ _ _ hbβ] using disjoint_bot_left
namespace Set
theorem Pairwise.mono (h : t β s) (hs : s.Pairwise r) : t.Pairwise r :=
fun _x xt _y yt => hs (h xt) (h yt)
theorem Pairwise.mono' (H : r β€ p) (hr : s.Pairwise r) : s.Pairwise p :=
hr.imp H
theorem pairwise_top (s : Set Ξ±) : s.Pairwise β€ :=
pairwise_of_forall s _ fun _ _ => trivial
protected theorem Subsingleton.pairwise (h : s.Subsingleton) (r : Ξ± β Ξ± β Prop) : s.Pairwise r :=
fun _x hx _y hy hne => (hne (h hx hy)).elim
@[simp]
theorem pairwise_empty (r : Ξ± β Ξ± β Prop) : (β
: Set Ξ±).Pairwise r :=
subsingleton_empty.pairwise r
@[simp]
theorem pairwise_singleton (a : Ξ±) (r : Ξ± β Ξ± β Prop) : Set.Pairwise {a} r :=
subsingleton_singleton.pairwise r
theorem pairwise_iff_of_refl [IsRefl Ξ± r] : s.Pairwise r β β β¦aβ¦, a β s β β β¦bβ¦, b β s β r a b :=
forallβ_congr fun _ _ _ _ => or_iff_not_imp_left.symm.trans <| or_iff_right_of_imp of_eq
alias β¨Pairwise.of_refl, _β© := pairwise_iff_of_refl
theorem Nonempty.pairwise_iff_exists_forall [IsEquiv Ξ± r] {s : Set ΞΉ} (hs : s.Nonempty) :
s.Pairwise (r on f) β β z, β x β s, r (f x) z := by
constructor
Β· rcases hs with β¨y, hyβ©
refine fun H => β¨f y, fun x hx => ?_β©
rcases eq_or_ne x y with (rfl | hne)
Β· apply IsRefl.refl
Β· exact H hx hy hne
Β· rintro β¨z, hzβ© x hx y hy _
exact @IsTrans.trans Ξ± r _ (f x) z (f y) (hz _ hx) (IsSymm.symm _ _ <| hz _ hy)
/-- For a nonempty set `s`, a function `f` takes pairwise equal values on `s` if and only if
for some `z` in the codomain, `f` takes value `z` on all `x β s`. See also
`Set.pairwise_eq_iff_exists_eq` for a version that assumes `[Nonempty ΞΉ]` instead of
`Set.Nonempty s`. -/
theorem Nonempty.pairwise_eq_iff_exists_eq {s : Set Ξ±} (hs : s.Nonempty) {f : Ξ± β ΞΉ} :
(s.Pairwise fun x y => f x = f y) β β z, β x β s, f x = z :=
hs.pairwise_iff_exists_forall
theorem pairwise_iff_exists_forall [Nonempty ΞΉ] (s : Set Ξ±) (f : Ξ± β ΞΉ) {r : ΞΉ β ΞΉ β Prop}
[IsEquiv ΞΉ r] : s.Pairwise (r on f) β β z, β x β s, r (f x) z := by
rcases s.eq_empty_or_nonempty with (rfl | hne)
Β· simp
Β· exact hne.pairwise_iff_exists_forall
/-- A function `f : Ξ± β ΞΉ` with nonempty codomain takes pairwise equal values on a set `s` if and
only if for some `z` in the codomain, `f` takes value `z` on all `x β s`. See also
`Set.Nonempty.pairwise_eq_iff_exists_eq` for a version that assumes `Set.Nonempty s` instead of
`[Nonempty ΞΉ]`. -/
theorem pairwise_eq_iff_exists_eq [Nonempty ΞΉ] (s : Set Ξ±) (f : Ξ± β ΞΉ) :
(s.Pairwise fun x y => f x = f y) β β z, β x β s, f x = z :=
pairwise_iff_exists_forall s f
theorem pairwise_union :
(s βͺ t).Pairwise r β
s.Pairwise r β§ t.Pairwise r β§ β a β s, β b β t, a β b β r a b β§ r b a := by
simp only [Set.Pairwise, mem_union, or_imp, forall_and]
aesop
theorem pairwise_union_of_symmetric (hr : Symmetric r) :
(s βͺ t).Pairwise r β s.Pairwise r β§ t.Pairwise r β§ β a β s, β b β t, a β b β r a b :=
pairwise_union.trans <| by simp only [hr.iff, and_self_iff]
theorem pairwise_insert :
(insert a s).Pairwise r β s.Pairwise r β§ β b β s, a β b β r a b β§ r b a := by
simp only [insert_eq, pairwise_union, pairwise_singleton, true_and, mem_singleton_iff, forall_eq]
theorem pairwise_insert_of_not_mem (ha : a β s) :
(insert a s).Pairwise r β s.Pairwise r β§ β b β s, r a b β§ r b a :=
pairwise_insert.trans <|
and_congr_right' <| forallβ_congr fun b hb => by simp [(ne_of_mem_of_not_mem hb ha).symm]
protected theorem Pairwise.insert (hs : s.Pairwise r) (h : β b β s, a β b β r a b β§ r b a) :
(insert a s).Pairwise r :=
pairwise_insert.2 β¨hs, hβ©
theorem Pairwise.insert_of_not_mem (ha : a β s) (hs : s.Pairwise r) (h : β b β s, r a b β§ r b a) :
(insert a s).Pairwise r :=
(pairwise_insert_of_not_mem ha).2 β¨hs, hβ©
theorem pairwise_insert_of_symmetric (hr : Symmetric r) :
(insert a s).Pairwise r β s.Pairwise r β§ β b β s, a β b β r a b := by
simp only [pairwise_insert, hr.iff a, and_self_iff]
theorem pairwise_insert_of_symmetric_of_not_mem (hr : Symmetric r) (ha : a β s) :
(insert a s).Pairwise r β s.Pairwise r β§ β b β s, r a b := by
simp only [pairwise_insert_of_not_mem ha, hr.iff a, and_self_iff]
theorem Pairwise.insert_of_symmetric (hs : s.Pairwise r) (hr : Symmetric r)
(h : β b β s, a β b β r a b) : (insert a s).Pairwise r :=
(pairwise_insert_of_symmetric hr).2 β¨hs, hβ©
@[deprecated Pairwise.insert_of_symmetric (since := "2025-03-19")]
theorem Pairwise.insert_of_symmetric_of_not_mem (hs : s.Pairwise r) (hr : Symmetric r) (ha : a β s)
(h : β b β s, r a b) : (insert a s).Pairwise r :=
(pairwise_insert_of_symmetric_of_not_mem hr ha).2 β¨hs, hβ©
theorem pairwise_pair : Set.Pairwise {a, b} r β a β b β r a b β§ r b a := by simp [pairwise_insert]
theorem pairwise_pair_of_symmetric (hr : Symmetric r) : Set.Pairwise {a, b} r β a β b β r a b := by
simp [pairwise_insert_of_symmetric hr]
theorem pairwise_univ : (univ : Set Ξ±).Pairwise r β Pairwise r := by
simp only [Set.Pairwise, Pairwise, mem_univ, forall_const]
@[simp]
theorem pairwise_bot_iff : s.Pairwise (β₯ : Ξ± β Ξ± β Prop) β (s : Set Ξ±).Subsingleton :=
β¨fun h _a ha _b hb => h.eq ha hb id, fun h => h.pairwise _β©
alias β¨Pairwise.subsingleton, _β© := pairwise_bot_iff
/-- See also `Function.injective_iff_pairwise_ne` -/
lemma injOn_iff_pairwise_ne {s : Set ΞΉ} : InjOn f s β s.Pairwise (f Β· β f Β·) := by
simp only [InjOn, Set.Pairwise, not_imp_not]
alias β¨InjOn.pairwise_ne, _β© := injOn_iff_pairwise_ne
protected theorem Pairwise.image {s : Set ΞΉ} (h : s.Pairwise (r on f)) : (f '' s).Pairwise r :=
forall_mem_image.2 fun _x hx β¦ forall_mem_image.2 fun _y hy hne β¦ h hx hy <| ne_of_apply_ne _ hne
/-- See also `Set.Pairwise.image`. -/
| Mathlib/Data/Set/Pairwise/Basic.lean | 196 | 197 | theorem InjOn.pairwise_image {s : Set ΞΉ} (h : s.InjOn f) :
(f '' s).Pairwise r β s.Pairwise (r on f) := by | |
/-
Copyright (c) 2021 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.LinearAlgebra.Basis.Basic
import Mathlib.LinearAlgebra.Basis.Submodule
import Mathlib.LinearAlgebra.Dimension.Finrank
import Mathlib.LinearAlgebra.InvariantBasisNumber
/-!
# Lemmas about rank and finrank in rings satisfying strong rank condition.
## Main statements
For modules over rings satisfying the rank condition
* `Basis.le_span`:
the cardinality of a basis is bounded by the cardinality of any spanning set
For modules over rings satisfying the strong rank condition
* `linearIndependent_le_span`:
For any linearly independent family `v : ΞΉ β M`
and any finite spanning set `w : Set M`,
the cardinality of `ΞΉ` is bounded by the cardinality of `w`.
* `linearIndependent_le_basis`:
If `b` is a basis for a module `M`,
and `s` is a linearly independent set,
then the cardinality of `s` is bounded by the cardinality of `b`.
For modules over rings with invariant basis number
(including all commutative rings and all noetherian rings)
* `mk_eq_mk_of_basis`: the dimension theorem, any two bases of the same vector space have the same
cardinality.
## Additional definition
* `Algebra.IsQuadraticExtension`: An extension of rings `R β S` is quadratic if `S` is a
free `R`-algebra of rank `2`.
-/
noncomputable section
universe u v w w'
variable {R : Type u} {M : Type v} [Semiring R] [AddCommMonoid M] [Module R M]
variable {ΞΉ : Type w} {ΞΉ' : Type w'}
open Cardinal Basis Submodule Function Set Module
attribute [local instance] nontrivial_of_invariantBasisNumber
section InvariantBasisNumber
variable [InvariantBasisNumber R]
/-- The dimension theorem: if `v` and `v'` are two bases, their index types
have the same cardinalities. -/
theorem mk_eq_mk_of_basis (v : Basis ΞΉ R M) (v' : Basis ΞΉ' R M) :
Cardinal.lift.{w'} #ΞΉ = Cardinal.lift.{w} #ΞΉ' := by
classical
haveI := nontrivial_of_invariantBasisNumber R
cases fintypeOrInfinite ΞΉ
Β· -- `v` is a finite basis, so by `basis_finite_of_finite_spans` so is `v'`.
-- haveI : Finite (range v) := Set.finite_range v
haveI := basis_finite_of_finite_spans (Set.finite_range v) v.span_eq v'
cases nonempty_fintype ΞΉ'
-- We clean up a little:
rw [Cardinal.mk_fintype, Cardinal.mk_fintype]
simp only [Cardinal.lift_natCast, Nat.cast_inj]
-- Now we can use invariant basis number to show they have the same cardinality.
apply card_eq_of_linearEquiv R
exact
(Finsupp.linearEquivFunOnFinite R R ΞΉ).symm.trans v.repr.symm βͺβ«β v'.repr βͺβ«β
Finsupp.linearEquivFunOnFinite R R ΞΉ'
Β· -- `v` is an infinite basis,
-- so by `infinite_basis_le_maximal_linearIndependent`, `v'` is at least as big,
-- and then applying `infinite_basis_le_maximal_linearIndependent` again
-- we see they have the same cardinality.
have wβ := infinite_basis_le_maximal_linearIndependent' v _ v'.linearIndependent v'.maximal
rcases Cardinal.lift_mk_le'.mp wβ with β¨fβ©
haveI : Infinite ΞΉ' := Infinite.of_injective f f.2
have wβ := infinite_basis_le_maximal_linearIndependent' v' _ v.linearIndependent v.maximal
exact le_antisymm wβ wβ
/-- Given two bases indexed by `ΞΉ` and `ΞΉ'` of an `R`-module, where `R` satisfies the invariant
basis number property, an equiv `ΞΉ β ΞΉ'`. -/
def Basis.indexEquiv (v : Basis ΞΉ R M) (v' : Basis ΞΉ' R M) : ΞΉ β ΞΉ' :=
(Cardinal.lift_mk_eq'.1 <| mk_eq_mk_of_basis v v').some
theorem mk_eq_mk_of_basis' {ΞΉ' : Type w} (v : Basis ΞΉ R M) (v' : Basis ΞΉ' R M) : #ΞΉ = #ΞΉ' :=
Cardinal.lift_inj.1 <| mk_eq_mk_of_basis v v'
end InvariantBasisNumber
section RankCondition
variable [RankCondition R]
/-- An auxiliary lemma for `Basis.le_span`.
If `R` satisfies the rank condition,
then for any finite basis `b : Basis ΞΉ R M`,
and any finite spanning set `w : Set M`,
the cardinality of `ΞΉ` is bounded by the cardinality of `w`.
-/
theorem Basis.le_span'' {ΞΉ : Type*} [Fintype ΞΉ] (b : Basis ΞΉ R M) {w : Set M} [Fintype w]
(s : span R w = β€) : Fintype.card ΞΉ β€ Fintype.card w := by
-- We construct a surjective linear map `(w β R) ββ[R] (ΞΉ β R)`,
-- by expressing a linear combination in `w` as a linear combination in `ΞΉ`.
fapply card_le_of_surjective' R
Β· exact b.repr.toLinearMap.comp (Finsupp.linearCombination R (β))
Β· apply Surjective.comp (g := b.repr.toLinearMap)
Β· apply LinearEquiv.surjective
rw [β LinearMap.range_eq_top, Finsupp.range_linearCombination]
simpa using s
/--
Another auxiliary lemma for `Basis.le_span`, which does not require assuming the basis is finite,
but still assumes we have a finite spanning set.
-/
theorem basis_le_span' {ΞΉ : Type*} (b : Basis ΞΉ R M) {w : Set M} [Fintype w] (s : span R w = β€) :
#ΞΉ β€ Fintype.card w := by
haveI := nontrivial_of_invariantBasisNumber R
haveI := basis_finite_of_finite_spans w.toFinite s b
cases nonempty_fintype ΞΉ
rw [Cardinal.mk_fintype ΞΉ]
simp only [Nat.cast_le]
exact Basis.le_span'' b s
-- Note that if `R` satisfies the strong rank condition,
-- this also follows from `linearIndependent_le_span` below.
/-- If `R` satisfies the rank condition,
then the cardinality of any basis is bounded by the cardinality of any spanning set.
-/
| Mathlib/LinearAlgebra/Dimension/StrongRankCondition.lean | 140 | 164 | theorem Basis.le_span {J : Set M} (v : Basis ΞΉ R M) (hJ : span R J = β€) : #(range v) β€ #J := by | haveI := nontrivial_of_invariantBasisNumber R
cases fintypeOrInfinite J
Β· rw [β Cardinal.lift_le, Cardinal.mk_range_eq_of_injective v.injective, Cardinal.mk_fintype J]
convert Cardinal.lift_le.{v}.2 (basis_le_span' v hJ)
simp
Β· let S : J β Set ΞΉ := fun j => β(v.repr j).support
let S' : J β Set M := fun j => v '' S j
have hs : range v β β j, S' j := by
intro b hb
rcases mem_range.1 hb with β¨i, hiβ©
have : span R J β€ comap v.repr.toLinearMap (Finsupp.supported R R (β j, S j)) :=
span_le.2 fun j hj x hx => β¨_, β¨β¨j, hjβ©, rflβ©, hxβ©
rw [hJ] at this
replace : v.repr (v i) β Finsupp.supported R R (β j, S j) := this trivial
rw [v.repr_self, Finsupp.mem_supported, Finsupp.support_single_ne_zero _ one_ne_zero] at this
Β· subst b
rcases mem_iUnion.1 (this (Finset.mem_singleton_self _)) with β¨j, hjβ©
exact mem_iUnion.2 β¨j, (mem_image _ _ _).2 β¨i, hj, rflβ©β©
refine le_of_not_lt fun IJ => ?_
suffices #(β j, S' j) < #(range v) by exact not_le_of_lt this β¨Set.embeddingOfSubset _ _ hsβ©
refine lt_of_le_of_lt (le_trans Cardinal.mk_iUnion_le_sum_mk
(Cardinal.sum_le_sum _ (fun _ => β΅β) ?_)) ?_
Β· exact fun j => (Cardinal.lt_aleph0_of_finite _).le
Β· simpa |
/-
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.Sets.Closeds
import Mathlib.Topology.Sets.OpenCover
/-!
# 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.
* `genericPoints` : The set of generic points of irreducible components.
-/
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
theorem isGenericPoint_def {x : Ξ±} {S : Set Ξ±} : IsGenericPoint x S β closure ({x} : Set Ξ±) = S :=
Iff.rfl
theorem IsGenericPoint.def {x : Ξ±} {S : Set Ξ±} (h : IsGenericPoint x S) :
closure ({x} : Set Ξ±) = S :=
h
theorem isGenericPoint_closure {x : Ξ±} : IsGenericPoint x (closure ({x} : Set Ξ±)) :=
refl _
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]
namespace IsGenericPoint
theorem specializes_iff_mem (h : IsGenericPoint x S) : x β€³ y β y β S :=
isGenericPoint_iff_specializes.1 h y
protected theorem specializes (h : IsGenericPoint x S) (h' : y β S) : x β€³ y :=
h.specializes_iff_mem.2 h'
protected theorem mem (h : IsGenericPoint x S) : x β S :=
h.specializes_iff_mem.1 specializes_rfl
protected theorem isClosed (h : IsGenericPoint x S) : IsClosed S :=
h.def βΈ isClosed_closure
protected theorem isIrreducible (h : IsGenericPoint x S) : IsIrreducible S :=
h.def βΈ isIrreducible_singleton.closure
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
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β©
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]
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]
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]
end IsGenericPoint
| Mathlib/Topology/Sober.lean | 92 | 93 | theorem isGenericPoint_iff_forall_closed (hS : IsClosed S) (hxS : x β S) :
IsGenericPoint x S β β Z : Set Ξ±, IsClosed Z β x β Z β S β Z := by | |
/-
Copyright (c) 2020 Kim Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kim Morrison
-/
import Mathlib.CategoryTheory.Monoidal.Discrete
import Mathlib.CategoryTheory.Monoidal.NaturalTransformation
import Mathlib.CategoryTheory.Monoidal.Opposite
import Mathlib.Tactic.CategoryTheory.Monoidal.Basic
import Mathlib.CategoryTheory.CommSq
/-!
# Braided and symmetric monoidal categories
The basic definitions of braided monoidal categories, and symmetric monoidal categories,
as well as braided functors.
## Implementation note
We make `BraidedCategory` another typeclass, but then have `SymmetricCategory` extend this.
The rationale is that we are not carrying any additional data, just requiring a property.
## Future work
* Construct the Drinfeld center of a monoidal category as a braided monoidal category.
* Say something about pseudo-natural transformations.
## References
* [Pavel Etingof, Shlomo Gelaki, Dmitri Nikshych, Victor Ostrik, *Tensor categories*][egno15]
-/
universe v vβ vβ vβ u uβ uβ uβ
namespace CategoryTheory
open Category MonoidalCategory Functor.LaxMonoidal Functor.OplaxMonoidal Functor.Monoidal
/-- A braided monoidal category is a monoidal category equipped with a braiding isomorphism
`Ξ²_ X Y : X β Y β
Y β X`
which is natural in both arguments,
and also satisfies the two hexagon identities.
-/
class BraidedCategory (C : Type u) [Category.{v} C] [MonoidalCategory.{v} C] where
/-- The braiding natural isomorphism. -/
braiding : β X Y : C, X β Y β
Y β X
braiding_naturality_right :
β (X : C) {Y Z : C} (f : Y βΆ Z),
X β f β« (braiding X Z).hom = (braiding X Y).hom β« f β· X := by
aesop_cat
braiding_naturality_left :
β {X Y : C} (f : X βΆ Y) (Z : C),
f β· Z β« (braiding Y Z).hom = (braiding X Z).hom β« Z β f := by
aesop_cat
/-- The first hexagon identity. -/
hexagon_forward :
β X Y Z : C,
(Ξ±_ X Y Z).hom β« (braiding X (Y β Z)).hom β« (Ξ±_ Y Z X).hom =
((braiding X Y).hom β· Z) β« (Ξ±_ Y X Z).hom β« (Y β (braiding X Z).hom) := by
aesop_cat
/-- The second hexagon identity. -/
hexagon_reverse :
β X Y Z : C,
(Ξ±_ X Y Z).inv β« (braiding (X β Y) Z).hom β« (Ξ±_ Z X Y).inv =
(X β (braiding Y Z).hom) β« (Ξ±_ X Z Y).inv β« ((braiding X Z).hom β· Y) := by
aesop_cat
attribute [reassoc (attr := simp)]
BraidedCategory.braiding_naturality_left
BraidedCategory.braiding_naturality_right
attribute [reassoc] BraidedCategory.hexagon_forward BraidedCategory.hexagon_reverse
open BraidedCategory
@[inherit_doc]
notation "Ξ²_" => BraidedCategory.braiding
namespace BraidedCategory
variable {C : Type u} [Category.{v} C] [MonoidalCategory.{v} C] [BraidedCategory.{v} C]
@[simp, reassoc]
theorem braiding_tensor_left (X Y Z : C) :
(Ξ²_ (X β Y) Z).hom =
(Ξ±_ X Y Z).hom β« X β (Ξ²_ Y Z).hom β« (Ξ±_ X Z Y).inv β«
(Ξ²_ X Z).hom β· Y β« (Ξ±_ Z X Y).hom := by
apply (cancel_epi (Ξ±_ X Y Z).inv).1
apply (cancel_mono (Ξ±_ Z X Y).inv).1
simp [hexagon_reverse]
@[simp, reassoc]
theorem braiding_tensor_right (X Y Z : C) :
(Ξ²_ X (Y β Z)).hom =
(Ξ±_ X Y Z).inv β« (Ξ²_ X Y).hom β· Z β« (Ξ±_ Y X Z).hom β«
Y β (Ξ²_ X Z).hom β« (Ξ±_ Y Z X).inv := by
apply (cancel_epi (Ξ±_ X Y Z).hom).1
apply (cancel_mono (Ξ±_ Y Z X).hom).1
simp [hexagon_forward]
@[simp, reassoc]
theorem braiding_inv_tensor_left (X Y Z : C) :
(Ξ²_ (X β Y) Z).inv =
(Ξ±_ Z X Y).inv β« (Ξ²_ X Z).inv β· Y β« (Ξ±_ X Z Y).hom β«
X β (Ξ²_ Y Z).inv β« (Ξ±_ X Y Z).inv :=
eq_of_inv_eq_inv (by simp)
@[simp, reassoc]
theorem braiding_inv_tensor_right (X Y Z : C) :
(Ξ²_ X (Y β Z)).inv =
(Ξ±_ Y Z X).hom β« Y β (Ξ²_ X Z).inv β« (Ξ±_ Y X Z).inv β«
(Ξ²_ X Y).inv β· Z β« (Ξ±_ X Y Z).hom :=
eq_of_inv_eq_inv (by simp)
@[reassoc (attr := simp)]
| Mathlib/CategoryTheory/Monoidal/Braided/Basic.lean | 118 | 122 | theorem braiding_naturality {X X' Y Y' : C} (f : X βΆ Y) (g : X' βΆ Y') :
(f β g) β« (braiding Y Y').hom = (braiding X X').hom β« (g β f) := by | rw [tensorHom_def' f g, tensorHom_def g f]
simp_rw [Category.assoc, braiding_naturality_left, braiding_naturality_right_assoc] |
/-
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.Data.Fin.Tuple.Basic
/-!
# Lists from functions
Theorems and lemmas for dealing with `List.ofFn`, which converts a function on `Fin n` to a list
of length `n`.
## Main Statements
The main statements pertain to lists generated using `List.ofFn`
- `List.get?_ofFn`, which tells us the nth element of such a list
- `List.equivSigmaTuple`, which is an `Equiv` between lists and the functions that generate them
via `List.ofFn`.
-/
assert_not_exists Monoid
universe u
variable {Ξ± : Type u}
open Nat
namespace List
theorem get_ofFn {n} (f : Fin n β Ξ±) (i) : get (ofFn f) i = f (Fin.cast (by simp) i) := by
simp; congr
@[deprecated (since := "2025-02-15")] alias get?_ofFn := List.getElem?_ofFn
@[simp]
theorem map_ofFn {Ξ² : Type*} {n : β} (f : Fin n β Ξ±) (g : Ξ± β Ξ²) :
map g (ofFn f) = ofFn (g β f) :=
ext_get (by simp) fun i h h' => by simp
@[congr]
theorem ofFn_congr {m n : β} (h : m = n) (f : Fin m β Ξ±) :
ofFn f = ofFn fun i : Fin n => f (Fin.cast h.symm i) := by
subst h
simp_rw [Fin.cast_refl, id]
theorem ofFn_succ' {n} (f : Fin (succ n) β Ξ±) :
ofFn f = (ofFn fun i => f (Fin.castSucc i)).concat (f (Fin.last _)) := by
induction' n with n IH
Β· rw [ofFn_zero, concat_nil, ofFn_succ, ofFn_zero]
rfl
Β· rw [ofFn_succ, IH, ofFn_succ, concat_cons, Fin.castSucc_zero]
congr
/-- Note this matches the convention of `List.ofFn_succ'`, putting the `Fin m` elements first. -/
theorem ofFn_add {m n} (f : Fin (m + n) β Ξ±) :
List.ofFn f =
(List.ofFn fun i => f (Fin.castAdd n i)) ++ List.ofFn fun j => f (Fin.natAdd m j) := by
induction' n with n IH
Β· rw [ofFn_zero, append_nil, Fin.castAdd_zero, Fin.cast_refl]
rfl
Β· rw [ofFn_succ', ofFn_succ', IH, append_concat]
rfl
@[simp]
theorem ofFn_fin_append {m n} (a : Fin m β Ξ±) (b : Fin n β Ξ±) :
List.ofFn (Fin.append a b) = List.ofFn a ++ List.ofFn b := by
simp_rw [ofFn_add, Fin.append_left, Fin.append_right]
/-- This breaks a list of `m*n` items into `m` groups each containing `n` elements. -/
theorem ofFn_mul {m n} (f : Fin (m * n) β Ξ±) :
List.ofFn f = List.flatten (List.ofFn fun i : Fin m => List.ofFn fun j : Fin n => f β¨i * n + j,
calc
βi * n + j < (i + 1) * n :=
(Nat.add_lt_add_left j.prop _).trans_eq (by rw [Nat.add_mul, Nat.one_mul])
_ β€ _ := Nat.mul_le_mul_right _ i.propβ©) := by
induction' m with m IH
Β· simp [ofFn_zero, Nat.zero_mul, ofFn_zero, flatten]
Β· simp_rw [ofFn_succ', succ_mul]
simp [flatten_concat, ofFn_add, IH]
rfl
/-- This breaks a list of `m*n` items into `n` groups each containing `m` elements. -/
theorem ofFn_mul' {m n} (f : Fin (m * n) β Ξ±) :
List.ofFn f = List.flatten (List.ofFn fun i : Fin n => List.ofFn fun j : Fin m => f β¨m * i + j,
calc
m * i + j < m * (i + 1) :=
(Nat.add_lt_add_left j.prop _).trans_eq (by rw [Nat.mul_add, Nat.mul_one])
_ β€ _ := Nat.mul_le_mul_left _ i.propβ©) := by simp_rw [m.mul_comm, ofFn_mul, Fin.cast_mk]
@[simp]
theorem ofFn_get : β l : List Ξ±, (ofFn (get l)) = l
| [] => by rw [ofFn_zero]
| a :: l => by
rw [ofFn_succ]
congr
exact ofFn_get l
@[simp]
theorem ofFn_getElem : β l : List Ξ±, (ofFn (fun i : Fin l.length => l[(i : Nat)])) = l
| [] => by rw [ofFn_zero]
| a :: l => by
rw [ofFn_succ]
congr
exact ofFn_get l
@[simp]
theorem ofFn_getElem_eq_map {Ξ² : Type*} (l : List Ξ±) (f : Ξ± β Ξ²) :
ofFn (fun i : Fin l.length => f <| l[(i : Nat)]) = l.map f := by
rw [β Function.comp_def, β map_ofFn, ofFn_getElem]
-- Note there is a now another `mem_ofFn` defined in Lean, with an existential on the RHS,
-- which is marked as a simp lemma.
| Mathlib/Data/List/OfFn.lean | 116 | 119 | theorem mem_ofFn' {n} (f : Fin n β Ξ±) (a : Ξ±) : a β ofFn f β a β Set.range f := by | simp only [mem_iff_get, Set.mem_range, get_ofFn]
exact β¨fun β¨i, hiβ© => β¨Fin.cast (by simp) i, hiβ©, fun β¨i, hiβ© => β¨Fin.cast (by simp) i, hiβ©β© |
/-
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, Mitchell Lee
-/
import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Algebra.Group.Submonoid.Basic
import Mathlib.Algebra.Group.ULift
import Mathlib.Order.Filter.Pointwise
import Mathlib.Topology.Algebra.MulAction
import Mathlib.Topology.ContinuousMap.Defs
import Mathlib.Topology.Algebra.Monoid.Defs
/-!
# Theory of topological monoids
In this file we define mixin classes `ContinuousMul` and `ContinuousAdd`. While in many
applications the underlying type is a monoid (multiplicative or additive), we do not require this in
the definitions.
-/
universe u v
open Set Filter TopologicalSpace Topology
open scoped Topology Pointwise
variable {ΞΉ Ξ± M N X : Type*} [TopologicalSpace X]
@[to_additive (attr := continuity, fun_prop)]
theorem continuous_one [TopologicalSpace M] [One M] : Continuous (1 : X β M) :=
@continuous_const _ _ _ _ 1
section ContinuousMul
variable [TopologicalSpace M] [Mul M] [ContinuousMul M]
@[to_additive]
instance : ContinuousMul Mα΅α΅ :=
βΉContinuousMul MβΊ
@[to_additive]
instance : ContinuousMul (ULift.{u} M) := by
constructor
apply continuous_uliftUp.comp
exact continuous_mul.compβ (continuous_uliftDown.comp continuous_fst)
(continuous_uliftDown.comp continuous_snd)
@[to_additive]
instance ContinuousMul.to_continuousSMul : ContinuousSMul M M :=
β¨continuous_mulβ©
@[to_additive]
instance ContinuousMul.to_continuousSMul_op : ContinuousSMul Mα΅α΅α΅ M :=
β¨show Continuous ((fun p : M Γ M => p.1 * p.2) β Prod.swap β Prod.map MulOpposite.unop id) from
continuous_mul.comp <|
continuous_swap.comp <| Continuous.prodMap MulOpposite.continuous_unop continuous_idβ©
@[to_additive]
theorem ContinuousMul.induced {Ξ± : Type*} {Ξ² : Type*} {F : Type*} [FunLike F Ξ± Ξ²] [Mul Ξ±]
[Mul Ξ²] [MulHomClass F Ξ± Ξ²] [tΞ² : TopologicalSpace Ξ²] [ContinuousMul Ξ²] (f : F) :
@ContinuousMul Ξ± (tΞ².induced f) _ := by
let tΞ± := tΞ².induced f
refine β¨continuous_induced_rng.2 ?_β©
simp only [Function.comp_def, map_mul]
fun_prop
@[to_additive (attr := continuity)]
theorem continuous_mul_left (a : M) : Continuous fun b : M => a * b :=
continuous_const.mul continuous_id
@[to_additive (attr := continuity)]
theorem continuous_mul_right (a : M) : Continuous fun b : M => b * a :=
continuous_id.mul continuous_const
@[to_additive]
theorem tendsto_mul {a b : M} : Tendsto (fun p : M Γ M => p.fst * p.snd) (π (a, b)) (π (a * b)) :=
continuous_iff_continuousAt.mp ContinuousMul.continuous_mul (a, b)
@[to_additive]
theorem Filter.Tendsto.const_mul (b : M) {c : M} {f : Ξ± β M} {l : Filter Ξ±}
(h : Tendsto (fun k : Ξ± => f k) l (π c)) : Tendsto (fun k : Ξ± => b * f k) l (π (b * c)) :=
tendsto_const_nhds.mul h
@[to_additive]
theorem Filter.Tendsto.mul_const (b : M) {c : M} {f : Ξ± β M} {l : Filter Ξ±}
(h : Tendsto (fun k : Ξ± => f k) l (π c)) : Tendsto (fun k : Ξ± => f k * b) l (π (c * b)) :=
h.mul tendsto_const_nhds
@[to_additive]
theorem le_nhds_mul (a b : M) : π a * π b β€ π (a * b) := by
rw [β mapβ_mul, β map_uncurry_prod, β nhds_prod_eq]
exact continuous_mul.tendsto _
@[to_additive (attr := simp)]
theorem nhds_one_mul_nhds {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
π (1 : M) * π a = π a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (one_mul a)).antisymm <|
le_mul_of_one_le_left' <| pure_le_nhds 1
@[to_additive (attr := simp)]
theorem nhds_mul_nhds_one {M} [MulOneClass M] [TopologicalSpace M] [ContinuousMul M] (a : M) :
π a * π 1 = π a :=
((le_nhds_mul _ _).trans_eq <| congr_arg _ (mul_one a)).antisymm <|
le_mul_of_one_le_right' <| pure_le_nhds 1
section tendsto_nhds
variable {π : Type*} [Preorder π] [Zero π] [Mul π] [TopologicalSpace π] [ContinuousMul π]
{l : Filter Ξ±} {f : Ξ± β π} {b c : π} (hb : 0 < b)
include hb
theorem Filter.TendstoNhdsWithinIoi.const_mul [PosMulStrictMono π] [PosMulReflectLT π]
(h : Tendsto f l (π[>] c)) : Tendsto (fun a => b * f a) l (π[>] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
theorem Filter.TendstoNhdsWithinIio.const_mul [PosMulStrictMono π] [PosMulReflectLT π]
(h : Tendsto f l (π[<] c)) : Tendsto (fun a => b * f a) l (π[<] (b * c)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).const_mul b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_left hb).mpr
theorem Filter.TendstoNhdsWithinIoi.mul_const [MulPosStrictMono π] [MulPosReflectLT π]
(h : Tendsto f l (π[>] c)) : Tendsto (fun a => f a * b) l (π[>] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
theorem Filter.TendstoNhdsWithinIio.mul_const [MulPosStrictMono π] [MulPosReflectLT π]
(h : Tendsto f l (π[<] c)) : Tendsto (fun a => f a * b) l (π[<] (c * b)) :=
tendsto_nhdsWithin_of_tendsto_nhds_of_eventually_within _
((tendsto_nhds_of_tendsto_nhdsWithin h).mul_const b) <|
(tendsto_nhdsWithin_iff.mp h).2.mono fun _ => (mul_lt_mul_right hb).mpr
end tendsto_nhds
@[to_additive]
protected theorem Specializes.mul {a b c d : M} (hab : a β€³ b) (hcd : c β€³ d) : (a * c) β€³ (b * d) :=
hab.smul hcd
@[to_additive]
protected theorem Inseparable.mul {a b c d : M} (hab : Inseparable a b) (hcd : Inseparable c d) :
Inseparable (a * c) (b * d) :=
hab.smul hcd
@[to_additive]
protected theorem Specializes.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M]
{a b : M} (h : a β€³ b) (n : β) : (a ^ n) β€³ (b ^ n) :=
Nat.recOn n (by simp only [pow_zero, specializes_rfl]) fun _ ihn β¦ by
simpa only [pow_succ] using ihn.mul h
@[to_additive]
protected theorem Inseparable.pow {M : Type*} [Monoid M] [TopologicalSpace M] [ContinuousMul M]
{a b : M} (h : Inseparable a b) (n : β) : Inseparable (a ^ n) (b ^ n) :=
(h.specializes.pow n).antisymm (h.specializes'.pow n)
/-- Construct a unit from limits of units and their inverses. -/
@[to_additive (attr := simps)
"Construct an additive unit from limits of additive units and their negatives."]
def Filter.Tendsto.units [TopologicalSpace N] [Monoid N] [ContinuousMul N] [T2Space N]
{f : ΞΉ β NΛ£} {rβ rβ : N} {l : Filter ΞΉ} [l.NeBot] (hβ : Tendsto (fun x => β(f x)) l (π rβ))
(hβ : Tendsto (fun x => β(f x)β»ΒΉ) l (π rβ)) : NΛ£ where
val := rβ
inv := rβ
val_inv := by
symm
simpa using hβ.mul hβ
inv_val := by
symm
simpa using hβ.mul hβ
@[to_additive]
instance Prod.continuousMul [TopologicalSpace N] [Mul N] [ContinuousMul N] :
ContinuousMul (M Γ N) :=
β¨by apply Continuous.prodMk <;> fun_propβ©
@[to_additive]
instance Pi.continuousMul {C : ΞΉ β Type*} [β i, TopologicalSpace (C i)] [β i, Mul (C i)]
[β i, ContinuousMul (C i)] : ContinuousMul (β i, C i) where
continuous_mul :=
continuous_pi fun i => (continuous_apply i).fst'.mul (continuous_apply i).snd'
/-- A version of `Pi.continuousMul` for non-dependent functions. It is needed because sometimes
Lean 3 fails to use `Pi.continuousMul` for non-dependent functions. -/
@[to_additive "A version of `Pi.continuousAdd` for non-dependent functions. It is needed
because sometimes Lean fails to use `Pi.continuousAdd` for non-dependent functions."]
instance Pi.continuousMul' : ContinuousMul (ΞΉ β M) :=
Pi.continuousMul
@[to_additive]
instance (priority := 100) continuousMul_of_discreteTopology [TopologicalSpace N] [Mul N]
[DiscreteTopology N] : ContinuousMul N :=
β¨continuous_of_discreteTopologyβ©
open Filter
open Function
@[to_additive]
theorem ContinuousMul.of_nhds_one {M : Type u} [Monoid M] [TopologicalSpace M]
(hmul : Tendsto (uncurry ((Β· * Β·) : M β M β M)) (π 1 ΓΛ’ π 1) <| π 1)
(hleft : β xβ : M, π xβ = map (fun x => xβ * x) (π 1))
(hright : β xβ : M, π xβ = map (fun x => x * xβ) (π 1)) : ContinuousMul M :=
β¨by
rw [continuous_iff_continuousAt]
rintro β¨xβ, yββ©
have key : (fun p : M Γ M => xβ * p.1 * (p.2 * yβ)) =
((fun x => xβ * x) β fun x => x * yβ) β uncurry (Β· * Β·) := by
ext p
simp [uncurry, mul_assoc]
have keyβ : ((fun x => xβ * x) β fun x => yβ * x) = fun x => xβ * yβ * x := by
ext x
simp [mul_assoc]
calc
map (uncurry (Β· * Β·)) (π (xβ, yβ)) = map (uncurry (Β· * Β·)) (π xβ ΓΛ’ π yβ) := by
rw [nhds_prod_eq]
_ = map (fun p : M Γ M => xβ * p.1 * (p.2 * yβ)) (π 1 ΓΛ’ π 1) := by
-- Porting note: `rw` was able to prove this
-- Now it fails with `failed to rewrite using equation theorems for 'Function.uncurry'`
-- and `failed to rewrite using equation theorems for 'Function.comp'`.
-- Removing those two lemmas, the `rw` would succeed, but then needs a `rfl`.
simp +unfoldPartialApp only [uncurry]
simp_rw [hleft xβ, hright yβ, prod_map_map_eq, Filter.map_map, Function.comp_def]
_ = map ((fun x => xβ * x) β fun x => x * yβ) (map (uncurry (Β· * Β·)) (π 1 ΓΛ’ π 1)) := by
rw [key, β Filter.map_map]
_ β€ map ((fun x : M => xβ * x) β fun x => x * yβ) (π 1) := map_mono hmul
_ = π (xβ * yβ) := by
rw [β Filter.map_map, β hright, hleft yβ, Filter.map_map, keyβ, β hleft]β©
@[to_additive]
theorem continuousMul_of_comm_of_nhds_one (M : Type u) [CommMonoid M] [TopologicalSpace M]
(hmul : Tendsto (uncurry ((Β· * Β·) : M β M β M)) (π 1 ΓΛ’ π 1) (π 1))
(hleft : β xβ : M, π xβ = map (fun x => xβ * x) (π 1)) : ContinuousMul M := by
apply ContinuousMul.of_nhds_one hmul hleft
intro xβ
simp_rw [mul_comm, hleft xβ]
end ContinuousMul
section PointwiseLimits
variable (Mβ Mβ : Type*) [TopologicalSpace Mβ] [T2Space Mβ]
@[to_additive]
theorem isClosed_setOf_map_one [One Mβ] [One Mβ] : IsClosed { f : Mβ β Mβ | f 1 = 1 } :=
isClosed_eq (continuous_apply 1) continuous_const
@[to_additive]
theorem isClosed_setOf_map_mul [Mul Mβ] [Mul Mβ] [ContinuousMul Mβ] :
IsClosed { f : Mβ β Mβ | β x y, f (x * y) = f x * f y } := by
simp only [setOf_forall]
exact isClosed_iInter fun x β¦ isClosed_iInter fun y β¦
isClosed_eq (continuous_apply _) (by fun_prop)
section Semigroup
variable {Mβ Mβ} [Mul Mβ] [Mul Mβ] [ContinuousMul Mβ]
{F : Type*} [FunLike F Mβ Mβ] [MulHomClass F Mβ Mβ] {l : Filter Ξ±}
/-- Construct a bundled semigroup homomorphism `Mβ ββ* Mβ` from a function `f` and a proof that it
belongs to the closure of the range of the coercion from `Mβ ββ* Mβ` (or another type of bundled
homomorphisms that has a `MulHomClass` instance) to `Mβ β Mβ`. -/
@[to_additive (attr := simps -fullyApplied)
"Construct a bundled additive semigroup homomorphism `Mβ ββ+ Mβ` from a function `f`
and a proof that it belongs to the closure of the range of the coercion from `Mβ ββ+ Mβ` (or another
type of bundled homomorphisms that has an `AddHomClass` instance) to `Mβ β Mβ`."]
def mulHomOfMemClosureRangeCoe (f : Mβ β Mβ)
(hf : f β closure (range fun (f : F) (x : Mβ) => f x)) : Mβ ββ* Mβ where
toFun := f
map_mul' := (isClosed_setOf_map_mul Mβ Mβ).closure_subset_iff.2 (range_subset_iff.2 map_mul) hf
/-- Construct a bundled semigroup homomorphism from a pointwise limit of semigroup homomorphisms. -/
@[to_additive (attr := simps! -fullyApplied)
"Construct a bundled additive semigroup homomorphism from a pointwise limit of additive
semigroup homomorphisms"]
def mulHomOfTendsto (f : Mβ β Mβ) (g : Ξ± β F) [l.NeBot]
(h : Tendsto (fun a x => g a x) l (π f)) : Mβ ββ* Mβ :=
mulHomOfMemClosureRangeCoe f <|
mem_closure_of_tendsto h <| Eventually.of_forall fun _ => mem_range_self _
variable (Mβ Mβ)
@[to_additive]
theorem MulHom.isClosed_range_coe : IsClosed (Set.range ((β) : (Mβ ββ* Mβ) β Mβ β Mβ)) :=
isClosed_of_closure_subset fun f hf => β¨mulHomOfMemClosureRangeCoe f hf, rflβ©
end Semigroup
section Monoid
variable {Mβ Mβ} [MulOneClass Mβ] [MulOneClass Mβ] [ContinuousMul Mβ]
{F : Type*} [FunLike F Mβ Mβ] [MonoidHomClass F Mβ Mβ] {l : Filter Ξ±}
/-- Construct a bundled monoid homomorphism `Mβ β* Mβ` from a function `f` and a proof that it
belongs to the closure of the range of the coercion from `Mβ β* Mβ` (or another type of bundled
homomorphisms that has a `MonoidHomClass` instance) to `Mβ β Mβ`. -/
@[to_additive (attr := simps -fullyApplied)
"Construct a bundled additive monoid homomorphism `Mβ β+ Mβ` from a function `f`
and a proof that it belongs to the closure of the range of the coercion from `Mβ β+ Mβ` (or another
type of bundled homomorphisms that has an `AddMonoidHomClass` instance) to `Mβ β Mβ`."]
def monoidHomOfMemClosureRangeCoe (f : Mβ β Mβ)
(hf : f β closure (range fun (f : F) (x : Mβ) => f x)) : Mβ β* Mβ where
toFun := f
map_one' := (isClosed_setOf_map_one Mβ Mβ).closure_subset_iff.2 (range_subset_iff.2 map_one) hf
map_mul' := (isClosed_setOf_map_mul Mβ Mβ).closure_subset_iff.2 (range_subset_iff.2 map_mul) hf
/-- Construct a bundled monoid homomorphism from a pointwise limit of monoid homomorphisms. -/
@[to_additive (attr := simps! -fullyApplied)
"Construct a bundled additive monoid homomorphism from a pointwise limit of additive
monoid homomorphisms"]
def monoidHomOfTendsto (f : Mβ β Mβ) (g : Ξ± β F) [l.NeBot]
(h : Tendsto (fun a x => g a x) l (π f)) : Mβ β* Mβ :=
monoidHomOfMemClosureRangeCoe f <|
mem_closure_of_tendsto h <| Eventually.of_forall fun _ => mem_range_self _
variable (Mβ Mβ)
@[to_additive]
theorem MonoidHom.isClosed_range_coe : IsClosed (Set.range ((β) : (Mβ β* Mβ) β Mβ β Mβ)) :=
isClosed_of_closure_subset fun f hf => β¨monoidHomOfMemClosureRangeCoe f hf, rflβ©
end Monoid
end PointwiseLimits
@[to_additive]
theorem Topology.IsInducing.continuousMul {M N F : Type*} [Mul M] [Mul N] [FunLike F M N]
[MulHomClass F M N] [TopologicalSpace M] [TopologicalSpace N] [ContinuousMul N] (f : F)
(hf : IsInducing f) : ContinuousMul M :=
β¨(hf.continuousSMul hf.continuous (map_mul f _ _)).1β©
@[deprecated (since := "2024-10-28")] alias Inducing.continuousMul := IsInducing.continuousMul
@[to_additive]
theorem continuousMul_induced {M N F : Type*} [Mul M] [Mul N] [FunLike F M N] [MulHomClass F M N]
[TopologicalSpace N] [ContinuousMul N] (f : F) : @ContinuousMul M (induced f βΉ_βΊ) _ :=
letI := induced f βΉ_βΊ
IsInducing.continuousMul f β¨rflβ©
@[to_additive]
instance Subsemigroup.continuousMul [TopologicalSpace M] [Semigroup M] [ContinuousMul M]
(S : Subsemigroup M) : ContinuousMul S :=
IsInducing.continuousMul ({ toFun := (β), map_mul' := fun _ _ => rfl} : MulHom S M) β¨rflβ©
@[to_additive]
instance Submonoid.continuousMul [TopologicalSpace M] [Monoid M] [ContinuousMul M]
(S : Submonoid M) : ContinuousMul S :=
S.toSubsemigroup.continuousMul
section MulZeroClass
open Filter
variable {Ξ± Ξ² : Type*}
variable [TopologicalSpace M] [MulZeroClass M] [ContinuousMul M]
theorem exists_mem_nhds_zero_mul_subset
{K U : Set M} (hK : IsCompact K) (hU : U β π 0) : β V β π 0, K * V β U := by
refine hK.induction_on ?_ ?_ ?_ ?_
Β· exact β¨univ, by simpβ©
Β· rintro s t hst β¨V, hV, hV'β©
exact β¨V, hV, (mul_subset_mul_right hst).trans hV'β©
Β· rintro s t β¨V, V_in, hV'β© β¨W, W_in, hW'β©
use V β© W, inter_mem V_in W_in
rw [union_mul]
exact
union_subset ((mul_subset_mul_left V.inter_subset_left).trans hV')
((mul_subset_mul_left V.inter_subset_right).trans hW')
Β· intro x hx
have := tendsto_mul (show U β π (x * 0) by simpa using hU)
rw [nhds_prod_eq, mem_map, mem_prod_iff] at this
rcases this with β¨t, ht, s, hs, hβ©
rw [β image_subset_iff, image_mul_prod] at h
exact β¨t, mem_nhdsWithin_of_mem_nhds ht, s, hs, hβ©
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `l` be a filter on `M` which is disjoint from the cocompact filter. Then, the multiplication map
`M Γ M β M` tends to zero on the filter product `π 0 ΓΛ’ l`. -/
theorem tendsto_mul_nhds_zero_prod_of_disjoint_cocompact {l : Filter M}
(hl : Disjoint l (cocompact M)) :
Tendsto (fun x : M Γ M β¦ x.1 * x.2) (π 0 ΓΛ’ l) (π 0) := calc
map (fun x : M Γ M β¦ x.1 * x.2) (π 0 ΓΛ’ l)
_ β€ map (fun x : M Γ M β¦ x.1 * x.2) (πΛ’ ({0} ΓΛ’ Set.univ)) :=
map_mono <| nhds_prod_le_of_disjoint_cocompact 0 hl
_ β€ π 0 := continuous_mul.tendsto_nhdsSet_nhds fun _ β¨hx, _β© β¦ mul_eq_zero_of_left hx _
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `l` be a filter on `M` which is disjoint from the cocompact filter. Then, the multiplication map
`M Γ M β M` tends to zero on the filter product `l ΓΛ’ π 0`. -/
theorem tendsto_mul_prod_nhds_zero_of_disjoint_cocompact {l : Filter M}
(hl : Disjoint l (cocompact M)) :
Tendsto (fun x : M Γ M β¦ x.1 * x.2) (l ΓΛ’ π 0) (π 0) := calc
map (fun x : M Γ M β¦ x.1 * x.2) (l ΓΛ’ π 0)
_ β€ map (fun x : M Γ M β¦ x.1 * x.2) (πΛ’ (Set.univ ΓΛ’ {0})) :=
map_mono <| prod_nhds_le_of_disjoint_cocompact 0 hl
_ β€ π 0 := continuous_mul.tendsto_nhdsSet_nhds fun _ β¨_, hxβ© β¦ mul_eq_zero_of_right _ hx
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `l` be a filter on `M Γ M` which is disjoint from the cocompact filter. Then, the multiplication
map `M Γ M β M` tends to zero on `(π 0).coprod (π 0) β l`. -/
theorem tendsto_mul_coprod_nhds_zero_inf_of_disjoint_cocompact {l : Filter (M Γ M)}
(hl : Disjoint l (cocompact (M Γ M))) :
Tendsto (fun x : M Γ M β¦ x.1 * x.2) ((π 0).coprod (π 0) β l) (π 0) := by
have := calc
(π 0).coprod (π 0) β l
_ β€ (π 0).coprod (π 0) β map Prod.fst l ΓΛ’ map Prod.snd l :=
inf_le_inf_left _ le_prod_map_fst_snd
_ β€ π 0 ΓΛ’ map Prod.snd l β map Prod.fst l ΓΛ’ π 0 :=
coprod_inf_prod_le _ _ _ _
apply (Tendsto.sup _ _).mono_left this
Β· apply tendsto_mul_nhds_zero_prod_of_disjoint_cocompact
exact disjoint_map_cocompact continuous_snd hl
Β· apply tendsto_mul_prod_nhds_zero_of_disjoint_cocompact
exact disjoint_map_cocompact continuous_fst hl
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `l` be a filter on `M Γ M` which is both disjoint from the cocompact filter and less than or
equal to `(π 0).coprod (π 0)`. Then the multiplication map `M Γ M β M` tends to zero on `l`. -/
theorem tendsto_mul_nhds_zero_of_disjoint_cocompact {l : Filter (M Γ M)}
(hl : Disjoint l (cocompact (M Γ M))) (h'l : l β€ (π 0).coprod (π 0)) :
Tendsto (fun x : M Γ M β¦ x.1 * x.2) l (π 0) := by
simpa [inf_eq_right.mpr h'l] using tendsto_mul_coprod_nhds_zero_inf_of_disjoint_cocompact hl
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `f : Ξ± β M` and `g : Ξ± β M` be functions. If `f` tends to zero on a filter `l`
and the image of `l` under `g` is disjoint from the cocompact filter on `M`, then
`fun x : Ξ± β¦ f x * g x` also tends to zero on `l`. -/
theorem Tendsto.tendsto_mul_zero_of_disjoint_cocompact_right {f g : Ξ± β M} {l : Filter Ξ±}
(hf : Tendsto f l (π 0)) (hg : Disjoint (map g l) (cocompact M)) :
Tendsto (fun x β¦ f x * g x) l (π 0) :=
tendsto_mul_nhds_zero_prod_of_disjoint_cocompact hg |>.comp (hf.prodMk tendsto_map)
/-- Let `M` be a topological space with a continuous multiplication operation and a `0`.
Let `f : Ξ± β M` and `g : Ξ± β M` be functions. If `g` tends to zero on a filter `l`
and the image of `l` under `f` is disjoint from the cocompact filter on `M`, then
`fun x : Ξ± β¦ f x * g x` also tends to zero on `l`. -/
theorem Tendsto.tendsto_mul_zero_of_disjoint_cocompact_left {f g : Ξ± β M} {l : Filter Ξ±}
(hf : Disjoint (map f l) (cocompact M)) (hg : Tendsto g l (π 0)):
Tendsto (fun x β¦ f x * g x) l (π 0) :=
tendsto_mul_prod_nhds_zero_of_disjoint_cocompact hf |>.comp (tendsto_map.prodMk hg)
/-- If `f : Ξ± β M` and `g : Ξ² β M` are continuous and both tend to zero on the cocompact filter,
then `fun i : Ξ± Γ Ξ² β¦ f i.1 * g i.2` also tends to zero on the cocompact filter. -/
theorem tendsto_mul_cocompact_nhds_zero [TopologicalSpace Ξ±] [TopologicalSpace Ξ²]
{f : Ξ± β M} {g : Ξ² β M} (f_cont : Continuous f) (g_cont : Continuous g)
(hf : Tendsto f (cocompact Ξ±) (π 0)) (hg : Tendsto g (cocompact Ξ²) (π 0)) :
Tendsto (fun i : Ξ± Γ Ξ² β¦ f i.1 * g i.2) (cocompact (Ξ± Γ Ξ²)) (π 0) := by
set l : Filter (M Γ M) := map (Prod.map f g) (cocompact (Ξ± Γ Ξ²)) with l_def
set K : Set (M Γ M) := (insert 0 (range f)) ΓΛ’ (insert 0 (range g))
have K_compact : IsCompact K := .prod (hf.isCompact_insert_range_of_cocompact f_cont)
(hg.isCompact_insert_range_of_cocompact g_cont)
have K_mem_l : K β l := eventually_map.mpr <| .of_forall fun β¨x, yβ© β¦
β¨mem_insert_of_mem _ (mem_range_self _), mem_insert_of_mem _ (mem_range_self _)β©
have l_compact : Disjoint l (cocompact (M Γ M)) := by
rw [disjoint_cocompact_right]
exact β¨K, K_mem_l, K_compactβ©
have l_le_coprod : l β€ (π 0).coprod (π 0) := by
rw [l_def, β coprod_cocompact]
exact hf.prodMap_coprod hg
exact tendsto_mul_nhds_zero_of_disjoint_cocompact l_compact l_le_coprod |>.comp tendsto_map
/-- If `f : Ξ± β M` and `g : Ξ² β M` both tend to zero on the cofinite filter, then so does
`fun i : Ξ± Γ Ξ² β¦ f i.1 * g i.2`. -/
theorem tendsto_mul_cofinite_nhds_zero {f : Ξ± β M} {g : Ξ² β M}
(hf : Tendsto f cofinite (π 0)) (hg : Tendsto g cofinite (π 0)) :
Tendsto (fun i : Ξ± Γ Ξ² β¦ f i.1 * g i.2) cofinite (π 0) := by
letI : TopologicalSpace Ξ± := β₯
haveI : DiscreteTopology Ξ± := discreteTopology_bot Ξ±
letI : TopologicalSpace Ξ² := β₯
haveI : DiscreteTopology Ξ² := discreteTopology_bot Ξ²
rw [β cocompact_eq_cofinite] at *
exact tendsto_mul_cocompact_nhds_zero
continuous_of_discreteTopology continuous_of_discreteTopology hf hg
end MulZeroClass
section GroupWithZero
lemma GroupWithZero.isOpen_singleton_zero [GroupWithZero M] [TopologicalSpace M]
[ContinuousMul M] [CompactSpace M] [T1Space M] :
IsOpen {(0 : M)} := by
obtain β¨U, hU, h0U, h1Uβ© := t1Space_iff_exists_open.mp βΉ_βΊ zero_ne_one
obtain β¨W, hW, hW'β© := exists_mem_nhds_zero_mul_subset isCompact_univ (hU.mem_nhds h0U)
by_cases H : β x β 0, x β W
Β· obtain β¨x, hx, hxWβ© := H
cases h1U (hW' (by simpa [hx] using Set.mul_mem_mul (Set.mem_univ xβ»ΒΉ) hxW))
Β· obtain rfl : W = {0} := subset_antisymm
(by simpa [not_imp_not] using H) (by simpa using mem_of_mem_nhds hW)
simpa [isOpen_iff_mem_nhds]
end GroupWithZero
section MulOneClass
variable [TopologicalSpace M] [MulOneClass M] [ContinuousMul M]
@[to_additive exists_open_nhds_zero_half]
theorem exists_open_nhds_one_split {s : Set M} (hs : s β π (1 : M)) :
β V : Set M, IsOpen V β§ (1 : M) β V β§ β v β V, β w β V, v * w β s := by
have : (fun a : M Γ M => a.1 * a.2) β»ΒΉ' s β π ((1, 1) : M Γ M) :=
tendsto_mul (by simpa only [one_mul] using hs)
simpa only [prod_subset_iff] using exists_nhds_square this
@[to_additive exists_nhds_zero_half]
theorem exists_nhds_one_split {s : Set M} (hs : s β π (1 : M)) :
β V β π (1 : M), β v β V, β w β V, v * w β s :=
let β¨V, Vo, V1, hVβ© := exists_open_nhds_one_split hs
β¨V, IsOpen.mem_nhds Vo V1, hVβ©
/-- Given a neighborhood `U` of `1` there is an open neighborhood `V` of `1`
such that `V * V β U`. -/
@[to_additive "Given an open neighborhood `U` of `0` there is an open neighborhood `V` of `0`
such that `V + V β U`."]
theorem exists_open_nhds_one_mul_subset {U : Set M} (hU : U β π (1 : M)) :
β V : Set M, IsOpen V β§ (1 : M) β V β§ V * V β U := by
simpa only [mul_subset_iff] using exists_open_nhds_one_split hU
@[to_additive]
theorem Filter.HasBasis.mul_self {p : ΞΉ β Prop} {s : ΞΉ β Set M} (h : (π 1).HasBasis p s) :
(π 1).HasBasis p fun i => s i * s i := by
rw [β nhds_mul_nhds_one, β mapβ_mul, β map_uncurry_prod]
simpa only [β image_mul_prod] using h.prod_self.map _
end MulOneClass
section ContinuousMul
section Semigroup
variable [TopologicalSpace M] [Semigroup M] [ContinuousMul M]
@[to_additive]
theorem Subsemigroup.top_closure_mul_self_subset (s : Subsemigroup M) :
_root_.closure (s : Set M) * _root_.closure s β _root_.closure s :=
image2_subset_iff.2 fun _ hx _ hy =>
map_mem_closureβ continuous_mul hx hy fun _ ha _ hb => s.mul_mem ha hb
/-- The (topological-space) closure of a subsemigroup of a space `M` with `ContinuousMul` is
itself a subsemigroup. -/
@[to_additive "The (topological-space) closure of an additive submonoid of a space `M` with
`ContinuousAdd` is itself an additive submonoid."]
def Subsemigroup.topologicalClosure (s : Subsemigroup M) : Subsemigroup M where
carrier := _root_.closure (s : Set M)
mul_mem' ha hb := s.top_closure_mul_self_subset β¨_, ha, _, hb, rflβ©
@[to_additive]
theorem Subsemigroup.coe_topologicalClosure (s : Subsemigroup M) :
(s.topologicalClosure : Set M) = _root_.closure (s : Set M) := rfl
@[to_additive]
theorem Subsemigroup.le_topologicalClosure (s : Subsemigroup M) : s β€ s.topologicalClosure :=
_root_.subset_closure
@[to_additive]
theorem Subsemigroup.isClosed_topologicalClosure (s : Subsemigroup M) :
IsClosed (s.topologicalClosure : Set M) := isClosed_closure
@[to_additive]
theorem Subsemigroup.topologicalClosure_minimal (s : Subsemigroup M) {t : Subsemigroup M}
(h : s β€ t) (ht : IsClosed (t : Set M)) : s.topologicalClosure β€ t := closure_minimal h ht
/-- If a subsemigroup of a topological semigroup is commutative, then so is its topological
closure.
See note [reducible non-instances] -/
@[to_additive "If a submonoid of an additive topological monoid is commutative, then so is its
topological closure.
See note [reducible non-instances]"]
abbrev Subsemigroup.commSemigroupTopologicalClosure [T2Space M] (s : Subsemigroup M)
(hs : β x y : s, x * y = y * x) : CommSemigroup s.topologicalClosure :=
{ MulMemClass.toSemigroup s.topologicalClosure with
mul_comm :=
have : β x β s, β y β s, x * y = y * x := fun x hx y hy =>
congr_arg Subtype.val (hs β¨x, hxβ© β¨y, hyβ©)
fun β¨x, hxβ© β¨y, hyβ© =>
Subtype.ext <|
eqOn_closureβ this continuous_mul (continuous_snd.mul continuous_fst) x hx y hy }
@[to_additive]
theorem IsCompact.mul {s t : Set M} (hs : IsCompact s) (ht : IsCompact t) : IsCompact (s * t) := by
rw [β image_mul_prod]
exact (hs.prod ht).image continuous_mul
end Semigroup
variable [TopologicalSpace M] [Monoid M] [ContinuousMul M]
@[to_additive]
theorem Submonoid.top_closure_mul_self_subset (s : Submonoid M) :
_root_.closure (s : Set M) * _root_.closure s β _root_.closure s :=
image2_subset_iff.2 fun _ hx _ hy =>
map_mem_closureβ continuous_mul hx hy fun _ ha _ hb => s.mul_mem ha hb
@[to_additive]
theorem Submonoid.top_closure_mul_self_eq (s : Submonoid M) :
_root_.closure (s : Set M) * _root_.closure s = _root_.closure s :=
Subset.antisymm s.top_closure_mul_self_subset fun x hx =>
β¨x, hx, 1, _root_.subset_closure s.one_mem, mul_one _β©
/-- The (topological-space) closure of a submonoid of a space `M` with `ContinuousMul` is
itself a submonoid. -/
@[to_additive "The (topological-space) closure of an additive submonoid of a space `M` with
`ContinuousAdd` is itself an additive submonoid."]
def Submonoid.topologicalClosure (s : Submonoid M) : Submonoid M where
carrier := _root_.closure (s : Set M)
one_mem' := _root_.subset_closure s.one_mem
mul_mem' ha hb := s.top_closure_mul_self_subset β¨_, ha, _, hb, rflβ©
@[to_additive]
theorem Submonoid.coe_topologicalClosure (s : Submonoid M) :
(s.topologicalClosure : Set M) = _root_.closure (s : Set M) := rfl
@[to_additive]
theorem Submonoid.le_topologicalClosure (s : Submonoid M) : s β€ s.topologicalClosure :=
_root_.subset_closure
@[to_additive]
theorem Submonoid.isClosed_topologicalClosure (s : Submonoid M) :
IsClosed (s.topologicalClosure : Set M) := isClosed_closure
@[to_additive]
theorem Submonoid.topologicalClosure_minimal (s : Submonoid M) {t : Submonoid M} (h : s β€ t)
(ht : IsClosed (t : Set M)) : s.topologicalClosure β€ t := closure_minimal h ht
/-- If a submonoid of a topological monoid is commutative, then so is its topological closure. -/
@[to_additive "If a submonoid of an additive topological monoid is commutative, then so is its
topological closure.
See note [reducible non-instances]."]
abbrev Submonoid.commMonoidTopologicalClosure [T2Space M] (s : Submonoid M)
(hs : β x y : s, x * y = y * x) : CommMonoid s.topologicalClosure :=
{ s.topologicalClosure.toMonoid, s.toSubsemigroup.commSemigroupTopologicalClosure hs with }
@[to_additive exists_nhds_zero_quarter]
theorem exists_nhds_one_split4 {u : Set M} (hu : u β π (1 : M)) :
β V β π (1 : M), β {v w s t}, v β V β w β V β s β V β t β V β v * w * s * t β u := by
rcases exists_nhds_one_split hu with β¨W, W1, hβ©
rcases exists_nhds_one_split W1 with β¨V, V1, h'β©
use V, V1
intro v w s t v_in w_in s_in t_in
simpa only [mul_assoc] using h _ (h' v v_in w w_in) _ (h' s s_in t t_in)
@[to_additive]
theorem tendsto_list_prod {f : ΞΉ β Ξ± β M} {x : Filter Ξ±} {a : ΞΉ β M} :
β l : List ΞΉ,
(β i β l, Tendsto (f i) x (π (a i))) β
Tendsto (fun b => (l.map fun c => f c b).prod) x (π (l.map a).prod)
| [], _ => by simp [tendsto_const_nhds]
| f::l, h => by
simp only [List.map_cons, List.prod_cons]
exact
(h f List.mem_cons_self).mul
(tendsto_list_prod l fun c hc => h c (List.mem_cons_of_mem _ hc))
@[to_additive (attr := continuity)]
theorem continuous_list_prod {f : ΞΉ β X β M} (l : List ΞΉ) (h : β i β l, Continuous (f i)) :
Continuous fun a => (l.map fun i => f i a).prod :=
continuous_iff_continuousAt.2 fun x =>
tendsto_list_prod l fun c hc => continuous_iff_continuousAt.1 (h c hc) x
@[to_additive]
theorem continuousOn_list_prod {f : ΞΉ β X β M} (l : List ΞΉ) {t : Set X}
(h : β i β l, ContinuousOn (f i) t) :
ContinuousOn (fun a => (l.map fun i => f i a).prod) t := by
intro x hx
rw [continuousWithinAt_iff_continuousAt_restrict _ hx]
refine tendsto_list_prod _ fun i hi => ?_
specialize h i hi x hx
rw [continuousWithinAt_iff_continuousAt_restrict _ hx] at h
exact h
@[to_additive (attr := continuity)]
theorem continuous_pow : β n : β, Continuous fun a : M => a ^ n
| 0 => by simpa using continuous_const
| k + 1 => by
simp only [pow_succ']
exact continuous_id.mul (continuous_pow _)
instance AddMonoid.continuousConstSMul_nat {A} [AddMonoid A] [TopologicalSpace A]
[ContinuousAdd A] : ContinuousConstSMul β A :=
β¨continuous_nsmulβ©
instance AddMonoid.continuousSMul_nat {A} [AddMonoid A] [TopologicalSpace A]
[ContinuousAdd A] : ContinuousSMul β A :=
β¨continuous_prod_of_discrete_left.mpr continuous_nsmulβ©
-- We register `Continuous.pow` as a `continuity` lemma with low penalty (so
-- `continuity` will try it before other `continuity` lemmas). This is a
-- workaround for goals of the form `Continuous fun x => x ^ 2`, where
-- `continuity` applies `Continuous.mul` since the goal is defeq to
-- `Continuous fun x => x * x`.
--
-- To properly fix this, we should make sure that `continuity` applies its
-- lemmas with reducible transparency, preventing the unfolding of `^`. But this
-- is quite an invasive change.
@[to_additive (attr := aesop safe -100 (rule_sets := [Continuous]), fun_prop)]
theorem Continuous.pow {f : X β M} (h : Continuous f) (n : β) : Continuous fun b => f b ^ n :=
(continuous_pow n).comp h
@[to_additive]
theorem continuousOn_pow {s : Set M} (n : β) : ContinuousOn (fun (x : M) => x ^ n) s :=
(continuous_pow n).continuousOn
@[to_additive]
theorem continuousAt_pow (x : M) (n : β) : ContinuousAt (fun (x : M) => x ^ n) x :=
(continuous_pow n).continuousAt
@[to_additive]
theorem Filter.Tendsto.pow {l : Filter Ξ±} {f : Ξ± β M} {x : M} (hf : Tendsto f l (π x)) (n : β) :
Tendsto (fun x => f x ^ n) l (π (x ^ n)) :=
(continuousAt_pow _ _).tendsto.comp hf
@[to_additive]
theorem ContinuousWithinAt.pow {f : X β M} {x : X} {s : Set X} (hf : ContinuousWithinAt f s x)
(n : β) : ContinuousWithinAt (fun x => f x ^ n) s x :=
Filter.Tendsto.pow hf n
@[to_additive (attr := fun_prop)]
theorem ContinuousAt.pow {f : X β M} {x : X} (hf : ContinuousAt f x) (n : β) :
ContinuousAt (fun x => f x ^ n) x :=
Filter.Tendsto.pow hf n
@[to_additive (attr := fun_prop)]
theorem ContinuousOn.pow {f : X β M} {s : Set X} (hf : ContinuousOn f s) (n : β) :
ContinuousOn (fun x => f x ^ n) s := fun x hx => (hf x hx).pow n
/-- Left-multiplication by a left-invertible element of a topological monoid is proper, i.e.,
inverse images of compact sets are compact. -/
theorem Filter.tendsto_cocompact_mul_left {a b : M} (ha : b * a = 1) :
Filter.Tendsto (fun x : M => a * x) (Filter.cocompact M) (Filter.cocompact M) := by
refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_left b))
convert Filter.tendsto_id
ext x
simp [β mul_assoc, ha]
/-- Right-multiplication by a right-invertible element of a topological monoid is proper, i.e.,
inverse images of compact sets are compact. -/
theorem Filter.tendsto_cocompact_mul_right {a b : M} (ha : a * b = 1) :
Filter.Tendsto (fun x : M => x * a) (Filter.cocompact M) (Filter.cocompact M) := by
refine Filter.Tendsto.of_tendsto_comp ?_ (Filter.comap_cocompact_le (continuous_mul_right b))
simp only [comp_mul_right, ha, mul_one]
exact Filter.tendsto_id
/-- If `R` acts on `A` via `A`, then continuous multiplication implies continuous scalar
multiplication by constants.
Notably, this instances applies when `R = A`, or when `[Algebra R A]` is available. -/
@[to_additive "If `R` acts on `A` via `A`, then continuous addition implies
continuous affine addition by constants."]
instance (priority := 100) IsScalarTower.continuousConstSMul {R A : Type*} [Monoid A] [SMul R A]
[IsScalarTower R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where
continuous_const_smul q := by
simp +singlePass only [β smul_one_mul q (_ : A)]
exact continuous_const.mul continuous_id
/-- If the action of `R` on `A` commutes with left-multiplication, then continuous multiplication
implies continuous scalar multiplication by constants.
Notably, this instances applies when `R = Aα΅α΅α΅`. -/
@[to_additive "If the action of `R` on `A` commutes with left-addition, then
continuous addition implies continuous affine addition by constants.
Notably, this instances applies when `R = Aα΅α΅α΅`."]
instance (priority := 100) SMulCommClass.continuousConstSMul {R A : Type*} [Monoid A] [SMul R A]
[SMulCommClass R A A] [TopologicalSpace A] [ContinuousMul A] : ContinuousConstSMul R A where
continuous_const_smul q := by
simp +singlePass only [β mul_smul_one q (_ : A)]
exact continuous_id.mul continuous_const
end ContinuousMul
namespace MulOpposite
/-- If multiplication is continuous in `Ξ±`, then it also is in `Ξ±α΅α΅α΅`. -/
@[to_additive "If addition is continuous in `Ξ±`, then it also is in `Ξ±α΅α΅α΅`."]
instance [TopologicalSpace Ξ±] [Mul Ξ±] [ContinuousMul Ξ±] : ContinuousMul Ξ±α΅α΅α΅ :=
β¨continuous_op.comp (continuous_unop.snd'.mul continuous_unop.fst')β©
end MulOpposite
namespace Units
open MulOpposite
variable [TopologicalSpace Ξ±] [Monoid Ξ±] [ContinuousMul Ξ±]
/-- If multiplication on a monoid is continuous, then multiplication on the units of the monoid,
with respect to the induced topology, is continuous.
Inversion is also continuous, but we register this in a later file, `Topology.Algebra.Group`,
because the predicate `ContinuousInv` has not yet been defined. -/
@[to_additive "If addition on an additive monoid is continuous, then addition on the additive units
of the monoid, with respect to the induced topology, is continuous.
Negation is also continuous, but we register this in a later file, `Topology.Algebra.Group`, because
the predicate `ContinuousNeg` has not yet been defined."]
instance : ContinuousMul Ξ±Λ£ := isInducing_embedProduct.continuousMul (embedProduct Ξ±)
end Units
@[to_additive (attr := fun_prop)]
theorem Continuous.units_map [Monoid M] [Monoid N] [TopologicalSpace M] [TopologicalSpace N]
(f : M β* N) (hf : Continuous f) : Continuous (Units.map f) :=
Units.continuous_iff.2 β¨hf.comp Units.continuous_val, hf.comp Units.continuous_coe_invβ©
section
variable [TopologicalSpace M] [CommMonoid M]
@[to_additive]
theorem Submonoid.mem_nhds_one (S : Submonoid M) (oS : IsOpen (S : Set M)) :
(S : Set M) β π (1 : M) :=
IsOpen.mem_nhds oS S.one_mem
variable [ContinuousMul M]
@[to_additive]
| Mathlib/Topology/Algebra/Monoid.lean | 821 | 827 | theorem tendsto_multiset_prod {f : ΞΉ β Ξ± β M} {x : Filter Ξ±} {a : ΞΉ β M} (s : Multiset ΞΉ) :
(β i β s, Tendsto (f i) x (π (a i))) β
Tendsto (fun b => (s.map fun c => f c b).prod) x (π (s.map a).prod) := by | rcases s with β¨lβ©
simpa using tendsto_list_prod l
@[to_additive] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.