source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/RingTheory/NonUnitalSubsemiring/Basic.lean | import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.Algebra.Group.Subsemigroup.Membership
import Mathlib.Algebra.Group.Subsemigroup.Operations
import Mathlib.Algebra.GroupWithZero.Center
import Mathlib.Algebra.Ring.Center
import Mathlib.Algebra.Ring.Centralizer
import Mathlib.Algebra.Ring.Opposite
import Mathlib.Algebra.Ring.Prod
import Mathlib.Algebra.Ring.Submonoid.Basic
import Mathlib.Data.Set.Finite.Range
import Mathlib.GroupTheory.Submonoid.Center
import Mathlib.GroupTheory.Subsemigroup.Centralizer
import Mathlib.RingTheory.NonUnitalSubsemiring.Defs
/-!
# Bundled non-unital subsemirings
We define the `CompleteLattice` structure, and non-unital subsemiring
`map`, `comap` and range (`srange`) of a `NonUnitalRingHom` etc.
-/
universe u v w
variable {R : Type u} {S : Type v} {T : Type w} [NonUnitalNonAssocSemiring R] (M : Subsemigroup R)
namespace NonUnitalSubsemiring
@[mono]
theorem toSubsemigroup_strictMono :
StrictMono (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R) := fun _ _ => id
@[mono]
theorem toSubsemigroup_mono : Monotone (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R) :=
toSubsemigroup_strictMono.monotone
@[mono]
theorem toAddSubmonoid_strictMono :
StrictMono (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R) := fun _ _ => id
@[mono]
theorem toAddSubmonoid_mono : Monotone (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R) :=
toAddSubmonoid_strictMono.monotone
end NonUnitalSubsemiring
namespace NonUnitalSubsemiring
variable [NonUnitalNonAssocSemiring S] [NonUnitalNonAssocSemiring T]
variable {F G : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
[FunLike G S T] [NonUnitalRingHomClass G S T]
(s : NonUnitalSubsemiring R)
/-- The ring equiv between the top element of `NonUnitalSubsemiring R` and `R`. -/
@[simps!]
def topEquiv : (⊤ : NonUnitalSubsemiring R) ≃+* R :=
{ Subsemigroup.topEquiv, AddSubmonoid.topEquiv with }
/-- The preimage of a non-unital subsemiring along a non-unital ring homomorphism is a
non-unital subsemiring. -/
def comap (f : F) (s : NonUnitalSubsemiring S) : NonUnitalSubsemiring R :=
{ s.toSubsemigroup.comap (f : MulHom R S), s.toAddSubmonoid.comap (f : R →+ S) with
carrier := f ⁻¹' s }
@[simp]
theorem coe_comap (s : NonUnitalSubsemiring S) (f : F) : (s.comap f : Set R) = f ⁻¹' s :=
rfl
@[simp]
theorem mem_comap {s : NonUnitalSubsemiring S} {f : F} {x : R} : x ∈ s.comap f ↔ f x ∈ s :=
Iff.rfl
-- this has some nasty coercions, how to deal with it?
theorem comap_comap (s : NonUnitalSubsemiring T) (g : G) (f : F) :
((s.comap g : NonUnitalSubsemiring S).comap f : NonUnitalSubsemiring R) =
s.comap ((g : S →ₙ+* T).comp (f : R →ₙ+* S)) :=
rfl
/-- The image of a non-unital subsemiring along a ring homomorphism is a non-unital subsemiring. -/
def map (f : F) (s : NonUnitalSubsemiring R) : NonUnitalSubsemiring S :=
{ s.toSubsemigroup.map (f : R →ₙ* S), s.toAddSubmonoid.map (f : R →+ S) with carrier := f '' s }
@[simp]
theorem coe_map (f : F) (s : NonUnitalSubsemiring R) : (s.map f : Set S) = f '' s :=
rfl
@[simp]
theorem mem_map {f : F} {s : NonUnitalSubsemiring R} {y : S} : y ∈ s.map f ↔ ∃ x ∈ s, f x = y :=
Iff.rfl
@[simp]
theorem map_id : s.map (NonUnitalRingHom.id R) = s :=
SetLike.coe_injective <| Set.image_id _
-- unavoidable coercions?
theorem map_map (g : G) (f : F) :
(s.map (f : R →ₙ+* S)).map (g : S →ₙ+* T) = s.map ((g : S →ₙ+* T).comp (f : R →ₙ+* S)) :=
SetLike.coe_injective <| Set.image_image _ _ _
theorem map_le_iff_le_comap {f : F} {s : NonUnitalSubsemiring R} {t : NonUnitalSubsemiring S} :
s.map f ≤ t ↔ s ≤ t.comap f :=
Set.image_subset_iff
theorem gc_map_comap (f : F) :
@GaloisConnection (NonUnitalSubsemiring R) (NonUnitalSubsemiring S) _ _ (map f) (comap f) :=
fun _ _ => map_le_iff_le_comap
/-- A non-unital subsemiring is isomorphic to its image under an injective function -/
noncomputable def equivMapOfInjective (f : F) (hf : Function.Injective (f : R → S)) :
s ≃+* s.map f :=
{ Equiv.Set.image f s hf with
map_mul' := fun _ _ => Subtype.ext (map_mul f _ _)
map_add' := fun _ _ => Subtype.ext (map_add f _ _) }
@[simp]
theorem coe_equivMapOfInjective_apply (f : F) (hf : Function.Injective f) (x : s) :
(equivMapOfInjective s f hf x : S) = f x :=
rfl
end NonUnitalSubsemiring
namespace NonUnitalRingHom
open NonUnitalSubsemiring
variable [NonUnitalNonAssocSemiring S] [NonUnitalNonAssocSemiring T]
variable {F G : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
variable [FunLike G S T] [NonUnitalRingHomClass G S T] (f : F) (g : G)
/-- The range of a non-unital ring homomorphism is a non-unital subsemiring.
See note [range copy pattern]. -/
def srange : NonUnitalSubsemiring S :=
((⊤ : NonUnitalSubsemiring R).map (f : R →ₙ+* S)).copy (Set.range f) Set.image_univ.symm
@[simp]
theorem coe_srange : (srange f : Set S) = Set.range f :=
rfl
@[simp]
theorem mem_srange {f : F} {y : S} : y ∈ srange f ↔ ∃ x, f x = y :=
Iff.rfl
theorem srange_eq_map : srange f = (⊤ : NonUnitalSubsemiring R).map f := by
ext
simp
theorem mem_srange_self (f : F) (x : R) : f x ∈ srange f :=
mem_srange.mpr ⟨x, rfl⟩
theorem map_srange (g : S →ₙ+* T) (f : R →ₙ+* S) : map g (srange f) = srange (g.comp f) := by
simpa only [srange_eq_map] using (⊤ : NonUnitalSubsemiring R).map_map g f
/-- The range of a morphism of non-unital semirings is finite if the domain is a finite. -/
instance finite_srange [Finite R] (f : F) : Finite (srange f : NonUnitalSubsemiring S) :=
(Set.finite_range f).to_subtype
end NonUnitalRingHom
namespace NonUnitalSubsemiring
instance : InfSet (NonUnitalSubsemiring R) :=
⟨fun s =>
NonUnitalSubsemiring.mk' (⋂ t ∈ s, ↑t) (⨅ t ∈ s, NonUnitalSubsemiring.toSubsemigroup t)
(by simp) (⨅ t ∈ s, NonUnitalSubsemiring.toAddSubmonoid t) (by simp)⟩
@[simp, norm_cast]
theorem coe_sInf (S : Set (NonUnitalSubsemiring R)) :
((sInf S : NonUnitalSubsemiring R) : Set R) = ⋂ s ∈ S, ↑s :=
rfl
theorem mem_sInf {S : Set (NonUnitalSubsemiring R)} {x : R} : x ∈ sInf S ↔ ∀ p ∈ S, x ∈ p :=
Set.mem_iInter₂
@[simp, norm_cast]
theorem coe_iInf {ι : Sort*} {S : ι → NonUnitalSubsemiring R} :
(↑(⨅ i, S i) : Set R) = ⋂ i, S i := by
simp only [iInf, coe_sInf, Set.biInter_range]
theorem mem_iInf {ι : Sort*} {S : ι → NonUnitalSubsemiring R} {x : R} :
(x ∈ ⨅ i, S i) ↔ ∀ i, x ∈ S i := by
simp only [iInf, mem_sInf, Set.forall_mem_range]
@[simp]
theorem sInf_toSubsemigroup (s : Set (NonUnitalSubsemiring R)) :
(sInf s).toSubsemigroup = ⨅ t ∈ s, NonUnitalSubsemiring.toSubsemigroup t :=
mk'_toSubsemigroup _ _
@[simp]
theorem sInf_toAddSubmonoid (s : Set (NonUnitalSubsemiring R)) :
(sInf s).toAddSubmonoid = ⨅ t ∈ s, NonUnitalSubsemiring.toAddSubmonoid t :=
mk'_toAddSubmonoid _ _
/-- Non-unital subsemirings of a non-unital semiring form a complete lattice. -/
instance : CompleteLattice (NonUnitalSubsemiring R) :=
{ completeLatticeOfInf (NonUnitalSubsemiring R)
fun _ => IsGLB.of_image SetLike.coe_subset_coe isGLB_biInf with
bot := ⊥
bot_le := fun s _ hx => (mem_bot.mp hx).symm ▸ zero_mem s
top := ⊤
le_top := fun _ _ _ => trivial
inf := (· ⊓ ·)
inf_le_left := fun _ _ _ => And.left
inf_le_right := fun _ _ _ => And.right
le_inf := fun _ _ _ h₁ h₂ _ hx => ⟨h₁ hx, h₂ hx⟩ }
theorem eq_top_iff' (A : NonUnitalSubsemiring R) : A = ⊤ ↔ ∀ x : R, x ∈ A :=
eq_top_iff.trans ⟨fun h m => h <| mem_top m, fun h m _ => h m⟩
section NonUnitalNonAssocSemiring
variable (R)
/-- The center of a semiring `R` is the set of elements that commute and associate with everything
in `R` -/
def center : NonUnitalSubsemiring R :=
{ Subsemigroup.center R with
zero_mem' := Set.zero_mem_center
add_mem' := Set.add_mem_center }
theorem coe_center : ↑(center R) = Set.center R :=
rfl
@[simp]
theorem center_toSubsemigroup :
(center R).toSubsemigroup = Subsemigroup.center R :=
rfl
/-- The center is commutative and associative. -/
instance center.instNonUnitalCommSemiring : NonUnitalCommSemiring (center R) :=
{ Subsemigroup.center.commSemigroup,
NonUnitalSubsemiringClass.toNonUnitalNonAssocSemiring (center R) with }
/-- A point-free means of proving membership in the center, for a non-associative ring.
This can be helpful when working with types that have ext lemmas for `R →+ R`. -/
lemma _root_.Set.mem_center_iff_addMonoidHom (a : R) :
a ∈ Set.center R ↔
AddMonoidHom.mulLeft a = .mulRight a ∧
AddMonoidHom.compr₂ .mul (.mulLeft a) = .comp .mul (.mulLeft a) ∧
AddMonoidHom.compr₂ .mul (.mulRight a) = .compl₂ .mul (.mulRight a) := by
rw [Set.mem_center_iff, isMulCentral_iff]
simp [DFunLike.ext_iff, commute_iff_eq]
variable {R}
/-- The center of isomorphic (not necessarily unital or associative) semirings are isomorphic. -/
@[simps!] def centerCongr [NonUnitalNonAssocSemiring S] (e : R ≃+* S) : center R ≃+* center S where
__ := Subsemigroup.centerCongr e
map_add' _ _ := Subtype.ext <| by exact map_add e ..
/-- The center of a (not necessarily unital or associative) semiring
is isomorphic to the center of its opposite. -/
@[simps!] def centerToMulOpposite : center R ≃+* center Rᵐᵒᵖ where
__ := Subsemigroup.centerToMulOpposite
map_add' _ _ := rfl
end NonUnitalNonAssocSemiring
section NonUnitalSemiring
-- no instance diamond, unlike the unital version
example {R} [NonUnitalSemiring R] :
(center.instNonUnitalCommSemiring _).toNonUnitalSemiring =
NonUnitalSubsemiringClass.toNonUnitalSemiring (center R) := by
with_reducible_and_instances rfl
theorem mem_center_iff {R} [NonUnitalSemiring R] {z : R} : z ∈ center R ↔ ∀ g, g * z = z * g := by
rw [← Semigroup.mem_center_iff]
exact Iff.rfl
instance decidableMemCenter {R} [NonUnitalSemiring R] [DecidableEq R] [Fintype R] :
DecidablePred (· ∈ center R) := fun _ => decidable_of_iff' _ mem_center_iff
@[simp]
theorem center_eq_top (R) [NonUnitalCommSemiring R] : center R = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ R)
end NonUnitalSemiring
section Centralizer
/-- The centralizer of a set as non-unital subsemiring. -/
def centralizer {R} [NonUnitalSemiring R] (s : Set R) : NonUnitalSubsemiring R :=
{ Subsemigroup.centralizer s with
carrier := s.centralizer
zero_mem' := Set.zero_mem_centralizer
add_mem' := Set.add_mem_centralizer }
@[simp, norm_cast]
theorem coe_centralizer {R} [NonUnitalSemiring R] (s : Set R) :
(centralizer s : Set R) = s.centralizer :=
rfl
theorem centralizer_toSubsemigroup {R} [NonUnitalSemiring R] (s : Set R) :
(centralizer s).toSubsemigroup = Subsemigroup.centralizer s :=
rfl
theorem mem_centralizer_iff {R} [NonUnitalSemiring R] {s : Set R} {z : R} :
z ∈ centralizer s ↔ ∀ g ∈ s, g * z = z * g :=
Iff.rfl
theorem center_le_centralizer {R} [NonUnitalSemiring R] (s) : center R ≤ centralizer s :=
s.center_subset_centralizer
theorem centralizer_le {R} [NonUnitalSemiring R] (s t : Set R) (h : s ⊆ t) :
centralizer t ≤ centralizer s :=
Set.centralizer_subset h
@[simp]
theorem centralizer_eq_top_iff_subset {R} [NonUnitalSemiring R] {s : Set R} :
centralizer s = ⊤ ↔ s ⊆ center R :=
SetLike.ext'_iff.trans Set.centralizer_eq_top_iff_subset
@[simp]
theorem centralizer_univ {R} [NonUnitalSemiring R] : centralizer Set.univ = center R :=
SetLike.ext' (Set.centralizer_univ R)
end Centralizer
/-- The `NonUnitalSubsemiring` generated by a set. -/
def closure (s : Set R) : NonUnitalSubsemiring R :=
sInf { S | s ⊆ S }
theorem mem_closure {x : R} {s : Set R} :
x ∈ closure s ↔ ∀ S : NonUnitalSubsemiring R, s ⊆ S → x ∈ S :=
mem_sInf
/-- The non-unital subsemiring generated by a set includes the set. -/
@[simp, aesop safe 20 (rule_sets := [SetLike])]
theorem subset_closure {s : Set R} : s ⊆ closure s := fun _ hx => mem_closure.2 fun _ hS => hS hx
@[aesop 80% (rule_sets := [SetLike])]
theorem mem_closure_of_mem {s : Set R} {x : R} (hx : x ∈ s) : x ∈ closure s := subset_closure hx
theorem notMem_of_notMem_closure {s : Set R} {P : R} (hP : P ∉ closure s) : P ∉ s := fun h =>
hP (subset_closure h)
@[deprecated (since := "2025-05-23")] alias not_mem_of_not_mem_closure := notMem_of_notMem_closure
/-- A non-unital subsemiring `S` includes `closure s` if and only if it includes `s`. -/
@[simp]
theorem closure_le {s : Set R} {t : NonUnitalSubsemiring R} : closure s ≤ t ↔ s ⊆ t :=
⟨Set.Subset.trans subset_closure, fun h => sInf_le h⟩
/-- Subsemiring closure of a set is monotone in its argument: if `s ⊆ t`,
then `closure s ≤ closure t`. -/
@[gcongr]
theorem closure_mono ⦃s t : Set R⦄ (h : s ⊆ t) : closure s ≤ closure t :=
closure_le.2 <| Set.Subset.trans h subset_closure
theorem closure_eq_of_le {s : Set R} {t : NonUnitalSubsemiring R} (h₁ : s ⊆ t)
(h₂ : t ≤ closure s) : closure s = t :=
le_antisymm (closure_le.2 h₁) h₂
lemma closure_le_centralizer_centralizer {R : Type*} [NonUnitalSemiring R] (s : Set R) :
closure s ≤ centralizer (centralizer s) :=
closure_le.mpr Set.subset_centralizer_centralizer
/-- If all the elements of a set `s` commute, then `closure s` is a non-unital commutative
semiring. -/
abbrev closureNonUnitalCommSemiringOfComm {R : Type*} [NonUnitalSemiring R] {s : Set R}
(hcomm : ∀ x ∈ s, ∀ y ∈ s, x * y = y * x) : NonUnitalCommSemiring (closure s) :=
{ NonUnitalSubsemiringClass.toNonUnitalSemiring (closure s) with
mul_comm := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦
have := closure_le_centralizer_centralizer s
Subtype.ext <| Set.centralizer_centralizer_comm_of_comm hcomm _ (this h₁) _ (this h₂) }
variable [NonUnitalNonAssocSemiring S]
theorem mem_map_equiv {f : R ≃+* S} {K : NonUnitalSubsemiring R} {x : S} :
x ∈ K.map (f : R →ₙ+* S) ↔ f.symm x ∈ K := by
convert @Set.mem_image_equiv _ _ (↑K) f.toEquiv x
theorem map_equiv_eq_comap_symm (f : R ≃+* S) (K : NonUnitalSubsemiring R) :
K.map (f : R →ₙ+* S) = K.comap f.symm :=
SetLike.coe_injective (f.toEquiv.image_eq_preimage_symm K)
theorem comap_equiv_eq_map_symm (f : R ≃+* S) (K : NonUnitalSubsemiring S) :
K.comap (f : R →ₙ+* S) = K.map f.symm :=
(map_equiv_eq_comap_symm f.symm K).symm
end NonUnitalSubsemiring
namespace Subsemigroup
/-- The additive closure of a non-unital subsemigroup is a non-unital subsemiring. -/
def nonUnitalSubsemiringClosure (M : Subsemigroup R) : NonUnitalSubsemiring R :=
{ AddSubmonoid.closure (M : Set R) with mul_mem' := MulMemClass.mul_mem_add_closure }
theorem nonUnitalSubsemiringClosure_coe :
(M.nonUnitalSubsemiringClosure : Set R) = AddSubmonoid.closure (M : Set R) :=
rfl
theorem nonUnitalSubsemiringClosure_toAddSubmonoid :
M.nonUnitalSubsemiringClosure.toAddSubmonoid = AddSubmonoid.closure (M : Set R) :=
rfl
/-- The `NonUnitalSubsemiring` generated by a multiplicative subsemigroup coincides with the
`NonUnitalSubsemiring.closure` of the subsemigroup itself . -/
theorem nonUnitalSubsemiringClosure_eq_closure :
M.nonUnitalSubsemiringClosure = NonUnitalSubsemiring.closure (M : Set R) := by
ext
refine ⟨fun hx => ?_,
fun hx => (NonUnitalSubsemiring.mem_closure.mp hx) M.nonUnitalSubsemiringClosure fun s sM => ?_⟩
<;> rintro - ⟨H1, rfl⟩
<;> rintro - ⟨H2, rfl⟩
· exact AddSubmonoid.mem_closure.mp hx H1.toAddSubmonoid H2
· exact H2 sM
end Subsemigroup
namespace NonUnitalSubsemiring
@[simp]
theorem closure_subsemigroup_closure (s : Set R) : closure ↑(Subsemigroup.closure s) = closure s :=
le_antisymm
(closure_le.mpr fun _ hy =>
(Subsemigroup.mem_closure.mp hy) (closure s).toSubsemigroup subset_closure)
(closure_mono Subsemigroup.subset_closure)
/-- The elements of the non-unital subsemiring closure of `M` are exactly the elements of the
additive closure of a multiplicative subsemigroup `M`. -/
theorem coe_closure_eq (s : Set R) :
(closure s : Set R) = AddSubmonoid.closure (Subsemigroup.closure s : Set R) := by
simp [← Subsemigroup.nonUnitalSubsemiringClosure_toAddSubmonoid,
Subsemigroup.nonUnitalSubsemiringClosure_eq_closure]
theorem mem_closure_iff {s : Set R} {x} :
x ∈ closure s ↔ x ∈ AddSubmonoid.closure (Subsemigroup.closure s : Set R) :=
Set.ext_iff.mp (coe_closure_eq s) x
@[simp]
theorem closure_addSubmonoid_closure {s : Set R} :
closure ↑(AddSubmonoid.closure s) = closure s := by
ext x
refine ⟨fun hx => ?_, fun hx => closure_mono AddSubmonoid.subset_closure hx⟩
rintro - ⟨H, rfl⟩
rintro - ⟨J, rfl⟩
refine (AddSubmonoid.mem_closure.mp (mem_closure_iff.mp hx)) H.toAddSubmonoid fun y hy => ?_
refine (Subsemigroup.mem_closure.mp hy) H.toSubsemigroup fun z hz => ?_
exact (AddSubmonoid.mem_closure.mp hz) H.toAddSubmonoid fun w hw => J hw
/-- An induction principle for closure membership. If `p` holds for `0`, `1`, and all elements
of `s`, and is preserved under addition and multiplication, then `p` holds for all elements
of the closure of `s`. -/
@[elab_as_elim]
theorem closure_induction {s : Set R} {p : (x : R) → x ∈ closure s → Prop}
(mem : ∀ (x) (hx : x ∈ s), p x (subset_closure hx)) (zero : p 0 (zero_mem _))
(add : ∀ x y hx hy, p x hx → p y hy → p (x + y) (add_mem hx hy))
(mul : ∀ x y hx hy, p x hx → p y hy → p (x * y) (mul_mem hx hy))
{x} (hx : x ∈ closure s) : p x hx :=
let K : NonUnitalSubsemiring R :=
{ carrier := { x | ∃ hx, p x hx }
mul_mem' := fun ⟨_, hpx⟩ ⟨_, hpy⟩ ↦ ⟨_, mul _ _ _ _ hpx hpy⟩
add_mem' := fun ⟨_, hpx⟩ ⟨_, hpy⟩ ↦ ⟨_, add _ _ _ _ hpx hpy⟩
zero_mem' := ⟨_, zero⟩ }
closure_le (t := K) |>.mpr (fun y hy ↦ ⟨subset_closure hy, mem y hy⟩) hx |>.elim fun _ ↦ id
/-- An induction principle for closure membership for predicates with two arguments. -/
@[elab_as_elim]
theorem closure_induction₂ {s : Set R} {p : (x y : R) → x ∈ closure s → y ∈ closure s → Prop}
(mem_mem : ∀ (x) (hx : x ∈ s) (y) (hy : y ∈ s), p x y (subset_closure hx) (subset_closure hy))
(zero_left : ∀ x hx, p 0 x (zero_mem _) hx) (zero_right : ∀ x hx, p x 0 hx (zero_mem _))
(add_left : ∀ x y z hx hy hz, p x z hx hz → p y z hy hz → p (x + y) z (add_mem hx hy) hz)
(add_right : ∀ x y z hx hy hz, p x y hx hy → p x z hx hz → p x (y + z) hx (add_mem hy hz))
(mul_left : ∀ x y z hx hy hz, p x z hx hz → p y z hy hz → p (x * y) z (mul_mem hx hy) hz)
(mul_right : ∀ x y z hx hy hz, p x y hx hy → p x z hx hz → p x (y * z) hx (mul_mem hy hz))
{x y : R} (hx : x ∈ closure s) (hy : y ∈ closure s) :
p x y hx hy := by
induction hy using closure_induction with
| mem z hz => induction hx using closure_induction with
| mem _ h => exact mem_mem _ h _ hz
| zero => exact zero_left _ _
| mul _ _ _ _ h₁ h₂ => exact mul_left _ _ _ _ _ _ h₁ h₂
| add _ _ _ _ h₁ h₂ => exact add_left _ _ _ _ _ _ h₁ h₂
| zero => exact zero_right x hx
| mul _ _ _ _ h₁ h₂ => exact mul_right _ _ _ _ _ _ h₁ h₂
| add _ _ _ _ h₁ h₂ => exact add_right _ _ _ _ _ _ h₁ h₂
variable (R) in
/-- `closure` forms a Galois insertion with the coercion to set. -/
protected def gi : GaloisInsertion (@closure R _) (↑) where
choice s _ := closure s
gc _ _ := closure_le
le_l_u _ := subset_closure
choice_eq _ _ := rfl
variable [NonUnitalNonAssocSemiring S]
variable {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
/-- Closure of a non-unital subsemiring `S` equals `S`. -/
@[simp]
theorem closure_eq (s : NonUnitalSubsemiring R) : closure (s : Set R) = s :=
(NonUnitalSubsemiring.gi R).l_u_eq s
@[simp]
theorem closure_empty : closure (∅ : Set R) = ⊥ :=
(NonUnitalSubsemiring.gi R).gc.l_bot
@[simp]
theorem closure_univ : closure (Set.univ : Set R) = ⊤ :=
@coe_top R _ ▸ closure_eq ⊤
theorem closure_union (s t : Set R) : closure (s ∪ t) = closure s ⊔ closure t :=
(NonUnitalSubsemiring.gi R).gc.l_sup
theorem closure_iUnion {ι} (s : ι → Set R) : closure (⋃ i, s i) = ⨆ i, closure (s i) :=
(NonUnitalSubsemiring.gi R).gc.l_iSup
theorem closure_sUnion (s : Set (Set R)) : closure (⋃₀ s) = ⨆ t ∈ s, closure t :=
(NonUnitalSubsemiring.gi R).gc.l_sSup
theorem map_sup (s t : NonUnitalSubsemiring R) (f : F) :
(map f (s ⊔ t) : NonUnitalSubsemiring S) = map f s ⊔ map f t :=
@GaloisConnection.l_sup _ _ s t _ _ _ _ (gc_map_comap f)
theorem map_iSup {ι : Sort*} (f : F) (s : ι → NonUnitalSubsemiring R) :
(map f (iSup s) : NonUnitalSubsemiring S) = ⨆ i, map f (s i) :=
@GaloisConnection.l_iSup _ _ _ _ _ _ _ (gc_map_comap f) s
theorem map_inf (s t : NonUnitalSubsemiring R) (f : F) (hf : Function.Injective f) :
(map f (s ⊓ t) : NonUnitalSubsemiring S) = map f s ⊓ map f t :=
SetLike.coe_injective (Set.image_inter hf)
theorem map_iInf {ι : Sort*} [Nonempty ι] (f : F) (hf : Function.Injective f)
(s : ι → NonUnitalSubsemiring R) :
(map f (iInf s) : NonUnitalSubsemiring S) = ⨅ i, map f (s i) := by
apply SetLike.coe_injective
simpa using (Set.injOn_of_injective hf).image_iInter_eq (s := SetLike.coe ∘ s)
theorem comap_inf (s t : NonUnitalSubsemiring S) (f : F) :
(comap f (s ⊓ t) : NonUnitalSubsemiring R) = comap f s ⊓ comap f t :=
@GaloisConnection.u_inf _ _ s t _ _ _ _ (gc_map_comap f)
theorem comap_iInf {ι : Sort*} (f : F) (s : ι → NonUnitalSubsemiring S) :
(comap f (iInf s) : NonUnitalSubsemiring R) = ⨅ i, comap f (s i) :=
@GaloisConnection.u_iInf _ _ _ _ _ _ _ (gc_map_comap f) s
@[simp]
theorem map_bot (f : F) : map f (⊥ : NonUnitalSubsemiring R) = (⊥ : NonUnitalSubsemiring S) :=
(gc_map_comap f).l_bot
@[simp]
theorem comap_top (f : F) : comap f (⊤ : NonUnitalSubsemiring S) = (⊤ : NonUnitalSubsemiring R) :=
(gc_map_comap f).u_top
/-- Given `NonUnitalSubsemiring`s `s`, `t` of semirings `R`, `S` respectively, `s.prod t` is
`s × t` as a non-unital subsemiring of `R × S`. -/
def prod (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) : NonUnitalSubsemiring (R × S) :=
{ s.toSubsemigroup.prod t.toSubsemigroup, s.toAddSubmonoid.prod t.toAddSubmonoid with
carrier := (s : Set R) ×ˢ (t : Set S) }
@[norm_cast]
theorem coe_prod (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) :
(s.prod t : Set (R × S)) = (s : Set R) ×ˢ (t : Set S) :=
rfl
theorem mem_prod {s : NonUnitalSubsemiring R} {t : NonUnitalSubsemiring S} {p : R × S} :
p ∈ s.prod t ↔ p.1 ∈ s ∧ p.2 ∈ t :=
Iff.rfl
@[mono]
theorem prod_mono ⦃s₁ s₂ : NonUnitalSubsemiring R⦄ (hs : s₁ ≤ s₂) ⦃t₁ t₂ : NonUnitalSubsemiring S⦄
(ht : t₁ ≤ t₂) : s₁.prod t₁ ≤ s₂.prod t₂ :=
Set.prod_mono hs ht
theorem prod_mono_right (s : NonUnitalSubsemiring R) :
Monotone fun t : NonUnitalSubsemiring S => s.prod t :=
prod_mono (le_refl s)
theorem prod_mono_left (t : NonUnitalSubsemiring S) :
Monotone fun s : NonUnitalSubsemiring R => s.prod t := fun _ _ hs => prod_mono hs (le_refl t)
theorem prod_top (s : NonUnitalSubsemiring R) :
s.prod (⊤ : NonUnitalSubsemiring S) = s.comap (NonUnitalRingHom.fst R S) :=
ext fun x => by simp [mem_prod]
theorem top_prod (s : NonUnitalSubsemiring S) :
(⊤ : NonUnitalSubsemiring R).prod s = s.comap (NonUnitalRingHom.snd R S) :=
ext fun x => by simp [mem_prod]
@[simp]
theorem top_prod_top : (⊤ : NonUnitalSubsemiring R).prod (⊤ : NonUnitalSubsemiring S) = ⊤ :=
(top_prod _).trans <| comap_top _
/-- Product of non-unital subsemirings is isomorphic to their product as semigroups. -/
def prodEquiv (s : NonUnitalSubsemiring R) (t : NonUnitalSubsemiring S) : s.prod t ≃+* s × t :=
{ Equiv.Set.prod (s : Set R) (t : Set S) with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
theorem mem_iSup_of_directed {ι} [hι : Nonempty ι] {S : ι → NonUnitalSubsemiring R}
(hS : Directed (· ≤ ·) S) {x : R} : (x ∈ ⨆ i, S i) ↔ ∃ i, x ∈ S i := by
refine ⟨?_, fun ⟨i, hi⟩ ↦ le_iSup S i hi⟩
let U : NonUnitalSubsemiring R :=
NonUnitalSubsemiring.mk' (⋃ i, (S i : Set R))
(⨆ i, (S i).toSubsemigroup) (Subsemigroup.coe_iSup_of_directed hS)
(⨆ i, (S i).toAddSubmonoid) (AddSubmonoid.coe_iSup_of_directed hS)
suffices ⨆ i, S i ≤ U by simpa [U] using @this x
exact iSup_le fun i x hx => Set.mem_iUnion.2 ⟨i, hx⟩
theorem coe_iSup_of_directed {ι} [hι : Nonempty ι] {S : ι → NonUnitalSubsemiring R}
(hS : Directed (· ≤ ·) S) : ((⨆ i, S i : NonUnitalSubsemiring R) : Set R) = ⋃ i, S i :=
Set.ext fun x ↦ by simp [mem_iSup_of_directed hS]
theorem mem_sSup_of_directedOn {S : Set (NonUnitalSubsemiring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) {x : R} : x ∈ sSup S ↔ ∃ s ∈ S, x ∈ s := by
haveI : Nonempty S := Sne.to_subtype
simp only [sSup_eq_iSup', mem_iSup_of_directed hS.directed_val, Subtype.exists, exists_prop]
theorem coe_sSup_of_directedOn {S : Set (NonUnitalSubsemiring R)} (Sne : S.Nonempty)
(hS : DirectedOn (· ≤ ·) S) : (↑(sSup S) : Set R) = ⋃ s ∈ S, ↑s :=
Set.ext fun x => by simp [mem_sSup_of_directedOn Sne hS]
end NonUnitalSubsemiring
namespace NonUnitalRingHom
variable {F : Type*} [FunLike F R S]
theorem eq_of_eqOn_stop {f g : F}
(h : Set.EqOn (f : R → S) (g : R → S) (⊤ : NonUnitalSubsemiring R)) : f = g :=
DFunLike.ext _ _ fun _ => h trivial
variable [NonUnitalNonAssocSemiring S] [NonUnitalNonAssocSemiring T]
[NonUnitalRingHomClass F R S]
{S' : Type*} [SetLike S' S] [NonUnitalSubsemiringClass S' S]
{s : NonUnitalSubsemiring R}
open NonUnitalSubsemiringClass NonUnitalSubsemiring
/-- Restriction of a non-unital ring homomorphism to its range interpreted as a
non-unital subsemiring.
This is the bundled version of `Set.rangeFactorization`. -/
def srangeRestrict (f : F) : R →ₙ+* (srange f : NonUnitalSubsemiring S) :=
codRestrict f (srange f) (mem_srange_self f)
@[simp]
theorem coe_srangeRestrict (f : F) (x : R) : (srangeRestrict f x : S) = f x :=
rfl
theorem srangeRestrict_surjective (f : F) :
Function.Surjective (srangeRestrict f : R → (srange f : NonUnitalSubsemiring S)) :=
fun ⟨_, hy⟩ =>
let ⟨x, hx⟩ := mem_srange.mp hy
⟨x, Subtype.ext hx⟩
theorem srange_eq_top_iff_surjective {f : F} :
srange f = (⊤ : NonUnitalSubsemiring S) ↔ Function.Surjective (f : R → S) :=
SetLike.ext'_iff.trans <| Iff.trans (by rw [coe_srange, coe_top]) Set.range_eq_univ
/-- The range of a surjective non-unital ring homomorphism is the whole of the codomain. -/
@[simp]
theorem srange_eq_top_of_surjective (f : F) (hf : Function.Surjective (f : R → S)) :
srange f = (⊤ : NonUnitalSubsemiring S) :=
srange_eq_top_iff_surjective.2 hf
/-- If two non-unital ring homomorphisms are equal on a set, then they are equal on its
non-unital subsemiring closure. -/
theorem eqOn_sclosure {f g : F} {s : Set R} (h : Set.EqOn (f : R → S) (g : R → S) s) :
Set.EqOn f g (closure s) :=
show closure s ≤ eqSlocus f g from closure_le.2 h
theorem eq_of_eqOn_sdense {s : Set R} (hs : closure s = ⊤) {f g : F}
(h : s.EqOn (f : R → S) (g : R → S)) : f = g :=
eq_of_eqOn_stop <| hs ▸ eqOn_sclosure h
theorem sclosure_preimage_le (f : F) (s : Set S) :
closure ((f : R → S) ⁻¹' s) ≤ (closure s).comap f :=
closure_le.2 fun _ hx => SetLike.mem_coe.2 <| mem_comap.2 <| subset_closure hx
/-- The image under a ring homomorphism of the subsemiring generated by a set equals
the subsemiring generated by the image of the set. -/
theorem map_sclosure (f : F) (s : Set R) : (closure s).map f = closure ((f : R → S) '' s) :=
Set.image_preimage.l_comm_of_u_comm (gc_map_comap f) (NonUnitalSubsemiring.gi S).gc
(NonUnitalSubsemiring.gi R).gc fun _ ↦ rfl
end NonUnitalRingHom
namespace NonUnitalSubsemiring
open NonUnitalRingHom NonUnitalSubsemiringClass
@[simp]
theorem srange_subtype (s : NonUnitalSubsemiring R) : NonUnitalRingHom.srange (subtype s) = s :=
SetLike.coe_injective <| (coe_srange _).trans Subtype.range_coe
variable [NonUnitalNonAssocSemiring S]
@[simp]
theorem range_fst : NonUnitalRingHom.srange (fst R S) = ⊤ :=
NonUnitalRingHom.srange_eq_top_of_surjective (fst R S) Prod.fst_surjective
@[simp]
theorem range_snd : NonUnitalRingHom.srange (snd R S) = ⊤ :=
NonUnitalRingHom.srange_eq_top_of_surjective (snd R S) <| Prod.snd_surjective
end NonUnitalSubsemiring
namespace RingEquiv
open NonUnitalRingHom NonUnitalSubsemiringClass
variable {s t : NonUnitalSubsemiring R}
variable [NonUnitalNonAssocSemiring S] {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
/-- Makes the identity isomorphism from a proof two non-unital subsemirings of a multiplicative
monoid are equal. -/
def nonUnitalSubsemiringCongr (h : s = t) : s ≃+* t :=
{ Equiv.setCongr <| congr_arg _ h with
map_mul' := fun _ _ => rfl
map_add' := fun _ _ => rfl }
/-- Restrict a non-unital ring homomorphism with a left inverse to a ring isomorphism to its
`NonUnitalRingHom.srange`. -/
def sofLeftInverse' {g : S → R} {f : F} (h : Function.LeftInverse g f) : R ≃+* srange f :=
{ srangeRestrict f with
toFun := srangeRestrict f
invFun := fun x => g (subtype (srange f) x)
left_inv := h
right_inv := fun x =>
Subtype.ext <|
let ⟨x', hx'⟩ := NonUnitalRingHom.mem_srange.mp x.prop
show f (g x) = x by rw [← hx', h x'] }
@[simp]
theorem sofLeftInverse'_apply {g : S → R} {f : F} (h : Function.LeftInverse g f) (x : R) :
↑(sofLeftInverse' h x) = f x :=
rfl
@[simp]
theorem sofLeftInverse'_symm_apply {g : S → R} {f : F} (h : Function.LeftInverse g f)
(x : srange f) : (sofLeftInverse' h).symm x = g x :=
rfl
/-- Given an equivalence `e : R ≃+* S` of non-unital semirings and a non-unital subsemiring
`s` of `R`, `non_unital_subsemiring_map e s` is the induced equivalence between `s` and
`s.map e` -/
@[simps!]
def nonUnitalSubsemiringMap (e : R ≃+* S) (s : NonUnitalSubsemiring R) :
s ≃+* NonUnitalSubsemiring.map e.toNonUnitalRingHom s :=
{ e.toAddEquiv.addSubmonoidMap s.toAddSubmonoid,
e.toMulEquiv.subsemigroupMap s.toSubsemigroup with }
end RingEquiv |
.lake/packages/mathlib/Mathlib/RingTheory/NonUnitalSubsemiring/Defs.lean | import Mathlib.Algebra.Ring.Hom.Defs
import Mathlib.Algebra.Ring.InjSurj
import Mathlib.Algebra.Group.Submonoid.Defs
import Mathlib.Tactic.FastInstance
/-!
# Bundled non-unital subsemirings
We define bundled non-unital subsemirings and some standard constructions:
`subtype` and `inclusion` ring homomorphisms.
-/
assert_not_exists RelIso
universe u v w
section neg_mul
variable {R S : Type*} [Mul R] [HasDistribNeg R] [SetLike S R] [MulMemClass S R] {s : S}
/-- This lemma exists for `aesop`, as `aesop` simplifies `-x * y` to `-(x * y)` before applying
unsafe rules like `mul_mem`, leading to a dead end in cases where `neg_mem` does not hold. -/
@[aesop unsafe 80% (rule_sets := [SetLike])]
theorem neg_mul_mem {x y : R} (hx : -x ∈ s) (hy : y ∈ s) : -(x * y) ∈ s := by
simpa using mul_mem hx hy
/-- This lemma exists for `aesop`, as `aesop` simplifies `x * -y` to `-(x * y)` before applying
unsafe rules like `mul_mem`, leading to a dead end in cases where `neg_mem` does not hold. -/
@[aesop unsafe 80% (rule_sets := [SetLike])]
theorem mul_neg_mem {x y : R} (hx : x ∈ s) (hy : -y ∈ s) : -(x * y) ∈ s := by
simpa using mul_mem hx hy
-- doesn't work without the above `aesop` lemmas
example {x y z : R} (hx : x ∈ s) (hy : -y ∈ s) (hz : z ∈ s) :
x * (-y) * z ∈ s := by aesop
end neg_mul
variable {R : Type u} {S : Type v} {T : Type w} [NonUnitalNonAssocSemiring R]
/-- `NonUnitalSubsemiringClass S R` states that `S` is a type of subsets `s ⊆ R` that
are both an additive submonoid and also a multiplicative subsemigroup. -/
class NonUnitalSubsemiringClass (S : Type*) (R : outParam (Type u)) [NonUnitalNonAssocSemiring R]
[SetLike S R] : Prop
extends AddSubmonoidClass S R where
mul_mem : ∀ {s : S} {a b : R}, a ∈ s → b ∈ s → a * b ∈ s
-- See note [lower instance priority]
instance (priority := 100) NonUnitalSubsemiringClass.mulMemClass (S : Type*) (R : Type u)
[NonUnitalNonAssocSemiring R] [SetLike S R] [h : NonUnitalSubsemiringClass S R] :
MulMemClass S R :=
{ h with }
namespace NonUnitalSubsemiringClass
variable [SetLike S R] [NonUnitalSubsemiringClass S R] (s : S)
open AddSubmonoidClass
/- Prefer subclasses of `NonUnitalNonAssocSemiring` over subclasses of
`NonUnitalSubsemiringClass`. -/
/-- A non-unital subsemiring of a `NonUnitalNonAssocSemiring` inherits a
`NonUnitalNonAssocSemiring` structure -/
instance (priority := 75) toNonUnitalNonAssocSemiring :
NonUnitalNonAssocSemiring s := fast_instance%
Subtype.coe_injective.nonUnitalNonAssocSemiring Subtype.val rfl (by simp) (fun _ _ => rfl)
fun _ _ => rfl
instance noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors s :=
Subtype.coe_injective.noZeroDivisors Subtype.val rfl fun _ _ => rfl
/-- The natural non-unital ring hom from a non-unital subsemiring of a non-unital semiring `R` to
`R`. -/
def subtype : s →ₙ+* R :=
{ AddSubmonoidClass.subtype s, MulMemClass.subtype s with toFun := (↑) }
variable {s} in
@[simp]
theorem subtype_apply (x : s) : subtype s x = x :=
rfl
theorem subtype_injective : Function.Injective (subtype s) :=
Subtype.coe_injective
@[simp]
theorem coe_subtype : (subtype s : s → R) = ((↑) : s → R) :=
rfl
/-- A non-unital subsemiring of a `NonUnitalSemiring` is a `NonUnitalSemiring`. -/
instance toNonUnitalSemiring {R} [NonUnitalSemiring R] [SetLike S R]
[NonUnitalSubsemiringClass S R] : NonUnitalSemiring s := fast_instance%
Subtype.coe_injective.nonUnitalSemiring Subtype.val rfl (by simp) (fun _ _ => rfl) fun _ _ => rfl
/-- A non-unital subsemiring of a `NonUnitalCommSemiring` is a `NonUnitalCommSemiring`. -/
instance toNonUnitalCommSemiring {R} [NonUnitalCommSemiring R] [SetLike S R]
[NonUnitalSubsemiringClass S R] : NonUnitalCommSemiring s := fast_instance%
Subtype.coe_injective.nonUnitalCommSemiring Subtype.val rfl (by simp) (fun _ _ => rfl)
fun _ _ => rfl
/-! Note: currently, there are no ordered versions of non-unital rings. -/
end NonUnitalSubsemiringClass
/-- A non-unital subsemiring of a non-unital semiring `R` is a subset `s` that is both an additive
submonoid and a semigroup. -/
structure NonUnitalSubsemiring (R : Type u) [NonUnitalNonAssocSemiring R] extends AddSubmonoid R,
Subsemigroup R
/-- Reinterpret a `NonUnitalSubsemiring` as a `Subsemigroup`. -/
add_decl_doc NonUnitalSubsemiring.toSubsemigroup
/-- Reinterpret a `NonUnitalSubsemiring` as an `AddSubmonoid`. -/
add_decl_doc NonUnitalSubsemiring.toAddSubmonoid
namespace NonUnitalSubsemiring
instance : SetLike (NonUnitalSubsemiring R) R where
coe s := s.carrier
coe_injective' p q h := by cases p; cases q; congr; exact SetLike.coe_injective' h
/-- The actual `NonUnitalSubsemiring` obtained from an element of a `NonUnitalSubsemiringClass`. -/
@[simps]
def ofClass {S R : Type*} [NonUnitalNonAssocSemiring R] [SetLike S R]
[NonUnitalSubsemiringClass S R] (s : S) : NonUnitalSubsemiring R where
carrier := s
add_mem' := add_mem
zero_mem' := zero_mem _
mul_mem' := mul_mem
instance (priority := 100) : CanLift (Set R) (NonUnitalSubsemiring R) (↑)
(fun s ↦ 0 ∈ s ∧ (∀ {x y}, x ∈ s → y ∈ s → x + y ∈ s) ∧ ∀ {x y}, x ∈ s → y ∈ s → x * y ∈ s)
where
prf s h :=
⟨ { carrier := s
zero_mem' := h.1
add_mem' := h.2.1
mul_mem' := h.2.2 },
rfl ⟩
instance : NonUnitalSubsemiringClass (NonUnitalSubsemiring R) R where
zero_mem {s} := AddSubmonoid.zero_mem' s.toAddSubmonoid
add_mem {s} := AddSubsemigroup.add_mem' s.toAddSubmonoid.toAddSubsemigroup
mul_mem {s} := mul_mem' s
theorem mem_carrier {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.carrier ↔ x ∈ s :=
Iff.rfl
/-- Two non-unital subsemirings are equal if they have the same elements. -/
@[ext]
theorem ext {S T : NonUnitalSubsemiring R} (h : ∀ x, x ∈ S ↔ x ∈ T) : S = T :=
SetLike.ext h
/-- Copy of a non-unital subsemiring with a new `carrier` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) :
NonUnitalSubsemiring R :=
{ S.toAddSubmonoid.copy s hs, S.toSubsemigroup.copy s hs with carrier := s }
@[simp]
theorem coe_copy (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) :
(S.copy s hs : Set R) = s :=
rfl
theorem copy_eq (S : NonUnitalSubsemiring R) (s : Set R) (hs : s = ↑S) : S.copy s hs = S :=
SetLike.coe_injective hs
theorem toSubsemigroup_injective :
Function.Injective (toSubsemigroup : NonUnitalSubsemiring R → Subsemigroup R)
| _, _, h => ext (SetLike.ext_iff.mp h :)
theorem toAddSubmonoid_injective :
Function.Injective (toAddSubmonoid : NonUnitalSubsemiring R → AddSubmonoid R)
| _, _, h => ext (SetLike.ext_iff.mp h :)
/-- Construct a `NonUnitalSubsemiring R` from a set `s`, a subsemigroup `sg`, and an additive
submonoid `sa` such that `x ∈ s ↔ x ∈ sg ↔ x ∈ sa`. -/
protected def mk' (s : Set R) (sg : Subsemigroup R) (hg : ↑sg = s) (sa : AddSubmonoid R)
(ha : ↑sa = s) : NonUnitalSubsemiring R where
carrier := s
zero_mem' := by subst ha; exact sa.zero_mem
add_mem' := by subst ha; exact sa.add_mem
mul_mem' := by subst hg; exact sg.mul_mem
@[simp]
theorem coe_mk' {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha : Set R) = s :=
rfl
@[simp]
theorem mem_mk' {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) {x : R} : x ∈ NonUnitalSubsemiring.mk' s sg hg sa ha ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem mk'_toSubsemigroup {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha).toSubsemigroup = sg :=
SetLike.coe_injective hg.symm
@[simp]
theorem mk'_toAddSubmonoid {s : Set R} {sg : Subsemigroup R} (hg : ↑sg = s) {sa : AddSubmonoid R}
(ha : ↑sa = s) : (NonUnitalSubsemiring.mk' s sg hg sa ha).toAddSubmonoid = sa :=
SetLike.coe_injective ha.symm
end NonUnitalSubsemiring
namespace NonUnitalSubsemiring
variable [NonUnitalNonAssocSemiring S]
variable {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S] (s : NonUnitalSubsemiring R)
@[simp, norm_cast]
theorem coe_zero : ((0 : s) : R) = (0 : R) :=
rfl
@[simp, norm_cast]
theorem coe_add (x y : s) : ((x + y : s) : R) = (x + y : R) :=
rfl
@[simp, norm_cast]
theorem coe_mul (x y : s) : ((x * y : s) : R) = (x * y : R) :=
rfl
/-! Note: currently, there are no ordered versions of non-unital rings. -/
@[simp high]
theorem mem_toSubsemigroup {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.toSubsemigroup ↔ x ∈ s :=
Iff.rfl
@[simp high]
theorem coe_toSubsemigroup (s : NonUnitalSubsemiring R) : (s.toSubsemigroup : Set R) = s :=
rfl
@[simp]
theorem mem_toAddSubmonoid {s : NonUnitalSubsemiring R} {x : R} : x ∈ s.toAddSubmonoid ↔ x ∈ s :=
Iff.rfl
@[simp]
theorem coe_toAddSubmonoid (s : NonUnitalSubsemiring R) : (s.toAddSubmonoid : Set R) = s :=
rfl
/-- The non-unital subsemiring `R` of the non-unital semiring `R`. -/
instance : Top (NonUnitalSubsemiring R) :=
⟨{ (⊤ : Subsemigroup R), (⊤ : AddSubmonoid R) with }⟩
@[simp]
theorem mem_top (x : R) : x ∈ (⊤ : NonUnitalSubsemiring R) :=
Set.mem_univ x
@[simp]
theorem coe_top : ((⊤ : NonUnitalSubsemiring R) : Set R) = Set.univ :=
rfl
end NonUnitalSubsemiring
namespace NonUnitalRingHom
open NonUnitalSubsemiring
variable [NonUnitalNonAssocSemiring S]
variable {F : Type*} [FunLike F R S] [NonUnitalRingHomClass F R S]
variable (f : F)
end NonUnitalRingHom
namespace NonUnitalSubsemiring
-- should we define this as the range of the zero homomorphism?
instance : Bot (NonUnitalSubsemiring R) :=
⟨{ carrier := {0}
add_mem' := fun _ _ => by simp_all
zero_mem' := Set.mem_singleton 0
mul_mem' := fun _ _ => by simp_all }⟩
instance : Inhabited (NonUnitalSubsemiring R) :=
⟨⊥⟩
theorem coe_bot : ((⊥ : NonUnitalSubsemiring R) : Set R) = {0} :=
rfl
theorem mem_bot {x : R} : x ∈ (⊥ : NonUnitalSubsemiring R) ↔ x = 0 :=
Set.mem_singleton_iff
/-- The inf of two non-unital subsemirings is their intersection. -/
instance : Min (NonUnitalSubsemiring R) :=
⟨fun s t =>
{ s.toSubsemigroup ⊓ t.toSubsemigroup, s.toAddSubmonoid ⊓ t.toAddSubmonoid with
carrier := s ∩ t }⟩
@[simp]
theorem coe_inf (p p' : NonUnitalSubsemiring R) :
((p ⊓ p' : NonUnitalSubsemiring R) : Set R) = (p : Set R) ∩ p' :=
rfl
@[simp]
theorem mem_inf {p p' : NonUnitalSubsemiring R} {x : R} : x ∈ p ⊓ p' ↔ x ∈ p ∧ x ∈ p' :=
Iff.rfl
end NonUnitalSubsemiring
namespace NonUnitalRingHom
variable {F : Type*} [FunLike F R S]
variable [NonUnitalNonAssocSemiring S]
[NonUnitalRingHomClass F R S]
{S' : Type*} [SetLike S' S] [NonUnitalSubsemiringClass S' S]
{s : NonUnitalSubsemiring R}
open NonUnitalSubsemiringClass NonUnitalSubsemiring
/-- Restriction of a non-unital ring homomorphism to a non-unital subsemiring of the codomain. -/
def codRestrict (f : F) (s : S') (h : ∀ x, f x ∈ s) : R →ₙ+* s where
toFun n := ⟨f n, h n⟩
map_mul' x y := Subtype.eq (map_mul f x y)
map_add' x y := Subtype.eq (map_add f x y)
map_zero' := Subtype.eq (map_zero f)
/-- The non-unital subsemiring of elements `x : R` such that `f x = g x` -/
def eqSlocus (f g : F) : NonUnitalSubsemiring R :=
{ (f : R →ₙ* S).eqLocus (g : R →ₙ* S), (f : R →+ S).eqLocusM g with
carrier := { x | f x = g x } }
end NonUnitalRingHom
namespace NonUnitalSubsemiring
open NonUnitalRingHom NonUnitalSubsemiringClass
/-- The non-unital ring homomorphism associated to an inclusion of
non-unital subsemirings. -/
def inclusion {S T : NonUnitalSubsemiring R} (h : S ≤ T) : S →ₙ+* T :=
codRestrict (subtype S) _ fun x => h x.2
end NonUnitalSubsemiring |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Substitution.lean | import Mathlib.RingTheory.MvPowerSeries.Evaluation
import Mathlib.RingTheory.MvPowerSeries.LinearTopology
import Mathlib.RingTheory.Nilpotent.Basic
import Mathlib.Topology.UniformSpace.DiscreteUniformity
/-! # Substitutions in multivariate power series
Here we define the substitution of power series into other power series.
We follow [Bourbaki, Algebra II, chap. 4, §4, n° 3][bourbaki1981]
who present substitution of power series as an application of evaluation.
For an `R`-algebra `S`, `f : MvPowerSeries σ R` and `a : σ → MvPowerSeries τ S`,
`MvPowerSeries.subst a f` is the substitution of `X s` by `a s` in `f`.
It is only well defined under one of the two following conditions:
* `f` is a polynomial, in which case it is the classical evaluation;
* or the condition `MvPowerSeries.HasSubst a` holds, which means:
- For every `s`, the constant coefficient of `a s` is nilpotent;
- For every `d : σ →₀ ℕ`, all but finitely many of the coefficients
`(a s).coeff d` vanish.
In the other cases, it is defined as 0 (dummy value).
When `HasSubst a`, `MvPowerSeries.subst a` gives rise to an algebra homomorphism
`MvPowerSeries.substAlgHom ha : MvPowerSeries σ R →ₐ[R] MvPowerSeries τ S`.
We also define `MvPowerSeries.rescale` which rescales a multivariate
power series `f : MvPowerSeries σ R` by a map `a : σ → R`
and show its relation with substitution (under `CommRing R`).
To stay in line with `PowerSeries.rescale`, this is defined by hand
for commutative *semirings*.
## Implementation note
Evaluation of a power series at adequate elements has been defined
in `Mathlib/RingTheory/MvPowerSeries/Evaluation.lean`.
The goal here is to check the relevant hypotheses:
* The ring of coefficients is endowed the discrete topology.
* The main condition rewrites as having nilpotent constant coefficient
* Multivariate power series have a linear topology
The function `MvPowerSeries.subst` is defined using an explicit
invocation of the discrete uniformity (`⊥`).
If users need to enter the API, they can use `MvPowerSeries.subst_eq_eval₂`
and similar lemmas that hold for whatever uniformity on the space as soon
as it is discrete.
## TODO
* `MvPowerSeries.IsNilpotent_subst` asserts that the constant coefficient
of a legit substitution is nilpotent; prove that the converse holds when
the kernel of `algebraMap R S` is a nil ideal.
-/
namespace MvPowerSeries
variable {σ : Type*}
{A : Type*} [CommSemiring A]
{R : Type*} [CommRing R] [Algebra A R]
{τ : Type*}
{S : Type*} [CommRing S] [Algebra A S] [Algebra R S] [IsScalarTower A R S]
open WithPiTopology
attribute [local instance] DiscreteTopology.instContinuousSMul
/-- Families of power series which can be substituted -/
@[mk_iff hasSubst_def]
structure HasSubst (a : σ → MvPowerSeries τ S) : Prop where
const_coeff s : IsNilpotent (constantCoeff (a s))
coeff_zero d : {s | (a s).coeff d ≠ 0}.Finite
variable {a : σ → MvPowerSeries τ S}
lemma coeff_zero_iff [TopologicalSpace S] [DiscreteTopology S] :
Filter.Tendsto a Filter.cofinite (nhds 0) ↔
∀ d : τ →₀ ℕ, {s | (a s).coeff d ≠ 0}.Finite := by
simp [tendsto_iff_coeff_tendsto, coeff_zero, nhds_discrete]
/-- A multivariate power series can be substituted if and only if
it can be evaluated when the topology on the coefficients ring is the discrete topology. -/
lemma hasSubst_iff_hasEval_of_discreteTopology [TopologicalSpace S] [DiscreteTopology S] :
HasSubst a ↔ HasEval a := by
simp_rw [hasSubst_def, hasEval_def, coeff_zero_iff,
isTopologicallyNilpotent_iff_constantCoeff_isNilpotent]
theorem HasSubst.hasEval [TopologicalSpace S] (ha : HasSubst a) :
HasEval a := HasEval.mono (instTopologicalSpace_mono τ bot_le) <|
(@hasSubst_iff_hasEval_of_discreteTopology σ τ _ _ a ⊥ (@DiscreteTopology.mk S ⊥ rfl)).mp ha
theorem HasSubst.zero : HasSubst (fun (_ : σ) ↦ (0 : MvPowerSeries τ S)) := by
letI : UniformSpace S := ⊥
simpa [hasSubst_iff_hasEval_of_discreteTopology] using HasEval.zero
theorem HasSubst.add {a b : σ → MvPowerSeries τ S} (ha : HasSubst a) (hb : HasSubst b) :
HasSubst (a + b) := by
letI : UniformSpace S := ⊥
rw [hasSubst_iff_hasEval_of_discreteTopology] at ha hb ⊢
exact ha.add hb
theorem HasSubst.mul_left (b : σ → MvPowerSeries τ S)
{a : σ → MvPowerSeries τ S} (ha : HasSubst a) :
HasSubst (b * a) := by
letI : UniformSpace S := ⊥
rw [hasSubst_iff_hasEval_of_discreteTopology] at ha ⊢
exact ha.mul_left b
theorem HasSubst.mul_right (b : σ → MvPowerSeries τ S)
{a : σ → MvPowerSeries τ S} (ha : HasSubst a) :
HasSubst (a * b) :=
mul_comm a b ▸ ha.mul_left b
theorem HasSubst.smul (r : MvPowerSeries τ S) {a : σ → MvPowerSeries τ S} (ha : HasSubst a) :
HasSubst (r • a) := ha.mul_left _
protected theorem HasSubst.X : HasSubst (fun (s : σ) ↦ (X s : MvPowerSeries σ S)) := by
letI : UniformSpace S := ⊥
simpa [hasSubst_iff_hasEval_of_discreteTopology] using HasEval.X
theorem HasSubst.smul_X (a : σ → R) :
HasSubst (a • X : σ → MvPowerSeries σ R) := by
convert HasSubst.X.mul_left (fun s ↦ algebraMap R (MvPowerSeries σ R) (a s))
simp [funext_iff, algebra_compatible_smul (MvPowerSeries σ R)]
/-- Families of `MvPowerSeries` that can be substituted, as an `Ideal` -/
noncomputable def hasSubstIdeal : Ideal (σ → MvPowerSeries τ S) :=
{ carrier := setOf HasSubst
add_mem' := HasSubst.add
zero_mem' := HasSubst.zero
smul_mem' := HasSubst.mul_left }
/-- If `σ` is finite, then the nilpotent condition is enough for `HasSubst` -/
theorem hasSubst_of_constantCoeff_nilpotent [Finite σ]
{a : σ → MvPowerSeries τ S} (ha : ∀ s, IsNilpotent (constantCoeff (a s))) :
HasSubst a where
const_coeff := ha
coeff_zero _ := Set.toFinite _
/-- If `σ` is finite, then having zero constant coefficient is enough for `HasSubst` -/
theorem hasSubst_of_constantCoeff_zero [Finite σ]
{a : σ → MvPowerSeries τ S} (ha : ∀ s, constantCoeff (a s) = 0) :
HasSubst a :=
hasSubst_of_constantCoeff_nilpotent (fun s ↦ by simp only [ha s, IsNilpotent.zero])
/-- Substitution of power series into a power series
It coincides with evaluation when `f` is a polynomial, or under `HasSubst a`.
Otherwise, it is given the dummy value `0`. -/
noncomputable def subst (a : σ → MvPowerSeries τ S) (f : MvPowerSeries σ R) :
MvPowerSeries τ S :=
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
eval₂ (algebraMap _ _) a f
theorem subst_eq_eval₂
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S] :
(subst : (σ → MvPowerSeries τ S) → (MvPowerSeries σ R) → _) = eval₂ (algebraMap _ _) := by
ext; simp [subst, DiscreteUniformity.eq_bot]
theorem subst_coe (p : MvPolynomial σ R) :
subst (R := R) a p = MvPolynomial.aeval a p := by
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
rw [subst_eq_eval₂, eval₂_coe, MvPolynomial.aeval_def]
variable {a : σ → MvPowerSeries τ S}
/-- For `HasSubst a`, `MvPowerSeries.subst` is an algebra morphism. -/
noncomputable def substAlgHom (ha : HasSubst a) :
MvPowerSeries σ R →ₐ[R] MvPowerSeries τ S :=
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
MvPowerSeries.aeval ha.hasEval
/-- Rewrite `MvPowerSeries.substAlgHom` as `MvPowerSeries.aeval`.
Its use is discouraged because it introduces a topology and might lead
into awkward comparisons. -/
theorem substAlgHom_eq_aeval
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S]
(ha : HasSubst a) :
(substAlgHom ha : MvPowerSeries σ R → MvPowerSeries τ S) = MvPowerSeries.aeval ha.hasEval := by
simp only [substAlgHom, coe_aeval ha.hasEval]
convert coe_aeval (R := R) (hasSubst_iff_hasEval_of_discreteTopology.mp ha) <;>
exact DiscreteUniformity.eq_bot.symm
@[simp]
theorem coe_substAlgHom (ha : HasSubst a) :
⇑(substAlgHom ha) = subst (R := R) a := by
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
rw [substAlgHom_eq_aeval, coe_aeval ha.hasEval, subst_eq_eval₂]
theorem subst_self : subst (MvPowerSeries.X : σ → MvPowerSeries σ R) = id := by
rw [← coe_substAlgHom HasSubst.X]
letI : UniformSpace R := ⊥
ext1 f
simp only [substAlgHom_eq_aeval]
have := aeval_unique (ε := AlgHom.id R (MvPowerSeries σ R)) continuous_id
rw [DFunLike.ext_iff] at this
exact this f
@[simp]
theorem substAlgHom_apply (ha : HasSubst a) (f : MvPowerSeries σ R) :
substAlgHom ha f = subst a f := by
rw [coe_substAlgHom]
theorem subst_add (ha : HasSubst a) (f g : MvPowerSeries σ R) :
subst a (f + g) = subst a f + subst a g := by
simp only [← substAlgHom_apply ha, map_add]
theorem subst_mul (ha : HasSubst a) (f g : MvPowerSeries σ R) :
subst a (f * g) = subst a f * subst a g := by
simp only [← substAlgHom_apply ha, map_mul]
theorem subst_pow (ha : HasSubst a) (f : MvPowerSeries σ R) (n : ℕ) :
subst a (f ^ n) = (subst a f) ^ n := by
simp only [← substAlgHom_apply ha, map_pow]
theorem subst_smul (ha : HasSubst a) (r : A) (f : MvPowerSeries σ R) :
subst a (r • f) = r • (subst a f) := by
simp only [← substAlgHom_apply ha, AlgHom.map_smul_of_tower]
theorem substAlgHom_coe (ha : HasSubst a) (p : MvPolynomial σ R) :
substAlgHom (R := R) ha p = MvPolynomial.aeval a p := by
simp [substAlgHom]
theorem substAlgHom_X (ha : HasSubst a) (s : σ) :
substAlgHom (R := R) ha (X s) = a s := by
rw [← MvPolynomial.coe_X, substAlgHom_coe ha, MvPolynomial.aeval_X]
theorem substAlgHom_monomial (ha : HasSubst a) (e : σ →₀ ℕ) (r : R) :
substAlgHom ha (monomial e r) =
(algebraMap R (MvPowerSeries τ S) r) * (e.prod (fun s n ↦ (a s) ^ n)) := by
rw [← MvPolynomial.coe_monomial, substAlgHom_coe, MvPolynomial.aeval_monomial]
@[simp]
theorem subst_X (ha : HasSubst a) (s : σ) :
subst (R := R) a (X s) = a s := by
rw [← coe_substAlgHom ha, substAlgHom_X]
theorem subst_monomial (ha : HasSubst a) (e : σ →₀ ℕ) (r : R) :
subst a (monomial e r) =
(algebraMap R (MvPowerSeries τ S) r) * (e.prod (fun s n ↦ (a s) ^ n)) := by
rw [← coe_substAlgHom ha, substAlgHom_monomial]
theorem continuous_subst (ha : HasSubst a)
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S] :
Continuous (subst a : MvPowerSeries σ R → MvPowerSeries τ S) := by
rw [subst_eq_eval₂]
exact continuous_eval₂ (continuous_algebraMap _ _) ha.hasEval
theorem coeff_subst_finite (ha : HasSubst a) (f : MvPowerSeries σ R) (e : τ →₀ ℕ) :
Set.Finite (fun d ↦ coeff d f • (coeff e (d.prod fun s e => (a s) ^ e))).support :=
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
Summable.finite_support_of_discreteTopology _
((hasSum_aeval ha.hasEval f).map (coeff e) (continuous_coeff S e)).summable
theorem coeff_subst (ha : HasSubst a) (f : MvPowerSeries σ R) (e : τ →₀ ℕ) :
coeff e (subst a f) =
finsum (fun d ↦ coeff d f • (coeff e (d.prod fun s e => (a s) ^ e))) := by
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
have := ((hasSum_aeval ha.hasEval f).map (coeff e) (continuous_coeff S e))
simp [← coe_substAlgHom ha, substAlgHom, ← this.tsum_eq,
tsum_eq_finsum (coeff_subst_finite ha f e)]
theorem constantCoeff_subst (ha : HasSubst a) (f : MvPowerSeries σ R) :
constantCoeff (subst a f) =
finsum (fun d ↦ coeff d f • (constantCoeff (d.prod fun s e => (a s) ^ e))) := by
simp only [← coeff_zero_eq_constantCoeff_apply, coeff_subst ha f 0]
theorem map_algebraMap_eq_subst_X (f : MvPowerSeries σ R) :
map (algebraMap R S) f = subst X f := by
ext e
rw [coeff_map, coeff_subst HasSubst.X f e, finsum_eq_single _ e]
· rw [← MvPowerSeries.monomial_one_eq, coeff_monomial_same,
algebra_compatible_smul S, smul_eq_mul, mul_one]
· intro d hd
rw [← MvPowerSeries.monomial_one_eq, coeff_monomial_ne hd.symm, smul_zero]
variable
{T : Type*} [CommRing T]
[UniformSpace T] [T2Space T] [CompleteSpace T]
[IsUniformAddGroup T] [IsTopologicalRing T] [IsLinearTopology T T] [Algebra R T]
{ε : MvPowerSeries τ S →ₐ[R] T}
theorem comp_substAlgHom
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S]
(ha : HasSubst a) (hε : Continuous ε) :
ε.comp (substAlgHom ha) = aeval (ha.hasEval.map hε) := by
ext f
simp only [AlgHom.coe_comp, substAlgHom_eq_aeval ha]
exact DFunLike.congr_fun (comp_aeval ha.hasEval hε) f
theorem comp_subst [UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S]
(ha : HasSubst a) (hε : Continuous ε) :
ε ∘ (subst a) = aeval (R := R) (ha.hasEval.map hε) := by
rw [← comp_substAlgHom ha hε, AlgHom.coe_comp, coe_substAlgHom]
theorem comp_subst_apply
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S]
(ha : HasSubst a) (hε : Continuous ε) (f : MvPowerSeries σ R) :
ε (subst a f) = aeval (R := R) (ha.hasEval.map hε) f :=
congr_fun (comp_subst ha hε) f
variable [Algebra S T] [IsScalarTower R S T]
theorem eval₂_subst
[UniformSpace R] [DiscreteUniformity R] [UniformSpace S] [DiscreteUniformity S]
(ha : HasSubst a) {b : τ → T} (hb : HasEval b) (f : MvPowerSeries σ R) :
eval₂ (algebraMap S T) b (subst a f) =
eval₂ (algebraMap R T) (fun s ↦ eval₂ (algebraMap S T) b (a s)) f := by
let ε : MvPowerSeries τ S →ₐ[R] T := (aeval hb).restrictScalars R
have hε : Continuous ε := continuous_aeval hb
simpa only [AlgHom.coe_restrictScalars', AlgHom.toRingHom_eq_coe,
AlgHom.coe_restrictScalars, RingHom.coe_coe, ε, coe_aeval]
using comp_subst_apply ha hε f
variable {υ : Type*}
{T : Type*} [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
{b : τ → MvPowerSeries υ T}
theorem IsNilpotent_subst (ha : HasSubst a)
{f : MvPowerSeries σ R} (hf : IsNilpotent (constantCoeff f)) :
IsNilpotent (constantCoeff (substAlgHom ha f)) := by
classical
rw [coe_substAlgHom, constantCoeff_subst ha]
apply isNilpotent_finsum
intro d
by_cases hd : d = 0
· rw [← algebraMap_smul S, smul_eq_mul, mul_comm, ← smul_eq_mul, hd]
apply IsNilpotent.smul
simpa using IsNilpotent.map hf (algebraMap R S)
· apply IsNilpotent.smul
rw [← ne_eq, Finsupp.ne_iff] at hd
obtain ⟨t, hs⟩ := hd
rw [← Finsupp.prod_filter_mul_prod_filter_not (fun i ↦ i = t), map_mul,
mul_comm, ← smul_eq_mul]
apply IsNilpotent.smul
rw [Finsupp.prod_eq_single t]
· simpa using IsNilpotent.pow_of_pos (ha.const_coeff t) hs
· intro t' htt' ht'
simp [ht'] at htt'
· exact fun _ ↦ by rw [pow_zero]
theorem HasSubst.comp (ha : HasSubst a) (hb : HasSubst b) :
HasSubst (fun s ↦ substAlgHom hb (a s)) where
const_coeff s := IsNilpotent_subst hb (ha.const_coeff s)
coeff_zero := by
letI : UniformSpace S := ⊥
letI : UniformSpace T := ⊥
rw [← coeff_zero_iff]
apply Filter.Tendsto.comp _ (ha.hasEval.tendsto_zero)
simpa [← map_zero (substAlgHom (R := S) hb)] using (continuous_subst hb).continuousAt
theorem substAlgHom_comp_substAlgHom (ha : HasSubst a) (hb : HasSubst b) :
((substAlgHom hb).restrictScalars R).comp (substAlgHom ha) = substAlgHom (ha.comp hb) := by
letI : UniformSpace R := ⊥
letI : UniformSpace S := ⊥
letI : UniformSpace T := ⊥
apply comp_aeval (R := R) (ε := (substAlgHom hb).restrictScalars R) ha.hasEval
simpa [AlgHom.coe_restrictScalars'] using continuous_subst (R := S) hb
theorem substAlgHom_comp_substAlgHom_apply (ha : HasSubst a) (hb : HasSubst b)
(f : MvPowerSeries σ R) :
(substAlgHom hb) (substAlgHom ha f) = substAlgHom (ha.comp hb) f :=
DFunLike.congr_fun (substAlgHom_comp_substAlgHom ha hb) f
theorem subst_comp_subst (ha : HasSubst a) (hb : HasSubst b) :
(subst b) ∘ (subst a) = subst (R := R) (fun s ↦ subst b (a s)) := by
simpa [funext_iff, DFunLike.ext_iff] using substAlgHom_comp_substAlgHom (R := R) ha hb
theorem subst_comp_subst_apply (ha : HasSubst a) (hb : HasSubst b) (f : MvPowerSeries σ R) :
subst b (subst a f) = subst (fun s ↦ subst b (a s)) f :=
congr_fun (subst_comp_subst (R := R) ha hb) f
section rescale
section CommSemiring
variable {R : Type*} [CommSemiring R]
-- To match the `PowerSeries.rescale` API which holds for `CommSemiring`,
-- we redo it by hand.
/-- The ring homomorphism taking a multivariate power series `f(X)` to `f(aX)`. -/
noncomputable def rescale (a : σ → R) : MvPowerSeries σ R →+* MvPowerSeries σ R where
toFun f := fun n ↦ (n.prod fun s m ↦ a s ^ m) * f.coeff n
map_zero' := by
ext
simp [map_zero, coeff_apply]
map_one' := by
ext1 n
classical
simp only [coeff_one, mul_ite, mul_one, mul_zero]
split_ifs with h
· simp [h, coeff_apply]
· simp only [coeff_apply, ite_eq_right_iff]
exact fun a_1 ↦ False.elim (h a_1)
map_add' := by
intros
ext
exact mul_add _ _ _
map_mul' f g := by
ext n
classical
rw [coeff_apply, coeff_mul, coeff_mul, Finset.mul_sum]
apply Finset.sum_congr rfl
intro x hx
simp only [Finset.mem_antidiagonal] at hx
rw [← hx]
simp only [coeff_apply]
rw [Finsupp.prod_of_support_subset _ Finsupp.support_add,
Finsupp.prod_of_support_subset x.1 Finset.subset_union_left,
Finsupp.prod_of_support_subset x.2 Finset.subset_union_right]
· simp only [← mul_assoc]
congr 1
rw [mul_assoc, mul_comm (f x.1), ← mul_assoc]
congr 1
rw [← Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
simp [pow_add]
all_goals {simp}
@[simp]
theorem coeff_rescale (f : MvPowerSeries σ R) (a : σ → R) (n : σ →₀ ℕ) :
coeff n (rescale a f) = (n.prod fun s m ↦ a s ^ m) * f.coeff n := by
simp [rescale, coeff_apply]
@[simp]
theorem rescale_zero :
(rescale 0 : MvPowerSeries σ R →+* MvPowerSeries σ R) = C.comp constantCoeff := by
classical
ext x n
simp [Function.comp_apply, RingHom.coe_comp, rescale, RingHom.coe_mk, coeff_C]
split_ifs with h
· simp [h, coeff_apply, ← @coeff_zero_eq_constantCoeff_apply, coeff_apply]
· simp only [coeff_apply]
convert zero_mul _
simp only [DFunLike.ext_iff, not_forall, Finsupp.coe_zero, Pi.zero_apply] at h
obtain ⟨s, h⟩ := h
simp only [Finsupp.prod]
apply Finset.prod_eq_zero (i := s) _ (zero_pow h)
simpa using h
theorem rescale_zero_apply (f : MvPowerSeries σ R) :
rescale 0 f = C (constantCoeff f) := by simp
@[simp]
theorem rescale_one : rescale 1 = RingHom.id (MvPowerSeries σ R) := by
ext f n
simp [coeff_rescale, Finsupp.prod]
theorem rescale_rescale (f : MvPowerSeries σ R) (a b : σ → R) :
rescale b (rescale a f) = rescale (a * b) f := by
ext n
simp [← mul_assoc, mul_pow, mul_comm]
theorem rescale_mul (a b : σ → R) : rescale (a * b) = (rescale b).comp (rescale a) := by
ext
simp [← rescale_rescale]
/-- Rescaling a homogeneous power series -/
lemma rescale_homogeneous_eq_smul {n : ℕ} {r : R} {f : MvPowerSeries σ R}
(hf : ∀ d ∈ f.support, d.degree = n) :
MvPowerSeries.rescale (Function.const σ r) f = r ^ n • f := by
ext e
simp only [MvPowerSeries.coeff_rescale, map_smul, Finsupp.prod, Function.const_apply,
Finset.prod_pow_eq_pow_sum, smul_eq_mul]
by_cases he : e ∈ f.support
· rw [← hf e he, Finsupp.degree]
· simp only [Function.mem_support, ne_eq, not_not] at he
simp [he, mul_zero, coeff_apply]
/-- Rescale a multivariate power series, as a `MonoidHom` in the scaling parameters. -/
noncomputable def rescaleMonoidHom :
(σ → R) →* MvPowerSeries σ R →+* MvPowerSeries σ R where
toFun := rescale
map_one' := rescale_one
map_mul' a b := by ext; simp [mul_comm, rescale_rescale]
end CommSemiring
section CommRing
theorem rescale_eq_subst (a : σ → R) (f : MvPowerSeries σ R) :
rescale a f = subst (a • X) f := by
classical
ext n
rw [coeff_rescale]
rw [coeff_subst (HasSubst.smul_X a),
finsum_eq_sum _ (coeff_subst_finite (HasSubst.smul_X a) f n)]
simp only [Pi.smul_apply', smul_eq_mul]
rw [Finset.sum_eq_single n _ _]
· simp [mul_comm, ← monomial_eq]
· intro b hb hbn
rw [← monomial_eq, coeff_monomial, if_neg (Ne.symm hbn), mul_zero]
· intro hn
simpa using hn
/-- Rescale a multivariate power series, as an `AlgHom` in the scaling parameters,
by multiplying each variable `x` by the value `a x`. -/
noncomputable def rescaleAlgHom (a : σ → R) :
MvPowerSeries σ R →ₐ[R] MvPowerSeries σ R :=
substAlgHom (HasSubst.smul_X a)
theorem rescaleAlgHom_apply (a : σ → R) (f : MvPowerSeries σ R) :
rescaleAlgHom a f = rescale a f := by
simp [rescaleAlgHom, rescale_eq_subst]
theorem rescaleAlgHom_mul (a b : σ → R) :
rescaleAlgHom (a * b) = (rescaleAlgHom b).comp (rescaleAlgHom a) := by
ext1 f
simp [rescaleAlgHom_apply, rescale_rescale]
theorem rescaleAlgHom_one :
rescaleAlgHom 1 = AlgHom.id R (MvPowerSeries σ R) := by
ext1 f
simp [rescaleAlgHom, subst_self]
end CommRing
end rescale
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Inverse.lean | import Mathlib.Algebra.Group.Units.Basic
import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.RingTheory.MvPowerSeries.NoZeroDivisors
import Mathlib.RingTheory.LocalRing.Basic
/-!
# Formal (multivariate) power series - Inverses
This file defines multivariate formal power series and develops the basic
properties of these objects, when it comes about multiplicative inverses.
For `φ : MvPowerSeries σ R` and `u : Rˣ` is the constant coefficient of `φ`,
`MvPowerSeries.invOfUnit φ u` is a formal power series such,
and `MvPowerSeries.mul_invOfUnit` proves that `φ * invOfUnit φ u = 1`.
The construction of the power series `invOfUnit` is done by writing that
relation and solving and for its coefficients by induction.
Over a field, all power series `φ` have an “inverse” `MvPowerSeries.inv φ`,
which is `0` if and only if the constant coefficient of `φ` is zero
(by `MvPowerSeries.inv_eq_zero`),
and `MvPowerSeries.mul_inv_cancel` asserts the equality `φ * φ⁻¹ = 1` when
the constant coefficient of `φ` is nonzero.
Instances are defined:
* Formal power series over a local ring form a local ring.
* The morphism `MvPowerSeries.map σ f : MvPowerSeries σ A →* MvPowerSeries σ B`
induced by a local morphism `f : A →+* B` (`IsLocalHom f`)
of commutative rings is a *local* morphism.
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
namespace MvPowerSeries
open Finsupp
variable {σ R : Type*}
section Ring
variable [Ring R]
/-
The inverse of a multivariate formal power series is defined by
well-founded recursion on the coefficients of the inverse.
-/
/-- Auxiliary definition that unifies
the totalised inverse formal power series `(_)⁻¹` and
the inverse formal power series that depends on
an inverse of the constant coefficient `invOfUnit`. -/
protected noncomputable def inv.aux (a : R) (φ : MvPowerSeries σ R) : MvPowerSeries σ R
| n =>
letI := Classical.decEq σ
if n = 0 then a
else
-a *
∑ x ∈ antidiagonal n, if _ : x.2 < n then coeff x.1 φ * inv.aux a φ x.2 else 0
termination_by n => n
theorem coeff_inv_aux [DecidableEq σ] (n : σ →₀ ℕ) (a : R) (φ : MvPowerSeries σ R) :
coeff n (inv.aux a φ) =
if n = 0 then a
else
-a *
∑ x ∈ antidiagonal n, if x.2 < n then coeff x.1 φ * coeff x.2 (inv.aux a φ) else 0 :=
show inv.aux a φ n = _ by
cases Subsingleton.elim ‹DecidableEq σ› (Classical.decEq σ)
rw [inv.aux]
rfl
/-- A multivariate formal power series is invertible if the constant coefficient is invertible. -/
def invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) : MvPowerSeries σ R :=
inv.aux (↑u⁻¹) φ
theorem coeff_invOfUnit [DecidableEq σ] (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) (u : Rˣ) :
coeff n (invOfUnit φ u) =
if n = 0 then ↑u⁻¹
else
-↑u⁻¹ *
∑ x ∈ antidiagonal n,
if x.2 < n then coeff x.1 φ * coeff x.2 (invOfUnit φ u) else 0 := by
convert coeff_inv_aux n (↑u⁻¹) φ
@[simp]
theorem constantCoeff_invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) :
constantCoeff (invOfUnit φ u) = ↑u⁻¹ := by
classical
rw [← coeff_zero_eq_constantCoeff_apply, coeff_invOfUnit, if_pos rfl]
@[simp]
theorem mul_invOfUnit (φ : MvPowerSeries σ R) (u : Rˣ) (h : constantCoeff φ = u) :
φ * invOfUnit φ u = 1 :=
ext fun n =>
letI := Classical.decEq (σ →₀ ℕ)
if H : n = 0 then by
rw [H]
simp [h]
else by
classical
have : ((0 : σ →₀ ℕ), n) ∈ antidiagonal n := by rw [mem_antidiagonal, zero_add]
rw [coeff_one, if_neg H, coeff_mul, ← Finset.insert_erase this,
Finset.sum_insert (Finset.notMem_erase _ _), coeff_zero_eq_constantCoeff_apply, h,
coeff_invOfUnit, if_neg H, neg_mul, mul_neg, Units.mul_inv_cancel_left, ←
Finset.insert_erase this, Finset.sum_insert (Finset.notMem_erase _ _),
Finset.insert_erase this, if_neg (not_lt_of_ge <| le_rfl), zero_add, add_comm, ←
sub_eq_add_neg, sub_eq_zero, Finset.sum_congr rfl]
rintro ⟨i, j⟩ hij
rw [Finset.mem_erase, mem_antidiagonal] at hij
obtain ⟨h₁, rfl⟩ := hij
rw [if_pos]
refine lt_add_of_pos_left _ <| pos_iff_ne_zero.2 ?_
rintro rfl
simp at h₁
-- TODO : can one prove equivalence?
@[simp]
theorem invOfUnit_mul (φ : MvPowerSeries σ R) (u : Rˣ) (h : constantCoeff φ = u) :
invOfUnit φ u * φ = 1 := by
rw [← mul_cancel_right_mem_nonZeroDivisors (r := φ.invOfUnit u), mul_assoc, one_mul,
mul_invOfUnit _ _ h, mul_one]
apply mem_nonZeroDivisors_of_constantCoeff
simp only [constantCoeff_invOfUnit, IsUnit.mem_nonZeroDivisors (Units.isUnit u⁻¹)]
theorem isUnit_iff_constantCoeff {φ : MvPowerSeries σ R} :
IsUnit φ ↔ IsUnit (constantCoeff φ) := by
constructor
· exact IsUnit.map _
· intro ⟨u, hu⟩
exact ⟨⟨_, φ.invOfUnit u, mul_invOfUnit φ u hu.symm, invOfUnit_mul φ u hu.symm⟩, rfl⟩
end Ring
section CommRing
variable [CommRing R]
/-- Multivariate formal power series over a local ring form a local ring. -/
instance [IsLocalRing R] : IsLocalRing (MvPowerSeries σ R) :=
IsLocalRing.of_isUnit_or_isUnit_one_sub_self <| by
intro φ
obtain ⟨u, h⟩ | ⟨u, h⟩ := IsLocalRing.isUnit_or_isUnit_one_sub_self (constantCoeff φ) <;>
[left; right] <;>
· refine .of_mul_eq_one _ (mul_invOfUnit _ u ?_)
simpa using h.symm
-- TODO(jmc): once adic topology lands, show that this is complete
end CommRing
section IsLocalRing
variable {S : Type*} [CommRing R] [CommRing S] (f : R →+* S) [IsLocalHom f]
-- Thanks to the linter for informing us that this instance does
-- not actually need R and S to be local rings!
/-- The map between multivariate formal power series over the same indexing set
induced by a local ring hom `A → B` is local -/
@[instance]
theorem map.isLocalHom : IsLocalHom (map (σ := σ) f) :=
⟨by
rintro φ ⟨ψ, h⟩
replace h := congr_arg constantCoeff h
rw [constantCoeff_map] at h
have : IsUnit (constantCoeff ψ.val) := isUnit_constantCoeff _ ψ.isUnit
rw [h] at this
rcases isUnit_of_map_unit f _ this with ⟨c, hc⟩
exact .of_mul_eq_one (invOfUnit φ c) (mul_invOfUnit φ c hc.symm)⟩
end IsLocalRing
section Field
open MvPowerSeries
variable {k : Type*} [Field k]
/-- The inverse `1/f` of a multivariable power series `f` over a field -/
protected def inv (φ : MvPowerSeries σ k) : MvPowerSeries σ k :=
inv.aux (constantCoeff φ)⁻¹ φ
instance : Inv (MvPowerSeries σ k) :=
⟨MvPowerSeries.inv⟩
theorem coeff_inv [DecidableEq σ] (n : σ →₀ ℕ) (φ : MvPowerSeries σ k) :
coeff n φ⁻¹ =
if n = 0 then (constantCoeff φ)⁻¹
else
-(constantCoeff φ)⁻¹ *
∑ x ∈ antidiagonal n, if x.2 < n then coeff x.1 φ * coeff x.2 φ⁻¹ else 0 :=
coeff_inv_aux n _ φ
@[simp]
theorem constantCoeff_inv (φ : MvPowerSeries σ k) :
constantCoeff φ⁻¹ = (constantCoeff φ)⁻¹ := by
classical
rw [← coeff_zero_eq_constantCoeff_apply, coeff_inv, if_pos rfl]
theorem inv_eq_zero {φ : MvPowerSeries σ k} : φ⁻¹ = 0 ↔ constantCoeff φ = 0 :=
⟨fun h => by simpa using congr_arg constantCoeff h, fun h =>
ext fun n => by
classical
rw [coeff_inv]
split_ifs <;>
simp only [h, map_zero, zero_mul, inv_zero, neg_zero]⟩
@[simp]
theorem zero_inv : (0 : MvPowerSeries σ k)⁻¹ = 0 := by
rw [inv_eq_zero, constantCoeff_zero]
@[simp]
theorem invOfUnit_eq (φ : MvPowerSeries σ k) (h : constantCoeff φ ≠ 0) :
invOfUnit φ (Units.mk0 _ h) = φ⁻¹ :=
rfl
@[simp]
theorem invOfUnit_eq' (φ : MvPowerSeries σ k) (u : Units k) (h : constantCoeff φ = u) :
invOfUnit φ u = φ⁻¹ := by
rw [← invOfUnit_eq φ (h.symm ▸ u.ne_zero)]
apply congrArg (invOfUnit φ)
rw [Units.ext_iff]
exact h.symm
@[simp]
protected theorem mul_inv_cancel (φ : MvPowerSeries σ k) (h : constantCoeff φ ≠ 0) :
φ * φ⁻¹ = 1 := by rw [← invOfUnit_eq φ h, mul_invOfUnit φ (Units.mk0 _ h) rfl]
@[simp]
protected theorem inv_mul_cancel (φ : MvPowerSeries σ k) (h : constantCoeff φ ≠ 0) :
φ⁻¹ * φ = 1 := by rw [mul_comm, φ.mul_inv_cancel h]
protected theorem eq_mul_inv_iff_mul_eq {φ₁ φ₂ φ₃ : MvPowerSeries σ k}
(h : constantCoeff φ₃ ≠ 0) : φ₁ = φ₂ * φ₃⁻¹ ↔ φ₁ * φ₃ = φ₂ :=
⟨fun k => by simp [k, mul_assoc, MvPowerSeries.inv_mul_cancel _ h], fun k => by
simp [← k, mul_assoc, MvPowerSeries.mul_inv_cancel _ h]⟩
protected theorem eq_inv_iff_mul_eq_one {φ ψ : MvPowerSeries σ k} (h : constantCoeff ψ ≠ 0) :
φ = ψ⁻¹ ↔ φ * ψ = 1 := by rw [← MvPowerSeries.eq_mul_inv_iff_mul_eq h, one_mul]
protected theorem inv_eq_iff_mul_eq_one {φ ψ : MvPowerSeries σ k} (h : constantCoeff ψ ≠ 0) :
ψ⁻¹ = φ ↔ φ * ψ = 1 := by rw [eq_comm, MvPowerSeries.eq_inv_iff_mul_eq_one h]
@[simp]
protected theorem mul_inv_rev (φ ψ : MvPowerSeries σ k) :
(φ * ψ)⁻¹ = ψ⁻¹ * φ⁻¹ := by
by_cases h : constantCoeff (φ * ψ) = 0
· rw [inv_eq_zero.mpr h]
simp only [map_mul, mul_eq_zero] at h
-- we don't have `NoZeroDivisors (MvPowerSeries σ k)` yet,
rcases h with h | h <;> simp [inv_eq_zero.mpr h]
· rw [MvPowerSeries.inv_eq_iff_mul_eq_one h]
simp only [not_or, map_mul, mul_eq_zero] at h
rw [← mul_assoc, mul_assoc _⁻¹, MvPowerSeries.inv_mul_cancel _ h.left, mul_one,
MvPowerSeries.inv_mul_cancel _ h.right]
instance : InvOneClass (MvPowerSeries σ k) :=
{ inferInstanceAs (One (MvPowerSeries σ k)),
inferInstanceAs (Inv (MvPowerSeries σ k)) with
inv_one := by
rw [MvPowerSeries.inv_eq_iff_mul_eq_one, mul_one]
simp }
@[simp]
theorem C_inv (r : k) : (C (σ := σ) r)⁻¹ = C r⁻¹ := by
rcases eq_or_ne r 0 with (rfl | hr)
· simp
rw [MvPowerSeries.inv_eq_iff_mul_eq_one, ← map_mul, inv_mul_cancel₀ hr, map_one]
simpa using hr
@[simp]
theorem X_inv (s : σ) : (X s : MvPowerSeries σ k)⁻¹ = 0 := by
rw [inv_eq_zero, constantCoeff_X]
@[simp]
theorem smul_inv (r : k) (φ : MvPowerSeries σ k) : (r • φ)⁻¹ = r⁻¹ • φ⁻¹ := by
simp [smul_eq_C_mul, mul_comm]
end Field
end MvPowerSeries
end |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/PiTopology.lean | import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.RingTheory.MvPowerSeries.Order
import Mathlib.RingTheory.MvPowerSeries.Trunc
import Mathlib.RingTheory.Nilpotent.Defs
import Mathlib.Topology.Algebra.InfiniteSum.Constructions
import Mathlib.Topology.Algebra.Ring.Basic
import Mathlib.Topology.Instances.ENat
import Mathlib.Topology.UniformSpace.Pi
import Mathlib.Topology.Algebra.InfiniteSum.Ring
import Mathlib.Topology.Algebra.TopologicallyNilpotent
import Mathlib.Topology.Algebra.IsUniformGroup.Constructions
/-! # Product topology on multivariate power series
Let `R` be with `Semiring R` and `TopologicalSpace R`
In this file we define the topology on `MvPowerSeries σ R`
that corresponds to the simple convergence on its coefficients.
It is the coarsest topology for which all coefficient maps are continuous.
When `R` has `UniformSpace R`, we define the corresponding uniform structure.
This topology can be included by writing `open scoped MvPowerSeries.WithPiTopology`.
When the type of coefficients has the discrete topology, it corresponds to the topology defined by
[N. Bourbaki, *Algebra {II}*, Chapter 4, §4, n°2][bourbaki1981].
It is *not* the adic topology in general.
## Main results
- `MvPowerSeries.WithPiTopology.isTopologicallyNilpotent_of_constantCoeff_isNilpotent`,
`MvPowerSeries.WithPiTopology.isTopologicallyNilpotent_of_constantCoeff_zero`: if the constant
coefficient of `f` is nilpotent, or vanishes, then `f` is topologically nilpotent.
- `MvPowerSeries.WithPiTopology.isTopologicallyNilpotent_iff_constantCoeff_isNilpotent` :
assuming the base ring has the discrete topology, `f` is topologically nilpotent iff the constant
coefficient of `f` is nilpotent.
- `MvPowerSeries.WithPiTopology.hasSum_of_monomials_self` : viewed as an infinite sum, a power
series converges to itself.
TODO: add the similar result for the series of homogeneous components.
## Instances
- If `R` is a topological (semi)ring, then so is `MvPowerSeries σ R`.
- If the topology of `R` is T0 or T2, then so is that of `MvPowerSeries σ R`.
- If `R` is a `IsUniformAddGroup`, then so is `MvPowerSeries σ R`.
- If `R` is complete, then so is `MvPowerSeries σ R`.
## Implementation Notes
In `Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean`, we generalize the criterion for
topological nilpotency by proving that, if the base ring is equipped with a *linear* topology, then
a power series is topologically nilpotent if and only if its constant coefficient is.
This is lemma `MvPowerSeries.LinearTopology.isTopologicallyNilpotent_iff_constantCoeff`.
Mathematically, everything proven in this file follows from that general statement. However,
formalizing this yields a few (minor) annoyances:
- we would need to push the results in this file slightly lower in the import tree
(likely, in a new dedicated file);
- we would have to work in `CommRing`s rather than `CommSemiring`s (this probably does not
matter in any way though);
- because `isTopologicallyNilpotent_of_constantCoeff_isNilpotent` holds for *any* topology,
not necessarily discrete nor linear, the proof going through the general case involves
juggling a bit with the topologies.
Since the code duplication is rather minor (the interesting part of the proof is already extracted
as `MvPowerSeries.coeff_eq_zero_of_constantCoeff_nilpotent`), we just leave this as is for now.
But future contributors wishing to clean this up should feel free to give it a try!
-/
namespace MvPowerSeries
open Function Filter
open scoped Topology
variable {σ R : Type*}
namespace WithPiTopology
section Topology
variable [TopologicalSpace R]
variable (R) in
/-- The pointwise topology on `MvPowerSeries` -/
scoped instance : TopologicalSpace (MvPowerSeries σ R) :=
Pi.topologicalSpace
theorem instTopologicalSpace_mono (σ : Type*) {R : Type*} {t u : TopologicalSpace R} (htu : t ≤ u) :
@instTopologicalSpace σ R t ≤ @instTopologicalSpace σ R u := by
simp only [instTopologicalSpace, Pi.topologicalSpace, le_iInf_iff]
grw [htu]
exact iInf_le _
/-- `MvPowerSeries` on a `T0Space` form a `T0Space` -/
@[scoped instance]
theorem instT0Space [T0Space R] : T0Space (MvPowerSeries σ R) := Pi.instT0Space
/-- `MvPowerSeries` on a `T2Space` form a `T2Space` -/
@[scoped instance]
theorem instT2Space [T2Space R] : T2Space (MvPowerSeries σ R) := Pi.t2Space
variable (R) in
/-- `MvPowerSeries.coeff` is continuous. -/
@[fun_prop]
theorem continuous_coeff [Semiring R] (d : σ →₀ ℕ) :
Continuous (MvPowerSeries.coeff (R := R) d) :=
continuous_pi_iff.mp continuous_id d
variable (R) in
/-- `MvPowerSeries.constantCoeff` is continuous -/
theorem continuous_constantCoeff [Semiring R] : Continuous (constantCoeff (σ := σ) (R := R)) :=
continuous_coeff (R := R) 0
/-- A family of power series converges iff it converges coefficientwise -/
theorem tendsto_iff_coeff_tendsto [Semiring R] {ι : Type*}
(f : ι → MvPowerSeries σ R) (u : Filter ι) (g : MvPowerSeries σ R) :
Tendsto f u (nhds g) ↔
∀ d : σ →₀ ℕ, Tendsto (fun i => coeff d (f i)) u (nhds (coeff d g)) := by
rw [nhds_pi, tendsto_pi]
exact forall_congr' (fun d => Iff.rfl)
theorem tendsto_trunc'_atTop [DecidableEq σ] [CommSemiring R] (f : MvPowerSeries σ R) :
Tendsto (fun d ↦ (trunc' R d f : MvPowerSeries σ R)) atTop (𝓝 f) := by
rw [tendsto_iff_coeff_tendsto]
intro d
exact tendsto_atTop_of_eventually_const fun n (hdn : d ≤ n) ↦ (by simp [coeff_trunc', hdn])
theorem tendsto_trunc_atTop [DecidableEq σ] [CommSemiring R] [Nonempty σ] (f : MvPowerSeries σ R) :
Tendsto (fun d ↦ (trunc R d f : MvPowerSeries σ R)) atTop (𝓝 f) := by
rw [tendsto_iff_coeff_tendsto]
intro d
obtain ⟨s, _⟩ := (exists_const σ).mpr trivial
apply tendsto_atTop_of_eventually_const (i₀ := d + Finsupp.single s 1)
intro n hn
rw [MvPolynomial.coeff_coe, coeff_trunc, if_pos]
apply lt_of_lt_of_le _ hn
simp only [lt_add_iff_pos_right, Finsupp.lt_def]
refine ⟨zero_le _, ⟨s, by simp⟩⟩
/-- The inclusion of polynomials into power series has dense image -/
theorem denseRange_toMvPowerSeries [CommSemiring R] :
DenseRange (MvPolynomial.toMvPowerSeries (R := R) (σ := σ)) := fun f ↦ by
classical
exact mem_closure_of_tendsto (tendsto_trunc'_atTop f) <| .of_forall fun _ ↦ Set.mem_range_self _
@[deprecated (since := "2025-05-21")] alias toMvPowerSeries_denseRange := denseRange_toMvPowerSeries
variable (σ R)
/-- The semiring topology on `MvPowerSeries` of a topological semiring -/
@[scoped instance]
theorem instIsTopologicalSemiring [Semiring R] [IsTopologicalSemiring R] :
IsTopologicalSemiring (MvPowerSeries σ R) where
continuous_add := continuous_pi fun d => continuous_add.comp
(((continuous_coeff R d).fst').prodMk (continuous_coeff R d).snd')
continuous_mul := continuous_pi fun _ =>
continuous_finset_sum _ fun i _ => continuous_mul.comp
((continuous_coeff R i.fst).fst'.prodMk (continuous_coeff R i.snd).snd')
/-- The ring topology on `MvPowerSeries` of a topological ring -/
@[scoped instance]
theorem instIsTopologicalRing [Ring R] [IsTopologicalRing R] :
IsTopologicalRing (MvPowerSeries σ R) :=
{ instIsTopologicalSemiring σ R with
continuous_neg := continuous_pi fun d ↦ Continuous.comp continuous_neg
(continuous_coeff R d) }
variable {σ R}
@[fun_prop]
theorem continuous_C [Semiring R] :
Continuous (C (σ := σ) (R := R)) := by
classical
simp only [continuous_iff_continuousAt]
refine fun r ↦ (tendsto_iff_coeff_tendsto _ _ _).mpr fun d ↦ ?_
simp only [coeff_C]
split_ifs
· exact tendsto_id
· exact tendsto_const_nhds
/-- Scalar multiplication on `MvPowerSeries` is continuous. -/
instance {S : Type*} [Semiring S] [TopologicalSpace S]
[CommSemiring R] [Algebra R S] [ContinuousSMul R S] :
ContinuousSMul R (MvPowerSeries σ S) :=
instContinuousSMulForall
theorem variables_tendsto_zero [Semiring R] :
Tendsto (X · : σ → MvPowerSeries σ R) cofinite (nhds 0) := by
classical
simp only [tendsto_iff_coeff_tendsto, ← coeff_apply, coeff_X, coeff_zero]
refine fun d ↦ tendsto_nhds_of_eventually_eq ?_
by_cases! h : ∃ i, d = Finsupp.single i 1
· obtain ⟨i, hi⟩ := h
filter_upwards [eventually_cofinite_ne i] with j hj
simp [hi, Finsupp.single_eq_single_iff, hj.symm]
· simpa only [ite_eq_right_iff] using
Eventually.of_forall fun x h' ↦ (h x h').elim
theorem isTopologicallyNilpotent_of_constantCoeff_isNilpotent [CommSemiring R]
{f : MvPowerSeries σ R} (hf : IsNilpotent (constantCoeff f)) :
IsTopologicallyNilpotent f := by
classical
obtain ⟨m, hm⟩ := hf
simp_rw [IsTopologicallyNilpotent, tendsto_iff_coeff_tendsto, coeff_zero]
exact fun d ↦ tendsto_atTop_of_eventually_const fun n hn ↦
coeff_eq_zero_of_constantCoeff_nilpotent hm hn
theorem isTopologicallyNilpotent_of_constantCoeff_zero [CommSemiring R]
{f : MvPowerSeries σ R} (hf : constantCoeff f = 0) :
Tendsto (fun n : ℕ => f ^ n) atTop (nhds 0) := by
apply isTopologicallyNilpotent_of_constantCoeff_isNilpotent
rw [hf]
exact IsNilpotent.zero
/-- Assuming the base ring has a discrete topology, the powers of a `MvPowerSeries` converge to 0
iff its constant coefficient is nilpotent.
[N. Bourbaki, *Algebra {II}*, Chapter 4, §4, n°2, corollary of prop. 3][bourbaki1981]
See also `MvPowerSeries.LinearTopology.isTopologicallyNilpotent_iff_constantCoeff`. -/
theorem isTopologicallyNilpotent_iff_constantCoeff_isNilpotent
[CommRing R] [DiscreteTopology R] (f : MvPowerSeries σ R) :
IsTopologicallyNilpotent f ↔ IsNilpotent (constantCoeff f) := by
refine ⟨fun H ↦ ?_, isTopologicallyNilpotent_of_constantCoeff_isNilpotent⟩
replace H := H.map (continuous_constantCoeff R)
simp_rw [IsTopologicallyNilpotent, nhds_discrete, tendsto_pure] at H
exact H.exists
variable [Semiring R]
/-- A multivariate power series is the sum (in the sense of summable families) of its monomials -/
theorem hasSum_of_monomials_self (f : MvPowerSeries σ R) :
HasSum (fun d : σ →₀ ℕ => monomial d (coeff d f)) f := by
rw [Pi.hasSum]
intro d
simpa using hasSum_single d (fun d' h ↦ coeff_monomial_ne h.symm _)
/-- If the coefficient space is T2, then the multivariate power series is `tsum` of its monomials -/
theorem as_tsum [T2Space R] (f : MvPowerSeries σ R) :
f = tsum fun d : σ →₀ ℕ => monomial d (coeff d f) :=
(HasSum.tsum_eq (hasSum_of_monomials_self _)).symm
section Sum
variable {ι : Type*} {f : ι → MvPowerSeries σ R}
theorem hasSum_iff_hasSum_coeff {g : MvPowerSeries σ R} :
HasSum f g ↔ ∀ d : σ →₀ ℕ, HasSum (fun i ↦ coeff d (f i)) (coeff d g) := by
simp_rw [HasSum, ← map_sum]
apply tendsto_iff_coeff_tendsto
theorem summable_iff_summable_coeff :
Summable f ↔ ∀ d : σ →₀ ℕ, Summable (fun i ↦ coeff d (f i)) := by
simp_rw [Summable, hasSum_iff_hasSum_coeff]
constructor
· rintro ⟨a, h⟩ n
exact ⟨coeff n a, h n⟩
· intro h
choose a h using h
exact ⟨a, by simpa using h⟩
variable [LinearOrder ι] [LocallyFiniteOrderBot ι]
/-- A family of `MvPowerSeries` is summable if their weighted order tends to infinity. -/
theorem summable_of_tendsto_weightedOrder_atTop_nhds_top {w : σ → ℕ}
(h : Tendsto (fun i ↦ weightedOrder w (f i)) atTop (𝓝 ⊤)) : Summable f := by
rcases isEmpty_or_nonempty ι with hempty | hempty
· apply summable_empty
rw [summable_iff_summable_coeff]
simp_rw [ENat.tendsto_nhds_top_iff_natCast_lt, Filter.eventually_atTop] at h
intro d
obtain ⟨i, hi⟩ := h (Finsupp.weight w d)
refine summable_of_finite_support <| (Set.finite_Iic i).subset ?_
simp_rw [Function.support_subset_iff, Set.mem_Iic]
intro k hk
contrapose! hk
exact coeff_eq_zero_of_lt_weightedOrder w <| hi k hk.le
/-- A family of `MvPowerSeries` is summable if their order tends to infinity. -/
theorem summable_of_tendsto_order_atTop_nhds_top
(h : Tendsto (fun i ↦ (f i).order) atTop (𝓝 ⊤)) : Summable f :=
summable_of_tendsto_weightedOrder_atTop_nhds_top h
/-- The geometric series converges if the constant term is zero. -/
theorem summable_pow_of_constantCoeff_eq_zero {f : MvPowerSeries σ R}
(h : f.constantCoeff = 0) : Summable (f ^ ·) := by
apply summable_of_tendsto_order_atTop_nhds_top
simp_rw [ENat.tendsto_nhds_top_iff_natCast_lt, Filter.eventually_atTop]
refine fun n ↦ ⟨n + 1, fun m hm ↦ lt_of_lt_of_le ?_ (le_order_pow _)⟩
refine (ENat.coe_lt_coe.mpr (Nat.add_one_le_iff.mp hm.le)).trans_le ?_
simpa [nsmul_eq_mul] using ENat.self_le_mul_right m (order_ne_zero_iff_constCoeff_eq_zero.mpr h)
section GeomSeries
variable {R : Type*} [TopologicalSpace R] [Ring R] [IsTopologicalRing R] [T2Space R]
variable {f : MvPowerSeries σ R}
/-- Formula for geometric series. -/
theorem tsum_pow_mul_one_sub_of_constantCoeff_eq_zero (h : f.constantCoeff = 0) :
(∑' (i : ℕ), f ^ i) * (1 - f) = 1 :=
(summable_pow_of_constantCoeff_eq_zero h).tsum_pow_mul_one_sub
/-- Formula for geometric series. -/
theorem one_sub_mul_tsum_pow_of_constantCoeff_eq_zero (h : f.constantCoeff = 0) :
(1 - f) * ∑' (i : ℕ), f ^ i = 1 :=
(summable_pow_of_constantCoeff_eq_zero h).one_sub_mul_tsum_pow
end GeomSeries
end Sum
section Prod
variable {σ R : Type*} [TopologicalSpace R] [CommSemiring R]
variable {ι : Type*} {f : ι → MvPowerSeries σ R} [LinearOrder ι] [LocallyFiniteOrderBot ι]
/-- If the weighted order of a family of `MvPowerSeries` tends to infinity, the collection of all
possible products over `Finset` is summable. -/
theorem summable_prod_of_tendsto_weightedOrder_atTop_nhds_top {w : σ → ℕ}
(h : Tendsto (fun i ↦ weightedOrder w (f i)) atTop (𝓝 ⊤)) : Summable (∏ i ∈ ·, f i) := by
rcases isEmpty_or_nonempty ι with hempty | hempty
· apply Summable.of_finite
refine summable_iff_summable_coeff.mpr fun d ↦ summable_of_finite_support ?_
simp_rw [ENat.tendsto_nhds_top_iff_natCast_lt, eventually_atTop] at h
obtain ⟨i, hi⟩ := h (Finsupp.weight w d)
apply (Finset.Iio i).powerset.finite_toSet.subset
suffices ∀ s : Finset ι, coeff d (∏ i ∈ s, f i) ≠ 0 → ↑s ⊆ Set.Iio i by simpa
intro s hs
contrapose! hs
obtain ⟨x, hxs, hxi⟩ := Set.not_subset.mp hs
rw [Set.mem_Iio, not_lt] at hxi
refine coeff_eq_zero_of_lt_weightedOrder w <| (hi x hxi).trans_le <| ?_
apply le_trans (Finset.single_le_sum (by simp) hxs) (le_weightedOrder_prod w _ _)
/-- If the order of a family of `MvPowerSeries` tends to infinity, the collection of all
possible products over `Finset` is summable. -/
theorem summable_prod_of_tendsto_order_atTop_nhds_top
(h : Tendsto (fun i ↦ (f i).order) atTop (𝓝 ⊤)) : Summable (∏ i ∈ ·, f i) :=
summable_prod_of_tendsto_weightedOrder_atTop_nhds_top h
/-- A family of `MvPowerSeries` in the form `1 + f i` is multipliable if the weighted order of `f i`
tends to infinity. -/
theorem multipliable_one_add_of_tendsto_weightedOrder_atTop_nhds_top {w : σ → ℕ}
(h : Tendsto (fun i ↦ weightedOrder w (f i)) atTop (nhds ⊤)) : Multipliable (1 + f ·) :=
multipliable_one_add_of_summable_prod <| summable_prod_of_tendsto_weightedOrder_atTop_nhds_top h
/-- A family of `MvPowerSeries` in the form `1 + f i` is multipliable if the order of `f i`
tends to infinity. -/
theorem multipliable_one_add_of_tendsto_order_atTop_nhds_top
(h : Tendsto (fun i ↦ (f i).order) atTop (nhds ⊤)) : Multipliable (1 + f ·) :=
multipliable_one_add_of_summable_prod <| summable_prod_of_tendsto_order_atTop_nhds_top h
end Prod
end Topology
section Uniformity
variable [UniformSpace R]
/-- The componentwise uniformity on `MvPowerSeries` -/
scoped instance : UniformSpace (MvPowerSeries σ R) :=
Pi.uniformSpace fun _ : σ →₀ ℕ => R
variable (R) in
/-- Coefficients of a multivariate power series are uniformly continuous -/
theorem uniformContinuous_coeff [Semiring R] (d : σ →₀ ℕ) :
UniformContinuous fun f : MvPowerSeries σ R => coeff d f :=
uniformContinuous_pi.mp uniformContinuous_id d
/-- Completeness of the uniform structure on `MvPowerSeries` -/
@[scoped instance]
theorem instCompleteSpace [CompleteSpace R] :
CompleteSpace (MvPowerSeries σ R) := Pi.complete _
/-- The `IsUniformAddGroup` structure on `MvPowerSeries` of a `IsUniformAddGroup` -/
@[scoped instance]
theorem instIsUniformAddGroup [AddGroup R] [IsUniformAddGroup R] :
IsUniformAddGroup (MvPowerSeries σ R) := Pi.instIsUniformAddGroup
end Uniformity
end WithPiTopology
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Order.lean | import Mathlib.Data.ENat.Basic
import Mathlib.Data.Finsupp.Weight
import Mathlib.RingTheory.MvPowerSeries.Basic
/-! # Order of multivariate power series
We work with `MvPowerSeries σ R`, for `Semiring R`, and `w : σ → ℕ`.
## Weighted Order
- `MvPowerSeries.weightedOrder`: the weighted order of a multivariate power series,
with respect to `w`, as an element of `ℕ∞`.
- `MvPowerSeries.weightedOrder_zero`: the weighted order of `0` is `0`.
- `MvPowerSeries.ne_zero_iff_weightedOrder_finite`: a multivariate power series is nonzero if
and only if its weighted order is finite.
- `MvPowerSeries.exists_coeff_ne_zero_of_weightedOrder`: if the weighted order is finite,
then there exists a nonzero coefficient of weight the weighted order.
- `MvPowerSeries.weightedOrder_le` : if a coefficient is nonzero, then the weighted order is at
most the weight of that exponent.
- `MvPowerSeries.coeff_eq_zero_of_lt_weightedOrder`: all coefficients of weights strictly less
than the weighted order vanish.
- `MvPowerSeries.weightedOrder_eq_top_iff`: the weighted order of `f` is `⊤` if and only if `f = 0`.
- `MvPowerSeries.nat_le_weightedOrder`: if all coefficients of weight `< n` vanish, then the
weighted order is at least `n`.
- `MvPowerSeries.weightedOrder_eq_nat_iff`: the weighted order is some integer `n` iff there
exists a nonzero coefficient of weight `n`, and all coefficients of strictly smaller weight vanish.
- `MvPowerSeries.weightedOrder_monomial`, `MvPowerSeries.weightedOrder_monomial_of_ne_zero`:
the weighted order of a monomial, of a monomial with nonzero coefficient.
- `MvPowerSeries.min_weightedOrder_le_add`: the order of the sum of two multivariate power series
is at least the minimum of their orders.
- `MvPowerSeries.weightedOrder_add_of_weightedOrder_ne`: the weighted_order of the sum of two
formal power series is the minimum of their orders if their orders differ.
- `MvPowerSeries.le_weightedOrder_mul`: the weighted_order of the product of two formal power
series is at least the sum of their orders.
- `MvPowerSeries.coeff_mul_left_one_sub_of_lt_weightedOrder`,
`MvPowerSeries.coeff_mul_right_one_sub_of_lt_weightedOrder`: the coefficients of `f * (1 - g)`
and `(1 - g) * f` in weights strictly less than the weighted order of `g`.
- `MvPowerSeries.coeff_mul_prod_one_sub_of_lt_weightedOrder`: the coefficients of
`f * Π i in s, (1 - g i)`, in weights strictly less than the weighted orders of `g i`, for `i ∈ s`.
## Order
- `MvPowerSeries.order`: the weighted order, for `w = (1 : σ → ℕ)`.
- `MvPowerSeries.ne_zero_iff_order_finite`: `f` is nonzero iff its order is finite.
- `MvPowerSeries.order_eq_top_iff`: the order of `f` is infinite iff `f = 0`.
- `MvPowerSeries.exists_coeff_ne_zero_of_order`: if the order is finite, then there exists a
nonzero coefficient of degree equal to the order.
- `MvPowerSeries.order_le` : if a coefficient of some degree is nonzero, then the order
is at least that degree.
- `MvPowerSeries.nat_le_order`: if all coefficients of degree strictly smaller than some integer
vanish, then the order is at least that integer.
- `MvPowerSeries.order_eq_nat_iff`: the order of a power series is an integer `n` iff there exists
a nonzero coefficient in that degree, and all coefficients below that degree vanish.
- `MvPowerSeries.order_monomial`, `MvPowerSeries.order_monomial_of_ne_zero`: the order of a
monomial, with a nonzero coefficient
- `MvPowerSeries.min_order_le_add`: the order of a sum of two power series is at least the minimum
of their orders.
- `MvPowerSeries.order_add_of_order_ne`: the order of a sum of two power series of distinct orders
is the minimum of their orders.
- `MvPowerSeries.order_mul_ge`: the order of a product of two power series is at least the sum of
their orders.
- `MvPowerSeries.coeff_mul_left_one_sub_of_lt_order`,
`MvPowerSeries.coeff_mul_right_one_sub_of_lt_order`: the coefficients of `f * (1 - g)` and
`(1 - g) * f` below the order of `g` coincide with that of `f`.
- `MvPowerSeries.coeff_mul_prod_one_sub_of_lt_order`: the coefficients of `f * Π i in s, (1 - g i)`
coincide with that of `f` below the minimum of the orders of the `g i`, for `i ∈ s`.
## Homogeneous components
- `MvPowerSeries.weightedHomogeneousComponent`, `MvPowerSeries.homogeneousComponent`: the power
series which is the sum of all monomials of given weighted degree, resp. degree.
NOTE:
Under `Finite σ`, one can use `Finsupp.finite_of_degree_le` and `Finsupp.finite_of_weight_le` to
show that they have finite support, hence correspond to `MvPolynomial`.
However, when `σ` is finite, this is not necessarily an `MvPolynomial`.
(For example: the homogeneous components of degree 1 of the multivariate power
series, all of which coefficients are `1`, is the sum of all indeterminates.)
TODO: Define a coercion to MvPolynomial.
-/
namespace MvPowerSeries
noncomputable section
open ENat WithTop Finsupp
variable {σ R : Type*} [Semiring R]
section WeightedOrder
variable (w : σ → ℕ) {f g : MvPowerSeries σ R}
theorem ne_zero_iff_exists_coeff_ne_zero_and_weight :
f ≠ 0 ↔ (∃ n : ℕ, ∃ d : σ →₀ ℕ, coeff d f ≠ 0 ∧ weight w d = n) := by
refine not_iff_not.mp ?_
simp only [ne_eq, not_not, not_exists, not_and, forall_apply_eq_imp_iff₂, imp_false]
exact MvPowerSeries.ext_iff
/-- The weighted order of a mv_power_series -/
def weightedOrder (f : MvPowerSeries σ R) : ℕ∞ := by
classical
exact dite (f = 0) (fun _ => ⊤) fun h =>
Nat.find ((ne_zero_iff_exists_coeff_ne_zero_and_weight w).mp h)
@[simp] theorem weightedOrder_zero : (0 : MvPowerSeries σ R).weightedOrder w = ⊤ := by
rw [weightedOrder, dif_pos rfl]
theorem ne_zero_iff_weightedOrder_finite :
f ≠ 0 ↔ (f.weightedOrder w).toNat = f.weightedOrder w := by
simp only [weightedOrder, ne_eq, coe_toNat_eq_self, dite_eq_left_iff,
ENat.coe_ne_top, imp_false, not_not]
/-- The `0` power series is the unique power series with infinite order. -/
@[simp]
theorem weightedOrder_eq_top_iff :
f.weightedOrder w = ⊤ ↔ f = 0 := by
rw [← not_iff_not, ← ne_eq, ← ne_eq, ne_zero_iff_weightedOrder_finite w, coe_toNat_eq_self]
/-- If the order of a formal power series `f` is finite,
then some coefficient of weight equal to the order of `f` is nonzero. -/
theorem exists_coeff_ne_zero_and_weightedOrder
(h : (toNat (f.weightedOrder w) : ℕ∞) = f.weightedOrder w) :
∃ d, coeff d f ≠ 0 ∧ weight w d = f.weightedOrder w := by
classical
simp_rw [weightedOrder, dif_neg ((ne_zero_iff_weightedOrder_finite w).mpr h), Nat.cast_inj]
generalize_proofs h1
exact Nat.find_spec h1
/-- If the `d`th coefficient of a formal power series is nonzero,
then the weighted order of the power series is less than or equal to `weight d w`. -/
theorem weightedOrder_le {d : σ →₀ ℕ} (h : coeff d f ≠ 0) :
f.weightedOrder w ≤ weight w d := by
rw [weightedOrder, dif_neg]
· simp only [ne_eq, Nat.cast_le, Nat.find_le_iff]
exact ⟨weight w d, le_rfl, d, h, rfl⟩
· exact (f.ne_zero_iff_exists_coeff_ne_zero_and_weight w).mpr ⟨weight w d, d, h, rfl⟩
/-- The `n`th coefficient of a formal power series is `0` if `n` is strictly
smaller than the order of the power series. -/
theorem coeff_eq_zero_of_lt_weightedOrder {d : σ →₀ ℕ} (h : (weight w d) < f.weightedOrder w) :
coeff d f = 0 := by
contrapose! h; exact weightedOrder_le w h
/-- The order of a formal power series is at least `n` if
the `d`th coefficient is `0` for all `d` such that `weight w d < n`. -/
theorem nat_le_weightedOrder {n : ℕ} (h : ∀ d, weight w d < n → coeff d f = 0) :
n ≤ f.weightedOrder w := by
by_contra! H
have : (f.weightedOrder w).toNat = f.weightedOrder w := by
rw [coe_toNat_eq_self]; exact ne_top_of_lt H
obtain ⟨d, hfd, hd⟩ := exists_coeff_ne_zero_and_weightedOrder w this
rw [← hd, Nat.cast_lt] at H
exact hfd (h d H)
/-- The order of a formal power series is at least `n` if
the `d`th coefficient is `0` for all `d` such that `weight w d < n`. -/
theorem le_weightedOrder {n : ℕ∞} (h : ∀ d : σ →₀ ℕ, weight w d < n → coeff d f = 0) :
n ≤ f.weightedOrder w := by
cases n
· rw [top_le_iff, weightedOrder_eq_top_iff]
ext d; exact h d (ENat.coe_lt_top _)
· apply nat_le_weightedOrder;
simpa only [ENat.some_eq_coe, Nat.cast_lt] using h
/-- The order of a formal power series is exactly `n` if and only if some coefficient of weight `n`
is nonzero, and the `d`th coefficient is `0` for all `d` such that `weight w d < n`. -/
theorem weightedOrder_eq_nat {n : ℕ} :
f.weightedOrder w = n ↔
(∃ d, coeff d f ≠ 0 ∧ weight w d = n) ∧ ∀ d, weight w d < n → coeff d f = 0 := by
constructor
· intro h
obtain ⟨d, hd⟩ := f.exists_coeff_ne_zero_and_weightedOrder w (by simp only [h, toNat_coe])
exact ⟨⟨d, by simpa [h, Nat.cast_inj, ne_eq] using hd⟩,
fun e he ↦ f.coeff_eq_zero_of_lt_weightedOrder w (by simp only [h, Nat.cast_lt, he])⟩
· rintro ⟨⟨d, hd', hd⟩, h⟩
exact le_antisymm (hd.symm ▸ f.weightedOrder_le w hd') (nat_le_weightedOrder w h)
/-- The weighted_order of the monomial `a*X^d` is infinite if `a = 0` and `weight w d` otherwise. -/
theorem weightedOrder_monomial {d : σ →₀ ℕ} {a : R} [Decidable (a = 0)] :
weightedOrder w (monomial d a) = if a = 0 then (⊤ : ℕ∞) else weight w d := by
classical
split_ifs with h
· rw [h, weightedOrder_eq_top_iff, LinearMap.map_zero]
· rw [weightedOrder_eq_nat]
constructor
· use d
simp only [coeff_monomial_same, ne_eq, h, not_false_eq_true, and_self]
· intro b hb
rw [coeff_monomial, if_neg]
rintro rfl
exact hb.false
/-- The order of the monomial `a*X^n` is `n` if `a ≠ 0`. -/
theorem weightedOrder_monomial_of_ne_zero {d : σ →₀ ℕ} {a : R} (h : a ≠ 0) :
weightedOrder w (monomial d a) = weight w d := by
classical
rw [weightedOrder_monomial, if_neg h]
@[simp]
theorem weightedOrder_one [Nontrivial R] : (1 : MvPowerSeries σ R).weightedOrder w = 0 :=
weightedOrder_monomial_of_ne_zero w one_ne_zero
/-- The order of the sum of two formal power series is at least the minimum of their orders. -/
theorem min_weightedOrder_le_add :
min (f.weightedOrder w) (g.weightedOrder w) ≤ (f + g).weightedOrder w := by
apply le_weightedOrder w
simp +contextual only
[coeff_eq_zero_of_lt_weightedOrder w, lt_min_iff, map_add, add_zero,
imp_true_iff]
private theorem weightedOrder_add_of_weightedOrder_lt.aux
(H : f.weightedOrder w < g.weightedOrder w) :
(f + g).weightedOrder w = f.weightedOrder w := by
obtain ⟨n, hn : (n : ℕ∞) = _⟩ := ENat.ne_top_iff_exists.mp (ne_top_of_lt H)
rw [← hn, weightedOrder_eq_nat]
obtain ⟨d, hd', hd⟩ := ((weightedOrder_eq_nat w).mp hn.symm).1
constructor
· refine ⟨d, ?_, hd⟩
rw [← hn, ← hd] at H
rw [(coeff _).map_add, coeff_eq_zero_of_lt_weightedOrder w H, add_zero]
exact hd'
· intro b hb
suffices weight w b < weightedOrder w f by
rw [(coeff _).map_add, coeff_eq_zero_of_lt_weightedOrder w this,
coeff_eq_zero_of_lt_weightedOrder w (lt_trans this H), add_zero]
rw [← hn, Nat.cast_lt]
exact hb
/-- The weighted_order of the sum of two formal power series
is the minimum of their orders if their orders differ. -/
theorem weightedOrder_add_of_weightedOrder_ne (h : f.weightedOrder w ≠ g.weightedOrder w) :
weightedOrder w (f + g) = weightedOrder w f ⊓ weightedOrder w g := by
refine le_antisymm ?_ (min_weightedOrder_le_add w)
wlog H₁ : f.weightedOrder w < g.weightedOrder w
· rw [add_comm f g, inf_comm]
exact this _ h.symm ((le_of_not_gt H₁).lt_of_ne' h)
simp only [le_inf_iff, weightedOrder_add_of_weightedOrder_lt.aux w H₁]
exact ⟨le_rfl, le_of_lt H₁⟩
/-- The weighted_order of the product of two formal power series
is at least the sum of their orders. -/
theorem le_weightedOrder_mul :
f.weightedOrder w + g.weightedOrder w ≤ weightedOrder w (f * g) := by
classical
apply le_weightedOrder
intro d hd
rw [coeff_mul, Finset.sum_eq_zero]
rintro ⟨i, j⟩ hij
by_cases! hi : weight w i < f.weightedOrder w
· rw [coeff_eq_zero_of_lt_weightedOrder w hi, zero_mul]
· by_cases! hj : weight w j < g.weightedOrder w
· rw [coeff_eq_zero_of_lt_weightedOrder w hj, mul_zero]
· simp only [Finset.mem_antidiagonal] at hij
exfalso
apply ne_of_lt (lt_of_lt_of_le hd <| add_le_add hi hj)
rw [← hij, map_add, Nat.cast_add]
theorem le_weightedOrder_pow (n : ℕ) : n • f.weightedOrder w ≤ (f ^ n).weightedOrder w := by
induction n with
| zero => simp
| succ n hn =>
simpa [add_smul] using
le_trans (add_le_add_right hn (f.weightedOrder w)) (le_weightedOrder_mul w)
theorem le_weightedOrder_prod {R : Type*} [CommSemiring R] {ι : Type*} (w : σ → ℕ)
(f : ι → MvPowerSeries σ R) (s : Finset ι) :
∑ i ∈ s, (f i).weightedOrder w ≤ (∏ i ∈ s, f i).weightedOrder w := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha ih => grw [Finset.sum_cons ha, Finset.prod_cons ha, ih, le_weightedOrder_mul]
alias weightedOrder_mul_ge := le_weightedOrder_mul
section Ring
variable {R : Type*} [Ring R] {f g : MvPowerSeries σ R}
theorem coeff_mul_left_one_sub_of_lt_weightedOrder
{d : σ →₀ ℕ} (h : (weight w d) < g.weightedOrder w) :
coeff d (f * (1 - g)) = coeff d f := by
simp only [mul_sub, mul_one, map_sub, sub_eq_self]
apply coeff_eq_zero_of_lt_weightedOrder w
exact lt_of_lt_of_le (lt_of_lt_of_le h le_add_self) (le_weightedOrder_mul w)
theorem coeff_mul_right_one_sub_of_lt_weightedOrder
{d : σ →₀ ℕ} (h : (weight w d) < g.weightedOrder w) :
coeff d ((1 - g) * f) = coeff d f := by
simp only [sub_mul, one_mul, map_sub, sub_eq_self]
apply coeff_eq_zero_of_lt_weightedOrder w
apply lt_of_lt_of_le (lt_of_lt_of_le h le_self_add) (le_weightedOrder_mul w)
theorem coeff_mul_prod_one_sub_of_lt_weightedOrder {R ι : Type*} [CommRing R] (d : σ →₀ ℕ)
(s : Finset ι) (f : MvPowerSeries σ R) (g : ι → MvPowerSeries σ R)
(h : ∀ i ∈ s, (weight w d) < weightedOrder w (g i)) :
coeff d (f * ∏ i ∈ s, (1 - g i)) = coeff d f := by
classical
induction s using Finset.induction_on with
| empty => simp only [Finset.prod_empty, mul_one]
| insert a s ha ih =>
simp only [Finset.mem_insert, forall_eq_or_imp] at h
rw [Finset.prod_insert ha, ← mul_assoc, mul_right_comm,
coeff_mul_left_one_sub_of_lt_weightedOrder w h.1, ih h.2]
@[simp]
theorem weightedOrder_neg (f : MvPowerSeries σ R) : (-f).weightedOrder w = f.weightedOrder w := by
by_contra! h
have : f = 0 := by simpa using (weightedOrder_add_of_weightedOrder_ne w h).symm
simp [this] at h
end Ring
end WeightedOrder
section Order
variable {f g : MvPowerSeries σ R}
theorem eq_zero_iff_forall_coeff_eq_zero_and :
f = 0 ↔ (∀ d : σ →₀ ℕ, coeff d f = 0) :=
MvPowerSeries.ext_iff
theorem ne_zero_iff_exists_coeff_ne_zero_and_degree :
f ≠ 0 ↔ (∃ n : ℕ, ∃ d : σ →₀ ℕ, coeff d f ≠ 0 ∧ degree d = n) := by
simp_rw [degree_eq_weight_one]
exact ne_zero_iff_exists_coeff_ne_zero_and_weight (fun _ => 1)
/-- The order of a mv_power_series -/
def order (f : MvPowerSeries σ R) : ℕ∞ := weightedOrder (fun _ => 1) f
@[simp]
theorem order_zero : (0 : MvPowerSeries σ R).order = ⊤ :=
weightedOrder_zero _
theorem ne_zero_iff_order_finite : f ≠ 0 ↔ f.order.toNat = f.order :=
ne_zero_iff_weightedOrder_finite 1
/-- The `0` power series is the unique power series with infinite order. -/
@[simp] theorem order_eq_top_iff : f.order = ⊤ ↔ f = 0 :=
weightedOrder_eq_top_iff _
/-- If the order of a formal power series `f` is finite,
then some coefficient of degree the order of `f` is nonzero. -/
theorem exists_coeff_ne_zero_and_order (h : f.order.toNat = f.order) :
∃ d : σ →₀ ℕ, coeff d f ≠ 0 ∧ degree d = f.order := by
simp_rw [degree_eq_weight_one]
exact exists_coeff_ne_zero_and_weightedOrder _ h
/-- If the `d`th coefficient of a formal power series is nonzero,
then the order of the power series is less than or equal to `degree d`. -/
theorem order_le {d : σ →₀ ℕ} (h : coeff d f ≠ 0) : f.order ≤ degree d := by
rw [degree_eq_weight_one]
exact weightedOrder_le _ h
/-- The `n`th coefficient of a formal power series is `0` if `n` is strictly
smaller than the order of the power series. -/
theorem coeff_of_lt_order {d : σ →₀ ℕ} (h : degree d < f.order) :
coeff d f = 0 := by
rw [degree_eq_weight_one] at h
exact coeff_eq_zero_of_lt_weightedOrder _ h
/-- The order of a formal power series is at least `n` if
the `d`th coefficient is `0` for all `d` such that `degree d < n`. -/
theorem nat_le_order {n : ℕ} (h : ∀ d, degree d < n → coeff d f = 0) :
n ≤ f.order := by
simp_rw [degree_eq_weight_one] at h
exact nat_le_weightedOrder _ h
/-- The order of a formal power series is at least `n` if
the `d`th coefficient is `0` for all `d` such that `degree d < n`. -/
theorem le_order {n : ℕ∞} (h : ∀ d : σ →₀ ℕ, degree d < n → coeff d f = 0) :
n ≤ f.order := by
simp_rw [degree_eq_weight_one] at h
exact le_weightedOrder _ h
/-- The order of a formal power series is exactly `n` some coefficient
of degree `n` is nonzero,
and the `d`th coefficient is `0` for all `d` such that `degree d < n`. -/
theorem order_eq_nat {n : ℕ} :
f.order = n ↔
(∃ d, coeff d f ≠ 0 ∧ degree d = n) ∧ ∀ d, degree d < n → coeff d f = 0 := by
simp_rw [degree_eq_weight_one]
exact weightedOrder_eq_nat _
/-- The order of the monomial `a*X^d` is infinite if `a = 0` and `degree d` otherwise. -/
theorem order_monomial {d : σ →₀ ℕ} {a : R} [Decidable (a = 0)] :
order (monomial d a) = if a = 0 then (⊤ : ℕ∞) else ↑(degree d) := by
rw [degree_eq_weight_one]
exact weightedOrder_monomial _
/-- The order of the monomial `a*X^n` is `n` if `a ≠ 0`. -/
theorem order_monomial_of_ne_zero {d : σ →₀ ℕ} {a : R} (h : a ≠ 0) :
order (monomial d a) = degree d := by
rw [degree_eq_weight_one]
exact weightedOrder_monomial_of_ne_zero _ h
/-- The order of the sum of two formal power series
is at least the minimum of their orders. -/
theorem min_order_le_add : min f.order g.order ≤ (f + g).order :=
min_weightedOrder_le_add _
/-- The order of the sum of two formal power series
is the minimum of their orders if their orders differ. -/
theorem order_add_of_order_ne (h : f.order ≠ g.order) :
order (f + g) = order f ⊓ order g :=
weightedOrder_add_of_weightedOrder_ne _ h
/-- The order of the product of two formal power series
is at least the sum of their orders. -/
theorem le_order_mul : f.order + g.order ≤ order (f * g) :=
le_weightedOrder_mul _
alias order_mul_ge := le_order_mul
theorem le_order_pow (n : ℕ) : n • f.order ≤ (f ^ n).order :=
le_weightedOrder_pow _ n
theorem le_order_prod {R : Type*} [CommSemiring R] {ι : Type*}
(f : ι → MvPowerSeries σ R) (s : Finset ι) : ∑ i ∈ s, (f i).order ≤ (∏ i ∈ s, f i).order :=
le_weightedOrder_prod _ _ _
theorem order_ne_zero_iff_constCoeff_eq_zero :
f.order ≠ 0 ↔ f.constantCoeff = 0 := by
constructor
· intro h
apply coeff_of_lt_order
simpa using pos_of_ne_zero h
· intro h
refine ENat.one_le_iff_ne_zero.mp <| MvPowerSeries.le_order fun d hd ↦ ?_
rw [Nat.cast_lt_one] at hd
simp [(degree_eq_zero_iff d).mp hd, h]
section Ring
variable {R : Type*} [Ring R] {f g : MvPowerSeries σ R}
theorem coeff_mul_left_one_sub_of_lt_order (d : σ →₀ ℕ) (h : degree d < g.order) :
coeff d (f * (1 - g)) = coeff d f := by
rw [degree_eq_weight_one] at h
exact coeff_mul_left_one_sub_of_lt_weightedOrder _ h
theorem coeff_mul_right_one_sub_of_lt_order (d : σ →₀ ℕ) (h : degree d < g.order) :
coeff d ((1 - g) * f) = coeff d f := by
rw [degree_eq_weight_one] at h
exact coeff_mul_right_one_sub_of_lt_weightedOrder _ h
theorem coeff_mul_prod_one_sub_of_lt_order {R ι : Type*} [CommRing R] (d : σ →₀ ℕ) (s : Finset ι)
(f : MvPowerSeries σ R) (g : ι → MvPowerSeries σ R) :
(∀ i ∈ s, degree d < order (g i)) → coeff d (f * ∏ i ∈ s, (1 - g i)) = coeff d f := by
rw [degree_eq_weight_one]
exact coeff_mul_prod_one_sub_of_lt_weightedOrder _ d s f g
@[simp]
theorem order_neg (f : MvPowerSeries σ R) : (-f).order = f.order := weightedOrder_neg _ f
end Ring
end Order
section HomogeneousComponent
variable (w : σ → ℕ)
/-- Weighted homogeneous power series -/
def IsWeightedHomogeneous (f : MvPowerSeries σ R) (p : ℕ) : Prop :=
∀ {d : σ →₀ ℕ}, f.coeff d ≠ 0 → weight w d = p
variable {w} in
theorem IsWeightedHomogeneous.coeff_eq_zero {f : MvPowerSeries σ R} {p : ℕ}
(hf : f.IsWeightedHomogeneous w p) {d : σ →₀ ℕ} (hd : weight w d ≠ p) :
f.coeff d = 0 := by
simpa [Classical.not_not] using mt (@hf d) hd
variable {w} in
protected theorem IsWeightedHomogeneous.add {f g : MvPowerSeries σ R} {p : ℕ}
(hf : f.IsWeightedHomogeneous w p) (hg : g.IsWeightedHomogeneous w p) :
(f + g).IsWeightedHomogeneous w p := fun {d} ↦ by
rw [not_imp_comm]
intro hd
rw [map_add, hf.coeff_eq_zero hd, hg.coeff_eq_zero hd, add_zero]
variable {w} in
protected theorem IsWeightedHomogeneous.mul {f g : MvPowerSeries σ R} {p q : ℕ}
(hf : f.IsWeightedHomogeneous w p) (hg : g.IsWeightedHomogeneous w q) :
(f * g).IsWeightedHomogeneous w (p + q) := fun {d} ↦ by
classical
rw [not_imp_comm]
intro hd
rw [coeff_mul]
apply Finset.sum_eq_zero
intro x hx
rw [Finset.mem_antidiagonal] at hx
suffices weight w x.1 ≠ p ∨ weight w x.2 ≠ q by
rcases this with hp | hq
· rw [hf.coeff_eq_zero hp, zero_mul]
· rw [hg.coeff_eq_zero hq, mul_zero]
rw [← not_and_or]
rintro ⟨hp, hq⟩
apply hd
rw [← hx, map_add, hp, hq]
/-- The weighted homogeneous components of an `MvPowerSeries f`. -/
def weightedHomogeneousComponent (p : ℕ) : MvPowerSeries σ R →ₗ[R] MvPowerSeries σ R where
toFun f d := if weight w d = p then coeff d f else 0
map_add' f g := by
ext d
simp only [map_add, coeff_apply]
split_ifs with h
· rfl
· rw [add_zero]
map_smul' a f := by
ext d
simp only [map_smul,
smul_eq_mul, RingHom.id_apply, coeff_apply, mul_ite, mul_zero]
theorem coeff_weightedHomogeneousComponent (p : ℕ) (d : σ →₀ ℕ) (f : MvPowerSeries σ R) :
coeff d (weightedHomogeneousComponent w p f) =
if weight w d = p then coeff d f else 0 :=
rfl
variable {w} in
theorem weightedHomogeneousComponent_of_lt_weightedOrder_eq_zero
{f : MvPowerSeries σ R} {p : ℕ} (hf : p < f.weightedOrder w) :
f.weightedHomogeneousComponent w p = 0 := by
ext d
rw [coeff_weightedHomogeneousComponent]
split_ifs with hd
· rw [coeff_zero]
apply coeff_eq_zero_of_lt_weightedOrder w
rw [hd]
exact hf
· rw [map_zero]
variable {w} in
theorem weightedHomogeneousComponent_of_weightedOrder
{f : MvPowerSeries σ R} {p : ℕ} (hf : p = f.weightedOrder w) :
f.weightedHomogeneousComponent w p ≠ 0 := by
intro hf'
obtain ⟨d, hd⟩ := f.exists_coeff_ne_zero_and_weightedOrder w (by rw [← hf, toNat_coe])
simp only [ne_eq, ← hf, Nat.cast_inj] at hd
apply hd.1
rw [MvPowerSeries.ext_iff] at hf'
specialize hf' d
simp only [coeff_weightedHomogeneousComponent, coeff_zero, ite_eq_right_iff] at hf'
exact hf' hd.2
theorem isWeightedHomogeneous_weightedHomogeneousComponent (f : MvPowerSeries σ R) (p : ℕ) :
IsWeightedHomogeneous w (f.weightedHomogeneousComponent w p) p := fun {d} ↦ by
rw [not_imp_comm]
intro hd
rw [coeff_weightedHomogeneousComponent, if_neg hd]
variable {w} in
theorem isWeightedHomogeneous_iff_eq_weightedHomogeneousComponent
{f : MvPowerSeries σ R} {p : ℕ} :
IsWeightedHomogeneous w f p ↔ f = f.weightedHomogeneousComponent w p := by
constructor
· intro hf
ext d
rw [coeff_weightedHomogeneousComponent]
split_ifs with hd
· rfl
· exact hf.coeff_eq_zero hd
· intro hf
rw [hf]
exact isWeightedHomogeneous_weightedHomogeneousComponent w f p
variable {w} in
theorem weightedHomogeneousComponent_mul_of_le_weightedOrder {f g : MvPowerSeries σ R} {p q : ℕ}
(hf : p ≤ f.weightedOrder w) (hg : q ≤ g.weightedOrder w) :
weightedHomogeneousComponent w (p + q) (f * g) =
weightedHomogeneousComponent w p f * weightedHomogeneousComponent w q g := by
classical
ext d
rw [coeff_weightedHomogeneousComponent]
split_ifs with hd
· apply Finset.sum_congr rfl
intro x hx
rw [Finset.mem_antidiagonal] at hx
rw [← hx, map_add] at hd
simp only [coeff_weightedHomogeneousComponent]
rcases trichotomy_of_add_eq_add hd with h | h | h
· rw [if_pos h.1, if_pos h.2]
· rw [if_neg (ne_of_lt h), zero_mul]
rw [← ENat.coe_lt_coe] at h
rw [coeff_eq_zero_of_lt_weightedOrder w (lt_of_lt_of_le h hf), zero_mul]
· rw [if_neg (ne_of_lt h), mul_zero]
rw [← ENat.coe_lt_coe] at h
rw [coeff_eq_zero_of_lt_weightedOrder w (lt_of_lt_of_le h hg), mul_zero]
· symm
apply IsWeightedHomogeneous.coeff_eq_zero _ hd
exact IsWeightedHomogeneous.mul
(isWeightedHomogeneous_weightedHomogeneousComponent w f p)
(isWeightedHomogeneous_weightedHomogeneousComponent w g q)
/-- Homogeneous power series -/
def IsHomogeneous (f : MvPowerSeries σ R) (p : ℕ) : Prop :=
IsWeightedHomogeneous 1 f p
theorem IsHomogeneous.coeff_eq_zero {f : MvPowerSeries σ R} {p : ℕ}
(hf : f.IsHomogeneous p) {d : σ →₀ ℕ} (hd : degree d ≠ p) :
f.coeff d = 0 := by
apply IsWeightedHomogeneous.coeff_eq_zero hf
rwa [degree_eq_weight_one] at hd
protected theorem IsHomogeneous.add {f g : MvPowerSeries σ R} {p : ℕ}
(hf : f.IsHomogeneous p) (hg : g.IsHomogeneous p) :
(f + g).IsHomogeneous p :=
IsWeightedHomogeneous.add hf hg
protected theorem IsHomogeneous.mul {f g : MvPowerSeries σ R} {p q : ℕ}
(hf : f.IsHomogeneous p) (hg : g.IsHomogeneous q) :
(f * g).IsHomogeneous (p + q) :=
IsWeightedHomogeneous.mul hf hg
/-- The homogeneous components of an `MvPowerSeries` -/
def homogeneousComponent (p : ℕ) : MvPowerSeries σ R →ₗ[R] MvPowerSeries σ R :=
weightedHomogeneousComponent 1 p
theorem coeff_homogeneousComponent (p : ℕ) (d : σ →₀ ℕ) (f : MvPowerSeries σ R) :
coeff d (homogeneousComponent p f) =
if degree d = p then coeff d f else 0 := by
rw [degree_eq_weight_one]
exact coeff_weightedHomogeneousComponent 1 p d f
theorem homogeneousComponent_of_lt_order_eq_zero
{f : MvPowerSeries σ R} {p : ℕ} (hf : p < f.order) :
f.homogeneousComponent p = 0 :=
weightedHomogeneousComponent_of_lt_weightedOrder_eq_zero hf
theorem homogeneousComponent_of_order
{f : MvPowerSeries σ R} {p : ℕ} (hf : p = f.order) :
f.homogeneousComponent p ≠ 0 :=
weightedHomogeneousComponent_of_weightedOrder hf
theorem isHomogeneous_homogeneousComponent (f : MvPowerSeries σ R) (p : ℕ) :
IsHomogeneous (f.homogeneousComponent p) p :=
isWeightedHomogeneous_weightedHomogeneousComponent 1 f p
theorem isHomogeneous_iff_eq_homogeneousComponent
{f : MvPowerSeries σ R} {p : ℕ} :
IsHomogeneous f p ↔ f = f.homogeneousComponent p :=
isWeightedHomogeneous_iff_eq_weightedHomogeneousComponent
theorem homogeneousComponent_mul_of_le_order {f g : MvPowerSeries σ R} {p q : ℕ}
(hf : p ≤ f.order) (hg : q ≤ g.order) :
homogeneousComponent (p + q) (f * g) =
homogeneousComponent p f * homogeneousComponent q g :=
weightedHomogeneousComponent_mul_of_le_weightedOrder hf hg
end HomogeneousComponent
end
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Evaluation.lean | import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.RingTheory.Ideal.BigOperators
import Mathlib.RingTheory.MvPowerSeries.PiTopology
import Mathlib.RingTheory.MvPowerSeries.Trunc
import Mathlib.Topology.Algebra.Algebra
import Mathlib.Topology.Algebra.TopologicallyNilpotent
import Mathlib.Topology.Algebra.LinearTopology
import Mathlib.Topology.Algebra.UniformRing
/-! # Evaluation of multivariate power series
Let `σ`, `R`, `S` be types, with `CommRing R`, `CommRing S`.
One assumes that `IsTopologicalRing R` and `IsUniformAddGroup R`,
and that `S` is a complete and separated topological `R`-algebra,
with `IsLinearTopology S S`, which means there is a basis of neighborhoods of 0
consisting of ideals.
Given `φ : R →+* S`, `a : σ → S`, and `f : MvPowerSeries σ R`,
`MvPowerSeries.eval₂ f φ a` is the evaluation of the multivariate power series `f` at `a`.
It `f` is (the coercion of) a polynomial, it coincides with the evaluation of that polynomial.
Otherwise, it is defined by density from polynomials;
its values are irrelevant unless `φ` is continuous and `a` satisfies two conditions
bundled in `MvPowerSeries.HasEval a` :
- for all `s : σ`, `a s` is topologically nilpotent,
meaning that `(a s) ^ n` tends to 0 when `n` tends to infinity
- when `a s` tends to zero for the filter of cofinite subsets of `σ`.
Under `Continuous φ` and `HasEval a`, the following lemmas furnish the properties of evaluation:
* `MvPowerSeries.eval₂Hom`: the evaluation of multivariate power series, as a ring morphism,
* `MvPowerSeries.aeval`: the evaluation map as an algebra morphism
* `MvPowerSeries.uniformContinuous_eval₂`: uniform continuity of the evaluation
* `MvPowerSeries.continuous_eval₂`: continuity of the evaluation
* `MvPowerSeries.eval₂_eq_tsum`: the evaluation is given by the sum of its monomials, evaluated.
-/
namespace MvPowerSeries
open Topology
open Filter MvPolynomial RingHom Set TopologicalSpace UniformSpace
/- ## Necessary conditions -/
section
variable {σ : Type*}
variable {R : Type*} [CommRing R] [TopologicalSpace R]
variable {S : Type*} [CommRing S] [TopologicalSpace S]
variable {φ : R →+* S}
-- We endow MvPowerSeries σ R with the Pi topology
open WithPiTopology
/-- Families at which power series can be consistently evaluated -/
@[mk_iff hasEval_def]
structure HasEval (a : σ → S) : Prop where
hpow : ∀ s, IsTopologicallyNilpotent (a s)
tendsto_zero : Tendsto a cofinite (𝓝 0)
theorem HasEval.mono {S : Type*} [CommRing S] {a : σ → S}
{t u : TopologicalSpace S} (h : t ≤ u) (ha : @HasEval _ _ _ t a) :
@HasEval _ _ _ u a :=
⟨fun s ↦ Filter.Tendsto.mono_right (@HasEval.hpow _ _ _ t a ha s) (nhds_mono h),
Filter.Tendsto.mono_right (@HasEval.tendsto_zero σ _ _ t a ha) (nhds_mono h)⟩
theorem HasEval.zero : HasEval (0 : σ → S) where
hpow _ := .zero
tendsto_zero := tendsto_const_nhds
theorem HasEval.add [ContinuousAdd S] [IsLinearTopology S S]
{a b : σ → S} (ha : HasEval a) (hb : HasEval b) : HasEval (a + b) where
hpow s := (ha.hpow s).add (hb.hpow s)
tendsto_zero := by rw [← add_zero 0]; exact ha.tendsto_zero.add hb.tendsto_zero
theorem HasEval.mul_left [IsLinearTopology S S]
(c : σ → S) {x : σ → S} (hx : HasEval x) : HasEval (c * x) where
hpow s := (hx.hpow s).mul_left (c s)
tendsto_zero := IsLinearTopology.tendsto_mul_zero_of_right _ _ hx.tendsto_zero
theorem HasEval.mul_right [IsLinearTopology S S]
(c : σ → S) {x : σ → S} (hx : HasEval x) : HasEval (x * c) :=
mul_comm x c ▸ HasEval.mul_left c hx
/-- [Bourbaki, *Algebra*, chap. 4, §4, n°3, Prop. 4 (i) (a & b)][bourbaki1981]. -/
theorem HasEval.map (hφ : Continuous φ) {a : σ → R} (ha : HasEval a) :
HasEval (fun s ↦ φ (a s)) where
hpow s := (ha.hpow s).map hφ
tendsto_zero := (map_zero φ ▸ hφ.tendsto 0).comp ha.tendsto_zero
protected theorem HasEval.X :
HasEval (fun s ↦ (MvPowerSeries.X s : MvPowerSeries σ R)) where
hpow s := isTopologicallyNilpotent_of_constantCoeff_zero (constantCoeff_X s)
tendsto_zero := variables_tendsto_zero
variable [IsTopologicalRing S] [IsLinearTopology S S]
/-- The domain of evaluation of `MvPowerSeries`, as an ideal -/
@[simps]
def hasEvalIdeal : Ideal (σ → S) where
carrier := {a | HasEval a}
add_mem' := HasEval.add
zero_mem' := HasEval.zero
smul_mem' := HasEval.mul_left
theorem mem_hasEvalIdeal_iff {a : σ → S} :
a ∈ hasEvalIdeal ↔ HasEval a := by
simp [hasEvalIdeal]
end
/- ## Construction of an evaluation morphism for power series -/
section Evaluation
open WithPiTopology
variable {σ : Type*}
variable {R : Type*} [CommRing R] [UniformSpace R]
variable {S : Type*} [CommRing S] [UniformSpace S]
variable {φ : R →+* S}
-- We endow MvPowerSeries σ R with the product uniform structure
private instance : UniformSpace (MvPolynomial σ R) :=
comap toMvPowerSeries (Pi.uniformSpace _)
/-- The induced uniform structure of MvPolynomial σ R is an additive group uniform structure -/
private instance [IsUniformAddGroup R] : IsUniformAddGroup (MvPolynomial σ R) :=
IsUniformAddGroup.comap coeToMvPowerSeries.ringHom
theorem _root_.MvPolynomial.toMvPowerSeries_isUniformInducing :
IsUniformInducing (toMvPowerSeries (σ := σ) (R := R)) :=
(isUniformInducing_iff toMvPowerSeries).mpr rfl
theorem _root_.MvPolynomial.toMvPowerSeries_isDenseInducing :
IsDenseInducing (toMvPowerSeries (σ := σ) (R := R)) :=
toMvPowerSeries_isUniformInducing.isDenseInducing denseRange_toMvPowerSeries
variable {a : σ → S}
/- The evaluation map on multivariate polynomials is uniformly continuous
for the uniform structure induced by that on multivariate power series. -/
theorem _root_.MvPolynomial.toMvPowerSeries_uniformContinuous
[IsUniformAddGroup R] [IsUniformAddGroup S] [IsLinearTopology S S]
(hφ : Continuous φ) (ha : HasEval a) :
UniformContinuous (MvPolynomial.eval₂Hom φ a) := by
classical
apply uniformContinuous_of_continuousAt_zero
rw [ContinuousAt, map_zero, IsLinearTopology.hasBasis_ideal.tendsto_right_iff]
intro I hI
let n : σ → ℕ := fun s ↦ sInf {n : ℕ | (a s) ^ n.succ ∈ I}
have hn_ne : ∀ s, Set.Nonempty {n : ℕ | (a s) ^ n.succ ∈ I} := fun s ↦ by
rcases ha.hpow s |>.eventually_mem hI |>.exists_forall_of_atTop with ⟨n, hn⟩
use n
simpa using hn n.succ n.le_succ
have hn : Set.Finite (n.support) := by
change n =ᶠ[cofinite] 0
filter_upwards [ha.tendsto_zero.eventually_mem hI] with s has
simpa [n, Pi.zero_apply, Nat.sInf_eq_zero, or_iff_left (hn_ne s).ne_empty] using has
let n₀ : σ →₀ ℕ := .ofSupportFinite n hn
let D := Iic n₀
have hD : Set.Finite D := finite_Iic _
have : ∀ d ∈ D, ∀ᶠ (p : MvPolynomial σ R) in 𝓝 0, φ (p.coeff d) ∈ I := fun d hd ↦ by
have : Tendsto (φ ∘ coeff d ∘ toMvPowerSeries) (𝓝 0) (𝓝 0) :=
hφ.comp (continuous_coeff R d) |>.comp continuous_induced_dom |>.tendsto' 0 0 (map_zero _)
filter_upwards [this.eventually_mem hI] with f hf
simpa using hf
rw [← hD.eventually_all] at this
filter_upwards [this] with p hp
rw [coe_eval₂Hom, SetLike.mem_coe, eval₂_eq]
apply Ideal.sum_mem
intro d _
by_cases hd : d ∈ D
· exact Ideal.mul_mem_right _ _ (hp d hd)
· apply Ideal.mul_mem_left
simp only [mem_Iic, D, Finsupp.le_iff] at hd
push_neg at hd
rcases hd with ⟨s, hs', hs⟩
exact I.prod_mem hs' (I.pow_mem_of_pow_mem (Nat.sInf_mem (hn_ne s)) hs)
variable (φ a)
open scoped Classical in
/-- Evaluation of a multivariate power series at `f` at a point `a : σ → S`.
It coincides with the evaluation of `f` as a polynomial if `f` is the coercion of a polynomial.
Otherwise, it is only relevant if `φ` is continuous and `HasEval a`. -/
noncomputable def eval₂ (f : MvPowerSeries σ R) : S :=
if H : ∃ p : MvPolynomial σ R, p = f then (MvPolynomial.eval₂ φ a H.choose)
else IsDenseInducing.extend toMvPowerSeries_isDenseInducing (MvPolynomial.eval₂ φ a) f
@[simp, norm_cast]
theorem eval₂_coe (f : MvPolynomial σ R) :
MvPowerSeries.eval₂ φ a f = MvPolynomial.eval₂ φ a f := by
have : ∃ p : MvPolynomial σ R, (p : MvPowerSeries σ R) = f := ⟨f, rfl⟩
rw [eval₂, dif_pos this]
congr
rw [← MvPolynomial.coe_inj, this.choose_spec]
@[simp]
theorem eval₂_C (r : R) : eval₂ φ a (C r) = φ r := by
rw [← coe_C, eval₂_coe, MvPolynomial.eval₂_C]
@[simp]
theorem eval₂_X (s : σ) : eval₂ φ a (X s) = a s := by
rw [← coe_X, eval₂_coe, MvPolynomial.eval₂_X]
variable [IsTopologicalSemiring R] [IsUniformAddGroup R]
[IsUniformAddGroup S] [CompleteSpace S] [T2Space S]
[IsTopologicalRing S] [IsLinearTopology S S]
variable {φ a}
/-- Evaluation of power series at adequate elements, as a `RingHom` -/
noncomputable def eval₂Hom (hφ : Continuous φ) (ha : HasEval a) :
MvPowerSeries σ R →+* S :=
IsDenseInducing.extendRingHom (i := coeToMvPowerSeries.ringHom)
toMvPowerSeries_isUniformInducing
denseRange_toMvPowerSeries
(toMvPowerSeries_uniformContinuous hφ ha)
theorem eval₂Hom_eq_extend (hφ : Continuous φ) (ha : HasEval a) (f : MvPowerSeries σ R) :
eval₂Hom hφ ha f =
toMvPowerSeries_isDenseInducing.extend (MvPolynomial.eval₂ φ a) f :=
rfl
theorem coe_eval₂Hom (hφ : Continuous φ) (ha : HasEval a) :
⇑(eval₂Hom hφ ha) = eval₂ φ a := by
ext f
simp only [eval₂Hom_eq_extend, eval₂]
split_ifs with h
· obtain ⟨p, rfl⟩ := h
simpa [MvPolynomial.coe_eval₂Hom] using
toMvPowerSeries_isDenseInducing.extend_eq
(toMvPowerSeries_uniformContinuous hφ ha).continuous p
· rw [← eval₂Hom_eq_extend hφ ha]
-- Note: this is still true without the `T2Space` hypothesis, by arguing that the case
-- disjunction in the definition of `eval₂` only replaces some values by topologically
-- inseparable ones.
theorem uniformContinuous_eval₂ (hφ : Continuous φ) (ha : HasEval a) :
UniformContinuous (eval₂ φ a) := by
rw [← coe_eval₂Hom hφ ha]
exact uniformContinuous_uniformly_extend
toMvPowerSeries_isUniformInducing
denseRange_toMvPowerSeries
(toMvPowerSeries_uniformContinuous hφ ha)
theorem continuous_eval₂ (hφ : Continuous φ) (ha : HasEval a) :
Continuous (eval₂ φ a : MvPowerSeries σ R → S) :=
(uniformContinuous_eval₂ hφ ha).continuous
theorem hasSum_eval₂ (hφ : Continuous φ) (ha : HasEval a) (f : MvPowerSeries σ R) :
HasSum
(fun (d : σ →₀ ℕ) ↦ φ (coeff d f) * (d.prod fun s e => (a s) ^ e))
(MvPowerSeries.eval₂ φ a f) := by
rw [← coe_eval₂Hom hφ ha, eval₂Hom_eq_extend hφ ha]
convert (hasSum_of_monomials_self f).map (eval₂Hom hφ ha) (?_) with d
· simp only [Function.comp_apply, coe_eval₂Hom, ← MvPolynomial.coe_monomial,
eval₂_coe, eval₂_monomial]
· rw [coe_eval₂Hom]; exact continuous_eval₂ hφ ha
theorem eval₂_eq_tsum (hφ : Continuous φ) (ha : HasEval a) (f : MvPowerSeries σ R) :
MvPowerSeries.eval₂ φ a f =
∑' (d : σ →₀ ℕ), φ (coeff d f) * (d.prod fun s e => (a s) ^ e) :=
(hasSum_eval₂ hφ ha f).tsum_eq.symm
theorem eval₂_unique (hφ : Continuous φ) (ha : HasEval a)
{ε : MvPowerSeries σ R → S} (hε : Continuous ε)
(h : ∀ p : MvPolynomial σ R, ε p = MvPolynomial.eval₂ φ a p) :
ε = eval₂ φ a := by
rw [← coe_eval₂Hom hφ ha]
exact (toMvPowerSeries_isDenseInducing.extend_unique h hε).symm
theorem comp_eval₂ (hφ : Continuous φ) (ha : HasEval a)
{T : Type*} [UniformSpace T] [CompleteSpace T] [T2Space T]
[CommRing T] [IsTopologicalRing T] [IsLinearTopology T T] [IsUniformAddGroup T]
{ε : S →+* T} (hε : Continuous ε) :
ε ∘ eval₂ φ a = eval₂ (ε.comp φ) (ε ∘ a) := by
apply eval₂_unique _ (ha.map hε)
· exact Continuous.comp hε (continuous_eval₂ hφ ha)
· intro p
simp only [Function.comp_apply, eval₂_coe]
rw [← MvPolynomial.coe_eval₂Hom, ← comp_apply, MvPolynomial.comp_eval₂Hom,
MvPolynomial.coe_eval₂Hom]
· simp only [coe_comp, Continuous.comp hε hφ]
variable [Algebra R S] [ContinuousSMul R S]
/-- Evaluation of power series at adequate elements, as an `AlgHom` -/
noncomputable def aeval (ha : HasEval a) : MvPowerSeries σ R →ₐ[R] S where
toRingHom := MvPowerSeries.eval₂Hom (continuous_algebraMap R S) ha
commutes' r := by
simp only [toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, MonoidHom.coe_coe]
rw [← c_eq_algebraMap, coe_eval₂Hom, eval₂_C]
theorem coe_aeval (ha : HasEval a) :
↑(aeval ha) = eval₂ (algebraMap R S) a := by
simp only [aeval, AlgHom.coe_mk, coe_eval₂Hom]
theorem continuous_aeval (ha : HasEval a) :
Continuous (aeval ha : MvPowerSeries σ R → S) := by
rw [coe_aeval]
exact continuous_eval₂ (continuous_algebraMap R S) ha
@[simp]
theorem aeval_coe (ha : HasEval a) (p : MvPolynomial σ R) :
aeval ha (p : MvPowerSeries σ R) = p.aeval a := by
rw [coe_aeval, aeval_def, eval₂_coe]
theorem aeval_unique {ε : MvPowerSeries σ R →ₐ[R] S} (hε : Continuous ε) :
aeval (HasEval.X.map hε) = ε := by
apply DFunLike.ext'
rw [coe_aeval]
refine (eval₂_unique (continuous_algebraMap R S) (HasEval.X.map hε) hε ?_).symm
intro p
trans ε.comp (coeToMvPowerSeries.algHom R) p
· simp
conv_lhs => rw [← p.aeval_X_left_apply, MvPolynomial.comp_aeval_apply, MvPolynomial.aeval_def]
simp
theorem hasSum_aeval (ha : HasEval a) (f : MvPowerSeries σ R) :
HasSum (fun (d : σ →₀ ℕ) ↦ (coeff d f) • (d.prod fun s e => (a s) ^ e))
(MvPowerSeries.aeval ha f) := by
simp_rw [coe_aeval, ← algebraMap_smul (R := R) S, smul_eq_mul]
exact hasSum_eval₂ (continuous_algebraMap R S) ha f
theorem aeval_eq_sum (ha : HasEval a) (f : MvPowerSeries σ R) :
MvPowerSeries.aeval ha f =
tsum (fun (d : σ →₀ ℕ) ↦ (coeff d f) • (d.prod fun s e => (a s) ^ e)) :=
(hasSum_aeval ha f).tsum_eq.symm
theorem comp_aeval (ha : HasEval a)
{T : Type*} [CommRing T] [UniformSpace T] [IsUniformAddGroup T]
[IsTopologicalRing T] [IsLinearTopology T T]
[T2Space T] [Algebra R T] [ContinuousSMul R T] [CompleteSpace T]
{ε : S →ₐ[R] T} (hε : Continuous ε) :
ε.comp (aeval ha) = aeval (ha.map hε) := by
apply DFunLike.ext'
simp only [AlgHom.coe_comp, coe_aeval ha]
rw [← RingHom.coe_coe,
comp_eval₂ (continuous_algebraMap R S) ha (show Continuous (ε : S →+* T) from hε), coe_aeval]
congr!
simp only [AlgHom.comp_algebraMap_of_tower]
end Evaluation
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Trunc.lean | import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.Data.Finsupp.Interval
import Mathlib.Algebra.MvPolynomial.Eval
/-!
# Formal (multivariate) power series - Truncation
* `MvPowerSeries.trunc n φ` truncates a formal multivariate power series
to the multivariate polynomial that has the same coefficients as `φ`,
for all `m < n`, and `0` otherwise.
Note that here, `m` and `n` have types `σ →₀ ℕ`,
so that `m < n` means that `m ≠ n` and `m s ≤ n s` for all `s : σ`.
* `MvPowerSeries.trunc_one` : truncation of the unit power series
* `MvPowerSeries.trunc_C` : truncation of a constant
* `MvPowerSeries.trunc_C_mul` : truncation of constant multiple.
* `MvPowerSeries.trunc' n φ` truncates a formal multivariate power series
to the multivariate polynomial that has the same coefficients as `φ`,
for all `m ≤ n`, and `0` otherwise.
Here, `m` and `n` have types `σ →₀ ℕ` so that `m ≤ n` means that `m s ≤ n s` for all `s : σ`.
* `MvPowerSeries.coeff_mul_eq_coeff_trunc'_mul_trunc'` : compares the coefficients
of a product with those of the product of truncations.
* `MvPowerSeries.trunc'_one` : truncation of a the unit power series.
* `MvPowerSeries.trunc'_C` : truncation of a constant.
* `MvPowerSeries.trunc'_C_mul` : truncation of a constant multiple.
* `MvPowerSeries.trunc'_map` : image of a truncation under a change of rings
## TODO
* Unify both versions using a general purpose API
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
namespace MvPowerSeries
open Finsupp
variable {σ R S : Type*}
section TruncLT
variable [DecidableEq σ] [CommSemiring R] (n : σ →₀ ℕ)
/-- Auxiliary definition for the truncation function. -/
def truncFun (φ : MvPowerSeries σ R) : MvPolynomial σ R :=
∑ m ∈ Finset.Iio n, MvPolynomial.monomial m (coeff m φ)
theorem coeff_truncFun (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
(truncFun n φ).coeff m = if m < n then coeff m φ else 0 := by
classical
simp [truncFun, MvPolynomial.coeff_sum]
variable (R) in
/-- The `n`th truncation of a multivariate formal power series to a multivariate polynomial
If `f : MvPowerSeries σ R` and `n : σ →₀ ℕ` is a (finitely-supported) function from `σ`
to the naturals, then `trunc' R n f` is the multivariable power series obtained from `f`
by keeping only the monomials $c\prod_i X_i^{a_i}$ where `a i ≤ n i` for all `i`
and $a i < n i` for some `i`. -/
def trunc : MvPowerSeries σ R →+ MvPolynomial σ R where
toFun := truncFun n
map_zero' := by
classical
ext
simp [coeff_truncFun]
map_add' := by
classical
intro x y
ext m
simp only [coeff_truncFun, MvPolynomial.coeff_add, ite_add_ite, ← map_add, add_zero]
theorem coeff_trunc (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
(trunc R n φ).coeff m = if m < n then coeff m φ else 0 := by
classical simp [trunc, coeff_truncFun]
@[simp]
theorem trunc_one (n : σ →₀ ℕ) (hnn : n ≠ 0) : trunc R n 1 = 1 :=
MvPolynomial.ext _ _ fun m ↦ by
classical
rw [coeff_trunc, coeff_one]
split_ifs with H H'
· subst m
simp
· symm
rw [MvPolynomial.coeff_one]
exact if_neg (Ne.symm H')
· symm
rw [MvPolynomial.coeff_one]
refine if_neg ?_
rintro rfl
apply H
exact Ne.bot_lt hnn
@[simp]
theorem trunc_C (n : σ →₀ ℕ) (hnn : n ≠ 0) (a : R) : trunc R n (C a) = MvPolynomial.C a :=
MvPolynomial.ext _ _ fun m ↦ by
classical
rw [coeff_trunc, coeff_C, MvPolynomial.coeff_C]
split_ifs with H <;> first | rfl | try simp_all only [ne_eq, not_true_eq_false]
exfalso; apply H; subst m; exact Ne.bot_lt hnn
@[simp]
theorem trunc_C_mul (n : σ →₀ ℕ) (a : R) (p : MvPowerSeries σ R) :
trunc R n (C a * p) = MvPolynomial.C a * trunc R n p := by
ext m; simp [coeff_trunc]
@[simp]
theorem trunc_map [CommSemiring S] (n : σ →₀ ℕ) (f : R →+* S) (p : MvPowerSeries σ R) :
trunc S n (map f p) = MvPolynomial.map f (trunc R n p) := by
ext m; simp [coeff_trunc, MvPolynomial.coeff_map, apply_ite f]
end TruncLT
section TruncLE
variable [DecidableEq σ] [CommSemiring R] (n : σ →₀ ℕ)
/-- Auxiliary definition for the truncation function. -/
def truncFun' (φ : MvPowerSeries σ R) : MvPolynomial σ R :=
∑ m ∈ Finset.Iic n, MvPolynomial.monomial m (coeff m φ)
/-- Coefficients of the truncated function. -/
theorem coeff_truncFun' (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
(truncFun' n φ).coeff m = if m ≤ n then coeff m φ else 0 := by
classical
simp [truncFun', MvPolynomial.coeff_sum]
variable (R) in
/--
The `n`th truncation of a multivariate formal power series to a multivariate polynomial.
If `f : MvPowerSeries σ R` and `n : σ →₀ ℕ` is a (finitely-supported) function from `σ`
to the naturals, then `trunc' R n f` is the multivariable power series obtained from `f`
by keeping only the monomials $c\prod_i X_i^{a_i}$ where `a i ≤ n i` for all `i`. -/
def trunc' : MvPowerSeries σ R →+ MvPolynomial σ R where
toFun := truncFun' n
map_zero' := by
ext
simp only [coeff_truncFun', map_zero, ite_self, MvPolynomial.coeff_zero]
map_add' x y := by
ext m
simp only [coeff_truncFun', MvPolynomial.coeff_add]
rw [ite_add_ite, ← map_add, zero_add]
/-- Coefficients of the truncation of a multivariate power series. -/
theorem coeff_trunc' (m : σ →₀ ℕ) (φ : MvPowerSeries σ R) :
(trunc' R n φ).coeff m = if m ≤ n then coeff m φ else 0 :=
coeff_truncFun' n m φ
/-- Truncation of the multivariate power series `1` -/
@[simp]
theorem trunc'_one (n : σ →₀ ℕ) : trunc' R n 1 = 1 :=
MvPolynomial.ext _ _ fun m ↦ by
classical
rw [coeff_trunc', coeff_one]
split_ifs with H H'
· subst m; simp only [MvPolynomial.coeff_zero_one]
· rw [MvPolynomial.coeff_one, if_neg (Ne.symm H')]
· rw [MvPolynomial.coeff_one, if_neg ?_]
rintro rfl
exact H (zero_le n)
@[simp]
theorem trunc'_C (n : σ →₀ ℕ) (a : R) :
trunc' R n (C a) = MvPolynomial.C a :=
MvPolynomial.ext _ _ fun m ↦ by
classical
rw [coeff_trunc', coeff_C, MvPolynomial.coeff_C]
split_ifs with H <;> first | rfl | try simp_all
exfalso; apply H; subst m; exact zero_le n
/-- Coefficients of the truncation of a product of two multivariate power series -/
theorem coeff_mul_eq_coeff_trunc'_mul_trunc' (n : σ →₀ ℕ)
(f g : MvPowerSeries σ R) {m : σ →₀ ℕ} (h : m ≤ n) :
coeff m (f * g) = (trunc' R n f * trunc' R n g).coeff m := by
classical
simp only [MvPowerSeries.coeff_mul, MvPolynomial.coeff_mul]
apply Finset.sum_congr rfl
rintro ⟨i, j⟩ hij
simp only [mem_antidiagonal] at hij
rw [← hij] at h
simp only
apply congr_arg₂
· rw [coeff_trunc', if_pos (le_trans le_self_add h)]
· rw [coeff_trunc', if_pos (le_trans le_add_self h)]
@[simp]
theorem trunc'_C_mul (n : σ →₀ ℕ) (a : R) (p : MvPowerSeries σ R) :
trunc' R n (C a * p) = MvPolynomial.C a * trunc' R n p := by
ext m; simp [coeff_trunc']
@[simp]
theorem trunc'_map [CommSemiring S] (n : σ →₀ ℕ) (f : R →+* S) (p : MvPowerSeries σ R) :
trunc' S n (map f p) = MvPolynomial.map f (trunc' R n p) := by
ext m; simp [coeff_trunc', MvPolynomial.coeff_map, apply_ite f]
end TruncLE
end MvPowerSeries
end |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/NoZeroDivisors.lean | import Mathlib.Data.Finsupp.WellFounded
import Mathlib.RingTheory.MvPowerSeries.LexOrder
import Mathlib.RingTheory.MvPowerSeries.Order
/-! # ZeroDivisors in a MvPowerSeries ring
- `mem_nonZeroDivisors_of_constantCoeff` proves that
a multivariate power series whose constant coefficient is not a zero divisor
is itself not a zero divisor
- `MvPowerSeries.order_mul` : multiplicativity of `MvPowerSeries.order`
if the semiring `R` has no zero divisors
## Instance
If `R` has `NoZeroDivisors`, then so does `MvPowerSeries σ R`.
## TODO
* Transfer/adapt these results to `HahnSeries`.
## Remark
The analogue of `Polynomial.notMem_nonZeroDivisors_iff`
(McCoy theorem) holds for power series over a Noetherian ring,
but not in general. See [Fields1971]
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
namespace MvPowerSeries
open Finsupp nonZeroDivisors
variable {σ R : Type*}
section Semiring
variable [Semiring R]
theorem mem_nonZeroDivisorsRight_of_constantCoeff {φ : MvPowerSeries σ R}
(hφ : constantCoeff φ ∈ nonZeroDivisorsRight R) :
φ ∈ nonZeroDivisorsRight (MvPowerSeries σ R) := by
classical
intro x hx
ext d
apply WellFoundedLT.induction d
intro e he
rw [map_zero, ← mul_right_mem_nonZeroDivisorsRight_eq_zero_iff hφ,
← map_zero (f := coeff e), ← hx]
convert (coeff_mul e x φ).symm
rw [Finset.sum_eq_single (e, 0), coeff_zero_eq_constantCoeff]
· rintro ⟨u, _⟩ huv _
suffices u < e by simp only [he u this, zero_mul, map_zero]
apply lt_of_le_of_ne
· simp only [← mem_antidiagonal.mp huv, le_add_iff_nonneg_right, zero_le]
· rintro rfl
simp_all
· simp only [mem_antidiagonal, add_zero, not_true_eq_false, coeff_zero_eq_constantCoeff,
false_implies]
-- TODO: derive from `mem_nonZeroDivisorsRight_of_constantCoeff` using `MulOpposite`
theorem mem_nonZeroDivisorsLeft_of_constantCoeff {φ : MvPowerSeries σ R}
(hφ : constantCoeff φ ∈ nonZeroDivisorsLeft R) :
φ ∈ nonZeroDivisorsLeft (MvPowerSeries σ R) := by
classical
intro x hx
ext d
apply WellFoundedLT.induction d
intro e he
rw [map_zero, ← mul_left_mem_nonZeroDivisorsLeft_eq_zero_iff hφ,
← map_zero (f := coeff e), ← hx]
convert (coeff_mul e φ x).symm
rw [Finset.sum_eq_single (0, e), coeff_zero_eq_constantCoeff]
· rintro ⟨_, u⟩ huv _
suffices u < e by simp only [he u this, mul_zero, map_zero]
apply lt_of_le_of_ne
· simp only [← mem_antidiagonal.mp huv, le_add_iff_nonneg_left, zero_le]
· rintro rfl
simp_all
· simp only [mem_antidiagonal, zero_add, not_true_eq_false, coeff_zero_eq_constantCoeff,
false_implies]
/-- A multivariate power series is not a zero divisor
when its constant coefficient is not a zero divisor -/
theorem mem_nonZeroDivisors_of_constantCoeff {φ : MvPowerSeries σ R}
(hφ : constantCoeff φ ∈ R⁰) :
φ ∈ (MvPowerSeries σ R)⁰ :=
⟨mem_nonZeroDivisorsLeft_of_constantCoeff hφ.1, mem_nonZeroDivisorsRight_of_constantCoeff hφ.2⟩
lemma monomial_mem_nonzeroDivisorsLeft {n : σ →₀ ℕ} {r} :
monomial n r ∈ nonZeroDivisorsLeft (MvPowerSeries σ R) ↔ r ∈ nonZeroDivisorsLeft R := by
constructor
· intro H s hrs
have := H (C s) (by rw [← monomial_zero_eq_C, monomial_mul_monomial]; ext; simp [hrs])
simpa using congr(coeff 0 $(this))
· intro H p hrp
ext i
have := congr(coeff (i + n) $hrp)
rw [coeff_monomial_mul, if_pos le_add_self, add_tsub_cancel_right] at this
simpa using H _ this
-- TODO: reduce duplication
lemma monomial_mem_nonzeroDivisorsRight {n : σ →₀ ℕ} {r} :
monomial n r ∈ nonZeroDivisorsRight (MvPowerSeries σ R) ↔ r ∈ nonZeroDivisorsRight R := by
constructor
· intro H s hrs
have := H (C s) (by rw [← monomial_zero_eq_C, monomial_mul_monomial]; ext; simp [hrs])
simpa using congr(coeff 0 $(this))
· intro H p hrp
ext i
have := congr(coeff (i + n) $hrp)
rw [coeff_mul_monomial, if_pos le_add_self, add_tsub_cancel_right] at this
simpa using H _ this
lemma monomial_mem_nonzeroDivisors {n : σ →₀ ℕ} {r} :
monomial n r ∈ (MvPowerSeries σ R)⁰ ↔ r ∈ R⁰ :=
monomial_mem_nonzeroDivisorsLeft.and monomial_mem_nonzeroDivisorsRight
lemma X_mem_nonzeroDivisors {i : σ} :
X i ∈ (MvPowerSeries σ R)⁰ := by
rw [X, monomial_mem_nonzeroDivisors]
exact Submonoid.one_mem R⁰
end Semiring
variable [Semiring R] [NoZeroDivisors R]
instance : NoZeroDivisors (MvPowerSeries σ R) where
eq_zero_or_eq_zero_of_mul_eq_zero {φ ψ} h := by
letI : LinearOrder σ := LinearOrder.swap σ WellOrderingRel.isWellOrder.linearOrder
letI : WellFoundedGT σ := by
change IsWellFounded σ fun x y ↦ WellOrderingRel x y
exact IsWellOrder.toIsWellFounded
simpa only [← lexOrder_eq_top_iff_eq_zero, lexOrder_mul, WithTop.add_eq_top] using h
theorem weightedOrder_mul (w : σ → ℕ) (f g : MvPowerSeries σ R) :
(f * g).weightedOrder w = f.weightedOrder w + g.weightedOrder w := by
apply le_antisymm _ (le_weightedOrder_mul w)
by_cases hf : f.weightedOrder w < ⊤
· by_cases hg : g.weightedOrder w < ⊤
· let p := (f.weightedOrder w).toNat
have hp : p = f.weightedOrder w := by
simpa only [p, ENat.coe_toNat_eq_self, ← lt_top_iff_ne_top]
let q := (g.weightedOrder w).toNat
have hq : q = g.weightedOrder w := by
simpa only [q, ENat.coe_toNat_eq_self, ← lt_top_iff_ne_top]
have : f.weightedHomogeneousComponent w p * g.weightedHomogeneousComponent w q ≠ 0 := by
simp only [ne_eq, mul_eq_zero]
intro H
rcases H with H | H <;>
· refine weightedHomogeneousComponent_of_weightedOrder ?_ H
simp only [ENat.coe_toNat_eq_self, ne_eq, weightedOrder_eq_top_iff, p, q]
rw [← ne_eq, ne_zero_iff_weightedOrder_finite w]
exact ENat.coe_toNat (ne_top_of_lt (by simpa))
rw [← weightedHomogeneousComponent_mul_of_le_weightedOrder
(le_of_eq hp) (le_of_eq hq)] at this
rw [← hp, ← hq, ← Nat.cast_add, ← not_lt]
intro H
apply this
apply weightedHomogeneousComponent_of_lt_weightedOrder_eq_zero H
· rw [not_lt_top_iff] at hg
simp [hg]
· rw [not_lt_top_iff] at hf
simp [hf]
theorem weightedOrder_prod {R : Type*} [CommSemiring R] [NoZeroDivisors R] [Nontrivial R]
{ι : Type*} (w : σ → ℕ) (f : ι → MvPowerSeries σ R) (s : Finset ι) :
(∏ i ∈ s, f i).weightedOrder w = ∑ i ∈ s, (f i).weightedOrder w := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha ih => rw [Finset.sum_cons ha, Finset.prod_cons ha, weightedOrder_mul, ih]
theorem order_mul (f g : MvPowerSeries σ R) :
(f * g).order = f.order + g.order :=
weightedOrder_mul _ f g
theorem order_prod {R : Type*} [CommSemiring R] [NoZeroDivisors R] [Nontrivial R]
{ι : Type*} (f : ι → MvPowerSeries σ R) (s : Finset ι) :
(∏ i ∈ s, f i).order = ∑ i ∈ s, (f i).order := weightedOrder_prod _ _ _
end MvPowerSeries
end |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/Basic.lean | import Mathlib.Algebra.Order.Antidiag.Finsupp
import Mathlib.Data.Finsupp.Weight
import Mathlib.Tactic.Linarith
import Mathlib.LinearAlgebra.Pi
import Mathlib.Algebra.MvPolynomial.Eval
/-!
# Formal (multivariate) power series
This file defines multivariate formal power series
and develops the basic properties of these objects.
A formal power series is to a polynomial like an infinite sum is to a finite sum.
We provide the natural inclusion from multivariate polynomials to multivariate formal power series.
## Main definitions
- `MvPowerSeries.C`: constant power series
- `MvPowerSeries.X`: the indeterminates
- `MvPowerSeries.coeff`, `MvPowerSeries.constantCoeff`:
the coefficients of a `MvPowerSeries`, its constant coefficient
- `MvPowerSeries.monomial`: the monomials
- `MvPowerSeries.coeff_mul`: computes the coefficients of the product of two `MvPowerSeries`
- `MvPowerSeries.coeff_prod` : computes the coefficients of products of `MvPowerSeries`
- `MvPowerSeries.coeff_pow` : computes the coefficients of powers of a `MvPowerSeries`
- `MvPowerSeries.coeff_eq_zero_of_constantCoeff_nilpotent`: if the constant coefficient
of a `MvPowerSeries` is nilpotent, then some coefficients of its powers are automatically zero
- `MvPowerSeries.map`: apply a `RingHom` to the coefficients of a `MvPowerSeries` (as a `RingHom)
- `MvPowerSeries.X_pow_dvd_iff`, `MvPowerSeries.X_dvd_iff`: equivalent
conditions for (a power of) an indeterminate to divide a `MvPowerSeries`
- `MvPolynomial.toMvPowerSeries`: the canonical coercion from `MvPolynomial` to `MvPowerSeries`
## Note
This file sets up the (semi)ring structure on multivariate power series:
additional results are in:
* `Mathlib/RingTheory/MvPowerSeries/Inverse.lean` : invertibility,
formal power series over a local ring form a local ring;
* `Mathlib/RingTheory/MvPowerSeries/Trunc.lean`: truncation of power series.
In `Mathlib/RingTheory/PowerSeries/Basic.lean`, formal power series in one variable
will be obtained as a particular case, defined by
`PowerSeries R := MvPowerSeries Unit R`.
See that file for a specific description.
## Implementation notes
In this file we define multivariate formal power series with
variables indexed by `σ` and coefficients in `R` as
`MvPowerSeries σ R := (σ →₀ ℕ) → R`.
Unfortunately there is not yet enough API to show that they are the completion
of the ring of multivariate polynomials. However, we provide most of the infrastructure
that is needed to do this. Once I-adic completion (topological or algebraic) is available
it should not be hard to fill in the details.
-/
noncomputable section
open Finset (antidiagonal mem_antidiagonal)
/-- Multivariate formal power series, where `σ` is the index set of the variables
and `R` is the coefficient ring. -/
def MvPowerSeries (σ : Type*) (R : Type*) :=
(σ →₀ ℕ) → R
namespace MvPowerSeries
open Finsupp
variable {σ R : Type*}
instance [Inhabited R] : Inhabited (MvPowerSeries σ R) :=
⟨fun _ => default⟩
instance [Zero R] : Zero (MvPowerSeries σ R) :=
Pi.instZero
instance [AddMonoid R] : AddMonoid (MvPowerSeries σ R) :=
Pi.addMonoid
instance [AddGroup R] : AddGroup (MvPowerSeries σ R) :=
Pi.addGroup
instance [AddCommMonoid R] : AddCommMonoid (MvPowerSeries σ R) :=
Pi.addCommMonoid
instance [AddCommGroup R] : AddCommGroup (MvPowerSeries σ R) :=
Pi.addCommGroup
instance [Nontrivial R] : Nontrivial (MvPowerSeries σ R) :=
Function.nontrivial
instance {A} [Semiring R] [AddCommMonoid A] [Module R A] : Module R (MvPowerSeries σ A) :=
Pi.module _ _ _
instance {A S} [Semiring R] [Semiring S] [AddCommMonoid A] [Module R A] [Module S A] [SMul R S]
[IsScalarTower R S A] : IsScalarTower R S (MvPowerSeries σ A) :=
Pi.isScalarTower
section Semiring
variable [Semiring R]
/-- The `n`th monomial as multivariate formal power series:
it is defined as the `R`-linear map from `R` to the semiring
of multivariate formal power series associating to each `a`
the map sending `n : σ →₀ ℕ` to the value `a`
and sending all other `x : σ →₀ ℕ` different from `n` to `0`. -/
def monomial (n : σ →₀ ℕ) : R →ₗ[R] MvPowerSeries σ R :=
letI := Classical.decEq σ
LinearMap.single R (fun _ ↦ R) n
/-- The `n`th coefficient of a multivariate formal power series. -/
def coeff (n : σ →₀ ℕ) : MvPowerSeries σ R →ₗ[R] R :=
LinearMap.proj n
theorem coeff_apply (f : MvPowerSeries σ R) (d : σ →₀ ℕ) : coeff d f = f d :=
rfl
/-- Two multivariate formal power series are equal if all their coefficients are equal. -/
@[ext]
theorem ext {φ ψ : MvPowerSeries σ R} (h : ∀ n : σ →₀ ℕ, coeff n φ = coeff n ψ) : φ = ψ :=
funext h
/-- Two multivariate formal power series are equal
if and only if all their coefficients are equal. -/
add_decl_doc MvPowerSeries.ext_iff
theorem monomial_def [DecidableEq σ] (n : σ →₀ ℕ) :
monomial n = LinearMap.single R (fun _ ↦ R) n := by
rw [monomial]
-- unify the `Decidable` arguments
convert rfl
theorem coeff_monomial [DecidableEq σ] (m n : σ →₀ ℕ) (a : R) :
coeff m (monomial n a) = if m = n then a else 0 := by
dsimp only [coeff, MvPowerSeries]
rw [monomial_def, LinearMap.proj_apply (i := m), LinearMap.single_apply, Pi.single_apply]
@[simp]
theorem coeff_monomial_same (n : σ →₀ ℕ) (a : R) : coeff n (monomial n a) = a := by
classical
rw [monomial_def]
exact Pi.single_eq_same _ _
theorem coeff_monomial_ne {m n : σ →₀ ℕ} (h : m ≠ n) (a : R) : coeff m (monomial n a) = 0 := by
classical
rw [monomial_def]
exact Pi.single_eq_of_ne h _
theorem eq_of_coeff_monomial_ne_zero {m n : σ →₀ ℕ} {a : R} (h : coeff m (monomial n a) ≠ 0) :
m = n :=
by_contra fun h' => h <| coeff_monomial_ne h' a
@[simp]
theorem coeff_comp_monomial (n : σ →₀ ℕ) : (coeff (R := R) n).comp (monomial n) = LinearMap.id :=
LinearMap.ext <| coeff_monomial_same n
@[simp]
theorem coeff_zero (n : σ →₀ ℕ) : coeff n (0 : MvPowerSeries σ R) = 0 :=
rfl
theorem eq_zero_iff_forall_coeff_zero {f : MvPowerSeries σ R} :
f = 0 ↔ (∀ d : σ →₀ ℕ, coeff d f = 0) :=
MvPowerSeries.ext_iff
theorem ne_zero_iff_exists_coeff_ne_zero (f : MvPowerSeries σ R) :
f ≠ 0 ↔ (∃ d : σ →₀ ℕ, coeff d f ≠ 0) := by
simp only [MvPowerSeries.ext_iff, ne_eq, coeff_zero, not_forall]
variable (m n : σ →₀ ℕ) (φ ψ : MvPowerSeries σ R)
instance : One (MvPowerSeries σ R) :=
⟨monomial (0 : σ →₀ ℕ) 1⟩
theorem coeff_one [DecidableEq σ] : coeff n (1 : MvPowerSeries σ R) = if n = 0 then 1 else 0 :=
coeff_monomial _ _ _
theorem coeff_zero_one : coeff (R := R) (0 : σ →₀ ℕ) 1 = 1 :=
coeff_monomial_same 0 1
theorem monomial_zero_one : monomial (R := R) (0 : σ →₀ ℕ) 1 = 1 :=
rfl
instance : AddMonoidWithOne (MvPowerSeries σ R) :=
{ show AddMonoid (MvPowerSeries σ R) by infer_instance with
natCast := fun n => monomial 0 n
natCast_zero := by simp [Nat.cast]
natCast_succ := by simp [Nat.cast, monomial_zero_one] }
instance : Mul (MvPowerSeries σ R) :=
letI := Classical.decEq σ
⟨fun φ ψ n => ∑ p ∈ antidiagonal n, coeff p.1 φ * coeff p.2 ψ⟩
theorem coeff_mul [DecidableEq σ] :
coeff n (φ * ψ) = ∑ p ∈ antidiagonal n, coeff p.1 φ * coeff p.2 ψ := by
refine Finset.sum_congr ?_ fun _ _ => rfl
rw [Subsingleton.elim (Classical.decEq σ) ‹DecidableEq σ›]
protected theorem zero_mul : (0 : MvPowerSeries σ R) * φ = 0 :=
ext fun n => by classical simp [coeff_mul]
protected theorem mul_zero : φ * 0 = 0 :=
ext fun n => by classical simp [coeff_mul]
theorem coeff_monomial_mul (a : R) :
coeff m (monomial n a * φ) = if n ≤ m then a * coeff (m - n) φ else 0 := by
classical
have :
∀ p ∈ antidiagonal m,
coeff (p : (σ →₀ ℕ) × (σ →₀ ℕ)).1 (monomial n a) * coeff p.2 φ ≠ 0 → p.1 = n :=
fun p _ hp => eq_of_coeff_monomial_ne_zero (left_ne_zero_of_mul hp)
rw [coeff_mul, ← Finset.sum_filter_of_ne this, Finset.filter_fst_eq_antidiagonal _ n,
Finset.sum_ite_index]
simp only [Finset.sum_singleton, coeff_monomial_same, Finset.sum_empty]
theorem coeff_mul_monomial (a : R) :
coeff m (φ * monomial n a) = if n ≤ m then coeff (m - n) φ * a else 0 := by
classical
have :
∀ p ∈ antidiagonal m,
coeff (p : (σ →₀ ℕ) × (σ →₀ ℕ)).1 φ * coeff p.2 (monomial n a) ≠ 0 → p.2 = n :=
fun p _ hp => eq_of_coeff_monomial_ne_zero (right_ne_zero_of_mul hp)
rw [coeff_mul, ← Finset.sum_filter_of_ne this, Finset.filter_snd_eq_antidiagonal _ n,
Finset.sum_ite_index]
simp only [Finset.sum_singleton, coeff_monomial_same, Finset.sum_empty]
theorem coeff_add_monomial_mul (a : R) :
coeff (m + n) (monomial m a * φ) = a * coeff n φ := by
rw [coeff_monomial_mul, if_pos, add_tsub_cancel_left]
exact le_add_right le_rfl
theorem coeff_add_mul_monomial (a : R) :
coeff (m + n) (φ * monomial n a) = coeff m φ * a := by
rw [coeff_mul_monomial, if_pos, add_tsub_cancel_right]
exact le_add_left le_rfl
@[simp]
theorem commute_monomial {a : R} {n} :
Commute φ (monomial n a) ↔ ∀ m, Commute (coeff m φ) a := by
rw [commute_iff_eq, MvPowerSeries.ext_iff]
refine ⟨fun h m => ?_, fun h m => ?_⟩
· have := h (m + n)
rwa [coeff_add_mul_monomial, add_comm, coeff_add_monomial_mul] at this
· rw [coeff_mul_monomial, coeff_monomial_mul]
split_ifs <;> [apply h; rfl]
protected theorem one_mul : (1 : MvPowerSeries σ R) * φ = φ :=
ext fun n => by simpa using coeff_add_monomial_mul 0 n φ 1
protected theorem mul_one : φ * 1 = φ :=
ext fun n => by simpa using coeff_add_mul_monomial n 0 φ 1
protected theorem mul_add (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : φ₁ * (φ₂ + φ₃) = φ₁ * φ₂ + φ₁ * φ₃ :=
ext fun n => by
classical simp only [coeff_mul, mul_add, Finset.sum_add_distrib, LinearMap.map_add]
protected theorem add_mul (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : (φ₁ + φ₂) * φ₃ = φ₁ * φ₃ + φ₂ * φ₃ :=
ext fun n => by
classical simp only [coeff_mul, add_mul, Finset.sum_add_distrib, LinearMap.map_add]
protected theorem mul_assoc (φ₁ φ₂ φ₃ : MvPowerSeries σ R) : φ₁ * φ₂ * φ₃ = φ₁ * (φ₂ * φ₃) := by
ext1 n
classical
simp only [coeff_mul, Finset.sum_mul, Finset.mul_sum, Finset.sum_sigma']
apply Finset.sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l + j), (l, j)⟩)
(fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i + k, l), (i, k)⟩) <;> aesop (add simp [add_assoc, mul_assoc])
instance : Semiring (MvPowerSeries σ R) :=
{ inferInstanceAs (AddMonoidWithOne (MvPowerSeries σ R)),
inferInstanceAs (Mul (MvPowerSeries σ R)),
inferInstanceAs (AddCommMonoid (MvPowerSeries σ R)) with
mul_one := MvPowerSeries.mul_one
one_mul := MvPowerSeries.one_mul
mul_assoc := MvPowerSeries.mul_assoc
mul_zero := MvPowerSeries.mul_zero
zero_mul := MvPowerSeries.zero_mul
left_distrib := MvPowerSeries.mul_add
right_distrib := MvPowerSeries.add_mul }
end Semiring
instance [CommSemiring R] : CommSemiring (MvPowerSeries σ R) :=
{ show Semiring (MvPowerSeries σ R) by infer_instance with
mul_comm := fun φ ψ =>
ext fun n => by
classical
simpa only [coeff_mul, mul_comm] using
sum_antidiagonal_swap n fun a b => coeff a φ * coeff b ψ }
instance [Ring R] : Ring (MvPowerSeries σ R) :=
{ inferInstanceAs (Semiring (MvPowerSeries σ R)),
inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with }
instance [CommRing R] : CommRing (MvPowerSeries σ R) :=
{ inferInstanceAs (CommSemiring (MvPowerSeries σ R)),
inferInstanceAs (AddCommGroup (MvPowerSeries σ R)) with }
section Semiring
variable [Semiring R]
theorem monomial_mul_monomial (m n : σ →₀ ℕ) (a b : R) :
monomial m a * monomial n b = monomial (m + n) (a * b) := by
classical
ext k
simp only [coeff_mul_monomial, coeff_monomial]
split_ifs with h₁ h₂ h₃ h₃ h₂ <;> try rfl
· rw [← h₂, tsub_add_cancel_of_le h₁] at h₃
exact (h₃ rfl).elim
· rw [h₃, add_tsub_cancel_right] at h₂
exact (h₂ rfl).elim
· exact zero_mul b
· rw [h₂] at h₁
exact (h₁ <| le_add_left le_rfl).elim
/-- The constant multivariate formal power series. -/
def C : R →+* MvPowerSeries σ R :=
{ monomial (0 : σ →₀ ℕ) with
map_one' := rfl
map_mul' := fun a b => Eq.trans (by simp) (monomial_mul_monomial _ _ a b).symm
map_zero' := (monomial 0).map_zero }
@[simp]
theorem monomial_zero_eq_C : ⇑(monomial (R := R) (0 : σ →₀ ℕ)) = C :=
rfl
theorem monomial_zero_eq_C_apply (a : R) : monomial (0 : σ →₀ ℕ) a = C a :=
rfl
theorem coeff_C [DecidableEq σ] (n : σ →₀ ℕ) (a : R) :
coeff n (C a) = if n = 0 then a else 0 :=
coeff_monomial _ _ _
theorem coeff_zero_C (a : R) : coeff (0 : σ →₀ ℕ) (C a) = a :=
coeff_monomial_same 0 a
/-- The variables of the multivariate formal power series ring. -/
def X (s : σ) : MvPowerSeries σ R :=
monomial (single s 1) 1
theorem coeff_X [DecidableEq σ] (n : σ →₀ ℕ) (s : σ) :
coeff n (X s : MvPowerSeries σ R) = if n = single s 1 then 1 else 0 :=
coeff_monomial _ _ _
theorem coeff_index_single_X [DecidableEq σ] (s t : σ) :
coeff (single t 1) (X s : MvPowerSeries σ R) = if t = s then 1 else 0 := by
simp only [coeff_X, single_left_inj (one_ne_zero : (1 : ℕ) ≠ 0)]
@[simp]
theorem coeff_index_single_self_X (s : σ) : coeff (single s 1) (X s : MvPowerSeries σ R) = 1 :=
coeff_monomial_same _ _
theorem coeff_zero_X (s : σ) : coeff (0 : σ →₀ ℕ) (X s : MvPowerSeries σ R) = 0 := by
classical
rw [coeff_X, if_neg]
intro h
exact one_ne_zero (single_eq_zero.mp h.symm)
theorem commute_X (φ : MvPowerSeries σ R) (s : σ) : Commute φ (X s) :=
φ.commute_monomial.mpr fun _m => Commute.one_right _
theorem X_mul {φ : MvPowerSeries σ R} {s : σ} : X s * φ = φ * X s :=
φ.commute_X s |>.symm.eq
theorem commute_X_pow (φ : MvPowerSeries σ R) (s : σ) (n : ℕ) : Commute φ (X s ^ n) :=
φ.commute_X s |>.pow_right _
theorem X_pow_mul {φ : MvPowerSeries σ R} {s : σ} {n : ℕ} : X s ^ n * φ = φ * X s ^ n :=
φ.commute_X_pow s n |>.symm.eq
theorem X_def (s : σ) : X s = monomial (single s 1) 1 :=
rfl
theorem X_pow_eq (s : σ) (n : ℕ) : (X s : MvPowerSeries σ R) ^ n = monomial (single s n) 1 := by
induction n with
| zero => simp
| succ n ih => rw [pow_succ, ih, Finsupp.single_add, X, monomial_mul_monomial, one_mul]
theorem coeff_X_pow [DecidableEq σ] (m : σ →₀ ℕ) (s : σ) (n : ℕ) :
coeff m ((X s : MvPowerSeries σ R) ^ n) = if m = single s n then 1 else 0 := by
rw [X_pow_eq s n, coeff_monomial]
@[simp]
theorem coeff_mul_C (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) (a : R) :
coeff n (φ * C a) = coeff n φ * a := by simpa using coeff_add_mul_monomial n 0 φ a
@[simp]
theorem coeff_C_mul (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) (a : R) :
coeff n (C a * φ) = a * coeff n φ := by simpa using coeff_add_monomial_mul 0 n φ a
theorem coeff_zero_mul_X (φ : MvPowerSeries σ R) (s : σ) : coeff (0 : σ →₀ ℕ) (φ * X s) = 0 := by
have : ¬single s 1 ≤ 0 := fun h => by simpa using h s
simp only [X, coeff_mul_monomial, if_neg this]
theorem coeff_zero_X_mul (φ : MvPowerSeries σ R) (s : σ) : coeff (0 : σ →₀ ℕ) (X s * φ) = 0 := by
rw [← (φ.commute_X s).eq, coeff_zero_mul_X]
/-- The constant coefficient of a formal power series. -/
def constantCoeff : MvPowerSeries σ R →+* R :=
{ coeff (0 : σ →₀ ℕ) with
toFun := coeff (0 : σ →₀ ℕ)
map_one' := coeff_zero_one
map_mul' := fun φ ψ => by classical simp [coeff_mul]
map_zero' := LinearMap.map_zero _ }
@[simp]
theorem coeff_zero_eq_constantCoeff : ⇑(coeff (R := R) (0 : σ →₀ ℕ)) = constantCoeff :=
rfl
theorem coeff_zero_eq_constantCoeff_apply (φ : MvPowerSeries σ R) :
coeff (0 : σ →₀ ℕ) φ = constantCoeff φ :=
rfl
@[simp]
theorem constantCoeff_C (a : R) : constantCoeff (σ := σ) (C a) = a :=
rfl
@[simp]
theorem constantCoeff_comp_C : (constantCoeff (σ := σ)).comp C = RingHom.id R :=
rfl
@[simp]
theorem constantCoeff_zero : constantCoeff (0 : MvPowerSeries σ R) = 0 :=
rfl
@[simp]
theorem constantCoeff_one : constantCoeff (1 : MvPowerSeries σ R) = 1 :=
rfl
@[simp]
theorem constantCoeff_X (s : σ) : constantCoeff (R := R) (X s) = 0 :=
coeff_zero_X s
@[simp]
theorem constantCoeff_smul {S : Type*} [Semiring S] [Module R S]
(φ : MvPowerSeries σ S) (a : R) :
constantCoeff (a • φ) = a • constantCoeff φ := rfl
/-- If a multivariate formal power series is invertible,
then so is its constant coefficient. -/
theorem isUnit_constantCoeff (φ : MvPowerSeries σ R) (h : IsUnit φ) :
IsUnit (constantCoeff φ) :=
h.map _
@[simp]
theorem coeff_smul (f : MvPowerSeries σ R) (n) (a : R) : coeff n (a • f) = a * coeff n f :=
rfl
theorem smul_eq_C_mul (f : MvPowerSeries σ R) (a : R) : a • f = C a * f := by
ext
simp
theorem X_inj [Nontrivial R] {s t : σ} : (X s : MvPowerSeries σ R) = X t ↔ s = t :=
⟨by
classical
intro h
replace h := congr_arg (coeff (single s 1)) h
rw [coeff_X, if_pos rfl, coeff_X] at h
split_ifs at h with H
· rw [Finsupp.single_eq_single_iff] at H
rcases H with H | H
· exact H.1
· exfalso
exact one_ne_zero H.1
· exfalso
exact one_ne_zero h, congr_arg X⟩
end Semiring
section Map
variable {S T : Type*} [Semiring R] [Semiring S] [Semiring T]
variable (f : R →+* S) (g : S →+* T)
/-- The map between multivariate formal power series induced by a map on the coefficients. -/
def map : MvPowerSeries σ R →+* MvPowerSeries σ S where
toFun φ n := f <| coeff n φ
map_zero' := ext fun _n => f.map_zero
map_one' :=
ext fun n =>
show f (coeff n 1) = coeff n 1 by
classical
rw [coeff_one, coeff_one]
split_ifs with h
· simp only [map_one]
· simp only [map_zero]
map_add' φ ψ :=
ext fun n => show f (coeff n (φ + ψ)) = f (coeff n φ) + f (coeff n ψ) by simp
map_mul' φ ψ :=
ext fun n =>
show f _ = _ by
classical
rw [coeff_mul, map_sum, coeff_mul]
apply Finset.sum_congr rfl
rintro ⟨i, j⟩ _; rw [f.map_mul]; rfl
@[simp]
theorem map_id : map (σ := σ) (RingHom.id R) = RingHom.id _ :=
rfl
theorem map_comp : map (σ := σ) (g.comp f) = (map g).comp (map f) :=
rfl
@[simp]
theorem coeff_map (n : σ →₀ ℕ) (φ : MvPowerSeries σ R) : coeff n (map f φ) = f (coeff n φ) :=
rfl
@[simp]
theorem constantCoeff_map (φ : MvPowerSeries σ R) :
constantCoeff (map f φ) = f (constantCoeff φ) :=
rfl
@[simp]
theorem map_monomial (n : σ →₀ ℕ) (a : R) : map f (monomial n a) = monomial n (f a) := by
classical
ext m
simp [coeff_monomial, apply_ite f]
@[simp]
theorem map_C (a : R) : map (σ := σ) f (C a) = C (f a) :=
map_monomial _ _ _
@[simp]
theorem map_X (s : σ) : map f (X s) = X s := by simp [MvPowerSeries.X]
end Map
@[simp]
theorem map_eq_zero {S : Type*} [DivisionSemiring R] [Semiring S] [Nontrivial S]
(φ : MvPowerSeries σ R) (f : R →+* S) : φ.map f = 0 ↔ φ = 0 := by
simp only [MvPowerSeries.ext_iff]
congr! with n
simp
section Semiring
variable [Semiring R]
theorem X_pow_dvd_iff {s : σ} {n : ℕ} {φ : MvPowerSeries σ R} :
(X s : MvPowerSeries σ R) ^ n ∣ φ ↔ ∀ m : σ →₀ ℕ, m s < n → coeff m φ = 0 := by
classical
constructor
· rintro ⟨φ, rfl⟩ m h
rw [coeff_mul, Finset.sum_eq_zero]
rintro ⟨i, j⟩ hij
rw [coeff_X_pow, if_neg, zero_mul]
contrapose! h
dsimp at h
subst i
rw [mem_antidiagonal] at hij
rw [← hij, Finsupp.add_apply, Finsupp.single_eq_same]
exact Nat.le_add_right n _
· intro h
refine ⟨fun m => coeff (m + single s n) φ, ?_⟩
ext m
by_cases H : m - single s n + single s n = m
· rw [coeff_mul, Finset.sum_eq_single (single s n, m - single s n)]
· rw [coeff_X_pow, if_pos rfl, one_mul]
simpa using congr_arg (fun m : σ →₀ ℕ => coeff m φ) H.symm
· rintro ⟨i, j⟩ hij hne
rw [mem_antidiagonal] at hij
rw [coeff_X_pow]
split_ifs with hi
· exfalso
apply hne
rw [← hij, ← hi, Prod.mk_inj]
refine ⟨rfl, ?_⟩
ext t
simp only [add_tsub_cancel_left]
· exact zero_mul _
· intro hni
exfalso
apply hni
rwa [mem_antidiagonal, add_comm]
· rw [h, coeff_mul, Finset.sum_eq_zero]
· rintro ⟨i, j⟩ hij
rw [mem_antidiagonal] at hij
rw [coeff_X_pow]
split_ifs with hi
· exfalso
apply H
rw [← hij, hi]
ext
rw [coe_add, coe_add, Pi.add_apply, Pi.add_apply, add_tsub_cancel_left, add_comm]
· exact zero_mul _
· contrapose! H
ext t
by_cases hst : s = t
· subst t
simpa using tsub_add_cancel_of_le H
· simp [hst]
theorem X_dvd_iff {s : σ} {φ : MvPowerSeries σ R} :
(X s : MvPowerSeries σ R) ∣ φ ↔ ∀ m : σ →₀ ℕ, m s = 0 → coeff m φ = 0 := by
rw [← pow_one (X s : MvPowerSeries σ R), X_pow_dvd_iff]
constructor <;> intro h m hm
· exact h m (hm.symm ▸ zero_lt_one)
· exact h m (Nat.eq_zero_of_le_zero <| Nat.le_of_succ_le_succ hm)
end Semiring
section CommSemiring
open Finset.HasAntidiagonal Finset
variable {R : Type*} [CommSemiring R] {ι : Type*}
/-- Coefficients of a product of power series -/
theorem coeff_prod [DecidableEq ι] [DecidableEq σ]
(f : ι → MvPowerSeries σ R) (d : σ →₀ ℕ) (s : Finset ι) :
coeff d (∏ j ∈ s, f j) =
∑ l ∈ finsuppAntidiag s d,
∏ i ∈ s, coeff (l i) (f i) := by
induction s using Finset.induction_on generalizing d with
| empty =>
simp only [prod_empty, sum_const, nsmul_eq_mul, mul_one, coeff_one, finsuppAntidiag_empty]
split_ifs
· simp only [card_singleton, Nat.cast_one]
· simp only [card_empty, Nat.cast_zero]
| insert a s ha ih =>
rw [finsuppAntidiag_insert ha, prod_insert ha, coeff_mul, sum_biUnion]
· apply Finset.sum_congr rfl
simp only [mem_antidiagonal, sum_map, Function.Embedding.coeFn_mk, coe_update, Prod.forall]
rintro u v rfl
rw [ih, Finset.mul_sum, ← Finset.sum_attach]
apply Finset.sum_congr rfl
simp only [mem_attach, Finset.prod_insert ha, Function.update_self, forall_true_left,
Subtype.forall]
rintro x -
rw [Finset.prod_congr rfl]
intro i hi
rw [Function.update_of_ne]
exact ne_of_mem_of_not_mem hi ha
· simp only [Set.PairwiseDisjoint, Set.Pairwise, mem_coe, mem_antidiagonal, ne_eq,
disjoint_left, mem_map, mem_attach, Function.Embedding.coeFn_mk, true_and, Subtype.exists,
exists_prop, not_exists, not_and, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂,
Prod.forall, Prod.mk.injEq]
rintro u v rfl u' v' huv h k - l - hkl
obtain rfl : u' = u := by
simpa only [Finsupp.coe_update, Function.update_self] using DFunLike.congr_fun hkl a
simp only [add_right_inj] at huv
exact h rfl huv.symm
theorem prod_monomial (f : ι → σ →₀ ℕ) (g : ι → R) (s : Finset ι) :
∏ i ∈ s, monomial (f i) (g i) = monomial (∑ i ∈ s, f i) (∏ i ∈ s, g i) := by
induction s using Finset.cons_induction with
| empty => simp
| cons a s ha h => simp [h, monomial_mul_monomial]
/-- The `d`th coefficient of a power of a multivariate power series
is the sum, indexed by `finsuppAntidiag (Finset.range n) d`, of products of coefficients -/
theorem coeff_pow [DecidableEq σ] (f : MvPowerSeries σ R) {n : ℕ} (d : σ →₀ ℕ) :
coeff d (f ^ n) =
∑ l ∈ finsuppAntidiag (Finset.range n) d,
∏ i ∈ Finset.range n, coeff (l i) f := by
suffices f ^ n = (Finset.range n).prod fun _ ↦ f by
rw [this, coeff_prod]
rw [Finset.prod_const, card_range]
theorem monomial_pow (m : σ →₀ ℕ) (a : R) (n : ℕ) :
(monomial m a) ^ n = monomial (n • m) (a ^ n) := by
rw [Finset.pow_eq_prod_const, prod_monomial, ← Finset.nsmul_eq_sum_const,
← Finset.pow_eq_prod_const]
/-- Vanishing of coefficients of powers of multivariate power series
when the constant coefficient is nilpotent
[N. Bourbaki, *Algebra {II}*, Chapter 4, §4, n°2, proposition 3][bourbaki1981] -/
theorem coeff_eq_zero_of_constantCoeff_nilpotent {f : MvPowerSeries σ R} {m : ℕ}
(hf : constantCoeff f ^ m = 0) {d : σ →₀ ℕ} {n : ℕ} (hn : m + degree d ≤ n) :
coeff d (f ^ n) = 0 := by
classical
rw [coeff_pow]
apply sum_eq_zero
intro k hk
rw [mem_finsuppAntidiag] at hk
set s := {i ∈ range n | k i = 0} with hs_def
have hs : s ⊆ range n := filter_subset _ _
have hs' (i : ℕ) (hi : i ∈ s) : coeff (k i) f = constantCoeff f := by
simp only [hs_def, mem_filter] at hi
rw [hi.2, coeff_zero_eq_constantCoeff]
have hs'' (i : ℕ) (hi : i ∈ s) : k i = 0 := by
simp only [hs_def, mem_filter] at hi
rw [hi.2]
rw [← prod_sdiff (s₁ := s) (filter_subset _ _)]
apply mul_eq_zero_of_right
rw [prod_congr rfl hs', prod_const]
suffices m ≤ #s by
obtain ⟨m', hm'⟩ := Nat.exists_eq_add_of_le this
rw [hm', pow_add, hf, zero_mul]
rw [← Nat.add_le_add_iff_right, add_comm #s,
Finset.card_sdiff_add_card_eq_card (filter_subset _ _), card_range]
apply le_trans _ hn
simp only [add_comm m, Nat.add_le_add_iff_right, ← hk.1,
← sum_sdiff (hs), sum_eq_zero (s := s) hs'', add_zero]
rw [← hs_def]
convert Finset.card_nsmul_le_sum (range n \ s) (fun x ↦ degree (k x)) 1 _
· simp only [Algebra.id.smul_eq_mul, mul_one]
· simp only [degree_eq_weight_one, map_sum]
· simp only [hs_def, mem_filter, mem_sdiff, mem_range, not_and, and_imp]
intro i hi hi'
rw [← not_lt, Nat.lt_one_iff, degree_eq_zero_iff]
exact hi' hi
end CommSemiring
section Algebra
variable {A : Type*} [CommSemiring R] [Semiring A] [Algebra R A]
{B : Type*} [Semiring B] [Algebra R B]
instance : Algebra R (MvPowerSeries σ A) where
algebraMap := (MvPowerSeries.map (algebraMap R A)).comp C
commutes' := fun a φ => by
ext n
simp [Algebra.commutes]
smul_def' := fun a σ => by
ext n
simp [(coeff A n).map_smul_of_tower a, Algebra.smul_def]
theorem c_eq_algebraMap : C = algebraMap R (MvPowerSeries σ R) :=
rfl
theorem algebraMap_apply {r : R} :
algebraMap R (MvPowerSeries σ A) r = C (algebraMap R A r) := by
change (MvPowerSeries.map (algebraMap R A)).comp C r = _
simp
/-- Change of coefficients in mv power series, as an `AlgHom` -/
def mapAlgHom (φ : A →ₐ[R] B) :
MvPowerSeries σ A →ₐ[R] MvPowerSeries σ B where
toRingHom := MvPowerSeries.map φ
commutes' r := by
simp only [RingHom.toMonoidHom_eq_coe, OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe,
MonoidHom.coe_coe, MvPowerSeries.algebraMap_apply, map_C, RingHom.coe_coe, AlgHom.commutes]
theorem mapAlgHom_apply (φ : A →ₐ[R] B) (f : MvPowerSeries σ A) :
mapAlgHom (σ := σ) φ f = MvPowerSeries.map φ f := rfl
instance [Nonempty σ] [Nontrivial R] : Nontrivial (Subalgebra R (MvPowerSeries σ R)) :=
⟨⟨⊥, ⊤, by
classical
rw [Ne, SetLike.ext_iff, not_forall]
inhabit σ
refine ⟨X default, ?_⟩
simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true, Algebra.mem_top]
intro x
rw [MvPowerSeries.ext_iff, not_forall]
refine ⟨Finsupp.single default 1, ?_⟩
simp [algebraMap_apply, coeff_C]⟩⟩
end Algebra
end MvPowerSeries
namespace MvPolynomial
open Finsupp
variable {σ : Type*} {R : Type*} [CommSemiring R] (φ ψ : MvPolynomial σ R)
/-- The natural inclusion from multivariate polynomials into multivariate formal power series. -/
@[coe]
def toMvPowerSeries : MvPolynomial σ R → MvPowerSeries σ R :=
fun φ n => coeff n φ
/-- The natural inclusion from multivariate polynomials into multivariate formal power series. -/
instance coeToMvPowerSeries : Coe (MvPolynomial σ R) (MvPowerSeries σ R) :=
⟨toMvPowerSeries⟩
theorem coe_def : (φ : MvPowerSeries σ R) = fun n => coeff n φ :=
rfl
@[simp, norm_cast]
theorem coeff_coe (n : σ →₀ ℕ) : MvPowerSeries.coeff n ↑φ = coeff n φ :=
rfl
@[simp, norm_cast]
theorem coe_monomial (n : σ →₀ ℕ) (a : R) :
(monomial n a : MvPowerSeries σ R) = MvPowerSeries.monomial n a :=
MvPowerSeries.ext fun m => by
classical
rw [coeff_coe, coeff_monomial, MvPowerSeries.coeff_monomial]
split_ifs with h₁ h₂ <;> first | rfl | subst m; contradiction
@[simp, norm_cast]
theorem coe_zero : ((0 : MvPolynomial σ R) : MvPowerSeries σ R) = 0 :=
rfl
@[simp, norm_cast]
theorem coe_one : ((1 : MvPolynomial σ R) : MvPowerSeries σ R) = 1 :=
coe_monomial _ _
@[simp, norm_cast]
theorem coe_add : ((φ + ψ : MvPolynomial σ R) : MvPowerSeries σ R) = φ + ψ :=
rfl
@[simp, norm_cast]
theorem coe_mul : ((φ * ψ : MvPolynomial σ R) : MvPowerSeries σ R) = φ * ψ :=
MvPowerSeries.ext fun n => by
classical
simp only [coeff_coe, MvPowerSeries.coeff_mul, coeff_mul]
@[simp, norm_cast]
lemma coe_smul (φ : MvPolynomial σ R) (r : R) :
(r • φ : MvPolynomial σ R) = r • (φ : MvPowerSeries σ R) := rfl
@[simp, norm_cast]
theorem coe_C (a : R) : ((C a : MvPolynomial σ R) : MvPowerSeries σ R) = MvPowerSeries.C a :=
coe_monomial _ _
@[simp, norm_cast]
theorem coe_X (s : σ) : ((X s : MvPolynomial σ R) : MvPowerSeries σ R) = MvPowerSeries.X s :=
coe_monomial _ _
variable (σ R)
theorem coe_injective : Function.Injective ((↑) : MvPolynomial σ R → MvPowerSeries σ R) := by
intro x y h
ext
simp_rw [← coeff_coe, h]
variable {σ R φ ψ}
@[simp, norm_cast]
theorem coe_inj : (φ : MvPowerSeries σ R) = ψ ↔ φ = ψ :=
(coe_injective σ R).eq_iff
@[simp]
theorem coe_eq_zero_iff : (φ : MvPowerSeries σ R) = 0 ↔ φ = 0 := by rw [← coe_zero, coe_inj]
@[simp]
theorem coe_eq_one_iff : (φ : MvPowerSeries σ R) = 1 ↔ φ = 1 := by rw [← coe_one, coe_inj]
/-- The coercion from multivariate polynomials to multivariate power series
as a ring homomorphism.
-/
def coeToMvPowerSeries.ringHom : MvPolynomial σ R →+* MvPowerSeries σ R where
toFun := (Coe.coe : MvPolynomial σ R → MvPowerSeries σ R)
map_zero' := coe_zero
map_one' := coe_one
map_add' := coe_add
map_mul' := coe_mul
@[simp, norm_cast]
theorem coe_pow (n : ℕ) :
((φ ^ n : MvPolynomial σ R) : MvPowerSeries σ R) = (φ : MvPowerSeries σ R) ^ n :=
coeToMvPowerSeries.ringHom.map_pow _ _
variable (φ ψ)
@[simp]
theorem coeToMvPowerSeries.ringHom_apply : coeToMvPowerSeries.ringHom φ = φ :=
rfl
theorem _root_.MvPowerSeries.monomial_one_eq
(e : σ →₀ ℕ) :
MvPowerSeries.monomial e (1 : R) =
e.prod fun s n ↦ (MvPowerSeries.X s) ^ n := by
simp only [← coe_X, ← coe_pow, ← coe_monomial, monomial_eq, map_one, one_mul]
simp only [← coeToMvPowerSeries.ringHom_apply, ← map_finsuppProd]
section Algebra
variable (A : Type*) [CommSemiring A] [Algebra R A]
/-- The coercion from multivariate polynomials to multivariate power series
as an algebra homomorphism.
-/
def coeToMvPowerSeries.algHom : MvPolynomial σ R →ₐ[R] MvPowerSeries σ A :=
{ (MvPowerSeries.map (algebraMap R A)).comp coeToMvPowerSeries.ringHom with
commutes' := fun r => by simp [MvPowerSeries.algebraMap_apply] }
@[simp]
theorem coeToMvPowerSeries.algHom_apply :
coeToMvPowerSeries.algHom A φ = MvPowerSeries.map (algebraMap R A) ↑φ :=
rfl
theorem _root_.MvPowerSeries.prod_smul_X_eq_smul_monomial_one
{A : Type*} [CommSemiring A] [Algebra A R] (e : σ →₀ ℕ) (a : σ → A) :
e.prod (fun s n ↦ ((a s • MvPowerSeries.X s) ^ n))
= (e.prod fun s n ↦ (a s) ^ n) • MvPowerSeries.monomial (R := R) e 1 := by
rw [Finsupp.prod_congr
(g2 := fun s n ↦ ((MvPowerSeries.C (algebraMap A R (a s)) * (MvPowerSeries.X s)) ^ n))]
· have (a : A) (f : MvPowerSeries σ R) : a • f =
MvPowerSeries.C ((algebraMap A R) a) * f := by
rw [← MvPowerSeries.smul_eq_C_mul, IsScalarTower.algebraMap_smul]
simp only [mul_pow, Finsupp.prod_mul, ← map_pow, ← MvPowerSeries.monomial_one_eq, this]
simp only [map_finsuppProd, map_pow]
· intro x _
rw [algebra_compatible_smul R, MvPowerSeries.smul_eq_C_mul]
theorem _root_.MvPowerSeries.monomial_eq (e : σ →₀ ℕ) (r : σ → R) :
MvPowerSeries.monomial e (e.prod (fun s n => r s ^ n))
= e.prod fun s e => (r s • MvPowerSeries.X s) ^ e := by
rw [MvPowerSeries.prod_smul_X_eq_smul_monomial_one, ← map_smul, smul_eq_mul, mul_one]
theorem _root_.MvPowerSeries.monomial_smul_const
{σ : Type*} {R : Type*} [CommSemiring R]
(e : σ →₀ ℕ) (r : R) :
MvPowerSeries.monomial e (r ^ (e.sum fun _ n => n))
= (e.prod fun s e => (r • MvPowerSeries.X s) ^ e) := by
rw [MvPowerSeries.prod_smul_X_eq_smul_monomial_one, ← map_smul, smul_eq_mul, mul_one]
simp only [Finsupp.sum, Finsupp.prod, Finset.prod_pow_eq_pow_sum]
end Algebra
end MvPolynomial
namespace MvPowerSeries
variable {σ R A : Type*} [CommSemiring R] [CommSemiring A] [Algebra R A] (f : MvPowerSeries σ R)
instance algebraMvPolynomial : Algebra (MvPolynomial σ R) (MvPowerSeries σ A) :=
RingHom.toAlgebra (MvPolynomial.coeToMvPowerSeries.algHom A).toRingHom
instance algebraMvPowerSeries : Algebra (MvPowerSeries σ R) (MvPowerSeries σ A) :=
(map (algebraMap R A)).toAlgebra
variable (A)
theorem algebraMap_apply' (p : MvPolynomial σ R) :
algebraMap (MvPolynomial σ R) (MvPowerSeries σ A) p = map (algebraMap R A) p :=
rfl
theorem algebraMap_apply'' :
algebraMap (MvPowerSeries σ R) (MvPowerSeries σ A) f = map (algebraMap R A) f :=
rfl
end MvPowerSeries
end |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/LinearTopology.lean | import Mathlib.Data.Finsupp.Interval
import Mathlib.RingTheory.Ideal.Quotient.Defs
import Mathlib.RingTheory.MvPowerSeries.PiTopology
import Mathlib.Topology.Algebra.LinearTopology
import Mathlib.RingTheory.TwoSidedIdeal.Operations
/-! # Linear topology on the ring of multivariate power series
- `MvPowerSeries.LinearTopology.basis`: the ideals of the ring of multivariate power series
all coefficients the exponent of which is smaller than some bound vanish.
- `MvPowerSeries.LinearTopology.hasBasis_nhds_zero` :
the two-sided ideals from `MvPowerSeries.LinearTopology.basis` form a basis
of neighborhoods of `0` if the topology of `R` is (left and right) linear.
## Instances :
If `R` has a linear topology, then the product topology on `MvPowerSeries σ R`
is a linear topology.
This applies in particular when `R` has the discrete topology.
## Note
If we had an analogue of `PolynomialModule` for power series,
meaning that we could consider the `R⟦X⟧`-module `M⟦X⟧` when `M` is an `R`-module,
then one could prove that `M⟦X⟧` is linearly topologized over `R⟦X⟧`
whenever `M` is linearly topologized over `R`.
To recover the ring case, it would remain to show that the isomorphism between
`Rᵐᵒᵖ⟦X⟧` and `R⟦X⟧ᵐᵒᵖ` identifies their respective actions on `R⟦X⟧`.
(And likewise in the multivariate case.)
-/
namespace MvPowerSeries
namespace LinearTopology
open scoped Topology
open Set SetLike Filter
/-- The underlying family for the basis of ideals in a multivariate power series ring. -/
def basis (σ : Type*) (R : Type*) [Ring R] (Jd : TwoSidedIdeal R × (σ →₀ ℕ)) :
TwoSidedIdeal (MvPowerSeries σ R) :=
TwoSidedIdeal.mk' {f | ∀ e ≤ Jd.2, coeff e f ∈ Jd.1}
(by simp [coeff_zero])
(fun hf hg e he ↦ by rw [map_add]; exact add_mem (hf e he) (hg e he))
(fun {f} hf e he ↦ by simp only [map_neg, neg_mem, hf e he])
(fun {f g} hg e he ↦ by
classical
rw [coeff_mul]
apply sum_mem
rintro uv huv
exact TwoSidedIdeal.mul_mem_left _ _ _ (hg _ (le_trans (Finset.antidiagonal.snd_le huv) he)))
(fun {f g} hf e he ↦ by
classical
rw [coeff_mul]
apply sum_mem
rintro uv huv
exact TwoSidedIdeal.mul_mem_right _ _ _ (hf _ (le_trans (Finset.antidiagonal.fst_le huv) he)))
variable {σ : Type*} {R : Type*} [Ring R]
/-- A power series `f` belongs to the two-sided ideal `basis σ R ⟨J, d⟩`
if and only if `coeff e f ∈ J` for all `e ≤ d`. -/
theorem mem_basis_iff {f : MvPowerSeries σ R} {Jd : TwoSidedIdeal R × (σ →₀ ℕ)} :
f ∈ basis σ R Jd ↔ ∀ e ≤ Jd.2, coeff e f ∈ Jd.1 := by
simp [basis]
/-- If `J ≤ K` and `e ≤ d`, then we have the inclusion of two-sided ideals
`basis σ R ⟨J, d⟩ ≤ basis σ R ⟨K, e,>`. -/
theorem basis_le {Jd Ke : TwoSidedIdeal R × (σ →₀ ℕ)} (hJK : Jd.1 ≤ Ke.1) (hed : Ke.2 ≤ Jd.2) :
basis σ R Jd ≤ basis σ R Ke :=
fun _ ↦ forall_imp (fun _ h hue ↦ hJK (h (le_trans hue hed)))
/-- `basis σ R ⟨J, d⟩ ≤ basis σ R ⟨K, e⟩` if and only if `J ≤ K` and `e ≤ d`. -/
theorem basis_le_iff {J K : TwoSidedIdeal R} {d e : σ →₀ ℕ} (hK : K ≠ ⊤) :
basis σ R ⟨J, d⟩ ≤ basis σ R ⟨K, e⟩ ↔ J ≤ K ∧ e ≤ d := by
classical
constructor
· simp only [basis, TwoSidedIdeal.le_iff, TwoSidedIdeal.coe_mk', setOf_subset_setOf]
intro h
constructor
· intro x hx
have (d' : _) : coeff d' (C (σ := σ) x) ∈ J := by
rw [coeff_C]; split_ifs <;> [exact hx; exact J.zero_mem]
simpa using h (C x) (fun _ _ ↦ this _) _ (zero_le _)
· by_contra h'
apply hK
rw [eq_top_iff]
intro x _
have (d') (hd'_le : d' ≤ d) : coeff d' (monomial e x) ∈ J := by
rw [coeff_monomial]
split_ifs with hd' <;> [exact (h' (hd' ▸ hd'_le)).elim; exact J.zero_mem]
simpa using h (monomial e x) this _ le_rfl
· rintro ⟨hJK, hed⟩
exact basis_le hJK hed
variable [TopologicalSpace R]
-- We endow MvPowerSeries σ R with the product topology.
open WithPiTopology
/-- If the ring `R` is endowed with a linear topology, then the sets `↑basis σ R (J, d)`,
for `J : TwoSidedIdeal R` which are neighborhoods of `0 : R` and `d : σ →₀ ℕ`,
constitute a basis of neighborhoods of `0 : MvPowerSeries σ R` for the product topology. -/
lemma hasBasis_nhds_zero [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] :
(𝓝 0 : Filter (MvPowerSeries σ R)).HasBasis
(fun Id : TwoSidedIdeal R × (σ →₀ ℕ) ↦ (Id.1 : Set R) ∈ 𝓝 0)
(fun Id ↦ basis _ _ Id) := by
classical
rw [nhds_pi]
refine IsLinearTopology.hasBasis_twoSidedIdeal.pi_self.to_hasBasis ?_ ?_
· intro ⟨D, I⟩ ⟨hD, hI⟩
refine ⟨⟨I, Finset.sup hD.toFinset id⟩, hI, fun f hf d hd ↦ ?_⟩
rw [SetLike.mem_coe, mem_basis_iff] at hf
convert hf _ <| Finset.le_sup (hD.mem_toFinset.mpr hd)
· intro ⟨I, d⟩ hI
refine ⟨⟨Iic d, I⟩, ⟨finite_Iic d, hI⟩, ?_⟩
simpa [basis, coeff_apply, Iic, Set.pi] using subset_rfl
/-- The topology on `MvPowerSeries` is a left linear topology
when the ring of coefficients has a linear topology. -/
instance [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] :
IsLinearTopology (MvPowerSeries σ R) (MvPowerSeries σ R) :=
IsLinearTopology.mk_of_hasBasis' _ hasBasis_nhds_zero TwoSidedIdeal.mul_mem_left
/-- The topology on `MvPowerSeries` is a right linear topology
when the ring of coefficients has a linear topology. -/
instance [IsLinearTopology R R] [IsLinearTopology Rᵐᵒᵖ R] :
IsLinearTopology (MvPowerSeries σ R)ᵐᵒᵖ (MvPowerSeries σ R) :=
IsLinearTopology.mk_of_hasBasis' _ hasBasis_nhds_zero (fun J _ _ hg ↦ J.mul_mem_right _ _ hg)
theorem isTopologicallyNilpotent_of_constantCoeff
{R : Type*} [CommRing R] [TopologicalSpace R] [IsLinearTopology R R]
{f : MvPowerSeries σ R} (hf : IsTopologicallyNilpotent (constantCoeff f)) :
IsTopologicallyNilpotent f := by
simp_rw [IsTopologicallyNilpotent, tendsto_iff_coeff_tendsto, coeff_zero,
IsLinearTopology.hasBasis_ideal.tendsto_right_iff]
intro d I hI
replace hf := hf.eventually_mem hI
simp_rw [eventually_atTop, SetLike.mem_coe, ← Ideal.Quotient.eq_zero_iff_mem,
map_pow, ← coeff_map, ← constantCoeff_map] at hf ⊢
obtain ⟨N, hN⟩ := hf
use N + d.degree
intro n hn
simpa only [map_pow] using coeff_eq_zero_of_constantCoeff_nilpotent (hN N le_rfl) hn
/-- Assuming the base ring has a linear topology, the powers of a `MvPowerSeries` converge to 0
iff its constant coefficient is topologically nilpotent.
See also `MvPowerSeries.WithPiTopology.isTopologicallyNilpotent_iff_constantCoeff_isNilpotent`. -/
theorem isTopologicallyNilpotent_iff_constantCoeff
{R : Type*} [CommRing R] [TopologicalSpace R] [IsLinearTopology R R] (f : MvPowerSeries σ R) :
Tendsto (fun n : ℕ => f ^ n) atTop (nhds 0) ↔
IsTopologicallyNilpotent (constantCoeff f) := by
refine ⟨fun H ↦ ?_, isTopologicallyNilpotent_of_constantCoeff⟩
replace H : Tendsto (fun n ↦ constantCoeff (f ^ n)) atTop (nhds 0) :=
continuous_constantCoeff R |>.tendsto' 0 0 constantCoeff_zero |>.comp H
simpa only [map_pow] using H
end LinearTopology
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/MvPowerSeries/LexOrder.lean | import Mathlib.RingTheory.MvPowerSeries.Basic
import Mathlib.Data.Finsupp.WellFounded
/-! LexOrder of multivariate power series
Given an ordering of `σ` such that `WellOrderGT σ`,
the lexicographic order on `σ →₀ ℕ` is a well ordering,
which can be used to define a natural valuation `lexOrder` on the ring `MvPowerSeries σ R`:
the smallest exponent in the support.
-/
namespace MvPowerSeries
variable {σ R : Type*}
variable [Semiring R]
section LexOrder
open Finsupp
variable [LinearOrder σ] [WellFoundedGT σ]
/-- The lex order on multivariate power series. -/
noncomputable def lexOrder (φ : MvPowerSeries σ R) : (WithTop (Lex (σ →₀ ℕ))) := by
classical
exact if h : φ = 0 then ⊤ else by
have ne : Set.Nonempty (toLex '' φ.support) := by
simp only [Set.image_nonempty, Function.support_nonempty_iff, ne_eq, h, not_false_eq_true]
apply WithTop.some
apply WellFounded.min _ (toLex '' φ.support) ne
· exact Finsupp.instLTLex.lt
· exact wellFounded_lt
theorem lexOrder_def_of_ne_zero {φ : MvPowerSeries σ R} (hφ : φ ≠ 0) :
∃ (ne : Set.Nonempty (toLex '' φ.support)),
lexOrder φ = WithTop.some ((@wellFounded_lt (Lex (σ →₀ ℕ))
(instLTLex) (Lex.wellFoundedLT)).min (toLex '' φ.support) ne) := by
suffices ne : Set.Nonempty (toLex '' φ.support) by
use ne
unfold lexOrder
simp only [dif_neg hφ]
simp only [Set.image_nonempty, Function.support_nonempty_iff, ne_eq, hφ, not_false_eq_true]
@[simp]
theorem lexOrder_eq_top_iff_eq_zero (φ : MvPowerSeries σ R) :
lexOrder φ = ⊤ ↔ φ = 0 := by
unfold lexOrder
split_ifs with h
· simp only [h]
· simp only [h, WithTop.coe_ne_top]
theorem lexOrder_zero : lexOrder (0 : MvPowerSeries σ R) = ⊤ := by
unfold lexOrder
rw [dif_pos rfl]
theorem exists_finsupp_eq_lexOrder_of_ne_zero {φ : MvPowerSeries σ R} (hφ : φ ≠ 0) :
∃ (d : σ →₀ ℕ), lexOrder φ = toLex d := by
simp only [ne_eq, ← lexOrder_eq_top_iff_eq_zero, WithTop.ne_top_iff_exists] at hφ
obtain ⟨p, hp⟩ := hφ
exact ⟨ofLex p, by simp only [toLex_ofLex, hp]⟩
theorem coeff_ne_zero_of_lexOrder {φ : MvPowerSeries σ R} {d : σ →₀ ℕ}
(h : toLex d = lexOrder φ) : coeff d φ ≠ 0 := by
have hφ : φ ≠ 0 := by
simp only [ne_eq, ← lexOrder_eq_top_iff_eq_zero, ← h, WithTop.coe_ne_top, not_false_eq_true]
have hφ' := lexOrder_def_of_ne_zero hφ
rcases hφ' with ⟨ne, hφ'⟩
simp only [← h, WithTop.coe_eq_coe] at hφ'
suffices toLex d ∈ toLex '' φ.support by
simp only [Set.mem_image_equiv, toLex_symm_eq, ofLex_toLex, Function.mem_support, ne_eq] at this
apply this
rw [hφ']
apply WellFounded.min_mem
theorem coeff_eq_zero_of_lt_lexOrder {φ : MvPowerSeries σ R} {d : σ →₀ ℕ}
(h : toLex d < lexOrder φ) : coeff d φ = 0 := by
by_cases hφ : φ = 0
· simp only [hφ, map_zero]
· rcases lexOrder_def_of_ne_zero hφ with ⟨ne, hφ'⟩
rw [hφ', WithTop.coe_lt_coe] at h
by_contra h'
exact WellFounded.not_lt_min _ (toLex '' φ.support) ne (Set.mem_image_equiv.mpr h') h
theorem lexOrder_le_of_coeff_ne_zero {φ : MvPowerSeries σ R} {d : σ →₀ ℕ}
(h : coeff d φ ≠ 0) : lexOrder φ ≤ toLex d := by
rw [← not_lt]
intro h'
exact h (coeff_eq_zero_of_lt_lexOrder h')
theorem le_lexOrder_iff {φ : MvPowerSeries σ R} {w : WithTop (Lex (σ →₀ ℕ))} :
w ≤ lexOrder φ ↔ (∀ (d : σ →₀ ℕ) (_ : toLex d < w), coeff d φ = 0) := by
constructor
· intro h d hd
apply coeff_eq_zero_of_lt_lexOrder
exact lt_of_lt_of_le hd h
· intro h
rw [← not_lt]
intro h'
have hφ : φ ≠ 0 := by
rw [ne_eq, ← lexOrder_eq_top_iff_eq_zero]
exact ne_top_of_lt h'
obtain ⟨d, hd⟩ := exists_finsupp_eq_lexOrder_of_ne_zero hφ
refine coeff_ne_zero_of_lexOrder hd.symm (h d ?_)
rwa [← hd]
theorem min_lexOrder_le {φ ψ : MvPowerSeries σ R} :
min (lexOrder φ) (lexOrder ψ) ≤ lexOrder (φ + ψ) := by
rw [le_lexOrder_iff]
intro d hd
simp only [lt_min_iff] at hd
rw [map_add, coeff_eq_zero_of_lt_lexOrder hd.1, coeff_eq_zero_of_lt_lexOrder hd.2, add_zero]
theorem coeff_mul_of_add_lexOrder {φ ψ : MvPowerSeries σ R}
{p q : σ →₀ ℕ} (hp : lexOrder φ = toLex p) (hq : lexOrder ψ = toLex q) :
coeff (p + q) (φ * ψ) = coeff p φ * coeff q ψ := by
rw [coeff_mul, Finset.sum_eq_single_of_mem ⟨p, q⟩ (by simp)]
rintro ⟨u, v⟩ h h'
simp only [Finset.mem_antidiagonal] at h
rcases trichotomy_of_add_eq_add (congrArg toLex h) with h'' | h'' | h''
· exact False.elim (h' (by simp [h''.1, h''.2]))
· rw [coeff_eq_zero_of_lt_lexOrder (d := u), zero_mul]
rw [hp]
norm_cast
· rw [coeff_eq_zero_of_lt_lexOrder (d := v), mul_zero]
rw [hq]
norm_cast
theorem le_lexOrder_mul (φ ψ : MvPowerSeries σ R) :
lexOrder φ + lexOrder ψ ≤ lexOrder (φ * ψ) := by
rw [le_lexOrder_iff]
intro d hd
rw [coeff_mul]
apply Finset.sum_eq_zero
rintro ⟨u, v⟩ h
simp only [Finset.mem_antidiagonal] at h
simp only
suffices toLex u < lexOrder φ ∨ toLex v < lexOrder ψ by
rcases this with (hu | hv)
· rw [coeff_eq_zero_of_lt_lexOrder hu, zero_mul]
· rw [coeff_eq_zero_of_lt_lexOrder hv, mul_zero]
rw [or_iff_not_imp_left, not_lt, ← not_le]
intro hu hv
rw [← not_le] at hd
apply hd
simp only [← h, toLex_add, WithTop.coe_add, add_le_add hu hv]
alias lexOrder_mul_ge := le_lexOrder_mul
theorem lexOrder_mul [NoZeroDivisors R] (φ ψ : MvPowerSeries σ R) :
lexOrder (φ * ψ) = lexOrder φ + lexOrder ψ := by
by_cases hφ : φ = 0
· simp only [hφ, zero_mul, lexOrder_zero, top_add]
by_cases hψ : ψ = 0
· simp only [hψ, mul_zero, lexOrder_zero, add_top]
rcases exists_finsupp_eq_lexOrder_of_ne_zero hφ with ⟨p, hp⟩
rcases exists_finsupp_eq_lexOrder_of_ne_zero hψ with ⟨q, hq⟩
apply le_antisymm _ (lexOrder_mul_ge φ ψ)
rw [hp, hq]
apply lexOrder_le_of_coeff_ne_zero (d := p + q)
rw [coeff_mul_of_add_lexOrder hp hq, mul_ne_zero_iff]
exact ⟨coeff_ne_zero_of_lexOrder hp.symm, coeff_ne_zero_of_lexOrder hq.symm⟩
end LexOrder
end MvPowerSeries |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/IntegrallyClosed.lean | import Mathlib.RingTheory.IntegralClosure.IntegrallyClosed
import Mathlib.RingTheory.LocalProperties.Basic
import Mathlib.RingTheory.Spectrum.Maximal.Localization
/-!
# `IsIntegrallyClosed` is a local property
In this file, we prove that `IsIntegrallyClosed` is a local property.
## Main results
* `IsIntegrallyClosed.of_localization_maximal` : An integral domain `R` is integral closed
if `Rₘ` is integral closed for any maximal ideal `m` of `R`.
-/
open scoped nonZeroDivisors
open Localization Ideal IsLocalization
variable {R K : Type*} [CommRing R] [Field K] [Algebra R K] [IsFractionRing R K]
theorem IsIntegrallyClosed.iInf {ι : Type*} (S : ι → Subalgebra R K)
(h : ∀ i, IsIntegrallyClosed (S i)) :
IsIntegrallyClosed (⨅ i, S i : Subalgebra R K) := by
refine (isIntegrallyClosed_iff K).mpr (fun {x} hx ↦ CanLift.prf x (Algebra.mem_iInf.mpr ?_))
intro i
have le : (⨅ i : ι, S i : Subalgebra R K) ≤ S i := iInf_le S i
algebraize [(Subalgebra.inclusion le).toRingHom]
have : IsScalarTower ↥(⨅ i, S i) (S i) K := Subalgebra.inclusion.isScalarTower_right le K
rcases (isIntegrallyClosed_iff K).mp (h i) hx.tower_top with ⟨⟨_, hin⟩, hy⟩
rwa [← hy]
theorem IsIntegrallyClosed.of_iInf_eq_bot {ι : Type*} (S : ι → Subalgebra R K)
(h : ∀ i : ι, IsIntegrallyClosed (S i)) (hs : ⨅ i : ι, S i = ⊥) : IsIntegrallyClosed R :=
have f : (⊥ : Subalgebra R K) ≃ₐ[R] R :=
Algebra.botEquivOfInjective (FaithfulSMul.algebraMap_injective R K)
(IsIntegrallyClosed.iInf S h).of_equiv (hs ▸ f).toRingEquiv
theorem IsIntegrallyClosed.of_localization_submonoid [IsDomain R] {ι : Type*} (S : ι → Submonoid R)
(h : ∀ i : ι, S i ≤ R⁰) (hi : ∀ i : ι, IsIntegrallyClosed (Localization (S i)))
(hs : ⨅ i : ι, Localization.subalgebra (FractionRing R) (S i) (h i) = ⊥) :
IsIntegrallyClosed R :=
IsIntegrallyClosed.of_iInf_eq_bot (fun i ↦ Localization.subalgebra (FractionRing R) (S i) (h i))
(fun i ↦ (hi i).of_equiv (IsLocalization.algEquiv (S i) (Localization (S i)) _).toRingEquiv) hs
/-- An integral domain $R$ is integrally closed if there exists a set of prime ideals $S$ such that
$\bigcap_{\mathfrak{p} \in S} R_{\mathfrak{p}} = R$ and for every $\mathfrak{p} \in S$,
$R_{\mathfrak{p}}$ is integrally closed. -/
theorem IsIntegrallyClosed.of_localization [IsDomain R] (S : Set (PrimeSpectrum R))
(h : ∀ p ∈ S, IsIntegrallyClosed (Localization.AtPrime p.1))
(hs : ⨅ p ∈ S, (Localization.subalgebra (FractionRing R) p.1.primeCompl
p.1.primeCompl_le_nonZeroDivisors) = ⊥) : IsIntegrallyClosed R := by
apply IsIntegrallyClosed.of_localization_submonoid (fun p : S ↦ p.1.1.primeCompl)
(fun p ↦ p.1.1.primeCompl_le_nonZeroDivisors) (fun p ↦ h p.1 p.2)
ext x
simp only [← hs, Algebra.mem_iInf, Subtype.forall]
/-- An integral domain `R` is integral closed if `Rₘ` is integral closed
for any maximal ideal `m` of `R`. -/
theorem IsIntegrallyClosed.of_localization_maximal [IsDomain R]
(h : ∀ p : Ideal R, p ≠ ⊥ → [p.IsMaximal] → IsIntegrallyClosed (Localization.AtPrime p)) :
IsIntegrallyClosed R := by
by_cases hf : IsField R
· exact hf.toField.instIsIntegrallyClosed
refine of_localization (.range MaximalSpectrum.toPrimeSpectrum) (fun _ ↦ ?_) ?_
· rintro ⟨p, rfl⟩
exact h p.asIdeal (Ring.ne_bot_of_isMaximal_of_not_isField p.isMaximal hf)
· rw [iInf_range]
convert MaximalSpectrum.iInf_localization_eq_bot R (FractionRing R)
rw [subalgebra.ofField_eq, MaximalSpectrum.toPrimeSpectrum]
theorem isIntegrallyClosed_ofLocalizationMaximal :
OfLocalizationMaximal fun R _ => ([IsDomain R] → IsIntegrallyClosed R) :=
fun _ _ h _ ↦ IsIntegrallyClosed.of_localization_maximal fun p _ hpm ↦ h p hpm
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommRing (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
theorem IsIntegrallyClosed.of_isLocalization_maximal [IsDomain R]
(h : ∀ (P : Ideal R) [P.IsMaximal], IsIntegrallyClosed (Rₚ P)) :
IsIntegrallyClosed R := .of_localization_maximal
(fun P _ _ ↦ .of_equiv <| ringEquivOfRingEquiv (Rₚ P) _ (RingEquiv.refl R) P.primeCompl.map_id) |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Basic.lean | import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.Localization.BaseChange
import Mathlib.RingTheory.Localization.Submodule
import Mathlib.RingTheory.LocalProperties.Submodule
import Mathlib.RingTheory.RingHomProperties
/-!
# Local properties of commutative rings
In this file, we define local properties in general.
## Naming Conventions
* `localization_P` : `P` holds for `S⁻¹R` if `P` holds for `R`.
* `P_of_localization_maximal` : `P` holds for `R` if `P` holds for `Rₘ` for all maximal `m`.
* `P_of_localization_prime` : `P` holds for `R` if `P` holds for `Rₘ` for all prime `m`.
* `P_ofLocalizationSpan` : `P` holds for `R` if given a spanning set `{fᵢ}`, `P` holds for all
`R_{fᵢ}`.
## Main definitions
* `LocalizationPreserves` : A property `P` of comm rings is said to be preserved by localization
if `P` holds for `M⁻¹R` whenever `P` holds for `R`.
* `OfLocalizationMaximal` : A property `P` of comm rings satisfies `OfLocalizationMaximal`
if `P` holds for `R` whenever `P` holds for `Rₘ` for all maximal ideal `m`.
* `RingHom.LocalizationPreserves` : A property `P` of ring homs is said to be preserved by
localization if `P` holds for `M⁻¹R →+* M⁻¹S` whenever `P` holds for `R →+* S`.
* `RingHom.OfLocalizationSpan` : A property `P` of ring homs satisfies
`RingHom.OfLocalizationSpan` if `P` holds for `R →+* S` whenever there exists a
set `{ r }` that spans `R` such that `P` holds for `Rᵣ →+* Sᵣ`.
## Main results
* The triviality of an ideal or an element:
`ideal_eq_bot_of_localization`, `eq_zero_of_localization`
-/
open scoped Pointwise
universe u
section Properties
variable {R S : Type u} [CommRing R] [CommRing S] (f : R →+* S)
variable (R' S' : Type u) [CommRing R'] [CommRing S']
variable [Algebra R R'] [Algebra S S']
section CommRing
variable (P : ∀ (R : Type u) [CommRing R], Prop)
/-- A property `P` of comm rings is said to be preserved by localization
if `P` holds for `M⁻¹R` whenever `P` holds for `R`. -/
def LocalizationPreserves : Prop :=
∀ {R : Type u} [hR : CommRing R] (M : Submonoid R) (S : Type u) [hS : CommRing S] [Algebra R S]
[IsLocalization M S], @P R hR → @P S hS
/-- A property `P` of comm rings satisfies `OfLocalizationMaximal`
if `P` holds for `R` whenever `P` holds for `Rₘ` for all maximal ideal `m`. -/
def OfLocalizationMaximal : Prop :=
∀ (R : Type u) [CommRing R],
(∀ (J : Ideal R) (_ : J.IsMaximal), P (Localization.AtPrime J)) → P R
end CommRing
section RingHom
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S] (_ : R →+* S), Prop)
/-- A property `P` of ring homs is said to contain identities if `P` holds
for the identity homomorphism of every ring. -/
def RingHom.ContainsIdentities := ∀ (R : Type u) [CommRing R], P (RingHom.id R)
/-- A property `P` of ring homs is said to be preserved by localization
if `P` holds for `M⁻¹R →+* M⁻¹S` whenever `P` holds for `R →+* S`. -/
def RingHom.LocalizationPreserves :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (M : Submonoid R) (R' S' : Type u)
[CommRing R'] [CommRing S'] [Algebra R R'] [Algebra S S'] [IsLocalization M R']
[IsLocalization (M.map f) S'],
P f → P (IsLocalization.map S' f (Submonoid.le_comap_map M) : R' →+* S')
/-- A property `P` of ring homs is said to be preserved by localization away
if `P` holds for `Rᵣ →+* Sᵣ` whenever `P` holds for `R →+* S`. -/
def RingHom.LocalizationAwayPreserves :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (r : R) (R' S' : Type u)
[CommRing R'] [CommRing S'] [Algebra R R'] [Algebra S S'] [IsLocalization.Away r R']
[IsLocalization.Away (f r) S'],
P f → P (IsLocalization.Away.map R' S' f r : R' →+* S')
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpan`
if `P` holds for `R →+* S` whenever there exists a finite set `{ r }` that spans `R` such that
`P` holds for `Rᵣ →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationSpan` via
`RingHom.ofLocalizationSpan_iff_finite`, but this is easier to prove. -/
def RingHom.OfLocalizationFiniteSpan :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Finset R)
(_ : Ideal.span (s : Set R) = ⊤) (_ : ∀ r : s, P (Localization.awayMap f r)), P f
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpan`
if `P` holds for `R →+* S` whenever there exists a set `{ r }` that spans `R` such that
`P` holds for `Rᵣ →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationFiniteSpan` via
`RingHom.ofLocalizationSpan_iff_finite`, but this has less restrictions when applying. -/
def RingHom.OfLocalizationSpan :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Set R) (_ : Ideal.span s = ⊤)
(_ : ∀ r : s, P (Localization.awayMap f r)), P f
/-- A property `P` of ring homs satisfies `RingHom.HoldsForLocalizationAway`
if `P` holds for each localization map `R →+* Rᵣ`. -/
def RingHom.HoldsForLocalizationAway : Prop :=
∀ ⦃R : Type u⦄ (S : Type u) [CommRing R] [CommRing S] [Algebra R S] (r : R)
[IsLocalization.Away r S], P (algebraMap R S)
/-- A property `P` of ring homs satisfies `RingHom.StableUnderCompositionWithLocalizationAwaySource`
if whenever `P` holds for `f` it also holds for the composition with
localization maps on the source. -/
def RingHom.StableUnderCompositionWithLocalizationAwaySource : Prop :=
∀ ⦃R : Type u⦄ (S : Type u) ⦃T : Type u⦄ [CommRing R] [CommRing S] [CommRing T] [Algebra R S]
(r : R) [IsLocalization.Away r S] (f : S →+* T), P f → P (f.comp (algebraMap R S))
/-- A property `P` of ring homs satisfies `RingHom.StableUnderCompositionWithLocalizationAway`
if whenever `P` holds for `f` it also holds for the composition with
localization maps on the target. -/
def RingHom.StableUnderCompositionWithLocalizationAwayTarget : Prop :=
∀ ⦃R S : Type u⦄ (T : Type u) [CommRing R] [CommRing S] [CommRing T] [Algebra S T] (s : S)
[IsLocalization.Away s T] (f : R →+* S), P f → P ((algebraMap S T).comp f)
/-- A property `P` of ring homs satisfies `RingHom.StableUnderCompositionWithLocalizationAway`
if whenever `P` holds for `f` it also holds for the composition with
localization maps on the left and on the right. -/
def RingHom.StableUnderCompositionWithLocalizationAway : Prop :=
StableUnderCompositionWithLocalizationAwaySource P ∧
StableUnderCompositionWithLocalizationAwayTarget P
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationFiniteSpanTarget`
if `P` holds for `R →+* S` whenever there exists a finite set `{ r }` that spans `S` such that
`P` holds for `R →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationSpanTarget` via
`RingHom.ofLocalizationSpanTarget_iff_finite`, but this is easier to prove. -/
def RingHom.OfLocalizationFiniteSpanTarget : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Finset S)
(_ : Ideal.span (s : Set S) = ⊤)
(_ : ∀ r : s, P ((algebraMap S (Localization.Away (r : S))).comp f)), P f
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationSpanTarget`
if `P` holds for `R →+* S` whenever there exists a set `{ r }` that spans `S` such that
`P` holds for `R →+* Sᵣ`.
Note that this is equivalent to `RingHom.OfLocalizationFiniteSpanTarget` via
`RingHom.ofLocalizationSpanTarget_iff_finite`, but this has less restrictions when applying. -/
def RingHom.OfLocalizationSpanTarget : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S) (s : Set S) (_ : Ideal.span s = ⊤)
(_ : ∀ r : s, P ((algebraMap S (Localization.Away (r : S))).comp f)), P f
/-- A property `P` of ring homs satisfies `RingHom.OfLocalizationPrime`
if `P` holds for `R` whenever `P` holds for `Rₘ` for all prime ideals `p`. -/
def RingHom.OfLocalizationPrime : Prop :=
∀ ⦃R S : Type u⦄ [CommRing R] [CommRing S] (f : R →+* S),
(∀ (J : Ideal S) (_ : J.IsPrime), P (Localization.localRingHom _ J f rfl)) → P f
/-- A property of ring homs is local if it is preserved by localizations and compositions, and for
each `{ r }` that spans `S`, we have `P (R →+* S) ↔ ∀ r, P (R →+* Sᵣ)`. -/
structure RingHom.PropertyIsLocal : Prop where
localizationAwayPreserves : RingHom.LocalizationAwayPreserves @P
ofLocalizationSpanTarget : RingHom.OfLocalizationSpanTarget @P
ofLocalizationSpan : RingHom.OfLocalizationSpan @P
StableUnderCompositionWithLocalizationAwayTarget :
RingHom.StableUnderCompositionWithLocalizationAwayTarget @P
theorem RingHom.ofLocalizationSpan_iff_finite :
RingHom.OfLocalizationSpan @P ↔ RingHom.OfLocalizationFiniteSpan @P := by
delta RingHom.OfLocalizationSpan RingHom.OfLocalizationFiniteSpan
apply forall₅_congr
-- TODO: Using `refine` here breaks `resetI`.
intros
constructor
· intro h s; exact h s
· intro h s hs hs'
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
theorem RingHom.ofLocalizationSpanTarget_iff_finite :
RingHom.OfLocalizationSpanTarget @P ↔ RingHom.OfLocalizationFiniteSpanTarget @P := by
delta RingHom.OfLocalizationSpanTarget RingHom.OfLocalizationFiniteSpanTarget
apply forall₅_congr
-- TODO: Using `refine` here breaks `resetI`.
intros
constructor
· intro h s; exact h s
· intro h s hs hs'
obtain ⟨s', h₁, h₂⟩ := (Ideal.span_eq_top_iff_finite s).mp hs
exact h s' h₂ fun x => hs' ⟨_, h₁ x.prop⟩
open TensorProduct
attribute [local instance] Algebra.TensorProduct.rightAlgebra in
lemma RingHom.OfLocalizationSpan.mk (hP : RingHom.RespectsIso P)
(H : ∀ {R S : Type u} [CommRing R] [CommRing S] [Algebra R S] (s : Set R),
Ideal.span s = ⊤ →
(∀ r ∈ s, P (algebraMap (Localization.Away r) (Localization.Away r ⊗[R] S))) →
P (algebraMap R S)) :
OfLocalizationSpan P := by
introv R hs hf
algebraize [f]
let _ := fun r : R => (Localization.awayMap (algebraMap R S) r).toAlgebra
refine H s hs (fun r hr ↦ ?_)
have : algebraMap (Localization.Away r) (Localization.Away r ⊗[R] S) =
((IsLocalization.Away.tensorRightEquiv S r (Localization.Away r)).symm : _ →+* _).comp
(algebraMap (Localization.Away r) (Localization.Away (algebraMap R S r))) := by
apply IsLocalization.ringHom_ext (Submonoid.powers r)
ext
simp [RingHom.algebraMap_toAlgebra, Localization.awayMap, IsLocalization.Away.map,
Algebra.TensorProduct.tmul_one_eq_one_tmul, RingHom.algebraMap_toAlgebra]
rw [this]
exact hP.1 _ _ (hf ⟨r, hr⟩)
theorem RingHom.HoldsForLocalizationAway.of_bijective
(H : RingHom.HoldsForLocalizationAway P) (hf : Function.Bijective f) :
P f := by
letI := f.toAlgebra
have := IsLocalization.at_units (.powers (1 : R)) (by simp)
have := IsLocalization.isLocalization_of_algEquiv (.powers (1 : R))
(AlgEquiv.ofBijective (Algebra.ofId R S) hf)
exact H _ 1
variable {P f R' S'}
lemma RingHom.StableUnderComposition.stableUnderCompositionWithLocalizationAway
(hPc : RingHom.StableUnderComposition P) (hPl : HoldsForLocalizationAway P) :
StableUnderCompositionWithLocalizationAway P := by
constructor
· introv _ _ hf
exact hPc _ _ (hPl S r) hf
· introv _ _ hf
exact hPc _ _ hf (hPl T s)
lemma RingHom.HoldsForLocalizationAway.containsIdentities (hPl : HoldsForLocalizationAway P) :
ContainsIdentities P := by
introv R
exact hPl.of_bijective _ _ Function.bijective_id
lemma RingHom.LocalizationAwayPreserves.respectsIso
(hP : LocalizationAwayPreserves P) :
RespectsIso P where
left {R S T} _ _ _ f e hf := by
letI := e.toRingHom.toAlgebra
have : IsLocalization.Away (1 : R) R :=
IsLocalization.away_of_isUnit_of_bijective _ isUnit_one (Equiv.refl _).bijective
have : IsLocalization.Away (f 1) T :=
IsLocalization.away_of_isUnit_of_bijective _ (by simp) e.bijective
convert hP f 1 R T hf
trans (IsLocalization.Away.map R T f 1).comp (algebraMap R R)
· rw [IsLocalization.Away.map, IsLocalization.map_comp]; rfl
· rfl
right {R S T} _ _ _ f e hf := by
letI := e.symm.toRingHom.toAlgebra
have : IsLocalization.Away (1 : S) R :=
IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.symm.bijective
have : IsLocalization.Away (f 1) T :=
IsLocalization.away_of_isUnit_of_bijective _ (by simp) (Equiv.refl _).bijective
convert hP f 1 R T hf
have : (IsLocalization.Away.map R T f 1).comp e.symm.toRingHom = f :=
IsLocalization.map_comp ..
conv_lhs => rw [← this, RingHom.comp_assoc]
simp only [RingEquiv.toRingHom_eq_coe, RingEquiv.symm_comp, RingHomCompTriple.comp_eq]
lemma RingHom.StableUnderCompositionWithLocalizationAway.respectsIso
(hP : StableUnderCompositionWithLocalizationAway P) :
RespectsIso P where
left {R S T} _ _ _ f e hf := by
letI := e.toRingHom.toAlgebra
have : IsLocalization.Away (1 : S) T :=
IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.bijective
exact hP.right T (1 : S) f hf
right {R S T} _ _ _ f e hf := by
letI := e.toRingHom.toAlgebra
have : IsLocalization.Away (1 : R) S :=
IsLocalization.away_of_isUnit_of_bijective _ isUnit_one e.bijective
exact hP.left S (1 : R) f hf
theorem RingHom.PropertyIsLocal.respectsIso (hP : RingHom.PropertyIsLocal @P) :
RingHom.RespectsIso @P :=
hP.localizationAwayPreserves.respectsIso
-- Almost all arguments are implicit since this is not intended to use mid-proof.
theorem RingHom.LocalizationPreserves.away (H : RingHom.LocalizationPreserves @P) :
RingHom.LocalizationAwayPreserves P := by
intro R S _ _ f r R' S' _ _ _ _ _ _ hf
have : IsLocalization ((Submonoid.powers r).map f) S' := by rw [Submonoid.map_powers]; assumption
exact H f (Submonoid.powers r) R' S' hf
lemma RingHom.PropertyIsLocal.HoldsForLocalizationAway (hP : RingHom.PropertyIsLocal @P)
(hPi : ContainsIdentities P) :
RingHom.HoldsForLocalizationAway @P := by
introv R _
have : algebraMap R S = (algebraMap R S).comp (RingHom.id R) := by simp
rw [this]
apply hP.StableUnderCompositionWithLocalizationAwayTarget S r
apply hPi
theorem RingHom.OfLocalizationSpanTarget.ofLocalizationSpan
(hP : RingHom.OfLocalizationSpanTarget @P)
(hP' : RingHom.StableUnderCompositionWithLocalizationAwaySource @P) :
RingHom.OfLocalizationSpan @P := by
introv R hs hs'
apply_fun Ideal.map f at hs
rw [Ideal.map_span, Ideal.map_top] at hs
apply hP _ _ hs
rintro ⟨_, r, hr, rfl⟩
rw [← IsLocalization.map_comp (M := Submonoid.powers r) (S := Localization.Away r)
(T := Submonoid.powers (f r))]
· apply hP' _ r
exact hs' ⟨r, hr⟩
lemma RingHom.OfLocalizationSpan.ofIsLocalization
(hP : RingHom.OfLocalizationSpan P) (hPi : RingHom.RespectsIso P)
{R S : Type u} [CommRing R] [CommRing S] (f : R →+* S) (s : Set R) (hs : Ideal.span s = ⊤)
(hT : ∀ r : s, ∃ (Rᵣ Sᵣ : Type u) (_ : CommRing Rᵣ) (_ : CommRing Sᵣ)
(_ : Algebra R Rᵣ) (_ : Algebra S Sᵣ) (_ : IsLocalization.Away r.val Rᵣ)
(_ : IsLocalization.Away (f r.val) Sᵣ) (fᵣ : Rᵣ →+* Sᵣ)
(_ : fᵣ.comp (algebraMap R Rᵣ) = (algebraMap S Sᵣ).comp f),
P fᵣ) : P f := by
apply hP _ s hs
intro r
obtain ⟨Rᵣ, Sᵣ, _, _, _, _, _, _, fᵣ, hfᵣ, hf⟩ := hT r
let e₁ := (Localization.algEquiv (.powers r.val) Rᵣ).toRingEquiv
let e₂ := (IsLocalization.algEquiv (.powers (f r.val))
(Localization (.powers (f r.val))) Sᵣ).symm.toRingEquiv
have : Localization.awayMap f r.val =
(e₂.toRingHom.comp fᵣ).comp e₁.toRingHom := by
apply IsLocalization.ringHom_ext (.powers r.val)
ext x
have : fᵣ ((algebraMap R Rᵣ) x) = algebraMap S Sᵣ (f x) := by
rw [← RingHom.comp_apply, hfᵣ, RingHom.comp_apply]
simp [-AlgEquiv.symm_toRingEquiv, e₂, e₁, Localization.awayMap, IsLocalization.Away.map, this]
rw [this]
apply hPi.right
apply hPi.left
exact hf
/-- Variant of `RingHom.OfLocalizationSpan.ofIsLocalization` where
`fᵣ = IsLocalization.Away.map`. -/
lemma RingHom.OfLocalizationSpan.ofIsLocalization'
(hP : RingHom.OfLocalizationSpan P) (hPi : RingHom.RespectsIso P)
{R S : Type u} [CommRing R] [CommRing S] (f : R →+* S) (s : Set R) (hs : Ideal.span s = ⊤)
(hT : ∀ r : s, ∃ (Rᵣ Sᵣ : Type u) (_ : CommRing Rᵣ) (_ : CommRing Sᵣ)
(_ : Algebra R Rᵣ) (_ : Algebra S Sᵣ) (_ : IsLocalization.Away r.val Rᵣ)
(_ : IsLocalization.Away (f r.val) Sᵣ),
P (IsLocalization.Away.map Rᵣ Sᵣ f r)) : P f := by
apply hP.ofIsLocalization hPi _ s hs
intro r
obtain ⟨Rᵣ, Sᵣ, _, _, _, _, _, _, hf⟩ := hT r
exact ⟨Rᵣ, Sᵣ, inferInstance, inferInstance, inferInstance, inferInstance,
inferInstance, inferInstance, IsLocalization.Away.map Rᵣ Sᵣ f r, IsLocalization.map_comp _, hf⟩
lemma RingHom.OfLocalizationSpanTarget.ofIsLocalization
(hP : RingHom.OfLocalizationSpanTarget P) (hP' : RingHom.RespectsIso P)
{R S : Type u} [CommRing R] [CommRing S] (f : R →+* S) (s : Set S) (hs : Ideal.span s = ⊤)
(hT : ∀ r : s, ∃ (T : Type u) (_ : CommRing T) (_ : Algebra S T)
(_ : IsLocalization.Away (r : S) T), P ((algebraMap S T).comp f)) : P f := by
apply hP _ s hs
intro r
obtain ⟨T, _, _, _, hT⟩ := hT r
convert hP'.1 _
(Localization.algEquiv (R := S) (Submonoid.powers (r : S)) T).symm.toRingEquiv hT
rw [← RingHom.comp_assoc, RingEquiv.toRingHom_eq_coe, AlgEquiv.toRingEquiv_eq_coe,
AlgEquiv.toRingEquiv_toRingHom, Localization.coe_algEquiv_symm, IsLocalization.map_comp,
RingHom.comp_id]
section
variable {Q : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
lemma RingHom.OfLocalizationSpanTarget.and (hP : OfLocalizationSpanTarget P)
(hQ : OfLocalizationSpanTarget Q) :
OfLocalizationSpanTarget (fun f ↦ P f ∧ Q f) := by
introv R hs hf
exact ⟨hP f s hs fun r ↦ (hf r).1, hQ f s hs fun r ↦ (hf r).2⟩
lemma RingHom.OfLocalizationSpan.and (hP : OfLocalizationSpan P) (hQ : OfLocalizationSpan Q) :
OfLocalizationSpan (fun f ↦ P f ∧ Q f) := by
introv R hs hf
exact ⟨hP f s hs fun r ↦ (hf r).1, hQ f s hs fun r ↦ (hf r).2⟩
lemma RingHom.LocalizationAwayPreserves.and (hP : LocalizationAwayPreserves P)
(hQ : LocalizationAwayPreserves Q) :
LocalizationAwayPreserves (fun f ↦ P f ∧ Q f) := by
introv R h
exact ⟨hP f r R' S' h.1, hQ f r R' S' h.2⟩
lemma RingHom.StableUnderCompositionWithLocalizationAwayTarget.and
(hP : StableUnderCompositionWithLocalizationAwayTarget P)
(hQ : StableUnderCompositionWithLocalizationAwayTarget Q) :
StableUnderCompositionWithLocalizationAwayTarget (fun f ↦ P f ∧ Q f) := by
introv R h hf
exact ⟨hP T s f hf.1, hQ T s f hf.2⟩
lemma RingHom.PropertyIsLocal.and (hP : PropertyIsLocal P) (hQ : PropertyIsLocal Q) :
PropertyIsLocal (fun f ↦ P f ∧ Q f) where
localizationAwayPreserves := hP.localizationAwayPreserves.and hQ.localizationAwayPreserves
ofLocalizationSpanTarget := hP.ofLocalizationSpanTarget.and hQ.ofLocalizationSpanTarget
ofLocalizationSpan := hP.ofLocalizationSpan.and hQ.ofLocalizationSpan
StableUnderCompositionWithLocalizationAwayTarget :=
hP.StableUnderCompositionWithLocalizationAwayTarget.and
hQ.StableUnderCompositionWithLocalizationAwayTarget
end
section
variable (hP : RingHom.IsStableUnderBaseChange @P)
variable {R S Rᵣ Sᵣ : Type u} [CommRing R] [CommRing S] [CommRing Rᵣ] [CommRing Sᵣ] [Algebra R Rᵣ]
[Algebra S Sᵣ]
include hP
/-- Let `S` be an `R`-algebra and `Sᵣ` and `Rᵣ` be the respective localizations at a submonoid
`M` of `R`. If `P` is stable under base change and `P` holds for `algebraMap R S`, then
`P` holds for `algebraMap Rᵣ Sᵣ`. -/
lemma RingHom.IsStableUnderBaseChange.of_isLocalization [Algebra R S] [Algebra R Sᵣ] [Algebra Rᵣ Sᵣ]
[IsScalarTower R S Sᵣ] [IsScalarTower R Rᵣ Sᵣ]
(M : Submonoid R) [IsLocalization M Rᵣ] [IsLocalization (Algebra.algebraMapSubmonoid S M) Sᵣ]
(h : P (algebraMap R S)) : P (algebraMap Rᵣ Sᵣ) :=
letI : Algebra.IsPushout R S Rᵣ Sᵣ := Algebra.isPushout_of_isLocalization M Rᵣ S Sᵣ
hP R S Rᵣ Sᵣ h
/-- If `P` is stable under base change and holds for `f`, then `P` holds for `f` localized
at any submonoid `M` of `R`. -/
lemma RingHom.IsStableUnderBaseChange.isLocalization_map (M : Submonoid R) [IsLocalization M Rᵣ]
(f : R →+* S) [IsLocalization (M.map f) Sᵣ] (hf : P f) :
P (IsLocalization.map Sᵣ f M.le_comap_map : Rᵣ →+* Sᵣ) := by
algebraize [f, IsLocalization.map (S := Rᵣ) Sᵣ f M.le_comap_map,
(IsLocalization.map (S := Rᵣ) Sᵣ f M.le_comap_map).comp (algebraMap R Rᵣ)]
haveI : IsScalarTower R S Sᵣ := IsScalarTower.of_algebraMap_eq'
(IsLocalization.map_comp M.le_comap_map)
haveI : IsLocalization (Algebra.algebraMapSubmonoid S M) Sᵣ :=
inferInstanceAs <| IsLocalization (M.map f) Sᵣ
apply hP.of_isLocalization M hf
lemma RingHom.IsStableUnderBaseChange.localizationPreserves : LocalizationPreserves P := by
introv R hf
exact hP.isLocalization_map _ _ hf
end
end RingHom
end Properties
section Ideal
variable {R : Type*} (S : Type*) [CommSemiring R] [CommSemiring S] [Algebra R S]
variable (p : Submonoid R) [IsLocalization p S]
theorem Ideal.localized'_eq_map (I : Ideal R) :
Submodule.localized' S p (Algebra.linearMap R S) I = I.map (algebraMap R S) := by
rw [map, span, Submodule.localized'_eq_span, Algebra.coe_linearMap]
theorem Ideal.localized₀_eq_restrictScalars_map (I : Ideal R) :
Submodule.localized₀ p (Algebra.linearMap R S) I = (I.map (algebraMap R S)).restrictScalars R :=
congr(Submodule.restrictScalars R $(localized'_eq_map S p I))
theorem Algebra.idealMap_eq_ofEq_comp_toLocalized₀ (I : Ideal R) :
Algebra.idealMap S I =
(LinearEquiv.ofEq _ _ <| Ideal.localized₀_eq_restrictScalars_map S p I).toLinearMap ∘ₗ
Submodule.toLocalized₀ p (Algebra.linearMap R S) I :=
rfl
theorem Ideal.mem_of_localization_maximal {r : R} {J : Ideal R}
(h : ∀ (P : Ideal R) (_ : P.IsMaximal),
algebraMap R _ r ∈ Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
r ∈ J :=
Submodule.mem_of_localization_maximal _ _ _ _ fun P hP ↦ by
apply (localized'_eq_map (Localization.AtPrime P) P.primeCompl J).symm ▸ h P hP
/-- Let `I J : Ideal R`. If the localization of `I` at each maximal ideal `P` is included in
the localization of `J` at `P`, then `I ≤ J`. -/
theorem Ideal.le_of_localization_maximal {I J : Ideal R}
(h : ∀ (P : Ideal R) (_ : P.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime P)) I ≤
Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
I ≤ J :=
fun _ hm ↦ mem_of_localization_maximal fun P hP ↦ h P hP (mem_map_of_mem _ hm)
/-- Let `I J : Ideal R`. If the localization of `I` at each maximal ideal `P` is equal to
the localization of `J` at `P`, then `I = J`. -/
theorem Ideal.eq_of_localization_maximal {I J : Ideal R}
(h : ∀ (P : Ideal R) (_ : P.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime P)) I =
Ideal.map (algebraMap R (Localization.AtPrime P)) J) :
I = J :=
le_antisymm (le_of_localization_maximal fun P hP ↦ (h P hP).le)
(le_of_localization_maximal fun P hP ↦ (h P hP).ge)
/-- An ideal is trivial if its localization at every maximal ideal is trivial. -/
theorem ideal_eq_bot_of_localization' (I : Ideal R)
(h : ∀ (J : Ideal R) (_ : J.IsMaximal),
Ideal.map (algebraMap R (Localization.AtPrime J)) I = ⊥) :
I = ⊥ :=
Ideal.eq_of_localization_maximal fun P hP => by simpa using h P hP
theorem eq_zero_of_localization (r : R)
(h : ∀ (J : Ideal R) (_ : J.IsMaximal), algebraMap R (Localization.AtPrime J) r = 0) :
r = 0 :=
Module.eq_zero_of_localization_maximal _ (fun _ _ ↦ Algebra.linearMap R _) r h
/-- An ideal is trivial if its localization at every maximal ideal is trivial. -/
theorem ideal_eq_bot_of_localization (I : Ideal R)
(h : ∀ (J : Ideal R) (_ : J.IsMaximal),
IsLocalization.coeSubmodule (Localization.AtPrime J) I = ⊥) :
I = ⊥ :=
bot_unique fun r hr ↦ eq_zero_of_localization r fun J hJ ↦ (h J hJ).le ⟨r, hr, rfl⟩
end Ideal |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Projective.lean | import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.Algebra.Module.Projective
import Mathlib.LinearAlgebra.Dimension.Constructions
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.RingTheory.LocalProperties.Submodule
/-!
# Being projective is a local property
## Main results
- `LinearMap.split_surjective_of_localization_maximal`
If `N` is finitely presented, then `f : M →ₗ[R] N`
being split injective can be checked on stalks (of maximal ideals).
- `Module.projective_of_localization_maximal` If `M` is finitely presented,
then `M` being projective can be checked on stalks (of maximal ideals).
## TODO
- Show that being projective is Zariski-local (very hard)
-/
universe uM
variable {R N N' : Type*} {M : Type uM} [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N]
variable [Module R N] [AddCommGroup N'] [Module R N'] (S : Submonoid R)
theorem Module.free_of_isLocalizedModule {Rₛ Mₛ} [AddCommGroup Mₛ] [Module R Mₛ]
[CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ Mₛ] [IsScalarTower R Rₛ Mₛ]
(S) (f : M →ₗ[R] Mₛ) [IsLocalization S Rₛ] [IsLocalizedModule S f] [Module.Free R M] :
Module.Free Rₛ Mₛ :=
Free.of_equiv (IsLocalizedModule.isBaseChange S Rₛ f).equiv
universe uR' uM' in
/--
Also see `IsLocalizedModule.lift_rank_eq` for a version for non-free modules,
but requires `S` to not contain any zero-divisors.
-/
theorem Module.lift_rank_of_isLocalizedModule_of_free
(Rₛ : Type uR') {Mₛ : Type uM'} [AddCommGroup Mₛ] [Module R Mₛ]
[CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ Mₛ] [IsScalarTower R Rₛ Mₛ] (S : Submonoid R)
(f : M →ₗ[R] Mₛ) [IsLocalization S Rₛ] [IsLocalizedModule S f] [Module.Free R M]
[Nontrivial Rₛ] :
Cardinal.lift.{uM} (Module.rank Rₛ Mₛ) = Cardinal.lift.{uM'} (Module.rank R M) := by
apply Cardinal.lift_injective.{max uM' uR'}
have := (algebraMap R Rₛ).domain_nontrivial
have := (IsLocalizedModule.isBaseChange S Rₛ f).equiv.lift_rank_eq.symm
simp only [rank_tensorProduct, rank_self,
Cardinal.lift_one, one_mul, Cardinal.lift_lift] at this ⊢
convert this
exact Cardinal.lift_umax
theorem Module.finrank_of_isLocalizedModule_of_free
(Rₛ : Type*) {Mₛ : Type*} [AddCommGroup Mₛ] [Module R Mₛ]
[CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ Mₛ] [IsScalarTower R Rₛ Mₛ] (S : Submonoid R)
(f : M →ₗ[R] Mₛ) [IsLocalization S Rₛ] [IsLocalizedModule S f] [Module.Free R M]
[Nontrivial Rₛ] :
Module.finrank Rₛ Mₛ = Module.finrank R M := by
simpa using congr(Cardinal.toNat $(Module.lift_rank_of_isLocalizedModule_of_free Rₛ S f))
theorem Module.projective_of_isLocalizedModule {Rₛ Mₛ} [AddCommGroup Mₛ] [Module R Mₛ]
[CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ Mₛ] [IsScalarTower R Rₛ Mₛ]
(S) (f : M →ₗ[R] Mₛ) [IsLocalization S Rₛ] [IsLocalizedModule S f] [Module.Projective R M] :
Module.Projective Rₛ Mₛ :=
Projective.of_equiv (IsLocalizedModule.isBaseChange S Rₛ f).equiv
theorem LinearMap.split_surjective_of_localization_maximal
(f : M →ₗ[R] N) [Module.FinitePresentation R N]
(H : ∀ (I : Ideal R) (_ : I.IsMaximal),
∃ (g : _ →ₗ[Localization.AtPrime I] _),
(LocalizedModule.map I.primeCompl f).comp g = LinearMap.id) :
∃ (g : N →ₗ[R] M), f.comp g = LinearMap.id := by
change LinearMap.id ∈ LinearMap.range (LinearMap.llcomp R N M N f)
refine Submodule.mem_of_localization_maximal _ (fun P _ ↦ LocalizedModule.map P.primeCompl) _ _
fun I hI ↦ ?_
rw [LocalizedModule.map_id]
have : LinearMap.id ∈ LinearMap.range (LinearMap.llcomp _
(LocalizedModule I.primeCompl N) _ _ (LocalizedModule.map I.primeCompl f)) := H I hI
convert this
· ext f
constructor
· intro hf
obtain ⟨a, ha, c, rfl⟩ := hf
obtain ⟨g, rfl⟩ := ha
use IsLocalizedModule.mk' (LocalizedModule.map I.primeCompl) g c
apply ((Module.End.isUnit_iff _).mp <| IsLocalizedModule.map_units
(LocalizedModule.map I.primeCompl) c).injective
dsimp
conv_rhs => rw [← Submonoid.smul_def]
conv_lhs => rw [← LinearMap.map_smul_of_tower]
rw [← Submonoid.smul_def, IsLocalizedModule.mk'_cancel', IsLocalizedModule.mk'_cancel']
apply LinearMap.restrictScalars_injective R
apply IsLocalizedModule.ext I.primeCompl (LocalizedModule.mkLinearMap I.primeCompl N)
· exact IsLocalizedModule.map_units (LocalizedModule.mkLinearMap I.primeCompl N)
ext
simp only [LocalizedModule.map_mk, LinearMap.coe_comp, LinearMap.coe_restrictScalars,
Function.comp_apply, LocalizedModule.mkLinearMap_apply, LinearMap.llcomp_apply,
LocalizedModule.map_mk]
· rintro ⟨g, rfl⟩
obtain ⟨⟨g, s⟩, rfl⟩ :=
IsLocalizedModule.mk'_surjective I.primeCompl (LocalizedModule.map I.primeCompl) g
simp only [Function.uncurry_apply_pair]
refine ⟨f.comp g, ⟨g, rfl⟩, s, ?_⟩
apply ((Module.End.isUnit_iff _).mp <| IsLocalizedModule.map_units
(LocalizedModule.map I.primeCompl) s).injective
simp only [Module.algebraMap_end_apply, ← Submonoid.smul_def, IsLocalizedModule.mk'_cancel',
← LinearMap.map_smul_of_tower]
apply LinearMap.restrictScalars_injective R
apply IsLocalizedModule.ext I.primeCompl (LocalizedModule.mkLinearMap I.primeCompl N)
· exact IsLocalizedModule.map_units (LocalizedModule.mkLinearMap I.primeCompl N)
ext
simp only [coe_comp, coe_restrictScalars, Function.comp_apply,
LocalizedModule.mkLinearMap_apply, LocalizedModule.map_mk, llcomp_apply]
theorem Module.projective_of_localization_maximal (H : ∀ (I : Ideal R) (_ : I.IsMaximal),
Module.Projective (Localization.AtPrime I) (LocalizedModule I.primeCompl M))
[Module.FinitePresentation R M] : Module.Projective R M := by
have : Module.Finite R M := by infer_instance
have : (⊤ : Submodule R M).FG := this.fg_top
have : ∃ (s : Finset M), _ := this
obtain ⟨s, hs⟩ := this
let N := s →₀ R
let f : N →ₗ[R] M := Finsupp.linearCombination R (Subtype.val : s → M)
have hf : Function.Surjective f := by
rw [← LinearMap.range_eq_top, Finsupp.range_linearCombination, Subtype.range_val]
convert hs
have (I : Ideal R) (hI : I.IsMaximal) :=
letI := H I hI
Module.projective_lifting_property (LocalizedModule.map I.primeCompl f) LinearMap.id
(LocalizedModule.map_surjective _ _ hf)
obtain ⟨g, hg⟩ := LinearMap.split_surjective_of_localization_maximal _ this
exact Module.Projective.of_split _ _ hg
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommRing (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
(Mₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommGroup (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module (Rₚ P) (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsScalarTower R (Rₚ P) (Mₚ P)]
(f : ∀ (P : Ideal R) [P.IsMaximal], M →ₗ[R] Mₚ P)
[inst : ∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule P.primeCompl (f P)]
attribute [local instance] RingHomInvPair.of_ringEquiv in
include f in
/--
A variant of `Module.projective_of_localization_maximal` that accepts `IsLocalizedModule`.
-/
theorem Module.projective_of_localization_maximal'
(H : ∀ (I : Ideal R) (_ : I.IsMaximal), Module.Projective (Rₚ I) (Mₚ I))
[Module.FinitePresentation R M] : Module.Projective R M := by
apply Module.projective_of_localization_maximal
intro P hP
refine Module.Projective.of_ringEquiv (M := Mₚ P)
(IsLocalization.algEquiv P.primeCompl (Rₚ P) (Localization.AtPrime P)).toRingEquiv
{ __ := IsLocalizedModule.linearEquiv P.primeCompl (f P)
(LocalizedModule.mkLinearMap P.primeCompl M)
map_smul' := ?_ }
· intro r m
obtain ⟨r, s, rfl⟩ := IsLocalization.exists_mk'_eq P.primeCompl r
apply ((Module.End.isUnit_iff _).mp
(IsLocalizedModule.map_units (LocalizedModule.mkLinearMap P.primeCompl M) s)).1
dsimp
simp only [← map_smul, ← smul_assoc, IsLocalization.smul_mk'_self, algebraMap_smul,
IsLocalization.map_id_mk'] |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Exactness.lean | import Mathlib.Algebra.Exact
import Mathlib.RingTheory.LocalProperties.Submodule
import Mathlib.RingTheory.Localization.Algebra
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.Algebra.Module.LocalizedModule.AtPrime
import Mathlib.Algebra.Module.LocalizedModule.Away
/-!
# Local properties about linear maps
In this file, we show that
injectivity, surjectivity, bijectivity and exactness of linear maps are local properties.
More precisely, we show that these can be checked at maximal ideals and on standard covers.
-/
open Submodule LocalizedModule Ideal LinearMap
section isLocalized_maximal
open IsLocalizedModule
variable {R M N L : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid N] [Module R N] [AddCommMonoid L] [Module R L]
-- For every maximal ideal `p` of `R`, let `Mₚ` (resp. `Nₚ`, resp. `Lₚ`) the localizations
-- of `M` (resp. `N`, resp. `L`) at `p`.
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommSemiring (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
(Mₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module (Rₚ P) (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsScalarTower R (Rₚ P) (Mₚ P)]
(f : ∀ (P : Ideal R) [P.IsMaximal], M →ₗ[R] Mₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule.AtPrime P (f P)]
(Nₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (Nₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Nₚ P)]
(g : ∀ (P : Ideal R) [P.IsMaximal], N →ₗ[R] Nₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule.AtPrime P (g P)]
(Lₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (Lₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Lₚ P)]
(h : ∀ (P : Ideal R) [P.IsMaximal], L →ₗ[R] Lₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule.AtPrime P (h P)]
(F : M →ₗ[R] N) (G : N →ₗ[R] L)
theorem injective_of_isLocalized_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal], Function.Injective (map P.primeCompl (f P) (g P) F)) :
Function.Injective F :=
fun x y eq ↦ Module.eq_of_localization_maximal _ f _ _ fun P _ ↦ H P <| by simp [eq]
theorem surjective_of_isLocalized_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal], Function.Surjective (map P.primeCompl (f P) (g P) F)) :
Function.Surjective F :=
range_eq_top.mp <| eq_top_of_localization₀_maximal Nₚ g _ <|
fun P _ ↦ (range_localizedMap_eq_localized₀_range _ (f P) (g P) F).symm.trans <|
range_eq_top.mpr <| H P
theorem bijective_of_isLocalized_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal], Function.Bijective (map P.primeCompl (f P) (g P) F)) :
Function.Bijective F :=
⟨injective_of_isLocalized_maximal Mₚ f Nₚ g F fun J _ ↦ (H J).1,
surjective_of_isLocalized_maximal Mₚ f Nₚ g F fun J _ ↦ (H J).2⟩
theorem exact_of_isLocalized_maximal (H : ∀ (J : Ideal R) [J.IsMaximal],
Function.Exact (map J.primeCompl (f J) (g J) F) (map J.primeCompl (g J) (h J) G)) :
Function.Exact F G := by
simp only [LinearMap.exact_iff] at H ⊢
apply eq_of_localization₀_maximal Nₚ g
intro J hJ
rw [← LinearMap.range_localizedMap_eq_localized₀_range _ (f J) (g J) F,
← LinearMap.ker_localizedMap_eq_localized₀_ker J.primeCompl (g J) (h J) G]
have := SetLike.ext_iff.mp <| H J
ext x
simp only [mem_range, mem_ker] at this ⊢
exact this x
theorem LinearIndependent.of_isLocalized_maximal {ι} (v : ι → M)
(H : ∀ (P : Ideal R) [P.IsMaximal], LinearIndependent (Rₚ P) (f P ∘ v)) :
LinearIndependent R v :=
injective_of_isLocalized_maximal _ (fun P _ ↦ Finsupp.mapRange.linearMap <|
Algebra.linearMap R (Rₚ P)) _ f _ fun P _ ↦ by rw [map_linearCombination]; exact H P
end isLocalized_maximal
section localized_maximal
variable {R M N L : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid N] [Module R N] [AddCommMonoid L] [Module R L] (f : M →ₗ[R] N) (g : N →ₗ[R] L)
theorem injective_of_localized_maximal
(h : ∀ (J : Ideal R) [J.IsMaximal], Function.Injective (map J.primeCompl f)) :
Function.Injective f :=
injective_of_isLocalized_maximal _ (fun _ _ ↦ mkLinearMap _ _) _ (fun _ _ ↦ mkLinearMap _ _) f h
theorem surjective_of_localized_maximal
(h : ∀ (J : Ideal R) [J.IsMaximal], Function.Surjective (map J.primeCompl f)) :
Function.Surjective f :=
surjective_of_isLocalized_maximal _ (fun _ _ ↦ mkLinearMap _ _) _ (fun _ _ ↦ mkLinearMap _ _) f h
theorem bijective_of_localized_maximal
(h : ∀ (J : Ideal R) [J.IsMaximal], Function.Bijective (map J.primeCompl f)) :
Function.Bijective f :=
⟨injective_of_localized_maximal _ fun J _ ↦ (h J).1,
surjective_of_localized_maximal _ fun J _ ↦ (h J).2⟩
theorem exact_of_localized_maximal
(h : ∀ (J : Ideal R) [J.IsMaximal], Function.Exact (map J.primeCompl f) (map J.primeCompl g)) :
Function.Exact f g :=
exact_of_isLocalized_maximal _ (fun _ _ ↦ mkLinearMap _ _) _ (fun _ _ ↦ mkLinearMap _ _)
_ (fun _ _ ↦ mkLinearMap _ _) f g h
end localized_maximal
section isLocalized_span
open IsLocalizedModule
variable {R M N L : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid N] [Module R N] [AddCommMonoid L] [Module R L] (s : Set R) (spn : Ideal.span s = ⊤)
include spn
-- For every element `r ∈ s`, let `Mᵣ` (resp. `Nᵣ`, resp. `Lᵣ`) the localizations
-- of `M` (resp. `N`, resp. `L`) away from `r`.
variable
(Mₚ : ∀ _ : s, Type*)
[∀ r : s, AddCommMonoid (Mₚ r)]
[∀ r : s, Module R (Mₚ r)]
(f : ∀ r : s, M →ₗ[R] Mₚ r)
[∀ r : s, IsLocalizedModule.Away r.1 (f r)]
(Nₚ : ∀ _ : s, Type*)
[∀ r : s, AddCommMonoid (Nₚ r)]
[∀ r : s, Module R (Nₚ r)]
(g : ∀ r : s, N →ₗ[R] Nₚ r)
[∀ r : s, IsLocalizedModule.Away r.1 (g r)]
(Lₚ : ∀ _ : s, Type*)
[∀ r : s, AddCommMonoid (Lₚ r)]
[∀ r : s, Module R (Lₚ r)]
(h : ∀ r : s, L →ₗ[R] Lₚ r)
[∀ r : s, IsLocalizedModule.Away r.1 (h r)]
(F : M →ₗ[R] N) (G : N →ₗ[R] L)
theorem injective_of_isLocalized_span
(H : ∀ r : s, Function.Injective (map (.powers r.1) (f r) (g r) F)) :
Function.Injective F :=
fun x y eq ↦ Module.eq_of_isLocalized_span _ spn _ f _ _ fun P ↦ H P <| by simp [eq]
theorem surjective_of_isLocalized_span
(H : ∀ r : s, Function.Surjective (map (.powers r.1) (f r) (g r) F)) :
Function.Surjective F :=
range_eq_top.mp <| eq_top_of_isLocalized₀_span s spn Nₚ g fun r ↦
(range_localizedMap_eq_localized₀_range _ (f r) (g r) F).symm.trans <| range_eq_top.mpr <| H r
theorem bijective_of_isLocalized_span
(H : ∀ r : s, Function.Bijective (map (.powers r.1) (f r) (g r) F)) :
Function.Bijective F :=
⟨injective_of_isLocalized_span _ spn Mₚ f Nₚ g F fun r ↦ (H r).1,
surjective_of_isLocalized_span _ spn Mₚ f Nₚ g F fun r ↦ (H r).2⟩
lemma exact_of_isLocalized_span (H : ∀ r : s, Function.Exact
(map (.powers r.1) (f r) (g r) F) (map (.powers r.1) (g r) (h r) G)) :
Function.Exact F G := by
simp only [LinearMap.exact_iff] at H ⊢
apply Submodule.eq_of_isLocalized₀_span s spn Nₚ g
intro r
rw [← LinearMap.range_localizedMap_eq_localized₀_range _ (f r) (g r) F]
rw [← LinearMap.ker_localizedMap_eq_localized₀_ker (.powers r.1) (g r) (h r) G]
have := SetLike.ext_iff.mp <| H r
ext x
simp only [mem_range, mem_ker] at this ⊢
exact this x
end isLocalized_span
section localized_span
variable {R M N L : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid N] [Module R N] [AddCommMonoid L] [Module R L]
(s : Set R) (spn : span s = ⊤) (f : M →ₗ[R] N) (g : N →ₗ[R] L)
include spn
theorem injective_of_localized_span
(h : ∀ r : s, Function.Injective (map (.powers r.1) f)) :
Function.Injective f :=
injective_of_isLocalized_span s spn _ (fun _ ↦ mkLinearMap _ _) _ (fun _ ↦ mkLinearMap _ _) f h
theorem surjective_of_localized_span
(h : ∀ r : s, Function.Surjective (map (.powers r.1) f)) :
Function.Surjective f :=
surjective_of_isLocalized_span s spn _ (fun _ ↦ mkLinearMap _ _) _ (fun _ ↦ mkLinearMap _ _) f h
theorem bijective_of_localized_span
(h : ∀ r : s, Function.Bijective (map (.powers r.1) f)) :
Function.Bijective f :=
⟨injective_of_localized_span _ spn _ fun r ↦ (h r).1,
surjective_of_localized_span _ spn _ fun r ↦ (h r).2⟩
lemma exact_of_localized_span
(h : ∀ r : s, Function.Exact (map (.powers r.1) f) (map (.powers r.1) g)) :
Function.Exact f g :=
exact_of_isLocalized_span s spn _ (fun _ ↦ mkLinearMap _ _) _ (fun _ ↦ mkLinearMap _ _)
_ (fun _ ↦ mkLinearMap _ _) f g h
end localized_span
section Algebra
variable {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
-- For every maximal ideal `p` of `R`, let `Rₚ` be the localization of `R` at `p`
-- and `Sₚ` the localization of `S` at `p`.
variable
(Rₚ : ∀ (p : Ideal R) [p.IsMaximal], Type*)
[∀ (p : Ideal R) [p.IsMaximal], CommSemiring (Rₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], Algebra R (Rₚ p)]
(Sₚ : ∀ (p : Ideal R) [p.IsMaximal], Type*)
[∀ (p : Ideal R) [p.IsMaximal], CommSemiring (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], Algebra S (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], Algebra (Rₚ p) (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], Algebra R (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], IsScalarTower R (Rₚ p) (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], IsScalarTower R S (Sₚ p)]
[∀ (p : Ideal R) [p.IsMaximal], IsLocalization.AtPrime (Rₚ p) p]
[∀ (p : Ideal R) [p.IsMaximal],
IsLocalizedModule.AtPrime p (IsScalarTower.toAlgHom R S (Sₚ p) : S →ₗ[R] (Sₚ p))]
open TensorProduct
lemma IsLocalizedModule.map_linearMap_of_isLocalization (Rₚ Sₚ : Type*) [CommSemiring Rₚ]
[Algebra R Rₚ] [CommSemiring Sₚ] [Algebra S Sₚ] [Algebra R Sₚ] [IsScalarTower R S Sₚ]
[Algebra Rₚ Sₚ] [IsScalarTower R Rₚ Sₚ] (p : Ideal R) [p.IsPrime]
[IsLocalization.AtPrime Rₚ p]
[IsLocalizedModule.AtPrime p (IsScalarTower.toAlgHom R S Sₚ : S →ₗ[R] Sₚ)] :
IsLocalizedModule.map p.primeCompl (Algebra.linearMap R Rₚ)
(IsScalarTower.toAlgHom R S Sₚ : S →ₗ[R] Sₚ) (Algebra.linearMap R S) =
(Algebra.linearMap Rₚ Sₚ).restrictScalars R := by
apply IsLocalizedModule.linearMap_ext p.primeCompl (Algebra.linearMap _ _)
(IsScalarTower.toAlgHom R S Sₚ : S →ₗ[R] Sₚ)
ext
simp only [LinearMap.coe_comp, Function.comp_apply, Algebra.linearMap_apply, map_one,
LinearMap.coe_restrictScalars]
rw [show 1 = Algebra.linearMap R Rₚ 1 by simp, IsLocalizedModule.map_apply]
simp
lemma injective_of_isLocalization_isMaximal
(H : ∀ (p : Ideal R) [p.IsMaximal], Function.Injective (algebraMap (Rₚ p) (Sₚ p))) :
Function.Injective (algebraMap R S) := by
apply injective_of_isLocalized_maximal (fun P _ ↦ Rₚ P) (fun P _ ↦ Algebra.linearMap _ _)
(fun P _ ↦ Sₚ P) (fun P _ ↦ IsScalarTower.toAlgHom R S (Sₚ P)) (Algebra.linearMap R S) _
intro p hp
convert_to Function.Injective ((Algebra.linearMap (Rₚ p) (Sₚ p)).restrictScalars R)
· rw [DFunLike.coe_fn_eq]
apply IsLocalizedModule.map_linearMap_of_isLocalization
· exact H p
lemma surjective_of_isLocalization_isMaximal
(H : ∀ (p : Ideal R) [p.IsMaximal], Function.Surjective (algebraMap (Rₚ p) (Sₚ p))) :
Function.Surjective (algebraMap R S) := by
apply surjective_of_isLocalized_maximal (fun P _ ↦ Rₚ P) (fun P _ ↦ Algebra.linearMap _ _)
(fun P _ ↦ Sₚ P) (fun P _ ↦ IsScalarTower.toAlgHom R S (Sₚ P)) (Algebra.linearMap R S) _
intro p hp
convert_to Function.Surjective ((Algebra.linearMap (Rₚ p) (Sₚ p)).restrictScalars R)
· rw [DFunLike.coe_fn_eq]
apply IsLocalizedModule.map_linearMap_of_isLocalization
· exact H p
lemma bijective_of_isLocalization_isMaximal
(H : ∀ (p : Ideal R) [p.IsMaximal], Function.Bijective (algebraMap (Rₚ p) (Sₚ p))) :
Function.Bijective (algebraMap R S) :=
⟨injective_of_isLocalization_isMaximal _ _ (fun p _ ↦ (H p).1),
surjective_of_isLocalization_isMaximal _ _ (fun p _ ↦ (H p).2)⟩
end Algebra
section IsLocalization
variable {R S : Type*} [CommSemiring R] [CommSemiring S] {s : Set R} (hs : span s = ⊤)
-- For every element `r ∈ s`, let `Rᵣ` be the localization of `R` away from `r`
-- and `Sᵣ` the localization of `S` away from `f r`.
variable (Rᵣ : s → Type*) [∀ r, CommSemiring (Rᵣ r)] [∀ r, Algebra R (Rᵣ r)]
(Sᵣ : s → Type*) [∀ r, CommSemiring (Sᵣ r)] [∀ r, Algebra S (Sᵣ r)]
variable (f : R →+* S) [∀ r, IsLocalization.Away r.val (Rᵣ r)]
[∀ r, IsLocalization.Away (f r.val) (Sᵣ r)]
include hs
lemma injective_of_isLocalization_of_span_eq_top
(h : ∀ r : s, Function.Injective (IsLocalization.Away.map (Rᵣ r) (Sᵣ r) f r.1)) :
Function.Injective f := by
algebraize [f]
letI (r : s) : Algebra R (Sᵣ r) := (algebraMap S (Sᵣ r)).comp f |>.toAlgebra
have (r : s) : IsScalarTower R S (Sᵣ r) := IsScalarTower.of_algebraMap_eq' rfl
have : ∀ r, IsLocalization.Away (algebraMap R S r.val) (Sᵣ r) := ‹_›
letI (r : s) : Algebra (Rᵣ r) (Sᵣ r) := localizationAlgebra (.powers r.val) S
have (r : s) : IsScalarTower R (Rᵣ r) (Sᵣ r) :=
.of_algebraMap_eq <| by simp [RingHom.algebraMap_toAlgebra]
apply injective_of_isLocalized_span s hs Rᵣ (fun r : s ↦ Algebra.linearMap _ _) _
(fun r : s ↦ ((IsScalarTower.toAlgHom R S (Sᵣ r)).toLinearMap)) (Algebra.linearMap R S)
simpa [IsLocalization.map_linearMap_eq_toLinearMap_mapₐ] using h
lemma surjective_of_isLocalization_of_span_eq_top
(h : ∀ r : s, Function.Surjective (IsLocalization.Away.map (Rᵣ r) (Sᵣ r) f r.1)) :
Function.Surjective f := by
algebraize [f]
letI (r : s) : Algebra R (Sᵣ r) := (algebraMap S (Sᵣ r)).comp f |>.toAlgebra
have (r : s) : IsScalarTower R S (Sᵣ r) := IsScalarTower.of_algebraMap_eq' rfl
have : ∀ r, IsLocalization.Away (algebraMap R S r.val) (Sᵣ r) := ‹_›
letI (r : s) : Algebra (Rᵣ r) (Sᵣ r) := localizationAlgebra (.powers r.val) S
have (r : s) : IsScalarTower R (Rᵣ r) (Sᵣ r) :=
.of_algebraMap_eq <| by simp [RingHom.algebraMap_toAlgebra]
apply surjective_of_isLocalized_span s hs Rᵣ (fun r : s ↦ Algebra.linearMap _ _) _
(fun r : s ↦ ((IsScalarTower.toAlgHom R S (Sᵣ r)).toLinearMap)) (Algebra.linearMap R S)
simpa [IsLocalization.map_linearMap_eq_toLinearMap_mapₐ] using h
lemma bijective_of_isLocalization_of_span_eq_top
(h : ∀ r : s, Function.Bijective (IsLocalization.Away.map (Rᵣ r) (Sᵣ r) f r.1)) :
Function.Bijective f :=
⟨injective_of_isLocalization_of_span_eq_top hs _ _ _ (fun r ↦ (h r).1),
surjective_of_isLocalization_of_span_eq_top hs _ _ _ (fun r ↦ (h r).2)⟩
end IsLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Submodule.lean | import Mathlib.Algebra.Module.LocalizedModule.Submodule
import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.Localization.Away.Basic
/-!
# Local properties of modules and submodules
In this file, we show that several conditions on submodules can be checked on stalks.
-/
open scoped nonZeroDivisors
variable {R M M₁ : Type*} [CommSemiring R] [AddCommMonoid M] [Module R M]
[AddCommMonoid M₁] [Module R M₁]
section maximal
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommSemiring (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
(Mₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module (Rₚ P) (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsScalarTower R (Rₚ P) (Mₚ P)]
(f : ∀ (P : Ideal R) [P.IsMaximal], M →ₗ[R] Mₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule P.primeCompl (f P)]
(M₁ₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (M₁ₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (M₁ₚ P)]
(f₁ : ∀ (P : Ideal R) [P.IsMaximal], M₁ →ₗ[R] M₁ₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule P.primeCompl (f₁ P)]
theorem Submodule.mem_of_localization_maximal (m : M) (N : Submodule R M)
(h : ∀ (P : Ideal R) [P.IsMaximal], f P m ∈ N.localized₀ P.primeCompl (f P)) :
m ∈ N := by
let I : Ideal R := N.comap (LinearMap.toSpanSingleton R M m)
suffices I = ⊤ by simpa [I] using I.eq_top_iff_one.mp this
refine Not.imp_symm I.exists_le_maximal fun ⟨P, hP, le⟩ ↦ ?_
obtain ⟨a, ha, s, e⟩ := h P
rw [← IsLocalizedModule.mk'_one P.primeCompl, IsLocalizedModule.mk'_eq_mk'_iff] at e
obtain ⟨t, ht⟩ := e
simp_rw [smul_smul] at ht
exact (t * s).2 (le <| by apply ht ▸ smul_mem _ _ ha)
/-- Let `N₁ N₂ : Submodule R M`. If the localization of `N₁` at each maximal ideal `P` is
included in the localization of `N₂` at `P`, then `N₁ ≤ N₂`. -/
theorem Submodule.le_of_localization_maximal {N₁ N₂ : Submodule R M}
(h : ∀ (P : Ideal R) [P.IsMaximal],
N₁.localized₀ P.primeCompl (f P) ≤ N₂.localized₀ P.primeCompl (f P)) :
N₁ ≤ N₂ :=
fun m hm ↦ mem_of_localization_maximal _ f _ _ fun P hP ↦ h P ⟨m, hm, 1, by simp⟩
/-- Let `N₁ N₂ : Submodule R M`. If the localization of `N₁` at each maximal ideal `P` is equal to
the localization of `N₂` at `P`, then `N₁ = N₂`. -/
theorem Submodule.eq_of_localization₀_maximal {N₁ N₂ : Submodule R M}
(h : ∀ (P : Ideal R) [P.IsMaximal],
N₁.localized₀ P.primeCompl (f P) = N₂.localized₀ P.primeCompl (f P)) :
N₁ = N₂ :=
le_antisymm (Submodule.le_of_localization_maximal Mₚ f fun P _ ↦ (h P).le)
(Submodule.le_of_localization_maximal Mₚ f fun P _ ↦ (h P).ge)
/-- A submodule is trivial if its localization at every maximal ideal is trivial. -/
theorem Submodule.eq_bot_of_localization₀_maximal (N : Submodule R M)
(h : ∀ (P : Ideal R) [P.IsMaximal], N.localized₀ P.primeCompl (f P) = ⊥) :
N = ⊥ :=
Submodule.eq_of_localization₀_maximal Mₚ f fun P hP ↦ by simpa using h P
theorem Submodule.eq_top_of_localization₀_maximal (N : Submodule R M)
(h : ∀ (P : Ideal R) [P.IsMaximal], N.localized₀ P.primeCompl (f P) = ⊤) :
N = ⊤ :=
Submodule.eq_of_localization₀_maximal Mₚ f fun P hP ↦ by simpa using h P
theorem Module.eq_of_localization_maximal (m m' : M)
(h : ∀ (P : Ideal R) [P.IsMaximal], f P m = f P m') :
m = m' := by
rw [← one_smul R m, ← one_smul R m']
by_contra ne
have ⟨P, mP, le⟩ := (eqIdeal R m m').exists_le_maximal ((Ideal.ne_top_iff_one _).mpr ne)
have ⟨s, hs⟩ := (IsLocalizedModule.eq_iff_exists P.primeCompl _).mp (h P)
exact s.2 (le hs)
theorem Module.eq_zero_of_localization_maximal (m : M)
(h : ∀ (P : Ideal R) [P.IsMaximal], f P m = 0) :
m = 0 :=
eq_of_localization_maximal _ f _ _ fun P _ ↦ by rw [h, map_zero]
theorem LinearMap.eq_of_localization_maximal (g g' : M →ₗ[R] M₁)
(h : ∀ (P : Ideal R) [P.IsMaximal],
IsLocalizedModule.map P.primeCompl (f P) (f₁ P) g =
IsLocalizedModule.map P.primeCompl (f P) (f₁ P) g') :
g = g' :=
ext fun x ↦ Module.eq_of_localization_maximal _ f₁ _ _ fun P _ ↦ by
simpa only [IsLocalizedModule.map_apply] using DFunLike.congr_fun (h P) (f P x)
include f in
theorem Module.subsingleton_of_localization_maximal
(h : ∀ (P : Ideal R) [P.IsMaximal], Subsingleton (Mₚ P)) :
Subsingleton M := by
rw [subsingleton_iff_forall_eq 0]
intro x
exact Module.eq_of_localization_maximal Mₚ f x 0 fun _ _ ↦ Subsingleton.elim _ _
theorem Submodule.eq_of_localization_maximal {N₁ N₂ : Submodule R M}
(h : ∀ (P : Ideal R) [P.IsMaximal],
N₁.localized' (Rₚ P) P.primeCompl (f P) = N₂.localized' (Rₚ P) P.primeCompl (f P)) :
N₁ = N₂ :=
eq_of_localization₀_maximal Mₚ f fun P _ ↦ congr(restrictScalars _ $(h P))
theorem Submodule.eq_bot_of_localization_maximal (N : Submodule R M)
(h : ∀ (P : Ideal R) [P.IsMaximal], N.localized' (Rₚ P) P.primeCompl (f P) = ⊥) :
N = ⊥ :=
Submodule.eq_of_localization_maximal Rₚ Mₚ f fun P hP ↦ by simpa using h P
theorem Submodule.eq_top_of_localization_maximal (N : Submodule R M)
(h : ∀ (P : Ideal R) [P.IsMaximal], N.localized' (Rₚ P) P.primeCompl (f P) = ⊤) :
N = ⊤ :=
Submodule.eq_of_localization_maximal Rₚ Mₚ f fun P hP ↦ by simpa using h P
end maximal
section span
open IsLocalizedModule LocalizedModule Ideal
variable (s : Set R) (span_eq : Ideal.span s = ⊤)
include span_eq
variable
(Rₚ : ∀ _ : s, Type*)
[∀ r : s, CommSemiring (Rₚ r)]
[∀ r : s, Algebra R (Rₚ r)]
[∀ r : s, IsLocalization.Away r.1 (Rₚ r)]
(Mₚ : ∀ _ : s, Type*)
[∀ r : s, AddCommMonoid (Mₚ r)]
[∀ r : s, Module R (Mₚ r)]
[∀ r : s, Module (Rₚ r) (Mₚ r)]
[∀ r : s, IsScalarTower R (Rₚ r) (Mₚ r)]
(f : ∀ r : s, M →ₗ[R] Mₚ r)
[∀ r : s, IsLocalizedModule (.powers r.1) (f r)]
theorem Module.eq_of_isLocalized_span (x y : M) (h : ∀ r : s, f r x = f r y) : x = y := by
suffices Module.eqIdeal R x y = ⊤ by simpa [Module.eqIdeal] using (eq_top_iff_one _).mp this
by_contra ne
have ⟨r, hrs, disj⟩ := exists_disjoint_powers_of_span_eq_top s span_eq _ ne
let r : s := ⟨r, hrs⟩
have ⟨⟨_, n, rfl⟩, eq⟩ := (IsLocalizedModule.eq_iff_exists (.powers r.1) _).mp (h r)
exact Set.disjoint_left.mp disj eq ⟨n, rfl⟩
theorem Module.eq_zero_of_isLocalized_span (x : M) (h : ∀ r : s, f r x = 0) : x = 0 :=
eq_of_isLocalized_span s span_eq _ f x 0 <| by simpa only [map_zero] using h
theorem Submodule.mem_of_isLocalized_span {m : M} {N : Submodule R M}
(h : ∀ r : s, f r m ∈ N.localized₀ (.powers r.1) (f r)) : m ∈ N := by
let I : Ideal R := N.comap (LinearMap.toSpanSingleton R M m)
suffices I = ⊤ by simpa [I] using I.eq_top_iff_one.mp this
by_contra! ne
have ⟨r, hrs, disj⟩ := exists_disjoint_powers_of_span_eq_top s span_eq _ ne
let r : s := ⟨r, hrs⟩
obtain ⟨a, ha, t, e⟩ := h r
rw [← IsLocalizedModule.mk'_one (.powers r.1), IsLocalizedModule.mk'_eq_mk'_iff] at e
have ⟨u, hu⟩ := e
simp_rw [smul_smul] at hu
exact Set.disjoint_right.mp disj (u * t).2 (by apply hu ▸ smul_mem _ _ ha)
theorem Submodule.le_of_isLocalized_span {N P : Submodule R M}
(h : ∀ r : s, N.localized₀ (.powers r.1) (f r) ≤ P.localized₀ (.powers r.1) (f r)) : N ≤ P :=
fun m hm ↦ mem_of_isLocalized_span s span_eq _ f fun r ↦ h r ⟨m, hm, 1, by simp⟩
theorem Submodule.eq_of_isLocalized₀_span {N P : Submodule R M}
(h : ∀ r : s, N.localized₀ (.powers r.1) (f r) = P.localized₀ (.powers r.1) (f r)) : N = P :=
le_antisymm (le_of_isLocalized_span s span_eq _ _ fun r ↦ (h r).le)
(le_of_isLocalized_span s span_eq _ _ fun r ↦ (h r).ge)
theorem Submodule.eq_bot_of_isLocalized₀_span {N : Submodule R M}
(h : ∀ r : s, N.localized₀ (.powers r.1) (f r) = ⊥) : N = ⊥ :=
eq_of_isLocalized₀_span s span_eq Mₚ f fun _ ↦ by simp only [h, Submodule.localized₀_bot]
theorem Submodule.eq_top_of_isLocalized₀_span {N : Submodule R M}
(h : ∀ r : s, N.localized₀ (.powers r.1) (f r) = ⊤) : N = ⊤ :=
eq_of_isLocalized₀_span s span_eq Mₚ f fun _ ↦ by simp only [h, Submodule.localized₀_top]
theorem Submodule.eq_of_isLocalized'_span {N P : Submodule R M}
(h : ∀ r, N.localized' (Rₚ r) (.powers r.1) (f r) = P.localized' (Rₚ r) (.powers r.1) (f r)) :
N = P :=
eq_of_isLocalized₀_span s span_eq _ f fun r ↦ congr(restrictScalars _ $(h r))
theorem Submodule.eq_bot_of_isLocalized'_span {N : Submodule R M}
(h : ∀ r : s, N.localized' (Rₚ r) (.powers r.1) (f r) = ⊥) : N = ⊥ :=
eq_of_isLocalized'_span s span_eq Rₚ Mₚ f fun _ ↦ by simp only [h, Submodule.localized'_bot]
theorem Submodule.eq_top_of_isLocalized'_span {N : Submodule R M}
(h : ∀ r : s, N.localized' (Rₚ r) (.powers r.1) (f r) = ⊤) : N = ⊤ :=
eq_of_isLocalized'_span s span_eq Rₚ Mₚ f fun _ ↦ by simp only [h, Submodule.localized'_top]
end span |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Semilocal.lean | import Mathlib.RingTheory.DedekindDomain.PID
import Mathlib.RingTheory.KrullDimension.PID
/-!
# Local properties for semilocal rings
This file proves some local properties for a semilocal ring `R` (a ring with
finitely many maximal ideals).
## Main results
* `Module.Finite.of_isLocalized_maximal`: A module `M` over a semilocal ring `R` is finite if its
localization at every maximal ideal is finite.
* `IsNoetherianRing.of_isLocalization_maximal`: A semilocal ring `R` is Noetherian if its
localization at every maximal ideal is a Noetherian ring.
* `isPrincipalIdealRing_of_isPrincipalIdealRing_isLocalization_maximal`: A semilocal
integral domain `A` is a PID if its localization at every maximal ideal is a PID.
-/
section CommSemiring
variable {R : Type*} [CommSemiring R] [Finite (MaximalSpectrum R)]
variable (M : Type*) [AddCommMonoid M] [Module R M]
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommSemiring (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
(Mₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], AddCommMonoid (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module R (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Module (Rₚ P) (Mₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsScalarTower R (Rₚ P) (Mₚ P)]
(f : ∀ (P : Ideal R) [P.IsMaximal], M →ₗ[R] Mₚ P)
[∀ (P : Ideal R) [P.IsMaximal], IsLocalizedModule P.primeCompl (f P)]
section IsLocalized
include f in
/-- A module `M` over a semilocal ring `R` is finite if
its localization at every maximal ideal is finite. -/
theorem Module.Finite.of_isLocalized_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal], Module.Finite (Rₚ P) (Mₚ P)) :
Module.Finite R M := by
classical
have : Fintype (MaximalSpectrum R) := Fintype.ofFinite _
choose s hs using fun P : MaximalSpectrum R ↦ (H P.1).fg_top
choose frac hfrac using fun P : MaximalSpectrum R ↦ IsLocalizedModule.surj P.1.primeCompl (f P.1)
use Finset.biUnion Finset.univ fun P ↦ Finset.image (frac P · |>.1) (s P)
refine Submodule.eq_top_of_localization_maximal Rₚ Mₚ f _ fun P hP ↦ ?_
rw [eq_top_iff, ← hs ⟨P, hP⟩, Submodule.localized'_span, Submodule.span_le]
intro x hx
lift x to s ⟨P, hP⟩ using hx
rw [SetLike.mem_coe, ← IsLocalization.smul_mem_iff (s := (frac ⟨P, hP⟩ x).2), hfrac]
exact Submodule.subset_span ⟨_, by simpa using ⟨_, _, x.2, rfl⟩, rfl⟩
variable {M} in
/-- A submodule `N` of a module `M` over a semilocal ring `R` is finitely generated if
its localization at every maximal ideal is finitely generated. -/
theorem Submodule.fg_of_isLocalized_maximal (N : Submodule R M)
(H : ∀ (P : Ideal R) [P.IsMaximal], (Submodule.localized' (Rₚ P) P.primeCompl (f P) N).FG) :
N.FG := by
simp_rw [← Module.Finite.iff_fg] at ⊢ H
exact .of_isLocalized_maximal _ _ _ (fun P ↦ N.toLocalized' (Rₚ P) P.primeCompl (f P)) H
end IsLocalized
section Localized
theorem Module.Finite.of_localized_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal],
Module.Finite (Localization P.primeCompl) (LocalizedModule P.primeCompl M)) :
Module.Finite R M :=
.of_isLocalized_maximal M _ _ (fun _ _ ↦ LocalizedModule.mkLinearMap _ _) H
variable {M} in
theorem Submodule.fg_of_localized_maximal (N : Submodule R M)
(H : ∀ (P : Ideal R) [P.IsMaximal], (N.localized P.primeCompl).FG) :
N.FG := N.fg_of_isLocalized_maximal _ _ _ H
end Localized
section IsLocalization
/-- A semilocal ring `R` is Noetherian if
its localization at every maximal ideal is a Noetherian ring. -/
theorem IsNoetherianRing.of_isLocalization_maximal
(H : ∀ (P : Ideal R) [P.IsMaximal], IsNoetherianRing (Rₚ P)) :
IsNoetherianRing R where
noetherian N := Submodule.fg_of_isLocalized_maximal
Rₚ Rₚ (fun P _ => Algebra.linearMap R (Rₚ P)) N fun _ _ ↦ IsNoetherian.noetherian _
end IsLocalization
end CommSemiring
section CommRing
section IsLocalization
variable {R : Type*} [CommRing R] [Finite (MaximalSpectrum R)]
variable
(Rₚ : ∀ (P : Ideal R) [P.IsMaximal], Type*)
[∀ (P : Ideal R) [P.IsMaximal], CommRing (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], Algebra R (Rₚ P)]
[∀ (P : Ideal R) [P.IsMaximal], IsLocalization.AtPrime (Rₚ P) P]
/-- A semilocal integral domain `A` is a PID if its localization at every maximal ideal is a PID. -/
theorem isPrincipalIdealRing_of_isPrincipalIdealRing_isLocalization_maximal [IsDomain R]
(hpid : ∀ (P : Ideal R) [P.IsMaximal], IsPrincipalIdealRing (Rₚ P)) :
IsPrincipalIdealRing R := by
have : IsNoetherianRing R :=
IsNoetherianRing.of_isLocalization_maximal Rₚ fun P _ => inferInstance
have : IsIntegrallyClosed R := by
refine IsIntegrallyClosed.of_isLocalization_maximal Rₚ fun P hP => ?_
have : IsDomain (Rₚ P) := IsLocalization.isDomain_of_atPrime (Rₚ P) P
infer_instance
have : Ring.KrullDimLE 1 R :=
Ring.krullDimLE_of_isLocalization_maximal Rₚ fun P _ => inferInstance
rw [Ring.krullDimLE_one_iff_of_noZeroDivisors] at this
have dedekind : IsDedekindDomain R := { maximalOfPrime := this _ }
have hp_finite : {P : Ideal R | P.IsMaximal}.Finite := by
rw [← MaximalSpectrum.range_asIdeal]
exact Set.finite_range MaximalSpectrum.asIdeal
exact IsPrincipalIdealRing.of_finite_maximals hp_finite
end IsLocalization
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/LocalProperties/Reduced.lean | import Mathlib.RingTheory.LocalProperties.Basic
import Mathlib.RingTheory.Nilpotent.Defs
/-!
# `IsReduced` is a local property
In this file, we prove that `IsReduced` is a local property.
## Main results
Let `R` be a commutative ring, `M` be a submonoid of `R`.
* `isReduced_localizationPreserves` : `M⁻¹R` is reduced if `R` is reduced.
* `isReduced_ofLocalizationMaximal` : `R` is reduced if `Rₘ` is reduced for all maximal ideal `m`.
-/
/-- `M⁻¹R` is reduced if `R` is reduced. -/
theorem isReduced_localizationPreserves : LocalizationPreserves fun R _ => IsReduced R := by
introv R _ _
constructor
rintro x ⟨_ | n, e⟩
· simpa using congr_arg (· * x) e
obtain ⟨⟨y, m⟩, hx⟩ := IsLocalization.surj M x
dsimp only at hx
let hx' := congr_arg (· ^ n.succ) hx
simp only [mul_pow, e, zero_mul, ← RingHom.map_pow] at hx'
rw [← (algebraMap R S).map_zero] at hx'
obtain ⟨m', hm'⟩ := (IsLocalization.eq_iff_exists M S).mp hx'
apply_fun (· * (m' : R) ^ n) at hm'
simp only [mul_assoc, zero_mul, mul_zero] at hm'
rw [← mul_left_comm, ← pow_succ', ← mul_pow] at hm'
replace hm' := IsNilpotent.eq_zero ⟨_, hm'.symm⟩
rw [← (IsLocalization.map_units S m).mul_left_inj, hx, zero_mul,
IsLocalization.map_eq_zero_iff M]
exact ⟨m', by rw [← hm', mul_comm]⟩
instance {R : Type*} [CommRing R] (M : Submonoid R) [IsReduced R] : IsReduced (Localization M) :=
isReduced_localizationPreserves M _ inferInstance
/-- `R` is reduced if `Rₘ` is reduced for all maximal ideal `m`. -/
theorem isReduced_ofLocalizationMaximal : OfLocalizationMaximal fun R _ => IsReduced R := by
introv R h
constructor
intro x hx
apply eq_zero_of_localization
intro J hJ
specialize h J hJ
exact (hx.map <| algebraMap R <| Localization.AtPrime J).eq_zero |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/NumDen.lean | import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
import Mathlib.RingTheory.UniqueFactorizationDomain.GCDMonoid
/-!
# Numerator and denominator in a localization
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
namespace IsFractionRing
open IsLocalization
section NumDen
variable (A : Type*) [CommRing A] [IsDomain A] [UniqueFactorizationMonoid A]
variable {K : Type*} [Field K] [Algebra A K] [IsFractionRing A K]
theorem exists_reduced_fraction (x : K) :
∃ (a : A) (b : nonZeroDivisors A), IsRelPrime a b ∧ mk' K a b = x := by
obtain ⟨⟨b, b_nonzero⟩, a, hab⟩ := exists_integer_multiple (nonZeroDivisors A) x
obtain ⟨a', b', c', no_factor, rfl, rfl⟩ :=
UniqueFactorizationMonoid.exists_reduced_factors' a b
(mem_nonZeroDivisors_iff_ne_zero.mp b_nonzero)
obtain ⟨_, b'_nonzero⟩ := mul_mem_nonZeroDivisors.mp b_nonzero
refine ⟨a', ⟨b', b'_nonzero⟩, no_factor, ?_⟩
refine mul_left_cancel₀ (IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors b_nonzero) ?_
simp only [RingHom.map_mul, Algebra.smul_def] at *
rw [← hab, mul_assoc, mk'_spec' _ a' ⟨b', b'_nonzero⟩]
/-- `f.num x` is the numerator of `x : f.codomain` as a reduced fraction. -/
noncomputable def num (x : K) : A :=
Classical.choose (exists_reduced_fraction A x)
/-- `f.den x` is the denominator of `x : f.codomain` as a reduced fraction. -/
noncomputable def den (x : K) : nonZeroDivisors A :=
Classical.choose (Classical.choose_spec (exists_reduced_fraction A x))
theorem num_den_reduced (x : K) : IsRelPrime (num A x) (den A x) :=
(Classical.choose_spec (Classical.choose_spec (exists_reduced_fraction A x))).1
-- `@[simp]` normal form is called `mk'_num_den'`.
theorem mk'_num_den (x : K) : mk' K (num A x) (den A x) = x :=
(Classical.choose_spec (Classical.choose_spec (exists_reduced_fraction A x))).2
@[simp]
theorem mk'_num_den' (x : K) : algebraMap A K (num A x) / algebraMap A K (den A x) = x := by
rw [← mk'_eq_div]
apply mk'_num_den
variable {A}
theorem num_mul_den_eq_num_iff_eq {x y : K} :
x * algebraMap A K (den A y) = algebraMap A K (num A y) ↔ x = y :=
⟨fun h => by simpa only [mk'_num_den] using eq_mk'_iff_mul_eq.mpr h, fun h ↦
eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_den])⟩
theorem num_mul_den_eq_num_iff_eq' {x y : K} :
y * algebraMap A K (den A x) = algebraMap A K (num A x) ↔ x = y :=
⟨fun h ↦ by simpa only [eq_comm, mk'_num_den] using eq_mk'_iff_mul_eq.mpr h, fun h ↦
eq_mk'_iff_mul_eq.mp (by rw [h, mk'_num_den])⟩
theorem num_mul_den_eq_num_mul_den_iff_eq {x y : K} :
num A y * den A x = num A x * den A y ↔ x = y :=
⟨fun h ↦ by simpa only [mk'_num_den] using mk'_eq_of_eq' (S := K) h, fun h ↦ by rw [h]⟩
theorem eq_zero_of_num_eq_zero {x : K} (h : num A x = 0) : x = 0 :=
(num_mul_den_eq_num_iff_eq' (A := A)).mp (by rw [zero_mul, h, RingHom.map_zero])
@[simp]
lemma num_zero : IsFractionRing.num A (0 : K) = 0 := by
have := mk'_num_den' A (0 : K)
simp only [div_eq_zero_iff] at this
simp_all
@[simp]
lemma num_eq_zero (x : K) : IsFractionRing.num A x = 0 ↔ x = 0 :=
⟨eq_zero_of_num_eq_zero, fun h ↦ h ▸ num_zero⟩
theorem isInteger_of_isUnit_den {x : K} (h : IsUnit (den A x : A)) : IsInteger A x := by
obtain ⟨d, hd⟩ := h
have d_ne_zero : algebraMap A K (den A x) ≠ 0 :=
IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors (den A x).2
use ↑d⁻¹ * num A x
refine _root_.trans ?_ (mk'_num_den A x)
rw [map_mul, map_units_inv, hd]
apply mul_left_cancel₀ d_ne_zero
rw [← mul_assoc, mul_inv_cancel₀ d_ne_zero, one_mul, mk'_spec']
theorem isUnit_den_iff (x : K) : IsUnit (den A x : A) ↔ IsLocalization.IsInteger A x where
mp := isInteger_of_isUnit_den
mpr h := by
have ⟨v, h⟩ := h
apply IsRelPrime.isUnit_of_dvd (num_den_reduced A x).symm
use v
apply_fun algebraMap A K
· simp only [map_mul, h]
rw [mul_comm, ← div_eq_iff]
· simp only [mk'_num_den']
intro h
replace h : algebraMap A K (den A x : A) = algebraMap A K 0 := by convert h; simp
exact nonZeroDivisors.coe_ne_zero _ <| FaithfulSMul.algebraMap_injective A K h
exact FaithfulSMul.algebraMap_injective A K
theorem isUnit_den_zero : IsUnit (den A (0 : K) : A) := by
simp [isUnit_den_iff, IsLocalization.isInteger_zero]
lemma associated_den_num_inv (x : K) (hx : x ≠ 0) : Associated (den A x : A) (num A x⁻¹) :=
associated_of_dvd_dvd
(IsRelPrime.dvd_of_dvd_mul_right (IsFractionRing.num_den_reduced A x).symm <|
dvd_of_mul_left_dvd (a := (den A x⁻¹ : A)) <| dvd_of_eq <|
FaithfulSMul.algebraMap_injective A K <| Eq.symm <| eq_of_div_eq_one
(by simp [mul_div_mul_comm, hx]))
(IsRelPrime.dvd_of_dvd_mul_right (IsFractionRing.num_den_reduced A x⁻¹) <|
dvd_of_mul_left_dvd (a := (num A x : A)) <| dvd_of_eq <|
FaithfulSMul.algebraMap_injective A K <| eq_of_div_eq_one
(by simp [mul_div_mul_comm, hx]))
lemma associated_num_den_inv (x : K) (hx : x ≠ 0) : Associated (num A x : A) (den A x⁻¹) := by
have : Associated (num A x⁻¹⁻¹ : A) (den A x⁻¹) :=
(associated_den_num_inv x⁻¹ (inv_ne_zero hx)).symm
rw [inv_inv] at this
exact this
end NumDen
end IsFractionRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Integral.lean | import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Algebra.Polynomial.Lifts
import Mathlib.RingTheory.Algebraic.Integral
import Mathlib.RingTheory.IntegralClosure.Algebra.Basic
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
/-!
# Integral and algebraic elements of a fraction field
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommRing R] (M : Submonoid R) {S : Type*} [CommRing S]
variable [Algebra R S]
open Polynomial
namespace IsLocalization
section IntegerNormalization
open Polynomial
variable [IsLocalization M S]
open scoped Classical in
/-- `coeffIntegerNormalization p` gives the coefficients of the polynomial
`integerNormalization p` -/
noncomputable def coeffIntegerNormalization (p : S[X]) (i : ℕ) : R :=
if hi : i ∈ p.support then
Classical.choose
(Classical.choose_spec (exist_integer_multiples_of_finset M (p.support.image p.coeff))
(p.coeff i) (Finset.mem_image.mpr ⟨i, hi, rfl⟩))
else 0
theorem coeffIntegerNormalization_of_coeff_zero (p : S[X]) (i : ℕ) (h : coeff p i = 0) :
coeffIntegerNormalization M p i = 0 := by
simp only [coeffIntegerNormalization, h, mem_support_iff, not_true, Ne,
dif_neg, not_false_iff]
@[deprecated (since := "2025-05-23")]
alias coeffIntegerNormalization_of_not_mem_support := coeffIntegerNormalization_of_coeff_zero
theorem coeffIntegerNormalization_mem_support (p : S[X]) (i : ℕ)
(h : coeffIntegerNormalization M p i ≠ 0) : i ∈ p.support := by
contrapose h
rw [Ne, Classical.not_not, coeffIntegerNormalization, dif_neg h]
/-- `integerNormalization g` normalizes `g` to have integer coefficients
by clearing the denominators -/
noncomputable def integerNormalization (p : S[X]) : R[X] :=
∑ i ∈ p.support, monomial i (coeffIntegerNormalization M p i)
@[simp]
theorem integerNormalization_coeff (p : S[X]) (i : ℕ) :
(integerNormalization M p).coeff i = coeffIntegerNormalization M p i := by
simp +contextual [integerNormalization, coeff_monomial,
coeffIntegerNormalization_of_coeff_zero]
theorem integerNormalization_spec (p : S[X]) :
∃ b : M, ∀ i, algebraMap R S ((integerNormalization M p).coeff i) = (b : R) • p.coeff i := by
classical
use Classical.choose (exist_integer_multiples_of_finset M (p.support.image p.coeff))
intro i
rw [integerNormalization_coeff, coeffIntegerNormalization]
split_ifs with hi
· exact
Classical.choose_spec
(Classical.choose_spec (exist_integer_multiples_of_finset M (p.support.image p.coeff))
(p.coeff i) (Finset.mem_image.mpr ⟨i, hi, rfl⟩))
· rw [RingHom.map_zero, notMem_support_iff.mp hi, smul_zero]
theorem integerNormalization_map_to_map (p : S[X]) :
∃ b : M, (integerNormalization M p).map (algebraMap R S) = (b : R) • p :=
let ⟨b, hb⟩ := integerNormalization_spec M p
⟨b,
Polynomial.ext fun i => by
rw [coeff_map, coeff_smul]
exact hb i⟩
variable {R' : Type*} [CommRing R']
theorem integerNormalization_eval₂_eq_zero (g : S →+* R') (p : S[X]) {x : R'}
(hx : eval₂ g x p = 0) : eval₂ (g.comp (algebraMap R S)) x (integerNormalization M p) = 0 :=
let ⟨b, hb⟩ := integerNormalization_map_to_map M p
_root_.trans (eval₂_map (algebraMap R S) g x).symm
(by rw [hb, ← IsScalarTower.algebraMap_smul S (b : R) p, eval₂_smul, hx, mul_zero])
theorem integerNormalization_aeval_eq_zero [Algebra R R'] [Algebra S R'] [IsScalarTower R S R']
(p : S[X]) {x : R'} (hx : aeval x p = 0) : aeval x (integerNormalization M p) = 0 := by
rwa [aeval_def, IsScalarTower.algebraMap_eq R S R', integerNormalization_eval₂_eq_zero]
end IntegerNormalization
end IsLocalization
namespace IsFractionRing
open IsLocalization
variable {A K C : Type*} [CommRing A] [IsDomain A] [Field K] [Algebra A K] [IsFractionRing A K]
variable [CommRing C]
theorem integerNormalization_eq_zero_iff {p : K[X]} :
integerNormalization (nonZeroDivisors A) p = 0 ↔ p = 0 := by
refine Polynomial.ext_iff.trans (Polynomial.ext_iff.trans ?_).symm
obtain ⟨⟨b, nonzero⟩, hb⟩ := integerNormalization_spec (nonZeroDivisors A) p
constructor <;> intro h i
· rw [coeff_zero, ← to_map_eq_zero_iff (K := K), hb i, h i, coeff_zero, smul_zero]
· have hi := h i
rw [Polynomial.coeff_zero, ← @to_map_eq_zero_iff A _ K, hb i, Algebra.smul_def] at hi
apply Or.resolve_left (eq_zero_or_eq_zero_of_mul_eq_zero hi)
intro h
apply mem_nonZeroDivisors_iff_ne_zero.mp nonzero
exact to_map_eq_zero_iff.mp h
variable (A K C)
/-- An element of a ring is algebraic over the ring `A` iff it is algebraic
over the field of fractions of `A`.
-/
theorem isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] {x : C} :
IsAlgebraic A x ↔ IsAlgebraic K x := by
constructor <;> rintro ⟨p, hp, px⟩
· refine ⟨p.map (algebraMap A K), fun h => hp (Polynomial.ext fun i => ?_), ?_⟩
· have : algebraMap A K (p.coeff i) = 0 :=
_root_.trans (Polynomial.coeff_map _ _).symm (by simp [h])
exact to_map_eq_zero_iff.mp this
· exact (Polynomial.aeval_map_algebraMap K _ _).trans px
· exact
⟨integerNormalization _ p, mt integerNormalization_eq_zero_iff.mp hp,
integerNormalization_aeval_eq_zero _ p px⟩
variable {A K C}
/-- A ring is algebraic over the ring `A` iff it is algebraic over the field of fractions of `A`.
-/
theorem comap_isAlgebraic_iff [Algebra A C] [Algebra K C] [IsScalarTower A K C] :
Algebra.IsAlgebraic A C ↔ Algebra.IsAlgebraic K C :=
⟨fun h => ⟨fun x => (isAlgebraic_iff A K C).mp (h.isAlgebraic x)⟩,
fun h => ⟨fun x => (isAlgebraic_iff A K C).mpr (h.isAlgebraic x)⟩⟩
end IsFractionRing
open IsLocalization
section IsIntegral
variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ]
variable [Algebra R Rₘ] [IsLocalization M Rₘ]
variable [Algebra S Sₘ] [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ]
variable {M}
open Polynomial
theorem RingHom.isIntegralElem_localization_at_leadingCoeff {R S : Type*} [CommSemiring R]
[CommSemiring S] (f : R →+* S) (x : S) (p : R[X]) (hf : p.eval₂ f x = 0) (M : Submonoid R)
(hM : p.leadingCoeff ∈ M) {Rₘ Sₘ : Type*} [CommRing Rₘ] [CommRing Sₘ] [Algebra R Rₘ]
[IsLocalization M Rₘ] [Algebra S Sₘ] [IsLocalization (M.map f : Submonoid S) Sₘ] :
(map Sₘ f M.le_comap_map : Rₘ →+* _).IsIntegralElem (algebraMap S Sₘ x) := by
by_cases triv : (1 : Rₘ) = 0
· exact ⟨0, ⟨_root_.trans leadingCoeff_zero triv.symm, eval₂_zero _ _⟩⟩
haveI : Nontrivial Rₘ := nontrivial_of_ne 1 0 triv
obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.mp (map_units Rₘ ⟨p.leadingCoeff, hM⟩)
refine ⟨p.map (algebraMap R Rₘ) * C b, ⟨?_, ?_⟩⟩
· refine monic_mul_C_of_leadingCoeff_mul_eq_one ?_
rwa [leadingCoeff_map_of_leadingCoeff_ne_zero (algebraMap R Rₘ)]
refine fun hfp => zero_ne_one
(_root_.trans (zero_mul b).symm (hfp ▸ hb) : (0 : Rₘ) = 1)
· refine eval₂_mul_eq_zero_of_left _ _ _ ?_
rw [eval₂_map, IsLocalization.map_comp, ← hom_eval₂ _ f (algebraMap S Sₘ) x]
exact _root_.trans (congr_arg (algebraMap S Sₘ) hf) (RingHom.map_zero _)
/-- Given a particular witness to an element being algebraic over an algebra `R → S`,
We can localize to a submonoid containing the leading coefficient to make it integral.
Explicitly, the map between the localizations will be an integral ring morphism -/
theorem is_integral_localization_at_leadingCoeff {x : S} (p : R[X]) (hp : aeval x p = 0)
(hM : p.leadingCoeff ∈ M) :
(map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
Rₘ →+* _).IsIntegralElem
(algebraMap S Sₘ x) :=
haveI : IsLocalization (Submonoid.map (algebraMap R S) M) Sₘ :=
inferInstanceAs (IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ)
(algebraMap R S).isIntegralElem_localization_at_leadingCoeff x p hp M hM
/-- If `R → S` is an integral extension, `M` is a submonoid of `R`,
`Rₘ` is the localization of `R` at `M`,
and `Sₘ` is the localization of `S` at the image of `M` under the extension map,
then the induced map `Rₘ → Sₘ` is also an integral extension -/
theorem isIntegral_localization [Algebra.IsIntegral R S] :
(map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
Rₘ →+* _).IsIntegral := by
intro x
obtain ⟨⟨s, ⟨u, hu⟩⟩, hx⟩ := surj (Algebra.algebraMapSubmonoid S M) x
obtain ⟨v, hv⟩ := hu
obtain ⟨v', hv'⟩ := isUnit_iff_exists_inv'.1 (map_units Rₘ ⟨v, hv.1⟩)
refine @IsIntegral.of_mul_unit Rₘ _ _ _ (localizationAlgebra M S) x (algebraMap S Sₘ u) v' ?_ ?_
· replace hv' := congr_arg (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) hv'
rw [RingHom.map_mul, RingHom.map_one, localizationAlgebraMap_def, IsLocalization.map_eq]
at hv'
exact hv.2 ▸ hv'
· obtain ⟨p, hp⟩ := Algebra.IsIntegral.isIntegral (R := R) s
exact hx.symm ▸ is_integral_localization_at_leadingCoeff p hp.2 (hp.1.symm ▸ M.one_mem)
theorem isIntegral_localization' {R S : Type*} [CommRing R] [CommRing S] {f : R →+* S}
(hf : f.IsIntegral) (M : Submonoid R) :
(map (Localization (M.map (f : R →* S))) f
(M.le_comap_map : _ ≤ Submonoid.comap (f : R →* S) _) :
Localization M →+* _).IsIntegral :=
let _ := f.toAlgebra
have : Algebra.IsIntegral R S := ⟨hf⟩
have : IsLocalization (Algebra.algebraMapSubmonoid S M)
(Localization (Submonoid.map (f : R →* S) M)) := Localization.isLocalization
isIntegral_localization
variable (M)
theorem IsLocalization.scaleRoots_commonDenom_mem_lifts (p : Rₘ[X])
(hp : p.leadingCoeff ∈ (algebraMap R Rₘ).range) :
p.scaleRoots (algebraMap R Rₘ <| IsLocalization.commonDenom M p.support p.coeff) ∈
Polynomial.lifts (algebraMap R Rₘ) := by
rw [Polynomial.lifts_iff_coeff_lifts]
intro n
rw [Polynomial.coeff_scaleRoots]
by_cases h₁ : n ∈ p.support
on_goal 1 => by_cases h₂ : n = p.natDegree
· rwa [h₂, Polynomial.coeff_natDegree, tsub_self, pow_zero, _root_.mul_one]
· have : n + 1 ≤ p.natDegree := lt_of_le_of_ne (Polynomial.le_natDegree_of_mem_supp _ h₁) h₂
rw [← tsub_add_cancel_of_le (le_tsub_of_add_le_left this), pow_add, pow_one, mul_comm,
_root_.mul_assoc, ← map_pow]
change _ ∈ (algebraMap R Rₘ).range
apply mul_mem
· exact RingHom.mem_range_self _ _
· rw [← Algebra.smul_def]
exact ⟨_, IsLocalization.map_integerMultiple M p.support p.coeff ⟨n, h₁⟩⟩
· rw [Polynomial.notMem_support_iff] at h₁
rw [h₁, zero_mul]
exact zero_mem (algebraMap R Rₘ).range
theorem IsIntegral.exists_multiple_integral_of_isLocalization [Algebra Rₘ S] [IsScalarTower R Rₘ S]
(x : S) (hx : IsIntegral Rₘ x) : ∃ m : M, IsIntegral R (m • x) := by
rcases subsingleton_or_nontrivial Rₘ with _ | nontriv
· haveI := (_root_.algebraMap Rₘ S).codomain_trivial
exact ⟨1, Polynomial.X, Polynomial.monic_X, Subsingleton.elim _ _⟩
obtain ⟨p, hp₁, hp₂⟩ := hx
-- Porting note: obtain doesn't support side goals
have :=
lifts_and_natDegree_eq_and_monic (IsLocalization.scaleRoots_commonDenom_mem_lifts M p ?_) ?_
· obtain ⟨p', hp'₁, -, hp'₂⟩ := this
refine ⟨IsLocalization.commonDenom M p.support p.coeff, p', hp'₂, ?_⟩
rw [IsScalarTower.algebraMap_eq R Rₘ S, ← Polynomial.eval₂_map, hp'₁, Submonoid.smul_def,
Algebra.smul_def, IsScalarTower.algebraMap_apply R Rₘ S]
exact Polynomial.scaleRoots_eval₂_eq_zero _ hp₂
· rw [hp₁.leadingCoeff]
exact one_mem _
· rwa [Polynomial.monic_scaleRoots_iff]
end IsIntegral
variable {A K : Type*} [CommRing A]
namespace IsIntegralClosure
variable (A)
variable {L : Type*} [Field K] [Field L] [Algebra A K] [Algebra A L] [IsFractionRing A K]
variable (C : Type*) [CommRing C] [IsDomain C] [Algebra C L] [IsIntegralClosure C A L]
variable [Algebra A C] [IsScalarTower A C L]
open Algebra
/-- If the field `L` is an algebraic extension of the integral domain `A`,
the integral closure `C` of `A` in `L` has fraction field `L`. -/
theorem isFractionRing_of_algebraic [Algebra.IsAlgebraic A L]
(inj : ∀ x, algebraMap A L x = 0 → x = 0) : IsFractionRing C L :=
{ map_units := fun ⟨y, hy⟩ =>
IsUnit.mk0 _
(show algebraMap C L y ≠ 0 from fun h =>
mem_nonZeroDivisors_iff_ne_zero.mp hy
((injective_iff_map_eq_zero (algebraMap C L)).mp (algebraMap_injective C A L) _ h))
surj := fun z =>
let ⟨x, hx, int⟩ := (Algebra.IsAlgebraic.isAlgebraic z).exists_integral_multiple
⟨⟨mk' C _ int, algebraMap _ _ x, mem_nonZeroDivisors_of_ne_zero fun h ↦
hx (inj _ <| by rw [IsScalarTower.algebraMap_apply A C L, h, RingHom.map_zero])⟩, by
rw [algebraMap_mk', ← IsScalarTower.algebraMap_apply A C L, Algebra.smul_def, mul_comm]⟩
exists_of_eq := fun {x y} h => ⟨1, by simpa using algebraMap_injective C A L h⟩ }
variable (K L)
/-- If the field `L` is a finite extension of the fraction field of the integral domain `A`,
the integral closure `C` of `A` in `L` has fraction field `L`. -/
theorem isFractionRing_of_finite_extension [IsDomain A] [Algebra K L] [IsScalarTower A K L]
[FiniteDimensional K L] : IsFractionRing C L :=
have : Algebra.IsAlgebraic A L := IsFractionRing.comap_isAlgebraic_iff.mpr
(inferInstanceAs (Algebra.IsAlgebraic K L))
isFractionRing_of_algebraic A C
fun _ hx =>
IsFractionRing.to_map_eq_zero_iff.mp
((map_eq_zero <| algebraMap K L).mp <| (IsScalarTower.algebraMap_apply _ _ _ _).symm.trans hx)
end IsIntegralClosure
namespace integralClosure
variable {L : Type*} [Field K] [Field L] [Algebra A K] [IsFractionRing A K]
open Algebra
/-- If the field `L` is an algebraic extension of the integral domain `A`,
the integral closure of `A` in `L` has fraction field `L`. -/
theorem isFractionRing_of_algebraic [Algebra A L] [Algebra.IsAlgebraic A L]
(inj : ∀ x, algebraMap A L x = 0 → x = 0) : IsFractionRing (integralClosure A L) L :=
IsIntegralClosure.isFractionRing_of_algebraic A (integralClosure A L) inj
variable (K L)
/-- If the field `L` is a finite extension of the fraction field of the integral domain `A`,
the integral closure of `A` in `L` has fraction field `L`. -/
theorem isFractionRing_of_finite_extension [IsDomain A] [Algebra A L] [Algebra K L]
[IsScalarTower A K L] [FiniteDimensional K L] : IsFractionRing (integralClosure A L) L :=
IsIntegralClosure.isFractionRing_of_finite_extension A K L (integralClosure A L)
end integralClosure
namespace IsFractionRing
variable (R S K)
/-- `S` is algebraic over `R` iff a fraction ring of `S` is algebraic over `R` -/
theorem isAlgebraic_iff' [Field K] [IsDomain R] [Algebra R K] [Algebra S K]
[NoZeroSMulDivisors R K] [IsFractionRing S K] [IsScalarTower R S K] :
Algebra.IsAlgebraic R S ↔ Algebra.IsAlgebraic R K := by
simp only [Algebra.isAlgebraic_def]
constructor
· intro h x
letI := MulActionWithZero.nontrivial S K
letI := FractionRing.liftAlgebra R K
have := FractionRing.isScalarTower_liftAlgebra R K
rw [IsFractionRing.isAlgebraic_iff R (FractionRing R) K, isAlgebraic_iff_isIntegral]
obtain ⟨a : S, b, ha, rfl⟩ := div_surjective (A := S) x
obtain ⟨f, hf₁, hf₂⟩ := h b
rw [div_eq_mul_inv]
refine .mul ?_ (.inv ?_) <;> exact isAlgebraic_iff_isIntegral.mp <|
(h _).algebraMap.extendScalars (FaithfulSMul.algebraMap_injective R _)
· intro h x
obtain ⟨f, hf₁, hf₂⟩ := h (algebraMap S K x)
use f, hf₁
rw [Polynomial.aeval_algebraMap_apply] at hf₂
exact
(injective_iff_map_eq_zero (algebraMap S K)).1 (FaithfulSMul.algebraMap_injective _ _) _
hf₂
open nonZeroDivisors
variable {S K}
/-- If the `S`-multiples of `a` are contained in some `R`-span, then `Frac(S)`-multiples of `a`
are contained in the equivalent `Frac(R)`-span. -/
theorem ideal_span_singleton_map_subset {L : Type*} [IsDomain R] [IsDomain S] [Field K] [Field L]
[Algebra R K] [Algebra R L] [Algebra S L] [Algebra.IsAlgebraic R S] [IsFractionRing S L]
[Algebra K L] [IsScalarTower R S L] [IsScalarTower R K L] {a : S} {b : Set S}
(inj : Function.Injective (algebraMap R L))
(h : (Ideal.span ({a} : Set S) : Set S) ⊆ Submodule.span R b) :
(Ideal.span ({algebraMap S L a} : Set L) : Set L) ⊆ Submodule.span K (algebraMap S L '' b) := by
intro x hx
obtain ⟨x', rfl⟩ := Ideal.mem_span_singleton.mp hx
obtain ⟨y', z', rfl⟩ := IsLocalization.exists_mk'_eq S⁰ x'
obtain ⟨y, z, hz0, yz_eq⟩ :=
Algebra.IsAlgebraic.exists_smul_eq_mul R y' (nonZeroDivisors.coe_ne_zero z')
have injRS : Function.Injective (algebraMap R S) := by
refine
Function.Injective.of_comp (show Function.Injective (algebraMap S L ∘ algebraMap R S) from ?_)
rwa [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq]
have hz0' : algebraMap R S z ∈ S⁰ :=
map_mem_nonZeroDivisors (algebraMap R S) injRS (mem_nonZeroDivisors_of_ne_zero hz0)
have mk_yz_eq : IsLocalization.mk' L y' z' = IsLocalization.mk' L y ⟨_, hz0'⟩ := by
rw [Algebra.smul_def, mul_comm _ y, mul_comm _ y'] at yz_eq
exact IsLocalization.mk'_eq_of_eq (by rw [mul_comm _ y, mul_comm _ y', yz_eq])
suffices hy : algebraMap S L (a * y) ∈ Submodule.span K ((algebraMap S L) '' b) by
rw [mk_yz_eq, IsFractionRing.mk'_eq_div, ← IsScalarTower.algebraMap_apply,
IsScalarTower.algebraMap_apply R K L, div_eq_mul_inv, ← mul_assoc, mul_comm, ← map_inv₀, ←
Algebra.smul_def, ← map_mul]
exact (Submodule.span K _).smul_mem _ hy
refine Submodule.span_subset_span R K _ ?_
rw [Submodule.span_algebraMap_image_of_tower]
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specify the value of `f` here:
exact Submodule.mem_map_of_mem (f := LinearMap.restrictScalars _ _)
(h (Ideal.mem_span_singleton.mpr ⟨y, rfl⟩))
end IsFractionRing
open nonZeroDivisors in
lemma isAlgebraic_of_isFractionRing {R S} (K L) [CommRing R] [CommRing S] [Field K] [CommRing L]
[Algebra R S] [Algebra R K] [Algebra R L] [Algebra S L] [Algebra K L] [IsScalarTower R S L]
[IsScalarTower R K L] [IsFractionRing S L]
[Algebra.IsIntegral R S] : Algebra.IsAlgebraic K L := by
constructor
intro x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq S⁰ x
apply IsIntegral.isAlgebraic
rw [IsLocalization.mk'_eq_mul_mk'_one]
apply RingHom.IsIntegralElem.mul
· apply IsIntegral.tower_top (R := R)
apply IsIntegral.map (IsScalarTower.toAlgHom R S L)
exact Algebra.IsIntegral.isIntegral x
· change IsIntegral _ _
rw [← isAlgebraic_iff_isIntegral, ← IsAlgebraic.invOf_iff, isAlgebraic_iff_isIntegral]
apply IsIntegral.tower_top (R := R)
apply IsIntegral.map (IsScalarTower.toAlgHom R S L)
exact Algebra.IsIntegral.isIntegral (s : S) |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Module.lean | import Mathlib.Algebra.Module.LocalizedModule.IsLocalization
import Mathlib.LinearAlgebra.Basis.Basic
import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Integer
/-!
# Modules / vector spaces over localizations / fraction fields
This file contains some results about vector spaces over the field of fractions of a ring.
## Main results
* `LinearIndependent.localization`: `b` is linear independent over a localization of `R`
if it is linear independent over `R` itself
* `Basis.ofIsLocalizedModule` / `Basis.localizationLocalization`: promote an `R`-basis `b` of `A`
to an `Rₛ`-basis of `Aₛ`, where `Rₛ` and `Aₛ` are localizations of `R` and `A` at `s`
respectively
* `LinearIndependent.iff_fractionRing`: `b` is linear independent over `R` iff it is
linear independent over `Frac(R)`
-/
open nonZeroDivisors
section Localization
variable {R : Type*} (Rₛ : Type*)
section IsLocalizedModule
open Submodule
variable [CommSemiring R] (S : Submonoid R) [CommSemiring Rₛ] [Algebra R Rₛ] [IsLocalization S Rₛ]
{M Mₛ : Type*} [AddCommMonoid M] [Module R M] [AddCommMonoid Mₛ] [Module R Mₛ]
[Module Rₛ Mₛ] [IsScalarTower R Rₛ Mₛ] (f : M →ₗ[R] Mₛ) [IsLocalizedModule S f]
include S
theorem span_eq_top_of_isLocalizedModule {v : Set M} (hv : span R v = ⊤) :
span Rₛ (f '' v) = ⊤ := top_unique fun x _ ↦ by
obtain ⟨⟨m, s⟩, h⟩ := IsLocalizedModule.surj S f x
rw [Submonoid.smul_def, ← algebraMap_smul Rₛ, ← Units.smul_isUnit (IsLocalization.map_units Rₛ s),
eq_comm, ← inv_smul_eq_iff] at h
refine h ▸ smul_mem _ _ (span_subset_span R Rₛ _ ?_)
rw [← LinearMap.coe_restrictScalars R, ← LinearMap.map_span, hv]
exact mem_map_of_mem mem_top
theorem LinearIndependent.of_isLocalizedModule {ι : Type*} {v : ι → M}
(hv : LinearIndependent R v) : LinearIndependent Rₛ (f ∘ v) := by
rw [linearIndependent_iff'ₛ] at hv ⊢
intro t g₁ g₂ eq i hi
choose! a fg hfg using IsLocalization.exist_integer_multiples S (t.disjSum t) (Sum.elim g₁ g₂)
simp_rw [Sum.forall, Finset.inl_mem_disjSum, Sum.elim_inl, Finset.inr_mem_disjSum, Sum.elim_inr,
Subtype.forall'] at hfg
apply_fun ((a : R) • ·) at eq
simp_rw [← t.sum_coe_sort, Finset.smul_sum, ← smul_assoc, ← hfg,
algebraMap_smul, Function.comp_def, ← map_smul, ← map_sum,
t.sum_coe_sort (f := fun x ↦ fg (Sum.inl x) • v x),
t.sum_coe_sort (f := fun x ↦ fg (Sum.inr x) • v x)] at eq
have ⟨s, eq⟩ := IsLocalizedModule.exists_of_eq (S := S) eq
simp_rw [Finset.smul_sum, Submonoid.smul_def, smul_smul] at eq
have := congr(algebraMap R Rₛ $(hv t _ _ eq i hi))
simpa only [map_mul, (IsLocalization.map_units Rₛ s).mul_right_inj, hfg.1 ⟨i, hi⟩, hfg.2 ⟨i, hi⟩,
Algebra.smul_def, (IsLocalization.map_units Rₛ a).mul_right_inj] using this
theorem LinearIndependent.of_isLocalizedModule_of_isRegular {ι : Type*} {v : ι → M}
(hv : LinearIndependent R v) (h : ∀ s : S, IsRegular (s : R)) : LinearIndependent R (f ∘ v) :=
hv.map_injOn _ <| by
rw [← Finsupp.range_linearCombination]
rintro _ ⟨_, r, rfl⟩ _ ⟨_, r', rfl⟩ eq
congr; ext i
have ⟨s, eq⟩ := IsLocalizedModule.exists_of_eq (S := S) eq
simp_rw [Submonoid.smul_def, ← map_smul] at eq
exact (h s).1 (DFunLike.congr_fun (hv eq) i)
theorem LinearIndependent.localization [Module Rₛ M] [IsScalarTower R Rₛ M]
{ι : Type*} {b : ι → M} (hli : LinearIndependent R b) :
LinearIndependent Rₛ b := by
have := isLocalizedModule_id S M Rₛ
exact hli.of_isLocalizedModule Rₛ S .id
include f in
lemma IsLocalizedModule.linearIndependent_lift {ι} {v : ι → Mₛ} (hf : LinearIndependent R v) :
∃ w : ι → M, LinearIndependent R w := by
cases isEmpty_or_nonempty ι
· exact ⟨isEmptyElim, linearIndependent_empty_type⟩
have inj := hf.smul_left_injective (Classical.arbitrary ι)
choose sec hsec using surj S f
use fun i ↦ (sec (v i)).1
rw [linearIndependent_iff'ₛ] at hf ⊢
intro t g g' eq i hit
refine (isRegular_of_smul_left_injective f inj (sec (v i)).2).2 <|
hf t (fun i ↦ _ * (sec (v i)).2) (fun i ↦ _ * (sec (v i)).2) ?_ i hit
simp_rw [mul_smul, ← Submonoid.smul_def, hsec, ← map_smul, ← map_sum, eq]
namespace Module.Basis
variable {ι : Type*} (b : Basis ι R M)
/-- If `M` has an `R`-basis, then localizing `M` at `S` has a basis over `R` localized at `S`. -/
noncomputable def ofIsLocalizedModule : Basis ι Rₛ Mₛ :=
.mk (b.linearIndependent.of_isLocalizedModule Rₛ S f) <| by
rw [Set.range_comp, span_eq_top_of_isLocalizedModule Rₛ S _ b.span_eq]
@[simp]
theorem ofIsLocalizedModule_apply (i : ι) : b.ofIsLocalizedModule Rₛ S f i = f (b i) := by
rw [ofIsLocalizedModule, coe_mk, Function.comp_apply]
@[simp]
theorem ofIsLocalizedModule_repr_apply (m : M) (i : ι) :
((b.ofIsLocalizedModule Rₛ S f).repr (f m)) i = algebraMap R Rₛ (b.repr m i) := by
suffices ((b.ofIsLocalizedModule Rₛ S f).repr.toLinearMap.restrictScalars R) ∘ₗ f =
Finsupp.mapRange.linearMap (Algebra.linearMap R Rₛ) ∘ₗ b.repr.toLinearMap by
exact DFunLike.congr_fun (LinearMap.congr_fun this m) i
refine ext b fun i ↦ ?_
rw [LinearMap.coe_comp, Function.comp_apply, LinearMap.coe_restrictScalars,
LinearEquiv.coe_coe, ← b.ofIsLocalizedModule_apply Rₛ S f, repr_self, LinearMap.coe_comp,
Function.comp_apply, LinearEquiv.coe_coe, repr_self, Finsupp.mapRange.linearMap_apply,
Finsupp.mapRange_single, Algebra.linearMap_apply, map_one]
theorem ofIsLocalizedModule_span :
span R (Set.range (b.ofIsLocalizedModule Rₛ S f)) = LinearMap.range f := by
calc span R (Set.range (b.ofIsLocalizedModule Rₛ S f))
_ = span R (f '' (Set.range b)) := by congr; ext; simp
_ = map f (span R (Set.range b)) := by rw [Submodule.map_span]
_ = LinearMap.range f := by rw [b.span_eq, Submodule.map_top]
end Module.Basis
end IsLocalizedModule
section LocalizationLocalization
variable [CommSemiring R] (S : Submonoid R) [CommSemiring Rₛ] [Algebra R Rₛ]
variable [IsLocalization S Rₛ]
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable (Aₛ : Type*) [CommSemiring Aₛ] [Algebra A Aₛ]
variable [Algebra Rₛ Aₛ] [Algebra R Aₛ] [IsScalarTower R Rₛ Aₛ] [IsScalarTower R A Aₛ]
variable [IsLocalization (Algebra.algebraMapSubmonoid A S) Aₛ]
open Submodule
include S
theorem LinearIndependent.localization_localization {ι : Type*} {v : ι → A}
(hv : LinearIndependent R v) : LinearIndependent Rₛ (algebraMap A Aₛ ∘ v) :=
hv.of_isLocalizedModule Rₛ S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap
theorem span_eq_top_localization_localization {v : Set A} (hv : span R v = ⊤) :
span Rₛ (algebraMap A Aₛ '' v) = ⊤ :=
span_eq_top_of_isLocalizedModule Rₛ S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap hv
namespace Module.Basis
/-- If `A` has an `R`-basis, then localizing `A` at `S` has a basis over `R` localized at `S`.
A suitable instance for `[Algebra A Aₛ]` is `localizationAlgebra`.
-/
noncomputable def localizationLocalization {ι : Type*} (b : Basis ι R A) : Basis ι Rₛ Aₛ :=
b.ofIsLocalizedModule Rₛ S (IsScalarTower.toAlgHom R A Aₛ).toLinearMap
@[simp]
theorem localizationLocalization_apply {ι : Type*} (b : Basis ι R A) (i) :
b.localizationLocalization Rₛ S Aₛ i = algebraMap A Aₛ (b i) :=
b.ofIsLocalizedModule_apply Rₛ S _ i
@[simp]
theorem localizationLocalization_repr_algebraMap {ι : Type*} (b : Basis ι R A) (x i) :
(b.localizationLocalization Rₛ S Aₛ).repr (algebraMap A Aₛ x) i =
algebraMap R Rₛ (b.repr x i) := b.ofIsLocalizedModule_repr_apply Rₛ S _ _ i
theorem localizationLocalization_span {ι : Type*} (b : Basis ι R A) :
Submodule.span R (Set.range (b.localizationLocalization Rₛ S Aₛ)) =
LinearMap.range (IsScalarTower.toAlgHom R A Aₛ) := b.ofIsLocalizedModule_span Rₛ S _
end Module.Basis
end LocalizationLocalization
section FractionRing
variable (R K : Type*) [CommRing R] [CommRing K] [Algebra R K] [IsFractionRing R K]
variable {V : Type*} [AddCommGroup V] [Module R V] [Module K V] [IsScalarTower R K V]
theorem LinearIndependent.iff_fractionRing {ι : Type*} {b : ι → V} :
LinearIndependent R b ↔ LinearIndependent K b :=
⟨.localization K R⁰,
.restrict_scalars <| (faithfulSMul_iff_injective_smul_one ..).mp inferInstance⟩
end FractionRing
section
variable {R : Type*} [CommSemiring R] (S : Submonoid R)
variable (A : Type*) [CommSemiring A] [Algebra R A] [IsLocalization S A]
variable {M N : Type*}
[AddCommMonoid M] [Module R M] [Module A M] [IsScalarTower R A M]
[AddCommMonoid N] [Module R N] [Module A N] [IsScalarTower R A N]
open IsLocalization
/-- An `R`-linear map between two `S⁻¹R`-modules is actually `S⁻¹R`-linear. -/
def LinearMap.extendScalarsOfIsLocalization (f : M →ₗ[R] N) : M →ₗ[A] N where
toFun := f
map_add' := f.map_add
map_smul' := (IsLocalization.linearMap_compatibleSMul S A M N).map_smul _
@[simp] lemma LinearMap.restrictScalars_extendScalarsOfIsLocalization (f : M →ₗ[R] N) :
(f.extendScalarsOfIsLocalization S A).restrictScalars R = f := rfl
@[simp] lemma LinearMap.extendScalarsOfIsLocalization_apply (f : M →ₗ[A] N) :
f.extendScalarsOfIsLocalization S A = f := rfl
@[simp] lemma LinearMap.extendScalarsOfIsLocalization_apply' (f : M →ₗ[R] N) (x : M) :
(f.extendScalarsOfIsLocalization S A) x = f x := rfl
/-- The `S⁻¹R`-linear maps between two `S⁻¹R`-modules are exactly the `R`-linear maps. -/
@[simps]
def LinearMap.extendScalarsOfIsLocalizationEquiv : (M →ₗ[R] N) ≃ₗ[A] (M →ₗ[A] N) where
toFun := LinearMap.extendScalarsOfIsLocalization S A
invFun := LinearMap.restrictScalars R
map_add' := by intros; ext; simp
map_smul' := by intros; ext; simp
left_inv := by intro _; ext; simp
right_inv := by intro _; ext; simp
/-- An `R`-linear isomorphism between `S⁻¹R`-modules is actually `S⁻¹R`-linear. -/
@[simps!]
def LinearEquiv.extendScalarsOfIsLocalization (f : M ≃ₗ[R] N) : M ≃ₗ[A] N :=
.ofLinear (LinearMap.extendScalarsOfIsLocalization S A f)
(LinearMap.extendScalarsOfIsLocalization S A f.symm)
(by ext; simp) (by ext; simp)
/-- The `S⁻¹R`-linear isomorphisms between two `S⁻¹R`-modules are exactly the `R`-linear
isomorphisms. -/
@[simps]
def LinearEquiv.extendScalarsOfIsLocalizationEquiv : (M ≃ₗ[R] N) ≃ M ≃ₗ[A] N where
toFun e := e.extendScalarsOfIsLocalization S A
invFun e := e.restrictScalars R
left_inv e := by ext; simp
right_inv e := by ext; simp
end
end Localization
namespace IsLocalizedModule
variable {R : Type*} [CommSemiring R] (S : Submonoid R)
variable {M M' : Type*} [AddCommMonoid M] [AddCommMonoid M']
variable [Module R M] [Module R M']
variable (f : M →ₗ[R] M') [IsLocalizedModule S f]
variable {N N'} [AddCommMonoid N] [AddCommMonoid N'] [Module R N] [Module R N']
variable (g : N →ₗ[R] N') [IsLocalizedModule S g]
variable (Rₛ) [CommSemiring Rₛ] [Algebra R Rₛ] [Module Rₛ M'] [Module Rₛ N']
variable [IsScalarTower R Rₛ M'] [IsScalarTower R Rₛ N'] [IsLocalization S Rₛ]
/-- A linear map `M →ₗ[R] N` gives a map between localized modules `Mₛ →ₗ[Rₛ] Nₛ`. -/
@[simps!]
noncomputable
def mapExtendScalars : (M →ₗ[R] N) →ₗ[R] (M' →ₗ[Rₛ] N') :=
((LinearMap.extendScalarsOfIsLocalizationEquiv S Rₛ).restrictScalars R).toLinearMap ∘ₗ map S f g
/-- An `R`-module isomorphism `M ≃ₗ[R] N` gives an `Rₛ`-module isomorphism `Mₛ ≃ₗ[Rₛ] Nₛ`. -/
@[simps!]
noncomputable
def mapEquiv (e : M ≃ₗ[R] N) : M' ≃ₗ[Rₛ] N' :=
LinearEquiv.ofLinear
(IsLocalizedModule.mapExtendScalars S f g Rₛ e)
(IsLocalizedModule.mapExtendScalars S g f Rₛ e.symm)
(by
apply LinearMap.restrictScalars_injective R
apply IsLocalizedModule.linearMap_ext S g g
ext; simp)
(by
apply LinearMap.restrictScalars_injective R
apply IsLocalizedModule.linearMap_ext S f f
ext; simp)
end IsLocalizedModule
section LocalizedModule
variable {R : Type*} [CommSemiring R] (S : Submonoid R)
variable {M : Type*} [AddCommMonoid M] [Module R M]
variable {N} [AddCommMonoid N] [Module R N]
/-- A linear map `M →ₗ[R] N` gives a map between localized modules `Mₛ →ₗ[Rₛ] Nₛ`. -/
noncomputable
def LocalizedModule.map :
(M →ₗ[R] N) →ₗ[R] (LocalizedModule S M →ₗ[Localization S] LocalizedModule S N) :=
IsLocalizedModule.mapExtendScalars S (LocalizedModule.mkLinearMap S M)
(LocalizedModule.mkLinearMap S N) (Localization S)
@[simp]
lemma LocalizedModule.map_mk (f : M →ₗ[R] N) (x y) :
map S f (.mk x y) = LocalizedModule.mk (f x) y := by
rw [IsLocalizedModule.mk_eq_mk', IsLocalizedModule.mk_eq_mk']
exact IsLocalizedModule.map_mk' _ _ _ _ _ _
@[simp]
lemma LocalizedModule.map_id :
LocalizedModule.map S (.id (R := R) (M := M)) = LinearMap.id :=
LinearMap.ext fun x ↦ LinearMap.congr_fun (IsLocalizedModule.map_id S (mkLinearMap S M)) x
lemma LocalizedModule.map_injective (l : M →ₗ[R] N) (hl : Function.Injective l) :
Function.Injective (map S l) :=
IsLocalizedModule.map_injective S (mkLinearMap S M) (mkLinearMap S N) l hl
lemma LocalizedModule.map_surjective (l : M →ₗ[R] N) (hl : Function.Surjective l) :
Function.Surjective (map S l) :=
IsLocalizedModule.map_surjective S (mkLinearMap S M) (mkLinearMap S N) l hl
lemma LocalizedModule.restrictScalars_map_eq {M' N' : Type*} [AddCommMonoid M'] [AddCommMonoid N']
[Module R M'] [Module R N'] (g₁ : M →ₗ[R] M') (g₂ : N →ₗ[R] N')
[IsLocalizedModule S g₁] [IsLocalizedModule S g₂]
(l : M →ₗ[R] N) :
(map S l).restrictScalars R = (IsLocalizedModule.iso S g₂).symm ∘ₗ
IsLocalizedModule.map S g₁ g₂ l ∘ₗ IsLocalizedModule.iso S g₁ := by
rw [LinearEquiv.eq_toLinearMap_symm_comp, ← LinearEquiv.comp_toLinearMap_symm_eq]
apply IsLocalizedModule.linearMap_ext S g₁ g₂
rw [LinearMap.comp_assoc, IsLocalizedModule.iso_symm_comp]
ext
simp
end LocalizedModule |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/AsSubring.lean | import Mathlib.RingTheory.Localization.LocalizationLocalization
import Mathlib.LinearAlgebra.FreeModule.Basic
import Mathlib.Algebra.Algebra.Subalgebra.Tower
/-!
# Localizations of domains as subalgebras of the fraction field.
Given a domain `A` with fraction field `K`, and a submonoid `S` of `A` which
does not contain zero, this file constructs the localization of `A` at `S`
as a subalgebra of the field `K` over `A`.
-/
namespace Localization
open nonZeroDivisors
variable {A : Type*} (K : Type*) [CommRing A] (S : Submonoid A) (hS : S ≤ A⁰)
section CommRing
variable [CommRing K] [Algebra A K] [IsFractionRing A K]
theorem map_isUnit_of_le (hS : S ≤ A⁰) (s : S) : IsUnit (algebraMap A K s) := by
apply IsLocalization.map_units K (⟨s.1, hS s.2⟩ : A⁰)
/-- The canonical map from a localization of `A` at `S` to the fraction ring
of `A`, given that `S ≤ A⁰`. -/
noncomputable def mapToFractionRing (B : Type*) [CommRing B] [Algebra A B] [IsLocalization S B]
(hS : S ≤ A⁰) : B →ₐ[A] K :=
{ IsLocalization.lift (map_isUnit_of_le K S hS) with commutes' := fun a => by simp }
@[simp]
theorem mapToFractionRing_apply {B : Type*} [CommRing B] [Algebra A B] [IsLocalization S B]
(hS : S ≤ A⁰) (b : B) :
mapToFractionRing K S B hS b = IsLocalization.lift (map_isUnit_of_le K S hS) b :=
rfl
theorem mem_range_mapToFractionRing_iff (B : Type*) [CommRing B] [Algebra A B] [IsLocalization S B]
(hS : S ≤ A⁰) (x : K) :
x ∈ (mapToFractionRing K S B hS).range ↔
∃ (a s : A) (hs : s ∈ S), x = IsLocalization.mk' K a ⟨s, hS hs⟩ :=
⟨by
rintro ⟨x, rfl⟩
obtain ⟨a, s, rfl⟩ := IsLocalization.exists_mk'_eq S x
use a, s, s.2
apply IsLocalization.lift_mk', by
rintro ⟨a, s, hs, rfl⟩
use IsLocalization.mk' _ a ⟨s, hs⟩
apply IsLocalization.lift_mk'⟩
instance isLocalization_range_mapToFractionRing (B : Type*) [CommRing B] [Algebra A B]
[IsLocalization S B] (hS : S ≤ A⁰) : IsLocalization S (mapToFractionRing K S B hS).range :=
IsLocalization.isLocalization_of_algEquiv S <|
show B ≃ₐ[A] _ from AlgEquiv.ofBijective (mapToFractionRing K S B hS).rangeRestrict (by
refine ⟨fun a b h => ?_, Set.rangeFactorization_surjective⟩
refine (IsLocalization.lift_injective_iff _).2 (fun a b => ?_) (Subtype.ext_iff.1 h)
exact ⟨fun h => congr_arg _ (IsLocalization.injective _ hS h),
fun h => congr_arg _ (IsFractionRing.injective A K h)⟩)
instance isFractionRing_range_mapToFractionRing (B : Type*) [CommRing B] [Algebra A B]
[IsLocalization S B] (hS : S ≤ A⁰) : IsFractionRing (mapToFractionRing K S B hS).range K :=
IsFractionRing.isFractionRing_of_isLocalization S _ _ hS
/-- Given a commutative ring `A` with fraction ring `K`, and a submonoid `S` of `A` which
contains no zero divisor, this is the localization of `A` at `S`, considered as
a subalgebra of `K` over `A`.
The carrier of this subalgebra is defined as the set of all `x : K` of the form
`IsLocalization.mk' K a ⟨s, _⟩`, where `s ∈ S`.
-/
noncomputable def subalgebra (hS : S ≤ A⁰) : Subalgebra A K :=
(mapToFractionRing K S (Localization S) hS).range.copy
{ x | ∃ (a s : A) (hs : s ∈ S), x = IsLocalization.mk' K a ⟨s, hS hs⟩ } <| by
ext
symm
apply mem_range_mapToFractionRing_iff
namespace subalgebra
instance isLocalization_subalgebra : IsLocalization S (subalgebra K S hS) := by
dsimp only [Localization.subalgebra]
rw [Subalgebra.copy_eq]
infer_instance
instance isFractionRing : IsFractionRing (subalgebra K S hS) K :=
IsFractionRing.isFractionRing_of_isLocalization S _ _ hS
end subalgebra
end CommRing
section Field
variable [Field K] [Algebra A K] [IsFractionRing A K]
namespace subalgebra
theorem mem_range_mapToFractionRing_iff_ofField (B : Type*) [CommRing B] [Algebra A B]
[IsLocalization S B] (x : K) :
x ∈ (mapToFractionRing K S B hS).range ↔
∃ (a s : A) (_ : s ∈ S), x = algebraMap A K a * (algebraMap A K s)⁻¹ := by
rw [mem_range_mapToFractionRing_iff]
convert Iff.rfl
congr
rw [Units.val_inv_eq_inv_val]
rfl
/-- Given a domain `A` with fraction field `K`, and a submonoid `S` of `A` which
contains no zero divisor, this is the localization of `A` at `S`, considered as
a subalgebra of `K` over `A`.
The carrier of this subalgebra is defined as the set of all `x : K` of the form
`algebraMap A K a * (algebraMap A K s)⁻¹` where `a s : A` and `s ∈ S`.
-/
noncomputable def ofField : Subalgebra A K :=
(mapToFractionRing K S (Localization S) hS).range.copy
{ x | ∃ (a s : A) (_ : s ∈ S), x = algebraMap A K a * (algebraMap A K s)⁻¹ } <| by
ext
symm
apply mem_range_mapToFractionRing_iff_ofField
theorem ofField_eq : ofField K S hS = subalgebra K S hS := by
simp_rw [ofField, subalgebra, Subalgebra.copy_eq]
instance isLocalization_ofField : IsLocalization S (ofField K S hS) := by
rw [ofField_eq]
exact isLocalization_subalgebra K S hS
instance (S : Subalgebra A K) : IsFractionRing S K := by
refine IsFractionRing.of_field S K fun z ↦ ?_
rcases IsFractionRing.div_surjective (A := A) z with ⟨x, y, _, eq⟩
exact ⟨algebraMap A S x, algebraMap A S y, eq.symm⟩
instance isFractionRing_ofField : IsFractionRing (ofField K S hS) K :=
inferInstance
end subalgebra
end Field
end Localization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/AtPrime.lean | import Mathlib.RingTheory.Localization.AtPrime.Basic
deprecated_module (since := "2025-08-01") |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Integer.lean | import Mathlib.Algebra.Group.Pointwise.Set.Scalar
import Mathlib.Algebra.Ring.Subsemiring.Basic
import Mathlib.RingTheory.Localization.Defs
/-!
# Integer elements of a localization
## Main definitions
* `IsLocalization.IsInteger` is a predicate stating that `x : S` is in the image of `R`
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommSemiring R] {M : Submonoid R} {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
open Function
namespace IsLocalization
section
variable (R)
-- TODO: define a subalgebra of `IsInteger`s
/-- Given `a : S`, `S` a localization of `R`, `IsInteger R a` iff `a` is in the image of
the localization map from `R` to `S`. -/
def IsInteger (a : S) : Prop :=
a ∈ (algebraMap R S).rangeS
end
theorem isInteger_zero : IsInteger R (0 : S) :=
Subsemiring.zero_mem _
theorem isInteger_one : IsInteger R (1 : S) :=
Subsemiring.one_mem _
theorem isInteger_add {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a + b) :=
Subsemiring.add_mem _ ha hb
theorem isInteger_mul {a b : S} (ha : IsInteger R a) (hb : IsInteger R b) : IsInteger R (a * b) :=
Subsemiring.mul_mem _ ha hb
theorem isInteger_smul {a : R} {b : S} (hb : IsInteger R b) : IsInteger R (a • b) := by
rcases hb with ⟨b', hb⟩
use a * b'
rw [← hb, (algebraMap R S).map_mul, Algebra.smul_def]
variable (M)
variable [IsLocalization M S]
/-- Each element `a : S` has an `M`-multiple which is an integer.
This version multiplies `a` on the right, matching the argument order in `LocalizationMap.surj`.
-/
theorem exists_integer_multiple' (a : S) : ∃ b : M, IsInteger R (a * algebraMap R S b) :=
let ⟨⟨Num, denom⟩, h⟩ := IsLocalization.surj _ a
⟨denom, Set.mem_range.mpr ⟨Num, h.symm⟩⟩
/-- Each element `a : S` has an `M`-multiple which is an integer.
This version multiplies `a` on the left, matching the argument order in the `SMul` instance.
-/
theorem exists_integer_multiple (a : S) : ∃ b : M, IsInteger R ((b : R) • a) := by
simp_rw [Algebra.smul_def, mul_comm _ a]
apply exists_integer_multiple'
/-- We can clear the denominators of a `Finset`-indexed family of fractions. -/
theorem exist_integer_multiples {ι : Type*} (s : Finset ι) (f : ι → S) :
∃ b : M, ∀ i ∈ s, IsLocalization.IsInteger R ((b : R) • f i) := by
haveI := Classical.propDecidable
refine ⟨∏ i ∈ s, (sec M (f i)).2, fun i hi => ⟨?_, ?_⟩⟩
· exact (∏ j ∈ s.erase i, (sec M (f j)).2) * (sec M (f i)).1
rw [RingHom.map_mul, sec_spec', ← mul_assoc, ← (algebraMap R S).map_mul, ← Algebra.smul_def]
congr 2
refine _root_.trans ?_ (map_prod (Submonoid.subtype M) _ _).symm
rw [mul_comm,Submonoid.coe_finset_prod,
-- Porting note: explicitly supplied `f`
← Finset.prod_insert (f := fun i => ((sec M (f i)).snd : R)) (s.notMem_erase i),
Finset.insert_erase hi]
rfl
/-- We can clear the denominators of a finite indexed family of fractions. -/
theorem exist_integer_multiples_of_finite {ι : Type*} [Finite ι] (f : ι → S) :
∃ b : M, ∀ i, IsLocalization.IsInteger R ((b : R) • f i) := by
cases nonempty_fintype ι
obtain ⟨b, hb⟩ := exist_integer_multiples M Finset.univ f
exact ⟨b, fun i => hb i (Finset.mem_univ _)⟩
/-- We can clear the denominators of a finite set of fractions. -/
theorem exist_integer_multiples_of_finset (s : Finset S) :
∃ b : M, ∀ a ∈ s, IsInteger R ((b : R) • a) :=
exist_integer_multiples M s id
/-- A choice of a common multiple of the denominators of a `Finset`-indexed family of fractions. -/
noncomputable def commonDenom {ι : Type*} (s : Finset ι) (f : ι → S) : M :=
(exist_integer_multiples M s f).choose
/-- The numerator of a fraction after clearing the denominators
of a `Finset`-indexed family of fractions. -/
noncomputable def integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) : R :=
((exist_integer_multiples M s f).choose_spec i i.prop).choose
@[simp]
theorem map_integerMultiple {ι : Type*} (s : Finset ι) (f : ι → S) (i : s) :
algebraMap R S (integerMultiple M s f i) = commonDenom M s f • f i :=
((exist_integer_multiples M s f).choose_spec _ i.prop).choose_spec
/-- A choice of a common multiple of the denominators of a finite set of fractions. -/
noncomputable def commonDenomOfFinset (s : Finset S) : M :=
commonDenom M s id
/-- The finset of numerators after clearing the denominators of a finite set of fractions. -/
noncomputable def finsetIntegerMultiple [DecidableEq R] (s : Finset S) : Finset R :=
s.attach.image fun t => integerMultiple M s id t
open Pointwise
theorem finsetIntegerMultiple_image [DecidableEq R] (s : Finset S) :
algebraMap R S '' finsetIntegerMultiple M s = commonDenomOfFinset M s • (s : Set S) := by
delta finsetIntegerMultiple commonDenom
rw [Finset.coe_image]
ext
constructor
· rintro ⟨_, ⟨x, -, rfl⟩, rfl⟩
rw [map_integerMultiple]
exact Set.mem_image_of_mem _ x.prop
· rintro ⟨x, hx, rfl⟩
exact ⟨_, ⟨⟨x, hx⟩, s.mem_attach _, rfl⟩, map_integerMultiple M s id _⟩
end IsLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Pi.lean | import Mathlib.Algebra.Algebra.Pi
import Mathlib.Algebra.BigOperators.Pi
import Mathlib.Algebra.Divisibility.Prod
import Mathlib.Algebra.Group.Submonoid.BigOperators
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.RingTheory.Localization.Basic
import Mathlib.Algebra.Group.Pi.Units
import Mathlib.RingTheory.KrullDimension.Zero
/-!
# Localizing a product of commutative rings
## Main Result
* `bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom`: the canonical map from a
localization of a finite product of rings `R i `at a monoid `M` to the direct product of
localizations `R i` at the projection of `M` onto each corresponding factor is bijective.
## Implementation notes
See `Mathlib/RingTheory/Localization/Defs.lean` for a design overview.
## Tags
localization, commutative ring
-/
namespace IsLocalization
variable {ι : Type*} (R S : ι → Type*)
[Π i, CommSemiring (R i)] [Π i, CommSemiring (S i)] [Π i, Algebra (R i) (S i)]
/-- If `S i` is a localization of `R i` at the submonoid `M i` for each `i`,
then `Π i, S i` is a localization of `Π i, R i` at the product submonoid. -/
instance (M : Π i, Submonoid (R i)) [∀ i, IsLocalization (M i) (S i)] :
IsLocalization (.pi .univ M) (Π i, S i) where
map_units m := Pi.isUnit_iff.mpr fun i ↦ map_units _ ⟨m.1 i, m.2 i ⟨⟩⟩
surj z := by
choose rm h using fun i ↦ surj (M := M i) (z i)
exact ⟨(fun i ↦ (rm i).1, ⟨_, fun i _ ↦ (rm i).2.2⟩), funext h⟩
exists_of_eq {x y} eq := by
choose c hc using fun i ↦ exists_of_eq (M := M i) (congr_fun eq i)
exact ⟨⟨_, fun i _ ↦ (c i).2⟩, funext hc⟩
variable (S' : Type*) [CommSemiring S'] [Algebra (Π i, R i) S'] (M : Submonoid (Π i, R i))
theorem iff_map_piEvalRingHom [Finite ι] :
IsLocalization M S' ↔ IsLocalization (.pi .univ fun i ↦ M.map (Pi.evalRingHom R i)) S' :=
iff_of_le_of_exists_dvd M _ (fun m hm i _ ↦ ⟨m, hm, rfl⟩) fun n hn ↦ by
choose m mem eq using hn
have := Fintype.ofFinite ι
refine ⟨∏ i, m i ⟨⟩, prod_mem fun i _ ↦ mem i _, pi_dvd_iff.mpr fun i ↦ ?_⟩
rw [Fintype.prod_apply]
exact (eq i ⟨⟩).symm.dvd.trans (Finset.dvd_prod_of_mem _ <| Finset.mem_univ _)
variable [∀ i, IsLocalization (M.map (Pi.evalRingHom R i)) (S i)]
/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote
the projection of `M` onto each corresponding factor. Given a ring homomorphism from the direct
product `Π i, R i` to the product of the localizations of each `R i` at `M' i`, every `y : M`
maps to a unit under this homomorphism. -/
lemma isUnit_piRingHom_algebraMap_comp_piEvalRingHom (y : M) :
IsUnit ((Pi.ringHom fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i)) y) :=
Pi.isUnit_iff.mpr fun i ↦ map_units _ (⟨y.1 i, y, y.2, rfl⟩ : M.map (Pi.evalRingHom R i))
/-- Let `M` be a submonoid of a direct product of commutative rings `R i`, and let `M' i` denote
the projection of `M` onto each factor. Then the canonical map from the localization of the direct
product `Π i, R i` at `M` to the direct product of the localizations of each `R i` at `M' i`
is bijective. -/
theorem bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom [IsLocalization M S'] [Finite ι] :
Function.Bijective (lift (S := S') (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) :=
have := (iff_map_piEvalRingHom R (Π i, S i) M).mpr inferInstance
(ringEquivOfRingEquiv (M := M) (T := M) _ _ (.refl _) <|
Submonoid.map_equiv_eq_comap_symm _ _).bijective
open Function Ideal
include M in
variable {R} in
lemma surjective_piRingHom_algebraMap_comp_piEvalRingHom
[∀ i, Ring.KrullDimLE 0 (R i)] [∀ i, IsLocalRing (R i)] :
Surjective (Pi.ringHom (fun i ↦ (algebraMap (R i) (S i)).comp (Pi.evalRingHom R i))) := by
apply Surjective.piMap (fun i ↦ ?_)
by_cases h₀ : (0 : R i) ∈ (M.map (Pi.evalRingHom R i))
· have := uniqueOfZeroMem h₀ (S := (S i))
exact surjective_to_subsingleton (algebraMap (R i) (S i))
· exact (IsLocalization.atUnits _ _ (by simpa)).surjective
variable {R} in
/-- Let `M` be a submonoid of a direct product of commutative rings `R i`.
If each `R i` has maximal nilradical then the direct product `∏ R i` surjects onto the
localization of `∏ R i` at `M`. -/
lemma algebraMap_pi_surjective_of_isLocalization [∀ i, Ring.KrullDimLE 0 (R i)]
[∀ i, IsLocalRing (R i)] [IsLocalization M S']
[Finite ι] : Surjective (algebraMap (Π i, R i) S') := by
intro s
set S := fun (i : ι) => Localization (M.map (Pi.evalRingHom R i))
obtain ⟨r, hr⟩ :=
surjective_piRingHom_algebraMap_comp_piEvalRingHom
S M ((lift (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M)) s)
refine ⟨r, (bijective_lift_piRingHom_algebraMap_comp_piEvalRingHom R S _ M).injective ?_⟩
rwa [lift_eq (isUnit_piRingHom_algebraMap_comp_piEvalRingHom R S M) r]
end IsLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/InvSubmonoid.lean | import Mathlib.GroupTheory.Submonoid.Inverses
import Mathlib.RingTheory.FiniteType
import Mathlib.RingTheory.Localization.Defs
/-!
# Submonoid of inverses
## Main definitions
* `IsLocalization.invSubmonoid M S` is the submonoid of `S = M⁻¹R` consisting of inverses of
each element `x ∈ M`
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S]
variable [Algebra R S]
open Function
namespace IsLocalization
section InvSubmonoid
/-- The submonoid of `S = M⁻¹R` consisting of `{ 1 / x | x ∈ M }`. -/
def invSubmonoid : Submonoid S :=
(M.map (algebraMap R S)).leftInv
variable [IsLocalization M S]
theorem submonoid_map_le_is_unit : M.map (algebraMap R S) ≤ IsUnit.submonoid S := by
rintro _ ⟨a, ha, rfl⟩
exact IsLocalization.map_units S ⟨_, ha⟩
/-- There is an equivalence of monoids between the image of `M` and `invSubmonoid`. -/
noncomputable abbrev equivInvSubmonoid : M.map (algebraMap R S) ≃* invSubmonoid M S :=
((M.map (algebraMap R S)).leftInvEquiv (submonoid_map_le_is_unit M S)).symm
/-- There is a canonical map from `M` to `invSubmonoid` sending `x` to `1 / x`. -/
noncomputable def toInvSubmonoid : M →* invSubmonoid M S :=
(equivInvSubmonoid M S).toMonoidHom.comp ((algebraMap R S : R →* S).submonoidMap M)
theorem toInvSubmonoid_surjective : Function.Surjective (toInvSubmonoid M S) :=
Function.Surjective.comp (β := M.map (algebraMap R S))
(Equiv.surjective (equivInvSubmonoid _ _).toEquiv) (MonoidHom.submonoidMap_surjective _ _)
@[simp]
theorem toInvSubmonoid_mul (m : M) : (toInvSubmonoid M S m : S) * algebraMap R S m = 1 :=
Submonoid.leftInvEquiv_symm_mul _ (submonoid_map_le_is_unit _ _) _
@[simp]
theorem mul_toInvSubmonoid (m : M) : algebraMap R S m * (toInvSubmonoid M S m : S) = 1 :=
Submonoid.mul_leftInvEquiv_symm _ (submonoid_map_le_is_unit _ _) ⟨_, _⟩
@[simp]
theorem smul_toInvSubmonoid (m : M) : m • (toInvSubmonoid M S m : S) = 1 := by
convert mul_toInvSubmonoid M S m
ext
rw [← Algebra.smul_def]
rfl
variable {S}
-- `surj'` was taken, so use `surj''` instead
-- TODO: this can be fixed after the deprecations of 2025-09-04 are removed.
theorem surj'' (z : S) : ∃ (r : R) (m : M), z = r • (toInvSubmonoid M S m : S) := by
rcases IsLocalization.surj M z with ⟨⟨r, m⟩, e : z * _ = algebraMap R S r⟩
refine ⟨r, m, ?_⟩
rw [Algebra.smul_def, ← e, mul_assoc]
simp
theorem toInvSubmonoid_eq_mk' (x : M) : (toInvSubmonoid M S x : S) = mk' S 1 x := by
rw [← (IsLocalization.map_units S x).mul_left_inj]
simp
theorem mem_invSubmonoid_iff_exists_mk' (x : S) :
x ∈ invSubmonoid M S ↔ ∃ m : M, mk' S 1 m = x := by
simp_rw [← toInvSubmonoid_eq_mk']
exact ⟨fun h => ⟨_, congr_arg Subtype.val (toInvSubmonoid_surjective M S ⟨x, h⟩).choose_spec⟩,
fun h => h.choose_spec ▸ (toInvSubmonoid M S h.choose).prop⟩
variable (S)
theorem span_invSubmonoid : Submodule.span R (invSubmonoid M S : Set S) = ⊤ := by
rw [eq_top_iff]
rintro x -
rcases IsLocalization.surj'' M x with ⟨r, m, rfl⟩
exact Submodule.smul_mem _ _ (Submodule.subset_span (toInvSubmonoid M S m).prop)
theorem finiteType_of_monoid_fg [Monoid.FG M] : Algebra.FiniteType R S := by
have := Monoid.fg_of_surjective _ (toInvSubmonoid_surjective M S)
rw [Monoid.fg_iff_submonoid_fg] at this
rcases this with ⟨s, hs⟩
refine ⟨⟨s, ?_⟩⟩
rw [eq_top_iff]
rintro x -
change x ∈ (Subalgebra.toSubmodule (Algebra.adjoin R _ : Subalgebra R S) : Set S)
rw [Algebra.adjoin_eq_span, hs, span_invSubmonoid]
trivial
end InvSubmonoid
end IsLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Basic.lean | import Mathlib.Algebra.Algebra.Tower
import Mathlib.Algebra.Field.IsField
import Mathlib.Algebra.GroupWithZero.NonZeroDivisors
import Mathlib.Data.Finite.Prod
import Mathlib.GroupTheory.MonoidLocalization.MonoidWithZero
import Mathlib.RingTheory.Localization.Defs
import Mathlib.RingTheory.OreLocalization.Ring
/-!
# Localizations of commutative rings
This file contains various basic results on localizations.
We characterize the localization of a commutative ring `R` at a submonoid `M` up to
isomorphism; that is, a commutative ring `S` is the localization of `R` at `M` iff we can find a
ring homomorphism `f : R →+* S` satisfying 3 properties:
1. For all `y ∈ M`, `f y` is a unit;
2. For all `z : S`, there exists `(x, y) : R × M` such that `z * f y = f x`;
3. For all `x, y : R` such that `f x = f y`, there exists `c ∈ M` such that `x * c = y * c`.
(The converse is a consequence of 1.)
In the following, let `R, P` be commutative rings, `S, Q` be `R`- and `P`-algebras
and `M, T` be submonoids of `R` and `P` respectively, e.g.:
```
variable (R S P Q : Type*) [CommRing R] [CommRing S] [CommRing P] [CommRing Q]
variable [Algebra R S] [Algebra P Q] (M : Submonoid R) (T : Submonoid P)
```
## Main definitions
* `IsLocalization.algEquiv`: if `Q` is another localization of `R` at `M`, then `S` and `Q`
are isomorphic as `R`-algebras
## Implementation notes
In maths it is natural to reason up to isomorphism, but in Lean we cannot naturally `rewrite` one
structure with an isomorphic one; one way around this is to isolate a predicate characterizing
a structure up to isomorphism, and reason about things that satisfy the predicate.
A previous version of this file used a fully bundled type of ring localization maps,
then used a type synonym `f.codomain` for `f : LocalizationMap M S` to instantiate the
`R`-algebra structure on `S`. This results in defining ad-hoc copies for everything already
defined on `S`. By making `IsLocalization` a predicate on the `algebraMap R S`,
we can ensure the localization map commutes nicely with other `algebraMap`s.
To prove most lemmas about a localization map `algebraMap R S` in this file we invoke the
corresponding proof for the underlying `CommMonoid` localization map
`IsLocalization.toLocalizationMap M S`, which can be found in `GroupTheory.MonoidLocalization`
and the namespace `Submonoid.LocalizationMap`.
To reason about the localization as a quotient type, use `mk_eq_of_mk'` and associated lemmas.
These show the quotient map `mk : R → M → Localization M` equals the surjection
`LocalizationMap.mk'` induced by the map `algebraMap : R →+* Localization M`.
The lemma `mk_eq_of_mk'` hence gives you access to the results in the rest of the file,
which are about the `LocalizationMap.mk'` induced by any localization map.
The proof that "a `CommRing` `K` which is the localization of an integral domain `R` at `R \ {0}`
is a field" is a `def` rather than an `instance`, so if you want to reason about a field of
fractions `K`, assume `[Field K]` instead of just `[CommRing K]`.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
assert_not_exists Ideal
open Function
namespace Localization
open IsLocalization
variable {ι : Type*} {R : ι → Type*} [∀ i, CommSemiring (R i)]
variable {i : ι} (S : Submonoid (R i))
/-- `IsLocalization.map` applied to a projection homomorphism from a product ring. -/
noncomputable abbrev mapPiEvalRingHom :
Localization (S.comap <| Pi.evalRingHom R i) →+* Localization S :=
map (T := S) _ (Pi.evalRingHom R i) le_rfl
open Function in
theorem mapPiEvalRingHom_bijective : Bijective (mapPiEvalRingHom S) := by
let T := S.comap (Pi.evalRingHom R i)
classical
refine ⟨fun x₁ x₂ eq ↦ ?_, fun x ↦ ?_⟩
· obtain ⟨r₁, s₁, rfl⟩ := exists_mk'_eq T x₁
obtain ⟨r₂, s₂, rfl⟩ := exists_mk'_eq T x₂
simp_rw [map_mk'] at eq
rw [IsLocalization.eq] at eq ⊢
obtain ⟨s, hs⟩ := eq
refine ⟨⟨update 0 i s, by apply update_self i s.1 0 ▸ s.2⟩, funext fun j ↦ ?_⟩
obtain rfl | ne := eq_or_ne j i
· simpa using hs
· simp [update_of_ne ne]
· obtain ⟨r, s, rfl⟩ := exists_mk'_eq S x
exact ⟨mk' (M := T) _ (update 0 i r) ⟨update 0 i s, by apply update_self i s.1 0 ▸ s.2⟩,
by simp [map_mk']⟩
end Localization
section CommSemiring
variable {R : Type*} [CommSemiring R] {M N : Submonoid R} {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
namespace IsLocalization
section IsLocalization
variable [IsLocalization M S]
include M in
variable (R M) in
protected lemma finite [Finite R] : Finite S := by
have : Function.Surjective (Function.uncurry (mk' (M := M) S)) := fun x ↦ by
simpa using IsLocalization.exists_mk'_eq M x
exact .of_surjective _ this
section CompatibleSMul
variable (N₁ N₂ : Type*) [AddCommMonoid N₁] [AddCommMonoid N₂] [Module R N₁] [Module R N₂]
variable (M S) in
include M in
theorem linearMap_compatibleSMul [Module S N₁] [Module S N₂]
[IsScalarTower R S N₁] [IsScalarTower R S N₂] :
LinearMap.CompatibleSMul N₁ N₂ S R where
map_smul f s s' := by
obtain ⟨r, m, rfl⟩ := exists_mk'_eq M s
rw [← (map_units S m).smul_left_cancel]
simp_rw [algebraMap_smul, ← map_smul, ← smul_assoc, smul_mk'_self, algebraMap_smul, map_smul]
instance [Module (Localization M) N₁] [Module (Localization M) N₂]
[IsScalarTower R (Localization M) N₁] [IsScalarTower R (Localization M) N₂] :
LinearMap.CompatibleSMul N₁ N₂ (Localization M) R :=
linearMap_compatibleSMul M ..
end CompatibleSMul
variable {g : R →+* P} (hg : ∀ y : M, IsUnit (g y))
variable (M) in
include M in
-- This is not an instance since the submonoid `M` would become a metavariable in typeclass search.
theorem algHom_subsingleton [Algebra R P] : Subsingleton (S →ₐ[R] P) :=
⟨fun f g =>
AlgHom.coe_ringHom_injective <|
IsLocalization.ringHom_ext M <| by rw [f.comp_algebraMap, g.comp_algebraMap]⟩
section AlgEquiv
variable {Q : Type*} [CommSemiring Q] [Algebra R Q] [IsLocalization M Q]
section
variable (M S Q)
/-- If `S`, `Q` are localizations of `R` at the submonoid `M` respectively,
there is an isomorphism of localizations `S ≃ₐ[R] Q`. -/
@[simps!]
noncomputable def algEquiv : S ≃ₐ[R] Q :=
{ ringEquivOfRingEquiv S Q (RingEquiv.refl R) M.map_id with
commutes' := ringEquivOfRingEquiv_eq _ }
end
theorem algEquiv_mk' (x : R) (y : M) : algEquiv M S Q (mk' S x y) = mk' Q x y := by
simp
theorem algEquiv_symm_mk' (x : R) (y : M) : (algEquiv M S Q).symm (mk' Q x y) = mk' S x y := by simp
variable (M) in
include M in
protected lemma bijective (f : S →+* Q) (hf : f.comp (algebraMap R S) = algebraMap R Q) :
Function.Bijective f :=
(show f = IsLocalization.algEquiv M S Q by
apply IsLocalization.ringHom_ext M; rw [hf]; ext; simp) ▸
(IsLocalization.algEquiv M S Q).toEquiv.bijective
end AlgEquiv
section liftAlgHom
variable {A : Type*} [CommSemiring A]
{R : Type*} [CommSemiring R] [Algebra A R] {M : Submonoid R}
{S : Type*} [CommSemiring S] [Algebra A S] [Algebra R S] [IsScalarTower A R S]
{P : Type*} [CommSemiring P] [Algebra A P] [IsLocalization M S]
{f : R →ₐ[A] P} (hf : ∀ y : M, IsUnit (f y)) (x : S)
include hf
/-- `AlgHom` version of `IsLocalization.lift`. -/
noncomputable def liftAlgHom : S →ₐ[A] P where
__ := lift hf
commutes' r := show lift hf (algebraMap A S r) = _ by
simp [IsScalarTower.algebraMap_apply A R S]
theorem liftAlgHom_toRingHom : (liftAlgHom hf : S →ₐ[A] P).toRingHom = lift hf := rfl
@[simp]
theorem coe_liftAlgHom : ⇑(liftAlgHom hf : S →ₐ[A] P) = lift hf := rfl
theorem liftAlgHom_apply : liftAlgHom hf x = lift hf x := rfl
end liftAlgHom
section AlgEquivOfAlgEquiv
variable {A : Type*} [CommSemiring A]
{R : Type*} [CommSemiring R] [Algebra A R] {M : Submonoid R} (S : Type*)
[CommSemiring S] [Algebra A S] [Algebra R S] [IsScalarTower A R S] [IsLocalization M S]
{P : Type*} [CommSemiring P] [Algebra A P] {T : Submonoid P} (Q : Type*)
[CommSemiring Q] [Algebra A Q] [Algebra P Q] [IsScalarTower A P Q] [IsLocalization T Q]
(h : R ≃ₐ[A] P) (H : Submonoid.map h M = T)
include H
/-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M`, `T` respectively,
an isomorphism `h : R ≃ₐ[A] P` such that `h(M) = T` induces an isomorphism of localizations
`S ≃ₐ[A] Q`. -/
@[simps!]
noncomputable def algEquivOfAlgEquiv : S ≃ₐ[A] Q where
__ := ringEquivOfRingEquiv S Q h.toRingEquiv H
commutes' _ := by dsimp; rw [IsScalarTower.algebraMap_apply A R S, map_eq,
RingHom.coe_coe, AlgEquiv.commutes, IsScalarTower.algebraMap_apply A P Q]
variable {S Q h}
theorem algEquivOfAlgEquiv_eq_map :
(algEquivOfAlgEquiv S Q h H : S →+* Q) =
map Q (h : R →+* P) (M.le_comap_of_map_le (le_of_eq H)) :=
rfl
theorem algEquivOfAlgEquiv_eq (x : R) :
algEquivOfAlgEquiv S Q h H ((algebraMap R S) x) = algebraMap P Q (h x) := by
simp
set_option linter.docPrime false in
theorem algEquivOfAlgEquiv_mk' (x : R) (y : M) :
algEquivOfAlgEquiv S Q h H (mk' S x y) =
mk' Q (h x) ⟨h y, show h y ∈ T from H ▸ Set.mem_image_of_mem h y.2⟩ := by
simp [map_mk']
theorem algEquivOfAlgEquiv_symm : (algEquivOfAlgEquiv S Q h H).symm =
algEquivOfAlgEquiv Q S h.symm (show Submonoid.map h.symm T = M by
rw [← H, ← Submonoid.map_coe_toMulEquiv, AlgEquiv.symm_toMulEquiv,
← Submonoid.comap_equiv_eq_map_symm, ← Submonoid.map_coe_toMulEquiv,
Submonoid.comap_map_eq_of_injective (h : R ≃* P).injective]) := rfl
end AlgEquivOfAlgEquiv
section smul
variable {R : Type*} [CommSemiring R] {S : Submonoid R}
variable {R' : Type*} [CommSemiring R'] [Algebra R R'] [IsLocalization S R']
variable {M' : Type*} [AddCommMonoid M'] [Module R' M'] [Module R M'] [IsScalarTower R R' M']
/-- If `x` in a `R' = S⁻¹ R`-module `M'`, then for a submodule `N'` of `M'`,
`s • x ∈ N'` if and only if `x ∈ N'` for some `s` in S. -/
lemma smul_mem_iff {N' : Submodule R' M'} {x : M'} {s : S} :
s • x ∈ N' ↔ x ∈ N' := by
refine ⟨fun h ↦ ?_, fun h ↦ Submodule.smul_of_tower_mem N' s h⟩
rwa [← Submodule.smul_mem_iff_of_isUnit (r := algebraMap R R' s) N' (map_units R' s),
algebraMap_smul]
end smul
section at_units
variable (R M)
/-- The localization at a module of units is isomorphic to the ring. -/
noncomputable def atUnits (H : M ≤ IsUnit.submonoid R) : R ≃ₐ[R] S := by
refine AlgEquiv.ofBijective (Algebra.ofId R S) ⟨?_, ?_⟩
· intro x y hxy
obtain ⟨c, eq⟩ := (IsLocalization.eq_iff_exists M S).mp hxy
obtain ⟨u, hu⟩ := H c.prop
rwa [← hu, Units.mul_right_inj] at eq
· intro y
obtain ⟨⟨x, s⟩, eq⟩ := IsLocalization.surj M y
obtain ⟨u, hu⟩ := H s.prop
use x * u.inv
dsimp [Algebra.ofId, RingHom.toFun_eq_coe, AlgHom.coe_mks]
rw [RingHom.map_mul, ← eq, ← hu, mul_assoc, ← RingHom.map_mul]
simp
end at_units
end IsLocalization
section
variable (M N)
theorem isLocalization_of_algEquiv [Algebra R P] [IsLocalization M S] (h : S ≃ₐ[R] P) :
IsLocalization M P := by
constructor
· intro y
convert (IsLocalization.map_units S y).map h.toAlgHom.toRingHom.toMonoidHom
exact (h.commutes y).symm
· intro y
obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj M (h.symm y)
apply_fun (show S → P from h) at e
simp only [map_mul, h.apply_symm_apply, h.commutes] at e
exact ⟨⟨x, s⟩, e⟩
· intro x y
rw [← h.symm.toEquiv.injective.eq_iff, ← IsLocalization.eq_iff_exists M S, ← h.symm.commutes, ←
h.symm.commutes]
exact id
variable {M} in
protected theorem self (H : M ≤ IsUnit.submonoid R) : IsLocalization M R :=
isLocalization_of_algEquiv _ (atUnits _ _ (S := Localization M) H).symm
theorem isLocalization_iff_of_algEquiv [Algebra R P] (h : S ≃ₐ[R] P) :
IsLocalization M S ↔ IsLocalization M P :=
⟨fun _ => isLocalization_of_algEquiv M h, fun _ => isLocalization_of_algEquiv M h.symm⟩
theorem isLocalization_iff_of_ringEquiv (h : S ≃+* P) :
IsLocalization M S ↔
haveI := (h.toRingHom.comp <| algebraMap R S).toAlgebra; IsLocalization M P :=
letI := (h.toRingHom.comp <| algebraMap R S).toAlgebra
isLocalization_iff_of_algEquiv M { h with commutes' := fun _ => rfl }
variable (S) in
/-- If an algebra is simultaneously localizations for two submonoids, then an arbitrary algebra
is a localization of one submonoid iff it is a localization of the other. -/
theorem isLocalization_iff_of_isLocalization [IsLocalization M S] [IsLocalization N S]
[Algebra R P] : IsLocalization M P ↔ IsLocalization N P :=
⟨fun _ ↦ isLocalization_of_algEquiv N (algEquiv M S P),
fun _ ↦ isLocalization_of_algEquiv M (algEquiv N S P)⟩
theorem iff_of_le_of_exists_dvd (N : Submonoid R) (h₁ : M ≤ N) (h₂ : ∀ n ∈ N, ∃ m ∈ M, n ∣ m) :
IsLocalization M S ↔ IsLocalization N S :=
have : IsLocalization N (Localization M) := of_le_of_exists_dvd _ _ h₁ h₂
isLocalization_iff_of_isLocalization _ _ (Localization M)
end
variable (M)
/-- If `S₁` is the localization of `R` at `M₁` and `S₂` is the localization of
`R` at `M₂`, then every localization `T` of `S₂` at `M₁` is also a localization of
`S₁` at `M₂`, in other words `M₁⁻¹M₂⁻¹R` can be identified with `M₂⁻¹M₁⁻¹R`. -/
lemma commutes (S₁ S₂ T : Type*) [CommSemiring S₁]
[CommSemiring S₂] [CommSemiring T] [Algebra R S₁] [Algebra R S₂] [Algebra R T] [Algebra S₁ T]
[Algebra S₂ T] [IsScalarTower R S₁ T] [IsScalarTower R S₂ T] (M₁ M₂ : Submonoid R)
[IsLocalization M₁ S₁] [IsLocalization M₂ S₂]
[IsLocalization (Algebra.algebraMapSubmonoid S₂ M₁) T] :
IsLocalization (Algebra.algebraMapSubmonoid S₁ M₂) T where
map_units := by
rintro ⟨m, ⟨a, ha, rfl⟩⟩
rw [← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R S₂ T]
exact IsUnit.map _ (IsLocalization.map_units _ ⟨a, ha⟩)
surj a := by
obtain ⟨⟨y, -, m, hm, rfl⟩, hy⟩ := surj (M := Algebra.algebraMapSubmonoid S₂ M₁) a
rw [← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R S₁ T] at hy
obtain ⟨⟨z, n, hn⟩, hz⟩ := IsLocalization.surj (M := M₂) y
have hunit : IsUnit (algebraMap R S₁ m) := map_units _ ⟨m, hm⟩
use ⟨algebraMap R S₁ z * hunit.unit⁻¹, ⟨algebraMap R S₁ n, n, hn, rfl⟩⟩
rw [map_mul, ← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R S₂ T]
conv_rhs => rw [← IsScalarTower.algebraMap_apply]
rw [IsScalarTower.algebraMap_apply R S₂ T, ← hz, map_mul, ← hy]
convert_to _ = a * (algebraMap S₂ T) ((algebraMap R S₂) n) *
(algebraMap S₁ T) (((algebraMap R S₁) m) * hunit.unit⁻¹.val)
· rw [map_mul]
ring
simp
exists_of_eq {x y} hxy := by
obtain ⟨r, s, d, hr, hs⟩ := IsLocalization.surj₂ M₁ S₁ x y
apply_fun (· * algebraMap S₁ T (algebraMap R S₁ d)) at hxy
simp_rw [← map_mul, hr, hs, ← IsScalarTower.algebraMap_apply,
IsScalarTower.algebraMap_apply R S₂ T] at hxy
obtain ⟨⟨-, c, hmc, rfl⟩, hc⟩ := exists_of_eq (M := Algebra.algebraMapSubmonoid S₂ M₁) hxy
simp_rw [← map_mul] at hc
obtain ⟨a, ha⟩ := IsLocalization.exists_of_eq (M := M₂) hc
use ⟨algebraMap R S₁ a, a, a.property, rfl⟩
apply (map_units S₁ d).mul_right_cancel
rw [mul_assoc, hr, mul_assoc, hs]
apply (map_units S₁ ⟨c, hmc⟩).mul_right_cancel
rw [← map_mul, ← map_mul, mul_assoc, mul_comm _ c, ha, map_mul, map_mul]
ring
variable (Rₘ Sₙ Rₘ' Sₙ' : Type*) [CommSemiring Rₘ] [CommSemiring Sₙ] [CommSemiring Rₘ']
[CommSemiring Sₙ'] [Algebra R Rₘ] [Algebra S Sₙ] [Algebra R Rₘ'] [Algebra S Sₙ'] [Algebra R Sₙ]
[Algebra Rₘ Sₙ] [Algebra Rₘ' Sₙ'] [Algebra R Sₙ'] (N : Submonoid S) [IsLocalization M Rₘ]
[IsLocalization N Sₙ] [IsLocalization M Rₘ'] [IsLocalization N Sₙ'] [IsScalarTower R Rₘ Sₙ]
[IsScalarTower R S Sₙ] [IsScalarTower R Rₘ' Sₙ'] [IsScalarTower R S Sₙ']
theorem algEquiv_comp_algebraMap : (algEquiv N Sₙ Sₙ' : _ →+* Sₙ').comp (algebraMap Rₘ Sₙ) =
(algebraMap Rₘ' Sₙ').comp (algEquiv M Rₘ Rₘ') := by
refine IsLocalization.ringHom_ext M (RingHom.ext fun x => ?_)
simp only [RingHom.coe_comp, RingHom.coe_coe, Function.comp_apply, AlgEquiv.commutes]
rw [← IsScalarTower.algebraMap_apply, ← IsScalarTower.algebraMap_apply,
← AlgEquiv.restrictScalars_apply R, AlgEquiv.commutes]
variable {Rₘ} in
theorem algEquiv_comp_algebraMap_apply (x : Rₘ) :
(algEquiv N Sₙ Sₙ' : _ →+* Sₙ').comp (algebraMap Rₘ Sₙ) x =
(algebraMap Rₘ' Sₙ').comp (algEquiv M Rₘ Rₘ') x := by
rw [algEquiv_comp_algebraMap M Rₘ Sₙ Rₘ']
end IsLocalization
namespace Localization
open IsLocalization
theorem mk_natCast (m : ℕ) : (mk m 1 : Localization M) = m := by
simpa using mk_algebraMap (R := R) (A := ℕ) _
variable [IsLocalization M S]
section
variable (S) (M)
/-- The localization of `R` at `M` as a quotient type is isomorphic to any other localization. -/
@[simps!]
noncomputable def algEquiv : Localization M ≃ₐ[R] S :=
IsLocalization.algEquiv M _ _
/-- The localization of a singleton is a singleton. Cannot be an instance due to metavariables. -/
noncomputable def _root_.IsLocalization.unique (R Rₘ) [CommSemiring R] [CommSemiring Rₘ]
(M : Submonoid R) [Subsingleton R] [Algebra R Rₘ] [IsLocalization M Rₘ] : Unique Rₘ :=
have : Inhabited Rₘ := ⟨1⟩
(algEquiv M Rₘ).symm.injective.unique
end
nonrec theorem algEquiv_mk' (x : R) (y : M) : algEquiv M S (mk' (Localization M) x y) = mk' S x y :=
algEquiv_mk' _ _
nonrec theorem algEquiv_symm_mk' (x : R) (y : M) :
(algEquiv M S).symm (mk' S x y) = mk' (Localization M) x y :=
algEquiv_symm_mk' _ _
theorem algEquiv_mk (x y) : algEquiv M S (mk x y) = mk' S x y := by rw [mk_eq_mk', algEquiv_mk']
theorem algEquiv_symm_mk (x : R) (y : M) : (algEquiv M S).symm (mk' S x y) = mk x y := by
rw [mk_eq_mk', algEquiv_symm_mk']
lemma coe_algEquiv :
(Localization.algEquiv M S : Localization M →+* S) =
IsLocalization.map (M := M) (T := M) _ (RingHom.id R) le_rfl := rfl
lemma coe_algEquiv_symm :
((Localization.algEquiv M S).symm : S →+* Localization M) =
IsLocalization.map (M := M) (T := M) _ (RingHom.id R) le_rfl := rfl
end Localization
open IsLocalization
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem IsField.localization_map_bijective {R Rₘ : Type*} [CommRing R] [CommRing Rₘ]
{M : Submonoid R} (hM : (0 : R) ∉ M) (hR : IsField R) [Algebra R Rₘ] [IsLocalization M Rₘ] :
Function.Bijective (algebraMap R Rₘ) := by
letI := hR.toField
replace hM := le_nonZeroDivisors_of_noZeroDivisors hM
refine ⟨IsLocalization.injective _ hM, fun x => ?_⟩
obtain ⟨r, ⟨m, hm⟩, rfl⟩ := exists_mk'_eq M x
obtain ⟨n, hn⟩ := hR.mul_inv_cancel (nonZeroDivisors.ne_zero <| hM hm)
exact ⟨r * n, by rw [eq_mk'_iff_mul_eq, ← map_mul, mul_assoc, _root_.mul_comm n, hn, mul_one]⟩
/-- If `R` is a field, then localizing at a submonoid not containing `0` adds no new elements. -/
theorem Field.localization_map_bijective {K Kₘ : Type*} [Field K] [CommRing Kₘ] {M : Submonoid K}
(hM : (0 : K) ∉ M) [Algebra K Kₘ] [IsLocalization M Kₘ] :
Function.Bijective (algebraMap K Kₘ) :=
(Field.toIsField K).localization_map_bijective hM
-- this looks weird due to the `letI` inside the above lemma, but trying to do it the other
-- way round causes issues with defeq of instances, so this is actually easier.
section Algebra
variable {Rₘ Sₘ : Type*} [CommSemiring Rₘ] [CommSemiring Sₘ]
variable [Algebra R Rₘ] [IsLocalization M Rₘ]
variable [Algebra S Sₘ] [i : IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ]
include S
section
variable (S M)
/-- Definition of the natural algebra induced by the localization of an algebra.
Given an algebra `R → S`, a submonoid `R` of `M`, and a localization `Rₘ` for `M`,
let `Sₘ` be the localization of `S` to the image of `M` under `algebraMap R S`.
Then this is the natural algebra structure on `Rₘ → Sₘ`, such that the entire square commutes,
where `localization_map.map_comp` gives the commutativity of the underlying maps.
This instance can be helpful if you define `Sₘ := Localization (Algebra.algebraMapSubmonoid S M)`,
however we will instead use the hypotheses `[Algebra Rₘ Sₘ] [IsScalarTower R Rₘ Sₘ]` in lemmas
since the algebra structure may arise in different ways.
-/
noncomputable def localizationAlgebra : Algebra Rₘ Sₘ :=
(map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :
Rₘ →+* Sₘ).toAlgebra
noncomputable instance : Algebra (Localization M)
(Localization (Algebra.algebraMapSubmonoid S M)) := localizationAlgebra M S
instance : IsScalarTower R (Localization M) (Localization (Algebra.algebraMapSubmonoid S M)) :=
IsScalarTower.of_algebraMap_eq (fun x ↦
(IsLocalization.map_eq (T := (Algebra.algebraMapSubmonoid S M)) M.le_comap_map x).symm)
end
section
variable [Algebra Rₘ Sₘ] [Algebra R Sₘ] [IsScalarTower R Rₘ Sₘ] [IsScalarTower R S Sₘ]
variable (S Rₘ Sₘ)
theorem IsLocalization.map_units_map_submonoid (y : M) : IsUnit (algebraMap R Sₘ y) := by
rw [IsScalarTower.algebraMap_apply _ S]
exact IsLocalization.map_units Sₘ ⟨algebraMap R S y, Algebra.mem_algebraMapSubmonoid_of_mem y⟩
-- can't be simp, as `S` only appears on the RHS
theorem IsLocalization.algebraMap_mk' (x : R) (y : M) :
algebraMap Rₘ Sₘ (IsLocalization.mk' Rₘ x y) =
IsLocalization.mk' Sₘ (algebraMap R S x)
⟨algebraMap R S y, Algebra.mem_algebraMapSubmonoid_of_mem y⟩ := by
rw [IsLocalization.eq_mk'_iff_mul_eq, Subtype.coe_mk, ← IsScalarTower.algebraMap_apply, ←
IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply R Rₘ Sₘ,
IsScalarTower.algebraMap_apply R Rₘ Sₘ, ← map_mul, mul_comm,
IsLocalization.mul_mk'_eq_mk'_of_mul]
exact congr_arg (algebraMap Rₘ Sₘ) (IsLocalization.mk'_mul_cancel_left x y)
variable (M)
/-- If the square below commutes, the bottom map is uniquely specified:
```
R → S
↓ ↓
Rₘ → Sₘ
```
-/
theorem IsLocalization.algebraMap_eq_map_map_submonoid :
algebraMap Rₘ Sₘ =
map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :=
Eq.symm <|
IsLocalization.map_unique _ (algebraMap Rₘ Sₘ) fun x => by
rw [← IsScalarTower.algebraMap_apply R S Sₘ, ← IsScalarTower.algebraMap_apply R Rₘ Sₘ]
/-- If the square below commutes, the bottom map is uniquely specified:
```
R → S
↓ ↓
Rₘ → Sₘ
```
-/
theorem IsLocalization.algebraMap_apply_eq_map_map_submonoid (x) :
algebraMap Rₘ Sₘ x =
map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) x :=
DFunLike.congr_fun (IsLocalization.algebraMap_eq_map_map_submonoid _ _ _ _) x
theorem IsLocalization.lift_algebraMap_eq_algebraMap :
IsLocalization.lift (M := M) (IsLocalization.map_units_map_submonoid S Sₘ) =
algebraMap Rₘ Sₘ :=
IsLocalization.lift_unique _ fun _ => (IsScalarTower.algebraMap_apply _ _ _ _).symm
end
variable (Rₘ Sₘ)
theorem localizationAlgebraMap_def :
@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S) =
map Sₘ (algebraMap R S)
(show _ ≤ (Algebra.algebraMapSubmonoid S M).comap _ from M.le_comap_map) :=
rfl
/-- Injectivity of the underlying `algebraMap` descends to the algebra induced by localization. -/
theorem localizationAlgebra_injective (hRS : Function.Injective (algebraMap R S)) :
Function.Injective (@algebraMap Rₘ Sₘ _ _ (localizationAlgebra M S)) :=
have : IsLocalization (M.map (algebraMap R S)) Sₘ := i
IsLocalization.map_injective_of_injective _ _ _ hRS
instance : IsLocalization (Algebra.algebraMapSubmonoid R M) Rₘ := by
simpa
end Algebra
end CommSemiring
section CommRing
variable {R : Type*} [CommRing R] {M : Submonoid R} (S : Type*) [CommRing S]
namespace IsLocalization
variable (M) in
/--
Another version of `IsLocalization.map_injective_of_injective` that is more general for the choice
of the localization submonoid but requires it does not contain zero.
-/
theorem map_injective_of_injective' {f : R →+* S} {Rₘ : Type*} [CommRing Rₘ] [Algebra R Rₘ]
[IsLocalization M Rₘ] (Sₘ : Type*) {N : Submonoid S} [CommRing Sₘ] [Algebra S Sₘ]
[IsLocalization N Sₘ] (hf : M ≤ Submonoid.comap f N) (hN : 0 ∉ N) [IsDomain S]
(hf' : Function.Injective f) :
Function.Injective (map Sₘ f hf : Rₘ →+* Sₘ) := by
refine (injective_iff_map_eq_zero (map Sₘ f hf)).mpr fun x h ↦ ?_
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M x
aesop (add simp [map_mk', mk'_eq_zero_iff])
end IsLocalization
theorem Localization.mk_intCast (m : ℤ) : (mk m 1 : Localization M) = m := by
simpa using mk_algebraMap (R := R) (A := ℤ) _
end CommRing
section Algebra
-- This is not tagged with `@[ext]` because `A` and `W` cannot be inferred.
theorem IsLocalization.algHom_ext {R A L B : Type*}
[CommSemiring R] [CommSemiring A] [CommSemiring L] [Semiring B]
(W : Submonoid A) [Algebra A L] [IsLocalization W L]
[Algebra R A] [Algebra R L] [IsScalarTower R A L] [Algebra R B]
{f g : L →ₐ[R] B} (h : f.comp (Algebra.algHom R A L) = g.comp (Algebra.algHom R A L)) :
f = g :=
AlgHom.coe_ringHom_injective <| IsLocalization.ringHom_ext W <| RingHom.ext <| AlgHom.ext_iff.mp h
-- This is a more specific case where the domain is `Localization W`, so this is tagged
-- `@[ext high]` so that it will be automatically applied before the default extensionality lemmas
-- which compare every element.
@[ext high] theorem Localization.algHom_ext {R A B : Type*}
[CommSemiring R] [CommSemiring A] [Semiring B] [Algebra R A] [Algebra R B] (W : Submonoid A)
{f g : Localization W →ₐ[R] B}
(h : f.comp (Algebra.algHom R A _) = g.comp (Algebra.algHom R A _)) :
f = g :=
IsLocalization.algHom_ext W h
end Algebra |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Cardinality.lean | import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.GroupTheory.MonoidLocalization.Cardinality
import Mathlib.RingTheory.OreLocalization.Cardinality
/-!
# Cardinality of localizations
In this file, we establish the cardinality of localizations. In most cases, a localization has
cardinality equal to the base ring. If there are zero-divisors, however, this is no longer true -
for example, `ZMod 6` localized at `{2, 4}` is equal to `ZMod 3`, and if you have zero in your
submonoid, then your localization is trivial (see `IsLocalization.uniqueOfZeroMem`).
## Main statements
* `IsLocalization.cardinalMk_le`: A localization has cardinality no larger than the base ring.
* `IsLocalization.cardinalMk`: If you don't localize at zero-divisors, the localization of a ring
has cardinality equal to its base ring.
-/
open Cardinal nonZeroDivisors
universe u v
section CommSemiring
variable {R : Type u} [CommSemiring R] {L : Type v} [CommSemiring L] [Algebra R L]
namespace IsLocalization
theorem lift_cardinalMk_le (S : Submonoid R) [IsLocalization S L] :
Cardinal.lift.{u} #L ≤ Cardinal.lift.{v} #R := by
have := Localization.cardinalMk_le S
rwa [← lift_le.{v}, lift_mk_eq'.2 ⟨(Localization.algEquiv S L).toEquiv⟩] at this
/-- A localization always has cardinality less than or equal to the base ring. -/
theorem cardinalMk_le {L : Type u} [CommSemiring L] [Algebra R L]
(S : Submonoid R) [IsLocalization S L] : #L ≤ #R := by
simpa using lift_cardinalMk_le (L := L) S
end IsLocalization
end CommSemiring
section CommRing
variable {R : Type u} [CommRing R] {L : Type v} [CommRing L] [Algebra R L]
namespace Localization
theorem cardinalMk {S : Submonoid R} (hS : S ≤ R⁰) : #(Localization S) = #R := by
apply OreLocalization.cardinalMk
rwa [nonZeroDivisorsLeft_eq_nonZeroDivisors]
end Localization
namespace IsLocalization
variable (L)
theorem lift_cardinalMk (S : Submonoid R) [IsLocalization S L] (hS : S ≤ R⁰) :
Cardinal.lift.{u} #L = Cardinal.lift.{v} #R := by
have := Localization.cardinalMk hS
rwa [← lift_inj.{u, v}, lift_mk_eq'.2 ⟨(Localization.algEquiv S L).toEquiv⟩] at this
/-- If you do not localize at any zero-divisors, localization preserves cardinality. -/
theorem cardinalMk (L : Type u) [CommRing L] [Algebra R L]
(S : Submonoid R) [IsLocalization S L] (hS : S ≤ R⁰) : #L = #R := by
simpa using lift_cardinalMk L S hS
end IsLocalization
@[simp]
theorem Cardinal.mk_fractionRing (R : Type u) [CommRing R] : #(FractionRing R) = #R :=
IsLocalization.cardinalMk (FractionRing R) R⁰ le_rfl
alias FractionRing.cardinalMk := Cardinal.mk_fractionRing
namespace IsFractionRing
variable (R L)
theorem lift_cardinalMk [IsFractionRing R L] : Cardinal.lift.{u} #L = Cardinal.lift.{v} #R :=
IsLocalization.lift_cardinalMk L _ le_rfl
theorem cardinalMk (L : Type u) [CommRing L] [Algebra R L] [IsFractionRing R L] : #L = #R :=
IsLocalization.cardinalMk L _ le_rfl
end IsFractionRing
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Ideal.lean | import Mathlib.GroupTheory.MonoidLocalization.Away
import Mathlib.RingTheory.Ideal.Quotient.Operations
import Mathlib.RingTheory.Localization.Defs
import Mathlib.RingTheory.Spectrum.Prime.Defs
import Mathlib.Algebra.Algebra.Tower
/-!
# Ideals in localizations of commutative rings
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
namespace IsLocalization
section CommSemiring
variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S]
variable [Algebra R S] [IsLocalization M S]
variable {M S} in
theorem mk'_mem_iff {x} {y : M} {I : Ideal S} : mk' S x y ∈ I ↔ algebraMap R S x ∈ I := by
constructor <;> intro h
· rw [← mk'_spec S x y, mul_comm]
exact I.mul_mem_left ((algebraMap R S) y) h
· rw [← mk'_spec S x y] at h
obtain ⟨b, hb⟩ := isUnit_iff_exists_inv.1 (map_units S y)
have := I.mul_mem_left b h
rwa [mul_comm, mul_assoc, hb, mul_one] at this
/-- Explicit characterization of the ideal given by `Ideal.map (algebraMap R S) I`.
In practice, this ideal differs only in that the carrier set is defined explicitly.
This definition is only meant to be used in proving `mem_map_algebraMap_iff`,
and any proof that needs to refer to the explicit carrier set should use that theorem. -/
-- TODO: golf this using `Submodule.localized'`
private def map_ideal (I : Ideal R) : Ideal S where
carrier := { z : S | ∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 }
zero_mem' := ⟨⟨0, 1⟩, by simp⟩
add_mem' := by
rintro a b ⟨a', ha⟩ ⟨b', hb⟩
let Z : { x // x ∈ I } := ⟨(a'.2 : R) * (b'.1 : R) + (b'.2 : R) * (a'.1 : R),
I.add_mem (I.mul_mem_left _ b'.1.2) (I.mul_mem_left _ a'.1.2)⟩
use ⟨Z, a'.2 * b'.2⟩
simp only [Z, RingHom.map_add, Submonoid.coe_mul, RingHom.map_mul]
rw [add_mul, ← mul_assoc a, ha, mul_comm (algebraMap R S a'.2) (algebraMap R S b'.2), ←
mul_assoc b, hb]
ring
smul_mem' := by
rintro c x ⟨x', hx⟩
obtain ⟨c', hc⟩ := IsLocalization.surj M c
let Z : { x // x ∈ I } := ⟨c'.1 * x'.1, I.mul_mem_left c'.1 x'.1.2⟩
use ⟨Z, c'.2 * x'.2⟩
simp only [Z, ← hx, ← hc, smul_eq_mul, Submonoid.coe_mul, RingHom.map_mul]
ring
theorem mem_map_algebraMap_iff {I : Ideal R} {z} : z ∈ Ideal.map (algebraMap R S) I ↔
∃ x : I × M, z * algebraMap R S x.2 = algebraMap R S x.1 := by
constructor
· change _ → z ∈ map_ideal M S I
refine fun h => Ideal.mem_sInf.1 h fun z hz => ?_
obtain ⟨y, hy⟩ := hz
let Z : { x // x ∈ I } := ⟨y, hy.left⟩
use ⟨Z, 1⟩
simp [Z, hy.right]
· rintro ⟨⟨a, s⟩, h⟩
rw [← Ideal.unit_mul_mem_iff_mem _ (map_units S s), mul_comm]
exact h.symm ▸ Ideal.mem_map_of_mem _ a.2
lemma mk'_mem_map_algebraMap_iff (I : Ideal R) (x : R) (s : M) :
IsLocalization.mk' S x s ∈ I.map (algebraMap R S) ↔ ∃ s ∈ M, s * x ∈ I := by
rw [← Ideal.unit_mul_mem_iff_mem _ (IsLocalization.map_units S s), IsLocalization.mk'_spec',
IsLocalization.mem_map_algebraMap_iff M]
simp_rw [← map_mul, IsLocalization.eq_iff_exists M, mul_comm x, ← mul_assoc, ← Submonoid.coe_mul]
exact ⟨fun ⟨⟨y, t⟩, c, h⟩ ↦ ⟨_, (c * t).2, h ▸ I.mul_mem_left c.1 y.2⟩, fun ⟨s, hs, h⟩ ↦
⟨⟨⟨_, h⟩, ⟨s, hs⟩⟩, 1, by simp⟩⟩
lemma algebraMap_mem_map_algebraMap_iff (I : Ideal R) (x : R) :
algebraMap R S x ∈ I.map (algebraMap R S) ↔
∃ m ∈ M, m * x ∈ I := by
rw [← IsLocalization.mk'_one (M := M), mk'_mem_map_algebraMap_iff]
lemma map_algebraMap_ne_top_iff_disjoint (I : Ideal R) :
I.map (algebraMap R S) ≠ ⊤ ↔ Disjoint (M : Set R) (I : Set R) := by
simp only [ne_eq, Ideal.eq_top_iff_one, ← map_one (algebraMap R S), not_iff_comm,
IsLocalization.algebraMap_mem_map_algebraMap_iff M]
simp [Set.disjoint_left]
include M in
theorem map_comap (J : Ideal S) :
Ideal.map (algebraMap R S) (Ideal.comap (algebraMap R S) J) = J :=
le_antisymm (Ideal.map_le_iff_le_comap.2 le_rfl) fun x hJ => by
obtain ⟨r, s, hx⟩ := exists_mk'_eq M x
rw [← hx] at hJ ⊢
exact
Ideal.mul_mem_right _ _
(Ideal.mem_map_of_mem _
(show (algebraMap R S) r ∈ J from
mk'_spec S r s ▸ J.mul_mem_right ((algebraMap R S) s) hJ))
theorem comap_map_of_isPrime_disjoint (I : Ideal R) (hI : I.IsPrime) (hM : Disjoint (M : Set R) I) :
Ideal.comap (algebraMap R S) (Ideal.map (algebraMap R S) I) = I := by
refine le_antisymm ?_ Ideal.le_comap_map
refine (fun a ha => ?_)
obtain ⟨⟨b, s⟩, h⟩ := (mem_map_algebraMap_iff M S).1 (Ideal.mem_comap.1 ha)
replace h : algebraMap R S (s * a) = algebraMap R S b := by
simpa only [← map_mul, mul_comm] using h
obtain ⟨c, hc⟩ := (eq_iff_exists M S).1 h
have : ↑c * ↑s * a ∈ I := by
rw [mul_assoc, hc]
exact I.mul_mem_left c b.2
exact (hI.mem_or_mem this).resolve_left fun hsc => hM.le_bot ⟨(c * s).2, hsc⟩
/-- If `S` is the localization of `R` at a submonoid, the ordering of ideals of `S` is
embedded in the ordering of ideals of `R`. -/
def orderEmbedding : Ideal S ↪o Ideal R where
toFun J := Ideal.comap (algebraMap R S) J
inj' := Function.LeftInverse.injective (map_comap M S)
map_rel_iff' := by
rintro J₁ J₂
constructor
· exact fun hJ => (map_comap M S) J₁ ▸ (map_comap M S) J₂ ▸ Ideal.map_mono hJ
· exact fun hJ => Ideal.comap_mono hJ
/-- If `R` is a ring, then prime ideals in the localization at `M`
correspond to prime ideals in the original ring `R` that are disjoint from `M`.
This lemma gives the particular case for an ideal and its comap,
see `le_rel_iso_of_prime` for the more general relation isomorphism -/
theorem isPrime_iff_isPrime_disjoint (J : Ideal S) :
J.IsPrime ↔
(Ideal.comap (algebraMap R S) J).IsPrime ∧
Disjoint (M : Set R) ↑(Ideal.comap (algebraMap R S) J) := by
constructor
· refine fun h =>
⟨⟨?_, ?_⟩,
Set.disjoint_left.mpr fun m hm1 hm2 =>
h.ne_top (Ideal.eq_top_of_isUnit_mem _ hm2 (map_units S ⟨m, hm1⟩))⟩
· refine fun hJ => h.ne_top ?_
rw [eq_top_iff, ← (orderEmbedding M S).le_iff_le]
exact le_of_eq hJ.symm
· intro x y hxy
rw [Ideal.mem_comap, RingHom.map_mul] at hxy
exact h.mem_or_mem hxy
· refine fun h => ⟨fun hJ => h.left.ne_top (eq_top_iff.2 ?_), ?_⟩
· rwa [eq_top_iff, ← (orderEmbedding M S).le_iff_le] at hJ
· intro x y hxy
obtain ⟨a, s, ha⟩ := exists_mk'_eq M x
obtain ⟨b, t, hb⟩ := exists_mk'_eq M y
have : mk' S (a * b) (s * t) ∈ J := by rwa [mk'_mul, ha, hb]
rw [mk'_mem_iff, ← Ideal.mem_comap] at this
have this₂ := (h.1).mul_mem_iff_mem_or_mem.1 this
rw [Ideal.mem_comap, Ideal.mem_comap] at this₂
rwa [← ha, ← hb, mk'_mem_iff, mk'_mem_iff]
/-- If `R` is a ring, then prime ideals in the localization at `M`
correspond to prime ideals in the original ring `R` that are disjoint from `M`.
This lemma gives the particular case for an ideal and its map,
see `le_rel_iso_of_prime` for the more general relation isomorphism, and the reverse implication -/
theorem isPrime_of_isPrime_disjoint (I : Ideal R) (hp : I.IsPrime) (hd : Disjoint (M : Set R) ↑I) :
(Ideal.map (algebraMap R S) I).IsPrime := by
rw [isPrime_iff_isPrime_disjoint M S, comap_map_of_isPrime_disjoint M S I hp hd]
exact ⟨hp, hd⟩
theorem disjoint_comap_iff (J : Ideal S) :
Disjoint (M : Set R) (J.comap (algebraMap R S)) ↔ J ≠ ⊤ := by
rw [← iff_not_comm, Set.not_disjoint_iff]
constructor
· rintro rfl
exact ⟨1, M.one_mem, ⟨⟩⟩
· rintro ⟨x, hxM, hxJ⟩
exact J.eq_top_of_isUnit_mem hxJ (IsLocalization.map_units S ⟨x, hxM⟩)
/-- If `R` is a ring, then prime ideals in the localization at `M`
correspond to prime ideals in the original ring `R` that are disjoint from `M` -/
@[simps] def orderIsoOfPrime :
{ p : Ideal S // p.IsPrime } ≃o { p : Ideal R // p.IsPrime ∧ Disjoint (M : Set R) ↑p } where
toFun p := ⟨Ideal.comap (algebraMap R S) p.1, (isPrime_iff_isPrime_disjoint M S p.1).1 p.2⟩
invFun p := ⟨Ideal.map (algebraMap R S) p.1, isPrime_of_isPrime_disjoint M S p.1 p.2.1 p.2.2⟩
left_inv J := Subtype.eq (map_comap M S J)
right_inv I := Subtype.eq (comap_map_of_isPrime_disjoint M S I.1 I.2.1 I.2.2)
map_rel_iff' {I I'} := by
constructor
· exact fun h => show I.val ≤ I'.val from map_comap M S I.val ▸
map_comap M S I'.val ▸ Ideal.map_mono h
exact fun h x hx => h hx
/-- The prime spectrum of the localization of a ring at a submonoid `M` are in
order-preserving bijection with subset of the prime spectrum of the ring consisting of
prime ideals disjoint from `M`. -/
@[simps!] def primeSpectrumOrderIso :
PrimeSpectrum S ≃o {p : PrimeSpectrum R // Disjoint (M : Set R) p.asIdeal} :=
(PrimeSpectrum.equivSubtype S).trans <| (orderIsoOfPrime M S).trans
⟨⟨fun p ↦ ⟨⟨p, p.2.1⟩, p.2.2⟩, fun p ↦ ⟨p.1.1, p.1.2, p.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩, .rfl⟩
include M in
lemma map_radical (I : Ideal R) :
I.radical.map (algebraMap R S) = (I.map (algebraMap R S)).radical := by
refine (I.map_radical_le (algebraMap R S)).antisymm ?_
rintro x ⟨n, hn⟩
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M x
simp only [← IsLocalization.mk'_pow, IsLocalization.mk'_mem_map_algebraMap_iff M] at hn ⊢
obtain ⟨s, hs, h⟩ := hn
refine ⟨s, hs, n + 1, by convert I.mul_mem_left (s ^ n * x) h; ring⟩
theorem ideal_eq_iInf_comap_map_away {S : Finset R} (hS : Ideal.span (α := R) S = ⊤) (I : Ideal R) :
I = ⨅ f ∈ S, (I.map (algebraMap R (Localization.Away f))).comap
(algebraMap R (Localization.Away f)) := by
apply le_antisymm
· simp only [le_iInf₂_iff, ← Ideal.map_le_iff_le_comap, le_refl, implies_true]
· intro x hx
apply Submodule.mem_of_span_eq_top_of_smul_pow_mem _ _ hS
rintro ⟨s, hs⟩
simp only [Ideal.mem_iInf, Ideal.mem_comap] at hx
obtain ⟨⟨y, ⟨_, n, rfl⟩⟩, e⟩ :=
(IsLocalization.mem_map_algebraMap_iff (.powers s) _).mp (hx s hs)
dsimp only at e
rw [← map_mul, IsLocalization.eq_iff_exists (.powers s)] at e
obtain ⟨⟨_, m, rfl⟩, e⟩ := e
use m + n
dsimp at e ⊢
rw [pow_add, mul_assoc, ← mul_comm x, e]
exact I.mul_mem_left _ y.2
end CommSemiring
section CommRing
variable {R : Type*} [CommRing R] (M : Submonoid R) (S : Type*) [CommRing S]
variable [Algebra R S] [IsLocalization M S]
include M in
/-- `quotientMap` applied to maximal ideals of a localization is `surjective`.
The quotient by a maximal ideal is a field, so inverses to elements already exist,
and the localization necessarily maps the equivalence class of the inverse in the localization -/
theorem surjective_quotientMap_of_maximal_of_localization {I : Ideal S} [I.IsPrime] {J : Ideal R}
{H : J ≤ I.comap (algebraMap R S)} (hI : (I.comap (algebraMap R S)).IsMaximal) :
Function.Surjective (Ideal.quotientMap I (algebraMap R S) H) := by
intro s
obtain ⟨s, rfl⟩ := Ideal.Quotient.mk_surjective s
obtain ⟨r, ⟨m, hm⟩, rfl⟩ := exists_mk'_eq M s
by_cases hM : (Ideal.Quotient.mk (I.comap (algebraMap R S))) m = 0
· have : I = ⊤ := by
rw [Ideal.eq_top_iff_one]
rw [Ideal.Quotient.eq_zero_iff_mem, Ideal.mem_comap] at hM
convert I.mul_mem_right (mk' S (1 : R) ⟨m, hm⟩) hM
rw [← mk'_eq_mul_mk'_one, mk'_self]
exact ⟨0, eq_comm.1 (by simp [Ideal.Quotient.eq_zero_iff_mem, this])⟩
· rw [Ideal.Quotient.maximal_ideal_iff_isField_quotient] at hI
obtain ⟨n, hn⟩ := hI.3 hM
obtain ⟨rn, rfl⟩ := Ideal.Quotient.mk_surjective n
refine ⟨(Ideal.Quotient.mk J) (r * rn), ?_⟩
-- The rest of the proof is essentially just algebraic manipulations to prove the equality
replace hn := congr_arg (Ideal.quotientMap I (algebraMap R S) le_rfl) hn
rw [RingHom.map_one, RingHom.map_mul] at hn
rw [Ideal.quotientMap_mk, ← sub_eq_zero, ← RingHom.map_sub, Ideal.Quotient.eq_zero_iff_mem, ←
Ideal.Quotient.eq_zero_iff_mem, RingHom.map_sub, sub_eq_zero, mk'_eq_mul_mk'_one]
simp only [mul_eq_mul_left_iff, RingHom.map_mul]
refine
Or.inl
(mul_left_cancel₀ (M₀ := S ⧸ I)
(fun hn =>
hM
(Ideal.Quotient.eq_zero_iff_mem.2
(Ideal.mem_comap.2 (Ideal.Quotient.eq_zero_iff_mem.1 hn))))
(_root_.trans hn ?_))
rw [← map_mul, ← mk'_eq_mul_mk'_one, mk'_self, RingHom.map_one]
open nonZeroDivisors
theorem bot_lt_comap_prime [IsDomain R] (hM : M ≤ R⁰) (p : Ideal S) [hpp : p.IsPrime]
(hp0 : p ≠ ⊥) : ⊥ < Ideal.comap (algebraMap R S) p := by
haveI : IsDomain S := isDomain_of_le_nonZeroDivisors _ hM
rw [← Ideal.comap_bot_of_injective (algebraMap R S) (IsLocalization.injective _ hM)]
convert (orderIsoOfPrime M S).lt_iff_lt.mpr (show (⟨⊥, Ideal.bot_prime⟩ :
{ p : Ideal S // p.IsPrime }) < ⟨p, hpp⟩ from hp0.bot_lt)
variable (R) in
lemma _root_.NoZeroSMulDivisors_of_isLocalization (Rₚ Sₚ : Type*) [CommRing Rₚ] [CommRing Sₚ]
[Algebra R Rₚ] [Algebra R Sₚ] [Algebra S Sₚ] [Algebra Rₚ Sₚ] [IsScalarTower R S Sₚ]
[IsScalarTower R Rₚ Sₚ] {M : Submonoid R} (hM : M ≤ R⁰) [IsLocalization M Rₚ]
[IsLocalization (Algebra.algebraMapSubmonoid S M) Sₚ] [NoZeroSMulDivisors R S] [IsDomain S] :
NoZeroSMulDivisors Rₚ Sₚ := by
have e : Algebra.algebraMapSubmonoid S M ≤ S⁰ :=
Submonoid.map_le_of_le_comap _ <| hM.trans
(nonZeroDivisors_le_comap_nonZeroDivisors_of_injective _
(FaithfulSMul.algebraMap_injective _ _))
have : IsDomain Sₚ := IsLocalization.isDomain_of_le_nonZeroDivisors _ e
have : algebraMap Rₚ Sₚ = IsLocalization.map (T := Algebra.algebraMapSubmonoid S M) Sₚ
(algebraMap R S) (Submonoid.le_comap_map M) := by
apply IsLocalization.ringHom_ext M
simp only [IsLocalization.map_comp, ← IsScalarTower.algebraMap_eq]
rw [NoZeroSMulDivisors.iff_algebraMap_injective, RingHom.injective_iff_ker_eq_bot,
RingHom.ker_eq_bot_iff_eq_zero]
intro x hx
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M x
simp only [IsLocalization.map_mk', IsLocalization.mk'_eq_zero_iff,
Subtype.exists, exists_prop, this] at hx ⊢
obtain ⟨_, ⟨a, ha, rfl⟩, H⟩ := hx
simp only [← map_mul,
(injective_iff_map_eq_zero' _).mp (FaithfulSMul.algebraMap_injective R S)] at H
exact ⟨a, ha, H⟩
lemma of_surjective {R' S' : Type*} [CommRing R'] [CommRing S'] [Algebra R' S']
(f : R →+* R') (hf : Function.Surjective f) (g : S →+* S') (hg : Function.Surjective g)
(H : g.comp (algebraMap R S) = (algebraMap _ _).comp f)
(H' : RingHom.ker g ≤ (RingHom.ker f).map (algebraMap R S)) : IsLocalization (M.map f) S' where
map_units := by
rintro ⟨_, y, hy, rfl⟩
simpa only [← RingHom.comp_apply, H] using (IsLocalization.map_units S ⟨y, hy⟩).map g
surj := by
intro z
obtain ⟨z, rfl⟩ := hg z
obtain ⟨⟨r, s⟩, e⟩ := IsLocalization.surj M z
refine ⟨⟨f r, _, s.1, s.2, rfl⟩, ?_⟩
simpa only [map_mul, ← RingHom.comp_apply, H] using DFunLike.congr_arg g e
exists_of_eq := by
intro x y e
obtain ⟨x, rfl⟩ := hf x
obtain ⟨y, rfl⟩ := hf y
rw [← sub_eq_zero, ← map_sub, ← map_sub, ← RingHom.comp_apply, ← H, RingHom.comp_apply,
← IsLocalization.mk'_one (M := M)] at e
obtain ⟨r, hr, hr'⟩ := (IsLocalization.mk'_mem_map_algebraMap_iff M _ _ _ _).mp (H' e)
exact ⟨⟨_, r, hr, rfl⟩, by simpa [sub_eq_zero, mul_sub] using hr'⟩
open Algebra in
instance {P : Ideal R} [P.IsPrime] [IsDomain R] [IsDomain S] [FaithfulSMul R S] :
IsDomain (Localization (algebraMapSubmonoid S P.primeCompl)) :=
isDomain_localization (map_le_nonZeroDivisors_of_injective _
(FaithfulSMul.algebraMap_injective R S) P.primeCompl_le_nonZeroDivisors)
end CommRing
end IsLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/NormTrace.lean | import Mathlib.RingTheory.Localization.Module
import Mathlib.RingTheory.Norm.Basic
import Mathlib.RingTheory.Discriminant
/-!
# Field/algebra norm / trace and localization
This file contains results on the combination of `IsLocalization` and `Algebra.norm`,
`Algebra.trace` and `Algebra.discr`.
## Main results
* `Algebra.norm_localization`: let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M`
of `R S` respectively. Then the norm of `a : Sₘ` over `Rₘ` is the norm of `a : S` over `R`
if `S` is free as `R`-module.
* `Algebra.trace_localization`: let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M`
of `R S` respectively. Then the trace of `a : Sₘ` over `Rₘ` is the trace of `a : S` over `R`
if `S` is free as `R`-module.
* `Algebra.discr_localizationLocalization`: let `S` be an extension of `R` and `Rₘ Sₘ` be
localizations at `M` of `R S` respectively. Let `b` be a `R`-basis of `S`. Then discriminant of
the `Rₘ`-basis of `Sₘ` induced by `b` is the discriminant of `b`.
## Tags
field norm, algebra norm, localization
-/
open Module
open scoped nonZeroDivisors
variable (R : Type*) {S : Type*} [CommRing R] [CommRing S] [Algebra R S]
variable {Rₘ Sₘ : Type*} [CommRing Rₘ] [Algebra R Rₘ] [CommRing Sₘ] [Algebra S Sₘ]
variable (M : Submonoid R)
variable [IsLocalization M Rₘ] [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ]
variable [Algebra Rₘ Sₘ] [Algebra R Sₘ] [IsScalarTower R Rₘ Sₘ] [IsScalarTower R S Sₘ]
include M
open Algebra
theorem Algebra.map_leftMulMatrix_localization {ι : Type*} [Fintype ι] [DecidableEq ι]
(b : Basis ι R S) (a : S) :
(algebraMap R Rₘ).mapMatrix (leftMulMatrix b a) =
leftMulMatrix (b.localizationLocalization Rₘ M Sₘ) (algebraMap S Sₘ a) := by
ext i j
simp only [Matrix.map_apply, RingHom.mapMatrix_apply, leftMulMatrix_eq_repr_mul, ← map_mul,
Basis.localizationLocalization_apply, Basis.localizationLocalization_repr_algebraMap]
/-- Let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively.
Then the norm of `a : Sₘ` over `Rₘ` is the norm of `a : S` over `R` if `S` is free as `R`-module.
-/
theorem Algebra.norm_localization [Module.Free R S] [Module.Finite R S] (a : S) :
Algebra.norm Rₘ (algebraMap S Sₘ a) = algebraMap R Rₘ (Algebra.norm R a) := by
cases subsingleton_or_nontrivial R
· haveI : Subsingleton Rₘ := Module.subsingleton R Rₘ
simp [eq_iff_true_of_subsingleton]
let b := Module.Free.chooseBasis R S
letI := Classical.decEq (Module.Free.ChooseBasisIndex R S)
rw [Algebra.norm_eq_matrix_det (b.localizationLocalization Rₘ M Sₘ),
Algebra.norm_eq_matrix_det b, RingHom.map_det, ← Algebra.map_leftMulMatrix_localization]
variable {M} in
/-- The norm of `a : S` in `R` can be computed in `Sₘ`. -/
lemma Algebra.norm_eq_iff [Module.Free R S] [Module.Finite R S] {a : S} {b : R}
(hM : M ≤ nonZeroDivisors R) : Algebra.norm R a = b ↔
(Algebra.norm Rₘ) ((algebraMap S Sₘ) a) = algebraMap R Rₘ b :=
⟨fun h ↦ h.symm ▸ Algebra.norm_localization _ M _, fun h ↦
IsLocalization.injective Rₘ hM <| h.symm ▸ (Algebra.norm_localization R M a).symm⟩
/-- Let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively.
Then the trace of `a : Sₘ` over `Rₘ` is the trace of `a : S` over `R` if `S` is free as `R`-module.
-/
theorem Algebra.trace_localization [Module.Free R S] [Module.Finite R S] (a : S) :
Algebra.trace Rₘ Sₘ (algebraMap S Sₘ a) = algebraMap R Rₘ (Algebra.trace R S a) := by
cases subsingleton_or_nontrivial R
· haveI : Subsingleton Rₘ := Module.subsingleton R Rₘ
simp [eq_iff_true_of_subsingleton]
let b := Module.Free.chooseBasis R S
letI := Classical.decEq (Module.Free.ChooseBasisIndex R S)
rw [Algebra.trace_eq_matrix_trace (b.localizationLocalization Rₘ M Sₘ),
Algebra.trace_eq_matrix_trace b, ← Algebra.map_leftMulMatrix_localization]
exact (AddMonoidHom.map_trace (algebraMap R Rₘ).toAddMonoidHom _).symm
section LocalizationLocalization
variable (Sₘ : Type*) [CommRing Sₘ] [Algebra S Sₘ] [Algebra Rₘ Sₘ] [Algebra R Sₘ]
variable [IsScalarTower R Rₘ Sₘ] [IsScalarTower R S Sₘ]
variable [IsLocalization (Algebra.algebraMapSubmonoid S M) Sₘ]
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
theorem Algebra.traceMatrix_localizationLocalization (b : Basis ι R S) :
Algebra.traceMatrix Rₘ (b.localizationLocalization Rₘ M Sₘ) =
(algebraMap R Rₘ).mapMatrix (Algebra.traceMatrix R b) := by
have : Module.Finite R S := Module.Finite.of_basis b
have : Module.Free R S := Module.Free.of_basis b
ext i j : 2
simp_rw [RingHom.mapMatrix_apply, Matrix.map_apply, traceMatrix_apply, traceForm_apply,
Basis.localizationLocalization_apply, ← map_mul]
exact Algebra.trace_localization R M _
/-- Let `S` be an extension of `R` and `Rₘ Sₘ` be localizations at `M` of `R S` respectively. Let
`b` be a `R`-basis of `S`. Then discriminant of the `Rₘ`-basis of `Sₘ` induced by `b` is the
discriminant of `b`.
-/
theorem Algebra.discr_localizationLocalization (b : Basis ι R S) :
Algebra.discr Rₘ (b.localizationLocalization Rₘ M Sₘ) =
algebraMap R Rₘ (Algebra.discr R b) := by
rw [Algebra.discr_def, Algebra.discr_def, RingHom.map_det,
Algebra.traceMatrix_localizationLocalization]
end LocalizationLocalization |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Defs.lean | import Mathlib.Algebra.BigOperators.Group.Finset.Defs
import Mathlib.Algebra.Regular.Basic
import Mathlib.Algebra.Ring.NonZeroDivisors
import Mathlib.Data.Fintype.Prod
import Mathlib.GroupTheory.MonoidLocalization.MonoidWithZero
import Mathlib.RingTheory.OreLocalization.Ring
import Mathlib.Tactic.ApplyFun
import Mathlib.Tactic.Ring
/-!
# Localizations of commutative rings
We characterize the localization of a commutative ring `R` at a submonoid `M` up to
isomorphism; that is, a commutative ring `S` is the localization of `R` at `M` iff we can find a
ring homomorphism `f : R →+* S` satisfying 3 properties:
1. For all `y ∈ M`, `f y` is a unit;
2. For all `z : S`, there exists `(x, y) : R × M` such that `z * f y = f x`;
3. For all `x, y : R` such that `f x = f y`, there exists `c ∈ M` such that `x * c = y * c`.
(The converse is a consequence of 1.)
In the following, let `R, P` be commutative rings, `S, Q` be `R`- and `P`-algebras
and `M, T` be submonoids of `R` and `P` respectively, e.g.:
```
variable (R S P Q : Type*) [CommRing R] [CommRing S] [CommRing P] [CommRing Q]
variable [Algebra R S] [Algebra P Q] (M : Submonoid R) (T : Submonoid P)
```
## Main definitions
* `IsLocalization (M : Submonoid R) (S : Type*)` is a typeclass expressing that `S` is a
localization of `R` at `M`, i.e. the canonical map `algebraMap R S : R →+* S` is a
localization map (satisfying the above properties).
* `IsLocalization.mk' S` is a surjection sending `(x, y) : R × M` to `f x * (f y)⁻¹`
* `IsLocalization.lift` is the ring homomorphism from `S` induced by a homomorphism from `R`
which maps elements of `M` to invertible elements of the codomain.
* `IsLocalization.map S Q` is the ring homomorphism from `S` to `Q` which maps elements
of `M` to elements of `T`
* `IsLocalization.ringEquivOfRingEquiv`: if `R` and `P` are isomorphic by an isomorphism
sending `M` to `T`, then `S` and `Q` are isomorphic
## Main results
* `Localization M S`, a construction of the localization as a quotient type, defined in
`GroupTheory.MonoidLocalization`, has `CommRing`, `Algebra R` and `IsLocalization M`
instances if `R` is a ring. `Localization.Away`, `Localization.AtPrime` and `FractionRing`
are abbreviations for `Localization`s and have their corresponding `IsLocalization` instances
## Implementation notes
In maths it is natural to reason up to isomorphism, but in Lean we cannot naturally `rewrite` one
structure with an isomorphic one; one way around this is to isolate a predicate characterizing
a structure up to isomorphism, and reason about things that satisfy the predicate.
A previous version of this file used a fully bundled type of ring localization maps,
then used a type synonym `f.codomain` for `f : LocalizationMap M S` to instantiate the
`R`-algebra structure on `S`. This results in defining ad-hoc copies for everything already
defined on `S`. By making `IsLocalization` a predicate on the `algebraMap R S`,
we can ensure the localization map commutes nicely with other `algebraMap`s.
To prove most lemmas about a localization map `algebraMap R S` in this file we invoke the
corresponding proof for the underlying `CommMonoid` localization map
`IsLocalization.toLocalizationMap M S`, which can be found in `GroupTheory.MonoidLocalization`
and the namespace `Submonoid.LocalizationMap`.
To reason about the localization as a quotient type, use `mk_eq_of_mk'` and associated lemmas.
These show the quotient map `mk : R → M → Localization M` equals the surjection
`LocalizationMap.mk'` induced by the map `algebraMap : R →+* Localization M`.
The lemma `mk_eq_of_mk'` hence gives you access to the results in the rest of the file,
which are about the `LocalizationMap.mk'` induced by any localization map.
The proof that "a `CommRing` `K` which is the localization of an integral domain `R` at `R \ {0}`
is a field" is a `def` rather than an `instance`, so if you want to reason about a field of
fractions `K`, assume `[Field K]` instead of just `[CommRing K]`.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
assert_not_exists AlgHom Ideal
open Function
section CommSemiring
variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
/-- The typeclass `IsLocalization (M : Submonoid R) S` where `S` is an `R`-algebra
expresses that `S` is isomorphic to the localization of `R` at `M`. -/
@[mk_iff]
class IsLocalization (M : Submonoid R) (S : Type*) [CommSemiring S] [Algebra R S] : Prop where
/-- Everything in the image of `algebraMap` is a unit -/
map_units (S) : ∀ y : M, IsUnit (algebraMap R S y)
/-- The `algebraMap` is surjective -/
surj (M) : ∀ z : S, ∃ x : R × M, z * algebraMap R S x.2 = algebraMap R S x.1
/-- The kernel of `algebraMap` is contained in the annihilator of `M`;
it is then equal to the annihilator by `map_units'` -/
exists_of_eq : ∀ {x y}, algebraMap R S x = algebraMap R S y → ∃ c : M, ↑c * x = ↑c * y
variable {M}
namespace IsLocalization
section IsLocalization
variable [IsLocalization M S]
section
@[deprecated (since := "2025-09-04")] alias map_units' := IsLocalization.map_units
@[deprecated (since := "2025-09-04")] alias surj' := IsLocalization.surj
variable (M) {S}
variable (S) in
@[inherit_doc IsLocalization.exists_of_eq]
theorem eq_iff_exists {x y} : algebraMap R S x = algebraMap R S y ↔ ∃ c : M, ↑c * x = ↑c * y :=
Iff.intro IsLocalization.exists_of_eq fun ⟨c, h⟩ ↦ by
apply_fun algebraMap R S at h
rw [map_mul, map_mul] at h
exact (IsLocalization.map_units S c).mul_right_inj.mp h
theorem injective_iff_isRegular : Injective (algebraMap R S) ↔ ∀ c : M, IsRegular (c : R) := by
simp_rw [Commute.isRegular_iff (Commute.all _), IsLeftRegular,
Injective, eq_iff_exists M, exists_imp, forall_comm (α := M)]
theorem of_le (N : Submonoid R) (h₁ : M ≤ N) (h₂ : ∀ r ∈ N, IsUnit (algebraMap R S r)) :
IsLocalization N S where
map_units r := h₂ r r.2
surj s :=
have ⟨⟨x, y, hy⟩, H⟩ := IsLocalization.surj M s
⟨⟨x, y, h₁ hy⟩, H⟩
exists_of_eq {x y} := by
rw [IsLocalization.eq_iff_exists M]
rintro ⟨c, hc⟩
exact ⟨⟨c, h₁ c.2⟩, hc⟩
theorem of_le_of_exists_dvd (N : Submonoid R) (h₁ : M ≤ N) (h₂ : ∀ n ∈ N, ∃ m ∈ M, n ∣ m) :
IsLocalization N S :=
of_le M N h₁ fun n hn ↦ have ⟨m, hm, dvd⟩ := h₂ n hn
isUnit_of_dvd_unit (map_dvd _ dvd) (map_units S ⟨m, hm⟩)
theorem algebraMap_isUnit_iff {x : R} : IsUnit (algebraMap R S x) ↔ ∃ m ∈ M, x ∣ m := by
refine ⟨fun h ↦ ?_, fun ⟨m, hm, dvd⟩ ↦ isUnit_of_dvd_unit (map_dvd _ dvd) (map_units S ⟨m, hm⟩)⟩
have ⟨s, hxs⟩ := isUnit_iff_dvd_one.mp h
have ⟨⟨r, m⟩, hrm⟩ := surj M s
apply_fun (algebraMap R S x * ·) at hrm
rw [← mul_assoc, ← hxs, one_mul, ← map_mul] at hrm
have ⟨m', eq⟩ := exists_of_eq (M := M) hrm
exact ⟨m' * m, mul_mem m'.2 m.2, _, mul_left_comm _ x _ ▸ eq⟩
variable (S)
/-- `IsLocalization.toLocalizationMap M S` shows `S` is the monoid localization of `R` at `M`. -/
abbrev toLocalizationMap : M.LocalizationMap S where
__ := algebraMap R S
toFun := algebraMap R S
map_units' := IsLocalization.map_units _
surj' := IsLocalization.surj _
exists_of_eq _ _ := IsLocalization.exists_of_eq
@[deprecated (since := "2025-08-01")] alias toLocalizationWithZeroMap := toLocalizationMap
@[simp]
lemma toLocalizationMap_toMonoidHom :
(toLocalizationMap M S).toMonoidHom = (algebraMap R S : R →*₀ S) := rfl
@[deprecated (since := "2025-08-13")] alias toLocalizationMap_toMap := toLocalizationMap_toMonoidHom
@[simp] lemma coe_toLocalizationMap : ⇑(toLocalizationMap M S) = algebraMap R S := rfl
@[deprecated (since := "2025-08-13")] alias toLocalizationMap_toMap_apply := coe_toLocalizationMap
lemma toLocalizationMap_apply (x) : toLocalizationMap M S x = algebraMap R S x := rfl
theorem surj₂ : ∀ z w : S, ∃ z' w' : R, ∃ d : M,
(z * algebraMap R S d = algebraMap R S z') ∧ (w * algebraMap R S d = algebraMap R S w') :=
(toLocalizationMap M S).surj₂
end
variable (M) {S}
/-- Given a localization map `f : M →* N`, a section function sending `z : N` to some
`(x, y) : M × S` such that `f x * (f y)⁻¹ = z`. -/
noncomputable def sec (z : S) : R × M :=
Classical.choose <| IsLocalization.surj _ z
@[simp]
theorem toLocalizationMap_sec : (toLocalizationMap M S).sec = sec M :=
rfl
/-- Given `z : S`, `IsLocalization.sec M z` is defined to be a pair `(x, y) : R × M` such
that `z * f y = f x` (so this lemma is true by definition). -/
theorem sec_spec (z : S) :
z * algebraMap R S (IsLocalization.sec M z).2 = algebraMap R S (IsLocalization.sec M z).1 :=
Classical.choose_spec <| IsLocalization.surj _ z
/-- Given `z : S`, `IsLocalization.sec M z` is defined to be a pair `(x, y) : R × M` such
that `z * f y = f x`, so this lemma is just an application of `S`'s commutativity. -/
theorem sec_spec' (z : S) :
algebraMap R S (IsLocalization.sec M z).1 = algebraMap R S (IsLocalization.sec M z).2 * z := by
rw [mul_comm, sec_spec]
variable {M}
/-- If `M` contains `0` then the localization at `M` is trivial. -/
theorem subsingleton (h : 0 ∈ M) : Subsingleton S := (toLocalizationMap M S).subsingleton h
protected theorem subsingleton_iff : Subsingleton S ↔ 0 ∈ M :=
(toLocalizationMap M S).subsingleton_iff
theorem map_right_cancel {x y} {c : M} (h : algebraMap R S (c * x) = algebraMap R S (c * y)) :
algebraMap R S x = algebraMap R S y :=
(toLocalizationMap M S).map_right_cancel h
theorem map_left_cancel {x y} {c : M} (h : algebraMap R S (x * c) = algebraMap R S (y * c)) :
algebraMap R S x = algebraMap R S y :=
(toLocalizationMap M S).map_left_cancel h
theorem eq_zero_of_fst_eq_zero {z x} {y : M} (h : z * algebraMap R S y = algebraMap R S x)
(hx : x = 0) : z = 0 := by
rw [hx, (algebraMap R S).map_zero] at h
exact (IsUnit.mul_left_eq_zero (IsLocalization.map_units S y)).1 h
variable (M S)
theorem map_eq_zero_iff (r : R) : algebraMap R S r = 0 ↔ ∃ m : M, ↑m * r = 0 :=
(toLocalizationMap M S).map_eq_zero_iff
variable {M}
/-- `IsLocalization.mk' S` is the surjection sending `(x, y) : R × M` to
`f x * (f y)⁻¹`. -/
noncomputable def mk' (x : R) (y : M) : S :=
(toLocalizationMap M S).mk' x y
@[simp]
theorem mk'_sec (z : S) : mk' S (IsLocalization.sec M z).1 (IsLocalization.sec M z).2 = z :=
(toLocalizationMap M S).mk'_sec _
theorem mk'_mul (x₁ x₂ : R) (y₁ y₂ : M) : mk' S (x₁ * x₂) (y₁ * y₂) = mk' S x₁ y₁ * mk' S x₂ y₂ :=
(toLocalizationMap M S).mk'_mul _ _ _ _
theorem mk'_one (x) : mk' S x (1 : M) = algebraMap R S x :=
(toLocalizationMap M S).mk'_one _
@[simp]
theorem mk'_spec (x) (y : M) : mk' S x y * algebraMap R S y = algebraMap R S x :=
(toLocalizationMap M S).mk'_spec _ _
@[simp]
theorem mk'_spec' (x) (y : M) : algebraMap R S y * mk' S x y = algebraMap R S x :=
(toLocalizationMap M S).mk'_spec' _ _
@[simp]
theorem mk'_spec_mk (x) (y : R) (hy : y ∈ M) :
mk' S x ⟨y, hy⟩ * algebraMap R S y = algebraMap R S x :=
mk'_spec S x ⟨y, hy⟩
@[simp]
theorem mk'_spec'_mk (x) (y : R) (hy : y ∈ M) :
algebraMap R S y * mk' S x ⟨y, hy⟩ = algebraMap R S x :=
mk'_spec' S x ⟨y, hy⟩
variable {S}
theorem eq_mk'_iff_mul_eq {x} {y : M} {z} :
z = mk' S x y ↔ z * algebraMap R S y = algebraMap R S x :=
(toLocalizationMap M S).eq_mk'_iff_mul_eq
theorem eq_mk'_of_mul_eq {x : R} {y : M} {z : R} (h : z * y = x) : (algebraMap R S) z = mk' S x y :=
eq_mk'_iff_mul_eq.mpr (by rw [← h, map_mul])
theorem mk'_eq_iff_eq_mul {x} {y : M} {z} :
mk' S x y = z ↔ algebraMap R S x = z * algebraMap R S y :=
(toLocalizationMap M S).mk'_eq_iff_eq_mul
theorem mk'_add_eq_iff_add_mul_eq_mul {x} {y : M} {z₁ z₂} :
mk' S x y + z₁ = z₂ ↔ algebraMap R S x + z₁ * algebraMap R S y = z₂ * algebraMap R S y := by
rw [← mk'_spec S x y, ← IsUnit.mul_left_inj (IsLocalization.map_units S y), right_distrib]
theorem mk'_pow (x : R) (y : M) (n : ℕ) : mk' S (x ^ n) (y ^ n) = mk' S x y ^ n := by
simp_rw [IsLocalization.mk'_eq_iff_eq_mul, SubmonoidClass.coe_pow, map_pow, ← mul_pow]
simp
variable (M)
theorem mk'_surjective : Surjective fun ((r, m) : R × M) ↦ mk' S r m := fun z ↦
let ⟨r, hr⟩ := IsLocalization.surj _ z
⟨r, (eq_mk'_iff_mul_eq.2 hr).symm⟩
theorem exists_mk'_eq (z : S) : ∃ (x : R) (y : M), mk' S x y = z :=
let ⟨⟨r, m⟩, hz⟩ := mk'_surjective M z; ⟨r, m, hz⟩
variable (S) in
/-- The localization of a `Fintype` is a `Fintype`. Cannot be an instance. -/
noncomputable def fintype' [Fintype R] : Fintype S :=
have := Classical.propDecidable
.ofSurjective (Function.uncurry <| IsLocalization.mk' S) <| mk'_surjective M
variable {M}
/-- Localizing at a submonoid with 0 inside it leads to the trivial ring. -/
def uniqueOfZeroMem (h : (0 : R) ∈ M) : Unique S :=
uniqueOfZeroEqOne <| by simpa using IsLocalization.map_units S ⟨0, h⟩
theorem mk'_eq_iff_eq {x₁ x₂} {y₁ y₂ : M} :
mk' S x₁ y₁ = mk' S x₂ y₂ ↔ algebraMap R S (y₂ * x₁) = algebraMap R S (y₁ * x₂) :=
(toLocalizationMap M S).mk'_eq_iff_eq
theorem mk'_eq_iff_eq' {x₁ x₂} {y₁ y₂ : M} :
mk' S x₁ y₁ = mk' S x₂ y₂ ↔ algebraMap R S (x₁ * y₂) = algebraMap R S (x₂ * y₁) :=
(toLocalizationMap M S).mk'_eq_iff_eq'
protected theorem eq {a₁ b₁} {a₂ b₂ : M} :
mk' S a₁ a₂ = mk' S b₁ b₂ ↔ ∃ c : M, ↑c * (↑b₂ * a₁) = c * (a₂ * b₁) :=
(toLocalizationMap M S).eq
theorem mk'_eq_zero_iff (x : R) (s : M) : mk' S x s = 0 ↔ ∃ m : M, ↑m * x = 0 :=
(toLocalizationMap M S).mk'_eq_zero_iff x s
@[simp]
theorem mk'_zero (s : M) : IsLocalization.mk' S 0 s = 0 :=
(toLocalizationMap M S).mk'_zero s
theorem ne_zero_of_mk'_ne_zero {x : R} {y : M} (hxy : IsLocalization.mk' S x y ≠ 0) : x ≠ 0 := by
rintro rfl
exact hxy (IsLocalization.mk'_zero _)
/-- If we localise a ring `R` at a submonoid `M` made of regular elements, then `r / m : R[1/M]` is
regular iff `r : R` is. -/
@[simp] lemma isRegular_mk' (hM : ∀ m ∈ M, IsRegular m) {r : R} {m : M} :
IsRegular (IsLocalization.mk' S r m) ↔ IsRegular r := by
have (n : M) (x y : R) : n * x = n * y ↔ x = y := (hM _ n.2).1.eq_iff
simp +contextual only [← isLeftRegular_iff_isRegular, IsLeftRegular, Function.Injective,
(mk'_surjective M).forall, ← mk'_mul, Prod.forall, Subtype.forall, IsLocalization.eq,
Submonoid.coe_mul, this, exists_const, mul_assoc]
simp_rw [← mul_left_comm r]
exact ⟨fun h a b ↦ by simpa using h a 1 M.one_mem b 1 M.one_mem, fun h ha s hs b t ht ↦ @h _ _⟩
include M in
variable (M) in
/-- Any localization of a commutative semiring without zero-divisors also has no zero-divisors. -/
theorem noZeroDivisors [NoZeroDivisors R] : NoZeroDivisors S :=
(toLocalizationMap M S).noZeroDivisors
theorem sec_fst_ne_zero {x : S} (hx : x ≠ 0) : (sec M x).fst ≠ 0 :=
mt (fun h ↦ by rw [← mk'_sec (M := M) S x, h, mk'_zero]) hx
section Ext
theorem eq_iff_eq [Algebra R P] [IsLocalization M P] {x y} :
algebraMap R S x = algebraMap R S y ↔ algebraMap R P x = algebraMap R P y :=
(toLocalizationMap M S).eq_iff_eq (toLocalizationMap M P)
theorem mk'_eq_iff_mk'_eq [Algebra R P] [IsLocalization M P] {x₁ x₂} {y₁ y₂ : M} :
mk' S x₁ y₁ = mk' S x₂ y₂ ↔ mk' P x₁ y₁ = mk' P x₂ y₂ :=
(toLocalizationMap M S).mk'_eq_iff_mk'_eq (toLocalizationMap M P)
theorem mk'_eq_of_eq {a₁ b₁ : R} {a₂ b₂ : M} (H : ↑a₂ * b₁ = ↑b₂ * a₁) :
mk' S a₁ a₂ = mk' S b₁ b₂ :=
(toLocalizationMap M S).mk'_eq_of_eq H
theorem mk'_eq_of_eq' {a₁ b₁ : R} {a₂ b₂ : M} (H : b₁ * ↑a₂ = a₁ * ↑b₂) :
mk' S a₁ a₂ = mk' S b₁ b₂ :=
(toLocalizationMap M S).mk'_eq_of_eq' H
theorem mk'_cancel (a : R) (b c : M) :
mk' S (a * c) (b * c) = mk' S a b := (toLocalizationMap M S).mk'_cancel _ _ _
variable (S)
@[simp]
theorem mk'_self {x : R} (hx : x ∈ M) : mk' S x ⟨x, hx⟩ = 1 :=
(toLocalizationMap M S).mk'_self _ hx
@[simp]
theorem mk'_self' {x : M} : mk' S (x : R) x = 1 :=
(toLocalizationMap M S).mk'_self' _
theorem mk'_self'' {x : M} : mk' S x.1 x = 1 :=
mk'_self' _
end Ext
theorem mul_mk'_eq_mk'_of_mul (x y : R) (z : M) :
(algebraMap R S) x * mk' S y z = mk' S (x * y) z :=
(toLocalizationMap M S).mul_mk'_eq_mk'_of_mul _ _ _
theorem mk'_eq_mul_mk'_one (x : R) (y : M) : mk' S x y = (algebraMap R S) x * mk' S 1 y :=
((toLocalizationMap M S).mul_mk'_one_eq_mk' _ _).symm
@[simp]
theorem mk'_mul_cancel_left (x : R) (y : M) : mk' S (y * x : R) y = (algebraMap R S) x :=
(toLocalizationMap M S).mk'_mul_cancel_left _ _
theorem mk'_mul_cancel_right (x : R) (y : M) : mk' S (x * y) y = (algebraMap R S) x :=
(toLocalizationMap M S).mk'_mul_cancel_right _ _
@[simp]
theorem mk'_mul_mk'_eq_one (x y : M) : mk' S (x : R) y * mk' S (y : R) x = 1 := by
rw [← mk'_mul, mul_comm]; exact mk'_self _ _
theorem mk'_mul_mk'_eq_one' (x : R) (y : M) (h : x ∈ M) : mk' S x y * mk' S (y : R) ⟨x, h⟩ = 1 :=
mk'_mul_mk'_eq_one ⟨x, h⟩ _
theorem smul_mk' (x y : R) (m : M) : x • mk' S y m = mk' S (x * y) m := by
nth_rw 2 [← one_mul m]
rw [mk'_mul, mk'_one, Algebra.smul_def]
@[simp] theorem smul_mk'_one (x : R) (m : M) : x • mk' S 1 m = mk' S x m := by
rw [smul_mk', mul_one]
@[simp] lemma smul_mk'_self {m : M} {r : R} :
(m : R) • mk' S r m = algebraMap R S r := by
rw [smul_mk', mk'_mul_cancel_left]
@[simps]
noncomputable instance invertible_mk'_one (s : M) :
Invertible (IsLocalization.mk' S (1 : R) s) where
invOf := algebraMap R S s
invOf_mul_self := by simp
mul_invOf_self := by simp
section
variable (M)
theorem isUnit_comp (j : S →+* P) (y : M) : IsUnit (j.comp (algebraMap R S) y) :=
(toLocalizationMap M S).isUnit_comp j.toMonoidHom _
end
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g(M) ⊆ Units P`, `f x = f y → g x = g y` for all `x y : R`. -/
theorem eq_of_eq {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) {x y}
(h : (algebraMap R S) x = (algebraMap R S) y) : g x = g y :=
Submonoid.LocalizationMap.eq_of_eq (toLocalizationMap M S) (g := g.toMonoidHom) hg h
theorem mk'_add (x₁ x₂ : R) (y₁ y₂ : M) :
mk' S (x₁ * y₂ + x₂ * y₁) (y₁ * y₂) = mk' S x₁ y₁ + mk' S x₂ y₂ :=
mk'_eq_iff_eq_mul.2 <|
Eq.symm
(by
rw [mul_comm (_ + _), mul_add, mul_mk'_eq_mk'_of_mul, mk'_add_eq_iff_add_mul_eq_mul,
mul_comm (_ * _), ← mul_assoc, add_comm, ← map_mul, mul_mk'_eq_mk'_of_mul,
mk'_add_eq_iff_add_mul_eq_mul]
simp only [map_add, Submonoid.coe_mul, map_mul]
ring)
theorem mul_add_inv_left {g : R →+* P} (h : ∀ y : M, IsUnit (g y)) (y : M) (w z₁ z₂ : P) :
w * ↑(IsUnit.liftRight (g.toMonoidHom.restrict M) h y)⁻¹ + z₁ =
z₂ ↔ w + g y * z₁ = g y * z₂ := by
rw [mul_comm, ← one_mul z₁, ← Units.inv_mul (IsUnit.liftRight (g.toMonoidHom.restrict M) h y),
mul_assoc, ← mul_add, Units.inv_mul_eq_iff_eq_mul, Units.inv_mul_cancel_left,
IsUnit.coe_liftRight]
simp [RingHom.toMonoidHom_eq_coe, MonoidHom.restrict_apply]
theorem lift_spec_mul_add {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) (z w w' v) :
((toLocalizationMap M S).lift hg) z * w + w' = v ↔
g ((toLocalizationMap M S).sec z).1 * w + g ((toLocalizationMap M S).sec z).2 * w' =
g ((toLocalizationMap M S).sec z).2 * v := by
rw [mul_comm, Submonoid.LocalizationMap.lift_apply, ← mul_assoc, mul_add_inv_left hg,
mul_comm]
rfl
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →+* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` sending `z : S` to `g x * (g y)⁻¹`, where `(x, y) : R × M` are such that
`z = f x * (f y)⁻¹`. -/
noncomputable def lift {g : R →+* P} (hg : ∀ y : M, IsUnit (g y)) : S →+* P :=
{ (toLocalizationMap M S).lift₀ g.toMonoidWithZeroHom hg with
map_add' := by
intro x y
dsimp
rw [(toLocalizationMap M S).lift₀_def, (toLocalizationMap M S).lift_spec,
mul_add, mul_comm, eq_comm, lift_spec_mul_add, add_comm, mul_comm, mul_assoc, mul_comm,
mul_assoc, lift_spec_mul_add]
simp_rw [← mul_assoc]
change g _ * g _ * g _ + g _ * g _ * g _ = g _ * g _ * g _
simp_rw [← map_mul g, ← map_add g]
apply eq_of_eq (S := S) hg
simp only [sec_spec', toLocalizationMap_sec, map_add, map_mul]
ring }
variable {g : R →+* P} (hg : ∀ y : M, IsUnit (g y))
/-- Given a localization map `f : R →+* S` for a submonoid `M ⊆ R` and a map of `CommSemiring`s
`g : R →* P` such that `g y` is invertible for all `y : M`, the homomorphism induced from
`S` to `P` maps `f x * (f y)⁻¹` to `g x * (g y)⁻¹` for all `x : R, y ∈ M`. -/
theorem lift_mk' (x y) :
lift hg (mk' S x y) = g x * ↑(IsUnit.liftRight (g.toMonoidHom.restrict M) hg y)⁻¹ :=
(toLocalizationMap M S).lift_mk' _ _ _
theorem lift_mk'_spec (x v) (y : M) : lift hg (mk' S x y) = v ↔ g x = g y * v :=
(toLocalizationMap M S).lift_mk'_spec _ _ _ _
@[simp]
theorem lift_eq (x : R) : lift hg ((algebraMap R S) x) = g x :=
(toLocalizationMap M S).lift_eq _ _
theorem lift_eq_iff {x y : R × M} :
lift hg (mk' S x.1 x.2) = lift hg (mk' S y.1 y.2) ↔ g (x.1 * y.2) = g (y.1 * x.2) :=
(toLocalizationMap M S).lift_eq_iff _
@[simp]
theorem lift_comp : (lift hg).comp (algebraMap R S) = g :=
RingHom.ext <| (DFunLike.ext_iff (F := MonoidHom _ _)).1 <| (toLocalizationMap M S).lift_comp _
@[simp]
theorem lift_of_comp (j : S →+* P) : lift (isUnit_comp M j) = j :=
RingHom.ext <| (DFunLike.ext_iff (F := MonoidHom _ _)).1 <|
(toLocalizationMap M S).lift_of_comp j.toMonoidHom
variable (M)
section
include M
/-- See note [partially-applied ext lemmas] -/
theorem monoidHom_ext {P : Type*} [Monoid P] ⦃j k : S →* P⦄
(h : j.comp (algebraMap R S : R →* S) = k.comp (algebraMap R S)) : j = k :=
(toLocalizationMap M S).epic_of_localizationMap h
/-- See note [partially-applied ext lemmas] -/
theorem ringHom_ext {P : Type*} [Semiring P] ⦃j k : S →+* P⦄
(h : j.comp (algebraMap R S) = k.comp (algebraMap R S)) :
j = k :=
RingHom.coe_monoidHom_injective <| monoidHom_ext M <| MonoidHom.ext <| RingHom.congr_fun h
/-- To show `j` and `k` agree on the whole localization, it suffices to show they agree
on the image of the base ring, if they preserve `1` and `*`. -/
protected theorem ext {P : Type*} [Monoid P] (j k : S → P) (hj1 : j 1 = 1) (hk1 : k 1 = 1)
(hjm : ∀ a b, j (a * b) = j a * j b) (hkm : ∀ a b, k (a * b) = k a * k b)
(h : ∀ a, j (algebraMap R S a) = k (algebraMap R S a)) : j = k :=
let j' : MonoidHom S P :=
{ toFun := j, map_one' := hj1, map_mul' := hjm }
let k' : MonoidHom S P :=
{ toFun := k, map_one' := hk1, map_mul' := hkm }
have : j' = k' := monoidHom_ext M (MonoidHom.ext h)
show j'.toFun = k'.toFun by rw [this]
end
variable {M}
theorem lift_unique {j : S →+* P} (hj : ∀ x, j ((algebraMap R S) x) = g x) : lift hg = j :=
RingHom.ext <|
(DFunLike.ext_iff (F := MonoidHom _ _)).1 <|
Submonoid.LocalizationMap.lift_unique (toLocalizationMap M S) (g := g.toMonoidHom) hg
(j := j.toMonoidHom) hj
@[simp]
theorem lift_id (x) : lift (map_units S : ∀ _ : M, IsUnit _) x = x :=
(toLocalizationMap M S).lift_id _
theorem lift_surjective_iff :
Surjective (lift hg : S → P) ↔ ∀ v : P, ∃ x : R × M, v * g x.2 = g x.1 :=
(toLocalizationMap M S).lift_surjective_iff hg
theorem lift_injective_iff :
Injective (lift hg : S → P) ↔ ∀ x y, algebraMap R S x = algebraMap R S y ↔ g x = g y :=
(toLocalizationMap M S).lift_injective_iff hg
variable (M) in
include M in
lemma injective_iff_map_algebraMap_eq {T} [CommSemiring T] (f : S →+* T) :
Function.Injective f ↔ ∀ x y,
algebraMap R S x = algebraMap R S y ↔ f (algebraMap R S x) = f (algebraMap R S y) := by
rw [← IsLocalization.lift_of_comp (M := M) f, IsLocalization.lift_injective_iff]
simp
section Map
variable {T : Submonoid P} {Q : Type*} [CommSemiring Q]
variable [Algebra P Q] [IsLocalization T Q]
section
variable (Q)
/-- Map a homomorphism `g : R →+* P` to `S →+* Q`, where `S` and `Q` are
localizations of `R` and `P` at `M` and `T` respectively,
such that `g(M) ⊆ T`.
We send `z : S` to `algebraMap P Q (g x) * (algebraMap P Q (g y))⁻¹`, where
`(x, y) : R × M` are such that `z = f x * (f y)⁻¹`. -/
noncomputable def map (g : R →+* P) (hy : M ≤ T.comap g) : S →+* Q :=
lift (M := M) (g := (algebraMap P Q).comp g) fun y => map_units _ ⟨g y, hy y.2⟩
end
section
variable (hy : M ≤ T.comap g)
include hy
@[simp]
theorem map_eq (x) : map Q g hy ((algebraMap R S) x) = algebraMap P Q (g x) :=
lift_eq (fun y => map_units _ ⟨g y, hy y.2⟩) x
@[simp]
theorem map_comp : (map Q g hy).comp (algebraMap R S) = (algebraMap P Q).comp g :=
lift_comp fun y => map_units _ ⟨g y, hy y.2⟩
theorem map_mk' (x) (y : M) : map Q g hy (mk' S x y) = mk' Q (g x) ⟨g y, hy y.2⟩ :=
Submonoid.LocalizationMap.map_mk' (toLocalizationMap M S) (g := g.toMonoidHom)
(fun y => hy y.2) (k := toLocalizationMap T Q) ..
theorem map_unique (j : S →+* Q) (hj : ∀ x : R, j (algebraMap R S x) = algebraMap P Q (g x)) :
map Q g hy = j :=
lift_unique (fun y => map_units _ ⟨g y, hy y.2⟩) hj
/-- If `CommSemiring` homs `g : R →+* P, l : P →+* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
theorem map_comp_map {A : Type*} [CommSemiring A] {U : Submonoid A} {W} [CommSemiring W]
[Algebra A W] [IsLocalization U W] {l : P →+* A} (hl : T ≤ U.comap l) :
(map W l hl).comp (map Q g hy : S →+* _) = map W (l.comp g) fun _ hx => hl (hy hx) :=
RingHom.ext fun x =>
Submonoid.LocalizationMap.map_map (P := P) (toLocalizationMap M S) (fun y => hy y.2)
(toLocalizationMap U W) (fun w => hl w.2) x
/-- If `CommSemiring` homs `g : R →+* P, l : P →+* A` induce maps of localizations, the composition
of the induced maps equals the map of localizations induced by `l ∘ g`. -/
theorem map_map {A : Type*} [CommSemiring A] {U : Submonoid A} {W} [CommSemiring W] [Algebra A W]
[IsLocalization U W] {l : P →+* A} (hl : T ≤ U.comap l) (x : S) :
map W l hl (map Q g hy x) = map W (l.comp g) (fun _ hx => hl (hy hx)) x := by
rw [← map_comp_map (Q := Q) hy hl]; rfl
protected theorem map_smul (x : S) (z : R) : map Q g hy (z • x : S) = g z • map Q g hy x := by
rw [Algebra.smul_def, Algebra.smul_def, RingHom.map_mul, map_eq]
end
@[simp]
theorem map_id_mk' {Q : Type*} [CommSemiring Q] [Algebra R Q] [IsLocalization M Q] (x) (y : M) :
map Q (RingHom.id R) (le_refl M) (mk' S x y) = mk' Q x y :=
map_mk' ..
@[simp]
theorem map_id (z : S) (h : M ≤ M.comap (RingHom.id R) := le_refl M) :
map S (RingHom.id _) h z = z :=
lift_id _
section
variable (S Q)
/-- If `S`, `Q` are localizations of `R` and `P` at submonoids `M, T` respectively, an
isomorphism `j : R ≃+* P` such that `j(M) = T` induces an isomorphism of localizations
`S ≃+* Q`. -/
@[simps]
noncomputable def ringEquivOfRingEquiv (h : R ≃+* P) (H : M.map h.toMonoidHom = T) : S ≃+* Q :=
have H' : T.map h.symm.toMonoidHom = M := by
rw [← M.map_id, ← H, Submonoid.map_map]
congr
ext
apply h.symm_apply_apply
{ map Q (h : R →+* P) (M.le_comap_of_map_le (le_of_eq H)) with
toFun := map Q (h : R →+* P) (M.le_comap_of_map_le (le_of_eq H))
invFun := map S (h.symm : P →+* R) (T.le_comap_of_map_le (le_of_eq H'))
left_inv := fun x => by
rw [map_map, map_unique _ (RingHom.id _), RingHom.id_apply]
simp
right_inv := fun x => by
rw [map_map, map_unique _ (RingHom.id _), RingHom.id_apply]
simp }
end
theorem ringEquivOfRingEquiv_eq_map {j : R ≃+* P} (H : M.map j.toMonoidHom = T) :
(ringEquivOfRingEquiv S Q j H : S →+* Q) =
map Q (j : R →+* P) (M.le_comap_of_map_le (le_of_eq H)) :=
rfl
theorem ringEquivOfRingEquiv_eq {j : R ≃+* P} (H : M.map j.toMonoidHom = T) (x) :
ringEquivOfRingEquiv S Q j H ((algebraMap R S) x) = algebraMap P Q (j x) := by
simp
theorem ringEquivOfRingEquiv_mk' {j : R ≃+* P} (H : M.map j.toMonoidHom = T) (x : R) (y : M) :
ringEquivOfRingEquiv S Q j H (mk' S x y) =
mk' Q (j x) ⟨j y, show j y ∈ T from H ▸ Set.mem_image_of_mem j y.2⟩ := by
simp [map_mk']
@[simp]
theorem ringEquivOfRingEquiv_symm {j : R ≃+* P} (H : M.map j = T) :
(ringEquivOfRingEquiv S Q j H).symm =
ringEquivOfRingEquiv Q S j.symm (show T.map (j : R ≃* P).symm = M by
rw [← H, ← Submonoid.comap_equiv_eq_map_symm, ← Submonoid.map_coe_toMulEquiv,
Submonoid.comap_map_eq_of_injective (j : R ≃* P).injective]) := rfl
end Map
section at_units
lemma at_units (S : Submonoid R)
(hS : S ≤ IsUnit.submonoid R) : IsLocalization S R where
map_units y := hS y.prop
surj := fun s ↦ ⟨⟨s, 1⟩, by simp⟩
exists_of_eq := fun {x y} (e : x = y) ↦ ⟨1, e ▸ rfl⟩
end at_units
section
variable (M S) (Q : Type*) [CommSemiring Q] [Algebra P Q]
/-- Injectivity of a map descends to the map induced on localizations. -/
theorem map_injective_of_injective (h : Function.Injective g) [IsLocalization (M.map g) Q] :
Function.Injective (map Q g M.le_comap_map : S → Q) :=
(toLocalizationMap M S).map_injective_of_injective h (toLocalizationMap (M.map g) Q)
/-- Surjectivity of a map descends to the map induced on localizations. -/
theorem map_surjective_of_surjective (h : Function.Surjective g) [IsLocalization (M.map g) Q] :
Function.Surjective (map Q g M.le_comap_map : S → Q) :=
(toLocalizationMap M S).map_surjective_of_surjective h (toLocalizationMap (M.map g) Q)
end
end IsLocalization
section
variable (M)
theorem isLocalization_of_base_ringEquiv [IsLocalization M S] (h : R ≃+* P) :
haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
IsLocalization (M.map h) S := by
letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
constructor
· rintro ⟨_, ⟨y, hy, rfl⟩⟩
convert IsLocalization.map_units S ⟨y, hy⟩
dsimp only [RingHom.algebraMap_toAlgebra, RingHom.comp_apply]
exact congr_arg _ (h.symm_apply_apply _)
· intro y
obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj M y
refine ⟨⟨h x, _, _, s.prop, rfl⟩, ?_⟩
dsimp only [RingHom.algebraMap_toAlgebra, RingHom.comp_apply] at e ⊢
convert e <;> exact h.symm_apply_apply _
· intro x y
rw [RingHom.algebraMap_toAlgebra, RingHom.comp_apply, RingHom.comp_apply,
IsLocalization.eq_iff_exists M S]
simp [← h.toEquiv.apply_eq_iff_eq]
theorem isLocalization_iff_of_base_ringEquiv (h : R ≃+* P) :
IsLocalization M S ↔
haveI := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
IsLocalization (M.map h) S := by
letI : Algebra P S := ((algebraMap R S).comp h.symm.toRingHom).toAlgebra
refine ⟨fun _ => isLocalization_of_base_ringEquiv M S h, ?_⟩
intro (H : IsLocalization (Submonoid.map (h : R ≃* P) M) S)
convert isLocalization_of_base_ringEquiv (Submonoid.map (h : R ≃* P) M) S h.symm
· rw [← Submonoid.map_coe_toMulEquiv, RingEquiv.coe_toMulEquiv_symm, ←
Submonoid.comap_equiv_eq_map_symm, Submonoid.comap_map_eq_of_injective]
exact h.toEquiv.injective
rw [RingHom.algebraMap_toAlgebra, RingHom.comp_assoc]
simp only [RingHom.comp_id, RingEquiv.symm_symm, RingEquiv.symm_toRingHom_comp_toRingHom]
apply Algebra.algebra_ext
intro r
rw [RingHom.algebraMap_toAlgebra]
end
variable (M)
theorem nonZeroDivisors_le_comap [IsLocalization M S] :
nonZeroDivisors R ≤ (nonZeroDivisors S).comap (algebraMap R S) :=
(toLocalizationMap M S).nonZeroDivisors_le_comap
theorem map_nonZeroDivisors_le [IsLocalization M S] :
(nonZeroDivisors R).map (algebraMap R S) ≤ nonZeroDivisors S :=
(toLocalizationMap M S).map_nonZeroDivisors_le
end IsLocalization
namespace Localization
open IsLocalization
/-! ### Constructing a localization at a given submonoid -/
section
instance instUniqueLocalization [Subsingleton R] : Unique (Localization M) where
uniq a := by
with_unfolding_all change a = mk 1 1
exact Localization.induction_on a fun _ => by
congr <;> apply Subsingleton.elim
theorem add_mk (a b c d) : (mk a b : Localization M) + mk c d =
mk ((b : R) * c + (d : R) * a) (b * d) := by
rw [add_comm (b * c) (d * a), mul_comm b d]
exact OreLocalization.oreDiv_add_oreDiv
theorem add_mk_self (a b c) : (mk a b : Localization M) + mk c b = mk (a + c) b := by
rw [add_mk, mk_eq_mk_iff, r_eq_r']
refine (r' M).symm ⟨1, ?_⟩
simp only [Submonoid.coe_one, Submonoid.coe_mul]
ring
/-- For any given denominator `b : M`, the map `a ↦ a / b` is an `AddMonoidHom` from `R` to
`Localization M`. -/
@[simps]
def mkAddMonoidHom (b : M) : R →+ Localization M where
toFun a := mk a b
map_zero' := mk_zero _
map_add' _ _ := (add_mk_self _ _ _).symm
theorem mk_sum {ι : Type*} (f : ι → R) (s : Finset ι) (b : M) :
mk (∑ i ∈ s, f i) b = ∑ i ∈ s, mk (f i) b :=
map_sum (mkAddMonoidHom b) f s
theorem mk_list_sum (l : List R) (b : M) : mk l.sum b = (l.map fun a => mk a b).sum :=
map_list_sum (mkAddMonoidHom b) l
theorem mk_multiset_sum (l : Multiset R) (b : M) : mk l.sum b = (l.map fun a => mk a b).sum :=
(mkAddMonoidHom b).map_multiset_sum l
instance isLocalization : IsLocalization M (Localization M) where
map_units := (Localization.monoidOf M).map_units
surj := (Localization.monoidOf M).surj
exists_of_eq := (Localization.monoidOf M).eq_iff_exists.mp
instance [NoZeroDivisors R] : NoZeroDivisors (Localization M) := IsLocalization.noZeroDivisors M
end
@[simp]
theorem toLocalizationMap_eq_monoidOf : toLocalizationMap M (Localization M) = monoidOf M :=
rfl
theorem monoidOf_eq_algebraMap (x) : monoidOf M x = algebraMap R (Localization M) x :=
rfl
theorem mk_one_eq_algebraMap (x) : mk x 1 = algebraMap R (Localization M) x :=
rfl
theorem mk_eq_mk'_apply (x y) : mk x y = IsLocalization.mk' (Localization M) x y := by
rw [mk_eq_monoidOf_mk'_apply, mk', toLocalizationMap_eq_monoidOf]
theorem mk_eq_mk' : (mk : R → M → Localization M) = IsLocalization.mk' (Localization M) :=
mk_eq_monoidOf_mk'
theorem mk_algebraMap {A : Type*} [CommSemiring A] [Algebra A R] (m : A) :
mk (algebraMap A R m) 1 = algebraMap A (Localization M) m := by
rw [mk_eq_mk', mk'_eq_iff_eq_mul, Submonoid.coe_one, map_one, mul_one]; rfl
end Localization
namespace IsLocalization
variable [IsLocalization M S]
theorem to_map_eq_zero_iff {x : R} (hM : M ≤ nonZeroDivisors R) : algebraMap R S x = 0 ↔ x = 0 := by
constructor <;> intro h
· obtain ⟨c, hc⟩ := (map_eq_zero_iff M _ _).mp h
exact (hM c.2).1 x hc
· rw [h, map_zero]
protected theorem injectiveₛ (hM : ∀ m ∈ M, IsRegular m) : Injective (algebraMap R S) :=
(toLocalizationMap M S).injective_iff.mpr hM
protected theorem to_map_ne_zero_of_mem_nonZeroDivisors [Nontrivial R] (hM : M ≤ nonZeroDivisors R)
{x : R} (hx : x ∈ nonZeroDivisors R) : algebraMap R S x ≠ 0 := by
rw [Ne, to_map_eq_zero_iff S hM]
exact nonZeroDivisors.ne_zero hx
variable {S}
theorem sec_snd_ne_zero [Nontrivial R] (hM : M ≤ nonZeroDivisors R) (x : S) :
((sec M x).snd : R) ≠ 0 :=
nonZeroDivisors.coe_ne_zero ⟨(sec M x).snd.val, hM (sec M x).snd.property⟩
variable [IsDomain R]
variable (S) in
/-- A `CommRing` `S` which is the localization of an integral domain `R` at a subset of
non-zero elements is an integral domain. -/
theorem isDomain_of_le_nonZeroDivisors (hM : M ≤ nonZeroDivisors R) : IsDomain S where
__ : IsCancelMulZero S := (toLocalizationMap M S).isCancelMulZero
__ : Nontrivial S := (toLocalizationMap M S).nontrivial fun h ↦ zero_notMem_nonZeroDivisors (hM h)
/-- The localization of an integral domain to a set of non-zero elements is an integral domain. -/
theorem isDomain_localization {M : Submonoid R} (hM : M ≤ nonZeroDivisors R) :
IsDomain (Localization M) :=
isDomain_of_le_nonZeroDivisors _ hM
end IsLocalization
end CommSemiring
section CommRing
variable {R : Type*} [CommRing R] {M : Submonoid R} (S : Type*) [CommRing S]
variable [Algebra R S] {P : Type*} [CommRing P]
namespace Localization
theorem neg_mk (a b) : -(mk a b : Localization M) = mk (-a) b := OreLocalization.neg_def _ _
theorem sub_mk (a c) (b d) : (mk a b : Localization M) - mk c d =
mk ((d : R) * a - b * c) (b * d) := by
rw [sub_eq_add_neg, neg_mk, add_mk, add_comm, mul_neg, ← sub_eq_add_neg]
end Localization
namespace IsLocalization
variable [IsLocalization M S]
theorem mk'_neg (x : R) (y : M) :
mk' S (-x) y = -mk' S x y := by
rw [eq_comm, eq_mk'_iff_mul_eq, neg_mul, map_neg, mk'_spec]
theorem mk'_sub (x₁ x₂ : R) (y₁ y₂ : M) :
mk' S (x₁ * y₂ - x₂ * y₁) (y₁ * y₂) = mk' S x₁ y₁ - mk' S x₂ y₂ := by
rw [sub_eq_add_neg, sub_eq_add_neg, ← mk'_neg, ← mk'_add, neg_mul]
include M in
lemma injective_of_map_algebraMap_zero {T} [CommRing T] (f : S →+* T)
(h : ∀ x, f (algebraMap R S x) = 0 → algebraMap R S x = 0) :
Function.Injective f := by
rw [IsLocalization.injective_iff_map_algebraMap_eq M]
refine fun x y ↦ ⟨fun hz ↦ hz ▸ rfl, fun hz ↦ ?_⟩
rw [← sub_eq_zero, ← map_sub, ← map_sub] at hz
apply h at hz
rwa [map_sub, sub_eq_zero] at hz
protected theorem injective (hM : M ≤ nonZeroDivisors R) : Injective (algebraMap R S) :=
IsLocalization.injectiveₛ S fun _x hx ↦ isRegular_iff_mem_nonZeroDivisors.mpr (hM hx)
end IsLocalization
end CommRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/LocalizationLocalization.lean | import Mathlib.RingTheory.Localization.AtPrime.Basic
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.Localization.FractionRing
/-!
# Localizations of localizations
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
open Function
namespace IsLocalization
section LocalizationLocalization
variable {R : Type*} [CommSemiring R] (M : Submonoid R) {S : Type*} [CommSemiring S] [Algebra R S]
variable (N : Submonoid S) (T : Type*) [CommSemiring T] [Algebra R T]
section
variable [Algebra S T] [IsScalarTower R S T]
-- This should only be defined when `S` is the localization `M⁻¹R`, hence the nolint.
/-- Localizing w.r.t. `M ⊆ R` and then w.r.t. `N ⊆ S = M⁻¹R` is equal to the localization of `R`
w.r.t. this module. See `localization_localization_isLocalization`.
-/
@[nolint unusedArguments]
def localizationLocalizationSubmodule : Submonoid R :=
(N ⊔ M.map (algebraMap R S)).comap (algebraMap R S)
variable {M N}
@[simp]
theorem mem_localizationLocalizationSubmodule {x : R} :
x ∈ localizationLocalizationSubmodule M N ↔
∃ (y : N) (z : M), algebraMap R S x = y * algebraMap R S z := by
rw [localizationLocalizationSubmodule, Submonoid.mem_comap, Submonoid.mem_sup]
constructor
· rintro ⟨y, hy, _, ⟨z, hz, rfl⟩, e⟩
exact ⟨⟨y, hy⟩, ⟨z, hz⟩, e.symm⟩
· rintro ⟨y, z, e⟩
exact ⟨y, y.prop, _, ⟨z, z.prop, rfl⟩, e.symm⟩
variable (M N)
variable [IsLocalization M S]
theorem localization_localization_map_units [IsLocalization N T]
(y : localizationLocalizationSubmodule M N) : IsUnit (algebraMap R T y) := by
obtain ⟨y', z, eq⟩ := mem_localizationLocalizationSubmodule.mp y.prop
rw [IsScalarTower.algebraMap_apply R S T, eq, RingHom.map_mul, IsUnit.mul_iff]
exact ⟨IsLocalization.map_units T y', (IsLocalization.map_units _ z).map (algebraMap S T)⟩
theorem localization_localization_surj [IsLocalization N T] (x : T) :
∃ y : R × localizationLocalizationSubmodule M N,
x * algebraMap R T y.2 = algebraMap R T y.1 := by
rcases IsLocalization.surj N x with ⟨⟨y, s⟩, eq₁⟩
-- x = y / s
rcases IsLocalization.surj M y with ⟨⟨z, t⟩, eq₂⟩
-- y = z / t
rcases IsLocalization.surj M (s : S) with ⟨⟨z', t'⟩, eq₃⟩
-- s = z' / t'
dsimp only at eq₁ eq₂ eq₃
refine ⟨⟨z * t', z' * t, ?_⟩, ?_⟩ -- x = y / s = (z * t') / (z' * t)
· rw [mem_localizationLocalizationSubmodule]
refine ⟨s, t * t', ?_⟩
rw [RingHom.map_mul, ← eq₃, mul_assoc, ← RingHom.map_mul, mul_comm t, Submonoid.coe_mul]
· simp only [RingHom.map_mul, IsScalarTower.algebraMap_apply R S T, ← eq₃, ← eq₂,
← eq₁]
ring
theorem localization_localization_exists_of_eq [IsLocalization N T] (x y : R) :
algebraMap R T x = algebraMap R T y →
∃ c : localizationLocalizationSubmodule M N, ↑c * x = ↑c * y := by
rw [IsScalarTower.algebraMap_apply R S T, IsScalarTower.algebraMap_apply R S T,
IsLocalization.eq_iff_exists N T]
rintro ⟨z, eq₁⟩
rcases IsLocalization.surj M (z : S) with ⟨⟨z', s⟩, eq₂⟩
dsimp only at eq₂
suffices (algebraMap R S) (x * z' : R) = (algebraMap R S) (y * z') by
obtain ⟨c, eq₃ : ↑c * (x * z') = ↑c * (y * z')⟩ := (IsLocalization.eq_iff_exists M S).mp this
refine ⟨⟨c * z', ?_⟩, ?_⟩
· rw [mem_localizationLocalizationSubmodule]
refine ⟨z, c * s, ?_⟩
rw [map_mul, ← eq₂, Submonoid.coe_mul, map_mul, mul_left_comm]
· rwa [mul_comm _ z', mul_comm _ z', ← mul_assoc, ← mul_assoc] at eq₃
rw [map_mul, map_mul, ← eq₂, ← mul_assoc, ← mul_assoc, mul_comm _ (z : S), eq₁,
mul_comm _ (z : S)]
/-- Given submodules `M ⊆ R` and `N ⊆ S = M⁻¹R`, with `f : R →+* S` the localization map, we have
`N ⁻¹ S = T = (f⁻¹ (N • f(M))) ⁻¹ R`. I.e., the localization of a localization is a localization.
-/
theorem localization_localization_isLocalization [IsLocalization N T] :
IsLocalization (localizationLocalizationSubmodule M N) T where
map_units := localization_localization_map_units M N T
surj := localization_localization_surj M N T
exists_of_eq := localization_localization_exists_of_eq M N T _ _
include M in
/-- Given submodules `M ⊆ R` and `N ⊆ S = M⁻¹R`, with `f : R →+* S` the localization map, if
`N` contains all the units of `S`, then `N ⁻¹ S = T = (f⁻¹ N) ⁻¹ R`. I.e., the localization of a
localization is a localization.
-/
theorem localization_localization_isLocalization_of_has_all_units [IsLocalization N T]
(H : ∀ x : S, IsUnit x → x ∈ N) : IsLocalization (N.comap (algebraMap R S)) T := by
convert localization_localization_isLocalization M N T using 1
dsimp [localizationLocalizationSubmodule]
congr
symm
rw [sup_eq_left]
rintro _ ⟨x, hx, rfl⟩
exact H _ (IsLocalization.map_units _ ⟨x, hx⟩)
include M in
/--
Given a submodule `M ⊆ R` and a prime ideal `p` of `S = M⁻¹R`, with `f : R →+* S` the localization
map, then `T = Sₚ` is the localization of `R` at `f⁻¹(p)`.
-/
theorem isLocalization_isLocalization_atPrime_isLocalization (p : Ideal S) [Hp : p.IsPrime]
[IsLocalization.AtPrime T p] : IsLocalization.AtPrime T (p.comap (algebraMap R S)) := by
apply localization_localization_isLocalization_of_has_all_units M p.primeCompl T
intro x hx hx'
exact (Hp.1 : ¬_) (p.eq_top_of_isUnit_mem hx' hx)
instance (p : Ideal (Localization M)) [p.IsPrime] : Algebra R (Localization.AtPrime p) :=
inferInstance
instance (p : Ideal (Localization M)) [p.IsPrime] :
IsScalarTower R (Localization M) (Localization.AtPrime p) :=
IsScalarTower.of_algebraMap_eq' rfl
instance isLocalization_atPrime_localization_atPrime (p : Ideal (Localization M))
[p.IsPrime] : IsLocalization.AtPrime (Localization.AtPrime p) (p.comap (algebraMap R _)) :=
isLocalization_isLocalization_atPrime_isLocalization M _ _
/-- Given a submodule `M ⊆ R` and a prime ideal `p` of `M⁻¹R`, with `f : R →+* S` the localization
map, then `(M⁻¹R)ₚ` is isomorphic (as an `R`-algebra) to the localization of `R` at `f⁻¹(p)`.
-/
noncomputable def localizationLocalizationAtPrimeIsoLocalization (p : Ideal (Localization M))
[p.IsPrime] :
Localization.AtPrime (p.comap (algebraMap R (Localization M))) ≃ₐ[R] Localization.AtPrime p :=
IsLocalization.algEquiv (p.comap (algebraMap R (Localization M))).primeCompl _ _
end
variable (S)
/-- Given submonoids `M ≤ N` of `R`, this is the canonical algebra structure
of `M⁻¹S` acting on `N⁻¹S`. -/
noncomputable abbrev localizationAlgebraOfSubmonoidLe (M N : Submonoid R) (h : M ≤ N)
[IsLocalization M S] [IsLocalization N T] : Algebra S T :=
(@IsLocalization.lift R _ M S _ _ T _ _ (algebraMap R T)
(fun y => map_units T ⟨↑y, h y.prop⟩)).toAlgebra
/-- If `M ≤ N` are submonoids of `R`, then the natural map `M⁻¹S →+* N⁻¹S` commutes with the
localization maps -/
theorem localization_isScalarTower_of_submonoid_le (M N : Submonoid R) (h : M ≤ N)
[IsLocalization M S] [IsLocalization N T] :
@IsScalarTower R S T _ (localizationAlgebraOfSubmonoidLe S T M N h).toSMul _ :=
letI := localizationAlgebraOfSubmonoidLe S T M N h
IsScalarTower.of_algebraMap_eq' (IsLocalization.lift_comp _).symm
noncomputable instance instAlgebraLocalizationAtPrime (x : Ideal R) [H : x.IsPrime] [IsDomain R] :
Algebra (Localization.AtPrime x) (Localization (nonZeroDivisors R)) :=
localizationAlgebraOfSubmonoidLe _ _ x.primeCompl (nonZeroDivisors R)
(by
intro a ha
rw [mem_nonZeroDivisors_iff_ne_zero]
exact fun h => ha (h.symm ▸ x.zero_mem))
instance {R : Type*} [CommRing R] [IsDomain R] (p : Ideal R) [p.IsPrime] :
IsScalarTower R (Localization.AtPrime p) (FractionRing R) :=
localization_isScalarTower_of_submonoid_le (Localization.AtPrime p) (FractionRing R)
p.primeCompl (nonZeroDivisors R) p.primeCompl_le_nonZeroDivisors
/-- If `M ≤ N` are submonoids of `R`, then `N⁻¹S` is also the localization of `M⁻¹S` at `N`. -/
theorem isLocalization_of_submonoid_le (M N : Submonoid R) (h : M ≤ N) [IsLocalization M S]
[IsLocalization N T] [Algebra S T] [IsScalarTower R S T] :
IsLocalization (N.map (algebraMap R S)) T where
map_units := by
rintro ⟨_, ⟨y, hy, rfl⟩⟩
convert IsLocalization.map_units T ⟨y, hy⟩
exact (IsScalarTower.algebraMap_apply _ _ _ _).symm
surj y := by
obtain ⟨⟨x, s⟩, e⟩ := IsLocalization.surj N y
refine ⟨⟨algebraMap R S x, _, _, s.prop, rfl⟩, ?_⟩
simpa [← IsScalarTower.algebraMap_apply] using e
exists_of_eq {x₁ x₂} := by
obtain ⟨⟨y₁, s₁⟩, e₁⟩ := IsLocalization.surj M x₁
obtain ⟨⟨y₂, s₂⟩, e₂⟩ := IsLocalization.surj M x₂
refine (Set.exists_image_iff (algebraMap R S) N fun c => c * x₁ = c * x₂).mpr.comp ?_
dsimp only at e₁ e₂ ⊢
suffices algebraMap R T (y₁ * s₂) = algebraMap R T (y₂ * s₁) →
∃ a : N, algebraMap R S (a * (y₁ * s₂)) = algebraMap R S (a * (y₂ * s₁)) by
have h₁ := @IsUnit.mul_left_inj T _ _ (algebraMap S T x₁) (algebraMap S T x₂)
(IsLocalization.map_units T ⟨(s₁ : R), h s₁.prop⟩)
have h₂ := @IsUnit.mul_left_inj T _ _ ((algebraMap S T x₁) * (algebraMap R T s₁))
((algebraMap S T x₂) * (algebraMap R T s₁))
(IsLocalization.map_units T ⟨(s₂ : R), h s₂.prop⟩)
simp only [IsScalarTower.algebraMap_apply R S T] at h₁ h₂
simp only [IsScalarTower.algebraMap_apply R S T, map_mul, ← e₁, ← e₂, ← mul_assoc,
mul_right_comm _ (algebraMap R S s₂),
(IsLocalization.map_units S s₁).mul_left_inj,
(IsLocalization.map_units S s₂).mul_left_inj] at this
rw [h₂, h₁] at this
simpa only [mul_comm] using this
simp_rw [IsLocalization.eq_iff_exists N T, IsLocalization.eq_iff_exists M S]
intro ⟨a, e⟩
exact ⟨a, 1, by convert e using 1 <;> simp⟩
/-- If `M ≤ N` are submonoids of `R` such that `∀ x : N, ∃ m : R, m * x ∈ M`, then the
localization at `N` is equal to the localization of `M`. -/
theorem isLocalization_of_is_exists_mul_mem (M N : Submonoid R) [IsLocalization M S] (h : M ≤ N)
(h' : ∀ x : N, ∃ m : R, m * x ∈ M) : IsLocalization N S where
map_units y := by
obtain ⟨m, hm⟩ := h' y
have := IsLocalization.map_units S ⟨_, hm⟩
rw [map_mul] at this
exact (IsUnit.mul_iff.mp this).2
surj z := by
obtain ⟨⟨y, s⟩, e⟩ := IsLocalization.surj M z
exact ⟨⟨y, _, h s.prop⟩, e⟩
exists_of_eq {_ _} := by
rw [IsLocalization.eq_iff_exists M]
exact fun ⟨x, hx⟩ => ⟨⟨_, h x.prop⟩, hx⟩
theorem mk'_eq_algebraMap_mk'_of_submonoid_le {M N : Submonoid R} (h : M ≤ N) [IsLocalization M S]
[IsLocalization N T] [Algebra S T] [IsScalarTower R S T] (x : R) (y : {a : R // a ∈ M}) :
mk' T x ⟨y.1, h y.2⟩ = algebraMap S T (mk' S x y) :=
mk'_eq_iff_eq_mul.mpr (by simp only [IsScalarTower.algebraMap_apply R S T, ← map_mul, mk'_spec])
end LocalizationLocalization
end IsLocalization
namespace IsFractionRing
variable {R : Type*} [CommRing R] (M : Submonoid R)
open IsLocalization
theorem isFractionRing_of_isLocalization (S T : Type*) [CommRing S] [CommRing T] [Algebra R S]
[Algebra R T] [Algebra S T] [IsScalarTower R S T] [IsLocalization M S] [IsFractionRing R T]
(hM : M ≤ nonZeroDivisors R) : IsFractionRing S T := by
have := isLocalization_of_submonoid_le S T M (nonZeroDivisors R) hM
refine @isLocalization_of_is_exists_mul_mem _ _ _ _ _ _ _ this ?_ ?_
· exact map_nonZeroDivisors_le M S
· rintro ⟨x, -, hx⟩
obtain ⟨⟨y, s⟩, e⟩ := IsLocalization.surj M x
use algebraMap R S s
rw [mul_comm, Subtype.coe_mk, e]
refine Set.mem_image_of_mem (algebraMap R S) (mem_nonZeroDivisors_iff_right.mpr ?_)
intro z hz
apply IsLocalization.injective S hM
rw [map_zero]
apply hx
rw [← (map_units S s).mul_left_inj, mul_assoc, e, ← map_mul, hz, map_zero,
zero_mul]
theorem isFractionRing_of_isDomain_of_isLocalization [IsDomain R] (S T : Type*) [CommRing S]
[CommRing T] [Algebra R S] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
[IsLocalization M S] [IsFractionRing R T] : IsFractionRing S T := by
haveI := IsFractionRing.nontrivial R T
haveI := (algebraMap S T).domain_nontrivial
apply isFractionRing_of_isLocalization M S T
intro x hx
rw [mem_nonZeroDivisors_iff_ne_zero]
intro hx'
apply @zero_ne_one S
rw [← (algebraMap R S).map_one, ← @mk'_one R _ M, @comm _ Eq, mk'_eq_zero_iff]
exact ⟨⟨x, hx⟩, by simp [hx']⟩
instance {R : Type*} [CommRing R] [IsDomain R] (p : Ideal R) [p.IsPrime] :
IsFractionRing (Localization.AtPrime p) (FractionRing R) :=
IsFractionRing.isFractionRing_of_isDomain_of_isLocalization p.primeCompl
(Localization.AtPrime p) (FractionRing R)
end IsFractionRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Submodule.lean | import Mathlib.RingTheory.Localization.FractionRing
import Mathlib.RingTheory.Localization.Ideal
import Mathlib.RingTheory.Noetherian.Defs
import Mathlib.RingTheory.EssentialFiniteness
/-!
# Submodules in localizations of commutative rings
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommSemiring R] (M : Submonoid R) (S : Type*) [CommSemiring S]
variable [Algebra R S]
namespace IsLocalization
-- This was previously a `hasCoe` instance, but if `S = R` then this will loop.
-- It could be a `hasCoeT` instance, but we keep it explicit here to avoid slowing down
-- the rest of the library.
/-- Map from ideals of `R` to submodules of `S` induced by `f`. -/
def coeSubmodule (I : Ideal R) : Submodule R S :=
Submodule.map (Algebra.linearMap R S) I
theorem mem_coeSubmodule (I : Ideal R) {x : S} :
x ∈ coeSubmodule S I ↔ ∃ y : R, y ∈ I ∧ algebraMap R S y = x :=
Iff.rfl
theorem coeSubmodule_mono {I J : Ideal R} (h : I ≤ J) : coeSubmodule S I ≤ coeSubmodule S J :=
Submodule.map_mono h
@[simp]
theorem coeSubmodule_bot : coeSubmodule S (⊥ : Ideal R) = ⊥ := by
rw [coeSubmodule, Submodule.map_bot]
@[simp]
theorem coeSubmodule_top : coeSubmodule S (⊤ : Ideal R) = 1 := by
rw [coeSubmodule, Submodule.map_top, Submodule.one_eq_range]
@[simp]
theorem coeSubmodule_sup (I J : Ideal R) :
coeSubmodule S (I ⊔ J) = coeSubmodule S I ⊔ coeSubmodule S J :=
Submodule.map_sup _ _ _
@[simp]
theorem coeSubmodule_mul (I J : Ideal R) :
coeSubmodule S (I * J) = coeSubmodule S I * coeSubmodule S J :=
Submodule.map_mul _ _ (Algebra.ofId R S)
theorem coeSubmodule_fg (hS : Function.Injective (algebraMap R S)) (I : Ideal R) :
Submodule.FG (coeSubmodule S I) ↔ Submodule.FG I :=
⟨Submodule.fg_of_fg_map_injective _ hS, Submodule.FG.map _⟩
@[simp]
theorem coeSubmodule_span (s : Set R) :
coeSubmodule S (Ideal.span s) = Submodule.span R (algebraMap R S '' s) := by
rw [IsLocalization.coeSubmodule, Ideal.span, Submodule.map_span]
rfl
theorem coeSubmodule_span_singleton (x : R) :
coeSubmodule S (Ideal.span {x}) = Submodule.span R {(algebraMap R S) x} := by
rw [coeSubmodule_span, Set.image_singleton]
variable [IsLocalization M S]
include M in
theorem isNoetherianRing (h : IsNoetherianRing R) : IsNoetherianRing S := by
rw [isNoetherianRing_iff, isNoetherian_iff] at h ⊢
exact OrderEmbedding.wellFounded (IsLocalization.orderEmbedding M S).dual h
instance {R} [CommRing R] [IsNoetherianRing R] (S : Submonoid R) :
IsNoetherianRing (Localization S) :=
IsLocalization.isNoetherianRing S _ ‹_›
lemma _root_.Algebra.EssFiniteType.isNoetherianRing
(R S : Type*) [CommRing R] [CommRing S] [Algebra R S]
[Algebra.EssFiniteType R S] [IsNoetherianRing R] : IsNoetherianRing S := by
exact IsLocalization.isNoetherianRing (Algebra.EssFiniteType.submonoid R S) _
(Algebra.FiniteType.isNoetherianRing R _)
section NonZeroDivisors
variable {R : Type*} [CommRing R] {M : Submonoid R}
{S : Type*} [CommRing S] [Algebra R S] [IsLocalization M S]
@[mono]
theorem coeSubmodule_le_coeSubmodule (h : M ≤ nonZeroDivisors R) {I J : Ideal R} :
coeSubmodule S I ≤ coeSubmodule S J ↔ I ≤ J :=
-- Note: https://github.com/leanprover-community/mathlib4/pull/8386 had to specify the value of `f` here:
Submodule.map_le_map_iff_of_injective (f := Algebra.linearMap R S) (IsLocalization.injective _ h)
_ _
@[mono]
theorem coeSubmodule_strictMono (h : M ≤ nonZeroDivisors R) :
StrictMono (coeSubmodule S : Ideal R → Submodule R S) :=
strictMono_of_le_iff_le fun _ _ => (coeSubmodule_le_coeSubmodule h).symm
variable (S)
theorem coeSubmodule_injective (h : M ≤ nonZeroDivisors R) :
Function.Injective (coeSubmodule S : Ideal R → Submodule R S) :=
injective_of_le_imp_le _ fun hl => (coeSubmodule_le_coeSubmodule h).mp hl
theorem coeSubmodule_isPrincipal {I : Ideal R} (h : M ≤ nonZeroDivisors R) :
(coeSubmodule S I).IsPrincipal ↔ I.IsPrincipal := by
constructor <;> rintro ⟨⟨x, hx⟩⟩
· have x_mem : x ∈ coeSubmodule S I := hx.symm ▸ Submodule.mem_span_singleton_self x
obtain ⟨x, _, rfl⟩ := (mem_coeSubmodule _ _).mp x_mem
refine ⟨⟨x, coeSubmodule_injective S h ?_⟩⟩
rw [Ideal.submodule_span_eq, hx, coeSubmodule_span_singleton]
· refine ⟨⟨algebraMap R S x, ?_⟩⟩
rw [hx, Ideal.submodule_span_eq, coeSubmodule_span_singleton]
end NonZeroDivisors
variable {S}
theorem mem_span_iff {N : Type*} [AddCommMonoid N] [Module R N] [Module S N] [IsScalarTower R S N]
{x : N} {a : Set N} :
x ∈ Submodule.span S a ↔ ∃ y ∈ Submodule.span R a, ∃ z : M, x = mk' S 1 z • y := by
constructor
· intro h
refine Submodule.span_induction ?_ ?_ ?_ ?_ h
· rintro x hx
exact ⟨x, Submodule.subset_span hx, 1, by rw [mk'_one, map_one, one_smul]⟩
· exact ⟨0, Submodule.zero_mem _, 1, by rw [mk'_one, map_one, one_smul]⟩
· rintro _ _ _ _ ⟨y, hy, z, rfl⟩ ⟨y', hy', z', rfl⟩
refine
⟨(z' : R) • y + (z : R) • y',
Submodule.add_mem _ (Submodule.smul_mem _ _ hy) (Submodule.smul_mem _ _ hy'), z * z', ?_⟩
rw [smul_add, ← IsScalarTower.algebraMap_smul S (z : R), ←
IsScalarTower.algebraMap_smul S (z' : R), smul_smul, smul_smul]
congr 1
· rw [← mul_one (1 : R), mk'_mul, mul_assoc, mk'_spec, map_one, mul_one, mul_one]
· rw [← mul_one (1 : R), mk'_mul, mul_right_comm, mk'_spec, map_one, mul_one, one_mul]
· rintro a _ _ ⟨y, hy, z, rfl⟩
obtain ⟨y', z', rfl⟩ := exists_mk'_eq M a
refine ⟨y' • y, Submodule.smul_mem _ _ hy, z' * z, ?_⟩
rw [← IsScalarTower.algebraMap_smul S y', smul_smul, ← mk'_mul, smul_smul,
mul_comm (mk' S _ _), mul_mk'_eq_mk'_of_mul]
· rintro ⟨y, hy, z, rfl⟩
exact Submodule.smul_mem _ _ (Submodule.span_subset_span R S _ hy)
theorem mem_span_map {x : S} {a : Set R} :
x ∈ Ideal.span (algebraMap R S '' a) ↔ ∃ y ∈ Ideal.span a, ∃ z : M, x = mk' S y z := by
refine (mem_span_iff M).trans ?_
constructor
· rw [← coeSubmodule_span]
rintro ⟨_, ⟨y, hy, rfl⟩, z, hz⟩
refine ⟨y, hy, z, ?_⟩
rw [hz, Algebra.linearMap_apply, smul_eq_mul, mul_comm, mul_mk'_eq_mk'_of_mul, mul_one]
· rintro ⟨y, hy, z, hz⟩
refine ⟨algebraMap R S y, Submodule.map_mem_span_algebraMap_image _ _ hy, z, ?_⟩
rw [hz, smul_eq_mul, mul_comm, mul_mk'_eq_mk'_of_mul, mul_one]
end IsLocalization
namespace IsFractionRing
open IsLocalization
variable {R K : Type*}
section CommRing
variable [CommRing R] [CommRing K] [Algebra R K] [IsFractionRing R K]
@[simp, mono]
theorem coeSubmodule_le_coeSubmodule {I J : Ideal R} :
coeSubmodule K I ≤ coeSubmodule K J ↔ I ≤ J :=
IsLocalization.coeSubmodule_le_coeSubmodule le_rfl
@[mono]
theorem coeSubmodule_strictMono : StrictMono (coeSubmodule K : Ideal R → Submodule R K) :=
strictMono_of_le_iff_le fun _ _ => coeSubmodule_le_coeSubmodule.symm
variable (R K)
theorem coeSubmodule_injective : Function.Injective (coeSubmodule K : Ideal R → Submodule R K) :=
injective_of_le_imp_le _ fun hl => coeSubmodule_le_coeSubmodule.mp hl
@[simp]
theorem coeSubmodule_isPrincipal {I : Ideal R} : (coeSubmodule K I).IsPrincipal ↔ I.IsPrincipal :=
IsLocalization.coeSubmodule_isPrincipal _ le_rfl
end CommRing
end IsFractionRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Algebra.lean | import Mathlib.Algebra.Module.LocalizedModule.IsLocalization
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Localization.BaseChange
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.Localization.Ideal
import Mathlib.RingTheory.PolynomialAlgebra
/-!
# Localization of algebra maps
In this file we provide constructors to localize algebra maps. Also we show that
localization commutes with taking kernels for ring homomorphisms.
## Implementation detail
The proof that localization commutes with taking kernels does not use the result for linear maps,
as the translation is currently tedious and can be unified easily after the localization refactor.
-/
variable {R S P : Type*} (Q : Type*) [CommSemiring R] [CommSemiring S] [CommSemiring P]
[CommSemiring Q]
{M : Submonoid R} {T : Submonoid P}
[Algebra R S] [Algebra P Q] [IsLocalization M S] [IsLocalization T Q]
(g : R →+* P)
open IsLocalization in
variable (M S) in
/-- The span of `I` in a localization of `R` at `M` is the localization of `I` at `M`. -/
-- TODO: golf using `Ideal.localized'_eq_map`
instance Algebra.idealMap_isLocalizedModule (I : Ideal R) :
IsLocalizedModule M (Algebra.idealMap I (S := S)) where
map_units x :=
(Module.End.isUnit_iff _).mpr ⟨fun a b e ↦ Subtype.ext ((map_units S x).mul_right_injective
(by simpa [Algebra.smul_def] using congr(($e).1))),
fun a ↦ ⟨⟨_, Ideal.mul_mem_left _ (map_units S x).unit⁻¹.1 a.2⟩,
Subtype.ext (by simp [Algebra.smul_def, ← mul_assoc])⟩⟩
surj y :=
have ⟨x, hx⟩ := (mem_map_algebraMap_iff M S).mp y.property
⟨x, Subtype.ext (by simp [Submonoid.smul_def, Algebra.smul_def, mul_comm, hx])⟩
exists_of_eq h := ⟨_, Subtype.ext (exists_of_eq congr(($h).1)).choose_spec⟩
lemma IsLocalization.ker_map (hT : Submonoid.map g M = T) :
RingHom.ker (IsLocalization.map Q g (hT.symm ▸ M.le_comap_map) : S →+* Q) =
(RingHom.ker g).map (algebraMap R S) := by
ext x
obtain ⟨x, s, rfl⟩ := IsLocalization.exists_mk'_eq M x
simp [RingHom.mem_ker, IsLocalization.map_mk', IsLocalization.mk'_eq_zero_iff,
IsLocalization.mk'_mem_map_algebraMap_iff, ← hT]
variable (S) in
/-- The canonical linear map from the kernel of `g` to the kernel of its localization. -/
noncomputable def RingHom.toKerIsLocalization (hy : M ≤ Submonoid.comap g T) :
RingHom.ker g →ₗ[R] RingHom.ker (IsLocalization.map Q g hy : S →+* Q) where
toFun x := ⟨algebraMap R S x, by simp [RingHom.mem_ker, RingHom.mem_ker.mp x.property]⟩
map_add' x y := by
simp only [Submodule.coe_add, map_add, AddMemClass.mk_add_mk]
map_smul' a x := by
simp only [SetLike.val_smul, smul_eq_mul, map_mul, id_apply, SetLike.mk_smul_of_tower_mk,
Algebra.smul_def]
@[simp]
lemma RingHom.toKerIsLocalization_apply (hy : M ≤ Submonoid.comap g T) (r : RingHom.ker g) :
(RingHom.toKerIsLocalization S Q g hy r).val = algebraMap R S r :=
rfl
/-- The canonical linear map from the kernel of `g` to the kernel of its localization
is localizing. In other words, localization commutes with taking kernels. -/
lemma RingHom.toKerIsLocalization_isLocalizedModule (hT : Submonoid.map g M = T) :
IsLocalizedModule M (toKerIsLocalization S Q g (hT.symm ▸ Submonoid.le_comap_map M)) := by
let e := LinearEquiv.ofEq _ _ (IsLocalization.ker_map (S := S) Q g hT).symm
convert_to IsLocalizedModule M ((e.restrictScalars R).toLinearMap ∘ₗ
Algebra.idealMap S (RingHom.ker g))
apply IsLocalizedModule.of_linearEquiv
section Algebra
open Algebra
variable {R : Type*} [CommSemiring R] (M : Submonoid R)
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable {B : Type*} [CommSemiring B] [Algebra R B]
variable (Rₚ : Type*) [CommSemiring Rₚ] [Algebra R Rₚ] [IsLocalization M Rₚ]
variable (Aₚ : Type*) [CommSemiring Aₚ] [Algebra R Aₚ] [Algebra A Aₚ] [IsScalarTower R A Aₚ]
[IsLocalization (Algebra.algebraMapSubmonoid A M) Aₚ]
variable (Bₚ : Type*) [CommSemiring Bₚ] [Algebra R Bₚ] [Algebra B Bₚ] [IsScalarTower R B Bₚ]
[IsLocalization (Algebra.algebraMapSubmonoid B M) Bₚ]
variable [Algebra Rₚ Aₚ] [Algebra Rₚ Bₚ] [IsScalarTower R Rₚ Aₚ] [IsScalarTower R Rₚ Bₚ]
namespace IsLocalization
instance isLocalization_algebraMapSubmonoid_map_algHom (f : A →ₐ[R] B) :
IsLocalization ((algebraMapSubmonoid A M).map f.toRingHom) Bₚ := by
rw [AlgHom.toRingHom_eq_coe, ← Submonoid.map_coe_toMonoidHom, AlgHom.toRingHom_toMonoidHom,
Submonoid.map_coe_toMonoidHom, algebraMapSubmonoid_map_eq M f]
infer_instance
/-- An algebra map `A →ₐ[R] B` induces an algebra map on localizations `Aₚ →ₐ[Rₚ] Bₚ`. -/
noncomputable def mapₐ (f : A →ₐ[R] B) : Aₚ →ₐ[Rₚ] Bₚ :=
⟨IsLocalization.map Bₚ f.toRingHom (Algebra.algebraMapSubmonoid_le_comap M f), fun r ↦ by
obtain ⟨a, m, rfl⟩ := IsLocalization.exists_mk'_eq M r
simp [algebraMap_mk' (S := A), algebraMap_mk' (S := B), map_mk']⟩
@[simp]
lemma mapₐ_coe (f : A →ₐ[R] B) :
(mapₐ M Rₚ Aₚ Bₚ f : Aₚ → Bₚ) = map Bₚ f.toRingHom (algebraMapSubmonoid_le_comap M f) :=
rfl
lemma mapₐ_injective_of_injective (f : A →ₐ[R] B) (hf : Function.Injective f) :
Function.Injective (mapₐ M Rₚ Aₚ Bₚ f) :=
IsLocalization.map_injective_of_injective _ _ _ hf
lemma mapₐ_surjective_of_surjective (f : A →ₐ[R] B) (hf : Function.Surjective f) :
Function.Surjective (mapₐ M Rₚ Aₚ Bₚ f) :=
IsLocalization.map_surjective_of_surjective _ _ _ hf
section
/-- Localizing the underlying linear map of `A →ₐ[R] B` in the sense of `IsLocalizedModule`
is the same as taking the underlying linear map of the localization in the sense of
`IsLocalization`. -/
lemma mapExtendScalars_eq_toLinearMap_mapₐ (f : A →ₐ[R] B) :
IsLocalizedModule.mapExtendScalars M (IsScalarTower.toAlgHom R A Aₚ).toLinearMap
(IsScalarTower.toAlgHom R B Bₚ).toLinearMap Rₚ f.toLinearMap =
(IsLocalization.mapₐ M Rₚ Aₚ Bₚ f).toLinearMap := by
refine LinearMap.restrictScalars_injective R ?_
apply IsLocalizedModule.linearMap_ext M
(IsScalarTower.toAlgHom R A Aₚ).toLinearMap
((IsScalarTower.toAlgHom R B Bₚ).toLinearMap)
ext x
rw [LinearMap.coe_comp, LinearMap.coe_restrictScalars, Function.comp_apply,
IsLocalizedModule.mapExtendScalars_apply_apply, IsLocalizedModule.map_apply]
simp
/-- Less linear version of `mapExtendScalars_eq_toLinearMap_mapₐ`.
For a version where `R = A`, see `map_linearMap_eq_toLinearMap_mapₐ`. -/
lemma map_eq_toLinearMap_mapₐ (f : A →ₐ[R] B) :
IsLocalizedModule.map M (IsScalarTower.toAlgHom R A Aₚ).toLinearMap
(IsScalarTower.toAlgHom R B Bₚ).toLinearMap f.toLinearMap =
(IsLocalization.mapₐ M Rₚ Aₚ Bₚ f).toLinearMap := by
ext x
exact DFunLike.congr_fun (mapExtendScalars_eq_toLinearMap_mapₐ M Rₚ Aₚ Bₚ f) x
lemma map_linearMap_eq_toLinearMap_mapₐ :
IsLocalizedModule.map M (Algebra.linearMap R Rₚ) (IsScalarTower.toAlgHom R A Aₚ).toLinearMap
(Algebra.linearMap R A) = (IsLocalization.mapₐ M Rₚ Rₚ Aₚ (Algebra.ofId R A)).toLinearMap :=
map_eq_toLinearMap_mapₐ M Rₚ Rₚ Aₚ (Algebra.ofId R A)
end
end IsLocalization
open IsLocalization
/-- The canonical linear map from the kernel of an algebra homomorphism to its localization. -/
noncomputable def AlgHom.toKerIsLocalization (f : A →ₐ[R] B) :
RingHom.ker f →ₗ[A] RingHom.ker (mapₐ M Rₚ Aₚ Bₚ f) :=
RingHom.toKerIsLocalization Aₚ Bₚ f.toRingHom (algebraMapSubmonoid_le_comap M f)
@[simp]
lemma AlgHom.toKerIsLocalization_apply (f : A →ₐ[R] B) (x : RingHom.ker f) :
AlgHom.toKerIsLocalization M Rₚ Aₚ Bₚ f x =
RingHom.toKerIsLocalization Aₚ Bₚ f.toRingHom (algebraMapSubmonoid_le_comap M f) x :=
rfl
/-- The canonical linear map from the kernel of an algebra homomorphism to its localization
is localizing. -/
lemma AlgHom.toKerIsLocalization_isLocalizedModule (f : A →ₐ[R] B) :
IsLocalizedModule (Algebra.algebraMapSubmonoid A M)
(AlgHom.toKerIsLocalization M Rₚ Aₚ Bₚ f) :=
RingHom.toKerIsLocalization_isLocalizedModule Bₚ f.toRingHom
(algebraMapSubmonoid_map_eq M f)
end Algebra
namespace Polynomial
/-- If `A` is the localization of `R` at a submonoid `S`, then `A[X]` is the localization of
`R[X]` at `S.map Polynomial.C`.
See also `MvPolynomial.isLocalization` for the multivariate case. -/
lemma isLocalization {R} [CommSemiring R] (S : Submonoid R) (A) [CommSemiring A] [Algebra R A]
[IsLocalization S A] : letI := (mapRingHom (algebraMap R A)).toAlgebra
IsLocalization (S.map C) A[X] :=
letI := (mapRingHom (algebraMap R A)).toAlgebra
have : IsScalarTower R R[X] A[X] := .of_algebraMap_eq fun _ ↦ (map_C _).symm
isLocalizedModule_iff_isLocalization.mp <| (isLocalizedModule_iff_isBaseChange S A _).mpr <|
.of_equiv (polyEquivTensor' R A).symm.toLinearEquiv fun _ ↦ by simp
end Polynomial |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/BaseChange.lean | import Mathlib.LinearAlgebra.DirectSum.Finsupp
import Mathlib.RingTheory.IsTensorProduct
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Localization.Module
/-!
# Localized Module
Given a commutative semiring `R`, a multiplicative subset `S ⊆ R` and an `R`-module `M`, we can
localize `M` by `S`. This gives us a `Localization S`-module.
## Main definition
* `isLocalizedModule_iff_isBaseChange` : A localization of modules corresponds to a base change.
-/
variable {R : Type*} [CommSemiring R] (S : Submonoid R)
(A : Type*) [CommSemiring A] [Algebra R A] [IsLocalization S A]
{M : Type*} [AddCommMonoid M] [Module R M]
{M' : Type*} [AddCommMonoid M'] [Module R M'] [Module A M'] [IsScalarTower R A M']
(f : M →ₗ[R] M')
/-- The forward direction of `isLocalizedModule_iff_isBaseChange`. It is also used to prove the
other direction. -/
theorem IsLocalizedModule.isBaseChange [IsLocalizedModule S f] : IsBaseChange A f :=
.of_lift_unique _ fun Q _ _ _ _ g ↦ by
obtain ⟨ℓ, rfl, h₂⟩ := IsLocalizedModule.is_universal S f g fun s ↦ by
rw [← (Algebra.lsmul R (A := A) R Q).commutes]; exact (IsLocalization.map_units A s).map _
refine ⟨ℓ.extendScalarsOfIsLocalization S A, by simp, fun g'' h ↦ ?_⟩
cases h₂ (LinearMap.restrictScalars R g'') h; rfl
/-- The map `(f : M →ₗ[R] M')` is a localization of modules iff the map
`(Localization S) × M → N, (s, m) ↦ s • f m` is the tensor product (insomuch as it is the universal
bilinear map).
In particular, there is an isomorphism between `LocalizedModule S M` and `(Localization S) ⊗[R] M`
given by `m/s ↦ (1/s) ⊗ₜ m`.
-/
theorem isLocalizedModule_iff_isBaseChange : IsLocalizedModule S f ↔ IsBaseChange A f := by
refine ⟨fun _ ↦ IsLocalizedModule.isBaseChange S A f, fun h ↦ ?_⟩
have : IsBaseChange A (LocalizedModule.mkLinearMap S M) := IsLocalizedModule.isBaseChange S A _
let e := (this.equiv.symm.trans h.equiv).restrictScalars R
convert IsLocalizedModule.of_linearEquiv S (LocalizedModule.mkLinearMap S M) e
ext
rw [LinearMap.coe_comp, LinearEquiv.coe_coe, Function.comp_apply,
LinearEquiv.restrictScalars_apply, LinearEquiv.trans_apply, IsBaseChange.equiv_symm_apply,
IsBaseChange.equiv_tmul, one_smul]
open TensorProduct
variable (M) in
/-- The localization of an `R`-module `M` at a submonoid `S` is isomorphic to `S⁻¹R ⊗[R] M` as
an `S⁻¹R`-module. -/
noncomputable def LocalizedModule.equivTensorProduct :
LocalizedModule S M ≃ₗ[Localization S] Localization S ⊗[R] M :=
IsLocalizedModule.isBaseChange S (Localization S)
(LocalizedModule.mkLinearMap S M) |>.equiv.symm
@[simp]
lemma LocalizedModule.equivTensorProduct_symm_apply_tmul (x : M) (r : R) (s : S) :
(equivTensorProduct S M).symm (Localization.mk r s ⊗ₜ[R] x) = r • mk x s := by
simp [equivTensorProduct, IsBaseChange.equiv_tmul, mk_smul_mk, smul'_mk]
@[simp]
lemma LocalizedModule.equivTensorProduct_symm_apply_tmul_one (x : M) :
(equivTensorProduct S M).symm (1 ⊗ₜ[R] x) = mk x 1 := by
simp [← Localization.mk_one]
@[simp]
lemma LocalizedModule.equivTensorProduct_apply_mk (x : M) (s : S) :
equivTensorProduct S M (mk x s) = Localization.mk 1 s ⊗ₜ[R] x := by
apply (equivTensorProduct S M).symm.injective
simp
namespace IsLocalization
open TensorProduct Algebra.TensorProduct
instance tensorProduct_isLocalizedModule : IsLocalizedModule S (TensorProduct.mk R A M 1) :=
(isLocalizedModule_iff_isBaseChange _ A _).mpr (TensorProduct.isBaseChange _ _ _)
variable (M₁ M₂ B C) [AddCommMonoid M₁] [AddCommMonoid M₂] [Module R M₁] [Module R M₂]
[Module A M₁] [Module A M₂] [IsScalarTower R A M₁] [IsScalarTower R A M₂]
[Semiring B] [Algebra R B] [Algebra A B] [IsScalarTower R A B]
[Semiring C] [Algebra R C] [Algebra A C] [IsScalarTower R A C]
include S
theorem tensorProduct_compatibleSMul : CompatibleSMul R A M₁ M₂ where
smul_tmul a _ _ := by
obtain ⟨r, s, rfl⟩ := exists_mk'_eq S a
rw [← (map_units A s).smul_left_cancel]
simp_rw [algebraMap_smul, smul_tmul', ← smul_assoc, smul_tmul, ← smul_assoc, smul_mk'_self,
algebraMap_smul, smul_tmul]
instance [Module (Localization S) M₁] [Module (Localization S) M₂]
[IsScalarTower R (Localization S) M₁] [IsScalarTower R (Localization S) M₂] :
CompatibleSMul R (Localization S) M₁ M₂ :=
tensorProduct_compatibleSMul S ..
instance (N N') [AddCommMonoid N] [Module R N] [AddCommMonoid N'] [Module R N'] (g : N →ₗ[R] N')
[IsLocalizedModule S f] [IsLocalizedModule S g] :
IsLocalizedModule S (TensorProduct.map f g) := by
let eM := IsLocalizedModule.linearEquiv S f (TensorProduct.mk R (Localization S) M 1)
let eN := IsLocalizedModule.linearEquiv S g (TensorProduct.mk R (Localization S) N 1)
convert IsLocalizedModule.of_linearEquiv S (TensorProduct.mk R (Localization S) (M ⊗[R] N) 1) <|
(AlgebraTensorModule.distribBaseChange R (Localization S) ..).restrictScalars R ≪≫ₗ
(congr eM eN ≪≫ₗ TensorProduct.equivOfCompatibleSMul ..).symm
ext; congrm(?_ ⊗ₜ ?_) <;> simp [LinearEquiv.eq_symm_apply, eM, eN]
/-- If `A` is a localization of `R`, tensoring two `A`-modules over `A` is the same as
tensoring them over `R`. -/
noncomputable def moduleTensorEquiv : M₁ ⊗[A] M₂ ≃ₗ[A] M₁ ⊗[R] M₂ :=
have := tensorProduct_compatibleSMul S A M₁ M₂
equivOfCompatibleSMul R A M₁ M₂
/-- If `A` is a localization of `R`, tensoring an `A`-module with `A` over `R` does nothing. -/
noncomputable def moduleLid : A ⊗[R] M₁ ≃ₗ[A] M₁ :=
have := tensorProduct_compatibleSMul S A A M₁
(equivOfCompatibleSMul R A A M₁).symm ≪≫ₗ TensorProduct.lid _ _
/-- If `A` is a localization of `R`, tensoring two `A`-algebras over `A` is the same as
tensoring them over `R`. -/
noncomputable def algebraTensorEquiv : B ⊗[A] C ≃ₐ[A] B ⊗[R] C :=
have := tensorProduct_compatibleSMul S A B C
Algebra.TensorProduct.equivOfCompatibleSMul R A B C
/-- If `A` is a localization of `R`, tensoring an `A`-algebra with `A` over `R` does nothing. -/
noncomputable def algebraLid : A ⊗[R] B ≃ₐ[A] B :=
have := tensorProduct_compatibleSMul S A A B
Algebra.TensorProduct.lidOfCompatibleSMul R A B
set_option linter.docPrime false in
theorem bijective_linearMap_mul' : Function.Bijective (LinearMap.mul' R A) :=
have := tensorProduct_compatibleSMul S A A A
(Algebra.TensorProduct.lmulEquiv R A).bijective
end IsLocalization
variable (T B : Type*) [CommSemiring T] [CommSemiring B]
[Algebra R T] [Algebra T B] [Algebra R B] [Algebra A B] [IsScalarTower R T B]
[IsScalarTower R A B]
variable {T B} in
lemma Algebra.isLocalization_iff_isPushout :
IsLocalization (Algebra.algebraMapSubmonoid T S) B ↔ IsPushout R T A B := by
rw [Algebra.IsPushout.comm, Algebra.isPushout_iff, ← isLocalizedModule_iff_isLocalization]
rw [← isLocalizedModule_iff_isBaseChange (S := S)]
lemma Algebra.isPushout_of_isLocalization [IsLocalization (Algebra.algebraMapSubmonoid T S) B] :
Algebra.IsPushout R T A B :=
(Algebra.isLocalization_iff_isPushout S _).mp inferInstance
variable (R M) in
open TensorProduct in
instance {α} [IsLocalizedModule S f] :
IsLocalizedModule S (Finsupp.mapRange.linearMap (α := α) f) := by
classical
let e : Localization S ⊗[R] M ≃ₗ[R] M' :=
(LocalizedModule.equivTensorProduct S M).symm.restrictScalars R ≪≫ₗ IsLocalizedModule.iso S f
let e' : Localization S ⊗[R] (α →₀ M) ≃ₗ[R] (α →₀ M') :=
finsuppRight R (Localization S) M α ≪≫ₗ Finsupp.mapRange.linearEquiv e
suffices IsLocalizedModule S (e'.symm.toLinearMap ∘ₗ Finsupp.mapRange.linearMap f) by
convert this.of_linearEquiv (e := e')
ext
simp
rw [isLocalizedModule_iff_isBaseChange S (Localization S)]
convert TensorProduct.isBaseChange R (α →₀ M) (Localization S) using 1
ext a m
apply (finsuppRight R (Localization S) M α).injective
ext b
apply e.injective
suffices (if a = b then f m else 0) = e (1 ⊗ₜ[R] if a = b then m else 0) by
simpa [e', Finsupp.single_apply, -EmbeddingLike.apply_eq_iff_eq, apply_ite e]
split_ifs with h
· simp [e]
· simp only [tmul_zero, map_zero]
open Finsupp in
theorem IsLocalizedModule.map_linearCombination {α : Type*} {v : α → M} [IsLocalizedModule S f] :
map S (mapRange.linearMap (Algebra.linearMap R A)) f (linearCombination R v) =
linearCombination A (f ∘ v) :=
linearMap_ext (S := S) (mapRange.linearMap (Algebra.linearMap R A)) f <| by
ext; simp [IsLocalizedModule.map_comp]
section
variable (S : Submonoid A) {N : Type*} [AddCommMonoid N] [Module R N]
variable [Module A M] [IsScalarTower R A M]
open TensorProduct
/-- `S⁻¹M ⊗[R] N = S⁻¹(M ⊗[R] N)`. -/
instance IsLocalizedModule.rTensor (g : M →ₗ[A] M') [h : IsLocalizedModule S g] :
IsLocalizedModule S (AlgebraTensorModule.rTensor R N g) := by
let Aₚ := Localization S
letI : Module Aₚ M' := (IsLocalizedModule.iso S g).symm.toAddEquiv.module Aₚ
haveI : IsScalarTower A Aₚ M' := (IsLocalizedModule.iso S g).symm.isScalarTower Aₚ
haveI : IsScalarTower R Aₚ M' :=
IsScalarTower.of_algebraMap_smul <| fun r x ↦ by simp [IsScalarTower.algebraMap_apply R A Aₚ]
rw [isLocalizedModule_iff_isBaseChange (S := S) (A := Aₚ)] at h ⊢
exact isBaseChange_tensorProduct_map _ h
variable {P : Type*} [AddCommMonoid P] [Module R P] (f : N →ₗ[R] P)
lemma IsLocalizedModule.map_lTensor (g : M →ₗ[A] M') [h : IsLocalizedModule S g] :
IsLocalizedModule.map S (AlgebraTensorModule.rTensor R N g) (AlgebraTensorModule.rTensor R P g)
(AlgebraTensorModule.lTensor A M f) = AlgebraTensorModule.lTensor A M' f := by
apply linearMap_ext S (AlgebraTensorModule.rTensor R N g) (AlgebraTensorModule.rTensor R P g)
rw [map_comp]
ext
simp
end
section
variable {R S : Type*} [CommSemiring R] [CommSemiring S] [Algebra R S]
(r : R) (A : Type*) [CommSemiring A] [Algebra R A]
instance IsLocalization.tensor (M : Submonoid R) [IsLocalization M A] :
IsLocalization (Algebra.algebraMapSubmonoid S M) (S ⊗[R] A) := by
let _ : Algebra A (S ⊗[R] A) := Algebra.TensorProduct.rightAlgebra
rw [Algebra.isLocalization_iff_isPushout _ A]
infer_instance
attribute [local instance] Algebra.TensorProduct.rightAlgebra
instance IsLocalization.tensorRight (M : Submonoid R) [IsLocalization M A] :
IsLocalization (Algebra.algebraMapSubmonoid S M) (A ⊗[R] S) := by
rw [Algebra.isLocalization_iff_isPushout _ A]
infer_instance
open Algebra.TensorProduct in
lemma IsLocalization.tmul_mk' (M : Submonoid R) [IsLocalization M A] (s : S) (x : R) (y : M) :
s ⊗ₜ IsLocalization.mk' A x y =
IsLocalization.mk' (S ⊗[R] A) (algebraMap R S x * s)
⟨algebraMap R S y.1, Algebra.mem_algebraMapSubmonoid_of_mem _⟩ := by
rw [IsLocalization.eq_mk'_iff_mul_eq, algebraMap_apply, Algebra.algebraMap_self,
RingHomCompTriple.comp_apply, tmul_one_eq_one_tmul, tmul_mul_tmul, mul_one, mul_comm,
IsLocalization.mk'_spec', algebraMap_apply, Algebra.algebraMap_self, RingHom.id_apply,
← Algebra.smul_def, smul_tmul, Algebra.smul_def, mul_one]
open Algebra.TensorProduct in
lemma IsLocalization.mk'_tmul (M : Submonoid R) [IsLocalization M A] (s : S) (x : R) (y : M) :
IsLocalization.mk' A x y ⊗ₜ s =
IsLocalization.mk' (A ⊗[R] S) (algebraMap R S x * s)
⟨algebraMap R S y.1, Algebra.mem_algebraMapSubmonoid_of_mem _⟩ := by
simp [IsLocalization.eq_mk'_iff_mul_eq, map_mul,
RingHom.algebraMap_toAlgebra]
namespace IsLocalization.Away
instance tensor [IsLocalization.Away r A] :
IsLocalization.Away (algebraMap R S r) (S ⊗[R] A) := by
simp only [IsLocalization.Away, ← Algebra.algebraMapSubmonoid_powers]
infer_instance
variable (S) in
/-- The `S`-isomorphism `S ⊗[R] Rᵣ ≃ₐ Sᵣ`. -/
noncomputable abbrev tensorEquiv [IsLocalization.Away r A] :
S ⊗[R] A ≃ₐ[S] Localization.Away (algebraMap R S r) :=
IsLocalization.algEquiv (Submonoid.powers <| algebraMap R S r) _ _
attribute [local instance] Algebra.TensorProduct.rightAlgebra
instance tensorRight [IsLocalization.Away r A] :
IsLocalization.Away (algebraMap R S r) (A ⊗[R] S) := by
simp only [IsLocalization.Away, ← Algebra.algebraMapSubmonoid_powers]
infer_instance
variable (S) in
/-- The `S`-isomorphism `S ⊗[R] Rᵣ ≃ₐ Sᵣ`. -/
noncomputable abbrev tensorRightEquiv [IsLocalization.Away r A] :
A ⊗[R] S ≃ₐ[S] Localization.Away (algebraMap R S r) :=
IsLocalization.algEquiv (Submonoid.powers <| algebraMap R S r) _ _
end IsLocalization.Away
end |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Free.lean | import Mathlib.Algebra.Module.FinitePresentation
import Mathlib.RingTheory.Localization.Finiteness
import Mathlib.LinearAlgebra.FreeModule.StrongRankCondition
import Mathlib.LinearAlgebra.Dimension.StrongRankCondition
/-!
# Free modules and localization
## Main result
- `Module.FinitePresentation.exists_free_localizedModule_powers`:
If `M` is a finitely presented `R`-module
such that `Mₛ` is free over `Rₛ` for some `S : Submonoid R`,
then `Mᵣ` is already free over `Rᵣ` for some `r ∈ S`.
## Future projects
- Show that a finitely presented flat module has locally constant dimension.
- Show that the flat locus of a finitely presented module is open.
-/
variable {R M N N'} [CommRing R] [AddCommGroup M] [Module R M] [AddCommGroup N] [Module R N]
variable (S : Submonoid R) [AddCommGroup N'] [Module R N']
variable {M' : Type*} [AddCommGroup M'] [Module R M'] (f : M →ₗ[R] M') [IsLocalizedModule S f]
variable {N' : Type*} [AddCommGroup N'] [Module R N'] (g : N →ₗ[R] N') [IsLocalizedModule S g]
include f in
/--
If `M` is a finitely presented `R`-module,
then any `Rₛ`-basis of `Mₛ` for some `S : Submonoid R` can be lifted to
a `Rᵣ`-basis of `Mᵣ` for some `r ∈ S`.
-/
lemma Module.FinitePresentation.exists_basis_localizedModule_powers
(Rₛ) [CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ M'] [IsScalarTower R Rₛ M']
[IsLocalization S Rₛ] [Module.FinitePresentation R M]
{I} [Finite I] (b : Basis I Rₛ M') :
∃ (r : R) (hr : r ∈ S)
(b' : Basis I (Localization (.powers r)) (LocalizedModule (.powers r) M)),
∀ i, (LocalizedModule.lift (.powers r) f fun s ↦ IsLocalizedModule.map_units f
⟨s.1, SetLike.le_def.mp (Submonoid.powers_le.mpr hr) s.2⟩) (b' i) = b i := by
have : Module.FinitePresentation R (I →₀ R) := Module.finitePresentation_of_projective _ _
obtain ⟨r, hr, e, he⟩ := Module.FinitePresentation.exists_lift_equiv_of_isLocalizedModule S f
(Finsupp.mapRange.linearMap (Algebra.linearMap R Rₛ)) (b.repr.restrictScalars R)
let e' := IsLocalizedModule.iso (.powers r) (Finsupp.mapRange.linearMap (α := I)
(Algebra.linearMap R (Localization (.powers r))))
refine ⟨r, hr, .ofRepr (e ≪≫ₗ ?_), ?_⟩
· exact
{ __ := e',
toLinearMap := e'.extendScalarsOfIsLocalization (.powers r) (Localization (.powers r)) }
· intro i
have : e'.symm _ = _ := LinearMap.congr_fun (IsLocalizedModule.iso_symm_comp (.powers r)
(Finsupp.mapRange.linearMap (Algebra.linearMap R (Localization (.powers r)))))
(Finsupp.single i 1)
simp only [Finsupp.mapRange.linearMap_apply, Finsupp.mapRange_single, Algebra.linearMap_apply,
map_one, LocalizedModule.mkLinearMap_apply] at this
change LocalizedModule.lift _ _ _ (e.symm (e'.symm _)) = _
replace he := LinearMap.congr_fun he (e.symm (e'.symm (Finsupp.single i 1)))
simp only [LinearMap.coe_comp, LinearMap.coe_restrictScalars, LinearEquiv.coe_coe,
Function.comp_apply, LinearEquiv.apply_symm_apply, LinearEquiv.restrictScalars_apply] at he
apply b.repr.injective
rw [← he, Basis.repr_self, this, LocalizedModule.lift_mk]
simp
include f in
/--
If `M` is a finitely presented `R`-module
such that `Mₛ` is free over `Rₛ` for some `S : Submonoid R`,
then `Mᵣ` is already free over `Rᵣ` for some `r ∈ S`.
-/
lemma Module.FinitePresentation.exists_free_localizedModule_powers
(Rₛ) [CommRing Rₛ] [Algebra R Rₛ] [Module Rₛ M'] [IsScalarTower R Rₛ M'] [Nontrivial Rₛ]
[IsLocalization S Rₛ] [Module.FinitePresentation R M] [Module.Free Rₛ M'] :
∃ r, r ∈ S ∧
Module.Free (Localization (.powers r)) (LocalizedModule (.powers r) M) ∧
Module.finrank (Localization (.powers r)) (LocalizedModule (.powers r) M) =
Module.finrank Rₛ M' := by
let I := Module.Free.ChooseBasisIndex Rₛ M'
let b : Basis I Rₛ M' := Module.Free.chooseBasis Rₛ M'
have : Module.Finite Rₛ M' := Module.Finite.of_isLocalizedModule S (Rₚ := Rₛ) f
obtain ⟨r, hr, b', _⟩ := Module.FinitePresentation.exists_basis_localizedModule_powers S f Rₛ b
have := (show Localization (.powers r) →+* Rₛ from IsLocalization.map (M := .powers r) (T := S) _
(RingHom.id _) (Submonoid.powers_le.mpr hr)).domain_nontrivial
refine ⟨r, hr, .of_basis b', ?_⟩
rw [Module.finrank_eq_nat_card_basis b, Module.finrank_eq_nat_card_basis b'] |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Finiteness.lean | import Mathlib.Algebra.Module.LocalizedModule.Int
import Mathlib.RingTheory.Localization.Algebra
import Mathlib.RingTheory.RingHom.Finite
/-!
# Finiteness properties under localization
In this file we establish behaviour of `Module.Finite` under localizations.
## Main results
- `Module.Finite.of_isLocalizedModule`: If `M` is a finite `R`-module,
`S` is a submonoid of `R`, `Rₚ` is the localization of `R` at `S`
and `Mₚ` is the localization of `M` at `S`, then `Mₚ` is a finite
`Rₚ`-module.
- `Module.Finite.of_localizationSpan_finite`: If `M` is an `R`-module
and `{ r }` is a finite set generating the unit ideal such that
`Mᵣ` is a finite `Rᵣ`-module for each `r`, then `M` is a finite `R`-module.
-/
universe u v w t
namespace Module.Finite
section
variable {R : Type u} [CommSemiring R] (S : Submonoid R)
variable {Rₚ : Type v} [CommSemiring Rₚ] [Algebra R Rₚ] [IsLocalization S Rₚ]
variable {M : Type w} [AddCommMonoid M] [Module R M]
variable {Mₚ : Type t} [AddCommMonoid Mₚ] [Module R Mₚ] [Module Rₚ Mₚ] [IsScalarTower R Rₚ Mₚ]
variable (f : M →ₗ[R] Mₚ) [IsLocalizedModule S f]
include S f in
lemma of_isLocalizedModule [Module.Finite R M] : Module.Finite Rₚ Mₚ := by
classical
obtain ⟨T, hT⟩ := ‹Module.Finite R M›
use T.image f
rw [eq_top_iff]
rintro x -
obtain ⟨⟨y, m⟩, (hyx : IsLocalizedModule.mk' f y m = x)⟩ :=
IsLocalizedModule.mk'_surjective S f x
have hy : y ∈ Submodule.span R T := by rw [hT]; trivial
have : f y ∈ Submodule.map f (Submodule.span R T) := Submodule.mem_map_of_mem hy
rw [Submodule.map_span] at this
have H : Submodule.span R (f '' T) ≤
(Submodule.span Rₚ (f '' T)).restrictScalars R := by
rw [Submodule.span_le]; exact Submodule.subset_span
convert (Submodule.span Rₚ (f '' T)).smul_mem
(IsLocalization.mk' Rₚ (1 : R) m) (H this) using 0
· rw [← hyx, ← IsLocalizedModule.mk'_one S, IsLocalizedModule.mk'_smul_mk']
simp
instance [Module.Finite R M] : Module.Finite (Localization S) (LocalizedModule S M) :=
of_isLocalizedModule S (LocalizedModule.mkLinearMap S M)
end
variable {R : Type u} [CommRing R] {M : Type w} [AddCommMonoid M] [Module R M]
/--
If there exists a finite set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`,
then `M` is a finite `R`-module.
General version for any modules `Mᵣ` and rings `Rᵣ` satisfying the correct universal properties.
See `Module.Finite.of_localizationSpan_finite` for the specialized version.
See `of_localizationSpan'` for a version without the finite set assumption.
-/
theorem of_localizationSpan_finite' (t : Finset R) (ht : Ideal.span (t : Set R) = ⊤)
{Mₚ : ∀ (_ : t), Type*} [∀ (g : t), AddCommMonoid (Mₚ g)] [∀ (g : t), Module R (Mₚ g)]
{Rₚ : ∀ (_ : t), Type u} [∀ (g : t), CommRing (Rₚ g)] [∀ (g : t), Algebra R (Rₚ g)]
[∀ (g : t), IsLocalization.Away g.val (Rₚ g)]
[∀ (g : t), Module (Rₚ g) (Mₚ g)] [∀ (g : t), IsScalarTower R (Rₚ g) (Mₚ g)]
(f : ∀ (g : t), M →ₗ[R] Mₚ g) [∀ (g : t), IsLocalizedModule (Submonoid.powers g.val) (f g)]
(H : ∀ (g : t), Module.Finite (Rₚ g) (Mₚ g)) :
Module.Finite R M := by
classical
constructor
choose s₁ s₂ using (fun g ↦ (H g).1)
let sf := fun x : t ↦
IsLocalizedModule.finsetIntegerMultiple (Submonoid.powers x.val) (f x) (s₁ x)
use t.attach.biUnion sf
rw [Submodule.span_attach_biUnion, eq_top_iff]
rintro x -
refine Submodule.mem_of_span_eq_top_of_smul_pow_mem _ (t : Set R) ht _ (fun r ↦ ?_)
set S : Submonoid R := Submonoid.powers r.val
obtain ⟨⟨_, n₁, rfl⟩, hn₁⟩ := multiple_mem_span_of_mem_localization_span S (Rₚ r)
(s₁ r : Set (Mₚ r)) (IsLocalizedModule.mk' (f r) x (1 : S)) (by rw [s₂ r]; trivial)
rw [Submonoid.smul_def, ← IsLocalizedModule.mk'_smul, IsLocalizedModule.mk'_one] at hn₁
obtain ⟨⟨_, n₂, rfl⟩, hn₂⟩ := IsLocalizedModule.smul_mem_finsetIntegerMultiple_span
S (f r) _ (s₁ r) hn₁
rw [Submonoid.smul_def] at hn₂
use n₂ + n₁
apply le_iSup (fun x : t ↦ Submodule.span R (sf x : Set M)) r
rw [pow_add, mul_smul]
exact hn₂
/--
If there exists a set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`,
then `M` is a finite `R`-module.
General version for any modules `Mᵣ` and rings `Rᵣ` satisfying the correct universal properties.
See `Module.Finite.of_localizationSpan_finite` for the specialized version.
-/
theorem of_localizationSpan' (t : Set R) (ht : Ideal.span t = ⊤)
{Mₚ : ∀ (_ : t), Type*} [∀ (g : t), AddCommMonoid (Mₚ g)] [∀ (g : t), Module R (Mₚ g)]
{Rₚ : ∀ (_ : t), Type u} [∀ (g : t), CommRing (Rₚ g)] [∀ (g : t), Algebra R (Rₚ g)]
[h₁ : ∀ (g : t), IsLocalization.Away g.val (Rₚ g)]
[∀ (g : t), Module (Rₚ g) (Mₚ g)] [∀ (g : t), IsScalarTower R (Rₚ g) (Mₚ g)]
(f : ∀ (g : t), M →ₗ[R] Mₚ g) [h₂ : ∀ (g : t), IsLocalizedModule (Submonoid.powers g.val) (f g)]
(H : ∀ (g : t), Module.Finite (Rₚ g) (Mₚ g)) :
Module.Finite R M := by
rw [Ideal.span_eq_top_iff_finite] at ht
obtain ⟨t', hc, ht'⟩ := ht
have (g : t') : IsLocalization.Away g.val (Rₚ ⟨g.val, hc g.property⟩) :=
h₁ ⟨g.val, hc g.property⟩
have (g : t') : IsLocalizedModule (Submonoid.powers g.val)
((fun g ↦ f ⟨g.val, hc g.property⟩) g) := h₂ ⟨g.val, hc g.property⟩
apply of_localizationSpan_finite' t' ht' (fun g ↦ f ⟨g.val, hc g.property⟩)
(fun g ↦ H ⟨g.val, hc g.property⟩)
/--
If there exists a finite set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`,
then `M` is a finite `R`-module.
See `of_localizationSpan` for a version without the finite set assumption.
-/
theorem of_localizationSpan_finite (t : Finset R) (ht : Ideal.span (t : Set R) = ⊤)
(H : ∀ (g : t), Module.Finite (Localization.Away g.val)
(LocalizedModule (Submonoid.powers g.val) M)) :
Module.Finite R M :=
let f (g : t) : M →ₗ[R] LocalizedModule (Submonoid.powers g.val) M :=
LocalizedModule.mkLinearMap (Submonoid.powers g.val) M
of_localizationSpan_finite' t ht f H
/-- If there exists a set `{ r }` of `R` such that `Mᵣ` is `Rᵣ`-finite for each `r`,
then `M` is a finite `R`-module. -/
theorem of_localizationSpan (t : Set R) (ht : Ideal.span t = ⊤)
(H : ∀ (g : t), Module.Finite (Localization.Away g.val)
(LocalizedModule (Submonoid.powers g.val) M)) :
Module.Finite R M :=
let f (g : t) : M →ₗ[R] LocalizedModule (Submonoid.powers g.val) M :=
LocalizedModule.mkLinearMap (Submonoid.powers g.val) M
of_localizationSpan' t ht f H
end Finite
end Module
namespace Ideal
variable {R : Type u} [CommRing R]
/-- If `I` is an ideal such that there exists a set `{ r }` of `R` such
that the image of `I` in `Rᵣ` is finitely generated for each `r`, then `I` is finitely
generated. -/
lemma fg_of_localizationSpan {I : Ideal R} (t : Set R) (ht : Ideal.span t = ⊤)
(H : ∀ (g : t), (I.map (algebraMap R (Localization.Away g.val))).FG) : I.FG := by
apply Module.Finite.iff_fg.mp
let k (g : t) : I →ₗ[R] (I.map (algebraMap R (Localization.Away g.val))) :=
Algebra.idealMap I (S := Localization.Away g.val)
exact Module.Finite.of_localizationSpan' t ht k (fun g ↦ Module.Finite.iff_fg.mpr (H g))
end Ideal
variable {R : Type u} [CommRing R] {S : Type v} [CommRing S] {f : R →+* S}
/--
To check that the kernel of a ring homomorphism is finitely generated,
it suffices to check this after localizing at a spanning set of the source.
-/
lemma RingHom.ker_fg_of_localizationSpan (t : Set R) (ht : Ideal.span t = ⊤)
(H : ∀ g : t, (RingHom.ker (Localization.awayMap f g.val)).FG) :
(RingHom.ker f).FG := by
apply Ideal.fg_of_localizationSpan t ht
intro g
rw [← IsLocalization.ker_map (Localization.Away (f g.val)) f (Submonoid.map_powers f g.val)]
exact H g |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/FractionRing.lean | import Mathlib.Algebra.Ring.Hom.InjSurj
import Mathlib.Algebra.Field.Equiv
import Mathlib.Algebra.Field.Subfield.Basic
import Mathlib.Algebra.Order.GroupWithZero.Submonoid
import Mathlib.Algebra.Order.Ring.Int
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.SimpleRing.Basic
/-!
# Fraction ring / fraction field Frac(R) as localization
## Main definitions
* `IsFractionRing R K` expresses that `K` is a field of fractions of `R`, as an abbreviation of
`IsLocalization (NonZeroDivisors R) K`
## Main results
* `IsFractionRing.field`: a definition (not an instance) stating the localization of an integral
domain `R` at `R \ {0}` is a field
* `Rat.isFractionRing` is an instance stating `ℚ` is the field of fractions of `ℤ`
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
assert_not_exists Ideal
open nonZeroDivisors
variable (R : Type*) [CommRing R] {M : Submonoid R} (S : Type*) [CommRing S]
variable [Algebra R S] {P : Type*} [CommRing P]
variable {A : Type*} [CommRing A] (K : Type*)
-- TODO: should this extend `Algebra` instead of assuming it?
-- TODO: this was recently generalized from `CommRing` to `CommSemiring`, but all lemmas below are
-- still stated for `CommRing`. Generalize these lemmas where it is appropriate.
/-- `IsFractionRing R K` states `K` is the ring of fractions of a commutative ring `R`. -/
abbrev IsFractionRing (R : Type*) [CommSemiring R] (K : Type*) [CommSemiring K] [Algebra R K] :=
IsLocalization (nonZeroDivisors R) K
instance {R : Type*} [Field R] : IsFractionRing R R :=
IsLocalization.at_units _ (fun _ ↦ isUnit_of_mem_nonZeroDivisors)
/-- The cast from `Int` to `Rat` as a `FractionRing`. -/
instance Rat.isFractionRing : IsFractionRing ℤ ℚ where
map_units := by
rintro ⟨x, hx⟩
rw [mem_nonZeroDivisors_iff_ne_zero] at hx
simpa only [eq_intCast, isUnit_iff_ne_zero, Int.cast_eq_zero, Ne, Subtype.coe_mk] using hx
surj := by
rintro ⟨n, d, hd, h⟩
refine ⟨⟨n, ⟨d, ?_⟩⟩, Rat.mul_den_eq_num _⟩
rw [mem_nonZeroDivisors_iff_ne_zero, Int.natCast_ne_zero_iff_pos]
exact Nat.zero_lt_of_ne_zero hd
exists_of_eq {x y} := by
rw [eq_intCast, eq_intCast, Int.cast_inj]
rintro rfl
use 1
/-- As a corollary, `Rat` is also a localization at only positive integers. -/
instance : IsLocalization (Submonoid.pos ℤ) ℚ where
map_units y := by simpa using y.prop.ne'
surj z := by
obtain ⟨⟨x1, x2⟩, hx⟩ := IsLocalization.surj (nonZeroDivisors ℤ) z
obtain hx2 | hx2 := lt_or_gt_of_ne (show x2.val ≠ 0 by simp)
· exact ⟨⟨-x1, ⟨-x2.val, by simpa using hx2⟩⟩, by simpa using hx⟩
· exact ⟨⟨x1, ⟨x2.val, hx2⟩⟩, hx⟩
exists_of_eq {x y} h := ⟨1, by simpa using Rat.intCast_inj.mp h⟩
/-- `NNRat` is the ring of fractions of `Nat`. -/
instance NNRat.isFractionRing : IsFractionRing ℕ ℚ≥0 where
map_units y := by simp
surj z := ⟨⟨z.num, ⟨z.den, by simp⟩⟩, by simp⟩
exists_of_eq {x y} h := ⟨1, by simpa using h⟩
namespace IsFractionRing
open IsLocalization
theorem of_field [Field K] [Algebra R K] [FaithfulSMul R K]
(surj : ∀ z : K, ∃ x y, z = algebraMap R K x / algebraMap R K y) :
IsFractionRing R K :=
have inj := FaithfulSMul.algebraMap_injective R K
have := inj.noZeroDivisors _ (map_zero _) (map_mul _)
have := Module.nontrivial R K
{ map_units x :=
.mk0 _ <| (map_ne_zero_iff _ inj).mpr <| mem_nonZeroDivisors_iff_ne_zero.mp x.2
surj z := by
have ⟨x, y, eq⟩ := surj z
obtain rfl | hy := eq_or_ne y 0
· obtain rfl : z = 0 := by simpa using eq
exact ⟨(0, 1), by simp⟩
exact ⟨⟨x, y, mem_nonZeroDivisors_iff_ne_zero.mpr hy⟩,
(eq_div_iff_mul_eq <| (map_ne_zero_iff _ inj).mpr hy).mp eq⟩
exists_of_eq eq := ⟨1, by simpa using inj eq⟩ }
variable {R K}
section CommRing
variable [CommRing K] [Algebra R K] [IsFractionRing R K] [Algebra A K] [IsFractionRing A K]
theorem to_map_eq_zero_iff {x : R} : algebraMap R K x = 0 ↔ x = 0 :=
IsLocalization.to_map_eq_zero_iff _ le_rfl
variable (R K)
protected theorem injective : Function.Injective (algebraMap R K) :=
IsLocalization.injective _ (le_of_eq rfl)
include R in
theorem nonZeroDivisors_eq_isUnit : K⁰ = IsUnit.submonoid K := by
refine le_antisymm (fun x hx ↦ ?_) (isUnit_le_nonZeroDivisors K)
have ⟨r, eq⟩ := surj R⁰ x
let r' : R⁰ := ⟨r.1, mem_nonZeroDivisors_of_injective (IsFractionRing.injective R K)
(eq ▸ mul_mem hx (map_units ..).mem_nonZeroDivisors)⟩
exact isUnit_of_mul_isUnit_left <| eq ▸ map_units K r'
include R in
/-- If `L` is a fraction ring of `K` which is a fraction ring of `R`,
the `K`-algebra homomorphism from `K` to `L` is an isomorphism. -/
noncomputable def algEquiv (L) [CommRing L] [Algebra K L] [IsFractionRing K L] : K ≃ₐ[K] L :=
atUnits K _ (nonZeroDivisors_eq_isUnit R K).le
include R in
theorem idem : IsFractionRing K K := IsLocalization.self (nonZeroDivisors_eq_isUnit R K).le
/-- Taking fraction ring is idempotent: a fraction ring of a fraction ring of `R` is
itself a fraction ring of `R`. -/
theorem trans (L) [CommRing L] [Algebra K L] [IsFractionRing K L] [Algebra R L]
[IsScalarTower R K L] : IsFractionRing R L :=
isLocalization_of_algEquiv _ <| (algEquiv R K L).restrictScalars R
instance (priority := 100) : FaithfulSMul R K :=
(faithfulSMul_iff_algebraMap_injective R K).mpr <| IsFractionRing.injective R K
variable {R}
theorem self_iff_nonZeroDivisors_eq_isUnit : IsFractionRing R R ↔ R⁰ = IsUnit.submonoid R where
mp _ := nonZeroDivisors_eq_isUnit R R
mpr h := IsLocalization.self h.le
theorem self_iff_nonZeroDivisors_le_isUnit : IsFractionRing R R ↔ R⁰ ≤ IsUnit.submonoid R := by
rw [self_iff_nonZeroDivisors_eq_isUnit, le_antisymm_iff,
and_iff_left (isUnit_le_nonZeroDivisors R)]
theorem self_iff_bijective : IsFractionRing R R ↔ Function.Bijective (algebraMap R K) where
mp h := (atUnits R _ <| self_iff_nonZeroDivisors_le_isUnit.mp h).bijective
mpr h := isLocalization_of_algEquiv _ (AlgEquiv.ofBijective (Algebra.ofId R K) h).symm
theorem self_iff_surjective : IsFractionRing R R ↔ Function.Surjective (algebraMap R K) := by
rw [self_iff_bijective K, Function.Bijective, and_iff_right (IsFractionRing.injective R K)]
variable {K}
open algebraMap in
@[norm_cast]
theorem coe_inj {a b : R} : (↑a : K) = ↑b ↔ a = b :=
algebraMap.coe_inj _ _
protected theorem to_map_ne_zero_of_mem_nonZeroDivisors [Nontrivial R] {x : R}
(hx : x ∈ nonZeroDivisors R) : algebraMap R K x ≠ 0 :=
IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors _ le_rfl hx
variable (A) [IsDomain A]
include A in
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is an
integral domain. -/
protected theorem isDomain : IsDomain K :=
isDomain_of_le_nonZeroDivisors _ (le_refl (nonZeroDivisors A))
/-- The inverse of an element in the field of fractions of an integral domain. -/
protected noncomputable irreducible_def inv (z : K) : K := open scoped Classical in
if h : z = 0 then 0
else
mk' K ↑(sec (nonZeroDivisors A) z).2
⟨(sec _ z).1,
mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
h <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) z) h0⟩
protected theorem mul_inv_cancel (x : K) (hx : x ≠ 0) : x * IsFractionRing.inv A x = 1 := by
rw [IsFractionRing.inv, dif_neg hx, ←
IsUnit.mul_left_inj
(map_units K
⟨(sec _ x).1,
mem_nonZeroDivisors_iff_ne_zero.2 fun h0 =>
hx <| eq_zero_of_fst_eq_zero (sec_spec (nonZeroDivisors A) x) h0⟩),
one_mul, mul_assoc]
rw [mk'_spec, ← eq_mk'_iff_mul_eq]
exact (mk'_sec _ x).symm
/-- A `CommRing` `K` which is the localization of an integral domain `R` at `R - {0}` is a field.
See note [reducible non-instances]. -/
@[stacks 09FJ]
noncomputable abbrev toField : Field K where
__ := IsFractionRing.isDomain A
inv := IsFractionRing.inv A
mul_inv_cancel := IsFractionRing.mul_inv_cancel A
inv_zero := show IsFractionRing.inv A (0 : K) = 0 by rw [IsFractionRing.inv]; exact dif_pos rfl
nnqsmul := _
nnqsmul_def := fun _ _ => rfl
qsmul := _
qsmul_def := fun _ _ => rfl
lemma surjective_iff_isField [IsDomain R] : Function.Surjective (algebraMap R K) ↔ IsField R where
mp h := (RingEquiv.ofBijective (algebraMap R K)
⟨IsFractionRing.injective R K, h⟩).toMulEquiv.isField (IsFractionRing.toField R).toIsField
mpr h :=
letI := h.toField
(IsLocalization.atUnits R _ (S := K)
(fun _ hx ↦ Ne.isUnit (mem_nonZeroDivisors_iff_ne_zero.mp hx))).surjective
end CommRing
variable {B : Type*} [CommRing B] [IsDomain B] [Field K] {L : Type*} [Field L] [Algebra A K]
[IsFractionRing A K] {g : A →+* L}
theorem mk'_mk_eq_div {r s} (hs : s ∈ nonZeroDivisors A) :
mk' K r ⟨s, hs⟩ = algebraMap A K r / algebraMap A K s :=
haveI := (algebraMap A K).domain_nontrivial
mk'_eq_iff_eq_mul.2 <|
(div_mul_cancel₀ (algebraMap A K r)
(IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors hs)).symm
@[simp]
theorem mk'_eq_div {r} (s : nonZeroDivisors A) : mk' K r s = algebraMap A K r / algebraMap A K s :=
mk'_mk_eq_div s.2
theorem div_surjective (z : K) :
∃ x y : A, y ∈ nonZeroDivisors A ∧ algebraMap _ _ x / algebraMap _ _ y = z :=
let ⟨x, ⟨y, hy⟩, h⟩ := exists_mk'_eq (nonZeroDivisors A) z
⟨x, y, hy, by rwa [mk'_eq_div] at h⟩
theorem isUnit_map_of_injective (hg : Function.Injective g) (y : nonZeroDivisors A) :
IsUnit (g y) :=
haveI := g.domain_nontrivial
IsUnit.mk0 (g y) <|
show g.toMonoidWithZeroHom y ≠ 0 from map_ne_zero_of_mem_nonZeroDivisors g hg y.2
theorem mk'_eq_zero_iff_eq_zero [Algebra R K] [IsFractionRing R K] {x : R} {y : nonZeroDivisors R} :
mk' K x y = 0 ↔ x = 0 := by
haveI := (algebraMap R K).domain_nontrivial
simp [nonZeroDivisors.ne_zero]
theorem mk'_eq_one_iff_eq {x : A} {y : nonZeroDivisors A} : mk' K x y = 1 ↔ x = y := by
haveI := (algebraMap A K).domain_nontrivial
refine ⟨?_, fun hxy => by rw [hxy, mk'_self']⟩
intro hxy
have hy : (algebraMap A K) ↑y ≠ (0 : K) :=
IsFractionRing.to_map_ne_zero_of_mem_nonZeroDivisors y.property
rw [IsFractionRing.mk'_eq_div, div_eq_one_iff_eq hy] at hxy
exact IsFractionRing.injective A K hxy
section commutes
variable [Algebra A B] {K₁ K₂ : Type*} [Field K₁] [Field K₂] [Algebra A K₁] [Algebra A K₂]
[IsFractionRing A K₁] {L₁ L₂ : Type*} [Field L₁] [Field L₂] [Algebra B L₁] [Algebra B L₂]
[Algebra K₁ L₁] [Algebra K₂ L₂] [Algebra A L₁] [Algebra A L₂] [IsScalarTower A K₁ L₁]
[IsScalarTower A K₂ L₂] [IsScalarTower A B L₁] [IsScalarTower A B L₂]
omit [IsDomain B]
theorem algHom_commutes (e : K₁ →ₐ[A] K₂) (f : L₁ →ₐ[B] L₂) (x : K₁) :
algebraMap K₂ L₂ (e x) = f (algebraMap K₁ L₁ x) := by
obtain ⟨r, s, hs, rfl⟩ := IsFractionRing.div_surjective (A := A) x
simp_rw [map_div₀, AlgHom.commutes, ← IsScalarTower.algebraMap_apply,
IsScalarTower.algebraMap_apply A B L₁, AlgHom.commutes, ← IsScalarTower.algebraMap_apply]
theorem algEquiv_commutes (e : K₁ ≃ₐ[A] K₂) (f : L₁ ≃ₐ[B] L₂) (x : K₁) :
algebraMap K₂ L₂ (e x) = f (algebraMap K₁ L₁ x) := by
exact algHom_commutes e.toAlgHom f.toAlgHom _
end commutes
section Subfield
variable (A K) in
/-- If `A` is a commutative ring with fraction field `K`, then the subfield of `K` generated by
the image of `algebraMap A K` is equal to the whole field `K`. -/
theorem closure_range_algebraMap : Subfield.closure (Set.range (algebraMap A K)) = ⊤ :=
top_unique fun z _ ↦ by
obtain ⟨_, _, -, rfl⟩ := div_surjective (A := A) z
apply div_mem <;> exact Subfield.subset_closure ⟨_, rfl⟩
variable {L : Type*} [Field L] {g : A →+* L} {f : K →+* L}
/-- If `A` is a commutative ring with fraction field `K`, `L` is a field, `g : A →+* L` lifts to
`f : K →+* L`, then the image of `f` is the subfield generated by the image of `g`. -/
theorem ringHom_fieldRange_eq_of_comp_eq (h : RingHom.comp f (algebraMap A K) = g) :
f.fieldRange = Subfield.closure g.range := by
rw [f.fieldRange_eq_map, ← closure_range_algebraMap A K,
f.map_field_closure, ← Set.range_comp, ← f.coe_comp, h, g.coe_range]
/-- If `A` is a commutative ring with fraction field `K`, `L` is a field, `g : A →+* L` lifts to
`f : K →+* L`, `s` is a set such that the image of `g` is the subring generated by `s`,
then the image of `f` is the subfield generated by `s`. -/
theorem ringHom_fieldRange_eq_of_comp_eq_of_range_eq (h : RingHom.comp f (algebraMap A K) = g)
{s : Set L} (hs : g.range = Subring.closure s) : f.fieldRange = Subfield.closure s := by
rw [ringHom_fieldRange_eq_of_comp_eq h, hs]
ext
simp_rw [Subfield.mem_closure_iff, Subring.closure_eq]
end Subfield
open Function
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field, we get a
field hom sending `z : K` to `g x * (g y)⁻¹`, where `(x, y) : A × (NonZeroDivisors A)` are
such that `z = f x * (f y)⁻¹`. -/
noncomputable def lift (hg : Injective g) : K →+* L :=
IsLocalization.lift fun y : nonZeroDivisors A => isUnit_map_of_injective hg y
theorem lift_unique (hg : Function.Injective g) {f : K →+* L}
(hf1 : ∀ x, f (algebraMap A K x) = g x) : IsFractionRing.lift hg = f :=
IsLocalization.lift_unique _ hf1
/-- Another version of unique to give two lift maps should be equal -/
theorem ringHom_ext {f1 f2 : K →+* L}
(hf : ∀ x : A, f1 (algebraMap A K x) = f2 (algebraMap A K x)) : f1 = f2 := by
ext z
obtain ⟨x, y, hy, rfl⟩ := IsFractionRing.div_surjective (A := A) z
rw [map_div₀, map_div₀, hf, hf]
theorem injective_comp_algebraMap :
Function.Injective fun (f : K →+* L) => f.comp (algebraMap A K) :=
fun _ _ h => ringHom_ext (fun x => RingHom.congr_fun h x)
section liftAlgHom
variable [Algebra R A] [Algebra R K] [IsScalarTower R A K] [Algebra R L]
{g : A →ₐ[R] L} (hg : Injective g) (x : K)
include hg
/-- `AlgHom` version of `IsFractionRing.lift`. -/
noncomputable def liftAlgHom : K →ₐ[R] L :=
IsLocalization.liftAlgHom fun y : nonZeroDivisors A => isUnit_map_of_injective hg y
theorem liftAlgHom_toRingHom : (liftAlgHom hg : K →ₐ[R] L).toRingHom = lift hg := rfl
@[simp]
theorem coe_liftAlgHom : ⇑(liftAlgHom hg : K →ₐ[R] L) = lift hg := rfl
theorem liftAlgHom_apply : liftAlgHom hg x = lift hg x := rfl
end liftAlgHom
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field,
the field hom induced from `K` to `L` maps `x` to `g x` for all
`x : A`. -/
@[simp]
theorem lift_algebraMap (hg : Injective g) (x) : lift hg (algebraMap A K x) = g x :=
lift_eq _ _
/-- The image of `IsFractionRing.lift` is the subfield generated by the image
of the ring hom. -/
theorem lift_fieldRange (hg : Injective g) :
(lift hg : K →+* L).fieldRange = Subfield.closure g.range :=
ringHom_fieldRange_eq_of_comp_eq (by ext; simp)
/-- The image of `IsFractionRing.lift` is the subfield generated by `s`, if the image
of the ring hom is the subring generated by `s`. -/
theorem lift_fieldRange_eq_of_range_eq (hg : Injective g)
{s : Set L} (hs : g.range = Subring.closure s) :
(lift hg : K →+* L).fieldRange = Subfield.closure s :=
ringHom_fieldRange_eq_of_comp_eq_of_range_eq (by ext; simp) hs
/-- Given a commutative ring `A` with field of fractions `K`,
and an injective ring hom `g : A →+* L` where `L` is a field,
field hom induced from `K` to `L` maps `f x / f y` to `g x / g y` for all
`x : A, y ∈ NonZeroDivisors A`. -/
theorem lift_mk' (hg : Injective g) (x) (y : nonZeroDivisors A) :
lift hg (mk' K x y) = g x / g y := by simp only [mk'_eq_div, map_div₀, lift_algebraMap]
/-- Given commutative rings `A, B` where `B` is an integral domain, with fraction rings `K`, `L`
and an injective ring hom `j : A →+* B`, we get a ring hom
sending `z : K` to `g (j x) * (g (j y))⁻¹`, where `(x, y) : A × (NonZeroDivisors A)` are
such that `z = f x * (f y)⁻¹`. -/
noncomputable def map {A B K L : Type*} [CommRing A] [CommRing B] [IsDomain B] [CommRing K]
[Algebra A K] [IsFractionRing A K] [CommRing L] [Algebra B L] [IsFractionRing B L] {j : A →+* B}
(hj : Injective j) : K →+* L :=
IsLocalization.map L j
(show nonZeroDivisors A ≤ (nonZeroDivisors B).comap j from
nonZeroDivisors_le_comap_nonZeroDivisors_of_injective j hj)
section ringEquivOfRingEquiv
variable {A K B L : Type*} [CommRing A] [CommRing B] [CommRing K] [CommRing L]
[Algebra A K] [IsFractionRing A K] [Algebra B L] [IsFractionRing B L]
(h : A ≃+* B)
/-- Given rings `A, B` and localization maps to their fraction rings
`f : A →+* K, g : B →+* L`, an isomorphism `h : A ≃+* B` induces an isomorphism of
fraction rings `K ≃+* L`. -/
noncomputable def ringEquivOfRingEquiv : K ≃+* L :=
IsLocalization.ringEquivOfRingEquiv K L h (MulEquivClass.map_nonZeroDivisors h)
@[simp]
lemma ringEquivOfRingEquiv_algebraMap
(a : A) : ringEquivOfRingEquiv h (algebraMap A K a) = algebraMap B L (h a) := by
simp [ringEquivOfRingEquiv]
@[simp]
lemma ringEquivOfRingEquiv_symm :
(ringEquivOfRingEquiv h : K ≃+* L).symm = ringEquivOfRingEquiv h.symm := rfl
end ringEquivOfRingEquiv
section algEquivOfAlgEquiv
variable {R A K B L : Type*} [CommSemiring R] [CommRing A] [CommRing B] [CommRing K] [CommRing L]
[Algebra R A] [Algebra R K] [Algebra A K] [IsFractionRing A K] [IsScalarTower R A K]
[Algebra R B] [Algebra R L] [Algebra B L] [IsFractionRing B L] [IsScalarTower R B L]
(h : A ≃ₐ[R] B)
/-- Given `R`-algebras `A, B` and localization maps to their fraction rings
`f : A →ₐ[R] K, g : B →ₐ[R] L`, an isomorphism `h : A ≃ₐ[R] B` induces an isomorphism of
fraction rings `K ≃ₐ[R] L`. -/
noncomputable def algEquivOfAlgEquiv : K ≃ₐ[R] L :=
IsLocalization.algEquivOfAlgEquiv K L h (MulEquivClass.map_nonZeroDivisors h)
@[simp]
lemma algEquivOfAlgEquiv_algebraMap
(a : A) : algEquivOfAlgEquiv h (algebraMap A K a) = algebraMap B L (h a) := by
simp [algEquivOfAlgEquiv]
@[simp]
lemma algEquivOfAlgEquiv_symm :
(algEquivOfAlgEquiv h : K ≃ₐ[R] L).symm = algEquivOfAlgEquiv h.symm := rfl
end algEquivOfAlgEquiv
section fieldEquivOfAlgEquiv
variable {A B C D : Type*}
[CommRing A] [CommRing B] [CommRing C] [CommRing D]
[Algebra A B] [Algebra A C] [Algebra A D]
(FA FB FC FD : Type*) [Field FA] [Field FB] [Field FC] [Field FD]
[Algebra A FA] [Algebra B FB] [Algebra C FC] [Algebra D FD]
[IsFractionRing A FA] [IsFractionRing B FB] [IsFractionRing C FC] [IsFractionRing D FD]
[Algebra A FB] [IsScalarTower A B FB]
[Algebra A FC] [IsScalarTower A C FC]
[Algebra A FD] [IsScalarTower A D FD]
[Algebra FA FB] [IsScalarTower A FA FB]
[Algebra FA FC] [IsScalarTower A FA FC]
[Algebra FA FD] [IsScalarTower A FA FD]
/-- An algebra isomorphism of rings induces an algebra isomorphism of fraction fields. -/
noncomputable def fieldEquivOfAlgEquiv (f : B ≃ₐ[A] C) : FB ≃ₐ[FA] FC where
__ := IsFractionRing.ringEquivOfRingEquiv f.toRingEquiv
commutes' x := by
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := A) x
simp_rw [map_div₀, ← IsScalarTower.algebraMap_apply, IsScalarTower.algebraMap_apply A B FB]
simp [← IsScalarTower.algebraMap_apply A C FC]
lemma restrictScalars_fieldEquivOfAlgEquiv (f : B ≃ₐ[A] C) :
(fieldEquivOfAlgEquiv FA FB FC f).restrictScalars A = algEquivOfAlgEquiv f := by
ext; rfl
/-- This says that `fieldEquivOfAlgEquiv f` is an extension of `f` (i.e., it agrees with `f` on
`B`). Whereas `(fieldEquivOfAlgEquiv f).commutes` says that `fieldEquivOfAlgEquiv f` fixes `K`. -/
@[simp]
lemma fieldEquivOfAlgEquiv_algebraMap (f : B ≃ₐ[A] C) (b : B) :
fieldEquivOfAlgEquiv FA FB FC f (algebraMap B FB b) = algebraMap C FC (f b) :=
ringEquivOfRingEquiv_algebraMap f.toRingEquiv b
variable (A B) in
@[simp]
lemma fieldEquivOfAlgEquiv_refl :
fieldEquivOfAlgEquiv FA FB FB (AlgEquiv.refl : B ≃ₐ[A] B) = AlgEquiv.refl := by
ext x
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := B) x
simp
lemma fieldEquivOfAlgEquiv_trans (f : B ≃ₐ[A] C) (g : C ≃ₐ[A] D) :
fieldEquivOfAlgEquiv FA FB FD (f.trans g) =
(fieldEquivOfAlgEquiv FA FB FC f).trans (fieldEquivOfAlgEquiv FA FC FD g) := by
ext x
obtain ⟨x, y, -, rfl⟩ := IsFractionRing.div_surjective (A := B) x
simp
end fieldEquivOfAlgEquiv
section fieldEquivOfAlgEquivHom
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
(K L : Type*) [Field K] [Field L]
[Algebra A K] [Algebra B L] [IsFractionRing A K] [IsFractionRing B L]
[Algebra A L] [IsScalarTower A B L] [Algebra K L] [IsScalarTower A K L]
/-- An algebra automorphism of a ring induces an algebra automorphism of its fraction field.
This is a bundled version of `fieldEquivOfAlgEquiv`. -/
noncomputable def fieldEquivOfAlgEquivHom : (B ≃ₐ[A] B) →* (L ≃ₐ[K] L) where
toFun := fieldEquivOfAlgEquiv K L L
map_one' := fieldEquivOfAlgEquiv_refl A B K L
map_mul' f g := fieldEquivOfAlgEquiv_trans K L L L g f
@[simp]
lemma fieldEquivOfAlgEquivHom_apply (f : B ≃ₐ[A] B) :
fieldEquivOfAlgEquivHom K L f = fieldEquivOfAlgEquiv K L L f :=
rfl
variable (A B)
lemma fieldEquivOfAlgEquivHom_injective :
Function.Injective (fieldEquivOfAlgEquivHom K L : (B ≃ₐ[A] B) →* (L ≃ₐ[K] L)) := by
intro f g h
ext b
simpa using AlgEquiv.ext_iff.mp h (algebraMap B L b)
end fieldEquivOfAlgEquivHom
theorem isFractionRing_iff_of_base_ringEquiv (h : R ≃+* P) :
IsFractionRing R S ↔
@IsFractionRing P _ S _ ((algebraMap R S).comp h.symm.toRingHom).toAlgebra := by
delta IsFractionRing
convert isLocalization_iff_of_base_ringEquiv (nonZeroDivisors R) S h
exact (MulEquivClass.map_nonZeroDivisors h).symm
variable (R S : Type*) [CommSemiring R] [CommSemiring S] [Algebra R S] [h : IsFractionRing R S]
theorem nontrivial_iff_nontrivial : Nontrivial R ↔ Nontrivial S := by
by_contra! h'
rcases h' with ⟨_, _⟩ | ⟨_, _⟩
· obtain ⟨c, hc⟩ := h.exists_of_eq (x := 1) (y := 0) (Subsingleton.elim _ _)
simp at hc
· apply (h.map_units 1).ne_zero
rw [Subsingleton.eq_zero ((1 : nonZeroDivisors R) : R), map_zero]
protected theorem nontrivial [hR : Nontrivial R] : Nontrivial S :=
h.nontrivial_iff_nontrivial.mp hR
end IsFractionRing
section algebraMap_injective
theorem algebraMap_injective_of_field_isFractionRing (K L : Type*) [Field K] [Semiring L]
[Nontrivial L] [Algebra R K] [IsFractionRing R K] [Algebra S L] [Algebra K L] [Algebra R L]
[IsScalarTower R S L] [IsScalarTower R K L] : Function.Injective (algebraMap R S) := by
refine Function.Injective.of_comp (f := algebraMap S L) ?_
rw [← RingHom.coe_comp, ← IsScalarTower.algebraMap_eq, IsScalarTower.algebraMap_eq R K L]
exact (algebraMap K L).injective.comp (IsFractionRing.injective R K)
theorem FaithfulSMul.of_field_isFractionRing (K L : Type*) [Field K] [Semiring L]
[Nontrivial L] [Algebra R K] [IsFractionRing R K] [Algebra S L] [Algebra K L] [Algebra R L]
[IsScalarTower R S L] [IsScalarTower R K L] : FaithfulSMul R S :=
(faithfulSMul_iff_algebraMap_injective R S).mpr <|
algebraMap_injective_of_field_isFractionRing R S K L
end algebraMap_injective
variable (A)
/-- The fraction ring of a commutative ring `R` as a quotient type.
We instantiate this definition as generally as possible, and assume that the
commutative ring `R` is an integral domain only when this is needed for proving.
In this generality, this construction is also known as the *total fraction ring* of `R`.
-/
abbrev FractionRing :=
Localization (nonZeroDivisors R)
namespace FractionRing
instance : IsFractionRing (FractionRing R) (FractionRing R) := IsFractionRing.idem R _
instance unique [Subsingleton R] : Unique (FractionRing R) := inferInstance
instance [Nontrivial R] : Nontrivial (FractionRing R) := inferInstance
variable [IsDomain A]
noncomputable instance field : Field (FractionRing A) := inferInstance
@[simp]
theorem mk_eq_div {r s} :
(Localization.mk r s : FractionRing A) =
(algebraMap _ _ r / algebraMap A _ s : FractionRing A) := by
rw [Localization.mk_eq_mk', IsFractionRing.mk'_eq_div]
section liftAlgebra
variable [Field K] [Algebra R K] [FaithfulSMul R K]
/-- This is not an instance because it creates a diamond when `K = FractionRing R`.
Should usually be introduced locally along with `isScalarTower_liftAlgebra`
See note [reducible non-instances]. -/
noncomputable abbrev liftAlgebra : Algebra (FractionRing R) K :=
have := (FaithfulSMul.algebraMap_injective R K).isDomain
RingHom.toAlgebra (IsFractionRing.lift (FaithfulSMul.algebraMap_injective R K))
attribute [local instance] liftAlgebra
instance isScalarTower_liftAlgebra : IsScalarTower R (FractionRing R) K :=
have := (FaithfulSMul.algebraMap_injective R K).isDomain
.of_algebraMap_eq fun x ↦
(IsFractionRing.lift_algebraMap (FaithfulSMul.algebraMap_injective R K) x).symm
lemma algebraMap_liftAlgebra :
have := (FaithfulSMul.algebraMap_injective R K).isDomain
algebraMap (FractionRing R) K = IsFractionRing.lift (FaithfulSMul.algebraMap_injective R _) :=
rfl
instance {R₀} [SMul R₀ R] [IsScalarTower R₀ R R] [SMul R₀ K] [IsScalarTower R₀ R K] :
IsScalarTower R₀ (FractionRing R) K := IsScalarTower.to₁₃₄ _ R _ _
end liftAlgebra
/-- Given a ring `A` and a localization map to a fraction ring
`f : A →+* K`, we get an `A`-isomorphism between the fraction ring of `A` as a quotient
type and `K`. -/
noncomputable def algEquiv (K : Type*) [CommRing K] [Algebra A K] [IsFractionRing A K] :
FractionRing A ≃ₐ[A] K :=
Localization.algEquiv (nonZeroDivisors A) K
instance [Algebra R A] [FaithfulSMul R A] : FaithfulSMul R (FractionRing A) := by
rw [faithfulSMul_iff_algebraMap_injective, IsScalarTower.algebraMap_eq R A]
exact (FaithfulSMul.algebraMap_injective A (FractionRing A)).comp
(FaithfulSMul.algebraMap_injective R A)
section IsScalarTower
attribute [local instance] liftAlgebra
instance (k K : Type*) [Field k] [Field K] [Algebra A k] [Algebra A K] [Algebra k K]
[FaithfulSMul A k] [FaithfulSMul A K] [IsScalarTower A k K] :
IsScalarTower (FractionRing A) k K where
smul_assoc a b c := a.ind fun ⟨a₁, a₂⟩ ↦ by
rw [← smul_right_inj (nonZeroDivisors.coe_ne_zero a₂)]
simp_rw [← smul_assoc, Localization.smul_mk, smul_eq_mul, Localization.mk_eq_mk',
IsLocalization.mk'_mul_cancel_left, algebraMap_smul, smul_assoc]
end IsScalarTower
end FractionRing |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Away/Lemmas.lean | import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.Localization.Submodule
/-!
# More lemmas on localization away
This file contains lemmas on localization away from an element requiring more imports.
-/
variable {R : Type*} [CommRing R]
namespace IsLocalization.Away
/-- Given a set `s` in a ring `R` and for every `t : s` a set `p t` of fractions in
a localization of `R` at `t`, this is the function sending a pair `(t, y)`, with
`t : s` and `y : t a`, to `t` multiplied with a numerator of `y`. The range
of this function spans the unit ideal, if `s` and every `p t` do. -/
noncomputable def mulNumerator (s : Set R)
{Rₜ : s → Type*} [∀ t, CommRing (Rₜ t)] [∀ t, Algebra R (Rₜ t)]
[∀ t, IsLocalization.Away t.val (Rₜ t)]
(p : (t : s) → Set (Rₜ t)) (x : (t : s) × p t) : R :=
x.1 * (IsLocalization.Away.sec x.1.1 x.2.1).1
lemma span_range_mulNumerator_eq_top {s : Set R}
(hsone : Ideal.span s = ⊤) {Rₜ : s → Type*} [∀ t, CommRing (Rₜ t)] [∀ t, Algebra R (Rₜ t)]
[∀ t, IsLocalization.Away t.val (Rₜ t)]
{p : (t : s) → Set (Rₜ t)} (htone : ∀ (r : s), Ideal.span (p r) = ⊤) :
Ideal.span (Set.range (IsLocalization.Away.mulNumerator s p)) = ⊤ := by
rw [← Ideal.radical_eq_top, eq_top_iff, ← hsone, Ideal.span_le]
intro a ha
haveI : IsLocalization (Submonoid.powers a) (Rₜ ⟨a, ha⟩) :=
inferInstanceAs <| IsLocalization.Away (⟨a, ha⟩ : s).val (Rₜ ⟨a, ha⟩)
have h₁ : Ideal.span (p ⟨a, ha⟩) ≤ Ideal.span
(algebraMap R (Rₜ ⟨a, ha⟩) '' Set.range (IsLocalization.Away.mulNumerator s p)) := by
rw [Ideal.span_le]
intro x hx
rw [SetLike.mem_coe, IsLocalization.mem_span_map (Submonoid.powers a)]
refine ⟨a * (IsLocalization.Away.sec a x).1, Ideal.subset_span ⟨⟨⟨a, ha⟩, ⟨x, hx⟩⟩, rfl⟩, ?_⟩
use ⟨a ^ ((IsLocalization.Away.sec a x).2 + 1), _, rfl⟩
rw [IsLocalization.eq_mk'_iff_mul_eq, map_pow, map_mul, ← map_pow, pow_add, map_mul,
← mul_assoc, IsLocalization.Away.sec_spec a x, mul_comm, pow_one]
have h₂ : IsLocalization.mk' (Rₜ ⟨a, ha⟩) 1 (1 : Submonoid.powers a) ∈ Ideal.span
(algebraMap R (Rₜ ⟨a, ha⟩) ''
(Set.range <| IsLocalization.Away.mulNumerator s p)) := by
rw [IsLocalization.mk'_one]
apply h₁
simp [htone]
rw [IsLocalization.mem_span_map (Submonoid.powers a)] at h₂
obtain ⟨y, hy, ⟨-, m, rfl⟩, hyz⟩ := h₂
rw [IsLocalization.eq] at hyz
obtain ⟨⟨-, n, rfl⟩, hc⟩ := hyz
simp only [OneMemClass.coe_one, one_mul, mul_one] at hc
use n + m
simpa [pow_add, hc] using Ideal.mul_mem_left _ _ hy
lemma quotient_of_isIdempotentElem {e : R} (he : IsIdempotentElem e) :
IsLocalization.Away e (R ⧸ Ideal.span {1 - e}) :=
away_of_isIdempotentElem he Ideal.mk_ker Quotient.mk_surjective
end IsLocalization.Away |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Away/AdjoinRoot.lean | import Mathlib.RingTheory.AdjoinRoot
import Mathlib.RingTheory.Localization.Away.Basic
/-!
The `R`-`AlgEquiv` between the localization of `R` away from `r` and
`R` with an inverse of `r` adjoined.
-/
open Polynomial AdjoinRoot Localization
variable {R : Type*} [CommRing R]
attribute [local instance] AdjoinRoot.algHom_subsingleton
/-- The `R`-`AlgEquiv` between the localization of `R` away from `r` and
`R` with an inverse of `r` adjoined. -/
noncomputable def Localization.awayEquivAdjoin (r : R) : Away r ≃ₐ[R] AdjoinRoot (C r * X - 1) :=
AlgEquiv.ofAlgHom
{ awayLift _ r _ with
commutes' :=
IsLocalization.Away.lift_eq r (.of_mul_eq_one _ <| root_isInv r) }
(liftAlgHom _ (Algebra.ofId _ _) (IsLocalization.Away.invSelf r) <| show aeval _ _ = _ by simp)
(Subsingleton.elim _ _)
(Subsingleton.elim (h := IsLocalization.algHom_subsingleton (Submonoid.powers r)) _ _)
theorem IsLocalization.adjoin_inv (r : R) : IsLocalization.Away r (AdjoinRoot <| C r * X - 1) :=
IsLocalization.isLocalization_of_algEquiv _ (Localization.awayEquivAdjoin r)
theorem IsLocalization.Away.finitePresentation (r : R) {S} [CommRing S] [Algebra R S]
[IsLocalization.Away r S] : Algebra.FinitePresentation R S :=
(AdjoinRoot.finitePresentation _).equiv <|
(Localization.awayEquivAdjoin r).symm.trans <| IsLocalization.algEquiv (Submonoid.powers r) _ _ |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/Away/Basic.lean | import Mathlib.GroupTheory.MonoidLocalization.Away
import Mathlib.Algebra.Algebra.Pi
import Mathlib.RingTheory.Ideal.Maps
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.UniqueFactorizationDomain.Multiplicity
/-!
# Localizations away from an element
## Main definitions
* `IsLocalization.Away (x : R) S` expresses that `S` is a localization away from `x`, as an
abbreviation of `IsLocalization (Submonoid.powers x) S`.
* `exists_reduced_fraction' (hb : b ≠ 0)` produces a reduced fraction of the form `b = a * x^n` for
some `n : ℤ` and some `a : R` that is not divisible by `x`.
## Implementation notes
See `Mathlib/RingTheory/Localization/Basic.lean` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
section CommSemiring
variable {R : Type*} [CommSemiring R] (M : Submonoid R) {S : Type*} [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
namespace IsLocalization
section Away
variable (x : R)
/-- Given `x : R`, the typeclass `IsLocalization.Away x S` states that `S` is
isomorphic to the localization of `R` at the submonoid generated by `x`.
See `IsLocalization.Away.mk` for a specialized constructor. -/
abbrev Away (S : Type*) [CommSemiring S] [Algebra R S] :=
IsLocalization (Submonoid.powers x) S
namespace Away
variable [IsLocalization.Away x S]
/-- Given `x : R` and a localization map `F : R →+* S` away from `x`, `invSelf` is `(F x)⁻¹`. -/
noncomputable def invSelf : S :=
mk' S (1 : R) ⟨x, Submonoid.mem_powers _⟩
@[simp]
theorem mul_invSelf : algebraMap R S x * invSelf x = 1 := by
convert IsLocalization.mk'_mul_mk'_eq_one (M := Submonoid.powers x) (S := S) _ 1
symm
apply IsLocalization.mk'_one
/-- For `s : S` with `S` being the localization of `R` away from `x`,
this is a choice of `(r, n) : R × ℕ` such that `s * algebraMap R S (x ^ n) = algebraMap R S r`. -/
noncomputable def sec (s : S) : R × ℕ :=
⟨(IsLocalization.sec (Submonoid.powers x) s).1,
(IsLocalization.sec (Submonoid.powers x) s).2.property.choose⟩
lemma sec_spec (s : S) : s * (algebraMap R S) (x ^ (IsLocalization.Away.sec x s).2) =
algebraMap R S (IsLocalization.Away.sec x s).1 := by
simp only [IsLocalization.Away.sec, ← IsLocalization.sec_spec]
congr
exact (IsLocalization.sec (Submonoid.powers x) s).2.property.choose_spec
lemma algebraMap_pow_isUnit (n : ℕ) : IsUnit (algebraMap R S x ^ n) :=
IsUnit.pow _ <| IsLocalization.map_units _ (⟨x, 1, by simp⟩ : Submonoid.powers x)
lemma algebraMap_isUnit : IsUnit (algebraMap R S x) :=
IsLocalization.map_units _ (⟨x, 1, by simp⟩ : Submonoid.powers x)
theorem associated_sec_fst (s : S) :
Associated (algebraMap R S (IsLocalization.Away.sec x s).1) s := by
rw [← IsLocalization.Away.sec_spec, map_pow]
exact associated_mul_unit_left _ _ <| .pow _ <| IsLocalization.Away.algebraMap_isUnit _
lemma algebraMap_isUnit_iff {y : R} : IsUnit (algebraMap R S y) ↔ ∃ n, y ∣ x ^ n :=
(IsLocalization.algebraMap_isUnit_iff <| .powers x).trans <| by simp [Submonoid.mem_powers_iff]
lemma surj (z : S) : ∃ (n : ℕ) (a : R), z * algebraMap R S x ^ n = algebraMap R S a := by
obtain ⟨⟨a, ⟨-, n, rfl⟩⟩, h⟩ := IsLocalization.surj (Submonoid.powers x) z
use n, a
simpa using h
lemma exists_of_eq {a b : R} (h : algebraMap R S a = algebraMap R S b) :
∃ (n : ℕ), x ^ n * a = x ^ n * b := by
obtain ⟨⟨-, n, rfl⟩, hx⟩ := IsLocalization.exists_of_eq (M := Submonoid.powers x) h
use n
/-- Specialized constructor for `IsLocalization.Away`. -/
lemma mk (r : R) (map_unit : IsUnit (algebraMap R S r))
(surj : ∀ s, ∃ (n : ℕ) (a : R), s * algebraMap R S r ^ n = algebraMap R S a)
(exists_of_eq : ∀ a b, algebraMap R S a = algebraMap R S b → ∃ (n : ℕ), r ^ n * a = r ^ n * b) :
IsLocalization.Away r S where
map_units := by
rintro ⟨-, n, rfl⟩
simp only [map_pow]
exact IsUnit.pow _ map_unit
surj z := by
obtain ⟨n, a, hn⟩ := surj z
use ⟨a, ⟨r ^ n, n, rfl⟩⟩
simpa using hn
exists_of_eq {x y} h := by
obtain ⟨n, hn⟩ := exists_of_eq x y h
use ⟨r ^ n, n, rfl⟩
lemma of_associated {r r' : R} (h : Associated r r') [IsLocalization.Away r S] :
IsLocalization.Away r' S := by
obtain ⟨u, rfl⟩ := h
refine mk _ ?_ (fun s ↦ ?_) (fun a b hab ↦ ?_)
· simp [algebraMap_isUnit r, IsUnit.map _ u.isUnit]
· obtain ⟨n, a, hn⟩ := surj r s
use n, a * u ^ n
simp [mul_pow, ← mul_assoc, hn]
· obtain ⟨n, hn⟩ := exists_of_eq r hab
use n
rw [mul_pow, mul_comm (r ^ n), mul_assoc, mul_assoc, hn]
/-- If `r` and `r'` are associated elements of `R`, an `R`-algebra `S`
is the localization of `R` away from `r` if and only if it is the localization of `R` away from
`r'`. -/
lemma iff_of_associated {r r' : R} (h : Associated r r') :
IsLocalization.Away r S ↔ IsLocalization.Away r' S :=
⟨fun _ ↦ IsLocalization.Away.of_associated h, fun _ ↦ IsLocalization.Away.of_associated h.symm⟩
lemma isUnit_of_dvd {r : R} (h : r ∣ x) : IsUnit (algebraMap R S r) :=
isUnit_of_dvd_unit (map_dvd _ h) (algebraMap_isUnit x)
variable {g : R →+* P}
/-- Given `x : R`, a localization map `F : R →+* S` away from `x`, and a map of `CommSemiring`s
`g : R →+* P` such that `g x` is invertible, the homomorphism induced from `S` to `P` sending
`z : S` to `g y * (g x)⁻ⁿ`, where `y : R, n : ℕ` are such that `z = F y * (F x)⁻ⁿ`. -/
noncomputable def lift (hg : IsUnit (g x)) : S →+* P :=
IsLocalization.lift fun y : Submonoid.powers x =>
show IsUnit (g y.1) by
obtain ⟨n, hn⟩ := y.2
rw [← hn, g.map_pow]
exact IsUnit.map (powMonoidHom n : P →* P) hg
@[simp]
theorem lift_eq (hg : IsUnit (g x)) (a : R) : lift x hg (algebraMap R S a) = g a :=
IsLocalization.lift_eq _ _
@[simp]
theorem lift_comp (hg : IsUnit (g x)) : (lift x hg).comp (algebraMap R S) = g :=
IsLocalization.lift_comp _
/-- Given `x y : R` and localizations `S`, `P` away from `x` and `y * x`
respectively, the homomorphism induced from `S` to `P`. -/
noncomputable def awayToAwayLeft (y : R) [Algebra R P] [IsLocalization.Away (y * x) P] : S →+* P :=
lift x <| isUnit_of_dvd (y * x) (dvd_mul_left _ _)
/-- Given `x y : R` and localizations `S`, `P` away from `x` and `x * y`
respectively, the homomorphism induced from `S` to `P`. -/
noncomputable def awayToAwayRight (y : R) [Algebra R P] [IsLocalization.Away (x * y) P] : S →+* P :=
lift x <| isUnit_of_dvd (x * y) (dvd_mul_right _ _)
theorem awayToAwayLeft_eq (y : R) [Algebra R P] [IsLocalization.Away (y * x) P] (a : R) :
awayToAwayLeft x y (algebraMap R S a) = algebraMap R P a :=
lift_eq _ _ _
theorem awayToAwayRight_eq (y : R) [Algebra R P] [IsLocalization.Away (x * y) P] (a : R) :
awayToAwayRight x y (algebraMap R S a) = algebraMap R P a :=
lift_eq _ _ _
variable (S) (Q : Type*) [CommSemiring Q] [Algebra P Q]
/-- Given a map `f : R →+* S` and an element `r : R`, we may construct a map `Rᵣ →+* Sᵣ`. -/
noncomputable def map (f : R →+* P) (r : R) [IsLocalization.Away r S]
[IsLocalization.Away (f r) Q] : S →+* Q :=
IsLocalization.map Q f
(show Submonoid.powers r ≤ (Submonoid.powers (f r)).comap f by
rintro x ⟨n, rfl⟩
use n
simp)
section Algebra
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable {B : Type*} [CommSemiring B] [Algebra R B]
variable (Aₚ : Type*) [CommSemiring Aₚ] [Algebra A Aₚ] [Algebra R Aₚ] [IsScalarTower R A Aₚ]
variable (Bₚ : Type*) [CommSemiring Bₚ] [Algebra B Bₚ] [Algebra R Bₚ] [IsScalarTower R B Bₚ]
instance {f : A →+* B} (a : A) [Away (f a) Bₚ] : IsLocalization (.map f (.powers a)) Bₚ := by
simpa
instance (x : R) [IsLocalization.Away (algebraMap R A x) Aₚ] :
IsLocalization (Algebra.algebraMapSubmonoid A (.powers x)) Aₚ := by
simpa
/-- Given a algebra map `f : A →ₐ[R] B` and an element `a : A`, we may construct a map
`Aₐ →ₐ[R] Bₐ`. -/
noncomputable def mapₐ (f : A →ₐ[R] B) (a : A) [Away a Aₚ] [Away (f a) Bₚ] : Aₚ →ₐ[R] Bₚ :=
⟨map Aₚ Bₚ f.toRingHom a, fun r ↦ by
dsimp only [AlgHom.toRingHom_eq_coe, map, RingHom.coe_coe, OneHom.toFun_eq_coe]
rw [IsScalarTower.algebraMap_apply R A Aₚ, IsScalarTower.algebraMap_eq R B Bₚ]
simp⟩
@[simp]
lemma mapₐ_apply (f : A →ₐ[R] B) (a : A) [Away a Aₚ] [Away (f a) Bₚ] (x : Aₚ) :
mapₐ Aₚ Bₚ f a x = map Aₚ Bₚ f.toRingHom a x :=
rfl
variable {Aₚ} {Bₚ}
lemma mapₐ_injective_of_injective {f : A →ₐ[R] B} (a : A) [Away a Aₚ] [Away (f a) Bₚ]
(hf : Function.Injective f) : Function.Injective (mapₐ Aₚ Bₚ f a) :=
IsLocalization.map_injective_of_injective _ _ _ hf
lemma mapₐ_surjective_of_surjective {f : A →ₐ[R] B} (a : A) [Away a Aₚ] [Away (f a) Bₚ]
(hf : Function.Surjective f) : Function.Surjective (mapₐ Aₚ Bₚ f a) :=
have : IsLocalization (Submonoid.map f.toRingHom (Submonoid.powers a)) Bₚ := by
simp only [AlgHom.toRingHom_eq_coe, Submonoid.map_powers, RingHom.coe_coe]
infer_instance
IsLocalization.map_surjective_of_surjective _ _ _ hf
end Algebra
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `y * x`. See `IsLocalization.Away.mul'` for the `x * y` version. -/
lemma mul (T : Type*) [CommSemiring T] [Algebra S T]
[Algebra R T] [IsScalarTower R S T] (x y : R)
[IsLocalization.Away x S] [IsLocalization.Away (algebraMap R S y) T] :
IsLocalization.Away (y * x) T := by
refine mk _ ?_ (fun z ↦ ?_) (fun a b h ↦ ?_)
· simp only [map_mul, IsUnit.mul_iff, IsScalarTower.algebraMap_apply R S T]
exact ⟨algebraMap_isUnit _, IsUnit.map _ (algebraMap_isUnit x)⟩
· obtain ⟨m, p, hpq⟩ := surj (algebraMap R S y) z
obtain ⟨n, a, hab⟩ := surj x p
use m + n, a * x ^ m * y ^ n
simp only [mul_pow, pow_add, map_pow, map_mul, ← mul_assoc, hpq,
IsScalarTower.algebraMap_apply R S T, ← hab]
ring
· repeat rw [IsScalarTower.algebraMap_apply R S T] at h
obtain ⟨n, hn⟩ := exists_of_eq (algebraMap R S y) h
simp only [← map_pow, ← map_mul, ← map_mul] at hn
obtain ⟨m, hm⟩ := exists_of_eq x hn
use n + m
convert_to y ^ m * x ^ n * (x ^ m * (y ^ n * a)) = y ^ m * x ^ n * (x ^ m * (y ^ n * b))
· ring
· ring
· rw [hm]
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `x * y`. See `IsLocalization.Away.mul` for the `y * x` version. -/
lemma mul' (T : Type*) [CommSemiring T] [Algebra S T] [Algebra R T] [IsScalarTower R S T] (x y : R)
[IsLocalization.Away x S] [IsLocalization.Away (algebraMap R S y) T] :
IsLocalization.Away (x * y) T :=
mul_comm x y ▸ mul S T x y
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `y * x`. -/
instance (x y : R) [IsLocalization.Away x S] :
IsLocalization.Away (y * x) (Localization.Away (algebraMap R S y)) :=
IsLocalization.Away.mul S (Localization.Away (algebraMap R S y)) _ _
/-- Localizing the localization of `R` at `x` at the image of `y` is the same as localizing
`R` at `x * y`. -/
instance (x y : R) [IsLocalization.Away x S] :
IsLocalization.Away (x * y) (Localization.Away (algebraMap R S y)) :=
IsLocalization.Away.mul' S (Localization.Away (algebraMap R S y)) _ _
/-- If `S₁` is the localization of `R` away from `f` and `S₂` is the localization away from `g`,
then any localization `T` of `S₂` away from `f` is also a localization of `S₁` away from `g`. -/
lemma commutes {R : Type*} [CommSemiring R] (S₁ S₂ T : Type*) [CommSemiring S₁]
[CommSemiring S₂] [CommSemiring T] [Algebra R S₁] [Algebra R S₂] [Algebra R T] [Algebra S₁ T]
[Algebra S₂ T] [IsScalarTower R S₁ T] [IsScalarTower R S₂ T] (x y : R)
[IsLocalization.Away x S₁] [IsLocalization.Away y S₂]
[IsLocalization.Away (algebraMap R S₂ x) T] :
IsLocalization.Away (algebraMap R S₁ y) T := by
convert IsLocalization.commutes S₁ S₂ T (Submonoid.powers x) (Submonoid.powers y)
ext x
simp
end Away
end Away
variable [IsLocalization M S]
section AtUnits
variable (R) (S)
/-- The localization away from a unit is isomorphic to the ring. -/
noncomputable def atUnit (x : R) (e : IsUnit x) [IsLocalization.Away x S] : R ≃ₐ[R] S :=
atUnits R (Submonoid.powers x)
(by rwa [Submonoid.powers_eq_closure, Submonoid.closure_le, Set.singleton_subset_iff])
/-- The localization at one is isomorphic to the ring. -/
noncomputable def atOne [IsLocalization.Away (1 : R) S] : R ≃ₐ[R] S :=
@atUnit R _ S _ _ (1 : R) isUnit_one _
theorem away_of_isUnit_of_bijective {R : Type*} (S : Type*) [CommSemiring R] [CommSemiring S]
[Algebra R S] {r : R} (hr : IsUnit r) (H : Function.Bijective (algebraMap R S)) :
IsLocalization.Away r S :=
{ map_units := by
rintro ⟨_, n, rfl⟩
exact (algebraMap R S).isUnit_map (hr.pow _)
surj := fun z => by
obtain ⟨z', rfl⟩ := H.2 z
exact ⟨⟨z', 1⟩, by simp⟩
exists_of_eq := fun {x y} => by
rw [H.1.eq_iff]
rintro rfl
exact ⟨1, rfl⟩ }
end AtUnits
section Prod
lemma away_of_isIdempotentElem_of_mul {R S} [CommSemiring R] [CommSemiring S] [Algebra R S]
{e : R} (he : IsIdempotentElem e)
(H : ∀ x y, algebraMap R S x = algebraMap R S y ↔ e * x = e * y)
(H' : Function.Surjective (algebraMap R S)) :
IsLocalization.Away e S where
map_units r := by
obtain ⟨r, n, rfl⟩ := r
simp [show algebraMap R S e = 1 by rw [← (algebraMap R S).map_one, H, mul_one, he]]
surj z := by
obtain ⟨z, rfl⟩ := H' z
exact ⟨⟨z, 1⟩, by simp⟩
exists_of_eq {x y} h := ⟨⟨e, Submonoid.mem_powers e⟩, (H x y).mp h⟩
lemma away_of_isIdempotentElem {R S} [CommRing R] [CommRing S] [Algebra R S]
{e : R} (he : IsIdempotentElem e)
(H : RingHom.ker (algebraMap R S) = Ideal.span {1 - e})
(H' : Function.Surjective (algebraMap R S)) :
IsLocalization.Away e S :=
away_of_isIdempotentElem_of_mul he (fun x y ↦ by
rw [← sub_eq_zero, ← map_sub, ← RingHom.mem_ker, H, ← he.ker_toSpanSingleton_eq_span,
LinearMap.mem_ker, LinearMap.toSpanSingleton_apply, sub_smul, sub_eq_zero]
simp_rw [mul_comm e, smul_eq_mul]) H'
instance away_fst {R S} [CommSemiring R] [CommSemiring S] :
letI := (RingHom.fst R S).toAlgebra
IsLocalization.Away (R := R × S) (1, 0) R :=
letI := (RingHom.fst R S).toAlgebra
away_of_isIdempotentElem_of_mul (by ext <;> simp)
(fun ⟨xR, xS⟩ ⟨yR, yS⟩ ↦ show xR = yR ↔ _ by simp) Prod.fst_surjective
instance away_snd {R S} [CommSemiring R] [CommSemiring S] :
letI := (RingHom.snd R S).toAlgebra
IsLocalization.Away (R := R × S) (0, 1) S :=
letI := (RingHom.snd R S).toAlgebra
away_of_isIdempotentElem_of_mul (by ext <;> simp)
(fun ⟨xR, xS⟩ ⟨yR, yS⟩ ↦ show xS = yS ↔ _ by simp) Prod.snd_surjective
end Prod
end IsLocalization
namespace Localization
open IsLocalization
variable {M}
/-- Given a map `f : R →+* S` and an element `r : R`, such that `f r` is invertible,
we may construct a map `Rᵣ →+* S`. -/
noncomputable abbrev awayLift (f : R →+* P) (r : R) (hr : IsUnit (f r)) :
Localization.Away r →+* P :=
IsLocalization.Away.lift r hr
lemma awayLift_mk {A : Type*} [CommSemiring A] (f : R →+* A) (r : R)
(a : R) (v : A) (hv : f r * v = 1) (j : ℕ) :
Localization.awayLift f r (isUnit_iff_exists_inv.mpr ⟨v, hv⟩)
(Localization.mk a ⟨r ^ j, j, rfl⟩) = f a * v ^ j := by
simp [Localization.mk_eq_mk', awayLift, Away.lift, IsLocalization.lift_mk',
Units.mul_inv_eq_iff_eq_mul, IsUnit.liftRight, mul_assoc, ← mul_pow, (mul_comm _ _).trans hv]
/-- Given a map `f : R →+* S` and an element `r : R`, we may construct a map `Rᵣ →+* Sᵣ`. -/
noncomputable abbrev awayMap (f : R →+* P) (r : R) :
Localization.Away r →+* Localization.Away (f r) :=
IsLocalization.Away.map _ _ f r
variable {A : Type*} [CommSemiring A] [Algebra R A]
variable {B : Type*} [CommSemiring B] [Algebra R B]
/-- Given a map `f : A →ₐ[R] B` and an element `a : A`, we may construct a map `Aₐ →ₐ[R] Bₐ`. -/
noncomputable abbrev awayMapₐ (f : A →ₐ[R] B) (a : A) :
Localization.Away a →ₐ[R] Localization.Away (f a) :=
IsLocalization.Away.mapₐ _ _ f a
theorem algebraMap_injective_of_span_eq_top (s : Set R) (span_eq : Ideal.span s = ⊤) :
Function.Injective (algebraMap R <| Π a : s, Away a.1) := fun x y eq ↦ by
suffices Module.eqIdeal R x y = ⊤ by simpa [Module.eqIdeal] using (Ideal.eq_top_iff_one _).mp this
by_contra ne
have ⟨r, hrs, disj⟩ := Ideal.exists_disjoint_powers_of_span_eq_top s span_eq _ ne
let r : s := ⟨r, hrs⟩
have ⟨⟨_, n, rfl⟩, eq⟩ := (IsLocalization.eq_iff_exists (.powers r.1) _).mp (congr_fun eq r)
exact Set.disjoint_left.mp disj eq ⟨n, rfl⟩
/-- The sheaf condition for the structure sheaf on `Spec R`
for a covering of the whole prime spectrum by basic opens. -/
theorem existsUnique_algebraMap_eq_of_span_eq_top (s : Set R) (span_eq : Ideal.span s = ⊤)
(f : Π a : s, Away a.1) (h : ∀ a b : s,
Away.awayToAwayRight (P := Away (a * b : R)) a.1 b (f a) = Away.awayToAwayLeft b.1 a (f b)) :
∃! r : R, ∀ a : s, algebraMap R _ r = f a := by
have mem := (Ideal.eq_top_iff_one _).mp span_eq; clear span_eq
wlog finset_eq : ∃ t : Finset R, t = s generalizing s
· have ⟨t, hts, mem⟩ := Submodule.mem_span_finite_of_mem_span mem
have ⟨r, eq, uniq⟩ := this t (fun a ↦ f ⟨a, hts a.2⟩)
(fun a b ↦ h ⟨a, hts a.2⟩ ⟨b, hts b.2⟩) mem ⟨_, rfl⟩
refine ⟨r, fun a ↦ ?_, fun _ eq ↦ uniq _ fun a ↦ eq ⟨a, hts a.2⟩⟩
replace hts := Set.insert_subset a.2 hts
classical
have ⟨r', eq, _⟩ := this ({a.1} ∪ t) (fun a ↦ f ⟨a, hts a.2⟩) (fun a b ↦
h ⟨a, hts a.2⟩ ⟨b, hts b.2⟩) (Ideal.span_mono (fun _ ↦ .inr) mem) ⟨{a.1} ∪ t, by simp⟩
exact (congr_arg _ (uniq _ fun b ↦ eq ⟨b, .inr b.2⟩).symm).trans (eq ⟨a, .inl rfl⟩)
have span_eq := (Ideal.eq_top_iff_one _).mpr mem
refine existsUnique_of_exists_of_unique ?_ fun x y hx hy ↦
algebraMap_injective_of_span_eq_top s span_eq (funext fun a ↦ (hx a).trans (hy a).symm)
obtain ⟨s, rfl⟩ := finset_eq
choose n r eq using fun a ↦ Away.surj a.1 (f a)
let N := s.attach.sup n
let r a := a ^ (N - n a) * r a
have eq a : f a * algebraMap R _ (a ^ N) = algebraMap R _ (r a) := by
rw [map_mul, ← eq, mul_left_comm, ← map_pow, ← map_mul, ← pow_add,
Nat.sub_add_cancel (Finset.le_sup <| s.mem_attach a)]
have eq2 a b : ∃ N', (a * b) ^ N' * (r a * b ^ N) = (a * b) ^ N' * (r b * a ^ N) :=
Away.exists_of_eq (S := Away (a * b : R)) _ <| by
simp_rw [map_mul, ← Away.awayToAwayRight_eq (S := Away a.1) a.1 b (r a),
← Away.awayToAwayLeft_eq (S := Away b.1) b.1 a (r b), ← eq, map_mul,
Away.awayToAwayRight_eq, Away.awayToAwayLeft_eq, h, mul_assoc, ← map_mul, mul_comm]
choose N' hN' using eq2
let N' := (s ×ˢ s).attach.sup fun a ↦ N'
⟨_, (Finset.mem_product.mp a.2).1⟩ ⟨_, (Finset.mem_product.mp a.2).2⟩
have eq2 a b : (a * b) ^ N' * (r a * b ^ N) = (a * b) ^ N' * (r b * a ^ N) := by
dsimp only [N']; rw [← Nat.sub_add_cancel (Finset.le_sup <| (Finset.mem_attach _ ⟨⟨a, b⟩,
Finset.mk_mem_product a.2 b.2⟩)), pow_add, mul_assoc, hN', ← mul_assoc]
let N := N' + N
let r a := a ^ N' * r a
have eq a : f a * algebraMap R _ (a ^ N) = algebraMap R _ (r a) := by
rw [map_mul, ← eq, mul_left_comm, ← map_mul, ← pow_add]
have eq2 a b : r a * b ^ N = r b * a ^ N := by
rw [pow_add, mul_mul_mul_comm, ← mul_pow, eq2,
mul_comm a.1, mul_pow, mul_mul_mul_comm, ← pow_add]
have ⟨c, eq1⟩ := (Submodule.mem_span_range_iff_exists_fun _).mp <|
(Ideal.eq_top_iff_one _).mp <| (Set.image_eq_range _ _ ▸ Ideal.span_pow_eq_top _ span_eq N)
refine ⟨∑ b, c b * r b, fun a ↦ ((Away.algebraMap_isUnit a.1).pow N).mul_left_inj.mp ?_⟩
simp_rw [← map_pow, eq, ← map_mul, Finset.sum_mul, mul_assoc, eq2 _ a, mul_left_comm (c _),
← Finset.mul_sum, ← smul_eq_mul (a := c _), eq1, mul_one]
end Localization
end CommSemiring
open Localization
variable {R : Type*} [CommSemiring R]
section NumDen
open IsLocalization
variable (x : R)
variable (B : Type*) [CommSemiring B] [Algebra R B] [IsLocalization.Away x B]
/-- `selfZPow x (m : ℤ)` is `x ^ m` as an element of the localization away from `x`. -/
noncomputable def selfZPow (m : ℤ) : B :=
if _ : 0 ≤ m then algebraMap _ _ x ^ m.natAbs else mk' _ (1 : R) (Submonoid.pow x m.natAbs)
theorem selfZPow_of_nonneg {n : ℤ} (hn : 0 ≤ n) : selfZPow x B n = algebraMap R B x ^ n.natAbs :=
dif_pos hn
@[simp]
theorem selfZPow_natCast (d : ℕ) : selfZPow x B d = algebraMap R B x ^ d :=
selfZPow_of_nonneg _ _ (Int.natCast_nonneg d)
@[simp]
theorem selfZPow_zero : selfZPow x B 0 = 1 := by
simp [selfZPow_of_nonneg _ _ le_rfl]
theorem selfZPow_of_neg {n : ℤ} (hn : n < 0) :
selfZPow x B n = mk' _ (1 : R) (Submonoid.pow x n.natAbs) :=
dif_neg hn.not_ge
theorem selfZPow_of_nonpos {n : ℤ} (hn : n ≤ 0) :
selfZPow x B n = mk' _ (1 : R) (Submonoid.pow x n.natAbs) := by
by_cases hn0 : n = 0
· simp [hn0, selfZPow_zero, Submonoid.pow_apply]
· simp [selfZPow_of_neg _ _ (lt_of_le_of_ne hn hn0)]
@[simp]
theorem selfZPow_neg_natCast (d : ℕ) : selfZPow x B (-d) = mk' _ (1 : R) (Submonoid.pow x d) := by
simp [selfZPow_of_nonpos _ _ (neg_nonpos.mpr (Int.natCast_nonneg d))]
@[simp]
theorem selfZPow_sub_natCast {n m : ℕ} :
selfZPow x B (n - m) = mk' _ (x ^ n) (Submonoid.pow x m) := by
by_cases! h : m ≤ n
· rw [IsLocalization.eq_mk'_iff_mul_eq, Submonoid.pow_apply, Subtype.coe_mk, ← Int.ofNat_sub h,
selfZPow_natCast, ← map_pow, ← map_mul, ← pow_add, Nat.sub_add_cancel h]
· rw [← neg_sub, ← Int.ofNat_sub h.le, selfZPow_neg_natCast, IsLocalization.mk'_eq_iff_eq]
simp [Submonoid.pow_apply, ← pow_add, Nat.sub_add_cancel h.le]
@[simp]
theorem selfZPow_add {n m : ℤ} : selfZPow x B (n + m) = selfZPow x B n * selfZPow x B m := by
rcases le_or_gt 0 n with hn | hn <;> rcases le_or_gt 0 m with hm | hm
· rw [selfZPow_of_nonneg _ _ hn, selfZPow_of_nonneg _ _ hm,
selfZPow_of_nonneg _ _ (add_nonneg hn hm), Int.natAbs_add_of_nonneg hn hm, pow_add]
· have : n + m = n.natAbs - m.natAbs := by
rw [Int.natAbs_of_nonneg hn, Int.ofNat_natAbs_of_nonpos hm.le, sub_neg_eq_add]
rw [selfZPow_of_nonneg _ _ hn, selfZPow_of_neg _ _ hm, this, selfZPow_sub_natCast,
IsLocalization.mk'_eq_mul_mk'_one, map_pow]
· have : n + m = m.natAbs - n.natAbs := by
rw [Int.natAbs_of_nonneg hm, Int.ofNat_natAbs_of_nonpos hn.le, sub_neg_eq_add, add_comm]
rw [selfZPow_of_nonneg _ _ hm, selfZPow_of_neg _ _ hn, this, selfZPow_sub_natCast,
IsLocalization.mk'_eq_mul_mk'_one, map_pow, mul_comm]
· rw [selfZPow_of_neg _ _ hn, selfZPow_of_neg _ _ hm, selfZPow_of_neg _ _ (add_neg hn hm),
Int.natAbs_add_of_nonpos hn.le hm.le, ← mk'_mul, one_mul]
congr
ext
simp [pow_add]
theorem selfZPow_mul_neg (d : ℤ) : selfZPow x B d * selfZPow x B (-d) = 1 := by
by_cases! hd : d ≤ 0
· rw [selfZPow_of_nonpos x B hd, selfZPow_of_nonneg, ← map_pow, Int.natAbs_neg,
Submonoid.pow_apply, IsLocalization.mk'_spec, map_one]
apply nonneg_of_neg_nonpos
rwa [neg_neg]
· rw [selfZPow_of_nonneg x B hd.le, selfZPow_of_nonpos, ← map_pow, Int.natAbs_neg,
Submonoid.pow_apply, IsLocalization.mk'_spec'_mk, map_one]
refine nonpos_of_neg_nonneg (le_of_lt ?_)
rwa [neg_neg]
theorem selfZPow_neg_mul (d : ℤ) : selfZPow x B (-d) * selfZPow x B d = 1 := by
rw [mul_comm, selfZPow_mul_neg x B d]
theorem selfZPow_pow_sub (a : R) (b : B) (m d : ℤ) :
selfZPow x B (m - d) * mk' B a (1 : Submonoid.powers x) = b ↔
selfZPow x B m * mk' B a (1 : Submonoid.powers x) = selfZPow x B d * b := by
rw [sub_eq_add_neg, selfZPow_add, mul_assoc, mul_comm _ (mk' B a 1), ← mul_assoc]
constructor
· intro h
have := congr_arg (fun s : B => s * selfZPow x B d) h
simp only at this
rwa [mul_assoc, mul_assoc, selfZPow_neg_mul, mul_one, mul_comm b _] at this
· intro h
have := congr_arg (fun s : B => s * selfZPow x B (-d)) h
simp only at this
rwa [mul_comm _ b, mul_assoc b _ _, selfZPow_mul_neg, mul_one] at this
variable {R : Type*} [CommRing R] (x : R) (B : Type*) [CommRing B]
variable [Algebra R B] [IsLocalization.Away x B] [IsDomain R] [WfDvdMonoid R]
theorem exists_reduced_fraction' {b : B} (hb : b ≠ 0) (hx : Irreducible x) :
∃ (a : R) (n : ℤ), ¬x ∣ a ∧ selfZPow x B n * algebraMap R B a = b := by
obtain ⟨⟨a₀, y⟩, H⟩ := surj (Submonoid.powers x) b
obtain ⟨d, hy⟩ := (Submonoid.mem_powers_iff y.1 x).mp y.2
have ha₀ : a₀ ≠ 0 := by
haveI := isDomain_of_le_nonZeroDivisors B
(powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
simp only [← hy, map_pow] at H
apply ((injective_iff_map_eq_zero' (algebraMap R B)).mp _ a₀).mpr.mt
· rw [← H]
apply mul_ne_zero hb (pow_ne_zero _ _)
exact
IsLocalization.to_map_ne_zero_of_mem_nonZeroDivisors B
(powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
(mem_nonZeroDivisors_iff_ne_zero.mpr hx.ne_zero)
· exact IsLocalization.injective B (powers_le_nonZeroDivisors_of_noZeroDivisors hx.ne_zero)
simp only [← hy] at H
obtain ⟨m, a, hyp1, hyp2⟩ := WfDvdMonoid.max_power_factor ha₀ hx
refine ⟨a, m - d, ?_⟩
rw [← mk'_one (M := Submonoid.powers x) B, selfZPow_pow_sub, selfZPow_natCast, selfZPow_natCast,
← map_pow _ _ d, mul_comm _ b, H, hyp2, map_mul, map_pow _ _ m]
exact ⟨hyp1, congr_arg _ (IsLocalization.mk'_one _ _)⟩
end NumDen |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/AtPrime/Extension.lean | import Mathlib.RingTheory.DedekindDomain.Dvr
/-!
# Primes in an extension of localization at prime
Let `R ⊆ S` be an extension of Dedekind domains and `p` be a prime ideal of `R`. Let `Rₚ` be the
localization of `R` at the complement of `p` and `Sₚ` the localization of `S` at the (image)
of the complement of `p`.
In this file, we study the relation between the (nonzero) prime ideals of `Sₚ` and the prime
ideals of `S` above `p`. In particular, we prove that (under suitable conditions) they are in
bijection.
# Main definitions and results
- `IsLocalization.AtPrime.mem_primesOver_of_isPrime`: The nonzero prime ideals of `Sₚ` are
primes over the maximal ideal of `Rₚ`.
- `IsDedekindDomain.primesOverEquivPrimesOver`: the order-preserving bijection between the primes
over `p` in `S` and the primes over the maximal ideal of `Rₚ` in `Sₚ`.
-/
open Algebra IsLocalRing Ideal Localization.AtPrime
variable {R S : Type*} [CommRing R] [CommRing S] [Algebra R S] (p : Ideal R) [p.IsPrime]
(Rₚ : Type*) [CommRing Rₚ] [Algebra R Rₚ] [IsLocalization.AtPrime Rₚ p] [IsLocalRing Rₚ]
(Sₚ : Type*) [CommRing Sₚ] [Algebra S Sₚ] [IsLocalization (algebraMapSubmonoid S p.primeCompl) Sₚ]
[Algebra Rₚ Sₚ] (P : Ideal S) [hPp : P.LiesOver p]
namespace IsLocalization.AtPrime
/--
The nonzero prime ideals of `Sₚ` are prime ideals over the maximal ideal of `Rₚ`.
See `Localization.AtPrime.primesOverEquivPrimesOver` for the bijection between the prime ideals
of `Sₚ` over the maximal ideal of `Rₚ` and the primes ideals of `S` above `p`.
-/
theorem mem_primesOver_of_isPrime {Q : Ideal Sₚ} [Q.IsMaximal] [Algebra.IsIntegral Rₚ Sₚ] :
Q ∈ (maximalIdeal Rₚ).primesOver Sₚ := by
refine ⟨inferInstance, ?_⟩
rw [liesOver_iff, ← eq_maximalIdeal]
exact IsMaximal.under Rₚ Q
theorem liesOver_comap_of_liesOver {T : Type*} [CommRing T] [Algebra R T] [Algebra Rₚ T]
[Algebra S T] [IsScalarTower R S T] [IsScalarTower R Rₚ T] (Q : Ideal T)
[Q.LiesOver (maximalIdeal Rₚ)] : (comap (algebraMap S T) Q).LiesOver p := by
have : Q.LiesOver p := by
have : (maximalIdeal Rₚ).LiesOver p := liesOver_maximalIdeal Rₚ p _
exact LiesOver.trans Q (IsLocalRing.maximalIdeal Rₚ) p
exact comap_liesOver Q p <| IsScalarTower.toAlgHom R S T
variable [Algebra R Sₚ] [IsScalarTower R S Sₚ] [IsScalarTower R Rₚ Sₚ]
include p in
theorem liesOver_map_of_liesOver [P.IsPrime] :
(P.map (algebraMap S Sₚ)).LiesOver (IsLocalRing.maximalIdeal Rₚ) := by
rw [liesOver_iff, eq_comm, ← map_eq_maximalIdeal p, over_def P p]
exact under_map_eq_map_under _
(over_def P p ▸ map_eq_maximalIdeal p Rₚ ▸ maximalIdeal.isMaximal Rₚ)
(isPrime_map_of_liesOver S p Sₚ P).ne_top
end IsLocalization.AtPrime
namespace IsDedekindDomain
open IsLocalization AtPrime
variable [Algebra R Sₚ] [IsScalarTower R S Sₚ] [IsScalarTower R Rₚ Sₚ] [IsDedekindDomain S]
[NoZeroSMulDivisors R S]
/--
For `R ⊆ S` an extension of Dedekind domains and `p` a prime ideal of `R`, the bijection
between the primes of `S` over `p` and the primes over the maximal ideal of `Rₚ` in `Sₚ` where
`Rₚ` and `Sₚ` are resp. the localizations of `R` and `S` at the complement of `p`.
-/
noncomputable def primesOverEquivPrimesOver (hp : p ≠ ⊥) :
p.primesOver S ≃o (maximalIdeal Rₚ).primesOver Sₚ where
toFun P := ⟨map (algebraMap S Sₚ) P.1, isPrime_map_of_liesOver S p Sₚ P.1,
liesOver_map_of_liesOver p Rₚ Sₚ P.1⟩
map_rel_iff' {Q Q'} := by
refine ⟨fun h ↦ ?_, fun h ↦ map_mono h⟩
have : Q'.1.IsMaximal :=
(primesOver.isPrime p Q').isMaximal (ne_bot_of_mem_primesOver hp Q'.prop)
simpa [comap_map_of_isMaximal S p] using le_comap_of_map_le h
invFun Q := ⟨comap (algebraMap S Sₚ) Q.1, IsPrime.under S Q.1,
liesOver_comap_of_liesOver p Rₚ Q.1⟩
left_inv P := by
have : P.val.IsMaximal := Ring.DimensionLEOne.maximalOfPrime
(ne_bot_of_mem_primesOver hp P.prop) (primesOver.isPrime p P)
exact SetCoe.ext <| IsLocalization.AtPrime.comap_map_of_isMaximal S p Sₚ P.1
right_inv Q := SetCoe.ext <| map_comap (algebraMapSubmonoid S p.primeCompl) Sₚ Q
@[simp]
theorem primesOverEquivPrimesOver_apply (hp : p ≠ ⊥) (P : p.primesOver S) :
primesOverEquivPrimesOver p Rₚ Sₚ hp P = Ideal.map (algebraMap S Sₚ) P := rfl
@[simp]
theorem primesOverEquivPrimesOver_symm_apply (hp : p ≠ ⊥) (Q : (maximalIdeal Rₚ).primesOver Sₚ) :
((primesOverEquivPrimesOver p Rₚ Sₚ hp).symm Q).1 = Ideal.comap (algebraMap S Sₚ) Q := rfl
end IsDedekindDomain |
.lake/packages/mathlib/Mathlib/RingTheory/Localization/AtPrime/Basic.lean | import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.LocalRing.MaximalIdeal.Basic
import Mathlib.RingTheory.Localization.Basic
import Mathlib.RingTheory.Localization.Ideal
import Mathlib.RingTheory.Ideal.MinimalPrime.Basic
/-!
# Localizations of commutative rings at the complement of a prime ideal
## Main definitions
* `IsLocalization.AtPrime (P : Ideal R) [IsPrime P] (S : Type*)` expresses that `S` is a
localization at (the complement of) a prime ideal `P`, as an abbreviation of
`IsLocalization P.prime_compl S`
## Main results
* `IsLocalization.AtPrime.isLocalRing`: a theorem (not an instance) stating a localization at the
complement of a prime ideal is a local ring
## Implementation notes
See `RingTheory.Localization.Basic` for a design overview.
## Tags
localization, ring localization, commutative ring localization, characteristic predicate,
commutative ring, field of fractions
-/
variable {R : Type*} [CommSemiring R] (S : Type*) [CommSemiring S]
variable [Algebra R S] {P : Type*} [CommSemiring P]
section AtPrime
variable (P : Ideal R) [hp : P.IsPrime]
/-- Given a prime ideal `P`, the typeclass `IsLocalization.AtPrime S P` states that `S` is
isomorphic to the localization of `R` at the complement of `P`. -/
protected abbrev IsLocalization.AtPrime :=
IsLocalization P.primeCompl S
/-- Given a prime ideal `P`, `Localization.AtPrime P` is a localization of
`R` at the complement of `P`, as a quotient type. -/
protected abbrev Localization.AtPrime :=
Localization P.primeCompl
namespace IsLocalization
theorem AtPrime.nontrivial [IsLocalization.AtPrime S P] : Nontrivial S :=
nontrivial_of_ne (0 : S) 1 fun hze => by
rw [← (algebraMap R S).map_one, ← (algebraMap R S).map_zero] at hze
obtain ⟨t, ht⟩ := (eq_iff_exists P.primeCompl S).1 hze
have htz : (t : R) = 0 := by simpa using ht.symm
exact t.2 (htz.symm ▸ P.zero_mem : ↑t ∈ P)
@[deprecated (since := "2025-07-31")] alias AtPrime.Nontrivial := IsLocalization.AtPrime.nontrivial
theorem AtPrime.isLocalRing [IsLocalization.AtPrime S P] : IsLocalRing S :=
letI := AtPrime.nontrivial S P -- Can't be a local instance because we can't figure out `P`.
IsLocalRing.of_nonunits_add
(by
intro x y hx hy hu
obtain ⟨z, hxyz⟩ := isUnit_iff_exists_inv.1 hu
have : ∀ {r : R} {s : P.primeCompl}, mk' S r s ∈ nonunits S → r ∈ P := fun {r s} =>
not_imp_comm.1 fun nr => isUnit_iff_exists_inv.2 ⟨mk' S ↑s (⟨r, nr⟩ : P.primeCompl),
mk'_mul_mk'_eq_one' _ _ <| show r ∈ P.primeCompl from nr⟩
rcases exists_mk'_eq P.primeCompl x with ⟨rx, sx, hrx⟩
rcases exists_mk'_eq P.primeCompl y with ⟨ry, sy, hry⟩
rcases exists_mk'_eq P.primeCompl z with ⟨rz, sz, hrz⟩
rw [← hrx, ← hry, ← hrz, ← mk'_add, ← mk'_mul, ← mk'_self S P.primeCompl.one_mem] at hxyz
rw [← hrx] at hx
rw [← hry] at hy
obtain ⟨t, ht⟩ := IsLocalization.eq.1 hxyz
simp only [mul_one, one_mul, Submonoid.coe_mul] at ht
suffices (t : R) * (sx * sy * sz) ∈ P from
not_or_intro (mt hp.mem_or_mem <| not_or_intro sx.2 sy.2) sz.2
(hp.mem_or_mem <| (hp.mem_or_mem this).resolve_left t.2)
rw [← ht]
exact
P.mul_mem_left _ <| P.mul_mem_right _ <|
P.add_mem (P.mul_mem_right _ <| this hx) <| P.mul_mem_right _ <| this hy)
end IsLocalization
namespace Localization
/-- The localization of `R` at the complement of a prime ideal is a local ring. -/
instance AtPrime.isLocalRing : IsLocalRing (Localization P.primeCompl) :=
IsLocalization.AtPrime.isLocalRing (Localization P.primeCompl) P
instance {R S : Type*} [CommRing R] [NoZeroDivisors R] {P : Ideal R} [CommRing S] [Algebra R S]
[NoZeroSMulDivisors R S] [IsDomain S] [P.IsPrime] :
NoZeroSMulDivisors (Localization.AtPrime P)
(Localization (Algebra.algebraMapSubmonoid S P.primeCompl)) :=
NoZeroSMulDivisors_of_isLocalization R S _ _ P.primeCompl_le_nonZeroDivisors
theorem _root_.IsLocalization.AtPrime.faithfulSMul (R : Type*) [CommRing R] [NoZeroDivisors R]
[Algebra R S] (P : Ideal R) [hp : P.IsPrime] [IsLocalization.AtPrime S P] :
FaithfulSMul R S := by
rw [faithfulSMul_iff_algebraMap_injective, IsLocalization.injective_iff_isRegular P.primeCompl]
exact fun ⟨_, h⟩ ↦ isRegular_of_ne_zero <| by aesop
instance {R : Type*} [CommRing R] [NoZeroDivisors R] (P : Ideal R) [hp : P.IsPrime] :
FaithfulSMul R (Localization.AtPrime P) := IsLocalization.AtPrime.faithfulSMul _ _ P
end Localization
end AtPrime
namespace IsLocalization
variable {A : Type*} [CommRing A] [IsDomain A]
/-- The localization of an integral domain at the complement of a prime ideal is an integral domain.
-/
instance isDomain_of_local_atPrime {P : Ideal A} (_ : P.IsPrime) :
IsDomain (Localization.AtPrime P) :=
isDomain_localization P.primeCompl_le_nonZeroDivisors
/-- This is an `IsLocalization.AtPrime` version for `IsLocalization.isDomain_of_local_atPrime`. -/
theorem isDomain_of_atPrime (S : Type*) [CommSemiring S] [Algebra A S]
(P : Ideal A) [P.IsPrime] [IsLocalization.AtPrime S P] : IsDomain S :=
isDomain_of_le_nonZeroDivisors S P.primeCompl_le_nonZeroDivisors
namespace AtPrime
variable (I : Ideal R) [hI : I.IsPrime] [IsLocalization.AtPrime S I]
/-- The prime ideals in the localization of a commutative ring at a prime ideal I are in
order-preserving bijection with the prime ideals contained in I. -/
@[simps!]
def orderIsoOfPrime : { p : Ideal S // p.IsPrime } ≃o { p : Ideal R // p.IsPrime ∧ p ≤ I } :=
(IsLocalization.orderIsoOfPrime I.primeCompl S).trans <| .setCongr _ _ <| show setOf _ = setOf _
by ext; simp [Ideal.primeCompl, ← le_compl_iff_disjoint_left]
/-- The prime spectrum of the localization of a commutative ring R at a prime ideal I are in
order-preserving bijection with the interval (-∞, I] in the prime spectrum of R. -/
@[simps!] def primeSpectrumOrderIso : PrimeSpectrum S ≃o Set.Iic (⟨I, hI⟩ : PrimeSpectrum R) :=
(PrimeSpectrum.equivSubtype S).trans <| (orderIsoOfPrime S I).trans
⟨⟨fun p ↦ ⟨⟨p, p.2.1⟩, p.2.2⟩, fun p ↦ ⟨p.1.1, p.1.2, p.2⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩, .rfl⟩
theorem isUnit_to_map_iff (x : R) : IsUnit ((algebraMap R S) x) ↔ x ∈ I.primeCompl :=
⟨fun h hx =>
(isPrime_of_isPrime_disjoint I.primeCompl S I hI disjoint_compl_left).ne_top <|
(Ideal.map (algebraMap R S) I).eq_top_of_isUnit_mem (Ideal.mem_map_of_mem _ hx) h,
fun h => map_units S ⟨x, h⟩⟩
-- Can't use typeclasses to infer the `IsLocalRing` instance, so use an `optParam` instead
-- (since `IsLocalRing` is a `Prop`, there should be no unification issues.)
theorem to_map_mem_maximal_iff (x : R) (h : IsLocalRing S := isLocalRing S I) :
algebraMap R S x ∈ IsLocalRing.maximalIdeal S ↔ x ∈ I :=
not_iff_not.mp <| by
simpa only [IsLocalRing.mem_maximalIdeal, mem_nonunits_iff, Classical.not_not] using
isUnit_to_map_iff S I x
theorem comap_maximalIdeal (h : IsLocalRing S := isLocalRing S I) :
(IsLocalRing.maximalIdeal S).comap (algebraMap R S) = I :=
Ideal.ext fun x => by simpa only [Ideal.mem_comap] using to_map_mem_maximal_iff _ I x
theorem liesOver_maximalIdeal (h : IsLocalRing S := isLocalRing S I) :
(IsLocalRing.maximalIdeal S).LiesOver I :=
(Ideal.liesOver_iff _ _).mpr (comap_maximalIdeal _ _).symm
theorem isUnit_mk'_iff (x : R) (y : I.primeCompl) : IsUnit (mk' S x y) ↔ x ∈ I.primeCompl :=
⟨fun h hx => mk'_mem_iff.mpr ((to_map_mem_maximal_iff S I x).mpr hx) h, fun h =>
isUnit_iff_exists_inv.mpr ⟨mk' S ↑y ⟨x, h⟩, mk'_mul_mk'_eq_one ⟨x, h⟩ y⟩⟩
theorem mk'_mem_maximal_iff (x : R) (y : I.primeCompl) (h : IsLocalRing S := isLocalRing S I) :
mk' S x y ∈ IsLocalRing.maximalIdeal S ↔ x ∈ I :=
not_iff_not.mp <| by
simpa only [IsLocalRing.mem_maximalIdeal, mem_nonunits_iff, Classical.not_not] using
isUnit_mk'_iff S I x y
end AtPrime
end IsLocalization
namespace Localization
open IsLocalization
variable (I : Ideal R) [hI : I.IsPrime]
variable {I}
/-- The unique maximal ideal of the localization at `I.primeCompl` lies over the ideal `I`. -/
theorem AtPrime.comap_maximalIdeal :
Ideal.comap (algebraMap R (Localization.AtPrime I))
(IsLocalRing.maximalIdeal (Localization I.primeCompl)) =
I :=
IsLocalization.AtPrime.comap_maximalIdeal _ _
/-- The image of `I` in the localization at `I.primeCompl` is a maximal ideal, and in particular
it is the unique maximal ideal given by the local ring structure `AtPrime.isLocalRing` -/
theorem AtPrime.map_eq_maximalIdeal :
Ideal.map (algebraMap R (Localization.AtPrime I)) I =
IsLocalRing.maximalIdeal (Localization I.primeCompl) := by
convert congr_arg (Ideal.map _) AtPrime.comap_maximalIdeal.symm
rw [map_comap I.primeCompl]
lemma AtPrime.eq_maximalIdeal_iff_comap_eq {J : Ideal (Localization.AtPrime I)} :
Ideal.comap (algebraMap R (Localization.AtPrime I)) J = I ↔
J = IsLocalRing.maximalIdeal (Localization.AtPrime I) where
mp h := le_antisymm (IsLocalRing.le_maximalIdeal (fun hJ ↦ (hI.ne_top (h.symm ▸ hJ ▸ rfl)))) <| by
simpa [← AtPrime.map_eq_maximalIdeal, ← h] using Ideal.map_comap_le
mpr h := h.symm ▸ AtPrime.comap_maximalIdeal
theorem le_comap_primeCompl_iff {J : Ideal P} [J.IsPrime] {f : R →+* P} :
I.primeCompl ≤ J.primeCompl.comap f ↔ J.comap f ≤ I :=
⟨fun h x hx => by
contrapose! hx
exact h hx,
fun h _ hx hfxJ => hx (h hfxJ)⟩
variable (I)
/-- For a ring hom `f : R →+* S` and a prime ideal `J` in `S`, the induced ring hom from the
localization of `R` at `J.comap f` to the localization of `S` at `J`.
To make this definition more flexible, we allow any ideal `I` of `R` as input, together with a proof
that `I = J.comap f`. This can be useful when `I` is not definitionally equal to `J.comap f`.
-/
noncomputable def localRingHom (J : Ideal P) [J.IsPrime] (f : R →+* P) (hIJ : I = J.comap f) :
Localization.AtPrime I →+* Localization.AtPrime J :=
IsLocalization.map (Localization.AtPrime J) f (le_comap_primeCompl_iff.mpr (ge_of_eq hIJ))
theorem localRingHom_to_map (J : Ideal P) [J.IsPrime] (f : R →+* P) (hIJ : I = J.comap f)
(x : R) : localRingHom I J f hIJ (algebraMap _ _ x) = algebraMap _ _ (f x) :=
map_eq _ _
theorem localRingHom_mk' (J : Ideal P) [J.IsPrime] (f : R →+* P) (hIJ : I = J.comap f) (x : R)
(y : I.primeCompl) :
localRingHom I J f hIJ (IsLocalization.mk' _ x y) =
IsLocalization.mk' (Localization.AtPrime J) (f x)
(⟨f y, le_comap_primeCompl_iff.mpr (ge_of_eq hIJ) y.2⟩ : J.primeCompl) :=
map_mk' _ _ _
@[instance]
theorem isLocalHom_localRingHom (J : Ideal P) [hJ : J.IsPrime] (f : R →+* P)
(hIJ : I = J.comap f) : IsLocalHom (localRingHom I J f hIJ) :=
IsLocalHom.mk fun x hx => by
rcases IsLocalization.exists_mk'_eq I.primeCompl x with ⟨r, s, rfl⟩
rw [localRingHom_mk'] at hx
rw [AtPrime.isUnit_mk'_iff] at hx ⊢
exact fun hr => hx ((SetLike.ext_iff.mp hIJ r).mp hr)
theorem localRingHom_unique (J : Ideal P) [J.IsPrime] (f : R →+* P) (hIJ : I = J.comap f)
{j : Localization.AtPrime I →+* Localization.AtPrime J}
(hj : ∀ x : R, j (algebraMap _ _ x) = algebraMap _ _ (f x)) : localRingHom I J f hIJ = j :=
map_unique _ _ hj
@[simp]
theorem localRingHom_id : localRingHom I I (RingHom.id R) (Ideal.comap_id I).symm = RingHom.id _ :=
localRingHom_unique _ _ _ _ fun _ => rfl
-- `simp` can't figure out `J` so this can't be a `@[simp]` lemma.
theorem localRingHom_comp {S : Type*} [CommSemiring S] (J : Ideal S) [hJ : J.IsPrime] (K : Ideal P)
[hK : K.IsPrime] (f : R →+* S) (hIJ : I = J.comap f) (g : S →+* P) (hJK : J = K.comap g) :
localRingHom I K (g.comp f) (by rw [hIJ, hJK, Ideal.comap_comap f g]) =
(localRingHom J K g hJK).comp (localRingHom I J f hIJ) :=
localRingHom_unique _ _ _ _ fun r => by
simp only [Function.comp_apply, RingHom.coe_comp, localRingHom_to_map]
namespace AtPrime
section
variable {A B : Type*} [CommRing A] [CommRing B] [Algebra A B]
[Algebra R A] [Algebra R B] [IsScalarTower R A B]
noncomputable instance (p : Ideal A) [p.IsPrime] (P : Ideal B) [P.IsPrime] [P.LiesOver p] :
Algebra (Localization.AtPrime p) (Localization.AtPrime P) :=
(Localization.localRingHom p P (algebraMap A B) Ideal.LiesOver.over).toAlgebra
instance (p : Ideal A) [p.IsPrime] (P : Ideal B) [P.IsPrime] [P.LiesOver p] :
IsScalarTower R (Localization.AtPrime p) (Localization.AtPrime P) :=
.of_algebraMap_eq <| by
simp [RingHom.algebraMap_toAlgebra, IsScalarTower.algebraMap_apply R A (Localization.AtPrime p),
Localization.localRingHom_to_map, IsScalarTower.algebraMap_apply R B (Localization.AtPrime P),
IsScalarTower.algebraMap_apply R A B]
end
variable {ι : Type*} {R : ι → Type*} [∀ i, CommSemiring (R i)]
variable {i : ι} (I : Ideal (R i)) [I.IsPrime]
/-- `Localization.localRingHom` specialized to a projection homomorphism from a product ring. -/
noncomputable abbrev mapPiEvalRingHom :
Localization.AtPrime (I.comap <| Pi.evalRingHom R i) →+* Localization.AtPrime I :=
localRingHom _ _ _ rfl
theorem mapPiEvalRingHom_bijective : Function.Bijective (mapPiEvalRingHom I) :=
Localization.mapPiEvalRingHom_bijective _
theorem mapPiEvalRingHom_comp_algebraMap :
(mapPiEvalRingHom I).comp (algebraMap _ _) = (algebraMap _ _).comp (Pi.evalRingHom R i) :=
IsLocalization.map_comp _
theorem mapPiEvalRingHom_algebraMap_apply {r : Π i, R i} :
mapPiEvalRingHom I (algebraMap _ _ r) = algebraMap _ _ (r i) :=
localRingHom_to_map ..
end AtPrime
end Localization
section
variable (q : Ideal R) [q.IsPrime] (M : Submonoid R) {S : Type*} [CommSemiring S] [Algebra R S]
[IsLocalization.AtPrime S q]
lemma Ideal.isPrime_map_of_isLocalizationAtPrime {p : Ideal R} [p.IsPrime] (hpq : p ≤ q) :
(p.map (algebraMap R S)).IsPrime := by
have disj : Disjoint (q.primeCompl : Set R) p := by
simp [Ideal.primeCompl, ← le_compl_iff_disjoint_left, hpq]
apply IsLocalization.isPrime_of_isPrime_disjoint q.primeCompl _ p (by simpa) disj
lemma Ideal.under_map_of_isLocalizationAtPrime {p : Ideal R} [p.IsPrime] (hpq : p ≤ q) :
(p.map (algebraMap R S)).under R = p := by
have disj : Disjoint (q.primeCompl : Set R) p := by
simp [Ideal.primeCompl, ← le_compl_iff_disjoint_left, hpq]
exact IsLocalization.comap_map_of_isPrime_disjoint _ _ p (by simpa) disj
lemma IsLocalization.subsingleton_primeSpectrum_of_mem_minimalPrimes
{R : Type*} [CommSemiring R] (p : Ideal R) (hp : p ∈ minimalPrimes R)
(S : Type*) [CommSemiring S] [Algebra R S] [IsLocalization.AtPrime S p (hp := hp.1.1)] :
Subsingleton (PrimeSpectrum S) :=
have := hp.1.1
have : Unique (Set.Iic (⟨p, hp.1.1⟩ : PrimeSpectrum R)) := ⟨⟨⟨p, hp.1.1⟩, by exact
fun ⦃x⦄ a ↦ a⟩, fun i ↦ Subtype.ext <| PrimeSpectrum.ext <|
(minimalPrimes_eq_minimals (R := R) ▸ hp).eq_of_le i.1.2 i.2⟩
(IsLocalization.AtPrime.primeSpectrumOrderIso S p).subsingleton
end
namespace IsLocalization.AtPrime
open Algebra IsLocalRing Ideal IsLocalization IsLocalization.AtPrime
variable (p : Ideal R) [p.IsPrime] (Rₚ : Type*) [CommSemiring Rₚ] [Algebra R Rₚ]
[IsLocalization.AtPrime Rₚ p] [IsLocalRing Rₚ] (Sₚ : Type*) [CommSemiring Sₚ] [Algebra S Sₚ]
[IsLocalization (Algebra.algebraMapSubmonoid S p.primeCompl) Sₚ] [Algebra Rₚ Sₚ]
(P : Ideal S)
theorem isPrime_map_of_liesOver [P.IsPrime] [P.LiesOver p] : (P.map (algebraMap S Sₚ)).IsPrime :=
isPrime_of_isPrime_disjoint _ _ _ inferInstance (Ideal.disjoint_primeCompl_of_liesOver P p)
theorem map_eq_maximalIdeal : p.map (algebraMap R Rₚ) = maximalIdeal Rₚ := by
convert congr_arg (Ideal.map (algebraMap R Rₚ)) (comap_maximalIdeal Rₚ p).symm
rw [map_comap p.primeCompl]
theorem comap_map_of_isMaximal [P.IsMaximal] [P.LiesOver p] :
Ideal.comap (algebraMap S Sₚ) (Ideal.map (algebraMap S Sₚ) P) = P :=
comap_map_eq_self_of_isMaximal _ (isPrime_map_of_liesOver S p Sₚ P).ne_top
end IsLocalization.AtPrime |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Summable.lean | import Mathlib.Algebra.Ring.Action.Rat
import Mathlib.RingTheory.HahnSeries.Multiplication
import Mathlib.Data.Rat.Cast.Lemmas
/-!
# Summable families of Hahn Series
We introduce a notion of formal summability for families of Hahn series, and define a formal sum
function. This theory is applied to characterize invertible Hahn series whose coefficients are in a
commutative domain.
## Main Definitions
* `HahnSeries.SummableFamily` is a family of Hahn series such that the union of the supports
is partially well-ordered and only finitely many are nonzero at any given coefficient. Note that
this is different from `Summable` in the valuation topology, because there are topologically
summable families that do not satisfy the axioms of `HahnSeries.SummableFamily`, and formally
summable families whose sums do not converge topologically.
* `HahnSeries.SummableFamily.hsum` is the formal sum of a summable family.
* `HahnSeries.SummableFamily.lsum` is the formal sum bundled as a `LinearMap`.
* `HahnSeries.SummableFamily.smul` is the summable family given by pointwise scalar multiplication
of component Hahn series.
* `HahnSeries.SummableFamily.mul` is the summable family given by pointwise multiplication.
* `HahnSeries.SummableFamily.powers` is the summable family given by non-negative powers of a
Hahn series, if the series has strictly positive order. If the series has non-positive order, then
the summable family takes the junk value of zero.
## Main results
* `HahnSeries.isUnit_iff`: If `R` is a commutative domain, and `Γ` is a linearly ordered additive
commutative group, then a Hahn series is a unit if and only if its leading term is a unit in `R`.
* `HahnSeries.SummableFamily.hsum_smul`: `smul` is compatible with `hsum`.
* `HahnSeries.SummableFamily.hsum_mul`: `mul` is compatible with `hsum`. That is, the product of
sums is equal to the sum of pointwise products.
## TODO
* Summable Pi families
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function
open Pointwise
noncomputable section
variable {Γ Γ' R V α β : Type*}
namespace HahnSeries
section
/-- A family of Hahn series whose formal coefficient-wise sum is a Hahn series. For each
coefficient of the sum to be well-defined, we require that only finitely many series are nonzero at
any given coefficient. For the formal sum to be a Hahn series, we require that the union of the
supports of the constituent series is partially well-ordered. -/
structure SummableFamily (Γ) (R) [PartialOrder Γ] [AddCommMonoid R] (α : Type*) where
/-- A parametrized family of Hahn series. -/
toFun : α → HahnSeries Γ R
isPWO_iUnion_support' : Set.IsPWO (⋃ a : α, (toFun a).support)
finite_co_support' : ∀ g : Γ, { a | (toFun a).coeff g ≠ 0 }.Finite
end
namespace SummableFamily
section AddCommMonoid
variable [PartialOrder Γ] [AddCommMonoid R]
instance : FunLike (SummableFamily Γ R α) α (HahnSeries Γ R) where
coe := toFun
coe_injective' | ⟨_, _, _⟩, ⟨_, _, _⟩, rfl => rfl
@[simp]
theorem coe_mk (toFun : α → HahnSeries Γ R) (h1 h2) :
(⟨toFun, h1, h2⟩ : SummableFamily Γ R α) = toFun :=
rfl
theorem isPWO_iUnion_support (s : SummableFamily Γ R α) : Set.IsPWO (⋃ a : α, (s a).support) :=
s.isPWO_iUnion_support'
theorem finite_co_support (s : SummableFamily Γ R α) (g : Γ) :
(Function.support fun a => (s a).coeff g).Finite :=
s.finite_co_support' g
theorem coe_injective : @Function.Injective (SummableFamily Γ R α) (α → HahnSeries Γ R) (⇑) :=
DFunLike.coe_injective
@[ext]
theorem ext {s t : SummableFamily Γ R α} (h : ∀ a : α, s a = t a) : s = t :=
DFunLike.ext s t h
instance : Add (SummableFamily Γ R α) :=
⟨fun x y =>
{ toFun := x + y
isPWO_iUnion_support' :=
(x.isPWO_iUnion_support.union y.isPWO_iUnion_support).mono
(by
rw [← Set.iUnion_union_distrib]
exact Set.iUnion_mono fun a => support_add_subset)
finite_co_support' := fun g =>
((x.finite_co_support g).union (y.finite_co_support g)).subset
(by
intro a ha
change (x a).coeff g + (y a).coeff g ≠ 0 at ha
rw [Set.mem_union, Function.mem_support, Function.mem_support]
contrapose! ha
rw [ha.1, ha.2, add_zero]) }⟩
instance : Zero (SummableFamily Γ R α) :=
⟨⟨0, by simp, by simp⟩⟩
instance : Inhabited (SummableFamily Γ R α) :=
⟨0⟩
@[simp]
theorem coe_add (s t : SummableFamily Γ R α) : ⇑(s + t) = s + t :=
rfl
theorem add_apply {s t : SummableFamily Γ R α} {a : α} : (s + t) a = s a + t a :=
rfl
@[simp]
theorem coe_zero : ((0 : SummableFamily Γ R α) : α → HahnSeries Γ R) = 0 :=
rfl
theorem zero_apply {a : α} : (0 : SummableFamily Γ R α) a = 0 :=
rfl
section SMul
variable {M} [SMulZeroClass M R]
instance : SMul M (SummableFamily Γ R β) :=
⟨fun r t =>
{ toFun := r • t
isPWO_iUnion_support' := t.isPWO_iUnion_support.mono (Set.iUnion_mono fun i =>
Pi.smul_apply r t i ▸ Function.support_const_smul_subset r _)
finite_co_support' := by
intro g
refine (t.finite_co_support g).subset ?_
intro i hi
simp only [Pi.smul_apply, coeff_smul, ne_eq, Set.mem_setOf_eq] at hi
simp only [Function.mem_support, ne_eq]
exact right_ne_zero_of_smul hi } ⟩
@[simp]
theorem coe_smul' (m : M) (s : SummableFamily Γ R α) : ⇑(m • s) = m • s :=
rfl
theorem smul_apply' (m : M) (s : SummableFamily Γ R α) (a : α) : (m • s) a = m • s a :=
rfl
end SMul
instance : AddCommMonoid (SummableFamily Γ R α) := fast_instance%
DFunLike.coe_injective.addCommMonoid _ coe_zero coe_add (fun _ _ => coe_smul' _ _)
/-- The coefficient function of a summable family, as a finsupp on the parameter type. -/
@[simps]
def coeff (s : SummableFamily Γ R α) (g : Γ) : α →₀ R where
support := (s.finite_co_support g).toFinset
toFun a := (s a).coeff g
mem_support_toFun a := by simp
@[simp]
theorem coeff_def (s : SummableFamily Γ R α) (a : α) (g : Γ) : s.coeff g a = (s a).coeff g :=
rfl
/-- The infinite sum of a `SummableFamily` of Hahn series. -/
def hsum (s : SummableFamily Γ R α) : HahnSeries Γ R where
coeff g := ∑ᶠ i, (s i).coeff g
isPWO_support' :=
s.isPWO_iUnion_support.mono fun g => by
contrapose
rw [Set.mem_iUnion, not_exists, Function.mem_support, Classical.not_not]
simp_rw [mem_support, Classical.not_not]
intro h
rw [finsum_congr h, finsum_zero]
@[simp]
theorem coeff_hsum {s : SummableFamily Γ R α} {g : Γ} : s.hsum.coeff g = ∑ᶠ i, (s i).coeff g :=
rfl
@[simp]
theorem hsum_zero : (0 : SummableFamily Γ R α).hsum = 0 := by
ext
simp
theorem support_hsum_subset {s : SummableFamily Γ R α} : s.hsum.support ⊆ ⋃ a : α, (s a).support :=
fun g hg => by
rw [mem_support, coeff_hsum, finsum_eq_sum _ (s.finite_co_support _)] at hg
obtain ⟨a, _, h2⟩ := exists_ne_zero_of_sum_ne_zero hg
rw [Set.mem_iUnion]
exact ⟨a, h2⟩
@[simp]
theorem hsum_add {s t : SummableFamily Γ R α} : (s + t).hsum = s.hsum + t.hsum := by
ext g
simp only [coeff_hsum, coeff_add, add_apply]
exact finsum_add_distrib (s.finite_co_support _) (t.finite_co_support _)
theorem coeff_hsum_eq_sum_of_subset {s : SummableFamily Γ R α} {g : Γ} {t : Finset α}
(h : { a | (s a).coeff g ≠ 0 } ⊆ t) : s.hsum.coeff g = ∑ i ∈ t, (s i).coeff g := by
simp only [coeff_hsum, finsum_eq_sum _ (s.finite_co_support _)]
exact sum_subset (Set.Finite.toFinset_subset.mpr h) (by simp)
theorem coeff_hsum_eq_sum {s : SummableFamily Γ R α} {g : Γ} :
s.hsum.coeff g = ∑ i ∈ (s.coeff g).support, (s i).coeff g := by
simp only [coeff_hsum, finsum_eq_sum _ (s.finite_co_support _), coeff_support]
/-- The summable family made of a single Hahn series. -/
@[simps]
def single {ι} [DecidableEq ι] (i : ι) (x : HahnSeries Γ R) : SummableFamily Γ R ι where
toFun := Pi.single i x
isPWO_iUnion_support' := by
have : (Pi.single (M := fun _ ↦ HahnSeries Γ R) i x i).support.IsPWO := by simp
refine this.mono <| Set.iUnion_subset fun a => ?_
obtain rfl | ha := eq_or_ne a i
· rfl
· simp [ha]
finite_co_support' g := (Set.finite_singleton i).subset fun j => by
obtain rfl | ha := eq_or_ne j i <;> simp [*]
@[simp]
theorem hsum_single {ι} [DecidableEq ι] (i : ι) (x : HahnSeries Γ R) : (single i x).hsum = x := by
ext g
rw [coeff_hsum, finsum_eq_single _ i, single_toFun, Pi.single_eq_same]
simp +contextual
/-- The summable family made of a constant Hahn series. -/
@[simps]
def const (ι) [Finite ι] (x : HahnSeries Γ R) : SummableFamily Γ R ι where
toFun _ := x
isPWO_iUnion_support' := by
cases isEmpty_or_nonempty ι
· simp
· exact Eq.mpr (congrArg (fun s ↦ s.IsPWO) (Set.iUnion_const x.support)) x.isPWO_support
finite_co_support' g := Set.toFinite {a | ((fun _ ↦ x) a).coeff g ≠ 0}
@[simp]
theorem hsum_unique {ι} [Unique ι] (x : SummableFamily Γ R ι) : x.hsum = x default := by
ext g
simp only [coeff_hsum, finsum_unique]
/-- A summable family induced by an equivalence of the parametrizing type. -/
@[simps]
def Equiv (e : α ≃ β) (s : SummableFamily Γ R α) : SummableFamily Γ R β where
toFun b := s (e.symm b)
isPWO_iUnion_support' := by
refine Set.IsPWO.mono s.isPWO_iUnion_support fun g => ?_
simp only [Set.mem_iUnion, mem_support, ne_eq, forall_exists_index]
exact fun b hg => Exists.intro (e.symm b) hg
finite_co_support' g :=
(Equiv.set_finite_iff e.subtypeEquivOfSubtype').mp <| s.finite_co_support' g
@[simp]
theorem hsum_equiv (e : α ≃ β) (s : SummableFamily Γ R α) : (Equiv e s).hsum = s.hsum := by
ext g
simp only [coeff_hsum, Equiv_toFun]
exact finsum_eq_of_bijective e.symm (Equiv.bijective e.symm) fun x => rfl
/-- The summable family given by multiplying every series in a summable family by a scalar. -/
@[simps]
def smulFamily [AddCommMonoid V] [SMulWithZero R V] (f : α → R) (s : SummableFamily Γ V α) :
SummableFamily Γ V α where
toFun a := (f a) • s a
isPWO_iUnion_support' := by
refine Set.IsPWO.mono s.isPWO_iUnion_support fun g hg => ?_
simp_all only [Set.mem_iUnion, mem_support, coeff_smul, ne_eq]
obtain ⟨i, hi⟩ := hg
exact Exists.intro i <| right_ne_zero_of_smul hi
finite_co_support' g := by
refine Set.Finite.subset (s.finite_co_support g) fun i hi => ?_
simp_all only [coeff_smul, ne_eq, Set.mem_setOf_eq, Function.mem_support]
exact right_ne_zero_of_smul hi
theorem hsum_smulFamily [AddCommMonoid V] [SMulWithZero R V] (f : α → R)
(s : SummableFamily Γ V α) (g : Γ) :
(smulFamily f s).hsum.coeff g = ∑ᶠ i, (f i) • ((s i).coeff g) :=
rfl
end AddCommMonoid
section AddCommGroup
variable [PartialOrder Γ] [AddCommGroup R] {s t : SummableFamily Γ R α} {a : α}
instance : Neg (SummableFamily Γ R α) where
neg s :=
{ toFun := fun a => -s a
isPWO_iUnion_support' := by
simp_rw [support_neg]
exact s.isPWO_iUnion_support
finite_co_support' := fun g => by
simp only [coeff_neg', Pi.neg_apply, Ne, neg_eq_zero]
exact s.finite_co_support g }
@[simp]
theorem coe_neg (s : SummableFamily Γ R α) : ⇑(-s) = -s :=
rfl
theorem neg_apply : (-s) a = -s a :=
rfl
instance : Sub (SummableFamily Γ R α) where
sub s s' :=
{ toFun := s - s'
isPWO_iUnion_support' := by
simp_rw [sub_eq_add_neg]
exact (s + -s').isPWO_iUnion_support
finite_co_support' g := by
simp_rw [sub_eq_add_neg]
exact (s + -s').finite_co_support' _ }
@[simp]
theorem coe_sub (s t : SummableFamily Γ R α) : ⇑(s - t) = s - t :=
rfl
theorem sub_apply : (s - t) a = s a - t a :=
rfl
instance : AddCommGroup (SummableFamily Γ R α) := fast_instance%
DFunLike.coe_injective.addCommGroup _ coe_zero coe_add coe_neg coe_sub
(fun _ _ => coe_smul' _ _) (fun _ _ => coe_smul' _ _)
end AddCommGroup
section SMul
variable [PartialOrder Γ] [PartialOrder Γ'] [AddCommMonoid V]
variable [AddCommMonoid R] [SMulWithZero R V]
theorem smul_support_subset_prod (s : SummableFamily Γ R α)
(t : SummableFamily Γ' V β) (gh : Γ × Γ') :
(Function.support fun (i : α × β) ↦ (s i.1).coeff gh.1 • (t i.2).coeff gh.2) ⊆
((s.finite_co_support' gh.1).prod (t.finite_co_support' gh.2)).toFinset := by
intro _ hab
simp_all only [Function.mem_support, ne_eq, Set.Finite.coe_toFinset, Set.mem_prod,
Set.mem_setOf_eq]
exact ⟨left_ne_zero_of_smul hab, right_ne_zero_of_smul hab⟩
theorem smul_support_finite (s : SummableFamily Γ R α)
(t : SummableFamily Γ' V β) (gh : Γ × Γ') :
(Function.support fun (i : α × β) ↦ (s i.1).coeff gh.1 • (t i.2).coeff gh.2).Finite :=
Set.Finite.subset (Set.toFinite ((s.finite_co_support' gh.1).prod
(t.finite_co_support' gh.2)).toFinset) (smul_support_subset_prod s t gh)
variable [VAdd Γ Γ'] [IsOrderedCancelVAdd Γ Γ']
open HahnModule
theorem isPWO_iUnion_support_prod_smul {s : α → HahnSeries Γ R} {t : β → HahnSeries Γ' V}
(hs : (⋃ a, (s a).support).IsPWO) (ht : (⋃ b, (t b).support).IsPWO) :
(⋃ (a : α × β), ((fun a ↦ (of R).symm
((s a.1) • (of R) (t a.2))) a).support).IsPWO := by
apply (hs.vadd ht).mono
have hsupp : ∀ ab : α × β, support ((fun ab ↦ (of R).symm (s ab.1 • (of R) (t ab.2))) ab) ⊆
(s ab.1).support +ᵥ (t ab.2).support := by
intro ab
refine Set.Subset.trans (fun x hx => ?_) (support_vaddAntidiagonal_subset_vadd
(hs := (s ab.1).isPWO_support) (ht := (t ab.2).isPWO_support))
contrapose! hx
simp only [Set.mem_setOf_eq, not_nonempty_iff_eq_empty] at hx
rw [mem_support, not_not, HahnModule.coeff_smul, hx, sum_empty]
refine Set.Subset.trans (Set.iUnion_mono fun a => (hsupp a)) ?_
simp_all only [Set.iUnion_subset_iff, Prod.forall]
exact fun a b => Set.vadd_subset_vadd (Set.subset_iUnion_of_subset a fun x y ↦ y)
(Set.subset_iUnion_of_subset b fun x y ↦ y)
theorem finite_co_support_prod_smul (s : SummableFamily Γ R α)
(t : SummableFamily Γ' V β) (g : Γ') :
Finite {(ab : α × β) |
((fun (ab : α × β) ↦ (of R).symm (s ab.1 • (of R) (t ab.2))) ab).coeff g ≠ 0} := by
apply ((VAddAntidiagonal s.isPWO_iUnion_support t.isPWO_iUnion_support g).finite_toSet.biUnion'
(fun gh _ => smul_support_finite s t gh)).subset _
exact fun ab hab => by
simp only [ne_eq, Set.mem_setOf_eq] at hab
obtain ⟨ij, hij⟩ := Finset.exists_ne_zero_of_sum_ne_zero hab
simp only [mem_coe, mem_vaddAntidiagonal, Set.mem_iUnion, mem_support, ne_eq,
Function.mem_support, exists_prop, Prod.exists]
exact ⟨ij.1, ij.2, ⟨⟨ab.1, left_ne_zero_of_smul hij.2⟩, ⟨ab.2, right_ne_zero_of_smul hij.2⟩,
((mem_vaddAntidiagonal _ _ _).mp hij.1).2.2⟩, hij.2⟩
/-- An elementwise scalar multiplication of one summable family on another. -/
@[simps]
def smul (s : SummableFamily Γ R α) (t : SummableFamily Γ' V β) : SummableFamily Γ' V (α × β) where
toFun ab := (of R).symm (s (ab.1) • ((of R) (t (ab.2))))
isPWO_iUnion_support' :=
isPWO_iUnion_support_prod_smul s.isPWO_iUnion_support t.isPWO_iUnion_support
finite_co_support' g := finite_co_support_prod_smul s t g
theorem sum_vAddAntidiagonal_eq (s : SummableFamily Γ R α) (t : SummableFamily Γ' V β) (g : Γ')
(a : α × β) :
∑ x ∈ VAddAntidiagonal (s a.1).isPWO_support' (t a.2).isPWO_support' g, (s a.1).coeff x.1 •
(t a.2).coeff x.2 = ∑ x ∈ VAddAntidiagonal s.isPWO_iUnion_support' t.isPWO_iUnion_support' g,
(s a.1).coeff x.1 • (t a.2).coeff x.2 := by
refine sum_subset (fun gh hgh => ?_) fun gh hgh h => ?_
· simp_all only [mem_vaddAntidiagonal, Function.mem_support, Set.mem_iUnion, mem_support]
exact ⟨Exists.intro a.1 hgh.1, Exists.intro a.2 hgh.2.1, trivial⟩
· by_cases hs : (s a.1).coeff gh.1 = 0
· exact smul_eq_zero_of_left hs ((t a.2).coeff gh.2)
· simp_all
theorem coeff_smul {R} {V} [Semiring R] [AddCommMonoid V] [Module R V]
(s : SummableFamily Γ R α) (t : SummableFamily Γ' V β) (g : Γ') :
(smul s t).hsum.coeff g = ∑ gh ∈ VAddAntidiagonal s.isPWO_iUnion_support
t.isPWO_iUnion_support g, (s.hsum.coeff gh.1) • (t.hsum.coeff gh.2) := by
rw [coeff_hsum]
simp only [coeff_hsum_eq_sum, smul_toFun, HahnModule.coeff_smul, Equiv.symm_apply_apply]
simp_rw [sum_vAddAntidiagonal_eq, Finset.smul_sum, Finset.sum_smul]
rw [← sum_finsum_comm _ _ <| fun gh _ => smul_support_finite s t gh]
refine sum_congr rfl fun gh _ => ?_
rw [finsum_eq_sum _ (smul_support_finite s t gh), ← sum_product_right']
refine sum_subset (fun ab hab => ?_) (fun ab _ hab => by simp_all)
have hsupp := smul_support_subset_prod s t gh
simp_all only [mem_vaddAntidiagonal, Set.mem_iUnion, mem_support, ne_eq, Set.Finite.mem_toFinset,
Function.mem_support, Set.Finite.coe_toFinset, support_subset_iff, Set.mem_prod,
Set.mem_setOf_eq, Prod.forall, coeff_support, mem_product]
exact hsupp ab.1 ab.2 hab
theorem smul_hsum {R} {V} [Semiring R] [AddCommMonoid V] [Module R V]
(s : SummableFamily Γ R α) (t : SummableFamily Γ' V β) :
(smul s t).hsum = (of R).symm (s.hsum • (of R) (t.hsum)) := by
ext g
rw [coeff_smul s t g, HahnModule.coeff_smul, Equiv.symm_apply_apply]
refine Eq.symm (sum_of_injOn (fun a ↦ a) (fun _ _ _ _ h ↦ h) (fun _ hgh => ?_)
(fun gh _ hgh => ?_) fun _ _ => by simp)
· simp_all only [mem_coe, mem_vaddAntidiagonal, mem_support, ne_eq, Set.mem_iUnion, and_true]
constructor
· rw [coeff_hsum_eq_sum] at hgh
have h' := Finset.exists_ne_zero_of_sum_ne_zero hgh.1
simpa using h'
· by_contra hi
simp_all
· simp only [Set.image_id', mem_coe, mem_vaddAntidiagonal, mem_support, ne_eq, not_and] at hgh
by_cases h : s.hsum.coeff gh.1 = 0
· exact smul_eq_zero_of_left h (t.hsum.coeff gh.2)
· simp_all
instance [AddCommMonoid R] [SMulWithZero R V] : SMul (HahnSeries Γ R) (SummableFamily Γ' V β) where
smul x t := Equiv (Equiv.punitProd β) <| smul (const Unit x) t
theorem smul_eq {x : HahnSeries Γ R} {t : SummableFamily Γ' V β} :
x • t = Equiv (Equiv.punitProd β) (smul (const Unit x) t) :=
rfl
@[simp]
theorem smul_apply {x : HahnSeries Γ R} {s : SummableFamily Γ' V α} {a : α} :
(x • s) a = (of R).symm (x • of R (s a)) :=
rfl
@[simp]
theorem hsum_smul_module {R} {V} [Semiring R] [AddCommMonoid V] [Module R V] {x : HahnSeries Γ R}
{s : SummableFamily Γ' V α} :
(x • s).hsum = (of R).symm (x • of R s.hsum) := by
rw [smul_eq, hsum_equiv, smul_hsum, hsum_unique, const_toFun]
end SMul
section Semiring
variable [AddCommMonoid Γ] [PartialOrder Γ] [IsOrderedCancelAddMonoid Γ]
[PartialOrder Γ'] [AddAction Γ Γ'] [IsOrderedCancelVAdd Γ Γ'] [Semiring R]
instance [AddCommMonoid V] [Module R V] : Module (HahnSeries Γ R) (SummableFamily Γ' V α) where
smul_zero _ := ext fun _ => by simp
zero_smul _ := ext fun _ => by simp
one_smul _ := ext fun _ => by rw [smul_apply, HahnModule.one_smul', Equiv.symm_apply_apply]
add_smul _ _ _ := ext fun _ => by simp [add_smul]
smul_add _ _ _ := ext fun _ => by simp
mul_smul _ _ _ := ext fun _ => by simp [HahnModule.instModule.mul_smul]
theorem hsum_smul {x : HahnSeries Γ R} {s : SummableFamily Γ R α} :
(x • s).hsum = x * s.hsum := by
rw [hsum_smul_module, of_symm_smul_of_eq_mul]
/-- The summation of a `summable_family` as a `LinearMap`. -/
@[simps]
def lsum : SummableFamily Γ R α →ₗ[HahnSeries Γ R] HahnSeries Γ R where
toFun := hsum
map_add' _ _ := hsum_add
map_smul' _ _ := hsum_smul
@[simp]
theorem hsum_sub {R : Type*} [Ring R] {s t : SummableFamily Γ R α} :
(s - t).hsum = s.hsum - t.hsum := by
rw [← lsum_apply, LinearMap.map_sub, lsum_apply, lsum_apply]
theorem isPWO_iUnion_support_prod_mul {s : α → HahnSeries Γ R} {t : β → HahnSeries Γ R}
(hs : (⋃ a, (s a).support).IsPWO) (ht : (⋃ b, (t b).support).IsPWO) :
(⋃ (a : α × β), ((fun a ↦ ((s a.1) * (t a.2))) a).support).IsPWO :=
isPWO_iUnion_support_prod_smul hs ht
theorem finite_co_support_prod_mul (s : SummableFamily Γ R α)
(t : SummableFamily Γ R β) (g : Γ) :
Finite {(a : α × β) | ((fun (a : α × β) ↦ (s a.1 * t a.2)) a).coeff g ≠ 0} :=
finite_co_support_prod_smul s t g
/-- A summable family given by pointwise multiplication of a pair of summable families. -/
@[simps]
def mul (s : SummableFamily Γ R α) (t : SummableFamily Γ R β) :
(SummableFamily Γ R (α × β)) where
toFun a := s (a.1) * t (a.2)
isPWO_iUnion_support' :=
isPWO_iUnion_support_prod_mul s.isPWO_iUnion_support t.isPWO_iUnion_support
finite_co_support' g := finite_co_support_prod_mul s t g
theorem mul_eq_smul (s : SummableFamily Γ R α) (t : SummableFamily Γ R β) :
mul s t = smul s t :=
rfl
theorem coeff_hsum_mul (s : SummableFamily Γ R α) (t : SummableFamily Γ R β) (g : Γ) :
(mul s t).hsum.coeff g = ∑ gh ∈ addAntidiagonal s.isPWO_iUnion_support
t.isPWO_iUnion_support g, (s.hsum.coeff gh.1) * (t.hsum.coeff gh.2) := by
simp_rw [← smul_eq_mul, mul_eq_smul]
exact coeff_smul s t g
theorem hsum_mul (s : SummableFamily Γ R α) (t : SummableFamily Γ R β) :
(mul s t).hsum = s.hsum * t.hsum := by
rw [← smul_eq_mul, mul_eq_smul]
exact smul_hsum s t
end Semiring
section OfFinsupp
variable [PartialOrder Γ] [AddCommMonoid R]
/-- A family with only finitely many nonzero elements is summable. -/
def ofFinsupp (f : α →₀ HahnSeries Γ R) : SummableFamily Γ R α where
toFun := f
isPWO_iUnion_support' := by
apply (f.support.isPWO_bUnion.2 fun a _ => (f a).isPWO_support).mono
refine Set.iUnion_subset_iff.2 fun a g hg => ?_
have haf : a ∈ f.support := by
rw [Finsupp.mem_support_iff, ← support_nonempty_iff]
exact ⟨g, hg⟩
exact Set.mem_biUnion haf hg
finite_co_support' g := by
refine f.support.finite_toSet.subset fun a ha => ?_
simp only [mem_coe, Finsupp.mem_support_iff, Ne]
contrapose! ha
simp [ha]
@[simp]
theorem coe_ofFinsupp {f : α →₀ HahnSeries Γ R} : ⇑(SummableFamily.ofFinsupp f) = f :=
rfl
@[simp]
theorem hsum_ofFinsupp {f : α →₀ HahnSeries Γ R} : (ofFinsupp f).hsum = f.sum fun _ => id := by
ext g
simp only [coeff_hsum, coe_ofFinsupp, Finsupp.sum]
simp_rw [← coeff.addMonoidHom_apply, id]
rw [map_sum, finsum_eq_sum_of_support_subset]
intro x h
simp only [mem_coe, Finsupp.mem_support_iff, Ne]
contrapose! h
simp [h]
end OfFinsupp
section EmbDomain
variable [PartialOrder Γ] [AddCommMonoid R]
open Classical in
/-- A summable family can be reindexed by an embedding without changing its sum. -/
def embDomain (s : SummableFamily Γ R α) (f : α ↪ β) : SummableFamily Γ R β where
toFun b := if h : b ∈ Set.range f then s (Classical.choose h) else 0
isPWO_iUnion_support' := by
refine s.isPWO_iUnion_support.mono (Set.iUnion_subset fun b g h => ?_)
by_cases hb : b ∈ Set.range f
· rw [dif_pos hb] at h
exact Set.mem_iUnion.2 ⟨Classical.choose hb, h⟩
· simp [-Set.mem_range, dif_neg hb] at h
finite_co_support' g :=
((s.finite_co_support g).image f).subset
(by
intro b h
by_cases hb : b ∈ Set.range f
· simp only [Ne, Set.mem_setOf_eq, dif_pos hb] at h
exact ⟨Classical.choose hb, h, Classical.choose_spec hb⟩
· simp only [Ne, Set.mem_setOf_eq, dif_neg hb, coeff_zero, not_true_eq_false] at h)
variable (s : SummableFamily Γ R α) (f : α ↪ β) {a : α} {b : β}
open Classical in
theorem embDomain_apply :
s.embDomain f b = if h : b ∈ Set.range f then s (Classical.choose h) else 0 :=
rfl
@[simp]
theorem embDomain_image : s.embDomain f (f a) = s a := by
rw [embDomain_apply, dif_pos (Set.mem_range_self a)]
exact congr rfl (f.injective (Classical.choose_spec (Set.mem_range_self a)))
@[simp]
theorem embDomain_notin_range (h : b ∉ Set.range f) : s.embDomain f b = 0 := by
rw [embDomain_apply, dif_neg h]
@[simp]
theorem hsum_embDomain : (s.embDomain f).hsum = s.hsum := by
classical
ext g
simp only [coeff_hsum, embDomain_apply, apply_dite HahnSeries.coeff, dite_apply, coeff_zero]
exact finsum_emb_domain f fun a => (s a).coeff g
end EmbDomain
section powers
theorem support_pow_subset_closure [AddCommMonoid Γ] [PartialOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Semiring R] (x : HahnSeries Γ R)
(n : ℕ) : support (x ^ n) ⊆ AddSubmonoid.closure (support x) := by
intro g hn
induction n generalizing g with
| zero =>
simp only [pow_zero, mem_support, coeff_one, ne_eq, ite_eq_right_iff, Classical.not_imp] at hn
simp only [hn, SetLike.mem_coe]
exact AddSubmonoid.zero_mem _
| succ n ih =>
obtain ⟨i, hi, j, hj, rfl⟩ := support_mul_subset_add_support hn
exact SetLike.mem_coe.2 (AddSubmonoid.add_mem _ (ih hi) (AddSubmonoid.subset_closure hj))
theorem isPWO_iUnion_support_powers [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Semiring R]
{x : HahnSeries Γ R} (hx : 0 ≤ x.order) :
(⋃ n : ℕ, (x ^ n).support).IsPWO :=
(x.isPWO_support'.addSubmonoid_closure
fun _ hg => le_trans hx (order_le_of_coeff_ne_zero (Function.mem_support.mp hg))).mono
(Set.iUnion_subset fun n => support_pow_subset_closure x n)
theorem co_support_zero [AddCommMonoid Γ] [PartialOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Semiring R] (g : Γ) :
{a | ¬((0 : HahnSeries Γ R) ^ a).coeff g = 0} ⊆ {0} := by
simp only [Set.subset_singleton_iff, Set.mem_setOf_eq]
intro n hn
by_contra h'
simp_all only [ne_eq, not_false_eq_true, zero_pow, coeff_zero, not_true_eq_false]
variable [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [CommRing R]
theorem pow_finite_co_support {x : HahnSeries Γ R} (hx : 0 < x.orderTop) (g : Γ) :
Set.Finite {a | ((fun n ↦ x ^ n) a).coeff g ≠ 0} := by
have hpwo : Set.IsPWO (⋃ n, support (x ^ n)) :=
isPWO_iUnion_support_powers (zero_le_orderTop_iff.mp <| le_of_lt hx)
by_cases h0 : x = 0; · exact h0 ▸ Set.Finite.subset (Set.finite_singleton 0) (co_support_zero g)
by_cases hg : g ∈ ⋃ n : ℕ, { g | (x ^ n).coeff g ≠ 0 }
swap; · exact Set.finite_empty.subset fun n hn => hg (Set.mem_iUnion.2 ⟨n, hn⟩)
apply hpwo.isWF.induction hg
intro y ys hy
refine ((((addAntidiagonal x.isPWO_support hpwo y).finite_toSet.biUnion
fun ij hij => hy ij.snd (mem_addAntidiagonal.1 (mem_coe.1 hij)).2.1 ?_).image Nat.succ).union
(Set.finite_singleton 0)).subset ?_
· obtain ⟨hi, _, rfl⟩ := mem_addAntidiagonal.1 (mem_coe.1 hij)
exact lt_add_of_pos_left ij.2 <| lt_of_lt_of_le ((zero_lt_orderTop_iff h0).mp hx) <|
order_le_of_coeff_ne_zero <| Function.mem_support.mp hi
· rintro (_ | n) hn
· exact Set.mem_union_right _ (Set.mem_singleton 0)
· obtain ⟨i, hi, j, hj, rfl⟩ := support_mul_subset_add_support hn
refine Set.mem_union_left _ ⟨n, Set.mem_iUnion.2 ⟨⟨j, i⟩, Set.mem_iUnion.2 ⟨?_, hi⟩⟩, rfl⟩
simp only [mem_coe, mem_addAntidiagonal, mem_support, ne_eq, Set.mem_iUnion]
exact ⟨hj, ⟨n, hi⟩, add_comm j i⟩
/-- A summable family of powers of a Hahn series `x`. If `x` has non-positive `orderTop`, then
return a junk value given by pretending `x = 0`. -/
@[simps]
def powers (x : HahnSeries Γ R) : SummableFamily Γ R ℕ where
toFun n := (if 0 < x.orderTop then x else 0) ^ n
isPWO_iUnion_support' := by
by_cases h : 0 < x.orderTop
· simp only [h, ↓reduceIte]
exact isPWO_iUnion_support_powers (zero_le_orderTop_iff.mp <| le_of_lt h)
· simp only [h, ↓reduceIte]
apply isPWO_iUnion_support_powers
rw [order_zero]
finite_co_support' g := by
by_cases h : 0 < x.orderTop
· simp only [h, ↓reduceIte]
exact pow_finite_co_support h g
· simp only [h, ↓reduceIte]
exact pow_finite_co_support (orderTop_zero (R := R) (Γ := Γ) ▸ WithTop.top_pos) g
theorem powers_of_orderTop_pos {x : HahnSeries Γ R} (hx : 0 < x.orderTop) (n : ℕ) :
powers x n = x ^ n := by
simp [hx]
theorem powers_of_not_orderTop_pos {x : HahnSeries Γ R} (hx : ¬ 0 < x.orderTop) :
powers x = .single 0 1 := by
ext a
obtain rfl | ha := eq_or_ne a 0 <;> simp [powers, *]
@[simp]
theorem powers_zero : powers (0 : HahnSeries Γ R) = .single 0 1 := by
ext n
rw [powers_of_orderTop_pos (by simp)]
obtain rfl | ha := eq_or_ne n 0 <;> simp [*]
variable {x : HahnSeries Γ R} (hx : 0 < x.orderTop)
include hx in
@[simp]
theorem coe_powers : ⇑(powers x) = HPow.hPow x := by
ext1 n
simp [hx]
include hx in
theorem embDomain_succ_smul_powers :
(x • powers x).embDomain ⟨Nat.succ, Nat.succ_injective⟩ =
powers x - ofFinsupp (Finsupp.single 0 1) := by
apply SummableFamily.ext
rintro (_ | n)
· simp [hx]
· -- FIXME: smul_eq_mul introduces type confusion between HahnModule and HahnSeries.
simp [embDomain_apply, of_symm_smul_of_eq_mul, powers_of_orderTop_pos hx, pow_succ',
-smul_eq_mul, -Algebra.id.smul_eq_mul]
include hx in
theorem one_sub_self_mul_hsum_powers : (1 - x) * (powers x).hsum = 1 := by
rw [← hsum_smul, sub_smul 1 x (powers x), one_smul, hsum_sub, ←
hsum_embDomain (x • powers x) ⟨Nat.succ, Nat.succ_injective⟩, embDomain_succ_smul_powers hx]
simp
end powers
end SummableFamily
section Inversion
section CommRing
variable [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [CommRing R]
theorem one_minus_single_neg_mul {x y : HahnSeries Γ R} {r : R} (hr : r * x.leadingCoeff = 1)
(hxy : x = y + single x.order x.leadingCoeff) (oinv : Γ) (hxo : oinv + x.order = 0) :
1 - single oinv r * x = -(single oinv r * y) := by
nth_rw 1 [hxy]
rw [mul_add, single_mul_single, hr, hxo,
sub_add_eq_sub_sub_swap, sub_eq_neg_self, sub_eq_zero_of_eq single_zero_one.symm]
theorem unit_aux (x : HahnSeries Γ R) {r : R} (hr : r * x.leadingCoeff = 1)
(oinv : Γ) (hxo : oinv + x.order = 0) :
0 < (1 - single oinv r * x).orderTop := by
let y := (x - single x.order x.leadingCoeff)
by_cases hy : y = 0
· have hrx : (single oinv) r * x = 1 := by
rw [eq_of_sub_eq_zero hy, single_mul_single, hxo, hr, single_zero_one]
simp only [hrx, sub_self, orderTop_zero, WithTop.top_pos]
· have hr' : IsRegular r := IsUnit.isRegular <| .of_mul_eq_one x.leadingCoeff hr
have hy' : 0 < (single oinv r * y).order := by
rw [(order_single_mul_of_isRegular hr' hy)]
refine pos_of_lt_add_right (a := x.order) ?_
rw [← add_assoc, add_comm x.order, hxo, zero_add]
exact order_lt_order_of_eq_add_single (sub_add_cancel x _).symm hy
rw [one_minus_single_neg_mul hr (sub_add_cancel x _).symm _ hxo, orderTop_neg]
exact zero_lt_orderTop_of_order hy'
theorem isUnit_of_isUnit_leadingCoeff_AddUnitOrder {x : HahnSeries Γ R} (hx : IsUnit x.leadingCoeff)
(hxo : IsAddUnit x.order) : IsUnit x := by
let ⟨⟨u, i, ui, iu⟩, h⟩ := hx
rw [Units.val_mk] at h
rw [h] at iu
have h' := SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu _ hxo.addUnit.neg_add)
rw [sub_sub_cancel] at h'
exact isUnit_of_mul_isUnit_right (.of_mul_eq_one _ h')
end CommRing
section IsDomain
variable [AddCommGroup Γ] [LinearOrder Γ] [IsOrderedAddMonoid Γ] [CommRing R] [IsDomain R]
theorem isUnit_iff {x : HahnSeries Γ R} : IsUnit x ↔ IsUnit (x.leadingCoeff) := by
constructor
· rintro ⟨⟨u, i, ui, iu⟩, rfl⟩
refine
.of_mul_eq_one (i.leadingCoeff)
((coeff_mul_order_add_order u i).symm.trans ?_)
rw [ui, coeff_one, if_pos]
rw [← order_mul (left_ne_zero_of_mul_eq_one ui) (right_ne_zero_of_mul_eq_one ui), ui, order_one]
· rintro ⟨⟨u, i, ui, iu⟩, hx⟩
rw [Units.val_mk] at hx
rw [hx] at iu
have h :=
SummableFamily.one_sub_self_mul_hsum_powers (unit_aux x iu _ (neg_add_cancel x.order))
rw [sub_sub_cancel] at h
exact isUnit_of_mul_isUnit_right (.of_mul_eq_one _ h)
end IsDomain
section Field
variable [AddCommGroup Γ] [LinearOrder Γ] [IsOrderedAddMonoid Γ] [Field R]
@[simps -isSimp inv]
instance : DivInvMonoid (HahnSeries Γ R) where
inv x :=
single (-x.order) (x.leadingCoeff)⁻¹ *
(SummableFamily.powers <| 1 - single (-x.order) (x.leadingCoeff)⁻¹ * x).hsum
@[simp]
theorem inv_single (a : Γ) (r : R) : (single a r)⁻¹ = single (-a) r⁻¹ := by
obtain rfl | hr := eq_or_ne r 0
· simp [inv_def]
· simp [inv_def, hr]
@[simp]
theorem single_div_single (a b : Γ) (r s : R) :
single a r / single b s = single (a - b) (r / s) := by
rw [div_eq_mul_inv, sub_eq_add_neg, div_eq_mul_inv, inv_single, single_mul_single]
instance instField : Field (HahnSeries Γ R) where
inv_zero := by simp [inv_def]
mul_inv_cancel x x0 := by
have h :=
SummableFamily.one_sub_self_mul_hsum_powers
(unit_aux x (inv_mul_cancel₀ (leadingCoeff_ne_zero.mpr x0)) _ (neg_add_cancel x.order))
rw [sub_sub_cancel] at h
rw [inv_def, ← mul_assoc, mul_comm x, h]
nnqsmul := (· • ·)
qsmul := (· • ·)
nnqsmul_def q x := by ext; simp [← single_zero_nnratCast, NNRat.smul_def]
qsmul_def q x := by ext; simp [← single_zero_ratCast, Rat.smul_def]
nnratCast_def q := by
simp [← single_zero_nnratCast, ← single_zero_natCast, NNRat.cast_def]
ratCast_def q := by
simp [← single_zero_ratCast, ← single_zero_intCast, ← single_zero_natCast, Rat.cast_def]
example : (instSMul : SMul NNRat (HahnSeries Γ R)) = NNRat.smulDivisionSemiring := rfl
example : (instSMul : SMul ℚ (HahnSeries Γ R)) = Rat.smulDivisionRing := rfl
theorem single_zero_ofScientific (m e s) :
single (0 : Γ) (OfScientific.ofScientific m e s : R) = OfScientific.ofScientific m e s := by
simpa using single_zero_ratCast (Γ := Γ) (R := R) (OfScientific.ofScientific m e s)
end Field
end Inversion
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Valuation.lean | import Mathlib.RingTheory.HahnSeries.Multiplication
import Mathlib.RingTheory.Valuation.Basic
/-!
# Valuations on Hahn Series rings
If `Γ` is a `LinearOrderedCancelAddCommMonoid` and `R` is a domain, then the domain `HahnSeries Γ R`
admits an additive valuation given by `orderTop`.
## Main Definitions
* `HahnSeries.addVal Γ R` defines an `AddValuation` on `HahnSeries Γ R` when `Γ` is linearly
ordered.
## TODO
* Multiplicative valuations
* Add any API for Laurent series valuations that do not depend on `Γ = ℤ`.
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
noncomputable section
variable {Γ R : Type*}
namespace HahnSeries
section Valuation
variable (Γ R) [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [Ring R] [IsDomain R]
/-- The additive valuation on `HahnSeries Γ R`, returning the smallest index at which
a Hahn Series has a nonzero coefficient, or `⊤` for the 0 series. -/
def addVal : AddValuation (HahnSeries Γ R) (WithTop Γ) :=
AddValuation.of orderTop orderTop_zero (orderTop_one) (fun _ _ => min_orderTop_le_orderTop_add)
fun x y => by
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
rw [← order_eq_orderTop_of_ne_zero hx, ← order_eq_orderTop_of_ne_zero hy,
← order_eq_orderTop_of_ne_zero (mul_ne_zero hx hy), ← WithTop.coe_add, WithTop.coe_eq_coe,
order_mul hx hy]
variable {Γ} {R}
theorem addVal_apply {x : HahnSeries Γ R} :
addVal Γ R x = x.orderTop :=
AddValuation.of_apply _
@[simp]
theorem addVal_apply_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) : addVal Γ R x = x.order :=
addVal_apply.trans (order_eq_orderTop_of_ne_zero hx).symm
theorem addVal_le_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) :
addVal Γ R x ≤ g :=
orderTop_le_of_coeff_ne_zero h
end Valuation
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/HahnEmbedding.lean | import Mathlib.Algebra.Order.Module.HahnEmbedding
import Mathlib.Algebra.Module.LinearMap.Rat
import Mathlib.Algebra.Field.Rat
import Mathlib.Analysis.RCLike.Basic
import Mathlib.Data.Real.Embedding
import Mathlib.GroupTheory.DivisibleHull
/-!
# Hahn embedding theorem
In this file, we prove the Hahn embedding theorem: every linearly ordered abelian group
can be embedded as an ordered subgroup of `Lex (HahnSeries Ω ℝ)`, where `Ω` is the finite
Archimedean classes of the group. The theorem is stated as `hahnEmbedding_isOrderedAddMonoid`.
## References
* [A. H. Clifford, *Note on Hahn’s theorem on ordered Abelian groups.*][clifford1954]
-/
open ArchimedeanClass
variable (M : Type*) [AddCommGroup M] [LinearOrder M] [IsOrderedAddMonoid M]
section Module
variable [Module ℚ M] [IsOrderedModule ℚ M]
instance : Nonempty (HahnEmbedding.Seed ℚ M ℝ) := by
obtain ⟨strata⟩ : Nonempty (HahnEmbedding.ArchimedeanStrata ℚ M) := inferInstance
choose f hf using fun c ↦ Archimedean.exists_orderAddMonoidHom_real_injective (strata.stratum c)
refine ⟨strata, fun c ↦ (f c).toRatLinearMap, fun c ↦ ?_⟩
apply Monotone.strictMono_of_injective
· simpa using OrderHomClass.monotone (f c)
· simpa using hf c
theorem hahnEmbedding_isOrderedModule_rat :
∃ f : M →ₗ[ℚ] Lex (HahnSeries (FiniteArchimedeanClass M) ℝ), StrictMono f ∧
∀ a, mk a = FiniteArchimedeanClass.withTopOrderIso M (ofLex (f a)).orderTop := by
apply hahnEmbedding_isOrderedModule
end Module
/--
**Hahn embedding theorem**
For a linearly ordered additive group `M`, there exists an injective `OrderAddMonoidHom` from `M` to
`Lex (HahnSeries (FiniteArchimedeanClass M) ℝ)` that sends each `a : M` to an element of the
`a`-Archimedean class of the Hahn series.
-/
theorem hahnEmbedding_isOrderedAddMonoid :
∃ f : M →+o Lex (HahnSeries (FiniteArchimedeanClass M) ℝ), Function.Injective f ∧
∀ a, mk a = FiniteArchimedeanClass.withTopOrderIso M (ofLex (f a)).orderTop := by
/-
The desired embedding is the composition of three functions:
Group type `ArchimedeanClass` / `HahnSeries.orderTop` type
`M` `ArchimedeanClass M`
`f₁` ↓+o ↓o~
`D-Hull M` `ArchimedeanClass (D-Hull M)`
`f₂` ↓+o ↓o~
`Lex (HahnSeries (F-A-Class (D-Hull M)) ℝ)` `WithTop (F-A-Class (D-Hull M))`
`f₃` ↓+o(~) ↓o~
`Lex (HahnSeries (F-A-Class M) ℝ)` `WithTop (F-A-Class M)`
-/
let f₁ := DivisibleHull.coeOrderAddMonoidHom M
have hf₁ : Function.Injective f₁ := DivisibleHull.coe_injective
have hf₁class (a : M) : mk a = (DivisibleHull.archimedeanClassOrderIso M).symm (mk (f₁ a)) := by
simp [f₁]
obtain ⟨f₂', hf₂', hf₂class'⟩ := hahnEmbedding_isOrderedModule_rat (DivisibleHull M)
let f₂ := OrderAddMonoidHom.mk f₂'.toAddMonoidHom hf₂'.monotone
have hf₂ : Function.Injective f₂ := hf₂'.injective
have hf₂class (a : DivisibleHull M) :
mk a = (FiniteArchimedeanClass.withTopOrderIso (DivisibleHull M)) (ofLex (f₂ a)).orderTop :=
hf₂class' a
let f₃ : Lex (HahnSeries (FiniteArchimedeanClass (DivisibleHull M)) ℝ) →+o
Lex (HahnSeries (FiniteArchimedeanClass M) ℝ) :=
HahnSeries.embDomainOrderAddMonoidHom
(FiniteArchimedeanClass.congrOrderIso (DivisibleHull.archimedeanClassOrderIso M).symm)
have hf₃ : Function.Injective f₃ := HahnSeries.embDomainOrderAddMonoidHom_injective _
have hf₃class (a : Lex (HahnSeries (FiniteArchimedeanClass (DivisibleHull M)) ℝ)) :
(ofLex a).orderTop = OrderIso.withTopCongr
((FiniteArchimedeanClass.congrOrderIso (DivisibleHull.archimedeanClassOrderIso M)))
(ofLex (f₃ a)).orderTop := by
rw [← OrderIso.symm_apply_eq]
simp [f₃, ← OrderIso.withTopCongr_symm]
refine ⟨f₃.comp (f₂.comp f₁), hf₃.comp (hf₂.comp hf₁), ?_⟩
intro a
simp_rw [hf₁class, hf₂class, hf₃class, OrderAddMonoidHom.comp_apply]
cases (ofLex (f₃ (f₂ (f₁ a)))).orderTop with
| top => simp
| coe x => simp [-DivisibleHull.archimedeanClassOrderIso_apply] |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Lex.lean | import Mathlib.Algebra.Order.Archimedean.Class
import Mathlib.Order.Hom.Lex
import Mathlib.Order.PiLex
import Mathlib.RingTheory.HahnSeries.Addition
/-!
# Lexicographical order on Hahn series
In this file, we define lexicographical ordered `Lex (HahnSeries Γ R)`, and show this
is a `LinearOrder` when `Γ` and `R` themselves are linearly ordered. Additionally,
it is an ordered group when `R` is.
## Main definitions
* `HahnSeries.finiteArchimedeanClassOrderIsoLex`: `FiniteArchimedeanClass` of `Lex (HahnSeries Γ R)`
can be decomposed by `Γ`.
-/
namespace HahnSeries
variable {Γ R : Type*} [LinearOrder Γ]
section PartialOrder
variable [Zero R] [PartialOrder R]
instance : PartialOrder (Lex (HahnSeries Γ R)) :=
PartialOrder.lift (toLex <| ofLex · |>.coeff) fun x y ↦ by simp
theorem lt_iff (a b : Lex (HahnSeries Γ R)) :
a < b ↔ ∃ (i : Γ), (∀ (j : Γ), j < i → (ofLex a).coeff j = (ofLex b).coeff j)
∧ (ofLex a).coeff i < (ofLex b).coeff i := by rfl
end PartialOrder
section LinearOrder
variable [Zero R] [LinearOrder R]
noncomputable
instance : LinearOrder (Lex (HahnSeries Γ R)) where
le_total a b := by
rcases eq_or_ne a b with hab | hab
· exact Or.inl hab.le
· have hab := Function.ne_iff.mp <| HahnSeries.ext_iff.ne.mp hab
let u := {i : Γ | (ofLex a).coeff i ≠ 0} ∪ {i : Γ | (ofLex b).coeff i ≠ 0}
let v := {i : Γ | (ofLex a).coeff i ≠ (ofLex b).coeff i}
have hvu : v ⊆ u := by
intro i h
rw [Set.mem_union, Set.mem_setOf_eq, Set.mem_setOf_eq]
contrapose! h
rw [Set.notMem_setOf_iff, not_not, h.1, h.2]
have hv : v.IsWF :=
((ofLex a).isPWO_support'.isWF.union (ofLex b).isPWO_support'.isWF).subset hvu
let i := hv.min hab
have hji (j) : j < i → (ofLex a).coeff j = (ofLex b).coeff j :=
not_imp_not.mp <| fun h' ↦ hv.not_lt_min hab h'
have hne : (ofLex a).coeff i ≠ (ofLex b).coeff i := hv.min_mem hab
obtain hi | hi := lt_or_gt_of_ne hne
· exact Or.inl (le_of_lt ⟨i, hji, hi⟩)
· exact Or.inr (le_of_lt ⟨i, fun j hj ↦ (hji j hj).symm, hi⟩)
toDecidableLE := Classical.decRel _
@[simp]
theorem leadingCoeff_pos_iff {x : Lex (HahnSeries Γ R)} : 0 < (ofLex x).leadingCoeff ↔ 0 < x := by
rw [lt_iff]
constructor
· intro hpos
have hne : (ofLex x) ≠ 0 := leadingCoeff_ne_zero.mp hpos.ne.symm
have htop : (ofLex x).orderTop ≠ ⊤ := orderTop_ne_top.2 hne
refine ⟨(ofLex x).orderTop.untop htop, ?_, by simpa [coeff_untop_eq_leadingCoeff] using hpos⟩
intro j hj
simpa using (coeff_eq_zero_of_lt_orderTop ((WithTop.lt_untop_iff htop).mp hj)).symm
· intro ⟨i, hj, hi⟩
have horder : (ofLex x).orderTop = WithTop.some i := by
apply orderTop_eq_of_le
· simpa using hi.ne.symm
· intro g hg
contrapose! hg
simpa using (hj g hg).symm
have htop : (ofLex x).orderTop ≠ ⊤ := WithTop.ne_top_iff_exists.mpr ⟨i, horder.symm⟩
have hne : ofLex x ≠ 0 := orderTop_ne_top.1 htop
have horder' : (ofLex x).orderTop.untop htop = i := (WithTop.untop_eq_iff _).mpr horder
rw [leadingCoeff_of_ne_zero hne, horder']
simpa using hi
theorem leadingCoeff_nonneg_iff {x : Lex (HahnSeries Γ R)} :
0 ≤ (ofLex x).leadingCoeff ↔ 0 ≤ x := by
constructor
· intro h
obtain heq | hlt := h.eq_or_lt
· exact le_of_eq (leadingCoeff_eq_zero.mp heq.symm).symm
· exact (leadingCoeff_pos_iff.mp hlt).le
· intro h
obtain rfl | hlt := h.eq_or_lt
· simp
· exact (leadingCoeff_pos_iff.mpr hlt).le
theorem leadingCoeff_neg_iff {x : Lex (HahnSeries Γ R)} : (ofLex x).leadingCoeff < 0 ↔ x < 0 := by
simpa using (leadingCoeff_nonneg_iff (x := x)).not
theorem leadingCoeff_nonpos_iff {x : Lex (HahnSeries Γ R)} :
(ofLex x).leadingCoeff ≤ 0 ↔ x ≤ 0 := by
simp [← not_lt]
end LinearOrder
section OrderedMonoid
variable [PartialOrder R] [AddCommMonoid R] [AddLeftStrictMono R] [IsOrderedAddMonoid R]
instance : IsOrderedAddMonoid (Lex (HahnSeries Γ R)) where
add_le_add_left a b hab c := by
obtain rfl | hlt := hab.eq_or_lt
· simp
· apply le_of_lt
rw [lt_iff] at hlt ⊢
obtain ⟨i, hj, hi⟩ := hlt
refine ⟨i, ?_, ?_⟩
· intro j hji
simpa using congrArg ((ofLex c).coeff j + ·) (hj j hji)
· simpa using add_lt_add_left hi ((ofLex c).coeff i)
end OrderedMonoid
section OrderedGroup
variable [LinearOrder R] [AddCommGroup R] [IsOrderedAddMonoid R]
@[simp]
theorem support_abs (x : Lex (HahnSeries Γ R)) : (ofLex |x|).support = (ofLex x).support := by
obtain hle | hge := le_total x 0
· rw [abs_eq_neg_self.mpr hle]
simp
· rw [abs_eq_self.mpr hge]
@[simp]
theorem orderTop_abs (x : Lex (HahnSeries Γ R)) : (ofLex |x|).orderTop = (ofLex x).orderTop := by
obtain hle | hge := le_total x 0
· rw [abs_eq_neg_self.mpr hle, ofLex_neg, orderTop_neg]
· rw [abs_eq_self.mpr hge]
theorem order_abs [Zero Γ] (x : Lex (HahnSeries Γ R)) : (ofLex |x|).order = (ofLex x).order := by
obtain rfl | hne := eq_or_ne x 0
· simp
· have hne' : ofLex x ≠ 0 := hne
have habs : ofLex |x| ≠ 0 := by simpa using hne
apply WithTop.coe_injective
rw [order_eq_orderTop_of_ne_zero habs, order_eq_orderTop_of_ne_zero hne']
apply orderTop_abs
theorem leadingCoeff_abs (x : Lex (HahnSeries Γ R)) :
(ofLex |x|).leadingCoeff = |(ofLex x).leadingCoeff| := by
obtain hlt | rfl | hgt := lt_trichotomy x 0
· obtain hlt' := leadingCoeff_neg_iff.mpr hlt
rw [abs_eq_neg_self.mpr hlt.le, abs_eq_neg_self.mpr hlt'.le, ofLex_neg, leadingCoeff_neg]
· simp
· obtain hgt' := leadingCoeff_pos_iff.mpr hgt
rw [abs_eq_self.mpr hgt.le, abs_eq_self.mpr hgt'.le]
theorem abs_lt_abs_of_orderTop_ofLex {x y : Lex (HahnSeries Γ R)}
(h : (ofLex y).orderTop < (ofLex x).orderTop) : |x| < |y| := by
rw [← orderTop_abs x, ← orderTop_abs y] at h
refine (lt_iff _ _).mpr ⟨(ofLex |y|).orderTop.untop h.ne_top, ?_, ?_⟩
· simp +contextual [-orderTop_abs, coeff_eq_zero_of_lt_orderTop, h.trans']
· simpa [-orderTop_abs, coeff_eq_zero_of_lt_orderTop, coeff_untop_eq_leadingCoeff, h]
using h.ne_top
theorem archimedeanClassMk_le_archimedeanClassMk_iff_of_orderTop_ofLex {x y : Lex (HahnSeries Γ R)}
(h : (ofLex x).orderTop = (ofLex y).orderTop) :
ArchimedeanClass.mk x ≤ .mk y ↔
ArchimedeanClass.mk (ofLex x).leadingCoeff ≤ .mk (ofLex y).leadingCoeff := by
simp_rw [ArchimedeanClass.mk_le_mk]
obtain rfl | hy := eq_or_ne y 0
· -- special case: both `x` and `y` are zero
simp_all
-- general case: `x` and `y` are not zero
have hx : x ≠ 0 := by simpa using orderTop_ne_top.1 <| h ▸ orderTop_ne_top.2 (by simpa using hy)
have h' : (ofLex |x|).orderTop = (ofLex |y|).orderTop := by simpa using h
constructor
· -- `mk x ≤ mk y → mk x.leadingCoeff ≤ mk y.leadingCoeff`
intro ⟨n, hn⟩
refine ⟨n + 1, ?_⟩
have hn' : |y| < (n + 1) • |x| :=
lt_of_le_of_lt hn <| nsmul_lt_nsmul_left (by simpa using hx) (by simp)
obtain ⟨j, hj, hi⟩ := (lt_iff _ _).mp hn'
simp_rw [ofLex_smul, coeff_smul] at hj hi
simp_rw [← leadingCoeff_abs]
rw [leadingCoeff_of_ne_zero (by simpa using hy), leadingCoeff_of_ne_zero (by simpa using hx)]
simp_rw [← h']
obtain hjlt | hjeq | hjgt := lt_trichotomy (WithTop.some j) (ofLex |x|).orderTop
· -- impossible case: `x` and `y` differ before their leading coefficients
have hjlt' : j < (ofLex |y|).orderTop := h'.symm ▸ hjlt
simp [coeff_eq_zero_of_lt_orderTop hjlt, coeff_eq_zero_of_lt_orderTop hjlt'] at hi
· convert hi.le <;> exact (WithTop.untop_eq_iff _).mpr hjeq.symm
· exact (hj _ ((WithTop.untop_lt_iff _).mpr hjgt)).le
· -- `mk x.leadingCoeff ≤ mk y.leadingCoeff → mk x ≤ mk y`
intro ⟨n, hn⟩
refine ⟨n + 1, ((lt_iff _ _).mpr ?_).le⟩
refine ⟨(ofLex x).orderTop.untop (by simpa using hx), ?_, ?_⟩
· -- all coefficients before the leading coefficient are zero
intro j hj
trans 0
· apply coeff_eq_zero_of_lt_orderTop
simpa [← h] using hj
· suffices (ofLex |x|).coeff j = 0 by simp [this]
apply coeff_eq_zero_of_lt_orderTop
simpa using hj
-- the leading coefficient determines the relation
rw [ofLex_smul, coeff_smul]
suffices |(ofLex y).leadingCoeff| < (n + 1) • |(ofLex x).leadingCoeff| by
simp_rw [← leadingCoeff_abs] at this
rw [leadingCoeff_of_ne_zero (by simpa using hy), leadingCoeff_of_ne_zero (by simpa using hx)]
at this
convert this using 3 <;> simp [h]
refine lt_of_le_of_lt hn <| nsmul_lt_nsmul_left ?_ (by simp)
rwa [abs_pos, leadingCoeff_ne_zero]
theorem archimedeanClassMk_le_archimedeanClassMk_iff {x y : Lex (HahnSeries Γ R)} :
ArchimedeanClass.mk x ≤ .mk y ↔
(ofLex x).orderTop < (ofLex y).orderTop ∨
(ofLex x).orderTop = (ofLex y).orderTop ∧
ArchimedeanClass.mk (ofLex x).leadingCoeff ≤ .mk (ofLex y).leadingCoeff := by
obtain hlt | heq | hgt := lt_trichotomy (ofLex x).orderTop (ofLex y).orderTop
· -- when `x`'s order is less than `y`'s, this reduces to abs_lt_abs_of_orderTop_ofLex
simpa [ArchimedeanClass.mk_le_mk, hlt] using
⟨1, by simpa using (abs_lt_abs_of_orderTop_ofLex hlt).le⟩
· -- when `x` and `y` have the same order, this reduces to
-- `archimedeanClass_le_iff_of_orderTop_eq`
simpa [heq] using archimedeanClassMk_le_archimedeanClassMk_iff_of_orderTop_ofLex heq
-- when `x`'s order is greater than `y`'s, neither side is true
simp_rw [ArchimedeanClass.mk_le_mk]
refine ⟨?_, by simp [hgt.not_gt, hgt.ne']⟩
intro ⟨n, hn⟩
contrapose! hn
rw [← abs_nsmul]
have hgt' : (ofLex y).orderTop < (ofLex (n • x)).orderTop := by
apply lt_of_lt_of_le hgt
simpa using orderTop_smul_not_lt n (ofLex x)
exact abs_lt_abs_of_orderTop_ofLex hgt'
theorem archimedeanClassMk_eq_archimedeanClassMk_iff {x y : Lex (HahnSeries Γ R)} :
ArchimedeanClass.mk x = ArchimedeanClass.mk y ↔
(ofLex x).orderTop = (ofLex y).orderTop ∧
ArchimedeanClass.mk (ofLex x).leadingCoeff = ArchimedeanClass.mk (ofLex y).leadingCoeff := by
rw [le_antisymm_iff, archimedeanClassMk_le_archimedeanClassMk_iff,
archimedeanClassMk_le_archimedeanClassMk_iff]
constructor
· simpa +contextual [or_imp, ne_of_gt, le_of_lt] using fun _ ↦ le_antisymm
· intro ⟨horder, hcoeff⟩
exact ⟨.inr ⟨horder, hcoeff.le⟩, .inr ⟨horder.symm, hcoeff.ge⟩⟩
variable (Γ R) in
/-- Finite archimedean classes of `Lex (HahnSeries Γ R)` decompose into lexicographical pairs
of `order` and the finite archimedean class of `leadingCoeff`. -/
noncomputable def finiteArchimedeanClassOrderHomLex :
FiniteArchimedeanClass (Lex (HahnSeries Γ R)) →o Γ ×ₗ FiniteArchimedeanClass R :=
FiniteArchimedeanClass.liftOrderHom
(fun ⟨x, hx⟩ ↦ toLex
⟨(ofLex x).orderTop.untop (by simp [orderTop_of_ne_zero (show ofLex x ≠ 0 by exact hx)]),
FiniteArchimedeanClass.mk (ofLex x).leadingCoeff (leadingCoeff_ne_zero.mpr hx)⟩)
fun ⟨a, ha⟩ ⟨b, hb⟩ h ↦ by
rw [Prod.Lex.le_iff]
simp only [ofLex_toLex]
rw [FiniteArchimedeanClass.mk_le_mk] at ⊢ h
rw [WithTop.untop_eq_iff]
simpa using archimedeanClassMk_le_archimedeanClassMk_iff.mp h
variable (Γ R) in
/-- The inverse of `finiteArchimedeanClassOrderHomLex`. -/
noncomputable def finiteArchimedeanClassOrderHomInvLex :
Γ ×ₗ FiniteArchimedeanClass R →o FiniteArchimedeanClass (Lex (HahnSeries Γ R)) where
toFun x := (ofLex x).2.liftOrderHom
(fun a ↦ FiniteArchimedeanClass.mk (toLex (single (ofLex x).1 a.val)) (by
simpa using a.prop))
fun ⟨a, ha⟩ ⟨b, hb⟩ h ↦ by
rw [FiniteArchimedeanClass.mk_le_mk, archimedeanClassMk_le_archimedeanClassMk_iff]
simpa [ha, hb] using h
monotone' a b := a.rec fun (ao, ac) ↦ b.rec fun (bo, bc) h ↦ by
obtain h | ⟨rfl, hle⟩ := Prod.Lex.le_iff.mp h
· induction ac using FiniteArchimedeanClass.ind with | mk a ha
induction bc using FiniteArchimedeanClass.ind with | mk b hb
simp only [ne_eq, ofLex_toLex, FiniteArchimedeanClass.liftOrderHom_mk]
rw [FiniteArchimedeanClass.mk_le_mk, archimedeanClassMk_le_archimedeanClassMk_iff]
exact .inl (by simpa [ha, hb] using h)
· exact OrderHom.monotone _ hle
variable (Γ R) in
/-- The correspondence between finite archimedean classes of `Lex (HahnSeries Γ R)`
and lexicographical pairs of `HahnSeries.orderTop` and the finite archimedean class of
`HahnSeries.leadingCoeff`. -/
noncomputable def finiteArchimedeanClassOrderIsoLex :
FiniteArchimedeanClass (Lex (HahnSeries Γ R)) ≃o Γ ×ₗ FiniteArchimedeanClass R := by
apply OrderIso.ofHomInv (finiteArchimedeanClassOrderHomLex Γ R)
(finiteArchimedeanClassOrderHomInvLex Γ R)
· ext x
cases x with | h x
obtain ⟨order, coeff⟩ := x
induction coeff using FiniteArchimedeanClass.ind with | mk a ha
simp [finiteArchimedeanClassOrderHomLex, finiteArchimedeanClassOrderHomInvLex, ha]
· ext x
induction x using FiniteArchimedeanClass.ind with | mk a ha
simp [finiteArchimedeanClassOrderHomLex, finiteArchimedeanClassOrderHomInvLex,
archimedeanClassMk_eq_archimedeanClassMk_iff, ha]
@[simp]
theorem finiteArchimedeanClassOrderIsoLex_apply_fst {x : Lex (HahnSeries Γ R)} (h : x ≠ 0) :
(ofLex (finiteArchimedeanClassOrderIsoLex Γ R (FiniteArchimedeanClass.mk x h))).1 =
(ofLex x).orderTop := by
simp [finiteArchimedeanClassOrderIsoLex, finiteArchimedeanClassOrderHomLex]
@[simp]
theorem finiteArchimedeanClassOrderIsoLex_apply_snd {x : Lex (HahnSeries Γ R)} (h : x ≠ 0) :
(ofLex (finiteArchimedeanClassOrderIsoLex Γ R (FiniteArchimedeanClass.mk x h))).2.val =
ArchimedeanClass.mk (ofLex x).leadingCoeff := by
simp [finiteArchimedeanClassOrderIsoLex, finiteArchimedeanClassOrderHomLex]
section Archimedean
variable [Archimedean R] [Nontrivial R]
variable (Γ R) in
/-- For `Archimedean` coefficients, there is a correspondence between finite
archimedean classes and `HahnSeries.orderTop` without the top element. -/
noncomputable def finiteArchimedeanClassOrderIso :
FiniteArchimedeanClass (Lex (HahnSeries Γ R)) ≃o Γ :=
have : Unique (FiniteArchimedeanClass R) := (nonempty_unique _).some
(finiteArchimedeanClassOrderIsoLex Γ R).trans (Prod.Lex.prodUnique _ _)
@[simp]
theorem finiteArchimedeanClassOrderIso_apply {x : Lex (HahnSeries Γ R)} (h : x ≠ 0) :
finiteArchimedeanClassOrderIso Γ R (FiniteArchimedeanClass.mk x h) = (ofLex x).orderTop := by
simp [finiteArchimedeanClassOrderIso]
variable (Γ R) in
/-- For `Archimedean` coefficients, there is a correspondence between
archimedean classes (with top) and `HahnSeries.orderTop`. -/
noncomputable def archimedeanClassOrderIsoWithTop :
ArchimedeanClass (Lex (HahnSeries Γ R)) ≃o WithTop Γ :=
(FiniteArchimedeanClass.withTopOrderIso _).symm.trans
(finiteArchimedeanClassOrderIso _ _).withTopCongr
@[simp]
theorem archimedeanClassOrderIsoWithTop_apply (x : Lex (HahnSeries Γ R)) :
archimedeanClassOrderIsoWithTop Γ R (ArchimedeanClass.mk x) = (ofLex x).orderTop := by
unfold archimedeanClassOrderIsoWithTop
obtain rfl | h := eq_or_ne x 0 <;>
simp [FiniteArchimedeanClass.withTopOrderIso_symm_apply, *]
end Archimedean
end OrderedGroup
section EmbDomain
variable [PartialOrder R] {Γ' : Type*} [LinearOrder Γ'] (f : Γ ↪o Γ')
/-- `HahnSeries.embDomain` as an `OrderEmbedding`. -/
@[simps]
noncomputable
def embDomainOrderEmbedding [Zero R] : Lex (HahnSeries Γ R) ↪o Lex (HahnSeries Γ' R) where
toFun a := toLex (embDomain f (ofLex a))
inj' := toLex.injective.comp (embDomain_injective.comp (ofLex.injective))
map_rel_iff' {a b} := by
simp_rw [le_iff_lt_or_eq, lt_iff]
simp only [Function.Embedding.coeFn_mk, ofLex_toLex, EmbeddingLike.apply_eq_iff_eq]
constructor
· rintro (⟨i, hj, hi⟩ | heq)
· have himem : i ∈ Set.range f := by
contrapose! hi
simp [embDomain_notin_range hi]
obtain ⟨k, rfl⟩ := himem
refine Or.inl ⟨k, fun j hjk ↦ ?_, by simpa using hi⟩
simpa using hj (f j) (f.lt_iff_lt.mpr hjk)
· exact Or.inr <| embDomain_injective.comp (ofLex.injective) heq
· rintro (⟨i, hj, hi⟩ | rfl)
· refine Or.inl ⟨f i, fun k hki ↦ ?_, by simpa using hi⟩
by_cases hkmem : k ∈ Set.range f
· obtain ⟨j', rfl⟩ := hkmem
simpa using hj _ <| f.lt_iff_lt.mp hki
· simp_rw [embDomain_notin_range hkmem]
· simp
/-- `HahnSeries.embDomain` as an `OrderAddMonoidHom`. -/
@[simps]
noncomputable
def embDomainOrderAddMonoidHom [AddMonoid R] : Lex (HahnSeries Γ R) →+o Lex (HahnSeries Γ' R) where
__ := (embDomainOrderEmbedding f).toOrderHom
map_zero' := by simp
map_add' := by simp [embDomainOrderEmbedding, embDomain_add]
theorem embDomainOrderAddMonoidHom_injective [AddMonoid R] :
Function.Injective (embDomainOrderAddMonoidHom f (R := R)) :=
(embDomainOrderEmbedding f).injective
end EmbDomain
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/PowerSeries.lean | import Mathlib.RingTheory.HahnSeries.Multiplication
import Mathlib.RingTheory.PowerSeries.Basic
import Mathlib.RingTheory.MvPowerSeries.NoZeroDivisors
import Mathlib.Data.Finsupp.PWO
/-!
# Comparison between Hahn series and power series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and
`Γ`, we can add further structure on `HahnSeries Γ R`. When `R` is a semiring and `Γ = ℕ`, then
we get the more familiar semiring of formal power series with coefficients in `R`.
## Main Definitions
* `toPowerSeries` the isomorphism from `HahnSeries ℕ R` to `PowerSeries R`.
* `ofPowerSeries` the inverse, casting a `PowerSeries R` to a `HahnSeries ℕ R`.
## Instances
* For `Finite σ`, the instance `NoZeroDivisors (HahnSeries (σ →₀ ℕ) R)`,
deduced from the case of `MvPowerSeries`
The case of `HahnSeries ℕ R` is taken care of by `instNoZeroDivisors`.
## TODO
* Build an API for the variable `X` (defined to be `single 1 1 : HahnSeries Γ R`) in analogy to
`X : R[X]` and `X : PowerSeries R`
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function Pointwise Polynomial
noncomputable section
variable {Γ R : Type*}
namespace HahnSeries
section Semiring
variable [Semiring R]
/-- The ring `HahnSeries ℕ R` is isomorphic to `PowerSeries R`. -/
@[simps]
def toPowerSeries : HahnSeries ℕ R ≃+* PowerSeries R where
toFun f := PowerSeries.mk f.coeff
invFun f := ⟨fun n => PowerSeries.coeff n f, .of_linearOrder _⟩
left_inv f := by
ext
simp
right_inv f := by
ext
simp
map_add' f g := by
ext
simp
map_mul' f g := by
ext n
simp only [PowerSeries.coeff_mul, PowerSeries.coeff_mk, coeff_mul]
classical
refine (sum_filter_ne_zero _).symm.trans <| (sum_congr ?_ fun _ _ ↦ rfl).trans <|
sum_filter_ne_zero _
ext m
simp only [mem_antidiagonal, mem_addAntidiagonal, and_congr_left_iff, mem_filter,
mem_support]
rintro h
rw [and_iff_right (left_ne_zero_of_mul h), and_iff_right (right_ne_zero_of_mul h)]
theorem coeff_toPowerSeries {f : HahnSeries ℕ R} {n : ℕ} :
PowerSeries.coeff n (toPowerSeries f) = f.coeff n :=
PowerSeries.coeff_mk _ _
theorem coeff_toPowerSeries_symm {f : PowerSeries R} {n : ℕ} :
(HahnSeries.toPowerSeries.symm f).coeff n = PowerSeries.coeff n f :=
rfl
variable (Γ R) [Semiring Γ] [PartialOrder Γ] [IsStrictOrderedRing Γ]
/-- Casts a power series as a Hahn series with coefficients from a `StrictOrderedSemiring`. -/
def ofPowerSeries : PowerSeries R →+* HahnSeries Γ R :=
(HahnSeries.embDomainRingHom (Nat.castAddMonoidHom Γ) Nat.strictMono_cast.injective fun _ _ =>
Nat.cast_le).comp
(RingEquiv.toRingHom toPowerSeries.symm)
variable {Γ} {R}
theorem ofPowerSeries_injective : Function.Injective (ofPowerSeries Γ R) :=
embDomain_injective.comp toPowerSeries.symm.injective
-- Not `@[simp]` since the RHS is more complicated and it makes linter failures elsewhere
theorem ofPowerSeries_apply (x : PowerSeries R) :
ofPowerSeries Γ R x =
HahnSeries.embDomain
⟨⟨((↑) : ℕ → Γ), Nat.strictMono_cast.injective⟩, by
simp only [Function.Embedding.coeFn_mk]
exact Nat.cast_le⟩
(toPowerSeries.symm x) :=
rfl
theorem ofPowerSeries_apply_coeff (x : PowerSeries R) (n : ℕ) :
(ofPowerSeries Γ R x).coeff n = PowerSeries.coeff n x := by simp [ofPowerSeries_apply]
@[simp]
theorem ofPowerSeries_C (r : R) : ofPowerSeries Γ R (PowerSeries.C r) = HahnSeries.C r := by
ext n
simp only [ofPowerSeries_apply, C, RingHom.coe_mk, MonoidHom.coe_mk, OneHom.coe_mk,
coeff_single]
split_ifs with hn
· subst hn
convert embDomain_coeff (a := 0) <;> simp
· rw [embDomain_notin_image_support]
simp only [not_exists, Set.mem_image, toPowerSeries_symm_apply_coeff, mem_support,
PowerSeries.coeff_C]
intro
simp +contextual [Ne.symm hn]
@[simp]
theorem ofPowerSeries_X : ofPowerSeries Γ R PowerSeries.X = single 1 1 := by
ext n
simp only [coeff_single, ofPowerSeries_apply]
split_ifs with hn
· rw [hn]
convert embDomain_coeff (a := 1) <;> simp
· rw [embDomain_notin_image_support]
simp only [not_exists, Set.mem_image, toPowerSeries_symm_apply_coeff, mem_support,
PowerSeries.coeff_X]
intro
simp +contextual [Ne.symm hn]
theorem ofPowerSeries_X_pow {R} [Semiring R] (n : ℕ) :
ofPowerSeries Γ R (PowerSeries.X ^ n) = single (n : Γ) 1 := by
simp
-- Lemmas about converting hahn_series over fintype to and from mv_power_series
/-- The ring `HahnSeries (σ →₀ ℕ) R` is isomorphic to `MvPowerSeries σ R` for a `Finite` `σ`.
We take the index set of the hahn series to be `Finsupp` rather than `pi`,
even though we assume `Finite σ` as this is more natural for alignment with `MvPowerSeries`.
After importing `Mathlib/Algebra/Order/Pi.lean` the ring `HahnSeries (σ → ℕ) R` could be constructed
instead.
-/
@[simps]
def toMvPowerSeries {σ : Type*} [Finite σ] : HahnSeries (σ →₀ ℕ) R ≃+* MvPowerSeries σ R where
toFun f := f.coeff
invFun f := ⟨(f : (σ →₀ ℕ) → R), Finsupp.isPWO _⟩
left_inv f := by
ext
simp
right_inv f := by
ext
simp
map_add' f g := by
ext
simp
map_mul' f g := by
ext n
classical
change (f * g).coeff n = _
simp_rw [coeff_mul]
refine (sum_filter_ne_zero _).symm.trans <| (sum_congr ?_ fun _ _ ↦ rfl).trans <|
sum_filter_ne_zero _
ext m
simp only [and_congr_left_iff, mem_addAntidiagonal, mem_filter, mem_support,
Finset.mem_antidiagonal]
rintro h
rw [and_iff_right (left_ne_zero_of_mul h), and_iff_right (right_ne_zero_of_mul h)]
variable {σ : Type*} [Finite σ]
-- TODO : generalize to all (?) rings of Hahn Series
/-- If R has no zero divisors and `σ` is finite,
then `HahnSeries (σ →₀ ℕ) R` has no zero divisors -/
instance [NoZeroDivisors R] : NoZeroDivisors (HahnSeries (σ →₀ ℕ) R) :=
toMvPowerSeries.toMulEquiv.noZeroDivisors (A := HahnSeries (σ →₀ ℕ) R) (MvPowerSeries σ R)
theorem coeff_toMvPowerSeries {f : HahnSeries (σ →₀ ℕ) R} {n : σ →₀ ℕ} :
MvPowerSeries.coeff n (toMvPowerSeries f) = f.coeff n :=
rfl
theorem coeff_toMvPowerSeries_symm {f : MvPowerSeries σ R} {n : σ →₀ ℕ} :
(HahnSeries.toMvPowerSeries.symm f).coeff n = MvPowerSeries.coeff n f :=
rfl
end Semiring
section Algebra
variable (R) [CommSemiring R] {A : Type*} [Semiring A] [Algebra R A]
/-- The `R`-algebra `HahnSeries ℕ A` is isomorphic to `PowerSeries A`. -/
@[simps!]
def toPowerSeriesAlg : HahnSeries ℕ A ≃ₐ[R] PowerSeries A :=
{ toPowerSeries with
commutes' := fun r => by
ext n
cases n <;> simp [algebraMap_apply, PowerSeries.algebraMap_apply] }
variable (Γ) [Semiring Γ] [PartialOrder Γ] [IsStrictOrderedRing Γ]
/-- Casting a power series as a Hahn series with coefficients from a `StrictOrderedSemiring`
is an algebra homomorphism. -/
@[simps!]
def ofPowerSeriesAlg : PowerSeries A →ₐ[R] HahnSeries Γ A :=
(HahnSeries.embDomainAlgHom (Nat.castAddMonoidHom Γ) Nat.strictMono_cast.injective fun _ _ =>
Nat.cast_le).comp
(AlgEquiv.toAlgHom (toPowerSeriesAlg R).symm)
instance powerSeriesAlgebra {S : Type*} [CommSemiring S] [Algebra S (PowerSeries R)] :
Algebra S (HahnSeries Γ R) :=
RingHom.toAlgebra <| (ofPowerSeries Γ R).comp (algebraMap S (PowerSeries R))
variable {R}
variable {S : Type*} [CommSemiring S] [Algebra S (PowerSeries R)]
theorem algebraMap_apply' (x : S) :
algebraMap S (HahnSeries Γ R) x = ofPowerSeries Γ R (algebraMap S (PowerSeries R) x) :=
rfl
@[simp]
theorem _root_.Polynomial.algebraMap_hahnSeries_apply (f : R[X]) :
algebraMap R[X] (HahnSeries Γ R) f = ofPowerSeries Γ R f :=
rfl
theorem _root_.Polynomial.algebraMap_hahnSeries_injective :
Function.Injective (algebraMap R[X] (HahnSeries Γ R)) :=
ofPowerSeries_injective.comp (Polynomial.coe_injective R)
end Algebra
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Addition.lean | import Mathlib.Algebra.BigOperators.Group.Finset.Basic
import Mathlib.Algebra.Group.Pi.Lemmas
import Mathlib.Algebra.Group.Support
import Mathlib.Algebra.Module.Basic
import Mathlib.Algebra.Module.LinearMap.Defs
import Mathlib.Data.Finsupp.SMul
import Mathlib.RingTheory.HahnSeries.Basic
import Mathlib.Tactic.FastInstance
/-!
# Additive properties of Hahn series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and
`Γ`, we can add further structure on `HahnSeries Γ R`. When `R` has an addition operation,
`HahnSeries Γ R` also has addition by adding coefficients.
## Main Definitions
* If `R` is a (commutative) additive monoid or group, then so is `HahnSeries Γ R`.
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function
noncomputable section
variable {Γ Γ' R S U V α : Type*}
namespace HahnSeries
section SMulZeroClass
variable [PartialOrder Γ] {V : Type*} [Zero V] [SMulZeroClass R V]
instance : SMul R (HahnSeries Γ V) :=
⟨fun r x =>
{ coeff := r • x.coeff
isPWO_support' := x.isPWO_support.mono (Function.support_const_smul_subset r x.coeff) }⟩
@[simp]
theorem coeff_smul' (r : R) (x : HahnSeries Γ V) : (r • x).coeff = r • x.coeff :=
rfl
@[simp]
theorem coeff_smul {r : R} {x : HahnSeries Γ V} {a : Γ} : (r • x).coeff a = r • x.coeff a :=
rfl
instance : SMulZeroClass R (HahnSeries Γ V) :=
{ inferInstanceAs (SMul R (HahnSeries Γ V)) with
smul_zero := by
intro
ext
simp only [coeff_smul, coeff_zero, smul_zero]}
theorem orderTop_smul_not_lt (r : R) (x : HahnSeries Γ V) : ¬ (r • x).orderTop < x.orderTop := by
by_cases hrx : r • x = 0
· rw [hrx, orderTop_zero]
exact not_top_lt
· simp only [orderTop_of_ne_zero hrx, orderTop_of_ne_zero <| right_ne_zero_of_smul hrx,
WithTop.coe_lt_coe]
exact Set.IsWF.min_of_subset_not_lt_min
(Function.support_smul_subset_right (fun _ => r) x.coeff)
theorem order_smul_not_lt [Zero Γ] (r : R) (x : HahnSeries Γ V) (h : r • x ≠ 0) :
¬ (r • x).order < x.order := by
have hx : x ≠ 0 := right_ne_zero_of_smul h
simp_all only [order, dite_false]
exact Set.IsWF.min_of_subset_not_lt_min (Function.support_smul_subset_right (fun _ => r) x.coeff)
theorem le_order_smul {Γ} [Zero Γ] [LinearOrder Γ] (r : R) (x : HahnSeries Γ V) (h : r • x ≠ 0) :
x.order ≤ (r • x).order :=
le_of_not_gt (order_smul_not_lt r x h)
theorem truncLT_smul [DecidableLT Γ] (c : Γ) (r : R) (x : HahnSeries Γ V) :
truncLT c (r • x) = r • truncLT c x := by ext; simp
end SMulZeroClass
section Addition
variable [PartialOrder Γ]
section AddMonoid
variable [AddMonoid R]
instance : Add (HahnSeries Γ R) where
add x y :=
{ coeff := x.coeff + y.coeff
isPWO_support' := (x.isPWO_support.union y.isPWO_support).mono (Function.support_add _ _) }
@[simp]
theorem coeff_add' (x y : HahnSeries Γ R) : (x + y).coeff = x.coeff + y.coeff :=
rfl
theorem coeff_add {x y : HahnSeries Γ R} {a : Γ} : (x + y).coeff a = x.coeff a + y.coeff a :=
rfl
@[simp] theorem single_add (a : Γ) (r s : R) : single a (r + s) = single a r + single a s := by
classical
ext : 1; exact Pi.single_add (f := fun _ => R) a r s
instance : AddMonoid (HahnSeries Γ R) := fast_instance%
coeff_injective.addMonoid _
coeff_zero' coeff_add' (fun _ _ => coeff_smul' _ _)
theorem coeff_nsmul {x : HahnSeries Γ R} {n : ℕ} : (n • x).coeff = n • x.coeff := coeff_smul' _ _
@[simp]
protected lemma map_add [AddMonoid S] (f : R →+ S) {x y : HahnSeries Γ R} :
((x + y).map f : HahnSeries Γ S) = x.map f + y.map f := by
ext; simp
/--
`addOppositeEquiv` is an additive monoid isomorphism between
Hahn series over `Γ` with coefficients in the opposite additive monoid `Rᵃᵒᵖ`
and the additive opposite of Hahn series over `Γ` with coefficients `R`.
-/
@[simps -isSimp]
def addOppositeEquiv : HahnSeries Γ Rᵃᵒᵖ ≃+ (HahnSeries Γ R)ᵃᵒᵖ where
toFun x := .op ⟨fun a ↦ (x.coeff a).unop, by convert x.isPWO_support; ext; simp⟩
invFun x := ⟨fun a ↦ .op (x.unop.coeff a), by convert x.unop.isPWO_support; ext; simp⟩
left_inv x := by simp
right_inv x := by
apply AddOpposite.unop_injective
simp
map_add' x y := by
apply AddOpposite.unop_injective
ext
simp
@[simp]
lemma addOppositeEquiv_support (x : HahnSeries Γ Rᵃᵒᵖ) :
(addOppositeEquiv x).unop.support = x.support := by
ext
simp [addOppositeEquiv_apply]
@[simp]
lemma addOppositeEquiv_symm_support (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).support = x.unop.support := by
rw [← addOppositeEquiv_support, AddEquiv.apply_symm_apply]
@[simp]
lemma addOppositeEquiv_orderTop (x : HahnSeries Γ Rᵃᵒᵖ) :
(addOppositeEquiv x).unop.orderTop = x.orderTop := by
classical
simp only [orderTop,
addOppositeEquiv_support]
simp only [addOppositeEquiv_apply, AddOpposite.unop_op, mk_eq_zero]
simp_rw [HahnSeries.ext_iff, funext_iff]
simp only [Pi.zero_apply, AddOpposite.unop_eq_zero_iff, coeff_zero]
@[simp]
lemma addOppositeEquiv_symm_orderTop (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).orderTop = x.unop.orderTop := by
rw [← addOppositeEquiv_orderTop, AddEquiv.apply_symm_apply]
@[simp]
lemma addOppositeEquiv_leadingCoeff (x : HahnSeries Γ Rᵃᵒᵖ) :
(addOppositeEquiv x).unop.leadingCoeff = x.leadingCoeff.unop := by
classical
obtain rfl | hx := eq_or_ne x 0
· simp
simp only [ne_eq, AddOpposite.unop_eq_zero_iff, EmbeddingLike.map_eq_zero_iff, hx,
not_false_eq_true, leadingCoeff_of_ne_zero, addOppositeEquiv_orderTop]
simp [addOppositeEquiv]
@[simp]
lemma addOppositeEquiv_symm_leadingCoeff (x : (HahnSeries Γ R)ᵃᵒᵖ) :
(addOppositeEquiv.symm x).leadingCoeff = .op x.unop.leadingCoeff := by
apply AddOpposite.unop_injective
rw [← addOppositeEquiv_leadingCoeff, AddEquiv.apply_symm_apply, AddOpposite.unop_op]
theorem support_add_subset {x y : HahnSeries Γ R} : support (x + y) ⊆ support x ∪ support y :=
fun a ha => by
rw [mem_support, coeff_add] at ha
rw [Set.mem_union, mem_support, mem_support]
contrapose! ha
rw [ha.1, ha.2, add_zero]
protected theorem min_le_min_add {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} (hx : x ≠ 0)
(hy : y ≠ 0) (hxy : x + y ≠ 0) :
min (Set.IsWF.min x.isWF_support (support_nonempty_iff.2 hx))
(Set.IsWF.min y.isWF_support (support_nonempty_iff.2 hy)) ≤
Set.IsWF.min (x + y).isWF_support (support_nonempty_iff.2 hxy) := by
rw [← Set.IsWF.min_union]
exact Set.IsWF.min_le_min_of_subset (support_add_subset (x := x) (y := y))
theorem min_orderTop_le_orderTop_add {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} :
min x.orderTop y.orderTop ≤ (x + y).orderTop := by
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
by_cases hxy : x + y = 0; · simp [hxy]
rw [orderTop_of_ne_zero hx, orderTop_of_ne_zero hy, orderTop_of_ne_zero hxy, ← WithTop.coe_min,
WithTop.coe_le_coe]
exact HahnSeries.min_le_min_add hx hy hxy
theorem min_order_le_order_add {Γ} [Zero Γ] [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x + y ≠ 0) : min x.order y.order ≤ (x + y).order := by
by_cases hx : x = 0; · simp [hx]
by_cases hy : y = 0; · simp [hy]
rw [order_of_ne hx, order_of_ne hy, order_of_ne hxy]
exact HahnSeries.min_le_min_add hx hy hxy
theorem orderTop_add_eq_left {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x + y).orderTop = x.orderTop := by
have hx : x ≠ 0 := orderTop_ne_top.1 hxy.ne_top
let g : Γ := Set.IsWF.min x.isWF_support (support_nonempty_iff.2 hx)
have hcxyne : (x + y).coeff g ≠ 0 := by
rw [coeff_add, coeff_eq_zero_of_lt_orderTop (lt_of_eq_of_lt (orderTop_of_ne_zero hx).symm hxy),
add_zero]
exact coeff_orderTop_ne (orderTop_of_ne_zero hx)
have hxyx : (x + y).orderTop ≤ x.orderTop := by
rw [orderTop_of_ne_zero hx]
exact orderTop_le_of_coeff_ne_zero hcxyne
exact le_antisymm hxyx (le_of_eq_of_le (min_eq_left_of_lt hxy).symm min_orderTop_le_orderTop_add)
theorem orderTop_add_eq_right {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : y.orderTop < x.orderTop) : (x + y).orderTop = y.orderTop := by
simpa [← map_add, ← AddOpposite.op_add, hxy] using orderTop_add_eq_left
(x := addOppositeEquiv.symm (.op y))
(y := addOppositeEquiv.symm (.op x))
theorem leadingCoeff_add_eq_left {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x + y).leadingCoeff = x.leadingCoeff := by
have hx : x ≠ 0 := orderTop_ne_top.1 hxy.ne_top
have ho : (x + y).orderTop = x.orderTop := orderTop_add_eq_left hxy
by_cases h : x + y = 0
· rw [h, orderTop_zero] at ho
rw [h, orderTop_eq_top.mp ho.symm]
· simp_rw [leadingCoeff_of_ne_zero h, leadingCoeff_of_ne_zero hx, ho, coeff_add]
rw [coeff_eq_zero_of_lt_orderTop (x := y) (by simpa using hxy), add_zero]
theorem leadingCoeff_add_eq_right {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : y.orderTop < x.orderTop) : (x + y).leadingCoeff = y.leadingCoeff := by
simpa [← map_add, ← AddOpposite.op_add, hxy] using leadingCoeff_add_eq_left
(x := addOppositeEquiv.symm (.op y))
(y := addOppositeEquiv.symm (.op x))
theorem ne_zero_of_eq_add_single [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) : x ≠ 0 := by
by_contra h
simp only [h, order_zero, leadingCoeff_zero, map_zero, add_zero] at hxy
exact hy hxy.symm
theorem coeff_order_of_eq_add_single {R} [AddCancelCommMonoid R] [Zero Γ] {x y : HahnSeries Γ R}
(hxy : x = y + single x.order x.leadingCoeff) : y.coeff x.order = 0 := by
simpa [← leadingCoeff_eq] using congr(($hxy).coeff x.order)
theorem order_lt_order_of_eq_add_single {R} {Γ} [LinearOrder Γ] [Zero Γ] [AddCancelCommMonoid R]
{x y : HahnSeries Γ R} (hxy : x = y + single x.order x.leadingCoeff) (hy : y ≠ 0) :
x.order < y.order := by
have : x.order ≠ y.order := by
intro h
have hyne : single y.order y.leadingCoeff ≠ 0 := single_ne_zero <| leadingCoeff_ne_zero.mpr hy
rw [leadingCoeff_eq, ← h, coeff_order_of_eq_add_single hxy, single_eq_zero] at hyne
exact hyne rfl
refine lt_of_le_of_ne ?_ this
simp only [order, ne_zero_of_eq_add_single hxy hy, ↓reduceDIte, hy]
have : y.support ⊆ x.support := by
intro g hg
by_cases hgx : g = x.order
· refine (mem_support x g).mpr ?_
have : x.coeff x.order ≠ 0 := coeff_order_ne_zero <| ne_zero_of_eq_add_single hxy hy
rwa [← hgx] at this
· have : x.coeff g = (y + (single x.order) x.leadingCoeff).coeff g := by rw [← hxy]
rw [coeff_add, coeff_single_of_ne hgx, add_zero] at this
simpa [this] using hg
exact Set.IsWF.min_le_min_of_subset this
/-- `single` as an additive monoid/group homomorphism -/
@[simps!]
def single.addMonoidHom (a : Γ) : R →+ HahnSeries Γ R :=
{ single a with
map_add' := single_add _ }
/-- `coeff g` as an additive monoid/group homomorphism -/
@[simps]
def coeff.addMonoidHom (g : Γ) : HahnSeries Γ R →+ R where
toFun f := f.coeff g
map_zero' := coeff_zero
map_add' _ _ := coeff_add
section Domain
variable [PartialOrder Γ']
theorem embDomain_add (f : Γ ↪o Γ') (x y : HahnSeries Γ R) :
embDomain f (x + y) = embDomain f x + embDomain f y := by
ext g
by_cases hg : g ∈ Set.range f
· obtain ⟨a, rfl⟩ := hg
simp
· simp [embDomain_notin_range hg]
end Domain
theorem truncLT_add [DecidableLT Γ] (c : Γ) (x y : HahnSeries Γ R) :
truncLT c (x + y) = truncLT c x + truncLT c y := by
ext i
by_cases h : i < c <;> simp [h]
end AddMonoid
section AddCommMonoid
variable [AddCommMonoid R]
instance : AddCommMonoid (HahnSeries Γ R) :=
{ inferInstanceAs (AddMonoid (HahnSeries Γ R)) with
add_comm := fun x y => by
ext
apply add_comm }
@[simp]
theorem coeff_sum {s : Finset α} {x : α → HahnSeries Γ R} (g : Γ) :
(∑ i ∈ s, x i).coeff g = ∑ i ∈ s, (x i).coeff g :=
cons_induction rfl (fun i s his hsum => by rw [sum_cons, sum_cons, coeff_add, hsum]) s
end AddCommMonoid
section AddGroup
variable [AddGroup R]
instance : Neg (HahnSeries Γ R) where
neg x :=
{ coeff := fun a => -x.coeff a
isPWO_support' := by
rw [Function.support_fun_neg]
exact x.isPWO_support }
@[simp]
theorem coeff_neg' (x : HahnSeries Γ R) : (-x).coeff = -x.coeff :=
rfl
theorem coeff_neg {x : HahnSeries Γ R} {a : Γ} : (-x).coeff a = -x.coeff a :=
rfl
instance : Sub (HahnSeries Γ R) where
sub x y :=
{ coeff := x.coeff - y.coeff
isPWO_support' := (x.isPWO_support.union y.isPWO_support).mono (Function.support_sub _ _) }
@[simp]
theorem coeff_sub' (x y : HahnSeries Γ R) : (x - y).coeff = x.coeff - y.coeff :=
rfl
theorem coeff_sub {x y : HahnSeries Γ R} {a : Γ} : (x - y).coeff a = x.coeff a - y.coeff a :=
rfl
instance : AddGroup (HahnSeries Γ R) := fast_instance%
coeff_injective.addGroup _
coeff_zero' coeff_add' (coeff_neg') (coeff_sub')
(fun _ _ => coeff_smul' _ _) (fun _ _ => coeff_smul' _ _)
@[simp]
theorem single_sub (a : Γ) (r s : R) : single a (r - s) = single a r - single a s :=
map_sub (single.addMonoidHom a) _ _
@[simp]
theorem single_neg (a : Γ) (r : R) : single a (-r) = -single a r :=
map_neg (single.addMonoidHom a) _
@[simp]
theorem support_neg {x : HahnSeries Γ R} : (-x).support = x.support := by
ext
simp
@[simp]
protected lemma map_neg [AddGroup S] (f : R →+ S) {x : HahnSeries Γ R} :
((-x).map f : HahnSeries Γ S) = -(x.map f) := by
ext; simp
@[simp]
theorem orderTop_neg {x : HahnSeries Γ R} : (-x).orderTop = x.orderTop := by
classical simp only [orderTop, support_neg, neg_eq_zero]
@[simp]
theorem order_neg [Zero Γ] {f : HahnSeries Γ R} : (-f).order = f.order := by
classical
by_cases hf : f = 0
· simp only [hf, neg_zero]
simp only [order, support_neg, neg_eq_zero]
theorem leadingCoeff_neg {x : HahnSeries Γ R} : (-x).leadingCoeff = -x.leadingCoeff := by
obtain rfl | hx := eq_or_ne x 0 <;> simp [leadingCoeff_of_ne_zero, *]
@[simp]
protected lemma map_sub [AddGroup S] (f : R →+ S) {x y : HahnSeries Γ R} :
((x - y).map f : HahnSeries Γ S) = x.map f - y.map f := by
ext; simp
theorem min_orderTop_le_orderTop_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R} :
min x.orderTop y.orderTop ≤ (x - y).orderTop := by
rw [sub_eq_add_neg, ← orderTop_neg (x := y)]
exact min_orderTop_le_orderTop_add
theorem orderTop_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x - y).orderTop = x.orderTop := by
rw [sub_eq_add_neg]
rw [← orderTop_neg (x := y)] at hxy
exact orderTop_add_eq_left hxy
theorem leadingCoeff_sub {Γ} [LinearOrder Γ] {x y : HahnSeries Γ R}
(hxy : x.orderTop < y.orderTop) : (x - y).leadingCoeff = x.leadingCoeff := by
rw [sub_eq_add_neg]
rw [← orderTop_neg (x := y)] at hxy
exact leadingCoeff_add_eq_left hxy
end AddGroup
instance [AddCommGroup R] : AddCommGroup (HahnSeries Γ R) :=
{ inferInstanceAs (AddCommMonoid (HahnSeries Γ R)),
inferInstanceAs (AddGroup (HahnSeries Γ R)) with }
end Addition
section DistribMulAction
variable [PartialOrder Γ] {V : Type*} [Monoid R] [AddMonoid V] [DistribMulAction R V]
instance : DistribMulAction R (HahnSeries Γ V) where
one_smul _ := by
ext
simp
smul_zero _ := by
ext
simp
smul_add _ _ _ := by
ext
simp [smul_add]
mul_smul _ _ _ := by
ext
simp [mul_smul]
variable {S : Type*} [Monoid S] [DistribMulAction S V]
instance [SMul R S] [IsScalarTower R S V] : IsScalarTower R S (HahnSeries Γ V) :=
⟨fun r s a => by
ext
simp⟩
instance [SMulCommClass R S V] : SMulCommClass R S (HahnSeries Γ V) :=
⟨fun r s a => by
ext
simp [smul_comm]⟩
end DistribMulAction
section Module
variable [PartialOrder Γ] [Semiring R] [AddCommMonoid V] [Module R V]
instance : Module R (HahnSeries Γ V) :=
{ inferInstanceAs (DistribMulAction R (HahnSeries Γ V)) with
zero_smul := fun _ => by
ext
simp
add_smul := fun _ _ _ => by
ext
simp [add_smul] }
/-- `single` as a linear map -/
@[simps]
def single.linearMap (a : Γ) : V →ₗ[R] HahnSeries Γ V :=
{ single.addMonoidHom a with
map_smul' := fun r s => by
ext b
by_cases h : b = a <;> simp [h] }
/-- `coeff g` as a linear map -/
@[simps]
def coeff.linearMap (g : Γ) : HahnSeries Γ V →ₗ[R] V :=
{ coeff.addMonoidHom g with map_smul' := fun _ _ => rfl }
@[simp]
protected lemma map_smul [AddCommMonoid U] [Module R U] (f : U →ₗ[R] V) {r : R}
{x : HahnSeries Γ U} : (r • x).map f = r • ((x.map f) : HahnSeries Γ V) := by
ext; simp
section Finsupp
variable (R) in
/-- `ofFinsupp` as a linear map. -/
def ofFinsuppLinearMap : (Γ →₀ V) →ₗ[R] HahnSeries Γ V where
toFun := ofFinsupp
map_add' _ _ := by
ext
simp
map_smul' _ _ := by
ext
simp
variable (R) in
@[simp]
theorem coeff_ofFinsuppLinearMap (f : Γ →₀ V) (a : Γ) :
(ofFinsuppLinearMap R f).coeff a = f a := rfl
end Finsupp
section Domain
variable [PartialOrder Γ']
theorem embDomain_smul (f : Γ ↪o Γ') (r : R) (x : HahnSeries Γ R) :
embDomain f (r • x) = r • embDomain f x := by
ext g
by_cases hg : g ∈ Set.range f
· obtain ⟨a, rfl⟩ := hg
simp
· simp [embDomain_notin_range hg]
/-- Extending the domain of Hahn series is a linear map. -/
@[simps]
def embDomainLinearMap (f : Γ ↪o Γ') : HahnSeries Γ R →ₗ[R] HahnSeries Γ' R where
toFun := embDomain f
map_add' := embDomain_add f
map_smul' := embDomain_smul f
end Domain
variable (R) in
/-- `HahnSeries.truncLT` as a linear map. -/
def truncLTLinearMap [DecidableLT Γ] (c : Γ) : HahnSeries Γ V →ₗ[R] HahnSeries Γ V where
toFun := truncLT c
map_add' := truncLT_add c
map_smul' := truncLT_smul c
variable (R) in
@[simp]
theorem coe_truncLTLinearMap [DecidableLT Γ] (c : Γ) :
(truncLTLinearMap R c : HahnSeries Γ V → HahnSeries Γ V) = truncLT c := by rfl
end Module
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Multiplication.lean | import Mathlib.Algebra.Algebra.Subalgebra.Lattice
import Mathlib.Algebra.GroupWithZero.Regular
import Mathlib.Algebra.Module.BigOperators
import Mathlib.Data.Finset.MulAntidiagonal
import Mathlib.Data.Finset.SMulAntidiagonal
import Mathlib.GroupTheory.GroupAction.Ring
import Mathlib.RingTheory.HahnSeries.Addition
/-!
# Multiplicative properties of Hahn series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. This module introduces
multiplication and scalar multiplication on Hahn series. If `Γ` is an ordered cancellative
commutative additive monoid and `R` is a semiring, then we get a semiring structure on
`HahnSeries Γ R`. If `Γ` has an ordered vector-addition on `Γ'` and `R` has a scalar multiplication
on `V`, we define `HahnModule Γ' R V` as a type alias for `HahnSeries Γ' V` that admits a scalar
multiplication from `HahnSeries Γ R`. The scalar action of `R` on `HahnSeries Γ R` is compatible
with the action of `HahnSeries Γ R` on `HahnModule Γ' R V`.
## Main Definitions
* `HahnModule` is a type alias for `HahnSeries`, which we use for defining scalar multiplication
of `HahnSeries Γ R` on `HahnModule Γ' R V` for an `R`-module `V`, where `Γ'` admits an ordered
cancellative vector addition operation from `Γ`. The type alias allows us to avoid a potential
instance diamond.
* `HahnModule.of` is the isomorphism from `HahnSeries Γ V` to `HahnModule Γ R V`.
* `HahnSeries.C` is the `constant term` ring homomorphism `R →+* HahnSeries Γ R`.
* `HahnSeries.embDomainRingHom` is the ring homomorphism `HahnSeries Γ R →+* HahnSeries Γ' R`
induced by an order embedding `Γ ↪o Γ'`.
## Main results
* If `R` is a (commutative) (semi-)ring, then so is `HahnSeries Γ R`.
* If `V` is an `R`-module, then `HahnModule Γ' R V` is a `HahnSeries Γ R`-module.
## TODO
The following may be useful for composing vertex operators, but they seem to take time.
* rightTensorMap: `HahnModule Γ' R U ⊗[R] V →ₗ[R] HahnModule Γ' R (U ⊗[R] V)`
* leftTensorMap: `U ⊗[R] HahnModule Γ' R V →ₗ[R] HahnModule Γ' R (U ⊗[R] V)`
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function Pointwise
noncomputable section
variable {Γ Γ' R S V : Type*}
namespace HahnSeries
variable [Zero Γ] [PartialOrder Γ]
instance [Zero R] [One R] : One (HahnSeries Γ R) where one := single 0 1
instance [Zero R] [NatCast R] : NatCast (HahnSeries Γ R) where natCast n := single 0 n
instance [Zero R] [IntCast R] : IntCast (HahnSeries Γ R) where intCast z := single 0 z
instance [Zero R] [NNRatCast R] : NNRatCast (HahnSeries Γ R) where nnratCast q := single 0 q
instance [Zero R] [RatCast R] : RatCast (HahnSeries Γ R) where ratCast q := single 0 q
open Classical in
@[simp]
theorem coeff_one [Zero R] [One R] {a : Γ} :
(1 : HahnSeries Γ R).coeff a = if a = 0 then 1 else 0 :=
coeff_single
@[simp] theorem single_zero_one [Zero R] [One R] : single (0 : Γ) (1 : R) = 1 := rfl
theorem single_zero_natCast [Zero R] [NatCast R] (n : ℕ) : single (0 : Γ) (n : R) = n := rfl
theorem single_zero_intCast [Zero R] [IntCast R] (z : ℤ) : single (0 : Γ) (z : R) = z := rfl
theorem single_zero_nnratCast [Zero R] [NNRatCast R] (q : ℚ≥0) : single (0 : Γ) (q : R) = q := rfl
theorem single_zero_ratCast [Zero R] [RatCast R] (q : ℚ) : single (0 : Γ) (q : R) = q := rfl
theorem single_zero_ofNat [Zero R] [NatCast R] (n : ℕ) [n.AtLeastTwo] :
single (0 : Γ) (ofNat(n) : R) = ofNat(n) := rfl
@[simp]
theorem support_one [MulZeroOneClass R] [Nontrivial R] : support (1 : HahnSeries Γ R) = {0} :=
support_single_of_ne one_ne_zero
@[simp]
theorem orderTop_one [MulZeroOneClass R] [Nontrivial R] : orderTop (1 : HahnSeries Γ R) = 0 := by
rw [← single_zero_one, orderTop_single one_ne_zero, WithTop.coe_eq_zero]
@[simp]
theorem order_one [MulZeroOneClass R] : order (1 : HahnSeries Γ R) = 0 := by
cases subsingleton_or_nontrivial R
· rw [Subsingleton.elim (1 : HahnSeries Γ R) 0, order_zero]
· exact order_single one_ne_zero
@[simp]
theorem leadingCoeff_one [MulZeroOneClass R] : (1 : HahnSeries Γ R).leadingCoeff = 1 := by
simp [leadingCoeff_eq]
@[simp]
protected lemma map_one [MonoidWithZero R] [MonoidWithZero S] (f : R →*₀ S) :
(1 : HahnSeries Γ R).map f = (1 : HahnSeries Γ S) :=
HahnSeries.map_single (a := (0 : Γ)) f.toZeroHom |>.trans <| congrArg _ <| f.map_one
instance [AddCommMonoidWithOne R] : AddCommMonoidWithOne (HahnSeries Γ R) where
natCast_zero := by simp [← single_zero_natCast]
natCast_succ n := by simp [← single_zero_natCast]
instance [AddCommGroupWithOne R] : AddCommGroupWithOne (HahnSeries Γ R) where
intCast_ofNat n := by simp [← single_zero_natCast, ← single_zero_intCast]
intCast_negSucc n := by simp [← single_zero_natCast, ← single_zero_intCast]
end HahnSeries
/-- We introduce a type alias for `HahnSeries` in order to work with scalar multiplication by
series. If we wrote a `SMul (HahnSeries Γ R) (HahnSeries Γ V)` instance, then when
`V = HahnSeries Γ R`, we would have two different actions of `HahnSeries Γ R` on `HahnSeries Γ V`.
See `Mathlib/Algebra/Polynomial/Module.lean` for more discussion on this problem. -/
@[nolint unusedArguments]
def HahnModule (Γ R V : Type*) [PartialOrder Γ] [Zero V] [SMul R V] :=
HahnSeries Γ V
namespace HahnModule
section
variable [PartialOrder Γ] [Zero V] [SMul R V]
/-- The casting function to the type synonym. -/
def of (R : Type*) [SMul R V] : HahnSeries Γ V ≃ HahnModule Γ R V :=
Equiv.refl _
/-- Recursion principle to reduce a result about the synonym to the original type. -/
@[elab_as_elim]
def rec {motive : HahnModule Γ R V → Sort*} (h : ∀ x : HahnSeries Γ V, motive (of R x)) :
∀ x, motive x :=
fun x => h <| (of R).symm x
@[ext]
theorem ext (x y : HahnModule Γ R V) (h : ((of R).symm x).coeff = ((of R).symm y).coeff) : x = y :=
(of R).symm.injective <| HahnSeries.coeff_inj.1 h
end
section SMul
variable [PartialOrder Γ] [SMul R V]
instance instZero [Zero V] : Zero (HahnModule Γ R V) :=
inferInstanceAs <| Zero (HahnSeries Γ V)
instance instAddCommMonoid [AddCommMonoid V] : AddCommMonoid (HahnModule Γ R V) :=
inferInstanceAs <| AddCommMonoid (HahnSeries Γ V)
instance instAddCommGroup [AddCommGroup V] : AddCommGroup (HahnModule Γ R V) :=
inferInstanceAs <| AddCommGroup (HahnSeries Γ V)
instance instBaseSMul {V} [Monoid R] [AddMonoid V] [DistribMulAction R V] :
SMul R (HahnModule Γ R V) :=
inferInstanceAs <| SMul R (HahnSeries Γ V)
@[simp] theorem of_zero [Zero V] : of R (0 : HahnSeries Γ V) = 0 := rfl
@[simp] theorem of_add [AddCommMonoid V] (x y : HahnSeries Γ V) :
of R (x + y) = of R x + of R y := rfl
@[simp] theorem of_sub [AddCommGroup V] (x y : HahnSeries Γ V) :
of R (x - y) = of R x - of R y := rfl
@[simp] theorem of_symm_zero [Zero V] : (of R).symm (0 : HahnModule Γ R V) = 0 := rfl
@[simp] theorem of_symm_add [AddCommMonoid V] (x y : HahnModule Γ R V) :
(of R).symm (x + y) = (of R).symm x + (of R).symm y := rfl
@[simp] theorem of_symm_sub [AddCommGroup V] (x y : HahnModule Γ R V) :
(of R).symm (x - y) = (of R).symm x - (of R).symm y := rfl
variable [PartialOrder Γ'] [VAdd Γ Γ'] [IsOrderedCancelVAdd Γ Γ'] [Zero R] [AddCommMonoid V]
instance instSMul : SMul (HahnSeries Γ R) (HahnModule Γ' R V) where
smul x y := (of R) {
coeff := fun a =>
∑ ij ∈ VAddAntidiagonal x.isPWO_support ((of R).symm y).isPWO_support a,
x.coeff ij.fst • ((of R).symm y).coeff ij.snd
isPWO_support' :=
haveI h :
{ a : Γ' |
(∑ ij ∈ VAddAntidiagonal x.isPWO_support ((of R).symm y).isPWO_support a,
x.coeff ij.fst • ((of R).symm y).coeff ij.snd) ≠ 0 } ⊆
{ a : Γ' | (VAddAntidiagonal x.isPWO_support
((of R).symm y).isPWO_support a).Nonempty } := by
intro a ha
contrapose! ha
simp [not_nonempty_iff_eq_empty.1 ha]
isPWO_support_vaddAntidiagonal.mono h }
theorem coeff_smul (x : HahnSeries Γ R) (y : HahnModule Γ' R V) (a : Γ') :
((of R).symm <| x • y).coeff a =
∑ ij ∈ VAddAntidiagonal x.isPWO_support ((of R).symm y).isPWO_support a,
x.coeff ij.fst • ((of R).symm y).coeff ij.snd :=
rfl
end SMul
section SMulZeroClass
variable [PartialOrder Γ] [PartialOrder Γ'] [VAdd Γ Γ'] [IsOrderedCancelVAdd Γ Γ']
[AddCommMonoid V]
instance instBaseSMulZeroClass [SMulZeroClass R V] :
SMulZeroClass R (HahnModule Γ R V) :=
inferInstanceAs <| SMulZeroClass R (HahnSeries Γ V)
@[simp] theorem of_smul [SMulZeroClass R V] (r : R) (x : HahnSeries Γ V) :
(of R) (r • x) = r • (of R) x := rfl
@[simp] theorem of_symm_smul [SMulZeroClass R V] (r : R) (x : HahnModule Γ R V) :
(of R).symm (r • x) = r • (of R).symm x := rfl
variable [Zero R]
instance instSMulZeroClass [SMulZeroClass R V] :
SMulZeroClass (HahnSeries Γ R) (HahnModule Γ' R V) where
smul_zero x := by
ext
simp [coeff_smul]
theorem coeff_smul_right [SMulZeroClass R V] {x : HahnSeries Γ R} {y : HahnModule Γ' R V} {a : Γ'}
{s : Set Γ'} (hs : s.IsPWO) (hys : ((of R).symm y).support ⊆ s) :
((of R).symm <| x • y).coeff a =
∑ ij ∈ VAddAntidiagonal x.isPWO_support hs a,
x.coeff ij.fst • ((of R).symm y).coeff ij.snd := by
classical
rw [coeff_smul]
apply sum_subset_zero_on_sdiff (vaddAntidiagonal_mono_right hys) _ fun _ _ => rfl
intro b hb
simp only [not_and, mem_sdiff, mem_vaddAntidiagonal, HahnSeries.mem_support, not_imp_not] at hb
rw [hb.2 hb.1.1 hb.1.2.2, smul_zero]
theorem coeff_smul_left [SMulWithZero R V] {x : HahnSeries Γ R}
{y : HahnModule Γ' R V} {a : Γ'} {s : Set Γ}
(hs : s.IsPWO) (hxs : x.support ⊆ s) :
((of R).symm <| x • y).coeff a =
∑ ij ∈ VAddAntidiagonal hs ((of R).symm y).isPWO_support a,
x.coeff ij.fst • ((of R).symm y).coeff ij.snd := by
classical
rw [coeff_smul]
apply sum_subset_zero_on_sdiff (vaddAntidiagonal_mono_left hxs) _ fun _ _ => rfl
intro b hb
simp only [not_and', mem_sdiff, mem_vaddAntidiagonal, HahnSeries.mem_support, not_ne_iff] at hb
rw [hb.2 ⟨hb.1.2.1, hb.1.2.2⟩, zero_smul]
end SMulZeroClass
section DistribSMul
variable [PartialOrder Γ] [PartialOrder Γ'] [VAdd Γ Γ'] [IsOrderedCancelVAdd Γ Γ'] [AddCommMonoid V]
theorem smul_add [Zero R] [DistribSMul R V] (x : HahnSeries Γ R) (y z : HahnModule Γ' R V) :
x • (y + z) = x • y + x • z := by
ext k
have hwf := ((of R).symm y).isPWO_support.union ((of R).symm z).isPWO_support
rw [coeff_smul_right hwf, of_symm_add]
· simp_all only [HahnSeries.coeff_add', Pi.add_apply, of_symm_add]
rw [coeff_smul_right hwf Set.subset_union_right,
coeff_smul_right hwf Set.subset_union_left]
simp_all [sum_add_distrib]
· intro b
simp_all only [Set.isPWO_union, HahnSeries.isPWO_support, and_self, of_symm_add,
HahnSeries.coeff_add', Pi.add_apply, ne_eq, Set.mem_union, HahnSeries.mem_support]
contrapose!
intro h
rw [h.1, h.2, add_zero]
instance instDistribSMul [MonoidWithZero R] [DistribSMul R V] : DistribSMul (HahnSeries Γ R)
(HahnModule Γ' R V) where
smul_add := smul_add
theorem add_smul [AddCommMonoid R] [SMulWithZero R V] {x y : HahnSeries Γ R}
{z : HahnModule Γ' R V} (h : ∀ (r s : R) (u : V), (r + s) • u = r • u + s • u) :
(x + y) • z = x • z + y • z := by
ext a
have hwf := x.isPWO_support.union y.isPWO_support
rw [coeff_smul_left hwf, HahnSeries.coeff_add', of_symm_add]
· simp_all only [Pi.add_apply, HahnSeries.coeff_add']
rw [coeff_smul_left hwf Set.subset_union_right,
coeff_smul_left hwf Set.subset_union_left]
simp only [sum_add_distrib]
· intro b
simp_all only [Set.isPWO_union, HahnSeries.isPWO_support, and_self, HahnSeries.mem_support,
HahnSeries.coeff_add, ne_eq, Set.mem_union]
contrapose!
intro h
rw [h.1, h.2, add_zero]
theorem coeff_single_smul_vadd [MulZeroClass R] [SMulWithZero R V] {r : R} {x : HahnModule Γ' R V}
{a : Γ'} {b : Γ} :
((of R).symm (HahnSeries.single b r • x)).coeff (b +ᵥ a) = r • ((of R).symm x).coeff a := by
by_cases hr : r = 0
· simp_all only [map_zero, zero_smul, coeff_smul, HahnSeries.support_zero, HahnSeries.coeff_zero,
sum_const_zero]
simp only [hr, coeff_smul, coeff_smul, HahnSeries.support_single_of_ne, ne_eq, not_false_iff]
by_cases hx : ((of R).symm x).coeff a = 0
· simp only [hx, smul_zero]
rw [sum_congr _ fun _ _ => rfl, sum_empty]
ext ⟨a1, a2⟩
simp only [notMem_empty, not_and, Set.mem_singleton_iff,
mem_vaddAntidiagonal, iff_false]
rintro rfl h2 h1
rw [IsCancelVAdd.left_cancel a1 a2 a h1] at h2
exact h2 hx
trans ∑ ij ∈ {(b, a)},
(HahnSeries.single b r).coeff ij.fst • ((of R).symm x).coeff ij.snd
· apply sum_congr _ fun _ _ => rfl
ext ⟨a1, a2⟩
simp only [Set.mem_singleton_iff, Prod.mk_inj, mem_vaddAntidiagonal, mem_singleton]
constructor
· rintro ⟨rfl, _, h1⟩
exact ⟨rfl, IsCancelVAdd.left_cancel a1 a2 a h1⟩
· rintro ⟨rfl, rfl⟩
exact ⟨rfl, by exact hx, rfl⟩
· simp
theorem coeff_single_zero_smul {Γ} [AddCommMonoid Γ] [PartialOrder Γ] [AddAction Γ Γ']
[IsOrderedCancelVAdd Γ Γ'] [MulZeroClass R] [SMulWithZero R V] {r : R}
{x : HahnModule Γ' R V} {a : Γ'} :
((of R).symm ((HahnSeries.single 0 r : HahnSeries Γ R) • x)).coeff a =
r • ((of R).symm x).coeff a := by
nth_rw 1 [← zero_vadd Γ a]
exact coeff_single_smul_vadd
@[simp]
theorem single_zero_smul_eq_smul (Γ) [AddCommMonoid Γ] [PartialOrder Γ] [AddAction Γ Γ']
[IsOrderedCancelVAdd Γ Γ'] [MulZeroClass R] [SMulWithZero R V] {r : R}
{x : HahnModule Γ' R V} :
(HahnSeries.single (0 : Γ) r) • x = r • x := by
ext
exact coeff_single_zero_smul
@[simp]
theorem zero_smul' [Zero R] [SMulWithZero R V] {x : HahnModule Γ' R V} :
(0 : HahnSeries Γ R) • x = 0 := by
ext
simp [coeff_smul]
@[simp]
theorem one_smul' {Γ} [AddCommMonoid Γ] [PartialOrder Γ] [AddAction Γ Γ'] [IsOrderedCancelVAdd Γ Γ']
[MonoidWithZero R] [MulActionWithZero R V] {x : HahnModule Γ' R V} :
(1 : HahnSeries Γ R) • x = x := by
ext g
exact coeff_single_zero_smul.trans (one_smul R (x.coeff g))
theorem support_smul_subset_vadd_support' [MulZeroClass R] [SMulWithZero R V] {x : HahnSeries Γ R}
{y : HahnModule Γ' R V} :
((of R).symm (x • y)).support ⊆ x.support +ᵥ ((of R).symm y).support := by
apply Set.Subset.trans (fun x hx => _) support_vaddAntidiagonal_subset_vadd
· exact x.isPWO_support
· exact y.isPWO_support
intro x hx
contrapose! hx
simp only [Set.mem_setOf_eq, not_nonempty_iff_eq_empty] at hx
simp [hx, coeff_smul]
theorem support_smul_subset_vadd_support [MulZeroClass R] [SMulWithZero R V] {x : HahnSeries Γ R}
{y : HahnModule Γ' R V} :
((of R).symm (x • y)).support ⊆ x.support +ᵥ ((of R).symm y).support := by
exact support_smul_subset_vadd_support'
theorem orderTop_vAdd_le_orderTop_smul {Γ Γ'} [LinearOrder Γ] [LinearOrder Γ'] [VAdd Γ Γ']
[IsOrderedCancelVAdd Γ Γ'] [MulZeroClass R] [SMulWithZero R V] {x : HahnSeries Γ R}
[VAdd (WithTop Γ) (WithTop Γ')] {y : HahnModule Γ' R V}
(h : ∀ (γ : Γ) (γ' : Γ'), γ +ᵥ γ' = (γ : WithTop Γ) +ᵥ (γ' : WithTop Γ')) :
x.orderTop +ᵥ ((of R).symm y).orderTop ≤ ((of R).symm (x • y)).orderTop := by
by_cases hx : x = 0; · simp_all
by_cases hy : y = 0; · simp_all
have hhy : ((of R).symm y) ≠ 0 := hy
rw [HahnSeries.orderTop_of_ne_zero hx, HahnSeries.orderTop_of_ne_zero hhy, ← h,
← Set.IsWF.min_vadd]
by_cases hxy : (of R).symm (x • y) = 0
· rw [hxy, HahnSeries.orderTop_zero]
exact OrderTop.le_top (α := WithTop Γ') _
· rw [HahnSeries.orderTop_of_ne_zero hxy, WithTop.coe_le_coe]
exact Set.IsWF.min_le_min_of_subset support_smul_subset_vadd_support
theorem coeff_smul_order_add_order {Γ}
[AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [Zero R]
[SMulWithZero R V] (x : HahnSeries Γ R) (y : HahnModule Γ R V) :
((of R).symm (x • y)).coeff (x.order + ((of R).symm y).order) =
x.leadingCoeff • ((of R).symm y).leadingCoeff := by
by_cases hx : x = (0 : HahnSeries Γ R); · simp [HahnSeries.coeff_zero, hx]
by_cases hy : (of R).symm y = 0; · simp [hy, coeff_smul]
rw [HahnSeries.order_of_ne hx, HahnSeries.order_of_ne hy, coeff_smul,
HahnSeries.leadingCoeff_of_ne_zero hx, HahnSeries.leadingCoeff_of_ne_zero hy, ← vadd_eq_add,
Finset.vaddAntidiagonal_min_vadd_min, Finset.sum_singleton]
simp [HahnSeries.orderTop, hx, hy]
end DistribSMul
end HahnModule
variable [AddCommMonoid Γ] [PartialOrder Γ] [IsOrderedCancelAddMonoid Γ]
namespace HahnSeries
instance [NonUnitalNonAssocSemiring R] : Mul (HahnSeries Γ R) where
mul x y := (HahnModule.of R).symm (x • HahnModule.of R y)
theorem of_symm_smul_of_eq_mul [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} :
(HahnModule.of R).symm (x • HahnModule.of R y) = x * y := rfl
theorem coeff_mul [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} :
(x * y).coeff a =
∑ ij ∈ addAntidiagonal x.isPWO_support y.isPWO_support a, x.coeff ij.fst * y.coeff ij.snd :=
rfl
protected lemma map_mul [NonUnitalNonAssocSemiring R] [NonUnitalNonAssocSemiring S] (f : R →ₙ+* S)
{x y : HahnSeries Γ R} : (x * y).map f = (x.map f : HahnSeries Γ S) * (y.map f) := by
ext
simp only [map_coeff, coeff_mul, map_sum, map_mul]
refine Eq.symm (sum_subset (fun gh hgh => ?_) (fun gh hgh hz => ?_))
· simp_all only [mem_addAntidiagonal, mem_support, map_coeff, ne_eq, and_true]
exact ⟨fun h => hgh.1 (map_zero f ▸ congrArg f h), fun h => hgh.2.1 (map_zero f ▸ congrArg f h)⟩
· simp_all only [mem_addAntidiagonal, mem_support, ne_eq, map_coeff, and_true,
not_and, not_not]
by_cases h : f (x.coeff gh.1) = 0
· exact mul_eq_zero_of_left h (f (y.coeff gh.2))
· exact mul_eq_zero_of_right (f (x.coeff gh.1)) (hz h)
theorem coeff_mul_left' [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} {s : Set Γ}
(hs : s.IsPWO) (hxs : x.support ⊆ s) :
(x * y).coeff a =
∑ ij ∈ addAntidiagonal hs y.isPWO_support a, x.coeff ij.fst * y.coeff ij.snd :=
HahnModule.coeff_smul_left hs hxs
theorem coeff_mul_right' [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} {a : Γ} {s : Set Γ}
(hs : s.IsPWO) (hys : y.support ⊆ s) :
(x * y).coeff a =
∑ ij ∈ addAntidiagonal x.isPWO_support hs a, x.coeff ij.fst * y.coeff ij.snd :=
HahnModule.coeff_smul_right hs hys
instance [NonUnitalNonAssocSemiring R] : Distrib (HahnSeries Γ R) :=
{ inferInstanceAs (Mul (HahnSeries Γ R)),
inferInstanceAs (Add (HahnSeries Γ R)) with
left_distrib := fun x y z => by
simp only [← of_symm_smul_of_eq_mul]
exact HahnModule.smul_add x y z
right_distrib := fun x y z => by
simp only [← of_symm_smul_of_eq_mul]
refine HahnModule.add_smul ?_
simp only [smul_eq_mul]
exact add_mul }
theorem coeff_single_mul_add [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ}
{b : Γ} : (single b r * x).coeff (a + b) = r * x.coeff a := by
rw [← of_symm_smul_of_eq_mul, add_comm, ← vadd_eq_add]
exact HahnModule.coeff_single_smul_vadd
theorem coeff_mul_single_add [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ}
{b : Γ} : (x * single b r).coeff (a + b) = x.coeff a * r := by
by_cases hr : r = 0
· simp [hr, coeff_mul]
simp only [hr, coeff_mul, support_single_of_ne, Ne, not_false_iff]
by_cases hx : x.coeff a = 0
· simp only [hx, zero_mul]
rw [sum_congr _ fun _ _ => rfl, sum_empty]
ext ⟨a1, a2⟩
simp only [notMem_empty, not_and, Set.mem_singleton_iff,
mem_addAntidiagonal, iff_false]
rintro h2 rfl h1
rw [← add_right_cancel h1] at hx
exact h2 hx
trans ∑ ij ∈ {(a, b)}, x.coeff ij.fst * (single b r).coeff ij.snd
· apply sum_congr _ fun _ _ => rfl
ext ⟨a1, a2⟩
simp only [Set.mem_singleton_iff, Prod.mk_inj, mem_addAntidiagonal, mem_singleton]
constructor
· rintro ⟨_, rfl, h1⟩
exact ⟨add_right_cancel h1, rfl⟩
· rintro ⟨rfl, rfl⟩
simp [hx]
· simp
@[simp]
theorem coeff_mul_single_zero [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} :
(x * single 0 r).coeff a = x.coeff a * r := by rw [← add_zero a, coeff_mul_single_add, add_zero]
theorem coeff_single_zero_mul [NonUnitalNonAssocSemiring R] {r : R} {x : HahnSeries Γ R} {a : Γ} :
((single 0 r : HahnSeries Γ R) * x).coeff a = r * x.coeff a := by
rw [← add_zero a, coeff_single_mul_add, add_zero]
@[simp]
theorem single_zero_mul_eq_smul [Semiring R] {r : R} {x : HahnSeries Γ R} :
single 0 r * x = r • x := by
ext
exact coeff_single_zero_mul
theorem support_mul_subset_add_support [NonUnitalNonAssocSemiring R] {x y : HahnSeries Γ R} :
support (x * y) ⊆ support x + support y := by
rw [← of_symm_smul_of_eq_mul, ← vadd_eq_add]
exact HahnModule.support_smul_subset_vadd_support
section orderLemmas
variable {Γ : Type*} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[NonUnitalNonAssocSemiring R]
theorem coeff_mul_order_add_order (x y : HahnSeries Γ R) :
(x * y).coeff (x.order + y.order) = x.leadingCoeff * y.leadingCoeff := by
simp only [← of_symm_smul_of_eq_mul]
exact HahnModule.coeff_smul_order_add_order x y
theorem orderTop_add_le_mul {x y : HahnSeries Γ R} :
x.orderTop + y.orderTop ≤ (x * y).orderTop := by
rw [← smul_eq_mul]
exact HahnModule.orderTop_vAdd_le_orderTop_smul fun i j ↦ rfl
theorem order_mul_of_nonzero {x y : HahnSeries Γ R}
(h : x.leadingCoeff * y.leadingCoeff ≠ 0) : (x * y).order = x.order + y.order := by
have hx : x.leadingCoeff ≠ 0 := by aesop
have hy : y.leadingCoeff ≠ 0 := by aesop
have hxy : (x * y).coeff (x.order + y.order) ≠ 0 :=
ne_of_eq_of_ne (coeff_mul_order_add_order x y) h
refine le_antisymm (order_le_of_coeff_ne_zero
(Eq.mpr (congrArg (fun _a ↦ _a ≠ 0) (coeff_mul_order_add_order x y)) h)) ?_
rw [order_of_ne <| leadingCoeff_ne_zero.mp hx, order_of_ne <| leadingCoeff_ne_zero.mp hy,
order_of_ne <| ne_zero_of_coeff_ne_zero hxy, ← Set.IsWF.min_add]
exact Set.IsWF.min_le_min_of_subset support_mul_subset_add_support
theorem order_single_mul_of_isRegular {g : Γ} {r : R} (hr : IsRegular r)
{x : HahnSeries Γ R} (hx : x ≠ 0) : (((single g) r) * x).order = g + x.order := by
obtain _ | _ := subsingleton_or_nontrivial R
· exact (hx <| Subsingleton.eq_zero x).elim
have hrx : ((single g) r).leadingCoeff * x.leadingCoeff ≠ 0 := by
rwa [leadingCoeff_of_single, ne_eq, hr.left.mul_left_eq_zero_iff, leadingCoeff_eq_zero]
rw [order_mul_of_nonzero hrx, order_single <| IsRegular.ne_zero hr]
end orderLemmas
private theorem mul_assoc' [NonUnitalSemiring R] (x y z : HahnSeries Γ R) :
x * y * z = x * (y * z) := by
ext b
rw [coeff_mul_left' (x.isPWO_support.add y.isPWO_support) support_mul_subset_add_support,
coeff_mul_right' (y.isPWO_support.add z.isPWO_support) support_mul_subset_add_support]
simp only [coeff_mul, sum_mul, mul_sum, sum_sigma']
apply Finset.sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l + j), (l, j)⟩)
(fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i + k, l), (i, k)⟩) <;>
aesop (add safe Set.add_mem_add) (add simp [add_assoc, mul_assoc])
instance [NonUnitalNonAssocSemiring R] : NonUnitalNonAssocSemiring (HahnSeries Γ R) :=
{ inferInstanceAs (AddCommMonoid (HahnSeries Γ R)),
inferInstanceAs (Distrib (HahnSeries Γ R)) with
zero_mul := fun _ => by
ext
simp [coeff_mul]
mul_zero := fun _ => by
ext
simp [coeff_mul] }
instance [NonUnitalSemiring R] : NonUnitalSemiring (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)) with
mul_assoc := mul_assoc' }
instance [NonAssocSemiring R] : NonAssocSemiring (HahnSeries Γ R) :=
{ inferInstanceAs (AddMonoidWithOne (HahnSeries Γ R)),
inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)) with
one_mul := fun x => by
ext
exact coeff_single_zero_mul.trans (one_mul _)
mul_one := fun x => by
ext
exact coeff_mul_single_zero.trans (mul_one _) }
instance [Semiring R] : Semiring (HahnSeries Γ R) :=
{ inferInstanceAs (NonAssocSemiring (HahnSeries Γ R)),
inferInstanceAs (NonUnitalSemiring (HahnSeries Γ R)) with }
instance [NonUnitalCommSemiring R] : NonUnitalCommSemiring (HahnSeries Γ R) where
__ : NonUnitalSemiring (HahnSeries Γ R) := inferInstance
mul_comm x y := by
ext
simp_rw [coeff_mul, mul_comm]
exact Finset.sum_equiv (Equiv.prodComm _ _) (fun _ ↦ swap_mem_addAntidiagonal.symm) <| by simp
instance [CommSemiring R] : CommSemiring (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalCommSemiring (HahnSeries Γ R)),
inferInstanceAs (Semiring (HahnSeries Γ R)) with }
instance [NonUnitalNonAssocRing R] : NonUnitalNonAssocRing (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalNonAssocSemiring (HahnSeries Γ R)),
inferInstanceAs (AddGroup (HahnSeries Γ R)) with }
instance [NonUnitalRing R] : NonUnitalRing (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalNonAssocRing (HahnSeries Γ R)),
inferInstanceAs (NonUnitalSemiring (HahnSeries Γ R)) with }
instance [NonAssocRing R] : NonAssocRing (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalNonAssocRing (HahnSeries Γ R)),
inferInstanceAs (NonAssocSemiring (HahnSeries Γ R)),
inferInstanceAs (AddGroupWithOne (HahnSeries Γ R)) with }
instance [Ring R] : Ring (HahnSeries Γ R) :=
{ inferInstanceAs (Semiring (HahnSeries Γ R)),
inferInstanceAs (AddCommGroupWithOne (HahnSeries Γ R)) with }
instance [NonUnitalCommRing R] : NonUnitalCommRing (HahnSeries Γ R) :=
{ inferInstanceAs (NonUnitalCommSemiring (HahnSeries Γ R)),
inferInstanceAs (NonUnitalRing (HahnSeries Γ R)) with }
instance [CommRing R] : CommRing (HahnSeries Γ R) :=
{ inferInstanceAs (CommSemiring (HahnSeries Γ R)),
inferInstanceAs (Ring (HahnSeries Γ R)) with }
theorem orderTop_nsmul_le_orderTop_pow {Γ}
[AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Semiring R] {x : HahnSeries Γ R} {n : ℕ} : n • x.orderTop ≤ (x ^ n).orderTop := by
induction n with
| zero =>
simp only [zero_smul, pow_zero]
by_cases h : (0 : R) = 1
· simp [subsingleton_iff_zero_eq_one.mp h]
· simp [nontrivial_of_ne 0 1 h]
| succ n ih =>
rw [add_nsmul, pow_add]
calc
n • x.orderTop + 1 • x.orderTop ≤ (x ^ n).orderTop + 1 • x.orderTop := by gcongr
(x ^ n).orderTop + 1 • x.orderTop = (x ^ n).orderTop + x.orderTop := by rw [one_nsmul]
(x ^ n).orderTop + x.orderTop ≤ (x ^ n * x).orderTop := orderTop_add_le_mul
(x ^ n * x).orderTop ≤ (x ^ n * x ^ 1).orderTop := by rw [pow_one]
end HahnSeries
namespace HahnModule
variable [PartialOrder Γ'] [AddAction Γ Γ'] [IsOrderedCancelVAdd Γ Γ'] [AddCommMonoid V]
private theorem mul_smul' [Semiring R] [Module R V] (x y : HahnSeries Γ R)
(z : HahnModule Γ' R V) : (x * y) • z = x • (y • z) := by
ext b
rw [coeff_smul_left (x.isPWO_support.add y.isPWO_support)
HahnSeries.support_mul_subset_add_support, coeff_smul_right
(y.isPWO_support.vadd ((of R).symm z).isPWO_support) support_smul_subset_vadd_support]
simp only [HahnSeries.coeff_mul, coeff_smul, sum_smul, smul_sum, sum_sigma']
apply Finset.sum_nbij' (fun ⟨⟨_i, j⟩, ⟨k, l⟩⟩ ↦ ⟨(k, l +ᵥ j), (l, j)⟩)
(fun ⟨⟨i, _j⟩, ⟨k, l⟩⟩ ↦ ⟨(i + k, l), (i, k)⟩) <;>
aesop (add safe [Set.vadd_mem_vadd, Set.add_mem_add]) (add simp [add_vadd, mul_smul])
instance instBaseModule [Semiring R] [Module R V] : Module R (HahnModule Γ' R V) :=
inferInstanceAs <| Module R (HahnSeries Γ' V)
instance instModule [Semiring R] [Module R V] : Module (HahnSeries Γ R)
(HahnModule Γ' R V) := {
inferInstanceAs (DistribSMul (HahnSeries Γ R) (HahnModule Γ' R V)) with
mul_smul := mul_smul'
one_smul := fun _ => one_smul'
add_smul := fun _ _ _ => add_smul Module.add_smul
zero_smul := fun _ => zero_smul' }
instance [Zero R] {S : Type*} [Zero S] [SMul R S] [SMulWithZero R V] [SMulWithZero S V]
[IsScalarTower R S V] : IsScalarTower R S (HahnSeries Γ V) where
smul_assoc r s a := by
ext
simp
instance [Semiring R] [Module R V] : IsScalarTower R (HahnSeries Γ R) (HahnModule Γ' R V) where
smul_assoc r x a := by
rw [← HahnSeries.single_zero_mul_eq_smul, mul_smul', ← single_zero_smul_eq_smul Γ]
instance SMulCommClass [CommSemiring R] [Module R V] :
SMulCommClass R (HahnSeries Γ R) (HahnModule Γ' R V) where
smul_comm r x y := by
rw [← single_zero_smul_eq_smul Γ, ← mul_smul', mul_comm, mul_smul', single_zero_smul_eq_smul Γ]
instance instNoZeroSMulDivisors {Γ} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Zero R] [SMulWithZero R V] [NoZeroSMulDivisors R V] :
NoZeroSMulDivisors (HahnSeries Γ R) (HahnModule Γ R V) where
eq_zero_or_eq_zero_of_smul_eq_zero {x y} hxy := by
contrapose! hxy
simp only [ne_eq]
rw [HahnModule.ext_iff, funext_iff, not_forall]
refine ⟨x.order + ((of R).symm y).order, ?_⟩
rw [coeff_smul_order_add_order x y, of_symm_zero, HahnSeries.coeff_zero, smul_eq_zero, not_or]
constructor
· exact HahnSeries.leadingCoeff_ne_zero.mpr hxy.1
· exact HahnSeries.leadingCoeff_ne_zero.mpr hxy.2
end HahnModule
namespace HahnSeries
instance {Γ} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[NonUnitalNonAssocSemiring R] [NoZeroDivisors R] :
NoZeroDivisors (HahnSeries Γ R) where
eq_zero_or_eq_zero_of_mul_eq_zero {x y} xy := by
haveI : NoZeroSMulDivisors (HahnSeries Γ R) (HahnSeries Γ R) :=
HahnModule.instNoZeroSMulDivisors
exact eq_zero_or_eq_zero_of_smul_eq_zero xy
instance {Γ} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [Ring R] [IsDomain R] :
IsDomain (HahnSeries Γ R) :=
NoZeroDivisors.to_isDomain _
@[deprecated (since := "2025-08-11")] alias orderTop_add_orderTop_le_orderTop_mul :=
orderTop_add_le_mul
@[simp]
theorem order_mul {Γ} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[NonUnitalNonAssocSemiring R]
[NoZeroDivisors R] {x y : HahnSeries Γ R} (hx : x ≠ 0) (hy : y ≠ 0) :
(x * y).order = x.order + y.order := by
apply le_antisymm
· apply order_le_of_coeff_ne_zero
rw [coeff_mul_order_add_order x y]
exact mul_ne_zero (leadingCoeff_ne_zero.mpr hx) (leadingCoeff_ne_zero.mpr hy)
· rw [order_of_ne hx, order_of_ne hy, order_of_ne (mul_ne_zero hx hy), ← Set.IsWF.min_add]
exact Set.IsWF.min_le_min_of_subset support_mul_subset_add_support
@[simp]
theorem order_pow {Γ} [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[Semiring R] [NoZeroDivisors R]
(x : HahnSeries Γ R) (n : ℕ) : (x ^ n).order = n • x.order := by
induction n with
| zero => simp
| succ h IH =>
rcases eq_or_ne x 0 with (rfl | hx); · simp
rw [pow_succ, order_mul (pow_ne_zero _ hx) hx, succ_nsmul, IH]
section NonUnitalNonAssocSemiring
variable [NonUnitalNonAssocSemiring R]
@[simp]
theorem single_mul_single {a b : Γ} {r s : R} :
single a r * single b s = single (a + b) (r * s) := by
ext x
by_cases h : x = a + b
· rw [h, coeff_mul_single_add]
simp
· rw [coeff_single_of_ne h, coeff_mul, sum_eq_zero]
simp_rw [mem_addAntidiagonal]
rintro ⟨y, z⟩ ⟨hy, hz, rfl⟩
rw [eq_of_mem_support_single hy, eq_of_mem_support_single hz] at h
exact (h rfl).elim
end NonUnitalNonAssocSemiring
section Semiring
variable [Semiring R]
@[simp]
theorem single_pow (a : Γ) (n : ℕ) (r : R) : single a r ^ n = single (n • a) (r ^ n) := by
induction n with
| zero => ext; simp only [pow_zero, coeff_one, zero_smul, coeff_single]
| succ n IH => rw [pow_succ, pow_succ, IH, single_mul_single, succ_nsmul]
end Semiring
section NonAssocSemiring
variable [NonAssocSemiring R]
/-- `C a` is the constant Hahn Series `a`. `C` is provided as a ring homomorphism. -/
@[simps]
def C : R →+* HahnSeries Γ R where
toFun := single 0
map_zero' := single_eq_zero
map_one' := rfl
map_add' x y := by
ext a
by_cases h : a = 0 <;> simp [h]
map_mul' x y := by rw [single_mul_single, zero_add]
theorem C_zero : C (0 : R) = (0 : HahnSeries Γ R) :=
C.map_zero
theorem C_one : C (1 : R) = (1 : HahnSeries Γ R) :=
C.map_one
theorem map_C [NonAssocSemiring S] (a : R) (f : R →+* S) :
((C a).map f : HahnSeries Γ S) = C (f a) := by
ext g
by_cases h : g = 0 <;> simp [h]
theorem C_injective : Function.Injective (C : R → HahnSeries Γ R) := by
intro r s rs
rw [HahnSeries.ext_iff, funext_iff] at rs
have h := rs 0
rwa [C_apply, coeff_single_same, C_apply, coeff_single_same] at h
theorem C_ne_zero {r : R} (h : r ≠ 0) : (C r : HahnSeries Γ R) ≠ 0 :=
C_injective.ne_iff' C_zero |>.mpr h
theorem order_C {r : R} : order (C r : HahnSeries Γ R) = 0 := by
by_cases h : r = 0
· rw [h, C_zero, order_zero]
· exact order_single h
end NonAssocSemiring
section Semiring
variable [Semiring R]
theorem C_mul_eq_smul {r : R} {x : HahnSeries Γ R} : C r * x = r • x :=
single_zero_mul_eq_smul
end Semiring
section Domain
variable {Γ' : Type*} [AddCommMonoid Γ'] [PartialOrder Γ'] [IsOrderedCancelAddMonoid Γ']
theorem embDomain_mul [NonUnitalNonAssocSemiring R] (f : Γ ↪o Γ')
(hf : ∀ x y, f (x + y) = f x + f y) (x y : HahnSeries Γ R) :
embDomain f (x * y) = embDomain f x * embDomain f y := by
ext g
by_cases hg : g ∈ Set.range f
· obtain ⟨g, rfl⟩ := hg
simp only [coeff_mul, embDomain_coeff]
trans
∑ ij ∈
(addAntidiagonal x.isPWO_support y.isPWO_support g).map
(f.toEmbedding.prodMap f.toEmbedding),
(embDomain f x).coeff ij.1 * (embDomain f y).coeff ij.2
· simp
apply sum_subset
· rintro ⟨i, j⟩ hij
simp only [mem_map, mem_addAntidiagonal,
Function.Embedding.coe_prodMap, mem_support, Prod.exists] at hij
obtain ⟨i, j, ⟨hx, hy, rfl⟩, rfl, rfl⟩ := hij
simp [hx, hy, hf]
· rintro ⟨_, _⟩ h1 h2
contrapose! h2
obtain ⟨i, _, rfl⟩ := support_embDomain_subset (ne_zero_and_ne_zero_of_mul h2).1
obtain ⟨j, _, rfl⟩ := support_embDomain_subset (ne_zero_and_ne_zero_of_mul h2).2
simp only [mem_map, mem_addAntidiagonal,
Function.Embedding.coe_prodMap, mem_support, Prod.exists]
simp only [mem_addAntidiagonal, embDomain_coeff, mem_support, ← hf,
OrderEmbedding.eq_iff_eq] at h1
exact ⟨i, j, h1, rfl⟩
· rw [embDomain_notin_range hg, eq_comm]
contrapose! hg
obtain ⟨_, hi, _, hj, rfl⟩ := support_mul_subset_add_support ((mem_support _ _).2 hg)
obtain ⟨i, _, rfl⟩ := support_embDomain_subset hi
obtain ⟨j, _, rfl⟩ := support_embDomain_subset hj
exact ⟨i + j, hf i j⟩
omit [IsOrderedCancelAddMonoid Γ] [IsOrderedCancelAddMonoid Γ'] in
theorem embDomain_one [NonAssocSemiring R] (f : Γ ↪o Γ') (hf : f 0 = 0) :
embDomain f (1 : HahnSeries Γ R) = (1 : HahnSeries Γ' R) :=
embDomain_single.trans <| hf.symm ▸ rfl
/-- Extending the domain of Hahn series is a ring homomorphism. -/
@[simps]
def embDomainRingHom [NonAssocSemiring R] (f : Γ →+ Γ') (hfi : Function.Injective f)
(hf : ∀ g g' : Γ, f g ≤ f g' ↔ g ≤ g') : HahnSeries Γ R →+* HahnSeries Γ' R where
toFun := embDomain ⟨⟨f, hfi⟩, hf _ _⟩
map_one' := embDomain_one _ f.map_zero
map_mul' := embDomain_mul _ f.map_add
map_zero' := embDomain_zero
map_add' := embDomain_add _
theorem embDomainRingHom_C [NonAssocSemiring R] {f : Γ →+ Γ'} {hfi : Function.Injective f}
{hf : ∀ g g' : Γ, f g ≤ f g' ↔ g ≤ g'} {r : R} : embDomainRingHom f hfi hf (C r) = C r :=
embDomain_single.trans (by simp)
end Domain
section Algebra
variable [CommSemiring R] {A : Type*} [Semiring A] [Algebra R A]
instance : Algebra R (HahnSeries Γ A) where
algebraMap := C.comp (algebraMap R A)
smul_def' r x := by
ext
simp
commutes' r x := by
ext
simp only [coeff_smul, single_zero_mul_eq_smul, RingHom.coe_comp, C_apply,
Function.comp_apply, algebraMap_smul, coeff_mul_single_zero]
rw [← Algebra.commutes, Algebra.smul_def]
theorem C_eq_algebraMap : C = algebraMap R (HahnSeries Γ R) :=
rfl
theorem algebraMap_apply {r : R} : algebraMap R (HahnSeries Γ A) r = C (algebraMap R A r) :=
rfl
instance [Nontrivial Γ] [Nontrivial R] : Nontrivial (Subalgebra R (HahnSeries Γ R)) :=
⟨⟨⊥, ⊤, by
rw [Ne, SetLike.ext_iff, not_forall]
obtain ⟨a, ha⟩ := exists_ne (0 : Γ)
refine ⟨single a 1, ?_⟩
simp only [Algebra.mem_bot, not_exists, Set.mem_range, iff_true, Algebra.mem_top]
intro x
rw [HahnSeries.ext_iff, funext_iff, not_forall]
refine ⟨a, ?_⟩
rw [coeff_single_same, algebraMap_apply, C_apply, coeff_single_of_ne ha]
exact zero_ne_one⟩⟩
section Domain
variable {Γ' : Type*} [AddCommMonoid Γ'] [PartialOrder Γ'] [IsOrderedCancelAddMonoid Γ']
/-- Extending the domain of Hahn series is an algebra homomorphism. -/
@[simps!]
def embDomainAlgHom (f : Γ →+ Γ') (hfi : Function.Injective f)
(hf : ∀ g g' : Γ, f g ≤ f g' ↔ g ≤ g') : HahnSeries Γ A →ₐ[R] HahnSeries Γ' A :=
{ embDomainRingHom f hfi hf with commutes' := fun _ => embDomainRingHom_C (hf := hf) }
end Domain
end Algebra
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/Basic.lean | import Mathlib.Algebra.Notation.Support
import Mathlib.Algebra.Order.Monoid.Unbundled.WithTop
import Mathlib.Data.Finsupp.Defs
import Mathlib.Order.WellFoundedSet
/-!
# Hahn Series
If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of formal series over `Γ` with
coefficients in `R`, whose supports are partially well-ordered. With further structure on `R` and
`Γ`, we can add further structure on `HahnSeries Γ R`, with the most studied case being when `Γ` is
a linearly ordered abelian group and `R` is a field, in which case `HahnSeries Γ R` is a
valued field, with value group `Γ`.
These generalize Laurent series (with value group `ℤ`), and Laurent series are implemented that way
in the file `Mathlib/RingTheory/LaurentSeries.lean`.
## Main Definitions
* If `Γ` is ordered and `R` has zero, then `HahnSeries Γ R` consists of
formal series over `Γ` with coefficients in `R`, whose supports are partially well-ordered.
* `support x` is the subset of `Γ` whose coefficients are nonzero.
* `single a r` is the Hahn series which has coefficient `r` at `a` and zero otherwise.
* `orderTop x` is a minimal element of `WithTop Γ` where `x` has a nonzero
coefficient if `x ≠ 0`, and is `⊤` when `x = 0`.
* `order x` is a minimal element of `Γ` where `x` has a nonzero coefficient if `x ≠ 0`, and is zero
when `x = 0`.
* `map` takes each coefficient of a Hahn series to its target under a zero-preserving map.
* `embDomain` preserves coefficients, but embeds the index set `Γ` in a larger poset.
## References
- [J. van der Hoeven, *Operators on Generalized Power Series*][van_der_hoeven]
-/
open Finset Function
noncomputable section
/-- If `Γ` is linearly ordered and `R` has zero, then `HahnSeries Γ R` consists of
formal series over `Γ` with coefficients in `R`, whose supports are well-founded. -/
@[ext]
structure HahnSeries (Γ : Type*) (R : Type*) [PartialOrder Γ] [Zero R] where
/-- The coefficient function of a Hahn Series. -/
coeff : Γ → R
isPWO_support' : (Function.support coeff).IsPWO
variable {Γ Γ' R S : Type*}
namespace HahnSeries
section Zero
variable [PartialOrder Γ] [Zero R]
theorem coeff_injective : Injective (coeff : HahnSeries Γ R → Γ → R) :=
fun _ _ => HahnSeries.ext
@[simp]
theorem coeff_inj {x y : HahnSeries Γ R} : x.coeff = y.coeff ↔ x = y :=
coeff_injective.eq_iff
/-- The support of a Hahn series is just the set of indices whose coefficients are nonzero.
Notably, it is well-founded. -/
nonrec def support (x : HahnSeries Γ R) : Set Γ :=
support x.coeff
@[simp]
theorem isPWO_support (x : HahnSeries Γ R) : x.support.IsPWO :=
x.isPWO_support'
@[simp]
theorem isWF_support (x : HahnSeries Γ R) : x.support.IsWF :=
x.isPWO_support.isWF
@[simp]
theorem mem_support (x : HahnSeries Γ R) (a : Γ) : a ∈ x.support ↔ x.coeff a ≠ 0 :=
Iff.refl _
instance : Zero (HahnSeries Γ R) :=
⟨{ coeff := 0
isPWO_support' := by simp }⟩
instance : Inhabited (HahnSeries Γ R) :=
⟨0⟩
instance [Subsingleton R] : Subsingleton (HahnSeries Γ R) :=
⟨fun _ _ => HahnSeries.ext (by subsingleton)⟩
theorem coeff_zero' : (0 : HahnSeries Γ R).coeff = 0 :=
rfl
@[simp]
theorem coeff_zero {a : Γ} : (0 : HahnSeries Γ R).coeff a = 0 :=
rfl
@[simp]
theorem coeff_fun_eq_zero_iff {x : HahnSeries Γ R} : x.coeff = 0 ↔ x = 0 :=
coeff_injective.eq_iff' rfl
theorem ne_zero_of_coeff_ne_zero {x : HahnSeries Γ R} {g : Γ} (h : x.coeff g ≠ 0) : x ≠ 0 :=
mt (fun x0 => (x0.symm ▸ coeff_zero : x.coeff g = 0)) h
@[simp]
theorem support_zero : support (0 : HahnSeries Γ R) = ∅ :=
Function.support_zero
@[simp]
nonrec theorem support_nonempty_iff {x : HahnSeries Γ R} : x.support.Nonempty ↔ x ≠ 0 := by
rw [support, support_nonempty_iff, Ne, coeff_fun_eq_zero_iff]
@[simp]
theorem support_eq_empty_iff {x : HahnSeries Γ R} : x.support = ∅ ↔ x = 0 :=
Function.support_eq_empty_iff.trans coeff_fun_eq_zero_iff
/-- The map of Hahn series induced by applying a zero-preserving map to each coefficient. -/
@[simps]
def map [Zero S] (x : HahnSeries Γ R) {F : Type*} [FunLike F R S] [ZeroHomClass F R S] (f : F) :
HahnSeries Γ S where
coeff g := f (x.coeff g)
isPWO_support' := x.isPWO_support.mono <| Function.support_comp_subset (ZeroHomClass.map_zero f) _
@[simp]
protected lemma map_zero [Zero S] (f : ZeroHom R S) :
(0 : HahnSeries Γ R).map f = 0 := by
ext; simp
/-- Change a HahnSeries with coefficients in HahnSeries to a HahnSeries on the Lex product. -/
def ofIterate [PartialOrder Γ'] (x : HahnSeries Γ (HahnSeries Γ' R)) :
HahnSeries (Γ ×ₗ Γ') R where
coeff := fun g => coeff (coeff x g.1) g.2
isPWO_support' := by
refine Set.PartiallyWellOrderedOn.subsetProdLex ?_ ?_
· refine Set.IsPWO.mono x.isPWO_support' ?_
simp_rw [Set.image_subset_iff, support_subset_iff, Set.mem_preimage, Function.mem_support]
exact fun _ ↦ ne_zero_of_coeff_ne_zero
· exact fun a => by simpa [Function.mem_support, ne_eq] using (x.coeff a).isPWO_support'
@[simp]
lemma mk_eq_zero (f : Γ → R) (h) : HahnSeries.mk f h = 0 ↔ f = 0 := by
simp_rw [HahnSeries.ext_iff, funext_iff, coeff_zero, Pi.zero_apply]
/-- Change a Hahn series on a lex product to a Hahn series with coefficients in a Hahn series. -/
def toIterate [PartialOrder Γ'] (x : HahnSeries (Γ ×ₗ Γ') R) :
HahnSeries Γ (HahnSeries Γ' R) where
coeff := fun g => {
coeff := fun g' => coeff x (g, g')
isPWO_support' := Set.PartiallyWellOrderedOn.fiberProdLex x.isPWO_support' g
}
isPWO_support' := by
have h₁ : (Function.support fun g => HahnSeries.mk (fun g' => x.coeff (g, g'))
(Set.PartiallyWellOrderedOn.fiberProdLex x.isPWO_support' g)) = Function.support
fun g => fun g' => x.coeff (g, g') := by
simp only [Function.support, ne_eq, mk_eq_zero]
rw [h₁, Function.support_fun_curry x.coeff]
exact Set.PartiallyWellOrderedOn.imageProdLex x.isPWO_support'
/-- The equivalence between iterated Hahn series and Hahn series on the lex product. -/
@[simps]
def iterateEquiv [PartialOrder Γ'] :
HahnSeries Γ (HahnSeries Γ' R) ≃ HahnSeries (Γ ×ₗ Γ') R where
toFun := ofIterate
invFun := toIterate
left_inv := congrFun rfl
right_inv := congrFun rfl
open Classical in
/-- `single a r` is the Hahn series which has coefficient `r` at `a` and zero otherwise. -/
def single (a : Γ) : ZeroHom R (HahnSeries Γ R) where
toFun r :=
{ coeff := Pi.single a r
isPWO_support' := (Set.isPWO_singleton a).mono Pi.support_single_subset }
map_zero' := HahnSeries.ext (Pi.single_zero _)
variable {a b : Γ} {r : R}
@[simp]
theorem coeff_single_same (a : Γ) (r : R) : (single a r).coeff a = r := by
classical exact Pi.single_eq_same (M := fun _ => R) a r
@[simp]
theorem coeff_single_of_ne (h : b ≠ a) : (single a r).coeff b = 0 := by
classical exact Pi.single_eq_of_ne (M := fun _ => R) h r
open Classical in
theorem coeff_single : (single a r).coeff b = if b = a then r else 0 := by
split_ifs with h <;> simp [h]
@[simp]
theorem support_single_of_ne (h : r ≠ 0) : support (single a r) = {a} := by
classical exact Pi.support_single_of_ne h
theorem support_single_subset : support (single a r) ⊆ {a} := by
classical exact Pi.support_single_subset
theorem eq_of_mem_support_single {b : Γ} (h : b ∈ support (single a r)) : b = a :=
support_single_subset h
theorem single_eq_zero : single a (0 : R) = 0 :=
(single a).map_zero
theorem single_injective (a : Γ) : Function.Injective (single a : R → HahnSeries Γ R) :=
fun r s rs => by rw [← coeff_single_same a r, ← coeff_single_same a s, rs]
theorem single_ne_zero (h : r ≠ 0) : single a r ≠ 0 := fun con =>
h (single_injective a (con.trans single_eq_zero.symm))
@[simp]
theorem single_eq_zero_iff {a : Γ} {r : R} : single a r = 0 ↔ r = 0 :=
map_eq_zero_iff _ <| single_injective a
@[simp]
protected lemma map_single [Zero S] (f : ZeroHom R S) : (single a r).map f = single a (f r) := by
ext g
by_cases h : g = a <;> simp [h]
instance [Nonempty Γ] [Nontrivial R] : Nontrivial (HahnSeries Γ R) :=
⟨by
obtain ⟨r, s, rs⟩ := exists_pair_ne R
inhabit Γ
refine ⟨single default r, single default s, fun con => rs ?_⟩
rw [← coeff_single_same (default : Γ) r, con, coeff_single_same]⟩
section Order
variable {x : HahnSeries Γ R}
open Classical in
/-- The orderTop of a Hahn series `x` is a minimal element of `WithTop Γ` where `x` has a nonzero
coefficient if `x ≠ 0`, and is `⊤` when `x = 0`. -/
def orderTop (x : HahnSeries Γ R) : WithTop Γ :=
if h : x = 0 then ⊤ else x.isWF_support.min (support_nonempty_iff.2 h)
@[simp]
theorem orderTop_zero : orderTop (0 : HahnSeries Γ R) = ⊤ :=
dif_pos rfl
@[simp]
theorem orderTop_of_subsingleton [Subsingleton R] : x.orderTop = ⊤ :=
(Subsingleton.eq_zero x) ▸ orderTop_zero
@[deprecated (since := "2025-08-19")] alias orderTop_of_Subsingleton := orderTop_of_subsingleton
theorem orderTop_of_ne_zero (hx : x ≠ 0) :
orderTop x = x.isWF_support.min (support_nonempty_iff.2 hx) :=
dif_neg hx
@[deprecated (since := "2025-08-19")] alias orderTop_of_ne := orderTop_of_ne_zero
@[simp] lemma orderTop_eq_top : orderTop x = ⊤ ↔ x = 0 := by simp [orderTop]
@[simp] lemma orderTop_lt_top : orderTop x < ⊤ ↔ x ≠ 0 := by simp [lt_top_iff_ne_top]
lemma orderTop_ne_top : orderTop x ≠ ⊤ ↔ x ≠ 0 := orderTop_eq_top.not
@[deprecated (since := "2025-08-19")] alias orderTop_eq_top_iff := orderTop_eq_top
@[deprecated orderTop_ne_top (since := "2025-08-19")]
lemma ne_zero_iff_orderTop : x ≠ 0 ↔ orderTop x ≠ ⊤ := orderTop_ne_top.symm
theorem orderTop_eq_of_le {x : HahnSeries Γ R} {g : Γ} (hg : g ∈ x.support)
(hx : ∀ g' ∈ x.support, g ≤ g') : orderTop x = g := by
rw [orderTop_of_ne_zero <| support_nonempty_iff.mp <| Set.nonempty_of_mem hg,
x.isWF_support.min_eq_of_le hg hx]
theorem untop_orderTop_of_ne_zero {x : HahnSeries Γ R} (hx : x ≠ 0) :
WithTop.untop x.orderTop (orderTop_ne_top.2 hx) =
x.isWF_support.min (support_nonempty_iff.2 hx) :=
WithTop.coe_inj.mp ((WithTop.coe_untop (orderTop x) (orderTop_ne_top.2 hx)).trans
(orderTop_of_ne_zero hx))
theorem coeff_orderTop_ne {x : HahnSeries Γ R} {g : Γ} (hg : x.orderTop = g) :
x.coeff g ≠ 0 := by
have h : orderTop x ≠ ⊤ := by simp_all only [ne_eq, WithTop.coe_ne_top, not_false_eq_true]
have hx : x ≠ 0 := orderTop_ne_top.1 h
rw [orderTop_of_ne_zero hx, WithTop.coe_eq_coe] at hg
rw [← hg]
exact x.isWF_support.min_mem (support_nonempty_iff.2 hx)
theorem orderTop_le_of_coeff_ne_zero {Γ} [LinearOrder Γ] {x : HahnSeries Γ R}
{g : Γ} (h : x.coeff g ≠ 0) : x.orderTop ≤ g := by
rw [orderTop_of_ne_zero (ne_zero_of_coeff_ne_zero h), WithTop.coe_le_coe]
exact Set.IsWF.min_le _ _ ((mem_support _ _).2 h)
@[simp]
theorem orderTop_single (h : r ≠ 0) : (single a r).orderTop = a :=
(orderTop_of_ne_zero (single_ne_zero h)).trans
(WithTop.coe_inj.mpr (support_single_subset
((single a r).isWF_support.min_mem (support_nonempty_iff.2 (single_ne_zero h)))))
theorem orderTop_single_le : a ≤ (single a r).orderTop := by
by_cases hr : r = 0
· simp only [hr, map_zero, orderTop_zero, le_top]
· rw [orderTop_single hr]
theorem lt_orderTop_single {g g' : Γ} (hgg' : g < g') : g < (single g' r).orderTop :=
lt_of_lt_of_le (WithTop.coe_lt_coe.mpr hgg') orderTop_single_le
theorem coeff_eq_zero_of_lt_orderTop {x : HahnSeries Γ R} {i : Γ} (hi : i < x.orderTop) :
x.coeff i = 0 := by
rcases eq_or_ne x 0 with (rfl | hx)
· exact coeff_zero
contrapose! hi
rw [← mem_support] at hi
rw [orderTop_of_ne_zero hx, WithTop.coe_lt_coe]
exact Set.IsWF.not_lt_min _ _ hi
open Classical in
/-- A leading coefficient of a Hahn series is the coefficient of a lowest-order nonzero term, or
zero if the series vanishes. -/
def leadingCoeff (x : HahnSeries Γ R) : R := x.orderTop.recTopCoe 0 x.coeff
@[simp]
theorem leadingCoeff_zero : leadingCoeff (0 : HahnSeries Γ R) = 0 := by simp [leadingCoeff]
theorem leadingCoeff_of_ne_zero {x : HahnSeries Γ R} (hx : x ≠ 0) :
x.leadingCoeff = x.coeff (x.orderTop.untop <| orderTop_ne_top.2 hx) := by
simp [leadingCoeff, orderTop, hx]
@[deprecated (since := "2025-08-19")] alias leadingCoeff_of_ne := leadingCoeff_of_ne_zero
@[simp]
theorem leadingCoeff_eq_zero {x : HahnSeries Γ R} : x.leadingCoeff = 0 ↔ x = 0 := by
obtain rfl | hx := eq_or_ne x 0 <;> simp [leadingCoeff_of_ne_zero, coeff_orderTop_ne, *]
theorem leadingCoeff_ne_zero {x : HahnSeries Γ R} : x.leadingCoeff ≠ 0 ↔ x ≠ 0 :=
leadingCoeff_eq_zero.not
@[deprecated (since := "2025-08-19")] alias leadingCoeff_eq_iff := leadingCoeff_eq_zero
@[deprecated (since := "2025-08-19")] alias leadingCoeff_ne_iff := leadingCoeff_ne_zero
@[simp]
theorem leadingCoeff_of_single {a : Γ} {r : R} : leadingCoeff (single a r) = r := by
by_cases h : r = 0 <;> simp [leadingCoeff, h]
theorem coeff_untop_eq_leadingCoeff {x : HahnSeries Γ R} (hx) :
x.coeff (x.orderTop.untop hx) = x.leadingCoeff := by
rw [orderTop_ne_top] at hx
rw [leadingCoeff_of_ne_zero hx, (WithTop.untop_eq_iff _).mpr (orderTop_of_ne_zero hx)]
variable [Zero Γ]
open Classical in
/-- The order of a nonzero Hahn series `x` is a minimal element of `Γ` where `x` has a
nonzero coefficient, the order of 0 is 0. -/
def order (x : HahnSeries Γ R) : Γ :=
if h : x = 0 then 0 else x.isWF_support.min (support_nonempty_iff.2 h)
@[simp]
theorem order_zero : order (0 : HahnSeries Γ R) = 0 :=
dif_pos rfl
theorem order_of_ne {x : HahnSeries Γ R} (hx : x ≠ 0) :
order x = x.isWF_support.min (support_nonempty_iff.2 hx) :=
dif_neg hx
theorem order_eq_orderTop_of_ne_zero (hx : x ≠ 0) : order x = orderTop x := by
rw [order_of_ne hx, orderTop_of_ne_zero hx]
@[deprecated (since := "2025-08-19")] alias order_eq_orderTop_of_ne := order_eq_orderTop_of_ne_zero
theorem coeff_order_ne_zero {x : HahnSeries Γ R} (hx : x ≠ 0) : x.coeff x.order ≠ 0 := by
rw [order_of_ne hx]
exact x.isWF_support.min_mem (support_nonempty_iff.2 hx)
theorem order_le_of_coeff_ne_zero {Γ} [Zero Γ] [LinearOrder Γ] {x : HahnSeries Γ R}
{g : Γ} (h : x.coeff g ≠ 0) : x.order ≤ g :=
le_trans (le_of_eq (order_of_ne (ne_zero_of_coeff_ne_zero h)))
(Set.IsWF.min_le _ _ ((mem_support _ _).2 h))
@[simp]
theorem order_single (h : r ≠ 0) : (single a r).order = a :=
(order_of_ne (single_ne_zero h)).trans
(support_single_subset
((single a r).isWF_support.min_mem (support_nonempty_iff.2 (single_ne_zero h))))
theorem coeff_eq_zero_of_lt_order {x : HahnSeries Γ R} {i : Γ} (hi : i < x.order) :
x.coeff i = 0 := by
rcases eq_or_ne x 0 with (rfl | hx)
· simp
contrapose! hi
rw [← mem_support] at hi
rw [order_of_ne hx]
exact Set.IsWF.not_lt_min _ _ hi
theorem zero_lt_orderTop_iff {x : HahnSeries Γ R} (hx : x ≠ 0) :
0 < x.orderTop ↔ 0 < x.order := by
simp_all [orderTop_of_ne_zero hx, order_of_ne hx]
theorem zero_lt_orderTop_of_order {x : HahnSeries Γ R} (hx : 0 < x.order) : 0 < x.orderTop := by
by_cases h : x = 0
· simp_all only [order_zero, lt_self_iff_false]
· exact (zero_lt_orderTop_iff h).mpr hx
theorem zero_le_orderTop_iff {x : HahnSeries Γ R} : 0 ≤ x.orderTop ↔ 0 ≤ x.order := by
by_cases h : x = 0
· simp_all
· simp_all [order_of_ne h, orderTop_of_ne_zero h]
theorem leadingCoeff_eq {x : HahnSeries Γ R} : x.leadingCoeff = x.coeff x.order := by
by_cases h : x = 0
· rw [h, leadingCoeff_zero, coeff_zero]
· simp [leadingCoeff_of_ne_zero, orderTop_of_ne_zero, order_of_ne, h]
end Order
section Finsupp
/-- Create a `HahnSeries` with a `Finsupp` as coefficients. -/
def ofFinsupp : ZeroHom (Γ →₀ R) (HahnSeries Γ R) where
toFun f := { coeff := f, isPWO_support' := f.finite_support.isPWO }
map_zero' := by simp
@[simp]
theorem coeff_ofFinsupp (f : Γ →₀ R) (a : Γ) : (ofFinsupp f).coeff a = f a := rfl
end Finsupp
section Domain
variable [PartialOrder Γ']
open Classical in
/-- Extends the domain of a `HahnSeries` by an `OrderEmbedding`. -/
def embDomain (f : Γ ↪o Γ') : HahnSeries Γ R → HahnSeries Γ' R := fun x =>
{ coeff := fun b : Γ' => if h : b ∈ f '' x.support then x.coeff (Classical.choose h) else 0
isPWO_support' :=
(x.isPWO_support.image_of_monotone f.monotone).mono fun b hb => by
contrapose! hb
rw [Function.mem_support, dif_neg hb, Classical.not_not] }
@[simp]
theorem embDomain_coeff {f : Γ ↪o Γ'} {x : HahnSeries Γ R} {a : Γ} :
(embDomain f x).coeff (f a) = x.coeff a := by
rw [embDomain]
dsimp only
by_cases ha : a ∈ x.support
· rw [dif_pos (Set.mem_image_of_mem f ha)]
exact congr rfl (f.injective (Classical.choose_spec (Set.mem_image_of_mem f ha)).2)
· rw [dif_neg, Classical.not_not.1 fun c => ha ((mem_support _ _).2 c)]
contrapose! ha
obtain ⟨b, hb1, hb2⟩ := (Set.mem_image _ _ _).1 ha
rwa [f.injective hb2] at hb1
@[simp]
theorem embDomain_mk_coeff {f : Γ → Γ'} (hfi : Function.Injective f)
(hf : ∀ g g' : Γ, f g ≤ f g' ↔ g ≤ g') {x : HahnSeries Γ R} {a : Γ} :
(embDomain ⟨⟨f, hfi⟩, hf _ _⟩ x).coeff (f a) = x.coeff a :=
embDomain_coeff
theorem embDomain_notin_image_support {f : Γ ↪o Γ'} {x : HahnSeries Γ R} {b : Γ'}
(hb : b ∉ f '' x.support) : (embDomain f x).coeff b = 0 :=
dif_neg hb
theorem support_embDomain_subset {f : Γ ↪o Γ'} {x : HahnSeries Γ R} :
support (embDomain f x) ⊆ f '' x.support := by
intro g hg
contrapose! hg
rw [mem_support, embDomain_notin_image_support hg, Classical.not_not]
theorem embDomain_notin_range {f : Γ ↪o Γ'} {x : HahnSeries Γ R} {b : Γ'} (hb : b ∉ Set.range f) :
(embDomain f x).coeff b = 0 :=
embDomain_notin_image_support fun con => hb (Set.image_subset_range _ _ con)
@[simp]
theorem embDomain_zero {f : Γ ↪o Γ'} : embDomain f (0 : HahnSeries Γ R) = 0 := by
ext
simp [embDomain_notin_image_support]
@[simp]
theorem embDomain_single {f : Γ ↪o Γ'} {g : Γ} {r : R} :
embDomain f (single g r) = single (f g) r := by
ext g'
by_cases h : g' = f g
· simp [h]
rw [embDomain_notin_image_support, coeff_single_of_ne h]
by_cases hr : r = 0
· simp [hr]
rwa [support_single_of_ne hr, Set.image_singleton, Set.mem_singleton_iff]
theorem embDomain_injective {f : Γ ↪o Γ'} :
Function.Injective (embDomain f : HahnSeries Γ R → HahnSeries Γ' R) := fun x y xy => by
ext g
rw [HahnSeries.ext_iff, funext_iff] at xy
have xyg := xy (f g)
rwa [embDomain_coeff, embDomain_coeff] at xyg
@[simp]
theorem orderTop_embDomain {Γ : Type*} [LinearOrder Γ] {f : Γ ↪o Γ'} {x : HahnSeries Γ R} :
(embDomain f x).orderTop = WithTop.map f x.orderTop := by
obtain rfl | hx := eq_or_ne x 0
· simp
rw [← WithTop.coe_untop x.orderTop (by simpa using hx), WithTop.map_coe]
apply orderTop_eq_of_le
· simpa using coeff_orderTop_ne (by simp)
intro y hy
obtain ⟨z, hz, rfl⟩ :=
(Set.mem_image _ _ _).mp <| Set.mem_of_subset_of_mem support_embDomain_subset hy
rw [OrderEmbedding.le_iff_le, WithTop.untop_le_iff]
apply orderTop_le_of_coeff_ne_zero
simpa using hz
end Domain
end Zero
section LocallyFiniteLinearOrder
variable [Zero R] [LinearOrder Γ]
theorem forallLTEqZero_supp_BddBelow (f : Γ → R) (n : Γ) (hn : ∀ (m : Γ), m < n → f m = 0) :
BddBelow (Function.support f) := by
simp only [BddBelow, Set.Nonempty, lowerBounds]
use n
intro m hm
rw [Function.mem_support, ne_eq] at hm
exact not_lt.mp (mt (hn m) hm)
theorem BddBelow_zero [Nonempty Γ] : BddBelow (Function.support (0 : Γ → R)) := by
simp only [Function.support_zero, bddBelow_empty]
variable [LocallyFiniteOrder Γ]
theorem suppBddBelow_supp_PWO (f : Γ → R) (hf : BddBelow (Function.support f)) :
(Function.support f).IsPWO :=
hf.isWF.isPWO
/-- Construct a Hahn series from any function whose support is bounded below. -/
@[simps]
def ofSuppBddBelow (f : Γ → R) (hf : BddBelow (Function.support f)) : HahnSeries Γ R where
coeff := f
isPWO_support' := suppBddBelow_supp_PWO f hf
@[simp]
theorem zero_ofSuppBddBelow [Nonempty Γ] : ofSuppBddBelow 0 BddBelow_zero = (0 : HahnSeries Γ R) :=
rfl
theorem order_ofForallLtEqZero [Zero Γ] (f : Γ → R) (hf : f ≠ 0) (n : Γ)
(hn : ∀ (m : Γ), m < n → f m = 0) :
n ≤ order (ofSuppBddBelow f (forallLTEqZero_supp_BddBelow f n hn)) := by
dsimp only [order]
by_cases h : ofSuppBddBelow f (forallLTEqZero_supp_BddBelow f n hn) = 0
cases h
· exact (hf rfl).elim
simp_all only [dite_false]
rw [Set.IsWF.le_min_iff]
intro m hm
rw [HahnSeries.support, Function.mem_support, ne_eq] at hm
exact not_lt.mp (mt (hn m) hm)
end LocallyFiniteLinearOrder
section Truncate
variable [Zero R]
/-- Zeroes out coefficients of a `HahnSeries` at indices not less than `c`. -/
def truncLT [PartialOrder Γ] [DecidableLT Γ] (c : Γ) :
ZeroHom (HahnSeries Γ R) (HahnSeries Γ R) where
toFun x :=
{ coeff i := if i < c then x.coeff i else 0
isPWO_support' := Set.IsPWO.mono x.isPWO_support (by simp) }
map_zero' := by ext; simp
@[simp]
protected theorem coeff_truncLT [PartialOrder Γ] [DecidableLT Γ]
(c : Γ) (x : HahnSeries Γ R) (i : Γ) :
(truncLT c x).coeff i = if i < c then x.coeff i else 0 := rfl
theorem coeff_truncLT_of_lt [PartialOrder Γ] [DecidableLT Γ]
{c i : Γ} (h : i < c) (x : HahnSeries Γ R) : (truncLT c x).coeff i = x.coeff i := by
simp [h]
theorem coeff_truncLT_of_le [LinearOrder Γ]
{c i : Γ} (h : c ≤ i) (x : HahnSeries Γ R) :
(truncLT c x).coeff i = 0 := by
simp [h]
end Truncate
end HahnSeries |
.lake/packages/mathlib/Mathlib/RingTheory/HahnSeries/HEval.lean | import Mathlib.RingTheory.HahnSeries.Summable
import Mathlib.RingTheory.PowerSeries.Basic
/-!
# Evaluation of power series in Hahn Series
We describe a class of ring homomorphisms from formal power series to Hahn series,
given by substitution of the generating variable to an element of strictly positive order.
## Main Definitions
* `HahnSeries.SummableFamily.powerSeriesFamily`: A summable family of Hahn series whose elements
are non-negative powers of a fixed positive-order Hahn series multiplied by the coefficients of a
formal power series.
* `PowerSeries.heval`: The `R`-algebra homomorphism from `PowerSeries σ R` to `HahnSeries Γ R` that
takes `X` to a fixed positive-order Hahn Series and extends to formal infinite sums.
## TODO
* `MvPowerSeries.heval`: An `R`-algebra homomorphism from `MvPowerSeries σ R` to `HahnSeries Γ R`
(for finite σ) taking each `X i` to a positive order Hahn Series.
-/
open Finset Function
noncomputable section
variable {Γ Γ' R V α β σ : Type*}
namespace HahnSeries
namespace SummableFamily
section PowerSeriesFamily
variable [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ] [CommRing R]
variable [CommRing V] [Algebra R V]
/-- A summable family given by scalar multiples of powers of a positive order Hahn series.
The scalar multiples are given by the coefficients of a power series. -/
abbrev powerSeriesFamily (x : HahnSeries Γ V) (f : PowerSeries R) : SummableFamily Γ V ℕ :=
smulFamily (fun n => f.coeff n) (powers x)
theorem powerSeriesFamily_of_not_orderTop_pos {x : HahnSeries Γ V} (hx : ¬ 0 < x.orderTop)
(f : PowerSeries R) :
powerSeriesFamily x f = powerSeriesFamily 0 f := by
ext n g
obtain rfl | hn := eq_or_ne n 0 <;> simp [*]
theorem powerSeriesFamily_of_orderTop_pos {x : HahnSeries Γ V} (hx : 0 < x.orderTop)
(f : PowerSeries R) (n : ℕ) :
powerSeriesFamily x f n = f.coeff n • x ^ n := by
simp [hx]
theorem powerSeriesFamily_hsum_zero (f : PowerSeries R) :
(powerSeriesFamily 0 f).hsum = f.constantCoeff • (1 : HahnSeries Γ V) := by
ext g
by_cases hg : g = 0
· simp only [hg, coeff_hsum]
rw [finsum_eq_single _ 0 (fun n hn ↦ by simp [hn])]
simp
· rw [coeff_hsum, finsum_eq_zero_of_forall_eq_zero
fun n ↦ (by by_cases hn : n = 0 <;> simp [hg, hn])]
simp [hg]
theorem powerSeriesFamily_add {x : HahnSeries Γ V} (f g : PowerSeries R) :
powerSeriesFamily x (f + g) = powerSeriesFamily x f + powerSeriesFamily x g := by
ext1 n
by_cases hx : 0 < x.orderTop <;> · simp [hx, add_smul]
theorem powerSeriesFamily_smul {x : HahnSeries Γ V} (f : PowerSeries R) (r : R) :
powerSeriesFamily x (r • f) = HahnSeries.single (0 : Γ) r • powerSeriesFamily x f := by
ext1 n
simp [mul_smul]
theorem support_powerSeriesFamily_subset {x : HahnSeries Γ V} (a b : PowerSeries R) (g : Γ) :
((powerSeriesFamily x (a * b)).coeff g).support ⊆
(((powerSeriesFamily x a).mul (powerSeriesFamily x b)).coeff g).support.image
fun i => i.1 + i.2 := by
by_cases h : 0 < x.orderTop
· simp only [coeff_support, Set.Finite.toFinset_subset, support_subset_iff]
intro n hn
have he : ∃ c ∈ antidiagonal n, (PowerSeries.coeff c.1) a • (PowerSeries.coeff c.2) b •
((powers x) n).coeff g ≠ 0 := by
refine exists_ne_zero_of_sum_ne_zero ?_
simpa [PowerSeries.coeff_mul, sum_smul, mul_smul, h] using hn
simp only [powers_of_orderTop_pos h, mem_antidiagonal] at he
obtain ⟨c, hcn, hc⟩ := he
simp only [coe_image, Set.Finite.coe_toFinset, Set.mem_image]
use c
simp only [mul_toFun, smulFamily_toFun, Function.mem_support, hcn,
and_true]
rw [powers_of_orderTop_pos h c.1, powers_of_orderTop_pos h c.2, Algebra.smul_mul_assoc,
Algebra.mul_smul_comm, ← pow_add, hcn]
simp [hc]
· simp only [coeff_support, Set.Finite.toFinset_subset, support_subset_iff]
intro n hn
by_cases hz : n = 0
· have : g = 0 ∧ (a.constantCoeff * b.constantCoeff) • (1 : V) ≠ 0 := by
simpa [hz, h] using hn
simp only [coe_image, Set.mem_image]
use (0, 0)
simp [this.2, this.1, h, hz, smul_smul, mul_comm]
· simp [h, hz] at hn
theorem hsum_powerSeriesFamily_mul {x : HahnSeries Γ V} (a b : PowerSeries R) :
(powerSeriesFamily x (a * b)).hsum =
((powerSeriesFamily x a).mul (powerSeriesFamily x b)).hsum := by
by_cases h : 0 < x.orderTop;
· ext g
simp only [coeff_hsum_eq_sum, smulFamily_toFun, h, powers_of_orderTop_pos,
HahnSeries.coeff_smul, mul_toFun, Algebra.mul_smul_comm, Algebra.smul_mul_assoc]
rw [sum_subset (support_powerSeriesFamily_subset a b g)
(fun i hi his ↦ by simpa [h, PowerSeries.coeff_mul, sum_smul] using his)]
simp only [coeff_support, mul_toFun, smulFamily_toFun, Algebra.mul_smul_comm,
Algebra.smul_mul_assoc, HahnSeries.coeff_smul, PowerSeries.coeff_mul, sum_smul]
rw [sum_sigma']
refine (Finset.sum_of_injOn (fun x => ⟨x.1 + x.2, x⟩) (fun _ _ _ _ => by simp) ?_ ?_
(fun _ _ => by simp [smul_smul, mul_comm, pow_add])).symm
· intro ij hij
simp only [coe_sigma, coe_image, Set.mem_sigma_iff, Set.mem_image, Prod.exists, mem_coe,
mem_antidiagonal, and_true]
use ij.1, ij.2
simp_all
· intro i hi his
have hisc : ∀ j k : ℕ, ⟨j + k, (j, k)⟩ = i → (PowerSeries.coeff k) b •
(PowerSeries.coeff j a • (x ^ j * x ^ k).coeff g) = 0 := by
intro m n
contrapose!
simp only [powers_of_orderTop_pos h, Set.Finite.coe_toFinset, Set.mem_image,
Function.mem_support, ne_eq, Prod.exists, not_exists, not_and] at his
exact his m n
simp only [mem_sigma, mem_antidiagonal] at hi
rw [mul_comm ((PowerSeries.coeff i.snd.1) a), ← hi.2, mul_smul, pow_add]
exact hisc i.snd.1 i.snd.2 <| Sigma.eq hi.2 (by simp)
· simp only [h, not_false_eq_true, powerSeriesFamily_of_not_orderTop_pos,
powerSeriesFamily_hsum_zero, map_mul, hsum_mul]
rw [smul_mul_smul_comm, mul_one]
end PowerSeriesFamily
end SummableFamily
end HahnSeries
namespace PowerSeries
open HahnSeries SummableFamily
variable [AddCommMonoid Γ] [LinearOrder Γ] [IsOrderedCancelAddMonoid Γ]
[CommRing R] (x : HahnSeries Γ R)
/-- The `R`-algebra homomorphism from `R[[X]]` to `HahnSeries Γ R` given by sending the power series
variable `X` to a positive order element `x` and extending to infinite sums. -/
@[simps]
def heval : PowerSeries R →ₐ[R] HahnSeries Γ R where
toFun f := (powerSeriesFamily x f).hsum
map_one' := by
simp only [hsum, smulFamily_toFun, coeff_one, powers_toFun, ite_smul, one_smul, zero_smul]
ext g
simp only
rw [finsum_eq_single _ (0 : ℕ) (fun n hn => by simp [hn])]
simp
map_mul' a b := by
simp only [← hsum_mul, hsum_powerSeriesFamily_mul]
map_zero' := by
simp only [hsum, smulFamily_toFun, map_zero, zero_smul,
coeff_zero, finsum_zero, mk_eq_zero, Pi.zero_def]
map_add' a b := by
simp only [powerSeriesFamily_add, hsum_add]
commutes' r := by
simp only [algebraMap_eq]
ext g
simp only [coeff_hsum, smulFamily_toFun, coeff_C, powers_toFun, ite_smul, zero_smul]
rw [finsum_eq_single _ 0 fun n hn => by simp [hn]]
by_cases hg : g = 0 <;> simp [hg, Algebra.algebraMap_eq_smul_one]
theorem heval_mul {a b : PowerSeries R} :
heval x (a * b) = heval x a * heval x b :=
map_mul (heval x) a b
theorem heval_C (r : R) : heval x (C r) = r • 1 := by
ext g
simp only [heval_apply, coeff_hsum, smulFamily_toFun, powers_toFun, HahnSeries.coeff_smul,
HahnSeries.coeff_one, smul_eq_mul, mul_ite, mul_one, mul_zero]
rw [finsum_eq_single _ 0 (fun n hn ↦ by simp [coeff_ne_zero_C hn])]
by_cases hg : g = 0 <;> simp
theorem heval_X (hx : 0 < x.orderTop) : heval x X = x := by
rw [X_eq, monomial_eq_mk, heval_apply, powerSeriesFamily, smulFamily]
simp only [coeff_mk, powers_toFun, hx, ↓reduceIte, ite_smul, one_smul, zero_smul]
ext g
rw [coeff_hsum, finsum_eq_single _ 1 (fun n hn ↦ by simp [hn])]
simp
theorem heval_unit (u : (PowerSeries R)ˣ) : IsUnit (heval x u) := by
refine isUnit_iff_exists_inv.mpr ?_
use heval x u.inv
rw [← heval_mul, Units.val_inv, map_one]
theorem coeff_heval (f : PowerSeries R) (g : Γ) :
(heval x f).coeff g = ∑ᶠ n, ((powerSeriesFamily x f).coeff g) n := by
rw [heval_apply, coeff_hsum]
exact rfl
theorem coeff_heval_zero (f : PowerSeries R) :
(heval x f).coeff 0 = PowerSeries.constantCoeff f := by
rw [coeff_heval, finsum_eq_single (fun n => ((powerSeriesFamily x f).coeff 0) n) 0,
← PowerSeries.coeff_zero_eq_constantCoeff_apply]
· simp
· intro n hn
simp only [coeff_toFun, smulFamily_toFun, HahnSeries.coeff_smul, smul_eq_mul]
refine mul_eq_zero_of_right (coeff n f) (coeff_eq_zero_of_lt_orderTop ?_)
by_cases h : 0 < x.orderTop
· refine (lt_of_lt_of_le ((nsmul_pos_iff hn).mpr h) ?_)
simp [h, orderTop_nsmul_le_orderTop_pow]
· simp [h, hn]
end PowerSeries |
.lake/packages/mathlib/Mathlib/MeasureTheory/Topology.lean | import Mathlib.MeasureTheory.Measure.Typeclasses.NoAtoms
import Mathlib.Topology.DiscreteSubset
/-!
# Theorems combining measure theory and topology
This file gathers theorems that combine measure theory and topology, and cannot easily be added to
the existing files without introducing massive dependencies between the subjects.
-/
open Filter MeasureTheory
/-- Under reasonable assumptions, sets that are codiscrete within `U` are contained in the “almost
everywhere” filter of co-null sets. -/
theorem ae_restrict_le_codiscreteWithin
{α : Type*} [MeasurableSpace α] [TopologicalSpace α] [SecondCountableTopology α]
{μ : Measure α} [NoAtoms μ] {U : Set α} (hU : MeasurableSet U) :
ae (μ.restrict U) ≤ codiscreteWithin U := by
intro s hs
have := discreteTopology_of_codiscreteWithin hs
rw [mem_ae_iff, Measure.restrict_apply' hU]
apply Set.Countable.measure_zero (TopologicalSpace.separableSpace_iff_countable.1 inferInstance) |
.lake/packages/mathlib/Mathlib/MeasureTheory/SetAlgebra.lean | import Mathlib.Data.Finite.Prod
import Mathlib.MeasureTheory.SetSemiring
/-!
# Algebra of sets
In this file we define the notion of algebra of sets and give its basic properties. An algebra
of sets is a family of sets containing the empty set and closed by complement and binary union.
It is therefore similar to a `σ`-algebra, except that it is not necessarily closed
by countable unions.
We also define the algebra of sets generated by a family of sets and give its basic properties,
and we prove that it is countable when it is generated by a countable family. We prove that
the `σ`-algebra generated by a family of sets `𝒜` is the same as the one generated by the algebra
of sets generated by `𝒜`.
## Main definitions
* `MeasureTheory.IsSetAlgebra`: property of being an algebra of sets.
* `MeasureTheory.generateSetAlgebra`: the algebra of sets generated by a family of sets.
## Main statements
* `MeasureTheory.mem_generateSetAlgebra_elim`: If a set `s` belongs to the algebra of sets
generated by `𝒜`, then it can be written as a finite union of finite intersections of sets which
are in `𝒜` or have their complement in `𝒜`.
* `MeasureTheory.countable_generateSetAlgebra`: If a family of sets is countable then so is
the algebra of sets generated by it.
## References
* <https://en.wikipedia.org/wiki/Field_of_sets>
## Tags
algebra of sets, generated algebra of sets
-/
open MeasurableSpace Set
namespace MeasureTheory
variable {α : Type*} {𝒜 : Set (Set α)} {s t : Set α}
/-! ### Definition and basic properties of an algebra of sets -/
/-- An algebra of sets is a family of sets containing the empty set and closed by complement and
union. Consequently it is also closed by difference (see `IsSetAlgebra.diff_mem`) and intersection
(see `IsSetAlgebra.inter_mem`). -/
structure IsSetAlgebra (𝒜 : Set (Set α)) : Prop where
empty_mem : ∅ ∈ 𝒜
compl_mem : ∀ ⦃s⦄, s ∈ 𝒜 → sᶜ ∈ 𝒜
union_mem : ∀ ⦃s t⦄, s ∈ 𝒜 → t ∈ 𝒜 → s ∪ t ∈ 𝒜
namespace IsSetAlgebra
/-- An algebra of sets contains the whole set. -/
theorem univ_mem (h𝒜 : IsSetAlgebra 𝒜) : univ ∈ 𝒜 :=
compl_empty ▸ h𝒜.compl_mem h𝒜.empty_mem
/-- An algebra of sets is closed by intersection. -/
theorem inter_mem (h𝒜 : IsSetAlgebra 𝒜) (s_mem : s ∈ 𝒜) (t_mem : t ∈ 𝒜) :
s ∩ t ∈ 𝒜 :=
inter_eq_compl_compl_union_compl .. ▸
h𝒜.compl_mem (h𝒜.union_mem (h𝒜.compl_mem s_mem) (h𝒜.compl_mem t_mem))
/-- An algebra of sets is closed by difference. -/
theorem diff_mem (h𝒜 : IsSetAlgebra 𝒜) (s_mem : s ∈ 𝒜) (t_mem : t ∈ 𝒜) :
s \ t ∈ 𝒜 := h𝒜.inter_mem s_mem (h𝒜.compl_mem t_mem)
/-- An algebra of sets is a ring of sets. -/
theorem isSetRing (h𝒜 : IsSetAlgebra 𝒜) : IsSetRing 𝒜 where
empty_mem := h𝒜.empty_mem
union_mem := h𝒜.union_mem
diff_mem := fun _ _ ↦ h𝒜.diff_mem
/-- An algebra of sets is closed by finite unions. -/
theorem biUnion_mem {ι : Type*} (h𝒜 : IsSetAlgebra 𝒜) {s : ι → Set α} (S : Finset ι)
(hs : ∀ i ∈ S, s i ∈ 𝒜) : ⋃ i ∈ S, s i ∈ 𝒜 := h𝒜.isSetRing.biUnion_mem S hs
/-- An algebra of sets is closed by finite intersections. -/
theorem biInter_mem {ι : Type*} (h𝒜 : IsSetAlgebra 𝒜) {s : ι → Set α} (S : Finset ι)
(hs : ∀ i ∈ S, s i ∈ 𝒜) : ⋂ i ∈ S, s i ∈ 𝒜 := by
by_cases h : S = ∅
· rw [h, ← Finset.set_biInter_coe, Finset.coe_empty, biInter_empty]
exact h𝒜.univ_mem
· rw [← ne_eq, ← Finset.nonempty_iff_ne_empty] at h
exact h𝒜.isSetRing.biInter_mem S h hs
end IsSetAlgebra
section generateSetAlgebra
/-! ### Definition and properties of the algebra of sets generated by some family -/
/-- `generateSetAlgebra 𝒜` is the smallest algebra of sets containing `𝒜`. -/
inductive generateSetAlgebra {α : Type*} (𝒜 : Set (Set α)) : Set (Set α)
| base (s : Set α) (s_mem : s ∈ 𝒜) : generateSetAlgebra 𝒜 s
| empty : generateSetAlgebra 𝒜 ∅
| compl (s : Set α) (hs : generateSetAlgebra 𝒜 s) : generateSetAlgebra 𝒜 sᶜ
| union (s t : Set α) (hs : generateSetAlgebra 𝒜 s) (ht : generateSetAlgebra 𝒜 t) :
generateSetAlgebra 𝒜 (s ∪ t)
/-- The algebra of sets generated by a family of sets is an algebra of sets. -/
theorem isSetAlgebra_generateSetAlgebra :
IsSetAlgebra (generateSetAlgebra 𝒜) where
empty_mem := generateSetAlgebra.empty
compl_mem := fun _ hs ↦ generateSetAlgebra.compl _ hs
union_mem := fun _ _ hs ht ↦ generateSetAlgebra.union _ _ hs ht
/-- The algebra of sets generated by `𝒜` contains `𝒜`. -/
theorem self_subset_generateSetAlgebra : 𝒜 ⊆ generateSetAlgebra 𝒜 :=
fun _ ↦ generateSetAlgebra.base _
/-- The measurable space generated by a family of sets `𝒜` is the same as the one generated
by the algebra of sets generated by `𝒜`. -/
@[simp]
theorem generateFrom_generateSetAlgebra_eq :
generateFrom (generateSetAlgebra 𝒜) = generateFrom 𝒜 := by
refine le_antisymm (fun s ms ↦ ?_) (generateFrom_mono self_subset_generateSetAlgebra)
induction s, ms using generateFrom_induction with
| hC t ht h =>
clear h
induction ht with
| base u u_mem => exact measurableSet_generateFrom u_mem
| empty => exact @MeasurableSet.empty _ (generateFrom 𝒜)
| compl u _ mu => exact mu.compl
| union u v _ _ mu mv => exact MeasurableSet.union mu mv
| empty => exact MeasurableSpace.measurableSet_empty _
| compl t _ ht => exact ht.compl
| iUnion t _ ht => exact .iUnion ht
/-- If a family of sets `𝒜` is contained in `ℬ`, then the algebra of sets generated by `𝒜`
is contained in the one generated by `ℬ`. -/
theorem generateSetAlgebra_mono {ℬ : Set (Set α)} (h : 𝒜 ⊆ ℬ) :
generateSetAlgebra 𝒜 ⊆ generateSetAlgebra ℬ := by
intro s hs
induction hs with
| base t t_mem => exact self_subset_generateSetAlgebra (h t_mem)
| empty => exact isSetAlgebra_generateSetAlgebra.empty_mem
| compl t _ t_mem => exact isSetAlgebra_generateSetAlgebra.compl_mem t_mem
| union t u _ _ t_mem u_mem => exact isSetAlgebra_generateSetAlgebra.union_mem t_mem u_mem
namespace IsSetAlgebra
/-- If a family of sets `𝒜` is contained in an algebra of sets `ℬ`, then so is the algebra of sets
generated by `𝒜`. -/
theorem generateSetAlgebra_subset {ℬ : Set (Set α)} (h : 𝒜 ⊆ ℬ)
(hℬ : IsSetAlgebra ℬ) : generateSetAlgebra 𝒜 ⊆ ℬ := by
intro s hs
induction hs with
| base t t_mem => exact h t_mem
| empty => exact hℬ.empty_mem
| compl t _ t_mem => exact hℬ.compl_mem t_mem
| union t u _ _ t_mem u_mem => exact hℬ.union_mem t_mem u_mem
/-- If `𝒜` is an algebra of sets, then it contains the algebra generated by itself. -/
theorem generateSetAlgebra_subset_self (h𝒜 : IsSetAlgebra 𝒜) :
generateSetAlgebra 𝒜 ⊆ 𝒜 := h𝒜.generateSetAlgebra_subset subset_rfl
/-- If `𝒜` is an algebra of sets, then it is equal to the algebra generated by itself. -/
theorem generateSetAlgebra_eq (h𝒜 : IsSetAlgebra 𝒜) : generateSetAlgebra 𝒜 = 𝒜 :=
Subset.antisymm h𝒜.generateSetAlgebra_subset_self self_subset_generateSetAlgebra
end IsSetAlgebra
/-- If a set belongs to the algebra of sets generated by `𝒜` then it can be written as a finite
union of finite intersections of sets which are in `𝒜` or have their complement in `𝒜`. -/
theorem mem_generateSetAlgebra_elim (s_mem : s ∈ generateSetAlgebra 𝒜) :
∃ A : Set (Set (Set α)), A.Finite ∧ (∀ a ∈ A, a.Finite) ∧
(∀ᵉ (a ∈ A) (t ∈ a), t ∈ 𝒜 ∨ tᶜ ∈ 𝒜) ∧ s = ⋃ a ∈ A, ⋂ t ∈ a, t := by
induction s_mem with
| base u u_mem =>
refine ⟨{{u}}, finite_singleton {u},
fun a ha ↦ eq_of_mem_singleton ha ▸ finite_singleton u,
fun a ha t ht ↦ ?_, by simp⟩
rw [eq_of_mem_singleton ha, ha, eq_of_mem_singleton ht, ht] at *
exact Or.inl u_mem
| empty => exact ⟨∅, finite_empty, fun _ h ↦ (notMem_empty _ h).elim,
fun _ ha _ _ ↦ (notMem_empty _ ha).elim, by simp⟩
| compl u _ u_ind =>
rcases u_ind with ⟨A, A_fin, mem_A, hA, u_eq⟩
have := finite_coe_iff.2 A_fin
have := fun a : A ↦ finite_coe_iff.2 <| mem_A a.1 a.2
refine ⟨{{(f a).1ᶜ | a : A} | f : (Π a : A, ↑a)}, finite_coe_iff.1 inferInstance,
fun a ⟨f, hf⟩ ↦ hf ▸ finite_coe_iff.1 inferInstance, fun a ha t ht ↦ ?_, ?_⟩
· rcases ha with ⟨f, rfl⟩
rcases ht with ⟨a, rfl⟩
rw [compl_compl, or_comm]
exact hA a.1 a.2 (f a).1 (f a).2
· ext x
simp only [u_eq, compl_iUnion, compl_iInter, mem_iInter, mem_iUnion, mem_compl_iff,
exists_prop, Subtype.exists, mem_setOf_eq, iUnion_exists, iUnion_iUnion_eq',
iInter_exists]
constructor <;> intro hx
· choose f hf using hx
exact ⟨fun ⟨a, ha⟩ ↦ ⟨f a ha, (hf a ha).1⟩, fun _ a ha h ↦ by rw [← h]; exact (hf a ha).2⟩
· rcases hx with ⟨f, hf⟩
exact fun a ha ↦ ⟨f ⟨a, ha⟩, (f ⟨a, ha⟩).2, hf (f ⟨a, ha⟩)ᶜ a ha rfl⟩
| union u v _ _ u_ind v_ind =>
rcases u_ind with ⟨Au, Au_fin, mem_Au, hAu, u_eq⟩
rcases v_ind with ⟨Av, Av_fin, mem_Av, hAv, v_eq⟩
refine ⟨Au ∪ Av, Au_fin.union Av_fin, ?_, ?_, by rw [u_eq, v_eq, ← biUnion_union]⟩
· rintro a (ha | ha)
· exact mem_Au a ha
· exact mem_Av a ha
· rintro a (ha | ha) t ht
· exact hAu a ha t ht
· exact hAv a ha t ht
/-- If a family of sets is countable then so is the algebra of sets generated by it. -/
theorem countable_generateSetAlgebra (h : 𝒜.Countable) :
(generateSetAlgebra 𝒜).Countable := by
let ℬ := {s | s ∈ 𝒜} ∪ {s | sᶜ ∈ 𝒜}
have count_ℬ : ℬ.Countable := by
apply h.union
have : compl '' 𝒜 = {s | sᶜ ∈ 𝒜} := by
ext s
simpa using ⟨fun ⟨x, x_mem, hx⟩ ↦ by simp [← hx, x_mem], fun hs ↦ ⟨sᶜ, hs, by simp⟩⟩
exact this ▸ h.image compl
let f : Set (Set (Set α)) → Set α := fun A ↦ ⋃ a ∈ A, ⋂ t ∈ a, t
let 𝒞 := {a | a.Finite ∧ a ⊆ ℬ}
have count_𝒞 : 𝒞.Countable := countable_setOf_finite_subset (countable_coe_iff.1 count_ℬ)
let 𝒟 := {A | A.Finite ∧ A ⊆ 𝒞}
have count_𝒟 : 𝒟.Countable := countable_setOf_finite_subset (countable_coe_iff.1 count_𝒞)
have : generateSetAlgebra 𝒜 ⊆ f '' 𝒟 := by
intro s s_mem
rcases mem_generateSetAlgebra_elim s_mem with ⟨A, A_fin, mem_A, hA, rfl⟩
exact ⟨A, ⟨A_fin, fun a ha ↦ ⟨mem_A a ha, hA a ha⟩⟩, rfl⟩
exact (count_𝒟.image f).mono this
end generateSetAlgebra
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/PiSystem.lean | import Mathlib.Logic.Encodable.Lattice
import Mathlib.MeasureTheory.MeasurableSpace.Defs
import Mathlib.Order.Disjointed
/-!
# Induction principles for measurable sets, related to π-systems and λ-systems.
## Main statements
* The main theorem of this file is Dynkin's π-λ theorem, which appears
here as an induction principle `induction_on_inter`. Suppose `s` is a
collection of subsets of `α` such that the intersection of two members
of `s` belongs to `s` whenever it is nonempty. Let `m` be the σ-algebra
generated by `s`. In order to check that a predicate `C` holds on every
member of `m`, it suffices to check that `C` holds on the members of `s` and
that `C` is preserved by complementation and *disjoint* countable
unions.
* The proof of this theorem relies on the notion of `IsPiSystem`, i.e., a collection of sets
which is closed under binary non-empty intersections. Note that this is a small variation around
the usual notion in the literature, which often requires that a π-system is non-empty, and closed
also under disjoint intersections. This variation turns out to be convenient for the
formalization.
* The proof of Dynkin's π-λ theorem also requires the notion of `DynkinSystem`, i.e., a collection
of sets which contains the empty set, is closed under complementation and under countable union
of pairwise disjoint sets. The disjointness condition is the only difference with `σ`-algebras.
* `generatePiSystem g` gives the minimal π-system containing `g`.
This can be considered a Galois insertion into both measurable spaces and sets.
* `generateFrom_generatePiSystem_eq` proves that if you start from a collection of sets `g`,
take the generated π-system, and then the generated σ-algebra, you get the same result as
the σ-algebra generated from `g`. This is useful because there are connections between
independent sets that are π-systems and the generated independent spaces.
* `mem_generatePiSystem_iUnion_elim` and `mem_generatePiSystem_iUnion_elim'` show that any
element of the π-system generated from the union of a set of π-systems can be
represented as the intersection of a finite number of elements from these sets.
* `piiUnionInter` defines a new π-system from a family of π-systems `π : ι → Set (Set α)` and a
set of indices `S : Set ι`. `piiUnionInter π S` is the set of sets that can be written
as `⋂ x ∈ t, f x` for some finset `t ∈ S` and sets `f x ∈ π x`.
## Implementation details
* `IsPiSystem` is a predicate, not a type. Thus, we don't explicitly define the Galois
insertion, nor do we define a complete lattice. In theory, we could define a complete
lattice and Galois insertion on the subtype corresponding to `IsPiSystem`.
-/
open MeasurableSpace Set
open MeasureTheory
variable {α β : Type*}
/-- A π-system is a collection of subsets of `α` that is closed under binary intersection of
non-disjoint sets. Usually it is also required that the collection is nonempty, but we don't do
that here. -/
def IsPiSystem (C : Set (Set α)) : Prop :=
∀ᵉ (s ∈ C) (t ∈ C), (s ∩ t : Set α).Nonempty → s ∩ t ∈ C
namespace MeasurableSpace
theorem isPiSystem_measurableSet {α : Type*} [MeasurableSpace α] :
IsPiSystem { s : Set α | MeasurableSet s } := fun _ hs _ ht _ => hs.inter ht
end MeasurableSpace
theorem IsPiSystem.singleton (S : Set α) : IsPiSystem ({S} : Set (Set α)) := by
intro s h_s t h_t _
rw [Set.mem_singleton_iff.1 h_s, Set.mem_singleton_iff.1 h_t, Set.inter_self,
Set.mem_singleton_iff]
theorem IsPiSystem.insert_empty {S : Set (Set α)} (h_pi : IsPiSystem S) :
IsPiSystem (insert ∅ S) := by
intro s hs t ht hst
rcases hs with hs | hs
· simp [hs]
· rcases ht with ht | ht
· simp [ht]
· exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
theorem IsPiSystem.insert_univ {S : Set (Set α)} (h_pi : IsPiSystem S) :
IsPiSystem (insert Set.univ S) := by
intro s hs t ht hst
rcases hs with hs | hs
· rcases ht with ht | ht <;> simp [hs, ht]
· rcases ht with ht | ht
· simp [hs, ht]
· exact Set.mem_insert_of_mem _ (h_pi s hs t ht hst)
theorem IsPiSystem.comap {α β} {S : Set (Set β)} (h_pi : IsPiSystem S) (f : α → β) :
IsPiSystem { s : Set α | ∃ t ∈ S, f ⁻¹' t = s } := by
rintro _ ⟨s, hs_mem, rfl⟩ _ ⟨t, ht_mem, rfl⟩ hst
rw [← Set.preimage_inter] at hst ⊢
exact ⟨s ∩ t, h_pi s hs_mem t ht_mem (nonempty_of_nonempty_preimage hst), rfl⟩
theorem isPiSystem_iUnion_of_directed_le {α ι} (p : ι → Set (Set α))
(hp_pi : ∀ n, IsPiSystem (p n)) (hp_directed : Directed (· ≤ ·) p) :
IsPiSystem (⋃ n, p n) := by
intro t1 ht1 t2 ht2 h
rw [Set.mem_iUnion] at ht1 ht2 ⊢
obtain ⟨n, ht1⟩ := ht1
obtain ⟨m, ht2⟩ := ht2
obtain ⟨k, hpnk, hpmk⟩ : ∃ k, p n ≤ p k ∧ p m ≤ p k := hp_directed n m
exact ⟨k, hp_pi k t1 (hpnk ht1) t2 (hpmk ht2) h⟩
theorem isPiSystem_iUnion_of_monotone {α ι} [SemilatticeSup ι] (p : ι → Set (Set α))
(hp_pi : ∀ n, IsPiSystem (p n)) (hp_mono : Monotone p) : IsPiSystem (⋃ n, p n) :=
isPiSystem_iUnion_of_directed_le p hp_pi (Monotone.directed_le hp_mono)
/-- Rectangles formed by π-systems form a π-system. -/
lemma IsPiSystem.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsPiSystem C) (hD : IsPiSystem D) :
IsPiSystem (image2 (· ×ˢ ·) C D) := by
rintro _ ⟨s₁, hs₁, t₁, ht₁, rfl⟩ _ ⟨s₂, hs₂, t₂, ht₂, rfl⟩ hst
rw [prod_inter_prod] at hst ⊢; rw [prod_nonempty_iff] at hst
exact mem_image2_of_mem (hC _ hs₁ _ hs₂ hst.1) (hD _ ht₁ _ ht₂ hst.2)
/-- A nonempty finite intersection of sets in a π-system belongs to the π-system. -/
lemma IsPiSystem.biInter_mem {S : Set (Set α)} (h_pi : IsPiSystem S) {t : Finset (Set α)}
(t_ne : t.Nonempty) (ht : ∀ s ∈ t, s ∈ S) (h' : (⋂ s ∈ t, s).Nonempty) :
(⋂ s ∈ t, s) ∈ S := by
classical
induction t_ne using Finset.Nonempty.cons_induction with
| singleton a => simpa using ht
| cons a t hat t_ne ih =>
simp only [Finset.cons_eq_insert, Finset.mem_insert, iInter_iInter_eq_or_left] at h' ht ⊢
refine h_pi _ (ht a (Or.inl rfl)) _ ?_ h'
refine ih (fun s hs ↦ ?_) h'.right
exact ht s (Or.inr hs)
section Order
variable {ι ι' : Sort*} [LinearOrder α]
theorem isPiSystem_image_Iio (s : Set α) : IsPiSystem (Iio '' s) := by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
exact ⟨a ⊓ b, inf_ind a b ha hb, Iio_inter_Iio.symm⟩
theorem isPiSystem_Iio : IsPiSystem (range Iio : Set (Set α)) :=
@image_univ α _ Iio ▸ isPiSystem_image_Iio univ
theorem isPiSystem_image_Ioi (s : Set α) : IsPiSystem (Ioi '' s) :=
@isPiSystem_image_Iio αᵒᵈ _ s
theorem isPiSystem_Ioi : IsPiSystem (range Ioi : Set (Set α)) :=
@image_univ α _ Ioi ▸ isPiSystem_image_Ioi univ
theorem isPiSystem_image_Iic (s : Set α) : IsPiSystem (Iic '' s) := by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩ -
exact ⟨a ⊓ b, inf_ind a b ha hb, Iic_inter_Iic.symm⟩
theorem isPiSystem_Iic : IsPiSystem (range Iic : Set (Set α)) :=
@image_univ α _ Iic ▸ isPiSystem_image_Iic univ
theorem isPiSystem_image_Ici (s : Set α) : IsPiSystem (Ici '' s) :=
@isPiSystem_image_Iic αᵒᵈ _ s
theorem isPiSystem_Ici : IsPiSystem (range Ici : Set (Set α)) :=
@image_univ α _ Ici ▸ isPiSystem_image_Ici univ
theorem isPiSystem_Ixx_mem {Ixx : α → α → Set α} {p : α → α → Prop}
(Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
(Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (s t : Set α) :
IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), p l u ∧ Ixx l u = S } := by
rintro _ ⟨l₁, hls₁, u₁, hut₁, _, rfl⟩ _ ⟨l₂, hls₂, u₂, hut₂, _, rfl⟩
simp only [Hi]
exact fun H => ⟨l₁ ⊔ l₂, sup_ind l₁ l₂ hls₁ hls₂, u₁ ⊓ u₂, inf_ind u₁ u₂ hut₁ hut₂, Hne H, rfl⟩
theorem isPiSystem_Ixx {Ixx : α → α → Set α} {p : α → α → Prop}
(Hne : ∀ {a b}, (Ixx a b).Nonempty → p a b)
(Hi : ∀ {a₁ b₁ a₂ b₂}, Ixx a₁ b₁ ∩ Ixx a₂ b₂ = Ixx (max a₁ a₂) (min b₁ b₂)) (f : ι → α)
(g : ι' → α) : @IsPiSystem α { S | ∃ i j, p (f i) (g j) ∧ Ixx (f i) (g j) = S } := by
simpa only [exists_range_iff] using isPiSystem_Ixx_mem (@Hne) (@Hi) (range f) (range g)
theorem isPiSystem_Ioo_mem (s t : Set α) :
IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ioo l u = S } :=
isPiSystem_Ixx_mem (Ixx := Ioo) (fun ⟨_, hax, hxb⟩ => hax.trans hxb) Ioo_inter_Ioo s t
theorem isPiSystem_Ioo (f : ι → α) (g : ι' → α) :
@IsPiSystem α { S | ∃ l u, f l < g u ∧ Ioo (f l) (g u) = S } :=
isPiSystem_Ixx (Ixx := Ioo) (fun ⟨_, hax, hxb⟩ => hax.trans hxb) Ioo_inter_Ioo f g
theorem isPiSystem_Ioc_mem (s t : Set α) :
IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ioc l u = S } :=
isPiSystem_Ixx_mem (Ixx := Ioc) (fun ⟨_, hax, hxb⟩ => hax.trans_le hxb) Ioc_inter_Ioc s t
theorem isPiSystem_Ioc (f : ι → α) (g : ι' → α) :
@IsPiSystem α { S | ∃ i j, f i < g j ∧ Ioc (f i) (g j) = S } :=
isPiSystem_Ixx (Ixx := Ioc) (fun ⟨_, hax, hxb⟩ => hax.trans_le hxb) Ioc_inter_Ioc f g
theorem isPiSystem_Ico_mem (s t : Set α) :
IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l < u ∧ Ico l u = S } :=
isPiSystem_Ixx_mem (Ixx := Ico) (fun ⟨_, hax, hxb⟩ => hax.trans_lt hxb) Ico_inter_Ico s t
theorem isPiSystem_Ico (f : ι → α) (g : ι' → α) :
@IsPiSystem α { S | ∃ i j, f i < g j ∧ Ico (f i) (g j) = S } :=
isPiSystem_Ixx (Ixx := Ico) (fun ⟨_, hax, hxb⟩ => hax.trans_lt hxb) Ico_inter_Ico f g
theorem isPiSystem_Icc_mem (s t : Set α) :
IsPiSystem { S | ∃ᵉ (l ∈ s) (u ∈ t), l ≤ u ∧ Icc l u = S } :=
isPiSystem_Ixx_mem (Ixx := Icc) nonempty_Icc.1 (by exact Icc_inter_Icc) s t
theorem isPiSystem_Icc (f : ι → α) (g : ι' → α) :
@IsPiSystem α { S | ∃ i j, f i ≤ g j ∧ Icc (f i) (g j) = S } :=
isPiSystem_Ixx (Ixx := Icc) nonempty_Icc.1 (by exact Icc_inter_Icc) f g
end Order
/-- Given a collection `S` of subsets of `α`, then `generatePiSystem S` is the smallest
π-system containing `S`. -/
inductive generatePiSystem (S : Set (Set α)) : Set (Set α)
| base {s : Set α} (h_s : s ∈ S) : generatePiSystem S s
| inter {s t : Set α} (h_s : generatePiSystem S s) (h_t : generatePiSystem S t)
(h_nonempty : (s ∩ t).Nonempty) : generatePiSystem S (s ∩ t)
theorem isPiSystem_generatePiSystem (S : Set (Set α)) : IsPiSystem (generatePiSystem S) :=
fun _ h_s _ h_t h_nonempty => generatePiSystem.inter h_s h_t h_nonempty
theorem subset_generatePiSystem_self (S : Set (Set α)) : S ⊆ generatePiSystem S := fun _ =>
generatePiSystem.base
theorem generatePiSystem_subset_self {S : Set (Set α)} (h_S : IsPiSystem S) :
generatePiSystem S ⊆ S := fun x h => by
induction h with
| base h_s => exact h_s
| inter _ _ h_nonempty h_s h_u => exact h_S _ h_s _ h_u h_nonempty
theorem generatePiSystem_eq {S : Set (Set α)} (h_pi : IsPiSystem S) : generatePiSystem S = S :=
Set.Subset.antisymm (generatePiSystem_subset_self h_pi) (subset_generatePiSystem_self S)
theorem generatePiSystem_mono {S T : Set (Set α)} (hST : S ⊆ T) :
generatePiSystem S ⊆ generatePiSystem T := fun t ht => by
induction ht with
| base h_s => exact generatePiSystem.base (Set.mem_of_subset_of_mem hST h_s)
| inter _ _ h_nonempty h_s h_u => exact isPiSystem_generatePiSystem T _ h_s _ h_u h_nonempty
theorem generatePiSystem_measurableSet [M : MeasurableSpace α] {S : Set (Set α)}
(h_meas_S : ∀ s ∈ S, MeasurableSet s) (t : Set α) (h_in_pi : t ∈ generatePiSystem S) :
MeasurableSet t := by
induction h_in_pi with
| base h_s => apply h_meas_S _ h_s
| inter _ _ _ h_s h_u => apply MeasurableSet.inter h_s h_u
theorem generateFrom_measurableSet_of_generatePiSystem {g : Set (Set α)} (t : Set α)
(ht : t ∈ generatePiSystem g) : MeasurableSet[generateFrom g] t :=
@generatePiSystem_measurableSet α (generateFrom g) g
(fun _ h_s_in_g => measurableSet_generateFrom h_s_in_g) t ht
theorem generateFrom_generatePiSystem_eq {g : Set (Set α)} :
generateFrom (generatePiSystem g) = generateFrom g := by
apply le_antisymm <;> apply generateFrom_le
· exact fun t h_t => generateFrom_measurableSet_of_generatePiSystem t h_t
· exact fun t h_t => measurableSet_generateFrom (generatePiSystem.base h_t)
/-- Every element of the π-system generated by the union of a family of π-systems
is a finite intersection of elements from the π-systems.
For an indexed union version, see `mem_generatePiSystem_iUnion_elim'`. -/
theorem mem_generatePiSystem_iUnion_elim {α β} {g : β → Set (Set α)} (h_pi : ∀ b, IsPiSystem (g b))
(t : Set α) (h_t : t ∈ generatePiSystem (⋃ b, g b)) :
∃ (T : Finset β) (f : β → Set α), (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
classical
induction h_t with
| @base s h_s =>
rcases h_s with ⟨t', ⟨⟨b, rfl⟩, h_s_in_t'⟩⟩
refine ⟨{b}, fun _ => s, ?_⟩
simpa using h_s_in_t'
| inter h_gen_s h_gen_t' h_nonempty h_s h_t' =>
rcases h_t' with ⟨T_t', ⟨f_t', ⟨rfl, h_t'⟩⟩⟩
rcases h_s with ⟨T_s, ⟨f_s, ⟨rfl, h_s⟩⟩⟩
use T_s ∪ T_t', fun b : β =>
if b ∈ T_s then if b ∈ T_t' then f_s b ∩ f_t' b else f_s b
else if b ∈ T_t' then f_t' b else (∅ : Set α)
constructor
· ext a
simp_rw [Set.mem_inter_iff, Set.mem_iInter, Finset.mem_union]
grind
intro b h_b
split_ifs with hbs hbt hbt
· refine h_pi b (f_s b) (h_s b hbs) (f_t' b) (h_t' b hbt) (Set.Nonempty.mono ?_ h_nonempty)
exact Set.inter_subset_inter (Set.biInter_subset_of_mem hbs) (Set.biInter_subset_of_mem hbt)
· exact h_s b hbs
· exact h_t' b hbt
· rw [Finset.mem_union] at h_b
apply False.elim (h_b.elim hbs hbt)
/-- Every element of the π-system generated by an indexed union of a family of π-systems
is a finite intersection of elements from the π-systems.
For a total union version, see `mem_generatePiSystem_iUnion_elim`. -/
theorem mem_generatePiSystem_iUnion_elim' {α β} {g : β → Set (Set α)} {s : Set β}
(h_pi : ∀ b ∈ s, IsPiSystem (g b)) (t : Set α) (h_t : t ∈ generatePiSystem (⋃ b ∈ s, g b)) :
∃ (T : Finset β) (f : β → Set α), ↑T ⊆ s ∧ (t = ⋂ b ∈ T, f b) ∧ ∀ b ∈ T, f b ∈ g b := by
classical
have : t ∈ generatePiSystem (⋃ b : Subtype s, (g ∘ Subtype.val) b) := by
suffices h1 : ⋃ b : Subtype s, (g ∘ Subtype.val) b = ⋃ b ∈ s, g b by rwa [h1]
ext x
simp only [exists_prop, Set.mem_iUnion, Function.comp_apply, Subtype.exists]
rfl
rcases @mem_generatePiSystem_iUnion_elim α (Subtype s) (g ∘ Subtype.val)
(fun b => h_pi b.val b.property) t this with
⟨T, ⟨f, ⟨rfl, h_t'⟩⟩⟩
refine
⟨T.image (fun x : s => (x : β)),
Function.extend (fun x : s => (x : β)) f fun _ : β => (∅ : Set α), by simp, ?_, ?_⟩
· ext a
constructor <;>
· simp -proj only
[Set.mem_iInter, Subtype.forall, Finset.set_biInter_finset_image]
intro h1 b h_b h_b_in_T
have h2 := h1 b h_b h_b_in_T
revert h2
rw [Subtype.val_injective.extend_apply]
apply id
· intro b h_b
simp_rw [Finset.mem_image, Subtype.exists, exists_and_right, exists_eq_right]
at h_b
obtain ⟨h_b_w, h_b_h⟩ := h_b
have h_b_alt : b = (Subtype.mk b h_b_w).val := rfl
rw [h_b_alt, Subtype.val_injective.extend_apply]
apply h_t'
apply h_b_h
section UnionInter
variable {α ι : Type*}
/-! ### π-system generated by finite intersections of sets of a π-system family -/
/-- From a set of indices `S : Set ι` and a family of sets of sets `π : ι → Set (Set α)`,
define the set of sets that can be written as `⋂ x ∈ t, f x` for some finset `t ⊆ S` and sets
`f x ∈ π x`. If `π` is a family of π-systems, then it is a π-system. -/
def piiUnionInter (π : ι → Set (Set α)) (S : Set ι) : Set (Set α) :=
{ s : Set α |
∃ (t : Finset ι) (_ : ↑t ⊆ S) (f : ι → Set α) (_ : ∀ x, x ∈ t → f x ∈ π x), s = ⋂ x ∈ t, f x }
theorem piiUnionInter_singleton (π : ι → Set (Set α)) (i : ι) :
piiUnionInter π {i} = π i ∪ {univ} := by
ext1 s
simp only [piiUnionInter, exists_prop, mem_union]
refine ⟨?_, fun h => ?_⟩
· rintro ⟨t, hti, f, hfπ, rfl⟩
simp only [subset_singleton_iff, Finset.mem_coe] at hti
by_cases hi : i ∈ t
· have ht_eq_i : t = {i} := by
ext1 x
rw [Finset.mem_singleton]
exact ⟨fun h => hti x h, fun h => h.symm ▸ hi⟩
simp only [ht_eq_i, Finset.mem_singleton, iInter_iInter_eq_left]
exact Or.inl (hfπ i hi)
· have ht_empty : t = ∅ := by
ext1 x
simp only [Finset.notMem_empty, iff_false]
exact fun hx => hi (hti x hx ▸ hx)
simp [ht_empty, iInter_univ, Set.mem_singleton univ]
· rcases h with hs | hs
· refine ⟨{i}, ?_, fun _ => s, ⟨fun x hx => ?_, ?_⟩⟩
· rw [Finset.coe_singleton]
· rw [Finset.mem_singleton] at hx
rwa [hx]
· simp only [Finset.mem_singleton, iInter_iInter_eq_left]
· refine ⟨∅, ?_⟩
simpa only [Finset.coe_empty, subset_singleton_iff, mem_empty_iff_false, IsEmpty.forall_iff,
imp_true_iff, Finset.notMem_empty, iInter_false, iInter_univ, true_and,
exists_const] using hs
theorem piiUnionInter_singleton_left (s : ι → Set α) (S : Set ι) :
piiUnionInter (fun i => ({s i} : Set (Set α))) S =
{ s' : Set α | ∃ (t : Finset ι) (_ : ↑t ⊆ S), s' = ⋂ i ∈ t, s i } := by
ext1 s'
simp_rw [piiUnionInter, Set.mem_singleton_iff, exists_prop, Set.mem_setOf_eq]
refine ⟨fun h => ?_, fun ⟨t, htS, h_eq⟩ => ⟨t, htS, s, fun _ _ => rfl, h_eq⟩⟩
grind
theorem generateFrom_piiUnionInter_singleton_left (s : ι → Set α) (S : Set ι) :
generateFrom (piiUnionInter (fun k => {s k}) S) = generateFrom { t | ∃ k ∈ S, s k = t } := by
refine le_antisymm (generateFrom_le ?_) (generateFrom_mono ?_)
· rintro _ ⟨I, hI, f, hf, rfl⟩
refine Finset.measurableSet_biInter _ fun m hm => measurableSet_generateFrom ?_
exact ⟨m, hI hm, (hf m hm).symm⟩
· rintro _ ⟨k, hk, rfl⟩
refine ⟨{k}, fun m hm => ?_, s, fun i _ => ?_, ?_⟩
· rw [Finset.mem_coe, Finset.mem_singleton] at hm
rwa [hm]
· exact Set.mem_singleton _
· simp only [Finset.mem_singleton, Set.iInter_iInter_eq_left]
/-- If `π` is a family of π-systems, then `piiUnionInter π S` is a π-system. -/
theorem isPiSystem_piiUnionInter (π : ι → Set (Set α)) (hpi : ∀ x, IsPiSystem (π x)) (S : Set ι) :
IsPiSystem (piiUnionInter π S) := by
classical
rintro t1 ⟨p1, hp1S, f1, hf1m, ht1_eq⟩ t2 ⟨p2, hp2S, f2, hf2m, ht2_eq⟩ h_nonempty
simp_rw [piiUnionInter, Set.mem_setOf_eq]
let g n := ite (n ∈ p1) (f1 n) Set.univ ∩ ite (n ∈ p2) (f2 n) Set.univ
have hp_union_ss : ↑(p1 ∪ p2) ⊆ S := by
simp only [hp1S, hp2S, Finset.coe_union, union_subset_iff, and_self_iff]
use p1 ∪ p2, hp_union_ss, g
have h_inter_eq : t1 ∩ t2 = ⋂ i ∈ p1 ∪ p2, g i := by
rw [ht1_eq, ht2_eq]
simp_rw [← Set.inf_eq_inter]
ext1 x
simp only [inf_eq_inter, mem_inter_iff, mem_iInter]
grind
refine ⟨fun n hn => ?_, h_inter_eq⟩
simp only [g]
split_ifs with hn1 hn2 h
· refine hpi n (f1 n) (hf1m n hn1) (f2 n) (hf2m n hn2) (Set.nonempty_iff_ne_empty.2 fun h => ?_)
rw [h_inter_eq] at h_nonempty
suffices h_empty : ⋂ i ∈ p1 ∪ p2, g i = ∅ from
(Set.not_nonempty_iff_eq_empty.mpr h_empty) h_nonempty
refine le_antisymm (Set.iInter_subset_of_subset n ?_) (Set.empty_subset _)
refine Set.iInter_subset_of_subset hn ?_
grind
· simp [hf1m n hn1]
· simp [hf2m n h]
· exact absurd hn (by simp [hn1, h])
theorem piiUnionInter_mono_left {π π' : ι → Set (Set α)} (h_le : ∀ i, π i ⊆ π' i) (S : Set ι) :
piiUnionInter π S ⊆ piiUnionInter π' S := fun _ ⟨t, ht_mem, ft, hft_mem_pi, h_eq⟩ =>
⟨t, ht_mem, ft, fun x hxt => h_le x (hft_mem_pi x hxt), h_eq⟩
theorem piiUnionInter_mono_right {π : ι → Set (Set α)} {S T : Set ι} (hST : S ⊆ T) :
piiUnionInter π S ⊆ piiUnionInter π T := fun _ ⟨t, ht_mem, ft, hft_mem_pi, h_eq⟩ =>
⟨t, ht_mem.trans hST, ft, hft_mem_pi, h_eq⟩
theorem generateFrom_piiUnionInter_le {m : MeasurableSpace α} (π : ι → Set (Set α))
(h : ∀ n, generateFrom (π n) ≤ m) (S : Set ι) : generateFrom (piiUnionInter π S) ≤ m := by
refine generateFrom_le ?_
rintro t ⟨ht_p, _, ft, hft_mem_pi, rfl⟩
refine Finset.measurableSet_biInter _ fun x hx_mem => (h x) _ ?_
exact measurableSet_generateFrom (hft_mem_pi x hx_mem)
theorem subset_piiUnionInter {π : ι → Set (Set α)} {S : Set ι} {i : ι} (his : i ∈ S) :
π i ⊆ piiUnionInter π S := by
have h_ss : {i} ⊆ S := by
intro j hj
rw [mem_singleton_iff] at hj
rwa [hj]
refine Subset.trans ?_ (piiUnionInter_mono_right h_ss)
rw [piiUnionInter_singleton]
exact subset_union_left
theorem mem_piiUnionInter_of_measurableSet (m : ι → MeasurableSpace α) {S : Set ι} {i : ι}
(hiS : i ∈ S) (s : Set α) (hs : MeasurableSet[m i] s) :
s ∈ piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S :=
subset_piiUnionInter hiS hs
theorem le_generateFrom_piiUnionInter {π : ι → Set (Set α)} (S : Set ι) {x : ι} (hxS : x ∈ S) :
generateFrom (π x) ≤ generateFrom (piiUnionInter π S) :=
generateFrom_mono (subset_piiUnionInter hxS)
theorem measurableSet_iSup_of_mem_piiUnionInter (m : ι → MeasurableSpace α) (S : Set ι) (t : Set α)
(ht : t ∈ piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S) :
MeasurableSet[⨆ i ∈ S, m i] t := by
rcases ht with ⟨pt, hpt, ft, ht_m, rfl⟩
refine pt.measurableSet_biInter fun i hi => ?_
suffices h_le : m i ≤ ⨆ i ∈ S, m i from h_le (ft i) (ht_m i hi)
have hi' : i ∈ S := hpt hi
exact le_iSup₂ (f := fun i (_ : i ∈ S) => m i) i hi'
theorem generateFrom_piiUnionInter_measurableSet (m : ι → MeasurableSpace α) (S : Set ι) :
generateFrom (piiUnionInter (fun n => { s | MeasurableSet[m n] s }) S) = ⨆ i ∈ S, m i := by
refine le_antisymm ?_ ?_
· rw [← @generateFrom_measurableSet α (⨆ i ∈ S, m i)]
exact generateFrom_mono (measurableSet_iSup_of_mem_piiUnionInter m S)
· refine iSup₂_le fun i hi => ?_
rw [← @generateFrom_measurableSet α (m i)]
exact generateFrom_mono (mem_piiUnionInter_of_measurableSet m hi)
end UnionInter
namespace MeasurableSpace
open scoped Function -- required for scoped `on` notation
variable {α : Type*}
/-! ## Dynkin systems and Π-λ theorem -/
/-- A Dynkin system is a collection of subsets of a type `α` that contains the empty set,
is closed under complementation and under countable union of pairwise disjoint sets.
The disjointness condition is the only difference with `σ`-algebras.
The main purpose of Dynkin systems is to provide a powerful induction rule for σ-algebras
generated by a collection of sets which is stable under intersection.
A Dynkin system is also known as a "λ-system" or a "d-system".
-/
structure DynkinSystem (α : Type*) where
/-- Predicate saying that a given set is contained in the Dynkin system. -/
Has : Set α → Prop
/-- A Dynkin system contains the empty set. -/
has_empty : Has ∅
/-- A Dynkin system is closed under complementation. -/
has_compl : ∀ {a}, Has a → Has aᶜ
/-- A Dynkin system is closed under countable union of pairwise disjoint sets. Use a more general
`MeasurableSpace.DynkinSystem.has_iUnion` instead. -/
has_iUnion_nat : ∀ {f : ℕ → Set α}, Pairwise (Disjoint on f) → (∀ i, Has (f i)) → Has (⋃ i, f i)
namespace DynkinSystem
@[ext]
theorem ext : ∀ {d₁ d₂ : DynkinSystem α}, (∀ s : Set α, d₁.Has s ↔ d₂.Has s) → d₁ = d₂
| ⟨s₁, _, _, _⟩, ⟨s₂, _, _, _⟩, h => by
have : s₁ = s₂ := funext fun x => propext <| h x
subst this
rfl
variable (d : DynkinSystem α)
theorem has_compl_iff {a} : d.Has aᶜ ↔ d.Has a :=
⟨fun h => by simpa using d.has_compl h, fun h => d.has_compl h⟩
theorem has_univ : d.Has univ := by simpa using d.has_compl d.has_empty
theorem has_iUnion {β} [Countable β] {f : β → Set α} (hd : Pairwise (Disjoint on f))
(h : ∀ i, d.Has (f i)) : d.Has (⋃ i, f i) := by
cases nonempty_encodable β
rw [← Encodable.iUnion_decode₂]
exact
d.has_iUnion_nat (Encodable.iUnion_decode₂_disjoint_on hd) fun n =>
Encodable.iUnion_decode₂_cases d.has_empty h
theorem has_union {s₁ s₂ : Set α} (h₁ : d.Has s₁) (h₂ : d.Has s₂) (h : Disjoint s₁ s₂) :
d.Has (s₁ ∪ s₂) := by
rw [union_eq_iUnion]
exact d.has_iUnion (pairwise_disjoint_on_bool.2 h) (Bool.forall_bool.2 ⟨h₂, h₁⟩)
theorem has_diff {s₁ s₂ : Set α} (h₁ : d.Has s₁) (h₂ : d.Has s₂) (h : s₂ ⊆ s₁) :
d.Has (s₁ \ s₂) := by
apply d.has_compl_iff.1
simp only [diff_eq, compl_inter, compl_compl]
exact d.has_union (d.has_compl h₁) h₂ (disjoint_compl_left.mono_right h)
instance instLEDynkinSystem : LE (DynkinSystem α) where le m₁ m₂ := m₁.Has ≤ m₂.Has
theorem le_def {a b : DynkinSystem α} : a ≤ b ↔ a.Has ≤ b.Has :=
Iff.rfl
instance : PartialOrder (DynkinSystem α) :=
{ DynkinSystem.instLEDynkinSystem with
le_refl := fun _ _ => le_rfl
le_trans := fun _ _ _ hab hbc => le_def.mpr (le_trans hab hbc)
le_antisymm := fun _ _ h₁ h₂ => ext fun s => ⟨h₁ s, h₂ s⟩ }
/-- Every measurable space (σ-algebra) forms a Dynkin system -/
def ofMeasurableSpace (m : MeasurableSpace α) : DynkinSystem α where
Has := m.MeasurableSet'
has_empty := m.measurableSet_empty
has_compl {a} := m.measurableSet_compl a
has_iUnion_nat {f} _ hf := m.measurableSet_iUnion f hf
theorem ofMeasurableSpace_le_ofMeasurableSpace_iff {m₁ m₂ : MeasurableSpace α} :
ofMeasurableSpace m₁ ≤ ofMeasurableSpace m₂ ↔ m₁ ≤ m₂ :=
Iff.rfl
/-- The least Dynkin system containing a collection of basic sets.
This inductive type gives the underlying collection of sets. -/
inductive GenerateHas (s : Set (Set α)) : Set α → Prop
| basic : ∀ t ∈ s, GenerateHas s t
| empty : GenerateHas s ∅
| compl : ∀ {a}, GenerateHas s a → GenerateHas s aᶜ
| iUnion : ∀ {f : ℕ → Set α},
Pairwise (Disjoint on f) → (∀ i, GenerateHas s (f i)) → GenerateHas s (⋃ i, f i)
theorem generateHas_compl {C : Set (Set α)} {s : Set α} : GenerateHas C sᶜ ↔ GenerateHas C s := by
refine ⟨?_, GenerateHas.compl⟩
intro h
convert GenerateHas.compl h
simp
/-- The least Dynkin system containing a collection of basic sets. -/
def generate (s : Set (Set α)) : DynkinSystem α where
Has := GenerateHas s
has_empty := GenerateHas.empty
has_compl {_} := GenerateHas.compl
has_iUnion_nat {_} := GenerateHas.iUnion
theorem generateHas_def {C : Set (Set α)} : (generate C).Has = GenerateHas C :=
rfl
instance : Inhabited (DynkinSystem α) :=
⟨generate univ⟩
/-- If a Dynkin system is closed under binary intersection, then it forms a `σ`-algebra. -/
def toMeasurableSpace (h_inter : ∀ s₁ s₂, d.Has s₁ → d.Has s₂ → d.Has (s₁ ∩ s₂)) :
MeasurableSpace α where
MeasurableSet' := d.Has
measurableSet_empty := d.has_empty
measurableSet_compl _ h := d.has_compl h
measurableSet_iUnion f hf := by
rw [← iUnion_disjointed]
exact
d.has_iUnion (disjoint_disjointed _) fun n =>
disjointedRec (fun (t : Set α) i h => h_inter _ _ h <| d.has_compl <| hf i) (hf n)
theorem ofMeasurableSpace_toMeasurableSpace
(h_inter : ∀ s₁ s₂, d.Has s₁ → d.Has s₂ → d.Has (s₁ ∩ s₂)) :
ofMeasurableSpace (d.toMeasurableSpace h_inter) = d :=
ext fun _ => Iff.rfl
/-- If `s` is in a Dynkin system `d`, we can form the new Dynkin system `{s ∩ t | t ∈ d}`. -/
def restrictOn {s : Set α} (h : d.Has s) : DynkinSystem α where
Has t := d.Has (t ∩ s)
has_empty := by simp [d.has_empty]
has_compl {t} hts := by
have : tᶜ ∩ s = (t ∩ s)ᶜ \ sᶜ := Set.ext fun x => by by_cases h : x ∈ s <;> simp [h]
simp_rw [this]
exact
d.has_diff (d.has_compl hts) (d.has_compl h)
(compl_subset_compl.mpr inter_subset_right)
has_iUnion_nat {f} hd hf := by
rw [iUnion_inter]
refine d.has_iUnion_nat ?_ hf
exact hd.mono fun i j => Disjoint.mono inter_subset_left inter_subset_left
theorem generate_le {s : Set (Set α)} (h : ∀ t ∈ s, d.Has t) : generate s ≤ d := fun _ ht =>
ht.recOn h d.has_empty (fun {_} _ h => d.has_compl h) fun {_} hd _ hf => d.has_iUnion hd hf
theorem generate_has_subset_generate_measurable {C : Set (Set α)} {s : Set α}
(hs : (generate C).Has s) : MeasurableSet[generateFrom C] s :=
generate_le (ofMeasurableSpace (generateFrom C)) (fun _ => measurableSet_generateFrom) s hs
theorem generate_inter {s : Set (Set α)} (hs : IsPiSystem s) {t₁ t₂ : Set α}
(ht₁ : (generate s).Has t₁) (ht₂ : (generate s).Has t₂) : (generate s).Has (t₁ ∩ t₂) :=
have : generate s ≤ (generate s).restrictOn ht₂ :=
generate_le _ fun s₁ hs₁ =>
have : (generate s).Has s₁ := GenerateHas.basic s₁ hs₁
have : generate s ≤ (generate s).restrictOn this :=
generate_le _ fun s₂ hs₂ =>
show (generate s).Has (s₂ ∩ s₁) from
(s₂ ∩ s₁).eq_empty_or_nonempty.elim (fun h => h.symm ▸ GenerateHas.empty) fun h =>
GenerateHas.basic _ <| hs _ hs₂ _ hs₁ h
have : (generate s).Has (t₂ ∩ s₁) := this _ ht₂
show (generate s).Has (s₁ ∩ t₂) by rwa [inter_comm]
this _ ht₁
/-- **Dynkin's π-λ theorem**:
Given a collection of sets closed under binary intersections, then the Dynkin system it
generates is equal to the σ-algebra it generates.
This result is known as the π-λ theorem.
A collection of sets closed under binary intersection is called a π-system (often requiring
additionally that it is non-empty, but we drop this condition in the formalization).
-/
theorem generateFrom_eq {s : Set (Set α)} (hs : IsPiSystem s) :
generateFrom s = (generate s).toMeasurableSpace fun _ _ => generate_inter hs :=
le_antisymm (generateFrom_le fun t ht => GenerateHas.basic t ht)
(ofMeasurableSpace_le_ofMeasurableSpace_iff.mp <| by
rw [ofMeasurableSpace_toMeasurableSpace]
exact generate_le _ fun t ht => measurableSet_generateFrom ht)
end DynkinSystem
/-- Induction principle for measurable sets.
If `s` is a π-system that generates the product `σ`-algebra on `α`
and a predicate `C` defined on measurable sets is true
- on the empty set;
- on each set `t ∈ s`;
- on the complement of a measurable set that satisfies `C`;
- on the union of a sequence of pairwise disjoint measurable sets that satisfy `C`,
then it is true on all measurable sets in `α`. -/
@[elab_as_elim]
theorem induction_on_inter {m : MeasurableSpace α} {C : ∀ s : Set α, MeasurableSet s → Prop}
{s : Set (Set α)} (h_eq : m = generateFrom s) (h_inter : IsPiSystem s)
(empty : C ∅ .empty) (basic : ∀ t (ht : t ∈ s), C t <| h_eq ▸ .basic t ht)
(compl : ∀ t (htm : MeasurableSet t), C t htm → C tᶜ htm.compl)
(iUnion : ∀ (f : ℕ → Set α), Pairwise (Disjoint on f) → ∀ (hfm : ∀ i, MeasurableSet (f i)),
(∀ i, C (f i) (hfm i)) → C (⋃ i, f i) (.iUnion hfm)) :
∀ t (ht : MeasurableSet t), C t ht := by
have eq : MeasurableSet = DynkinSystem.GenerateHas s := by
rw [h_eq, DynkinSystem.generateFrom_eq h_inter]
rfl
suffices ∀ t (ht : DynkinSystem.GenerateHas s t), C t (eq ▸ ht) from
fun t ht ↦ this t (eq ▸ ht)
intro t ht
induction ht with
| basic u hu => exact basic u hu
| empty => exact empty
| @compl u hu ihu => exact compl _ (eq ▸ hu) ihu
| @iUnion f hfd hf ihf => exact iUnion f hfd (eq ▸ hf) ihf
end MeasurableSpace |
.lake/packages/mathlib/Mathlib/MeasureTheory/SetSemiring.lean | import Mathlib.Data.Nat.Lattice
import Mathlib.Data.Set.Accumulate
import Mathlib.Data.Set.Pairwise.Lattice
import Mathlib.MeasureTheory.PiSystem
/-! # Semirings and rings of sets
A semi-ring of sets `C` (in the sense of measure theory) is a family of sets containing `∅`,
stable by intersection and such that for all `s, t ∈ C`, `t \ s` is equal to a disjoint union of
finitely many sets in `C`. Note that a semi-ring of sets may not contain unions.
An important example of a semi-ring of sets is intervals in `ℝ`. The intersection of two intervals
is an interval (possibly empty). The union of two intervals may not be an interval.
The set difference of two intervals may not be an interval, but it will be a disjoint union of
two intervals.
A ring of sets is a set of sets containing `∅`, stable by union, set difference and intersection.
## Main definitions
* `MeasureTheory.IsSetSemiring C`: property of being a semi-ring of sets.
* `MeasureTheory.IsSetSemiring.disjointOfDiff hs ht`: for `s, t` in a semi-ring `C`
(with `hC : IsSetSemiring C`) with `hs : s ∈ C`, `ht : t ∈ C`, this is a `Finset` of
pairwise disjoint sets such that `s \ t = ⋃₀ hC.disjointOfDiff hs ht`.
* `MeasureTheory.IsSetSemiring.disjointOfDiffUnion hs hI`: for `hs : s ∈ C` and a finset
`I` of sets in `C` (with `hI : ↑I ⊆ C`), this is a `Finset` of pairwise disjoint sets such that
`s \ ⋃₀ I = ⋃₀ hC.disjointOfDiffUnion hs hI`.
* `MeasureTheory.IsSetSemiring.disjointOfUnion hJ`: for `hJ ⊆ C`, this is a
`Finset` of pairwise disjoint sets such that `⋃₀ J = ⋃₀ hC.disjointOfUnion hJ`.
* `MeasureTheory.IsSetRing`: property of being a ring of sets.
## Main statements
* `MeasureTheory.IsSetSemiring.exists_disjoint_finset_diff_eq`: the existence of the `Finset` given
by the definition `IsSetSemiring.disjointOfDiffUnion` (see above).
* `MeasureTheory.IsSetSemiring.disjointOfUnion_props`: In a `hC : IsSetSemiring C`,
for a `J : Finset (Set α)` with `J ⊆ C`, there is
for every `x in J` some `K x ⊆ C` finite, such that
* `⋃ x ∈ J, K x` are pairwise disjoint and do not contain ∅,
* `⋃ s ∈ K x, s ⊆ x`,
* `⋃ x ∈ J, x = ⋃ x ∈ J, ⋃ s ∈ K x, s`.
-/
open Finset Set
namespace MeasureTheory
variable {α : Type*} {C : Set (Set α)} {s t : Set α}
/-- A semi-ring of sets `C` is a family of sets containing `∅`, stable by intersection and such that
for all `s, t ∈ C`, `s \ t` is equal to a disjoint union of finitely many sets in `C`. -/
structure IsSetSemiring (C : Set (Set α)) : Prop where
empty_mem : ∅ ∈ C
inter_mem : ∀ s ∈ C, ∀ t ∈ C, s ∩ t ∈ C
diff_eq_sUnion' : ∀ s ∈ C, ∀ t ∈ C,
∃ I : Finset (Set α), ↑I ⊆ C ∧ PairwiseDisjoint (I : Set (Set α)) id ∧ s \ t = ⋃₀ I
namespace IsSetSemiring
lemma isPiSystem (hC : IsSetSemiring C) : IsPiSystem C := fun s hs t ht _ ↦ hC.inter_mem s hs t ht
section disjointOfDiff
open scoped Classical in
/-- In a semi-ring of sets `C`, for all sets `s, t ∈ C`, `s \ t` is equal to a disjoint union of
finitely many sets in `C`. The finite set of sets in the union is not unique, but this definition
gives an arbitrary `Finset (Set α)` that satisfies the equality.
We remove the empty set to ensure that `t ∉ hC.disjointOfDiff hs ht` even if `t = ∅`. -/
noncomputable def disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
Finset (Set α) :=
(hC.diff_eq_sUnion' s hs t ht).choose \ {∅}
lemma empty_notMem_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
∅ ∉ hC.disjointOfDiff hs ht := by
classical
simp only [disjointOfDiff, mem_sdiff, Finset.mem_singleton,
not_true, and_false, not_false_iff]
@[deprecated (since := "2025-05-24")] alias empty_nmem_disjointOfDiff := empty_notMem_disjointOfDiff
lemma subset_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
↑(hC.disjointOfDiff hs ht) ⊆ C := by
classical
simp only [disjointOfDiff, coe_sdiff, coe_singleton, diff_singleton_subset_iff]
exact (hC.diff_eq_sUnion' s hs t ht).choose_spec.1.trans (Set.subset_insert _ _)
lemma pairwiseDisjoint_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
PairwiseDisjoint (hC.disjointOfDiff hs ht : Set (Set α)) id := by
classical
simp only [disjointOfDiff, coe_sdiff, coe_singleton]
exact Set.PairwiseDisjoint.subset (hC.diff_eq_sUnion' s hs t ht).choose_spec.2.1
diff_subset
lemma sUnion_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
⋃₀ hC.disjointOfDiff hs ht = s \ t := by
classical
rw [(hC.diff_eq_sUnion' s hs t ht).choose_spec.2.2]
simp only [disjointOfDiff, coe_sdiff, coe_singleton]
rw [sUnion_diff_singleton_empty]
lemma notMem_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
t ∉ hC.disjointOfDiff hs ht := by
intro hs_mem
suffices t ⊆ s \ t by
have h := @disjoint_sdiff_self_right _ t s _
specialize h le_rfl this
simp only [Set.bot_eq_empty, Set.le_eq_subset, subset_empty_iff] at h
refine hC.empty_notMem_disjointOfDiff hs ht ?_
rwa [← h]
rw [← hC.sUnion_disjointOfDiff hs ht]
exact subset_sUnion_of_mem hs_mem
@[deprecated (since := "2025-05-24")] alias nmem_disjointOfDiff := notMem_disjointOfDiff
lemma sUnion_insert_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C)
(ht : t ∈ C) (hst : t ⊆ s) :
⋃₀ insert t (hC.disjointOfDiff hs ht) = s := by
conv_rhs => rw [← union_diff_cancel hst, ← hC.sUnion_disjointOfDiff hs ht]
simp only [sUnion_insert]
lemma disjoint_sUnion_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C) (ht : t ∈ C) :
Disjoint t (⋃₀ hC.disjointOfDiff hs ht) := by
rw [hC.sUnion_disjointOfDiff]
exact disjoint_sdiff_right
lemma pairwiseDisjoint_insert_disjointOfDiff (hC : IsSetSemiring C) (hs : s ∈ C)
(ht : t ∈ C) :
PairwiseDisjoint (insert t (hC.disjointOfDiff hs ht) : Set (Set α)) id := by
have h := hC.pairwiseDisjoint_disjointOfDiff hs ht
refine PairwiseDisjoint.insert_of_notMem h (hC.notMem_disjointOfDiff hs ht) fun u hu ↦ ?_
simp_rw [id]
refine Disjoint.mono_right ?_ (hC.disjoint_sUnion_disjointOfDiff hs ht)
simp only [Set.le_eq_subset]
exact subset_sUnion_of_mem hu
end disjointOfDiff
section disjointOfDiffUnion
variable {I : Finset (Set α)}
/-- In a semiring of sets `C`, for all set `s ∈ C` and finite set of sets `I ⊆ C`, there is a
finite set of sets in `C` whose union is `s \ ⋃₀ I`.
See `IsSetSemiring.disjointOfDiffUnion` for a definition that gives such a set. -/
lemma exists_disjoint_finset_diff_eq (hC : IsSetSemiring C) (hs : s ∈ C) (hI : ↑I ⊆ C) :
∃ J : Finset (Set α), ↑J ⊆ C ∧ PairwiseDisjoint (J : Set (Set α)) id ∧
s \ ⋃₀ I = ⋃₀ J := by
classical
induction I using Finset.induction with
| empty =>
simp only [coe_empty, sUnion_empty, diff_empty]
refine ⟨{s}, singleton_subset_set_iff.mpr hs, ?_⟩
simp only [coe_singleton, pairwiseDisjoint_singleton, sUnion_singleton,
and_self_iff]
| insert t I' _ h => ?_
rw [coe_insert] at hI
have ht : t ∈ C := hI (Set.mem_insert _ _)
obtain ⟨J, h_ss, h_dis, h_eq⟩ := h ((Set.subset_insert _ _).trans hI)
let Ju : ∀ u ∈ C, Finset (Set α) := fun u hu ↦ hC.disjointOfDiff hu ht
have hJu_subset : ∀ (u) (hu : u ∈ C), ↑(Ju u hu) ⊆ C := by
intro u hu x hx
exact hC.subset_disjointOfDiff hu ht hx
have hJu_disj : ∀ (u) (hu : u ∈ C), (Ju u hu : Set (Set α)).PairwiseDisjoint id := fun u hu ↦
hC.pairwiseDisjoint_disjointOfDiff hu ht
have hJu_sUnion : ∀ (u) (hu : u ∈ C), ⋃₀ (Ju u hu : Set (Set α)) = u \ t :=
fun u hu ↦ hC.sUnion_disjointOfDiff hu ht
have hJu_disj' : ∀ (u) (hu : u ∈ C) (v) (hv : v ∈ C) (_h_dis : Disjoint u v),
Disjoint (⋃₀ (Ju u hu : Set (Set α))) (⋃₀ ↑(Ju v hv)) := by
intro u hu v hv huv_disj
rw [hJu_sUnion, hJu_sUnion]
exact disjoint_of_subset Set.diff_subset Set.diff_subset huv_disj
let J' : Finset (Set α) := Finset.biUnion (Finset.univ : Finset J) fun u ↦ Ju u (h_ss u.prop)
have hJ'_subset : ↑J' ⊆ C := by
intro u
simp only [J', univ_eq_attach, coe_biUnion, mem_coe, mem_attach, iUnion_true,
mem_iUnion, Finset.exists_coe, exists₂_imp]
intro v hv huvt
exact hJu_subset v (h_ss hv) huvt
refine ⟨J', hJ'_subset, ?_, ?_⟩
· rw [Finset.coe_biUnion]
refine PairwiseDisjoint.biUnion ?_ ?_
· simp only [univ_eq_attach, mem_coe, id, iSup_eq_iUnion]
simp_rw [PairwiseDisjoint, Set.Pairwise]
intro x _ y _ hxy
have hxy_disj : Disjoint (x : Set α) y := by
by_contra h_contra
refine hxy ?_
refine Subtype.ext ?_
exact h_dis.elim x.prop y.prop h_contra
convert hJu_disj' (x : Set α) (h_ss x.prop) y (h_ss y.prop) hxy_disj
· rw [sUnion_eq_biUnion]
congr
· rw [sUnion_eq_biUnion]
congr
· exact fun u _ ↦ hJu_disj _ _
· rw [coe_insert, sUnion_insert, Set.union_comm, ← Set.diff_diff, h_eq]
simp_rw [J', sUnion_eq_biUnion, Set.iUnion_diff]
simp only [mem_coe, Finset.mem_biUnion, Finset.mem_univ,
Finset.exists_coe, iUnion_exists, true_and]
rw [iUnion_comm]
refine iUnion_congr fun i ↦ ?_
by_cases hi : i ∈ J
· simp only [hi, iUnion_true]
rw [← hJu_sUnion i (h_ss hi), sUnion_eq_biUnion]
simp only [mem_coe]
· simp only [hi, iUnion_of_empty, iUnion_empty]
open scoped Classical in
/-- In a semiring of sets `C`, for all set `s ∈ C` and finite set of sets `I ⊆ C`,
`disjointOfDiffUnion` is a finite set of sets in `C` such that
`s \ ⋃₀ I = ⋃₀ (hC.disjointOfDiffUnion hs I hI)`.
`disjointOfDiff` is a special case of `disjointOfDiffUnion` where `I` is a
singleton. -/
noncomputable def disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C) (hI : ↑I ⊆ C) :
Finset (Set α) :=
(hC.exists_disjoint_finset_diff_eq hs hI).choose \ {∅}
lemma empty_notMem_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) :
∅ ∉ hC.disjointOfDiffUnion hs hI := by
classical
simp only [disjointOfDiffUnion, mem_sdiff, Finset.mem_singleton,
not_true, and_false, not_false_iff]
@[deprecated (since := "2025-05-24")]
alias empty_nmem_disjointOfDiffUnion := empty_notMem_disjointOfDiffUnion
lemma disjointOfDiffUnion_subset (hC : IsSetSemiring C) (hs : s ∈ C) (hI : ↑I ⊆ C) :
↑(hC.disjointOfDiffUnion hs hI) ⊆ C := by
classical
simp only [disjointOfDiffUnion, coe_sdiff, coe_singleton, diff_singleton_subset_iff]
exact (hC.exists_disjoint_finset_diff_eq hs hI).choose_spec.1.trans (Set.subset_insert _ _)
lemma pairwiseDisjoint_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) : PairwiseDisjoint (hC.disjointOfDiffUnion hs hI : Set (Set α)) id := by
classical
simp only [disjointOfDiffUnion, coe_sdiff, coe_singleton]
exact Set.PairwiseDisjoint.subset
(hC.exists_disjoint_finset_diff_eq hs hI).choose_spec.2.1 diff_subset
lemma diff_sUnion_eq_sUnion_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) : s \ ⋃₀ I = ⋃₀ hC.disjointOfDiffUnion hs hI := by
classical
rw [(hC.exists_disjoint_finset_diff_eq hs hI).choose_spec.2.2]
simp only [disjointOfDiffUnion, coe_sdiff, coe_singleton]
rw [sUnion_diff_singleton_empty]
lemma sUnion_disjointOfDiffUnion_subset (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) : ⋃₀ (hC.disjointOfDiffUnion hs hI : Set (Set α)) ⊆ s := by
rw [← hC.diff_sUnion_eq_sUnion_disjointOfDiffUnion]
exact diff_subset
lemma subset_of_diffUnion_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C) (hI : ↑I ⊆ C)
(t : Set α) (ht : t ∈ (hC.disjointOfDiffUnion hs hI : Set (Set α))) :
t ⊆ s \ ⋃₀ I := by
revert t ht
rw [← sUnion_subset_iff, hC.diff_sUnion_eq_sUnion_disjointOfDiffUnion hs hI]
lemma subset_of_mem_disjointOfDiffUnion (hC : IsSetSemiring C) {I : Finset (Set α)}
(hs : s ∈ C) (hI : ↑I ⊆ C) (t : Set α)
(ht : t ∈ (hC.disjointOfDiffUnion hs hI : Set (Set α))) :
t ⊆ s := by
apply le_trans <| hC.subset_of_diffUnion_disjointOfDiffUnion hs hI t ht
exact sdiff_le (a := s) (b := ⋃₀ I)
lemma disjoint_sUnion_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) :
Disjoint (⋃₀ (I : Set (Set α))) (⋃₀ hC.disjointOfDiffUnion hs hI) := by
rw [← hC.diff_sUnion_eq_sUnion_disjointOfDiffUnion]; exact Set.disjoint_sdiff_right
lemma disjoint_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C) (hI : ↑I ⊆ C) :
Disjoint I (hC.disjointOfDiffUnion hs hI) := by
by_contra h
rw [Finset.not_disjoint_iff] at h
obtain ⟨u, huI, hu_disjointOfDiffUnion⟩ := h
have h_disj : u ≤ ⊥ :=
hC.disjoint_sUnion_disjointOfDiffUnion hs hI (subset_sUnion_of_mem huI)
(subset_sUnion_of_mem hu_disjointOfDiffUnion)
simp only [Set.bot_eq_empty, Set.le_eq_subset, subset_empty_iff] at h_disj
refine hC.empty_notMem_disjointOfDiffUnion hs hI ?_
rwa [h_disj] at hu_disjointOfDiffUnion
lemma pairwiseDisjoint_union_disjointOfDiffUnion (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) (h_dis : PairwiseDisjoint (I : Set (Set α)) id) :
PairwiseDisjoint (I ∪ hC.disjointOfDiffUnion hs hI : Set (Set α)) id := by
rw [pairwiseDisjoint_union]
refine ⟨h_dis, hC.pairwiseDisjoint_disjointOfDiffUnion hs hI, fun u hu v hv _ ↦ ?_⟩
simp_rw [id]
exact disjoint_of_subset (subset_sUnion_of_mem hu) (subset_sUnion_of_mem hv)
(hC.disjoint_sUnion_disjointOfDiffUnion hs hI)
lemma sUnion_union_sUnion_disjointOfDiffUnion_of_subset (hC : IsSetSemiring C)
(hs : s ∈ C) (hI : ↑I ⊆ C) (hI_ss : ∀ t ∈ I, t ⊆ s) :
⋃₀ I ∪ ⋃₀ hC.disjointOfDiffUnion hs hI = s := by
conv_rhs => rw [← union_diff_cancel (Set.sUnion_subset hI_ss : ⋃₀ ↑I ⊆ s),
hC.diff_sUnion_eq_sUnion_disjointOfDiffUnion hs hI]
lemma sUnion_union_disjointOfDiffUnion_of_subset (hC : IsSetSemiring C) (hs : s ∈ C)
(hI : ↑I ⊆ C) (hI_ss : ∀ t ∈ I, t ⊆ s) [DecidableEq (Set α)] :
⋃₀ ↑(I ∪ hC.disjointOfDiffUnion hs hI) = s := by
conv_rhs => rw [← sUnion_union_sUnion_disjointOfDiffUnion_of_subset hC hs hI hI_ss]
simp_rw [coe_union]
rw [sUnion_union]
end disjointOfDiffUnion
section disjointOfUnion
variable {j : Set α} {J : Finset (Set α)}
open MeasureTheory Order
theorem disjointOfUnion_props (hC : IsSetSemiring C) (h1 : ↑J ⊆ C) :
∃ K : Set α → Finset (Set α),
PairwiseDisjoint J K
∧ (∀ i ∈ J, ↑(K i) ⊆ C)
∧ PairwiseDisjoint (⋃ x ∈ J, (K x : Set (Set α))) id
∧ (∀ j ∈ J, ⋃₀ K j ⊆ j)
∧ (∀ j ∈ J, ∅ ∉ K j)
∧ ⋃₀ J = ⋃₀ (⋃ x ∈ J, (K x : Set (Set α))) := by
classical
induction J using Finset.cons_induction with
| empty => simp
| cons s J hJ hind =>
rw [cons_eq_insert, coe_insert, Set.insert_subset_iff] at h1
obtain ⟨K, hK0, ⟨hK1, hK2, hK3, hK4, hK5⟩⟩ := hind h1.2
let K1 : Set α → Finset (Set α) := fun (t : Set α) ↦
if t = s then (hC.disjointOfDiffUnion h1.1 h1.2) else K t
have hK1s : K1 s = hC.disjointOfDiffUnion h1.1 h1.2 := by simp [K1]
have hK1_of_ne t (ht : t ≠ s) : K1 t = K t := by simp [K1, ht]
use K1
simp only [cons_eq_insert,
mem_coe, Finset.mem_insert, sUnion_subset_iff,
forall_eq_or_imp, coe_insert, sUnion_insert]
-- two simplification rules for induction hypothesis
have ht1' : ∀ x ∈ J, K1 x = K x := fun x hx ↦ hK1_of_ne _ (fun h_eq ↦ hJ (h_eq ▸ hx))
have ht2 : (⋃ x ∈ J, (K1 x : Set (Set α))) = ⋃ x ∈ J, ((K x : Set (Set α))) := by
apply iUnion₂_congr
intro x hx
exact_mod_cast hK1_of_ne _ (ne_of_mem_of_not_mem hx hJ)
simp only [hK1s]
refine ⟨?_, ⟨hC.disjointOfDiffUnion_subset h1.1 h1.2, ?_⟩, ?_,
⟨hC.subset_of_mem_disjointOfDiffUnion h1.1 h1.2, ?_⟩, ?_, ?_⟩
· apply Set.Pairwise.insert
· intro j hj i hi hij
rw [Function.onFun, ht1' j hj, ht1' i hi]
exact hK0 hj hi hij
· intro i hi _
have h7 : Disjoint ↑(hC.disjointOfDiffUnion h1.1 h1.2) (K i : Set (Set α)) := by
refine disjoint_of_sSup_disjoint_of_le_of_le
(hC.subset_of_diffUnion_disjointOfDiffUnion h1.1 h1.2) ?_
(@disjoint_sdiff_left _ (⋃₀ J) s) (Or.inl
(hC.empty_notMem_disjointOfDiffUnion h1.1 h1.2))
simp only [mem_coe, Set.le_eq_subset]
apply sUnion_subset_iff.mp
exact (hK3 i hi).trans (subset_sUnion_of_mem hi)
have h8 : Function.onFun Disjoint K1 s i := by
refine Finset.disjoint_iff_inter_eq_empty.mpr ?_
rw [ht1' i hi, hK1s]
rw [Set.disjoint_iff_inter_eq_empty] at h7
exact_mod_cast h7
exact ⟨h8, Disjoint.symm h8⟩
· intro i hi
rw [ht1' i hi]
exact hK1 i hi
· simp only [iUnion_iUnion_eq_or_left]
refine pairwiseDisjoint_union.mpr ⟨?_, ?_, ?_⟩
· rw [hK1s]
exact hC.pairwiseDisjoint_disjointOfDiffUnion h1.1 h1.2
· simpa [ht2]
· simp only [mem_coe, mem_iUnion, exists_prop, ne_eq, id_eq, forall_exists_index, and_imp]
intro i hi j x hx h3 h4
obtain ki : i ⊆ s \ ⋃₀ J := hC.subset_of_diffUnion_disjointOfDiffUnion h1.1 h1.2 _
(hK1s ▸ hi)
obtain hx2 : j ⊆ x := subset_trans (subset_sUnion_of_mem (ht1' x hx ▸ h3)) (hK3 x hx)
obtain kj : j ⊆ ⋃₀ J := hx2.trans <| subset_sUnion_of_mem hx
exact disjoint_of_subset ki kj disjoint_sdiff_left
· intro a ha
simp_rw [hK1_of_ne _ (ne_of_mem_of_not_mem ha hJ)]
change ∀ t' ∈ (K a : Set (Set α)), t' ⊆ a
rw [← sUnion_subset_iff]
exact hK3 a ha
· refine ⟨hC.empty_notMem_disjointOfDiffUnion h1.1 h1.2, ?_⟩
intro a ha
rw [ht1' a ha]
exact hK4 a ha
· simp only [iUnion_iUnion_eq_or_left, sUnion_union, ht2, K1]
simp_rw [apply_ite, hK5,
← hC.diff_sUnion_eq_sUnion_disjointOfDiffUnion h1.1 h1.2, hK5]
simp only [↓reduceIte, diff_union_self]
/-- For some `hJ : J ⊆ C` and `j : Set α`, where `hC : IsSetSemiring C`, this is
a `Finset (Set α)` such that `K j := hC.disjointOfUnion hJ` are disjoint
and `⋃₀ K j ⊆ j`, for `j ∈ J`.
Using these we write `⋃₀ J` as a disjoint union `⋃₀ J = ⋃₀ ⋃ x ∈ J, (K x)`.
See `MeasureTheory.IsSetSemiring.disjointOfUnion_props`. -/
noncomputable def disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (j : Set α) :=
(hC.disjointOfUnion_props hJ).choose j
lemma pairwiseDisjoint_disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) :
PairwiseDisjoint J (hC.disjointOfUnion hJ) :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).1
lemma disjointOfUnion_subset (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (hj : j ∈ J) :
(disjointOfUnion hC hJ j : Set (Set α)) ⊆ C :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).2.1 _ hj
lemma pairwiseDisjoint_biUnion_disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) :
PairwiseDisjoint (⋃ x ∈ J, (hC.disjointOfUnion hJ x : Set (Set α))) id :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).2.2.1
lemma pairwiseDisjoint_disjointOfUnion_of_mem (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (hj : j ∈ J) :
PairwiseDisjoint (hC.disjointOfUnion hJ j : Set (Set α)) id := by
apply PairwiseDisjoint.subset (hC.pairwiseDisjoint_biUnion_disjointOfUnion hJ)
exact subset_iUnion₂_of_subset j hj fun ⦃a⦄ a ↦ a
lemma disjointOfUnion_subset_of_mem (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (hj : j ∈ J) :
⋃₀ hC.disjointOfUnion hJ j ⊆ j :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).2.2.2.1 j hj
lemma subset_of_mem_disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (hj : j ∈ J) {x : Set α}
(hx : x ∈ (hC.disjointOfUnion hJ) j) : x ⊆ j :=
sUnion_subset_iff.mp (hC.disjointOfUnion_subset_of_mem hJ hj) x hx
lemma empty_notMem_disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) (hj : j ∈ J) :
∅ ∉ hC.disjointOfUnion hJ j :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).2.2.2.2.1 j hj
@[deprecated (since := "2025-05-24")]
alias empty_nmem_disjointOfUnion := empty_notMem_disjointOfUnion
lemma sUnion_disjointOfUnion (hC : IsSetSemiring C) (hJ : ↑J ⊆ C) :
⋃₀ ⋃ x ∈ J, (hC.disjointOfUnion hJ x : Set (Set α)) = ⋃₀ J :=
(Exists.choose_spec (hC.disjointOfUnion_props hJ)).2.2.2.2.2.symm
end disjointOfUnion
end IsSetSemiring
/-- A ring of sets `C` is a family of sets containing `∅`, stable by union and set difference.
It is then also stable by intersection (see `IsSetRing.inter_mem`). -/
structure IsSetRing (C : Set (Set α)) : Prop where
empty_mem : ∅ ∈ C
union_mem ⦃s t : Set α⦄ : s ∈ C → t ∈ C → s ∪ t ∈ C
diff_mem ⦃s t : Set α⦄ : s ∈ C → t ∈ C → s \ t ∈ C
namespace IsSetRing
lemma inter_mem (hC : IsSetRing C) (hs : s ∈ C) (ht : t ∈ C) : s ∩ t ∈ C := by
rw [← diff_diff_right_self]; exact hC.diff_mem hs (hC.diff_mem hs ht)
lemma isSetSemiring (hC : IsSetRing C) : IsSetSemiring C where
empty_mem := hC.empty_mem
inter_mem := fun _ hs _ ht => hC.inter_mem hs ht
diff_eq_sUnion' := by
refine fun s hs t ht => ⟨{s \ t}, ?_, ?_, ?_⟩
· simp only [coe_singleton, Set.singleton_subset_iff]
exact hC.diff_mem hs ht
· simp only [coe_singleton, pairwiseDisjoint_singleton]
· simp only [coe_singleton, sUnion_singleton]
lemma biUnion_mem {ι : Type*} (hC : IsSetRing C) {s : ι → Set α}
(S : Finset ι) (hs : ∀ n ∈ S, s n ∈ C) :
⋃ i ∈ S, s i ∈ C := by
classical
induction S using Finset.induction with
| empty => simp [hC.empty_mem]
| insert i S _ h =>
simp_rw [← Finset.mem_coe, Finset.coe_insert, Set.biUnion_insert]
refine hC.union_mem (hs i (mem_insert_self i S)) ?_
exact h (fun n hnS ↦ hs n (mem_insert_of_mem hnS))
lemma biInter_mem {ι : Type*} (hC : IsSetRing C) {s : ι → Set α}
(S : Finset ι) (hS : S.Nonempty) (hs : ∀ n ∈ S, s n ∈ C) :
⋂ i ∈ S, s i ∈ C := by
classical
induction hS using Finset.Nonempty.cons_induction with
| singleton => simpa using hs
| cons i S hiS _ h =>
simp_rw [← Finset.mem_coe, Finset.coe_cons, Set.biInter_insert]
simp only [cons_eq_insert, Finset.mem_insert, forall_eq_or_imp] at hs
refine hC.inter_mem hs.1 ?_
exact h (fun n hnS ↦ hs.2 n hnS)
lemma finsetSup_mem (hC : IsSetRing C) {ι : Type*} {s : ι → Set α} {t : Finset ι}
(hs : ∀ i ∈ t, s i ∈ C) :
t.sup s ∈ C := by
classical
induction t using Finset.induction_on with
| empty => exact hC.empty_mem
| insert m t hm ih =>
simpa only [sup_insert] using
hC.union_mem (hs m <| mem_insert_self m t) (ih <| fun i hi ↦ hs _ <| mem_insert_of_mem hi)
lemma partialSups_mem {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
(hC : IsSetRing C) {s : ι → Set α} (hs : ∀ n, s n ∈ C) (n : ι) :
partialSups s n ∈ C := by
simpa only [partialSups_apply, sup'_eq_sup] using hC.finsetSup_mem (fun i hi ↦ hs i)
lemma disjointed_mem {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
(hC : IsSetRing C) {s : ι → Set α} (hs : ∀ j, s j ∈ C) (i : ι) :
disjointed s i ∈ C :=
disjointedRec (fun _ j ht ↦ hC.diff_mem ht <| hs j) (hs i)
theorem iUnion_le_mem (hC : IsSetRing C) {s : ℕ → Set α} (hs : ∀ n, s n ∈ C) (n : ℕ) :
(⋃ i ≤ n, s i) ∈ C := by
induction n with
| zero => simp [hs 0]
| succ n hn => rw [biUnion_le_succ]; exact hC.union_mem hn (hs _)
theorem iInter_le_mem (hC : IsSetRing C) {s : ℕ → Set α} (hs : ∀ n, s n ∈ C) (n : ℕ) :
(⋂ i ≤ n, s i) ∈ C := by
induction n with
| zero => simp [hs 0]
| succ n hn => rw [biInter_le_succ]; exact hC.inter_mem hn (hs _)
theorem accumulate_mem (hC : IsSetRing C) {s : ℕ → Set α} (hs : ∀ i, s i ∈ C) (n : ℕ) :
Accumulate s n ∈ C := by
induction n with
| zero => simp [hs 0]
| succ n hn => rw [accumulate_succ]; exact hC.union_mem hn (hs _)
end IsSetRing
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/Order/UpperLower.lean | import Mathlib.Analysis.Normed.Order.UpperLower
import Mathlib.MeasureTheory.Covering.BesicovitchVectorSpace
import Mathlib.Topology.Order.DenselyOrdered
/-!
# Order-connected sets are null-measurable
This file proves that order-connected sets in `ℝⁿ` under the pointwise order are null-measurable.
Recall that `x ≤ y` iff `∀ i, x i ≤ y i`, and `s` is order-connected iff
`∀ x y ∈ s, ∀ z, x ≤ z → z ≤ y → z ∈ s`.
## Main declarations
* `Set.OrdConnected.null_frontier`: The frontier of an order-connected set in `ℝⁿ` has measure `0`.
## Notes
We prove null-measurability in `ℝⁿ` with the `∞`-metric, but this transfers directly to `ℝⁿ` with
the Euclidean metric because they have the same measurable sets.
Null-measurability can't be strengthened to measurability because any antichain (and in particular
any subset of the antidiagonal `{(x, y) | x + y = 0}`) is order-connected.
## Sketch proof
1. To show an order-connected set is null-measurable, it is enough to show it has null frontier.
2. Since an order-connected set is the intersection of its upper and lower closure, it's enough to
show that upper and lower sets have null frontier.
3. WLOG let's prove it for an upper set `s`.
4. By the Lebesgue density theorem, it is enough to show that any frontier point `x` of `s` is not a
Lebesgue point, namely we want the density of `s` over small balls centered at `x` to not tend to
either `0` or `1`.
5. This is true, since by the upper setness of `s` we can intercalate a ball of radius `δ / 4` in
`s` intersected with the upper quadrant of the ball of radius `δ` centered at `x` (recall that the
balls are taken in the ∞-norm, so they are cubes), and another ball of radius `δ / 4` in `sᶜ` and
the lower quadrant of the ball of radius `δ` centered at `x`.
## TODO
Generalize so that it also applies to `ℝ × ℝ`, for example.
-/
open Filter MeasureTheory Metric Set
open scoped Topology
variable {ι : Type*} [Fintype ι] {s : Set (ι → ℝ)} {x : ι → ℝ}
/-- If we can fit a small ball inside a set `s` intersected with any neighborhood of `x`, then the
density of `s` near `x` is not `0`.
Along with `aux₁`, this proves that `x` is a Lebesgue point of `s`. This will be used to prove that
the frontier of an order-connected set is null. -/
private lemma aux₀
(h : ∀ δ, 0 < δ →
∃ y, closedBall y (δ / 4) ⊆ closedBall x δ ∧ closedBall y (δ / 4) ⊆ interior s) :
¬Tendsto (fun r ↦ volume (closure s ∩ closedBall x r) / volume (closedBall x r)) (𝓝[>] 0)
(𝓝 0) := by
choose f hf₀ hf₁ using h
intro H
obtain ⟨ε, -, hε', hε₀⟩ := exists_seq_strictAnti_tendsto_nhdsWithin (0 : ℝ)
refine not_eventually.2
(Frequently.of_forall fun _ ↦ lt_irrefl <| ENNReal.ofReal <| 4⁻¹ ^ Fintype.card ι)
((Filter.Tendsto.eventually_lt (H.comp hε₀) tendsto_const_nhds ?_).mono fun n ↦
lt_of_le_of_lt ?_)
on_goal 2 =>
calc
ENNReal.ofReal (4⁻¹ ^ Fintype.card ι)
= volume (closedBall (f (ε n) (hε' n)) (ε n / 4)) / volume (closedBall x (ε n)) := ?_
_ ≤ volume (closure s ∩ closedBall x (ε n)) / volume (closedBall x (ε n)) := by
gcongr
exact subset_inter ((hf₁ _ <| hε' n).trans interior_subset_closure) <| hf₀ _ <| hε' n
have := hε' n
rw [Real.volume_pi_closedBall, Real.volume_pi_closedBall, ← ENNReal.ofReal_div_of_pos,
← div_pow, mul_div_mul_left _ _ (two_ne_zero' ℝ), div_right_comm, div_self, one_div]
all_goals positivity
/-- If we can fit a small ball inside a set `sᶜ` intersected with any neighborhood of `x`, then the
density of `s` near `x` is not `1`.
Along with `aux₀`, this proves that `x` is a Lebesgue point of `s`. This will be used to prove that
the frontier of an order-connected set is null. -/
private lemma aux₁
(h : ∀ δ, 0 < δ →
∃ y, closedBall y (δ / 4) ⊆ closedBall x δ ∧ closedBall y (δ / 4) ⊆ interior sᶜ) :
¬Tendsto (fun r ↦ volume (closure s ∩ closedBall x r) / volume (closedBall x r)) (𝓝[>] 0)
(𝓝 1) := by
choose f hf₀ hf₁ using h
intro H
obtain ⟨ε, -, hε', hε₀⟩ := exists_seq_strictAnti_tendsto_nhdsWithin (0 : ℝ)
refine not_eventually.2
(Frequently.of_forall fun _ ↦ lt_irrefl <| 1 - ENNReal.ofReal (4⁻¹ ^ Fintype.card ι))
((Filter.Tendsto.eventually_lt tendsto_const_nhds (H.comp hε₀) <|
ENNReal.sub_lt_self ENNReal.one_ne_top one_ne_zero ?_).mono
fun n ↦ lt_of_le_of_lt' ?_)
on_goal 2 =>
calc
volume (closure s ∩ closedBall x (ε n)) / volume (closedBall x (ε n))
≤ volume (closedBall x (ε n) \ closedBall (f (ε n) <| hε' n) (ε n / 4)) /
volume (closedBall x (ε n)) := by
gcongr
rw [diff_eq_compl_inter]
refine inter_subset_inter_left _ ?_
rw [subset_compl_comm, ← interior_compl]
exact hf₁ _ _
_ = 1 - ENNReal.ofReal (4⁻¹ ^ Fintype.card ι) := ?_
dsimp only
have := hε' n
rw [measure_diff (hf₀ _ _) _ ((Real.volume_pi_closedBall _ _).trans_ne ENNReal.ofReal_ne_top),
Real.volume_pi_closedBall, Real.volume_pi_closedBall, ENNReal.sub_div fun _ _ ↦ _,
ENNReal.div_self _ ENNReal.ofReal_ne_top, ← ENNReal.ofReal_div_of_pos, ← div_pow,
mul_div_mul_left _ _ (two_ne_zero' ℝ), div_right_comm, div_self, one_div]
all_goals try positivity
· simp_all
· exact measurableSet_closedBall.nullMeasurableSet
theorem IsUpperSet.null_frontier (hs : IsUpperSet s) : volume (frontier s) = 0 := by
refine measure_mono_null (fun x hx ↦ ?_)
(Besicovitch.ae_tendsto_measure_inter_div_of_measurableSet _
(isClosed_closure (s := s)).measurableSet)
by_cases h : x ∈ closure s <;>
simp only [mem_compl_iff, mem_setOf, h, not_false_eq_true, indicator_of_notMem,
indicator_of_mem, Pi.one_apply]
· refine aux₁ fun _ ↦ hs.compl.exists_subset_ball <| frontier_subset_closure ?_
rwa [frontier_compl]
· exact aux₀ fun _ ↦ hs.exists_subset_ball <| frontier_subset_closure hx
theorem IsLowerSet.null_frontier (hs : IsLowerSet s) : volume (frontier s) = 0 := by
refine measure_mono_null (fun x hx ↦ ?_)
(Besicovitch.ae_tendsto_measure_inter_div_of_measurableSet _
(isClosed_closure (s := s)).measurableSet)
by_cases h : x ∈ closure s <;>
simp only [mem_compl_iff, mem_setOf, h, not_false_eq_true, indicator_of_notMem,
indicator_of_mem, Pi.one_apply]
· refine aux₁ fun _ ↦ hs.compl.exists_subset_ball <| frontier_subset_closure ?_
rwa [frontier_compl]
· exact aux₀ fun _ ↦ hs.exists_subset_ball <| frontier_subset_closure hx
theorem Set.OrdConnected.null_frontier (hs : s.OrdConnected) : volume (frontier s) = 0 := by
rw [← hs.upperClosure_inter_lowerClosure]
exact measure_mono_null (frontier_inter_subset _ _) <| measure_union_null
(measure_inter_null_of_null_left _ (UpperSet.upper _).null_frontier)
(measure_inter_null_of_null_right _ (LowerSet.lower _).null_frontier)
protected theorem Set.OrdConnected.nullMeasurableSet (hs : s.OrdConnected) : NullMeasurableSet s :=
nullMeasurableSet_of_null_frontier hs.null_frontier
theorem IsAntichain.volume_eq_zero [Nonempty ι] (hs : IsAntichain (· ≤ ·) s) : volume s = 0 := by
refine measure_mono_null ?_ hs.ordConnected.null_frontier
rw [← closure_diff_interior, hs.interior_eq_empty, diff_empty]
exact subset_closure |
.lake/packages/mathlib/Mathlib/MeasureTheory/Order/Lattice.lean | import Mathlib.MeasureTheory.Measure.AEMeasurable
/-!
# Typeclasses for measurability of lattice operations
In this file we define classes `MeasurableSup` and `MeasurableInf` and prove dot-style
lemmas (`Measurable.sup`, `AEMeasurable.sup` etc). For binary operations we define two typeclasses:
- `MeasurableSup` says that both left and right sup are measurable;
- `MeasurableSup₂` says that `fun p : α × α => p.1 ⊔ p.2` is measurable,
and similarly for other binary operations. The reason for introducing these classes is that in case
of topological space `α` equipped with the Borel `σ`-algebra, instances for `MeasurableSup₂`
etc. require `α` to have a second countable topology.
For instances relating, e.g., `ContinuousSup` to `MeasurableSup` see file
`MeasureTheory.BorelSpace`.
## Tags
measurable function, lattice operation
-/
open MeasureTheory
/-- We say that a type has `MeasurableSup` if `(c ⊔ ·)` and `(· ⊔ c)` are measurable functions.
For a typeclass assuming measurability of `uncurry (· ⊔ ·)` see `MeasurableSup₂`. -/
class MeasurableSup (M : Type*) [MeasurableSpace M] [Max M] : Prop where
measurable_const_sup : ∀ c : M, Measurable (c ⊔ ·)
measurable_sup_const : ∀ c : M, Measurable (· ⊔ c)
/-- We say that a type has `MeasurableSup₂` if `uncurry (· ⊔ ·)` is a measurable functions.
For a typeclass assuming measurability of `(c ⊔ ·)` and `(· ⊔ c)` see `MeasurableSup`. -/
class MeasurableSup₂ (M : Type*) [MeasurableSpace M] [Max M] : Prop where
measurable_sup : Measurable fun p : M × M => p.1 ⊔ p.2
export MeasurableSup₂ (measurable_sup)
export MeasurableSup (measurable_const_sup measurable_sup_const)
/-- We say that a type has `MeasurableInf` if `(c ⊓ ·)` and `(· ⊓ c)` are measurable functions.
For a typeclass assuming measurability of `uncurry (· ⊓ ·)` see `MeasurableInf₂`. -/
class MeasurableInf (M : Type*) [MeasurableSpace M] [Min M] : Prop where
measurable_const_inf : ∀ c : M, Measurable (c ⊓ ·)
measurable_inf_const : ∀ c : M, Measurable (· ⊓ c)
/-- We say that a type has `MeasurableInf₂` if `uncurry (· ⊓ ·)` is a measurable functions.
For a typeclass assuming measurability of `(c ⊓ ·)` and `(· ⊓ c)` see `MeasurableInf`. -/
class MeasurableInf₂ (M : Type*) [MeasurableSpace M] [Min M] : Prop where
measurable_inf : Measurable fun p : M × M => p.1 ⊓ p.2
export MeasurableInf₂ (measurable_inf)
export MeasurableInf (measurable_const_inf measurable_inf_const)
variable {M : Type*} [MeasurableSpace M]
section OrderDual
instance (priority := 100) OrderDual.instMeasurableSup [Min M] [MeasurableInf M] :
MeasurableSup Mᵒᵈ :=
⟨@measurable_const_inf M _ _ _, @measurable_inf_const M _ _ _⟩
instance (priority := 100) OrderDual.instMeasurableInf [Max M] [MeasurableSup M] :
MeasurableInf Mᵒᵈ :=
⟨@measurable_const_sup M _ _ _, @measurable_sup_const M _ _ _⟩
instance (priority := 100) OrderDual.instMeasurableSup₂ [Min M] [MeasurableInf₂ M] :
MeasurableSup₂ Mᵒᵈ :=
⟨@measurable_inf M _ _ _⟩
instance (priority := 100) OrderDual.instMeasurableInf₂ [Max M] [MeasurableSup₂ M] :
MeasurableInf₂ Mᵒᵈ :=
⟨@measurable_sup M _ _ _⟩
end OrderDual
variable {α : Type*} {m : MeasurableSpace α} {μ : Measure α} {f g : α → M}
section Sup
variable [Max M]
section MeasurableSup
variable [MeasurableSup M]
@[measurability]
theorem Measurable.const_sup (hf : Measurable f) (c : M) : Measurable fun x => c ⊔ f x :=
(measurable_const_sup c).comp hf
@[measurability]
theorem AEMeasurable.const_sup (hf : AEMeasurable f μ) (c : M) :
AEMeasurable (fun x => c ⊔ f x) μ :=
(MeasurableSup.measurable_const_sup c).comp_aemeasurable hf
@[measurability]
theorem Measurable.sup_const (hf : Measurable f) (c : M) : Measurable fun x => f x ⊔ c :=
(measurable_sup_const c).comp hf
@[measurability]
theorem AEMeasurable.sup_const (hf : AEMeasurable f μ) (c : M) :
AEMeasurable (fun x => f x ⊔ c) μ :=
(measurable_sup_const c).comp_aemeasurable hf
end MeasurableSup
section MeasurableSup₂
variable [MeasurableSup₂ M]
@[measurability]
theorem Measurable.sup' (hf : Measurable f) (hg : Measurable g) : Measurable (f ⊔ g) :=
measurable_sup.comp (hf.prodMk hg)
@[measurability]
theorem Measurable.sup (hf : Measurable f) (hg : Measurable g) : Measurable fun a => f a ⊔ g a :=
measurable_sup.comp (hf.prodMk hg)
@[measurability]
theorem AEMeasurable.sup' (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
AEMeasurable (f ⊔ g) μ :=
measurable_sup.comp_aemeasurable (hf.prodMk hg)
@[measurability]
theorem AEMeasurable.sup (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
AEMeasurable (fun a => f a ⊔ g a) μ :=
measurable_sup.comp_aemeasurable (hf.prodMk hg)
instance (priority := 100) MeasurableSup₂.toMeasurableSup : MeasurableSup M :=
⟨fun _ => measurable_const.sup measurable_id, fun _ => measurable_id.sup measurable_const⟩
end MeasurableSup₂
end Sup
section Inf
variable [Min M]
section MeasurableInf
variable [MeasurableInf M]
@[measurability]
theorem Measurable.const_inf (hf : Measurable f) (c : M) : Measurable fun x => c ⊓ f x :=
(measurable_const_inf c).comp hf
@[measurability]
theorem AEMeasurable.const_inf (hf : AEMeasurable f μ) (c : M) :
AEMeasurable (fun x => c ⊓ f x) μ :=
(MeasurableInf.measurable_const_inf c).comp_aemeasurable hf
@[measurability]
theorem Measurable.inf_const (hf : Measurable f) (c : M) : Measurable fun x => f x ⊓ c :=
(measurable_inf_const c).comp hf
@[measurability]
theorem AEMeasurable.inf_const (hf : AEMeasurable f μ) (c : M) :
AEMeasurable (fun x => f x ⊓ c) μ :=
(measurable_inf_const c).comp_aemeasurable hf
end MeasurableInf
section MeasurableInf₂
variable [MeasurableInf₂ M]
@[measurability]
theorem Measurable.inf' (hf : Measurable f) (hg : Measurable g) : Measurable (f ⊓ g) :=
measurable_inf.comp (hf.prodMk hg)
@[measurability]
theorem Measurable.inf (hf : Measurable f) (hg : Measurable g) : Measurable fun a => f a ⊓ g a :=
measurable_inf.comp (hf.prodMk hg)
@[measurability]
theorem AEMeasurable.inf' (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
AEMeasurable (f ⊓ g) μ :=
measurable_inf.comp_aemeasurable (hf.prodMk hg)
@[measurability]
theorem AEMeasurable.inf (hf : AEMeasurable f μ) (hg : AEMeasurable g μ) :
AEMeasurable (fun a => f a ⊓ g a) μ :=
measurable_inf.comp_aemeasurable (hf.prodMk hg)
instance (priority := 100) MeasurableInf₂.to_hasMeasurableInf : MeasurableInf M :=
⟨fun _ => measurable_const.inf measurable_id, fun _ => measurable_id.inf measurable_const⟩
end MeasurableInf₂
end Inf
section SemilatticeSup
open Finset
variable {δ : Type*} [MeasurableSpace δ] [SemilatticeSup α] [MeasurableSup₂ α]
@[measurability]
theorem Finset.measurable_sup' {ι : Type*} {s : Finset ι} (hs : s.Nonempty) {f : ι → δ → α}
(hf : ∀ n ∈ s, Measurable (f n)) : Measurable (s.sup' hs f) :=
Finset.sup'_induction hs _ (fun _f hf _g hg => hf.sup hg) fun n hn => hf n hn
@[measurability]
theorem Finset.measurable_range_sup' {f : ℕ → δ → α} {n : ℕ} (hf : ∀ k ≤ n, Measurable (f k)) :
Measurable ((range (n + 1)).sup' nonempty_range_add_one f) := by
simp_rw [← Nat.lt_succ_iff] at hf
refine Finset.measurable_sup' _ ?_
simpa [Finset.mem_range]
@[measurability]
theorem Finset.measurable_range_sup'' {f : ℕ → δ → α} {n : ℕ} (hf : ∀ k ≤ n, Measurable (f k)) :
Measurable fun x => (range (n + 1)).sup' nonempty_range_add_one fun k => f k x := by
convert Finset.measurable_range_sup' hf using 1
ext x
simp
end SemilatticeSup |
.lake/packages/mathlib/Mathlib/MeasureTheory/Order/Group/Lattice.lean | import Mathlib.Algebra.Order.Group.PosPart
import Mathlib.MeasureTheory.Group.Arithmetic
import Mathlib.MeasureTheory.Order.Lattice
/-!
# Measurability results on groups with a lattice structure.
## Tags
measurable function, group, lattice operation
-/
variable {α β : Type*} [Lattice α] [Group α] [MeasurableSpace α]
[MeasurableSpace β] {f : β → α}
@[to_additive (attr := measurability)]
theorem measurable_oneLePart [MeasurableSup α] : Measurable (oneLePart : α → α) :=
measurable_sup_const _
@[to_additive (attr := measurability)]
protected theorem Measurable.oneLePart [MeasurableSup α] (hf : Measurable f) :
Measurable fun x ↦ oneLePart (f x) :=
measurable_oneLePart.comp hf
variable [MeasurableInv α]
@[to_additive (attr := measurability)]
theorem measurable_leOnePart [MeasurableSup α] : Measurable (leOnePart : α → α) :=
(measurable_sup_const _).comp measurable_inv
@[to_additive (attr := measurability)]
protected theorem Measurable.leOnePart [MeasurableSup α] (hf : Measurable f) :
Measurable fun x ↦ leOnePart (f x) :=
measurable_leOnePart.comp hf
variable [MeasurableSup₂ α]
@[to_additive (attr := measurability)]
theorem measurable_mabs : Measurable (mabs : α → α) :=
measurable_id'.sup measurable_inv
@[to_additive (attr := measurability, fun_prop)]
protected theorem Measurable.mabs (hf : Measurable f) : Measurable fun x ↦ mabs (f x) :=
measurable_mabs.comp hf
@[to_additive (attr := measurability, fun_prop)]
protected theorem AEMeasurable.mabs {μ : MeasureTheory.Measure β} (hf : AEMeasurable f μ) :
AEMeasurable (fun x ↦ mabs (f x)) μ :=
measurable_mabs.comp_aemeasurable hf |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/Caratheodory.lean | import Mathlib.MeasureTheory.OuterMeasure.OfFunction
import Mathlib.MeasureTheory.PiSystem
/-!
# The Caratheodory σ-algebra of an outer measure
Given an outer measure `m`, the Carathéodory-measurable sets are the sets `s` such that
for all sets `t` we have `m t = m (t ∩ s) + m (t \ s)`. This forms a measurable space.
## Main definitions and statements
* `MeasureTheory.OuterMeasure.caratheodory` is the Carathéodory-measurable space
of an outer measure.
## References
* <https://en.wikipedia.org/wiki/Outer_measure>
* <https://en.wikipedia.org/wiki/Carath%C3%A9odory%27s_criterion>
## Tags
Carathéodory-measurable, Carathéodory's criterion
-/
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
namespace OuterMeasure
section CaratheodoryMeasurable
universe u
variable {α : Type u} (m : OuterMeasure α)
attribute [local simp] Set.inter_comm Set.inter_left_comm Set.inter_assoc
variable {s s₁ s₂ : Set α}
/-- A set `s` is Carathéodory-measurable for an outer measure `m` if for all sets `t` we have
`m t = m (t ∩ s) + m (t \ s)`. -/
def IsCaratheodory (s : Set α) : Prop :=
∀ t, m t = m (t ∩ s) + m (t \ s)
theorem isCaratheodory_iff_le' {s : Set α} :
IsCaratheodory m s ↔ ∀ t, m (t ∩ s) + m (t \ s) ≤ m t :=
forall_congr' fun _ => le_antisymm_iff.trans <| and_iff_right <| measure_le_inter_add_diff _ _ _
@[simp]
theorem isCaratheodory_empty : IsCaratheodory m ∅ := by simp [IsCaratheodory, diff_empty]
theorem isCaratheodory_compl : IsCaratheodory m s₁ → IsCaratheodory m s₁ᶜ := by
simp [IsCaratheodory, diff_eq, add_comm]
@[simp]
theorem isCaratheodory_compl_iff : IsCaratheodory m sᶜ ↔ IsCaratheodory m s :=
⟨fun h => by simpa using isCaratheodory_compl m h, isCaratheodory_compl m⟩
theorem isCaratheodory_union (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
IsCaratheodory m (s₁ ∪ s₂) := fun t => by
rw [h₁ t, h₂ (t ∩ s₁), h₂ (t \ s₁), h₁ (t ∩ (s₁ ∪ s₂)), inter_diff_assoc _ _ s₁,
Set.inter_assoc _ _ s₁, inter_eq_self_of_subset_right Set.subset_union_left,
union_diff_left, h₂ (t ∩ s₁)]
simp [diff_eq, add_assoc]
variable {m} in
lemma IsCaratheodory.biUnion_of_finite {ι : Type*} {s : ι → Set α} {t : Set ι} (ht : t.Finite)
(h : ∀ i ∈ t, m.IsCaratheodory (s i)) :
m.IsCaratheodory (⋃ i ∈ t, s i) := by
classical
lift t to Finset ι using ht
induction t using Finset.induction_on with
| empty => simp
| insert i t hi IH =>
simp only [Finset.mem_coe, Finset.mem_insert, iUnion_iUnion_eq_or_left] at h ⊢
exact m.isCaratheodory_union (h _ <| Or.inl rfl) (IH fun _ hj ↦ h _ <| Or.inr hj)
theorem measure_inter_union (h : s₁ ∩ s₂ ⊆ ∅) (h₁ : IsCaratheodory m s₁) {t : Set α} :
m (t ∩ (s₁ ∪ s₂)) = m (t ∩ s₁) + m (t ∩ s₂) := by
rw [h₁, Set.inter_assoc, Set.union_inter_cancel_left, inter_diff_assoc, union_diff_cancel_left h]
theorem isCaratheodory_iUnion_lt {s : ℕ → Set α} :
∀ {n : ℕ}, (∀ i < n, IsCaratheodory m (s i)) → IsCaratheodory m (⋃ i < n, s i)
| 0, _ => by simp
| n + 1, h => by
rw [biUnion_lt_succ]
exact isCaratheodory_union m
(isCaratheodory_iUnion_lt fun i hi => h i <| lt_of_lt_of_le hi <| Nat.le_succ _)
(h n (le_refl (n + 1)))
theorem isCaratheodory_inter (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
IsCaratheodory m (s₁ ∩ s₂) := by
rw [← isCaratheodory_compl_iff, Set.compl_inter]
exact isCaratheodory_union _ (isCaratheodory_compl _ h₁) (isCaratheodory_compl _ h₂)
lemma isCaratheodory_diff (h₁ : IsCaratheodory m s₁) (h₂ : IsCaratheodory m s₂) :
IsCaratheodory m (s₁ \ s₂) := m.isCaratheodory_inter h₁ (m.isCaratheodory_compl h₂)
lemma isCaratheodory_partialSups {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
{s : ι → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ι) :
m.IsCaratheodory (partialSups s i) := by
simpa only [partialSups_apply, Finset.sup'_eq_sup, Finset.sup_set_eq_biUnion, ← Finset.mem_coe,
Finset.coe_Iic] using .biUnion_of_finite (finite_Iic _) (fun j _ ↦ h j)
lemma isCaratheodory_disjointed {ι : Type*} [Preorder ι] [LocallyFiniteOrderBot ι]
{s : ι → Set α} (h : ∀ i, m.IsCaratheodory (s i)) (i : ι) :
m.IsCaratheodory (disjointed s i) :=
disjointedRec (fun _ j ht ↦ m.isCaratheodory_diff ht <| h j) (h i)
theorem isCaratheodory_sum {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i))
(hd : Pairwise (Disjoint on s)) {t : Set α} :
∀ {n}, (∑ i ∈ Finset.range n, m (t ∩ s i)) = m (t ∩ ⋃ i < n, s i)
| 0 => by simp
| Nat.succ n => by
rw [biUnion_lt_succ, Finset.sum_range_succ, Set.union_comm, isCaratheodory_sum h hd,
m.measure_inter_union _ (h n), add_comm]
intro a
simpa using fun (h₁ : a ∈ s n) i (hi : i < n) h₂ => (hd (ne_of_gt hi)).le_bot ⟨h₁, h₂⟩
/-- Use `isCaratheodory_iUnion` instead, which does not require the disjoint assumption. -/
theorem isCaratheodory_iUnion_of_disjoint {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i))
(hd : Pairwise (Disjoint on s)) : IsCaratheodory m (⋃ i, s i) := by
apply (isCaratheodory_iff_le' m).mpr
intro t
have hp : m (t ∩ ⋃ i, s i) ≤ ⨆ n, m (t ∩ ⋃ i < n, s i) := by
convert measure_iUnion_le (μ := m) fun i => t ∩ s i using 1
· simp [inter_iUnion]
· simp [ENNReal.tsum_eq_iSup_nat, isCaratheodory_sum m h hd]
grw [hp, ENNReal.iSup_add]
refine iSup_le fun n => ?_
rw [isCaratheodory_iUnion_lt _ (fun i _ => h i) t (n := n)]
gcongr with i
exact iUnion_subset fun _ => .rfl
lemma isCaratheodory_iUnion {s : ℕ → Set α} (h : ∀ i, m.IsCaratheodory (s i)) :
m.IsCaratheodory (⋃ i, s i) := by
rw [← iUnion_disjointed]
exact m.isCaratheodory_iUnion_of_disjoint (m.isCaratheodory_disjointed h)
(disjoint_disjointed _)
theorem f_iUnion {s : ℕ → Set α} (h : ∀ i, IsCaratheodory m (s i)) (hd : Pairwise (Disjoint on s)) :
m (⋃ i, s i) = ∑' i, m (s i) := by
refine le_antisymm (measure_iUnion_le s) ?_
rw [ENNReal.tsum_eq_iSup_nat]
refine iSup_le fun n => ?_
have := @isCaratheodory_sum _ m _ h hd univ n
simp only [inter_comm, inter_univ, univ_inter] at this; simp only [this]
exact m.mono (iUnion₂_subset fun i _ => subset_iUnion _ i)
/-- The Carathéodory-measurable sets for an outer measure `m` form a Dynkin system. -/
def caratheodoryDynkin : MeasurableSpace.DynkinSystem α where
Has := IsCaratheodory m
has_empty := isCaratheodory_empty m
has_compl s := isCaratheodory_compl m s
has_iUnion_nat _ hf hn := by apply isCaratheodory_iUnion m hf
/-- Given an outer measure `μ`, the Carathéodory-measurable space is
defined such that `s` is measurable if `∀ t, μ t = μ (t ∩ s) + μ (t \ s)`. -/
protected def caratheodory : MeasurableSpace α := by
apply MeasurableSpace.DynkinSystem.toMeasurableSpace (caratheodoryDynkin m)
intro s₁ s₂
apply isCaratheodory_inter
theorem isCaratheodory_iff {s : Set α} :
MeasurableSet[OuterMeasure.caratheodory m] s ↔ ∀ t, m t = m (t ∩ s) + m (t \ s) :=
Iff.rfl
theorem isCaratheodory_iff_le {s : Set α} :
MeasurableSet[OuterMeasure.caratheodory m] s ↔ ∀ t, m (t ∩ s) + m (t \ s) ≤ m t :=
isCaratheodory_iff_le' m
protected theorem iUnion_eq_of_caratheodory {s : ℕ → Set α}
(h : ∀ i, MeasurableSet[OuterMeasure.caratheodory m] (s i)) (hd : Pairwise (Disjoint on s)) :
m (⋃ i, s i) = ∑' i, m (s i) :=
f_iUnion m h hd
end CaratheodoryMeasurable
variable {α : Type*}
theorem ofFunction_caratheodory {m : Set α → ℝ≥0∞} {s : Set α} {h₀ : m ∅ = 0}
(hs : ∀ t, m (t ∩ s) + m (t \ s) ≤ m t) :
MeasurableSet[(OuterMeasure.ofFunction m h₀).caratheodory] s := by
apply (isCaratheodory_iff_le _).mpr
refine fun t => le_iInf fun f => le_iInf fun hf => ?_
refine
le_trans
(add_le_add ((iInf_le_of_le fun i => f i ∩ s) <| iInf_le _ ?_)
((iInf_le_of_le fun i => f i \ s) <| iInf_le _ ?_))
?_
· rw [← iUnion_inter]
exact inter_subset_inter_left _ hf
· rw [← iUnion_diff]
exact diff_subset_diff_left hf
· rw [← ENNReal.tsum_add]
exact ENNReal.tsum_le_tsum fun i => hs _
theorem boundedBy_caratheodory {m : Set α → ℝ≥0∞} {s : Set α}
(hs : ∀ t, m (t ∩ s) + m (t \ s) ≤ m t) : MeasurableSet[(boundedBy m).caratheodory] s := by
apply ofFunction_caratheodory; intro t
rcases t.eq_empty_or_nonempty with h | h
· simp [h, Set.not_nonempty_empty]
· convert le_trans _ (hs t)
· simp [h]
exact add_le_add iSup_const_le iSup_const_le
@[simp]
theorem zero_caratheodory : (0 : OuterMeasure α).caratheodory = ⊤ :=
top_unique fun _ _ _ => (add_zero _).symm
theorem top_caratheodory : (⊤ : OuterMeasure α).caratheodory = ⊤ :=
top_unique fun s _ =>
(isCaratheodory_iff_le _).2 fun t =>
t.eq_empty_or_nonempty.elim (fun ht => by simp [ht]) fun ht => by
simp only [ht, top_apply, le_top]
theorem le_add_caratheodory (m₁ m₂ : OuterMeasure α) :
m₁.caratheodory ⊓ m₂.caratheodory ≤ (m₁ + m₂ : OuterMeasure α).caratheodory :=
fun s ⟨hs₁, hs₂⟩ t => by simp [hs₁ t, hs₂ t, add_left_comm, add_assoc]
theorem le_sum_caratheodory {ι} (m : ι → OuterMeasure α) :
⨅ i, (m i).caratheodory ≤ (sum m).caratheodory := fun s h t => by
simp [fun i => MeasurableSpace.measurableSet_iInf.1 h i t, ENNReal.tsum_add]
theorem le_smul_caratheodory (a : ℝ≥0∞) (m : OuterMeasure α) :
m.caratheodory ≤ (a • m).caratheodory := fun s h t => by
simp only [smul_apply, smul_eq_mul]
rw [(isCaratheodory_iff m).mp h t]
simp [mul_add]
@[simp]
theorem dirac_caratheodory (a : α) : (dirac a).caratheodory = ⊤ :=
top_unique fun s _ t => by
by_cases ht : a ∈ t; swap; · simp [ht]
by_cases hs : a ∈ s <;> simp [*]
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/BorelCantelli.lean | import Mathlib.MeasureTheory.OuterMeasure.AE
/-!
# Borel-Cantelli lemma, part 1
In this file we show one implication of the **Borel-Cantelli lemma**:
if `s i` is a countable family of sets such that `∑' i, μ (s i)` is finite,
then a.e. all points belong to finitely many sets of the family.
We prove several versions of this lemma:
- `MeasureTheory.ae_finite_setOf_mem`: as stated above;
- `MeasureTheory.measure_limsup_cofinite_eq_zero`:
in terms of `Filter.limsup` along `Filter.cofinite`;
- `MeasureTheory.measure_limsup_atTop_eq_zero`:
in terms of `Filter.limsup` along `(Filter.atTop : Filter ℕ)`.
For the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),
see `ProbabilityTheory.measure_limsup_eq_one`.
-/
open Filter Set
open scoped ENNReal Topology
namespace MeasureTheory
variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] [Countable ι] {μ : F}
/-- One direction of the **Borel-Cantelli lemma**
(sometimes called the "*first* Borel-Cantelli lemma"):
if `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,
then the limit superior of the `s i` along the cofinite filter is a null set.
Note: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),
see `ProbabilityTheory.measure_limsup_eq_one`. -/
theorem measure_limsup_cofinite_eq_zero {s : ι → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :
μ (limsup s cofinite) = 0 := by
refine bot_unique <| ge_of_tendsto' (ENNReal.tendsto_tsum_compl_atTop_zero hs) fun t ↦ ?_
calc
μ (limsup s cofinite) ≤ μ (⋃ i : {i // i ∉ t}, s i) := by
gcongr
rw [hasBasis_cofinite.limsup_eq_iInf_iSup, iUnion_subtype]
exact iInter₂_subset _ t.finite_toSet
_ ≤ ∑' i : {i // i ∉ t}, μ (s i) := measure_iUnion_le _
/-- One direction of the **Borel-Cantelli lemma**
(sometimes called the "*first* Borel-Cantelli lemma"):
if `(s i)` is a sequence of sets such that `∑' i, μ (s i)` is finite,
then the limit superior of the `s i` along the `atTop` filter is a null set.
Note: for the *second* Borel-Cantelli lemma (applying to independent sets in a probability space),
see `ProbabilityTheory.measure_limsup_eq_one`. -/
theorem measure_limsup_atTop_eq_zero {s : ℕ → Set α} (hs : ∑' i, μ (s i) ≠ ∞) :
μ (limsup s atTop) = 0 := by
rw [← Nat.cofinite_eq_atTop, measure_limsup_cofinite_eq_zero hs]
/-- One direction of the **Borel-Cantelli lemma**
(sometimes called the "*first* Borel-Cantelli lemma"):
if `(s i)` is a countable family of sets such that `∑' i, μ (s i)` is finite,
then a.e. all points belong to finitely sets of the family. -/
theorem ae_finite_setOf_mem {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :
∀ᵐ x ∂μ, {i | x ∈ s i}.Finite := by
rw [ae_iff, ← measure_limsup_cofinite_eq_zero h]
congr 1 with x
simp [mem_limsup_iff_frequently_mem, Filter.Frequently]
/-- A version of the **Borel-Cantelli lemma**: if `pᵢ` is a sequence of predicates such that
`∑' i, μ {x | pᵢ x}` is finite, then the measure of `x` such that `pᵢ x` holds frequently as `i → ∞`
(or equivalently, `pᵢ x` holds for infinitely many `i`) is equal to zero. -/
theorem measure_setOf_frequently_eq_zero {p : ℕ → α → Prop} (hp : ∑' i, μ { x | p i x } ≠ ∞) :
μ { x | ∃ᶠ n in atTop, p n x } = 0 := by
simpa only [limsup_eq_iInf_iSup_of_nat, frequently_atTop, ← bex_def, setOf_forall,
setOf_exists] using measure_limsup_atTop_eq_zero hp
/-- A version of the **Borel-Cantelli lemma**: if `sᵢ` is a sequence of sets such that
`∑' i, μ sᵢ` is finite, then for almost all `x`, `x` does not belong to `sᵢ` for large `i`. -/
theorem ae_eventually_notMem {s : ℕ → Set α} (hs : (∑' i, μ (s i)) ≠ ∞) :
∀ᵐ x ∂μ, ∀ᶠ n in atTop, x ∉ s n :=
measure_setOf_frequently_eq_zero hs
@[deprecated (since := "2025-05-23")] alias ae_eventually_not_mem := ae_eventually_notMem
theorem measure_liminf_cofinite_eq_zero [Infinite ι] {s : ι → Set α} (h : ∑' i, μ (s i) ≠ ∞) :
μ (liminf s cofinite) = 0 := by
rw [← le_zero_iff, ← measure_limsup_cofinite_eq_zero h]
exact measure_mono liminf_le_limsup
theorem measure_liminf_atTop_eq_zero {s : ℕ → Set α} (h : (∑' i, μ (s i)) ≠ ∞) :
μ (liminf s atTop) = 0 := by
rw [← Nat.cofinite_eq_atTop, measure_liminf_cofinite_eq_zero h]
-- TODO: the next 2 lemmas are true for any filter with countable intersections, not only `ae`.
-- Need to specify `α := Set α` below because of diamond; see https://github.com/leanprover-community/mathlib4/pull/19041
theorem limsup_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}
(h : ∀ n, s n =ᵐ[μ] t) : limsup (α := Set α) s atTop =ᵐ[μ] t := by
simp only [eventuallyEq_set, ← eventually_countable_forall] at h
refine eventuallyEq_set.2 <| h.mono fun x hx ↦ ?_
simp [mem_limsup_iff_frequently_mem, hx]
-- Need to specify `α := Set α` above because of diamond; see https://github.com/leanprover-community/mathlib4/pull/19041
theorem liminf_ae_eq_of_forall_ae_eq (s : ℕ → Set α) {t : Set α}
(h : ∀ n, s n =ᵐ[μ] t) : liminf (α := Set α) s atTop =ᵐ[μ] t := by
simp only [eventuallyEq_set, ← eventually_countable_forall] at h
refine eventuallyEq_set.2 <| h.mono fun x hx ↦ ?_
simp only [mem_liminf_iff_eventually_mem, hx, eventually_const]
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/OfFunction.lean | import Mathlib.MeasureTheory.OuterMeasure.Operations
import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Outer measures from functions
Given an arbitrary function `m : Set α → ℝ≥0∞` that sends `∅` to `0` we can define an outer
measure on `α` that on `s` is defined to be the infimum of `∑ᵢ, m (sᵢ)` for all collections of sets
`sᵢ` that cover `s`. This is the unique maximal outer measure that is at most the given function.
Given an outer measure `m`, the Carathéodory-measurable sets are the sets `s` such that
for all sets `t` we have `m t = m (t ∩ s) + m (t \ s)`. This forms a measurable space.
## Main definitions and statements
* `OuterMeasure.boundedBy` is the greatest outer measure that is at most the given function.
If you know that the given function sends `∅` to `0`, then `OuterMeasure.ofFunction` is a
special case.
* `sInf_eq_boundedBy_sInfGen` is a characterization of the infimum of outer measures.
## References
* <https://en.wikipedia.org/wiki/Outer_measure>
* <https://en.wikipedia.org/wiki/Carath%C3%A9odory%27s_criterion>
## Tags
outer measure, Carathéodory-measurable, Carathéodory's criterion
-/
assert_not_exists Module.Basis
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
namespace OuterMeasure
section OfFunction
variable {α : Type*}
/-- Given any function `m` assigning measures to sets satisfying `m ∅ = 0`, there is
a unique maximal outer measure `μ` satisfying `μ s ≤ m s` for all `s : Set α`. -/
protected def ofFunction (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0) : OuterMeasure α :=
let μ s := ⨅ (f : ℕ → Set α) (_ : s ⊆ ⋃ i, f i), ∑' i, m (f i)
{ measureOf := μ
empty :=
le_antisymm
((iInf_le_of_le fun _ => ∅) <| iInf_le_of_le (empty_subset _) <| by simp [m_empty])
(zero_le _)
mono := fun {_ _} hs => iInf_mono fun _ => iInf_mono' fun hb => ⟨hs.trans hb, le_rfl⟩
iUnion_nat := fun s _ =>
ENNReal.le_of_forall_pos_le_add <| by
intro ε hε (hb : (∑' i, μ (s i)) < ∞)
rcases ENNReal.exists_pos_sum_of_countable (ENNReal.coe_pos.2 hε).ne' ℕ with ⟨ε', hε', hl⟩
grw [← hl]
rw [← ENNReal.tsum_add]
choose f hf using
show ∀ i, ∃ f : ℕ → Set α, (s i ⊆ ⋃ i, f i) ∧ (∑' i, m (f i)) < μ (s i) + ε' i by
intro i
have : μ (s i) < μ (s i) + ε' i :=
ENNReal.lt_add_right (ne_top_of_le_ne_top hb.ne <| ENNReal.le_tsum _)
(by simpa using (hε' i).ne')
rcases iInf_lt_iff.mp this with ⟨t, ht⟩
exists t
contrapose! ht
exact le_iInf ht
refine le_trans ?_ (ENNReal.tsum_le_tsum fun i => le_of_lt (hf i).2)
rw [← ENNReal.tsum_prod, ← Nat.pairEquiv.symm.tsum_eq]
refine iInf_le_of_le _ (iInf_le _ ?_)
apply iUnion_subset
intro i
apply Subset.trans (hf i).1
apply iUnion_subset
simp only [Nat.pairEquiv_symm_apply]
rw [iUnion_unpair]
intro j
apply subset_iUnion₂ i }
variable (m : Set α → ℝ≥0∞) (m_empty : m ∅ = 0)
/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets
`tᵢ` that cover `s`. -/
theorem ofFunction_apply (s : Set α) :
OuterMeasure.ofFunction m m_empty s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, m (t n) :=
rfl
/-- `ofFunction` of a set `s` is the infimum of `∑ᵢ, m (tᵢ)` for all collections of sets
`tᵢ` that cover `s`, with all `tᵢ` satisfying a predicate `P` such that `m` is infinite for sets
that don't satisfy `P`.
This is similar to `ofFunction_apply`, except that the sets `tᵢ` satisfy `P`.
The hypothesis `m_top` applies in particular to a function of the form `extend m'`. -/
theorem ofFunction_eq_iInf_mem {P : Set α → Prop} (m_top : ∀ s, ¬ P s → m s = ∞) (s : Set α) :
OuterMeasure.ofFunction m m_empty s =
⨅ (t : ℕ → Set α) (_ : ∀ i, P (t i)) (_ : s ⊆ ⋃ i, t i), ∑' i, m (t i) := by
rw [OuterMeasure.ofFunction_apply]
apply le_antisymm
· exact le_iInf fun t ↦ le_iInf fun _ ↦ le_iInf fun h ↦ iInf₂_le _ (by exact h)
· simp_rw [le_iInf_iff]
refine fun t ht_subset ↦ iInf_le_of_le t ?_
by_cases ht : ∀ i, P (t i)
· exact iInf_le_of_le ht (iInf_le_of_le ht_subset le_rfl)
· simp only [ht, not_false_eq_true, iInf_neg, top_le_iff]
push_neg at ht
obtain ⟨i, hti_notMem⟩ := ht
have hfi_top : m (t i) = ∞ := m_top _ hti_notMem
exact ENNReal.tsum_eq_top_of_eq_top ⟨i, hfi_top⟩
variable {m m_empty}
theorem ofFunction_le (s : Set α) : OuterMeasure.ofFunction m m_empty s ≤ m s :=
let f : ℕ → Set α := fun i => Nat.casesOn i s fun _ => ∅
iInf_le_of_le f <|
iInf_le_of_le (subset_iUnion f 0) <|
le_of_eq <| tsum_eq_single 0 <| by
rintro (_ | i)
· simp
· simp [f, m_empty]
theorem ofFunction_eq (s : Set α) (m_mono : ∀ ⦃t : Set α⦄, s ⊆ t → m s ≤ m t)
(m_subadd : ∀ s : ℕ → Set α, m (⋃ i, s i) ≤ ∑' i, m (s i)) :
OuterMeasure.ofFunction m m_empty s = m s :=
le_antisymm (ofFunction_le s) <|
le_iInf fun f => le_iInf fun hf => le_trans (m_mono hf) (m_subadd f)
theorem le_ofFunction {μ : OuterMeasure α} :
μ ≤ OuterMeasure.ofFunction m m_empty ↔ ∀ s, μ s ≤ m s :=
⟨fun H s => le_trans (H s) (ofFunction_le s), fun H _ =>
le_iInf fun f =>
le_iInf fun hs =>
le_trans (μ.mono hs) <| le_trans (measure_iUnion_le f) <| ENNReal.tsum_le_tsum fun _ => H _⟩
theorem isGreatest_ofFunction :
IsGreatest { μ : OuterMeasure α | ∀ s, μ s ≤ m s } (OuterMeasure.ofFunction m m_empty) :=
⟨fun _ => ofFunction_le _, fun _ => le_ofFunction.2⟩
theorem ofFunction_eq_sSup : OuterMeasure.ofFunction m m_empty = sSup { μ | ∀ s, μ s ≤ m s } :=
(@isGreatest_ofFunction α m m_empty).isLUB.sSup_eq.symm
/-- If `m u = ∞` for any set `u` that has nonempty intersection both with `s` and `t`, then
`μ (s ∪ t) = μ s + μ t`, where `μ = MeasureTheory.OuterMeasure.ofFunction m m_empty`.
E.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma
implies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s`
and `y ∈ t`. -/
theorem ofFunction_union_of_top_of_nonempty_inter {s t : Set α}
(h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) :
OuterMeasure.ofFunction m m_empty (s ∪ t) =
OuterMeasure.ofFunction m m_empty s + OuterMeasure.ofFunction m m_empty t := by
refine le_antisymm (measure_union_le _ _) (le_iInf₂ fun f hf ↦ ?_)
set μ := OuterMeasure.ofFunction m m_empty
rcases Classical.em (∃ i, (s ∩ f i).Nonempty ∧ (t ∩ f i).Nonempty) with (⟨i, hs, ht⟩ | he)
· calc
μ s + μ t ≤ ∞ := le_top
_ = m (f i) := (h (f i) hs ht).symm
_ ≤ ∑' i, m (f i) := ENNReal.le_tsum i
set I := fun s => { i : ℕ | (s ∩ f i).Nonempty }
have hd : Disjoint (I s) (I t) := disjoint_iff_inf_le.mpr fun i hi => he ⟨i, hi⟩
have hI : ∀ u ⊆ s ∪ t, μ u ≤ ∑' i : I u, μ (f i) := fun u hu =>
calc
μ u ≤ μ (⋃ i : I u, f i) :=
μ.mono fun x hx =>
let ⟨i, hi⟩ := mem_iUnion.1 (hf (hu hx))
mem_iUnion.2 ⟨⟨i, ⟨x, hx, hi⟩⟩, hi⟩
_ ≤ ∑' i : I u, μ (f i) := measure_iUnion_le _
calc
μ s + μ t ≤ (∑' i : I s, μ (f i)) + ∑' i : I t, μ (f i) :=
add_le_add (hI _ subset_union_left) (hI _ subset_union_right)
_ = ∑' i : ↑(I s ∪ I t), μ (f i) :=
(ENNReal.summable.tsum_union_disjoint (f := fun i => μ (f i)) hd ENNReal.summable).symm
_ ≤ ∑' i, μ (f i) :=
(ENNReal.summable.tsum_le_tsum_of_inj (↑) Subtype.coe_injective (fun _ _ => zero_le _)
(fun _ => le_rfl) ENNReal.summable)
_ ≤ ∑' i, m (f i) := ENNReal.tsum_le_tsum fun i => ofFunction_le _
theorem comap_ofFunction {β} (f : β → α) (h : Monotone m ∨ Surjective f) :
comap f (OuterMeasure.ofFunction m m_empty) =
OuterMeasure.ofFunction (fun s => m (f '' s)) (by simp; simp [m_empty]) := by
refine le_antisymm (le_ofFunction.2 fun s => ?_) fun s => ?_
· rw [comap_apply]
apply ofFunction_le
· rw [comap_apply, ofFunction_apply, ofFunction_apply]
refine iInf_mono' fun t => ⟨fun k => f ⁻¹' t k, ?_⟩
refine iInf_mono' fun ht => ?_
rw [Set.image_subset_iff, preimage_iUnion] at ht
refine ⟨ht, ENNReal.tsum_le_tsum fun n => ?_⟩
rcases h with hl | hr
exacts [hl (image_preimage_subset _ _), (congr_arg m (hr.image_preimage (t n))).le]
theorem map_ofFunction_le {β} (f : α → β) :
map f (OuterMeasure.ofFunction m m_empty) ≤
OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty :=
le_ofFunction.2 fun s => by
rw [map_apply]
apply ofFunction_le
theorem map_ofFunction {β} {f : α → β} (hf : Injective f) :
map f (OuterMeasure.ofFunction m m_empty) =
OuterMeasure.ofFunction (fun s => m (f ⁻¹' s)) m_empty := by
refine (map_ofFunction_le _).antisymm fun s => ?_
simp only [ofFunction_apply, map_apply, le_iInf_iff]
intro t ht
refine iInf_le_of_le (fun n => (range f)ᶜ ∪ f '' t n) (iInf_le_of_le ?_ ?_)
· rw [← union_iUnion, ← inter_subset, ← image_preimage_eq_inter_range, ← image_iUnion]
exact image_mono ht
· refine ENNReal.tsum_le_tsum fun n => le_of_eq ?_
simp [hf.preimage_image]
-- TODO (kmill): change `m (t ∩ s)` to `m (s ∩ t)`
theorem restrict_ofFunction (s : Set α) (hm : Monotone m) :
restrict s (OuterMeasure.ofFunction m m_empty) =
OuterMeasure.ofFunction (fun t => m (t ∩ s)) (by simp; simp [m_empty]) := by
rw [restrict]
simp only [inter_comm _ s, LinearMap.comp_apply]
rw [comap_ofFunction _ (Or.inl hm)]
simp only [map_ofFunction Subtype.coe_injective, Subtype.image_preimage_coe]
theorem smul_ofFunction {c : ℝ≥0∞} (hc : c ≠ ∞) : c • OuterMeasure.ofFunction m m_empty =
OuterMeasure.ofFunction (c • m) (by simp [m_empty]) := by
ext1 s
haveI : Nonempty { t : ℕ → Set α // s ⊆ ⋃ i, t i } := ⟨⟨fun _ => s, subset_iUnion (fun _ => s) 0⟩⟩
simp only [smul_apply, ofFunction_apply, ENNReal.tsum_mul_left, Pi.smul_apply, smul_eq_mul,
iInf_subtype']
rw [ENNReal.mul_iInf fun h => (hc h).elim]
end OfFunction
section BoundedBy
variable {α : Type*} (m : Set α → ℝ≥0∞)
/-- Given any function `m` assigning measures to sets, there is a unique maximal outer measure `μ`
satisfying `μ s ≤ m s` for all `s : Set α`. This is the same as `OuterMeasure.ofFunction`,
except that it doesn't require `m ∅ = 0`. -/
def boundedBy : OuterMeasure α :=
OuterMeasure.ofFunction (fun s => ⨆ _ : s.Nonempty, m s) (by simp [Set.not_nonempty_empty])
variable {m}
theorem boundedBy_le (s : Set α) : boundedBy m s ≤ m s :=
(ofFunction_le _).trans iSup_const_le
theorem boundedBy_eq_ofFunction (m_empty : m ∅ = 0) (s : Set α) :
boundedBy m s = OuterMeasure.ofFunction m m_empty s := by
have : (fun s : Set α => ⨆ _ : s.Nonempty, m s) = m := by
ext1 t
rcases t.eq_empty_or_nonempty with h | h <;> simp [h, Set.not_nonempty_empty, m_empty]
simp [boundedBy, this]
theorem boundedBy_apply (s : Set α) :
boundedBy m s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t),
∑' n, ⨆ _ : (t n).Nonempty, m (t n) := by
simp [boundedBy, ofFunction_apply]
theorem boundedBy_eq (s : Set α) (m_empty : m ∅ = 0) (m_mono : ∀ ⦃t : Set α⦄, s ⊆ t → m s ≤ m t)
(m_subadd : ∀ s : ℕ → Set α, m (⋃ i, s i) ≤ ∑' i, m (s i)) : boundedBy m s = m s := by
rw [boundedBy_eq_ofFunction m_empty, ofFunction_eq s m_mono m_subadd]
@[simp]
theorem boundedBy_eq_self (m : OuterMeasure α) : boundedBy m = m :=
ext fun _ => boundedBy_eq _ measure_empty (fun _ ht => measure_mono ht) measure_iUnion_le
theorem le_boundedBy {μ : OuterMeasure α} : μ ≤ boundedBy m ↔ ∀ s, μ s ≤ m s := by
rw [boundedBy, le_ofFunction, forall_congr']; intro s
rcases s.eq_empty_or_nonempty with h | h <;> simp [h, Set.not_nonempty_empty]
theorem le_boundedBy' {μ : OuterMeasure α} :
μ ≤ boundedBy m ↔ ∀ s : Set α, s.Nonempty → μ s ≤ m s := by
rw [le_boundedBy, forall_congr']
intro s
rcases s.eq_empty_or_nonempty with h | h <;> simp [h]
@[simp]
theorem boundedBy_top : boundedBy (⊤ : Set α → ℝ≥0∞) = ⊤ := by
rw [eq_top_iff, le_boundedBy']
intro s hs
rw [top_apply hs]
exact le_rfl
@[simp]
theorem boundedBy_zero : boundedBy (0 : Set α → ℝ≥0∞) = 0 := by
rw [← coe_bot, eq_bot_iff]
apply boundedBy_le
theorem smul_boundedBy {c : ℝ≥0∞} (hc : c ≠ ∞) : c • boundedBy m = boundedBy (c • m) := by
simp only [boundedBy, smul_ofFunction hc]
congr 1 with s : 1
rcases s.eq_empty_or_nonempty with (rfl | hs) <;> simp [*]
theorem comap_boundedBy {β} (f : β → α)
(h : (Monotone fun s : { s : Set α // s.Nonempty } => m s) ∨ Surjective f) :
comap f (boundedBy m) = boundedBy fun s => m (f '' s) := by
refine (comap_ofFunction _ ?_).trans ?_
· refine h.imp (fun H s t hst => iSup_le fun hs => ?_) id
have ht : t.Nonempty := hs.mono hst
exact (@H ⟨s, hs⟩ ⟨t, ht⟩ hst).trans (le_iSup (fun _ : t.Nonempty => m t) ht)
· dsimp only [boundedBy]
congr with s : 1
rw [image_nonempty]
/-- If `m u = ∞` for any set `u` that has nonempty intersection both with `s` and `t`, then
`μ (s ∪ t) = μ s + μ t`, where `μ = MeasureTheory.OuterMeasure.boundedBy m`.
E.g., if `α` is an (e)metric space and `m u = ∞` on any set of diameter `≥ r`, then this lemma
implies that `μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s`
and `y ∈ t`. -/
theorem boundedBy_union_of_top_of_nonempty_inter {s t : Set α}
(h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → m u = ∞) :
boundedBy m (s ∪ t) = boundedBy m s + boundedBy m t :=
ofFunction_union_of_top_of_nonempty_inter fun u hs ht =>
top_unique <| (h u hs ht).ge.trans <| le_iSup (fun _ => m u) (hs.mono inter_subset_right)
end BoundedBy
section sInfGen
variable {α : Type*}
/-- Given a set of outer measures, we define a new function that on a set `s` is defined to be the
infimum of `μ(s)` for the outer measures `μ` in the collection. We ensure that this
function is defined to be `0` on `∅`, even if the collection of outer measures is empty.
The outer measure generated by this function is the infimum of the given outer measures. -/
def sInfGen (m : Set (OuterMeasure α)) (s : Set α) : ℝ≥0∞ :=
⨅ (μ : OuterMeasure α) (_ : μ ∈ m), μ s
theorem sInfGen_def (m : Set (OuterMeasure α)) (t : Set α) :
sInfGen m t = ⨅ (μ : OuterMeasure α) (_ : μ ∈ m), μ t :=
rfl
theorem sInf_eq_boundedBy_sInfGen (m : Set (OuterMeasure α)) :
sInf m = OuterMeasure.boundedBy (sInfGen m) := by
refine le_antisymm ?_ ?_
· refine le_boundedBy.2 fun s => le_iInf₂ fun μ hμ => ?_
apply sInf_le hμ
· refine le_sInf ?_
intro μ hμ t
exact le_trans (boundedBy_le t) (iInf₂_le μ hμ)
theorem iSup_sInfGen_nonempty {m : Set (OuterMeasure α)} (h : m.Nonempty) (t : Set α) :
⨆ _ : t.Nonempty, sInfGen m t = ⨅ (μ : OuterMeasure α) (_ : μ ∈ m), μ t := by
rcases t.eq_empty_or_nonempty with (rfl | ht)
· simp [biInf_const h]
· simp [ht, sInfGen_def]
/-- The value of the Infimum of a nonempty set of outer measures on a set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem sInf_apply {m : Set (OuterMeasure α)} {s : Set α} (h : m.Nonempty) :
sInf m s =
⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ (μ : OuterMeasure α) (_ : μ ∈ m), μ (t n) := by
simp_rw [sInf_eq_boundedBy_sInfGen, boundedBy_apply, iSup_sInfGen_nonempty h]
/-- The value of the Infimum of a set of outer measures on a nonempty set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem sInf_apply' {m : Set (OuterMeasure α)} {s : Set α} (h : s.Nonempty) :
sInf m s =
⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ (μ : OuterMeasure α) (_ : μ ∈ m), μ (t n) :=
m.eq_empty_or_nonempty.elim (fun hm => by simp [hm, h]) sInf_apply
/-- The value of the Infimum of a nonempty family of outer measures on a set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem iInf_apply {ι} [Nonempty ι] (m : ι → OuterMeasure α) (s : Set α) :
(⨅ i, m i) s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ i, m i (t n) := by
rw [iInf, sInf_apply (range_nonempty m)]
simp only [iInf_range]
/-- The value of the Infimum of a family of outer measures on a nonempty set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem iInf_apply' {ι} (m : ι → OuterMeasure α) {s : Set α} (hs : s.Nonempty) :
(⨅ i, m i) s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ i, m i (t n) := by
rw [iInf, sInf_apply' hs]
simp only [iInf_range]
/-- The value of the Infimum of a nonempty family of outer measures on a set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem biInf_apply {ι} {I : Set ι} (hI : I.Nonempty) (m : ι → OuterMeasure α) (s : Set α) :
(⨅ i ∈ I, m i) s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ i ∈ I, m i (t n) := by
haveI := hI.to_subtype
simp only [← iInf_subtype'', iInf_apply]
/-- The value of the Infimum of a nonempty family of outer measures on a set is not simply
the minimum value of a measure on that set: it is the infimum sum of measures of countable set of
sets that covers that set, where a different measure can be used for each set in the cover. -/
theorem biInf_apply' {ι} (I : Set ι) (m : ι → OuterMeasure α) {s : Set α} (hs : s.Nonempty) :
(⨅ i ∈ I, m i) s = ⨅ (t : ℕ → Set α) (_ : s ⊆ iUnion t), ∑' n, ⨅ i ∈ I, m i (t n) := by
simp only [← iInf_subtype'', iInf_apply' _ hs]
theorem map_iInf_le {ι β} (f : α → β) (m : ι → OuterMeasure α) :
map f (⨅ i, m i) ≤ ⨅ i, map f (m i) :=
(map_mono f).map_iInf_le
theorem comap_iInf {ι β} (f : α → β) (m : ι → OuterMeasure β) :
comap f (⨅ i, m i) = ⨅ i, comap f (m i) := by
refine ext_nonempty fun s hs => ?_
refine ((comap_mono f).map_iInf_le s).antisymm ?_
simp only [comap_apply, iInf_apply' _ hs, iInf_apply' _ (hs.image _), le_iInf_iff,
Set.image_subset_iff, preimage_iUnion]
refine fun t ht => iInf_le_of_le _ (iInf_le_of_le ht <| ENNReal.tsum_le_tsum fun k => ?_)
exact iInf_mono fun i => (m i).mono (image_preimage_subset _ _)
theorem map_iInf {ι β} {f : α → β} (hf : Injective f) (m : ι → OuterMeasure α) :
map f (⨅ i, m i) = restrict (range f) (⨅ i, map f (m i)) := by
refine Eq.trans ?_ (map_comap _ _)
simp only [comap_iInf, comap_map hf]
theorem map_iInf_comap {ι β} [Nonempty ι] {f : α → β} (m : ι → OuterMeasure β) :
map f (⨅ i, comap f (m i)) = ⨅ i, map f (comap f (m i)) := by
refine (map_iInf_le _ _).antisymm fun s => ?_
simp only [map_apply, comap_apply, iInf_apply, le_iInf_iff]
refine fun t ht => iInf_le_of_le (fun n => f '' t n ∪ (range f)ᶜ) (iInf_le_of_le ?_ ?_)
· rw [← iUnion_union, Set.union_comm, ← inter_subset, ← image_iUnion, ←
image_preimage_eq_inter_range]
exact image_mono ht
· refine ENNReal.tsum_le_tsum fun n => iInf_mono fun i => (m i).mono ?_
simpa only [preimage_union, preimage_compl, preimage_range, compl_univ, union_empty,
image_subset_iff] using subset_rfl
theorem map_biInf_comap {ι β} {I : Set ι} (hI : I.Nonempty) {f : α → β} (m : ι → OuterMeasure β) :
map f (⨅ i ∈ I, comap f (m i)) = ⨅ i ∈ I, map f (comap f (m i)) := by
haveI := hI.to_subtype
rw [← iInf_subtype'', ← iInf_subtype'']
exact map_iInf_comap _
theorem restrict_iInf_restrict {ι} (s : Set α) (m : ι → OuterMeasure α) :
restrict s (⨅ i, restrict s (m i)) = restrict s (⨅ i, m i) :=
calc restrict s (⨅ i, restrict s (m i))
_ = restrict (range ((↑) : s → α)) (⨅ i, restrict s (m i)) := by rw [Subtype.range_coe]
_ = map ((↑) : s → α) (⨅ i, comap (↑) (m i)) := (map_iInf Subtype.coe_injective _).symm
_ = restrict s (⨅ i, m i) := congr_arg (map ((↑) : s → α)) (comap_iInf _ _).symm
theorem restrict_iInf {ι} [Nonempty ι] (s : Set α) (m : ι → OuterMeasure α) :
restrict s (⨅ i, m i) = ⨅ i, restrict s (m i) :=
(congr_arg (map ((↑) : s → α)) (comap_iInf _ _)).trans (map_iInf_comap _)
theorem restrict_biInf {ι} {I : Set ι} (hI : I.Nonempty) (s : Set α) (m : ι → OuterMeasure α) :
restrict s (⨅ i ∈ I, m i) = ⨅ i ∈ I, restrict s (m i) := by
haveI := hI.to_subtype
rw [← iInf_subtype'', ← iInf_subtype'']
exact restrict_iInf _ _
/-- This proves that Inf and restrict commute for outer measures, so long as the set of
outer measures is nonempty. -/
theorem restrict_sInf_eq_sInf_restrict (m : Set (OuterMeasure α)) {s : Set α} (hm : m.Nonempty) :
restrict s (sInf m) = sInf (restrict s '' m) := by
simp only [sInf_eq_iInf, restrict_biInf, hm, iInf_image]
end sInfGen
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/Basic.lean | import Mathlib.Data.Countable.Basic
import Mathlib.Data.Fin.VecNotation
import Mathlib.Order.Disjointed
import Mathlib.MeasureTheory.OuterMeasure.Defs
import Mathlib.Topology.Instances.ENNReal.Lemmas
/-!
# Outer Measures
An outer measure is a function `μ : Set α → ℝ≥0∞`, from the powerset of a type to the extended
nonnegative real numbers that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is monotone;
3. `μ` is countably subadditive. This means that the outer measure of a countable union is at most
the sum of the outer measure on the individual sets.
Note that we do not need `α` to be measurable to define an outer measure.
## References
<https://en.wikipedia.org/wiki/Outer_measure>
## Tags
outer measure
-/
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
section OuterMeasureClass
variable {α ι F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α]
{μ : F} {s t : Set α}
@[simp]
theorem measure_empty : μ ∅ = 0 := OuterMeasureClass.measure_empty μ
@[mono, gcongr]
theorem measure_mono (h : s ⊆ t) : μ s ≤ μ t :=
OuterMeasureClass.measure_mono μ h
theorem measure_mono_null (h : s ⊆ t) (ht : μ t = 0) : μ s = 0 :=
eq_bot_mono (measure_mono h) ht
lemma pos_mono ⦃s t : Set α⦄ (h : s ⊆ t) (hs : 0 < μ s) :
0 < μ t := hs.trans_le <| measure_mono h
lemma measure_eq_top_mono (h : s ⊆ t) (hs : μ s = ∞) : μ t = ∞ := eq_top_mono (measure_mono h) hs
lemma measure_lt_top_mono (h : s ⊆ t) (ht : μ t < ∞) : μ s < ∞ := (measure_mono h).trans_lt ht
theorem measure_pos_of_superset (h : s ⊆ t) (hs : μ s ≠ 0) : 0 < μ t :=
hs.bot_lt.trans_le (measure_mono h)
theorem measure_iUnion_le [Countable ι] (s : ι → Set α) : μ (⋃ i, s i) ≤ ∑' i, μ (s i) := by
refine rel_iSup_tsum μ measure_empty (· ≤ ·) (fun t ↦ ?_) _
calc
μ (⋃ i, t i) = μ (⋃ i, disjointed t i) := by rw [iUnion_disjointed]
_ ≤ ∑' i, μ (disjointed t i) :=
OuterMeasureClass.measure_iUnion_nat_le _ _ (disjoint_disjointed _)
_ ≤ ∑' i, μ (t i) := by gcongr; exact disjointed_subset ..
theorem measure_biUnion_le {I : Set ι} (μ : F) (hI : I.Countable) (s : ι → Set α) :
μ (⋃ i ∈ I, s i) ≤ ∑' i : I, μ (s i) := by
have := hI.to_subtype
rw [biUnion_eq_iUnion]
apply measure_iUnion_le
theorem measure_biUnion_finset_le (I : Finset ι) (s : ι → Set α) :
μ (⋃ i ∈ I, s i) ≤ ∑ i ∈ I, μ (s i) :=
(measure_biUnion_le μ I.countable_toSet s).trans_eq <| I.tsum_subtype (μ <| s ·)
theorem measure_iUnion_fintype_le [Fintype ι] (μ : F) (s : ι → Set α) :
μ (⋃ i, s i) ≤ ∑ i, μ (s i) := by
simpa using measure_biUnion_finset_le Finset.univ s
theorem measure_union_le (s t : Set α) : μ (s ∪ t) ≤ μ s + μ t := by
simpa [union_eq_iUnion] using measure_iUnion_fintype_le μ (cond · s t)
lemma measure_univ_le_add_compl (s : Set α) : μ univ ≤ μ s + μ sᶜ :=
s.union_compl_self ▸ measure_union_le s sᶜ
theorem measure_le_inter_add_diff (μ : F) (s t : Set α) : μ s ≤ μ (s ∩ t) + μ (s \ t) := by
simpa using measure_union_le (s ∩ t) (s \ t)
theorem measure_diff_null (ht : μ t = 0) : μ (s \ t) = μ s :=
(measure_mono diff_subset).antisymm <| calc
μ s ≤ μ (s ∩ t) + μ (s \ t) := measure_le_inter_add_diff _ _ _
_ ≤ μ t + μ (s \ t) := by gcongr; apply inter_subset_right
_ = μ (s \ t) := by simp [ht]
theorem measure_biUnion_null_iff {I : Set ι} (hI : I.Countable) {s : ι → Set α} :
μ (⋃ i ∈ I, s i) = 0 ↔ ∀ i ∈ I, μ (s i) = 0 := by
refine ⟨fun h i hi ↦ measure_mono_null (subset_biUnion_of_mem hi) h, fun h ↦ ?_⟩
have _ := hI.to_subtype
simpa [h] using measure_iUnion_le (μ := μ) fun x : I ↦ s x
theorem measure_sUnion_null_iff {S : Set (Set α)} (hS : S.Countable) :
μ (⋃₀ S) = 0 ↔ ∀ s ∈ S, μ s = 0 := by
rw [sUnion_eq_biUnion, measure_biUnion_null_iff hS]
@[simp]
theorem measure_iUnion_null_iff {ι : Sort*} [Countable ι] {s : ι → Set α} :
μ (⋃ i, s i) = 0 ↔ ∀ i, μ (s i) = 0 := by
rw [← sUnion_range, measure_sUnion_null_iff (countable_range s), forall_mem_range]
alias ⟨_, measure_iUnion_null⟩ := measure_iUnion_null_iff
@[simp]
theorem measure_union_null_iff : μ (s ∪ t) = 0 ↔ μ s = 0 ∧ μ t = 0 := by
simp [union_eq_iUnion, and_comm]
theorem measure_union_null (hs : μ s = 0) (ht : μ t = 0) : μ (s ∪ t) = 0 := by simp [*]
lemma measure_null_iff_singleton (hs : s.Countable) : μ s = 0 ↔ ∀ x ∈ s, μ {x} = 0 := by
rw [← measure_biUnion_null_iff hs, biUnion_of_singleton]
/-- Let `μ` be an (outer) measure; let `s : ι → Set α` be a sequence of sets, `S = ⋃ n, s n`.
If `μ (S \ s n)` tends to zero along some nontrivial filter (usually `Filter.atTop` on `ι = ℕ`),
then `μ S = ⨆ n, μ (s n)`. -/
theorem measure_iUnion_of_tendsto_zero {ι} (μ : F) {s : ι → Set α} (l : Filter ι) [NeBot l]
(h0 : Tendsto (fun k => μ ((⋃ n, s n) \ s k)) l (𝓝 0)) : μ (⋃ n, s n) = ⨆ n, μ (s n) := by
refine le_antisymm ?_ <| iSup_le fun n ↦ measure_mono <| subset_iUnion _ _
set S := ⋃ n, s n
set M := ⨆ n, μ (s n)
have A : ∀ k, μ S ≤ M + μ (S \ s k) := fun k ↦ calc
μ S ≤ μ (S ∩ s k) + μ (S \ s k) := measure_le_inter_add_diff _ _ _
_ ≤ μ (s k) + μ (S \ s k) := by gcongr; apply inter_subset_right
_ ≤ M + μ (S \ s k) := by gcongr; exact le_iSup (μ ∘ s) k
have B : Tendsto (fun k ↦ M + μ (S \ s k)) l (𝓝 M) := by simpa using tendsto_const_nhds.add h0
exact ge_of_tendsto' B A
/-- If a set has zero measure in a neighborhood of each of its points, then it has zero measure
in a second-countable space. -/
theorem measure_null_of_locally_null [TopologicalSpace α] [SecondCountableTopology α]
(s : Set α) (hs : ∀ x ∈ s, ∃ u ∈ 𝓝[s] x, μ u = 0) : μ s = 0 := by
choose! u hxu hu₀ using hs
choose t ht using TopologicalSpace.countable_cover_nhdsWithin hxu
rcases ht with ⟨ts, t_count, ht⟩
apply measure_mono_null ht
exact (measure_biUnion_null_iff t_count).2 fun x hx => hu₀ x (ts hx)
/-- If `m s ≠ 0`, then for some point `x ∈ s` and any `t ∈ 𝓝[s] x` we have `0 < m t`. -/
theorem exists_mem_forall_mem_nhdsWithin_pos_measure [TopologicalSpace α]
[SecondCountableTopology α] {s : Set α} (hs : μ s ≠ 0) :
∃ x ∈ s, ∀ t ∈ 𝓝[s] x, 0 < μ t := by
contrapose! hs
simp only [nonpos_iff_eq_zero] at hs
exact measure_null_of_locally_null s hs
end OuterMeasureClass
namespace OuterMeasure
variable {α β : Type*} {m : OuterMeasure α}
/-- If `s : ι → Set α` is a sequence of sets, `S = ⋃ n, s n`, and `m (S \ s n)` tends to zero along
some nontrivial filter (usually `atTop` on `ι = ℕ`), then `m S = ⨆ n, m (s n)`. -/
theorem iUnion_of_tendsto_zero {ι} (m : OuterMeasure α) {s : ι → Set α} (l : Filter ι) [NeBot l]
(h0 : Tendsto (fun k => m ((⋃ n, s n) \ s k)) l (𝓝 0)) : m (⋃ n, s n) = ⨆ n, m (s n) :=
measure_iUnion_of_tendsto_zero m l h0
/-- If `s : ℕ → Set α` is a monotone sequence of sets such that `∑' k, m (s (k + 1) \ s k) ≠ ∞`,
then `m (⋃ n, s n) = ⨆ n, m (s n)`. -/
theorem iUnion_nat_of_monotone_of_tsum_ne_top (m : OuterMeasure α) {s : ℕ → Set α}
(h_mono : ∀ n, s n ⊆ s (n + 1)) (h0 : (∑' k, m (s (k + 1) \ s k)) ≠ ∞) :
m (⋃ n, s n) = ⨆ n, m (s n) := by
classical
refine measure_iUnion_of_tendsto_zero m atTop ?_
refine tendsto_nhds_bot_mono' (ENNReal.tendsto_sum_nat_add _ h0) fun n => ?_
refine (m.mono ?_).trans (measure_iUnion_le _)
-- Current goal: `(⋃ k, s k) \ s n ⊆ ⋃ k, s (k + n + 1) \ s (k + n)`
have h' : Monotone s := @monotone_nat_of_le_succ (Set α) _ _ h_mono
simp only [diff_subset_iff, iUnion_subset_iff]
intro i x hx
have : ∃ i, x ∈ s i := by exists i
rcases Nat.findX this with ⟨j, hj, hlt⟩
clear hx i
rcases le_or_gt j n with hjn | hnj
· exact Or.inl (h' hjn hj)
have : j - (n + 1) + n + 1 = j := by omega
refine Or.inr (mem_iUnion.2 ⟨j - (n + 1), ?_, hlt _ ?_⟩)
· rwa [this]
· rw [← Nat.succ_le_iff, Nat.succ_eq_add_one, this]
theorem coe_fn_injective : Injective fun (μ : OuterMeasure α) (s : Set α) => μ s :=
DFunLike.coe_injective
@[ext]
theorem ext {μ₁ μ₂ : OuterMeasure α} (h : ∀ s, μ₁ s = μ₂ s) : μ₁ = μ₂ :=
DFunLike.ext _ _ h
/-- A version of `MeasureTheory.OuterMeasure.ext` that assumes `μ₁ s = μ₂ s` on all *nonempty*
sets `s`, and gets `μ₁ ∅ = μ₂ ∅` from `MeasureTheory.OuterMeasure.empty'`. -/
theorem ext_nonempty {μ₁ μ₂ : OuterMeasure α} (h : ∀ s : Set α, s.Nonempty → μ₁ s = μ₂ s) :
μ₁ = μ₂ :=
ext fun s => s.eq_empty_or_nonempty.elim (fun he => by simp [he]) (h s)
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/Operations.lean | import Mathlib.Algebra.Order.Group.Indicator
import Mathlib.MeasureTheory.OuterMeasure.Basic
/-!
# Operations on outer measures
In this file we define algebraic operations (addition, scalar multiplication)
on the type of outer measures on a type.
We also show that outer measures on a type `α` form a complete lattice.
## References
* <https://en.wikipedia.org/wiki/Outer_measure>
## Tags
outer measure
-/
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
namespace OuterMeasure
section Basic
variable {α β : Type*} {m : OuterMeasure α}
instance instZero : Zero (OuterMeasure α) :=
⟨{ measureOf := fun _ => 0
empty := rfl
mono := by intro _ _ _; exact le_refl 0
iUnion_nat := fun _ _ => zero_le _ }⟩
@[simp]
theorem coe_zero : ⇑(0 : OuterMeasure α) = 0 :=
rfl
instance instInhabited : Inhabited (OuterMeasure α) :=
⟨0⟩
instance instAdd : Add (OuterMeasure α) :=
⟨fun m₁ m₂ =>
{ measureOf := fun s => m₁ s + m₂ s
empty := show m₁ ∅ + m₂ ∅ = 0 by simp
mono := fun {_ _} h => add_le_add (m₁.mono h) (m₂.mono h)
iUnion_nat := fun s _ =>
calc
m₁ (⋃ i, s i) + m₂ (⋃ i, s i) ≤ (∑' i, m₁ (s i)) + ∑' i, m₂ (s i) :=
add_le_add (measure_iUnion_le s) (measure_iUnion_le s)
_ = _ := ENNReal.tsum_add.symm }⟩
@[simp]
theorem coe_add (m₁ m₂ : OuterMeasure α) : ⇑(m₁ + m₂) = m₁ + m₂ :=
rfl
theorem add_apply (m₁ m₂ : OuterMeasure α) (s : Set α) : (m₁ + m₂) s = m₁ s + m₂ s :=
rfl
section SMul
variable {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
variable {R' : Type*} [SMul R' ℝ≥0∞] [IsScalarTower R' ℝ≥0∞ ℝ≥0∞]
instance instSMul : SMul R (OuterMeasure α) :=
⟨fun c m =>
{ measureOf := fun s => c • m s
empty := by simp only [measure_empty]; rw [← smul_one_mul c]; simp
mono := fun {s t} h => by
rw [← smul_one_mul c, ← smul_one_mul c (m t)]
exact mul_right_mono (m.mono h)
iUnion_nat := fun s _ => by
simp_rw [← smul_one_mul c (m _), ENNReal.tsum_mul_left]
exact mul_right_mono (measure_iUnion_le _) }⟩
@[simp]
theorem coe_smul (c : R) (m : OuterMeasure α) : ⇑(c • m) = c • ⇑m :=
rfl
theorem smul_apply (c : R) (m : OuterMeasure α) (s : Set α) : (c • m) s = c • m s :=
rfl
instance instSMulCommClass [SMulCommClass R R' ℝ≥0∞] : SMulCommClass R R' (OuterMeasure α) :=
⟨fun _ _ _ => ext fun _ => smul_comm _ _ _⟩
instance instIsScalarTower [SMul R R'] [IsScalarTower R R' ℝ≥0∞] :
IsScalarTower R R' (OuterMeasure α) :=
⟨fun _ _ _ => ext fun _ => smul_assoc _ _ _⟩
instance instIsCentralScalar [SMul Rᵐᵒᵖ ℝ≥0∞] [IsCentralScalar R ℝ≥0∞] :
IsCentralScalar R (OuterMeasure α) :=
⟨fun _ _ => ext fun _ => op_smul_eq_smul _ _⟩
end SMul
instance instMulAction {R : Type*} [Monoid R] [MulAction R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
MulAction R (OuterMeasure α) :=
Injective.mulAction _ coe_fn_injective coe_smul
instance addCommMonoid : AddCommMonoid (OuterMeasure α) :=
Injective.addCommMonoid (show OuterMeasure α → Set α → ℝ≥0∞ from _) coe_fn_injective rfl
(fun _ _ => rfl) fun _ _ => rfl
/-- `(⇑)` as an `AddMonoidHom`. -/
@[simps]
def coeFnAddMonoidHom : OuterMeasure α →+ Set α → ℝ≥0∞ where
toFun := (⇑)
map_zero' := coe_zero
map_add' := coe_add
instance instDistribMulAction {R : Type*} [Monoid R] [DistribMulAction R ℝ≥0∞]
[IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
DistribMulAction R (OuterMeasure α) :=
Injective.distribMulAction coeFnAddMonoidHom coe_fn_injective coe_smul
instance instModule {R : Type*} [Semiring R] [Module R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] :
Module R (OuterMeasure α) :=
Injective.module R coeFnAddMonoidHom coe_fn_injective coe_smul
instance instBot : Bot (OuterMeasure α) :=
⟨0⟩
@[simp]
theorem coe_bot : (⊥ : OuterMeasure α) = 0 :=
rfl
instance instPartialOrder : PartialOrder (OuterMeasure α) where
le m₁ m₂ := ∀ s, m₁ s ≤ m₂ s
le_refl _ _ := le_rfl
le_trans _ _ _ hab hbc s := le_trans (hab s) (hbc s)
le_antisymm _ _ hab hba := ext fun s => le_antisymm (hab s) (hba s)
instance instIsOrderedAddMonoid {α : Type*} : IsOrderedAddMonoid (OuterMeasure α) where
add_le_add_left _ _ h _ s := add_le_add_left (h s) _
instance orderBot : OrderBot (OuterMeasure α) :=
{ bot := 0,
bot_le := fun a s => by simp only [coe_zero, Pi.zero_apply, zero_le] }
theorem univ_eq_zero_iff (m : OuterMeasure α) : m univ = 0 ↔ m = 0 :=
⟨fun h => bot_unique fun s => (measure_mono <| subset_univ s).trans_eq h, fun h => h.symm ▸ rfl⟩
section Supremum
instance instSupSet : SupSet (OuterMeasure α) :=
⟨fun ms =>
{ measureOf := fun s => ⨆ m ∈ ms, (m : OuterMeasure α) s
empty := nonpos_iff_eq_zero.1 <| iSup₂_le fun m _ => le_of_eq m.empty
mono := fun {_ _} hs => iSup₂_mono fun m _ => m.mono hs
iUnion_nat := fun f _ =>
iSup₂_le fun m hm =>
calc
m (⋃ i, f i) ≤ ∑' i : ℕ, m (f i) := measure_iUnion_le _
_ ≤ ∑' i, ⨆ m ∈ ms, (m : OuterMeasure α) (f i) :=
ENNReal.tsum_le_tsum fun i => by apply le_iSup₂ m hm
}⟩
instance instCompleteLattice : CompleteLattice (OuterMeasure α) :=
{ OuterMeasure.orderBot,
completeLatticeOfSup (OuterMeasure α) fun ms =>
⟨fun m hm s => by apply le_iSup₂ m hm, fun _ hm s => iSup₂_le fun _ hm' => hm hm' s⟩ with }
@[simp]
theorem sSup_apply (ms : Set (OuterMeasure α)) (s : Set α) :
(sSup ms) s = ⨆ m ∈ ms, (m : OuterMeasure α) s :=
rfl
@[simp]
theorem iSup_apply {ι} (f : ι → OuterMeasure α) (s : Set α) : (⨆ i : ι, f i) s = ⨆ i, f i s := by
rw [iSup, sSup_apply, iSup_range]
@[norm_cast]
theorem coe_iSup {ι} (f : ι → OuterMeasure α) : ⇑(⨆ i, f i) = ⨆ i, ⇑(f i) :=
funext fun s => by simp
@[simp]
theorem sup_apply (m₁ m₂ : OuterMeasure α) (s : Set α) : (m₁ ⊔ m₂) s = m₁ s ⊔ m₂ s := by
have := iSup_apply (fun b => cond b m₁ m₂) s; rwa [iSup_bool_eq, iSup_bool_eq] at this
theorem smul_iSup {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
{ι : Sort*} (f : ι → OuterMeasure α) (c : R) :
(c • ⨆ i, f i) = ⨆ i, c • f i :=
ext fun s => by simp only [smul_apply, iSup_apply, ENNReal.smul_iSup]
end Supremum
@[mono, gcongr]
theorem mono'' {m₁ m₂ : OuterMeasure α} {s₁ s₂ : Set α} (hm : m₁ ≤ m₂) (hs : s₁ ⊆ s₂) :
m₁ s₁ ≤ m₂ s₂ :=
(hm s₁).trans (m₂.mono hs)
/-- The pushforward of `m` along `f`. The outer measure on `s` is defined to be `m (f ⁻¹' s)`. -/
def map {β} (f : α → β) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure β where
toFun m :=
{ measureOf := fun s => m (f ⁻¹' s)
empty := m.empty
mono := fun {_ _} h => m.mono (preimage_mono h)
iUnion_nat := fun s _ => by simpa using measure_iUnion_le fun i => f ⁻¹' s i }
map_add' _ _ := coe_fn_injective rfl
map_smul' _ _ := coe_fn_injective rfl
@[simp]
theorem map_apply {β} (f : α → β) (m : OuterMeasure α) (s : Set β) : map f m s = m (f ⁻¹' s) :=
rfl
@[simp]
theorem map_id (m : OuterMeasure α) : map id m = m :=
ext fun _ => rfl
@[simp]
theorem map_map {β γ} (f : α → β) (g : β → γ) (m : OuterMeasure α) :
map g (map f m) = map (g ∘ f) m :=
ext fun _ => rfl
@[mono]
theorem map_mono {β} (f : α → β) : Monotone (map f) := fun _ _ h _ => h _
@[simp]
theorem map_sup {β} (f : α → β) (m m' : OuterMeasure α) : map f (m ⊔ m') = map f m ⊔ map f m' :=
ext fun s => by simp only [map_apply, sup_apply]
@[simp]
theorem map_iSup {β ι} (f : α → β) (m : ι → OuterMeasure α) : map f (⨆ i, m i) = ⨆ i, map f (m i) :=
ext fun s => by simp only [map_apply, iSup_apply]
instance instFunctor : Functor OuterMeasure where map {_ _} f := map f
instance instLawfulFunctor : LawfulFunctor OuterMeasure := by constructor <;> intros <;> rfl
/-- The dirac outer measure. -/
def dirac (a : α) : OuterMeasure α where
measureOf s := indicator s (fun _ => 1) a
empty := by simp
mono {_ _} h := indicator_le_indicator_of_subset h (fun _ => zero_le _) a
iUnion_nat s _ := calc
indicator (⋃ n, s n) 1 a = ⨆ n, indicator (s n) 1 a :=
indicator_iUnion_apply (M := ℝ≥0∞) rfl _ _ _
_ ≤ ∑' n, indicator (s n) 1 a := iSup_le fun _ ↦ ENNReal.le_tsum _
@[simp]
theorem dirac_apply (a : α) (s : Set α) : dirac a s = indicator s (fun _ => 1) a :=
rfl
/-- The sum of an (arbitrary) collection of outer measures. -/
def sum {ι} (f : ι → OuterMeasure α) : OuterMeasure α where
measureOf s := ∑' i, f i s
empty := by simp
mono {_ _} h := ENNReal.tsum_le_tsum fun _ => measure_mono h
iUnion_nat s _ := by
rw [ENNReal.tsum_comm]; exact ENNReal.tsum_le_tsum fun i => measure_iUnion_le _
@[simp]
theorem sum_apply {ι} (f : ι → OuterMeasure α) (s : Set α) : sum f s = ∑' i, f i s :=
rfl
theorem smul_dirac_apply (a : ℝ≥0∞) (b : α) (s : Set α) :
(a • dirac b) s = indicator s (fun _ => a) b := by
simp only [smul_apply, smul_eq_mul, dirac_apply, ← indicator_mul_right _ fun _ => a, mul_one]
/-- Pullback of an `OuterMeasure`: `comap f μ s = μ (f '' s)`. -/
def comap {β} (f : α → β) : OuterMeasure β →ₗ[ℝ≥0∞] OuterMeasure α where
toFun m :=
{ measureOf := fun s => m (f '' s)
empty := by simp
mono := fun {_ _} h => by gcongr
iUnion_nat := fun s _ => by simpa only [image_iUnion] using measure_iUnion_le _ }
map_add' _ _ := rfl
map_smul' _ _ := rfl
@[simp]
theorem comap_apply {β} (f : α → β) (m : OuterMeasure β) (s : Set α) : comap f m s = m (f '' s) :=
rfl
@[mono]
theorem comap_mono {β} (f : α → β) : Monotone (comap f) := fun _ _ h _ => h _
@[simp]
theorem comap_iSup {β ι} (f : α → β) (m : ι → OuterMeasure β) :
comap f (⨆ i, m i) = ⨆ i, comap f (m i) :=
ext fun s => by simp only [comap_apply, iSup_apply]
/-- Restrict an `OuterMeasure` to a set. -/
def restrict (s : Set α) : OuterMeasure α →ₗ[ℝ≥0∞] OuterMeasure α :=
(map (↑)).comp (comap ((↑) : s → α))
-- TODO (kmill): change `m (t ∩ s)` to `m (s ∩ t)`
@[simp]
theorem restrict_apply (s t : Set α) (m : OuterMeasure α) : restrict s m t = m (t ∩ s) := by
simp [restrict, inter_comm t]
@[mono]
theorem restrict_mono {s t : Set α} (h : s ⊆ t) {m m' : OuterMeasure α} (hm : m ≤ m') :
restrict s m ≤ restrict t m' := fun u => by
simp only [restrict_apply]
exact (hm _).trans (m'.mono <| inter_subset_inter_right _ h)
@[simp]
theorem restrict_univ (m : OuterMeasure α) : restrict univ m = m :=
ext fun s => by simp
@[simp]
theorem restrict_empty (m : OuterMeasure α) : restrict ∅ m = 0 :=
ext fun s => by simp
@[simp]
theorem restrict_iSup {ι} (s : Set α) (m : ι → OuterMeasure α) :
restrict s (⨆ i, m i) = ⨆ i, restrict s (m i) := by simp [restrict]
theorem map_comap {β} (f : α → β) (m : OuterMeasure β) : map f (comap f m) = restrict (range f) m :=
ext fun s => congr_arg m <| by simp only [image_preimage_eq_inter_range, Subtype.range_coe]
theorem map_comap_le {β} (f : α → β) (m : OuterMeasure β) : map f (comap f m) ≤ m := fun _ =>
m.mono <| image_preimage_subset _ _
theorem restrict_le_self (m : OuterMeasure α) (s : Set α) : restrict s m ≤ m :=
map_comap_le _ _
@[simp]
theorem map_le_restrict_range {β} {ma : OuterMeasure α} {mb : OuterMeasure β} {f : α → β} :
map f ma ≤ restrict (range f) mb ↔ map f ma ≤ mb :=
⟨fun h => h.trans (restrict_le_self _ _), fun h s => by simpa using h (s ∩ range f)⟩
theorem map_comap_of_surjective {β} {f : α → β} (hf : Surjective f) (m : OuterMeasure β) :
map f (comap f m) = m :=
ext fun s => by rw [map_apply, comap_apply, hf.image_preimage]
theorem le_comap_map {β} (f : α → β) (m : OuterMeasure α) : m ≤ comap f (map f m) := fun _ =>
m.mono <| subset_preimage_image _ _
theorem comap_map {β} {f : α → β} (hf : Injective f) (m : OuterMeasure α) : comap f (map f m) = m :=
ext fun s => by rw [comap_apply, map_apply, hf.preimage_image]
@[simp]
theorem top_apply {s : Set α} (h : s.Nonempty) : (⊤ : OuterMeasure α) s = ∞ :=
let ⟨a, as⟩ := h
top_unique <| le_trans (by simp [smul_dirac_apply, as]) (le_iSup₂ (∞ • dirac a) trivial)
theorem top_apply' (s : Set α) : (⊤ : OuterMeasure α) s = ⨅ _ : s = ∅, 0 :=
s.eq_empty_or_nonempty.elim (fun h => by simp [h]) fun h => by simp [h, h.ne_empty]
@[simp]
theorem comap_top (f : α → β) : comap f ⊤ = ⊤ :=
ext_nonempty fun s hs => by rw [comap_apply, top_apply hs, top_apply (hs.image _)]
theorem map_top (f : α → β) : map f ⊤ = restrict (range f) ⊤ :=
ext fun s => by
rw [map_apply, restrict_apply, ← image_preimage_eq_inter_range, top_apply', top_apply',
Set.image_eq_empty]
@[simp]
theorem map_top_of_surjective (f : α → β) (hf : Surjective f) : map f ⊤ = ⊤ := by
rw [map_top, hf.range_eq, restrict_univ]
end Basic
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/OfAddContent.lean | import Mathlib.MeasureTheory.SetSemiring
import Mathlib.MeasureTheory.Measure.AddContent
import Mathlib.MeasureTheory.Measure.Trim
/-!
# Carathéodory's extension theorem
Let `C` be a semiring of sets and `m` an additive content on `C`, which is sigma-subadditive.
Then all sets in the sigma-algebra generated by `C` are Carathéodory measurable with respect to
the outer measure induced by `m`. The induced outer measure is equal to `m` on `C`.
## Main declarations
* `MeasureTheory.AddContent.measureCaratheodory`:
Construct a measure from a sigma-subadditive function on a semiring. This
measure is defined on the associated Carathéodory sigma-algebra.
* `MeasureTheory.AddContent.measure`: Construct a measure from a sigma-subadditive content
on a semiring, assuming the semiring generates a given measurable structure. The measure is
defined on this measurable structure.
## Main results
* `MeasureTheory.AddContent.inducedOuterMeasure_eq`: The outer measure induced by
a sigma-subadditive content on a semiring is equal to the content on the sets of the semiring.
* `MeasureTheory.AddContent.isCaratheodory_inducedOuterMeasure_of_mem`: all sets of the semiring are
Carathéodory measurable with respect to the outer measure induced by a sigma-subadditive content.
* `MeasureTheory.AddContent.isCaratheodory_inducedOuterMeasure`: all sets of the sigma-algebra
generated by the semiring are Carathéodory measurable with respect to the outer measure induced
by a sigma-subadditive content.
* `MeasureTheory.AddContent.measureCaratheodory_eq`: The measure
`MeasureTheory.AddContent.measureCaratheodory` generated from an `m : AddContent C`
on a `IsSetSemiring C` coincides with `m` on `C`.
* `MeasureTheory.AddContent.measure_eq`: The measure defined through a sigma-subadditive
content on a semiring coincides with the content on the semiring.
-/
open Set
open scoped ENNReal
namespace MeasureTheory.AddContent
variable {α : Type*} {C : Set (Set α)} {s : Set α}
/-- For `m : AddContent C` sigma-sub-additive, finite on `C`, the `OuterMeasure` given by `m`
coincides with `m` on `C`. -/
theorem ofFunction_eq (hC : IsSetSemiring C) (m : AddContent C)
(m_sigma_subadd : m.IsSigmaSubadditive) (m_top : ∀ s ∉ C, m s = ∞) (hs : s ∈ C) :
OuterMeasure.ofFunction m addContent_empty s = m s := by
refine le_antisymm (OuterMeasure.ofFunction_le s) ?_
rw [OuterMeasure.ofFunction_eq_iInf_mem _ _ m_top]
refine le_iInf fun f ↦ le_iInf fun hf ↦ le_iInf fun hs_subset ↦ ?_
calc m s = m (s ∩ ⋃ i, f i) := by rw [inter_eq_self_of_subset_left hs_subset]
_ = m (⋃ i, s ∩ f i) := by rw [inter_iUnion]
_ ≤ ∑' i, m (s ∩ f i) := by
refine m_sigma_subadd (fun i ↦ hC.inter_mem _ hs _ (hf i)) ?_
rwa [← inter_iUnion, inter_eq_self_of_subset_left hs_subset]
_ ≤ ∑' i, m (f i) := by
refine ENNReal.summable.tsum_le_tsum (fun i ↦ ?_) ENNReal.summable
exact addContent_mono hC (hC.inter_mem _ hs _ (hf i)) (hf i) Set.inter_subset_right
/-- For `m : AddContent C` sigma-sub-additive, finite on `C`, the `inducedOuterMeasure` given by `m`
coincides with `m` on `C`. -/
theorem inducedOuterMeasure_eq (hC : IsSetSemiring C) (m : AddContent C)
(m_sigma_subadd : m.IsSigmaSubadditive) (hs : s ∈ C) :
inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty s = m s := by
suffices inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty s = m.extend hC s by
rwa [m.extend_eq hC hs] at this
refine Eq.trans ?_ ((m.extend hC).ofFunction_eq hC ?_ ?_ hs)
· congr
· intro f hf hf_mem
rw [m.extend_eq hC hf_mem]
refine (m_sigma_subadd hf hf_mem).trans_eq ?_
congr with i
rw [m.extend_eq hC (hf i)]
· exact fun _ ↦ m.extend_eq_top _
theorem isCaratheodory_ofFunction_of_mem (hC : IsSetSemiring C) (m : AddContent C)
(m_top : ∀ s ∉ C, m s = ∞) (hs : s ∈ C) :
(OuterMeasure.ofFunction m addContent_empty).IsCaratheodory s := by
rw [OuterMeasure.isCaratheodory_iff_le']
intro t
conv_rhs => rw [OuterMeasure.ofFunction_eq_iInf_mem _ _ m_top]
refine le_iInf fun f ↦ le_iInf fun hf ↦ le_iInf fun hf_subset ↦ ?_
let A : ℕ → Finset (Set α) := fun i ↦ hC.disjointOfDiff (hf i) (hC.inter_mem _ (hf i) _ hs)
have h_diff_eq_sUnion i : f i \ s = ⋃₀ A i := by simp [A, IsSetSemiring.sUnion_disjointOfDiff]
classical
have h_m_eq i : m (f i) = m (f i ∩ s) + ∑ u ∈ A i, m u :=
eq_add_disjointOfDiff_of_subset hC (hC.inter_mem (f i) (hf i) s hs) (hf i) inter_subset_left
simp_rw [h_m_eq]
rw [ENNReal.tsum_add]
refine add_le_add ?_ ?_
· refine iInf_le_of_le (fun i ↦ f i ∩ s) <| iInf_le_of_le ?_ le_rfl
rw [← iUnion_inter]
exact Set.inter_subset_inter_left _ hf_subset
· apply le_trans <| (OuterMeasure.ofFunction m addContent_empty).mono
<| (iUnion_diff s f) ▸ diff_subset_diff_left hf_subset
simp only [OuterMeasure.measureOf_eq_coe, A]
apply le_trans <| measure_iUnion_le (μ := OuterMeasure.ofFunction m addContent_empty)
(fun i ↦ f i \ s)
apply ENNReal.tsum_le_tsum
intro i
simp_rw [sUnion_eq_biUnion] at h_diff_eq_sUnion
rw [h_diff_eq_sUnion]
obtain h6 := MeasureTheory.measure_biUnion_finset_le
(μ := OuterMeasure.ofFunction m addContent_empty) (A i) id
simp only [id_eq] at h6
exact le_trans h6 <| Finset.sum_le_sum <| fun b _ ↦ OuterMeasure.ofFunction_le b
/-- Every `s ∈ C` for an `m : AddContent C` with `IsSetSemiring C` is Carathéodory measurable
with respect to the `inducedOuterMeasure` from `m`. -/
theorem isCaratheodory_inducedOuterMeasure_of_mem (hC : IsSetSemiring C) (m : AddContent C)
{s : Set α} (hs : s ∈ C) :
(inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty).IsCaratheodory s :=
isCaratheodory_ofFunction_of_mem hC (m.extend hC) (fun _ ↦ m.extend_eq_top hC) hs
theorem isCaratheodory_inducedOuterMeasure (hC : IsSetSemiring C) (m : AddContent C)
(s : Set α) (hs : MeasurableSet[MeasurableSpace.generateFrom C] s) :
(inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty).IsCaratheodory s := by
induction hs with
| basic u hu => exact isCaratheodory_inducedOuterMeasure_of_mem hC m hu
| empty => exact OuterMeasure.isCaratheodory_empty _
| compl t _ h => exact OuterMeasure.isCaratheodory_compl _ h
| iUnion f _ h => exact OuterMeasure.isCaratheodory_iUnion _ h
/-- Construct a measure from a sigma-subadditive content on a semiring. This
measure is defined on the associated Carathéodory sigma-algebra. -/
noncomputable def measureCaratheodory (m : AddContent C) (hC : IsSetSemiring C)
(m_sigma_subadd : m.IsSigmaSubadditive) :
@Measure α (inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty).caratheodory :=
letI : MeasurableSpace α :=
(inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty).caratheodory
{ inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty with
m_iUnion := fun f hf hd ↦ OuterMeasure.iUnion_eq_of_caratheodory _ hf hd
trim_le := by
apply le_inducedOuterMeasure.mpr fun s hs ↦ ?_
have hs_meas : MeasurableSet[(inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem
addContent_empty).caratheodory] s := by
change (inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty).IsCaratheodory s
exact isCaratheodory_inducedOuterMeasure_of_mem hC m hs
rw [OuterMeasure.trim_eq _ hs_meas, m.inducedOuterMeasure_eq hC m_sigma_subadd hs] }
/-- The measure `MeasureTheory.AddContent.measureCaratheodory` generated from an
`m : AddContent C` on a `IsSetSemiring C` coincides with the `MeasureTheory.inducedOuterMeasure`. -/
theorem measureCaratheodory_eq_inducedOuterMeasure (hC : IsSetSemiring C) (m : AddContent C)
(m_sigma_subadd : m.IsSigmaSubadditive) :
m.measureCaratheodory hC m_sigma_subadd s
= inducedOuterMeasure (fun x _ ↦ m x) hC.empty_mem addContent_empty s := rfl
theorem measureCaratheodory_eq (m : AddContent C) (hC : IsSetSemiring C)
(m_sigma_subadd : m.IsSigmaSubadditive) (hs : s ∈ C) :
m.measureCaratheodory hC m_sigma_subadd s = m s :=
m.inducedOuterMeasure_eq hC m_sigma_subadd hs
/-- Construct a measure from a sigma-subadditive content on a semiring, assuming the semiring
generates a given measurable structure. The measure is defined on this measurable structure. -/
noncomputable def measure [mα : MeasurableSpace α] (m : AddContent C) (hC : IsSetSemiring C)
(hC_gen : mα ≤ MeasurableSpace.generateFrom C) (m_sigma_subadd : m.IsSigmaSubadditive) :
Measure α :=
(m.measureCaratheodory hC m_sigma_subadd).trim <|
fun s a ↦ isCaratheodory_inducedOuterMeasure hC m s (hC_gen s a)
/-- The measure defined through a sigma-subadditive
content on a semiring coincides with the content on the semiring. -/
theorem measure_eq [mα : MeasurableSpace α] (m : AddContent C) (hC : IsSetSemiring C)
(hC_gen : mα = MeasurableSpace.generateFrom C) (m_sigma_subadd : m.IsSigmaSubadditive)
(hs : s ∈ C) :
m.measure hC hC_gen.le m_sigma_subadd s = m s := by
rw [measure, trim_measurableSet_eq]
· exact m.measureCaratheodory_eq hC m_sigma_subadd hs
· rw [hC_gen]
apply MeasurableSpace.measurableSet_generateFrom hs
end MeasureTheory.AddContent |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/Defs.lean | import Mathlib.Topology.Algebra.InfiniteSum.Defs
import Mathlib.Topology.Order.Real
/-!
# Definitions of an outer measure and the corresponding `FunLike` class
In this file we define `MeasureTheory.OuterMeasure α`
to be the type of outer measures on `α`.
An outer measure is a function `μ : Set α → ℝ≥0∞`,
from the powerset of a type to the extended nonnegative real numbers
that satisfies the following conditions:
1. `μ ∅ = 0`;
2. `μ` is monotone;
3. `μ` is countably subadditive. This means that the outer measure of a countable union
is at most the sum of the outer measure on the individual sets.
Note that we do not need `α` to be measurable to define an outer measure.
We also define a typeclass `MeasureTheory.OuterMeasureClass`.
## References
<https://en.wikipedia.org/wiki/Outer_measure>
## Tags
outer measure
-/
assert_not_exists Module.Basis IsTopologicalRing UniformSpace
open scoped ENNReal
variable {α : Type*}
namespace MeasureTheory
open scoped Function -- required for scoped `on` notation
/-- An outer measure is a countably subadditive monotone function that sends `∅` to `0`. -/
structure OuterMeasure (α : Type*) where
/-- Outer measure function. Use automatic coercion instead. -/
protected measureOf : Set α → ℝ≥0∞
protected empty : measureOf ∅ = 0
protected mono : ∀ {s₁ s₂}, s₁ ⊆ s₂ → measureOf s₁ ≤ measureOf s₂
protected iUnion_nat : ∀ s : ℕ → Set α, Pairwise (Disjoint on s) →
measureOf (⋃ i, s i) ≤ ∑' i, measureOf (s i)
/-- A mixin class saying that elements `μ : F` are outer measures on `α`.
This typeclass is used to unify some API for outer measures and measures. -/
class OuterMeasureClass (F : Type*) (α : outParam Type*) [FunLike F (Set α) ℝ≥0∞] : Prop where
protected measure_empty (f : F) : f ∅ = 0
protected measure_mono (f : F) {s t} : s ⊆ t → f s ≤ f t
protected measure_iUnion_nat_le (f : F) (s : ℕ → Set α) : Pairwise (Disjoint on s) →
f (⋃ i, s i) ≤ ∑' i, f (s i)
namespace OuterMeasure
instance : FunLike (OuterMeasure α) (Set α) ℝ≥0∞ where
coe m := m.measureOf
coe_injective' | ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, rfl => rfl
@[simp] theorem measureOf_eq_coe (m : OuterMeasure α) : m.measureOf = m := rfl
instance : OuterMeasureClass (OuterMeasure α) α where
measure_empty f := f.empty
measure_mono f := f.mono
measure_iUnion_nat_le f := f.iUnion_nat
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/AE.lean | import Mathlib.MeasureTheory.OuterMeasure.Basic
/-!
# The “almost everywhere” filter of co-null sets.
If `μ` is an outer measure or a measure on `α`,
then `MeasureTheory.ae μ` is the filter of co-null sets: `s ∈ ae μ ↔ μ sᶜ = 0`.
In this file we define the filter and prove some basic theorems about it.
## Notation
- `∀ᵐ x ∂μ, p x`: the predicate `p` holds for `μ`-a.e. all `x`;
- `∃ᶠ x ∂μ, p x`: the predicate `p` holds on a set of nonzero measure;
- `f =ᵐ[μ] g`: `f x = g x` for `μ`-a.e. all `x`;
- `f ≤ᵐ[μ] g`: `f x ≤ g x` for `μ`-a.e. all `x`.
## Implementation details
All notation introduced in this file
reducibly unfolds to the corresponding definitions about filters,
so generic lemmas about `Filter.Eventually`, `Filter.EventuallyEq` etc. apply.
However, we restate some lemmas specifically for `ae`.
## Tags
outer measure, measure, almost everywhere
-/
open Filter Set
open scoped ENNReal
namespace MeasureTheory
variable {α β F : Type*} [FunLike F (Set α) ℝ≥0∞] [OuterMeasureClass F α] {μ : F} {s t : Set α}
/-- The “almost everywhere” filter of co-null sets. -/
def ae (μ : F) : Filter α :=
.ofCountableUnion (μ · = 0) (fun _S hSc ↦ (measure_sUnion_null_iff hSc).2) fun _t ht _s hs ↦
measure_mono_null hs ht
/-- `∀ᵐ a ∂μ, p a` means that `p a` for a.e. `a`, i.e. `p` holds true away from a null set.
This is notation for `Filter.Eventually p (MeasureTheory.ae μ)`. -/
notation3 "∀ᵐ "(...)" ∂"μ", "r:(scoped p => Filter.Eventually p <| MeasureTheory.ae μ) => r
/-- `∃ᵐ a ∂μ, p a` means that `p` holds `∂μ`-frequently,
i.e. `p` holds on a set of positive measure.
This is notation for `Filter.Frequently p (MeasureTheory.ae μ)`. -/
notation3 "∃ᵐ "(...)" ∂"μ", "r:(scoped P => Filter.Frequently P <| MeasureTheory.ae μ) => r
/-- `f =ᵐ[μ] g` means `f` and `g` are eventually equal along the a.e. filter,
i.e. `f=g` away from a null set.
This is notation for `Filter.EventuallyEq (MeasureTheory.ae μ) f g`. -/
notation:50 f " =ᵐ[" μ:50 "] " g:50 => Filter.EventuallyEq (MeasureTheory.ae μ) f g
/-- `f ≤ᵐ[μ] g` means `f` is eventually less than `g` along the a.e. filter,
i.e. `f ≤ g` away from a null set.
This is notation for `Filter.EventuallyLE (MeasureTheory.ae μ) f g`. -/
notation:50 f " ≤ᵐ[" μ:50 "] " g:50 => Filter.EventuallyLE (MeasureTheory.ae μ) f g
theorem mem_ae_iff {s : Set α} : s ∈ ae μ ↔ μ sᶜ = 0 :=
Iff.rfl
theorem ae_iff {p : α → Prop} : (∀ᵐ a ∂μ, p a) ↔ μ { a | ¬p a } = 0 :=
Iff.rfl
theorem compl_mem_ae_iff {s : Set α} : sᶜ ∈ ae μ ↔ μ s = 0 := by simp only [mem_ae_iff, compl_compl]
theorem frequently_ae_iff {p : α → Prop} : (∃ᵐ a ∂μ, p a) ↔ μ { a | p a } ≠ 0 :=
not_congr compl_mem_ae_iff
theorem frequently_ae_mem_iff {s : Set α} : (∃ᵐ a ∂μ, a ∈ s) ↔ μ s ≠ 0 :=
not_congr compl_mem_ae_iff
theorem measure_eq_zero_iff_ae_notMem {s : Set α} : μ s = 0 ↔ ∀ᵐ a ∂μ, a ∉ s :=
compl_mem_ae_iff.symm
@[deprecated (since := "2025-08-26")]
alias measure_zero_iff_ae_notMem := measure_eq_zero_iff_ae_notMem
@[deprecated (since := "2025-05-24")]
alias measure_zero_iff_ae_nmem := measure_eq_zero_iff_ae_notMem
theorem ae_of_all {p : α → Prop} (μ : F) : (∀ a, p a) → ∀ᵐ a ∂μ, p a :=
Eventually.of_forall
instance instCountableInterFilter : CountableInterFilter (ae μ) := by
unfold ae; infer_instance
theorem ae_all_iff {ι : Sort*} [Countable ι] {p : α → ι → Prop} :
(∀ᵐ a ∂μ, ∀ i, p a i) ↔ ∀ i, ∀ᵐ a ∂μ, p a i :=
eventually_countable_forall
theorem all_ae_of {ι : Sort*} {p : α → ι → Prop} (hp : ∀ᵐ a ∂μ, ∀ i, p a i) (i : ι) :
∀ᵐ a ∂μ, p a i := by
filter_upwards [hp] with a ha using ha i
lemma ae_iff_of_countable [Countable α] {p : α → Prop} : (∀ᵐ x ∂μ, p x) ↔ ∀ x, μ {x} ≠ 0 → p x := by
rw [ae_iff, measure_null_iff_singleton]
exacts [forall_congr' fun _ ↦ not_imp_comm, Set.to_countable _]
theorem ae_ball_iff {ι : Type*} {S : Set ι} (hS : S.Countable) {p : α → ∀ i ∈ S, Prop} :
(∀ᵐ x ∂μ, ∀ i (hi : i ∈ S), p x i hi) ↔ ∀ i (hi : i ∈ S), ∀ᵐ x ∂μ, p x i hi :=
eventually_countable_ball hS
lemma ae_eq_refl (f : α → β) : f =ᵐ[μ] f := EventuallyEq.rfl
lemma ae_eq_rfl {f : α → β} : f =ᵐ[μ] f := EventuallyEq.rfl
lemma ae_eq_comm {f g : α → β} : f =ᵐ[μ] g ↔ g =ᵐ[μ] f := eventuallyEq_comm
theorem ae_eq_symm {f g : α → β} (h : f =ᵐ[μ] g) : g =ᵐ[μ] f :=
h.symm
theorem ae_eq_trans {f g h : α → β} (h₁ : f =ᵐ[μ] g) (h₂ : g =ᵐ[μ] h) : f =ᵐ[μ] h :=
h₁.trans h₂
@[simp] lemma ae_eq_top : ae μ = ⊤ ↔ ∀ a, μ {a} ≠ 0 := by
simp only [Filter.ext_iff, mem_ae_iff, mem_top, ne_eq]
refine ⟨fun h a ha ↦ by simpa [ha] using (h {a}ᶜ).1, fun h s ↦ ⟨fun hs ↦ ?_, ?_⟩⟩
· rw [← compl_empty_iff, ← not_nonempty_iff_eq_empty]
rintro ⟨a, ha⟩
exact h _ <| measure_mono_null (singleton_subset_iff.2 ha) hs
· rintro rfl
simp
theorem ae_le_of_ae_lt {β : Type*} [Preorder β] {f g : α → β} (h : ∀ᵐ x ∂μ, f x < g x) :
f ≤ᵐ[μ] g :=
h.mono fun _ ↦ le_of_lt
@[simp]
theorem ae_eq_empty : s =ᵐ[μ] (∅ : Set α) ↔ μ s = 0 :=
eventuallyEq_empty.trans <| by simp only [ae_iff, Classical.not_not, setOf_mem_eq]
-- The priority should be higher than `eventuallyEq_univ`.
@[simp high]
theorem ae_eq_univ : s =ᵐ[μ] (univ : Set α) ↔ μ sᶜ = 0 :=
eventuallyEq_univ
theorem ae_le_set : s ≤ᵐ[μ] t ↔ μ (s \ t) = 0 :=
calc
s ≤ᵐ[μ] t ↔ ∀ᵐ x ∂μ, x ∈ s → x ∈ t := Iff.rfl
_ ↔ μ (s \ t) = 0 := by simp [ae_iff]; rfl
theorem ae_le_set_inter {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') :
(s ∩ s' : Set α) ≤ᵐ[μ] (t ∩ t' : Set α) :=
h.inter h'
theorem ae_le_set_union {s' t' : Set α} (h : s ≤ᵐ[μ] t) (h' : s' ≤ᵐ[μ] t') :
(s ∪ s' : Set α) ≤ᵐ[μ] (t ∪ t' : Set α) :=
h.union h'
theorem union_ae_eq_right : (s ∪ t : Set α) =ᵐ[μ] t ↔ μ (s \ t) = 0 := by
simp [eventuallyLE_antisymm_iff, ae_le_set, union_diff_right,
diff_eq_empty.2 Set.subset_union_right]
theorem diff_ae_eq_self : (s \ t : Set α) =ᵐ[μ] s ↔ μ (s ∩ t) = 0 := by
simp [eventuallyLE_antisymm_iff, ae_le_set]
theorem diff_null_ae_eq_self (ht : μ t = 0) : (s \ t : Set α) =ᵐ[μ] s :=
diff_ae_eq_self.mpr (measure_mono_null inter_subset_right ht)
theorem ae_eq_set {s t : Set α} : s =ᵐ[μ] t ↔ μ (s \ t) = 0 ∧ μ (t \ s) = 0 := by
simp [eventuallyLE_antisymm_iff, ae_le_set]
open scoped symmDiff in
@[simp]
theorem measure_symmDiff_eq_zero_iff {s t : Set α} : μ (s ∆ t) = 0 ↔ s =ᵐ[μ] t := by
simp [ae_eq_set, symmDiff_def]
@[simp]
theorem ae_eq_set_compl_compl {s t : Set α} : sᶜ =ᵐ[μ] tᶜ ↔ s =ᵐ[μ] t := by
simp only [← measure_symmDiff_eq_zero_iff, compl_symmDiff_compl]
theorem ae_eq_set_compl {s t : Set α} : sᶜ =ᵐ[μ] t ↔ s =ᵐ[μ] tᶜ := by
rw [← ae_eq_set_compl_compl, compl_compl]
theorem ae_eq_set_inter {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') :
(s ∩ s' : Set α) =ᵐ[μ] (t ∩ t' : Set α) :=
h.inter h'
theorem ae_eq_set_union {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') :
(s ∪ s' : Set α) =ᵐ[μ] (t ∪ t' : Set α) :=
h.union h'
theorem ae_eq_set_diff {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') :
s \ s' =ᵐ[μ] t \ t' :=
h.diff h'
open scoped symmDiff in
theorem ae_eq_set_symmDiff {s' t' : Set α} (h : s =ᵐ[μ] t) (h' : s' =ᵐ[μ] t') :
s ∆ s' =ᵐ[μ] t ∆ t' :=
h.symmDiff h'
theorem union_ae_eq_univ_of_ae_eq_univ_left (h : s =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ :=
(ae_eq_set_union h (ae_eq_refl t)).trans <| by rw [univ_union]
theorem union_ae_eq_univ_of_ae_eq_univ_right (h : t =ᵐ[μ] univ) : (s ∪ t : Set α) =ᵐ[μ] univ := by
convert ae_eq_set_union (ae_eq_refl s) h
rw [union_univ]
theorem union_ae_eq_right_of_ae_eq_empty (h : s =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] t := by
convert ae_eq_set_union h (ae_eq_refl t)
rw [empty_union]
theorem union_ae_eq_left_of_ae_eq_empty (h : t =ᵐ[μ] (∅ : Set α)) : (s ∪ t : Set α) =ᵐ[μ] s := by
convert ae_eq_set_union (ae_eq_refl s) h
rw [union_empty]
theorem inter_ae_eq_right_of_ae_eq_univ (h : s =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] t := by
convert ae_eq_set_inter h (ae_eq_refl t)
rw [univ_inter]
theorem inter_ae_eq_left_of_ae_eq_univ (h : t =ᵐ[μ] univ) : (s ∩ t : Set α) =ᵐ[μ] s := by
convert ae_eq_set_inter (ae_eq_refl s) h
rw [inter_univ]
theorem inter_ae_eq_empty_of_ae_eq_empty_left (h : s =ᵐ[μ] (∅ : Set α)) :
(s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by
convert ae_eq_set_inter h (ae_eq_refl t)
rw [empty_inter]
theorem inter_ae_eq_empty_of_ae_eq_empty_right (h : t =ᵐ[μ] (∅ : Set α)) :
(s ∩ t : Set α) =ᵐ[μ] (∅ : Set α) := by
convert ae_eq_set_inter (ae_eq_refl s) h
rw [inter_empty]
@[to_additive]
theorem _root_.Set.mulIndicator_ae_eq_one {M : Type*} [One M] {f : α → M} {s : Set α} :
s.mulIndicator f =ᵐ[μ] 1 ↔ μ (s ∩ f.mulSupport) = 0 := by
simp [EventuallyEq, eventually_iff, ae, compl_setOf]; rfl
/-- If `s ⊆ t` modulo a set of measure `0`, then `μ s ≤ μ t`. -/
@[mono]
theorem measure_mono_ae (H : s ≤ᵐ[μ] t) : μ s ≤ μ t :=
calc
μ s ≤ μ (s ∪ t) := measure_mono subset_union_left
_ = μ (t ∪ s \ t) := by rw [union_diff_self, Set.union_comm]
_ ≤ μ t + μ (s \ t) := measure_union_le _ _
_ = μ t := by rw [ae_le_set.1 H, add_zero]
alias _root_.Filter.EventuallyLE.measure_le := measure_mono_ae
/-- If two sets are equal modulo a set of measure zero, then `μ s = μ t`. -/
theorem measure_congr (H : s =ᵐ[μ] t) : μ s = μ t :=
le_antisymm H.le.measure_le H.symm.le.measure_le
alias _root_.Filter.EventuallyEq.measure_eq := measure_congr
theorem measure_mono_null_ae (H : s ≤ᵐ[μ] t) (ht : μ t = 0) : μ s = 0 :=
nonpos_iff_eq_zero.1 <| ht ▸ H.measure_le
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/OuterMeasure/Induced.lean | import Mathlib.Data.ENNReal.Action
import Mathlib.MeasureTheory.MeasurableSpace.Constructions
import Mathlib.MeasureTheory.OuterMeasure.Caratheodory
/-!
# Induced Outer Measure
We can extend a function defined on a subset of `Set α` to an outer measure.
The underlying function is called `extend`, and the measure it induces is called
`inducedOuterMeasure`.
Some lemmas below are proven twice, once in the general case, and one where the function `m`
is only defined on measurable sets (i.e. when `P = MeasurableSet`). In the latter cases, we can
remove some hypotheses in the statement. The general version has the same name, but with a prime
at the end.
## Tags
outer measure
-/
noncomputable section
open Set Function Filter
open scoped NNReal Topology ENNReal
namespace MeasureTheory
open OuterMeasure
section Extend
variable {α : Type*} {P : α → Prop}
variable (m : ∀ s : α, P s → ℝ≥0∞)
/-- We can trivially extend a function defined on a subclass of objects (with codomain `ℝ≥0∞`)
to all objects by defining it to be `∞` on the objects not in the class. -/
def extend (s : α) : ℝ≥0∞ :=
⨅ h : P s, m s h
theorem extend_eq {s : α} (h : P s) : extend m s = m s h := by simp [extend, h]
theorem extend_eq_top {s : α} (h : ¬P s) : extend m s = ∞ := by simp [extend, h]
theorem smul_extend {R} [Zero R] [SMulWithZero R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞]
[NoZeroSMulDivisors R ℝ≥0∞] {c : R} (hc : c ≠ 0) :
c • extend m = extend fun s h => c • m s h := by
classical
ext1 s
dsimp [extend]
by_cases h : P s
· simp [h]
· simp [h, ENNReal.smul_top, hc]
theorem le_extend {s : α} (h : P s) : m s h ≤ extend m s := by
simp only [extend, le_iInf_iff]
intro
rfl
-- TODO: why this is a bad `congr` lemma?
theorem extend_congr {β : Type*} {Pb : β → Prop} {mb : ∀ s : β, Pb s → ℝ≥0∞} {sa : α} {sb : β}
(hP : P sa ↔ Pb sb) (hm : ∀ (ha : P sa) (hb : Pb sb), m sa ha = mb sb hb) :
extend m sa = extend mb sb :=
iInf_congr_Prop hP fun _h => hm _ _
@[simp]
theorem extend_top {α : Type*} {P : α → Prop} : extend (fun _ _ => ∞ : ∀ s : α, P s → ℝ≥0∞) = ⊤ :=
funext fun _ => iInf_eq_top.mpr fun _ => rfl
end Extend
section ExtendSet
variable {α : Type*} {P : Set α → Prop}
variable {m : ∀ s : Set α, P s → ℝ≥0∞}
variable (P0 : P ∅) (m0 : m ∅ P0 = 0)
variable (PU : ∀ ⦃f : ℕ → Set α⦄ (_hm : ∀ i, P (f i)), P (⋃ i, f i))
variable
(mU :
∀ ⦃f : ℕ → Set α⦄ (hm : ∀ i, P (f i)),
Pairwise (Disjoint on f) → m (⋃ i, f i) (PU hm) = ∑' i, m (f i) (hm i))
variable (msU : ∀ ⦃f : ℕ → Set α⦄ (hm : ∀ i, P (f i)), m (⋃ i, f i) (PU hm) ≤ ∑' i, m (f i) (hm i))
variable (m_mono : ∀ ⦃s₁ s₂ : Set α⦄ (hs₁ : P s₁) (hs₂ : P s₂), s₁ ⊆ s₂ → m s₁ hs₁ ≤ m s₂ hs₂)
theorem extend_iUnion_nat {f : ℕ → Set α} (hm : ∀ i, P (f i))
(mU : m (⋃ i, f i) (PU hm) = ∑' i, m (f i) (hm i)) :
extend m (⋃ i, f i) = ∑' i, extend m (f i) :=
(extend_eq _ _).trans <|
mU.trans <| by
congr with i
rw [extend_eq]
include P0 m0 in
theorem extend_empty : extend m ∅ = 0 :=
(extend_eq _ P0).trans m0
section Subadditive
include PU msU in
theorem extend_iUnion_le_tsum_nat' (s : ℕ → Set α) :
extend m (⋃ i, s i) ≤ ∑' i, extend m (s i) := by
by_cases! h : ∀ i, P (s i)
· rw [extend_eq _ (PU h), congr_arg tsum _]
· apply msU h
funext i
apply extend_eq _ (h i)
· obtain ⟨i, hi⟩ := h
exact le_trans (le_iInf fun h => hi.elim h) (ENNReal.le_tsum i)
end Subadditive
section Mono
include m_mono in
theorem extend_mono' ⦃s₁ s₂ : Set α⦄ (h₁ : P s₁) (hs : s₁ ⊆ s₂) : extend m s₁ ≤ extend m s₂ := by
refine le_iInf ?_
intro h₂
rw [extend_eq m h₁]
exact m_mono h₁ h₂ hs
end Mono
section Unions
include P0 m0 PU mU in
theorem extend_iUnion {β} [Countable β] {f : β → Set α} (hd : Pairwise (Disjoint on f))
(hm : ∀ i, P (f i)) : extend m (⋃ i, f i) = ∑' i, extend m (f i) := by
cases nonempty_encodable β
rw [← Encodable.iUnion_decode₂, ← tsum_iUnion_decode₂]
· exact
extend_iUnion_nat PU (fun n => Encodable.iUnion_decode₂_cases P0 hm)
(mU _ (Encodable.iUnion_decode₂_disjoint_on hd))
· exact extend_empty P0 m0
include P0 m0 PU mU in
theorem extend_union {s₁ s₂ : Set α} (hd : Disjoint s₁ s₂) (h₁ : P s₁) (h₂ : P s₂) :
extend m (s₁ ∪ s₂) = extend m s₁ + extend m s₂ := by
rw [union_eq_iUnion,
extend_iUnion P0 m0 PU mU (pairwise_disjoint_on_bool.2 hd) (Bool.forall_bool.2 ⟨h₂, h₁⟩),
tsum_fintype]
simp
end Unions
variable (m)
/-- Given an arbitrary function on a subset of sets, we can define the outer measure corresponding
to it (this is the unique maximal outer measure that is at most `m` on the domain of `m`). -/
def inducedOuterMeasure : OuterMeasure α :=
OuterMeasure.ofFunction (extend m) (extend_empty P0 m0)
variable {m P0 m0}
theorem le_inducedOuterMeasure {μ : OuterMeasure α} :
μ ≤ inducedOuterMeasure m P0 m0 ↔ ∀ (s) (hs : P s), μ s ≤ m s hs :=
le_ofFunction.trans <| forall_congr' fun _s => le_iInf_iff
/-- If `P u` is `False` for any set `u` that has nonempty intersection both with `s` and `t`, then
`μ (s ∪ t) = μ s + μ t`, where `μ = inducedOuterMeasure m P0 m0`.
E.g., if `α` is an (e)metric space and `P u = diam u < r`, then this lemma implies that
`μ (s ∪ t) = μ s + μ t` on any two sets such that `r ≤ edist x y` for all `x ∈ s` and `y ∈ t`. -/
theorem inducedOuterMeasure_union_of_false_of_nonempty_inter {s t : Set α}
(h : ∀ u, (s ∩ u).Nonempty → (t ∩ u).Nonempty → ¬P u) :
inducedOuterMeasure m P0 m0 (s ∪ t) =
inducedOuterMeasure m P0 m0 s + inducedOuterMeasure m P0 m0 t :=
ofFunction_union_of_top_of_nonempty_inter fun u hsu htu => @iInf_of_empty _ _ _ ⟨h u hsu htu⟩ _
include PU msU m_mono
theorem inducedOuterMeasure_eq_extend' {s : Set α} (hs : P s) :
inducedOuterMeasure m P0 m0 s = extend m s :=
ofFunction_eq s (fun _t => extend_mono' m_mono hs) (extend_iUnion_le_tsum_nat' PU msU)
theorem inducedOuterMeasure_eq' {s : Set α} (hs : P s) : inducedOuterMeasure m P0 m0 s = m s hs :=
(inducedOuterMeasure_eq_extend' PU msU m_mono hs).trans <| extend_eq _ _
theorem inducedOuterMeasure_eq_iInf (s : Set α) :
inducedOuterMeasure m P0 m0 s = ⨅ (t : Set α) (ht : P t) (_ : s ⊆ t), m t ht := by
apply le_antisymm
· simp only [le_iInf_iff]
intro t ht hs
grw [hs]
exact le_of_eq (inducedOuterMeasure_eq' _ msU m_mono _)
· refine le_iInf ?_
intro f
refine le_iInf ?_
intro hf
refine le_trans ?_ (extend_iUnion_le_tsum_nat' _ msU _)
refine le_iInf ?_
intro h2f
exact iInf_le_of_le _ (iInf_le_of_le h2f <| iInf_le _ hf)
theorem inducedOuterMeasure_preimage (f : α ≃ α) (Pm : ∀ s : Set α, P (f ⁻¹' s) ↔ P s)
(mm : ∀ (s : Set α) (hs : P s), m (f ⁻¹' s) ((Pm _).mpr hs) = m s hs) {A : Set α} :
inducedOuterMeasure m P0 m0 (f ⁻¹' A) = inducedOuterMeasure m P0 m0 A := by
rw [inducedOuterMeasure_eq_iInf _ msU m_mono, inducedOuterMeasure_eq_iInf _ msU m_mono]; symm
refine f.injective.preimage_surjective.iInf_congr (preimage f) fun s => ?_
refine iInf_congr_Prop (Pm s) ?_; intro hs
refine iInf_congr_Prop f.surjective.preimage_subset_preimage_iff ?_
intro _; exact mm s hs
theorem inducedOuterMeasure_exists_set {s : Set α} (hs : inducedOuterMeasure m P0 m0 s ≠ ∞)
{ε : ℝ≥0∞} (hε : ε ≠ 0) :
∃ t : Set α,
P t ∧ s ⊆ t ∧ inducedOuterMeasure m P0 m0 t ≤ inducedOuterMeasure m P0 m0 s + ε := by
have h := ENNReal.lt_add_right hs hε
conv at h =>
lhs
rw [inducedOuterMeasure_eq_iInf _ msU m_mono]
simp only [iInf_lt_iff] at h
rcases h with ⟨t, h1t, h2t, h3t⟩
exact
⟨t, h1t, h2t, le_trans (le_of_eq <| inducedOuterMeasure_eq' _ msU m_mono h1t) (le_of_lt h3t)⟩
/-- To test whether `s` is Carathéodory-measurable we only need to check the sets `t` for which
`P t` holds. See `ofFunction_caratheodory` for another way to show the Carathéodory-measurability
of `s`.
-/
theorem inducedOuterMeasure_caratheodory (s : Set α) :
MeasurableSet[(inducedOuterMeasure m P0 m0).caratheodory] s ↔
∀ t : Set α,
P t →
inducedOuterMeasure m P0 m0 (t ∩ s) + inducedOuterMeasure m P0 m0 (t \ s) ≤
inducedOuterMeasure m P0 m0 t := by
rw [isCaratheodory_iff_le]
constructor
· intro h t _ht
exact h t
· intro h u
conv_rhs => rw [inducedOuterMeasure_eq_iInf _ msU m_mono]
refine le_iInf ?_
intro t
refine le_iInf ?_
intro ht
refine le_iInf ?_
intro h2t
refine le_trans ?_ ((h t ht).trans_eq <| inducedOuterMeasure_eq' _ msU m_mono ht)
gcongr
end ExtendSet
/-! If `P` is `MeasurableSet` for some measurable space, then we can remove some hypotheses of the
above lemmas. -/
section MeasurableSpace
variable {α : Type*} [MeasurableSpace α]
variable {m : ∀ s : Set α, MeasurableSet s → ℝ≥0∞}
variable (m0 : m ∅ MeasurableSet.empty = 0)
variable
(mU :
∀ ⦃f : ℕ → Set α⦄ (hm : ∀ i, MeasurableSet (f i)),
Pairwise (Disjoint on f) → m (⋃ i, f i) (MeasurableSet.iUnion hm) = ∑' i, m (f i) (hm i))
include m0 mU
theorem extend_mono {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁) (hs : s₁ ⊆ s₂) :
extend m s₁ ≤ extend m s₂ := by
refine le_iInf ?_; intro h₂
have :=
extend_union MeasurableSet.empty m0 MeasurableSet.iUnion mU disjoint_sdiff_self_right h₁
(h₂.diff h₁)
rw [union_diff_cancel hs] at this
rw [← extend_eq m]
exact le_iff_exists_add.2 ⟨_, this⟩
theorem extend_iUnion_le_tsum_nat : ∀ s : ℕ → Set α,
extend m (⋃ i, s i) ≤ ∑' i, extend m (s i) := by
refine extend_iUnion_le_tsum_nat' MeasurableSet.iUnion ?_; intro f h
simp +singlePass only [iUnion_disjointed.symm]
rw [mU (MeasurableSet.disjointed h) (disjoint_disjointed _)]
refine ENNReal.tsum_le_tsum fun i => ?_
rw [← extend_eq m, ← extend_eq m]
exact extend_mono m0 mU (MeasurableSet.disjointed h _) (disjointed_le f _)
theorem inducedOuterMeasure_eq_extend {s : Set α} (hs : MeasurableSet s) :
inducedOuterMeasure m MeasurableSet.empty m0 s = extend m s :=
ofFunction_eq s (fun _t => extend_mono m0 mU hs) (extend_iUnion_le_tsum_nat m0 mU)
theorem inducedOuterMeasure_eq {s : Set α} (hs : MeasurableSet s) :
inducedOuterMeasure m MeasurableSet.empty m0 s = m s hs :=
(inducedOuterMeasure_eq_extend m0 mU hs).trans <| extend_eq _ _
end MeasurableSpace
namespace OuterMeasure
variable {α : Type*} [MeasurableSpace α] (m : OuterMeasure α)
/-- Given an outer measure `m` we can forget its value on non-measurable sets, and then consider
`m.trim`, the unique maximal outer measure less than that function. -/
def trim : OuterMeasure α :=
inducedOuterMeasure (P := MeasurableSet) (fun s _ => m s) .empty m.empty
theorem le_trim_iff {m₁ m₂ : OuterMeasure α} :
m₁ ≤ m₂.trim ↔ ∀ s, MeasurableSet s → m₁ s ≤ m₂ s :=
le_inducedOuterMeasure
theorem le_trim : m ≤ m.trim := le_trim_iff.2 fun _ _ ↦ le_rfl
lemma null_of_trim_null {s : Set α} (h : m.trim s = 0) : m s = 0 :=
nonpos_iff_eq_zero.1 <| (le_trim m s).trans_eq h
@[simp]
theorem trim_eq {s : Set α} (hs : MeasurableSet s) : m.trim s = m s :=
inducedOuterMeasure_eq' MeasurableSet.iUnion (fun f _hf => measure_iUnion_le f)
(fun _ _ _ _ h => measure_mono h) hs
theorem trim_congr {m₁ m₂ : OuterMeasure α} (H : ∀ {s : Set α}, MeasurableSet s → m₁ s = m₂ s) :
m₁.trim = m₂.trim := by
simp +contextual only [trim, H]
@[mono]
theorem trim_mono : Monotone (trim : OuterMeasure α → OuterMeasure α) := fun _m₁ _m₂ H _s =>
iInf₂_mono fun _f _hs => ENNReal.tsum_le_tsum fun _b => iInf_mono fun _hf => H _
/-- `OuterMeasure.trim` is antitone in the σ-algebra. -/
theorem trim_anti_measurableSpace {α} (m : OuterMeasure α) {m0 m1 : MeasurableSpace α}
(h : m0 ≤ m1) : @trim _ m1 m ≤ @trim _ m0 m := by
simp only [le_trim_iff]
intro s hs
rw [trim_eq _ (h s hs)]
theorem trim_le_trim_iff {m₁ m₂ : OuterMeasure α} :
m₁.trim ≤ m₂.trim ↔ ∀ s, MeasurableSet s → m₁ s ≤ m₂ s :=
le_trim_iff.trans <| forall₂_congr fun s hs => by rw [trim_eq _ hs]
theorem trim_eq_trim_iff {m₁ m₂ : OuterMeasure α} :
m₁.trim = m₂.trim ↔ ∀ s, MeasurableSet s → m₁ s = m₂ s := by
simp only [le_antisymm_iff, trim_le_trim_iff, forall_and]
theorem trim_eq_iInf (s : Set α) : m.trim s = ⨅ (t) (_ : s ⊆ t) (_ : MeasurableSet t), m t := by
simp +singlePass only [iInf_comm]
exact
inducedOuterMeasure_eq_iInf MeasurableSet.iUnion (fun f _ => measure_iUnion_le f)
(fun _ _ _ _ h => measure_mono h) s
theorem trim_eq_iInf' (s : Set α) : m.trim s = ⨅ t : { t // s ⊆ t ∧ MeasurableSet t }, m t := by
simp [iInf_subtype, iInf_and, trim_eq_iInf]
theorem trim_trim (m : OuterMeasure α) : m.trim.trim = m.trim :=
trim_eq_trim_iff.2 fun _s => m.trim_eq
@[simp]
theorem trim_top : (⊤ : OuterMeasure α).trim = ⊤ :=
top_unique <| le_trim _
@[simp]
theorem trim_zero : (0 : OuterMeasure α).trim = 0 :=
ext fun s =>
le_antisymm
((measure_mono (subset_univ s)).trans_eq <| trim_eq _ MeasurableSet.univ)
(zero_le _)
theorem trim_sum_ge {ι} (m : ι → OuterMeasure α) : (sum fun i => (m i).trim) ≤ (sum m).trim :=
fun s => by
simp only [sum_apply, trim_eq_iInf, le_iInf_iff]
exact fun t st ht =>
ENNReal.tsum_le_tsum fun i => iInf_le_of_le t <| iInf_le_of_le st <| iInf_le _ ht
theorem exists_measurable_superset_eq_trim (m : OuterMeasure α) (s : Set α) :
∃ t, s ⊆ t ∧ MeasurableSet t ∧ m t = m.trim s := by
simp only [trim_eq_iInf]; set ms := ⨅ (t : Set α) (_ : s ⊆ t) (_ : MeasurableSet t), m t
by_cases hs : ms = ∞
· simp only [hs]
simp only [iInf_eq_top, ms] at hs
exact ⟨univ, subset_univ s, MeasurableSet.univ, hs _ (subset_univ s) MeasurableSet.univ⟩
· have : ∀ r > ms, ∃ t, s ⊆ t ∧ MeasurableSet t ∧ m t < r := by
intro r hs
have : ∃ t, MeasurableSet t ∧ s ⊆ t ∧ m t < r := by simpa [ms, iInf_lt_iff] using hs
rcases this with ⟨t, hmt, hin, hlt⟩
exists t
have : ∀ n : ℕ, ∃ t, s ⊆ t ∧ MeasurableSet t ∧ m t < ms + (n : ℝ≥0∞)⁻¹ := by
intro n
refine this _ (ENNReal.lt_add_right hs ?_)
simp
choose t hsub hm hm' using this
refine ⟨⋂ n, t n, subset_iInter hsub, MeasurableSet.iInter hm, ?_⟩
have : Tendsto (fun n : ℕ => ms + (n : ℝ≥0∞)⁻¹) atTop (𝓝 (ms + 0)) :=
tendsto_const_nhds.add ENNReal.tendsto_inv_nat_nhds_zero
rw [add_zero] at this
refine le_antisymm (ge_of_tendsto' this fun n => ?_) ?_
· exact le_trans (measure_mono <| iInter_subset t n) (hm' n).le
· refine iInf_le_of_le (⋂ n, t n) ?_
refine iInf_le_of_le (subset_iInter hsub) ?_
exact iInf_le _ (MeasurableSet.iInter hm)
theorem exists_measurable_superset_of_trim_eq_zero {m : OuterMeasure α} {s : Set α}
(h : m.trim s = 0) : ∃ t, s ⊆ t ∧ MeasurableSet t ∧ m t = 0 := by
rcases exists_measurable_superset_eq_trim m s with ⟨t, hst, ht, hm⟩
exact ⟨t, hst, ht, h ▸ hm⟩
/-- If `μ i` is a countable family of outer measures, then for every set `s` there exists
a measurable set `t ⊇ s` such that `μ i t = (μ i).trim s` for all `i`. -/
theorem exists_measurable_superset_forall_eq_trim {ι} [Countable ι] (μ : ι → OuterMeasure α)
(s : Set α) : ∃ t, s ⊆ t ∧ MeasurableSet t ∧ ∀ i, μ i t = (μ i).trim s := by
choose t hst ht hμt using fun i => (μ i).exists_measurable_superset_eq_trim s
replace hst := subset_iInter hst
replace ht := MeasurableSet.iInter ht
refine ⟨⋂ i, t i, hst, ht, fun i => le_antisymm ?_ ?_⟩
exacts [hμt i ▸ (μ i).mono (iInter_subset _ _), (measure_mono hst).trans_eq ((μ i).trim_eq ht)]
/-- If `m₁ s = op (m₂ s) (m₃ s)` for all `s`, then the same is true for `m₁.trim`, `m₂.trim`,
and `m₃ s`. -/
theorem trim_binop {m₁ m₂ m₃ : OuterMeasure α} {op : ℝ≥0∞ → ℝ≥0∞ → ℝ≥0∞}
(h : ∀ s, m₁ s = op (m₂ s) (m₃ s)) (s : Set α) : m₁.trim s = op (m₂.trim s) (m₃.trim s) := by
rcases exists_measurable_superset_forall_eq_trim ![m₁, m₂, m₃] s with ⟨t, _hst, _ht, htm⟩
simp only [Fin.forall_iff_succ, Matrix.cons_val_zero, Matrix.cons_val_succ] at htm
rw [← htm.1, ← htm.2.1, ← htm.2.2.1, h]
/-- If `m₁ s = op (m₂ s)` for all `s`, then the same is true for `m₁.trim` and `m₂.trim`. -/
theorem trim_op {m₁ m₂ : OuterMeasure α} {op : ℝ≥0∞ → ℝ≥0∞} (h : ∀ s, m₁ s = op (m₂ s))
(s : Set α) : m₁.trim s = op (m₂.trim s) :=
@trim_binop α _ m₁ m₂ 0 (fun a _b => op a) h s
/-- `trim` is additive. -/
theorem trim_add (m₁ m₂ : OuterMeasure α) : (m₁ + m₂).trim = m₁.trim + m₂.trim :=
ext <| trim_binop (add_apply m₁ m₂)
/-- `trim` respects scalar multiplication. -/
theorem trim_smul {R : Type*} [SMul R ℝ≥0∞] [IsScalarTower R ℝ≥0∞ ℝ≥0∞] (c : R)
(m : OuterMeasure α) : (c • m).trim = c • m.trim :=
ext <| trim_op (smul_apply c m)
/-- `trim` sends the supremum of two outer measures to the supremum of the trimmed measures. -/
theorem trim_sup (m₁ m₂ : OuterMeasure α) : (m₁ ⊔ m₂).trim = m₁.trim ⊔ m₂.trim :=
ext fun s => (trim_binop (sup_apply m₁ m₂) s).trans (sup_apply _ _ _).symm
/-- `trim` sends the supremum of a countable family of outer measures to the supremum
of the trimmed measures. -/
theorem trim_iSup {ι} [Countable ι] (μ : ι → OuterMeasure α) :
trim (⨆ i, μ i) = ⨆ i, trim (μ i) := by
simp_rw [← @iSup_plift_down _ ι]
ext1 s
obtain ⟨t, _, _, hμt⟩ :=
exists_measurable_superset_forall_eq_trim
(Option.elim' (⨆ i, μ (PLift.down i)) (μ ∘ PLift.down)) s
simp only [Option.forall, Option.elim'] at hμt
simp only [iSup_apply, ← hμt.1]
exact iSup_congr hμt.2
/-- The trimmed property of a measure μ states that `μ.toOuterMeasure.trim = μ.toOuterMeasure`.
This theorem shows that a restricted trimmed outer measure is a trimmed outer measure. -/
theorem restrict_trim {μ : OuterMeasure α} {s : Set α} (hs : MeasurableSet s) :
(restrict s μ).trim = restrict s μ.trim := by
refine le_antisymm (fun t => ?_) (le_trim_iff.2 fun t ht => ?_)
· rw [restrict_apply]
rcases μ.exists_measurable_superset_eq_trim (t ∩ s) with ⟨t', htt', ht', hμt'⟩
rw [← hμt']
rw [inter_subset] at htt'
refine (measure_mono htt').trans ?_
rw [trim_eq _ (hs.compl.union ht'), restrict_apply, union_inter_distrib_right, compl_inter_self,
Set.empty_union]
exact measure_mono inter_subset_left
· rw [restrict_apply, trim_eq _ (ht.inter hs), restrict_apply]
end OuterMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Basic.lean | import Mathlib.MeasureTheory.Measure.Real
import Mathlib.MeasureTheory.Measure.Typeclasses.Finite
import Mathlib.Topology.Algebra.InfiniteSum.Module
/-!
# Vector-valued measures
This file defines vector-valued measures, which are σ-additive functions from a set to an
additive monoid `M` such that it maps the empty set and non-measurable sets to zero. In the case
that `M = ℝ`, we called the vector measure a signed measure and write `SignedMeasure α`.
Similarly, when `M = ℂ`, we call the measure a complex measure and write `ComplexMeasure α`
(defined in `MeasureTheory/Measure/Complex`).
## Main definitions
* `MeasureTheory.VectorMeasure` is a vector-valued, σ-additive function that maps the empty
and non-measurable set to zero.
* `MeasureTheory.VectorMeasure.map` is the pushforward of a vector measure along a function.
* `MeasureTheory.VectorMeasure.restrict` is the restriction of a vector measure on some set.
## Notation
* `v ≤[i] w` means that the vector measure `v` restricted on the set `i` is less than or equal
to the vector measure `w` restricted on `i`, i.e. `v.restrict i ≤ w.restrict i`.
## Implementation notes
We require all non-measurable sets to be mapped to zero in order for the extensionality lemma
to only compare the underlying functions for measurable sets.
We use `HasSum` instead of `tsum` in the definition of vector measures in comparison to `Measure`
since this provides summability.
## Tags
vector measure, signed measure, complex measure
-/
noncomputable section
open NNReal ENNReal
open scoped Function -- required for scoped `on` notation
namespace MeasureTheory
variable {α β : Type*} {m : MeasurableSpace α}
/-- A vector measure on a measurable space `α` is a σ-additive `M`-valued function (for some `M`
an additive monoid) such that the empty set and non-measurable sets are mapped to zero. -/
structure VectorMeasure (α : Type*) [MeasurableSpace α] (M : Type*) [AddCommMonoid M]
[TopologicalSpace M] where
/-- The measure of sets -/
measureOf' : Set α → M
/-- The empty set has measure zero -/
empty' : measureOf' ∅ = 0
/-- Non-measurable sets have measure zero -/
not_measurable' ⦃i : Set α⦄ : ¬MeasurableSet i → measureOf' i = 0
/-- The measure is σ-additive -/
m_iUnion' ⦃f : ℕ → Set α⦄ : (∀ i, MeasurableSet (f i)) → Pairwise (Disjoint on f) →
HasSum (fun i => measureOf' (f i)) (measureOf' (⋃ i, f i))
/-- A `SignedMeasure` is an `ℝ`-vector measure. -/
abbrev SignedMeasure (α : Type*) [MeasurableSpace α] :=
VectorMeasure α ℝ
open Set
namespace VectorMeasure
section
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
attribute [coe] VectorMeasure.measureOf'
instance instCoeFun : CoeFun (VectorMeasure α M) fun _ => Set α → M :=
⟨VectorMeasure.measureOf'⟩
initialize_simps_projections VectorMeasure (measureOf' → apply)
@[simp]
theorem empty (v : VectorMeasure α M) : v ∅ = 0 :=
v.empty'
theorem not_measurable (v : VectorMeasure α M) {i : Set α} (hi : ¬MeasurableSet i) : v i = 0 :=
v.not_measurable' hi
theorem m_iUnion (v : VectorMeasure α M) {f : ℕ → Set α} (hf₁ : ∀ i, MeasurableSet (f i))
(hf₂ : Pairwise (Disjoint on f)) : HasSum (fun i => v (f i)) (v (⋃ i, f i)) :=
v.m_iUnion' hf₁ hf₂
theorem coe_injective : @Function.Injective (VectorMeasure α M) (Set α → M) (⇑) := fun v w h => by
cases v
cases w
congr
theorem ext_iff' (v w : VectorMeasure α M) : v = w ↔ ∀ i : Set α, v i = w i := by
rw [← coe_injective.eq_iff, funext_iff]
theorem ext_iff (v w : VectorMeasure α M) : v = w ↔ ∀ i : Set α, MeasurableSet i → v i = w i := by
constructor
· rintro rfl _ _
rfl
· rw [ext_iff']
intro h i
by_cases hi : MeasurableSet i
· exact h i hi
· simp_rw [not_measurable _ hi]
@[ext]
theorem ext {s t : VectorMeasure α M} (h : ∀ i : Set α, MeasurableSet i → s i = t i) : s = t :=
(ext_iff s t).2 h
variable [Countable β] {v : VectorMeasure α M} {f : β → Set α}
theorem hasSum_of_disjoint_iUnion (hm : ∀ i, MeasurableSet (f i)) (hd : Pairwise (Disjoint on f)) :
HasSum (fun i => v (f i)) (v (⋃ i, f i)) := by
rcases Countable.exists_injective_nat β with ⟨e, he⟩
rw [← hasSum_extend_zero he]
convert m_iUnion v (f := Function.extend e f fun _ ↦ ∅) _ _
· simp only [Pi.zero_def, Function.apply_extend v, Function.comp_def, empty]
· exact (iSup_extend_bot he _).symm
· simp [Function.apply_extend MeasurableSet, Function.comp_def, hm]
· exact hd.disjoint_extend_bot (he.factorsThrough _)
variable [T2Space M]
theorem of_disjoint_iUnion (hm : ∀ i, MeasurableSet (f i)) (hd : Pairwise (Disjoint on f)) :
v (⋃ i, f i) = ∑' i, v (f i) :=
(hasSum_of_disjoint_iUnion hm hd).tsum_eq.symm
theorem of_union {A B : Set α} (h : Disjoint A B) (hA : MeasurableSet A) (hB : MeasurableSet B) :
v (A ∪ B) = v A + v B := by
rw [Set.union_eq_iUnion, of_disjoint_iUnion, tsum_fintype, Fintype.sum_bool, cond, cond]
exacts [fun b => Bool.casesOn b hB hA, pairwise_disjoint_on_bool.2 h]
theorem of_add_of_diff {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B) (h : A ⊆ B) :
v A + v (B \ A) = v B := by
rw [← of_union (@Set.disjoint_sdiff_right _ A B) hA (hB.diff hA), Set.union_diff_cancel h]
theorem of_diff {M : Type*} [AddCommGroup M] [TopologicalSpace M] [T2Space M]
{v : VectorMeasure α M} {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B)
(h : A ⊆ B) : v (B \ A) = v B - v A := by
rw [← of_add_of_diff hA hB h, add_sub_cancel_left]
theorem of_diff_of_diff_eq_zero {A B : Set α} (hA : MeasurableSet A) (hB : MeasurableSet B)
(h' : v (B \ A) = 0) : v (A \ B) + v B = v A := by
symm
calc
v A = v (A \ B ∪ A ∩ B) := by simp only [Set.diff_union_inter]
_ = v (A \ B) + v (A ∩ B) := by
rw [of_union]
· rw [disjoint_comm]
exact Set.disjoint_of_subset_left A.inter_subset_right disjoint_sdiff_self_right
· exact hA.diff hB
· exact hA.inter hB
_ = v (A \ B) + v (A ∩ B ∪ B \ A) := by
rw [of_union, h', add_zero]
· exact Set.disjoint_of_subset_left A.inter_subset_left disjoint_sdiff_self_right
· exact hA.inter hB
· exact hB.diff hA
_ = v (A \ B) + v B := by rw [Set.union_comm, Set.inter_comm, Set.diff_union_inter]
theorem of_iUnion_nonneg {M : Type*} [TopologicalSpace M]
[AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M]
[OrderClosedTopology M] {v : VectorMeasure α M} (hf₁ : ∀ i, MeasurableSet (f i))
(hf₂ : Pairwise (Disjoint on f)) (hf₃ : ∀ i, 0 ≤ v (f i)) : 0 ≤ v (⋃ i, f i) :=
(v.of_disjoint_iUnion hf₁ hf₂).symm ▸ tsum_nonneg hf₃
theorem of_iUnion_nonpos {M : Type*} [TopologicalSpace M]
[AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M]
[OrderClosedTopology M] {v : VectorMeasure α M} (hf₁ : ∀ i, MeasurableSet (f i))
(hf₂ : Pairwise (Disjoint on f)) (hf₃ : ∀ i, v (f i) ≤ 0) : v (⋃ i, f i) ≤ 0 :=
(v.of_disjoint_iUnion hf₁ hf₂).symm ▸ tsum_nonpos hf₃
theorem of_nonneg_disjoint_union_eq_zero {s : SignedMeasure α} {A B : Set α} (h : Disjoint A B)
(hA₁ : MeasurableSet A) (hB₁ : MeasurableSet B) (hA₂ : 0 ≤ s A) (hB₂ : 0 ≤ s B)
(hAB : s (A ∪ B) = 0) : s A = 0 := by
rw [of_union h hA₁ hB₁] at hAB
linarith
theorem of_nonpos_disjoint_union_eq_zero {s : SignedMeasure α} {A B : Set α} (h : Disjoint A B)
(hA₁ : MeasurableSet A) (hB₁ : MeasurableSet B) (hA₂ : s A ≤ 0) (hB₂ : s B ≤ 0)
(hAB : s (A ∪ B) = 0) : s A = 0 := by
rw [of_union h hA₁ hB₁] at hAB
linarith
end
section SMul
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M]
/-- Given a scalar `r` and a vector measure `v`, `smul r v` is the vector measure corresponding to
the set function `s : Set α => r • (v s)`. -/
def smul (r : R) (v : VectorMeasure α M) : VectorMeasure α M where
measureOf' := r • ⇑v
empty' := by rw [Pi.smul_apply, empty, smul_zero]
not_measurable' _ hi := by rw [Pi.smul_apply, v.not_measurable hi, smul_zero]
m_iUnion' _ hf₁ hf₂ := by exact HasSum.const_smul _ (v.m_iUnion hf₁ hf₂)
instance instSMul : SMul R (VectorMeasure α M) :=
⟨smul⟩
@[simp]
theorem coe_smul (r : R) (v : VectorMeasure α M) : ⇑(r • v) = r • ⇑v := rfl
theorem smul_apply (r : R) (v : VectorMeasure α M) (i : Set α) : (r • v) i = r • v i := rfl
end SMul
section AddCommMonoid
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
instance instZero : Zero (VectorMeasure α M) :=
⟨⟨0, rfl, fun _ _ => rfl, fun _ _ _ => hasSum_zero⟩⟩
instance instInhabited : Inhabited (VectorMeasure α M) :=
⟨0⟩
@[simp]
theorem coe_zero : ⇑(0 : VectorMeasure α M) = 0 := rfl
theorem zero_apply (i : Set α) : (0 : VectorMeasure α M) i = 0 := rfl
variable [ContinuousAdd M]
/-- The sum of two vector measure is a vector measure. -/
def add (v w : VectorMeasure α M) : VectorMeasure α M where
measureOf' := v + w
empty' := by simp
not_measurable' _ hi := by rw [Pi.add_apply, v.not_measurable hi, w.not_measurable hi, add_zero]
m_iUnion' _ hf₁ hf₂ := HasSum.add (v.m_iUnion hf₁ hf₂) (w.m_iUnion hf₁ hf₂)
instance instAdd : Add (VectorMeasure α M) :=
⟨add⟩
@[simp]
theorem coe_add (v w : VectorMeasure α M) : ⇑(v + w) = v + w := rfl
theorem add_apply (v w : VectorMeasure α M) (i : Set α) : (v + w) i = v i + w i := rfl
instance instAddCommMonoid : AddCommMonoid (VectorMeasure α M) :=
Function.Injective.addCommMonoid _ coe_injective coe_zero coe_add fun _ _ => coe_smul _ _
/-- `(⇑)` is an `AddMonoidHom`. -/
@[simps]
def coeFnAddMonoidHom : VectorMeasure α M →+ Set α → M where
toFun := (⇑)
map_zero' := coe_zero
map_add' := coe_add
end AddCommMonoid
section AddCommGroup
variable {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
/-- The negative of a vector measure is a vector measure. -/
def neg (v : VectorMeasure α M) : VectorMeasure α M where
measureOf' := -v
empty' := by simp
not_measurable' _ hi := by rw [Pi.neg_apply, neg_eq_zero, v.not_measurable hi]
m_iUnion' _ hf₁ hf₂ := HasSum.neg <| v.m_iUnion hf₁ hf₂
instance instNeg : Neg (VectorMeasure α M) :=
⟨neg⟩
@[simp]
theorem coe_neg (v : VectorMeasure α M) : ⇑(-v) = -v := rfl
theorem neg_apply (v : VectorMeasure α M) (i : Set α) : (-v) i = -v i := rfl
/-- The difference of two vector measure is a vector measure. -/
def sub (v w : VectorMeasure α M) : VectorMeasure α M where
measureOf' := v - w
empty' := by simp
not_measurable' _ hi := by rw [Pi.sub_apply, v.not_measurable hi, w.not_measurable hi, sub_zero]
m_iUnion' _ hf₁ hf₂ := HasSum.sub (v.m_iUnion hf₁ hf₂) (w.m_iUnion hf₁ hf₂)
instance instSub : Sub (VectorMeasure α M) :=
⟨sub⟩
@[simp]
theorem coe_sub (v w : VectorMeasure α M) : ⇑(v - w) = v - w := rfl
theorem sub_apply (v w : VectorMeasure α M) (i : Set α) : (v - w) i = v i - w i := rfl
instance instAddCommGroup : AddCommGroup (VectorMeasure α M) :=
Function.Injective.addCommGroup _ coe_injective coe_zero coe_add coe_neg coe_sub
(fun _ _ => coe_smul _ _) fun _ _ => coe_smul _ _
end AddCommGroup
section DistribMulAction
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M]
instance instDistribMulAction [ContinuousAdd M] : DistribMulAction R (VectorMeasure α M) :=
Function.Injective.distribMulAction coeFnAddMonoidHom coe_injective coe_smul
end DistribMulAction
section Module
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable {R : Type*} [Semiring R] [Module R M] [ContinuousConstSMul R M]
instance instModule [ContinuousAdd M] : Module R (VectorMeasure α M) :=
Function.Injective.module R coeFnAddMonoidHom coe_injective coe_smul
end Module
end VectorMeasure
namespace Measure
open Classical in
/-- A finite measure coerced into a real function is a signed measure. -/
@[simps]
def toSignedMeasure (μ : Measure α) [hμ : IsFiniteMeasure μ] : SignedMeasure α where
measureOf' := fun s : Set α => if MeasurableSet s then μ.real s else 0
empty' := by simp
not_measurable' _ hi := if_neg hi
m_iUnion' f hf₁ hf₂ := by
simp only [*, MeasurableSet.iUnion hf₁, if_true, measure_iUnion hf₂ hf₁, measureReal_def]
rw [ENNReal.tsum_toReal_eq]
exacts [(summable_measure_toReal hf₁ hf₂).hasSum, fun _ ↦ measure_ne_top _ _]
theorem toSignedMeasure_apply_measurable {μ : Measure α} [IsFiniteMeasure μ] {i : Set α}
(hi : MeasurableSet i) : μ.toSignedMeasure i = μ.real i :=
if_pos hi
-- Without this lemma, `singularPart_neg` in
-- `Mathlib/MeasureTheory/Measure/Decomposition/Lebesgue.lean` is extremely slow
theorem toSignedMeasure_congr {μ ν : Measure α} [IsFiniteMeasure μ] [IsFiniteMeasure ν]
(h : μ = ν) : μ.toSignedMeasure = ν.toSignedMeasure := by
congr
theorem toSignedMeasure_eq_toSignedMeasure_iff {μ ν : Measure α} [IsFiniteMeasure μ]
[IsFiniteMeasure ν] : μ.toSignedMeasure = ν.toSignedMeasure ↔ μ = ν := by
refine ⟨fun h => ?_, fun h => ?_⟩
· ext1 i hi
have : μ.toSignedMeasure i = ν.toSignedMeasure i := by rw [h]
rwa [toSignedMeasure_apply_measurable hi, toSignedMeasure_apply_measurable hi,
measureReal_eq_measureReal_iff] at this
· congr
@[simp]
theorem toSignedMeasure_zero : (0 : Measure α).toSignedMeasure = 0 := by
ext i
simp
@[simp]
theorem toSignedMeasure_add (μ ν : Measure α) [IsFiniteMeasure μ] [IsFiniteMeasure ν] :
(μ + ν).toSignedMeasure = μ.toSignedMeasure + ν.toSignedMeasure := by
ext i hi
rw [toSignedMeasure_apply_measurable hi, measureReal_add_apply,
VectorMeasure.add_apply, toSignedMeasure_apply_measurable hi,
toSignedMeasure_apply_measurable hi]
@[simp]
theorem toSignedMeasure_smul (μ : Measure α) [IsFiniteMeasure μ] (r : ℝ≥0) :
(r • μ).toSignedMeasure = r • μ.toSignedMeasure := by
ext i hi
rw [toSignedMeasure_apply_measurable hi, VectorMeasure.smul_apply,
toSignedMeasure_apply_measurable hi, measureReal_nnreal_smul_apply]
rfl
open Classical in
/-- A measure is a vector measure over `ℝ≥0∞`. -/
@[simps]
def toENNRealVectorMeasure (μ : Measure α) : VectorMeasure α ℝ≥0∞ where
measureOf' := fun i : Set α => if MeasurableSet i then μ i else 0
empty' := by simp
not_measurable' _ hi := if_neg hi
m_iUnion' _ hf₁ hf₂ := by
rw [Summable.hasSum_iff ENNReal.summable, if_pos (MeasurableSet.iUnion hf₁),
MeasureTheory.measure_iUnion hf₂ hf₁]
exact tsum_congr fun n => if_pos (hf₁ n)
theorem toENNRealVectorMeasure_apply_measurable {μ : Measure α} {i : Set α} (hi : MeasurableSet i) :
μ.toENNRealVectorMeasure i = μ i :=
if_pos hi
@[simp]
theorem toENNRealVectorMeasure_zero : (0 : Measure α).toENNRealVectorMeasure = 0 := by
ext i
simp
@[simp]
theorem toENNRealVectorMeasure_add (μ ν : Measure α) :
(μ + ν).toENNRealVectorMeasure = μ.toENNRealVectorMeasure + ν.toENNRealVectorMeasure := by
refine MeasureTheory.VectorMeasure.ext fun i hi => ?_
rw [toENNRealVectorMeasure_apply_measurable hi, add_apply, VectorMeasure.add_apply,
toENNRealVectorMeasure_apply_measurable hi, toENNRealVectorMeasure_apply_measurable hi]
theorem toSignedMeasure_sub_apply {μ ν : Measure α} [IsFiniteMeasure μ] [IsFiniteMeasure ν]
{i : Set α} (hi : MeasurableSet i) :
(μ.toSignedMeasure - ν.toSignedMeasure) i = μ.real i - ν.real i := by
rw [VectorMeasure.sub_apply, toSignedMeasure_apply_measurable hi,
Measure.toSignedMeasure_apply_measurable hi]
end Measure
namespace VectorMeasure
open Measure
section
/-- A vector measure over `ℝ≥0∞` is a measure. -/
def ennrealToMeasure {_ : MeasurableSpace α} (v : VectorMeasure α ℝ≥0∞) : Measure α :=
ofMeasurable (fun s _ => v s) v.empty fun _ hf₁ hf₂ => v.of_disjoint_iUnion hf₁ hf₂
theorem ennrealToMeasure_apply {m : MeasurableSpace α} {v : VectorMeasure α ℝ≥0∞} {s : Set α}
(hs : MeasurableSet s) : ennrealToMeasure v s = v s := by
rw [ennrealToMeasure, ofMeasurable_apply _ hs]
@[simp]
theorem _root_.MeasureTheory.Measure.toENNRealVectorMeasure_ennrealToMeasure
(μ : VectorMeasure α ℝ≥0∞) :
toENNRealVectorMeasure (ennrealToMeasure μ) = μ := ext fun s hs => by
rw [toENNRealVectorMeasure_apply_measurable hs, ennrealToMeasure_apply hs]
@[simp]
theorem ennrealToMeasure_toENNRealVectorMeasure (μ : Measure α) :
ennrealToMeasure (toENNRealVectorMeasure μ) = μ := Measure.ext fun s hs => by
rw [ennrealToMeasure_apply hs, toENNRealVectorMeasure_apply_measurable hs]
/-- The equiv between `VectorMeasure α ℝ≥0∞` and `Measure α` formed by
`MeasureTheory.VectorMeasure.ennrealToMeasure` and
`MeasureTheory.Measure.toENNRealVectorMeasure`. -/
@[simps]
def equivMeasure [MeasurableSpace α] : VectorMeasure α ℝ≥0∞ ≃ Measure α where
toFun := ennrealToMeasure
invFun := toENNRealVectorMeasure
left_inv := toENNRealVectorMeasure_ennrealToMeasure
right_inv := ennrealToMeasure_toENNRealVectorMeasure
end
section
variable [MeasurableSpace α] [MeasurableSpace β]
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable (v : VectorMeasure α M)
open Classical in
/-- The pushforward of a vector measure along a function. -/
def map (v : VectorMeasure α M) (f : α → β) : VectorMeasure β M :=
if hf : Measurable f then
{ measureOf' := fun s => if MeasurableSet s then v (f ⁻¹' s) else 0
empty' := by simp
not_measurable' := fun _ hi => if_neg hi
m_iUnion' := by
intro g hg₁ hg₂
convert v.m_iUnion (fun i => hf (hg₁ i)) fun i j hij => (hg₂ hij).preimage _
· rw [if_pos (hg₁ _)]
· rw [Set.preimage_iUnion, if_pos (MeasurableSet.iUnion hg₁)] }
else 0
theorem map_not_measurable {f : α → β} (hf : ¬Measurable f) : v.map f = 0 :=
dif_neg hf
theorem map_apply {f : α → β} (hf : Measurable f) {s : Set β} (hs : MeasurableSet s) :
v.map f s = v (f ⁻¹' s) := by
rw [map, dif_pos hf]
exact if_pos hs
@[simp]
theorem map_id : v.map id = v :=
ext fun i hi => by rw [map_apply v measurable_id hi, Set.preimage_id]
@[simp]
theorem map_zero (f : α → β) : (0 : VectorMeasure α M).map f = 0 := by
by_cases hf : Measurable f
· ext i hi
rw [map_apply _ hf hi, zero_apply, zero_apply]
· exact dif_neg hf
section
variable {N : Type*} [AddCommMonoid N] [TopologicalSpace N]
/-- Given a vector measure `v` on `M` and a continuous `AddMonoidHom` `f : M → N`, `f ∘ v` is a
vector measure on `N`. -/
def mapRange (v : VectorMeasure α M) (f : M →+ N) (hf : Continuous f) : VectorMeasure α N where
measureOf' s := f (v s)
empty' := by rw [empty, AddMonoidHom.map_zero]
not_measurable' i hi := by rw [not_measurable v hi, AddMonoidHom.map_zero]
m_iUnion' _ hg₁ hg₂ := HasSum.map (v.m_iUnion hg₁ hg₂) f hf
@[simp]
theorem mapRange_apply {f : M →+ N} (hf : Continuous f) {s : Set α} : v.mapRange f hf s = f (v s) :=
rfl
@[simp]
theorem mapRange_id : v.mapRange (AddMonoidHom.id M) continuous_id = v := by
ext
rfl
@[simp]
theorem mapRange_zero {f : M →+ N} (hf : Continuous f) :
mapRange (0 : VectorMeasure α M) f hf = 0 := by
ext
simp
section ContinuousAdd
variable [ContinuousAdd M] [ContinuousAdd N]
@[simp]
theorem mapRange_add {v w : VectorMeasure α M} {f : M →+ N} (hf : Continuous f) :
(v + w).mapRange f hf = v.mapRange f hf + w.mapRange f hf := by
ext
simp
/-- Given a continuous `AddMonoidHom` `f : M → N`, `mapRangeHom` is the `AddMonoidHom` mapping the
vector measure `v` on `M` to the vector measure `f ∘ v` on `N`. -/
def mapRangeHom (f : M →+ N) (hf : Continuous f) : VectorMeasure α M →+ VectorMeasure α N where
toFun v := v.mapRange f hf
map_zero' := mapRange_zero hf
map_add' _ _ := mapRange_add hf
end ContinuousAdd
section Module
variable {R : Type*} [Semiring R] [Module R M] [Module R N]
variable [ContinuousAdd M] [ContinuousAdd N] [ContinuousConstSMul R M] [ContinuousConstSMul R N]
/-- Given a continuous linear map `f : M → N`, `mapRangeₗ` is the linear map mapping the
vector measure `v` on `M` to the vector measure `f ∘ v` on `N`. -/
def mapRangeₗ (f : M →ₗ[R] N) (hf : Continuous f) : VectorMeasure α M →ₗ[R] VectorMeasure α N where
toFun v := v.mapRange f.toAddMonoidHom hf
map_add' _ _ := mapRange_add hf
map_smul' := by
intros
ext
simp
end Module
end
open Classical in
/-- The restriction of a vector measure on some set. -/
def restrict (v : VectorMeasure α M) (i : Set α) : VectorMeasure α M :=
if hi : MeasurableSet i then
{ measureOf' := fun s => if MeasurableSet s then v (s ∩ i) else 0
empty' := by simp
not_measurable' := fun _ hi => if_neg hi
m_iUnion' := by
intro f hf₁ hf₂
convert v.m_iUnion (fun n => (hf₁ n).inter hi)
(hf₂.mono fun i j => Disjoint.mono inf_le_left inf_le_left)
· rw [if_pos (hf₁ _)]
· rw [Set.iUnion_inter, if_pos (MeasurableSet.iUnion hf₁)] }
else 0
theorem restrict_not_measurable {i : Set α} (hi : ¬MeasurableSet i) : v.restrict i = 0 :=
dif_neg hi
theorem restrict_apply {i : Set α} (hi : MeasurableSet i) {j : Set α} (hj : MeasurableSet j) :
v.restrict i j = v (j ∩ i) := by
rw [restrict, dif_pos hi]
exact if_pos hj
theorem restrict_eq_self {i : Set α} (hi : MeasurableSet i) {j : Set α} (hj : MeasurableSet j)
(hij : j ⊆ i) : v.restrict i j = v j := by
rw [restrict_apply v hi hj, Set.inter_eq_left.2 hij]
@[simp]
theorem restrict_empty : v.restrict ∅ = 0 :=
ext fun i hi => by
rw [restrict_apply v MeasurableSet.empty hi, Set.inter_empty, v.empty, zero_apply]
@[simp]
theorem restrict_univ : v.restrict Set.univ = v :=
ext fun i hi => by rw [restrict_apply v MeasurableSet.univ hi, Set.inter_univ]
@[simp]
theorem restrict_zero {i : Set α} : (0 : VectorMeasure α M).restrict i = 0 := by
by_cases hi : MeasurableSet i
· ext j hj
rw [restrict_apply 0 hi hj, zero_apply, zero_apply]
· exact dif_neg hi
section ContinuousAdd
variable [ContinuousAdd M]
theorem map_add (v w : VectorMeasure α M) (f : α → β) : (v + w).map f = v.map f + w.map f := by
by_cases hf : Measurable f
· ext i hi
simp [map_apply _ hf hi]
· simp [map, dif_neg hf]
/-- `VectorMeasure.map` as an additive monoid homomorphism. -/
@[simps]
def mapGm (f : α → β) : VectorMeasure α M →+ VectorMeasure β M where
toFun v := v.map f
map_zero' := map_zero f
map_add' _ _ := map_add _ _ f
@[simp]
theorem restrict_add (v w : VectorMeasure α M) (i : Set α) :
(v + w).restrict i = v.restrict i + w.restrict i := by
by_cases hi : MeasurableSet i
· ext j hj
simp [restrict_apply _ hi hj]
· simp [restrict_not_measurable _ hi]
/-- `VectorMeasure.restrict` as an additive monoid homomorphism. -/
@[simps]
def restrictGm (i : Set α) : VectorMeasure α M →+ VectorMeasure α M where
toFun v := v.restrict i
map_zero' := restrict_zero
map_add' _ _ := restrict_add _ _ i
end ContinuousAdd
section Partition
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [T2Space M] [ContinuousAdd M]
variable (v : VectorMeasure α M) {i : Set α}
@[simp]
theorem restrict_add_restrict_compl (hi : MeasurableSet i) :
v.restrict i + v.restrict iᶜ = v := by
ext A hA
rw [add_apply, restrict_apply _ hi hA, restrict_apply _ hi.compl hA,
← of_union _ (hA.inter hi) (hA.inter hi.compl)]
· simp
· exact disjoint_compl_right.inter_right' A |>.inter_left' A
end Partition
section Sub
variable {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
@[simp]
theorem restrict_neg (v : VectorMeasure α M) (i : Set α) :
(-v).restrict i = -(v.restrict i) := by
by_cases hi : MeasurableSet i
· ext j hj; simp [restrict_apply _ hi hj]
· simp [restrict_not_measurable _ hi]
@[simp]
theorem restrict_sub (v w : VectorMeasure α M) (i : Set α) :
(v - w).restrict i = v.restrict i - w.restrict i := by
simp [sub_eq_add_neg, restrict_add, restrict_neg]
end Sub
end
section
variable [MeasurableSpace β]
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M]
@[simp]
theorem map_smul {v : VectorMeasure α M} {f : α → β} (c : R) : (c • v).map f = c • v.map f := by
by_cases hf : Measurable f
· ext i hi
simp [map_apply _ hf hi]
· simp only [map, dif_neg hf]
-- `smul_zero` does not work since we do not require `ContinuousAdd`
ext i
simp
@[simp]
theorem restrict_smul {v : VectorMeasure α M} {i : Set α} (c : R) :
(c • v).restrict i = c • v.restrict i := by
by_cases hi : MeasurableSet i
· ext j hj
simp [restrict_apply _ hi hj]
· simp only [restrict_not_measurable _ hi]
-- `smul_zero` does not work since we do not require `ContinuousAdd`
ext j
simp
end
section
variable [MeasurableSpace β]
variable {M : Type*} [AddCommMonoid M] [TopologicalSpace M]
variable {R : Type*} [Semiring R] [Module R M] [ContinuousConstSMul R M] [ContinuousAdd M]
/-- `VectorMeasure.map` as a linear map. -/
@[simps]
def mapₗ (f : α → β) : VectorMeasure α M →ₗ[R] VectorMeasure β M where
toFun v := v.map f
map_add' _ _ := map_add _ _ f
map_smul' _ _ := map_smul _
/-- `VectorMeasure.restrict` as an additive monoid homomorphism. -/
@[simps]
def restrictₗ (i : Set α) : VectorMeasure α M →ₗ[R] VectorMeasure α M where
toFun v := v.restrict i
map_add' _ _ := restrict_add _ _ i
map_smul' _ _ := restrict_smul _
end
section
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [PartialOrder M]
/-- Vector measures over a partially ordered monoid is partially ordered.
This definition is consistent with `Measure.instPartialOrder`. -/
instance instPartialOrder : PartialOrder (VectorMeasure α M) where
le v w := ∀ i, MeasurableSet i → v i ≤ w i
le_refl _ _ _ := le_rfl
le_trans _ _ _ h₁ h₂ i hi := le_trans (h₁ i hi) (h₂ i hi)
le_antisymm _ _ h₁ h₂ := ext fun i hi => le_antisymm (h₁ i hi) (h₂ i hi)
variable {v w : VectorMeasure α M}
theorem le_iff : v ≤ w ↔ ∀ i, MeasurableSet i → v i ≤ w i := Iff.rfl
theorem le_iff' : v ≤ w ↔ ∀ i, v i ≤ w i := by
refine ⟨fun h i => ?_, fun h i _ => h i⟩
by_cases hi : MeasurableSet i
· exact h i hi
· rw [v.not_measurable hi, w.not_measurable hi]
end
/-- `v ≤[i] w` is notation for `v.restrict i ≤ w.restrict i`. -/
scoped[MeasureTheory]
notation3:50 v " ≤[" i:50 "] " w:50 =>
MeasureTheory.VectorMeasure.restrict v i ≤ MeasureTheory.VectorMeasure.restrict w i
section
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [PartialOrder M]
variable (v w : VectorMeasure α M)
theorem restrict_le_restrict_iff {i : Set α} (hi : MeasurableSet i) :
v ≤[i] w ↔ ∀ ⦃j⦄, MeasurableSet j → j ⊆ i → v j ≤ w j :=
⟨fun h j hj₁ hj₂ => restrict_eq_self v hi hj₁ hj₂ ▸ restrict_eq_self w hi hj₁ hj₂ ▸ h j hj₁,
fun h => le_iff.1 fun _ hj =>
(restrict_apply v hi hj).symm ▸ (restrict_apply w hi hj).symm ▸
h (hj.inter hi) Set.inter_subset_right⟩
theorem subset_le_of_restrict_le_restrict {i : Set α} (hi : MeasurableSet i) (hi₂ : v ≤[i] w)
{j : Set α} (hj : j ⊆ i) : v j ≤ w j := by
by_cases hj₁ : MeasurableSet j
· exact (restrict_le_restrict_iff _ _ hi).1 hi₂ hj₁ hj
· rw [v.not_measurable hj₁, w.not_measurable hj₁]
theorem restrict_le_restrict_of_subset_le {i : Set α}
(h : ∀ ⦃j⦄, MeasurableSet j → j ⊆ i → v j ≤ w j) : v ≤[i] w := by
by_cases hi : MeasurableSet i
· exact (restrict_le_restrict_iff _ _ hi).2 h
· rw [restrict_not_measurable v hi, restrict_not_measurable w hi]
theorem restrict_le_restrict_subset {i j : Set α} (hi₁ : MeasurableSet i) (hi₂ : v ≤[i] w)
(hij : j ⊆ i) : v ≤[j] w :=
restrict_le_restrict_of_subset_le v w fun _ _ hk₂ =>
subset_le_of_restrict_le_restrict v w hi₁ hi₂ (Set.Subset.trans hk₂ hij)
theorem le_restrict_empty : v ≤[∅] w := by
simp
theorem le_restrict_univ_iff_le : v ≤[Set.univ] w ↔ v ≤ w := by
simp
end
section
variable {M : Type*} [TopologicalSpace M]
[AddCommGroup M] [PartialOrder M] [IsOrderedAddMonoid M] [IsTopologicalAddGroup M]
variable (v w : VectorMeasure α M)
nonrec theorem neg_le_neg {i : Set α} (hi : MeasurableSet i) (h : v ≤[i] w) : -w ≤[i] -v := by
intro j hj₁
rw [restrict_apply _ hi hj₁, restrict_apply _ hi hj₁, neg_apply, neg_apply]
refine neg_le_neg ?_
rw [← restrict_apply _ hi hj₁, ← restrict_apply _ hi hj₁]
exact h j hj₁
theorem neg_le_neg_iff {i : Set α} (hi : MeasurableSet i) : -w ≤[i] -v ↔ v ≤[i] w :=
⟨fun h => neg_neg v ▸ neg_neg w ▸ neg_le_neg _ _ hi h, fun h => neg_le_neg _ _ hi h⟩
end
section
variable {M : Type*} [TopologicalSpace M]
[AddCommMonoid M] [PartialOrder M] [IsOrderedAddMonoid M] [OrderClosedTopology M]
variable (v w : VectorMeasure α M) {i j : Set α}
theorem restrict_le_restrict_iUnion {f : ℕ → Set α} (hf₁ : ∀ n, MeasurableSet (f n))
(hf₂ : ∀ n, v ≤[f n] w) : v ≤[⋃ n, f n] w := by
refine restrict_le_restrict_of_subset_le v w fun a ha₁ ha₂ => ?_
have ha₃ : ⋃ n, a ∩ disjointed f n = a := by
rwa [← Set.inter_iUnion, iUnion_disjointed, Set.inter_eq_left]
have ha₄ : Pairwise (Disjoint on fun n => a ∩ disjointed f n) :=
(disjoint_disjointed _).mono fun i j => Disjoint.mono inf_le_right inf_le_right
rw [← ha₃, v.of_disjoint_iUnion _ ha₄, w.of_disjoint_iUnion _ ha₄]
· refine Summable.tsum_le_tsum (fun n => (restrict_le_restrict_iff v w (hf₁ n)).1 (hf₂ n) ?_ ?_)
?_ ?_
· exact ha₁.inter (MeasurableSet.disjointed hf₁ n)
· exact Set.Subset.trans Set.inter_subset_right (disjointed_subset _ _)
· refine (v.m_iUnion (fun n => ?_) ?_).summable
· exact ha₁.inter (MeasurableSet.disjointed hf₁ n)
· exact (disjoint_disjointed _).mono fun i j => Disjoint.mono inf_le_right inf_le_right
· refine (w.m_iUnion (fun n => ?_) ?_).summable
· exact ha₁.inter (MeasurableSet.disjointed hf₁ n)
· exact (disjoint_disjointed _).mono fun i j => Disjoint.mono inf_le_right inf_le_right
· intro n
exact ha₁.inter (MeasurableSet.disjointed hf₁ n)
· exact fun n => ha₁.inter (MeasurableSet.disjointed hf₁ n)
theorem restrict_le_restrict_countable_iUnion [Countable β] {f : β → Set α}
(hf₁ : ∀ b, MeasurableSet (f b)) (hf₂ : ∀ b, v ≤[f b] w) : v ≤[⋃ b, f b] w := by
cases nonempty_encodable β
rw [← Encodable.iUnion_decode₂]
refine restrict_le_restrict_iUnion v w ?_ ?_
· intro n
measurability
· intro n
rcases Encodable.decode₂ β n with - | b
· simp
· simp [hf₂ b]
theorem restrict_le_restrict_union (hi₁ : MeasurableSet i) (hi₂ : v ≤[i] w) (hj₁ : MeasurableSet j)
(hj₂ : v ≤[j] w) : v ≤[i ∪ j] w := by
rw [Set.union_eq_iUnion]
refine restrict_le_restrict_countable_iUnion v w ?_ ?_
· measurability
· rintro (_ | _) <;> simpa
end
section
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [PartialOrder M]
variable (v w : VectorMeasure α M) {i j : Set α}
theorem nonneg_of_zero_le_restrict (hi₂ : 0 ≤[i] v) : 0 ≤ v i := by
by_cases hi₁ : MeasurableSet i
· exact (restrict_le_restrict_iff _ _ hi₁).1 hi₂ hi₁ Set.Subset.rfl
· rw [v.not_measurable hi₁]
theorem nonpos_of_restrict_le_zero (hi₂ : v ≤[i] 0) : v i ≤ 0 := by
by_cases hi₁ : MeasurableSet i
· exact (restrict_le_restrict_iff _ _ hi₁).1 hi₂ hi₁ Set.Subset.rfl
· rw [v.not_measurable hi₁]
theorem zero_le_restrict_not_measurable (hi : ¬MeasurableSet i) : 0 ≤[i] v := by
rw [restrict_zero, restrict_not_measurable _ hi]
theorem restrict_le_zero_of_not_measurable (hi : ¬MeasurableSet i) : v ≤[i] 0 := by
rw [restrict_zero, restrict_not_measurable _ hi]
theorem measurable_of_not_zero_le_restrict (hi : ¬0 ≤[i] v) : MeasurableSet i :=
Not.imp_symm (zero_le_restrict_not_measurable _) hi
theorem measurable_of_not_restrict_le_zero (hi : ¬v ≤[i] 0) : MeasurableSet i :=
Not.imp_symm (restrict_le_zero_of_not_measurable _) hi
theorem zero_le_restrict_subset (hi₁ : MeasurableSet i) (hij : j ⊆ i) (hi₂ : 0 ≤[i] v) : 0 ≤[j] v :=
restrict_le_restrict_of_subset_le _ _ fun _ hk₁ hk₂ =>
(restrict_le_restrict_iff _ _ hi₁).1 hi₂ hk₁ (Set.Subset.trans hk₂ hij)
theorem restrict_le_zero_subset (hi₁ : MeasurableSet i) (hij : j ⊆ i) (hi₂ : v ≤[i] 0) : v ≤[j] 0 :=
restrict_le_restrict_of_subset_le _ _ fun _ hk₁ hk₂ =>
(restrict_le_restrict_iff _ _ hi₁).1 hi₂ hk₁ (Set.Subset.trans hk₂ hij)
end
section
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [LinearOrder M]
variable (v w : VectorMeasure α M) {i j : Set α}
theorem exists_pos_measure_of_not_restrict_le_zero (hi : ¬v ≤[i] 0) :
∃ j : Set α, MeasurableSet j ∧ j ⊆ i ∧ 0 < v j := by
have hi₁ : MeasurableSet i := measurable_of_not_restrict_le_zero _ hi
rw [restrict_le_restrict_iff _ _ hi₁] at hi
push_neg at hi
exact hi
end
section
variable {M : Type*} [TopologicalSpace M] [AddCommMonoid M] [PartialOrder M]
[AddLeftMono M] [ContinuousAdd M]
instance instAddLeftMono : AddLeftMono (VectorMeasure α M) :=
⟨fun _ _ _ h i hi => by dsimp; grw [h i hi]⟩
end
section
variable {L M N : Type*}
variable [AddCommMonoid L] [TopologicalSpace L] [AddCommMonoid M] [TopologicalSpace M]
[AddCommMonoid N] [TopologicalSpace N]
/-- A vector measure `v` is absolutely continuous with respect to a measure `μ` if for all sets
`s`, `μ s = 0`, we have `v s = 0`. -/
def AbsolutelyContinuous (v : VectorMeasure α M) (w : VectorMeasure α N) :=
∀ ⦃s : Set α⦄, w s = 0 → v s = 0
@[inherit_doc VectorMeasure.AbsolutelyContinuous]
scoped[MeasureTheory] infixl:50 " ≪ᵥ " => MeasureTheory.VectorMeasure.AbsolutelyContinuous
open MeasureTheory
namespace AbsolutelyContinuous
variable {v : VectorMeasure α M} {w : VectorMeasure α N}
theorem mk (h : ∀ ⦃s : Set α⦄, MeasurableSet s → w s = 0 → v s = 0) : v ≪ᵥ w := by
intro s hs
by_cases hmeas : MeasurableSet s
· exact h hmeas hs
· exact not_measurable v hmeas
theorem eq {w : VectorMeasure α M} (h : v = w) : v ≪ᵥ w :=
fun _ hs => h.symm ▸ hs
@[refl]
theorem refl (v : VectorMeasure α M) : v ≪ᵥ v :=
eq rfl
@[trans]
theorem trans {u : VectorMeasure α L} {v : VectorMeasure α M} {w : VectorMeasure α N} (huv : u ≪ᵥ v)
(hvw : v ≪ᵥ w) : u ≪ᵥ w :=
fun _ hs => huv <| hvw hs
theorem zero (v : VectorMeasure α N) : (0 : VectorMeasure α M) ≪ᵥ v :=
fun s _ => VectorMeasure.zero_apply s
theorem neg_left {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
{v : VectorMeasure α M} {w : VectorMeasure α N} (h : v ≪ᵥ w) : -v ≪ᵥ w := by
intro s hs
rw [neg_apply, h hs, neg_zero]
theorem neg_right {N : Type*} [AddCommGroup N] [TopologicalSpace N] [IsTopologicalAddGroup N]
{v : VectorMeasure α M} {w : VectorMeasure α N} (h : v ≪ᵥ w) : v ≪ᵥ -w := by
intro s hs
rw [neg_apply, neg_eq_zero] at hs
exact h hs
theorem add [ContinuousAdd M] {v₁ v₂ : VectorMeasure α M} {w : VectorMeasure α N} (hv₁ : v₁ ≪ᵥ w)
(hv₂ : v₂ ≪ᵥ w) : v₁ + v₂ ≪ᵥ w := by
intro s hs
rw [add_apply, hv₁ hs, hv₂ hs, zero_add]
theorem sub {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
{v₁ v₂ : VectorMeasure α M} {w : VectorMeasure α N} (hv₁ : v₁ ≪ᵥ w) (hv₂ : v₂ ≪ᵥ w) :
v₁ - v₂ ≪ᵥ w := by
intro s hs
rw [sub_apply, hv₁ hs, hv₂ hs, zero_sub, neg_zero]
theorem smul {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M] {r : R}
{v : VectorMeasure α M} {w : VectorMeasure α N} (h : v ≪ᵥ w) : r • v ≪ᵥ w := by
intro s hs
rw [smul_apply, h hs, smul_zero]
theorem map [MeasureSpace β] (h : v ≪ᵥ w) (f : α → β) : v.map f ≪ᵥ w.map f := by
by_cases hf : Measurable f
· refine mk fun s hs hws => ?_
rw [map_apply _ hf hs] at hws ⊢
exact h hws
· intro s _
rw [map_not_measurable v hf, zero_apply]
theorem ennrealToMeasure {μ : VectorMeasure α ℝ≥0∞} :
(∀ ⦃s : Set α⦄, μ.ennrealToMeasure s = 0 → v s = 0) ↔ v ≪ᵥ μ := by
constructor <;> intro h
· refine mk fun s hmeas hs => h ?_
rw [← hs, ennrealToMeasure_apply hmeas]
· intro s hs
by_cases hmeas : MeasurableSet s
· rw [ennrealToMeasure_apply hmeas] at hs
exact h hs
· exact not_measurable v hmeas
end AbsolutelyContinuous
/-- Two vector measures `v` and `w` are said to be mutually singular if there exists a measurable
set `s`, such that for all `t ⊆ s`, `v t = 0` and for all `t ⊆ sᶜ`, `w t = 0`.
We note that we do not require the measurability of `t` in the definition since this makes it easier
to use. This is equivalent to the definition which requires measurability. To prove
`MutuallySingular` with the measurability condition, use
`MeasureTheory.VectorMeasure.MutuallySingular.mk`. -/
def MutuallySingular (v : VectorMeasure α M) (w : VectorMeasure α N) : Prop :=
∃ s : Set α, MeasurableSet s ∧ (∀ t ⊆ s, v t = 0) ∧ ∀ t ⊆ sᶜ, w t = 0
@[inherit_doc VectorMeasure.MutuallySingular]
scoped[MeasureTheory] infixl:60 " ⟂ᵥ " => MeasureTheory.VectorMeasure.MutuallySingular
namespace MutuallySingular
variable {v v₁ v₂ : VectorMeasure α M} {w w₁ w₂ : VectorMeasure α N}
theorem mk (s : Set α) (hs : MeasurableSet s) (h₁ : ∀ t ⊆ s, MeasurableSet t → v t = 0)
(h₂ : ∀ t ⊆ sᶜ, MeasurableSet t → w t = 0) : v ⟂ᵥ w := by
refine ⟨s, hs, fun t hst => ?_, fun t hst => ?_⟩ <;> by_cases ht : MeasurableSet t
· exact h₁ t hst ht
· exact not_measurable v ht
· exact h₂ t hst ht
· exact not_measurable w ht
theorem symm (h : v ⟂ᵥ w) : w ⟂ᵥ v :=
let ⟨s, hmeas, hs₁, hs₂⟩ := h
⟨sᶜ, hmeas.compl, hs₂, fun t ht => hs₁ _ (compl_compl s ▸ ht : t ⊆ s)⟩
theorem zero_right : v ⟂ᵥ (0 : VectorMeasure α N) :=
⟨∅, MeasurableSet.empty, fun _ ht => (Set.subset_empty_iff.1 ht).symm ▸ v.empty,
fun _ _ => zero_apply _⟩
theorem zero_left : (0 : VectorMeasure α M) ⟂ᵥ w :=
zero_right.symm
theorem add_left [T2Space N] [ContinuousAdd M] (h₁ : v₁ ⟂ᵥ w) (h₂ : v₂ ⟂ᵥ w) : v₁ + v₂ ⟂ᵥ w := by
obtain ⟨u, hmu, hu₁, hu₂⟩ := h₁
obtain ⟨v, hmv, hv₁, hv₂⟩ := h₂
refine mk (u ∩ v) (hmu.inter hmv) (fun t ht _ => ?_) fun t ht hmt => ?_
· rw [add_apply, hu₁ _ (Set.subset_inter_iff.1 ht).1, hv₁ _ (Set.subset_inter_iff.1 ht).2,
zero_add]
· rw [Set.compl_inter] at ht
rw [(_ : t = uᶜ ∩ t ∪ vᶜ \ uᶜ ∩ t),
of_union _ (hmu.compl.inter hmt) ((hmv.compl.diff hmu.compl).inter hmt), hu₂, hv₂, add_zero]
· exact Set.Subset.trans Set.inter_subset_left diff_subset
· exact Set.inter_subset_left
· exact disjoint_sdiff_self_right.mono Set.inter_subset_left Set.inter_subset_left
· apply Set.Subset.antisymm <;> intro x hx
· by_cases hxu' : x ∈ uᶜ
· exact Or.inl ⟨hxu', hx⟩
rcases ht hx with (hxu | hxv)
exacts [False.elim (hxu' hxu), Or.inr ⟨⟨hxv, hxu'⟩, hx⟩]
· rcases hx with hx | hx <;> exact hx.2
theorem add_right [T2Space M] [ContinuousAdd N] (h₁ : v ⟂ᵥ w₁) (h₂ : v ⟂ᵥ w₂) : v ⟂ᵥ w₁ + w₂ :=
(add_left h₁.symm h₂.symm).symm
theorem smul_right {R : Type*} [Semiring R] [DistribMulAction R N] [ContinuousConstSMul R N]
(r : R) (h : v ⟂ᵥ w) : v ⟂ᵥ r • w :=
let ⟨s, hmeas, hs₁, hs₂⟩ := h
⟨s, hmeas, hs₁, fun t ht => by simp only [coe_smul, Pi.smul_apply, hs₂ t ht, smul_zero]⟩
theorem smul_left {R : Type*} [Semiring R] [DistribMulAction R M] [ContinuousConstSMul R M] (r : R)
(h : v ⟂ᵥ w) : r • v ⟂ᵥ w :=
(smul_right r h.symm).symm
theorem neg_left {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
{v : VectorMeasure α M} {w : VectorMeasure α N} (h : v ⟂ᵥ w) : -v ⟂ᵥ w := by
obtain ⟨u, hmu, hu₁, hu₂⟩ := h
refine ⟨u, hmu, fun s hs => ?_, hu₂⟩
rw [neg_apply v s, neg_eq_zero]
exact hu₁ s hs
theorem neg_right {N : Type*} [AddCommGroup N] [TopologicalSpace N] [IsTopologicalAddGroup N]
{v : VectorMeasure α M} {w : VectorMeasure α N} (h : v ⟂ᵥ w) : v ⟂ᵥ -w :=
h.symm.neg_left.symm
@[simp]
theorem neg_left_iff {M : Type*} [AddCommGroup M] [TopologicalSpace M] [IsTopologicalAddGroup M]
{v : VectorMeasure α M} {w : VectorMeasure α N} : -v ⟂ᵥ w ↔ v ⟂ᵥ w :=
⟨fun h => neg_neg v ▸ h.neg_left, neg_left⟩
@[simp]
theorem neg_right_iff {N : Type*} [AddCommGroup N] [TopologicalSpace N] [IsTopologicalAddGroup N]
{v : VectorMeasure α M} {w : VectorMeasure α N} : v ⟂ᵥ -w ↔ v ⟂ᵥ w :=
⟨fun h => neg_neg w ▸ h.neg_right, neg_right⟩
end MutuallySingular
section Trim
open Classical in
/-- Restriction of a vector measure onto a sub-σ-algebra. -/
@[simps]
def trim {m n : MeasurableSpace α} (v : VectorMeasure α M) (hle : m ≤ n) :
@VectorMeasure α m M _ _ :=
@VectorMeasure.mk α m M _ _
(fun i => if MeasurableSet[m] i then v i else 0)
(by dsimp only; rw [if_pos (@MeasurableSet.empty _ m), v.empty])
(fun i hi => by dsimp only; rw [if_neg hi])
(fun f hf₁ hf₂ => by
dsimp only
have hf₁' : ∀ k, MeasurableSet[n] (f k) := fun k => hle _ (hf₁ k)
convert v.m_iUnion hf₁' hf₂ using 1
· ext n
rw [if_pos (hf₁ n)]
· rw [if_pos (@MeasurableSet.iUnion _ _ m _ _ hf₁)])
variable {n : MeasurableSpace α} {v : VectorMeasure α M}
theorem trim_eq_self : v.trim le_rfl = v := by
ext i hi
exact if_pos hi
@[simp]
theorem zero_trim (hle : m ≤ n) : (0 : VectorMeasure α M).trim hle = 0 := by
ext i hi
exact if_pos hi
theorem trim_measurableSet_eq (hle : m ≤ n) {i : Set α} (hi : MeasurableSet[m] i) :
v.trim hle i = v i :=
if_pos hi
theorem restrict_trim (hle : m ≤ n) {i : Set α} (hi : MeasurableSet[m] i) :
@VectorMeasure.restrict α m M _ _ (v.trim hle) i = (v.restrict i).trim hle := by
ext j hj
rw [@restrict_apply _ m, trim_measurableSet_eq hle hj, restrict_apply, trim_measurableSet_eq]
all_goals measurability
end Trim
end
end VectorMeasure
namespace SignedMeasure
open VectorMeasure
open MeasureTheory
/-- The underlying function for `SignedMeasure.toMeasureOfZeroLE`. -/
def toMeasureOfZeroLE' (s : SignedMeasure α) (i : Set α) (hi : 0 ≤[i] s) (j : Set α)
(hj : MeasurableSet j) : ℝ≥0∞ :=
((↑) : ℝ≥0 → ℝ≥0∞) ⟨s.restrict i j, le_trans (by simp) (hi j hj)⟩
/-- Given a signed measure `s` and a positive measurable set `i`, `toMeasureOfZeroLE`
provides the measure, mapping measurable sets `j` to `s (i ∩ j)`. -/
def toMeasureOfZeroLE (s : SignedMeasure α) (i : Set α) (hi₁ : MeasurableSet i) (hi₂ : 0 ≤[i] s) :
Measure α := by
refine Measure.ofMeasurable (s.toMeasureOfZeroLE' i hi₂) ?_ ?_
· simp_rw [toMeasureOfZeroLE', s.restrict_apply hi₁ MeasurableSet.empty, Set.empty_inter i,
s.empty]
rfl
· intro f hf₁ hf₂
have h₁ : ∀ n, MeasurableSet (i ∩ f n) := fun n => hi₁.inter (hf₁ n)
have h₂ : Pairwise (Disjoint on fun n : ℕ => i ∩ f n) := by
intro n m hnm
exact ((hf₂ hnm).inf_left' i).inf_right' i
simp only [toMeasureOfZeroLE', s.restrict_apply hi₁ (MeasurableSet.iUnion hf₁), Set.inter_comm,
Set.inter_iUnion, s.of_disjoint_iUnion h₁ h₂]
have h : ∀ n, 0 ≤ s (i ∩ f n) := fun n =>
s.nonneg_of_zero_le_restrict (s.zero_le_restrict_subset hi₁ Set.inter_subset_left hi₂)
rw [NNReal.coe_tsum_of_nonneg h, ENNReal.coe_tsum]
· refine tsum_congr fun n => ?_
simp_rw [s.restrict_apply hi₁ (hf₁ n), Set.inter_comm]
· exact (NNReal.summable_mk h).2 (s.m_iUnion h₁ h₂).summable
variable (s : SignedMeasure α) {i j : Set α}
theorem toMeasureOfZeroLE_apply (hi : 0 ≤[i] s) (hi₁ : MeasurableSet i) (hj₁ : MeasurableSet j) :
s.toMeasureOfZeroLE i hi₁ hi j = ((↑) : ℝ≥0 → ℝ≥0∞) ⟨s (i ∩ j), nonneg_of_zero_le_restrict
s (zero_le_restrict_subset s hi₁ Set.inter_subset_left hi)⟩ := by
simp_rw [toMeasureOfZeroLE, Measure.ofMeasurable_apply _ hj₁, toMeasureOfZeroLE',
s.restrict_apply hi₁ hj₁, Set.inter_comm]
theorem toMeasureOfZeroLE_real_apply (hi : 0 ≤[i] s) (hi₁ : MeasurableSet i)
(hj₁ : MeasurableSet j) :
(s.toMeasureOfZeroLE i hi₁ hi).real j = s (i ∩ j) := by
simp [measureReal_def, toMeasureOfZeroLE_apply, hj₁]
/-- Given a signed measure `s` and a negative measurable set `i`, `toMeasureOfLEZero`
provides the measure, mapping measurable sets `j` to `-s (i ∩ j)`. -/
def toMeasureOfLEZero (s : SignedMeasure α) (i : Set α) (hi₁ : MeasurableSet i) (hi₂ : s ≤[i] 0) :
Measure α :=
toMeasureOfZeroLE (-s) i hi₁ <| @neg_zero (VectorMeasure α ℝ) _ ▸ neg_le_neg _ _ hi₁ hi₂
theorem toMeasureOfLEZero_apply (hi : s ≤[i] 0) (hi₁ : MeasurableSet i) (hj₁ : MeasurableSet j) :
s.toMeasureOfLEZero i hi₁ hi j = ((↑) : ℝ≥0 → ℝ≥0∞) ⟨-s (i ∩ j), neg_apply s (i ∩ j) ▸
nonneg_of_zero_le_restrict _ (zero_le_restrict_subset _ hi₁ Set.inter_subset_left
(@neg_zero (VectorMeasure α ℝ) _ ▸ neg_le_neg _ _ hi₁ hi))⟩ := by
erw [toMeasureOfZeroLE_apply]
· simp
· assumption
theorem toMeasureOfLEZero_real_apply (hi : s ≤[i] 0) (hi₁ : MeasurableSet i)
(hj₁ : MeasurableSet j) :
(s.toMeasureOfLEZero i hi₁ hi).real j = -s (i ∩ j) := by
simp [measureReal_def, toMeasureOfLEZero_apply _ hi hi₁ hj₁]
/-- `SignedMeasure.toMeasureOfZeroLE` is a finite measure. -/
instance toMeasureOfZeroLE_finite (hi : 0 ≤[i] s) (hi₁ : MeasurableSet i) :
IsFiniteMeasure (s.toMeasureOfZeroLE i hi₁ hi) where
measure_univ_lt_top := by
rw [toMeasureOfZeroLE_apply s hi hi₁ MeasurableSet.univ]
exact ENNReal.coe_lt_top
/-- `SignedMeasure.toMeasureOfLEZero` is a finite measure. -/
instance toMeasureOfLEZero_finite (hi : s ≤[i] 0) (hi₁ : MeasurableSet i) :
IsFiniteMeasure (s.toMeasureOfLEZero i hi₁ hi) where
measure_univ_lt_top := by
rw [toMeasureOfLEZero_apply s hi hi₁ MeasurableSet.univ]
exact ENNReal.coe_lt_top
theorem toMeasureOfZeroLE_toSignedMeasure (hs : 0 ≤[Set.univ] s) :
(s.toMeasureOfZeroLE Set.univ MeasurableSet.univ hs).toSignedMeasure = s := by
ext i hi
simp [hi, toMeasureOfZeroLE_apply _ _ _ hi, measureReal_def]
theorem toMeasureOfLEZero_toSignedMeasure (hs : s ≤[Set.univ] 0) :
(s.toMeasureOfLEZero Set.univ MeasurableSet.univ hs).toSignedMeasure = -s := by
ext i hi
simp [hi, toMeasureOfLEZero_apply _ _ _ hi, measureReal_def]
end SignedMeasure
namespace Measure
open VectorMeasure
variable (μ ν : Measure α) [IsFiniteMeasure μ] [IsFiniteMeasure ν] (s : Set α)
theorem zero_le_toSignedMeasure : 0 ≤ μ.toSignedMeasure := by
rw [← le_restrict_univ_iff_le]
refine restrict_le_restrict_of_subset_le _ _ fun j hj₁ _ => ?_
simp only [VectorMeasure.coe_zero, Pi.zero_apply, Measure.toSignedMeasure_apply_measurable hj₁,
measureReal_nonneg]
theorem toSignedMeasure_toMeasureOfZeroLE :
μ.toSignedMeasure.toMeasureOfZeroLE Set.univ MeasurableSet.univ
((le_restrict_univ_iff_le _ _).2 (zero_le_toSignedMeasure μ)) = μ := by
refine Measure.ext fun i hi => ?_
lift μ i to ℝ≥0 using (measure_lt_top _ _).ne with m hm
rw [SignedMeasure.toMeasureOfZeroLE_apply _ _ _ hi, ENNReal.coe_inj]
congr
simp [hi, ← hm, measureReal_def]
theorem toSignedMeasure_restrict_eq_restrict_toSignedMeasure (hs : MeasurableSet s) :
μ.toSignedMeasure.restrict s = (μ.restrict s).toSignedMeasure := by
ext A hA
simp [VectorMeasure.restrict_apply, toSignedMeasure_apply, hA, hs]
theorem toSignedMeasure_le_toSignedMeasure_iff :
μ.toSignedMeasure ≤ ν.toSignedMeasure ↔ μ ≤ ν := by
rw [Measure.le_iff, VectorMeasure.le_iff]
congrm ∀ s, (hs : MeasurableSet s) → ?_
simp_rw [toSignedMeasure_apply_measurable hs, real_def]
apply ENNReal.toReal_le_toReal <;> finiteness
end Measure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/WithDensity.lean | import Mathlib.MeasureTheory.VectorMeasure.Basic
import Mathlib.MeasureTheory.Function.AEEqOfIntegral
/-!
# Vector measure defined by an integral
Given a measure `μ` and an integrable function `f : α → E`, we can define a vector measure `v` such
that for all measurable set `s`, `v i = ∫ x in s, f x ∂μ`. This definition is useful for
the Radon-Nikodym theorem for signed measures.
## Main definitions
* `MeasureTheory.Measure.withDensityᵥ`: the vector measure formed by integrating a function `f`
with respect to a measure `μ` on some set if `f` is integrable, and `0` otherwise.
-/
noncomputable section
open scoped MeasureTheory NNReal ENNReal
variable {α : Type*} {m : MeasurableSpace α}
namespace MeasureTheory
open TopologicalSpace
variable {μ : Measure α}
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
open Classical in
/-- Given a measure `μ` and an integrable function `f`, `μ.withDensityᵥ f` is
the vector measure which maps the set `s` to `∫ₛ f ∂μ`. -/
def Measure.withDensityᵥ {m : MeasurableSpace α} (μ : Measure α) (f : α → E) : VectorMeasure α E :=
if hf : Integrable f μ then
{ measureOf' := fun s => if MeasurableSet s then ∫ x in s, f x ∂μ else 0
empty' := by simp
not_measurable' := fun _ hs => if_neg hs
m_iUnion' := fun s hs₁ hs₂ => by
convert hasSum_integral_iUnion hs₁ hs₂ hf.integrableOn with n
· rw [if_pos (hs₁ n)]
· rw [if_pos (MeasurableSet.iUnion hs₁)] }
else 0
open Measure
variable {f g : α → E}
theorem withDensityᵥ_apply (hf : Integrable f μ) {s : Set α} (hs : MeasurableSet s) :
μ.withDensityᵥ f s = ∫ x in s, f x ∂μ := by rw [withDensityᵥ, dif_pos hf]; exact dif_pos hs
@[simp]
theorem withDensityᵥ_zero : μ.withDensityᵥ (0 : α → E) = 0 := by
ext1 s hs
rw [Pi.zero_def, withDensityᵥ_apply (integrable_zero α E μ) hs]
simp
@[simp]
theorem withDensityᵥ_neg : μ.withDensityᵥ (-f) = -μ.withDensityᵥ f := by
by_cases hf : Integrable f μ
· ext1 i hi
rw [VectorMeasure.neg_apply, withDensityᵥ_apply hf hi, ← integral_neg,
withDensityᵥ_apply hf.neg hi]
simp only [Pi.neg_apply]
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, neg_zero]
rwa [integrable_neg_iff]
theorem withDensityᵥ_neg' : (μ.withDensityᵥ fun x => -f x) = -μ.withDensityᵥ f :=
withDensityᵥ_neg
@[simp]
theorem withDensityᵥ_add (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ (f + g) = μ.withDensityᵥ f + μ.withDensityᵥ g := by
ext1 i hi
rw [withDensityᵥ_apply (hf.add hg) hi, VectorMeasure.add_apply, withDensityᵥ_apply hf hi,
withDensityᵥ_apply hg hi]
simp_rw [Pi.add_apply]
rw [integral_add]
· exact hf.integrableOn
· exact hg.integrableOn
theorem withDensityᵥ_add' (hf : Integrable f μ) (hg : Integrable g μ) :
(μ.withDensityᵥ fun x => f x + g x) = μ.withDensityᵥ f + μ.withDensityᵥ g :=
withDensityᵥ_add hf hg
@[simp]
theorem withDensityᵥ_sub (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ (f - g) = μ.withDensityᵥ f - μ.withDensityᵥ g := by
rw [sub_eq_add_neg, sub_eq_add_neg, withDensityᵥ_add hf hg.neg, withDensityᵥ_neg]
theorem withDensityᵥ_sub' (hf : Integrable f μ) (hg : Integrable g μ) :
(μ.withDensityᵥ fun x => f x - g x) = μ.withDensityᵥ f - μ.withDensityᵥ g :=
withDensityᵥ_sub hf hg
@[simp]
theorem withDensityᵥ_smul {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
[SMulCommClass ℝ 𝕜 E] (f : α → E) (r : 𝕜) : μ.withDensityᵥ (r • f) = r • μ.withDensityᵥ f := by
by_cases hf : Integrable f μ
· ext1 i hi
rw [withDensityᵥ_apply (hf.smul r) hi, VectorMeasure.smul_apply, withDensityᵥ_apply hf hi, ←
integral_smul r f]
simp only [Pi.smul_apply]
· by_cases hr : r = 0
· rw [hr, zero_smul, zero_smul, withDensityᵥ_zero]
· rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg, smul_zero]
rwa [integrable_smul_iff hr f]
theorem withDensityᵥ_smul' {𝕜 : Type*} [NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E]
[SMulCommClass ℝ 𝕜 E] (f : α → E) (r : 𝕜) :
(μ.withDensityᵥ fun x => r • f x) = r • μ.withDensityᵥ f :=
withDensityᵥ_smul f r
theorem withDensityᵥ_smul_eq_withDensityᵥ_withDensity {f : α → ℝ≥0} {g : α → E}
(hf : AEMeasurable f μ) (hfg : Integrable (f • g) μ) :
μ.withDensityᵥ (f • g) = (μ.withDensity (fun x ↦ f x)).withDensityᵥ g := by
ext s hs
rw [withDensityᵥ_apply hfg hs,
withDensityᵥ_apply ((integrable_withDensity_iff_integrable_smul₀ hf).mpr hfg) hs,
setIntegral_withDensity_eq_setIntegral_smul₀ hf.restrict _ hs]
simp only [Pi.smul_apply']
theorem withDensityᵥ_smul_eq_withDensityᵥ_withDensity' {f : α → ℝ≥0∞} {g : α → E}
(hf : AEMeasurable f μ) (hflt : ∀ᵐ x ∂μ, f x < ∞)
(hfg : Integrable (fun x ↦ (f x).toReal • g x) μ) :
μ.withDensityᵥ (fun x ↦ (f x).toReal • g x) = (μ.withDensity f).withDensityᵥ g := by
rw [← withDensity_congr_ae (coe_toNNReal_ae_eq hflt),
← withDensityᵥ_smul_eq_withDensityᵥ_withDensity hf.ennreal_toNNReal hfg]
apply congr_arg
ext
simp [NNReal.smul_def, ENNReal.coe_toNNReal_eq_toReal]
theorem Measure.withDensityᵥ_absolutelyContinuous (μ : Measure α) (f : α → ℝ) :
μ.withDensityᵥ f ≪ᵥ μ.toENNRealVectorMeasure := by
by_cases hf : Integrable f μ
· refine VectorMeasure.AbsolutelyContinuous.mk fun i hi₁ hi₂ => ?_
rw [toENNRealVectorMeasure_apply_measurable hi₁] at hi₂
rw [withDensityᵥ_apply hf hi₁, Measure.restrict_zero_set hi₂, integral_zero_measure]
· rw [withDensityᵥ, dif_neg hf]
exact VectorMeasure.AbsolutelyContinuous.zero _
/-- Having the same density implies the underlying functions are equal almost everywhere. -/
theorem Integrable.ae_eq_of_withDensityᵥ_eq [CompleteSpace E] {f g : α → E} (hf : Integrable f μ)
(hg : Integrable g μ) (hfg : μ.withDensityᵥ f = μ.withDensityᵥ g) : f =ᵐ[μ] g := by
refine hf.ae_eq_of_forall_setIntegral_eq f g hg fun i hi _ => ?_
rw [← withDensityᵥ_apply hf hi, hfg, withDensityᵥ_apply hg hi]
theorem WithDensityᵥEq.congr_ae {f g : α → E} (h : f =ᵐ[μ] g) :
μ.withDensityᵥ f = μ.withDensityᵥ g := by
by_cases hf : Integrable f μ
· ext i hi
rw [withDensityᵥ_apply hf hi, withDensityᵥ_apply (hf.congr h) hi]
exact integral_congr_ae (ae_restrict_of_ae h)
· have hg : ¬Integrable g μ := by intro hg; exact hf (hg.congr h.symm)
rw [withDensityᵥ, withDensityᵥ, dif_neg hf, dif_neg hg]
theorem Integrable.withDensityᵥ_eq_iff [CompleteSpace E]
{f g : α → E} (hf : Integrable f μ) (hg : Integrable g μ) :
μ.withDensityᵥ f = μ.withDensityᵥ g ↔ f =ᵐ[μ] g :=
⟨fun hfg => hf.ae_eq_of_withDensityᵥ_eq hg hfg, fun h => WithDensityᵥEq.congr_ae h⟩
section SignedMeasure
theorem withDensityᵥ_toReal {f : α → ℝ≥0∞} (hfm : AEMeasurable f μ) (hf : (∫⁻ x, f x ∂μ) ≠ ∞) :
(μ.withDensityᵥ fun x => (f x).toReal) =
@toSignedMeasure α _ (μ.withDensity f) (isFiniteMeasure_withDensity hf) := by
have hfi := integrable_toReal_of_lintegral_ne_top hfm hf
haveI := isFiniteMeasure_withDensity hf
ext i hi
rw [withDensityᵥ_apply hfi hi, toSignedMeasure_apply_measurable hi, measureReal_def,
withDensity_apply _ hi, integral_toReal hfm.restrict]
refine ae_lt_top' hfm.restrict (ne_top_of_le_ne_top hf ?_)
conv_rhs => rw [← setLIntegral_univ]
exact lintegral_mono_set (Set.subset_univ _)
theorem withDensityᵥ_eq_withDensity_pos_part_sub_withDensity_neg_part {f : α → ℝ}
(hfi : Integrable f μ) :
μ.withDensityᵥ f =
@toSignedMeasure α _ (μ.withDensity fun x => ENNReal.ofReal <| f x)
(isFiniteMeasure_withDensity_ofReal hfi.2) -
@toSignedMeasure α _ (μ.withDensity fun x => ENNReal.ofReal <| -f x)
(isFiniteMeasure_withDensity_ofReal hfi.neg.2) := by
haveI := isFiniteMeasure_withDensity_ofReal hfi.2
haveI := isFiniteMeasure_withDensity_ofReal hfi.neg.2
ext i hi
rw [withDensityᵥ_apply hfi hi,
integral_eq_lintegral_pos_part_sub_lintegral_neg_part hfi.integrableOn,
VectorMeasure.sub_apply, toSignedMeasure_apply_measurable hi,
toSignedMeasure_apply_measurable hi, measureReal_def, measureReal_def,
withDensity_apply _ hi, withDensity_apply _ hi]
theorem Integrable.withDensityᵥ_trim_eq_integral {m m0 : MeasurableSpace α} {μ : Measure α}
(hm : m ≤ m0) {f : α → ℝ} (hf : Integrable f μ) {i : Set α} (hi : MeasurableSet[m] i) :
(μ.withDensityᵥ f).trim hm i = ∫ x in i, f x ∂μ := by
rw [VectorMeasure.trim_measurableSet_eq hm hi, withDensityᵥ_apply hf (hm _ hi)]
theorem Integrable.withDensityᵥ_trim_absolutelyContinuous {m m0 : MeasurableSpace α} {μ : Measure α}
(hm : m ≤ m0) (hfi : Integrable f μ) :
(μ.withDensityᵥ f).trim hm ≪ᵥ (μ.trim hm).toENNRealVectorMeasure := by
refine VectorMeasure.AbsolutelyContinuous.mk fun j hj₁ hj₂ => ?_
rw [Measure.toENNRealVectorMeasure_apply_measurable hj₁, trim_measurableSet_eq hm hj₁] at hj₂
rw [VectorMeasure.trim_measurableSet_eq hm hj₁, withDensityᵥ_apply hfi (hm _ hj₁)]
simp only [Measure.restrict_eq_zero.mpr hj₂, integral_zero_measure]
end SignedMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Jordan.lean | import Mathlib.MeasureTheory.VectorMeasure.Decomposition.Hahn
import Mathlib.MeasureTheory.Measure.MutuallySingular
import Mathlib.Topology.Algebra.UniformMulAction
/-!
# Jordan decomposition
This file proves the existence and uniqueness of the Jordan decomposition for signed measures.
The Jordan decomposition theorem states that, given a signed measure `s`, there exists a
unique pair of mutually singular measures `μ` and `ν`, such that `s = μ - ν`.
The Jordan decomposition theorem for measures is a corollary of the Hahn decomposition theorem and
is useful for the Lebesgue decomposition theorem.
## Main definitions
* `MeasureTheory.JordanDecomposition`: a Jordan decomposition of a measurable space is a
pair of mutually singular finite measures. We say `j` is a Jordan decomposition of a signed
measure `s` if `s = j.posPart - j.negPart`.
* `MeasureTheory.SignedMeasure.toJordanDecomposition`: the Jordan decomposition of a
signed measure.
* `MeasureTheory.SignedMeasure.toJordanDecompositionEquiv`: is the `Equiv` between
`MeasureTheory.SignedMeasure` and `MeasureTheory.JordanDecomposition` formed by
`MeasureTheory.SignedMeasure.toJordanDecomposition`.
## Main results
* `MeasureTheory.SignedMeasure.toSignedMeasure_toJordanDecomposition` : the Jordan
decomposition theorem.
* `MeasureTheory.JordanDecomposition.toSignedMeasure_injective` : the Jordan decomposition of a
signed measure is unique.
## Tags
Jordan decomposition theorem
-/
noncomputable section
open scoped MeasureTheory ENNReal NNReal
variable {α : Type*} [MeasurableSpace α]
namespace MeasureTheory
/-- A Jordan decomposition of a measurable space is a pair of mutually singular,
finite measures. -/
@[ext]
structure JordanDecomposition (α : Type*) [MeasurableSpace α] where
/-- Positive part of the Jordan decomposition -/
posPart : Measure α
/-- Negative part of the Jordan decomposition -/
negPart : Measure α
[posPart_finite : IsFiniteMeasure posPart]
[negPart_finite : IsFiniteMeasure negPart]
mutuallySingular : posPart ⟂ₘ negPart
attribute [instance] JordanDecomposition.posPart_finite
attribute [instance] JordanDecomposition.negPart_finite
namespace JordanDecomposition
open Measure VectorMeasure
variable (j : JordanDecomposition α)
instance instZero : Zero (JordanDecomposition α) where zero := ⟨0, 0, MutuallySingular.zero_right⟩
instance instInhabited : Inhabited (JordanDecomposition α) where default := 0
instance instInvolutiveNeg : InvolutiveNeg (JordanDecomposition α) where
neg j := ⟨j.negPart, j.posPart, j.mutuallySingular.symm⟩
neg_neg _ := JordanDecomposition.ext rfl rfl
instance instSMul : SMul ℝ≥0 (JordanDecomposition α) where
smul r j :=
⟨r • j.posPart, r • j.negPart,
MutuallySingular.smul _ (MutuallySingular.smul _ j.mutuallySingular.symm).symm⟩
instance instSMulReal : SMul ℝ (JordanDecomposition α) where
smul r j := if 0 ≤ r then r.toNNReal • j else -((-r).toNNReal • j)
@[simp]
theorem zero_posPart : (0 : JordanDecomposition α).posPart = 0 :=
rfl
@[simp]
theorem zero_negPart : (0 : JordanDecomposition α).negPart = 0 :=
rfl
@[simp]
theorem neg_posPart : (-j).posPart = j.negPart :=
rfl
@[simp]
theorem neg_negPart : (-j).negPart = j.posPart :=
rfl
@[simp]
theorem smul_posPart (r : ℝ≥0) : (r • j).posPart = r • j.posPart :=
rfl
@[simp]
theorem smul_negPart (r : ℝ≥0) : (r • j).negPart = r • j.negPart :=
rfl
theorem real_smul_def (r : ℝ) (j : JordanDecomposition α) :
r • j = if 0 ≤ r then r.toNNReal • j else -((-r).toNNReal • j) :=
rfl
@[simp]
theorem coe_smul (r : ℝ≥0) : (r : ℝ) • j = r • j := by
rw [real_smul_def, if_pos (NNReal.coe_nonneg r), Real.toNNReal_coe]
theorem real_smul_nonneg (r : ℝ) (hr : 0 ≤ r) : r • j = r.toNNReal • j :=
dif_pos hr
theorem real_smul_neg (r : ℝ) (hr : r < 0) : r • j = -((-r).toNNReal • j) :=
dif_neg (not_le.2 hr)
theorem real_smul_posPart_nonneg (r : ℝ) (hr : 0 ≤ r) :
(r • j).posPart = r.toNNReal • j.posPart := by
rw [real_smul_def, ← smul_posPart, if_pos hr]
theorem real_smul_negPart_nonneg (r : ℝ) (hr : 0 ≤ r) :
(r • j).negPart = r.toNNReal • j.negPart := by
rw [real_smul_def, ← smul_negPart, if_pos hr]
theorem real_smul_posPart_neg (r : ℝ) (hr : r < 0) :
(r • j).posPart = (-r).toNNReal • j.negPart := by
rw [real_smul_def, ← smul_negPart, if_neg (not_le.2 hr), neg_posPart]
theorem real_smul_negPart_neg (r : ℝ) (hr : r < 0) :
(r • j).negPart = (-r).toNNReal • j.posPart := by
rw [real_smul_def, ← smul_posPart, if_neg (not_le.2 hr), neg_negPart]
/-- The signed measure associated with a Jordan decomposition. -/
def toSignedMeasure : SignedMeasure α :=
j.posPart.toSignedMeasure - j.negPart.toSignedMeasure
theorem toSignedMeasure_zero : (0 : JordanDecomposition α).toSignedMeasure = 0 := by
ext1 i hi
rw [toSignedMeasure, toSignedMeasure_sub_apply hi, zero_posPart, zero_negPart, sub_self,
VectorMeasure.coe_zero, Pi.zero_apply]
theorem toSignedMeasure_neg : (-j).toSignedMeasure = -j.toSignedMeasure := by
ext1 i hi
rw [neg_apply, toSignedMeasure, toSignedMeasure, toSignedMeasure_sub_apply hi,
toSignedMeasure_sub_apply hi, neg_sub, neg_posPart, neg_negPart]
theorem toSignedMeasure_smul (r : ℝ≥0) : (r • j).toSignedMeasure = r • j.toSignedMeasure := by
ext1 i hi
rw [VectorMeasure.smul_apply, toSignedMeasure, toSignedMeasure,
toSignedMeasure_sub_apply hi, toSignedMeasure_sub_apply hi, smul_sub, smul_posPart,
smul_negPart, measureReal_nnreal_smul_apply, measureReal_nnreal_smul_apply]
rfl
/-- A Jordan decomposition provides a Hahn decomposition. -/
theorem exists_compl_positive_negative :
∃ S : Set α,
MeasurableSet S ∧
j.toSignedMeasure ≤[S] 0 ∧
0 ≤[Sᶜ] j.toSignedMeasure ∧ j.posPart S = 0 ∧ j.negPart Sᶜ = 0 := by
obtain ⟨S, hS₁, hS₂, hS₃⟩ := j.mutuallySingular
refine ⟨S, hS₁, ?_, ?_, hS₂, hS₃⟩
· refine restrict_le_restrict_of_subset_le _ _ fun A hA hA₁ => ?_
rw [toSignedMeasure, toSignedMeasure_sub_apply hA, measureReal_def,
show j.posPart A = 0 from nonpos_iff_eq_zero.1 (hS₂ ▸ measure_mono hA₁), ENNReal.toReal_zero,
zero_sub, neg_le, zero_apply, neg_zero]
exact ENNReal.toReal_nonneg
· refine restrict_le_restrict_of_subset_le _ _ fun A hA hA₁ => ?_
rw [toSignedMeasure, toSignedMeasure_sub_apply hA, measureReal_def (μ := j.negPart),
show j.negPart A = 0 from nonpos_iff_eq_zero.1 (hS₃ ▸ measure_mono hA₁), ENNReal.toReal_zero,
sub_zero]
exact ENNReal.toReal_nonneg
end JordanDecomposition
namespace SignedMeasure
open JordanDecomposition Measure Set VectorMeasure
variable {s : SignedMeasure α}
/-- Given a signed measure `s`, `s.toJordanDecomposition` is the Jordan decomposition `j`,
such that `s = j.toSignedMeasure`. This property is known as the Jordan decomposition
theorem, and is shown by
`MeasureTheory.SignedMeasure.toSignedMeasure_toJordanDecomposition`. -/
def toJordanDecomposition (s : SignedMeasure α) : JordanDecomposition α :=
let i := s.exists_compl_positive_negative.choose
have hi := s.exists_compl_positive_negative.choose_spec
{ posPart := s.toMeasureOfZeroLE i hi.1 hi.2.1
negPart := s.toMeasureOfLEZero iᶜ hi.1.compl hi.2.2
posPart_finite := inferInstance
negPart_finite := inferInstance
mutuallySingular := by
refine ⟨iᶜ, hi.1.compl, ?_, ?_⟩
· rw [toMeasureOfZeroLE_apply _ _ hi.1 hi.1.compl]; simp
· rw [toMeasureOfLEZero_apply _ _ hi.1.compl hi.1.compl.compl]; simp }
theorem toJordanDecomposition_spec (s : SignedMeasure α) :
∃ (i : Set α) (hi₁ : MeasurableSet i) (hi₂ : 0 ≤[i] s) (hi₃ : s ≤[iᶜ] 0),
s.toJordanDecomposition.posPart = s.toMeasureOfZeroLE i hi₁ hi₂ ∧
s.toJordanDecomposition.negPart = s.toMeasureOfLEZero iᶜ hi₁.compl hi₃ := by
set i := s.exists_compl_positive_negative.choose
obtain ⟨hi₁, hi₂, hi₃⟩ := s.exists_compl_positive_negative.choose_spec
exact ⟨i, hi₁, hi₂, hi₃, rfl, rfl⟩
/-- **The Jordan decomposition theorem**: Given a signed measure `s`, there exists a pair of
mutually singular measures `μ` and `ν` such that `s = μ - ν`. In this case, the measures `μ`
and `ν` are given by `s.toJordanDecomposition.posPart` and
`s.toJordanDecomposition.negPart` respectively.
Note that we use `MeasureTheory.JordanDecomposition.toSignedMeasure` to represent the
signed measure corresponding to
`s.toJordanDecomposition.posPart - s.toJordanDecomposition.negPart`. -/
@[simp]
theorem toSignedMeasure_toJordanDecomposition (s : SignedMeasure α) :
s.toJordanDecomposition.toSignedMeasure = s := by
obtain ⟨i, hi₁, hi₂, hi₃, hμ, hν⟩ := s.toJordanDecomposition_spec
simp only [JordanDecomposition.toSignedMeasure, hμ, hν]
ext k hk
rw [toSignedMeasure_sub_apply hk, toMeasureOfZeroLE_real_apply _ hi₂ hi₁ hk,
toMeasureOfLEZero_real_apply _ hi₃ hi₁.compl hk]
simp only [sub_neg_eq_add]
rw [← of_union _ (MeasurableSet.inter hi₁ hk) (MeasurableSet.inter hi₁.compl hk),
Set.inter_comm i, Set.inter_comm iᶜ, Set.inter_union_compl _ _]
exact (disjoint_compl_right.inf_left _).inf_right _
section
variable {u v w : Set α}
/-- A subset `v` of a null-set `w` has zero measure if `w` is a subset of a positive set `u`. -/
theorem subset_positive_null_set (hu : MeasurableSet u) (hv : MeasurableSet v)
(hw : MeasurableSet w) (hsu : 0 ≤[u] s) (hw₁ : s w = 0) (hw₂ : w ⊆ u) (hwt : v ⊆ w) :
s v = 0 := by
have : s v + s (w \ v) = 0 := by
rw [← hw₁, ← of_union Set.disjoint_sdiff_right hv (hw.diff hv), Set.union_diff_self,
Set.union_eq_self_of_subset_left hwt]
have h₁ := nonneg_of_zero_le_restrict _ (restrict_le_restrict_subset _ _ hu hsu (hwt.trans hw₂))
have h₂ : 0 ≤ s (w \ v) :=
nonneg_of_zero_le_restrict _
(restrict_le_restrict_subset _ _ hu hsu (diff_subset.trans hw₂))
linarith
/-- A subset `v` of a null-set `w` has zero measure if `w` is a subset of a negative set `u`. -/
theorem subset_negative_null_set (hu : MeasurableSet u) (hv : MeasurableSet v)
(hw : MeasurableSet w) (hsu : s ≤[u] 0) (hw₁ : s w = 0) (hw₂ : w ⊆ u) (hwt : v ⊆ w) :
s v = 0 := by
rw [← s.neg_le_neg_iff _ hu, neg_zero] at hsu
have := subset_positive_null_set hu hv hw hsu
simp only [Pi.neg_apply, neg_eq_zero, coe_neg] at this
exact this hw₁ hw₂ hwt
open scoped symmDiff
/-- If the symmetric difference of two positive sets is a null-set, then so are the differences
between the two sets. -/
theorem of_diff_eq_zero_of_symmDiff_eq_zero_positive (hu : MeasurableSet u) (hv : MeasurableSet v)
(hsu : 0 ≤[u] s) (hsv : 0 ≤[v] s) (hs : s (u ∆ v) = 0) : s (u \ v) = 0 ∧ s (v \ u) = 0 := by
rw [restrict_le_restrict_iff] at hsu hsv
on_goal 1 =>
have a := hsu (hu.diff hv) diff_subset
have b := hsv (hv.diff hu) diff_subset
rw [Set.symmDiff_def,
of_union (v := s) (Set.disjoint_of_subset_left diff_subset disjoint_sdiff_self_right)
(hu.diff hv) (hv.diff hu)] at hs
rw [zero_apply] at a b
constructor
all_goals first | linarith | assumption
/-- If the symmetric difference of two negative sets is a null-set, then so are the differences
between the two sets. -/
theorem of_diff_eq_zero_of_symmDiff_eq_zero_negative (hu : MeasurableSet u) (hv : MeasurableSet v)
(hsu : s ≤[u] 0) (hsv : s ≤[v] 0) (hs : s (u ∆ v) = 0) : s (u \ v) = 0 ∧ s (v \ u) = 0 := by
rw [← s.neg_le_neg_iff _ hu, neg_zero] at hsu
rw [← s.neg_le_neg_iff _ hv, neg_zero] at hsv
have := of_diff_eq_zero_of_symmDiff_eq_zero_positive hu hv hsu hsv
simp only [Pi.neg_apply, neg_eq_zero, coe_neg] at this
exact this hs
theorem of_inter_eq_of_symmDiff_eq_zero_positive (hu : MeasurableSet u) (hv : MeasurableSet v)
(hw : MeasurableSet w) (hsu : 0 ≤[u] s) (hsv : 0 ≤[v] s) (hs : s (u ∆ v) = 0) :
s (w ∩ u) = s (w ∩ v) := by
have hwuv : s ((w ∩ u) ∆ (w ∩ v)) = 0 := by
refine
subset_positive_null_set (hu.union hv) ((hw.inter hu).symmDiff (hw.inter hv))
(hu.symmDiff hv) (restrict_le_restrict_union _ _ hu hsu hv hsv) hs
Set.symmDiff_subset_union ?_
rw [← Set.inter_symmDiff_distrib_left]
exact Set.inter_subset_right
obtain ⟨huv, hvu⟩ :=
of_diff_eq_zero_of_symmDiff_eq_zero_positive (hw.inter hu) (hw.inter hv)
(restrict_le_restrict_subset _ _ hu hsu (w.inter_subset_right))
(restrict_le_restrict_subset _ _ hv hsv (w.inter_subset_right)) hwuv
rw [← of_diff_of_diff_eq_zero (hw.inter hu) (hw.inter hv) hvu, huv, zero_add]
theorem of_inter_eq_of_symmDiff_eq_zero_negative (hu : MeasurableSet u) (hv : MeasurableSet v)
(hw : MeasurableSet w) (hsu : s ≤[u] 0) (hsv : s ≤[v] 0) (hs : s (u ∆ v) = 0) :
s (w ∩ u) = s (w ∩ v) := by
rw [← s.neg_le_neg_iff _ hu, neg_zero] at hsu
rw [← s.neg_le_neg_iff _ hv, neg_zero] at hsv
have := of_inter_eq_of_symmDiff_eq_zero_positive hu hv hw hsu hsv
simp only [Pi.neg_apply, neg_inj, neg_eq_zero, coe_neg] at this
exact this hs
end
end SignedMeasure
namespace JordanDecomposition
open Measure VectorMeasure SignedMeasure Function
private theorem eq_of_posPart_eq_posPart {j₁ j₂ : JordanDecomposition α}
(hj : j₁.posPart = j₂.posPart) (hj' : j₁.toSignedMeasure = j₂.toSignedMeasure) : j₁ = j₂ := by
ext1
· exact hj
· rw [← toSignedMeasure_eq_toSignedMeasure_iff]
unfold toSignedMeasure at hj'
simp_rw [hj, sub_right_inj] at hj'
exact hj'
/-- The Jordan decomposition of a signed measure is unique. -/
theorem toSignedMeasure_injective : Injective <| @JordanDecomposition.toSignedMeasure α _ := by
/- The main idea is that two Jordan decompositions of a signed measure provide two
Hahn decompositions for that measure. Then, from `of_symmDiff_compl_positive_negative`,
the symmetric difference of the two Hahn decompositions has measure zero, thus, allowing us to
show the equality of the underlying measures of the Jordan decompositions. -/
intro j₁ j₂ hj
-- obtain the two Hahn decompositions from the Jordan decompositions
obtain ⟨S, hS₁, hS₂, hS₃, hS₄, hS₅⟩ := j₁.exists_compl_positive_negative
obtain ⟨T, hT₁, hT₂, hT₃, hT₄, hT₅⟩ := j₂.exists_compl_positive_negative
rw [← hj] at hT₂ hT₃
-- the symmetric differences of the two Hahn decompositions have measure zero
obtain ⟨hST₁, -⟩ :=
of_symmDiff_compl_positive_negative hS₁.compl hT₁.compl ⟨hS₃, (compl_compl S).symm ▸ hS₂⟩
⟨hT₃, (compl_compl T).symm ▸ hT₂⟩
-- it suffices to show the Jordan decompositions have the same positive parts
refine eq_of_posPart_eq_posPart ?_ hj
ext1 i hi
-- we see that the positive parts of the two Jordan decompositions are equal to their
-- associated signed measures restricted on their associated Hahn decompositions
have hμ₁ : j₁.posPart.real i = j₁.toSignedMeasure (i ∩ Sᶜ) := by
rw [toSignedMeasure, toSignedMeasure_sub_apply (hi.inter hS₁.compl),
measureReal_def (μ := j₁.negPart),
show j₁.negPart (i ∩ Sᶜ) = 0 from
nonpos_iff_eq_zero.1 (hS₅ ▸ measure_mono Set.inter_subset_right),
ENNReal.toReal_zero, sub_zero]
conv_lhs => rw [← Set.inter_union_compl i S]
rw [measureReal_union, measureReal_def,
show j₁.posPart (i ∩ S) = 0 from
nonpos_iff_eq_zero.1 (hS₄ ▸ measure_mono Set.inter_subset_right),
ENNReal.toReal_zero, zero_add]
· refine
Set.disjoint_of_subset_left Set.inter_subset_right
(Set.disjoint_of_subset_right Set.inter_subset_right disjoint_compl_right)
· exact hi.inter hS₁.compl
have hμ₂ : j₂.posPart.real i = j₂.toSignedMeasure (i ∩ Tᶜ) := by
rw [toSignedMeasure, toSignedMeasure_sub_apply (hi.inter hT₁.compl),
measureReal_def (μ := j₂.negPart),
show j₂.negPart (i ∩ Tᶜ) = 0 from
nonpos_iff_eq_zero.1 (hT₅ ▸ measure_mono Set.inter_subset_right),
ENNReal.toReal_zero, sub_zero]
conv_lhs => rw [← Set.inter_union_compl i T]
rw [measureReal_union, measureReal_def,
show j₂.posPart (i ∩ T) = 0 from
nonpos_iff_eq_zero.1 (hT₄ ▸ measure_mono Set.inter_subset_right),
ENNReal.toReal_zero, zero_add]
· exact
Set.disjoint_of_subset_left Set.inter_subset_right
(Set.disjoint_of_subset_right Set.inter_subset_right disjoint_compl_right)
· exact hi.inter hT₁.compl
-- since the two signed measures associated with the Jordan decompositions are the same,
-- and the symmetric difference of the Hahn decompositions have measure zero, the result follows
rw [← measureReal_eq_measureReal_iff, hμ₁, hμ₂, ← hj]
exact of_inter_eq_of_symmDiff_eq_zero_positive hS₁.compl hT₁.compl hi hS₃ hT₃ hST₁
@[simp]
theorem toJordanDecomposition_toSignedMeasure (j : JordanDecomposition α) :
j.toSignedMeasure.toJordanDecomposition = j :=
(@toSignedMeasure_injective _ _ j j.toSignedMeasure.toJordanDecomposition (by simp)).symm
end JordanDecomposition
namespace SignedMeasure
open JordanDecomposition
/-- `MeasureTheory.SignedMeasure.toJordanDecomposition` and
`MeasureTheory.JordanDecomposition.toSignedMeasure` form an `Equiv`. -/
@[simps apply symm_apply]
def toJordanDecompositionEquiv (α : Type*) [MeasurableSpace α] :
SignedMeasure α ≃ JordanDecomposition α where
toFun := toJordanDecomposition
invFun := toSignedMeasure
left_inv := toSignedMeasure_toJordanDecomposition
right_inv := toJordanDecomposition_toSignedMeasure
theorem toJordanDecomposition_zero : (0 : SignedMeasure α).toJordanDecomposition = 0 := by
apply toSignedMeasure_injective
simp [toSignedMeasure_zero]
theorem toJordanDecomposition_neg (s : SignedMeasure α) :
(-s).toJordanDecomposition = -s.toJordanDecomposition := by
apply toSignedMeasure_injective
simp [toSignedMeasure_neg]
theorem toJordanDecomposition_smul (s : SignedMeasure α) (r : ℝ≥0) :
(r • s).toJordanDecomposition = r • s.toJordanDecomposition := by
apply toSignedMeasure_injective
simp [toSignedMeasure_smul]
private theorem toJordanDecomposition_smul_real_nonneg (s : SignedMeasure α) (r : ℝ)
(hr : 0 ≤ r) : (r • s).toJordanDecomposition = r • s.toJordanDecomposition := by
lift r to ℝ≥0 using hr
rw [JordanDecomposition.coe_smul, ← toJordanDecomposition_smul]
rfl
theorem toJordanDecomposition_smul_real (s : SignedMeasure α) (r : ℝ) :
(r • s).toJordanDecomposition = r • s.toJordanDecomposition := by
by_cases! hr : 0 ≤ r
· exact toJordanDecomposition_smul_real_nonneg s r hr
· ext1
· rw [real_smul_posPart_neg _ _ hr,
show r • s = -(-r • s) by rw [neg_smul, neg_neg], toJordanDecomposition_neg, neg_posPart,
toJordanDecomposition_smul_real_nonneg, ← smul_negPart, real_smul_nonneg]
all_goals exact Left.nonneg_neg_iff.2 hr.le
· rw [real_smul_negPart_neg _ _ hr,
show r • s = -(-r • s) by rw [neg_smul, neg_neg], toJordanDecomposition_neg, neg_negPart,
toJordanDecomposition_smul_real_nonneg, ← smul_posPart, real_smul_nonneg]
all_goals exact Left.nonneg_neg_iff.2 hr.le
theorem toJordanDecomposition_eq {s : SignedMeasure α} {j : JordanDecomposition α}
(h : s = j.toSignedMeasure) : s.toJordanDecomposition = j := by
rw [h, toJordanDecomposition_toSignedMeasure]
/-- The total variation of a signed measure. -/
def totalVariation (s : SignedMeasure α) : Measure α :=
s.toJordanDecomposition.posPart + s.toJordanDecomposition.negPart
theorem totalVariation_zero : (0 : SignedMeasure α).totalVariation = 0 := by
simp [totalVariation, toJordanDecomposition_zero]
theorem totalVariation_neg (s : SignedMeasure α) : (-s).totalVariation = s.totalVariation := by
simp [totalVariation, toJordanDecomposition_neg, add_comm]
theorem null_of_totalVariation_zero (s : SignedMeasure α) {i : Set α}
(hs : s.totalVariation i = 0) : s i = 0 := by
rw [totalVariation, Measure.coe_add, Pi.add_apply, add_eq_zero] at hs
rw [← toSignedMeasure_toJordanDecomposition s, toSignedMeasure, VectorMeasure.coe_sub,
Pi.sub_apply, Measure.toSignedMeasure_apply, Measure.toSignedMeasure_apply]
by_cases hi : MeasurableSet i
· simp [hs.1, hs.2, measureReal_def]
· simp [if_neg hi]
theorem absolutelyContinuous_ennreal_iff (s : SignedMeasure α) (μ : VectorMeasure α ℝ≥0∞) :
s ≪ᵥ μ ↔ s.totalVariation ≪ μ.ennrealToMeasure := by
constructor <;> intro h
· refine Measure.AbsolutelyContinuous.mk fun S hS₁ hS₂ => ?_
obtain ⟨i, hi₁, hi₂, hi₃, hpos, hneg⟩ := s.toJordanDecomposition_spec
rw [totalVariation, Measure.add_apply, hpos, hneg, toMeasureOfZeroLE_apply _ _ _ hS₁,
toMeasureOfLEZero_apply _ _ _ hS₁]
rw [← VectorMeasure.AbsolutelyContinuous.ennrealToMeasure] at h
simp [h (measure_mono_null (i.inter_subset_right) hS₂),
h (measure_mono_null (iᶜ.inter_subset_right) hS₂)]
· refine VectorMeasure.AbsolutelyContinuous.mk fun S hS₁ hS₂ => ?_
rw [← VectorMeasure.ennrealToMeasure_apply hS₁] at hS₂
exact null_of_totalVariation_zero s (h hS₂)
theorem totalVariation_absolutelyContinuous_iff (s : SignedMeasure α) (μ : Measure α) :
s.totalVariation ≪ μ ↔
s.toJordanDecomposition.posPart ≪ μ ∧ s.toJordanDecomposition.negPart ≪ μ := by
constructor <;> intro h
· constructor
all_goals
refine Measure.AbsolutelyContinuous.mk fun S _ hS₂ => ?_
have := h hS₂
rw [totalVariation, Measure.add_apply, add_eq_zero] at this
exacts [this.1, this.2]
· refine Measure.AbsolutelyContinuous.mk fun S _ hS₂ => ?_
rw [totalVariation, Measure.add_apply, h.1 hS₂, h.2 hS₂, add_zero]
-- TODO: Generalize to vector measures once total variation on vector measures is defined
theorem mutuallySingular_iff (s t : SignedMeasure α) :
s ⟂ᵥ t ↔ s.totalVariation ⟂ₘ t.totalVariation := by
constructor
· rintro ⟨u, hmeas, hu₁, hu₂⟩
obtain ⟨i, hi₁, hi₂, hi₃, hipos, hineg⟩ := s.toJordanDecomposition_spec
obtain ⟨j, hj₁, hj₂, hj₃, hjpos, hjneg⟩ := t.toJordanDecomposition_spec
refine ⟨u, hmeas, ?_, ?_⟩
· rw [totalVariation, Measure.add_apply, hipos, hineg, toMeasureOfZeroLE_apply _ _ _ hmeas,
toMeasureOfLEZero_apply _ _ _ hmeas]
simp [hu₁ _ Set.inter_subset_right]
· rw [totalVariation, Measure.add_apply, hjpos, hjneg,
toMeasureOfZeroLE_apply _ _ _ hmeas.compl,
toMeasureOfLEZero_apply _ _ _ hmeas.compl]
simp [hu₂ _ Set.inter_subset_right]
· rintro ⟨u, hmeas, hu₁, hu₂⟩
exact
⟨u, hmeas, fun t htu => null_of_totalVariation_zero _ (measure_mono_null htu hu₁),
fun t htv => null_of_totalVariation_zero _ (measure_mono_null htv hu₂)⟩
theorem mutuallySingular_ennreal_iff (s : SignedMeasure α) (μ : VectorMeasure α ℝ≥0∞) :
s ⟂ᵥ μ ↔ s.totalVariation ⟂ₘ μ.ennrealToMeasure := by
constructor
· rintro ⟨u, hmeas, hu₁, hu₂⟩
obtain ⟨i, hi₁, hi₂, hi₃, hpos, hneg⟩ := s.toJordanDecomposition_spec
refine ⟨u, hmeas, ?_, ?_⟩
· rw [totalVariation, Measure.add_apply, hpos, hneg, toMeasureOfZeroLE_apply _ _ _ hmeas,
toMeasureOfLEZero_apply _ _ _ hmeas]
simp [hu₁ _ Set.inter_subset_right]
· rw [VectorMeasure.ennrealToMeasure_apply hmeas.compl]
exact hu₂ _ (Set.Subset.refl _)
· rintro ⟨u, hmeas, hu₁, hu₂⟩
refine
VectorMeasure.MutuallySingular.mk u hmeas
(fun t htu _ => null_of_totalVariation_zero _ (measure_mono_null htu hu₁)) fun t htv hmt =>
?_
rw [← VectorMeasure.ennrealToMeasure_apply hmt]
exact measure_mono_null htv hu₂
theorem totalVariation_mutuallySingular_iff (s : SignedMeasure α) (μ : Measure α) :
s.totalVariation ⟂ₘ μ ↔
s.toJordanDecomposition.posPart ⟂ₘ μ ∧ s.toJordanDecomposition.negPart ⟂ₘ μ :=
Measure.MutuallySingular.add_left_iff
end SignedMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Decomposition/JordanSub.lean | import Mathlib.MeasureTheory.Measure.Decomposition.Hahn
import Mathlib.MeasureTheory.Measure.Sub
import Mathlib.MeasureTheory.VectorMeasure.Decomposition.Jordan
/-!
# Jordan decomposition from signed measure subtraction
This file develops the Jordan decomposition of the signed measure `μ - ν` for finite measures `μ`
and `ν`, expressing it as the pair `(μ - ν, ν - μ)` of mutually singular finite measures.
The key tool is the Hahn decomposition theorem, which yields a measurable partition of the space
where `μ ≤ ν` and `ν ≤ μ`, and the measure difference behaves like a signed measure difference.
## Main results
* `toJordanDecomposition_toSignedMeasure_sub`:
The Jordan decomposition of `μ.toSignedMeasure - ν.toSignedMeasure` is given by
`(μ - ν, ν - μ)`. It relies on the following intermediate results.
* `mutually_singular_measure_sub`:
The measures `μ - ν` and `ν - μ` are mutually singular.
* `sub_toSignedMeasure_eq_toSignedMeasure_sub`:
The signed measure `μ.toSignedMeasure - ν.toSignedMeasure` equals
`(μ - ν).toSignedMeasure - (ν - μ).toSignedMeasure`.
-/
open scoped ENNReal NNReal
namespace MeasureTheory.Measure
noncomputable section
variable {X : Type*} {mX : MeasurableSpace X}
variable {s : Set X}
variable {μ ν : Measure X}
lemma sub_apply_eq_zero_of_isHahnDecomposition
(hs : IsHahnDecomposition μ ν s) : (μ - ν) s = 0 := by
rw [← restrict_eq_zero, restrict_sub_eq_restrict_sub_restrict hs.measurableSet]
exact sub_eq_zero_of_le hs.le_on
variable [IsFiniteMeasure μ] [IsFiniteMeasure ν]
theorem mutually_singular_measure_sub :
(μ - ν).MutuallySingular (ν - μ) := by
obtain ⟨s, hs⟩ := exists_isHahnDecomposition μ ν
exact ⟨s, hs.measurableSet,
sub_apply_eq_zero_of_isHahnDecomposition hs,
sub_apply_eq_zero_of_isHahnDecomposition hs.compl⟩
lemma toSignedMeasure_restrict_sub (hs : IsHahnDecomposition μ ν s) :
((ν - μ).restrict s).toSignedMeasure =
ν.toSignedMeasure.restrict s - μ.toSignedMeasure.restrict s := by
have hmeas := hs.measurableSet
rw [eq_sub_iff_add_eq, toSignedMeasure_restrict_eq_restrict_toSignedMeasure _ _ hmeas,
← toSignedMeasure_add]
simp only [restrict_sub_eq_restrict_sub_restrict, hmeas, sub_add_cancel_of_le hs.le_on]
exact (toSignedMeasure_restrict_eq_restrict_toSignedMeasure _ _ hmeas).symm
theorem sub_toSignedMeasure_eq_toSignedMeasure_sub :
μ.toSignedMeasure - ν.toSignedMeasure =
(μ - ν).toSignedMeasure - (ν - μ).toSignedMeasure := by
obtain ⟨s, hs⟩ := exists_isHahnDecomposition μ ν
have hsc := hs.compl
have h₁ := toSignedMeasure_restrict_sub hs
have h₂ := toSignedMeasure_restrict_sub hsc
have h₁' := toSignedMeasure_congr <| restrict_eq_zero.mpr <|
sub_apply_eq_zero_of_isHahnDecomposition hs
have h₂' := toSignedMeasure_congr <| restrict_eq_zero.mpr <|
sub_apply_eq_zero_of_isHahnDecomposition hsc
have partition₁ := VectorMeasure.restrict_add_restrict_compl (μ - ν).toSignedMeasure
hs.measurableSet
have partition₂ := VectorMeasure.restrict_add_restrict_compl (ν - μ).toSignedMeasure
hs.measurableSet
rw [toSignedMeasure_restrict_eq_restrict_toSignedMeasure _ _ hs.measurableSet,
toSignedMeasure_restrict_eq_restrict_toSignedMeasure _ _ hs.measurableSet.compl]
at partition₁ partition₂
rw [h₁', h₂] at partition₁
rw [h₁, h₂'] at partition₂
simp only [toSignedMeasure_zero, zero_add] at partition₁ partition₂
rw [← VectorMeasure.restrict_add_restrict_compl μ.toSignedMeasure hs.measurableSet,
← VectorMeasure.restrict_add_restrict_compl ν.toSignedMeasure hs.measurableSet,
← partition₁, ← partition₂]
repeat rw [sub_eq_add_neg]
abel
/-- The Jordan decomposition associated to the pair of mutually singular measures `μ - ν`
and `ν - μ`. -/
def jordanDecompositionOfToSignedMeasureSub
(μ ν : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν] : JordanDecomposition X where
posPart := μ - ν
negPart := ν - μ
mutuallySingular := mutually_singular_measure_sub
lemma jordanDecompositionOfToSignedMeasureSub_posPart :
(jordanDecompositionOfToSignedMeasureSub μ ν).posPart = μ - ν := rfl
lemma jordanDecompositionOfToSignedMeasureSub_negPart :
(jordanDecompositionOfToSignedMeasureSub μ ν).negPart = ν - μ := rfl
lemma jordanDecompositionOfToSignedMeasureSub_toSignedMeasure :
(jordanDecompositionOfToSignedMeasureSub μ ν).toSignedMeasure =
μ.toSignedMeasure - ν.toSignedMeasure := by
simp_rw [JordanDecomposition.toSignedMeasure, jordanDecompositionOfToSignedMeasureSub_posPart,
jordanDecompositionOfToSignedMeasureSub_negPart, ← sub_toSignedMeasure_eq_toSignedMeasure_sub]
/-- The Jordan decomposition of `μ.toSignedMeasure - ν.toSignedMeasure` is `(μ - ν, ν - μ)`. -/
@[simp]
theorem toJordanDecomposition_toSignedMeasure_sub :
(μ.toSignedMeasure - ν.toSignedMeasure).toJordanDecomposition =
jordanDecompositionOfToSignedMeasureSub μ ν := by
apply JordanDecomposition.toSignedMeasure_injective
rw [SignedMeasure.toSignedMeasure_toJordanDecomposition,
jordanDecompositionOfToSignedMeasureSub_toSignedMeasure]
end
end MeasureTheory.Measure |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Hahn.lean | import Mathlib.MeasureTheory.VectorMeasure.Basic
import Mathlib.Order.SymmDiff
/-!
# Hahn decomposition
This file proves the Hahn decomposition theorem (signed version). The Hahn decomposition theorem
states that, given a signed measure `s`, there exist complementary, measurable sets `i` and `j`,
such that `i` is positive and `j` is negative with respect to `s`; that is, `s` restricted on `i`
is non-negative and `s` restricted on `j` is non-positive.
The Hahn decomposition theorem leads to many other results in measure theory, most notably,
the Jordan decomposition theorem, the Lebesgue decomposition theorem and the Radon-Nikodym theorem.
## Main results
* `MeasureTheory.SignedMeasure.exists_isCompl_positive_negative` : the Hahn decomposition
theorem.
* `MeasureTheory.SignedMeasure.exists_subset_restrict_nonpos` : A measurable set of negative
measure contains a negative subset.
## Notation
We use the notations `0 ≤[i] s` and `s ≤[i] 0` to denote the usual definitions of a set `i`
being positive/negative with respect to the signed measure `s`.
## Tags
Hahn decomposition theorem
-/
noncomputable section
open scoped NNReal ENNReal MeasureTheory
variable {α β : Type*} [MeasurableSpace α]
namespace MeasureTheory
namespace SignedMeasure
open Filter VectorMeasure
variable {s : SignedMeasure α} {i j : Set α}
section ExistsSubsetRestrictNonpos
/-! ### exists_subset_restrict_nonpos
In this section we will prove that a set `i` whose measure is negative contains a negative subset
`j` with respect to the signed measure `s` (i.e. `s ≤[j] 0`), whose measure is negative. This lemma
is used to prove the Hahn decomposition theorem.
To prove this lemma, we will construct a sequence of measurable sets $(A_n)_{n \in \mathbb{N}}$,
such that, for all $n$, $s(A_{n + 1})$ is close to maximal among subsets of
$i \setminus \bigcup_{k \le n} A_k$.
This sequence of sets does not necessarily exist. However, if this sequence terminates; that is,
there does not exists any sets satisfying the property, the last $A_n$ will be a negative subset
of negative measure, hence proving our claim.
In the case that the sequence does not terminate, it is easy to see that
$i \setminus \bigcup_{k = 0}^\infty A_k$ is the required negative set.
To implement this in Lean, we define several auxiliary definitions.
- given the sets `i` and the natural number `n`, `ExistsOneDivLT s i n` is the property that
there exists a measurable set `k ⊆ i` such that `1 / (n + 1) < s k`.
- given the sets `i` and that `i` is not negative, `findExistsOneDivLT s i` is the
least natural number `n` such that `ExistsOneDivLT s i n`.
- given the sets `i` and that `i` is not negative, `someExistsOneDivLT` chooses the set
`k` from `ExistsOneDivLT s i (findExistsOneDivLT s i)`.
- lastly, given the set `i`, `restrictNonposSeq s i` is the sequence of sets defined inductively
where
`restrictNonposSeq s i 0 = someExistsOneDivLT s (i \ ∅)` and
`restrictNonposSeq s i (n + 1) = someExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq k)`.
This definition represents the sequence $(A_n)$ in the proof as described above.
With these definitions, we are able consider the case where the sequence terminates separately,
allowing us to prove `exists_subset_restrict_nonpos`.
-/
/-- Given the set `i` and the natural number `n`, `ExistsOneDivLT s i j` is the property that
there exists a measurable set `k ⊆ i` such that `1 / (n + 1) < s k`. -/
private def ExistsOneDivLT (s : SignedMeasure α) (i : Set α) (n : ℕ) : Prop :=
∃ k : Set α, k ⊆ i ∧ MeasurableSet k ∧ (1 / (n + 1) : ℝ) < s k
private theorem existsNatOneDivLTMeasure_of_not_negative (hi : ¬s ≤[i] 0) :
∃ n : ℕ, ExistsOneDivLT s i n :=
let ⟨k, hj₁, hj₂, hj⟩ := exists_pos_measure_of_not_restrict_le_zero s hi
let ⟨n, hn⟩ := exists_nat_one_div_lt hj
⟨n, k, hj₂, hj₁, hn⟩
open scoped Classical in
/-- Given the set `i`, if `i` is not negative, `findExistsOneDivLT s i` is the
least natural number `n` such that `ExistsOneDivLT s i n`, otherwise, it returns 0. -/
private def findExistsOneDivLT (s : SignedMeasure α) (i : Set α) : ℕ :=
if hi : ¬s ≤[i] 0 then Nat.find (existsNatOneDivLTMeasure_of_not_negative hi) else 0
private theorem findExistsOneDivLT_spec (hi : ¬s ≤[i] 0) :
ExistsOneDivLT s i (findExistsOneDivLT s i) := by
rw [findExistsOneDivLT, dif_pos hi]
convert Nat.find_spec (existsNatOneDivLTMeasure_of_not_negative hi)
private theorem findExistsOneDivLT_min (hi : ¬s ≤[i] 0) {m : ℕ}
(hm : m < findExistsOneDivLT s i) : ¬ExistsOneDivLT s i m := by
classical
rw [findExistsOneDivLT, dif_pos hi] at hm
exact Nat.find_min _ hm
open scoped Classical in
/-- Given the set `i`, if `i` is not negative, `someExistsOneDivLT` chooses the set
`k` from `ExistsOneDivLT s i (findExistsOneDivLT s i)`, otherwise, it returns the
empty set. -/
private def someExistsOneDivLT (s : SignedMeasure α) (i : Set α) : Set α :=
if hi : ¬s ≤[i] 0 then Classical.choose (findExistsOneDivLT_spec hi) else ∅
private theorem someExistsOneDivLT_spec (hi : ¬s ≤[i] 0) :
someExistsOneDivLT s i ⊆ i ∧
MeasurableSet (someExistsOneDivLT s i) ∧
(1 / (findExistsOneDivLT s i + 1) : ℝ) < s (someExistsOneDivLT s i) := by
rw [someExistsOneDivLT, dif_pos hi]
exact Classical.choose_spec (findExistsOneDivLT_spec hi)
private theorem someExistsOneDivLT_subset : someExistsOneDivLT s i ⊆ i := by
by_cases hi : ¬s ≤[i] 0
· exact
let ⟨h, _⟩ := someExistsOneDivLT_spec hi
h
· rw [someExistsOneDivLT, dif_neg hi]
exact Set.empty_subset _
private theorem someExistsOneDivLT_subset' : someExistsOneDivLT s (i \ j) ⊆ i :=
someExistsOneDivLT_subset.trans Set.diff_subset
private theorem someExistsOneDivLT_measurableSet : MeasurableSet (someExistsOneDivLT s i) := by
by_cases hi : ¬s ≤[i] 0
· exact
let ⟨_, h, _⟩ := someExistsOneDivLT_spec hi
h
· rw [someExistsOneDivLT, dif_neg hi]
exact MeasurableSet.empty
private theorem someExistsOneDivLT_lt (hi : ¬s ≤[i] 0) :
(1 / (findExistsOneDivLT s i + 1) : ℝ) < s (someExistsOneDivLT s i) :=
let ⟨_, _, h⟩ := someExistsOneDivLT_spec hi
h
/-- Given the set `i`, `restrictNonposSeq s i` is the sequence of sets defined inductively where
`restrictNonposSeq s i 0 = someExistsOneDivLT s (i \ ∅)` and
`restrictNonposSeq s i (n + 1) = someExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq k)`.
For each `n : ℕ`,`s (restrictNonposSeq s i n)` is close to maximal among all subsets of
`i \ ⋃ k ≤ n, restrictNonposSeq s i k`. -/
private def restrictNonposSeq (s : SignedMeasure α) (i : Set α) : ℕ → Set α
| 0 => someExistsOneDivLT s (i \ ∅) -- I used `i \ ∅` instead of `i` to simplify some proofs
| n + 1 =>
someExistsOneDivLT s
(i \
⋃ (k) (H : k ≤ n),
have : k < n + 1 := Nat.lt_succ_iff.mpr H
restrictNonposSeq s i k)
private theorem restrictNonposSeq_succ (n : ℕ) :
restrictNonposSeq s i n.succ = someExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) := by
rw [restrictNonposSeq]
private theorem restrictNonposSeq_subset (n : ℕ) : restrictNonposSeq s i n ⊆ i := by
cases n <;> · rw [restrictNonposSeq]; exact someExistsOneDivLT_subset'
private theorem restrictNonposSeq_lt (n : ℕ) (hn : ¬s ≤[i \ ⋃ k ≤ n, restrictNonposSeq s i k] 0) :
(1 / (findExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k) + 1) : ℝ) <
s (restrictNonposSeq s i n.succ) := by
rw [restrictNonposSeq_succ]
apply someExistsOneDivLT_lt hn
private theorem measure_of_restrictNonposSeq (hi₂ : ¬s ≤[i] 0) (n : ℕ)
(hn : ¬s ≤[i \ ⋃ k < n, restrictNonposSeq s i k] 0) : 0 < s (restrictNonposSeq s i n) := by
cases n with
| zero =>
rw [restrictNonposSeq]; rw [← @Set.diff_empty _ i] at hi₂
rcases someExistsOneDivLT_spec hi₂ with ⟨_, _, h⟩
exact lt_trans Nat.one_div_pos_of_nat h
| succ n =>
rw [restrictNonposSeq_succ]
have h₁ : ¬s ≤[i \ ⋃ (k : ℕ) (_ : k ≤ n), restrictNonposSeq s i k] 0 := by
refine mt (restrict_le_zero_subset _ ?_ (by simp [Nat.lt_succ_iff])) hn
convert measurable_of_not_restrict_le_zero _ hn using 3
exact funext fun x => by rw [Nat.lt_succ_iff]
rcases someExistsOneDivLT_spec h₁ with ⟨_, _, h⟩
exact lt_trans Nat.one_div_pos_of_nat h
private theorem restrictNonposSeq_measurableSet (n : ℕ) :
MeasurableSet (restrictNonposSeq s i n) := by
cases n <;>
· rw [restrictNonposSeq]
exact someExistsOneDivLT_measurableSet
private theorem restrictNonposSeq_disjoint' {n m : ℕ} (h : n < m) :
restrictNonposSeq s i n ∩ restrictNonposSeq s i m = ∅ := by
rw [Set.eq_empty_iff_forall_notMem]
rintro x ⟨hx₁, hx₂⟩
cases m; · cutsat
· rw [restrictNonposSeq] at hx₂
exact
(someExistsOneDivLT_subset hx₂).2
(Set.mem_iUnion.2 ⟨n, Set.mem_iUnion.2 ⟨Nat.lt_succ_iff.mp h, hx₁⟩⟩)
open scoped Function in -- required for scoped `on` notation
private theorem restrictNonposSeq_disjoint : Pairwise (Disjoint on restrictNonposSeq s i) := by
intro n m h
rw [Function.onFun, Set.disjoint_iff_inter_eq_empty]
rcases lt_or_gt_of_ne h with (h | h)
· rw [restrictNonposSeq_disjoint' h]
· rw [Set.inter_comm, restrictNonposSeq_disjoint' h]
private theorem exists_subset_restrict_nonpos' (hi₁ : MeasurableSet i) (hi₂ : s i < 0)
(hn : ¬∀ n : ℕ, ¬s ≤[i \ ⋃ l < n, restrictNonposSeq s i l] 0) :
∃ j : Set α, MeasurableSet j ∧ j ⊆ i ∧ s ≤[j] 0 ∧ s j < 0 := by
classical
by_cases h : s ≤[i] 0
· exact ⟨i, hi₁, Set.Subset.refl _, h, hi₂⟩
push_neg at hn
set k := Nat.find hn
have hk₂ : s ≤[i \ ⋃ l < k, restrictNonposSeq s i l] 0 := Nat.find_spec hn
have hmeas : MeasurableSet (⋃ (l : ℕ) (_ : l < k), restrictNonposSeq s i l) :=
MeasurableSet.iUnion fun _ => MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _
refine ⟨i \ ⋃ l < k, restrictNonposSeq s i l, hi₁.diff hmeas, Set.diff_subset, hk₂, ?_⟩
rw [of_diff hmeas hi₁, s.of_disjoint_iUnion]
· have h₁ : ∀ l < k, 0 ≤ s (restrictNonposSeq s i l) := by
intro l hl
refine le_of_lt (measure_of_restrictNonposSeq h _ ?_)
refine mt (restrict_le_zero_subset _ (hi₁.diff ?_) (Set.Subset.refl _)) (Nat.find_min hn hl)
exact
MeasurableSet.iUnion fun _ =>
MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _
suffices 0 ≤ ∑' l : ℕ, s (⋃ _ : l < k, restrictNonposSeq s i l) by
rw [sub_neg]
exact lt_of_lt_of_le hi₂ this
refine tsum_nonneg ?_
intro l; by_cases h : l < k
· convert h₁ _ h
ext x
rw [Set.mem_iUnion, exists_prop, and_iff_right_iff_imp]
exact fun _ => h
· convert le_of_eq s.empty.symm
ext; simp only [exists_prop, Set.mem_empty_iff_false, Set.mem_iUnion, not_and, iff_false]
exact fun h' => False.elim (h h')
· intro; exact MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _
· intro a b hab
refine Set.disjoint_iUnion_left.mpr fun _ => ?_
refine Set.disjoint_iUnion_right.mpr fun _ => ?_
exact restrictNonposSeq_disjoint hab
· apply Set.iUnion_subset
intro a x
simp only [and_imp, exists_prop, Set.mem_iUnion]
intro _ hx
exact restrictNonposSeq_subset _ hx
/-- A measurable set of negative measure has a negative subset of negative measure. -/
theorem exists_subset_restrict_nonpos (hi : s i < 0) :
∃ j : Set α, MeasurableSet j ∧ j ⊆ i ∧ s ≤[j] 0 ∧ s j < 0 := by
have hi₁ : MeasurableSet i := by_contradiction fun h => ne_of_lt hi <| s.not_measurable h
by_cases h : s ≤[i] 0; · exact ⟨i, hi₁, Set.Subset.refl _, h, hi⟩
by_cases hn : ∀ n : ℕ, ¬s ≤[i \ ⋃ l < n, restrictNonposSeq s i l] 0
swap; · exact exists_subset_restrict_nonpos' hi₁ hi hn
set A := i \ ⋃ l, restrictNonposSeq s i l with hA
set bdd : ℕ → ℕ := fun n => findExistsOneDivLT s (i \ ⋃ k ≤ n, restrictNonposSeq s i k)
have hn' : ∀ n : ℕ, ¬s ≤[i \ ⋃ l ≤ n, restrictNonposSeq s i l] 0 := by
intro n
convert hn (n + 1) using 5 <;>
· ext l
simp only [exists_prop, Set.mem_iUnion, and_congr_left_iff]
exact fun _ => Nat.lt_succ_iff.symm
have h₁ : s i = s A + ∑' l, s (restrictNonposSeq s i l) := by
rw [hA, ← s.of_disjoint_iUnion, add_comm, of_add_of_diff]
· exact MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _
exacts [hi₁, Set.iUnion_subset fun _ => restrictNonposSeq_subset _, fun _ =>
restrictNonposSeq_measurableSet _, restrictNonposSeq_disjoint]
have h₂ : s A ≤ s i := by
rw [h₁]
apply le_add_of_nonneg_right
exact tsum_nonneg fun n => le_of_lt (measure_of_restrictNonposSeq h _ (hn n))
have h₃' : Summable fun n => (1 / (bdd n + 1) : ℝ) := by
have : Summable fun l => s (restrictNonposSeq s i l) :=
HasSum.summable
(s.m_iUnion (fun _ => restrictNonposSeq_measurableSet _) restrictNonposSeq_disjoint)
refine .of_nonneg_of_le (fun n => ?_) (fun n => ?_)
(this.comp_injective Nat.succ_injective)
· exact le_of_lt Nat.one_div_pos_of_nat
· exact le_of_lt (restrictNonposSeq_lt n (hn' n))
have h₃ : Tendsto (fun n => (bdd n : ℝ) + 1) atTop atTop := by
simp only [one_div] at h₃'
exact Summable.tendsto_atTop_of_pos h₃' fun n => Nat.cast_add_one_pos (bdd n)
have h₄ : Tendsto (fun n => (bdd n : ℝ)) atTop atTop := by
convert atTop.tendsto_atTop_add_const_right (-1) h₃; simp
have A_meas : MeasurableSet A :=
hi₁.diff (MeasurableSet.iUnion fun _ => restrictNonposSeq_measurableSet _)
refine ⟨A, A_meas, Set.diff_subset, ?_, h₂.trans_lt hi⟩
by_contra hnn
rw [restrict_le_restrict_iff _ _ A_meas] at hnn; push_neg at hnn
obtain ⟨E, hE₁, hE₂, hE₃⟩ := hnn
have : ∃ k, 1 ≤ bdd k ∧ 1 / (bdd k : ℝ) < s E := by
rw [tendsto_atTop_atTop] at h₄
obtain ⟨k, hk⟩ := h₄ (max (1 / s E + 1) 1)
refine ⟨k, ?_, ?_⟩
· have hle := le_of_max_le_right (hk k le_rfl)
norm_cast at hle
· have : 1 / s E < bdd k := by
linarith only [le_of_max_le_left (hk k le_rfl)]
rw [one_div] at this ⊢
exact inv_lt_of_inv_lt₀ hE₃ this
obtain ⟨k, hk₁, hk₂⟩ := this
have hA' : A ⊆ i \ ⋃ l ≤ k, restrictNonposSeq s i l := by
apply Set.diff_subset_diff_right
intro x; simp only [Set.mem_iUnion]
rintro ⟨n, _, hn₂⟩
exact ⟨n, hn₂⟩
refine
findExistsOneDivLT_min (hn' k) (Nat.sub_lt hk₁ Nat.zero_lt_one)
⟨E, Set.Subset.trans hE₂ hA', hE₁, ?_⟩
convert hk₂; norm_cast
exact tsub_add_cancel_of_le hk₁
end ExistsSubsetRestrictNonpos
/-- The set of measures of the set of measurable negative sets. -/
def measureOfNegatives (s : SignedMeasure α) : Set ℝ :=
s '' { B | MeasurableSet B ∧ s ≤[B] 0 }
theorem zero_mem_measureOfNegatives : (0 : ℝ) ∈ s.measureOfNegatives :=
⟨∅, ⟨MeasurableSet.empty, le_restrict_empty _ _⟩, s.empty⟩
theorem bddBelow_measureOfNegatives : BddBelow s.measureOfNegatives := by
simp_rw [BddBelow, Set.Nonempty, mem_lowerBounds]
by_contra! h
have h' : ∀ n : ℕ, ∃ y : ℝ, y ∈ s.measureOfNegatives ∧ y < -n := fun n => h (-n)
choose f hf using h'
have hf' : ∀ n : ℕ, ∃ B, MeasurableSet B ∧ s ≤[B] 0 ∧ s B < -n := by
intro n
rcases hf n with ⟨⟨B, ⟨hB₁, hBr⟩, hB₂⟩, hlt⟩
exact ⟨B, hB₁, hBr, hB₂.symm ▸ hlt⟩
choose B hmeas hr h_lt using hf'
set A := ⋃ n, B n with hA
have hfalse : ∀ n : ℕ, s A ≤ -n := by
intro n
refine le_trans ?_ (le_of_lt (h_lt _))
rw [hA, ← Set.diff_union_of_subset (Set.subset_iUnion _ n),
of_union Set.disjoint_sdiff_left _ (hmeas n)]
· refine add_le_of_nonpos_left ?_
have : s ≤[A] 0 := restrict_le_restrict_iUnion _ _ hmeas hr
refine nonpos_of_restrict_le_zero _ (restrict_le_zero_subset _ ?_ Set.diff_subset this)
exact MeasurableSet.iUnion hmeas
· exact (MeasurableSet.iUnion hmeas).diff (hmeas n)
rcases exists_nat_gt (-s A) with ⟨n, hn⟩
exact lt_irrefl _ ((neg_lt.1 hn).trans_le (hfalse n))
/-- Alternative formulation of `MeasureTheory.SignedMeasure.exists_isCompl_positive_negative`
(the Hahn decomposition theorem) using set complements. -/
theorem exists_compl_positive_negative (s : SignedMeasure α) :
∃ i : Set α, MeasurableSet i ∧ 0 ≤[i] s ∧ s ≤[iᶜ] 0 := by
obtain ⟨f, _, hf₂, hf₁⟩ :=
exists_seq_tendsto_sInf ⟨0, @zero_mem_measureOfNegatives _ _ s⟩ bddBelow_measureOfNegatives
choose B hB using hf₁
have hB₁ : ∀ n, MeasurableSet (B n) := fun n => (hB n).1.1
have hB₂ : ∀ n, s ≤[B n] 0 := fun n => (hB n).1.2
set A := ⋃ n, B n with hA
have hA₁ : MeasurableSet A := MeasurableSet.iUnion hB₁
have hA₂ : s ≤[A] 0 := restrict_le_restrict_iUnion _ _ hB₁ hB₂
have hA₃ : s A = sInf s.measureOfNegatives := by
apply le_antisymm
· refine le_of_tendsto_of_tendsto tendsto_const_nhds hf₂ (Eventually.of_forall fun n => ?_)
rw [← (hB n).2, hA, ← Set.diff_union_of_subset (Set.subset_iUnion _ n),
of_union Set.disjoint_sdiff_left _ (hB₁ n)]
· refine add_le_of_nonpos_left ?_
have : s ≤[A] 0 :=
restrict_le_restrict_iUnion _ _ hB₁ fun m =>
let ⟨_, h⟩ := (hB m).1
h
refine
nonpos_of_restrict_le_zero _ (restrict_le_zero_subset _ ?_ Set.diff_subset this)
exact MeasurableSet.iUnion hB₁
· exact (MeasurableSet.iUnion hB₁).diff (hB₁ n)
· exact csInf_le bddBelow_measureOfNegatives ⟨A, ⟨hA₁, hA₂⟩, rfl⟩
refine ⟨Aᶜ, hA₁.compl, ?_, (compl_compl A).symm ▸ hA₂⟩
rw [restrict_le_restrict_iff _ _ hA₁.compl]
intro C _ hC₁
by_contra! hC₂
rcases exists_subset_restrict_nonpos hC₂ with ⟨D, hD₁, hD, hD₂, hD₃⟩
have : s (A ∪ D) < sInf s.measureOfNegatives := by
rw [← hA₃,
of_union (Set.disjoint_of_subset_right (Set.Subset.trans hD hC₁) disjoint_compl_right) hA₁
hD₁]
linarith
refine not_le.2 this ?_
refine csInf_le bddBelow_measureOfNegatives ⟨A ∪ D, ⟨?_, ?_⟩, rfl⟩
· exact hA₁.union hD₁
· exact restrict_le_restrict_union _ _ hA₁ hA₂ hD₁ hD₂
/-- **The Hahn decomposition theorem**: Given a signed measure `s`, there exist
complement measurable sets `i` and `j` such that `i` is positive, `j` is negative. -/
theorem exists_isCompl_positive_negative (s : SignedMeasure α) :
∃ i j : Set α, MeasurableSet i ∧ 0 ≤[i] s ∧ MeasurableSet j ∧ s ≤[j] 0 ∧ IsCompl i j :=
let ⟨i, hi₁, hi₂, hi₃⟩ := exists_compl_positive_negative s
⟨i, iᶜ, hi₁, hi₂, hi₁.compl, hi₃, isCompl_compl⟩
open scoped symmDiff in
/-- The symmetric difference of two Hahn decompositions has measure zero. -/
theorem of_symmDiff_compl_positive_negative {s : SignedMeasure α} {i j : Set α}
(hi : MeasurableSet i) (hj : MeasurableSet j) (hi' : 0 ≤[i] s ∧ s ≤[iᶜ] 0)
(hj' : 0 ≤[j] s ∧ s ≤[jᶜ] 0) : s (i ∆ j) = 0 ∧ s (iᶜ ∆ jᶜ) = 0 := by
rw [restrict_le_restrict_iff s 0, restrict_le_restrict_iff 0 s] at hi' hj'
constructor
· rw [Set.symmDiff_def, Set.diff_eq_compl_inter, Set.diff_eq_compl_inter, of_union,
le_antisymm (hi'.2 (hi.compl.inter hj) Set.inter_subset_left)
(hj'.1 (hi.compl.inter hj) Set.inter_subset_right),
le_antisymm (hj'.2 (hj.compl.inter hi) Set.inter_subset_left)
(hi'.1 (hj.compl.inter hi) Set.inter_subset_right),
zero_apply, zero_apply, zero_add]
· exact
Set.disjoint_of_subset_left Set.inter_subset_left
(Set.disjoint_of_subset_right Set.inter_subset_right
(disjoint_comm.1 (IsCompl.disjoint isCompl_compl)))
· exact hj.compl.inter hi
· exact hi.compl.inter hj
· rw [Set.symmDiff_def, Set.diff_eq_compl_inter, Set.diff_eq_compl_inter, compl_compl,
compl_compl, of_union,
le_antisymm (hi'.2 (hj.inter hi.compl) Set.inter_subset_right)
(hj'.1 (hj.inter hi.compl) Set.inter_subset_left),
le_antisymm (hj'.2 (hi.inter hj.compl) Set.inter_subset_right)
(hi'.1 (hi.inter hj.compl) Set.inter_subset_left),
zero_apply, zero_apply, zero_add]
· exact
Set.disjoint_of_subset_left Set.inter_subset_left
(Set.disjoint_of_subset_right Set.inter_subset_right
(IsCompl.disjoint isCompl_compl))
· exact hj.inter hi.compl
· exact hi.inter hj.compl
all_goals measurability
end SignedMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Decomposition/RadonNikodym.lean | import Mathlib.MeasureTheory.Measure.Decomposition.RadonNikodym
import Mathlib.MeasureTheory.VectorMeasure.Decomposition.Lebesgue
/-!
# Radon-Nikodym derivatives of vector measures
This file contains results about Radon-Nikodym derivatives of signed measures
that depend both on the Lebesgue decomposition of signed measures
and the theory of Radon-Nikodym derivatives of usual measures.
-/
namespace MeasureTheory
variable {α : Type*} {m : MeasurableSpace α}
open Measure VectorMeasure
namespace SignedMeasure
theorem withDensityᵥ_rnDeriv_eq (s : SignedMeasure α) (μ : Measure α) [SigmaFinite μ]
(h : s ≪ᵥ μ.toENNRealVectorMeasure) : μ.withDensityᵥ (s.rnDeriv μ) = s := by
rw [absolutelyContinuous_ennreal_iff, (_ : μ.toENNRealVectorMeasure.ennrealToMeasure = μ),
totalVariation_absolutelyContinuous_iff] at h
· ext1 i hi
rw [withDensityᵥ_apply (integrable_rnDeriv _ _) hi, rnDeriv_def, integral_sub,
setIntegral_toReal_rnDeriv h.1 i, setIntegral_toReal_rnDeriv h.2 i]
· conv_rhs => rw [← s.toSignedMeasure_toJordanDecomposition]
erw [VectorMeasure.sub_apply]
rw [toSignedMeasure_apply_measurable hi, toSignedMeasure_apply_measurable hi, measureReal_def,
measureReal_def]
all_goals
refine Integrable.integrableOn ?_
refine ⟨?_, hasFiniteIntegral_toReal_of_lintegral_ne_top ?_⟩
· apply Measurable.aestronglyMeasurable (by fun_prop)
· exact (lintegral_rnDeriv_lt_top _ _).ne
· exact equivMeasure.right_inv μ
/-- The Radon-Nikodym theorem for signed measures. -/
theorem absolutelyContinuous_iff_withDensityᵥ_rnDeriv_eq (s : SignedMeasure α) (μ : Measure α)
[SigmaFinite μ] : s ≪ᵥ μ.toENNRealVectorMeasure ↔ μ.withDensityᵥ (s.rnDeriv μ) = s :=
⟨withDensityᵥ_rnDeriv_eq s μ, fun h => h ▸ withDensityᵥ_absolutelyContinuous _ _⟩
end SignedMeasure
theorem withDensityᵥ_rnDeriv_smul {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
{μ ν : Measure α} [μ.HaveLebesgueDecomposition ν] [SigmaFinite μ] {f : α → E}
(hμν : μ ≪ ν) (hf : Integrable f μ) :
ν.withDensityᵥ (fun x ↦ (μ.rnDeriv ν x).toReal • f x) = μ.withDensityᵥ f := by
rw [withDensityᵥ_smul_eq_withDensityᵥ_withDensity' (measurable_rnDeriv μ ν).aemeasurable
(rnDeriv_lt_top μ ν) ((integrable_rnDeriv_smul_iff hμν).mpr hf), withDensity_rnDeriv_eq μ ν hμν]
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/VectorMeasure/Decomposition/Lebesgue.lean | import Mathlib.MeasureTheory.Measure.Decomposition.Lebesgue
import Mathlib.MeasureTheory.Measure.Complex
import Mathlib.MeasureTheory.VectorMeasure.Decomposition.Jordan
import Mathlib.MeasureTheory.VectorMeasure.WithDensity
/-!
# Lebesgue decomposition
This file proves the Lebesgue decomposition theorem for signed measures. The Lebesgue decomposition
theorem states that, given two σ-finite measures `μ` and `ν`, there exists a σ-finite measure `ξ`
and a measurable function `f` such that `μ = ξ + fν` and `ξ` is mutually singular with respect
to `ν`.
## Main definitions
* `MeasureTheory.SignedMeasure.HaveLebesgueDecomposition` : A signed measure `s` and a
measure `μ` is said to `HaveLebesgueDecomposition` if both the positive part and negative
part of `s` `HaveLebesgueDecomposition` with respect to `μ`.
* `MeasureTheory.SignedMeasure.singularPart` : The singular part between a signed measure `s`
and a measure `μ` is simply the singular part of the positive part of `s` with respect to `μ`
minus the singular part of the negative part of `s` with respect to `μ`.
* `MeasureTheory.SignedMeasure.rnDeriv` : The Radon-Nikodym derivative of a signed
measure `s` with respect to a measure `μ` is the Radon-Nikodym derivative of the positive part of
`s` with respect to `μ` minus the Radon-Nikodym derivative of the negative part of `s` with
respect to `μ`.
## Main results
* `MeasureTheory.SignedMeasure.singularPart_add_withDensity_rnDeriv_eq` :
the Lebesgue decomposition theorem between a signed measure and a σ-finite positive measure.
## Tags
Lebesgue decomposition theorem
-/
noncomputable section
open scoped MeasureTheory NNReal ENNReal
open Set
variable {α : Type*} {m : MeasurableSpace α} {μ : MeasureTheory.Measure α}
namespace MeasureTheory
namespace SignedMeasure
open Measure
/-- A signed measure `s` is said to `HaveLebesgueDecomposition` with respect to a measure `μ`
if the positive part and the negative part of `s` both `HaveLebesgueDecomposition` with
respect to `μ`. -/
class HaveLebesgueDecomposition (s : SignedMeasure α) (μ : Measure α) : Prop where
posPart : s.toJordanDecomposition.posPart.HaveLebesgueDecomposition μ
negPart : s.toJordanDecomposition.negPart.HaveLebesgueDecomposition μ
attribute [instance] HaveLebesgueDecomposition.posPart
attribute [instance] HaveLebesgueDecomposition.negPart
theorem not_haveLebesgueDecomposition_iff (s : SignedMeasure α) (μ : Measure α) :
¬s.HaveLebesgueDecomposition μ ↔
¬s.toJordanDecomposition.posPart.HaveLebesgueDecomposition μ ∨
¬s.toJordanDecomposition.negPart.HaveLebesgueDecomposition μ :=
⟨fun h => not_or_of_imp fun hp hn => h ⟨hp, hn⟩, fun h hl => (not_and_or.2 h) ⟨hl.1, hl.2⟩⟩
-- `inferInstance` directly does not work
-- see Note [lower instance priority]
instance (priority := 100) haveLebesgueDecomposition_of_sigmaFinite (s : SignedMeasure α)
(μ : Measure α) [SigmaFinite μ] : s.HaveLebesgueDecomposition μ where
posPart := inferInstance
negPart := inferInstance
instance haveLebesgueDecomposition_neg (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] : (-s).HaveLebesgueDecomposition μ where
posPart := by
rw [toJordanDecomposition_neg, JordanDecomposition.neg_posPart]
infer_instance
negPart := by
rw [toJordanDecomposition_neg, JordanDecomposition.neg_negPart]
infer_instance
instance haveLebesgueDecomposition_smul (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] (r : ℝ≥0) : (r • s).HaveLebesgueDecomposition μ where
posPart := by
rw [toJordanDecomposition_smul, JordanDecomposition.smul_posPart]
infer_instance
negPart := by
rw [toJordanDecomposition_smul, JordanDecomposition.smul_negPart]
infer_instance
instance haveLebesgueDecomposition_smul_real (s : SignedMeasure α) (μ : Measure α)
[s.HaveLebesgueDecomposition μ] (r : ℝ) : (r • s).HaveLebesgueDecomposition μ := by
by_cases! hr : 0 ≤ r
· lift r to ℝ≥0 using hr
exact s.haveLebesgueDecomposition_smul μ _
· refine
{ posPart := by
rw [toJordanDecomposition_smul_real, JordanDecomposition.real_smul_posPart_neg _ _ hr]
infer_instance
negPart := by
rw [toJordanDecomposition_smul_real, JordanDecomposition.real_smul_negPart_neg _ _ hr]
infer_instance }
/-- Given a signed measure `s` and a measure `μ`, `s.singularPart μ` is the signed measure
such that `s.singularPart μ + μ.withDensityᵥ (s.rnDeriv μ) = s` and
`s.singularPart μ` is mutually singular with respect to `μ`. -/
def singularPart (s : SignedMeasure α) (μ : Measure α) : SignedMeasure α :=
(s.toJordanDecomposition.posPart.singularPart μ).toSignedMeasure -
(s.toJordanDecomposition.negPart.singularPart μ).toSignedMeasure
section
theorem singularPart_mutuallySingular (s : SignedMeasure α) (μ : Measure α) :
s.toJordanDecomposition.posPart.singularPart μ ⟂ₘ
s.toJordanDecomposition.negPart.singularPart μ := by
by_cases hl : s.HaveLebesgueDecomposition μ
· obtain ⟨i, hi, hpos, hneg⟩ := s.toJordanDecomposition.mutuallySingular
rw [s.toJordanDecomposition.posPart.haveLebesgueDecomposition_add μ] at hpos
rw [s.toJordanDecomposition.negPart.haveLebesgueDecomposition_add μ] at hneg
rw [add_apply, add_eq_zero] at hpos hneg
exact ⟨i, hi, hpos.1, hneg.1⟩
· rw [not_haveLebesgueDecomposition_iff] at hl
rcases hl with hp | hn
· rw [Measure.singularPart, dif_neg hp]
exact MutuallySingular.zero_left
· rw [Measure.singularPart, Measure.singularPart, dif_neg hn]
exact MutuallySingular.zero_right
theorem singularPart_totalVariation (s : SignedMeasure α) (μ : Measure α) :
(s.singularPart μ).totalVariation =
s.toJordanDecomposition.posPart.singularPart μ +
s.toJordanDecomposition.negPart.singularPart μ := by
have :
(s.singularPart μ).toJordanDecomposition =
⟨s.toJordanDecomposition.posPart.singularPart μ,
s.toJordanDecomposition.negPart.singularPart μ, singularPart_mutuallySingular s μ⟩ := by
refine JordanDecomposition.toSignedMeasure_injective ?_
rw [toSignedMeasure_toJordanDecomposition, singularPart, JordanDecomposition.toSignedMeasure]
rw [totalVariation, this]
nonrec theorem mutuallySingular_singularPart (s : SignedMeasure α) (μ : Measure α) :
singularPart s μ ⟂ᵥ μ.toENNRealVectorMeasure := by
rw [mutuallySingular_ennreal_iff, singularPart_totalVariation,
VectorMeasure.ennrealToMeasure_toENNRealVectorMeasure]
exact (mutuallySingular_singularPart _ _).add_left (mutuallySingular_singularPart _ _)
end
/-- The Radon-Nikodym derivative between a signed measure and a positive measure.
`rnDeriv s μ` satisfies `μ.withDensityᵥ (s.rnDeriv μ) = s`
if and only if `s` is absolutely continuous with respect to `μ` and this fact is known as
`MeasureTheory.SignedMeasure.absolutelyContinuous_iff_withDensity_rnDeriv_eq`
and can be found in `Mathlib/MeasureTheory/Measure/Decomposition/RadonNikodym.lean`. -/
def rnDeriv (s : SignedMeasure α) (μ : Measure α) : α → ℝ := fun x =>
(s.toJordanDecomposition.posPart.rnDeriv μ x).toReal -
(s.toJordanDecomposition.negPart.rnDeriv μ x).toReal
-- The generated equation theorem is the form of `rnDeriv s μ x = ...`.
theorem rnDeriv_def (s : SignedMeasure α) (μ : Measure α) : rnDeriv s μ = fun x =>
(s.toJordanDecomposition.posPart.rnDeriv μ x).toReal -
(s.toJordanDecomposition.negPart.rnDeriv μ x).toReal :=
rfl
variable {s t : SignedMeasure α}
@[measurability]
theorem measurable_rnDeriv (s : SignedMeasure α) (μ : Measure α) : Measurable (rnDeriv s μ) := by
rw [rnDeriv_def]
fun_prop
theorem integrable_rnDeriv (s : SignedMeasure α) (μ : Measure α) : Integrable (rnDeriv s μ) μ := by
refine Integrable.sub ?_ ?_ <;>
· constructor
· apply Measurable.aestronglyMeasurable
fun_prop
exact hasFiniteIntegral_toReal_of_lintegral_ne_top (lintegral_rnDeriv_lt_top _ μ).ne
variable (s μ)
/-- **The Lebesgue Decomposition theorem between a signed measure and a measure**:
Given a signed measure `s` and a σ-finite measure `μ`, there exist a signed measure `t` and a
measurable and integrable function `f`, such that `t` is mutually singular with respect to `μ`
and `s = t + μ.withDensityᵥ f`. In this case `t = s.singularPart μ` and
`f = s.rnDeriv μ`. -/
theorem singularPart_add_withDensity_rnDeriv_eq [s.HaveLebesgueDecomposition μ] :
s.singularPart μ + μ.withDensityᵥ (s.rnDeriv μ) = s := by
conv_rhs =>
rw [← toSignedMeasure_toJordanDecomposition s, JordanDecomposition.toSignedMeasure]
rw [singularPart, rnDeriv_def,
withDensityᵥ_sub' (integrable_toReal_of_lintegral_ne_top _ _)
(integrable_toReal_of_lintegral_ne_top _ _),
withDensityᵥ_toReal, withDensityᵥ_toReal, sub_eq_add_neg, sub_eq_add_neg,
add_comm (s.toJordanDecomposition.posPart.singularPart μ).toSignedMeasure, ← add_assoc,
add_assoc (-(s.toJordanDecomposition.negPart.singularPart μ).toSignedMeasure),
← toSignedMeasure_add, add_comm, ← add_assoc, ← neg_add, ← toSignedMeasure_add, add_comm,
← sub_eq_add_neg]
· convert rfl
-- `convert rfl` much faster than `congr`
· exact s.toJordanDecomposition.posPart.haveLebesgueDecomposition_add μ
· rw [add_comm]
exact s.toJordanDecomposition.negPart.haveLebesgueDecomposition_add μ
all_goals
first
| exact (lintegral_rnDeriv_lt_top _ _).ne
| measurability
variable {s μ}
theorem jordanDecomposition_add_withDensity_mutuallySingular {f : α → ℝ} (hf : Measurable f)
(htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) :
(t.toJordanDecomposition.posPart + μ.withDensity fun x : α => ENNReal.ofReal (f x)) ⟂ₘ
t.toJordanDecomposition.negPart + μ.withDensity fun x : α => ENNReal.ofReal (-f x) := by
rw [mutuallySingular_ennreal_iff, totalVariation_mutuallySingular_iff,
VectorMeasure.ennrealToMeasure_toENNRealVectorMeasure] at htμ
exact
((JordanDecomposition.mutuallySingular _).add_right
(htμ.1.mono_ac (refl _) (withDensity_absolutelyContinuous _ _))).add_left
((htμ.2.symm.mono_ac (withDensity_absolutelyContinuous _ _) (refl _)).add_right
(withDensity_ofReal_mutuallySingular hf))
theorem toJordanDecomposition_eq_of_eq_add_withDensity {f : α → ℝ} (hf : Measurable f)
(hfi : Integrable f μ) (htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) (hadd : s = t + μ.withDensityᵥ f) :
s.toJordanDecomposition =
@JordanDecomposition.mk α _
(t.toJordanDecomposition.posPart + μ.withDensity fun x => ENNReal.ofReal (f x))
(t.toJordanDecomposition.negPart + μ.withDensity fun x => ENNReal.ofReal (-f x))
(by haveI := isFiniteMeasure_withDensity_ofReal hfi.2; infer_instance)
(by haveI := isFiniteMeasure_withDensity_ofReal hfi.neg.2; infer_instance)
(jordanDecomposition_add_withDensity_mutuallySingular hf htμ) := by
haveI := isFiniteMeasure_withDensity_ofReal hfi.2
haveI := isFiniteMeasure_withDensity_ofReal hfi.neg.2
refine toJordanDecomposition_eq ?_
simp_rw [JordanDecomposition.toSignedMeasure, hadd]
ext i hi
rw [VectorMeasure.sub_apply, toSignedMeasure_apply_measurable hi,
toSignedMeasure_apply_measurable hi, measureReal_add_apply, measureReal_add_apply,
add_sub_add_comm, ← toSignedMeasure_apply_measurable hi,
← toSignedMeasure_apply_measurable hi, ← VectorMeasure.sub_apply,
← JordanDecomposition.toSignedMeasure, toSignedMeasure_toJordanDecomposition,
VectorMeasure.add_apply, ← toSignedMeasure_apply_measurable hi,
← toSignedMeasure_apply_measurable hi,
withDensityᵥ_eq_withDensity_pos_part_sub_withDensity_neg_part hfi,
VectorMeasure.sub_apply]
private theorem haveLebesgueDecomposition_mk' (μ : Measure α) {f : α → ℝ} (hf : Measurable f)
(hfi : Integrable f μ) (htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) (hadd : s = t + μ.withDensityᵥ f) :
s.HaveLebesgueDecomposition μ := by
have htμ' := htμ
rw [mutuallySingular_ennreal_iff] at htμ
change _ ⟂ₘ VectorMeasure.equivMeasure.toFun (VectorMeasure.equivMeasure.invFun μ) at htμ
rw [VectorMeasure.equivMeasure.right_inv, totalVariation_mutuallySingular_iff] at htμ
refine
{ posPart := by
use ⟨t.toJordanDecomposition.posPart, fun x => ENNReal.ofReal (f x)⟩
refine ⟨hf.ennreal_ofReal, htμ.1, ?_⟩
rw [toJordanDecomposition_eq_of_eq_add_withDensity hf hfi htμ' hadd]
negPart := by
use ⟨t.toJordanDecomposition.negPart, fun x => ENNReal.ofReal (-f x)⟩
refine ⟨hf.neg.ennreal_ofReal, htμ.2, ?_⟩
rw [toJordanDecomposition_eq_of_eq_add_withDensity hf hfi htμ' hadd] }
theorem haveLebesgueDecomposition_mk (μ : Measure α) {f : α → ℝ} (hf : Measurable f)
(htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) (hadd : s = t + μ.withDensityᵥ f) :
s.HaveLebesgueDecomposition μ := by
by_cases hfi : Integrable f μ
· exact haveLebesgueDecomposition_mk' μ hf hfi htμ hadd
· rw [withDensityᵥ, dif_neg hfi, add_zero] at hadd
refine haveLebesgueDecomposition_mk' μ measurable_zero (integrable_zero _ _ μ) htμ ?_
rwa [withDensityᵥ_zero, add_zero]
private theorem eq_singularPart' (t : SignedMeasure α) {f : α → ℝ} (hf : Measurable f)
(hfi : Integrable f μ) (htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) (hadd : s = t + μ.withDensityᵥ f) :
t = s.singularPart μ := by
have htμ' := htμ
rw [mutuallySingular_ennreal_iff, totalVariation_mutuallySingular_iff,
VectorMeasure.ennrealToMeasure_toENNRealVectorMeasure] at htμ
rw [singularPart, ← t.toSignedMeasure_toJordanDecomposition,
JordanDecomposition.toSignedMeasure]
congr
· have hfpos : Measurable fun x => ENNReal.ofReal (f x) := by fun_prop
refine eq_singularPart hfpos htμ.1 ?_
rw [toJordanDecomposition_eq_of_eq_add_withDensity hf hfi htμ' hadd]
· have hfneg : Measurable fun x => ENNReal.ofReal (-f x) := by fun_prop
refine eq_singularPart hfneg htμ.2 ?_
rw [toJordanDecomposition_eq_of_eq_add_withDensity hf hfi htμ' hadd]
/-- Given a measure `μ`, signed measures `s` and `t`, and a function `f` such that `t` is
mutually singular with respect to `μ` and `s = t + μ.withDensityᵥ f`, we have
`t = singularPart s μ`, i.e. `t` is the singular part of the Lebesgue decomposition between
`s` and `μ`. -/
theorem eq_singularPart (t : SignedMeasure α) (f : α → ℝ) (htμ : t ⟂ᵥ μ.toENNRealVectorMeasure)
(hadd : s = t + μ.withDensityᵥ f) : t = s.singularPart μ := by
by_cases hfi : Integrable f μ
· refine eq_singularPart' t hfi.1.measurable_mk (hfi.congr hfi.1.ae_eq_mk) htμ ?_
convert hadd using 2
exact WithDensityᵥEq.congr_ae hfi.1.ae_eq_mk.symm
· rw [withDensityᵥ, dif_neg hfi, add_zero] at hadd
refine eq_singularPart' t measurable_zero (integrable_zero _ _ μ) htμ ?_
rwa [withDensityᵥ_zero, add_zero]
theorem singularPart_zero (μ : Measure α) : (0 : SignedMeasure α).singularPart μ = 0 := by
refine (eq_singularPart 0 0 VectorMeasure.MutuallySingular.zero_left ?_).symm
rw [zero_add, withDensityᵥ_zero]
theorem singularPart_neg (s : SignedMeasure α) (μ : Measure α) :
(-s).singularPart μ = -s.singularPart μ := by
have h₁ :
((-s).toJordanDecomposition.posPart.singularPart μ).toSignedMeasure =
(s.toJordanDecomposition.negPart.singularPart μ).toSignedMeasure := by
refine toSignedMeasure_congr ?_
rw [toJordanDecomposition_neg, JordanDecomposition.neg_posPart]
have h₂ :
((-s).toJordanDecomposition.negPart.singularPart μ).toSignedMeasure =
(s.toJordanDecomposition.posPart.singularPart μ).toSignedMeasure := by
refine toSignedMeasure_congr ?_
rw [toJordanDecomposition_neg, JordanDecomposition.neg_negPart]
rw [singularPart, singularPart, neg_sub, h₁, h₂]
theorem singularPart_smul_nnreal (s : SignedMeasure α) (μ : Measure α) (r : ℝ≥0) :
(r • s).singularPart μ = r • s.singularPart μ := by
rw [singularPart, singularPart, smul_sub, ← toSignedMeasure_smul, ← toSignedMeasure_smul]
conv_lhs =>
congr
· congr
· rw [toJordanDecomposition_smul, JordanDecomposition.smul_posPart, singularPart_smul]
· congr
rw [toJordanDecomposition_smul, JordanDecomposition.smul_negPart, singularPart_smul]
nonrec theorem singularPart_smul (s : SignedMeasure α) (μ : Measure α) (r : ℝ) :
(r • s).singularPart μ = r • s.singularPart μ := by
cases le_or_gt 0 r with
| inl hr =>
lift r to ℝ≥0 using hr
exact singularPart_smul_nnreal s μ r
| inr hr =>
rw [singularPart, singularPart]
conv_lhs =>
congr
· congr
· rw [toJordanDecomposition_smul_real,
JordanDecomposition.real_smul_posPart_neg _ _ hr, singularPart_smul]
· congr
· rw [toJordanDecomposition_smul_real,
JordanDecomposition.real_smul_negPart_neg _ _ hr, singularPart_smul]
rw [toSignedMeasure_smul, toSignedMeasure_smul, ← neg_sub, ← smul_sub, NNReal.smul_def,
← neg_smul, Real.coe_toNNReal _ (le_of_lt (neg_pos.mpr hr)), neg_neg]
theorem singularPart_add (s t : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ]
[t.HaveLebesgueDecomposition μ] :
(s + t).singularPart μ = s.singularPart μ + t.singularPart μ := by
refine
(eq_singularPart _ (s.rnDeriv μ + t.rnDeriv μ)
((mutuallySingular_singularPart s μ).add_left (mutuallySingular_singularPart t μ))
?_).symm
rw [withDensityᵥ_add (integrable_rnDeriv s μ) (integrable_rnDeriv t μ), add_assoc,
add_comm (t.singularPart μ), add_assoc, add_comm _ (t.singularPart μ),
singularPart_add_withDensity_rnDeriv_eq, ← add_assoc,
singularPart_add_withDensity_rnDeriv_eq]
theorem singularPart_sub (s t : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ]
[t.HaveLebesgueDecomposition μ] :
(s - t).singularPart μ = s.singularPart μ - t.singularPart μ := by
rw [sub_eq_add_neg, sub_eq_add_neg, singularPart_add, singularPart_neg]
/-- Given a measure `μ`, signed measures `s` and `t`, and a function `f` such that `t` is
mutually singular with respect to `μ` and `s = t + μ.withDensityᵥ f`, we have
`f = rnDeriv s μ`, i.e. `f` is the Radon-Nikodym derivative of `s` and `μ`. -/
theorem eq_rnDeriv (t : SignedMeasure α) (f : α → ℝ) (hfi : Integrable f μ)
(htμ : t ⟂ᵥ μ.toENNRealVectorMeasure) (hadd : s = t + μ.withDensityᵥ f) :
f =ᵐ[μ] s.rnDeriv μ := by
set f' := hfi.1.mk f
have hadd' : s = t + μ.withDensityᵥ f' := by
convert hadd using 2
exact WithDensityᵥEq.congr_ae hfi.1.ae_eq_mk.symm
have := haveLebesgueDecomposition_mk μ hfi.1.measurable_mk htμ hadd'
refine (Integrable.ae_eq_of_withDensityᵥ_eq (integrable_rnDeriv _ _) hfi ?_).symm
rw [← add_right_inj t, ← hadd, eq_singularPart _ f htμ hadd,
singularPart_add_withDensity_rnDeriv_eq]
theorem rnDeriv_neg (s : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ] :
(-s).rnDeriv μ =ᵐ[μ] -s.rnDeriv μ := by
refine
Integrable.ae_eq_of_withDensityᵥ_eq (integrable_rnDeriv _ _) (integrable_rnDeriv _ _).neg ?_
rw [withDensityᵥ_neg, ← add_right_inj ((-s).singularPart μ),
singularPart_add_withDensity_rnDeriv_eq, singularPart_neg, ← neg_add,
singularPart_add_withDensity_rnDeriv_eq]
theorem rnDeriv_smul (s : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ] (r : ℝ) :
(r • s).rnDeriv μ =ᵐ[μ] r • s.rnDeriv μ := by
refine
Integrable.ae_eq_of_withDensityᵥ_eq (integrable_rnDeriv _ _)
((integrable_rnDeriv _ _).smul r) ?_
rw [withDensityᵥ_smul (rnDeriv s μ) r, ← add_right_inj ((r • s).singularPart μ),
singularPart_add_withDensity_rnDeriv_eq, singularPart_smul, ← smul_add,
singularPart_add_withDensity_rnDeriv_eq]
theorem rnDeriv_add (s t : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ]
[t.HaveLebesgueDecomposition μ] [(s + t).HaveLebesgueDecomposition μ] :
(s + t).rnDeriv μ =ᵐ[μ] s.rnDeriv μ + t.rnDeriv μ := by
refine
Integrable.ae_eq_of_withDensityᵥ_eq (integrable_rnDeriv _ _)
((integrable_rnDeriv _ _).add (integrable_rnDeriv _ _)) ?_
rw [← add_right_inj ((s + t).singularPart μ), singularPart_add_withDensity_rnDeriv_eq,
withDensityᵥ_add (integrable_rnDeriv _ _) (integrable_rnDeriv _ _), singularPart_add,
add_assoc, add_comm (t.singularPart μ), add_assoc, add_comm _ (t.singularPart μ),
singularPart_add_withDensity_rnDeriv_eq, ← add_assoc,
singularPart_add_withDensity_rnDeriv_eq]
theorem rnDeriv_sub (s t : SignedMeasure α) (μ : Measure α) [s.HaveLebesgueDecomposition μ]
[t.HaveLebesgueDecomposition μ] [hst : (s - t).HaveLebesgueDecomposition μ] :
(s - t).rnDeriv μ =ᵐ[μ] s.rnDeriv μ - t.rnDeriv μ := by
rw [sub_eq_add_neg] at hst
rw [sub_eq_add_neg, sub_eq_add_neg]
grw [rnDeriv_add, rnDeriv_neg]
end SignedMeasure
namespace ComplexMeasure
/-- A complex measure is said to `HaveLebesgueDecomposition` with respect to a positive measure
if both its real and imaginary part `HaveLebesgueDecomposition` with respect to that measure. -/
class HaveLebesgueDecomposition (c : ComplexMeasure α) (μ : Measure α) : Prop where
rePart : c.re.HaveLebesgueDecomposition μ
imPart : c.im.HaveLebesgueDecomposition μ
attribute [instance] HaveLebesgueDecomposition.rePart
attribute [instance] HaveLebesgueDecomposition.imPart
/-- The singular part between a complex measure `c` and a positive measure `μ` is the complex
measure satisfying `c.singularPart μ + μ.withDensityᵥ (c.rnDeriv μ) = c`. This property is given
by `MeasureTheory.ComplexMeasure.singularPart_add_withDensity_rnDeriv_eq`. -/
def singularPart (c : ComplexMeasure α) (μ : Measure α) : ComplexMeasure α :=
(c.re.singularPart μ).toComplexMeasure (c.im.singularPart μ)
/-- The Radon-Nikodym derivative between a complex measure and a positive measure. -/
def rnDeriv (c : ComplexMeasure α) (μ : Measure α) : α → ℂ := fun x =>
⟨c.re.rnDeriv μ x, c.im.rnDeriv μ x⟩
variable {c : ComplexMeasure α}
theorem integrable_rnDeriv (c : ComplexMeasure α) (μ : Measure α) : Integrable (c.rnDeriv μ) μ := by
rw [← memLp_one_iff_integrable, ← memLp_re_im_iff]
exact
⟨memLp_one_iff_integrable.2 (SignedMeasure.integrable_rnDeriv _ _),
memLp_one_iff_integrable.2 (SignedMeasure.integrable_rnDeriv _ _)⟩
theorem singularPart_add_withDensity_rnDeriv_eq [c.HaveLebesgueDecomposition μ] :
c.singularPart μ + μ.withDensityᵥ (c.rnDeriv μ) = c := by
conv_rhs => rw [← c.toComplexMeasure_to_signedMeasure]
ext i hi : 1
rw [VectorMeasure.add_apply, SignedMeasure.toComplexMeasure_apply]
apply Complex.ext
· rw [Complex.add_re, withDensityᵥ_apply (c.integrable_rnDeriv μ) hi, ← RCLike.re_eq_complex_re,
← integral_re (c.integrable_rnDeriv μ).integrableOn, RCLike.re_eq_complex_re,
← withDensityᵥ_apply _ hi]
· change (c.re.singularPart μ + μ.withDensityᵥ (c.re.rnDeriv μ)) i = _
rw [c.re.singularPart_add_withDensity_rnDeriv_eq μ]
· exact SignedMeasure.integrable_rnDeriv _ _
· rw [Complex.add_im, withDensityᵥ_apply (c.integrable_rnDeriv μ) hi, ← RCLike.im_eq_complex_im,
← integral_im (c.integrable_rnDeriv μ).integrableOn, RCLike.im_eq_complex_im,
← withDensityᵥ_apply _ hi]
· change (c.im.singularPart μ + μ.withDensityᵥ (c.im.rnDeriv μ)) i = _
rw [c.im.singularPart_add_withDensity_rnDeriv_eq μ]
· exact SignedMeasure.integrable_rnDeriv _ _
end ComplexMeasure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/SpecificCodomains/Pi.lean | import Mathlib.MeasureTheory.Integral.Bochner.ContinuousLinearMap
/-!
# Integrability in a product space
We prove that `f : X → Π i, E i` is in `Lᵖ` if and only if for all `i`, `f · i` is in `Lᵖ`.
We do the same for `f : X → (E × F)`.
-/
namespace MeasureTheory
open scoped ENNReal
variable {X : Type*} {mX : MeasurableSpace X} {μ : Measure X} {p : ℝ≥0∞}
section Pi
variable {ι : Type*} [Fintype ι] {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)]
{f : X → Π i, E i}
lemma memLp_pi_iff : MemLp f p μ ↔ ∀ i, MemLp (f · i) p μ where
mp hf i := (LipschitzWith.eval (α := E) i).comp_memLp rfl hf
mpr hf := by
classical
have : f = ∑ i, (Pi.single i) ∘ (f · i) := by ext; simp
rw [this]
refine memLp_finset_sum' _ fun i _ ↦ ?_
exact (Isometry.single i).lipschitz.comp_memLp (by simp) (hf i)
alias ⟨MemLp.eval, MemLp.of_eval⟩ := memLp_pi_iff
lemma integrable_pi_iff : Integrable f μ ↔ ∀ i, Integrable (f · i) μ := by
simp_rw [← memLp_one_iff_integrable, memLp_pi_iff]
alias ⟨Integrable.eval, Integrable.of_eval⟩ := integrable_pi_iff
variable [∀ i, NormedSpace ℝ (E i)] [∀ i, CompleteSpace (E i)]
lemma eval_integral (hf : ∀ i, Integrable (f · i) μ) (i : ι) :
(∫ x, f x ∂μ) i = ∫ x, f x i ∂μ := by
simp [← ContinuousLinearMap.proj_apply (R := ℝ) i (∫ x, f x ∂μ),
← ContinuousLinearMap.integral_comp_comm _ (Integrable.of_eval hf)]
end Pi
section Prod
variable {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : X → E × F}
lemma memLp_prod_iff :
MemLp f p μ ↔ MemLp (fun x ↦ (f x).fst) p μ ∧ MemLp (fun x ↦ (f x).snd) p μ where
mp h := ⟨LipschitzWith.prod_fst.comp_memLp (by simp) h,
LipschitzWith.prod_snd.comp_memLp (by simp) h⟩
mpr h := by
have : f = (AddMonoidHom.inl E F) ∘ (fun x ↦ (f x).fst) +
(AddMonoidHom.inr E F) ∘ (fun x ↦ (f x).snd) := by
ext; all_goals simp
rw [this]
exact MemLp.add (Isometry.inl.lipschitz.comp_memLp (by simp) h.1)
(Isometry.inr.lipschitz.comp_memLp (by simp) h.2)
lemma MemLp.fst (h : MemLp f p μ) : MemLp (fun x ↦ (f x).fst) p μ :=
memLp_prod_iff.1 h |>.1
lemma MemLp.snd (h : MemLp f p μ) : MemLp (fun x ↦ (f x).snd) p μ :=
memLp_prod_iff.1 h |>.2
alias ⟨_, MemLp.of_fst_snd⟩ := memLp_prod_iff
end Prod
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/SpecificCodomains/ContinuousMap.lean | import Mathlib.Topology.ContinuousMap.Compact
import Mathlib.Topology.ContinuousMap.Algebra
import Mathlib.MeasureTheory.Integral.IntegrableOn
/-!
# Specific results about `ContinuousMap`-valued integration
In this file, we collect a few results regarding integrability, on a measure space `(X, μ)`,
of a `C(Y, E)`-valued function, where `Y` is a compact topological space and `E` is a normed group.
These are all elementary from a mathematical point of view, but they require a bit of care in order
to be conveniently usable. In particular, to accommodate the need of families `f : X → Y → E` which
such that `f x` is only continuous for *almost every* `x`, we give a variety of results about the
integrability of `fun x ↦ ContinuousMap.mkD (f x) g` whose assumption only mention `f` (so that
user don't have to convert between `f` and `fun x ↦ ContinuousMap.mkD (f x) g` by hand).
## Main results
* `hasFiniteIntegral_of_bound`: given `f : X → C(Y, E)`, the natural way to show
`HasFiniteIntegral f` is to give a `bound : X → ℝ`, which itself has finite integral, and such
that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.
* `hasFiniteIntegral_mkD_of_bound` is the `mkD` analog of the above: given `f : X → Y → E` such
that `f x` is continuous for almost every `x`, as well as a bound as above, we prove
`HasFiniteIntegral (fun x ↦ mkD (f x) g)`. Note that, conveniently, `mkD` only appears in the
result.
* `aeStronglyMeasurable_mkD_of_uncurry`: if now `X` is a topological space with the Borel σ-algebra,
and `f : X → Y → E` is continuous on `X × Y`, then `fun x ↦ mkD (f x) g` is
`AEStronglyMeasurable`. Note that this is far from optimal: this function is in fact continuous,
and one could avoid `mkD` entirely since `f x` is always continuous in that case. Nevertheless,
this turns out to be most convenient, as we explain below.
## Implementation Note
We claim that using "constructors with default values" such as `ContinuousMap.mkD` is the right way
to approach integration valued in a functional space `ℱ`. More precisely:
- if you happen to start from a bundled `f : X → ℱ` function, you should be able to use
the general theory without any issues.
- if instead you start with a family of bare functions `f : X → Y → E`, to integrate it in `ℱ`, you
should always consider the family `fun x ↦ ℱ.mkD (f x) 0`, *even if your `f` always lands in `ℱ`*.
This allows for a unified setting with the case where `f x` belongs to `ℱ` for *almost every `x`*,
and also avoids entering dependent-types hell.
-/
open MeasureTheory
namespace ContinuousMap
variable {X Y : Type*} [MeasurableSpace X] {μ : Measure X} [TopologicalSpace Y]
variable {E : Type*} [NormedAddCommGroup E]
/-- A natural criterion for `HasFiniteIntegral` of a `C(Y, E)`-valued function is the existence
of some positive function with finite integral such that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.
Note that there is no dominated convergence here (hence no first-countability assumption
on `Y`). We are just using the properties of Banach-space-valued integration. -/
lemma hasFiniteIntegral_of_bound [CompactSpace Y] (f : X → C(Y, E)) (bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral f μ := by
rcases isEmpty_or_nonempty Y with (h|h)
· simp
· have bound_nonneg : 0 ≤ᵐ[μ] bound := by
filter_upwards [bound_ge] with x bound_x using le_trans (norm_nonneg _) (bound_x h.some)
refine .mono' bound_int ?_
filter_upwards [bound_ge, bound_nonneg] with x bound_ge_x bound_nonneg_x
exact ContinuousMap.norm_le _ bound_nonneg_x |>.mpr bound_ge_x
/-- A variant of `ContinuousMap.hasFiniteIntegral_of_bound` spelled in terms of
`ContinuousMap.mkD`. -/
lemma hasFiniteIntegral_mkD_of_bound [CompactSpace Y] (f : X → Y → E) (g : C(Y, E))
(f_ae_cont : ∀ᵐ x ∂μ, Continuous (f x))
(bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral (fun x ↦ mkD (f x) g) μ := by
refine hasFiniteIntegral_of_bound _ bound bound_int ?_
filter_upwards [bound_ge, f_ae_cont] with x bound_ge_x cont_x
simpa only [mkD_apply_of_continuous cont_x] using bound_ge_x
/-- A variant of `ContinuousMap.hasFiniteIntegral_mkD_of_bound` for a family of
functions which are continuous on a compact set. -/
lemma hasFiniteIntegral_mkD_restrict_of_bound {s : Set Y} [CompactSpace s]
(f : X → Y → E) (g : C(s, E))
(f_ae_contOn : ∀ᵐ x ∂μ, ContinuousOn (f x) s)
(bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y ∈ s, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral (fun x ↦ mkD (s.restrict (f x)) g) μ := by
refine hasFiniteIntegral_mkD_of_bound _ _ ?_ bound bound_int ?_
· simpa [← continuousOn_iff_continuous_restrict]
· simpa
lemma aeStronglyMeasurable_mkD_of_uncurry [CompactSpace Y] [TopologicalSpace X]
[OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(Y, E))]
(f : X → Y → E) (g : C(Y, E)) (f_cont : Continuous (Function.uncurry f)) :
AEStronglyMeasurable (fun x ↦ mkD (f x) g) μ :=
continuous_mkD_of_uncurry _ _ f_cont |>.aestronglyMeasurable
open Set in
lemma aeStronglyMeasurable_restrict_mkD_of_uncurry [CompactSpace Y] {s : Set X}
[TopologicalSpace X] [OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(Y, E))]
(hs : MeasurableSet s) (f : X → Y → E) (g : C(Y, E))
(f_cont : ContinuousOn (Function.uncurry f) (s ×ˢ univ)) :
AEStronglyMeasurable (fun x ↦ mkD (f x) g) (μ.restrict s) :=
continuousOn_mkD_of_uncurry _ _ f_cont |>.aestronglyMeasurable hs
open Set in
lemma aeStronglyMeasurable_mkD_restrict_of_uncurry {t : Set Y} [CompactSpace t] [TopologicalSpace X]
[OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(t, E))]
(f : X → Y → E) (g : C(t, E)) (f_cont : ContinuousOn (Function.uncurry f) (univ ×ˢ t)) :
AEStronglyMeasurable (fun x ↦ mkD (t.restrict (f x)) g) μ :=
continuous_mkD_restrict_of_uncurry _ _ f_cont |>.aestronglyMeasurable
open Set in
lemma aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry {s : Set X} {t : Set Y}
[CompactSpace t] [TopologicalSpace X] [OpensMeasurableSpace X]
[SecondCountableTopologyEither X (C(t, E))]
(hs : MeasurableSet s) (f : X → Y → E) (g : C(t, E))
(f_cont : ContinuousOn (Function.uncurry f) (s ×ˢ t)) :
AEStronglyMeasurable (fun x ↦ mkD (t.restrict (f x)) g) (μ.restrict s) :=
continuousOn_mkD_restrict_of_uncurry _ _ f_cont |>.aestronglyMeasurable hs
end ContinuousMap |
.lake/packages/mathlib/Mathlib/MeasureTheory/SpecificCodomains/ContinuousMapZero.lean | import Mathlib.Topology.ContinuousMap.ContinuousMapZero
import Mathlib.MeasureTheory.SpecificCodomains.ContinuousMap
/-!
# Specific results about `ContinuousMapZero`-valued integration
In this file, we collect a few results regarding integrability, on a measure space `(X, μ)`,
of a `C(Y, E)₀`-valued function, where `Y` is a compact topological space with a distinguished `0`,
and `E` is a normed group.
The structure of this file is largely similar to that of
`Mathlib.MeasureTheory.SpecificCodomains.ContinuousMap`, which contains a more detailed
module docstring.
-/
open MeasureTheory
namespace ContinuousMapZero
variable {X Y : Type*} [MeasurableSpace X] {μ : Measure X} [TopologicalSpace Y]
variable {E : Type*} [NormedAddCommGroup E]
/-- A natural criterion for `HasFiniteIntegral` of a `C(Y, E)₀`-valued function is the existence
of some positive function with finite integral such that `∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x`.
Note that there is no dominated convergence here (hence no first-countability assumption
on `Y`). We are just using the properties of Banach-space-valued integration. -/
lemma hasFiniteIntegral_of_bound [CompactSpace Y] [Zero Y] (f : X → C(Y, E)₀) (bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral f μ := by
have bound_nonneg : 0 ≤ᵐ[μ] bound := by
filter_upwards [bound_ge] with x bound_x using le_trans (norm_nonneg _) (bound_x 0)
refine .mono' bound_int ?_
filter_upwards [bound_ge, bound_nonneg] with x bound_ge_x bound_nonneg_x
exact ContinuousMap.norm_le _ bound_nonneg_x |>.mpr bound_ge_x
/-- A variant of `ContinuousMapZero.hasFiniteIntegral_of_bound` spelled in terms of
`ContinuousMapZero.mkD`. -/
lemma hasFiniteIntegral_mkD_of_bound [CompactSpace Y] [Zero Y] (f : X → Y → E) (g : C(Y, E)₀)
(f_ae_cont : ∀ᵐ x ∂μ, Continuous (f x))
(f_ae_zero : ∀ᵐ x ∂μ, f x 0 = 0)
(bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y : Y, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral (fun x ↦ mkD (f x) g) μ := by
refine hasFiniteIntegral_of_bound _ bound bound_int ?_
filter_upwards [bound_ge, f_ae_cont, f_ae_zero] with x bound_ge_x cont_x zero_x
simpa only [mkD_apply_of_continuous cont_x zero_x] using bound_ge_x
/-- A variant of `ContinuousMapZero.hasFiniteIntegral_mkD_of_bound` for a family of
functions which are continuous on a compact set. -/
lemma hasFiniteIntegral_mkD_restrict_of_bound {s : Set Y} [CompactSpace s] [Zero s]
(f : X → Y → E) (g : C(s, E)₀)
(f_ae_contOn : ∀ᵐ x ∂μ, ContinuousOn (f x) s)
(f_ae_zero : ∀ᵐ x ∂μ, f x (0 : s) = 0)
(bound : X → ℝ)
(bound_int : HasFiniteIntegral bound μ)
(bound_ge : ∀ᵐ x ∂μ, ∀ y ∈ s, ‖f x y‖ ≤ bound x) :
HasFiniteIntegral (fun x ↦ mkD (s.restrict (f x)) g) μ := by
refine hasFiniteIntegral_mkD_of_bound _ _ ?_ f_ae_zero bound bound_int ?_
· simpa [← continuousOn_iff_continuous_restrict]
· simpa
lemma aeStronglyMeasurable_mkD_of_uncurry [CompactSpace Y] [Zero Y] [TopologicalSpace X]
[OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(Y, E))]
(f : X → Y → E) (g : C(Y, E)₀) (f_cont : Continuous (Function.uncurry f))
(f_zero : ∀ᵐ x ∂μ, f x 0 = 0) :
AEStronglyMeasurable (fun x ↦ mkD (f x) g) μ := by
rw [← ContinuousMapZero.isEmbedding_toContinuousMap.aestronglyMeasurable_comp_iff]
refine aestronglyMeasurable_congr ?_ |>.mp <|
ContinuousMap.aeStronglyMeasurable_mkD_of_uncurry f g f_cont
filter_upwards [f_zero] with x zero_x
rw [mkD_eq_mkD_of_map_zero _ _ zero_x]
open Set in
lemma aeStronglyMeasurable_restrict_mkD_of_uncurry [CompactSpace Y] [Zero Y] {s : Set X}
[TopologicalSpace X] [OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(Y, E))]
(hs : MeasurableSet s) (f : X → Y → E) (g : C(Y, E)₀)
(f_cont : ContinuousOn (Function.uncurry f) (s ×ˢ univ))
(f_zero : ∀ᵐ x ∂(μ.restrict s), f x 0 = 0) :
AEStronglyMeasurable (fun x ↦ mkD (f x) g) (μ.restrict s) := by
rw [← ContinuousMapZero.isEmbedding_toContinuousMap.aestronglyMeasurable_comp_iff]
refine aestronglyMeasurable_congr ?_ |>.mp <|
ContinuousMap.aeStronglyMeasurable_restrict_mkD_of_uncurry hs f g f_cont
filter_upwards [f_zero] with x zero_x
rw [mkD_eq_mkD_of_map_zero _ _ zero_x]
open Set in
lemma aeStronglyMeasurable_mkD_restrict_of_uncurry {t : Set Y} [CompactSpace t] [Zero t]
[TopologicalSpace X] [OpensMeasurableSpace X] [SecondCountableTopologyEither X (C(t, E))]
(f : X → Y → E) (g : C(t, E)₀) (f_cont : ContinuousOn (Function.uncurry f) (univ ×ˢ t))
(f_zero : ∀ᵐ x ∂μ, f x (0 : t) = 0) :
AEStronglyMeasurable (fun x ↦ mkD (t.restrict (f x)) g) μ := by
rw [← ContinuousMapZero.isEmbedding_toContinuousMap.aestronglyMeasurable_comp_iff]
refine aestronglyMeasurable_congr ?_ |>.mp <|
ContinuousMap.aeStronglyMeasurable_mkD_restrict_of_uncurry f g f_cont
filter_upwards [f_zero] with x zero_x
rw [mkD_eq_mkD_of_map_zero _ _ zero_x]
open Set in
lemma aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry {s : Set X} {t : Set Y}
[CompactSpace t] [Zero t] [TopologicalSpace X] [OpensMeasurableSpace X]
[SecondCountableTopologyEither X (C(t, E))]
(hs : MeasurableSet s) (f : X → Y → E) (g : C(t, E)₀)
(f_cont : ContinuousOn (Function.uncurry f) (s ×ˢ t))
(f_zero : ∀ᵐ x ∂(μ.restrict s), f x (0 : t) = 0) :
AEStronglyMeasurable (fun x ↦ mkD (t.restrict (f x)) g) (μ.restrict s) := by
rw [← ContinuousMapZero.isEmbedding_toContinuousMap.aestronglyMeasurable_comp_iff]
refine aestronglyMeasurable_congr ?_ |>.mp <|
ContinuousMap.aeStronglyMeasurable_restrict_mkD_restrict_of_uncurry hs f g f_cont
filter_upwards [f_zero] with x zero_x
rw [mkD_eq_mkD_of_map_zero _ _ zero_x]
end ContinuousMapZero |
.lake/packages/mathlib/Mathlib/MeasureTheory/SpecificCodomains/WithLp.lean | import Mathlib.Analysis.Normed.Lp.PiLp
import Mathlib.MeasureTheory.SpecificCodomains.Pi
/-!
# Integrability in `WithLp`
We prove that `f : X → PiLp q E` is in `Lᵖ` if and only if for all `i`, `f · i` is in `Lᵖ`.
We do the same for `f : X → WithLp q (E × F)`.
-/
open scoped ENNReal
namespace MeasureTheory
variable {X : Type*} {mX : MeasurableSpace X} {μ : Measure X} {p q : ℝ≥0∞} [Fact (1 ≤ q)]
section Pi
variable {ι : Type*} [Fintype ι] {E : ι → Type*} [∀ i, NormedAddCommGroup (E i)] {f : X → PiLp q E}
lemma memLp_piLp_iff : MemLp f p μ ↔ ∀ i, MemLp (f · i) p μ := by
simp_rw [← memLp_pi_iff, ← Function.comp_apply (f := WithLp.ofLp)]
exact (PiLp.lipschitzWith_ofLp q E).memLp_comp_iff_of_antilipschitz
(PiLp.antilipschitzWith_ofLp q E) (by simp) |>.symm
alias ⟨MemLp.eval_piLp, MemLp.of_eval_piLp⟩ := memLp_piLp_iff
lemma integrable_piLp_iff : Integrable f μ ↔ ∀ i, Integrable (f · i) μ := by
simp_rw [← memLp_one_iff_integrable, memLp_piLp_iff]
alias ⟨Integrable.eval_piLp, Integrable.of_eval_piLp⟩ := integrable_piLp_iff
variable [∀ i, NormedSpace ℝ (E i)] [∀ i, CompleteSpace (E i)]
lemma eval_integral_piLp (hf : ∀ i, Integrable (f · i) μ) (i : ι) :
(∫ x, f x ∂μ) i = ∫ x, f x i ∂μ := by
rw [← PiLp.proj_apply (𝕜 := ℝ) q E i (∫ x, f x ∂μ), ← ContinuousLinearMap.integral_comp_comm]
· simp
exact Integrable.of_eval_piLp hf
end Pi
section Prod
variable {E F : Type*} [NormedAddCommGroup E] [NormedAddCommGroup F] {f : X → WithLp q (E × F)}
lemma memLp_prodLp_iff :
MemLp f p μ ↔ MemLp (fun x ↦ (f x).fst) p μ ∧ MemLp (fun x ↦ (f x).snd) p μ := by
simp_rw [← WithLp.ofLp_fst, ← WithLp.ofLp_snd, ← memLp_prod_iff]
exact (WithLp.prod_lipschitzWith_ofLp q E F).memLp_comp_iff_of_antilipschitz
(WithLp.prod_antilipschitzWith_ofLp q E F) (by simp) |>.symm
lemma MemLp.prodLp_fst (h : MemLp f p μ) : MemLp (fun x ↦ (f x).fst) p μ :=
memLp_prodLp_iff.1 h |>.1
lemma MemLp.prodLp_snd (h : MemLp f p μ) : MemLp (fun x ↦ (f x).snd) p μ :=
memLp_prodLp_iff.1 h |>.2
alias ⟨_, MemLp.of_fst_of_snd_prodLp⟩ := memLp_prodLp_iff
lemma integrable_prodLp_iff :
Integrable f μ ↔
Integrable (fun x ↦ (f x).fst) μ ∧
Integrable (fun x ↦ (f x).snd) μ := by
simp_rw [← memLp_one_iff_integrable, memLp_prodLp_iff]
lemma Integrable.prodLp_fst (h : Integrable f μ) : Integrable (fun x ↦ (f x).fst) μ :=
integrable_prodLp_iff.1 h |>.1
lemma Integrable.prodLp_snd (h : Integrable f μ) : Integrable (fun x ↦ (f x).snd) μ :=
integrable_prodLp_iff.1 h |>.2
alias ⟨_, Integrable.of_fst_of_snd_prodLp⟩ := integrable_prodLp_iff
variable [NormedSpace ℝ E] [NormedSpace ℝ F]
theorem fst_integral_withLp [CompleteSpace F] (hf : Integrable f μ) :
(∫ x, f x ∂μ).fst = ∫ x, (f x).fst ∂μ := by
rw [← WithLp.ofLp_fst]
conv => enter [1, 1]; change WithLp.prodContinuousLinearEquiv q ℝ E F _
rw [← ContinuousLinearEquiv.integral_comp_comm, fst_integral]
· rfl
· exact (ContinuousLinearEquiv.integrable_comp_iff _).2 hf
theorem snd_integral_withLp [CompleteSpace E] (hf : Integrable f μ) :
(∫ x, f x ∂μ).snd = ∫ x, (f x).snd ∂μ := by
rw [← WithLp.ofLp_snd]
conv => enter [1, 1]; change WithLp.prodContinuousLinearEquiv q ℝ E F _
rw [← ContinuousLinearEquiv.integral_comp_comm, snd_integral]
· rfl
· exact (ContinuousLinearEquiv.integrable_comp_iff _).2 hf
end Prod
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Instances.lean | import Mathlib.MeasureTheory.MeasurableSpace.Defs
import Mathlib.GroupTheory.GroupAction.IterateAct
import Mathlib.Data.Rat.Init
import Mathlib.Data.ZMod.Defs
/-!
# Measurable-space typeclass instances
This file provides measurable-space instances for a selection of standard countable types,
in each case defining the Σ-algebra to be `⊤` (the discrete measurable-space structure).
-/
instance Empty.instMeasurableSpace : MeasurableSpace Empty := ⊤
instance PUnit.instMeasurableSpace : MeasurableSpace PUnit := ⊤
instance Bool.instMeasurableSpace : MeasurableSpace Bool := ⊤
instance Prop.instMeasurableSpace : MeasurableSpace Prop := ⊤
instance Nat.instMeasurableSpace : MeasurableSpace ℕ := ⊤
instance ENat.instMeasurableSpace : MeasurableSpace ℕ∞ := ⊤
instance Fin.instMeasurableSpace (n : ℕ) : MeasurableSpace (Fin n) := ⊤
instance ZMod.instMeasurableSpace (n : ℕ) : MeasurableSpace (ZMod n) := ⊤
instance Int.instMeasurableSpace : MeasurableSpace ℤ := ⊤
instance Rat.instMeasurableSpace : MeasurableSpace ℚ := ⊤
@[to_additive]
instance IterateMulAct.instMeasurableSpace {α : Type*} {f : α → α} :
MeasurableSpace (IterateMulAct f) := ⊤
@[to_additive]
instance IterateMulAct.instDiscreteMeasurableSpace {α : Type*} {f : α → α} :
DiscreteMeasurableSpace (IterateMulAct f) := inferInstance
instance (priority := 100) Subsingleton.measurableSingletonClass
{α} [MeasurableSpace α] [Subsingleton α] : MeasurableSingletonClass α := by
refine ⟨fun i => ?_⟩
convert MeasurableSet.univ
simp [Set.eq_univ_iff_forall, eq_iff_true_of_subsingleton]
instance Bool.instMeasurableSingletonClass : MeasurableSingletonClass Bool := ⟨fun _ => trivial⟩
instance Prop.instMeasurableSingletonClass : MeasurableSingletonClass Prop := ⟨fun _ => trivial⟩
instance Nat.instMeasurableSingletonClass : MeasurableSingletonClass ℕ := ⟨fun _ => trivial⟩
instance ENat.instDiscreteMeasurableSpace : DiscreteMeasurableSpace ℕ∞ := ⟨fun _ ↦ trivial⟩
instance ENat.instMeasurableSingletonClass : MeasurableSingletonClass ℕ∞ := inferInstance
instance Fin.instMeasurableSingletonClass (n : ℕ) : MeasurableSingletonClass (Fin n) :=
⟨fun _ => trivial⟩
instance ZMod.instMeasurableSingletonClass (n : ℕ) : MeasurableSingletonClass (ZMod n) :=
⟨fun _ => trivial⟩
instance Int.instMeasurableSingletonClass : MeasurableSingletonClass ℤ := ⟨fun _ => trivial⟩
instance Rat.instMeasurableSingletonClass : MeasurableSingletonClass ℚ := ⟨fun _ => trivial⟩ |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Card.lean | import Mathlib.MeasureTheory.MeasurableSpace.Defs
import Mathlib.SetTheory.Cardinal.Regular
import Mathlib.SetTheory.Cardinal.Continuum
import Mathlib.SetTheory.Cardinal.Ordinal
/-!
# Cardinal of sigma-algebras
If a sigma-algebra is generated by a set of sets `s`, then the cardinality of the sigma-algebra is
bounded by `(max #s 2) ^ ℵ₀`. This is stated in `MeasurableSpace.cardinal_generate_measurable_le`
and `MeasurableSpace.cardinalMeasurableSet_le`.
In particular, if `#s ≤ 𝔠`, then the generated sigma-algebra has cardinality at most `𝔠`, see
`MeasurableSpace.cardinal_measurableSet_le_continuum`.
For the proof, we rely on an explicit inductive construction of the sigma-algebra generated by
`s` (instead of the inductive predicate `GenerateMeasurable`). This transfinite inductive
construction is parameterized by an ordinal `< ω₁`, and the cardinality bound is preserved along
each step of the construction. We show in `MeasurableSpace.generateMeasurable_eq_rec` that this
indeed generates this sigma-algebra.
-/
universe u v
variable {α : Type u}
open Cardinal Ordinal Set MeasureTheory
namespace MeasurableSpace
/-- Transfinite induction construction of the sigma-algebra generated by a set of sets `s`. At each
step, we add all elements of `s`, the empty set, the complements of already constructed sets, and
countable unions of already constructed sets.
We index this construction by an arbitrary ordinal for simplicity, but by `ω₁` we will have
generated all the sets in the sigma-algebra.
This construction is very similar to that of the Borel hierarchy. -/
def generateMeasurableRec (s : Set (Set α)) (i : Ordinal) : Set (Set α) :=
let S := ⋃ j < i, generateMeasurableRec s j
s ∪ {∅} ∪ compl '' S ∪ Set.range fun f : ℕ → S => ⋃ n, (f n).1
termination_by i
theorem self_subset_generateMeasurableRec (s : Set (Set α)) (i : Ordinal) :
s ⊆ generateMeasurableRec s i := by
unfold generateMeasurableRec
apply_rules [subset_union_of_subset_left]
exact subset_rfl
theorem empty_mem_generateMeasurableRec (s : Set (Set α)) (i : Ordinal) :
∅ ∈ generateMeasurableRec s i := by
unfold generateMeasurableRec
exact mem_union_left _ (mem_union_left _ (mem_union_right _ (mem_singleton ∅)))
theorem compl_mem_generateMeasurableRec {s : Set (Set α)} {i j : Ordinal} (h : j < i) {t : Set α}
(ht : t ∈ generateMeasurableRec s j) : tᶜ ∈ generateMeasurableRec s i := by
unfold generateMeasurableRec
exact mem_union_left _ (mem_union_right _ ⟨t, mem_iUnion₂.2 ⟨j, h, ht⟩, rfl⟩)
theorem iUnion_mem_generateMeasurableRec {s : Set (Set α)} {i : Ordinal} {f : ℕ → Set α}
(hf : ∀ n, ∃ j < i, f n ∈ generateMeasurableRec s j) :
⋃ n, f n ∈ generateMeasurableRec s i := by
unfold generateMeasurableRec
exact mem_union_right _ ⟨fun n => ⟨f n, let ⟨j, hj, hf⟩ := hf n; mem_iUnion₂.2 ⟨j, hj, hf⟩⟩, rfl⟩
theorem generateMeasurableRec_mono (s : Set (Set α)) : Monotone (generateMeasurableRec s) := by
intro i j h x hx
rcases h.eq_or_lt with (rfl | h)
· exact hx
· convert iUnion_mem_generateMeasurableRec fun _ => ⟨i, h, hx⟩
exact (iUnion_const x).symm
/-- An inductive principle for the elements of `generateMeasurableRec`. -/
@[elab_as_elim]
theorem generateMeasurableRec_induction {s : Set (Set α)} {i : Ordinal} {t : Set α}
{p : Set α → Prop} (hs : ∀ t ∈ s, p t) (h0 : p ∅)
(hc : ∀ u, p u → (∃ j < i, u ∈ generateMeasurableRec s j) → p uᶜ)
(hn : ∀ f : ℕ → Set α,
(∀ n, p (f n) ∧ ∃ j < i, f n ∈ generateMeasurableRec s j) → p (⋃ n, f n)) :
t ∈ generateMeasurableRec s i → p t := by
suffices H : ∀ k ≤ i, ∀ t ∈ generateMeasurableRec s k, p t from H i le_rfl t
intro k
apply WellFoundedLT.induction k
intro k IH hk t
replace IH := fun j hj => IH j hj (hj.le.trans hk)
unfold generateMeasurableRec
rintro (((ht | rfl) | ht) | ⟨f, rfl⟩)
· exact hs t ht
· exact h0
· simp_rw [mem_image, mem_iUnion₂] at ht
obtain ⟨u, ⟨⟨j, hj, hj'⟩, rfl⟩⟩ := ht
exact hc u (IH j hj u hj') ⟨j, hj.trans_le hk, hj'⟩
· apply hn
intro n
obtain ⟨j, hj, hj'⟩ := mem_iUnion₂.1 (f n).2
use IH j hj _ hj', j, hj.trans_le hk
theorem generateMeasurableRec_omega1 (s : Set (Set α)) :
generateMeasurableRec s (ω₁ : Ordinal.{v}) =
⋃ i < (ω₁ : Ordinal.{v}), generateMeasurableRec s i := by
apply (iUnion₂_subset fun i h => generateMeasurableRec_mono s h.le).antisymm'
intro t ht
rw [mem_iUnion₂]
refine generateMeasurableRec_induction ?_ ?_ ?_ ?_ ht
· intro t ht
exact ⟨0, omega_pos 1, self_subset_generateMeasurableRec s 0 ht⟩
· exact ⟨0, omega_pos 1, empty_mem_generateMeasurableRec s 0⟩
· rintro u - ⟨j, hj, hj'⟩
exact ⟨_, (isSuccLimit_omega 1).succ_lt hj,
compl_mem_generateMeasurableRec (Order.lt_succ j) hj'⟩
· intro f H
choose I hI using fun n => (H n).1
simp_rw [exists_prop] at hI
refine ⟨_, Ordinal.lsub_lt_ord_lift ?_ fun n => (hI n).1,
iUnion_mem_generateMeasurableRec fun n => ⟨_, Ordinal.lt_lsub I n, (hI n).2⟩⟩
rw [mk_nat, lift_aleph0, isRegular_aleph_one.cof_omega_eq]
exact aleph0_lt_aleph_one
theorem generateMeasurableRec_subset (s : Set (Set α)) (i : Ordinal) :
generateMeasurableRec s i ⊆ { t | GenerateMeasurable s t } := by
apply WellFoundedLT.induction i
exact fun i IH t ht => generateMeasurableRec_induction .basic .empty
(fun u _ ⟨j, hj, hj'⟩ => .compl _ (IH j hj hj')) (fun f H => .iUnion _ fun n => (H n).1) ht
/-- `generateMeasurableRec s ω₁` generates precisely the smallest sigma-algebra containing `s`. -/
theorem generateMeasurable_eq_rec (s : Set (Set α)) :
{ t | GenerateMeasurable s t } = generateMeasurableRec s ω₁ := by
apply (generateMeasurableRec_subset s _).antisymm'
intro t ht
induction ht with
| basic u hu => exact self_subset_generateMeasurableRec s _ hu
| empty => exact empty_mem_generateMeasurableRec s _
| compl u _ IH =>
rw [generateMeasurableRec_omega1, mem_iUnion₂] at IH
obtain ⟨i, hi, hi'⟩ := IH
exact generateMeasurableRec_mono _ ((isSuccLimit_omega 1).succ_lt hi).le
(compl_mem_generateMeasurableRec (Order.lt_succ i) hi')
| iUnion f _ IH =>
simp_rw [generateMeasurableRec_omega1, mem_iUnion₂, exists_prop] at IH
exact iUnion_mem_generateMeasurableRec IH
/-- `generateMeasurableRec` is constant for ordinals `≥ ω₁`. -/
theorem generateMeasurableRec_of_omega1_le (s : Set (Set α)) {i : Ordinal.{v}} (hi : ω₁ ≤ i) :
generateMeasurableRec s i = generateMeasurableRec s (ω₁ : Ordinal.{v}) := by
apply (generateMeasurableRec_mono s hi).antisymm'
rw [← generateMeasurable_eq_rec]
exact generateMeasurableRec_subset s i
/-- At each step of the inductive construction, the cardinality bound `≤ #s ^ ℵ₀` holds. -/
theorem cardinal_generateMeasurableRec_le (s : Set (Set α)) (i : Ordinal.{v}) :
#(generateMeasurableRec s i) ≤ max #s 2 ^ ℵ₀ := by
suffices ∀ i ≤ ω₁, #(generateMeasurableRec s i) ≤ max #s 2 ^ ℵ₀ by
obtain hi | hi := le_or_gt i ω₁
· exact this i hi
· rw [generateMeasurableRec_of_omega1_le s hi.le]
exact this _ le_rfl
intro i
apply WellFoundedLT.induction i
intro i IH hi
have A : 𝔠 ≤ max #s 2 ^ ℵ₀ := power_le_power_right (le_max_right _ _)
have B := aleph0_le_continuum.trans A
have C : #(⋃ j < i, generateMeasurableRec s j) ≤ max #s 2 ^ ℵ₀ := by
apply mk_iUnion_Ordinal_lift_le_of_le _ B _
· intro j hj
exact IH j hj (hj.trans_le hi).le
· rw [lift_power, lift_aleph0]
rw [← Ordinal.lift_le.{u}, lift_omega, Ordinal.lift_one, ← ord_aleph] at hi
have H := card_le_of_le_ord hi
rw [← Ordinal.lift_card] at H
apply H.trans <| aleph_one_le_continuum.trans <| power_le_power_right _
rw [lift_max, Cardinal.lift_ofNat]
exact le_max_right _ _
rw [generateMeasurableRec]
apply_rules [(mk_union_le _ _).trans, add_le_of_le (aleph_one_le_continuum.trans A),
mk_image_le.trans]
· exact (self_le_power _ one_le_aleph0).trans (power_le_power_right (le_max_left _ _))
· rw [mk_singleton]
exact one_lt_aleph0.le.trans B
· apply mk_range_le.trans
simp only [mk_pi, prod_const, Cardinal.lift_uzero, mk_denumerable, lift_aleph0]
have := @power_le_power_right _ _ ℵ₀ C
rwa [← power_mul, aleph0_mul_aleph0] at this
/-- If a sigma-algebra is generated by a set of sets `s`, then the sigma-algebra has cardinality at
most `max #s 2 ^ ℵ₀`. -/
theorem cardinal_generateMeasurable_le (s : Set (Set α)) :
#{ t | GenerateMeasurable s t } ≤ max #s 2 ^ ℵ₀ := by
rw [generateMeasurable_eq_rec.{u, 0}]
exact cardinal_generateMeasurableRec_le s _
/-- If a sigma-algebra is generated by a set of sets `s`, then the sigma
algebra has cardinality at most `max #s 2 ^ ℵ₀`. -/
theorem cardinal_measurableSet_le (s : Set (Set α)) :
#{ t | @MeasurableSet α (generateFrom s) t } ≤ max #s 2 ^ ℵ₀ :=
cardinal_generateMeasurable_le s
/-- If a sigma-algebra is generated by a set of sets `s` with cardinality at most the continuum,
then the sigma algebra has the same cardinality bound. -/
theorem cardinal_generateMeasurable_le_continuum {s : Set (Set α)} (hs : #s ≤ 𝔠) :
#{ t | GenerateMeasurable s t } ≤ 𝔠 := by
apply (cardinal_generateMeasurable_le s).trans
rw [← continuum_power_aleph0]
exact_mod_cast power_le_power_right (max_le hs (nat_lt_continuum 2).le)
/-- If a sigma-algebra is generated by a set of sets `s` with cardinality at most the continuum,
then the sigma algebra has the same cardinality bound. -/
theorem cardinal_measurableSet_le_continuum {s : Set (Set α)} :
#s ≤ 𝔠 → #{ t | @MeasurableSet α (generateFrom s) t } ≤ 𝔠 :=
cardinal_generateMeasurable_le_continuum
end MeasurableSpace |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/MeasurablyGenerated.lean | import Mathlib.MeasureTheory.MeasurableSpace.Constructions
import Mathlib.Order.Filter.AtTopBot.CompleteLattice
import Mathlib.Order.Filter.AtTopBot.CountablyGenerated
import Mathlib.Order.Filter.SmallSets
import Mathlib.Order.LiminfLimsup
import Mathlib.Tactic.FinCases
/-!
# Measurably generated filters
We say that a filter `f` is measurably generated if every set `s ∈ f` includes a measurable
set `t ∈ f`. This property is useful, e.g., to extract a measurable witness of `Filter.Eventually`.
-/
open Set Filter
universe uι
variable {α β γ δ : Type*} {ι : Sort uι}
namespace MeasurableSpace
/-- The sigma-algebra generated by a single set `s` is `{∅, s, sᶜ, univ}`. -/
@[simp] theorem generateFrom_singleton (s : Set α) :
generateFrom {s} = MeasurableSpace.comap (· ∈ s) ⊤ := by
classical
letI : MeasurableSpace α := generateFrom {s}
refine le_antisymm (generateFrom_le fun t ht => ⟨{True}, trivial, by simp [ht.symm]⟩) ?_
rintro _ ⟨u, -, rfl⟩
exact (show MeasurableSet s from GenerateMeasurable.basic _ <| mem_singleton s).mem trivial
lemma generateFrom_singleton_le {m : MeasurableSpace α} {s : Set α} (hs : MeasurableSet s) :
MeasurableSpace.generateFrom {s} ≤ m :=
generateFrom_le (fun _ ht ↦ mem_singleton_iff.1 ht ▸ hs)
end MeasurableSpace
namespace MeasureTheory
theorem measurableSet_generateFrom_singleton_iff {s t : Set α} :
MeasurableSet[MeasurableSpace.generateFrom {s}] t ↔ t = ∅ ∨ t = s ∨ t = sᶜ ∨ t = univ := by
simp_rw [MeasurableSpace.generateFrom_singleton]
unfold MeasurableSet MeasurableSpace.MeasurableSet' MeasurableSpace.comap
simp_rw [MeasurableSpace.measurableSet_top, true_and]
constructor
· rintro ⟨x, rfl⟩
by_cases hT : True ∈ x
· by_cases hF : False ∈ x
· suffices x = univ by grind
grind [univ_eq_true_false]
· grind
· by_cases hF : False ∈ x
· grind
· suffices x ⊆ ∅ by grind
intro p hp
fin_cases p <;> contradiction
· rintro (rfl | rfl | rfl | rfl)
on_goal 1 => use ∅
on_goal 2 => use {True}
on_goal 3 => use {False}
on_goal 4 => use Set.univ
all_goals
simp [compl_def]
end MeasureTheory
namespace Filter
variable [MeasurableSpace α]
/-- A filter `f` is measurably generates if each `s ∈ f` includes a measurable `t ∈ f`. -/
class IsMeasurablyGenerated (f : Filter α) : Prop where
exists_measurable_subset : ∀ ⦃s⦄, s ∈ f → ∃ t ∈ f, MeasurableSet t ∧ t ⊆ s
instance isMeasurablyGenerated_bot : IsMeasurablyGenerated (⊥ : Filter α) :=
⟨fun _ _ => ⟨∅, mem_bot, MeasurableSet.empty, empty_subset _⟩⟩
instance isMeasurablyGenerated_top : IsMeasurablyGenerated (⊤ : Filter α) :=
⟨fun _s hs => ⟨univ, univ_mem, MeasurableSet.univ, fun x _ => hs x⟩⟩
theorem Eventually.exists_measurable_mem {f : Filter α} [IsMeasurablyGenerated f] {p : α → Prop}
(h : ∀ᶠ x in f, p x) : ∃ s ∈ f, MeasurableSet s ∧ ∀ x ∈ s, p x :=
IsMeasurablyGenerated.exists_measurable_subset h
theorem Eventually.exists_measurable_mem_of_smallSets {f : Filter α} [IsMeasurablyGenerated f]
{p : Set α → Prop} (h : ∀ᶠ s in f.smallSets, p s) : ∃ s ∈ f, MeasurableSet s ∧ p s :=
let ⟨_s, hsf, hs⟩ := eventually_smallSets.1 h
let ⟨t, htf, htm, hts⟩ := IsMeasurablyGenerated.exists_measurable_subset hsf
⟨t, htf, htm, hs t hts⟩
instance inf_isMeasurablyGenerated (f g : Filter α) [IsMeasurablyGenerated f]
[IsMeasurablyGenerated g] : IsMeasurablyGenerated (f ⊓ g) := by
constructor
rintro t ⟨sf, hsf, sg, hsg, rfl⟩
rcases IsMeasurablyGenerated.exists_measurable_subset hsf with ⟨s'f, hs'f, hmf, hs'sf⟩
rcases IsMeasurablyGenerated.exists_measurable_subset hsg with ⟨s'g, hs'g, hmg, hs'sg⟩
refine ⟨s'f ∩ s'g, inter_mem_inf hs'f hs'g, hmf.inter hmg, ?_⟩
exact inter_subset_inter hs'sf hs'sg
theorem principal_isMeasurablyGenerated_iff {s : Set α} :
IsMeasurablyGenerated (𝓟 s) ↔ MeasurableSet s := by
refine ⟨?_, fun hs => ⟨fun t ht => ⟨s, mem_principal_self s, hs, ht⟩⟩⟩
rintro ⟨hs⟩
rcases hs (mem_principal_self s) with ⟨t, ht, htm, hts⟩
have : t = s := hts.antisymm ht
rwa [← this]
alias ⟨_, _root_.MeasurableSet.principal_isMeasurablyGenerated⟩ :=
principal_isMeasurablyGenerated_iff
instance iInf_isMeasurablyGenerated {f : ι → Filter α} [∀ i, IsMeasurablyGenerated (f i)] :
IsMeasurablyGenerated (⨅ i, f i) := by
refine ⟨fun s hs => ?_⟩
rw [← Equiv.plift.surjective.iInf_comp, mem_iInf] at hs
rcases hs with ⟨t, ht, ⟨V, hVf, rfl⟩⟩
choose U hUf hU using fun i => IsMeasurablyGenerated.exists_measurable_subset (hVf i)
refine ⟨⋂ i : t, U i, ?_, ?_, ?_⟩
· rw [← Equiv.plift.surjective.iInf_comp, mem_iInf]
exact ⟨t, ht, U, hUf, rfl⟩
· haveI := ht.countable.toEncodable.countable
exact MeasurableSet.iInter fun i => (hU i).1
· exact iInter_mono fun i => (hU i).2
end Filter
/-- The set of points for which a sequence of measurable functions converges to a given value
is measurable. -/
@[measurability]
lemma measurableSet_tendsto {_ : MeasurableSpace β} [MeasurableSpace γ]
[Countable δ] {l : Filter δ} [l.IsCountablyGenerated]
(l' : Filter γ) [l'.IsCountablyGenerated] [hl' : l'.IsMeasurablyGenerated]
{f : δ → β → γ} (hf : ∀ i, Measurable (f i)) :
MeasurableSet { x | Tendsto (fun n ↦ f n x) l l' } := by
rcases l.exists_antitone_basis with ⟨u, hu⟩
rcases (Filter.hasBasis_self.mpr hl'.exists_measurable_subset).exists_antitone_subbasis with
⟨v, v_meas, hv⟩
simp only [hu.tendsto_iff hv.toHasBasis, true_imp_iff, true_and, setOf_forall, setOf_exists]
exact .iInter fun n ↦ .iUnion fun _ ↦ .biInter (to_countable _) fun i _ ↦
(v_meas n).2.preimage (hf i)
namespace MeasurableSet
variable [MeasurableSpace α]
protected theorem iUnion_of_monotone_of_frequently
{ι : Type*} [Preorder ι] [(atTop : Filter ι).IsCountablyGenerated] {s : ι → Set α}
(hsm : Monotone s) (hs : ∃ᶠ i in atTop, MeasurableSet (s i)) : MeasurableSet (⋃ i, s i) := by
rcases exists_seq_forall_of_frequently hs with ⟨x, hx, hxm⟩
rw [← hsm.iUnion_comp_tendsto_atTop hx]
exact .iUnion hxm
protected theorem iInter_of_antitone_of_frequently
{ι : Type*} [Preorder ι] [(atTop : Filter ι).IsCountablyGenerated] {s : ι → Set α}
(hsm : Antitone s) (hs : ∃ᶠ i in atTop, MeasurableSet (s i)) : MeasurableSet (⋂ i, s i) := by
rw [← compl_iff, compl_iInter]
exact .iUnion_of_monotone_of_frequently (compl_anti.comp hsm) <| hs.mono fun _ ↦ .compl
protected theorem iUnion_of_monotone {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)]
[(atTop : Filter ι).IsCountablyGenerated] {s : ι → Set α}
(hsm : Monotone s) (hs : ∀ i, MeasurableSet (s i)) : MeasurableSet (⋃ i, s i) := by
cases isEmpty_or_nonempty ι with
| inl _ => simp
| inr _ => exact .iUnion_of_monotone_of_frequently hsm <| .of_forall hs
protected theorem iInter_of_antitone {ι : Type*} [Preorder ι] [IsDirected ι (· ≤ ·)]
[(atTop : Filter ι).IsCountablyGenerated] {s : ι → Set α}
(hsm : Antitone s) (hs : ∀ i, MeasurableSet (s i)) : MeasurableSet (⋂ i, s i) := by
rw [← compl_iff, compl_iInter]
exact .iUnion_of_monotone (compl_anti.comp hsm) fun i ↦ (hs i).compl
/-!
### Typeclasses on `Subtype MeasurableSet`
-/
instance Subtype.instMembership : Membership α (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun s a => a ∈ (s : Set α)⟩
@[simp]
theorem mem_coe (a : α) (s : Subtype (MeasurableSet : Set α → Prop)) : a ∈ (s : Set α) ↔ a ∈ s :=
Iff.rfl
instance Subtype.instEmptyCollection : EmptyCollection (Subtype (MeasurableSet : Set α → Prop)) :=
⟨⟨∅, MeasurableSet.empty⟩⟩
@[simp]
theorem coe_empty : ↑(∅ : Subtype (MeasurableSet : Set α → Prop)) = (∅ : Set α) :=
rfl
instance Subtype.instInsert [MeasurableSingletonClass α] :
Insert α (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun a s => ⟨insert a (s : Set α), s.prop.insert a⟩⟩
@[simp]
theorem coe_insert [MeasurableSingletonClass α] (a : α)
(s : Subtype (MeasurableSet : Set α → Prop)) :
↑(Insert.insert a s) = (Insert.insert a s : Set α) :=
rfl
instance Subtype.instSingleton [MeasurableSingletonClass α] :
Singleton α (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun a => ⟨{a}, .singleton _⟩⟩
@[simp] theorem coe_singleton [MeasurableSingletonClass α] (a : α) :
↑({a} : Subtype (MeasurableSet : Set α → Prop)) = ({a} : Set α) :=
rfl
instance Subtype.instLawfulSingleton [MeasurableSingletonClass α] :
LawfulSingleton α (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun _ => Subtype.eq <| insert_empty_eq _⟩
instance Subtype.instHasCompl : HasCompl (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x => ⟨xᶜ, x.prop.compl⟩⟩
@[simp]
theorem coe_compl (s : Subtype (MeasurableSet : Set α → Prop)) : ↑sᶜ = (sᶜ : Set α) :=
rfl
instance Subtype.instUnion : Union (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x y => ⟨(x : Set α) ∪ y, x.prop.union y.prop⟩⟩
@[simp]
theorem coe_union (s t : Subtype (MeasurableSet : Set α → Prop)) : ↑(s ∪ t) = (s ∪ t : Set α) :=
rfl
instance Subtype.instSup : Max (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x y => x ∪ y⟩
@[simp]
protected theorem sup_eq_union (s t : {s : Set α // MeasurableSet s}) : s ⊔ t = s ∪ t := rfl
instance Subtype.instInter : Inter (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x y => ⟨x ∩ y, x.prop.inter y.prop⟩⟩
@[simp]
theorem coe_inter (s t : Subtype (MeasurableSet : Set α → Prop)) : ↑(s ∩ t) = (s ∩ t : Set α) :=
rfl
instance Subtype.instInf : Min (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x y => x ∩ y⟩
@[simp]
protected theorem inf_eq_inter (s t : {s : Set α // MeasurableSet s}) : s ⊓ t = s ∩ t := rfl
instance Subtype.instSDiff : SDiff (Subtype (MeasurableSet : Set α → Prop)) :=
⟨fun x y => ⟨x \ y, x.prop.diff y.prop⟩⟩
-- TODO: Why does it complain that `x ⇨ y` is noncomputable?
noncomputable instance Subtype.instHImp : HImp (Subtype (MeasurableSet : Set α → Prop)) where
himp x y := ⟨x ⇨ y, x.prop.himp y.prop⟩
@[simp]
theorem coe_sdiff (s t : Subtype (MeasurableSet : Set α → Prop)) : ↑(s \ t) = (s : Set α) \ t :=
rfl
@[simp]
lemma coe_himp (s t : Subtype (MeasurableSet : Set α → Prop)) : ↑(s ⇨ t) = (s ⇨ t : Set α) := rfl
instance Subtype.instBot : Bot (Subtype (MeasurableSet : Set α → Prop)) := ⟨∅⟩
@[simp]
theorem coe_bot : ↑(⊥ : Subtype (MeasurableSet : Set α → Prop)) = (⊥ : Set α) :=
rfl
instance Subtype.instTop : Top (Subtype (MeasurableSet : Set α → Prop)) :=
⟨⟨Set.univ, MeasurableSet.univ⟩⟩
@[simp]
theorem coe_top : ↑(⊤ : Subtype (MeasurableSet : Set α → Prop)) = (⊤ : Set α) :=
rfl
noncomputable instance Subtype.instBooleanAlgebra :
BooleanAlgebra (Subtype (MeasurableSet : Set α → Prop)) :=
Subtype.coe_injective.booleanAlgebra _ coe_union coe_inter coe_top coe_bot coe_compl coe_sdiff
coe_himp
@[measurability]
theorem measurableSet_blimsup {s : ℕ → Set α} {p : ℕ → Prop} (h : ∀ n, p n → MeasurableSet (s n)) :
MeasurableSet <| blimsup s atTop p := by
simp only [blimsup_eq_iInf_biSup_of_nat, iSup_eq_iUnion, iInf_eq_iInter]
exact .iInter fun _ => .iUnion fun m => .iUnion fun hm => h m hm.1
@[measurability]
theorem measurableSet_bliminf {s : ℕ → Set α} {p : ℕ → Prop} (h : ∀ n, p n → MeasurableSet (s n)) :
MeasurableSet <| Filter.bliminf s Filter.atTop p := by
simp only [Filter.bliminf_eq_iSup_biInf_of_nat, iInf_eq_iInter, iSup_eq_iUnion]
exact .iUnion fun n => .iInter fun m => .iInter fun hm => h m hm.1
@[measurability]
theorem measurableSet_limsup {s : ℕ → Set α} (hs : ∀ n, MeasurableSet <| s n) :
MeasurableSet <| Filter.limsup s Filter.atTop := by
simpa only [← blimsup_true] using measurableSet_blimsup fun n _ => hs n
@[measurability]
theorem measurableSet_liminf {s : ℕ → Set α} (hs : ∀ n, MeasurableSet <| s n) :
MeasurableSet <| Filter.liminf s Filter.atTop := by
simpa only [← bliminf_true] using measurableSet_bliminf fun n _ => hs n
end MeasurableSet |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/CountablyGenerated.lean | import Mathlib.MeasureTheory.MeasurableSpace.Embedding
import Mathlib.Data.Set.MemPartition
import Mathlib.Order.Filter.CountableSeparatingOn
/-!
# Countably generated measurable spaces
We say a measurable space is countably generated if it can be generated by a countable set of sets.
In such a space, we can also build a sequence of finer and finer finite measurable partitions of
the space such that the measurable space is generated by the union of all partitions.
## Main definitions
* `MeasurableSpace.CountablyGenerated`: class stating that a measurable space is countably
generated.
* `MeasurableSpace.countableGeneratingSet`: a countable set of sets that generates the σ-algebra.
* `MeasurableSpace.countablePartition`: sequences of finer and finer partitions of
a countably generated space, defined by taking the `memPartition` of an enumeration of the sets in
`countableGeneratingSet`.
* `MeasurableSpace.SeparatesPoints` : class stating that a measurable space separates points.
## Main statements
* `MeasurableSpace.measurableEquiv_nat_bool_of_countablyGenerated`: if a measurable space is
countably generated and separates points, it is measure equivalent to a subset of the Cantor Space
`ℕ → Bool` (equipped with the product sigma algebra).
* `MeasurableSpace.measurable_injection_nat_bool_of_countablySeparated`: If a measurable space
admits a countable sequence of measurable sets separating points,
it admits a measurable injection into the Cantor space `ℕ → Bool`
`ℕ → Bool` (equipped with the product sigma algebra).
The file also contains measurability results about `memPartition`, from which the properties of
`countablePartition` are deduced.
-/
open Set MeasureTheory
namespace MeasurableSpace
variable {α β : Type*}
/-- We say a measurable space is countably generated
if it can be generated by a countable set of sets. -/
class CountablyGenerated (α : Type*) [m : MeasurableSpace α] : Prop where
isCountablyGenerated : ∃ b : Set (Set α), b.Countable ∧ m = generateFrom b
/-- A countable set of sets that generate the measurable space.
We insert `∅` to ensure it is nonempty. -/
def countableGeneratingSet (α : Type*) [MeasurableSpace α] [h : CountablyGenerated α] :
Set (Set α) :=
insert ∅ h.isCountablyGenerated.choose
lemma countable_countableGeneratingSet [MeasurableSpace α] [h : CountablyGenerated α] :
Set.Countable (countableGeneratingSet α) :=
Countable.insert _ h.isCountablyGenerated.choose_spec.1
lemma generateFrom_countableGeneratingSet [m : MeasurableSpace α] [h : CountablyGenerated α] :
generateFrom (countableGeneratingSet α) = m :=
(generateFrom_insert_empty _).trans <| h.isCountablyGenerated.choose_spec.2.symm
lemma empty_mem_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α] :
∅ ∈ countableGeneratingSet α := mem_insert _ _
lemma nonempty_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α] :
Set.Nonempty (countableGeneratingSet α) :=
⟨∅, mem_insert _ _⟩
lemma measurableSet_countableGeneratingSet [MeasurableSpace α] [CountablyGenerated α]
{s : Set α} (hs : s ∈ countableGeneratingSet α) :
MeasurableSet s := by
rw [← generateFrom_countableGeneratingSet (α := α)]
exact measurableSet_generateFrom hs
/-- A countable sequence of sets generating the measurable space. -/
def natGeneratingSequence (α : Type*) [MeasurableSpace α] [CountablyGenerated α] : ℕ → (Set α) :=
enumerateCountable (countable_countableGeneratingSet (α := α)) ∅
lemma generateFrom_natGeneratingSequence (α : Type*) [m : MeasurableSpace α]
[CountablyGenerated α] : generateFrom (range (natGeneratingSequence _)) = m := by
rw [natGeneratingSequence, range_enumerateCountable_of_mem _ empty_mem_countableGeneratingSet,
generateFrom_countableGeneratingSet]
lemma measurableSet_natGeneratingSequence [MeasurableSpace α] [CountablyGenerated α] (n : ℕ) :
MeasurableSet (natGeneratingSequence α n) :=
measurableSet_countableGeneratingSet <| Set.enumerateCountable_mem _
empty_mem_countableGeneratingSet n
theorem CountablyGenerated.comap [m : MeasurableSpace β] [h : CountablyGenerated β] (f : α → β) :
@CountablyGenerated α (.comap f m) := by
rcases h with ⟨⟨b, hbc, rfl⟩⟩
rw [comap_generateFrom]
letI := generateFrom (preimage f '' b)
exact ⟨_, hbc.image _, rfl⟩
theorem CountablyGenerated.sup {m₁ m₂ : MeasurableSpace β} (h₁ : @CountablyGenerated β m₁)
(h₂ : @CountablyGenerated β m₂) : @CountablyGenerated β (m₁ ⊔ m₂) := by
rcases h₁ with ⟨⟨b₁, hb₁c, rfl⟩⟩
rcases h₂ with ⟨⟨b₂, hb₂c, rfl⟩⟩
exact @mk _ (_ ⊔ _) ⟨_, hb₁c.union hb₂c, generateFrom_sup_generateFrom⟩
/-- Any measurable space structure on a countable space is countably generated. -/
instance (priority := 100) [MeasurableSpace α] [Countable α] : CountablyGenerated α where
isCountablyGenerated := by
refine ⟨⋃ y, {measurableAtom y}, countable_iUnion (fun i ↦ countable_singleton _), ?_⟩
refine le_antisymm ?_ (generateFrom_le (by simp [MeasurableSet.measurableAtom_of_countable]))
intro s hs
have : s = ⋃ y ∈ s, measurableAtom y := by
apply Subset.antisymm
· intro x hx
simpa using ⟨x, hx, by simp⟩
· simp only [iUnion_subset_iff]
intro x hx
exact measurableAtom_subset hs hx
rw [this]
apply MeasurableSet.biUnion (to_countable s) (fun x _hx ↦ ?_)
apply measurableSet_generateFrom
simp
instance [MeasurableSpace α] [CountablyGenerated α] {p : α → Prop} :
CountablyGenerated { x // p x } := .comap _
instance [MeasurableSpace α] [CountablyGenerated α] [MeasurableSpace β] [CountablyGenerated β] :
CountablyGenerated (α × β) :=
.sup (.comap Prod.fst) (.comap Prod.snd)
section SeparatesPoints
/-- We say that a measurable space separates points if for any two distinct points,
there is a measurable set containing one but not the other. -/
class SeparatesPoints (α : Type*) [m : MeasurableSpace α] : Prop where
separates : ∀ x y : α, (∀ s, MeasurableSet s → (x ∈ s → y ∈ s)) → x = y
theorem separatesPoints_def [MeasurableSpace α] [hs : SeparatesPoints α] {x y : α}
(h : ∀ s, MeasurableSet s → (x ∈ s → y ∈ s)) : x = y := hs.separates _ _ h
theorem exists_measurableSet_of_ne [MeasurableSpace α] [SeparatesPoints α] {x y : α}
(h : x ≠ y) : ∃ s, MeasurableSet s ∧ x ∈ s ∧ y ∉ s := by
contrapose! h
exact separatesPoints_def h
theorem separatesPoints_iff [MeasurableSpace α] : SeparatesPoints α ↔
∀ x y : α, (∀ s, MeasurableSet s → (x ∈ s ↔ y ∈ s)) → x = y :=
⟨fun h ↦ fun _ _ hxy ↦ h.separates _ _ fun _ hs xs ↦ (hxy _ hs).mp xs,
fun h ↦ ⟨fun _ _ hxy ↦ h _ _ fun _ hs ↦
⟨fun xs ↦ hxy _ hs xs, not_imp_not.mp fun xs ↦ hxy _ hs.compl xs⟩⟩⟩
/-- If the measurable space generated by `S` separates points,
then this is witnessed by sets in `S`. -/
theorem separating_of_generateFrom (S : Set (Set α))
[h : @SeparatesPoints α (generateFrom S)] :
∀ x y : α, (∀ s ∈ S, x ∈ s ↔ y ∈ s) → x = y := by
letI := generateFrom S
intro x y hxy
rw [← forall_generateFrom_mem_iff_mem_iff] at hxy
exact separatesPoints_def <| fun _ hs ↦ (hxy _ hs).mp
theorem SeparatesPoints.mono {m m' : MeasurableSpace α} [hsep : @SeparatesPoints _ m] (h : m ≤ m') :
@SeparatesPoints _ m' := @SeparatesPoints.mk _ m' fun _ _ hxy ↦
@SeparatesPoints.separates _ m hsep _ _ fun _ hs ↦ hxy _ (h _ hs)
/-- We say that a measurable space is countably separated if there is a
countable sequence of measurable sets separating points. -/
class CountablySeparated (α : Type*) [MeasurableSpace α] : Prop where
countably_separated : HasCountableSeparatingOn α MeasurableSet univ
instance countablySeparated_of_hasCountableSeparatingOn [MeasurableSpace α]
[h : HasCountableSeparatingOn α MeasurableSet univ] : CountablySeparated α := ⟨h⟩
instance hasCountableSeparatingOn_of_countablySeparated [MeasurableSpace α]
[h : CountablySeparated α] : HasCountableSeparatingOn α MeasurableSet univ :=
h.countably_separated
theorem countablySeparated_def [MeasurableSpace α] :
CountablySeparated α ↔ HasCountableSeparatingOn α MeasurableSet univ :=
⟨fun h ↦ h.countably_separated, fun h ↦ ⟨h⟩⟩
theorem CountablySeparated.mono {m m' : MeasurableSpace α} [hsep : @CountablySeparated _ m]
(h : m ≤ m') : @CountablySeparated _ m' := by
simp_rw [countablySeparated_def] at *
rcases hsep with ⟨S, Sct, Smeas, hS⟩
use S, Sct, (fun s hs ↦ h _ <| Smeas _ hs), hS
theorem CountablySeparated.subtype_iff [MeasurableSpace α] {s : Set α} :
CountablySeparated s ↔ HasCountableSeparatingOn α MeasurableSet s := by
rw [countablySeparated_def]
exact HasCountableSeparatingOn.subtype_iff
instance (priority := 100) Subtype.separatesPoints [MeasurableSpace α] [h : SeparatesPoints α]
{s : Set α} : SeparatesPoints s :=
⟨fun _ _ hxy ↦ Subtype.val_injective <| h.1 _ _ fun _ ht ↦ hxy _ <| measurable_subtype_coe ht⟩
instance (priority := 100) Subtype.countablySeparated [MeasurableSpace α]
[h : CountablySeparated α] {s : Set α} : CountablySeparated s := by
rw [CountablySeparated.subtype_iff]
exact h.countably_separated.mono (fun s ↦ id) <| subset_univ _
instance (priority := 100) separatesPoints_of_measurableSingletonClass [MeasurableSpace α]
[MeasurableSingletonClass α] : SeparatesPoints α := by
refine ⟨fun x y h ↦ ?_⟩
specialize h _ (MeasurableSet.singleton x)
simp_rw [mem_singleton_iff, forall_true_left] at h
exact h.symm
instance (priority := 50) MeasurableSingletonClass.of_separatesPoints [MeasurableSpace α]
[Countable α] [SeparatesPoints α] : MeasurableSingletonClass α where
measurableSet_singleton x := by
choose s hsm hxs hys using fun y (h : x ≠ y) ↦ exists_measurableSet_of_ne h
convert MeasurableSet.iInter fun y ↦ .iInter fun h ↦ hsm y h
ext y
rcases eq_or_ne x y with rfl | h
· simpa
· simp only [mem_singleton_iff, h.symm, false_iff, mem_iInter, not_forall]
exact ⟨y, h, hys y h⟩
instance hasCountableSeparatingOn_of_countablySeparated_subtype
[MeasurableSpace α] {s : Set α} [h : CountablySeparated s] :
HasCountableSeparatingOn _ MeasurableSet s := CountablySeparated.subtype_iff.mp h
instance countablySeparated_subtype_of_hasCountableSeparatingOn
[MeasurableSpace α] {s : Set α} [h : HasCountableSeparatingOn _ MeasurableSet s] :
CountablySeparated s := CountablySeparated.subtype_iff.mpr h
instance countablySeparated_of_separatesPoints [MeasurableSpace α]
[h : CountablyGenerated α] [SeparatesPoints α] : CountablySeparated α := by
rcases h with ⟨b, hbc, hb⟩
refine ⟨⟨b, hbc, fun t ht ↦ hb.symm ▸ .basic t ht, ?_⟩⟩
rw [hb] at ‹SeparatesPoints _›
convert separating_of_generateFrom b
simp
variable (α)
/-- If a measurable space admits a countable separating family of measurable sets,
there is a countably generated coarser space which still separates points. -/
theorem exists_countablyGenerated_le_of_countablySeparated [m : MeasurableSpace α]
[h : CountablySeparated α] :
∃ m' : MeasurableSpace α, @CountablyGenerated _ m' ∧ @SeparatesPoints _ m' ∧ m' ≤ m := by
rcases h with ⟨b, bct, hbm, hb⟩
refine ⟨generateFrom b, ?_, ?_, generateFrom_le hbm⟩
· use b
rw [@separatesPoints_iff]
exact fun x y hxy ↦ hb _ trivial _ trivial fun _ hs ↦ hxy _ <| measurableSet_generateFrom hs
open Function
open Classical in
/-- A map from a measurable space to the Cantor space `ℕ → Bool` induced by a countable
sequence of sets generating the measurable space. -/
noncomputable
def mapNatBool [MeasurableSpace α] [CountablyGenerated α] (x : α) (n : ℕ) :
Bool := x ∈ natGeneratingSequence α n
theorem measurable_mapNatBool [MeasurableSpace α] [CountablyGenerated α] :
Measurable (mapNatBool α) := by
rw [measurable_pi_iff]
refine fun n ↦ measurable_to_bool ?_
simp only [preimage, mem_singleton_iff, mapNatBool,
Bool.decide_iff, setOf_mem_eq]
apply measurableSet_natGeneratingSequence
theorem injective_mapNatBool [MeasurableSpace α] [CountablyGenerated α]
[SeparatesPoints α] : Injective (mapNatBool α) := by
intro x y hxy
rw [← generateFrom_natGeneratingSequence α] at *
apply separating_of_generateFrom (range (natGeneratingSequence _))
rintro - ⟨n, rfl⟩
rw [← decide_eq_decide]
exact congr_fun hxy n
/-- If a measurable space is countably generated and separates points, it is measure equivalent
to some subset of the Cantor space `ℕ → Bool` (equipped with the product sigma algebra).
Note: `s` need not be measurable, so this map need not be a `MeasurableEmbedding` to
the Cantor Space. -/
theorem measurableEquiv_nat_bool_of_countablyGenerated [MeasurableSpace α]
[CountablyGenerated α] [SeparatesPoints α] :
∃ s : Set (ℕ → Bool), Nonempty (α ≃ᵐ s) := by
use range (mapNatBool α), Equiv.ofInjective _ <|
injective_mapNatBool _,
Measurable.subtype_mk <| measurable_mapNatBool _
simp_rw [← generateFrom_natGeneratingSequence α]
apply measurable_generateFrom
rintro _ ⟨n, rfl⟩
rw [← Equiv.image_eq_preimage_symm _ _]
refine ⟨{y | y n}, by measurability, ?_⟩
rw [← Equiv.preimage_eq_iff_eq_image]
simp [mapNatBool]
/-- If a measurable space admits a countable sequence of measurable sets separating points,
it admits a measurable injection into the Cantor space `ℕ → Bool`
(equipped with the product sigma algebra). -/
theorem measurable_injection_nat_bool_of_countablySeparated [MeasurableSpace α]
[CountablySeparated α] : ∃ f : α → ℕ → Bool, Measurable f ∧ Injective f := by
rcases exists_countablyGenerated_le_of_countablySeparated α with ⟨m', _, _, m'le⟩
refine ⟨mapNatBool α, ?_, injective_mapNatBool _⟩
exact (measurable_mapNatBool _).mono m'le le_rfl
variable {α}
--TODO: Make this an instance
theorem measurableSingletonClass_of_countablySeparated
[MeasurableSpace α] [CountablySeparated α] :
MeasurableSingletonClass α := by
rcases measurable_injection_nat_bool_of_countablySeparated α with ⟨f, fmeas, finj⟩
refine ⟨fun x ↦ ?_⟩
rw [← finj.preimage_image {x}, image_singleton]
exact fmeas <| MeasurableSet.singleton _
end SeparatesPoints
section MeasurableMemPartition
lemma measurableSet_succ_memPartition (t : ℕ → Set α) (n : ℕ) {s : Set α}
(hs : s ∈ memPartition t n) :
MeasurableSet[generateFrom (memPartition t (n + 1))] s := by
rw [← diff_union_inter s (t n)]
refine MeasurableSet.union ?_ ?_ <;>
· refine measurableSet_generateFrom ?_
rw [memPartition_succ]
exact ⟨s, hs, by simp⟩
lemma generateFrom_memPartition_le_succ (t : ℕ → Set α) (n : ℕ) :
generateFrom (memPartition t n) ≤ generateFrom (memPartition t (n + 1)) :=
generateFrom_le (fun _ hs ↦ measurableSet_succ_memPartition t n hs)
lemma measurableSet_generateFrom_memPartition_iff (t : ℕ → Set α) (n : ℕ) (s : Set α) :
MeasurableSet[generateFrom (memPartition t n)] s
↔ ∃ S : Finset (Set α), ↑S ⊆ memPartition t n ∧ s = ⋃₀ S := by
refine ⟨fun h ↦ ?_, fun ⟨S, hS_subset, hS_eq⟩ ↦ ?_⟩
· induction s, h using generateFrom_induction with
| hC u hu _ => exact ⟨{u}, by simp [hu], by simp⟩
| empty => exact ⟨∅, by simp, by simp⟩
| compl u _ hu =>
obtain ⟨S, hS_subset, rfl⟩ := hu
classical
refine ⟨(memPartition t n).toFinset \ S, ?_, ?_⟩
· simp only [Finset.coe_sdiff, coe_toFinset]
exact diff_subset
· simp only [Finset.coe_sdiff, coe_toFinset]
refine (IsCompl.eq_compl ⟨?_, ?_⟩).symm
· refine Set.disjoint_sUnion_right.mpr fun u huS => ?_
refine Set.disjoint_sUnion_left.mpr fun v huV => ?_
refine disjoint_memPartition t n (mem_of_mem_diff huV) (hS_subset huS) ?_
exact ne_of_mem_of_not_mem huS (notMem_of_mem_diff huV) |>.symm
· rw [codisjoint_iff]
simp only [sup_eq_union, top_eq_univ]
rw [← sUnion_memPartition t n, union_comm, ← sUnion_union, union_diff_cancel hS_subset]
| iUnion f _ h =>
choose S hS_subset hS_eq using h
have : Fintype (⋃ n, (S n : Set (Set α))) := by
refine (Finite.subset (finite_memPartition t n) ?_).fintype
simp only [iUnion_subset_iff]
exact hS_subset
refine ⟨(⋃ n, (S n : Set (Set α))).toFinset, ?_, ?_⟩
· simp only [coe_toFinset, iUnion_subset_iff]
exact hS_subset
· simp only [coe_toFinset, sUnion_iUnion, hS_eq]
· rw [hS_eq, sUnion_eq_biUnion]
refine MeasurableSet.biUnion ?_ (fun t ht ↦ ?_)
· exact S.countable_toSet
· exact measurableSet_generateFrom (hS_subset ht)
lemma measurableSet_generateFrom_memPartition (t : ℕ → Set α) (n : ℕ) :
MeasurableSet[generateFrom (memPartition t (n + 1))] (t n) := by
have : t n = ⋃ u ∈ memPartition t n, u ∩ t n := by
simp_rw [← iUnion_inter, ← sUnion_eq_biUnion, sUnion_memPartition, univ_inter]
rw [this]
refine MeasurableSet.biUnion (finite_memPartition _ _).countable (fun v hv ↦ ?_)
refine measurableSet_generateFrom ?_
rw [memPartition_succ]
exact ⟨v, hv, Or.inl rfl⟩
lemma generateFrom_iUnion_memPartition (t : ℕ → Set α) :
generateFrom (⋃ n, memPartition t n) = generateFrom (range t) := by
refine le_antisymm (generateFrom_le fun u hu ↦ ?_) (generateFrom_le fun u hu ↦ ?_)
· simp only [mem_iUnion] at hu
obtain ⟨n, hun⟩ := hu
induction n generalizing u with
| zero =>
simp only [memPartition_zero, mem_singleton_iff] at hun
rw [hun]
exact MeasurableSet.univ
| succ n ih =>
simp only [memPartition_succ, mem_setOf_eq] at hun
obtain ⟨v, hv, huv⟩ := hun
rcases huv with rfl | rfl
· exact (ih v hv).inter (measurableSet_generateFrom ⟨n, rfl⟩)
· exact (ih v hv).diff (measurableSet_generateFrom ⟨n, rfl⟩)
· simp only [mem_range] at hu
obtain ⟨n, rfl⟩ := hu
exact generateFrom_mono (subset_iUnion _ _) _ (measurableSet_generateFrom_memPartition t n)
lemma generateFrom_memPartition_le_range (t : ℕ → Set α) (n : ℕ) :
generateFrom (memPartition t n) ≤ generateFrom (range t) := by
conv_rhs => rw [← generateFrom_iUnion_memPartition t]
exact generateFrom_mono (subset_iUnion _ _)
lemma generateFrom_iUnion_memPartition_le [m : MeasurableSpace α] {t : ℕ → Set α}
(ht : ∀ n, MeasurableSet (t n)) :
generateFrom (⋃ n, memPartition t n) ≤ m := by
refine (generateFrom_iUnion_memPartition t).trans_le (generateFrom_le ?_)
rintro s ⟨i, rfl⟩
exact ht i
lemma generateFrom_memPartition_le [m : MeasurableSpace α] {t : ℕ → Set α}
(ht : ∀ n, MeasurableSet (t n)) (n : ℕ) :
generateFrom (memPartition t n) ≤ m :=
(generateFrom_mono (subset_iUnion _ _)).trans (generateFrom_iUnion_memPartition_le ht)
lemma measurableSet_memPartition [MeasurableSpace α] {t : ℕ → Set α}
(ht : ∀ n, MeasurableSet (t n)) (n : ℕ) {s : Set α} (hs : s ∈ memPartition t n) :
MeasurableSet s :=
generateFrom_memPartition_le ht n _ (measurableSet_generateFrom hs)
lemma measurableSet_memPartitionSet [MeasurableSpace α] {t : ℕ → Set α}
(ht : ∀ n, MeasurableSet (t n)) (n : ℕ) (a : α) :
MeasurableSet (memPartitionSet t n a) :=
measurableSet_memPartition ht n (memPartitionSet_mem t n a)
end MeasurableMemPartition
variable [m : MeasurableSpace α] [h : CountablyGenerated α]
/-- For each `n : ℕ`, `countablePartition α n` is a partition of the space in at most
`2^n` sets. Each partition is finer than the preceding one. The measurable space generated by
the union of all those partitions is the measurable space on `α`. -/
def countablePartition (α : Type*) [MeasurableSpace α] [CountablyGenerated α] : ℕ → Set (Set α) :=
memPartition (enumerateCountable countable_countableGeneratingSet ∅)
lemma measurableSet_enumerateCountable_countableGeneratingSet
(α : Type*) [MeasurableSpace α] [CountablyGenerated α] (n : ℕ) :
MeasurableSet (enumerateCountable (countable_countableGeneratingSet (α := α)) ∅ n) :=
measurableSet_countableGeneratingSet
(enumerateCountable_mem _ (empty_mem_countableGeneratingSet) n)
lemma finite_countablePartition (α : Type*) [MeasurableSpace α] [CountablyGenerated α] (n : ℕ) :
Set.Finite (countablePartition α n) :=
finite_memPartition _ n
instance instFinite_countablePartition (n : ℕ) : Finite (countablePartition α n) :=
Set.finite_coe_iff.mp (finite_countablePartition _ _)
lemma disjoint_countablePartition {n : ℕ} {s t : Set α}
(hs : s ∈ countablePartition α n) (ht : t ∈ countablePartition α n) (hst : s ≠ t) :
Disjoint s t :=
disjoint_memPartition _ n hs ht hst
lemma sUnion_countablePartition (α : Type*) [MeasurableSpace α] [CountablyGenerated α] (n : ℕ) :
⋃₀ countablePartition α n = univ :=
sUnion_memPartition _ n
lemma measurableSet_generateFrom_countablePartition_iff (n : ℕ) (s : Set α) :
MeasurableSet[generateFrom (countablePartition α n)] s
↔ ∃ S : Finset (Set α), ↑S ⊆ countablePartition α n ∧ s = ⋃₀ S :=
measurableSet_generateFrom_memPartition_iff _ n s
lemma measurableSet_succ_countablePartition (n : ℕ) {s : Set α} (hs : s ∈ countablePartition α n) :
MeasurableSet[generateFrom (countablePartition α (n + 1))] s :=
measurableSet_succ_memPartition _ _ hs
lemma generateFrom_countablePartition_le_succ (α : Type*) [MeasurableSpace α] [CountablyGenerated α]
(n : ℕ) :
generateFrom (countablePartition α n) ≤ generateFrom (countablePartition α (n + 1)) :=
generateFrom_memPartition_le_succ _ _
lemma generateFrom_iUnion_countablePartition (α : Type*) [m : MeasurableSpace α]
[CountablyGenerated α] :
generateFrom (⋃ n, countablePartition α n) = m := by
rw [countablePartition, generateFrom_iUnion_memPartition,
range_enumerateCountable_of_mem _ empty_mem_countableGeneratingSet,
generateFrom_countableGeneratingSet]
lemma generateFrom_countablePartition_le (α : Type*) [m : MeasurableSpace α] [CountablyGenerated α]
(n : ℕ) :
generateFrom (countablePartition α n) ≤ m :=
generateFrom_memPartition_le (measurableSet_enumerateCountable_countableGeneratingSet α) n
lemma measurableSet_countablePartition (n : ℕ) {s : Set α} (hs : s ∈ countablePartition α n) :
MeasurableSet s :=
generateFrom_countablePartition_le α n _ (measurableSet_generateFrom hs)
/-- The set in `countablePartition α n` to which `a : α` belongs. -/
def countablePartitionSet (n : ℕ) (a : α) : Set α :=
memPartitionSet (enumerateCountable countable_countableGeneratingSet ∅) n a
lemma countablePartitionSet_mem (n : ℕ) (a : α) :
countablePartitionSet n a ∈ countablePartition α n :=
memPartitionSet_mem _ _ _
lemma mem_countablePartitionSet (n : ℕ) (a : α) : a ∈ countablePartitionSet n a :=
mem_memPartitionSet _ _ _
lemma countablePartitionSet_eq_iff {n : ℕ} (a : α) {s : Set α} (hs : s ∈ countablePartition α n) :
countablePartitionSet n a = s ↔ a ∈ s :=
memPartitionSet_eq_iff _ hs
lemma countablePartitionSet_of_mem {n : ℕ} {a : α} {s : Set α} (hs : s ∈ countablePartition α n)
(ha : a ∈ s) :
countablePartitionSet n a = s :=
memPartitionSet_of_mem hs ha
@[measurability]
lemma measurableSet_countablePartitionSet (n : ℕ) (a : α) :
MeasurableSet (countablePartitionSet n a) :=
measurableSet_countablePartition n (countablePartitionSet_mem n a)
section CountableOrCountablyGenerated
variable {α γ : Type*} [MeasurableSpace γ]
/-- A class registering that either `α` is countable or `β` is a countably generated
measurable space. -/
class CountableOrCountablyGenerated (α β : Type*) [MeasurableSpace β] :
Prop where
countableOrCountablyGenerated : Countable α ∨ MeasurableSpace.CountablyGenerated β
instance instCountableOrCountablyGeneratedOfCountable [h1 : Countable α] [MeasurableSpace β] :
CountableOrCountablyGenerated α β := ⟨Or.inl h1⟩
instance instCountableOrCountablyGeneratedOfCountablyGenerated [MeasurableSpace β]
[h : CountablyGenerated β] :
CountableOrCountablyGenerated α β := ⟨Or.inr h⟩
instance [hα : CountableOrCountablyGenerated α γ] [hβ : CountableOrCountablyGenerated β γ] :
CountableOrCountablyGenerated (α × β) γ := by
rcases hα with (hα | hα) <;> rcases hβ with (hβ | hβ) <;> infer_instance
lemma countableOrCountablyGenerated_left_of_prod_left_of_nonempty [Nonempty β]
[h : CountableOrCountablyGenerated (α × β) γ] :
CountableOrCountablyGenerated α γ := by
rcases h.countableOrCountablyGenerated with (h | h)
· have := countable_left_of_prod_of_nonempty h
infer_instance
· infer_instance
lemma countableOrCountablyGenerated_right_of_prod_left_of_nonempty [Nonempty α]
[h : CountableOrCountablyGenerated (α × β) γ] :
CountableOrCountablyGenerated β γ := by
rcases h.countableOrCountablyGenerated with (h | h)
· have := countable_right_of_prod_of_nonempty h
infer_instance
· infer_instance
lemma countableOrCountablyGenerated_prod_left_swap [h : CountableOrCountablyGenerated (α × β) γ] :
CountableOrCountablyGenerated (β × α) γ := by
rcases h with (h | h)
· refine ⟨Or.inl countable_prod_swap⟩
· exact ⟨Or.inr h⟩
end CountableOrCountablyGenerated
end MeasurableSpace |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Prod.lean | import Mathlib.MeasureTheory.MeasurableSpace.Embedding
import Mathlib.MeasureTheory.PiSystem
/-!
# The product sigma algebra
This file talks about the measurability of operations on binary functions.
-/
assert_not_exists MeasureTheory.Measure
noncomputable section
open Set MeasurableSpace
variable {α β : Type*} [MeasurableSpace α] [MeasurableSpace β]
/-- The product of generated σ-algebras is the one generated by rectangles, if both generating sets
are countably spanning. -/
theorem generateFrom_prod_eq {α β} {C : Set (Set α)} {D : Set (Set β)} (hC : IsCountablySpanning C)
(hD : IsCountablySpanning D) :
@Prod.instMeasurableSpace _ _ (generateFrom C) (generateFrom D) =
generateFrom (image2 (· ×ˢ ·) C D) := by
apply le_antisymm
· refine sup_le ?_ ?_ <;> rw [comap_generateFrom] <;> apply generateFrom_le <;>
rintro _ ⟨s, hs, rfl⟩
· rcases hD with ⟨t, h1t, h2t⟩
rw [← prod_univ, ← h2t, prod_iUnion]
apply MeasurableSet.iUnion
intro n
apply measurableSet_generateFrom
exact ⟨s, hs, t n, h1t n, rfl⟩
· rcases hC with ⟨t, h1t, h2t⟩
rw [← univ_prod, ← h2t, iUnion_prod_const]
apply MeasurableSet.iUnion
rintro n
apply measurableSet_generateFrom
exact mem_image2_of_mem (h1t n) hs
· apply generateFrom_le
rintro _ ⟨s, hs, t, ht, rfl⟩
dsimp only
rw [prod_eq]
apply (measurable_fst _).inter (measurable_snd _)
· exact measurableSet_generateFrom hs
· exact measurableSet_generateFrom ht
/-- If `C` and `D` generate the σ-algebras on `α` resp. `β`, then rectangles formed by `C` and `D`
generate the σ-algebra on `α × β`. -/
theorem generateFrom_eq_prod {C : Set (Set α)} {D : Set (Set β)} (hC : generateFrom C = ‹_›)
(hD : generateFrom D = ‹_›) (h2C : IsCountablySpanning C) (h2D : IsCountablySpanning D) :
generateFrom (image2 (· ×ˢ ·) C D) = Prod.instMeasurableSpace := by
rw [← hC, ← hD, generateFrom_prod_eq h2C h2D]
/-- The product σ-algebra is generated from boxes, i.e. `s ×ˢ t` for sets `s : Set α` and
`t : Set β`. -/
lemma generateFrom_prod :
generateFrom (image2 (· ×ˢ ·) { s : Set α | MeasurableSet s } { t : Set β | MeasurableSet t }) =
Prod.instMeasurableSpace :=
generateFrom_eq_prod generateFrom_measurableSet generateFrom_measurableSet
isCountablySpanning_measurableSet isCountablySpanning_measurableSet
/-- Rectangles form a π-system. -/
lemma isPiSystem_prod :
IsPiSystem (image2 (· ×ˢ ·) { s : Set α | MeasurableSet s } { t : Set β | MeasurableSet t }) :=
isPiSystem_measurableSet.prod isPiSystem_measurableSet
/-- The comap of a product is the supremum of the comaps. -/
lemma MeasurableSpace.comap_prodMk {α β γ : Type*} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
(X : α → β) (Y : α → γ) :
(mβ.prod mγ).comap (fun ω ↦ (X ω, Y ω)) = mβ.comap X ⊔ mγ.comap Y := by
simp_rw [MeasurableSpace.prod, comap_sup, comap_comp]
rfl
/-- The comap of `Prod.map` is the product of the comaps. -/
lemma MeasurableSpace.comap_prodMap {α β γ δ : Type*}
{mα : MeasurableSpace α} {mβ : MeasurableSpace β} (X : γ → α) (Y : δ → β) :
(mα.prod mβ).comap (Prod.map X Y) = (mα.comap X).prod (mβ.comap Y) := by
simp_rw [MeasurableSpace.prod, comap_sup, comap_comp]
rfl
/-- `Prod.map` of two measurable embeddings is a measurable embedding. -/
lemma MeasurableEmbedding.prodMap {α β γ δ : Type*} {mα : MeasurableSpace α}
{mβ : MeasurableSpace β} {mγ : MeasurableSpace γ} {mδ : MeasurableSpace δ} {f : α → β}
{g : γ → δ} (hg : MeasurableEmbedding g) (hf : MeasurableEmbedding f) :
MeasurableEmbedding (Prod.map g f) := by
rw [MeasurableEmbedding.iff_comap_eq]
refine ⟨hg.injective.prodMap hf.injective, ?_, ?_⟩
· rw [Prod.instMeasurableSpace, Prod.instMeasurableSpace, MeasurableSpace.comap_prodMap,
hg.comap_eq, hf.comap_eq]
· rw [range_prodMap]
exact hg.measurableSet_range.prod hf.measurableSet_range
lemma MeasurableEmbedding.prodMk_left {β γ : Type*} [MeasurableSingletonClass α]
{mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
(x : α) {f : γ → β} (hf : MeasurableEmbedding f) :
MeasurableEmbedding (fun y ↦ (x, f y)) where
injective := by
intro y y'
simp only [Prod.mk.injEq, true_and]
exact fun h ↦ hf.injective h
measurable := Measurable.prodMk measurable_const hf.measurable
measurableSet_image' := by
intro s hs
convert (MeasurableSet.singleton x).prod (hf.measurableSet_image.mpr hs)
ext x
simp [Prod.ext_iff, eq_comm, ← exists_and_left, and_left_comm]
lemma measurableEmbedding_prodMk_left [MeasurableSingletonClass α] (x : α) :
MeasurableEmbedding (Prod.mk x : β → α × β) :=
MeasurableEmbedding.prodMk_left x MeasurableEmbedding.id
lemma MeasurableEmbedding.prodMk_right {β γ : Type*} [MeasurableSingletonClass α]
{mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
{f : γ → β} (hf : MeasurableEmbedding f) (x : α) :
MeasurableEmbedding (fun y ↦ (f y, x)) :=
MeasurableEquiv.prodComm.measurableEmbedding.comp (hf.prodMk_left _)
lemma measurableEmbedding_prod_mk_right [MeasurableSingletonClass α] (x : α) :
MeasurableEmbedding (fun y ↦ (y, x) : β → β × α) :=
MeasurableEmbedding.prodMk_right MeasurableEmbedding.id x |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/NCard.lean | import Mathlib.Data.Set.Card
import Mathlib.MeasureTheory.MeasurableSpace.Constructions
/-!
# Measurability of `Set.encard` and `Set.ncard`
In this file we prove that `Set.encard` and `Set.ncard` are measurable functions,
provided that the ambient space is countable.
-/
open Set
variable {α : Type*} [Countable α]
@[measurability]
theorem measurable_encard : Measurable (Set.encard : Set α → ℕ∞) :=
ENat.measurable_iff.2 fun _n ↦ Countable.measurableSet <| Countable.setOf_finite.mono fun _s hs ↦
finite_of_encard_eq_coe hs
@[measurability]
theorem measurable_ncard : Measurable (Set.ncard : Set α → ℕ) :=
Measurable.of_discrete.comp measurable_encard |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/EventuallyMeasurable.lean | import Mathlib.MeasureTheory.MeasurableSpace.Defs
import Mathlib.Order.Filter.CountableInter
/-!
# Measurability modulo a filter
In this file we consider the general notion of measurability modulo a σ-filter.
Two important instances of this construction are null-measurability with respect to a measure,
where the filter is the collection of co-null sets, and
Baire-measurability with respect to a topology,
where the filter is the collection of comeager (residual) sets.
(not to be confused with measurability with respect to the sigma algebra
of Baire sets, which is sometimes also called this.)
TODO: Implement the latter.
## Main definitions
* `eventuallyMeasurableSpace`: A `MeasurableSpace` on a type `α` consisting of sets which are
`Filter.EventuallyEq` to a measurable set with respect to a given `CountableInterFilter` on `α`
and `MeasurableSpace` on `α`.
* `EventuallyMeasurableSet`: A `Prop` for sets which are measurable with respect to some
`eventuallyMeasurableSpace`.
* `EventuallyMeasurable`: A `Prop` for functions which are measurable with respect to some
`eventuallyMeasurableSpace` on the domain.
-/
open Filter Set MeasurableSpace
variable {α : Type*} (m : MeasurableSpace α) {s t : Set α}
/-- The `MeasurableSpace` of sets which are measurable with respect to a given σ-algebra `m`
on `α`, modulo a given σ-filter `l` on `α`. -/
def eventuallyMeasurableSpace (l : Filter α) [CountableInterFilter l] : MeasurableSpace α where
MeasurableSet' s := ∃ t, MeasurableSet t ∧ s =ᶠ[l] t
measurableSet_empty := ⟨∅, MeasurableSet.empty, EventuallyEq.refl _ _ ⟩
measurableSet_compl := fun _ ⟨t, ht, hts⟩ => ⟨tᶜ, ht.compl, hts.compl⟩
measurableSet_iUnion s hs := by
choose t ht hts using hs
exact ⟨⋃ i, t i, MeasurableSet.iUnion ht, EventuallyEq.countable_iUnion hts⟩
@[deprecated (since := "2025-06-21")] alias EventuallyMeasurableSpace := eventuallyMeasurableSpace
/-- We say a set `s` is an `EventuallyMeasurableSet` with respect to a given
σ-algebra `m` and σ-filter `l` if it differs from a set in `m` by a set in
the dual ideal of `l`. -/
def EventuallyMeasurableSet (l : Filter α) [CountableInterFilter l] (s : Set α) : Prop :=
@MeasurableSet _ (eventuallyMeasurableSpace m l) s
variable {l : Filter α} [CountableInterFilter l]
variable {m}
theorem MeasurableSet.eventuallyMeasurableSet (hs : MeasurableSet s) :
EventuallyMeasurableSet m l s :=
⟨s, hs, EventuallyEq.refl _ _⟩
theorem le_eventuallyMeasurableSpace : m ≤ eventuallyMeasurableSpace m l :=
fun _ hs => hs.eventuallyMeasurableSet
@[deprecated (since := "2025-06-21")] alias EventuallyMeasurableSpace.measurable_le :=
le_eventuallyMeasurableSpace
theorem eventuallyMeasurableSet_of_mem_filter (hs : s ∈ l) : EventuallyMeasurableSet m l s :=
⟨univ, MeasurableSet.univ, eventuallyEq_univ.mpr hs⟩
/-- A set which is `EventuallyEq` to an `EventuallyMeasurableSet`
is an `EventuallyMeasurableSet`. -/
theorem EventuallyMeasurableSet.congr
(ht : EventuallyMeasurableSet m l t) (hst : s =ᶠ[l] t) : EventuallyMeasurableSet m l s := by
rcases ht with ⟨t', ht', htt'⟩
exact ⟨t', ht', hst.trans htt'⟩
section instances
instance eventuallyMeasurableSingleton [MeasurableSingletonClass α] :
@MeasurableSingletonClass α (eventuallyMeasurableSpace m l) :=
@MeasurableSingletonClass.mk _ (_) <| fun x => (MeasurableSet.singleton x).eventuallyMeasurableSet
@[deprecated (since := "2025-06-21")] alias EventuallyMeasurableSpace.measurableSingleton :=
eventuallyMeasurableSingleton
end instances
section EventuallyMeasurable
open Function
variable (m l) {β γ : Type*} [MeasurableSpace β] [MeasurableSpace γ]
/-- We say a function is `EventuallyMeasurable` with respect to a given
σ-algebra `m` and σ-filter `l` if the preimage of any measurable set is equal to some
`m`-measurable set modulo `l`.
Warning: This is not always the same as being equal to some `m`-measurable function modulo `l`.
In general it is weaker. See `Measurable.eventuallyMeasurable_of_eventuallyEq`.
*TODO*: Add lemmas about when these are equivalent. -/
def EventuallyMeasurable (f : α → β) : Prop := @Measurable _ _ (eventuallyMeasurableSpace m l) _ f
variable {m l} {f g : α → β} {h : β → γ}
theorem Measurable.eventuallyMeasurable (hf : Measurable f) : EventuallyMeasurable m l f :=
hf.le le_eventuallyMeasurableSpace
theorem Measurable.comp_eventuallyMeasurable (hh : Measurable h) (hf : EventuallyMeasurable m l f) :
EventuallyMeasurable m l (h ∘ f) :=
hh.comp hf
/-- A function which is `EventuallyEq` to some `EventuallyMeasurable` function
is `EventuallyMeasurable`. -/
theorem EventuallyMeasurable.congr
(hf : EventuallyMeasurable m l f) (hgf : g =ᶠ[l] f) : EventuallyMeasurable m l g :=
fun _ hs => EventuallyMeasurableSet.congr (hf hs)
(hgf.preimage _)
/-- A function which is `EventuallyEq` to some `Measurable` function is `EventuallyMeasurable`. -/
theorem Measurable.eventuallyMeasurable_of_eventuallyEq
(hf : Measurable f) (hgf : g =ᶠ[l] f) : EventuallyMeasurable m l g :=
hf.eventuallyMeasurable.congr hgf
end EventuallyMeasurable |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Pi.lean | import Mathlib.MeasureTheory.MeasurableSpace.Constructions
import Mathlib.MeasureTheory.PiSystem
/-!
# Bases of the indexed product σ-algebra
In this file we prove several versions of the following lemma:
given a finite indexed collection of measurable spaces `α i`,
if the σ-algebra on each `α i` is generated by `C i`,
then the sets `{x | ∀ i, x i ∈ s i}`, where `s i ∈ C i`,
generate the σ-algebra on the indexed product of `α i`s.
-/
noncomputable section
open Function Set MeasurableSpace Encodable
variable {ι : Type*} {α : ι → Type*}
/-! We start with some measurability properties -/
lemma MeasurableSpace.pi_eq_generateFrom_projections {mα : ∀ i, MeasurableSpace (α i)} :
pi = generateFrom {B | ∃ (i : ι) (A : Set (α i)), MeasurableSet A ∧ eval i ⁻¹' A = B} := by
simp only [pi, ← generateFrom_iUnion_measurableSet, iUnion_setOf, measurableSet_comap]
/-- Boxes formed by π-systems form a π-system. -/
theorem IsPiSystem.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsPiSystem (C i)) :
IsPiSystem (pi univ '' pi univ C) := by
rintro _ ⟨s₁, hs₁, rfl⟩ _ ⟨s₂, hs₂, rfl⟩ hst
rw [← pi_inter_distrib] at hst ⊢; rw [univ_pi_nonempty_iff] at hst
exact mem_image_of_mem _ fun i _ => hC i _ (hs₁ i (mem_univ i)) _ (hs₂ i (mem_univ i)) (hst i)
/-- Boxes form a π-system. -/
theorem isPiSystem_pi [∀ i, MeasurableSpace (α i)] :
IsPiSystem (pi univ '' pi univ fun i => { s : Set (α i) | MeasurableSet s }) :=
IsPiSystem.pi fun _ => isPiSystem_measurableSet
section Finite
variable [Finite ι]
/-- Boxes of countably spanning sets are countably spanning. -/
theorem IsCountablySpanning.pi {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) :
IsCountablySpanning (pi univ '' pi univ C) := by
choose s h1s h2s using hC
cases nonempty_encodable (ι → ℕ)
let e : ℕ → ι → ℕ := fun n => (@decode (ι → ℕ) _ n).iget
refine ⟨fun n => Set.pi univ fun i => s i (e n i), fun n =>
mem_image_of_mem _ fun i _ => h1s i _, ?_⟩
simp_rw
[e, (surjective_decode_iget (ι → ℕ)).iUnion_comp fun x => Set.pi univ fun i => s i (x i),
iUnion_univ_pi s, h2s, pi_univ]
/-- The product of generated σ-algebras is the one generated by boxes, if both generating sets
are countably spanning. -/
theorem generateFrom_pi_eq {C : ∀ i, Set (Set (α i))} (hC : ∀ i, IsCountablySpanning (C i)) :
(@MeasurableSpace.pi _ _ fun i => generateFrom (C i)) =
generateFrom (pi univ '' pi univ C) := by
classical
cases nonempty_encodable ι
apply le_antisymm
· refine iSup_le ?_; intro i; rw [comap_generateFrom]
apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩
choose t h1t h2t using hC
simp_rw [eval_preimage, ← h2t]
rw [← @iUnion_const _ ℕ _ s]
have : Set.pi univ (update (fun i' : ι => iUnion (t i')) i (⋃ _ : ℕ, s)) =
Set.pi univ fun k => ⋃ j : ℕ,
@update ι (fun i' => Set (α i')) _ (fun i' => t i' j) i s k := by
ext; simp_rw [mem_univ_pi]; apply forall_congr'; intro i'
by_cases h : i' = i
· subst h; simp
· simp [h]
rw [this, ← iUnion_univ_pi]
apply MeasurableSet.iUnion
intro n; apply measurableSet_generateFrom
apply mem_image_of_mem; intro j _; dsimp only
by_cases h : j = i
· subst h; rwa [update_self]
· rw [update_of_ne h]; apply h1t
· apply generateFrom_le; rintro _ ⟨s, hs, rfl⟩
rw [univ_pi_eq_iInter]; apply MeasurableSet.iInter; intro i
apply @measurable_pi_apply _ _ (fun i => generateFrom (C i))
exact measurableSet_generateFrom (hs i (mem_univ i))
/-- If `C` and `D` generate the σ-algebras on `α` resp. `β`, then rectangles formed by `C` and `D`
generate the σ-algebra on `α × β`. -/
theorem generateFrom_eq_pi [h : ∀ i, MeasurableSpace (α i)] {C : ∀ i, Set (Set (α i))}
(hC : ∀ i, generateFrom (C i) = h i) (h2C : ∀ i, IsCountablySpanning (C i)) :
generateFrom (pi univ '' pi univ C) = MeasurableSpace.pi := by
simp only [← funext hC, generateFrom_pi_eq h2C]
/-- The product σ-algebra is generated from boxes, i.e. `s ×ˢ t` for sets `s : set α` and
`t : set β`. -/
theorem generateFrom_pi [∀ i, MeasurableSpace (α i)] :
generateFrom (pi univ '' pi univ fun i => { s : Set (α i) | MeasurableSet s }) =
MeasurableSpace.pi :=
generateFrom_eq_pi (fun _ => generateFrom_measurableSet) fun _ =>
isCountablySpanning_measurableSet
end Finite |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Basic.lean | import Mathlib.Algebra.Notation.Indicator
import Mathlib.Data.Int.Cast.Pi
import Mathlib.Data.Nat.Cast.Basic
import Mathlib.MeasureTheory.MeasurableSpace.Defs
/-!
# Measurable spaces and measurable functions
This file provides properties of measurable spaces and the functions and isomorphisms between them.
The definition of a measurable space is in `Mathlib/MeasureTheory/MeasurableSpace/Defs.lean`.
A measurable space is a set equipped with a σ-algebra, a collection of subsets closed under
complementation and countable union. A function between measurable spaces is measurable if
the preimage of each measurable subset is measurable.
σ-algebras on a fixed set `α` form a complete lattice. Here we order σ-algebras by writing `m₁ ≤ m₂`
if every set which is `m₁`-measurable is also `m₂`-measurable (that is, `m₁` is a subset of `m₂`).
In particular, any collection of subsets of `α` generates a smallest σ-algebra which contains
all of them. A function `f : α → β` induces a Galois connection between the lattices of σ-algebras
on `α` and `β`.
## Implementation notes
Measurability of a function `f : α → β` between measurable spaces is defined in terms of the
Galois connection induced by `f`.
## References
* <https://en.wikipedia.org/wiki/Measurable_space>
* <https://en.wikipedia.org/wiki/Sigma-algebra>
* <https://en.wikipedia.org/wiki/Dynkin_system>
## Tags
measurable space, σ-algebra, measurable function, dynkin system, π-λ theorem, π-system
-/
open Set MeasureTheory
universe uι
variable {α β γ : Type*} {ι : Sort uι} {s : Set α}
namespace MeasurableSpace
section Functors
variable {m m₁ m₂ : MeasurableSpace α} {m' : MeasurableSpace β} {f : α → β} {g : β → α}
/-- The forward image of a measurable space under a function. `map f m` contains the sets
`s : Set β` whose preimage under `f` is measurable. -/
protected def map (f : α → β) (m : MeasurableSpace α) : MeasurableSpace β where
MeasurableSet' s := MeasurableSet[m] <| f ⁻¹' s
measurableSet_empty := m.measurableSet_empty
measurableSet_compl _ hs := m.measurableSet_compl _ hs
measurableSet_iUnion f hf := by simpa only [preimage_iUnion] using m.measurableSet_iUnion _ hf
lemma map_def {s : Set β} : MeasurableSet[m.map f] s ↔ MeasurableSet[m] (f ⁻¹' s) := Iff.rfl
@[simp]
theorem map_id : m.map id = m :=
MeasurableSpace.ext fun _ => Iff.rfl
@[simp]
theorem map_comp {f : α → β} {g : β → γ} : (m.map f).map g = m.map (g ∘ f) :=
MeasurableSpace.ext fun _ => Iff.rfl
/-- The reverse image of a measurable space under a function. `comap f m` contains the sets
`s : Set α` such that `s` is the `f`-preimage of a measurable set in `β`. -/
protected def comap (f : α → β) (m : MeasurableSpace β) : MeasurableSpace α where
MeasurableSet' s := ∃ s', MeasurableSet[m] s' ∧ f ⁻¹' s' = s
measurableSet_empty := ⟨∅, m.measurableSet_empty, rfl⟩
measurableSet_compl := fun _ ⟨s', h₁, h₂⟩ => ⟨s'ᶜ, m.measurableSet_compl _ h₁, h₂ ▸ rfl⟩
measurableSet_iUnion s hs :=
let ⟨s', hs'⟩ := Classical.axiom_of_choice hs
⟨⋃ i, s' i, m.measurableSet_iUnion _ fun i => (hs' i).left, by simp [hs']⟩
lemma measurableSet_comap {m : MeasurableSpace β} :
MeasurableSet[m.comap f] s ↔ ∃ s', MeasurableSet[m] s' ∧ f ⁻¹' s' = s := .rfl
theorem comap_eq_generateFrom (m : MeasurableSpace β) (f : α → β) :
m.comap f = generateFrom { t | ∃ s, MeasurableSet s ∧ f ⁻¹' s = t } :=
(@generateFrom_measurableSet _ (.comap f m)).symm
@[simp]
theorem comap_id : m.comap id = m :=
MeasurableSpace.ext fun s => ⟨fun ⟨_, hs', h⟩ => h ▸ hs', fun h => ⟨s, h, rfl⟩⟩
@[simp]
theorem comap_comp {f : β → α} {g : γ → β} : (m.comap f).comap g = m.comap (f ∘ g) :=
MeasurableSpace.ext fun _ =>
⟨fun ⟨_, ⟨u, h, hu⟩, ht⟩ => ⟨u, h, ht ▸ hu ▸ rfl⟩, fun ⟨t, h, ht⟩ => ⟨f ⁻¹' t, ⟨_, h, rfl⟩, ht⟩⟩
theorem comap_le_iff_le_map {f : α → β} : m'.comap f ≤ m ↔ m' ≤ m.map f :=
⟨fun h _s hs => h _ ⟨_, hs, rfl⟩, fun h _s ⟨_t, ht, heq⟩ => heq ▸ h _ ht⟩
theorem gc_comap_map (f : α → β) :
GaloisConnection (MeasurableSpace.comap f) (MeasurableSpace.map f) := fun _ _ =>
comap_le_iff_le_map
theorem map_mono (h : m₁ ≤ m₂) : m₁.map f ≤ m₂.map f :=
(gc_comap_map f).monotone_u h
theorem monotone_map : Monotone (MeasurableSpace.map f) := fun _ _ => map_mono
theorem comap_mono (h : m₁ ≤ m₂) : m₁.comap g ≤ m₂.comap g :=
(gc_comap_map g).monotone_l h
theorem monotone_comap : Monotone (MeasurableSpace.comap g) := fun _ _ h => comap_mono h
@[simp]
theorem comap_bot : (⊥ : MeasurableSpace α).comap g = ⊥ :=
(gc_comap_map g).l_bot
@[simp]
theorem comap_sup : (m₁ ⊔ m₂).comap g = m₁.comap g ⊔ m₂.comap g :=
(gc_comap_map g).l_sup
@[simp]
theorem comap_iSup {m : ι → MeasurableSpace α} : (⨆ i, m i).comap g = ⨆ i, (m i).comap g :=
(gc_comap_map g).l_iSup
@[simp]
theorem map_top : (⊤ : MeasurableSpace α).map f = ⊤ :=
(gc_comap_map f).u_top
@[simp]
theorem map_inf : (m₁ ⊓ m₂).map f = m₁.map f ⊓ m₂.map f :=
(gc_comap_map f).u_inf
@[simp]
theorem map_iInf {m : ι → MeasurableSpace α} : (⨅ i, m i).map f = ⨅ i, (m i).map f :=
(gc_comap_map f).u_iInf
theorem comap_map_le : (m.map f).comap f ≤ m :=
(gc_comap_map f).l_u_le _
theorem le_map_comap : m ≤ (m.comap g).map g :=
(gc_comap_map g).le_u_l _
end Functors
@[simp] theorem map_const {m} (b : β) : MeasurableSpace.map (fun _a : α ↦ b) m = ⊤ :=
eq_top_iff.2 <| fun s _ ↦ by rw [map_def]; by_cases h : b ∈ s <;> simp [h]
@[simp] theorem comap_const {m} (b : β) : MeasurableSpace.comap (fun _a : α => b) m = ⊥ :=
eq_bot_iff.2 <| by rintro _ ⟨s, -, rfl⟩; by_cases b ∈ s <;> simp [*]
theorem comap_generateFrom {f : α → β} {s : Set (Set β)} :
(generateFrom s).comap f = generateFrom (preimage f '' s) :=
le_antisymm
(comap_le_iff_le_map.2 <|
generateFrom_le fun _t hts => GenerateMeasurable.basic _ <| mem_image_of_mem _ <| hts)
(generateFrom_le fun _t ⟨u, hu, Eq⟩ => Eq ▸ ⟨u, GenerateMeasurable.basic _ hu, rfl⟩)
end MeasurableSpace
section MeasurableFunctions
open MeasurableSpace
theorem measurable_iff_le_map {m₁ : MeasurableSpace α} {m₂ : MeasurableSpace β} {f : α → β} :
Measurable f ↔ m₂ ≤ m₁.map f :=
Iff.rfl
alias ⟨Measurable.le_map, Measurable.of_le_map⟩ := measurable_iff_le_map
theorem measurable_iff_comap_le {m₁ : MeasurableSpace α} {m₂ : MeasurableSpace β} {f : α → β} :
Measurable f ↔ m₂.comap f ≤ m₁ :=
comap_le_iff_le_map.symm
alias ⟨Measurable.comap_le, Measurable.of_comap_le⟩ := measurable_iff_comap_le
theorem comap_measurable {m : MeasurableSpace β} (f : α → β) : Measurable[m.comap f] f :=
fun s hs => ⟨s, hs, rfl⟩
lemma measurable_comap_iff {mα : MeasurableSpace α} {mγ : MeasurableSpace γ}
{f : α → β} {g : β → γ} : Measurable[mα, mγ.comap g] f ↔ Measurable (g ∘ f) := by
simp [measurable_iff_comap_le]
theorem Measurable.mono {ma ma' : MeasurableSpace α} {mb mb' : MeasurableSpace β} {f : α → β}
(hf : @Measurable α β ma mb f) (ha : ma ≤ ma') (hb : mb' ≤ mb) : @Measurable α β ma' mb' f :=
fun _t ht => ha _ <| hf <| hb _ ht
lemma Measurable.iSup' {mα : ι → MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β} (i₀ : ι)
(h : Measurable[mα i₀] f) :
Measurable[⨆ i, mα i] f :=
h.mono (le_iSup mα i₀) le_rfl
lemma Measurable.sup_of_left {mα mα' : MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β}
(h : Measurable[mα] f) :
Measurable[mα ⊔ mα'] f :=
h.mono le_sup_left le_rfl
lemma Measurable.sup_of_right {mα mα' : MeasurableSpace α} {_ : MeasurableSpace β} {f : α → β}
(h : Measurable[mα'] f) :
Measurable[mα ⊔ mα'] f :=
h.mono le_sup_right le_rfl
theorem measurable_id'' {m mα : MeasurableSpace α} (hm : m ≤ mα) : @Measurable α α mα m id :=
measurable_id.mono le_rfl hm
@[measurability]
theorem measurable_from_top [MeasurableSpace β] {f : α → β} : Measurable[⊤] f := fun _ _ => trivial
theorem measurable_generateFrom [MeasurableSpace α] {s : Set (Set β)} {f : α → β}
(h : ∀ t ∈ s, MeasurableSet (f ⁻¹' t)) : @Measurable _ _ _ (generateFrom s) f :=
Measurable.of_le_map <| generateFrom_le h
variable {f g : α → β}
section TypeclassMeasurableSpace
variable [MeasurableSpace α] [MeasurableSpace β]
@[nontriviality, measurability]
theorem Subsingleton.measurable [Subsingleton α] : Measurable f := fun _ _ =>
@Subsingleton.measurableSet α _ _ _
@[nontriviality, measurability]
theorem measurable_of_subsingleton_codomain [Subsingleton β] (f : α → β) : Measurable f :=
fun s _ => Subsingleton.set_cases MeasurableSet.empty MeasurableSet.univ s
@[to_additive (attr := measurability, fun_prop)]
theorem measurable_one [One α] : Measurable (1 : β → α) :=
@measurable_const _ _ _ _ 1
theorem measurable_of_empty [IsEmpty α] (f : α → β) : Measurable f :=
Subsingleton.measurable
theorem measurable_of_empty_codomain [IsEmpty β] (f : α → β) : Measurable f :=
measurable_of_subsingleton_codomain f
/-- A version of `measurable_const` that assumes `f x = f y` for all `x, y`. This version works
for functions between empty types. -/
theorem measurable_const' {f : β → α} (hf : ∀ x y, f x = f y) : Measurable f := by
nontriviality β
inhabit β
convert @measurable_const α β _ _ (f default) using 2
apply hf
@[measurability]
theorem measurable_natCast [NatCast α] (n : ℕ) : Measurable (n : β → α) :=
@measurable_const α _ _ _ n
@[measurability]
theorem measurable_intCast [IntCast α] (n : ℤ) : Measurable (n : β → α) :=
@measurable_const α _ _ _ n
theorem measurable_of_countable [Countable α] [MeasurableSingletonClass α] (f : α → β) :
Measurable f := fun s _ =>
(f ⁻¹' s).to_countable.measurableSet
theorem measurable_of_finite [Finite α] [MeasurableSingletonClass α] (f : α → β) : Measurable f :=
measurable_of_countable f
end TypeclassMeasurableSpace
variable {m : MeasurableSpace α}
@[measurability]
theorem Measurable.iterate {f : α → α} (hf : Measurable f) : ∀ n, Measurable f^[n]
| 0 => measurable_id
| n + 1 => (Measurable.iterate hf n).comp hf
variable {mβ : MeasurableSpace β}
@[measurability]
theorem measurableSet_preimage {t : Set β} (hf : Measurable f) (ht : MeasurableSet t) :
MeasurableSet (f ⁻¹' t) :=
hf ht
protected theorem MeasurableSet.preimage {t : Set β} (ht : MeasurableSet t) (hf : Measurable f) :
MeasurableSet (f ⁻¹' t) :=
hf ht
@[measurability, fun_prop]
protected theorem Measurable.piecewise {_ : DecidablePred (· ∈ s)} (hs : MeasurableSet s)
(hf : Measurable f) (hg : Measurable g) : Measurable (piecewise s f g) := by
intro t ht
rw [piecewise_preimage]
exact hs.ite (hf ht) (hg ht)
/-- This is slightly different from `Measurable.piecewise`. It can be used to show
`Measurable (ite (x=0) 0 1)` by
`exact Measurable.ite (measurableSet_singleton 0) measurable_const measurable_const`,
but replacing `Measurable.ite` by `Measurable.piecewise` in that example proof does not work. -/
theorem Measurable.ite {p : α → Prop} {_ : DecidablePred p} (hp : MeasurableSet { a : α | p a })
(hf : Measurable f) (hg : Measurable g) : Measurable fun x => ite (p x) (f x) (g x) :=
Measurable.piecewise hp hf hg
@[measurability, fun_prop]
theorem Measurable.indicator [Zero β] (hf : Measurable f) (hs : MeasurableSet s) :
Measurable (s.indicator f) :=
hf.piecewise hs measurable_const
/-- The measurability of a set `A` is equivalent to the measurability of the indicator function
which takes a constant value `b ≠ 0` on a set `A` and `0` elsewhere. -/
lemma measurable_indicator_const_iff [Zero β] [MeasurableSingletonClass β] (b : β) [NeZero b] :
Measurable (s.indicator (fun (_ : α) ↦ b)) ↔ MeasurableSet s := by
constructor <;> intro h
· convert h (MeasurableSet.singleton (0 : β)).compl
ext a
simp [NeZero.ne b]
· exact measurable_const.indicator h
@[to_additive (attr := measurability)]
theorem measurableSet_mulSupport [One β] [MeasurableSingletonClass β] (hf : Measurable f) :
MeasurableSet (Function.mulSupport f) :=
hf (measurableSet_singleton 1).compl
/-- If a function coincides with a measurable function outside of a countable set, it is
measurable. -/
theorem Measurable.measurable_of_countable_ne [MeasurableSingletonClass α] (hf : Measurable f)
(h : Set.Countable { x | f x ≠ g x }) : Measurable g := by
intro t ht
have : g ⁻¹' t = g ⁻¹' t ∩ { x | f x = g x }ᶜ ∪ g ⁻¹' t ∩ { x | f x = g x } := by
simp [← inter_union_distrib_left]
rw [this]
refine (h.mono inter_subset_right).measurableSet.union ?_
have : g ⁻¹' t ∩ { x : α | f x = g x } = f ⁻¹' t ∩ { x : α | f x = g x } := by
ext x
simp +contextual
rw [this]
exact (hf ht).inter h.measurableSet.of_compl
end MeasurableFunctions
/-- We say that a collection of sets is countably spanning if a countable subset spans the
whole type. This is a useful condition in various parts of measure theory. For example, it is
a needed condition to show that the product of two collections generate the product sigma algebra,
see `generateFrom_prod_eq`. -/
def IsCountablySpanning (C : Set (Set α)) : Prop :=
∃ s : ℕ → Set α, (∀ n, s n ∈ C) ∧ ⋃ n, s n = univ
theorem isCountablySpanning_measurableSet [MeasurableSpace α] :
IsCountablySpanning { s : Set α | MeasurableSet s } :=
⟨fun _ => univ, fun _ => MeasurableSet.univ, iUnion_const _⟩
/-- Rectangles of countably spanning sets are countably spanning. -/
lemma IsCountablySpanning.prod {C : Set (Set α)} {D : Set (Set β)} (hC : IsCountablySpanning C)
(hD : IsCountablySpanning D) : IsCountablySpanning (image2 (· ×ˢ ·) C D) := by
rcases hC, hD with ⟨⟨s, h1s, h2s⟩, t, h1t, h2t⟩
refine ⟨fun n => s n.unpair.1 ×ˢ t n.unpair.2, fun n => mem_image2_of_mem (h1s _) (h1t _), ?_⟩
rw [iUnion_unpair_prod, h2s, h2t, univ_prod_univ] |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Constructions.lean | import Mathlib.Data.Finset.Update
import Mathlib.Data.Prod.TProd
import Mathlib.Data.Set.UnionLift
import Mathlib.GroupTheory.Coset.Defs
import Mathlib.MeasureTheory.MeasurableSpace.Basic
import Mathlib.MeasureTheory.MeasurableSpace.Instances
import Mathlib.Order.Disjointed
/-!
# Constructions for measurable spaces and functions
This file provides several ways to construct new measurable spaces and functions from old ones:
`Quotient`, `Subtype`, `Prod`, `Pi`, etc.
-/
assert_not_exists Filter
open Set Function
universe uι
variable {α β γ δ δ' : Type*} {ι : Sort uι} {s : Set α}
theorem measurable_to_countable [MeasurableSpace α] [Countable α] [MeasurableSpace β] {f : β → α}
(h : ∀ y, MeasurableSet (f ⁻¹' {f y})) : Measurable f := fun s _ => by
rw [← biUnion_preimage_singleton]
refine MeasurableSet.iUnion fun y => MeasurableSet.iUnion fun hy => ?_
by_cases hyf : y ∈ range f
· rcases hyf with ⟨y, rfl⟩
apply h
· simp only [preimage_singleton_eq_empty.2 hyf, MeasurableSet.empty]
theorem measurable_to_countable' [MeasurableSpace α] [Countable α] [MeasurableSpace β] {f : β → α}
(h : ∀ x, MeasurableSet (f ⁻¹' {x})) : Measurable f :=
measurable_to_countable fun y => h (f y)
theorem ENat.measurable_iff {α : Type*} [MeasurableSpace α] {f : α → ℕ∞} :
Measurable f ↔ ∀ n : ℕ, MeasurableSet (f ⁻¹' {↑n}) := by
refine ⟨fun hf n ↦ hf <| measurableSet_singleton _, fun h ↦ measurable_to_countable' fun n ↦ ?_⟩
cases n with
| top =>
rw [← WithTop.none_eq_top, ← compl_range_some, preimage_compl, ← iUnion_singleton_eq_range,
preimage_iUnion]
exact .compl <| .iUnion h
| coe n => exact h n
@[measurability]
theorem measurable_unit [MeasurableSpace α] (f : Unit → α) : Measurable f :=
measurable_from_top
section ULift
variable [MeasurableSpace α]
instance _root_.ULift.instMeasurableSpace : MeasurableSpace (ULift α) :=
‹MeasurableSpace α›.map ULift.up
lemma measurable_down : Measurable (ULift.down : ULift α → α) := fun _ ↦ id
lemma measurable_up : Measurable (ULift.up : α → ULift α) := fun _ ↦ id
@[simp] lemma measurableSet_preimage_down {s : Set α} :
MeasurableSet (ULift.down ⁻¹' s) ↔ MeasurableSet s := Iff.rfl
@[simp] lemma measurableSet_preimage_up {s : Set (ULift α)} :
MeasurableSet (ULift.up ⁻¹' s) ↔ MeasurableSet s := Iff.rfl
end ULift
section Nat
variable {mα : MeasurableSpace α}
@[measurability]
theorem measurable_from_nat {f : ℕ → α} : Measurable f :=
measurable_from_top
theorem measurable_to_nat {f : α → ℕ} : (∀ y, MeasurableSet (f ⁻¹' {f y})) → Measurable f :=
measurable_to_countable
theorem measurable_to_bool {f : α → Bool} (h : MeasurableSet (f ⁻¹' {true})) : Measurable f := by
apply measurable_to_countable'
rintro (- | -)
· convert h.compl
rw [← preimage_compl, Bool.compl_singleton, Bool.not_true]
exact h
theorem measurable_to_prop {f : α → Prop} (h : MeasurableSet (f ⁻¹' {True})) : Measurable f := by
refine measurable_to_countable' fun x => ?_
by_cases hx : x
· simpa [hx] using h
· simpa only [hx, ← preimage_compl, Prop.compl_singleton, not_true, preimage_singleton_false]
using h.compl
theorem measurable_findGreatest' {p : α → ℕ → Prop} [∀ x, DecidablePred (p x)] {N : ℕ}
(hN : ∀ k ≤ N, MeasurableSet { x | Nat.findGreatest (p x) N = k }) :
Measurable fun x => Nat.findGreatest (p x) N :=
measurable_to_nat fun _ => hN _ N.findGreatest_le
theorem measurable_findGreatest {p : α → ℕ → Prop} [∀ x, DecidablePred (p x)] {N}
(hN : ∀ k ≤ N, MeasurableSet { x | p x k }) : Measurable fun x => Nat.findGreatest (p x) N := by
refine measurable_findGreatest' fun k hk => ?_
simp only [Nat.findGreatest_eq_iff, setOf_and, setOf_forall, ← compl_setOf]
repeat' apply_rules [MeasurableSet.inter, MeasurableSet.const, MeasurableSet.iInter,
MeasurableSet.compl, hN] <;> try intros
@[simp, measurability]
protected theorem MeasurableSet.disjointed {f : ℕ → Set α} (h : ∀ i, MeasurableSet (f i)) (n) :
MeasurableSet (disjointed f n) :=
disjointedRec (fun _ _ ht => MeasurableSet.diff ht <| h _) (h n)
theorem measurable_find {p : α → ℕ → Prop} [∀ x, DecidablePred (p x)] (hp : ∀ x, ∃ N, p x N)
(hm : ∀ k, MeasurableSet { x | p x k }) : Measurable fun x => Nat.find (hp x) := by
refine measurable_to_nat fun x => ?_
rw [preimage_find_eq_disjointed (fun k => {x | p x k})]
exact MeasurableSet.disjointed hm _
end Nat
section Quotient
variable [MeasurableSpace α] [MeasurableSpace β]
instance Quot.instMeasurableSpace {α} {r : α → α → Prop} [m : MeasurableSpace α] :
MeasurableSpace (Quot r) :=
m.map (Quot.mk r)
instance Quotient.instMeasurableSpace {α} {s : Setoid α} [m : MeasurableSpace α] :
MeasurableSpace (Quotient s) :=
m.map Quotient.mk''
@[to_additive]
instance QuotientGroup.measurableSpace {G} [Group G] [MeasurableSpace G] (S : Subgroup G) :
MeasurableSpace (G ⧸ S) :=
Quotient.instMeasurableSpace
theorem measurableSet_quotient {s : Setoid α} {t : Set (Quotient s)} :
MeasurableSet t ↔ MeasurableSet (Quotient.mk'' ⁻¹' t) :=
Iff.rfl
theorem measurable_from_quotient {s : Setoid α} {f : Quotient s → β} :
Measurable f ↔ Measurable (f ∘ Quotient.mk'') :=
Iff.rfl
@[measurability]
theorem measurable_quotient_mk' [s : Setoid α] : Measurable (Quotient.mk' : α → Quotient s) :=
fun _ => id
@[measurability]
theorem measurable_quotient_mk'' {s : Setoid α} : Measurable (Quotient.mk'' : α → Quotient s) :=
fun _ => id
@[measurability]
theorem measurable_quot_mk {r : α → α → Prop} : Measurable (Quot.mk r) := fun _ => id
@[to_additive (attr := measurability)]
theorem QuotientGroup.measurable_coe {G} [Group G] [MeasurableSpace G] {S : Subgroup G} :
Measurable ((↑) : G → G ⧸ S) :=
measurable_quotient_mk''
@[to_additive]
nonrec theorem QuotientGroup.measurable_from_quotient {G} [Group G] [MeasurableSpace G]
{S : Subgroup G} {f : G ⧸ S → α} : Measurable f ↔ Measurable (f ∘ ((↑) : G → G ⧸ S)) :=
measurable_from_quotient
instance Quotient.instDiscreteMeasurableSpace {α} {s : Setoid α} [MeasurableSpace α]
[DiscreteMeasurableSpace α] : DiscreteMeasurableSpace (Quotient s) where
forall_measurableSet _ := measurableSet_quotient.2 .of_discrete
@[to_additive]
instance QuotientGroup.instDiscreteMeasurableSpace {G} [Group G] [MeasurableSpace G]
[DiscreteMeasurableSpace G] (S : Subgroup G) : DiscreteMeasurableSpace (G ⧸ S) :=
Quotient.instDiscreteMeasurableSpace
end Quotient
section Subtype
instance Subtype.instMeasurableSpace {α} {p : α → Prop} [m : MeasurableSpace α] :
MeasurableSpace (Subtype p) :=
m.comap ((↑) : _ → α)
section
variable [MeasurableSpace α]
@[measurability]
theorem measurable_subtype_coe {p : α → Prop} : Measurable ((↑) : Subtype p → α) :=
MeasurableSpace.le_map_comap
instance Subtype.instMeasurableSingletonClass {p : α → Prop} [MeasurableSingletonClass α] :
MeasurableSingletonClass (Subtype p) where
measurableSet_singleton x :=
⟨{(x : α)}, measurableSet_singleton (x : α), by
rw [← image_singleton, preimage_image_eq _ Subtype.val_injective]⟩
end
variable {m : MeasurableSpace α} {mβ : MeasurableSpace β}
theorem MeasurableSet.of_subtype_image {s : Set α} {t : Set s}
(h : MeasurableSet (Subtype.val '' t)) : MeasurableSet t :=
⟨_, h, preimage_image_eq _ Subtype.val_injective⟩
theorem MeasurableSet.subtype_image {s : Set α} {t : Set s} (hs : MeasurableSet s) :
MeasurableSet t → MeasurableSet (((↑) : s → α) '' t) := by
rintro ⟨u, hu, rfl⟩
rw [Subtype.image_preimage_coe]
exact hs.inter hu
@[measurability]
theorem Measurable.subtype_coe {p : β → Prop} {f : α → Subtype p} (hf : Measurable f) :
Measurable fun a : α => (f a : β) :=
measurable_subtype_coe.comp hf
alias Measurable.subtype_val := Measurable.subtype_coe
@[measurability]
theorem Measurable.subtype_mk {p : β → Prop} {f : α → β} (hf : Measurable f) {h : ∀ x, p (f x)} :
Measurable fun x => (⟨f x, h x⟩ : Subtype p) := fun t ⟨s, hs⟩ =>
hs.2 ▸ by simp only [← preimage_comp, Function.comp_def, hf hs.1]
@[measurability]
protected theorem Measurable.rangeFactorization {f : α → β} (hf : Measurable f) :
Measurable (rangeFactorization f) :=
hf.subtype_mk
theorem Measurable.subtype_map {f : α → β} {p : α → Prop} {q : β → Prop} (hf : Measurable f)
(hpq : ∀ x, p x → q (f x)) : Measurable (Subtype.map f hpq) :=
(hf.comp measurable_subtype_coe).subtype_mk
theorem measurable_inclusion {s t : Set α} (h : s ⊆ t) : Measurable (inclusion h) :=
measurable_id.subtype_map h
theorem MeasurableSet.image_inclusion' {s t : Set α} (h : s ⊆ t) {u : Set s}
(hs : MeasurableSet (Subtype.val ⁻¹' s : Set t)) (hu : MeasurableSet u) :
MeasurableSet (inclusion h '' u) := by
rcases hu with ⟨u, hu, rfl⟩
convert (measurable_subtype_coe hu).inter hs
ext ⟨x, hx⟩
simpa [@and_comm _ (_ = x)] using and_comm
theorem MeasurableSet.image_inclusion {s t : Set α} (h : s ⊆ t) {u : Set s}
(hs : MeasurableSet s) (hu : MeasurableSet u) :
MeasurableSet (inclusion h '' u) :=
(measurable_subtype_coe hs).image_inclusion' h hu
theorem MeasurableSet.of_union_cover {s t u : Set α} (hs : MeasurableSet s) (ht : MeasurableSet t)
(h : univ ⊆ s ∪ t) (hsu : MeasurableSet (((↑) : s → α) ⁻¹' u))
(htu : MeasurableSet (((↑) : t → α) ⁻¹' u)) : MeasurableSet u := by
convert (hs.subtype_image hsu).union (ht.subtype_image htu)
simp [image_preimage_eq_inter_range, ← inter_union_distrib_left, univ_subset_iff.1 h]
theorem measurable_of_measurable_union_cover {f : α → β} (s t : Set α) (hs : MeasurableSet s)
(ht : MeasurableSet t) (h : univ ⊆ s ∪ t) (hc : Measurable fun a : s => f a)
(hd : Measurable fun a : t => f a) : Measurable f := fun _u hu =>
.of_union_cover hs ht h (hc hu) (hd hu)
theorem measurable_of_restrict_of_restrict_compl {f : α → β} {s : Set α} (hs : MeasurableSet s)
(h₁ : Measurable (s.restrict f)) (h₂ : Measurable (sᶜ.restrict f)) : Measurable f :=
measurable_of_measurable_union_cover s sᶜ hs hs.compl (union_compl_self s).ge h₁ h₂
theorem Measurable.dite [∀ x, Decidable (x ∈ s)] {f : s → β} (hf : Measurable f)
{g : (sᶜ : Set α) → β} (hg : Measurable g) (hs : MeasurableSet s) :
Measurable fun x => if hx : x ∈ s then f ⟨x, hx⟩ else g ⟨x, hx⟩ :=
measurable_of_restrict_of_restrict_compl hs (by simpa) (by simpa)
theorem measurable_of_measurable_on_compl_finite [MeasurableSingletonClass α] {f : α → β}
(s : Set α) (hs : s.Finite) (hf : Measurable (sᶜ.restrict f)) : Measurable f :=
have := hs.to_subtype
measurable_of_restrict_of_restrict_compl hs.measurableSet (measurable_of_finite _) hf
theorem measurable_of_measurable_on_compl_singleton [MeasurableSingletonClass α] {f : α → β} (a : α)
(hf : Measurable ({ x | x ≠ a }.restrict f)) : Measurable f :=
measurable_of_measurable_on_compl_finite {a} (finite_singleton a) hf
end Subtype
section Atoms
variable [MeasurableSpace β]
/-- The *measurable atom* of `x` is the intersection of all the measurable sets containing `x`.
It is measurable when the space is countable (or more generally when the measurable space is
countably generated). -/
def measurableAtom (x : β) : Set β :=
⋂ (s : Set β) (_h's : x ∈ s) (_hs : MeasurableSet s), s
@[simp] lemma mem_measurableAtom_self (x : β) : x ∈ measurableAtom x := by
simp +contextual [measurableAtom]
lemma mem_of_mem_measurableAtom {x y : β} (h : y ∈ measurableAtom x) {s : Set β}
(hs : MeasurableSet s) (hxs : x ∈ s) : y ∈ s := by
simp only [measurableAtom, mem_iInter] at h
exact h s hxs hs
lemma measurableAtom_subset {s : Set β} {x : β} (hs : MeasurableSet s) (hx : x ∈ s) :
measurableAtom x ⊆ s :=
iInter₂_subset_of_subset s hx fun ⦃a⦄ ↦ (by simp [hs])
@[simp] lemma measurableAtom_of_measurableSingletonClass [MeasurableSingletonClass β] (x : β) :
measurableAtom x = {x} :=
Subset.antisymm (measurableAtom_subset (measurableSet_singleton x) rfl) (by simp)
lemma MeasurableSet.measurableAtom_of_countable [Countable β] (x : β) :
MeasurableSet (measurableAtom x) := by
have : ∀ (y : β), y ∉ measurableAtom x → ∃ s, x ∈ s ∧ MeasurableSet s ∧ y ∉ s :=
fun y hy ↦ by simpa [measurableAtom] using hy
choose! s hs using this
have : measurableAtom x = ⋂ (y ∈ (measurableAtom x)ᶜ), s y := by
apply Subset.antisymm
· intro z hz
simp only [mem_iInter, mem_compl_iff]
intro i hi
exact mem_of_mem_measurableAtom hz (hs i hi).2.1 (hs i hi).1
· apply compl_subset_compl.1
intro z hz
simp only [compl_iInter, mem_iUnion, mem_compl_iff, exists_prop]
exact ⟨z, hz, (hs z hz).2.2⟩
rw [this]
exact MeasurableSet.biInter (to_countable (measurableAtom x)ᶜ) (fun i hi ↦ (hs i hi).2.1)
/-- There is in fact equality: see `measurableAtom_eq_of_mem`. -/
lemma measurableAtom_subset_of_mem {x y : β} (hx : x ∈ measurableAtom y) :
measurableAtom x ⊆ measurableAtom y := by
intro z hz
simp only [measurableAtom, mem_iInter] at hz hx ⊢
exact fun s hys hs ↦ hz s (hx s hys hs) hs
lemma measurableAtom_eq_of_mem {x y : β} (hx : x ∈ measurableAtom y) :
measurableAtom x = measurableAtom y := by
refine subset_antisymm (measurableAtom_subset_of_mem hx) ?_
by_cases hy : y ∈ measurableAtom x
· exact measurableAtom_subset_of_mem hy
exfalso
simp only [measurableAtom, mem_iInter, not_forall] at hx hy ⊢
obtain ⟨s, hxs, hs, hys⟩ := hy
specialize hx sᶜ hys hs.compl
exact hx hxs
lemma disjoint_measurableAtom_of_notMem {x y : β} (hx : x ∉ measurableAtom y) :
Disjoint (measurableAtom x) (measurableAtom y) := by
rw [Set.disjoint_iff_inter_eq_empty]
ext z
simp only [mem_inter_iff, mem_empty_iff_false, iff_false, not_and]
intro hzx hzy
have h1 := measurableAtom_eq_of_mem hzx
have h2 := measurableAtom_eq_of_mem hzy
rw [← h2, h1] at hx
exact hx (mem_measurableAtom_self x)
end Atoms
section Prod
/-- A `MeasurableSpace` structure on the product of two measurable spaces. -/
def MeasurableSpace.prod {α β} (m₁ : MeasurableSpace α) (m₂ : MeasurableSpace β) :
MeasurableSpace (α × β) :=
m₁.comap Prod.fst ⊔ m₂.comap Prod.snd
instance Prod.instMeasurableSpace {α β} [m₁ : MeasurableSpace α] [m₂ : MeasurableSpace β] :
MeasurableSpace (α × β) :=
m₁.prod m₂
@[measurability]
theorem measurable_fst {_ : MeasurableSpace α} {_ : MeasurableSpace β} :
Measurable (Prod.fst : α × β → α) :=
Measurable.of_comap_le le_sup_left
@[measurability]
theorem measurable_snd {_ : MeasurableSpace α} {_ : MeasurableSpace β} :
Measurable (Prod.snd : α × β → β) :=
Measurable.of_comap_le le_sup_right
variable {m : MeasurableSpace α} {mβ : MeasurableSpace β} {mγ : MeasurableSpace γ}
@[fun_prop]
theorem Measurable.fst {f : α → β × γ} (hf : Measurable f) : Measurable fun a : α => (f a).1 :=
measurable_fst.comp hf
@[fun_prop]
theorem Measurable.snd {f : α → β × γ} (hf : Measurable f) : Measurable fun a : α => (f a).2 :=
measurable_snd.comp hf
@[measurability]
theorem Measurable.prod {f : α → β × γ} (hf₁ : Measurable fun a => (f a).1)
(hf₂ : Measurable fun a => (f a).2) : Measurable f :=
Measurable.of_le_map <|
sup_le
(by
rw [MeasurableSpace.comap_le_iff_le_map, MeasurableSpace.map_comp]
exact hf₁)
(by
rw [MeasurableSpace.comap_le_iff_le_map, MeasurableSpace.map_comp]
exact hf₂)
@[fun_prop]
theorem Measurable.prodMk {β γ} {_ : MeasurableSpace β} {_ : MeasurableSpace γ} {f : α → β}
{g : α → γ} (hf : Measurable f) (hg : Measurable g) : Measurable fun a : α => (f a, g a) :=
Measurable.prod hf hg
@[fun_prop]
theorem Measurable.prodMap [MeasurableSpace δ] {f : α → β} {g : γ → δ} (hf : Measurable f)
(hg : Measurable g) : Measurable (Prod.map f g) :=
(hf.comp measurable_fst).prodMk (hg.comp measurable_snd)
theorem measurable_prodMk_left {x : α} : Measurable (@Prod.mk _ β x) :=
measurable_const.prodMk measurable_id
theorem measurable_prodMk_right {y : β} : Measurable fun x : α => (x, y) :=
measurable_id.prodMk measurable_const
theorem Measurable.of_uncurry_left {f : α → β → γ} (hf : Measurable (uncurry f)) {x : α} :
Measurable (f x) :=
hf.comp measurable_prodMk_left
theorem Measurable.of_uncurry_right {f : α → β → γ} (hf : Measurable (uncurry f)) {y : β} :
Measurable fun x => f x y :=
hf.comp measurable_prodMk_right
theorem measurable_fun_prod {f : α → β × γ} :
Measurable f ↔ (Measurable fun a => (f a).1) ∧ Measurable fun a => (f a).2 :=
⟨fun hf => ⟨measurable_fst.comp hf, measurable_snd.comp hf⟩, fun h => Measurable.prod h.1 h.2⟩
@[fun_prop, measurability]
theorem measurable_swap : Measurable (Prod.swap : α × β → β × α) :=
Measurable.prod measurable_snd measurable_fst
theorem measurable_swap_iff {_ : MeasurableSpace γ} {f : α × β → γ} :
Measurable (f ∘ Prod.swap) ↔ Measurable f :=
⟨fun hf => hf.comp measurable_swap, fun hf => hf.comp measurable_swap⟩
@[measurability]
protected theorem MeasurableSet.prod {s : Set α} {t : Set β} (hs : MeasurableSet s)
(ht : MeasurableSet t) : MeasurableSet (s ×ˢ t) :=
MeasurableSet.inter (measurable_fst hs) (measurable_snd ht)
theorem measurableSet_prod_of_nonempty {s : Set α} {t : Set β} (h : (s ×ˢ t).Nonempty) :
MeasurableSet (s ×ˢ t) ↔ MeasurableSet s ∧ MeasurableSet t := by
rcases h with ⟨⟨x, y⟩, hx, hy⟩
refine ⟨fun hst => ?_, fun h => h.1.prod h.2⟩
have : MeasurableSet ((fun x => (x, y)) ⁻¹' s ×ˢ t) := measurable_prodMk_right hst
have : MeasurableSet (Prod.mk x ⁻¹' s ×ˢ t) := measurable_prodMk_left hst
simp_all
theorem measurableSet_prod {s : Set α} {t : Set β} :
MeasurableSet (s ×ˢ t) ↔ MeasurableSet s ∧ MeasurableSet t ∨ s = ∅ ∨ t = ∅ := by
rcases (s ×ˢ t).eq_empty_or_nonempty with h | h
· simp [h, prod_eq_empty_iff.mp h]
· simp [← not_nonempty_iff_eq_empty, prod_nonempty_iff.mp h, measurableSet_prod_of_nonempty h]
theorem measurableSet_swap_iff {s : Set (α × β)} :
MeasurableSet (Prod.swap ⁻¹' s) ↔ MeasurableSet s :=
⟨fun hs => measurable_swap hs, fun hs => measurable_swap hs⟩
instance Prod.instMeasurableSingletonClass
[MeasurableSingletonClass α] [MeasurableSingletonClass β] :
MeasurableSingletonClass (α × β) :=
⟨fun ⟨a, b⟩ => @singleton_prod_singleton _ _ a b ▸ .prod (.singleton a) (.singleton b)⟩
/-- See `measurable_from_prod_countable_left` for a version where we assume that singletons are
measurable instead of reasoning about `measurableAtom`. -/
theorem measurable_from_prod_countable_left' [Countable β] {f : α × β → γ}
(hf : ∀ y, Measurable fun x => f (x, y))
(h'f : ∀ y y' x, y' ∈ measurableAtom y → f (x, y') = f (x, y)) : Measurable f := fun s hs => by
have : f ⁻¹' s = ⋃ y, ((fun x => f (x, y)) ⁻¹' s) ×ˢ (measurableAtom y : Set β) := by
ext1 ⟨x, y⟩
simp only [mem_preimage, mem_iUnion, mem_prod]
refine ⟨fun h ↦ ⟨y, h, mem_measurableAtom_self y⟩, ?_⟩
rintro ⟨y', hy's, hy'⟩
rwa [h'f y' y x hy']
rw [this]
exact .iUnion (fun y ↦ (hf y hs).prod (.measurableAtom_of_countable y))
/-- See `measurable_from_prod_countable_right` for a version where we assume that singletons are
measurable instead of reasoning about `measurableAtom`. -/
lemma measurable_from_prod_countable_right' [Countable α] {f : α × β → γ}
(hf : ∀ x, Measurable fun y => f (x, y))
(h'f : ∀ x x' y, x' ∈ measurableAtom x → f (x', y) = f (x, y)) : Measurable f := by
change Measurable ((fun p ↦ f (p.2, p.1)) ∘ Prod.swap)
exact (measurable_from_prod_countable_left' hf h'f).comp measurable_swap
@[deprecated (since := "2025-08-17")]
alias measurable_from_prod_countable' := measurable_from_prod_countable_left'
/-- For the version where the first space in the product is countable,
see `measurable_from_prod_countable_right`. -/
theorem measurable_from_prod_countable_left [Countable β] [MeasurableSingletonClass β]
{f : α × β → γ} (hf : ∀ y, Measurable fun x => f (x, y)) :
Measurable f :=
measurable_from_prod_countable_left' hf (by simp +contextual)
/-- For the version where the second space in the product is countable,
see `measurable_from_prod_countable_left`. -/
lemma measurable_from_prod_countable_right [Countable α] [MeasurableSingletonClass α]
{f : α × β → γ} (hf : ∀ x, Measurable fun y => f (x, y)) : Measurable f :=
measurable_from_prod_countable_right' hf (by simp +contextual)
/-- A piecewise function on countably many pieces is measurable if all the data is measurable. -/
theorem Measurable.find {_ : MeasurableSpace α} {f : ℕ → α → β} {p : ℕ → α → Prop}
[∀ n, DecidablePred (p n)] (hf : ∀ n, Measurable (f n)) (hp : ∀ n, MeasurableSet { x | p n x })
(h : ∀ x, ∃ n, p n x) : Measurable fun x => f (Nat.find (h x)) x :=
have : Measurable fun p : α × ℕ => f p.2 p.1 := measurable_from_prod_countable_left fun n => hf n
this.comp (Measurable.prodMk measurable_id (measurable_find h hp))
/-- Let `t i` be a countable covering of a set `T` by measurable sets. Let `f i : t i → β` be a
family of functions that agree on the intersections `t i ∩ t j`. Then the function
`Set.iUnionLift t f _ _ : T → β`, defined as `f i ⟨x, hx⟩` for `hx : x ∈ t i`, is measurable. -/
theorem measurable_iUnionLift [Countable ι] {t : ι → Set α} {f : ∀ i, t i → β}
(htf : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩)
{T : Set α} (hT : T ⊆ ⋃ i, t i) (htm : ∀ i, MeasurableSet (t i)) (hfm : ∀ i, Measurable (f i)) :
Measurable (iUnionLift t f htf T hT) := fun s hs => by
rw [preimage_iUnionLift]
exact .preimage (.iUnion fun i => .image_inclusion _ (htm _) (hfm i hs)) (measurable_inclusion _)
/-- Let `t i` be a countable covering of `α` by measurable sets. Let `f i : t i → β` be a family of
functions that agree on the intersections `t i ∩ t j`. Then the function `Set.liftCover t f _ _`,
defined as `f i ⟨x, hx⟩` for `hx : x ∈ t i`, is measurable. -/
theorem measurable_liftCover [Countable ι] (t : ι → Set α) (htm : ∀ i, MeasurableSet (t i))
(f : ∀ i, t i → β) (hfm : ∀ i, Measurable (f i))
(hf : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), f i ⟨x, hxi⟩ = f j ⟨x, hxj⟩)
(htU : ⋃ i, t i = univ) :
Measurable (liftCover t f hf htU) := fun s hs => by
rw [preimage_liftCover]
exact .iUnion fun i => .subtype_image (htm i) <| hfm i hs
/-- Let `t i` be a nonempty countable family of measurable sets in `α`. Let `g i : α → β` be a
family of measurable functions such that `g i` agrees with `g j` on `t i ∩ t j`. Then there exists
a measurable function `f : α → β` that agrees with each `g i` on `t i`.
We only need the assumption `[Nonempty ι]` to prove `[Nonempty (α → β)]`. -/
theorem exists_measurable_piecewise {ι} [Countable ι] [Nonempty ι] (t : ι → Set α)
(t_meas : ∀ n, MeasurableSet (t n)) (g : ι → α → β) (hg : ∀ n, Measurable (g n))
(ht : Pairwise fun i j => EqOn (g i) (g j) (t i ∩ t j)) :
∃ f : α → β, Measurable f ∧ ∀ n, EqOn f (g n) (t n) := by
inhabit ι
set g' : (i : ι) → t i → β := fun i => g i ∘ (↑)
-- see https://github.com/leanprover-community/mathlib4/issues/2184
have ht' : ∀ (i j) (x : α) (hxi : x ∈ t i) (hxj : x ∈ t j), g' i ⟨x, hxi⟩ = g' j ⟨x, hxj⟩ := by
intro i j x hxi hxj
rcases eq_or_ne i j with rfl | hij
· rfl
· exact ht hij ⟨hxi, hxj⟩
set f : (⋃ i, t i) → β := iUnionLift t g' ht' _ Subset.rfl
have hfm : Measurable f := measurable_iUnionLift _ _ t_meas
(fun i => (hg i).comp measurable_subtype_coe)
classical
refine ⟨fun x => if hx : x ∈ ⋃ i, t i then f ⟨x, hx⟩ else g default x,
hfm.dite ((hg default).comp measurable_subtype_coe) (.iUnion t_meas), fun i x hx => ?_⟩
simp only [dif_pos (mem_iUnion.2 ⟨i, hx⟩)]
exact iUnionLift_of_mem ⟨x, mem_iUnion.2 ⟨i, hx⟩⟩ hx
end Prod
section Pi
variable {X : δ → Type*} [MeasurableSpace α]
instance MeasurableSpace.pi [m : ∀ a, MeasurableSpace (X a)] : MeasurableSpace (∀ a, X a) :=
⨆ a, (m a).comap fun b => b a
variable [∀ a, MeasurableSpace (X a)] [MeasurableSpace γ]
theorem measurable_pi_iff {g : α → ∀ a, X a} : Measurable g ↔ ∀ a, Measurable fun x => g x a := by
simp_rw [measurable_iff_comap_le, MeasurableSpace.pi, MeasurableSpace.comap_iSup,
MeasurableSpace.comap_comp, Function.comp_def, iSup_le_iff]
@[fun_prop]
theorem measurable_pi_apply (a : δ) : Measurable fun f : ∀ a, X a => f a :=
measurable_pi_iff.1 measurable_id a
theorem Measurable.eval {a : δ} {g : α → ∀ a, X a} (hg : Measurable g) :
Measurable fun x => g x a :=
(measurable_pi_apply a).comp hg
@[fun_prop]
theorem measurable_pi_lambda (f : α → ∀ a, X a) (hf : ∀ a, Measurable fun c => f c a) :
Measurable f :=
measurable_pi_iff.mpr hf
/-- The function `(f, x) ↦ update f a x : (Π a, X a) × X a → Π a, X a` is measurable. -/
@[measurability, fun_prop]
theorem measurable_update' {a : δ} [DecidableEq δ] :
Measurable (fun p : (∀ i, X i) × X a ↦ update p.1 a p.2) := by
rw [measurable_pi_iff]
intro j
dsimp [update]
split_ifs with h
· subst h
dsimp
exact measurable_snd
· exact measurable_pi_iff.1 measurable_fst _
@[measurability, fun_prop]
theorem measurable_uniqueElim [Unique δ] :
Measurable (uniqueElim : X (default : δ) → ∀ i, X i) := by
simp_rw [measurable_pi_iff, Unique.forall_iff, uniqueElim_default]; exact measurable_id
@[measurability, fun_prop]
theorem measurable_updateFinset' [DecidableEq δ] {s : Finset δ} :
Measurable (fun p : (Π i, X i) × (Π i : s, X i) ↦ updateFinset p.1 s p.2) := by
simp only [updateFinset, measurable_pi_iff]
intro i
by_cases h : i ∈ s <;> simp [h, Measurable.eval, measurable_fst, measurable_snd]
@[measurability, fun_prop]
theorem measurable_updateFinset [DecidableEq δ] {s : Finset δ} {x : Π i, X i} :
Measurable (updateFinset x s) :=
measurable_updateFinset'.comp measurable_prodMk_left
@[measurability, fun_prop]
theorem measurable_updateFinset_left [DecidableEq δ] {s : Finset δ} {x : Π i : s, X i} :
Measurable (updateFinset · s x) :=
measurable_updateFinset'.comp measurable_prodMk_right
/-- The function `update f a : X a → Π a, X a` is always measurable.
This doesn't require `f` to be measurable.
This should not be confused with the statement that `update f a x` is measurable. -/
@[measurability, fun_prop]
theorem measurable_update (f : ∀ a : δ, X a) {a : δ} [DecidableEq δ] : Measurable (update f a) :=
measurable_update'.comp measurable_prodMk_left
@[measurability, fun_prop]
theorem measurable_update_left {a : δ} [DecidableEq δ] {x : X a} :
Measurable (update · a x) :=
measurable_update'.comp measurable_prodMk_right
@[measurability, fun_prop]
theorem Set.measurable_restrict (s : Set δ) : Measurable (s.restrict (π := X)) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
@[measurability, fun_prop]
theorem Set.measurable_restrict₂ {s t : Set δ} (hst : s ⊆ t) :
Measurable (restrict₂ (π := X) hst) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
@[measurability, fun_prop]
theorem Finset.measurable_restrict (s : Finset δ) : Measurable (s.restrict (π := X)) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
@[measurability, fun_prop]
theorem Finset.measurable_restrict₂ {s t : Finset δ} (hst : s ⊆ t) :
Measurable (Finset.restrict₂ (π := X) hst) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
@[measurability, fun_prop]
theorem Set.measurable_restrict_apply (s : Set α) {f : α → γ} (hf : Measurable f) :
Measurable (s.restrict f) := hf.comp measurable_subtype_coe
@[measurability, fun_prop]
theorem Set.measurable_restrict₂_apply {s t : Set α} (hst : s ⊆ t)
{f : t → γ} (hf : Measurable f) :
Measurable (restrict₂ (π := fun _ ↦ γ) hst f) := hf.comp (measurable_inclusion hst)
@[measurability, fun_prop]
theorem Finset.measurable_restrict_apply (s : Finset α) {f : α → γ} (hf : Measurable f) :
Measurable (s.restrict f) := hf.comp measurable_subtype_coe
@[measurability, fun_prop]
theorem Finset.measurable_restrict₂_apply {s t : Finset α} (hst : s ⊆ t)
{f : t → γ} (hf : Measurable f) :
Measurable (restrict₂ (π := fun _ ↦ γ) hst f) := hf.comp (measurable_inclusion hst)
variable (X) in
theorem measurable_eq_mp {i i' : δ} (h : i = i') : Measurable (congr_arg X h).mp := by
cases h
exact measurable_id
variable (X) in
theorem Measurable.eq_mp {β} [MeasurableSpace β] {i i' : δ} (h : i = i') {f : β → X i}
(hf : Measurable f) : Measurable fun x => (congr_arg X h).mp (f x) :=
(measurable_eq_mp X h).comp hf
@[measurability, fun_prop]
theorem measurable_piCongrLeft (f : δ' ≃ δ) : Measurable (Equiv.piCongrLeft X f) := by
rw [measurable_pi_iff]
intro i
simp_rw [Equiv.piCongrLeft_apply_eq_cast]
exact Measurable.eq_mp X (f.apply_symm_apply i) <| measurable_pi_apply <| f.symm i
/- Even though we cannot use projection notation, we still keep a dot to be consistent with similar
lemmas, like `MeasurableSet.prod`. -/
@[measurability]
protected theorem MeasurableSet.pi {s : Set δ} {t : ∀ i : δ, Set (X i)} (hs : s.Countable)
(ht : ∀ i ∈ s, MeasurableSet (t i)) : MeasurableSet (s.pi t) := by
rw [pi_def]
exact MeasurableSet.biInter hs fun i hi => measurable_pi_apply _ (ht i hi)
protected theorem MeasurableSet.univ_pi [Countable δ] {t : ∀ i : δ, Set (X i)}
(ht : ∀ i, MeasurableSet (t i)) : MeasurableSet (pi univ t) :=
MeasurableSet.pi (to_countable _) fun i _ => ht i
theorem measurableSet_pi_of_nonempty {s : Set δ} {t : ∀ i, Set (X i)} (hs : s.Countable)
(h : (pi s t).Nonempty) : MeasurableSet (pi s t) ↔ ∀ i ∈ s, MeasurableSet (t i) := by
classical
rcases h with ⟨f, hf⟩
refine ⟨fun hst i hi => ?_, MeasurableSet.pi hs⟩
convert measurable_update f (a := i) hst
rw [update_preimage_pi hi]
exact fun j hj _ => hf j hj
theorem measurableSet_pi {s : Set δ} {t : ∀ i, Set (X i)} (hs : s.Countable) :
MeasurableSet (pi s t) ↔ (∀ i ∈ s, MeasurableSet (t i)) ∨ pi s t = ∅ := by
rcases (pi s t).eq_empty_or_nonempty with h | h
· simp [h]
· simp [measurableSet_pi_of_nonempty hs, h, ← not_nonempty_iff_eq_empty]
instance Pi.instMeasurableSingletonClass [Countable δ] [∀ a, MeasurableSingletonClass (X a)] :
MeasurableSingletonClass (∀ a, X a) :=
⟨fun f => univ_pi_singleton f ▸ MeasurableSet.univ_pi fun t => measurableSet_singleton (f t)⟩
variable (X)
@[measurability]
theorem measurable_piEquivPiSubtypeProd_symm (p : δ → Prop) [DecidablePred p] :
Measurable (Equiv.piEquivPiSubtypeProd p X).symm := by
refine measurable_pi_iff.2 fun j => ?_
by_cases hj : p j
· simp only [hj, dif_pos, Equiv.piEquivPiSubtypeProd_symm_apply]
have : Measurable fun (f : ∀ i : { x // p x }, X i.1) => f ⟨j, hj⟩ :=
measurable_pi_apply (X := fun i : {x // p x} => X i.1) ⟨j, hj⟩
exact Measurable.comp this measurable_fst
· simp only [hj, Equiv.piEquivPiSubtypeProd_symm_apply, dif_neg, not_false_iff]
have : Measurable fun (f : ∀ i : { x // ¬p x }, X i.1) => f ⟨j, hj⟩ :=
measurable_pi_apply (X := fun i : {x // ¬p x} => X i.1) ⟨j, hj⟩
exact Measurable.comp this measurable_snd
@[measurability]
theorem measurable_piEquivPiSubtypeProd (p : δ → Prop) [DecidablePred p] :
Measurable (Equiv.piEquivPiSubtypeProd p X) :=
(measurable_pi_iff.2 fun _ => measurable_pi_apply _).prodMk
(measurable_pi_iff.2 fun _ => measurable_pi_apply _)
end Pi
instance TProd.instMeasurableSpace (X : δ → Type*) [∀ i, MeasurableSpace (X i)] :
∀ l : List δ, MeasurableSpace (List.TProd X l)
| [] => PUnit.instMeasurableSpace
| _::is => @Prod.instMeasurableSpace _ _ _ (TProd.instMeasurableSpace X is)
section TProd
open List
variable {X : δ → Type*} [∀ i, MeasurableSpace (X i)]
theorem measurable_tProd_mk (l : List δ) : Measurable (@TProd.mk δ X l) := by
induction l with
| nil => exact measurable_const
| cons i l ih => exact (measurable_pi_apply i).prodMk ih
theorem measurable_tProd_elim [DecidableEq δ] :
∀ {l : List δ} {i : δ} (hi : i ∈ l), Measurable fun v : TProd X l => v.elim hi
| i::is, j, hj => by
by_cases hji : j = i
· subst hji
simpa using measurable_fst
· simp only [TProd.elim_of_ne _ hji]
rw [mem_cons] at hj
exact (measurable_tProd_elim (hj.resolve_left hji)).comp measurable_snd
theorem measurable_tProd_elim' [DecidableEq δ] {l : List δ} (h : ∀ i, i ∈ l) :
Measurable (TProd.elim' h : TProd X l → ∀ i, X i) :=
measurable_pi_lambda _ fun i => measurable_tProd_elim (h i)
theorem MeasurableSet.tProd (l : List δ) {s : ∀ i, Set (X i)} (hs : ∀ i, MeasurableSet (s i)) :
MeasurableSet (Set.tprod l s) := by
induction l with
| nil => exact MeasurableSet.univ
| cons i l ih => exact (hs i).prod ih
end TProd
instance Sum.instMeasurableSpace {α β} [m₁ : MeasurableSpace α] [m₂ : MeasurableSpace β] :
MeasurableSpace (α ⊕ β) :=
m₁.map Sum.inl ⊓ m₂.map Sum.inr
section Sum
@[measurability]
theorem measurable_inl [MeasurableSpace α] [MeasurableSpace β] : Measurable (@Sum.inl α β) :=
Measurable.of_le_map inf_le_left
@[measurability]
theorem measurable_inr [MeasurableSpace α] [MeasurableSpace β] : Measurable (@Sum.inr α β) :=
Measurable.of_le_map inf_le_right
variable {m : MeasurableSpace α} {mβ : MeasurableSpace β}
theorem measurableSet_sum_iff {s : Set (α ⊕ β)} :
MeasurableSet s ↔ MeasurableSet (Sum.inl ⁻¹' s) ∧ MeasurableSet (Sum.inr ⁻¹' s) :=
Iff.rfl
theorem measurable_fun_sum {_ : MeasurableSpace γ} {f : α ⊕ β → γ} (hl : Measurable (f ∘ Sum.inl))
(hr : Measurable (f ∘ Sum.inr)) : Measurable f :=
Measurable.of_comap_le <|
le_inf (MeasurableSpace.comap_le_iff_le_map.2 <| hl)
(MeasurableSpace.comap_le_iff_le_map.2 <| hr)
@[measurability]
theorem Measurable.sumElim {_ : MeasurableSpace γ} {f : α → γ} {g : β → γ} (hf : Measurable f)
(hg : Measurable g) : Measurable (Sum.elim f g) :=
measurable_fun_sum hf hg
theorem Measurable.sumMap {_ : MeasurableSpace γ} {_ : MeasurableSpace δ} {f : α → β} {g : γ → δ}
(hf : Measurable f) (hg : Measurable g) : Measurable (Sum.map f g) :=
(measurable_inl.comp hf).sumElim (measurable_inr.comp hg)
@[simp] theorem measurableSet_inl_image {s : Set α} :
MeasurableSet (Sum.inl '' s : Set (α ⊕ β)) ↔ MeasurableSet s := by
simp [measurableSet_sum_iff, Sum.inl_injective.preimage_image]
alias ⟨_, MeasurableSet.inl_image⟩ := measurableSet_inl_image
@[simp] theorem measurableSet_inr_image {s : Set β} :
MeasurableSet (Sum.inr '' s : Set (α ⊕ β)) ↔ MeasurableSet s := by
simp [measurableSet_sum_iff, Sum.inr_injective.preimage_image]
alias ⟨_, MeasurableSet.inr_image⟩ := measurableSet_inr_image
theorem measurableSet_range_inl [MeasurableSpace α] :
MeasurableSet (range Sum.inl : Set (α ⊕ β)) := by
rw [← image_univ]
exact MeasurableSet.univ.inl_image
theorem measurableSet_range_inr [MeasurableSpace α] :
MeasurableSet (range Sum.inr : Set (α ⊕ β)) := by
rw [← image_univ]
exact MeasurableSet.univ.inr_image
end Sum
instance Sigma.instMeasurableSpace {α} {β : α → Type*} [m : ∀ a, MeasurableSpace (β a)] :
MeasurableSpace (Sigma β) :=
⨅ a, (m a).map (Sigma.mk a)
section prop
variable [MeasurableSpace α] {p q : α → Prop}
@[simp] theorem measurableSet_setOf : MeasurableSet {a | p a} ↔ Measurable p :=
⟨fun h ↦ measurable_to_prop <| by simpa only [preimage_singleton_true], fun h => by
simpa using h (measurableSet_singleton True)⟩
@[simp] theorem measurable_mem : Measurable (· ∈ s) ↔ MeasurableSet s := measurableSet_setOf.symm
alias ⟨_, Measurable.setOf⟩ := measurableSet_setOf
alias ⟨_, MeasurableSet.mem⟩ := measurable_mem
@[fun_prop]
lemma Measurable.not (hp : Measurable p) : Measurable (¬ p ·) :=
measurableSet_setOf.1 hp.setOf.compl
@[fun_prop]
lemma Measurable.and (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a ∧ q a :=
measurableSet_setOf.1 <| hp.setOf.inter hq.setOf
@[fun_prop]
lemma Measurable.or (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a ∨ q a :=
measurableSet_setOf.1 <| hp.setOf.union hq.setOf
lemma Measurable.imp (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a → q a :=
measurableSet_setOf.1 <| hp.setOf.himp hq.setOf
@[fun_prop]
lemma Measurable.iff (hp : Measurable p) (hq : Measurable q) : Measurable fun a ↦ p a ↔ q a :=
measurableSet_setOf.1 <| by simp_rw [iff_iff_implies_and_implies]; exact hq.setOf.bihimp hp.setOf
lemma Measurable.forall [Countable ι] {p : ι → α → Prop} (hp : ∀ i, Measurable (p i)) :
Measurable fun a ↦ ∀ i, p i a :=
measurableSet_setOf.1 <| by rw [setOf_forall]; exact MeasurableSet.iInter fun i ↦ (hp i).setOf
@[fun_prop]
lemma Measurable.exists [Countable ι] {p : ι → α → Prop} (hp : ∀ i, Measurable (p i)) :
Measurable fun a ↦ ∃ i, p i a :=
measurableSet_setOf.1 <| by rw [setOf_exists]; exact MeasurableSet.iUnion fun i ↦ (hp i).setOf
end prop
section Set
variable [MeasurableSpace β] {g : β → Set α}
/-- This instance is useful when talking about Bernoulli sequences of random variables or binomial
random graphs. -/
instance Set.instMeasurableSpace : MeasurableSpace (Set α) := by unfold Set; infer_instance
instance Set.instMeasurableSingletonClass [Countable α] : MeasurableSingletonClass (Set α) := by
unfold Set; infer_instance
lemma measurable_set_iff : Measurable g ↔ ∀ a, Measurable fun x ↦ a ∈ g x := measurable_pi_iff
@[fun_prop]
lemma measurable_set_mem (a : α) : Measurable fun s : Set α ↦ a ∈ s := measurable_pi_apply _
@[fun_prop, aesop safe 100 apply (rule_sets := [Measurable])]
lemma measurable_set_notMem (a : α) : Measurable fun s : Set α ↦ a ∉ s :=
(Measurable.of_discrete (f := Not)).comp <| measurable_set_mem a
@[deprecated (since := "2025-05-23")] alias measurable_set_not_mem := measurable_set_notMem
@[aesop safe 100 apply (rule_sets := [Measurable])]
lemma measurableSet_mem (a : α) : MeasurableSet {s : Set α | a ∈ s} :=
measurableSet_setOf.2 <| measurable_set_mem _
@[aesop safe 100 apply (rule_sets := [Measurable])]
lemma measurableSet_notMem (a : α) : MeasurableSet {s : Set α | a ∉ s} :=
measurableSet_setOf.2 <| measurable_set_notMem _
@[deprecated (since := "2025-05-23")] alias measurableSet_not_mem := measurableSet_notMem
lemma measurable_compl : Measurable ((·ᶜ) : Set α → Set α) :=
measurable_set_iff.2 fun _ ↦ measurable_set_notMem _
lemma MeasurableSet.setOf_finite [Countable α] : MeasurableSet {s : Set α | s.Finite} :=
Countable.setOf_finite.measurableSet
lemma MeasurableSet.setOf_infinite [Countable α] : MeasurableSet {s : Set α | s.Infinite} :=
.setOf_finite |> .compl
lemma MeasurableSet.sep_finite [Countable α] {S : Set (Set α)} (hS : MeasurableSet S) :
MeasurableSet {s ∈ S | s.Finite} :=
hS.inter .setOf_finite
lemma MeasurableSet.sep_infinite [Countable α] {S : Set (Set α)} (hS : MeasurableSet S) :
MeasurableSet {s ∈ S | s.Infinite} :=
hS.inter .setOf_infinite
end Set
section curry
variable {ι : Type*}
section Function
variable {κ X : Type*} [MeasurableSpace X]
@[fun_prop, measurability]
lemma measurable_curry : Measurable (@curry ι κ X) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
-- This cannot be tagged with `fun_prop` because `fun_prop` can see through `Function.uncurry`.
lemma measurable_uncurry : Measurable (@uncurry ι κ X) := by fun_prop
@[fun_prop, measurability]
lemma measurable_equivCurry : Measurable (Equiv.curry ι κ X) := measurable_curry
@[fun_prop, measurability]
lemma measurable_equivCurry_symm : Measurable (Equiv.curry ι κ X).symm := measurable_uncurry
end Function
section Sigma
variable {κ : ι → Type*} {X : (i : ι) → κ i → Type*} [∀ i j, MeasurableSpace (X i j)]
@[fun_prop, measurability]
lemma measurable_sigmaCurry : Measurable (Sigma.curry (γ := X)) :=
measurable_pi_lambda _ fun _ ↦ measurable_pi_lambda _ fun _ ↦ measurable_pi_apply _
@[fun_prop, measurability]
lemma measurable_sigmaUncurry : Measurable (Sigma.uncurry (γ := X)) := by
refine measurable_pi_lambda _ fun _ ↦ ?_
simp only [Sigma.uncurry]
fun_prop
@[fun_prop, measurability]
lemma measurable_piCurry : Measurable (Equiv.piCurry X) := measurable_sigmaCurry
@[fun_prop, measurability]
lemma measurable_piCurry_symm : Measurable (Equiv.piCurry X).symm := measurable_sigmaUncurry
end Sigma
end curry |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Defs.lean | import Mathlib.Data.Set.Countable
import Mathlib.Order.ConditionallyCompleteLattice.Basic
import Mathlib.Tactic.FunProp.Attr
import Mathlib.Tactic.Measurability
/-!
# Measurable spaces and measurable functions
This file defines measurable spaces and measurable functions.
A measurable space is a set equipped with a σ-algebra, a collection of
subsets closed under complementation and countable union. A function
between measurable spaces is measurable if the preimage of each
measurable subset is measurable.
σ-algebras on a fixed set `α` form a complete lattice. Here we order
σ-algebras by writing `m₁ ≤ m₂` if every set which is `m₁`-measurable is
also `m₂`-measurable (that is, `m₁` is a subset of `m₂`). In particular, any
collection of subsets of `α` generates a smallest σ-algebra which
contains all of them.
## References
* <https://en.wikipedia.org/wiki/Measurable_space>
* <https://en.wikipedia.org/wiki/Sigma-algebra>
* <https://en.wikipedia.org/wiki/Dynkin_system>
## Tags
measurable space, σ-algebra, measurable function
-/
assert_not_exists Covariant MonoidWithZero
open Set Encodable Function Equiv
variable {α β γ δ δ' : Type*} {ι : Sort*} {s t u : Set α}
/-- A measurable space is a space equipped with a σ-algebra. -/
@[class] structure MeasurableSpace (α : Type*) where
/-- Predicate saying that a given set is measurable. Use `MeasurableSet` in the root namespace
instead. -/
MeasurableSet' : Set α → Prop
/-- The empty set is a measurable set. Use `MeasurableSet.empty` instead. -/
measurableSet_empty : MeasurableSet' ∅
/-- The complement of a measurable set is a measurable set. Use `MeasurableSet.compl` instead. -/
measurableSet_compl : ∀ s, MeasurableSet' s → MeasurableSet' sᶜ
/-- The union of a sequence of measurable sets is a measurable set. Use a more general
`MeasurableSet.iUnion` instead. -/
measurableSet_iUnion : ∀ f : ℕ → Set α, (∀ i, MeasurableSet' (f i)) → MeasurableSet' (⋃ i, f i)
instance [h : MeasurableSpace α] : MeasurableSpace αᵒᵈ := h
/-- `MeasurableSet s` means that `s` is measurable (in the ambient measure space on `α`) -/
def MeasurableSet [MeasurableSpace α] (s : Set α) : Prop :=
‹MeasurableSpace α›.MeasurableSet' s
/-- Notation for `MeasurableSet` with respect to a non-standard σ-algebra. -/
scoped[MeasureTheory] notation "MeasurableSet[" m "]" => @MeasurableSet _ m
open MeasureTheory
section
open scoped symmDiff
@[simp, measurability]
theorem MeasurableSet.empty [MeasurableSpace α] : MeasurableSet (∅ : Set α) :=
MeasurableSpace.measurableSet_empty _
variable {m : MeasurableSpace α}
@[measurability]
protected theorem MeasurableSet.compl : MeasurableSet s → MeasurableSet sᶜ :=
MeasurableSpace.measurableSet_compl _ s
protected theorem MeasurableSet.of_compl (h : MeasurableSet sᶜ) : MeasurableSet s :=
compl_compl s ▸ h.compl
@[simp]
theorem MeasurableSet.compl_iff : MeasurableSet sᶜ ↔ MeasurableSet s :=
⟨.of_compl, .compl⟩
@[simp, measurability]
protected theorem MeasurableSet.univ : MeasurableSet (univ : Set α) :=
.of_compl <| by simp
@[nontriviality, measurability]
theorem Subsingleton.measurableSet [Subsingleton α] {s : Set α} : MeasurableSet s :=
Subsingleton.set_cases MeasurableSet.empty MeasurableSet.univ s
theorem MeasurableSet.congr {s t : Set α} (hs : MeasurableSet s) (h : s = t) : MeasurableSet t := by
rwa [← h]
@[measurability]
protected theorem MeasurableSet.iUnion [Countable ι] ⦃f : ι → Set α⦄
(h : ∀ b, MeasurableSet (f b)) : MeasurableSet (⋃ b, f b) := by
cases isEmpty_or_nonempty ι
· simp
· rcases exists_surjective_nat ι with ⟨e, he⟩
rw [← iUnion_congr_of_surjective _ he (fun _ => rfl)]
exact m.measurableSet_iUnion _ fun _ => h _
protected theorem MeasurableSet.biUnion {f : β → Set α} {s : Set β} (hs : s.Countable)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋃ b ∈ s, f b) := by
rw [biUnion_eq_iUnion]
have := hs.to_subtype
exact MeasurableSet.iUnion (by simpa using h)
theorem Set.Finite.measurableSet_biUnion {f : β → Set α} {s : Set β} (hs : s.Finite)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋃ b ∈ s, f b) :=
.biUnion hs.countable h
theorem Finset.measurableSet_biUnion {f : β → Set α} (s : Finset β)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋃ b ∈ s, f b) :=
s.finite_toSet.measurableSet_biUnion h
protected theorem MeasurableSet.sUnion {s : Set (Set α)} (hs : s.Countable)
(h : ∀ t ∈ s, MeasurableSet t) : MeasurableSet (⋃₀ s) := by
rw [sUnion_eq_biUnion]
exact .biUnion hs h
theorem Set.Finite.measurableSet_sUnion {s : Set (Set α)} (hs : s.Finite)
(h : ∀ t ∈ s, MeasurableSet t) : MeasurableSet (⋃₀ s) :=
MeasurableSet.sUnion hs.countable h
@[measurability]
theorem MeasurableSet.iInter [Countable ι] {f : ι → Set α} (h : ∀ b, MeasurableSet (f b)) :
MeasurableSet (⋂ b, f b) :=
.of_compl <| by rw [compl_iInter]; exact .iUnion fun b => (h b).compl
theorem MeasurableSet.biInter {f : β → Set α} {s : Set β} (hs : s.Countable)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋂ b ∈ s, f b) :=
.of_compl <| by rw [compl_iInter₂]; exact .biUnion hs fun b hb => (h b hb).compl
theorem Set.Finite.measurableSet_biInter {f : β → Set α} {s : Set β} (hs : s.Finite)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋂ b ∈ s, f b) :=
.biInter hs.countable h
theorem Finset.measurableSet_biInter {f : β → Set α} (s : Finset β)
(h : ∀ b ∈ s, MeasurableSet (f b)) : MeasurableSet (⋂ b ∈ s, f b) :=
s.finite_toSet.measurableSet_biInter h
theorem MeasurableSet.sInter {s : Set (Set α)} (hs : s.Countable) (h : ∀ t ∈ s, MeasurableSet t) :
MeasurableSet (⋂₀ s) := by
rw [sInter_eq_biInter]
exact MeasurableSet.biInter hs h
theorem Set.Finite.measurableSet_sInter {s : Set (Set α)} (hs : s.Finite)
(h : ∀ t ∈ s, MeasurableSet t) : MeasurableSet (⋂₀ s) :=
MeasurableSet.sInter hs.countable h
@[simp, measurability]
protected theorem MeasurableSet.union {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) : MeasurableSet (s₁ ∪ s₂) := by
rw [union_eq_iUnion]
exact .iUnion (Bool.forall_bool.2 ⟨h₂, h₁⟩)
@[simp, measurability]
protected theorem MeasurableSet.inter {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) : MeasurableSet (s₁ ∩ s₂) := by
rw [inter_eq_compl_compl_union_compl]
exact (h₁.compl.union h₂.compl).compl
@[simp, measurability]
protected theorem MeasurableSet.diff {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) : MeasurableSet (s₁ \ s₂) :=
h₁.inter h₂.compl
@[simp, measurability]
protected lemma MeasurableSet.himp {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁) (h₂ : MeasurableSet s₂) :
MeasurableSet (s₁ ⇨ s₂) := by rw [himp_eq]; exact h₂.union h₁.compl
@[simp, measurability]
protected theorem MeasurableSet.symmDiff {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) : MeasurableSet (s₁ ∆ s₂) :=
(h₁.diff h₂).union (h₂.diff h₁)
@[simp, measurability]
protected lemma MeasurableSet.bihimp {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) : MeasurableSet (s₁ ⇔ s₂) := (h₂.himp h₁).inter (h₁.himp h₂)
@[simp, measurability]
protected theorem MeasurableSet.ite {t s₁ s₂ : Set α} (ht : MeasurableSet t)
(h₁ : MeasurableSet s₁) (h₂ : MeasurableSet s₂) : MeasurableSet (t.ite s₁ s₂) :=
(h₁.inter ht).union (h₂.diff ht)
open Classical in
theorem MeasurableSet.ite' {s t : Set α} {p : Prop} (hs : p → MeasurableSet s)
(ht : ¬p → MeasurableSet t) : MeasurableSet (ite p s t) := by
split_ifs with h
exacts [hs h, ht h]
@[simp, measurability]
protected theorem MeasurableSet.cond {s₁ s₂ : Set α} (h₁ : MeasurableSet s₁)
(h₂ : MeasurableSet s₂) {i : Bool} : MeasurableSet (cond i s₁ s₂) := by
cases i
exacts [h₂, h₁]
protected theorem MeasurableSet.const (p : Prop) : MeasurableSet { _a : α | p } := by
by_cases p <;> simp [*]
/-- Every set has a measurable superset. Declare this as local instance as needed. -/
theorem nonempty_measurable_superset (s : Set α) : Nonempty { t // s ⊆ t ∧ MeasurableSet t } :=
⟨⟨univ, subset_univ s, MeasurableSet.univ⟩⟩
end
theorem MeasurableSpace.measurableSet_injective : Injective (@MeasurableSet α)
| ⟨_, _, _, _⟩, ⟨_, _, _, _⟩, _ => by congr
@[ext]
theorem MeasurableSpace.ext {m₁ m₂ : MeasurableSpace α}
(h : ∀ s : Set α, MeasurableSet[m₁] s ↔ MeasurableSet[m₂] s) : m₁ = m₂ :=
measurableSet_injective <| funext fun s => propext (h s)
/-- A typeclass mixin for `MeasurableSpace`s such that each singleton is measurable. -/
class MeasurableSingletonClass (α : Type*) [MeasurableSpace α] : Prop where
/-- A singleton is a measurable set. -/
measurableSet_singleton : ∀ x, MeasurableSet ({x} : Set α)
export MeasurableSingletonClass (measurableSet_singleton)
@[simp]
lemma MeasurableSet.singleton [MeasurableSpace α] [MeasurableSingletonClass α] (a : α) :
MeasurableSet {a} :=
measurableSet_singleton a
section MeasurableSingletonClass
variable [MeasurableSpace α] [MeasurableSingletonClass α]
@[measurability]
theorem measurableSet_eq {a : α} : MeasurableSet { x | x = a } := .singleton a
@[measurability]
protected theorem MeasurableSet.insert {s : Set α} (hs : MeasurableSet s) (a : α) :
MeasurableSet (insert a s) :=
.union (.singleton a) hs
@[simp]
theorem measurableSet_insert {a : α} {s : Set α} :
MeasurableSet (insert a s) ↔ MeasurableSet s := by
classical
exact ⟨fun h =>
if ha : a ∈ s then by rwa [← insert_eq_of_mem ha]
else insert_diff_self_of_notMem ha ▸ h.diff (.singleton _),
fun h => h.insert a⟩
theorem Set.Subsingleton.measurableSet {s : Set α} (hs : s.Subsingleton) : MeasurableSet s :=
hs.induction_on .empty .singleton
theorem Set.Finite.measurableSet {s : Set α} (hs : s.Finite) : MeasurableSet s :=
Finite.induction_on _ hs .empty fun _ _ hsm => hsm.insert _
@[measurability]
protected theorem Finset.measurableSet (s : Finset α) : MeasurableSet (↑s : Set α) :=
s.finite_toSet.measurableSet
theorem Set.Countable.measurableSet {s : Set α} (hs : s.Countable) : MeasurableSet s := by
rw [← biUnion_of_singleton s]
exact .biUnion hs fun b _ => .singleton b
end MeasurableSingletonClass
namespace MeasurableSpace
/-- Copy of a `MeasurableSpace` with a new `MeasurableSet` equal to the old one. Useful to fix
definitional equalities. -/
protected def copy (m : MeasurableSpace α) (p : Set α → Prop) (h : ∀ s, p s ↔ MeasurableSet[m] s) :
MeasurableSpace α where
MeasurableSet' := p
measurableSet_empty := by simpa only [h] using m.measurableSet_empty
measurableSet_compl := by simpa only [h] using m.measurableSet_compl
measurableSet_iUnion := by simpa only [h] using m.measurableSet_iUnion
lemma measurableSet_copy {m : MeasurableSpace α} {p : Set α → Prop}
(h : ∀ s, p s ↔ MeasurableSet[m] s) {s} : MeasurableSet[.copy m p h] s ↔ p s :=
Iff.rfl
lemma copy_eq {m : MeasurableSpace α} {p : Set α → Prop} (h : ∀ s, p s ↔ MeasurableSet[m] s) :
m.copy p h = m :=
ext h
section CompleteLattice
instance : LE (MeasurableSpace α) where le m₁ m₂ := ∀ s, MeasurableSet[m₁] s → MeasurableSet[m₂] s
theorem le_def {α} {a b : MeasurableSpace α} : a ≤ b ↔ a.MeasurableSet' ≤ b.MeasurableSet' :=
Iff.rfl
instance : PartialOrder (MeasurableSpace α) :=
{ PartialOrder.lift (@MeasurableSet α) measurableSet_injective with
le := LE.le
lt := fun m₁ m₂ => m₁ ≤ m₂ ∧ ¬m₂ ≤ m₁ }
/-- The smallest σ-algebra containing a collection `s` of basic sets -/
inductive GenerateMeasurable (s : Set (Set α)) : Set α → Prop
| protected basic : ∀ u ∈ s, GenerateMeasurable s u
| protected empty : GenerateMeasurable s ∅
| protected compl : ∀ t, GenerateMeasurable s t → GenerateMeasurable s tᶜ
| protected iUnion : ∀ f : ℕ → Set α, (∀ n, GenerateMeasurable s (f n)) →
GenerateMeasurable s (⋃ i, f i)
/-- Construct the smallest measure space containing a collection of basic sets -/
def generateFrom (s : Set (Set α)) : MeasurableSpace α where
MeasurableSet' := GenerateMeasurable s
measurableSet_empty := .empty
measurableSet_compl := .compl
measurableSet_iUnion := .iUnion
theorem measurableSet_generateFrom {s : Set (Set α)} {t : Set α} (ht : t ∈ s) :
MeasurableSet[generateFrom s] t :=
.basic t ht
@[elab_as_elim]
theorem generateFrom_induction (C : Set (Set α))
(p : ∀ s : Set α, MeasurableSet[generateFrom C] s → Prop) (hC : ∀ t ∈ C, ∀ ht, p t ht)
(empty : p ∅ (measurableSet_empty _)) (compl : ∀ t ht, p t ht → p tᶜ ht.compl)
(iUnion : ∀ (s : ℕ → Set α) (hs : ∀ n, MeasurableSet[generateFrom C] (s n)),
(∀ n, p (s n) (hs n)) → p (⋃ i, s i) (.iUnion hs)) (s : Set α)
(hs : MeasurableSet[generateFrom C] s) : p s hs := by
induction hs
exacts [hC _ ‹_› _, empty, compl _ ‹_› ‹_›, iUnion ‹_› ‹_› ‹_›]
theorem generateFrom_le {s : Set (Set α)} {m : MeasurableSpace α}
(h : ∀ t ∈ s, MeasurableSet[m] t) : generateFrom s ≤ m :=
fun t (ht : GenerateMeasurable s t) =>
ht.recOn h .empty (fun _ _ => .compl) fun _ _ hf => .iUnion hf
theorem generateFrom_le_iff {s : Set (Set α)} (m : MeasurableSpace α) :
generateFrom s ≤ m ↔ s ⊆ { t | MeasurableSet[m] t } :=
Iff.intro (fun h _ hu => h _ <| measurableSet_generateFrom hu) fun h => generateFrom_le h
@[simp]
theorem generateFrom_measurableSet [MeasurableSpace α] :
generateFrom { s : Set α | MeasurableSet s } = ‹_› :=
le_antisymm (generateFrom_le fun _ => id) fun _ => measurableSet_generateFrom
theorem forall_generateFrom_mem_iff_mem_iff {S : Set (Set α)} {x y : α} :
(∀ s, MeasurableSet[generateFrom S] s → (x ∈ s ↔ y ∈ s)) ↔ (∀ s ∈ S, x ∈ s ↔ y ∈ s) := by
refine ⟨fun H s hs ↦ H s (.basic s hs), fun H s ↦ ?_⟩
apply generateFrom_induction
· exact fun s hs _ ↦ H s hs
· rfl
· exact fun _ _ ↦ Iff.not
· intro f _ hf
simp only [mem_iUnion, hf]
/-- If `g` is a collection of subsets of `α` such that the `σ`-algebra generated from `g` contains
the same sets as `g`, then `g` was already a `σ`-algebra. -/
protected def mkOfClosure (g : Set (Set α)) (hg : { t | MeasurableSet[generateFrom g] t } = g) :
MeasurableSpace α :=
(generateFrom g).copy (· ∈ g) <| Set.ext_iff.1 hg.symm
theorem mkOfClosure_sets {s : Set (Set α)} {hs : { t | MeasurableSet[generateFrom s] t } = s} :
MeasurableSpace.mkOfClosure s hs = generateFrom s :=
copy_eq _
/-- We get a Galois insertion between `σ`-algebras on `α` and `Set (Set α)` by using `generate_from`
on one side and the collection of measurable sets on the other side. -/
def giGenerateFrom : GaloisInsertion (@generateFrom α) fun m => { t | MeasurableSet[m] t } where
gc _ := generateFrom_le_iff
le_l_u _ _ := measurableSet_generateFrom
choice g hg := MeasurableSpace.mkOfClosure g <| le_antisymm hg <| (generateFrom_le_iff _).1 le_rfl
choice_eq _ _ := mkOfClosure_sets
instance : CompleteLattice (MeasurableSpace α) :=
giGenerateFrom.liftCompleteLattice
instance : Inhabited (MeasurableSpace α) := ⟨⊤⟩
@[mono]
theorem generateFrom_mono {s t : Set (Set α)} (h : s ⊆ t) : generateFrom s ≤ generateFrom t :=
giGenerateFrom.gc.monotone_l h
theorem generateFrom_sup_generateFrom {s t : Set (Set α)} :
generateFrom s ⊔ generateFrom t = generateFrom (s ∪ t) :=
(@giGenerateFrom α).gc.l_sup.symm
lemma iSup_generateFrom (s : ι → Set (Set α)) :
⨆ i, generateFrom (s i) = generateFrom (⋃ i, s i) :=
(@MeasurableSpace.giGenerateFrom α).gc.l_iSup.symm
@[simp]
lemma generateFrom_empty : generateFrom (∅ : Set (Set α)) = ⊥ :=
le_bot_iff.mp (generateFrom_le (by simp))
theorem generateFrom_singleton_empty : generateFrom {∅} = (⊥ : MeasurableSpace α) :=
bot_unique <| generateFrom_le <| by simp [@MeasurableSet.empty α ⊥]
theorem generateFrom_singleton_univ : generateFrom {Set.univ} = (⊥ : MeasurableSpace α) :=
bot_unique <| generateFrom_le <| by simp
@[simp]
theorem generateFrom_insert_univ (S : Set (Set α)) :
generateFrom (insert Set.univ S) = generateFrom S := by
rw [insert_eq, ← generateFrom_sup_generateFrom, generateFrom_singleton_univ, bot_sup_eq]
@[simp]
theorem generateFrom_insert_empty (S : Set (Set α)) :
generateFrom (insert ∅ S) = generateFrom S := by
rw [insert_eq, ← generateFrom_sup_generateFrom, generateFrom_singleton_empty, bot_sup_eq]
theorem measurableSet_bot_iff {s : Set α} : MeasurableSet[⊥] s ↔ s = ∅ ∨ s = univ :=
let b : MeasurableSpace α :=
{ MeasurableSet' := fun s => s = ∅ ∨ s = univ
measurableSet_empty := Or.inl rfl
measurableSet_compl := by simp +contextual [or_imp]
measurableSet_iUnion := fun _ hf => sUnion_mem_empty_univ (forall_mem_range.2 hf) }
have : b = ⊥ :=
bot_unique fun _ hs =>
hs.elim (fun s => s.symm ▸ @measurableSet_empty _ ⊥) fun s =>
s.symm ▸ @MeasurableSet.univ _ ⊥
this ▸ Iff.rfl
@[simp, measurability] theorem measurableSet_top {s : Set α} : MeasurableSet[⊤] s := trivial
@[simp]
-- The `m₁` parameter gets filled in by typeclass instance synthesis (for some reason...)
-- so we have to order it *after* `m₂`. Otherwise `simp` can't apply this lemma.
theorem measurableSet_inf {m₂ m₁ : MeasurableSpace α} {s : Set α} :
MeasurableSet[m₁ ⊓ m₂] s ↔ MeasurableSet[m₁] s ∧ MeasurableSet[m₂] s :=
Iff.rfl
@[simp]
theorem measurableSet_sInf {ms : Set (MeasurableSpace α)} {s : Set α} :
MeasurableSet[sInf ms] s ↔ ∀ m ∈ ms, MeasurableSet[m] s :=
show s ∈ ⋂₀ _ ↔ _ by simp
theorem measurableSet_iInf {ι} {m : ι → MeasurableSpace α} {s : Set α} :
MeasurableSet[iInf m] s ↔ ∀ i, MeasurableSet[m i] s := by
rw [iInf, measurableSet_sInf, forall_mem_range]
theorem measurableSet_sup {m₁ m₂ : MeasurableSpace α} {s : Set α} :
MeasurableSet[m₁ ⊔ m₂] s ↔ GenerateMeasurable (MeasurableSet[m₁] ∪ MeasurableSet[m₂]) s :=
Iff.rfl
theorem measurableSet_sSup {ms : Set (MeasurableSpace α)} {s : Set α} :
MeasurableSet[sSup ms] s ↔
GenerateMeasurable { s : Set α | ∃ m ∈ ms, MeasurableSet[m] s } s := by
change GenerateMeasurable (⋃₀ _) _ ↔ _
simp [← setOf_exists]
theorem measurableSet_iSup {ι} {m : ι → MeasurableSpace α} {s : Set α} :
MeasurableSet[iSup m] s ↔ GenerateMeasurable { s : Set α | ∃ i, MeasurableSet[m i] s } s := by
simp only [iSup, measurableSet_sSup, exists_range_iff]
theorem measurableSpace_iSup_eq (m : ι → MeasurableSpace α) :
⨆ n, m n = generateFrom { s | ∃ n, MeasurableSet[m n] s } := by
ext s
rw [measurableSet_iSup]
rfl
theorem generateFrom_iUnion_measurableSet (m : ι → MeasurableSpace α) :
generateFrom (⋃ n, { t | MeasurableSet[m n] t }) = ⨆ n, m n :=
(@giGenerateFrom α).l_iSup_u m
end CompleteLattice
end MeasurableSpace
/-- A function `f` between measurable spaces is measurable if the preimage of every
measurable set is measurable. -/
@[fun_prop]
def Measurable [MeasurableSpace α] [MeasurableSpace β] (f : α → β) : Prop :=
∀ ⦃t : Set β⦄, MeasurableSet t → MeasurableSet (f ⁻¹' t)
add_aesop_rules safe tactic
(rule_sets := [Measurable])
(index := [target @Measurable ..])
(by fun_prop (disch := measurability))
namespace MeasureTheory
set_option quotPrecheck false in
/-- Notation for `Measurable` with respect to a non-standard σ-algebra in the domain. -/
scoped notation "Measurable[" m "]" => @Measurable _ _ m _
/-- Notation for `Measurable` with respect to a non-standard σ-algebra in the domain and codomain.
-/
scoped notation "Measurable[" mα ", " mβ "]" => @Measurable _ _ mα mβ
end MeasureTheory
section MeasurableFunctions
@[measurability]
theorem measurable_id {_ : MeasurableSpace α} : Measurable (@id α) := fun _ => id
@[fun_prop, measurability]
theorem measurable_id' {_ : MeasurableSpace α} : Measurable fun a : α => a := measurable_id
protected theorem Measurable.comp {_ : MeasurableSpace α} {_ : MeasurableSpace β}
{_ : MeasurableSpace γ} {g : β → γ} {f : α → β} (hg : Measurable g) (hf : Measurable f) :
Measurable (g ∘ f) :=
fun _ h => hf (hg h)
@[fun_prop]
protected theorem Measurable.comp' {_ : MeasurableSpace α} {_ : MeasurableSpace β}
{_ : MeasurableSpace γ} {g : β → γ} {f : α → β} (hg : Measurable g) (hf : Measurable f) :
Measurable (fun x => g (f x)) := Measurable.comp hg hf
@[simp, fun_prop, measurability]
theorem measurable_const {_ : MeasurableSpace α} {_ : MeasurableSpace β} {a : α} :
Measurable fun _ : β => a := fun s _ => .const (a ∈ s)
theorem Measurable.le {α} {m m0 : MeasurableSpace α} {_ : MeasurableSpace β} (hm : m ≤ m0)
{f : α → β} (hf : Measurable[m] f) : Measurable[m0] f := fun _ hs => hm _ (hf hs)
end MeasurableFunctions
/-- A typeclass mixin for `MeasurableSpace`s such that all sets are measurable. -/
class DiscreteMeasurableSpace (α : Type*) [MeasurableSpace α] : Prop where
/-- Do not use this. Use `MeasurableSet.of_discrete` instead. -/
forall_measurableSet : ∀ s : Set α, MeasurableSet s
instance : @DiscreteMeasurableSpace α ⊤ :=
@DiscreteMeasurableSpace.mk _ (_) fun _ ↦ MeasurableSpace.measurableSet_top
-- See note [lower instance priority]
instance (priority := 100) MeasurableSingletonClass.toDiscreteMeasurableSpace [MeasurableSpace α]
[MeasurableSingletonClass α] [Countable α] : DiscreteMeasurableSpace α where
forall_measurableSet _ := (Set.to_countable _).measurableSet
section DiscreteMeasurableSpace
variable [MeasurableSpace α] [MeasurableSpace β] [DiscreteMeasurableSpace α] {s : Set α} {f : α → β}
@[measurability] lemma MeasurableSet.of_discrete : MeasurableSet s :=
DiscreteMeasurableSpace.forall_measurableSet _
@[measurability, fun_prop] lemma Measurable.of_discrete : Measurable f := fun _ _ ↦ .of_discrete
/-- Warning: Creates a typeclass loop with `MeasurableSingletonClass.toDiscreteMeasurableSpace`.
To be monitored. -/
-- See note [lower instance priority]
instance (priority := 100) DiscreteMeasurableSpace.toMeasurableSingletonClass :
MeasurableSingletonClass α where
measurableSet_singleton _ := .of_discrete
end DiscreteMeasurableSpace |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Embedding.lean | import Mathlib.MeasureTheory.MeasurableSpace.Constructions
import Mathlib.Tactic.FunProp
/-!
# Measurable embeddings and equivalences
A measurable equivalence between measurable spaces is an equivalence
which respects the σ-algebras, that is, for which both directions of
the equivalence are measurable functions.
## Main definitions
* `MeasurableEmbedding`: a map `f : α → β` is called a *measurable embedding* if it is injective,
measurable, and sends measurable sets to measurable sets.
* `MeasurableEquiv`: an equivalence `α ≃ β` is a *measurable equivalence* if its forward and inverse
functions are measurable.
We prove a multitude of elementary lemmas about these, and one more substantial theorem:
* `MeasurableEmbedding.schroederBernstein`: the **measurable Schröder-Bernstein Theorem**: given
measurable embeddings `α → β` and `β → α`, we can find a measurable equivalence `α ≃ᵐ β`.
## Notation
* We write `α ≃ᵐ β` for measurable equivalences between the measurable spaces `α` and `β`.
This should not be confused with `≃ₘ` which is used for diffeomorphisms between manifolds.
## Tags
measurable equivalence, measurable embedding
-/
open Set Function Equiv MeasureTheory
universe uι
variable {α β γ δ δ' : Type*} {ι : Sort uι} {s t u : Set α}
/-- A map `f : α → β` is called a *measurable embedding* if it is injective, measurable, and sends
measurable sets to measurable sets. The latter assumption can be replaced with “`f` has measurable
inverse `g : Set.range f → α`”, see `MeasurableEmbedding.measurable_rangeSplitting`,
`MeasurableEmbedding.of_measurable_inverse_range`, and
`MeasurableEmbedding.of_measurable_inverse`.
One more interpretation: `f` is a measurable embedding if it defines a measurable equivalence to its
range and the range is a measurable set. One implication is formalized as
`MeasurableEmbedding.equivRange`; the other one follows from
`MeasurableEquiv.measurableEmbedding`, `MeasurableEmbedding.subtype_coe`, and
`MeasurableEmbedding.comp`. -/
structure MeasurableEmbedding [MeasurableSpace α] [MeasurableSpace β] (f : α → β) : Prop where
/-- A measurable embedding is injective. -/
protected injective : Injective f
/-- A measurable embedding is a measurable function. -/
protected measurable : Measurable f
/-- The image of a measurable set under a measurable embedding is a measurable set. -/
protected measurableSet_image' : ∀ ⦃s⦄, MeasurableSet s → MeasurableSet (f '' s)
attribute [fun_prop] MeasurableEmbedding.measurable
namespace MeasurableEmbedding
variable {mα : MeasurableSpace α} [MeasurableSpace β] [MeasurableSpace γ] {f : α → β} {g : β → γ}
theorem measurableSet_image (hf : MeasurableEmbedding f) :
MeasurableSet (f '' s) ↔ MeasurableSet s :=
⟨fun h => by simpa only [hf.injective.preimage_image] using hf.measurable h, fun h =>
hf.measurableSet_image' h⟩
theorem id : MeasurableEmbedding (id : α → α) :=
⟨injective_id, measurable_id, fun s hs => by rwa [image_id]⟩
theorem comp (hg : MeasurableEmbedding g) (hf : MeasurableEmbedding f) :
MeasurableEmbedding (g ∘ f) :=
⟨hg.injective.comp hf.injective, hg.measurable.comp hf.measurable, fun s hs => by
rwa [image_comp, hg.measurableSet_image, hf.measurableSet_image]⟩
theorem subtype_coe (hs : MeasurableSet s) : MeasurableEmbedding ((↑) : s → α) where
injective := Subtype.coe_injective
measurable := measurable_subtype_coe
measurableSet_image' := fun _ => MeasurableSet.subtype_image hs
theorem measurableSet_range (hf : MeasurableEmbedding f) : MeasurableSet (range f) := by
rw [← image_univ]
exact hf.measurableSet_image' MeasurableSet.univ
theorem measurableSet_preimage (hf : MeasurableEmbedding f) {s : Set β} :
MeasurableSet (f ⁻¹' s) ↔ MeasurableSet (s ∩ range f) := by
rw [← image_preimage_eq_inter_range, hf.measurableSet_image]
theorem measurable_rangeSplitting (hf : MeasurableEmbedding f) :
Measurable (rangeSplitting f) := fun s hs => by
rwa [preimage_rangeSplitting hf.injective,
← (subtype_coe hf.measurableSet_range).measurableSet_image, ← image_comp,
coe_comp_rangeFactorization, hf.measurableSet_image]
theorem measurable_extend (hf : MeasurableEmbedding f) {g : α → γ} {g' : β → γ} (hg : Measurable g)
(hg' : Measurable g') : Measurable (extend f g g') := by
refine measurable_of_restrict_of_restrict_compl hf.measurableSet_range ?_ ?_
· rw [restrict_extend_range]
simpa only [rangeSplitting] using hg.comp hf.measurable_rangeSplitting
· rw [restrict_extend_compl_range]
exact hg'.comp measurable_subtype_coe
theorem exists_measurable_extend (hf : MeasurableEmbedding f) {g : α → γ} (hg : Measurable g)
(hne : β → Nonempty γ) : ∃ g' : β → γ, Measurable g' ∧ g' ∘ f = g :=
⟨extend f g fun x => Classical.choice (hne x),
hf.measurable_extend hg (measurable_const' fun _ _ => rfl),
funext fun _ => hf.injective.extend_apply _ _ _⟩
theorem measurable_comp_iff (hg : MeasurableEmbedding g) : Measurable (g ∘ f) ↔ Measurable f := by
refine ⟨fun H => ?_, hg.measurable.comp⟩
suffices Measurable ((rangeSplitting g ∘ rangeFactorization g) ∘ f) by
rwa [(rightInverse_rangeSplitting hg.injective).comp_eq_id] at this
exact hg.measurable_rangeSplitting.comp H.subtype_mk
end MeasurableEmbedding
section gluing
variable {α₁ α₂ α₃ : Type*} {mα : MeasurableSpace α} {mβ : MeasurableSpace β}
{mα₁ : MeasurableSpace α₁} {mα₂ : MeasurableSpace α₂} {mα₃ : MeasurableSpace α₃}
{i₁ : α₁ → α} {i₂ : α₂ → α} {i₃ : α₃ → α} {s : Set α} {f : α → β}
lemma MeasurableSet.of_union_range_cover (hi₁ : MeasurableEmbedding i₁)
(hi₂ : MeasurableEmbedding i₂) (h : univ ⊆ range i₁ ∪ range i₂)
(hs₁ : MeasurableSet (i₁ ⁻¹' s)) (hs₂ : MeasurableSet (i₂ ⁻¹' s)) : MeasurableSet s := by
convert (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂)
simp [image_preimage_eq_range_inter, ← union_inter_distrib_right,univ_subset_iff.1 h]
lemma MeasurableSet.of_union₃_range_cover (hi₁ : MeasurableEmbedding i₁)
(hi₂ : MeasurableEmbedding i₂) (hi₃ : MeasurableEmbedding i₃)
(h : univ ⊆ range i₁ ∪ range i₂ ∪ range i₃) (hs₁ : MeasurableSet (i₁ ⁻¹' s))
(hs₂ : MeasurableSet (i₂ ⁻¹' s)) (hs₃ : MeasurableSet (i₃ ⁻¹' s)) : MeasurableSet s := by
convert (hi₁.measurableSet_image' hs₁).union (hi₂.measurableSet_image' hs₂) |>.union
(hi₃.measurableSet_image' hs₃)
simp [image_preimage_eq_range_inter, ← union_inter_distrib_right, univ_subset_iff.1 h]
lemma Measurable.of_union_range_cover (hi₁ : MeasurableEmbedding i₁)
(hi₂ : MeasurableEmbedding i₂) (h : univ ⊆ range i₁ ∪ range i₂)
(hf₁ : Measurable (f ∘ i₁)) (hf₂ : Measurable (f ∘ i₂)) : Measurable f :=
fun _s hs ↦ .of_union_range_cover hi₁ hi₂ h (hf₁ hs) (hf₂ hs)
lemma Measurable.of_union₃_range_cover (hi₁ : MeasurableEmbedding i₁)
(hi₂ : MeasurableEmbedding i₂) (hi₃ : MeasurableEmbedding i₃)
(h : univ ⊆ range i₁ ∪ range i₂ ∪ range i₃) (hf₁ : Measurable (f ∘ i₁))
(hf₂ : Measurable (f ∘ i₂)) (hf₃ : Measurable (f ∘ i₃)) : Measurable f :=
fun _s hs ↦ .of_union₃_range_cover hi₁ hi₂ hi₃ h (hf₁ hs) (hf₂ hs) (hf₃ hs)
end gluing
theorem MeasurableSet.exists_measurable_proj {_ : MeasurableSpace α}
(hs : MeasurableSet s) (hne : s.Nonempty) : ∃ f : α → s, Measurable f ∧ ∀ x : s, f x = x :=
let ⟨f, hfm, hf⟩ :=
(MeasurableEmbedding.subtype_coe hs).exists_measurable_extend measurable_id fun _ =>
hne.to_subtype
⟨f, hfm, congr_fun hf⟩
/-- Equivalences between measurable spaces. Main application is the simplification of measurability
statements along measurable equivalences. -/
structure MeasurableEquiv (α β : Type*) [MeasurableSpace α] [MeasurableSpace β] extends α ≃ β where
/-- The forward function of a measurable equivalence is measurable. -/
measurable_toFun : Measurable toEquiv
/-- The inverse function of a measurable equivalence is measurable. -/
measurable_invFun : Measurable toEquiv.symm
@[inherit_doc]
infixl:25 " ≃ᵐ " => MeasurableEquiv
namespace MeasurableEquiv
variable [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ]
theorem toEquiv_injective : Injective (toEquiv : α ≃ᵐ β → α ≃ β) := by
rintro ⟨e₁, _, _⟩ ⟨e₂, _, _⟩ (rfl : e₁ = e₂)
rfl
instance instEquivLike : EquivLike (α ≃ᵐ β) α β where
coe e := e.toEquiv
inv e := e.toEquiv.symm
left_inv e := e.toEquiv.left_inv
right_inv e := e.toEquiv.right_inv
coe_injective' _ _ he _ := toEquiv_injective <| DFunLike.ext' he
@[simp]
theorem coe_toEquiv (e : α ≃ᵐ β) : (e.toEquiv : α → β) = e :=
rfl
@[measurability, fun_prop]
protected theorem measurable (e : α ≃ᵐ β) : Measurable (e : α → β) :=
e.measurable_toFun
@[simp]
theorem coe_mk (e : α ≃ β) (h1 : Measurable e) (h2 : Measurable e.symm) :
((⟨e, h1, h2⟩ : α ≃ᵐ β) : α → β) = e :=
rfl
/-- Any measurable space is equivalent to itself. -/
def refl (α : Type*) [MeasurableSpace α] : α ≃ᵐ α where
toEquiv := Equiv.refl α
measurable_toFun := measurable_id
measurable_invFun := measurable_id
instance instInhabited : Inhabited (α ≃ᵐ α) := ⟨refl α⟩
/-- The composition of equivalences between measurable spaces. -/
def trans (ab : α ≃ᵐ β) (bc : β ≃ᵐ γ) : α ≃ᵐ γ where
toEquiv := ab.toEquiv.trans bc.toEquiv
measurable_toFun := bc.measurable_toFun.comp ab.measurable_toFun
measurable_invFun := ab.measurable_invFun.comp bc.measurable_invFun
theorem coe_trans (ab : α ≃ᵐ β) (bc : β ≃ᵐ γ) : ⇑(ab.trans bc) = bc ∘ ab := rfl
/-- The inverse of an equivalence between measurable spaces. -/
def symm (ab : α ≃ᵐ β) : β ≃ᵐ α where
toEquiv := ab.toEquiv.symm
measurable_toFun := ab.measurable_invFun
measurable_invFun := ab.measurable_toFun
@[simp]
theorem coe_toEquiv_symm (e : α ≃ᵐ β) : (e.toEquiv.symm : β → α) = e.symm :=
rfl
/-- 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 (h : α ≃ᵐ β) : α → β := h
/-- See Note [custom simps projection] -/
def Simps.symm_apply (h : α ≃ᵐ β) : β → α := h.symm
initialize_simps_projections MeasurableEquiv (toFun → apply, invFun → symm_apply)
@[ext] theorem ext {e₁ e₂ : α ≃ᵐ β} (h : (e₁ : α → β) = e₂) : e₁ = e₂ := DFunLike.ext' h
@[simp]
theorem symm_mk (e : α ≃ β) (h1 : Measurable e) (h2 : Measurable e.symm) :
(⟨e, h1, h2⟩ : α ≃ᵐ β).symm = ⟨e.symm, h2, h1⟩ :=
rfl
attribute [simps! apply toEquiv] trans refl
@[simp]
theorem symm_symm (e : α ≃ᵐ β) : e.symm.symm = e := rfl
theorem symm_bijective :
Function.Bijective (MeasurableEquiv.symm : (α ≃ᵐ β) → β ≃ᵐ α) :=
Function.bijective_iff_has_inverse.mpr ⟨_, symm_symm, symm_symm⟩
@[simp]
theorem symm_refl (α : Type*) [MeasurableSpace α] : (refl α).symm = refl α :=
rfl
@[simp]
theorem symm_comp_self (e : α ≃ᵐ β) : e.symm ∘ e = id :=
funext e.left_inv
@[simp]
theorem self_comp_symm (e : α ≃ᵐ β) : e ∘ e.symm = id :=
funext e.right_inv
@[simp]
theorem apply_symm_apply (e : α ≃ᵐ β) (y : β) : e (e.symm y) = y :=
e.right_inv y
@[simp]
theorem symm_apply_apply (e : α ≃ᵐ β) (x : α) : e.symm (e x) = x :=
e.left_inv x
@[simp]
theorem symm_trans_self (e : α ≃ᵐ β) : e.symm.trans e = refl β :=
ext e.self_comp_symm
@[simp]
theorem self_trans_symm (e : α ≃ᵐ β) : e.trans e.symm = refl α :=
ext e.symm_comp_self
protected theorem surjective (e : α ≃ᵐ β) : Surjective e :=
e.toEquiv.surjective
protected theorem bijective (e : α ≃ᵐ β) : Bijective e :=
e.toEquiv.bijective
protected theorem injective (e : α ≃ᵐ β) : Injective e :=
e.toEquiv.injective
@[simp]
theorem symm_preimage_preimage (e : α ≃ᵐ β) (s : Set β) : e.symm ⁻¹' (e ⁻¹' s) = s :=
e.toEquiv.symm_preimage_preimage s
theorem image_eq_preimage_symm (e : α ≃ᵐ β) (s : Set α) : e '' s = e.symm ⁻¹' s :=
e.toEquiv.image_eq_preimage_symm s
lemma preimage_symm (e : α ≃ᵐ β) (s : Set α) : e.symm ⁻¹' s = e '' s :=
(image_eq_preimage_symm ..).symm
lemma image_symm (e : α ≃ᵐ β) (s : Set β) : e.symm '' s = e ⁻¹' s := image_symm_eq_preimage ..
lemma eq_image_iff_symm_image_eq (e : α ≃ᵐ β) (s : Set β) (t : Set α) :
s = e '' t ↔ e.symm '' s = t := by
rw [← coe_toEquiv, Equiv.eq_image_iff_symm_image_eq, coe_toEquiv_symm]
@[simp]
lemma image_preimage (e : α ≃ᵐ β) (s : Set β) : e '' (e ⁻¹' s) = s := by
rw [← coe_toEquiv, Equiv.image_preimage]
@[simp]
lemma preimage_image (e : α ≃ᵐ β) (s : Set α) : e ⁻¹' (e '' s) = s := by
rw [← coe_toEquiv, Equiv.preimage_image]
@[simp]
theorem measurableSet_preimage (e : α ≃ᵐ β) {s : Set β} :
MeasurableSet (e ⁻¹' s) ↔ MeasurableSet s :=
⟨fun h => by simpa only [symm_preimage_preimage] using e.symm.measurable h, fun h =>
e.measurable h⟩
@[simp]
theorem measurableSet_image (e : α ≃ᵐ β) : MeasurableSet (e '' s) ↔ MeasurableSet s := by
rw [image_eq_preimage_symm, measurableSet_preimage]
@[simp] theorem map_eq (e : α ≃ᵐ β) : MeasurableSpace.map e ‹_› = ‹_› :=
e.measurable.le_map.antisymm' fun _s ↦ e.measurableSet_preimage.1
/-- A measurable equivalence is a measurable embedding. -/
protected theorem measurableEmbedding (e : α ≃ᵐ β) : MeasurableEmbedding e where
injective := e.injective
measurable := e.measurable
measurableSet_image' := fun _ => e.measurableSet_image.2
/-- Equal measurable spaces are equivalent. -/
protected def cast {α β} [i₁ : MeasurableSpace α] [i₂ : MeasurableSpace β] (h : α = β)
(hi : i₁ ≍ i₂) : α ≃ᵐ β where
toEquiv := Equiv.cast h
measurable_toFun := by
subst h
subst hi
exact measurable_id
measurable_invFun := by
subst h
subst hi
exact measurable_id
/-- Measurable equivalence between `ULift α` and `α`. -/
def ulift.{u, v} {α : Type u} [MeasurableSpace α] : ULift.{v, u} α ≃ᵐ α :=
⟨Equiv.ulift, measurable_down, measurable_up⟩
protected theorem measurable_comp_iff {f : β → γ} (e : α ≃ᵐ β) :
Measurable (f ∘ e) ↔ Measurable f :=
Iff.intro
(fun hfe => by
have : Measurable (f ∘ (e.symm.trans e).toEquiv) := hfe.comp e.symm.measurable
rwa [coe_toEquiv, symm_trans_self] at this)
fun h => h.comp e.measurable
/-- Any two types with unique elements are measurably equivalent. -/
def ofUniqueOfUnique (α β : Type*) [MeasurableSpace α] [MeasurableSpace β] [Unique α] [Unique β] :
α ≃ᵐ β where
toEquiv := ofUnique α β
measurable_toFun := Subsingleton.measurable
measurable_invFun := Subsingleton.measurable
variable [MeasurableSpace δ] in
/-- Products of equivalent measurable spaces are equivalent. -/
def prodCongr (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α × γ ≃ᵐ β × δ where
toEquiv := .prodCongr ab.toEquiv cd.toEquiv
measurable_toFun :=
(ab.measurable_toFun.comp measurable_id.fst).prodMk
(cd.measurable_toFun.comp measurable_id.snd)
measurable_invFun :=
(ab.measurable_invFun.comp measurable_id.fst).prodMk
(cd.measurable_invFun.comp measurable_id.snd)
/-- Products of measurable spaces are symmetric. -/
def prodComm : α × β ≃ᵐ β × α where
toEquiv := .prodComm α β
measurable_toFun := measurable_id.snd.prodMk measurable_id.fst
measurable_invFun := measurable_id.snd.prodMk measurable_id.fst
/-- Products of measurable spaces are associative. -/
def prodAssoc : (α × β) × γ ≃ᵐ α × β × γ where
toEquiv := .prodAssoc α β γ
measurable_toFun := measurable_fst.fst.prodMk <| measurable_fst.snd.prodMk measurable_snd
measurable_invFun := (measurable_fst.prodMk measurable_snd.fst).prodMk measurable_snd.snd
/-- `PUnit` is a left identity for product of measurable spaces up to a measurable equivalence. -/
def punitProd : PUnit × α ≃ᵐ α where
toEquiv := Equiv.punitProd α
measurable_toFun := measurable_snd
measurable_invFun := measurable_prodMk_left
/-- `PUnit` is a right identity for product of measurable spaces up to a measurable equivalence. -/
def prodPUnit : α × PUnit ≃ᵐ α where
toEquiv := Equiv.prodPUnit α
measurable_toFun := measurable_fst
measurable_invFun := measurable_prodMk_right
variable [MeasurableSpace δ] in
/-- Sums of measurable spaces are symmetric. -/
def sumCongr (ab : α ≃ᵐ β) (cd : γ ≃ᵐ δ) : α ⊕ γ ≃ᵐ β ⊕ δ where
toEquiv := .sumCongr ab.toEquiv cd.toEquiv
measurable_toFun := ab.measurable.sumMap cd.measurable
measurable_invFun := ab.symm.measurable.sumMap cd.symm.measurable
/-- `s ×ˢ t ≃ (s × t)` as measurable spaces. -/
def Set.prod (s : Set α) (t : Set β) : ↥(s ×ˢ t) ≃ᵐ s × t where
toEquiv := Equiv.Set.prod s t
measurable_toFun :=
measurable_id.subtype_val.fst.subtype_mk.prodMk measurable_id.subtype_val.snd.subtype_mk
measurable_invFun :=
Measurable.subtype_mk <| measurable_id.fst.subtype_val.prodMk measurable_id.snd.subtype_val
/-- `univ α ≃ α` as measurable spaces. -/
def Set.univ (α : Type*) [MeasurableSpace α] : (univ : Set α) ≃ᵐ α where
toEquiv := Equiv.Set.univ α
measurable_toFun := measurable_id.subtype_val
measurable_invFun := measurable_id.subtype_mk
/-- `{a} ≃ Unit` as measurable spaces. -/
def Set.singleton (a : α) : ({a} : Set α) ≃ᵐ Unit where
toEquiv := Equiv.Set.singleton a
measurable_toFun := measurable_const
measurable_invFun := measurable_const
/-- `α` is equivalent to its image in `α ⊕ β` as measurable spaces. -/
def Set.rangeInl : (range Sum.inl : Set (α ⊕ β)) ≃ᵐ α where
toEquiv := Equiv.Set.rangeInl α β
measurable_toFun s (hs : MeasurableSet s) := by
refine ⟨_, hs.inl_image, Set.ext ?_⟩
simp
measurable_invFun := Measurable.subtype_mk measurable_inl
/-- `β` is equivalent to its image in `α ⊕ β` as measurable spaces. -/
def Set.rangeInr : (range Sum.inr : Set (α ⊕ β)) ≃ᵐ β where
toEquiv := Equiv.Set.rangeInr α β
measurable_toFun s (hs : MeasurableSet s) := by
refine ⟨_, hs.inr_image, Set.ext ?_⟩
simp
measurable_invFun := Measurable.subtype_mk measurable_inr
/-- Products distribute over sums (on the right) as measurable spaces. -/
def sumProdDistrib (α β γ) [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] :
(α ⊕ β) × γ ≃ᵐ (α × γ) ⊕ (β × γ) where
toEquiv := .sumProdDistrib α β γ
measurable_toFun := by
refine
measurable_of_measurable_union_cover (range Sum.inl ×ˢ (univ : Set γ))
(range Sum.inr ×ˢ (univ : Set γ)) (measurableSet_range_inl.prod MeasurableSet.univ)
(measurableSet_range_inr.prod MeasurableSet.univ)
(by rintro ⟨a | b, c⟩ <;> simp [Set.prod_eq]) ?_ ?_
· refine (Set.prod (range Sum.inl) univ).symm.measurable_comp_iff.1 ?_
refine (prodCongr Set.rangeInl (Set.univ _)).symm.measurable_comp_iff.1 ?_
exact measurable_inl
· refine (Set.prod (range Sum.inr) univ).symm.measurable_comp_iff.1 ?_
refine (prodCongr Set.rangeInr (Set.univ _)).symm.measurable_comp_iff.1 ?_
exact measurable_inr
measurable_invFun :=
measurable_fun_sum ((measurable_inl.comp measurable_fst).prodMk measurable_snd)
((measurable_inr.comp measurable_fst).prodMk measurable_snd)
/-- Products distribute over sums (on the left) as measurable spaces. -/
def prodSumDistrib (α β γ) [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] :
α × (β ⊕ γ) ≃ᵐ (α × β) ⊕ (α × γ) :=
prodComm.trans <| (sumProdDistrib _ _ _).trans <| sumCongr prodComm prodComm
/-- Products distribute over sums as measurable spaces. -/
def sumProdSum (α β γ δ) [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ]
[MeasurableSpace δ] : (α ⊕ β) × (γ ⊕ δ) ≃ᵐ ((α × γ) ⊕ (α × δ)) ⊕ ((β × γ) ⊕ (β × δ)) :=
(sumProdDistrib _ _ _).trans <| sumCongr (prodSumDistrib _ _ _) (prodSumDistrib _ _ _)
variable {π π' : δ' → Type*} [∀ x, MeasurableSpace (π x)] [∀ x, MeasurableSpace (π' x)]
/-- A family of measurable equivalences `Π a, β₁ a ≃ᵐ β₂ a` generates a measurable equivalence
between `Π a, β₁ a` and `Π a, β₂ a`. -/
def piCongrRight (e : ∀ a, π a ≃ᵐ π' a) : (∀ a, π a) ≃ᵐ ∀ a, π' a where
toEquiv := .piCongrRight fun a => (e a).toEquiv
measurable_toFun :=
measurable_pi_lambda _ fun i => (e i).measurable_toFun.comp (measurable_pi_apply i)
measurable_invFun :=
measurable_pi_lambda _ fun i => (e i).measurable_invFun.comp (measurable_pi_apply i)
variable (π) in
/-- Moving a dependent type along an equivalence of coordinates, as a measurable equivalence. -/
def piCongrLeft (f : δ ≃ δ') : (∀ b, π (f b)) ≃ᵐ ∀ a, π a where
__ := Equiv.piCongrLeft π f
measurable_toFun := measurable_piCongrLeft f
measurable_invFun := by
rw [measurable_pi_iff]
exact fun i => measurable_pi_apply (f i)
theorem coe_piCongrLeft (f : δ ≃ δ') :
⇑(MeasurableEquiv.piCongrLeft π f) = f.piCongrLeft π := by rfl
lemma piCongrLeft_apply_apply {ι ι' : Type*} (e : ι ≃ ι') {β : ι' → Type*}
[∀ i', MeasurableSpace (β i')] (x : (i : ι) → β (e i)) (i : ι) :
piCongrLeft (fun i' ↦ β i') e x (e i) = x i := by
rw [piCongrLeft, coe_mk, Equiv.piCongrLeft_apply_apply]
/-- The isomorphism `(γ → α × β) ≃ (γ → α) × (γ → β)` as a measurable equivalence. -/
def arrowProdEquivProdArrow (α β γ : Type*) [MeasurableSpace α] [MeasurableSpace β] :
(γ → α × β) ≃ᵐ (γ → α) × (γ → β) where
__ := Equiv.arrowProdEquivProdArrow γ _ _
measurable_toFun := by
dsimp [Equiv.arrowProdEquivProdArrow]
fun_prop
measurable_invFun := by
dsimp [Equiv.arrowProdEquivProdArrow]
fun_prop
/-- The measurable equivalence `(α₁ → β₁) ≃ᵐ (α₂ → β₂)` induced by `α₁ ≃ α₂` and `β₁ ≃ᵐ β₂`. -/
def arrowCongr' {α₁ β₁ α₂ β₂ : Type*} [MeasurableSpace β₁] [MeasurableSpace β₂]
(hα : α₁ ≃ α₂) (hβ : β₁ ≃ᵐ β₂) :
(α₁ → β₁) ≃ᵐ (α₂ → β₂) where
__ := Equiv.arrowCongr' hα hβ
measurable_toFun _ h := by
exact MeasurableSet.preimage h <|
measurable_pi_iff.mpr fun _ ↦ hβ.measurable.comp' (measurable_pi_apply _)
measurable_invFun _ h := by
exact MeasurableSet.preimage h <|
measurable_pi_iff.mpr fun _ ↦ hβ.symm.measurable.comp' (measurable_pi_apply _)
/-- Pi-types are measurably equivalent to iterated products. -/
@[simps! -fullyApplied]
def piMeasurableEquivTProd [DecidableEq δ'] {l : List δ'} (hnd : l.Nodup) (h : ∀ i, i ∈ l) :
(∀ i, π i) ≃ᵐ List.TProd π l where
toEquiv := List.TProd.piEquivTProd hnd h
measurable_toFun := measurable_tProd_mk l
measurable_invFun := measurable_tProd_elim' h
variable (π) in
/-- The measurable equivalence `(∀ i, π i) ≃ᵐ π ⋆` when the domain of `π` only contains `⋆` -/
@[simps! -fullyApplied]
def piUnique [Unique δ'] : (∀ i, π i) ≃ᵐ π default where
toEquiv := Equiv.piUnique π
measurable_toFun := measurable_pi_apply _
measurable_invFun := measurable_uniqueElim
/-- If `α` has a unique term, then the type of function `α → β` is measurably equivalent to `β`. -/
@[simps! -fullyApplied]
def funUnique (α β : Type*) [Unique α] [MeasurableSpace β] : (α → β) ≃ᵐ β :=
MeasurableEquiv.piUnique _
/-- The space `Π i : Fin 2, α i` is measurably equivalent to `α 0 × α 1`. -/
@[simps! -fullyApplied]
def piFinTwo (α : Fin 2 → Type*) [∀ i, MeasurableSpace (α i)] : (∀ i, α i) ≃ᵐ α 0 × α 1 where
toEquiv := piFinTwoEquiv α
measurable_toFun := Measurable.prod (measurable_pi_apply _) (measurable_pi_apply _)
measurable_invFun := measurable_pi_iff.2 <| Fin.forall_fin_two.2 ⟨measurable_fst, measurable_snd⟩
/-- The space `Fin 2 → α` is measurably equivalent to `α × α`. -/
@[simps! -fullyApplied]
def finTwoArrow : (Fin 2 → α) ≃ᵐ α × α :=
piFinTwo fun _ => α
/-- Measurable equivalence between `Π j : Fin (n + 1), α j` and
`α i × Π j : Fin n, α (Fin.succAbove i j)`.
Measurable version of `Fin.insertNthEquiv`. -/
@[simps! -fullyApplied]
def piFinSuccAbove {n : ℕ} (α : Fin (n + 1) → Type*) [∀ i, MeasurableSpace (α i)]
(i : Fin (n + 1)) : (∀ j, α j) ≃ᵐ α i × ∀ j, α (i.succAbove j) where
toEquiv := (Fin.insertNthEquiv α i).symm
measurable_toFun := (measurable_pi_apply i).prodMk <| measurable_pi_iff.2 fun _ =>
measurable_pi_apply _
measurable_invFun := measurable_pi_iff.2 <| i.forall_iff_succAbove.2
⟨by simp [measurable_fst], fun j => by simpa using (measurable_pi_apply _).comp measurable_snd⟩
variable (π)
/-- Measurable equivalence between (dependent) functions on a type and pairs of functions on
`{i // p i}` and `{i // ¬p i}`. See also `Equiv.piEquivPiSubtypeProd`. -/
@[simps! -fullyApplied]
def piEquivPiSubtypeProd (p : δ' → Prop) [DecidablePred p] :
(∀ i, π i) ≃ᵐ (∀ i : Subtype p, π i) × ∀ i : { i // ¬p i }, π i where
toEquiv := .piEquivPiSubtypeProd p π
measurable_toFun := measurable_piEquivPiSubtypeProd π p
measurable_invFun := measurable_piEquivPiSubtypeProd_symm π p
/-- The measurable equivalence between the pi type over a sum type and a product of pi-types.
This is similar to `MeasurableEquiv.piEquivPiSubtypeProd`. -/
def sumPiEquivProdPi (α : δ ⊕ δ' → Type*) [∀ i, MeasurableSpace (α i)] :
(∀ i, α i) ≃ᵐ (∀ i, α (.inl i)) × ∀ i', α (.inr i') where
__ := Equiv.sumPiEquivProdPi α
measurable_toFun := by
apply Measurable.prod <;> rw [measurable_pi_iff] <;> rintro i <;> apply measurable_pi_apply
measurable_invFun := by
rw [measurable_pi_iff]; rintro (i | i)
· exact measurable_pi_iff.1 measurable_fst _
· exact measurable_pi_iff.1 measurable_snd _
theorem coe_sumPiEquivProdPi (α : δ ⊕ δ' → Type*) [∀ i, MeasurableSpace (α i)] :
⇑(MeasurableEquiv.sumPiEquivProdPi α) = Equiv.sumPiEquivProdPi α := by rfl
theorem coe_sumPiEquivProdPi_symm (α : δ ⊕ δ' → Type*) [∀ i, MeasurableSpace (α i)] :
⇑(MeasurableEquiv.sumPiEquivProdPi α).symm = (Equiv.sumPiEquivProdPi α).symm := by rfl
/-- The measurable equivalence for (dependent) functions on an Option type
`(∀ i : Option δ, α i) ≃ᵐ (∀ (i : δ), α i) × α none`. -/
def piOptionEquivProd {δ : Type*} (α : Option δ → Type*) [∀ i, MeasurableSpace (α i)] :
(∀ i, α i) ≃ᵐ (∀ (i : δ), α i) × α none :=
let e : Option δ ≃ δ ⊕ Unit := Equiv.optionEquivSumPUnit δ
let em1 : ((i : δ ⊕ Unit) → α (e.symm i)) ≃ᵐ ((a : Option δ) → α a) :=
MeasurableEquiv.piCongrLeft α e.symm
let em2 : ((i : δ ⊕ Unit) → α (e.symm i)) ≃ᵐ ((i : δ) → α (e.symm (Sum.inl i)))
× ((i' : Unit) → α (e.symm (Sum.inr i'))) :=
MeasurableEquiv.sumPiEquivProdPi (fun i ↦ α (e.symm i))
let em3 : ((i : δ) → α (e.symm (Sum.inl i))) × ((i' : Unit) → α (e.symm (Sum.inr i')))
≃ᵐ ((i : δ) → α (some i)) × α none :=
MeasurableEquiv.prodCongr (MeasurableEquiv.refl ((i : δ) → α (e.symm (Sum.inl i))))
(MeasurableEquiv.piUnique fun i ↦ α (e.symm (Sum.inr i)))
em1.symm.trans <| em2.trans em3
/-- The measurable equivalence `(∀ i : s, π i) × (∀ i : t, π i) ≃ᵐ (∀ i : s ∪ t, π i)`
for disjoint finsets `s` and `t`. `Equiv.piFinsetUnion` as a measurable equivalence. -/
def piFinsetUnion [DecidableEq δ'] {s t : Finset δ'} (h : Disjoint s t) :
((∀ i : s, π i) × ∀ i : t, π i) ≃ᵐ ∀ i : (s ∪ t : Finset δ'), π i :=
letI e := Finset.union s t h
MeasurableEquiv.sumPiEquivProdPi (fun b ↦ π (e b)) |>.symm.trans <|
.piCongrLeft (fun i : ↥(s ∪ t) ↦ π i) e
/-- If `s` is a measurable set in a measurable space, that space is equivalent
to the sum of `s` and `sᶜ`. -/
def sumCompl {s : Set α} [DecidablePred (· ∈ s)] (hs : MeasurableSet s) :
s ⊕ (sᶜ : Set α) ≃ᵐ α where
toEquiv := .sumCompl (· ∈ s)
measurable_toFun := measurable_subtype_coe.sumElim measurable_subtype_coe
measurable_invFun := Measurable.dite measurable_inl measurable_inr hs
/-- Convert a measurable involutive function `f` to a measurable permutation with
`toFun = invFun = f`. See also `Function.Involutive.toPerm`. -/
@[simps toEquiv]
def ofInvolutive (f : α → α) (hf : Involutive f) (hf' : Measurable f) : α ≃ᵐ α where
toEquiv := hf.toPerm
measurable_toFun := hf'
measurable_invFun := hf'
@[simp] theorem ofInvolutive_apply (f : α → α) (hf : Involutive f) (hf' : Measurable f) (a : α) :
ofInvolutive f hf hf' a = f a := rfl
@[simp] theorem ofInvolutive_symm (f : α → α) (hf : Involutive f) (hf' : Measurable f) :
(ofInvolutive f hf hf').symm = ofInvolutive f hf hf' := rfl
/-- `setOf` as a `MeasurableEquiv`. -/
@[simps]
protected def setOf {α : Type*} : (α → Prop) ≃ᵐ Set α where
toFun p := {a | p a}
invFun s a := a ∈ s
measurable_toFun := measurable_id
measurable_invFun := measurable_id
@[simp, norm_cast] lemma coe_setOf {α : Type*} : ⇑MeasurableEquiv.setOf = setOf (α := α) := rfl
end MeasurableEquiv
namespace MeasurableEmbedding
variable [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] {f : α → β} {g : β → α}
@[simp] theorem comap_eq (hf : MeasurableEmbedding f) : MeasurableSpace.comap f ‹_› = ‹_› :=
hf.measurable.comap_le.antisymm fun _s h ↦
⟨_, hf.measurableSet_image' h, hf.injective.preimage_image _⟩
theorem iff_comap_eq :
MeasurableEmbedding f ↔
Injective f ∧ MeasurableSpace.comap f ‹_› = ‹_› ∧ MeasurableSet (range f) :=
⟨fun hf ↦ ⟨hf.injective, hf.comap_eq, hf.measurableSet_range⟩, fun hf ↦
{ injective := hf.1
measurable := by rw [← hf.2.1]; exact comap_measurable f
measurableSet_image' := by
rw [← hf.2.1]
rintro _ ⟨s, hs, rfl⟩
simpa only [image_preimage_eq_inter_range] using hs.inter hf.2.2 }⟩
/-- A set is equivalent to its image under a function `f` as measurable spaces,
if `f` is a measurable embedding -/
noncomputable def equivImage (s : Set α) (hf : MeasurableEmbedding f) : s ≃ᵐ f '' s where
toEquiv := Equiv.Set.image f s hf.injective
measurable_toFun := (hf.measurable.comp measurable_id.subtype_val).subtype_mk
measurable_invFun := by
rintro t ⟨u, hu, rfl⟩
simpa [preimage_preimage, Set.image_symm_preimage hf.injective]
using measurable_subtype_coe (hf.measurableSet_image' hu)
/-- The domain of `f` is equivalent to its range as measurable spaces,
if `f` is a measurable embedding -/
noncomputable def equivRange (hf : MeasurableEmbedding f) : α ≃ᵐ range f :=
(MeasurableEquiv.Set.univ _).symm.trans <|
(hf.equivImage univ).trans <| MeasurableEquiv.cast (by rw [image_univ]) (by rw [image_univ])
theorem of_measurable_inverse_on_range {g : range f → α} (hf₁ : Measurable f)
(hf₂ : MeasurableSet (range f)) (hg : Measurable g) (H : LeftInverse g (rangeFactorization f)) :
MeasurableEmbedding f := by
set e : α ≃ᵐ range f :=
⟨⟨rangeFactorization f, g, H, H.rightInverse_of_surjective rangeFactorization_surjective⟩,
hf₁.subtype_mk, hg⟩
exact (MeasurableEmbedding.subtype_coe hf₂).comp e.measurableEmbedding
theorem of_measurable_inverse (hf₁ : Measurable f) (hf₂ : MeasurableSet (range f))
(hg : Measurable g) (H : LeftInverse g f) : MeasurableEmbedding f :=
of_measurable_inverse_on_range hf₁ hf₂ (hg.comp measurable_subtype_coe) H
/-- The **measurable Schröder-Bernstein Theorem**: given measurable embeddings
`α → β` and `β → α`, we can find a measurable equivalence `α ≃ᵐ β`. -/
noncomputable def schroederBernstein {f : α → β} {g : β → α} (hf : MeasurableEmbedding f)
(hg : MeasurableEmbedding g) : α ≃ᵐ β := by
let F : Set α → Set α := fun A => (g '' (f '' A)ᶜ)ᶜ
-- We follow the proof of the usual SB theorem in mathlib,
-- the crux of which is finding a fixed point of this F.
-- However, we must find this fixed point manually instead of invoking Knaster-Tarski
-- in order to make sure it is measurable.
suffices Σ' A : Set α, MeasurableSet A ∧ F A = A by
classical
rcases this with ⟨A, Ameas, Afp⟩
let B := f '' A
have Bmeas : MeasurableSet B := hf.measurableSet_image' Ameas
refine (MeasurableEquiv.sumCompl Ameas).symm.trans
(MeasurableEquiv.trans ?_ (MeasurableEquiv.sumCompl Bmeas))
apply MeasurableEquiv.sumCongr (hf.equivImage _)
have : Aᶜ = g '' Bᶜ := by
apply compl_injective
rw [← Afp]
simp [F, B]
rw [this]
exact (hg.equivImage _).symm
have Fmono : ∀ {A B}, A ⊆ B → F A ⊆ F B := fun h =>
compl_subset_compl.mpr <| Set.image_mono <| compl_subset_compl.mpr <| Set.image_mono h
let X : ℕ → Set α := fun n => F^[n] univ
refine ⟨iInter X, ?_, ?_⟩
· refine MeasurableSet.iInter fun n ↦ ?_
induction n with
| zero => exact MeasurableSet.univ
| succ n ih =>
rw [Function.iterate_succ', Function.comp_apply]
exact (hg.measurableSet_image' (hf.measurableSet_image' ih).compl).compl
apply subset_antisymm
· apply subset_iInter
intro n
cases n
· exact subset_univ _
rw [Function.iterate_succ', Function.comp_apply]
exact Fmono (iInter_subset _ _)
rintro x hx ⟨y, hy, rfl⟩
rw [mem_iInter] at hx
apply hy
rw [hf.injective.injOn.image_iInter_eq]
rw [mem_iInter]
intro n
specialize hx n.succ
rw [Function.iterate_succ', Function.comp_apply] at hx
by_contra h
apply hx
exact ⟨y, h, rfl⟩
@[simp]
lemma equivRange_apply (hf : MeasurableEmbedding f) (x : α) :
hf.equivRange x = ⟨f x, mem_range_self x⟩ := by
simp [MeasurableEmbedding.equivRange, MeasurableEquiv.cast, MeasurableEquiv.Set.univ,
MeasurableEmbedding.equivImage]
@[simp]
lemma equivRange_symm_apply_mk (hf : MeasurableEmbedding f) (x : α) :
hf.equivRange.symm ⟨f x, mem_range_self x⟩ = x := by
nth_rw 3 [← hf.equivRange.symm_apply_apply x]
rw [hf.equivRange_apply]
/-- The left-inverse of a `MeasurableEmbedding` -/
protected noncomputable
def invFun [Nonempty α] (hf : MeasurableEmbedding f) (x : β) : α :=
open Classical in
if hx : x ∈ range f then hf.equivRange.symm ⟨x, hx⟩ else (Nonempty.some inferInstance)
@[fun_prop, measurability]
lemma measurable_invFun [Nonempty α] (hf : MeasurableEmbedding f) :
Measurable (hf.invFun : β → α) :=
open Classical in
Measurable.dite (by fun_prop) measurable_const hf.measurableSet_range
lemma leftInverse_invFun [Nonempty α] (hf : MeasurableEmbedding f) : hf.invFun.LeftInverse f := by
intro x
simp [MeasurableEmbedding.invFun]
end MeasurableEmbedding
theorem MeasurableSpace.comap_compl {m' : MeasurableSpace β} [BooleanAlgebra β]
(h : Measurable (compl : β → β)) (f : α → β) :
MeasurableSpace.comap (fun a => (f a)ᶜ) inferInstance =
MeasurableSpace.comap f inferInstance := by
rw [← Function.comp_def, ← MeasurableSpace.comap_comp]
congr
exact (MeasurableEquiv.ofInvolutive _ compl_involutive h).measurableEmbedding.comap_eq
@[simp] theorem MeasurableSpace.comap_not (p : α → Prop) :
MeasurableSpace.comap (fun a ↦ ¬p a) inferInstance = MeasurableSpace.comap p inferInstance :=
MeasurableSpace.comap_compl (fun _ _ ↦ measurableSet_top) _
section curry
/-! ### Currying as a measurable equivalence -/
namespace MeasurableEquiv
/-- The currying operation `Function.curry` as a measurable equivalence.
See `MeasurableEquiv.curry` for the non-dependent version. -/
@[simps!]
def piCurry {ι : Type*} {κ : ι → Type*} (X : (i : ι) → κ i → Type*)
[∀ i j, MeasurableSpace (X i j)] :
((p : (i : ι) × κ i) → X p.1 p.2) ≃ᵐ ((i : ι) → (j : κ i) → X i j) where
toEquiv := Equiv.piCurry X
measurable_toFun := by fun_prop
measurable_invFun := by fun_prop
lemma coe_piCurry {ι : Type*} {κ : ι → Type*} (X : (i : ι) → κ i → Type*)
[∀ i j, MeasurableSpace (X i j)] : ⇑(piCurry X) = Sigma.curry := rfl
lemma coe_piCurry_symm {ι : Type*} {κ : ι → Type*} (X : (i : ι) → κ i → Type*)
[∀ i j, MeasurableSpace (X i j)] : ⇑(piCurry X).symm = Sigma.uncurry := rfl
/-- The currying operation `Sigma.curry` as a measurable equivalence.
See `MeasurableEquiv.piCurry` for the dependent version. -/
@[simps!]
def curry (ι κ X : Type*) [MeasurableSpace X] : (ι × κ → X) ≃ᵐ (ι → κ → X) where
toEquiv := Equiv.curry ι κ X
measurable_toFun := by fun_prop
measurable_invFun := by fun_prop
lemma coe_curry (ι κ X : Type*) [MeasurableSpace X] : ⇑(curry ι κ X) = Function.curry := rfl
lemma coe_curry_symm (ι κ X : Type*) [MeasurableSpace X] :
⇑(curry ι κ X).symm = Function.uncurry := rfl
end MeasurableEquiv
end curry |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/PreorderRestrict.lean | import Mathlib.MeasureTheory.MeasurableSpace.Constructions
import Mathlib.Order.Restriction
/-!
# Measurability of the restriction function for functions indexed by a preorder
We prove that the map which restricts a function `f : (i : α) → X i` to elements `≤ a` is
measurable.
-/
open MeasureTheory
namespace Preorder
variable {α : Type*} [Preorder α] {X : α → Type*} [∀ a, MeasurableSpace (X a)]
@[measurability, fun_prop]
theorem measurable_restrictLe (a : α) : Measurable (restrictLe (π := X) a) :=
Set.measurable_restrict _
@[measurability, fun_prop]
theorem measurable_restrictLe₂ {a b : α} (hab : a ≤ b) : Measurable (restrictLe₂ (π := X) hab) :=
Set.measurable_restrict₂ _
variable [LocallyFiniteOrderBot α]
@[measurability, fun_prop]
theorem measurable_frestrictLe (a : α) : Measurable (frestrictLe (π := X) a) :=
Finset.measurable_restrict _
@[measurability, fun_prop]
theorem measurable_frestrictLe₂ {a b : α} (hab : a ≤ b) : Measurable (frestrictLe₂ (π := X) hab) :=
Finset.measurable_restrict₂ _
end Preorder |
.lake/packages/mathlib/Mathlib/MeasureTheory/MeasurableSpace/Invariants.lean | import Mathlib.MeasureTheory.MeasurableSpace.Defs
/-!
# σ-algebra of sets invariant under a self-map
In this file we define `MeasurableSpace.invariants (f : α → α)`
to be the σ-algebra of sets `s : Set α` such that
- `s` is measurable w.r.t. the canonical σ-algebra on `α`;
- and `f ⁻ˢ' s = s`.
-/
open Set Function
open scoped MeasureTheory
namespace MeasurableSpace
variable {α : Type*}
/-- Given a self-map `f : α → α`,
`invariants f` is the σ-algebra of measurable sets that are invariant under `f`.
A set `s` is `(invariants f)`-measurable
iff it is measurable w.r.t. the canonical σ-algebra on `α` and `f ⁻¹' s = s`. -/
def invariants [m : MeasurableSpace α] (f : α → α) : MeasurableSpace α :=
{ m ⊓ ⟨fun s ↦ f ⁻¹' s = s, by simp, by simp, fun f hf ↦ by simp [hf]⟩ with
MeasurableSet' := fun s ↦ MeasurableSet[m] s ∧ f ⁻¹' s = s }
variable [MeasurableSpace α]
/-- A set `s` is `(invariants f)`-measurable
iff it is measurable w.r.t. the canonical σ-algebra on `α` and `f ⁻¹' s = s`. -/
theorem measurableSet_invariants {f : α → α} {s : Set α} :
MeasurableSet[invariants f] s ↔ MeasurableSet s ∧ f ⁻¹' s = s :=
.rfl
@[simp]
theorem invariants_id : invariants (id : α → α) = ‹MeasurableSpace α› :=
ext fun _ ↦ ⟨And.left, fun h ↦ ⟨h, rfl⟩⟩
theorem invariants_le (f : α → α) : invariants f ≤ ‹MeasurableSpace α› := fun _ ↦ And.left
theorem inf_le_invariants_comp (f g : α → α) :
invariants f ⊓ invariants g ≤ invariants (f ∘ g) := fun s hs ↦
⟨hs.1.1, by rw [preimage_comp, hs.1.2, hs.2.2]⟩
theorem le_invariants_iterate (f : α → α) (n : ℕ) :
invariants f ≤ invariants (f^[n]) := by
induction n with
| zero => simp [invariants_le]
| succ n ihn => exact le_trans (le_inf ihn le_rfl) (inf_le_invariants_comp _ _)
variable {β : Type*} [MeasurableSpace β]
theorem measurable_invariants_dom {f : α → α} {g : α → β} :
Measurable[invariants f] g ↔ Measurable g ∧ ∀ s, MeasurableSet s → (g ∘ f) ⁻¹' s = g ⁻¹' s := by
simp only [Measurable, ← forall_and]; rfl
theorem measurable_invariants_of_semiconj {fa : α → α} {fb : β → β} {g : α → β} (hg : Measurable g)
(hfg : Semiconj g fa fb) : @Measurable _ _ (invariants fa) (invariants fb) g := fun s hs ↦
⟨hg hs.1, by rw [← preimage_comp, hfg.comp_eq, preimage_comp, hs.2]⟩
theorem comp_eq_of_measurable_invariants {f : α → α} {g : α → β} [MeasurableSingletonClass β]
(h : Measurable[invariants f] g) : g ∘ f = g := by
funext x
suffices x ∈ f⁻¹' (g⁻¹' {g x}) by simpa
rw [(h <| measurableSet_singleton (g x)).2, Set.mem_preimage, Set.mem_singleton_iff]
end MeasurableSpace |
.lake/packages/mathlib/Mathlib/MeasureTheory/Category/MeasCat.lean | import Mathlib.MeasureTheory.Measure.GiryMonad
import Mathlib.CategoryTheory.Monad.Algebra
import Mathlib.Topology.Category.TopCat.Basic
/-!
# The category of measurable spaces
Measurable spaces and measurable functions form a (concrete) category `MeasCat`.
## Main definitions
* `Measure : MeasCat ⥤ MeasCat`: the functor which sends a measurable space `X`
to the space of measures on `X`; it is a monad (the "Giry monad").
* `Borel : TopCat ⥤ MeasCat`: sends a topological space `X` to `X` equipped with the
`σ`-algebra of Borel sets (the `σ`-algebra generated by the open subsets of `X`).
## Tags
measurable space, giry monad, borel
-/
noncomputable section
open CategoryTheory MeasureTheory
open scoped ENNReal
universe u v
/-- The category of measurable spaces and measurable functions. -/
structure MeasCat : Type (u + 1) where
/-- Construct a bundled `MeasCat` from the underlying type and the typeclass. -/
of ::
/-- The underlying measurable space. -/
carrier : Type u
[str : MeasurableSpace carrier]
attribute [instance] MeasCat.str
namespace MeasCat
instance : CoeSort MeasCat Type* :=
⟨carrier⟩
theorem coe_of (X : Type u) [MeasurableSpace X] : (of X : Type u) = X :=
rfl
instance : LargeCategory MeasCat where
Hom X Y := { f : X → Y // Measurable f }
id X := ⟨id, measurable_id⟩
comp f g := ⟨g.1 ∘ f.1, g.2.comp f.2⟩
instance (X Y : MeasCat) : FunLike ({ f : X → Y // Measurable f }) X Y where
coe f := f
coe_injective' _ _ := Subtype.ext
instance : ConcreteCategory MeasCat ({ f : · → · // Measurable f }) where
hom f := f
ofHom f := f
instance : Inhabited MeasCat :=
⟨MeasCat.of Empty⟩
/-- `Measure X` is the measurable space of measures over the measurable space `X`. It is the
weakest measurable space, s.t. `fun μ ↦ μ s` is measurable for all measurable sets `s` in `X`. An
important purpose is to assign a monadic structure on it, the Giry monad. In the Giry monad,
the pure values are the Dirac measure, and the bind operation maps to the integral:
`(μ >>= ν) s = ∫ x. (ν x) s dμ`.
In probability theory, the `MeasCat`-morphisms `X → Prob X` are (sub-)Markov kernels (here `Prob` is
the restriction of `Measure` to (sub-)probability space.)
-/
def Measure : MeasCat ⥤ MeasCat where
obj X := of (@MeasureTheory.Measure X.1 X.2)
map f := ⟨Measure.map (⇑f), Measure.measurable_map f.1 f.2⟩
map_id X := Subtype.eq <| funext fun μ => @Measure.map_id X.carrier X.str μ
map_comp := fun ⟨_, hf⟩ ⟨_, hg⟩ => Subtype.eq <| funext fun _ => (Measure.map_map hg hf).symm
/-- The Giry monad, i.e. the monadic structure associated with `Measure`. -/
def Giry : CategoryTheory.Monad MeasCat where
toFunctor := Measure
η :=
{ app := fun X => ⟨@Measure.dirac X.1 X.2, Measure.measurable_dirac⟩
naturality := fun _ _ ⟨_, hf⟩ => Subtype.eq <| funext fun a => (Measure.map_dirac hf a).symm }
μ :=
{ app := fun X => ⟨@Measure.join X.1 X.2, Measure.measurable_join⟩
naturality := fun _ _ ⟨_, hf⟩ => Subtype.eq <| funext fun μ => Measure.join_map_map hf μ }
assoc _ := Subtype.eq <| funext fun _ => Measure.join_map_join _
left_unit _ := Subtype.eq <| funext fun _ => Measure.join_dirac _
right_unit _ := Subtype.eq <| funext fun _ => Measure.join_map_dirac _
/-- An example for an algebra on `Measure`: the nonnegative Lebesgue integral is a hom, behaving
nicely under the monad operations. -/
def Integral : Giry.Algebra where
A := MeasCat.of ℝ≥0∞
a := ⟨fun m : MeasureTheory.Measure ℝ≥0∞ ↦ ∫⁻ x, x ∂m, Measure.measurable_lintegral measurable_id⟩
unit := Subtype.eq <| funext fun _ : ℝ≥0∞ => lintegral_dirac' _ measurable_id
assoc := Subtype.eq <| funext fun μ : MeasureTheory.Measure (MeasureTheory.Measure ℝ≥0∞) ↦
show ∫⁻ x, x ∂μ.join = ∫⁻ x, x ∂Measure.map (fun m => ∫⁻ x, x ∂m) μ by
rw [Measure.lintegral_join, lintegral_map] <;>
apply_rules [Measurable.aemeasurable, measurable_id, Measure.measurable_lintegral]
end MeasCat
instance TopCat.hasForgetToMeasCat : HasForget₂ TopCat.{u} MeasCat.{u} where
forget₂.obj X := @MeasCat.of _ (borel X)
forget₂.map f := ⟨f.1, f.hom.2.borel_measurable⟩
/-- The Borel functor, the canonical embedding of topological spaces into measurable spaces. -/
abbrev Borel : TopCat.{u} ⥤ MeasCat.{u} :=
forget₂ TopCat.{u} MeasCat.{u} |
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Convolution.lean | import Mathlib.MeasureTheory.Group.Defs
import Mathlib.MeasureTheory.Measure.Prod
/-!
# The multiplicative and additive convolution of measures
In this file we define and prove properties about the convolutions of two measures.
## Main definitions
* `MeasureTheory.Measure.mconv`: The multiplicative convolution of two measures: the map of `*`
under the product measure.
* `MeasureTheory.Measure.conv`: The additive convolution of two measures: the map of `+`
under the product measure.
-/
namespace MeasureTheory
namespace Measure
open scoped ENNReal
variable {M : Type*} [Monoid M] [MeasurableSpace M]
/-- Multiplicative convolution of measures. -/
@[to_additive /-- Additive convolution of measures. -/]
noncomputable def mconv (μ : Measure M) (ν : Measure M) :
Measure M := Measure.map (fun x : M × M ↦ x.1 * x.2) (μ.prod ν)
/-- Scoped notation for the multiplicative convolution of measures. -/
scoped[MeasureTheory] infixr:80 " ∗ₘ " => MeasureTheory.Measure.mconv
/-- Scoped notation for the additive convolution of measures. -/
scoped[MeasureTheory] infixr:80 " ∗ " => MeasureTheory.Measure.conv
@[to_additive]
theorem lintegral_mconv_eq_lintegral_prod [MeasurableMul₂ M] {μ ν : Measure M}
{f : M → ℝ≥0∞} (hf : Measurable f) :
∫⁻ z, f z ∂(μ ∗ₘ ν) = ∫⁻ z, f (z.1 * z.2) ∂(μ.prod ν) := by
rw [mconv, lintegral_map hf measurable_mul]
@[to_additive]
theorem lintegral_mconv [MeasurableMul₂ M] {μ ν : Measure M} [SFinite ν]
{f : M → ℝ≥0∞} (hf : Measurable f) :
∫⁻ z, f z ∂(μ ∗ₘ ν) = ∫⁻ x, ∫⁻ y, f (x * y) ∂ν ∂μ := by
rw [lintegral_mconv_eq_lintegral_prod hf, lintegral_prod _ (by fun_prop)]
@[to_additive]
lemma dirac_mconv [MeasurableMul₂ M] (x : M) (μ : Measure M) [SFinite μ] :
(dirac x) ∗ₘ μ = μ.map (fun y ↦ x * y) := by
unfold mconv
rw [dirac_prod, map_map (by fun_prop) (by fun_prop)]
simp [Function.comp_def]
@[to_additive]
lemma mconv_dirac [MeasurableMul₂ M] (μ : Measure M) [SFinite μ] (x : M) :
μ ∗ₘ (dirac x) = μ.map (fun y ↦ y * x) := by
unfold mconv
rw [prod_dirac, map_map (by fun_prop) (by fun_prop)]
simp [Function.comp_def]
@[to_additive (attr := simp)]
lemma dirac_mconv_dirac [MeasurableMul₂ M] (x y : M) :
(dirac x) ∗ₘ (dirac y) = dirac (x * y) := by
rw [mconv_dirac, map_dirac (by fun_prop)]
/-- Convolution of the dirac measure at 1 with a measure μ returns μ. -/
@[to_additive (attr := simp)
/-- Convolution of the dirac measure at 0 with a measure μ returns μ. -/]
theorem dirac_one_mconv [MeasurableMul₂ M] (μ : Measure M) [SFinite μ] :
(dirac 1) ∗ₘ μ = μ := by
simp [dirac_mconv]
/-- Convolution of a measure μ with the dirac measure at 1 returns μ. -/
@[to_additive (attr := simp)
/-- Convolution of a measure μ with the dirac measure at 0 returns μ. -/]
theorem mconv_dirac_one [MeasurableMul₂ M]
(μ : Measure M) [SFinite μ] : μ ∗ₘ (dirac 1) = μ := by
simp [mconv_dirac]
/-- Convolution of the zero measure with a measure μ returns the zero measure. -/
@[to_additive (attr := simp) /-- Convolution of the zero measure with a measure μ returns
the zero measure. -/]
theorem zero_mconv (μ : Measure M) : (0 : Measure M) ∗ₘ μ = (0 : Measure M) := by
unfold mconv
simp
/-- Convolution of a measure μ with the zero measure returns the zero measure. -/
@[to_additive (attr := simp) /-- Convolution of a measure μ with the zero measure returns the zero
measure. -/]
theorem mconv_zero (μ : Measure M) : μ ∗ₘ (0 : Measure M) = (0 : Measure M) := by
unfold mconv
simp
-- `mconv_smul_right` needs an instance to get `SFinite (c • ν)` from `SFinite ν`,
-- hence it is placed in the `WithDensity` file, where the instance is defined.
@[to_additive conv_smul_left]
theorem mconv_smul_left (μ : Measure M) (ν : Measure M) [SFinite ν] (s : ℝ≥0∞) :
(s • μ) ∗ₘ ν = s • (μ ∗ₘ ν) := by
unfold mconv
rw [← Measure.map_smul, Measure.prod_smul_left]
@[to_additive]
theorem mconv_add [MeasurableMul₂ M] (μ : Measure M) (ν : Measure M) (ρ : Measure M) [SFinite μ]
[SFinite ν] [SFinite ρ] : μ ∗ₘ (ν + ρ) = μ ∗ₘ ν + μ ∗ₘ ρ := by
unfold mconv
rw [prod_add, Measure.map_add]
fun_prop
@[to_additive]
theorem add_mconv [MeasurableMul₂ M] (μ : Measure M) (ν : Measure M) (ρ : Measure M) [SFinite μ]
[SFinite ν] [SFinite ρ] : (μ + ν) ∗ₘ ρ = μ ∗ₘ ρ + ν ∗ₘ ρ := by
unfold mconv
rw [add_prod, Measure.map_add]
fun_prop
/-- To get commutativity, we need the underlying multiplication to be commutative. -/
@[to_additive /-- To get commutativity, we need the underlying addition to be commutative. -/]
theorem mconv_comm {M : Type*} [CommMonoid M] [MeasurableSpace M] [MeasurableMul₂ M] (μ : Measure M)
(ν : Measure M) [SFinite μ] [SFinite ν] : μ ∗ₘ ν = ν ∗ₘ μ := by
unfold mconv
rw [← prod_swap, map_map (by fun_prop)]
· simp [Function.comp_def, mul_comm]
fun_prop
/-- The convolution of s-finite measures is s-finite. -/
@[to_additive /-- The convolution of s-finite measures is s-finite. -/]
instance sfinite_mconv_of_sfinite (μ : Measure M) (ν : Measure M) [SFinite μ] [SFinite ν] :
SFinite (μ ∗ₘ ν) := inferInstanceAs <| SFinite ((μ.prod ν).map fun (x : M × M) ↦ x.1 * x.2)
@[to_additive]
instance finite_of_finite_mconv (μ : Measure M) (ν : Measure M) [IsFiniteMeasure μ]
[IsFiniteMeasure ν] : IsFiniteMeasure (μ ∗ₘ ν) := by
have h : (μ ∗ₘ ν) Set.univ < ⊤ := by
unfold mconv
exact IsFiniteMeasure.measure_univ_lt_top
exact {measure_univ_lt_top := h}
/-- Convolution is associative. -/
@[to_additive /-- Convolution is associative. -/]
theorem mconv_assoc [MeasurableMul₂ M] (μ ν ρ : Measure M)
[SFinite ν] [SFinite ρ] :
(μ ∗ₘ ν) ∗ₘ ρ = μ ∗ₘ (ν ∗ₘ ρ) := by
refine ext_of_lintegral _ fun f hf ↦ ?_
repeat rw [lintegral_mconv (by fun_prop)]
refine lintegral_congr fun x ↦ ?_
rw [lintegral_mconv (by fun_prop)]
repeat refine lintegral_congr fun x ↦ ?_
simp [mul_assoc]
@[to_additive]
instance probabilitymeasure_of_probabilitymeasures_mconv (μ : Measure M) (ν : Measure M)
[MeasurableMul₂ M] [IsProbabilityMeasure μ] [IsProbabilityMeasure ν] :
IsProbabilityMeasure (μ ∗ₘ ν) :=
isProbabilityMeasure_map (by fun_prop)
@[to_additive]
theorem mconv_absolutelyContinuous [MeasurableMul₂ M] {μ ν ρ : Measure M}
[IsMulLeftInvariant ρ] [SFinite ν] (hν : ν ≪ ρ) : μ ∗ₘ ν ≪ ρ := by
refine AbsolutelyContinuous.mk (fun s hs h ↦ ?_)
rw [← lintegral_indicator_one hs, lintegral_mconv (by measurability)]
conv in s.indicator 1 (_ * _) => change s.indicator 1 ((fun y ↦ x * y) y)
simp only [← Set.indicator_comp_right, Pi.one_comp]
conv in ∫⁻ _, _ ∂ν =>
rw [lintegral_indicator_one (by apply MeasurableSet.preimage hs (by fun_prop))]
have h0 (x : M) : ν (HMul.hMul x ⁻¹' s) = 0 := by
apply hν
rw [← map_apply (by fun_prop) hs, IsMulLeftInvariant.map_mul_left_eq_self, h]
simp [h0]
@[to_additive]
lemma map_mconv_monoidHom {M M' : Type*} {mM : MeasurableSpace M} [Monoid M] [MeasurableMul₂ M]
{mM' : MeasurableSpace M'} [Monoid M'] [MeasurableMul₂ M']
{μ ν : Measure M} [SFinite μ] [SFinite ν]
(L : M →* M') (hL : Measurable L) :
(μ ∗ₘ ν).map L = (μ.map L) ∗ₘ (ν.map L) := by
unfold mconv
rw [map_map (by fun_prop) (by fun_prop)]
have : (L ∘ fun p : M × M ↦ p.1 * p.2) = (fun p : M' × M' ↦ p.1 * p.2) ∘ (Prod.map L L) := by
ext; simp
rw [this, ← map_map (by fun_prop) (by fun_prop), ← map_prod_map _ _ (by fun_prop) (by fun_prop)]
lemma map_conv_continuousLinearMap {E F : Type*} [AddCommMonoid E] [AddCommMonoid F]
[Module ℝ E] [Module ℝ F] [TopologicalSpace E] [TopologicalSpace F]
{mE : MeasurableSpace E} [MeasurableAdd₂ E] {mF : MeasurableSpace F} [MeasurableAdd₂ F]
[OpensMeasurableSpace E] [BorelSpace F]
{μ ν : Measure E} [SFinite μ] [SFinite ν]
(L : E →L[ℝ] F) :
(μ ∗ ν).map L = (μ.map L) ∗ (ν.map L) := by
suffices (μ ∗ ν).map (L : E →+ F) = (μ.map (L : E →+ F)) ∗ (ν.map (L : E →+ F)) by simpa
rw [map_conv_addMonoidHom]
rw [AddMonoidHom.coe_coe]
fun_prop
end Measure
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Integral.lean | import Mathlib.MeasureTheory.Integral.Bochner.Basic
import Mathlib.MeasureTheory.Group.Measure
/-!
# Bochner Integration on Groups
We develop properties of integrals with a group as domain.
This file contains properties about integrability and Bochner integration.
-/
namespace MeasureTheory
open Measure TopologicalSpace
open scoped ENNReal
variable {𝕜 M α G E F : Type*} [MeasurableSpace G]
variable [NormedAddCommGroup E] [NormedSpace ℝ E] [NormedAddCommGroup F]
variable {μ : Measure G} {f : G → E} {g : G}
section MeasurableInv
variable [Group G] [MeasurableInv G]
@[to_additive]
theorem Integrable.comp_inv [IsInvInvariant μ] {f : G → F} (hf : Integrable f μ) :
Integrable (fun t => f t⁻¹) μ :=
(hf.mono_measure (map_inv_eq_self μ).le).comp_measurable measurable_inv
@[to_additive]
theorem integral_inv_eq_self (f : G → E) (μ : Measure G) [IsInvInvariant μ] :
∫ x, f x⁻¹ ∂μ = ∫ x, f x ∂μ := by
have h : MeasurableEmbedding fun x : G => x⁻¹ := (MeasurableEquiv.inv G).measurableEmbedding
rw [← h.integral_map, map_inv_eq_self]
@[to_additive]
theorem IntegrableOn.comp_inv [IsInvInvariant μ] {f : G → F} {s : Set G} (hf : IntegrableOn f s μ) :
IntegrableOn (fun x => f x⁻¹) s⁻¹ μ := by
apply (integrable_map_equiv (MeasurableEquiv.inv G) f).mp
have : s⁻¹ = MeasurableEquiv.inv G ⁻¹' s := by simp
rw [this, ← MeasurableEquiv.restrict_map]
simpa using hf
end MeasurableInv
section MeasurableInvOrder
variable [PartialOrder G] [CommGroup G] [IsOrderedMonoid G] [MeasurableInv G]
variable [IsInvInvariant μ]
@[to_additive]
theorem IntegrableOn.comp_inv_Iic {c : G} {f : G → F} (hf : IntegrableOn f (Set.Ici c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Iic c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Ici {c : G} {f : G → F} (hf : IntegrableOn f (Set.Iic c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Ici c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Iio {c : G} {f : G → F} (hf : IntegrableOn f (Set.Ioi c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Iio c) μ := by
simpa using hf.comp_inv
@[to_additive]
theorem IntegrableOn.comp_inv_Ioi {c : G} {f : G → F} (hf : IntegrableOn f (Set.Iio c⁻¹) μ) :
IntegrableOn (fun x => f x⁻¹) (Set.Ioi c) μ := by
simpa using hf.comp_inv
end MeasurableInvOrder
section MeasurableMul
variable [Group G] [MeasurableMul G]
/-- Translating a function by left-multiplication does not change its integral with respect to a
left-invariant measure. -/
@[to_additive
/-- Translating a function by left-addition does not change its integral with respect to a
left-invariant measure. -/]
theorem integral_mul_left_eq_self [IsMulLeftInvariant μ] (f : G → E) (g : G) :
(∫ x, f (g * x) ∂μ) = ∫ x, f x ∂μ := by
have h_mul : MeasurableEmbedding fun x => g * x := (MeasurableEquiv.mulLeft g).measurableEmbedding
rw [← h_mul.integral_map, map_mul_left_eq_self]
/-- Translating a function by right-multiplication does not change its integral with respect to a
right-invariant measure. -/
@[to_additive
/-- Translating a function by right-addition does not change its integral with respect to a
right-invariant measure. -/]
theorem integral_mul_right_eq_self [IsMulRightInvariant μ] (f : G → E) (g : G) :
(∫ x, f (x * g) ∂μ) = ∫ x, f x ∂μ := by
have h_mul : MeasurableEmbedding fun x => x * g :=
(MeasurableEquiv.mulRight g).measurableEmbedding
rw [← h_mul.integral_map, map_mul_right_eq_self]
@[to_additive]
theorem integral_div_right_eq_self [IsMulRightInvariant μ] (f : G → E) (g : G) :
(∫ x, f (x / g) ∂μ) = ∫ x, f x ∂μ := by
simp_rw [div_eq_mul_inv, integral_mul_right_eq_self f g⁻¹]
/-- If some left-translate of a function negates it, then the integral of the function with respect
to a left-invariant measure is 0. -/
@[to_additive
/-- If some left-translate of a function negates it, then the integral of the function with
respect to a left-invariant measure is 0. -/]
theorem integral_eq_zero_of_mul_left_eq_neg [IsMulLeftInvariant μ] (hf' : ∀ x, f (g * x) = -f x) :
∫ x, f x ∂μ = 0 := by
have : IsAddTorsionFree E := .of_noZeroSMulDivisors ℝ E
simp_rw [← self_eq_neg, ← integral_neg, ← hf', integral_mul_left_eq_self]
/-- If some right-translate of a function negates it, then the integral of the function with respect
to a right-invariant measure is 0. -/
@[to_additive
/-- If some right-translate of a function negates it, then the integral of the function with
respect to a right-invariant measure is 0. -/]
theorem integral_eq_zero_of_mul_right_eq_neg [IsMulRightInvariant μ] (hf' : ∀ x, f (x * g) = -f x) :
∫ x, f x ∂μ = 0 := by
have : IsAddTorsionFree E := .of_noZeroSMulDivisors ℝ E
simp_rw [← self_eq_neg, ← integral_neg, ← hf', integral_mul_right_eq_self]
@[to_additive]
theorem Integrable.comp_mul_left {f : G → F} [IsMulLeftInvariant μ] (hf : Integrable f μ) (g : G) :
Integrable (fun t => f (g * t)) μ :=
(hf.mono_measure (map_mul_left_eq_self μ g).le).comp_measurable <| measurable_const_mul g
@[to_additive]
theorem Integrable.comp_mul_right {f : G → F} [IsMulRightInvariant μ] (hf : Integrable f μ)
(g : G) : Integrable (fun t => f (t * g)) μ :=
(hf.mono_measure (map_mul_right_eq_self μ g).le).comp_measurable <| measurable_mul_const g
@[to_additive]
theorem Integrable.comp_div_right {f : G → F} [IsMulRightInvariant μ] (hf : Integrable f μ)
(g : G) : Integrable (fun t => f (t / g)) μ := by
simp_rw [div_eq_mul_inv]
exact hf.comp_mul_right g⁻¹
variable [MeasurableInv G]
@[to_additive]
theorem Integrable.comp_div_left {f : G → F} [IsInvInvariant μ] [IsMulLeftInvariant μ]
(hf : Integrable f μ) (g : G) : Integrable (fun t => f (g / t)) μ :=
((measurePreserving_div_left μ g).integrable_comp hf.aestronglyMeasurable).mpr hf
@[to_additive]
theorem integrable_comp_div_left (f : G → F) [IsInvInvariant μ] [IsMulLeftInvariant μ] (g : G) :
Integrable (fun t => f (g / t)) μ ↔ Integrable f μ := by
refine ⟨fun h => ?_, fun h => h.comp_div_left g⟩
convert h.comp_inv.comp_mul_left g⁻¹
simp_rw [div_inv_eq_mul, mul_inv_cancel_left]
@[to_additive]
theorem integral_div_left_eq_self (f : G → E) (μ : Measure G) [IsInvInvariant μ]
[IsMulLeftInvariant μ] (x' : G) : (∫ x, f (x' / x) ∂μ) = ∫ x, f x ∂μ := by
simp_rw [div_eq_mul_inv, integral_inv_eq_self (fun x => f (x' * x)) μ,
integral_mul_left_eq_self f x']
end MeasurableMul
section SMul
variable [Group G] [MeasurableSpace α] [MulAction G α] [MeasurableSMul G α]
@[to_additive]
theorem integral_smul_eq_self {μ : Measure α} [SMulInvariantMeasure G α μ] (f : α → E) {g : G} :
(∫ x, f (g • x) ∂μ) = ∫ x, f x ∂μ := by
have h : MeasurableEmbedding fun x : α => g • x := (MeasurableEquiv.smul g).measurableEmbedding
rw [← h.integral_map, MeasureTheory.map_smul]
end SMul
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/AEStabilizer.lean | import Mathlib.MeasureTheory.Group.Action
import Mathlib.Order.Filter.EventuallyConst
/-!
# A.e. stabilizer of a set
In this file we define the a.e. stabilizer of a set under a measure-preserving group action.
The a.e. stabilizer `MulAction.aestabilizer G μ s` of a set `s`
is the set of the elements `g : G` such that `s` is a.e.-invariant under `(g • ·)`.
For a measure-preserving group action, this set is a subgroup of `G`.
If the set is null or conull, then this subgroup is the whole group.
The converse is true for an ergodic action and a null-measurable set.
## Implementation notes
We define the a.e. stabilizer as a bundled `Subgroup`,
thus we do not deal with monoid actions.
Also, many lemmas in this file are true for a *quasi-measure-preserving* action,
but we don't have the corresponding typeclass.
-/
open Filter Set MeasureTheory
open scoped Pointwise
variable (G : Type*) {α : Type*} [Group G] [MulAction G α]
{_ : MeasurableSpace α} (μ : Measure α) [SMulInvariantMeasure G α μ]
namespace MulAction
/-- A.e. stabilizer of a set under a group action. -/
@[to_additive (attr := simps) /-- A.e. stabilizer of a set under an additive group action. -/]
def aestabilizer (s : Set α) : Subgroup G where
carrier := {g | g • s =ᵐ[μ] s}
one_mem' := by simp
-- TODO: `calc` would be more readable but fails because of defeq abuse
mul_mem' {g₁ g₂} h₁ h₂ := by simpa only [smul_smul] using ((smul_set_ae_eq g₁).2 h₂).trans h₁
inv_mem' {g} h := by simpa using (smul_set_ae_eq g⁻¹).2 h.out.symm
variable {G μ}
variable {g : G} {s t : Set α}
@[to_additive (attr := simp)]
lemma mem_aestabilizer : g ∈ aestabilizer G μ s ↔ g • s =ᵐ[μ] s := .rfl
@[to_additive]
lemma stabilizer_le_aestabilizer (s : Set α) : stabilizer G s ≤ aestabilizer G μ s := by
intro g hg
simp_all
@[to_additive (attr := simp)]
lemma aestabilizer_empty : aestabilizer G μ ∅ = ⊤ := top_unique fun _ _ ↦ by simp
@[to_additive (attr := simp)]
lemma aestabilizer_univ : aestabilizer G μ univ = ⊤ := top_unique fun _ _ ↦ by simp
@[to_additive]
lemma aestabilizer_congr (h : s =ᵐ[μ] t) : aestabilizer G μ s = aestabilizer G μ t := by
ext g
rw [mem_aestabilizer, mem_aestabilizer, h.congr_right, ((smul_set_ae_eq g).2 h).congr_left]
lemma aestabilizer_of_aeconst (hs : EventuallyConst s (ae μ)) : aestabilizer G μ s = ⊤ := by
refine top_unique fun g _ ↦ ?_
cases eventuallyConst_set'.mp hs with
| inl h => simp [aestabilizer_congr h]
| inr h => simp [aestabilizer_congr h]
end MulAction
variable {G μ}
variable {x y : G} {s : Set α}
namespace MeasureTheory
@[to_additive]
theorem smul_ae_eq_self_of_mem_zpowers (hs : (x • s : Set α) =ᵐ[μ] s)
(hy : y ∈ Subgroup.zpowers x) : (y • s : Set α) =ᵐ[μ] s := by
rw [← MulAction.mem_aestabilizer, ← Subgroup.zpowers_le] at hs
exact hs hy
@[to_additive]
theorem inv_smul_ae_eq_self (hs : (x • s : Set α) =ᵐ[μ] s) : (x⁻¹ • s : Set α) =ᵐ[μ] s :=
inv_mem (s := MulAction.aestabilizer G μ s) hs
end MeasureTheory |
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/AddCircle.lean | import Mathlib.MeasureTheory.Integral.IntervalIntegral.Periodic
import Mathlib.Data.ZMod.QuotientGroup
import Mathlib.MeasureTheory.Group.AEStabilizer
/-!
# Measure-theoretic results about the additive circle
The file is a place to collect measure-theoretic results about the additive circle.
## Main definitions:
* `AddCircle.closedBall_ae_eq_ball`: open and closed balls in the additive circle are almost
equal
* `AddCircle.isAddFundamentalDomain_of_ae_ball`: a ball is a fundamental domain for rational
angle rotation in the additive circle
-/
open Set Function Filter MeasureTheory MeasureTheory.Measure Metric
open scoped Finset MeasureTheory Pointwise Topology ENNReal
namespace AddCircle
variable {T : ℝ} [hT : Fact (0 < T)]
theorem closedBall_ae_eq_ball {x : AddCircle T} {ε : ℝ} : closedBall x ε =ᵐ[volume] ball x ε := by
rcases le_or_gt ε 0 with hε | hε
· rw [ball_eq_empty.mpr hε, ae_eq_empty, volume_closedBall,
min_eq_right (by linarith [hT.out] : 2 * ε ≤ T), ENNReal.ofReal_eq_zero]
exact mul_nonpos_of_nonneg_of_nonpos zero_le_two hε
· suffices volume (closedBall x ε) ≤ volume (ball x ε) from
(ae_eq_of_subset_of_measure_ge ball_subset_closedBall this
measurableSet_ball.nullMeasurableSet (measure_ne_top _ _)).symm
have : Tendsto (fun δ => volume (closedBall x δ)) (𝓝[<] ε) (𝓝 <| volume (closedBall x ε)) := by
simp_rw [volume_closedBall]
refine ENNReal.tendsto_ofReal (Tendsto.min tendsto_const_nhds <| Tendsto.const_mul _ ?_)
exact nhdsWithin_le_nhds
refine le_of_tendsto this <| mem_of_superset (Ioo_mem_nhdsLT hε) fun r hr ↦ ?_
exact measure_mono (closedBall_subset_ball hr.2)
/-- Let `G` be the subgroup of `AddCircle T` generated by a point `u` of finite order `n : ℕ`. Then
any set `I` that is almost equal to a ball of radius `T / 2n` is a fundamental domain for the action
of `G` on `AddCircle T` by left addition. -/
theorem isAddFundamentalDomain_of_ae_ball (I : Set <| AddCircle T) (u x : AddCircle T)
(hu : IsOfFinAddOrder u) (hI : I =ᵐ[volume] ball x (T / (2 * addOrderOf u))) :
IsAddFundamentalDomain (AddSubgroup.zmultiples u) I := by
set G := AddSubgroup.zmultiples u
set n := addOrderOf u
set B := ball x (T / (2 * n))
have hn : 1 ≤ (n : ℝ) := by norm_cast; linarith [hu.addOrderOf_pos]
refine IsAddFundamentalDomain.mk_of_measure_univ_le ?_ ?_ ?_ ?_
· -- `NullMeasurableSet I volume`
exact measurableSet_ball.nullMeasurableSet.congr hI.symm
· -- `∀ (g : G), g ≠ 0 → AEDisjoint volume (g +ᵥ I) I`
rintro ⟨g, hg⟩ hg'
replace hg' : g ≠ 0 := by simpa only [Ne, AddSubgroup.mk_eq_zero] using hg'
change AEDisjoint volume (g +ᵥ I) I
refine AEDisjoint.congr (Disjoint.aedisjoint ?_)
((quasiMeasurePreserving_add_left volume (-g)).vadd_ae_eq_of_ae_eq g hI) hI
have hBg : g +ᵥ B = ball (g + x) (T / (2 * n)) := by
rw [add_comm g x, ← singleton_add_ball _ x g, add_ball, thickening_singleton]
rw [hBg]
apply ball_disjoint_ball
rw [dist_eq_norm, add_sub_cancel_right, div_mul_eq_div_div, ← add_div, ← add_div,
add_self_div_two, div_le_iff₀' (by positivity : 0 < (n : ℝ)), ← nsmul_eq_mul]
refine (le_add_order_smul_norm_of_isOfFinAddOrder (hu.of_mem_zmultiples hg) hg').trans
(nsmul_le_nsmul_left (norm_nonneg g) ?_)
exact Nat.le_of_dvd (addOrderOf_pos_iff.mpr hu) (addOrderOf_dvd_of_mem_zmultiples hg)
· -- `∀ (g : G), QuasiMeasurePreserving (VAdd.vadd g) volume volume`
exact fun g => quasiMeasurePreserving_add_left (G := AddCircle T) volume g
· -- `volume univ ≤ ∑' (g : G), volume (g +ᵥ I)`
replace hI := hI.trans closedBall_ae_eq_ball.symm
haveI : Fintype G := @Fintype.ofFinite _ hu.finite_zmultiples.to_subtype
have hG_card : #(Finset.univ : Finset G) = n := by
change _ = addOrderOf u
rw [← Nat.card_zmultiples, Nat.card_eq_fintype_card]; rfl
simp_rw [measure_vadd]
rw [AddCircle.measure_univ, tsum_fintype, Finset.sum_const, measure_congr hI,
volume_closedBall, ← ENNReal.ofReal_nsmul, mul_div, mul_div_mul_comm,
div_self, one_mul, min_eq_right (div_le_self hT.out.le hn), hG_card,
nsmul_eq_mul, mul_div_cancel₀ T (lt_of_lt_of_le zero_lt_one hn).ne.symm]
exact two_ne_zero
theorem volume_of_add_preimage_eq (s I : Set <| AddCircle T) (u x : AddCircle T)
(hu : IsOfFinAddOrder u) (hs : (u +ᵥ s : Set <| AddCircle T) =ᵐ[volume] s)
(hI : I =ᵐ[volume] ball x (T / (2 * addOrderOf u))) :
volume s = addOrderOf u • volume (s ∩ I) := by
let G := AddSubgroup.zmultiples u
haveI : Fintype G := @Fintype.ofFinite _ hu.finite_zmultiples.to_subtype
have hsG : ∀ g : G, (g +ᵥ s : Set <| AddCircle T) =ᵐ[volume] s := by
rintro ⟨y, hy⟩; exact (vadd_ae_eq_self_of_mem_zmultiples hs hy :)
rw [(isAddFundamentalDomain_of_ae_ball I u x hu hI).measure_eq_card_smul_of_vadd_ae_eq_self s hsG,
← Nat.card_zmultiples u]
end AddCircle |
.lake/packages/mathlib/Mathlib/MeasureTheory/Group/Prod.lean | import Mathlib.MeasureTheory.Group.Measure
import Mathlib.MeasureTheory.Measure.Prod
/-!
# Measure theory in the product of groups
In this file we show properties about measure theory in products of measurable groups
and properties of iterated integrals in measurable groups.
These lemmas show the uniqueness of left invariant measures on measurable groups, up to
scaling. In this file we follow the proof and refer to the book *Measure Theory* by Paul Halmos.
The idea of the proof is to use the translation invariance of measures to prove `μ(t) = c * μ(s)`
for two sets `s` and `t`, where `c` is a constant that does not depend on `μ`. Let `e` and `f` be
the characteristic functions of `s` and `t`.
Assume that `μ` and `ν` are left-invariant measures. Then the map `(x, y) ↦ (y * x, x⁻¹)`
preserves the measure `μ × ν`, which means that
```
∫ x, ∫ y, h x y ∂ν ∂μ = ∫ x, ∫ y, h (y * x) x⁻¹ ∂ν ∂μ
```
If we apply this to `h x y := e x * f y⁻¹ / ν ((fun h ↦ h * y⁻¹) ⁻¹' s)`, we can rewrite the RHS to
`μ(t)`, and the LHS to `c * μ(s)`, where `c = c(ν)` does not depend on `μ`.
Applying this to `μ` and to `ν` gives `μ (t) / μ (s) = ν (t) / ν (s)`, which is the uniqueness up to
scalar multiplication.
The proof in [Halmos] seems to contain an omission in §60 Th. A, see
`MeasureTheory.measure_lintegral_div_measure`.
Note that this theory only applies in measurable groups, i.e., when multiplication and inversion
are measurable. This is not the case in general in locally compact groups, or even in compact
groups, when the topology is not second-countable. For arguments along the same line, but using
continuous functions instead of measurable sets and working in the general locally compact
setting, see the file `Mathlib/MeasureTheory/Measure/Haar/Unique.lean`.
-/
noncomputable section
open Set hiding prod_eq
open Function MeasureTheory
open Filter hiding map
open scoped ENNReal Pointwise MeasureTheory
variable (G : Type*) [MeasurableSpace G]
variable [Group G] [MeasurableMul₂ G]
variable (μ ν : Measure G) [SFinite ν] [SFinite μ] {s : Set G}
/-- The map `(x, y) ↦ (x, xy)` as a `MeasurableEquiv`. -/
@[to_additive /-- The map `(x, y) ↦ (x, x + y)` as a `MeasurableEquiv`. -/]
protected def MeasurableEquiv.shearMulRight [MeasurableInv G] : G × G ≃ᵐ G × G :=
{ Equiv.prodShear (Equiv.refl _) Equiv.mulLeft with
measurable_toFun := measurable_fst.prodMk measurable_mul
measurable_invFun := measurable_fst.prodMk <| measurable_fst.inv.mul measurable_snd }
/-- The map `(x, y) ↦ (x, y / x)` as a `MeasurableEquiv` with as inverse `(x, y) ↦ (x, yx)` -/
@[to_additive
/-- The map `(x, y) ↦ (x, y - x)` as a `MeasurableEquiv` with as inverse `(x, y) ↦ (x, y + x)`. -/]
protected def MeasurableEquiv.shearDivRight [MeasurableInv G] : G × G ≃ᵐ G × G :=
{ Equiv.prodShear (Equiv.refl _) Equiv.divRight with
measurable_toFun := measurable_fst.prodMk <| measurable_snd.div measurable_fst
measurable_invFun := measurable_fst.prodMk <| measurable_snd.mul measurable_fst }
variable {G}
namespace MeasureTheory
open Measure
section LeftInvariant
/-- The multiplicative shear mapping `(x, y) ↦ (x, xy)` preserves the measure `μ × ν`.
This condition is part of the definition of a measurable group in [Halmos, §59].
There, the map in this lemma is called `S`. -/
@[to_additive measurePreserving_prod_add
/-- The shear mapping `(x, y) ↦ (x, x + y)` preserves the measure `μ × ν`. -/]
theorem measurePreserving_prod_mul [IsMulLeftInvariant ν] :
MeasurePreserving (fun z : G × G => (z.1, z.1 * z.2)) (μ.prod ν) (μ.prod ν) :=
(MeasurePreserving.id μ).skew_product measurable_mul <|
Filter.Eventually.of_forall <| map_mul_left_eq_self ν
/-- The map `(x, y) ↦ (y, yx)` sends the measure `μ × ν` to `ν × μ`.
This is the map `SR` in [Halmos, §59].
`S` is the map `(x, y) ↦ (x, xy)` and `R` is `Prod.swap`. -/
@[to_additive measurePreserving_prod_add_swap
/-- The map `(x, y) ↦ (y, y + x)` sends the measure `μ × ν` to `ν × μ`. -/]
theorem measurePreserving_prod_mul_swap [IsMulLeftInvariant μ] :
MeasurePreserving (fun z : G × G => (z.2, z.2 * z.1)) (μ.prod ν) (ν.prod μ) :=
(measurePreserving_prod_mul ν μ).comp measurePreserving_swap
@[to_additive]
theorem measurable_measure_mul_right (hs : MeasurableSet s) :
Measurable fun x => μ ((fun y => y * x) ⁻¹' s) := by
suffices
Measurable fun y =>
μ ((fun x => (x, y)) ⁻¹' ((fun z : G × G => ((1 : G), z.1 * z.2)) ⁻¹' univ ×ˢ s))
by convert this using 1; ext1 x; congr 1 with y : 1; simp
apply measurable_measure_prodMk_right
apply measurable_const.prodMk measurable_mul (MeasurableSet.univ.prod hs)
infer_instance
variable [MeasurableInv G]
/-- The map `(x, y) ↦ (x, x⁻¹y)` is measure-preserving.
This is the function `S⁻¹` in [Halmos, §59],
where `S` is the map `(x, y) ↦ (x, xy)`. -/
@[to_additive measurePreserving_prod_neg_add
/-- The map `(x, y) ↦ (x, - x + y)` is measure-preserving. -/]
theorem measurePreserving_prod_inv_mul [IsMulLeftInvariant ν] :
MeasurePreserving (fun z : G × G => (z.1, z.1⁻¹ * z.2)) (μ.prod ν) (μ.prod ν) :=
(measurePreserving_prod_mul μ ν).symm <| MeasurableEquiv.shearMulRight G
variable [IsMulLeftInvariant μ]
/-- The map `(x, y) ↦ (y, y⁻¹x)` sends `μ × ν` to `ν × μ`.
This is the function `S⁻¹R` in [Halmos, §59],
where `S` is the map `(x, y) ↦ (x, xy)` and `R` is `Prod.swap`. -/
@[to_additive measurePreserving_prod_neg_add_swap
/-- The map `(x, y) ↦ (y, - y + x)` sends `μ × ν` to `ν × μ`. -/]
theorem measurePreserving_prod_inv_mul_swap :
MeasurePreserving (fun z : G × G => (z.2, z.2⁻¹ * z.1)) (μ.prod ν) (ν.prod μ) :=
(measurePreserving_prod_inv_mul ν μ).comp measurePreserving_swap
/-- The map `(x, y) ↦ (yx, x⁻¹)` is measure-preserving.
This is the function `S⁻¹RSR` in [Halmos, §59],
where `S` is the map `(x, y) ↦ (x, xy)` and `R` is `Prod.swap`. -/
@[to_additive measurePreserving_add_prod_neg
/-- The map `(x, y) ↦ (y + x, - x)` is measure-preserving. -/]
theorem measurePreserving_mul_prod_inv [IsMulLeftInvariant ν] :
MeasurePreserving (fun z : G × G => (z.2 * z.1, z.1⁻¹)) (μ.prod ν) (μ.prod ν) := by
convert (measurePreserving_prod_inv_mul_swap ν μ).comp (measurePreserving_prod_mul_swap μ ν)
using 1
ext1 ⟨x, y⟩
simp_rw [Function.comp_apply, mul_inv_rev, inv_mul_cancel_right]
@[to_additive (attr := fun_prop)]
theorem quasiMeasurePreserving_inv : QuasiMeasurePreserving (Inv.inv : G → G) μ μ := by
refine ⟨measurable_inv, AbsolutelyContinuous.mk fun s hsm hμs => ?_⟩
rw [map_apply measurable_inv hsm, inv_preimage]
have hf : Measurable fun z : G × G => (z.2 * z.1, z.1⁻¹) :=
(measurable_snd.mul measurable_fst).prodMk measurable_fst.inv
suffices map (fun z : G × G => (z.2 * z.1, z.1⁻¹)) (μ.prod μ) (s⁻¹ ×ˢ s⁻¹) = 0 by
simpa only [(measurePreserving_mul_prod_inv μ μ).map_eq, prod_prod, mul_eq_zero (M₀ := ℝ≥0∞),
or_self_iff] using this
have hsm' : MeasurableSet (s⁻¹ ×ˢ s⁻¹) := hsm.inv.prod hsm.inv
simp_rw [map_apply hf hsm', prod_apply_symm (μ := μ) (ν := μ) (hf hsm'), preimage_preimage,
mk_preimage_prod, inv_preimage, inv_inv, measure_mono_null inter_subset_right hμs,
lintegral_zero]
@[to_additive (attr := simp)]
theorem measure_inv_null : μ s⁻¹ = 0 ↔ μ s = 0 := by
refine ⟨fun hs => ?_, (quasiMeasurePreserving_inv μ).preimage_null⟩
rw [← inv_inv s]
exact (quasiMeasurePreserving_inv μ).preimage_null hs
@[to_additive (attr := simp)]
theorem inv_ae : (ae μ)⁻¹ = ae μ := by
refine le_antisymm (quasiMeasurePreserving_inv μ).tendsto_ae ?_
nth_rewrite 1 [← inv_inv (ae μ)]
exact Filter.map_mono (quasiMeasurePreserving_inv μ).tendsto_ae
@[to_additive (attr := simp)]
theorem eventuallyConst_inv_set_ae :
EventuallyConst (s⁻¹ : Set G) (ae μ) ↔ EventuallyConst s (ae μ) := by
rw [← inv_preimage, eventuallyConst_preimage, Filter.map_inv, inv_ae]
@[to_additive]
theorem inv_absolutelyContinuous : μ.inv ≪ μ :=
(quasiMeasurePreserving_inv μ).absolutelyContinuous
@[to_additive]
theorem absolutelyContinuous_inv : μ ≪ μ.inv := by
refine AbsolutelyContinuous.mk fun s _ => ?_
simp_rw [inv_apply μ s, measure_inv_null, imp_self]
@[to_additive]
theorem lintegral_lintegral_mul_inv [IsMulLeftInvariant ν] (f : G → G → ℝ≥0∞)
(hf : AEMeasurable (uncurry f) (μ.prod ν)) :
(∫⁻ x, ∫⁻ y, f (y * x) x⁻¹ ∂ν ∂μ) = ∫⁻ x, ∫⁻ y, f x y ∂ν ∂μ := by
have h : Measurable fun z : G × G => (z.2 * z.1, z.1⁻¹) :=
(measurable_snd.mul measurable_fst).prodMk measurable_fst.inv
have h2f : AEMeasurable (uncurry fun x y => f (y * x) x⁻¹) (μ.prod ν) :=
hf.comp_quasiMeasurePreserving (measurePreserving_mul_prod_inv μ ν).quasiMeasurePreserving
simp_rw [lintegral_lintegral h2f, lintegral_lintegral hf]
conv_rhs => rw [← (measurePreserving_mul_prod_inv μ ν).map_eq]
symm
exact
lintegral_map' (hf.mono' (measurePreserving_mul_prod_inv μ ν).map_eq.absolutelyContinuous)
h.aemeasurable
@[to_additive]
theorem measure_mul_right_null (y : G) : μ ((fun x => x * y) ⁻¹' s) = 0 ↔ μ s = 0 :=
calc
μ ((fun x => x * y) ⁻¹' s) = 0 ↔ μ ((fun x => y⁻¹ * x) ⁻¹' s⁻¹)⁻¹ = 0 := by
simp_rw [← inv_preimage, preimage_preimage, mul_inv_rev, inv_inv]
_ ↔ μ s = 0 := by simp only [measure_inv_null μ, measure_preimage_mul]
@[to_additive]
theorem measure_mul_right_ne_zero (h2s : μ s ≠ 0) (y : G) : μ ((fun x => x * y) ⁻¹' s) ≠ 0 :=
(not_congr (measure_mul_right_null μ y)).mpr h2s
@[to_additive]
theorem absolutelyContinuous_map_mul_right (g : G) : μ ≪ map (· * g) μ := by
refine AbsolutelyContinuous.mk fun s hs => ?_
rw [map_apply (measurable_mul_const g) hs, measure_mul_right_null]; exact id
@[to_additive]
theorem absolutelyContinuous_map_div_left (g : G) : μ ≪ map (fun h => g / h) μ := by
simp_rw [div_eq_mul_inv]
have := map_map (μ := μ) (measurable_const_mul g) measurable_inv
simp only [Function.comp_def] at this
rw [← this]
conv_lhs => rw [← map_mul_left_eq_self μ g]
exact (absolutelyContinuous_inv μ).map (measurable_const_mul g)
/-- This is the computation performed in the proof of [Halmos, §60 Th. A]. -/
@[to_additive /-- This is the computation performed in the proof of [Halmos, §60 Th. A]. -/]
theorem measure_mul_lintegral_eq [IsMulLeftInvariant ν] (sm : MeasurableSet s) (f : G → ℝ≥0∞)
(hf : Measurable f) : (μ s * ∫⁻ y, f y ∂ν) = ∫⁻ x, ν ((fun z => z * x) ⁻¹' s) * f x⁻¹ ∂μ := by
rw [← setLIntegral_one, ← lintegral_indicator sm,
← lintegral_lintegral_mul (measurable_const.indicator sm).aemeasurable hf.aemeasurable,
← lintegral_lintegral_mul_inv μ ν]
swap
· exact (((measurable_const.indicator sm).comp measurable_fst).mul
(hf.comp measurable_snd)).aemeasurable
have ms :
∀ x : G, Measurable fun y => ((fun z => z * x) ⁻¹' s).indicator (fun _ => (1 : ℝ≥0∞)) y :=
fun x => measurable_const.indicator (measurable_mul_const _ sm)
have : ∀ x y, s.indicator (fun _ : G => (1 : ℝ≥0∞)) (y * x) =
((fun z => z * x) ⁻¹' s).indicator (fun b : G => 1) y := by
intro x y; symm; convert indicator_comp_right (M := ℝ≥0∞) fun y => y * x using 2; ext1; rfl
simp_rw [this, lintegral_mul_const _ (ms _), lintegral_indicator (measurable_mul_const _ sm),
setLIntegral_one]
/-- Any two nonzero left-invariant measures are absolutely continuous w.r.t. each other. -/
@[to_additive
/-- Any two nonzero left-invariant measures are absolutely continuous w.r.t. each other. -/]
theorem absolutelyContinuous_of_isMulLeftInvariant [IsMulLeftInvariant ν] (hν : ν ≠ 0) : μ ≪ ν := by
refine AbsolutelyContinuous.mk fun s sm hνs => ?_
have h1 := measure_mul_lintegral_eq μ ν sm 1 measurable_one
simp_rw [Pi.one_apply, lintegral_one, mul_one, (measure_mul_right_null ν _).mpr hνs,
lintegral_zero, mul_eq_zero (M₀ := ℝ≥0∞), measure_univ_eq_zero.not.mpr hν, or_false] at h1
exact h1
section SigmaFinite
variable (μ' ν' : Measure G) [SigmaFinite μ'] [SigmaFinite ν'] [IsMulLeftInvariant μ']
[IsMulLeftInvariant ν']
@[to_additive]
theorem ae_measure_preimage_mul_right_lt_top (hμs : μ' s ≠ ∞) :
∀ᵐ x ∂μ', ν' ((· * x) ⁻¹' s) < ∞ := by
wlog sm : MeasurableSet s generalizing s
· filter_upwards [this ((measure_toMeasurable _).trans_ne hμs) (measurableSet_toMeasurable ..)]
with x hx using lt_of_le_of_lt (by gcongr; apply subset_toMeasurable) hx
refine ae_of_forall_measure_lt_top_ae_restrict' ν'.inv _ ?_
intro A hA _ h3A
simp only [ν'.inv_apply] at h3A
apply ae_lt_top (measurable_measure_mul_right ν' sm)
have h1 := measure_mul_lintegral_eq μ' ν' sm (A⁻¹.indicator 1) (measurable_one.indicator hA.inv)
rw [lintegral_indicator hA.inv] at h1
simp_rw [Pi.one_apply, setLIntegral_one, ← image_inv_eq_inv, indicator_image inv_injective,
image_inv_eq_inv, ← indicator_mul_right _ fun x => ν' ((· * x) ⁻¹' s), Function.comp,
Pi.one_apply, mul_one] at h1
rw [← lintegral_indicator hA, ← h1]
finiteness
@[to_additive]
theorem ae_measure_preimage_mul_right_lt_top_of_ne_zero (h2s : ν' s ≠ 0) (h3s : ν' s ≠ ∞) :
∀ᵐ x ∂μ', ν' ((fun y => y * x) ⁻¹' s) < ∞ := by
refine (ae_measure_preimage_mul_right_lt_top ν' ν' h3s).filter_mono ?_
refine (absolutelyContinuous_of_isMulLeftInvariant μ' ν' ?_).ae_le
refine mt ?_ h2s
intro hν
rw [hν, Measure.coe_zero, Pi.zero_apply]
/-- A technical lemma relating two different measures. This is basically [Halmos, §60 Th. A].
Note that if `f` is the characteristic function of a measurable set `t` this states that
`μ t = c * μ s` for a constant `c` that does not depend on `μ`.
Note: There is a gap in the last step of the proof in [Halmos].
In the last line, the equality `g(x⁻¹)ν(sx⁻¹) = f(x)` holds if we can prove that
`0 < ν(sx⁻¹) < ∞`. The first inequality follows from §59, Th. D, but the second inequality is
not justified. We prove this inequality for almost all `x` in
`MeasureTheory.ae_measure_preimage_mul_right_lt_top_of_ne_zero`. -/
@[to_additive
/-- A technical lemma relating two different measures. This is basically [Halmos, §60 Th. A]. Note
that if `f` is the characteristic function of a measurable set `t` this states that `μ t = c * μ s`
for a constant `c` that does not depend on `μ`.
Note: There is a gap in the last step of the proof in [Halmos]. In the last line, the equality
`g(-x) + ν(s - x) = f(x)` holds if we can prove that `0 < ν(s - x) < ∞`. The first inequality
follows from §59, Th. D, but the second inequality is not justified. We prove this inequality for
almost all `x` in `MeasureTheory.ae_measure_preimage_add_right_lt_top_of_ne_zero`. -/]
theorem measure_lintegral_div_measure (sm : MeasurableSet s) (h2s : ν' s ≠ 0) (h3s : ν' s ≠ ∞)
(f : G → ℝ≥0∞) (hf : Measurable f) :
(μ' s * ∫⁻ y, f y⁻¹ / ν' ((· * y⁻¹) ⁻¹' s) ∂ν') = ∫⁻ x, f x ∂μ' := by
set g := fun y => f y⁻¹ / ν' ((fun x => x * y⁻¹) ⁻¹' s)
have hg : Measurable g :=
(hf.comp measurable_inv).div ((measurable_measure_mul_right ν' sm).comp measurable_inv)
simp_rw [measure_mul_lintegral_eq μ' ν' sm g hg, g, inv_inv]
refine lintegral_congr_ae ?_
refine (ae_measure_preimage_mul_right_lt_top_of_ne_zero μ' ν' h2s h3s).mono fun x hx => ?_
simp_rw [ENNReal.mul_div_cancel (measure_mul_right_ne_zero ν' h2s _) hx.ne]
@[to_additive]
theorem measure_mul_measure_eq (s t : Set G) (h2s : ν' s ≠ 0) (h3s : ν' s ≠ ∞) :
μ' s * ν' t = ν' s * μ' t := by
wlog hs : MeasurableSet s generalizing s
· rcases exists_measurable_superset₂ μ' ν' s with ⟨s', -, hm, hμ, hν⟩
rw [← hμ, ← hν, this s' _ _ hm] <;> rwa [hν]
wlog ht : MeasurableSet t generalizing t
· rcases exists_measurable_superset₂ μ' ν' t with ⟨t', -, hm, hμ, hν⟩
rw [← hμ, ← hν, this _ hm]
have h1 := measure_lintegral_div_measure ν' ν' hs h2s h3s (t.indicator fun _ => 1)
(measurable_const.indicator ht)
have h2 := measure_lintegral_div_measure μ' ν' hs h2s h3s (t.indicator fun _ => 1)
(measurable_const.indicator ht)
rw [lintegral_indicator ht, setLIntegral_one] at h1 h2
rw [← h1, mul_left_comm, h2]
/-- Left invariant Borel measures on a measurable group are unique (up to a scalar). -/
@[to_additive
/-- Left invariant Borel measures on an additive measurable group are unique (up to a scalar). -/]
theorem measure_eq_div_smul (h2s : ν' s ≠ 0) (h3s : ν' s ≠ ∞) :
μ' = (μ' s / ν' s) • ν' := by
ext1 t -
rw [smul_apply, smul_eq_mul, mul_comm, ← mul_div_assoc, mul_comm,
measure_mul_measure_eq μ' ν' s t h2s h3s, mul_div_assoc, ENNReal.mul_div_cancel h2s h3s]
end SigmaFinite
end LeftInvariant
section RightInvariant
@[to_additive measurePreserving_prod_add_right]
theorem measurePreserving_prod_mul_right [IsMulRightInvariant ν] :
MeasurePreserving (fun z : G × G => (z.1, z.2 * z.1)) (μ.prod ν) (μ.prod ν) :=
MeasurePreserving.skew_product (g := fun x y => y * x) (MeasurePreserving.id μ)
(measurable_snd.mul measurable_fst) <| Filter.Eventually.of_forall <| map_mul_right_eq_self ν
/-- The map `(x, y) ↦ (y, xy)` sends the measure `μ × ν` to `ν × μ`. -/
@[to_additive measurePreserving_prod_add_swap_right
/-- The map `(x, y) ↦ (y, x + y)` sends the measure `μ × ν` to `ν × μ`. -/]
theorem measurePreserving_prod_mul_swap_right [IsMulRightInvariant μ] :
MeasurePreserving (fun z : G × G => (z.2, z.1 * z.2)) (μ.prod ν) (ν.prod μ) :=
(measurePreserving_prod_mul_right ν μ).comp measurePreserving_swap
/-- The map `(x, y) ↦ (xy, y)` preserves the measure `μ × ν`. -/
@[to_additive measurePreserving_add_prod
/-- The map `(x, y) ↦ (x + y, y)` preserves the measure `μ × ν`. -/]
theorem measurePreserving_mul_prod [IsMulRightInvariant μ] :
MeasurePreserving (fun z : G × G => (z.1 * z.2, z.2)) (μ.prod ν) (μ.prod ν) :=
measurePreserving_swap.comp (measurePreserving_prod_mul_swap_right μ ν)
variable [MeasurableInv G]
/-- The map `(x, y) ↦ (x, y / x)` is measure-preserving. -/
@[to_additive measurePreserving_prod_sub
/-- The map `(x, y) ↦ (x, y - x)` is measure-preserving. -/]
theorem measurePreserving_prod_div [IsMulRightInvariant ν] :
MeasurePreserving (fun z : G × G => (z.1, z.2 / z.1)) (μ.prod ν) (μ.prod ν) :=
(measurePreserving_prod_mul_right μ ν).symm (MeasurableEquiv.shearDivRight G).symm
/-- The map `(x, y) ↦ (y, x / y)` sends `μ × ν` to `ν × μ`. -/
@[to_additive measurePreserving_prod_sub_swap
/-- The map `(x, y) ↦ (y, x - y)` sends `μ × ν` to `ν × μ`. -/]
theorem measurePreserving_prod_div_swap [IsMulRightInvariant μ] :
MeasurePreserving (fun z : G × G => (z.2, z.1 / z.2)) (μ.prod ν) (ν.prod μ) :=
(measurePreserving_prod_div ν μ).comp measurePreserving_swap
/-- The map `(x, y) ↦ (x / y, y)` preserves the measure `μ × ν`. -/
@[to_additive measurePreserving_sub_prod
/-- The map `(x, y) ↦ (x - y, y)` preserves the measure `μ × ν`. -/]
theorem measurePreserving_div_prod [IsMulRightInvariant μ] :
MeasurePreserving (fun z : G × G => (z.1 / z.2, z.2)) (μ.prod ν) (μ.prod ν) :=
measurePreserving_swap.comp (measurePreserving_prod_div_swap μ ν)
/-- The map `(x, y) ↦ (xy, x⁻¹)` is measure-preserving. -/
@[to_additive measurePreserving_add_prod_neg_right
/-- The map `(x, y) ↦ (x + y, - x)` is measure-preserving. -/]
theorem measurePreserving_mul_prod_inv_right [IsMulRightInvariant μ] [IsMulRightInvariant ν] :
MeasurePreserving (fun z : G × G => (z.1 * z.2, z.1⁻¹)) (μ.prod ν) (μ.prod ν) := by
convert (measurePreserving_prod_div_swap ν μ).comp (measurePreserving_prod_mul_swap_right μ ν)
using 1
ext1 ⟨x, y⟩
simp_rw [Function.comp_apply, div_mul_eq_div_div_swap, div_self', one_div]
end RightInvariant
section QuasiMeasurePreserving
/-- The map `(x, y) ↦ x * y` is quasi-measure-preserving. -/
@[to_additive (attr := fun_prop) /-- The map `(x, y) ↦ x + y` is quasi-measure-preserving. -/]
theorem quasiMeasurePreserving_mul [IsMulLeftInvariant ν] :
QuasiMeasurePreserving (fun p ↦ p.1 * p.2) (μ.prod ν) ν :=
quasiMeasurePreserving_snd.comp (measurePreserving_prod_mul _ _).quasiMeasurePreserving
/-- The map `(x, y) ↦ y * x` is quasi-measure-preserving. -/
@[to_additive (attr := fun_prop) /-- The map `(x, y) ↦ y + x` is quasi-measure-preserving. -/]
theorem quasiMeasurePreserving_mul_swap [IsMulLeftInvariant μ] :
QuasiMeasurePreserving (fun p ↦ p.2 * p.1) (μ.prod ν) μ :=
quasiMeasurePreserving_snd.comp (measurePreserving_prod_mul_swap _ _).quasiMeasurePreserving
section MeasurableInv
variable [MeasurableInv G]
/-- The map `(x, y) ↦ x⁻¹ * y` is quasi-measure-preserving. -/
@[to_additive (attr := fun_prop) /-- The map `(x, y) ↦ -x + y` is quasi-measure-preserving. -/]
theorem quasiMeasurePreserving_inv_mul [IsMulLeftInvariant ν] :
QuasiMeasurePreserving (fun p ↦ p.1⁻¹ * p.2) (μ.prod ν) ν :=
quasiMeasurePreserving_snd.comp (measurePreserving_prod_inv_mul _ _).quasiMeasurePreserving
/-- The map `(x, y) ↦ y⁻¹ * x` is quasi-measure-preserving. -/
@[to_additive (attr := fun_prop) /-- The map `(x, y) ↦ -y + x` is quasi-measure-preserving. -/]
theorem quasiMeasurePreserving_inv_mul_swap [IsMulLeftInvariant μ] :
QuasiMeasurePreserving (fun p ↦ p.2⁻¹ * p.1) (μ.prod ν) μ :=
quasiMeasurePreserving_snd.comp (measurePreserving_prod_inv_mul_swap _ _).quasiMeasurePreserving
@[to_additive (attr := fun_prop)]
theorem quasiMeasurePreserving_inv_of_right_invariant [IsMulRightInvariant μ] :
QuasiMeasurePreserving (Inv.inv : G → G) μ μ := by
rw [← μ.inv_inv]
exact
(quasiMeasurePreserving_inv μ.inv).mono (inv_absolutelyContinuous μ.inv)
(absolutelyContinuous_inv μ.inv)
@[to_additive]
theorem quasiMeasurePreserving_div_left [IsMulLeftInvariant μ] (g : G) :
QuasiMeasurePreserving (fun h : G => g / h) μ μ := by
simp_rw [div_eq_mul_inv]
exact
(measurePreserving_mul_left μ g).quasiMeasurePreserving.comp (quasiMeasurePreserving_inv μ)
@[to_additive]
theorem quasiMeasurePreserving_div_left_of_right_invariant [IsMulRightInvariant μ] (g : G) :
QuasiMeasurePreserving (fun h : G => g / h) μ μ := by
rw [← μ.inv_inv]
exact
(quasiMeasurePreserving_div_left μ.inv g).mono (inv_absolutelyContinuous μ.inv)
(absolutelyContinuous_inv μ.inv)
@[to_additive]
theorem quasiMeasurePreserving_div_of_right_invariant [IsMulRightInvariant μ] :
QuasiMeasurePreserving (fun p : G × G => p.1 / p.2) (μ.prod ν) μ := by
refine QuasiMeasurePreserving.prod_of_left measurable_div (Eventually.of_forall fun y => ?_)
exact (measurePreserving_div_right μ y).quasiMeasurePreserving
@[to_additive]
theorem quasiMeasurePreserving_div [IsMulLeftInvariant μ] :
QuasiMeasurePreserving (fun p : G × G => p.1 / p.2) (μ.prod ν) μ :=
(quasiMeasurePreserving_div_of_right_invariant μ.inv ν).mono
((absolutelyContinuous_inv μ).prod AbsolutelyContinuous.rfl) (inv_absolutelyContinuous μ)
/-- A *left*-invariant measure is quasi-preserved by *right*-multiplication.
This should not be confused with `(measurePreserving_mul_right μ g).quasiMeasurePreserving`. -/
@[to_additive (attr := fun_prop)
/-- A *left*-invariant measure is quasi-preserved by *right*-addition.
This should not be confused with `(measurePreserving_add_right μ g).quasiMeasurePreserving`. -/]
theorem quasiMeasurePreserving_mul_right [IsMulLeftInvariant μ] (g : G) :
QuasiMeasurePreserving (fun h : G => h * g) μ μ := by
refine ⟨measurable_mul_const g, AbsolutelyContinuous.mk fun s hs => ?_⟩
rw [map_apply (measurable_mul_const g) hs, measure_mul_right_null]; exact id
/-- A *right*-invariant measure is quasi-preserved by *left*-multiplication.
This should not be confused with `(measurePreserving_mul_left μ g).quasiMeasurePreserving`. -/
@[to_additive (attr := fun_prop)
/-- A *right*-invariant measure is quasi-preserved by *left*-addition.
This should not be confused with `(measurePreserving_add_left μ g).quasiMeasurePreserving`. -/]
theorem quasiMeasurePreserving_mul_left [IsMulRightInvariant μ] (g : G) :
QuasiMeasurePreserving (fun h : G => g * h) μ μ := by
have :=
(quasiMeasurePreserving_mul_right μ.inv g⁻¹).mono (inv_absolutelyContinuous μ.inv)
(absolutelyContinuous_inv μ.inv)
rw [μ.inv_inv] at this
have :=
(quasiMeasurePreserving_inv_of_right_invariant μ).comp
(this.comp (quasiMeasurePreserving_inv_of_right_invariant μ))
simp_rw [Function.comp_def, mul_inv_rev, inv_inv] at this
exact this
end MeasurableInv
end QuasiMeasurePreserving
end MeasureTheory |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.