path stringlengths 11 71 | content stringlengths 75 124k |
|---|---|
AlgebraicGeometry\Spec.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison, Justus Springer
-/
import Mathlib.Geometry.RingedSpace.LocallyRingedSpace
import Mathlib.AlgebraicGeometry.StructureSheaf
import Mathlib.RingTheory.Localization.LocalizationLocalization
import Mathlib.Topology.Sheaves.SheafCondition.Sites
import Mathlib.Topology.Sheaves.Functors
import Mathlib.Algebra.Module.LocalizedModule
/-!
# $Spec$ as a functor to locally ringed spaces.
We define the functor $Spec$ from commutative rings to locally ringed spaces.
## Implementation notes
We define $Spec$ in three consecutive steps, each with more structure than the last:
1. `Spec.toTop`, valued in the category of topological spaces,
2. `Spec.toSheafedSpace`, valued in the category of sheafed spaces and
3. `Spec.toLocallyRingedSpace`, valued in the category of locally ringed spaces.
Additionally, we provide `Spec.toPresheafedSpace` as a composition of `Spec.toSheafedSpace` with
a forgetful functor.
## Related results
The adjunction `Γ ⊣ Spec` is constructed in `Mathlib/AlgebraicGeometry/GammaSpecAdjunction.lean`.
-/
-- Explicit universe annotations were used in this file to improve perfomance #12737
noncomputable section
universe u v
namespace AlgebraicGeometry
open Opposite
open CategoryTheory
open StructureSheaf
open Spec (structureSheaf)
/-- The spectrum of a commutative ring, as a topological space.
-/
def Spec.topObj (R : CommRingCat.{u}) : TopCat :=
TopCat.of (PrimeSpectrum R)
@[simp] theorem Spec.topObj_forget {R} : (forget TopCat).obj (Spec.topObj R) = PrimeSpectrum R :=
rfl
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of topological spaces.
-/
def Spec.topMap {R S : CommRingCat.{u}} (f : R ⟶ S) : Spec.topObj S ⟶ Spec.topObj R :=
PrimeSpectrum.comap f
@[simp]
theorem Spec.topMap_id (R : CommRingCat.{u}) : Spec.topMap (𝟙 R) = 𝟙 (Spec.topObj R) :=
rfl
@[simp]
theorem Spec.topMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.topMap (f ≫ g) = Spec.topMap g ≫ Spec.topMap f :=
rfl
-- Porting note: `simps!` generate some garbage lemmas, so choose manually,
-- if more is needed, add them here
/-- The spectrum, as a contravariant functor from commutative rings to topological spaces.
-/
@[simps! obj map]
def Spec.toTop : CommRingCat.{u}ᵒᵖ ⥤ TopCat where
obj R := Spec.topObj (unop R)
map {R S} f := Spec.topMap f.unop
/-- The spectrum of a commutative ring, as a `SheafedSpace`.
-/
@[simps]
def Spec.sheafedSpaceObj (R : CommRingCat.{u}) : SheafedSpace CommRingCat where
carrier := Spec.topObj R
presheaf := (structureSheaf R).1
IsSheaf := (structureSheaf R).2
/-- The induced map of a ring homomorphism on the ring spectra, as a morphism of sheafed spaces.
-/
@[simps]
def Spec.sheafedSpaceMap {R S : CommRingCat.{u}} (f : R ⟶ S) :
Spec.sheafedSpaceObj S ⟶ Spec.sheafedSpaceObj R where
base := Spec.topMap f
c :=
{ app := fun U =>
comap f (unop U) ((TopologicalSpace.Opens.map (Spec.topMap f)).obj (unop U)) fun _ => id
naturality := fun {_ _} _ => RingHom.ext fun _ => Subtype.eq <| funext fun _ => rfl }
@[simp]
theorem Spec.sheafedSpaceMap_id {R : CommRingCat.{u}} :
Spec.sheafedSpaceMap (𝟙 R) = 𝟙 (Spec.sheafedSpaceObj R) :=
AlgebraicGeometry.PresheafedSpace.Hom.ext _ _ (Spec.topMap_id R) <| by
ext
dsimp
erw [comap_id (by simp)]
simp
theorem Spec.sheafedSpaceMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.sheafedSpaceMap (f ≫ g) = Spec.sheafedSpaceMap g ≫ Spec.sheafedSpaceMap f :=
AlgebraicGeometry.PresheafedSpace.Hom.ext _ _ (Spec.topMap_comp f g) <| by
ext
-- Porting note: was one liner
-- `dsimp, rw category_theory.functor.map_id, rw category.comp_id, erw comap_comp f g, refl`
rw [NatTrans.comp_app, sheafedSpaceMap_c_app, whiskerRight_app, eqToHom_refl]
erw [(sheafedSpaceObj T).presheaf.map_id, Category.comp_id, comap_comp]
rfl
/-- Spec, as a contravariant functor from commutative rings to sheafed spaces.
-/
@[simps]
def Spec.toSheafedSpace : CommRingCat.{u}ᵒᵖ ⥤ SheafedSpace CommRingCat where
obj R := Spec.sheafedSpaceObj (unop R)
map f := Spec.sheafedSpaceMap f.unop
map_comp f g := by simp [Spec.sheafedSpaceMap_comp]
/-- Spec, as a contravariant functor from commutative rings to presheafed spaces.
-/
def Spec.toPresheafedSpace : CommRingCat.{u}ᵒᵖ ⥤ PresheafedSpace CommRingCat :=
Spec.toSheafedSpace ⋙ SheafedSpace.forgetToPresheafedSpace
@[simp]
theorem Spec.toPresheafedSpace_obj (R : CommRingCat.{u}ᵒᵖ) :
Spec.toPresheafedSpace.obj R = (Spec.sheafedSpaceObj (unop R)).toPresheafedSpace :=
rfl
theorem Spec.toPresheafedSpace_obj_op (R : CommRingCat.{u}) :
Spec.toPresheafedSpace.obj (op R) = (Spec.sheafedSpaceObj R).toPresheafedSpace :=
rfl
@[simp]
theorem Spec.toPresheafedSpace_map (R S : CommRingCat.{u}ᵒᵖ) (f : R ⟶ S) :
Spec.toPresheafedSpace.map f = Spec.sheafedSpaceMap f.unop :=
rfl
theorem Spec.toPresheafedSpace_map_op (R S : CommRingCat.{u}) (f : R ⟶ S) :
Spec.toPresheafedSpace.map f.op = Spec.sheafedSpaceMap f :=
rfl
theorem Spec.basicOpen_hom_ext {X : RingedSpace.{u}} {R : CommRingCat.{u}}
{α β : X ⟶ Spec.sheafedSpaceObj R} (w : α.base = β.base)
(h : ∀ r : R,
let U := PrimeSpectrum.basicOpen r
(toOpen R U ≫ α.c.app (op U)) ≫ X.presheaf.map (eqToHom (by rw [w])) =
toOpen R U ≫ β.c.app (op U)) :
α = β := by
ext : 1
· exact w
· apply
((TopCat.Sheaf.pushforward _ β.base).obj X.sheaf).hom_ext _ PrimeSpectrum.isBasis_basic_opens
intro r
apply (StructureSheaf.to_basicOpen_epi R r).1
simpa using h r
-- Porting note: `simps!` generate some garbage lemmas, so choose manually,
-- if more is needed, add them here
/-- The spectrum of a commutative ring, as a `LocallyRingedSpace`.
-/
@[simps! toSheafedSpace presheaf]
def Spec.locallyRingedSpaceObj (R : CommRingCat.{u}) : LocallyRingedSpace :=
{ Spec.sheafedSpaceObj R with
localRing := fun x =>
RingEquiv.localRing (A := Localization.AtPrime x.asIdeal)
(Iso.commRingCatIsoToRingEquiv <| stalkIso R x).symm }
lemma Spec.locallyRingedSpaceObj_sheaf (R : CommRingCat.{u}) :
(Spec.locallyRingedSpaceObj R).sheaf = structureSheaf R := rfl
lemma Spec.locallyRingedSpaceObj_sheaf' (R : Type u) [CommRing R] :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).sheaf = structureSheaf R := rfl
lemma Spec.locallyRingedSpaceObj_presheaf_map (R : CommRingCat.{u}) {U V} (i : U ⟶ V) :
(Spec.locallyRingedSpaceObj R).presheaf.map i =
(structureSheaf R).1.map i := rfl
lemma Spec.locallyRingedSpaceObj_presheaf' (R : Type u) [CommRing R] :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).presheaf = (structureSheaf R).1 := rfl
lemma Spec.locallyRingedSpaceObj_presheaf_map' (R : Type u) [CommRing R] {U V} (i : U ⟶ V) :
(Spec.locallyRingedSpaceObj <| CommRingCat.of R).presheaf.map i =
(structureSheaf R).1.map i := rfl
@[elementwise]
theorem stalkMap_toStalk {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
toStalk R (PrimeSpectrum.comap f p) ≫ (Spec.sheafedSpaceMap f).stalkMap p =
f ≫ toStalk S p := by
erw [← toOpen_germ S ⊤ ⟨p, trivial⟩, ← toOpen_germ R ⊤ ⟨PrimeSpectrum.comap f p, trivial⟩,
Category.assoc, PresheafedSpace.stalkMap_germ (Spec.sheafedSpaceMap f) ⊤ ⟨p, trivial⟩,
Spec.sheafedSpaceMap_c_app, toOpen_comp_comap_assoc]
rfl
/-- Under the isomorphisms `stalkIso`, the map `stalkMap (Spec.sheafedSpaceMap f) p` corresponds
to the induced local ring homomorphism `Localization.localRingHom`.
-/
@[elementwise]
theorem localRingHom_comp_stalkIso {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum S) :
(stalkIso R (PrimeSpectrum.comap f p)).hom ≫
@CategoryStruct.comp _ _
(CommRingCat.of (Localization.AtPrime (PrimeSpectrum.comap f p).asIdeal))
(CommRingCat.of (Localization.AtPrime p.asIdeal)) _
(Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f rfl)
(stalkIso S p).inv =
(Spec.sheafedSpaceMap f).stalkMap p :=
(stalkIso R (PrimeSpectrum.comap f p)).eq_inv_comp.mp <|
(stalkIso S p).comp_inv_eq.mpr <|
Localization.localRingHom_unique _ _ _ _ fun x => by
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644 and #8386
rw [stalkIso_hom, stalkIso_inv]
erw [comp_apply, comp_apply, localizationToStalk_of, stalkMap_toStalk_apply f p x,
stalkToFiberRingHom_toStalk]
/--
The induced map of a ring homomorphism on the prime spectra, as a morphism of locally ringed spaces.
-/
@[simps]
def Spec.locallyRingedSpaceMap {R S : CommRingCat.{u}} (f : R ⟶ S) :
Spec.locallyRingedSpaceObj S ⟶ Spec.locallyRingedSpaceObj R :=
LocallyRingedSpace.Hom.mk (Spec.sheafedSpaceMap f) fun p =>
IsLocalRingHom.mk fun a ha => by
-- Here, we are showing that the map on prime spectra induced by `f` is really a morphism of
-- *locally* ringed spaces, i.e. that the induced map on the stalks is a local ring
-- homomorphism.
#adaptation_note /-- nightly-2024-04-01
It's this `erw` that is blowing up. The implicit arguments differ significantly. -/
erw [← localRingHom_comp_stalkIso_apply] at ha
replace ha := (isUnit_map_iff (stalkIso S p).inv _).mp ha
-- Porting note: `f` had to be made explicit
replace ha := IsLocalRingHom.map_nonunit
(f := (Localization.localRingHom (PrimeSpectrum.comap f p).asIdeal p.asIdeal f _)) _ ha
convert RingHom.isUnit_map (stalkIso R (PrimeSpectrum.comap f p)).inv ha
erw [← comp_apply, show stalkToFiberRingHom R _ = (stalkIso _ _).hom from rfl,
Iso.hom_inv_id, id_apply]
@[simp]
theorem Spec.locallyRingedSpaceMap_id (R : CommRingCat.{u}) :
Spec.locallyRingedSpaceMap (𝟙 R) = 𝟙 (Spec.locallyRingedSpaceObj R) :=
LocallyRingedSpace.Hom.ext <| by
rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_id]; rfl
theorem Spec.locallyRingedSpaceMap_comp {R S T : CommRingCat.{u}} (f : R ⟶ S) (g : S ⟶ T) :
Spec.locallyRingedSpaceMap (f ≫ g) =
Spec.locallyRingedSpaceMap g ≫ Spec.locallyRingedSpaceMap f :=
LocallyRingedSpace.Hom.ext <| by
rw [Spec.locallyRingedSpaceMap_val, Spec.sheafedSpaceMap_comp]; rfl
/-- Spec, as a contravariant functor from commutative rings to locally ringed spaces.
-/
@[simps]
def Spec.toLocallyRingedSpace : CommRingCat.{u}ᵒᵖ ⥤ LocallyRingedSpace where
obj R := Spec.locallyRingedSpaceObj (unop R)
map f := Spec.locallyRingedSpaceMap f.unop
map_id R := by dsimp; rw [Spec.locallyRingedSpaceMap_id]
map_comp f g := by dsimp; rw [Spec.locallyRingedSpaceMap_comp]
section SpecΓ
open AlgebraicGeometry.LocallyRingedSpace
/-- The counit morphism `R ⟶ Γ(Spec R)` given by `AlgebraicGeometry.StructureSheaf.toOpen`. -/
@[simps!]
def toSpecΓ (R : CommRingCat.{u}) : R ⟶ Γ.obj (op (Spec.toLocallyRingedSpace.obj (op R))) :=
StructureSheaf.toOpen R ⊤
-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
attribute [nolint simpNF] AlgebraicGeometry.toSpecΓ_apply_coe
instance isIso_toSpecΓ (R : CommRingCat.{u}) : IsIso (toSpecΓ R) := by
cases R; apply StructureSheaf.isIso_to_global
@[reassoc]
theorem Spec_Γ_naturality {R S : CommRingCat.{u}} (f : R ⟶ S) :
f ≫ toSpecΓ S = toSpecΓ R ≫ Γ.map (Spec.toLocallyRingedSpace.map f.op).op := by
-- Porting note: `ext` failed to pick up one of the three lemmas
refine RingHom.ext fun x => Subtype.ext <| funext fun x' => ?_; symm
apply Localization.localRingHom_to_map
/-- The counit (`SpecΓIdentity.inv.op`) of the adjunction `Γ ⊣ Spec` is an isomorphism. -/
@[simps! hom_app inv_app]
def LocallyRingedSpace.SpecΓIdentity : Spec.toLocallyRingedSpace.rightOp ⋙ Γ ≅ 𝟭 _ :=
Iso.symm <| NatIso.ofComponents.{u,u,u+1,u+1} (fun R =>
-- Porting note: In Lean3, this `IsIso` is synthesized automatically
letI : IsIso (toSpecΓ R) := StructureSheaf.isIso_to_global _
asIso (toSpecΓ R)) fun {X Y} f => by convert Spec_Γ_naturality (R := X) (S := Y) f
end SpecΓ
/-- The stalk map of `Spec M⁻¹R ⟶ Spec R` is an iso for each `p : Spec M⁻¹R`. -/
theorem Spec_map_localization_isIso (R : CommRingCat.{u}) (M : Submonoid R)
(x : PrimeSpectrum (Localization M)) :
IsIso
((Spec.toPresheafedSpace.map
(CommRingCat.ofHom (algebraMap R (Localization M))).op).stalkMap x) := by
erw [← localRingHom_comp_stalkIso]
-- Porting note: replaced `apply (config := { instances := false })`.
-- See https://github.com/leanprover/lean4/issues/2273
refine @IsIso.comp_isIso _ _ _ _ _ _ _ _ (?_)
refine @IsIso.comp_isIso _ _ _ _ _ _ _ (?_) _
/- I do not know why this is defeq to the goal, but I'm happy to accept that it is. -/
show
IsIso (IsLocalization.localizationLocalizationAtPrimeIsoLocalization M
x.asIdeal).toRingEquiv.toCommRingCatIso.hom
infer_instance
namespace StructureSheaf
variable {R S : CommRingCat.{u}} (f : R ⟶ S) (p : PrimeSpectrum R)
/-- For an algebra `f : R →+* S`, this is the ring homomorphism `S →+* (f∗ 𝒪ₛ)ₚ` for a `p : Spec R`.
This is shown to be the localization at `p` in `isLocalizedModule_toPushforwardStalkAlgHom`.
-/
def toPushforwardStalk : S ⟶ (Spec.topMap f _* (structureSheaf S).1).stalk p :=
StructureSheaf.toOpen S ⊤ ≫
@TopCat.Presheaf.germ _ _ _ _ (Spec.topMap f _* (structureSheaf S).1) ⊤ ⟨p, trivial⟩
@[reassoc]
theorem toPushforwardStalk_comp :
f ≫ StructureSheaf.toPushforwardStalk f p =
StructureSheaf.toStalk R p ≫
(TopCat.Presheaf.stalkFunctor _ _).map (Spec.sheafedSpaceMap f).c := by
rw [StructureSheaf.toStalk]
erw [Category.assoc]
rw [TopCat.Presheaf.stalkFunctor_map_germ]
exact Spec_Γ_naturality_assoc f _
instance : Algebra R ((Spec.topMap f _* (structureSheaf S).1).stalk p) :=
(f ≫ StructureSheaf.toPushforwardStalk f p).toAlgebra
theorem algebraMap_pushforward_stalk :
algebraMap R ((Spec.topMap f _* (structureSheaf S).1).stalk p) =
f ≫ StructureSheaf.toPushforwardStalk f p :=
rfl
variable (R S)
variable [Algebra R S]
/--
This is the `AlgHom` version of `toPushforwardStalk`, which is the map `S ⟶ (f∗ 𝒪ₛ)ₚ` for some
algebra `R ⟶ S` and some `p : Spec R`.
-/
@[simps!]
def toPushforwardStalkAlgHom :
S →ₐ[R] (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).stalk p :=
{ StructureSheaf.toPushforwardStalk (algebraMap R S) p with commutes' := fun _ => rfl }
theorem isLocalizedModule_toPushforwardStalkAlgHom_aux (y) :
∃ x : S × p.asIdeal.primeCompl, x.2 • y = toPushforwardStalkAlgHom R S p x.1 := by
obtain ⟨U, hp, s, e⟩ := TopCat.Presheaf.germ_exist
-- Porting note: originally the first variable does not need to be explicit
(Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf S).val) _ y
obtain ⟨_, ⟨r, rfl⟩, hpr : p ∈ PrimeSpectrum.basicOpen r, hrU : PrimeSpectrum.basicOpen r ≤ U⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open (show p ∈ U from hp) U.2
change PrimeSpectrum.basicOpen r ≤ U at hrU
replace e :=
((Spec.topMap (algebraMap R S) _* (structureSheaf S).1).germ_res_apply (homOfLE hrU)
⟨p, hpr⟩ _).trans e
set s' := (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).map (homOfLE hrU).op s with h
replace e : ((Spec.topMap (algebraMap R S) _* (structureSheaf S).val).germ ⟨p, hpr⟩) s' = y := by
rw [h]; exact e
clear_value s'; clear! U
obtain ⟨⟨s, ⟨_, n, rfl⟩⟩, hsn⟩ :=
@IsLocalization.surj _ _ _ _ _ _
(StructureSheaf.IsLocalization.to_basicOpen S <| algebraMap R S r) s'
refine ⟨⟨s, ⟨r, hpr⟩ ^ n⟩, ?_⟩
rw [Submonoid.smul_def, Algebra.smul_def, algebraMap_pushforward_stalk, toPushforwardStalk,
comp_apply, comp_apply]
iterate 2
erw [← (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).germ_res_apply (homOfLE le_top)
⟨p, hpr⟩]
rw [← e]
-- Porting note: without this `change`, Lean doesn't know how to rewrite `map_mul`
let f := TopCat.Presheaf.germ (Spec.topMap (algebraMap R S) _* (structureSheaf S).val) ⟨p, hpr⟩
change f _ * f _ = f _
rw [← map_mul, mul_comm]
dsimp only [Subtype.coe_mk] at hsn
rw [← map_pow (algebraMap R S)] at hsn
congr 1
instance isLocalizedModule_toPushforwardStalkAlgHom :
IsLocalizedModule p.asIdeal.primeCompl (toPushforwardStalkAlgHom R S p).toLinearMap := by
apply IsLocalizedModule.mkOfAlgebra
· intro x hx; rw [algebraMap_pushforward_stalk, toPushforwardStalk_comp]
change IsUnit ((TopCat.Presheaf.stalkFunctor CommRingCat p).map
(Spec.sheafedSpaceMap (algebraMap ↑R ↑S)).c _)
exact (IsLocalization.map_units ((structureSheaf R).presheaf.stalk p) ⟨x, hx⟩).map _
· apply isLocalizedModule_toPushforwardStalkAlgHom_aux
· intro x hx
rw [toPushforwardStalkAlgHom_apply, ← (toPushforwardStalk (algebraMap R S) p).map_zero,
toPushforwardStalk] at hx
-- Porting note: this `change` is manually rewriting `comp_apply`
change _ = (TopCat.Presheaf.germ (Spec.topMap (algebraMap ↑R ↑S) _* (structureSheaf ↑S).val)
(⟨p, trivial⟩ : (⊤ : TopologicalSpace.Opens (PrimeSpectrum R))) (toOpen S ⊤ 0)) at hx
rw [map_zero] at hx
change (forget CommRingCat).map _ _ = (forget _).map _ _ at hx
obtain ⟨U, hpU, i₁, i₂, e⟩ := TopCat.Presheaf.germ_eq _ _ _ _ _ _ hx
obtain ⟨_, ⟨r, rfl⟩, hpr, hrU⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open (show p ∈ U.1 from hpU)
U.2
change PrimeSpectrum.basicOpen r ≤ U at hrU
apply_fun (Spec.topMap (algebraMap R S) _* (structureSheaf S).1).map (homOfLE hrU).op at e
simp only [Functor.op_map, map_zero, ← comp_apply, toOpen_res] at e
have : toOpen S (PrimeSpectrum.basicOpen <| algebraMap R S r) x = 0 := by
refine Eq.trans ?_ e; rfl
have :=
(@IsLocalization.mk'_one _ _ _ _ _ _
(StructureSheaf.IsLocalization.to_basicOpen S <| algebraMap R S r) x).trans
this
obtain ⟨⟨_, n, rfl⟩, e⟩ := (IsLocalization.mk'_eq_zero_iff _ _).mp this
refine ⟨⟨r, hpr⟩ ^ n, ?_⟩
rw [Submonoid.smul_def, Algebra.smul_def]
-- Porting note: manually rewrite `Submonoid.coe_pow`
change (algebraMap R S) (r ^ n) * x = 0
rw [map_pow]
exact e
end StructureSheaf
end AlgebraicGeometry
|
AlgebraicGeometry\Stalk.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang, Fangming Li
-/
import Mathlib.AlgebraicGeometry.AffineScheme
/-!
# Stalks of a Scheme
Given a scheme `X` and a point `x : X`, `AlgebraicGeometry.Scheme.fromSpecStalk X x` is the
canonical scheme morphism from `Spec(O_x)` to `X`. This is helpful for constructing the canonical
map from the spectrum of the residue field of a point to the original scheme.
-/
namespace AlgebraicGeometry
open CategoryTheory Opposite TopologicalSpace
/--
A morphism from `Spec(O_x)` to `X`, which is defined with the help of an affine open
neighborhood `U` of `x`.
-/
noncomputable def IsAffineOpen.fromSpecStalk
{X : Scheme} {U : X.Opens} (hU : IsAffineOpen U) {x : X} (hxU : x ∈ U) :
Spec (X.presheaf.stalk x) ⟶ X :=
Spec.map (X.presheaf.germ ⟨x, hxU⟩) ≫ hU.fromSpec
/--
The morphism from `Spec(O_x)` to `X` given by `IsAffineOpen.fromSpec` does not depend on the affine
open neighborhood of `x` we choose.
-/
theorem IsAffineOpen.fromSpecStalk_eq {X : Scheme} (x : X) {U V : X.Opens}
(hU : IsAffineOpen U) (hV : IsAffineOpen V) (hxU : x ∈ U) (hxV : x ∈ V) :
hU.fromSpecStalk hxU = hV.fromSpecStalk hxV := by
obtain ⟨U', h₁, h₂, h₃ : U' ≤ U ⊓ V⟩ :=
Opens.isBasis_iff_nbhd.mp (isBasis_affine_open X) (show x ∈ U ⊓ V from ⟨hxU, hxV⟩)
transitivity fromSpecStalk h₁ h₂
· delta fromSpecStalk
rw [← hU.map_fromSpec h₁ (homOfLE $ h₃.trans inf_le_left).op]
erw [← Scheme.Spec_map (X.presheaf.map _).op, ← Scheme.Spec_map (X.presheaf.germ ⟨x, h₂⟩).op]
rw [← Functor.map_comp_assoc, ← op_comp, TopCat.Presheaf.germ_res, Scheme.Spec_map,
Quiver.Hom.unop_op]
· delta fromSpecStalk
rw [← hV.map_fromSpec h₁ (homOfLE $ h₃.trans inf_le_right).op]
erw [← Scheme.Spec_map (X.presheaf.map _).op, ← Scheme.Spec_map (X.presheaf.germ ⟨x, h₂⟩).op]
rw [← Functor.map_comp_assoc, ← op_comp, TopCat.Presheaf.germ_res, Scheme.Spec_map,
Quiver.Hom.unop_op]
/--
If `x` is a point of `X`, this is the canonical morphism from `Spec(O_x)` to `X`.
-/
noncomputable def Scheme.fromSpecStalk (X : Scheme) (x : X) :
Scheme.Spec.obj (op (X.presheaf.stalk x)) ⟶ X :=
(isAffineOpen_opensRange (X.affineOpenCover.map x)).fromSpecStalk (X.affineOpenCover.covers x)
@[simp]
theorem IsAffineOpen.fromSpecStalk_eq_fromSpecStalk
{X : Scheme} {U : X.Opens} (hU : IsAffineOpen U) {x : X} (hxU : x ∈ U) :
hU.fromSpecStalk hxU = X.fromSpecStalk x := fromSpecStalk_eq ..
end AlgebraicGeometry
|
AlgebraicGeometry\StructureSheaf.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison
-/
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
import Mathlib.Algebra.Category.Ring.Colimits
import Mathlib.Algebra.Category.Ring.Limits
import Mathlib.Topology.Sheaves.LocalPredicate
import Mathlib.RingTheory.Localization.AtPrime
import Mathlib.Algebra.Ring.Subring.Basic
/-!
# The structure sheaf on `PrimeSpectrum R`.
We define the structure sheaf on `TopCat.of (PrimeSpectrum R)`, for a commutative ring `R` and prove
basic properties about it. We define this as a subsheaf of the sheaf of dependent functions into the
localizations, cut out by the condition that the function must be locally equal to a ratio of
elements of `R`.
Because the condition "is equal to a fraction" passes to smaller open subsets,
the subset of functions satisfying this condition is automatically a subpresheaf.
Because the condition "is locally equal to a fraction" is local,
it is also a subsheaf.
(It may be helpful to refer back to `Mathlib/Topology/Sheaves/SheafOfFunctions.lean`,
where we show that dependent functions into any type family form a sheaf,
and also `Mathlib/Topology/Sheaves/LocalPredicate.lean`, where we characterise the predicates
which pick out sub-presheaves and sub-sheaves of these sheaves.)
We also set up the ring structure, obtaining
`structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R)`.
We then construct two basic isomorphisms, relating the structure sheaf to the underlying ring `R`.
First, `StructureSheaf.stalkIso` gives an isomorphism between the stalk of the structure sheaf
at a point `p` and the localization of `R` at the prime ideal `p`. Second,
`StructureSheaf.basicOpenIso` gives an isomorphism between the structure sheaf on `basicOpen f`
and the localization of `R` at the submonoid of powers of `f`.
## References
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
universe u
noncomputable section
variable (R : Type u) [CommRing R]
open TopCat
open TopologicalSpace
open CategoryTheory
open Opposite
namespace AlgebraicGeometry
/-- The prime spectrum, just as a topological space.
-/
def PrimeSpectrum.Top : TopCat :=
TopCat.of (PrimeSpectrum R)
namespace StructureSheaf
/-- The type family over `PrimeSpectrum R` consisting of the localization over each point.
-/
def Localizations (P : PrimeSpectrum.Top R) : Type u :=
Localization.AtPrime P.asIdeal
-- Porting note: can't derive `CommRingCat`
instance commRingLocalizations (P : PrimeSpectrum.Top R) : CommRing <| Localizations R P :=
inferInstanceAs <| CommRing <| Localization.AtPrime P.asIdeal
-- Porting note: can't derive `LocalRing`
instance localRingLocalizations (P : PrimeSpectrum.Top R) : LocalRing <| Localizations R P :=
inferInstanceAs <| LocalRing <| Localization.AtPrime P.asIdeal
instance (P : PrimeSpectrum.Top R) : Inhabited (Localizations R P) :=
⟨1⟩
instance (U : Opens (PrimeSpectrum.Top R)) (x : U) : Algebra R (Localizations R x) :=
inferInstanceAs <| Algebra R (Localization.AtPrime x.1.asIdeal)
instance (U : Opens (PrimeSpectrum.Top R)) (x : U) :
IsLocalization.AtPrime (Localizations R x) (x : PrimeSpectrum.Top R).asIdeal :=
Localization.isLocalization
variable {R}
/-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
`r / s` in each of the stalks (which are localizations at various prime ideals).
-/
def IsFraction {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) : Prop :=
∃ r s : R, ∀ x : U, ¬s ∈ x.1.asIdeal ∧ f x * algebraMap _ _ s = algebraMap _ _ r
theorem IsFraction.eq_mk' {U : Opens (PrimeSpectrum.Top R)} {f : ∀ x : U, Localizations R x}
(hf : IsFraction f) :
∃ r s : R,
∀ x : U,
∃ hs : s ∉ x.1.asIdeal,
f x =
IsLocalization.mk' (Localization.AtPrime _) r
(⟨s, hs⟩ : (x : PrimeSpectrum.Top R).asIdeal.primeCompl) := by
rcases hf with ⟨r, s, h⟩
refine ⟨r, s, fun x => ⟨(h x).1, (IsLocalization.mk'_eq_iff_eq_mul.mpr ?_).symm⟩⟩
exact (h x).2.symm
variable (R)
/-- The predicate `IsFraction` is "prelocal",
in the sense that if it holds on `U` it holds on any open subset `V` of `U`.
-/
def isFractionPrelocal : PrelocalPredicate (Localizations R) where
pred {U} f := IsFraction f
res := by rintro V U i f ⟨r, s, w⟩; exact ⟨r, s, fun x => w (i x)⟩
/-- We will define the structure sheaf as
the subsheaf of all dependent functions in `Π x : U, Localizations R x`
consisting of those functions which can locally be expressed as a ratio of
(the images in the localization of) elements of `R`.
Quoting Hartshorne:
For an open set $U ⊆ Spec A$, we define $𝒪(U)$ to be the set of functions
$s : U → ⨆_{𝔭 ∈ U} A_𝔭$, such that $s(𝔭) ∈ A_𝔭$ for each $𝔭$,
and such that $s$ is locally a quotient of elements of $A$:
to be precise, we require that for each $𝔭 ∈ U$, there is a neighborhood $V$ of $𝔭$,
contained in $U$, and elements $a, f ∈ A$, such that for each $𝔮 ∈ V, f ∉ 𝔮$,
and $s(𝔮) = a/f$ in $A_𝔮$.
Now Hartshorne had the disadvantage of not knowing about dependent functions,
so we replace his circumlocution about functions into a disjoint union with
`Π x : U, Localizations x`.
-/
def isLocallyFraction : LocalPredicate (Localizations R) :=
(isFractionPrelocal R).sheafify
@[simp]
theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)} (f : ∀ x : U, Localizations R x) :
(isLocallyFraction R).pred f =
∀ x : U,
∃ (V : _) (_ : x.1 ∈ V) (i : V ⟶ U),
∃ r s : R,
∀ y : V, ¬s ∈ y.1.asIdeal ∧ f (i y : U) * algebraMap _ _ s = algebraMap _ _ r :=
rfl
/-- The functions satisfying `isLocallyFraction` form a subring.
-/
def sectionsSubring (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
Subring (∀ x : U.unop, Localizations R x) where
carrier := { f | (isLocallyFraction R).pred f }
zero_mem' := by
refine fun x => ⟨unop U, x.2, 𝟙 _, 0, 1, fun y => ⟨?_, ?_⟩⟩
· rw [← Ideal.ne_top_iff_one]; exact y.1.isPrime.1
· simp
one_mem' := by
refine fun x => ⟨unop U, x.2, 𝟙 _, 1, 1, fun y => ⟨?_, ?_⟩⟩
· rw [← Ideal.ne_top_iff_one]; exact y.1.isPrime.1
· simp
add_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ra * sb + rb * sa, sa * sb, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ y) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [add_mul, RingHom.map_add, Pi.add_apply, RingHom.map_mul]
erw [← wa, ← wb]
simp only [mul_assoc]
congr 2
rw [mul_comm]
neg_mem' := by
intro a ha x
rcases ha x with ⟨V, m, i, r, s, w⟩
refine ⟨V, m, i, -r, s, ?_⟩
intro y
rcases w y with ⟨nm, w⟩
fconstructor
· exact nm
· simp only [RingHom.map_neg, Pi.neg_apply]
erw [← w]
simp only [neg_mul]
mul_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ra * rb, sa * sb, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ y) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [Pi.mul_apply, RingHom.map_mul]
erw [← wa, ← wb]
simp only [mul_left_comm, mul_assoc, mul_comm]
end StructureSheaf
open StructureSheaf
/-- The structure sheaf (valued in `Type`, not yet `CommRingCat`) is the subsheaf consisting of
functions satisfying `isLocallyFraction`.
-/
def structureSheafInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
subsheafToTypes (isLocallyFraction R)
instance commRingStructureSheafInTypeObj (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
CommRing ((structureSheafInType R).1.obj U) :=
(sectionsSubring R U).toCommRing
open PrimeSpectrum
/-- The structure presheaf, valued in `CommRingCat`, constructed by dressing up the `Type` valued
structure presheaf.
-/
@[simps]
def structurePresheafInCommRing : Presheaf CommRingCat (PrimeSpectrum.Top R) where
obj U := CommRingCat.of ((structureSheafInType R).1.obj U)
map {U V} i :=
{ toFun := (structureSheafInType R).1.map i
map_zero' := rfl
map_add' := fun x y => rfl
map_one' := rfl
map_mul' := fun x y => rfl }
-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
attribute [nolint simpNF] AlgebraicGeometry.structurePresheafInCommRing_map_apply
/-- Some glue, verifying that the structure presheaf valued in `CommRingCat` agrees
with the `Type` valued structure presheaf.
-/
def structurePresheafCompForget :
structurePresheafInCommRing R ⋙ forget CommRingCat ≅ (structureSheafInType R).1 :=
NatIso.ofComponents fun U => Iso.refl _
open TopCat.Presheaf
/-- The structure sheaf on $Spec R$, valued in `CommRingCat`.
This is provided as a bundled `SheafedSpace` as `Spec.SheafedSpace R` later.
-/
def Spec.structureSheaf : Sheaf CommRingCat (PrimeSpectrum.Top R) :=
⟨structurePresheafInCommRing R,
(-- We check the sheaf condition under `forget CommRingCat`.
isSheaf_iff_isSheaf_comp
_ _).mpr
(isSheaf_of_iso (structurePresheafCompForget R).symm (structureSheafInType R).cond)⟩
open Spec (structureSheaf)
namespace StructureSheaf
@[simp]
theorem res_apply (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U)
(s : (structureSheaf R).1.obj (op U)) (x : V) :
((structureSheaf R).1.map i.op s).1 x = (s.1 (i x) : _) :=
rfl
/-
Notation in this comment
X = Spec R
OX = structure sheaf
In the following we construct an isomorphism between OX_p and R_p given any point p corresponding
to a prime ideal in R.
We do this via 8 steps:
1. def const (f g : R) (V) (hv : V ≤ D_g) : OX(V) [for api]
2. def toOpen (U) : R ⟶ OX(U)
3. [2] def toStalk (p : Spec R) : R ⟶ OX_p
4. [2] def toBasicOpen (f : R) : R_f ⟶ OX(D_f)
5. [3] def localizationToStalk (p : Spec R) : R_p ⟶ OX_p
6. def openToLocalization (U) (p) (hp : p ∈ U) : OX(U) ⟶ R_p
7. [6] def stalkToFiberRingHom (p : Spec R) : OX_p ⟶ R_p
8. [5,7] def stalkIso (p : Spec R) : OX_p ≅ R_p
In the square brackets we list the dependencies of a construction on the previous steps.
-/
/-- The section of `structureSheaf R` on an open `U` sending each `x ∈ U` to the element
`f/g` in the localization of `R` at `x`. -/
def const (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
(structureSheaf R).1.obj (op U) :=
⟨fun x => IsLocalization.mk' _ f ⟨g, hu x x.2⟩, fun x =>
⟨U, x.2, 𝟙 _, f, g, fun y => ⟨hu y y.2, IsLocalization.mk'_spec _ _ _⟩⟩⟩
@[simp]
theorem const_apply (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U) :
(const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hu x x.2⟩ :=
rfl
theorem const_apply' (f g : R) (U : Opens (PrimeSpectrum.Top R))
(hu : ∀ x ∈ U, g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) (x : U)
(hx : g ∈ (x : PrimeSpectrum.Top R).asIdeal.primeCompl) :
(const R f g U hu).1 x = IsLocalization.mk' _ f ⟨g, hx⟩ :=
rfl
theorem exists_const (U) (s : (structureSheaf R).1.obj (op U)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) :
∃ (V : Opens (PrimeSpectrum.Top R)) (_ : x ∈ V) (i : V ⟶ U) (f g : R) (hg : _),
const R f g V hg = (structureSheaf R).1.map i.op s :=
let ⟨V, hxV, iVU, f, g, hfg⟩ := s.2 ⟨x, hx⟩
⟨V, hxV, iVU, f, g, fun y hyV => (hfg ⟨y, hyV⟩).1,
Subtype.eq <| funext fun y => IsLocalization.mk'_eq_iff_eq_mul.2 <| Eq.symm <| (hfg y).2⟩
@[simp]
theorem res_const (f g : R) (U hu V hv i) :
(structureSheaf R).1.map i (const R f g U hu) = const R f g V hv :=
rfl
theorem res_const' (f g : R) (V hv) :
(structureSheaf R).1.map (homOfLE hv).op (const R f g (PrimeSpectrum.basicOpen g) fun _ => id) =
const R f g V hv :=
rfl
theorem const_zero (f : R) (U hu) : const R 0 f U hu = 0 :=
Subtype.eq <| funext fun x => IsLocalization.mk'_eq_iff_eq_mul.2 <| by
rw [RingHom.map_zero]
exact (mul_eq_zero_of_left rfl ((algebraMap R (Localizations R x)) _)).symm
theorem const_self (f : R) (U hu) : const R f f U hu = 1 :=
Subtype.eq <| funext fun _ => IsLocalization.mk'_self _ _
theorem const_one (U) : (const R 1 1 U fun _ _ => Submonoid.one_mem _) = 1 :=
const_self R 1 U _
theorem const_add (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
const R f₁ g₁ U hu₁ + const R f₂ g₂ U hu₂ =
const R (f₁ * g₂ + f₂ * g₁) (g₁ * g₂) U fun x hx =>
Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=
Subtype.eq <| funext fun x => Eq.symm <| IsLocalization.mk'_add _ _
⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
theorem const_mul (f₁ f₂ g₁ g₂ : R) (U hu₁ hu₂) :
const R f₁ g₁ U hu₁ * const R f₂ g₂ U hu₂ =
const R (f₁ * f₂) (g₁ * g₂) U fun x hx => Submonoid.mul_mem _ (hu₁ x hx) (hu₂ x hx) :=
Subtype.eq <|
funext fun x =>
Eq.symm <| IsLocalization.mk'_mul _ f₁ f₂ ⟨g₁, hu₁ x x.2⟩ ⟨g₂, hu₂ x x.2⟩
theorem const_ext {f₁ f₂ g₁ g₂ : R} {U hu₁ hu₂} (h : f₁ * g₂ = f₂ * g₁) :
const R f₁ g₁ U hu₁ = const R f₂ g₂ U hu₂ :=
Subtype.eq <|
funext fun x =>
IsLocalization.mk'_eq_of_eq (by rw [mul_comm, Subtype.coe_mk, ← h, mul_comm, Subtype.coe_mk])
theorem const_congr {f₁ f₂ g₁ g₂ : R} {U hu} (hf : f₁ = f₂) (hg : g₁ = g₂) :
const R f₁ g₁ U hu = const R f₂ g₂ U (hg ▸ hu) := by substs hf hg; rfl
theorem const_mul_rev (f g : R) (U hu₁ hu₂) : const R f g U hu₁ * const R g f U hu₂ = 1 := by
rw [const_mul, const_congr R rfl (mul_comm g f), const_self]
theorem const_mul_cancel (f g₁ g₂ : R) (U hu₁ hu₂) :
const R f g₁ U hu₁ * const R g₁ g₂ U hu₂ = const R f g₂ U hu₂ := by
rw [const_mul, const_ext]; rw [mul_assoc]
theorem const_mul_cancel' (f g₁ g₂ : R) (U hu₁ hu₂) :
const R g₁ g₂ U hu₂ * const R f g₁ U hu₁ = const R f g₂ U hu₂ := by
rw [mul_comm, const_mul_cancel]
/-- The canonical ring homomorphism interpreting an element of `R` as
a section of the structure sheaf. -/
def toOpen (U : Opens (PrimeSpectrum.Top R)) :
CommRingCat.of R ⟶ (structureSheaf R).1.obj (op U) where
toFun f :=
⟨fun x => algebraMap R _ f, fun x =>
⟨U, x.2, 𝟙 _, f, 1, fun y =>
⟨(Ideal.ne_top_iff_one _).1 y.1.2.1, by rw [RingHom.map_one, mul_one]⟩⟩⟩
map_one' := Subtype.eq <| funext fun x => RingHom.map_one _
map_mul' f g := Subtype.eq <| funext fun x => RingHom.map_mul _ _ _
map_zero' := Subtype.eq <| funext fun x => RingHom.map_zero _
map_add' f g := Subtype.eq <| funext fun x => RingHom.map_add _ _ _
@[simp]
theorem toOpen_res (U V : Opens (PrimeSpectrum.Top R)) (i : V ⟶ U) :
toOpen R U ≫ (structureSheaf R).1.map i.op = toOpen R V :=
rfl
@[simp]
theorem toOpen_apply (U : Opens (PrimeSpectrum.Top R)) (f : R) (x : U) :
(toOpen R U f).1 x = algebraMap _ _ f :=
rfl
theorem toOpen_eq_const (U : Opens (PrimeSpectrum.Top R)) (f : R) :
toOpen R U f = const R f 1 U fun x _ => (Ideal.ne_top_iff_one _).1 x.2.1 :=
Subtype.eq <| funext fun _ => Eq.symm <| IsLocalization.mk'_one _ f
/-- The canonical ring homomorphism interpreting an element of `R` as an element of
the stalk of `structureSheaf R` at `x`. -/
def toStalk (x : PrimeSpectrum.Top R) : CommRingCat.of R ⟶ (structureSheaf R).presheaf.stalk x :=
(toOpen R ⊤ ≫ (structureSheaf R).presheaf.germ ⟨x, by trivial⟩)
@[simp]
theorem toOpen_germ (U : Opens (PrimeSpectrum.Top R)) (x : U) :
toOpen R U ≫ (structureSheaf R).presheaf.germ x = toStalk R x := by
rw [← toOpen_res R ⊤ U (homOfLE le_top : U ⟶ ⊤), Category.assoc, Presheaf.germ_res]; rfl
@[simp]
theorem germ_toOpen (U : Opens (PrimeSpectrum.Top R)) (x : U) (f : R) :
(structureSheaf R).presheaf.germ x (toOpen R U f) = toStalk R x f := by rw [← toOpen_germ]; rfl
theorem germ_to_top (x : PrimeSpectrum.Top R) (f : R) :
(structureSheaf R).presheaf.germ (⟨x, trivial⟩ : (⊤ : Opens (PrimeSpectrum.Top R)))
(toOpen R ⊤ f) =
toStalk R x f :=
rfl
theorem isUnit_to_basicOpen_self (f : R) : IsUnit (toOpen R (PrimeSpectrum.basicOpen f) f) :=
isUnit_of_mul_eq_one _ (const R 1 f (PrimeSpectrum.basicOpen f) fun _ => id) <| by
rw [toOpen_eq_const, const_mul_rev]
theorem isUnit_toStalk (x : PrimeSpectrum.Top R) (f : x.asIdeal.primeCompl) :
IsUnit (toStalk R x (f : R)) := by
erw [← germ_toOpen R (PrimeSpectrum.basicOpen (f : R)) ⟨x, f.2⟩ (f : R)]
exact RingHom.isUnit_map _ (isUnit_to_basicOpen_self R f)
/-- The canonical ring homomorphism from the localization of `R` at `p` to the stalk
of the structure sheaf at the point `p`. -/
def localizationToStalk (x : PrimeSpectrum.Top R) :
CommRingCat.of (Localization.AtPrime x.asIdeal) ⟶ (structureSheaf R).presheaf.stalk x :=
show Localization.AtPrime x.asIdeal →+* _ from IsLocalization.lift (isUnit_toStalk R x)
@[simp]
theorem localizationToStalk_of (x : PrimeSpectrum.Top R) (f : R) :
localizationToStalk R x (algebraMap _ (Localization _) f) = toStalk R x f :=
IsLocalization.lift_eq (S := Localization x.asIdeal.primeCompl) _ f
@[simp]
theorem localizationToStalk_mk' (x : PrimeSpectrum.Top R) (f : R) (s : x.asIdeal.primeCompl) :
localizationToStalk R x (IsLocalization.mk' (Localization.AtPrime x.asIdeal) f s) =
(structureSheaf R).presheaf.germ (⟨x, s.2⟩ : PrimeSpectrum.basicOpen (s : R))
(const R f s (PrimeSpectrum.basicOpen s) fun _ => id) :=
(IsLocalization.lift_mk'_spec (S := Localization.AtPrime x.asIdeal) _ _ _ _).2 <| by
erw [← germ_toOpen R (PrimeSpectrum.basicOpen s) ⟨x, s.2⟩,
← germ_toOpen R (PrimeSpectrum.basicOpen s) ⟨x, s.2⟩, ← RingHom.map_mul, toOpen_eq_const,
toOpen_eq_const, const_mul_cancel']
/-- The ring homomorphism that takes a section of the structure sheaf of `R` on the open set `U`,
implemented as a subtype of dependent functions to localizations at prime ideals, and evaluates
the section on the point corresponding to a given prime ideal. -/
def openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R) (hx : x ∈ U) :
(structureSheaf R).1.obj (op U) ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) where
toFun s := (s.1 ⟨x, hx⟩ : _)
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
@[simp]
theorem coe_openToLocalization (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) :
(openToLocalization R U x hx :
(structureSheaf R).1.obj (op U) → Localization.AtPrime x.asIdeal) =
fun s => (s.1 ⟨x, hx⟩ : _) :=
rfl
theorem openToLocalization_apply (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
openToLocalization R U x hx s = (s.1 ⟨x, hx⟩ : _) :=
rfl
/-- The ring homomorphism from the stalk of the structure sheaf of `R` at a point corresponding to
a prime ideal `p` to the localization of `R` at `p`,
formed by gluing the `openToLocalization` maps. -/
def stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
(structureSheaf R).presheaf.stalk x ⟶ CommRingCat.of (Localization.AtPrime x.asIdeal) :=
Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (structureSheaf R).1)
{ pt := _
ι := { app := fun U =>
openToLocalization R ((OpenNhds.inclusion _).obj (unop U)) x (unop U).2 } }
@[simp]
theorem germ_comp_stalkToFiberRingHom (U : Opens (PrimeSpectrum.Top R)) (x : U) :
(structureSheaf R).presheaf.germ x ≫ stalkToFiberRingHom R x = openToLocalization R U x x.2 :=
Limits.colimit.ι_desc _ _
@[simp]
theorem stalkToFiberRingHom_germ' (U : Opens (PrimeSpectrum.Top R)) (x : PrimeSpectrum.Top R)
(hx : x ∈ U) (s : (structureSheaf R).1.obj (op U)) :
stalkToFiberRingHom R x ((structureSheaf R).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom R U ⟨x, hx⟩ : _) s
@[simp]
theorem stalkToFiberRingHom_germ (U : Opens (PrimeSpectrum.Top R)) (x : U)
(s : (structureSheaf R).1.obj (op U)) :
stalkToFiberRingHom R x ((structureSheaf R).presheaf.germ x s) = s.1 x := by
cases x; exact stalkToFiberRingHom_germ' R U _ _ _
@[simp]
theorem toStalk_comp_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
-- Porting note: now `algebraMap _ _` needs to be explicitly typed
toStalk R x ≫ stalkToFiberRingHom R x = algebraMap R (Localization.AtPrime x.asIdeal) := by
erw [toStalk, Category.assoc, germ_comp_stalkToFiberRingHom]; rfl
@[simp]
theorem stalkToFiberRingHom_toStalk (x : PrimeSpectrum.Top R) (f : R) :
-- Porting note: now `algebraMap _ _` needs to be explicitly typed
stalkToFiberRingHom R x (toStalk R x f) = algebraMap R (Localization.AtPrime x.asIdeal) f :=
RingHom.ext_iff.1 (toStalk_comp_stalkToFiberRingHom R x) _
/-- The ring isomorphism between the stalk of the structure sheaf of `R` at a point `p`
corresponding to a prime ideal in `R` and the localization of `R` at `p`. -/
@[simps]
def stalkIso (x : PrimeSpectrum.Top R) :
(structureSheaf R).presheaf.stalk x ≅ CommRingCat.of (Localization.AtPrime x.asIdeal) where
hom := stalkToFiberRingHom R x
inv := localizationToStalk R x
hom_inv_id := by
ext U hxU s
-- Note: this `simp` was longer, but the line below had to become an `erw`
simp only [Category.comp_id]
erw [comp_apply, comp_apply, stalkToFiberRingHom_germ']
obtain ⟨V, hxV, iVU, f, g, (hg : V ≤ PrimeSpectrum.basicOpen _), hs⟩ :=
exists_const _ _ s x hxU
erw [← res_apply R U V iVU s ⟨x, hxV⟩, ← hs, const_apply, localizationToStalk_mk']
refine (structureSheaf R).presheaf.germ_ext V hxV (homOfLE hg) iVU ?_
dsimp
erw [← hs, res_const']
inv_hom_id :=
@IsLocalization.ringHom_ext R _ x.asIdeal.primeCompl (Localization.AtPrime x.asIdeal) _ _
(Localization.AtPrime x.asIdeal) _ _
(RingHom.comp (stalkToFiberRingHom R x) (localizationToStalk R x))
(RingHom.id (Localization.AtPrime _)) <| by
ext f
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
rw [RingHom.comp_apply, RingHom.comp_apply]; erw [localizationToStalk_of,
stalkToFiberRingHom_toStalk]; rw [RingHom.comp_apply, RingHom.id_apply]
instance (x : PrimeSpectrum R) : IsIso (stalkToFiberRingHom R x) :=
(stalkIso R x).isIso_hom
instance (x : PrimeSpectrum R) : IsIso (localizationToStalk R x) :=
(stalkIso R x).isIso_inv
@[simp, reassoc]
theorem stalkToFiberRingHom_localizationToStalk (x : PrimeSpectrum.Top R) :
stalkToFiberRingHom R x ≫ localizationToStalk R x = 𝟙 _ :=
(stalkIso R x).hom_inv_id
@[simp, reassoc]
theorem localizationToStalk_stalkToFiberRingHom (x : PrimeSpectrum.Top R) :
localizationToStalk R x ≫ stalkToFiberRingHom R x = 𝟙 _ :=
(stalkIso R x).inv_hom_id
/-- The canonical ring homomorphism interpreting `s ∈ R_f` as a section of the structure sheaf
on the basic open defined by `f ∈ R`. -/
def toBasicOpen (f : R) :
Localization.Away f →+* (structureSheaf R).1.obj (op <| PrimeSpectrum.basicOpen f) :=
IsLocalization.Away.lift f (isUnit_to_basicOpen_self R f)
@[simp]
theorem toBasicOpen_mk' (s f : R) (g : Submonoid.powers s) :
toBasicOpen R s (IsLocalization.mk' (Localization.Away s) f g) =
const R f g (PrimeSpectrum.basicOpen s) fun x hx => Submonoid.powers_le.2 hx g.2 :=
(IsLocalization.lift_mk'_spec _ _ _ _).2 <| by
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [toOpen_eq_const, toOpen_eq_const]; rw [const_mul_cancel']
@[simp]
theorem localization_toBasicOpen (f : R) :
RingHom.comp (toBasicOpen R f) (algebraMap R (Localization.Away f)) =
toOpen R (PrimeSpectrum.basicOpen f) :=
RingHom.ext fun g => by
rw [toBasicOpen, IsLocalization.Away.lift, RingHom.comp_apply, IsLocalization.lift_eq]
@[simp]
theorem toBasicOpen_to_map (s f : R) :
toBasicOpen R s (algebraMap R (Localization.Away s) f) =
const R f 1 (PrimeSpectrum.basicOpen s) fun _ _ => Submonoid.one_mem _ :=
(IsLocalization.lift_eq _ _).trans <| toOpen_eq_const _ _ _
-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
theorem toBasicOpen_injective (f : R) : Function.Injective (toBasicOpen R f) := by
intro s t h_eq
obtain ⟨a, ⟨b, hb⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) s
obtain ⟨c, ⟨d, hd⟩, rfl⟩ := IsLocalization.mk'_surjective (Submonoid.powers f) t
simp only [toBasicOpen_mk'] at h_eq
rw [IsLocalization.eq]
-- We know that the fractions `a/b` and `c/d` are equal as sections of the structure sheaf on
-- `basicOpen f`. We need to show that they agree as elements in the localization of `R` at `f`.
-- This amounts showing that `r * (d * a) = r * (b * c)`, for some power `r = f ^ n` of `f`.
-- We define `I` as the ideal of *all* elements `r` satisfying the above equation.
let I : Ideal R :=
{ carrier := { r : R | r * (d * a) = r * (b * c) }
zero_mem' := by simp only [Set.mem_setOf_eq, zero_mul]
add_mem' := fun {r₁ r₂} hr₁ hr₂ => by dsimp at hr₁ hr₂ ⊢; simp only [add_mul, hr₁, hr₂]
smul_mem' := fun {r₁ r₂} hr₂ => by dsimp at hr₂ ⊢; simp only [mul_assoc, hr₂] }
-- Our claim now reduces to showing that `f` is contained in the radical of `I`
suffices f ∈ I.radical by
cases' this with n hn
exact ⟨⟨f ^ n, n, rfl⟩, hn⟩
rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.mem_vanishingIdeal]
intro p hfp
contrapose hfp
rw [PrimeSpectrum.mem_zeroLocus, Set.not_subset]
have := congr_fun (congr_arg Subtype.val h_eq) ⟨p, hfp⟩
dsimp at this
-- Porting note: need to tell Lean what `S` is and need to change to `erw`
-- https://github.com/leanprover-community/mathlib4/issues/5164
erw [IsLocalization.eq (S := Localization.AtPrime p.asIdeal)] at this
cases' this with r hr
exact ⟨r.1, hr, r.2⟩
/-
Auxiliary lemma for surjectivity of `toBasicOpen`.
Every section can locally be represented on basic opens `basicOpen g` as a fraction `f/g`
-/
theorem locally_const_basicOpen (U : Opens (PrimeSpectrum.Top R))
(s : (structureSheaf R).1.obj (op U)) (x : U) :
∃ (f g : R) (i : PrimeSpectrum.basicOpen g ⟶ U), x.1 ∈ PrimeSpectrum.basicOpen g ∧
(const R f g (PrimeSpectrum.basicOpen g) fun y hy => hy) =
(structureSheaf R).1.map i.op s := by
-- First, any section `s` can be represented as a fraction `f/g` on some open neighborhood of `x`
-- and we may pass to a `basicOpen h`, since these form a basis
obtain ⟨V, hxV : x.1 ∈ V.1, iVU, f, g, hVDg : V ≤ PrimeSpectrum.basicOpen g, s_eq⟩ :=
exists_const R U s x.1 x.2
obtain ⟨_, ⟨h, rfl⟩, hxDh, hDhV : PrimeSpectrum.basicOpen h ≤ V⟩ :=
PrimeSpectrum.isTopologicalBasis_basic_opens.exists_subset_of_mem_open hxV V.2
-- The problem is of course, that `g` and `h` don't need to coincide.
-- But, since `basicOpen h ≤ basicOpen g`, some power of `h` must be a multiple of `g`
cases' (PrimeSpectrum.basicOpen_le_basicOpen_iff h g).mp (Set.Subset.trans hDhV hVDg) with n hn
-- Actually, we will need a *nonzero* power of `h`.
-- This is because we will need the equality `basicOpen (h ^ n) = basicOpen h`, which only
-- holds for a nonzero power `n`. We therefore artificially increase `n` by one.
replace hn := Ideal.mul_mem_right h (Ideal.span {g}) hn
rw [← pow_succ, Ideal.mem_span_singleton'] at hn
cases' hn with c hc
have basic_opens_eq := PrimeSpectrum.basicOpen_pow h (n + 1) (by omega)
have i_basic_open := eqToHom basic_opens_eq ≫ homOfLE hDhV
-- We claim that `(f * c) / h ^ (n+1)` is our desired representation
use f * c, h ^ (n + 1), i_basic_open ≫ iVU, (basic_opens_eq.symm.le : _) hxDh
rw [op_comp, Functor.map_comp] --, comp_apply, ← s_eq, res_const]
-- Porting note: `comp_apply` can't be rewritten, so use a change
change const R _ _ _ _ = (structureSheaf R).1.map i_basic_open.op
((structureSheaf R).1.map iVU.op s)
rw [← s_eq, res_const]
-- Note that the last rewrite here generated an additional goal, which was a parameter
-- of `res_const`. We prove this goal first
swap
· intro y hy
rw [basic_opens_eq] at hy
exact (Set.Subset.trans hDhV hVDg : _) hy
-- All that is left is a simple calculation
apply const_ext
rw [mul_assoc f c g, hc]
/-
Auxiliary lemma for surjectivity of `toBasicOpen`.
A local representation of a section `s` as fractions `a i / h i` on finitely many basic opens
`basicOpen (h i)` can be "normalized" in such a way that `a i * h j = h i * a j` for all `i, j`
-/
theorem normalize_finite_fraction_representation (U : Opens (PrimeSpectrum.Top R))
(s : (structureSheaf R).1.obj (op U)) {ι : Type*} (t : Finset ι) (a h : ι → R)
(iDh : ∀ i : ι, PrimeSpectrum.basicOpen (h i) ⟶ U)
(h_cover : U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h i))
(hs :
∀ i : ι,
(const R (a i) (h i) (PrimeSpectrum.basicOpen (h i)) fun y hy => hy) =
(structureSheaf R).1.map (iDh i).op s) :
∃ (a' h' : ι → R) (iDh' : ∀ i : ι, PrimeSpectrum.basicOpen (h' i) ⟶ U),
(U ≤ ⨆ i ∈ t, PrimeSpectrum.basicOpen (h' i)) ∧
(∀ (i) (_ : i ∈ t) (j) (_ : j ∈ t), a' i * h' j = h' i * a' j) ∧
∀ i ∈ t,
(structureSheaf R).1.map (iDh' i).op s =
const R (a' i) (h' i) (PrimeSpectrum.basicOpen (h' i)) fun y hy => hy := by
-- First we show that the fractions `(a i * h j) / (h i * h j)` and `(h i * a j) / (h i * h j)`
-- coincide in the localization of `R` at `h i * h j`
have fractions_eq :
∀ i j : ι,
IsLocalization.mk' (Localization.Away (h i * h j))
(a i * h j) ⟨h i * h j, Submonoid.mem_powers _⟩ =
IsLocalization.mk' _ (h i * a j) ⟨h i * h j, Submonoid.mem_powers _⟩ := by
intro i j
let D := PrimeSpectrum.basicOpen (h i * h j)
let iDi : D ⟶ PrimeSpectrum.basicOpen (h i) := homOfLE (PrimeSpectrum.basicOpen_mul_le_left _ _)
let iDj : D ⟶ PrimeSpectrum.basicOpen (h j) :=
homOfLE (PrimeSpectrum.basicOpen_mul_le_right _ _)
-- Crucially, we need injectivity of `toBasicOpen`
apply toBasicOpen_injective R (h i * h j)
rw [toBasicOpen_mk', toBasicOpen_mk']
simp only []
-- Here, both sides of the equation are equal to a restriction of `s`
trans
on_goal 1 =>
convert congr_arg ((structureSheaf R).1.map iDj.op) (hs j).symm using 1
convert congr_arg ((structureSheaf R).1.map iDi.op) (hs i) using 1
all_goals rw [res_const]; apply const_ext; ring
-- The remaining two goals were generated during the rewrite of `res_const`
-- These can be solved immediately
exacts [PrimeSpectrum.basicOpen_mul_le_left _ _, PrimeSpectrum.basicOpen_mul_le_right _ _]
-- From the equality in the localization, we obtain for each `(i,j)` some power `(h i * h j) ^ n`
-- which equalizes `a i * h j` and `h i * a j`
have exists_power :
∀ i j : ι, ∃ n : ℕ, a i * h j * (h i * h j) ^ n = h i * a j * (h i * h j) ^ n := by
intro i j
obtain ⟨⟨c, n, rfl⟩, hc⟩ := IsLocalization.eq.mp (fractions_eq i j)
use n + 1
rw [pow_succ]
dsimp at hc
convert hc using 1 <;> ring
let n := fun p : ι × ι => (exists_power p.1 p.2).choose
have n_spec := fun p : ι × ι => (exists_power p.fst p.snd).choose_spec
-- We need one power `(h i * h j) ^ N` that works for *all* pairs `(i,j)`
-- Since there are only finitely many indices involved, we can pick the supremum.
let N := (t ×ˢ t).sup n
have basic_opens_eq : ∀ i : ι, PrimeSpectrum.basicOpen (h i ^ (N + 1)) =
PrimeSpectrum.basicOpen (h i) := fun i => PrimeSpectrum.basicOpen_pow _ _ (by omega)
-- Expanding the fraction `a i / h i` by the power `(h i) ^ n` gives the desired normalization
refine
⟨fun i => a i * h i ^ N, fun i => h i ^ (N + 1), fun i => eqToHom (basic_opens_eq i) ≫ iDh i,
?_, ?_, ?_⟩
· simpa only [basic_opens_eq] using h_cover
· intro i hi j hj
-- Here we need to show that our new fractions `a i / h i` satisfy the normalization condition
-- Of course, the power `N` we used to expand the fractions might be bigger than the power
-- `n (i, j)` which was originally chosen. We denote their difference by `k`
have n_le_N : n (i, j) ≤ N := Finset.le_sup (Finset.mem_product.mpr ⟨hi, hj⟩)
cases' Nat.le.dest n_le_N with k hk
simp only [← hk, pow_add, pow_one]
-- To accommodate for the difference `k`, we multiply both sides of the equation `n_spec (i, j)`
-- by `(h i * h j) ^ k`
convert congr_arg (fun z => z * (h i * h j) ^ k) (n_spec (i, j)) using 1 <;>
· simp only [n, mul_pow]; ring
-- Lastly, we need to show that the new fractions still represent our original `s`
intro i _
rw [op_comp, Functor.map_comp]
-- Porting note: `comp_apply` can't be rewritten, so use a change
change (structureSheaf R).1.map (eqToHom (basic_opens_eq _)).op
((structureSheaf R).1.map (iDh i).op s) = _
rw [← hs, res_const]
-- additional goal spit out by `res_const`
swap
· exact (basic_opens_eq i).le
apply const_ext
dsimp
rw [pow_succ]
ring
-- Porting note: in the following proof there are two places where `⋃ i, ⋃ (hx : i ∈ _), ... `
-- though `hx` is not used in `...` part, it is still required to maintain the structure of
-- the original proof in mathlib3.
set_option linter.unusedVariables false in
-- The proof here follows the argument in Hartshorne's Algebraic Geometry, Proposition II.2.2.
theorem toBasicOpen_surjective (f : R) : Function.Surjective (toBasicOpen R f) := by
intro s
-- In this proof, `basicOpen f` will play two distinct roles: Firstly, it is an open set in the
-- prime spectrum. Secondly, it is used as an indexing type for various families of objects
-- (open sets, ring elements, ...). In order to make the distinction clear, we introduce a type
-- alias `ι` that is used whenever we want think of it as an indexing type.
let ι : Type u := PrimeSpectrum.basicOpen f
-- First, we pick some cover of basic opens, on which we can represent `s` as a fraction
choose a' h' iDh' hxDh' s_eq' using locally_const_basicOpen R (PrimeSpectrum.basicOpen f) s
-- Since basic opens are compact, we can pass to a finite subcover
obtain ⟨t, ht_cover'⟩ :=
(PrimeSpectrum.isCompact_basicOpen f).elim_finite_subcover
(fun i : ι => PrimeSpectrum.basicOpen (h' i)) (fun i => PrimeSpectrum.isOpen_basicOpen)
-- Here, we need to show that our basic opens actually form a cover of `basicOpen f`
fun x hx => by rw [Set.mem_iUnion]; exact ⟨⟨x, hx⟩, hxDh' ⟨x, hx⟩⟩
simp only [← Opens.coe_iSup, SetLike.coe_subset_coe] at ht_cover'
-- We use the normalization lemma from above to obtain the relation `a i * h j = h i * a j`
obtain ⟨a, h, iDh, ht_cover, ah_ha, s_eq⟩ :=
normalize_finite_fraction_representation R (PrimeSpectrum.basicOpen f)
s t a' h' iDh' ht_cover' s_eq'
clear s_eq' iDh' hxDh' ht_cover' a' h'
-- Porting note: simp with `[← SetLike.coe_subset_coe, Opens.coe_iSup]` does not result in
-- desired form
rw [← SetLike.coe_subset_coe, Opens.coe_iSup] at ht_cover
replace ht_cover : (PrimeSpectrum.basicOpen f : Set <| PrimeSpectrum R) ⊆
⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.basicOpen (h i) : Set _) := by
convert ht_cover using 2
exact funext fun j => by rw [Opens.coe_iSup]
-- Next we show that some power of `f` is a linear combination of the `h i`
obtain ⟨n, hn⟩ : f ∈ (Ideal.span (h '' ↑t)).radical := by
rw [← PrimeSpectrum.vanishingIdeal_zeroLocus_eq_radical, PrimeSpectrum.zeroLocus_span]
-- Porting note: simp with `PrimeSpectrum.basicOpen_eq_zeroLocus_compl` does not work
replace ht_cover : (PrimeSpectrum.zeroLocus {f})ᶜ ⊆
⋃ (i : ι) (x : i ∈ t), (PrimeSpectrum.zeroLocus {h i})ᶜ := by
convert ht_cover
· rw [PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
· simp only [Opens.iSup_mk, Opens.carrier_eq_coe, PrimeSpectrum.basicOpen_eq_zeroLocus_compl]
rw [Set.compl_subset_comm] at ht_cover
-- Why doesn't `simp_rw` do this?
simp_rw [Set.compl_iUnion, compl_compl, ← PrimeSpectrum.zeroLocus_iUnion,
← Finset.set_biUnion_coe, ← Set.image_eq_iUnion] at ht_cover
apply PrimeSpectrum.vanishingIdeal_anti_mono ht_cover
exact PrimeSpectrum.subset_vanishingIdeal_zeroLocus {f} (Set.mem_singleton f)
replace hn := Ideal.mul_mem_right f _ hn
erw [← pow_succ, Finsupp.mem_span_image_iff_total] at hn
rcases hn with ⟨b, b_supp, hb⟩
rw [Finsupp.total_apply_of_mem_supported R b_supp] at hb
dsimp at hb
-- Finally, we have all the ingredients.
-- We claim that our preimage is given by `(∑ (i : ι) ∈ t, b i * a i) / f ^ (n+1)`
use
IsLocalization.mk' (Localization.Away f) (∑ i ∈ t, b i * a i)
(⟨f ^ (n + 1), n + 1, rfl⟩ : Submonoid.powers _)
rw [toBasicOpen_mk']
-- Since the structure sheaf is a sheaf, we can show the desired equality locally.
-- Annoyingly, `Sheaf.eq_of_locally_eq'` requires an open cover indexed by a *type*, so we need to
-- coerce our finset `t` to a type first.
let tt := ((t : Set (PrimeSpectrum.basicOpen f)) : Type u)
apply
(structureSheaf R).eq_of_locally_eq' (fun i : tt => PrimeSpectrum.basicOpen (h i))
(PrimeSpectrum.basicOpen f) fun i : tt => iDh i
· -- This feels a little redundant, since already have `ht_cover` as a hypothesis
-- Unfortunately, `ht_cover` uses a bounded union over the set `t`, while here we have the
-- Union indexed by the type `tt`, so we need some boilerplate to translate one to the other
intro x hx
erw [TopologicalSpace.Opens.mem_iSup]
have := ht_cover hx
rw [← Finset.set_biUnion_coe, Set.mem_iUnion₂] at this
rcases this with ⟨i, i_mem, x_mem⟩
exact ⟨⟨i, i_mem⟩, x_mem⟩
rintro ⟨i, hi⟩
dsimp
change (structureSheaf R).1.map _ _ = (structureSheaf R).1.map _ _
rw [s_eq i hi, res_const]
-- Again, `res_const` spits out an additional goal
swap
· intro y hy
change y ∈ PrimeSpectrum.basicOpen (f ^ (n + 1))
rw [PrimeSpectrum.basicOpen_pow f (n + 1) (by omega)]
exact (leOfHom (iDh i) : _) hy
-- The rest of the proof is just computation
apply const_ext
rw [← hb, Finset.sum_mul, Finset.mul_sum]
apply Finset.sum_congr rfl
intro j hj
rw [mul_assoc, ah_ha j hj i hi]
ring
instance isIso_toBasicOpen (f : R) :
IsIso (show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f) :=
haveI : IsIso ((forget CommRingCat).map
(show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f)) :=
(isIso_iff_bijective _).mpr ⟨toBasicOpen_injective R f, toBasicOpen_surjective R f⟩
isIso_of_reflects_iso _ (forget CommRingCat)
/-- The ring isomorphism between the structure sheaf on `basicOpen f` and the localization of `R`
at the submonoid of powers of `f`. -/
def basicOpenIso (f : R) :
(structureSheaf R).1.obj (op (PrimeSpectrum.basicOpen f)) ≅
CommRingCat.of (Localization.Away f) :=
(asIso (show CommRingCat.of (Localization.Away f) ⟶ _ from toBasicOpen R f)).symm
instance stalkAlgebra (p : PrimeSpectrum R) : Algebra R ((structureSheaf R).presheaf.stalk p) :=
(toStalk R p).toAlgebra
@[simp]
theorem stalkAlgebra_map (p : PrimeSpectrum R) (r : R) :
algebraMap R ((structureSheaf R).presheaf.stalk p) r = toStalk R p r :=
rfl
/-- Stalk of the structure sheaf at a prime p as localization of R -/
instance IsLocalization.to_stalk (p : PrimeSpectrum R) :
IsLocalization.AtPrime ((structureSheaf R).presheaf.stalk p) p.asIdeal := by
convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.AtPrime p.asIdeal) _
(stalkIso R p).symm.commRingCatIsoToRingEquiv).mp
Localization.isLocalization
apply Algebra.algebra_ext
intro
rw [stalkAlgebra_map]
congr 1
change toStalk R p = _ ≫ (stalkIso R p).inv
erw [Iso.eq_comp_inv]
exact toStalk_comp_stalkToFiberRingHom R p
instance openAlgebra (U : (Opens (PrimeSpectrum R))ᵒᵖ) : Algebra R ((structureSheaf R).val.obj U) :=
(toOpen R (unop U)).toAlgebra
@[simp]
theorem openAlgebra_map (U : (Opens (PrimeSpectrum R))ᵒᵖ) (r : R) :
algebraMap R ((structureSheaf R).val.obj U) r = toOpen R (unop U) r :=
rfl
/-- Sections of the structure sheaf of Spec R on a basic open as localization of R -/
instance IsLocalization.to_basicOpen (r : R) :
IsLocalization.Away r ((structureSheaf R).val.obj (op <| PrimeSpectrum.basicOpen r)) := by
convert (IsLocalization.isLocalization_iff_of_ringEquiv (S := Localization.Away r) _
(basicOpenIso R r).symm.commRingCatIsoToRingEquiv).mp
Localization.isLocalization
apply Algebra.algebra_ext
intro x
congr 1
exact (localization_toBasicOpen R r).symm
instance to_basicOpen_epi (r : R) : Epi (toOpen R (PrimeSpectrum.basicOpen r)) :=
⟨fun _ _ h => IsLocalization.ringHom_ext (Submonoid.powers r) h⟩
@[elementwise]
theorem to_global_factors :
toOpen R ⊤ =
CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R))) ≫
toBasicOpen R (1 : R) ≫
(structureSheaf R).1.map (eqToHom PrimeSpectrum.basicOpen_one.symm).op := by
rw [← Category.assoc]
change toOpen R ⊤ =
(CommRingCat.ofHom <| (toBasicOpen R 1).comp (algebraMap R (Localization.Away 1))) ≫
(structureSheaf R).1.map (eqToHom _).op
unfold CommRingCat.ofHom
rw [localization_toBasicOpen R, toOpen_res]
instance isIso_to_global : IsIso (toOpen R ⊤) := by
let hom := CommRingCat.ofHom (algebraMap R (Localization.Away (1 : R)))
haveI : IsIso hom :=
(IsLocalization.atOne R (Localization.Away (1 : R))).toRingEquiv.toCommRingCatIso.isIso_hom
rw [to_global_factors R]
infer_instance
/-- The ring isomorphism between the ring `R` and the global sections `Γ(X, 𝒪ₓ)`. -/
-- Porting note: was @[simps (config := { rhsMd := Tactic.Transparency.semireducible })]
@[simps!]
def globalSectionsIso : CommRingCat.of R ≅ (structureSheaf R).1.obj (op ⊤) :=
asIso (toOpen R ⊤)
-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
attribute [nolint simpNF] AlgebraicGeometry.StructureSheaf.globalSectionsIso_hom_apply_coe
@[simp]
theorem globalSectionsIso_hom (R : CommRingCat) : (globalSectionsIso R).hom = toOpen R ⊤ :=
rfl
@[simp, reassoc, elementwise]
theorem toStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R} (h : x ⤳ y) :
toStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h = toStalk R x := by
dsimp [toStalk]; simp [-toOpen_germ]
@[simp, reassoc, elementwise]
theorem localizationToStalk_stalkSpecializes {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
(h : x ⤳ y) :
StructureSheaf.localizationToStalk R y ≫ (structureSheaf R).presheaf.stalkSpecializes h =
CommRingCat.ofHom (PrimeSpectrum.localizationMapOfSpecializes h) ≫
StructureSheaf.localizationToStalk R x := by
apply IsLocalization.ringHom_ext (S := Localization.AtPrime y.asIdeal) y.asIdeal.primeCompl
erw [RingHom.comp_assoc]
conv_rhs => erw [RingHom.comp_assoc]
dsimp [CommRingCat.ofHom, localizationToStalk, PrimeSpectrum.localizationMapOfSpecializes]
rw [IsLocalization.lift_comp, IsLocalization.lift_comp, IsLocalization.lift_comp]
exact toStalk_stalkSpecializes h
@[simp, reassoc, elementwise]
theorem stalkSpecializes_stalk_to_fiber {R : Type*} [CommRing R] {x y : PrimeSpectrum R}
(h : x ⤳ y) :
(structureSheaf R).presheaf.stalkSpecializes h ≫ StructureSheaf.stalkToFiberRingHom R x =
StructureSheaf.stalkToFiberRingHom R y ≫
-- Porting note: `PrimeSpectrum.localizationMapOfSpecializes h` by itself is interpreted as a
-- ring homomorphism, so it is changed in a way to force it being interpreted as categorical
-- arrow.
(show CommRingCat.of (Localization.AtPrime y.asIdeal) ⟶
CommRingCat.of (Localization.AtPrime x.asIdeal)
from PrimeSpectrum.localizationMapOfSpecializes h) := by
change _ ≫ (StructureSheaf.stalkIso R x).hom = (StructureSheaf.stalkIso R y).hom ≫ _
rw [← Iso.eq_comp_inv, Category.assoc, ← Iso.inv_comp_eq]
exact localizationToStalk_stalkSpecializes h
section Comap
variable {R} {S : Type u} [CommRing S] {P : Type u} [CommRing P]
/--
Given a ring homomorphism `f : R →+* S`, an open set `U` of the prime spectrum of `R` and an open
set `V` of the prime spectrum of `S`, such that `V ⊆ (comap f) ⁻¹' U`, we can push a section `s`
on `U` to a section on `V`, by composing with `Localization.localRingHom _ _ f` from the left and
`comap f` from the right. Explicitly, if `s` evaluates on `comap f p` to `a / b`, its image on `V`
evaluates on `p` to `f(a) / f(b)`.
At the moment, we work with arbitrary dependent functions `s : Π x : U, Localizations R x`. Below,
we prove the predicate `isLocallyFraction` is preserved by this map, hence it can be extended to
a morphism between the structure sheaves of `R` and `S`.
-/
def comapFun (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
(hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (s : ∀ x : U, Localizations R x) (y : V) :
Localizations S y :=
Localization.localRingHom (PrimeSpectrum.comap f y.1).asIdeal _ f rfl
(s ⟨PrimeSpectrum.comap f y.1, hUV y.2⟩ : _)
theorem comapFunIsLocallyFraction (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
(s : ∀ x : U, Localizations R x) (hs : (isLocallyFraction R).toPrelocalPredicate.pred s) :
(isLocallyFraction S).toPrelocalPredicate.pred (comapFun f U V hUV s) := by
rintro ⟨p, hpV⟩
-- Since `s` is locally fraction, we can find a neighborhood `W` of `PrimeSpectrum.comap f p`
-- in `U`, such that `s = a / b` on `W`, for some ring elements `a, b : R`.
rcases hs ⟨PrimeSpectrum.comap f p, hUV hpV⟩ with ⟨W, m, iWU, a, b, h_frac⟩
-- We claim that we can write our new section as the fraction `f a / f b` on the neighborhood
-- `(comap f) ⁻¹ W ⊓ V` of `p`.
refine ⟨Opens.comap (PrimeSpectrum.comap f) W ⊓ V, ⟨m, hpV⟩, Opens.infLERight _ _, f a, f b, ?_⟩
rintro ⟨q, ⟨hqW, hqV⟩⟩
specialize h_frac ⟨PrimeSpectrum.comap f q, hqW⟩
refine ⟨h_frac.1, ?_⟩
dsimp only [comapFun]
erw [← Localization.localRingHom_to_map (PrimeSpectrum.comap f q).asIdeal, ← RingHom.map_mul,
h_frac.2, Localization.localRingHom_to_map]
rfl
/-- For a ring homomorphism `f : R →+* S` and open sets `U` and `V` of the prime spectra of `R` and
`S` such that `V ⊆ (comap f) ⁻¹ U`, the induced ring homomorphism from the structure sheaf of `R`
at `U` to the structure sheaf of `S` at `V`.
Explicitly, this map is given as follows: For a point `p : V`, if the section `s` evaluates on `p`
to the fraction `a / b`, its image on `V` evaluates on `p` to the fraction `f(a) / f(b)`.
-/
def comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) (V : Opens (PrimeSpectrum.Top S))
(hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) :
(structureSheaf R).1.obj (op U) →+* (structureSheaf S).1.obj (op V) where
toFun s := ⟨comapFun f U V hUV s.1, comapFunIsLocallyFraction f U V hUV s.1 s.2⟩
map_one' :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_one, Pi.one_apply, RingHom.map_one]
rfl
map_zero' :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_zero, Pi.zero_apply, RingHom.map_zero]
rfl
map_add' s t :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_add, Pi.add_apply, RingHom.map_add]
rfl
map_mul' s t :=
Subtype.ext <|
funext fun p => by
dsimp
rw [comapFun, (sectionsSubring R (op U)).coe_mul, Pi.mul_apply, RingHom.map_mul]
rfl
@[simp]
theorem comap_apply (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1)
(s : (structureSheaf R).1.obj (op U)) (p : V) :
(comap f U V hUV s).1 p =
Localization.localRingHom (PrimeSpectrum.comap f p.1).asIdeal _ f rfl
(s.1 ⟨PrimeSpectrum.comap f p.1, hUV p.2⟩ : _) :=
rfl
theorem comap_const (f : R →+* S) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (hUV : V.1 ⊆ PrimeSpectrum.comap f ⁻¹' U.1) (a b : R)
(hb : ∀ x : PrimeSpectrum R, x ∈ U → b ∈ x.asIdeal.primeCompl) :
comap f U V hUV (const R a b U hb) =
const S (f a) (f b) V fun p hpV => hb (PrimeSpectrum.comap f p) (hUV hpV) :=
Subtype.eq <|
funext fun p => by
rw [comap_apply, const_apply, const_apply]
erw [Localization.localRingHom_mk']
rfl
/-- For an inclusion `i : V ⟶ U` between open sets of the prime spectrum of `R`, the comap of the
identity from OO_X(U) to OO_X(V) equals as the restriction map of the structure sheaf.
This is a generalization of the fact that, for fixed `U`, the comap of the identity from OO_X(U)
to OO_X(U) is the identity.
-/
theorem comap_id_eq_map (U V : Opens (PrimeSpectrum.Top R)) (iVU : V ⟶ U) :
(comap (RingHom.id R) U V fun p hpV => leOfHom iVU <| hpV) =
(structureSheaf R).1.map iVU.op :=
RingHom.ext fun s => Subtype.eq <| funext fun p => by
rw [comap_apply]
-- Unfortunately, we cannot use `Localization.localRingHom_id` here, because
-- `PrimeSpectrum.comap (RingHom.id R) p` is not *definitionally* equal to `p`. Instead, we use
-- that we can write `s` as a fraction `a/b` in a small neighborhood around `p`. Since
-- `PrimeSpectrum.comap (RingHom.id R) p` equals `p`, it is also contained in the same
-- neighborhood, hence `s` equals `a/b` there too.
obtain ⟨W, hpW, iWU, h⟩ := s.2 (iVU p)
obtain ⟨a, b, h'⟩ := h.eq_mk'
obtain ⟨hb₁, s_eq₁⟩ := h' ⟨p, hpW⟩
obtain ⟨hb₂, s_eq₂⟩ :=
h' ⟨PrimeSpectrum.comap (RingHom.id _) p.1, hpW⟩
dsimp only at s_eq₁ s_eq₂
erw [s_eq₂, Localization.localRingHom_mk', ← s_eq₁, ← res_apply _ _ _ iVU]
/--
The comap of the identity is the identity. In this variant of the lemma, two open subsets `U` and
`V` are given as arguments, together with a proof that `U = V`. This is useful when `U` and `V`
are not definitionally equal.
-/
theorem comap_id {U V : Opens (PrimeSpectrum.Top R)} (hUV : U = V) :
(comap (RingHom.id R) U V fun p hpV => by rwa [hUV, PrimeSpectrum.comap_id]) =
eqToHom (show (structureSheaf R).1.obj (op U) = _ by rw [hUV]) := by
erw [comap_id_eq_map U V (eqToHom hUV.symm), eqToHom_op, eqToHom_map]
@[simp]
theorem comap_id' (U : Opens (PrimeSpectrum.Top R)) :
(comap (RingHom.id R) U U fun p hpU => by rwa [PrimeSpectrum.comap_id]) = RingHom.id _ := by
rw [comap_id rfl]; rfl
theorem comap_comp (f : R →+* S) (g : S →+* P) (U : Opens (PrimeSpectrum.Top R))
(V : Opens (PrimeSpectrum.Top S)) (W : Opens (PrimeSpectrum.Top P))
(hUV : ∀ p ∈ V, PrimeSpectrum.comap f p ∈ U) (hVW : ∀ p ∈ W, PrimeSpectrum.comap g p ∈ V) :
(comap (g.comp f) U W fun p hpW => hUV (PrimeSpectrum.comap g p) (hVW p hpW)) =
(comap g V W hVW).comp (comap f U V hUV) :=
RingHom.ext fun s =>
Subtype.eq <|
funext fun p => by
rw [comap_apply]
erw [Localization.localRingHom_comp _ (PrimeSpectrum.comap g p.1).asIdeal] <;>
-- refl works here, because `PrimeSpectrum.comap (g.comp f) p` is defeq to
-- `PrimeSpectrum.comap f (PrimeSpectrum.comap g p)`
rfl
@[elementwise, reassoc]
theorem toOpen_comp_comap (f : R →+* S) (U : Opens (PrimeSpectrum.Top R)) :
(toOpen R U ≫ comap f U (Opens.comap (PrimeSpectrum.comap f) U) fun _ => id) =
CommRingCat.ofHom f ≫ toOpen S _ :=
RingHom.ext fun _ => Subtype.eq <| funext fun _ => Localization.localRingHom_to_map _ _ _ _ _
lemma comap_basicOpen (f : R →+* S) (x : R) :
comap f (PrimeSpectrum.basicOpen x) (PrimeSpectrum.basicOpen (f x))
(PrimeSpectrum.comap_basicOpen f x).le =
IsLocalization.map (M := .powers x) (T := .powers (f x)) _ f
(Submonoid.powers_le.mpr (Submonoid.mem_powers _)) :=
IsLocalization.ringHom_ext (.powers x) <| by simpa using toOpen_comp_comap f _
end Comap
end StructureSheaf
end AlgebraicGeometry
|
AlgebraicGeometry\Cover\Open.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.OpenImmersion
/-!
# Open covers of schemes
This file provides the basic API for open covers of schemes.
## Main definition
- `AlgebraicGeometry.Scheme.OpenCover`: The type of open covers of a scheme `X`,
consisting of a family of open immersions into `X`,
and for each `x : X` an open immersion (indexed by `f x`) that covers `x`.
- `AlgebraicGeometry.Scheme.affineCover`: `X.affineCover` is a choice of an affine cover of `X`.
- `AlgebraicGeometry.Scheme.AffineOpenCover`: The type of affine open covers of a scheme `X`.
-/
noncomputable section
open TopologicalSpace CategoryTheory Opposite CategoryTheory.Limits
universe v v₁ v₂ u
namespace AlgebraicGeometry
namespace Scheme
-- TODO: provide API to and from a presieve.
/-- An open cover of `X` consists of a family of open immersions into `X`,
and for each `x : X` an open immersion (indexed by `f x`) that covers `x`.
This is merely a coverage in the Zariski pretopology, and it would be optimal
if we could reuse the existing API about pretopologies, However, the definitions of sieves and
grothendieck topologies uses `Prop`s, so that the actual open sets and immersions are hard to
obtain. Also, since such a coverage in the pretopology usually contains a proper class of
immersions, it is quite hard to glue them, reason about finite covers, etc.
-/
structure OpenCover (X : Scheme.{u}) where
/-- index set of an open cover of a scheme `X` -/
J : Type v
/-- the subschemes of an open cover -/
obj : J → Scheme
/-- the embedding of subschemes to `X` -/
map : ∀ j : J, obj j ⟶ X
/-- given a point of `x : X`, `f x` is the index of the subscheme which contains `x` -/
f : X → J
/-- the subschemes covers `X` -/
covers : ∀ x, x ∈ Set.range (map (f x)).1.base
/-- the embedding of subschemes are open immersions -/
IsOpen : ∀ x, IsOpenImmersion (map x) := by infer_instance
@[deprecated (since := "2024-06-23")] alias OpenCover.Covers := OpenCover.covers
attribute [instance] OpenCover.IsOpen
variable {X Y Z : Scheme.{u}} (𝒰 : OpenCover X) (f : X ⟶ Z) (g : Y ⟶ Z)
variable [∀ x, HasPullback (𝒰.map x ≫ f) g]
/-- The affine cover of a scheme. -/
def affineCover (X : Scheme.{u}) : OpenCover X where
J := X
obj x := Spec (X.local_affine x).choose_spec.choose
map x :=
((X.local_affine x).choose_spec.choose_spec.some.inv ≫ X.toLocallyRingedSpace.ofRestrict _ : _)
f x := x
covers := by
intro x
erw [TopCat.coe_comp] -- now `erw` after #13170
rw [Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ]
· erw [Subtype.range_coe_subtype]
exact (X.local_affine x).choose.2
erw [← TopCat.epi_iff_surjective] -- now `erw` after #13170
change Epi ((SheafedSpace.forget _).map (LocallyRingedSpace.forgetToSheafedSpace.map _))
infer_instance
instance : Inhabited X.OpenCover :=
⟨X.affineCover⟩
theorem OpenCover.iUnion_range {X : Scheme.{u}} (𝒰 : X.OpenCover) :
⋃ i, Set.range (𝒰.map i).1.base = Set.univ := by
rw [Set.eq_univ_iff_forall]
intro x
rw [Set.mem_iUnion]
exact ⟨𝒰.f x, 𝒰.covers x⟩
theorem OpenCover.iSup_opensRange {X : Scheme.{u}} (𝒰 : X.OpenCover) :
⨆ i, (𝒰.map i).opensRange = ⊤ :=
Opens.ext <| by rw [Opens.coe_iSup]; exact 𝒰.iUnion_range
/-- Given an open cover `{ Uᵢ }` of `X`, and for each `Uᵢ` an open cover, we may combine these
open covers to form an open cover of `X`. -/
@[simps! J obj map]
def OpenCover.bind (f : ∀ x : 𝒰.J, OpenCover (𝒰.obj x)) : OpenCover X where
J := Σ i : 𝒰.J, (f i).J
obj x := (f x.1).obj x.2
map x := (f x.1).map x.2 ≫ 𝒰.map x.1
f x := ⟨_, (f _).f (𝒰.covers x).choose⟩
covers x := by
let y := (𝒰.covers x).choose
have hy : (𝒰.map (𝒰.f x)).val.base y = x := (𝒰.covers x).choose_spec
rcases (f (𝒰.f x)).covers y with ⟨z, hz⟩
change x ∈ Set.range ((f (𝒰.f x)).map ((f (𝒰.f x)).f y) ≫ 𝒰.map (𝒰.f x)).1.base
use z
erw [comp_apply]
erw [hz, hy] -- now `erw` after #13170
-- Porting note: weirdly, even though no input is needed, `inferInstance` does not work
-- `PresheafedSpace.IsOpenImmersion.comp` is marked as `instance`
IsOpen x := PresheafedSpace.IsOpenImmersion.comp _ _
/-- An isomorphism `X ⟶ Y` is an open cover of `Y`. -/
@[simps J obj map]
def openCoverOfIsIso {X Y : Scheme.{u}} (f : X ⟶ Y) [IsIso f] : OpenCover.{v} Y where
J := PUnit.{v + 1}
obj _ := X
map _ := f
f _ := PUnit.unit
covers x := by
rw [Set.range_iff_surjective.mpr]
all_goals try trivial
rw [← TopCat.epi_iff_surjective]
infer_instance
/-- We construct an open cover from another, by providing the needed fields and showing that the
provided fields are isomorphic with the original open cover. -/
@[simps J obj map]
def OpenCover.copy {X : Scheme.{u}} (𝒰 : OpenCover X) (J : Type*) (obj : J → Scheme)
(map : ∀ i, obj i ⟶ X) (e₁ : J ≃ 𝒰.J) (e₂ : ∀ i, obj i ≅ 𝒰.obj (e₁ i))
(e₂ : ∀ i, map i = (e₂ i).hom ≫ 𝒰.map (e₁ i)) : OpenCover X :=
{ J, obj, map
f := fun x => e₁.symm (𝒰.f x)
covers := fun x => by
rw [e₂, Scheme.comp_val_base, TopCat.coe_comp, Set.range_comp, Set.range_iff_surjective.mpr,
Set.image_univ, e₁.rightInverse_symm]
· exact 𝒰.covers x
· erw [← TopCat.epi_iff_surjective]; infer_instance -- now `erw` after #13170
-- Porting note: weirdly, even though no input is needed, `inferInstance` does not work
-- `PresheafedSpace.IsOpenImmersion.comp` is marked as `instance`
IsOpen := fun i => by rw [e₂]; exact PresheafedSpace.IsOpenImmersion.comp _ _ }
-- Porting note: need more hint on universe level
/-- The pushforward of an open cover along an isomorphism. -/
@[simps! J obj map]
def OpenCover.pushforwardIso {X Y : Scheme.{u}} (𝒰 : OpenCover.{v} X) (f : X ⟶ Y) [IsIso f] :
OpenCover.{v} Y :=
((openCoverOfIsIso.{v, u} f).bind fun _ => 𝒰).copy 𝒰.J _ _
((Equiv.punitProd _).symm.trans (Equiv.sigmaEquivProd PUnit 𝒰.J).symm) (fun _ => Iso.refl _)
fun _ => (Category.id_comp _).symm
/-- Adding an open immersion into an open cover gives another open cover. -/
@[simps]
def OpenCover.add {X Y : Scheme.{u}} (𝒰 : X.OpenCover) (f : Y ⟶ X) [IsOpenImmersion f] :
X.OpenCover where
J := Option 𝒰.J
obj i := Option.rec Y 𝒰.obj i
map i := Option.rec f 𝒰.map i
f x := some (𝒰.f x)
covers := 𝒰.covers
IsOpen := by rintro (_ | _) <;> dsimp <;> infer_instance
/-- Given an open cover on `X`, we may pull them back along a morphism `W ⟶ X` to obtain
an open cover of `W`. -/
@[simps]
def OpenCover.pullbackCover {X W : Scheme.{u}} (𝒰 : X.OpenCover) (f : W ⟶ X) :
W.OpenCover where
J := 𝒰.J
obj x := pullback f (𝒰.map x)
map x := pullback.fst _ _
f x := 𝒰.f (f.1.base x)
covers x := by
rw [←
show _ = (pullback.fst _ _ : pullback f (𝒰.map (𝒰.f (f.1.base x))) ⟶ _).1.base from
PreservesPullback.iso_hom_fst Scheme.forgetToTop f (𝒰.map (𝒰.f (f.1.base x)))]
-- Porting note: `rw` to `erw` on this single lemma
rw [TopCat.coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
TopCat.pullback_fst_range]
· obtain ⟨y, h⟩ := 𝒰.covers (f.1.base x)
exact ⟨y, h.symm⟩
· rw [← TopCat.epi_iff_surjective]; infer_instance
/-- The family of morphisms from the pullback cover to the original cover. -/
def OpenCover.pullbackHom {X W : Scheme.{u}} (𝒰 : X.OpenCover) (f : W ⟶ X) (i) :
(𝒰.pullbackCover f).obj i ⟶ 𝒰.obj i :=
pullback.snd f (𝒰.map i)
@[reassoc (attr := simp)]
lemma OpenCover.pullbackHom_map {X W : Scheme.{u}} (𝒰 : X.OpenCover) (f : W ⟶ X) (i) :
𝒰.pullbackHom f i ≫ 𝒰.map i = (𝒰.pullbackCover f).map i ≫ f := pullback.condition.symm
/-- Given an open cover on `X`, we may pull them back along a morphism `f : W ⟶ X` to obtain
an open cover of `W`. This is similar to `Scheme.OpenCover.pullbackCover`, but here we
take `pullback (𝒰.map x) f` instead of `pullback f (𝒰.map x)`. -/
@[simps]
def OpenCover.pullbackCover' {X W : Scheme.{u}} (𝒰 : X.OpenCover) (f : W ⟶ X) :
W.OpenCover where
J := 𝒰.J
obj x := pullback (𝒰.map x) f
map x := pullback.snd _ _
f x := 𝒰.f (f.1.base x)
covers x := by
rw [←
show _ = (pullback.snd (𝒰.map (𝒰.f (f.1.base x))) f).1.base from
PreservesPullback.iso_hom_snd Scheme.forgetToTop (𝒰.map (𝒰.f (f.1.base x))) f]
-- Porting note: `rw` to `erw` on this single lemma
rw [TopCat.coe_comp, Set.range_comp, Set.range_iff_surjective.mpr, Set.image_univ,
TopCat.pullback_snd_range]
· obtain ⟨y, h⟩ := 𝒰.covers (f.1.base x)
exact ⟨y, h⟩
· rw [← TopCat.epi_iff_surjective]; infer_instance
/-- Every open cover of a quasi-compact scheme can be refined into a finite subcover.
-/
@[simps! obj map]
def OpenCover.finiteSubcover {X : Scheme.{u}} (𝒰 : OpenCover X) [H : CompactSpace X] :
OpenCover X := by
have :=
@CompactSpace.elim_nhds_subcover _ _ H (fun x : X => Set.range (𝒰.map (𝒰.f x)).1.base)
fun x => (IsOpenImmersion.isOpen_range (𝒰.map (𝒰.f x))).mem_nhds (𝒰.covers x)
let t := this.choose
have h : ∀ x : X, ∃ y : t, x ∈ Set.range (𝒰.map (𝒰.f y)).1.base := by
intro x
have h' : x ∈ (⊤ : Set X) := trivial
rw [← Classical.choose_spec this, Set.mem_iUnion] at h'
rcases h' with ⟨y, _, ⟨hy, rfl⟩, hy'⟩
exact ⟨⟨y, hy⟩, hy'⟩
exact
{ J := t
obj := fun x => 𝒰.obj (𝒰.f x.1)
map := fun x => 𝒰.map (𝒰.f x.1)
f := fun x => (h x).choose
covers := fun x => (h x).choose_spec }
instance [H : CompactSpace X] : Fintype 𝒰.finiteSubcover.J := by
delta OpenCover.finiteSubcover; infer_instance
theorem OpenCover.compactSpace {X : Scheme.{u}} (𝒰 : X.OpenCover) [Finite 𝒰.J]
[H : ∀ i, CompactSpace (𝒰.obj i)] : CompactSpace X := by
cases nonempty_fintype 𝒰.J
rw [← isCompact_univ_iff, ← 𝒰.iUnion_range]
apply isCompact_iUnion
intro i
rw [isCompact_iff_compactSpace]
exact
@Homeomorph.compactSpace _ _ _ _ (H i)
(TopCat.homeoOfIso
(asIso
(IsOpenImmersion.isoOfRangeEq (𝒰.map i)
(X.ofRestrict (Opens.openEmbedding ⟨_, (𝒰.IsOpen i).base_open.isOpen_range⟩))
Subtype.range_coe.symm).hom.1.base))
/-- Given open covers `{ Uᵢ }` and `{ Uⱼ }`, we may form the open cover `{ Uᵢ ∩ Uⱼ }`. -/
def OpenCover.inter {X : Scheme.{u}} (𝒰₁ : Scheme.OpenCover.{v₁} X)
(𝒰₂ : Scheme.OpenCover.{v₂} X) : X.OpenCover where
J := 𝒰₁.J × 𝒰₂.J
obj ij := pullback (𝒰₁.map ij.1) (𝒰₂.map ij.2)
map ij := pullback.fst _ _ ≫ 𝒰₁.map ij.1
f x := ⟨𝒰₁.f x, 𝒰₂.f x⟩
covers x := by
rw [IsOpenImmersion.range_pullback_to_base_of_left]
exact ⟨𝒰₁.covers x, 𝒰₂.covers x⟩
IsOpen x := inferInstance
/--
An affine open cover of `X` consists of a family of open immersions into `X` from
spectra of rings.
-/
structure AffineOpenCover (X : Scheme.{u}) where
/-- index set of an affine open cover of a scheme `X` -/
J : Type v
/-- the ring associated to a component of an affine open cover -/
obj : J → CommRingCat.{u}
/-- the embedding of subschemes to `X` -/
map : ∀ j : J, Spec (obj j) ⟶ X
/-- given a point of `x : X`, `f x` is the index of the subscheme which contains `x` -/
f : X → J
/-- the subschemes covers `X` -/
covers : ∀ x, x ∈ Set.range (map (f x)).1.base
/-- the embedding of subschemes are open immersions -/
IsOpen : ∀ x, IsOpenImmersion (map x) := by infer_instance
namespace AffineOpenCover
attribute [instance] AffineOpenCover.IsOpen
/-- The open cover associated to an affine open cover. -/
@[simps]
def openCover {X : Scheme.{u}} (𝓤 : X.AffineOpenCover) : X.OpenCover where
J := 𝓤.J
map := 𝓤.map
f := 𝓤.f
covers := 𝓤.covers
end AffineOpenCover
/-- A choice of an affine open cover of a scheme. -/
def affineOpenCover (X : Scheme.{u}) : X.AffineOpenCover where
J := X.affineCover.J
map := X.affineCover.map
f := X.affineCover.f
covers := X.affineCover.covers
@[simp]
lemma openCover_affineOpenCover (X : Scheme.{u}) : X.affineOpenCover.openCover = X.affineCover :=
rfl
/-- Given any open cover `𝓤`, this is an affine open cover which refines it.
The morphism in the category of open covers which proves that this is indeed a refinement, see
`AlgebraicGeometry.Scheme.OpenCover.fromAffineRefinement`.
-/
def OpenCover.affineRefinement {X : Scheme.{u}} (𝓤 : X.OpenCover) : X.AffineOpenCover where
J := (𝓤.bind fun j => (𝓤.obj j).affineCover).J
map := (𝓤.bind fun j => (𝓤.obj j).affineCover).map
f := (𝓤.bind fun j => (𝓤.obj j).affineCover).f
covers := (𝓤.bind fun j => (𝓤.obj j).affineCover).covers
/-- The pullback of the affine refinement is the pullback of the affine cover. -/
def OpenCover.pullbackCoverAffineRefinementObjIso (f : X ⟶ Y) (𝒰 : Y.OpenCover) (i) :
(𝒰.affineRefinement.openCover.pullbackCover f).obj i ≅
((𝒰.obj i.1).affineCover.pullbackCover (𝒰.pullbackHom f i.1)).obj i.2 :=
pullbackSymmetry _ _ ≪≫ (pullbackRightPullbackFstIso _ _ _).symm ≪≫
pullbackSymmetry _ _ ≪≫ asIso (pullback.map _ _ _ _ (pullbackSymmetry _ _).hom (𝟙 _) (𝟙 _)
(by simp [pullbackHom]) (by simp))
@[reassoc]
lemma OpenCover.pullbackCoverAffineRefinementObjIso_inv_map (f : X ⟶ Y) (𝒰 : Y.OpenCover) (i) :
(𝒰.pullbackCoverAffineRefinementObjIso f i).inv ≫
(𝒰.affineRefinement.openCover.pullbackCover f).map i =
((𝒰.obj i.1).affineCover.pullbackCover (𝒰.pullbackHom f i.1)).map i.2 ≫
(𝒰.pullbackCover f).map i.1 := by
simp only [pullbackCover_obj, AffineOpenCover.openCover_obj, AffineOpenCover.openCover_map,
pullbackCoverAffineRefinementObjIso, Iso.trans_inv, asIso_inv, Iso.symm_inv, Category.assoc,
pullbackCover_map, pullbackSymmetry_inv_comp_fst, IsIso.inv_comp_eq, limit.lift_π_assoc, id_eq,
PullbackCone.mk_pt, cospan_left, PullbackCone.mk_π_app, pullbackSymmetry_hom_comp_fst]
convert pullbackSymmetry_inv_comp_snd_assoc
((𝒰.obj i.1).affineCover.map i.2) (pullback.fst _ _) _ using 2
exact pullbackRightPullbackFstIso_hom_snd _ _ _
@[reassoc]
lemma OpenCover.pullbackCoverAffineRefinementObjIso_inv_pullbackHom
(f : X ⟶ Y) (𝒰 : Y.OpenCover) (i) :
(𝒰.pullbackCoverAffineRefinementObjIso f i).inv ≫
𝒰.affineRefinement.openCover.pullbackHom f i =
(𝒰.obj i.1).affineCover.pullbackHom (𝒰.pullbackHom f i.1) i.2 := by
simp only [pullbackCover_obj, pullbackHom, AffineOpenCover.openCover_obj,
AffineOpenCover.openCover_map, pullbackCoverAffineRefinementObjIso, Iso.trans_inv, asIso_inv,
Iso.symm_inv, Category.assoc, pullbackSymmetry_inv_comp_snd, IsIso.inv_comp_eq, limit.lift_π,
id_eq, PullbackCone.mk_pt, PullbackCone.mk_π_app, Category.comp_id]
convert pullbackSymmetry_inv_comp_fst ((𝒰.obj i.1).affineCover.map i.2) (pullback.fst _ _)
exact pullbackRightPullbackFstIso_hom_fst _ _ _
section category
/--
A morphism between open covers `𝓤 ⟶ 𝓥` indicates that `𝓤` is a refinement of `𝓥`.
Since open covers of schemes are indexed, the definition also involves a map on the
indexing types.
-/
structure OpenCover.Hom {X : Scheme.{u}} (𝓤 𝓥 : OpenCover.{v} X) where
/-- The map on indexing types associated to a morphism of open covers. -/
idx : 𝓤.J → 𝓥.J
/-- The morphism between open subsets associated to a morphism of open covers. -/
app (j : 𝓤.J) : 𝓤.obj j ⟶ 𝓥.obj (idx j)
isOpen (j : 𝓤.J) : IsOpenImmersion (app j) := by infer_instance
w (j : 𝓤.J) : app j ≫ 𝓥.map _ = 𝓤.map _ := by aesop_cat
attribute [reassoc (attr := simp)] OpenCover.Hom.w
attribute [instance] OpenCover.Hom.isOpen
/-- The identity morphism in the category of open covers of a scheme. -/
def OpenCover.Hom.id {X : Scheme.{u}} (𝓤 : OpenCover.{v} X) : 𝓤.Hom 𝓤 where
idx j := j
app j := 𝟙 _
/-- The composition of two morphisms in the category of open covers of a scheme. -/
def OpenCover.Hom.comp {X : Scheme.{u}} {𝓤 𝓥 𝓦 : OpenCover.{v} X}
(f : 𝓤.Hom 𝓥) (g : 𝓥.Hom 𝓦) : 𝓤.Hom 𝓦 where
idx j := g.idx <| f.idx j
app j := f.app _ ≫ g.app _
instance OpenCover.category {X : Scheme.{u}} : Category (OpenCover.{v} X) where
Hom 𝓤 𝓥 := 𝓤.Hom 𝓥
id := OpenCover.Hom.id
comp f g := f.comp g
@[simp]
lemma OpenCover.id_idx_apply {X : Scheme.{u}} (𝓤 : X.OpenCover) (j : 𝓤.J) :
(𝟙 𝓤 : 𝓤 ⟶ 𝓤).idx j = j := rfl
@[simp]
lemma OpenCover.id_app {X : Scheme.{u}} (𝓤 : X.OpenCover) (j : 𝓤.J) :
(𝟙 𝓤 : 𝓤 ⟶ 𝓤).app j = 𝟙 _ := rfl
@[simp]
lemma OpenCover.comp_idx_apply {X : Scheme.{u}} {𝓤 𝓥 𝓦 : X.OpenCover}
(f : 𝓤 ⟶ 𝓥) (g : 𝓥 ⟶ 𝓦) (j : 𝓤.J) :
(f ≫ g).idx j = g.idx (f.idx j) := rfl
@[simp]
lemma OpenCover.comp_app {X : Scheme.{u}} {𝓤 𝓥 𝓦 : X.OpenCover}
(f : 𝓤 ⟶ 𝓥) (g : 𝓥 ⟶ 𝓦) (j : 𝓤.J) :
(f ≫ g).app j = f.app j ≫ g.app _ := rfl
end category
/-- Given any open cover `𝓤`, this is an affine open cover which refines it. -/
def OpenCover.fromAffineRefinement {X : Scheme.{u}} (𝓤 : X.OpenCover) :
𝓤.affineRefinement.openCover ⟶ 𝓤 where
idx j := j.fst
app j := (𝓤.obj j.fst).affineCover.map _
/-- If two global sections agree after restriction to each member of an open cover, then
they agree globally. -/
lemma OpenCover.ext_elem {X : Scheme.{u}} {U : X.Opens} (f g : Γ(X, U)) (𝒰 : X.OpenCover)
(h : ∀ i : 𝒰.J, (𝒰.map i).app U f = (𝒰.map i).app U g) : f = g := by
fapply TopCat.Sheaf.eq_of_locally_eq' X.sheaf
(fun i ↦ (𝒰.map (𝒰.f i)).opensRange ⊓ U) _ (fun _ ↦ homOfLE inf_le_right)
· intro x hx
simp only [Opens.iSup_mk, Opens.carrier_eq_coe, Opens.coe_inf, Hom.opensRange_coe, Opens.coe_mk,
Set.mem_iUnion, Set.mem_inter_iff, Set.mem_range, SetLike.mem_coe, exists_and_right]
refine ⟨?_, hx⟩
simpa using ⟨_, 𝒰.covers x⟩
· intro x
replace h := h (𝒰.f x)
rw [← IsOpenImmersion.map_ΓIso_inv] at h
exact (IsOpenImmersion.ΓIso (𝒰.map (𝒰.f x)) U).commRingCatIsoToRingEquiv.symm.injective h
/-- If the restriction of a global section to each member of an open cover is zero, then it is
globally zero. -/
lemma zero_of_zero_cover {X : Scheme.{u}} {U : X.Opens} (s : Γ(X, U)) (𝒰 : X.OpenCover)
(h : ∀ i : 𝒰.J, (𝒰.map i).app U s = 0) : s = 0 :=
𝒰.ext_elem s 0 (fun i ↦ by rw [map_zero]; exact h i)
/-- If a global section is nilpotent on each member of a finite open cover, then `f` is
nilpotent. -/
lemma isNilpotent_of_isNilpotent_cover {X : Scheme.{u}} {U : X.Opens} (s : Γ(X, U))
(𝒰 : X.OpenCover) [Finite 𝒰.J] (h : ∀ i : 𝒰.J, IsNilpotent ((𝒰.map i).app U s)) :
IsNilpotent s := by
choose fn hfn using h
have : Fintype 𝒰.J := Fintype.ofFinite 𝒰.J
/- the maximum of all `fn i` (exists, because `𝒰.J` is finite) -/
let N : ℕ := Finset.sup Finset.univ fn
have hfnleN (i : 𝒰.J) : fn i ≤ N := Finset.le_sup (Finset.mem_univ i)
use N
apply zero_of_zero_cover (𝒰 := 𝒰)
on_goal 1 => intro i; simp only [map_pow]
-- This closes both remaining goals at once.
exact pow_eq_zero_of_le (hfnleN i) (hfn i)
section deprecated
/-- The basic open sets form an affine open cover of `Spec R`. -/
def affineBasisCoverOfAffine (R : CommRingCat.{u}) : OpenCover (Spec R) where
J := R
obj r := Spec (CommRingCat.of <| Localization.Away r)
map r := Spec.map (CommRingCat.ofHom (algebraMap R (Localization.Away r)))
f _ := 1
covers r := by
rw [Set.range_iff_surjective.mpr ((TopCat.epi_iff_surjective _).mp _)]
· exact trivial
· -- Porting note: need more hand holding here because Lean knows that
-- `CommRing.ofHom ...` is iso, but without `ofHom` Lean does not know what to do
change Epi (Spec.map (CommRingCat.ofHom (algebraMap _ _))).1.base
infer_instance
IsOpen x := AlgebraicGeometry.Scheme.basic_open_isOpenImmersion x
/-- We may bind the basic open sets of an open affine cover to form an affine cover that is also
a basis. -/
def affineBasisCover (X : Scheme.{u}) : OpenCover X :=
X.affineCover.bind fun _ => affineBasisCoverOfAffine _
/-- The coordinate ring of a component in the `affine_basis_cover`. -/
def affineBasisCoverRing (X : Scheme.{u}) (i : X.affineBasisCover.J) : CommRingCat :=
CommRingCat.of <| @Localization.Away (X.local_affine i.1).choose_spec.choose _ i.2
theorem affineBasisCover_obj (X : Scheme.{u}) (i : X.affineBasisCover.J) :
X.affineBasisCover.obj i = Spec (X.affineBasisCoverRing i) :=
rfl
theorem affineBasisCover_map_range (X : Scheme.{u}) (x : X)
(r : (X.local_affine x).choose_spec.choose) :
Set.range (X.affineBasisCover.map ⟨x, r⟩).1.base =
(X.affineCover.map x).1.base '' (PrimeSpectrum.basicOpen r).1 := by
erw [coe_comp, Set.range_comp]
-- Porting note: `congr` fails to see the goal is comparing image of the same function
refine congr_arg (_ '' ·) ?_
exact (PrimeSpectrum.localization_away_comap_range (Localization.Away r) r : _)
theorem affineBasisCover_is_basis (X : Scheme.{u}) :
TopologicalSpace.IsTopologicalBasis
{x : Set X |
∃ a : X.affineBasisCover.J, x = Set.range (X.affineBasisCover.map a).1.base} := by
apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
· rintro _ ⟨a, rfl⟩
exact IsOpenImmersion.isOpen_range (X.affineBasisCover.map a)
· rintro a U haU hU
rcases X.affineCover.covers a with ⟨x, e⟩
let U' := (X.affineCover.map (X.affineCover.f a)).1.base ⁻¹' U
have hxU' : x ∈ U' := by rw [← e] at haU; exact haU
rcases PrimeSpectrum.isBasis_basic_opens.exists_subset_of_mem_open hxU'
((X.affineCover.map (X.affineCover.f a)).1.base.continuous_toFun.isOpen_preimage _
hU) with
⟨_, ⟨_, ⟨s, rfl⟩, rfl⟩, hxV, hVU⟩
refine ⟨_, ⟨⟨_, s⟩, rfl⟩, ?_, ?_⟩ <;> erw [affineBasisCover_map_range]
· exact ⟨x, hxV, e⟩
· rw [Set.image_subset_iff]; exact hVU
end deprecated
end Scheme
end AlgebraicGeometry
|
AlgebraicGeometry\EllipticCurve\Affine.lean | /-
Copyright (c) 2023 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.Algebra.Polynomial.Bivariate
import Mathlib.AlgebraicGeometry.EllipticCurve.Weierstrass
/-!
# Affine coordinates for Weierstrass curves
This file defines the type of points on a Weierstrass curve as an inductive, consisting of the point
at infinity and affine points satisfying a Weierstrass equation with a nonsingular condition. This
file also defines the negation and addition operations of the group law for this type, and proves
that they respect the Weierstrass equation and the nonsingular condition. The fact that they form an
abelian group is proven in `Mathlib.AlgebraicGeometry.EllipticCurve.Group`.
## Mathematical background
Let `W` be a Weierstrass curve over a field `F`. A rational point on `W` is simply a point
$[X:Y:Z]$ defined over `F` in the projective plane satisfying the homogeneous cubic equation
$Y^2Z + a_1XYZ + a_3YZ^2 = X^3 + a_2X^2Z + a_4XZ^2 + a_6Z^3$. Any such point either lies in the
affine chart $Z \ne 0$ and satisfies the Weierstrass equation obtained by replacing $X/Z$ with $X$
and $Y/Z$ with $Y$, or is the unique point at infinity $0 := [0:1:0]$ when $Z = 0$. With this new
description, a nonsingular rational point on `W` is either $0$ or an affine point $(x, y)$ where
the partial derivatives $W_X(X, Y)$ and $W_Y(X, Y)$ do not vanish simultaneously. For a field
extension `K` of `F`, a `K`-rational point is simply a rational point on `W` base changed to `K`.
The set of nonsingular rational points forms an abelian group under a secant-and-tangent process.
* The identity rational point is `0`.
* Given a nonsingular rational point `P`, its negation `-P` is defined to be the unique third
point of intersection between `W` and the line through `0` and `P`.
Explicitly, if `P` is $(x, y)$, then `-P` is $(x, -y - a_1x - a_3)$.
* Given two points `P` and `Q`, their addition `P + Q` is defined to be the negation of the unique
third point of intersection between `W` and the line `L` through `P` and `Q`.
Explicitly, let `P` be $(x_1, y_1)$ and let `Q` be $(x_2, y_2)$.
* If $x_1 = x_2$ and $y_1 = -y_2 - a_1x_2 - a_3$, then `L` is vertical and `P + Q` is `0`.
* If $x_1 = x_2$ and $y_1 \ne -y_2 - a_1x_2 - a_3$, then `L` is the tangent of `W` at `P = Q`,
and has slope $\ell := (3x_1^2 + 2a_2x_1 + a_4 - a_1y_1) / (2y_1 + a_1x_1 + a_3)$.
* Otherwise $x_1 \ne x_2$, then `L` is the secant of `W` through `P` and `Q`, and has slope
$\ell := (y_1 - y_2) / (x_1 - x_2)$.
In the latter two cases, the $X$-coordinate of `P + Q` is then the unique third solution of the
equation obtained by substituting the line $Y = \ell(X - x_1) + y_1$ into the Weierstrass
equation, and can be written down explicitly as $x := \ell^2 + a_1\ell - a_2 - x_1 - x_2$ by
inspecting the $X^2$ terms. The $Y$-coordinate of `P + Q`, after applying the final negation
that maps $Y$ to $-Y - a_1X - a_3$, is precisely $y := -(\ell(x - x_1) + y_1) - a_1x - a_3$.
The group law on this set is then uniquely determined by these constructions.
## Main definitions
* `WeierstrassCurve.Affine.Equation`: the Weierstrass equation of an affine Weierstrass curve.
* `WeierstrassCurve.Affine.Nonsingular`: the nonsingular condition on an affine Weierstrass curve.
* `WeierstrassCurve.Affine.Point`: a nonsingular rational point on an affine Weierstrass curve.
* `WeierstrassCurve.Affine.Point.neg`: the negation operation on an affine Weierstrass curve.
* `WeierstrassCurve.Affine.Point.add`: the addition operation on an affine Weierstrass curve.
## Main statements
* `WeierstrassCurve.Affine.equation_neg`: negation preserves the Weierstrass equation.
* `WeierstrassCurve.Affine.equation_add`: addition preserves the Weierstrass equation.
* `WeierstrassCurve.Affine.nonsingular_neg`: negation preserves the nonsingular condition.
* `WeierstrassCurve.Affine.nonsingular_add`: addition preserves the nonsingular condition.
* `WeierstrassCurve.Affine.nonsingular_of_Δ_ne_zero`: an affine Weierstrass curve is nonsingular at
every point if its discriminant is non-zero.
* `EllipticCurve.Affine.nonsingular`: an affine elliptic curve is nonsingular at every point.
## Notations
* `W⟮K⟯`: the group of nonsingular rational points on `W` base changed to `K`.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, rational point, affine coordinates
-/
open Polynomial
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
local macro "derivative_simp" : tactic =>
`(tactic| simp only [derivative_C, derivative_X, derivative_X_pow, derivative_neg, derivative_add,
derivative_sub, derivative_mul, derivative_sq])
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_neg, eval_add, eval_sub, eval_mul, eval_pow, evalEval])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow, map_div₀,
Polynomial.map_ofNat, map_C, map_X, Polynomial.map_neg, Polynomial.map_add, Polynomial.map_sub,
Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_div, coe_mapRingHom,
WeierstrassCurve.map])
universe r s u v w
/-! ## Weierstrass curves -/
/-- An abbreviation for a Weierstrass curve in affine coordinates. -/
abbrev WeierstrassCurve.Affine (R : Type u) : Type u :=
WeierstrassCurve R
/-- The coercion to a Weierstrass curve in affine coordinates. -/
abbrev WeierstrassCurve.toAffine {R : Type u} (W : WeierstrassCurve R) : Affine R :=
W
namespace WeierstrassCurve.Affine
variable {R : Type u} [CommRing R] (W : Affine R)
section Equation
/-! ### Weierstrass equations -/
/-- The polynomial $W(X, Y) := Y^2 + a_1XY + a_3Y - (X^3 + a_2X^2 + a_4X + a_6)$ associated to a
Weierstrass curve `W` over `R`. For ease of polynomial manipulation, this is represented as a term
of type `R[X][X]`, where the inner variable represents $X$ and the outer variable represents $Y$.
For clarity, the alternative notations `Y` and `R[X][Y]` are provided in the `Polynomial`
scope to represent the outer variable and the bivariate polynomial ring `R[X][X]` respectively. -/
noncomputable def polynomial : R[X][Y] :=
Y ^ 2 + C (C W.a₁ * X + C W.a₃) * Y - C (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆)
lemma polynomial_eq : W.polynomial =
Cubic.toPoly
⟨0, 1, Cubic.toPoly ⟨0, 0, W.a₁, W.a₃⟩, Cubic.toPoly ⟨-1, -W.a₂, -W.a₄, -W.a₆⟩⟩ := by
simp only [polynomial, Cubic.toPoly]
C_simp
ring1
lemma polynomial_ne_zero [Nontrivial R] : W.polynomial ≠ 0 := by
rw [polynomial_eq]
exact Cubic.ne_zero_of_b_ne_zero one_ne_zero
@[simp]
lemma degree_polynomial [Nontrivial R] : W.polynomial.degree = 2 := by
rw [polynomial_eq]
exact Cubic.degree_of_b_ne_zero' one_ne_zero
@[simp]
lemma natDegree_polynomial [Nontrivial R] : W.polynomial.natDegree = 2 := by
rw [polynomial_eq]
exact Cubic.natDegree_of_b_ne_zero' one_ne_zero
lemma monic_polynomial : W.polynomial.Monic := by
nontriviality R
simpa only [polynomial_eq] using Cubic.monic_of_b_eq_one'
lemma irreducible_polynomial [IsDomain R] : Irreducible W.polynomial := by
by_contra h
rcases (W.monic_polynomial.not_irreducible_iff_exists_add_mul_eq_coeff W.natDegree_polynomial).mp
h with ⟨f, g, h0, h1⟩
simp only [polynomial_eq, Cubic.coeff_eq_c, Cubic.coeff_eq_d] at h0 h1
apply_fun degree at h0 h1
rw [Cubic.degree_of_a_ne_zero' <| neg_ne_zero.mpr <| one_ne_zero' R, degree_mul] at h0
apply (h1.symm.le.trans Cubic.degree_of_b_eq_zero').not_lt
rcases Nat.WithBot.add_eq_three_iff.mp h0.symm with h | h | h | h
-- Porting note: replaced two `any_goals` proofs with two `iterate 2` proofs
iterate 2 rw [degree_add_eq_right_of_degree_lt] <;> simp only [h] <;> decide
iterate 2 rw [degree_add_eq_left_of_degree_lt] <;> simp only [h] <;> decide
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma evalEval_polynomial (x y : R) : W.polynomial.evalEval x y =
y ^ 2 + W.a₁ * x * y + W.a₃ * y - (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) := by
simp only [polynomial]
eval_simp
rw [add_mul, ← add_assoc]
@[simp]
lemma evalEval_polynomial_zero : W.polynomial.evalEval 0 0 = -W.a₆ := by
simp only [evalEval_polynomial, zero_add, zero_sub, mul_zero, zero_pow <| Nat.succ_ne_zero _]
/-- The proposition that an affine point $(x, y)$ lies in `W`. In other words, $W(x, y) = 0$. -/
def Equation (x y : R) : Prop :=
W.polynomial.evalEval x y = 0
lemma equation_iff' (x y : R) : W.Equation x y ↔
y ^ 2 + W.a₁ * x * y + W.a₃ * y - (x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆) = 0 := by
rw [Equation, evalEval_polynomial]
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma equation_iff (x y : R) :
W.Equation x y ↔ y ^ 2 + W.a₁ * x * y + W.a₃ * y = x ^ 3 + W.a₂ * x ^ 2 + W.a₄ * x + W.a₆ := by
rw [equation_iff', sub_eq_zero]
@[simp]
lemma equation_zero : W.Equation 0 0 ↔ W.a₆ = 0 := by
rw [Equation, evalEval_polynomial_zero, neg_eq_zero]
lemma equation_iff_variableChange (x y : R) :
W.Equation x y ↔ (W.variableChange ⟨1, x, 0, y⟩).toAffine.Equation 0 0 := by
rw [equation_iff', ← neg_eq_zero, equation_zero, variableChange_a₆, inv_one, Units.val_one]
congr! 1
ring1
end Equation
section Nonsingular
/-! ### Nonsingular Weierstrass equations -/
/-- The partial derivative $W_X(X, Y)$ of $W(X, Y)$ with respect to $X$.
TODO: define this in terms of `Polynomial.derivative`. -/
noncomputable def polynomialX : R[X][Y] :=
C (C W.a₁) * Y - C (C 3 * X ^ 2 + C (2 * W.a₂) * X + C W.a₄)
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma evalEval_polynomialX (x y : R) :
W.polynomialX.evalEval x y = W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) := by
simp only [polynomialX]
eval_simp
@[simp]
lemma evalEval_polynomialX_zero : W.polynomialX.evalEval 0 0 = -W.a₄ := by
simp only [evalEval_polynomialX, zero_add, zero_sub, mul_zero, zero_pow <| Nat.succ_ne_zero _]
/-- The partial derivative $W_Y(X, Y)$ of $W(X, Y)$ with respect to $Y$.
TODO: define this in terms of `Polynomial.derivative`. -/
noncomputable def polynomialY : R[X][Y] :=
C (C 2) * Y + C (C W.a₁ * X + C W.a₃)
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma evalEval_polynomialY (x y : R) :
W.polynomialY.evalEval x y = 2 * y + W.a₁ * x + W.a₃ := by
simp only [polynomialY]
eval_simp
rw [← add_assoc]
@[simp]
lemma evalEval_polynomialY_zero : W.polynomialY.evalEval 0 0 = W.a₃ := by
simp only [evalEval_polynomialY, zero_add, mul_zero]
@[deprecated (since := "2024-06-19")] alias eval_polynomial := evalEval_polynomial
@[deprecated (since := "2024-06-19")] alias eval_polynomial_zero := evalEval_polynomial_zero
@[deprecated (since := "2024-06-19")] alias eval_polynomialX := evalEval_polynomialX
@[deprecated (since := "2024-06-19")] alias eval_polynomialX_zero := evalEval_polynomialX_zero
@[deprecated (since := "2024-06-19")] alias eval_polynomialY := evalEval_polynomialY
@[deprecated (since := "2024-06-19")] alias eval_polynomialY_zero := evalEval_polynomialY_zero
/-- The proposition that an affine point $(x, y)$ in `W` is nonsingular.
In other words, either $W_X(x, y) \ne 0$ or $W_Y(x, y) \ne 0$.
Note that this definition is only mathematically accurate for fields.
TODO: generalise this definition to be mathematically accurate for a larger class of rings. -/
def Nonsingular (x y : R) : Prop :=
W.Equation x y ∧ (W.polynomialX.evalEval x y ≠ 0 ∨ W.polynomialY.evalEval x y ≠ 0)
lemma nonsingular_iff' (x y : R) : W.Nonsingular x y ↔ W.Equation x y ∧
(W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄) ≠ 0 ∨ 2 * y + W.a₁ * x + W.a₃ ≠ 0) := by
rw [Nonsingular, equation_iff', evalEval_polynomialX, evalEval_polynomialY]
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma nonsingular_iff (x y : R) : W.Nonsingular x y ↔
W.Equation x y ∧ (W.a₁ * y ≠ 3 * x ^ 2 + 2 * W.a₂ * x + W.a₄ ∨ y ≠ -y - W.a₁ * x - W.a₃) := by
rw [nonsingular_iff', sub_ne_zero, ← sub_ne_zero (a := y)]
congr! 3
ring1
@[simp]
lemma nonsingular_zero : W.Nonsingular 0 0 ↔ W.a₆ = 0 ∧ (W.a₃ ≠ 0 ∨ W.a₄ ≠ 0) := by
rw [Nonsingular, equation_zero, evalEval_polynomialX_zero, neg_ne_zero, evalEval_polynomialY_zero,
or_comm]
lemma nonsingular_iff_variableChange (x y : R) :
W.Nonsingular x y ↔ (W.variableChange ⟨1, x, 0, y⟩).toAffine.Nonsingular 0 0 := by
rw [nonsingular_iff', equation_iff_variableChange, equation_zero, ← neg_ne_zero, or_comm,
nonsingular_zero, variableChange_a₃, variableChange_a₄, inv_one, Units.val_one]
simp only [variableChange]
congr! 3 <;> ring1
lemma nonsingular_zero_of_Δ_ne_zero (h : W.Equation 0 0) (hΔ : W.Δ ≠ 0) : W.Nonsingular 0 0 := by
simp only [equation_zero, nonsingular_zero] at *
contrapose! hΔ
simp only [b₂, b₄, b₆, b₈, Δ, h, hΔ]
ring1
/-- A Weierstrass curve is nonsingular at every point if its discriminant is non-zero. -/
lemma nonsingular_of_Δ_ne_zero {x y : R} (h : W.Equation x y) (hΔ : W.Δ ≠ 0) : W.Nonsingular x y :=
(W.nonsingular_iff_variableChange x y).mpr <|
nonsingular_zero_of_Δ_ne_zero _ ((W.equation_iff_variableChange x y).mp h) <| by
rwa [variableChange_Δ, inv_one, Units.val_one, one_pow, one_mul]
end Nonsingular
section Ring
/-! ### Group operation polynomials over a ring -/
/-- The polynomial $-Y - a_1X - a_3$ associated to negation. -/
noncomputable def negPolynomial : R[X][Y] :=
-(Y : R[X][Y]) - C (C W.a₁ * X + C W.a₃)
lemma Y_sub_polynomialY : Y - W.polynomialY = W.negPolynomial := by
rw [polynomialY, negPolynomial]; C_simp; ring
lemma Y_sub_negPolynomial : Y - W.negPolynomial = W.polynomialY := by
rw [← Y_sub_polynomialY, sub_sub_cancel]
/-- The $Y$-coordinate of the negation of an affine point in `W`.
This depends on `W`, and has argument order: $x$, $y$. -/
@[simp]
def negY (x y : R) : R :=
-y - W.a₁ * x - W.a₃
lemma negY_negY (x y : R) : W.negY x (W.negY x y) = y := by
simp only [negY]
ring1
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma eval_negPolynomial (x y : R) : W.negPolynomial.evalEval x y = W.negY x y := by
rw [negY, sub_sub, negPolynomial]
eval_simp
/-- The polynomial $L(X - x) + y$ associated to the line $Y = L(X - x) + y$,
with a slope of $L$ that passes through an affine point $(x, y)$.
This does not depend on `W`, and has argument order: $x$, $y$, $L$. -/
noncomputable def linePolynomial (x y L : R) : R[X] :=
C L * (X - C x) + C y
/-- The polynomial obtained by substituting the line $Y = L*(X - x) + y$, with a slope of $L$
that passes through an affine point $(x, y)$, into the polynomial $W(X, Y)$ associated to `W`.
If such a line intersects `W` at another point $(x', y')$, then the roots of this polynomial are
precisely $x$, $x'$, and the $X$-coordinate of the addition of $(x, y)$ and $(x', y')$.
This depends on `W`, and has argument order: $x$, $y$, $L$. -/
noncomputable def addPolynomial (x y L : R) : R[X] :=
W.polynomial.eval <| linePolynomial x y L
lemma C_addPolynomial (x y L : R) : C (W.addPolynomial x y L) =
(Y - C (linePolynomial x y L)) * (W.negPolynomial - C (linePolynomial x y L)) +
W.polynomial := by
rw [addPolynomial, linePolynomial, polynomial, negPolynomial]
eval_simp
C_simp
ring1
lemma addPolynomial_eq (x y L : R) : W.addPolynomial x y L = -Cubic.toPoly
⟨1, -L ^ 2 - W.a₁ * L + W.a₂,
2 * x * L ^ 2 + (W.a₁ * x - 2 * y - W.a₃) * L + (-W.a₁ * y + W.a₄),
-x ^ 2 * L ^ 2 + (2 * x * y + W.a₃ * x) * L - (y ^ 2 + W.a₃ * y - W.a₆)⟩ := by
rw [addPolynomial, linePolynomial, polynomial, Cubic.toPoly]
eval_simp
C_simp
ring1
/-- The $X$-coordinate of the addition of two affine points $(x_1, y_1)$ and $(x_2, y_2)$ in `W`,
where the line through them is not vertical and has a slope of $L$.
This depends on `W`, and has argument order: $x_1$, $x_2$, $L$. -/
@[simp]
def addX (x₁ x₂ L : R) : R :=
L ^ 2 + W.a₁ * L - W.a₂ - x₁ - x₂
/-- The $Y$-coordinate of the negated addition of two affine points $(x_1, y_1)$ and $(x_2, y_2)$,
where the line through them is not vertical and has a slope of $L$.
This depends on `W`, and has argument order: $x_1$, $x_2$, $y_1$, $L$. -/
@[simp]
def negAddY (x₁ x₂ y₁ L : R) : R :=
L * (W.addX x₁ x₂ L - x₁) + y₁
/-- The $Y$-coordinate of the addition of two affine points $(x_1, y_1)$ and $(x_2, y_2)$ in `W`,
where the line through them is not vertical and has a slope of $L$.
This depends on `W`, and has argument order: $x_1$, $x_2$, $y_1$, $L$. -/
@[simp]
def addY (x₁ x₂ y₁ L : R) : R :=
W.negY (W.addX x₁ x₂ L) (W.negAddY x₁ x₂ y₁ L)
lemma equation_neg_iff (x y : R) : W.Equation x (W.negY x y) ↔ W.Equation x y := by
rw [equation_iff, equation_iff, negY]
congr! 1
ring1
lemma nonsingular_neg_iff (x y : R) : W.Nonsingular x (W.negY x y) ↔ W.Nonsingular x y := by
rw [nonsingular_iff, equation_neg_iff, ← negY, negY_negY, ← @ne_comm _ y, nonsingular_iff]
exact and_congr_right' <| (iff_congr not_and_or.symm not_and_or.symm).mpr <|
not_congr <| and_congr_left fun h => by rw [← h]
lemma equation_add_iff (x₁ x₂ y₁ L : R) :
W.Equation (W.addX x₁ x₂ L) (W.negAddY x₁ x₂ y₁ L) ↔
(W.addPolynomial x₁ y₁ L).eval (W.addX x₁ x₂ L) = 0 := by
rw [Equation, negAddY, addPolynomial, linePolynomial, polynomial]
eval_simp
variable {W}
lemma equation_neg_of {x y : R} (h : W.Equation x <| W.negY x y) : W.Equation x y :=
(W.equation_neg_iff ..).mp h
/-- The negation of an affine point in `W` lies in `W`. -/
lemma equation_neg {x y : R} (h : W.Equation x y) : W.Equation x <| W.negY x y :=
(W.equation_neg_iff ..).mpr h
lemma nonsingular_neg_of {x y : R} (h : W.Nonsingular x <| W.negY x y) : W.Nonsingular x y :=
(W.nonsingular_neg_iff ..).mp h
/-- The negation of a nonsingular affine point in `W` is nonsingular. -/
lemma nonsingular_neg {x y : R} (h : W.Nonsingular x y) : W.Nonsingular x <| W.negY x y :=
(W.nonsingular_neg_iff ..).mpr h
lemma nonsingular_negAdd_of_eval_derivative_ne_zero {x₁ x₂ y₁ L : R}
(hx' : W.Equation (W.addX x₁ x₂ L) (W.negAddY x₁ x₂ y₁ L))
(hx : (W.addPolynomial x₁ y₁ L).derivative.eval (W.addX x₁ x₂ L) ≠ 0) :
W.Nonsingular (W.addX x₁ x₂ L) (W.negAddY x₁ x₂ y₁ L) := by
rw [Nonsingular, and_iff_right hx', negAddY, polynomialX, polynomialY]
eval_simp
contrapose! hx
rw [addPolynomial, linePolynomial, polynomial]
eval_simp
derivative_simp
simp only [zero_add, add_zero, sub_zero, zero_mul, mul_one]
eval_simp
linear_combination (norm := (norm_num1; ring1)) hx.left + L * hx.right
end Ring
section Field
/-! ### Group operation polynomials over a field -/
open Classical in
/-- The slope of the line through two affine points $(x_1, y_1)$ and $(x_2, y_2)$ in `W`.
If $x_1 \ne x_2$, then this line is the secant of `W` through $(x_1, y_1)$ and $(x_2, y_2)$,
and has slope $(y_1 - y_2) / (x_1 - x_2)$. Otherwise, if $y_1 \ne -y_1 - a_1x_1 - a_3$,
then this line is the tangent of `W` at $(x_1, y_1) = (x_2, y_2)$, and has slope
$(3x_1^2 + 2a_2x_1 + a_4 - a_1y_1) / (2y_1 + a_1x_1 + a_3)$. Otherwise, this line is vertical,
and has undefined slope, in which case this function returns the value 0.
This depends on `W`, and has argument order: $x_1$, $x_2$, $y_1$, $y_2$. -/
noncomputable def slope {F : Type u} [Field F] (W : Affine F) (x₁ x₂ y₁ y₂ : F) : F :=
if x₁ = x₂ then if y₁ = W.negY x₂ y₂ then 0
else (3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - W.negY x₁ y₁)
else (y₁ - y₂) / (x₁ - x₂)
variable {F : Type u} [Field F] {W : Affine F}
@[simp]
lemma slope_of_Y_eq {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ = W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ = 0 := by
rw [slope, if_pos hx, if_pos hy]
@[simp]
lemma slope_of_Y_ne {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ ≠ W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ =
(3 * x₁ ^ 2 + 2 * W.a₂ * x₁ + W.a₄ - W.a₁ * y₁) / (y₁ - W.negY x₁ y₁) := by
rw [slope, if_pos hx, if_neg hy]
@[simp]
lemma slope_of_X_ne {x₁ x₂ y₁ y₂ : F} (hx : x₁ ≠ x₂) :
W.slope x₁ x₂ y₁ y₂ = (y₁ - y₂) / (x₁ - x₂) := by
rw [slope, if_neg hx]
lemma slope_of_Y_ne_eq_eval {x₁ x₂ y₁ y₂ : F} (hx : x₁ = x₂) (hy : y₁ ≠ W.negY x₂ y₂) :
W.slope x₁ x₂ y₁ y₂ = -W.polynomialX.evalEval x₁ y₁ / W.polynomialY.evalEval x₁ y₁ := by
rw [slope_of_Y_ne hx hy, evalEval_polynomialX, neg_sub]
congr 1
rw [negY, evalEval_polynomialY]
ring1
lemma Y_eq_of_X_eq {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hx : x₁ = x₂) : y₁ = y₂ ∨ y₁ = W.negY x₂ y₂ := by
rw [equation_iff] at h₁ h₂
rw [← sub_eq_zero, ← sub_eq_zero (a := y₁), ← mul_eq_zero, negY]
linear_combination (norm := (rw [hx]; ring1)) h₁ - h₂
lemma Y_eq_of_Y_ne {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂) (hx : x₁ = x₂)
(hy : y₁ ≠ W.negY x₂ y₂) : y₁ = y₂ :=
(Y_eq_of_X_eq h₁ h₂ hx).resolve_right hy
lemma addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) : W.addPolynomial x₁ y₁ (W.slope x₁ x₂ y₁ y₂) =
-((X - C x₁) * (X - C x₂) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂))) := by
rw [addPolynomial_eq, neg_inj, Cubic.prod_X_sub_C_eq, Cubic.toPoly_injective]
by_cases hx : x₁ = x₂
· rcases hx, Y_eq_of_Y_ne h₁ h₂ hx (hxy hx) with ⟨rfl, rfl⟩
rw [equation_iff] at h₁ h₂
rw [slope_of_Y_ne rfl <| hxy rfl]
rw [negY, ← sub_ne_zero] at hxy
ext
· rfl
· simp only [addX]
ring1
· field_simp [hxy rfl]
ring1
· linear_combination (norm := (field_simp [hxy rfl]; ring1)) -h₁
· rw [equation_iff] at h₁ h₂
rw [slope_of_X_ne hx]
rw [← sub_eq_zero] at hx
ext
· rfl
· simp only [addX]
ring1
· apply mul_right_injective₀ hx
linear_combination (norm := (field_simp [hx]; ring1)) h₂ - h₁
· apply mul_right_injective₀ hx
linear_combination (norm := (field_simp [hx]; ring1)) x₂ * h₁ - x₁ * h₂
/-- The negated addition of two affine points in `W` on a sloped line lies in `W`. -/
lemma equation_negAdd {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) : W.Equation
(W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.negAddY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
rw [equation_add_iff, addPolynomial_slope h₁ h₂ hxy]
eval_simp
rw [neg_eq_zero, sub_self, mul_zero]
/-- The addition of two affine points in `W` on a sloped line lies in `W`. -/
lemma equation_add {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
W.Equation (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) :=
equation_neg <| equation_negAdd h₁ h₂ hxy
lemma derivative_addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁)
(h₂ : W.Equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
derivative (W.addPolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) =
-((X - C x₁) * (X - C x₂) + (X - C x₁) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)) +
(X - C x₂) * (X - C (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂))) := by
rw [addPolynomial_slope h₁ h₂ hxy]
derivative_simp
ring1
/-- The negated addition of two nonsingular affine points in `W` on a sloped line is nonsingular. -/
lemma nonsingular_negAdd {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁) (h₂ : W.Nonsingular x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) : W.Nonsingular
(W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.negAddY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
by_cases hx₁ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₁
· rwa [negAddY, hx₁, sub_self, mul_zero, zero_add]
· by_cases hx₂ : W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = x₂
· by_cases hx : x₁ = x₂
· subst hx
contradiction
· rwa [negAddY, ← neg_sub, mul_neg, hx₂, slope_of_X_ne hx,
div_mul_cancel₀ _ <| sub_ne_zero_of_ne hx, neg_sub, sub_add_cancel]
· apply nonsingular_negAdd_of_eval_derivative_ne_zero <| equation_negAdd h₁.1 h₂.1 hxy
rw [derivative_addPolynomial_slope h₁.left h₂.left hxy]
eval_simp
simpa only [neg_ne_zero, sub_self, mul_zero, add_zero] using
mul_ne_zero (sub_ne_zero_of_ne hx₁) (sub_ne_zero_of_ne hx₂)
/-- The addition of two nonsingular affine points in `W` on a sloped line is nonsingular. -/
lemma nonsingular_add {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁) (h₂ : W.Nonsingular x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
W.Nonsingular (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) (W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) :=
nonsingular_neg <| nonsingular_negAdd h₁ h₂ hxy
variable {x₁ x₂ : F} (y₁ y₂ : F) (hx : x₁ ≠ x₂)
/-- The formula x(P₁ + P₂) = x(P₁ - P₂) - ψ(P₁)ψ(P₂) / (x(P₂) - x(P₁))²,
where ψ(x,y) = 2y + a₁x + a₃. -/
lemma addX_eq_addX_negY_sub :
W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂) = W.addX x₁ x₂ (W.slope x₁ x₂ y₁ (W.negY x₂ y₂))
- (y₁ - W.negY x₁ y₁) * (y₂ - W.negY x₂ y₂) / (x₂ - x₁) ^ 2 := by
simp_rw [slope_of_X_ne hx, addX, negY, ← neg_sub x₁, neg_sq]
field_simp [sub_ne_zero.mpr hx]
ring1
/-- The formula y(P₁)(x(P₂) - x(P₃)) + y(P₂)(x(P₃) - x(P₁)) + y(P₃)(x(P₁) - x(P₂)) = 0,
assuming that P₁ + P₂ + P₃ = O. -/
lemma cyclic_sum_Y_mul_X_sub_X :
letI x₃ := W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)
y₁ * (x₂ - x₃) + y₂ * (x₃ - x₁) + W.negAddY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂) * (x₁ - x₂) = 0 := by
simp_rw [slope_of_X_ne hx, negAddY, addX]
field_simp [sub_ne_zero.mpr hx]
ring1
/-- The formula
ψ(P₁ + P₂) = (ψ(P₂)(x(P₁) - x(P₃)) - ψ(P₁)(x(P₂) - x(P₃))) / (x(P₂) - x(P₁)),
where ψ(x,y) = 2y + a₁x + a₃. -/
lemma addY_sub_negY_addY :
letI x₃ := W.addX x₁ x₂ (W.slope x₁ x₂ y₁ y₂)
letI y₃ := W.addY x₁ x₂ y₁ (W.slope x₁ x₂ y₁ y₂)
y₃ - W.negY x₃ y₃ =
((y₂ - W.negY x₂ y₂) * (x₁ - x₃) - (y₁ - W.negY x₁ y₁) * (x₂ - x₃)) / (x₂ - x₁) := by
simp_rw [addY, negY, eq_div_iff (sub_ne_zero.mpr hx.symm)]
linear_combination 2 * cyclic_sum_Y_mul_X_sub_X y₁ y₂ hx
end Field
section Group
/-! ### Group operations -/
/-- A nonsingular rational point on a Weierstrass curve `W` in affine coordinates. This is either
the unique point at infinity `WeierstrassCurve.Affine.Point.zero` or the nonsingular affine points
`WeierstrassCurve.Affine.Point.some` $(x, y)$ satisfying the Weierstrass equation of `W`. -/
inductive Point
| zero
| some {x y : R} (h : W.Nonsingular x y)
/-- For an algebraic extension `S` of `R`, the type of nonsingular `S`-rational points on `W`. -/
scoped notation3:max W "⟮" S "⟯" => Affine.Point <| baseChange W S
namespace Point
variable {W}
instance : Inhabited W.Point :=
⟨zero⟩
instance : Zero W.Point :=
⟨zero⟩
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma zero_def : (zero : W.Point) = 0 :=
rfl
lemma some_ne_zero {x y : R} (h : W.Nonsingular x y) : some h ≠ 0 := by rintro (_|_)
/-- The negation of a nonsingular rational point on `W`.
Given a nonsingular rational point `P` on `W`, use `-P` instead of `neg P`. -/
def neg : W.Point → W.Point
| 0 => 0
| some h => some <| nonsingular_neg h
instance : Neg W.Point :=
⟨neg⟩
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma neg_def (P : W.Point) : P.neg = -P :=
rfl
@[simp]
lemma neg_zero : (-0 : W.Point) = 0 :=
rfl
@[simp]
lemma neg_some {x y : R} (h : W.Nonsingular x y) : -some h = some (nonsingular_neg h) :=
rfl
instance : InvolutiveNeg W.Point :=
⟨by rintro (_ | _) <;> simp [zero_def]; ring1⟩
variable {F : Type u} [Field F] {W : Affine F}
open Classical in
/-- The addition of two nonsingular rational points on `W`.
Given two nonsingular rational points `P` and `Q` on `W`, use `P + Q` instead of `add P Q`. -/
noncomputable def add : W.Point → W.Point → W.Point
| 0, P => P
| P, 0 => P
| @some _ _ _ x₁ y₁ h₁, @some _ _ _ x₂ y₂ h₂ =>
if h : x₁ = x₂ ∧ y₁ = W.negY x₂ y₂ then 0
else some (nonsingular_add h₁ h₂ fun hx hy ↦ h ⟨hx, hy⟩)
noncomputable instance instAddPoint : Add W.Point :=
⟨add⟩
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma add_def (P Q : W.Point) : P.add Q = P + Q :=
rfl
noncomputable instance instAddZeroClassPoint : AddZeroClass W.Point :=
⟨by rintro (_ | _) <;> rfl, by rintro (_ | _) <;> rfl⟩
@[simp]
lemma add_of_Y_eq {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ = x₂) (hy : y₁ = W.negY x₂ y₂) : some h₁ + some h₂ = 0 := by
simp_rw [← add_def, add]; exact dif_pos ⟨hx, hy⟩
@[simp]
lemma add_self_of_Y_eq {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ = W.negY x₁ y₁) :
some h₁ + some h₁ = 0 :=
add_of_Y_eq rfl hy
@[simp]
lemma add_of_imp {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) : some h₁ + some h₂ = some (nonsingular_add h₁ h₂ hxy) :=
dif_neg fun hn ↦ hxy hn.1 hn.2
@[simp]
lemma add_of_Y_ne {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hy : y₁ ≠ W.negY x₂ y₂) :
some h₁ + some h₂ = some (nonsingular_add h₁ h₂ fun _ ↦ hy) :=
add_of_imp fun _ ↦ hy
lemma add_of_Y_ne' {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hy : y₁ ≠ W.negY x₂ y₂) :
some h₁ + some h₂ = -some (nonsingular_negAdd h₁ h₂ fun _ ↦ hy) :=
add_of_Y_ne hy
@[simp]
lemma add_self_of_Y_ne {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ ≠ W.negY x₁ y₁) :
some h₁ + some h₁ = some (nonsingular_add h₁ h₁ fun _ => hy) :=
add_of_Y_ne hy
lemma add_self_of_Y_ne' {x₁ y₁ : F} {h₁ : W.Nonsingular x₁ y₁} (hy : y₁ ≠ W.negY x₁ y₁) :
some h₁ + some h₁ = -some (nonsingular_negAdd h₁ h₁ fun _ => hy) :=
add_of_Y_ne hy
@[simp]
lemma add_of_X_ne {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ ≠ x₂) : some h₁ + some h₂ = some (nonsingular_add h₁ h₂ fun h => (hx h).elim) :=
add_of_imp fun h ↦ (hx h).elim
lemma add_of_X_ne' {x₁ x₂ y₁ y₂ : F} {h₁ : W.Nonsingular x₁ y₁} {h₂ : W.Nonsingular x₂ y₂}
(hx : x₁ ≠ x₂) : some h₁ + some h₂ = -some (nonsingular_negAdd h₁ h₂ fun h => (hx h).elim) :=
add_of_X_ne hx
@[deprecated (since := "2024-06-03")] alias some_add_some_of_Yeq := add_of_Y_eq
@[deprecated (since := "2024-06-03")] alias some_add_self_of_Yeq := add_self_of_Y_eq
@[deprecated (since := "2024-06-03")] alias some_add_some_of_Yne := add_of_Y_ne
@[deprecated (since := "2024-06-03")] alias some_add_some_of_Yne' := add_of_Y_ne'
@[deprecated (since := "2024-06-03")] alias some_add_self_of_Yne := add_self_of_Y_ne
@[deprecated (since := "2024-06-03")] alias some_add_self_of_Yne' := add_self_of_Y_ne'
@[deprecated (since := "2024-06-03")] alias some_add_some_of_Xne := add_of_X_ne
@[deprecated (since := "2024-06-03")] alias some_add_some_of_Xne' := add_of_X_ne'
end Point
end Group
section Map
/-! ### Maps across ring homomorphisms -/
variable {S : Type v} [CommRing S] (f : R →+* S)
lemma map_polynomial : (W.map f).toAffine.polynomial = W.polynomial.map (mapRingHom f) := by
simp only [polynomial]
map_simp
lemma evalEval_baseChange_polynomial_X_Y :
(W.baseChange R[X][Y]).toAffine.polynomial.evalEval (C X) Y = W.polynomial := by
rw [baseChange, toAffine, map_polynomial, evalEval, eval_map, eval_C_X_eval₂_map_C_X]
variable {W} in
lemma Equation.map {x y : R} (h : W.Equation x y) : Equation (W.map f) (f x) (f y) := by
rw [Equation, map_polynomial, map_mapRingHom_evalEval, ← f.map_zero]; exact congr_arg f h
variable {f} in
lemma map_equation (hf : Function.Injective f) (x y : R) :
(W.map f).toAffine.Equation (f x) (f y) ↔ W.Equation x y := by
simp only [Equation, map_polynomial, map_mapRingHom_evalEval, map_eq_zero_iff f hf]
lemma map_polynomialX : (W.map f).toAffine.polynomialX = W.polynomialX.map (mapRingHom f) := by
simp only [polynomialX]
map_simp
lemma map_polynomialY : (W.map f).toAffine.polynomialY = W.polynomialY.map (mapRingHom f) := by
simp only [polynomialY]
map_simp
variable {f} in
lemma map_nonsingular (hf : Function.Injective f) (x y : R) :
(W.map f).toAffine.Nonsingular (f x) (f y) ↔ W.Nonsingular x y := by
simp only [Nonsingular, evalEval, W.map_equation hf, map_polynomialX,
map_polynomialY, map_mapRingHom_evalEval, map_ne_zero_iff f hf]
lemma map_negPolynomial :
(W.map f).toAffine.negPolynomial = W.negPolynomial.map (mapRingHom f) := by
simp only [negPolynomial]
map_simp
lemma map_negY (x y : R) : (W.map f).toAffine.negY (f x) (f y) = f (W.negY x y) := by
simp only [negY]
map_simp
lemma map_linePolynomial (x y L : R) :
linePolynomial (f x) (f y) (f L) = (linePolynomial x y L).map f := by
simp only [linePolynomial]
map_simp
lemma map_addPolynomial (x y L : R) :
(W.map f).toAffine.addPolynomial (f x) (f y) (f L) = (W.addPolynomial x y L).map f := by
rw [addPolynomial, map_polynomial, eval_map, linePolynomial, addPolynomial, ← coe_mapRingHom,
← eval₂_hom, linePolynomial]
map_simp
lemma map_addX (x₁ x₂ L : R) :
(W.map f).toAffine.addX (f x₁) (f x₂) (f L) = f (W.addX x₁ x₂ L) := by
simp only [addX]
map_simp
lemma map_negAddY (x₁ x₂ y₁ L : R) :
(W.map f).toAffine.negAddY (f x₁) (f x₂) (f y₁) (f L) = f (W.negAddY x₁ x₂ y₁ L) := by
simp only [negAddY, map_addX]
map_simp
lemma map_addY (x₁ x₂ y₁ L : R) :
(W.map f).toAffine.addY (f x₁) (f x₂) (f y₁) (f L) = f (W.toAffine.addY x₁ x₂ y₁ L) := by
simp only [addY, map_negAddY, map_addX, map_negY]
lemma map_slope {F : Type u} [Field F] (W : Affine F) {K : Type v} [Field K] (f : F →+* K)
(x₁ x₂ y₁ y₂ : F) : (W.map f).toAffine.slope (f x₁) (f x₂) (f y₁) (f y₂) =
f (W.slope x₁ x₂ y₁ y₂) := by
by_cases hx : x₁ = x₂
· by_cases hy : y₁ = W.negY x₂ y₂
· rw [slope_of_Y_eq (congr_arg f hx) <| by rw [hy, map_negY], slope_of_Y_eq hx hy, map_zero]
· rw [slope_of_Y_ne (congr_arg f hx) <| W.map_negY f x₂ y₂ ▸ fun h => hy <| f.injective h,
map_negY, slope_of_Y_ne hx hy]
map_simp
· rw [slope_of_X_ne fun h => hx <| f.injective h, slope_of_X_ne hx]
map_simp
end Map
section BaseChange
/-! ### Base changes across algebra homomorphisms -/
variable {R : Type r} [CommRing R] (W : Affine R) {S : Type s} [CommRing S] [Algebra R S]
{A : Type u} [CommRing A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
{B : Type v} [CommRing B] [Algebra R B] [Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B)
lemma baseChange_polynomial : (W.baseChange B).toAffine.polynomial =
(W.baseChange A).toAffine.polynomial.map (mapRingHom f) := by
rw [← map_polynomial, map_baseChange]
variable {g} in
lemma baseChange_equation (hf : Function.Injective f) (x y : A) :
(W.baseChange B).toAffine.Equation (f x) (f y) ↔ (W.baseChange A).toAffine.Equation x y := by
erw [← map_equation _ hf, map_baseChange]
rfl
lemma baseChange_polynomialX : (W.baseChange B).toAffine.polynomialX =
(W.baseChange A).toAffine.polynomialX.map (mapRingHom f) := by
rw [← map_polynomialX, map_baseChange]
lemma baseChange_polynomialY : (W.baseChange B).toAffine.polynomialY =
(W.baseChange A).toAffine.polynomialY.map (mapRingHom f) := by
rw [← map_polynomialY, map_baseChange]
variable {f} in
lemma baseChange_nonsingular (hf : Function.Injective f) (x y : A) :
(W.baseChange B).toAffine.Nonsingular (f x) (f y) ↔
(W.baseChange A).toAffine.Nonsingular x y := by
erw [← map_nonsingular _ hf, map_baseChange]
rfl
lemma baseChange_negPolynomial :
(W.baseChange B).toAffine.negPolynomial =
(W.baseChange A).toAffine.negPolynomial.map (mapRingHom f) := by
rw [← map_negPolynomial, map_baseChange]
lemma baseChange_negY (x y : A) :
(W.baseChange B).toAffine.negY (f x) (f y) = f ((W.baseChange A).toAffine.negY x y) := by
erw [← map_negY, map_baseChange]
rfl
lemma baseChange_addPolynomial (x y L : A) :
(W.baseChange B).toAffine.addPolynomial (f x) (f y) (f L) =
((W.baseChange A).toAffine.addPolynomial x y L).map f := by
rw [← map_addPolynomial, map_baseChange]
rfl
lemma baseChange_addX (x₁ x₂ L : A) :
(W.baseChange B).toAffine.addX (f x₁) (f x₂) (f L) =
f ((W.baseChange A).toAffine.addX x₁ x₂ L) := by
erw [← map_addX, map_baseChange]
rfl
lemma baseChange_negAddY (x₁ x₂ y₁ L : A) :
(W.baseChange B).toAffine.negAddY (f x₁) (f x₂) (f y₁) (f L) =
f ((W.baseChange A).toAffine.negAddY x₁ x₂ y₁ L) := by
erw [← map_negAddY, map_baseChange]
rfl
lemma baseChange_addY (x₁ x₂ y₁ L : A) :
(W.baseChange B).toAffine.addY (f x₁) (f x₂) (f y₁) (f L) =
f ((W.baseChange A).toAffine.addY x₁ x₂ y₁ L) := by
erw [← map_addY, map_baseChange]
rfl
variable {F : Type u} [Field F] [Algebra R F] [Algebra S F] [IsScalarTower R S F]
{K : Type v} [Field K] [Algebra R K] [Algebra S K] [IsScalarTower R S K] (f : F →ₐ[S] K)
{L : Type w} [Field L] [Algebra R L] [Algebra S L] [IsScalarTower R S L] (g : K →ₐ[S] L)
lemma baseChange_slope (x₁ x₂ y₁ y₂ : F) :
(W.baseChange K).toAffine.slope (f x₁) (f x₂) (f y₁) (f y₂) =
f ((W.baseChange F).toAffine.slope x₁ x₂ y₁ y₂) := by
erw [← map_slope, map_baseChange]
rfl
namespace Point
/-- The function from `W⟮F⟯` to `W⟮K⟯` induced by an algebra homomorphism `f : F →ₐ[S] K`,
where `W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/
def mapFun : W⟮F⟯ → W⟮K⟯
| 0 => 0
| some h => some <| (W.baseChange_nonsingular f.injective ..).mpr h
/-- The group homomorphism from `W⟮F⟯` to `W⟮K⟯` induced by an algebra homomorphism `f : F →ₐ[S] K`,
where `W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/
def map : W⟮F⟯ →+ W⟮K⟯ where
toFun := mapFun W f
map_zero' := rfl
map_add' := by
rintro (_ | @⟨x₁, y₁, _⟩) (_ | @⟨x₂, y₂, _⟩)
any_goals rfl
have inj : Function.Injective f := f.injective
by_cases h : x₁ = x₂ ∧ y₁ = negY (W.baseChange F) x₂ y₂
· simp only [add_of_Y_eq h.1 h.2, mapFun]
rw [add_of_Y_eq congr(f $(h.1))]
rw [baseChange_negY, inj.eq_iff]
exact h.2
· simp only [add_of_imp fun hx hy ↦ h ⟨hx, hy⟩, mapFun]
rw [add_of_imp]
· simp only [some.injEq, ← baseChange_addX, ← baseChange_addY, ← baseChange_slope]
· push_neg at h; rwa [baseChange_negY, inj.eq_iff, inj.ne_iff]
lemma map_zero : map W f (0 : W⟮F⟯) = 0 :=
rfl
lemma map_some {x y : F} (h : (W.baseChange F).toAffine.Nonsingular x y) :
map W f (some h) = some ((W.baseChange_nonsingular f.injective ..).mpr h) :=
rfl
lemma map_id (P : W⟮F⟯) : map W (Algebra.ofId F F) P = P := by
cases P <;> rfl
lemma map_map (P : W⟮F⟯) : map W g (map W f P) = map W (g.comp f) P := by
cases P <;> rfl
lemma map_injective : Function.Injective <| map W f := by
rintro (_ | _) (_ | _) h
any_goals contradiction
· rfl
· simpa only [some.injEq] using ⟨f.injective (some.inj h).left, f.injective (some.inj h).right⟩
variable (F K) in
/-- The group homomorphism from `W⟮F⟯` to `W⟮K⟯` induced by the base change from `F` to `K`,
where `W` is defined over a subring of a ring `S`, and `F` and `K` are field extensions of `S`. -/
abbrev baseChange [Algebra F K] [IsScalarTower R F K] : W⟮F⟯ →+ W⟮K⟯ :=
map W <| Algebra.ofId F K
lemma map_baseChange [Algebra F K] [IsScalarTower R F K] [Algebra F L] [IsScalarTower R F L]
(f : K →ₐ[F] L) (P : W⟮F⟯) : map W f (baseChange W F K P) = baseChange W F L P := by
have : Subsingleton (F →ₐ[F] L) := inferInstance
convert map_map W (Algebra.ofId F K) f P
end Point
end BaseChange
@[deprecated (since := "2024-06-03")] alias addY' := negAddY
@[deprecated (since := "2024-06-03")] alias
nonsingular_add_of_eval_derivative_ne_zero := nonsingular_negAdd_of_eval_derivative_ne_zero
@[deprecated (since := "2024-06-03")] alias slope_of_Yeq := slope_of_Y_eq
@[deprecated (since := "2024-06-03")] alias slope_of_Yne := slope_of_Y_ne
@[deprecated (since := "2024-06-03")] alias slope_of_Xne := slope_of_X_ne
@[deprecated (since := "2024-06-03")] alias slope_of_Yne_eq_eval := slope_of_Y_ne_eq_eval
@[deprecated (since := "2024-06-03")] alias Yeq_of_Xeq := Y_eq_of_X_eq
@[deprecated (since := "2024-06-03")] alias Yeq_of_Yne := Y_eq_of_Y_ne
@[deprecated (since := "2024-06-03")] alias equation_add' := equation_negAdd
@[deprecated (since := "2024-06-03")] alias nonsingular_add' := nonsingular_negAdd
@[deprecated (since := "2024-06-03")] alias baseChange_addY' := baseChange_negAddY
@[deprecated (since := "2024-06-03")] alias map_addY' := map_negAddY
end WeierstrassCurve.Affine
/-! ## Elliptic curves -/
/-- The coercion from an elliptic curve to a Weierstrass curve in affine coordinates. -/
abbrev EllipticCurve.toAffine {R : Type u} [CommRing R] (E : EllipticCurve R) :
WeierstrassCurve.Affine R :=
E.toWeierstrassCurve.toAffine
namespace EllipticCurve.Affine
variable {R : Type u} [CommRing R] (E : EllipticCurve R)
lemma nonsingular [Nontrivial R] {x y : R} (h : E.toAffine.Equation x y) :
E.toAffine.Nonsingular x y :=
E.toAffine.nonsingular_of_Δ_ne_zero h <| E.coe_Δ' ▸ E.Δ'.ne_zero
end EllipticCurve.Affine
|
AlgebraicGeometry\EllipticCurve\Group.lean | /-
Copyright (c) 2023 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian
import Mathlib.LinearAlgebra.FreeModule.Norm
import Mathlib.RingTheory.ClassGroup
/-!
# Group law on Weierstrass curves
This file proves that the nonsingular rational points on a Weierstrass curve forms an abelian group
under the geometric group law defined in `Mathlib.AlgebraicGeometry.EllipticCurve.Affine` and in
`Mathlib.AlgebraicGeometry.EllipticCurve.Jacobian`.
## Mathematical background
Let `W` be a Weierstrass curve over a field `F` given by a Weierstrass equation $W(X, Y) = 0$ in
affine coordinates. As in `Mathlib.AlgebraicGeometry.EllipticCurve.Affine`, the set of nonsingular
rational points `W⟮F⟯` of `W` consist of the unique point at infinity $0$ and nonsingular affine
points $(x, y)$. With this description, there is an addition-preserving injection between `W⟮F⟯`
and the ideal class group of the coordinate ring $F[W] := F[X, Y] / \langle W(X, Y)\rangle$ of `W`.
This is defined by mapping the point at infinity $0$ to the trivial ideal class and an affine point
$(x, y)$ to the ideal class of the invertible fractional ideal $\langle X - x, Y - y\rangle$.
Proving that this is well-defined and preserves addition reduce to checking several equalities of
integral ideals, which is done in `WeierstrassCurve.Affine.CoordinateRing.XYIdeal_neg_mul` and in
`WeierstrassCurve.Affine.CoordinateRing.XYIdeal_mul_XYIdeal` via explicit ideal computations.
Now $F[W]$ is a free rank two $F[X]$-algebra with basis $\{1, Y\}$, so every element of $F[W]$ is
of the form $p + qY$ for some $p, q \in F[X]$, and there is an algebra norm $N : F[W] \to F[X]$.
Injectivity can then be shown by computing the degree of such a norm $N(p + qY)$ in two different
ways, which is done in `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis` and in the
auxiliary lemmas in the proof of `WeierstrassCurve.Affine.Point.instAddCommGroup`.
When `W` is given in Jacobian coordinates, `WeierstrassCurve.Jacobian.Point.toAffineAddEquiv` pulls
back the group law on `WeierstrassCurve.Affine.Point` to `WeierstrassCurve.Jacobian.Point`.
## Main definitions
* `WeierstrassCurve.Affine.CoordinateRing`: the coordinate ring `F[W]` of a Weierstrass curve `W`.
* `WeierstrassCurve.Affine.CoordinateRing.basis`: the power basis of `F[W]` over `F[X]`.
## Main statements
* `WeierstrassCurve.Affine.CoordinateRing.instIsDomainCoordinateRing`: the coordinate ring of an
affine Weierstrass curve is an integral domain.
* `WeierstrassCurve.Affine.CoordinateRing.degree_norm_smul_basis`: the degree of the norm of an
element in the coordinate ring of an affine Weierstrass curve in terms of the power basis.
* `WeierstrassCurve.Affine.Point.instAddCommGroup`: the type of nonsingular rational points on
an affine Weierstrass curve forms an abelian group under addition.
* `WeierstrassCurve.Jacobian.Point.instAddCommGroup`: the type of nonsingular rational
points on a Jacobian Weierstrass curve forms an abelian group under addition.
## References
https://drops.dagstuhl.de/storage/00lipics/lipics-vol268-itp2023/LIPIcs.ITP.2023.6/LIPIcs.ITP.2023.6.pdf
## Tags
elliptic curve, group law, class group
-/
open Ideal nonZeroDivisors Polynomial
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_neg, eval_add, eval_sub, eval_mul, eval_pow])
universe u v
namespace WeierstrassCurve.Affine
/-! ## Weierstrass curves in affine coordinates -/
variable {R : Type u} {S : Type v} [CommRing R] [CommRing S] (W : Affine R) (f : R →+* S)
-- Porting note: in Lean 3, this is a `def` under a `derive comm_ring` tag.
-- This generates a reducible instance of `comm_ring` for `coordinate_ring`. In certain
-- circumstances this might be extremely slow, because all instances in its definition are unified
-- exponentially many times. In this case, one solution is to manually add the local attribute
-- `local attribute [irreducible] coordinate_ring.comm_ring` to block this type-level unification.
-- In Lean 4, this is no longer an issue and is now an `abbrev`. See Zulip thread:
-- https://leanprover.zulipchat.com/#narrow/stream/116395-maths/topic/.E2.9C.94.20class_group.2Emk
/-- The coordinate ring $R[W] := R[X, Y] / \langle W(X, Y) \rangle$ of `W`. -/
abbrev CoordinateRing : Type u :=
AdjoinRoot W.polynomial
/-- The function field $R(W) := \mathrm{Frac}(R[W])$ of `W`. -/
abbrev FunctionField : Type u :=
FractionRing W.CoordinateRing
namespace CoordinateRing
section Algebra
/-! ### The coordinate ring as an `R[X]`-algebra -/
noncomputable instance : Algebra R W.CoordinateRing :=
Quotient.algebra R
noncomputable instance : Algebra R[X] W.CoordinateRing :=
Quotient.algebra R[X]
instance : IsScalarTower R R[X] W.CoordinateRing :=
Quotient.isScalarTower R R[X] _
instance [Subsingleton R] : Subsingleton W.CoordinateRing :=
Module.subsingleton R[X] _
-- Porting note: added the abbreviation `mk` for `AdjoinRoot.mk W.polynomial`
/-- The natural ring homomorphism mapping an element of `R[X][Y]` to an element of `R[W]`. -/
noncomputable abbrev mk : R[X][Y] →+* W.CoordinateRing :=
AdjoinRoot.mk W.polynomial
-- Porting note: added `classical` explicitly
/-- The basis $\{1, Y\}$ for the coordinate ring $R[W]$ over the polynomial ring $R[X]$. -/
protected noncomputable def basis : Basis (Fin 2) R[X] W.CoordinateRing := by
classical exact (subsingleton_or_nontrivial R).by_cases (fun _ => default) fun _ =>
(AdjoinRoot.powerBasis' W.monic_polynomial).basis.reindex <| finCongr W.natDegree_polynomial
lemma basis_apply (n : Fin 2) :
CoordinateRing.basis W n = (AdjoinRoot.powerBasis' W.monic_polynomial).gen ^ (n : ℕ) := by
classical
nontriviality R
rw [CoordinateRing.basis, Or.by_cases, dif_neg <| not_subsingleton R, Basis.reindex_apply,
PowerBasis.basis_eq_pow]
rfl
-- Porting note: added `@[simp]` in lieu of `coe_basis`
@[simp]
lemma basis_zero : CoordinateRing.basis W 0 = 1 := by
simpa only [basis_apply] using pow_zero _
-- Porting note: added `@[simp]` in lieu of `coe_basis`
@[simp]
lemma basis_one : CoordinateRing.basis W 1 = mk W Y := by
simpa only [basis_apply] using pow_one _
-- Porting note: removed `@[simp]` in lieu of `basis_zero` and `basis_one`
lemma coe_basis : (CoordinateRing.basis W : Fin 2 → W.CoordinateRing) = ![1, mk W Y] := by
ext n
fin_cases n
exacts [basis_zero W, basis_one W]
variable {W} in
lemma smul (x : R[X]) (y : W.CoordinateRing) : x • y = mk W (C x) * y :=
(algebraMap_smul W.CoordinateRing x y).symm
variable {W} in
lemma smul_basis_eq_zero {p q : R[X]} (hpq : p • (1 : W.CoordinateRing) + q • mk W Y = 0) :
p = 0 ∧ q = 0 := by
have h := Fintype.linearIndependent_iff.mp (CoordinateRing.basis W).linearIndependent ![p, q]
erw [Fin.sum_univ_succ, basis_zero, Fin.sum_univ_one, basis_one] at h
exact ⟨h hpq 0, h hpq 1⟩
variable {W} in
lemma exists_smul_basis_eq (x : W.CoordinateRing) :
∃ p q : R[X], p • (1 : W.CoordinateRing) + q • mk W Y = x := by
have h := (CoordinateRing.basis W).sum_equivFun x
erw [Fin.sum_univ_succ, Fin.sum_univ_one, basis_zero, basis_one] at h
exact ⟨_, _, h⟩
lemma smul_basis_mul_C (y : R[X]) (p q : R[X]) :
(p • (1 : W.CoordinateRing) + q • mk W Y) * mk W (C y) =
(p * y) • (1 : W.CoordinateRing) + (q * y) • mk W Y := by
simp only [smul, _root_.map_mul]
ring1
lemma smul_basis_mul_Y (p q : R[X]) : (p • (1 : W.CoordinateRing) + q • mk W Y) * mk W Y =
(q * (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆)) • (1 : W.CoordinateRing) +
(p - q * (C W.a₁ * X + C W.a₃)) • mk W Y := by
have Y_sq : mk W Y ^ 2 =
mk W (C (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆) - C (C W.a₁ * X + C W.a₃) * Y) := by
exact AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [polynomial]; ring1⟩
simp only [smul, add_mul, mul_assoc, ← sq, Y_sq, C_sub, map_sub, C_mul, _root_.map_mul]
ring1
/-- The ring homomorphism `R[W] →+* S[W.map f]` induced by a ring homomorphism `f : R →+* S`. -/
noncomputable def map : W.CoordinateRing →+* (W.map f).toAffine.CoordinateRing :=
AdjoinRoot.lift ((AdjoinRoot.of _).comp <| mapRingHom f) _ <| by
rw [← eval₂_map, ← map_polynomial, AdjoinRoot.eval₂_root]
lemma map_mk (x : R[X][Y]) : map W f (mk W x) = mk (W.map f) (x.map <| mapRingHom f) := by
rw [map, AdjoinRoot.lift_mk, ← eval₂_map]
exact AdjoinRoot.aeval_eq <| x.map <| mapRingHom f
variable {W} in
protected lemma map_smul (x : R[X]) (y : W.CoordinateRing) :
map W f (x • y) = x.map f • map W f y := by
rw [smul, _root_.map_mul, map_mk, map_C, smul]
rfl
variable {f} in
lemma map_injective (hf : Function.Injective f) : Function.Injective <| map W f :=
(injective_iff_map_eq_zero _).mpr fun y hy => by
obtain ⟨p, q, rfl⟩ := exists_smul_basis_eq y
simp_rw [map_add, CoordinateRing.map_smul, map_one, map_mk, map_X] at hy
obtain ⟨hp, hq⟩ := smul_basis_eq_zero hy
rw [Polynomial.map_eq_zero_iff hf] at hp hq
simp_rw [hp, hq, zero_smul, add_zero]
instance [IsDomain R] : IsDomain W.CoordinateRing :=
have : IsDomain (W.map <| algebraMap R <| FractionRing R).toAffine.CoordinateRing :=
AdjoinRoot.isDomain_of_prime (irreducible_polynomial _).prime
(map_injective W <| IsFractionRing.injective R <| FractionRing R).isDomain
end Algebra
section Ring
/-! ### Ideals in the coordinate ring over a ring -/
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The class of the element $X - x$ in $R[W]$ for some $x \in R$. -/
noncomputable def XClass (x : R) : W.CoordinateRing :=
mk W <| C <| X - C x
lemma XClass_ne_zero [Nontrivial R] (x : R) : XClass W x ≠ 0 :=
AdjoinRoot.mk_ne_zero_of_natDegree_lt W.monic_polynomial (C_ne_zero.mpr <| X_sub_C_ne_zero x) <|
by rw [natDegree_polynomial, natDegree_C]; norm_num1
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The class of the element $Y - y(X)$ in $R[W]$ for some $y(X) \in R[X]$. -/
noncomputable def YClass (y : R[X]) : W.CoordinateRing :=
mk W <| Y - C y
lemma YClass_ne_zero [Nontrivial R] (y : R[X]) : YClass W y ≠ 0 :=
AdjoinRoot.mk_ne_zero_of_natDegree_lt W.monic_polynomial (X_sub_C_ne_zero y) <|
by rw [natDegree_polynomial, natDegree_X_sub_C]; norm_num1
lemma C_addPolynomial (x y L : R) : mk W (C <| W.addPolynomial x y L) =
mk W ((Y - C (linePolynomial x y L)) * (W.negPolynomial - C (linePolynomial x y L))) :=
AdjoinRoot.mk_eq_mk.mpr ⟨1, by rw [W.C_addPolynomial, add_sub_cancel_left, mul_one]⟩
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The ideal $\langle X - x \rangle$ of $R[W]$ for some $x \in R$. -/
noncomputable def XIdeal (x : R) : Ideal W.CoordinateRing :=
span {XClass W x}
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The ideal $\langle Y - y(X) \rangle$ of $R[W]$ for some $y(X) \in R[X]$. -/
noncomputable def YIdeal (y : R[X]) : Ideal W.CoordinateRing :=
span {YClass W y}
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The ideal $\langle X - x, Y - y(X) \rangle$ of $R[W]$ for some $x \in R$ and $y(X) \in R[X]$. -/
noncomputable def XYIdeal (x : R) (y : R[X]) : Ideal W.CoordinateRing :=
span {XClass W x, YClass W y}
lemma XYIdeal_eq₁ (x y L : R) : XYIdeal W x (C y) = XYIdeal W x (linePolynomial x y L) := by
simp only [XYIdeal, XClass, YClass, linePolynomial]
rw [← span_pair_add_mul_right <| mk W <| C <| C <| -L, ← _root_.map_mul, ← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
C_simp
ring1
lemma XYIdeal_add_eq (x₁ x₂ y₁ L : R) : XYIdeal W (W.addX x₁ x₂ L) (C <| W.addY x₁ x₂ y₁ L) =
span {mk W <| W.negPolynomial - C (linePolynomial x₁ y₁ L)} ⊔ XIdeal W (W.addX x₁ x₂ L) := by
simp only [XYIdeal, XIdeal, XClass, YClass, addY, negAddY, negY, negPolynomial, linePolynomial]
rw [sub_sub <| -(Y : R[X][Y]), neg_sub_left (Y : R[X][Y]), map_neg, span_singleton_neg, sup_comm,
← span_insert, ← span_pair_add_mul_right <| mk W <| C <| C <| W.a₁ + L, ← _root_.map_mul,
← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
C_simp
ring1
/-- The $R$-algebra isomorphism from $R[W] / \langle X - x, Y - y(X) \rangle$ to $R$ obtained by
evaluation at $y(X)$ and at $x$ provided that $W(x, y(x)) = 0$. -/
noncomputable def quotientXYIdealEquiv {x : R} {y : R[X]} (h : (W.polynomial.eval y).eval x = 0) :
(W.CoordinateRing ⧸ XYIdeal W x y) ≃ₐ[R] R :=
((quotientEquivAlgOfEq R <| by
simp only [XYIdeal, XClass, YClass, ← Set.image_pair, ← map_span]; rfl).trans <|
DoubleQuot.quotQuotEquivQuotOfLEₐ R <| (span_singleton_le_iff_mem _).mpr <|
mem_span_C_X_sub_C_X_sub_C_iff_eval_eval_eq_zero.mpr h).trans
quotientSpanCXSubCXSubCAlgEquiv
end Ring
section Field
/-! ### Ideals in the coordinate ring over a field -/
variable {F : Type u} [Field F] {W : Affine F}
lemma C_addPolynomial_slope {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) : mk W (C <| W.addPolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) =
-(XClass W x₁ * XClass W x₂ * XClass W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)) := by
simp only [addPolynomial_slope h₁ h₂ hxy, C_neg, mk, map_neg, neg_inj, _root_.map_mul]
rfl
lemma XYIdeal_eq₂ {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁)
(h₂ : W.Equation x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
XYIdeal W x₂ (C y₂) = XYIdeal W x₂ (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
have hy₂ : y₂ = (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂).eval x₂ := by
by_cases hx : x₁ = x₂
· rcases hx, Y_eq_of_Y_ne h₁ h₂ hx <| hxy hx with ⟨rfl, rfl⟩
field_simp [linePolynomial, sub_ne_zero_of_ne <| hxy rfl]
· field_simp [linePolynomial, slope_of_X_ne hx, sub_ne_zero_of_ne hx]
ring1
nth_rw 1 [hy₂]
simp only [XYIdeal, XClass, YClass, linePolynomial]
rw [← span_pair_add_mul_right <| mk W <| C <| C <| -W.slope x₁ x₂ y₁ y₂, ← _root_.map_mul,
← map_add]
apply congr_arg (_ ∘ _ ∘ _ ∘ _)
eval_simp
C_simp
ring1
lemma XYIdeal_neg_mul {x y : F} (h : W.Nonsingular x y) :
XYIdeal W x (C <| W.negY x y) * XYIdeal W x (C y) = XIdeal W x := by
have Y_rw : (Y - C (C y)) * (Y - C (C <| W.negY x y)) -
C (X - C x) * (C (X ^ 2 + C (x + W.a₂) * X + C (x ^ 2 + W.a₂ * x + W.a₄)) - C (C W.a₁) * Y) =
W.polynomial * 1 := by
linear_combination (norm := (rw [negY, polynomial]; C_simp; ring1))
congr_arg C (congr_arg C ((equation_iff ..).mp h.left).symm)
simp_rw [XYIdeal, XClass, YClass, span_pair_mul_span_pair, mul_comm, ← _root_.map_mul,
AdjoinRoot.mk_eq_mk.mpr ⟨1, Y_rw⟩, _root_.map_mul, span_insert,
← span_singleton_mul_span_singleton, ← Ideal.mul_sup, ← span_insert]
convert mul_top (_ : Ideal W.CoordinateRing) using 2
simp_rw [← Set.image_singleton (f := mk W), ← Set.image_insert_eq, ← map_span]
convert map_top (R := F[X][Y]) (mk W) using 1
apply congr_arg
simp_rw [eq_top_iff_one, mem_span_insert', mem_span_singleton']
rcases ((nonsingular_iff' ..).mp h).right with hx | hy
· let W_X := W.a₁ * y - (3 * x ^ 2 + 2 * W.a₂ * x + W.a₄)
refine
⟨C <| C W_X⁻¹ * -(X + C (2 * x + W.a₂)), C <| C <| W_X⁻¹ * W.a₁, 0, C <| C <| W_X⁻¹ * -1, ?_⟩
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hx]
C_simp
ring1
· let W_Y := 2 * y + W.a₁ * x + W.a₃
refine ⟨0, C <| C W_Y⁻¹, C <| C <| W_Y⁻¹ * -1, 0, ?_⟩
rw [negY, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hy]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hy]
C_simp
ring1
private lemma XYIdeal'_mul_inv {x y : F} (h : W.Nonsingular x y) :
XYIdeal W x (C y) * (XYIdeal W x (C <| W.negY x y) *
(XIdeal W x : FractionalIdeal W.CoordinateRing⁰ W.FunctionField)⁻¹) = 1 := by
rw [← mul_assoc, ← FractionalIdeal.coeIdeal_mul, mul_comm <| XYIdeal W .., XYIdeal_neg_mul h,
XIdeal, FractionalIdeal.coe_ideal_span_singleton_mul_inv W.FunctionField <| XClass_ne_zero W x]
lemma XYIdeal_mul_XYIdeal {x₁ x₂ y₁ y₂ : F} (h₁ : W.Equation x₁ y₁) (h₂ : W.Equation x₂ y₂)
(hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
XIdeal W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂) * (XYIdeal W x₁ (C y₁) * XYIdeal W x₂ (C y₂)) =
YIdeal W (linePolynomial x₁ y₁ <| W.slope x₁ x₂ y₁ y₂) *
XYIdeal W (W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂)
(C <| W.addY x₁ x₂ y₁ <| W.slope x₁ x₂ y₁ y₂) := by
have sup_rw : ∀ a b c d : Ideal W.CoordinateRing, a ⊔ (b ⊔ (c ⊔ d)) = a ⊔ d ⊔ b ⊔ c :=
fun _ _ c _ => by rw [← sup_assoc, sup_comm c, sup_sup_sup_comm, ← sup_assoc]
rw [XYIdeal_add_eq, XIdeal, mul_comm, XYIdeal_eq₁ W x₁ y₁ <| W.slope x₁ x₂ y₁ y₂, XYIdeal,
XYIdeal_eq₂ h₁ h₂ hxy, XYIdeal, span_pair_mul_span_pair]
simp_rw [span_insert, sup_rw, Ideal.sup_mul, span_singleton_mul_span_singleton]
rw [← neg_eq_iff_eq_neg.mpr <| C_addPolynomial_slope h₁ h₂ hxy, span_singleton_neg,
C_addPolynomial, _root_.map_mul, YClass]
simp_rw [mul_comm <| XClass W x₁, mul_assoc, ← span_singleton_mul_span_singleton, ← Ideal.mul_sup]
rw [span_singleton_mul_span_singleton, ← span_insert,
← span_pair_add_mul_right <| -(XClass W <| W.addX x₁ x₂ <| W.slope x₁ x₂ y₁ y₂), mul_neg,
← sub_eq_add_neg, ← sub_mul, ← map_sub <| mk W, sub_sub_sub_cancel_right, span_insert,
← span_singleton_mul_span_singleton, ← sup_rw, ← Ideal.sup_mul, ← Ideal.sup_mul]
apply congr_arg (_ ∘ _)
convert top_mul (_ : Ideal W.CoordinateRing)
simp_rw [XClass, ← Set.image_singleton (f := mk W), ← map_span, ← Ideal.map_sup, eq_top_iff_one,
mem_map_iff_of_surjective _ AdjoinRoot.mk_surjective, ← span_insert, mem_span_insert',
mem_span_singleton']
by_cases hx : x₁ = x₂
· rcases hx, Y_eq_of_Y_ne h₁ h₂ hx (hxy hx) with ⟨rfl, rfl⟩
let y := (y₁ - W.negY x₁ y₁) ^ 2
replace hxy := pow_ne_zero 2 <| sub_ne_zero_of_ne <| hxy rfl
refine ⟨1 + C (C <| y⁻¹ * 4) * W.polynomial,
⟨C <| C y⁻¹ * (C 4 * X ^ 2 + C (4 * x₁ + W.b₂) * X + C (4 * x₁ ^ 2 + W.b₂ * x₁ + 2 * W.b₄)),
0, C (C y⁻¹) * (Y - W.negPolynomial), ?_⟩, by
rw [map_add, map_one, _root_.map_mul <| mk W, AdjoinRoot.mk_self, mul_zero, add_zero]⟩
rw [polynomial, negPolynomial, ← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hxy]
simp only [mul_add, ← mul_assoc, ← C_mul, mul_inv_cancel hxy]
linear_combination (norm := (rw [b₂, b₄, negY]; C_simp; ring1))
-4 * congr_arg C (congr_arg C <| (equation_iff ..).mp h₁)
· replace hx := sub_ne_zero_of_ne hx
refine ⟨_, ⟨⟨C <| C (x₁ - x₂)⁻¹, C <| C <| (x₁ - x₂)⁻¹ * -1, 0, ?_⟩, map_one _⟩⟩
rw [← mul_right_inj' <| C_ne_zero.mpr <| C_ne_zero.mpr hx]
simp only [← mul_assoc, mul_add, ← C_mul, mul_inv_cancel hx]
C_simp
ring1
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The non-zero fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ for some $x, y \in F$. -/
noncomputable def XYIdeal' {x y : F} (h : W.Nonsingular x y) :
(FractionalIdeal W.CoordinateRing⁰ W.FunctionField)ˣ :=
Units.mkOfMulEqOne _ _ <| XYIdeal'_mul_inv h
lemma XYIdeal'_eq {x y : F} (h : W.Nonsingular x y) :
(XYIdeal' h : FractionalIdeal W.CoordinateRing⁰ W.FunctionField) = XYIdeal W x (C y) :=
rfl
lemma mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq {x y : F} (h : W.Nonsingular x y) :
ClassGroup.mk (XYIdeal' <| nonsingular_neg h) * ClassGroup.mk (XYIdeal' h) = 1 := by
rw [← _root_.map_mul]
exact
(ClassGroup.mk_eq_one_of_coe_ideal <| by exact (FractionalIdeal.coeIdeal_mul ..).symm.trans <|
FractionalIdeal.coeIdeal_inj.mpr <| XYIdeal_neg_mul h).mpr ⟨_, XClass_ne_zero W _, rfl⟩
lemma mk_XYIdeal'_mul_mk_XYIdeal' {x₁ x₂ y₁ y₂ : F} (h₁ : W.Nonsingular x₁ y₁)
(h₂ : W.Nonsingular x₂ y₂) (hxy : x₁ = x₂ → y₁ ≠ W.negY x₂ y₂) :
ClassGroup.mk (XYIdeal' h₁) * ClassGroup.mk (XYIdeal' h₂) =
ClassGroup.mk (XYIdeal' <| nonsingular_add h₁ h₂ hxy) := by
rw [← _root_.map_mul]
exact (ClassGroup.mk_eq_mk_of_coe_ideal (by exact (FractionalIdeal.coeIdeal_mul ..).symm) <|
XYIdeal'_eq _).mpr
⟨_, _, XClass_ne_zero W _, YClass_ne_zero W _, XYIdeal_mul_XYIdeal h₁.left h₂.left hxy⟩
end Field
section Norm
/-! ### Norms on the coordinate ring -/
lemma norm_smul_basis (p q : R[X]) :
Algebra.norm R[X] (p • (1 : W.CoordinateRing) + q • mk W Y) =
p ^ 2 - p * q * (C W.a₁ * X + C W.a₃) -
q ^ 2 * (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆) := by
simp_rw [Algebra.norm_eq_matrix_det <| CoordinateRing.basis W, Matrix.det_fin_two,
Algebra.leftMulMatrix_eq_repr_mul, basis_zero, mul_one, basis_one, smul_basis_mul_Y, map_add,
Finsupp.add_apply, map_smul, Finsupp.smul_apply, ← basis_zero, ← basis_one,
Basis.repr_self_apply, if_pos, one_ne_zero, if_false, smul_eq_mul]
ring1
lemma coe_norm_smul_basis (p q : R[X]) :
Algebra.norm R[X] (p • (1 : W.CoordinateRing) + q • mk W Y) =
mk W ((C p + C q * X) * (C p + C q * (-(Y : R[X][Y]) - C (C W.a₁ * X + C W.a₃)))) :=
AdjoinRoot.mk_eq_mk.mpr
⟨C q ^ 2, by simp only [norm_smul_basis, polynomial]; C_simp; ring1⟩
lemma degree_norm_smul_basis [IsDomain R] (p q : R[X]) :
(Algebra.norm R[X] <| p • (1 : W.CoordinateRing) + q • mk W Y).degree =
max (2 • p.degree) (2 • q.degree + 3) := by
have hdp : (p ^ 2).degree = 2 • p.degree := degree_pow p 2
have hdpq : (p * q * (C W.a₁ * X + C W.a₃)).degree ≤ p.degree + q.degree + 1 := by
simpa only [degree_mul] using add_le_add_left degree_linear_le (p.degree + q.degree)
have hdq :
(q ^ 2 * (X ^ 3 + C W.a₂ * X ^ 2 + C W.a₄ * X + C W.a₆)).degree = 2 • q.degree + 3 := by
rw [degree_mul, degree_pow, ← one_mul <| X ^ 3, ← C_1, degree_cubic <| one_ne_zero' R]
rw [norm_smul_basis]
by_cases hp : p = 0
· simpa only [hp, hdq, neg_zero, zero_sub, zero_mul, zero_pow two_ne_zero, degree_neg] using
(max_bot_left _).symm
· by_cases hq : q = 0
· simpa only [hq, hdp, sub_zero, zero_mul, mul_zero, zero_pow two_ne_zero] using
(max_bot_right _).symm
· rw [← not_congr degree_eq_bot] at hp hq
-- Porting note: BUG `cases` tactic does not modify assumptions in `hp'` and `hq'`
rcases hp' : p.degree with _ | dp -- `hp' : ` should be redundant
· exact (hp hp').elim -- `hp'` should be `rfl`
· rw [hp'] at hdp hdpq -- line should be redundant
rcases hq' : q.degree with _ | dq -- `hq' : ` should be redundant
· exact (hq hq').elim -- `hq'` should be `rfl`
· rw [hq'] at hdpq hdq -- line should be redundant
rcases le_or_lt dp (dq + 1) with hpq | hpq
· convert (degree_sub_eq_right_of_degree_lt <| (degree_sub_le _ _).trans_lt <|
max_lt_iff.mpr ⟨hdp.trans_lt _, hdpq.trans_lt _⟩).trans
(max_eq_right_of_lt _).symm <;> rw [hdq] <;>
exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq]
· rw [sub_sub]
convert (degree_sub_eq_left_of_degree_lt <| (degree_add_le _ _).trans_lt <|
max_lt_iff.mpr ⟨hdpq.trans_lt _, hdq.trans_lt _⟩).trans
(max_eq_left_of_lt _).symm <;> rw [hdp] <;>
exact WithBot.coe_lt_coe.mpr <| by dsimp; linarith only [hpq]
variable {W} in
lemma degree_norm_ne_one [IsDomain R] (x : W.CoordinateRing) :
(Algebra.norm R[X] x).degree ≠ 1 := by
rcases exists_smul_basis_eq x with ⟨p, q, rfl⟩
rw [degree_norm_smul_basis]
rcases p.degree with (_ | _ | _ | _) <;> cases q.degree
any_goals rintro (_ | _)
-- Porting note: replaced `dec_trivial` with `by exact (cmp_eq_lt_iff ..).mp rfl`
exact (lt_max_of_lt_right <| by exact (cmp_eq_lt_iff ..).mp rfl).ne'
variable {W} in
lemma natDegree_norm_ne_one [IsDomain R] (x : W.CoordinateRing) :
(Algebra.norm R[X] x).natDegree ≠ 1 :=
degree_norm_ne_one x ∘ (degree_eq_iff_natDegree_eq_of_pos zero_lt_one).mpr
end Norm
end CoordinateRing
namespace Point
/-! ### The axioms for nonsingular rational points on a Weierstrass curve -/
variable {F : Type u} [Field F] {W : Affine F}
/-- The set function mapping an affine point $(x, y)$ of `W` to the class of the non-zero fractional
ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simp]
noncomputable def toClassFun : W.Point → Additive (ClassGroup W.CoordinateRing)
| 0 => 0
| some h => Additive.ofMul <| ClassGroup.mk <| CoordinateRing.XYIdeal' h
/-- The group homomorphism mapping an affine point $(x, y)$ of `W` to the class of the non-zero
fractional ideal $\langle X - x, Y - y \rangle$ of $F(W)$ in the class group of $F[W]$. -/
@[simps]
noncomputable def toClass : W.Point →+ Additive (ClassGroup W.CoordinateRing) where
toFun := toClassFun
map_zero' := rfl
map_add' := by
rintro (_ | @⟨x₁, y₁, h₁⟩) (_ | @⟨x₂, y₂, h₂⟩)
any_goals simp only [zero_def, toClassFun, zero_add, add_zero]
obtain ⟨rfl, rfl⟩ | h := em (x₁ = x₂ ∧ y₁ = W.negY x₂ y₂)
· rw [add_of_Y_eq rfl rfl]
exact (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq h₂).symm
· have h hx hy := h ⟨hx, hy⟩
rw [add_of_imp h]
exact (CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal' h₁ h₂ h).symm
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
lemma toClass_zero : toClass (0 : W.Point) = 0 :=
rfl
lemma toClass_some {x y : F} (h : W.Nonsingular x y) :
toClass (some h) = ClassGroup.mk (CoordinateRing.XYIdeal' h) :=
rfl
private lemma add_eq_zero (P Q : W.Point) : P + Q = 0 ↔ P = -Q := by
rcases P, Q with ⟨_ | @⟨x₁, y₁, _⟩, _ | @⟨x₂, y₂, _⟩⟩
any_goals rfl
· rw [zero_def, zero_add, ← neg_eq_iff_eq_neg, neg_zero, eq_comm]
· rw [neg_some, some.injEq]
constructor
· contrapose!; intro h; rw [add_of_imp h]; exact some_ne_zero _
· exact fun ⟨hx, hy⟩ ↦ add_of_Y_eq hx hy
lemma toClass_eq_zero (P : W.Point) : toClass P = 0 ↔ P = 0 := by
constructor
· intro hP
rcases P with (_ | ⟨h, _⟩)
· rfl
· rcases (ClassGroup.mk_eq_one_of_coe_ideal <| by rfl).mp hP with ⟨p, h0, hp⟩
apply (p.natDegree_norm_ne_one _).elim
rw [← finrank_quotient_span_eq_natDegree_norm (CoordinateRing.basis W) h0,
← (quotientEquivAlgOfEq F hp).toLinearEquiv.finrank_eq,
(CoordinateRing.quotientXYIdealEquiv W h).toLinearEquiv.finrank_eq,
FiniteDimensional.finrank_self]
· exact congr_arg toClass
lemma toClass_injective : Function.Injective <| @toClass _ _ W := by
rintro (_ | h) _ hP
all_goals rw [← neg_inj, ← add_eq_zero, ← toClass_eq_zero, map_add, ← hP]
· exact zero_add 0
· exact CoordinateRing.mk_XYIdeal'_mul_mk_XYIdeal'_of_Yeq h
noncomputable instance : AddCommGroup W.Point where
nsmul := nsmulRec
zsmul := zsmulRec
zero_add := zero_add
add_zero := add_zero
add_left_neg _ := by rw [add_eq_zero]
add_comm _ _ := toClass_injective <| by simp only [map_add, add_comm]
add_assoc _ _ _ := toClass_injective <| by simp only [map_add, add_assoc]
end Point
end WeierstrassCurve.Affine
namespace WeierstrassCurve.Jacobian.Point
/-! ## Weierstrass curves in Jacobian coordinates -/
variable {F : Type u} [Field F] {W : Jacobian F}
noncomputable instance : AddCommGroup W.Point where
nsmul := nsmulRec
zsmul := zsmulRec
zero_add _ := (toAffineAddEquiv W).injective <| by
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, zero_add]
add_zero _ := (toAffineAddEquiv W).injective <| by
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_zero, add_zero]
add_left_neg P := (toAffineAddEquiv W).injective <| by
simp only [map_add, toAffineAddEquiv_apply, toAffineLift_neg, add_left_neg, toAffineLift_zero]
add_comm _ _ := (toAffineAddEquiv W).injective <| by simp only [map_add, add_comm]
add_assoc _ _ _ := (toAffineAddEquiv W).injective <| by simp only [map_add, add_assoc]
end WeierstrassCurve.Jacobian.Point
namespace EllipticCurve.Affine.Point
/-! ## Elliptic curves in affine coordinates -/
variable {R : Type} [Nontrivial R] [CommRing R] (E : EllipticCurve R)
/-- An affine point on an elliptic curve `E` over `R`. -/
def mk {x y : R} (h : E.toAffine.Equation x y) : E.toAffine.Point :=
WeierstrassCurve.Affine.Point.some <| nonsingular E h
end EllipticCurve.Affine.Point
|
AlgebraicGeometry\EllipticCurve\Jacobian.lean | /-
Copyright (c) 2023 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.PDeriv
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine
import Mathlib.Data.Fin.Tuple.Reflection
/-!
# Jacobian coordinates for Weierstrass curves
This file defines the type of points on a Weierstrass curve as a tuple, consisting of an equivalence
class of triples up to scaling by weights, satisfying a Weierstrass equation with a nonsingular
condition. This file also defines the negation and addition operations of the group law for this
type, and proves that they respect the Weierstrass equation and the nonsingular condition. The fact
that they form an abelian group is proven in `Mathlib.AlgebraicGeometry.EllipticCurve.Group`.
## Mathematical background
Let `W` be a Weierstrass curve over a field `F`. A point on the weighted projective plane with
weights $(2, 3, 1)$ is an equivalence class of triples $[x:y:z]$ with coordinates in `F` such that
$(x, y, z) \sim (x', y', z')$ precisely if there is some unit `u` of `F` such that
$(x, y, z) = (u^2x', u^3y', uz')$, with an extra condition that $(x, y, z) \ne (0, 0, 0)$.
A rational point is a point on the $(2, 3, 1)$-projective plane satisfying a $(2, 3, 1)$-homogeneous
Weierstrass equation $Y^2 + a_1XYZ + a_3YZ^3 = X^3 + a_2X^2Z^2 + a_4XZ^4 + a_6Z^6$, and being
nonsingular means the partial derivatives $W_X(X, Y, Z)$, $W_Y(X, Y, Z)$, and $W_Z(X, Y, Z)$ do not
vanish simultaneously. Note that the vanishing of the Weierstrass equation and its partial
derivatives are independent of the representative for $[x:y:z]$, and the nonsingularity condition
already implies that $(x, y, z) \ne (0, 0, 0)$, so a nonsingular rational point on `W` can simply be
given by a tuple consisting of $[x:y:z]$ and the nonsingular condition on any representative.
In cryptography, as well as in this file, this is often called the Jacobian coordinates of `W`.
As in `Mathlib.AlgebraicGeometry.EllipticCurve.Affine`, the set of nonsingular rational points forms
an abelian group under the same secant-and-tangent process, but the polynomials involved are
$(2, 3, 1)$-homogeneous, and any instances of division become multiplication in the $Z$-coordinate.
Note that most computational proofs follow from their analogous proofs for affine coordinates.
## Main definitions
* `WeierstrassCurve.Jacobian.PointClass`: the equivalence class of a point representative.
* `WeierstrassCurve.Jacobian.toAffine`: the Weierstrass curve in affine coordinates.
* `WeierstrassCurve.Jacobian.Nonsingular`: the nonsingular condition on a point representative.
* `WeierstrassCurve.Jacobian.NonsingularLift`: the nonsingular condition on a point class.
* `WeierstrassCurve.Jacobian.neg`: the negation operation on a point representative.
* `WeierstrassCurve.Jacobian.negMap`: the negation operation on a point class.
* `WeierstrassCurve.Jacobian.add`: the addition operation on a point representative.
* `WeierstrassCurve.Jacobian.addMap`: the addition operation on a point class.
* `WeierstrassCurve.Jacobian.Point`: a nonsingular rational point.
* `WeierstrassCurve.Jacobian.Point.neg`: the negation operation on a nonsingular rational point.
* `WeierstrassCurve.Jacobian.Point.add`: the addition operation on a nonsingular rational point.
* `WeierstrassCurve.Jacobian.Point.toAffineAddEquiv`: the equivalence between the nonsingular
rational points on a Weierstrass curve in Jacobian coordinates with those in affine coordinates.
## Main statements
* `WeierstrassCurve.Jacobian.NonsingularNeg`: negation preserves the nonsingular condition.
* `WeierstrassCurve.Jacobian.NonsingularAdd`: addition preserves the nonsingular condition.
## Implementation notes
A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector
notation `![x, y, z]`. However, `P` is not syntactically equivalent to the expanded vector
`![P x, P y, P z]`, so the lemmas `fin3_def` and `fin3_def_ext` can be used to convert between the
two forms. The equivalence of two point representatives `P` and `Q` is implemented as an equivalence
of orbits of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that
`P = u • Q`. However, `u • Q` is not syntactically equal to `![u² * Q x, u³ * Q y, u * Q z]`, so the
lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, rational point, Jacobian coordinates
-/
local notation3 "x" => (0 : Fin 3)
local notation3 "y" => (1 : Fin 3)
local notation3 "z" => (2 : Fin 3)
local macro "matrix_simp" : tactic =>
`(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons,
Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two])
universe u v
/-! ## Weierstrass curves -/
/-- An abbreviation for a Weierstrass curve in Jacobian coordinates. -/
abbrev WeierstrassCurve.Jacobian (R : Type u) : Type u :=
WeierstrassCurve R
/-- The coercion to a Weierstrass curve in Jacobian coordinates. -/
abbrev WeierstrassCurve.toJacobian {R : Type u} (W : WeierstrassCurve R) : Jacobian R :=
W
namespace WeierstrassCurve.Jacobian
open MvPolynomial
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, eval_pow])
local macro "pderiv_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow,
pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm,
pderiv_X_of_ne (by decide : z ≠ x), pderiv_X_of_ne (by decide : x ≠ z),
pderiv_X_of_ne (by decide : z ≠ y), pderiv_X_of_ne (by decide : y ≠ z)])
variable {R : Type u} {W' : Jacobian R} {F : Type v} [Field F] {W : Jacobian F}
section Jacobian
/-! ### Jacobian coordinates -/
lemma fin3_def (P : Fin 3 → R) : ![P x, P y, P z] = P := by
ext n; fin_cases n <;> rfl
lemma fin3_def_ext (X Y Z : R) : ![X, Y, Z] x = X ∧ ![X, Y, Z] y = Y ∧ ![X, Y, Z] z = Z :=
⟨rfl, rfl, rfl⟩
lemma comp_fin3 {S} (f : R → S) (X Y Z : R) : f ∘ ![X, Y, Z] = ![f X, f Y, f Z] :=
(FinVec.map_eq _ _).symm
variable [CommRing R]
/-- The scalar multiplication on a point representative. -/
scoped instance instSMulPoint : SMul R <| Fin 3 → R :=
⟨fun u P => ![u ^ 2 * P x, u ^ 3 * P y, u * P z]⟩
lemma smul_fin3 (P : Fin 3 → R) (u : R) : u • P = ![u ^ 2 * P x, u ^ 3 * P y, u * P z] :=
rfl
lemma smul_fin3_ext (P : Fin 3 → R) (u : R) :
(u • P) x = u ^ 2 * P x ∧ (u • P) y = u ^ 3 * P y ∧ (u • P) z = u * P z :=
⟨rfl, rfl, rfl⟩
/-- The multiplicative action on a point representative. -/
scoped instance instMulActionPoint : MulAction R <| Fin 3 → R where
one_smul _ := by simp_rw [smul_fin3, one_pow, one_mul, fin3_def]
mul_smul _ _ _ := by simp_rw [smul_fin3, mul_pow, mul_assoc, fin3_def_ext]
/-- The equivalence setoid for a point representative. -/
scoped instance instSetoidPoint : Setoid <| Fin 3 → R :=
MulAction.orbitRel Rˣ <| Fin 3 → R
variable (R) in
/-- The equivalence class of a point representative. -/
abbrev PointClass : Type u :=
MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R
lemma smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : u • P ≈ P :=
⟨hu.unit, rfl⟩
@[simp]
lemma smul_eq (P : Fin 3 → R) {u : R} (hu : IsUnit u) : (⟦u • P⟧ : PointClass R) = ⟦P⟧ :=
Quotient.eq.mpr <| smul_equiv P hu
variable (W') in
/-- The coercion to a Weierstrass curve in affine coordinates. -/
abbrev toAffine : Affine R :=
W'
lemma equiv_iff_eq_of_Z_eq' {P Q : Fin 3 → R} (hz : P z = Q z) (mem : Q z ∈ nonZeroDivisors R) :
P ≈ Q ↔ P = Q := by
refine ⟨?_, by rintro rfl; exact Setoid.refl _⟩
rintro ⟨u, rfl⟩
rw [← one_mul (Q z)] at hz
simp_rw [Units.smul_def, (mul_cancel_right_mem_nonZeroDivisors mem).mp hz, one_smul]
lemma equiv_iff_eq_of_Z_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hz : P z = Q z) (hQz : Q z ≠ 0) :
P ≈ Q ↔ P = Q :=
equiv_iff_eq_of_Z_eq' hz (mem_nonZeroDivisors_of_ne_zero hQz)
lemma Z_eq_zero_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P z = 0 ↔ Q z = 0 := by
rcases h with ⟨_, rfl⟩
simp only [Units.smul_def, smul_fin3_ext, Units.mul_right_eq_zero]
lemma X_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P x * Q z ^ 2 = Q x * P z ^ 2 := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma Y_eq_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : P y * Q z ^ 3 = Q y * P z ^ 3 := by
rcases h with ⟨u, rfl⟩
simp only [Units.smul_def, smul_fin3_ext]
ring1
lemma not_equiv_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) (hQz : Q z ≠ 0) : ¬P ≈ Q :=
fun h => hQz <| (Z_eq_zero_of_equiv h).mp hPz
lemma not_equiv_of_Z_eq_zero_right {P Q : Fin 3 → R} (hPz : P z ≠ 0) (hQz : Q z = 0) : ¬P ≈ Q :=
fun h => hPz <| (Z_eq_zero_of_equiv h).mpr hQz
lemma not_equiv_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : ¬P ≈ Q :=
hx.comp X_eq_of_equiv
lemma not_equiv_of_Y_ne {P Q : Fin 3 → R} (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : ¬P ≈ Q :=
hy.comp Y_eq_of_equiv
lemma equiv_of_X_eq_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3) : P ≈ Q := by
use Units.mk0 _ hPz / Units.mk0 _ hQz
simp only [Units.smul_def, smul_fin3, Units.val_div_eq_div_val, Units.val_mk0, div_pow, mul_comm,
mul_div, ← hx, ← hy, mul_div_cancel_right₀ _ <| pow_ne_zero _ hQz, mul_div_cancel_right₀ _ hQz,
fin3_def]
lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
P ≈ ![P x / P z ^ 2, P y / P z ^ 3, 1] :=
equiv_of_X_eq_of_Y_eq hPz one_ne_zero
(by linear_combination (norm := (matrix_simp; ring1)) -P x * div_self (pow_ne_zero 2 hPz))
(by linear_combination (norm := (matrix_simp; ring1)) -P y * div_self (pow_ne_zero 3 hPz))
lemma X_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P x * Q z ^ 2 = Q x * P z ^ 2 ↔ P x / P z ^ 2 = Q x / Q z ^ 2 :=
(div_eq_div_iff (pow_ne_zero 2 hPz) (pow_ne_zero 2 hQz)).symm
lemma Y_eq_iff {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z ^ 3 = Q y * P z ^ 3 ↔ P y / P z ^ 3 = Q y / Q z ^ 3 :=
(div_eq_div_iff (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)).symm
end Jacobian
variable [CommRing R]
section Equation
/-! ### Weierstrass equations -/
variable (W') in
/-- The polynomial $W(X, Y, Z) := Y^2 + a_1XYZ + a_3YZ^3 - (X^3 + a_2X^2Z^2 + a_4XZ^4 + a_6Z^6)$
associated to a Weierstrass curve `W'` over `R`. This is represented as a term of type
`MvPolynomial (Fin 3) R`, where `X 0`, `X 1`, and `X 2` represent $X$, $Y$, and $Z$ respectively. -/
noncomputable def polynomial : MvPolynomial (Fin 3) R :=
X 1 ^ 2 + C W'.a₁ * X 0 * X 1 * X 2 + C W'.a₃ * X 1 * X 2 ^ 3
- (X 0 ^ 3 + C W'.a₂ * X 0 ^ 2 * X 2 ^ 2 + C W'.a₄ * X 0 * X 2 ^ 4 + C W'.a₆ * X 2 ^ 6)
lemma eval_polynomial (P : Fin 3 → R) : eval P W'.polynomial =
P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) := by
rw [polynomial]
eval_simp
lemma eval_polynomial_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : eval P W.polynomial / P z ^ 6 =
W.toAffine.polynomial.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomial, Affine.evalEval_polynomial]; ring1))
W.a₁ * P x * P y / P z ^ 5 * div_self hPz + W.a₃ * P y / P z ^ 3 * div_self (pow_ne_zero 3 hPz)
- W.a₂ * P x ^ 2 / P z ^ 4 * div_self (pow_ne_zero 2 hPz)
- W.a₄ * P x / P z ^ 2 * div_self (pow_ne_zero 4 hPz) - W.a₆ * div_self (pow_ne_zero 6 hPz)
variable (W') in
/-- The proposition that a point representative $(x, y, z)$ lies in `W'`.
In other words, $W(x, y, z) = 0$. -/
def Equation (P : Fin 3 → R) : Prop :=
eval P W'.polynomial = 0
lemma equation_iff (P : Fin 3 → R) : W'.Equation P ↔
P y ^ 2 + W'.a₁ * P x * P y * P z + W'.a₃ * P y * P z ^ 3
- (P x ^ 3 + W'.a₂ * P x ^ 2 * P z ^ 2 + W'.a₄ * P x * P z ^ 4 + W'.a₆ * P z ^ 6) = 0 := by
rw [Equation, eval_polynomial]
lemma equation_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.Equation (u • P) ↔ W'.Equation P :=
have (u : R) {P : Fin 3 → R} (hP : W'.Equation P) : W'.Equation <| u • P := by
rw [equation_iff] at hP ⊢
linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) u ^ 6 * hP
⟨fun h => by convert this hu.unit.inv h; erw [smul_smul, hu.val_inv_mul, one_smul], this u⟩
lemma equation_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Equation P ↔ W'.Equation Q := by
rcases h with ⟨u, rfl⟩
exact equation_smul Q u.isUnit
lemma equation_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) :
W'.Equation P ↔ P y ^ 2 = P x ^ 3 := by
simp only [equation_iff, hPz, add_zero, mul_zero, zero_pow <| OfNat.ofNat_ne_zero _, sub_eq_zero]
lemma equation_zero : W'.Equation ![1, 1, 0] := by
simp only [equation_of_Z_eq_zero, fin3_def_ext, one_pow]
lemma equation_some (X Y : R) : W'.Equation ![X, Y, 1] ↔ W'.toAffine.Equation X Y := by
simp only [equation_iff, Affine.equation_iff', fin3_def_ext, one_pow, mul_one]
lemma equation_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Equation P ↔ W.toAffine.Equation (P x / P z ^ 2) (P y / P z ^ 3) :=
(equation_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| equation_some ..
end Equation
section Nonsingular
/-! ### Nonsingular Weierstrass equations -/
variable (W') in
/-- The partial derivative $W_X(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $X$. -/
noncomputable def polynomialX : MvPolynomial (Fin 3) R :=
pderiv x W'.polynomial
lemma polynomialX_eq : W'.polynomialX =
C W'.a₁ * X 1 * X 2 - (C 3 * X 0 ^ 2 + C (2 * W'.a₂) * X 0 * X 2 ^ 2 + C W'.a₄ * X 2 ^ 4) := by
rw [polynomialX, polynomial]
pderiv_simp
ring1
lemma eval_polynomialX (P : Fin 3 → R) : eval P W'.polynomialX =
W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) := by
rw [polynomialX_eq]
eval_simp
lemma eval_polynomialX_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialX / P z ^ 4 =
W.toAffine.polynomialX.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomialX, Affine.evalEval_polynomialX]; ring1))
W.a₁ * P y / P z ^ 3 * div_self hPz - 2 * W.a₂ * P x / P z ^ 2 * div_self (pow_ne_zero 2 hPz)
- W.a₄ * div_self (pow_ne_zero 4 hPz)
variable (W') in
/-- The partial derivative $W_Y(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Y$. -/
noncomputable def polynomialY : MvPolynomial (Fin 3) R :=
pderiv y W'.polynomial
lemma polynomialY_eq : W'.polynomialY = C 2 * X 1 + C W'.a₁ * X 0 * X 2 + C W'.a₃ * X 2 ^ 3 := by
rw [polynomialY, polynomial]
pderiv_simp
ring1
lemma eval_polynomialY (P : Fin 3 → R) :
eval P W'.polynomialY = 2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 := by
rw [polynomialY_eq]
eval_simp
lemma eval_polynomialY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
eval P W.polynomialY / P z ^ 3 =
W.toAffine.polynomialY.evalEval (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [eval_polynomialY, Affine.evalEval_polynomialY]; ring1))
W.a₁ * P x / P z ^ 2 * div_self hPz + W.a₃ * div_self (pow_ne_zero 3 hPz)
variable (W') in
/-- The partial derivative $W_Z(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Z$. -/
noncomputable def polynomialZ : MvPolynomial (Fin 3) R :=
pderiv z W'.polynomial
lemma polynomialZ_eq : W'.polynomialZ = C W'.a₁ * X 0 * X 1 + C (3 * W'.a₃) * X 1 * X 2 ^ 2 -
(C (2 * W'.a₂) * X 0 ^ 2 * X 2 + C (4 * W'.a₄) * X 0 * X 2 ^ 3 + C (6 * W'.a₆) * X 2 ^ 5) := by
rw [polynomialZ, polynomial]
pderiv_simp
ring1
lemma eval_polynomialZ (P : Fin 3 → R) : eval P W'.polynomialZ =
W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2 -
(2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) := by
rw [polynomialZ_eq]
eval_simp
variable (W') in
/-- The proposition that a point representative $(x, y, z)$ in `W'` is nonsingular.
In other words, either $W_X(x, y, z) \ne 0$, $W_Y(x, y, z) \ne 0$, or $W_Z(x, y, z) \ne 0$.
Note that this definition is only mathematically accurate for fields.
TODO: generalise this definition to be mathematically accurate for a larger class of rings. -/
def Nonsingular (P : Fin 3 → R) : Prop :=
W'.Equation P ∧
(eval P W'.polynomialX ≠ 0 ∨ eval P W'.polynomialY ≠ 0 ∨ eval P W'.polynomialZ ≠ 0)
lemma nonsingular_iff (P : Fin 3 → R) : W'.Nonsingular P ↔ W'.Equation P ∧
(W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) ≠ 0 ∨
2 * P y + W'.a₁ * P x * P z + W'.a₃ * P z ^ 3 ≠ 0 ∨
W'.a₁ * P x * P y + 3 * W'.a₃ * P y * P z ^ 2
- (2 * W'.a₂ * P x ^ 2 * P z + 4 * W'.a₄ * P x * P z ^ 3 + 6 * W'.a₆ * P z ^ 5) ≠ 0) := by
rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
lemma nonsingular_smul (P : Fin 3 → R) {u : R} (hu : IsUnit u) :
W'.Nonsingular (u • P) ↔ W'.Nonsingular P :=
have {u : R} (hu : IsUnit u) {P : Fin 3 → R} (hP : W'.Nonsingular <| u • P) :
W'.Nonsingular P := by
rcases (nonsingular_iff _).mp hP with ⟨hP, hP'⟩
refine (nonsingular_iff P).mpr ⟨(equation_smul P hu).mp hP, ?_⟩
contrapose! hP'
simp only [smul_fin3_ext]
exact ⟨by linear_combination (norm := ring1) u ^ 4 * hP'.left,
by linear_combination (norm := ring1) u ^ 3 * hP'.right.left,
by linear_combination (norm := ring1) u ^ 5 * hP'.right.right⟩
⟨this hu, fun h => this hu.unit⁻¹.isUnit <| by rwa [smul_smul, hu.val_inv_mul, one_smul]⟩
lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.Nonsingular P ↔ W'.Nonsingular Q := by
rcases h with ⟨u, rfl⟩
exact nonsingular_smul Q u.isUnit
lemma nonsingular_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) :
W'.Nonsingular P ↔ W'.Equation P ∧ (3 * P x ^ 2 ≠ 0 ∨ 2 * P y ≠ 0 ∨ W'.a₁ * P x * P y ≠ 0) := by
simp only [nonsingular_iff, hPz, add_zero, sub_zero, zero_sub, mul_zero,
zero_pow <| OfNat.ofNat_ne_zero _, neg_ne_zero]
lemma nonsingular_zero [Nontrivial R] : W'.Nonsingular ![1, 1, 0] := by
simp only [nonsingular_of_Z_eq_zero, equation_zero, true_and, fin3_def_ext, ← not_and_or]
exact fun h => one_ne_zero <| by linear_combination (norm := ring1) h.1 - h.2.1
lemma nonsingular_some (X Y : R) : W'.Nonsingular ![X, Y, 1] ↔ W'.toAffine.Nonsingular X Y := by
simp_rw [nonsingular_iff, equation_some, fin3_def_ext, Affine.nonsingular_iff',
Affine.equation_iff', and_congr_right_iff, ← not_and_or, not_iff_not, one_pow, mul_one,
and_congr_right_iff, Iff.comm, iff_self_and]
intro h hX hY
linear_combination (norm := ring1) 6 * h - 2 * X * hX - 3 * Y * hY
lemma nonsingular_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z ^ 2) (P y / P z ^ 3) :=
(nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| nonsingular_some ..
lemma nonsingular_iff_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0) := by
rw [nonsingular_of_Z_ne_zero hPz, Affine.Nonsingular, ← equation_of_Z_ne_zero hPz,
← eval_polynomialX_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 4 hPz,
← eval_polynomialY_of_Z_ne_zero hPz, div_ne_zero_iff, and_iff_left <| pow_ne_zero 3 hPz]
lemma X_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P)
(hPz : P z = 0) : P x ≠ 0 := by
intro hPx
simp only [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPx, mul_zero, zero_mul,
zero_pow <| OfNat.ofNat_ne_zero _, ne_self_iff_false, or_false, false_or] at hP
rwa [pow_eq_zero_iff two_ne_zero, hP.left, eq_self, true_and, mul_zero, ne_self_iff_false] at hP
lemma isUnit_X_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P x) :=
(X_ne_zero_of_Z_eq_zero hP hPz).isUnit
lemma Y_ne_zero_of_Z_eq_zero [NoZeroDivisors R] {P : Fin 3 → R} (hP : W'.Nonsingular P)
(hPz : P z = 0) : P y ≠ 0 := by
have hPx : P x ≠ 0 := X_ne_zero_of_Z_eq_zero hP hPz
intro hPy
rw [nonsingular_of_Z_eq_zero hPz, equation_of_Z_eq_zero hPz, hPy, zero_pow two_ne_zero] at hP
exact hPx <| pow_eq_zero hP.left.symm
lemma isUnit_Y_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) : IsUnit (P y) :=
(Y_ne_zero_of_Z_eq_zero hP hPz).isUnit
lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by
have hPx : IsUnit <| P x := isUnit_X_of_Z_eq_zero hP hPz
have hPy : IsUnit <| P y := isUnit_Y_of_Z_eq_zero hP hPz
have hQx : IsUnit <| Q x := isUnit_X_of_Z_eq_zero hQ hQz
have hQy : IsUnit <| Q y := isUnit_Y_of_Z_eq_zero hQ hQz
simp only [nonsingular_of_Z_eq_zero, equation_of_Z_eq_zero, hPz, hQz] at hP hQ
use (hPy.unit / hPx.unit) * (hQx.unit / hQy.unit)
simp only [Units.smul_def, smul_fin3, Units.val_mul, Units.val_div_eq_div_val, IsUnit.unit_spec,
mul_pow, div_pow, hQz, mul_zero]
conv_rhs => rw [← fin3_def P, hPz]
congr! 2
· rw [hP.left, pow_succ, (hPx.pow 2).mul_div_cancel_left, hQ.left, pow_succ _ 2,
(hQx.pow 2).div_mul_cancel_left, hQx.inv_mul_cancel_right]
· rw [← hP.left, pow_succ, (hPy.pow 2).mul_div_cancel_left, ← hQ.left, pow_succ _ 2,
(hQy.pow 2).div_mul_cancel_left, hQy.inv_mul_cancel_right]
lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
P ≈ ![1, 1, 0] :=
equiv_of_Z_eq_zero hP nonsingular_zero hPz rfl
variable (W') in
/-- The proposition that a point class on `W'` is nonsingular. If `P` is a point representative,
then `W'.NonsingularLift ⟦P⟧` is definitionally equivalent to `W'.Nonsingular P`. -/
def NonsingularLift (P : PointClass R) : Prop :=
P.lift W'.Nonsingular fun _ _ => propext ∘ nonsingular_of_equiv
lemma nonsingularLift_iff (P : Fin 3 → R) : W'.NonsingularLift ⟦P⟧ ↔ W'.Nonsingular P :=
Iff.rfl
lemma nonsingularLift_zero [Nontrivial R] : W'.NonsingularLift ⟦![1, 1, 0]⟧ :=
nonsingular_zero
lemma nonsingularLift_some (X Y : R) :
W'.NonsingularLift ⟦![X, Y, 1]⟧ ↔ W'.toAffine.Nonsingular X Y :=
nonsingular_some X Y
end Nonsingular
section Negation
/-! ### Negation formulae -/
variable (W') in
/-- The $Y$-coordinate of the negation of a point representative. -/
def negY (P : Fin 3 → R) : R :=
-P y - W'.a₁ * P x * P z - W'.a₃ * P z ^ 3
lemma negY_smul (P : Fin 3 → R) {u : R} : W'.negY (u • P) = u ^ 3 * W'.negY P := by
simp only [negY, smul_fin3_ext]
ring1
lemma negY_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.negY P = -P y := by
simp only [negY, hPz, sub_zero, mul_zero, zero_pow three_ne_zero]
lemma negY_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negY P / P z ^ 3 = W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3) := by
linear_combination (norm := (rw [negY, Affine.negY]; ring1))
-W.a₁ * P x / P z ^ 2 * div_self hPz - W.a₃ * div_self (pow_ne_zero 3 hPz)
lemma Y_sub_Y_mul_Y_sub_negY {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
(P y * Q z ^ 3 - Q y * P z ^ 3) * (P y * Q z ^ 3 - W'.negY Q * P z ^ 3) = 0 := by
linear_combination (norm := (rw [negY]; ring1)) Q z ^ 6 * (equation_iff P).mp hP
- P z ^ 6 * (equation_iff Q).mp hQ + hx * hx * hx + W'.a₂ * P z ^ 2 * Q z ^ 2 * hx * hx
+ (W'.a₄ * P z ^ 4 * Q z ^ 4 - W'.a₁ * P y * P z * Q z ^ 4) * hx
lemma Y_eq_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
P y * Q z ^ 3 = W.negY Q * P z ^ 3 :=
eq_of_sub_eq_zero <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_left <|
sub_ne_zero_of_ne hy
lemma Y_eq_of_Y_ne' {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
P y * Q z ^ 3 = Q y * P z ^ 3 :=
eq_of_sub_eq_zero <| (mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_right <|
sub_ne_zero_of_ne hy
lemma Y_eq_iff' {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) :
P y * Q z ^ 3 = W.negY Q * P z ^ 3 ↔
P y / P z ^ 3 = W.toAffine.negY (Q x / Q z ^ 2) (Q y / Q z ^ 3) :=
negY_of_Z_ne_zero hQz ▸ (div_eq_div_iff (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)).symm
lemma Y_sub_Y_add_Y_sub_negY (P Q : Fin 3 → R) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
(P y * Q z ^ 3 - Q y * P z ^ 3) + (P y * Q z ^ 3 - W'.negY Q * P z ^ 3) =
(P y - W'.negY P) * Q z ^ 3 := by
linear_combination (norm := (rw [negY, negY]; ring1)) -W'.a₁ * P z * Q z * hx
lemma Y_ne_negY_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
P y ≠ W'.negY P := by
have hy' : P y * Q z ^ 3 - W'.negY Q * P z ^ 3 = 0 :=
(mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_left <| sub_ne_zero_of_ne hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY P Q hx + Q z ^ 3 * hy - hy'
lemma Y_ne_negY_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W'.negY Q * P z ^ 3) : P y ≠ W'.negY P := by
have hy' : P y * Q z ^ 3 - Q y * P z ^ 3 = 0 :=
(mul_eq_zero.mp <| Y_sub_Y_mul_Y_sub_negY hP hQ hx).resolve_right <| sub_ne_zero_of_ne hy
contrapose! hy
linear_combination (norm := ring1) Y_sub_Y_add_Y_sub_negY P Q hx + Q z ^ 3 * hy - hy'
lemma Y_eq_negY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : P y = W'.negY P :=
mul_left_injective₀ (pow_ne_zero 3 hQz) <| by
linear_combination (norm := ring1) -Y_sub_Y_add_Y_sub_negY P Q hx + hy + hy'
lemma nonsingular_iff_of_Y_eq_negY {P : Fin 3 → F} (hPz : P z ≠ 0) (hy : P y = W.negY P) :
W.Nonsingular P ↔ W.Equation P ∧ eval P W.polynomialX ≠ 0 := by
have : eval P W.polynomialY = P y - W.negY P := by
rw [negY, eval_polynomialY]; ring1
rw [nonsingular_iff_of_Z_ne_zero hPz, this, hy, sub_self, ne_self_iff_false, or_false]
end Negation
section Doubling
/-! ### Doubling formulae -/
variable (W') in
/-- The unit associated to the doubling of a 2-torsion point.
More specifically, the unit `u` such that `W.add P P = u • ![1, 1, 0]` where `P = W.neg P`. -/
noncomputable def dblU (P : Fin 3 → R) : R :=
eval P W'.polynomialX
lemma dblU_eq (P : Fin 3 → R) : W'.dblU P =
W'.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W'.a₂ * P x * P z ^ 2 + W'.a₄ * P z ^ 4) := by
rw [dblU, eval_polynomialX]
lemma dblU_smul (P : Fin 3 → R) (u : R) : W'.dblU (u • P) = u ^ 4 * W'.dblU P := by
simp only [dblU_eq, smul_fin3_ext]
ring1
lemma dblU_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.dblU P = -3 * P x ^ 2 := by
rw [dblU_eq, hPz]
ring1
lemma dblU_ne_zero_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.dblU P ≠ 0 :=
((nonsingular_iff_of_Y_eq_negY hPz <| Y_eq_negY_of_Y_eq hQz hx hy hy').mp hP).right
lemma isUnit_dblU_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : IsUnit (W.dblU P) :=
(dblU_ne_zero_of_Y_eq hP hPz hQz hx hy hy').isUnit
variable (W') in
/-- The $Z$-coordinate of the doubling of a point representative. -/
def dblZ (P : Fin 3 → R) : R :=
P z * (P y - W'.negY P)
lemma dblZ_smul (P : Fin 3 → R) (u : R) : W'.dblZ (u • P) = u ^ 4 * W'.dblZ P := by
simp only [dblZ, negY_smul, smul_fin3_ext]
ring1
lemma dblZ_of_Z_eq_zero {P : Fin 3 → R} (hPz : P z = 0) : W'.dblZ P = 0 := by
rw [dblZ, hPz, zero_mul]
lemma dblZ_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblZ P = 0 := by
rw [dblZ, Y_eq_negY_of_Y_eq hQz hx hy hy', sub_self, mul_zero]
lemma dblZ_ne_zero_of_Y_ne [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| sub_ne_zero_of_ne <| Y_ne_negY_of_Y_ne hP hQ hx hy
lemma isUnit_dblZ_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne hP hQ hPz hx hy).isUnit
lemma dblZ_ne_zero_of_Y_ne' [NoZeroDivisors R] {P Q : Fin 3 → R} (hP : W'.Equation P)
(hQ : W'.Equation Q) (hPz : P z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W'.negY Q * P z ^ 3) : W'.dblZ P ≠ 0 :=
mul_ne_zero hPz <| sub_ne_zero_of_ne <| Y_ne_negY_of_Y_ne' hP hQ hx hy
lemma isUnit_dblZ_of_Y_ne' {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
IsUnit (W.dblZ P) :=
(dblZ_ne_zero_of_Y_ne' hP hQ hPz hx hy).isUnit
private lemma toAffine_slope_of_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3) =
-W.dblU P / W.dblZ P := by
have hPy : P y - W.negY P ≠ 0 := sub_ne_zero_of_ne <| Y_ne_negY_of_Y_ne' hP hQ hx hy
simp only [mul_comm <| P z ^ _, X_eq_iff hPz hQz, ne_eq, Y_eq_iff' hPz hQz] at hx hy
rw [Affine.slope_of_Y_ne hx <| negY_of_Z_ne_zero hQz ▸ hy, ← negY_of_Z_ne_zero hPz, dblU_eq, dblZ]
field_simp [pow_ne_zero 2 hPz]
ring1
variable (W') in
/-- The $X$-coordinate of the doubling of a point representative. -/
noncomputable def dblX (P : Fin 3 → R) : R :=
W'.dblU P ^ 2 - W'.a₁ * W'.dblU P * P z * (P y - W'.negY P)
- W'.a₂ * P z ^ 2 * (P y - W'.negY P) ^ 2 - 2 * P x * (P y - W'.negY P) ^ 2
lemma dblX_smul (P : Fin 3 → R) (u : R) : W'.dblX (u • P) = (u ^ 4) ^ 2 * W'.dblX P := by
simp_rw [dblX, dblU_smul, negY_smul, smul_fin3_ext]
ring1
lemma dblX_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblX P = (P x ^ 2) ^ 2 := by
linear_combination (norm := (rw [dblX, dblU_of_Z_eq_zero hPz, negY_of_Z_eq_zero hPz, hPz]; ring1))
-8 * P x * (equation_of_Z_eq_zero hPz).mp hP
lemma dblX_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblX P = W'.dblU P ^ 2 := by
rw [dblX, Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
private lemma toAffine_addX_of_eq {P : Fin 3 → F} {n d : F} (hPz : P z ≠ 0) (hd : d ≠ 0) :
W.toAffine.addX (P x / P z ^ 2) (P x / P z ^ 2) (-n / (P z * d)) =
(n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * d ^ 2) / (P z * d) ^ 2 := by
field_simp [mul_ne_zero hPz hd]
ring1
lemma dblX_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblX P / W.dblZ P ^ 2 = W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [dblX, toAffine_slope_of_eq hP hQ hPz hQz hx hy, dblZ, ← (X_eq_iff hPz hQz).mp hx,
toAffine_addX_of_eq hPz <| sub_ne_zero_of_ne <| Y_ne_negY_of_Y_ne' hP hQ hx hy]
variable (W') in
/-- The $Y$-coordinate of the negated doubling of a point representative. -/
noncomputable def negDblY (P : Fin 3 → R) : R :=
-W'.dblU P * (W'.dblX P - P x * (P y - W'.negY P) ^ 2) + P y * (P y - W'.negY P) ^ 3
lemma negDblY_smul (P : Fin 3 → R) (u : R) : W'.negDblY (u • P) = (u ^ 4) ^ 3 * W'.negDblY P := by
simp only [negDblY, dblU_smul, dblX_smul, negY_smul, smul_fin3_ext]
ring1
lemma negDblY_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negDblY P = -(P x ^ 2) ^ 3 := by
linear_combination (norm :=
(rw [negDblY, dblU_of_Z_eq_zero hPz, dblX_of_Z_eq_zero hP hPz, negY_of_Z_eq_zero hPz]; ring1))
(8 * (equation_of_Z_eq_zero hPz).mp hP - 12 * P x ^ 3) * (equation_of_Z_eq_zero hPz).mp hP
lemma negDblY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.negDblY P = (-W'.dblU P) ^ 3 := by
rw [negDblY, dblX_of_Y_eq hQz hx hy hy', Y_eq_negY_of_Y_eq hQz hx hy hy']
ring1
private lemma toAffine_negAddY_of_eq {P : Fin 3 → F} {n d : F} (hPz : P z ≠ 0) (hd : d ≠ 0) :
W.toAffine.negAddY (P x / P z ^ 2) (P x / P z ^ 2) (P y / P z ^ 3) (-n / (P z * d)) =
(-n * (n ^ 2 - W.a₁ * n * P z * d - W.a₂ * P z ^ 2 * d ^ 2 - 2 * P x * d ^ 2 - P x * d ^ 2)
+ P y * d ^ 3) / (P z * d) ^ 3 := by
linear_combination (norm := (rw [Affine.negAddY, toAffine_addX_of_eq hPz hd]; ring1))
-n * P x / (P z ^ 3 * d) * div_self (pow_ne_zero 2 hd)
- P y / P z ^ 3 * div_self (pow_ne_zero 3 hd)
lemma negDblY_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q)
(hPz : P z ≠ 0) (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) : W.negDblY P / W.dblZ P ^ 3 =
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [negDblY, dblX, toAffine_slope_of_eq hP hQ hPz hQz hx hy, dblZ, ← (X_eq_iff hPz hQz).mp hx,
toAffine_negAddY_of_eq hPz <| sub_ne_zero_of_ne <| Y_ne_negY_of_Y_ne' hP hQ hx hy]
variable (W') in
/-- The $Y$-coordinate of the doubling of a point representative. -/
noncomputable def dblY (P : Fin 3 → R) : R :=
W'.negY ![W'.dblX P, W'.negDblY P, W'.dblZ P]
lemma dblY_smul (P : Fin 3 → R) (u : R) : W'.dblY (u • P) = (u ^ 4) ^ 3 * W'.dblY P := by
simp only [dblY, negY, dblX_smul, negDblY_smul, dblZ_smul, fin3_def_ext]
ring1
lemma dblY_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblY P = (P x ^ 2) ^ 3 := by
erw [dblY, negDblY_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz, negY_of_Z_eq_zero rfl, neg_neg]
lemma dblY_of_Y_eq [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) : W'.dblY P = W'.dblU P ^ 3 := by
erw [dblY, dblZ_of_Y_eq hQz hx hy hy', negY_of_Z_eq_zero rfl, negDblY_of_Y_eq hQz hx hy hy',
← Odd.neg_pow <| by decide, neg_neg]
lemma dblY_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblY P / W.dblZ P ^ 3 = W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
erw [dblY, negY_of_Z_ne_zero <| dblZ_ne_zero_of_Y_ne' hP hQ hPz hx hy,
dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, negDblY_of_Z_ne_zero hP hQ hPz hQz hx hy, Affine.addY]
variable (W') in
/-- The coordinates of the doubling of a point representative. -/
noncomputable def dblXYZ (P : Fin 3 → R) : Fin 3 → R :=
![W'.dblX P, W'.dblY P, W'.dblZ P]
lemma dblXYZ_smul (P : Fin 3 → R) (u : R) : W'.dblXYZ (u • P) = (u ^ 4) • W'.dblXYZ P := by
rw [dblXYZ, dblX_smul, dblY_smul, dblZ_smul]
rfl
lemma dblXYZ_of_Z_eq_zero {P : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.dblXYZ P = P x ^ 2 • ![1, 1, 0] := by
erw [dblXYZ, dblX_of_Z_eq_zero hP hPz, dblY_of_Z_eq_zero hP hPz, dblZ_of_Z_eq_zero hPz, smul_fin3,
mul_one, mul_one, mul_zero]
lemma dblXYZ_of_Y_eq' [NoZeroDivisors R] {P Q : Fin 3 → R} (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W'.negY Q * P z ^ 3) :
W'.dblXYZ P = ![W'.dblU P ^ 2, W'.dblU P ^ 3, 0] := by
rw [dblXYZ, dblX_of_Y_eq hQz hx hy hy', dblY_of_Y_eq hQz hx hy hy', dblZ_of_Y_eq hQz hx hy hy']
lemma dblXYZ_of_Y_eq {P Q : Fin 3 → F} (hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy : P y * Q z ^ 3 = Q y * P z ^ 3) (hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) :
W.dblXYZ P = W.dblU P • ![1, 1, 0] := by
erw [dblXYZ_of_Y_eq' hQz hx hy hy', smul_fin3, mul_one, mul_one, mul_zero]
lemma dblXYZ_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.dblXYZ P = W.dblZ P •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
have hZ {n : ℕ} : IsUnit <| W.dblZ P ^ n := (isUnit_dblZ_of_Y_ne' hP hQ hPz hx hy).pow n
erw [dblXYZ, smul_fin3, ← dblX_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel,
← dblY_of_Z_ne_zero hP hQ hPz hQz hx hy, hZ.mul_div_cancel, mul_one]
end Doubling
section Addition
/-! ### Addition formulae -/
/-- The unit associated to the addition of a non-2-torsion point with its negation.
More specifically, the unit `u` such that `W.add P Q = u • ![1, 1, 0]` where
`P x / P z ^ 2 = Q x / Q z ^ 2` but `P ≠ W.neg P`. -/
def addU (P Q : Fin 3 → F) : F :=
-((P y * Q z ^ 3 - Q y * P z ^ 3) / (P z * Q z))
lemma addU_smul {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) {u v : F} (hu : u ≠ 0)
(hv : v ≠ 0) : addU (u • P) (v • Q) = (u * v) ^ 2 * addU P Q := by
field_simp [addU, smul_fin3_ext]
ring1
lemma addU_of_Z_eq_zero_left {P Q : Fin 3 → F} (hPz : P z = 0) : addU P Q = 0 := by
rw [addU, hPz, zero_mul, div_zero, neg_zero]
lemma addU_of_Z_eq_zero_right {P Q : Fin 3 → F} (hQz : Q z = 0) : addU P Q = 0 := by
rw [addU, hQz, mul_zero, div_zero, neg_zero]
lemma addU_ne_zero_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : addU P Q ≠ 0 :=
neg_ne_zero.mpr <| div_ne_zero (sub_ne_zero_of_ne hy) <| mul_ne_zero hPz hQz
lemma isUnit_addU_of_Y_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) : IsUnit (addU P Q) :=
(addU_ne_zero_of_Y_ne hPz hQz hy).isUnit
/-- The $Z$-coordinate of the addition of two distinct point representatives. -/
def addZ (P Q : Fin 3 → R) : R :=
P x * Q z ^ 2 - Q x * P z ^ 2
lemma addZ_self {P : Fin 3 → R} : addZ P P = 0 := sub_self _
lemma addZ_smul (P Q : Fin 3 → R) (u v : R) : addZ (u • P) (v • Q) = (u * v) ^ 2 * addZ P Q := by
simp only [addZ, smul_fin3_ext]
ring1
lemma addZ_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) : addZ P Q = P x * Q z * Q z := by
rw [addZ, hPz]
ring1
lemma addZ_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQz : Q z = 0) :
addZ P Q = -(Q x * P z) * P z := by
rw [addZ, hQz]
ring1
lemma addZ_of_X_eq {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : addZ P Q = 0 := by
rw [addZ, hx, sub_self]
lemma addZ_ne_zero_of_X_ne {P Q : Fin 3 → R} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : addZ P Q ≠ 0 :=
sub_ne_zero_of_ne hx
lemma isUnit_addZ_of_X_ne {P Q : Fin 3 → F} (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
IsUnit <| addZ P Q :=
(addZ_ne_zero_of_X_ne hx).isUnit
private lemma toAffine_slope_of_ne {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3) =
(P y * Q z ^ 3 - Q y * P z ^ 3) / (P z * Q z * addZ P Q) := by
rw [Affine.slope_of_X_ne <| by rwa [ne_eq, ← X_eq_iff hPz hQz],
div_sub_div _ _ (pow_ne_zero 2 hPz) (pow_ne_zero 2 hQz), mul_comm <| _ ^ 2, addZ]
field_simp [mul_ne_zero (mul_ne_zero hPz hQz) <| sub_ne_zero_of_ne hx,
mul_ne_zero (mul_ne_zero (pow_ne_zero 3 hPz) (pow_ne_zero 3 hQz)) <| sub_ne_zero_of_ne hx]
ring1
variable (W') in
/-- The $X$-coordinate of the addition of two distinct point representatives. -/
def addX (P Q : Fin 3 → R) : R :=
P x * Q x ^ 2 * P z ^ 2 - 2 * P y * Q y * P z * Q z + P x ^ 2 * Q x * Q z ^ 2
- W'.a₁ * P x * Q y * P z ^ 2 * Q z - W'.a₁ * P y * Q x * P z * Q z ^ 2
+ 2 * W'.a₂ * P x * Q x * P z ^ 2 * Q z ^ 2 - W'.a₃ * Q y * P z ^ 4 * Q z
- W'.a₃ * P y * P z * Q z ^ 4 + W'.a₄ * Q x * P z ^ 4 * Q z ^ 2
+ W'.a₄ * P x * P z ^ 2 * Q z ^ 4 + 2 * W'.a₆ * P z ^ 4 * Q z ^ 4
lemma addX_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addX P P = 0 := by
linear_combination (norm := (rw [addX]; ring1)) -2 * P z ^ 2 * (equation_iff _).mp hP
lemma addX_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q) :
W'.addX P Q * (P z * Q z) ^ 2 =
(P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2
+ W'.a₁ * (P y * Q z ^ 3 - Q y * P z ^ 3) * P z * Q z * addZ P Q
- W'.a₂ * P z ^ 2 * Q z ^ 2 * addZ P Q ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2
- Q x * P z ^ 2 * addZ P Q ^ 2 := by
linear_combination (norm := (rw [addX, addZ]; ring1)) -Q z ^ 6 * (equation_iff P).mp hP
- P z ^ 6 * (equation_iff Q).mp hQ
lemma addX_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) : W.addX P Q =
((P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2
+ W.a₁ * (P y * Q z ^ 3 - Q y * P z ^ 3) * P z * Q z * addZ P Q
- W.a₂ * P z ^ 2 * Q z ^ 2 * addZ P Q ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2
- Q x * P z ^ 2 * addZ P Q ^ 2) / (P z * Q z) ^ 2 := by
rw [← addX_eq' hP hQ, mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
lemma addX_smul (P Q : Fin 3 → R) (u v : R) :
W'.addX (u • P) (v • Q) = ((u * v) ^ 2) ^ 2 * W'.addX P Q := by
simp only [addX, smul_fin3_ext]
ring1
lemma addX_of_Z_eq_zero_left {P Q : Fin 3 → R} (hPz : P z = 0) :
W'.addX P Q = (P x * Q z) ^ 2 * Q x := by
rw [addX, hPz]
ring1
lemma addX_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQz : Q z = 0) :
W'.addX P Q = (-(Q x * P z)) ^ 2 * P x := by
rw [addX, hQz]
ring1
lemma addX_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.addX P Q * (P z * Q z) ^ 2 = (P y * Q z ^ 3 - Q y * P z ^ 3) ^ 2 := by
simp only [addX_eq' hP hQ, addZ_of_X_eq hx, add_zero, sub_zero, mul_zero, zero_pow two_ne_zero]
lemma addX_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.addX P Q = addU P Q ^ 2 := by
rw [addU, neg_sq, div_pow, ← addX_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 2 <| mul_ne_zero hPz hQz]
private lemma toAffine_addX_of_ne {P Q : Fin 3 → F} {n d : F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hd : d ≠ 0) : W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2) (n / (P z * Q z * d)) =
(n ^ 2 + W.a₁ * n * P z * Q z * d - W.a₂ * P z ^ 2 * Q z ^ 2 * d ^ 2 - P x * Q z ^ 2 * d ^ 2
- Q x * P z ^ 2 * d ^ 2) / (P z * Q z * d) ^ 2 := by
field_simp [mul_ne_zero (mul_ne_zero hPz hQz) hd]
ring1
lemma addX_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.addX P Q / addZ P Q ^ 2 = W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [addX_eq hP hQ hPz hQz, div_div, ← mul_pow, toAffine_slope_of_ne hPz hQz hx,
toAffine_addX_of_ne hPz hQz <| addZ_ne_zero_of_X_ne hx]
variable (W') in
/-- The $Y$-coordinate of the negated addition of two distinct point representatives. -/
def negAddY (P Q : Fin 3 → R) : R :=
-P y * Q x ^ 3 * P z ^ 3 + 2 * P y * Q y ^ 2 * P z ^ 3 - 3 * P x ^ 2 * Q x * Q y * P z ^ 2 * Q z
+ 3 * P x * P y * Q x ^ 2 * P z * Q z ^ 2 + P x ^ 3 * Q y * Q z ^ 3
- 2 * P y ^ 2 * Q y * Q z ^ 3 + W'.a₁ * P x * Q y ^ 2 * P z ^ 4
+ W'.a₁ * P y * Q x * Q y * P z ^ 3 * Q z - W'.a₁ * P x * P y * Q y * P z * Q z ^ 3
- W'.a₁ * P y ^ 2 * Q x * Q z ^ 4 - 2 * W'.a₂ * P x * Q x * Q y * P z ^ 4 * Q z
+ 2 * W'.a₂ * P x * P y * Q x * P z * Q z ^ 4 + W'.a₃ * Q y ^ 2 * P z ^ 6
- W'.a₃ * P y ^ 2 * Q z ^ 6 - W'.a₄ * Q x * Q y * P z ^ 6 * Q z
- W'.a₄ * P x * Q y * P z ^ 4 * Q z ^ 3 + W'.a₄ * P y * Q x * P z ^ 3 * Q z ^ 4
+ W'.a₄ * P x * P y * P z * Q z ^ 6 - 2 * W'.a₆ * Q y * P z ^ 6 * Q z ^ 3
+ 2 * W'.a₆ * P y * P z ^ 3 * Q z ^ 6
lemma negAddY_self {P : Fin 3 → R} : W'.negAddY P P = 0 := by rw [negAddY]; ring
lemma negAddY_eq' {P Q : Fin 3 → R} : W'.negAddY P Q * (P z * Q z) ^ 3 =
(P y * Q z ^ 3 - Q y * P z ^ 3) * (W'.addX P Q * (P z * Q z) ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2)
+ P y * Q z ^ 3 * addZ P Q ^ 3 := by
rw [negAddY, addX, addZ]
ring1
lemma negAddY_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0) : W.negAddY P Q =
((P y * Q z ^ 3 - Q y * P z ^ 3) * (W.addX P Q * (P z * Q z) ^ 2 - P x * Q z ^ 2 * addZ P Q ^ 2)
+ P y * Q z ^ 3 * addZ P Q ^ 3) / (P z * Q z) ^ 3 := by
rw [← negAddY_eq', mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
lemma negAddY_smul (P Q : Fin 3 → R) (u v : R) :
W'.negAddY (u • P) (v • Q) = ((u * v) ^ 2) ^ 3 * W'.negAddY P Q := by
simp only [negAddY, smul_fin3_ext]
ring1
lemma negAddY_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.negAddY P Q = (P x * Q z) ^ 3 * W'.negY Q := by
linear_combination (norm := (rw [negAddY, negY, hPz]; ring1))
(W'.negY Q - Q y) * Q z ^ 3 * (equation_of_Z_eq_zero hPz).mp hP
lemma negAddY_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.negAddY P Q = (-(Q x * P z)) ^ 3 * W'.negY P := by
linear_combination (norm := (rw [negAddY, negY, hQz]; ring1))
(P y - W'.negY P) * P z ^ 3 * (equation_of_Z_eq_zero hQz).mp hQ
lemma negAddY_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.negAddY P Q * (P z * Q z) ^ 3 = (P y * Q z ^ 3 - Q y * P z ^ 3) ^ 3 := by
simp only [negAddY_eq', addX_eq' hP hQ, addZ_of_X_eq hx, add_zero, sub_zero, mul_zero,
zero_pow <| OfNat.ofNat_ne_zero _, ← pow_succ']
lemma negAddY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.negAddY P Q = (-addU P Q) ^ 3 := by
rw [addU, neg_neg, div_pow, ← negAddY_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
private lemma toAffine_negAddY_of_ne {P Q : Fin 3 → F} {n d : F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hd : d ≠ 0) :
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (n / (P z * Q z * d)) =
(n * (n ^ 2 + W.a₁ * n * P z * Q z * d - W.a₂ * P z ^ 2 * Q z ^ 2 * d ^ 2
- P x * Q z ^ 2 * d ^ 2 - Q x * P z ^ 2 * d ^ 2 - P x * Q z ^ 2 * d ^ 2)
+ P y * Q z ^ 3 * d ^ 3) / (P z * Q z * d) ^ 3 := by
linear_combination (norm := (rw [Affine.negAddY, toAffine_addX_of_ne hPz hQz hd]; ring1))
n * P x / (P z ^ 3 * Q z * d) * div_self (pow_ne_zero 2 <| mul_ne_zero hQz hd)
- P y / P z ^ 3 * div_self (pow_ne_zero 3 <| mul_ne_zero hQz hd)
lemma negAddY_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) : W.negAddY P Q / addZ P Q ^ 3 =
W.toAffine.negAddY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
rw [negAddY_eq hPz hQz, addX_eq' hP hQ, div_div, ← mul_pow _ _ 3, toAffine_slope_of_ne hPz hQz hx,
toAffine_negAddY_of_ne hPz hQz <| addZ_ne_zero_of_X_ne hx]
variable (W') in
/-- The $Y$-coordinate of the addition of two distinct point representatives. -/
def addY (P Q : Fin 3 → R) : R :=
W'.negY ![W'.addX P Q, W'.negAddY P Q, addZ P Q]
lemma addY_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addY P P = 0 := by
erw [addY, addX_self hP, negAddY_self, addZ_self, negY_of_Z_eq_zero rfl, neg_zero]
lemma addY_smul (P Q : Fin 3 → R) (u v : R) :
W'.addY (u • P) (v • Q) = ((u * v) ^ 2) ^ 3 * W'.addY P Q := by
simp only [addY, negY, addX_smul, negAddY_smul, addZ_smul, fin3_def_ext]
ring1
lemma addY_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.addY P Q = (P x * Q z) ^ 3 * Q y := by
simp only [addY, addX_of_Z_eq_zero_left hPz, negAddY_of_Z_eq_zero_left hP hPz,
addZ_of_Z_eq_zero_left hPz, negY, fin3_def_ext]
ring1
lemma addY_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.addY P Q = (-(Q x * P z)) ^ 3 * P y := by
simp only [addY, addX_of_Z_eq_zero_right hQz, negAddY_of_Z_eq_zero_right hQ hQz,
addZ_of_Z_eq_zero_right hQz, negY, fin3_def_ext]
ring1
lemma addY_of_X_eq' {P Q : Fin 3 → R} (hP : W'.Equation P) (hQ : W'.Equation Q)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W'.addY P Q * (P z * Q z) ^ 3 = (-(P y * Q z ^ 3 - Q y * P z ^ 3)) ^ 3 := by
erw [addY, negY, addZ_of_X_eq hx, mul_zero, sub_zero, zero_pow three_ne_zero, mul_zero, sub_zero,
neg_mul, negAddY_of_X_eq' hP hQ hx, Odd.neg_pow <| by decide]
lemma addY_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) : W.addY P Q = addU P Q ^ 3 := by
rw [addU, ← neg_div, div_pow, ← addY_of_X_eq' hP hQ hx,
mul_div_cancel_right₀ _ <| pow_ne_zero 3 <| mul_ne_zero hPz hQz]
lemma addY_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.addY P Q / addZ P Q ^ 3 = W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)) := by
erw [addY, negY_of_Z_ne_zero <| addZ_ne_zero_of_X_ne hx, addX_of_Z_ne_zero hP hQ hPz hQz hx,
negAddY_of_Z_ne_zero hP hQ hPz hQz hx, Affine.addY]
variable (W') in
/-- The coordinates of the addition of two distinct point representatives. -/
noncomputable def addXYZ (P Q : Fin 3 → R) : Fin 3 → R :=
![W'.addX P Q, W'.addY P Q, addZ P Q]
lemma addXYZ_self {P : Fin 3 → R} (hP : W'.Equation P) : W'.addXYZ P P = ![0, 0, 0] := by
rw [addXYZ, addX_self hP, addY_self hP, addZ_self]
lemma addXYZ_smul (P Q : Fin 3 → R) (u v : R) :
W'.addXYZ (u • P) (v • Q) = (u * v) ^ 2 • W'.addXYZ P Q := by
rw [addXYZ, addX_smul, addY_smul, addZ_smul]
rfl
lemma addXYZ_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) :
W'.addXYZ P Q = (P x * Q z) • Q := by
rw [addXYZ, addX_of_Z_eq_zero_left hPz, addY_of_Z_eq_zero_left hP hPz, addZ_of_Z_eq_zero_left hPz,
smul_fin3]
lemma addXYZ_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hQz : Q z = 0) :
W'.addXYZ P Q = -(Q x * P z) • P := by
rw [addXYZ, addX_of_Z_eq_zero_right hQz, addY_of_Z_eq_zero_right hQ hQz,
addZ_of_Z_eq_zero_right hQz, smul_fin3]
lemma addXYZ_of_X_eq {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) :
W.addXYZ P Q = addU P Q • ![1, 1, 0] := by
erw [addXYZ, addX_of_X_eq hP hQ hPz hQz hx, addY_of_X_eq hP hQ hPz hQz hx, addZ_of_X_eq hx,
smul_fin3, mul_one, mul_one, mul_zero]
lemma addXYZ_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.addXYZ P Q = addZ P Q •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
have hZ {n : ℕ} : IsUnit <| addZ P Q ^ n := (isUnit_addZ_of_X_ne hx).pow n
erw [addXYZ, smul_fin3, ← addX_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel,
← addY_of_Z_ne_zero hP hQ hPz hQz hx, hZ.mul_div_cancel, mul_one]
end Addition
section Negation
/-! ### Negation on point representatives -/
variable (W') in
/-- The negation of a point representative. -/
def neg (P : Fin 3 → R) : Fin 3 → R :=
![P x, W'.negY P, P z]
lemma neg_smul (P : Fin 3 → R) (u : R) : W'.neg (u • P) = u • W'.neg P := by
rw [neg, negY_smul]
rfl
lemma neg_smul_equiv (P : Fin 3 → R) {u : R} (hu : IsUnit u) : W'.neg (u • P) ≈ W'.neg P :=
⟨hu.unit, (neg_smul ..).symm⟩
lemma neg_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.neg P ≈ W'.neg Q := by
rcases h with ⟨u, rfl⟩
exact neg_smul_equiv Q u.isUnit
lemma neg_of_Z_eq_zero' {P : Fin 3 → R} (hPz : P z = 0) : W'.neg P = ![P x, -P y, 0] := by
rw [neg, negY_of_Z_eq_zero hPz, hPz]
lemma neg_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
W.neg P = -(P y / P x) • ![1, 1, 0] := by
have hX {n : ℕ} : IsUnit <| P x ^ n := (isUnit_X_of_Z_eq_zero hP hPz).pow n
erw [neg_of_Z_eq_zero' hPz, smul_fin3, neg_sq, div_pow, (equation_of_Z_eq_zero hPz).mp hP.left,
pow_succ, hX.mul_div_cancel_left, mul_one, Odd.neg_pow <| by decide, div_pow, pow_succ,
(equation_of_Z_eq_zero hPz).mp hP.left, hX.mul_div_cancel_left, mul_one, mul_zero]
lemma neg_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.neg P = P z • ![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1] := by
erw [neg, smul_fin3, mul_div_cancel₀ _ <| pow_ne_zero 2 hPz, ← negY_of_Z_ne_zero hPz,
mul_div_cancel₀ _ <| pow_ne_zero 3 hPz, mul_one]
private lemma nonsingular_neg_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
W.Nonsingular ![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1] := by
exact (nonsingular_some ..).mpr <| Affine.nonsingular_neg <| (nonsingular_of_Z_ne_zero hPz).mp hP
lemma nonsingular_neg {P : Fin 3 → F} (hP : W.Nonsingular P) : W.Nonsingular <| W.neg P := by
by_cases hPz : P z = 0
· simp only [neg_of_Z_eq_zero hP hPz, nonsingular_smul _
((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg, nonsingular_zero]
· simp only [neg_of_Z_ne_zero hPz, nonsingular_smul _ <| Ne.isUnit hPz,
nonsingular_neg_of_Z_ne_zero hP hPz]
lemma addZ_neg {P : Fin 3 → R} : addZ P (W'.neg P) = 0 := addZ_of_X_eq rfl
lemma addX_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.addX P (W'.neg P) = W'.dblZ P ^ 2 := by
simp only [addX, neg, dblZ, negY, fin3_def_ext]
linear_combination -2 * P z ^ 2 * (equation_iff _).mp hP
lemma negAddY_neg {P : Fin 3 → R} (hP : W'.Equation P) :
W'.negAddY P (W'.neg P) = W'.dblZ P ^ 3 := by
simp only [negAddY, neg, dblZ, negY, fin3_def_ext]
linear_combination -2 * (2 * P y * P z ^ 3 + W'.a₁ * P x * P z ^ 4 + W'.a₃ * P z ^ 6)
* (equation_iff _).mp hP
lemma addY_neg {P : Fin 3 → R} (hP : W'.Equation P) : W'.addY P (W'.neg P) = -W'.dblZ P ^ 3 := by
rw [addY, addX_neg hP, negAddY_neg hP, negY_of_Z_eq_zero addZ_neg]; rfl
lemma addXYZ_neg {P : Fin 3 → R} (hP : W'.Equation P) :
W'.addXYZ P (W'.neg P) = -W'.dblZ P • ![1, 1, 0] := by
erw [addXYZ, addX_neg hP, addY_neg hP, addZ_neg, smul_fin3, neg_sq, mul_one,
Odd.neg_pow <| by decide, mul_one, mul_zero]
variable (W') in
/-- The negation of a point class. If `P` is a point representative,
then `W'.negMap ⟦P⟧` is definitionally equivalent to `W'.neg P`. -/
def negMap (P : PointClass R) : PointClass R :=
P.map W'.neg fun _ _ => neg_equiv
lemma negMap_eq {P : Fin 3 → R} : W'.negMap ⟦P⟧ = ⟦W'.neg P⟧ :=
rfl
lemma negMap_of_Z_eq_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z = 0) :
W.negMap ⟦P⟧ = ⟦![1, 1, 0]⟧ := by
rw [negMap_eq, neg_of_Z_eq_zero hP hPz,
smul_eq _ ((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg]
lemma negMap_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.negMap ⟦P⟧ = ⟦![P x / P z ^ 2, W.toAffine.negY (P x / P z ^ 2) (P y / P z ^ 3), 1]⟧ := by
rw [negMap_eq, neg_of_Z_ne_zero hPz, smul_eq _ <| Ne.isUnit hPz]
lemma nonsingularLift_negMap {P : PointClass F} (hP : W.NonsingularLift P) :
W.NonsingularLift <| W.negMap P := by
rcases P with ⟨_⟩
exact nonsingular_neg hP
end Negation
section Addition
/-! ### Addition on point representatives -/
open Classical in
variable (W') in
/-- The addition of two point representatives. -/
noncomputable def add (P Q : Fin 3 → R) : Fin 3 → R :=
if P ≈ Q then W'.dblXYZ P else W'.addXYZ P Q
lemma add_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W'.add P Q = W'.dblXYZ P :=
if_pos h
lemma add_smul_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) = u ^ 4 • W'.add P Q := by
have smul : P ≈ Q ↔ u • P ≈ v • Q := by
erw [← Quotient.eq, ← Quotient.eq, smul_eq P hu, smul_eq Q hv]
rfl
rw [add_of_equiv <| smul.mp h, dblXYZ_smul, add_of_equiv h]
lemma add_self (P : Fin 3 → R) : W'.add P P = W'.dblXYZ P :=
add_of_equiv <| Setoid.refl _
lemma add_of_eq {P Q : Fin 3 → R} (h : P = Q) : W'.add P Q = W'.dblXYZ P :=
h ▸ add_self P
lemma add_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) : W'.add P Q = W'.addXYZ P Q :=
if_neg h
lemma add_smul_of_not_equiv {P Q : Fin 3 → R} (h : ¬P ≈ Q) {u v : R} (hu : IsUnit u)
(hv : IsUnit v) : W'.add (u • P) (v • Q) = (u * v) ^ 2 • W'.add P Q := by
have smul : P ≈ Q ↔ u • P ≈ v • Q := by
erw [← Quotient.eq, ← Quotient.eq, smul_eq P hu, smul_eq Q hv]
rfl
rw [add_of_not_equiv <| h.comp smul.mpr, addXYZ_smul, add_of_not_equiv h]
lemma add_smul_equiv (P Q : Fin 3 → R) {u v : R} (hu : IsUnit u) (hv : IsUnit v) :
W'.add (u • P) (v • Q) ≈ W'.add P Q := by
by_cases h : P ≈ Q
· exact ⟨hu.unit ^ 4, by convert (add_smul_of_equiv h hu hv).symm⟩
· exact ⟨(hu.unit * hv.unit) ^ 2, by convert (add_smul_of_not_equiv h hu hv).symm⟩
lemma add_equiv {P P' Q Q' : Fin 3 → R} (hP : P ≈ P') (hQ : Q ≈ Q') :
W'.add P Q ≈ W'.add P' Q' := by
rcases hP, hQ with ⟨⟨u, rfl⟩, ⟨v, rfl⟩⟩
exact add_smul_equiv P' Q' u.isUnit v.isUnit
lemma add_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : W.add P Q = P x ^ 2 • ![1, 1, 0] := by
rw [add, if_pos <| equiv_of_Z_eq_zero hP hQ hPz hQz, dblXYZ_of_Z_eq_zero hP.left hPz]
lemma add_of_Z_eq_zero_left {P Q : Fin 3 → R} (hP : W'.Equation P) (hPz : P z = 0) (hQz : Q z ≠ 0) :
W'.add P Q = (P x * Q z) • Q := by
rw [add, if_neg <| not_equiv_of_Z_eq_zero_left hPz hQz, addXYZ_of_Z_eq_zero_left hP hPz]
lemma add_of_Z_eq_zero_right {P Q : Fin 3 → R} (hQ : W'.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z = 0) : W'.add P Q = -(Q x * P z) • P := by
rw [add, if_neg <| not_equiv_of_Z_eq_zero_right hPz hQz, addXYZ_of_Z_eq_zero_right hQ hQz]
lemma add_of_Y_eq {P Q : Fin 3 → F} (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 = Q y * P z ^ 3)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.add P Q = W.dblU P • ![1, 1, 0] := by
rw [add, if_pos <| equiv_of_X_eq_of_Y_eq hPz hQz hx hy, dblXYZ_of_Y_eq hQz hx hy hy']
lemma add_of_Y_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ Q y * P z ^ 3) :
W.add P Q = addU P Q • ![1, 1, 0] := by
rw [add, if_neg <| not_equiv_of_Y_ne hy, addXYZ_of_X_eq hP hQ hPz hQz hx]
lemma add_of_Y_ne' {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2) (hy : P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.add P Q = W.dblZ P •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
rw [add, if_pos <| equiv_of_X_eq_of_Y_eq hPz hQz hx <| Y_eq_of_Y_ne' hP hQ hx hy,
dblXYZ_of_Z_ne_zero hP hQ hPz hQz hx hy]
lemma add_of_X_ne {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 ≠ Q x * P z ^ 2) :
W.add P Q = addZ P Q •
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] := by
rw [add, if_neg <| not_equiv_of_X_ne hx, addXYZ_of_Z_ne_zero hP hQ hPz hQz hx]
private lemma nonsingular_add_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : P x * Q z ^ 2 = Q x * P z ^ 2 → P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) : W.Nonsingular
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)), 1] :=
(nonsingular_some ..).mpr <| Affine.nonsingular_add ((nonsingular_of_Z_ne_zero hPz).mp hP)
((nonsingular_of_Z_ne_zero hQz).mp hQ) (by rwa [← X_eq_iff hPz hQz, ne_eq, ← Y_eq_iff' hPz hQz])
lemma nonsingular_add {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
W.Nonsingular <| W.add P Q := by
by_cases hPz : P z = 0
· by_cases hQz : Q z = 0
· simp only [add_of_Z_eq_zero hP hQ hPz hQz,
nonsingular_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, nonsingular_zero]
· simpa only [add_of_Z_eq_zero_left hP.left hPz hQz,
nonsingular_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· simpa only [add_of_Z_eq_zero_right hQ.left hPz hQz,
nonsingular_smul _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg]
· by_cases hxy : P x * Q z ^ 2 = Q x * P z ^ 2 → P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3
· by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· simp only [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| hxy hx,
nonsingular_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hx <| hxy hx,
nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy]
· simp only [add_of_X_ne hP.left hQ.left hPz hQz hx,
nonsingular_smul _ <| isUnit_addZ_of_X_ne hx,
nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy]
· rw [_root_.not_imp, not_ne_iff] at hxy
by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· simp only [add_of_Y_eq hPz hQz hxy.left hy hxy.right, nonsingular_smul _ <|
isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, nonsingular_zero]
· simp only [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
nonsingular_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, nonsingular_zero]
variable (W') in
/-- The addition of two point classes. If `P` is a point representative,
then `W.addMap ⟦P⟧ ⟦Q⟧` is definitionally equivalent to `W.add P Q`. -/
noncomputable def addMap (P Q : PointClass R) : PointClass R :=
Quotient.map₂ W'.add (fun _ _ hP _ _ hQ => add_equiv hP hQ) P Q
lemma addMap_eq (P Q : Fin 3 → R) : W'.addMap ⟦P⟧ ⟦Q⟧ = ⟦W'.add P Q⟧ :=
rfl
lemma addMap_of_Z_eq_zero_left {P : Fin 3 → F} {Q : PointClass F} (hP : W.Nonsingular P)
(hQ : W.NonsingularLift Q) (hPz : P z = 0) : W.addMap ⟦P⟧ Q = Q := by
rcases Q with ⟨Q⟩
by_cases hQz : Q z = 0
· erw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hQ hQz
· erw [addMap_eq, add_of_Z_eq_zero_left hP.left hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
rfl
lemma addMap_of_Z_eq_zero_right {P : PointClass F} {Q : Fin 3 → F} (hP : W.NonsingularLift P)
(hQ : W.Nonsingular Q) (hQz : Q z = 0) : W.addMap P ⟦Q⟧ = P := by
rcases P with ⟨P⟩
by_cases hPz : P z = 0
· erw [addMap_eq, add_of_Z_eq_zero hP hQ hPz hQz,
smul_eq _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2, Quotient.eq]
exact Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· erw [addMap_eq, add_of_Z_eq_zero_right hQ.left hPz hQz,
smul_eq _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg]
rfl
lemma addMap_of_Y_eq {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hx : P x * Q z ^ 2 = Q x * P z ^ 2)
(hy' : P y * Q z ^ 3 = W.negY Q * P z ^ 3) : W.addMap ⟦P⟧ ⟦Q⟧ = ⟦![1, 1, 0]⟧ := by
by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· rw [addMap_eq, add_of_Y_eq hPz hQz hx hy hy',
smul_eq _ <| isUnit_dblU_of_Y_eq hP hPz hQz hx hy hy']
· rw [addMap_eq, add_of_Y_ne hP.left hQ hPz hQz hx hy,
smul_eq _ <| isUnit_addU_of_Y_ne hPz hQz hy]
lemma addMap_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Equation P) (hQ : W.Equation Q) (hPz : P z ≠ 0)
(hQz : Q z ≠ 0) (hxy : P x * Q z ^ 2 = Q x * P z ^ 2 → P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
W.addMap ⟦P⟧ ⟦Q⟧ =
⟦![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1]⟧ := by
by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· rw [addMap_eq, add_of_Y_ne' hP hQ hPz hQz hx <| hxy hx,
smul_eq _ <| isUnit_dblZ_of_Y_ne' hP hQ hPz hx <| hxy hx]
· rw [addMap_eq, add_of_X_ne hP hQ hPz hQz hx, smul_eq _ <| isUnit_addZ_of_X_ne hx]
lemma nonsingularLift_addMap {P Q : PointClass F} (hP : W.NonsingularLift P)
(hQ : W.NonsingularLift Q) : W.NonsingularLift <| W.addMap P Q := by
rcases P; rcases Q
exact nonsingular_add hP hQ
end Addition
/-! ### Nonsingular rational points -/
variable (W') in
/-- A nonsingular rational point on `W'`. -/
@[ext]
structure Point where
/-- The point class underlying a nonsingular rational point on `W'`. -/
{point : PointClass R}
/-- The nonsingular condition underlying a nonsingular rational point on `W'`. -/
(nonsingular : W'.NonsingularLift point)
namespace Point
lemma mk_point {P : PointClass R} (h : W'.NonsingularLift P) : (mk h).point = P :=
rfl
instance instZeroPoint [Nontrivial R] : Zero W'.Point :=
⟨⟨nonsingularLift_zero⟩⟩
lemma zero_def [Nontrivial R] : (0 : W'.Point) = ⟨nonsingularLift_zero⟩ :=
rfl
lemma zero_point [Nontrivial R] : (0 : W'.Point).point = ⟦![1, 1, 0]⟧ :=
rfl
/-- The map from a nonsingular rational point on a Weierstrass curve `W'` in affine coordinates
to the corresponding nonsingular rational point on `W'` in Jacobian coordinates. -/
def fromAffine [Nontrivial R] : W'.toAffine.Point → W'.Point
| 0 => 0
| .some h => ⟨(nonsingularLift_some ..).mpr h⟩
lemma fromAffine_zero [Nontrivial R] : fromAffine 0 = (0 : W'.Point) :=
rfl
lemma fromAffine_some [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) = ⟨(nonsingularLift_some ..).mpr h⟩ :=
rfl
lemma fromAffine_ne_zero [Nontrivial R] {X Y : R} (h : W'.toAffine.Nonsingular X Y) :
fromAffine (.some h) ≠ 0 := fun h0 ↦ by
obtain ⟨u, eq⟩ := Quotient.eq.mp <| (Point.ext_iff ..).mp h0
simpa [Units.smul_def, smul_fin3] using congr_fun eq z
/-- The negation of a nonsingular rational point on `W`.
Given a nonsingular rational point `P` on `W`, use `-P` instead of `neg P`. -/
def neg (P : W.Point) : W.Point :=
⟨nonsingularLift_negMap P.nonsingular⟩
instance instNegPoint : Neg W.Point :=
⟨neg⟩
lemma neg_def (P : W.Point) : -P = P.neg :=
rfl
lemma neg_point (P : W.Point) : (-P).point = W.negMap P.point :=
rfl
/-- The addition of two nonsingular rational points on `W`.
Given two nonsingular rational points `P` and `Q` on `W`, use `P + Q` instead of `add P Q`. -/
noncomputable def add (P Q : W.Point) : W.Point :=
⟨nonsingularLift_addMap P.nonsingular Q.nonsingular⟩
noncomputable instance instAddPoint : Add W.Point :=
⟨add⟩
lemma add_def (P Q : W.Point) : P + Q = P.add Q :=
rfl
lemma add_point (P Q : W.Point) : (P + Q).point = W.addMap P.point Q.point :=
rfl
end Point
section Affine
/-! ### Equivalence with affine coordinates -/
namespace Point
open Classical in
variable (W) in
/-- The map from a point representative that is nonsingular on a Weierstrass curve `W` in Jacobian
coordinates to the corresponding nonsingular rational point on `W` in affine coordinates. -/
noncomputable def toAffine (P : Fin 3 → F) : W.toAffine.Point :=
if hP : W.Nonsingular P ∧ P z ≠ 0 then .some <| (nonsingular_of_Z_ne_zero hP.2).mp hP.1 else 0
lemma toAffine_of_singular {P : Fin 3 → F} (hP : ¬W.Nonsingular P) : toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_of_not_left _ hP]
lemma toAffine_of_Z_eq_zero {P : Fin 3 → F} (hPz : P z = 0) :
toAffine W P = 0 := by
rw [toAffine, dif_neg <| not_and_not_right.mpr fun _ => hPz]
lemma toAffine_zero : toAffine W ![1, 1, 0] = 0 :=
toAffine_of_Z_eq_zero rfl
lemma toAffine_of_Z_ne_zero {P : Fin 3 → F} (hP : W.Nonsingular P) (hPz : P z ≠ 0) :
toAffine W P = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) := by
rw [toAffine, dif_pos ⟨hP, hPz⟩]
lemma toAffine_some {X Y : F} (h : W.Nonsingular ![X, Y, 1]) :
toAffine W ![X, Y, 1] = .some ((nonsingular_some ..).mp h) := by
simp only [toAffine_of_Z_ne_zero h one_ne_zero, fin3_def_ext, one_pow, div_one]
lemma toAffine_smul (P : Fin 3 → F) {u : F} (hu : IsUnit u) :
toAffine W (u • P) = toAffine W P := by
by_cases hP : W.Nonsingular P
· by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero <| mul_eq_zero_of_right u hPz, toAffine_of_Z_eq_zero hPz]
· rw [toAffine_of_Z_ne_zero ((nonsingular_smul P hu).mpr hP) <| mul_ne_zero hu.ne_zero hPz,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.some.injEq]
simp only [smul_fin3_ext, mul_pow, mul_div_mul_left _ _ (hu.pow _).ne_zero, and_self]
· rw [toAffine_of_singular <| hP.comp (nonsingular_smul P hu).mp, toAffine_of_singular hP]
lemma toAffine_of_equiv {P Q : Fin 3 → F} (h : P ≈ Q) : toAffine W P = toAffine W Q := by
rcases h with ⟨u, rfl⟩
exact toAffine_smul Q u.isUnit
lemma toAffine_neg {P : Fin 3 → F} (hP : W.Nonsingular P) :
toAffine W (W.neg P) = -toAffine W P := by
by_cases hPz : P z = 0
· rw [neg_of_Z_eq_zero hP hPz,
toAffine_smul _ ((isUnit_Y_of_Z_eq_zero hP hPz).div <| isUnit_X_of_Z_eq_zero hP hPz).neg,
toAffine_zero, toAffine_of_Z_eq_zero hPz, Affine.Point.neg_zero]
· rw [neg_of_Z_ne_zero hPz, toAffine_smul _ <| Ne.isUnit hPz, toAffine_some <|
(nonsingular_smul _ <| Ne.isUnit hPz).mp <| neg_of_Z_ne_zero hPz ▸ nonsingular_neg hP,
toAffine_of_Z_ne_zero hP hPz, Affine.Point.neg_some]
private lemma toAffine_add_of_Z_ne_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P)
(hQ : W.Nonsingular Q) (hPz : P z ≠ 0) (hQz : Q z ≠ 0)
(hxy : P x * Q z ^ 2 = Q x * P z ^ 2 → P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3) :
toAffine W
![W.toAffine.addX (P x / P z ^ 2) (Q x / Q z ^ 2)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
W.toAffine.addY (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3)
(W.toAffine.slope (P x / P z ^ 2) (Q x / Q z ^ 2) (P y / P z ^ 3) (Q y / Q z ^ 3)),
1] = toAffine W P + toAffine W Q := by
rw [toAffine_some <| nonsingular_add_of_Z_ne_zero hP hQ hPz hQz hxy, toAffine_of_Z_ne_zero hP hPz,
toAffine_of_Z_ne_zero hQ hQz,
Affine.Point.add_of_imp <| by rwa [← X_eq_iff hPz hQz, ne_eq, ← Y_eq_iff' hPz hQz]]
lemma toAffine_add {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q) :
toAffine W (W.add P Q) = toAffine W P + toAffine W Q := by
by_cases hPz : P z = 0
· rw [toAffine_of_Z_eq_zero hPz, zero_add]
by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero hP hQ hPz hQz, toAffine_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).pow 2,
toAffine_zero, toAffine_of_Z_eq_zero hQz]
· rw [add_of_Z_eq_zero_left hP.left hPz hQz,
toAffine_smul _ <| (isUnit_X_of_Z_eq_zero hP hPz).mul <| Ne.isUnit hQz]
· by_cases hQz : Q z = 0
· rw [add_of_Z_eq_zero_right hQ.left hPz hQz,
toAffine_smul _ ((isUnit_X_of_Z_eq_zero hQ hQz).mul <| Ne.isUnit hPz).neg,
toAffine_of_Z_eq_zero hQz, add_zero]
· by_cases hxy : P x * Q z ^ 2 = Q x * P z ^ 2 → P y * Q z ^ 3 ≠ W.negY Q * P z ^ 3
· by_cases hx : P x * Q z ^ 2 = Q x * P z ^ 2
· rw [add_of_Y_ne' hP.left hQ.left hPz hQz hx <| hxy hx,
toAffine_smul _ <| isUnit_dblZ_of_Y_ne' hP.left hQ.left hPz hx <| hxy hx,
toAffine_add_of_Z_ne_zero hP hQ hPz hQz hxy]
· rw [add_of_X_ne hP.left hQ.left hPz hQz hx, toAffine_smul _ <| isUnit_addZ_of_X_ne hx,
toAffine_add_of_Z_ne_zero hP hQ hPz hQz hxy]
· rw [_root_.not_imp, not_ne_iff] at hxy
rw [toAffine_of_Z_ne_zero hP hPz, toAffine_of_Z_ne_zero hQ hQz, Affine.Point.add_of_Y_eq
((X_eq_iff hPz hQz).mp hxy.left) ((Y_eq_iff' hPz hQz).mp hxy.right)]
by_cases hy : P y * Q z ^ 3 = Q y * P z ^ 3
· rw [add_of_Y_eq hPz hQz hxy.left hy hxy.right,
toAffine_smul _ <| isUnit_dblU_of_Y_eq hP hPz hQz hxy.left hy hxy.right, toAffine_zero]
· rw [add_of_Y_ne hP.left hQ.left hPz hQz hxy.left hy,
toAffine_smul _ <| isUnit_addU_of_Y_ne hPz hQz hy, toAffine_zero]
/-- The map from a nonsingular rational point on a Weierstrass curve `W` in Jacobian coordinates
to the corresponding nonsingular rational point on `W` in affine coordinates. -/
noncomputable def toAffineLift (P : W.Point) : W.toAffine.Point :=
P.point.lift _ fun _ _ => toAffine_of_equiv
lemma toAffineLift_eq {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) :
toAffineLift ⟨hP⟩ = toAffine W P :=
rfl
lemma toAffineLift_of_Z_eq_zero {P : Fin 3 → F} (hP : W.NonsingularLift ⟦P⟧) (hPz : P z = 0) :
toAffineLift ⟨hP⟩ = 0 :=
toAffine_of_Z_eq_zero hPz
lemma toAffineLift_zero : toAffineLift (0 : W.Point) = 0 :=
toAffine_zero
lemma toAffineLift_of_Z_ne_zero {P : Fin 3 → F} {hP : W.NonsingularLift ⟦P⟧} (hPz : P z ≠ 0) :
toAffineLift ⟨hP⟩ = .some ((nonsingular_of_Z_ne_zero hPz).mp hP) :=
toAffine_of_Z_ne_zero hP hPz
lemma toAffineLift_some {X Y : F} (h : W.NonsingularLift ⟦![X, Y, 1]⟧) :
toAffineLift ⟨h⟩ = .some ((nonsingular_some ..).mp h) :=
toAffine_some h
lemma toAffineLift_neg (P : W.Point) : (-P).toAffineLift = -P.toAffineLift := by
rcases P with @⟨⟨_⟩, hP⟩
exact toAffine_neg hP
lemma toAffineLift_add (P Q : W.Point) :
(P + Q).toAffineLift = P.toAffineLift + Q.toAffineLift := by
rcases P, Q with ⟨@⟨⟨_⟩, hP⟩, @⟨⟨_⟩, hQ⟩⟩
exact toAffine_add hP hQ
variable (W) in
/-- The equivalence between the nonsingular rational points on a Weierstrass curve `W` in Jacobian
coordinates with the nonsingular rational points on `W` in affine coordinates. -/
@[simps]
noncomputable def toAffineAddEquiv : W.Point ≃+ W.toAffine.Point where
toFun := toAffineLift
invFun := fromAffine
left_inv := by
rintro @⟨⟨P⟩, hP⟩
by_cases hPz : P z = 0
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_eq_zero hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_zero_of_Z_eq_zero hP hPz
· rw [Point.ext_iff, toAffineLift_eq, toAffine_of_Z_ne_zero hP hPz]
exact Quotient.eq.mpr <| Setoid.symm <| equiv_some_of_Z_ne_zero hPz
right_inv := by
rintro (_ | _)
· erw [fromAffine_zero, toAffineLift_zero, Affine.Point.zero_def]
· rw [fromAffine_some, toAffineLift_some]
map_add' := toAffineLift_add
end Point
end Affine
section Map
variable {S : Type*} [CommRing S] (f : R →+* S) (P Q : Fin 3 → R)
protected lemma map_smul (u : R) : f ∘ (u • P) = f u • (f ∘ P) := by
ext i; fin_cases i <;> simp [smul_fin3]
@[simp] lemma map_addZ : addZ (f ∘ P) (f ∘ Q) = f (addZ P Q) := by simp [addZ]
@[simp] lemma map_addX : addX (W'.map f) (f ∘ P) (f ∘ Q) = f (W'.addX P Q) := by simp [addX]
@[simp] lemma map_negAddY : negAddY (W'.map f) (f ∘ P) (f ∘ Q) = f (W'.negAddY P Q) := by
simp [negAddY]
@[simp] lemma map_negY : negY (W'.map f) (f ∘ P) = f (W'.negY P) := by simp [negY]
@[simp] protected lemma map_neg : neg (W'.map f) (f ∘ P) = f ∘ W'.neg P := by
ext i; fin_cases i <;> simp [neg]
@[simp] lemma map_addY : addY (W'.map f) (f ∘ P) (f ∘ Q) = f (W'.addY P Q) := by
simp [addY, ← comp_fin3]
@[simp] lemma map_addXYZ : addXYZ (W'.map f) (f ∘ P) (f ∘ Q) = f ∘ addXYZ W' P Q := by
simp_rw [addXYZ, comp_fin3, map_addX, map_addY, map_addZ]
lemma map_polynomial : (W'.map f).toJacobian.polynomial = MvPolynomial.map f W'.polynomial := by
simp [polynomial]
lemma map_polynomialX : (W'.map f).toJacobian.polynomialX = MvPolynomial.map f W'.polynomialX := by
simp [polynomialX, map_polynomial, pderiv_map]
lemma map_polynomialY : (W'.map f).toJacobian.polynomialY = MvPolynomial.map f W'.polynomialY := by
simp [polynomialY, map_polynomial, pderiv_map]
lemma map_polynomialZ : (W'.map f).toJacobian.polynomialZ = MvPolynomial.map f W'.polynomialZ := by
simp [polynomialZ, map_polynomial, pderiv_map]
@[simp] lemma map_dblZ : dblZ (W'.map f) (f ∘ P) = f (W'.dblZ P) := by simp [dblZ]
@[simp] lemma map_dblU : dblU (W'.map f) (f ∘ P) = f (W'.dblU P) := by
simp [dblU, map_polynomialX, ← eval₂_id, eval₂_comp_left]
@[simp] lemma map_dblX : dblX (W'.map f) (f ∘ P) = f (W'.dblX P) := by simp [dblX]
@[simp] lemma map_negDblY : negDblY (W'.map f) (f ∘ P) = f (W'.negDblY P) := by simp [negDblY]
@[simp] lemma map_dblY : dblY (W'.map f) (f ∘ P) = f (W'.dblY P) := by simp [dblY, ← comp_fin3]
@[simp] lemma map_dblXYZ : dblXYZ (W'.map f) (f ∘ P) = f ∘ dblXYZ W' P := by
simp_rw [dblXYZ, comp_fin3, map_dblX, map_dblY, map_dblZ]
end Map
end WeierstrassCurve.Jacobian
/-- An abbreviation for `WeierstrassCurve.Jacobian.Point.fromAffine` for dot notation. -/
abbrev WeierstrassCurve.Affine.Point.toJacobian {R : Type u} [CommRing R]
[Nontrivial R] {W : Affine R} (P : W.Point) : W.toJacobian.Point :=
Jacobian.Point.fromAffine P
|
AlgebraicGeometry\EllipticCurve\Projective.lean | /-
Copyright (c) 2023 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.AlgebraicGeometry.EllipticCurve.Affine
import Mathlib.Algebra.MvPolynomial.CommRing
import Mathlib.Algebra.MvPolynomial.PDeriv
/-!
# Projective coordinates for Weierstrass curves
This file defines the type of points on a Weierstrass curve as a tuple, consisting of an equivalence
class of triples up to scaling by a unit, satisfying a Weierstrass equation with a nonsingular
condition.
## Mathematical background
Let `W` be a Weierstrass curve over a field `F`. A point on the projective plane is an equivalence
class of triples $[x:y:z]$ with coordinates in `F` such that $(x, y, z) \sim (x', y', z')$ precisely
if there is some unit $u$ of `F` such that $(x, y, z) = (ux', uy', uz')$, with an extra condition
that $(x, y, z) \ne (0, 0, 0)$. As described in `Mathlib.AlgebraicGeometry.EllipticCurve.Affine`, a
rational point is a point on the projective plane satisfying a homogeneous Weierstrass equation, and
being nonsingular means the partial derivatives $W_X(X, Y, Z)$, $W_Y(X, Y, Z)$, and $W_Z(X, Y, Z)$
do not vanish simultaneously. Note that the vanishing of the Weierstrass equation and its partial
derivatives are independent of the representative for $[x:y:z]$, and the nonsingularity condition
already implies that $(x, y, z) \ne (0, 0, 0)$, so a nonsingular rational point on `W` can simply be
given by a tuple consisting of $[x:y:z]$ and the nonsingular condition on any representative.
## Main definitions
* `WeierstrassCurve.Projective.PointClass`: the equivalence class of a point representative.
* `WeierstrassCurve.Projective.toAffine`: the Weierstrass curve in affine coordinates.
* `WeierstrassCurve.Projective.Nonsingular`: the nonsingular condition on a point representative.
* `WeierstrassCurve.Projective.NonsingularLift`: the nonsingular condition on a point class.
## Main statements
* `WeierstrassCurve.Projective.polynomial_relation`: Euler's homogeneous function theorem.
## Implementation notes
A point representative is implemented as a term `P` of type `Fin 3 → R`, which allows for the vector
notation `![x, y, z]`. However, `P` is not definitionally equivalent to the expanded vector
`![P x, P y, P z]`, so the auxiliary lemma `fin3_def` can be used to convert between the two forms.
The equivalence of two point representatives `P` and `Q` is implemented as an equivalence of orbits
of the action of `Rˣ`, or equivalently that there is some unit `u` of `R` such that `P = u • Q`.
However, `u • Q` is again not definitionally equal to `![u * Q x, u * Q y, u * Q z]`, so the
auxiliary lemmas `smul_fin3` and `smul_fin3_ext` can be used to convert between the two forms.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, rational point, projective coordinates
-/
local notation "x" => 0
local notation "y" => 1
local notation "z" => 2
local macro "matrix_simp" : tactic =>
`(tactic| simp only [Matrix.head_cons, Matrix.tail_cons, Matrix.smul_empty, Matrix.smul_cons,
Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two])
universe u
/-! ## Weierstrass curves -/
/-- An abbreviation for a Weierstrass curve in projective coordinates. -/
abbrev WeierstrassCurve.Projective :=
WeierstrassCurve
namespace WeierstrassCurve.Projective
open MvPolynomial
local macro "eval_simp" : tactic =>
`(tactic| simp only [eval_C, eval_X, eval_add, eval_sub, eval_mul, eval_pow])
local macro "pderiv_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, pderiv_mul, pderiv_pow,
pderiv_C, pderiv_X_self, pderiv_X_of_ne one_ne_zero, pderiv_X_of_ne one_ne_zero.symm,
pderiv_X_of_ne (by decide : (2 : Fin 3) ≠ 0), pderiv_X_of_ne (by decide : (0 : Fin 3) ≠ 2),
pderiv_X_of_ne (by decide : (2 : Fin 3) ≠ 1), pderiv_X_of_ne (by decide : (1 : Fin 3) ≠ 2)])
variable {R : Type u} [CommRing R] (W : Projective R)
lemma fin3_def {R : Type u} (P : Fin 3 → R) : P = ![P x, P y, P z] := by
ext n; fin_cases n <;> rfl
lemma smul_fin3 {R : Type u} [CommRing R] (P : Fin 3 → R) (u : Rˣ) :
u • P = ![u * P x, u * P y, u * P z] := by
rw [fin3_def P]
matrix_simp
simp only [Units.smul_def, smul_eq_mul]
lemma smul_fin3_ext {R : Type u} [CommRing R] (P : Fin 3 → R) (u : Rˣ) :
(u • P) x = u * P x ∧ (u • P) y = u * P y ∧ (u • P) z = u * P z := by
refine ⟨?_, ?_, ?_⟩ <;> simp only [Units.smul_def, Pi.smul_apply, smul_eq_mul]
/-- The equivalence setoid for a point representative. -/
scoped instance instSetoidPoint : Setoid <| Fin 3 → R :=
MulAction.orbitRel Rˣ <| Fin 3 → R
/-- The equivalence class of a point representative. -/
abbrev PointClass (R : Type u) [CommRing R] : Type u :=
MulAction.orbitRel.Quotient Rˣ <| Fin 3 → R
/-- The coercion to a Weierstrass curve in affine coordinates. -/
abbrev toAffine : Affine R :=
W
section Equation
/-! ### Equations and nonsingularity -/
/-- The polynomial $W(X, Y, Z) := Y^2Z + a_1XYZ + a_3YZ^2 - (X^3 + a_2X^2Z + a_4XZ^2 + a_6Z^3)$
associated to a Weierstrass curve `W` over `R`. This is represented as a term of type
`MvPolynomial (Fin 3) R`, where `X 0`, `X 1`, and `X 2` represent $X$, $Y$, and $Z$ respectively. -/
noncomputable def polynomial : MvPolynomial (Fin 3) R :=
X 1 ^ 2 * X 2 + C W.a₁ * X 0 * X 1 * X 2 + C W.a₃ * X 1 * X 2 ^ 2
- (X 0 ^ 3 + C W.a₂ * X 0 ^ 2 * X 2 + C W.a₄ * X 0 * X 2 ^ 2 + C W.a₆ * X 2 ^ 3)
lemma eval_polynomial (P : Fin 3 → R) : eval P W.polynomial =
P y ^ 2 * P z + W.a₁ * P x * P y * P z + W.a₃ * P y * P z ^ 2
- (P x ^ 3 + W.a₂ * P x ^ 2 * P z + W.a₄ * P x * P z ^ 2 + W.a₆ * P z ^ 3) := by
rw [polynomial]
eval_simp
/-- The proposition that a point representative $(x, y, z)$ lies in `W`.
In other words, $W(x, y, z) = 0$. -/
def Equation (P : Fin 3 → R) : Prop :=
eval P W.polynomial = 0
lemma equation_iff (P : Fin 3 → R) : W.Equation P ↔
P y ^ 2 * P z + W.a₁ * P x * P y * P z + W.a₃ * P y * P z ^ 2
= P x ^ 3 + W.a₂ * P x ^ 2 * P z + W.a₄ * P x * P z ^ 2 + W.a₆ * P z ^ 3 := by
rw [Equation, eval_polynomial, sub_eq_zero]
lemma equation_zero (Y : R) : W.Equation ![0, Y, 0] :=
(W.equation_iff ![0, Y, 0]).mpr <| by matrix_simp; ring1
lemma equation_some (X Y : R) : W.Equation ![X, Y, 1] ↔ W.toAffine.Equation X Y := by
rw [equation_iff, W.toAffine.equation_iff]
congr! 1 <;> matrix_simp <;> ring1
lemma equation_smul_iff (P : Fin 3 → R) (u : Rˣ) : W.Equation (u • P) ↔ W.Equation P :=
have (u : Rˣ) {P : Fin 3 → R} (h : W.Equation P) : W.Equation <| u • P := by
rw [equation_iff] at h ⊢
linear_combination (norm := (simp only [smul_fin3_ext]; ring1)) (u : R) ^ 3 * h
⟨fun h => by convert this u⁻¹ h; rw [inv_smul_smul], this u⟩
/-- The partial derivative $W_X(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $X$. -/
noncomputable def polynomialX : MvPolynomial (Fin 3) R :=
pderiv x W.polynomial
lemma polynomialX_eq : W.polynomialX =
C W.a₁ * X 1 * X 2 - (C 3 * X 0 ^ 2 + C (2 * W.a₂) * X 0 * X 2 + C W.a₄ * X 2 ^ 2) := by
rw [polynomialX, polynomial]
pderiv_simp
ring1
lemma eval_polynomialX (P : Fin 3 → R) : eval P W.polynomialX =
W.a₁ * P y * P z - (3 * P x ^ 2 + 2 * W.a₂ * P x * P z + W.a₄ * P z ^ 2) := by
rw [polynomialX_eq]
eval_simp
/-- The partial derivative $W_Y(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Y$. -/
noncomputable def polynomialY : MvPolynomial (Fin 3) R :=
pderiv y W.polynomial
lemma polynomialY_eq : W.polynomialY =
C 2 * X 1 * X 2 + C W.a₁ * X 0 * X 2 + C W.a₃ * X 2 ^ 2 := by
rw [polynomialY, polynomial]
pderiv_simp
ring1
lemma eval_polynomialY (P : Fin 3 → R) :
eval P W.polynomialY = 2 * P y * P z + W.a₁ * P x * P z + W.a₃ * P z ^ 2 := by
rw [polynomialY_eq]
eval_simp
/-- The partial derivative $W_Z(X, Y, Z)$ of $W(X, Y, Z)$ with respect to $Z$. -/
noncomputable def polynomialZ : MvPolynomial (Fin 3) R :=
pderiv z W.polynomial
lemma polynomialZ_eq : W.polynomialZ =
X 1 ^ 2 + C W.a₁ * X 0 * X 1 + C (2 * W.a₃) * X 1 * X 2
- (C W.a₂ * X 0 ^ 2 + C (2 * W.a₄) * X 0 * X 2 + C (3 * W.a₆) * X 2 ^ 2) := by
rw [polynomialZ, polynomial]
pderiv_simp
ring1
lemma eval_polynomialZ (P : Fin 3 → R) : eval P W.polynomialZ =
P y ^ 2 + W.a₁ * P x * P y + 2 * W.a₃ * P y * P z
- (W.a₂ * P x ^ 2 + 2 * W.a₄ * P x * P z + 3 * W.a₆ * P z ^ 2) := by
rw [polynomialZ_eq]
eval_simp
/-- Euler's homogeneous function theorem. -/
theorem polynomial_relation (P : Fin 3 → R) : 3 * eval P W.polynomial =
P x * eval P W.polynomialX + P y * eval P W.polynomialY + P z * eval P W.polynomialZ := by
rw [eval_polynomial, eval_polynomialX, eval_polynomialY, eval_polynomialZ]
ring1
/-- The proposition that a point representative $(x, y, z)$ in `W` is nonsingular.
In other words, either $W_X(x, y, z) \ne 0$, $W_Y(x, y, z) \ne 0$, or $W_Z(x, y, z) \ne 0$. -/
def Nonsingular (P : Fin 3 → R) : Prop :=
W.Equation P ∧ (eval P W.polynomialX ≠ 0 ∨ eval P W.polynomialY ≠ 0 ∨ eval P W.polynomialZ ≠ 0)
lemma nonsingular_iff (P : Fin 3 → R) : W.Nonsingular P ↔ W.Equation P ∧
(W.a₁ * P y * P z ≠ 3 * P x ^ 2 + 2 * W.a₂ * P x * P z + W.a₄ * P z ^ 2 ∨
P y * P z ≠ -P y * P z - W.a₁ * P x * P z - W.a₃ * P z ^ 2 ∨
P y ^ 2 + W.a₁ * P x * P y + 2 * W.a₃ * P y * P z
≠ W.a₂ * P x ^ 2 + 2 * W.a₄ * P x * P z + 3 * W.a₆ * P z ^ 2) := by
rw [Nonsingular, eval_polynomialX, eval_polynomialY, eval_polynomialZ, sub_ne_zero, sub_ne_zero,
← sub_ne_zero (a := P y * P z)]
congr! 4
ring1
lemma nonsingular_zero [Nontrivial R] : W.Nonsingular ![0, 1, 0] :=
(W.nonsingular_iff ![0, 1, 0]).mpr ⟨W.equation_zero 1, by simp⟩
lemma nonsingular_zero' [NoZeroDivisors R] {Y : R} (hy : Y ≠ 0) : W.Nonsingular ![0, Y, 0] :=
(W.nonsingular_iff ![0, Y, 0]).mpr ⟨W.equation_zero Y, by simpa⟩
lemma nonsingular_some (X Y : R) : W.Nonsingular ![X, Y, 1] ↔ W.toAffine.Nonsingular X Y := by
rw [nonsingular_iff]
matrix_simp
simp only [W.toAffine.nonsingular_iff, equation_some, and_congr_right_iff,
W.toAffine.equation_iff, ← not_and_or, not_iff_not, one_pow, mul_one, Iff.comm, iff_self_and]
intro h hX hY
linear_combination (norm := ring1) 3 * h - X * hX - Y * hY
lemma nonsingular_smul_iff (P : Fin 3 → R) (u : Rˣ) : W.Nonsingular (u • P) ↔ W.Nonsingular P :=
have (u : Rˣ) {P : Fin 3 → R} (h : W.Nonsingular <| u • P) : W.Nonsingular P := by
rcases (W.nonsingular_iff _).mp h with ⟨h, h'⟩
refine (W.nonsingular_iff P).mpr ⟨(W.equation_smul_iff P u).mp h, ?_⟩
contrapose! h'
simp only [smul_fin3_ext]
exact ⟨by linear_combination (norm := ring1) (u : R) ^ 2 * h'.left,
by linear_combination (norm := ring1) (u : R) ^ 2 * h'.right.left,
by linear_combination (norm := ring1) (u : R) ^ 2 * h'.right.right⟩
⟨this u, fun h => this u⁻¹ <| by rwa [inv_smul_smul]⟩
lemma nonsingular_of_equiv {P Q : Fin 3 → R} (h : P ≈ Q) : W.Nonsingular P ↔ W.Nonsingular Q := by
rcases h with ⟨u, rfl⟩
exact W.nonsingular_smul_iff Q u
/-- The proposition that a point class on `W` is nonsingular. If `P` is a point representative,
then `W.NonsingularLift ⟦P⟧` is definitionally equivalent to `W.Nonsingular P`. -/
def NonsingularLift (P : PointClass R) : Prop :=
P.lift W.Nonsingular fun _ _ => propext ∘ W.nonsingular_of_equiv
@[simp]
lemma nonsingularLift_iff (P : Fin 3 → R) : W.NonsingularLift ⟦P⟧ ↔ W.Nonsingular P :=
Iff.rfl
lemma nonsingularLift_zero [Nontrivial R] : W.NonsingularLift ⟦![0, 1, 0]⟧ :=
W.nonsingular_zero
lemma nonsingularLift_zero' [NoZeroDivisors R] {Y : R} (hy : Y ≠ 0) :
W.NonsingularLift ⟦![0, Y, 0]⟧ :=
W.nonsingular_zero' hy
lemma nonsingularLift_some (X Y : R) :
W.NonsingularLift ⟦![X, Y, 1]⟧ ↔ W.toAffine.Nonsingular X Y :=
W.nonsingular_some X Y
variable {F : Type u} [Field F] {W : Projective F}
lemma equiv_of_Z_eq_zero {P Q : Fin 3 → F} (hP : W.Nonsingular P) (hQ : W.Nonsingular Q)
(hPz : P z = 0) (hQz : Q z = 0) : P ≈ Q := by
rw [fin3_def P, hPz] at hP ⊢
rw [fin3_def Q, hQz] at hQ ⊢
simp? [nonsingular_iff, equation_iff] at hP hQ says
simp only [Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, nonsingular_iff,
equation_iff, Matrix.cons_val_one, Matrix.head_cons, Matrix.cons_val_two, Matrix.tail_cons,
mul_zero, Matrix.cons_val_zero, add_zero, ne_eq, OfNat.ofNat_ne_zero, not_false_eq_true,
zero_pow, zero_eq_mul, pow_eq_zero_iff, not_or, sub_self, not_true_eq_false, false_or]
at hP hQ
simp? [pow_eq_zero hP.left.symm, pow_eq_zero hQ.left.symm] at * says
simp only [Fin.isValue, pow_eq_zero hP.left.symm, ne_eq, OfNat.ofNat_ne_zero,
not_false_eq_true, zero_pow, not_true_eq_false, and_false, mul_zero, zero_mul, add_zero,
pow_eq_zero_iff, false_or, true_and, pow_eq_zero hQ.left.symm, Nat.succ_eq_add_one,
Nat.reduceAdd] at *
exact ⟨Units.mk0 (P y / Q y) <| div_ne_zero hP hQ, by simp [div_mul_cancel₀ _ hQ]⟩
lemma equiv_zero_of_Z_eq_zero {P : Fin 3 → F} (h : W.Nonsingular P) (hPz : P z = 0) :
P ≈ ![0, 1, 0] :=
equiv_of_Z_eq_zero h W.nonsingular_zero hPz rfl
lemma equiv_some_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) : P ≈ ![P x / P z, P y / P z, 1] :=
⟨Units.mk0 _ hPz, by simp [← fin3_def P, mul_div_cancel₀ _ hPz]⟩
lemma nonsingular_iff_affine_of_Z_ne_zero {P : Fin 3 → F} (hPz : P z ≠ 0) :
W.Nonsingular P ↔ W.toAffine.Nonsingular (P x / P z) (P y / P z) :=
(W.nonsingular_of_equiv <| equiv_some_of_Z_ne_zero hPz).trans <| W.nonsingular_some ..
lemma nonsingular_of_affine_of_Z_ne_zero {P : Fin 3 → F}
(h : W.toAffine.Nonsingular (P x / P z) (P y / P z)) (hPz : P z ≠ 0) : W.Nonsingular P :=
(nonsingular_iff_affine_of_Z_ne_zero hPz).mpr h
lemma nonsingular_affine_of_Z_ne_zero {P : Fin 3 → F} (h : W.Nonsingular P) (hPz : P z ≠ 0) :
W.toAffine.Nonsingular (P x / P z) (P y / P z) :=
(nonsingular_iff_affine_of_Z_ne_zero hPz).mp h
end Equation
end WeierstrassCurve.Projective
|
AlgebraicGeometry\EllipticCurve\Weierstrass.lean | /-
Copyright (c) 2021 Kevin Buzzard. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin Buzzard, David Kurniadi Angdinata
-/
import Mathlib.Algebra.CubicDiscriminant
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
/-!
# Weierstrass equations of elliptic curves
This file defines the structure of an elliptic curve as a nonsingular Weierstrass curve given by a
Weierstrass equation, which is mathematically accurate in many cases but also good for computation.
## Mathematical background
Let `S` be a scheme. The actual category of elliptic curves over `S` is a large category, whose
objects are schemes `E` equipped with a map `E → S`, a section `S → E`, and some axioms (the map
is smooth and proper and the fibres are geometrically-connected one-dimensional group varieties). In
the special case where `S` is the spectrum of some commutative ring `R` whose Picard group is zero
(this includes all fields, all PIDs, and many other commutative rings) it can be shown (using a lot
of algebro-geometric machinery) that every elliptic curve `E` is a projective plane cubic isomorphic
to a Weierstrass curve given by the equation $Y^2 + a_1XY + a_3Y = X^3 + a_2X^2 + a_4X + a_6$ for
some $a_i$ in `R`, and such that a certain quantity called the discriminant of `E` is a unit in `R`.
If `R` is a field, this quantity divides the discriminant of a cubic polynomial whose roots over a
splitting field of `R` are precisely the $X$-coordinates of the non-zero 2-torsion points of `E`.
## Main definitions
* `WeierstrassCurve`: a Weierstrass curve over a commutative ring.
* `WeierstrassCurve.Δ`: the discriminant of a Weierstrass curve.
* `WeierstrassCurve.ofJ0`: a Weierstrass curve whose j-invariant is 0.
* `WeierstrassCurve.ofJ1728`: a Weierstrass curve whose j-invariant is 1728.
* `WeierstrassCurve.ofJ`: a Weierstrass curve whose j-invariant is neither 0 nor 1728.
* `WeierstrassCurve.VariableChange`: a change of variables of Weierstrass curves.
* `WeierstrassCurve.variableChange`: the Weierstrass curve induced by a change of variables.
* `WeierstrassCurve.map`: the Weierstrass curve mapped over a ring homomorphism.
* `WeierstrassCurve.twoTorsionPolynomial`: the 2-torsion polynomial of a Weierstrass curve.
* `EllipticCurve`: an elliptic curve over a commutative ring.
* `EllipticCurve.j`: the j-invariant of an elliptic curve.
* `EllipticCurve.ofJ0`: an elliptic curve whose j-invariant is 0.
* `EllipticCurve.ofJ1728`: an elliptic curve whose j-invariant is 1728.
* `EllipticCurve.ofJ'`: an elliptic curve whose j-invariant is neither 0 nor 1728.
* `EllipticCurve.ofJ`: an elliptic curve whose j-invariant equal to j.
## Main statements
* `WeierstrassCurve.twoTorsionPolynomial_disc`: the discriminant of a Weierstrass curve is a
constant factor of the cubic discriminant of its 2-torsion polynomial.
* `EllipticCurve.variableChange_j`: the j-invariant of an elliptic curve is invariant under an
admissible linear change of variables.
* `EllipticCurve.ofJ_j`: the j-invariant of `EllipticCurve.ofJ` is equal to j.
## Implementation notes
The definition of elliptic curves in this file makes sense for all commutative rings `R`, but it
only gives a type which can be beefed up to a category which is equivalent to the category of
elliptic curves over the spectrum $\mathrm{Spec}(R)$ of `R` in the case that `R` has trivial Picard
group $\mathrm{Pic}(R)$ or, slightly more generally, when its 12-torsion is trivial. The issue is
that for a general ring `R`, there might be elliptic curves over $\mathrm{Spec}(R)$ in the sense of
algebraic geometry which are not globally defined by a cubic equation valid over the entire base.
## References
* [N Katz and B Mazur, *Arithmetic Moduli of Elliptic Curves*][katz_mazur]
* [P Deligne, *Courbes Elliptiques: Formulaire (d'après J. Tate)*][deligne_formulaire]
* [J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, weierstrass equation, j invariant
-/
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow])
universe s u v w
/-! ## Weierstrass curves -/
/-- A Weierstrass curve $Y^2 + a_1XY + a_3Y = X^3 + a_2X^2 + a_4X + a_6$ with parameters $a_i$. -/
@[ext]
structure WeierstrassCurve (R : Type u) where
/-- The `a₁` coefficient of a Weierstrass curve. -/
a₁ : R
/-- The `a₂` coefficient of a Weierstrass curve. -/
a₂ : R
/-- The `a₃` coefficient of a Weierstrass curve. -/
a₃ : R
/-- The `a₄` coefficient of a Weierstrass curve. -/
a₄ : R
/-- The `a₆` coefficient of a Weierstrass curve. -/
a₆ : R
namespace WeierstrassCurve
instance instInhabited {R : Type u} [Inhabited R] :
Inhabited <| WeierstrassCurve R :=
⟨⟨default, default, default, default, default⟩⟩
variable {R : Type u} [CommRing R] (W : WeierstrassCurve R)
section Quantity
/-! ### Standard quantities -/
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `b₂` coefficient of a Weierstrass curve. -/
def b₂ : R :=
W.a₁ ^ 2 + 4 * W.a₂
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `b₄` coefficient of a Weierstrass curve. -/
def b₄ : R :=
2 * W.a₄ + W.a₁ * W.a₃
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `b₆` coefficient of a Weierstrass curve. -/
def b₆ : R :=
W.a₃ ^ 2 + 4 * W.a₆
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `b₈` coefficient of a Weierstrass curve. -/
def b₈ : R :=
W.a₁ ^ 2 * W.a₆ + 4 * W.a₂ * W.a₆ - W.a₁ * W.a₃ * W.a₄ + W.a₂ * W.a₃ ^ 2 - W.a₄ ^ 2
lemma b_relation : 4 * W.b₈ = W.b₂ * W.b₆ - W.b₄ ^ 2 := by
simp only [b₂, b₄, b₆, b₈]
ring1
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `c₄` coefficient of a Weierstrass curve. -/
def c₄ : R :=
W.b₂ ^ 2 - 24 * W.b₄
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The `c₆` coefficient of a Weierstrass curve. -/
def c₆ : R :=
-W.b₂ ^ 3 + 36 * W.b₂ * W.b₄ - 216 * W.b₆
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The discriminant `Δ` of a Weierstrass curve. If `R` is a field, then this polynomial vanishes
if and only if the cubic curve cut out by this equation is singular. Sometimes only defined up to
sign in the literature; we choose the sign used by the LMFDB. For more discussion, see
[the LMFDB page on discriminants](https://www.lmfdb.org/knowledge/show/ec.discriminant). -/
def Δ : R :=
-W.b₂ ^ 2 * W.b₈ - 8 * W.b₄ ^ 3 - 27 * W.b₆ ^ 2 + 9 * W.b₂ * W.b₄ * W.b₆
lemma c_relation : 1728 * W.Δ = W.c₄ ^ 3 - W.c₆ ^ 2 := by
simp only [b₂, b₄, b₆, b₈, c₄, c₆, Δ]
ring1
end Quantity
section VariableChange
/-! ### Variable changes -/
/-- An admissible linear change of variables of Weierstrass curves defined over a ring `R` given by
a tuple $(u, r, s, t)$ for some $u \in R^\times$ and some $r, s, t \in R$. As a matrix, it is
$\begin{pmatrix} u^2 & 0 & r \cr u^2s & u^3 & t \cr 0 & 0 & 1 \end{pmatrix}$. -/
@[ext]
structure VariableChange (R : Type u) [CommRing R] where
/-- The `u` coefficient of an admissible linear change of variables, which must be a unit. -/
u : Rˣ
/-- The `r` coefficient of an admissible linear change of variables. -/
r : R
/-- The `s` coefficient of an admissible linear change of variables. -/
s : R
/-- The `t` coefficient of an admissible linear change of variables. -/
t : R
namespace VariableChange
variable (C C' C'' : VariableChange R)
/-- The identity linear change of variables given by the identity matrix. -/
def id : VariableChange R :=
⟨1, 0, 0, 0⟩
/-- The composition of two linear changes of variables given by matrix multiplication. -/
def comp : VariableChange R where
u := C.u * C'.u
r := C.r * C'.u ^ 2 + C'.r
s := C'.u * C.s + C'.s
t := C.t * C'.u ^ 3 + C.r * C'.s * C'.u ^ 2 + C'.t
/-- The inverse of a linear change of variables given by matrix inversion. -/
def inv : VariableChange R where
u := C.u⁻¹
r := -C.r * C.u⁻¹ ^ 2
s := -C.s * C.u⁻¹
t := (C.r * C.s - C.t) * C.u⁻¹ ^ 3
lemma id_comp (C : VariableChange R) : comp id C = C := by
simp only [comp, id, zero_add, zero_mul, mul_zero, one_mul]
lemma comp_id (C : VariableChange R) : comp C id = C := by
simp only [comp, id, add_zero, mul_zero, one_mul, mul_one, one_pow, Units.val_one]
lemma comp_left_inv (C : VariableChange R) : comp (inv C) C = id := by
rw [comp, id, inv]
ext <;> dsimp only
· exact C.u.inv_mul
· linear_combination (norm := ring1) -C.r * pow_mul_pow_eq_one 2 C.u.inv_mul
· linear_combination (norm := ring1) -C.s * C.u.inv_mul
· linear_combination (norm := ring1) (C.r * C.s - C.t) * pow_mul_pow_eq_one 3 C.u.inv_mul
+ -C.r * C.s * pow_mul_pow_eq_one 2 C.u.inv_mul
lemma comp_assoc (C C' C'' : VariableChange R) : comp (comp C C') C'' = comp C (comp C' C'') := by
ext <;> simp only [comp, Units.val_mul] <;> ring1
instance instGroup : Group (VariableChange R) where
one := id
inv := inv
mul := comp
one_mul := id_comp
mul_one := comp_id
mul_left_inv := comp_left_inv
mul_assoc := comp_assoc
end VariableChange
variable (C : VariableChange R)
/-- The Weierstrass curve over `R` induced by an admissible linear change of variables
$(X, Y) \mapsto (u^2X + r, u^3Y + u^2sX + t)$ for some $u \in R^\times$ and some $r, s, t \in R$. -/
@[simps]
def variableChange : WeierstrassCurve R where
a₁ := C.u⁻¹ * (W.a₁ + 2 * C.s)
a₂ := C.u⁻¹ ^ 2 * (W.a₂ - C.s * W.a₁ + 3 * C.r - C.s ^ 2)
a₃ := C.u⁻¹ ^ 3 * (W.a₃ + C.r * W.a₁ + 2 * C.t)
a₄ := C.u⁻¹ ^ 4 * (W.a₄ - C.s * W.a₃ + 2 * C.r * W.a₂ - (C.t + C.r * C.s) * W.a₁ + 3 * C.r ^ 2
- 2 * C.s * C.t)
a₆ := C.u⁻¹ ^ 6 * (W.a₆ + C.r * W.a₄ + C.r ^ 2 * W.a₂ + C.r ^ 3 - C.t * W.a₃ - C.t ^ 2
- C.r * C.t * W.a₁)
lemma variableChange_id : W.variableChange VariableChange.id = W := by
rw [VariableChange.id, variableChange, inv_one, Units.val_one]
ext <;> (dsimp only; ring1)
lemma variableChange_comp (C C' : VariableChange R) (W : WeierstrassCurve R) :
W.variableChange (C.comp C') = (W.variableChange C').variableChange C := by
simp only [VariableChange.comp, variableChange]
ext <;> simp only [mul_inv, Units.val_mul]
· linear_combination (norm := ring1) C.u⁻¹ * C.s * 2 * C'.u.inv_mul
· linear_combination (norm := ring1)
C.s * (-C'.s * 2 - W.a₁) * C.u⁻¹ ^ 2 * C'.u⁻¹ * C'.u.inv_mul
+ (C.r * 3 - C.s ^ 2) * C.u⁻¹ ^ 2 * pow_mul_pow_eq_one 2 C'.u.inv_mul
· linear_combination (norm := ring1)
C.r * (C'.s * 2 + W.a₁) * C.u⁻¹ ^ 3 * C'.u⁻¹ * pow_mul_pow_eq_one 2 C'.u.inv_mul
+ C.t * 2 * C.u⁻¹ ^ 3 * pow_mul_pow_eq_one 3 C'.u.inv_mul
· linear_combination (norm := ring1)
C.s * (-W.a₃ - C'.r * W.a₁ - C'.t * 2) * C.u⁻¹ ^ 4 * C'.u⁻¹ ^ 3 * C'.u.inv_mul
+ C.u⁻¹ ^ 4 * C'.u⁻¹ ^ 2 * (C.r * C'.r * 6 + C.r * W.a₂ * 2 - C'.s * C.r * W.a₁ * 2
- C'.s ^ 2 * C.r * 2) * pow_mul_pow_eq_one 2 C'.u.inv_mul
- C.u⁻¹ ^ 4 * C'.u⁻¹ * (C.s * C'.s * C.r * 2 + C.s * C.r * W.a₁ + C'.s * C.t * 2
+ C.t * W.a₁) * pow_mul_pow_eq_one 3 C'.u.inv_mul
+ C.u⁻¹ ^ 4 * (C.r ^ 2 * 3 - C.s * C.t * 2) * pow_mul_pow_eq_one 4 C'.u.inv_mul
· linear_combination (norm := ring1)
C.r * C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 4 * (C'.r * W.a₂ * 2 - C'.r * C'.s * W.a₁ + C'.r ^ 2 * 3 + W.a₄
- C'.s * C'.t * 2 - C'.s * W.a₃ - C'.t * W.a₁) * pow_mul_pow_eq_one 2 C'.u.inv_mul
- C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 3 * C.t * (C'.r * W.a₁ + C'.t * 2 + W.a₃)
* pow_mul_pow_eq_one 3 C'.u.inv_mul
+ C.r ^ 2 * C.u⁻¹ ^ 6 * C'.u⁻¹ ^ 2 * (C'.r * 3 + W.a₂ - C'.s * W.a₁ - C'.s ^ 2)
* pow_mul_pow_eq_one 4 C'.u.inv_mul
- C.r * C.t * C.u⁻¹ ^ 6 * C'.u⁻¹ * (C'.s * 2 + W.a₁) * pow_mul_pow_eq_one 5 C'.u.inv_mul
+ C.u⁻¹ ^ 6 * (C.r ^ 3 - C.t ^ 2) * pow_mul_pow_eq_one 6 C'.u.inv_mul
instance instMulActionVariableChange : MulAction (VariableChange R) (WeierstrassCurve R) where
smul := fun C W => W.variableChange C
one_smul := variableChange_id
mul_smul := variableChange_comp
@[simp]
lemma variableChange_b₂ : (W.variableChange C).b₂ = C.u⁻¹ ^ 2 * (W.b₂ + 12 * C.r) := by
simp only [b₂, variableChange_a₁, variableChange_a₂]
ring1
@[simp]
lemma variableChange_b₄ :
(W.variableChange C).b₄ = C.u⁻¹ ^ 4 * (W.b₄ + C.r * W.b₂ + 6 * C.r ^ 2) := by
simp only [b₂, b₄, variableChange_a₁, variableChange_a₃, variableChange_a₄]
ring1
@[simp]
lemma variableChange_b₆ : (W.variableChange C).b₆ =
C.u⁻¹ ^ 6 * (W.b₆ + 2 * C.r * W.b₄ + C.r ^ 2 * W.b₂ + 4 * C.r ^ 3) := by
simp only [b₂, b₄, b₆, variableChange_a₃, variableChange_a₆]
ring1
@[simp]
lemma variableChange_b₈ : (W.variableChange C).b₈ = C.u⁻¹ ^ 8 *
(W.b₈ + 3 * C.r * W.b₆ + 3 * C.r ^ 2 * W.b₄ + C.r ^ 3 * W.b₂ + 3 * C.r ^ 4) := by
simp only [b₂, b₄, b₆, b₈, variableChange_a₁, variableChange_a₂, variableChange_a₃,
variableChange_a₄, variableChange_a₆]
ring1
@[simp]
lemma variableChange_c₄ : (W.variableChange C).c₄ = C.u⁻¹ ^ 4 * W.c₄ := by
simp only [c₄, variableChange_b₂, variableChange_b₄]
ring1
@[simp]
lemma variableChange_c₆ : (W.variableChange C).c₆ = C.u⁻¹ ^ 6 * W.c₆ := by
simp only [c₆, variableChange_b₂, variableChange_b₄, variableChange_b₆]
ring1
@[simp]
lemma variableChange_Δ : (W.variableChange C).Δ = C.u⁻¹ ^ 12 * W.Δ := by
simp only [b₂, b₄, b₆, b₈, Δ, variableChange_a₁, variableChange_a₂, variableChange_a₃,
variableChange_a₄, variableChange_a₆]
ring1
end VariableChange
section BaseChange
/-! ### Maps and base changes -/
variable {A : Type v} [CommRing A] (φ : R →+* A)
/-- The Weierstrass curve mapped over a ring homomorphism `φ : R →+* A`. -/
@[simps]
def map : WeierstrassCurve A :=
⟨φ W.a₁, φ W.a₂, φ W.a₃, φ W.a₄, φ W.a₆⟩
variable (A)
/-- The Weierstrass curve base changed to an algebra `A` over `R`. -/
abbrev baseChange [Algebra R A] : WeierstrassCurve A :=
W.map <| algebraMap R A
variable {A}
@[simp]
lemma map_b₂ : (W.map φ).b₂ = φ W.b₂ := by
simp only [b₂, map_a₁, map_a₂]
map_simp
@[simp]
lemma map_b₄ : (W.map φ).b₄ = φ W.b₄ := by
simp only [b₄, map_a₁, map_a₃, map_a₄]
map_simp
@[simp]
lemma map_b₆ : (W.map φ).b₆ = φ W.b₆ := by
simp only [b₆, map_a₃, map_a₆]
map_simp
@[simp]
lemma map_b₈ : (W.map φ).b₈ = φ W.b₈ := by
simp only [b₈, map_a₁, map_a₂, map_a₃, map_a₄, map_a₆]
map_simp
@[simp]
lemma map_c₄ : (W.map φ).c₄ = φ W.c₄ := by
simp only [c₄, map_b₂, map_b₄]
map_simp
@[simp]
lemma map_c₆ : (W.map φ).c₆ = φ W.c₆ := by
simp only [c₆, map_b₂, map_b₄, map_b₆]
map_simp
@[simp]
lemma map_Δ : (W.map φ).Δ = φ W.Δ := by
simp only [Δ, map_b₂, map_b₄, map_b₆, map_b₈]
map_simp
@[simp]
lemma map_id : W.map (RingHom.id R) = W :=
rfl
lemma map_map {B : Type w} [CommRing B] (ψ : A →+* B) : (W.map φ).map ψ = W.map (ψ.comp φ) :=
rfl
@[simp]
lemma map_baseChange {S : Type s} [CommRing S] [Algebra R S] {A : Type v} [CommRing A] [Algebra R A]
[Algebra S A] [IsScalarTower R S A] {B : Type w} [CommRing B] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (ψ : A →ₐ[S] B) : (W.baseChange A).map ψ = W.baseChange B :=
congr_arg W.map <| ψ.comp_algebraMap_of_tower R
lemma map_injective {φ : R →+* A} (hφ : Function.Injective φ) :
Function.Injective <| map (φ := φ) := fun _ _ h => by
rcases mk.inj h with ⟨_, _, _, _, _⟩
ext <;> apply_fun _ using hφ <;> assumption
namespace VariableChange
variable (C : VariableChange R)
/-- The change of variables mapped over a ring homomorphism `φ : R →+* A`. -/
@[simps]
def map : VariableChange A :=
⟨Units.map φ C.u, φ C.r, φ C.s, φ C.t⟩
variable (A)
/-- The change of variables base changed to an algebra `A` over `R`. -/
abbrev baseChange [Algebra R A] : VariableChange A :=
C.map <| algebraMap R A
variable {A}
@[simp]
lemma map_id : C.map (RingHom.id R) = C :=
rfl
lemma map_map {A : Type v} [CommRing A] (φ : R →+* A) {B : Type w} [CommRing B] (ψ : A →+* B) :
(C.map φ).map ψ = C.map (ψ.comp φ) :=
rfl
@[simp]
lemma map_baseChange {S : Type s} [CommRing S] [Algebra R S] {A : Type v} [CommRing A] [Algebra R A]
[Algebra S A] [IsScalarTower R S A] {B : Type w} [CommRing B] [Algebra R B] [Algebra S B]
[IsScalarTower R S B] (ψ : A →ₐ[S] B) : (C.baseChange A).map ψ = C.baseChange B :=
congr_arg C.map <| ψ.comp_algebraMap_of_tower R
lemma map_injective {φ : R →+* A} (hφ : Function.Injective φ) :
Function.Injective <| map (φ := φ) := fun _ _ h => by
rcases mk.inj h with ⟨h, _, _, _⟩
replace h := (Units.mk.inj h).left
ext <;> apply_fun _ using hφ <;> assumption
private lemma id_map : (id : VariableChange R).map φ = id := by
simp only [id, map]
ext <;> simp only [map_one, Units.val_one, map_zero]
private lemma comp_map (C' : VariableChange R) : (C.comp C').map φ = (C.map φ).comp (C'.map φ) := by
simp only [comp, map]
ext <;> map_simp <;> simp only [Units.coe_map, Units.coe_map_inv, MonoidHom.coe_coe]
/-- The map over a ring homomorphism of a change of variables is a group homomorphism. -/
def mapHom : VariableChange R →* VariableChange A where
toFun := map φ
map_one' := id_map φ
map_mul' := comp_map φ
end VariableChange
lemma map_variableChange (C : VariableChange R) :
(W.map φ).variableChange (C.map φ) = (W.variableChange C).map φ := by
simp only [map, variableChange, VariableChange.map]
ext <;> map_simp <;> simp only [Units.coe_map, Units.coe_map_inv, MonoidHom.coe_coe]
end BaseChange
section TorsionPolynomial
/-! ### 2-torsion polynomials -/
/-- A cubic polynomial whose discriminant is a multiple of the Weierstrass curve discriminant. If
`W` is an elliptic curve over a field `R` of characteristic different from 2, then its roots over a
splitting field of `R` are precisely the $X$-coordinates of the non-zero 2-torsion points of `W`. -/
def twoTorsionPolynomial : Cubic R :=
⟨4, W.b₂, 2 * W.b₄, W.b₆⟩
lemma twoTorsionPolynomial_disc : W.twoTorsionPolynomial.disc = 16 * W.Δ := by
simp only [b₂, b₄, b₆, b₈, Δ, twoTorsionPolynomial, Cubic.disc]
ring1
lemma twoTorsionPolynomial_disc_isUnit [Invertible (2 : R)] :
IsUnit W.twoTorsionPolynomial.disc ↔ IsUnit W.Δ := by
rw [twoTorsionPolynomial_disc, IsUnit.mul_iff, show (16 : R) = 2 ^ 4 by norm_num1]
exact and_iff_right <| isUnit_of_invertible <| 2 ^ 4
lemma twoTorsionPolynomial_disc_ne_zero [Nontrivial R] [Invertible (2 : R)] (hΔ : IsUnit W.Δ) :
W.twoTorsionPolynomial.disc ≠ 0 :=
(W.twoTorsionPolynomial_disc_isUnit.mpr hΔ).ne_zero
end TorsionPolynomial
section ModelsWithJ
/-! ### Models with prescribed j-invariant -/
variable (R)
/-- The Weierstrass curve $Y^2 + Y = X^3$. It is of j-invariant 0 if it is an elliptic curve. -/
def ofJ0 : WeierstrassCurve R :=
⟨0, 0, 1, 0, 0⟩
lemma ofJ0_c₄ : (ofJ0 R).c₄ = 0 := by
rw [ofJ0, c₄, b₂, b₄]
norm_num1
lemma ofJ0_Δ : (ofJ0 R).Δ = -27 := by
rw [ofJ0, Δ, b₂, b₄, b₆, b₈]
norm_num1
/-- The Weierstrass curve $Y^2 = X^3 + X$. It is of j-invariant 1728 if it is an elliptic curve. -/
def ofJ1728 : WeierstrassCurve R :=
⟨0, 0, 0, 1, 0⟩
lemma ofJ1728_c₄ : (ofJ1728 R).c₄ = -48 := by
rw [ofJ1728, c₄, b₂, b₄]
norm_num1
lemma ofJ1728_Δ : (ofJ1728 R).Δ = -64 := by
rw [ofJ1728, Δ, b₂, b₄, b₆, b₈]
norm_num1
variable {R} (j : R)
/-- The Weierstrass curve $Y^2 + (j - 1728)XY = X^3 - 36(j - 1728)^3X - (j - 1728)^5$.
It is of j-invariant j if it is an elliptic curve. -/
def ofJ : WeierstrassCurve R :=
⟨j - 1728, 0, 0, -36 * (j - 1728) ^ 3, -(j - 1728) ^ 5⟩
lemma ofJ_c₄ : (ofJ j).c₄ = j * (j - 1728) ^ 3 := by
simp only [ofJ, c₄, b₂, b₄]
ring1
lemma ofJ_Δ : (ofJ j).Δ = j ^ 2 * (j - 1728) ^ 9 := by
simp only [ofJ, Δ, b₂, b₄, b₆, b₈]
ring1
end ModelsWithJ
end WeierstrassCurve
/-! ## Elliptic curves -/
/-- An elliptic curve over a commutative ring. Note that this definition is only mathematically
accurate for certain rings whose Picard group has trivial 12-torsion, such as a field or a PID. -/
@[ext]
structure EllipticCurve (R : Type u) [CommRing R] extends WeierstrassCurve R where
/-- The discriminant `Δ'` of an elliptic curve over `R`, which is given as a unit in `R`. -/
Δ' : Rˣ
/-- The discriminant of `E` is equal to the discriminant of `E` as a Weierstrass curve. -/
coe_Δ' : Δ' = toWeierstrassCurve.Δ
namespace EllipticCurve
variable {R : Type u} [CommRing R] (E : EllipticCurve R)
-- Porting note (#10619): removed `@[simp]` to avoid a `simpNF` linter error
/-- The j-invariant `j` of an elliptic curve, which is invariant under isomorphisms over `R`. -/
def j : R :=
E.Δ'⁻¹ * E.c₄ ^ 3
lemma twoTorsionPolynomial_disc_ne_zero [Nontrivial R] [Invertible (2 : R)] :
E.twoTorsionPolynomial.disc ≠ 0 :=
E.toWeierstrassCurve.twoTorsionPolynomial_disc_ne_zero <| E.coe_Δ' ▸ E.Δ'.isUnit
section VariableChange
/-! ### Variable changes -/
variable (C : WeierstrassCurve.VariableChange R)
-- Porting note: was just `@[simps]`
/-- The elliptic curve over `R` induced by an admissible linear change of variables
$(X, Y) \mapsto (u^2X + r, u^3Y + u^2sX + t)$ for some $u \in R^\times$ and some $r, s, t \in R$.
When `R` is a field, any two Weierstrass equations isomorphic to `E` are related by this. -/
@[simps (config := { rhsMd := .default }) a₁ a₂ a₃ a₄ a₆ Δ' toWeierstrassCurve]
def variableChange : EllipticCurve R :=
⟨E.toWeierstrassCurve.variableChange C, C.u⁻¹ ^ 12 * E.Δ', by
rw [Units.val_mul, Units.val_pow_eq_pow_val, coe_Δ', E.variableChange_Δ]⟩
lemma variableChange_id : E.variableChange WeierstrassCurve.VariableChange.id = E := by
simp only [variableChange, WeierstrassCurve.variableChange_id]
simp only [WeierstrassCurve.VariableChange.id, inv_one, one_pow, one_mul]
lemma variableChange_comp (C C' : WeierstrassCurve.VariableChange R) (E : EllipticCurve R) :
E.variableChange (C.comp C') = (E.variableChange C').variableChange C := by
simp only [variableChange, WeierstrassCurve.variableChange_comp]
simp only [WeierstrassCurve.VariableChange.comp, mul_inv, mul_pow, ← mul_assoc]
instance instMulActionVariableChange :
MulAction (WeierstrassCurve.VariableChange R) (EllipticCurve R) where
smul := fun C E => E.variableChange C
one_smul := variableChange_id
mul_smul := variableChange_comp
lemma coe_variableChange_Δ' : (E.variableChange C).Δ' = C.u⁻¹ ^ 12 * E.Δ' :=
rfl
lemma coe_inv_variableChange_Δ' : (E.variableChange C).Δ'⁻¹ = C.u ^ 12 * E.Δ'⁻¹ := by
rw [variableChange_Δ', mul_inv, inv_pow, inv_inv]
@[simp]
lemma variableChange_j : (E.variableChange C).j = E.j := by
rw [j, coe_inv_variableChange_Δ', Units.val_mul, Units.val_pow_eq_pow_val,
variableChange_toWeierstrassCurve, WeierstrassCurve.variableChange_c₄]
have hu : (C.u * C.u⁻¹ : R) ^ 12 = 1 := by rw [C.u.mul_inv, one_pow]
linear_combination (norm := (rw [j]; ring1)) E.j * hu
end VariableChange
section BaseChange
/-! ### Maps and base changes -/
variable {A : Type v} [CommRing A] (φ : R →+* A)
-- Porting note: was just `@[simps]`
/-- The elliptic curve mapped over a ring homomorphism `φ : R →+* A`. -/
@[simps (config := { rhsMd := .default }) a₁ a₂ a₃ a₄ a₆ Δ' toWeierstrassCurve]
def map : EllipticCurve A :=
⟨E.toWeierstrassCurve.map φ, Units.map φ E.Δ', by simp only [Units.coe_map, coe_Δ', E.map_Δ]; rfl⟩
variable (A)
/-- The elliptic curve base changed to an algebra `A` over `R`. -/
abbrev baseChange [Algebra R A] : EllipticCurve A :=
E.map <| algebraMap R A
variable {A}
lemma coe_map_Δ' : (E.map φ).Δ' = φ E.Δ' :=
rfl
lemma coe_inv_map_Δ' : (E.map φ).Δ'⁻¹ = φ ↑E.Δ'⁻¹ :=
rfl
@[simp]
lemma map_j : (E.map φ).j = φ E.j := by
simp [j, map, E.map_c₄]
lemma map_injective {φ : R →+* A} (hφ : Function.Injective φ) :
Function.Injective <| map (φ := φ) := fun _ _ h => by
rcases mk.inj h with ⟨h1, h2⟩
replace h2 := (Units.mk.inj h2).left
rcases WeierstrassCurve.mk.inj h1 with ⟨_, _, _, _, _⟩
ext <;> apply_fun _ using hφ <;> assumption
end BaseChange
section ModelsWithJ
/-! ### Models with prescribed j-invariant -/
variable (R)
/-- When 3 is invertible, $Y^2 + Y = X^3$ is an elliptic curve.
It is of j-invariant 0 (see `EllipticCurve.ofJ0_j`). -/
def ofJ0 [Invertible (3 : R)] : EllipticCurve R :=
have := invertibleNeg (3 ^ 3 : R)
⟨WeierstrassCurve.ofJ0 R, unitOfInvertible (-3 ^ 3 : R),
by rw [val_unitOfInvertible, WeierstrassCurve.ofJ0_Δ R]; norm_num1⟩
lemma ofJ0_j [Invertible (3 : R)] : (ofJ0 R).j = 0 := by
simp only [j, ofJ0, WeierstrassCurve.ofJ0_c₄]
ring1
/-- When 2 is invertible, $Y^2 = X^3 + X$ is an elliptic curve.
It is of j-invariant 1728 (see `EllipticCurve.ofJ1728_j`). -/
def ofJ1728 [Invertible (2 : R)] : EllipticCurve R :=
have := invertibleNeg (2 ^ 6 : R)
⟨WeierstrassCurve.ofJ1728 R, unitOfInvertible (-2 ^ 6 : R),
by rw [val_unitOfInvertible, WeierstrassCurve.ofJ1728_Δ R]; norm_num1⟩
lemma ofJ1728_j [Invertible (2 : R)] : (ofJ1728 R).j = 1728 := by
field_simp [j, ofJ1728, @val_unitOfInvertible _ _ _ <| invertibleNeg _,
WeierstrassCurve.ofJ1728_c₄]
norm_num1
variable {R}
/-- When j and j - 1728 are both invertible,
$Y^2 + (j - 1728)XY = X^3 - 36(j - 1728)^3X - (j - 1728)^5$ is an elliptic curve.
It is of j-invariant j (see `EllipticCurve.ofJ'_j`). -/
def ofJ' (j : R) [Invertible j] [Invertible (j - 1728)] : EllipticCurve R :=
have := invertibleMul (j ^ 2) ((j - 1728) ^ 9)
⟨WeierstrassCurve.ofJ j, unitOfInvertible <| j ^ 2 * (j - 1728) ^ 9,
(WeierstrassCurve.ofJ_Δ j).symm⟩
lemma ofJ'_j (j : R) [Invertible j] [Invertible (j - 1728)] : (ofJ' j).j = j := by
field_simp [EllipticCurve.j, ofJ', @val_unitOfInvertible _ _ _ <| invertibleMul ..,
WeierstrassCurve.ofJ_c₄]
ring1
variable {F : Type u} [Field F] (j : F)
private lemma two_or_three_ne_zero : (2 : F) ≠ 0 ∨ (3 : F) ≠ 0 :=
ne_zero_or_ne_zero_of_nat_coprime <| by decide
variable [DecidableEq F]
/-- For any element j of a field $F$, there exists an elliptic curve over $F$
with j-invariant equal to j (see `EllipticCurve.ofJ_j`).
Its coefficients are given explicitly (see `EllipticCurve.ofJ0`, `EllipticCurve.ofJ1728`
and `EllipticCurve.ofJ'`). -/
def ofJ : EllipticCurve F :=
if h0 : j = 0 then
if h3 : (3 : F) = 0 then @ofJ1728 _ _ <| invertibleOfNonzero <|
two_or_three_ne_zero.neg_resolve_right h3
else @ofJ0 _ _ <| invertibleOfNonzero h3
else if h1728 : j = 1728 then
@ofJ1728 _ _ <| invertibleOfNonzero fun h => h0 <|
by rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
else @ofJ' _ _ j (invertibleOfNonzero h0) (invertibleOfNonzero <| sub_ne_zero_of_ne h1728)
lemma ofJ_0_of_three_ne_zero [h3 : NeZero (3 : F)] :
ofJ 0 = @ofJ0 _ _ (invertibleOfNonzero h3.out) := by
rw [ofJ, dif_pos rfl, dif_neg h3.out]
lemma ofJ_0_of_three_eq_zero (h3 : (3 : F) = 0) :
ofJ 0 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
rw [ofJ, dif_pos rfl, dif_pos h3]
lemma ofJ_0_of_two_eq_zero (h2 : (2 : F) = 0) :
ofJ 0 = @ofJ0 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_left h2) :=
have := neZero_iff.2 <| two_or_three_ne_zero.neg_resolve_left h2
ofJ_0_of_three_ne_zero
lemma ofJ_1728_of_three_eq_zero (h3 : (3 : F) = 0) :
ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3) := by
rw [ofJ, dif_pos <| by rw [show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul], dif_pos h3]
lemma ofJ_1728_of_two_ne_zero [h2 : NeZero (2 : F)] :
ofJ 1728 = @ofJ1728 _ _ (invertibleOfNonzero h2.out) := by
by_cases h3 : (3 : F) = 0
· exact ofJ_1728_of_three_eq_zero h3
· have h : (1728 : F) ≠ 0 := fun h => or_iff_not_and_not.mp
(mul_eq_zero.mp <| by rwa [show 2 ^ 6 * 3 ^ 3 = (1728 : F) by norm_num1])
⟨pow_ne_zero 6 h2.out, pow_ne_zero 3 h3⟩
rw [ofJ, dif_neg h, dif_pos rfl]
lemma ofJ_1728_of_two_eq_zero (h2 : (2 : F) = 0) :
ofJ 1728 = @ofJ0 _ _ (invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_left h2) := by
rw [ofJ, dif_pos <| by rw [show (1728 : F) = 2 * 864 by norm_num1, h2, zero_mul], dif_neg]
lemma ofJ_ne_0_ne_1728 (h0 : j ≠ 0) (h1728 : j ≠ 1728) : ofJ j =
@ofJ' _ _ j (invertibleOfNonzero h0) (invertibleOfNonzero <| sub_ne_zero_of_ne h1728) := by
rw [ofJ, dif_neg h0, dif_neg h1728]
lemma ofJ_j : (ofJ j).j = j := by
by_cases h0 : j = 0
· by_cases h3 : (3 : F) = 0
· rw [h0, ofJ_0_of_three_eq_zero h3,
@ofJ1728_j _ _ <| invertibleOfNonzero <| two_or_three_ne_zero.neg_resolve_right h3,
show (1728 : F) = 3 * 576 by norm_num1, h3, zero_mul]
· rw [h0, ofJ_0_of_three_ne_zero (h3 := neZero_iff.2 h3), @ofJ0_j _ _ <| invertibleOfNonzero h3]
· by_cases h1728 : j = 1728
· have h2 : (2 : F) ≠ 0 :=
fun h => h0 <| by rw [h1728, show (1728 : F) = 2 * 864 by norm_num1, h, zero_mul]
rw [h1728, ofJ_1728_of_two_ne_zero (h2 := neZero_iff.2 h2),
@ofJ1728_j _ _ <| invertibleOfNonzero h2]
· rw [ofJ_ne_0_ne_1728 j h0 h1728,
@ofJ'_j _ _ _ (invertibleOfNonzero h0) (invertibleOfNonzero <| sub_ne_zero_of_ne h1728)]
instance instInhabitedEllipticCurve : Inhabited <| EllipticCurve F :=
⟨ofJ 37⟩
end ModelsWithJ
end EllipticCurve
|
AlgebraicGeometry\EllipticCurve\DivisionPolynomial\Basic.lean | /-
Copyright (c) 2024 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.AlgebraicGeometry.EllipticCurve.Group
import Mathlib.NumberTheory.EllipticDivisibilitySequence
/-!
# Division polynomials of Weierstrass curves
This file defines certain polynomials associated to division polynomials of Weierstrass curves.
These are defined in terms of the auxiliary sequences for normalised elliptic divisibility sequences
(EDS) as defined in `Mathlib.NumberTheory.EllipticDivisibilitySequence`.
## Mathematical background
Let $W$ be a Weierstrass curve over a commutative ring $R$. The sequence of $n$-division polynomials
$\psi_n \in R[X, Y]$ of $W$ is the normalised EDS with initial values
* $\psi_0 := 0$,
* $\psi_1 := 1$,
* $\psi_2 := 2Y + a_1X + a_3$,
* $\psi_3 := 3X^4 + b_2X^3 + 3b_4X ^ 2 + 3b_6X + b_8$, and
* $\psi_4 := \psi_2 \cdot
(2X^6 + b_2X^5 + 5b_4X^4 + 10b_6X^3 + 10b_8X^2 + (b_2b_8 - b_4b_6)X + (b_4b_8 - b_6^2))$.
Furthermore, define the associated sequences $\phi_n, \omega_n \in R[X, Y]$ by
* $\phi_n := X\psi_n^2 - \psi_{n + 1} \cdot \psi_{n - 1}$, and
* $\omega_n := (\psi_{2n} / \psi_n - \psi_n \cdot (a_1\phi_n + a_3\psi_n^2)) / 2$.
Note that $\omega_n$ is always well-defined as a polynomial in $R[X, Y]$. As a start, it can be
shown by induction that $\psi_n$ always divides $\psi_{2n}$ in $R[X, Y]$, so that
$\psi_{2n} / \psi_n$ is always well-defined as a polynomial, while division by 2 is well-defined
when $R$ has characteristic different from 2. In general, it can be shown that 2 always divides the
polynomial $\psi_{2n} / \psi_n - \psi_n \cdot (a_1\phi_n + a_3\psi_n^2)$ in the characteristic zero
universal ring $\mathcal{R}[X, Y] := \mathbb{Z}[A_1, A_2, A_3, A_4, A_6][X, Y]$ of $W$, where the
$A_i$ are indeterminates. Then $\omega_n$ can be equivalently defined as the image of this division
under the associated universal morphism $\mathcal{R}[X, Y] \to R[X, Y]$ mapping $A_i$ to $a_i$.
Now, in the coordinate ring $R[W]$, note that $\psi_2^2$ is congruent to the polynomial
$\Psi_2^{[2]} := 4X^3 + b_2X^2 + 2b_4X + b_6 \in R[X]$. As such, in $R[W]$, the recurrences
associated to a normalised EDS show that $\psi_n / \psi_2$ are congruent to certain polynomials in
$R[X]$. In particular, define $\tilde{\Psi}_n \in R[X]$ as the auxiliary sequence for a normalised
EDS with extra parameter $(\Psi_2^{[2]})^2$ and initial values
* $\tilde{\Psi}_0 := 0$,
* $\tilde{\Psi}_1 := 1$,
* $\tilde{\Psi}_2 := 1$,
* $\tilde{\Psi}_3 := \psi_3$, and
* $\tilde{\Psi}_4 := \psi_4 / \psi_2$.
The corresponding normalised EDS $\Psi_n \in R[X, Y]$ is then given by
* $\Psi_n := \tilde{\Psi}_n \cdot \psi_2$ if $n$ is even, and
* $\Psi_n := \tilde{\Psi}_n$ if $n$ is odd.
Furthermore, define the associated sequences $\Psi_n^{[2]}, \Phi_n \in R[X]$ by
* $\Psi_n^{[2]} := \tilde{\Psi}_n^2 \cdot \Psi_2^{[2]}$ if $n$ is even,
* $\Psi_n^{[2]} := \tilde{\Psi}_n^2$ if $n$ is odd,
* $\Phi_n := X\Psi_n^{[2]} - \tilde{\Psi}_{n + 1} \cdot \tilde{\Psi}_{n - 1}$ if $n$ is even, and
* $\Phi_n := X\Psi_n^{[2]} - \tilde{\Psi}_{n + 1} \cdot \tilde{\Psi}_{n - 1} \cdot \Psi_2^{[2]}$
if $n$ is odd.
With these definitions in mind, $\psi_n \in R[X, Y]$ and $\phi_n \in R[X, Y]$ are congruent in
$R[W]$ to $\Psi_n \in R[X, Y]$ and $\Phi_n \in R[X]$ respectively, which are defined in terms of
$\Psi_2^{[2]} \in R[X]$ and $\tilde{\Psi}_n \in R[X]$.
## Main definitions
* `WeierstrassCurve.preΨ`: the univariate polynomials $\tilde{\Psi}_n$.
* `WeierstrassCurve.ΨSq`: the univariate polynomials $\Psi_n^{[2]}$.
* `WeierstrassCurve.Ψ`: the bivariate polynomials $\Psi_n$.
* `WeierstrassCurve.Φ`: the univariate polynomials $\Phi_n$.
* `WeierstrassCurve.ψ`: the bivariate $n$-division polynomials $\psi_n$.
* `WeierstrassCurve.φ`: the bivariate polynomials $\phi_n$.
* TODO: the bivariate polynomials $\omega_n$.
## Implementation notes
Analogously to `Mathlib.NumberTheory.EllipticDivisibilitySequence`, the bivariate polynomials
$\Psi_n$ are defined in terms of the univariate polynomials $\tilde{\Psi}_n$. This is done partially
to avoid ring division, but more crucially to allow the definition of $\Psi_n^{[2]}$ and $\Phi_n$ as
univariate polynomials without needing to work under the coordinate ring, and to allow the
computation of their leading terms without ambiguity. Furthermore, evaluating these polynomials at a
rational point on $W$ recovers their original definition up to linear combinations of the
Weierstrass equation of $W$, hence also avoiding the need to work in the coordinate ring.
TODO: implementation notes for the definition of $\omega_n$.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, division polynomial, torsion point
-/
open Polynomial
local macro "C_simp" : tactic =>
`(tactic| simp only [map_ofNat, C_0, C_1, C_neg, C_add, C_sub, C_mul, C_pow])
local macro "map_simp" : tactic =>
`(tactic| simp only [map_ofNat, map_neg, map_add, map_sub, map_mul, map_pow, map_div₀,
Polynomial.map_ofNat, Polynomial.map_one, map_C, map_X, Polynomial.map_neg, Polynomial.map_add,
Polynomial.map_sub, Polynomial.map_mul, Polynomial.map_pow, Polynomial.map_div, coe_mapRingHom,
apply_ite <| mapRingHom _, WeierstrassCurve.map])
universe r s u v
namespace WeierstrassCurve
variable {R : Type r} {S : Type s} [CommRing R] [CommRing S] (W : WeierstrassCurve R)
section Ψ₂Sq
/-! ### The univariate polynomial $\Psi_2^{[2]}$ -/
/-- The $2$-division polynomial $\psi_2 = \Psi_2$. -/
noncomputable def ψ₂ : R[X][Y] :=
W.toAffine.polynomialY
/-- The univariate polynomial $\Psi_2^{[2]}$ congruent to $\psi_2^2$. -/
noncomputable def Ψ₂Sq : R[X] :=
C 4 * X ^ 3 + C W.b₂ * X ^ 2 + C (2 * W.b₄) * X + C W.b₆
lemma C_Ψ₂Sq : C W.Ψ₂Sq = W.ψ₂ ^ 2 - 4 * W.toAffine.polynomial := by
rw [Ψ₂Sq, ψ₂, b₂, b₄, b₆, Affine.polynomialY, Affine.polynomial]
C_simp
ring1
lemma ψ₂_sq : W.ψ₂ ^ 2 = C W.Ψ₂Sq + 4 * W.toAffine.polynomial := by
rw [C_Ψ₂Sq, sub_add_cancel]
lemma Affine.CoordinateRing.mk_ψ₂_sq : mk W W.ψ₂ ^ 2 = mk W (C W.Ψ₂Sq) := by
rw [C_Ψ₂Sq, map_sub, map_mul, AdjoinRoot.mk_self, mul_zero, sub_zero, map_pow]
-- TODO: remove `twoTorsionPolynomial` in favour of `Ψ₂Sq`
lemma Ψ₂Sq_eq : W.Ψ₂Sq = W.twoTorsionPolynomial.toPoly :=
rfl
end Ψ₂Sq
section preΨ'
/-! ### The univariate polynomials $\tilde{\Psi}_n$ for $n \in \mathbb{N}$ -/
/-- The $3$-division polynomial $\psi_3 = \Psi_3$. -/
noncomputable def Ψ₃ : R[X] :=
3 * X ^ 4 + C W.b₂ * X ^ 3 + 3 * C W.b₄ * X ^ 2 + 3 * C W.b₆ * X + C W.b₈
/-- The univariate polynomial $\tilde{\Psi}_4$, which is auxiliary to the $4$-division polynomial
$\psi_4 = \Psi_4 = \tilde{\Psi}_4\psi_2$. -/
noncomputable def preΨ₄ : R[X] :=
2 * X ^ 6 + C W.b₂ * X ^ 5 + 5 * C W.b₄ * X ^ 4 + 10 * C W.b₆ * X ^ 3 + 10 * C W.b₈ * X ^ 2 +
C (W.b₂ * W.b₈ - W.b₄ * W.b₆) * X + C (W.b₄ * W.b₈ - W.b₆ ^ 2)
/-- The univariate polynomials $\tilde{\Psi}_n$ for $n \in \mathbb{N}$, which are auxiliary to the
bivariate polynomials $\Psi_n$ congruent to the bivariate $n$-division polynomials $\psi_n$. -/
noncomputable def preΨ' (n : ℕ) : R[X] :=
preNormEDS' (W.Ψ₂Sq ^ 2) W.Ψ₃ W.preΨ₄ n
@[simp]
lemma preΨ'_zero : W.preΨ' 0 = 0 :=
preNormEDS'_zero ..
@[simp]
lemma preΨ'_one : W.preΨ' 1 = 1 :=
preNormEDS'_one ..
@[simp]
lemma preΨ'_two : W.preΨ' 2 = 1 :=
preNormEDS'_two ..
@[simp]
lemma preΨ'_three : W.preΨ' 3 = W.Ψ₃ :=
preNormEDS'_three ..
@[simp]
lemma preΨ'_four : W.preΨ' 4 = W.preΨ₄ :=
preNormEDS'_four ..
lemma preΨ'_odd (m : ℕ) : W.preΨ' (2 * (m + 2) + 1) =
W.preΨ' (m + 4) * W.preΨ' (m + 2) ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2) :=
preNormEDS'_odd ..
lemma preΨ'_even (m : ℕ) : W.preΨ' (2 * (m + 3)) =
W.preΨ' (m + 2) ^ 2 * W.preΨ' (m + 3) * W.preΨ' (m + 5) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) * W.preΨ' (m + 4) ^ 2 :=
preNormEDS'_even ..
end preΨ'
section preΨ
/-! ### The univariate polynomials $\tilde{\Psi}_n$ for $n \in \mathbb{Z}$ -/
/-- The univariate polynomials $\tilde{\Psi}_n$ for $n \in \mathbb{Z}$, which are auxiliary to the
bivariate polynomials $\Psi_n$ congruent to the bivariate $n$-division polynomials $\psi_n$. -/
noncomputable def preΨ (n : ℤ) : R[X] :=
preNormEDS (W.Ψ₂Sq ^ 2) W.Ψ₃ W.preΨ₄ n
@[simp]
lemma preΨ_ofNat (n : ℕ) : W.preΨ n = W.preΨ' n :=
preNormEDS_ofNat ..
@[simp]
lemma preΨ_zero : W.preΨ 0 = 0 :=
preNormEDS_zero ..
@[simp]
lemma preΨ_one : W.preΨ 1 = 1 :=
preNormEDS_one ..
@[simp]
lemma preΨ_two : W.preΨ 2 = 1 :=
preNormEDS_two ..
@[simp]
lemma preΨ_three : W.preΨ 3 = W.Ψ₃ :=
preNormEDS_three ..
@[simp]
lemma preΨ_four : W.preΨ 4 = W.preΨ₄ :=
preNormEDS_four ..
lemma preΨ_odd (m : ℕ) : W.preΨ (2 * (m + 2) + 1) =
W.preΨ (m + 4) * W.preΨ (m + 2) ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ (m + 1) * W.preΨ (m + 3) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2) :=
preNormEDS_odd ..
lemma preΨ_even (m : ℕ) : W.preΨ (2 * (m + 3)) =
W.preΨ (m + 2) ^ 2 * W.preΨ (m + 3) * W.preΨ (m + 5) -
W.preΨ (m + 1) * W.preΨ (m + 3) * W.preΨ (m + 4) ^ 2 :=
preNormEDS_even ..
@[simp]
lemma preΨ_neg (n : ℤ) : W.preΨ (-n) = -W.preΨ n :=
preNormEDS_neg ..
end preΨ
section ΨSq
/-! ### The univariate polynomials $\Psi_n^{[2]}$ -/
/-- The univariate polynomials $\Psi_n^{[2]}$ congruent to $\psi_n^2$. -/
noncomputable def ΨSq (n : ℤ) : R[X] :=
W.preΨ n ^ 2 * if Even n then W.Ψ₂Sq else 1
@[simp]
lemma ΨSq_ofNat (n : ℕ) : W.ΨSq n = W.preΨ' n ^ 2 * if Even n then W.Ψ₂Sq else 1 := by
simp only [ΨSq, preΨ_ofNat, Int.even_coe_nat]
@[simp]
lemma ΨSq_zero : W.ΨSq 0 = 0 := by
erw [ΨSq_ofNat, preΨ'_zero, zero_pow two_ne_zero, zero_mul]
@[simp]
lemma ΨSq_one : W.ΨSq 1 = 1 := by
erw [ΨSq_ofNat, preΨ'_one, one_pow, mul_one]
@[simp]
lemma ΨSq_two : W.ΨSq 2 = W.Ψ₂Sq := by
erw [ΨSq_ofNat, preΨ'_two, one_pow, one_mul, if_pos even_two]
@[simp]
lemma ΨSq_three : W.ΨSq 3 = W.Ψ₃ ^ 2 := by
erw [ΨSq_ofNat, preΨ'_three, mul_one]
@[simp]
lemma ΨSq_four : W.ΨSq 4 = W.preΨ₄ ^ 2 * W.Ψ₂Sq := by
erw [ΨSq_ofNat, preΨ'_four, if_pos <| by decide]
lemma ΨSq_odd (m : ℕ) : W.ΨSq (2 * (m + 2) + 1) =
(W.preΨ' (m + 4) * W.preΨ' (m + 2) ^ 3 * (if Even m then W.Ψ₂Sq ^ 2 else 1) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) ^ 3 * (if Even m then 1 else W.Ψ₂Sq ^ 2)) ^ 2 := by
erw [ΨSq_ofNat, preΨ'_odd, if_neg (m + 2).not_even_two_mul_add_one, mul_one]
lemma ΨSq_even (m : ℕ) : W.ΨSq (2 * (m + 3)) =
(W.preΨ' (m + 2) ^ 2 * W.preΨ' (m + 3) * W.preΨ' (m + 5) -
W.preΨ' (m + 1) * W.preΨ' (m + 3) * W.preΨ' (m + 4) ^ 2) ^ 2 * W.Ψ₂Sq := by
erw [ΨSq_ofNat, preΨ'_even, if_pos <| even_two_mul _]
@[simp]
lemma ΨSq_neg (n : ℤ) : W.ΨSq (-n) = W.ΨSq n := by
simp only [ΨSq, preΨ_neg, neg_sq, even_neg]
end ΨSq
section Ψ
/-! ### The bivariate polynomials $\Psi_n$ -/
/-- The bivariate polynomials $\Psi_n$ congruent to the $n$-division polynomials $\psi_n$. -/
protected noncomputable def Ψ (n : ℤ) : R[X][Y] :=
C (W.preΨ n) * if Even n then W.ψ₂ else 1
open WeierstrassCurve (Ψ)
@[simp]
lemma Ψ_ofNat (n : ℕ) : W.Ψ n = C (W.preΨ' n) * if Even n then W.ψ₂ else 1 := by
simp only [Ψ, preΨ_ofNat, Int.even_coe_nat]
@[simp]
lemma Ψ_zero : W.Ψ 0 = 0 := by
erw [Ψ_ofNat, preΨ'_zero, C_0, zero_mul]
@[simp]
lemma Ψ_one : W.Ψ 1 = 1 := by
erw [Ψ_ofNat, preΨ'_one, C_1, mul_one]
@[simp]
lemma Ψ_two : W.Ψ 2 = W.ψ₂ := by
erw [Ψ_ofNat, preΨ'_two, one_mul, if_pos even_two]
@[simp]
lemma Ψ_three : W.Ψ 3 = C W.Ψ₃ := by
erw [Ψ_ofNat, preΨ'_three, mul_one]
@[simp]
lemma Ψ_four : W.Ψ 4 = C W.preΨ₄ * W.ψ₂ := by
erw [Ψ_ofNat, preΨ'_four, if_pos <| by decide]
lemma Ψ_odd (m : ℕ) : W.Ψ (2 * (m + 2) + 1) =
W.Ψ (m + 4) * W.Ψ (m + 2) ^ 3 - W.Ψ (m + 1) * W.Ψ (m + 3) ^ 3 +
W.toAffine.polynomial * (16 * W.toAffine.polynomial - 8 * W.ψ₂ ^ 2) * C
(if Even m then W.preΨ' (m + 4) * W.preΨ' (m + 2) ^ 3
else -W.preΨ' (m + 1) * W.preΨ' (m + 3) ^ 3) := by
repeat erw [Ψ_ofNat]
simp_rw [preΨ'_odd, if_neg (m + 2).not_even_two_mul_add_one, Nat.even_add_one, ite_not]
split_ifs <;> C_simp <;> rw [C_Ψ₂Sq] <;> ring1
lemma Ψ_even (m : ℕ) : W.Ψ (2 * (m + 3)) * W.ψ₂ =
W.Ψ (m + 2) ^ 2 * W.Ψ (m + 3) * W.Ψ (m + 5) - W.Ψ (m + 1) * W.Ψ (m + 3) * W.Ψ (m + 4) ^ 2 := by
repeat erw [Ψ_ofNat]
simp_rw [preΨ'_even, if_pos <| even_two_mul _, Nat.even_add_one, ite_not]
split_ifs <;> C_simp <;> ring1
@[simp]
lemma Ψ_neg (n : ℤ) : W.Ψ (-n) = -W.Ψ n := by
simp only [Ψ, preΨ_neg, C_neg, neg_mul (α := R[X][Y]), even_neg]
lemma Affine.CoordinateRing.mk_Ψ_sq (n : ℤ) : mk W (W.Ψ n) ^ 2 = mk W (C <| W.ΨSq n) := by
simp only [Ψ, ΨSq, map_one, map_mul, map_pow, one_pow, mul_pow, ite_pow, apply_ite C,
apply_ite <| mk W, mk_ψ₂_sq]
end Ψ
section Φ
/-! ### The univariate polynomials $\Phi_n$ -/
/-- The univariate polynomials $\Phi_n$ congruent to $\phi_n$. -/
protected noncomputable def Φ (n : ℤ) : R[X] :=
X * W.ΨSq n - W.preΨ (n + 1) * W.preΨ (n - 1) * if Even n then 1 else W.Ψ₂Sq
open WeierstrassCurve (Φ)
@[simp]
lemma Φ_ofNat (n : ℕ) : W.Φ (n + 1) =
X * W.preΨ' (n + 1) ^ 2 * (if Even n then 1 else W.Ψ₂Sq) -
W.preΨ' (n + 2) * W.preΨ' n * (if Even n then W.Ψ₂Sq else 1) := by
erw [Φ, ΨSq_ofNat, ← mul_assoc, preΨ_ofNat, add_sub_cancel_right, preΨ_ofNat]
simp only [Nat.even_add_one, Int.even_add_one, Int.even_coe_nat, ite_not]
@[simp]
lemma Φ_zero : W.Φ 0 = 1 := by
rw [Φ, ΨSq_zero, mul_zero, zero_sub, zero_add, preΨ_one, one_mul, zero_sub, preΨ_neg, preΨ_one,
neg_one_mul, neg_neg, if_pos even_zero]
@[simp]
lemma Φ_one : W.Φ 1 = X := by
erw [Φ_ofNat, preΨ'_one, one_pow, mul_one, mul_one, preΨ'_zero, mul_zero, zero_mul, sub_zero]
@[simp]
lemma Φ_two : W.Φ 2 = X ^ 4 - C W.b₄ * X ^ 2 - C (2 * W.b₆) * X - C W.b₈ := by
erw [Φ_ofNat, preΨ'_two, if_neg Nat.not_even_one, Ψ₂Sq, preΨ'_three, preΨ'_one, mul_one, Ψ₃]
C_simp
ring1
@[simp]
lemma Φ_three : W.Φ 3 = X * W.Ψ₃ ^ 2 - W.preΨ₄ * W.Ψ₂Sq := by
erw [Φ_ofNat, preΨ'_three, mul_one, preΨ'_four, preΨ'_two, mul_one, if_pos even_two]
@[simp]
lemma Φ_four : W.Φ 4 = X * W.preΨ₄ ^ 2 * W.Ψ₂Sq - W.Ψ₃ * (W.preΨ₄ * W.Ψ₂Sq ^ 2 - W.Ψ₃ ^ 3) := by
erw [Φ_ofNat, preΨ'_four, if_neg <| by decide, show 3 + 2 = 2 * 2 + 1 by rfl, preΨ'_odd,
preΨ'_four, preΨ'_two, if_pos even_zero, preΨ'_one, preΨ'_three, if_pos even_zero]
ring1
@[simp]
lemma Φ_neg (n : ℤ) : W.Φ (-n) = W.Φ n := by
simp only [Φ, ΨSq_neg, neg_add_eq_sub, ← neg_sub n, preΨ_neg, ← neg_add', preΨ_neg, neg_mul_neg,
mul_comm <| W.preΨ <| n - 1, even_neg]
end Φ
section ψ
/-! ### The bivariate polynomials $\psi_n$ -/
/-- The bivariate $n$-division polynomials $\psi_n$. -/
protected noncomputable def ψ (n : ℤ) : R[X][Y] :=
normEDS W.ψ₂ (C W.Ψ₃) (C W.preΨ₄) n
open WeierstrassCurve (Ψ ψ)
@[simp]
lemma ψ_zero : W.ψ 0 = 0 :=
normEDS_zero ..
@[simp]
lemma ψ_one : W.ψ 1 = 1 :=
normEDS_one ..
@[simp]
lemma ψ_two : W.ψ 2 = W.ψ₂ :=
normEDS_two ..
@[simp]
lemma ψ_three : W.ψ 3 = C W.Ψ₃ :=
normEDS_three ..
@[simp]
lemma ψ_four : W.ψ 4 = C W.preΨ₄ * W.ψ₂ :=
normEDS_four ..
lemma ψ_odd (m : ℕ) : W.ψ (2 * (m + 2) + 1) =
W.ψ (m + 4) * W.ψ (m + 2) ^ 3 - W.ψ (m + 1) * W.ψ (m + 3) ^ 3 :=
normEDS_odd ..
lemma ψ_even (m : ℕ) : W.ψ (2 * (m + 3)) * W.ψ₂ =
W.ψ (m + 2) ^ 2 * W.ψ (m + 3) * W.ψ (m + 5) - W.ψ (m + 1) * W.ψ (m + 3) * W.ψ (m + 4) ^ 2 :=
normEDS_even ..
@[simp]
lemma ψ_neg (n : ℤ) : W.ψ (-n) = -W.ψ n :=
normEDS_neg ..
lemma Affine.CoordinateRing.mk_ψ (n : ℤ) : mk W (W.ψ n) = mk W (W.Ψ n) := by
simp only [ψ, normEDS, Ψ, preΨ, map_mul, map_pow, map_preNormEDS, ← mk_ψ₂_sq, ← pow_mul]
end ψ
section φ
/-! ### The bivariate polynomials $\phi_n$ -/
/-- The bivariate polynomials $\phi_n$. -/
protected noncomputable def φ (n : ℤ) : R[X][Y] :=
C X * W.ψ n ^ 2 - W.ψ (n + 1) * W.ψ (n - 1)
open WeierstrassCurve (Ψ Φ φ)
@[simp]
lemma φ_zero : W.φ 0 = 1 := by
erw [φ, ψ_zero, zero_pow two_ne_zero, mul_zero, zero_sub, ψ_one, one_mul,
zero_sub, ψ_neg, neg_neg, ψ_one]
@[simp]
lemma φ_one : W.φ 1 = C X := by
erw [φ, ψ_one, one_pow, mul_one, ψ_zero, mul_zero, sub_zero]
@[simp]
lemma φ_two : W.φ 2 = C X * W.ψ₂ ^ 2 - C W.Ψ₃ := by
erw [φ, ψ_two, ψ_three, ψ_one, mul_one]
@[simp]
lemma φ_three : W.φ 3 = C X * C W.Ψ₃ ^ 2 - C W.preΨ₄ * W.ψ₂ ^ 2 := by
erw [φ, ψ_three, ψ_four, mul_assoc, ψ_two, ← sq]
@[simp]
lemma φ_four :
W.φ 4 = C X * C W.preΨ₄ ^ 2 * W.ψ₂ ^ 2 - C W.preΨ₄ * W.ψ₂ ^ 4 * C W.Ψ₃ + C W.Ψ₃ ^ 4 := by
erw [φ, ψ_four, show (4 + 1 : ℤ) = 2 * 2 + 1 by rfl, ψ_odd, ψ_four, ψ_two, ψ_one, ψ_three]
ring1
@[simp]
lemma φ_neg (n : ℤ) : W.φ (-n) = W.φ n := by
rw [φ, ψ_neg, neg_sq (R := R[X][Y]), neg_add_eq_sub, ← neg_sub n, ψ_neg, ← neg_add', ψ_neg,
neg_mul_neg (α := R[X][Y]), mul_comm <| W.ψ _, φ]
lemma Affine.CoordinateRing.mk_φ (n : ℤ) : mk W (W.φ n) = mk W (C <| W.Φ n) := by
simp_rw [φ, Φ, map_sub, map_mul, map_pow, mk_ψ, mk_Ψ_sq, Ψ, map_mul,
mul_mul_mul_comm _ <| mk W <| ite .., Int.even_add_one, Int.even_sub_one, ← sq, ite_not,
apply_ite C, apply_ite <| mk W, ite_pow, map_one, one_pow, mk_ψ₂_sq]
end φ
section Map
/-! ### Maps across ring homomorphisms -/
open WeierstrassCurve (Ψ Φ ψ φ)
variable (f : R →+* S)
lemma map_ψ₂ : (W.map f).ψ₂ = W.ψ₂.map (mapRingHom f) := by
simp only [ψ₂, Affine.map_polynomialY]
lemma map_Ψ₂Sq : (W.map f).Ψ₂Sq = W.Ψ₂Sq.map f := by
simp only [Ψ₂Sq, map_b₂, map_b₄, map_b₆]
map_simp
lemma map_Ψ₃ : (W.map f).Ψ₃ = W.Ψ₃.map f := by
simp only [Ψ₃, map_b₂, map_b₄, map_b₆, map_b₈]
map_simp
lemma map_preΨ₄ : (W.map f).preΨ₄ = W.preΨ₄.map f := by
simp only [preΨ₄, map_b₂, map_b₄, map_b₆, map_b₈]
map_simp
lemma map_preΨ' (n : ℕ) : (W.map f).preΨ' n = (W.preΨ' n).map f := by
simp only [preΨ', map_Ψ₂Sq, map_Ψ₃, map_preΨ₄, ← coe_mapRingHom, map_preNormEDS']
map_simp
lemma map_preΨ (n : ℤ) : (W.map f).preΨ n = (W.preΨ n).map f := by
simp only [preΨ, map_Ψ₂Sq, map_Ψ₃, map_preΨ₄, ← coe_mapRingHom, map_preNormEDS]
map_simp
lemma map_ΨSq (n : ℤ) : (W.map f).ΨSq n = (W.ΨSq n).map f := by
simp only [ΨSq, map_preΨ, map_Ψ₂Sq, ← coe_mapRingHom]
map_simp
lemma map_Ψ (n : ℤ) : (W.map f).Ψ n = (W.Ψ n).map (mapRingHom f) := by
simp only [Ψ, map_preΨ, map_ψ₂, ← coe_mapRingHom]
map_simp
lemma map_Φ (n : ℤ) : (W.map f).Φ n = (W.Φ n).map f := by
simp only [Φ, map_ΨSq, map_preΨ, map_Ψ₂Sq, ← coe_mapRingHom]
map_simp
lemma map_ψ (n : ℤ) : (W.map f).ψ n = (W.ψ n).map (mapRingHom f) := by
simp only [ψ, map_ψ₂, map_Ψ₃, map_preΨ₄, ← coe_mapRingHom, map_normEDS]
map_simp
lemma map_φ (n : ℤ) : (W.map f).φ n = (W.φ n).map (mapRingHom f) := by
simp only [φ, map_ψ]
map_simp
end Map
section BaseChange
/-! ### Base changes across algebra homomorphisms -/
variable [Algebra R S] {A : Type u} [CommRing A] [Algebra R A] [Algebra S A] [IsScalarTower R S A]
{B : Type v} [CommRing B] [Algebra R B] [Algebra S B] [IsScalarTower R S B] (f : A →ₐ[S] B)
lemma baseChange_ψ₂ : (W.baseChange B).ψ₂ = (W.baseChange A).ψ₂.map (mapRingHom f) := by
rw [← map_ψ₂, map_baseChange]
lemma baseChange_Ψ₂Sq : (W.baseChange B).Ψ₂Sq = (W.baseChange A).Ψ₂Sq.map f := by
rw [← map_Ψ₂Sq, map_baseChange]
lemma baseChange_Ψ₃ : (W.baseChange B).Ψ₃ = (W.baseChange A).Ψ₃.map f := by
rw [← map_Ψ₃, map_baseChange]
lemma baseChange_preΨ₄ : (W.baseChange B).preΨ₄ = (W.baseChange A).preΨ₄.map f := by
rw [← map_preΨ₄, map_baseChange]
lemma baseChange_preΨ' (n : ℕ) : (W.baseChange B).preΨ' n = ((W.baseChange A).preΨ' n).map f := by
rw [← map_preΨ', map_baseChange]
lemma baseChange_preΨ (n : ℤ) : (W.baseChange B).preΨ n = ((W.baseChange A).preΨ n).map f := by
rw [← map_preΨ, map_baseChange]
lemma baseChange_ΨSq (n : ℤ) : (W.baseChange B).ΨSq n = ((W.baseChange A).ΨSq n).map f := by
rw [← map_ΨSq, map_baseChange]
lemma baseChange_Ψ (n : ℤ) : (W.baseChange B).Ψ n = ((W.baseChange A).Ψ n).map (mapRingHom f) := by
rw [← map_Ψ, map_baseChange]
lemma baseChange_Φ (n : ℤ) : (W.baseChange B).Φ n = ((W.baseChange A).Φ n).map f := by
rw [← map_Φ, map_baseChange]
lemma baseChange_ψ (n : ℤ) : (W.baseChange B).ψ n = ((W.baseChange A).ψ n).map (mapRingHom f) := by
rw [← map_ψ, map_baseChange]
lemma baseChange_φ (n : ℤ) : (W.baseChange B).φ n = ((W.baseChange A).φ n).map (mapRingHom f) := by
rw [← map_φ, map_baseChange]
end BaseChange
end WeierstrassCurve
|
AlgebraicGeometry\EllipticCurve\DivisionPolynomial\Degree.lean | /-
Copyright (c) 2024 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.AlgebraicGeometry.EllipticCurve.DivisionPolynomial.Basic
import Mathlib.Tactic.ComputeDegree
/-!
# Division polynomials of Weierstrass curves
This file computes the leading terms of certain polynomials associated to division polynomials of
Weierstrass curves defined in `Mathlib.AlgebraicGeometry.EllipticCurve.DivisionPolynomial.Basic`.
## Mathematical background
Let $W$ be a Weierstrass curve over a commutative ring $R$. By strong induction,
* $\tilde{\Psi}_n = \tfrac{n}{2}X^{\tfrac{n^2 - 4}{2}} + \dots$ if $n$ is even,
* $\tilde{\Psi}_n = nX^{\tfrac{n^2 - 1}{2}} + \dots$ if $n$ is odd,
* $\Psi_n^{[2]} = n^2X^{n^2 - 1} + \dots$, and
* $\Phi_n = X^{n^2} + \dots$.
In particular, when $R$ is an integral domain of characteristic different from $n$, the univariate
polynomials $\tilde{\Psi}_n$, $\Psi_n^{[2]}$, and $\Phi_n$ all have their expected leading terms.
## Main statements
* `WeierstrassCurve.natDegree_preΨ_le`: the expected degree of $\tilde{\Psi}_n$.
* `WeierstrassCurve.coeff_preΨ`: the expected leading coefficient of $\tilde{\Psi}_n$.
* `WeierstrassCurve.natDegree_preΨ`: the degree of $\tilde{\Psi}_n$ when $n \ne 0$.
* `WeierstrassCurve.leadingCoeff_preΨ`: the leading coefficient of $\tilde{\Psi}_n$ when $n \ne 0$.
* `WeierstrassCurve.natDegree_ΨSq_le`: the expected degree of $\Psi_n^{[2]}$.
* `WeierstrassCurve.coeff_ΨSq`: the expected leading coefficient of $\Psi_n^{[2]}$.
* `WeierstrassCurve.natDegree_ΨSq`: the degree of $\Psi_n^{[2]}$ when $n \ne 0$.
* `WeierstrassCurve.leadingCoeff_ΨSq`: the leading coefficient of $\Psi_n^{[2]}$ when $n \ne 0$.
* `WeierstrassCurve.natDegree_Φ_le`: the expected degree of $\Phi_n$.
* `WeierstrassCurve.coeff_Φ`: the expected leading coefficient of $\Phi_n$.
* `WeierstrassCurve.natDegree_Φ`: the degree of $\Phi_n$ when $n \ne 0$.
* `WeierstrassCurve.leadingCoeff_Φ`: the leading coefficient of $\Phi_n$ when $n \ne 0$.
## References
[J Silverman, *The Arithmetic of Elliptic Curves*][silverman2009]
## Tags
elliptic curve, division polynomial, torsion point
-/
open Polynomial
universe u
namespace WeierstrassCurve
variable {R : Type u} [CommRing R] (W : WeierstrassCurve R)
section Ψ₂Sq
lemma natDegree_Ψ₂Sq_le : W.Ψ₂Sq.natDegree ≤ 3 := by
rw [Ψ₂Sq]
compute_degree
@[simp]
lemma coeff_Ψ₂Sq : W.Ψ₂Sq.coeff 3 = 4 := by
rw [Ψ₂Sq]
compute_degree!
lemma coeff_Ψ₂Sq_ne_zero (h : (4 : R) ≠ 0) : W.Ψ₂Sq.coeff 3 ≠ 0 := by
rwa [coeff_Ψ₂Sq]
@[simp]
lemma natDegree_Ψ₂Sq (h : (4 : R) ≠ 0) : W.Ψ₂Sq.natDegree = 3 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_Ψ₂Sq_le <| W.coeff_Ψ₂Sq_ne_zero h
lemma natDegree_Ψ₂Sq_pos (h : (4 : R) ≠ 0) : 0 < W.Ψ₂Sq.natDegree :=
W.natDegree_Ψ₂Sq h ▸ three_pos
@[simp]
lemma leadingCoeff_Ψ₂Sq (h : (4 : R) ≠ 0) : W.Ψ₂Sq.leadingCoeff = 4 := by
rw [leadingCoeff, W.natDegree_Ψ₂Sq h, coeff_Ψ₂Sq]
lemma Ψ₂Sq_ne_zero (h : (4 : R) ≠ 0) : W.Ψ₂Sq ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_Ψ₂Sq_pos h
end Ψ₂Sq
section Ψ₃
lemma natDegree_Ψ₃_le : W.Ψ₃.natDegree ≤ 4 := by
rw [Ψ₃]
compute_degree
@[simp]
lemma coeff_Ψ₃ : W.Ψ₃.coeff 4 = 3 := by
rw [Ψ₃]
compute_degree!
lemma coeff_Ψ₃_ne_zero (h : (3 : R) ≠ 0) : W.Ψ₃.coeff 4 ≠ 0 := by
rwa [coeff_Ψ₃]
@[simp]
lemma natDegree_Ψ₃ (h : (3 : R) ≠ 0) : W.Ψ₃.natDegree = 4 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_Ψ₃_le <| W.coeff_Ψ₃_ne_zero h
lemma natDegree_Ψ₃_pos (h : (3 : R) ≠ 0) : 0 < W.Ψ₃.natDegree :=
W.natDegree_Ψ₃ h ▸ four_pos
@[simp]
lemma leadingCoeff_Ψ₃ (h : (3 : R) ≠ 0) : W.Ψ₃.leadingCoeff = 3 := by
rw [leadingCoeff, W.natDegree_Ψ₃ h, coeff_Ψ₃]
lemma Ψ₃_ne_zero (h : (3 : R) ≠ 0) : W.Ψ₃ ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_Ψ₃_pos h
end Ψ₃
section preΨ₄
lemma natDegree_preΨ₄_le : W.preΨ₄.natDegree ≤ 6 := by
rw [preΨ₄]
compute_degree
@[simp]
lemma coeff_preΨ₄ : W.preΨ₄.coeff 6 = 2 := by
rw [preΨ₄]
compute_degree!
lemma coeff_preΨ₄_ne_zero (h : (2 : R) ≠ 0) : W.preΨ₄.coeff 6 ≠ 0 := by
rwa [coeff_preΨ₄]
@[simp]
lemma natDegree_preΨ₄ (h : (2 : R) ≠ 0) : W.preΨ₄.natDegree = 6 :=
natDegree_eq_of_le_of_coeff_ne_zero W.natDegree_preΨ₄_le <| W.coeff_preΨ₄_ne_zero h
lemma natDegree_preΨ₄_pos (h : (2 : R) ≠ 0) : 0 < W.preΨ₄.natDegree := by
linarith only [W.natDegree_preΨ₄ h]
@[simp]
lemma leadingCoeff_preΨ₄ (h : (2 : R) ≠ 0) : W.preΨ₄.leadingCoeff = 2 := by
rw [leadingCoeff, W.natDegree_preΨ₄ h, coeff_preΨ₄]
lemma preΨ₄_ne_zero (h : (2 : R) ≠ 0) : W.preΨ₄ ≠ 0 :=
ne_zero_of_natDegree_gt <| W.natDegree_preΨ₄_pos h
end preΨ₄
section preΨ'
private def expDegree (n : ℕ) : ℕ :=
(n ^ 2 - if Even n then 4 else 1) / 2
private lemma expDegree_cast {n : ℕ} (hn : n ≠ 0) :
2 * (expDegree n : ℤ) = n ^ 2 - if Even n then 4 else 1 := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩
· rcases n with _ | n
· contradiction
push_cast [expDegree, show (2 * (n + 1)) ^ 2 = 2 * (2 * n * (n + 2)) + 4 by ring1, even_two_mul,
Nat.add_sub_cancel, Nat.mul_div_cancel_left _ two_pos]
ring1
· push_cast [expDegree, show (2 * n + 1) ^ 2 = 2 * (2 * n * (n + 1)) + 1 by ring1,
n.not_even_two_mul_add_one, Nat.add_sub_cancel, Nat.mul_div_cancel_left _ two_pos]
ring1
private lemma expDegree_rec (m : ℕ) :
(expDegree (2 * (m + 3)) = 2 * expDegree (m + 2) + expDegree (m + 3) + expDegree (m + 5) ∧
expDegree (2 * (m + 3)) = expDegree (m + 1) + expDegree (m + 3) + 2 * expDegree (m + 4)) ∧
(expDegree (2 * (m + 2) + 1) =
expDegree (m + 4) + 3 * expDegree (m + 2) + (if Even m then 2 * 3 else 0) ∧
expDegree (2 * (m + 2) + 1) =
expDegree (m + 1) + 3 * expDegree (m + 3) + (if Even m then 0 else 2 * 3)) := by
push_cast [← @Nat.cast_inj ℤ, ← mul_left_cancel_iff_of_pos (b := (expDegree _ : ℤ)) two_pos,
mul_add, mul_left_comm (2 : ℤ)]
repeat rw [expDegree_cast <| by omega]
push_cast [Nat.even_add_one, ite_not, even_two_mul]
constructor <;> constructor <;> split_ifs <;> ring1
private def expCoeff (n : ℕ) : ℤ :=
if Even n then n / 2 else n
private lemma expCoeff_cast (n : ℕ) : (expCoeff n : ℚ) = if Even n then (n / 2 : ℚ) else n := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;> simp [expCoeff, n.not_even_two_mul_add_one]
private lemma expCoeff_rec (m : ℕ) :
(expCoeff (2 * (m + 3)) =
expCoeff (m + 2) ^ 2 * expCoeff (m + 3) * expCoeff (m + 5) -
expCoeff (m + 1) * expCoeff (m + 3) * expCoeff (m + 4) ^ 2) ∧
(expCoeff (2 * (m + 2) + 1) =
expCoeff (m + 4) * expCoeff (m + 2) ^ 3 * (if Even m then 4 ^ 2 else 1) -
expCoeff (m + 1) * expCoeff (m + 3) ^ 3 * (if Even m then 1 else 4 ^ 2)) := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast, even_two_mul, m.not_even_two_mul_add_one,
Nat.even_add_one, ite_not]
constructor <;> split_ifs <;> ring1
private lemma natDegree_coeff_preΨ' (n : ℕ) :
(W.preΨ' n).natDegree ≤ expDegree n ∧ (W.preΨ' n).coeff (expDegree n) = expCoeff n := by
let dm {m n p q} : _ → _ → (p * q : R[X]).natDegree ≤ m + n := natDegree_mul_le_of_le
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let cm {m n p q} : _ → _ → (p * q : R[X]).coeff (m + n) = _ := coeff_mul_of_natDegree_le
let cp {m n p} : _ → (p ^ m : R[X]).coeff (m * n) = _ := coeff_pow_of_natDegree_le
induction n using normEDSRec with
| zero => simpa only [preΨ'_zero] using ⟨by rfl, Int.cast_zero.symm⟩
| one => simpa only [preΨ'_one] using ⟨natDegree_one.le, coeff_one_zero.trans Int.cast_one.symm⟩
| two => simpa only [preΨ'_two] using ⟨natDegree_one.le, coeff_one_zero.trans Int.cast_one.symm⟩
| three => simpa only [preΨ'_three] using ⟨W.natDegree_Ψ₃_le, W.coeff_Ψ₃ ▸ Int.cast_three.symm⟩
| four => simpa only [preΨ'_four] using ⟨W.natDegree_preΨ₄_le, W.coeff_preΨ₄ ▸ Int.cast_two.symm⟩
| even m h₁ h₂ h₃ h₄ h₅ =>
constructor
· nth_rw 1 [preΨ'_even, ← max_self <| expDegree _, (expDegree_rec m).1.1, (expDegree_rec m).1.2]
exact natDegree_sub_le_of_le (dm (dm (dp h₂.1) h₃.1) h₅.1) (dm (dm h₁.1 h₃.1) (dp h₄.1))
· nth_rw 1 [preΨ'_even, coeff_sub, (expDegree_rec m).1.1, cm (dm (dp h₂.1) h₃.1) h₅.1,
cm (dp h₂.1) h₃.1, cp h₂.1, h₂.2, h₃.2, h₅.2, (expDegree_rec m).1.2,
cm (dm h₁.1 h₃.1) (dp h₄.1), cm h₁.1 h₃.1, h₁.2, cp h₄.1, h₃.2, h₄.2, (expCoeff_rec m).1]
norm_cast
| odd m h₁ h₂ h₃ h₄ =>
rw [preΨ'_odd]
constructor
· nth_rw 1 [← max_self <| expDegree _, (expDegree_rec m).2.1, (expDegree_rec m).2.2]
refine natDegree_sub_le_of_le (dm (dm h₄.1 (dp h₂.1)) ?_) (dm (dm h₁.1 (dp h₃.1)) ?_)
all_goals split_ifs <;>
simp only [apply_ite natDegree, natDegree_one.le, dp W.natDegree_Ψ₂Sq_le]
· nth_rw 1 [coeff_sub, (expDegree_rec m).2.1, cm (dm h₄.1 (dp h₂.1)), cm h₄.1 (dp h₂.1),
h₄.2, cp h₂.1, h₂.2, apply_ite₂ coeff, cp W.natDegree_Ψ₂Sq_le, coeff_Ψ₂Sq, coeff_one_zero,
(expDegree_rec m).2.2, cm (dm h₁.1 (dp h₃.1)), cm h₁.1 (dp h₃.1), h₁.2, cp h₃.1, h₃.2,
apply_ite₂ coeff, cp W.natDegree_Ψ₂Sq_le, coeff_one_zero, coeff_Ψ₂Sq, (expCoeff_rec m).2]
· norm_cast
all_goals split_ifs <;>
simp only [apply_ite natDegree, natDegree_one.le, dp W.natDegree_Ψ₂Sq_le]
lemma natDegree_preΨ'_le (n : ℕ) : (W.preΨ' n).natDegree ≤ (n ^ 2 - if Even n then 4 else 1) / 2 :=
(W.natDegree_coeff_preΨ' n).left
@[simp]
lemma coeff_preΨ' (n : ℕ) : (W.preΨ' n).coeff ((n ^ 2 - if Even n then 4 else 1) / 2) =
if Even n then n / 2 else n := by
convert (W.natDegree_coeff_preΨ' n).right using 1
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;> simp [expCoeff, n.not_even_two_mul_add_one]
lemma coeff_preΨ'_ne_zero {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).coeff ((n ^ 2 - if Even n then 4 else 1) / 2) ≠ 0 := by
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩
· rw [coeff_preΨ', if_pos <| even_two_mul n, n.mul_div_cancel_left two_pos]
exact right_ne_zero_of_mul <| by rwa [← Nat.cast_mul]
· rwa [coeff_preΨ', if_neg n.not_even_two_mul_add_one]
@[simp]
lemma natDegree_preΨ' {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).natDegree = (n ^ 2 - if Even n then 4 else 1) / 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_preΨ'_le n) <| W.coeff_preΨ'_ne_zero h
lemma natDegree_preΨ'_pos {n : ℕ} (hn : 2 < n) (h : (n : R) ≠ 0) : 0 < (W.preΨ' n).natDegree := by
rw [W.natDegree_preΨ' h, Nat.div_pos_iff two_ne_zero]
split_ifs <;>
exact Nat.AtLeastTwo.prop.trans <| Nat.sub_le_sub_right (Nat.pow_le_pow_of_le_left hn 2) _
@[simp]
lemma leadingCoeff_preΨ' {n : ℕ} (h : (n : R) ≠ 0) :
(W.preΨ' n).leadingCoeff = if Even n then n / 2 else n := by
rw [leadingCoeff, W.natDegree_preΨ' h, coeff_preΨ']
lemma preΨ'_ne_zero [Nontrivial R] {n : ℕ} (h : (n : R) ≠ 0) : W.preΨ' n ≠ 0 := by
by_cases hn : 2 < n
· exact ne_zero_of_natDegree_gt <| W.natDegree_preΨ'_pos hn h
· rcases n with _ | _ | _ <;> aesop
end preΨ'
section preΨ
lemma natDegree_preΨ_le (n : ℤ) : (W.preΨ n).natDegree ≤
(n.natAbs ^ 2 - if Even n then 4 else 1) / 2 := by
induction n using Int.negInduction with
| nat n => exact_mod_cast W.preΨ_ofNat n ▸ W.natDegree_preΨ'_le n
| neg => simpa only [preΨ_neg, natDegree_neg, Int.natAbs_neg, even_neg]
@[simp]
lemma coeff_preΨ (n : ℤ) : (W.preΨ n).coeff ((n.natAbs ^ 2 - if Even n then 4 else 1) / 2) =
if Even n then n / 2 else n := by
induction n using Int.negInduction with
| nat n => exact_mod_cast W.preΨ_ofNat n ▸ W.coeff_preΨ' n
| neg n ih =>
simp only [preΨ_neg, coeff_neg, Int.natAbs_neg, even_neg]
rcases n.even_or_odd' with ⟨n, rfl | rfl⟩ <;>
push_cast [even_two_mul, Int.not_even_two_mul_add_one, Int.neg_ediv_of_dvd ⟨n, rfl⟩] at * <;>
rw [ih]
lemma coeff_preΨ_ne_zero {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).coeff ((n.natAbs ^ 2 - if Even n then 4 else 1) / 2) ≠ 0 := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat, Int.even_coe_nat]
using W.coeff_preΨ'_ne_zero <| by exact_mod_cast h
| neg n ih => simpa only [preΨ_neg, coeff_neg, neg_ne_zero, Int.natAbs_neg, even_neg]
using ih <| neg_ne_zero.mp <| by exact_mod_cast h
@[simp]
lemma natDegree_preΨ {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).natDegree = (n.natAbs ^ 2 - if Even n then 4 else 1) / 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_preΨ_le n) <| W.coeff_preΨ_ne_zero h
lemma natDegree_preΨ_pos {n : ℤ} (hn : 2 < n.natAbs) (h : (n : R) ≠ 0) :
0 < (W.preΨ n).natDegree := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat] using W.natDegree_preΨ'_pos hn <| by exact_mod_cast h
| neg n ih => simpa only [preΨ_neg, natDegree_neg]
using ih (by rwa [← Int.natAbs_neg]) <| neg_ne_zero.mp <| by exact_mod_cast h
@[simp]
lemma leadingCoeff_preΨ {n : ℤ} (h : (n : R) ≠ 0) :
(W.preΨ n).leadingCoeff = if Even n then n / 2 else n := by
rw [leadingCoeff, W.natDegree_preΨ h, coeff_preΨ]
lemma preΨ_ne_zero [Nontrivial R] {n : ℤ} (h : (n : R) ≠ 0) : W.preΨ n ≠ 0 := by
induction n using Int.negInduction with
| nat n => simpa only [preΨ_ofNat] using W.preΨ'_ne_zero <| by exact_mod_cast h
| neg n ih => simpa only [preΨ_neg, neg_ne_zero] using ih <| neg_ne_zero.mp <| by exact_mod_cast h
end preΨ
section ΨSq
private lemma natDegree_coeff_ΨSq_ofNat (n : ℕ) :
(W.ΨSq n).natDegree ≤ n ^ 2 - 1 ∧ (W.ΨSq n).coeff (n ^ 2 - 1) = (n ^ 2 : ℤ) := by
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let h {n} := W.natDegree_coeff_preΨ' n
rcases n with _ | n
· simp
have hd : (n + 1) ^ 2 - 1 = 2 * expDegree (n + 1) + if Even (n + 1) then 3 else 0 := by
push_cast [← @Nat.cast_inj ℤ, add_sq, expDegree_cast (by omega : n + 1 ≠ 0)]
split_ifs <;> ring1
have hc : (n + 1) ^ 2 = expCoeff (n + 1) ^ 2 * if Even (n + 1) then 4 else 1 := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast]
split_ifs <;> ring1
rw [ΨSq_ofNat, hd]
constructor
· refine natDegree_mul_le_of_le (dp h.1) ?_
split_ifs <;> simp only [apply_ite natDegree, natDegree_one.le, W.natDegree_Ψ₂Sq_le]
· erw [coeff_mul_of_natDegree_le (dp h.1), coeff_pow_of_natDegree_le h.1, h.2, apply_ite₂ coeff,
coeff_Ψ₂Sq, coeff_one_zero, hc]
· norm_cast
split_ifs <;> simp only [apply_ite natDegree, natDegree_one.le, W.natDegree_Ψ₂Sq_le]
lemma natDegree_ΨSq_le (n : ℤ) : (W.ΨSq n).natDegree ≤ n.natAbs ^ 2 - 1 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_ΨSq_ofNat n).left
| neg => rwa [ΨSq_neg, Int.natAbs_neg]
@[simp]
lemma coeff_ΨSq (n : ℤ) : (W.ΨSq n).coeff (n.natAbs ^ 2 - 1) = n ^ 2 := by
induction n using Int.negInduction with
| nat n => exact_mod_cast (W.natDegree_coeff_ΨSq_ofNat n).right
| neg => rwa [ΨSq_neg, Int.natAbs_neg, ← Int.cast_pow, neg_sq, Int.cast_pow]
lemma coeff_ΨSq_ne_zero [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).coeff (n.natAbs ^ 2 - 1) ≠ 0 := by
rwa [coeff_ΨSq, pow_ne_zero_iff two_ne_zero]
@[simp]
lemma natDegree_ΨSq [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).natDegree = n.natAbs ^ 2 - 1 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_ΨSq_le n) <| W.coeff_ΨSq_ne_zero h
lemma natDegree_ΨSq_pos [NoZeroDivisors R] {n : ℤ} (hn : 1 < n.natAbs) (h : (n : R) ≠ 0) :
0 < (W.ΨSq n).natDegree := by
rwa [W.natDegree_ΨSq h, Nat.sub_pos_iff_lt, Nat.one_lt_pow_iff two_ne_zero]
@[simp]
lemma leadingCoeff_ΨSq [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) :
(W.ΨSq n).leadingCoeff = n ^ 2 := by
rw [leadingCoeff, W.natDegree_ΨSq h, coeff_ΨSq]
lemma ΨSq_ne_zero [NoZeroDivisors R] {n : ℤ} (h : (n : R) ≠ 0) : W.ΨSq n ≠ 0 := by
by_cases hn : 1 < n.natAbs
· exact ne_zero_of_natDegree_gt <| W.natDegree_ΨSq_pos hn h
· rcases hm : n.natAbs with _ | m
· push_cast [Int.natAbs_eq_zero.mp hm, ne_self_iff_false] at h
· rcases Int.natAbs_eq_iff.mp hm with rfl | rfl <;>
rw [hm, Nat.lt_add_left_iff_pos, Nat.not_lt_eq, Nat.le_zero] at hn <;>
push_cast [hn, ΨSq_neg, ΨSq_one] <;>
exact fun h' => h <| C_injective <| by push_cast [hn, C_neg, C_1, h', neg_zero, C_0]; rfl
end ΨSq
section Φ
private lemma natDegree_coeff_Φ_ofNat (n : ℕ) :
(W.Φ n).natDegree ≤ n ^ 2 ∧ (W.Φ n).coeff (n ^ 2) = 1 := by
let dm {m n p q} : _ → _ → (p * q : R[X]).natDegree ≤ m + n := natDegree_mul_le_of_le
let dp {m n p} : _ → (p ^ n : R[X]).natDegree ≤ n * m := natDegree_pow_le_of_le n
let cm {m n p q} : _ → _ → (p * q : R[X]).coeff (m + n) = _ := coeff_mul_of_natDegree_le
let h {n} := W.natDegree_coeff_preΨ' n
rcases n with _ | _ | n
· simp
· simp [natDegree_X_le]
have hd : (n + 1 + 1) ^ 2 = 1 + 2 * expDegree (n + 2) + if Even (n + 1) then 0 else 3 := by
push_cast [← @Nat.cast_inj ℤ, expDegree_cast (by omega : n + 2 ≠ 0), Nat.even_add_one, ite_not]
split_ifs <;> ring1
have hd' : (n + 1 + 1) ^ 2 =
expDegree (n + 3) + expDegree (n + 1) + if Even (n + 1) then 3 else 0 := by
push_cast [← @Nat.cast_inj ℤ, ← mul_left_cancel_iff_of_pos (b := (_ ^ 2 : ℤ)) two_pos, mul_add,
expDegree_cast (by omega : n + 3 ≠ 0), expDegree_cast (by omega : n + 1 ≠ 0),
Nat.even_add_one, ite_not]
split_ifs <;> ring1
have hc : (1 : ℤ) = 1 * expCoeff (n + 2) ^ 2 * (if Even (n + 1) then 1 else 4) -
expCoeff (n + 3) * expCoeff (n + 1) * (if Even (n + 1) then 4 else 1) := by
push_cast [← @Int.cast_inj ℚ, expCoeff_cast, Nat.even_add_one, ite_not]
split_ifs <;> ring1
erw [Φ_ofNat]
constructor
· nth_rw 1 [← max_self <| (_ + _) ^ 2, hd, hd']
refine natDegree_sub_le_of_le (dm (dm natDegree_X_le (dp h.1)) ?_) (dm (dm h.1 h.1) ?_)
all_goals split_ifs <;> simp only [apply_ite natDegree, natDegree_one.le, W.natDegree_Ψ₂Sq_le]
· nth_rw 1 [coeff_sub, hd, hd', cm (dm natDegree_X_le (dp h.1)), cm natDegree_X_le (dp h.1),
coeff_X_one, coeff_pow_of_natDegree_le h.1, h.2, apply_ite₂ coeff, coeff_one_zero, coeff_Ψ₂Sq,
cm (dm h.1 h.1), cm h.1 h.1, h.2, h.2, apply_ite₂ coeff, coeff_one_zero, coeff_Ψ₂Sq]
conv_rhs => rw [← Int.cast_one, hc]
· norm_cast
all_goals split_ifs <;> simp only [apply_ite natDegree, natDegree_one.le, W.natDegree_Ψ₂Sq_le]
lemma natDegree_Φ_le (n : ℤ) : (W.Φ n).natDegree ≤ n.natAbs ^ 2 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_Φ_ofNat n).left
| neg => rwa [Φ_neg, Int.natAbs_neg]
@[simp]
lemma coeff_Φ (n : ℤ) : (W.Φ n).coeff (n.natAbs ^ 2) = 1 := by
induction n using Int.negInduction with
| nat n => exact (W.natDegree_coeff_Φ_ofNat n).right
| neg => rwa [Φ_neg, Int.natAbs_neg]
lemma coeff_Φ_ne_zero [Nontrivial R] (n : ℤ) : (W.Φ n).coeff (n.natAbs ^ 2) ≠ 0 :=
W.coeff_Φ n ▸ one_ne_zero
@[simp]
lemma natDegree_Φ [Nontrivial R] (n : ℤ) : (W.Φ n).natDegree = n.natAbs ^ 2 :=
natDegree_eq_of_le_of_coeff_ne_zero (W.natDegree_Φ_le n) <| W.coeff_Φ_ne_zero n
lemma natDegree_Φ_pos [Nontrivial R] {n : ℤ} (hn : n ≠ 0) : 0 < (W.Φ n).natDegree := by
rwa [natDegree_Φ, pow_pos_iff two_ne_zero, Int.natAbs_pos]
@[simp]
lemma leadingCoeff_Φ [Nontrivial R] (n : ℤ) : (W.Φ n).leadingCoeff = 1 := by
rw [leadingCoeff, natDegree_Φ, coeff_Φ]
lemma Φ_ne_zero [Nontrivial R] (n : ℤ) : W.Φ n ≠ 0 := by
by_cases hn : n = 0
· simpa only [hn, Φ_zero] using one_ne_zero
· exact ne_zero_of_natDegree_gt <| W.natDegree_Φ_pos hn
end Φ
end WeierstrassCurve
|
AlgebraicGeometry\Modules\Presheaf.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Category.ModuleCat.Presheaf
import Mathlib.AlgebraicGeometry.Scheme
import Mathlib.CategoryTheory.Sites.Whiskering
/-!
# The category of presheaves of modules over a scheme
In this file, given a scheme `X`, we define the category of presheaves
of modules over `X`. As categories of presheaves of modules are
defined for presheaves of rings (and not presheaves of commutative rings),
we also introduce a definition `X.ringCatSheaf` for the underlying sheaf
of rings of `X`.
-/
universe u
open CategoryTheory
namespace AlgebraicGeometry.Scheme
variable (X : Scheme.{u})
/-- The underlying sheaf of rings of a scheme. -/
abbrev ringCatSheaf : TopCat.Sheaf RingCat.{u} X :=
(sheafCompose _ (forget₂ CommRingCat RingCat)).obj X.sheaf
/-- The category of presheaves of modules over a scheme. -/
nonrec abbrev PresheafOfModules := PresheafOfModules.{u} X.ringCatSheaf.val
end AlgebraicGeometry.Scheme
|
AlgebraicGeometry\Modules\Sheaf.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Category.ModuleCat.Sheaf.Abelian
import Mathlib.AlgebraicGeometry.Modules.Presheaf
/-!
# The category of sheaves of modules over a scheme
In this file, we define the abelian category of sheaves of modules
`X.Modules` over a scheme `X`.
-/
universe u
open CategoryTheory
namespace AlgebraicGeometry.Scheme
variable (X : Scheme.{u})
/-- The category of sheaves of modules over a scheme. -/
abbrev Modules := SheafOfModules.{u} X.ringCatSheaf
noncomputable instance : Abelian X.Modules := inferInstance
end AlgebraicGeometry.Scheme
|
AlgebraicGeometry\Modules\Tilde.lean | /-
Copyright (c) 2024 Weihong Xu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Weihong Xu
-/
import Mathlib.Algebra.Module.LocalizedModule
import Mathlib.AlgebraicGeometry.StructureSheaf
import Mathlib.AlgebraicGeometry.Modules.Sheaf
import Mathlib.Algebra.Category.ModuleCat.Sheaf
/-!
# Construction of M^~
Given any commutative ring `R` and `R`-module `M`, we construct the sheaf `M^~` of `𝒪_SpecR`-modules
such that `M^~(U)` is the set of dependent functions that are locally fractions.
## Main definitions
* `ModuleCat.tildeInAddCommGrp` : `M^~` as a sheaf of abelian groups.
* `ModuleCat.tilde` : `M^~` as a sheaf of `𝒪_{Spec R}`-modules.
-/
universe u
open TopCat AlgebraicGeometry TopologicalSpace CategoryTheory Opposite
variable {R : Type u} [CommRing R] (M : ModuleCat.{u} R)
namespace ModuleCat
namespace Tilde
/-- For an `R`-module `M` and a point `P` in `Spec R`, `Localizations P` is the localized module
`M` at the prime ideal `P`. -/
abbrev Localizations (P : PrimeSpectrum.Top R) :=
LocalizedModule P.asIdeal.primeCompl M
/-- For any open subset `U ⊆ Spec R`, `IsFraction` is the predicate expressing that a function
`f : ∏_{x ∈ U}, Mₓ` is such that for any `𝔭 ∈ U`, `f 𝔭 = m / s` for some `m : M` and `s ∉ 𝔭`.
In short `f` is a fraction on `U`. -/
def isFraction {U : Opens (PrimeSpectrum R)} (f : ∀ 𝔭 : U, Localizations M 𝔭.1) : Prop :=
∃ (m : M) (s : R),
∀ x : U, ¬s ∈ x.1.asIdeal ∧ s • f x = LocalizedModule.mkLinearMap x.1.asIdeal.primeCompl M m
/--
The property of a function `f : ∏_{x ∈ U}, Mₓ` being a fraction is stable under restriction.
-/
def isFractionPrelocal : PrelocalPredicate (Localizations M) where
pred {U} f := isFraction M f
res := by rintro V U i f ⟨m, s, w⟩; exact ⟨m, s, fun x => w (i x)⟩
/--
For any open subset `U ⊆ Spec R`, `IsLocallyFraction` is the predicate expressing that a function
`f : ∏_{x ∈ U}, Mₓ` is such that for any `𝔭 ∈ U`, there exists an open neighbourhood `V ∋ 𝔭`, such
that for any `𝔮 ∈ V`, `f 𝔮 = m / s` for some `m : M` and `s ∉ 𝔮`.
In short `f` is locally a fraction on `U`.
-/
def isLocallyFraction : LocalPredicate (Localizations M) := (isFractionPrelocal M).sheafify
@[simp]
theorem isLocallyFraction_pred {U : Opens (PrimeSpectrum.Top R)}
(f : ∀ x : U, Localizations M x) :
(isLocallyFraction M).pred f =
∀ y : U,
∃ (V : _) (_ : y.1 ∈ V) (i : V ⟶ U),
∃ (m : M) (s: R), ∀ x : V, ¬s ∈ x.1.asIdeal ∧ s • f (i x) =
LocalizedModule.mkLinearMap x.1.asIdeal.primeCompl M m :=
rfl
/- M_x is an O_SpecR(U)-module when x is in U -/
noncomputable instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) (x : U.unop):
Module ((Spec.structureSheaf R).val.obj U) (Localizations M x):=
Module.compHom (R := (Localization.AtPrime x.1.asIdeal)) _
(StructureSheaf.openToLocalization R U.unop x x.2 :
(Spec.structureSheaf R).val.obj U →+* Localization.AtPrime x.1.asIdeal)
@[simp]
lemma sections_smul_localizations_def
{U : (Opens (PrimeSpectrum.Top R))ᵒᵖ} (x : U.unop)
(r : (Spec.structureSheaf R).val.obj U)
(m : Localizations M ↑x) :
r • m = r.1 x • m := rfl
/--
For any `R`-module `M` and any open subset `U ⊆ Spec R`, `M^~(U)` is an `𝒪_{Spec R}(U)`-submodule
of `∏_{𝔭 ∈ U} M_𝔭`. -/
def sectionsSubmodule (U : (Opens (PrimeSpectrum R))ᵒᵖ) :
Submodule ((Spec.structureSheaf R).1.obj U) (∀ x : U.unop, Localizations M x.1) where
carrier := { f | (isLocallyFraction M).pred f }
zero_mem' x := ⟨unop U, x.2, 𝟙 _, 0, 1, fun y =>
⟨Ideal.ne_top_iff_one _ |>.1 y.1.isPrime.1, by simp⟩⟩
add_mem' := by
intro a b ha hb x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases hb x with ⟨Vb, mb, ib, rb, sb, wb⟩
refine ⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, sb• ra+ sa•rb , sa * sb, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y : Va) with ⟨nma, wa⟩
rcases wb (Opens.infLERight _ _ y : Vb) with ⟨nmb, wb⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [Opens.coe_inf, Pi.add_apply, smul_add, map_add,
LinearMapClass.map_smul] at wa wb ⊢
rw [← wa, ← wb, ← mul_smul, ← mul_smul]
congr 2
simp [mul_comm]
smul_mem' := by
intro r a ha x
rcases ha x with ⟨Va, ma, ia, ra, sa, wa⟩
rcases r.2 x with ⟨Vr, mr, ir, rr, sr, wr⟩
refine ⟨Va ⊓ Vr, ⟨ma, mr⟩, Opens.infLELeft _ _ ≫ ia, rr•ra, sr*sa, ?_⟩
intro y
rcases wa (Opens.infLELeft _ _ y : Va) with ⟨nma, wa⟩
rcases wr (Opens.infLERight _ _ y) with ⟨nmr, wr⟩
fconstructor
· intro H; cases y.1.isPrime.mem_or_mem H <;> contradiction
· simp only [Opens.coe_inf, Pi.smul_apply, LinearMapClass.map_smul] at wa wr ⊢
rw [mul_comm, ← Algebra.smul_def] at wr
rw [sections_smul_localizations_def, ← wa, ← mul_smul, ← smul_assoc, mul_comm sr, mul_smul,
wr, mul_comm rr, Algebra.smul_def, ← map_mul]
rfl
end Tilde
/--
For any `R`-module `M`, `TildeInType R M` is the sheaf of set on `Spec R` whose sections on `U` are
the dependent functions that are locally fractions. This is often denoted by `M^~`.
See also `Tilde.isLocallyFraction`.
-/
def tildeInType : Sheaf (Type u) (PrimeSpectrum.Top R) :=
subsheafToTypes (Tilde.isLocallyFraction M)
instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
AddCommGroup (M.tildeInType.1.obj U) :=
inferInstanceAs $ AddCommGroup (Tilde.sectionsSubmodule M U)
/--
`M^~` as a presheaf of abelian groups over `Spec R`
-/
def preTildeInAddCommGrp : Presheaf AddCommGrp (PrimeSpectrum.Top R) where
obj U := .of ((M.tildeInType).1.obj U)
map {U V} i :=
{ toFun := M.tildeInType.1.map i
map_zero' := rfl
map_add' := fun x y => rfl}
/--
`M^~` as a sheaf of abelian groups over `Spec R`
-/
def tildeInAddCommGrp : Sheaf AddCommGrp (PrimeSpectrum.Top R) :=
⟨M.preTildeInAddCommGrp,
TopCat.Presheaf.isSheaf_iff_isSheaf_comp (forget AddCommGrp) _ |>.mpr
(TopCat.Presheaf.isSheaf_of_iso (NatIso.ofComponents (fun _ => Iso.refl _) fun _ => rfl)
M.tildeInType.2)⟩
noncomputable instance (U : (Opens (PrimeSpectrum.Top R))ᵒᵖ) :
Module ((Spec (.of R)).ringCatSheaf.1.obj U) (M.tildeInAddCommGrp.1.obj U) :=
inferInstanceAs $ Module _ (Tilde.sectionsSubmodule M U)
/--
`M^~` as a sheaf of `𝒪_{Spec R}`-modules
-/
noncomputable def tilde : (Spec (CommRingCat.of R)).Modules where
val :=
{ presheaf := M.tildeInAddCommGrp.1
module := inferInstance
map_smul := fun _ _ _ => rfl }
isSheaf := M.tildeInAddCommGrp.2
end ModuleCat
|
AlgebraicGeometry\Morphisms\Affine.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.AlgebraicGeometry.Morphisms.IsIso
/-!
# Affine morphisms of schemes
A morphism of schemes `f : X ⟶ Y` is affine if the preimage
of an arbitrary affine open subset of `Y` is affine.
It is equivalent to ask only that `Y` is covered by affine opens whose preimage is affine.
## Main results
- `AlgebraicGeometry.IsAffineHom`: The class of affine morphisms.
- `AlgebraicGeometry.isAffineOpen_of_isAffineOpen_basicOpen`:
If `s` is a spanning set of `Γ(X, U)`, such that each `X.basicOpen i` is affine,
then `U` is also affine.
- `AlgebraicGeometry.isAffineHom_stableUnderBaseChange`:
Affine morphisms are stable under base change.
We also provide the instance `HasAffineProperty @IsAffineHom fun X _ _ _ ↦ IsAffine X`.
## TODO
- Affine morphisms are separated.
-/
universe v u
open CategoryTheory TopologicalSpace Opposite
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism of schemes `X ⟶ Y` is affine if
the preimage of any affine open subset of `Y` is affine. -/
@[mk_iff]
class IsAffineHom {X Y : Scheme} (f : X ⟶ Y) : Prop where
isAffine_preimage : ∀ U : Y.Opens, IsAffineOpen U → IsAffineOpen (f ⁻¹ᵁ U)
lemma isAffineOpen.preimage {X Y : Scheme} {U : Y.Opens} (hU : IsAffineOpen U)
(f : X ⟶ Y) [IsAffineHom f] :
IsAffineOpen (f ⁻¹ᵁ U) :=
IsAffineHom.isAffine_preimage _ hU
/-- The preimage of an affine open as an `Scheme.affine_opens`. -/
@[simps]
def affinePreimage {X Y : Scheme} (f : X ⟶ Y) [IsAffineHom f] (U : Y.affineOpens) :
X.affineOpens :=
⟨f ⁻¹ᵁ U.1, IsAffineHom.isAffine_preimage _ U.prop⟩
instance (priority := 900) [IsIso f] : IsAffineHom f :=
⟨fun _ hU ↦ hU.preimage_of_isIso f⟩
instance (priority := 900) [IsAffineHom f] : QuasiCompact f :=
(quasiCompact_iff_forall_affine f).mpr
(fun U hU ↦ (IsAffineHom.isAffine_preimage U hU).isCompact)
instance [IsAffineHom f] [IsAffineHom g] : IsAffineHom (f ≫ g) := by
constructor
intros U hU
rw [Scheme.comp_val_base, Opens.map_comp_obj]
apply IsAffineHom.isAffine_preimage
apply IsAffineHom.isAffine_preimage
exact hU
instance : MorphismProperty.IsMultiplicative @IsAffineHom where
id_mem := inferInstance
comp_mem _ _ _ _ := inferInstance
instance {X : Scheme} (r : Γ(X, ⊤)) :
IsAffineHom (X.basicOpen r).ι := by
constructor
intros U hU
fapply (Scheme.Hom.isAffineOpen_iff_of_isOpenImmersion (X.basicOpen r).ι).mp
convert hU.basicOpen (X.presheaf.map (homOfLE le_top).op r)
rw [X.basicOpen_res]
ext1
refine Set.image_preimage_eq_inter_range.trans ?_
erw [Subtype.range_coe]
rfl
lemma isAffineOpen_of_isAffineOpen_basicOpen_aux (s : Set Γ(X, ⊤))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
QuasiSeparatedSpace X := by
rw [quasiSeparatedSpace_iff_affine]
intros U V
obtain ⟨s', hs', e⟩ := (Ideal.span_eq_top_iff_finite _).mp hs
rw [← Set.inter_univ (_ ∩ _), ← Opens.coe_top, ← iSup_basicOpen_of_span_eq_top _ _ e,
← iSup_subtype'', Opens.coe_iSup, Set.inter_iUnion]
apply isCompact_iUnion
intro i
rw [Set.inter_inter_distrib_right]
refine (hs₂ i (hs' i.2)).isQuasiSeparated _ _ Set.inter_subset_right
(U.1.2.inter (X.basicOpen _).2) ?_ Set.inter_subset_right (V.1.2.inter (X.basicOpen _).2) ?_
· rw [← Opens.coe_inf, ← X.basicOpen_res _ (homOfLE le_top).op]
exact (U.2.basicOpen _).isCompact
· rw [← Opens.coe_inf, ← X.basicOpen_res _ (homOfLE le_top).op]
exact (V.2.basicOpen _).isCompact
lemma isAffine_of_isAffineOpen_basicOpen (s : Set Γ(X, ⊤))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
IsAffine X := by
have : QuasiSeparatedSpace X := isAffineOpen_of_isAffineOpen_basicOpen_aux s hs hs₂
have : CompactSpace X := by
obtain ⟨s', hs', e⟩ := (Ideal.span_eq_top_iff_finite _).mp hs
rw [← isCompact_univ_iff, ← Opens.coe_top, ← iSup_basicOpen_of_span_eq_top _ _ e]
simp only [Finset.mem_coe, Opens.iSup_mk, Opens.carrier_eq_coe, Opens.coe_mk]
apply s'.isCompact_biUnion
exact fun i hi ↦ (hs₂ _ (hs' hi)).isCompact
constructor
refine HasAffineProperty.of_iSup_eq_top (P := MorphismProperty.isomorphisms Scheme)
(fun i : s ↦ ⟨PrimeSpectrum.basicOpen i.1, ?_⟩) ?_ (fun i ↦ ⟨?_, ?_⟩)
· show IsAffineOpen _
simp only [← basicOpen_eq_of_affine]
exact (isAffineOpen_top (Scheme.Spec.obj (op _))).basicOpen _
· rw [PrimeSpectrum.iSup_basicOpen_eq_top_iff, Subtype.range_coe_subtype, Set.setOf_mem_eq, hs]
· show IsAffineOpen (ΓSpec.adjunction.unit.app X ⁻¹ᵁ PrimeSpectrum.basicOpen i.1)
rw [ΓSpec.adjunction_unit_map_basicOpen]
exact hs₂ _ i.2
· simp only [Functor.comp_obj, Functor.rightOp_obj, Scheme.Γ_obj, Scheme.Spec_obj, id_eq,
eq_mpr_eq_cast, Functor.id_obj, Opens.map_top, morphismRestrict_app]
apply (config := { allowSynthFailures := true }) IsIso.comp_isIso
convert isIso_ΓSpec_adjunction_unit_app_basicOpen i.1 using 0
refine congr(IsIso ((ΓSpec.adjunction.unit.app X).app $(?_)))
rw [Opens.openEmbedding_obj_top]
/--
If `s` is a spanning set of `Γ(X, U)`, such that each `X.basicOpen i` is affine, then `U` is also
affine.
-/
lemma isAffineOpen_of_isAffineOpen_basicOpen (U) (s : Set Γ(X, U))
(hs : Ideal.span s = ⊤) (hs₂ : ∀ i ∈ s, IsAffineOpen (X.basicOpen i)) :
IsAffineOpen U := by
apply isAffine_of_isAffineOpen_basicOpen (U.topIso.inv '' s)
· rw [← Ideal.map_span U.topIso.inv, hs, Ideal.map_top]
· rintro _ ⟨j, hj, rfl⟩
rw [← (Scheme.Opens.ι _).isAffineOpen_iff_of_isOpenImmersion, Scheme.image_basicOpen]
simpa [Scheme.Opens.toScheme_presheaf_obj] using hs₂ j hj
instance : HasAffineProperty @IsAffineHom fun X _ _ _ ↦ IsAffine X where
isLocal_affineProperty := by
constructor
· apply AffineTargetMorphismProperty.respectsIso_mk
· rintro X Y Z e _ _ H
have : IsAffine _ := H
exact isAffine_of_isIso e.hom
· exact fun _ _ _ ↦ id
· intro X Y _ f r H
have : IsAffine X := H
show IsAffineOpen _
rw [Scheme.preimage_basicOpen]
exact (isAffineOpen_top X).basicOpen _
· intro X Y _ f S hS hS'
apply_fun Ideal.map (f.1.c.app (op ⊤)) at hS
rw [Ideal.map_span, Ideal.map_top] at hS
apply isAffine_of_isAffineOpen_basicOpen _ hS
have : ∀ i : S, IsAffineOpen (f⁻¹ᵁ Y.basicOpen i.1) := hS'
simpa [Scheme.preimage_basicOpen] using this
eq_targetAffineLocally' := by
ext X Y f
simp only [targetAffineLocally, Scheme.affineOpens, Set.coe_setOf, Set.mem_setOf_eq,
Subtype.forall, isAffineHom_iff]
rfl
lemma isAffineHom_stableUnderBaseChange :
MorphismProperty.StableUnderBaseChange @IsAffineHom := by
apply HasAffineProperty.stableUnderBaseChange
letI := HasAffineProperty.isLocal_affineProperty
apply AffineTargetMorphismProperty.StableUnderBaseChange.mk
introv X hX H
infer_instance
instance (priority := 100) isAffineHom_of_isAffine [IsAffine X] [IsAffine Y] : IsAffineHom f :=
(HasAffineProperty.iff_of_isAffine (P := @IsAffineHom)).mpr inferInstance
lemma isAffine_of_isAffineHom [IsAffineHom f] [IsAffine Y] : IsAffine X :=
(HasAffineProperty.iff_of_isAffine (P := @IsAffineHom) (f := f)).mp inferInstance
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\Basic.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.AffineScheme
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.MorphismProperty.Limits
import Mathlib.Data.List.TFAE
/-!
# Properties of morphisms between Schemes
We provide the basic framework for talking about properties of morphisms between Schemes.
A `MorphismProperty Scheme` is a predicate on morphisms between schemes. For properties local at
the target, its behaviour is entirely determined by its definition on morphisms into affine schemes,
which we call an `AffineTargetMorphismProperty`. In this file, we provide API lemmas for properties
local at the target, and special support for those properties whose `AffineTargetMorphismProperty`
takes on a more simple form. We also provide API lemmas for properties local at the target.
The main interfaces of the API are the typeclasses `IsLocalAtTarget`, `IsLocalAtSource` and
`HasAffineProperty`, which we describle in detail below.
## `IsLocalAtTarget`
- `AlgebraicGeometry.IsLocalAtTarget`: We say that `IsLocalAtTarget P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`.
For a morphism property `P` local at the target and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.IsLocalAtTarget.of_isPullback`:
`P` is preserved under pullback along open immersions.
- `AlgebraicGeometry.IsLocalAtTarget.restrict`:
`P f → P (f ∣_ U)` for an open `U` of `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_iSup_eq_top`:
`P f ↔ ∀ i, P (f ∣_ U i)` for a family `U i` of open sets covering `Y`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_openCover`:
`P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for `𝒰 : Y.openCover`.
## `IsLocalAtSource`
- `AlgebraicGeometry.IsLocalAtSource`: We say that `IsLocalAtSource P` for
`P : MorphismProperty Scheme` if
1. `P` respects isomorphisms.
2. `P` holds for `𝒰.map i ≫ f` for an open cover `𝒰` of `X` iff `P` holds for `f : X ⟶ Y`.
For a morphism property `P` local at the source and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.IsLocalAtTarget.comp`:
`P` is preserved under composition with open immersions at the source.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_iSup_eq_top`:
`P f ↔ ∀ i, P (U.ι ≫ f)` for a family `U i` of open sets covering `X`.
- `AlgebraicGeometry.IsLocalAtTarget.iff_of_openCover`:
`P f ↔ ∀ i, P (𝒰.map i ≫ f)` for `𝒰 : X.openCover`.
- `AlgebraicGeometry.IsLocalAtTarget.of_isOpenImmersion`: If `P` contains identities then `P` holds
for open immersions.
## `AffineTargetMorphismProperty`
- `AlgebraicGeometry.AffineTargetMorphismProperty`:
The type of predicates on `f : X ⟶ Y` with `Y` affine.
- `AlgebraicGeometry.AffineTargetMorphismProperty.IsLocal`: We say that `P.IsLocal` if `P`
satisfies the assumptions of the affine communication lemma
(`AlgebraicGeometry.of_affine_open_cover`). That is,
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basicOpen r` for any
global section `r`.
3. If `P` holds for `f ∣_ Y.basicOpen r` for all `r` in a spanning set of the global sections,
then `P` holds for `f`.
## `HasAffineProperty`
- `AlgebraicGeometry.HasAffineProperty`:
`HasAffineProperty P Q` is a type class asserting that `P` is local at the target,
and over affine schemes, it is equivalent to `Q : AffineTargetMorphismProperty`.
For `HasAffineProperty P Q` and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.HasAffineProperty.of_isPullback`:
`P` is preserved under pullback along open immersions from affine schemes.
- `AlgebraicGeometry.HasAffineProperty.restrict`:
`P f → Q (f ∣_ U)` for affine `U` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_iSup_eq_top`:
`P f ↔ ∀ i, Q (f ∣_ U i)` for a family `U i` of affine open sets covering `Y`.
- `AlgebraicGeometry.HasAffineProperty.iff_of_openCover`:
`P f ↔ ∀ i, P (𝒰.pullbackHom f i)` for affine open covers `𝒰` of `Y`.
- `AlgebraicGeometry.HasAffineProperty.stableUnderBaseChange_mk`:
If `Q` is stable under affine base change, then `P` is stable under arbitrary base change.
-/
universe u
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
/--
We say that `P : MorphismProperty Scheme` is local at the target if
1. `P` respects isomorphisms.
2. `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`.
Also see `IsLocalAtTarget.mk'` for a convenient constructor.
-/
class IsLocalAtTarget (P : MorphismProperty Scheme) : Prop where
/-- `P` respects isomorphisms. -/
respectsIso : P.RespectsIso := by infer_instance
/-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/
iff_of_openCover' :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y),
P f ↔ ∀ i, P (𝒰.pullbackHom f i)
namespace IsLocalAtTarget
attribute [instance] respectsIso
/--
`P` is local at the target if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.
-/
protected lemma mk' {P : MorphismProperty Scheme} [P.RespectsIso]
(restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : Y.Opens), P f → P (f ∣_ U))
(of_sSup_eq_top :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Y.Opens), iSup U = ⊤ →
(∀ i, P (f ∣_ U i)) → P f) :
IsLocalAtTarget P := by
refine ⟨inferInstance, fun {X Y} f 𝒰 ↦ ⟨?_, fun H ↦ of_sSup_eq_top f _ 𝒰.iSup_opensRange ?_⟩⟩
· exact fun H i ↦ (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mp (restrict _ _ H)
· exact fun i ↦ (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (H i)
/-- The intersection of two morphism properties that are local at the target is again local at
the target. -/
instance inf (P Q : MorphismProperty Scheme) [IsLocalAtTarget P] [IsLocalAtTarget Q] :
IsLocalAtTarget (P ⊓ Q) where
iff_of_openCover' {X Y} f 𝒰 :=
⟨fun h i ↦ ⟨(iff_of_openCover' f 𝒰).mp h.left i, (iff_of_openCover' f 𝒰).mp h.right i⟩,
fun h ↦ ⟨(iff_of_openCover' f 𝒰).mpr (fun i ↦ (h i).left),
(iff_of_openCover' f 𝒰).mpr (fun i ↦ (h i).right)⟩⟩
variable {P} [hP : IsLocalAtTarget P]
variable {X Y U V : Scheme.{u}} {f : X ⟶ Y} {g : U ⟶ Y} [IsOpenImmersion g] (𝒰 : Y.OpenCover)
lemma of_isPullback {UX UY : Scheme.{u}} {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (H : P f) : P f' := by
rw [← P.cancel_left_of_respectsIso h.isoPullback.inv, h.isoPullback_inv_snd]
exact (iff_of_openCover' f (Y.affineCover.add iY)).mp H .none
theorem restrict (hf : P f) (U : Y.Opens) : P (f ∣_ U) :=
of_isPullback (isPullback_morphismRestrict f U).flip hf
lemma of_iSup_eq_top {ι} (U : ι → Y.Opens) (hU : iSup U = ⊤)
(H : ∀ i, P (f ∣_ U i)) : P f := by
refine (IsLocalAtTarget.iff_of_openCover' f
(Y.openCoverOfISupEqTop (s := Set.range U) Subtype.val (by ext; simp [← hU]))).mpr fun i ↦ ?_
obtain ⟨_, i, rfl⟩ := i
refine (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mp ?_
show P (f ∣_ (U i).ι.opensRange)
rw [Scheme.Opens.opensRange_ι]
exact H i
theorem iff_of_iSup_eq_top {ι} (U : ι → Y.Opens) (hU : iSup U = ⊤) :
P f ↔ ∀ i, P (f ∣_ U i) :=
⟨fun H _ ↦ restrict H _, of_iSup_eq_top U hU⟩
lemma of_openCover (H : ∀ i, P (𝒰.pullbackHom f i)) : P f := by
apply of_iSup_eq_top (fun i ↦ (𝒰.map i).opensRange) 𝒰.iSup_opensRange
exact fun i ↦ (P.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (H i)
theorem iff_of_openCover (𝒰 : Y.OpenCover) :
P f ↔ ∀ i, P (𝒰.pullbackHom f i) :=
⟨fun H _ ↦ of_isPullback (.of_hasPullback _ _) H, of_openCover _⟩
end IsLocalAtTarget
/--
We say that `P : MorphismProperty Scheme` is local at the source if
1. `P` respects isomorphisms.
2. `P` holds for `𝒰.map i ≫ f` for an open cover `𝒰` of `X` iff `P` holds for `f : X ⟶ Y`.
Also see `IsLocalAtSource.mk'` for a convenient constructor.
-/
class IsLocalAtSource (P : MorphismProperty Scheme) : Prop where
/-- `P` respects isomorphisms. -/
respectsIso : P.RespectsIso := by infer_instance
/-- `P` holds for `f ∣_ U` for an open cover `U` of `Y` if and only if `P` holds for `f`. -/
iff_of_openCover' :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} X),
P f ↔ ∀ i, P (𝒰.map i ≫ f)
namespace IsLocalAtSource
attribute [instance] respectsIso
/--
`P` is local at the target if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ U` for any `U`.
3. If `P` holds for `f ∣_ U` for an open cover `U` of `Y`, then `P` holds for `f`.
-/
protected lemma mk' {P : MorphismProperty Scheme} [P.RespectsIso]
(restrict : ∀ {X Y : Scheme} (f : X ⟶ Y) (U : X.Opens), P f → P (U.ι ≫ f))
(of_sSup_eq_top :
∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → X.Opens), iSup U = ⊤ →
(∀ i, P ((U i).ι ≫ f)) → P f) :
IsLocalAtSource P := by
refine ⟨inferInstance, fun {X Y} f 𝒰 ↦
⟨fun H i ↦ ?_, fun H ↦ of_sSup_eq_top f _ 𝒰.iSup_opensRange fun i ↦ ?_⟩⟩
· rw [← IsOpenImmersion.isoOfRangeEq_hom_fac (𝒰.map i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.map i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact restrict _ _ H
· rw [← IsOpenImmersion.isoOfRangeEq_inv_fac (𝒰.map i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.map i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact H _
/-- The intersection of two morphism properties that are local at the target is again local at
the target. -/
instance inf (P Q : MorphismProperty Scheme) [IsLocalAtSource P] [IsLocalAtSource Q] :
IsLocalAtSource (P ⊓ Q) where
iff_of_openCover' {X Y} f 𝒰 :=
⟨fun h i ↦ ⟨(iff_of_openCover' f 𝒰).mp h.left i, (iff_of_openCover' f 𝒰).mp h.right i⟩,
fun h ↦ ⟨(iff_of_openCover' f 𝒰).mpr (fun i ↦ (h i).left),
(iff_of_openCover' f 𝒰).mpr (fun i ↦ (h i).right)⟩⟩
variable {P} [IsLocalAtSource P]
variable {X Y U V : Scheme.{u}} {f : X ⟶ Y} {g : U ⟶ Y} [IsOpenImmersion g] (𝒰 : X.OpenCover)
lemma comp {UX : Scheme.{u}} (H : P f) (i : UX ⟶ X) [IsOpenImmersion i] :
P (i ≫ f) :=
(iff_of_openCover' f (X.affineCover.add i)).mp H .none
lemma of_iSup_eq_top {ι} (U : ι → X.Opens) (hU : iSup U = ⊤)
(H : ∀ i, P ((U i).ι ≫ f)) : P f := by
refine (iff_of_openCover' f
(X.openCoverOfISupEqTop (s := Set.range U) Subtype.val (by ext; simp [← hU]))).mpr fun i ↦ ?_
obtain ⟨_, i, rfl⟩ := i
exact H i
theorem iff_of_iSup_eq_top {ι} (U : ι → X.Opens) (hU : iSup U = ⊤) :
P f ↔ ∀ i, P ((U i).ι ≫ f) :=
⟨fun H _ ↦ comp H _, of_iSup_eq_top U hU⟩
lemma of_openCover (H : ∀ i, P (𝒰.map i ≫ f)) : P f := by
refine of_iSup_eq_top (fun i ↦ (𝒰.map i).opensRange) 𝒰.iSup_opensRange fun i ↦ ?_
rw [← IsOpenImmersion.isoOfRangeEq_inv_fac (𝒰.map i) (Scheme.Opens.ι _)
(congr_arg Opens.carrier (𝒰.map i).opensRange.opensRange_ι.symm), Category.assoc,
P.cancel_left_of_respectsIso]
exact H i
theorem iff_of_openCover :
P f ↔ ∀ i, P (𝒰.map i ≫ f) :=
⟨fun H _ ↦ comp H _, of_openCover _⟩
variable (f) in
lemma of_isOpenImmersion [P.ContainsIdentities] [IsOpenImmersion f] : P f :=
Category.comp_id f ▸ comp (P.id_mem Y) f
lemma isLocalAtTarget [P.IsMultiplicative]
(hP : ∀ {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z) [IsOpenImmersion g], P (f ≫ g) → P f) :
IsLocalAtTarget P where
iff_of_openCover' {X Y} f 𝒰 := by
refine (iff_of_openCover (𝒰.pullbackCover f)).trans (forall_congr' fun i ↦ ?_)
rw [← Scheme.OpenCover.pullbackHom_map]
constructor
· exact hP _ _
· exact fun H ↦ P.comp_mem _ _ H (of_isOpenImmersion _)
end IsLocalAtSource
/-- An `AffineTargetMorphismProperty` is a class of morphisms from an arbitrary scheme into an
affine scheme. -/
def AffineTargetMorphismProperty :=
∀ ⦃X Y : Scheme⦄ (_ : X ⟶ Y) [IsAffine Y], Prop
namespace AffineTargetMorphismProperty
@[ext]
lemma ext {P Q : AffineTargetMorphismProperty}
(H : ∀ ⦃X Y : Scheme⦄ (f : X ⟶ Y) [IsAffine Y], P f ↔ Q f) : P = Q := by
delta AffineTargetMorphismProperty; ext; exact H _
/-- The restriction of a `MorphismProperty Scheme` to morphisms with affine target. -/
def of (P : MorphismProperty Scheme) : AffineTargetMorphismProperty :=
fun _ _ f _ ↦ P f
/-- An `AffineTargetMorphismProperty` can be extended to a `MorphismProperty` such that it
*never* holds when the target is not affine -/
def toProperty (P : AffineTargetMorphismProperty) :
MorphismProperty Scheme := fun _ _ f => ∃ h, @P _ _ f h
theorem toProperty_apply (P : AffineTargetMorphismProperty)
{X Y : Scheme} (f : X ⟶ Y) [i : IsAffine Y] : P.toProperty f ↔ P f := by
delta AffineTargetMorphismProperty.toProperty; simp [*]
theorem cancel_left_of_respectsIso
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso f] [IsAffine Z] : P (f ≫ g) ↔ P g := by
rw [← P.toProperty_apply, ← P.toProperty_apply, P.toProperty.cancel_left_of_respectsIso]
theorem cancel_right_of_respectsIso
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsIso g] [IsAffine Z] [IsAffine Y] :
P (f ≫ g) ↔ P f := by rw [← P.toProperty_apply, ← P.toProperty_apply,
P.toProperty.cancel_right_of_respectsIso]
@[deprecated (since := "2024-07-02")] alias affine_cancel_left_isIso :=
AffineTargetMorphismProperty.cancel_left_of_respectsIso
@[deprecated (since := "2024-07-02")] alias affine_cancel_right_isIso :=
AffineTargetMorphismProperty.cancel_right_of_respectsIso
theorem arrow_mk_iso_iff
(P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
{X Y X' Y' : Scheme} {f : X ⟶ Y} {f' : X' ⟶ Y'}
(e : Arrow.mk f ≅ Arrow.mk f') {h : IsAffine Y} :
letI : IsAffine Y' := isAffine_of_isIso (Y := Y) e.inv.right
P f ↔ P f' := by
rw [← P.toProperty_apply, ← P.toProperty_apply, P.toProperty.arrow_mk_iso_iff e]
theorem respectsIso_mk {P : AffineTargetMorphismProperty}
(h₁ : ∀ {X Y Z} (e : X ≅ Y) (f : Y ⟶ Z) [IsAffine Z], P f → P (e.hom ≫ f))
(h₂ : ∀ {X Y Z} (e : Y ≅ Z) (f : X ⟶ Y) [h : IsAffine Y],
P f → @P _ _ (f ≫ e.hom) (isAffine_of_isIso e.inv)) :
P.toProperty.RespectsIso := by
constructor
· rintro X Y Z e f ⟨a, h⟩; exact ⟨a, h₁ e f h⟩
· rintro X Y Z e f ⟨a, h⟩; exact ⟨isAffine_of_isIso e.inv, h₂ e f h⟩
instance respectsIso_of
(P : MorphismProperty Scheme) [P.RespectsIso] :
(of P).toProperty.RespectsIso := by
apply respectsIso_mk
· intro _ _ _ _ _ _; apply MorphismProperty.RespectsIso.precomp
· intro _ _ _ _ _ _; apply MorphismProperty.RespectsIso.postcomp
/-- We say that `P : AffineTargetMorphismProperty` is a local property if
1. `P` respects isomorphisms.
2. If `P` holds for `f : X ⟶ Y`, then `P` holds for `f ∣_ Y.basicOpen r` for any
global section `r`.
3. If `P` holds for `f ∣_ Y.basicOpen r` for all `r` in a spanning set of the global sections,
then `P` holds for `f`.
-/
class IsLocal (P : AffineTargetMorphismProperty) : Prop where
/-- `P` as a morphism property respects isomorphisms -/
respectsIso : P.toProperty.RespectsIso
/-- `P` is stable under restriction to basic open set of global sections. -/
to_basicOpen :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (r : Γ(Y, ⊤)), P f → P (f ∣_ Y.basicOpen r)
/-- `P` for `f` if `P` holds for `f` restricted to basic sets of a spanning set of the global
sections -/
of_basicOpenCover :
∀ {X Y : Scheme} [IsAffine Y] (f : X ⟶ Y) (s : Finset Γ(Y, ⊤))
(_ : Ideal.span (s : Set Γ(Y, ⊤)) = ⊤), (∀ r : s, P (f ∣_ Y.basicOpen r.1)) → P f
attribute [instance] AffineTargetMorphismProperty.IsLocal.respectsIso
open AffineTargetMorphismProperty in
instance (P : MorphismProperty Scheme) [IsLocalAtTarget P] : (of P).IsLocal where
respectsIso := inferInstance
to_basicOpen _ _ H := IsLocalAtTarget.restrict H _
of_basicOpenCover {_ Y} _ _ _ hs := IsLocalAtTarget.of_iSup_eq_top _
(((isAffineOpen_top Y).basicOpen_union_eq_self_iff _).mpr hs)
/-- A `P : AffineTargetMorphismProperty` is stable under base change if `P` holds for `Y ⟶ S`
implies that `P` holds for `X ×ₛ Y ⟶ X` with `X` and `S` affine schemes. -/
def StableUnderBaseChange (P : AffineTargetMorphismProperty) : Prop :=
∀ ⦃Z X Y S : Scheme⦄ [IsAffine S] [IsAffine X] {f : X ⟶ S} {g : Y ⟶ S}
{f' : Z ⟶ Y} {g' : Z ⟶ X}, IsPullback g' f' f g → P g → P g'
lemma StableUnderBaseChange.mk (P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso]
(H : ∀ ⦃X Y S : Scheme⦄ [IsAffine S] [IsAffine X] (f : X ⟶ S) (g : Y ⟶ S),
P g → P (pullback.fst f g)) : P.StableUnderBaseChange := by
intros Z X Y S _ _ f g f' g' h hg
rw [← P.cancel_left_of_respectsIso h.isoPullback.inv, h.isoPullback_inv_fst]
exact H f g hg
end AffineTargetMorphismProperty
section targetAffineLocally
/-- For a `P : AffineTargetMorphismProperty`, `targetAffineLocally P` holds for
`f : X ⟶ Y` whenever `P` holds for the restriction of `f` on every affine open subset of `Y`. -/
def targetAffineLocally (P : AffineTargetMorphismProperty) : MorphismProperty Scheme :=
fun {X Y : Scheme} (f : X ⟶ Y) => ∀ U : Y.affineOpens, P (f ∣_ U)
theorem of_targetAffineLocally_of_isPullback
{P : AffineTargetMorphismProperty} [P.IsLocal]
{X Y UX UY : Scheme.{u}} [IsAffine UY] {f : X ⟶ Y} {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (hf : targetAffineLocally P f) :
P f' := by
rw [← P.cancel_left_of_respectsIso h.isoPullback.inv, h.isoPullback_inv_snd]
exact (P.arrow_mk_iso_iff
(morphismRestrictOpensRange f _)).mp (hf ⟨_, isAffineOpen_opensRange iY⟩)
instance (P : AffineTargetMorphismProperty) [P.toProperty.RespectsIso] :
(targetAffineLocally P).RespectsIso := by
constructor
· introv H U
rw [morphismRestrict_comp, P.cancel_left_of_respectsIso]
exact H U
· introv H
rintro ⟨U, hU : IsAffineOpen U⟩; dsimp
haveI : IsAffine _ := hU.preimage_of_isIso e.hom
rw [morphismRestrict_comp, P.cancel_right_of_respectsIso]
exact H ⟨(Opens.map e.hom.val.base).obj U, hU.preimage_of_isIso e.hom⟩
/--
`HasAffineProperty P Q` is a type class asserting that `P` is local at the target, and over affine
schemes, it is equivalent to `Q : AffineTargetMorphismProperty`.
To make the proofs easier, we state it instead as
1. `Q` is local at the target
2. `P f` if and only if `∀ U, Q (f ∣_ U)` ranging over all affine opens of `U`.
See `HasAffineProperty.iff`.
-/
class HasAffineProperty (P : MorphismProperty Scheme)
(Q : outParam AffineTargetMorphismProperty) : Prop where
isLocal_affineProperty : Q.IsLocal
eq_targetAffineLocally' : P = targetAffineLocally Q
namespace HasAffineProperty
variable (P : MorphismProperty Scheme) {Q} [HasAffineProperty P Q]
variable {X Y : Scheme.{u}} {f : X ⟶ Y}
instance (Q : AffineTargetMorphismProperty) [Q.IsLocal] :
HasAffineProperty (targetAffineLocally Q) Q :=
⟨inferInstance, rfl⟩
lemma eq_targetAffineLocally : P = targetAffineLocally Q := eq_targetAffineLocally'
/-- Every property local at the target can be associated with an affine target property.
This is not an instance as the associated property can often take on simpler forms. -/
lemma of_isLocalAtTarget (P) [IsLocalAtTarget P] :
HasAffineProperty P (AffineTargetMorphismProperty.of P) where
isLocal_affineProperty := inferInstance
eq_targetAffineLocally' := by
ext X Y f
constructor
· intro hf ⟨U, hU⟩
exact IsLocalAtTarget.restrict hf _
· intro hf
exact IsLocalAtTarget.of_openCover (P := P) Y.affineCover
fun i ↦ of_targetAffineLocally_of_isPullback (.of_hasPullback _ _) hf
lemma copy {P P'} {Q Q'} [HasAffineProperty P Q]
(e : P = P') (e' : Q = Q') : HasAffineProperty P' Q' where
isLocal_affineProperty := e' ▸ isLocal_affineProperty P
eq_targetAffineLocally' := e' ▸ e.symm ▸ eq_targetAffineLocally P
variable {P}
theorem of_isPullback {UX UY : Scheme.{u}} [IsAffine UY] {iY : UY ⟶ Y} [IsOpenImmersion iY]
{iX : UX ⟶ X} {f' : UX ⟶ UY} (h : IsPullback iX f' f iY) (hf : P f) :
Q f' :=
letI := isLocal_affineProperty P
of_targetAffineLocally_of_isPullback h (eq_targetAffineLocally (P := P) ▸ hf)
theorem restrict (hf : P f) (U : Y.affineOpens) :
Q (f ∣_ U) :=
of_isPullback (isPullback_morphismRestrict f U).flip hf
instance (priority := 900) : P.RespectsIso := by
letI := isLocal_affineProperty P
rw [eq_targetAffineLocally P]
infer_instance
theorem of_iSup_eq_top
{ι} (U : ι → Y.affineOpens) (hU : ⨆ i, (U i : Y.Opens) = ⊤)
(hU' : ∀ i, Q (f ∣_ U i)) :
P f := by
letI := isLocal_affineProperty P
rw [eq_targetAffineLocally P]
classical
intro V
induction V using of_affine_open_cover U hU with
| basicOpen U r h =>
haveI : IsAffine _ := U.2
have := AffineTargetMorphismProperty.IsLocal.to_basicOpen (f ∣_ U.1) (U.1.topIso.inv r) h
exact (Q.arrow_mk_iso_iff
(morphismRestrictRestrictBasicOpen f _ r)).mp this
| openCover U s hs H =>
apply AffineTargetMorphismProperty.IsLocal.of_basicOpenCover _
(s.image (Scheme.Opens.topIso _).inv) (by simp [← Ideal.map_span, hs, Ideal.map_top])
intro ⟨r, hr⟩
obtain ⟨r, hr', rfl⟩ := Finset.mem_image.mp hr
exact (Q.arrow_mk_iso_iff
(morphismRestrictRestrictBasicOpen f _ r).symm).mp (H ⟨r, hr'⟩)
| hU i => exact hU' i
theorem iff_of_iSup_eq_top
{ι} (U : ι → Y.affineOpens) (hU : ⨆ i, (U i : Y.Opens) = ⊤) :
P f ↔ ∀ i, Q (f ∣_ U i) :=
⟨fun H _ ↦ restrict H _, fun H ↦ HasAffineProperty.of_iSup_eq_top U hU H⟩
theorem of_openCover
(𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (h𝒰 : ∀ i, Q (𝒰.pullbackHom f i)) :
P f :=
letI := isLocal_affineProperty P
of_iSup_eq_top
(fun i ↦ ⟨_, isAffineOpen_opensRange (𝒰.map i)⟩) 𝒰.iSup_opensRange
(fun i ↦ (Q.arrow_mk_iso_iff (morphismRestrictOpensRange f _)).mpr (h𝒰 i))
theorem iff_of_openCover (𝒰 : Y.OpenCover) [∀ i, IsAffine (𝒰.obj i)] :
P f ↔ ∀ i, Q (𝒰.pullbackHom f i) := by
letI := isLocal_affineProperty P
rw [iff_of_iSup_eq_top (P := P)
(fun i ↦ ⟨_, isAffineOpen_opensRange _⟩) 𝒰.iSup_opensRange]
exact forall_congr' fun i ↦ Q.arrow_mk_iso_iff
(morphismRestrictOpensRange f _)
theorem iff_of_isAffine [IsAffine Y] : P f ↔ Q f := by
letI := isLocal_affineProperty P
haveI : ∀ i, IsAffine (Scheme.OpenCover.obj (Scheme.openCoverOfIsIso (𝟙 Y)) i) := fun i => by
dsimp; infer_instance
rw [iff_of_openCover (P := P) (Scheme.openCoverOfIsIso.{0} (𝟙 Y))]
trans Q (pullback.snd f (𝟙 _))
· exact ⟨fun H => H PUnit.unit, fun H _ => H⟩
rw [← Category.comp_id (pullback.snd _ _), ← pullback.condition,
Q.cancel_left_of_respectsIso]
instance (priority := 900) : IsLocalAtTarget P := by
letI := isLocal_affineProperty P
apply IsLocalAtTarget.mk'
· rw [eq_targetAffineLocally P]
intro X Y f U H V
rw [Q.arrow_mk_iso_iff (morphismRestrictRestrict f _ _)]
exact H ⟨_, V.2.image_of_isOpenImmersion (Y.ofRestrict _)⟩
· rintro X Y f ι U hU H
let 𝒰 := Y.openCoverOfISupEqTop U hU
apply of_openCover 𝒰.affineRefinement.openCover
rintro ⟨i, j⟩
have : P (𝒰.pullbackHom f i) := by
refine (P.arrow_mk_iso_iff
(morphismRestrictEq _ ?_ ≪≫ morphismRestrictOpensRange f (𝒰.map i))).mp (H i)
exact (Scheme.Opens.opensRange_ι _).symm
rw [← Q.cancel_left_of_respectsIso (𝒰.pullbackCoverAffineRefinementObjIso f _).inv,
𝒰.pullbackCoverAffineRefinementObjIso_inv_pullbackHom]
exact of_isPullback (.of_hasPullback _ _) this
open AffineTargetMorphismProperty in
protected theorem iff {P : MorphismProperty Scheme} {Q : AffineTargetMorphismProperty} :
HasAffineProperty P Q ↔ IsLocalAtTarget P ∧ Q = of P :=
⟨fun _ ↦ ⟨inferInstance, ext fun _ _ _ ↦ iff_of_isAffine.symm⟩,
fun ⟨_, e⟩ ↦ e ▸ of_isLocalAtTarget P⟩
private theorem pullback_fst_of_right (hP' : Q.StableUnderBaseChange)
{X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [IsAffine S] (H : Q g) :
P (pullback.fst f g) := by
letI := isLocal_affineProperty P
rw [iff_of_openCover (P := P) X.affineCover]
intro i
let e := pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g (X.affineCover.map i)
have : e.hom ≫ pullback.fst _ _ = X.affineCover.pullbackHom (pullback.fst _ _) i := by
simp [e, Scheme.OpenCover.pullbackHom]
rw [← this, Q.cancel_left_of_respectsIso]
apply hP' (.of_hasPullback _ _)
exact H
theorem stableUnderBaseChange (hP' : Q.StableUnderBaseChange) :
P.StableUnderBaseChange :=
MorphismProperty.StableUnderBaseChange.mk
(fun X Y S f g H => by
rw [IsLocalAtTarget.iff_of_openCover (P := P) (S.affineCover.pullbackCover f)]
intro i
let e : pullback (pullback.fst f g) ((S.affineCover.pullbackCover f).map i) ≅
_ := by
refine pullbackSymmetry _ _ ≪≫ pullbackRightPullbackFstIso f g _ ≪≫ ?_ ≪≫
(pullbackRightPullbackFstIso (S.affineCover.map i) g
(pullback.snd f (S.affineCover.map i))).symm
exact asIso
(pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) (by simpa using pullback.condition) (by simp))
have : e.hom ≫ pullback.fst _ _ =
(S.affineCover.pullbackCover f).pullbackHom (pullback.fst _ _) i := by
simp [e, Scheme.OpenCover.pullbackHom]
rw [← this, P.cancel_left_of_respectsIso]
apply HasAffineProperty.pullback_fst_of_right hP'
letI := isLocal_affineProperty P
rw [← pullbackSymmetry_hom_comp_snd, Q.cancel_left_of_respectsIso]
apply of_isPullback (.of_hasPullback _ _) H)
lemma isLocalAtSource
(H : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) [IsAffine Y] (𝒰 : Scheme.OpenCover.{u} X),
Q f ↔ ∀ i, Q (𝒰.map i ≫ f)) : IsLocalAtSource P where
iff_of_openCover' {X Y} f 𝒰 := by
simp_rw [IsLocalAtTarget.iff_of_iSup_eq_top _ (iSup_affineOpens_eq_top Y)]
rw [forall_comm]
refine forall_congr' fun U ↦ ?_
simp_rw [HasAffineProperty.iff_of_isAffine, morphismRestrict_comp]
exact @H _ _ (f ∣_ U.1) U.2 (𝒰.restrict (f ⁻¹ᵁ U.1))
end HasAffineProperty
end targetAffineLocally
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\ClosedImmersion.lean | /-
Copyright (c) 2023 Jonas van der Schaaf. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Amelia Livingston, Christian Merten, Jonas van der Schaaf
-/
import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact
import Mathlib.AlgebraicGeometry.Morphisms.Preimmersion
/-!
# Closed immersions of schemes
A morphism of schemes `f : X ⟶ Y` is a closed immersion if the underlying map of topological spaces
is a closed immersion and the induced morphisms of stalks are all surjective.
## Main definitions
* `IsClosedImmersion` : The property of scheme morphisms stating `f : X ⟶ Y` is a closed immersion.
## TODO
* Show closed immersions of affines are induced by surjective ring maps
* Show closed immersions are stable under pullback
* Show closed immersions are precisely the proper monomorphisms
* Define closed immersions of locally ringed spaces, where we also assume that the kernel of `O_X →
f_*O_Y` is locally generated by sections as an `O_X`-module, and relate it to this file. See
https://stacks.math.columbia.edu/tag/01HJ.
-/
universe v u
open CategoryTheory
namespace AlgebraicGeometry
/-- A morphism of schemes `X ⟶ Y` is a closed immersion if the underlying
topological map is a closed embedding and the induced stalk maps are surjective. -/
@[mk_iff]
class IsClosedImmersion {X Y : Scheme} (f : X ⟶ Y) : Prop where
base_closed : ClosedEmbedding f.1.base
surj_on_stalks : ∀ x, Function.Surjective (f.stalkMap x)
namespace IsClosedImmersion
lemma closedEmbedding {X Y : Scheme} (f : X ⟶ Y)
[IsClosedImmersion f] : ClosedEmbedding f.1.base :=
IsClosedImmersion.base_closed
lemma eq_inf : @IsClosedImmersion = (topologically ClosedEmbedding) ⊓
stalkwise (fun f ↦ Function.Surjective f) := by
ext X Y f
rw [isClosedImmersion_iff]
rfl
lemma iff_isPreimmersion {X Y : Scheme} {f : X ⟶ Y} :
IsClosedImmersion f ↔ IsPreimmersion f ∧ IsClosed (Set.range f.1.base) := by
rw [and_comm, isClosedImmersion_iff, isPreimmersion_iff, ← and_assoc, closedEmbedding_iff,
@and_comm (Embedding _)]
lemma of_isPreimmersion {X Y : Scheme} (f : X ⟶ Y) [IsPreimmersion f]
(hf : IsClosed (Set.range f.1.base)) : IsClosedImmersion f :=
iff_isPreimmersion.mpr ⟨‹_›, hf⟩
instance (priority := 900) {X Y : Scheme} (f : X ⟶ Y) [IsClosedImmersion f] : IsPreimmersion f :=
(iff_isPreimmersion.mp ‹_›).1
/-- Isomorphisms are closed immersions. -/
instance {X Y : Scheme} (f : X ⟶ Y) [IsIso f] : IsClosedImmersion f where
base_closed := Homeomorph.closedEmbedding <| TopCat.homeoOfIso (asIso f.1.base)
surj_on_stalks := fun _ ↦ (ConcreteCategory.bijective_of_isIso _).2
instance : MorphismProperty.IsMultiplicative @IsClosedImmersion where
id_mem _ := inferInstance
comp_mem {X Y Z} f g hf hg := by
refine ⟨hg.base_closed.comp hf.base_closed, fun x ↦ ?_⟩
rw [Scheme.stalkMap_comp]
exact (hf.surj_on_stalks x).comp (hg.surj_on_stalks (f.1.1 x))
/-- Composition of closed immersions is a closed immersion. -/
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsClosedImmersion f]
[IsClosedImmersion g] : IsClosedImmersion (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
/-- Composition with an isomorphism preserves closed immersions. -/
instance respectsIso : MorphismProperty.RespectsIso @IsClosedImmersion := by
constructor <;> intro X Y Z e f hf <;> infer_instance
/-- Given two commutative rings `R S : CommRingCat` and a surjective morphism
`f : R ⟶ S`, the induced scheme morphism `specObj S ⟶ specObj R` is a
closed immersion. -/
theorem spec_of_surjective {R S : CommRingCat} (f : R ⟶ S) (h : Function.Surjective f) :
IsClosedImmersion (Spec.map f) where
base_closed := PrimeSpectrum.closedEmbedding_comap_of_surjective _ _ h
surj_on_stalks x := by
haveI : (RingHom.toMorphismProperty (fun f ↦ Function.Surjective f)).RespectsIso := by
rw [← RingHom.toMorphismProperty_respectsIso_iff]
exact surjective_respectsIso
apply (MorphismProperty.arrow_mk_iso_iff
(RingHom.toMorphismProperty (fun f ↦ Function.Surjective f))
(Scheme.arrowStalkMapSpecIso f x)).mpr
exact surjective_localRingHom_of_surjective f h x.asIdeal
/-- For any ideal `I` in a commutative ring `R`, the quotient map `specObj R ⟶ specObj (R ⧸ I)`
is a closed immersion. -/
instance spec_of_quotient_mk {R : CommRingCat.{u}} (I : Ideal R) :
IsClosedImmersion (Spec.map (CommRingCat.ofHom (Ideal.Quotient.mk I))) :=
spec_of_surjective _ Ideal.Quotient.mk_surjective
/-- Any morphism between affine schemes that is surjective on global sections is a
closed immersion. -/
lemma of_surjective_of_isAffine {X Y : Scheme} [IsAffine X] [IsAffine Y] (f : X ⟶ Y)
(h : Function.Surjective (Scheme.Γ.map f.op)) : IsClosedImmersion f := by
rw [MorphismProperty.arrow_mk_iso_iff @IsClosedImmersion (arrowIsoSpecΓOfIsAffine f)]
apply spec_of_surjective
exact h
/-- If `f ≫ g` is a closed immersion, then `f` is a closed immersion. -/
theorem of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsClosedImmersion g]
[IsClosedImmersion (f ≫ g)] : IsClosedImmersion f where
base_closed := by
have h := closedEmbedding (f ≫ g)
rw [Scheme.comp_val_base] at h
apply closedEmbedding_of_continuous_injective_closed (Scheme.Hom.continuous f)
· exact Function.Injective.of_comp h.inj
· intro Z hZ
rw [ClosedEmbedding.closed_iff_image_closed (closedEmbedding g),
← Set.image_comp]
exact ClosedEmbedding.isClosedMap h _ hZ
surj_on_stalks x := by
have h := (f ≫ g).stalkMap_surjective x
simp_rw [Scheme.comp_val, Scheme.stalkMap_comp] at h
exact Function.Surjective.of_comp h
instance {X Y : Scheme} (f : X ⟶ Y) [IsClosedImmersion f] : QuasiCompact f where
isCompact_preimage _ _ hU' := base_closed.isCompact_preimage hU'
end IsClosedImmersion
/-- Being a closed immersion is local at the target. -/
instance IsClosedImmersion.isLocalAtTarget : IsLocalAtTarget @IsClosedImmersion :=
eq_inf ▸ inferInstance
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\Constructors.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.Basic
import Mathlib.RingTheory.RingHomProperties
/-!
# Constructors for properties of morphisms between schemes
This file provides some constructors to obtain morphism properties of schemes from other morphism
properties:
- `AffineTargetMorphismProperty.diagonal` : Given an affine target morphism property `P`,
`P.diagonal f` holds if `P (pullback.mapDesc f₁ f₂ f)` holds for two affine open
immersions `f₁` and `f₂`.
- `AffineTargetMorphismProperty.of`: Given a morphism property `P` of schemes,
this is the restriction of `P` to morphisms with affine target. If `P` is local at the
target, we have `(toAffineTargetMorphismProperty P).targetAffineLocally = P`
(see `MorphismProperty.targetAffineLocally_toAffineTargetMorphismProperty_eq_of_isLocalAtTarget`).
- `MorphismProperty.topologically`: Given a property `P` of maps of topological spaces,
`(topologically P) f` holds if `P` holds for the underlying continuous map of `f`.
- `MorphismProperty.stalkwise`: Given a property `P` of ring homs,
`(stalkwise P) f` holds if `P` holds for all stalk maps.
Also provides API for showing the standard locality and stability properties for these
types of properties.
-/
universe u
open TopologicalSpace CategoryTheory CategoryTheory.Limits Opposite
noncomputable section
namespace AlgebraicGeometry
section Diagonal
/-- The `AffineTargetMorphismProperty` associated to `(targetAffineLocally P).diagonal`.
See `diagonal_targetAffineLocally_eq_targetAffineLocally`.
-/
def AffineTargetMorphismProperty.diagonal (P : AffineTargetMorphismProperty) :
AffineTargetMorphismProperty :=
fun {X _} f _ =>
∀ ⦃U₁ U₂ : Scheme⦄ (f₁ : U₁ ⟶ X) (f₂ : U₂ ⟶ X) [IsAffine U₁] [IsAffine U₂] [IsOpenImmersion f₁]
[IsOpenImmersion f₂], P (pullback.mapDesc f₁ f₂ f)
instance AffineTargetMorphismProperty.diagonal_respectsIso (P : AffineTargetMorphismProperty)
[P.toProperty.RespectsIso] : P.diagonal.toProperty.RespectsIso := by
delta AffineTargetMorphismProperty.diagonal
apply AffineTargetMorphismProperty.respectsIso_mk
· introv H _ _
rw [pullback.mapDesc_comp, P.cancel_left_of_respectsIso, P.cancel_right_of_respectsIso]
apply H
· introv H _ _
rw [pullback.mapDesc_comp, P.cancel_right_of_respectsIso]
apply H
theorem HasAffineProperty.diagonal_of_openCover (P) {Q} [HasAffineProperty P Q]
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
(𝒰' : ∀ i, Scheme.OpenCover.{u} (pullback f (𝒰.map i))) [∀ i j, IsAffine ((𝒰' i).obj j)]
(h𝒰' : ∀ i j k,
Q (pullback.mapDesc ((𝒰' i).map j) ((𝒰' i).map k) (𝒰.pullbackHom f i))) :
P.diagonal f := by
letI := isLocal_affineProperty P
let 𝒱 := (Scheme.Pullback.openCoverOfBase 𝒰 f f).bind fun i =>
Scheme.Pullback.openCoverOfLeftRight.{u} (𝒰' i) (𝒰' i) (pullback.snd _ _) (pullback.snd _ _)
have i1 : ∀ i, IsAffine (𝒱.obj i) := fun i => by dsimp [𝒱]; infer_instance
apply of_openCover 𝒱
rintro ⟨i, j, k⟩
dsimp [𝒱]
convert (Q.cancel_left_of_respectsIso
((pullbackDiagonalMapIso _ _ ((𝒰' i).map j) ((𝒰' i).map k)).inv ≫
pullback.map _ _ _ _ (𝟙 _) (𝟙 _) (𝟙 _) _ _) (pullback.snd _ _)).mp _ using 1
· simp
· ext1 <;> simp
· simp only [Category.assoc, limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app,
Functor.const_obj_obj, cospan_one, cospan_left, cospan_right, Category.comp_id]
convert h𝒰' i j k
ext1 <;> simp [Scheme.OpenCover.pullbackHom]
theorem HasAffineProperty.diagonal_of_openCover_diagonal
(P) {Q} [HasAffineProperty P Q]
{X Y : Scheme.{u}} (f : X ⟶ Y) (𝒰 : Scheme.OpenCover.{u} Y) [∀ i, IsAffine (𝒰.obj i)]
(h𝒰 : ∀ i, Q.diagonal (𝒰.pullbackHom f i)) :
P.diagonal f :=
diagonal_of_openCover P f 𝒰 (fun _ ↦ Scheme.affineCover _)
(fun _ _ _ ↦ h𝒰 _ _ _)
theorem HasAffineProperty.diagonal_of_diagonal_of_isPullback
(P) {Q} [HasAffineProperty P Q]
{X Y U V : Scheme.{u}} {f : X ⟶ Y} {g : U ⟶ Y}
[IsAffine U] [IsOpenImmersion g]
{iV : V ⟶ X} {f' : V ⟶ U} (h : IsPullback iV f' f g) (H : P.diagonal f) :
Q.diagonal f' := by
letI := isLocal_affineProperty P
rw [← Q.diagonal.cancel_left_of_respectsIso h.isoPullback.inv,
h.isoPullback_inv_snd]
rintro U V f₁ f₂ hU hV hf₁ hf₂
rw [← Q.cancel_left_of_respectsIso (pullbackDiagonalMapIso f _ f₁ f₂).hom]
convert HasAffineProperty.of_isPullback (P := P) (.of_hasPullback _ _) H
· apply pullback.hom_ext <;> simp
· infer_instance
· infer_instance
theorem HasAffineProperty.diagonal_iff
(P) {Q} [HasAffineProperty P Q] {X Y} {f : X ⟶ Y} [IsAffine Y] :
Q.diagonal f ↔ P.diagonal f := by
letI := isLocal_affineProperty P
refine ⟨fun hf ↦ ?_, diagonal_of_diagonal_of_isPullback P .of_id_fst⟩
rw [← Q.diagonal.cancel_left_of_respectsIso
(pullback.fst (f := f) (g := 𝟙 Y)), pullback.condition, Category.comp_id] at hf
let 𝒰 := X.affineCover.pushforwardIso (inv (pullback.fst (f := f) (g := 𝟙 Y)))
have (i) : IsAffine (𝒰.obj i) := by dsimp [𝒰]; infer_instance
exact HasAffineProperty.diagonal_of_openCover P f (Scheme.openCoverOfIsIso (𝟙 _))
(fun _ ↦ 𝒰) (fun _ _ _ ↦ hf _ _)
instance HasAffineProperty.diagonal_affineProperty_isLocal
{Q : AffineTargetMorphismProperty} [Q.IsLocal] :
Q.diagonal.IsLocal where
respectsIso := inferInstance
to_basicOpen {X Y} _ f r hf :=
diagonal_of_diagonal_of_isPullback (targetAffineLocally Q)
(isPullback_morphismRestrict f (Y.basicOpen r)).flip
((diagonal_iff (targetAffineLocally Q)).mp hf)
of_basicOpenCover {X Y} _ f s hs hs' := by
refine (diagonal_iff (targetAffineLocally Q)).mpr ?_
let 𝒰 := Y.openCoverOfISupEqTop _ (((isAffineOpen_top Y).basicOpen_union_eq_self_iff _).mpr hs)
have (i) : IsAffine (𝒰.obj i) := (isAffineOpen_top Y).basicOpen i.1
refine diagonal_of_openCover_diagonal (targetAffineLocally Q) f 𝒰 ?_
intro i
exact (Q.diagonal.arrow_mk_iso_iff
(morphismRestrictEq _ (by simp [𝒰]) ≪≫ morphismRestrictOpensRange _ _)).mp (hs' i)
instance (P) {Q} [HasAffineProperty P Q] : HasAffineProperty P.diagonal Q.diagonal where
isLocal_affineProperty := letI := HasAffineProperty.isLocal_affineProperty P; inferInstance
eq_targetAffineLocally' := by
ext X Y f
letI := HasAffineProperty.isLocal_affineProperty P
constructor
· exact fun H U ↦ HasAffineProperty.diagonal_of_diagonal_of_isPullback P
(isPullback_morphismRestrict f U).flip H
· exact fun H ↦ HasAffineProperty.diagonal_of_openCover_diagonal P f Y.affineCover
(fun i ↦ of_targetAffineLocally_of_isPullback (.of_hasPullback _ _) H)
instance (P) [IsLocalAtTarget P] : IsLocalAtTarget P.diagonal :=
letI := HasAffineProperty.of_isLocalAtTarget P
inferInstance
end Diagonal
section Universally
theorem universally_isLocalAtTarget (P : MorphismProperty Scheme)
(hP₂ : ∀ {X Y : Scheme.{u}} (f : X ⟶ Y) {ι : Type u} (U : ι → Y.Opens)
(_ : iSup U = ⊤), (∀ i, P (f ∣_ U i)) → P f) : IsLocalAtTarget P.universally := by
apply IsLocalAtTarget.mk'
· exact fun {X Y} f U => P.universally_stableUnderBaseChange
(isPullback_morphismRestrict f U).flip
· intros X Y f ι U hU H X' Y' i₁ i₂ f' h
apply hP₂ _ (fun i ↦ i₂ ⁻¹ᵁ U i)
· rw [← top_le_iff] at hU ⊢
rintro x -
simpa using @hU (i₂.1.base x) trivial
· rintro i
refine H _ ((X'.restrictIsoOfEq ?_).hom ≫ i₁ ∣_ _) (i₂ ∣_ _) _ ?_
· exact congr($(h.1.1) ⁻¹ᵁ U i)
· rw [← (isPullback_morphismRestrict f _).paste_vert_iff]
· simp only [Scheme.restrictIsoOfEq, Category.assoc, morphismRestrict_ι,
IsOpenImmersion.isoOfRangeEq_hom_fac_assoc]
exact (isPullback_morphismRestrict f' (i₂ ⁻¹ᵁ U i)).paste_vert h
· rw [← cancel_mono (Scheme.Opens.ι _)]
simp [IsOpenImmersion.isoOfRangeEq_hom_fac_assoc, Scheme.restrictIsoOfEq,
morphismRestrict_ι_assoc, h.1.1]
end Universally
section Topologically
/-- `topologically P` holds for a morphism if the underlying topological map satisfies `P`. -/
def topologically
(P : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (_ : α → β), Prop) :
MorphismProperty Scheme.{u} := fun _ _ f => P f.1.base
variable (P : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (_ : α → β), Prop)
/-- If a property of maps of topological spaces is stable under composition, the induced
morphism property of schemes is stable under composition. -/
lemma topologically_isStableUnderComposition
(hP : ∀ {α β γ : Type u} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
(f : α → β) (g : β → γ) (_ : P f) (_ : P g), P (g ∘ f)) :
(topologically P).IsStableUnderComposition where
comp_mem {X Y Z} f g hf hg := by
simp only [topologically, Scheme.comp_coeBase, TopCat.coe_comp]
exact hP _ _ hf hg
/-- If a property of maps of topological spaces is satisfied by all homeomorphisms,
every isomorphism of schemes satisfies the induced property. -/
lemma topologically_iso_le
(hP : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α ≃ₜ β), P f) :
MorphismProperty.isomorphisms Scheme ≤ (topologically P) := by
intro X Y e (he : IsIso e)
have : IsIso e := he
exact hP (TopCat.homeoOfIso (asIso e.val.base))
/-- If a property of maps of topological spaces is satisfied by homeomorphisms and is stable
under composition, the induced property on schemes respects isomorphisms. -/
lemma topologically_respectsIso
(hP₁ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α ≃ₜ β), P f)
(hP₂ : ∀ {α β γ : Type u} [TopologicalSpace α] [TopologicalSpace β] [TopologicalSpace γ]
(f : α → β) (g : β → γ) (_ : P f) (_ : P g), P (g ∘ f)) :
(topologically P).RespectsIso :=
have : (topologically P).IsStableUnderComposition :=
topologically_isStableUnderComposition P hP₂
MorphismProperty.respectsIso_of_isStableUnderComposition (topologically_iso_le P hP₁)
/-- To check that a topologically defined morphism property is local at the target,
we may check the corresponding properties on topological spaces. -/
lemma topologically_isLocalAtTarget
[(topologically P).RespectsIso]
(hP₂ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β) (s : Set β),
P f → P (s.restrictPreimage f))
(hP₃ : ∀ {α β : Type u} [TopologicalSpace α] [TopologicalSpace β] (f : α → β) {ι : Type u}
(U : ι → TopologicalSpace.Opens β) (_ : iSup U = ⊤) (_ : Continuous f),
(∀ i, P ((U i).carrier.restrictPreimage f)) → P f) :
IsLocalAtTarget (topologically P) := by
apply IsLocalAtTarget.mk'
· intro X Y f U hf
simp_rw [topologically, morphismRestrict_val_base]
exact hP₂ f.val.base U.carrier hf
· intro X Y f ι U hU hf
apply hP₃ f.val.base U hU f.val.base.continuous fun i ↦ ?_
rw [← morphismRestrict_val_base]
exact hf i
end Topologically
/-- `stalkwise P` holds for a morphism if all stalks satisfy `P`. -/
def stalkwise (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop) :
MorphismProperty Scheme.{u} :=
fun _ _ f => ∀ x, P (f.stalkMap x)
section Stalkwise
variable {P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop}
/-- If `P` respects isos, then `stalkwise P` respects isos. -/
lemma stalkwise_respectsIso (hP : RingHom.RespectsIso P) :
(stalkwise P).RespectsIso where
precomp {X Y Z} e f hf := by
simp only [stalkwise, Scheme.comp_coeBase, TopCat.coe_comp, Function.comp_apply]
intro x
rw [Scheme.stalkMap_comp]
exact (RingHom.RespectsIso.cancel_right_isIso hP _ _).mpr <| hf (e.hom.val.base x)
postcomp {X Y Z} e f hf := by
simp only [stalkwise, Scheme.comp_coeBase, TopCat.coe_comp, Function.comp_apply]
intro x
rw [Scheme.stalkMap_comp]
exact (RingHom.RespectsIso.cancel_left_isIso hP _ _).mpr <| hf x
/-- If `P` respects isos, then `stalkwise P` is local at the target. -/
lemma stalkwiseIsLocalAtTarget_of_respectsIso (hP : RingHom.RespectsIso P) :
IsLocalAtTarget (stalkwise P) := by
have hP' : (RingHom.toMorphismProperty P).RespectsIso :=
RingHom.toMorphismProperty_respectsIso_iff.mp hP
letI := stalkwise_respectsIso hP
apply IsLocalAtTarget.mk'
· intro X Y f U hf x
apply ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
morphismRestrictStalkMap f U x).mpr <| hf _
· intro X Y f ι U hU hf x
have hy : f.val.base x ∈ iSup U := by rw [hU]; trivial
obtain ⟨i, hi⟩ := Opens.mem_iSup.mp hy
exact ((RingHom.toMorphismProperty P).arrow_mk_iso_iff <|
morphismRestrictStalkMap f (U i) ⟨x, hi⟩).mp <| hf i ⟨x, hi⟩
end Stalkwise
namespace AffineTargetMorphismProperty
/-- If `P` is local at the target, to show that `P` is stable under base change, it suffices to
check this for base change along a morphism of affine schemes. -/
lemma stableUnderBaseChange_of_stableUnderBaseChangeOnAffine_of_isLocalAtTarget
(P : MorphismProperty Scheme) [IsLocalAtTarget P]
(hP₂ : (of P).StableUnderBaseChange) :
P.StableUnderBaseChange :=
letI := HasAffineProperty.of_isLocalAtTarget P
HasAffineProperty.stableUnderBaseChange hP₂
end AffineTargetMorphismProperty
@[deprecated (since := "2024-06-22")]
alias diagonalTargetAffineLocallyOfOpenCover := HasAffineProperty.diagonal_of_openCover
@[deprecated (since := "2024-06-22")]
alias AffineTargetMorphismProperty.diagonalOfTargetAffineLocally :=
HasAffineProperty.diagonal_of_diagonal_of_isPullback
@[deprecated (since := "2024-06-22")]
alias universallyIsLocalAtTarget := universally_isLocalAtTarget
@[deprecated (since := "2024-06-22")]
alias universallyIsLocalAtTargetOfMorphismRestrict :=
universally_isLocalAtTarget
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\FiniteType.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.RingHomProperties
import Mathlib.RingTheory.RingHom.FiniteType
/-!
# Morphisms of finite type
A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.
A morphism of schemes is of finite type if it is both locally of finite type and quasi-compact.
We show that these properties are local, and are stable under compositions and base change.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism of schemes `f : X ⟶ Y` is locally of finite type if for each affine `U ⊆ Y` and
`V ⊆ f ⁻¹' U`, The induced map `Γ(Y, U) ⟶ Γ(X, V)` is of finite type.
-/
@[mk_iff]
class LocallyOfFiniteType (f : X ⟶ Y) : Prop where
finiteType_of_affine_subset :
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), (f.appLE U V e).FiniteType
instance : HasRingHomProperty @LocallyOfFiniteType RingHom.FiniteType where
isLocal_ringHomProperty := RingHom.finiteType_is_local
eq_affineLocally' := by
ext X Y f
rw [locallyOfFiniteType_iff, affineLocally_iff_affineOpens_le]
instance (priority := 900) locallyOfFiniteType_of_isOpenImmersion [IsOpenImmersion f] :
LocallyOfFiniteType f :=
HasRingHomProperty.of_isOpenImmersion
instance locallyOfFiniteType_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : LocallyOfFiniteType f] [hg : LocallyOfFiniteType g] : LocallyOfFiniteType (f ≫ g) :=
MorphismProperty.comp_mem _ f g hf hg
theorem locallyOfFiniteType_of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[LocallyOfFiniteType (f ≫ g)] : LocallyOfFiniteType f :=
HasRingHomProperty.of_comp (fun f g ↦ RingHom.FiniteType.of_comp_finiteType) ‹_›
open scoped TensorProduct in
lemma locallyOfFiniteType_stableUnderBaseChange :
MorphismProperty.StableUnderBaseChange @LocallyOfFiniteType :=
HasRingHomProperty.stableUnderBaseChange RingHom.finiteType_stableUnderBaseChange
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\IsIso.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.OpenImmersion
import Mathlib.Topology.IsLocalHomeomorph
/-!
# Being an isomorphism is local at the target
-/
open CategoryTheory MorphismProperty
namespace AlgebraicGeometry
lemma isomorphisms_eq_isOpenImmersion_inf_surjective :
isomorphisms Scheme = (@IsOpenImmersion ⊓ @Surjective : MorphismProperty Scheme) := by
ext
exact (isIso_iff_isOpenImmersion _).trans
(and_congr Iff.rfl ((TopCat.epi_iff_surjective _).trans (surjective_iff _).symm))
lemma isomorphisms_eq_stalkwise :
isomorphisms Scheme = (isomorphisms TopCat).inverseImage Scheme.forgetToTop ⊓
stalkwise (fun f ↦ Function.Bijective f) := by
rw [isomorphisms_eq_isOpenImmersion_inf_surjective, isOpenImmersion_eq_inf,
surjective_eq_topologically, inf_right_comm]
congr 1
ext X Y f
exact ⟨fun H ↦ inferInstanceAs (IsIso (TopCat.isoOfHomeo
(H.1.1.toHomeomeomorph_of_surjective H.2)).hom), fun (_ : IsIso f.1.base) ↦
let e := (TopCat.homeoOfIso <| asIso f.1.base); ⟨e.openEmbedding, e.surjective⟩⟩
instance : IsLocalAtTarget (isomorphisms Scheme) :=
isomorphisms_eq_isOpenImmersion_inf_surjective ▸ inferInstance
instance : HasAffineProperty (isomorphisms Scheme) fun X Y f _ ↦ IsAffine X ∧ IsIso (f.app ⊤) := by
convert HasAffineProperty.of_isLocalAtTarget (isomorphisms Scheme) with X Y f hY
exact ⟨fun ⟨_, _⟩ ↦ (arrow_mk_iso_iff (isomorphisms _) (arrowIsoSpecΓOfIsAffine f)).mpr
(inferInstanceAs (IsIso (Spec.map (f.app ⊤)))),
fun (_ : IsIso f) ↦ ⟨isAffine_of_isIso f, inferInstance⟩⟩
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\OpenImmersion.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
/-!
# Open immersions
A morphism is an open immersion if the underlying map of spaces is an open embedding
`f : X ⟶ U ⊆ Y`, and the sheaf map `Y(V) ⟶ f _* X(V)` is an iso for each `V ⊆ U`.
Most of the theories are developed in `AlgebraicGeometry/OpenImmersion`, and we provide the
remaining theorems analogous to other lemmas in `AlgebraicGeometry/Morphisms/*`.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
namespace AlgebraicGeometry
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
theorem isOpenImmersion_iff_stalk {f : X ⟶ Y} : IsOpenImmersion f ↔
OpenEmbedding f.1.base ∧ ∀ x, IsIso (f.stalkMap x) := by
constructor
· intro h; exact ⟨h.1, inferInstance⟩
· rintro ⟨h₁, h₂⟩; exact IsOpenImmersion.of_stalk_iso f h₁
theorem isOpenImmersion_eq_inf :
@IsOpenImmersion = (topologically OpenEmbedding) ⊓
stalkwise (fun f ↦ Function.Bijective f) := by
ext
exact isOpenImmersion_iff_stalk.trans
(and_congr Iff.rfl (forall_congr' fun x ↦ ConcreteCategory.isIso_iff_bijective _))
instance isOpenImmersion_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @IsOpenImmersion where
comp_mem f g _ _ := LocallyRingedSpace.IsOpenImmersion.comp f g
instance isOpenImmersion_respectsIso : MorphismProperty.RespectsIso @IsOpenImmersion := by
apply MorphismProperty.respectsIso_of_isStableUnderComposition
intro _ _ f (hf : IsIso f)
have : IsIso f := hf
infer_instance
instance : IsLocalAtTarget (stalkwise (fun f ↦ Function.Bijective f)) := by
apply stalkwiseIsLocalAtTarget_of_respectsIso
rw [RingHom.toMorphismProperty_respectsIso_iff]
convert (inferInstanceAs (MorphismProperty.isomorphisms CommRingCat).RespectsIso)
ext
exact (ConcreteCategory.isIso_iff_bijective _).symm
instance isOpenImmersion_isLocalAtTarget : IsLocalAtTarget @IsOpenImmersion :=
isOpenImmersion_eq_inf ▸ inferInstance
theorem isOpenImmersion_stableUnderBaseChange :
MorphismProperty.StableUnderBaseChange @IsOpenImmersion :=
MorphismProperty.StableUnderBaseChange.mk <| by
intro X Y Z f g H; infer_instance
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\Preimmersion.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.UnderlyingMap
import Mathlib.RingTheory.LocalProperties
/-!
# Preimmersions of schemes
A morphism of schemes `f : X ⟶ Y` is a preimmersion if the underlying map of topological spaces
is an embedding and the induced morphisms of stalks are all surjective. This is not a concept seen
in the literature but it is useful for generalizing results on immersions to other maps including
`Spec 𝒪_{X, x} ⟶ X` and inclusions of fibers `κ(x) ×ₓ Y ⟶ Y`.
## TODO
* Show preimmersions are local at the target.
* Show preimmersions are stable under pullback.
* Show that `Spec f` is a preimmersion for `f : R ⟶ S` if every `s : S` is of the form `f a / f b`.
-/
universe v u
open CategoryTheory
namespace AlgebraicGeometry
/-- A morphism of schemes `f : X ⟶ Y` is a preimmersion if the underlying map of
topological spaces is an embedding and the induced morphisms of stalks are all surjective. -/
@[mk_iff]
class IsPreimmersion {X Y : Scheme} (f : X ⟶ Y) : Prop where
base_embedding : Embedding f.1.base
surj_on_stalks : ∀ x, Function.Surjective (f.stalkMap x)
lemma Scheme.Hom.embedding {X Y : Scheme} (f : Hom X Y) [IsPreimmersion f] : Embedding f.1.base :=
IsPreimmersion.base_embedding
lemma Scheme.Hom.stalkMap_surjective {X Y : Scheme} (f : Hom X Y) [IsPreimmersion f] (x) :
Function.Surjective (f.stalkMap x) :=
IsPreimmersion.surj_on_stalks x
lemma isPreimmersion_eq_inf :
@IsPreimmersion = topologically Embedding ⊓ stalkwise (Function.Surjective ·) := by
ext
rw [isPreimmersion_iff]
rfl
/-- Being surjective on stalks is local at the target. -/
instance isSurjectiveOnStalks_isLocalAtTarget : IsLocalAtTarget
(stalkwise (Function.Surjective ·)) :=
stalkwiseIsLocalAtTarget_of_respectsIso surjective_respectsIso
namespace IsPreimmersion
instance : IsLocalAtTarget @IsPreimmersion :=
isPreimmersion_eq_inf ▸ inferInstance
instance (priority := 900) {X Y : Scheme} (f : X ⟶ Y) [IsOpenImmersion f] : IsPreimmersion f where
base_embedding := f.openEmbedding.toEmbedding
surj_on_stalks _ := (ConcreteCategory.bijective_of_isIso _).2
instance : MorphismProperty.IsMultiplicative @IsPreimmersion where
id_mem _ := inferInstance
comp_mem {X Y Z} f g hf hg := by
refine ⟨hg.base_embedding.comp hf.base_embedding, fun x ↦ ?_⟩
rw [Scheme.stalkMap_comp]
exact (hf.surj_on_stalks x).comp (hg.surj_on_stalks (f.1.1 x))
instance comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion f]
[IsPreimmersion g] : IsPreimmersion (f ≫ g) :=
MorphismProperty.IsStableUnderComposition.comp_mem f g inferInstance inferInstance
instance (priority := 900) {X Y} (f : X ⟶ Y) [IsPreimmersion f] : Mono f := by
refine (Scheme.forgetToLocallyRingedSpace ⋙
LocallyRingedSpace.forgetToSheafedSpace).mono_of_mono_map ?_
apply SheafedSpace.mono_of_base_injective_of_stalk_epi
· exact f.embedding.inj
· exact fun x ↦ ConcreteCategory.epi_of_surjective _ (f.stalkMap_surjective x)
theorem of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion g]
[IsPreimmersion (f ≫ g)] : IsPreimmersion f where
base_embedding := by
have h := (f ≫ g).embedding
rwa [← g.embedding.of_comp_iff]
surj_on_stalks x := by
have h := (f ≫ g).stalkMap_surjective x
rw [Scheme.stalkMap_comp] at h
exact Function.Surjective.of_comp h
theorem comp_iff {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [IsPreimmersion g] :
IsPreimmersion (f ≫ g) ↔ IsPreimmersion f :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
end IsPreimmersion
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\QuasiCompact.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.Basic
import Mathlib.Topology.Spectral.Hom
import Mathlib.AlgebraicGeometry.Limits
/-!
# Quasi-compact morphisms
A morphism of schemes is quasi-compact if the preimages of quasi-compact open sets are
quasi-compact.
It suffices to check that preimages of affine open sets are compact
(`quasiCompact_iff_forall_affine`).
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/--
A morphism is "quasi-compact" if the underlying map of topological spaces is, i.e. if the preimages
of quasi-compact open sets are quasi-compact.
-/
@[mk_iff]
class QuasiCompact (f : X ⟶ Y) : Prop where
/-- Preimage of compact open set under a quasi-compact morphism between schemes is compact. -/
isCompact_preimage : ∀ U : Set Y, IsOpen U → IsCompact U → IsCompact (f.1.base ⁻¹' U)
theorem quasiCompact_iff_spectral : QuasiCompact f ↔ IsSpectralMap f.1.base :=
⟨fun ⟨h⟩ => ⟨by fun_prop, h⟩, fun h => ⟨h.2⟩⟩
instance (priority := 900) quasiCompact_of_isIso {X Y : Scheme} (f : X ⟶ Y) [IsIso f] :
QuasiCompact f := by
constructor
intro U _ hU'
convert hU'.image (inv f.1.base).continuous_toFun using 1
rw [Set.image_eq_preimage_of_inverse]
· delta Function.LeftInverse
exact IsIso.inv_hom_id_apply f.1.base
· exact IsIso.hom_inv_id_apply f.1.base
instance quasiCompact_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiCompact f]
[QuasiCompact g] : QuasiCompact (f ≫ g) := by
constructor
intro U hU hU'
rw [Scheme.comp_val_base, TopCat.coe_comp, Set.preimage_comp]
apply QuasiCompact.isCompact_preimage
· exact Continuous.isOpen_preimage (by fun_prop) _ hU
apply QuasiCompact.isCompact_preimage <;> assumption
theorem isCompactOpen_iff_eq_finset_affine_union {X : Scheme} (U : Set X) :
IsCompact U ∧ IsOpen U ↔ ∃ s : Set X.affineOpens, s.Finite ∧ U = ⋃ i ∈ s, i := by
apply Opens.IsBasis.isCompact_open_iff_eq_finite_iUnion
(fun (U : X.affineOpens) => (U : X.Opens))
· rw [Subtype.range_coe]; exact isBasis_affine_open X
· exact fun i => i.2.isCompact
theorem isCompactOpen_iff_eq_basicOpen_union {X : Scheme} [IsAffine X] (U : Set X) :
IsCompact U ∧ IsOpen U ↔
∃ s : Set Γ(X, ⊤), s.Finite ∧ U = ⋃ i ∈ s, X.basicOpen i :=
(isBasis_basicOpen X).isCompact_open_iff_eq_finite_iUnion _
(fun _ => ((isAffineOpen_top _).basicOpen _).isCompact) _
theorem quasiCompact_iff_forall_affine :
QuasiCompact f ↔
∀ U : Y.Opens, IsAffineOpen U → IsCompact (f ⁻¹ᵁ U : Set X) := by
rw [quasiCompact_iff]
refine ⟨fun H U hU => H U U.isOpen hU.isCompact, ?_⟩
intro H U hU hU'
obtain ⟨S, hS, rfl⟩ := (isCompactOpen_iff_eq_finset_affine_union U).mp ⟨hU', hU⟩
simp only [Set.preimage_iUnion]
exact Set.Finite.isCompact_biUnion hS (fun i _ => H i i.prop)
theorem isCompact_basicOpen (X : Scheme) {U : X.Opens} (hU : IsCompact (U : Set X))
(f : Γ(X, U)) : IsCompact (X.basicOpen f : Set X) := by
classical
refine ((isCompactOpen_iff_eq_finset_affine_union _).mpr ?_).1
obtain ⟨s, hs, e⟩ := (isCompactOpen_iff_eq_finset_affine_union _).mp ⟨hU, U.isOpen⟩
let g : s → X.affineOpens := by
intro V
use V.1 ⊓ X.basicOpen f
have : V.1.1 ⟶ U := by
apply homOfLE; change _ ⊆ (U : Set X); rw [e]
convert Set.subset_iUnion₂ (s := fun (U : X.affineOpens) (_ : U ∈ s) => (U : Set X))
V V.prop using 1
erw [← X.toLocallyRingedSpace.toRingedSpace.basicOpen_res this.op]
exact IsAffineOpen.basicOpen V.1.prop _
haveI : Finite s := hs.to_subtype
refine ⟨Set.range g, Set.finite_range g, ?_⟩
refine (Set.inter_eq_right.mpr
(SetLike.coe_subset_coe.2 <| RingedSpace.basicOpen_le _ _)).symm.trans ?_
rw [e, Set.iUnion₂_inter]
apply le_antisymm <;> apply Set.iUnion₂_subset
· intro i hi
-- Porting note: had to make explicit the first given parameter to `Set.subset_iUnion₂`
exact Set.Subset.trans (Set.Subset.rfl : _ ≤ g ⟨i, hi⟩)
(@Set.subset_iUnion₂ _ _ _
(fun (i : X.affineOpens) (_ : i ∈ Set.range g) => (i : Set X.toPresheafedSpace)) _
(Set.mem_range_self ⟨i, hi⟩))
· rintro ⟨i, hi⟩ ⟨⟨j, hj⟩, hj'⟩
rw [← hj']
refine Set.Subset.trans ?_ (Set.subset_iUnion₂ j hj)
exact Set.Subset.rfl
@[reducible]
instance : HasAffineProperty @QuasiCompact (fun X _ _ _ ↦ CompactSpace X) where
eq_targetAffineLocally' := by
ext X Y f
simp only [quasiCompact_iff_forall_affine, isCompact_iff_compactSpace, targetAffineLocally,
Subtype.forall]
rfl
isLocal_affineProperty := by
constructor
· apply AffineTargetMorphismProperty.respectsIso_mk <;> rintro X Y Z e _ _ H
exacts [@Homeomorph.compactSpace _ _ _ _ H (TopCat.homeoOfIso (asIso e.inv.1.base)), H]
· introv _ H
change CompactSpace ((Opens.map f.val.base).obj (Y.basicOpen r))
rw [Scheme.preimage_basicOpen f r]
erw [← isCompact_iff_compactSpace]
rw [← isCompact_univ_iff] at H
apply isCompact_basicOpen
exact H
· rintro X Y H f S hS hS'
rw [← IsAffineOpen.basicOpen_union_eq_self_iff] at hS
· rw [← isCompact_univ_iff]
change IsCompact ((Opens.map f.val.base).obj ⊤).1
rw [← hS]
dsimp [Opens.map]
simp only [Opens.iSup_mk, Opens.coe_mk, Set.preimage_iUnion]
exact isCompact_iUnion fun i => isCompact_iff_compactSpace.mpr (hS' i)
· exact isAffineOpen_top _
theorem quasiCompact_over_affine_iff {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] :
QuasiCompact f ↔ CompactSpace X := by
rw [HasAffineProperty.iff_of_isAffine (P := @QuasiCompact)]
theorem compactSpace_iff_quasiCompact (X : Scheme) :
CompactSpace X ↔ QuasiCompact (terminal.from X) := by
rw [HasAffineProperty.iff_of_isAffine (P := @QuasiCompact)]
instance quasiCompact_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @QuasiCompact where
comp_mem _ _ _ _ := inferInstance
theorem quasiCompact_stableUnderBaseChange :
MorphismProperty.StableUnderBaseChange @QuasiCompact := by
letI := HasAffineProperty.isLocal_affineProperty @QuasiCompact
apply HasAffineProperty.stableUnderBaseChange
apply AffineTargetMorphismProperty.StableUnderBaseChange.mk
intro X Y S _ _ f g h
let 𝒰 := Scheme.Pullback.openCoverOfRight Y.affineCover.finiteSubcover f g
have : Finite 𝒰.J := by dsimp [𝒰]; infer_instance
have : ∀ i, CompactSpace (𝒰.obj i) := by intro i; dsimp [𝒰]; infer_instance
exact 𝒰.compactSpace
variable {Z : Scheme.{u}}
instance (f : X ⟶ Z) (g : Y ⟶ Z) [QuasiCompact g] : QuasiCompact (pullback.fst f g) :=
quasiCompact_stableUnderBaseChange.fst f g inferInstance
instance (f : X ⟶ Z) (g : Y ⟶ Z) [QuasiCompact f] : QuasiCompact (pullback.snd f g) :=
quasiCompact_stableUnderBaseChange.snd f g inferInstance
@[elab_as_elim]
theorem compact_open_induction_on {P : X.Opens → Prop} (S : X.Opens)
(hS : IsCompact S.1) (h₁ : P ⊥)
(h₂ : ∀ (S : X.Opens) (_ : IsCompact S.1) (U : X.affineOpens), P S → P (S ⊔ U)) :
P S := by
classical
obtain ⟨s, hs, hs'⟩ := (isCompactOpen_iff_eq_finset_affine_union S.1).mp ⟨hS, S.2⟩
replace hs' : S = iSup fun i : s => (i : X.Opens) := by ext1; simpa using hs'
subst hs'
apply @Set.Finite.induction_on _ _ _ hs
· convert h₁; rw [iSup_eq_bot]; rintro ⟨_, h⟩; exact h.elim
· intro x s _ hs h₄
have : IsCompact (⨆ i : s, (i : X.Opens)).1 := by
refine ((isCompactOpen_iff_eq_finset_affine_union _).mpr ?_).1; exact ⟨s, hs, by simp⟩
convert h₂ _ this x h₄
rw [iSup_subtype, sup_comm]
conv_rhs => rw [iSup_subtype]
exact iSup_insert
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen (X : Scheme)
{U : X.Opens} (hU : IsAffineOpen U) (x f : Γ(X, U))
(H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
rw [← map_zero (X.presheaf.map (homOfLE <| X.basicOpen_le f : X.basicOpen f ⟶ U).op)] at H
obtain ⟨⟨_, n, rfl⟩, e⟩ := (hU.isLocalization_basicOpen f).exists_of_eq H
exact ⟨n, by simpa [mul_comm x] using e⟩
/-- If `x : Γ(X, U)` is zero on `D(f)` for some `f : Γ(X, U)`, and `U` is quasi-compact, then
`f ^ n * x = 0` for some `n`. -/
theorem exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact (X : Scheme.{u})
{U : X.Opens} (hU : IsCompact U.1) (x f : Γ(X, U))
(H : x |_ X.basicOpen f = 0) : ∃ n : ℕ, f ^ n * x = 0 := by
obtain ⟨s, hs, e⟩ := (isCompactOpen_iff_eq_finset_affine_union U.1).mp ⟨hU, U.2⟩
replace e : U = iSup fun i : s => (i : X.Opens) := by
ext1; simpa using e
have h₁ : ∀ i : s, i.1.1 ≤ U := by
intro i
change (i : X.Opens) ≤ U
rw [e]
-- Porting note: `exact le_iSup _ _` no longer works
exact le_iSup (fun (i : s) => (i : Opens (X.toPresheafedSpace))) _
have H' := fun i : s =>
exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isAffineOpen X i.1.2
(X.presheaf.map (homOfLE (h₁ i)).op x) (X.presheaf.map (homOfLE (h₁ i)).op f) ?_
swap
· delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at H ⊢
convert congr_arg (X.presheaf.map (homOfLE _).op) H
-- Note: the below was `simp only [← comp_apply]`
· rw [← comp_apply, ← comp_apply]
· simp only [← Functor.map_comp]
rfl
· rw [map_zero]
· simp only [Scheme.basicOpen_res, inf_le_right]
choose n hn using H'
haveI := hs.to_subtype
cases nonempty_fintype s
use Finset.univ.sup n
suffices ∀ i : s, X.presheaf.map (homOfLE (h₁ i)).op (f ^ Finset.univ.sup n * x) = 0 by
subst e
apply TopCat.Sheaf.eq_of_locally_eq X.sheaf fun i : s => (i : X.Opens)
intro i
rw [map_zero]
apply this
intro i
replace hn :=
congr_arg (fun x => X.presheaf.map (homOfLE (h₁ i)).op (f ^ (Finset.univ.sup n - n i)) * x)
(hn i)
dsimp at hn
simp only [← map_mul, ← map_pow] at hn
rwa [mul_zero, ← mul_assoc, ← pow_add, tsub_add_cancel_of_le] at hn
apply Finset.le_sup (Finset.mem_univ i)
/-- A section over a compact open of a scheme is nilpotent if and only if its associated
basic open is empty. -/
lemma Scheme.isNilpotent_iff_basicOpen_eq_bot_of_isCompact {X : Scheme.{u}}
{U : X.Opens} (hU : IsCompact (U : Set X)) (f : Γ(X, U)) :
IsNilpotent f ↔ X.basicOpen f = ⊥ := by
refine ⟨X.basicOpen_eq_bot_of_isNilpotent U f, fun hf ↦ ?_⟩
have h : (1 : Γ(X, U)) |_ X.basicOpen f = (0 : Γ(X, X.basicOpen f)) := by
have e : X.basicOpen f ≤ ⊥ := by rw [hf]
rw [← X.presheaf.restrict_restrict e bot_le]
have : Subsingleton Γ(X, ⊥) :=
CommRingCat.subsingleton_of_isTerminal X.sheaf.isTerminalOfEmpty
rw [Subsingleton.eq_zero (1 |_ ⊥)]
show X.presheaf.map _ 0 = 0
rw [map_zero]
obtain ⟨n, hn⟩ := exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact X hU 1 f h
rw [mul_one] at hn
use n
/-- The zero locus of a set of sections over a compact open of a scheme is `X` if and only if
`s` is contained in the nilradical of `Γ(X, U)`. -/
lemma Scheme.zeroLocus_eq_top_iff_subset_nilradical_of_isCompact {X : Scheme.{u}} {U : X.Opens}
(hU : IsCompact (U : Set X)) (s : Set Γ(X, U)) :
X.zeroLocus s = ⊤ ↔ s ⊆ nilradical Γ(X, U) := by
simp [Scheme.zeroLocus_def, ← Scheme.isNilpotent_iff_basicOpen_eq_bot_of_isCompact hU,
← mem_nilradical, Set.subset_def]
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\QuasiSeparated.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.Constructors
import Mathlib.AlgebraicGeometry.Morphisms.QuasiCompact
import Mathlib.Topology.QuasiSeparated
/-!
# Quasi-separated morphisms
A morphism of schemes `f : X ⟶ Y` is quasi-separated if the diagonal morphism `X ⟶ X ×[Y] X` is
quasi-compact.
A scheme is quasi-separated if the intersections of any two affine open sets is quasi-compact.
(`AlgebraicGeometry.quasiSeparatedSpace_iff_affine`)
We show that a morphism is quasi-separated if the preimage of every affine open is quasi-separated.
We also show that this property is local at the target,
and is stable under compositions and base-changes.
## Main result
- `AlgebraicGeometry.is_localization_basicOpen_of_qcqs` (**Qcqs lemma**):
If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/
@[mk_iff]
class QuasiSeparated (f : X ⟶ Y) : Prop where
/-- A morphism is `QuasiSeparated` if diagonal map is quasi-compact. -/
diagonalQuasiCompact : QuasiCompact (pullback.diagonal f) := by infer_instance
theorem quasiSeparatedSpace_iff_affine (X : Scheme) :
QuasiSeparatedSpace X ↔ ∀ U V : X.affineOpens, IsCompact (U ∩ V : Set X) := by
rw [quasiSeparatedSpace_iff]
constructor
· intro H U V; exact H U V U.1.2 U.2.isCompact V.1.2 V.2.isCompact
· intro H
suffices
∀ (U : X.Opens) (_ : IsCompact U.1) (V : X.Opens) (_ : IsCompact V.1),
IsCompact (U ⊓ V).1
by intro U V hU hU' hV hV'; exact this ⟨U, hU⟩ hU' ⟨V, hV⟩ hV'
intro U hU V hV
refine compact_open_induction_on V hV ?_ ?_
· simp
· intro S _ V hV
change IsCompact (U.1 ∩ (S.1 ∪ V.1))
rw [Set.inter_union_distrib_left]
apply hV.union
clear hV
refine compact_open_induction_on U hU ?_ ?_
· simp
· intro S _ W hW
change IsCompact ((S.1 ∪ W.1) ∩ V.1)
rw [Set.union_inter_distrib_right]
apply hW.union
apply H
theorem quasiCompact_affineProperty_iff_quasiSeparatedSpace {X Y : Scheme} [IsAffine Y]
(f : X ⟶ Y) :
AffineTargetMorphismProperty.diagonal (fun X _ _ _ ↦ CompactSpace X) f ↔
QuasiSeparatedSpace X := by
delta AffineTargetMorphismProperty.diagonal
rw [quasiSeparatedSpace_iff_affine]
constructor
· intro H U V
haveI : IsAffine _ := U.2
haveI : IsAffine _ := V.2
let g : pullback U.1.ι V.1.ι ⟶ X := pullback.fst _ _ ≫ U.1.ι
-- Porting note: `inferInstance` does not work here
have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
erw [Subtype.range_coe, Subtype.range_coe] at e
rw [isCompact_iff_compactSpace]
exact @Homeomorph.compactSpace _ _ _ _ (H _ _) e
· introv H h₁ h₂
let g : pullback f₁ f₂ ⟶ X := pullback.fst _ _ ≫ f₁
-- Porting note: `inferInstance` does not work here
have : IsOpenImmersion g := PresheafedSpace.IsOpenImmersion.comp _ _
have e := Homeomorph.ofEmbedding _ this.base_open.toEmbedding
rw [IsOpenImmersion.range_pullback_to_base_of_left] at e
simp_rw [isCompact_iff_compactSpace] at H
exact
@Homeomorph.compactSpace _ _ _ _
(H ⟨⟨_, h₁.base_open.isOpen_range⟩, isAffineOpen_opensRange _⟩
⟨⟨_, h₂.base_open.isOpen_range⟩, isAffineOpen_opensRange _⟩)
e.symm
theorem quasiSeparated_eq_diagonal_is_quasiCompact :
@QuasiSeparated = MorphismProperty.diagonal @QuasiCompact := by ext; exact quasiSeparated_iff _
@[reducible]
instance : HasAffineProperty @QuasiSeparated (fun X _ _ _ ↦ QuasiSeparatedSpace X) where
__ := HasAffineProperty.copy
quasiSeparated_eq_diagonal_is_quasiCompact.symm
(by ext; exact quasiCompact_affineProperty_iff_quasiSeparatedSpace _)
instance (priority := 900) quasiSeparatedOfMono {X Y : Scheme} (f : X ⟶ Y) [Mono f] :
QuasiSeparated f where
instance quasiSeparated_isStableUnderComposition :
MorphismProperty.IsStableUnderComposition @QuasiSeparated :=
quasiSeparated_eq_diagonal_is_quasiCompact.symm ▸
(MorphismProperty.diagonal_isStableUnderComposition quasiCompact_stableUnderBaseChange)
theorem quasiSeparated_stableUnderBaseChange :
MorphismProperty.StableUnderBaseChange @QuasiSeparated :=
quasiSeparated_eq_diagonal_is_quasiCompact.symm ▸ quasiCompact_stableUnderBaseChange.diagonal
instance quasiSeparatedComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiSeparated f]
[QuasiSeparated g] : QuasiSeparated (f ≫ g) :=
MorphismProperty.comp_mem _ f g inferInstance inferInstance
theorem quasiSeparated_over_affine_iff {X Y : Scheme} (f : X ⟶ Y) [IsAffine Y] :
QuasiSeparated f ↔ QuasiSeparatedSpace X := by
rw [HasAffineProperty.iff_of_isAffine (P := @QuasiSeparated)]
theorem quasiSeparatedSpace_iff_quasiSeparated (X : Scheme) :
QuasiSeparatedSpace X ↔ QuasiSeparated (terminal.from X) :=
(quasiSeparated_over_affine_iff _).symm
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [QuasiSeparated g] :
QuasiSeparated (pullback.fst f g) :=
quasiSeparated_stableUnderBaseChange.fst f g inferInstance
instance {X Y S : Scheme} (f : X ⟶ S) (g : Y ⟶ S) [QuasiSeparated f] :
QuasiSeparated (pullback.snd f g) :=
quasiSeparated_stableUnderBaseChange.snd f g inferInstance
theorem quasiSeparatedSpace_of_quasiSeparated {X Y : Scheme} (f : X ⟶ Y)
[hY : QuasiSeparatedSpace Y] [QuasiSeparated f] : QuasiSeparatedSpace X := by
rw [quasiSeparatedSpace_iff_quasiSeparated] at hY ⊢
rw [← terminalIsTerminal.hom_ext (f ≫ terminal.from Y) (terminal.from X)]
infer_instance
instance quasiSeparatedSpace_of_isAffine (X : Scheme) [IsAffine X] :
QuasiSeparatedSpace X := by
constructor
intro U V hU hU' hV hV'
obtain ⟨s, hs, e⟩ := (isCompactOpen_iff_eq_basicOpen_union _).mp ⟨hU', hU⟩
obtain ⟨s', hs', e'⟩ := (isCompactOpen_iff_eq_basicOpen_union _).mp ⟨hV', hV⟩
rw [e, e', Set.iUnion₂_inter]
simp_rw [Set.inter_iUnion₂]
apply hs.isCompact_biUnion
intro i _
apply hs'.isCompact_biUnion
intro i' _
change IsCompact (X.basicOpen i ⊓ X.basicOpen i').1
rw [← Scheme.basicOpen_mul]
exact ((isAffineOpen_top _).basicOpen _).isCompact
theorem IsAffineOpen.isQuasiSeparated {X : Scheme} {U : X.Opens} (hU : IsAffineOpen U) :
IsQuasiSeparated (U : Set X) := by
rw [isQuasiSeparated_iff_quasiSeparatedSpace]
exacts [@AlgebraicGeometry.quasiSeparatedSpace_of_isAffine _ hU, U.isOpen]
theorem QuasiSeparated.of_comp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z) [QuasiSeparated (f ≫ g)] :
QuasiSeparated f := by
let 𝒰 := (Z.affineCover.pullbackCover g).bind fun x => Scheme.affineCover _
have (i) : IsAffine (𝒰.obj i) := by dsimp [𝒰]; infer_instance
apply HasAffineProperty.of_openCover
((Z.affineCover.pullbackCover g).bind fun x => Scheme.affineCover _)
rintro ⟨i, j⟩; dsimp at i j
refine @quasiSeparatedSpace_of_quasiSeparated _ _ ?_
(HasAffineProperty.of_isPullback (.of_hasPullback _ (Z.affineCover.map i)) ‹_›) ?_
· exact pullback.map _ _ _ _ (𝟙 _) _ _ (by simp) (Category.comp_id _) ≫
(pullbackRightPullbackFstIso g (Z.affineCover.map i) f).hom
· exact inferInstance
theorem exists_eq_pow_mul_of_isAffineOpen (X : Scheme) (U : X.Opens) (hU : IsAffineOpen U)
(f : Γ(X, U)) (x : Γ(X, X.basicOpen f)) :
∃ (n : ℕ) (y : Γ(X, U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
have := (hU.isLocalization_basicOpen f).2
obtain ⟨⟨y, _, n, rfl⟩, d⟩ := this x
use n, y
delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
simpa [mul_comm x] using d.symm
theorem exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux_aux {X : TopCat}
(F : X.Presheaf CommRingCat) {U₁ U₂ U₃ U₄ U₅ U₆ U₇ : Opens X} {n₁ n₂ : ℕ}
{y₁ : F.obj (op U₁)} {y₂ : F.obj (op U₂)} {f : F.obj (op <| U₁ ⊔ U₂)}
{x : F.obj (op U₃)} (h₄₁ : U₄ ≤ U₁) (h₄₂ : U₄ ≤ U₂) (h₅₁ : U₅ ≤ U₁) (h₅₃ : U₅ ≤ U₃)
(h₆₂ : U₆ ≤ U₂) (h₆₃ : U₆ ≤ U₃) (h₇₄ : U₇ ≤ U₄) (h₇₅ : U₇ ≤ U₅) (h₇₆ : U₇ ≤ U₆)
(e₁ : y₁ |_ U₅ = (f |_ U₁ |_ U₅) ^ n₁ * x |_ U₅)
(e₂ : y₂ |_ U₆ = (f |_ U₂ |_ U₆) ^ n₂ * x |_ U₆) :
(((f |_ U₁) ^ n₂ * y₁) |_ U₄) |_ U₇ = (((f |_ U₂) ^ n₁ * y₂) |_ U₄) |_ U₇ := by
apply_fun (fun x : F.obj (op U₅) ↦ x |_ U₇) at e₁
apply_fun (fun x : F.obj (op U₆) ↦ x |_ U₇) at e₂
dsimp only [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict] at e₁ e₂ ⊢
simp only [map_mul, map_pow, ← comp_apply, ← op_comp, ← F.map_comp, homOfLE_comp] at e₁ e₂ ⊢
rw [e₁, e₂, mul_left_comm]
theorem exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux (X : Scheme)
(S : X.affineOpens) (U₁ U₂ : X.Opens) {n₁ n₂ : ℕ} {y₁ : Γ(X, U₁)}
{y₂ : Γ(X, U₂)} {f : Γ(X, U₁ ⊔ U₂)}
{x : Γ(X, X.basicOpen f)} (h₁ : S.1 ≤ U₁) (h₂ : S.1 ≤ U₂)
(e₁ : y₁ |_ X.basicOpen (f |_ U₁) = ((f |_ U₁ |_ X.basicOpen _) ^ n₁) * x |_ X.basicOpen _)
(e₂ : y₂ |_ X.basicOpen (f |_ U₂) = ((f |_ U₂ |_ X.basicOpen _) ^ n₂) * x |_ X.basicOpen _) :
∃ n : ℕ, ∀ m, n ≤ m →
((f |_ U₁) ^ (m + n₂) * y₁) |_ S.1 = ((f |_ U₂) ^ (m + n₁) * y₂) |_ S.1 := by
obtain ⟨⟨_, n, rfl⟩, e⟩ :=
(@IsLocalization.eq_iff_exists _ _ _ _ _ _
(S.2.isLocalization_basicOpen (f |_ S.1))
(((f |_ U₁) ^ n₂ * y₁) |_ S.1)
(((f |_ U₂) ^ n₁ * y₂) |_ S.1)).mp <| by
apply exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux_aux (e₁ := e₁) (e₂ := e₂)
· show X.basicOpen _ ≤ _
simp only [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
repeat rw [Scheme.basicOpen_res] -- Note: used to be part of the `simp only`
exact inf_le_inf h₁ le_rfl
· show X.basicOpen _ ≤ _
simp only [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict]
repeat rw [Scheme.basicOpen_res] -- Note: used to be part of the `simp only`
exact inf_le_inf h₂ le_rfl
use n
intros m hm
rw [← tsub_add_cancel_of_le hm]
simp only [TopCat.Presheaf.restrictOpen, TopCat.Presheaf.restrict,
pow_add, map_pow, map_mul, ← comp_apply, mul_assoc, ← Functor.map_comp, ← op_comp, homOfLE_comp,
Subtype.coe_mk] at e ⊢
rw [e]
theorem exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated (X : Scheme.{u}) (U : X.Opens)
(hU : IsCompact U.1) (hU' : IsQuasiSeparated U.1) (f : Γ(X, U)) (x : Γ(X, X.basicOpen f)) :
∃ (n : ℕ) (y : Γ(X, U)), y |_ X.basicOpen f = (f |_ X.basicOpen f) ^ n * x := by
delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict
revert hU' f x
refine compact_open_induction_on U hU ?_ ?_
· intro _ f x
use 0, f
refine @Subsingleton.elim _
(CommRingCat.subsingleton_of_isTerminal (X.sheaf.isTerminalOfEqEmpty ?_)) _ _
erw [eq_bot_iff]
exact X.basicOpen_le f
· -- Given `f : 𝒪(S ∪ U), x : 𝒪(X_f)`, we need to show that `f ^ n * x` is the restriction of
-- some `y : 𝒪(S ∪ U)` for some `n : ℕ`.
intro S hS U hU hSU f x
-- We know that such `y₁, n₁` exists on `S` by the induction hypothesis.
obtain ⟨n₁, y₁, hy₁⟩ :=
hU (hSU.of_subset Set.subset_union_left) (X.presheaf.map (homOfLE le_sup_left).op f)
(X.presheaf.map (homOfLE _).op x)
-- · rw [X.basicOpen_res]; exact inf_le_right
-- We know that such `y₂, n₂` exists on `U` since `U` is affine.
obtain ⟨n₂, y₂, hy₂⟩ :=
exists_eq_pow_mul_of_isAffineOpen X _ U.2 (X.presheaf.map (homOfLE le_sup_right).op f)
(X.presheaf.map (homOfLE _).op x)
delta TopCat.Presheaf.restrictOpen TopCat.Presheaf.restrict at hy₂
-- swap; · rw [X.basicOpen_res]; exact inf_le_right
-- Since `S ∪ U` is quasi-separated, `S ∩ U` can be covered by finite affine opens.
obtain ⟨s, hs', hs⟩ :=
(isCompactOpen_iff_eq_finset_affine_union _).mp
⟨hSU _ _ Set.subset_union_left S.2 hS Set.subset_union_right U.1.2
U.2.isCompact,
(S ⊓ U.1).2⟩
haveI := hs'.to_subtype
cases nonempty_fintype s
replace hs : S ⊓ U.1 = iSup fun i : s => (i : X.Opens) := by ext1; simpa using hs
have hs₁ : ∀ i : s, i.1.1 ≤ S := by
intro i; change (i : X.Opens) ≤ S
refine le_trans ?_ (inf_le_left (b := U.1))
erw [hs]
-- Porting note: have to add argument explicitly
exact @le_iSup X.Opens s _ (fun (i : s) => (i : X.Opens)) i
have hs₂ : ∀ i : s, i.1.1 ≤ U.1 := by
intro i; change (i : X.Opens) ≤ U
refine le_trans ?_ (inf_le_right (a := S))
erw [hs]
-- Porting note: have to add argument explicitly
exact @le_iSup X.Opens s _ (fun (i : s) => (i : X.Opens)) i
-- On each affine open in the intersection, we have `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
-- for some `n` since `f ^ n₂ * y₁ = f ^ (n₁ + n₂) * x = f ^ n₁ * y₂` on `X_f`.
have := fun i ↦ exists_eq_pow_mul_of_is_compact_of_quasi_separated_space_aux
X i.1 S U (hs₁ i) (hs₂ i) hy₁ hy₂
choose n hn using this
-- We can thus choose a big enough `n` such that `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`
-- on `S ∩ U`.
have :
X.presheaf.map (homOfLE <| inf_le_left).op
(X.presheaf.map (homOfLE le_sup_left).op f ^ (Finset.univ.sup n + n₂) * y₁) =
X.presheaf.map (homOfLE <| inf_le_right).op
(X.presheaf.map (homOfLE le_sup_right).op f ^ (Finset.univ.sup n + n₁) * y₂) := by
fapply X.sheaf.eq_of_locally_eq' fun i : s => i.1.1
· refine fun i => homOfLE ?_; erw [hs]
-- Porting note: have to add argument explicitly
exact @le_iSup X.Opens s _ (fun (i : s) => (i : X.Opens)) i
· exact le_of_eq hs
· intro i
delta Scheme.sheaf SheafedSpace.sheaf
repeat rw [← comp_apply,]
simp only [← Functor.map_comp, ← op_comp]
apply hn
exact Finset.le_sup (Finset.mem_univ _)
use Finset.univ.sup n + n₁ + n₂
-- By the sheaf condition, since `f ^ (n + n₂) * y₁ = f ^ (n + n₁) * y₂`, it can be glued into
-- the desired section on `S ∪ U`.
use (X.sheaf.objSupIsoProdEqLocus S U.1).inv ⟨⟨_ * _, _ * _⟩, this⟩
refine (X.sheaf.objSupIsoProdEqLocus_inv_eq_iff _ _ _ (X.basicOpen_res _
(homOfLE le_sup_left).op) (X.basicOpen_res _ (homOfLE le_sup_right).op)).mpr ⟨?_, ?_⟩
· delta Scheme.sheaf SheafedSpace.sheaf
rw [add_assoc, add_comm n₁]
simp only [pow_add, map_pow, map_mul]
rw [hy₁] -- Note: `simp` can't use this
repeat rw [← comp_apply] -- Note: `simp` can't use this
simp only [← mul_assoc, ← Functor.map_comp, ← op_comp, homOfLE_comp]
· delta Scheme.sheaf SheafedSpace.sheaf
simp only [pow_add, map_pow, map_mul]
rw [hy₂] -- Note: `simp` can't use this
repeat rw [← comp_apply] -- Note: `simp` can't use this
simp only [← mul_assoc, ← Functor.map_comp, ← op_comp, homOfLE_comp]
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem is_localization_basicOpen_of_qcqs {X : Scheme} {U : X.Opens} (hU : IsCompact U.1)
(hU' : IsQuasiSeparated U.1) (f : Γ(X, U)) :
IsLocalization.Away f (Γ(X, X.basicOpen f)) := by
constructor
· rintro ⟨_, n, rfl⟩
simp only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra]
exact IsUnit.pow _ (RingedSpace.isUnit_res_basicOpen _ f)
· intro z
obtain ⟨n, y, e⟩ := exists_eq_pow_mul_of_isCompact_of_isQuasiSeparated X U hU hU' f z
refine ⟨⟨y, _, n, rfl⟩, ?_⟩
simpa only [map_pow, Subtype.coe_mk, RingHom.algebraMap_toAlgebra, mul_comm z] using e.symm
· intro x y
rw [← sub_eq_zero, ← map_sub, RingHom.algebraMap_toAlgebra]
simp_rw [← @sub_eq_zero _ _ (_ * x) (_ * y), ← mul_sub]
generalize x - y = z
intro H
obtain ⟨n, e⟩ := exists_pow_mul_eq_zero_of_res_basicOpen_eq_zero_of_isCompact X hU _ _ H
refine ⟨⟨_, n, rfl⟩, ?_⟩
simpa [mul_comm z] using e
/-- If `U` is qcqs, then `Γ(X, D(f)) ≃ Γ(X, U)_f` for every `f : Γ(X, U)`.
This is known as the **Qcqs lemma** in [R. Vakil, *The rising sea*][RisingSea]. -/
theorem isIso_ΓSpec_adjunction_unit_app_basicOpen {X : Scheme} [CompactSpace X]
[QuasiSeparatedSpace X] (f : X.presheaf.obj (op ⊤)) :
IsIso ((ΓSpec.adjunction.unit.app X).val.c.app (op (PrimeSpectrum.basicOpen f))) := by
refine @IsIso.of_isIso_comp_right _ _ _ _ _ _ (X.presheaf.map
(eqToHom (ΓSpec.adjunction_unit_map_basicOpen _ _).symm).op) _ ?_
rw [ConcreteCategory.isIso_iff_bijective, CommRingCat.forget_map]
apply (config := { allowSynthFailures := true }) IsLocalization.bijective
· exact StructureSheaf.IsLocalization.to_basicOpen _ _
· refine is_localization_basicOpen_of_qcqs ?_ ?_ _
· exact isCompact_univ
· exact isQuasiSeparated_univ
· rw [← CommRingCat.comp_eq_ring_hom_comp]
simp [RingHom.algebraMap_toAlgebra]
rw [ΓSpec.toOpen_unit_app_val_c_app'_assoc, ← Functor.map_comp]
rfl
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\RingHomProperties.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.Basic
import Mathlib.RingTheory.LocalProperties
/-!
# Properties of morphisms from properties of ring homs.
We provide the basic framework for talking about properties of morphisms that come from properties
of ring homs. For `P` a property of ring homs, we have two ways of defining a property of scheme
morphisms:
Let `f : X ⟶ Y`,
- `targetAffineLocally (affine_and P)`: the preimage of an affine open `U = Spec A` is affine
(`= Spec B`) and `A ⟶ B` satisfies `P`. (TODO)
- `affineLocally P`: For each pair of affine open `U = Spec A ⊆ X` and `V = Spec B ⊆ f ⁻¹' U`,
the ring hom `A ⟶ B` satisfies `P`.
For these notions to be well defined, we require `P` be a sufficient local property. For the former,
`P` should be local on the source (`RingHom.RespectsIso P`, `RingHom.LocalizationPreserves P`,
`RingHom.OfLocalizationSpan`), and `targetAffineLocally (affine_and P)` will be local on
the target. (TODO)
For the latter `P` should be local on the target (`RingHom.PropertyIsLocal P`), and
`affineLocally P` will be local on both the source and the target.
We also provide the following interface:
## `HasRingHomProperty`
`HasRingHomProperty P Q` is a type class asserting that `P` is local at the target and the source,
and for `f : Spec B ⟶ Spec A`, it is equivalent to the ring hom property `Q` on `Γ(f)`.
For `HasRingHomProperty P Q` and `f : X ⟶ Y`, we provide these API lemmas:
- `AlgebraicGeometry.HasRingHomProperty.iff_appLE`:
`P f` if and only if `Q (f.appLE U V _)` for all affine `U : Opens Y` and `V : Opens X`.
- `AlgebraicGeometry.HasRingHomProperty.iff_of_source_openCover`:
If `Y` is affine, `P f ↔ ∀ i, Q ((𝒰.map i ≫ f).app ⊤)` for an affine open cover `𝒰` of `X`.
- `AlgebraicGeometry.HasRingHomProperty.iff_of_isAffine`:
If `X` and `Y` are affine, then `P f ↔ Q (f.app ⊤)`.
- `AlgebraicGeometry.HasRingHomProperty.Spec_iff`:
`P (Spec.map φ) ↔ Q φ`
- `AlgebraicGeometry.HasRingHomProperty.iff_of_iSup_eq_top`:
If `Y` is affine, `P f ↔ ∀ i, Q (f.appLE ⊤ (U i) _)` for a family `U` of affine opens of `X`.
- `AlgebraicGeometry.HasRingHomProperty.of_isOpenImmersion`:
If `f` is an open immersion then `P f`.
- `AlgebraicGeometry.HasRingHomProperty.stableUnderBaseChange`:
If `Q` is stable under base change, then so is `P`.
We also provide the instances `P.IsMultiplicative`, `P.IsStableUnderComposition`,
`IsLocalAtTarget P`, `IsLocalAtSource P`.
-/
-- Explicit universe annotations were used in this file to improve perfomance #12737
universe u
open CategoryTheory Opposite TopologicalSpace CategoryTheory.Limits AlgebraicGeometry
namespace RingHom
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
theorem StableUnderBaseChange.pullback_fst_app_top
(hP : StableUnderBaseChange P) (hP' : RespectsIso P)
{X Y S : Scheme} [IsAffine X] [IsAffine Y] [IsAffine S] (f : X ⟶ S) (g : Y ⟶ S)
(H : P (g.app ⊤)) : P ((pullback.fst f g).app ⊤) := by
-- Porting note (#11224): change `rw` to `erw`
erw [← PreservesPullback.iso_inv_fst AffineScheme.forgetToScheme (AffineScheme.ofHom f)
(AffineScheme.ofHom g)]
rw [Scheme.comp_app, hP'.cancel_right_isIso, AffineScheme.forgetToScheme_map]
have := congr_arg Quiver.Hom.unop
(PreservesPullback.iso_hom_fst AffineScheme.Γ.rightOp (AffineScheme.ofHom f)
(AffineScheme.ofHom g))
simp only [AffineScheme.Γ, Functor.rightOp_obj, Functor.comp_obj, Functor.op_obj, unop_comp,
AffineScheme.forgetToScheme_obj, Scheme.Γ_obj, Functor.rightOp_map, Functor.comp_map,
Functor.op_map, Quiver.Hom.unop_op, AffineScheme.forgetToScheme_map, Scheme.Γ_map] at this
rw [← this, hP'.cancel_right_isIso, ← pushoutIsoUnopPullback_inl_hom, hP'.cancel_right_isIso]
exact hP.pushout_inl _ hP' _ _ H
end RingHom
namespace AlgebraicGeometry
section affineLocally
variable (P : ∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)
/-- For `P` a property of ring homomorphisms, `sourceAffineLocally P` holds for `f : X ⟶ Y`
whenever `P` holds for the restriction of `f` on every affine open subset of `X`. -/
def sourceAffineLocally : AffineTargetMorphismProperty := fun X _ f _ =>
∀ U : X.affineOpens, P (f.appLE ⊤ U le_top)
/-- For `P` a property of ring homomorphisms, `affineLocally P` holds for `f : X ⟶ Y` if for each
affine open `U = Spec A ⊆ Y` and `V = Spec B ⊆ f ⁻¹' U`, the ring hom `A ⟶ B` satisfies `P`.
Also see `affineLocally_iff_affineOpens_le`. -/
abbrev affineLocally : MorphismProperty Scheme.{u} :=
targetAffineLocally (sourceAffineLocally P)
theorem sourceAffineLocally_respectsIso (h₁ : RingHom.RespectsIso P) :
(sourceAffineLocally P).toProperty.RespectsIso := by
apply AffineTargetMorphismProperty.respectsIso_mk
· introv H U
have : IsIso (e.hom.appLE (e.hom ''ᵁ U) U.1 (e.hom.preimage_image_eq _).ge) :=
inferInstanceAs (IsIso (e.hom.app _ ≫
X.presheaf.map (eqToHom (e.hom.preimage_image_eq _).symm).op))
rw [← Scheme.appLE_comp_appLE _ _ ⊤ (e.hom ''ᵁ U) U.1 le_top (e.hom.preimage_image_eq _).ge,
h₁.cancel_right_isIso]
exact H ⟨_, U.prop.image_of_isOpenImmersion e.hom⟩
· introv H U
rw [Scheme.comp_appLE, h₁.cancel_left_isIso]
exact H U
theorem affineLocally_respectsIso (h : RingHom.RespectsIso P) : (affineLocally P).RespectsIso :=
letI := sourceAffineLocally_respectsIso P h
inferInstance
open Scheme in
theorem sourceAffineLocally_morphismRestrict {X Y : Scheme.{u}} (f : X ⟶ Y)
(U : Y.Opens) (hU : IsAffineOpen U) :
@sourceAffineLocally P _ _ (f ∣_ U) hU ↔
∀ (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U), P (f.appLE U V e) := by
dsimp only [sourceAffineLocally]
simp only [morphismRestrict_appLE]
rw [(affineOpensRestrict (f ⁻¹ᵁ U)).forall_congr_left, Subtype.forall]
refine forall₂_congr fun V h ↦ ?_
have := (affineOpensRestrict (f ⁻¹ᵁ U)).apply_symm_apply ⟨V, h⟩
exact f.appLE_congr _ (Opens.ι_image_top _) congr($(this).1.1) _
theorem affineLocally_iff_affineOpens_le {X Y : Scheme.{u}} (f : X ⟶ Y) :
affineLocally.{u} P f ↔
∀ (U : Y.affineOpens) (V : X.affineOpens) (e : V.1 ≤ f ⁻¹ᵁ U.1), P (f.appLE U V e) :=
forall_congr' fun U ↦ sourceAffineLocally_morphismRestrict P f U U.2
theorem sourceAffineLocally_isLocal (h₁ : RingHom.RespectsIso P)
(h₂ : RingHom.LocalizationPreserves P) (h₃ : RingHom.OfLocalizationSpan P) :
(sourceAffineLocally P).IsLocal := by
constructor
· exact sourceAffineLocally_respectsIso P h₁
· intro X Y _ f r H
rw [sourceAffineLocally_morphismRestrict]
intro U hU
have : X.basicOpen (f.appLE ⊤ U (by simp) r) = U := by
simp only [Scheme.Hom.appLE, Opens.map_top, CommRingCat.coe_comp_of, RingHom.coe_comp,
Function.comp_apply]
rw [Scheme.basicOpen_res]
simpa using hU
rw [← f.appLE_congr _ rfl this P,
IsAffineOpen.appLE_eq_away_map f (isAffineOpen_top Y) U.2 _ r]
apply (config := { allowSynthFailures := true }) h₂.away
exact H U
· introv hs hs' U
apply h₃ _ _ hs
intro r
simp_rw [sourceAffineLocally_morphismRestrict] at hs'
have := hs' r ⟨X.basicOpen (f.appLE ⊤ U le_top r.1), U.2.basicOpen (f.appLE ⊤ U le_top r.1)⟩
(by simp [Scheme.Hom.appLE])
rwa [IsAffineOpen.appLE_eq_away_map f (isAffineOpen_top Y) U.2,
← h₁.is_localization_away_iff] at this
end affineLocally
/--
`HasRingHomProperty P Q` is a type class asserting that `P` is local at the target and the source,
and for `f : Spec B ⟶ Spec A`, it is equivalent to the ring hom property `Q`.
To make the proofs easier, we state it instead as
1. `Q` is local (See `RingHom.PropertyIsLocal`)
2. `P f` if and only if `Q` holds for every `Γ(Y, U) ⟶ Γ(X, V)` for all affine `U`, `V`.
See `HasRingHomProperty.iff_appLE`.
-/
class HasRingHomProperty (P : MorphismProperty Scheme.{u})
(Q : outParam (∀ {R S : Type u} [CommRing R] [CommRing S], (R →+* S) → Prop)) : Prop where
isLocal_ringHomProperty : RingHom.PropertyIsLocal Q
eq_affineLocally' : P = affineLocally Q
namespace HasRingHomProperty
variable (P : MorphismProperty Scheme.{u}) {Q} [HasRingHomProperty P Q]
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
lemma eq_affineLocally : P = affineLocally Q := eq_affineLocally'
@[local instance]
lemma HasAffineProperty : HasAffineProperty P (sourceAffineLocally Q) where
isLocal_affineProperty := sourceAffineLocally_isLocal _
(isLocal_ringHomProperty P).respectsIso
(isLocal_ringHomProperty P).LocalizationPreserves
(isLocal_ringHomProperty P).ofLocalizationSpan
eq_targetAffineLocally' := eq_affineLocally P
theorem appLE (H : P f) (U : Y.affineOpens) (V : X.affineOpens) (e) : Q (f.appLE U V e) := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le] at H
exact H _ _ _
theorem app_top (H : P f) [IsAffine X] [IsAffine Y] : Q (f.app ⊤) := by
rw [Scheme.Hom.app_eq_appLE]
exact appLE P f H ⟨_, isAffineOpen_top _⟩ ⟨_, isAffineOpen_top _⟩ _
theorem comp_of_isOpenImmersion [IsOpenImmersion f] (H : P g) :
P (f ≫ g) := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le] at H ⊢
intro U V e
have : IsIso (f.appLE (f ''ᵁ V) V.1 (f.preimage_image_eq _).ge) :=
inferInstanceAs (IsIso (f.app _ ≫
X.presheaf.map (eqToHom (f.preimage_image_eq _).symm).op))
rw [← Scheme.appLE_comp_appLE _ _ _ (f ''ᵁ V) V.1
(Set.image_subset_iff.mpr e) (f.preimage_image_eq _).ge,
(isLocal_ringHomProperty P).respectsIso.cancel_right_isIso]
exact H _ ⟨_, V.2.image_of_isOpenImmersion _⟩ _
variable {P f}
lemma iff_appLE : P f ↔ ∀ (U : Y.affineOpens) (V : X.affineOpens) (e), Q (f.appLE U V e) := by
rw [eq_affineLocally P, affineLocally_iff_affineOpens_le]
theorem of_source_openCover [IsAffine Y]
(𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] (H : ∀ i, Q ((𝒰.map i ≫ f).app ⊤)) :
P f := by
rw [HasAffineProperty.iff_of_isAffine (P := P)]
intro U
let S i : X.affineOpens := ⟨_, isAffineOpen_opensRange (𝒰.map i)⟩
induction U using of_affine_open_cover S 𝒰.iSup_opensRange with
| basicOpen U r H =>
simp_rw [Scheme.affineBasicOpen_coe,
← f.appLE_map (U := ⊤) le_top (homOfLE (X.basicOpen_le r)).op]
apply (isLocal_ringHomProperty P).StableUnderComposition _ _ H
have := U.2.isLocalization_basicOpen r
apply (isLocal_ringHomProperty P).HoldsForLocalizationAway _ r
| openCover U s hs H =>
apply (isLocal_ringHomProperty P).OfLocalizationSpanTarget.ofIsLocalization
(isLocal_ringHomProperty P).respectsIso _ _ hs
rintro r
refine ⟨_, _, _, IsAffineOpen.isLocalization_basicOpen U.2 r, ?_⟩
rw [RingHom.algebraMap_toAlgebra, ← CommRingCat.comp_eq_ring_hom_comp, Scheme.Hom.appLE_map]
exact H r
| hU i =>
specialize H i
rw [← (isLocal_ringHomProperty P).respectsIso.cancel_right_isIso _
((IsOpenImmersion.isoOfRangeEq (𝒰.map i) (S i).1.ι
Subtype.range_coe.symm).inv.app _), ← Scheme.comp_app,
IsOpenImmersion.isoOfRangeEq_inv_fac_assoc, Scheme.comp_app,
Scheme.Opens.ι_app, Scheme.Hom.app_eq_appLE, Scheme.Hom.appLE_map] at H
exact (f.appLE_congr _ rfl (by simp) Q).mp H
theorem iff_of_source_openCover [IsAffine Y] (𝒰 : X.OpenCover) [∀ i, IsAffine (𝒰.obj i)] :
P f ↔ ∀ i, Q ((𝒰.map i ≫ f).app ⊤) :=
⟨fun H i ↦ app_top P _ (comp_of_isOpenImmersion P (𝒰.map i) f H), of_source_openCover 𝒰⟩
theorem iff_of_isAffine [IsAffine X] [IsAffine Y] :
P f ↔ Q (f.app ⊤) := by
rw [iff_of_source_openCover (P := P) (Scheme.openCoverOfIsIso.{u} (𝟙 _))]
simp
theorem Spec_iff {R S : CommRingCat.{u}} {φ : R ⟶ S} :
P (Spec.map φ) ↔ Q φ := by
have H := (isLocal_ringHomProperty P).respectsIso
rw [iff_of_isAffine (P := P), ← H.cancel_right_isIso _ (Scheme.ΓSpecIso _).hom,
Scheme.ΓSpecIso_naturality, H.cancel_left_isIso]
theorem of_iSup_eq_top [IsAffine Y] {ι : Type*}
(U : ι → X.affineOpens) (hU : ⨆ i, (U i : Opens X) = ⊤)
(H : ∀ i, Q (f.appLE ⊤ (U i).1 le_top)) :
P f := by
have (i) : IsAffine ((X.openCoverOfISupEqTop _ hU).obj i) := (U i).2
refine of_source_openCover (X.openCoverOfISupEqTop _ hU) fun i ↦ ?_
simpa [Scheme.Hom.app_eq_appLE] using (f.appLE_congr _ rfl (by simp) Q).mp (H i)
theorem iff_of_iSup_eq_top [IsAffine Y] {ι : Type*}
(U : ι → X.affineOpens) (hU : ⨆ i, (U i : Opens X) = ⊤) :
P f ↔ ∀ i, Q (f.appLE ⊤ (U i).1 le_top) :=
⟨fun H _ ↦ appLE P f H ⟨_, isAffineOpen_top _⟩ _ le_top, of_iSup_eq_top U hU⟩
instance : IsLocalAtSource P := by
apply HasAffineProperty.isLocalAtSource
intros X Y f _ 𝒰
simp_rw [← HasAffineProperty.iff_of_isAffine (P := P),
iff_of_source_openCover 𝒰.affineRefinement.openCover,
fun i ↦ iff_of_source_openCover (P := P) (f := 𝒰.map i ≫ f) (𝒰.obj i).affineCover]
simp [Scheme.OpenCover.affineRefinement]
instance : P.ContainsIdentities where
id_mem X := by
rw [IsLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
have : IsAffine (𝟙 X ⁻¹ᵁ U.1) := U.2
rw [morphismRestrict_id, iff_of_isAffine (P := P), Scheme.id_app]
exact (isLocal_ringHomProperty P).HoldsForLocalizationAway.of_bijective _ _
Function.bijective_id
instance : P.IsStableUnderComposition where
comp_mem {X Y Z} f g hf hg := by
wlog hZ : IsAffine Z generalizing X Y Z
· rw [IsLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top _)]
intro U
rw [morphismRestrict_comp]
exact this _ _ (IsLocalAtTarget.restrict hf _) (IsLocalAtTarget.restrict hg _) U.2
wlog hY : IsAffine Y generalizing X Y
· rw [IsLocalAtSource.iff_of_openCover (P := P) (Y.affineCover.pullbackCover f)]
intro i
rw [← Scheme.OpenCover.pullbackHom_map_assoc]
exact this _ _ (IsLocalAtTarget.of_isPullback (.of_hasPullback _ _) hf)
(comp_of_isOpenImmersion _ _ _ hg) inferInstance
wlog hX : IsAffine X generalizing X
· rw [IsLocalAtSource.iff_of_openCover (P := P) X.affineCover]
intro i
rw [← Category.assoc]
exact this _ (comp_of_isOpenImmersion _ _ _ hf) inferInstance
rw [iff_of_isAffine (P := P)] at hf hg ⊢
exact (isLocal_ringHomProperty P).StableUnderComposition _ _ hg hf
theorem of_comp
(H : ∀ {R S T : Type u} [CommRing R] [CommRing S] [CommRing T],
∀ (f : R →+* S) (g : S →+* T), Q (g.comp f) → Q g)
{X Y Z : Scheme.{u}} {f : X ⟶ Y} {g : Y ⟶ Z} (h : P (f ≫ g)) : P f := by
wlog hZ : IsAffine Z generalizing X Y Z
· rw [IsLocalAtTarget.iff_of_iSup_eq_top (P := P) _
(g.preimage_iSup_eq_top (iSup_affineOpens_eq_top Z))]
intro U
have H := IsLocalAtTarget.restrict h U.1
rw [morphismRestrict_comp] at H
exact this H inferInstance
wlog hY : IsAffine Y generalizing X Y
· rw [IsLocalAtTarget.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top Y)]
intro U
have H := comp_of_isOpenImmersion P (f ⁻¹ᵁ U.1).ι (f ≫ g) h
rw [← morphismRestrict_ι_assoc] at H
exact this H inferInstance
wlog hY : IsAffine X generalizing X
· rw [IsLocalAtSource.iff_of_iSup_eq_top (P := P) _ (iSup_affineOpens_eq_top X)]
intro U
have H := comp_of_isOpenImmersion P U.1.ι (f ≫ g) h
rw [← Category.assoc] at H
exact this H inferInstance
rw [iff_of_isAffine (P := P)] at h ⊢
exact H _ _ h
instance : P.IsMultiplicative where
lemma of_isOpenImmersion [IsOpenImmersion f] : P f := IsLocalAtSource.of_isOpenImmersion f
lemma stableUnderBaseChange (hP : RingHom.StableUnderBaseChange Q) : P.StableUnderBaseChange := by
apply HasAffineProperty.stableUnderBaseChange
letI := HasAffineProperty.isLocal_affineProperty P
apply AffineTargetMorphismProperty.StableUnderBaseChange.mk
intros X Y S _ _ f g H
rw [← HasAffineProperty.iff_of_isAffine (P := P)] at H ⊢
wlog hX : IsAffine Y generalizing Y
· rw [IsLocalAtSource.iff_of_openCover (P := P)
(Scheme.Pullback.openCoverOfRight Y.affineCover f g)]
intro i
simp only [Scheme.Pullback.openCoverOfRight_obj, Scheme.Pullback.openCoverOfRight_map,
limit.lift_π, PullbackCone.mk_pt, PullbackCone.mk_π_app, Category.comp_id]
apply this _ (comp_of_isOpenImmersion _ _ _ H) inferInstance
rw [iff_of_isAffine (P := P)] at H ⊢
exact hP.pullback_fst_app_top _ (isLocal_ringHomProperty P).respectsIso _ _ H
end HasRingHomProperty
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\Separated.lean | /-
Copyright (c) 2024 Christian Merten. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Christian Merten
-/
import Mathlib.AlgebraicGeometry.Morphisms.ClosedImmersion
import Mathlib.AlgebraicGeometry.Morphisms.QuasiSeparated
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.MorphismProperty.Limits
/-!
# Separated morphisms
A morphism of schemes is separated if its diagonal morphism is a closed immmersion.
## TODO
- Show separated is stable under composition and base change (this is immediate if
we show that closed immersions are stable under base change).
- Show separated is local at the target.
- Show affine morphisms are separated.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe u
open scoped AlgebraicGeometry
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
/-- A morphism is separated if the diagonal map is a closed immersion. -/
@[mk_iff]
class IsSeparated : Prop where
/-- A morphism is separated if the diagonal map is a closed immersion. -/
diagonal_isClosedImmersion : IsClosedImmersion (pullback.diagonal f) := by infer_instance
namespace IsSeparated
attribute [instance] diagonal_isClosedImmersion
theorem isSeparated_eq_diagonal_isClosedImmersion :
@IsSeparated = MorphismProperty.diagonal @IsClosedImmersion := by
ext
exact isSeparated_iff _
/-- Monomorphisms are separated. -/
instance (priority := 900) isSeparated_of_mono [Mono f] : IsSeparated f where
instance : MorphismProperty.RespectsIso @IsSeparated := by
rw [isSeparated_eq_diagonal_isClosedImmersion]
infer_instance
instance (priority := 900) [IsSeparated f] : QuasiSeparated f where
end IsSeparated
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\UnderlyingMap.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.Topology.LocalAtTarget
import Mathlib.AlgebraicGeometry.Morphisms.Constructors
/-!
## Properties on the underlying functions of morphisms of schemes.
This file includes various results on properties of morphisms of schemes that come from properties
of the underlying map of topological spaces, including
- `Injective`
- `Surjective`
- `IsOpenMap`
- `IsClosedMap`
- `Embedding`
- `OpenEmbedding`
- `ClosedEmbedding`
-/
open CategoryTheory
namespace AlgebraicGeometry
universe u
section Injective
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
instance : MorphismProperty.RespectsIso (topologically Function.Injective) :=
topologically_respectsIso _ (fun e ↦ e.injective) (fun _ _ hf hg ↦ hg.comp hf)
instance injective_isLocalAtTarget : IsLocalAtTarget (topologically Function.Injective) := by
refine topologically_isLocalAtTarget _ (fun _ s h ↦ h.restrictPreimage s)
fun f ι U H _ hf x₁ x₂ e ↦ ?_
obtain ⟨i, hxi⟩ : ∃ i, f x₁ ∈ U i := by simpa using congr(f x₁ ∈ $H)
exact congr(($(@hf i ⟨x₁, hxi⟩ ⟨x₂, show f x₂ ∈ U i from e ▸ hxi⟩ (Subtype.ext e))).1)
end Injective
section Surjective
variable {X Y Z : Scheme.{u}} (f : X ⟶ Y) (g : Y ⟶ Z)
/-- A morphism of schemes is surjective if the underlying map is. -/
@[mk_iff]
class Surjective : Prop where
surj : Function.Surjective f.1.base
lemma surjective_eq_topologically :
@Surjective = topologically Function.Surjective := by ext; exact surjective_iff _
lemma Scheme.Hom.surjective (f : X.Hom Y) [Surjective f] : Function.Surjective f.1.base :=
Surjective.surj
instance (priority := 100) [IsIso f] : Surjective f := ⟨f.homeomorph.surjective⟩
instance [Surjective f] [Surjective g] : Surjective (f ≫ g) := ⟨g.surjective.comp f.surjective⟩
lemma Surjective.of_comp [Surjective (f ≫ g)] : Surjective g where
surj := Function.Surjective.of_comp (g := f.1.base) (f ≫ g).surjective
lemma Surjective.comp_iff [Surjective f] : Surjective (f ≫ g) ↔ Surjective g :=
⟨fun _ ↦ of_comp f g, fun _ ↦ inferInstance⟩
instance : MorphismProperty.RespectsIso @Surjective :=
surjective_eq_topologically ▸ topologically_respectsIso _ (fun e ↦ e.surjective)
(fun _ _ hf hg ↦ hg.comp hf)
instance surjective_isLocalAtTarget : IsLocalAtTarget @Surjective := by
have : MorphismProperty.RespectsIso @Surjective := inferInstance
rw [surjective_eq_topologically] at this ⊢
refine topologically_isLocalAtTarget _ (fun _ s h ↦ h.restrictPreimage s) fun f ι U H _ hf x ↦ ?_
obtain ⟨i, hxi⟩ : ∃ i, x ∈ U i := by simpa using congr(x ∈ $H)
obtain ⟨⟨y, _⟩, hy⟩ := hf i ⟨x, hxi⟩
exact ⟨y, congr(($hy).1)⟩
end Surjective
section IsOpenMap
instance : (topologically IsOpenMap).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isOpenMap) (fun _ _ hf hg ↦ hg.comp hf)
instance isOpenMap_isLocalAtTarget : IsLocalAtTarget (topologically IsOpenMap) :=
topologically_isLocalAtTarget _
(fun _ s hf ↦ hf.restrictPreimage s)
(fun _ _ _ hU _ hf ↦ (isOpenMap_iff_isOpenMap_of_iSup_eq_top hU).mpr hf)
end IsOpenMap
section IsClosedMap
instance : (topologically IsClosedMap).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.isClosedMap) (fun _ _ hf hg ↦ hg.comp hf)
instance isClosedMap_isLocalAtTarget : IsLocalAtTarget (topologically IsClosedMap) :=
topologically_isLocalAtTarget _
(fun _ s hf ↦ hf.restrictPreimage s)
(fun _ _ _ hU _ hf ↦ (isClosedMap_iff_isClosedMap_of_iSup_eq_top hU).mpr hf)
end IsClosedMap
section Embedding
instance : (topologically Embedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.embedding) (fun _ _ hf hg ↦ hg.comp hf)
instance embedding_isLocalAtTarget : IsLocalAtTarget (topologically Embedding) :=
topologically_isLocalAtTarget _
(fun _ s hf ↦ hf.restrictPreimage s)
(fun _ _ _ hU hfcont hf ↦ (embedding_iff_embedding_of_iSup_eq_top hU hfcont).mpr hf)
end Embedding
section OpenEmbedding
instance : (topologically OpenEmbedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.openEmbedding) (fun _ _ hf hg ↦ hg.comp hf)
instance openEmbedding_isLocalAtTarget : IsLocalAtTarget (topologically OpenEmbedding) :=
topologically_isLocalAtTarget _
(fun _ s hf ↦ hf.restrictPreimage s)
(fun _ _ _ hU hfcont hf ↦ (openEmbedding_iff_openEmbedding_of_iSup_eq_top hU hfcont).mpr hf)
end OpenEmbedding
section ClosedEmbedding
instance : (topologically ClosedEmbedding).RespectsIso :=
topologically_respectsIso _ (fun e ↦ e.closedEmbedding) (fun _ _ hf hg ↦ hg.comp hf)
instance closedEmbedding_isLocalAtTarget : IsLocalAtTarget (topologically ClosedEmbedding) :=
topologically_isLocalAtTarget _
(fun _ s hf ↦ hf.restrictPreimage s)
(fun _ _ _ hU hfcont hf ↦ (closedEmbedding_iff_closedEmbedding_of_iSup_eq_top hU hfcont).mpr hf)
end ClosedEmbedding
end AlgebraicGeometry
|
AlgebraicGeometry\Morphisms\UniversallyClosed.lean | /-
Copyright (c) 2022 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.AlgebraicGeometry.Morphisms.Constructors
import Mathlib.Topology.LocalAtTarget
/-!
# Universally closed morphism
A morphism of schemes `f : X ⟶ Y` is universally closed if `X ×[Y] Y' ⟶ Y'` is a closed map
for all base change `Y' ⟶ Y`.
We show that being universally closed is local at the target, and is stable under compositions and
base changes.
-/
noncomputable section
open CategoryTheory CategoryTheory.Limits Opposite TopologicalSpace
universe v u
namespace AlgebraicGeometry
variable {X Y : Scheme.{u}} (f : X ⟶ Y)
open CategoryTheory.MorphismProperty
/-- A morphism of schemes `f : X ⟶ Y` is universally closed if the base change `X ×[Y] Y' ⟶ Y'`
along any morphism `Y' ⟶ Y` is (topologically) a closed map.
-/
@[mk_iff]
class UniversallyClosed (f : X ⟶ Y) : Prop where
out : universally (topologically @IsClosedMap) f
theorem universallyClosed_eq : @UniversallyClosed = universally (topologically @IsClosedMap) := by
ext X Y f; rw [universallyClosed_iff]
theorem universallyClosed_respectsIso : RespectsIso @UniversallyClosed :=
universallyClosed_eq.symm ▸ universally_respectsIso (topologically @IsClosedMap)
theorem universallyClosed_stableUnderBaseChange : StableUnderBaseChange @UniversallyClosed :=
universallyClosed_eq.symm ▸ universally_stableUnderBaseChange (topologically @IsClosedMap)
instance isClosedMap_isStableUnderComposition :
IsStableUnderComposition (topologically @IsClosedMap) where
comp_mem f g hf hg := IsClosedMap.comp (f := f.1.base) (g := g.1.base) hg hf
instance universallyClosed_isStableUnderComposition :
IsStableUnderComposition @UniversallyClosed := by
rw [universallyClosed_eq]
infer_instance
instance universallyClosedTypeComp {X Y Z : Scheme} (f : X ⟶ Y) (g : Y ⟶ Z)
[hf : UniversallyClosed f] [hg : UniversallyClosed g] : UniversallyClosed (f ≫ g) :=
comp_mem _ _ _ hf hg
instance universallyClosed_fst {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hg : UniversallyClosed g] :
UniversallyClosed (pullback.fst f g) :=
universallyClosed_stableUnderBaseChange.fst f g hg
instance universallyClosed_snd {X Y Z : Scheme} (f : X ⟶ Z) (g : Y ⟶ Z) [hf : UniversallyClosed f] :
UniversallyClosed (pullback.snd f g) :=
universallyClosed_stableUnderBaseChange.snd f g hf
instance universallyClosed_isLocalAtTarget : IsLocalAtTarget @UniversallyClosed := by
rw [universallyClosed_eq]
apply universally_isLocalAtTarget
intro X Y f ι U hU H
simp_rw [topologically, morphismRestrict_val_base] at H
exact (isClosedMap_iff_isClosedMap_of_iSup_eq_top hU).mpr H
end AlgebraicGeometry
|
AlgebraicGeometry\PrimeSpectrum\Basic.lean | /-
Copyright (c) 2020 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.RingTheory.PrimeSpectrum
import Mathlib.Topology.Irreducible
import Mathlib.Topology.Sets.Closeds
import Mathlib.Topology.Sober
import Mathlib.RingTheory.Ideal.MinimalPrime
import Mathlib.RingTheory.Ideal.Over
import Mathlib.RingTheory.Localization.Away.Basic
import Mathlib.RingTheory.LocalRing.ResidueField.Defs
/-!
# The Zariski topology on the prime spectrum of a commutative (semi)ring
## Conventions
We denote subsets of (semi)rings with `s`, `s'`, etc...
whereas we denote subsets of prime spectra with `t`, `t'`, etc...
## Inspiration/contributors
The contents of this file draw inspiration from <https://github.com/ramonfmir/lean-scheme>
which has contributions from Ramon Fernandez Mir, Kevin Buzzard, Kenny Lau,
and Chris Hughes (on an earlier repository).
-/
noncomputable section
universe u v
variable (R : Type u) (S : Type v)
namespace PrimeSpectrum
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
/-- The Zariski topology on the prime spectrum of a commutative (semi)ring is defined
via the closed sets of the topology: they are exactly those sets that are the zero locus
of a subset of the ring. -/
instance zariskiTopology : TopologicalSpace (PrimeSpectrum R) :=
TopologicalSpace.ofClosed (Set.range PrimeSpectrum.zeroLocus) ⟨Set.univ, by simp⟩
(by
intro Zs h
rw [Set.sInter_eq_iInter]
choose f hf using fun i : Zs => h i.prop
simp only [← hf]
exact ⟨_, zeroLocus_iUnion _⟩)
(by
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩
exact ⟨_, (union_zeroLocus s t).symm⟩)
theorem isOpen_iff (U : Set (PrimeSpectrum R)) : IsOpen U ↔ ∃ s, Uᶜ = zeroLocus s := by
simp only [@eq_comm _ Uᶜ]; rfl
theorem isClosed_iff_zeroLocus (Z : Set (PrimeSpectrum R)) : IsClosed Z ↔ ∃ s, Z = zeroLocus s := by
rw [← isOpen_compl_iff, isOpen_iff, compl_compl]
theorem isClosed_iff_zeroLocus_ideal (Z : Set (PrimeSpectrum R)) :
IsClosed Z ↔ ∃ I : Ideal R, Z = zeroLocus I :=
(isClosed_iff_zeroLocus _).trans
⟨fun ⟨s, hs⟩ => ⟨_, (zeroLocus_span s).substr hs⟩, fun ⟨I, hI⟩ => ⟨I, hI⟩⟩
theorem isClosed_iff_zeroLocus_radical_ideal (Z : Set (PrimeSpectrum R)) :
IsClosed Z ↔ ∃ I : Ideal R, I.IsRadical ∧ Z = zeroLocus I :=
(isClosed_iff_zeroLocus_ideal _).trans
⟨fun ⟨I, hI⟩ => ⟨_, I.radical_isRadical, (zeroLocus_radical I).substr hI⟩, fun ⟨I, _, hI⟩ =>
⟨I, hI⟩⟩
theorem isClosed_zeroLocus (s : Set R) : IsClosed (zeroLocus s) := by
rw [isClosed_iff_zeroLocus]
exact ⟨s, rfl⟩
theorem zeroLocus_vanishingIdeal_eq_closure (t : Set (PrimeSpectrum R)) :
zeroLocus (vanishingIdeal t : Set R) = closure t := by
rcases isClosed_iff_zeroLocus (closure t) |>.mp isClosed_closure with ⟨I, hI⟩
rw [subset_antisymm_iff, (isClosed_zeroLocus _).closure_subset_iff, hI,
subset_zeroLocus_iff_subset_vanishingIdeal, (gc R).u_l_u_eq_u,
← subset_zeroLocus_iff_subset_vanishingIdeal, ← hI]
exact ⟨subset_closure, subset_zeroLocus_vanishingIdeal t⟩
theorem vanishingIdeal_closure (t : Set (PrimeSpectrum R)) :
vanishingIdeal (closure t) = vanishingIdeal t :=
zeroLocus_vanishingIdeal_eq_closure t ▸ (gc R).u_l_u_eq_u t
theorem closure_singleton (x) : closure ({x} : Set (PrimeSpectrum R)) = zeroLocus x.asIdeal := by
rw [← zeroLocus_vanishingIdeal_eq_closure, vanishingIdeal_singleton]
theorem isClosed_singleton_iff_isMaximal (x : PrimeSpectrum R) :
IsClosed ({x} : Set (PrimeSpectrum R)) ↔ x.asIdeal.IsMaximal := by
rw [← closure_subset_iff_isClosed, ← zeroLocus_vanishingIdeal_eq_closure,
vanishingIdeal_singleton]
constructor <;> intro H
· rcases x.asIdeal.exists_le_maximal x.2.1 with ⟨m, hm, hxm⟩
exact (congr_arg asIdeal (@H ⟨m, hm.isPrime⟩ hxm)) ▸ hm
· exact fun p hp ↦ PrimeSpectrum.ext (H.eq_of_le p.2.1 hp).symm
theorem isRadical_vanishingIdeal (s : Set (PrimeSpectrum R)) : (vanishingIdeal s).IsRadical := by
rw [← vanishingIdeal_closure, ← zeroLocus_vanishingIdeal_eq_closure,
vanishingIdeal_zeroLocus_eq_radical]
apply Ideal.radical_isRadical
theorem vanishingIdeal_anti_mono_iff {s t : Set (PrimeSpectrum R)} (ht : IsClosed t) :
s ⊆ t ↔ vanishingIdeal t ≤ vanishingIdeal s :=
⟨vanishingIdeal_anti_mono, fun h => by
rw [← ht.closure_subset_iff, ← ht.closure_eq]
convert ← zeroLocus_anti_mono_ideal h <;> apply zeroLocus_vanishingIdeal_eq_closure⟩
theorem vanishingIdeal_strict_anti_mono_iff {s t : Set (PrimeSpectrum R)} (hs : IsClosed s)
(ht : IsClosed t) : s ⊂ t ↔ vanishingIdeal t < vanishingIdeal s := by
rw [Set.ssubset_def, vanishingIdeal_anti_mono_iff hs, vanishingIdeal_anti_mono_iff ht,
lt_iff_le_not_le]
/-- The antitone order embedding of closed subsets of `Spec R` into ideals of `R`. -/
def closedsEmbedding (R : Type*) [CommSemiring R] :
(TopologicalSpace.Closeds <| PrimeSpectrum R)ᵒᵈ ↪o Ideal R :=
OrderEmbedding.ofMapLEIff (fun s => vanishingIdeal ↑(OrderDual.ofDual s)) fun s _ =>
(vanishingIdeal_anti_mono_iff s.2).symm
theorem t1Space_iff_isField [IsDomain R] : T1Space (PrimeSpectrum R) ↔ IsField R := by
refine ⟨?_, fun h => ?_⟩
· intro h
have hbot : Ideal.IsPrime (⊥ : Ideal R) := Ideal.bot_prime
exact
Classical.not_not.1
(mt
(Ring.ne_bot_of_isMaximal_of_not_isField <|
(isClosed_singleton_iff_isMaximal _).1 (T1Space.t1 ⟨⊥, hbot⟩))
(by aesop))
· refine ⟨fun x => (isClosed_singleton_iff_isMaximal x).2 ?_⟩
by_cases hx : x.asIdeal = ⊥
· letI := h.toSemifield
exact hx.symm ▸ Ideal.bot_isMaximal
· exact absurd h (Ring.not_isField_iff_exists_prime.2 ⟨x.asIdeal, ⟨hx, x.2⟩⟩)
local notation "Z(" a ")" => zeroLocus (a : Set R)
theorem isIrreducible_zeroLocus_iff_of_radical (I : Ideal R) (hI : I.IsRadical) :
IsIrreducible (zeroLocus (I : Set R)) ↔ I.IsPrime := by
rw [Ideal.isPrime_iff, IsIrreducible]
apply and_congr
· rw [Set.nonempty_iff_ne_empty, Ne, zeroLocus_empty_iff_eq_top]
· trans ∀ x y : Ideal R, Z(I) ⊆ Z(x) ∪ Z(y) → Z(I) ⊆ Z(x) ∨ Z(I) ⊆ Z(y)
· simp_rw [isPreirreducible_iff_closed_union_closed, isClosed_iff_zeroLocus_ideal]
constructor
· rintro h x y
exact h _ _ ⟨x, rfl⟩ ⟨y, rfl⟩
· rintro h _ _ ⟨x, rfl⟩ ⟨y, rfl⟩
exact h x y
· simp_rw [← zeroLocus_inf, subset_zeroLocus_iff_le_vanishingIdeal,
vanishingIdeal_zeroLocus_eq_radical, hI.radical]
constructor
· simp_rw [← SetLike.mem_coe, ← Set.singleton_subset_iff, ← Ideal.span_le, ←
Ideal.span_singleton_mul_span_singleton]
refine fun h x y h' => h _ _ ?_
rw [← hI.radical_le_iff] at h' ⊢
simpa only [Ideal.radical_inf, Ideal.radical_mul] using h'
· simp_rw [or_iff_not_imp_left, SetLike.not_le_iff_exists]
rintro h s t h' ⟨x, hx, hx'⟩ y hy
exact h (h' ⟨Ideal.mul_mem_right _ _ hx, Ideal.mul_mem_left _ _ hy⟩) hx'
theorem isIrreducible_zeroLocus_iff (I : Ideal R) :
IsIrreducible (zeroLocus (I : Set R)) ↔ I.radical.IsPrime :=
zeroLocus_radical I ▸ isIrreducible_zeroLocus_iff_of_radical _ I.radical_isRadical
theorem isIrreducible_iff_vanishingIdeal_isPrime {s : Set (PrimeSpectrum R)} :
IsIrreducible s ↔ (vanishingIdeal s).IsPrime := by
rw [← isIrreducible_iff_closure, ← zeroLocus_vanishingIdeal_eq_closure,
isIrreducible_zeroLocus_iff_of_radical _ (isRadical_vanishingIdeal s)]
lemma vanishingIdeal_isIrreducible :
vanishingIdeal (R := R) '' {s | IsIrreducible s} = {P | P.IsPrime} :=
Set.ext fun I ↦ ⟨fun ⟨_, hs, e⟩ ↦ e ▸ isIrreducible_iff_vanishingIdeal_isPrime.mp hs,
fun h ↦ ⟨zeroLocus I, (isIrreducible_zeroLocus_iff_of_radical _ h.isRadical).mpr h,
(vanishingIdeal_zeroLocus_eq_radical I).trans h.radical⟩⟩
lemma vanishingIdeal_isClosed_isIrreducible :
vanishingIdeal (R := R) '' {s | IsClosed s ∧ IsIrreducible s} = {P | P.IsPrime} := by
refine (subset_antisymm ?_ ?_).trans vanishingIdeal_isIrreducible
· exact Set.image_subset _ fun _ ↦ And.right
rintro _ ⟨s, hs, rfl⟩
exact ⟨closure s, ⟨isClosed_closure, hs.closure⟩, vanishingIdeal_closure s⟩
instance irreducibleSpace [IsDomain R] : IrreducibleSpace (PrimeSpectrum R) := by
rw [irreducibleSpace_def, Set.top_eq_univ, ← zeroLocus_bot, isIrreducible_zeroLocus_iff]
simpa using Ideal.bot_prime
instance quasiSober : QuasiSober (PrimeSpectrum R) :=
⟨fun {S} h₁ h₂ =>
⟨⟨_, isIrreducible_iff_vanishingIdeal_isPrime.1 h₁⟩, by
rw [IsGenericPoint, closure_singleton, zeroLocus_vanishingIdeal_eq_closure, h₂.closure_eq]⟩⟩
/-- The prime spectrum of a commutative (semi)ring is a compact topological space. -/
instance compactSpace : CompactSpace (PrimeSpectrum R) := by
refine compactSpace_of_finite_subfamily_closed fun S S_closed S_empty ↦ ?_
choose I hI using fun i ↦ (isClosed_iff_zeroLocus_ideal (S i)).mp (S_closed i)
simp_rw [hI, ← zeroLocus_iSup, zeroLocus_empty_iff_eq_top, ← top_le_iff] at S_empty ⊢
exact Ideal.isCompactElement_top.exists_finset_of_le_iSup _ _ S_empty
section Comap
variable {S' : Type*} [CommSemiring S']
theorem preimage_comap_zeroLocus_aux (f : R →+* S) (s : Set R) :
(fun y => ⟨Ideal.comap f y.asIdeal, inferInstance⟩ : PrimeSpectrum S → PrimeSpectrum R) ⁻¹'
zeroLocus s =
zeroLocus (f '' s) := by
ext x
simp only [mem_zeroLocus, Set.image_subset_iff, Set.mem_preimage, mem_zeroLocus, Ideal.coe_comap]
/-- The function between prime spectra of commutative (semi)rings induced by a ring homomorphism.
This function is continuous. -/
def comap (f : R →+* S) : C(PrimeSpectrum S, PrimeSpectrum R) where
toFun y := ⟨Ideal.comap f y.asIdeal, inferInstance⟩
continuous_toFun := by
simp only [continuous_iff_isClosed, isClosed_iff_zeroLocus]
rintro _ ⟨s, rfl⟩
exact ⟨_, preimage_comap_zeroLocus_aux f s⟩
variable (f : R →+* S)
@[simp]
theorem comap_asIdeal (y : PrimeSpectrum S) : (comap f y).asIdeal = Ideal.comap f y.asIdeal :=
rfl
@[simp]
theorem comap_id : comap (RingHom.id R) = ContinuousMap.id _ := by
ext
rfl
@[simp]
theorem comap_comp (f : R →+* S) (g : S →+* S') : comap (g.comp f) = (comap f).comp (comap g) :=
rfl
theorem comap_comp_apply (f : R →+* S) (g : S →+* S') (x : PrimeSpectrum S') :
PrimeSpectrum.comap (g.comp f) x = (PrimeSpectrum.comap f) (PrimeSpectrum.comap g x) :=
rfl
@[simp]
theorem preimage_comap_zeroLocus (s : Set R) : comap f ⁻¹' zeroLocus s = zeroLocus (f '' s) :=
preimage_comap_zeroLocus_aux f s
theorem comap_injective_of_surjective (f : R →+* S) (hf : Function.Surjective f) :
Function.Injective (comap f) := fun x y h =>
PrimeSpectrum.ext (Ideal.comap_injective_of_surjective f hf
(congr_arg PrimeSpectrum.asIdeal h : (comap f x).asIdeal = (comap f y).asIdeal))
variable (S)
theorem localization_comap_inducing [Algebra R S] (M : Submonoid R) [IsLocalization M S] :
Inducing (comap (algebraMap R S)) := by
refine ⟨TopologicalSpace.ext_isClosed fun Z ↦ ?_⟩
simp_rw [isClosed_induced_iff, isClosed_iff_zeroLocus, @eq_comm _ _ (zeroLocus _),
exists_exists_eq_and, preimage_comap_zeroLocus]
constructor
· rintro ⟨s, rfl⟩
refine ⟨(Ideal.span s).comap (algebraMap R S), ?_⟩
rw [← zeroLocus_span, ← zeroLocus_span s, ← Ideal.map, IsLocalization.map_comap M S]
· rintro ⟨s, rfl⟩
exact ⟨_, rfl⟩
theorem localization_comap_injective [Algebra R S] (M : Submonoid R) [IsLocalization M S] :
Function.Injective (comap (algebraMap R S)) := by
intro p q h
replace h := congr_arg (fun x : PrimeSpectrum R => Ideal.map (algebraMap R S) x.asIdeal) h
dsimp only [comap, ContinuousMap.coe_mk] at h
rw [IsLocalization.map_comap M S, IsLocalization.map_comap M S] at h
ext1
exact h
theorem localization_comap_embedding [Algebra R S] (M : Submonoid R) [IsLocalization M S] :
Embedding (comap (algebraMap R S)) :=
⟨localization_comap_inducing S M, localization_comap_injective S M⟩
theorem localization_comap_range [Algebra R S] (M : Submonoid R) [IsLocalization M S] :
Set.range (comap (algebraMap R S)) = { p | Disjoint (M : Set R) p.asIdeal } := by
ext x
constructor
· simp_rw [disjoint_iff_inf_le]
rintro ⟨p, rfl⟩ x ⟨hx₁, hx₂⟩
exact (p.2.1 : ¬_) (p.asIdeal.eq_top_of_isUnit_mem hx₂ (IsLocalization.map_units S ⟨x, hx₁⟩))
· intro h
use ⟨x.asIdeal.map (algebraMap R S), IsLocalization.isPrime_of_isPrime_disjoint M S _ x.2 h⟩
ext1
exact IsLocalization.comap_map_of_isPrime_disjoint M S _ x.2 h
open Function RingHom
theorem comap_inducing_of_surjective (hf : Surjective f) : Inducing (comap f) where
induced := by
set_option tactic.skipAssignedInstances false in
simp_rw [TopologicalSpace.ext_iff, ← isClosed_compl_iff,
← @isClosed_compl_iff (PrimeSpectrum S)
((TopologicalSpace.induced (comap f) zariskiTopology)), isClosed_induced_iff,
isClosed_iff_zeroLocus]
refine fun s =>
⟨fun ⟨F, hF⟩ =>
⟨zeroLocus (f ⁻¹' F), ⟨f ⁻¹' F, rfl⟩, by
rw [preimage_comap_zeroLocus, Function.Surjective.image_preimage hf, hF]⟩,
?_⟩
rintro ⟨-, ⟨F, rfl⟩, hF⟩
exact ⟨f '' F, hF.symm.trans (preimage_comap_zeroLocus f F)⟩
end Comap
end CommSemiRing
section SpecOfSurjective
/-! The comap of a surjective ring homomorphism is a closed embedding between the prime spectra. -/
open Function RingHom
variable [CommRing R] [CommRing S]
variable (f : R →+* S)
variable {R}
theorem comap_singleton_isClosed_of_surjective (f : R →+* S) (hf : Function.Surjective f)
(x : PrimeSpectrum S) (hx : IsClosed ({x} : Set (PrimeSpectrum S))) :
IsClosed ({comap f x} : Set (PrimeSpectrum R)) :=
haveI : x.asIdeal.IsMaximal := (isClosed_singleton_iff_isMaximal x).1 hx
(isClosed_singleton_iff_isMaximal _).2 (Ideal.comap_isMaximal_of_surjective f hf)
theorem comap_singleton_isClosed_of_isIntegral (f : R →+* S) (hf : f.IsIntegral)
(x : PrimeSpectrum S) (hx : IsClosed ({x} : Set (PrimeSpectrum S))) :
IsClosed ({comap f x} : Set (PrimeSpectrum R)) :=
have := (isClosed_singleton_iff_isMaximal x).1 hx
(isClosed_singleton_iff_isMaximal _).2
(Ideal.isMaximal_comap_of_isIntegral_of_isMaximal' f hf x.asIdeal)
theorem image_comap_zeroLocus_eq_zeroLocus_comap (hf : Surjective f) (I : Ideal S) :
comap f '' zeroLocus I = zeroLocus (I.comap f) := by
simp only [Set.ext_iff, Set.mem_image, mem_zeroLocus, SetLike.coe_subset_coe]
refine fun p => ⟨?_, fun h_I_p => ?_⟩
· rintro ⟨p, hp, rfl⟩ a ha
exact hp ha
· have hp : ker f ≤ p.asIdeal := (Ideal.comap_mono bot_le).trans h_I_p
refine ⟨⟨p.asIdeal.map f, Ideal.map_isPrime_of_surjective hf hp⟩, fun x hx => ?_, ?_⟩
· obtain ⟨x', rfl⟩ := hf x
exact Ideal.mem_map_of_mem f (h_I_p hx)
· ext x
rw [comap_asIdeal, Ideal.mem_comap, Ideal.mem_map_iff_of_surjective f hf]
refine ⟨?_, fun hx => ⟨x, hx, rfl⟩⟩
rintro ⟨x', hx', heq⟩
rw [← sub_sub_cancel x' x]
refine p.asIdeal.sub_mem hx' (hp ?_)
rwa [mem_ker, map_sub, sub_eq_zero]
theorem range_comap_of_surjective (hf : Surjective f) :
Set.range (comap f) = zeroLocus (ker f) := by
rw [← Set.image_univ]
convert image_comap_zeroLocus_eq_zeroLocus_comap _ _ hf _
rw [zeroLocus_bot]
theorem isClosed_range_comap_of_surjective (hf : Surjective f) :
IsClosed (Set.range (comap f)) := by
rw [range_comap_of_surjective _ f hf]
exact isClosed_zeroLocus _
theorem closedEmbedding_comap_of_surjective (hf : Surjective f) : ClosedEmbedding (comap f) :=
{ induced := (comap_inducing_of_surjective S f hf).induced
inj := comap_injective_of_surjective f hf
isClosed_range := isClosed_range_comap_of_surjective S f hf }
end SpecOfSurjective
section SpecProd
variable {R S} [CommRing R] [CommRing S]
lemma primeSpectrumProd_symm_inl (x) :
(primeSpectrumProd R S).symm (.inl x) = comap (RingHom.fst R S) x := by
ext; simp [Ideal.prod]
lemma primeSpectrumProd_symm_inr (x) :
(primeSpectrumProd R S).symm (.inr x) = comap (RingHom.snd R S) x := by
ext; simp [Ideal.prod]
/-- The prime spectrum of `R × S` is homeomorphic
to the disjoint union of `PrimeSpectrum R` and `PrimeSpectrum S`. -/
noncomputable
def primeSpectrumProdHomeo :
PrimeSpectrum (R × S) ≃ₜ PrimeSpectrum R ⊕ PrimeSpectrum S := by
refine ((primeSpectrumProd R S).symm.toHomeomorphOfInducing ?_).symm
refine (closedEmbedding_of_continuous_injective_closed ?_ (Equiv.injective _) ?_).toInducing
· rw [continuous_sum_dom]
simp only [Function.comp, primeSpectrumProd_symm_inl, primeSpectrumProd_symm_inr]
exact ⟨(comap _).2, (comap _).2⟩
· rw [isClosedMap_sum]
constructor
· simp_rw [primeSpectrumProd_symm_inl]
refine (closedEmbedding_comap_of_surjective _ _ ?_).isClosedMap
exact Prod.fst_surjective
· simp_rw [primeSpectrumProd_symm_inr]
refine (closedEmbedding_comap_of_surjective _ _ ?_).isClosedMap
exact Prod.snd_surjective
end SpecProd
section CommSemiRing
variable [CommSemiring R] [CommSemiring S]
variable {R S}
section BasicOpen
/-- `basicOpen r` is the open subset containing all prime ideals not containing `r`. -/
def basicOpen (r : R) : TopologicalSpace.Opens (PrimeSpectrum R) where
carrier := { x | r ∉ x.asIdeal }
is_open' := ⟨{r}, Set.ext fun _ => Set.singleton_subset_iff.trans <| Classical.not_not.symm⟩
@[simp]
theorem mem_basicOpen (f : R) (x : PrimeSpectrum R) : x ∈ basicOpen f ↔ f ∉ x.asIdeal :=
Iff.rfl
theorem isOpen_basicOpen {a : R} : IsOpen (basicOpen a : Set (PrimeSpectrum R)) :=
(basicOpen a).isOpen
@[simp]
theorem basicOpen_eq_zeroLocus_compl (r : R) :
(basicOpen r : Set (PrimeSpectrum R)) = (zeroLocus {r})ᶜ :=
Set.ext fun x => by simp only [SetLike.mem_coe, mem_basicOpen, Set.mem_compl_iff, mem_zeroLocus,
Set.singleton_subset_iff]
@[simp]
theorem basicOpen_one : basicOpen (1 : R) = ⊤ :=
TopologicalSpace.Opens.ext <| by simp
@[simp]
theorem basicOpen_zero : basicOpen (0 : R) = ⊥ :=
TopologicalSpace.Opens.ext <| by simp
theorem basicOpen_le_basicOpen_iff (f g : R) :
basicOpen f ≤ basicOpen g ↔ f ∈ (Ideal.span ({g} : Set R)).radical := by
rw [← SetLike.coe_subset_coe, basicOpen_eq_zeroLocus_compl, basicOpen_eq_zeroLocus_compl,
Set.compl_subset_compl, zeroLocus_subset_zeroLocus_singleton_iff]
theorem basicOpen_mul (f g : R) : basicOpen (f * g) = basicOpen f ⊓ basicOpen g :=
TopologicalSpace.Opens.ext <| by simp [zeroLocus_singleton_mul]
theorem basicOpen_mul_le_left (f g : R) : basicOpen (f * g) ≤ basicOpen f := by
rw [basicOpen_mul f g]
exact inf_le_left
theorem basicOpen_mul_le_right (f g : R) : basicOpen (f * g) ≤ basicOpen g := by
rw [basicOpen_mul f g]
exact inf_le_right
@[simp]
theorem basicOpen_pow (f : R) (n : ℕ) (hn : 0 < n) : basicOpen (f ^ n) = basicOpen f :=
TopologicalSpace.Opens.ext <| by simpa using zeroLocus_singleton_pow f n hn
theorem isTopologicalBasis_basic_opens :
TopologicalSpace.IsTopologicalBasis
(Set.range fun r : R => (basicOpen r : Set (PrimeSpectrum R))) := by
apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
· rintro _ ⟨r, rfl⟩
exact isOpen_basicOpen
· rintro p U hp ⟨s, hs⟩
rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
obtain ⟨f, hfs, hfp⟩ := hp
refine ⟨basicOpen f, ⟨f, rfl⟩, hfp, ?_⟩
rw [← Set.compl_subset_compl, ← hs, basicOpen_eq_zeroLocus_compl, compl_compl]
exact zeroLocus_anti_mono (Set.singleton_subset_iff.mpr hfs)
theorem isBasis_basic_opens : TopologicalSpace.Opens.IsBasis (Set.range (@basicOpen R _)) := by
unfold TopologicalSpace.Opens.IsBasis
convert isTopologicalBasis_basic_opens (R := R)
rw [← Set.range_comp]
rfl
@[simp]
theorem basicOpen_eq_bot_iff (f : R) : basicOpen f = ⊥ ↔ IsNilpotent f := by
rw [← TopologicalSpace.Opens.coe_inj, basicOpen_eq_zeroLocus_compl]
simp only [Set.eq_univ_iff_forall, Set.singleton_subset_iff, TopologicalSpace.Opens.coe_bot,
nilpotent_iff_mem_prime, Set.compl_empty_iff, mem_zeroLocus, SetLike.mem_coe]
exact ⟨fun h I hI => h ⟨I, hI⟩, fun h ⟨I, hI⟩ => h I hI⟩
theorem localization_away_comap_range (S : Type v) [CommSemiring S] [Algebra R S] (r : R)
[IsLocalization.Away r S] : Set.range (comap (algebraMap R S)) = basicOpen r := by
rw [localization_comap_range S (Submonoid.powers r)]
ext x
simp only [mem_zeroLocus, basicOpen_eq_zeroLocus_compl, SetLike.mem_coe, Set.mem_setOf_eq,
Set.singleton_subset_iff, Set.mem_compl_iff, disjoint_iff_inf_le]
constructor
· intro h₁ h₂
exact h₁ ⟨Submonoid.mem_powers r, h₂⟩
· rintro h₁ _ ⟨⟨n, rfl⟩, h₃⟩
exact h₁ (x.2.mem_of_pow_mem _ h₃)
theorem localization_away_openEmbedding (S : Type v) [CommSemiring S] [Algebra R S] (r : R)
[IsLocalization.Away r S] : OpenEmbedding (comap (algebraMap R S)) :=
{ toEmbedding := localization_comap_embedding S (Submonoid.powers r)
isOpen_range := by
rw [localization_away_comap_range S r]
exact isOpen_basicOpen }
theorem isCompact_basicOpen (f : R) : IsCompact (basicOpen f : Set (PrimeSpectrum R)) := by
rw [← localization_away_comap_range (Localization (Submonoid.powers f))]
exact isCompact_range (map_continuous _)
lemma comap_basicOpen (f : R →+* S) (x : R) :
TopologicalSpace.Opens.comap (comap f) (basicOpen x) = basicOpen (f x) :=
rfl
open TopologicalSpace in
lemma iSup_basicOpen_eq_top_iff {ι : Type*} {f : ι → R} :
(⨆ i : ι, PrimeSpectrum.basicOpen (f i)) = ⊤ ↔ Ideal.span (Set.range f) = ⊤ := by
rw [SetLike.ext'_iff, Opens.coe_iSup]
simp only [PrimeSpectrum.basicOpen_eq_zeroLocus_compl, Opens.coe_top, ← Set.compl_iInter,
← PrimeSpectrum.zeroLocus_iUnion]
rw [← PrimeSpectrum.zeroLocus_empty_iff_eq_top, compl_involutive.eq_iff]
simp only [Set.iUnion_singleton_eq_range, Set.compl_univ, PrimeSpectrum.zeroLocus_span]
lemma iSup_basicOpen_eq_top_iff' {s : Set R} :
(⨆ i ∈ s, PrimeSpectrum.basicOpen i) = ⊤ ↔ Ideal.span s = ⊤ := by
conv_rhs => rw [← Subtype.range_val (s := s), ← iSup_basicOpen_eq_top_iff]
simp
end BasicOpen
section Order
/-!
## The specialization order
We endow `PrimeSpectrum R` with a partial order, where `x ≤ y` if and only if `y ∈ closure {x}`.
-/
theorem le_iff_mem_closure (x y : PrimeSpectrum R) :
x ≤ y ↔ y ∈ closure ({x} : Set (PrimeSpectrum R)) := by
rw [← asIdeal_le_asIdeal, ← zeroLocus_vanishingIdeal_eq_closure, mem_zeroLocus,
vanishingIdeal_singleton, SetLike.coe_subset_coe]
theorem le_iff_specializes (x y : PrimeSpectrum R) : x ≤ y ↔ x ⤳ y :=
(le_iff_mem_closure x y).trans specializes_iff_mem_closure.symm
/-- `nhds` as an order embedding. -/
@[simps!]
def nhdsOrderEmbedding : PrimeSpectrum R ↪o Filter (PrimeSpectrum R) :=
OrderEmbedding.ofMapLEIff nhds fun a b => (le_iff_specializes a b).symm
instance : T0Space (PrimeSpectrum R) :=
⟨nhdsOrderEmbedding.inj'⟩
end Order
/-- If `x` specializes to `y`, then there is a natural map from the localization of `y` to the
localization of `x`. -/
def localizationMapOfSpecializes {x y : PrimeSpectrum R} (h : x ⤳ y) :
Localization.AtPrime y.asIdeal →+* Localization.AtPrime x.asIdeal :=
@IsLocalization.lift _ _ _ _ _ _ _ _ Localization.isLocalization
(algebraMap R (Localization.AtPrime x.asIdeal))
(by
rintro ⟨a, ha⟩
rw [← PrimeSpectrum.le_iff_specializes, ← asIdeal_le_asIdeal, ← SetLike.coe_subset_coe, ←
Set.compl_subset_compl] at h
exact (IsLocalization.map_units (Localization.AtPrime x.asIdeal)
⟨a, show a ∈ x.asIdeal.primeCompl from h ha⟩ : _))
variable (R) in
/--
Zero loci of prime ideals are closed irreducible sets in the Zariski topology and any closed
irreducible set is a zero locus of some prime ideal.
-/
protected def pointsEquivIrreducibleCloseds :
PrimeSpectrum R ≃o (TopologicalSpace.IrreducibleCloseds (PrimeSpectrum R))ᵒᵈ where
__ := irreducibleSetEquivPoints.toEquiv.symm.trans OrderDual.toDual
map_rel_iff' {p q} :=
(RelIso.symm irreducibleSetEquivPoints).map_rel_iff.trans (le_iff_specializes p q).symm
section LocalizationAtMinimal
variable {I : Ideal R} [hI : I.IsPrime]
/--
Localizations at minimal primes have single-point prime spectra.
-/
def primeSpectrum_unique_of_localization_at_minimal (h : I ∈ minimalPrimes R) :
Unique (PrimeSpectrum (Localization.AtPrime I)) where
default :=
⟨LocalRing.maximalIdeal (Localization I.primeCompl),
(LocalRing.maximalIdeal.isMaximal _).isPrime⟩
uniq x := PrimeSpectrum.ext (Localization.AtPrime.prime_unique_of_minimal h x.asIdeal)
end LocalizationAtMinimal
end CommSemiRing
end PrimeSpectrum
section CommSemiring
variable [CommSemiring R]
open PrimeSpectrum in
/--
[Stacks: Lemma 00ES (3)](https://stacks.math.columbia.edu/tag/00ES)
Zero loci of minimal prime ideals of `R` are irreducible components in `Spec R` and any
irreducible component is a zero locus of some minimal prime ideal.
-/
protected def minimalPrimes.equivIrreducibleComponents :
minimalPrimes R ≃o (irreducibleComponents <| PrimeSpectrum R)ᵒᵈ := by
let e : {p : Ideal R | p.IsPrime ∧ ⊥ ≤ p} ≃o PrimeSpectrum R :=
⟨⟨fun x ↦ ⟨x.1, x.2.1⟩, fun x ↦ ⟨x.1, x.2, bot_le⟩, fun _ ↦ rfl, fun _ ↦ rfl⟩, Iff.rfl⟩
rw [irreducibleComponents_eq_maximals_closed]
exact OrderIso.setOfMinimalIsoSetOfMaximal
(e.trans ((PrimeSpectrum.pointsEquivIrreducibleCloseds R).trans
(TopologicalSpace.IrreducibleCloseds.orderIsoSubtype' (PrimeSpectrum R)).dual))
namespace PrimeSpectrum
lemma vanishingIdeal_irreducibleComponents :
vanishingIdeal '' (irreducibleComponents <| PrimeSpectrum R) =
minimalPrimes R := by
rw [irreducibleComponents_eq_maximals_closed, minimalPrimes_eq_minimals,
image_antitone_setOf_maximal (fun s t hs _ ↦ (vanishingIdeal_anti_mono_iff hs.1).symm),
← funext (@Set.mem_setOf_eq _ · Ideal.IsPrime), ← vanishingIdeal_isClosed_isIrreducible]
rfl
lemma zeroLocus_minimalPrimes :
zeroLocus ∘ (↑) '' minimalPrimes R =
irreducibleComponents (PrimeSpectrum R) := by
rw [← vanishingIdeal_irreducibleComponents, ← Set.image_comp, Set.EqOn.image_eq_self]
intros s hs
simpa [zeroLocus_vanishingIdeal_eq_closure, closure_eq_iff_isClosed]
using isClosed_of_mem_irreducibleComponents s hs
variable {R}
lemma vanishingIdeal_mem_minimalPrimes {s : Set (PrimeSpectrum R)} :
vanishingIdeal s ∈ minimalPrimes R ↔ closure s ∈ irreducibleComponents (PrimeSpectrum R) := by
constructor
· rw [← zeroLocus_minimalPrimes, ← zeroLocus_vanishingIdeal_eq_closure]
exact Set.mem_image_of_mem _
· rw [← vanishingIdeal_irreducibleComponents, ← vanishingIdeal_closure]
exact Set.mem_image_of_mem _
lemma zeroLocus_ideal_mem_irreducibleComponents {I : Ideal R} :
zeroLocus I ∈ irreducibleComponents (PrimeSpectrum R) ↔ I.radical ∈ minimalPrimes R := by
rw [← vanishingIdeal_zeroLocus_eq_radical]
conv_lhs => rw [← (isClosed_zeroLocus _).closure_eq]
exact vanishingIdeal_mem_minimalPrimes.symm
end PrimeSpectrum
end CommSemiring
namespace LocalRing
variable [CommSemiring R] [LocalRing R]
/-- The closed point in the prime spectrum of a local ring. -/
def closedPoint : PrimeSpectrum R :=
⟨maximalIdeal R, (maximalIdeal.isMaximal R).isPrime⟩
variable {R}
theorem isLocalRingHom_iff_comap_closedPoint {S : Type v} [CommSemiring S] [LocalRing S]
(f : R →+* S) : IsLocalRingHom f ↔ PrimeSpectrum.comap f (closedPoint S) = closedPoint R := by
-- Porting note: inline `this` does **not** work
have := (local_hom_TFAE f).out 0 4
rw [this, PrimeSpectrum.ext_iff]
rfl
@[simp]
theorem comap_closedPoint {S : Type v} [CommSemiring S] [LocalRing S] (f : R →+* S)
[IsLocalRingHom f] : PrimeSpectrum.comap f (closedPoint S) = closedPoint R :=
(isLocalRingHom_iff_comap_closedPoint f).mp inferInstance
theorem specializes_closedPoint (x : PrimeSpectrum R) : x ⤳ closedPoint R :=
(PrimeSpectrum.le_iff_specializes _ _).mp (LocalRing.le_maximalIdeal x.2.1)
theorem closedPoint_mem_iff (U : TopologicalSpace.Opens <| PrimeSpectrum R) :
closedPoint R ∈ U ↔ U = ⊤ := by
constructor
· rw [eq_top_iff]
exact fun h x _ => (specializes_closedPoint x).mem_open U.2 h
· rintro rfl
trivial
@[simp]
theorem PrimeSpectrum.comap_residue (T : Type u) [CommRing T] [LocalRing T]
(x : PrimeSpectrum (ResidueField T)) : PrimeSpectrum.comap (residue T) x = closedPoint T := by
rw [Subsingleton.elim x ⊥]
ext1
exact Ideal.mk_ker
end LocalRing
|
AlgebraicGeometry\PrimeSpectrum\IsOpenComapC.lean | /-
Copyright (c) 2021 Damiano Testa. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Damiano Testa
-/
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
import Mathlib.RingTheory.Polynomial.Basic
/-!
The morphism `Spec R[x] --> Spec R` induced by the natural inclusion `R --> R[x]` is an open map.
The main result is the first part of the statement of Lemma 00FB in the Stacks Project.
https://stacks.math.columbia.edu/tag/00FB
-/
open Ideal Polynomial PrimeSpectrum Set
namespace AlgebraicGeometry
namespace Polynomial
variable {R : Type*} [CommRing R] {f : R[X]}
/-- Given a polynomial `f ∈ R[x]`, `imageOfDf` is the subset of `Spec R` where at least one
of the coefficients of `f` does not vanish. Lemma `imageOfDf_eq_comap_C_compl_zeroLocus`
proves that `imageOfDf` is the image of `(zeroLocus {f})ᶜ` under the morphism
`comap C : Spec R[x] → Spec R`. -/
def imageOfDf (f : R[X]) : Set (PrimeSpectrum R) :=
{ p : PrimeSpectrum R | ∃ i : ℕ, coeff f i ∉ p.asIdeal }
theorem isOpen_imageOfDf : IsOpen (imageOfDf f) := by
rw [imageOfDf, setOf_exists fun i (x : PrimeSpectrum R) => coeff f i ∉ x.asIdeal]
exact isOpen_iUnion fun i => isOpen_basicOpen
/-- If a point of `Spec R[x]` is not contained in the vanishing set of `f`, then its image in
`Spec R` is contained in the open set where at least one of the coefficients of `f` is non-zero.
This lemma is a reformulation of `exists_C_coeff_not_mem`. -/
theorem comap_C_mem_imageOfDf {I : PrimeSpectrum R[X]}
(H : I ∈ (zeroLocus {f} : Set (PrimeSpectrum R[X]))ᶜ) :
PrimeSpectrum.comap (Polynomial.C : R →+* R[X]) I ∈ imageOfDf f :=
exists_C_coeff_not_mem (mem_compl_zeroLocus_iff_not_mem.mp H)
/-- The open set `imageOfDf f` coincides with the image of `basicOpen f` under the
morphism `C⁺ : Spec R[x] → Spec R`. -/
theorem imageOfDf_eq_comap_C_compl_zeroLocus :
imageOfDf f = PrimeSpectrum.comap (C : R →+* R[X]) '' (zeroLocus {f})ᶜ := by
ext x
refine ⟨fun hx => ⟨⟨map C x.asIdeal, isPrime_map_C_of_isPrime x.isPrime⟩, ⟨?_, ?_⟩⟩, ?_⟩
· rw [mem_compl_iff, mem_zeroLocus, singleton_subset_iff]
cases' hx with i hi
exact fun a => hi (mem_map_C_iff.mp a i)
· ext x
refine ⟨fun h => ?_, fun h => subset_span (mem_image_of_mem C.1 h)⟩
rw [← @coeff_C_zero R x _]
exact mem_map_C_iff.mp h 0
· rintro ⟨xli, complement, rfl⟩
exact comap_C_mem_imageOfDf complement
/-- The morphism `C⁺ : Spec R[x] → Spec R` is open.
Stacks Project "Lemma 00FB", first part.
https://stacks.math.columbia.edu/tag/00FB
-/
theorem isOpenMap_comap_C : IsOpenMap (PrimeSpectrum.comap (C : R →+* R[X])) := by
rintro U ⟨s, z⟩
rw [← compl_compl U, ← z, ← iUnion_of_singleton_coe s, zeroLocus_iUnion, compl_iInter,
image_iUnion]
simp_rw [← imageOfDf_eq_comap_C_compl_zeroLocus]
exact isOpen_iUnion fun f => isOpen_imageOfDf
end Polynomial
end AlgebraicGeometry
|
AlgebraicGeometry\PrimeSpectrum\Maximal.lean | /-
Copyright (c) 2022 David Kurniadi Angdinata. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Kurniadi Angdinata
-/
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
import Mathlib.RingTheory.MaximalSpectrum
/-!
# Maximal spectrum of a commutative ring
The maximal spectrum of a commutative ring is the type of all maximal ideals.
It is naturally a subset of the prime spectrum endowed with the subspace topology.
## Main definitions
* `MaximalSpectrum R`: The maximal spectrum of a commutative ring `R`,
i.e., the set of all maximal ideals of `R`.
## Implementation notes
The Zariski topology on the maximal spectrum is defined as the subspace topology induced by the
natural inclusion into the prime spectrum to avoid API duplication for zero loci.
-/
noncomputable section
universe u v
variable (R : Type u) [CommRing R]
variable {R}
namespace MaximalSpectrum
open PrimeSpectrum Set
theorem toPrimeSpectrum_range :
Set.range (@toPrimeSpectrum R _) = { x | IsClosed ({x} : Set <| PrimeSpectrum R) } := by
simp only [isClosed_singleton_iff_isMaximal]
ext ⟨x, _⟩
exact ⟨fun ⟨y, hy⟩ => hy ▸ y.IsMaximal, fun hx => ⟨⟨x, hx⟩, rfl⟩⟩
/-- The Zariski topology on the maximal spectrum of a commutative ring is defined as the subspace
topology induced by the natural inclusion into the prime spectrum. -/
instance zariskiTopology : TopologicalSpace <| MaximalSpectrum R :=
PrimeSpectrum.zariskiTopology.induced toPrimeSpectrum
instance : T1Space <| MaximalSpectrum R :=
⟨fun x => isClosed_induced_iff.mpr
⟨{toPrimeSpectrum x}, (isClosed_singleton_iff_isMaximal _).mpr x.IsMaximal, by
simpa only [← image_singleton] using preimage_image_eq {x} toPrimeSpectrum_injective⟩⟩
theorem toPrimeSpectrum_continuous : Continuous <| @toPrimeSpectrum R _ :=
continuous_induced_dom
end MaximalSpectrum
|
AlgebraicGeometry\PrimeSpectrum\Module.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.Support
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
/-!
# Subsets of prime spectra related to modules
## Main results
- `LocalizedModule.subsingleton_iff_disjoint` : `M[1/f] = 0 ↔ D(f) ∩ Supp M = 0`.
- `Module.isClosed_support` : If `M` is a finite `R`-module, then `Supp M` is closed.
## TODO
- If `M` is finitely presented, the complement of `Supp M` is quasi-compact. (stacks#051B)
-/
variable {R A M : Type*} [CommRing R] [AddCommGroup M] [Module R M]
[CommRing A] [Algebra R A] [Module A M]
section support
/-- `M[1/f] = 0` if and only if `D(f) ∩ Supp M = 0`. -/
lemma LocalizedModule.subsingleton_iff_disjoint {f : R} :
Subsingleton (LocalizedModule (.powers f) M) ↔
Disjoint ↑(PrimeSpectrum.basicOpen f) (Module.support R M) := by
rw [subsingleton_iff_support_subset, PrimeSpectrum.basicOpen_eq_zeroLocus_compl,
disjoint_compl_left_iff]
rfl
lemma Module.stableUnderSpecialization_support :
StableUnderSpecialization (Module.support R M) := by
intros x y e H
rw [mem_support_iff_exists_annihilator] at H ⊢
obtain ⟨m, hm⟩ := H
exact ⟨m, hm.trans ((PrimeSpectrum.le_iff_specializes _ _).mpr e)⟩
lemma Module.isClosed_support [Module.Finite R M] :
IsClosed (Module.support R M) :=
support_eq_zeroLocus (R := R) (M := M) ▸
PrimeSpectrum.isClosed_zeroLocus (Module.annihilator R M)
lemma Module.support_subset_preimage_comap [IsScalarTower R A M] :
Module.support A M ⊆ PrimeSpectrum.comap (algebraMap R A) ⁻¹' Module.support R M := by
intro x hx
simp only [Set.mem_preimage, mem_support_iff', PrimeSpectrum.comap_asIdeal, Ideal.mem_comap,
ne_eq, not_imp_not] at hx ⊢
obtain ⟨m, hm⟩ := hx
exact ⟨m, fun r e ↦ hm _ (by simpa)⟩
end support
|
AlgebraicGeometry\PrimeSpectrum\Noetherian.lean | /-
Copyright (c) 2020 Filippo A. E. Nuccio. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Filippo A. E. Nuccio, Andrew Yang
-/
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
import Mathlib.Topology.NoetherianSpace
/-!
This file proves additional properties of the prime spectrum a ring is Noetherian.
-/
universe u v
namespace PrimeSpectrum
open TopologicalSpace
variable (R : Type u) [CommRing R] [IsNoetherianRing R]
instance : NoetherianSpace (PrimeSpectrum R) := by
apply ((noetherianSpace_TFAE <| PrimeSpectrum R).out 0 1).mpr
have H := ‹IsNoetherianRing R›
rw [isNoetherianRing_iff, isNoetherian_iff_wellFounded] at H
exact (closedsEmbedding R).dual.wellFounded H
lemma _root_.minimalPrimes.finite_of_isNoetherianRing : (minimalPrimes R).Finite :=
minimalPrimes.equivIrreducibleComponents R
|>.set_finite_iff
|>.mpr NoetherianSpace.finite_irreducibleComponents
end PrimeSpectrum
|
AlgebraicGeometry\PrimeSpectrum\TensorProduct.lean | /-
Copyright (c) 2024 Andrew Yang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Andrew Yang
-/
import Mathlib.RingTheory.SurjectiveOnStalks
import Mathlib.AlgebraicGeometry.PrimeSpectrum.Basic
/-!
# Lemmas regarding the prime spectrum of tensor products
## Main result
- `PrimeSpectrum.embedding_tensorProductTo_of_surjectiveOnStalks`:
If `R →+* T` is surjective on stalks (see Mathlib/RingTheory/SurjectiveOnStalks.lean),
then `Spec(S ⊗[R] T) → Spec S × Spec T` is a topological embedding
(where `Spec S × Spec T` is the cartesian product with the product topology).
-/
variable (R S T : Type*) [CommRing R] [CommRing S] [Algebra R S]
variable [CommRing T] [Algebra R T] [Algebra S T] [IsScalarTower R S T]
open TensorProduct
/-- The canonical map from `Spec(S ⊗[R] T)` to the cartesian product `Spec S × Spec T`. -/
noncomputable
def PrimeSpectrum.tensorProductTo (x : PrimeSpectrum (S ⊗[R] T)) :
PrimeSpectrum S × PrimeSpectrum T :=
⟨comap (algebraMap _ _) x, comap Algebra.TensorProduct.includeRight.toRingHom x⟩
lemma PrimeSpectrum.continuous_tensorProductTo : Continuous (tensorProductTo R S T) :=
(comap _).2.prod_mk (comap _).2
variable (hRT : (algebraMap R T).SurjectiveOnStalks)
lemma PrimeSpectrum.embedding_tensorProductTo_of_surjectiveOnStalks_aux
(p₁ p₂ : PrimeSpectrum (S ⊗[R] T))
(h : tensorProductTo R S T p₁ = tensorProductTo R S T p₂) :
p₁ ≤ p₂ := by
let g : T →+* S ⊗[R] T := Algebra.TensorProduct.includeRight.toRingHom
intros x hxp₁
by_contra hxp₂
obtain ⟨t, r, a, ht, e⟩ := hRT.exists_mul_eq_tmul x
(p₂.asIdeal.comap g) inferInstance
have h₁ : a ⊗ₜ[R] t ∈ p₁.asIdeal := e ▸ p₁.asIdeal.mul_mem_left (1 ⊗ₜ[R] (r • t)) hxp₁
have h₂ : a ⊗ₜ[R] t ∉ p₂.asIdeal := e ▸ p₂.asIdeal.primeCompl.mul_mem ht hxp₂
rw [← mul_one a, ← one_mul t, ← Algebra.TensorProduct.tmul_mul_tmul] at h₁ h₂
have h₃ : t ∉ p₂.asIdeal.comap g := fun h ↦ h₂ (Ideal.mul_mem_left _ _ h)
have h₄ : a ∉ p₂.asIdeal.comap (algebraMap S (S ⊗[R] T)) :=
fun h ↦ h₂ (Ideal.mul_mem_right _ _ h)
replace h₃ : t ∉ p₁.asIdeal.comap g := by
rwa [show p₁.asIdeal.comap g = p₂.asIdeal.comap g from congr($h.2.1)]
replace h₄ : a ∉ p₁.asIdeal.comap (algebraMap S (S ⊗[R] T)) := by
rwa [show p₁.asIdeal.comap (algebraMap S (S ⊗[R] T)) = p₂.asIdeal.comap _ from congr($h.1.1)]
exact p₁.asIdeal.primeCompl.mul_mem h₄ h₃ h₁
lemma PrimeSpectrum.embedding_tensorProductTo_of_surjectiveOnStalks :
Embedding (tensorProductTo R S T) := by
refine ⟨?_, fun p₁ p₂ e ↦
(embedding_tensorProductTo_of_surjectiveOnStalks_aux R S T hRT p₁ p₂ e).antisymm
(embedding_tensorProductTo_of_surjectiveOnStalks_aux R S T hRT p₂ p₁ e.symm)⟩
let g : T →+* S ⊗[R] T := Algebra.TensorProduct.includeRight.toRingHom
refine ⟨(continuous_tensorProductTo ..).le_induced.antisymm (isBasis_basic_opens.le_iff.mpr ?_)⟩
rintro _ ⟨f, rfl⟩
rw [@isOpen_iff_forall_mem_open]
rintro J (hJ : f ∉ J.asIdeal)
obtain ⟨t, r, a, ht, e⟩ := hRT.exists_mul_eq_tmul f
(J.asIdeal.comap g) inferInstance
refine ⟨_, ?_, ⟨_, (basicOpen a).2.prod (basicOpen t).2, rfl⟩, ?_⟩
· rintro x ⟨hx₁ : a ⊗ₜ[R] (1 : T) ∉ x.asIdeal, hx₂ : (1 : S) ⊗ₜ[R] t ∉ x.asIdeal⟩
(hx₃ : f ∈ x.asIdeal)
apply x.asIdeal.primeCompl.mul_mem hx₁ hx₂
rw [Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul, ← e]
exact x.asIdeal.mul_mem_left _ hx₃
· have : a ⊗ₜ[R] (1 : T) * (1 : S) ⊗ₜ[R] t ∉ J.asIdeal := by
rw [Algebra.TensorProduct.tmul_mul_tmul, mul_one, one_mul, ← e]
exact J.asIdeal.primeCompl.mul_mem ht hJ
rwa [J.isPrime.mul_mem_iff_mem_or_mem.not, not_or] at this
|
AlgebraicGeometry\ProjectiveSpectrum\Scheme.lean | /-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang, Andrew Yang
-/
import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf
import Mathlib.AlgebraicGeometry.GammaSpecAdjunction
import Mathlib.RingTheory.GradedAlgebra.Radical
/-!
# Proj as a scheme
This file is to prove that `Proj` is a scheme.
## Notation
* `Proj` : `Proj` as a locally ringed space
* `Proj.T` : the underlying topological space of `Proj`
* `Proj| U` : `Proj` restricted to some open set `U`
* `Proj.T| U` : the underlying topological space of `Proj` restricted to open set `U`
* `pbo f` : basic open set at `f` in `Proj`
* `Spec` : `Spec` as a locally ringed space
* `Spec.T` : the underlying topological space of `Spec`
* `sbo g` : basic open set at `g` in `Spec`
* `A⁰_x` : the degree zero part of localized ring `Aₓ`
## Implementation
In `AlgebraicGeometry/ProjectiveSpectrum/StructureSheaf.lean`, we have given `Proj` a
structure sheaf so that `Proj` is a locally ringed space. In this file we will prove that `Proj`
equipped with this structure sheaf is a scheme. We achieve this by using an affine cover by basic
open sets in `Proj`, more specifically:
1. We prove that `Proj` can be covered by basic open sets at homogeneous element of positive degree.
2. We prove that for any homogeneous element `f : A` of positive degree `m`, `Proj.T | (pbo f)` is
homeomorphic to `Spec.T A⁰_f`:
- forward direction `toSpec`:
for any `x : pbo f`, i.e. a relevant homogeneous prime ideal `x`, send it to
`A⁰_f ∩ span {g / 1 | g ∈ x}` (see `ProjIsoSpecTopComponent.IoSpec.carrier`). This ideal is
prime, the proof is in `ProjIsoSpecTopComponent.ToSpec.toFun`. The fact that this function
is continuous is found in `ProjIsoSpecTopComponent.toSpec`
- backward direction `fromSpec`:
for any `q : Spec A⁰_f`, we send it to `{a | ∀ i, aᵢᵐ/fⁱ ∈ q}`; we need this to be a
homogeneous prime ideal that is relevant.
* This is in fact an ideal, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal`;
* This ideal is also homogeneous, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal.homogeneous`;
* This ideal is relevant, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.relevant`;
* This ideal is prime, the proof can be found in
`ProjIsoSpecTopComponent.FromSpec.carrier.asIdeal.prime`.
Hence we have a well defined function `Spec.T A⁰_f → Proj.T | (pbo f)`, this function is called
`ProjIsoSpecTopComponent.FromSpec.toFun`. But to prove the continuity of this function, we need
to prove `fromSpec ∘ toSpec` and `toSpec ∘ fromSpec` are both identities; these are achieved in
`ProjIsoSpecTopComponent.fromSpec_toSpec` and `ProjIsoSpecTopComponent.toSpec_fromSpec`.
3. Then we construct a morphism of locally ringed spaces `α : Proj| (pbo f) ⟶ Spec.T A⁰_f` as the
following: by the Gamma-Spec adjunction, it is sufficient to construct a ring map
`A⁰_f → Γ(Proj, pbo f)` from the ring of homogeneous localization of `A` away from `f` to the
local sections of structure sheaf of projective spectrum on the basic open set around `f`.
The map `A⁰_f → Γ(Proj, pbo f)` is constructed in `awayToΓ` and is defined by sending
`s ∈ A⁰_f` to the section `x ↦ s` on `pbo f`.
## Main Definitions and Statements
For a homogeneous element `f` of degree `m`
* `ProjIsoSpecTopComponent.toSpec`: the continuous map between `Proj.T| pbo f` and `Spec.T A⁰_f`
defined by sending `x : Proj| (pbo f)` to `A⁰_f ∩ span {g / 1 | g ∈ x}`. We also denote this map
as `ψ`.
* `ProjIsoSpecTopComponent.ToSpec.preimage_eq`: for any `a: A`, if `a/f^m` has degree zero,
then the preimage of `sbo a/f^m` under `to_Spec f` is `pbo f ∩ pbo a`.
If we further assume `m` is positive
* `ProjIsoSpecTopComponent.fromSpec`: the continuous map between `Spec.T A⁰_f` and `Proj.T| pbo f`
defined by sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}` where `aᵢ` is the `i`-th coordinate of `a`.
We also denote this map as `φ`
* `projIsoSpecTopComponent`: the homeomorphism `Proj.T| pbo f ≅ Spec.T A⁰_f` obtained by `φ` and
`ψ`.
* `ProjectiveSpectrum.Proj.toSpec`: the morphism of locally ringed spaces between `Proj| pbo f`
and `Spec A⁰_f` corresponding to the ring map `A⁰_f → Γ(Proj, pbo f)` under the Gamma-Spec
adjunction defined by sending `s` to the section `x ↦ s` on `pbo f`.
Finally,
* `AlgebraicGeometry.Proj`: for any `ℕ`-graded ring `A`, `Proj A` is locally affine, hence is a
scheme.
## Reference
* [Robin Hartshorne, *Algebraic Geometry*][Har77]: Chapter II.2 Proposition 2.5
-/
noncomputable section
namespace AlgebraicGeometry
open scoped DirectSum Pointwise
open DirectSum SetLike.GradedMonoid Localization
open Finset hiding mk_zero
variable {R A : Type*}
variable [CommRing R] [CommRing A] [Algebra R A]
variable (𝒜 : ℕ → Submodule R A)
variable [GradedAlgebra 𝒜]
open TopCat TopologicalSpace
open CategoryTheory Opposite
open ProjectiveSpectrum.StructureSheaf
-- Porting note: currently require lack of hygiene to use in variable declarations
-- maybe all make into notation3?
set_option hygiene false
/-- `Proj` as a locally ringed space -/
local notation3 "Proj" => Proj.toLocallyRingedSpace 𝒜
/-- The underlying topological space of `Proj` -/
local notation3 "Proj.T" => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace
<| LocallyRingedSpace.toSheafedSpace <| Proj.toLocallyRingedSpace 𝒜
/-- `Proj` restrict to some open set -/
macro "Proj| " U:term : term =>
`((Proj.toLocallyRingedSpace 𝒜).restrict (Opens.openEmbedding (X := Proj.T) ($U : Opens Proj.T)))
/-- the underlying topological space of `Proj` restricted to some open set -/
local notation "Proj.T| " U => PresheafedSpace.carrier <| SheafedSpace.toPresheafedSpace
<| LocallyRingedSpace.toSheafedSpace
<| (LocallyRingedSpace.restrict Proj (Opens.openEmbedding (X := Proj.T) (U : Opens Proj.T)))
/-- basic open sets in `Proj` -/
local notation "pbo " x => ProjectiveSpectrum.basicOpen 𝒜 x
/-- basic open sets in `Spec` -/
local notation "sbo " f => PrimeSpectrum.basicOpen f
/-- `Spec` as a locally ringed space -/
local notation3 "Spec " ring => Spec.locallyRingedSpaceObj (CommRingCat.of ring)
/-- the underlying topological space of `Spec` -/
local notation "Spec.T " ring =>
(Spec.locallyRingedSpaceObj (CommRingCat.of ring)).toSheafedSpace.toPresheafedSpace.1
local notation3 "A⁰_ " f => HomogeneousLocalization.Away 𝒜 f
namespace ProjIsoSpecTopComponent
/-
This section is to construct the homeomorphism between `Proj` restricted at basic open set at
a homogeneous element `x` and `Spec A⁰ₓ` where `A⁰ₓ` is the degree zero part of the localized
ring `Aₓ`.
-/
namespace ToSpec
open Ideal
-- This section is to construct the forward direction :
-- So for any `x` in `Proj| (pbo f)`, we need some point in `Spec A⁰_f`, i.e. a prime ideal,
-- and we need this correspondence to be continuous in their Zariski topology.
variable {𝒜}
variable {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (x : Proj| (pbo f))
/--
For any `x` in `Proj| (pbo f)`, the corresponding ideal in `Spec A⁰_f`. This fact that this ideal
is prime is proven in `TopComponent.Forward.toFun`-/
def carrier : Ideal (A⁰_ f) :=
Ideal.comap (algebraMap (A⁰_ f) (Away f))
(x.val.asHomogeneousIdeal.toIdeal.map (algebraMap A (Away f)))
@[simp]
theorem mk_mem_carrier (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
HomogeneousLocalization.mk z ∈ carrier x ↔ z.num.1 ∈ x.1.asHomogeneousIdeal := by
rw [carrier, Ideal.mem_comap, HomogeneousLocalization.algebraMap_apply,
HomogeneousLocalization.val_mk, Localization.mk_eq_mk', IsLocalization.mk'_eq_mul_mk'_one,
mul_comm, Ideal.unit_mul_mem_iff_mem, ← Ideal.mem_comap,
IsLocalization.comap_map_of_isPrime_disjoint (.powers f)]
· rfl
· infer_instance
· exact (disjoint_powers_iff_not_mem _ (Ideal.IsPrime.isRadical inferInstance)).mpr x.2
· exact isUnit_of_invertible _
theorem isPrime_carrier : Ideal.IsPrime (carrier x) := by
refine Ideal.IsPrime.comap _ (hK := ?_)
exact IsLocalization.isPrime_of_isPrime_disjoint
(Submonoid.powers f) _ _ inferInstance
((disjoint_powers_iff_not_mem _ (Ideal.IsPrime.isRadical inferInstance)).mpr x.2)
variable (f)
/-- The function between the basic open set `D(f)` in `Proj` to the corresponding basic open set in
`Spec A⁰_f`. This is bundled into a continuous map in `TopComponent.forward`.
-/
@[simps (config := .lemmasOnly)]
def toFun (x : Proj.T| pbo f) : Spec.T A⁰_ f :=
⟨carrier x, isPrime_carrier x⟩
/-
The preimage of basic open set `D(a/f^n)` in `Spec A⁰_f` under the forward map from `Proj A` to
`Spec A⁰_f` is the basic open set `D(a) ∩ D(f)` in `Proj A`. This lemma is used to prove that the
forward map is continuous.
-/
theorem preimage_basicOpen (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
toFun f ⁻¹' (sbo (HomogeneousLocalization.mk z) : Set (PrimeSpectrum (A⁰_ f))) =
Subtype.val ⁻¹' (pbo z.num.1 : Set (ProjectiveSpectrum 𝒜)) :=
Set.ext fun y ↦ (mk_mem_carrier y z).not
end ToSpec
section
/-- The continuous function from the basic open set `D(f)` in `Proj`
to the corresponding basic open set in `Spec A⁰_f`. -/
@[simps! (config := .lemmasOnly) apply_asIdeal]
def toSpec (f : A) : (Proj.T| pbo f) ⟶ Spec.T A⁰_ f where
toFun := ToSpec.toFun f
continuous_toFun := by
rw [PrimeSpectrum.isTopologicalBasis_basic_opens.continuous_iff]
rintro _ ⟨x, rfl⟩
obtain ⟨x, rfl⟩ := Quotient.surjective_Quotient_mk'' x
rw [ToSpec.preimage_basicOpen]
exact (pbo x.num).2.preimage continuous_subtype_val
variable {𝒜} in
lemma toSpec_preimage_basicOpen {f} (z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
toSpec 𝒜 f ⁻¹' (sbo (HomogeneousLocalization.mk z) : Set (PrimeSpectrum (A⁰_ f))) =
Subtype.val ⁻¹' (pbo z.num.1 : Set (ProjectiveSpectrum 𝒜)) :=
ToSpec.preimage_basicOpen f z
end
namespace FromSpec
open GradedAlgebra SetLike
open Finset hiding mk_zero
-- Porting note: _root_ doesn't work here
open HomogeneousLocalization
variable {𝒜}
variable {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m)
open Lean Meta Elab Tactic
macro "mem_tac_aux" : tactic =>
`(tactic| first | exact pow_mem_graded _ (Submodule.coe_mem _) | exact natCast_mem_graded _ _ |
exact pow_mem_graded _ f_deg)
macro "mem_tac" : tactic =>
`(tactic| first | mem_tac_aux |
repeat (all_goals (apply SetLike.GradedMonoid.toGradedMul.mul_mem)); mem_tac_aux)
/-- The function from `Spec A⁰_f` to `Proj|D(f)` is defined by `q ↦ {a | aᵢᵐ/fⁱ ∈ q}`, i.e. sending
`q` a prime ideal in `A⁰_f` to the homogeneous prime relevant ideal containing only and all the
elements `a : A` such that for every `i`, the degree 0 element formed by dividing the `m`-th power
of the `i`-th projection of `a` by the `i`-th power of the degree-`m` homogeneous element `f`,
lies in `q`.
The set `{a | aᵢᵐ/fⁱ ∈ q}`
* is an ideal, as proved in `carrier.asIdeal`;
* is homogeneous, as proved in `carrier.asHomogeneousIdeal`;
* is prime, as proved in `carrier.asIdeal.prime`;
* is relevant, as proved in `carrier.relevant`.
-/
def carrier (q : Spec.T A⁰_ f) : Set A :=
{a | ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by mem_tac⟩,
⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1}
theorem mem_carrier_iff (q : Spec.T A⁰_ f) (a : A) :
a ∈ carrier f_deg q ↔ ∀ i, (HomogeneousLocalization.mk ⟨m * i, ⟨proj 𝒜 i a ^ m, by mem_tac⟩,
⟨f ^ i, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.1 :=
Iff.rfl
theorem mem_carrier_iff' (q : Spec.T A⁰_ f) (a : A) :
a ∈ carrier f_deg q ↔
∀ i, (Localization.mk (proj 𝒜 i a ^ m) ⟨f ^ i, ⟨i, rfl⟩⟩ : Localization.Away f) ∈
algebraMap (HomogeneousLocalization.Away 𝒜 f) (Localization.Away f) '' { s | s ∈ q.1 } :=
(mem_carrier_iff f_deg q a).trans
(by
constructor <;> intro h i <;> specialize h i
· rw [Set.mem_image]; refine ⟨_, h, rfl⟩
· rw [Set.mem_image] at h; rcases h with ⟨x, h, hx⟩
change x ∈ q.asIdeal at h
convert h
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk]
dsimp only [Subtype.coe_mk]; rw [← hx]; rfl)
theorem mem_carrier_iff_of_mem (hm : 0 < m) (q : Spec.T A⁰_ f) (a : A) {n} (hn : a ∈ 𝒜 n) :
a ∈ carrier f_deg q ↔
(HomogeneousLocalization.mk ⟨m * n, ⟨a ^ m, pow_mem_graded m hn⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal := by
trans (HomogeneousLocalization.mk ⟨m * n, ⟨proj 𝒜 n a ^ m, by mem_tac⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal
· refine ⟨fun h ↦ h n, fun h i ↦ if hi : i = n then hi ▸ h else ?_⟩
convert zero_mem q.asIdeal
apply HomogeneousLocalization.val_injective
simp only [proj_apply, decompose_of_mem_ne _ hn (Ne.symm hi), zero_pow hm.ne',
HomogeneousLocalization.val_mk, Localization.mk_zero, HomogeneousLocalization.val_zero]
· simp only [proj_apply, decompose_of_mem_same _ hn]
theorem mem_carrier_iff_of_mem_mul (hm : 0 < m)
(q : Spec.T A⁰_ f) (a : A) {n} (hn : a ∈ 𝒜 (n * m)) :
a ∈ carrier f_deg q ↔ (HomogeneousLocalization.mk ⟨m * n, ⟨a, mul_comm n m ▸ hn⟩,
⟨f ^ n, by rw [mul_comm]; mem_tac⟩, ⟨_, rfl⟩⟩ : A⁰_ f) ∈ q.asIdeal := by
rw [mem_carrier_iff_of_mem f_deg hm q a hn, iff_iff_eq, eq_comm,
← Ideal.IsPrime.pow_mem_iff_mem (α := A⁰_ f) inferInstance m hm]
congr 1
apply HomogeneousLocalization.val_injective
simp only [HomogeneousLocalization.val_mk, HomogeneousLocalization.val_pow,
Localization.mk_pow, pow_mul]
rfl
theorem num_mem_carrier_iff (hm : 0 < m) (q : Spec.T A⁰_ f)
(z : HomogeneousLocalization.NumDenSameDeg 𝒜 (.powers f)) :
z.num.1 ∈ carrier f_deg q ↔ HomogeneousLocalization.mk z ∈ q.asIdeal := by
obtain ⟨n, hn : f ^ n = _⟩ := z.den_mem
have : f ^ n ≠ 0 := fun e ↦ by
have := HomogeneousLocalization.subsingleton 𝒜 (x := .powers f) ⟨n, e⟩
exact IsEmpty.elim (inferInstanceAs (IsEmpty (PrimeSpectrum (A⁰_ f)))) q
convert mem_carrier_iff_of_mem_mul f_deg hm q z.num.1 (n := n) ?_ using 2
· apply HomogeneousLocalization.val_injective; simp only [hn, HomogeneousLocalization.val_mk]
· have := degree_eq_of_mem_mem 𝒜 (SetLike.pow_mem_graded n f_deg) (hn.symm ▸ z.den.2) this
rw [← smul_eq_mul, this]; exact z.num.2
theorem carrier.add_mem (q : Spec.T A⁰_ f) {a b : A} (ha : a ∈ carrier f_deg q)
(hb : b ∈ carrier f_deg q) : a + b ∈ carrier f_deg q := by
refine fun i => (q.2.mem_or_mem ?_).elim id id
change (.mk ⟨_, _, _, _⟩ : A⁰_ f) ∈ q.1; dsimp only [Subtype.coe_mk]
simp_rw [← pow_add, map_add, add_pow, mul_comm, ← nsmul_eq_mul]
let g : ℕ → A⁰_ f := fun j => (m + m).choose j •
if h2 : m + m < j then (0 : A⁰_ f)
else
-- Porting note: inlining `l`, `r` causes a "can't synth HMul A⁰_ f A⁰_ f ?" error
if h1 : j ≤ m then
letI l : A⁰_ f := HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ j * proj 𝒜 i b ^ (m - j), ?_⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩
letI r : A⁰_ f := HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i b ^ m, by mem_tac⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩
l * r
else
letI l : A⁰_ f := HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ m, by mem_tac⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩
letI r : A⁰_ f := HomogeneousLocalization.mk
⟨m * i, ⟨proj 𝒜 i a ^ (j - m) * proj 𝒜 i b ^ (m + m - j), ?_⟩,
⟨_, by rw [mul_comm]; mem_tac⟩, ⟨i, rfl⟩⟩
l * r
rotate_left
· rw [(_ : m * i = _)]
-- Porting note: it seems unification with mul_mem is more fiddly reducing value of mem_tac
apply GradedMonoid.toGradedMul.mul_mem (i := j • i) (j := (m - j) • i) <;> mem_tac_aux
rw [← add_smul, Nat.add_sub_of_le h1]; rfl
· rw [(_ : m * i = _)]
apply GradedMonoid.toGradedMul.mul_mem (i := (j-m) • i) (j := (m + m - j) • i) <;> mem_tac_aux
rw [← add_smul]; congr; zify [le_of_not_lt h2, le_of_not_le h1]; abel
convert_to ∑ i ∈ range (m + m + 1), g i ∈ q.1; swap
· refine q.1.sum_mem fun j _ => nsmul_mem ?_ _; split_ifs
exacts [q.1.zero_mem, q.1.mul_mem_left _ (hb i), q.1.mul_mem_right _ (ha i)]
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk]
change _ = (algebraMap (HomogeneousLocalization.Away 𝒜 f) (Localization.Away f)) _
dsimp only [Subtype.coe_mk]; rw [map_sum, mk_sum]
apply Finset.sum_congr rfl fun j hj => _
intro j hj
change _ = HomogeneousLocalization.val _
rw [HomogeneousLocalization.val_smul]
split_ifs with h2 h1
· exact ((Finset.mem_range.1 hj).not_le h2).elim
all_goals simp only [HomogeneousLocalization.val_mul, HomogeneousLocalization.val_zero,
HomogeneousLocalization.val_mk, Subtype.coe_mk, Localization.mk_mul, ← smul_mk]; congr 2
· dsimp; rw [mul_assoc, ← pow_add, add_comm (m - j), Nat.add_sub_assoc h1]
· simp_rw [pow_add]; rfl
· dsimp; rw [← mul_assoc, ← pow_add, Nat.add_sub_of_le (le_of_not_le h1)]
· simp_rw [pow_add]; rfl
variable (hm : 0 < m) (q : Spec.T A⁰_ f)
theorem carrier.zero_mem : (0 : A) ∈ carrier f_deg q := fun i => by
convert Submodule.zero_mem q.1 using 1
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_zero]; simp_rw [map_zero, zero_pow hm.ne']
convert Localization.mk_zero (S := Submonoid.powers f) _ using 1
theorem carrier.smul_mem (c x : A) (hx : x ∈ carrier f_deg q) : c • x ∈ carrier f_deg q := by
revert c
refine DirectSum.Decomposition.inductionOn 𝒜 ?_ ?_ ?_
· rw [zero_smul]; exact carrier.zero_mem f_deg hm _
· rintro n ⟨a, ha⟩ i
simp_rw [proj_apply, smul_eq_mul, coe_decompose_mul_of_left_mem 𝒜 i ha]
-- Porting note: having trouble with Mul instance
let product : A⁰_ f :=
Mul.mul (HomogeneousLocalization.mk ⟨_, ⟨a ^ m, pow_mem_graded m ha⟩, ⟨_, ?_⟩, ⟨n, rfl⟩⟩)
(HomogeneousLocalization.mk ⟨_, ⟨proj 𝒜 (i - n) x ^ m, by mem_tac⟩, ⟨_, ?_⟩, ⟨i - n, rfl⟩⟩)
· split_ifs with h
· convert_to product ∈ q.1
· dsimp [product]
erw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mul, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mk]
· simp_rw [mul_pow]; rw [Localization.mk_mul]
· congr; erw [← pow_add, Nat.add_sub_of_le h]
· apply Ideal.mul_mem_left (α := A⁰_ f) _ _ (hx _)
rw [(_ : m • n = _)]
· mem_tac
· simp only [smul_eq_mul, mul_comm]
· simpa only [map_zero, zero_pow hm.ne'] using zero_mem f_deg hm q i
rw [(_ : m • (i - n) = _)]
· mem_tac
· simp only [smul_eq_mul, mul_comm]
· simp_rw [add_smul]; exact fun _ _ => carrier.add_mem f_deg q
/-- For a prime ideal `q` in `A⁰_f`, the set `{a | aᵢᵐ/fⁱ ∈ q}` as an ideal.
-/
def carrier.asIdeal : Ideal A where
carrier := carrier f_deg q
zero_mem' := carrier.zero_mem f_deg hm q
add_mem' := carrier.add_mem f_deg q
smul_mem' := carrier.smul_mem f_deg hm q
theorem carrier.asIdeal.homogeneous : (carrier.asIdeal f_deg hm q).IsHomogeneous 𝒜 :=
fun i a ha j =>
(em (i = j)).elim (fun h => h ▸ by simpa only [proj_apply, decompose_coe, of_eq_same] using ha _)
fun h => by
simpa only [proj_apply, decompose_of_mem_ne 𝒜 (Submodule.coe_mem (decompose 𝒜 a i)) h,
zero_pow hm.ne', map_zero] using carrier.zero_mem f_deg hm q j
/-- For a prime ideal `q` in `A⁰_f`, the set `{a | aᵢᵐ/fⁱ ∈ q}` as a homogeneous ideal.
-/
def carrier.asHomogeneousIdeal : HomogeneousIdeal 𝒜 :=
⟨carrier.asIdeal f_deg hm q, carrier.asIdeal.homogeneous f_deg hm q⟩
theorem carrier.denom_not_mem : f ∉ carrier.asIdeal f_deg hm q := fun rid =>
q.isPrime.ne_top <|
(Ideal.eq_top_iff_one _).mpr
(by
convert rid m
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_one,
HomogeneousLocalization.val_mk]
dsimp
simp_rw [decompose_of_mem_same _ f_deg]
simp only [mk_eq_monoidOf_mk', Submonoid.LocalizationMap.mk'_self])
theorem carrier.relevant : ¬HomogeneousIdeal.irrelevant 𝒜 ≤ carrier.asHomogeneousIdeal f_deg hm q :=
fun rid => carrier.denom_not_mem f_deg hm q <| rid <| DirectSum.decompose_of_mem_ne 𝒜 f_deg hm.ne'
theorem carrier.asIdeal.ne_top : carrier.asIdeal f_deg hm q ≠ ⊤ := fun rid =>
carrier.denom_not_mem f_deg hm q (rid.symm ▸ Submodule.mem_top)
theorem carrier.asIdeal.prime : (carrier.asIdeal f_deg hm q).IsPrime :=
(carrier.asIdeal.homogeneous f_deg hm q).isPrime_of_homogeneous_mem_or_mem
(carrier.asIdeal.ne_top f_deg hm q) fun {x y} ⟨nx, hnx⟩ ⟨ny, hny⟩ hxy =>
show (∀ i, _ ∈ _) ∨ ∀ i, _ ∈ _ by
rw [← and_forall_ne nx, and_iff_left, ← and_forall_ne ny, and_iff_left]
· apply q.2.mem_or_mem; convert hxy (nx + ny) using 1
dsimp
simp_rw [decompose_of_mem_same 𝒜 hnx, decompose_of_mem_same 𝒜 hny,
decompose_of_mem_same 𝒜 (SetLike.GradedMonoid.toGradedMul.mul_mem hnx hny),
mul_pow, pow_add]
simp only [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_mul, Localization.mk_mul]
simp only [Submonoid.mk_mul_mk, mk_eq_monoidOf_mk']
all_goals
intro n hn; convert q.1.zero_mem using 1
rw [HomogeneousLocalization.ext_iff_val, HomogeneousLocalization.val_mk,
HomogeneousLocalization.val_zero]; simp_rw [proj_apply]
convert mk_zero (S := Submonoid.powers f) _
rw [decompose_of_mem_ne 𝒜 _ hn.symm, zero_pow hm.ne']
· first | exact hnx | exact hny
/-- The function `Spec A⁰_f → Proj|D(f)` sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}`. -/
def toFun : (Spec.T A⁰_ f) → Proj.T| pbo f := fun q =>
⟨⟨carrier.asHomogeneousIdeal f_deg hm q, carrier.asIdeal.prime f_deg hm q,
carrier.relevant f_deg hm q⟩,
(ProjectiveSpectrum.mem_basicOpen _ f _).mp <| carrier.denom_not_mem f_deg hm q⟩
end FromSpec
section toSpecFromSpec
lemma toSpec_fromSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) (x : Spec.T (A⁰_ f)) :
toSpec 𝒜 f (FromSpec.toFun f_deg hm x) = x := by
apply PrimeSpectrum.ext
ext z
obtain ⟨z, rfl⟩ := z.mk_surjective
rw [← FromSpec.num_mem_carrier_iff f_deg hm x]
exact ToSpec.mk_mem_carrier _ z
@[deprecated (since := "2024-03-02")] alias toSpecFromSpec := toSpec_fromSpec
end toSpecFromSpec
section fromSpecToSpec
lemma fromSpec_toSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) (x : Proj.T| pbo f) :
FromSpec.toFun f_deg hm (toSpec 𝒜 f x) = x := by
refine Subtype.ext <| ProjectiveSpectrum.ext <| HomogeneousIdeal.ext' ?_
intros i z hzi
refine (FromSpec.mem_carrier_iff_of_mem f_deg hm _ _ hzi).trans ?_
exact (ToSpec.mk_mem_carrier _ _).trans (x.1.2.pow_mem_iff_mem m hm)
lemma toSpec_injective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Injective (toSpec 𝒜 f) := by
intro x₁ x₂ h
have := congr_arg (FromSpec.toFun f_deg hm) h
rwa [fromSpec_toSpec, fromSpec_toSpec] at this
lemma toSpec_surjective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Surjective (toSpec 𝒜 f) :=
Function.surjective_iff_hasRightInverse |>.mpr
⟨FromSpec.toFun f_deg hm, toSpec_fromSpec 𝒜 f_deg hm⟩
lemma toSpec_bijective {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
Function.Bijective (toSpec (𝒜 := 𝒜) (f := f)) :=
⟨toSpec_injective 𝒜 f_deg hm, toSpec_surjective 𝒜 f_deg hm⟩
end fromSpecToSpec
namespace toSpec
variable {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m)
variable {𝒜} in
lemma image_basicOpen_eq_basicOpen (a : A) (i : ℕ) :
toSpec 𝒜 f '' (Subtype.val ⁻¹' (pbo (decompose 𝒜 a i) : Set (ProjectiveSpectrum 𝒜))) =
(PrimeSpectrum.basicOpen (R := A⁰_ f) <|
HomogeneousLocalization.mk
⟨m * i, ⟨decompose 𝒜 a i ^ m, SetLike.pow_mem_graded _ (Submodule.coe_mem _)⟩,
⟨f^i, by rw [mul_comm]; exact SetLike.pow_mem_graded _ f_deg⟩, ⟨i, rfl⟩⟩).1 :=
Set.preimage_injective.mpr (toSpec_surjective 𝒜 f_deg hm) <|
Set.preimage_image_eq _ (toSpec_injective 𝒜 f_deg hm) ▸ by
rw [Opens.carrier_eq_coe, toSpec_preimage_basicOpen, ProjectiveSpectrum.basicOpen_pow 𝒜 _ m hm]
end toSpec
variable {𝒜} in
/-- The continuous function `Spec A⁰_f → Proj|D(f)` sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}` where
`m` is the degree of `f` -/
def fromSpec {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Spec.T (A⁰_ f)) ⟶ (Proj.T| (pbo f)) where
toFun := FromSpec.toFun f_deg hm
continuous_toFun := by
rw [isTopologicalBasis_subtype (ProjectiveSpectrum.isTopologicalBasis_basic_opens 𝒜) (pbo f).1
|>.continuous_iff]
rintro s ⟨_, ⟨a, rfl⟩, rfl⟩
have h₁ : Subtype.val (p := (pbo f).1) ⁻¹' (pbo a) =
⋃ i : ℕ, Subtype.val (p := (pbo f).1) ⁻¹' (pbo (decompose 𝒜 a i)) := by
simp [ProjectiveSpectrum.basicOpen_eq_union_of_projection 𝒜 a]
let e : _ ≃ _ :=
⟨FromSpec.toFun f_deg hm, ToSpec.toFun f, toSpec_fromSpec _ _ _, fromSpec_toSpec _ _ _⟩
change IsOpen <| e ⁻¹' _
rw [Set.preimage_equiv_eq_image_symm, h₁, Set.image_iUnion]
exact isOpen_iUnion fun i ↦ toSpec.image_basicOpen_eq_basicOpen f_deg hm a i ▸
PrimeSpectrum.isOpen_basicOpen
end ProjIsoSpecTopComponent
variable {𝒜} in
/--
The homeomorphism `Proj|D(f) ≅ Spec A⁰_f` defined by
- `φ : Proj|D(f) ⟶ Spec A⁰_f` by sending `x` to `A⁰_f ∩ span {g / 1 | g ∈ x}`
- `ψ : Spec A⁰_f ⟶ Proj|D(f)` by sending `q` to `{a | aᵢᵐ/fⁱ ∈ q}`.
-/
def projIsoSpecTopComponent {f : A} {m : ℕ} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Proj.T| (pbo f)) ≅ (Spec.T (A⁰_ f)) where
hom := ProjIsoSpecTopComponent.toSpec 𝒜 f
inv := ProjIsoSpecTopComponent.fromSpec f_deg hm
hom_inv_id := ConcreteCategory.hom_ext _ _
(ProjIsoSpecTopComponent.fromSpec_toSpec 𝒜 f_deg hm)
inv_hom_id := ConcreteCategory.hom_ext _ _
(ProjIsoSpecTopComponent.toSpec_fromSpec 𝒜 f_deg hm)
namespace ProjectiveSpectrum.Proj
/--
The ring map from `A⁰_ f` to the local sections of the structure sheaf of the projective spectrum of
`A` on the basic open set `D(f)` defined by sending `s ∈ A⁰_f` to the section `x ↦ s` on `D(f)`.
-/
def awayToSection (f) : CommRingCat.of (A⁰_ f) ⟶ (structureSheaf 𝒜).1.obj (op (pbo f)) where
toFun s :=
⟨fun x ↦ HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr x.2) s, fun x ↦ by
obtain ⟨s, rfl⟩ := HomogeneousLocalization.mk_surjective s
obtain ⟨n, hn : f ^ n = s.den.1⟩ := s.den_mem
exact ⟨_, x.2, 𝟙 _, s.1, s.2, s.3,
fun x hsx ↦ x.2 (Ideal.IsPrime.mem_of_pow_mem inferInstance n (hn ▸ hsx)), fun _ ↦ rfl⟩⟩
map_add' _ _ := by ext; simp only [map_add, HomogeneousLocalization.val_add, Proj.add_apply]
map_mul' _ _ := by ext; simp only [map_mul, HomogeneousLocalization.val_mul, Proj.mul_apply]
map_zero' := by ext; simp only [map_zero, HomogeneousLocalization.val_zero, Proj.zero_apply]
map_one' := by ext; simp only [map_one, HomogeneousLocalization.val_one, Proj.one_apply]
lemma awayToSection_germ (f x) :
awayToSection 𝒜 f ≫ (structureSheaf 𝒜).presheaf.germ x =
(HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr x.2)) ≫
(Proj.stalkIso' 𝒜 x).toCommRingCatIso.inv := by
ext z
apply (Proj.stalkIso' 𝒜 x).eq_symm_apply.mpr
apply Proj.stalkIso'_germ
/--
The ring map from `A⁰_ f` to the global sections of the structure sheaf of the projective spectrum
of `A` restricted to the basic open set `D(f)`.
Mathematically, the map is the same as `awayToSection`.
-/
def awayToΓ (f) : CommRingCat.of (A⁰_ f) ⟶ LocallyRingedSpace.Γ.obj (op <| Proj| pbo f) :=
awayToSection 𝒜 f ≫ (ProjectiveSpectrum.Proj.structureSheaf 𝒜).1.map
(homOfLE (Opens.openEmbedding_obj_top _).le).op
lemma awayToΓ_ΓToStalk (f) (x) :
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x =
HomogeneousLocalization.mapId 𝒜 (Submonoid.powers_le.mpr x.2) ≫
(Proj.stalkIso' 𝒜 x.1).toCommRingCatIso.inv ≫
((Proj.toLocallyRingedSpace 𝒜).restrictStalkIso (Opens.openEmbedding _) x).inv := by
rw [awayToΓ, Category.assoc, ← Category.assoc _ (Iso.inv _),
Iso.eq_comp_inv, Category.assoc, Category.assoc, Presheaf.Γgerm]
rw [LocallyRingedSpace.restrictStalkIso_hom_eq_germ]
simp only [Proj.toLocallyRingedSpace, Proj.toSheafedSpace]
rw [Presheaf.germ_res, awayToSection_germ]
rfl
/--
The morphism of locally ringed space from `Proj|D(f)` to `Spec A⁰_f` induced by the ring map
`A⁰_ f → Γ(Proj, D(f))` under the gamma spec adjunction.
-/
def toSpec (f) : (Proj| pbo f) ⟶ Spec (A⁰_ f) :=
ΓSpec.locallyRingedSpaceAdjunction.homEquiv (Proj| pbo f) (op (CommRingCat.of <| A⁰_ f))
(awayToΓ 𝒜 f).op
open HomogeneousLocalization LocalRing
lemma toSpec_base_apply_eq_comap {f} (x : Proj| pbo f) :
(toSpec 𝒜 f).1.base x = PrimeSpectrum.comap (mapId 𝒜 (Submonoid.powers_le.mpr x.2))
(closedPoint (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)) := by
show PrimeSpectrum.comap (awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x)
(LocalRing.closedPoint ((Proj| pbo f).presheaf.stalk x)) = _
rw [awayToΓ_ΓToStalk, CommRingCat.comp_eq_ring_hom_comp, PrimeSpectrum.comap_comp]
exact congr(PrimeSpectrum.comap _ $(@LocalRing.comap_closedPoint
(HomogeneousLocalization.AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) _ _
((Proj| pbo f).presheaf.stalk x) _ _ _ (isLocalRingHom_of_isIso _)))
lemma toSpec_base_apply_eq {f} (x : Proj| pbo f) :
(toSpec 𝒜 f).1.base x = ProjIsoSpecTopComponent.toSpec 𝒜 f x :=
toSpec_base_apply_eq_comap 𝒜 x |>.trans <| PrimeSpectrum.ext <| Ideal.ext fun z =>
show ¬ IsUnit _ ↔ z ∈ ProjIsoSpecTopComponent.ToSpec.carrier _ by
obtain ⟨z, rfl⟩ := z.mk_surjective
rw [← HomogeneousLocalization.isUnit_iff_isUnit_val,
ProjIsoSpecTopComponent.ToSpec.mk_mem_carrier, HomogeneousLocalization.map_mk,
HomogeneousLocalization.val_mk, Localization.mk_eq_mk',
IsLocalization.AtPrime.isUnit_mk'_iff]
exact not_not
lemma toSpec_base_isIso {f} {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
IsIso (toSpec 𝒜 f).1.base := by
convert (projIsoSpecTopComponent f_deg hm).isIso_hom
exact DFunLike.ext _ _ <| toSpec_base_apply_eq 𝒜
lemma mk_mem_toSpec_base_apply {f} (x : Proj| pbo f)
(z : NumDenSameDeg 𝒜 (.powers f)) :
HomogeneousLocalization.mk z ∈ ((toSpec 𝒜 f).1.base x).asIdeal ↔
z.num.1 ∈ x.1.asHomogeneousIdeal :=
(toSpec_base_apply_eq 𝒜 x).symm ▸ ProjIsoSpecTopComponent.ToSpec.mk_mem_carrier _ _
lemma toSpec_preimage_basicOpen {f}
(t : NumDenSameDeg 𝒜 (.powers f)) :
(Opens.map (toSpec 𝒜 f).1.base).obj (sbo (.mk t)) =
Opens.comap ⟨_, continuous_subtype_val⟩ (pbo t.num.1) :=
Opens.ext <| Opens.map_coe _ _ ▸ by
convert (ProjIsoSpecTopComponent.ToSpec.preimage_basicOpen f t)
exact funext fun _ => toSpec_base_apply_eq _ _
@[reassoc]
lemma toOpen_toSpec_val_c_app (f) (U) :
StructureSheaf.toOpen (A⁰_ f) U.unop ≫ (toSpec 𝒜 f).val.c.app U =
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.map (homOfLE le_top).op :=
Eq.trans (by congr) <| ΓSpec.toOpen_comp_locallyRingedSpaceAdjunction_homEquiv_app _ U
@[reassoc]
lemma toStalk_stalkMap_toSpec (f) (x) :
StructureSheaf.toStalk _ _ ≫ (toSpec 𝒜 f).stalkMap x =
awayToΓ 𝒜 f ≫ (Proj| pbo f).presheaf.Γgerm x := by
rw [StructureSheaf.toStalk, Category.assoc]
simp_rw [CommRingCat.coe_of]
erw [PresheafedSpace.stalkMap_germ']
rw [toOpen_toSpec_val_c_app_assoc, Presheaf.germ_res]
rfl
/--
If `x` is a point in the basic open set `D(f)` where `f` is a homogeneous element of positive
degree, then the homogeneously localized ring `A⁰ₓ` has the universal property of the localization
of `A⁰_f` at `φ(x)` where `φ : Proj|D(f) ⟶ Spec A⁰_f` is the morphism of locally ringed space
constructed as above.
-/
lemma isLocalization_atPrime (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
@IsLocalization (Away 𝒜 f) _ ((toSpec 𝒜 f).1.base x).asIdeal.primeCompl
(AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) _
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra := by
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
constructor
· rintro ⟨y, hy⟩
obtain ⟨y, rfl⟩ := y.mk_surjective
refine isUnit_of_mul_eq_one _
(.mk ⟨y.deg, y.den, y.num, (mk_mem_toSpec_base_apply _ _ _).not.mp hy⟩) <| val_injective _ ?_
simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mul, val_mk, mk_eq_mk',
val_one, IsLocalization.mk'_mul_mk'_eq_one']
· intro z
obtain ⟨⟨i, a, ⟨b, hb⟩, (hb' : b ∉ x.1.1)⟩, rfl⟩ := z.mk_surjective
refine ⟨⟨.mk ⟨i * m, ⟨a * b ^ (m - 1), ?_⟩, ⟨f ^ i, SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
⟨.mk ⟨i * m, ⟨b ^ m, mul_comm m i ▸ SetLike.pow_mem_graded _ hb⟩,
⟨f ^ i, SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
(mk_mem_toSpec_base_apply _ _ _).not.mpr <| x.1.1.toIdeal.primeCompl.pow_mem hb' m⟩⟩,
val_injective _ ?_⟩
· convert SetLike.mul_mem_graded a.2 (SetLike.pow_mem_graded (m - 1) hb) using 2
rw [← succ_nsmul', tsub_add_cancel_of_le (by omega), mul_comm, smul_eq_mul]
· simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mul, val_mk,
mk_eq_mk', ← IsLocalization.mk'_mul, Submonoid.mk_mul_mk, IsLocalization.mk'_eq_iff_eq]
rw [mul_comm b, mul_mul_mul_comm, ← pow_succ', mul_assoc, tsub_add_cancel_of_le (by omega)]
· intros y z e
obtain ⟨y, rfl⟩ := y.mk_surjective
obtain ⟨z, rfl⟩ := z.mk_surjective
obtain ⟨i, c, hc, hc', e⟩ : ∃ i, ∃ c ∈ 𝒜 i, c ∉ x.1.asHomogeneousIdeal ∧
c * (z.den.1 * y.num.1) = c * (y.den.1 * z.num.1) := by
apply_fun HomogeneousLocalization.val at e
simp only [RingHom.algebraMap_toAlgebra, map_mk, RingHom.id_apply, val_mk, mk_eq_mk',
IsLocalization.mk'_eq_iff_eq] at e
obtain ⟨⟨c, hcx⟩, hc⟩ := IsLocalization.exists_of_eq (M := x.1.1.toIdeal.primeCompl) e
obtain ⟨i, hi⟩ := not_forall.mp ((x.1.1.isHomogeneous.mem_iff _).not.mp hcx)
refine ⟨i, _, (decompose 𝒜 c i).2, hi, ?_⟩
apply_fun fun x ↦ (decompose 𝒜 x (i + z.deg + y.deg)).1 at hc
conv_rhs at hc => rw [add_right_comm]
rwa [← mul_assoc, coe_decompose_mul_add_of_right_mem, coe_decompose_mul_add_of_right_mem,
← mul_assoc, coe_decompose_mul_add_of_right_mem, coe_decompose_mul_add_of_right_mem,
mul_assoc, mul_assoc] at hc
exacts [y.den.2, z.num.2, z.den.2, y.num.2]
refine ⟨⟨.mk ⟨m * i, ⟨c ^ m, SetLike.pow_mem_graded _ hc⟩,
⟨f ^ i, mul_comm m i ▸ SetLike.pow_mem_graded _ f_deg⟩, ⟨_, rfl⟩⟩,
(mk_mem_toSpec_base_apply _ _ _).not.mpr <| x.1.1.toIdeal.primeCompl.pow_mem hc' _⟩,
val_injective _ ?_⟩
simp only [val_mul, val_mk, mk_eq_mk', ← IsLocalization.mk'_mul, Submonoid.mk_mul_mk,
IsLocalization.mk'_eq_iff_eq, mul_assoc]
congr 2
rw [mul_left_comm, mul_left_comm y.den.1, ← tsub_add_cancel_of_le (show 1 ≤ m from hm),
pow_succ, mul_assoc, mul_assoc, e]
/--
For an element `f ∈ A` with positive degree and a homogeneous ideal in `D(f)`, we have that the
stalk of `Spec A⁰_ f` at `y` is isomorphic to `A⁰ₓ` where `y` is the point in `Proj` corresponding
to `x`.
-/
def specStalkEquiv (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).1.base x) ≅
CommRingCat.of (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
haveI := isLocalization_atPrime 𝒜 f x f_deg hm
(IsLocalization.algEquiv
(R := A⁰_ f)
(M := ((toSpec 𝒜 f).1.base x).asIdeal.primeCompl)
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).1.base x))
(Q := AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)).toRingEquiv.toCommRingCatIso
lemma toStalk_specStalkEquiv (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
StructureSheaf.toStalk (A⁰_ f) ((toSpec 𝒜 f).1.base x) ≫ (specStalkEquiv 𝒜 f x f_deg hm).hom =
(mapId _ <| Submonoid.powers_le.mpr x.2 : (A⁰_ f) →+* AtPrime 𝒜 x.1.1.toIdeal) :=
letI : Algebra (Away 𝒜 f) (AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal) :=
(mapId 𝒜 (Submonoid.powers_le.mpr x.2)).toAlgebra
letI := isLocalization_atPrime 𝒜 f x f_deg hm
(IsLocalization.algEquiv
(R := A⁰_ f)
(M := ((toSpec 𝒜 f).1.base x).asIdeal.primeCompl)
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).1.base x))
(Q := AtPrime 𝒜 x.1.asHomogeneousIdeal.toIdeal)).toAlgHom.comp_algebraMap
lemma stalkMap_toSpec (f) (x : pbo f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(toSpec 𝒜 f).stalkMap x =
(specStalkEquiv 𝒜 f x f_deg hm).hom ≫ (Proj.stalkIso' 𝒜 x.1).toCommRingCatIso.inv ≫
((Proj.toLocallyRingedSpace 𝒜).restrictStalkIso (Opens.openEmbedding _) x).inv :=
IsLocalization.ringHom_ext (R := A⁰_ f) ((toSpec 𝒜 f).1.base x).asIdeal.primeCompl
(S := (Spec.structureSheaf (A⁰_ f)).presheaf.stalk ((toSpec 𝒜 f).1.base x)) <|
(toStalk_stalkMap_toSpec _ _ _).trans <| by
rw [awayToΓ_ΓToStalk, ← toStalk_specStalkEquiv, Category.assoc]; rfl
lemma isIso_toSpec (f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
IsIso (toSpec 𝒜 f) := by
haveI : IsIso (toSpec 𝒜 f).1.base := toSpec_base_isIso 𝒜 f_deg hm
haveI (x) : IsIso ((toSpec 𝒜 f).stalkMap x) := by
rw [stalkMap_toSpec 𝒜 f x f_deg hm]; infer_instance
haveI : LocallyRingedSpace.IsOpenImmersion (toSpec 𝒜 f) :=
LocallyRingedSpace.IsOpenImmersion.of_stalk_iso (toSpec 𝒜 f)
(TopCat.homeoOfIso (asIso <| (toSpec 𝒜 f).1.base)).openEmbedding
exact LocallyRingedSpace.IsOpenImmersion.to_iso _
end ProjectiveSpectrum.Proj
open ProjectiveSpectrum.Proj in
/--
If `f ∈ A` is a homogeneous element of positive degree, then the projective spectrum restricted to
`D(f)` as a locally ringed space is isomorphic to `Spec A⁰_f`.
-/
def projIsoSpec (f) {m} (f_deg : f ∈ 𝒜 m) (hm : 0 < m) :
(Proj| pbo f) ≅ (Spec (A⁰_ f)) :=
@asIso (f := toSpec 𝒜 f) (isIso_toSpec 𝒜 f f_deg hm)
/--
This is the scheme `Proj(A)` for any `ℕ`-graded ring `A`.
-/
def «Proj» : Scheme where
__ := Proj.toLocallyRingedSpace 𝒜
local_affine (x : Proj.T) := by
classical
obtain ⟨f, m, f_deg, hm, hx⟩ : ∃ (f : A) (m : ℕ) (_ : f ∈ 𝒜 m) (_ : 0 < m), f ∉ x.1 := by
by_contra!
refine x.not_irrelevant_le fun z hz ↦ ?_
rw [← DirectSum.sum_support_decompose 𝒜 z]
exact x.1.toIdeal.sum_mem fun k hk ↦ this _ k (SetLike.coe_mem _) <| by_contra <| by aesop
exact ⟨⟨pbo f, hx⟩, .of (A⁰_ f), ⟨projIsoSpec 𝒜 f f_deg hm⟩⟩
end AlgebraicGeometry
|
AlgebraicGeometry\ProjectiveSpectrum\StructureSheaf.lean | /-
Copyright (c) 2022 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang
-/
import Mathlib.AlgebraicGeometry.ProjectiveSpectrum.Topology
import Mathlib.Topology.Sheaves.LocalPredicate
import Mathlib.RingTheory.GradedAlgebra.HomogeneousLocalization
import Mathlib.Geometry.RingedSpace.LocallyRingedSpace
/-!
# The structure sheaf on `ProjectiveSpectrum 𝒜`.
In `Mathlib.AlgebraicGeometry.Topology`, we have given a topology on `ProjectiveSpectrum 𝒜`; in
this file we will construct a sheaf on `ProjectiveSpectrum 𝒜`.
## Notation
- `R` is a commutative semiring;
- `A` is a commutative ring and an `R`-algebra;
- `𝒜 : ℕ → Submodule R A` is the grading of `A`;
- `U` is opposite object of some open subset of `ProjectiveSpectrum.top`.
## Main definitions and results
We define the structure sheaf as the subsheaf of all dependent function
`f : Π x : U, HomogeneousLocalization 𝒜 x` such that `f` is locally expressible as ratio of two
elements of the *same grading*, i.e. `∀ y ∈ U, ∃ (V ⊆ U) (i : ℕ) (a b ∈ 𝒜 i), ∀ z ∈ V, f z = a / b`.
* `AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf.isLocallyFraction`: the predicate that
a dependent function is locally expressible as a ratio of two elements of the same grading.
* `AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf.sectionsSubring`: the dependent functions
satisfying the above local property forms a subring of all dependent functions
`Π x : U, HomogeneousLocalization 𝒜 x`.
* `AlgebraicGeometry.Proj.StructureSheaf`: the sheaf with `U ↦ sectionsSubring U` and natural
restriction map.
Then we establish that `Proj 𝒜` is a `LocallyRingedSpace`:
* `AlgebraicGeometry.Proj.stalkIso'`: for any `x : ProjectiveSpectrum 𝒜`, the stalk of
`Proj.StructureSheaf` at `x` is isomorphic to `HomogeneousLocalization 𝒜 x`.
* `AlgebraicGeometry.Proj.toLocallyRingedSpace`: `Proj` as a locally ringed space.
## References
* [Robin Hartshorne, *Algebraic Geometry*][Har77]
-/
noncomputable section
namespace AlgebraicGeometry
open scoped DirectSum Pointwise
open DirectSum SetLike Localization TopCat TopologicalSpace CategoryTheory Opposite
variable {R A : Type*}
variable [CommRing R] [CommRing A] [Algebra R A]
variable (𝒜 : ℕ → Submodule R A) [GradedAlgebra 𝒜]
local notation3 "at " x =>
HomogeneousLocalization.AtPrime 𝒜
(HomogeneousIdeal.toIdeal (ProjectiveSpectrum.asHomogeneousIdeal x))
namespace ProjectiveSpectrum.StructureSheaf
variable {𝒜}
/-- The predicate saying that a dependent function on an open `U` is realised as a fixed fraction
`r / s` of *same grading* in each of the stalks (which are localizations at various prime ideals).
-/
def IsFraction {U : Opens (ProjectiveSpectrum.top 𝒜)} (f : ∀ x : U, at x.1) : Prop :=
∃ (i : ℕ) (r s : 𝒜 i) (s_nin : ∀ x : U, s.1 ∉ x.1.asHomogeneousIdeal),
∀ x : U, f x = .mk ⟨i, r, s, s_nin x⟩
variable (𝒜)
/--
The predicate `IsFraction` is "prelocal", in the sense that if it holds on `U` it holds on any open
subset `V` of `U`.
-/
def isFractionPrelocal : PrelocalPredicate fun x : ProjectiveSpectrum.top 𝒜 => at x where
pred f := IsFraction f
res := by rintro V U i f ⟨j, r, s, h, w⟩; exact ⟨j, r, s, (h <| i ·), (w <| i ·)⟩
/-- We will define the structure sheaf as the subsheaf of all dependent functions in
`Π x : U, HomogeneousLocalization 𝒜 x` consisting of those functions which can locally be expressed
as a ratio of `A` of same grading. -/
def isLocallyFraction : LocalPredicate fun x : ProjectiveSpectrum.top 𝒜 => at x :=
(isFractionPrelocal 𝒜).sheafify
namespace SectionSubring
variable {𝒜}
open Submodule SetLike.GradedMonoid HomogeneousLocalization
theorem zero_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
(isLocallyFraction 𝒜).pred (0 : ∀ x : U.unop, at x.1) := fun x =>
⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨0, zero_mem _⟩, ⟨1, one_mem_graded _⟩, _, fun _ => rfl⟩⟩
theorem one_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
(isLocallyFraction 𝒜).pred (1 : ∀ x : U.unop, at x.1) := fun x =>
⟨unop U, x.2, 𝟙 (unop U), ⟨0, ⟨1, one_mem_graded _⟩, ⟨1, one_mem_graded _⟩, _, fun _ => rfl⟩⟩
theorem add_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a b : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) (hb : (isLocallyFraction 𝒜).pred b) :
(isLocallyFraction 𝒜).pred (a + b) := fun x => by
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, hwa, wa⟩
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, hwb, wb⟩
refine
⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ja + jb,
⟨sb * ra + sa * rb,
add_mem (add_comm jb ja ▸ mul_mem_graded sb_mem ra_mem : sb * ra ∈ 𝒜 (ja + jb))
(mul_mem_graded sa_mem rb_mem)⟩,
⟨sa * sb, mul_mem_graded sa_mem sb_mem⟩, fun y ↦
y.1.asHomogeneousIdeal.toIdeal.primeCompl.mul_mem (hwa ⟨y.1, y.2.1⟩) (hwb ⟨y.1, y.2.2⟩),
fun y => ?_⟩
simp only at wa wb
simp only [Pi.add_apply, wa ⟨y.1, y.2.1⟩, wb ⟨y.1, y.2.2⟩, ext_iff_val,
val_add, val_mk, add_mk, add_comm (sa * rb)]
rfl
theorem neg_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) : (isLocallyFraction 𝒜).pred (-a) := fun x => by
rcases ha x with ⟨V, m, i, j, ⟨r, r_mem⟩, ⟨s, s_mem⟩, nin, hy⟩
refine ⟨V, m, i, j, ⟨-r, Submodule.neg_mem _ r_mem⟩, ⟨s, s_mem⟩, nin, fun y => ?_⟩
simp only [ext_iff_val, val_mk] at hy
simp only [Pi.neg_apply, ext_iff_val, val_neg, hy, val_mk, neg_mk]
theorem mul_mem' (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) (a b : ∀ x : U.unop, at x.1)
(ha : (isLocallyFraction 𝒜).pred a) (hb : (isLocallyFraction 𝒜).pred b) :
(isLocallyFraction 𝒜).pred (a * b) := fun x => by
rcases ha x with ⟨Va, ma, ia, ja, ⟨ra, ra_mem⟩, ⟨sa, sa_mem⟩, hwa, wa⟩
rcases hb x with ⟨Vb, mb, ib, jb, ⟨rb, rb_mem⟩, ⟨sb, sb_mem⟩, hwb, wb⟩
refine
⟨Va ⊓ Vb, ⟨ma, mb⟩, Opens.infLELeft _ _ ≫ ia, ja + jb,
⟨ra * rb, SetLike.mul_mem_graded ra_mem rb_mem⟩,
⟨sa * sb, SetLike.mul_mem_graded sa_mem sb_mem⟩, fun y =>
y.1.asHomogeneousIdeal.toIdeal.primeCompl.mul_mem (hwa ⟨y.1, y.2.1⟩) (hwb ⟨y.1, y.2.2⟩),
fun y ↦ ?_⟩
simp only [Pi.mul_apply, wa ⟨y.1, y.2.1⟩, wb ⟨y.1, y.2.2⟩, ext_iff_val, val_mul, val_mk,
Localization.mk_mul]
rfl
end SectionSubring
section
open SectionSubring
variable {𝒜}
/-- The functions satisfying `isLocallyFraction` form a subring of all dependent functions
`Π x : U, HomogeneousLocalization 𝒜 x`. -/
def sectionsSubring (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
Subring (∀ x : U.unop, at x.1) where
carrier := {f | (isLocallyFraction 𝒜).pred f}
zero_mem' := zero_mem' U
one_mem' := one_mem' U
add_mem' := add_mem' U _ _
neg_mem' := neg_mem' U _
mul_mem' := mul_mem' U _ _
end
/-- The structure sheaf (valued in `Type`, not yet `CommRing`) is the subsheaf consisting of
functions satisfying `isLocallyFraction`. -/
def structureSheafInType : Sheaf (Type _) (ProjectiveSpectrum.top 𝒜) :=
subsheafToTypes (isLocallyFraction 𝒜)
instance commRingStructureSheafInTypeObj (U : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ) :
CommRing ((structureSheafInType 𝒜).1.obj U) :=
(sectionsSubring U).toCommRing
/-- The structure presheaf, valued in `CommRing`, constructed by dressing up the `Type` valued
structure presheaf. -/
@[simps]
def structurePresheafInCommRing : Presheaf CommRingCat (ProjectiveSpectrum.top 𝒜) where
obj U := CommRingCat.of ((structureSheafInType 𝒜).1.obj U)
map i :=
{ toFun := (structureSheafInType 𝒜).1.map i
map_zero' := rfl
map_add' := fun x y => rfl
map_one' := rfl
map_mul' := fun x y => rfl }
-- These lemmas have always been bad (#7657), but leanprover/lean4#2644 made `simp` start noticing
attribute [nolint simpNF]
AlgebraicGeometry.ProjectiveSpectrum.StructureSheaf.structurePresheafInCommRing_map_apply
/-- Some glue, verifying that the structure presheaf valued in `CommRing` agrees with the `Type`
valued structure presheaf. -/
def structurePresheafCompForget :
structurePresheafInCommRing 𝒜 ⋙ forget CommRingCat ≅ (structureSheafInType 𝒜).1 :=
NatIso.ofComponents (fun U => Iso.refl _) (by aesop_cat)
end ProjectiveSpectrum.StructureSheaf
namespace ProjectiveSpectrum
open TopCat.Presheaf ProjectiveSpectrum.StructureSheaf Opens
/-- The structure sheaf on `Proj` 𝒜, valued in `CommRing`. -/
def Proj.structureSheaf : Sheaf CommRingCat (ProjectiveSpectrum.top 𝒜) :=
⟨structurePresheafInCommRing 𝒜,
(-- We check the sheaf condition under `forget CommRing`.
isSheaf_iff_isSheaf_comp
_ _).mpr
(isSheaf_of_iso (structurePresheafCompForget 𝒜).symm (structureSheafInType 𝒜).cond)⟩
end ProjectiveSpectrum
section
open ProjectiveSpectrum ProjectiveSpectrum.StructureSheaf Opens
section
variable {U V : (Opens (ProjectiveSpectrum.top 𝒜))ᵒᵖ} (i : V ⟶ U)
(s t : (Proj.structureSheaf 𝒜).1.obj V) (x : V.unop)
@[simp]
theorem Proj.res_apply (x) : ((Proj.structureSheaf 𝒜).1.map i s).1 x = s.1 (i.unop x) := rfl
@[ext] theorem Proj.ext (h : s.1 = t.1) : s = t := Subtype.ext h
@[simp] theorem Proj.add_apply : (s + t).1 x = s.1 x + t.1 x := rfl
@[simp] theorem Proj.mul_apply : (s * t).1 x = s.1 x * t.1 x := rfl
@[simp] theorem Proj.sub_apply : (s - t).1 x = s.1 x - t.1 x := rfl
@[simp] theorem Proj.pow_apply (n : ℕ) : (s ^ n).1 x = s.1 x ^ n := rfl
@[simp] theorem Proj.zero_apply : (0 : (Proj.structureSheaf 𝒜).1.obj V).1 x = 0 := rfl
@[simp] theorem Proj.one_apply : (1 : (Proj.structureSheaf 𝒜).1.obj V).1 x = 1 := rfl
end
/-- `Proj` of a graded ring as a `SheafedSpace`-/
def Proj.toSheafedSpace : SheafedSpace CommRingCat where
carrier := TopCat.of (ProjectiveSpectrum 𝒜)
presheaf := (Proj.structureSheaf 𝒜).1
IsSheaf := (Proj.structureSheaf 𝒜).2
/-- The ring homomorphism that takes a section of the structure sheaf of `Proj` on the open set `U`,
implemented as a subtype of dependent functions to localizations at homogeneous prime ideals, and
evaluates the section on the point corresponding to a given homogeneous prime ideal. -/
def openToLocalization (U : Opens (ProjectiveSpectrum.top 𝒜)) (x : ProjectiveSpectrum.top 𝒜)
(hx : x ∈ U) : (Proj.structureSheaf 𝒜).1.obj (op U) ⟶ CommRingCat.of (at x) where
toFun s := (s.1 ⟨x, hx⟩ : _)
map_one' := rfl
map_mul' _ _ := rfl
map_zero' := rfl
map_add' _ _ := rfl
/-- The ring homomorphism from the stalk of the structure sheaf of `Proj` at a point corresponding
to a homogeneous prime ideal `x` to the *homogeneous localization* at `x`,
formed by gluing the `openToLocalization` maps. -/
def stalkToFiberRingHom (x : ProjectiveSpectrum.top 𝒜) :
(Proj.structureSheaf 𝒜).presheaf.stalk x ⟶ CommRingCat.of (at x) :=
Limits.colimit.desc ((OpenNhds.inclusion x).op ⋙ (Proj.structureSheaf 𝒜).1)
{ pt := _
ι :=
{ app := fun U =>
openToLocalization 𝒜 ((OpenNhds.inclusion _).obj U.unop) x U.unop.2 } }
@[simp]
theorem germ_comp_stalkToFiberRingHom (U : Opens (ProjectiveSpectrum.top 𝒜)) (x : U) :
(Proj.structureSheaf 𝒜).presheaf.germ x ≫ stalkToFiberRingHom 𝒜 x =
openToLocalization 𝒜 U x x.2 :=
Limits.colimit.ι_desc _ _
@[simp]
theorem stalkToFiberRingHom_germ' (U : Opens (ProjectiveSpectrum.top 𝒜))
(x : ProjectiveSpectrum.top 𝒜) (hx : x ∈ U) (s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
stalkToFiberRingHom 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
RingHom.ext_iff.1 (germ_comp_stalkToFiberRingHom 𝒜 U ⟨x, hx⟩ : _) s
@[simp]
theorem stalkToFiberRingHom_germ (U : Opens (ProjectiveSpectrum.top 𝒜)) (x : U)
(s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
stalkToFiberRingHom 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ x s) = s.1 x :=
stalkToFiberRingHom_germ' 𝒜 U _ _ _
theorem mem_basicOpen_den (x : ProjectiveSpectrum.top 𝒜)
(f : HomogeneousLocalization.NumDenSameDeg 𝒜 x.asHomogeneousIdeal.toIdeal.primeCompl) :
x ∈ ProjectiveSpectrum.basicOpen 𝒜 f.den := by
rw [ProjectiveSpectrum.mem_basicOpen]
exact f.den_mem
/-- Given a point `x` corresponding to a homogeneous prime ideal, there is a (dependent) function
such that, for any `f` in the homogeneous localization at `x`, it returns the obvious section in the
basic open set `D(f.den)`-/
def sectionInBasicOpen (x : ProjectiveSpectrum.top 𝒜) :
∀ f : HomogeneousLocalization.NumDenSameDeg 𝒜 x.asHomogeneousIdeal.toIdeal.primeCompl,
(Proj.structureSheaf 𝒜).1.obj (op (ProjectiveSpectrum.basicOpen 𝒜 f.den)) :=
fun f =>
⟨fun y => HomogeneousLocalization.mk ⟨f.deg, f.num, f.den, y.2⟩, fun y =>
⟨ProjectiveSpectrum.basicOpen 𝒜 f.den, y.2,
⟨𝟙 _, ⟨f.deg, ⟨f.num, f.den, _, fun _ => rfl⟩⟩⟩⟩⟩
open HomogeneousLocalization in
/-- Given any point `x` and `f` in the homogeneous localization at `x`, there is an element in the
stalk at `x` obtained by `sectionInBasicOpen`. This is the inverse of `stalkToFiberRingHom`.
-/
def homogeneousLocalizationToStalk (x : ProjectiveSpectrum.top 𝒜) (y : at x) :
(Proj.structureSheaf 𝒜).presheaf.stalk x := Quotient.liftOn' y (fun f =>
(Proj.structureSheaf 𝒜).presheaf.germ ⟨x, mem_basicOpen_den _ x f⟩ (sectionInBasicOpen _ x f))
fun f g (e : f.embedding = g.embedding) ↦ by
simp only [HomogeneousLocalization.NumDenSameDeg.embedding, Localization.mk_eq_mk',
IsLocalization.mk'_eq_iff_eq,
IsLocalization.eq_iff_exists x.asHomogeneousIdeal.toIdeal.primeCompl] at e
obtain ⟨⟨c, hc⟩, hc'⟩ := e
apply (Proj.structureSheaf 𝒜).presheaf.germ_ext
(ProjectiveSpectrum.basicOpen 𝒜 f.den.1 ⊓
ProjectiveSpectrum.basicOpen 𝒜 g.den.1 ⊓ ProjectiveSpectrum.basicOpen 𝒜 c)
⟨⟨mem_basicOpen_den _ x f, mem_basicOpen_den _ x g⟩, hc⟩
(homOfLE inf_le_left ≫ homOfLE inf_le_left) (homOfLE inf_le_left ≫ homOfLE inf_le_right)
apply Subtype.ext
ext ⟨t, ⟨htf, htg⟩, ht'⟩
rw [Proj.res_apply, Proj.res_apply]
simp only [sectionInBasicOpen, HomogeneousLocalization.val_mk, Localization.mk_eq_mk',
IsLocalization.mk'_eq_iff_eq]
apply (IsLocalization.map_units (M := t.asHomogeneousIdeal.toIdeal.primeCompl)
(Localization t.asHomogeneousIdeal.toIdeal.primeCompl) ⟨c, ht'⟩).mul_left_cancel
rw [← map_mul, ← map_mul, hc']
lemma homogeneousLocalizationToStalk_stalkToFiberRingHom (x z) :
homogeneousLocalizationToStalk 𝒜 x (stalkToFiberRingHom 𝒜 x z) = z := by
obtain ⟨U, hxU, s, rfl⟩ := (Proj.structureSheaf 𝒜).presheaf.germ_exist x z
obtain ⟨V, hxV, i, n, a, b, h, e⟩ := s.2 ⟨x, hxU⟩
simp only at e
rw [stalkToFiberRingHom_germ', homogeneousLocalizationToStalk, e ⟨x, hxV⟩, Quotient.liftOn'_mk'']
refine Presheaf.germ_ext _ V hxV (by exact homOfLE <| fun _ h' ↦ h ⟨_, h'⟩) i ?_
apply Subtype.ext
ext ⟨t, ht⟩
rw [Proj.res_apply, Proj.res_apply]
simp only [sectionInBasicOpen, HomogeneousLocalization.val_mk, Localization.mk_eq_mk',
IsLocalization.mk'_eq_iff_eq, e ⟨t, ht⟩]
lemma stalkToFiberRingHom_homogeneousLocalizationToStalk (x z) :
stalkToFiberRingHom 𝒜 x (homogeneousLocalizationToStalk 𝒜 x z) = z := by
obtain ⟨z, rfl⟩ := Quotient.surjective_Quotient_mk'' z
rw [homogeneousLocalizationToStalk, Quotient.liftOn'_mk'',
stalkToFiberRingHom_germ', sectionInBasicOpen]
/-- Using `homogeneousLocalizationToStalk`, we construct a ring isomorphism between stalk at `x`
and homogeneous localization at `x` for any point `x` in `Proj`. -/
def Proj.stalkIso' (x : ProjectiveSpectrum.top 𝒜) :
(Proj.structureSheaf 𝒜).presheaf.stalk x ≃+* at x where
__ := stalkToFiberRingHom _ x
invFun := homogeneousLocalizationToStalk 𝒜 x
left_inv := homogeneousLocalizationToStalk_stalkToFiberRingHom 𝒜 x
right_inv := stalkToFiberRingHom_homogeneousLocalizationToStalk 𝒜 x
@[simp]
theorem Proj.stalkIso'_germ' (U : Opens (ProjectiveSpectrum.top 𝒜))
(x : ProjectiveSpectrum.top 𝒜) (hx : x ∈ U) (s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
Proj.stalkIso' 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ ⟨x, hx⟩ s) = (s.1 ⟨x, hx⟩ : _) :=
stalkToFiberRingHom_germ' 𝒜 U x hx s
@[simp]
theorem Proj.stalkIso'_germ (U : Opens (ProjectiveSpectrum.top 𝒜)) (x : U)
(s : (Proj.structureSheaf 𝒜).1.obj (op U)) :
Proj.stalkIso' 𝒜 x ((Proj.structureSheaf 𝒜).presheaf.germ x s) = s.1 x :=
stalkToFiberRingHom_germ' 𝒜 U x x.2 s
@[simp]
theorem Proj.stalkIso'_symm_mk (x) (f) :
(Proj.stalkIso' 𝒜 x).symm (.mk f) = (Proj.structureSheaf 𝒜).presheaf.germ
⟨x, mem_basicOpen_den _ x f⟩ (sectionInBasicOpen _ x f) := rfl
/-- `Proj` of a graded ring as a `LocallyRingedSpace`-/
def Proj.toLocallyRingedSpace : LocallyRingedSpace :=
{ Proj.toSheafedSpace 𝒜 with
localRing := fun x =>
@RingEquiv.localRing _ _ _ (show LocalRing (at x) from inferInstance) _
(Proj.stalkIso' 𝒜 x).symm }
end
end AlgebraicGeometry
|
AlgebraicGeometry\ProjectiveSpectrum\Topology.lean | /-
Copyright (c) 2020 Jujian Zhang. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jujian Zhang, Johan Commelin
-/
import Mathlib.RingTheory.GradedAlgebra.HomogeneousIdeal
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Sets.Opens
import Mathlib.Data.Set.Subsingleton
/-!
# Projective spectrum of a graded ring
The projective spectrum of a graded commutative ring is the subtype of all homogenous ideals that
are prime and do not contain the irrelevant ideal.
It is naturally endowed with a topology: the Zariski topology.
## Notation
- `R` is a commutative semiring;
- `A` is a commutative ring and an `R`-algebra;
- `𝒜 : ℕ → Submodule R A` is the grading of `A`;
## Main definitions
* `ProjectiveSpectrum 𝒜`: The projective spectrum of a graded ring `A`, or equivalently, the set of
all homogeneous ideals of `A` that is both prime and relevant i.e. not containing irrelevant
ideal. Henceforth, we call elements of projective spectrum *relevant homogeneous prime ideals*.
* `ProjectiveSpectrum.zeroLocus 𝒜 s`: The zero locus of a subset `s` of `A`
is the subset of `ProjectiveSpectrum 𝒜` consisting of all relevant homogeneous prime ideals that
contain `s`.
* `ProjectiveSpectrum.vanishingIdeal t`: The vanishing ideal of a subset `t` of
`ProjectiveSpectrum 𝒜` is the intersection of points in `t` (viewed as relevant homogeneous prime
ideals).
* `ProjectiveSpectrum.Top`: the topological space of `ProjectiveSpectrum 𝒜` endowed with the
Zariski topology.
-/
noncomputable section
open DirectSum Pointwise SetLike TopCat TopologicalSpace CategoryTheory Opposite
variable {R A : Type*}
variable [CommSemiring R] [CommRing A] [Algebra R A]
variable (𝒜 : ℕ → Submodule R A) [GradedAlgebra 𝒜]
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- The projective spectrum of a graded commutative ring is the subtype of all homogenous ideals
that are prime and do not contain the irrelevant ideal. -/
@[ext]
structure ProjectiveSpectrum where
asHomogeneousIdeal : HomogeneousIdeal 𝒜
isPrime : asHomogeneousIdeal.toIdeal.IsPrime
not_irrelevant_le : ¬HomogeneousIdeal.irrelevant 𝒜 ≤ asHomogeneousIdeal
attribute [instance] ProjectiveSpectrum.isPrime
namespace ProjectiveSpectrum
/-- The zero locus of a set `s` of elements of a commutative ring `A` is the set of all relevant
homogeneous prime ideals of the ring that contain the set `s`.
An element `f` of `A` can be thought of as a dependent function on the projective spectrum of `𝒜`.
At a point `x` (a homogeneous prime ideal) the function (i.e., element) `f` takes values in the
quotient ring `A` modulo the prime ideal `x`. In this manner, `zeroLocus s` is exactly the subset
of `ProjectiveSpectrum 𝒜` where all "functions" in `s` vanish simultaneously. -/
def zeroLocus (s : Set A) : Set (ProjectiveSpectrum 𝒜) :=
{ x | s ⊆ x.asHomogeneousIdeal }
@[simp]
theorem mem_zeroLocus (x : ProjectiveSpectrum 𝒜) (s : Set A) :
x ∈ zeroLocus 𝒜 s ↔ s ⊆ x.asHomogeneousIdeal :=
Iff.rfl
@[simp]
theorem zeroLocus_span (s : Set A) : zeroLocus 𝒜 (Ideal.span s) = zeroLocus 𝒜 s := by
ext x
exact (Submodule.gi _ _).gc s x.asHomogeneousIdeal.toIdeal
variable {𝒜}
/-- The vanishing ideal of a set `t` of points of the projective spectrum of a commutative ring `R`
is the intersection of all the relevant homogeneous prime ideals in the set `t`.
An element `f` of `A` can be thought of as a dependent function on the projective spectrum of `𝒜`.
At a point `x` (a homogeneous prime ideal) the function (i.e., element) `f` takes values in the
quotient ring `A` modulo the prime ideal `x`. In this manner, `vanishingIdeal t` is exactly the
ideal of `A` consisting of all "functions" that vanish on all of `t`. -/
def vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) : HomogeneousIdeal 𝒜 :=
⨅ (x : ProjectiveSpectrum 𝒜) (_ : x ∈ t), x.asHomogeneousIdeal
theorem coe_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) :
(vanishingIdeal t : Set A) =
{ f | ∀ x : ProjectiveSpectrum 𝒜, x ∈ t → f ∈ x.asHomogeneousIdeal } := by
ext f
rw [vanishingIdeal, SetLike.mem_coe, ← HomogeneousIdeal.mem_iff, HomogeneousIdeal.toIdeal_iInf,
Submodule.mem_iInf]
refine forall_congr' fun x => ?_
rw [HomogeneousIdeal.toIdeal_iInf, Submodule.mem_iInf, HomogeneousIdeal.mem_iff]
theorem mem_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (f : A) :
f ∈ vanishingIdeal t ↔ ∀ x : ProjectiveSpectrum 𝒜, x ∈ t → f ∈ x.asHomogeneousIdeal := by
rw [← SetLike.mem_coe, coe_vanishingIdeal, Set.mem_setOf_eq]
@[simp]
theorem vanishingIdeal_singleton (x : ProjectiveSpectrum 𝒜) :
vanishingIdeal ({x} : Set (ProjectiveSpectrum 𝒜)) = x.asHomogeneousIdeal := by
simp [vanishingIdeal]
theorem subset_zeroLocus_iff_le_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (I : Ideal A) :
t ⊆ zeroLocus 𝒜 I ↔ I ≤ (vanishingIdeal t).toIdeal :=
⟨fun h _ k => (mem_vanishingIdeal _ _).mpr fun _ j => (mem_zeroLocus _ _ _).mpr (h j) k, fun h =>
fun x j =>
(mem_zeroLocus _ _ _).mpr (le_trans h fun _ h => ((mem_vanishingIdeal _ _).mp h) x j)⟩
variable (𝒜)
/-- `zeroLocus` and `vanishingIdeal` form a galois connection. -/
theorem gc_ideal :
@GaloisConnection (Ideal A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun I => zeroLocus 𝒜 I) fun t => (vanishingIdeal t).toIdeal :=
fun I t => subset_zeroLocus_iff_le_vanishingIdeal t I
/-- `zeroLocus` and `vanishingIdeal` form a galois connection. -/
theorem gc_set :
@GaloisConnection (Set A) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun s => zeroLocus 𝒜 s) fun t => vanishingIdeal t := by
have ideal_gc : GaloisConnection Ideal.span _ := (Submodule.gi A _).gc
simpa [zeroLocus_span, Function.comp] using GaloisConnection.compose ideal_gc (gc_ideal 𝒜)
theorem gc_homogeneousIdeal :
@GaloisConnection (HomogeneousIdeal 𝒜) (Set (ProjectiveSpectrum 𝒜))ᵒᵈ _ _
(fun I => zeroLocus 𝒜 I) fun t => vanishingIdeal t :=
fun I t => by
simpa [show I.toIdeal ≤ (vanishingIdeal t).toIdeal ↔ I ≤ vanishingIdeal t from Iff.rfl] using
subset_zeroLocus_iff_le_vanishingIdeal t I.toIdeal
theorem subset_zeroLocus_iff_subset_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) (s : Set A) :
t ⊆ zeroLocus 𝒜 s ↔ s ⊆ vanishingIdeal t :=
(gc_set _) s t
theorem subset_vanishingIdeal_zeroLocus (s : Set A) : s ⊆ vanishingIdeal (zeroLocus 𝒜 s) :=
(gc_set _).le_u_l s
theorem ideal_le_vanishingIdeal_zeroLocus (I : Ideal A) :
I ≤ (vanishingIdeal (zeroLocus 𝒜 I)).toIdeal :=
(gc_ideal _).le_u_l I
theorem homogeneousIdeal_le_vanishingIdeal_zeroLocus (I : HomogeneousIdeal 𝒜) :
I ≤ vanishingIdeal (zeroLocus 𝒜 I) :=
(gc_homogeneousIdeal _).le_u_l I
theorem subset_zeroLocus_vanishingIdeal (t : Set (ProjectiveSpectrum 𝒜)) :
t ⊆ zeroLocus 𝒜 (vanishingIdeal t) :=
(gc_ideal _).l_u_le t
theorem zeroLocus_anti_mono {s t : Set A} (h : s ⊆ t) : zeroLocus 𝒜 t ⊆ zeroLocus 𝒜 s :=
(gc_set _).monotone_l h
theorem zeroLocus_anti_mono_ideal {s t : Ideal A} (h : s ≤ t) :
zeroLocus 𝒜 (t : Set A) ⊆ zeroLocus 𝒜 (s : Set A) :=
(gc_ideal _).monotone_l h
theorem zeroLocus_anti_mono_homogeneousIdeal {s t : HomogeneousIdeal 𝒜} (h : s ≤ t) :
zeroLocus 𝒜 (t : Set A) ⊆ zeroLocus 𝒜 (s : Set A) :=
(gc_homogeneousIdeal _).monotone_l h
theorem vanishingIdeal_anti_mono {s t : Set (ProjectiveSpectrum 𝒜)} (h : s ⊆ t) :
vanishingIdeal t ≤ vanishingIdeal s :=
(gc_ideal _).monotone_u h
theorem zeroLocus_bot : zeroLocus 𝒜 ((⊥ : Ideal A) : Set A) = Set.univ :=
(gc_ideal 𝒜).l_bot
@[simp]
theorem zeroLocus_singleton_zero : zeroLocus 𝒜 ({0} : Set A) = Set.univ :=
zeroLocus_bot _
@[simp]
theorem zeroLocus_empty : zeroLocus 𝒜 (∅ : Set A) = Set.univ :=
(gc_set 𝒜).l_bot
@[simp]
theorem vanishingIdeal_univ : vanishingIdeal (∅ : Set (ProjectiveSpectrum 𝒜)) = ⊤ := by
simpa using (gc_ideal _).u_top
theorem zeroLocus_empty_of_one_mem {s : Set A} (h : (1 : A) ∈ s) : zeroLocus 𝒜 s = ∅ :=
Set.eq_empty_iff_forall_not_mem.mpr fun x hx =>
(inferInstance : x.asHomogeneousIdeal.toIdeal.IsPrime).ne_top <|
x.asHomogeneousIdeal.toIdeal.eq_top_iff_one.mpr <| hx h
@[simp]
theorem zeroLocus_singleton_one : zeroLocus 𝒜 ({1} : Set A) = ∅ :=
zeroLocus_empty_of_one_mem 𝒜 (Set.mem_singleton (1 : A))
@[simp]
theorem zeroLocus_univ : zeroLocus 𝒜 (Set.univ : Set A) = ∅ :=
zeroLocus_empty_of_one_mem _ (Set.mem_univ 1)
theorem zeroLocus_sup_ideal (I J : Ideal A) :
zeroLocus 𝒜 ((I ⊔ J : Ideal A) : Set A) = zeroLocus _ I ∩ zeroLocus _ J :=
(gc_ideal 𝒜).l_sup
theorem zeroLocus_sup_homogeneousIdeal (I J : HomogeneousIdeal 𝒜) :
zeroLocus 𝒜 ((I ⊔ J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus _ I ∩ zeroLocus _ J :=
(gc_homogeneousIdeal 𝒜).l_sup
theorem zeroLocus_union (s s' : Set A) : zeroLocus 𝒜 (s ∪ s') = zeroLocus _ s ∩ zeroLocus _ s' :=
(gc_set 𝒜).l_sup
theorem vanishingIdeal_union (t t' : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (t ∪ t') = vanishingIdeal t ⊓ vanishingIdeal t' := by
ext1; exact (gc_ideal 𝒜).u_inf
theorem zeroLocus_iSup_ideal {γ : Sort*} (I : γ → Ideal A) :
zeroLocus _ ((⨆ i, I i : Ideal A) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) :=
(gc_ideal 𝒜).l_iSup
theorem zeroLocus_iSup_homogeneousIdeal {γ : Sort*} (I : γ → HomogeneousIdeal 𝒜) :
zeroLocus _ ((⨆ i, I i : HomogeneousIdeal 𝒜) : Set A) = ⋂ i, zeroLocus 𝒜 (I i) :=
(gc_homogeneousIdeal 𝒜).l_iSup
theorem zeroLocus_iUnion {γ : Sort*} (s : γ → Set A) :
zeroLocus 𝒜 (⋃ i, s i) = ⋂ i, zeroLocus 𝒜 (s i) :=
(gc_set 𝒜).l_iSup
theorem zeroLocus_bUnion (s : Set (Set A)) :
zeroLocus 𝒜 (⋃ s' ∈ s, s' : Set A) = ⋂ s' ∈ s, zeroLocus 𝒜 s' := by
simp only [zeroLocus_iUnion]
theorem vanishingIdeal_iUnion {γ : Sort*} (t : γ → Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (⋃ i, t i) = ⨅ i, vanishingIdeal (t i) :=
HomogeneousIdeal.toIdeal_injective <| by
convert (gc_ideal 𝒜).u_iInf; exact HomogeneousIdeal.toIdeal_iInf _
theorem zeroLocus_inf (I J : Ideal A) :
zeroLocus 𝒜 ((I ⊓ J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.inf_le
theorem union_zeroLocus (s s' : Set A) :
zeroLocus 𝒜 s ∪ zeroLocus 𝒜 s' = zeroLocus 𝒜 (Ideal.span s ⊓ Ideal.span s' : Ideal A) := by
rw [zeroLocus_inf]
simp
theorem zeroLocus_mul_ideal (I J : Ideal A) :
zeroLocus 𝒜 ((I * J : Ideal A) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.mul_le
theorem zeroLocus_mul_homogeneousIdeal (I J : HomogeneousIdeal 𝒜) :
zeroLocus 𝒜 ((I * J : HomogeneousIdeal 𝒜) : Set A) = zeroLocus 𝒜 I ∪ zeroLocus 𝒜 J :=
Set.ext fun x => x.isPrime.mul_le
theorem zeroLocus_singleton_mul (f g : A) :
zeroLocus 𝒜 ({f * g} : Set A) = zeroLocus 𝒜 {f} ∪ zeroLocus 𝒜 {g} :=
Set.ext fun x => by simpa using x.isPrime.mul_mem_iff_mem_or_mem
@[simp]
theorem zeroLocus_singleton_pow (f : A) (n : ℕ) (hn : 0 < n) :
zeroLocus 𝒜 ({f ^ n} : Set A) = zeroLocus 𝒜 {f} :=
Set.ext fun x => by simpa using x.isPrime.pow_mem_iff_mem n hn
theorem sup_vanishingIdeal_le (t t' : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal t ⊔ vanishingIdeal t' ≤ vanishingIdeal (t ∩ t') := by
intro r
rw [← HomogeneousIdeal.mem_iff, HomogeneousIdeal.toIdeal_sup, mem_vanishingIdeal,
Submodule.mem_sup]
rintro ⟨f, hf, g, hg, rfl⟩ x ⟨hxt, hxt'⟩
erw [mem_vanishingIdeal] at hf hg
apply Submodule.add_mem <;> solve_by_elim
theorem mem_compl_zeroLocus_iff_not_mem {f : A} {I : ProjectiveSpectrum 𝒜} :
I ∈ (zeroLocus 𝒜 {f} : Set (ProjectiveSpectrum 𝒜))ᶜ ↔ f ∉ I.asHomogeneousIdeal := by
rw [Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]; rfl
/-- The Zariski topology on the prime spectrum of a commutative ring is defined via the closed sets
of the topology: they are exactly those sets that are the zero locus of a subset of the ring. -/
instance zariskiTopology : TopologicalSpace (ProjectiveSpectrum 𝒜) :=
TopologicalSpace.ofClosed (Set.range (ProjectiveSpectrum.zeroLocus 𝒜)) ⟨Set.univ, by simp⟩
(by
intro Zs h
rw [Set.sInter_eq_iInter]
let f : Zs → Set _ := fun i => Classical.choose (h i.2)
have H : (Set.iInter fun i ↦ zeroLocus 𝒜 (f i)) ∈ Set.range (zeroLocus 𝒜) :=
⟨_, zeroLocus_iUnion 𝒜 _⟩
convert H using 2
funext i
exact (Classical.choose_spec (h i.2)).symm)
(by
rintro _ ⟨s, rfl⟩ _ ⟨t, rfl⟩
exact ⟨_, (union_zeroLocus 𝒜 s t).symm⟩)
/-- The underlying topology of `Proj` is the projective spectrum of graded ring `A`. -/
def top : TopCat :=
TopCat.of (ProjectiveSpectrum 𝒜)
theorem isOpen_iff (U : Set (ProjectiveSpectrum 𝒜)) : IsOpen U ↔ ∃ s, Uᶜ = zeroLocus 𝒜 s := by
simp only [@eq_comm _ Uᶜ]; rfl
theorem isClosed_iff_zeroLocus (Z : Set (ProjectiveSpectrum 𝒜)) :
IsClosed Z ↔ ∃ s, Z = zeroLocus 𝒜 s := by rw [← isOpen_compl_iff, isOpen_iff, compl_compl]
theorem isClosed_zeroLocus (s : Set A) : IsClosed (zeroLocus 𝒜 s) := by
rw [isClosed_iff_zeroLocus]
exact ⟨s, rfl⟩
theorem zeroLocus_vanishingIdeal_eq_closure (t : Set (ProjectiveSpectrum 𝒜)) :
zeroLocus 𝒜 (vanishingIdeal t : Set A) = closure t := by
apply Set.Subset.antisymm
· rintro x hx t' ⟨ht', ht⟩
obtain ⟨fs, rfl⟩ : ∃ s, t' = zeroLocus 𝒜 s := by rwa [isClosed_iff_zeroLocus] at ht'
rw [subset_zeroLocus_iff_subset_vanishingIdeal] at ht
exact Set.Subset.trans ht hx
· rw [(isClosed_zeroLocus _ _).closure_subset_iff]
exact subset_zeroLocus_vanishingIdeal 𝒜 t
theorem vanishingIdeal_closure (t : Set (ProjectiveSpectrum 𝒜)) :
vanishingIdeal (closure t) = vanishingIdeal t := by
have := (gc_ideal 𝒜).u_l_u_eq_u t
ext1
erw [zeroLocus_vanishingIdeal_eq_closure 𝒜 t] at this
exact this
section BasicOpen
/-- `basicOpen r` is the open subset containing all prime ideals not containing `r`. -/
def basicOpen (r : A) : TopologicalSpace.Opens (ProjectiveSpectrum 𝒜) where
carrier := { x | r ∉ x.asHomogeneousIdeal }
is_open' := ⟨{r}, Set.ext fun _ => Set.singleton_subset_iff.trans <| Classical.not_not.symm⟩
@[simp]
theorem mem_basicOpen (f : A) (x : ProjectiveSpectrum 𝒜) :
x ∈ basicOpen 𝒜 f ↔ f ∉ x.asHomogeneousIdeal :=
Iff.rfl
theorem mem_coe_basicOpen (f : A) (x : ProjectiveSpectrum 𝒜) :
x ∈ (↑(basicOpen 𝒜 f) : Set (ProjectiveSpectrum 𝒜)) ↔ f ∉ x.asHomogeneousIdeal :=
Iff.rfl
theorem isOpen_basicOpen {a : A} : IsOpen (basicOpen 𝒜 a : Set (ProjectiveSpectrum 𝒜)) :=
(basicOpen 𝒜 a).isOpen
@[simp]
theorem basicOpen_eq_zeroLocus_compl (r : A) :
(basicOpen 𝒜 r : Set (ProjectiveSpectrum 𝒜)) = (zeroLocus 𝒜 {r})ᶜ :=
Set.ext fun x => by simp only [Set.mem_compl_iff, mem_zeroLocus, Set.singleton_subset_iff]; rfl
@[simp]
theorem basicOpen_one : basicOpen 𝒜 (1 : A) = ⊤ :=
TopologicalSpace.Opens.ext <| by simp
@[simp]
theorem basicOpen_zero : basicOpen 𝒜 (0 : A) = ⊥ :=
TopologicalSpace.Opens.ext <| by simp
theorem basicOpen_mul (f g : A) : basicOpen 𝒜 (f * g) = basicOpen 𝒜 f ⊓ basicOpen 𝒜 g :=
TopologicalSpace.Opens.ext <| by simp [zeroLocus_singleton_mul]
theorem basicOpen_mul_le_left (f g : A) : basicOpen 𝒜 (f * g) ≤ basicOpen 𝒜 f := by
rw [basicOpen_mul 𝒜 f g]
exact inf_le_left
theorem basicOpen_mul_le_right (f g : A) : basicOpen 𝒜 (f * g) ≤ basicOpen 𝒜 g := by
rw [basicOpen_mul 𝒜 f g]
exact inf_le_right
@[simp]
theorem basicOpen_pow (f : A) (n : ℕ) (hn : 0 < n) : basicOpen 𝒜 (f ^ n) = basicOpen 𝒜 f :=
TopologicalSpace.Opens.ext <| by simpa using zeroLocus_singleton_pow 𝒜 f n hn
theorem basicOpen_eq_union_of_projection (f : A) :
basicOpen 𝒜 f = ⨆ i : ℕ, basicOpen 𝒜 (GradedAlgebra.proj 𝒜 i f) :=
TopologicalSpace.Opens.ext <|
Set.ext fun z => by
erw [mem_coe_basicOpen, TopologicalSpace.Opens.mem_sSup]
constructor <;> intro hz
· rcases show ∃ i, GradedAlgebra.proj 𝒜 i f ∉ z.asHomogeneousIdeal by
contrapose! hz with H
classical
rw [← DirectSum.sum_support_decompose 𝒜 f]
apply Ideal.sum_mem _ fun i _ => H i with ⟨i, hi⟩
exact ⟨basicOpen 𝒜 (GradedAlgebra.proj 𝒜 i f), ⟨i, rfl⟩, by rwa [mem_basicOpen]⟩
· obtain ⟨_, ⟨i, rfl⟩, hz⟩ := hz
exact fun rid => hz (z.1.2 i rid)
theorem isTopologicalBasis_basic_opens :
TopologicalSpace.IsTopologicalBasis
(Set.range fun r : A => (basicOpen 𝒜 r : Set (ProjectiveSpectrum 𝒜))) := by
apply TopologicalSpace.isTopologicalBasis_of_isOpen_of_nhds
· rintro _ ⟨r, rfl⟩
exact isOpen_basicOpen 𝒜
· rintro p U hp ⟨s, hs⟩
rw [← compl_compl U, Set.mem_compl_iff, ← hs, mem_zeroLocus, Set.not_subset] at hp
obtain ⟨f, hfs, hfp⟩ := hp
refine ⟨basicOpen 𝒜 f, ⟨f, rfl⟩, hfp, ?_⟩
rw [← Set.compl_subset_compl, ← hs, basicOpen_eq_zeroLocus_compl, compl_compl]
exact zeroLocus_anti_mono 𝒜 (Set.singleton_subset_iff.mpr hfs)
end BasicOpen
section Order
/-!
## The specialization order
We endow `ProjectiveSpectrum 𝒜` with a partial order,
where `x ≤ y` if and only if `y ∈ closure {x}`.
-/
instance : PartialOrder (ProjectiveSpectrum 𝒜) :=
PartialOrder.lift asHomogeneousIdeal fun ⟨_, _, _⟩ ⟨_, _, _⟩ => by simp only [mk.injEq, imp_self]
@[simp]
theorem as_ideal_le_as_ideal (x y : ProjectiveSpectrum 𝒜) :
x.asHomogeneousIdeal ≤ y.asHomogeneousIdeal ↔ x ≤ y :=
Iff.rfl
@[simp]
theorem as_ideal_lt_as_ideal (x y : ProjectiveSpectrum 𝒜) :
x.asHomogeneousIdeal < y.asHomogeneousIdeal ↔ x < y :=
Iff.rfl
theorem le_iff_mem_closure (x y : ProjectiveSpectrum 𝒜) :
x ≤ y ↔ y ∈ closure ({x} : Set (ProjectiveSpectrum 𝒜)) := by
rw [← as_ideal_le_as_ideal, ← zeroLocus_vanishingIdeal_eq_closure, mem_zeroLocus,
vanishingIdeal_singleton]
simp only [as_ideal_le_as_ideal, coe_subset_coe]
end Order
end ProjectiveSpectrum
|
AlgebraicGeometry\Sites\BigZariski.lean | /-
Copyright (c) 2023 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou, Adam Topaz
-/
import Mathlib.AlgebraicGeometry.Pullbacks
import Mathlib.CategoryTheory.Sites.Pretopology
import Mathlib.CategoryTheory.Sites.Canonical
/-!
# The big Zariski site of schemes
In this file, we define the Zariski topology, as a Grothendieck topology on the
category `Scheme.{u}`: this is `Scheme.zariskiTopology.{u}`. If `X : Scheme.{u}`,
the Zariski topology on `Over X` can be obtained as `Scheme.zariskiTopology.over X`
(see `CategoryTheory.Sites.Over`.).
TODO:
* If `Y : Scheme.{u}`, define a continuous functor from the category of opens of `Y`
to `Over Y`, and show that a presheaf on `Over Y` is a sheaf for the Zariski topology
iff its "restriction" to the topological space `Z` is a sheaf for all `Z : Over Y`.
* We should have good notions of (pre)sheaves of `Type (u + 1)` (e.g. associated
sheaf functor, pushforward, pullbacks) on `Scheme.{u}` for this topology. However,
some constructions in the `CategoryTheory.Sites` folder currently assume that
the site is a small category: this should be generalized. As a result,
this big Zariski site can considered as a test case of the Grothendieck topology API
for future applications to étale cohomology.
-/
universe v u
open CategoryTheory
namespace AlgebraicGeometry
namespace Scheme
/-- The Zariski pretopology on the category of schemes. -/
def zariskiPretopology : Pretopology (Scheme.{u}) where
coverings Y S := ∃ (U : OpenCover.{u} Y), S = Presieve.ofArrows U.obj U.map
has_isos Y X f _ := ⟨openCoverOfIsIso f, (Presieve.ofArrows_pUnit _).symm⟩
pullbacks := by
rintro Y X f _ ⟨U, rfl⟩
exact ⟨U.pullbackCover' f, (Presieve.ofArrows_pullback _ _ _).symm⟩
transitive := by
rintro X _ T ⟨U, rfl⟩ H
choose V hV using H
use U.bind (fun j => V (U.map j) ⟨j⟩)
simpa only [OpenCover.bind, ← hV] using Presieve.ofArrows_bind U.obj U.map _
(fun _ f H => (V f H).obj) (fun _ f H => (V f H).map)
/-- The Zariski topology on the category of schemes. -/
abbrev zariskiTopology : GrothendieckTopology (Scheme.{u}) :=
zariskiPretopology.toGrothendieck
lemma zariskiPretopology_openCover {Y : Scheme.{u}} (U : OpenCover.{u} Y) :
zariskiPretopology Y (Presieve.ofArrows U.obj U.map) :=
⟨U, rfl⟩
lemma zariskiTopology_openCover {Y : Scheme.{u}} (U : OpenCover.{v} Y) :
zariskiTopology Y (Sieve.generate (Presieve.ofArrows U.obj U.map)) := by
let V : OpenCover.{u} Y :=
{ J := Y
obj := fun y => U.obj (U.f y)
map := fun y => U.map (U.f y)
f := id
covers := U.covers
IsOpen := fun _ => U.IsOpen _ }
refine ⟨_, zariskiPretopology_openCover V, ?_⟩
rintro _ _ ⟨y⟩
exact ⟨_, 𝟙 _, U.map (U.f y), ⟨_⟩, by simp⟩
lemma subcanonical_zariskiTopology : Sheaf.Subcanonical zariskiTopology := by
apply Sheaf.Subcanonical.of_yoneda_isSheaf
intro X
rw [Presieve.isSheaf_pretopology]
rintro Y S ⟨𝓤,rfl⟩ x hx
let e : Y ⟶ X := 𝓤.glueMorphisms (fun j => x (𝓤.map _) (.mk _)) <| by
intro i j
apply hx
exact Limits.pullback.condition
refine ⟨e, ?_, ?_⟩
· rintro Z e ⟨j⟩
dsimp [e]
rw [𝓤.ι_glueMorphisms]
· intro e' h
apply 𝓤.hom_ext
intro j
rw [𝓤.ι_glueMorphisms]
exact h (𝓤.map j) (.mk j)
end Scheme
end AlgebraicGeometry
|
AlgebraicTopology\AlternatingFaceMapComplex.lean | /-
Copyright (c) 2021 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou, Adam Topaz, Johan Commelin
-/
import Mathlib.Algebra.Homology.Additive
import Mathlib.AlgebraicTopology.MooreComplex
import Mathlib.Algebra.BigOperators.Fin
import Mathlib.CategoryTheory.Preadditive.Opposite
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
/-!
# The alternating face map complex of a simplicial object in a preadditive category
We construct the alternating face map complex, as a
functor `alternatingFaceMapComplex : SimplicialObject C ⥤ ChainComplex C ℕ`
for any preadditive category `C`. For any simplicial object `X` in `C`,
this is the homological complex `... → X_2 → X_1 → X_0`
where the differentials are alternating sums of faces.
The dual version `alternatingCofaceMapComplex : CosimplicialObject C ⥤ CochainComplex C ℕ`
is also constructed.
We also construct the natural transformation
`inclusionOfMooreComplex : normalizedMooreComplex A ⟶ alternatingFaceMapComplex A`
when `A` is an abelian category.
## References
* https://stacks.math.columbia.edu/tag/0194
* https://ncatlab.org/nlab/show/Moore+complex
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Subobject
open CategoryTheory.Preadditive CategoryTheory.Category CategoryTheory.Idempotents
open Opposite
open Simplicial
noncomputable section
namespace AlgebraicTopology
namespace AlternatingFaceMapComplex
/-!
## Construction of the alternating face map complex
-/
variable {C : Type*} [Category C] [Preadditive C]
variable (X : SimplicialObject C)
variable (Y : SimplicialObject C)
/-- The differential on the alternating face map complex is the alternate
sum of the face maps -/
@[simp]
def objD (n : ℕ) : X _[n + 1] ⟶ X _[n] :=
∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i
/-- ## The chain complex relation `d ≫ d`
-/
theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
-- we start by expanding d ≫ d as a double sum
dsimp
simp only [comp_sum, sum_comp, ← Finset.sum_product']
-- then, we decompose the index set P into a subset S and its complement Sᶜ
let P := Fin (n + 2) × Fin (n + 3)
let S := Finset.univ.filter fun ij : P => (ij.2 : ℕ) ≤ (ij.1 : ℕ)
erw [← Finset.sum_add_sum_compl S, ← eq_neg_iff_add_eq_zero, ← Finset.sum_neg_distrib]
/- we are reduced to showing that two sums are equal, and this is obtained
by constructing a bijection φ : S -> Sᶜ, which maps (i,j) to (j,i+1),
and by comparing the terms -/
let φ : ∀ ij : P, ij ∈ S → P := fun ij hij =>
(Fin.castLT ij.2 (lt_of_le_of_lt (Finset.mem_filter.mp hij).right (Fin.is_lt ij.1)), ij.1.succ)
apply Finset.sum_bij φ
· -- φ(S) is contained in Sᶜ
intro ij hij
simp only [S, Finset.mem_univ, Finset.compl_filter, Finset.mem_filter, true_and_iff,
Fin.val_succ, Fin.coe_castLT] at hij ⊢
linarith
· -- φ : S → Sᶜ is injective
rintro ⟨i, j⟩ hij ⟨i', j'⟩ hij' h
rw [Prod.mk.inj_iff]
exact ⟨by simpa using congr_arg Prod.snd h,
by simpa [Fin.castSucc_castLT] using congr_arg Fin.castSucc (congr_arg Prod.fst h)⟩
· -- φ : S → Sᶜ is surjective
rintro ⟨i', j'⟩ hij'
simp only [S, Finset.mem_univ, forall_true_left, Prod.forall, Finset.compl_filter,
not_le, Finset.mem_filter, true_and] at hij'
refine ⟨(j'.pred <| ?_, Fin.castSucc i'), ?_, ?_⟩
· rintro rfl
simp only [Fin.val_zero, not_lt_zero'] at hij'
· simpa only [S, Finset.mem_univ, forall_true_left, Prod.forall, Finset.mem_filter,
Fin.coe_castSucc, Fin.coe_pred, true_and] using Nat.le_sub_one_of_lt hij'
· simp only [φ, Fin.castLT_castSucc, Fin.succ_pred]
· -- identification of corresponding terms in both sums
rintro ⟨i, j⟩ hij
dsimp
simp only [zsmul_comp, comp_zsmul, smul_smul, ← neg_smul]
congr 1
· simp only [Fin.val_succ, pow_add, pow_one, mul_neg, neg_neg, mul_one]
apply mul_comm
· rw [CategoryTheory.SimplicialObject.δ_comp_δ'']
simpa [S] using hij
/-!
## Construction of the alternating face map complex functor
-/
/-- The alternating face map complex, on objects -/
def obj : ChainComplex C ℕ :=
ChainComplex.of (fun n => X _[n]) (objD X) (d_squared X)
@[simp]
theorem obj_X (X : SimplicialObject C) (n : ℕ) : (AlternatingFaceMapComplex.obj X).X n = X _[n] :=
rfl
@[simp]
theorem obj_d_eq (X : SimplicialObject C) (n : ℕ) :
(AlternatingFaceMapComplex.obj X).d (n + 1) n
= ∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i := by
apply ChainComplex.of_d
variable {X} {Y}
/-- The alternating face map complex, on morphisms -/
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
ChainComplex.ofHom _ _ _ _ _ _ (fun n => f.app (op [n])) fun n => by
dsimp
rw [comp_sum, sum_comp]
refine Finset.sum_congr rfl fun _ _ => ?_
rw [comp_zsmul, zsmul_comp]
congr 1
symm
apply f.naturality
@[simp]
theorem map_f (f : X ⟶ Y) (n : ℕ) : (map f).f n = f.app (op [n]) :=
rfl
end AlternatingFaceMapComplex
variable (C : Type*) [Category C] [Preadditive C]
/-- The alternating face map complex, as a functor -/
def alternatingFaceMapComplex : SimplicialObject C ⥤ ChainComplex C ℕ where
obj := AlternatingFaceMapComplex.obj
map f := AlternatingFaceMapComplex.map f
variable {C}
@[simp]
theorem alternatingFaceMapComplex_obj_X (X : SimplicialObject C) (n : ℕ) :
((alternatingFaceMapComplex C).obj X).X n = X _[n] :=
rfl
@[simp]
theorem alternatingFaceMapComplex_obj_d (X : SimplicialObject C) (n : ℕ) :
((alternatingFaceMapComplex C).obj X).d (n + 1) n = AlternatingFaceMapComplex.objD X n := by
dsimp only [alternatingFaceMapComplex, AlternatingFaceMapComplex.obj]
apply ChainComplex.of_d
@[simp]
theorem alternatingFaceMapComplex_map_f {X Y : SimplicialObject C} (f : X ⟶ Y) (n : ℕ) :
((alternatingFaceMapComplex C).map f).f n = f.app (op [n]) :=
rfl
theorem map_alternatingFaceMapComplex {D : Type*} [Category D] [Preadditive D] (F : C ⥤ D)
[F.Additive] :
alternatingFaceMapComplex C ⋙ F.mapHomologicalComplex _ =
(SimplicialObject.whiskering C D).obj F ⋙ alternatingFaceMapComplex D := by
apply CategoryTheory.Functor.ext
· intro X Y f
ext n
simp only [Functor.comp_map, HomologicalComplex.comp_f, alternatingFaceMapComplex_map_f,
Functor.mapHomologicalComplex_map_f, HomologicalComplex.eqToHom_f, eqToHom_refl, comp_id,
id_comp, SimplicialObject.whiskering_obj_map_app]
· intro X
apply HomologicalComplex.ext
· rintro i j (rfl : j + 1 = i)
dsimp only [Functor.comp_obj]
simp only [Functor.mapHomologicalComplex_obj_d, alternatingFaceMapComplex_obj_d,
eqToHom_refl, id_comp, comp_id, AlternatingFaceMapComplex.objD, Functor.map_sum,
Functor.map_zsmul]
rfl
· ext n
rfl
theorem karoubi_alternatingFaceMapComplex_d (P : Karoubi (SimplicialObject C)) (n : ℕ) :
((AlternatingFaceMapComplex.obj (KaroubiFunctorCategoryEmbedding.obj P)).d (n + 1) n).f =
P.p.app (op [n + 1]) ≫ (AlternatingFaceMapComplex.obj P.X).d (n + 1) n := by
dsimp
simp only [AlternatingFaceMapComplex.obj_d_eq, Karoubi.sum_hom, Preadditive.comp_sum,
Karoubi.zsmul_hom, Preadditive.comp_zsmul]
rfl
namespace AlternatingFaceMapComplex
/-- The natural transformation which gives the augmentation of the alternating face map
complex attached to an augmented simplicial object. -/
def ε [Limits.HasZeroObject C] :
SimplicialObject.Augmented.drop ⋙ AlgebraicTopology.alternatingFaceMapComplex C ⟶
SimplicialObject.Augmented.point ⋙ ChainComplex.single₀ C where
app X := by
refine (ChainComplex.toSingle₀Equiv _ _).symm ?_
refine ⟨X.hom.app (op [0]), ?_⟩
dsimp
rw [alternatingFaceMapComplex_obj_d, objD, Fin.sum_univ_two, Fin.val_zero,
pow_zero, one_smul, Fin.val_one, pow_one, neg_smul, one_smul, add_comp,
neg_comp, SimplicialObject.δ_naturality, SimplicialObject.δ_naturality]
apply add_right_neg
naturality X Y f := by
apply HomologicalComplex.to_single_hom_ext
dsimp
erw [ChainComplex.toSingle₀Equiv_symm_apply_f_zero,
ChainComplex.toSingle₀Equiv_symm_apply_f_zero]
simp only [ChainComplex.single₀_map_f_zero]
exact congr_app f.w _
@[simp]
lemma ε_app_f_zero [Limits.HasZeroObject C] (X : SimplicialObject.Augmented C) :
(ε.app X).f 0 = X.hom.app (op [0]) :=
ChainComplex.toSingle₀Equiv_symm_apply_f_zero _ _
@[simp]
lemma ε_app_f_succ [Limits.HasZeroObject C] (X : SimplicialObject.Augmented C) (n : ℕ) :
(ε.app X).f (n + 1) = 0 := rfl
end AlternatingFaceMapComplex
/-!
## Construction of the natural inclusion of the normalized Moore complex
-/
variable {A : Type*} [Category A] [Abelian A]
/-- The inclusion map of the Moore complex in the alternating face map complex -/
def inclusionOfMooreComplexMap (X : SimplicialObject A) :
(normalizedMooreComplex A).obj X ⟶ (alternatingFaceMapComplex A).obj X := by
dsimp only [normalizedMooreComplex, NormalizedMooreComplex.obj,
alternatingFaceMapComplex, AlternatingFaceMapComplex.obj]
apply ChainComplex.ofHom _ _ _ _ _ _ (fun n => (NormalizedMooreComplex.objX X n).arrow)
/- we have to show the compatibility of the differentials on the alternating
face map complex with those defined on the normalized Moore complex:
we first get rid of the terms of the alternating sum that are obviously
zero on the normalized_Moore_complex -/
intro i
simp only [AlternatingFaceMapComplex.objD, comp_sum]
rw [Fin.sum_univ_succ, Fintype.sum_eq_zero]
swap
· intro j
rw [NormalizedMooreComplex.objX, comp_zsmul,
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ _ (Finset.mem_univ j)),
Category.assoc, kernelSubobject_arrow_comp, comp_zero, smul_zero]
-- finally, we study the remaining term which is induced by X.δ 0
rw [add_zero, Fin.val_zero, pow_zero, one_zsmul]
dsimp [NormalizedMooreComplex.objD, NormalizedMooreComplex.objX]
cases i <;> simp
@[simp]
theorem inclusionOfMooreComplexMap_f (X : SimplicialObject A) (n : ℕ) :
(inclusionOfMooreComplexMap X).f n = (NormalizedMooreComplex.objX X n).arrow := by
dsimp only [inclusionOfMooreComplexMap]
exact ChainComplex.ofHom_f _ _ _ _ _ _ _ _ n
variable (A)
/-- The inclusion map of the Moore complex in the alternating face map complex,
as a natural transformation -/
@[simps]
def inclusionOfMooreComplex : normalizedMooreComplex A ⟶ alternatingFaceMapComplex A where
app := inclusionOfMooreComplexMap
namespace AlternatingCofaceMapComplex
variable (X Y : CosimplicialObject C)
/-- The differential on the alternating coface map complex is the alternate
sum of the coface maps -/
@[simp]
def objD (n : ℕ) : X.obj [n] ⟶ X.obj [n + 1] :=
∑ i : Fin (n + 2), (-1 : ℤ) ^ (i : ℕ) • X.δ i
theorem d_eq_unop_d (n : ℕ) :
objD X n =
(AlternatingFaceMapComplex.objD ((cosimplicialSimplicialEquiv C).functor.obj (op X))
n).unop := by
simp only [objD, AlternatingFaceMapComplex.objD, unop_sum, unop_zsmul]
rfl
theorem d_squared (n : ℕ) : objD X n ≫ objD X (n + 1) = 0 := by
simp only [d_eq_unop_d, ← unop_comp, AlternatingFaceMapComplex.d_squared, unop_zero]
/-- The alternating coface map complex, on objects -/
def obj : CochainComplex C ℕ :=
CochainComplex.of (fun n => X.obj [n]) (objD X) (d_squared X)
variable {X} {Y}
/-- The alternating face map complex, on morphisms -/
@[simp]
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
CochainComplex.ofHom _ _ _ _ _ _ (fun n => f.app [n]) fun n => by
dsimp
rw [comp_sum, sum_comp]
refine Finset.sum_congr rfl fun x _ => ?_
rw [comp_zsmul, zsmul_comp]
congr 1
symm
apply f.naturality
end AlternatingCofaceMapComplex
variable (C)
/-- The alternating coface map complex, as a functor -/
@[simps]
def alternatingCofaceMapComplex : CosimplicialObject C ⥤ CochainComplex C ℕ where
obj := AlternatingCofaceMapComplex.obj
map f := AlternatingCofaceMapComplex.map f
end AlgebraicTopology
|
AlgebraicTopology\CechNerve.lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplicialObject
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Limits.Shapes.WidePullbacks
import Mathlib.CategoryTheory.Limits.Shapes.FiniteProducts
/-!
# The Čech Nerve
This file provides a definition of the Čech nerve associated to an arrow, provided
the base category has the correct wide pullbacks.
Several variants are provided, given `f : Arrow C`:
1. `f.cechNerve` is the Čech nerve, considered as a simplicial object in `C`.
2. `f.augmentedCechNerve` is the augmented Čech nerve, considered as an
augmented simplicial object in `C`.
3. `SimplicialObject.cechNerve` and `SimplicialObject.augmentedCechNerve` are
functorial versions of 1 resp. 2.
We end the file with a description of the Čech nerve of an arrow `X ⟶ ⊤_ C` to a terminal
object, when `C` has finite products. We call this `cechNerveTerminalFrom`. When `C` is
`G`-Set this gives us `EG` (the universal cover of the classifying space of `G`) as a simplicial
`G`-set, which is useful for group cohomology.
-/
open CategoryTheory
open CategoryTheory.Limits
noncomputable section
universe v u w
variable {C : Type u} [Category.{v} C]
namespace CategoryTheory.Arrow
variable (f : Arrow C)
variable [∀ n : ℕ, HasWidePullback.{0} f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
/-- The Čech nerve associated to an arrow. -/
@[simps]
def cechNerve : SimplicialObject C where
obj n := widePullback.{0} f.right (fun _ : Fin (n.unop.len + 1) => f.left) fun _ => f.hom
map g := WidePullback.lift (WidePullback.base _)
(fun i => WidePullback.π _ (g.unop.toOrderHom i)) (by aesop_cat)
/-- The morphism between Čech nerves associated to a morphism of arrows. -/
@[simps]
def mapCechNerve {f g : Arrow C}
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
[∀ n : ℕ, HasWidePullback g.right (fun _ : Fin (n + 1) => g.left) fun _ => g.hom] (F : f ⟶ g) :
f.cechNerve ⟶ g.cechNerve where
app n :=
WidePullback.lift (WidePullback.base _ ≫ F.right) (fun i => WidePullback.π _ i ≫ F.left)
fun j => by simp
/-- The augmented Čech nerve associated to an arrow. -/
@[simps]
def augmentedCechNerve : SimplicialObject.Augmented C where
left := f.cechNerve
right := f.right
hom := { app := fun i => WidePullback.base _ }
/-- The morphism between augmented Čech nerve associated to a morphism of arrows. -/
@[simps]
def mapAugmentedCechNerve {f g : Arrow C}
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
[∀ n : ℕ, HasWidePullback g.right (fun _ : Fin (n + 1) => g.left) fun _ => g.hom] (F : f ⟶ g) :
f.augmentedCechNerve ⟶ g.augmentedCechNerve where
left := mapCechNerve F
right := F.right
end CategoryTheory.Arrow
namespace CategoryTheory
namespace SimplicialObject
variable
[∀ (n : ℕ) (f : Arrow C), HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
/-- The Čech nerve construction, as a functor from `Arrow C`. -/
@[simps]
def cechNerve : Arrow C ⥤ SimplicialObject C where
obj f := f.cechNerve
map F := Arrow.mapCechNerve F
/-- The augmented Čech nerve construction, as a functor from `Arrow C`. -/
@[simps!]
def augmentedCechNerve : Arrow C ⥤ SimplicialObject.Augmented C where
obj f := f.augmentedCechNerve
map F := Arrow.mapAugmentedCechNerve F
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def equivalenceRightToLeft (X : SimplicialObject.Augmented C) (F : Arrow C)
(G : X ⟶ F.augmentedCechNerve) : Augmented.toArrow.obj X ⟶ F where
left := G.left.app _ ≫ WidePullback.π _ 0
right := G.right
w := by
have := G.w
apply_fun fun e => e.app (Opposite.op <| SimplexCategory.mk 0) at this
simpa using this
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def equivalenceLeftToRight (X : SimplicialObject.Augmented C) (F : Arrow C)
(G : Augmented.toArrow.obj X ⟶ F) : X ⟶ F.augmentedCechNerve where
left :=
{ app := fun x =>
Limits.WidePullback.lift (X.hom.app _ ≫ G.right)
(fun i => X.left.map (SimplexCategory.const _ x.unop i).op ≫ G.left) fun i => by
dsimp
erw [Category.assoc, Arrow.w, Augmented.toArrow_obj_hom, NatTrans.naturality_assoc,
Functor.const_obj_map, Category.id_comp]
naturality := by
intro x y f
dsimp
ext
· dsimp
simp only [WidePullback.lift_π, Category.assoc, ← X.left.map_comp_assoc]
rfl
· dsimp
simp }
right := G.right
/-- A helper function used in defining the Čech adjunction. -/
@[simps]
def cechNerveEquiv (X : SimplicialObject.Augmented C) (F : Arrow C) :
(Augmented.toArrow.obj X ⟶ F) ≃ (X ⟶ F.augmentedCechNerve) where
toFun := equivalenceLeftToRight _ _
invFun := equivalenceRightToLeft _ _
left_inv := by
intro A
ext
· dsimp
erw [WidePullback.lift_π]
nth_rw 2 [← Category.id_comp A.left]
congr 1
convert X.left.map_id _
rw [← op_id]
congr 1
ext ⟨a, ha⟩
change a < 1 at ha
change 0 = a
omega
· rfl
right_inv := by
intro A
ext x : 2
· refine WidePullback.hom_ext _ _ _ (fun j => ?_) ?_
· dsimp
simp
rfl
· simpa using congr_app A.w.symm x
· rfl
/-- The augmented Čech nerve construction is right adjoint to the `toArrow` functor. -/
abbrev cechNerveAdjunction : (Augmented.toArrow : _ ⥤ Arrow C) ⊣ augmentedCechNerve :=
Adjunction.mkOfHomEquiv
{ homEquiv := cechNerveEquiv
homEquiv_naturality_left_symm := by dsimp [cechNerveEquiv]; aesop_cat
homEquiv_naturality_right := by
dsimp [cechNerveEquiv]
-- The next three lines were not needed before leanprover/lean4#2644
intro X Y Y' f g
change equivalenceLeftToRight X Y' (f ≫ g) =
equivalenceLeftToRight X Y f ≫ augmentedCechNerve.map g
aesop_cat
}
end SimplicialObject
end CategoryTheory
namespace CategoryTheory.Arrow
variable (f : Arrow C)
variable [∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
/-- The Čech conerve associated to an arrow. -/
@[simps]
def cechConerve : CosimplicialObject C where
obj n := widePushout f.left (fun _ : Fin (n.len + 1) => f.right) fun _ => f.hom
map {x y} g := by
refine WidePushout.desc (WidePushout.head _)
(fun i => (@WidePushout.ι _ _ _ _ _ (fun _ => f.hom) (_) (g.toOrderHom i))) (fun j => ?_)
erw [← WidePushout.arrow_ι]
/-- The morphism between Čech conerves associated to a morphism of arrows. -/
@[simps]
def mapCechConerve {f g : Arrow C}
[∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
[∀ n : ℕ, HasWidePushout g.left (fun _ : Fin (n + 1) => g.right) fun _ => g.hom] (F : f ⟶ g) :
f.cechConerve ⟶ g.cechConerve where
app n := WidePushout.desc (F.left ≫ WidePushout.head _)
(fun i => F.right ≫ (by apply WidePushout.ι _ i))
(fun i => (by rw [← Arrow.w_assoc F, ← WidePushout.arrow_ι]))
/-- The augmented Čech conerve associated to an arrow. -/
@[simps]
def augmentedCechConerve : CosimplicialObject.Augmented C where
left := f.left
right := f.cechConerve
hom :=
{ app := fun i => (WidePushout.head _ : f.left ⟶ _) }
/-- The morphism between augmented Čech conerves associated to a morphism of arrows. -/
@[simps]
def mapAugmentedCechConerve {f g : Arrow C}
[∀ n : ℕ, HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
[∀ n : ℕ, HasWidePushout g.left (fun _ : Fin (n + 1) => g.right) fun _ => g.hom] (F : f ⟶ g) :
f.augmentedCechConerve ⟶ g.augmentedCechConerve where
left := F.left
right := mapCechConerve F
end CategoryTheory.Arrow
namespace CategoryTheory
namespace CosimplicialObject
variable
[∀ (n : ℕ) (f : Arrow C), HasWidePushout f.left (fun _ : Fin (n + 1) => f.right) fun _ => f.hom]
/-- The Čech conerve construction, as a functor from `Arrow C`. -/
@[simps]
def cechConerve : Arrow C ⥤ CosimplicialObject C where
obj f := f.cechConerve
map F := Arrow.mapCechConerve F
/-- The augmented Čech conerve construction, as a functor from `Arrow C`. -/
@[simps]
def augmentedCechConerve : Arrow C ⥤ CosimplicialObject.Augmented C where
obj f := f.augmentedCechConerve
map F := Arrow.mapAugmentedCechConerve F
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps]
def equivalenceLeftToRight (F : Arrow C) (X : CosimplicialObject.Augmented C)
(G : F.augmentedCechConerve ⟶ X) : F ⟶ Augmented.toArrow.obj X where
left := G.left
right := (WidePushout.ι _ 0 ≫ G.right.app (SimplexCategory.mk 0) : _)
w := by
dsimp
rw [@WidePushout.arrow_ι_assoc _ _ _ _ _ (fun (_ : Fin 1) => F.hom)
(by dsimp; infer_instance)]
exact congr_app G.w (SimplexCategory.mk 0)
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps!]
def equivalenceRightToLeft (F : Arrow C) (X : CosimplicialObject.Augmented C)
(G : F ⟶ Augmented.toArrow.obj X) : F.augmentedCechConerve ⟶ X where
left := G.left
right :=
{ app := fun x =>
Limits.WidePushout.desc (G.left ≫ X.hom.app _)
(fun i => G.right ≫ X.right.map (SimplexCategory.const _ x i))
(by
rintro j
rw [← Arrow.w_assoc G]
have t := X.hom.naturality (SimplexCategory.const (SimplexCategory.mk 0) x j)
dsimp at t ⊢
simp only [Category.id_comp] at t
rw [← t])
naturality := by
intro x y f
dsimp
ext
· dsimp
simp only [WidePushout.ι_desc_assoc, WidePushout.ι_desc]
rw [Category.assoc, ← X.right.map_comp]
rfl
· dsimp
simp only [Functor.const_obj_map, ← NatTrans.naturality, WidePushout.head_desc_assoc,
WidePushout.head_desc, Category.assoc]
erw [Category.id_comp] }
/-- A helper function used in defining the Čech conerve adjunction. -/
@[simps]
def cechConerveEquiv (F : Arrow C) (X : CosimplicialObject.Augmented C) :
(F.augmentedCechConerve ⟶ X) ≃ (F ⟶ Augmented.toArrow.obj X) where
toFun := equivalenceLeftToRight _ _
invFun := equivalenceRightToLeft _ _
left_inv := by
intro A
ext x : 2
· rfl
· refine WidePushout.hom_ext _ _ _ (fun j => ?_) ?_
· dsimp
simp only [Category.assoc, ← NatTrans.naturality A.right, Arrow.augmentedCechConerve_right,
SimplexCategory.len_mk, Arrow.cechConerve_map, colimit.ι_desc,
WidePushoutShape.mkCocone_ι_app, colimit.ι_desc_assoc]
rfl
· dsimp
rw [colimit.ι_desc]
exact congr_app A.w x
right_inv := by
intro A
ext
· rfl
· dsimp
erw [WidePushout.ι_desc]
nth_rw 2 [← Category.comp_id A.right]
congr 1
convert X.right.map_id _
ext ⟨a, ha⟩
change a < 1 at ha
change 0 = a
omega
/-- The augmented Čech conerve construction is left adjoint to the `toArrow` functor. -/
abbrev cechConerveAdjunction : augmentedCechConerve ⊣ (Augmented.toArrow : _ ⥤ Arrow C) :=
Adjunction.mkOfHomEquiv { homEquiv := cechConerveEquiv }
end CosimplicialObject
/-- Given an object `X : C`, the natural simplicial object sending `[n]` to `Xⁿ⁺¹`. -/
def cechNerveTerminalFrom {C : Type u} [Category.{v} C] [HasFiniteProducts C] (X : C) :
SimplicialObject C where
obj n := ∏ᶜ fun _ : Fin (n.unop.len + 1) => X
map f := Limits.Pi.lift fun i => Limits.Pi.π _ (f.unop.toOrderHom i)
namespace CechNerveTerminalFrom
variable [HasTerminal C] (ι : Type w)
/-- The diagram `Option ι ⥤ C` sending `none` to the terminal object and `some j` to `X`. -/
def wideCospan (X : C) : WidePullbackShape ι ⥤ C :=
WidePullbackShape.wideCospan (terminal C) (fun _ : ι => X) fun _ => terminal.from X
instance uniqueToWideCospanNone (X Y : C) : Unique (Y ⟶ (wideCospan ι X).obj none) := by
dsimp [wideCospan]
infer_instance
variable [HasFiniteProducts C]
/-- The product `Xᶥ` is the vertex of a limit cone on `wideCospan ι X`. -/
def wideCospan.limitCone [Finite ι] (X : C) : LimitCone (wideCospan ι X) where
cone :=
{ pt := ∏ᶜ fun _ : ι => X
π :=
{ app := fun X => Option.casesOn X (terminal.from _) fun i => limit.π _ ⟨i⟩
naturality := fun i j f => by
cases f
· cases i
all_goals dsimp; simp
· simp only [Functor.const_obj_obj, Functor.const_obj_map, terminal.comp_from]
subsingleton } }
isLimit :=
{ lift := fun s => Limits.Pi.lift fun j => s.π.app (some j)
fac := fun s j => Option.casesOn j (by subsingleton) fun j => limit.lift_π _ _
uniq := fun s f h => by
dsimp
ext j
dsimp only [Limits.Pi.lift]
rw [limit.lift_π]
dsimp
rw [← h (some j)] }
instance hasWidePullback [Finite ι] (X : C) :
HasWidePullback (Arrow.mk (terminal.from X)).right
(fun _ : ι => (Arrow.mk (terminal.from X)).left)
(fun _ => (Arrow.mk (terminal.from X)).hom) := by
cases nonempty_fintype ι
exact ⟨⟨wideCospan.limitCone ι X⟩⟩
-- Porting note: added to make the following definitions work
instance hasWidePullback' [Finite ι] (X : C) :
HasWidePullback (⊤_ C)
(fun _ : ι => X)
(fun _ => terminal.from X) :=
hasWidePullback _ _
-- Porting note: added to make the following definitions work
instance hasLimit_wideCospan [Finite ι] (X : C) : HasLimit (wideCospan ι X) := hasWidePullback _ _
-- Porting note: added to ease the definition of `iso`
/-- the isomorphism to the product induced by the limit cone `wideCospan ι X` -/
def wideCospan.limitIsoPi [Finite ι] (X : C) :
limit (wideCospan ι X) ≅ ∏ᶜ fun _ : ι => X :=
(IsLimit.conePointUniqueUpToIso (limit.isLimit _)
(wideCospan.limitCone ι X).2)
-- Porting note: added to ease the definition of `iso`
@[reassoc (attr := simp)]
lemma wideCospan.limitIsoPi_inv_comp_pi [Finite ι] (X : C) (j : ι) :
(wideCospan.limitIsoPi ι X).inv ≫ WidePullback.π _ j = Pi.π _ j :=
IsLimit.conePointUniqueUpToIso_inv_comp _ _ _
@[reassoc (attr := simp)]
lemma wideCospan.limitIsoPi_hom_comp_pi [Finite ι] (X : C) (j : ι) :
(wideCospan.limitIsoPi ι X).hom ≫ Pi.π _ j = WidePullback.π _ j := by
rw [← wideCospan.limitIsoPi_inv_comp_pi, Iso.hom_inv_id_assoc]
/-- Given an object `X : C`, the Čech nerve of the hom to the terminal object `X ⟶ ⊤_ C` is
naturally isomorphic to a simplicial object sending `[n]` to `Xⁿ⁺¹` (when `C` is `G-Set`, this is
`EG`, the universal cover of the classifying space of `G`. -/
def iso (X : C) : (Arrow.mk (terminal.from X)).cechNerve ≅ cechNerveTerminalFrom X :=
NatIso.ofComponents (fun m => wideCospan.limitIsoPi _ _) (fun {m n} f => by
dsimp only [cechNerveTerminalFrom, Arrow.cechNerve]
ext ⟨j⟩
simp only [Category.assoc, limit.lift_π, Fan.mk_π_app]
erw [wideCospan.limitIsoPi_hom_comp_pi,
wideCospan.limitIsoPi_hom_comp_pi, limit.lift_π]
rfl)
end CechNerveTerminalFrom
end CategoryTheory
|
AlgebraicTopology\ExtraDegeneracy.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.AlternatingFaceMapComplex
import Mathlib.AlgebraicTopology.SimplicialSet
import Mathlib.AlgebraicTopology.CechNerve
import Mathlib.Algebra.Homology.Homotopy
import Mathlib.Tactic.FinCases
/-!
# Augmented simplicial objects with an extra degeneracy
In simplicial homotopy theory, in order to prove that the connected components
of a simplicial set `X` are contractible, it suffices to construct an extra
degeneracy as it is defined in *Simplicial Homotopy Theory* by Goerss-Jardine p. 190.
It consists of a series of maps `π₀ X → X _[0]` and `X _[n] → X _[n+1]` which
behave formally like an extra degeneracy `σ (-1)`. It can be thought as a datum
associated to the augmented simplicial set `X → π₀ X`.
In this file, we adapt this definition to the case of augmented
simplicial objects in any category.
## Main definitions
- the structure `ExtraDegeneracy X` for any `X : SimplicialObject.Augmented C`
- `ExtraDegeneracy.map`: extra degeneracies are preserved by the application of any
functor `C ⥤ D`
- `SSet.Augmented.StandardSimplex.extraDegeneracy`: the standard `n`-simplex has
an extra degeneracy
- `Arrow.AugmentedCechNerve.extraDegeneracy`: the Čech nerve of a split
epimorphism has an extra degeneracy
- `ExtraDegeneracy.homotopyEquiv`: in the case the category `C` is preadditive,
if we have an extra degeneracy on `X : SimplicialObject.Augmented C`, then
the augmentation on the alternating face map complex of `X` is a homotopy
equivalence.
## References
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory Category SimplicialObject.Augmented Opposite Simplicial
namespace SimplicialObject
namespace Augmented
variable {C : Type*} [Category C]
-- Porting note: in the formulation of the axioms `s_comp_δ₀`, etc, `drop.obj X` has been
-- replaced by `X.left` in order to have lemmas with LHS/RHS in normal form
/-- The datum of an extra degeneracy is a technical condition on
augmented simplicial objects. The morphisms `s'` and `s n` of the
structure formally behave like extra degeneracies `σ (-1)`. -/
@[ext]
structure ExtraDegeneracy (X : SimplicialObject.Augmented C) where
s' : point.obj X ⟶ drop.obj X _[0]
s : ∀ n : ℕ, drop.obj X _[n] ⟶ drop.obj X _[n + 1]
s'_comp_ε : s' ≫ X.hom.app (op [0]) = 𝟙 _
s₀_comp_δ₁ : s 0 ≫ X.left.δ 1 = X.hom.app (op [0]) ≫ s'
s_comp_δ₀ : ∀ n : ℕ, s n ≫ X.left.δ 0 = 𝟙 _
s_comp_δ :
∀ (n : ℕ) (i : Fin (n + 2)), s (n + 1) ≫ X.left.δ i.succ = X.left.δ i ≫ s n
s_comp_σ :
∀ (n : ℕ) (i : Fin (n + 1)), s n ≫ X.left.σ i.succ = X.left.σ i ≫ s (n + 1)
namespace ExtraDegeneracy
attribute [reassoc] s₀_comp_δ₁ s_comp_δ s_comp_σ
attribute [reassoc (attr := simp)] s'_comp_ε s_comp_δ₀
/-- If `ed` is an extra degeneracy for `X : SimplicialObject.Augmented C` and
`F : C ⥤ D` is a functor, then `ed.map F` is an extra degeneracy for the
augmented simplicial object in `D` obtained by applying `F` to `X`. -/
def map {D : Type*} [Category D] {X : SimplicialObject.Augmented C} (ed : ExtraDegeneracy X)
(F : C ⥤ D) : ExtraDegeneracy (((whiskering _ _).obj F).obj X) where
s' := F.map ed.s'
s n := F.map (ed.s n)
s'_comp_ε := by
dsimp
erw [comp_id, ← F.map_comp, ed.s'_comp_ε, F.map_id]
s₀_comp_δ₁ := by
dsimp
erw [comp_id, ← F.map_comp, ← F.map_comp, ed.s₀_comp_δ₁]
s_comp_δ₀ n := by
dsimp
erw [← F.map_comp, ed.s_comp_δ₀, F.map_id]
s_comp_δ n i := by
dsimp
erw [← F.map_comp, ← F.map_comp, ed.s_comp_δ]
rfl
s_comp_σ n i := by
dsimp
erw [← F.map_comp, ← F.map_comp, ed.s_comp_σ]
rfl
/-- If `X` and `Y` are isomorphic augmented simplicial objects, then an extra
degeneracy for `X` gives also an extra degeneracy for `Y` -/
def ofIso {X Y : SimplicialObject.Augmented C} (e : X ≅ Y) (ed : ExtraDegeneracy X) :
ExtraDegeneracy Y where
s' := (point.mapIso e).inv ≫ ed.s' ≫ (drop.mapIso e).hom.app (op [0])
s n := (drop.mapIso e).inv.app (op [n]) ≫ ed.s n ≫ (drop.mapIso e).hom.app (op [n + 1])
s'_comp_ε := by
simpa only [Functor.mapIso, assoc, w₀, ed.s'_comp_ε_assoc] using (point.mapIso e).inv_hom_id
s₀_comp_δ₁ := by
have h := w₀ e.inv
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.δ_naturality, ed.s₀_comp_δ₁_assoc, reassoc_of% h]
s_comp_δ₀ n := by
have h := ed.s_comp_δ₀
dsimp at h ⊢
simpa only [assoc, ← SimplicialObject.δ_naturality, reassoc_of% h] using
congr_app (drop.mapIso e).inv_hom_id (op [n])
s_comp_δ n i := by
have h := ed.s_comp_δ n i
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.δ_naturality, reassoc_of% h,
← SimplicialObject.δ_naturality_assoc]
s_comp_σ n i := by
have h := ed.s_comp_σ n i
dsimp at h ⊢
simp only [assoc, ← SimplicialObject.σ_naturality, reassoc_of% h,
← SimplicialObject.σ_naturality_assoc]
end ExtraDegeneracy
end Augmented
end SimplicialObject
namespace SSet
namespace Augmented
namespace StandardSimplex
/-- When `[HasZero X]`, the shift of a map `f : Fin n → X`
is a map `Fin (n+1) → X` which sends `0` to `0` and `i.succ` to `f i`. -/
def shiftFun {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) (i : Fin (n + 1)) : X :=
dite (i = 0) (fun _ => 0) fun h => f (i.pred h)
@[simp]
theorem shiftFun_0 {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) : shiftFun f 0 = 0 :=
rfl
@[simp]
theorem shiftFun_succ {n : ℕ} {X : Type*} [Zero X] (f : Fin n → X) (i : Fin n) :
shiftFun f i.succ = f i := by
dsimp [shiftFun]
split_ifs with h
· exfalso
simp only [Fin.ext_iff, Fin.val_succ, Fin.val_zero, add_eq_zero, and_false] at h
· simp only [Fin.pred_succ]
/-- The shift of a morphism `f : [n] → Δ` in `SimplexCategory` corresponds to
the monotone map which sends `0` to `0` and `i.succ` to `f.toOrderHom i`. -/
@[simp]
def shift {n : ℕ} {Δ : SimplexCategory}
(f : ([n] : SimplexCategory) ⟶ Δ) : ([n + 1] : SimplexCategory) ⟶ Δ :=
SimplexCategory.Hom.mk
{ toFun := shiftFun f.toOrderHom
monotone' := fun i₁ i₂ hi => by
by_cases h₁ : i₁ = 0
· subst h₁
simp only [shiftFun_0, Fin.zero_le]
· have h₂ : i₂ ≠ 0 := by
intro h₂
subst h₂
exact h₁ (le_antisymm hi (Fin.zero_le _))
cases' Fin.eq_succ_of_ne_zero h₁ with j₁ hj₁
cases' Fin.eq_succ_of_ne_zero h₂ with j₂ hj₂
substs hj₁ hj₂
simpa only [shiftFun_succ] using f.toOrderHom.monotone (Fin.succ_le_succ_iff.mp hi) }
open SSet.standardSimplex in
/-- The obvious extra degeneracy on the standard simplex. -/
protected noncomputable def extraDegeneracy (Δ : SimplexCategory) :
SimplicialObject.Augmented.ExtraDegeneracy (standardSimplex.obj Δ) where
s' _ := objMk (OrderHom.const _ 0)
s n f := (objEquiv _ _).symm
(shift (objEquiv _ _ f))
s'_comp_ε := by
dsimp
subsingleton
s₀_comp_δ₁ := by
dsimp
ext1 x
apply (objEquiv _ _).injective
ext j
fin_cases j
rfl
s_comp_δ₀ n := by
ext1 φ
apply (objEquiv _ _).injective
apply SimplexCategory.Hom.ext
ext i : 2
dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.standardSimplex,
objEquiv, Equiv.ulift, uliftFunctor]
simp only [shiftFun_succ]
s_comp_δ n i := by
ext1 φ
apply (objEquiv _ _).injective
apply SimplexCategory.Hom.ext
ext j : 2
dsimp [SimplicialObject.δ, SimplexCategory.δ, SSet.standardSimplex,
objEquiv, Equiv.ulift, uliftFunctor]
by_cases h : j = 0
· subst h
simp only [Fin.succ_succAbove_zero, shiftFun_0]
· obtain ⟨_, rfl⟩ := Fin.eq_succ_of_ne_zero <| h
simp only [Fin.succ_succAbove_succ, shiftFun_succ, Function.comp_apply,
Fin.succAboveOrderEmb_apply]
s_comp_σ n i := by
ext1 φ
apply (objEquiv _ _).injective
apply SimplexCategory.Hom.ext
ext j : 2
dsimp [SimplicialObject.σ, SimplexCategory.σ, SSet.standardSimplex,
objEquiv, Equiv.ulift, uliftFunctor]
by_cases h : j = 0
· subst h
rfl
· obtain ⟨_, rfl⟩ := Fin.eq_succ_of_ne_zero h
simp only [Fin.succ_predAbove_succ, shiftFun_succ, Function.comp_apply]
instance nonempty_extraDegeneracy_standardSimplex (Δ : SimplexCategory) :
Nonempty (SimplicialObject.Augmented.ExtraDegeneracy (standardSimplex.obj Δ)) :=
⟨StandardSimplex.extraDegeneracy Δ⟩
end StandardSimplex
end Augmented
end SSet
namespace CategoryTheory
open Limits
namespace Arrow
namespace AugmentedCechNerve
variable {C : Type*} [Category C] (f : Arrow C)
[∀ n : ℕ, HasWidePullback f.right (fun _ : Fin (n + 1) => f.left) fun _ => f.hom]
(S : SplitEpi f.hom)
/-- The extra degeneracy map on the Čech nerve of a split epi. It is
given on the `0`-projection by the given section of the split epi,
and by shifting the indices on the other projections. -/
noncomputable def ExtraDegeneracy.s (n : ℕ) :
f.cechNerve.obj (op [n]) ⟶ f.cechNerve.obj (op [n + 1]) :=
WidePullback.lift (WidePullback.base _)
(fun i =>
dite (i = 0)
(fun _ => WidePullback.base _ ≫ S.section_)
(fun h => WidePullback.π _ (i.pred h)))
fun i => by
dsimp
split_ifs with h
· subst h
simp only [assoc, SplitEpi.id, comp_id]
· simp only [WidePullback.π_arrow]
-- Porting note (#11119): @[simp] removed as the linter complains the LHS is not in normal form
theorem ExtraDegeneracy.s_comp_π_0 (n : ℕ) :
ExtraDegeneracy.s f S n ≫ WidePullback.π _ 0 =
@WidePullback.base _ _ _ f.right (fun _ : Fin (n + 1) => f.left) (fun _ => f.hom) _ ≫
S.section_ := by
dsimp [ExtraDegeneracy.s]
simp only [WidePullback.lift_π]
rfl
-- Porting note (#11119): @[simp] removed as the linter complains the LHS is not in normal form
theorem ExtraDegeneracy.s_comp_π_succ (n : ℕ) (i : Fin (n + 1)) :
ExtraDegeneracy.s f S n ≫ WidePullback.π _ i.succ =
@WidePullback.π _ _ _ f.right (fun _ : Fin (n + 1) => f.left) (fun _ => f.hom) _ i := by
dsimp [ExtraDegeneracy.s]
simp only [WidePullback.lift_π]
split_ifs with h
· simp only [Fin.ext_iff, Fin.val_succ, Fin.val_zero, add_eq_zero, and_false] at h
· simp only [Fin.pred_succ]
-- Porting note (#11119): @[simp] removed as the linter complains the LHS is not in normal form
theorem ExtraDegeneracy.s_comp_base (n : ℕ) :
ExtraDegeneracy.s f S n ≫ WidePullback.base _ = WidePullback.base _ := by
apply WidePullback.lift_base
/-- The augmented Čech nerve associated to a split epimorphism has an extra degeneracy. -/
noncomputable def extraDegeneracy :
SimplicialObject.Augmented.ExtraDegeneracy f.augmentedCechNerve where
s' := S.section_ ≫ WidePullback.lift f.hom (fun _ => 𝟙 _) fun i => by rw [id_comp]
s n := ExtraDegeneracy.s f S n
s'_comp_ε := by
dsimp
simp only [augmentedCechNerve_hom_app, assoc, WidePullback.lift_base, SplitEpi.id]
s₀_comp_δ₁ := by
dsimp [cechNerve, SimplicialObject.δ, SimplexCategory.δ]
ext j
· fin_cases j
simpa only [assoc, WidePullback.lift_π, comp_id] using ExtraDegeneracy.s_comp_π_0 f S 0
· simpa only [assoc, WidePullback.lift_base, SplitEpi.id, comp_id] using
ExtraDegeneracy.s_comp_base f S 0
s_comp_δ₀ n := by
dsimp [cechNerve, SimplicialObject.δ, SimplexCategory.δ]
ext j
· simpa only [assoc, WidePullback.lift_π, id_comp] using ExtraDegeneracy.s_comp_π_succ f S n j
· simpa only [assoc, WidePullback.lift_base, id_comp] using ExtraDegeneracy.s_comp_base f S n
s_comp_δ n i := by
dsimp [cechNerve, SimplicialObject.δ, SimplexCategory.δ]
ext j
· simp only [assoc, WidePullback.lift_π]
by_cases h : j = 0
· subst h
erw [Fin.succ_succAbove_zero, ExtraDegeneracy.s_comp_π_0, ExtraDegeneracy.s_comp_π_0]
dsimp
simp only [WidePullback.lift_base_assoc]
· cases' Fin.eq_succ_of_ne_zero h with k hk
subst hk
erw [Fin.succ_succAbove_succ, ExtraDegeneracy.s_comp_π_succ,
ExtraDegeneracy.s_comp_π_succ]
simp only [WidePullback.lift_π]
· simp only [assoc, WidePullback.lift_base]
erw [ExtraDegeneracy.s_comp_base, ExtraDegeneracy.s_comp_base]
dsimp
simp only [WidePullback.lift_base]
s_comp_σ n i := by
dsimp [cechNerve, SimplicialObject.σ, SimplexCategory.σ]
ext j
· simp only [assoc, WidePullback.lift_π]
by_cases h : j = 0
· subst h
erw [ExtraDegeneracy.s_comp_π_0, ExtraDegeneracy.s_comp_π_0]
dsimp
simp only [WidePullback.lift_base_assoc]
· cases' Fin.eq_succ_of_ne_zero h with k hk
subst hk
erw [Fin.succ_predAbove_succ, ExtraDegeneracy.s_comp_π_succ,
ExtraDegeneracy.s_comp_π_succ]
simp only [WidePullback.lift_π]
· simp only [assoc, WidePullback.lift_base]
erw [ExtraDegeneracy.s_comp_base, ExtraDegeneracy.s_comp_base]
dsimp
simp only [WidePullback.lift_base]
end AugmentedCechNerve
end Arrow
end CategoryTheory
namespace SimplicialObject
namespace Augmented
namespace ExtraDegeneracy
open AlgebraicTopology CategoryTheory Limits
/-- If `C` is a preadditive category and `X` is an augmented simplicial object
in `C` that has an extra degeneracy, then the augmentation on the alternating
face map complex of `X` is a homotopy equivalence. -/
noncomputable def homotopyEquiv {C : Type*} [Category C] [Preadditive C] [HasZeroObject C]
{X : SimplicialObject.Augmented C} (ed : ExtraDegeneracy X) :
HomotopyEquiv (AlgebraicTopology.AlternatingFaceMapComplex.obj (drop.obj X))
((ChainComplex.single₀ C).obj (point.obj X)) where
hom := AlternatingFaceMapComplex.ε.app X
inv := (ChainComplex.fromSingle₀Equiv _ _).symm (by exact ed.s')
homotopyInvHomId := Homotopy.ofEq (by
ext
dsimp
erw [AlternatingFaceMapComplex.ε_app_f_zero,
ChainComplex.fromSingle₀Equiv_symm_apply_f_zero, s'_comp_ε]
rfl)
homotopyHomInvId :=
{ hom := fun i j => by
by_cases i + 1 = j
· exact (-ed.s i) ≫ eqToHom (by congr)
· exact 0
zero := fun i j hij => by
dsimp
split_ifs with h
· exfalso
exact hij h
· simp only [eq_self_iff_true]
comm := fun i => by
rcases i with _|i
· rw [Homotopy.prevD_chainComplex, Homotopy.dNext_zero_chainComplex, zero_add]
dsimp
erw [ChainComplex.fromSingle₀Equiv_symm_apply_f_zero]
simp only [comp_id, ite_true, zero_add, ComplexShape.down_Rel, not_true,
AlternatingFaceMapComplex.obj_d_eq, Preadditive.neg_comp]
rw [Fin.sum_univ_two]
simp only [Fin.val_zero, pow_zero, one_smul, Fin.val_one, pow_one, neg_smul,
Preadditive.comp_add, s_comp_δ₀, drop_obj, Preadditive.comp_neg, neg_add_rev,
neg_neg, neg_add_cancel_right, s₀_comp_δ₁,
AlternatingFaceMapComplex.ε_app_f_zero]
· rw [Homotopy.prevD_chainComplex, Homotopy.dNext_succ_chainComplex]
dsimp
simp only [Preadditive.neg_comp,
AlternatingFaceMapComplex.obj_d_eq, comp_id, ite_true, Preadditive.comp_neg,
@Fin.sum_univ_succ _ _ (i + 2), Fin.val_zero, pow_zero, one_smul, Fin.val_succ,
Preadditive.comp_add, drop_obj, s_comp_δ₀, Preadditive.sum_comp,
Preadditive.zsmul_comp, Preadditive.comp_sum, Preadditive.comp_zsmul,
zsmul_neg, s_comp_δ, pow_add, pow_one, mul_neg, mul_one, neg_zsmul, neg_neg,
neg_add_cancel_comm_assoc, add_left_neg, zero_comp] }
end ExtraDegeneracy
end Augmented
end SimplicialObject
|
AlgebraicTopology\KanComplex.lean | /-
Copyright (c) 2023 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.AlgebraicTopology.SimplicialSet
/-!
# Kan complexes
In this file we give the definition of Kan complexes.
In `Mathlib/AlgebraicTopology/Quasicategory.lean`
we show that every Kan complex is a quasicategory.
## TODO
- Show that the singular simplicial set of a topological space is a Kan complex.
- Generalize the definition to higher universes.
Since `Λ[n, i]` is an object of `SSet.{0}`,
the current definition of a Kan complex `S`
requires `S : SSet.{0}`.
-/
namespace SSet
open CategoryTheory Simplicial
/-- A simplicial set `S` is a *Kan complex* if it satisfies the following horn-filling condition:
for every `n : ℕ` and `0 ≤ i ≤ n`,
every map of simplicial sets `σ₀ : Λ[n, i] → S` can be extended to a map `σ : Δ[n] → S`. -/
class KanComplex (S : SSet) : Prop where
hornFilling : ∀ ⦃n : ℕ⦄ ⦃i : Fin (n+1)⦄ (σ₀ : Λ[n, i] ⟶ S),
∃ σ : Δ[n] ⟶ S, σ₀ = hornInclusion n i ≫ σ
end SSet
|
AlgebraicTopology\MooreComplex.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Scott Morrison
-/
import Mathlib.Algebra.Homology.HomologicalComplex
import Mathlib.AlgebraicTopology.SimplicialObject
import Mathlib.CategoryTheory.Abelian.Basic
/-!
## Moore complex
We construct the normalized Moore complex, as a functor
`SimplicialObject C ⥤ ChainComplex C ℕ`,
for any abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
This functor is one direction of the Dold-Kan equivalence, which we're still working towards.
### References
* https://stacks.math.columbia.edu/tag/0194
* https://ncatlab.org/nlab/show/Moore+complex
-/
universe v u
noncomputable section
open CategoryTheory CategoryTheory.Limits
open Opposite
namespace AlgebraicTopology
variable {C : Type*} [Category C] [Abelian C]
attribute [local instance] Abelian.hasPullbacks
/-! The definitions in this namespace are all auxiliary definitions for `NormalizedMooreComplex`
and should usually only be accessed via that. -/
namespace NormalizedMooreComplex
open CategoryTheory.Subobject
variable (X : SimplicialObject C)
/-- The normalized Moore complex in degree `n`, as a subobject of `X n`.
-/
def objX : ∀ n : ℕ, Subobject (X.obj (op (SimplexCategory.mk n)))
| 0 => ⊤
| n + 1 => Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ)
theorem objX_zero : objX X 0 = ⊤ :=
rfl
theorem objX_add_one (n) :
objX X (n + 1) = Finset.univ.inf fun k : Fin (n + 1) => kernelSubobject (X.δ k.succ) :=
rfl
attribute [eqns objX_zero objX_add_one] objX
attribute [simp] objX
/-- The differentials in the normalized Moore complex.
-/
@[simp]
def objD : ∀ n : ℕ, (objX X (n + 1) : C) ⟶ (objX X n : C)
| 0 => Subobject.arrow _ ≫ X.δ (0 : Fin 2) ≫ inv (⊤ : Subobject _).arrow
| n + 1 => by
-- The differential is `Subobject.arrow _ ≫ X.δ (0 : Fin (n+3))`,
-- factored through the intersection of the kernels.
refine factorThru _ (arrow _ ≫ X.δ (0 : Fin (n + 3))) ?_
-- We now need to show that it factors!
-- A morphism factors through an intersection of subobjects if it factors through each.
refine (finset_inf_factors _).mpr fun i _ => ?_
-- A morphism `f` factors through the kernel of `g` exactly if `f ≫ g = 0`.
apply kernelSubobject_factors
dsimp [objX]
-- Use a simplicial identity
erw [Category.assoc, ← X.δ_comp_δ (Fin.zero_le i.succ)]
-- We can rewrite the arrow out of the intersection of all the kernels as a composition
-- of a morphism we don't care about with the arrow out of the kernel of `X.δ i.succ.succ`.
rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i.succ (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
theorem d_squared (n : ℕ) : objD X (n + 1) ≫ objD X n = 0 := by
-- It's a pity we need to do a case split here;
-- after the first erw the proofs are almost identical
rcases n with _ | n <;> dsimp [objD]
· erw [Subobject.factorThru_arrow_assoc, Category.assoc,
← X.δ_comp_δ_assoc (Fin.zero_le (0 : Fin 2)),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin 2) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
· erw [factorThru_right, factorThru_eq_zero, factorThru_arrow_assoc, Category.assoc,
← X.δ_comp_δ (Fin.zero_le (0 : Fin (n + 3))),
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ (0 : Fin (n + 3)) (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]
/-- The normalized Moore complex functor, on objects.
-/
@[simps!]
def obj (X : SimplicialObject C) : ChainComplex C ℕ :=
ChainComplex.of (fun n => (objX X n : C))
(-- the coercion here picks a representative of the subobject
objD X) (d_squared X)
variable {X} {Y : SimplicialObject C} (f : X ⟶ Y)
/-- The normalized Moore complex functor, on morphisms.
-/
@[simps!]
def map (f : X ⟶ Y) : obj X ⟶ obj Y :=
ChainComplex.ofHom _ _ _ _ _ _
(fun n => factorThru _ (arrow _ ≫ f.app (op (SimplexCategory.mk n))) (by
cases n <;> dsimp
· apply top_factors
· refine (finset_inf_factors _).mpr fun i _ => kernelSubobject_factors _ _ ?_
erw [Category.assoc, ← f.naturality,
← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ i (by simp)),
Category.assoc, kernelSubobject_arrow_comp_assoc, zero_comp, comp_zero]))
fun n => by
cases n <;> dsimp [objD, objX] <;> aesop_cat
end NormalizedMooreComplex
open NormalizedMooreComplex
variable (C)
/-- The (normalized) Moore complex of a simplicial object `X` in an abelian category `C`.
The `n`-th object is intersection of
the kernels of `X.δ i : X.obj n ⟶ X.obj (n-1)`, for `i = 1, ..., n`.
The differentials are induced from `X.δ 0`,
which maps each of these intersections of kernels to the next.
-/
@[simps]
def normalizedMooreComplex : SimplicialObject C ⥤ ChainComplex C ℕ where
obj := obj
map f := map f
-- Porting note: Why `aesop_cat` can't do `dsimp` steps?
map_id X := by ext (_ | _) <;> dsimp <;> aesop_cat
map_comp f g := by ext (_ | _) <;> apply Subobject.eq_of_comp_arrow_eq <;> dsimp <;> aesop_cat
variable {C}
-- Porting note: removed @[simp] as it is not in normal form
theorem normalizedMooreComplex_objD (X : SimplicialObject C) (n : ℕ) :
((normalizedMooreComplex C).obj X).d (n + 1) n = NormalizedMooreComplex.objD X n :=
-- Porting note: in mathlib, `apply ChainComplex.of_d` was enough
ChainComplex.of_d _ _ (d_squared X) n
end AlgebraicTopology
|
AlgebraicTopology\Nerve.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.SimplicialSet
import Mathlib.CategoryTheory.ComposableArrows
/-!
# The nerve of a category
This file provides the definition of the nerve of a category `C`,
which is a simplicial set `nerve C` (see [goerss-jardine-2009], Example I.1.4).
By definition, the type of `n`-simplices of `nerve C` is `ComposableArrows C n`,
which is the category `Fin (n + 1) ⥤ C`.
## References
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory.Category Simplicial
universe v u
namespace CategoryTheory
/-- The nerve of a category -/
@[simps]
def nerve (C : Type u) [Category.{v} C] : SSet.{max u v} where
obj Δ := ComposableArrows C (Δ.unop.len)
map f x := x.whiskerLeft (SimplexCategory.toCat.map f.unop)
instance {C : Type*} [Category C] {Δ : SimplexCategoryᵒᵖ} : Category ((nerve C).obj Δ) :=
(inferInstance : Category (ComposableArrows C (Δ.unop.len)))
/-- The nerve of a category, as a functor `Cat ⥤ SSet` -/
@[simps]
def nerveFunctor : Cat ⥤ SSet where
obj C := nerve C
map F := { app := fun Δ => (F.mapComposableArrows _).obj }
namespace Nerve
variable {C : Type*} [Category C] {n : ℕ}
lemma δ₀_eq {x : nerve C _[n + 1]} : (nerve C).δ (0 : Fin (n + 2)) x = x.δ₀ := rfl
end Nerve
end CategoryTheory
|
AlgebraicTopology\Quasicategory.lean | /-
Copyright (c) 2023 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin
-/
import Mathlib.AlgebraicTopology.KanComplex
/-!
# Quasicategories
In this file we define quasicategories,
a common model of infinity categories.
We show that every Kan complex is a quasicategory.
In `Mathlib/AlgebraicTopology/Nerve.lean`
we show (TODO) that the nerve of a category is a quasicategory.
## TODO
- Generalize the definition to higher universes.
See the corresponding TODO in `Mathlib/AlgebraicTopology/KanComplex.lean`.
-/
namespace SSet
open CategoryTheory Simplicial
/-- A simplicial set `S` is a *quasicategory* if it satisfies the following horn-filling condition:
for every `n : ℕ` and `0 < i < n`,
every map of simplicial sets `σ₀ : Λ[n, i] → S` can be extended to a map `σ : Δ[n] → S`.
[Kerodon, 003A] -/
class Quasicategory (S : SSet) : Prop where
hornFilling' : ∀ ⦃n : ℕ⦄ ⦃i : Fin (n+3)⦄ (σ₀ : Λ[n+2, i] ⟶ S)
(_h0 : 0 < i) (_hn : i < Fin.last (n+2)),
∃ σ : Δ[n+2] ⟶ S, σ₀ = hornInclusion (n+2) i ≫ σ
lemma Quasicategory.hornFilling {S : SSet} [Quasicategory S] ⦃n : ℕ⦄ ⦃i : Fin (n+1)⦄
(h0 : 0 < i) (hn : i < Fin.last n)
(σ₀ : Λ[n, i] ⟶ S) : ∃ σ : Δ[n] ⟶ S, σ₀ = hornInclusion n i ≫ σ := by
cases n using Nat.casesAuxOn with
| zero => simp [Fin.lt_iff_val_lt_val] at hn
| succ n =>
cases n using Nat.casesAuxOn with
| zero =>
simp only [Fin.lt_iff_val_lt_val, Fin.val_zero, Fin.val_last, zero_add, Nat.lt_one_iff] at h0 hn
simp [hn] at h0
| succ n => exact Quasicategory.hornFilling' σ₀ h0 hn
/-- Every Kan complex is a quasicategory.
[Kerodon, 003C] -/
instance (S : SSet) [KanComplex S] : Quasicategory S where
hornFilling' _ _ σ₀ _ _ := KanComplex.hornFilling σ₀
lemma quasicategory_of_filler (S : SSet)
(filler : ∀ ⦃n : ℕ⦄ ⦃i : Fin (n+3)⦄ (σ₀ : Λ[n+2, i] ⟶ S)
(_h0 : 0 < i) (_hn : i < Fin.last (n+2)),
∃ σ : S _[n+2], ∀ (j) (h : j ≠ i), S.δ j σ = σ₀.app _ (horn.face i j h)) :
Quasicategory S where
hornFilling' n i σ₀ h₀ hₙ := by
obtain ⟨σ, h⟩ := filler σ₀ h₀ hₙ
refine ⟨(S.yonedaEquiv _).symm σ, ?_⟩
apply horn.hom_ext
intro j hj
rw [← h j hj, NatTrans.comp_app]
rfl
end SSet
|
AlgebraicTopology\SimplexCategory.lean | /-
Copyright (c) 2020 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import Mathlib.Tactic.Linarith
import Mathlib.CategoryTheory.Skeletal
import Mathlib.Data.Fintype.Sort
import Mathlib.Order.Category.NonemptyFinLinOrd
import Mathlib.CategoryTheory.Functor.ReflectsIso
import Mathlib.CategoryTheory.Limits.Constructions.EpiMono
/-! # The simplex category
We construct a skeletal model of the simplex category, with objects `ℕ` and the
morphism `n ⟶ m` being the monotone maps from `Fin (n+1)` to `Fin (m+1)`.
We show that this category is equivalent to `NonemptyFinLinOrd`.
## Remarks
The definitions `SimplexCategory` and `SimplexCategory.Hom` are marked as irreducible.
We provide the following functions to work with these objects:
1. `SimplexCategory.mk` creates an object of `SimplexCategory` out of a natural number.
Use the notation `[n]` in the `Simplicial` locale.
2. `SimplexCategory.len` gives the "length" of an object of `SimplexCategory`, as a natural.
3. `SimplexCategory.Hom.mk` makes a morphism out of a monotone map between `Fin`'s.
4. `SimplexCategory.Hom.toOrderHom` gives the underlying monotone map associated to a
term of `SimplexCategory.Hom`.
-/
universe v
open CategoryTheory CategoryTheory.Limits
/-- The simplex category:
* objects are natural numbers `n : ℕ`
* morphisms from `n` to `m` are monotone functions `Fin (n+1) → Fin (m+1)`
-/
def SimplexCategory :=
ℕ
namespace SimplexCategory
section
-- Porting note: the definition of `SimplexCategory` is made irreducible below
/-- Interpret a natural number as an object of the simplex category. -/
def mk (n : ℕ) : SimplexCategory :=
n
/-- the `n`-dimensional simplex can be denoted `[n]` -/
scoped[Simplicial] notation "[" n "]" => SimplexCategory.mk n
-- TODO: Make `len` irreducible.
/-- The length of an object of `SimplexCategory`. -/
def len (n : SimplexCategory) : ℕ :=
n
@[ext]
theorem ext (a b : SimplexCategory) : a.len = b.len → a = b :=
id
attribute [irreducible] SimplexCategory
open Simplicial
@[simp]
theorem len_mk (n : ℕ) : [n].len = n :=
rfl
@[simp]
theorem mk_len (n : SimplexCategory) : ([n.len] : SimplexCategory) = n :=
rfl
/-- A recursor for `SimplexCategory`. Use it as `induction Δ using SimplexCategory.rec`. -/
protected def rec {F : SimplexCategory → Sort*} (h : ∀ n : ℕ, F [n]) : ∀ X, F X := fun n =>
h n.len
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Morphisms in the `SimplexCategory`. -/
protected def Hom (a b : SimplexCategory) :=
Fin (a.len + 1) →o Fin (b.len + 1)
namespace Hom
/-- Make a morphism in `SimplexCategory` from a monotone map of `Fin`'s. -/
def mk {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1)) : SimplexCategory.Hom a b :=
f
/-- Recover the monotone map from a morphism in the simplex category. -/
def toOrderHom {a b : SimplexCategory} (f : SimplexCategory.Hom a b) :
Fin (a.len + 1) →o Fin (b.len + 1) :=
f
theorem ext' {a b : SimplexCategory} (f g : SimplexCategory.Hom a b) :
f.toOrderHom = g.toOrderHom → f = g :=
id
attribute [irreducible] SimplexCategory.Hom
@[simp]
theorem mk_toOrderHom {a b : SimplexCategory} (f : SimplexCategory.Hom a b) : mk f.toOrderHom = f :=
rfl
@[simp]
theorem toOrderHom_mk {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1)) :
(mk f).toOrderHom = f :=
rfl
theorem mk_toOrderHom_apply {a b : SimplexCategory} (f : Fin (a.len + 1) →o Fin (b.len + 1))
(i : Fin (a.len + 1)) : (mk f).toOrderHom i = f i :=
rfl
/-- Identity morphisms of `SimplexCategory`. -/
@[simp]
def id (a : SimplexCategory) : SimplexCategory.Hom a a :=
mk OrderHom.id
/-- Composition of morphisms of `SimplexCategory`. -/
@[simp]
def comp {a b c : SimplexCategory} (f : SimplexCategory.Hom b c) (g : SimplexCategory.Hom a b) :
SimplexCategory.Hom a c :=
mk <| f.toOrderHom.comp g.toOrderHom
end Hom
instance smallCategory : SmallCategory.{0} SimplexCategory where
Hom n m := SimplexCategory.Hom n m
id m := SimplexCategory.Hom.id _
comp f g := SimplexCategory.Hom.comp g f
@[simp]
lemma id_toOrderHom (a : SimplexCategory) :
Hom.toOrderHom (𝟙 a) = OrderHom.id := rfl
@[simp]
lemma comp_toOrderHom {a b c : SimplexCategory} (f : a ⟶ b) (g : b ⟶ c) :
(f ≫ g).toOrderHom = g.toOrderHom.comp f.toOrderHom := rfl
-- Porting note: added because `Hom.ext'` is not triggered automatically
@[ext]
theorem Hom.ext {a b : SimplexCategory} (f g : a ⟶ b) :
f.toOrderHom = g.toOrderHom → f = g :=
Hom.ext' _ _
/-- The constant morphism from [0]. -/
def const (x y : SimplexCategory) (i : Fin (y.len + 1)) : x ⟶ y :=
Hom.mk <| ⟨fun _ => i, by tauto⟩
@[simp]
lemma const_eq_id : const [0] [0] 0 = 𝟙 _ := by aesop
@[simp]
lemma const_apply (x y : SimplexCategory) (i : Fin (y.len + 1)) (a : Fin (x.len + 1)) :
(const x y i).toOrderHom a = i := rfl
@[simp]
theorem const_comp (x : SimplexCategory) {y z : SimplexCategory}
(f : y ⟶ z) (i : Fin (y.len + 1)) :
const x y i ≫ f = const x z (f.toOrderHom i) :=
rfl
/-- Make a morphism `[n] ⟶ [m]` from a monotone map between fin's.
This is useful for constructing morphisms between `[n]` directly
without identifying `n` with `[n].len`.
-/
@[simp]
def mkHom {n m : ℕ} (f : Fin (n + 1) →o Fin (m + 1)) : ([n] : SimplexCategory) ⟶ [m] :=
SimplexCategory.Hom.mk f
theorem hom_zero_zero (f : ([0] : SimplexCategory) ⟶ [0]) : f = 𝟙 _ := by
ext : 3
apply @Subsingleton.elim (Fin 1)
end
open Simplicial
section Generators
/-!
## Generating maps for the simplex category
TODO: prove that the simplex category is equivalent to
one given by the following generators and relations.
-/
/-- The `i`-th face map from `[n]` to `[n+1]` -/
def δ {n} (i : Fin (n + 2)) : ([n] : SimplexCategory) ⟶ [n + 1] :=
mkHom (Fin.succAboveOrderEmb i).toOrderHom
/-- The `i`-th degeneracy map from `[n+1]` to `[n]` -/
def σ {n} (i : Fin (n + 1)) : ([n + 1] : SimplexCategory) ⟶ [n] :=
mkHom
{ toFun := Fin.predAbove i
monotone' := Fin.predAbove_right_monotone i }
/-- The generic case of the first simplicial identity -/
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
δ i ≫ δ j.succ = δ j ≫ δ (Fin.castSucc i) := by
ext k
dsimp [δ, Fin.succAbove]
rcases i with ⟨i, _⟩
rcases j with ⟨j, _⟩
rcases k with ⟨k, _⟩
split_ifs <;> · simp at * <;> omega
theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) :
δ i ≫ δ j =
δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) ≫
δ (Fin.castSucc i) := by
rw [← δ_comp_δ]
· rw [Fin.succ_pred]
· simpa only [Fin.le_iff_val_le_val, ← Nat.lt_succ_iff, Nat.succ_eq_add_one, ← Fin.val_succ,
j.succ_pred, Fin.lt_iff_val_lt_val] using H
theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) :
δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) ≫ δ j.succ =
δ j ≫ δ i := by
rw [δ_comp_δ]
· rfl
· exact H
/-- The special case of the first simplicial identity -/
@[reassoc]
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} : δ i ≫ δ (Fin.castSucc i) = δ i ≫ δ i.succ :=
(δ_comp_δ (le_refl i)).symm
@[reassoc]
theorem δ_comp_δ_self' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : j = Fin.castSucc i) :
δ i ≫ δ j = δ i ≫ δ i.succ := by
subst H
rw [δ_comp_δ_self]
/-- The second simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) :
δ (Fin.castSucc i) ≫ σ j.succ = σ j ≫ δ i := by
ext k : 3
dsimp [σ, δ]
rcases le_or_lt i k with (hik | hik)
· rw [Fin.succAbove_of_le_castSucc _ _ (Fin.castSucc_le_castSucc_iff.mpr hik),
Fin.succ_predAbove_succ, Fin.succAbove_of_le_castSucc]
rcases le_or_lt k (j.castSucc) with (hjk | hjk)
· rwa [Fin.predAbove_of_le_castSucc _ _ hjk, Fin.castSucc_castPred]
· rw [Fin.le_castSucc_iff, Fin.predAbove_of_castSucc_lt _ _ hjk, Fin.succ_pred]
exact H.trans_lt hjk
· rw [Fin.succAbove_of_castSucc_lt _ _ (Fin.castSucc_lt_castSucc_iff.mpr hik)]
have hjk := H.trans_lt' hik
rw [Fin.predAbove_of_le_castSucc _ _ (Fin.castSucc_le_castSucc_iff.mpr
(hjk.trans (Fin.castSucc_lt_succ _)).le),
Fin.predAbove_of_le_castSucc _ _ hjk.le, Fin.castPred_castSucc, Fin.succAbove_of_castSucc_lt,
Fin.castSucc_castPred]
rwa [Fin.castSucc_castPred]
/-- The first part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} :
δ (Fin.castSucc i) ≫ σ i = 𝟙 ([n] : SimplexCategory) := by
rcases i with ⟨i, hi⟩
ext ⟨j, hj⟩
simp? at hj says simp only [len_mk] at hj
dsimp [σ, δ, Fin.predAbove, Fin.succAbove]
simp only [Fin.lt_iff_val_lt_val, Fin.dite_val, Fin.ite_val, Fin.coe_pred, Fin.coe_castLT]
split_ifs
any_goals simp
all_goals omega
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) :
δ j ≫ σ i = 𝟙 ([n] : SimplexCategory) := by
subst H
rw [δ_comp_σ_self]
/-- The second part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : δ i.succ ≫ σ i = 𝟙 ([n] : SimplexCategory) := by
ext j
rcases i with ⟨i, _⟩
rcases j with ⟨j, _⟩
dsimp [δ, σ, Fin.succAbove, Fin.predAbove]
split_ifs <;> simp <;> simp at * <;> omega
@[reassoc]
theorem δ_comp_σ_succ' {n} (j : Fin (n + 2)) (i : Fin (n + 1)) (H : j = i.succ) :
δ j ≫ σ i = 𝟙 ([n] : SimplexCategory) := by
subst H
rw [δ_comp_σ_succ]
/-- The fourth simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) :
δ i.succ ≫ σ (Fin.castSucc j) = σ j ≫ δ i := by
ext k : 3
dsimp [δ, σ]
rcases le_or_lt k i with (hik | hik)
· rw [Fin.succAbove_of_castSucc_lt _ _ (Fin.castSucc_lt_succ_iff.mpr hik)]
rcases le_or_lt k (j.castSucc) with (hjk | hjk)
· rw [Fin.predAbove_of_le_castSucc _ _
(Fin.castSucc_le_castSucc_iff.mpr hjk), Fin.castPred_castSucc,
Fin.predAbove_of_le_castSucc _ _ hjk, Fin.succAbove_of_castSucc_lt, Fin.castSucc_castPred]
rw [Fin.castSucc_castPred]
exact hjk.trans_lt H
· rw [Fin.predAbove_of_castSucc_lt _ _ (Fin.castSucc_lt_castSucc_iff.mpr hjk),
Fin.predAbove_of_castSucc_lt _ _ hjk, Fin.succAbove_of_castSucc_lt,
Fin.castSucc_pred_eq_pred_castSucc]
rwa [Fin.castSucc_lt_iff_succ_le, Fin.succ_pred]
· rw [Fin.succAbove_of_le_castSucc _ _ (Fin.succ_le_castSucc_iff.mpr hik)]
have hjk := H.trans hik
rw [Fin.predAbove_of_castSucc_lt _ _ hjk, Fin.predAbove_of_castSucc_lt _ _
(Fin.castSucc_lt_succ_iff.mpr hjk.le),
Fin.pred_succ, Fin.succAbove_of_le_castSucc, Fin.succ_pred]
rwa [Fin.le_castSucc_pred_iff]
@[reassoc]
theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) :
δ i ≫ σ j = σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) ≫
δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) := by
rw [← δ_comp_σ_of_gt]
· simp
· rw [Fin.castSucc_castLT, ← Fin.succ_lt_succ_iff, Fin.succ_pred]
exact H
/-- The fifth simplicial identity -/
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
σ (Fin.castSucc i) ≫ σ j = σ j.succ ≫ σ i := by
ext k : 3
dsimp [σ]
cases' k using Fin.lastCases with k
· simp only [len_mk, Fin.predAbove_right_last]
· cases' k using Fin.cases with k
· rw [Fin.castSucc_zero, Fin.predAbove_of_le_castSucc _ 0 (Fin.zero_le _),
Fin.predAbove_of_le_castSucc _ _ (Fin.zero_le _), Fin.castPred_zero,
Fin.predAbove_of_le_castSucc _ 0 (Fin.zero_le _),
Fin.predAbove_of_le_castSucc _ _ (Fin.zero_le _)]
· rcases le_or_lt i k with (h | h)
· simp_rw [Fin.predAbove_of_castSucc_lt i.castSucc _ (Fin.castSucc_lt_castSucc_iff.mpr
(Fin.castSucc_lt_succ_iff.mpr h)), ← Fin.succ_castSucc, Fin.pred_succ,
Fin.succ_predAbove_succ]
rw [Fin.predAbove_of_castSucc_lt i _ (Fin.castSucc_lt_succ_iff.mpr _), Fin.pred_succ]
rcases le_or_lt k j with (hkj | hkj)
· rwa [Fin.predAbove_of_le_castSucc _ _ (Fin.castSucc_le_castSucc_iff.mpr hkj),
Fin.castPred_castSucc]
· rw [Fin.predAbove_of_castSucc_lt _ _ (Fin.castSucc_lt_castSucc_iff.mpr hkj),
Fin.le_pred_iff,
Fin.succ_le_castSucc_iff]
exact H.trans_lt hkj
· simp_rw [Fin.predAbove_of_le_castSucc i.castSucc _ (Fin.castSucc_le_castSucc_iff.mpr
(Fin.succ_le_castSucc_iff.mpr h)), Fin.castPred_castSucc, ← Fin.succ_castSucc,
Fin.succ_predAbove_succ]
rw [Fin.predAbove_of_le_castSucc _ k.castSucc
(Fin.castSucc_le_castSucc_iff.mpr (h.le.trans H)),
Fin.castPred_castSucc, Fin.predAbove_of_le_castSucc _ k.succ
(Fin.succ_le_castSucc_iff.mpr (H.trans_lt' h)), Fin.predAbove_of_le_castSucc _ k.succ
(Fin.succ_le_castSucc_iff.mpr h)]
/--
If `f : [m] ⟶ [n+1]` is a morphism and `j` is not in the range of `f`,
then `factor_δ f j` is a morphism `[m] ⟶ [n]` such that
`factor_δ f j ≫ δ j = f` (as witnessed by `factor_δ_spec`).
-/
def factor_δ {m n : ℕ} (f : ([m] : SimplexCategory) ⟶ [n+1]) (j : Fin (n+2)) :
([m] : SimplexCategory) ⟶ [n] :=
f ≫ σ (Fin.predAbove 0 j)
open Fin in
lemma factor_δ_spec {m n : ℕ} (f : ([m] : SimplexCategory) ⟶ [n+1]) (j : Fin (n+2))
(hj : ∀ (k : Fin (m+1)), f.toOrderHom k ≠ j) :
factor_δ f j ≫ δ j = f := by
ext k : 3
specialize hj k
dsimp [factor_δ, δ, σ]
cases' j using cases with j
· rw [predAbove_of_le_castSucc _ _ (zero_le _), castPred_zero, predAbove_of_castSucc_lt 0 _
(castSucc_zero ▸ pos_of_ne_zero hj),
zero_succAbove, succ_pred]
· rw [predAbove_of_castSucc_lt 0 _ (castSucc_zero ▸ succ_pos _), pred_succ]
rcases hj.lt_or_lt with (hj | hj)
· rw [predAbove_of_le_castSucc j _]
swap
· exact (le_castSucc_iff.mpr hj)
· rw [succAbove_of_castSucc_lt]
swap
· rwa [castSucc_lt_succ_iff, castPred_le_iff, le_castSucc_iff]
rw [castSucc_castPred]
· rw [predAbove_of_castSucc_lt]
swap
· exact (castSucc_lt_succ _).trans hj
rw [succAbove_of_le_castSucc]
swap
· rwa [succ_le_castSucc_iff, lt_pred_iff]
rw [succ_pred]
end Generators
section Skeleton
/-- The functor that exhibits `SimplexCategory` as skeleton
of `NonemptyFinLinOrd` -/
@[simps obj map]
def skeletalFunctor : SimplexCategory ⥤ NonemptyFinLinOrd where
obj a := NonemptyFinLinOrd.of (Fin (a.len + 1))
map f := f.toOrderHom
theorem skeletalFunctor.coe_map {Δ₁ Δ₂ : SimplexCategory} (f : Δ₁ ⟶ Δ₂) :
↑(skeletalFunctor.map f) = f.toOrderHom :=
rfl
theorem skeletal : Skeletal SimplexCategory := fun X Y ⟨I⟩ => by
suffices Fintype.card (Fin (X.len + 1)) = Fintype.card (Fin (Y.len + 1)) by
ext
simpa
apply Fintype.card_congr
exact ((skeletalFunctor ⋙ forget NonemptyFinLinOrd).mapIso I).toEquiv
namespace SkeletalFunctor
instance : skeletalFunctor.Full where
map_surjective f := ⟨SimplexCategory.Hom.mk f, rfl⟩
instance : skeletalFunctor.Faithful where
map_injective {_ _ f g} h := by
ext1
exact h
instance : skeletalFunctor.EssSurj where
mem_essImage X :=
⟨mk (Fintype.card X - 1 : ℕ),
⟨by
have aux : Fintype.card X = Fintype.card X - 1 + 1 :=
(Nat.succ_pred_eq_of_pos <| Fintype.card_pos_iff.mpr ⟨⊥⟩).symm
let f := monoEquivOfFin X aux
have hf := (Finset.univ.orderEmbOfFin aux).strictMono
refine
{ hom := ⟨f, hf.monotone⟩
inv := ⟨f.symm, ?_⟩
hom_inv_id := by ext1; apply f.symm_apply_apply
inv_hom_id := by ext1; apply f.apply_symm_apply }
intro i j h
show f.symm i ≤ f.symm j
rw [← hf.le_iff_le]
show f (f.symm i) ≤ f (f.symm j)
simpa only [OrderIso.apply_symm_apply]⟩⟩
noncomputable instance isEquivalence : skeletalFunctor.IsEquivalence where
end SkeletalFunctor
/-- The equivalence that exhibits `SimplexCategory` as skeleton
of `NonemptyFinLinOrd` -/
noncomputable def skeletalEquivalence : SimplexCategory ≌ NonemptyFinLinOrd :=
Functor.asEquivalence skeletalFunctor
end Skeleton
/-- `SimplexCategory` is a skeleton of `NonemptyFinLinOrd`.
-/
lemma isSkeletonOf :
IsSkeletonOf NonemptyFinLinOrd SimplexCategory skeletalFunctor where
skel := skeletal
eqv := SkeletalFunctor.isEquivalence
/-- The truncated simplex category. -/
def Truncated (n : ℕ) :=
FullSubcategory fun a : SimplexCategory => a.len ≤ n
instance (n : ℕ) : SmallCategory.{0} (Truncated n) :=
FullSubcategory.category _
namespace Truncated
instance {n} : Inhabited (Truncated n) :=
⟨⟨[0], by simp⟩⟩
/-- The fully faithful inclusion of the truncated simplex category into the usual
simplex category.
-/
def inclusion {n : ℕ} : SimplexCategory.Truncated n ⥤ SimplexCategory :=
fullSubcategoryInclusion _
instance (n : ℕ) : (inclusion : Truncated n ⥤ _).Full := FullSubcategory.full _
instance (n : ℕ) : (inclusion : Truncated n ⥤ _).Faithful := FullSubcategory.faithful _
end Truncated
section Concrete
instance : ConcreteCategory.{0} SimplexCategory where
forget :=
{ obj := fun i => Fin (i.len + 1)
map := fun f => f.toOrderHom }
forget_faithful := ⟨fun h => by ext : 2; exact h⟩
end Concrete
section EpiMono
/-- A morphism in `SimplexCategory` is a monomorphism precisely when it is an injective function
-/
theorem mono_iff_injective {n m : SimplexCategory} {f : n ⟶ m} :
Mono f ↔ Function.Injective f.toOrderHom := by
rw [← Functor.mono_map_iff_mono skeletalEquivalence.functor]
dsimp only [skeletalEquivalence, Functor.asEquivalence_functor]
simp only [skeletalFunctor_obj, skeletalFunctor_map,
NonemptyFinLinOrd.mono_iff_injective, NonemptyFinLinOrd.coe_of]
/-- A morphism in `SimplexCategory` is an epimorphism if and only if it is a surjective function
-/
theorem epi_iff_surjective {n m : SimplexCategory} {f : n ⟶ m} :
Epi f ↔ Function.Surjective f.toOrderHom := by
rw [← Functor.epi_map_iff_epi skeletalEquivalence.functor]
dsimp only [skeletalEquivalence, Functor.asEquivalence_functor]
simp only [skeletalFunctor_obj, skeletalFunctor_map,
NonemptyFinLinOrd.epi_iff_surjective, NonemptyFinLinOrd.coe_of]
/-- A monomorphism in `SimplexCategory` must increase lengths-/
theorem len_le_of_mono {x y : SimplexCategory} {f : x ⟶ y} : Mono f → x.len ≤ y.len := by
intro hyp_f_mono
have f_inj : Function.Injective f.toOrderHom.toFun := mono_iff_injective.1 hyp_f_mono
simpa using Fintype.card_le_of_injective f.toOrderHom.toFun f_inj
theorem le_of_mono {n m : ℕ} {f : ([n] : SimplexCategory) ⟶ [m]} : CategoryTheory.Mono f → n ≤ m :=
len_le_of_mono
/-- An epimorphism in `SimplexCategory` must decrease lengths-/
theorem len_le_of_epi {x y : SimplexCategory} {f : x ⟶ y} : Epi f → y.len ≤ x.len := by
intro hyp_f_epi
have f_surj : Function.Surjective f.toOrderHom.toFun := epi_iff_surjective.1 hyp_f_epi
simpa using Fintype.card_le_of_surjective f.toOrderHom.toFun f_surj
theorem le_of_epi {n m : ℕ} {f : ([n] : SimplexCategory) ⟶ [m]} : Epi f → m ≤ n :=
len_le_of_epi
instance {n : ℕ} {i : Fin (n + 2)} : Mono (δ i) := by
rw [mono_iff_injective]
exact Fin.succAbove_right_injective
instance {n : ℕ} {i : Fin (n + 1)} : Epi (σ i) := by
rw [epi_iff_surjective]
intro b
simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
by_cases h : b ≤ i
· use b
-- This was not needed before leanprover/lean4#2644
dsimp
rw [Fin.predAbove_of_le_castSucc i b (by simpa only [Fin.coe_eq_castSucc] using h)]
simp only [len_mk, Fin.coe_eq_castSucc, Fin.castPred_castSucc]
· use b.succ
-- This was not needed before leanprover/lean4#2644
dsimp
rw [Fin.predAbove_of_castSucc_lt i b.succ _, Fin.pred_succ]
rw [not_le] at h
rw [Fin.lt_iff_val_lt_val] at h ⊢
simpa only [Fin.val_succ, Fin.coe_castSucc] using Nat.lt.step h
instance : (forget SimplexCategory).ReflectsIsomorphisms :=
⟨fun f hf =>
Iso.isIso_hom
{ hom := f
inv := Hom.mk
{ toFun := inv ((forget SimplexCategory).map f)
monotone' := fun y₁ y₂ h => by
by_cases h' : y₁ < y₂
· by_contra h''
apply not_le.mpr h'
convert f.toOrderHom.monotone (le_of_not_ge h'')
all_goals
exact (congr_hom (Iso.inv_hom_id
(asIso ((forget SimplexCategory).map f))) _).symm
· rw [eq_of_le_of_not_lt h h'] }
hom_inv_id := by
ext1
ext1
exact Iso.hom_inv_id (asIso ((forget _).map f))
inv_hom_id := by
ext1
ext1
exact Iso.inv_hom_id (asIso ((forget _).map f)) }⟩
theorem isIso_of_bijective {x y : SimplexCategory} {f : x ⟶ y}
(hf : Function.Bijective f.toOrderHom.toFun) : IsIso f :=
haveI : IsIso ((forget SimplexCategory).map f) := (isIso_iff_bijective _).mpr hf
isIso_of_reflects_iso f (forget SimplexCategory)
/-- An isomorphism in `SimplexCategory` induces an `OrderIso`. -/
@[simp]
def orderIsoOfIso {x y : SimplexCategory} (e : x ≅ y) : Fin (x.len + 1) ≃o Fin (y.len + 1) :=
Equiv.toOrderIso
{ toFun := e.hom.toOrderHom
invFun := e.inv.toOrderHom
left_inv := fun i => by
simpa only using congr_arg (fun φ => (Hom.toOrderHom φ) i) e.hom_inv_id
right_inv := fun i => by
simpa only using congr_arg (fun φ => (Hom.toOrderHom φ) i) e.inv_hom_id }
e.hom.toOrderHom.monotone e.inv.toOrderHom.monotone
theorem iso_eq_iso_refl {x : SimplexCategory} (e : x ≅ x) : e = Iso.refl x := by
have h : (Finset.univ : Finset (Fin (x.len + 1))).card = x.len + 1 := Finset.card_fin (x.len + 1)
have eq₁ := Finset.orderEmbOfFin_unique' h fun i => Finset.mem_univ ((orderIsoOfIso e) i)
have eq₂ :=
Finset.orderEmbOfFin_unique' h fun i => Finset.mem_univ ((orderIsoOfIso (Iso.refl x)) i)
-- Porting note: the proof was rewritten from this point in #3414 (reenableeta)
-- It could be investigated again to see if the original can be restored.
ext x
replace eq₁ := congr_arg (· x) eq₁
replace eq₂ := congr_arg (· x) eq₂.symm
simp_all
theorem eq_id_of_isIso {x : SimplexCategory} (f : x ⟶ x) [IsIso f] : f = 𝟙 _ :=
congr_arg (fun φ : _ ≅ _ => φ.hom) (iso_eq_iso_refl (asIso f))
theorem eq_σ_comp_of_not_injective' {n : ℕ} {Δ' : SimplexCategory} (θ : mk (n + 1) ⟶ Δ')
(i : Fin (n + 1)) (hi : θ.toOrderHom (Fin.castSucc i) = θ.toOrderHom i.succ) :
∃ θ' : mk n ⟶ Δ', θ = σ i ≫ θ' := by
use δ i.succ ≫ θ
ext1; ext1; ext1 x
simp only [len_mk, σ, mkHom, comp_toOrderHom, Hom.toOrderHom_mk, OrderHom.comp_coe,
OrderHom.coe_mk, Function.comp_apply]
by_cases h' : x ≤ Fin.castSucc i
· -- This was not needed before leanprover/lean4#2644
dsimp
rw [Fin.predAbove_of_le_castSucc i x h']
dsimp [δ]
erw [Fin.succAbove_of_castSucc_lt _ _ _]
· rw [Fin.castSucc_castPred]
· exact (Fin.castSucc_lt_succ_iff.mpr h')
· simp only [not_le] at h'
let y := x.pred <| by rintro (rfl : x = 0); simp at h'
have hy : x = y.succ := (Fin.succ_pred x _).symm
rw [hy] at h' ⊢
-- This was not needed before leanprover/lean4#2644
conv_rhs => dsimp
rw [Fin.predAbove_of_castSucc_lt i y.succ h', Fin.pred_succ]
by_cases h'' : y = i
· rw [h'']
refine hi.symm.trans ?_
congr 1
dsimp [δ]
erw [Fin.succAbove_of_castSucc_lt i.succ]
exact Fin.lt_succ
· dsimp [δ]
erw [Fin.succAbove_of_le_castSucc i.succ _]
simp only [Fin.lt_iff_val_lt_val, Fin.le_iff_val_le_val, Fin.val_succ, Fin.coe_castSucc,
Nat.lt_succ_iff, Fin.ext_iff] at h' h'' ⊢
cases' Nat.le.dest h' with c hc
cases c
· exfalso
simp only [Nat.zero_eq, add_zero, len_mk, Fin.coe_pred] at hc
rw [hc] at h''
exact h'' rfl
· rw [← hc]
simp only [add_le_add_iff_left, Nat.succ_eq_add_one, le_add_iff_nonneg_left, zero_le]
theorem eq_σ_comp_of_not_injective {n : ℕ} {Δ' : SimplexCategory} (θ : mk (n + 1) ⟶ Δ')
(hθ : ¬Function.Injective θ.toOrderHom) :
∃ (i : Fin (n + 1)) (θ' : mk n ⟶ Δ'), θ = σ i ≫ θ' := by
simp only [Function.Injective, exists_prop, not_forall] at hθ
-- as θ is not injective, there exists `x<y` such that `θ x = θ y`
-- and then, `θ x = θ (x+1)`
have hθ₂ : ∃ x y : Fin (n + 2), (Hom.toOrderHom θ) x = (Hom.toOrderHom θ) y ∧ x < y := by
rcases hθ with ⟨x, y, ⟨h₁, h₂⟩⟩
by_cases h : x < y
· exact ⟨x, y, ⟨h₁, h⟩⟩
· refine ⟨y, x, ⟨h₁.symm, ?_⟩⟩
rcases lt_or_eq_of_le (not_lt.mp h) with h' | h'
· exact h'
· exfalso
exact h₂ h'.symm
rcases hθ₂ with ⟨x, y, ⟨h₁, h₂⟩⟩
use x.castPred ((Fin.le_last _).trans_lt' h₂).ne
apply eq_σ_comp_of_not_injective'
apply le_antisymm
· exact θ.toOrderHom.monotone (le_of_lt (Fin.castSucc_lt_succ _))
· rw [Fin.castSucc_castPred, h₁]
exact θ.toOrderHom.monotone ((Fin.succ_castPred_le_iff _).mpr h₂)
theorem eq_comp_δ_of_not_surjective' {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
(i : Fin (n + 2)) (hi : ∀ x, θ.toOrderHom x ≠ i) : ∃ θ' : Δ ⟶ mk n, θ = θ' ≫ δ i := by
by_cases h : i < Fin.last (n + 1)
· use θ ≫ σ (Fin.castPred i h.ne)
ext1
ext1
ext1 x
simp only [len_mk, Category.assoc, comp_toOrderHom, OrderHom.comp_coe, Function.comp_apply]
by_cases h' : θ.toOrderHom x ≤ i
· simp only [σ, mkHom, Hom.toOrderHom_mk, OrderHom.coe_mk]
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [Fin.predAbove_of_le_castSucc _ _ (by rwa [Fin.castSucc_castPred])]
dsimp [δ]
erw [Fin.succAbove_of_castSucc_lt i]
· rw [Fin.castSucc_castPred]
· rw [(hi x).le_iff_lt] at h'
exact h'
· simp only [not_le] at h'
dsimp [σ, δ]
erw [Fin.predAbove_of_castSucc_lt _ _ (by rwa [Fin.castSucc_castPred])]
rw [Fin.succAbove_of_le_castSucc i _]
· erw [Fin.succ_pred]
· exact Nat.le_sub_one_of_lt (Fin.lt_iff_val_lt_val.mp h')
· obtain rfl := le_antisymm (Fin.le_last i) (not_lt.mp h)
use θ ≫ σ (Fin.last _)
ext x : 3
dsimp [δ, σ]
simp_rw [Fin.succAbove_last, Fin.predAbove_last_apply]
erw [dif_neg (hi x)]
rw [Fin.castSucc_castPred]
theorem eq_comp_δ_of_not_surjective {n : ℕ} {Δ : SimplexCategory} (θ : Δ ⟶ mk (n + 1))
(hθ : ¬Function.Surjective θ.toOrderHom) :
∃ (i : Fin (n + 2)) (θ' : Δ ⟶ mk n), θ = θ' ≫ δ i := by
cases' not_forall.mp hθ with i hi
use i
exact eq_comp_δ_of_not_surjective' θ i (not_exists.mp hi)
theorem eq_id_of_mono {x : SimplexCategory} (i : x ⟶ x) [Mono i] : i = 𝟙 _ := by
suffices IsIso i by
apply eq_id_of_isIso
apply isIso_of_bijective
dsimp
rw [Fintype.bijective_iff_injective_and_card i.toOrderHom, ← mono_iff_injective,
eq_self_iff_true, and_true_iff]
infer_instance
theorem eq_id_of_epi {x : SimplexCategory} (i : x ⟶ x) [Epi i] : i = 𝟙 _ := by
suffices IsIso i by
haveI := this
apply eq_id_of_isIso
apply isIso_of_bijective
dsimp
rw [Fintype.bijective_iff_surjective_and_card i.toOrderHom, ← epi_iff_surjective,
eq_self_iff_true, and_true_iff]
infer_instance
theorem eq_σ_of_epi {n : ℕ} (θ : mk (n + 1) ⟶ mk n) [Epi θ] : ∃ i : Fin (n + 1), θ = σ i := by
rcases eq_σ_comp_of_not_injective θ (by
by_contra h
simpa using le_of_mono (mono_iff_injective.mpr h)) with ⟨i, θ', h⟩
use i
haveI : Epi (σ i ≫ θ') := by
rw [← h]
infer_instance
haveI := CategoryTheory.epi_of_epi (σ i) θ'
rw [h, eq_id_of_epi θ', Category.comp_id]
theorem eq_δ_of_mono {n : ℕ} (θ : mk n ⟶ mk (n + 1)) [Mono θ] : ∃ i : Fin (n + 2), θ = δ i := by
rcases eq_comp_δ_of_not_surjective θ (by
by_contra h
simpa using le_of_epi (epi_iff_surjective.mpr h)) with ⟨i, θ', h⟩
use i
haveI : Mono (θ' ≫ δ i) := by
rw [← h]
infer_instance
haveI := CategoryTheory.mono_of_mono θ' (δ i)
rw [h, eq_id_of_mono θ', Category.id_comp]
theorem len_lt_of_mono {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [hi : Mono i] (hi' : Δ ≠ Δ') :
Δ'.len < Δ.len := by
rcases lt_or_eq_of_le (len_le_of_mono hi) with (h | h)
· exact h
· exfalso
exact hi' (by ext; exact h.symm)
noncomputable instance : SplitEpiCategory SimplexCategory :=
skeletalEquivalence.inverse.splitEpiCategoryImpOfIsEquivalence
instance : HasStrongEpiMonoFactorisations SimplexCategory :=
Functor.hasStrongEpiMonoFactorisations_imp_of_isEquivalence
SimplexCategory.skeletalEquivalence.inverse
instance : HasStrongEpiImages SimplexCategory :=
Limits.hasStrongEpiImages_of_hasStrongEpiMonoFactorisations
instance (Δ Δ' : SimplexCategory) (θ : Δ ⟶ Δ') : Epi (factorThruImage θ) :=
StrongEpi.epi
theorem image_eq {Δ Δ' Δ'' : SimplexCategory} {φ : Δ ⟶ Δ''} {e : Δ ⟶ Δ'} [Epi e] {i : Δ' ⟶ Δ''}
[Mono i] (fac : e ≫ i = φ) : image φ = Δ' := by
haveI := strongEpi_of_epi e
let e := image.isoStrongEpiMono e i fac
ext
exact
le_antisymm (len_le_of_epi (inferInstance : Epi e.hom))
(len_le_of_mono (inferInstance : Mono e.hom))
theorem image_ι_eq {Δ Δ'' : SimplexCategory} {φ : Δ ⟶ Δ''} {e : Δ ⟶ image φ} [Epi e]
{i : image φ ⟶ Δ''} [Mono i] (fac : e ≫ i = φ) : image.ι φ = i := by
haveI := strongEpi_of_epi e
rw [← image.isoStrongEpiMono_hom_comp_ι e i fac,
SimplexCategory.eq_id_of_isIso (image.isoStrongEpiMono e i fac).hom, Category.id_comp]
theorem factorThruImage_eq {Δ Δ'' : SimplexCategory} {φ : Δ ⟶ Δ''} {e : Δ ⟶ image φ} [Epi e]
{i : image φ ⟶ Δ''} [Mono i] (fac : e ≫ i = φ) : factorThruImage φ = e := by
rw [← cancel_mono i, fac, ← image_ι_eq fac, image.fac]
end EpiMono
/-- This functor `SimplexCategory ⥤ Cat` sends `[n]` (for `n : ℕ`)
to the category attached to the ordered set `{0, 1, ..., n}` -/
@[simps! obj map]
def toCat : SimplexCategory ⥤ Cat.{0} :=
SimplexCategory.skeletalFunctor ⋙ forget₂ NonemptyFinLinOrd LinOrd ⋙
forget₂ LinOrd Lat ⋙ forget₂ Lat PartOrd ⋙
forget₂ PartOrd Preord ⋙ preordToCat
end SimplexCategory
|
AlgebraicTopology\SimplicialObject.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplexCategory
import Mathlib.CategoryTheory.Comma.Arrow
import Mathlib.CategoryTheory.Limits.FunctorCategory
import Mathlib.CategoryTheory.Opposites
/-!
# Simplicial objects in a category.
A simplicial object in a category `C` is a `C`-valued presheaf on `SimplexCategory`.
(Similarly a cosimplicial object is functor `SimplexCategory ⥤ C`.)
Use the notation `X _[n]` in the `Simplicial` locale to obtain the `n`-th term of a
(co)simplicial object `X`, where `n` is a natural number.
-/
open Opposite
open CategoryTheory
open CategoryTheory.Limits
universe v u v' u'
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- The category of simplicial objects valued in a category `C`.
This is the category of contravariant functors from `SimplexCategory` to `C`. -/
def SimplicialObject :=
SimplexCategoryᵒᵖ ⥤ C
@[simps!]
instance : Category (SimplicialObject C) := by
dsimp only [SimplicialObject]
infer_instance
namespace SimplicialObject
set_option quotPrecheck false in
/-- `X _[n]` denotes the `n`th-term of the simplicial object X -/
scoped[Simplicial]
notation3:1000 X " _[" n "]" =>
(X : CategoryTheory.SimplicialObject _).obj (Opposite.op (SimplexCategory.mk n))
open Simplicial
instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (SimplicialObject C) := by
dsimp [SimplicialObject]
infer_instance
instance [HasLimits C] : HasLimits (SimplicialObject C) :=
⟨inferInstance⟩
instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (SimplicialObject C) := by
dsimp [SimplicialObject]
infer_instance
instance [HasColimits C] : HasColimits (SimplicialObject C) :=
⟨inferInstance⟩
variable {C}
-- Porting note (#10688): added to ease automation
@[ext]
lemma hom_ext {X Y : SimplicialObject C} (f g : X ⟶ Y)
(h : ∀ (n : SimplexCategoryᵒᵖ), f.app n = g.app n) : f = g :=
NatTrans.ext (by ext; apply h)
variable (X : SimplicialObject C)
/-- Face maps for a simplicial object. -/
def δ {n} (i : Fin (n + 2)) : X _[n + 1] ⟶ X _[n] :=
X.map (SimplexCategory.δ i).op
/-- Degeneracy maps for a simplicial object. -/
def σ {n} (i : Fin (n + 1)) : X _[n] ⟶ X _[n + 1] :=
X.map (SimplexCategory.σ i).op
/-- Isomorphisms from identities in ℕ. -/
def eqToIso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=
X.mapIso (CategoryTheory.eqToIso (by congr))
@[simp]
theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by
ext
simp [eqToIso]
/-- The generic case of the first simplicial identity -/
@[reassoc]
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
X.δ j.succ ≫ X.δ i = X.δ (Fin.castSucc i) ≫ X.δ j := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ H]
@[reassoc]
theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) :
X.δ j ≫ X.δ i =
X.δ (Fin.castSucc i) ≫
X.δ (j.pred fun (hj : j = 0) => by simp [hj, Fin.not_lt_zero] at H) := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H]
@[reassoc]
theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) :
X.δ j.succ ≫ X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) =
X.δ i ≫ X.δ j := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ'' H]
/-- The special case of the first simplicial identity -/
@[reassoc]
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} :
X.δ (Fin.castSucc i) ≫ X.δ i = X.δ i.succ ≫ X.δ i := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ_self]
@[reassoc]
theorem δ_comp_δ_self' {n} {j : Fin (n + 3)} {i : Fin (n + 2)} (H : j = Fin.castSucc i) :
X.δ j ≫ X.δ i = X.δ i.succ ≫ X.δ i := by
subst H
rw [δ_comp_δ_self]
/-- The second simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) :
X.σ j.succ ≫ X.δ (Fin.castSucc i) = X.δ i ≫ X.σ j := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_le H]
/-- The first part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ (Fin.castSucc i) = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_self, op_id, X.map_id]
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) :
X.σ i ≫ X.δ j = 𝟙 _ := by
subst H
rw [δ_comp_σ_self]
/-- The second part of the third simplicial identity -/
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : X.σ i ≫ X.δ i.succ = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_succ, op_id, X.map_id]
@[reassoc]
theorem δ_comp_σ_succ' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) :
X.σ i ≫ X.δ j = 𝟙 _ := by
subst H
rw [δ_comp_σ_succ]
/-- The fourth simplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) :
X.σ (Fin.castSucc j) ≫ X.δ i.succ = X.δ i ≫ X.σ j := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt H]
@[reassoc]
theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) :
X.σ j ≫ X.δ i =
X.δ (i.pred fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) ≫
X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt' H]
/-- The fifth simplicial identity -/
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
X.σ j ≫ X.σ (Fin.castSucc i) = X.σ i ≫ X.σ j.succ := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.σ_comp_σ H]
open Simplicial
@[reassoc (attr := simp)]
theorem δ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 2)) :
X.δ i ≫ f.app (op [n]) = f.app (op [n + 1]) ≫ X'.δ i :=
f.naturality _
@[reassoc (attr := simp)]
theorem σ_naturality {X' X : SimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ f.app (op [n + 1]) = f.app (op [n]) ≫ X'.σ i :=
f.naturality _
variable (C)
/-- Functor composition induces a functor on simplicial objects. -/
@[simps!]
def whiskering (D : Type*) [Category D] : (C ⥤ D) ⥤ SimplicialObject C ⥤ SimplicialObject D :=
whiskeringRight _ _ _
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Truncated simplicial objects. -/
def Truncated (n : ℕ) :=
(SimplexCategory.Truncated n)ᵒᵖ ⥤ C
instance {n : ℕ} : Category (Truncated C n) := by
dsimp [Truncated]
infer_instance
variable {C}
namespace Truncated
instance {n} {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (SimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasLimits C] : HasLimits (SimplicialObject.Truncated C n) :=
⟨inferInstance⟩
instance {n} {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (SimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasColimits C] : HasColimits (SimplicialObject.Truncated C n) :=
⟨inferInstance⟩
variable (C)
/-- Functor composition induces a functor on truncated simplicial objects. -/
@[simps!]
def whiskering {n} (D : Type*) [Category D] : (C ⥤ D) ⥤ Truncated C n ⥤ Truncated D n :=
whiskeringRight _ _ _
variable {C}
end Truncated
section Skeleton
/-- The skeleton functor from simplicial objects to truncated simplicial objects. -/
def sk (n : ℕ) : SimplicialObject C ⥤ SimplicialObject.Truncated C n :=
(whiskeringLeft _ _ _).obj SimplexCategory.Truncated.inclusion.op
end Skeleton
variable (C)
/-- The constant simplicial object is the constant functor. -/
abbrev const : C ⥤ SimplicialObject C :=
CategoryTheory.Functor.const _
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- The category of augmented simplicial objects, defined as a comma category. -/
def Augmented :=
Comma (𝟭 (SimplicialObject C)) (const C)
@[simps!]
instance : Category (Augmented C) := by
dsimp only [Augmented]
infer_instance
variable {C}
namespace Augmented
-- Porting note (#10688): added to ease automation
@[ext]
lemma hom_ext {X Y : Augmented C} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
Comma.hom_ext _ _ h₁ h₂
/-- Drop the augmentation. -/
@[simps!]
def drop : Augmented C ⥤ SimplicialObject C :=
Comma.fst _ _
/-- The point of the augmentation. -/
@[simps!]
def point : Augmented C ⥤ C :=
Comma.snd _ _
/-- The functor from augmented objects to arrows. -/
@[simps]
def toArrow : Augmented C ⥤ Arrow C where
obj X :=
{ left := drop.obj X _[0]
right := point.obj X
hom := X.hom.app _ }
map η :=
{ left := (drop.map η).app _
right := point.map η
w := by
dsimp
rw [← NatTrans.comp_app]
erw [η.w]
rfl }
/-- The compatibility of a morphism with the augmentation, on 0-simplices -/
@[reassoc]
theorem w₀ {X Y : Augmented C} (f : X ⟶ Y) :
(Augmented.drop.map f).app (op (SimplexCategory.mk 0)) ≫ Y.hom.app (op (SimplexCategory.mk 0)) =
X.hom.app (op (SimplexCategory.mk 0)) ≫ Augmented.point.map f := by
convert congr_app f.w (op (SimplexCategory.mk 0))
variable (C)
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simp]
def whiskeringObj (D : Type*) [Category D] (F : C ⥤ D) : Augmented C ⥤ Augmented D where
obj X :=
{ left := ((whiskering _ _).obj F).obj (drop.obj X)
right := F.obj (point.obj X)
hom := whiskerRight X.hom F ≫ (Functor.constComp _ _ _).hom }
map η :=
{ left := whiskerRight η.left _
right := F.map η.right
w := by
ext
dsimp [whiskerRight]
simp only [Category.comp_id, ← F.map_comp, ← NatTrans.comp_app]
erw [η.w]
rfl }
/-- Functor composition induces a functor on augmented simplicial objects. -/
@[simps]
def whiskering (D : Type u') [Category.{v'} D] : (C ⥤ D) ⥤ Augmented C ⥤ Augmented D where
obj := whiskeringObj _ _
map η :=
{ app := fun A =>
{ left := whiskerLeft _ η
right := η.app _
w := by
ext n
dsimp
rw [Category.comp_id, Category.comp_id, η.naturality] } }
map_comp := fun _ _ => by ext <;> rfl
variable {C}
end Augmented
/-- Augment a simplicial object with an object. -/
@[simps]
def augment (X : SimplicialObject C) (X₀ : C) (f : X _[0] ⟶ X₀)
(w : ∀ (i : SimplexCategory) (g₁ g₂ : ([0] : SimplexCategory) ⟶ i),
X.map g₁.op ≫ f = X.map g₂.op ≫ f) :
SimplicialObject.Augmented C where
left := X
right := X₀
hom :=
{ app := fun i => X.map (SimplexCategory.const _ _ 0).op ≫ f
naturality := by
intro i j g
dsimp
rw [← g.op_unop]
simpa only [← X.map_comp, ← Category.assoc, Category.comp_id, ← op_comp] using w _ _ _ }
-- Porting note: removed @[simp] as the linter complains
theorem augment_hom_zero (X : SimplicialObject C) (X₀ : C) (f : X _[0] ⟶ X₀) (w) :
(X.augment X₀ f w).hom.app (op [0]) = f := by simp
end SimplicialObject
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Cosimplicial objects. -/
def CosimplicialObject :=
SimplexCategory ⥤ C
@[simps!]
instance : Category (CosimplicialObject C) := by
dsimp only [CosimplicialObject]
infer_instance
namespace CosimplicialObject
set_option quotPrecheck false in
/-- `X _[n]` denotes the `n`th-term of the cosimplicial object X -/
scoped[Simplicial]
notation:1000 X " _[" n "]" =>
(X : CategoryTheory.CosimplicialObject _).obj (SimplexCategory.mk n)
instance {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (CosimplicialObject C) := by
dsimp [CosimplicialObject]
infer_instance
instance [HasLimits C] : HasLimits (CosimplicialObject C) :=
⟨inferInstance⟩
instance {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (CosimplicialObject C) := by
dsimp [CosimplicialObject]
infer_instance
instance [HasColimits C] : HasColimits (CosimplicialObject C) :=
⟨inferInstance⟩
variable {C}
-- Porting note (#10688): added to ease automation
@[ext]
lemma hom_ext {X Y : CosimplicialObject C} (f g : X ⟶ Y)
(h : ∀ (n : SimplexCategory), f.app n = g.app n) : f = g :=
NatTrans.ext (by ext; apply h)
variable (X : CosimplicialObject C)
open Simplicial
/-- Coface maps for a cosimplicial object. -/
def δ {n} (i : Fin (n + 2)) : X _[n] ⟶ X _[n + 1] :=
X.map (SimplexCategory.δ i)
/-- Codegeneracy maps for a cosimplicial object. -/
def σ {n} (i : Fin (n + 1)) : X _[n + 1] ⟶ X _[n] :=
X.map (SimplexCategory.σ i)
/-- Isomorphisms from identities in ℕ. -/
def eqToIso {n m : ℕ} (h : n = m) : X _[n] ≅ X _[m] :=
X.mapIso (CategoryTheory.eqToIso (by rw [h]))
@[simp]
theorem eqToIso_refl {n : ℕ} (h : n = n) : X.eqToIso h = Iso.refl _ := by
ext
simp [eqToIso]
/-- The generic case of the first cosimplicial identity -/
@[reassoc]
theorem δ_comp_δ {n} {i j : Fin (n + 2)} (H : i ≤ j) :
X.δ i ≫ X.δ j.succ = X.δ j ≫ X.δ (Fin.castSucc i) := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ H]
@[reassoc]
theorem δ_comp_δ' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : Fin.castSucc i < j) :
X.δ i ≫ X.δ j =
X.δ (j.pred fun (hj : j = 0) => by simp only [hj, Fin.not_lt_zero] at H) ≫
X.δ (Fin.castSucc i) := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ' H]
@[reassoc]
theorem δ_comp_δ'' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : i ≤ Fin.castSucc j) :
X.δ (i.castLT (Nat.lt_of_le_of_lt (Fin.le_iff_val_le_val.mp H) j.is_lt)) ≫ X.δ j.succ =
X.δ j ≫ X.δ i := by
dsimp [δ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_δ'' H]
/-- The special case of the first cosimplicial identity -/
@[reassoc]
theorem δ_comp_δ_self {n} {i : Fin (n + 2)} :
X.δ i ≫ X.δ (Fin.castSucc i) = X.δ i ≫ X.δ i.succ := by
dsimp [δ]
simp only [← X.map_comp, SimplexCategory.δ_comp_δ_self]
@[reassoc]
theorem δ_comp_δ_self' {n} {i : Fin (n + 2)} {j : Fin (n + 3)} (H : j = Fin.castSucc i) :
X.δ i ≫ X.δ j = X.δ i ≫ X.δ i.succ := by
subst H
rw [δ_comp_δ_self]
/-- The second cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_le {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : i ≤ Fin.castSucc j) :
X.δ (Fin.castSucc i) ≫ X.σ j.succ = X.σ j ≫ X.δ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_le H]
/-- The first part of the third cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_self {n} {i : Fin (n + 1)} : X.δ (Fin.castSucc i) ≫ X.σ i = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_self, X.map_id]
@[reassoc]
theorem δ_comp_σ_self' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = Fin.castSucc i) :
X.δ j ≫ X.σ i = 𝟙 _ := by
subst H
rw [δ_comp_σ_self]
/-- The second part of the third cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_succ {n} {i : Fin (n + 1)} : X.δ i.succ ≫ X.σ i = 𝟙 _ := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_succ, X.map_id]
@[reassoc]
theorem δ_comp_σ_succ' {n} {j : Fin (n + 2)} {i : Fin (n + 1)} (H : j = i.succ) :
X.δ j ≫ X.σ i = 𝟙 _ := by
subst H
rw [δ_comp_σ_succ]
/-- The fourth cosimplicial identity -/
@[reassoc]
theorem δ_comp_σ_of_gt {n} {i : Fin (n + 2)} {j : Fin (n + 1)} (H : Fin.castSucc j < i) :
X.δ i.succ ≫ X.σ (Fin.castSucc j) = X.σ j ≫ X.δ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.δ_comp_σ_of_gt H]
@[reassoc]
theorem δ_comp_σ_of_gt' {n} {i : Fin (n + 3)} {j : Fin (n + 2)} (H : j.succ < i) :
X.δ i ≫ X.σ j =
X.σ (j.castLT ((add_lt_add_iff_right 1).mp (lt_of_lt_of_le H i.is_le))) ≫
X.δ (i.pred <|
fun (hi : i = 0) => by simp only [Fin.not_lt_zero, hi] at H) := by
dsimp [δ, σ]
simp only [← X.map_comp, ← op_comp, SimplexCategory.δ_comp_σ_of_gt' H]
/-- The fifth cosimplicial identity -/
@[reassoc]
theorem σ_comp_σ {n} {i j : Fin (n + 1)} (H : i ≤ j) :
X.σ (Fin.castSucc i) ≫ X.σ j = X.σ j.succ ≫ X.σ i := by
dsimp [δ, σ]
simp only [← X.map_comp, SimplexCategory.σ_comp_σ H]
@[reassoc (attr := simp)]
theorem δ_naturality {X' X : CosimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 2)) :
X.δ i ≫ f.app (SimplexCategory.mk (n + 1)) = f.app (SimplexCategory.mk n) ≫ X'.δ i :=
f.naturality _
@[reassoc (attr := simp)]
theorem σ_naturality {X' X : CosimplicialObject C} (f : X ⟶ X') {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ f.app (SimplexCategory.mk n) = f.app (SimplexCategory.mk (n + 1)) ≫ X'.σ i :=
f.naturality _
variable (C)
/-- Functor composition induces a functor on cosimplicial objects. -/
@[simps!]
def whiskering (D : Type*) [Category D] : (C ⥤ D) ⥤ CosimplicialObject C ⥤ CosimplicialObject D :=
whiskeringRight _ _ _
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Truncated cosimplicial objects. -/
def Truncated (n : ℕ) :=
SimplexCategory.Truncated n ⥤ C
instance {n : ℕ} : Category (Truncated C n) := by
dsimp [Truncated]
infer_instance
variable {C}
namespace Truncated
instance {n} {J : Type v} [SmallCategory J] [HasLimitsOfShape J C] :
HasLimitsOfShape J (CosimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasLimits C] : HasLimits (CosimplicialObject.Truncated C n) :=
⟨inferInstance⟩
instance {n} {J : Type v} [SmallCategory J] [HasColimitsOfShape J C] :
HasColimitsOfShape J (CosimplicialObject.Truncated C n) := by
dsimp [Truncated]
infer_instance
instance {n} [HasColimits C] : HasColimits (CosimplicialObject.Truncated C n) :=
⟨inferInstance⟩
variable (C)
/-- Functor composition induces a functor on truncated cosimplicial objects. -/
@[simps!]
def whiskering {n} (D : Type*) [Category D] : (C ⥤ D) ⥤ Truncated C n ⥤ Truncated D n :=
whiskeringRight _ _ _
variable {C}
end Truncated
section Skeleton
/-- The skeleton functor from cosimplicial objects to truncated cosimplicial objects. -/
def sk (n : ℕ) : CosimplicialObject C ⥤ CosimplicialObject.Truncated C n :=
(whiskeringLeft _ _ _).obj SimplexCategory.Truncated.inclusion
end Skeleton
variable (C)
/-- The constant cosimplicial object. -/
abbrev const : C ⥤ CosimplicialObject C :=
CategoryTheory.Functor.const _
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Augmented cosimplicial objects. -/
def Augmented :=
Comma (const C) (𝟭 (CosimplicialObject C))
@[simps!]
instance : Category (Augmented C) := by
dsimp only [Augmented]
infer_instance
variable {C}
namespace Augmented
-- Porting note (#10688): added to ease automation
@[ext]
lemma hom_ext {X Y : Augmented C} (f g : X ⟶ Y) (h₁ : f.left = g.left) (h₂ : f.right = g.right) :
f = g :=
Comma.hom_ext _ _ h₁ h₂
/-- Drop the augmentation. -/
@[simps!]
def drop : Augmented C ⥤ CosimplicialObject C :=
Comma.snd _ _
/-- The point of the augmentation. -/
@[simps!]
def point : Augmented C ⥤ C :=
Comma.fst _ _
/-- The functor from augmented objects to arrows. -/
@[simps!]
def toArrow : Augmented C ⥤ Arrow C where
obj X :=
{ left := point.obj X
right := drop.obj X _[0]
hom := X.hom.app _ }
map η :=
{ left := point.map η
right := (drop.map η).app _
w := by
dsimp
rw [← NatTrans.comp_app]
erw [← η.w]
rfl }
variable (C)
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simp]
def whiskeringObj (D : Type*) [Category D] (F : C ⥤ D) : Augmented C ⥤ Augmented D where
obj X :=
{ left := F.obj (point.obj X)
right := ((whiskering _ _).obj F).obj (drop.obj X)
hom := (Functor.constComp _ _ _).inv ≫ whiskerRight X.hom F }
map η :=
{ left := F.map η.left
right := whiskerRight η.right _
w := by
ext
dsimp
rw [Category.id_comp, Category.id_comp, ← F.map_comp, ← F.map_comp, ← NatTrans.comp_app]
erw [← η.w]
rfl }
/-- Functor composition induces a functor on augmented cosimplicial objects. -/
@[simps]
def whiskering (D : Type u') [Category.{v'} D] : (C ⥤ D) ⥤ Augmented C ⥤ Augmented D where
obj := whiskeringObj _ _
map η :=
{ app := fun A =>
{ left := η.app _
right := whiskerLeft _ η
w := by
ext n
dsimp
rw [Category.id_comp, Category.id_comp, η.naturality] }
naturality := fun _ _ f => by ext <;> dsimp <;> simp }
variable {C}
end Augmented
open Simplicial
/-- Augment a cosimplicial object with an object. -/
@[simps]
def augment (X : CosimplicialObject C) (X₀ : C) (f : X₀ ⟶ X.obj [0])
(w : ∀ (i : SimplexCategory) (g₁ g₂ : ([0] : SimplexCategory) ⟶ i),
f ≫ X.map g₁ = f ≫ X.map g₂) : CosimplicialObject.Augmented C where
left := X₀
right := X
hom :=
{ app := fun i => f ≫ X.map (SimplexCategory.const _ _ 0)
naturality := by
intro i j g
dsimp
rw [Category.id_comp, Category.assoc, ← X.map_comp, w] }
-- Porting note: removed @[simp] as the linter complains
theorem augment_hom_zero (X : CosimplicialObject C) (X₀ : C) (f : X₀ ⟶ X.obj [0]) (w) :
(X.augment X₀ f w).hom.app [0] = f := by simp
end CosimplicialObject
/-- The anti-equivalence between simplicial objects and cosimplicial objects. -/
@[simps!]
def simplicialCosimplicialEquiv : (SimplicialObject C)ᵒᵖ ≌ CosimplicialObject Cᵒᵖ :=
Functor.leftOpRightOpEquiv _ _
/-- The anti-equivalence between cosimplicial objects and simplicial objects. -/
@[simps!]
def cosimplicialSimplicialEquiv : (CosimplicialObject C)ᵒᵖ ≌ SimplicialObject Cᵒᵖ :=
Functor.opUnopEquiv _ _
variable {C}
/-- Construct an augmented cosimplicial object in the opposite
category from an augmented simplicial object. -/
@[simps!]
def SimplicialObject.Augmented.rightOp (X : SimplicialObject.Augmented C) :
CosimplicialObject.Augmented Cᵒᵖ where
left := Opposite.op X.right
right := X.left.rightOp
hom := NatTrans.rightOp X.hom
/-- Construct an augmented simplicial object from an augmented cosimplicial
object in the opposite category. -/
@[simps!]
def CosimplicialObject.Augmented.leftOp (X : CosimplicialObject.Augmented Cᵒᵖ) :
SimplicialObject.Augmented C where
left := X.right.leftOp
right := X.left.unop
hom := NatTrans.leftOp X.hom
/-- Converting an augmented simplicial object to an augmented cosimplicial
object and back is isomorphic to the given object. -/
@[simps!]
def SimplicialObject.Augmented.rightOpLeftOpIso (X : SimplicialObject.Augmented C) :
X.rightOp.leftOp ≅ X :=
Comma.isoMk X.left.rightOpLeftOpIso (CategoryTheory.eqToIso <| by aesop_cat)
/-- Converting an augmented cosimplicial object to an augmented simplicial
object and back is isomorphic to the given object. -/
@[simps!]
def CosimplicialObject.Augmented.leftOpRightOpIso (X : CosimplicialObject.Augmented Cᵒᵖ) :
X.leftOp.rightOp ≅ X :=
Comma.isoMk (CategoryTheory.eqToIso <| by simp) X.right.leftOpRightOpIso
variable (C)
/-- A functorial version of `SimplicialObject.Augmented.rightOp`. -/
@[simps]
def simplicialToCosimplicialAugmented :
(SimplicialObject.Augmented C)ᵒᵖ ⥤ CosimplicialObject.Augmented Cᵒᵖ where
obj X := X.unop.rightOp
map f :=
{ left := f.unop.right.op
right := NatTrans.rightOp f.unop.left
w := by
ext x
dsimp
simp_rw [← op_comp]
congr 1
exact (congr_app f.unop.w (op x)).symm }
/-- A functorial version of `Cosimplicial_object.Augmented.leftOp`. -/
@[simps]
def cosimplicialToSimplicialAugmented :
CosimplicialObject.Augmented Cᵒᵖ ⥤ (SimplicialObject.Augmented C)ᵒᵖ where
obj X := Opposite.op X.leftOp
map f :=
Quiver.Hom.op <|
{ left := NatTrans.leftOp f.right
right := f.left.unop
w := by
ext x
dsimp
simp_rw [← unop_comp]
congr 1
exact (congr_app f.w (unop x)).symm }
/-- The contravariant categorical equivalence between augmented simplicial
objects and augmented cosimplicial objects in the opposite category. -/
@[simps! functor inverse]
def simplicialCosimplicialAugmentedEquiv :
(SimplicialObject.Augmented C)ᵒᵖ ≌ CosimplicialObject.Augmented Cᵒᵖ :=
Equivalence.mk (simplicialToCosimplicialAugmented _) (cosimplicialToSimplicialAugmented _)
(NatIso.ofComponents (fun X => X.unop.rightOpLeftOpIso.op) fun f => by
dsimp
rw [← f.op_unop]
simp_rw [← op_comp]
congr 1
aesop_cat)
(NatIso.ofComponents fun X => X.leftOpRightOpIso)
end CategoryTheory
|
AlgebraicTopology\SimplicialSet.lean | /-
Copyright (c) 2021 Scott Morrison. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplicialObject
import Mathlib.CategoryTheory.Limits.Shapes.Types
import Mathlib.CategoryTheory.Yoneda
import Mathlib.Data.Fin.VecNotation
import Mathlib.Tactic.FinCases
/-!
# Simplicial sets
A simplicial set is just a simplicial object in `Type`,
i.e. a `Type`-valued presheaf on the simplex category.
(One might be tempted to call these "simplicial types" when working in type-theoretic foundations,
but this would be unnecessarily confusing given the existing notion of a simplicial type in
homotopy type theory.)
We define the standard simplices `Δ[n]` as simplicial sets,
and their boundaries `∂Δ[n]` and horns `Λ[n, i]`.
(The notations are available via `Open Simplicial`.)
## Future work
There isn't yet a complete API for simplices, boundaries, and horns.
As an example, we should have a function that constructs
from a non-surjective order preserving function `Fin n → Fin n`
a morphism `Δ[n] ⟶ ∂Δ[n]`.
-/
universe v u
open CategoryTheory CategoryTheory.Limits
open Simplicial
/-- The category of simplicial sets.
This is the category of contravariant functors from
`SimplexCategory` to `Type u`. -/
def SSet : Type (u + 1) :=
SimplicialObject (Type u)
namespace SSet
instance largeCategory : LargeCategory SSet := by
dsimp only [SSet]
infer_instance
instance hasLimits : HasLimits SSet := by
dsimp only [SSet]
infer_instance
instance hasColimits : HasColimits SSet := by
dsimp only [SSet]
infer_instance
-- Porting note (#5229): added an `ext` lemma.
@[ext]
lemma hom_ext {X Y : SSet} {f g : X ⟶ Y} (w : ∀ n, f.app n = g.app n) : f = g :=
SimplicialObject.hom_ext _ _ w
/-- The ulift functor `SSet.{u} ⥤ SSet.{max u v}` on simplicial sets. -/
def uliftFunctor : SSet.{u} ⥤ SSet.{max u v} :=
(SimplicialObject.whiskering _ _).obj CategoryTheory.uliftFunctor.{v, u}
/-- The `n`-th standard simplex `Δ[n]` associated with a nonempty finite linear order `n`
is the Yoneda embedding of `n`. -/
def standardSimplex : SimplexCategory ⥤ SSet.{u} :=
yoneda ⋙ uliftFunctor
@[inherit_doc SSet.standardSimplex]
scoped[Simplicial] notation3 "Δ[" n "]" => SSet.standardSimplex.obj (SimplexCategory.mk n)
instance : Inhabited SSet :=
⟨Δ[0]⟩
namespace standardSimplex
open Finset Opposite SimplexCategory
@[simp]
lemma map_id (n : SimplexCategory) :
(SSet.standardSimplex.map (SimplexCategory.Hom.mk OrderHom.id : n ⟶ n)) = 𝟙 _ :=
CategoryTheory.Functor.map_id _ _
/-- Simplices of the standard simplex identify to morphisms in `SimplexCategory`. -/
def objEquiv (n : SimplexCategory) (m : SimplexCategoryᵒᵖ) :
(standardSimplex.{u}.obj n).obj m ≃ (m.unop ⟶ n) :=
Equiv.ulift.{u, 0}
/-- Constructor for simplices of the standard simplex which takes a `OrderHom` as an input. -/
abbrev objMk {n : SimplexCategory} {m : SimplexCategoryᵒᵖ}
(f : Fin (len m.unop + 1) →o Fin (n.len + 1)) :
(standardSimplex.{u}.obj n).obj m :=
(objEquiv _ _).symm (Hom.mk f)
lemma map_apply {m₁ m₂ : SimplexCategoryᵒᵖ} (f : m₁ ⟶ m₂) {n : SimplexCategory}
(x : (standardSimplex.{u}.obj n).obj m₁) :
(standardSimplex.{u}.obj n).map f x = (objEquiv _ _).symm (f.unop ≫ (objEquiv _ _) x) := by
rfl
/-- The canonical bijection `(standardSimplex.obj n ⟶ X) ≃ X.obj (op n)`. -/
def _root_.SSet.yonedaEquiv (X : SSet.{u}) (n : SimplexCategory) :
(standardSimplex.obj n ⟶ X) ≃ X.obj (op n) :=
yonedaCompUliftFunctorEquiv X n
/-- The (degenerate) `m`-simplex in the standard simplex concentrated in vertex `k`. -/
def const (n : ℕ) (k : Fin (n+1)) (m : SimplexCategoryᵒᵖ) : Δ[n].obj m :=
objMk (OrderHom.const _ k )
@[simp]
lemma const_down_toOrderHom (n : ℕ) (k : Fin (n+1)) (m : SimplexCategoryᵒᵖ) :
(const n k m).down.toOrderHom = OrderHom.const _ k :=
rfl
/-- The edge of the standard simplex with endpoints `a` and `b`. -/
def edge (n : ℕ) (a b : Fin (n+1)) (hab : a ≤ b) : Δ[n] _[1] := by
refine objMk ⟨![a, b], ?_⟩
rw [Fin.monotone_iff_le_succ]
simp only [unop_op, len_mk, Fin.forall_fin_one]
apply Fin.mk_le_mk.mpr hab
lemma coe_edge_down_toOrderHom (n : ℕ) (a b : Fin (n+1)) (hab : a ≤ b) :
↑(edge n a b hab).down.toOrderHom = ![a, b] :=
rfl
/-- The triangle in the standard simplex with vertices `a`, `b`, and `c`. -/
def triangle {n : ℕ} (a b c : Fin (n+1)) (hab : a ≤ b) (hbc : b ≤ c) : Δ[n] _[2] := by
refine objMk ⟨![a, b, c], ?_⟩
rw [Fin.monotone_iff_le_succ]
simp only [unop_op, len_mk, Fin.forall_fin_two]
dsimp
simp only [*, Matrix.tail_cons, Matrix.head_cons, true_and]
lemma coe_triangle_down_toOrderHom {n : ℕ} (a b c : Fin (n+1)) (hab : a ≤ b) (hbc : b ≤ c) :
↑(triangle a b c hab hbc).down.toOrderHom = ![a, b, c] :=
rfl
end standardSimplex
section
/-- The `m`-simplices of the `n`-th standard simplex are
the monotone maps from `Fin (m+1)` to `Fin (n+1)`. -/
def asOrderHom {n} {m} (α : Δ[n].obj m) : OrderHom (Fin (m.unop.len + 1)) (Fin (n + 1)) :=
α.down.toOrderHom
end
/-- The boundary `∂Δ[n]` of the `n`-th standard simplex consists of
all `m`-simplices of `standardSimplex n` that are not surjective
(when viewed as monotone function `m → n`). -/
def boundary (n : ℕ) : SSet.{u} where
obj m := { α : Δ[n].obj m // ¬Function.Surjective (asOrderHom α) }
map {m₁ m₂} f α :=
⟨Δ[n].map f α.1, by
intro h
apply α.property
exact Function.Surjective.of_comp h⟩
/-- The boundary `∂Δ[n]` of the `n`-th standard simplex -/
scoped[Simplicial] notation3 "∂Δ[" n "]" => SSet.boundary n
/-- The inclusion of the boundary of the `n`-th standard simplex into that standard simplex. -/
def boundaryInclusion (n : ℕ) : ∂Δ[n] ⟶ Δ[n] where app m (α : { α : Δ[n].obj m // _ }) := α
/-- `horn n i` (or `Λ[n, i]`) is the `i`-th horn of the `n`-th standard simplex, where `i : n`.
It consists of all `m`-simplices `α` of `Δ[n]`
for which the union of `{i}` and the range of `α` is not all of `n`
(when viewing `α` as monotone function `m → n`). -/
def horn (n : ℕ) (i : Fin (n + 1)) : SSet where
obj m := { α : Δ[n].obj m // Set.range (asOrderHom α) ∪ {i} ≠ Set.univ }
map {m₁ m₂} f α :=
⟨Δ[n].map f α.1, by
intro h; apply α.property
rw [Set.eq_univ_iff_forall] at h ⊢; intro j
apply Or.imp _ id (h j)
intro hj
exact Set.range_comp_subset_range _ _ hj⟩
/-- The `i`-th horn `Λ[n, i]` of the standard `n`-simplex -/
scoped[Simplicial] notation3 "Λ[" n ", " i "]" => SSet.horn (n : ℕ) i
/-- The inclusion of the `i`-th horn of the `n`-th standard simplex into that standard simplex. -/
def hornInclusion (n : ℕ) (i : Fin (n + 1)) : Λ[n, i] ⟶ Δ[n] where
app m (α : { α : Δ[n].obj m // _ }) := α
namespace horn
open SimplexCategory Finset Opposite
/-- The (degenerate) subsimplex of `Λ[n+2, i]` concentrated in vertex `k`. -/
@[simps]
def const (n : ℕ) (i k : Fin (n+3)) (m : SimplexCategoryᵒᵖ) : Λ[n+2, i].obj m := by
refine ⟨standardSimplex.const _ k _, ?_⟩
suffices ¬ Finset.univ ⊆ {i, k} by
simpa [← Set.univ_subset_iff, Set.subset_def, asOrderHom, not_or, Fin.forall_fin_one,
subset_iff, mem_univ, @eq_comm _ _ k]
intro h
have := (card_le_card h).trans card_le_two
rw [card_fin] at this
omega
/-- The edge of `Λ[n, i]` with endpoints `a` and `b`.
This edge only exists if `{i, a, b}` has cardinality less than `n`. -/
@[simps]
def edge (n : ℕ) (i a b : Fin (n+1)) (hab : a ≤ b) (H : Finset.card {i, a, b} ≤ n) :
Λ[n, i] _[1] := by
refine ⟨standardSimplex.edge n a b hab, ?range⟩
case range =>
suffices ∃ x, ¬i = x ∧ ¬a = x ∧ ¬b = x by
simpa only [unop_op, SimplexCategory.len_mk, asOrderHom, SimplexCategory.Hom.toOrderHom_mk,
Set.union_singleton, ne_eq, ← Set.univ_subset_iff, Set.subset_def, Set.mem_univ,
Set.mem_insert_iff, @eq_comm _ _ i, Set.mem_range, forall_true_left, not_forall, not_or,
not_exists, Fin.forall_fin_two]
contrapose! H
replace H : univ ⊆ {i, a, b} :=
fun x _ ↦ by simpa [or_iff_not_imp_left, eq_comm] using H x
replace H := card_le_card H
rwa [card_fin] at H
/-- Alternative constructor for the edge of `Λ[n, i]` with endpoints `a` and `b`,
assuming `3 ≤ n`. -/
@[simps!]
def edge₃ (n : ℕ) (i a b : Fin (n+1)) (hab : a ≤ b) (H : 3 ≤ n) :
Λ[n, i] _[1] :=
horn.edge n i a b hab <| Finset.card_le_three.trans H
/-- The edge of `Λ[n, i]` with endpoints `j` and `j+1`.
This constructor assumes `0 < i < n`,
which is the type of horn that occurs in the horn-filling condition of quasicategories. -/
@[simps!]
def primitiveEdge {n : ℕ} {i : Fin (n+1)}
(h₀ : 0 < i) (hₙ : i < Fin.last n) (j : Fin n) :
Λ[n, i] _[1] := by
refine horn.edge n i j.castSucc j.succ ?_ ?_
· simp only [← Fin.val_fin_le, Fin.coe_castSucc, Fin.val_succ, le_add_iff_nonneg_right, zero_le]
simp only [← Fin.val_fin_lt, Fin.val_zero, Fin.val_last] at h₀ hₙ
obtain rfl|hn : n = 2 ∨ 2 < n := by
rw [eq_comm, or_comm, ← le_iff_lt_or_eq]; omega
· revert i j; decide
· exact Finset.card_le_three.trans hn
/-- The triangle in the standard simplex with vertices `k`, `k+1`, and `k+2`.
This constructor assumes `0 < i < n`,
which is the type of horn that occurs in the horn-filling condition of quasicategories. -/
@[simps]
def primitiveTriangle {n : ℕ} (i : Fin (n+4))
(h₀ : 0 < i) (hₙ : i < Fin.last (n+3))
(k : ℕ) (h : k < n+2) : Λ[n+3, i] _[2] := by
refine ⟨standardSimplex.triangle
(n := n+3) ⟨k, by omega⟩ ⟨k+1, by omega⟩ ⟨k+2, by omega⟩ ?_ ?_, ?_⟩
· simp only [Fin.mk_le_mk, le_add_iff_nonneg_right, zero_le]
· simp only [Fin.mk_le_mk, add_le_add_iff_left, one_le_two]
simp only [unop_op, SimplexCategory.len_mk, asOrderHom, SimplexCategory.Hom.toOrderHom_mk,
OrderHom.const_coe_coe, Set.union_singleton, ne_eq, ← Set.univ_subset_iff, Set.subset_def,
Set.mem_univ, Set.mem_insert_iff, Set.mem_range, Function.const_apply, exists_const,
forall_true_left, not_forall, not_or, unop_op, not_exists,
standardSimplex.triangle, OrderHom.coe_mk, @eq_comm _ _ i,
standardSimplex.objMk, standardSimplex.objEquiv, Equiv.ulift]
dsimp
by_cases hk0 : k = 0
· subst hk0
use Fin.last (n+3)
simp only [hₙ.ne, not_false_eq_true, Fin.zero_eta, zero_add, true_and]
intro j
fin_cases j <;> simp [Fin.ext_iff]
· use 0
simp only [h₀.ne', not_false_eq_true, true_and]
intro j
fin_cases j <;> simp [Fin.ext_iff, hk0]
/-- The `j`th subface of the `i`-th horn. -/
@[simps]
def face {n : ℕ} (i j : Fin (n+2)) (h : j ≠ i) : Λ[n+1, i] _[n] :=
⟨(standardSimplex.objEquiv _ _).symm (SimplexCategory.δ j), by
simpa [← Set.univ_subset_iff, Set.subset_def, asOrderHom, SimplexCategory.δ, not_or,
standardSimplex.objEquiv, asOrderHom, Equiv.ulift]⟩
/-- Two morphisms from a horn are equal if they are equal on all suitable faces. -/
protected
lemma hom_ext {n : ℕ} {i : Fin (n+2)} {S : SSet} (σ₁ σ₂ : Λ[n+1, i] ⟶ S)
(h : ∀ (j) (h : j ≠ i), σ₁.app _ (face i j h) = σ₂.app _ (face i j h)) :
σ₁ = σ₂ := by
apply NatTrans.ext; apply funext; apply Opposite.rec; apply SimplexCategory.rec
intro m; ext f
obtain ⟨f', hf⟩ := (standardSimplex.objEquiv _ _).symm.surjective f.1
obtain ⟨j, hji, hfj⟩ : ∃ j, ¬j = i ∧ ∀ k, f'.toOrderHom k ≠ j := by
obtain ⟨f, hf'⟩ := f
subst hf
simpa [← Set.univ_subset_iff, Set.subset_def, asOrderHom, not_or] using hf'
have H : f = (Λ[n+1, i].map (factor_δ f' j).op) (face i j hji) := by
apply Subtype.ext
apply (standardSimplex.objEquiv _ _).injective
rw [← hf]
exact (factor_δ_spec f' j hfj).symm
have H₁ := congrFun (σ₁.naturality (factor_δ f' j).op) (face i j hji)
have H₂ := congrFun (σ₂.naturality (factor_δ f' j).op) (face i j hji)
dsimp at H₁ H₂
erw [H, H₁, H₂, h _ hji]
end horn
section Examples
open Simplicial
/-- The simplicial circle. -/
noncomputable def S1 : SSet :=
Limits.colimit <|
Limits.parallelPair (standardSimplex.map <| SimplexCategory.δ 0 : Δ[0] ⟶ Δ[1])
(standardSimplex.map <| SimplexCategory.δ 1)
end Examples
/-- Truncated simplicial sets. -/
def Truncated (n : ℕ) :=
SimplicialObject.Truncated (Type u) n
instance Truncated.largeCategory (n : ℕ) : LargeCategory (Truncated n) := by
dsimp only [Truncated]
infer_instance
instance Truncated.hasLimits {n : ℕ} : HasLimits (Truncated n) := by
dsimp only [Truncated]
infer_instance
instance Truncated.hasColimits {n : ℕ} : HasColimits (Truncated n) := by
dsimp only [Truncated]
infer_instance
-- Porting note (#5229): added an `ext` lemma.
@[ext]
lemma Truncated.hom_ext {n : ℕ} {X Y : Truncated n} {f g : X ⟶ Y} (w : ∀ n, f.app n = g.app n) :
f = g :=
NatTrans.ext (funext w)
/-- The skeleton functor on simplicial sets. -/
def sk (n : ℕ) : SSet ⥤ SSet.Truncated n :=
SimplicialObject.sk n
instance {n} : Inhabited (SSet.Truncated n) :=
⟨(sk n).obj <| Δ[0]⟩
/-- The category of augmented simplicial sets, as a particular case of
augmented simplicial objects. -/
abbrev Augmented :=
SimplicialObject.Augmented (Type u)
namespace Augmented
-- Porting note: an instance of `Subsingleton (⊤_ (Type u))` was added in
-- `CategoryTheory.Limits.Types` to ease the automation in this definition
/-- The functor which sends `[n]` to the simplicial set `Δ[n]` equipped by
the obvious augmentation towards the terminal object of the category of sets. -/
@[simps]
noncomputable def standardSimplex : SimplexCategory ⥤ SSet.Augmented.{u} where
obj Δ :=
{ left := SSet.standardSimplex.obj Δ
right := terminal _
hom := { app := fun Δ' => terminal.from _ } }
map θ :=
{ left := SSet.standardSimplex.map θ
right := terminal.from _ }
end Augmented
end SSet
|
AlgebraicTopology\SingularSet.lean | /-
Copyright (c) 2023 Johan Commelin. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Scott Morrison, Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplicialSet
import Mathlib.AlgebraicTopology.TopologicalSimplex
import Mathlib.CategoryTheory.Limits.Presheaf
import Mathlib.Topology.Category.TopCat.Limits.Basic
/-!
# The singular simplicial set of a topological space and geometric realization of a simplicial set
The *singular simplicial set* `TopCat.to_SSet.obj X` of a topological space `X`
has as `n`-simplices the continuous maps `[n].toTop → X`.
Here, `[n].toTop` is the standard topological `n`-simplex,
defined as `{ f : Fin (n+1) → ℝ≥0 // ∑ i, f i = 1 }` with its subspace topology.
The *geometric realization* functor `SSet.toTop.obj` is left adjoint to `TopCat.toSSet`.
It is the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
# Main definitions
* `TopCat.toSSet : TopCat ⥤ SSet` is the functor
assigning the singular simplicial set to a topological space.
* `SSet.toTop : SSet ⥤ TopCat` is the functor
assigning the geometric realization to a simplicial set.
* `sSetTopAdj : SSet.toTop ⊣ TopCat.toSSet` is the adjunction between these two functors.
## TODO
- Generalize to an adjunction between `SSet.{u}` and `TopCat.{u}` for any universe `u`
- Show that the singular simplicial set is a Kan complex.
- Show the adjunction `sSetTopAdj` is a Quillen adjunction.
-/
open CategoryTheory
/-- The functor associating the *singular simplicial set* to a topological space.
Let `X` be a topological space.
Then the singular simplicial set of `X`
has as `n`-simplices the continuous maps `[n].toTop → X`.
Here, `[n].toTop` is the standard topological `n`-simplex,
defined as `{ f : Fin (n+1) → ℝ≥0 // ∑ i, f i = 1 }` with its subspace topology. -/
noncomputable def TopCat.toSSet : TopCat ⥤ SSet :=
Presheaf.restrictedYoneda SimplexCategory.toTop
/-- The *geometric realization functor* is
the left Kan extension of `SimplexCategory.toTop` along the Yoneda embedding.
It is left adjoint to `TopCat.toSSet`, as witnessed by `sSetTopAdj`. -/
noncomputable def SSet.toTop : SSet ⥤ TopCat :=
yoneda.leftKanExtension SimplexCategory.toTop
/-- Geometric realization is left adjoint to the singular simplicial set construction. -/
noncomputable def sSetTopAdj : SSet.toTop ⊣ TopCat.toSSet :=
Presheaf.yonedaAdjunction (yoneda.leftKanExtension SimplexCategory.toTop)
(yoneda.leftKanExtensionUnit SimplexCategory.toTop)
/-- The geometric realization of the representable simplicial sets agree
with the usual topological simplices. -/
noncomputable def SSet.toTopSimplex :
(yoneda : SimplexCategory ⥤ _) ⋙ SSet.toTop ≅ SimplexCategory.toTop :=
Presheaf.isExtensionAlongYoneda _
|
AlgebraicTopology\SplitSimplicialObject.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.SimplicialObject
import Mathlib.CategoryTheory.Limits.Shapes.Products
/-!
# Split simplicial objects
In this file, we introduce the notion of split simplicial object.
If `C` is a category that has finite coproducts, a splitting
`s : Splitting X` of a simplicial object `X` in `C` consists
of the datum of a sequence of objects `s.N : ℕ → C` (which
we shall refer to as "nondegenerate simplices") and a
sequence of morphisms `s.ι n : s.N n → X _[n]` that have
the property that a certain canonical map identifies `X _[n]`
with the coproduct of objects `s.N i` indexed by all possible
epimorphisms `[n] ⟶ [i]` in `SimplexCategory`. (We do not
assume that the morphisms `s.ι n` are monomorphisms: in the
most common categories, this would be a consequence of the
axioms.)
Simplicial objects equipped with a splitting form a category
`SimplicialObject.Split C`.
## References
* [Stacks: Splitting simplicial objects] https://stacks.math.columbia.edu/tag/017O
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits Opposite SimplexCategory
open Simplicial
universe u
variable {C : Type*} [Category C]
namespace SimplicialObject
namespace Splitting
/-- The index set which appears in the definition of split simplicial objects. -/
def IndexSet (Δ : SimplexCategoryᵒᵖ) :=
ΣΔ' : SimplexCategoryᵒᵖ, { α : Δ.unop ⟶ Δ'.unop // Epi α }
namespace IndexSet
/-- The element in `Splitting.IndexSet Δ` attached to an epimorphism `f : Δ ⟶ Δ'`. -/
@[simps]
def mk {Δ Δ' : SimplexCategory} (f : Δ ⟶ Δ') [Epi f] : IndexSet (op Δ) :=
⟨op Δ', f, inferInstance⟩
variable {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ)
/-- The epimorphism in `SimplexCategory` associated to `A : Splitting.IndexSet Δ` -/
def e :=
A.2.1
instance : Epi A.e :=
A.2.2
theorem ext' : A = ⟨A.1, ⟨A.e, A.2.2⟩⟩ := rfl
theorem ext (A₁ A₂ : IndexSet Δ) (h₁ : A₁.1 = A₂.1) (h₂ : A₁.e ≫ eqToHom (by rw [h₁]) = A₂.e) :
A₁ = A₂ := by
rcases A₁ with ⟨Δ₁, ⟨α₁, hα₁⟩⟩
rcases A₂ with ⟨Δ₂, ⟨α₂, hα₂⟩⟩
simp only at h₁
subst h₁
simp only [eqToHom_refl, comp_id, IndexSet.e] at h₂
simp only [h₂]
instance : Fintype (IndexSet Δ) :=
Fintype.ofInjective
(fun A =>
⟨⟨A.1.unop.len, Nat.lt_succ_iff.mpr (len_le_of_epi (inferInstance : Epi A.e))⟩,
A.e.toOrderHom⟩ :
IndexSet Δ → Sigma fun k : Fin (Δ.unop.len + 1) => Fin (Δ.unop.len + 1) → Fin (k + 1))
(by
rintro ⟨Δ₁, α₁⟩ ⟨Δ₂, α₂⟩ h₁
induction' Δ₁ using Opposite.rec with Δ₁
induction' Δ₂ using Opposite.rec with Δ₂
simp only [unop_op, Sigma.mk.inj_iff, Fin.mk.injEq] at h₁
have h₂ : Δ₁ = Δ₂ := by
ext1
simpa only [Fin.mk_eq_mk] using h₁.1
subst h₂
refine ext _ _ rfl ?_
ext : 2
exact eq_of_heq h₁.2)
variable (Δ)
/-- The distinguished element in `Splitting.IndexSet Δ` which corresponds to the
identity of `Δ`. -/
@[simps]
def id : IndexSet Δ :=
⟨Δ, ⟨𝟙 _, by infer_instance⟩⟩
instance : Inhabited (IndexSet Δ) :=
⟨id Δ⟩
variable {Δ}
/-- The condition that an element `Splitting.IndexSet Δ` is the distinguished
element `Splitting.IndexSet.Id Δ`. -/
@[simp]
def EqId : Prop :=
A = id _
theorem eqId_iff_eq : A.EqId ↔ A.1 = Δ := by
constructor
· intro h
dsimp at h
rw [h]
rfl
· intro h
rcases A with ⟨_, ⟨f, hf⟩⟩
simp only at h
subst h
refine ext _ _ rfl ?_
haveI := hf
simp only [eqToHom_refl, comp_id]
exact eq_id_of_epi f
theorem eqId_iff_len_eq : A.EqId ↔ A.1.unop.len = Δ.unop.len := by
rw [eqId_iff_eq]
constructor
· intro h
rw [h]
· intro h
rw [← unop_inj_iff]
ext
exact h
theorem eqId_iff_len_le : A.EqId ↔ Δ.unop.len ≤ A.1.unop.len := by
rw [eqId_iff_len_eq]
constructor
· intro h
rw [h]
· exact le_antisymm (len_le_of_epi (inferInstance : Epi A.e))
theorem eqId_iff_mono : A.EqId ↔ Mono A.e := by
constructor
· intro h
dsimp at h
subst h
dsimp only [id, e]
infer_instance
· intro h
rw [eqId_iff_len_le]
exact len_le_of_mono h
/-- Given `A : IndexSet Δ₁`, if `p.unop : unop Δ₂ ⟶ unop Δ₁` is an epi, this
is the obvious element in `A : IndexSet Δ₂` associated to the composition
of epimorphisms `p.unop ≫ A.e`. -/
@[simps]
def epiComp {Δ₁ Δ₂ : SimplexCategoryᵒᵖ} (A : IndexSet Δ₁) (p : Δ₁ ⟶ Δ₂) [Epi p.unop] :
IndexSet Δ₂ :=
⟨A.1, ⟨p.unop ≫ A.e, epi_comp _ _⟩⟩
variable {Δ' : SimplexCategoryᵒᵖ} (θ : Δ ⟶ Δ')
/-- When `A : IndexSet Δ` and `θ : Δ → Δ'` is a morphism in `SimplexCategoryᵒᵖ`,
an element in `IndexSet Δ'` can be defined by using the epi-mono factorisation
of `θ.unop ≫ A.e`. -/
def pull : IndexSet Δ' :=
mk (factorThruImage (θ.unop ≫ A.e))
@[reassoc]
theorem fac_pull : (A.pull θ).e ≫ image.ι (θ.unop ≫ A.e) = θ.unop ≫ A.e :=
image.fac _
end IndexSet
variable (N : ℕ → C) (Δ : SimplexCategoryᵒᵖ) (X : SimplicialObject C) (φ : ∀ n, N n ⟶ X _[n])
/-- Given a sequences of objects `N : ℕ → C` in a category `C`, this is
a family of objects indexed by the elements `A : Splitting.IndexSet Δ`.
The `Δ`-simplices of a split simplicial objects shall identify to the
coproduct of objects in such a family. -/
@[simp, nolint unusedArguments]
def summand (A : IndexSet Δ) : C :=
N A.1.unop.len
/-- The cofan for `summand N Δ` induced by morphisms `N n ⟶ X_ [n]` for all `n : ℕ`. -/
def cofan' (Δ : SimplexCategoryᵒᵖ) : Cofan (summand N Δ) :=
Cofan.mk (X.obj Δ) (fun A => φ A.1.unop.len ≫ X.map A.e.op)
end Splitting
--porting note (#5171): removed @[nolint has_nonempty_instance]
/-- A splitting of a simplicial object `X` consists of the datum of a sequence
of objects `N`, a sequence of morphisms `ι : N n ⟶ X _[n]` such that
for all `Δ : SimplexCategoryᵒᵖ`, the canonical map `Splitting.map X ι Δ`
is an isomorphism. -/
structure Splitting (X : SimplicialObject C) where
/-- The "nondegenerate simplices" `N n` for all `n : ℕ`. -/
N : ℕ → C
/-- The "inclusion" `N n ⟶ X _[n]` for all `n : ℕ`. -/
ι : ∀ n, N n ⟶ X _[n]
/-- For each `Δ`, `X.obj Δ` identifies to the coproduct of the objects `N A.1.unop.len`
for all `A : IndexSet Δ`. -/
isColimit' : ∀ Δ : SimplexCategoryᵒᵖ, IsColimit (Splitting.cofan' N X ι Δ)
namespace Splitting
variable {X Y : SimplicialObject C} (s : Splitting X)
/-- The cofan for `summand s.N Δ` induced by a splitting of a simplicial object. -/
def cofan (Δ : SimplexCategoryᵒᵖ) : Cofan (summand s.N Δ) :=
Cofan.mk (X.obj Δ) (fun A => s.ι A.1.unop.len ≫ X.map A.e.op)
/-- The cofan `s.cofan Δ` is colimit. -/
def isColimit (Δ : SimplexCategoryᵒᵖ) : IsColimit (s.cofan Δ) := s.isColimit' Δ
@[reassoc]
theorem cofan_inj_eq {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A = s.ι A.1.unop.len ≫ X.map A.e.op := rfl
theorem cofan_inj_id (n : ℕ) : (s.cofan _).inj (IndexSet.id (op [n])) = s.ι n := by
erw [cofan_inj_eq, X.map_id, comp_id]
rfl
/-- As it is stated in `Splitting.hom_ext`, a morphism `f : X ⟶ Y` from a split
simplicial object to any simplicial object is determined by its restrictions
`s.φ f n : s.N n ⟶ Y _[n]` to the distinguished summands in each degree `n`. -/
@[simp]
def φ (f : X ⟶ Y) (n : ℕ) : s.N n ⟶ Y _[n] :=
s.ι n ≫ f.app (op [n])
@[reassoc (attr := simp)]
theorem cofan_inj_comp_app (f : X ⟶ Y) {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A ≫ f.app Δ = s.φ f A.1.unop.len ≫ Y.map A.e.op := by
simp only [cofan_inj_eq_assoc, φ, assoc]
erw [NatTrans.naturality]
theorem hom_ext' {Z : C} {Δ : SimplexCategoryᵒᵖ} (f g : X.obj Δ ⟶ Z)
(h : ∀ A : IndexSet Δ, (s.cofan Δ).inj A ≫ f = (s.cofan Δ).inj A ≫ g) : f = g :=
Cofan.IsColimit.hom_ext (s.isColimit Δ) _ _ h
theorem hom_ext (f g : X ⟶ Y) (h : ∀ n : ℕ, s.φ f n = s.φ g n) : f = g := by
ext Δ
apply s.hom_ext'
intro A
induction' Δ using Opposite.rec with Δ
induction' Δ using SimplexCategory.rec with n
dsimp
simp only [s.cofan_inj_comp_app, h]
/-- The map `X.obj Δ ⟶ Z` obtained by providing a family of morphisms on all the
terms of decomposition given by a splitting `s : Splitting X` -/
def desc {Z : C} (Δ : SimplexCategoryᵒᵖ) (F : ∀ A : IndexSet Δ, s.N A.1.unop.len ⟶ Z) :
X.obj Δ ⟶ Z :=
Cofan.IsColimit.desc (s.isColimit Δ) F
@[reassoc (attr := simp)]
theorem ι_desc {Z : C} (Δ : SimplexCategoryᵒᵖ) (F : ∀ A : IndexSet Δ, s.N A.1.unop.len ⟶ Z)
(A : IndexSet Δ) : (s.cofan Δ).inj A ≫ s.desc Δ F = F A := by
apply Cofan.IsColimit.fac
/-- A simplicial object that is isomorphic to a split simplicial object is split. -/
@[simps]
def ofIso (e : X ≅ Y) : Splitting Y where
N := s.N
ι n := s.ι n ≫ e.hom.app (op [n])
isColimit' Δ := IsColimit.ofIsoColimit (s.isColimit Δ ) (Cofan.ext (e.app Δ)
(fun A => by simp [cofan, cofan']))
@[reassoc]
theorem cofan_inj_epi_naturality {Δ₁ Δ₂ : SimplexCategoryᵒᵖ} (A : IndexSet Δ₁) (p : Δ₁ ⟶ Δ₂)
[Epi p.unop] : (s.cofan Δ₁).inj A ≫ X.map p = (s.cofan Δ₂).inj (A.epiComp p) := by
dsimp [cofan]
rw [assoc, ← X.map_comp]
rfl
end Splitting
variable (C)
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- The category `SimplicialObject.Split C` is the category of simplicial objects
in `C` equipped with a splitting, and morphisms are morphisms of simplicial objects
which are compatible with the splittings. -/
@[ext]
structure Split where
/-- the underlying simplicial object -/
X : SimplicialObject C
/-- a splitting of the simplicial object -/
s : Splitting X
namespace Split
variable {C}
/-- The object in `SimplicialObject.Split C` attached to a splitting `s : Splitting X`
of a simplicial object `X`. -/
@[simps]
def mk' {X : SimplicialObject C} (s : Splitting X) : Split C :=
⟨X, s⟩
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- Morphisms in `SimplicialObject.Split C` are morphisms of simplicial objects that
are compatible with the splittings. -/
structure Hom (S₁ S₂ : Split C) where
/-- the morphism between the underlying simplicial objects -/
F : S₁.X ⟶ S₂.X
/-- the morphism between the "nondegenerate" `n`-simplices for all `n : ℕ` -/
f : ∀ n : ℕ, S₁.s.N n ⟶ S₂.s.N n
comm : ∀ n : ℕ, S₁.s.ι n ≫ F.app (op [n]) = f n ≫ S₂.s.ι n := by aesop_cat
@[ext]
theorem Hom.ext {S₁ S₂ : Split C} (Φ₁ Φ₂ : Hom S₁ S₂) (h : ∀ n : ℕ, Φ₁.f n = Φ₂.f n) : Φ₁ = Φ₂ := by
rcases Φ₁ with ⟨F₁, f₁, c₁⟩
rcases Φ₂ with ⟨F₂, f₂, c₂⟩
have h' : f₁ = f₂ := by
ext
apply h
subst h'
simp only [mk.injEq, and_true]
apply S₁.s.hom_ext
intro n
dsimp
rw [c₁, c₂]
attribute [simp, reassoc] Hom.comm
end Split
instance : Category (Split C) where
Hom := Split.Hom
id S :=
{ F := 𝟙 _
f := fun n => 𝟙 _ }
comp Φ₁₂ Φ₂₃ :=
{ F := Φ₁₂.F ≫ Φ₂₃.F
f := fun n => Φ₁₂.f n ≫ Φ₂₃.f n
comm := fun n => by
dsimp
simp only [assoc, Split.Hom.comm_assoc, Split.Hom.comm] }
variable {C}
namespace Split
-- Porting note: added as `Hom.ext` is not triggered automatically
@[ext]
theorem hom_ext {S₁ S₂ : Split C} (Φ₁ Φ₂ : S₁ ⟶ S₂) (h : ∀ n : ℕ, Φ₁.f n = Φ₂.f n) : Φ₁ = Φ₂ :=
Hom.ext _ _ h
theorem congr_F {S₁ S₂ : Split C} {Φ₁ Φ₂ : S₁ ⟶ S₂} (h : Φ₁ = Φ₂) : Φ₁.f = Φ₂.f := by rw [h]
theorem congr_f {S₁ S₂ : Split C} {Φ₁ Φ₂ : S₁ ⟶ S₂} (h : Φ₁ = Φ₂) (n : ℕ) : Φ₁.f n = Φ₂.f n := by
rw [h]
@[simp]
theorem id_F (S : Split C) : (𝟙 S : S ⟶ S).F = 𝟙 S.X :=
rfl
@[simp]
theorem id_f (S : Split C) (n : ℕ) : (𝟙 S : S ⟶ S).f n = 𝟙 (S.s.N n) :=
rfl
@[simp]
theorem comp_F {S₁ S₂ S₃ : Split C} (Φ₁₂ : S₁ ⟶ S₂) (Φ₂₃ : S₂ ⟶ S₃) :
(Φ₁₂ ≫ Φ₂₃).F = Φ₁₂.F ≫ Φ₂₃.F :=
rfl
@[simp]
theorem comp_f {S₁ S₂ S₃ : Split C} (Φ₁₂ : S₁ ⟶ S₂) (Φ₂₃ : S₂ ⟶ S₃) (n : ℕ) :
(Φ₁₂ ≫ Φ₂₃).f n = Φ₁₂.f n ≫ Φ₂₃.f n :=
rfl
@[reassoc (attr := simp 1100)]
theorem cofan_inj_naturality_symm {S₁ S₂ : Split C} (Φ : S₁ ⟶ S₂) {Δ : SimplexCategoryᵒᵖ}
(A : Splitting.IndexSet Δ) :
(S₁.s.cofan Δ).inj A ≫ Φ.F.app Δ = Φ.f A.1.unop.len ≫ (S₂.s.cofan Δ).inj A := by
erw [S₁.s.cofan_inj_eq, S₂.s.cofan_inj_eq, assoc, Φ.F.naturality, ← Φ.comm_assoc]
variable (C)
/-- The functor `SimplicialObject.Split C ⥤ SimplicialObject C` which forgets
the splitting. -/
@[simps]
def forget : Split C ⥤ SimplicialObject C where
obj S := S.X
map Φ := Φ.F
/-- The functor `SimplicialObject.Split C ⥤ C` which sends a simplicial object equipped
with a splitting to its nondegenerate `n`-simplices. -/
@[simps]
def evalN (n : ℕ) : Split C ⥤ C where
obj S := S.s.N n
map Φ := Φ.f n
/-- The inclusion of each summand in the coproduct decomposition of simplices
in split simplicial objects is a natural transformation of functors
`SimplicialObject.Split C ⥤ C` -/
@[simps]
def natTransCofanInj {Δ : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) :
evalN C A.1.unop.len ⟶ forget C ⋙ (evaluation SimplexCategoryᵒᵖ C).obj Δ where
app S := (S.s.cofan Δ).inj A
naturality _ _ Φ := (cofan_inj_naturality_symm Φ A).symm
end Split
end SimplicialObject
|
AlgebraicTopology\TopologicalSimplex.lean | /-
Copyright (c) 2021 Adam Topaz. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Johan Commelin, Adam Topaz
-/
import Mathlib.AlgebraicTopology.SimplexCategory
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Instances.NNReal
/-!
# Topological simplices
We define the natural functor from `SimplexCategory` to `TopCat` sending `[n]` to the
topological `n`-simplex.
This is used to define `TopCat.toSSet` in `AlgebraicTopology.SingularSet`.
-/
noncomputable section
namespace SimplexCategory
open Simplicial NNReal CategoryTheory
attribute [local instance] ConcreteCategory.hasCoeToSort ConcreteCategory.instFunLike
-- Porting note: added, should be moved
instance (x : SimplexCategory) : Fintype (ConcreteCategory.forget.obj x) :=
inferInstanceAs (Fintype (Fin _))
/-- The topological simplex associated to `x : SimplexCategory`.
This is the object part of the functor `SimplexCategory.toTop`. -/
def toTopObj (x : SimplexCategory) := { f : x → ℝ≥0 | ∑ i, f i = 1 }
instance (x : SimplexCategory) : CoeFun x.toTopObj fun _ => x → ℝ≥0 :=
⟨fun f => (f : x → ℝ≥0)⟩
@[ext]
theorem toTopObj.ext {x : SimplexCategory} (f g : x.toTopObj) : (f : x → ℝ≥0) = g → f = g :=
Subtype.ext
open Classical in
/-- A morphism in `SimplexCategory` induces a map on the associated topological spaces. -/
def toTopMap {x y : SimplexCategory} (f : x ⟶ y) (g : x.toTopObj) : y.toTopObj :=
⟨fun i => ∑ j ∈ Finset.univ.filter (f · = i), g j, by
simp only [toTopObj, Set.mem_setOf]
rw [← Finset.sum_biUnion]
· have hg : ∑ i : (forget SimplexCategory).obj x, g i = 1 := g.2
convert hg
simp [Finset.eq_univ_iff_forall]
· apply Set.pairwiseDisjoint_filter⟩
open Classical in
@[simp]
theorem coe_toTopMap {x y : SimplexCategory} (f : x ⟶ y) (g : x.toTopObj) (i : y) :
toTopMap f g i = ∑ j ∈ Finset.univ.filter (f · = i), g j :=
rfl
@[continuity]
theorem continuous_toTopMap {x y : SimplexCategory} (f : x ⟶ y) : Continuous (toTopMap f) := by
refine Continuous.subtype_mk (continuous_pi fun i => ?_) _
dsimp only [coe_toTopMap]
exact continuous_finset_sum _ (fun j _ => (continuous_apply _).comp continuous_subtype_val)
/-- The functor associating the topological `n`-simplex to `[n] : SimplexCategory`. -/
@[simps obj map]
def toTop : SimplexCategory ⥤ TopCat where
obj x := TopCat.of x.toTopObj
map f := ⟨toTopMap f, by continuity⟩
map_id := by
classical
intro Δ
ext f
apply toTopObj.ext
funext i
change (Finset.univ.filter (· = i)).sum _ = _
simp [Finset.sum_filter, CategoryTheory.id_apply]
map_comp := fun f g => by
classical
ext h
apply toTopObj.ext
funext i
dsimp
simp only [comp_apply, TopCat.coe_of_of, ContinuousMap.coe_mk, coe_toTopMap]
rw [← Finset.sum_biUnion]
· apply Finset.sum_congr
· exact Finset.ext (fun j => ⟨fun hj => by simpa using hj, fun hj => by simpa using hj⟩)
· tauto
· apply Set.pairwiseDisjoint_filter
end SimplexCategory
|
AlgebraicTopology\DoldKan\Compatibility.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.CategoryTheory.Equivalence
/-! Tools for compatibilities between Dold-Kan equivalences
The purpose of this file is to introduce tools which will enable the
construction of the Dold-Kan equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
for a pseudoabelian category `C` from the equivalence
`Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)` and the two
equivalences `simplicial_object C ≅ Karoubi (SimplicialObject C)` and
`ChainComplex C ℕ ≅ Karoubi (ChainComplex C ℕ)`.
It is certainly possible to get an equivalence `SimplicialObject C ≌ ChainComplex C ℕ`
using a compositions of the three equivalences above, but then neither the functor
nor the inverse would have good definitional properties. For example, it would be better
if the inverse functor of the equivalence was exactly the functor
`Γ₀ : SimplicialObject C ⥤ ChainComplex C ℕ` which was constructed in `FunctorGamma.lean`.
In this file, given four categories `A`, `A'`, `B`, `B'`, equivalences `eA : A ≅ A'`,
`eB : B ≅ B'`, `e' : A' ≅ B'`, functors `F : A ⥤ B'`, `G : B ⥤ A` equipped with certain
compatibilities, we construct successive equivalences:
- `equivalence₀` from `A` to `B'`, which is the composition of `eA` and `e'`.
- `equivalence₁` from `A` to `B'`, with the same inverse functor as `equivalence₀`,
but whose functor is `F`.
- `equivalence₂` from `A` to `B`, which is the composition of `equivalence₁` and the
inverse of `eB`:
- `equivalence` from `A` to `B`, which has the same functor `F ⋙ eB.inverse` as `equivalence₂`,
but whose inverse functor is `G`.
When extra assumptions are given, we shall also provide simplification lemmas for the
unit and counit isomorphisms of `equivalence`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category
namespace AlgebraicTopology
namespace DoldKan
namespace Compatibility
variable {A A' B B' : Type*} [Category A] [Category A'] [Category B] [Category B'] (eA : A ≌ A')
(eB : B ≌ B') (e' : A' ≌ B') {F : A ⥤ B'} (hF : eA.functor ⋙ e'.functor ≅ F) {G : B ⥤ A}
(hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor)
/-- A basic equivalence `A ≅ B'` obtained by composing `eA : A ≅ A'` and `e' : A' ≅ B'`. -/
@[simps! functor inverse unitIso_hom_app]
def equivalence₀ : A ≌ B' :=
eA.trans e'
variable {eA} {e'}
/-- An intermediate equivalence `A ≅ B'` whose functor is `F` and whose inverse is
`e'.inverse ⋙ eA.inverse`. -/
@[simps! functor]
def equivalence₁ : A ≌ B' := (equivalence₀ eA e').changeFunctor hF
theorem equivalence₁_inverse : (equivalence₁ hF).inverse = e'.inverse ⋙ eA.inverse :=
rfl
/-- The counit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/
@[simps!]
def equivalence₁CounitIso : (e'.inverse ⋙ eA.inverse) ⋙ F ≅ 𝟭 B' :=
calc
(e'.inverse ⋙ eA.inverse) ⋙ F ≅ (e'.inverse ⋙ eA.inverse) ⋙ eA.functor ⋙ e'.functor :=
isoWhiskerLeft _ hF.symm
_ ≅ e'.inverse ⋙ (eA.inverse ⋙ eA.functor) ⋙ e'.functor := Iso.refl _
_ ≅ e'.inverse ⋙ 𝟭 _ ⋙ e'.functor := isoWhiskerLeft _ (isoWhiskerRight eA.counitIso _)
_ ≅ e'.inverse ⋙ e'.functor := Iso.refl _
_ ≅ 𝟭 B' := e'.counitIso
theorem equivalence₁CounitIso_eq : (equivalence₁ hF).counitIso = equivalence₁CounitIso hF := by
ext Y
simp [equivalence₁, equivalence₀]
/-- The unit isomorphism of the equivalence `equivalence₁` between `A` and `B'`. -/
@[simps!]
def equivalence₁UnitIso : 𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse :=
calc
𝟭 A ≅ eA.functor ⋙ eA.inverse := eA.unitIso
_ ≅ eA.functor ⋙ 𝟭 A' ⋙ eA.inverse := Iso.refl _
_ ≅ eA.functor ⋙ (e'.functor ⋙ e'.inverse) ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight e'.unitIso _)
_ ≅ (eA.functor ⋙ e'.functor) ⋙ e'.inverse ⋙ eA.inverse := Iso.refl _
_ ≅ F ⋙ e'.inverse ⋙ eA.inverse := isoWhiskerRight hF _
theorem equivalence₁UnitIso_eq : (equivalence₁ hF).unitIso = equivalence₁UnitIso hF := by
ext X
simp [equivalence₁]
/-- An intermediate equivalence `A ≅ B` obtained as the composition of `equivalence₁` and
the inverse of `eB : B ≌ B'`. -/
@[simps! functor]
def equivalence₂ : A ≌ B :=
(equivalence₁ hF).trans eB.symm
theorem equivalence₂_inverse :
(equivalence₂ eB hF).inverse = eB.functor ⋙ e'.inverse ⋙ eA.inverse :=
rfl
/-- The counit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/
@[simps!]
def equivalence₂CounitIso : (eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse ≅ 𝟭 B :=
calc
(eB.functor ⋙ e'.inverse ⋙ eA.inverse) ⋙ F ⋙ eB.inverse ≅
eB.functor ⋙ (e'.inverse ⋙ eA.inverse ⋙ F) ⋙ eB.inverse :=
Iso.refl _
_ ≅ eB.functor ⋙ 𝟭 _ ⋙ eB.inverse :=
isoWhiskerLeft _ (isoWhiskerRight (equivalence₁CounitIso hF) _)
_ ≅ eB.functor ⋙ eB.inverse := Iso.refl _
_ ≅ 𝟭 B := eB.unitIso.symm
theorem equivalence₂CounitIso_eq :
(equivalence₂ eB hF).counitIso = equivalence₂CounitIso eB hF := by
ext Y'
dsimp [equivalence₂, Iso.refl]
simp only [equivalence₁CounitIso_eq, equivalence₂CounitIso_hom_app,
equivalence₁CounitIso_hom_app, Functor.map_comp, assoc]
/-- The unit isomorphism of the equivalence `equivalence₂` between `A` and `B`. -/
@[simps!]
def equivalence₂UnitIso : 𝟭 A ≅ (F ⋙ eB.inverse) ⋙ eB.functor ⋙ e'.inverse ⋙ eA.inverse :=
calc
𝟭 A ≅ F ⋙ e'.inverse ⋙ eA.inverse := equivalence₁UnitIso hF
_ ≅ F ⋙ 𝟭 B' ⋙ e'.inverse ⋙ eA.inverse := Iso.refl _
_ ≅ F ⋙ (eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight eB.counitIso.symm _)
_ ≅ (F ⋙ eB.inverse) ⋙ eB.functor ⋙ e'.inverse ⋙ eA.inverse := Iso.refl _
theorem equivalence₂UnitIso_eq : (equivalence₂ eB hF).unitIso = equivalence₂UnitIso eB hF := by
ext X
dsimp [equivalence₂]
simp only [equivalence₂UnitIso_hom_app, equivalence₁UnitIso_eq, equivalence₁UnitIso_hom_app,
assoc, NatIso.cancel_natIso_hom_left]
rfl
variable {eB}
/-- The equivalence `A ≅ B` whose functor is `F ⋙ eB.inverse` and
whose inverse is `G : B ≅ A`. -/
@[simps! inverse]
def equivalence : A ≌ B :=
((equivalence₂ eB hF).changeInverse
(calc eB.functor ⋙ e'.inverse ⋙ eA.inverse ≅
(eB.functor ⋙ e'.inverse) ⋙ eA.inverse := (Functor.associator _ _ _).symm
_ ≅ (G ⋙ eA.functor) ⋙ eA.inverse := isoWhiskerRight hG _
_ ≅ G ⋙ 𝟭 A := isoWhiskerLeft _ eA.unitIso.symm
_ ≅ G := G.rightUnitor))
theorem equivalence_functor : (equivalence hF hG).functor = F ⋙ eB.inverse :=
rfl
/-- The isomorphism `eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor` deduced
from the counit isomorphism of `e'`. -/
@[simps! hom_app]
def τ₀ : eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor :=
calc
eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor ⋙ 𝟭 _ := isoWhiskerLeft _ e'.counitIso
_ ≅ eB.functor := Functor.rightUnitor _
/-- The isomorphism `eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor` deduced
from the isomorphisms `hF : eA.functor ⋙ e'.functor ≅ F`,
`hG : eB.functor ⋙ e'.inverse ≅ G ⋙ eA.functor` and the datum of
an isomorphism `η : G ⋙ F ≅ eB.functor`. -/
@[simps! hom_app]
def τ₁ (η : G ⋙ F ≅ eB.functor) : eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ eB.functor :=
calc
eB.functor ⋙ e'.inverse ⋙ e'.functor ≅ (eB.functor ⋙ e'.inverse) ⋙ e'.functor :=
Iso.refl _
_ ≅ (G ⋙ eA.functor) ⋙ e'.functor := isoWhiskerRight hG _
_ ≅ G ⋙ eA.functor ⋙ e'.functor := by rfl
_ ≅ G ⋙ F := isoWhiskerLeft _ hF
_ ≅ eB.functor := η
variable (η : G ⋙ F ≅ eB.functor)
/-- The counit isomorphism of `equivalence`. -/
@[simps!]
def equivalenceCounitIso : G ⋙ F ⋙ eB.inverse ≅ 𝟭 B :=
calc
G ⋙ F ⋙ eB.inverse ≅ (G ⋙ F) ⋙ eB.inverse := Iso.refl _
_ ≅ eB.functor ⋙ eB.inverse := isoWhiskerRight η _
_ ≅ 𝟭 B := eB.unitIso.symm
variable {η hF hG}
theorem equivalenceCounitIso_eq (hη : τ₀ = τ₁ hF hG η) :
(equivalence hF hG).counitIso = equivalenceCounitIso η := by
ext1; apply NatTrans.ext; ext Y
dsimp [equivalence]
simp only [comp_id, id_comp, Functor.map_comp, equivalence₂CounitIso_eq,
equivalence₂CounitIso_hom_app, assoc, equivalenceCounitIso_hom_app]
simp only [← eB.inverse.map_comp_assoc, ← τ₀_hom_app, hη, τ₁_hom_app]
erw [hF.inv.naturality_assoc, hF.inv.naturality_assoc]
dsimp
congr 2
simp only [← e'.functor.map_comp_assoc, Equivalence.fun_inv_map, assoc,
Iso.inv_hom_id_app_assoc, hG.inv_hom_id_app]
dsimp
rw [comp_id, eA.functor_unitIso_comp, e'.functor.map_id, id_comp, hF.inv_hom_id_app_assoc]
variable (hF)
/-- The isomorphism `eA.functor ≅ F ⋙ e'.inverse` deduced from the
unit isomorphism of `e'` and the isomorphism `hF : eA.functor ⋙ e'.functor ≅ F`. -/
@[simps!]
def υ : eA.functor ≅ F ⋙ e'.inverse :=
calc
eA.functor ≅ eA.functor ⋙ 𝟭 A' := (Functor.leftUnitor _).symm
_ ≅ eA.functor ⋙ e'.functor ⋙ e'.inverse := isoWhiskerLeft _ e'.unitIso
_ ≅ (eA.functor ⋙ e'.functor) ⋙ e'.inverse := Iso.refl _
_ ≅ F ⋙ e'.inverse := isoWhiskerRight hF _
variable (ε : eA.functor ≅ F ⋙ e'.inverse) (hG)
/-- The unit isomorphism of `equivalence`. -/
@[simps!]
def equivalenceUnitIso : 𝟭 A ≅ (F ⋙ eB.inverse) ⋙ G :=
calc
𝟭 A ≅ eA.functor ⋙ eA.inverse := eA.unitIso
_ ≅ (F ⋙ e'.inverse) ⋙ eA.inverse := isoWhiskerRight ε _
_ ≅ F ⋙ 𝟭 B' ⋙ e'.inverse ⋙ eA.inverse := Iso.refl _
_ ≅ F ⋙ (eB.inverse ⋙ eB.functor) ⋙ e'.inverse ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight eB.counitIso.symm _)
_ ≅ (F ⋙ eB.inverse) ⋙ (eB.functor ⋙ e'.inverse) ⋙ eA.inverse := Iso.refl _
_ ≅ (F ⋙ eB.inverse) ⋙ (G ⋙ eA.functor) ⋙ eA.inverse :=
isoWhiskerLeft _ (isoWhiskerRight hG _)
_ ≅ (F ⋙ eB.inverse ⋙ G) ⋙ eA.functor ⋙ eA.inverse := Iso.refl _
_ ≅ (F ⋙ eB.inverse ⋙ G) ⋙ 𝟭 A := isoWhiskerLeft _ eA.unitIso.symm
_ ≅ (F ⋙ eB.inverse) ⋙ G := Iso.refl _
variable {ε hF hG}
theorem equivalenceUnitIso_eq (hε : υ hF = ε) :
(equivalence hF hG).unitIso = equivalenceUnitIso hG ε := by
ext1; apply NatTrans.ext; ext X
dsimp [equivalence]
simp only [assoc, comp_id, equivalenceUnitIso_hom_app]
erw [id_comp]
simp only [equivalence₂UnitIso_eq eB hF, equivalence₂UnitIso_hom_app,
← eA.inverse.map_comp_assoc, assoc, ← hε, υ_hom_app]
end Compatibility
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Decomposition.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Decomposition of the Q endomorphisms
In this file, we obtain a lemma `decomposition_Q` which expresses
explicitly the projection `(Q q).f (n+1) : X _[n+1] ⟶ X _[n+1]`
(`X : SimplicialObject C` with `C` a preadditive category) as
a sum of terms which are postcompositions with degeneracies.
(TODO @joelriou: when `C` is abelian, define the degenerate
subcomplex of the alternating face map complex of `X` and show
that it is a complement to the normalized Moore complex.)
Then, we introduce an ad hoc structure `MorphComponents X n Z` which
can be used in order to define morphisms `X _[n+1] ⟶ Z` using the
decomposition provided by `decomposition_Q`. This shall play a critical
role in the proof that the functor
`N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))`
reflects isomorphisms.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
Opposite Simplicial
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X X' : SimplicialObject C}
/-- In each positive degree, this lemma decomposes the idempotent endomorphism
`Q q` as a sum of morphisms which are postcompositions with suitable degeneracies.
As `Q q` is the complement projection to `P q`, this implies that in the case of
simplicial abelian groups, any $(n+1)$-simplex $x$ can be decomposed as
$x = x' + \sum (i=0}^{q-1} σ_{n-i}(y_i)$ where $x'$ is in the image of `P q` and
the $y_i$ are in degree $n$. -/
theorem decomposition_Q (n q : ℕ) :
((Q q).f (n + 1) : X _[n + 1] ⟶ X _[n + 1]) =
∑ i ∈ Finset.filter (fun i : Fin (n + 1) => (i : ℕ) < q) Finset.univ,
(P i).f (n + 1) ≫ X.δ i.rev.succ ≫ X.σ (Fin.rev i) := by
induction' q with q hq
· simp only [Nat.zero_eq, Q_zero, HomologicalComplex.zero_f_apply, Nat.not_lt_zero,
Finset.filter_False, Finset.sum_empty]
· by_cases hqn : q + 1 ≤ n + 1
swap
· rw [Q_is_eventually_constant (show n + 1 ≤ q by omega), hq]
congr 1
ext ⟨x, hx⟩
simp only [Nat.succ_eq_add_one, Finset.mem_filter, Finset.mem_univ, true_and]
omega
· cases' Nat.le.dest (Nat.succ_le_succ_iff.mp hqn) with a ha
rw [Q_succ, HomologicalComplex.sub_f_apply, HomologicalComplex.comp_f, hq]
symm
conv_rhs => rw [sub_eq_add_neg, add_comm]
let q' : Fin (n + 1) := ⟨q, Nat.succ_le_iff.mp hqn⟩
rw [← @Finset.add_sum_erase _ _ _ _ _ _ q' (by simp)]
congr
· have hnaq' : n = a + q := by omega
simp only [Fin.val_mk, (HigherFacesVanish.of_P q n).comp_Hσ_eq hnaq',
q'.rev_eq hnaq', neg_neg]
rfl
· ext ⟨i, hi⟩
simp only [q', Nat.succ_eq_add_one, Nat.lt_succ_iff_lt_or_eq, Finset.mem_univ,
forall_true_left, Finset.mem_filter, lt_self_iff_false, or_true, and_self, not_true,
Finset.mem_erase, ne_eq, Fin.mk.injEq, true_and]
aesop
variable (X)
-- porting note (#5171): removed @[nolint has_nonempty_instance]
/-- The structure `MorphComponents` is an ad hoc structure that is used in
the proof that `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ))`
reflects isomorphisms. The fields are the data that are needed in order to
construct a morphism `X _[n+1] ⟶ Z` (see `φ`) using the decomposition of the
identity given by `decomposition_Q n (n+1)`. -/
@[ext]
structure MorphComponents (n : ℕ) (Z : C) where
a : X _[n + 1] ⟶ Z
b : Fin (n + 1) → (X _[n] ⟶ Z)
namespace MorphComponents
variable {X} {n : ℕ} {Z Z' : C} (f : MorphComponents X n Z) (g : X' ⟶ X) (h : Z ⟶ Z')
/-- The morphism `X _[n+1] ⟶ Z` associated to `f : MorphComponents X n Z`. -/
def φ {Z : C} (f : MorphComponents X n Z) : X _[n + 1] ⟶ Z :=
PInfty.f (n + 1) ≫ f.a + ∑ i : Fin (n + 1), (P i).f (n + 1) ≫ X.δ i.rev.succ ≫
f.b (Fin.rev i)
variable (X n)
/-- the canonical `MorphComponents` whose associated morphism is the identity
(see `F_id`) thanks to `decomposition_Q n (n+1)` -/
@[simps]
def id : MorphComponents X n (X _[n + 1]) where
a := PInfty.f (n + 1)
b i := X.σ i
@[simp]
theorem id_φ : (id X n).φ = 𝟙 _ := by
simp only [← P_add_Q_f (n + 1) (n + 1), φ]
congr 1
· simp only [id, PInfty_f, P_f_idem]
· exact Eq.trans (by congr; simp) (decomposition_Q n (n + 1)).symm
variable {X n}
/-- A `MorphComponents` can be postcomposed with a morphism. -/
@[simps]
def postComp : MorphComponents X n Z' where
a := f.a ≫ h
b i := f.b i ≫ h
@[simp]
theorem postComp_φ : (f.postComp h).φ = f.φ ≫ h := by
unfold φ postComp
simp only [add_comp, sum_comp, assoc]
/-- A `MorphComponents` can be precomposed with a morphism of simplicial objects. -/
@[simps]
def preComp : MorphComponents X' n Z where
a := g.app (op [n + 1]) ≫ f.a
b i := g.app (op [n]) ≫ f.b i
@[simp]
theorem preComp_φ : (f.preComp g).φ = g.app (op [n + 1]) ≫ f.φ := by
unfold φ preComp
simp only [PInfty_f, comp_add]
congr 1
· simp only [P_f_naturality_assoc]
· simp only [comp_sum, P_f_naturality_assoc, SimplicialObject.δ_naturality_assoc]
end MorphComponents
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Degeneracies.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.Decomposition
import Mathlib.Tactic.FinCases
/-!
# Behaviour of P_infty with respect to degeneracies
For any `X : SimplicialObject C` where `C` is an abelian category,
the projector `PInfty : K[X] ⟶ K[X]` is supposed to be the projection
on the normalized subcomplex, parallel to the degenerate subcomplex, i.e.
the subcomplex generated by the images of all `X.σ i`.
In this file, we obtain `degeneracy_comp_P_infty` which states that
if `X : SimplicialObject C` with `C` a preadditive category,
`θ : [n] ⟶ Δ'` is a non injective map in `SimplexCategory`, then
`X.map θ.op ≫ P_infty.f n = 0`. It follows from the more precise
statement vanishing statement `σ_comp_P_eq_zero` for the `P q`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Preadditive Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
theorem HigherFacesVanish.comp_σ {Y : C} {X : SimplicialObject C} {n b q : ℕ} {φ : Y ⟶ X _[n + 1]}
(v : HigherFacesVanish q φ) (hnbq : n + 1 = b + q) :
HigherFacesVanish q
(φ ≫
X.σ ⟨b, by
simp only [hnbq, Nat.lt_add_one_iff, le_add_iff_nonneg_right, zero_le]⟩) :=
fun j hj => by
rw [assoc, SimplicialObject.δ_comp_σ_of_gt', Fin.pred_succ, v.comp_δ_eq_zero_assoc _ _ hj,
zero_comp]
· dsimp
rw [Fin.lt_iff_val_lt_val, Fin.val_succ]
linarith
· intro hj'
simp only [hnbq, add_comm b, add_assoc, hj', Fin.val_zero, zero_add, add_le_iff_nonpos_right,
nonpos_iff_eq_zero, add_eq_zero, false_and] at hj
theorem σ_comp_P_eq_zero (X : SimplicialObject C) {n q : ℕ} (i : Fin (n + 1)) (hi : n + 1 ≤ i + q) :
X.σ i ≫ (P q).f (n + 1) = 0 := by
revert i hi
induction' q with q hq
· intro i (hi : n + 1 ≤ i)
exfalso
linarith [Fin.is_lt i]
· intro i (hi : n + 1 ≤ i + q + 1)
by_cases h : n + 1 ≤ (i : ℕ) + q
· rw [P_succ, HomologicalComplex.comp_f, ← assoc, hq i h, zero_comp]
· replace hi : n = i + q := by
obtain ⟨j, hj⟩ := le_iff_exists_add.mp hi
rw [← Nat.lt_succ_iff, Nat.succ_eq_add_one, hj, not_lt, add_le_iff_nonpos_right,
nonpos_iff_eq_zero] at h
rw [← add_left_inj 1, hj, self_eq_add_right, h]
rcases n with _|n
· fin_cases i
dsimp at h hi
rw [show q = 0 by omega]
change X.σ 0 ≫ (P 1).f 1 = 0
simp only [P_succ, HomologicalComplex.add_f_apply, comp_add,
HomologicalComplex.id_f, AlternatingFaceMapComplex.obj_d_eq, Hσ,
HomologicalComplex.comp_f, Homotopy.nullHomotopicMap'_f (c_mk 2 1 rfl) (c_mk 1 0 rfl),
comp_id]
erw [hσ'_eq' (zero_add 0).symm, hσ'_eq' (add_zero 1).symm, comp_id, Fin.sum_univ_two,
Fin.sum_univ_succ, Fin.sum_univ_two]
simp only [Fin.val_zero, pow_zero, pow_one, pow_add, one_smul, neg_smul, Fin.mk_one,
Fin.val_succ, Fin.val_one, Fin.succ_one_eq_two, P_zero, HomologicalComplex.id_f,
Fin.val_two, pow_two, mul_neg, one_mul, neg_mul, neg_neg, id_comp, add_comp,
comp_add, Fin.mk_zero, neg_comp, comp_neg, Fin.succ_zero_eq_one]
erw [SimplicialObject.δ_comp_σ_self, SimplicialObject.δ_comp_σ_self_assoc,
SimplicialObject.δ_comp_σ_succ, comp_id,
SimplicialObject.δ_comp_σ_of_le X
(show (0 : Fin 2) ≤ Fin.castSucc 0 by rw [Fin.castSucc_zero]),
SimplicialObject.δ_comp_σ_self_assoc, SimplicialObject.δ_comp_σ_succ_assoc]
simp only [add_right_neg, add_zero, zero_add]
· rw [← id_comp (X.σ i), ← (P_add_Q_f q n.succ : _ = 𝟙 (X.obj _)), add_comp, add_comp,
P_succ]
have v : HigherFacesVanish q ((P q).f n.succ ≫ X.σ i) :=
(HigherFacesVanish.of_P q n).comp_σ hi
erw [← assoc, v.comp_P_eq_self, HomologicalComplex.add_f_apply, Preadditive.comp_add,
comp_id, v.comp_Hσ_eq hi, assoc, SimplicialObject.δ_comp_σ_succ_assoc, Fin.eta,
decomposition_Q n q, sum_comp, sum_comp, Finset.sum_eq_zero, add_zero, add_neg_eq_zero]
intro j hj
simp only [true_and_iff, Finset.mem_univ, Finset.mem_filter] at hj
obtain ⟨k, hk⟩ := Nat.le.dest (Nat.lt_succ_iff.mp (Fin.is_lt j))
rw [add_comm] at hk
have hi' : i = Fin.castSucc ⟨i, by omega⟩ := by
ext
simp only [Fin.castSucc_mk, Fin.eta]
have eq := hq j.rev.succ (by
simp only [← hk, Fin.rev_eq j hk.symm, Nat.succ_eq_add_one, Fin.succ_mk, Fin.val_mk]
omega)
rw [HomologicalComplex.comp_f, assoc, assoc, assoc, hi',
SimplicialObject.σ_comp_σ_assoc, reassoc_of% eq, zero_comp, comp_zero, comp_zero,
comp_zero]
simp only [Fin.rev_eq j hk.symm, Fin.le_iff_val_le_val, Fin.val_mk]
omega
@[reassoc (attr := simp)]
theorem σ_comp_PInfty (X : SimplicialObject C) {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ PInfty.f (n + 1) = 0 := by
rw [PInfty_f, σ_comp_P_eq_zero X i]
simp only [le_add_iff_nonneg_left, zero_le]
@[reassoc]
theorem degeneracy_comp_PInfty (X : SimplicialObject C) (n : ℕ) {Δ' : SimplexCategory}
(θ : ([n] : SimplexCategory) ⟶ Δ') (hθ : ¬Mono θ) : X.map θ.op ≫ PInfty.f n = 0 := by
rw [SimplexCategory.mono_iff_injective] at hθ
cases n
· exfalso
apply hθ
intro x y h
fin_cases x
fin_cases y
rfl
· obtain ⟨i, α, h⟩ := SimplexCategory.eq_σ_comp_of_not_injective θ hθ
rw [h, op_comp, X.map_comp, assoc, show X.map (SimplexCategory.σ i).op = X.σ i by rfl,
σ_comp_PInfty, comp_zero]
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Equivalence.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.EquivalencePseudoabelian
import Mathlib.AlgebraicTopology.DoldKan.Normalized
/-!
# The Dold-Kan correspondence
The Dold-Kan correspondence states that for any abelian category `A`, there is
an equivalence between the category of simplicial objects in `A` and the
category of chain complexes in `A` (with degrees indexed by `ℕ` and the
homological convention that the degree is decreased by the differentials).
In this file, we finish the construction of this equivalence by providing
`CategoryTheory.Abelian.DoldKan.equivalence` which is of type
`SimplicialObject A ≌ ChainComplex A ℕ` for any abelian category `A`.
The functor `SimplicialObject A ⥤ ChainComplex A ℕ` of this equivalence is
definitionally equal to `normalizedMooreComplex A`.
## Overall strategy of the proof of the correspondence
Before starting the implementation of the proof in Lean, the author noticed
that the Dold-Kan equivalence not only applies to abelian categories, but
should also hold generally for any pseudoabelian category `C`
(i.e. a category with instances `[Preadditive C]`
`[HasFiniteCoproducts C]` and `[IsIdempotentComplete C]`): this is
`CategoryTheory.Idempotents.DoldKan.equivalence`.
When the alternating face map complex `K[X]` of a simplicial object `X` in an
abelian is studied, it is shown that it decomposes as a direct sum of the
normalized subcomplex and of the degenerate subcomplex. The crucial observation
is that in this decomposition, the projection on the normalized subcomplex can
be defined in each degree using simplicial operators. Then, the definition
of this projection `PInfty : K[X] ⟶ K[X]` can be carried out for any
`X : SimplicialObject C` when `C` is a preadditive category.
The construction of the endomorphism `PInfty` is done in the files
`Homotopies.lean`, `Faces.lean`, `Projections.lean` and `PInfty.lean`.
Eventually, as we would also like to show that the inclusion of the normalized
Moore complex is a homotopy equivalence (cf. file `HomotopyEquivalence.lean`),
this projection `PInfty` needs to be homotopic to the identity. In our
construction, we get this for free because `PInfty` is obtained by altering
the identity endomorphism by null homotopic maps. More details about this
aspect of the proof are in the file `Homotopies.lean`.
When the alternating face map complex `K[X]` is equipped with the idempotent
endomorphism `PInfty`, it becomes an object in `Karoubi (ChainComplex C ℕ)`
which is the idempotent completion of the category `ChainComplex C ℕ`. In `FunctorN.lean`,
we obtain this functor `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`,
which is formally extended as
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`. (Here, some functors
have an index which is the number of occurrences of `Karoubi` at the source or the
target.)
In `FunctorGamma.lean`, assuming that the category `C` is additive,
we define the functor in the other direction
`Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` as the formal
extension of a functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C` which is
defined similarly as in [*Simplicial Homotopy Theory* by Goerss-Jardine][goerss-jardine-2009].
In `Degeneracies.lean`, we show that `PInfty` vanishes on the image of degeneracy
operators, which is one of the key properties that makes it possible to contruct
the isomorphism `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`.
The rest of the proof follows the strategy in the [original paper by Dold][dold1958]. We show
that the functor `N₂` reflects isomorphisms in `NReflectsIso.lean`: this relies on a
decomposition of the identity of `X _[n]` using `PInfty.f n` and degeneracies obtained in
`Decomposition.lean`. Then, in `NCompGamma.lean`, we construct a natural transformation
`Γ₂N₂.trans : N₂ ⋙ Γ₂ ⟶ 𝟭 (Karoubi (SimplicialObject C))`. It is shown that it is an
isomorphism using the fact that `N₂` reflects isomorphisms, and because we can show
that the composition `N₂ ⟶ N₂ ⋙ Γ₂ ⋙ N₂ ⟶ N₂` is the identity (see `identity_N₂`). The fact
that `N₂` is defined as a formal direct factor makes the proof easier because we only
have to compare endomorphisms of an alternating face map complex `K[X]` and we do not
have to worry with inclusions of kernel subobjects.
In `EquivalenceAdditive.lean`, we obtain
the equivalence `equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`.
It is in the namespace `CategoryTheory.Preadditive.DoldKan`. The functors in this
equivalence are named `N` and `Γ`: by definition, they are `N₂` and `Γ₂`.
In `EquivalencePseudoabelian.lean`, assuming `C` is idempotent complete,
we obtain `equivalence : SimplicialObject C ≌ ChainComplex C ℕ`
in the namespace `CategoryTheory.Idempotents.DoldKan`. This could be roughly
obtained by composing the previous equivalence with the equivalences
`SimplicialObject C ≌ Karoubi (SimplicialObject C)` and
`Karoubi (ChainComplex C ℕ) ≌ ChainComplex C ℕ`. Instead, we polish this construction
in `Compatibility.lean` by ensuring good definitional properties of the equivalence (e.g.
the inverse functor is definitionally equal to
`Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject C`) and
showing compatibilities for the unit and counit isomorphisms.
In this file `Equivalence.lean`, assuming the category `A` is abelian, we obtain
`equivalence : SimplicialObject A ≌ ChainComplex A ℕ` in the namespace
`CategoryTheory.Abelian.DoldKan`. This is obtained by replacing the functor
`CategoryTheory.Idempotents.DoldKan.N` of the equivalence in the pseudoabelian case
with the isomorphic functor `normalizedMooreComplex A` thanks to the isomorphism
obtained in `Normalized.lean`.
TODO: Show functoriality properties of the three equivalences above. More precisely,
for example in the case of abelian categories `A` and `B`, if `F : A ⥤ B` is an
additive functor, we can show that the functors `N` for `A` and `B` are compatible
with the functors `SimplicialObject A ⥤ SimplicialObject B` and
`ChainComplex A ℕ ⥤ ChainComplex B ℕ` induced by `F`. (Note that this does not
require that `F` is an exact functor!)
TODO: Introduce the degenerate subcomplex `D[X]` which is generated by
degenerate simplices, show that the projector `PInfty` corresponds to
a decomposition `K[X] ≅ N[X] ⊞ D[X]`.
TODO: dualise all of this as `CosimplicialObject A ⥤ CochainComplex A ℕ`. (It is unclear
what is the best way to do this. The exact design may be decided when it is needed.)
## References
* [Albrecht Dold, Homology of Symmetric Products and Other Functors of Complexes][dold1958]
* [Paul G. Goerss, John F. Jardine, Simplicial Homotopy Theory][goerss-jardine-2009]
-/
noncomputable section
open CategoryTheory Category Idempotents
variable {A : Type*} [Category A] [Abelian A]
namespace CategoryTheory
namespace Abelian
namespace DoldKan
open AlgebraicTopology.DoldKan
/-- The functor `N` for the equivalence is `normalizedMooreComplex A` -/
def N : SimplicialObject A ⥤ ChainComplex A ℕ :=
AlgebraicTopology.normalizedMooreComplex A
/-- The functor `Γ` for the equivalence is the same as in the pseudoabelian case. -/
def Γ : ChainComplex A ℕ ⥤ SimplicialObject A :=
Idempotents.DoldKan.Γ
/-- The comparison isomorphism between `normalizedMooreComplex A` and
the functor `Idempotents.DoldKan.N` from the pseudoabelian case -/
@[simps!]
def comparisonN : (N : SimplicialObject A ⥤ _) ≅ Idempotents.DoldKan.N :=
calc
N ≅ N ⋙ 𝟭 _ := Functor.leftUnitor N
_ ≅ N ⋙ (toKaroubiEquivalence _).functor ⋙ (toKaroubiEquivalence _).inverse :=
isoWhiskerLeft _ (toKaroubiEquivalence _).unitIso
_ ≅ (N ⋙ (toKaroubiEquivalence _).functor) ⋙ (toKaroubiEquivalence _).inverse :=
Iso.refl _
_ ≅ N₁ ⋙ (toKaroubiEquivalence _).inverse :=
isoWhiskerRight (N₁_iso_normalizedMooreComplex_comp_toKaroubi A).symm _
_ ≅ Idempotents.DoldKan.N := Iso.refl _
/-- The Dold-Kan equivalence for abelian categories -/
@[simps! functor]
def equivalence : SimplicialObject A ≌ ChainComplex A ℕ :=
(Idempotents.DoldKan.equivalence (C := A)).changeFunctor comparisonN.symm
theorem equivalence_inverse : (equivalence : SimplicialObject A ≌ _).inverse = Γ :=
rfl
end DoldKan
end Abelian
end CategoryTheory
|
AlgebraicTopology\DoldKan\EquivalenceAdditive.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.NCompGamma
/-! The Dold-Kan equivalence for additive categories.
This file defines `Preadditive.DoldKan.equivalence` which is the equivalence
of categories `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Idempotents AlgebraicTopology.DoldKan
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Preadditive
namespace DoldKan
/-- The functor `Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def N : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ) :=
N₂
variable [HasFiniteCoproducts C]
/-- The inverse functor `Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)` of
the Dold-Kan equivalence for additive categories. -/
@[simp]
def Γ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C) :=
Γ₂
/-- The Dold-Kan equivalence `Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ)`
for additive categories. -/
@[simps]
def equivalence : Karoubi (SimplicialObject C) ≌ Karoubi (ChainComplex C ℕ) where
functor := N
inverse := Γ
unitIso := Γ₂N₂
counitIso := N₂Γ₂
functor_unitIso_comp P := by
let α := N.mapIso (Γ₂N₂.app P)
let β := N₂Γ₂.app (N.obj P)
symm
change 𝟙 _ = α.hom ≫ β.hom
rw [← Iso.inv_comp_eq, comp_id, ← comp_id β.hom, ← Iso.inv_comp_eq]
exact AlgebraicTopology.DoldKan.identity_N₂_objectwise P
end DoldKan
end Preadditive
end CategoryTheory
|
AlgebraicTopology\DoldKan\EquivalencePseudoabelian.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.EquivalenceAdditive
import Mathlib.AlgebraicTopology.DoldKan.Compatibility
import Mathlib.CategoryTheory.Idempotents.SimplicialObject
import Mathlib.Tactic.SuppressCompilation
/-!
# The Dold-Kan correspondence for pseudoabelian categories
In this file, for any idempotent complete additive category `C`,
the Dold-Kan equivalence
`Idempotents.DoldKan.Equivalence C : SimplicialObject C ≌ ChainComplex C ℕ`
is obtained. It is deduced from the equivalence
`Preadditive.DoldKan.Equivalence` between the respective idempotent
completions of these categories using the fact that when `C` is idempotent complete,
then both `SimplicialObject C` and `ChainComplex C ℕ` are idempotent complete.
The construction of `Idempotents.DoldKan.Equivalence` uses the tools
introduced in the file `Compatibility.lean`. Doing so, the functor
`Idempotents.DoldKan.N` of the equivalence is
the composition of `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`
(defined in `FunctorN.lean`) and the inverse of the equivalence
`ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. The functor
`Idempotents.DoldKan.Γ` of the equivalence is by definition the functor
`Γ₀` introduced in `FunctorGamma.lean`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
suppress_compilation
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents
variable {C : Type*} [Category C] [Preadditive C]
namespace CategoryTheory
namespace Idempotents
namespace DoldKan
open AlgebraicTopology.DoldKan
/-- The functor `N` for the equivalence is obtained by composing
`N' : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` and the inverse
of the equivalence `ChainComplex C ℕ ≌ Karoubi (ChainComplex C ℕ)`. -/
@[simps!, nolint unusedArguments]
def N [IsIdempotentComplete C] [HasFiniteCoproducts C] : SimplicialObject C ⥤ ChainComplex C ℕ :=
N₁ ⋙ (toKaroubiEquivalence _).inverse
/-- The functor `Γ` for the equivalence is `Γ'`. -/
@[simps!, nolint unusedArguments]
def Γ [IsIdempotentComplete C] [HasFiniteCoproducts C] : ChainComplex C ℕ ⥤ SimplicialObject C :=
Γ₀
variable [IsIdempotentComplete C] [HasFiniteCoproducts C]
/-- A reformulation of the isomorphism `toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁` -/
def isoN₁ :
(toKaroubiEquivalence (SimplicialObject C)).functor ⋙
Preadditive.DoldKan.equivalence.functor ≅ N₁ := toKaroubiCompN₂IsoN₁
@[simp]
lemma isoN₁_hom_app_f (X : SimplicialObject C) :
(isoN₁.hom.app X).f = PInfty := rfl
/-- A reformulation of the canonical isomorphism
`toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ≅ Γ ⋙ toKaroubi (SimplicialObject C)`. -/
def isoΓ₀ :
(toKaroubiEquivalence (ChainComplex C ℕ)).functor ⋙ Preadditive.DoldKan.equivalence.inverse ≅
Γ ⋙ (toKaroubiEquivalence _).functor :=
(functorExtension₂CompWhiskeringLeftToKaroubiIso _ _).app Γ₀
@[simp]
lemma N₂_map_isoΓ₀_hom_app_f (X : ChainComplex C ℕ) :
(N₂.map (isoΓ₀.hom.app X)).f = PInfty := by
ext
apply comp_id
/-- The Dold-Kan equivalence for pseudoabelian categories given
by the functors `N` and `Γ`. It is obtained by applying the results in
`Compatibility.lean` to the equivalence `Preadditive.DoldKan.Equivalence`. -/
def equivalence : SimplicialObject C ≌ ChainComplex C ℕ :=
Compatibility.equivalence isoN₁ isoΓ₀
theorem equivalence_functor : (equivalence : SimplicialObject C ≌ _).functor = N :=
rfl
theorem equivalence_inverse : (equivalence : SimplicialObject C ≌ _).inverse = Γ :=
rfl
/-- The natural isomorphism `NΓ' satisfies the compatibility that is needed
for the construction of our counit isomorphism `η` -/
theorem hη :
Compatibility.τ₀ =
Compatibility.τ₁ isoN₁ isoΓ₀
(N₁Γ₀ : Γ ⋙ N₁ ≅ (toKaroubiEquivalence (ChainComplex C ℕ)).functor) := by
ext K : 3
simp only [Compatibility.τ₀_hom_app, Compatibility.τ₁_hom_app]
exact (N₂Γ₂_compatible_with_N₁Γ₀ K).trans (by simp )
/-- The counit isomorphism induced by `N₁Γ₀` -/
@[simps!]
def η : Γ ⋙ N ≅ 𝟭 (ChainComplex C ℕ) :=
Compatibility.equivalenceCounitIso
(N₁Γ₀ : (Γ : ChainComplex C ℕ ⥤ _) ⋙ N₁ ≅ (toKaroubiEquivalence _).functor)
theorem equivalence_counitIso :
DoldKan.equivalence.counitIso = (η : Γ ⋙ N ≅ 𝟭 (ChainComplex C ℕ)) :=
Compatibility.equivalenceCounitIso_eq hη
theorem hε :
Compatibility.υ (isoN₁) =
(Γ₂N₁ : (toKaroubiEquivalence _).functor ≅
(N₁ : SimplicialObject C ⥤ _) ⋙ Preadditive.DoldKan.equivalence.inverse) := by
dsimp only [isoN₁]
ext1
rw [← cancel_epi Γ₂N₁.inv, Iso.inv_hom_id]
ext X : 2
rw [NatTrans.comp_app]
erw [compatibility_Γ₂N₁_Γ₂N₂_natTrans X]
rw [Compatibility.υ_hom_app, Preadditive.DoldKan.equivalence_unitIso, Iso.app_inv, assoc]
erw [← NatTrans.comp_app_assoc, IsIso.hom_inv_id]
rw [NatTrans.id_app, id_comp, NatTrans.id_app, Γ₂N₂ToKaroubiIso_inv_app]
dsimp only [Preadditive.DoldKan.equivalence_inverse, Preadditive.DoldKan.Γ]
rw [← Γ₂.map_comp, Iso.inv_hom_id_app, Γ₂.map_id]
rfl
/-- The unit isomorphism induced by `Γ₂N₁`. -/
def ε : 𝟭 (SimplicialObject C) ≅ N ⋙ Γ :=
Compatibility.equivalenceUnitIso isoΓ₀ Γ₂N₁
theorem equivalence_unitIso :
DoldKan.equivalence.unitIso = (ε : 𝟭 (SimplicialObject C) ≅ N ⋙ Γ) :=
Compatibility.equivalenceUnitIso_eq hε
end DoldKan
end Idempotents
end CategoryTheory
|
AlgebraicTopology\DoldKan\Faces.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.Homotopies
import Mathlib.Tactic.Ring
/-!
# Study of face maps for the Dold-Kan correspondence
In this file, we obtain the technical lemmas that are used in the file
`Projections.lean` in order to get basic properties of the endomorphisms
`P q : K[X] ⟶ K[X]` with respect to face maps (see `Homotopies.lean` for the
role of these endomorphisms in the overall strategy of proof).
The main lemma in this file is `HigherFacesVanish.induction`. It is based
on two technical lemmas `HigherFacesVanish.comp_Hσ_eq` and
`HigherFacesVanish.comp_Hσ_eq_zero`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Category
CategoryTheory.Preadditive CategoryTheory.SimplicialObject Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
variable {X : SimplicialObject C}
/-- A morphism `φ : Y ⟶ X _[n+1]` satisfies `HigherFacesVanish q φ`
when the compositions `φ ≫ X.δ j` are `0` for `j ≥ max 1 (n+2-q)`. When `q ≤ n+1`,
it basically means that the composition `φ ≫ X.δ j` are `0` for the `q` highest
possible values of a nonzero `j`. Otherwise, when `q ≥ n+2`, all the compositions
`φ ≫ X.δ j` for nonzero `j` vanish. See also the lemma `comp_P_eq_self_iff` in
`Projections.lean` which states that `HigherFacesVanish q φ` is equivalent to
the identity `φ ≫ (P q).f (n+1) = φ`. -/
def HigherFacesVanish {Y : C} {n : ℕ} (q : ℕ) (φ : Y ⟶ X _[n + 1]) : Prop :=
∀ j : Fin (n + 1), n + 1 ≤ (j : ℕ) + q → φ ≫ X.δ j.succ = 0
namespace HigherFacesVanish
@[reassoc]
theorem comp_δ_eq_zero {Y : C} {n : ℕ} {q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ)
(j : Fin (n + 2)) (hj₁ : j ≠ 0) (hj₂ : n + 2 ≤ (j : ℕ) + q) : φ ≫ X.δ j = 0 := by
obtain ⟨i, rfl⟩ := Fin.eq_succ_of_ne_zero hj₁
apply v i
simp only [Fin.val_succ] at hj₂
omega
theorem of_succ {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish (q + 1) φ) :
HigherFacesVanish q φ := fun j hj => v j (by simpa only [← add_assoc] using le_add_right hj)
theorem of_comp {Y Z : C} {q n : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ) (f : Z ⟶ Y) :
HigherFacesVanish q (f ≫ φ) := fun j hj => by rw [assoc, v j hj, comp_zero]
theorem comp_Hσ_eq {Y : C} {n a q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ)
(hnaq : n = a + q) :
φ ≫ (Hσ q).f (n + 1) =
-φ ≫ X.δ ⟨a + 1, Nat.succ_lt_succ (Nat.lt_succ_iff.mpr (Nat.le.intro hnaq.symm))⟩ ≫
X.σ ⟨a, Nat.lt_succ_iff.mpr (Nat.le.intro hnaq.symm)⟩ := by
have hnaq_shift : ∀ d : ℕ, n + d = a + d + q := by
intro d
rw [add_assoc, add_comm d, ← add_assoc, hnaq]
rw [Hσ, Homotopy.nullHomotopicMap'_f (c_mk (n + 2) (n + 1) rfl) (c_mk (n + 1) n rfl),
hσ'_eq hnaq (c_mk (n + 1) n rfl), hσ'_eq (hnaq_shift 1) (c_mk (n + 2) (n + 1) rfl)]
simp only [AlternatingFaceMapComplex.obj_d_eq, eqToHom_refl, comp_id, comp_sum, sum_comp,
comp_add]
simp only [comp_zsmul, zsmul_comp, ← assoc, ← mul_zsmul]
-- cleaning up the first sum
rw [← Fin.sum_congr' _ (hnaq_shift 2).symm, Fin.sum_trunc]
swap
· rintro ⟨k, hk⟩
suffices φ ≫ X.δ (⟨a + 2 + k, by omega⟩ : Fin (n + 2)) = 0 by
simp only [this, Fin.natAdd_mk, Fin.cast_mk, zero_comp, smul_zero]
convert v ⟨a + k + 1, by omega⟩ (by rw [Fin.val_mk]; omega)
dsimp
omega
-- cleaning up the second sum
rw [← Fin.sum_congr' _ (hnaq_shift 3).symm, @Fin.sum_trunc _ _ (a + 3)]
swap
· rintro ⟨k, hk⟩
rw [assoc, X.δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· simp only [Fin.lt_iff_val_lt_val]
dsimp [Fin.natAdd, Fin.cast]
omega
· intro h
rw [Fin.pred_eq_iff_eq_succ, Fin.ext_iff] at h
dsimp [Fin.cast] at h
omega
· dsimp [Fin.cast, Fin.pred]
rw [Nat.add_right_comm, Nat.add_sub_assoc (by norm_num : 1 ≤ 3)]
omega
simp only [assoc]
conv_lhs =>
congr
· rw [Fin.sum_univ_castSucc]
· rw [Fin.sum_univ_castSucc, Fin.sum_univ_castSucc]
dsimp [Fin.cast, Fin.castLE, Fin.castLT]
/- the purpose of the following `simplif` is to create three subgoals in order
to finish the proof -/
have simplif :
∀ a b c d e f : Y ⟶ X _[n + 1], b = f → d + e = 0 → c + a = 0 → a + b + (c + d + e) = f := by
intro a b c d e f h1 h2 h3
rw [add_assoc c d e, h2, add_zero, add_comm a, add_assoc, add_comm a, h3, add_zero, h1]
apply simplif
· -- b = f
rw [← pow_add, Odd.neg_one_pow, neg_smul, one_zsmul]
exact ⟨a, by omega⟩
· -- d + e = 0
rw [X.δ_comp_σ_self' (Fin.castSucc_mk _ _ _).symm,
X.δ_comp_σ_succ' (Fin.succ_mk _ _ _).symm]
simp only [comp_id, pow_add _ (a + 1) 1, pow_one, mul_neg, mul_one, neg_mul, neg_smul,
add_right_neg]
· -- c + a = 0
rw [← Finset.sum_add_distrib]
apply Finset.sum_eq_zero
rintro ⟨i, hi⟩ _
simp only
have hia : (⟨i, by omega⟩ : Fin (n + 2)) ≤
Fin.castSucc (⟨a, by omega⟩ : Fin (n + 1)) := by
rw [Fin.le_iff_val_le_val]
dsimp
omega
erw [δ_comp_σ_of_le X hia, add_eq_zero_iff_eq_neg, ← neg_zsmul]
congr 2
ring
theorem comp_Hσ_eq_zero {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ)
(hqn : n < q) : φ ≫ (Hσ q).f (n + 1) = 0 := by
simp only [Hσ, Homotopy.nullHomotopicMap'_f (c_mk (n + 2) (n + 1) rfl) (c_mk (n + 1) n rfl)]
rw [hσ'_eq_zero hqn (c_mk (n + 1) n rfl), comp_zero, zero_add]
by_cases hqn' : n + 1 < q
· rw [hσ'_eq_zero hqn' (c_mk (n + 2) (n + 1) rfl), zero_comp, comp_zero]
· simp only [hσ'_eq (show n + 1 = 0 + q by omega) (c_mk (n + 2) (n + 1) rfl), pow_zero,
Fin.mk_zero, one_zsmul, eqToHom_refl, comp_id, comp_sum,
AlternatingFaceMapComplex.obj_d_eq]
rw [← Fin.sum_congr' _ (show 2 + (n + 1) = n + 1 + 2 by omega), Fin.sum_trunc]
· simp only [Fin.sum_univ_castSucc, Fin.sum_univ_zero, zero_add, Fin.last, Fin.castLE_mk,
Fin.cast_mk, Fin.castSucc_mk]
simp only [Fin.mk_zero, Fin.val_zero, pow_zero, one_zsmul, Fin.mk_one, Fin.val_one, pow_one,
neg_smul, comp_neg]
erw [δ_comp_σ_self, δ_comp_σ_succ, add_right_neg]
· intro j
dsimp [Fin.cast, Fin.castLE, Fin.castLT]
rw [comp_zsmul, comp_zsmul, δ_comp_σ_of_gt', v.comp_δ_eq_zero_assoc, zero_comp, zsmul_zero]
· simp only [Fin.lt_iff_val_lt_val]
dsimp [Fin.succ]
omega
· intro h
simp only [Fin.pred, Fin.subNat, Fin.ext_iff, Nat.succ_add_sub_one,
Fin.val_zero, add_eq_zero, false_and] at h
· simp only [Fin.pred, Fin.subNat, Nat.pred_eq_sub_one, Nat.succ_add_sub_one]
omega
theorem induction {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ) :
HigherFacesVanish (q + 1) (φ ≫ (𝟙 _ + Hσ q).f (n + 1)) := by
intro j hj₁
dsimp
simp only [comp_add, add_comp, comp_id]
-- when n < q, the result follows immediately from the assumption
by_cases hqn : n < q
· rw [v.comp_Hσ_eq_zero hqn, zero_comp, add_zero, v j (by omega)]
-- we now assume that n≥q, and write n=a+q
cases' Nat.le.dest (not_lt.mp hqn) with a ha
rw [v.comp_Hσ_eq (show n = a + q by omega), neg_comp, add_neg_eq_zero, assoc, assoc]
cases' n with m hm
-- the boundary case n=0
· simp only [Nat.eq_zero_of_add_eq_zero_left ha, Fin.eq_zero j, Fin.mk_zero, Fin.mk_one,
δ_comp_σ_succ, comp_id]
rfl
-- in the other case, we need to write n as m+1
-- then, we first consider the particular case j = a
by_cases hj₂ : a = (j : ℕ)
· simp only [hj₂, Fin.eta, δ_comp_σ_succ, comp_id]
rfl
-- now, we assume j ≠ a (i.e. a < j)
have haj : a < j := (Ne.le_iff_lt hj₂).mp (by omega)
have ham : a ≤ m := by
by_contra h
rw [not_le, ← Nat.succ_le_iff] at h
omega
rw [X.δ_comp_σ_of_gt', j.pred_succ]
swap
· rw [Fin.lt_iff_val_lt_val]
simpa only [Fin.val_mk, Fin.val_succ, add_lt_add_iff_right] using haj
obtain _ | ham'' := ham.lt_or_eq
· -- case where `a<m`
rw [← X.δ_comp_δ''_assoc]
swap
· rw [Fin.le_iff_val_le_val]
dsimp
linarith
simp only [← assoc, v j (by omega), zero_comp]
· -- in the last case, a=m, q=1 and j=a+1
rw [X.δ_comp_δ_self'_assoc]
swap
· ext
cases j
dsimp
dsimp only [Nat.succ_eq_add_one] at *
omega
simp only [← assoc, v j (by omega), zero_comp]
end HigherFacesVanish
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\FunctorGamma.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.SplitSimplicialObject
import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Construction of the inverse functor of the Dold-Kan equivalence
In this file, we construct the functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`
which shall be the inverse functor of the Dold-Kan equivalence in the case of abelian categories,
and more generally pseudoabelian categories.
By definition, when `K` is a chain_complex, `Γ₀.obj K` is a simplicial object which
sends `Δ : SimplexCategoryᵒᵖ` to a certain coproduct indexed by the set
`Splitting.IndexSet Δ` whose elements consists of epimorphisms `e : Δ.unop ⟶ Δ'.unop`
(with `Δ' : SimplexCategoryᵒᵖ`); the summand attached to such an `e` is `K.X Δ'.unop.len`.
By construction, `Γ₀.obj K` is a split simplicial object whose splitting is `Γ₀.splitting K`.
We also construct `Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C)`
which shall be an equivalence for any additive category `C`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits SimplexCategory
SimplicialObject Opposite CategoryTheory.Idempotents Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] (K K' : ChainComplex C ℕ) (f : K ⟶ K')
{Δ Δ' Δ'' : SimplexCategory}
/-- `Isδ₀ i` is a simple condition used to check whether a monomorphism `i` in
`SimplexCategory` identifies to the coface map `δ 0`. -/
@[nolint unusedArguments]
def Isδ₀ {Δ Δ' : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] : Prop :=
Δ.len = Δ'.len + 1 ∧ i.toOrderHom 0 ≠ 0
namespace Isδ₀
theorem iff {j : ℕ} {i : Fin (j + 2)} : Isδ₀ (SimplexCategory.δ i) ↔ i = 0 := by
constructor
· rintro ⟨_, h₂⟩
by_contra h
exact h₂ (Fin.succAbove_ne_zero_zero h)
· rintro rfl
exact ⟨rfl, by dsimp; exact Fin.succ_ne_zero (0 : Fin (j + 1))⟩
theorem eq_δ₀ {n : ℕ} {i : ([n] : SimplexCategory) ⟶ [n + 1]} [Mono i] (hi : Isδ₀ i) :
i = SimplexCategory.δ 0 := by
obtain ⟨j, rfl⟩ := SimplexCategory.eq_δ_of_mono i
rw [iff] at hi
rw [hi]
end Isδ₀
namespace Γ₀
namespace Obj
/-- In the definition of `(Γ₀.obj K).obj Δ` as a direct sum indexed by `A : Splitting.IndexSet Δ`,
the summand `summand K Δ A` is `K.X A.1.len`. -/
def summand (Δ : SimplexCategoryᵒᵖ) (A : Splitting.IndexSet Δ) : C :=
K.X A.1.unop.len
/-- The functor `Γ₀` sends a chain complex `K` to the simplicial object which
sends `Δ` to the direct sum of the objects `summand K Δ A` for all `A : Splitting.IndexSet Δ` -/
def obj₂ (K : ChainComplex C ℕ) (Δ : SimplexCategoryᵒᵖ) [HasFiniteCoproducts C] : C :=
∐ fun A : Splitting.IndexSet Δ => summand K Δ A
namespace Termwise
/-- A monomorphism `i : Δ' ⟶ Δ` induces a morphism `K.X Δ.len ⟶ K.X Δ'.len` which
is the identity if `Δ = Δ'`, the differential on the complex `K` if `i = δ 0`, and
zero otherwise. -/
def mapMono (K : ChainComplex C ℕ) {Δ' Δ : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] :
K.X Δ.len ⟶ K.X Δ'.len := by
by_cases Δ = Δ'
· exact eqToHom (by congr)
· by_cases Isδ₀ i
· exact K.d Δ.len Δ'.len
· exact 0
variable (Δ)
theorem mapMono_id : mapMono K (𝟙 Δ) = 𝟙 _ := by
unfold mapMono
simp only [eq_self_iff_true, eqToHom_refl, dite_eq_ite, if_true]
variable {Δ}
theorem mapMono_δ₀' (i : Δ' ⟶ Δ) [Mono i] (hi : Isδ₀ i) : mapMono K i = K.d Δ.len Δ'.len := by
unfold mapMono
suffices Δ ≠ Δ' by
simp only [dif_neg this, dif_pos hi]
rintro rfl
simpa only [self_eq_add_right, Nat.one_ne_zero] using hi.1
@[simp]
theorem mapMono_δ₀ {n : ℕ} : mapMono K (δ (0 : Fin (n + 2))) = K.d (n + 1) n :=
mapMono_δ₀' K _ (by rw [Isδ₀.iff])
theorem mapMono_eq_zero (i : Δ' ⟶ Δ) [Mono i] (h₁ : Δ ≠ Δ') (h₂ : ¬Isδ₀ i) : mapMono K i = 0 := by
unfold mapMono
rw [Ne] at h₁
split_ifs
rfl
variable {K K'}
@[reassoc (attr := simp)]
theorem mapMono_naturality (i : Δ ⟶ Δ') [Mono i] :
mapMono K i ≫ f.f Δ.len = f.f Δ'.len ≫ mapMono K' i := by
unfold mapMono
split_ifs with h
· subst h
simp only [id_comp, eqToHom_refl, comp_id]
· rw [HomologicalComplex.Hom.comm]
· rw [zero_comp, comp_zero]
variable (K)
@[reassoc (attr := simp)]
theorem mapMono_comp (i' : Δ'' ⟶ Δ') (i : Δ' ⟶ Δ) [Mono i'] [Mono i] :
mapMono K i ≫ mapMono K i' = mapMono K (i' ≫ i) := by
-- case where i : Δ' ⟶ Δ is the identity
by_cases h₁ : Δ = Δ'
· subst h₁
simp only [SimplexCategory.eq_id_of_mono i, comp_id, id_comp, mapMono_id K, eqToHom_refl]
-- case where i' : Δ'' ⟶ Δ' is the identity
by_cases h₂ : Δ' = Δ''
· subst h₂
simp only [SimplexCategory.eq_id_of_mono i', comp_id, id_comp, mapMono_id K, eqToHom_refl]
-- then the RHS is always zero
obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i h₁)
obtain ⟨k', hk'⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i' h₂)
have eq : Δ.len = Δ''.len + (k + k' + 2) := by omega
rw [mapMono_eq_zero K (i' ≫ i) _ _]; rotate_left
· by_contra h
simp only [self_eq_add_right, h, add_eq_zero_iff, and_false] at eq
· by_contra h
simp only [h.1, add_right_inj] at eq
omega
-- in all cases, the LHS is also zero, either by definition, or because d ≫ d = 0
by_cases h₃ : Isδ₀ i
· by_cases h₄ : Isδ₀ i'
· rw [mapMono_δ₀' K i h₃, mapMono_δ₀' K i' h₄, HomologicalComplex.d_comp_d]
· simp only [mapMono_eq_zero K i' h₂ h₄, comp_zero]
· simp only [mapMono_eq_zero K i h₁ h₃, zero_comp]
end Termwise
variable [HasFiniteCoproducts C]
/-- The simplicial morphism on the simplicial object `Γ₀.obj K` induced by
a morphism `Δ' → Δ` in `SimplexCategory` is defined on each summand
associated to an `A : Splitting.IndexSet Δ` in terms of the epi-mono factorisation
of `θ ≫ A.e`. -/
def map (K : ChainComplex C ℕ) {Δ' Δ : SimplexCategoryᵒᵖ} (θ : Δ ⟶ Δ') : obj₂ K Δ ⟶ obj₂ K Δ' :=
Sigma.desc fun A =>
Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫ Sigma.ι (summand K Δ') (A.pull θ)
@[reassoc]
theorem map_on_summand₀ {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) {θ : Δ ⟶ Δ'}
{Δ'' : SimplexCategory} {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [Epi e] [Mono i]
(fac : e ≫ i = θ.unop ≫ A.e) :
Sigma.ι (summand K Δ) A ≫ map K θ =
Termwise.mapMono K i ≫ Sigma.ι (summand K Δ') (Splitting.IndexSet.mk e) := by
simp only [map, colimit.ι_desc, Cofan.mk_ι_app]
have h := SimplexCategory.image_eq fac
subst h
congr
· exact SimplexCategory.image_ι_eq fac
· dsimp only [SimplicialObject.Splitting.IndexSet.pull]
congr
exact SimplexCategory.factorThruImage_eq fac
@[reassoc]
theorem map_on_summand₀' {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ') :
Sigma.ι (summand K Δ) A ≫ map K θ =
Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫ Sigma.ι (summand K _) (A.pull θ) :=
map_on_summand₀ K A (A.fac_pull θ)
end Obj
variable [HasFiniteCoproducts C]
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, on objects. -/
@[simps]
def obj (K : ChainComplex C ℕ) : SimplicialObject C where
obj Δ := Obj.obj₂ K Δ
map θ := Obj.map K θ
map_id Δ := colimit.hom_ext (fun ⟨A⟩ => by
dsimp
have fac : A.e ≫ 𝟙 A.1.unop = (𝟙 Δ).unop ≫ A.e := by rw [unop_id, comp_id, id_comp]
erw [Obj.map_on_summand₀ K A fac, Obj.Termwise.mapMono_id, id_comp, comp_id]
rfl)
map_comp {Δ'' Δ' Δ} θ' θ := colimit.hom_ext (fun ⟨A⟩ => by
have fac : θ.unop ≫ θ'.unop ≫ A.e = (θ' ≫ θ).unop ≫ A.e := by rw [unop_comp, assoc]
rw [← image.fac (θ'.unop ≫ A.e), ← assoc, ←
image.fac (θ.unop ≫ factorThruImage (θ'.unop ≫ A.e)), assoc] at fac
simp only [Obj.map_on_summand₀'_assoc K A θ', Obj.map_on_summand₀' K _ θ,
Obj.Termwise.mapMono_comp_assoc, Obj.map_on_summand₀ K A fac]
rfl)
/-- By construction, the simplicial `Γ₀.obj K` is equipped with a splitting. -/
def splitting (K : ChainComplex C ℕ) : SimplicialObject.Splitting (Γ₀.obj K) where
N n := K.X n
ι n := Sigma.ι (Γ₀.Obj.summand K (op [n])) (Splitting.IndexSet.id (op [n]))
isColimit' Δ := IsColimit.ofIsoColimit (colimit.isColimit _) (Cofan.ext (Iso.refl _) (by
intro A
dsimp [Splitting.cofan']
rw [comp_id, Γ₀.Obj.map_on_summand₀ K (SimplicialObject.Splitting.IndexSet.id A.1)
(show A.e ≫ 𝟙 _ = A.e.op.unop ≫ 𝟙 _ by rfl), Γ₀.Obj.Termwise.mapMono_id]
dsimp
rw [id_comp]
rfl))
@[reassoc]
theorem Obj.map_on_summand {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ')
{Δ'' : SimplexCategory} {e : Δ'.unop ⟶ Δ''} {i : Δ'' ⟶ A.1.unop} [Epi e] [Mono i]
(fac : e ≫ i = θ.unop ≫ A.e) :
((Γ₀.splitting K).cofan Δ).inj A ≫ (Γ₀.obj K).map θ =
Γ₀.Obj.Termwise.mapMono K i ≫ ((Γ₀.splitting K).cofan Δ').inj (Splitting.IndexSet.mk e) := by
dsimp [Splitting.cofan]
change (_ ≫ (Γ₀.obj K).map A.e.op) ≫ (Γ₀.obj K).map θ = _
rw [assoc, ← Functor.map_comp]
dsimp [splitting]
erw [Γ₀.Obj.map_on_summand₀ K (Splitting.IndexSet.id A.1)
(show e ≫ i = ((Splitting.IndexSet.e A).op ≫ θ).unop ≫ 𝟙 _ by rw [comp_id, fac]; rfl),
Γ₀.Obj.map_on_summand₀ K (Splitting.IndexSet.id (op Δ''))
(show e ≫ 𝟙 Δ'' = e.op.unop ≫ 𝟙 _ by simp), Termwise.mapMono_id, id_comp]
@[reassoc]
theorem Obj.map_on_summand' {Δ Δ' : SimplexCategoryᵒᵖ} (A : Splitting.IndexSet Δ) (θ : Δ ⟶ Δ') :
((splitting K).cofan Δ).inj A ≫ (obj K).map θ =
Obj.Termwise.mapMono K (image.ι (θ.unop ≫ A.e)) ≫
((splitting K).cofan Δ').inj (A.pull θ) := by
apply Obj.map_on_summand
apply image.fac
@[reassoc]
theorem Obj.mapMono_on_summand_id {Δ Δ' : SimplexCategory} (i : Δ' ⟶ Δ) [Mono i] :
((splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ)) ≫ (obj K).map i.op =
Obj.Termwise.mapMono K i ≫ ((splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ')) :=
Obj.map_on_summand K (Splitting.IndexSet.id (op Δ)) i.op (rfl : 𝟙 _ ≫ i = i ≫ 𝟙 _)
@[reassoc]
theorem Obj.map_epi_on_summand_id {Δ Δ' : SimplexCategory} (e : Δ' ⟶ Δ) [Epi e] :
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op Δ)) ≫ (Γ₀.obj K).map e.op =
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.mk e) := by
simpa only [Γ₀.Obj.map_on_summand K (Splitting.IndexSet.id (op Δ)) e.op
(rfl : e ≫ 𝟙 Δ = e ≫ 𝟙 Δ),
Γ₀.Obj.Termwise.mapMono_id] using id_comp _
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, on morphisms. -/
@[simps]
def map {K K' : ChainComplex C ℕ} (f : K ⟶ K') : obj K ⟶ obj K' where
app Δ := (Γ₀.splitting K).desc Δ fun A => f.f A.1.unop.len ≫
((Γ₀.splitting K').cofan _).inj A
naturality {Δ' Δ} θ := by
apply (Γ₀.splitting K).hom_ext'
intro A
simp only [(splitting K).ι_desc_assoc, Obj.map_on_summand'_assoc K _ θ, (splitting K).ι_desc,
assoc, Obj.map_on_summand' K' _ θ]
apply Obj.Termwise.mapMono_naturality_assoc
end Γ₀
variable [HasFiniteCoproducts C]
/-- The functor `Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject.Split C`
that induces `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, which
shall be the inverse functor of the Dold-Kan equivalence for
abelian or pseudo-abelian categories. -/
@[simps]
def Γ₀' : ChainComplex C ℕ ⥤ SimplicialObject.Split C where
obj K := SimplicialObject.Split.mk' (Γ₀.splitting K)
map {K K'} f :=
{ F := Γ₀.map f
f := f.f
comm := fun n => by
dsimp
simp only [← Splitting.cofan_inj_id, (Γ₀.splitting K).ι_desc]
rfl }
/-- The functor `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`, which is
the inverse functor of the Dold-Kan equivalence when `C` is an abelian
category, or more generally a pseudoabelian category. -/
@[simps!]
def Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C :=
Γ₀' ⋙ Split.forget _
/-- The extension of `Γ₀ : ChainComplex C ℕ ⥤ SimplicialObject C`
on the idempotent completions. It shall be an equivalence of categories
for any additive category `C`. -/
@[simps!]
def Γ₂ : Karoubi (ChainComplex C ℕ) ⥤ Karoubi (SimplicialObject C) :=
(CategoryTheory.Idempotents.functorExtension₂ _ _).obj Γ₀
theorem HigherFacesVanish.on_Γ₀_summand_id (K : ChainComplex C ℕ) (n : ℕ) :
@HigherFacesVanish C _ _ (Γ₀.obj K) _ n (n + 1)
(((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op [n + 1]))) := by
intro j _
have eq := Γ₀.Obj.mapMono_on_summand_id K (SimplexCategory.δ j.succ)
rw [Γ₀.Obj.Termwise.mapMono_eq_zero K, zero_comp] at eq; rotate_left
· intro h
exact (Nat.succ_ne_self n) (congr_arg SimplexCategory.len h)
· exact fun h => Fin.succ_ne_zero j (by simpa only [Isδ₀.iff] using h)
exact eq
@[reassoc (attr := simp)]
theorem PInfty_on_Γ₀_splitting_summand_eq_self (K : ChainComplex C ℕ) {n : ℕ} :
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op [n])) ≫
(PInfty : K[Γ₀.obj K] ⟶ _).f n =
((Γ₀.splitting K).cofan _).inj (Splitting.IndexSet.id (op [n])) := by
rw [PInfty_f]
rcases n with _|n
· simpa only [P_f_0_eq] using comp_id _
· exact (HigherFacesVanish.on_Γ₀_summand_id K n).comp_P_eq_self
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\FunctorN.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.PInfty
/-!
# Construction of functors N for the Dold-Kan correspondence
In this file, we construct functors `N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)`
and `N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
for any preadditive category `C`. (The indices of these functors are the number of occurrences
of `Karoubi` at the source or the target.)
In the case `C` is additive, the functor `N₂` shall be the functor of the equivalence
`CategoryTheory.Preadditive.DoldKan.equivalence` defined in `EquivalenceAdditive.lean`.
In the case the category `C` is pseudoabelian, the composition of `N₁` with the inverse of the
equivalence `ChainComplex C ℕ ⥤ Karoubi (ChainComplex C ℕ)` will be the functor
`CategoryTheory.Idempotents.DoldKan.N` of the equivalence of categories
`CategoryTheory.Idempotents.DoldKan.equivalence : SimplicialObject C ≌ ChainComplex C ℕ`
defined in `EquivalencePseudoabelian.lean`.
When the category `C` is abelian, a relation between `N₁` and the
normalized Moore complex functor shall be obtained in `Normalized.lean`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Idempotents
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
/-- The functor `SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` which maps
`X` to the formal direct factor of `K[X]` defined by `PInfty`. -/
@[simps]
def N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ) where
obj X :=
{ X := AlternatingFaceMapComplex.obj X
p := PInfty
idem := PInfty_idem }
map f :=
{ f := PInfty ≫ AlternatingFaceMapComplex.map f }
/-- The extension of `N₁` to the Karoubi envelope of `SimplicialObject C`. -/
@[simps!]
def N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ) :=
(functorExtension₁ _ _).obj N₁
/-- The canonical isomorphism `toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁`. -/
def toKaroubiCompN₂IsoN₁ : toKaroubi (SimplicialObject C) ⋙ N₂ ≅ N₁ :=
(functorExtension₁CompWhiskeringLeftToKaroubiIso _ _).app N₁
@[simp]
lemma toKaroubiCompN₂IsoN₁_hom_app (X : SimplicialObject C) :
(toKaroubiCompN₂IsoN₁.hom.app X).f = PInfty := rfl
@[simp]
lemma toKaroubiCompN₂IsoN₁_inv_app (X : SimplicialObject C) :
(toKaroubiCompN₂IsoN₁.inv.app X).f = PInfty := rfl
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\GammaCompN.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.FunctorGamma
import Mathlib.AlgebraicTopology.DoldKan.SplitSimplicialObject
import Mathlib.CategoryTheory.Idempotents.HomologicalComplex
/-! The counit isomorphism of the Dold-Kan equivalence
The purpose of this file is to construct natural isomorphisms
`N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)`
and `N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ))`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Idempotents Opposite SimplicialObject Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C]
/-- The isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for all `K : ChainComplex C ℕ`. -/
@[simps!]
def Γ₀NondegComplexIso (K : ChainComplex C ℕ) : (Γ₀.splitting K).nondegComplex ≅ K :=
HomologicalComplex.Hom.isoOfComponents (fun n => Iso.refl _)
(by
rintro _ n (rfl : n + 1 = _)
dsimp
simp only [id_comp, comp_id, AlternatingFaceMapComplex.obj_d_eq, Preadditive.sum_comp,
Preadditive.comp_sum]
rw [Fintype.sum_eq_single (0 : Fin (n + 2))]
· simp only [Fin.val_zero, pow_zero, one_zsmul]
erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_δ₀,
Splitting.cofan_inj_πSummand_eq_id, comp_id]
· intro i hi
dsimp
simp only [Preadditive.zsmul_comp, Preadditive.comp_zsmul, assoc]
erw [Γ₀.Obj.mapMono_on_summand_id_assoc, Γ₀.Obj.Termwise.mapMono_eq_zero, zero_comp,
zsmul_zero]
· intro h
replace h := congr_arg SimplexCategory.len h
change n + 1 = n at h
omega
· simpa only [Isδ₀.iff] using hi)
/-- The natural isomorphism `(Γ₀.splitting K).nondegComplex ≅ K` for `K : ChainComplex C ℕ`. -/
def Γ₀'CompNondegComplexFunctor : Γ₀' ⋙ Split.nondegComplexFunctor ≅ 𝟭 (ChainComplex C ℕ) :=
NatIso.ofComponents Γ₀NondegComplexIso
/-- The natural isomorphism `Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ)`. -/
def N₁Γ₀ : Γ₀ ⋙ N₁ ≅ toKaroubi (ChainComplex C ℕ) :=
calc
Γ₀ ⋙ N₁ ≅ Γ₀' ⋙ Split.forget C ⋙ N₁ := Functor.associator _ _ _
_ ≅ Γ₀' ⋙ Split.nondegComplexFunctor ⋙ toKaroubi _ :=
(isoWhiskerLeft Γ₀' Split.toKaroubiNondegComplexFunctorIsoN₁.symm)
_ ≅ (Γ₀' ⋙ Split.nondegComplexFunctor) ⋙ toKaroubi _ := (Functor.associator _ _ _).symm
_ ≅ 𝟭 _ ⋙ toKaroubi (ChainComplex C ℕ) := isoWhiskerRight Γ₀'CompNondegComplexFunctor _
_ ≅ toKaroubi (ChainComplex C ℕ) := Functor.leftUnitor _
theorem N₁Γ₀_app (K : ChainComplex C ℕ) :
N₁Γ₀.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.symm ≪≫
(toKaroubi _).mapIso (Γ₀NondegComplexIso K) := by
ext1
dsimp [N₁Γ₀]
erw [id_comp, comp_id, comp_id]
rfl
theorem N₁Γ₀_hom_app (K : ChainComplex C ℕ) :
N₁Γ₀.hom.app K = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv ≫
(toKaroubi _).map (Γ₀NondegComplexIso K).hom := by
change (N₁Γ₀.app K).hom = _
simp only [N₁Γ₀_app]
rfl
theorem N₁Γ₀_inv_app (K : ChainComplex C ℕ) :
N₁Γ₀.inv.app K = (toKaroubi _).map (Γ₀NondegComplexIso K).inv ≫
(Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom := by
change (N₁Γ₀.app K).inv = _
simp only [N₁Γ₀_app]
rfl
@[simp]
theorem N₁Γ₀_hom_app_f_f (K : ChainComplex C ℕ) (n : ℕ) :
(N₁Γ₀.hom.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.inv.f.f n := by
rw [N₁Γ₀_hom_app]
apply comp_id
@[simp]
theorem N₁Γ₀_inv_app_f_f (K : ChainComplex C ℕ) (n : ℕ) :
(N₁Γ₀.inv.app K).f.f n = (Γ₀.splitting K).toKaroubiNondegComplexIsoN₁.hom.f.f n := by
rw [N₁Γ₀_inv_app]
apply id_comp
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] N₁Γ₀
/-- Compatibility isomorphism between `toKaroubi _ ⋙ Γ₂ ⋙ N₂` and `Γ₀ ⋙ N₁` which
are functors `ChainComplex C ℕ ⥤ Karoubi (ChainComplex C ℕ)`. -/
def N₂Γ₂ToKaroubiIso : toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ⋙ N₂ ≅ Γ₀ ⋙ N₁ :=
calc
toKaroubi (ChainComplex C ℕ) ⋙ Γ₂ ⋙ N₂ ≅
toKaroubi (ChainComplex C ℕ) ⋙ (Γ₂ ⋙ N₂) := (Functor.associator _ _ _).symm
_ ≅ (Γ₀ ⋙ toKaroubi (SimplicialObject C)) ⋙ N₂ :=
isoWhiskerRight ((functorExtension₂CompWhiskeringLeftToKaroubiIso _ _).app Γ₀) N₂
_ ≅ Γ₀ ⋙ toKaroubi (SimplicialObject C) ⋙ N₂ := Functor.associator _ _ _
_ ≅ Γ₀ ⋙ N₁ :=
isoWhiskerLeft Γ₀ ((functorExtension₁CompWhiskeringLeftToKaroubiIso _ _).app N₁)
@[simp]
lemma N₂Γ₂ToKaroubiIso_hom_app (X : ChainComplex C ℕ) :
(N₂Γ₂ToKaroubiIso.hom.app X).f = PInfty := by
ext n
dsimp [N₂Γ₂ToKaroubiIso]
simp only [comp_id, assoc, PInfty_f_idem]
conv_rhs =>
rw [← PInfty_f_idem]
congr 1
apply (Γ₀.splitting X).hom_ext'
intro A
rw [Splitting.ι_desc_assoc, assoc]
apply id_comp
@[simp]
lemma N₂Γ₂ToKaroubiIso_inv_app (X : ChainComplex C ℕ) :
(N₂Γ₂ToKaroubiIso.inv.app X).f = PInfty := by
ext n
dsimp [N₂Γ₂ToKaroubiIso]
simp only [comp_id, PInfty_f_idem_assoc, AlternatingFaceMapComplex.obj_X, Γ₀_obj_obj]
convert comp_id _
apply (Γ₀.splitting X).hom_ext'
intro A
rw [Splitting.ι_desc]
erw [comp_id, id_comp]
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] N₂Γ₂ToKaroubiIso
/-- The counit isomorphism of the Dold-Kan equivalence for additive categories. -/
def N₂Γ₂ : Γ₂ ⋙ N₂ ≅ 𝟭 (Karoubi (ChainComplex C ℕ)) :=
((whiskeringLeft _ _ _).obj (toKaroubi (ChainComplex C ℕ))).preimageIso
(N₂Γ₂ToKaroubiIso ≪≫ N₁Γ₀)
@[simp]
theorem N₂Γ₂_inv_app_f_f (X : Karoubi (ChainComplex C ℕ)) (n : ℕ) :
(N₂Γ₂.inv.app X).f.f n =
X.p.f n ≫ ((Γ₀.splitting X.X).cofan _).inj (Splitting.IndexSet.id (op [n])) := by
dsimp [N₂Γ₂]
simp only [whiskeringLeft_obj_preimage_app, NatTrans.comp_app, Functor.comp_map,
Karoubi.comp_f, N₂Γ₂ToKaroubiIso_inv_app, HomologicalComplex.comp_f,
N₁Γ₀_inv_app_f_f, toKaroubi_obj_X, Splitting.toKaroubiNondegComplexIsoN₁_hom_f_f,
Γ₀.obj_obj, PInfty_on_Γ₀_splitting_summand_eq_self, N₂_map_f_f,
Γ₂_map_f_app, unop_op, Karoubi.decompId_p_f, PInfty_f_idem_assoc,
PInfty_on_Γ₀_splitting_summand_eq_self_assoc, Splitting.IndexSet.id_fst, SimplexCategory.len_mk,
Splitting.ι_desc]
apply Karoubi.HomologicalComplex.p_idem_assoc
-- Porting note: added to ease the proof of `N₂Γ₂_compatible_with_N₁Γ₀`
lemma whiskerLeft_toKaroubi_N₂Γ₂_hom :
whiskerLeft (toKaroubi (ChainComplex C ℕ)) N₂Γ₂.hom = N₂Γ₂ToKaroubiIso.hom ≫ N₁Γ₀.hom := by
let e : _ ≅ toKaroubi (ChainComplex C ℕ) ⋙ 𝟭 _ := N₂Γ₂ToKaroubiIso ≪≫ N₁Γ₀
have h := ((whiskeringLeft _ _ (Karoubi (ChainComplex C ℕ))).obj
(toKaroubi (ChainComplex C ℕ))).map_preimage e.hom
dsimp only [whiskeringLeft, N₂Γ₂, Functor.preimageIso] at h ⊢
exact h
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] N₂Γ₂
theorem N₂Γ₂_compatible_with_N₁Γ₀ (K : ChainComplex C ℕ) :
N₂Γ₂.hom.app ((toKaroubi _).obj K) = N₂Γ₂ToKaroubiIso.hom.app K ≫ N₁Γ₀.hom.app K :=
congr_app whiskerLeft_toKaroubi_N₂Γ₂_hom K
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Homotopies.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.Algebra.Homology.Homotopy
import Mathlib.AlgebraicTopology.DoldKan.Notations
/-!
# Construction of homotopies for the Dold-Kan correspondence
(The general strategy of proof of the Dold-Kan correspondence is explained
in `Equivalence.lean`.)
The purpose of the files `Homotopies.lean`, `Faces.lean`, `Projections.lean`
and `PInfty.lean` is to construct an idempotent endomorphism
`PInfty : K[X] ⟶ K[X]` of the alternating face map complex
for each `X : SimplicialObject C` when `C` is a preadditive category.
In the case `C` is abelian, this `PInfty` shall be the projection on the
normalized Moore subcomplex of `K[X]` associated to the decomposition of the
complex `K[X]` as a direct sum of this normalized subcomplex and of the
degenerate subcomplex.
In `PInfty.lean`, this endomorphism `PInfty` shall be obtained by
passing to the limit idempotent endomorphisms `P q` for all `(q : ℕ)`.
These endomorphisms `P q` are defined by induction. The idea is to
start from the identity endomorphism `P 0` of `K[X]` and to ensure by
induction that the `q` higher face maps (except $d_0$) vanish on the
image of `P q`. Then, in a certain degree `n`, the image of `P q` for
a big enough `q` will be contained in the normalized subcomplex. This
construction is done in `Projections.lean`.
It would be easy to define the `P q` degreewise (similarly as it is done
in *Simplicial Homotopy Theory* by Goerrs-Jardine p. 149), but then we would
have to prove that they are compatible with the differential (i.e. they
are chain complex maps), and also that they are homotopic to the identity.
These two verifications are quite technical. In order to reduce the number
of such technical lemmas, the strategy that is followed here is to define
a series of null homotopic maps `Hσ q` (attached to families of maps `hσ`)
and use these in order to construct `P q` : the endomorphisms `P q`
shall basically be obtained by altering the identity endomorphism by adding
null homotopic maps, so that we get for free that they are morphisms
of chain complexes and that they are homotopic to the identity. The most
technical verifications that are needed about the null homotopic maps `Hσ`
are obtained in `Faces.lean`.
In this file `Homotopies.lean`, we define the null homotopic maps
`Hσ q : K[X] ⟶ K[X]`, show that they are natural (see `natTransHσ`) and
compatible the application of additive functors (see `map_Hσ`).
## References
* [Albrecht Dold, *Homology of Symmetric Products and Other Functors of Complexes*][dold1958]
* [Paul G. Goerss, John F. Jardine, *Simplicial Homotopy Theory*][goerss-jardine-2009]
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive
CategoryTheory.SimplicialObject Homotopy Opposite Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
variable {X : SimplicialObject C}
/-- As we are using chain complexes indexed by `ℕ`, we shall need the relation
`c` such `c m n` if and only if `n+1=m`. -/
abbrev c :=
ComplexShape.down ℕ
/-- Helper when we need some `c.rel i j` (i.e. `ComplexShape.down ℕ`),
e.g. `c_mk n (n+1) rfl` -/
theorem c_mk (i j : ℕ) (h : j + 1 = i) : c.Rel i j :=
ComplexShape.down_mk i j h
/-- This lemma is meant to be used with `nullHomotopicMap'_f_of_not_rel_left` -/
theorem cs_down_0_not_rel_left (j : ℕ) : ¬c.Rel 0 j := by
intro hj
dsimp at hj
apply Nat.not_succ_le_zero j
rw [Nat.succ_eq_add_one, hj]
/-- The sequence of maps which gives the null homotopic maps `Hσ` that shall be in
the inductive construction of the projections `P q : K[X] ⟶ K[X]` -/
def hσ (q : ℕ) (n : ℕ) : X _[n] ⟶ X _[n + 1] :=
if n < q then 0 else (-1 : ℤ) ^ (n - q) • X.σ ⟨n - q, Nat.lt_succ_of_le (Nat.sub_le _ _)⟩
/-- We can turn `hσ` into a datum that can be passed to `nullHomotopicMap'`. -/
def hσ' (q : ℕ) : ∀ n m, c.Rel m n → (K[X].X n ⟶ K[X].X m) := fun n m hnm =>
hσ q n ≫ eqToHom (by congr)
theorem hσ'_eq_zero {q n m : ℕ} (hnq : n < q) (hnm : c.Rel m n) :
(hσ' q n m hnm : X _[n] ⟶ X _[m]) = 0 := by
simp only [hσ', hσ]
split_ifs
exact zero_comp
theorem hσ'_eq {q n a m : ℕ} (ha : n = a + q) (hnm : c.Rel m n) :
(hσ' q n m hnm : X _[n] ⟶ X _[m]) =
((-1 : ℤ) ^ a • X.σ ⟨a, Nat.lt_succ_iff.mpr (Nat.le.intro (Eq.symm ha))⟩) ≫
eqToHom (by congr) := by
simp only [hσ', hσ]
split_ifs
· omega
· have h' := tsub_eq_of_eq_add ha
congr
theorem hσ'_eq' {q n a : ℕ} (ha : n = a + q) :
(hσ' q n (n + 1) rfl : X _[n] ⟶ X _[n + 1]) =
(-1 : ℤ) ^ a • X.σ ⟨a, Nat.lt_succ_iff.mpr (Nat.le.intro (Eq.symm ha))⟩ := by
rw [hσ'_eq ha rfl, eqToHom_refl, comp_id]
/-- The null homotopic map $(hσ q) ∘ d + d ∘ (hσ q)$ -/
def Hσ (q : ℕ) : K[X] ⟶ K[X] :=
nullHomotopicMap' (hσ' q)
/-- `Hσ` is null homotopic -/
def homotopyHσToZero (q : ℕ) : Homotopy (Hσ q : K[X] ⟶ K[X]) 0 :=
nullHomotopy' (hσ' q)
/-- In degree `0`, the null homotopic map `Hσ` is zero. -/
theorem Hσ_eq_zero (q : ℕ) : (Hσ q : K[X] ⟶ K[X]).f 0 = 0 := by
unfold Hσ
rw [nullHomotopicMap'_f_of_not_rel_left (c_mk 1 0 rfl) cs_down_0_not_rel_left]
rcases q with (_|q)
· rw [hσ'_eq (show 0 = 0 + 0 by rfl) (c_mk 1 0 rfl)]
simp only [pow_zero, Fin.mk_zero, one_zsmul, eqToHom_refl, Category.comp_id]
erw [ChainComplex.of_d]
rw [AlternatingFaceMapComplex.objD, Fin.sum_univ_two, Fin.val_zero, Fin.val_one, pow_zero,
pow_one, one_smul, neg_smul, one_smul, comp_add, comp_neg, add_neg_eq_zero]
erw [δ_comp_σ_self, δ_comp_σ_succ]
· rw [hσ'_eq_zero (Nat.succ_pos q) (c_mk 1 0 rfl), zero_comp]
/-- The maps `hσ' q n m hnm` are natural on the simplicial object -/
theorem hσ'_naturality (q : ℕ) (n m : ℕ) (hnm : c.Rel m n) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op [n]) ≫ hσ' q n m hnm = hσ' q n m hnm ≫ f.app (op [m]) := by
have h : n + 1 = m := hnm
subst h
simp only [hσ', eqToHom_refl, comp_id]
unfold hσ
split_ifs
· rw [zero_comp, comp_zero]
· simp only [zsmul_comp, comp_zsmul]
erw [f.naturality]
rfl
/-- For each q, `Hσ q` is a natural transformation. -/
def natTransHσ (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app X := Hσ q
naturality _ _ f := by
unfold Hσ
rw [nullHomotopicMap'_comp, comp_nullHomotopicMap']
congr
ext n m hnm
simp only [alternatingFaceMapComplex_map_f, hσ'_naturality]
/-- The maps `hσ' q n m hnm` are compatible with the application of additive functors. -/
theorem map_hσ' {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n m : ℕ) (hnm : c.Rel m n) :
(hσ' q n m hnm : K[((whiskering _ _).obj G).obj X].X n ⟶ _) =
G.map (hσ' q n m hnm : K[X].X n ⟶ _) := by
unfold hσ' hσ
split_ifs
· simp only [Functor.map_zero, zero_comp]
· simp only [eqToHom_map, Functor.map_comp, Functor.map_zsmul]
rfl
/-- The null homotopic maps `Hσ` are compatible with the application of additive functors. -/
theorem map_Hσ {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
(Hσ q : K[((whiskering C D).obj G).obj X] ⟶ _).f n = G.map ((Hσ q : K[X] ⟶ _).f n) := by
unfold Hσ
have eq := HomologicalComplex.congr_hom (map_nullHomotopicMap' G (@hσ' _ _ _ X q)) n
simp only [Functor.mapHomologicalComplex_map_f, ← map_hσ'] at eq
rw [eq]
let h := (Functor.congr_obj (map_alternatingFaceMapComplex G) X).symm
congr
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\HomotopyEquivalence.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.Normalized
/-!
# The normalized Moore complex and the alternating face map complex are homotopy equivalent
In this file, when the category `A` is abelian, we obtain the homotopy equivalence
`homotopyEquivNormalizedMooreComplexAlternatingFaceMapComplex` between the
normalized Moore complex and the alternating face map complex of a simplicial object in `A`.
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Preadditive Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] (X : SimplicialObject C)
/-- Inductive construction of homotopies from `P q` to `𝟙 _` -/
noncomputable def homotopyPToId : ∀ q : ℕ, Homotopy (P q : K[X] ⟶ _) (𝟙 _)
| 0 => Homotopy.refl _
| q + 1 => by
refine
Homotopy.trans (Homotopy.ofEq ?_)
(Homotopy.trans
(Homotopy.add (homotopyPToId q) (Homotopy.compLeft (homotopyHσToZero q) (P q)))
(Homotopy.ofEq ?_))
· simp only [P_succ, comp_add, comp_id]
· simp only [add_zero, comp_zero]
/-- The complement projection `Q q` to `P q` is homotopic to zero. -/
def homotopyQToZero (q : ℕ) : Homotopy (Q q : K[X] ⟶ _) 0 :=
Homotopy.equivSubZero.toFun (homotopyPToId X q).symm
theorem homotopyPToId_eventually_constant {q n : ℕ} (hqn : n < q) :
((homotopyPToId X (q + 1)).hom n (n + 1) : X _[n] ⟶ X _[n + 1]) =
(homotopyPToId X q).hom n (n + 1) := by
simp only [homotopyHσToZero, AlternatingFaceMapComplex.obj_X, Nat.add_eq, Homotopy.trans_hom,
Homotopy.ofEq_hom, Pi.zero_apply, Homotopy.add_hom, Homotopy.compLeft_hom, add_zero,
Homotopy.nullHomotopy'_hom, ComplexShape.down_Rel, hσ'_eq_zero hqn (c_mk (n + 1) n rfl),
dite_eq_ite, ite_self, comp_zero, zero_add, homotopyPToId]
/-- Construction of the homotopy from `PInfty` to the identity using eventually
(termwise) constant homotopies from `P q` to the identity for all `q` -/
@[simps]
def homotopyPInftyToId : Homotopy (PInfty : K[X] ⟶ _) (𝟙 _) where
hom i j := (homotopyPToId X (j + 1)).hom i j
zero i j hij := Homotopy.zero _ i j hij
comm n := by
rcases n with _|n
· simpa only [Homotopy.dNext_zero_chainComplex, Homotopy.prevD_chainComplex,
PInfty_f, Nat.zero_eq, P_f_0_eq, zero_add] using (homotopyPToId X 2).comm 0
· simp only [Homotopy.dNext_succ_chainComplex, Homotopy.prevD_chainComplex,
HomologicalComplex.id_f, PInfty_f, ← P_is_eventually_constant (rfl.le : n + 1 ≤ n + 1)]
-- Porting note(lean4/2146): remaining proof was
-- `simpa only [homotopyPToId_eventually_constant X (lt_add_one (Nat.succ n))]
-- using (homotopyPToId X (n + 2)).comm (n + 1)`;
-- fails since leanprover/lean4:nightly-2023-05-16; `erw` below clunkily works around this.
erw [homotopyPToId_eventually_constant X (lt_add_one (Nat.succ n))]
have := (homotopyPToId X (n + 2)).comm (n + 1)
rw [Homotopy.dNext_succ_chainComplex, Homotopy.prevD_chainComplex] at this
exact this
/-- The inclusion of the Moore complex in the alternating face map complex
is a homotopy equivalence -/
@[simps]
def homotopyEquivNormalizedMooreComplexAlternatingFaceMapComplex {A : Type*} [Category A]
[Abelian A] {Y : SimplicialObject A} :
HomotopyEquiv ((normalizedMooreComplex A).obj Y) ((alternatingFaceMapComplex A).obj Y) where
hom := inclusionOfMooreComplexMap Y
inv := PInftyToNormalizedMooreComplex Y
homotopyHomInvId := Homotopy.ofEq (splitMonoInclusionOfMooreComplexMap Y).id
homotopyInvHomId := Homotopy.trans
(Homotopy.ofEq (PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap Y))
(homotopyPInftyToId Y)
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\NCompGamma.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.GammaCompN
import Mathlib.AlgebraicTopology.DoldKan.NReflectsIso
/-! The unit isomorphism of the Dold-Kan equivalence
In order to construct the unit isomorphism of the Dold-Kan equivalence,
we first construct natural transformations
`Γ₂N₁.natTrans : N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)` and
`Γ₂N₂.natTrans : N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`.
It is then shown that `Γ₂N₂.natTrans` is an isomorphism by using
that it becomes an isomorphism after the application of the functor
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)`
which reflects isomorphisms.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
noncomputable section
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Idempotents
SimplexCategory Opposite SimplicialObject Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
theorem PInfty_comp_map_mono_eq_zero (X : SimplicialObject C) {n : ℕ} {Δ' : SimplexCategory}
(i : Δ' ⟶ [n]) [hi : Mono i] (h₁ : Δ'.len ≠ n) (h₂ : ¬Isδ₀ i) :
PInfty.f n ≫ X.map i.op = 0 := by
induction' Δ' using SimplexCategory.rec with m
obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_lt (len_lt_of_mono i fun h => by
rw [← h] at h₁
exact h₁ rfl)
simp only [len_mk] at hk
rcases k with _|k
· change n = m + 1 at hk
subst hk
obtain ⟨j, rfl⟩ := eq_δ_of_mono i
rw [Isδ₀.iff] at h₂
have h₃ : 1 ≤ (j : ℕ) := by
by_contra h
exact h₂ (by simpa only [Fin.ext_iff, not_le, Nat.lt_one_iff] using h)
exact (HigherFacesVanish.of_P (m + 1) m).comp_δ_eq_zero j h₂ (by omega)
· simp only [Nat.succ_eq_add_one, ← add_assoc] at hk
clear h₂ hi
subst hk
obtain ⟨j₁ : Fin (_ + 1), i, rfl⟩ :=
eq_comp_δ_of_not_surjective i fun h => by
have h' := len_le_of_epi (SimplexCategory.epi_iff_surjective.2 h)
dsimp at h'
omega
obtain ⟨j₂, i, rfl⟩ :=
eq_comp_δ_of_not_surjective i fun h => by
have h' := len_le_of_epi (SimplexCategory.epi_iff_surjective.2 h)
dsimp at h'
omega
by_cases hj₁ : j₁ = 0
· subst hj₁
rw [assoc, ← SimplexCategory.δ_comp_δ'' (Fin.zero_le _)]
simp only [op_comp, X.map_comp, assoc, PInfty_f]
erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ j₂.succ_ne_zero, zero_comp]
simp only [Nat.succ_eq_add_one, Nat.add, Fin.succ]
omega
· simp only [op_comp, X.map_comp, assoc, PInfty_f]
erw [(HigherFacesVanish.of_P _ _).comp_δ_eq_zero_assoc _ hj₁, zero_comp]
by_contra
exact hj₁ (by simp only [Fin.ext_iff, Fin.val_zero]; linarith)
@[reassoc]
theorem Γ₀_obj_termwise_mapMono_comp_PInfty (X : SimplicialObject C) {Δ Δ' : SimplexCategory}
(i : Δ ⟶ Δ') [Mono i] :
Γ₀.Obj.Termwise.mapMono (AlternatingFaceMapComplex.obj X) i ≫ PInfty.f Δ.len =
PInfty.f Δ'.len ≫ X.map i.op := by
induction' Δ using SimplexCategory.rec with n
induction' Δ' using SimplexCategory.rec with n'
dsimp
-- We start with the case `i` is an identity
by_cases h : n = n'
· subst h
simp only [SimplexCategory.eq_id_of_mono i, Γ₀.Obj.Termwise.mapMono_id, op_id, X.map_id]
dsimp
simp only [id_comp, comp_id]
by_cases hi : Isδ₀ i
-- The case `i = δ 0`
· have h' : n' = n + 1 := hi.left
subst h'
simp only [Γ₀.Obj.Termwise.mapMono_δ₀' _ i hi]
dsimp
rw [← PInfty.comm _ n, AlternatingFaceMapComplex.obj_d_eq]
simp only [eq_self_iff_true, id_comp, if_true, Preadditive.comp_sum]
rw [Finset.sum_eq_single (0 : Fin (n + 2))]
rotate_left
· intro b _ hb
rw [Preadditive.comp_zsmul]
erw [PInfty_comp_map_mono_eq_zero X (SimplexCategory.δ b) h
(by
rw [Isδ₀.iff]
exact hb),
zsmul_zero]
· simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff]
· simp only [hi.eq_δ₀, Fin.val_zero, pow_zero, one_zsmul]
rfl
-- The case `i ≠ δ 0`
· rw [Γ₀.Obj.Termwise.mapMono_eq_zero _ i _ hi, zero_comp]
swap
· by_contra h'
exact h (congr_arg SimplexCategory.len h'.symm)
rw [PInfty_comp_map_mono_eq_zero]
· exact h
· by_contra h'
exact hi h'
variable [HasFiniteCoproducts C]
namespace Γ₂N₁
/-- The natural transformation `N₁ ⋙ Γ₂ ⟶ toKaroubi (SimplicialObject C)`. -/
@[simps]
def natTrans : (N₁ : SimplicialObject C ⥤ _) ⋙ Γ₂ ⟶ toKaroubi _ where
app X :=
{ f :=
{ app := fun Δ => (Γ₀.splitting K[X]).desc Δ fun A => PInfty.f A.1.unop.len ≫ X.map A.e.op
naturality := fun Δ Δ' θ => by
apply (Γ₀.splitting K[X]).hom_ext'
intro A
change _ ≫ (Γ₀.obj K[X]).map θ ≫ _ = _
simp only [Splitting.ι_desc_assoc, assoc, Γ₀.Obj.map_on_summand'_assoc,
Splitting.ι_desc]
erw [Γ₀_obj_termwise_mapMono_comp_PInfty_assoc X (image.ι (θ.unop ≫ A.e))]
dsimp only [toKaroubi]
simp only [← X.map_comp]
congr 2
simp only [eqToHom_refl, id_comp, comp_id, ← op_comp]
exact Quiver.Hom.unop_inj (A.fac_pull θ) }
comm := by
apply (Γ₀.splitting K[X]).hom_ext
intro n
dsimp [N₁]
simp only [← Splitting.cofan_inj_id, Splitting.ι_desc, comp_id, Splitting.ι_desc_assoc,
assoc, PInfty_f_idem_assoc] }
naturality {X Y} f := by
ext1
apply (Γ₀.splitting K[X]).hom_ext
intro n
dsimp [N₁, toKaroubi]
simp only [← Splitting.cofan_inj_id, Splitting.ι_desc, Splitting.ι_desc_assoc, assoc,
PInfty_f_idem_assoc, Karoubi.comp_f, NatTrans.comp_app, Γ₂_map_f_app,
HomologicalComplex.comp_f, AlternatingFaceMapComplex.map_f, PInfty_f_naturality_assoc,
NatTrans.naturality, Splitting.IndexSet.id_fst, unop_op, len_mk]
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] natTrans
end Γ₂N₁
-- Porting note: removed @[simps] attribute because it was creating timeouts
/-- The compatibility isomorphism relating `N₂ ⋙ Γ₂` and `N₁ ⋙ Γ₂`. -/
def Γ₂N₂ToKaroubiIso : toKaroubi (SimplicialObject C) ⋙ N₂ ⋙ Γ₂ ≅ N₁ ⋙ Γ₂ :=
(Functor.associator _ _ _).symm ≪≫ isoWhiskerRight toKaroubiCompN₂IsoN₁ Γ₂
@[simp]
lemma Γ₂N₂ToKaroubiIso_hom_app (X : SimplicialObject C) :
Γ₂N₂ToKaroubiIso.hom.app X = Γ₂.map (toKaroubiCompN₂IsoN₁.hom.app X) := by
simp [Γ₂N₂ToKaroubiIso]
@[simp]
lemma Γ₂N₂ToKaroubiIso_inv_app (X : SimplicialObject C) :
Γ₂N₂ToKaroubiIso.inv.app X = Γ₂.map (toKaroubiCompN₂IsoN₁.inv.app X) := by
simp [Γ₂N₂ToKaroubiIso]
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] Γ₂N₂ToKaroubiIso
namespace Γ₂N₂
/-- The natural transformation `N₂ ⋙ Γ₂ ⟶ 𝟭 (SimplicialObject C)`. -/
def natTrans : (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ Γ₂ ⟶ 𝟭 _ :=
((whiskeringLeft _ _ _).obj (toKaroubi (SimplicialObject C))).preimage
(Γ₂N₂ToKaroubiIso.hom ≫ Γ₂N₁.natTrans)
theorem natTrans_app_f_app (P : Karoubi (SimplicialObject C)) :
Γ₂N₂.natTrans.app P =
(N₂ ⋙ Γ₂).map P.decompId_i ≫
(Γ₂N₂ToKaroubiIso.hom ≫ Γ₂N₁.natTrans).app P.X ≫ P.decompId_p := by
dsimp only [natTrans]
simp only [whiskeringLeft_obj_preimage_app, Functor.id_map, assoc]
-- Porting note (#10694): added to speed up elaboration
attribute [irreducible] natTrans
end Γ₂N₂
theorem compatibility_Γ₂N₁_Γ₂N₂_natTrans (X : SimplicialObject C) :
Γ₂N₁.natTrans.app X =
(Γ₂N₂ToKaroubiIso.app X).inv ≫
Γ₂N₂.natTrans.app ((toKaroubi (SimplicialObject C)).obj X) := by
rw [Γ₂N₂.natTrans_app_f_app]
dsimp only [Karoubi.decompId_i_toKaroubi, Karoubi.decompId_p_toKaroubi, Functor.comp_map,
NatTrans.comp_app]
rw [N₂.map_id, Γ₂.map_id, Iso.app_inv]
dsimp only [toKaroubi]
erw [id_comp]
rw [comp_id, Iso.inv_hom_id_app_assoc]
theorem identity_N₂_objectwise (P : Karoubi (SimplicialObject C)) :
(N₂Γ₂.inv.app (N₂.obj P) : N₂.obj P ⟶ N₂.obj (Γ₂.obj (N₂.obj P))) ≫
N₂.map (Γ₂N₂.natTrans.app P) = 𝟙 (N₂.obj P) := by
ext n
have eq₁ : (N₂Γ₂.inv.app (N₂.obj P)).f.f n = PInfty.f n ≫ P.p.app (op [n]) ≫
((Γ₀.splitting (N₂.obj P).X).cofan _).inj (Splitting.IndexSet.id (op [n])) := by
simp only [N₂Γ₂_inv_app_f_f, N₂_obj_p_f, assoc]
have eq₂ : ((Γ₀.splitting (N₂.obj P).X).cofan _).inj (Splitting.IndexSet.id (op [n])) ≫
(N₂.map (Γ₂N₂.natTrans.app P)).f.f n = PInfty.f n ≫ P.p.app (op [n]) := by
dsimp
rw [PInfty_on_Γ₀_splitting_summand_eq_self_assoc, Γ₂N₂.natTrans_app_f_app]
dsimp
rw [Γ₂N₂ToKaroubiIso_hom_app, assoc, Splitting.ι_desc_assoc, assoc, assoc]
dsimp [toKaroubi]
rw [Splitting.ι_desc_assoc]
dsimp
simp only [assoc, Splitting.ι_desc_assoc, unop_op, Splitting.IndexSet.id_fst,
len_mk, NatTrans.naturality, PInfty_f_idem_assoc,
PInfty_f_naturality_assoc, app_idem_assoc]
erw [P.X.map_id, comp_id]
simp only [Karoubi.comp_f, HomologicalComplex.comp_f, Karoubi.id_f, N₂_obj_p_f, assoc,
eq₁, eq₂, PInfty_f_naturality_assoc, app_idem, PInfty_f_idem_assoc]
-- Porting note: `Functor.associator` was added to the statement in order to prevent a timeout
theorem identity_N₂ :
(𝟙 (N₂ : Karoubi (SimplicialObject C) ⥤ _) ◫ N₂Γ₂.inv) ≫
(Functor.associator _ _ _).inv ≫ Γ₂N₂.natTrans ◫ 𝟙 (@N₂ C _ _) = 𝟙 N₂ := by
ext P : 2
dsimp only [NatTrans.comp_app, NatTrans.hcomp_app, Functor.comp_map, Functor.associator,
NatTrans.id_app, Functor.comp_obj]
rw [Γ₂.map_id, N₂.map_id, comp_id, id_comp, id_comp, identity_N₂_objectwise P]
instance : IsIso (Γ₂N₂.natTrans : (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ _ ⟶ _) := by
have : ∀ P : Karoubi (SimplicialObject C), IsIso (Γ₂N₂.natTrans.app P) := by
intro P
have : IsIso (N₂.map (Γ₂N₂.natTrans.app P)) := by
have h := identity_N₂_objectwise P
erw [hom_comp_eq_id] at h
rw [h]
infer_instance
exact isIso_of_reflects_iso _ N₂
apply NatIso.isIso_of_isIso_app
instance : IsIso (Γ₂N₁.natTrans : (N₁ : SimplicialObject C ⥤ _) ⋙ _ ⟶ _) := by
have : ∀ X : SimplicialObject C, IsIso (Γ₂N₁.natTrans.app X) := by
intro X
rw [compatibility_Γ₂N₁_Γ₂N₂_natTrans]
infer_instance
apply NatIso.isIso_of_isIso_app
/-- The unit isomorphism of the Dold-Kan equivalence. -/
@[simps! inv]
def Γ₂N₂ : 𝟭 _ ≅ (N₂ : Karoubi (SimplicialObject C) ⥤ _) ⋙ Γ₂ :=
(asIso Γ₂N₂.natTrans).symm
/-- The natural isomorphism `toKaroubi (SimplicialObject C) ≅ N₁ ⋙ Γ₂`. -/
@[simps! inv]
def Γ₂N₁ : toKaroubi _ ≅ (N₁ : SimplicialObject C ⥤ _) ⋙ Γ₂ :=
(asIso Γ₂N₁.natTrans).symm
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Normalized.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.FunctorN
/-!
# Comparison with the normalized Moore complex functor
In this file, we show that when the category `A` is abelian,
there is an isomorphism `N₁_iso_normalizedMooreComplex_comp_toKaroubi` between
the functor `N₁ : SimplicialObject A ⥤ Karoubi (ChainComplex A ℕ)`
defined in `FunctorN.lean` and the composition of
`normalizedMooreComplex A` with the inclusion
`ChainComplex A ℕ ⥤ Karoubi (ChainComplex A ℕ)`.
This isomorphism shall be used in `Equivalence.lean` in order to obtain
the Dold-Kan equivalence
`CategoryTheory.Abelian.DoldKan.equivalence : SimplicialObject A ≌ ChainComplex A ℕ`
with a functor (definitionally) equal to `normalizedMooreComplex A`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits
CategoryTheory.Subobject CategoryTheory.Idempotents DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
universe v
variable {A : Type*} [Category A] [Abelian A] {X : SimplicialObject A}
theorem HigherFacesVanish.inclusionOfMooreComplexMap (n : ℕ) :
HigherFacesVanish (n + 1) ((inclusionOfMooreComplexMap X).f (n + 1)) := fun j _ => by
dsimp [AlgebraicTopology.inclusionOfMooreComplexMap, NormalizedMooreComplex.objX]
rw [← factorThru_arrow _ _ (finset_inf_arrow_factors Finset.univ _ j
(by simp only [Finset.mem_univ])), assoc, kernelSubobject_arrow_comp, comp_zero]
theorem factors_normalizedMooreComplex_PInfty (n : ℕ) :
Subobject.Factors (NormalizedMooreComplex.objX X n) (PInfty.f n) := by
rcases n with _|n
· apply top_factors
· rw [PInfty_f, NormalizedMooreComplex.objX, finset_inf_factors]
intro i _
apply kernelSubobject_factors
exact (HigherFacesVanish.of_P (n + 1) n) i le_add_self
/-- `PInfty` factors through the normalized Moore complex -/
@[simps!]
def PInftyToNormalizedMooreComplex (X : SimplicialObject A) : K[X] ⟶ N[X] :=
ChainComplex.ofHom _ _ _ _ _ _
(fun n => factorThru _ _ (factors_normalizedMooreComplex_PInfty n)) fun n => by
rw [← cancel_mono (NormalizedMooreComplex.objX X n).arrow, assoc, assoc, factorThru_arrow,
← inclusionOfMooreComplexMap_f, ← normalizedMooreComplex_objD,
← (inclusionOfMooreComplexMap X).comm (n + 1) n, inclusionOfMooreComplexMap_f,
factorThru_arrow_assoc, ← alternatingFaceMapComplex_obj_d]
exact PInfty.comm (n + 1) n
@[reassoc (attr := simp)]
theorem PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap (X : SimplicialObject A) :
PInftyToNormalizedMooreComplex X ≫ inclusionOfMooreComplexMap X = PInfty := by aesop_cat
@[reassoc (attr := simp)]
theorem PInftyToNormalizedMooreComplex_naturality {X Y : SimplicialObject A} (f : X ⟶ Y) :
AlternatingFaceMapComplex.map f ≫ PInftyToNormalizedMooreComplex Y =
PInftyToNormalizedMooreComplex X ≫ NormalizedMooreComplex.map f := by
aesop_cat
@[reassoc (attr := simp)]
theorem PInfty_comp_PInftyToNormalizedMooreComplex (X : SimplicialObject A) :
PInfty ≫ PInftyToNormalizedMooreComplex X = PInftyToNormalizedMooreComplex X := by aesop_cat
@[reassoc (attr := simp)]
theorem inclusionOfMooreComplexMap_comp_PInfty (X : SimplicialObject A) :
inclusionOfMooreComplexMap X ≫ PInfty = inclusionOfMooreComplexMap X := by
ext (_|n)
· dsimp
simp only [comp_id]
· exact (HigherFacesVanish.inclusionOfMooreComplexMap n).comp_P_eq_self
instance : Mono (inclusionOfMooreComplexMap X) :=
⟨fun _ _ hf => by
ext n
dsimp
ext
exact HomologicalComplex.congr_hom hf n⟩
/-- `inclusionOfMooreComplexMap X` is a split mono. -/
def splitMonoInclusionOfMooreComplexMap (X : SimplicialObject A) :
SplitMono (inclusionOfMooreComplexMap X) where
retraction := PInftyToNormalizedMooreComplex X
id := by
simp only [← cancel_mono (inclusionOfMooreComplexMap X), assoc, id_comp,
PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
inclusionOfMooreComplexMap_comp_PInfty]
variable (A)
/-- When the category `A` is abelian,
the functor `N₁ : SimplicialObject A ⥤ Karoubi (ChainComplex A ℕ)` defined
using `PInfty` identifies to the composition of the normalized Moore complex functor
and the inclusion in the Karoubi envelope. -/
def N₁_iso_normalizedMooreComplex_comp_toKaroubi : N₁ ≅ normalizedMooreComplex A ⋙ toKaroubi _ where
hom :=
{ app := fun X =>
{ f := PInftyToNormalizedMooreComplex X
comm := by erw [comp_id, PInfty_comp_PInftyToNormalizedMooreComplex] }
naturality := fun X Y f => by
simp only [Functor.comp_map, normalizedMooreComplex_map,
PInftyToNormalizedMooreComplex_naturality, Karoubi.hom_ext_iff, Karoubi.comp_f, N₁_map_f,
PInfty_comp_PInftyToNormalizedMooreComplex_assoc, toKaroubi_map_f, assoc] }
inv :=
{ app := fun X =>
{ f := inclusionOfMooreComplexMap X
comm := by erw [inclusionOfMooreComplexMap_comp_PInfty, id_comp] }
naturality := fun X Y f => by
ext
simp only [Functor.comp_map, normalizedMooreComplex_map, Karoubi.comp_f, toKaroubi_map_f,
HomologicalComplex.comp_f, NormalizedMooreComplex.map_f,
inclusionOfMooreComplexMap_f, factorThru_arrow, N₁_map_f,
inclusionOfMooreComplexMap_comp_PInfty_assoc, AlternatingFaceMapComplex.map_f] }
hom_inv_id := by
ext X : 3
simp only [PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
NatTrans.comp_app, Karoubi.comp_f, N₁_obj_p, NatTrans.id_app, Karoubi.id_f]
inv_hom_id := by
ext X : 3
rw [← cancel_mono (inclusionOfMooreComplexMap X)]
simp only [NatTrans.comp_app, Karoubi.comp_f, assoc, NatTrans.id_app, Karoubi.id_f,
PInftyToNormalizedMooreComplex_comp_inclusionOfMooreComplexMap,
inclusionOfMooreComplexMap_comp_PInfty]
dsimp only [Functor.comp_obj, toKaroubi]
erw [id_comp]
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Notations.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.AlternatingFaceMapComplex
/-!
# Notations for the Dold-Kan equivalence
This file defines the notation `K[X] : ChainComplex C ℕ` for the alternating face
map complex of `(X : SimplicialObject C)` where `C` is a preadditive category, as well
as `N[X]` for the normalized subcomplex in the case `C` is an abelian category.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
@[inherit_doc]
scoped[DoldKan] notation "K[" X "]" => AlgebraicTopology.AlternatingFaceMapComplex.obj X
@[inherit_doc]
scoped[DoldKan] notation "N[" X "]" => AlgebraicTopology.NormalizedMooreComplex.obj X
|
AlgebraicTopology\DoldKan\NReflectsIso.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.FunctorN
import Mathlib.AlgebraicTopology.DoldKan.Decomposition
import Mathlib.CategoryTheory.Idempotents.HomologicalComplex
import Mathlib.CategoryTheory.Idempotents.KaroubiKaroubi
/-!
# N₁ and N₂ reflects isomorphisms
In this file, it is shown that the functors
`N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)` and
`N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ))`
reflect isomorphisms for any preadditive category `C`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Idempotents Opposite Simplicial
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C]
open MorphComponents
instance : (N₁ : SimplicialObject C ⥤ Karoubi (ChainComplex C ℕ)).ReflectsIsomorphisms :=
⟨fun {X Y} f => by
intro
-- restating the result in a way that allows induction on the degree n
suffices ∀ n : ℕ, IsIso (f.app (op [n])) by
haveI : ∀ Δ : SimplexCategoryᵒᵖ, IsIso (f.app Δ) := fun Δ => this Δ.unop.len
apply NatIso.isIso_of_isIso_app
-- restating the assumption in a more practical form
have h₁ := HomologicalComplex.congr_hom (Karoubi.hom_ext_iff.mp (IsIso.hom_inv_id (N₁.map f)))
have h₂ := HomologicalComplex.congr_hom (Karoubi.hom_ext_iff.mp (IsIso.inv_hom_id (N₁.map f)))
have h₃ := fun n =>
Karoubi.HomologicalComplex.p_comm_f_assoc (inv (N₁.map f)) n (f.app (op [n]))
simp only [N₁_map_f, Karoubi.comp_f, HomologicalComplex.comp_f,
AlternatingFaceMapComplex.map_f, N₁_obj_p, Karoubi.id_f, assoc] at h₁ h₂ h₃
-- we have to construct an inverse to f in degree n, by induction on n
intro n
induction' n with n hn
-- degree 0
· use (inv (N₁.map f)).f.f 0
have h₁₀ := h₁ 0
have h₂₀ := h₂ 0
dsimp at h₁₀ h₂₀
simp only [id_comp, comp_id] at h₁₀ h₂₀
tauto
· haveI := hn
use φ { a := PInfty.f (n + 1) ≫ (inv (N₁.map f)).f.f (n + 1)
b := fun i => inv (f.app (op [n])) ≫ X.σ i }
simp only [MorphComponents.id, ← id_φ, ← preComp_φ, preComp, ← postComp_φ, postComp,
PInfty_f_naturality_assoc, IsIso.hom_inv_id_assoc, assoc, IsIso.inv_hom_id_assoc,
SimplicialObject.σ_naturality, h₁, h₂, h₃, and_self]⟩
theorem compatibility_N₂_N₁_karoubi :
N₂ ⋙ (karoubiChainComplexEquivalence C ℕ).functor =
karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C ⋙
N₁ ⋙ (karoubiChainComplexEquivalence (Karoubi C) ℕ).functor ⋙
Functor.mapHomologicalComplex (KaroubiKaroubi.equivalence C).inverse _ := by
refine CategoryTheory.Functor.ext (fun P => ?_) fun P Q f => ?_
· refine HomologicalComplex.ext ?_ ?_
· ext n
· rfl
· dsimp
simp only [karoubi_PInfty_f, comp_id, PInfty_f_naturality, id_comp, eqToHom_refl]
· rintro _ n (rfl : n + 1 = _)
ext
have h := (AlternatingFaceMapComplex.map P.p).comm (n + 1) n
dsimp [N₂, karoubiChainComplexEquivalence,
KaroubiHomologicalComplexEquivalence.Functor.obj] at h ⊢
simp only [assoc, Karoubi.eqToHom_f, eqToHom_refl, comp_id,
karoubi_alternatingFaceMapComplex_d, karoubi_PInfty_f,
← HomologicalComplex.Hom.comm_assoc, ← h, app_idem_assoc]
· ext n
dsimp [KaroubiKaroubi.inverse, Functor.mapHomologicalComplex]
simp only [karoubi_PInfty_f, HomologicalComplex.eqToHom_f, Karoubi.eqToHom_f,
assoc, comp_id, PInfty_f_naturality, app_p_comp,
karoubiChainComplexEquivalence_functor_obj_X_p, N₂_obj_p_f, eqToHom_refl,
PInfty_f_naturality_assoc, app_comp_p, PInfty_f_idem_assoc]
/-- We deduce that `N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ))`
reflects isomorphisms from the fact that
`N₁ : SimplicialObject (Karoubi C) ⥤ Karoubi (ChainComplex (Karoubi C) ℕ)` does. -/
instance : (N₂ : Karoubi (SimplicialObject C) ⥤ Karoubi (ChainComplex C ℕ)).ReflectsIsomorphisms :=
⟨fun f => by
intro
-- The following functor `F` reflects isomorphism because it is
-- a composition of four functors which reflects isomorphisms.
-- Then, it suffices to show that `F.map f` is an isomorphism.
let F₁ := karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C
let F₂ : SimplicialObject (Karoubi C) ⥤ _ := N₁
let F₃ := (karoubiChainComplexEquivalence (Karoubi C) ℕ).functor
let F₄ := Functor.mapHomologicalComplex (KaroubiKaroubi.equivalence C).inverse
(ComplexShape.down ℕ)
let F := F₁ ⋙ F₂ ⋙ F₃ ⋙ F₄
-- Porting note: we have to help Lean4 find the `ReflectsIsomorphisms` instances
-- could this be fixed by setting better instance priorities?
haveI : F₁.ReflectsIsomorphisms := reflectsIsomorphisms_of_full_and_faithful _
haveI : F₂.ReflectsIsomorphisms := by infer_instance
haveI : F₃.ReflectsIsomorphisms := reflectsIsomorphisms_of_full_and_faithful _
haveI : ((KaroubiKaroubi.equivalence C).inverse).ReflectsIsomorphisms :=
reflectsIsomorphisms_of_full_and_faithful _
have : IsIso (F.map f) := by
simp only [F]
rw [← compatibility_N₂_N₁_karoubi, Functor.comp_map]
apply Functor.map_isIso
exact isIso_of_reflects_iso f F⟩
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\PInfty.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.Projections
import Mathlib.CategoryTheory.Idempotents.FunctorCategories
import Mathlib.CategoryTheory.Idempotents.FunctorExtension
/-!
# Construction of the projection `PInfty` for the Dold-Kan correspondence
In this file, we construct the projection `PInfty : K[X] ⟶ K[X]` by passing
to the limit the projections `P q` defined in `Projections.lean`. This
projection is a critical tool in this formalisation of the Dold-Kan correspondence,
because in the case of abelian categories, `PInfty` corresponds to the
projection on the normalized Moore subcomplex, with kernel the degenerate subcomplex.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.SimplicialObject CategoryTheory.Idempotents Opposite Simplicial DoldKan
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C}
theorem P_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((P (q + 1)).f n : X _[n] ⟶ _) = (P q).f n := by
rcases n with (_|n)
· simp only [Nat.zero_eq, P_f_0_eq]
· simp only [P_succ, add_right_eq_self, comp_add, HomologicalComplex.comp_f,
HomologicalComplex.add_f_apply, comp_id]
exact (HigherFacesVanish.of_P q n).comp_Hσ_eq_zero (Nat.succ_le_iff.mp hqn)
theorem Q_is_eventually_constant {q n : ℕ} (hqn : n ≤ q) :
((Q (q + 1)).f n : X _[n] ⟶ _) = (Q q).f n := by
simp only [Q, HomologicalComplex.sub_f_apply, P_is_eventually_constant hqn]
/-- The endomorphism `PInfty : K[X] ⟶ K[X]` obtained from the `P q` by passing to the limit. -/
noncomputable def PInfty : K[X] ⟶ K[X] :=
ChainComplex.ofHom _ _ _ _ _ _ (fun n => ((P n).f n : X _[n] ⟶ _)) fun n => by
simpa only [← P_is_eventually_constant (show n ≤ n by rfl),
AlternatingFaceMapComplex.obj_d_eq] using (P (n + 1) : K[X] ⟶ _).comm (n + 1) n
/-- The endomorphism `QInfty : K[X] ⟶ K[X]` obtained from the `Q q` by passing to the limit. -/
noncomputable def QInfty : K[X] ⟶ K[X] :=
𝟙 _ - PInfty
@[simp]
theorem PInfty_f_0 : (PInfty.f 0 : X _[0] ⟶ X _[0]) = 𝟙 _ :=
rfl
theorem PInfty_f (n : ℕ) : (PInfty.f n : X _[n] ⟶ X _[n]) = (P n).f n :=
rfl
@[simp]
theorem QInfty_f_0 : (QInfty.f 0 : X _[0] ⟶ X _[0]) = 0 := by
dsimp [QInfty]
simp only [sub_self]
theorem QInfty_f (n : ℕ) : (QInfty.f n : X _[n] ⟶ X _[n]) = (Q n).f n :=
rfl
@[reassoc (attr := simp)]
theorem PInfty_f_naturality (n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op [n]) ≫ PInfty.f n = PInfty.f n ≫ f.app (op [n]) :=
P_f_naturality n n f
@[reassoc (attr := simp)]
theorem QInfty_f_naturality (n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op [n]) ≫ QInfty.f n = QInfty.f n ≫ f.app (op [n]) :=
Q_f_naturality n n f
@[reassoc (attr := simp)]
theorem PInfty_f_idem (n : ℕ) : (PInfty.f n : X _[n] ⟶ _) ≫ PInfty.f n = PInfty.f n := by
simp only [PInfty_f, P_f_idem]
@[reassoc (attr := simp)]
theorem PInfty_idem : (PInfty : K[X] ⟶ _) ≫ PInfty = PInfty := by
ext n
exact PInfty_f_idem n
@[reassoc (attr := simp)]
theorem QInfty_f_idem (n : ℕ) : (QInfty.f n : X _[n] ⟶ _) ≫ QInfty.f n = QInfty.f n :=
Q_f_idem _ _
@[reassoc (attr := simp)]
theorem QInfty_idem : (QInfty : K[X] ⟶ _) ≫ QInfty = QInfty := by
ext n
exact QInfty_f_idem n
@[reassoc (attr := simp)]
theorem PInfty_f_comp_QInfty_f (n : ℕ) : (PInfty.f n : X _[n] ⟶ _) ≫ QInfty.f n = 0 := by
dsimp only [QInfty]
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, comp_sub, comp_id,
PInfty_f_idem, sub_self]
@[reassoc (attr := simp)]
theorem PInfty_comp_QInfty : (PInfty : K[X] ⟶ _) ≫ QInfty = 0 := by
ext n
apply PInfty_f_comp_QInfty_f
@[reassoc (attr := simp)]
theorem QInfty_f_comp_PInfty_f (n : ℕ) : (QInfty.f n : X _[n] ⟶ _) ≫ PInfty.f n = 0 := by
dsimp only [QInfty]
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, sub_comp, id_comp,
PInfty_f_idem, sub_self]
@[reassoc (attr := simp)]
theorem QInfty_comp_PInfty : (QInfty : K[X] ⟶ _) ≫ PInfty = 0 := by
ext n
apply QInfty_f_comp_PInfty_f
@[simp]
theorem PInfty_add_QInfty : (PInfty : K[X] ⟶ _) + QInfty = 𝟙 _ := by
dsimp only [QInfty]
simp only [add_sub_cancel]
theorem PInfty_f_add_QInfty_f (n : ℕ) : (PInfty.f n : X _[n] ⟶ _) + QInfty.f n = 𝟙 _ :=
HomologicalComplex.congr_hom PInfty_add_QInfty n
variable (C)
/-- `PInfty` induces a natural transformation, i.e. an endomorphism of
the functor `alternatingFaceMapComplex C`. -/
@[simps]
noncomputable def natTransPInfty : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app _ := PInfty
naturality X Y f := by
ext n
exact PInfty_f_naturality n f
/-- The natural transformation in each degree that is induced by `natTransPInfty`. -/
@[simps!]
noncomputable def natTransPInfty_f (n : ℕ) :=
natTransPInfty C ◫ 𝟙 (HomologicalComplex.eval _ _ n)
variable {C}
@[simp]
theorem map_PInfty_f {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (n : ℕ) :
(PInfty : K[((whiskering C D).obj G).obj X] ⟶ _).f n =
G.map ((PInfty : AlternatingFaceMapComplex.obj X ⟶ _).f n) := by
simp only [PInfty_f, map_P]
/-- Given an object `Y : Karoubi (SimplicialObject C)`, this lemma
computes `PInfty` for the associated object in `SimplicialObject (Karoubi C)`
in terms of `PInfty` for `Y.X : SimplicialObject C` and `Y.p`. -/
theorem karoubi_PInfty_f {Y : Karoubi (SimplicialObject C)} (n : ℕ) :
((PInfty : K[(karoubiFunctorCategoryEmbedding _ _).obj Y] ⟶ _).f n).f =
Y.p.app (op [n]) ≫ (PInfty : K[Y.X] ⟶ _).f n := by
-- We introduce P_infty endomorphisms P₁, P₂, P₃, P₄ on various objects Y₁, Y₂, Y₃, Y₄.
let Y₁ := (karoubiFunctorCategoryEmbedding _ _).obj Y
let Y₂ := Y.X
let Y₃ := ((whiskering _ _).obj (toKaroubi C)).obj Y.X
let Y₄ := (karoubiFunctorCategoryEmbedding _ _).obj ((toKaroubi _).obj Y.X)
let P₁ : K[Y₁] ⟶ _ := PInfty
let P₂ : K[Y₂] ⟶ _ := PInfty
let P₃ : K[Y₃] ⟶ _ := PInfty
let P₄ : K[Y₄] ⟶ _ := PInfty
-- The statement of lemma relates P₁ and P₂.
change (P₁.f n).f = Y.p.app (op [n]) ≫ P₂.f n
-- The proof proceeds by obtaining relations h₃₂, h₄₃, h₁₄.
have h₃₂ : (P₃.f n).f = P₂.f n := Karoubi.hom_ext_iff.mp (map_PInfty_f (toKaroubi C) Y₂ n)
have h₄₃ : P₄.f n = P₃.f n := by
have h := Functor.congr_obj (toKaroubi_comp_karoubiFunctorCategoryEmbedding _ _) Y₂
simp only [P₃, P₄, ← natTransPInfty_f_app]
congr 1
have h₁₄ := Idempotents.natTrans_eq
((𝟙 (karoubiFunctorCategoryEmbedding SimplexCategoryᵒᵖ C)) ◫
(natTransPInfty_f (Karoubi C) n)) Y
dsimp [natTransPInfty_f] at h₁₄
erw [id_comp, id_comp, comp_id, comp_id] at h₁₄
-- We use the three equalities h₃₂, h₄₃, h₁₄.
rw [← h₃₂, ← h₄₃, h₁₄]
simp only [KaroubiFunctorCategoryEmbedding.map_app_f, Karoubi.decompId_p_f,
Karoubi.decompId_i_f, Karoubi.comp_f]
let π : Y₄ ⟶ Y₄ := (toKaroubi _ ⋙ karoubiFunctorCategoryEmbedding _ _).map Y.p
have eq := Karoubi.hom_ext_iff.mp (PInfty_f_naturality n π)
simp only [Karoubi.comp_f] at eq
dsimp [π] at eq
rw [← eq, app_idem_assoc Y (op [n])]
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\Projections.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.DoldKan.Faces
import Mathlib.CategoryTheory.Idempotents.Basic
/-!
# Construction of projections for the Dold-Kan correspondence
In this file, we construct endomorphisms `P q : K[X] ⟶ K[X]` for all
`q : ℕ`. We study how they behave with respect to face maps with the lemmas
`HigherFacesVanish.of_P`, `HigherFacesVanish.comp_P_eq_self` and
`comp_P_eq_self_iff`.
Then, we show that they are projections (see `P_f_idem`
and `P_idem`). They are natural transformations (see `natTransP`
and `P_f_naturality`) and are compatible with the application
of additive functors (see `map_P`).
By passing to the limit, these endomorphisms `P q` shall be used in `PInfty.lean`
in order to define `PInfty : K[X] ⟶ K[X]`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Category CategoryTheory.Limits CategoryTheory.Preadditive
CategoryTheory.SimplicialObject Opposite CategoryTheory.Idempotents
open Simplicial DoldKan
noncomputable section
namespace AlgebraicTopology
namespace DoldKan
variable {C : Type*} [Category C] [Preadditive C] {X : SimplicialObject C}
/-- This is the inductive definition of the projections `P q : K[X] ⟶ K[X]`,
with `P 0 := 𝟙 _` and `P (q+1) := P q ≫ (𝟙 _ + Hσ q)`. -/
noncomputable def P : ℕ → (K[X] ⟶ K[X])
| 0 => 𝟙 _
| q + 1 => P q ≫ (𝟙 _ + Hσ q)
-- Porting note: `P_zero` and `P_succ` have been added to ease the port, because
-- `unfold P` would sometimes unfold to a `match` rather than the induction formula
lemma P_zero : (P 0 : K[X] ⟶ K[X]) = 𝟙 _ := rfl
lemma P_succ (q : ℕ) : (P (q+1) : K[X] ⟶ K[X]) = P q ≫ (𝟙 _ + Hσ q) := rfl
/-- All the `P q` coincide with `𝟙 _` in degree 0. -/
@[simp]
theorem P_f_0_eq (q : ℕ) : ((P q).f 0 : X _[0] ⟶ X _[0]) = 𝟙 _ := by
induction' q with q hq
· rfl
· simp only [P_succ, HomologicalComplex.add_f_apply, HomologicalComplex.comp_f,
HomologicalComplex.id_f, id_comp, hq, Hσ_eq_zero, add_zero]
/-- `Q q` is the complement projection associated to `P q` -/
def Q (q : ℕ) : K[X] ⟶ K[X] :=
𝟙 _ - P q
theorem P_add_Q (q : ℕ) : P q + Q q = 𝟙 K[X] := by
rw [Q]
abel
theorem P_add_Q_f (q n : ℕ) : (P q).f n + (Q q).f n = 𝟙 (X _[n]) :=
HomologicalComplex.congr_hom (P_add_Q q) n
@[simp]
theorem Q_zero : (Q 0 : K[X] ⟶ _) = 0 :=
sub_self _
theorem Q_succ (q : ℕ) : (Q (q + 1) : K[X] ⟶ _) = Q q - P q ≫ Hσ q := by
simp only [Q, P_succ, comp_add, comp_id]
abel
/-- All the `Q q` coincide with `0` in degree 0. -/
@[simp]
theorem Q_f_0_eq (q : ℕ) : ((Q q).f 0 : X _[0] ⟶ X _[0]) = 0 := by
simp only [HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, Q, P_f_0_eq, sub_self]
namespace HigherFacesVanish
/-- This lemma expresses the vanishing of
`(P q).f (n+1) ≫ X.δ k : X _[n+1] ⟶ X _[n]` when `k≠0` and `k≥n-q+2` -/
theorem of_P : ∀ q n : ℕ, HigherFacesVanish q ((P q).f (n + 1) : X _[n + 1] ⟶ X _[n + 1])
| 0 => fun n j hj₁ => by omega
| q + 1 => fun n => by
simp only [P_succ]
exact (of_P q n).induction
@[reassoc]
theorem comp_P_eq_self {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} (v : HigherFacesVanish q φ) :
φ ≫ (P q).f (n + 1) = φ := by
induction' q with q hq
· simp only [P_zero]
apply comp_id
· simp only [P_succ, comp_add, HomologicalComplex.comp_f, HomologicalComplex.add_f_apply,
comp_id, ← assoc, hq v.of_succ, add_right_eq_self]
by_cases hqn : n < q
· exact v.of_succ.comp_Hσ_eq_zero hqn
· obtain ⟨a, ha⟩ := Nat.le.dest (not_lt.mp hqn)
have hnaq : n = a + q := by omega
simp only [v.of_succ.comp_Hσ_eq hnaq, neg_eq_zero, ← assoc]
have eq := v ⟨a, by omega⟩ (by
simp only [hnaq, Nat.succ_eq_add_one, add_assoc]
rfl)
simp only [Fin.succ_mk] at eq
simp only [eq, zero_comp]
end HigherFacesVanish
theorem comp_P_eq_self_iff {Y : C} {n q : ℕ} {φ : Y ⟶ X _[n + 1]} :
φ ≫ (P q).f (n + 1) = φ ↔ HigherFacesVanish q φ := by
constructor
· intro hφ
rw [← hφ]
apply HigherFacesVanish.of_comp
apply HigherFacesVanish.of_P
· exact HigherFacesVanish.comp_P_eq_self
@[reassoc (attr := simp)]
theorem P_f_idem (q n : ℕ) : ((P q).f n : X _[n] ⟶ _) ≫ (P q).f n = (P q).f n := by
rcases n with (_|n)
· rw [P_f_0_eq q, comp_id]
· exact (HigherFacesVanish.of_P q n).comp_P_eq_self
@[reassoc (attr := simp)]
theorem Q_f_idem (q n : ℕ) : ((Q q).f n : X _[n] ⟶ _) ≫ (Q q).f n = (Q q).f n :=
idem_of_id_sub_idem _ (P_f_idem q n)
@[reassoc (attr := simp)]
theorem P_idem (q : ℕ) : (P q : K[X] ⟶ K[X]) ≫ P q = P q := by
ext n
exact P_f_idem q n
@[reassoc (attr := simp)]
theorem Q_idem (q : ℕ) : (Q q : K[X] ⟶ K[X]) ≫ Q q = Q q := by
ext n
exact Q_f_idem q n
/-- For each `q`, `P q` is a natural transformation. -/
@[simps]
def natTransP (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app X := P q
naturality _ _ f := by
induction' q with q hq
· dsimp [alternatingFaceMapComplex]
simp only [P_zero, id_comp, comp_id]
· simp only [P_succ, add_comp, comp_add, assoc, comp_id, hq, reassoc_of% hq]
erw [(natTransHσ q).naturality f]
rfl
@[reassoc (attr := simp)]
theorem P_f_naturality (q n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op [n]) ≫ (P q).f n = (P q).f n ≫ f.app (op [n]) :=
HomologicalComplex.congr_hom ((natTransP q).naturality f) n
@[reassoc (attr := simp)]
theorem Q_f_naturality (q n : ℕ) {X Y : SimplicialObject C} (f : X ⟶ Y) :
f.app (op [n]) ≫ (Q q).f n = (Q q).f n ≫ f.app (op [n]) := by
simp only [Q, HomologicalComplex.sub_f_apply, HomologicalComplex.id_f, comp_sub, P_f_naturality,
sub_comp, sub_left_inj]
dsimp
simp only [comp_id, id_comp]
/-- For each `q`, `Q q` is a natural transformation. -/
@[simps]
def natTransQ (q : ℕ) : alternatingFaceMapComplex C ⟶ alternatingFaceMapComplex C where
app X := Q q
theorem map_P {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
G.map ((P q : K[X] ⟶ _).f n) = (P q : K[((whiskering C D).obj G).obj X] ⟶ _).f n := by
induction' q with q hq
· simp only [P_zero]
apply G.map_id
· simp only [P_succ, comp_add, HomologicalComplex.comp_f, HomologicalComplex.add_f_apply,
comp_id, Functor.map_add, Functor.map_comp, hq, map_Hσ]
theorem map_Q {D : Type*} [Category D] [Preadditive D] (G : C ⥤ D) [G.Additive]
(X : SimplicialObject C) (q n : ℕ) :
G.map ((Q q : K[X] ⟶ _).f n) = (Q q : K[((whiskering C D).obj G).obj X] ⟶ _).f n := by
rw [← add_right_inj (G.map ((P q : K[X] ⟶ _).f n)), ← G.map_add, map_P G X q n, P_add_Q_f,
P_add_Q_f]
apply G.map_id
end DoldKan
end AlgebraicTopology
|
AlgebraicTopology\DoldKan\SplitSimplicialObject.lean | /-
Copyright (c) 2022 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.SplitSimplicialObject
import Mathlib.AlgebraicTopology.DoldKan.Degeneracies
import Mathlib.AlgebraicTopology.DoldKan.FunctorN
/-!
# Split simplicial objects in preadditive categories
In this file we define a functor `nondegComplex : SimplicialObject.Split C ⥤ ChainComplex C ℕ`
when `C` is a preadditive category with finite coproducts, and get an isomorphism
`toKaroubiNondegComplexFunctorIsoN₁ : nondegComplex ⋙ toKaroubi _ ≅ forget C ⋙ DoldKan.N₁`.
(See `Equivalence.lean` for the general strategy of proof of the Dold-Kan equivalence.)
-/
open CategoryTheory CategoryTheory.Limits CategoryTheory.Category CategoryTheory.Preadditive
CategoryTheory.Idempotents Opposite AlgebraicTopology AlgebraicTopology.DoldKan
Simplicial DoldKan
namespace SimplicialObject
namespace Splitting
variable {C : Type*} [Category C] {X : SimplicialObject C}
(s : Splitting X)
/-- The projection on a summand of the coproduct decomposition given
by a splitting of a simplicial object. -/
noncomputable def πSummand [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
X.obj Δ ⟶ s.N A.1.unop.len :=
s.desc Δ (fun B => by
by_cases h : B = A
· exact eqToHom (by subst h; rfl)
· exact 0)
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_id [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A : IndexSet Δ) :
(s.cofan Δ).inj A ≫ s.πSummand A = 𝟙 _ := by
simp [πSummand]
@[reassoc (attr := simp)]
theorem cofan_inj_πSummand_eq_zero [HasZeroMorphisms C] {Δ : SimplexCategoryᵒᵖ} (A B : IndexSet Δ)
(h : B ≠ A) : (s.cofan Δ).inj A ≫ s.πSummand B = 0 := by
dsimp [πSummand]
rw [ι_desc, dif_neg h.symm]
variable [Preadditive C]
theorem decomposition_id (Δ : SimplexCategoryᵒᵖ) :
𝟙 (X.obj Δ) = ∑ A : IndexSet Δ, s.πSummand A ≫ (s.cofan Δ).inj A := by
apply s.hom_ext'
intro A
dsimp
erw [comp_id, comp_sum, Finset.sum_eq_single A, cofan_inj_πSummand_eq_id_assoc]
· intro B _ h₂
rw [s.cofan_inj_πSummand_eq_zero_assoc _ _ h₂, zero_comp]
· simp
@[reassoc (attr := simp)]
theorem σ_comp_πSummand_id_eq_zero {n : ℕ} (i : Fin (n + 1)) :
X.σ i ≫ s.πSummand (IndexSet.id (op [n + 1])) = 0 := by
apply s.hom_ext'
intro A
dsimp only [SimplicialObject.σ]
rw [comp_zero, s.cofan_inj_epi_naturality_assoc A (SimplexCategory.σ i).op,
cofan_inj_πSummand_eq_zero]
rw [ne_comm]
change ¬(A.epiComp (SimplexCategory.σ i).op).EqId
rw [IndexSet.eqId_iff_len_eq]
have h := SimplexCategory.len_le_of_epi (inferInstance : Epi A.e)
dsimp at h ⊢
omega
/-- If a simplicial object `X` in an additive category is split,
then `PInfty` vanishes on all the summands of `X _[n]` which do
not correspond to the identity of `[n]`. -/
theorem cofan_inj_comp_PInfty_eq_zero {X : SimplicialObject C} (s : SimplicialObject.Splitting X)
{n : ℕ} (A : SimplicialObject.Splitting.IndexSet (op [n])) (hA : ¬A.EqId) :
(s.cofan _).inj A ≫ PInfty.f n = 0 := by
rw [SimplicialObject.Splitting.IndexSet.eqId_iff_mono] at hA
rw [SimplicialObject.Splitting.cofan_inj_eq, assoc, degeneracy_comp_PInfty X n A.e hA, comp_zero]
theorem comp_PInfty_eq_zero_iff {Z : C} {n : ℕ} (f : Z ⟶ X _[n]) :
f ≫ PInfty.f n = 0 ↔ f ≫ s.πSummand (IndexSet.id (op [n])) = 0 := by
constructor
· intro h
rcases n with _|n
· dsimp at h
rw [comp_id] at h
rw [h, zero_comp]
· have h' := f ≫= PInfty_f_add_QInfty_f (n + 1)
dsimp at h'
rw [comp_id, comp_add, h, zero_add] at h'
rw [← h', assoc, QInfty_f, decomposition_Q, Preadditive.sum_comp, Preadditive.comp_sum,
Finset.sum_eq_zero]
intro i _
simp only [assoc, σ_comp_πSummand_id_eq_zero, comp_zero]
· intro h
rw [← comp_id f, assoc, s.decomposition_id, Preadditive.sum_comp, Preadditive.comp_sum,
Fintype.sum_eq_zero]
intro A
by_cases hA : A.EqId
· dsimp at hA
subst hA
rw [assoc, reassoc_of% h, zero_comp]
· simp only [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]
@[reassoc (attr := simp)]
theorem PInfty_comp_πSummand_id (n : ℕ) :
PInfty.f n ≫ s.πSummand (IndexSet.id (op [n])) = s.πSummand (IndexSet.id (op [n])) := by
conv_rhs => rw [← id_comp (s.πSummand _)]
symm
rw [← sub_eq_zero, ← sub_comp, ← comp_PInfty_eq_zero_iff, sub_comp, id_comp, PInfty_f_idem,
sub_self]
@[reassoc (attr := simp)]
theorem πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty (n : ℕ) :
s.πSummand (IndexSet.id (op [n])) ≫ (s.cofan _).inj (IndexSet.id (op [n])) ≫ PInfty.f n =
PInfty.f n := by
conv_rhs => rw [← id_comp (PInfty.f n)]
erw [s.decomposition_id, Preadditive.sum_comp]
rw [Fintype.sum_eq_single (IndexSet.id (op [n])), assoc]
rintro A (hA : ¬A.EqId)
rw [assoc, s.cofan_inj_comp_PInfty_eq_zero A hA, comp_zero]
/-- The differentials `s.d i j : s.N i ⟶ s.N j` on nondegenerate simplices of a split
simplicial object are induced by the differentials on the alternating face map complex. -/
@[simp]
noncomputable def d (i j : ℕ) : s.N i ⟶ s.N j :=
(s.cofan _).inj (IndexSet.id (op [i])) ≫ K[X].d i j ≫ s.πSummand (IndexSet.id (op [j]))
theorem ιSummand_comp_d_comp_πSummand_eq_zero (j k : ℕ) (A : IndexSet (op [j])) (hA : ¬A.EqId) :
(s.cofan _).inj A ≫ K[X].d j k ≫ s.πSummand (IndexSet.id (op [k])) = 0 := by
rw [A.eqId_iff_mono] at hA
rw [← assoc, ← s.comp_PInfty_eq_zero_iff, assoc, ← PInfty.comm j k, s.cofan_inj_eq, assoc,
degeneracy_comp_PInfty_assoc X j A.e hA, zero_comp, comp_zero]
/-- If `s` is a splitting of a simplicial object `X` in a preadditive category,
`s.nondegComplex` is a chain complex which is given in degree `n` by
the nondegenerate `n`-simplices of `X`. -/
@[simps]
noncomputable def nondegComplex : ChainComplex C ℕ where
X := s.N
d := s.d
shape i j hij := by simp only [d, K[X].shape i j hij, zero_comp, comp_zero]
d_comp_d' i j k _ _ := by
simp only [d, assoc]
have eq : K[X].d i j ≫ 𝟙 (X.obj (op [j])) ≫ K[X].d j k ≫
s.πSummand (IndexSet.id (op [k])) = 0 := by
erw [id_comp, HomologicalComplex.d_comp_d_assoc, zero_comp]
rw [s.decomposition_id] at eq
classical
rw [Fintype.sum_eq_add_sum_compl (IndexSet.id (op [j])), add_comp, comp_add, assoc,
Preadditive.sum_comp, Preadditive.comp_sum, Finset.sum_eq_zero, add_zero] at eq
swap
· intro A hA
simp only [Finset.mem_compl, Finset.mem_singleton] at hA
simp only [assoc, ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ _ hA, comp_zero]
rw [eq, comp_zero]
/-- The chain complex `s.nondegComplex` attached to a splitting of a simplicial object `X`
becomes isomorphic to the normalized Moore complex `N₁.obj X` defined as a formal direct
factor in the category `Karoubi (ChainComplex C ℕ)`. -/
@[simps]
noncomputable def toKaroubiNondegComplexIsoN₁ :
(toKaroubi _).obj s.nondegComplex ≅ N₁.obj X where
hom :=
{ f :=
{ f := fun n => (s.cofan _).inj (IndexSet.id (op [n])) ≫ PInfty.f n
comm' := fun i j _ => by
dsimp
rw [assoc, assoc, assoc, πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty,
HomologicalComplex.Hom.comm] }
comm := by
ext n
dsimp
rw [id_comp, assoc, PInfty_f_idem] }
inv :=
{ f :=
{ f := fun n => s.πSummand (IndexSet.id (op [n]))
comm' := fun i j _ => by
dsimp
slice_rhs 1 1 => rw [← id_comp (K[X].d i j)]
erw [s.decomposition_id]
rw [sum_comp, sum_comp, Finset.sum_eq_single (IndexSet.id (op [i])), assoc, assoc]
· intro A _ hA
simp only [assoc, s.ιSummand_comp_d_comp_πSummand_eq_zero _ _ _ hA, comp_zero]
· simp only [Finset.mem_univ, not_true, IsEmpty.forall_iff] }
comm := by
ext n
dsimp
simp only [comp_id, PInfty_comp_πSummand_id] }
hom_inv_id := by
ext n
simp only [assoc, PInfty_comp_πSummand_id, Karoubi.comp_f, HomologicalComplex.comp_f,
cofan_inj_πSummand_eq_id]
rfl
inv_hom_id := by
ext n
simp only [πSummand_comp_cofan_inj_id_comp_PInfty_eq_PInfty, Karoubi.comp_f,
HomologicalComplex.comp_f, N₁_obj_p, Karoubi.id_f]
end Splitting
namespace Split
variable {C : Type*} [Category C] [Preadditive C] [HasFiniteCoproducts C]
/-- The functor which sends a split simplicial object in a preadditive category to
the chain complex which consists of nondegenerate simplices. -/
@[simps]
noncomputable def nondegComplexFunctor : Split C ⥤ ChainComplex C ℕ where
obj S := S.s.nondegComplex
map {S₁ S₂} Φ :=
{ f := Φ.f
comm' := fun i j _ => by
dsimp
erw [← cofan_inj_naturality_symm_assoc Φ (Splitting.IndexSet.id (op [i])),
((alternatingFaceMapComplex C).map Φ.F).comm_assoc i j]
simp only [assoc]
congr 2
apply S₁.s.hom_ext'
intro A
dsimp [alternatingFaceMapComplex]
erw [cofan_inj_naturality_symm_assoc Φ A]
by_cases h : A.EqId
· dsimp at h
subst h
rw [Splitting.cofan_inj_πSummand_eq_id]
dsimp
rw [comp_id, Splitting.cofan_inj_πSummand_eq_id_assoc]
· rw [S₁.s.cofan_inj_πSummand_eq_zero_assoc _ _ (Ne.symm h),
S₂.s.cofan_inj_πSummand_eq_zero _ _ (Ne.symm h), zero_comp, comp_zero] }
/-- The natural isomorphism (in `Karoubi (ChainComplex C ℕ)`) between the chain complex
of nondegenerate simplices of a split simplicial object and the normalized Moore complex
defined as a formal direct factor of the alternating face map complex. -/
@[simps!]
noncomputable def toKaroubiNondegComplexFunctorIsoN₁ :
nondegComplexFunctor ⋙ toKaroubi (ChainComplex C ℕ) ≅ forget C ⋙ DoldKan.N₁ :=
NatIso.ofComponents (fun S => S.s.toKaroubiNondegComplexIsoN₁) fun Φ => by
ext n
dsimp
simp only [Karoubi.comp_f, toKaroubi_map_f, HomologicalComplex.comp_f,
nondegComplexFunctor_map_f, Splitting.toKaroubiNondegComplexIsoN₁_hom_f_f, N₁_map_f,
AlternatingFaceMapComplex.map_f, assoc, PInfty_f_idem_assoc]
erw [← Split.cofan_inj_naturality_symm_assoc Φ (Splitting.IndexSet.id (op [n]))]
rw [PInfty_f_naturality]
end Split
end SimplicialObject
|
AlgebraicTopology\FundamentalGroupoid\Basic.lean | /-
Copyright (c) 2021 Shing Tak Lam. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Shing Tak Lam
-/
import Mathlib.CategoryTheory.Category.Grpd
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Homotopy.Path
import Mathlib.Data.Set.Subsingleton
/-!
# Fundamental groupoid of a space
Given a topological space `X`, we can define the fundamental groupoid of `X` to be the category with
objects being points of `X`, and morphisms `x ⟶ y` being paths from `x` to `y`, quotiented by
homotopy equivalence. With this, the fundamental group of `X` based at `x` is just the automorphism
group of `x`.
-/
open CategoryTheory
universe u v
variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open unitInterval
namespace Path
namespace Homotopy
section
/-- Auxiliary function for `reflTransSymm`. -/
def reflTransSymmAux (x : I × I) : ℝ :=
if (x.2 : ℝ) ≤ 1 / 2 then x.1 * 2 * x.2 else x.1 * (2 - 2 * x.2)
@[continuity]
theorem continuous_reflTransSymmAux : Continuous reflTransSymmAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_
· continuity
· continuity
· continuity
· continuity
intro x hx
norm_num [hx, mul_assoc]
theorem reflTransSymmAux_mem_I (x : I × I) : reflTransSymmAux x ∈ I := by
dsimp only [reflTransSymmAux]
split_ifs
· constructor
· apply mul_nonneg
· apply mul_nonneg
· unit_interval
· norm_num
· unit_interval
· rw [mul_assoc]
apply mul_le_one
· unit_interval
· apply mul_nonneg
· norm_num
· unit_interval
· linarith
· constructor
· apply mul_nonneg
· unit_interval
linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· apply mul_le_one
· unit_interval
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
· linarith [unitInterval.nonneg x.2, unitInterval.le_one x.2]
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₀` to
`p.trans p.symm`. -/
def reflTransSymm (p : Path x₀ x₁) : Homotopy (Path.refl x₀) (p.trans p.symm) where
toFun x := p ⟨reflTransSymmAux x, reflTransSymmAux_mem_I x⟩
continuous_toFun := by continuity
map_zero_left := by simp [reflTransSymmAux]
map_one_left x := by
dsimp only [reflTransSymmAux, Path.coe_toContinuousMap, Path.trans]
change _ = ite _ _ _
split_ifs with h
· rw [Path.extend, Set.IccExtend_of_mem]
· norm_num
· rw [unitInterval.mul_pos_mem_iff zero_lt_two]
exact ⟨unitInterval.nonneg x, h⟩
· rw [Path.symm, Path.extend, Set.IccExtend_of_mem]
· simp only [Set.Icc.coe_one, one_mul, coe_mk_mk, Function.comp_apply]
congr 1
ext
norm_num [sub_sub_eq_add_sub]
· rw [unitInterval.two_mul_sub_one_mem_iff]
exact ⟨(not_le.1 h).le, unitInterval.le_one x⟩
prop' t x hx := by
simp only [Set.mem_singleton_iff, Set.mem_insert_iff] at hx
simp only [ContinuousMap.coe_mk, coe_toContinuousMap, Path.refl_apply]
cases hx with
| inl hx
| inr hx =>
rw [hx]
norm_num [reflTransSymmAux]
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from the constant path based at `x₁` to
`p.symm.trans p`. -/
def reflSymmTrans (p : Path x₀ x₁) : Homotopy (Path.refl x₁) (p.symm.trans p) :=
(reflTransSymm p.symm).cast rfl <| congr_arg _ (Path.symm_symm _)
end
section TransRefl
/-- Auxiliary function for `trans_refl_reparam`. -/
def transReflReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 2 then 2 * t else 1
@[continuity]
theorem continuous_transReflReparamAux : Continuous transReflReparamAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_ <;>
[continuity; continuity; continuity; continuity; skip]
intro x hx
simp [hx]
theorem transReflReparamAux_mem_I (t : I) : transReflReparamAux t ∈ I := by
unfold transReflReparamAux
split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t]
theorem transReflReparamAux_zero : transReflReparamAux 0 = 0 := by
norm_num [transReflReparamAux]
theorem transReflReparamAux_one : transReflReparamAux 1 = 1 := by
norm_num [transReflReparamAux]
theorem trans_refl_reparam (p : Path x₀ x₁) :
p.trans (Path.refl x₁) =
p.reparam (fun t => ⟨transReflReparamAux t, transReflReparamAux_mem_I t⟩) (by continuity)
(Subtype.ext transReflReparamAux_zero) (Subtype.ext transReflReparamAux_one) := by
ext
unfold transReflReparamAux
simp only [Path.trans_apply, not_le, coe_reparam, Function.comp_apply, one_div, Path.refl_apply]
split_ifs
· rfl
· rfl
· simp
· simp
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from `p.trans (Path.refl x₁)` to `p`. -/
def transRefl (p : Path x₀ x₁) : Homotopy (p.trans (Path.refl x₁)) p :=
((Homotopy.reparam p (fun t => ⟨transReflReparamAux t, transReflReparamAux_mem_I t⟩)
(by continuity) (Subtype.ext transReflReparamAux_zero)
(Subtype.ext transReflReparamAux_one)).cast
rfl (trans_refl_reparam p).symm).symm
/-- For any path `p` from `x₀` to `x₁`, we have a homotopy from `(Path.refl x₀).trans p` to `p`. -/
def reflTrans (p : Path x₀ x₁) : Homotopy ((Path.refl x₀).trans p) p :=
(transRefl p.symm).symm₂.cast (by simp) (by simp)
end TransRefl
section Assoc
/-- Auxiliary function for `trans_assoc_reparam`. -/
def transAssocReparamAux (t : I) : ℝ :=
if (t : ℝ) ≤ 1 / 4 then 2 * t else if (t : ℝ) ≤ 1 / 2 then t + 1 / 4 else 1 / 2 * (t + 1)
@[continuity]
theorem continuous_transAssocReparamAux : Continuous transAssocReparamAux := by
refine continuous_if_le ?_ ?_ (Continuous.continuousOn ?_)
(continuous_if_le ?_ ?_
(Continuous.continuousOn ?_) (Continuous.continuousOn ?_) ?_).continuousOn
?_ <;>
[continuity; continuity; continuity; continuity; continuity; continuity; continuity; skip;
skip] <;>
· intro x hx
norm_num [hx]
theorem transAssocReparamAux_mem_I (t : I) : transAssocReparamAux t ∈ I := by
unfold transAssocReparamAux
split_ifs <;> constructor <;> linarith [unitInterval.le_one t, unitInterval.nonneg t]
theorem transAssocReparamAux_zero : transAssocReparamAux 0 = 0 := by
norm_num [transAssocReparamAux]
theorem transAssocReparamAux_one : transAssocReparamAux 1 = 1 := by
norm_num [transAssocReparamAux]
theorem trans_assoc_reparam {x₀ x₁ x₂ x₃ : X} (p : Path x₀ x₁) (q : Path x₁ x₂) (r : Path x₂ x₃) :
(p.trans q).trans r =
(p.trans (q.trans r)).reparam
(fun t => ⟨transAssocReparamAux t, transAssocReparamAux_mem_I t⟩) (by continuity)
(Subtype.ext transAssocReparamAux_zero) (Subtype.ext transAssocReparamAux_one) := by
ext x
simp only [transAssocReparamAux, Path.trans_apply, mul_inv_cancel_left₀, not_le,
Function.comp_apply, Ne, not_false_iff, one_ne_zero, mul_ite, Subtype.coe_mk,
Path.coe_reparam]
-- TODO: why does split_ifs not reduce the ifs??????
split_ifs with h₁ h₂ h₃ h₄ h₅
· rfl
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· have h : 2 * (2 * (x : ℝ)) - 1 = 2 * (2 * (↑x + 1 / 4) - 1) := by linarith
simp [h₂, h₁, h, dif_neg (show ¬False from id), dif_pos True.intro, if_false, if_true]
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· exfalso
linarith
· congr
ring
/-- For paths `p q r`, we have a homotopy from `(p.trans q).trans r` to `p.trans (q.trans r)`. -/
def transAssoc {x₀ x₁ x₂ x₃ : X} (p : Path x₀ x₁) (q : Path x₁ x₂) (r : Path x₂ x₃) :
Homotopy ((p.trans q).trans r) (p.trans (q.trans r)) :=
((Homotopy.reparam (p.trans (q.trans r))
(fun t => ⟨transAssocReparamAux t, transAssocReparamAux_mem_I t⟩) (by continuity)
(Subtype.ext transAssocReparamAux_zero) (Subtype.ext transAssocReparamAux_one)).cast
rfl (trans_assoc_reparam p q r).symm).symm
end Assoc
end Homotopy
end Path
/-- The fundamental groupoid of a space `X` is defined to be a wrapper around `X`, and we
subsequently put a `CategoryTheory.Groupoid` structure on it. -/
@[ext]
structure FundamentalGroupoid (X : Type u) where
/-- View a term of `FundamentalGroupoid X` as a term of `X`. -/
as : X
namespace FundamentalGroupoid
/-- The equivalence between `X` and the underlying type of its fundamental groupoid.
This is useful for transferring constructions (instances, etc.)
from `X` to `πₓ X`. -/
@[simps]
def equiv (X : Type*) : FundamentalGroupoid X ≃ X where
toFun x := x.as
invFun x := .mk x
left_inv _ := rfl
right_inv _ := rfl
@[simp]
lemma isEmpty_iff (X : Type*) :
IsEmpty (FundamentalGroupoid X) ↔ IsEmpty X :=
equiv _ |>.isEmpty_congr
instance (X : Type*) [IsEmpty X] :
IsEmpty (FundamentalGroupoid X) :=
equiv _ |>.isEmpty
@[simp]
lemma nonempty_iff (X : Type*) :
Nonempty (FundamentalGroupoid X) ↔ Nonempty X :=
equiv _ |>.nonempty_congr
instance (X : Type*) [Nonempty X] :
Nonempty (FundamentalGroupoid X) :=
equiv _ |>.nonempty
@[simp]
lemma subsingleton_iff (X : Type*) :
Subsingleton (FundamentalGroupoid X) ↔ Subsingleton X :=
equiv _ |>.subsingleton_congr
instance (X : Type*) [Subsingleton X] :
Subsingleton (FundamentalGroupoid X) :=
equiv _ |>.subsingleton
-- TODO: It seems that `Equiv.nontrivial_congr` doesn't exist.
-- Once it is added, please add the corresponding lemma and instance.
instance {X : Type u} [Inhabited X] : Inhabited (FundamentalGroupoid X) :=
⟨⟨default⟩⟩
attribute [local instance] Path.Homotopic.setoid
instance : CategoryTheory.Groupoid (FundamentalGroupoid X) where
Hom x y := Path.Homotopic.Quotient x.as y.as
id x := ⟦Path.refl x.as⟧
comp {x y z} := Path.Homotopic.Quotient.comp
id_comp {x y} f :=
Quotient.inductionOn f fun a =>
show ⟦(Path.refl x.as).trans a⟧ = ⟦a⟧ from Quotient.sound ⟨Path.Homotopy.reflTrans a⟩
comp_id {x y} f :=
Quotient.inductionOn f fun a =>
show ⟦a.trans (Path.refl y.as)⟧ = ⟦a⟧ from Quotient.sound ⟨Path.Homotopy.transRefl a⟩
assoc {w x y z} f g h :=
Quotient.inductionOn₃ f g h fun p q r =>
show ⟦(p.trans q).trans r⟧ = ⟦p.trans (q.trans r)⟧ from
Quotient.sound ⟨Path.Homotopy.transAssoc p q r⟩
inv {x y} p :=
Quotient.lift (fun l : Path x.as y.as => ⟦l.symm⟧)
(by
rintro a b ⟨h⟩
simp only
rw [Quotient.eq]
exact ⟨h.symm₂⟩)
p
inv_comp {x y} f :=
Quotient.inductionOn f fun a =>
show ⟦a.symm.trans a⟧ = ⟦Path.refl y.as⟧ from
Quotient.sound ⟨(Path.Homotopy.reflSymmTrans a).symm⟩
comp_inv {x y} f :=
Quotient.inductionOn f fun a =>
show ⟦a.trans a.symm⟧ = ⟦Path.refl x.as⟧ from
Quotient.sound ⟨(Path.Homotopy.reflTransSymm a).symm⟩
theorem comp_eq (x y z : FundamentalGroupoid X) (p : x ⟶ y) (q : y ⟶ z) : p ≫ q = p.comp q := rfl
theorem id_eq_path_refl (x : FundamentalGroupoid X) : 𝟙 x = ⟦Path.refl x.as⟧ := rfl
/-- The functor sending a topological space `X` to its fundamental groupoid. -/
def fundamentalGroupoidFunctor : TopCat ⥤ CategoryTheory.Grpd where
obj X := { α := FundamentalGroupoid X }
map f :=
{ obj := fun x => ⟨f x.as⟩
map := fun {X Y} p => by exact Path.Homotopic.Quotient.mapFn p f
map_id := fun X => rfl
map_comp := fun {x y z} p q => by
refine Quotient.inductionOn₂ p q fun a b => ?_
simp only [comp_eq, ← Path.Homotopic.map_lift, ← Path.Homotopic.comp_lift, Path.map_trans] }
map_id X := by
simp only
change _ = (⟨_, _, _⟩ : FundamentalGroupoid X ⥤ FundamentalGroupoid X)
congr
ext x y p
refine Quotient.inductionOn p fun q => ?_
rw [← Path.Homotopic.map_lift]
conv_rhs => rw [← q.map_id]
rfl
map_comp f g := by
simp only
congr
ext x y p
refine Quotient.inductionOn p fun q => ?_
simp only [Quotient.map_mk, Path.map_map, Quotient.eq']
rfl
@[inherit_doc] scoped notation "π" => FundamentalGroupoid.fundamentalGroupoidFunctor
/-- The fundamental groupoid of a topological space. -/
scoped notation "πₓ" => FundamentalGroupoid.fundamentalGroupoidFunctor.obj
/-- The functor between fundamental groupoids induced by a continuous map. -/
scoped notation "πₘ" => FundamentalGroupoid.fundamentalGroupoidFunctor.map
theorem map_eq {X Y : TopCat} {x₀ x₁ : X} (f : C(X, Y)) (p : Path.Homotopic.Quotient x₀ x₁) :
(πₘ f).map p = p.mapFn f := rfl
/-- Help the typechecker by converting a point in a groupoid back to a point in
the underlying topological space. -/
abbrev toTop {X : TopCat} (x : πₓ X) : X := x.as
/-- Help the typechecker by converting a point in a topological space to a
point in the fundamental groupoid of that space. -/
abbrev fromTop {X : TopCat} (x : X) : πₓ X := ⟨x⟩
/-- Help the typechecker by converting an arrow in the fundamental groupoid of
a topological space back to a path in that space (i.e., `Path.Homotopic.Quotient`). -/
-- Porting note: Added `(X := X)` to the type.
abbrev toPath {X : TopCat} {x₀ x₁ : πₓ X} (p : x₀ ⟶ x₁) :
Path.Homotopic.Quotient (X := X) x₀.as x₁.as :=
p
/-- Help the typechecker by converting a path in a topological space to an arrow in the
fundamental groupoid of that space. -/
abbrev fromPath {X : TopCat} {x₀ x₁ : X} (p : Path.Homotopic.Quotient x₀ x₁) :
FundamentalGroupoid.mk x₀ ⟶ FundamentalGroupoid.mk x₁ := p
end FundamentalGroupoid
|
AlgebraicTopology\FundamentalGroupoid\FundamentalGroup.lean | /-
Copyright (c) 2021 Mark Lavrentyev. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mark Lavrentyev
-/
import Mathlib.CategoryTheory.Groupoid
import Mathlib.Topology.Category.TopCat.Basic
import Mathlib.Topology.Connected.PathConnected
import Mathlib.Topology.Homotopy.Path
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
/-!
# Fundamental group of a space
Given a topological space `X` and a basepoint `x`, the fundamental group is the automorphism group
of `x` i.e. the group with elements being loops based at `x` (quotiented by homotopy equivalence).
-/
universe u v
variable {X : Type u} {Y : Type v} [TopologicalSpace X] [TopologicalSpace Y]
variable {x₀ x₁ : X}
noncomputable section
open CategoryTheory
/-- The fundamental group is the automorphism group (vertex group) of the basepoint
in the fundamental groupoid. -/
def FundamentalGroup (X : Type u) [TopologicalSpace X] (x : X) :=
@Aut (FundamentalGroupoid X) _ ⟨x⟩
instance (X : Type u) [TopologicalSpace X] (x : X) : Group (FundamentalGroup X x) := by
dsimp only [FundamentalGroup]
infer_instance
instance (X : Type u) [TopologicalSpace X] (x : X) : Inhabited (FundamentalGroup X x) := by
dsimp only [FundamentalGroup]
infer_instance
namespace FundamentalGroup
attribute [local instance] Path.Homotopic.setoid
-- Porting note: removed this attribute
--attribute [local reducible] FundamentalGroupoid
/-- Get an isomorphism between the fundamental groups at two points given a path -/
def fundamentalGroupMulEquivOfPath (p : Path x₀ x₁) :
FundamentalGroup X x₀ ≃* FundamentalGroup X x₁ :=
Aut.autMulEquivOfIso (asIso ⟦p⟧)
variable (x₀ x₁)
/-- The fundamental group of a path connected space is independent of the choice of basepoint. -/
def fundamentalGroupMulEquivOfPathConnected [PathConnectedSpace X] :
FundamentalGroup X x₀ ≃* FundamentalGroup X x₁ :=
fundamentalGroupMulEquivOfPath (PathConnectedSpace.somePath x₀ x₁)
/-- An element of the fundamental group as an arrow in the fundamental groupoid. -/
abbrev toArrow {X : TopCat} {x : X} (p : FundamentalGroup X x) :
FundamentalGroupoid.mk x ⟶ FundamentalGroupoid.mk x :=
p.hom
/-- An element of the fundamental group as a quotient of homotopic paths. -/
abbrev toPath {X : TopCat} {x : X} (p : FundamentalGroup X x) : Path.Homotopic.Quotient x x :=
toArrow p
/-- An element of the fundamental group, constructed from an arrow in the fundamental groupoid. -/
abbrev fromArrow {X : TopCat} {x : X}
(p : FundamentalGroupoid.mk x ⟶ FundamentalGroupoid.mk x) :
FundamentalGroup X x where
hom := p
inv := CategoryTheory.Groupoid.inv p
/-- An element of the fundamental group, constructed from a quotient of homotopic paths. -/
abbrev fromPath {X : TopCat} {x : X} (p : Path.Homotopic.Quotient x x) : FundamentalGroup X x :=
fromArrow p
end FundamentalGroup
|
AlgebraicTopology\FundamentalGroupoid\InducedMaps.lean | /-
Copyright (c) 2022 Praneeth Kolichala. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Praneeth Kolichala
-/
import Mathlib.Topology.Homotopy.Equiv
import Mathlib.CategoryTheory.Equivalence
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Product
/-!
# Homotopic maps induce naturally isomorphic functors
## Main definitions
- `FundamentalGroupoidFunctor.homotopicMapsNatIso H` The natural isomorphism
between the induced functors `f : π(X) ⥤ π(Y)` and `g : π(X) ⥤ π(Y)`, given a homotopy
`H : f ∼ g`
- `FundamentalGroupoidFunctor.equivOfHomotopyEquiv hequiv` The equivalence of the categories
`π(X)` and `π(Y)` given a homotopy equivalence `hequiv : X ≃ₕ Y` between them.
## Implementation notes
- In order to be more universe polymorphic, we define `ContinuousMap.Homotopy.uliftMap`
which lifts a homotopy from `I × X → Y` to `(TopCat.of ((ULift I) × X)) → Y`. This is because
this construction uses `FundamentalGroupoidFunctor.prodToProdTop` to convert between
pairs of paths in I and X and the corresponding path after passing through a homotopy `H`.
But `FundamentalGroupoidFunctor.prodToProdTop` requires two spaces in the same universe.
-/
noncomputable section
universe u
open FundamentalGroupoid
open CategoryTheory
open FundamentalGroupoidFunctor
open scoped FundamentalGroupoid
open scoped unitInterval
namespace unitInterval
/-- The path 0 ⟶ 1 in `I` -/
def path01 : Path (0 : I) 1 where
toFun := id
source' := rfl
target' := rfl
/-- The path 0 ⟶ 1 in `ULift I` -/
def upath01 : Path (ULift.up 0 : ULift.{u} I) (ULift.up 1) where
toFun := ULift.up
source' := rfl
target' := rfl
attribute [local instance] Path.Homotopic.setoid
/-- The homotopy path class of 0 → 1 in `ULift I` -/
def uhpath01 : @fromTop (TopCat.of <| ULift.{u} I) (ULift.up (0 : I)) ⟶ fromTop (ULift.up 1) :=
⟦upath01⟧
end unitInterval
namespace ContinuousMap.Homotopy
open unitInterval (uhpath01)
attribute [local instance] Path.Homotopic.setoid
section Casts
/-- Abbreviation for `eqToHom` that accepts points in a topological space -/
abbrev hcast {X : TopCat} {x₀ x₁ : X} (hx : x₀ = x₁) : fromTop x₀ ⟶ fromTop x₁ :=
eqToHom <| FundamentalGroupoid.ext hx
@[simp]
theorem hcast_def {X : TopCat} {x₀ x₁ : X} (hx₀ : x₀ = x₁) :
hcast hx₀ = eqToHom (FundamentalGroupoid.ext hx₀) :=
rfl
variable {X₁ X₂ Y : TopCat.{u}} {f : C(X₁, Y)} {g : C(X₂, Y)} {x₀ x₁ : X₁} {x₂ x₃ : X₂}
{p : Path x₀ x₁} {q : Path x₂ x₃} (hfg : ∀ t, f (p t) = g (q t))
/-- If `f(p(t) = g(q(t))` for two paths `p` and `q`, then the induced path homotopy classes
`f(p)` and `g(p)` are the same as well, despite having a priori different types -/
theorem heq_path_of_eq_image : HEq ((πₘ f).map ⟦p⟧) ((πₘ g).map ⟦q⟧) := by
simp only [map_eq, ← Path.Homotopic.map_lift]; apply Path.Homotopic.hpath_hext; exact hfg
private theorem start_path : f x₀ = g x₂ := by convert hfg 0 <;> simp only [Path.source]
private theorem end_path : f x₁ = g x₃ := by convert hfg 1 <;> simp only [Path.target]
theorem eq_path_of_eq_image :
(πₘ f).map ⟦p⟧ = hcast (start_path hfg) ≫ (πₘ g).map ⟦q⟧ ≫ hcast (end_path hfg).symm := by
rw [Functor.conj_eqToHom_iff_heq
((πₘ f).map ⟦p⟧) ((πₘ g).map ⟦q⟧)
(FundamentalGroupoid.ext <| start_path hfg)
(FundamentalGroupoid.ext <| end_path hfg)]
exact heq_path_of_eq_image hfg
end Casts
-- We let `X` and `Y` be spaces, and `f` and `g` be homotopic maps between them
variable {X Y : TopCat.{u}} {f g : C(X, Y)} (H : ContinuousMap.Homotopy f g) {x₀ x₁ : X}
(p : fromTop x₀ ⟶ fromTop x₁)
/-!
These definitions set up the following diagram, for each path `p`:
f(p)
*--------*
| \ |
H₀ | \ d | H₁
| \ |
*--------*
g(p)
Here, `H₀ = H.evalAt x₀` is the path from `f(x₀)` to `g(x₀)`,
and similarly for `H₁`. Similarly, `f(p)` denotes the
path in Y that the induced map `f` takes `p`, and similarly for `g(p)`.
Finally, `d`, the diagonal path, is H(0 ⟶ 1, p), the result of the induced `H` on
`Path.Homotopic.prod (0 ⟶ 1) p`, where `(0 ⟶ 1)` denotes the path from `0` to `1` in `I`.
It is clear that the diagram commutes (`H₀ ≫ g(p) = d = f(p) ≫ H₁`), but unfortunately,
many of the paths do not have defeq starting/ending points, so we end up needing some casting.
-/
/-- Interpret a homotopy `H : C(I × X, Y)` as a map `C(ULift I × X, Y)` -/
def uliftMap : C(TopCat.of (ULift.{u} I × X), Y) :=
⟨fun x => H (x.1.down, x.2),
H.continuous.comp ((continuous_uLift_down.comp continuous_fst).prod_mk continuous_snd)⟩
-- This lemma has always been bad, but the linter only noticed after lean4#2644.
@[simp, nolint simpNF]
theorem ulift_apply (i : ULift.{u} I) (x : X) : H.uliftMap (i, x) = H (i.down, x) :=
rfl
/-- An abbreviation for `prodToProdTop`, with some types already in place to help the
typechecker. In particular, the first path should be on the ulifted unit interval. -/
abbrev prodToProdTopI {a₁ a₂ : TopCat.of (ULift I)} {b₁ b₂ : X} (p₁ : fromTop a₁ ⟶ fromTop a₂)
(p₂ : fromTop b₁ ⟶ fromTop b₂) :=
(prodToProdTop (TopCat.of <| ULift I) X).map (X := (⟨a₁⟩, ⟨b₁⟩)) (Y := (⟨a₂⟩, ⟨b₂⟩)) (p₁, p₂)
/-- The diagonal path `d` of a homotopy `H` on a path `p` -/
def diagonalPath : fromTop (H (0, x₀)) ⟶ fromTop (H (1, x₁)) :=
(πₘ H.uliftMap).map (prodToProdTopI uhpath01 p)
/-- The diagonal path, but starting from `f x₀` and going to `g x₁` -/
def diagonalPath' : fromTop (f x₀) ⟶ fromTop (g x₁) :=
hcast (H.apply_zero x₀).symm ≫ H.diagonalPath p ≫ hcast (H.apply_one x₁)
/-- Proof that `f(p) = H(0 ⟶ 0, p)`, with the appropriate casts -/
theorem apply_zero_path : (πₘ f).map p = hcast (H.apply_zero x₀).symm ≫
(πₘ H.uliftMap).map (prodToProdTopI (𝟙 (@fromTop (TopCat.of _) (ULift.up 0))) p) ≫
hcast (H.apply_zero x₁) :=
Quotient.inductionOn p fun p' => by
apply @eq_path_of_eq_image _ _ _ _ H.uliftMap _ _ _ _ _ ((Path.refl (ULift.up _)).prod p')
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [Path.prod_coe]; simp_rw [ulift_apply]; simp
/-- Proof that `g(p) = H(1 ⟶ 1, p)`, with the appropriate casts -/
theorem apply_one_path : (πₘ g).map p = hcast (H.apply_one x₀).symm ≫
(πₘ H.uliftMap).map (prodToProdTopI (𝟙 (@fromTop (TopCat.of _) (ULift.up 1))) p) ≫
hcast (H.apply_one x₁) :=
Quotient.inductionOn p fun p' => by
apply @eq_path_of_eq_image _ _ _ _ H.uliftMap _ _ _ _ _ ((Path.refl (ULift.up _)).prod p')
-- This used to be `rw`, but we need `erw` after leanprover/lean4#2644
erw [Path.prod_coe]; simp_rw [ulift_apply]; simp
/-- Proof that `H.evalAt x = H(0 ⟶ 1, x ⟶ x)`, with the appropriate casts -/
theorem evalAt_eq (x : X) : ⟦H.evalAt x⟧ = hcast (H.apply_zero x).symm ≫
(πₘ H.uliftMap).map (prodToProdTopI uhpath01 (𝟙 (fromTop x))) ≫
hcast (H.apply_one x).symm.symm := by
dsimp only [prodToProdTopI, uhpath01, hcast]
refine (@Functor.conj_eqToHom_iff_heq (πₓ Y) _ _ _ _ _ _ _ _
(FundamentalGroupoid.ext <| H.apply_one x).symm).mpr ?_
simp only [id_eq_path_refl, prodToProdTop_map, Path.Homotopic.prod_lift, map_eq, ←
Path.Homotopic.map_lift]
apply Path.Homotopic.hpath_hext; intro; rfl
-- Finally, we show `d = f(p) ≫ H₁ = H₀ ≫ g(p)`
theorem eq_diag_path : (πₘ f).map p ≫ ⟦H.evalAt x₁⟧ = H.diagonalPath' p ∧
(⟦H.evalAt x₀⟧ ≫ (πₘ g).map p : fromTop (f x₀) ⟶ fromTop (g x₁)) = H.diagonalPath' p := by
rw [H.apply_zero_path, H.apply_one_path, H.evalAt_eq]
erw [H.evalAt_eq] -- Porting note: `rw` didn't work, so using `erw`
dsimp only [prodToProdTopI]
constructor
· slice_lhs 2 4 => rw [eqToHom_trans, eqToHom_refl] -- Porting note: this ↓ `simp` didn't do this
slice_lhs 2 4 => simp [← CategoryTheory.Functor.map_comp]
rfl
· slice_lhs 2 4 => rw [eqToHom_trans, eqToHom_refl] -- Porting note: this ↓ `simp` didn't do this
slice_lhs 2 4 => simp [← CategoryTheory.Functor.map_comp]
rfl
end ContinuousMap.Homotopy
namespace FundamentalGroupoidFunctor
open CategoryTheory
open scoped FundamentalGroupoid
attribute [local instance] Path.Homotopic.setoid
variable {X Y : TopCat.{u}} {f g : C(X, Y)} (H : ContinuousMap.Homotopy f g)
/-- Given a homotopy H : f ∼ g, we have an associated natural isomorphism between the induced
functors `f` and `g` -/
-- Porting note: couldn't use category arrow `\hom` in statement, needed to expand
def homotopicMapsNatIso : @Quiver.Hom _ Functor.category.toQuiver (πₘ f) (πₘ g) where
app x := ⟦H.evalAt x.as⟧
-- Porting note: Turned `rw` into `erw` in the line below
naturality x y p := by erw [(H.eq_diag_path p).1, (H.eq_diag_path p).2]
instance : IsIso (homotopicMapsNatIso H) := by apply NatIso.isIso_of_isIso_app
open scoped ContinuousMap
/-- Homotopy equivalent topological spaces have equivalent fundamental groupoids. -/
def equivOfHomotopyEquiv (hequiv : X ≃ₕ Y) : πₓ X ≌ πₓ Y := by
apply CategoryTheory.Equivalence.mk (πₘ hequiv.toFun : πₓ X ⥤ πₓ Y)
(πₘ hequiv.invFun : πₓ Y ⥤ πₓ X) <;>
simp only [Grpd.hom_to_functor, Grpd.id_to_functor]
· convert (asIso (homotopicMapsNatIso hequiv.left_inv.some)).symm
exacts [((π).map_id X).symm, ((π).map_comp _ _).symm]
· convert asIso (homotopicMapsNatIso hequiv.right_inv.some)
exacts [((π).map_comp _ _).symm, ((π).map_id Y).symm]
end FundamentalGroupoidFunctor
|
AlgebraicTopology\FundamentalGroupoid\Product.lean | /-
Copyright (c) 2022 Praneeth Kolichala. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Praneeth Kolichala
-/
import Mathlib.CategoryTheory.Groupoid
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
import Mathlib.Topology.Category.TopCat.Limits.Products
import Mathlib.Topology.Homotopy.Product
/-!
# Fundamental groupoid preserves products
In this file, we give the following definitions/theorems:
- `FundamentalGroupoidFunctor.piIso` An isomorphism between Π i, (π Xᵢ) and π (Πi, Xᵢ), whose
inverse is precisely the product of the maps π (Π i, Xᵢ) → π (Xᵢ), each induced by
the projection in `Top` Π i, Xᵢ → Xᵢ.
- `FundamentalGroupoidFunctor.prodIso` An isomorphism between πX × πY and π (X × Y), whose
inverse is precisely the product of the maps π (X × Y) → πX and π (X × Y) → Y, each induced by
the projections X × Y → X and X × Y → Y
- `FundamentalGroupoidFunctor.preservesProduct` A proof that the fundamental groupoid functor
preserves all products.
-/
noncomputable section
open scoped FundamentalGroupoid CategoryTheory
namespace FundamentalGroupoidFunctor
universe u
section Pi
variable {I : Type u} (X : I → TopCat.{u})
/-- The projection map Π i, X i → X i induces a map π(Π i, X i) ⟶ π(X i).
-/
def proj (i : I) : πₓ (TopCat.of (∀ i, X i)) ⥤ πₓ (X i) :=
πₘ ⟨_, continuous_apply i⟩
/-- The projection map is precisely `Path.Homotopic.proj` interpreted as a functor -/
@[simp]
theorem proj_map (i : I) (x₀ x₁ : πₓ (TopCat.of (∀ i, X i))) (p : x₀ ⟶ x₁) :
(proj X i).map p = @Path.Homotopic.proj _ _ _ _ _ i p :=
rfl
/-- The map taking the pi product of a family of fundamental groupoids to the fundamental
groupoid of the pi product. This is actually an isomorphism (see `piIso`)
-/
@[simps]
def piToPiTop : (∀ i, πₓ (X i)) ⥤ πₓ (TopCat.of (∀ i, X i)) where
obj g := ⟨fun i => (g i).as⟩
map p := Path.Homotopic.pi p
map_id x := by
change (Path.Homotopic.pi fun i => ⟦_⟧) = _
simp only [FundamentalGroupoid.id_eq_path_refl, Path.Homotopic.pi_lift]
rfl
map_comp f g := (Path.Homotopic.comp_pi_eq_pi_comp f g).symm
/-- Shows `piToPiTop` is an isomorphism, whose inverse is precisely the pi product
of the induced projections. This shows that `fundamentalGroupoidFunctor` preserves products.
-/
@[simps]
def piIso : CategoryTheory.Grpd.of (∀ i : I, πₓ (X i)) ≅ πₓ (TopCat.of (∀ i, X i)) where
hom := piToPiTop X
inv := CategoryTheory.Functor.pi' (proj X)
hom_inv_id := by
change piToPiTop X ⋙ CategoryTheory.Functor.pi' (proj X) = 𝟭 _
apply CategoryTheory.Functor.ext ?_ ?_
· intros; rfl
· intros; ext; simp
inv_hom_id := by
change CategoryTheory.Functor.pi' (proj X) ⋙ piToPiTop X = 𝟭 _
apply CategoryTheory.Functor.ext
· intro _ _ f
suffices Path.Homotopic.pi ((CategoryTheory.Functor.pi' (proj X)).map f) = f by simpa
change Path.Homotopic.pi (fun i => (CategoryTheory.Functor.pi' (proj X)).map f i) = _
simp
· intros; rfl
section Preserves
open CategoryTheory
/-- Equivalence between the categories of cones over the objects `π Xᵢ` written in two ways -/
def coneDiscreteComp :
Limits.Cone (Discrete.functor X ⋙ π) ≌ Limits.Cone (Discrete.functor fun i => πₓ (X i)) :=
Limits.Cones.postcomposeEquivalence (Discrete.compNatIsoDiscrete X π)
theorem coneDiscreteComp_obj_mapCone :
-- Porting note: check universe parameters here
(coneDiscreteComp X).functor.obj (Functor.mapCone π (TopCat.piFan.{u,u} X)) =
Limits.Fan.mk (πₓ (TopCat.of (∀ i, X i))) (proj X) :=
rfl
/-- This is `piIso.inv` as a cone morphism (in fact, isomorphism) -/
def piTopToPiCone :
Limits.Fan.mk (πₓ (TopCat.of (∀ i, X i))) (proj X) ⟶ Grpd.piLimitFan fun i : I => πₓ (X i) where
hom := CategoryTheory.Functor.pi' (proj X)
instance : IsIso (piTopToPiCone X) :=
haveI : IsIso (piTopToPiCone X).hom := (inferInstance : IsIso (piIso X).inv)
Limits.Cones.cone_iso_of_hom_iso (piTopToPiCone X)
/-- The fundamental groupoid functor preserves products -/
def preservesProduct : Limits.PreservesLimit (Discrete.functor X) π := by
-- Porting note: check universe parameters here
apply Limits.preservesLimitOfPreservesLimitCone (TopCat.piFanIsLimit.{u,u} X)
apply (Limits.IsLimit.ofConeEquiv (coneDiscreteComp X)).toFun
simp only [coneDiscreteComp_obj_mapCone]
apply Limits.IsLimit.ofIsoLimit _ (asIso (piTopToPiCone X)).symm
exact Grpd.piLimitFanIsLimit _
end Preserves
end Pi
section Prod
variable (A B : TopCat.{u})
/-- The induced map of the left projection map X × Y → X -/
def projLeft : πₓ (TopCat.of (A × B)) ⥤ πₓ A :=
πₘ ⟨_, continuous_fst⟩
/-- The induced map of the right projection map X × Y → Y -/
def projRight : πₓ (TopCat.of (A × B)) ⥤ πₓ B :=
πₘ ⟨_, continuous_snd⟩
@[simp]
theorem projLeft_map (x₀ x₁ : πₓ (TopCat.of (A × B))) (p : x₀ ⟶ x₁) :
(projLeft A B).map p = Path.Homotopic.projLeft p :=
rfl
@[simp]
theorem projRight_map (x₀ x₁ : πₓ (TopCat.of (A × B))) (p : x₀ ⟶ x₁) :
(projRight A B).map p = Path.Homotopic.projRight p :=
rfl
/--
The map taking the product of two fundamental groupoids to the fundamental groupoid of the product
of the two topological spaces. This is in fact an isomorphism (see `prodIso`).
-/
@[simps obj]
def prodToProdTop : πₓ A × πₓ B ⥤ πₓ (TopCat.of (A × B)) where
obj g := ⟨g.fst.as, g.snd.as⟩
map {x y} p :=
match x, y, p with
| (x₀, x₁), (y₀, y₁), (p₀, p₁) => @Path.Homotopic.prod _ _ (_) (_) _ _ _ _ p₀ p₁
map_id := by
rintro ⟨x₀, x₁⟩
simp only [CategoryTheory.prod_id, FundamentalGroupoid.id_eq_path_refl]
rfl
map_comp {x y z} f g :=
match x, y, z, f, g with
| (x₀, x₁), (y₀, y₁), (z₀, z₁), (f₀, f₁), (g₀, g₁) =>
(Path.Homotopic.comp_prod_eq_prod_comp f₀ f₁ g₀ g₁).symm
theorem prodToProdTop_map {x₀ x₁ : πₓ A} {y₀ y₁ : πₓ B} (p₀ : x₀ ⟶ x₁) (p₁ : y₀ ⟶ y₁) :
(prodToProdTop A B).map (X := (x₀, y₀)) (Y := (x₁, y₁)) (p₀, p₁) =
Path.Homotopic.prod p₀ p₁ :=
rfl
/-- Shows `prodToProdTop` is an isomorphism, whose inverse is precisely the product
of the induced left and right projections.
-/
@[simps]
def prodIso : CategoryTheory.Grpd.of (πₓ A × πₓ B) ≅ πₓ (TopCat.of (A × B)) where
hom := prodToProdTop A B
inv := (projLeft A B).prod' (projRight A B)
hom_inv_id := by
change prodToProdTop A B ⋙ (projLeft A B).prod' (projRight A B) = 𝟭 _
apply CategoryTheory.Functor.hext; · intros; ext <;> simp <;> rfl
rintro ⟨x₀, x₁⟩ ⟨y₀, y₁⟩ ⟨f₀, f₁⟩
have : Path.Homotopic.projLeft ((prodToProdTop A B).map (f₀, f₁)) = f₀ ∧
Path.Homotopic.projRight ((prodToProdTop A B).map (f₀, f₁)) = f₁ :=
And.intro (Path.Homotopic.projLeft_prod f₀ f₁) (Path.Homotopic.projRight_prod f₀ f₁)
simpa
inv_hom_id := by
change (projLeft A B).prod' (projRight A B) ⋙ prodToProdTop A B = 𝟭 _
apply CategoryTheory.Functor.hext
· intros; apply FundamentalGroupoid.ext; apply Prod.ext <;> simp <;> rfl
rintro ⟨x₀, x₁⟩ ⟨y₀, y₁⟩ f
have := Path.Homotopic.prod_projLeft_projRight f
-- Porting note: was simpa but TopSpace instances might be getting in the way
simp only [CategoryTheory.Functor.comp_obj, CategoryTheory.Functor.prod'_obj, prodToProdTop_obj,
CategoryTheory.Functor.comp_map, CategoryTheory.Functor.prod'_map, projLeft_map,
projRight_map, CategoryTheory.Functor.id_obj, CategoryTheory.Functor.id_map, heq_eq_eq]
apply this
end Prod
end FundamentalGroupoidFunctor
|
AlgebraicTopology\FundamentalGroupoid\PUnit.lean | /-
Copyright (c) 2022 Praneeth Kolichala. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Praneeth Kolichala
-/
import Mathlib.CategoryTheory.PUnit
import Mathlib.AlgebraicTopology.FundamentalGroupoid.Basic
/-!
# Fundamental groupoid of punit
The fundamental groupoid of punit is naturally isomorphic to `CategoryTheory.Discrete PUnit`
-/
noncomputable section
open CategoryTheory
universe u v
namespace Path
instance : Subsingleton (Path PUnit.unit PUnit.unit) :=
⟨fun x y => by ext⟩
end Path
namespace FundamentalGroupoid
instance {x y : FundamentalGroupoid PUnit} : Subsingleton (x ⟶ y) := by
convert_to Subsingleton (Path.Homotopic.Quotient PUnit.unit PUnit.unit)
apply Quotient.instSubsingletonQuotient
/-- Equivalence of groupoids between fundamental groupoid of punit and punit -/
def punitEquivDiscretePUnit : FundamentalGroupoid PUnit.{u + 1} ≌ Discrete PUnit.{v + 1} :=
CategoryTheory.Equivalence.mk
(Functor.star _)
((CategoryTheory.Functor.const _).obj ⟨PUnit.unit⟩)
-- Porting note: was `by decide`
(NatIso.ofComponents fun _ => eqToIso (by simp))
(Functor.punitExt _ _)
end FundamentalGroupoid
|
AlgebraicTopology\FundamentalGroupoid\SimplyConnected.lean | /-
Copyright (c) 2022 Praneeth Kolichala. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Praneeth Kolichala
-/
import Mathlib.AlgebraicTopology.FundamentalGroupoid.InducedMaps
import Mathlib.Topology.Homotopy.Contractible
import Mathlib.CategoryTheory.PUnit
import Mathlib.AlgebraicTopology.FundamentalGroupoid.PUnit
/-!
# Simply connected spaces
This file defines simply connected spaces.
A topological space is simply connected if its fundamental groupoid is equivalent to `Unit`.
## Main theorems
- `simply_connected_iff_unique_homotopic` - A space is simply connected if and only if it is
nonempty and there is a unique path up to homotopy between any two points
- `SimplyConnectedSpace.ofContractible` - A contractible space is simply connected
-/
universe u
noncomputable section
open CategoryTheory
open ContinuousMap
open scoped ContinuousMap
/-- A simply connected space is one whose fundamental groupoid is equivalent to `Discrete Unit` -/
@[mk_iff simply_connected_def]
class SimplyConnectedSpace (X : Type*) [TopologicalSpace X] : Prop where
equiv_unit : Nonempty (FundamentalGroupoid X ≌ Discrete Unit)
theorem simply_connected_iff_unique_homotopic (X : Type*) [TopologicalSpace X] :
SimplyConnectedSpace X ↔
Nonempty X ∧ ∀ x y : X, Nonempty (Unique (Path.Homotopic.Quotient x y)) := by
simp only [simply_connected_def, equiv_punit_iff_unique,
FundamentalGroupoid.nonempty_iff X, and_congr_right_iff, Nonempty.forall]
intros
exact ⟨fun h _ _ => h _ _, fun h _ _ => h _ _⟩
namespace SimplyConnectedSpace
variable {X : Type*} [TopologicalSpace X] [SimplyConnectedSpace X]
instance (x y : X) : Subsingleton (Path.Homotopic.Quotient x y) :=
@Unique.instSubsingleton _ (Nonempty.some (by
rw [simply_connected_iff_unique_homotopic] at *; tauto))
attribute [local instance] Path.Homotopic.setoid
instance (priority := 100) : PathConnectedSpace X :=
let unique_homotopic := (simply_connected_iff_unique_homotopic X).mp inferInstance
{ nonempty := unique_homotopic.1
joined := fun x y => ⟨(unique_homotopic.2 x y).some.default.out⟩ }
/-- In a simply connected space, any two paths are homotopic -/
theorem paths_homotopic {x y : X} (p₁ p₂ : Path x y) : Path.Homotopic p₁ p₂ :=
Quotient.eq.mp (@Subsingleton.elim (Path.Homotopic.Quotient x y) _ _ _)
instance (priority := 100) ofContractible (Y : Type u) [TopologicalSpace Y] [ContractibleSpace Y] :
SimplyConnectedSpace Y where
equiv_unit :=
let H : TopCat.of Y ≃ₕ TopCat.of PUnit.{u+1} := (ContractibleSpace.hequiv Y PUnit.{u+1}).some
⟨(FundamentalGroupoidFunctor.equivOfHomotopyEquiv H).trans
FundamentalGroupoid.punitEquivDiscretePUnit⟩
end SimplyConnectedSpace
attribute [local instance] Path.Homotopic.setoid
/-- A space is simply connected iff it is path connected, and there is at most one path
up to homotopy between any two points. -/
theorem simply_connected_iff_paths_homotopic {Y : Type*} [TopologicalSpace Y] :
SimplyConnectedSpace Y ↔
PathConnectedSpace Y ∧ ∀ x y : Y, Subsingleton (Path.Homotopic.Quotient x y) :=
⟨by intro; constructor <;> infer_instance, fun h => by
cases h; rw [simply_connected_iff_unique_homotopic]
exact ⟨inferInstance, fun x y => ⟨uniqueOfSubsingleton ⟦PathConnectedSpace.somePath x y⟧⟩⟩⟩
/-- Another version of `simply_connected_iff_paths_homotopic` -/
theorem simply_connected_iff_paths_homotopic' {Y : Type*} [TopologicalSpace Y] :
SimplyConnectedSpace Y ↔
PathConnectedSpace Y ∧ ∀ {x y : Y} (p₁ p₂ : Path x y), Path.Homotopic p₁ p₂ := by
convert simply_connected_iff_paths_homotopic (Y := Y)
simp [Path.Homotopic.Quotient, Setoid.eq_top_iff]; rfl
|
AlgebraicTopology\SimplicialCategory\Basic.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou
-/
import Mathlib.AlgebraicTopology.SimplicialSet.Monoidal
import Mathlib.CategoryTheory.Enriched.Basic
/-!
# Simplicial categories
A simplicial category is a category `C` that is enriched over the
category of simplicial sets in such a way that morphisms in
`C` identify to the `0`-simplices of the enriched hom.
## TODO
* construct a simplicial category structure on simplicial objects, so
that it applies in particular to simplicial sets
* obtain the adjunction property `(K ⊗ X ⟶ Y) ≃ (K ⟶ sHom X Y)` when `K`, `X`, and `Y`
are simplicial sets
* develop the notion of "simplicial tensor" `K ⊗ₛ X : C` with `K : SSet` and `X : C`
an object in a simplicial category `C`
* define the notion of path between `0`-simplices of simplicial sets
* deduce the notion of homotopy between morphisms in a simplicial category
* obtain that homotopies in simplicial categories can be interpreted as given
by morphisms `Δ[1] ⊗ X ⟶ Y`.
## References
* [Daniel G. Quillen, *Homotopical algebra*, II §1][quillen-1967]
-/
universe v u
open CategoryTheory Category Simplicial MonoidalCategory
namespace CategoryTheory
variable (C : Type u) [Category.{v} C]
/-- A simplicial category is a category `C` that is enriched over the
category of simplicial sets in such a way that morphisms in
`C` identify to the `0`-simplices of the enriched hom. -/
class SimplicialCategory extends EnrichedCategory SSet.{v} C where
/-- morphisms identify to `0`-simplices of the enriched hom -/
homEquiv (K L : C) : (K ⟶ L) ≃ (𝟙_ SSet.{v} ⟶ EnrichedCategory.Hom K L)
homEquiv_id (K : C) : homEquiv K K (𝟙 K) = eId SSet K := by aesop_cat
homEquiv_comp {K L M : C} (f : K ⟶ L) (g : L ⟶ M) :
homEquiv K M (f ≫ g) = (λ_ _).inv ≫ (homEquiv K L f ⊗ homEquiv L M g) ≫
eComp SSet K L M := by aesop_cat
namespace SimplicialCategory
variable [SimplicialCategory C]
variable {C}
/-- Abbreviation for the enriched hom of a simplicial category. -/
abbrev sHom (K L : C) : SSet.{v} := EnrichedCategory.Hom K L
/-- Abbreviation for the enriched composition in a simplicial category. -/
abbrev sHomComp (K L M : C) : sHom K L ⊗ sHom L M ⟶ sHom K M := eComp SSet K L M
/-- The bijection `(K ⟶ L) ≃ sHom K L _[0]` for all objects `K` and `L`
in a simplicial category. -/
def homEquiv' (K L : C) : (K ⟶ L) ≃ sHom K L _[0] :=
(homEquiv K L).trans (sHom K L).unitHomEquiv
/-- The morphism `sHom K' L ⟶ sHom K L` induced by a morphism `K ⟶ K'`. -/
noncomputable def sHomWhiskerRight {K K' : C} (f : K ⟶ K') (L : C) :
sHom K' L ⟶ sHom K L :=
(λ_ _).inv ≫ homEquiv K K' f ▷ _ ≫ sHomComp K K' L
@[simp]
lemma sHomWhiskerRight_id (K L : C) : sHomWhiskerRight (𝟙 K) L = 𝟙 _ := by
simp [sHomWhiskerRight, homEquiv_id]
@[simp, reassoc]
lemma sHomWhiskerRight_comp {K K' K'' : C} (f : K ⟶ K') (f' : K' ⟶ K'') (L : C) :
sHomWhiskerRight (f ≫ f') L = sHomWhiskerRight f' L ≫ sHomWhiskerRight f L := by
dsimp [sHomWhiskerRight]
simp only [assoc, homEquiv_comp, comp_whiskerRight, leftUnitor_inv_whiskerRight, ← e_assoc']
rfl
/-- The morphism `sHom K L ⟶ sHom K L'` induced by a morphism `L ⟶ L'`. -/
noncomputable def sHomWhiskerLeft (K : C) {L L' : C} (g : L ⟶ L') :
sHom K L ⟶ sHom K L' :=
(ρ_ _).inv ≫ _ ◁ homEquiv L L' g ≫ sHomComp K L L'
@[simp]
lemma sHomWhiskerLeft_id (K L : C) : sHomWhiskerLeft K (𝟙 L) = 𝟙 _ := by
simp [sHomWhiskerLeft, homEquiv_id]
@[simp, reassoc]
lemma sHomWhiskerLeft_comp (K : C) {L L' L'' : C} (g : L ⟶ L') (g' : L' ⟶ L'') :
sHomWhiskerLeft K (g ≫ g') = sHomWhiskerLeft K g ≫ sHomWhiskerLeft K g' := by
dsimp [sHomWhiskerLeft]
simp only [homEquiv_comp, MonoidalCategory.whiskerLeft_comp, assoc, ← e_assoc]
rfl
@[reassoc]
lemma sHom_whisker_exchange {K K' L L' : C} (f : K ⟶ K') (g : L ⟶ L') :
sHomWhiskerLeft K' g ≫ sHomWhiskerRight f L' =
sHomWhiskerRight f L ≫ sHomWhiskerLeft K g :=
((ρ_ _).inv ≫ _ ◁ homEquiv L L' g ≫ (λ_ _).inv ≫ homEquiv K K' f ▷ _) ≫=
(e_assoc SSet.{v} K K' L L').symm
attribute [local simp] sHom_whisker_exchange
variable (C) in
/-- The bifunctor `Cᵒᵖ ⥤ C ⥤ SSet.{v}` which sends `K : Cᵒᵖ` and `L : C` to `sHom K.unop L`. -/
@[simps]
noncomputable def sHomFunctor : Cᵒᵖ ⥤ C ⥤ SSet.{v} where
obj K :=
{ obj := fun L => sHom K.unop L
map := fun φ => sHomWhiskerLeft K.unop φ }
map φ :=
{ app := fun L => sHomWhiskerRight φ.unop L }
end SimplicialCategory
end CategoryTheory
|
AlgebraicTopology\SimplicialSet\Monoidal.lean | /-
Copyright (c) 2024 Joël Riou. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Joël Riou, Jack McKoen
-/
import Mathlib.AlgebraicTopology.SimplicialSet
import Mathlib.CategoryTheory.ChosenFiniteProducts.FunctorCategory
import Mathlib.CategoryTheory.Monoidal.Types.Basic
/-!
# The monoidal category structure on simplicial sets
This file defines an instance of chosen finite products
for the category `SSet`. It follows from the fact
the `SSet` if a category of functors to the category
of types and that the category of types have chosen
finite products. As a result, we obtain a monoidal
category structure on `SSet`.
-/
universe u
open Simplicial CategoryTheory MonoidalCategory
namespace SSet
noncomputable instance : ChosenFiniteProducts SSet.{u} :=
(inferInstance : ChosenFiniteProducts (SimplexCategoryᵒᵖ ⥤ Type u))
@[simp]
lemma leftUnitor_hom_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : (𝟙_ _ ⊗ K).obj Δ) :
(λ_ K).hom.app Δ x = x.2 := rfl
@[simp]
lemma leftUnitor_inv_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : K.obj Δ) :
(λ_ K).inv.app Δ x = ⟨PUnit.unit, x⟩ := rfl
@[simp]
lemma rightUnitor_hom_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ 𝟙_ _).obj Δ) :
(ρ_ K).hom.app Δ x = x.1 := rfl
@[simp]
lemma rightUnitor_inv_app_apply (K : SSet.{u}) {Δ : SimplexCategoryᵒᵖ} (x : K.obj Δ) :
(ρ_ K).inv.app Δ x = ⟨x, PUnit.unit⟩ := rfl
@[simp]
lemma tensorHom_app_apply {K K' L L' : SSet.{u}} (f : K ⟶ K') (g : L ⟶ L')
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(f ⊗ g).app Δ x = ⟨f.app Δ x.1, g.app Δ x.2⟩ := rfl
@[simp]
lemma whiskerLeft_app_apply (K : SSet.{u}) {L L' : SSet.{u}} (g : L ⟶ L')
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(K ◁ g).app Δ x = ⟨x.1, g.app Δ x.2⟩ := rfl
@[simp]
lemma whiskerRight_app_apply {K K' : SSet.{u}} (f : K ⟶ K') (L : SSet.{u})
{Δ : SimplexCategoryᵒᵖ} (x : (K ⊗ L).obj Δ) :
(f ▷ L).app Δ x = ⟨f.app Δ x.1, x.2⟩ := rfl
@[simp]
lemma associator_hom_app_apply (K L M : SSet.{u}) {Δ : SimplexCategoryᵒᵖ}
(x : ((K ⊗ L) ⊗ M).obj Δ) :
(α_ K L M).hom.app Δ x = ⟨x.1.1, x.1.2, x.2⟩ := rfl
@[simp]
lemma associator_inv_app_apply (K L M : SSet.{u}) {Δ : SimplexCategoryᵒᵖ}
(x : (K ⊗ L ⊗ M).obj Δ) :
(α_ K L M).inv.app Δ x = ⟨⟨x.1, x.2.1⟩, x.2.2⟩ := rfl
/-- The bijection `(𝟙_ SSet ⟶ K) ≃ K _[0]`. -/
def unitHomEquiv (K : SSet.{u}) : (𝟙_ _ ⟶ K) ≃ K _[0] where
toFun φ := φ.app _ PUnit.unit
invFun x :=
{ app := fun Δ _ => K.map (SimplexCategory.const Δ.unop [0] 0).op x
naturality := fun Δ Δ' f => by
ext ⟨⟩
dsimp
rw [← FunctorToTypes.map_comp_apply]
rfl }
left_inv φ := by
ext Δ ⟨⟩
dsimp
rw [← FunctorToTypes.naturality]
rfl
right_inv x := by simp
end SSet
|
Analysis\BoundedVariation.lean | /-
Copyright (c) 2022 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Calculus.FDeriv.Add
import Mathlib.Analysis.Calculus.FDeriv.Equiv
import Mathlib.Analysis.Calculus.FDeriv.Prod
import Mathlib.Analysis.Calculus.Monotone
import Mathlib.Data.Set.Function
import Mathlib.Algebra.Group.Basic
import Mathlib.Tactic.WLOG
/-!
# Functions of bounded variation
We study functions of bounded variation. In particular, we show that a bounded variation function
is a difference of monotone functions, and differentiable almost everywhere. This implies that
Lipschitz functions from the real line into finite-dimensional vector space are also differentiable
almost everywhere.
## Main definitions and results
* `eVariationOn f s` is the total variation of the function `f` on the set `s`, in `ℝ≥0∞`.
* `BoundedVariationOn f s` registers that the variation of `f` on `s` is finite.
* `LocallyBoundedVariationOn f s` registers that `f` has finite variation on any compact
subinterval of `s`.
* `variationOnFromTo f s a b` is the signed variation of `f` on `s ∩ Icc a b`, converted to `ℝ`.
* `eVariationOn.Icc_add_Icc` states that the variation of `f` on `[a, c]` is the sum of its
variations on `[a, b]` and `[b, c]`.
* `LocallyBoundedVariationOn.exists_monotoneOn_sub_monotoneOn` proves that a function
with locally bounded variation is the difference of two monotone functions.
* `LipschitzWith.locallyBoundedVariationOn` shows that a Lipschitz function has locally
bounded variation.
* `LocallyBoundedVariationOn.ae_differentiableWithinAt` shows that a bounded variation
function into a finite dimensional real vector space is differentiable almost everywhere.
* `LipschitzOnWith.ae_differentiableWithinAt` is the same result for Lipschitz functions.
We also give several variations around these results.
## Implementation
We define the variation as an extended nonnegative real, to allow for infinite variation. This makes
it possible to use the complete linear order structure of `ℝ≥0∞`. The proofs would be much
more tedious with an `ℝ`-valued or `ℝ≥0`-valued variation, since one would always need to check
that the sets one uses are nonempty and bounded above as these are only conditionally complete.
-/
open scoped NNReal ENNReal Topology UniformConvergence
open Set MeasureTheory Filter
-- Porting note: sectioned variables because a `wlog` was broken due to extra variables in context
variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E]
/-- The (extended real valued) variation of a function `f` on a set `s` inside a linear order is
the supremum of the sum of `edist (f (u (i+1))) (f (u i))` over all finite increasing
sequences `u` in `s`. -/
noncomputable def eVariationOn (f : α → E) (s : Set α) : ℝ≥0∞ :=
⨆ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
∑ i ∈ Finset.range p.1, edist (f (p.2.1 (i + 1))) (f (p.2.1 i))
/-- A function has bounded variation on a set `s` if its total variation there is finite. -/
def BoundedVariationOn (f : α → E) (s : Set α) :=
eVariationOn f s ≠ ∞
/-- A function has locally bounded variation on a set `s` if, given any interval `[a, b]` with
endpoints in `s`, then the function has finite variation on `s ∩ [a, b]`. -/
def LocallyBoundedVariationOn (f : α → E) (s : Set α) :=
∀ a b, a ∈ s → b ∈ s → BoundedVariationOn f (s ∩ Icc a b)
/-! ## Basic computations of variation -/
namespace eVariationOn
theorem nonempty_monotone_mem {s : Set α} (hs : s.Nonempty) :
Nonempty { u // Monotone u ∧ ∀ i : ℕ, u i ∈ s } := by
obtain ⟨x, hx⟩ := hs
exact ⟨⟨fun _ => x, fun i j _ => le_rfl, fun _ => hx⟩⟩
theorem eq_of_edist_zero_on {f f' : α → E} {s : Set α} (h : ∀ ⦃x⦄, x ∈ s → edist (f x) (f' x) = 0) :
eVariationOn f s = eVariationOn f' s := by
dsimp only [eVariationOn]
congr 1 with p : 1
congr 1 with i : 1
rw [edist_congr_right (h <| p.snd.prop.2 (i + 1)), edist_congr_left (h <| p.snd.prop.2 i)]
theorem eq_of_eqOn {f f' : α → E} {s : Set α} (h : EqOn f f' s) :
eVariationOn f s = eVariationOn f' s :=
eq_of_edist_zero_on fun x xs => by rw [h xs, edist_self]
theorem sum_le (f : α → E) {s : Set α} (n : ℕ) {u : ℕ → α} (hu : Monotone u) (us : ∀ i, u i ∈ s) :
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) ≤ eVariationOn f s :=
le_iSup_of_le ⟨n, u, hu, us⟩ le_rfl
theorem sum_le_of_monotoneOn_Icc (f : α → E) {s : Set α} {m n : ℕ} {u : ℕ → α}
(hu : MonotoneOn u (Icc m n)) (us : ∀ i ∈ Icc m n, u i ∈ s) :
(∑ i ∈ Finset.Ico m n, edist (f (u (i + 1))) (f (u i))) ≤ eVariationOn f s := by
rcases le_total n m with hnm | hmn
· simp [Finset.Ico_eq_empty_of_le hnm]
let π := projIcc m n hmn
let v i := u (π i)
calc
∑ i ∈ Finset.Ico m n, edist (f (u (i + 1))) (f (u i))
= ∑ i ∈ Finset.Ico m n, edist (f (v (i + 1))) (f (v i)) :=
Finset.sum_congr rfl fun i hi ↦ by
rw [Finset.mem_Ico] at hi
simp only [v, π, projIcc_of_mem hmn ⟨hi.1, hi.2.le⟩,
projIcc_of_mem hmn ⟨hi.1.trans i.le_succ, hi.2⟩]
_ ≤ ∑ i ∈ Finset.range n, edist (f (v (i + 1))) (f (v i)) :=
Finset.sum_mono_set _ (Nat.Iio_eq_range ▸ Finset.Ico_subset_Iio_self)
_ ≤ eVariationOn f s :=
sum_le _ _ (fun i j h ↦ hu (π i).2 (π j).2 (monotone_projIcc hmn h)) fun i ↦ us _ (π i).2
theorem sum_le_of_monotoneOn_Iic (f : α → E) {s : Set α} {n : ℕ} {u : ℕ → α}
(hu : MonotoneOn u (Iic n)) (us : ∀ i ≤ n, u i ∈ s) :
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) ≤ eVariationOn f s := by
simpa using sum_le_of_monotoneOn_Icc f (m := 0) (hu.mono Icc_subset_Iic_self) fun i hi ↦ us i hi.2
theorem mono (f : α → E) {s t : Set α} (hst : t ⊆ s) : eVariationOn f t ≤ eVariationOn f s := by
apply iSup_le _
rintro ⟨n, ⟨u, hu, ut⟩⟩
exact sum_le f n hu fun i => hst (ut i)
theorem _root_.BoundedVariationOn.mono {f : α → E} {s : Set α} (h : BoundedVariationOn f s)
{t : Set α} (ht : t ⊆ s) : BoundedVariationOn f t :=
ne_top_of_le_ne_top h (eVariationOn.mono f ht)
theorem _root_.BoundedVariationOn.locallyBoundedVariationOn {f : α → E} {s : Set α}
(h : BoundedVariationOn f s) : LocallyBoundedVariationOn f s := fun _ _ _ _ =>
h.mono inter_subset_left
theorem edist_le (f : α → E) {s : Set α} {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
edist (f x) (f y) ≤ eVariationOn f s := by
wlog hxy : y ≤ x generalizing x y
· rw [edist_comm]
exact this hy hx (le_of_not_le hxy)
let u : ℕ → α := fun n => if n = 0 then y else x
have hu : Monotone u := monotone_nat_of_le_succ fun
| 0 => hxy
| (_ + 1) => le_rfl
have us : ∀ i, u i ∈ s := fun
| 0 => hy
| (_ + 1) => hx
simpa only [Finset.sum_range_one] using sum_le f 1 hu us
theorem eq_zero_iff (f : α → E) {s : Set α} :
eVariationOn f s = 0 ↔ ∀ x ∈ s, ∀ y ∈ s, edist (f x) (f y) = 0 := by
constructor
· rintro h x xs y ys
rw [← le_zero_iff, ← h]
exact edist_le f xs ys
· rintro h
dsimp only [eVariationOn]
rw [ENNReal.iSup_eq_zero]
rintro ⟨n, u, um, us⟩
exact Finset.sum_eq_zero fun i _ => h _ (us i.succ) _ (us i)
theorem constant_on {f : α → E} {s : Set α} (hf : (f '' s).Subsingleton) :
eVariationOn f s = 0 := by
rw [eq_zero_iff]
rintro x xs y ys
rw [hf ⟨x, xs, rfl⟩ ⟨y, ys, rfl⟩, edist_self]
@[simp]
protected theorem subsingleton (f : α → E) {s : Set α} (hs : s.Subsingleton) :
eVariationOn f s = 0 :=
constant_on (hs.image f)
theorem lowerSemicontinuous_aux {ι : Type*} {F : ι → α → E} {p : Filter ι} {f : α → E} {s : Set α}
(Ffs : ∀ x ∈ s, Tendsto (fun i => F i x) p (𝓝 (f x))) {v : ℝ≥0∞} (hv : v < eVariationOn f s) :
∀ᶠ n : ι in p, v < eVariationOn (F n) s := by
obtain ⟨⟨n, ⟨u, um, us⟩⟩, hlt⟩ :
∃ p : ℕ × { u : ℕ → α // Monotone u ∧ ∀ i, u i ∈ s },
v < ∑ i ∈ Finset.range p.1, edist (f ((p.2 : ℕ → α) (i + 1))) (f ((p.2 : ℕ → α) i)) :=
lt_iSup_iff.mp hv
have : Tendsto (fun j => ∑ i ∈ Finset.range n, edist (F j (u (i + 1))) (F j (u i))) p
(𝓝 (∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i)))) := by
apply tendsto_finset_sum
exact fun i _ => Tendsto.edist (Ffs (u i.succ) (us i.succ)) (Ffs (u i) (us i))
exact (eventually_gt_of_tendsto_gt hlt this).mono fun i h => h.trans_le (sum_le (F i) n um us)
/-- The map `(eVariationOn · s)` is lower semicontinuous for pointwise convergence *on `s`*.
Pointwise convergence on `s` is encoded here as uniform convergence on the family consisting of the
singletons of elements of `s`.
-/
protected theorem lowerSemicontinuous (s : Set α) :
LowerSemicontinuous fun f : α →ᵤ[s.image singleton] E => eVariationOn f s := fun f ↦ by
apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E (s.image singleton)) id (𝓝 f) f s _
simpa only [UniformOnFun.tendsto_iff_tendstoUniformlyOn, mem_image, forall_exists_index, and_imp,
forall_apply_eq_imp_iff₂, tendstoUniformlyOn_singleton_iff_tendsto] using @tendsto_id _ (𝓝 f)
/-- The map `(eVariationOn · s)` is lower semicontinuous for uniform convergence on `s`. -/
theorem lowerSemicontinuous_uniformOn (s : Set α) :
LowerSemicontinuous fun f : α →ᵤ[{s}] E => eVariationOn f s := fun f ↦ by
apply @lowerSemicontinuous_aux _ _ _ _ (UniformOnFun α E {s}) id (𝓝 f) f s _
have := @tendsto_id _ (𝓝 f)
rw [UniformOnFun.tendsto_iff_tendstoUniformlyOn] at this
simp_rw [← tendstoUniformlyOn_singleton_iff_tendsto]
exact fun x xs => (this s rfl).mono (singleton_subset_iff.mpr xs)
theorem _root_.BoundedVariationOn.dist_le {E : Type*} [PseudoMetricSpace E] {f : α → E}
{s : Set α} (h : BoundedVariationOn f s) {x y : α} (hx : x ∈ s) (hy : y ∈ s) :
dist (f x) (f y) ≤ (eVariationOn f s).toReal := by
rw [← ENNReal.ofReal_le_ofReal_iff ENNReal.toReal_nonneg, ENNReal.ofReal_toReal h, ← edist_dist]
exact edist_le f hx hy
theorem _root_.BoundedVariationOn.sub_le {f : α → ℝ} {s : Set α} (h : BoundedVariationOn f s)
{x y : α} (hx : x ∈ s) (hy : y ∈ s) : f x - f y ≤ (eVariationOn f s).toReal := by
apply (le_abs_self _).trans
rw [← Real.dist_eq]
exact h.dist_le hx hy
/-- Consider a monotone function `u` parameterizing some points of a set `s`. Given `x ∈ s`, then
one can find another monotone function `v` parameterizing the same points as `u`, with `x` added.
In particular, the variation of a function along `u` is bounded by its variation along `v`. -/
theorem add_point (f : α → E) {s : Set α} {x : α} (hx : x ∈ s) (u : ℕ → α) (hu : Monotone u)
(us : ∀ i, u i ∈ s) (n : ℕ) :
∃ (v : ℕ → α) (m : ℕ), Monotone v ∧ (∀ i, v i ∈ s) ∧ x ∈ v '' Iio m ∧
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) ≤
∑ j ∈ Finset.range m, edist (f (v (j + 1))) (f (v j)) := by
rcases le_or_lt (u n) x with (h | h)
· let v i := if i ≤ n then u i else x
have vs : ∀ i, v i ∈ s := fun i ↦ by
simp only [v]
split_ifs
· exact us i
· exact hx
have hv : Monotone v := by
refine monotone_nat_of_le_succ fun i => ?_
simp only [v]
rcases lt_trichotomy i n with (hi | rfl | hi)
· have : i + 1 ≤ n := Nat.succ_le_of_lt hi
simp only [hi.le, this, if_true]
exact hu (Nat.le_succ i)
· simp only [le_refl, if_true, add_le_iff_nonpos_right, Nat.le_zero, Nat.one_ne_zero,
if_false, h]
· have A : ¬i ≤ n := hi.not_le
have B : ¬i + 1 ≤ n := fun h => A (i.le_succ.trans h)
simp only [A, B, if_false, le_rfl]
refine ⟨v, n + 2, hv, vs, (mem_image _ _ _).2 ⟨n + 1, ?_, ?_⟩, ?_⟩
· rw [mem_Iio]; exact Nat.lt_succ_self (n + 1)
· have : ¬n + 1 ≤ n := Nat.not_succ_le_self n
simp only [v, this, ite_eq_right_iff, IsEmpty.forall_iff]
· calc
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) =
∑ i ∈ Finset.range n, edist (f (v (i + 1))) (f (v i)) := by
apply Finset.sum_congr rfl fun i hi => ?_
simp only [Finset.mem_range] at hi
have : i + 1 ≤ n := Nat.succ_le_of_lt hi
simp only [v, hi.le, this, if_true]
_ ≤ ∑ j ∈ Finset.range (n + 2), edist (f (v (j + 1))) (f (v j)) :=
Finset.sum_le_sum_of_subset (Finset.range_mono (Nat.le_add_right n 2))
have exists_N : ∃ N, N ≤ n ∧ x < u N := ⟨n, le_rfl, h⟩
let N := Nat.find exists_N
have hN : N ≤ n ∧ x < u N := Nat.find_spec exists_N
let w : ℕ → α := fun i => if i < N then u i else if i = N then x else u (i - 1)
have ws : ∀ i, w i ∈ s := by
dsimp only [w]
intro i
split_ifs
exacts [us _, hx, us _]
have hw : Monotone w := by
apply monotone_nat_of_le_succ fun i => ?_
dsimp only [w]
rcases lt_trichotomy (i + 1) N with (hi | hi | hi)
· have : i < N := Nat.lt_of_le_of_lt (Nat.le_succ i) hi
simp only [hi, this, if_true]
exact hu (Nat.le_succ _)
· have A : i < N := hi ▸ i.lt_succ_self
have B : ¬i + 1 < N := by rw [← hi]; exact fun h => h.ne rfl
rw [if_pos A, if_neg B, if_pos hi]
have T := Nat.find_min exists_N A
push_neg at T
exact T (A.le.trans hN.1)
· have A : ¬i < N := (Nat.lt_succ_iff.mp hi).not_lt
have B : ¬i + 1 < N := hi.not_lt
have C : ¬i + 1 = N := hi.ne.symm
have D : i + 1 - 1 = i := Nat.pred_succ i
rw [if_neg A, if_neg B, if_neg C, D]
split_ifs
· exact hN.2.le.trans (hu (le_of_not_lt A))
· exact hu (Nat.pred_le _)
refine ⟨w, n + 1, hw, ws, (mem_image _ _ _).2 ⟨N, hN.1.trans_lt (Nat.lt_succ_self n), ?_⟩, ?_⟩
· dsimp only [w]; rw [if_neg (lt_irrefl N), if_pos rfl]
rcases eq_or_lt_of_le (zero_le N) with (Npos | Npos)
· calc
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) =
∑ i ∈ Finset.range n, edist (f (w (1 + i + 1))) (f (w (1 + i))) := by
apply Finset.sum_congr rfl fun i _hi => ?_
dsimp only [w]
simp only [← Npos, Nat.not_lt_zero, Nat.add_succ_sub_one, add_zero, if_false,
add_eq_zero_iff, Nat.one_ne_zero, false_and_iff, Nat.succ_add_sub_one, zero_add]
rw [add_comm 1 i]
_ = ∑ i ∈ Finset.Ico 1 (n + 1), edist (f (w (i + 1))) (f (w i)) := by
rw [Finset.range_eq_Ico]
exact Finset.sum_Ico_add (fun i => edist (f (w (i + 1))) (f (w i))) 0 n 1
_ ≤ ∑ j ∈ Finset.range (n + 1), edist (f (w (j + 1))) (f (w j)) := by
apply Finset.sum_le_sum_of_subset _
rw [Finset.range_eq_Ico]
exact Finset.Ico_subset_Ico zero_le_one le_rfl
· calc
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) =
((∑ i ∈ Finset.Ico 0 (N - 1), edist (f (u (i + 1))) (f (u i))) +
∑ i ∈ Finset.Ico (N - 1) N, edist (f (u (i + 1))) (f (u i))) +
∑ i ∈ Finset.Ico N n, edist (f (u (i + 1))) (f (u i)) := by
rw [Finset.sum_Ico_consecutive, Finset.sum_Ico_consecutive, Finset.range_eq_Ico]
· exact zero_le _
· exact hN.1
· exact zero_le _
· exact Nat.pred_le _
_ = (∑ i ∈ Finset.Ico 0 (N - 1), edist (f (w (i + 1))) (f (w i))) +
edist (f (u N)) (f (u (N - 1))) +
∑ i ∈ Finset.Ico N n, edist (f (w (1 + i + 1))) (f (w (1 + i))) := by
congr 1
· congr 1
· apply Finset.sum_congr rfl fun i hi => ?_
simp only [Finset.mem_Ico, zero_le', true_and_iff] at hi
dsimp only [w]
have A : i + 1 < N := Nat.lt_pred_iff.1 hi
have B : i < N := Nat.lt_of_succ_lt A
rw [if_pos A, if_pos B]
· have A : N - 1 + 1 = N := Nat.succ_pred_eq_of_pos Npos
have : Finset.Ico (N - 1) N = {N - 1} := by rw [← Nat.Ico_succ_singleton, A]
simp only [this, A, Finset.sum_singleton]
· apply Finset.sum_congr rfl fun i hi => ?_
rw [Finset.mem_Ico] at hi
dsimp only [w]
have A : ¬1 + i + 1 < N := by omega
have B : ¬1 + i + 1 = N := by omega
have C : ¬1 + i < N := by omega
have D : ¬1 + i = N := by omega
rw [if_neg A, if_neg B, if_neg C, if_neg D]
congr 3 <;> · rw [add_comm, Nat.sub_one]; apply Nat.pred_succ
_ = (∑ i ∈ Finset.Ico 0 (N - 1), edist (f (w (i + 1))) (f (w i))) +
edist (f (w (N + 1))) (f (w (N - 1))) +
∑ i ∈ Finset.Ico (N + 1) (n + 1), edist (f (w (i + 1))) (f (w i)) := by
congr 1
· congr 1
· dsimp only [w]
have A : ¬N + 1 < N := Nat.not_succ_lt_self
have B : N - 1 < N := Nat.pred_lt Npos.ne'
simp only [A, not_and, not_lt, Nat.succ_ne_self, Nat.add_succ_sub_one, add_zero,
if_false, B, if_true]
· exact Finset.sum_Ico_add (fun i => edist (f (w (i + 1))) (f (w i))) N n 1
_ ≤ ((∑ i ∈ Finset.Ico 0 (N - 1), edist (f (w (i + 1))) (f (w i))) +
∑ i ∈ Finset.Ico (N - 1) (N + 1), edist (f (w (i + 1))) (f (w i))) +
∑ i ∈ Finset.Ico (N + 1) (n + 1), edist (f (w (i + 1))) (f (w i)) := by
refine add_le_add (add_le_add le_rfl ?_) le_rfl
have A : N - 1 + 1 = N := Nat.succ_pred_eq_of_pos Npos
have B : N - 1 + 1 < N + 1 := A.symm ▸ N.lt_succ_self
have C : N - 1 < N + 1 := lt_of_le_of_lt N.pred_le N.lt_succ_self
rw [Finset.sum_eq_sum_Ico_succ_bot C, Finset.sum_eq_sum_Ico_succ_bot B, A, Finset.Ico_self,
Finset.sum_empty, add_zero, add_comm (edist _ _)]
exact edist_triangle _ _ _
_ = ∑ j ∈ Finset.range (n + 1), edist (f (w (j + 1))) (f (w j)) := by
rw [Finset.sum_Ico_consecutive, Finset.sum_Ico_consecutive, Finset.range_eq_Ico]
· exact zero_le _
· exact Nat.succ_le_succ hN.left
· exact zero_le _
· exact N.pred_le.trans N.le_succ
/-- The variation of a function on the union of two sets `s` and `t`, with `s` to the left of `t`,
bounds the sum of the variations along `s` and `t`. -/
theorem add_le_union (f : α → E) {s t : Set α} (h : ∀ x ∈ s, ∀ y ∈ t, x ≤ y) :
eVariationOn f s + eVariationOn f t ≤ eVariationOn f (s ∪ t) := by
by_cases hs : s = ∅
· simp [hs]
have : Nonempty { u // Monotone u ∧ ∀ i : ℕ, u i ∈ s } :=
nonempty_monotone_mem (nonempty_iff_ne_empty.2 hs)
by_cases ht : t = ∅
· simp [ht]
have : Nonempty { u // Monotone u ∧ ∀ i : ℕ, u i ∈ t } :=
nonempty_monotone_mem (nonempty_iff_ne_empty.2 ht)
refine ENNReal.iSup_add_iSup_le ?_
/- We start from two sequences `u` and `v` along `s` and `t` respectively, and we build a new
sequence `w` along `s ∪ t` by juxtaposing them. Its variation is larger than the sum of the
variations. -/
rintro ⟨n, ⟨u, hu, us⟩⟩ ⟨m, ⟨v, hv, vt⟩⟩
let w i := if i ≤ n then u i else v (i - (n + 1))
have wst : ∀ i, w i ∈ s ∪ t := by
intro i
by_cases hi : i ≤ n
· simp [w, hi, us]
· simp [w, hi, vt]
have hw : Monotone w := by
intro i j hij
dsimp only [w]
split_ifs with h_1 h_2 h_2
· exact hu hij
· apply h _ (us _) _ (vt _)
· exfalso; exact h_1 (hij.trans h_2)
· apply hv (tsub_le_tsub hij le_rfl)
calc
((∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) +
∑ i ∈ Finset.range m, edist (f (v (i + 1))) (f (v i))) =
(∑ i ∈ Finset.range n, edist (f (w (i + 1))) (f (w i))) +
∑ i ∈ Finset.range m, edist (f (w (n + 1 + i + 1))) (f (w (n + 1 + i))) := by
dsimp only [w]
congr 1
· refine Finset.sum_congr rfl fun i hi => ?_
simp only [Finset.mem_range] at hi
have : i + 1 ≤ n := Nat.succ_le_of_lt hi
simp [hi.le, this]
· refine Finset.sum_congr rfl fun i hi => ?_
simp only [Finset.mem_range] at hi
have B : ¬n + 1 + i ≤ n := by omega
have A : ¬n + 1 + i + 1 ≤ n := fun h => B ((n + 1 + i).le_succ.trans h)
have C : n + 1 + i - n = i + 1 := by
rw [tsub_eq_iff_eq_add_of_le]
· abel
· exact n.le_succ.trans (n.succ.le_add_right i)
simp only [A, B, C, Nat.succ_sub_succ_eq_sub, if_false, add_tsub_cancel_left]
_ = (∑ i ∈ Finset.range n, edist (f (w (i + 1))) (f (w i))) +
∑ i ∈ Finset.Ico (n + 1) (n + 1 + m), edist (f (w (i + 1))) (f (w i)) := by
congr 1
rw [Finset.range_eq_Ico]
convert Finset.sum_Ico_add (fun i : ℕ => edist (f (w (i + 1))) (f (w i))) 0 m (n + 1)
using 3 <;> abel
_ ≤ ∑ i ∈ Finset.range (n + 1 + m), edist (f (w (i + 1))) (f (w i)) := by
rw [← Finset.sum_union]
· apply Finset.sum_le_sum_of_subset _
rintro i hi
simp only [Finset.mem_union, Finset.mem_range, Finset.mem_Ico] at hi ⊢
cases' hi with hi hi
· exact lt_of_lt_of_le hi (n.le_succ.trans (n.succ.le_add_right m))
· exact hi.2
· refine Finset.disjoint_left.2 fun i hi h'i => ?_
simp only [Finset.mem_Ico, Finset.mem_range] at hi h'i
exact hi.not_lt (Nat.lt_of_succ_le h'i.left)
_ ≤ eVariationOn f (s ∪ t) := sum_le f _ hw wst
/-- If a set `s` is to the left of a set `t`, and both contain the boundary point `x`, then
the variation of `f` along `s ∪ t` is the sum of the variations. -/
theorem union (f : α → E) {s t : Set α} {x : α} (hs : IsGreatest s x) (ht : IsLeast t x) :
eVariationOn f (s ∪ t) = eVariationOn f s + eVariationOn f t := by
classical
apply le_antisymm _ (eVariationOn.add_le_union f fun a ha b hb => le_trans (hs.2 ha) (ht.2 hb))
apply iSup_le _
rintro ⟨n, ⟨u, hu, ust⟩⟩
obtain ⟨v, m, hv, vst, xv, huv⟩ : ∃ (v : ℕ → α) (m : ℕ),
Monotone v ∧ (∀ i, v i ∈ s ∪ t) ∧ x ∈ v '' Iio m ∧
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) ≤
∑ j ∈ Finset.range m, edist (f (v (j + 1))) (f (v j)) :=
eVariationOn.add_point f (mem_union_left t hs.1) u hu ust n
obtain ⟨N, hN, Nx⟩ : ∃ N, N < m ∧ v N = x := xv
calc
(∑ j ∈ Finset.range n, edist (f (u (j + 1))) (f (u j))) ≤
∑ j ∈ Finset.range m, edist (f (v (j + 1))) (f (v j)) :=
huv
_ = (∑ j ∈ Finset.Ico 0 N, edist (f (v (j + 1))) (f (v j))) +
∑ j ∈ Finset.Ico N m, edist (f (v (j + 1))) (f (v j)) := by
rw [Finset.range_eq_Ico, Finset.sum_Ico_consecutive _ (zero_le _) hN.le]
_ ≤ eVariationOn f s + eVariationOn f t := by
refine add_le_add ?_ ?_
· apply sum_le_of_monotoneOn_Icc _ (hv.monotoneOn _) fun i hi => ?_
rcases vst i with (h | h); · exact h
have : v i = x := by
apply le_antisymm
· rw [← Nx]; exact hv hi.2
· exact ht.2 h
rw [this]
exact hs.1
· apply sum_le_of_monotoneOn_Icc _ (hv.monotoneOn _) fun i hi => ?_
rcases vst i with (h | h); swap; · exact h
have : v i = x := by
apply le_antisymm
· exact hs.2 h
· rw [← Nx]; exact hv hi.1
rw [this]
exact ht.1
theorem Icc_add_Icc (f : α → E) {s : Set α} {a b c : α} (hab : a ≤ b) (hbc : b ≤ c) (hb : b ∈ s) :
eVariationOn f (s ∩ Icc a b) + eVariationOn f (s ∩ Icc b c) = eVariationOn f (s ∩ Icc a c) := by
have A : IsGreatest (s ∩ Icc a b) b :=
⟨⟨hb, hab, le_rfl⟩, inter_subset_right.trans Icc_subset_Iic_self⟩
have B : IsLeast (s ∩ Icc b c) b :=
⟨⟨hb, le_rfl, hbc⟩, inter_subset_right.trans Icc_subset_Ici_self⟩
rw [← eVariationOn.union f A B, ← inter_union_distrib_left, Icc_union_Icc_eq_Icc hab hbc]
section Monotone
variable {β : Type*} [LinearOrder β]
theorem comp_le_of_monotoneOn (f : α → E) {s : Set α} {t : Set β} (φ : β → α) (hφ : MonotoneOn φ t)
(φst : MapsTo φ t s) : eVariationOn (f ∘ φ) t ≤ eVariationOn f s :=
iSup_le fun ⟨n, u, hu, ut⟩ =>
le_iSup_of_le ⟨n, φ ∘ u, fun x y xy => hφ (ut x) (ut y) (hu xy), fun i => φst (ut i)⟩ le_rfl
theorem comp_le_of_antitoneOn (f : α → E) {s : Set α} {t : Set β} (φ : β → α) (hφ : AntitoneOn φ t)
(φst : MapsTo φ t s) : eVariationOn (f ∘ φ) t ≤ eVariationOn f s := by
refine iSup_le ?_
rintro ⟨n, u, hu, ut⟩
rw [← Finset.sum_range_reflect]
refine (Finset.sum_congr rfl fun x hx => ?_).trans_le <| le_iSup_of_le
⟨n, fun i => φ (u <| n - i), fun x y xy => hφ (ut _) (ut _) (hu <| Nat.sub_le_sub_left xy n),
fun i => φst (ut _)⟩
le_rfl
rw [Finset.mem_range] at hx
dsimp only [Subtype.coe_mk, Function.comp_apply]
rw [edist_comm]
congr 4 <;> omega
theorem comp_eq_of_monotoneOn (f : α → E) {t : Set β} (φ : β → α) (hφ : MonotoneOn φ t) :
eVariationOn (f ∘ φ) t = eVariationOn f (φ '' t) := by
apply le_antisymm (comp_le_of_monotoneOn f φ hφ (mapsTo_image φ t))
cases isEmpty_or_nonempty β
· convert zero_le (_ : ℝ≥0∞)
exact eVariationOn.subsingleton f <|
(subsingleton_of_subsingleton.image _).anti (surjOn_image φ t)
let ψ := φ.invFunOn t
have ψφs : EqOn (φ ∘ ψ) id (φ '' t) := (surjOn_image φ t).rightInvOn_invFunOn
have ψts : MapsTo ψ (φ '' t) t := (surjOn_image φ t).mapsTo_invFunOn
have hψ : MonotoneOn ψ (φ '' t) := Function.monotoneOn_of_rightInvOn_of_mapsTo hφ ψφs ψts
change eVariationOn (f ∘ id) (φ '' t) ≤ eVariationOn (f ∘ φ) t
rw [← eq_of_eqOn (ψφs.comp_left : EqOn (f ∘ φ ∘ ψ) (f ∘ id) (φ '' t))]
exact comp_le_of_monotoneOn _ ψ hψ ψts
theorem comp_inter_Icc_eq_of_monotoneOn (f : α → E) {t : Set β} (φ : β → α) (hφ : MonotoneOn φ t)
{x y : β} (hx : x ∈ t) (hy : y ∈ t) :
eVariationOn (f ∘ φ) (t ∩ Icc x y) = eVariationOn f (φ '' t ∩ Icc (φ x) (φ y)) := by
rcases le_total x y with (h | h)
· convert comp_eq_of_monotoneOn f φ (hφ.mono Set.inter_subset_left)
apply le_antisymm
· rintro _ ⟨⟨u, us, rfl⟩, vφx, vφy⟩
rcases le_total x u with (xu | ux)
· rcases le_total u y with (uy | yu)
· exact ⟨u, ⟨us, ⟨xu, uy⟩⟩, rfl⟩
· rw [le_antisymm vφy (hφ hy us yu)]
exact ⟨y, ⟨hy, ⟨h, le_rfl⟩⟩, rfl⟩
· rw [← le_antisymm vφx (hφ us hx ux)]
exact ⟨x, ⟨hx, ⟨le_rfl, h⟩⟩, rfl⟩
· rintro _ ⟨u, ⟨⟨hu, xu, uy⟩, rfl⟩⟩
exact ⟨⟨u, hu, rfl⟩, ⟨hφ hx hu xu, hφ hu hy uy⟩⟩
· rw [eVariationOn.subsingleton, eVariationOn.subsingleton]
exacts [(Set.subsingleton_Icc_of_ge (hφ hy hx h)).anti Set.inter_subset_right,
(Set.subsingleton_Icc_of_ge h).anti Set.inter_subset_right]
theorem comp_eq_of_antitoneOn (f : α → E) {t : Set β} (φ : β → α) (hφ : AntitoneOn φ t) :
eVariationOn (f ∘ φ) t = eVariationOn f (φ '' t) := by
apply le_antisymm (comp_le_of_antitoneOn f φ hφ (mapsTo_image φ t))
cases isEmpty_or_nonempty β
· convert zero_le (_ : ℝ≥0∞)
exact eVariationOn.subsingleton f <| (subsingleton_of_subsingleton.image _).anti
(surjOn_image φ t)
let ψ := φ.invFunOn t
have ψφs : EqOn (φ ∘ ψ) id (φ '' t) := (surjOn_image φ t).rightInvOn_invFunOn
have ψts := (surjOn_image φ t).mapsTo_invFunOn
have hψ : AntitoneOn ψ (φ '' t) := Function.antitoneOn_of_rightInvOn_of_mapsTo hφ ψφs ψts
change eVariationOn (f ∘ id) (φ '' t) ≤ eVariationOn (f ∘ φ) t
rw [← eq_of_eqOn (ψφs.comp_left : EqOn (f ∘ φ ∘ ψ) (f ∘ id) (φ '' t))]
exact comp_le_of_antitoneOn _ ψ hψ ψts
open OrderDual
theorem comp_ofDual (f : α → E) (s : Set α) :
eVariationOn (f ∘ ofDual) (ofDual ⁻¹' s) = eVariationOn f s := by
convert comp_eq_of_antitoneOn f ofDual fun _ _ _ _ => id
simp only [Equiv.image_preimage]
end Monotone
end eVariationOn
/-! ## Monotone functions and bounded variation -/
theorem MonotoneOn.eVariationOn_le {f : α → ℝ} {s : Set α} (hf : MonotoneOn f s) {a b : α}
(as : a ∈ s) (bs : b ∈ s) : eVariationOn f (s ∩ Icc a b) ≤ ENNReal.ofReal (f b - f a) := by
apply iSup_le _
rintro ⟨n, ⟨u, hu, us⟩⟩
calc
(∑ i ∈ Finset.range n, edist (f (u (i + 1))) (f (u i))) =
∑ i ∈ Finset.range n, ENNReal.ofReal (f (u (i + 1)) - f (u i)) := by
refine Finset.sum_congr rfl fun i hi => ?_
simp only [Finset.mem_range] at hi
rw [edist_dist, Real.dist_eq, abs_of_nonneg]
exact sub_nonneg_of_le (hf (us i).1 (us (i + 1)).1 (hu (Nat.le_succ _)))
_ = ENNReal.ofReal (∑ i ∈ Finset.range n, (f (u (i + 1)) - f (u i))) := by
rw [ENNReal.ofReal_sum_of_nonneg]
intro i _
exact sub_nonneg_of_le (hf (us i).1 (us (i + 1)).1 (hu (Nat.le_succ _)))
_ = ENNReal.ofReal (f (u n) - f (u 0)) := by rw [Finset.sum_range_sub fun i => f (u i)]
_ ≤ ENNReal.ofReal (f b - f a) := by
apply ENNReal.ofReal_le_ofReal
exact sub_le_sub (hf (us n).1 bs (us n).2.2) (hf as (us 0).1 (us 0).2.1)
theorem MonotoneOn.locallyBoundedVariationOn {f : α → ℝ} {s : Set α} (hf : MonotoneOn f s) :
LocallyBoundedVariationOn f s := fun _ _ as bs =>
((hf.eVariationOn_le as bs).trans_lt ENNReal.ofReal_lt_top).ne
/-- The **signed** variation of `f` on the interval `Icc a b` intersected with the set `s`,
squashed to a real (therefore only really meaningful if the variation is finite)
-/
noncomputable def variationOnFromTo (f : α → E) (s : Set α) (a b : α) : ℝ :=
if a ≤ b then (eVariationOn f (s ∩ Icc a b)).toReal else -(eVariationOn f (s ∩ Icc b a)).toReal
namespace variationOnFromTo
variable (f : α → E) (s : Set α)
protected theorem self (a : α) : variationOnFromTo f s a a = 0 := by
dsimp only [variationOnFromTo]
rw [if_pos le_rfl, Icc_self, eVariationOn.subsingleton, ENNReal.zero_toReal]
exact fun x hx y hy => hx.2.trans hy.2.symm
protected theorem nonneg_of_le {a b : α} (h : a ≤ b) : 0 ≤ variationOnFromTo f s a b := by
simp only [variationOnFromTo, if_pos h, ENNReal.toReal_nonneg]
protected theorem eq_neg_swap (a b : α) :
variationOnFromTo f s a b = -variationOnFromTo f s b a := by
rcases lt_trichotomy a b with (ab | rfl | ba)
· simp only [variationOnFromTo, if_pos ab.le, if_neg ab.not_le, neg_neg]
· simp only [variationOnFromTo.self, neg_zero]
· simp only [variationOnFromTo, if_pos ba.le, if_neg ba.not_le, neg_neg]
protected theorem nonpos_of_ge {a b : α} (h : b ≤ a) : variationOnFromTo f s a b ≤ 0 := by
rw [variationOnFromTo.eq_neg_swap]
exact neg_nonpos_of_nonneg (variationOnFromTo.nonneg_of_le f s h)
protected theorem eq_of_le {a b : α} (h : a ≤ b) :
variationOnFromTo f s a b = (eVariationOn f (s ∩ Icc a b)).toReal :=
if_pos h
protected theorem eq_of_ge {a b : α} (h : b ≤ a) :
variationOnFromTo f s a b = -(eVariationOn f (s ∩ Icc b a)).toReal := by
rw [variationOnFromTo.eq_neg_swap, neg_inj, variationOnFromTo.eq_of_le f s h]
protected theorem add {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s) {a b c : α}
(ha : a ∈ s) (hb : b ∈ s) (hc : c ∈ s) :
variationOnFromTo f s a b + variationOnFromTo f s b c = variationOnFromTo f s a c := by
symm
refine additive_of_isTotal ((· : α) ≤ ·) (variationOnFromTo f s) (· ∈ s) ?_ ?_ ha hb hc
· rintro x y _xs _ys
simp only [variationOnFromTo.eq_neg_swap f s y x, Subtype.coe_mk, add_right_neg,
forall_true_left]
· rintro x y z xy yz xs ys zs
rw [variationOnFromTo.eq_of_le f s xy, variationOnFromTo.eq_of_le f s yz,
variationOnFromTo.eq_of_le f s (xy.trans yz),
← ENNReal.toReal_add (hf x y xs ys) (hf y z ys zs), eVariationOn.Icc_add_Icc f xy yz ys]
protected theorem edist_zero_of_eq_zero {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s)
{a b : α} (ha : a ∈ s) (hb : b ∈ s) (h : variationOnFromTo f s a b = 0) :
edist (f a) (f b) = 0 := by
wlog h' : a ≤ b
· rw [edist_comm]
apply this f s hf hb ha _ (le_of_not_le h')
rw [variationOnFromTo.eq_neg_swap, h, neg_zero]
· apply le_antisymm _ (zero_le _)
rw [← ENNReal.ofReal_zero, ← h, variationOnFromTo.eq_of_le f s h',
ENNReal.ofReal_toReal (hf a b ha hb)]
apply eVariationOn.edist_le
exacts [⟨ha, ⟨le_rfl, h'⟩⟩, ⟨hb, ⟨h', le_rfl⟩⟩]
protected theorem eq_left_iff {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s)
{a b c : α} (ha : a ∈ s) (hb : b ∈ s) (hc : c ∈ s) :
variationOnFromTo f s a b = variationOnFromTo f s a c ↔ variationOnFromTo f s b c = 0 := by
simp only [← variationOnFromTo.add hf ha hb hc, self_eq_add_right]
protected theorem eq_zero_iff_of_le {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s)
{a b : α} (ha : a ∈ s) (hb : b ∈ s) (ab : a ≤ b) :
variationOnFromTo f s a b = 0 ↔
∀ ⦃x⦄ (_hx : x ∈ s ∩ Icc a b) ⦃y⦄ (_hy : y ∈ s ∩ Icc a b), edist (f x) (f y) = 0 := by
rw [variationOnFromTo.eq_of_le _ _ ab, ENNReal.toReal_eq_zero_iff, or_iff_left (hf a b ha hb),
eVariationOn.eq_zero_iff]
protected theorem eq_zero_iff_of_ge {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s)
{a b : α} (ha : a ∈ s) (hb : b ∈ s) (ba : b ≤ a) :
variationOnFromTo f s a b = 0 ↔
∀ ⦃x⦄ (_hx : x ∈ s ∩ Icc b a) ⦃y⦄ (_hy : y ∈ s ∩ Icc b a), edist (f x) (f y) = 0 := by
rw [variationOnFromTo.eq_of_ge _ _ ba, neg_eq_zero, ENNReal.toReal_eq_zero_iff,
or_iff_left (hf b a hb ha), eVariationOn.eq_zero_iff]
protected theorem eq_zero_iff {f : α → E} {s : Set α} (hf : LocallyBoundedVariationOn f s) {a b : α}
(ha : a ∈ s) (hb : b ∈ s) :
variationOnFromTo f s a b = 0 ↔
∀ ⦃x⦄ (_hx : x ∈ s ∩ uIcc a b) ⦃y⦄ (_hy : y ∈ s ∩ uIcc a b), edist (f x) (f y) = 0 := by
rcases le_total a b with (ab | ba)
· rw [uIcc_of_le ab]
exact variationOnFromTo.eq_zero_iff_of_le hf ha hb ab
· rw [uIcc_of_ge ba]
exact variationOnFromTo.eq_zero_iff_of_ge hf ha hb ba
variable {f} {s}
protected theorem monotoneOn (hf : LocallyBoundedVariationOn f s) {a : α} (as : a ∈ s) :
MonotoneOn (variationOnFromTo f s a) s := by
rintro b bs c cs bc
rw [← variationOnFromTo.add hf as bs cs]
exact le_add_of_nonneg_right (variationOnFromTo.nonneg_of_le f s bc)
protected theorem antitoneOn (hf : LocallyBoundedVariationOn f s) {b : α} (bs : b ∈ s) :
AntitoneOn (fun a => variationOnFromTo f s a b) s := by
rintro a as c cs ac
dsimp only
rw [← variationOnFromTo.add hf as cs bs]
exact le_add_of_nonneg_left (variationOnFromTo.nonneg_of_le f s ac)
protected theorem sub_self_monotoneOn {f : α → ℝ} {s : Set α} (hf : LocallyBoundedVariationOn f s)
{a : α} (as : a ∈ s) : MonotoneOn (variationOnFromTo f s a - f) s := by
rintro b bs c cs bc
rw [Pi.sub_apply, Pi.sub_apply, le_sub_iff_add_le, add_comm_sub, ← le_sub_iff_add_le']
calc
f c - f b ≤ |f c - f b| := le_abs_self _
_ = dist (f b) (f c) := by rw [dist_comm, Real.dist_eq]
_ ≤ variationOnFromTo f s b c := by
rw [variationOnFromTo.eq_of_le f s bc, dist_edist]
apply ENNReal.toReal_mono (hf b c bs cs)
apply eVariationOn.edist_le f
exacts [⟨bs, le_rfl, bc⟩, ⟨cs, bc, le_rfl⟩]
_ = variationOnFromTo f s a c - variationOnFromTo f s a b := by
rw [← variationOnFromTo.add hf as bs cs, add_sub_cancel_left]
protected theorem comp_eq_of_monotoneOn {β : Type*} [LinearOrder β] (f : α → E) {t : Set β}
(φ : β → α) (hφ : MonotoneOn φ t) {x y : β} (hx : x ∈ t) (hy : y ∈ t) :
variationOnFromTo (f ∘ φ) t x y = variationOnFromTo f (φ '' t) (φ x) (φ y) := by
rcases le_total x y with (h | h)
· rw [variationOnFromTo.eq_of_le _ _ h, variationOnFromTo.eq_of_le _ _ (hφ hx hy h),
eVariationOn.comp_inter_Icc_eq_of_monotoneOn f φ hφ hx hy]
· rw [variationOnFromTo.eq_of_ge _ _ h, variationOnFromTo.eq_of_ge _ _ (hφ hy hx h),
eVariationOn.comp_inter_Icc_eq_of_monotoneOn f φ hφ hy hx]
end variationOnFromTo
/-- If a real valued function has bounded variation on a set, then it is a difference of monotone
functions there. -/
theorem LocallyBoundedVariationOn.exists_monotoneOn_sub_monotoneOn {f : α → ℝ} {s : Set α}
(h : LocallyBoundedVariationOn f s) :
∃ p q : α → ℝ, MonotoneOn p s ∧ MonotoneOn q s ∧ f = p - q := by
rcases eq_empty_or_nonempty s with (rfl | ⟨c, cs⟩)
· exact ⟨f, 0, subsingleton_empty.monotoneOn _, subsingleton_empty.monotoneOn _,
(sub_zero f).symm⟩
· exact ⟨_, _, variationOnFromTo.monotoneOn h cs, variationOnFromTo.sub_self_monotoneOn h cs,
(sub_sub_cancel _ _).symm⟩
/-! ## Lipschitz functions and bounded variation -/
section LipschitzOnWith
variable {F : Type*} [PseudoEMetricSpace F]
theorem LipschitzOnWith.comp_eVariationOn_le {f : E → F} {C : ℝ≥0} {t : Set E}
(h : LipschitzOnWith C f t) {g : α → E} {s : Set α} (hg : MapsTo g s t) :
eVariationOn (f ∘ g) s ≤ C * eVariationOn g s := by
apply iSup_le _
rintro ⟨n, ⟨u, hu, us⟩⟩
calc
(∑ i ∈ Finset.range n, edist (f (g (u (i + 1)))) (f (g (u i)))) ≤
∑ i ∈ Finset.range n, C * edist (g (u (i + 1))) (g (u i)) :=
Finset.sum_le_sum fun i _ => h (hg (us _)) (hg (us _))
_ = C * ∑ i ∈ Finset.range n, edist (g (u (i + 1))) (g (u i)) := by rw [Finset.mul_sum]
_ ≤ C * eVariationOn g s := mul_le_mul_left' (eVariationOn.sum_le _ _ hu us) _
theorem LipschitzOnWith.comp_boundedVariationOn {f : E → F} {C : ℝ≥0} {t : Set E}
(hf : LipschitzOnWith C f t) {g : α → E} {s : Set α} (hg : MapsTo g s t)
(h : BoundedVariationOn g s) : BoundedVariationOn (f ∘ g) s :=
ne_top_of_le_ne_top (ENNReal.mul_ne_top ENNReal.coe_ne_top h) (hf.comp_eVariationOn_le hg)
theorem LipschitzOnWith.comp_locallyBoundedVariationOn {f : E → F} {C : ℝ≥0} {t : Set E}
(hf : LipschitzOnWith C f t) {g : α → E} {s : Set α} (hg : MapsTo g s t)
(h : LocallyBoundedVariationOn g s) : LocallyBoundedVariationOn (f ∘ g) s :=
fun x y xs ys =>
hf.comp_boundedVariationOn (hg.mono_left inter_subset_left) (h x y xs ys)
theorem LipschitzWith.comp_boundedVariationOn {f : E → F} {C : ℝ≥0} (hf : LipschitzWith C f)
{g : α → E} {s : Set α} (h : BoundedVariationOn g s) : BoundedVariationOn (f ∘ g) s :=
(hf.lipschitzOnWith univ).comp_boundedVariationOn (mapsTo_univ _ _) h
theorem LipschitzWith.comp_locallyBoundedVariationOn {f : E → F} {C : ℝ≥0}
(hf : LipschitzWith C f) {g : α → E} {s : Set α} (h : LocallyBoundedVariationOn g s) :
LocallyBoundedVariationOn (f ∘ g) s :=
(hf.lipschitzOnWith univ).comp_locallyBoundedVariationOn (mapsTo_univ _ _) h
theorem LipschitzOnWith.locallyBoundedVariationOn {f : ℝ → E} {C : ℝ≥0} {s : Set ℝ}
(hf : LipschitzOnWith C f s) : LocallyBoundedVariationOn f s :=
hf.comp_locallyBoundedVariationOn (mapsTo_id _)
(@monotoneOn_id ℝ _ s).locallyBoundedVariationOn
theorem LipschitzWith.locallyBoundedVariationOn {f : ℝ → E} {C : ℝ≥0} (hf : LipschitzWith C f)
(s : Set ℝ) : LocallyBoundedVariationOn f s :=
(hf.lipschitzOnWith s).locallyBoundedVariationOn
end LipschitzOnWith
/-! ## Almost everywhere differentiability of functions with locally bounded variation -/
variable {V : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] [FiniteDimensional ℝ V]
namespace LocallyBoundedVariationOn
/-- A bounded variation function into `ℝ` is differentiable almost everywhere. Superseded by
`ae_differentiableWithinAt_of_mem`. -/
theorem ae_differentiableWithinAt_of_mem_real {f : ℝ → ℝ} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
obtain ⟨p, q, hp, hq, rfl⟩ : ∃ p q, MonotoneOn p s ∧ MonotoneOn q s ∧ f = p - q :=
h.exists_monotoneOn_sub_monotoneOn
filter_upwards [hp.ae_differentiableWithinAt_of_mem, hq.ae_differentiableWithinAt_of_mem] with
x hxp hxq xs
exact (hxp xs).sub (hxq xs)
/-- A bounded variation function into a finite dimensional product vector space is differentiable
almost everywhere. Superseded by `ae_differentiableWithinAt_of_mem`. -/
theorem ae_differentiableWithinAt_of_mem_pi {ι : Type*} [Fintype ι] {f : ℝ → ι → ℝ} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
have A : ∀ i : ι, LipschitzWith 1 fun x : ι → ℝ => x i := fun i => LipschitzWith.eval i
have : ∀ i : ι, ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ (fun x : ℝ => f x i) s x := fun i ↦ by
apply ae_differentiableWithinAt_of_mem_real
exact LipschitzWith.comp_locallyBoundedVariationOn (A i) h
filter_upwards [ae_all_iff.2 this] with x hx xs
exact differentiableWithinAt_pi.2 fun i => hx i xs
/-- A real function into a finite dimensional real vector space with bounded variation on a set
is differentiable almost everywhere in this set. -/
theorem ae_differentiableWithinAt_of_mem {f : ℝ → V} {s : Set ℝ}
(h : LocallyBoundedVariationOn f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x := by
let A := (Basis.ofVectorSpace ℝ V).equivFun.toContinuousLinearEquiv
suffices H : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ (A ∘ f) s x by
filter_upwards [H] with x hx xs
have : f = (A.symm ∘ A) ∘ f := by
simp only [ContinuousLinearEquiv.symm_comp_self, Function.id_comp]
rw [this]
exact A.symm.differentiableAt.comp_differentiableWithinAt x (hx xs)
apply ae_differentiableWithinAt_of_mem_pi
exact A.lipschitz.comp_locallyBoundedVariationOn h
/-- A real function into a finite dimensional real vector space with bounded variation on a set
is differentiable almost everywhere in this set. -/
theorem ae_differentiableWithinAt {f : ℝ → V} {s : Set ℝ} (h : LocallyBoundedVariationOn f s)
(hs : MeasurableSet s) : ∀ᵐ x ∂volume.restrict s, DifferentiableWithinAt ℝ f s x := by
rw [ae_restrict_iff' hs]
exact h.ae_differentiableWithinAt_of_mem
/-- A real function into a finite dimensional real vector space with bounded variation
is differentiable almost everywhere. -/
theorem ae_differentiableAt {f : ℝ → V} (h : LocallyBoundedVariationOn f univ) :
∀ᵐ x, DifferentiableAt ℝ f x := by
filter_upwards [h.ae_differentiableWithinAt_of_mem] with x hx
rw [differentiableWithinAt_univ] at hx
exact hx (mem_univ _)
end LocallyBoundedVariationOn
/-- A real function into a finite dimensional real vector space which is Lipschitz on a set
is differentiable almost everywhere in this set. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzOnWith.ae_differentiableWithinAt_of_mem`.
-/
theorem LipschitzOnWith.ae_differentiableWithinAt_of_mem_real {C : ℝ≥0} {f : ℝ → V} {s : Set ℝ}
(h : LipschitzOnWith C f s) : ∀ᵐ x, x ∈ s → DifferentiableWithinAt ℝ f s x :=
h.locallyBoundedVariationOn.ae_differentiableWithinAt_of_mem
/-- A real function into a finite dimensional real vector space which is Lipschitz on a set
is differentiable almost everywhere in this set. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzOnWith.ae_differentiableWithinAt`. -/
theorem LipschitzOnWith.ae_differentiableWithinAt_real {C : ℝ≥0} {f : ℝ → V} {s : Set ℝ}
(h : LipschitzOnWith C f s) (hs : MeasurableSet s) :
∀ᵐ x ∂volume.restrict s, DifferentiableWithinAt ℝ f s x :=
h.locallyBoundedVariationOn.ae_differentiableWithinAt hs
/-- A real Lipschitz function into a finite dimensional real vector space is differentiable
almost everywhere. For the general Rademacher theorem assuming
that the source space is finite dimensional, see `LipschitzWith.ae_differentiableAt`. -/
theorem LipschitzWith.ae_differentiableAt_real {C : ℝ≥0} {f : ℝ → V} (h : LipschitzWith C f) :
∀ᵐ x, DifferentiableAt ℝ f x :=
(h.locallyBoundedVariationOn univ).ae_differentiableAt
|
Analysis\ConstantSpeed.lean | /-
Copyright (c) 2023 Rémi Bottinelli. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Rémi Bottinelli
-/
import Mathlib.Data.Set.Function
import Mathlib.Analysis.BoundedVariation
/-!
# Constant speed
This file defines the notion of constant (and unit) speed for a function `f : ℝ → E` with
pseudo-emetric structure on `E` with respect to a set `s : Set ℝ` and "speed" `l : ℝ≥0`, and shows
that if `f` has locally bounded variation on `s`, it can be obtained (up to distance zero, on `s`),
as a composite `φ ∘ (variationOnFromTo f s a)`, where `φ` has unit speed and `a ∈ s`.
## Main definitions
* `HasConstantSpeedOnWith f s l`, stating that the speed of `f` on `s` is `l`.
* `HasUnitSpeedOn f s`, stating that the speed of `f` on `s` is `1`.
* `naturalParameterization f s a : ℝ → E`, the unit speed reparameterization of `f` on `s` relative
to `a`.
## Main statements
* `unique_unit_speed_on_Icc_zero` proves that if `f` and `f ∘ φ` are both naturally
parameterized on closed intervals starting at `0`, then `φ` must be the identity on
those intervals.
* `edist_naturalParameterization_eq_zero` proves that if `f` has locally bounded variation, then
precomposing `naturalParameterization f s a` with `variationOnFromTo f s a` yields a function
at distance zero from `f` on `s`.
* `has_unit_speed_naturalParameterization` proves that if `f` has locally bounded
variation, then `naturalParameterization f s a` has unit speed on `s`.
## Tags
arc-length, parameterization
-/
open scoped NNReal ENNReal
open Set MeasureTheory
variable {α : Type*} [LinearOrder α] {E : Type*} [PseudoEMetricSpace E]
variable (f : ℝ → E) (s : Set ℝ) (l : ℝ≥0)
/-- `f` has constant speed `l` on `s` if the variation of `f` on `s ∩ Icc x y` is equal to
`l * (y - x)` for any `x y` in `s`.
-/
def HasConstantSpeedOnWith :=
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x))
variable {f s l}
theorem HasConstantSpeedOnWith.hasLocallyBoundedVariationOn (h : HasConstantSpeedOnWith f s l) :
LocallyBoundedVariationOn f s := fun x y hx hy => by
simp only [BoundedVariationOn, h hx hy, Ne, ENNReal.ofReal_ne_top, not_false_iff]
theorem hasConstantSpeedOnWith_of_subsingleton (f : ℝ → E) {s : Set ℝ} (hs : s.Subsingleton)
(l : ℝ≥0) : HasConstantSpeedOnWith f s l := by
rintro x hx y hy; cases hs hx hy
rw [eVariationOn.subsingleton f (fun y hy z hz => hs hy.1 hz.1 : (s ∩ Icc x x).Subsingleton)]
simp only [sub_self, mul_zero, ENNReal.ofReal_zero]
theorem hasConstantSpeedOnWith_iff_ordered :
HasConstantSpeedOnWith f s l ↔ ∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s),
x ≤ y → eVariationOn f (s ∩ Icc x y) = ENNReal.ofReal (l * (y - x)) := by
refine ⟨fun h x xs y ys _ => h xs ys, fun h x xs y ys => ?_⟩
rcases le_total x y with (xy | yx)
· exact h xs ys xy
· rw [eVariationOn.subsingleton, ENNReal.ofReal_of_nonpos]
· exact mul_nonpos_of_nonneg_of_nonpos l.prop (sub_nonpos_of_le yx)
· rintro z ⟨zs, xz, zy⟩ w ⟨ws, xw, wy⟩
cases le_antisymm (zy.trans yx) xz
cases le_antisymm (wy.trans yx) xw
rfl
theorem hasConstantSpeedOnWith_iff_variationOnFromTo_eq :
HasConstantSpeedOnWith f s l ↔ LocallyBoundedVariationOn f s ∧
∀ ⦃x⦄ (_ : x ∈ s) ⦃y⦄ (_ : y ∈ s), variationOnFromTo f s x y = l * (y - x) := by
constructor
· rintro h; refine ⟨h.hasLocallyBoundedVariationOn, fun x xs y ys => ?_⟩
rw [hasConstantSpeedOnWith_iff_ordered] at h
rcases le_total x y with (xy | yx)
· rw [variationOnFromTo.eq_of_le f s xy, h xs ys xy]
exact ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr xy))
· rw [variationOnFromTo.eq_of_ge f s yx, h ys xs yx]
have := ENNReal.toReal_ofReal (mul_nonneg l.prop (sub_nonneg.mpr yx))
simp_all only [NNReal.val_eq_coe]; ring
· rw [hasConstantSpeedOnWith_iff_ordered]
rintro h x xs y ys xy
rw [← h.2 xs ys, variationOnFromTo.eq_of_le f s xy, ENNReal.ofReal_toReal (h.1 x y xs ys)]
theorem HasConstantSpeedOnWith.union {t : Set ℝ} (hfs : HasConstantSpeedOnWith f s l)
(hft : HasConstantSpeedOnWith f t l) {x : ℝ} (hs : IsGreatest s x) (ht : IsLeast t x) :
HasConstantSpeedOnWith f (s ∪ t) l := by
rw [hasConstantSpeedOnWith_iff_ordered] at hfs hft ⊢
rintro z (zs | zt) y (ys | yt) zy
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨ws, zw, wy⟩
· exact ⟨(le_antisymm (wy.trans (hs.2 ys)) (ht.2 wt)).symm ▸ hs.1, zw, wy⟩
· rintro ⟨ws, zwy⟩; exact ⟨Or.inl ws, zwy⟩
rw [this, hfs zs ys zy]
· have : (s ∪ t) ∩ Icc z y = s ∩ Icc z x ∪ t ∩ Icc x y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
exacts [Or.inl ⟨ws, zw, hs.2 ws⟩, Or.inr ⟨wt, ht.2 wt, wy⟩]
· rintro (⟨ws, zw, wx⟩ | ⟨wt, xw, wy⟩)
exacts [⟨Or.inl ws, zw, wx.trans (ht.2 yt)⟩, ⟨Or.inr wt, (hs.2 zs).trans xw, wy⟩]
rw [this, @eVariationOn.union _ _ _ _ f _ _ x, hfs zs hs.1 (hs.2 zs), hft ht.1 yt (ht.2 yt)]
· have q := ENNReal.ofReal_add (mul_nonneg l.prop (sub_nonneg.mpr (hs.2 zs)))
(mul_nonneg l.prop (sub_nonneg.mpr (ht.2 yt)))
simp only [NNReal.val_eq_coe] at q
rw [← q]
ring_nf
exacts [⟨⟨hs.1, hs.2 zs, le_rfl⟩, fun w ⟨_, _, wx⟩ => wx⟩,
⟨⟨ht.1, le_rfl, ht.2 yt⟩, fun w ⟨_, xw, _⟩ => xw⟩]
· cases le_antisymm zy ((hs.2 ys).trans (ht.2 zt))
simp only [Icc_self, sub_self, mul_zero, ENNReal.ofReal_zero]
exact eVariationOn.subsingleton _ fun _ ⟨_, uz⟩ _ ⟨_, vz⟩ => uz.trans vz.symm
· have : (s ∪ t) ∩ Icc z y = t ∩ Icc z y := by
ext w; constructor
· rintro ⟨ws | wt, zw, wy⟩
· exact ⟨le_antisymm ((ht.2 zt).trans zw) (hs.2 ws) ▸ ht.1, zw, wy⟩
· exact ⟨wt, zw, wy⟩
· rintro ⟨wt, zwy⟩; exact ⟨Or.inr wt, zwy⟩
rw [this, hft zt yt zy]
theorem HasConstantSpeedOnWith.Icc_Icc {x y z : ℝ} (hfs : HasConstantSpeedOnWith f (Icc x y) l)
(hft : HasConstantSpeedOnWith f (Icc y z) l) : HasConstantSpeedOnWith f (Icc x z) l := by
rcases le_total x y with (xy | yx)
· rcases le_total y z with (yz | zy)
· rw [← Set.Icc_union_Icc_eq_Icc xy yz]
exact hfs.union hft (isGreatest_Icc xy) (isLeast_Icc yz)
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hfs ⟨xu, uz.trans zy⟩ ⟨xv, vz.trans zy⟩, Icc_inter_Icc, sup_of_le_right xu,
inf_of_le_right (vz.trans zy)]
· rintro u ⟨xu, uz⟩ v ⟨xv, vz⟩
rw [Icc_inter_Icc, sup_of_le_right xu, inf_of_le_right vz, ←
hft ⟨yx.trans xu, uz⟩ ⟨yx.trans xv, vz⟩, Icc_inter_Icc, sup_of_le_right (yx.trans xu),
inf_of_le_right vz]
theorem hasConstantSpeedOnWith_zero_iff :
HasConstantSpeedOnWith f s 0 ↔ ∀ᵉ (x ∈ s) (y ∈ s), edist (f x) (f y) = 0 := by
dsimp [HasConstantSpeedOnWith]
simp only [zero_mul, ENNReal.ofReal_zero, ← eVariationOn.eq_zero_iff]
constructor
· by_contra!
obtain ⟨h, hfs⟩ := this
simp_rw [ne_eq, eVariationOn.eq_zero_iff] at hfs h
push_neg at hfs
obtain ⟨x, xs, y, ys, hxy⟩ := hfs
rcases le_total x y with (xy | yx)
· exact hxy (h xs ys x ⟨xs, le_rfl, xy⟩ y ⟨ys, xy, le_rfl⟩)
· rw [edist_comm] at hxy
exact hxy (h ys xs y ⟨ys, le_rfl, yx⟩ x ⟨xs, yx, le_rfl⟩)
· rintro h x _ y _
refine le_antisymm ?_ zero_le'
rw [← h]
exact eVariationOn.mono f inter_subset_left
theorem HasConstantSpeedOnWith.ratio {l' : ℝ≥0} (hl' : l' ≠ 0) {φ : ℝ → ℝ} (φm : MonotoneOn φ s)
(hfφ : HasConstantSpeedOnWith (f ∘ φ) s l) (hf : HasConstantSpeedOnWith f (φ '' s) l') ⦃x : ℝ⦄
(xs : x ∈ s) : EqOn φ (fun y => l / l' * (y - x) + φ x) s := by
rintro y ys
rw [← sub_eq_iff_eq_add, mul_comm, ← mul_div_assoc, eq_div_iff (NNReal.coe_ne_zero.mpr hl')]
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hf
rw [hasConstantSpeedOnWith_iff_variationOnFromTo_eq] at hfφ
symm
calc
(y - x) * l = l * (y - x) := by rw [mul_comm]
_ = variationOnFromTo (f ∘ φ) s x y := (hfφ.2 xs ys).symm
_ = variationOnFromTo f (φ '' s) (φ x) (φ y) :=
(variationOnFromTo.comp_eq_of_monotoneOn f φ φm xs ys)
_ = l' * (φ y - φ x) := (hf.2 ⟨x, xs, rfl⟩ ⟨y, ys, rfl⟩)
_ = (φ y - φ x) * l' := by rw [mul_comm]
/-- `f` has unit speed on `s` if it is linearly parameterized by `l = 1` on `s`. -/
def HasUnitSpeedOn (f : ℝ → E) (s : Set ℝ) :=
HasConstantSpeedOnWith f s 1
theorem HasUnitSpeedOn.union {t : Set ℝ} {x : ℝ} (hfs : HasUnitSpeedOn f s)
(hft : HasUnitSpeedOn f t) (hs : IsGreatest s x) (ht : IsLeast t x) :
HasUnitSpeedOn f (s ∪ t) :=
HasConstantSpeedOnWith.union hfs hft hs ht
theorem HasUnitSpeedOn.Icc_Icc {x y z : ℝ} (hfs : HasUnitSpeedOn f (Icc x y))
(hft : HasUnitSpeedOn f (Icc y z)) : HasUnitSpeedOn f (Icc x z) :=
HasConstantSpeedOnWith.Icc_Icc hfs hft
/-- If both `f` and `f ∘ φ` have unit speed (on `t` and `s` respectively) and `φ`
monotonically maps `s` onto `t`, then `φ` is just a translation (on `s`).
-/
theorem unique_unit_speed {φ : ℝ → ℝ} (φm : MonotoneOn φ s) (hfφ : HasUnitSpeedOn (f ∘ φ) s)
(hf : HasUnitSpeedOn f (φ '' s)) ⦃x : ℝ⦄ (xs : x ∈ s) : EqOn φ (fun y => y - x + φ x) s := by
dsimp only [HasUnitSpeedOn] at hf hfφ
convert HasConstantSpeedOnWith.ratio one_ne_zero φm hfφ hf xs using 3
norm_num
/-- If both `f` and `f ∘ φ` have unit speed (on `Icc 0 t` and `Icc 0 s` respectively)
and `φ` monotonically maps `Icc 0 s` onto `Icc 0 t`, then `φ` is the identity on `Icc 0 s`
-/
theorem unique_unit_speed_on_Icc_zero {s t : ℝ} (hs : 0 ≤ s) (ht : 0 ≤ t) {φ : ℝ → ℝ}
(φm : MonotoneOn φ <| Icc 0 s) (φst : φ '' Icc 0 s = Icc 0 t)
(hfφ : HasUnitSpeedOn (f ∘ φ) (Icc 0 s)) (hf : HasUnitSpeedOn f (Icc 0 t)) :
EqOn φ id (Icc 0 s) := by
rw [← φst] at hf
convert unique_unit_speed φm hfφ hf ⟨le_rfl, hs⟩ using 1
have : φ 0 = 0 := by
have hm : 0 ∈ φ '' Icc 0 s := by simp only [φst, ht, mem_Icc, le_refl, and_self]
obtain ⟨x, xs, hx⟩ := hm
apply le_antisymm ((φm ⟨le_rfl, hs⟩ xs xs.1).trans_eq hx) _
have := φst ▸ mapsTo_image φ (Icc 0 s)
exact (mem_Icc.mp (@this 0 (by rw [mem_Icc]; exact ⟨le_rfl, hs⟩))).1
simp only [tsub_zero, this, add_zero]
rfl
/-- The natural parameterization of `f` on `s`, which, if `f` has locally bounded variation on `s`,
* has unit speed on `s` (by `has_unit_speed_naturalParameterization`).
* composed with `variationOnFromTo f s a`, is at distance zero from `f`
(by `edist_naturalParameterization_eq_zero`).
-/
noncomputable def naturalParameterization (f : α → E) (s : Set α) (a : α) : ℝ → E :=
f ∘ @Function.invFunOn _ _ ⟨a⟩ (variationOnFromTo f s a) s
theorem edist_naturalParameterization_eq_zero {f : α → E} {s : Set α}
(hf : LocallyBoundedVariationOn f s) {a : α} (as : a ∈ s) {b : α} (bs : b ∈ s) :
edist (naturalParameterization f s a (variationOnFromTo f s a b)) (f b) = 0 := by
dsimp only [naturalParameterization]
haveI : Nonempty α := ⟨a⟩
obtain ⟨cs, hc⟩ :=
@Function.invFunOn_pos _ _ _ s (variationOnFromTo f s a) (variationOnFromTo f s a b)
⟨b, bs, rfl⟩
rw [variationOnFromTo.eq_left_iff hf as cs bs] at hc
apply variationOnFromTo.edist_zero_of_eq_zero hf cs bs hc
theorem has_unit_speed_naturalParameterization (f : α → E) {s : Set α}
(hf : LocallyBoundedVariationOn f s) {a : α} (as : a ∈ s) :
HasUnitSpeedOn (naturalParameterization f s a) (variationOnFromTo f s a '' s) := by
dsimp only [HasUnitSpeedOn]
rw [hasConstantSpeedOnWith_iff_ordered]
rintro _ ⟨b, bs, rfl⟩ _ ⟨c, cs, rfl⟩ h
rcases le_total c b with (cb | bc)
· rw [NNReal.coe_one, one_mul, le_antisymm h (variationOnFromTo.monotoneOn hf as cs bs cb),
sub_self, ENNReal.ofReal_zero, Icc_self, eVariationOn.subsingleton]
exact fun x hx y hy => hx.2.trans hy.2.symm
· rw [NNReal.coe_one, one_mul, sub_eq_add_neg, variationOnFromTo.eq_neg_swap, neg_neg, add_comm,
variationOnFromTo.add hf bs as cs, ← variationOnFromTo.eq_neg_swap f]
rw [←
eVariationOn.comp_inter_Icc_eq_of_monotoneOn (naturalParameterization f s a) _
(variationOnFromTo.monotoneOn hf as) bs cs]
rw [@eVariationOn.eq_of_edist_zero_on _ _ _ _ _ f]
· rw [variationOnFromTo.eq_of_le _ _ bc, ENNReal.ofReal_toReal (hf b c bs cs)]
· rintro x ⟨xs, _, _⟩
exact edist_naturalParameterization_eq_zero hf as xs
|
Analysis\Convolution.lean | /-
Copyright (c) 2022 Floris van Doorn. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Floris van Doorn
-/
import Mathlib.Analysis.Calculus.ContDiff.Basic
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Constructions.Prod.Integral
import Mathlib.MeasureTheory.Function.LocallyIntegrable
import Mathlib.MeasureTheory.Group.Integral
import Mathlib.MeasureTheory.Group.Prod
import Mathlib.MeasureTheory.Integral.IntervalIntegral
/-!
# Convolution of functions
This file defines the convolution on two functions, i.e. `x ↦ ∫ f(t)g(x - t) ∂t`.
In the general case, these functions can be vector-valued, and have an arbitrary (additive)
group as domain. We use a continuous bilinear operation `L` on these function values as
"multiplication". The domain must be equipped with a Haar measure `μ`
(though many individual results have weaker conditions on `μ`).
For many applications we can take `L = ContinuousLinearMap.lsmul ℝ ℝ` or
`L = ContinuousLinearMap.mul ℝ ℝ`.
We also define `ConvolutionExists` and `ConvolutionExistsAt` to state that the convolution is
well-defined (everywhere or at a single point). These conditions are needed for pointwise
computations (e.g. `ConvolutionExistsAt.distrib_add`), but are generally not strong enough for any
local (or global) properties of the convolution. For this we need stronger assumptions on `f`
and/or `g`, and generally if we impose stronger conditions on one of the functions, we can impose
weaker conditions on the other.
We have proven many of the properties of the convolution assuming one of these functions
has compact support (in which case the other function only needs to be locally integrable).
We still need to prove the properties for other pairs of conditions (e.g. both functions are
rapidly decreasing)
# Design Decisions
We use a bilinear map `L` to "multiply" the two functions in the integrand.
This generality has several advantages
* This allows us to compute the total derivative of the convolution, in case the functions are
multivariate. The total derivative is again a convolution, but where the codomains of the
functions can be higher-dimensional. See `HasCompactSupport.hasFDerivAt_convolution_right`.
* This allows us to use `@[to_additive]` everywhere (which would not be possible if we would use
`mul`/`smul` in the integral, since `@[to_additive]` will incorrectly also try to additivize
those definitions).
* We need to support the case where at least one of the functions is vector-valued, but if we use
`smul` to multiply the functions, that would be an asymmetric definition.
# Main Definitions
* `MeasureTheory.convolution f g L μ x = (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ`
is the convolution of `f` and `g` w.r.t. the continuous bilinear map `L` and measure `μ`.
* `MeasureTheory.ConvolutionExistsAt f g x L μ` states that the convolution `(f ⋆[L, μ] g) x`
is well-defined (i.e. the integral exists).
* `MeasureTheory.ConvolutionExists f g L μ` states that the convolution `f ⋆[L, μ] g`
is well-defined at each point.
# Main Results
* `HasCompactSupport.hasFDerivAt_convolution_right` and
`HasCompactSupport.hasFDerivAt_convolution_left`: we can compute the total derivative
of the convolution as a convolution with the total derivative of the right (left) function.
* `HasCompactSupport.contDiff_convolution_right` and
`HasCompactSupport.contDiff_convolution_left`: the convolution is `𝒞ⁿ` if one of the functions
is `𝒞ⁿ` with compact support and the other function in locally integrable.
Versions of these statements for functions depending on a parameter are also given.
* `MeasureTheory.convolution_tendsto_right`: Given a sequence of nonnegative normalized functions
whose support tends to a small neighborhood around `0`, the convolution tends to the right
argument. This is specialized to bump functions in `ContDiffBump.convolution_tendsto_right`.
# Notation
The following notations are localized in the locale `Convolution`:
* `f ⋆[L, μ] g` for the convolution. Note: you have to use parentheses to apply the convolution
to an argument: `(f ⋆[L, μ] g) x`.
* `f ⋆[L] g := f ⋆[L, volume] g`
* `f ⋆ g := f ⋆[lsmul ℝ ℝ] g`
# To do
* Existence and (uniform) continuity of the convolution if
one of the maps is in `ℒ^p` and the other in `ℒ^q` with `1 / p + 1 / q = 1`.
This might require a generalization of `MeasureTheory.Memℒp.smul` where `smul` is generalized
to a continuous bilinear map.
(see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255K)
* The convolution is an `AEStronglyMeasurable` function
(see e.g. [Fremlin, *Measure Theory* (volume 2)][fremlin_vol2], 255I).
* Prove properties about the convolution if both functions are rapidly decreasing.
* Use `@[to_additive]` everywhere (this likely requires changes in `to_additive`)
-/
open Set Function Filter MeasureTheory MeasureTheory.Measure TopologicalSpace
open ContinuousLinearMap Metric Bornology
open scoped Pointwise Topology NNReal Filter
universe u𝕜 uG uE uE' uE'' uF uF' uF'' uP
variable {𝕜 : Type u𝕜} {G : Type uG} {E : Type uE} {E' : Type uE'} {E'' : Type uE''} {F : Type uF}
{F' : Type uF'} {F'' : Type uF''} {P : Type uP}
variable [NormedAddCommGroup E] [NormedAddCommGroup E'] [NormedAddCommGroup E'']
[NormedAddCommGroup F] {f f' : G → E} {g g' : G → E'} {x x' : G} {y y' : E}
namespace MeasureTheory
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜]
variable [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace 𝕜 F]
variable (L : E →L[𝕜] E' →L[𝕜] F)
section NoMeasurability
variable [AddGroup G] [TopologicalSpace G]
theorem convolution_integrand_bound_right_of_le_of_subset {C : ℝ} (hC : ∀ i, ‖g i‖ ≤ C) {x t : G}
{s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) :
‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * C) t := by
-- Porting note: had to add `f := _`
refine le_indicator (f := fun t ↦ ‖L (f t) (g (x - t))‖) (fun t _ => ?_) (fun t ht => ?_) t
· apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl]
· have : x - t ∉ support g := by
refine mt (fun hxt => hu ?_) ht
refine ⟨_, Set.neg_mem_neg.mpr (subset_closure hxt), _, hx, ?_⟩
simp only [neg_sub, sub_add_cancel]
simp only [nmem_support.mp this, (L _).map_zero, norm_zero, le_rfl]
theorem _root_.HasCompactSupport.convolution_integrand_bound_right_of_subset
(hcg : HasCompactSupport g) (hg : Continuous g)
{x t : G} {s u : Set G} (hx : x ∈ s) (hu : -tsupport g + s ⊆ u) :
‖L (f t) (g (x - t))‖ ≤ u.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t := by
refine convolution_integrand_bound_right_of_le_of_subset _ (fun i => ?_) hx hu
exact le_ciSup (hg.norm.bddAbove_range_of_hasCompactSupport hcg.norm) _
theorem _root_.HasCompactSupport.convolution_integrand_bound_right (hcg : HasCompactSupport g)
(hg : Continuous g) {x t : G} {s : Set G} (hx : x ∈ s) :
‖L (f t) (g (x - t))‖ ≤ (-tsupport g + s).indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖) t :=
hcg.convolution_integrand_bound_right_of_subset L hg hx Subset.rfl
theorem _root_.Continuous.convolution_integrand_fst [ContinuousSub G] (hg : Continuous g) (t : G) :
Continuous fun x => L (f t) (g (x - t)) :=
L.continuous₂.comp₂ continuous_const <| hg.comp <| continuous_id.sub continuous_const
theorem _root_.HasCompactSupport.convolution_integrand_bound_left (hcf : HasCompactSupport f)
(hf : Continuous f) {x t : G} {s : Set G} (hx : x ∈ s) :
‖L (f (x - t)) (g t)‖ ≤
(-tsupport f + s).indicator (fun t => (‖L‖ * ⨆ i, ‖f i‖) * ‖g t‖) t := by
convert hcf.convolution_integrand_bound_right L.flip hf hx using 1
simp_rw [L.opNorm_flip, mul_right_comm]
end NoMeasurability
section Measurability
variable [MeasurableSpace G] {μ ν : Measure G}
/-- The convolution of `f` and `g` exists at `x` when the function `t ↦ L (f t) (g (x - t))` is
integrable. There are various conditions on `f` and `g` to prove this. -/
def ConvolutionExistsAt [Sub G] (f : G → E) (g : G → E') (x : G) (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
Integrable (fun t => L (f t) (g (x - t))) μ
/-- The convolution of `f` and `g` exists when the function `t ↦ L (f t) (g (x - t))` is integrable
for all `x : G`. There are various conditions on `f` and `g` to prove this. -/
def ConvolutionExists [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : Prop :=
∀ x : G, ConvolutionExistsAt f g x L μ
section ConvolutionExists
variable {L} in
theorem ConvolutionExistsAt.integrable [Sub G] {x : G} (h : ConvolutionExistsAt f g x L μ) :
Integrable (fun t => L (f t) (g (x - t))) μ :=
h
section Group
variable [AddGroup G]
theorem AEStronglyMeasurable.convolution_integrand' [MeasurableAdd₂ G]
[MeasurableNeg G] [SFinite ν] (hf : AEStronglyMeasurable f ν)
(hg : AEStronglyMeasurable g <| map (fun p : G × G => p.1 - p.2) (μ.prod ν)) :
AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
L.aestronglyMeasurable_comp₂ hf.snd <| hg.comp_measurable measurable_sub
section
variable [MeasurableAdd G] [MeasurableNeg G]
theorem AEStronglyMeasurable.convolution_integrand_snd'
(hf : AEStronglyMeasurable f μ) {x : G}
(hg : AEStronglyMeasurable g <| map (fun t => x - t) μ) :
AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
L.aestronglyMeasurable_comp₂ hf <| hg.comp_measurable <| measurable_id.const_sub x
theorem AEStronglyMeasurable.convolution_integrand_swap_snd' {x : G}
(hf : AEStronglyMeasurable f <| map (fun t => x - t) μ) (hg : AEStronglyMeasurable g μ) :
AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ :=
L.aestronglyMeasurable_comp₂ (hf.comp_measurable <| measurable_id.const_sub x) hg
/-- A sufficient condition to prove that `f ⋆[L, μ] g` exists.
We assume that `f` is integrable on a set `s` and `g` is bounded and ae strongly measurable
on `x₀ - s` (note that both properties hold if `g` is continuous with compact support). -/
theorem _root_.BddAbove.convolutionExistsAt' {x₀ : G} {s : Set G}
(hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => -t + x₀) ⁻¹' s))) (hs : MeasurableSet s)
(h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ)
(hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) (μ.restrict s)) :
ConvolutionExistsAt f g x₀ L μ := by
rw [ConvolutionExistsAt]
rw [← integrableOn_iff_integrable_of_support_subset h2s]
set s' := (fun t => -t + x₀) ⁻¹' s
have : ∀ᵐ t : G ∂μ.restrict s,
‖L (f t) (g (x₀ - t))‖ ≤ s.indicator (fun t => ‖L‖ * ‖f t‖ * ⨆ i : s', ‖g i‖) t := by
filter_upwards
refine le_indicator (fun t ht => ?_) fun t ht => ?_
· apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl]
refine (le_ciSup_set hbg <| mem_preimage.mpr ?_)
rwa [neg_sub, sub_add_cancel]
· have : t ∉ support fun t => L (f t) (g (x₀ - t)) := mt (fun h => h2s h) ht
rw [nmem_support.mp this, norm_zero]
refine Integrable.mono' ?_ ?_ this
· rw [integrable_indicator_iff hs]; exact ((hf.norm.const_mul _).mul_const _).integrableOn
· exact hf.aestronglyMeasurable.convolution_integrand_snd' L hmg
/-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/
theorem ConvolutionExistsAt.ofNorm' {x₀ : G}
(h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ)
(hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g <| map (fun t => x₀ - t) μ) :
ConvolutionExistsAt f g x₀ L μ := by
refine (h.const_mul ‖L‖).mono'
(hmf.convolution_integrand_snd' L hmg) (eventually_of_forall fun x => ?_)
rw [mul_apply', ← mul_assoc]
apply L.le_opNorm₂
end
section Left
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ]
theorem AEStronglyMeasurable.convolution_integrand_snd (hf : AEStronglyMeasurable f μ)
(hg : AEStronglyMeasurable g μ) (x : G) :
AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
hf.convolution_integrand_snd' L <|
hg.mono_ac <| (quasiMeasurePreserving_sub_left_of_right_invariant μ x).absolutelyContinuous
theorem AEStronglyMeasurable.convolution_integrand_swap_snd
(hf : AEStronglyMeasurable f μ) (hg : AEStronglyMeasurable g μ) (x : G) :
AEStronglyMeasurable (fun t => L (f (x - t)) (g t)) μ :=
(hf.mono_ac
(quasiMeasurePreserving_sub_left_of_right_invariant μ
x).absolutelyContinuous).convolution_integrand_swap_snd'
L hg
/-- If `‖f‖ *[μ] ‖g‖` exists, then `f *[L, μ] g` exists. -/
theorem ConvolutionExistsAt.ofNorm {x₀ : G}
(h : ConvolutionExistsAt (fun x => ‖f x‖) (fun x => ‖g x‖) x₀ (mul ℝ ℝ) μ)
(hmf : AEStronglyMeasurable f μ) (hmg : AEStronglyMeasurable g μ) :
ConvolutionExistsAt f g x₀ L μ :=
h.ofNorm' L hmf <|
hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous
end Left
section Right
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ] [SFinite ν]
theorem AEStronglyMeasurable.convolution_integrand (hf : AEStronglyMeasurable f ν)
(hg : AEStronglyMeasurable g μ) :
AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
hf.convolution_integrand' L <|
hg.mono_ac (quasiMeasurePreserving_sub_of_right_invariant μ ν).absolutelyContinuous
theorem Integrable.convolution_integrand (hf : Integrable f ν) (hg : Integrable g μ) :
Integrable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) := by
have h_meas : AEStronglyMeasurable (fun p : G × G => L (f p.2) (g (p.1 - p.2))) (μ.prod ν) :=
hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable
have h2_meas : AEStronglyMeasurable (fun y : G => ∫ x : G, ‖L (f y) (g (x - y))‖ ∂μ) ν :=
h_meas.prod_swap.norm.integral_prod_right'
simp_rw [integrable_prod_iff' h_meas]
refine ⟨eventually_of_forall fun t => (L (f t)).integrable_comp (hg.comp_sub_right t), ?_⟩
refine Integrable.mono' ?_ h2_meas
(eventually_of_forall fun t => (?_ : _ ≤ ‖L‖ * ‖f t‖ * ∫ x, ‖g (x - t)‖ ∂μ))
· simp only [integral_sub_right_eq_self (‖g ·‖)]
exact (hf.norm.const_mul _).mul_const _
· simp_rw [← integral_mul_left]
rw [Real.norm_of_nonneg (by positivity)]
exact integral_mono_of_nonneg (eventually_of_forall fun t => norm_nonneg _)
((hg.comp_sub_right t).norm.const_mul _) (eventually_of_forall fun t => L.le_opNorm₂ _ _)
theorem Integrable.ae_convolution_exists (hf : Integrable f ν) (hg : Integrable g μ) :
∀ᵐ x ∂μ, ConvolutionExistsAt f g x L ν :=
((integrable_prod_iff <|
hf.aestronglyMeasurable.convolution_integrand L hg.aestronglyMeasurable).mp <|
hf.convolution_integrand L hg).1
end Right
variable [TopologicalSpace G] [TopologicalAddGroup G] [BorelSpace G]
theorem _root_.HasCompactSupport.convolutionExistsAt {x₀ : G}
(h : HasCompactSupport fun t => L (f t) (g (x₀ - t))) (hf : LocallyIntegrable f μ)
(hg : Continuous g) : ConvolutionExistsAt f g x₀ L μ := by
let u := (Homeomorph.neg G).trans (Homeomorph.addRight x₀)
let v := (Homeomorph.neg G).trans (Homeomorph.addLeft x₀)
apply ((u.isCompact_preimage.mpr h).bddAbove_image hg.norm.continuousOn).convolutionExistsAt' L
isClosed_closure.measurableSet subset_closure (hf.integrableOn_isCompact h)
have A : AEStronglyMeasurable (g ∘ v)
(μ.restrict (tsupport fun t : G => L (f t) (g (x₀ - t)))) := by
apply (hg.comp v.continuous).continuousOn.aestronglyMeasurable_of_isCompact h
exact (isClosed_tsupport _).measurableSet
convert ((v.continuous.measurable.measurePreserving
(μ.restrict (tsupport fun t => L (f t) (g (x₀ - t))))).aestronglyMeasurable_comp_iff
v.measurableEmbedding).1 A
ext x
simp only [v, Homeomorph.neg, sub_eq_add_neg, val_toAddUnits_apply, Homeomorph.trans_apply,
Equiv.neg_apply, Equiv.toFun_as_coe, Homeomorph.homeomorph_mk_coe, Equiv.coe_fn_mk,
Homeomorph.coe_addLeft]
theorem _root_.HasCompactSupport.convolutionExists_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : Continuous g) : ConvolutionExists f g L μ := by
intro x₀
refine HasCompactSupport.convolutionExistsAt L ?_ hf hg
refine (hcg.comp_homeomorph (Homeomorph.subLeft x₀)).mono ?_
refine fun t => mt fun ht : g (x₀ - t) = 0 => ?_
simp_rw [ht, (L _).map_zero]
theorem _root_.HasCompactSupport.convolutionExists_left_of_continuous_right
(hcf : HasCompactSupport f) (hf : LocallyIntegrable f μ) (hg : Continuous g) :
ConvolutionExists f g L μ := by
intro x₀
refine HasCompactSupport.convolutionExistsAt L ?_ hf hg
refine hcf.mono ?_
refine fun t => mt fun ht : f t = 0 => ?_
simp_rw [ht, L.map_zero₂]
end Group
section CommGroup
variable [AddCommGroup G]
section MeasurableGroup
variable [MeasurableNeg G] [IsAddLeftInvariant μ]
/-- A sufficient condition to prove that `f ⋆[L, μ] g` exists.
We assume that the integrand has compact support and `g` is bounded on this support (note that
both properties hold if `g` is continuous with compact support). We also require that `f` is
integrable on the support of the integrand, and that both functions are strongly measurable.
This is a variant of `BddAbove.convolutionExistsAt'` in an abelian group with a left-invariant
measure. This allows us to state the boundedness and measurability of `g` in a more natural way. -/
theorem _root_.BddAbove.convolutionExistsAt [MeasurableAdd₂ G] [SFinite μ] {x₀ : G} {s : Set G}
(hbg : BddAbove ((fun i => ‖g i‖) '' ((fun t => x₀ - t) ⁻¹' s))) (hs : MeasurableSet s)
(h2s : (support fun t => L (f t) (g (x₀ - t))) ⊆ s) (hf : IntegrableOn f s μ)
(hmg : AEStronglyMeasurable g μ) : ConvolutionExistsAt f g x₀ L μ := by
refine BddAbove.convolutionExistsAt' L ?_ hs h2s hf ?_
· simp_rw [← sub_eq_neg_add, hbg]
· have : AEStronglyMeasurable g (map (fun t : G => x₀ - t) μ) :=
hmg.mono_ac (quasiMeasurePreserving_sub_left_of_right_invariant μ x₀).absolutelyContinuous
apply this.mono_measure
exact map_mono restrict_le_self (measurable_const.sub measurable_id')
variable {L} [MeasurableAdd G] [IsNegInvariant μ]
theorem convolutionExistsAt_flip :
ConvolutionExistsAt g f x L.flip μ ↔ ConvolutionExistsAt f g x L μ := by
simp_rw [ConvolutionExistsAt, ← integrable_comp_sub_left (fun t => L (f t) (g (x - t))) x,
sub_sub_cancel, flip_apply]
theorem ConvolutionExistsAt.integrable_swap (h : ConvolutionExistsAt f g x L μ) :
Integrable (fun t => L (f (x - t)) (g t)) μ := by
convert h.comp_sub_left x
simp_rw [sub_sub_self]
theorem convolutionExistsAt_iff_integrable_swap :
ConvolutionExistsAt f g x L μ ↔ Integrable (fun t => L (f (x - t)) (g t)) μ :=
convolutionExistsAt_flip.symm
end MeasurableGroup
variable [TopologicalSpace G] [TopologicalAddGroup G] [BorelSpace G]
variable [IsAddLeftInvariant μ] [IsNegInvariant μ]
theorem _root_.HasCompactSupport.convolutionExistsLeft
(hcf : HasCompactSupport f) (hf : Continuous f)
(hg : LocallyIntegrable g μ) : ConvolutionExists f g L μ := fun x₀ =>
convolutionExistsAt_flip.mp <| hcf.convolutionExists_right L.flip hg hf x₀
theorem _root_.HasCompactSupport.convolutionExistsRightOfContinuousLeft (hcg : HasCompactSupport g)
(hf : Continuous f) (hg : LocallyIntegrable g μ) : ConvolutionExists f g L μ := fun x₀ =>
convolutionExistsAt_flip.mp <| hcg.convolutionExists_left_of_continuous_right L.flip hg hf x₀
end CommGroup
end ConvolutionExists
variable [NormedSpace ℝ F]
/-- The convolution of two functions `f` and `g` with respect to a continuous bilinear map `L` and
measure `μ`. It is defined to be `(f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ`. -/
noncomputable def convolution [Sub G] (f : G → E) (g : G → E') (L : E →L[𝕜] E' →L[𝕜] F)
(μ : Measure G := by volume_tac) : G → F := fun x =>
∫ t, L (f t) (g (x - t)) ∂μ
/-- The convolution of two functions with respect to a bilinear operation `L` and a measure `μ`. -/
scoped[Convolution] notation:67 f " ⋆[" L:67 ", " μ:67 "] " g:66 => convolution f g L μ
/-- The convolution of two functions with respect to a bilinear operation `L` and the volume. -/
scoped[Convolution]
notation:67 f " ⋆[" L:67 "]" g:66 => convolution f g L MeasureSpace.volume
/-- The convolution of two real-valued functions with respect to volume. -/
scoped[Convolution]
notation:67 f " ⋆ " g:66 =>
convolution f g (ContinuousLinearMap.lsmul ℝ ℝ) MeasureSpace.volume
open scoped Convolution
theorem convolution_def [Sub G] : (f ⋆[L, μ] g) x = ∫ t, L (f t) (g (x - t)) ∂μ :=
rfl
/-- The definition of convolution where the bilinear operator is scalar multiplication.
Note: it often helps the elaborator to give the type of the convolution explicitly. -/
theorem convolution_lsmul [Sub G] {f : G → 𝕜} {g : G → F} :
(f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f t • g (x - t) ∂μ :=
rfl
/-- The definition of convolution where the bilinear operator is multiplication. -/
theorem convolution_mul [Sub G] [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} :
(f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f t * g (x - t) ∂μ :=
rfl
section Group
variable {L} [AddGroup G]
theorem smul_convolution [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : y • f ⋆[L, μ] g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, L.map_smul₂]
theorem convolution_smul [SMulCommClass ℝ 𝕜 F] {y : 𝕜} : f ⋆[L, μ] y • g = y • (f ⋆[L, μ] g) := by
ext; simp only [Pi.smul_apply, convolution_def, ← integral_smul, (L _).map_smul]
@[simp]
theorem zero_convolution : 0 ⋆[L, μ] g = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, L.map_zero₂, integral_zero]
@[simp]
theorem convolution_zero : f ⋆[L, μ] 0 = 0 := by
ext
simp_rw [convolution_def, Pi.zero_apply, (L _).map_zero, integral_zero]
theorem ConvolutionExistsAt.distrib_add {x : G} (hfg : ConvolutionExistsAt f g x L μ)
(hfg' : ConvolutionExistsAt f g' x L μ) :
(f ⋆[L, μ] (g + g')) x = (f ⋆[L, μ] g) x + (f ⋆[L, μ] g') x := by
simp only [convolution_def, (L _).map_add, Pi.add_apply, integral_add hfg hfg']
theorem ConvolutionExists.distrib_add (hfg : ConvolutionExists f g L μ)
(hfg' : ConvolutionExists f g' L μ) : f ⋆[L, μ] (g + g') = f ⋆[L, μ] g + f ⋆[L, μ] g' := by
ext x
exact (hfg x).distrib_add (hfg' x)
theorem ConvolutionExistsAt.add_distrib {x : G} (hfg : ConvolutionExistsAt f g x L μ)
(hfg' : ConvolutionExistsAt f' g x L μ) :
((f + f') ⋆[L, μ] g) x = (f ⋆[L, μ] g) x + (f' ⋆[L, μ] g) x := by
simp only [convolution_def, L.map_add₂, Pi.add_apply, integral_add hfg hfg']
theorem ConvolutionExists.add_distrib (hfg : ConvolutionExists f g L μ)
(hfg' : ConvolutionExists f' g L μ) : (f + f') ⋆[L, μ] g = f ⋆[L, μ] g + f' ⋆[L, μ] g := by
ext x
exact (hfg x).add_distrib (hfg' x)
theorem convolution_mono_right {f g g' : G → ℝ} (hfg : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ)
(hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x) :
(f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by
apply integral_mono hfg hfg'
simp only [lsmul_apply, Algebra.id.smul_eq_mul]
intro t
apply mul_le_mul_of_nonneg_left (hg _) (hf _)
theorem convolution_mono_right_of_nonneg {f g g' : G → ℝ}
(hfg' : ConvolutionExistsAt f g' x (lsmul ℝ ℝ) μ) (hf : ∀ x, 0 ≤ f x) (hg : ∀ x, g x ≤ g' x)
(hg' : ∀ x, 0 ≤ g' x) : (f ⋆[lsmul ℝ ℝ, μ] g) x ≤ (f ⋆[lsmul ℝ ℝ, μ] g') x := by
by_cases H : ConvolutionExistsAt f g x (lsmul ℝ ℝ) μ
· exact convolution_mono_right H hfg' hf hg
have : (f ⋆[lsmul ℝ ℝ, μ] g) x = 0 := integral_undef H
rw [this]
exact integral_nonneg fun y => mul_nonneg (hf y) (hg' (x - y))
variable (L)
theorem convolution_congr [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ]
[IsAddRightInvariant μ] (h1 : f =ᵐ[μ] f') (h2 : g =ᵐ[μ] g') : f ⋆[L, μ] g = f' ⋆[L, μ] g' := by
ext x
apply integral_congr_ae
exact (h1.prod_mk <| h2.comp_tendsto
(quasiMeasurePreserving_sub_left_of_right_invariant μ x).tendsto_ae).fun_comp ↿fun x y ↦ L x y
theorem support_convolution_subset_swap : support (f ⋆[L, μ] g) ⊆ support g + support f := by
intro x h2x
by_contra hx
apply h2x
simp_rw [Set.mem_add, ← exists_and_left, not_exists, not_and_or, nmem_support] at hx
rw [convolution_def]
convert integral_zero G F using 2
ext t
rcases hx (x - t) t with (h | h | h)
· rw [h, (L _).map_zero]
· rw [h, L.map_zero₂]
· exact (h <| sub_add_cancel x t).elim
section
variable [MeasurableAdd₂ G] [MeasurableNeg G] [SFinite μ] [IsAddRightInvariant μ]
theorem Integrable.integrable_convolution (hf : Integrable f μ)
(hg : Integrable g μ) : Integrable (f ⋆[L, μ] g) μ :=
(hf.convolution_integrand L hg).integral_prod_left
end
variable [TopologicalSpace G]
variable [TopologicalAddGroup G]
protected theorem _root_.HasCompactSupport.convolution [T2Space G] (hcf : HasCompactSupport f)
(hcg : HasCompactSupport g) : HasCompactSupport (f ⋆[L, μ] g) :=
(hcg.isCompact.add hcf).of_isClosed_subset isClosed_closure <|
closure_minimal
((support_convolution_subset_swap L).trans <| add_subset_add subset_closure subset_closure)
(hcg.isCompact.add hcf).isClosed
variable [BorelSpace G] [TopologicalSpace P]
/-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and
compactly supported. Version where `g` depends on an additional parameter in a subset `s` of
a parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem continuousOn_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G}
(hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContinuousOn (↿g) (s ×ˢ univ)) :
ContinuousOn (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- First get rid of the case where the space is not locally compact. Then `g` vanishes everywhere
and the conclusion is trivial. -/
by_cases H : ∀ p ∈ s, ∀ x, g p x = 0
· apply (continuousOn_const (c := 0)).congr
rintro ⟨p, x⟩ ⟨hp, -⟩
apply integral_eq_zero_of_ae (eventually_of_forall (fun y ↦ ?_))
simp [H p hp _]
have : LocallyCompactSpace G := by
push_neg at H
rcases H with ⟨p, hp, x, hx⟩
have A : support (g p) ⊆ k := support_subset_iff'.2 (fun y hy ↦ hgs p y hp hy)
have B : Continuous (g p) := by
refine hg.comp_continuous (continuous_const.prod_mk continuous_id') fun x => ?_
simpa only [prod_mk_mem_set_prod_eq, mem_univ, and_true] using hp
rcases eq_zero_or_locallyCompactSpace_of_support_subset_isCompact_of_addGroup hk A B with H|H
· simp [H] at hx
· exact H
/- Since `G` is locally compact, one may thicken `k` a little bit into a larger compact set
`(-k) + t`, outside of which all functions that appear in the convolution vanish. Then we can
apply a continuity statement for integrals depending on a parameter, with respect to
locally integrable functions and compactly supported continuous functions. -/
rintro ⟨q₀, x₀⟩ ⟨hq₀, -⟩
obtain ⟨t, t_comp, ht⟩ : ∃ t, IsCompact t ∧ t ∈ 𝓝 x₀ := exists_compact_mem_nhds x₀
let k' : Set G := (-k) +ᵥ t
have k'_comp : IsCompact k' := IsCompact.vadd_set hk.neg t_comp
let g' : (P × G) → G → E' := fun p x ↦ g p.1 (p.2 - x)
let s' : Set (P × G) := s ×ˢ t
have A : ContinuousOn g'.uncurry (s' ×ˢ univ) := by
have : g'.uncurry = g.uncurry ∘ (fun w ↦ (w.1.1, w.1.2 - w.2)) := by ext y; rfl
rw [this]
refine hg.comp (continuous_fst.fst.prod_mk (continuous_fst.snd.sub
continuous_snd)).continuousOn ?_
simp (config := {contextual := true}) [s', MapsTo]
have B : ContinuousOn (fun a ↦ ∫ x, L (f x) (g' a x) ∂μ) s' := by
apply continuousOn_integral_bilinear_of_locally_integrable_of_compact_support L k'_comp A _
(hf.integrableOn_isCompact k'_comp)
rintro ⟨p, x⟩ y ⟨hp, hx⟩ hy
apply hgs p _ hp
contrapose! hy
exact ⟨y - x, by simpa using hy, x, hx, by simp⟩
apply ContinuousWithinAt.mono_of_mem (B (q₀, x₀) ⟨hq₀, mem_of_mem_nhds ht⟩)
exact mem_nhdsWithin_prod_iff.2 ⟨s, self_mem_nhdsWithin, t, nhdsWithin_le_nhds ht, Subset.rfl⟩
/-- The convolution `f * g` is continuous if `f` is locally integrable and `g` is continuous and
compactly supported. Version where `g` depends on an additional parameter in an open subset `s` of
a parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of compositions with an additional continuous map. -/
theorem continuousOn_convolution_right_with_param_comp {s : Set P} {v : P → G}
(hv : ContinuousOn v s) {g : P → G → E'} {k : Set G} (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContinuousOn (↿g) (s ×ˢ univ)) : ContinuousOn (fun x => (f ⋆[L, μ] g x) (v x)) s := by
apply
(continuousOn_convolution_right_with_param L hk hgs hf hg).comp (continuousOn_id.prod hv)
intro x hx
simp only [hx, prod_mk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
/-- The convolution is continuous if one function is locally integrable and the other has compact
support and is continuous. -/
theorem _root_.HasCompactSupport.continuous_convolution_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : Continuous g) : Continuous (f ⋆[L, μ] g) := by
rw [continuous_iff_continuousOn_univ]
let g' : G → G → E' := fun _ q => g q
have : ContinuousOn (↿g') (univ ×ˢ univ) := (hg.comp continuous_snd).continuousOn
exact continuousOn_convolution_right_with_param_comp L
(continuous_iff_continuousOn_univ.1 continuous_id) hcg
(fun p x _ hx => image_eq_zero_of_nmem_tsupport hx) hf this
/-- The convolution is continuous if one function is integrable and the other is bounded and
continuous. -/
theorem _root_.BddAbove.continuous_convolution_right_of_integrable
[FirstCountableTopology G] [SecondCountableTopologyEither G E']
(hbg : BddAbove (range fun x => ‖g x‖)) (hf : Integrable f μ) (hg : Continuous g) :
Continuous (f ⋆[L, μ] g) := by
refine continuous_iff_continuousAt.mpr fun x₀ => ?_
have : ∀ᶠ x in 𝓝 x₀, ∀ᵐ t : G ∂μ, ‖L (f t) (g (x - t))‖ ≤ ‖L‖ * ‖f t‖ * ⨆ i, ‖g i‖ := by
filter_upwards with x; filter_upwards with t
apply_rules [L.le_of_opNorm₂_le_of_le, le_rfl, le_ciSup hbg (x - t)]
refine continuousAt_of_dominated ?_ this ?_ ?_
· exact eventually_of_forall fun x =>
hf.aestronglyMeasurable.convolution_integrand_snd' L hg.aestronglyMeasurable
· exact (hf.norm.const_mul _).mul_const _
· exact eventually_of_forall fun t => (L.continuous₂.comp₂ continuous_const <|
hg.comp <| continuous_id.sub continuous_const).continuousAt
end Group
section CommGroup
variable [AddCommGroup G]
theorem support_convolution_subset : support (f ⋆[L, μ] g) ⊆ support f + support g :=
(support_convolution_subset_swap L).trans (add_comm _ _).subset
variable [IsAddLeftInvariant μ] [IsNegInvariant μ]
section Measurable
variable [MeasurableNeg G]
variable [MeasurableAdd G]
/-- Commutativity of convolution -/
theorem convolution_flip : g ⋆[L.flip, μ] f = f ⋆[L, μ] g := by
ext1 x
simp_rw [convolution_def]
rw [← integral_sub_left_eq_self _ μ x]
simp_rw [sub_sub_self, flip_apply]
/-- The symmetric definition of convolution. -/
theorem convolution_eq_swap : (f ⋆[L, μ] g) x = ∫ t, L (f (x - t)) (g t) ∂μ := by
rw [← convolution_flip]; rfl
/-- The symmetric definition of convolution where the bilinear operator is scalar multiplication. -/
theorem convolution_lsmul_swap {f : G → 𝕜} {g : G → F} :
(f ⋆[lsmul 𝕜 𝕜, μ] g : G → F) x = ∫ t, f (x - t) • g t ∂μ :=
convolution_eq_swap _
/-- The symmetric definition of convolution where the bilinear operator is multiplication. -/
theorem convolution_mul_swap [NormedSpace ℝ 𝕜] {f : G → 𝕜} {g : G → 𝕜} :
(f ⋆[mul 𝕜 𝕜, μ] g) x = ∫ t, f (x - t) * g t ∂μ :=
convolution_eq_swap _
/-- The convolution of two even functions is also even. -/
theorem convolution_neg_of_neg_eq (h1 : ∀ᵐ x ∂μ, f (-x) = f x) (h2 : ∀ᵐ x ∂μ, g (-x) = g x) :
(f ⋆[L, μ] g) (-x) = (f ⋆[L, μ] g) x :=
calc
∫ t : G, (L (f t)) (g (-x - t)) ∂μ = ∫ t : G, (L (f (-t))) (g (x + t)) ∂μ := by
apply integral_congr_ae
filter_upwards [h1, (eventually_add_left_iff μ x).2 h2] with t ht h't
simp_rw [ht, ← h't, neg_add']
_ = ∫ t : G, (L (f t)) (g (x - t)) ∂μ := by
rw [← integral_neg_eq_self]
simp only [neg_neg, ← sub_eq_add_neg]
end Measurable
variable [TopologicalSpace G]
variable [TopologicalAddGroup G]
variable [BorelSpace G]
theorem _root_.HasCompactSupport.continuous_convolution_left
(hcf : HasCompactSupport f) (hf : Continuous f) (hg : LocallyIntegrable g μ) :
Continuous (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hcf.continuous_convolution_right L.flip hg hf
theorem _root_.BddAbove.continuous_convolution_left_of_integrable
[FirstCountableTopology G] [SecondCountableTopologyEither G E]
(hbf : BddAbove (range fun x => ‖f x‖)) (hf : Continuous f) (hg : Integrable g μ) :
Continuous (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hbf.continuous_convolution_right_of_integrable L.flip hg hf
end CommGroup
section NormedAddCommGroup
variable [SeminormedAddCommGroup G]
/-- Compute `(f ⋆ g) x₀` if the support of the `f` is within `Metric.ball 0 R`, and `g` is constant
on `Metric.ball x₀ R`.
We can simplify the RHS further if we assume `f` is integrable, but also if `L = (•)` or more
generally if `L` has an `AntilipschitzWith`-condition. -/
theorem convolution_eq_right' {x₀ : G} {R : ℝ} (hf : support f ⊆ ball (0 : G) R)
(hg : ∀ x ∈ ball x₀ R, g x = g x₀) : (f ⋆[L, μ] g) x₀ = ∫ t, L (f t) (g x₀) ∂μ := by
have h2 : ∀ t, L (f t) (g (x₀ - t)) = L (f t) (g x₀) := fun t ↦ by
by_cases ht : t ∈ support f
· have h2t := hf ht
rw [mem_ball_zero_iff] at h2t
specialize hg (x₀ - t)
rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg
rw [hg h2t]
· rw [nmem_support] at ht
simp_rw [ht, L.map_zero₂]
simp_rw [convolution_def, h2]
variable [BorelSpace G] [SecondCountableTopology G]
variable [IsAddLeftInvariant μ] [SFinite μ]
/-- Approximate `(f ⋆ g) x₀` if the support of the `f` is bounded within a ball, and `g` is near
`g x₀` on a ball with the same radius around `x₀`. See `dist_convolution_le` for a special case.
We can simplify the second argument of `dist` further if we add some extra type-classes on `E`
and `𝕜` or if `L` is scalar multiplication. -/
theorem dist_convolution_le' {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε) (hif : Integrable f μ)
(hf : support f ⊆ ball (0 : G) R) (hmg : AEStronglyMeasurable g μ)
(hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) :
dist ((f ⋆[L, μ] g : G → F) x₀) (∫ t, L (f t) z₀ ∂μ) ≤ (‖L‖ * ∫ x, ‖f x‖ ∂μ) * ε := by
have hfg : ConvolutionExistsAt f g x₀ L μ := by
refine BddAbove.convolutionExistsAt L ?_ Metric.isOpen_ball.measurableSet (Subset.trans ?_ hf)
hif.integrableOn hmg
swap; · refine fun t => mt fun ht : f t = 0 => ?_; simp_rw [ht, L.map_zero₂]
rw [bddAbove_def]
refine ⟨‖z₀‖ + ε, ?_⟩
rintro _ ⟨x, hx, rfl⟩
refine norm_le_norm_add_const_of_dist_le (hg x ?_)
rwa [mem_ball_iff_norm, norm_sub_rev, ← mem_ball_zero_iff]
have h2 : ∀ t, dist (L (f t) (g (x₀ - t))) (L (f t) z₀) ≤ ‖L (f t)‖ * ε := by
intro t; by_cases ht : t ∈ support f
· have h2t := hf ht
rw [mem_ball_zero_iff] at h2t
specialize hg (x₀ - t)
rw [sub_eq_add_neg, add_mem_ball_iff_norm, norm_neg, ← sub_eq_add_neg] at hg
refine ((L (f t)).dist_le_opNorm _ _).trans ?_
exact mul_le_mul_of_nonneg_left (hg h2t) (norm_nonneg _)
· rw [nmem_support] at ht
simp_rw [ht, L.map_zero₂, L.map_zero, norm_zero, zero_mul, dist_self]
rfl
simp_rw [convolution_def]
simp_rw [dist_eq_norm] at h2 ⊢
rw [← integral_sub hfg.integrable]; swap; · exact (L.flip z₀).integrable_comp hif
refine (norm_integral_le_of_norm_le ((L.integrable_comp hif).norm.mul_const ε)
(eventually_of_forall h2)).trans ?_
rw [integral_mul_right]
refine mul_le_mul_of_nonneg_right ?_ hε
have h3 : ∀ t, ‖L (f t)‖ ≤ ‖L‖ * ‖f t‖ := by
intro t
exact L.le_opNorm (f t)
refine (integral_mono (L.integrable_comp hif).norm (hif.norm.const_mul _) h3).trans_eq ?_
rw [integral_mul_left]
variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [CompleteSpace E']
/-- Approximate `f ⋆ g` if the support of the `f` is bounded within a ball, and `g` is near `g x₀`
on a ball with the same radius around `x₀`.
This is a special case of `dist_convolution_le'` where `L` is `(•)`, `f` has integral 1 and `f` is
nonnegative. -/
theorem dist_convolution_le {f : G → ℝ} {x₀ : G} {R ε : ℝ} {z₀ : E'} (hε : 0 ≤ ε)
(hf : support f ⊆ ball (0 : G) R) (hnf : ∀ x, 0 ≤ f x) (hintf : ∫ x, f x ∂μ = 1)
(hmg : AEStronglyMeasurable g μ) (hg : ∀ x ∈ ball x₀ R, dist (g x) z₀ ≤ ε) :
dist ((f ⋆[lsmul ℝ ℝ, μ] g : G → E') x₀) z₀ ≤ ε := by
have hif : Integrable f μ := integrable_of_integral_eq_one hintf
convert (dist_convolution_le' (lsmul ℝ ℝ) hε hif hf hmg hg).trans _
· simp_rw [lsmul_apply, integral_smul_const, hintf, one_smul]
· simp_rw [Real.norm_of_nonneg (hnf _), hintf, mul_one]
exact (mul_le_mul_of_nonneg_right opNorm_lsmul_le hε).trans_eq (one_mul ε)
/-- `(φ i ⋆ g i) (k i)` tends to `z₀` as `i` tends to some filter `l` if
* `φ` is a sequence of nonnegative functions with integral `1` as `i` tends to `l`;
* The support of `φ` tends to small neighborhoods around `(0 : G)` as `i` tends to `l`;
* `g i` is `mu`-a.e. strongly measurable as `i` tends to `l`;
* `g i x` tends to `z₀` as `(i, x)` tends to `l ×ˢ 𝓝 x₀`;
* `k i` tends to `x₀`.
See also `ContDiffBump.convolution_tendsto_right`.
-/
theorem convolution_tendsto_right {ι} {g : ι → G → E'} {l : Filter ι} {x₀ : G} {z₀ : E'}
{φ : ι → G → ℝ} {k : ι → G} (hnφ : ∀ᶠ i in l, ∀ x, 0 ≤ φ i x)
(hiφ : ∀ᶠ i in l, ∫ x, φ i x ∂μ = 1)
-- todo: we could weaken this to "the integral tends to 1"
(hφ : Tendsto (fun n => support (φ n)) l (𝓝 0).smallSets)
(hmg : ∀ᶠ i in l, AEStronglyMeasurable (g i) μ) (hcg : Tendsto (uncurry g) (l ×ˢ 𝓝 x₀) (𝓝 z₀))
(hk : Tendsto k l (𝓝 x₀)) :
Tendsto (fun i : ι => (φ i ⋆[lsmul ℝ ℝ, μ] g i : G → E') (k i)) l (𝓝 z₀) := by
simp_rw [tendsto_smallSets_iff] at hφ
rw [Metric.tendsto_nhds] at hcg ⊢
simp_rw [Metric.eventually_prod_nhds_iff] at hcg
intro ε hε
have h2ε : 0 < ε / 3 := div_pos hε (by norm_num)
obtain ⟨p, hp, δ, hδ, hgδ⟩ := hcg _ h2ε
dsimp only [uncurry] at hgδ
have h2k := hk.eventually (ball_mem_nhds x₀ <| half_pos hδ)
have h2φ := hφ (ball (0 : G) _) <| ball_mem_nhds _ (half_pos hδ)
filter_upwards [hp, h2k, h2φ, hnφ, hiφ, hmg] with i hpi hki hφi hnφi hiφi hmgi
have hgi : dist (g i (k i)) z₀ < ε / 3 := hgδ hpi (hki.trans <| half_lt_self hδ)
have h1 : ∀ x' ∈ ball (k i) (δ / 2), dist (g i x') (g i (k i)) ≤ ε / 3 + ε / 3 := by
intro x' hx'
refine (dist_triangle_right _ _ _).trans (add_le_add (hgδ hpi ?_).le hgi.le)
exact ((dist_triangle _ _ _).trans_lt (add_lt_add hx'.out hki)).trans_eq (add_halves δ)
have := dist_convolution_le (add_pos h2ε h2ε).le hφi hnφi hiφi hmgi h1
refine ((dist_triangle _ _ _).trans_lt (add_lt_add_of_le_of_lt this hgi)).trans_eq ?_
field_simp; ring_nf
end NormedAddCommGroup
end Measurability
end NontriviallyNormedField
open scoped Convolution
section RCLike
variable [RCLike 𝕜]
variable [NormedSpace 𝕜 E]
variable [NormedSpace 𝕜 E']
variable [NormedSpace 𝕜 E'']
variable [NormedSpace ℝ F] [NormedSpace 𝕜 F]
variable {n : ℕ∞}
variable [CompleteSpace F]
variable [MeasurableSpace G] {μ ν : Measure G}
variable (L : E →L[𝕜] E' →L[𝕜] F)
section Assoc
variable [NormedAddCommGroup F'] [NormedSpace ℝ F'] [NormedSpace 𝕜 F'] [CompleteSpace F']
variable [NormedAddCommGroup F''] [NormedSpace ℝ F''] [NormedSpace 𝕜 F''] [CompleteSpace F'']
variable {k : G → E''}
variable (L₂ : F →L[𝕜] E'' →L[𝕜] F')
variable (L₃ : E →L[𝕜] F'' →L[𝕜] F')
variable (L₄ : E' →L[𝕜] E'' →L[𝕜] F'')
variable [AddGroup G]
variable [SFinite μ] [SFinite ν] [IsAddRightInvariant μ]
theorem integral_convolution [MeasurableAdd₂ G] [MeasurableNeg G] [NormedSpace ℝ E]
[NormedSpace ℝ E'] [CompleteSpace E] [CompleteSpace E'] (hf : Integrable f ν)
(hg : Integrable g μ) : ∫ x, (f ⋆[L, ν] g) x ∂μ = L (∫ x, f x ∂ν) (∫ x, g x ∂μ) := by
refine (integral_integral_swap (by apply hf.convolution_integrand L hg)).trans ?_
simp_rw [integral_comp_comm _ (hg.comp_sub_right _), integral_sub_right_eq_self]
exact (L.flip (∫ x, g x ∂μ)).integral_comp_comm hf
variable [MeasurableAdd₂ G] [IsAddRightInvariant ν] [MeasurableNeg G]
/-- Convolution is associative. This has a weak but inconvenient integrability condition.
See also `MeasureTheory.convolution_assoc`. -/
theorem convolution_assoc' (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z))
{x₀ : G} (hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν)
(hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt g k x L₄ μ)
(hi : Integrable (uncurry fun x y => (L₃ (f y)) ((L₄ (g (x - y))) (k (x₀ - x)))) (μ.prod ν)) :
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ :=
calc
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = ∫ t, L₂ (∫ s, L (f s) (g (t - s)) ∂ν) (k (x₀ - t)) ∂μ := rfl
_ = ∫ t, ∫ s, L₂ (L (f s) (g (t - s))) (k (x₀ - t)) ∂ν ∂μ :=
(integral_congr_ae (hfg.mono fun t ht => ((L₂.flip (k (x₀ - t))).integral_comp_comm ht).symm))
_ = ∫ t, ∫ s, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂ν ∂μ := by simp_rw [hL]
_ = ∫ s, ∫ t, L₃ (f s) (L₄ (g (t - s)) (k (x₀ - t))) ∂μ ∂ν := by rw [integral_integral_swap hi]
_ = ∫ s, ∫ u, L₃ (f s) (L₄ (g u) (k (x₀ - s - u))) ∂μ ∂ν := by
congr; ext t
rw [eq_comm, ← integral_sub_right_eq_self _ t]
simp_rw [sub_sub_sub_cancel_right]
_ = ∫ s, L₃ (f s) (∫ u, L₄ (g u) (k (x₀ - s - u)) ∂μ) ∂ν := by
refine integral_congr_ae ?_
refine ((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_
exact (L₃ (f t)).integral_comp_comm ht
_ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := rfl
/-- Convolution is associative. This requires that
* all maps are a.e. strongly measurable w.r.t one of the measures
* `f ⋆[L, ν] g` exists almost everywhere
* `‖g‖ ⋆[μ] ‖k‖` exists almost everywhere
* `‖f‖ ⋆[ν] (‖g‖ ⋆[μ] ‖k‖)` exists at `x₀` -/
theorem convolution_assoc (hL : ∀ (x : E) (y : E') (z : E''), L₂ (L x y) z = L₃ x (L₄ y z)) {x₀ : G}
(hf : AEStronglyMeasurable f ν) (hg : AEStronglyMeasurable g μ) (hk : AEStronglyMeasurable k μ)
(hfg : ∀ᵐ y ∂μ, ConvolutionExistsAt f g y L ν)
(hgk : ∀ᵐ x ∂ν, ConvolutionExistsAt (fun x => ‖g x‖) (fun x => ‖k x‖) x (mul ℝ ℝ) μ)
(hfgk :
ConvolutionExistsAt (fun x => ‖f x‖) ((fun x => ‖g x‖) ⋆[mul ℝ ℝ, μ] fun x => ‖k x‖) x₀
(mul ℝ ℝ) ν) :
((f ⋆[L, ν] g) ⋆[L₂, μ] k) x₀ = (f ⋆[L₃, ν] g ⋆[L₄, μ] k) x₀ := by
refine convolution_assoc' L L₂ L₃ L₄ hL hfg (hgk.mono fun x hx => hx.ofNorm L₄ hg hk) ?_
-- the following is similar to `Integrable.convolution_integrand`
have h_meas :
AEStronglyMeasurable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x))))
(μ.prod ν) := by
refine L₃.aestronglyMeasurable_comp₂ hf.snd ?_
refine L₄.aestronglyMeasurable_comp₂ hg.fst ?_
refine (hk.mono_ac ?_).comp_measurable
((measurable_const.sub measurable_snd).sub measurable_fst)
refine QuasiMeasurePreserving.absolutelyContinuous ?_
refine QuasiMeasurePreserving.prod_of_left
((measurable_const.sub measurable_snd).sub measurable_fst) (eventually_of_forall fun y => ?_)
dsimp only
exact quasiMeasurePreserving_sub_left_of_right_invariant μ _
have h2_meas :
AEStronglyMeasurable (fun y => ∫ x, ‖L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))‖ ∂μ) ν :=
h_meas.prod_swap.norm.integral_prod_right'
have h3 : map (fun z : G × G => (z.1 - z.2, z.2)) (μ.prod ν) = μ.prod ν :=
(measurePreserving_sub_prod μ ν).map_eq
suffices Integrable (uncurry fun x y => L₃ (f y) (L₄ (g x) (k (x₀ - y - x)))) (μ.prod ν) by
rw [← h3] at this
convert this.comp_measurable (measurable_sub.prod_mk measurable_snd)
ext ⟨x, y⟩
simp (config := { unfoldPartialApp := true }) only [uncurry, Function.comp_apply,
sub_sub_sub_cancel_right]
simp_rw [integrable_prod_iff' h_meas]
refine ⟨((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht =>
(L₃ (f t)).integrable_comp <| ht.ofNorm L₄ hg hk, ?_⟩
refine (hfgk.const_mul (‖L₃‖ * ‖L₄‖)).mono' h2_meas
(((quasiMeasurePreserving_sub_left_of_right_invariant ν x₀).ae hgk).mono fun t ht => ?_)
simp_rw [convolution_def, mul_apply', mul_mul_mul_comm ‖L₃‖ ‖L₄‖, ← integral_mul_left]
rw [Real.norm_of_nonneg (by positivity)]
refine integral_mono_of_nonneg (eventually_of_forall fun t => norm_nonneg _)
((ht.const_mul _).const_mul _) (eventually_of_forall fun s => ?_)
simp only [← mul_assoc ‖L₄‖]
apply_rules [ContinuousLinearMap.le_of_opNorm₂_le_of_le, le_rfl]
end Assoc
variable [NormedAddCommGroup G] [BorelSpace G]
theorem convolution_precompR_apply {g : G → E'' →L[𝕜] E'} (hf : LocallyIntegrable f μ)
(hcg : HasCompactSupport g) (hg : Continuous g) (x₀ : G) (x : E'') :
(f ⋆[L.precompR E'', μ] g) x₀ x = (f ⋆[L, μ] fun a => g a x) x₀ := by
have := hcg.convolutionExists_right (L.precompR E'' : _) hf hg x₀
simp_rw [convolution_def, ContinuousLinearMap.integral_apply this]
rfl
variable [NormedSpace 𝕜 G] [SFinite μ] [IsAddLeftInvariant μ]
/-- Compute the total derivative of `f ⋆ g` if `g` is `C^1` with compact support and `f` is locally
integrable. To write down the total derivative as a convolution, we use
`ContinuousLinearMap.precompR`. -/
theorem _root_.HasCompactSupport.hasFDerivAt_convolution_right (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 1 g) (x₀ : G) :
HasFDerivAt (f ⋆[L, μ] g) ((f ⋆[L.precompR G, μ] fderiv 𝕜 g) x₀) x₀ := by
rcases hcg.eq_zero_or_finiteDimensional 𝕜 hg.continuous with (rfl | fin_dim)
· have : fderiv 𝕜 (0 : G → E') = 0 := fderiv_const (0 : E')
simp only [this, convolution_zero, Pi.zero_apply]
exact hasFDerivAt_const (0 : F) x₀
have : ProperSpace G := FiniteDimensional.proper_rclike 𝕜 G
set L' := L.precompR G
have h1 : ∀ᶠ x in 𝓝 x₀, AEStronglyMeasurable (fun t => L (f t) (g (x - t))) μ :=
eventually_of_forall
(hf.aestronglyMeasurable.convolution_integrand_snd L hg.continuous.aestronglyMeasurable)
have h2 : ∀ x, AEStronglyMeasurable (fun t => L' (f t) (fderiv 𝕜 g (x - t))) μ :=
hf.aestronglyMeasurable.convolution_integrand_snd L'
(hg.continuous_fderiv le_rfl).aestronglyMeasurable
have h3 : ∀ x t, HasFDerivAt (fun x => g (x - t)) (fderiv 𝕜 g (x - t)) x := fun x t ↦ by
simpa using
(hg.differentiable le_rfl).differentiableAt.hasFDerivAt.comp x
((hasFDerivAt_id x).sub (hasFDerivAt_const t x))
let K' := -tsupport (fderiv 𝕜 g) + closedBall x₀ 1
have hK' : IsCompact K' := (hcg.fderiv 𝕜).neg.add (isCompact_closedBall x₀ 1)
-- Porting note: was
-- `refine' hasFDerivAt_integral_of_dominated_of_fderiv_le zero_lt_one h1 _ (h2 x₀) _ _ _`
-- but it failed; surprisingly, `apply` works
apply hasFDerivAt_integral_of_dominated_of_fderiv_le zero_lt_one h1 _ (h2 x₀)
· filter_upwards with t x hx using
(hcg.fderiv 𝕜).convolution_integrand_bound_right L' (hg.continuous_fderiv le_rfl)
(ball_subset_closedBall hx)
· rw [integrable_indicator_iff hK'.measurableSet]
exact ((hf.integrableOn_isCompact hK').norm.const_mul _).mul_const _
· exact eventually_of_forall fun t x _ => (L _).hasFDerivAt.comp x (h3 x t)
· exact hcg.convolutionExists_right L hf hg.continuous x₀
theorem _root_.HasCompactSupport.hasFDerivAt_convolution_left [IsNegInvariant μ]
(hcf : HasCompactSupport f) (hf : ContDiff 𝕜 1 f) (hg : LocallyIntegrable g μ) (x₀ : G) :
HasFDerivAt (f ⋆[L, μ] g) ((fderiv 𝕜 f ⋆[L.precompL G, μ] g) x₀) x₀ := by
simp (config := { singlePass := true }) only [← convolution_flip]
exact hcf.hasFDerivAt_convolution_right L.flip hg hf x₀
end RCLike
section Real
/-! The one-variable case -/
variable [RCLike 𝕜]
variable [NormedSpace 𝕜 E]
variable [NormedSpace 𝕜 E']
variable [NormedSpace ℝ F] [NormedSpace 𝕜 F]
variable {f₀ : 𝕜 → E} {g₀ : 𝕜 → E'}
variable {n : ℕ∞}
variable (L : E →L[𝕜] E' →L[𝕜] F)
variable [CompleteSpace F]
variable {μ : Measure 𝕜}
variable [IsAddLeftInvariant μ] [SFinite μ]
theorem _root_.HasCompactSupport.hasDerivAt_convolution_right (hf : LocallyIntegrable f₀ μ)
(hcg : HasCompactSupport g₀) (hg : ContDiff 𝕜 1 g₀) (x₀ : 𝕜) :
HasDerivAt (f₀ ⋆[L, μ] g₀) ((f₀ ⋆[L, μ] deriv g₀) x₀) x₀ := by
convert (hcg.hasFDerivAt_convolution_right L hf hg x₀).hasDerivAt using 1
rw [convolution_precompR_apply L hf (hcg.fderiv 𝕜) (hg.continuous_fderiv le_rfl)]
rfl
theorem _root_.HasCompactSupport.hasDerivAt_convolution_left [IsNegInvariant μ]
(hcf : HasCompactSupport f₀) (hf : ContDiff 𝕜 1 f₀) (hg : LocallyIntegrable g₀ μ) (x₀ : 𝕜) :
HasDerivAt (f₀ ⋆[L, μ] g₀) ((deriv f₀ ⋆[L, μ] g₀) x₀) x₀ := by
simp (config := { singlePass := true }) only [← convolution_flip]
exact hcf.hasDerivAt_convolution_right L.flip hg hf x₀
end Real
section WithParam
variable [RCLike 𝕜] [NormedSpace 𝕜 E] [NormedSpace 𝕜 E'] [NormedSpace 𝕜 E''] [NormedSpace ℝ F]
[NormedSpace 𝕜 F] [CompleteSpace F] [MeasurableSpace G] [NormedAddCommGroup G] [BorelSpace G]
[NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P] {μ : Measure G}
(L : E →L[𝕜] E' →L[𝕜] F)
/-- The derivative of the convolution `f * g` is given by `f * Dg`, when `f` is locally integrable
and `g` is `C^1` and compactly supported. Version where `g` depends on an additional parameter in an
open subset `s` of a parameter space `P` (and the compact support `k` is independent of the
parameter in `s`). -/
theorem hasFDerivAt_convolution_right_with_param {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 1 (↿g) (s ×ˢ univ)) (q₀ : P × G)
(hq₀ : q₀.1 ∈ s) :
HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2)
((f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 (↿g) (q₀.1, x)) q₀.2) q₀ := by
let g' := fderiv 𝕜 ↿g
have A : ∀ p ∈ s, Continuous (g p) := fun p hp ↦ by
refine hg.continuousOn.comp_continuous (continuous_const.prod_mk continuous_id') fun x => ?_
simpa only [prod_mk_mem_set_prod_eq, mem_univ, and_true_iff] using hp
have A' : ∀ q : P × G, q.1 ∈ s → s ×ˢ univ ∈ 𝓝 q := fun q hq ↦ by
apply (hs.prod isOpen_univ).mem_nhds
simpa only [mem_prod, mem_univ, and_true_iff] using hq
-- The derivative of `g` vanishes away from `k`.
have g'_zero : ∀ p x, p ∈ s → x ∉ k → g' (p, x) = 0 := by
intro p x hp hx
refine (hasFDerivAt_zero_of_eventually_const 0 ?_).fderiv
have M2 : kᶜ ∈ 𝓝 x := hk.isClosed.isOpen_compl.mem_nhds hx
have M1 : s ∈ 𝓝 p := hs.mem_nhds hp
rw [nhds_prod_eq]
filter_upwards [prod_mem_prod M1 M2]
rintro ⟨p, y⟩ ⟨hp, hy⟩
exact hgs p y hp hy
/- We find a small neighborhood of `{q₀.1} × k` on which the derivative is uniformly bounded. This
follows from the continuity at all points of the compact set `k`. -/
obtain ⟨ε, C, εpos, h₀ε, hε⟩ :
∃ ε C, 0 < ε ∧ ball q₀.1 ε ⊆ s ∧ ∀ p x, ‖p - q₀.1‖ < ε → ‖g' (p, x)‖ ≤ C := by
have A : IsCompact ({q₀.1} ×ˢ k) := isCompact_singleton.prod hk
obtain ⟨t, kt, t_open, ht⟩ : ∃ t, {q₀.1} ×ˢ k ⊆ t ∧ IsOpen t ∧ IsBounded (g' '' t) := by
have B : ContinuousOn g' (s ×ˢ univ) :=
hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl
apply exists_isOpen_isBounded_image_of_isCompact_of_continuousOn A (hs.prod isOpen_univ) _ B
simp only [prod_subset_prod_iff, hq₀, singleton_subset_iff, subset_univ, and_self_iff,
true_or_iff]
obtain ⟨ε, εpos, hε, h'ε⟩ :
∃ ε : ℝ, 0 < ε ∧ thickening ε ({q₀.fst} ×ˢ k) ⊆ t ∧ ball q₀.1 ε ⊆ s := by
obtain ⟨ε, εpos, hε⟩ : ∃ ε : ℝ, 0 < ε ∧ thickening ε (({q₀.fst} : Set P) ×ˢ k) ⊆ t :=
A.exists_thickening_subset_open t_open kt
obtain ⟨δ, δpos, hδ⟩ : ∃ δ : ℝ, 0 < δ ∧ ball q₀.1 δ ⊆ s := Metric.isOpen_iff.1 hs _ hq₀
refine ⟨min ε δ, lt_min εpos δpos, ?_, ?_⟩
· exact Subset.trans (thickening_mono (min_le_left _ _) _) hε
· exact Subset.trans (ball_subset_ball (min_le_right _ _)) hδ
obtain ⟨C, Cpos, hC⟩ : ∃ C, 0 < C ∧ g' '' t ⊆ closedBall 0 C := ht.subset_closedBall_lt 0 0
refine ⟨ε, C, εpos, h'ε, fun p x hp => ?_⟩
have hps : p ∈ s := h'ε (mem_ball_iff_norm.2 hp)
by_cases hx : x ∈ k
· have H : (p, x) ∈ t := by
apply hε
refine mem_thickening_iff.2 ⟨(q₀.1, x), ?_, ?_⟩
· simp only [hx, singleton_prod, mem_image, Prod.mk.inj_iff, eq_self_iff_true, true_and_iff,
exists_eq_right]
· rw [← dist_eq_norm] at hp
simpa only [Prod.dist_eq, εpos, dist_self, max_lt_iff, and_true_iff] using hp
have : g' (p, x) ∈ closedBall (0 : P × G →L[𝕜] E') C := hC (mem_image_of_mem _ H)
rwa [mem_closedBall_zero_iff] at this
· have : g' (p, x) = 0 := g'_zero _ _ hps hx
rw [this]
simpa only [norm_zero] using Cpos.le
/- Now, we wish to apply a theorem on differentiation of integrals. For this, we need to check
trivial measurability or integrability assumptions (in `I1`, `I2`, `I3`), as well as a uniform
integrability assumption over the derivative (in `I4` and `I5`) and pointwise differentiability
in `I6`. -/
have I1 :
∀ᶠ x : P × G in 𝓝 q₀, AEStronglyMeasurable (fun a : G => L (f a) (g x.1 (x.2 - a))) μ := by
filter_upwards [A' q₀ hq₀]
rintro ⟨p, x⟩ ⟨hp, -⟩
refine (HasCompactSupport.convolutionExists_right L ?_ hf (A _ hp) _).1
apply hk.of_isClosed_subset (isClosed_tsupport _)
exact closure_minimal (support_subset_iff'.2 fun z hz => hgs _ _ hp hz) hk.isClosed
have I2 : Integrable (fun a : G => L (f a) (g q₀.1 (q₀.2 - a))) μ := by
have M : HasCompactSupport (g q₀.1) := HasCompactSupport.intro hk fun x hx => hgs q₀.1 x hq₀ hx
apply M.convolutionExists_right L hf (A q₀.1 hq₀) q₀.2
have I3 : AEStronglyMeasurable (fun a : G => (L (f a)).comp (g' (q₀.fst, q₀.snd - a))) μ := by
have T : HasCompactSupport fun y => g' (q₀.1, y) :=
HasCompactSupport.intro hk fun x hx => g'_zero q₀.1 x hq₀ hx
apply (HasCompactSupport.convolutionExists_right (L.precompR (P × G) : _) T hf _ q₀.2).1
have : ContinuousOn g' (s ×ˢ univ) :=
hg.continuousOn_fderiv_of_isOpen (hs.prod isOpen_univ) le_rfl
apply this.comp_continuous (continuous_const.prod_mk continuous_id')
intro x
simpa only [prod_mk_mem_set_prod_eq, mem_univ, and_true_iff] using hq₀
set K' := (-k + {q₀.2} : Set G) with K'_def
have hK' : IsCompact K' := hk.neg.add isCompact_singleton
obtain ⟨U, U_open, K'U, hU⟩ : ∃ U, IsOpen U ∧ K' ⊆ U ∧ IntegrableOn f U μ :=
hf.integrableOn_nhds_isCompact hK'
obtain ⟨δ, δpos, δε, hδ⟩ : ∃ δ, (0 : ℝ) < δ ∧ δ ≤ ε ∧ K' + ball 0 δ ⊆ U := by
obtain ⟨V, V_mem, hV⟩ : ∃ V ∈ 𝓝 (0 : G), K' + V ⊆ U :=
compact_open_separated_add_right hK' U_open K'U
rcases Metric.mem_nhds_iff.1 V_mem with ⟨δ, δpos, hδ⟩
refine ⟨min δ ε, lt_min δpos εpos, min_le_right δ ε, ?_⟩
exact (add_subset_add_left ((ball_subset_ball (min_le_left _ _)).trans hδ)).trans hV
-- Porting note: added to speed up the line below.
letI := ContinuousLinearMap.hasOpNorm (𝕜 := 𝕜) (𝕜₂ := 𝕜) (E := E)
(F := (P × G →L[𝕜] E') →L[𝕜] P × G →L[𝕜] F) (σ₁₂ := RingHom.id 𝕜)
let bound : G → ℝ := indicator U fun t => ‖(L.precompR (P × G))‖ * ‖f t‖ * C
have I4 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ →
‖L.precompR (P × G) (f a) (g' (x.fst, x.snd - a))‖ ≤ bound a := by
filter_upwards with a x hx
rw [Prod.dist_eq, dist_eq_norm, dist_eq_norm] at hx
have : (-tsupport fun a => g' (x.1, a)) + ball q₀.2 δ ⊆ U := by
apply Subset.trans _ hδ
rw [K'_def, add_assoc]
apply add_subset_add
· rw [neg_subset_neg]
refine closure_minimal (support_subset_iff'.2 fun z hz => ?_) hk.isClosed
apply g'_zero x.1 z (h₀ε _) hz
rw [mem_ball_iff_norm]
exact ((le_max_left _ _).trans_lt hx).trans_le δε
· simp only [add_ball, thickening_singleton, zero_vadd, subset_rfl]
apply convolution_integrand_bound_right_of_le_of_subset _ _ _ this
· intro y
exact hε _ _ (((le_max_left _ _).trans_lt hx).trans_le δε)
· rw [mem_ball_iff_norm]
exact (le_max_right _ _).trans_lt hx
have I5 : Integrable bound μ := by
rw [integrable_indicator_iff U_open.measurableSet]
exact (hU.norm.const_mul _).mul_const _
have I6 : ∀ᵐ a : G ∂μ, ∀ x : P × G, dist x q₀ < δ →
HasFDerivAt (fun x : P × G => L (f a) (g x.1 (x.2 - a)))
((L (f a)).comp (g' (x.fst, x.snd - a))) x := by
filter_upwards with a x hx
apply (L _).hasFDerivAt.comp x
have N : s ×ˢ univ ∈ 𝓝 (x.1, x.2 - a) := by
apply A'
apply h₀ε
rw [Prod.dist_eq] at hx
exact lt_of_lt_of_le (lt_of_le_of_lt (le_max_left _ _) hx) δε
have Z := ((hg.differentiableOn le_rfl).differentiableAt N).hasFDerivAt
have Z' :
HasFDerivAt (fun x : P × G => (x.1, x.2 - a)) (ContinuousLinearMap.id 𝕜 (P × G)) x := by
have : (fun x : P × G => (x.1, x.2 - a)) = _root_.id - fun x => (0, a) := by
ext x <;> simp only [Pi.sub_apply, _root_.id, Prod.fst_sub, sub_zero, Prod.snd_sub]
rw [this]
exact (hasFDerivAt_id x).sub_const (0, a)
exact Z.comp x Z'
exact hasFDerivAt_integral_of_dominated_of_fderiv_le δpos I1 I2 I3 I4 I5 I6
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`).
In this version, all the types belong to the same universe (to get an induction working in the
proof). Use instead `contDiffOn_convolution_right_with_param`, which removes this restriction. -/
theorem contDiffOn_convolution_right_with_param_aux {G : Type uP} {E' : Type uP} {F : Type uP}
{P : Type uP} [NormedAddCommGroup E'] [NormedAddCommGroup F] [NormedSpace 𝕜 E']
[NormedSpace ℝ F] [NormedSpace 𝕜 F] [CompleteSpace F] [MeasurableSpace G]
{μ : Measure G}
[NormedAddCommGroup G] [BorelSpace G] [NormedSpace 𝕜 G] [NormedAddCommGroup P] [NormedSpace 𝕜 P]
{f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n (↿g) (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- We have a formula for the derivation of `f * g`, which is of the same form, thanks to
`hasFDerivAt_convolution_right_with_param`. Therefore, we can prove the result by induction on
`n` (but for this we need the spaces at the different steps of the induction to live in the same
universe, which is why we make the assumption in the lemma that all the relevant spaces
come from the same universe). -/
induction' n using ENat.nat_induction with n ih ih generalizing g E' F
· rw [contDiffOn_zero] at hg ⊢
exact continuousOn_convolution_right_with_param L hk hgs hf hg
· let f' : P → G → P × G →L[𝕜] F := fun p a =>
(f ⋆[L.precompR (P × G), μ] fun x : G => fderiv 𝕜 (uncurry g) (p, x)) a
have A : ∀ q₀ : P × G, q₀.1 ∈ s →
HasFDerivAt (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (f' q₀.1 q₀.2) q₀ :=
hasFDerivAt_convolution_right_with_param L hs hk hgs hf hg.one_of_succ
rw [contDiffOn_succ_iff_fderiv_of_isOpen (hs.prod (@isOpen_univ G _))] at hg ⊢
constructor
· rintro ⟨p, x⟩ ⟨hp, -⟩
exact (A (p, x) hp).differentiableAt.differentiableWithinAt
· suffices H : ContDiffOn 𝕜 n (↿f') (s ×ˢ univ) by
apply H.congr
rintro ⟨p, x⟩ ⟨hp, -⟩
exact (A (p, x) hp).fderiv
have B : ∀ (p : P) (x : G), p ∈ s → x ∉ k → fderiv 𝕜 (uncurry g) (p, x) = 0 := by
intro p x hp hx
apply (hasFDerivAt_zero_of_eventually_const (0 : E') _).fderiv
have M2 : kᶜ ∈ 𝓝 x := IsOpen.mem_nhds hk.isClosed.isOpen_compl hx
have M1 : s ∈ 𝓝 p := hs.mem_nhds hp
rw [nhds_prod_eq]
filter_upwards [prod_mem_prod M1 M2]
rintro ⟨p, y⟩ ⟨hp, hy⟩
exact hgs p y hp hy
apply ih (L.precompR (P × G) : _) B
convert hg.2
· rw [contDiffOn_top] at hg ⊢
intro n
exact ih n L hgs (hg n)
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem contDiffOn_convolution_right_with_param {f : G → E} {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F)
{g : P → G → E'} {s : Set P} {k : Set G} (hs : IsOpen s) (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n (↿g) (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (f ⋆[L, μ] g q.1) q.2) (s ×ˢ univ) := by
/- The result is known when all the universes are the same, from
`contDiffOn_convolution_right_with_param_aux`. We reduce to this situation by pushing
everything through `ULift` continuous linear equivalences. -/
let eG : Type max uG uE' uF uP := ULift.{max uE' uF uP} G
borelize eG
let eE' : Type max uE' uG uF uP := ULift.{max uG uF uP} E'
let eF : Type max uF uG uE' uP := ULift.{max uG uE' uP} F
let eP : Type max uP uG uE' uF := ULift.{max uG uE' uF} P
have isoG : eG ≃L[𝕜] G := ContinuousLinearEquiv.ulift
have isoE' : eE' ≃L[𝕜] E' := ContinuousLinearEquiv.ulift
have isoF : eF ≃L[𝕜] F := ContinuousLinearEquiv.ulift
have isoP : eP ≃L[𝕜] P := ContinuousLinearEquiv.ulift
let ef := f ∘ isoG
let eμ : Measure eG := Measure.map isoG.symm μ
let eg : eP → eG → eE' := fun ep ex => isoE'.symm (g (isoP ep) (isoG ex))
let eL :=
ContinuousLinearMap.comp
((ContinuousLinearEquiv.arrowCongr isoE' isoF).symm : (E' →L[𝕜] F) →L[𝕜] eE' →L[𝕜] eF) L
let R := fun q : eP × eG => (ef ⋆[eL, eμ] eg q.1) q.2
have R_contdiff : ContDiffOn 𝕜 n R ((isoP ⁻¹' s) ×ˢ univ) := by
have hek : IsCompact (isoG ⁻¹' k) := isoG.toHomeomorph.closedEmbedding.isCompact_preimage hk
have hes : IsOpen (isoP ⁻¹' s) := isoP.continuous.isOpen_preimage _ hs
refine contDiffOn_convolution_right_with_param_aux eL hes hek ?_ ?_ ?_
· intro p x hp hx
simp only [eg, (· ∘ ·), ContinuousLinearEquiv.prod_apply, LinearIsometryEquiv.coe_coe,
ContinuousLinearEquiv.map_eq_zero_iff]
exact hgs _ _ hp hx
· apply (locallyIntegrable_map_homeomorph isoG.symm.toHomeomorph).2
convert hf
ext1 x
simp only [ef, ContinuousLinearEquiv.coe_toHomeomorph, (· ∘ ·),
ContinuousLinearEquiv.apply_symm_apply]
· apply isoE'.symm.contDiff.comp_contDiffOn
apply hg.comp (isoP.prod isoG).contDiff.contDiffOn
rintro ⟨p, x⟩ ⟨hp, -⟩
simpa only [mem_preimage, ContinuousLinearEquiv.prod_apply, prod_mk_mem_set_prod_eq, mem_univ,
and_true_iff] using hp
have A : ContDiffOn 𝕜 n (isoF ∘ R ∘ (isoP.prod isoG).symm) (s ×ˢ univ) := by
apply isoF.contDiff.comp_contDiffOn
apply R_contdiff.comp (ContinuousLinearEquiv.contDiff _).contDiffOn
rintro ⟨p, x⟩ ⟨hp, -⟩
simpa only [mem_preimage, mem_prod, mem_univ, and_true_iff, ContinuousLinearEquiv.prod_symm,
ContinuousLinearEquiv.prod_apply, ContinuousLinearEquiv.apply_symm_apply] using hp
have : isoF ∘ R ∘ (isoP.prod isoG).symm = fun q : P × G => (f ⋆[L, μ] g q.1) q.2 := by
apply funext
rintro ⟨p, x⟩
simp only [LinearIsometryEquiv.coe_coe, (· ∘ ·), ContinuousLinearEquiv.prod_symm,
ContinuousLinearEquiv.prod_apply]
simp only [R, convolution, coe_comp', ContinuousLinearEquiv.coe_coe, (· ∘ ·)]
rw [ClosedEmbedding.integral_map, ← isoF.integral_comp_comm]
swap; · exact isoG.symm.toHomeomorph.closedEmbedding
congr 1
ext1 a
simp only [ef, eg, eL, (· ∘ ·), ContinuousLinearEquiv.apply_symm_apply, coe_comp',
ContinuousLinearEquiv.prod_apply, ContinuousLinearEquiv.map_sub,
ContinuousLinearEquiv.arrowCongr, ContinuousLinearEquiv.arrowCongrSL_symm_apply,
ContinuousLinearEquiv.coe_coe, Function.comp_apply, ContinuousLinearEquiv.apply_symm_apply]
simp_rw [this] at A
exact A
/-- The convolution `f * g` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of composition with an additional smooth function. -/
theorem contDiffOn_convolution_right_with_param_comp {n : ℕ∞} (L : E →L[𝕜] E' →L[𝕜] F) {s : Set P}
{v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E} {g : P → G → E'} {k : Set G} (hs : IsOpen s)
(hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n (↿g) (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (f ⋆[L, μ] g x) (v x)) s := by
apply (contDiffOn_convolution_right_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prod hv)
intro x hx
simp only [hx, mem_preimage, prod_mk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
/-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`). -/
theorem contDiffOn_convolution_left_with_param [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
(L : E' →L[𝕜] E →L[𝕜] F) {f : G → E} {n : ℕ∞} {g : P → G → E'} {s : Set P} {k : Set G}
(hs : IsOpen s) (hk : IsCompact k) (hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0)
(hf : LocallyIntegrable f μ) (hg : ContDiffOn 𝕜 n (↿g) (s ×ˢ univ)) :
ContDiffOn 𝕜 n (fun q : P × G => (g q.1 ⋆[L, μ] f) q.2) (s ×ˢ univ) := by
simpa only [convolution_flip] using contDiffOn_convolution_right_with_param L.flip hs hk hgs hf hg
/-- The convolution `g * f` is `C^n` when `f` is locally integrable and `g` is `C^n` and compactly
supported. Version where `g` depends on an additional parameter in an open subset `s` of a
parameter space `P` (and the compact support `k` is independent of the parameter in `s`),
given in terms of composition with additional smooth functions. -/
theorem contDiffOn_convolution_left_with_param_comp [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
(L : E' →L[𝕜] E →L[𝕜] F) {s : Set P} {n : ℕ∞} {v : P → G} (hv : ContDiffOn 𝕜 n v s) {f : G → E}
{g : P → G → E'} {k : Set G} (hs : IsOpen s) (hk : IsCompact k)
(hgs : ∀ p, ∀ x, p ∈ s → x ∉ k → g p x = 0) (hf : LocallyIntegrable f μ)
(hg : ContDiffOn 𝕜 n (↿g) (s ×ˢ univ)) : ContDiffOn 𝕜 n (fun x => (g x ⋆[L, μ] f) (v x)) s := by
apply (contDiffOn_convolution_left_with_param L hs hk hgs hf hg).comp (contDiffOn_id.prod hv)
intro x hx
simp only [hx, mem_preimage, prod_mk_mem_set_prod_eq, mem_univ, and_self_iff, _root_.id]
theorem _root_.HasCompactSupport.contDiff_convolution_right {n : ℕ∞} (hcg : HasCompactSupport g)
(hf : LocallyIntegrable f μ) (hg : ContDiff 𝕜 n g) : ContDiff 𝕜 n (f ⋆[L, μ] g) := by
rcases exists_compact_iff_hasCompactSupport.2 hcg with ⟨k, hk, h'k⟩
rw [← contDiffOn_univ]
exact contDiffOn_convolution_right_with_param_comp L contDiffOn_id isOpen_univ hk
(fun p x _ hx => h'k x hx) hf (hg.comp contDiff_snd).contDiffOn
theorem _root_.HasCompactSupport.contDiff_convolution_left [μ.IsAddLeftInvariant] [μ.IsNegInvariant]
{n : ℕ∞} (hcf : HasCompactSupport f) (hf : ContDiff 𝕜 n f) (hg : LocallyIntegrable g μ) :
ContDiff 𝕜 n (f ⋆[L, μ] g) := by
rw [← convolution_flip]
exact hcf.contDiff_convolution_right L.flip hg hf
end WithParam
section Nonneg
variable [NormedSpace ℝ E] [NormedSpace ℝ E'] [NormedSpace ℝ F] [CompleteSpace F]
/-- The forward convolution of two functions `f` and `g` on `ℝ`, with respect to a continuous
bilinear map `L` and measure `ν`. It is defined to be the function mapping `x` to
`∫ t in 0..x, L (f t) (g (x - t)) ∂ν` if `0 < x`, and 0 otherwise. -/
noncomputable def posConvolution (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F)
(ν : Measure ℝ := by volume_tac) : ℝ → F :=
indicator (Ioi (0 : ℝ)) fun x => ∫ t in (0)..x, L (f t) (g (x - t)) ∂ν
theorem posConvolution_eq_convolution_indicator (f : ℝ → E) (g : ℝ → E') (L : E →L[ℝ] E' →L[ℝ] F)
(ν : Measure ℝ := by volume_tac) [NoAtoms ν] :
posConvolution f g L ν = convolution (indicator (Ioi 0) f) (indicator (Ioi 0) g) L ν := by
ext1 x
-- Porting note: was `rw [convolution, posConvolution, indicator]`, now `rw` can't do it
-- the `rw` unfolded only one `indicator`; now we unfold it everywhere, so we need to adjust
-- `rw`s below
unfold convolution posConvolution indicator; simp only
split_ifs with h
· rw [intervalIntegral.integral_of_le (le_of_lt h), integral_Ioc_eq_integral_Ioo, ←
integral_indicator (measurableSet_Ioo : MeasurableSet (Ioo 0 x))]
congr 1 with t : 1
have : t ≤ 0 ∨ t ∈ Ioo 0 x ∨ x ≤ t := by
rcases le_or_lt t 0 with (h | h)
· exact Or.inl h
· rcases lt_or_le t x with (h' | h')
exacts [Or.inr (Or.inl ⟨h, h'⟩), Or.inr (Or.inr h')]
rcases this with (ht | ht | ht)
· -- Porting note: was
-- rw [indicator_of_not_mem (not_mem_Ioo_of_le ht), indicator_of_not_mem (not_mem_Ioi.mpr ht),
-- ContinuousLinearMap.map_zero, ContinuousLinearMap.zero_apply]
rw [indicator_of_not_mem (not_mem_Ioo_of_le ht), if_neg (not_mem_Ioi.mpr ht),
ContinuousLinearMap.map_zero, ContinuousLinearMap.zero_apply]
· -- Porting note: was
-- rw [indicator_of_mem ht, indicator_of_mem (mem_Ioi.mpr ht.1),
-- indicator_of_mem (mem_Ioi.mpr <| sub_pos.mpr ht.2)]
rw [indicator_of_mem ht, if_pos (mem_Ioi.mpr ht.1),
if_pos (mem_Ioi.mpr <| sub_pos.mpr ht.2)]
· -- Porting note: was
-- rw [indicator_of_not_mem (not_mem_Ioo_of_ge ht),
-- indicator_of_not_mem (not_mem_Ioi.mpr (sub_nonpos_of_le ht)),
-- ContinuousLinearMap.map_zero]
rw [indicator_of_not_mem (not_mem_Ioo_of_ge ht),
if_neg (not_mem_Ioi.mpr (sub_nonpos_of_le ht)), ContinuousLinearMap.map_zero]
· convert (integral_zero ℝ F).symm with t
by_cases ht : 0 < t
· -- Porting note: was
-- rw [indicator_of_not_mem (_ : x - t ∉ Ioi 0), ContinuousLinearMap.map_zero]
rw [if_neg (_ : x - t ∉ Ioi 0), ContinuousLinearMap.map_zero]
rw [not_mem_Ioi] at h ⊢
exact sub_nonpos.mpr (h.trans ht.le)
· -- Porting note: was
-- rw [indicator_of_not_mem (mem_Ioi.not.mpr ht), ContinuousLinearMap.map_zero,
-- ContinuousLinearMap.zero_apply]
rw [if_neg (mem_Ioi.not.mpr ht), ContinuousLinearMap.map_zero,
ContinuousLinearMap.zero_apply]
theorem integrable_posConvolution {f : ℝ → E} {g : ℝ → E'} {μ ν : Measure ℝ} [SFinite μ]
[SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] (hf : IntegrableOn f (Ioi 0) ν)
(hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) :
Integrable (posConvolution f g L ν) μ := by
rw [← integrable_indicator_iff (measurableSet_Ioi : MeasurableSet (Ioi (0 : ℝ)))] at hf hg
rw [posConvolution_eq_convolution_indicator f g L ν]
exact (hf.convolution_integrand L hg).integral_prod_left
/-- The integral over `Ioi 0` of a forward convolution of two functions is equal to the product
of their integrals over this set. (Compare `integral_convolution` for the two-sided convolution.) -/
theorem integral_posConvolution [CompleteSpace E] [CompleteSpace E'] {μ ν : Measure ℝ}
[SFinite μ] [SFinite ν] [IsAddRightInvariant μ] [NoAtoms ν] {f : ℝ → E} {g : ℝ → E'}
(hf : IntegrableOn f (Ioi 0) ν) (hg : IntegrableOn g (Ioi 0) μ) (L : E →L[ℝ] E' →L[ℝ] F) :
∫ x : ℝ in Ioi 0, ∫ t : ℝ in (0)..x, L (f t) (g (x - t)) ∂ν ∂μ =
L (∫ x : ℝ in Ioi 0, f x ∂ν) (∫ x : ℝ in Ioi 0, g x ∂μ) := by
rw [← integrable_indicator_iff measurableSet_Ioi] at hf hg
simp_rw [← integral_indicator measurableSet_Ioi]
convert integral_convolution L hf hg using 4 with x
apply posConvolution_eq_convolution_indicator
end Nonneg
end MeasureTheory
|
Analysis\Hofer.lean | /-
Copyright (c) 2020 Patrick Massot. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Patrick Massot
-/
import Mathlib.Analysis.SpecificLimits.Basic
/-!
# Hofer's lemma
This is an elementary lemma about complete metric spaces. It is motivated by an
application to the bubbling-off analysis for holomorphic curves in symplectic topology.
We are *very* far away from having these applications, but the proof here is a nice
example of a proof needing to construct a sequence by induction in the middle of the proof.
## References:
* H. Hofer and C. Viterbo, *The Weinstein conjecture in the presence of holomorphic spheres*
-/
open Topology Filter Finset
local notation "d" => dist
theorem hofer {X : Type*} [MetricSpace X] [CompleteSpace X] (x : X) (ε : ℝ) (ε_pos : 0 < ε)
{ϕ : X → ℝ} (cont : Continuous ϕ) (nonneg : ∀ y, 0 ≤ ϕ y) : ∃ ε' > 0, ∃ x' : X,
ε' ≤ ε ∧ d x' x ≤ 2 * ε ∧ ε * ϕ x ≤ ε' * ϕ x' ∧ ∀ y, d x' y ≤ ε' → ϕ y ≤ 2 * ϕ x' := by
by_contra H
have reformulation : ∀ (x') (k : ℕ), ε * ϕ x ≤ ε / 2 ^ k * ϕ x' ↔ 2 ^ k * ϕ x ≤ ϕ x' := by
intro x' k
rw [div_mul_eq_mul_div, le_div_iff, mul_assoc, mul_le_mul_left ε_pos, mul_comm]
positivity
-- Now let's specialize to `ε/2^k`
replace H : ∀ k : ℕ, ∀ x', d x' x ≤ 2 * ε ∧ 2 ^ k * ϕ x ≤ ϕ x' →
∃ y, d x' y ≤ ε / 2 ^ k ∧ 2 * ϕ x' < ϕ y := by
intro k x'
push_neg at H
have := H (ε / 2 ^ k) (by positivity) x' (by simp [ε_pos.le, one_le_two])
simpa [reformulation] using this
clear reformulation
haveI : Nonempty X := ⟨x⟩
choose! F hF using H
-- Use the axiom of choice
-- Now define u by induction starting at x, with u_{n+1} = F(n, u_n)
let u : ℕ → X := fun n => Nat.recOn n x F
-- The properties of F translate to properties of u
have hu :
∀ n,
d (u n) x ≤ 2 * ε ∧ 2 ^ n * ϕ x ≤ ϕ (u n) →
d (u n) (u <| n + 1) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u <| n + 1) := by
intro n
exact hF n (u n)
clear hF
-- Key properties of u, to be proven by induction
have key : ∀ n, d (u n) (u (n + 1)) ≤ ε / 2 ^ n ∧ 2 * ϕ (u n) < ϕ (u (n + 1)) := by
intro n
induction' n using Nat.case_strong_induction_on with n IH
· simpa [u, ε_pos.le] using hu 0
have A : d (u (n + 1)) x ≤ 2 * ε := by
rw [dist_comm]
let r := range (n + 1) -- range (n+1) = {0, ..., n}
calc
d (u 0) (u (n + 1)) ≤ ∑ i ∈ r, d (u i) (u <| i + 1) := dist_le_range_sum_dist u (n + 1)
_ ≤ ∑ i ∈ r, ε / 2 ^ i :=
(sum_le_sum fun i i_in => (IH i <| Nat.lt_succ_iff.mp <| Finset.mem_range.mp i_in).1)
_ = (∑ i ∈ r, (1 / 2 : ℝ) ^ i) * ε := by
rw [Finset.sum_mul]
congr with i
field_simp
_ ≤ 2 * ε := by gcongr; apply sum_geometric_two_le
have B : 2 ^ (n + 1) * ϕ x ≤ ϕ (u (n + 1)) := by
refine @geom_le (ϕ ∘ u) _ zero_le_two (n + 1) fun m hm => ?_
exact (IH _ <| Nat.lt_add_one_iff.1 hm).2.le
exact hu (n + 1) ⟨A, B⟩
cases' forall_and.mp key with key₁ key₂
clear hu key
-- Hence u is Cauchy
have cauchy_u : CauchySeq u := by
refine cauchySeq_of_le_geometric _ ε one_half_lt_one fun n => ?_
simpa only [one_div, inv_pow] using key₁ n
-- So u converges to some y
obtain ⟨y, limy⟩ : ∃ y, Tendsto u atTop (𝓝 y) := CompleteSpace.complete cauchy_u
-- And ϕ ∘ u goes to +∞
have lim_top : Tendsto (ϕ ∘ u) atTop atTop := by
let v n := (ϕ ∘ u) (n + 1)
suffices Tendsto v atTop atTop by rwa [tendsto_add_atTop_iff_nat] at this
have hv₀ : 0 < v 0 := by
calc
0 ≤ 2 * ϕ (u 0) := by specialize nonneg x; positivity
_ < ϕ (u (0 + 1)) := key₂ 0
apply tendsto_atTop_of_geom_le hv₀ one_lt_two
exact fun n => (key₂ (n + 1)).le
-- But ϕ ∘ u also needs to go to ϕ(y)
have lim : Tendsto (ϕ ∘ u) atTop (𝓝 (ϕ y)) := Tendsto.comp cont.continuousAt limy
-- So we have our contradiction!
exact not_tendsto_atTop_of_tendsto_nhds lim lim_top
|
Analysis\Matrix.lean | /-
Copyright (c) 2021 Heather Macbeth. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Heather Macbeth, Eric Wieser
-/
import Mathlib.Analysis.Normed.Lp.PiLp
import Mathlib.Analysis.InnerProductSpace.PiL2
/-!
# Matrices as a normed space
In this file we provide the following non-instances for norms on matrices:
* The elementwise norm:
* `Matrix.seminormedAddCommGroup`
* `Matrix.normedAddCommGroup`
* `Matrix.normedSpace`
* `Matrix.boundedSMul`
* The Frobenius norm:
* `Matrix.frobeniusSeminormedAddCommGroup`
* `Matrix.frobeniusNormedAddCommGroup`
* `Matrix.frobeniusNormedSpace`
* `Matrix.frobeniusNormedRing`
* `Matrix.frobeniusNormedAlgebra`
* `Matrix.frobeniusBoundedSMul`
* The $L^\infty$ operator norm:
* `Matrix.linftyOpSeminormedAddCommGroup`
* `Matrix.linftyOpNormedAddCommGroup`
* `Matrix.linftyOpNormedSpace`
* `Matrix.linftyOpBoundedSMul`
* `Matrix.linftyOpNonUnitalSemiNormedRing`
* `Matrix.linftyOpSemiNormedRing`
* `Matrix.linftyOpNonUnitalNormedRing`
* `Matrix.linftyOpNormedRing`
* `Matrix.linftyOpNormedAlgebra`
These are not declared as instances because there are several natural choices for defining the norm
of a matrix.
The norm induced by the identification of `Matrix m n 𝕜` with
`EuclideanSpace n 𝕜 →L[𝕜] EuclideanSpace m 𝕜` (i.e., the ℓ² operator norm) can be found in
`Analysis.CStarAlgebra.Matrix`. It is separated to avoid extraneous imports in this file.
-/
noncomputable section
open scoped NNReal Matrix
namespace Matrix
variable {R l m n α β ι : Type*} [Fintype l] [Fintype m] [Fintype n] [Unique ι]
/-! ### The elementwise supremum norm -/
section LinfLinf
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
/-- Seminormed group instance (using sup norm of sup norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def seminormedAddCommGroup : SeminormedAddCommGroup (Matrix m n α) :=
Pi.seminormedAddCommGroup
attribute [local instance] Matrix.seminormedAddCommGroup
theorem norm_def (A : Matrix m n α) : ‖A‖ = ‖fun i j => A i j‖ := rfl
/-- The norm of a matrix is the sup of the sup of the nnnorm of the entries -/
lemma norm_eq_sup_sup_nnnorm (A : Matrix m n α) :
‖A‖ = Finset.sup Finset.univ fun i ↦ Finset.sup Finset.univ fun j ↦ ‖A i j‖₊ := by
simp_rw [Matrix.norm_def, Pi.norm_def, Pi.nnnorm_def]
theorem nnnorm_def (A : Matrix m n α) : ‖A‖₊ = ‖fun i j => A i j‖₊ := rfl
theorem norm_le_iff {r : ℝ} (hr : 0 ≤ r) {A : Matrix m n α} : ‖A‖ ≤ r ↔ ∀ i j, ‖A i j‖ ≤ r := by
simp_rw [norm_def, pi_norm_le_iff_of_nonneg hr]
theorem nnnorm_le_iff {r : ℝ≥0} {A : Matrix m n α} : ‖A‖₊ ≤ r ↔ ∀ i j, ‖A i j‖₊ ≤ r := by
simp_rw [nnnorm_def, pi_nnnorm_le_iff]
theorem norm_lt_iff {r : ℝ} (hr : 0 < r) {A : Matrix m n α} : ‖A‖ < r ↔ ∀ i j, ‖A i j‖ < r := by
simp_rw [norm_def, pi_norm_lt_iff hr]
theorem nnnorm_lt_iff {r : ℝ≥0} (hr : 0 < r) {A : Matrix m n α} :
‖A‖₊ < r ↔ ∀ i j, ‖A i j‖₊ < r := by
simp_rw [nnnorm_def, pi_nnnorm_lt_iff hr]
theorem norm_entry_le_entrywise_sup_norm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖ ≤ ‖A‖ :=
(norm_le_pi_norm (A i) j).trans (norm_le_pi_norm A i)
theorem nnnorm_entry_le_entrywise_sup_nnnorm (A : Matrix m n α) {i : m} {j : n} : ‖A i j‖₊ ≤ ‖A‖₊ :=
(nnnorm_le_pi_nnnorm (A i) j).trans (nnnorm_le_pi_nnnorm A i)
@[simp]
theorem nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by
simp only [nnnorm_def, Pi.nnnorm_def, Matrix.map_apply, hf]
@[simp]
theorem norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) : ‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
@[simp]
theorem nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ :=
Finset.sup_comm _ _ _
@[simp]
theorem norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_transpose A
@[simp]
theorem nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(nnnorm_map_eq _ _ nnnorm_star).trans A.nnnorm_transpose
@[simp]
theorem norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) : ‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_conjTranspose A
instance [StarAddMonoid α] [NormedStarGroup α] : NormedStarGroup (Matrix m m α) :=
⟨norm_conjTranspose⟩
@[simp]
theorem nnnorm_col (v : m → α) : ‖col ι v‖₊ = ‖v‖₊ := by
simp [nnnorm_def, Pi.nnnorm_def]
@[simp]
theorem norm_col (v : m → α) : ‖col ι v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_col v
@[simp]
theorem nnnorm_row (v : n → α) : ‖row ι v‖₊ = ‖v‖₊ := by
simp [nnnorm_def, Pi.nnnorm_def]
@[simp]
theorem norm_row (v : n → α) : ‖row ι v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_row v
@[simp]
theorem nnnorm_diagonal [DecidableEq n] (v : n → α) : ‖diagonal v‖₊ = ‖v‖₊ := by
simp_rw [nnnorm_def, Pi.nnnorm_def]
congr 1 with i : 1
refine le_antisymm (Finset.sup_le fun j hj => ?_) ?_
· obtain rfl | hij := eq_or_ne i j
· rw [diagonal_apply_eq]
· rw [diagonal_apply_ne _ hij, nnnorm_zero]
exact zero_le _
· refine Eq.trans_le ?_ (Finset.le_sup (Finset.mem_univ i))
rw [diagonal_apply_eq]
@[simp]
theorem norm_diagonal [DecidableEq n] (v : n → α) : ‖diagonal v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| nnnorm_diagonal v
/-- Note this is safe as an instance as it carries no data. -/
-- Porting note: not yet implemented: `@[nolint fails_quickly]`
instance [Nonempty n] [DecidableEq n] [One α] [NormOneClass α] : NormOneClass (Matrix n n α) :=
⟨(norm_diagonal _).trans <| norm_one⟩
end SeminormedAddCommGroup
/-- Normed group instance (using sup norm of sup norm) for matrices over a normed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def normedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
Pi.normedAddCommGroup
section NormedSpace
attribute [local instance] Matrix.seminormedAddCommGroup
/-- This applies to the sup norm of sup norm. -/
protected theorem boundedSMul [SeminormedRing R] [SeminormedAddCommGroup α] [Module R α]
[BoundedSMul R α] : BoundedSMul R (Matrix m n α) :=
Pi.instBoundedSMul
variable [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α]
/-- Normed space instance (using sup norm of sup norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
protected def normedSpace : NormedSpace R (Matrix m n α) :=
Pi.normedSpace
end NormedSpace
end LinfLinf
/-! ### The $L_\infty$ operator norm
This section defines the matrix norm $\|A\|_\infty = \operatorname{sup}_i (\sum_j \|A_{ij}\|)$.
Note that this is equivalent to the operator norm, considering $A$ as a linear map between two
$L^\infty$ spaces.
-/
section LinftyOp
/-- Seminormed group instance (using sup norm of L1 norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpSeminormedAddCommGroup [SeminormedAddCommGroup α] :
SeminormedAddCommGroup (Matrix m n α) :=
(by infer_instance : SeminormedAddCommGroup (m → PiLp 1 fun j : n => α))
/-- Normed group instance (using sup norm of L1 norm) for matrices over a normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedAddCommGroup [NormedAddCommGroup α] :
NormedAddCommGroup (Matrix m n α) :=
(by infer_instance : NormedAddCommGroup (m → PiLp 1 fun j : n => α))
/-- This applies to the sup norm of L1 norm. -/
@[local instance]
protected theorem linftyOpBoundedSMul
[SeminormedRing R] [SeminormedAddCommGroup α] [Module R α] [BoundedSMul R α] :
BoundedSMul R (Matrix m n α) :=
(by infer_instance : BoundedSMul R (m → PiLp 1 fun j : n => α))
/-- Normed space instance (using sup norm of L1 norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedSpace [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α] :
NormedSpace R (Matrix m n α) :=
(by infer_instance : NormedSpace R (m → PiLp 1 fun j : n => α))
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α]
theorem linfty_opNorm_def (A : Matrix m n α) :
‖A‖ = ((Finset.univ : Finset m).sup fun i : m => ∑ j : n, ‖A i j‖₊ : ℝ≥0) := by
-- Porting note: added
change ‖fun i => (WithLp.equiv 1 _).symm (A i)‖ = _
simp [Pi.norm_def, PiLp.nnnorm_eq_sum ENNReal.one_ne_top]
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_def := linfty_opNorm_def
theorem linfty_opNNNorm_def (A : Matrix m n α) :
‖A‖₊ = (Finset.univ : Finset m).sup fun i : m => ∑ j : n, ‖A i j‖₊ :=
Subtype.ext <| linfty_opNorm_def A
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_def := linfty_opNNNorm_def
@[simp]
theorem linfty_opNNNorm_col (v : m → α) : ‖col ι v‖₊ = ‖v‖₊ := by
rw [linfty_opNNNorm_def, Pi.nnnorm_def]
simp
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_col := linfty_opNNNorm_col
@[simp]
theorem linfty_opNorm_col (v : m → α) : ‖col ι v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_col v
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_col := linfty_opNorm_col
@[simp]
theorem linfty_opNNNorm_row (v : n → α) : ‖row ι v‖₊ = ∑ i, ‖v i‖₊ := by
simp [linfty_opNNNorm_def]
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_row := linfty_opNNNorm_row
@[simp]
theorem linfty_opNorm_row (v : n → α) : ‖row ι v‖ = ∑ i, ‖v i‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_row v).trans <| by simp [NNReal.coe_sum]
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_row := linfty_opNorm_row
@[simp]
theorem linfty_opNNNorm_diagonal [DecidableEq m] (v : m → α) : ‖diagonal v‖₊ = ‖v‖₊ := by
rw [linfty_opNNNorm_def, Pi.nnnorm_def]
congr 1 with i : 1
refine (Finset.sum_eq_single_of_mem _ (Finset.mem_univ i) fun j _hj hij => ?_).trans ?_
· rw [diagonal_apply_ne' _ hij, nnnorm_zero]
· rw [diagonal_apply_eq]
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_diagonal := linfty_opNNNorm_diagonal
@[simp]
theorem linfty_opNorm_diagonal [DecidableEq m] (v : m → α) : ‖diagonal v‖ = ‖v‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| linfty_opNNNorm_diagonal v
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_diagonal := linfty_opNorm_diagonal
end SeminormedAddCommGroup
section NonUnitalSeminormedRing
variable [NonUnitalSeminormedRing α]
theorem linfty_opNNNorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖₊ ≤ ‖A‖₊ * ‖B‖₊ := by
simp_rw [linfty_opNNNorm_def, Matrix.mul_apply]
calc
(Finset.univ.sup fun i => ∑ k, ‖∑ j, A i j * B j k‖₊) ≤
Finset.univ.sup fun i => ∑ k, ∑ j, ‖A i j‖₊ * ‖B j k‖₊ :=
Finset.sup_mono_fun fun i _hi =>
Finset.sum_le_sum fun k _hk => nnnorm_sum_le_of_le _ fun j _hj => nnnorm_mul_le _ _
_ = Finset.univ.sup fun i => ∑ j, ‖A i j‖₊ * ∑ k, ‖B j k‖₊ := by
simp_rw [@Finset.sum_comm m, Finset.mul_sum]
_ ≤ Finset.univ.sup fun i => ∑ j, ‖A i j‖₊ * Finset.univ.sup fun i => ∑ j, ‖B i j‖₊ := by
refine Finset.sup_mono_fun fun i _hi => ?_
gcongr with j hj
exact Finset.le_sup (f := fun i ↦ ∑ k : n, ‖B i k‖₊) hj
_ ≤ (Finset.univ.sup fun i => ∑ j, ‖A i j‖₊) * Finset.univ.sup fun i => ∑ j, ‖B i j‖₊ := by
simp_rw [← Finset.sum_mul, ← NNReal.finset_sup_mul]
rfl
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_mul := linfty_opNNNorm_mul
theorem linfty_opNorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖ ≤ ‖A‖ * ‖B‖ :=
linfty_opNNNorm_mul _ _
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_mul := linfty_opNorm_mul
theorem linfty_opNNNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖₊ ≤ ‖A‖₊ * ‖v‖₊ := by
rw [← linfty_opNNNorm_col (ι := Fin 1) (A *ᵥ v), ← linfty_opNNNorm_col v (ι := Fin 1)]
exact linfty_opNNNorm_mul A (col (Fin 1) v)
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_mulVec := linfty_opNNNorm_mulVec
theorem linfty_opNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖ ≤ ‖A‖ * ‖v‖ :=
linfty_opNNNorm_mulVec _ _
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_mulVec := linfty_opNorm_mulVec
end NonUnitalSeminormedRing
/-- Seminormed non-unital ring instance (using sup norm of L1 norm) for matrices over a semi normed
non-unital ring. Not declared as an instance because there are several natural choices for defining
the norm of a matrix. -/
@[local instance]
protected def linftyOpNonUnitalSemiNormedRing [NonUnitalSeminormedRing α] :
NonUnitalSeminormedRing (Matrix n n α) :=
{ Matrix.linftyOpSeminormedAddCommGroup, Matrix.instNonUnitalRing with
norm_mul := linfty_opNorm_mul }
/-- The `L₁-L∞` norm preserves one on non-empty matrices. Note this is safe as an instance, as it
carries no data. -/
instance linfty_opNormOneClass [SeminormedRing α] [NormOneClass α] [DecidableEq n] [Nonempty n] :
NormOneClass (Matrix n n α) where norm_one := (linfty_opNorm_diagonal _).trans norm_one
/-- Seminormed ring instance (using sup norm of L1 norm) for matrices over a semi normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpSemiNormedRing [SeminormedRing α] [DecidableEq n] :
SeminormedRing (Matrix n n α) :=
{ Matrix.linftyOpNonUnitalSemiNormedRing, Matrix.instRing with }
/-- Normed non-unital ring instance (using sup norm of L1 norm) for matrices over a normed
non-unital ring. Not declared as an instance because there are several natural choices for defining
the norm of a matrix. -/
@[local instance]
protected def linftyOpNonUnitalNormedRing [NonUnitalNormedRing α] :
NonUnitalNormedRing (Matrix n n α) :=
{ Matrix.linftyOpNonUnitalSemiNormedRing with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
/-- Normed ring instance (using sup norm of L1 norm) for matrices over a normed ring. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedRing [NormedRing α] [DecidableEq n] : NormedRing (Matrix n n α) :=
{ Matrix.linftyOpSemiNormedRing with
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
/-- Normed algebra instance (using sup norm of L1 norm) for matrices over a normed algebra. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
protected def linftyOpNormedAlgebra [NormedField R] [SeminormedRing α] [NormedAlgebra R α]
[DecidableEq n] : NormedAlgebra R (Matrix n n α) :=
{ Matrix.linftyOpNormedSpace, Matrix.instAlgebra with }
section
variable [NormedDivisionRing α] [NormedAlgebra ℝ α]
/-- Auxiliary construction; an element of norm 1 such that `a * unitOf a = ‖a‖`. -/
private def unitOf (a : α) : α := by classical exact if a = 0 then 1 else ‖a‖ • a⁻¹
private theorem norm_unitOf (a : α) : ‖unitOf a‖₊ = 1 := by
rw [unitOf]
split_ifs with h
· simp
· rw [← nnnorm_eq_zero] at h
rw [nnnorm_smul, nnnorm_inv, nnnorm_norm, mul_inv_cancel h]
private theorem mul_unitOf (a : α) : a * unitOf a = algebraMap _ _ (‖a‖₊ : ℝ) := by
simp only [unitOf, coe_nnnorm]
split_ifs with h
· simp [h]
· rw [mul_smul_comm, mul_inv_cancel h, Algebra.algebraMap_eq_smul_one]
end
/-!
For a matrix over a field, the norm defined in this section agrees with the operator norm on
`ContinuousLinearMap`s between function types (which have the infinity norm).
-/
section
variable [NontriviallyNormedField α] [NormedAlgebra ℝ α]
lemma linfty_opNNNorm_eq_opNNNorm (A : Matrix m n α) :
‖A‖₊ = ‖ContinuousLinearMap.mk (Matrix.mulVecLin A)‖₊ := by
rw [ContinuousLinearMap.opNNNorm_eq_of_bounds _ (linfty_opNNNorm_mulVec _) fun N hN => ?_]
rw [linfty_opNNNorm_def]
refine Finset.sup_le fun i _ => ?_
cases isEmpty_or_nonempty n
· simp
classical
let x : n → α := fun j => unitOf (A i j)
have hxn : ‖x‖₊ = 1 := by
simp_rw [x, Pi.nnnorm_def, norm_unitOf, Finset.sup_const Finset.univ_nonempty]
specialize hN x
rw [hxn, mul_one, Pi.nnnorm_def, Finset.sup_le_iff] at hN
replace hN := hN i (Finset.mem_univ _)
dsimp [mulVec, dotProduct] at hN
simp_rw [x, mul_unitOf, ← map_sum, nnnorm_algebraMap, ← NNReal.coe_sum, NNReal.nnnorm_eq,
nnnorm_one, mul_one] at hN
exact hN
@[deprecated (since := "2024-02-02")]
alias linfty_op_nnnorm_eq_op_nnnorm := linfty_opNNNorm_eq_opNNNorm
lemma linfty_opNorm_eq_opNorm (A : Matrix m n α) :
‖A‖ = ‖ContinuousLinearMap.mk (Matrix.mulVecLin A)‖ :=
congr_arg NNReal.toReal (linfty_opNNNorm_eq_opNNNorm A)
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_eq_op_norm := linfty_opNorm_eq_opNorm
variable [DecidableEq n]
@[simp] lemma linfty_opNNNorm_toMatrix (f : (n → α) →L[α] (m → α)) :
‖LinearMap.toMatrix' (↑f : (n → α) →ₗ[α] (m → α))‖₊ = ‖f‖₊ := by
rw [linfty_opNNNorm_eq_opNNNorm]
simp only [← toLin'_apply', toLin'_toMatrix']
@[deprecated (since := "2024-02-02")] alias linfty_op_nnnorm_toMatrix := linfty_opNNNorm_toMatrix
@[simp] lemma linfty_opNorm_toMatrix (f : (n → α) →L[α] (m → α)) :
‖LinearMap.toMatrix' (↑f : (n → α) →ₗ[α] (m → α))‖ = ‖f‖ :=
congr_arg NNReal.toReal (linfty_opNNNorm_toMatrix f)
@[deprecated (since := "2024-02-02")] alias linfty_op_norm_toMatrix := linfty_opNorm_toMatrix
end
end LinftyOp
/-! ### The Frobenius norm
This is defined as $\|A\| = \sqrt{\sum_{i,j} \|A_{ij}\|^2}$.
When the matrix is over the real or complex numbers, this norm is submultiplicative.
-/
section frobenius
open scoped Matrix
/-- Seminormed group instance (using frobenius norm) for matrices over a seminormed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusSeminormedAddCommGroup [SeminormedAddCommGroup α] :
SeminormedAddCommGroup (Matrix m n α) :=
inferInstanceAs (SeminormedAddCommGroup (PiLp 2 fun _i : m => PiLp 2 fun _j : n => α))
/-- Normed group instance (using frobenius norm) for matrices over a normed group. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedAddCommGroup [NormedAddCommGroup α] : NormedAddCommGroup (Matrix m n α) :=
(by infer_instance : NormedAddCommGroup (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
/-- This applies to the frobenius norm. -/
@[local instance]
theorem frobeniusBoundedSMul [SeminormedRing R] [SeminormedAddCommGroup α] [Module R α]
[BoundedSMul R α] :
BoundedSMul R (Matrix m n α) :=
(by infer_instance : BoundedSMul R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
/-- Normed space instance (using frobenius norm) for matrices over a normed space. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedSpace [NormedField R] [SeminormedAddCommGroup α] [NormedSpace R α] :
NormedSpace R (Matrix m n α) :=
(by infer_instance : NormedSpace R (PiLp 2 fun i : m => PiLp 2 fun j : n => α))
section SeminormedAddCommGroup
variable [SeminormedAddCommGroup α] [SeminormedAddCommGroup β]
theorem frobenius_nnnorm_def (A : Matrix m n α) :
‖A‖₊ = (∑ i, ∑ j, ‖A i j‖₊ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) := by
-- Porting note: added, along with `WithLp.equiv_symm_pi_apply` below
change ‖(WithLp.equiv 2 _).symm fun i => (WithLp.equiv 2 _).symm fun j => A i j‖₊ = _
simp_rw [PiLp.nnnorm_eq_of_L2, NNReal.sq_sqrt, NNReal.sqrt_eq_rpow, NNReal.rpow_two,
WithLp.equiv_symm_pi_apply]
theorem frobenius_norm_def (A : Matrix m n α) :
‖A‖ = (∑ i, ∑ j, ‖A i j‖ ^ (2 : ℝ)) ^ (1 / 2 : ℝ) :=
(congr_arg ((↑) : ℝ≥0 → ℝ) (frobenius_nnnorm_def A)).trans <| by simp [NNReal.coe_sum]
@[simp]
theorem frobenius_nnnorm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖₊ = ‖a‖₊) :
‖A.map f‖₊ = ‖A‖₊ := by simp_rw [frobenius_nnnorm_def, Matrix.map_apply, hf]
@[simp]
theorem frobenius_norm_map_eq (A : Matrix m n α) (f : α → β) (hf : ∀ a, ‖f a‖ = ‖a‖) :
‖A.map f‖ = ‖A‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_map_eq A f fun a => Subtype.ext <| hf a : _)
@[simp]
theorem frobenius_nnnorm_transpose (A : Matrix m n α) : ‖Aᵀ‖₊ = ‖A‖₊ := by
rw [frobenius_nnnorm_def, frobenius_nnnorm_def, Finset.sum_comm]
simp_rw [Matrix.transpose_apply] -- Porting note: added
@[simp]
theorem frobenius_norm_transpose (A : Matrix m n α) : ‖Aᵀ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_transpose A
@[simp]
theorem frobenius_nnnorm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖₊ = ‖A‖₊ :=
(frobenius_nnnorm_map_eq _ _ nnnorm_star).trans A.frobenius_nnnorm_transpose
@[simp]
theorem frobenius_norm_conjTranspose [StarAddMonoid α] [NormedStarGroup α] (A : Matrix m n α) :
‖Aᴴ‖ = ‖A‖ :=
congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_conjTranspose A
instance frobenius_normedStarGroup [StarAddMonoid α] [NormedStarGroup α] :
NormedStarGroup (Matrix m m α) :=
⟨frobenius_norm_conjTranspose⟩
@[simp]
theorem frobenius_norm_row (v : m → α) : ‖row ι v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [row_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
@[simp]
theorem frobenius_nnnorm_row (v : m → α) : ‖row ι v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_row v
@[simp]
theorem frobenius_norm_col (v : n → α) : ‖col ι v‖ = ‖(WithLp.equiv 2 _).symm v‖ := by
simp_rw [frobenius_norm_def, Fintype.sum_unique, PiLp.norm_eq_of_L2, Real.sqrt_eq_rpow]
simp only [col_apply, Real.rpow_two, WithLp.equiv_symm_pi_apply]
@[simp]
theorem frobenius_nnnorm_col (v : n → α) : ‖col ι v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ :=
Subtype.ext <| frobenius_norm_col v
@[simp]
theorem frobenius_nnnorm_diagonal [DecidableEq n] (v : n → α) :
‖diagonal v‖₊ = ‖(WithLp.equiv 2 _).symm v‖₊ := by
simp_rw [frobenius_nnnorm_def, ← Finset.sum_product', Finset.univ_product_univ,
PiLp.nnnorm_eq_of_L2]
let s := (Finset.univ : Finset n).map ⟨fun i : n => (i, i), fun i j h => congr_arg Prod.fst h⟩
rw [← Finset.sum_subset (Finset.subset_univ s) fun i _hi his => ?_]
· rw [Finset.sum_map, NNReal.sqrt_eq_rpow]
dsimp
simp_rw [diagonal_apply_eq, NNReal.rpow_two]
· suffices i.1 ≠ i.2 by rw [diagonal_apply_ne _ this, nnnorm_zero, NNReal.zero_rpow two_ne_zero]
intro h
exact Finset.mem_map.not.mp his ⟨i.1, Finset.mem_univ _, Prod.ext rfl h⟩
@[simp]
theorem frobenius_norm_diagonal [DecidableEq n] (v : n → α) :
‖diagonal v‖ = ‖(WithLp.equiv 2 _).symm v‖ :=
(congr_arg ((↑) : ℝ≥0 → ℝ) <| frobenius_nnnorm_diagonal v : _).trans rfl
end SeminormedAddCommGroup
theorem frobenius_nnnorm_one [DecidableEq n] [SeminormedAddCommGroup α] [One α] :
‖(1 : Matrix n n α)‖₊ = NNReal.sqrt (Fintype.card n) * ‖(1 : α)‖₊ := by
refine (frobenius_nnnorm_diagonal _).trans ?_
-- Porting note: change to erw, since `fun x => 1` no longer matches `Function.const`
erw [PiLp.nnnorm_equiv_symm_const ENNReal.two_ne_top]
simp_rw [NNReal.sqrt_eq_rpow]
-- Porting note: added `ENNReal.toReal_ofNat`
simp only [ENNReal.toReal_div, ENNReal.one_toReal, ENNReal.toReal_ofNat]
section RCLike
variable [RCLike α]
theorem frobenius_nnnorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖₊ ≤ ‖A‖₊ * ‖B‖₊ := by
simp_rw [frobenius_nnnorm_def, Matrix.mul_apply]
rw [← NNReal.mul_rpow, @Finset.sum_comm _ _ m, Finset.sum_mul_sum]
gcongr with i _ j
rw [← NNReal.rpow_le_rpow_iff one_half_pos, ← NNReal.rpow_mul,
mul_div_cancel₀ (1 : ℝ) two_ne_zero, NNReal.rpow_one, NNReal.mul_rpow]
have :=
@nnnorm_inner_le_nnnorm α _ _ _ _ ((WithLp.equiv 2 <| _ → α).symm fun j => star (A i j))
((WithLp.equiv 2 <| _ → α).symm fun k => B k j)
simpa only [WithLp.equiv_symm_pi_apply, PiLp.inner_apply, RCLike.inner_apply, starRingEnd_apply,
Pi.nnnorm_def, PiLp.nnnorm_eq_of_L2, star_star, nnnorm_star, NNReal.sqrt_eq_rpow,
NNReal.rpow_two] using this
theorem frobenius_norm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖ ≤ ‖A‖ * ‖B‖ :=
frobenius_nnnorm_mul A B
/-- Normed ring instance (using frobenius norm) for matrices over `ℝ` or `ℂ`. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedRing [DecidableEq m] : NormedRing (Matrix m m α) :=
{ Matrix.frobeniusSeminormedAddCommGroup, Matrix.instRing with
norm := Norm.norm
norm_mul := frobenius_norm_mul
eq_of_dist_eq_zero := eq_of_dist_eq_zero }
/-- Normed algebra instance (using frobenius norm) for matrices over `ℝ` or `ℂ`. Not
declared as an instance because there are several natural choices for defining the norm of a
matrix. -/
@[local instance]
def frobeniusNormedAlgebra [DecidableEq m] [NormedField R] [NormedAlgebra R α] :
NormedAlgebra R (Matrix m m α) :=
{ Matrix.frobeniusNormedSpace, Matrix.instAlgebra with }
end RCLike
end frobenius
end Matrix
|
Analysis\MeanInequalities.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Data.Real.ConjExponents
/-!
# Mean value inequalities
In this file we prove several inequalities for finite sums, including AM-GM inequality,
HM-GM inequality, Young's inequality, Hölder inequality, and Minkowski inequality. Versions for
integrals of some of these inequalities are available in `MeasureTheory.MeanInequalities`.
## Main theorems
### AM-GM inequality:
The inequality says that the geometric mean of a tuple of non-negative numbers is less than or equal
to their arithmetic mean. We prove the weighted version of this inequality: if $w$ and $z$
are two non-negative vectors and $\sum_{i\in s} w_i=1$, then
$$
\prod_{i\in s} z_i^{w_i} ≤ \sum_{i\in s} w_iz_i.
$$
The classical version is a special case of this inequality for $w_i=\frac{1}{n}$.
We prove a few versions of this inequality. Each of the following lemmas comes in two versions:
a version for real-valued non-negative functions is in the `Real` namespace, and a version for
`NNReal`-valued functions is in the `NNReal` namespace.
- `geom_mean_le_arith_mean_weighted` : weighted version for functions on `Finset`s;
- `geom_mean_le_arith_mean2_weighted` : weighted version for two numbers;
- `geom_mean_le_arith_mean3_weighted` : weighted version for three numbers;
- `geom_mean_le_arith_mean4_weighted` : weighted version for four numbers.
### HM-GM inequality:
The inequality says that the harmonic mean of a tuple of positive numbers is less than or equal
to their geometric mean. We prove the weighted version of this inequality: if $w$ and $z$
are two positive vectors and $\sum_{i\in s} w_i=1$, then
$$
1/(\sum_{i\in s} w_i/z_i) ≤ \prod_{i\in s} z_i^{w_i}
$$
The classical version is proven as a special case of this inequality for $w_i=\frac{1}{n}$.
The inequalities are proven only for real valued positive functions on `Finset`s, and namespaced in
`Real`. The weighted version follows as a corollary of the weighted AM-GM inequality.
### Young's inequality
Young's inequality says that for non-negative numbers `a`, `b`, `p`, `q` such that
$\frac{1}{p}+\frac{1}{q}=1$ we have
$$
ab ≤ \frac{a^p}{p} + \frac{b^q}{q}.
$$
This inequality is a special case of the AM-GM inequality. It is then used to prove Hölder's
inequality (see below).
### Hölder's inequality
The inequality says that for two conjugate exponents `p` and `q` (i.e., for two positive numbers
such that $\frac{1}{p}+\frac{1}{q}=1$) and any two non-negative vectors their inner product is
less than or equal to the product of the $L_p$ norm of the first vector and the $L_q$ norm of the
second vector:
$$
\sum_{i\in s} a_ib_i ≤ \sqrt[p]{\sum_{i\in s} a_i^p}\sqrt[q]{\sum_{i\in s} b_i^q}.
$$
We give versions of this result in `ℝ`, `ℝ≥0` and `ℝ≥0∞`.
There are at least two short proofs of this inequality. In our proof we prenormalize both vectors,
then apply Young's inequality to each $a_ib_i$. Another possible proof would be to deduce this
inequality from the generalized mean inequality for well-chosen vectors and weights.
### Minkowski's inequality
The inequality says that for `p ≥ 1` the function
$$
\|a\|_p=\sqrt[p]{\sum_{i\in s} a_i^p}
$$
satisfies the triangle inequality $\|a+b\|_p\le \|a\|_p+\|b\|_p$.
We give versions of this result in `Real`, `ℝ≥0` and `ℝ≥0∞`.
We deduce this inequality from Hölder's inequality. Namely, Hölder inequality implies that $\|a\|_p$
is the maximum of the inner product $\sum_{i\in s}a_ib_i$ over `b` such that $\|b\|_q\le 1$. Now
Minkowski's inequality follows from the fact that the maximum value of the sum of two functions is
less than or equal to the sum of the maximum values of the summands.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `StrictConvexOn` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
-/
universe u v
open Finset NNReal ENNReal
noncomputable section
variable {ι : Type u} (s : Finset ι)
section GeomMeanLEArithMean
/-! ### AM-GM inequality -/
namespace Real
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for real-valued nonnegative functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) :
∏ i ∈ s, z i ^ w i ≤ ∑ i ∈ s, w i * z i := by
-- If some number `z i` equals zero and has non-zero weight, then LHS is 0 and RHS is nonnegative.
by_cases A : ∃ i ∈ s, z i = 0 ∧ w i ≠ 0
· rcases A with ⟨i, his, hzi, hwi⟩
rw [prod_eq_zero his]
· exact sum_nonneg fun j hj => mul_nonneg (hw j hj) (hz j hj)
· rw [hzi]
exact zero_rpow hwi
-- If all numbers `z i` with non-zero weight are positive, then we apply Jensen's inequality
-- for `exp` and numbers `log (z i)` with weights `w i`.
· simp only [not_exists, not_and, Ne, Classical.not_not] at A
have := convexOn_exp.map_sum_le hw hw' fun i _ => Set.mem_univ <| log (z i)
simp only [exp_sum, (· ∘ ·), smul_eq_mul, mul_comm (w _) (log _)] at this
convert this using 1 <;> [apply prod_congr rfl;apply sum_congr rfl] <;> intro i hi
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· exact rpow_def_of_pos hz _
· cases' eq_or_lt_of_le (hz i hi) with hz hz
· simp [A i hi hz.symm]
· rw [exp_log hz]
/-- **AM-GM inequality**: The **geometric mean is less than or equal to the arithmetic mean. --/
theorem geom_mean_le_arith_mean {ι : Type*} (s : Finset ι) (w : ι → ℝ) (z : ι → ℝ)
(hw : ∀ i ∈ s, 0 ≤ w i) (hw' : 0 < ∑ i ∈ s, w i) (hz : ∀ i ∈ s, 0 ≤ z i) :
(∏ i ∈ s, z i ^ w i) ^ (∑ i ∈ s, w i)⁻¹ ≤ (∑ i ∈ s, w i * z i) / (∑ i ∈ s, w i) := by
convert geom_mean_le_arith_mean_weighted s (fun i => (w i) / ∑ i ∈ s, w i) z ?_ ?_ hz using 2
· rw [← finset_prod_rpow _ _ (fun i hi => rpow_nonneg (hz _ hi) _) _]
refine Finset.prod_congr rfl (fun _ ih => ?_)
rw [div_eq_mul_inv, rpow_mul (hz _ ih)]
· simp_rw [div_eq_mul_inv, mul_assoc, mul_comm, ← mul_assoc, ← Finset.sum_mul, mul_comm]
· exact fun _ hi => div_nonneg (hw _ hi) (le_of_lt hw')
· simp_rw [div_eq_mul_inv, ← Finset.sum_mul]
exact mul_inv_cancel (by linarith)
theorem geom_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = x :=
calc
∏ i ∈ s, z i ^ w i = ∏ i ∈ s, x ^ w i := by
refine prod_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with h₀ | h₀
· rw [h₀, rpow_zero, rpow_zero]
· rw [hx i hi h₀]
_ = x := by
rw [← rpow_sum_of_nonneg _ hw, hw', rpow_one]
have : (∑ i ∈ s, w i) ≠ 0 := by
rw [hw']
exact one_ne_zero
obtain ⟨i, his, hi⟩ := exists_ne_zero_of_sum_ne_zero this
rw [← hx i his hi]
exact hz i his
theorem arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw' : ∑ i ∈ s, w i = 1)
(hx : ∀ i ∈ s, w i ≠ 0 → z i = x) : ∑ i ∈ s, w i * z i = x :=
calc
∑ i ∈ s, w i * z i = ∑ i ∈ s, w i * x := by
refine sum_congr rfl fun i hi => ?_
rcases eq_or_ne (w i) 0 with hwi | hwi
· rw [hwi, zero_mul, zero_mul]
· rw [hx i hi hwi]
_ = x := by rw [← sum_mul, hw', one_mul]
theorem geom_mean_eq_arith_mean_weighted_of_constant (w z : ι → ℝ) (x : ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (hx : ∀ i ∈ s, w i ≠ 0 → z i = x) :
∏ i ∈ s, z i ^ w i = ∑ i ∈ s, w i * z i := by
rw [geom_mean_weighted_of_constant, arith_mean_weighted_of_constant] <;> assumption
end Real
namespace NNReal
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for `NNReal`-valued functions. -/
theorem geom_mean_le_arith_mean_weighted (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) :
(∏ i ∈ s, z i ^ (w i : ℝ)) ≤ ∑ i ∈ s, w i * z i :=
mod_cast
Real.geom_mean_le_arith_mean_weighted _ _ _ (fun i _ => (w i).coe_nonneg)
(by assumption_mod_cast) fun i _ => (z i).coe_nonneg
/-- **AM-GM inequality**: The geometric mean is less than or equal to the arithmetic mean, weighted
version for two `NNReal` numbers. -/
theorem geom_mean_le_arith_mean2_weighted (w₁ w₂ p₁ p₂ : ℝ≥0) :
w₁ + w₂ = 1 → p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one] using
geom_mean_le_arith_mean_weighted univ ![w₁, w₂] ![p₁, p₂]
theorem geom_mean_le_arith_mean3_weighted (w₁ w₂ w₃ p₁ p₂ p₃ : ℝ≥0) :
w₁ + w₂ + w₃ = 1 →
p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one, ← add_assoc,
mul_assoc] using geom_mean_le_arith_mean_weighted univ ![w₁, w₂, w₃] ![p₁, p₂, p₃]
theorem geom_mean_le_arith_mean4_weighted (w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ≥0) :
w₁ + w₂ + w₃ + w₄ = 1 →
p₁ ^ (w₁ : ℝ) * p₂ ^ (w₂ : ℝ) * p₃ ^ (w₃ : ℝ) * p₄ ^ (w₄ : ℝ) ≤
w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ := by
simpa only [Fin.prod_univ_succ, Fin.sum_univ_succ, Finset.prod_empty, Finset.sum_empty,
Finset.univ_eq_empty, Fin.cons_succ, Fin.cons_zero, add_zero, mul_one, ← add_assoc,
mul_assoc] using geom_mean_le_arith_mean_weighted univ ![w₁, w₂, w₃, w₄] ![p₁, p₂, p₃, p₄]
end NNReal
namespace Real
theorem geom_mean_le_arith_mean2_weighted {w₁ w₂ p₁ p₂ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hw : w₁ + w₂ = 1) : p₁ ^ w₁ * p₂ ^ w₂ ≤ w₁ * p₁ + w₂ * p₂ :=
NNReal.geom_mean_le_arith_mean2_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ <|
NNReal.coe_inj.1 <| by assumption
theorem geom_mean_le_arith_mean3_weighted {w₁ w₂ w₃ p₁ p₂ p₃ : ℝ} (hw₁ : 0 ≤ w₁) (hw₂ : 0 ≤ w₂)
(hw₃ : 0 ≤ w₃) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃) (hw : w₁ + w₂ + w₃ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ :=
NNReal.geom_mean_le_arith_mean3_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩
⟨p₃, hp₃⟩ <|
NNReal.coe_inj.1 hw
theorem geom_mean_le_arith_mean4_weighted {w₁ w₂ w₃ w₄ p₁ p₂ p₃ p₄ : ℝ} (hw₁ : 0 ≤ w₁)
(hw₂ : 0 ≤ w₂) (hw₃ : 0 ≤ w₃) (hw₄ : 0 ≤ w₄) (hp₁ : 0 ≤ p₁) (hp₂ : 0 ≤ p₂) (hp₃ : 0 ≤ p₃)
(hp₄ : 0 ≤ p₄) (hw : w₁ + w₂ + w₃ + w₄ = 1) :
p₁ ^ w₁ * p₂ ^ w₂ * p₃ ^ w₃ * p₄ ^ w₄ ≤ w₁ * p₁ + w₂ * p₂ + w₃ * p₃ + w₄ * p₄ :=
NNReal.geom_mean_le_arith_mean4_weighted ⟨w₁, hw₁⟩ ⟨w₂, hw₂⟩ ⟨w₃, hw₃⟩ ⟨w₄, hw₄⟩ ⟨p₁, hp₁⟩
⟨p₂, hp₂⟩ ⟨p₃, hp₃⟩ ⟨p₄, hp₄⟩ <|
NNReal.coe_inj.1 <| by assumption
end Real
end GeomMeanLEArithMean
section HarmMeanLEGeomMean
/-! ### HM-GM inequality -/
namespace Real
/-- **HM-GM inequality**: The harmonic mean is less than or equal to the geometric mean, weighted
version for real-valued nonnegative functions. -/
theorem harm_mean_le_geom_mean_weighted (w z : ι → ℝ) (hs : s.Nonempty) (hw : ∀ i ∈ s, 0 < w i)
(hw' : ∑ i in s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) :
(∑ i in s, w i / z i)⁻¹ ≤ ∏ i in s, z i ^ w i := by
have : ∏ i in s, (1 / z) i ^ w i ≤ ∑ i in s, w i * (1 / z) i :=
geom_mean_le_arith_mean_weighted s w (1/z) (fun i hi ↦ le_of_lt (hw i hi)) hw'
(fun i hi ↦ one_div_nonneg.2 (le_of_lt (hz i hi)))
have p_pos : 0 < ∏ i in s, (z i)⁻¹ ^ w i :=
prod_pos fun i hi => rpow_pos_of_pos (inv_pos.2 (hz i hi)) _
have s_pos : 0 < ∑ i in s, w i * (z i)⁻¹ :=
sum_pos (fun i hi => Real.mul_pos (hw i hi) (inv_pos.2 (hz i hi))) hs
norm_num at this
rw [← inv_le_inv s_pos p_pos] at this
apply le_trans this
have p_pos₂ : 0 < (∏ i in s, (z i) ^ w i)⁻¹ :=
inv_pos.2 (prod_pos fun i hi => rpow_pos_of_pos ((hz i hi)) _ )
rw [← inv_inv (∏ i in s, z i ^ w i), inv_le_inv p_pos p_pos₂, ← Finset.prod_inv_distrib]
gcongr
· exact fun i hi ↦ inv_nonneg.mpr (Real.rpow_nonneg (le_of_lt (hz i hi)) _)
· rw [Real.inv_rpow]; apply fun i hi ↦ le_of_lt (hz i hi); assumption
/-- **HM-GM inequality**: The **harmonic mean is less than or equal to the geometric mean. --/
theorem harm_mean_le_geom_mean {ι : Type*} (s : Finset ι) (hs : s.Nonempty) (w : ι → ℝ)
(z : ι → ℝ) (hw : ∀ i ∈ s, 0 < w i) (hw' : 0 < ∑ i in s, w i) (hz : ∀ i ∈ s, 0 < z i) :
(∑ i in s, w i) / (∑ i in s, w i / z i) ≤ (∏ i in s, z i ^ w i) ^ (∑ i in s, w i)⁻¹ := by
have := harm_mean_le_geom_mean_weighted s (fun i => (w i) / ∑ i in s, w i) z hs ?_ ?_ hz
· simp only at this
set n := ∑ i in s, w i
nth_rw 1 [div_eq_mul_inv, (show n = (n⁻¹)⁻¹ by norm_num), ← mul_inv, Finset.mul_sum _ _ n⁻¹]
simp_rw [inv_mul_eq_div n ((w _)/(z _)), div_right_comm _ _ n]
convert this
rw [← Real.finset_prod_rpow s _ (fun i hi ↦ Real.rpow_nonneg (le_of_lt <| hz i hi) _)]
refine Finset.prod_congr rfl (fun i hi => ?_)
rw [← Real.rpow_mul (le_of_lt <| hz i hi) (w _) n⁻¹, div_eq_mul_inv (w _) n]
· exact fun i hi ↦ div_pos (hw i hi) hw'
· simp_rw [div_eq_mul_inv (w _) (∑ i in s, w i), ← Finset.sum_mul _ _ (∑ i in s, w i)⁻¹]
exact mul_inv_cancel hw'.ne'
end Real
end HarmMeanLEGeomMean
section Young
/-! ### Young's inequality -/
namespace Real
/-- **Young's inequality**, a version for nonnegative real numbers. -/
theorem young_inequality_of_nonneg {a b p q : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b)
(hpq : p.IsConjExponent q) : a * b ≤ a ^ p / p + b ^ q / q := by
simpa [← rpow_mul, ha, hb, hpq.ne_zero, hpq.symm.ne_zero, _root_.div_eq_inv_mul] using
geom_mean_le_arith_mean2_weighted hpq.inv_nonneg hpq.symm.inv_nonneg
(rpow_nonneg ha p) (rpow_nonneg hb q) hpq.inv_add_inv_conj
/-- **Young's inequality**, a version for arbitrary real numbers. -/
theorem young_inequality (a b : ℝ) {p q : ℝ} (hpq : p.IsConjExponent q) :
a * b ≤ |a| ^ p / p + |b| ^ q / q :=
calc
a * b ≤ |a * b| := le_abs_self (a * b)
_ = |a| * |b| := abs_mul a b
_ ≤ |a| ^ p / p + |b| ^ q / q :=
Real.young_inequality_of_nonneg (abs_nonneg a) (abs_nonneg b) hpq
end Real
namespace NNReal
/-- **Young's inequality**, `ℝ≥0` version. We use `{p q : ℝ≥0}` in order to avoid constructing
witnesses of `0 ≤ p` and `0 ≤ q` for the denominators. -/
theorem young_inequality (a b : ℝ≥0) {p q : ℝ≥0} (hpq : p.IsConjExponent q) :
a * b ≤ a ^ (p : ℝ) / p + b ^ (q : ℝ) / q :=
Real.young_inequality_of_nonneg a.coe_nonneg b.coe_nonneg hpq.coe
/-- **Young's inequality**, `ℝ≥0` version with real conjugate exponents. -/
theorem young_inequality_real (a b : ℝ≥0) {p q : ℝ} (hpq : p.IsConjExponent q) :
a * b ≤ a ^ p / Real.toNNReal p + b ^ q / Real.toNNReal q := by
simpa [Real.coe_toNNReal, hpq.nonneg, hpq.symm.nonneg] using young_inequality a b hpq.toNNReal
end NNReal
namespace ENNReal
/-- **Young's inequality**, `ℝ≥0∞` version with real conjugate exponents. -/
theorem young_inequality (a b : ℝ≥0∞) {p q : ℝ} (hpq : p.IsConjExponent q) :
a * b ≤ a ^ p / ENNReal.ofReal p + b ^ q / ENNReal.ofReal q := by
by_cases h : a = ⊤ ∨ b = ⊤
· refine le_trans le_top (le_of_eq ?_)
repeat rw [div_eq_mul_inv]
cases' h with h h <;> rw [h] <;> simp [h, hpq.pos, hpq.symm.pos]
push_neg at h
-- if a ≠ ⊤ and b ≠ ⊤, use the nnreal version: nnreal.young_inequality_real
rw [← coe_toNNReal h.left, ← coe_toNNReal h.right, ← coe_mul, coe_rpow_of_nonneg _ hpq.nonneg,
coe_rpow_of_nonneg _ hpq.symm.nonneg, ENNReal.ofReal, ENNReal.ofReal, ←
@coe_div (Real.toNNReal p) _ (by simp [hpq.pos]), ←
@coe_div (Real.toNNReal q) _ (by simp [hpq.symm.pos]), ← coe_add, coe_le_coe]
exact NNReal.young_inequality_real a.toNNReal b.toNNReal hpq
end ENNReal
end Young
section HoelderMinkowski
/-! ### Hölder's and Minkowski's inequalities -/
namespace NNReal
private theorem inner_le_Lp_mul_Lp_of_norm_le_one (f g : ι → ℝ≥0) {p q : ℝ}
(hpq : p.IsConjExponent q) (hf : ∑ i ∈ s, f i ^ p ≤ 1) (hg : ∑ i ∈ s, g i ^ q ≤ 1) :
∑ i ∈ s, f i * g i ≤ 1 := by
have hp_ne_zero : Real.toNNReal p ≠ 0 := (zero_lt_one.trans hpq.toNNReal.one_lt).ne.symm
have hq_ne_zero : Real.toNNReal q ≠ 0 := (zero_lt_one.trans hpq.toNNReal.symm.one_lt).ne.symm
calc
∑ i ∈ s, f i * g i ≤ ∑ i ∈ s, (f i ^ p / Real.toNNReal p + g i ^ q / Real.toNNReal q) :=
Finset.sum_le_sum fun i _ => young_inequality_real (f i) (g i) hpq
_ = (∑ i ∈ s, f i ^ p) / Real.toNNReal p + (∑ i ∈ s, g i ^ q) / Real.toNNReal q := by
rw [sum_add_distrib, sum_div, sum_div]
_ ≤ 1 / Real.toNNReal p + 1 / Real.toNNReal q := by
refine add_le_add ?_ ?_
· rwa [div_le_iff hp_ne_zero, div_mul_cancel₀ _ hp_ne_zero]
· rwa [div_le_iff hq_ne_zero, div_mul_cancel₀ _ hq_ne_zero]
_ = 1 := by simp_rw [one_div, hpq.toNNReal.inv_add_inv_conj]
private theorem inner_le_Lp_mul_Lp_of_norm_eq_zero (f g : ι → ℝ≥0) {p q : ℝ}
(hpq : p.IsConjExponent q) (hf : ∑ i ∈ s, f i ^ p = 0) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
simp only [hf, hpq.ne_zero, one_div, sum_eq_zero_iff, zero_rpow, zero_mul,
inv_eq_zero, Ne, not_false_iff, le_zero_iff, mul_eq_zero]
intro i his
left
rw [sum_eq_zero_iff] at hf
exact (rpow_eq_zero_iff.mp (hf i his)).left
/-- **Hölder inequality**: The scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0`-valued functions. -/
theorem inner_le_Lp_mul_Lq (f g : ι → ℝ≥0) {p q : ℝ} (hpq : p.IsConjExponent q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
by_cases hF_zero : ∑ i ∈ s, f i ^ p = 0
· exact inner_le_Lp_mul_Lp_of_norm_eq_zero s f g hpq hF_zero
by_cases hG_zero : ∑ i ∈ s, g i ^ q = 0
· calc
∑ i ∈ s, f i * g i = ∑ i ∈ s, g i * f i := by
congr with i
rw [mul_comm]
_ ≤ (∑ i ∈ s, g i ^ q) ^ (1 / q) * (∑ i ∈ s, f i ^ p) ^ (1 / p) :=
(inner_le_Lp_mul_Lp_of_norm_eq_zero s g f hpq.symm hG_zero)
_ = (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := mul_comm _ _
let f' i := f i / (∑ i ∈ s, f i ^ p) ^ (1 / p)
let g' i := g i / (∑ i ∈ s, g i ^ q) ^ (1 / q)
suffices (∑ i ∈ s, f' i * g' i) ≤ 1 by
simp_rw [f', g', div_mul_div_comm, ← sum_div] at this
rwa [div_le_iff, one_mul] at this
refine mul_ne_zero ?_ ?_
· rw [Ne, rpow_eq_zero_iff, not_and_or]
exact Or.inl hF_zero
· rw [Ne, rpow_eq_zero_iff, not_and_or]
exact Or.inl hG_zero
refine inner_le_Lp_mul_Lp_of_norm_le_one s f' g' hpq (le_of_eq ?_) (le_of_eq ?_)
· simp_rw [f', div_rpow, ← sum_div, ← rpow_mul, one_div, inv_mul_cancel hpq.ne_zero, rpow_one,
div_self hF_zero]
· simp_rw [g', div_rpow, ← sum_div, ← rpow_mul, one_div, inv_mul_cancel hpq.symm.ne_zero,
rpow_one, div_self hG_zero]
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
obtain rfl | hp := hp.eq_or_lt
· simp
calc
_ = ∑ i ∈ s, w i ^ (1 - p⁻¹) * (w i ^ p⁻¹ * f i) := ?_
_ ≤ (∑ i ∈ s, (w i ^ (1 - p⁻¹)) ^ (1 - p⁻¹)⁻¹) ^ (1 / (1 - p⁻¹)⁻¹) *
(∑ i ∈ s, (w i ^ p⁻¹ * f i) ^ p) ^ (1 / p) :=
inner_le_Lp_mul_Lq _ _ _ (.symm ⟨hp, by simp⟩)
_ = _ := ?_
· congr with i
rw [← mul_assoc, ← rpow_of_add_eq _ one_ne_zero, rpow_one]
simp
· have hp₀ : p ≠ 0 := by positivity
have hp₁ : 1 - p⁻¹ ≠ 0 := by simp [sub_eq_zero, hp.ne']
simp [mul_rpow, div_inv_eq_mul, one_mul, one_div, hp₀, hp₁]
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_hasSum`. -/
theorem inner_le_Lp_mul_Lq_tsum {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.IsConjExponent q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
(Summable fun i => f i * g i) ∧
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
have H₁ : ∀ s : Finset ι,
∑ i ∈ s, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
intro s
refine le_trans (inner_le_Lp_mul_Lq s f g hpq) (mul_le_mul ?_ ?_ bot_le bot_le)
· rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr hpq.pos)]
exact sum_le_tsum _ (fun _ _ => zero_le _) hf
· rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr hpq.symm.pos)]
exact sum_le_tsum _ (fun _ _ => zero_le _) hg
have bdd : BddAbove (Set.range fun s => ∑ i ∈ s, f i * g i) := by
refine ⟨(∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q), ?_⟩
rintro a ⟨s, rfl⟩
exact H₁ s
have H₂ : Summable _ := (hasSum_of_isLUB _ (isLUB_ciSup bdd)).summable
exact ⟨H₂, tsum_le_of_sum_le H₂ H₁⟩
theorem summable_mul_of_Lp_Lq {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.IsConjExponent q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
Summable fun i => f i * g i :=
(inner_le_Lp_mul_Lq_tsum hpq hf hg).1
theorem inner_le_Lp_mul_Lq_tsum' {f g : ι → ℝ≥0} {p q : ℝ} (hpq : p.IsConjExponent q)
(hf : Summable fun i => f i ^ p) (hg : Summable fun i => g i ^ q) :
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=
(inner_le_Lp_mul_Lq_tsum hpq hf hg).2
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are not already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_tsum`. -/
theorem inner_le_Lp_mul_Lq_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p q : ℝ}
(hpq : p.IsConjExponent q) (hf : HasSum (fun i => f i ^ p) (A ^ p))
(hg : HasSum (fun i => g i ^ q) (B ^ q)) : ∃ C, C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by
obtain ⟨H₁, H₂⟩ := inner_le_Lp_mul_Lq_tsum hpq hf.summable hg.summable
have hA : A = (∑' i : ι, f i ^ p) ^ (1 / p) := by rw [hf.tsum_eq, rpow_inv_rpow_self hpq.ne_zero]
have hB : B = (∑' i : ι, g i ^ q) ^ (1 / q) := by
rw [hg.tsum_eq, rpow_inv_rpow_self hpq.symm.ne_zero]
refine ⟨∑' i, f i * g i, ?_, ?_⟩
· simpa [hA, hB] using H₂
· simpa only [rpow_self_rpow_inv hpq.ne_zero] using H₁.hasSum
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ≥0`-valued functions.
-/
theorem rpow_sum_le_const_mul_sum_rpow (f : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, f i) ^ p ≤ (card s : ℝ≥0) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
cases' eq_or_lt_of_le hp with hp hp
· simp [← hp]
let q : ℝ := p / (p - 1)
have hpq : p.IsConjExponent q := .conjExponent hp
have hp₁ : 1 / p * p = 1 := one_div_mul_cancel hpq.ne_zero
have hq : 1 / q * p = p - 1 := by
rw [← hpq.div_conj_eq_sub_one]
ring
simpa only [NNReal.mul_rpow, ← NNReal.rpow_mul, hp₁, hq, one_mul, one_rpow, rpow_one,
Pi.one_apply, sum_const, Nat.smul_one_eq_cast] using
NNReal.rpow_le_rpow (inner_le_Lp_mul_Lq s 1 f hpq.symm) hpq.nonneg
/-- The `L_p` seminorm of a vector `f` is the greatest value of the inner product
`∑ i ∈ s, f i * g i` over functions `g` of `L_q` seminorm less than or equal to one. -/
theorem isGreatest_Lp (f : ι → ℝ≥0) {p q : ℝ} (hpq : p.IsConjExponent q) :
IsGreatest ((fun g : ι → ℝ≥0 => ∑ i ∈ s, f i * g i) '' { g | ∑ i ∈ s, g i ^ q ≤ 1 })
((∑ i ∈ s, f i ^ p) ^ (1 / p)) := by
constructor
· use fun i => f i ^ p / f i / (∑ i ∈ s, f i ^ p) ^ (1 / q)
by_cases hf : ∑ i ∈ s, f i ^ p = 0
· simp [hf, hpq.ne_zero, hpq.symm.ne_zero]
· have A : p + q - q ≠ 0 := by simp [hpq.ne_zero]
have B : ∀ y : ℝ≥0, y * y ^ p / y = y ^ p := by
refine fun y => mul_div_cancel_left_of_imp fun h => ?_
simp [h, hpq.ne_zero]
simp only [Set.mem_setOf_eq, div_rpow, ← sum_div, ← rpow_mul,
div_mul_cancel₀ _ hpq.symm.ne_zero, rpow_one, div_le_iff hf, one_mul, hpq.mul_eq_add, ←
rpow_sub' _ A, add_sub_cancel_right, le_refl, true_and_iff, ← mul_div_assoc, B]
rw [div_eq_iff, ← rpow_add hf, one_div, one_div, hpq.inv_add_inv_conj, rpow_one]
simpa [hpq.symm.ne_zero] using hf
· rintro _ ⟨g, hg, rfl⟩
apply le_trans (inner_le_Lp_mul_Lq s f g hpq)
simpa only [mul_one] using
mul_le_mul_left' (NNReal.rpow_le_one hg (le_of_lt hpq.symm.one_div_pos)) _
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `NNReal`-valued functions. -/
theorem Lp_add_le (f g : ι → ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
-- The result is trivial when `p = 1`, so we can assume `1 < p`.
rcases eq_or_lt_of_le hp with (rfl | hp)
· simp [Finset.sum_add_distrib]
have hpq := Real.IsConjExponent.conjExponent hp
have := isGreatest_Lp s (f + g) hpq
simp only [Pi.add_apply, add_mul, sum_add_distrib] at this
rcases this.1 with ⟨φ, hφ, H⟩
rw [← H]
exact
add_le_add ((isGreatest_Lp s f hpq).2 ⟨φ, hφ, rfl⟩) ((isGreatest_Lp s g hpq).2 ⟨φ, hφ, rfl⟩)
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `NNReal`-valued functions. For an alternative version, convenient if the
infinite sums are already expressed as `p`-th powers, see `Lp_add_le_hasSum_of_nonneg`. -/
theorem Lp_add_le_tsum {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) :
(Summable fun i => (f i + g i) ^ p) ∧
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤
(∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by
have pos : 0 < p := lt_of_lt_of_le zero_lt_one hp
have H₁ : ∀ s : Finset ι,
(∑ i ∈ s, (f i + g i) ^ p) ≤
((∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p)) ^ p := by
intro s
rw [one_div, ← NNReal.rpow_inv_le_iff pos, ← one_div]
refine le_trans (Lp_add_le s f g hp) (add_le_add ?_ ?_) <;>
rw [NNReal.rpow_le_rpow_iff (one_div_pos.mpr pos)] <;>
refine sum_le_tsum _ (fun _ _ => zero_le _) ?_
exacts [hf, hg]
have bdd : BddAbove (Set.range fun s => ∑ i ∈ s, (f i + g i) ^ p) := by
refine ⟨((∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p)) ^ p, ?_⟩
rintro a ⟨s, rfl⟩
exact H₁ s
have H₂ : Summable _ := (hasSum_of_isLUB _ (isLUB_ciSup bdd)).summable
refine ⟨H₂, ?_⟩
rw [one_div, NNReal.rpow_inv_le_iff pos, ← one_div]
exact tsum_le_of_sum_le H₂ H₁
theorem summable_Lp_add {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) : Summable fun i => (f i + g i) ^ p :=
(Lp_add_le_tsum hp hf hg).1
theorem Lp_add_le_tsum' {f g : ι → ℝ≥0} {p : ℝ} (hp : 1 ≤ p) (hf : Summable fun i => f i ^ p)
(hg : Summable fun i => g i ^ p) :
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=
(Lp_add_le_tsum hp hf hg).2
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `NNReal`-valued functions. For an alternative version, convenient if the
infinite sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/
theorem Lp_add_le_hasSum {f g : ι → ℝ≥0} {A B : ℝ≥0} {p : ℝ} (hp : 1 ≤ p)
(hf : HasSum (fun i => f i ^ p) (A ^ p)) (hg : HasSum (fun i => g i ^ p) (B ^ p)) :
∃ C, C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by
have hp' : p ≠ 0 := (lt_of_lt_of_le zero_lt_one hp).ne'
obtain ⟨H₁, H₂⟩ := Lp_add_le_tsum hp hf.summable hg.summable
have hA : A = (∑' i : ι, f i ^ p) ^ (1 / p) := by rw [hf.tsum_eq, rpow_inv_rpow_self hp']
have hB : B = (∑' i : ι, g i ^ p) ^ (1 / p) := by rw [hg.tsum_eq, rpow_inv_rpow_self hp']
refine ⟨(∑' i, (f i + g i) ^ p) ^ (1 / p), ?_, ?_⟩
· simpa [hA, hB] using H₂
· simpa only [rpow_self_rpow_inv hp'] using H₁.hasSum
end NNReal
namespace Real
variable (f g : ι → ℝ) {p q : ℝ}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : IsConjExponent p q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, |f i| ^ p) ^ (1 / p) * (∑ i ∈ s, |g i| ^ q) ^ (1 / q) := by
have :=
NNReal.coe_le_coe.2
(NNReal.inner_le_Lp_mul_Lq s (fun i => ⟨_, abs_nonneg (f i)⟩) (fun i => ⟨_, abs_nonneg (g i)⟩)
hpq)
push_cast at this
refine le_trans (sum_le_sum fun i _ => ?_) this
simp only [← abs_mul, le_abs_self]
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ`-valued functions. -/
theorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :
(∑ i ∈ s, |f i|) ^ p ≤ (card s : ℝ) ^ (p - 1) * ∑ i ∈ s, |f i| ^ p := by
have :=
NNReal.coe_le_coe.2
(NNReal.rpow_sum_le_const_mul_sum_rpow s (fun i => ⟨_, abs_nonneg (f i)⟩) hp)
push_cast at this
exact this
-- for some reason `exact_mod_cast` can't replace this argument
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `Real`-valued functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i ∈ s, |f i + g i| ^ p) ^ (1 / p) ≤
(∑ i ∈ s, |f i| ^ p) ^ (1 / p) + (∑ i ∈ s, |g i| ^ p) ^ (1 / p) := by
have :=
NNReal.coe_le_coe.2
(NNReal.Lp_add_le s (fun i => ⟨_, abs_nonneg (f i)⟩) (fun i => ⟨_, abs_nonneg (g i)⟩) hp)
push_cast at this
refine le_trans (rpow_le_rpow ?_ (sum_le_sum fun i _ => ?_) ?_) this <;>
simp [sum_nonneg, rpow_nonneg, abs_nonneg, le_trans zero_le_one hp, abs_add,
rpow_le_rpow]
variable {f g}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with real-valued nonnegative functions. -/
theorem inner_le_Lp_mul_Lq_of_nonneg (hpq : IsConjExponent p q) (hf : ∀ i ∈ s, 0 ≤ f i)
(hg : ∀ i ∈ s, 0 ≤ g i) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
convert inner_le_Lp_mul_Lq s f g hpq using 3 <;> apply sum_congr rfl <;> intro i hi <;>
simp only [abs_of_nonneg, hf i hi, hg i hi]
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ)
(hw : ∀ i, 0 ≤ w i) (hf : ∀ i, 0 ≤ f i) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
lift w to ι → ℝ≥0 using hw
lift f to ι → ℝ≥0 using hf
beta_reduce at *
norm_cast at *
exact NNReal.inner_le_weight_mul_Lp _ hp _ _
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `ℝ`-valued functions.
For an alternative version, convenient if the infinite sums are already expressed as `p`-th powers,
see `inner_le_Lp_mul_Lq_hasSum_of_nonneg`. -/
theorem inner_le_Lp_mul_Lq_tsum_of_nonneg (hpq : p.IsConjExponent q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
(Summable fun i => f i * g i) ∧
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
-- After leanprover/lean4#2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast at *
exact NNReal.inner_le_Lp_mul_Lq_tsum hpq hf_sum hg_sum
theorem summable_mul_of_Lp_Lq_of_nonneg (hpq : p.IsConjExponent q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
Summable fun i => f i * g i :=
(inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).1
theorem inner_le_Lp_mul_Lq_tsum_of_nonneg' (hpq : p.IsConjExponent q) (hf : ∀ i, 0 ≤ f i)
(hg : ∀ i, 0 ≤ g i) (hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ q) :
∑' i, f i * g i ≤ (∑' i, f i ^ p) ^ (1 / p) * (∑' i, g i ^ q) ^ (1 / q) :=
(inner_le_Lp_mul_Lq_tsum_of_nonneg hpq hf hg hf_sum hg_sum).2
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. A version for `NNReal`-valued
functions. For an alternative version, convenient if the infinite sums are not already expressed as
`p`-th powers, see `inner_le_Lp_mul_Lq_tsum_of_nonneg`. -/
theorem inner_le_Lp_mul_Lq_hasSum_of_nonneg (hpq : p.IsConjExponent q) {A B : ℝ} (hA : 0 ≤ A)
(hB : 0 ≤ B) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : HasSum (fun i => f i ^ p) (A ^ p)) (hg_sum : HasSum (fun i => g i ^ q) (B ^ q)) :
∃ C : ℝ, 0 ≤ C ∧ C ≤ A * B ∧ HasSum (fun i => f i * g i) C := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
lift A to ℝ≥0 using hA
lift B to ℝ≥0 using hB
-- After leanprover/lean4#2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast at hf_sum hg_sum
obtain ⟨C, hC, H⟩ := NNReal.inner_le_Lp_mul_Lq_hasSum hpq hf_sum hg_sum
refine ⟨C, C.prop, hC, ?_⟩
norm_cast
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with nonnegative `ℝ`-valued
functions. -/
theorem rpow_sum_le_const_mul_sum_rpow_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) :
(∑ i ∈ s, f i) ^ p ≤ (card s : ℝ) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
convert rpow_sum_le_const_mul_sum_rpow s f hp using 2 <;> apply sum_congr rfl <;> intro i hi <;>
simp only [abs_of_nonneg, hf i hi]
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `ℝ`-valued nonnegative
functions. -/
theorem Lp_add_le_of_nonneg (hp : 1 ≤ p) (hf : ∀ i ∈ s, 0 ≤ f i) (hg : ∀ i ∈ s, 0 ≤ g i) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
convert Lp_add_le s f g hp using 2 <;> [skip;congr 1;congr 1] <;> apply sum_congr rfl <;>
intro i hi <;>
simp only [abs_of_nonneg, hf i hi, hg i hi, add_nonneg]
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `ℝ`-valued functions. For an alternative version, convenient if the infinite
sums are already expressed as `p`-th powers, see `Lp_add_le_hasSum_of_nonneg`. -/
theorem Lp_add_le_tsum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
(Summable fun i => (f i + g i) ^ p) ∧
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤
(∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
-- After leanprover/lean4#2734, `norm_cast` needs help with beta reduction.
beta_reduce at *
norm_cast0 at *
exact NNReal.Lp_add_le_tsum hp hf_sum hg_sum
theorem summable_Lp_add_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
Summable fun i => (f i + g i) ^ p :=
(Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).1
theorem Lp_add_le_tsum_of_nonneg' (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i)
(hf_sum : Summable fun i => f i ^ p) (hg_sum : Summable fun i => g i ^ p) :
(∑' i, (f i + g i) ^ p) ^ (1 / p) ≤ (∑' i, f i ^ p) ^ (1 / p) + (∑' i, g i ^ p) ^ (1 / p) :=
(Lp_add_le_tsum_of_nonneg hp hf hg hf_sum hg_sum).2
/-- **Minkowski inequality**: the `L_p` seminorm of the infinite sum of two vectors is less than or
equal to the infinite sum of the `L_p`-seminorms of the summands, if these infinite sums both
exist. A version for `ℝ`-valued functions. For an alternative version, convenient if the infinite
sums are not already expressed as `p`-th powers, see `Lp_add_le_tsum_of_nonneg`. -/
theorem Lp_add_le_hasSum_of_nonneg (hp : 1 ≤ p) (hf : ∀ i, 0 ≤ f i) (hg : ∀ i, 0 ≤ g i) {A B : ℝ}
(hA : 0 ≤ A) (hB : 0 ≤ B) (hfA : HasSum (fun i => f i ^ p) (A ^ p))
(hgB : HasSum (fun i => g i ^ p) (B ^ p)) :
∃ C, 0 ≤ C ∧ C ≤ A + B ∧ HasSum (fun i => (f i + g i) ^ p) (C ^ p) := by
lift f to ι → ℝ≥0 using hf
lift g to ι → ℝ≥0 using hg
lift A to ℝ≥0 using hA
lift B to ℝ≥0 using hB
-- After leanprover/lean4#2734, `norm_cast` needs help with beta reduction.
beta_reduce at hfA hgB
norm_cast at hfA hgB
obtain ⟨C, hC₁, hC₂⟩ := NNReal.Lp_add_le_hasSum hp hfA hgB
use C
-- After leanprover/lean4#2734, `norm_cast` needs help with beta reduction.
beta_reduce
norm_cast
exact ⟨zero_le _, hC₁, hC₂⟩
end Real
namespace ENNReal
variable (f g : ι → ℝ≥0∞) {p q : ℝ}
/-- **Hölder inequality**: the scalar product of two functions is bounded by the product of their
`L^p` and `L^q` norms when `p` and `q` are conjugate exponents. Version for sums over finite sets,
with `ℝ≥0∞`-valued functions. -/
theorem inner_le_Lp_mul_Lq (hpq : p.IsConjExponent q) :
∑ i ∈ s, f i * g i ≤ (∑ i ∈ s, f i ^ p) ^ (1 / p) * (∑ i ∈ s, g i ^ q) ^ (1 / q) := by
by_cases H : (∑ i ∈ s, f i ^ p) ^ (1 / p) = 0 ∨ (∑ i ∈ s, g i ^ q) ^ (1 / q) = 0
· replace H : (∀ i ∈ s, f i = 0) ∨ ∀ i ∈ s, g i = 0 := by
simpa [ENNReal.rpow_eq_zero_iff, hpq.pos, hpq.symm.pos, asymm hpq.pos, asymm hpq.symm.pos,
sum_eq_zero_iff_of_nonneg] using H
have : ∀ i ∈ s, f i * g i = 0 := fun i hi => by cases' H with H H <;> simp [H i hi]
simp [sum_eq_zero this]
push_neg at H
by_cases H' : (∑ i ∈ s, f i ^ p) ^ (1 / p) = ⊤ ∨ (∑ i ∈ s, g i ^ q) ^ (1 / q) = ⊤
· cases' H' with H' H' <;> simp [H', -one_div, -sum_eq_zero_iff, -rpow_eq_zero_iff, H]
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ ∀ i ∈ s, g i ≠ ⊤ := by
simpa [ENNReal.rpow_eq_top_iff, asymm hpq.pos, asymm hpq.symm.pos, hpq.pos, hpq.symm.pos,
ENNReal.sum_eq_top_iff, not_or] using H'
have := ENNReal.coe_le_coe.2 (@NNReal.inner_le_Lp_mul_Lq _ s (fun i => ENNReal.toNNReal (f i))
(fun i => ENNReal.toNNReal (g i)) _ _ hpq)
simp [← ENNReal.coe_rpow_of_nonneg, le_of_lt hpq.pos, le_of_lt hpq.one_div_pos,
le_of_lt hpq.symm.pos, le_of_lt hpq.symm.one_div_pos] at this
convert this using 1 <;> [skip; congr 2] <;> [skip; skip; simp; skip; simp] <;>
· refine Finset.sum_congr rfl fun i hi => ?_
simp [H'.1 i hi, H'.2 i hi, -WithZero.coe_mul]
/-- **Weighted Hölder inequality**. -/
lemma inner_le_weight_mul_Lp_of_nonneg (s : Finset ι) {p : ℝ} (hp : 1 ≤ p) (w f : ι → ℝ≥0∞) :
∑ i ∈ s, w i * f i ≤ (∑ i ∈ s, w i) ^ (1 - p⁻¹) * (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ := by
obtain rfl | hp := hp.eq_or_lt
· simp
have hp₀ : 0 < p := by positivity
have hp₁ : p⁻¹ < 1 := inv_lt_one hp
by_cases H : (∑ i ∈ s, w i) ^ (1 - p⁻¹) = 0 ∨ (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ = 0
· replace H : (∀ i ∈ s, w i = 0) ∨ ∀ i ∈ s, w i = 0 ∨ f i = 0 := by
simpa [hp₀, hp₁, hp₀.not_lt, hp₁.not_lt, sum_eq_zero_iff_of_nonneg] using H
have (i) (hi : i ∈ s) : w i * f i = 0 := by cases' H with H H <;> simp [H i hi]
simp [sum_eq_zero this]
push_neg at H
by_cases H' : (∑ i ∈ s, w i) ^ (1 - p⁻¹) = ⊤ ∨ (∑ i ∈ s, w i * f i ^ p) ^ p⁻¹ = ⊤
· cases' H' with H' H' <;> simp [H', -one_div, -sum_eq_zero_iff, -rpow_eq_zero_iff, H]
replace H' : (∀ i ∈ s, w i ≠ ⊤) ∧ ∀ i ∈ s, w i * f i ^ p ≠ ⊤ := by
simpa [rpow_eq_top_iff,hp₀, hp₁, hp₀.not_lt, hp₁.not_lt, sum_eq_top_iff, not_or] using H'
have := coe_le_coe.2 $ NNReal.inner_le_weight_mul_Lp s hp.le (fun i ↦ ENNReal.toNNReal (w i))
fun i ↦ ENNReal.toNNReal (f i)
rw [coe_mul] at this
simp_rw [← coe_rpow_of_nonneg _ $ inv_nonneg.2 hp₀.le, coe_finset_sum, ENNReal.toNNReal_rpow,
← ENNReal.toNNReal_mul, sum_congr rfl fun i hi ↦ coe_toNNReal (H'.2 i hi)] at this
simp [← ENNReal.coe_rpow_of_nonneg, hp₀.le, hp₁.le] at this
convert this using 2 with i hi
· obtain hw | hw := eq_or_ne (w i) 0
· simp [hw]
rw [coe_toNNReal (H'.1 _ hi), coe_toNNReal]
simpa [mul_eq_top, hw, hp₀, hp₀.not_lt, H'.1 _ hi] using H'.2 _ hi
· convert rfl with i hi
exact coe_toNNReal (H'.1 _ hi)
/-- For `1 ≤ p`, the `p`-th power of the sum of `f i` is bounded above by a constant times the
sum of the `p`-th powers of `f i`. Version for sums over finite sets, with `ℝ≥0∞`-valued functions.
-/
theorem rpow_sum_le_const_mul_sum_rpow (hp : 1 ≤ p) :
(∑ i ∈ s, f i) ^ p ≤ (card s : ℝ≥0∞) ^ (p - 1) * ∑ i ∈ s, f i ^ p := by
cases' eq_or_lt_of_le hp with hp hp
· simp [← hp]
let q : ℝ := p / (p - 1)
have hpq : p.IsConjExponent q := .conjExponent hp
have hp₁ : 1 / p * p = 1 := one_div_mul_cancel hpq.ne_zero
have hq : 1 / q * p = p - 1 := by
rw [← hpq.div_conj_eq_sub_one]
ring
simpa only [ENNReal.mul_rpow_of_nonneg _ _ hpq.nonneg, ← ENNReal.rpow_mul, hp₁, hq, coe_one,
one_mul, one_rpow, rpow_one, Pi.one_apply, sum_const, Nat.smul_one_eq_cast] using
ENNReal.rpow_le_rpow (inner_le_Lp_mul_Lq s 1 f hpq.symm) hpq.nonneg
/-- **Minkowski inequality**: the `L_p` seminorm of the sum of two vectors is less than or equal
to the sum of the `L_p`-seminorms of the summands. A version for `ℝ≥0∞` valued nonnegative
functions. -/
theorem Lp_add_le (hp : 1 ≤ p) :
(∑ i ∈ s, (f i + g i) ^ p) ^ (1 / p) ≤
(∑ i ∈ s, f i ^ p) ^ (1 / p) + (∑ i ∈ s, g i ^ p) ^ (1 / p) := by
by_cases H' : (∑ i ∈ s, f i ^ p) ^ (1 / p) = ⊤ ∨ (∑ i ∈ s, g i ^ p) ^ (1 / p) = ⊤
· cases' H' with H' H' <;> simp [H', -one_div]
have pos : 0 < p := lt_of_lt_of_le zero_lt_one hp
replace H' : (∀ i ∈ s, f i ≠ ⊤) ∧ ∀ i ∈ s, g i ≠ ⊤ := by
simpa [ENNReal.rpow_eq_top_iff, asymm pos, pos, ENNReal.sum_eq_top_iff, not_or] using H'
have :=
ENNReal.coe_le_coe.2
(@NNReal.Lp_add_le _ s (fun i => ENNReal.toNNReal (f i)) (fun i => ENNReal.toNNReal (g i)) _
hp)
push_cast [← ENNReal.coe_rpow_of_nonneg, le_of_lt pos, le_of_lt (one_div_pos.2 pos)] at this
convert this using 2 <;> [skip; congr 1; congr 1] <;>
· refine Finset.sum_congr rfl fun i hi => ?_
simp [H'.1 i hi, H'.2 i hi]
end ENNReal
end HoelderMinkowski
|
Analysis\MeanInequalitiesPow.lean | /-
Copyright (c) 2019 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Sébastien Gouëzel, Rémy Degenne
-/
import Mathlib.Analysis.Convex.Jensen
import Mathlib.Analysis.Convex.Mul
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
/-!
# Mean value inequalities
In this file we prove several mean inequalities for finite sums. Versions for integrals of some of
these inequalities are available in `MeasureTheory.MeanInequalities`.
## Main theorems: generalized mean inequality
The inequality says that for two non-negative vectors $w$ and $z$ with $\sum_{i\in s} w_i=1$
and $p ≤ q$ we have
$$
\sqrt[p]{\sum_{i\in s} w_i z_i^p} ≤ \sqrt[q]{\sum_{i\in s} w_i z_i^q}.
$$
Currently we only prove this inequality for $p=1$. As in the rest of `Mathlib`, we provide
different theorems for natural exponents (`pow_arith_mean_le_arith_mean_pow`), integer exponents
(`zpow_arith_mean_le_arith_mean_zpow`), and real exponents (`rpow_arith_mean_le_arith_mean_rpow` and
`arith_mean_le_rpow_mean`). In the first two cases we prove
$$
\left(\sum_{i\in s} w_i z_i\right)^n ≤ \sum_{i\in s} w_i z_i^n
$$
in order to avoid using real exponents. For real exponents we prove both this and standard versions.
## TODO
- each inequality `A ≤ B` should come with a theorem `A = B ↔ _`; one of the ways to prove them
is to define `StrictConvexOn` functions.
- generalized mean inequality with any `p ≤ q`, including negative numbers;
- prove that the power mean tends to the geometric mean as the exponent tends to zero.
-/
universe u v
open Finset NNReal ENNReal
noncomputable section
variable {ι : Type u} (s : Finset ι)
namespace Real
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
(convexOn_pow n).map_sum_le hw hw' hz
theorem pow_arith_mean_le_arith_mean_pow_of_even (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) {n : ℕ} (hn : Even n) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
hn.convexOn_pow.map_sum_le hw hw' fun _ _ => Set.mem_univ _
/-- Specific case of Jensen's inequality for sums of powers -/
theorem pow_sum_div_card_le_sum_pow {f : ι → ℝ} (n : ℕ) (hf : ∀ a ∈ s, 0 ≤ f a) :
(∑ x ∈ s, f x) ^ (n + 1) / (s.card : ℝ) ^ n ≤ ∑ x ∈ s, f x ^ (n + 1) := by
rcases s.eq_empty_or_nonempty with (rfl | hs)
· simp_rw [Finset.sum_empty, zero_pow n.succ_ne_zero, zero_div]; rfl
· have hs0 : 0 < (s.card : ℝ) := Nat.cast_pos.2 hs.card_pos
suffices (∑ x ∈ s, f x / s.card) ^ (n + 1) ≤ ∑ x ∈ s, f x ^ (n + 1) / s.card by
rwa [← Finset.sum_div, ← Finset.sum_div, div_pow, pow_succ (s.card : ℝ), ← div_div,
div_le_iff hs0, div_mul, div_self hs0.ne', div_one] at this
have :=
@ConvexOn.map_sum_le ℝ ℝ ℝ ι _ _ _ _ _ _ (Set.Ici 0) (fun x => x ^ (n + 1)) s
(fun _ => 1 / s.card) ((↑) ∘ f) (convexOn_pow (n + 1)) ?_ ?_ fun i hi =>
Set.mem_Ici.2 (hf i hi)
· simpa only [inv_mul_eq_div, one_div, Algebra.id.smul_eq_mul] using this
· simp only [one_div, inv_nonneg, Nat.cast_nonneg, imp_true_iff]
· simpa only [one_div, Finset.sum_const, nsmul_eq_mul] using mul_inv_cancel hs0.ne'
theorem zpow_arith_mean_le_arith_mean_zpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 < z i) (m : ℤ) :
(∑ i ∈ s, w i * z i) ^ m ≤ ∑ i ∈ s, w i * z i ^ m :=
(convexOn_zpow m).map_sum_le hw hw' hz
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i)
(hw' : ∑ i ∈ s, w i = 1) (hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
(∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
(convexOn_rpow hp).map_sum_le hw hw' hz
theorem arith_mean_le_rpow_mean (w z : ι → ℝ) (hw : ∀ i ∈ s, 0 ≤ w i) (hw' : ∑ i ∈ s, w i = 1)
(hz : ∀ i ∈ s, 0 ≤ z i) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) := by
have : 0 < p := by positivity
rw [← rpow_le_rpow_iff _ _ this, ← rpow_mul, one_div_mul_cancel (ne_of_gt this), rpow_one]
· exact rpow_arith_mean_le_arith_mean_rpow s w z hw hw' hz hp
all_goals
apply_rules [sum_nonneg, rpow_nonneg]
intro i hi
apply_rules [mul_nonneg, rpow_nonneg, hw i hi, hz i hi]
end Real
namespace NNReal
/-- Weighted generalized mean inequality, version sums over finite sets, with `ℝ≥0`-valued
functions and natural exponent. -/
theorem pow_arith_mean_le_arith_mean_pow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) (n : ℕ) :
(∑ i ∈ s, w i * z i) ^ n ≤ ∑ i ∈ s, w i * z i ^ n :=
mod_cast
Real.pow_arith_mean_le_arith_mean_pow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) n
theorem pow_sum_div_card_le_sum_pow (f : ι → ℝ≥0) (n : ℕ) :
(∑ x ∈ s, f x) ^ (n + 1) / (s.card : ℝ) ^ n ≤ ∑ x ∈ s, f x ^ (n + 1) := by
simpa only [← NNReal.coe_le_coe, NNReal.coe_sum, Nonneg.coe_div, NNReal.coe_pow] using
@Real.pow_sum_div_card_le_sum_pow ι s (((↑) : ℝ≥0 → ℝ) ∘ f) n fun _ _ => NNReal.coe_nonneg _
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p :=
mod_cast
Real.rpow_arith_mean_le_arith_mean_rpow s _ _ (fun i _ => (w i).coe_nonneg)
(mod_cast hw') (fun i _ => (z i).coe_nonneg) hp
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
rcases eq_or_lt_of_le hp with (rfl | h'p)
· simp only [rpow_one, sub_self, rpow_zero, one_mul]; rfl
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂) (add_halves 1) hp
using 1
· simp only [one_div, inv_mul_cancel_left₀, Ne, mul_eq_zero, two_ne_zero, one_ne_zero,
not_false_iff]
· have A : p - 1 ≠ 0 := ne_of_gt (sub_pos.2 h'p)
simp only [mul_rpow, rpow_sub' _ A, div_eq_inv_mul, rpow_one, mul_one]
ring
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0`-valued
functions and real exponents. -/
theorem arith_mean_le_rpow_mean (w z : ι → ℝ≥0) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ} (hp : 1 ≤ p) :
∑ i ∈ s, w i * z i ≤ (∑ i ∈ s, w i * z i ^ p) ^ (1 / p) :=
mod_cast
Real.arith_mean_le_rpow_mean s _ _ (fun i _ => (w i).coe_nonneg) (mod_cast hw')
(fun i _ => (z i).coe_nonneg) hp
private theorem add_rpow_le_one_of_add_le_one {p : ℝ} (a b : ℝ≥0) (hab : a + b ≤ 1) (hp1 : 1 ≤ p) :
a ^ p + b ^ p ≤ 1 := by
have h_le_one : ∀ x : ℝ≥0, x ≤ 1 → x ^ p ≤ x := fun x hx => rpow_le_self_of_le_one hx hp1
have ha : a ≤ 1 := (self_le_add_right a b).trans hab
have hb : b ≤ 1 := (self_le_add_left b a).trans hab
exact (add_le_add (h_le_one a ha) (h_le_one b hb)).trans hab
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_zero : a + b = 0
· simp [add_eq_zero_iff.mp h_zero, hp_pos.ne']
have h_nonzero : ¬(a = 0 ∧ b = 0) := by rwa [add_eq_zero_iff] at h_zero
have h_add : a / (a + b) + b / (a + b) = 1 := by rw [div_add_div_same, div_self h_zero]
have h := add_rpow_le_one_of_add_le_one (a / (a + b)) (b / (a + b)) h_add.le hp1
rw [div_rpow a (a + b), div_rpow b (a + b)] at h
have hab_0 : (a + b) ^ p ≠ 0 := by simp [hp_pos, h_nonzero]
have hab_0' : 0 < (a + b) ^ p := zero_lt_iff.mpr hab_0
have h_mul : (a + b) ^ p * (a ^ p / (a + b) ^ p + b ^ p / (a + b) ^ p) ≤ (a + b) ^ p := by
nth_rw 4 [← mul_one ((a + b) ^ p)]
exact (mul_le_mul_left hab_0').mpr h
rwa [div_eq_mul_inv, div_eq_mul_inv, mul_add, mul_comm (a ^ p), mul_comm (b ^ p), ← mul_assoc, ←
mul_assoc, mul_inv_cancel hab_0, one_mul, one_mul] at h_mul
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div]
rw [← @NNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← NNReal.rpow_mul, div_eq_inv_mul, ← mul_assoc, _root_.mul_inv_cancel hp_pos.ne.symm,
one_mul]
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, NNReal.le_rpow_inv_iff hp_pos, ← NNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [NNReal.rpow_one] at h
exact (NNReal.le_rpow_inv_iff hp_pos).mp h
end NNReal
namespace ENNReal
/-- Weighted generalized mean inequality, version for sums over finite sets, with `ℝ≥0∞`-valued
functions and real exponents. -/
theorem rpow_arith_mean_le_arith_mean_rpow (w z : ι → ℝ≥0∞) (hw' : ∑ i ∈ s, w i = 1) {p : ℝ}
(hp : 1 ≤ p) : (∑ i ∈ s, w i * z i) ^ p ≤ ∑ i ∈ s, w i * z i ^ p := by
have hp_pos : 0 < p := by positivity
have hp_nonneg : 0 ≤ p := by positivity
have hp_not_neg : ¬p < 0 := by simp [hp_nonneg]
have h_top_iff_rpow_top : ∀ (i : ι), i ∈ s → (w i * z i = ⊤ ↔ w i * z i ^ p = ⊤) := by
simp [ENNReal.mul_eq_top, hp_pos, hp_nonneg, hp_not_neg]
refine le_of_top_imp_top_of_toNNReal_le ?_ ?_
· -- first, prove `(∑ i ∈ s, w i * z i) ^ p = ⊤ → ∑ i ∈ s, (w i * z i ^ p) = ⊤`
rw [rpow_eq_top_iff, sum_eq_top_iff, sum_eq_top_iff]
intro h
simp only [and_false_iff, hp_not_neg, false_or_iff] at h
rcases h.left with ⟨a, H, ha⟩
use a, H
rwa [← h_top_iff_rpow_top a H]
· -- second, suppose both `(∑ i ∈ s, w i * z i) ^ p ≠ ⊤` and `∑ i ∈ s, (w i * z i ^ p) ≠ ⊤`,
-- and prove `((∑ i ∈ s, w i * z i) ^ p).toNNReal ≤ (∑ i ∈ s, (w i * z i ^ p)).toNNReal`,
-- by using `NNReal.rpow_arith_mean_le_arith_mean_rpow`.
intro h_top_rpow_sum _
-- show hypotheses needed to put the `.toNNReal` inside the sums.
have h_top : ∀ a : ι, a ∈ s → w a * z a ≠ ⊤ :=
haveI h_top_sum : ∑ i ∈ s, w i * z i ≠ ⊤ := by
intro h
rw [h, top_rpow_of_pos hp_pos] at h_top_rpow_sum
exact h_top_rpow_sum rfl
fun a ha => (lt_top_of_sum_ne_top h_top_sum ha).ne
have h_top_rpow : ∀ a : ι, a ∈ s → w a * z a ^ p ≠ ⊤ := by
intro i hi
specialize h_top i hi
rwa [Ne, ← h_top_iff_rpow_top i hi]
-- put the `.toNNReal` inside the sums.
simp_rw [toNNReal_sum h_top_rpow, ← toNNReal_rpow, toNNReal_sum h_top, toNNReal_mul, ←
toNNReal_rpow]
-- use corresponding nnreal result
refine
NNReal.rpow_arith_mean_le_arith_mean_rpow s (fun i => (w i).toNNReal)
(fun i => (z i).toNNReal) ?_ hp
-- verify the hypothesis `∑ i ∈ s, (w i).toNNReal = 1`, using `∑ i ∈ s, w i = 1` .
have h_sum_nnreal : ∑ i ∈ s, w i = ↑(∑ i ∈ s, (w i).toNNReal) := by
rw [coe_finset_sum]
refine sum_congr rfl fun i hi => (coe_toNNReal ?_).symm
refine (lt_top_of_sum_ne_top ?_ hi).ne
exact hw'.symm ▸ ENNReal.one_ne_top
rwa [← coe_inj, ← h_sum_nnreal]
/-- Weighted generalized mean inequality, version for two elements of `ℝ≥0∞` and real
exponents. -/
theorem rpow_arith_mean_le_arith_mean2_rpow (w₁ w₂ z₁ z₂ : ℝ≥0∞) (hw' : w₁ + w₂ = 1) {p : ℝ}
(hp : 1 ≤ p) : (w₁ * z₁ + w₂ * z₂) ^ p ≤ w₁ * z₁ ^ p + w₂ * z₂ ^ p := by
have h := rpow_arith_mean_le_arith_mean_rpow univ ![w₁, w₂] ![z₁, z₂] ?_ hp
· simpa [Fin.sum_univ_succ] using h
· simp [hw', Fin.sum_univ_succ]
/-- Unweighted mean inequality, version for two elements of `ℝ≥0∞` and real exponents. -/
theorem rpow_add_le_mul_rpow_add_rpow (z₁ z₂ : ℝ≥0∞) {p : ℝ} (hp : 1 ≤ p) :
(z₁ + z₂) ^ p ≤ (2 : ℝ≥0∞) ^ (p - 1) * (z₁ ^ p + z₂ ^ p) := by
convert rpow_arith_mean_le_arith_mean2_rpow (1 / 2) (1 / 2) (2 * z₁) (2 * z₂)
(ENNReal.add_halves 1) hp using 1
· simp [← mul_assoc, ENNReal.inv_mul_cancel two_ne_zero two_ne_top]
· simp only [mul_rpow_of_nonneg _ _ (zero_le_one.trans hp), rpow_sub _ _ two_ne_zero two_ne_top,
ENNReal.div_eq_inv_mul, rpow_one, mul_one]
ring
theorem add_rpow_le_rpow_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) : a ^ p + b ^ p ≤ (a + b) ^ p := by
have hp_pos : 0 < p := by positivity
by_cases h_top : a + b = ⊤
· rw [← @ENNReal.rpow_eq_top_iff_of_pos (a + b) p hp_pos] at h_top
rw [h_top]
exact le_top
obtain ⟨ha_top, hb_top⟩ := add_ne_top.mp h_top
lift a to ℝ≥0 using ha_top
lift b to ℝ≥0 using hb_top
simpa [← ENNReal.coe_rpow_of_nonneg _ hp_pos.le] using
ENNReal.coe_le_coe.2 (NNReal.add_rpow_le_rpow_add a b hp1)
theorem rpow_add_rpow_le_add {p : ℝ} (a b : ℝ≥0∞) (hp1 : 1 ≤ p) :
(a ^ p + b ^ p) ^ (1 / p) ≤ a + b := by
rw [one_div, ← @ENNReal.le_rpow_inv_iff _ _ p⁻¹ (by simp [lt_of_lt_of_le zero_lt_one hp1])]
rw [inv_inv]
exact add_rpow_le_rpow_add _ _ hp1
theorem rpow_add_rpow_le {p q : ℝ} (a b : ℝ≥0∞) (hp_pos : 0 < p) (hpq : p ≤ q) :
(a ^ q + b ^ q) ^ (1 / q) ≤ (a ^ p + b ^ p) ^ (1 / p) := by
have h_rpow : ∀ a : ℝ≥0∞, a ^ q = (a ^ p) ^ (q / p) := fun a => by
rw [← ENNReal.rpow_mul, mul_div_cancel₀ _ hp_pos.ne']
have h_rpow_add_rpow_le_add :
((a ^ p) ^ (q / p) + (b ^ p) ^ (q / p)) ^ (1 / (q / p)) ≤ a ^ p + b ^ p := by
refine rpow_add_rpow_le_add (a ^ p) (b ^ p) ?_
rwa [one_le_div hp_pos]
rw [h_rpow a, h_rpow b, one_div p, ENNReal.le_rpow_inv_iff hp_pos, ← ENNReal.rpow_mul, mul_comm,
mul_one_div]
rwa [one_div_div] at h_rpow_add_rpow_le_add
theorem rpow_add_le_add_rpow {p : ℝ} (a b : ℝ≥0∞) (hp : 0 ≤ p) (hp1 : p ≤ 1) :
(a + b) ^ p ≤ a ^ p + b ^ p := by
rcases hp.eq_or_lt with (rfl | hp_pos)
· simp
have h := rpow_add_rpow_le a b hp_pos hp1
rw [one_div_one, one_div] at h
repeat' rw [ENNReal.rpow_one] at h
exact (ENNReal.le_rpow_inv_iff hp_pos).mp h
end ENNReal
|
Analysis\MellinInversion.lean | /-
Copyright (c) 2024 Lawrence Wu. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Lawrence Wu
-/
import Mathlib.Analysis.Fourier.Inversion
/-!
# Mellin inversion formula
We derive the Mellin inversion formula as a consequence of the Fourier inversion formula.
## Main results
- `mellin_inversion`: The inverse Mellin transform of the Mellin transform applied to `x > 0` is x.
-/
open Real Complex Set MeasureTheory
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
open scoped FourierTransform
private theorem rexp_neg_deriv_aux :
∀ x ∈ univ, HasDerivWithinAt (rexp ∘ Neg.neg) (-rexp (-x)) univ x :=
fun x _ ↦ mul_neg_one (rexp (-x)) ▸
((Real.hasDerivAt_exp (-x)).comp x (hasDerivAt_neg x)).hasDerivWithinAt
private theorem rexp_neg_image_aux : rexp ∘ Neg.neg '' univ = Ioi 0 := by
rw [Set.image_comp, Set.image_univ_of_surjective neg_surjective, Set.image_univ, Real.range_exp]
private theorem rexp_neg_injOn_aux : univ.InjOn (rexp ∘ Neg.neg) :=
Real.exp_injective.injOn.comp neg_injective.injOn (univ.mapsTo_univ _)
private theorem rexp_cexp_aux (x : ℝ) (s : ℂ) (f : E) :
rexp (-x) • cexp (-↑x) ^ (s - 1) • f = cexp (-s * ↑x) • f := by
show (rexp (-x) : ℂ) • _ = _ • f
rw [← smul_assoc, smul_eq_mul]
push_cast
conv in cexp _ * _ => lhs; rw [← cpow_one (cexp _)]
rw [← cpow_add _ _ (Complex.exp_ne_zero _), cpow_def_of_ne_zero (Complex.exp_ne_zero _),
Complex.log_exp (by norm_num; exact pi_pos) (by simpa using pi_nonneg)]
ring_nf
theorem mellin_eq_fourierIntegral (f : ℝ → E) {s : ℂ} :
mellin f s = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) :=
calc
mellin f s
= ∫ (u : ℝ), Complex.exp (-s * u) • f (Real.exp (-u)) := by
rw [mellin, ← rexp_neg_image_aux, integral_image_eq_integral_abs_deriv_smul
MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux]
simp [rexp_cexp_aux]
_ = ∫ (u : ℝ), Complex.exp (↑(-2 * π * (u * (s.im / (2 * π)))) * I) •
(Real.exp (-s.re * u) • f (Real.exp (-u))) := by
congr
ext u
trans Complex.exp (-s.im * u * I) • (Real.exp (-s.re * u) • f (Real.exp (-u)))
· conv => lhs; rw [← re_add_im s]
rw [neg_add, add_mul, Complex.exp_add, mul_comm, ← smul_eq_mul, smul_assoc]
norm_cast
push_cast
ring_nf
congr
rw [mul_comm (-s.im : ℂ) (u : ℂ), mul_comm (-2 * π)]
have : 2 * (π : ℂ) ≠ 0 := by norm_num; exact pi_ne_zero
field_simp
_ = 𝓕 (fun (u : ℝ) ↦ (Real.exp (-s.re * u) • f (Real.exp (-u)))) (s.im / (2 * π)) := by
simp [fourierIntegral_eq']
theorem mellinInv_eq_fourierIntegralInv (σ : ℝ) (f : ℂ → E) {x : ℝ} (hx : 0 < x) :
mellinInv σ f x =
(x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := calc
mellinInv σ f x
= (x : ℂ) ^ (-σ : ℂ) •
(∫ (y : ℝ), Complex.exp (2 * π * (y * (-Real.log x)) * I) • f (σ + 2 * π * y * I)) := by
rw [mellinInv, one_div, ← abs_of_pos (show 0 < (2 * π)⁻¹ by norm_num; exact pi_pos)]
have hx0 : (x : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt hx)
simp_rw [neg_add, cpow_add _ _ hx0, mul_smul, integral_smul]
rw [smul_comm, ← Measure.integral_comp_mul_left]
congr! 3
rw [cpow_def_of_ne_zero hx0, ← Complex.ofReal_log hx.le]
push_cast
ring_nf
_ = (x : ℂ) ^ (-σ : ℂ) • 𝓕⁻ (fun (y : ℝ) ↦ f (σ + 2 * π * y * I)) (-Real.log x) := by
simp [fourierIntegralInv_eq']
variable [CompleteSpace E]
/-- The inverse Mellin transform of the Mellin transform applied to `x > 0` is x. -/
theorem mellin_inversion (σ : ℝ) (f : ℝ → E) {x : ℝ} (hx : 0 < x) (hf : MellinConvergent f σ)
(hFf : VerticalIntegrable (mellin f) σ) (hfx : ContinuousAt f x) :
mellinInv σ (mellin f) x = f x := by
let g := fun (u : ℝ) => Real.exp (-σ * u) • f (Real.exp (-u))
replace hf : Integrable g := by
rw [MellinConvergent, ← rexp_neg_image_aux, integrableOn_image_iff_integrableOn_abs_deriv_smul
MeasurableSet.univ rexp_neg_deriv_aux rexp_neg_injOn_aux] at hf
replace hf : Integrable fun (x : ℝ) ↦ cexp (-↑σ * ↑x) • f (rexp (-x)) := by
simpa [rexp_cexp_aux] using hf
norm_cast at hf
replace hFf : Integrable (𝓕 g) := by
have h2π : 2 * π ≠ 0 := by norm_num; exact pi_ne_zero
have : Integrable (𝓕 (fun u ↦ rexp (-(σ * u)) • f (rexp (-u)))) := by
simpa [mellin_eq_fourierIntegral, mul_div_cancel_right₀ _ h2π] using hFf.comp_mul_right' h2π
simp_rw [neg_mul_eq_neg_mul] at this
exact this
replace hfx : ContinuousAt g (-Real.log x) := by
refine ContinuousAt.smul (by fun_prop) (ContinuousAt.comp ?_ (by fun_prop))
simpa [Real.exp_log hx] using hfx
calc
mellinInv σ (mellin f) x
= mellinInv σ (fun s ↦ 𝓕 g (s.im / (2 * π))) x := by
simp [g, mellinInv, mellin_eq_fourierIntegral]
_ = (x : ℂ) ^ (-σ : ℂ) • g (-Real.log x) := by
rw [mellinInv_eq_fourierIntegralInv _ _ hx, ← hf.fourier_inversion hFf hfx]
simp [mul_div_cancel_left₀ _ (show 2 * π ≠ 0 by norm_num; exact pi_ne_zero)]
_ = (x : ℂ) ^ (-σ : ℂ) • rexp (σ * Real.log x) • f (rexp (Real.log x)) := by simp [g]
_ = f x := by
norm_cast
rw [mul_comm σ, ← rpow_def_of_pos hx, Real.exp_log hx, ← Complex.ofReal_cpow hx.le]
norm_cast
rw [← smul_assoc, smul_eq_mul, Real.rpow_neg hx.le,
inv_mul_cancel (ne_of_gt (rpow_pos_of_pos hx σ)), one_smul]
|
Analysis\MellinTransform.lean | /-
Copyright (c) 2023 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.Analysis.Calculus.ParametricIntegral
import Mathlib.MeasureTheory.Measure.Haar.NormedSpace
/-! # The Mellin transform
We define the Mellin transform of a locally integrable function on `Ioi 0`, and show it is
differentiable in a suitable vertical strip.
## Main statements
- `mellin` : the Mellin transform `∫ (t : ℝ) in Ioi 0, t ^ (s - 1) • f t`,
where `s` is a complex number.
- `HasMellin`: shorthand asserting that the Mellin transform exists and has a given value
(analogous to `HasSum`).
- `mellin_differentiableAt_of_isBigO_rpow` : if `f` is `O(x ^ (-a))` at infinity, and
`O(x ^ (-b))` at 0, then `mellin f` is holomorphic on the domain `b < re s < a`.
-/
open MeasureTheory Set Filter Asymptotics TopologicalSpace
open Real
open Complex hiding exp log abs_of_nonneg
open scoped Topology
noncomputable section
section Defs
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℂ E]
/-- Predicate on `f` and `s` asserting that the Mellin integral is well-defined. -/
def MellinConvergent (f : ℝ → E) (s : ℂ) : Prop :=
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (Ioi 0)
theorem MellinConvergent.const_smul {f : ℝ → E} {s : ℂ} (hf : MellinConvergent f s) {𝕜 : Type*}
[NontriviallyNormedField 𝕜] [NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) :
MellinConvergent (fun t => c • f t) s := by
simpa only [MellinConvergent, smul_comm] using hf.smul c
theorem MellinConvergent.cpow_smul {f : ℝ → E} {s a : ℂ} :
MellinConvergent (fun t => (t : ℂ) ^ a • f t) s ↔ MellinConvergent f (s + a) := by
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi
simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
nonrec theorem MellinConvergent.div_const {f : ℝ → ℂ} {s : ℂ} (hf : MellinConvergent f s) (a : ℂ) :
MellinConvergent (fun t => f t / a) s := by
simpa only [MellinConvergent, smul_eq_mul, ← mul_div_assoc] using hf.div_const a
theorem MellinConvergent.comp_mul_left {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : 0 < a) :
MellinConvergent (fun t => f (a * t)) s ↔ MellinConvergent f s := by
have := integrableOn_Ioi_comp_mul_left_iff (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) 0 ha
rw [mul_zero] at this
have h1 : EqOn (fun t : ℝ => (↑(a * t) : ℂ) ^ (s - 1) • f (a * t))
((a : ℂ) ^ (s - 1) • fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t)) (Ioi 0) := fun t ht ↦ by
simp only [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), mul_smul, Pi.smul_apply]
have h2 : (a : ℂ) ^ (s - 1) ≠ 0 := by
rw [Ne, cpow_eq_zero_iff, not_and_or, ofReal_eq_zero]
exact Or.inl ha.ne'
rw [MellinConvergent, MellinConvergent, ← this, integrableOn_congr_fun h1 measurableSet_Ioi,
IntegrableOn, IntegrableOn, integrable_smul_iff h2]
theorem MellinConvergent.comp_rpow {f : ℝ → E} {s : ℂ} {a : ℝ} (ha : a ≠ 0) :
MellinConvergent (fun t => f (t ^ a)) s ↔ MellinConvergent f (s / a) := by
refine Iff.trans ?_ (integrableOn_Ioi_comp_rpow_iff' _ ha)
rw [MellinConvergent]
refine integrableOn_congr_fun (fun t ht => ?_) measurableSet_Ioi
dsimp only [Pi.smul_apply]
rw [← Complex.coe_smul (t ^ (a - 1)), ← mul_smul, ← cpow_mul_ofReal_nonneg (le_of_lt ht),
ofReal_cpow (le_of_lt ht), ← cpow_add _ _ (ofReal_ne_zero.mpr (ne_of_gt ht)), ofReal_sub,
ofReal_one, mul_sub, mul_div_cancel₀ _ (ofReal_ne_zero.mpr ha), mul_one, add_comm, ←
add_sub_assoc, sub_add_cancel]
/-- A function `f` is `VerticalIntegrable` at `σ` if `y ↦ f(σ + yi)` is integrable. -/
def Complex.VerticalIntegrable (f : ℂ → E) (σ : ℝ) (μ : Measure ℝ := by volume_tac) : Prop :=
Integrable (fun (y : ℝ) ↦ f (σ + y * I)) μ
/-- The Mellin transform of a function `f` (for a complex exponent `s`), defined as the integral of
`t ^ (s - 1) • f` over `Ioi 0`. -/
def mellin (f : ℝ → E) (s : ℂ) : E :=
∫ t : ℝ in Ioi 0, (t : ℂ) ^ (s - 1) • f t
/-- The Mellin inverse transform of a function `f`, defined as `1 / (2π)` times
the integral of `y ↦ x ^ -(σ + yi) • f (σ + yi)`. -/
def mellinInv (σ : ℝ) (f : ℂ → E) (x : ℝ) : E :=
(1 / (2 * π)) • ∫ y : ℝ, (x : ℂ) ^ (-(σ + y * I)) • f (σ + y * I)
-- next few lemmas don't require convergence of the Mellin transform (they are just 0 = 0 otherwise)
theorem mellin_cpow_smul (f : ℝ → E) (s a : ℂ) :
mellin (fun t => (t : ℂ) ^ a • f t) s = mellin f (s + a) := by
refine setIntegral_congr measurableSet_Ioi fun t ht => ?_
simp_rw [← sub_add_eq_add_sub, cpow_add _ _ (ofReal_ne_zero.2 <| ne_of_gt ht), mul_smul]
theorem mellin_const_smul (f : ℝ → E) (s : ℂ) {𝕜 : Type*} [NontriviallyNormedField 𝕜]
[NormedSpace 𝕜 E] [SMulCommClass ℂ 𝕜 E] (c : 𝕜) :
mellin (fun t => c • f t) s = c • mellin f s := by simp only [mellin, smul_comm, integral_smul]
theorem mellin_div_const (f : ℝ → ℂ) (s a : ℂ) : mellin (fun t => f t / a) s = mellin f s / a := by
simp_rw [mellin, smul_eq_mul, ← mul_div_assoc, integral_div]
theorem mellin_comp_rpow (f : ℝ → E) (s : ℂ) (a : ℝ) :
mellin (fun t => f (t ^ a)) s = |a|⁻¹ • mellin f (s / a) := by
/- This is true for `a = 0` as all sides are undefined but turn out to vanish thanks to our
convention. The interesting case is `a ≠ 0` -/
rcases eq_or_ne a 0 with rfl|ha
· by_cases hE : CompleteSpace E
· simp [integral_smul_const, mellin, setIntegral_Ioi_zero_cpow]
· simp [integral, mellin, hE]
simp_rw [mellin]
conv_rhs => rw [← integral_comp_rpow_Ioi _ ha, ← integral_smul]
refine setIntegral_congr measurableSet_Ioi fun t ht => ?_
dsimp only
rw [← mul_smul, ← mul_assoc, inv_mul_cancel (mt abs_eq_zero.1 ha), one_mul, ← smul_assoc,
real_smul]
rw [ofReal_cpow (le_of_lt ht), ← cpow_mul_ofReal_nonneg (le_of_lt ht), ←
cpow_add _ _ (ofReal_ne_zero.mpr <| ne_of_gt ht), ofReal_sub, ofReal_one, mul_sub,
mul_div_cancel₀ _ (ofReal_ne_zero.mpr ha), add_comm, ← add_sub_assoc, mul_one, sub_add_cancel]
theorem mellin_comp_mul_left (f : ℝ → E) (s : ℂ) {a : ℝ} (ha : 0 < a) :
mellin (fun t => f (a * t)) s = (a : ℂ) ^ (-s) • mellin f s := by
simp_rw [mellin]
have : EqOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f (a * t))
(fun t : ℝ => (a : ℂ) ^ (1 - s) • (fun u : ℝ => (u : ℂ) ^ (s - 1) • f u) (a * t))
(Ioi 0) := fun t ht ↦ by
dsimp only
rw [ofReal_mul, mul_cpow_ofReal_nonneg ha.le (le_of_lt ht), ← mul_smul,
(by ring : 1 - s = -(s - 1)), cpow_neg, inv_mul_cancel_left₀]
rw [Ne, cpow_eq_zero_iff, ofReal_eq_zero, not_and_or]
exact Or.inl ha.ne'
rw [setIntegral_congr measurableSet_Ioi this, integral_smul,
integral_comp_mul_left_Ioi (fun u ↦ (u : ℂ) ^ (s - 1) • f u) _ ha,
mul_zero, ← Complex.coe_smul, ← mul_smul, sub_eq_add_neg,
cpow_add _ _ (ofReal_ne_zero.mpr ha.ne'), cpow_one, ofReal_inv,
mul_assoc, mul_comm, inv_mul_cancel_right₀ (ofReal_ne_zero.mpr ha.ne')]
theorem mellin_comp_mul_right (f : ℝ → E) (s : ℂ) {a : ℝ} (ha : 0 < a) :
mellin (fun t => f (t * a)) s = (a : ℂ) ^ (-s) • mellin f s := by
simpa only [mul_comm] using mellin_comp_mul_left f s ha
theorem mellin_comp_inv (f : ℝ → E) (s : ℂ) : mellin (fun t => f t⁻¹) s = mellin f (-s) := by
simp_rw [← rpow_neg_one, mellin_comp_rpow _ _ _, abs_neg, abs_one,
inv_one, one_smul, ofReal_neg, ofReal_one, div_neg, div_one]
/-- Predicate standing for "the Mellin transform of `f` is defined at `s` and equal to `m`". This
shortens some arguments. -/
def HasMellin (f : ℝ → E) (s : ℂ) (m : E) : Prop :=
MellinConvergent f s ∧ mellin f s = m
theorem hasMellin_add {f g : ℝ → E} {s : ℂ} (hf : MellinConvergent f s)
(hg : MellinConvergent g s) : HasMellin (fun t => f t + g t) s (mellin f s + mellin g s) :=
⟨by simpa only [MellinConvergent, smul_add] using hf.add hg, by
simpa only [mellin, smul_add] using integral_add hf hg⟩
theorem hasMellin_sub {f g : ℝ → E} {s : ℂ} (hf : MellinConvergent f s)
(hg : MellinConvergent g s) : HasMellin (fun t => f t - g t) s (mellin f s - mellin g s) :=
⟨by simpa only [MellinConvergent, smul_sub] using hf.sub hg, by
simpa only [mellin, smul_sub] using integral_sub hf hg⟩
end Defs
variable {E : Type*} [NormedAddCommGroup E]
section MellinConvergent
/-! ## Convergence of Mellin transform integrals -/
/-- Auxiliary lemma to reduce convergence statements from vector-valued functions to real
scalar-valued functions. -/
theorem mellin_convergent_iff_norm [NormedSpace ℂ E] {f : ℝ → E} {T : Set ℝ} (hT : T ⊆ Ioi 0)
(hT' : MeasurableSet T) (hfc : AEStronglyMeasurable f <| volume.restrict <| Ioi 0) {s : ℂ} :
IntegrableOn (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) T ↔
IntegrableOn (fun t : ℝ => t ^ (s.re - 1) * ‖f t‖) T := by
have : AEStronglyMeasurable (fun t : ℝ => (t : ℂ) ^ (s - 1) • f t) (volume.restrict T) := by
refine ((ContinuousAt.continuousOn ?_).aestronglyMeasurable hT').smul (hfc.mono_set hT)
exact fun t ht => continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt (hT ht))
rw [IntegrableOn, ← integrable_norm_iff this, ← IntegrableOn]
refine integrableOn_congr_fun (fun t ht => ?_) hT'
simp_rw [norm_smul, Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos (hT ht), sub_re, one_re]
/-- If `f` is a locally integrable real-valued function which is `O(x ^ (-a))` at `∞`, then for any
`s < a`, its Mellin transform converges on some neighbourhood of `+∞`. -/
theorem mellin_convergent_top_of_isBigO {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0)) {a s : ℝ}
(hf : f =O[atTop] (· ^ (-a))) (hs : s < a) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioi c) := by
obtain ⟨d, hd'⟩ := hf.isBigOWith
simp_rw [IsBigOWith, eventually_atTop] at hd'
obtain ⟨e, he⟩ := hd'
have he' : 0 < max e 1 := zero_lt_one.trans_le (le_max_right _ _)
refine ⟨max e 1, he', ?_, ?_⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set (Ioi_subset_Ioi he'.le))
refine (ContinuousAt.continuousOn fun t ht => ?_).aestronglyMeasurable measurableSet_Ioi
exact continuousAt_rpow_const _ _ (Or.inl <| (he'.trans ht).ne')
· have : ∀ᵐ t : ℝ ∂volume.restrict (Ioi <| max e 1),
‖t ^ (s - 1) * f t‖ ≤ t ^ (s - 1 + -a) * d := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht => ?_
have ht' : 0 < t := he'.trans ht
rw [norm_mul, rpow_add ht', ← norm_of_nonneg (rpow_nonneg ht'.le (-a)), mul_assoc,
mul_comm _ d, norm_of_nonneg (rpow_nonneg ht'.le _)]
gcongr
exact he t ((le_max_left e 1).trans_lt ht).le
refine (HasFiniteIntegral.mul_const ?_ _).mono' this
exact (integrableOn_Ioi_rpow_of_lt (by linarith) he').hasFiniteIntegral
/-- If `f` is a locally integrable real-valued function which is `O(x ^ (-b))` at `0`, then for any
`b < s`, its Mellin transform converges on some right neighbourhood of `0`. -/
theorem mellin_convergent_zero_of_isBigO {b : ℝ} {f : ℝ → ℝ}
(hfc : AEStronglyMeasurable f <| volume.restrict (Ioi 0))
(hf : f =O[𝓝[>] 0] (· ^ (-b))) {s : ℝ} (hs : b < s) :
∃ c : ℝ, 0 < c ∧ IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioc 0 c) := by
obtain ⟨d, _, hd'⟩ := hf.exists_pos
simp_rw [IsBigOWith, eventually_nhdsWithin_iff, Metric.eventually_nhds_iff, gt_iff_lt] at hd'
obtain ⟨ε, hε, hε'⟩ := hd'
refine ⟨ε, hε, integrableOn_Ioc_iff_integrableOn_Ioo.mpr ⟨?_, ?_⟩⟩
· refine AEStronglyMeasurable.mul ?_ (hfc.mono_set Ioo_subset_Ioi_self)
refine (ContinuousAt.continuousOn fun t ht => ?_).aestronglyMeasurable measurableSet_Ioo
exact continuousAt_rpow_const _ _ (Or.inl ht.1.ne')
· apply HasFiniteIntegral.mono'
· show HasFiniteIntegral (fun t => d * t ^ (s - b - 1)) _
refine (Integrable.hasFiniteIntegral ?_).const_mul _
rw [← IntegrableOn, ← integrableOn_Ioc_iff_integrableOn_Ioo, ←
intervalIntegrable_iff_integrableOn_Ioc_of_le hε.le]
exact intervalIntegral.intervalIntegrable_rpow' (by linarith)
· refine (ae_restrict_iff' measurableSet_Ioo).mpr (eventually_of_forall fun t ht => ?_)
rw [mul_comm, norm_mul]
specialize hε' _ ht.1
· rw [dist_eq_norm, sub_zero, norm_of_nonneg (le_of_lt ht.1)]
exact ht.2
· calc _ ≤ d * ‖t ^ (-b)‖ * ‖t ^ (s - 1)‖ := by gcongr
_ = d * t ^ (s - b - 1) := ?_
simp_rw [norm_of_nonneg (rpow_nonneg (le_of_lt ht.1) _), mul_assoc]
rw [← rpow_add ht.1]
congr 2
abel
/-- If `f` is a locally integrable real-valued function on `Ioi 0` which is `O(x ^ (-a))` at `∞`
and `O(x ^ (-b))` at `0`, then its Mellin transform integral converges for `b < s < a`. -/
theorem mellin_convergent_of_isBigO_scalar {a b : ℝ} {f : ℝ → ℝ} {s : ℝ}
(hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s) :
IntegrableOn (fun t : ℝ => t ^ (s - 1) * f t) (Ioi 0) := by
obtain ⟨c1, hc1, hc1'⟩ := mellin_convergent_top_of_isBigO hfc.aestronglyMeasurable hf_top hs_top
obtain ⟨c2, hc2, hc2'⟩ :=
mellin_convergent_zero_of_isBigO hfc.aestronglyMeasurable hf_bot hs_bot
have : Ioi 0 = Ioc 0 c2 ∪ Ioc c2 c1 ∪ Ioi c1 := by
rw [union_assoc, Ioc_union_Ioi (le_max_right _ _),
Ioc_union_Ioi ((min_le_left _ _).trans (le_max_right _ _)), min_eq_left (lt_min hc2 hc1).le]
rw [this, integrableOn_union, integrableOn_union]
refine ⟨⟨hc2', integrableOn_Icc_iff_integrableOn_Ioc.mp ?_⟩, hc1'⟩
refine
(hfc.continuousOn_mul ?_ isOpen_Ioi).integrableOn_compact_subset
(fun t ht => (hc2.trans_le ht.1 : 0 < t)) isCompact_Icc
exact ContinuousAt.continuousOn fun t ht => continuousAt_rpow_const _ _ <| Or.inl <| ne_of_gt ht
theorem mellinConvergent_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ} {f : ℝ → E} {s : ℂ}
(hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s.re < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
MellinConvergent f s := by
rw [MellinConvergent,
mellin_convergent_iff_norm Subset.rfl measurableSet_Ioi hfc.aestronglyMeasurable]
exact mellin_convergent_of_isBigO_scalar hfc.norm hf_top.norm_left hs_top hf_bot.norm_left hs_bot
end MellinConvergent
section MellinDiff
/-- If `f` is `O(x ^ (-a))` as `x → +∞`, then `log • f` is `O(x ^ (-b))` for every `b < a`. -/
theorem isBigO_rpow_top_log_smul [NormedSpace ℝ E] {a b : ℝ} {f : ℝ → E} (hab : b < a)
(hf : f =O[atTop] (· ^ (-a))) :
(fun t : ℝ => log t • f t) =O[atTop] (· ^ (-b)) := by
refine
((isLittleO_log_rpow_atTop (sub_pos.mpr hab)).isBigO.smul hf).congr'
(eventually_of_forall fun t => by rfl)
((eventually_gt_atTop 0).mp (eventually_of_forall fun t ht => ?_))
simp only
rw [smul_eq_mul, ← rpow_add ht, ← sub_eq_add_neg, sub_eq_add_neg a, add_sub_cancel_left]
/-- If `f` is `O(x ^ (-a))` as `x → 0`, then `log • f` is `O(x ^ (-b))` for every `a < b`. -/
theorem isBigO_rpow_zero_log_smul [NormedSpace ℝ E] {a b : ℝ} {f : ℝ → E} (hab : a < b)
(hf : f =O[𝓝[>] 0] (· ^ (-a))) :
(fun t : ℝ => log t • f t) =O[𝓝[>] 0] (· ^ (-b)) := by
have : log =o[𝓝[>] 0] fun t : ℝ => t ^ (a - b) := by
refine ((isLittleO_log_rpow_atTop (sub_pos.mpr hab)).neg_left.comp_tendsto
tendsto_inv_zero_atTop).congr'
(eventually_nhdsWithin_iff.mpr <| eventually_of_forall fun t ht => ?_)
(eventually_nhdsWithin_iff.mpr <| eventually_of_forall fun t ht => ?_)
· simp_rw [Function.comp_apply, ← one_div, log_div one_ne_zero (ne_of_gt ht), Real.log_one,
zero_sub, neg_neg]
· simp_rw [Function.comp_apply, inv_rpow (le_of_lt ht), ← rpow_neg (le_of_lt ht), neg_sub]
refine (this.isBigO.smul hf).congr' (eventually_of_forall fun t => by rfl)
(eventually_nhdsWithin_iff.mpr (eventually_of_forall fun t ht => ?_))
simp_rw [smul_eq_mul, ← rpow_add ht]
congr 1
abel
/-- Suppose `f` is locally integrable on `(0, ∞)`, is `O(x ^ (-a))` as `x → ∞`, and is
`O(x ^ (-b))` as `x → 0`. Then its Mellin transform is differentiable on the domain `b < re s < a`,
with derivative equal to the Mellin transform of `log • f`. -/
theorem mellin_hasDerivAt_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ}
{f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f (Ioi 0)) (hf_top : f =O[atTop] (· ^ (-a)))
(hs_top : s.re < a) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
MellinConvergent (fun t => log t • f t) s ∧
HasDerivAt (mellin f) (mellin (fun t => log t • f t) s) s := by
set F : ℂ → ℝ → E := fun (z : ℂ) (t : ℝ) => (t : ℂ) ^ (z - 1) • f t
set F' : ℂ → ℝ → E := fun (z : ℂ) (t : ℝ) => ((t : ℂ) ^ (z - 1) * log t) • f t
-- A convenient radius of ball within which we can uniformly bound the derivative.
obtain ⟨v, hv0, hv1, hv2⟩ : ∃ v : ℝ, 0 < v ∧ v < s.re - b ∧ v < a - s.re := by
obtain ⟨w, hw1, hw2⟩ := exists_between (sub_pos.mpr hs_top)
obtain ⟨w', hw1', hw2'⟩ := exists_between (sub_pos.mpr hs_bot)
exact
⟨min w w', lt_min hw1 hw1', (min_le_right _ _).trans_lt hw2', (min_le_left _ _).trans_lt hw2⟩
let bound : ℝ → ℝ := fun t : ℝ => (t ^ (s.re + v - 1) + t ^ (s.re - v - 1)) * |log t| * ‖f t‖
have h1 : ∀ᶠ z : ℂ in 𝓝 s, AEStronglyMeasurable (F z) (volume.restrict <| Ioi 0) := by
refine eventually_of_forall fun z => AEStronglyMeasurable.smul ?_ hfc.aestronglyMeasurable
refine ContinuousOn.aestronglyMeasurable ?_ measurableSet_Ioi
refine ContinuousAt.continuousOn fun t ht => ?_
exact continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt ht)
have h2 : IntegrableOn (F s) (Ioi (0 : ℝ)) := by
exact mellinConvergent_of_isBigO_rpow hfc hf_top hs_top hf_bot hs_bot
have h3 : AEStronglyMeasurable (F' s) (volume.restrict <| Ioi 0) := by
apply LocallyIntegrableOn.aestronglyMeasurable
refine hfc.continuousOn_smul isOpen_Ioi ((ContinuousAt.continuousOn fun t ht => ?_).mul ?_)
· exact continuousAt_ofReal_cpow_const _ _ (Or.inr <| ne_of_gt ht)
· refine continuous_ofReal.comp_continuousOn ?_
exact continuousOn_log.mono (subset_compl_singleton_iff.mpr not_mem_Ioi_self)
have h4 : ∀ᵐ t : ℝ ∂volume.restrict (Ioi 0),
∀ z : ℂ, z ∈ Metric.ball s v → ‖F' z t‖ ≤ bound t := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht z hz => ?_
simp_rw [F', bound, norm_smul, norm_mul, Complex.norm_eq_abs (log _), Complex.abs_ofReal,
mul_assoc]
gcongr
rw [Complex.norm_eq_abs, abs_cpow_eq_rpow_re_of_pos ht]
rcases le_or_lt 1 t with h | h
· refine le_add_of_le_of_nonneg (rpow_le_rpow_of_exponent_le h ?_)
(rpow_nonneg (zero_le_one.trans h) _)
rw [sub_re, one_re, sub_le_sub_iff_right]
rw [mem_ball_iff_norm, Complex.norm_eq_abs] at hz
have hz' := (re_le_abs _).trans hz.le
rwa [sub_re, sub_le_iff_le_add'] at hz'
· refine
le_add_of_nonneg_of_le (rpow_pos_of_pos ht _).le (rpow_le_rpow_of_exponent_ge ht h.le ?_)
rw [sub_re, one_re, sub_le_iff_le_add, sub_add_cancel]
rw [mem_ball_iff_norm', Complex.norm_eq_abs] at hz
have hz' := (re_le_abs _).trans hz.le
rwa [sub_re, sub_le_iff_le_add, ← sub_le_iff_le_add'] at hz'
have h5 : IntegrableOn bound (Ioi 0) := by
simp_rw [bound, add_mul, mul_assoc]
suffices ∀ {j : ℝ}, b < j → j < a →
IntegrableOn (fun t : ℝ => t ^ (j - 1) * (|log t| * ‖f t‖)) (Ioi 0) volume by
refine Integrable.add (this ?_ ?_) (this ?_ ?_)
all_goals linarith
· intro j hj hj'
obtain ⟨w, hw1, hw2⟩ := exists_between hj
obtain ⟨w', hw1', hw2'⟩ := exists_between hj'
refine mellin_convergent_of_isBigO_scalar ?_ ?_ hw1' ?_ hw2
· simp_rw [mul_comm]
refine hfc.norm.mul_continuousOn ?_ isOpen_Ioi
refine Continuous.comp_continuousOn _root_.continuous_abs (continuousOn_log.mono ?_)
exact subset_compl_singleton_iff.mpr not_mem_Ioi_self
· refine (isBigO_rpow_top_log_smul hw2' hf_top).norm_left.congr_left fun t ↦ ?_
simp only [norm_smul, Real.norm_eq_abs]
· refine (isBigO_rpow_zero_log_smul hw1 hf_bot).norm_left.congr_left fun t ↦ ?_
simp only [norm_smul, Real.norm_eq_abs]
have h6 : ∀ᵐ t : ℝ ∂volume.restrict (Ioi 0),
∀ y : ℂ, y ∈ Metric.ball s v → HasDerivAt (fun z : ℂ => F z t) (F' y t) y := by
refine (ae_restrict_mem measurableSet_Ioi).mono fun t ht y _ => ?_
have ht' : (t : ℂ) ≠ 0 := ofReal_ne_zero.mpr (ne_of_gt ht)
have u1 : HasDerivAt (fun z : ℂ => (t : ℂ) ^ (z - 1)) (t ^ (y - 1) * log t) y := by
convert ((hasDerivAt_id' y).sub_const 1).const_cpow (Or.inl ht') using 1
rw [ofReal_log (le_of_lt ht)]
ring
exact u1.smul_const (f t)
have main := hasDerivAt_integral_of_dominated_loc_of_deriv_le hv0 h1 h2 h3 h4 h5 h6
simpa only [F', mul_smul] using main
/-- Suppose `f` is locally integrable on `(0, ∞)`, is `O(x ^ (-a))` as `x → ∞`, and is
`O(x ^ (-b))` as `x → 0`. Then its Mellin transform is differentiable on the domain `b < re s < a`.
-/
theorem mellin_differentiableAt_of_isBigO_rpow [NormedSpace ℂ E] {a b : ℝ}
{f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0)
(hf_top : f =O[atTop] (· ^ (-a))) (hs_top : s.re < a)
(hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) :
DifferentiableAt ℂ (mellin f) s :=
(mellin_hasDerivAt_of_isBigO_rpow hfc hf_top hs_top hf_bot hs_bot).2.differentiableAt
end MellinDiff
section ExpDecay
/-- If `f` is locally integrable, decays exponentially at infinity, and is `O(x ^ (-b))` at 0, then
its Mellin transform converges for `b < s.re`. -/
theorem mellinConvergent_of_isBigO_rpow_exp [NormedSpace ℂ E] {a b : ℝ} (ha : 0 < a) {f : ℝ → E}
{s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0) (hf_top : f =O[atTop] fun t => exp (-a * t))
(hf_bot : f =O[𝓝[>] 0] (· ^ (-b))) (hs_bot : b < s.re) : MellinConvergent f s :=
mellinConvergent_of_isBigO_rpow hfc (hf_top.trans (isLittleO_exp_neg_mul_rpow_atTop ha _).isBigO)
(lt_add_one _) hf_bot hs_bot
/-- If `f` is locally integrable, decays exponentially at infinity, and is `O(x ^ (-b))` at 0, then
its Mellin transform is holomorphic on `b < s.re`. -/
theorem mellin_differentiableAt_of_isBigO_rpow_exp [NormedSpace ℂ E] {a b : ℝ}
(ha : 0 < a) {f : ℝ → E} {s : ℂ} (hfc : LocallyIntegrableOn f <| Ioi 0)
(hf_top : f =O[atTop] fun t => exp (-a * t)) (hf_bot : f =O[𝓝[>] 0] (· ^ (-b)))
(hs_bot : b < s.re) : DifferentiableAt ℂ (mellin f) s :=
mellin_differentiableAt_of_isBigO_rpow hfc
(hf_top.trans (isLittleO_exp_neg_mul_rpow_atTop ha _).isBigO) (lt_add_one _) hf_bot hs_bot
end ExpDecay
section MellinIoc
/-!
## Mellin transforms of functions on `Ioc 0 1`
-/
/-- The Mellin transform of the indicator function of `Ioc 0 1`. -/
theorem hasMellin_one_Ioc {s : ℂ} (hs : 0 < re s) :
HasMellin (indicator (Ioc 0 1) (fun _ => 1 : ℝ → ℂ)) s (1 / s) := by
have aux1 : -1 < (s - 1).re := by
simpa only [sub_re, one_re, sub_eq_add_neg] using lt_add_of_pos_left _ hs
have aux2 : s ≠ 0 := by contrapose! hs; rw [hs, zero_re]
have aux3 : MeasurableSet (Ioc (0 : ℝ) 1) := measurableSet_Ioc
simp_rw [HasMellin, mellin, MellinConvergent, ← indicator_smul, IntegrableOn,
integrable_indicator_iff aux3, smul_eq_mul, integral_indicator aux3, mul_one, IntegrableOn,
Measure.restrict_restrict_of_subset Ioc_subset_Ioi_self]
rw [← IntegrableOn, ← intervalIntegrable_iff_integrableOn_Ioc_of_le zero_le_one]
refine ⟨intervalIntegral.intervalIntegrable_cpow' aux1, ?_⟩
rw [← intervalIntegral.integral_of_le zero_le_one, integral_cpow (Or.inl aux1), sub_add_cancel,
ofReal_zero, ofReal_one, one_cpow, zero_cpow aux2, sub_zero]
/-- The Mellin transform of a power function restricted to `Ioc 0 1`. -/
theorem hasMellin_cpow_Ioc (a : ℂ) {s : ℂ} (hs : 0 < re s + re a) :
HasMellin (indicator (Ioc 0 1) (fun t => ↑t ^ a : ℝ → ℂ)) s (1 / (s + a)) := by
have := hasMellin_one_Ioc (by rwa [add_re] : 0 < (s + a).re)
simp_rw [HasMellin, ← MellinConvergent.cpow_smul, ← mellin_cpow_smul, ← indicator_smul,
smul_eq_mul, mul_one] at this
exact this
end MellinIoc
|
Analysis\Oscillation.lean | /-
Copyright (c) 2024 James Sundstrom. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: James Sundstrom
-/
import Mathlib.Topology.EMetricSpace.Basic
import Mathlib.Order.WellFoundedSet
/-!
# Oscillation
In this file we define the oscillation of a function `f: E → F` at a point `x` of `E`. (`E` is
required to be a TopologicalSpace and `F` a PseudoEMetricSpace.) The oscillation of `f` at `x` is
defined to be the infimum of `diam f '' N` for all neighborhoods `N` of `x`. We also define
`oscillationWithin f D x`, which is the oscillation at `x` of `f` restricted to `D`.
We also prove some simple facts about oscillation, most notably that the oscillation of `f`
at `x` is 0 if and only if `f` is continuous at `x`, with versions for both `oscillation` and
`oscillationWithin`.
## Tags
oscillation, oscillationWithin
-/
open Topology EMetric Set ENNReal
universe u v
variable {E : Type u} {F : Type v} [PseudoEMetricSpace F]
/-- The oscillation of `f : E → F` at `x`. -/
noncomputable def oscillation [TopologicalSpace E] (f : E → F) (x : E) : ENNReal :=
⨅ S ∈ (𝓝 x).map f, diam S
/-- The oscillation of `f : E → F` within `D` at `x`. -/
noncomputable def oscillationWithin [TopologicalSpace E] (f : E → F) (D : Set E) (x : E) :
ENNReal := ⨅ S ∈ (𝓝[D] x).map f, diam S
/-- The oscillation of `f` at `x` within a neighborhood `D` of `x` is equal to `oscillation f x` -/
theorem oscillationWithin_nhd_eq_oscillation [TopologicalSpace E] (f : E → F) (D : Set E) (x : E)
(hD : D ∈ 𝓝 x) : oscillationWithin f D x = oscillation f x := by
rw [oscillation, oscillationWithin, nhdsWithin_eq_nhds.2 hD]
/-- The oscillation of `f` at `x` within `univ` is equal to `oscillation f x` -/
theorem oscillationWithin_univ_eq_oscillation [TopologicalSpace E] (f : E → F) (x : E) :
oscillationWithin f univ x = oscillation f x :=
oscillationWithin_nhd_eq_oscillation f univ x Filter.univ_mem
namespace ContinuousWithinAt
theorem oscillationWithin_eq_zero [TopologicalSpace E] {f : E → F} {D : Set E}
{x : E} (hf : ContinuousWithinAt f D x) : oscillationWithin f D x = 0 := by
refine le_antisymm (le_of_forall_pos_le_add fun ε hε _ ↦ ?_) (zero_le _)
rw [zero_add]
have : ball (f x) (ε / 2) ∈ (𝓝[D] x).map f := hf <| ball_mem_nhds _ (by simp [ne_of_gt hε])
refine (biInf_le diam this).trans (le_of_le_of_eq diam_ball ?_)
exact (ENNReal.mul_div_cancel' (by norm_num) (by norm_num))
end ContinuousWithinAt
namespace ContinuousAt
theorem oscillation_eq_zero [TopologicalSpace E] {f : E → F} {x : E} (hf : ContinuousAt f x) :
oscillation f x = 0 := by
rw [← continuousWithinAt_univ f x] at hf
exact oscillationWithin_univ_eq_oscillation f x ▸ hf.oscillationWithin_eq_zero
end ContinuousAt
namespace OscillationWithin
/-- The oscillation within `D` of `f` at `x ∈ D` is 0 if and only if `ContinuousWithinAt f D x`. -/
theorem eq_zero_iff_continuousWithinAt [TopologicalSpace E] (f : E → F) {D : Set E}
{x : E} (xD : x ∈ D) : oscillationWithin f D x = 0 ↔ ContinuousWithinAt f D x := by
refine ⟨fun hf ↦ EMetric.tendsto_nhds.mpr (fun ε ε0 ↦ ?_), fun hf ↦ hf.oscillationWithin_eq_zero⟩
simp_rw [← hf, oscillationWithin, iInf_lt_iff] at ε0
obtain ⟨S, hS, Sε⟩ := ε0
refine Filter.mem_of_superset hS (fun y hy ↦ lt_of_le_of_lt ?_ Sε)
exact edist_le_diam_of_mem (mem_preimage.1 hy) <| mem_preimage.1 (mem_of_mem_nhdsWithin xD hS)
end OscillationWithin
namespace Oscillation
/-- The oscillation of `f` at `x` is 0 if and only if `f` is continuous at `x`. -/
theorem eq_zero_iff_continuousAt [TopologicalSpace E] (f : E → F) (x : E) :
oscillation f x = 0 ↔ ContinuousAt f x := by
rw [← oscillationWithin_univ_eq_oscillation, ← continuousWithinAt_univ f x]
exact OscillationWithin.eq_zero_iff_continuousWithinAt f (mem_univ x)
end Oscillation
namespace IsCompact
variable [PseudoEMetricSpace E] {K : Set E}
variable {f : E → F} {D : Set E} {ε : ENNReal}
/-- If `oscillationWithin f D x < ε` at every `x` in a compact set `K`, then there exists `δ > 0`
such that the oscillation of `f` on `ball x δ ∩ D` is less than `ε` for every `x` in `K`. -/
theorem uniform_oscillationWithin (comp : IsCompact K) (hK : ∀ x ∈ K, oscillationWithin f D x < ε) :
∃ δ > 0, ∀ x ∈ K, diam (f '' (ball x (ENNReal.ofReal δ) ∩ D)) ≤ ε := by
let S := fun r ↦ { x : E | ∃ (a : ℝ), (a > r ∧ diam (f '' (ball x (ENNReal.ofReal a) ∩ D)) ≤ ε) }
have S_open : ∀ r > 0, IsOpen (S r) := by
refine fun r _ ↦ isOpen_iff.mpr fun x ⟨a, ar, ha⟩ ↦
⟨ENNReal.ofReal ((a - r) / 2), by simp [ar], ?_⟩
refine fun y hy ↦ ⟨a - (a - r) / 2, by linarith,
le_trans (diam_mono (image_mono fun z hz ↦ ?_)) ha⟩
refine ⟨lt_of_le_of_lt (edist_triangle z y x) (lt_of_lt_of_eq (add_lt_add hz.1 hy) ?_),
hz.2⟩
rw [← ofReal_add (by linarith) (by linarith), sub_add_cancel]
have S_cover : K ⊆ ⋃ r > 0, S r := by
intro x hx
have : oscillationWithin f D x < ε := hK x hx
simp only [oscillationWithin, Filter.mem_map, iInf_lt_iff] at this
obtain ⟨n, hn₁, hn₂⟩ := this
obtain ⟨r, r0, hr⟩ := mem_nhdsWithin_iff.1 hn₁
simp only [gt_iff_lt, mem_iUnion, exists_prop]
have : ∀ r', (ENNReal.ofReal r') ≤ r → diam (f '' (ball x (ENNReal.ofReal r') ∩ D)) ≤ ε := by
intro r' hr'
refine le_trans (diam_mono (subset_trans ?_ (image_subset_iff.2 hr))) (le_of_lt hn₂)
exact image_mono (inter_subset_inter_left D (ball_subset_ball hr'))
by_cases r_top : r = ⊤
· use 1, one_pos, 2, one_lt_two, this 2 (by simp only [r_top, le_top])
· obtain ⟨r', hr'⟩ := exists_between (toReal_pos (ne_of_gt r0) r_top)
use r', hr'.1, r.toReal, hr'.2, this r.toReal ofReal_toReal_le
have S_antitone : ∀ (r₁ r₂ : ℝ), r₁ ≤ r₂ → S r₂ ⊆ S r₁ :=
fun r₁ r₂ hr x ⟨a, ar₂, ha⟩ ↦ ⟨a, lt_of_le_of_lt hr ar₂, ha⟩
obtain ⟨δ, δ0, hδ⟩ : ∃ r > 0, K ⊆ S r := by
obtain ⟨T, Tb, Tfin, hT⟩ := comp.elim_finite_subcover_image S_open S_cover
by_cases T_nonempty : T.Nonempty
· use Tfin.isWF.min T_nonempty, Tb (Tfin.isWF.min_mem T_nonempty)
intro x hx
obtain ⟨r, hr⟩ := mem_iUnion.1 (hT hx)
simp only [mem_iUnion, exists_prop] at hr
exact (S_antitone _ r (IsWF.min_le Tfin.isWF T_nonempty hr.1)) hr.2
· rw [not_nonempty_iff_eq_empty] at T_nonempty
use 1, one_pos, subset_trans hT (by simp [T_nonempty])
use δ, δ0
intro x xK
obtain ⟨a, δa, ha⟩ := hδ xK
exact (diam_mono <| image_mono <| inter_subset_inter_left D <| ball_subset_ball <|
coe_le_coe.2 <| Real.toNNReal_mono (le_of_lt δa)).trans ha
/-- If `oscillation f x < ε` at every `x` in a compact set `K`, then there exists `δ > 0` such
that the oscillation of `f` on `ball x δ` is less than `ε` for every `x` in `K`. -/
theorem uniform_oscillation {K : Set E} (comp : IsCompact K)
{f : E → F} {ε : ENNReal} (hK : ∀ x ∈ K, oscillation f x < ε) :
∃ δ > 0, ∀ x ∈ K, diam (f '' (ball x (ENNReal.ofReal δ))) ≤ ε := by
simp only [← oscillationWithin_univ_eq_oscillation] at hK
convert ← comp.uniform_oscillationWithin hK
exact inter_univ _
end IsCompact
|
Analysis\PSeries.lean | /-
Copyright (c) 2020 Yury G. Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury G. Kudryashov
-/
import Mathlib.Analysis.SpecialFunctions.Pow.NNReal
import Mathlib.Analysis.SpecialFunctions.Pow.Continuity
import Mathlib.Analysis.SumOverResidueClass
/-!
# Convergence of `p`-series
In this file we prove that the series `∑' k in ℕ, 1 / k ^ p` converges if and only if `p > 1`.
The proof is based on the
[Cauchy condensation test](https://en.wikipedia.org/wiki/Cauchy_condensation_test): `∑ k, f k`
converges if and only if so does `∑ k, 2 ^ k f (2 ^ k)`. We prove this test in
`NNReal.summable_condensed_iff` and `summable_condensed_iff_of_nonneg`, then use it to prove
`summable_one_div_rpow`. After this transformation, a `p`-series turns into a geometric series.
## Tags
p-series, Cauchy condensation test
-/
/-!
### Schlömilch's generalization of the Cauchy condensation test
In this section we prove the Schlömilch's generalization of the Cauchy condensation test:
for a strictly increasing `u : ℕ → ℕ` with ratio of successive differences bounded and an
antitone `f : ℕ → ℝ≥0` or `f : ℕ → ℝ`, `∑ k, f k` converges if and only if
so does `∑ k, (u (k + 1) - u k) * f (u k)`. Instead of giving a monolithic proof, we split it
into a series of lemmas with explicit estimates of partial sums of each series in terms of the
partial sums of the other series.
-/
/--
A sequence `u` has the property that its ratio of successive differences is bounded
when there is a positive real number `C` such that, for all n ∈ ℕ,
(u (n + 2) - u (n + 1)) ≤ C * (u (n + 1) - u n)
-/
def SuccDiffBounded (C : ℕ) (u : ℕ → ℕ) : Prop :=
∀ n : ℕ, u (n + 2) - u (n + 1) ≤ C • (u (n + 1) - u n)
namespace Finset
variable {M : Type*} [OrderedAddCommMonoid M] {f : ℕ → M} {u : ℕ → ℕ}
theorem le_sum_schlomilch' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ Ico (u 0) (u n), f k) ≤ ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by
induction' n with n ihn
· simp
suffices (∑ k ∈ Ico (u n) (u (n + 1)), f k) ≤ (u (n + 1) - u n) • f (u n) by
rw [sum_range_succ, ← sum_Ico_consecutive]
· exact add_le_add ihn this
exacts [hu n.zero_le, hu n.le_succ]
have : ∀ k ∈ Ico (u n) (u (n + 1)), f k ≤ f (u n) := fun k hk =>
hf (Nat.succ_le_of_lt (h_pos n)) (mem_Ico.mp hk).1
convert sum_le_sum this
simp [pow_succ, mul_two]
theorem le_sum_condensed' (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ Ico 1 (2 ^ n), f k) ≤ ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by
convert le_sum_schlomilch' hf (fun n => pow_pos zero_lt_two n)
(fun m n hm => pow_le_pow_right one_le_two hm) n using 2
simp [pow_succ, mul_two, two_mul]
theorem le_sum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ range (u n), f k) ≤
∑ k ∈ range (u 0), f k + ∑ k ∈ range n, (u (k + 1) - u k) • f (u k) := by
convert add_le_add_left (le_sum_schlomilch' hf h_pos hu n) (∑ k ∈ range (u 0), f k)
rw [← sum_range_add_sum_Ico _ (hu n.zero_le)]
theorem le_sum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range (2 ^ n), f k) ≤ f 0 + ∑ k ∈ range n, 2 ^ k • f (2 ^ k) := by
convert add_le_add_left (le_sum_condensed' hf n) (f 0)
rw [← sum_range_add_sum_Ico _ n.one_le_two_pow, sum_range_succ, sum_range_zero, zero_add]
theorem sum_schlomilch_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : Monotone u) (n : ℕ) :
(∑ k ∈ range n, (u (k + 1) - u k) • f (u (k + 1))) ≤ ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by
induction' n with n ihn
· simp
suffices (u (n + 1) - u n) • f (u (n + 1)) ≤ ∑ k ∈ Ico (u n + 1) (u (n + 1) + 1), f k by
rw [sum_range_succ, ← sum_Ico_consecutive]
exacts [add_le_add ihn this,
(add_le_add_right (hu n.zero_le) _ : u 0 + 1 ≤ u n + 1),
add_le_add_right (hu n.le_succ) _]
have : ∀ k ∈ Ico (u n + 1) (u (n + 1) + 1), f (u (n + 1)) ≤ f k := fun k hk =>
hf (Nat.lt_of_le_of_lt (Nat.succ_le_of_lt (h_pos n)) <| (Nat.lt_succ_of_le le_rfl).trans_le
(mem_Ico.mp hk).1) (Nat.le_of_lt_succ <| (mem_Ico.mp hk).2)
convert sum_le_sum this
simp [pow_succ, mul_two]
theorem sum_condensed_le' (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range n, 2 ^ k • f (2 ^ (k + 1))) ≤ ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by
convert sum_schlomilch_le' hf (fun n => pow_pos zero_lt_two n)
(fun m n hm => pow_le_pow_right one_le_two hm) n using 2
simp [pow_succ, mul_two, two_mul]
theorem sum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) (n : ℕ) :
∑ k ∈ range (n + 1), (u (k + 1) - u k) • f (u k) ≤
(u 1 - u 0) • f (u 0) + C • ∑ k ∈ Ico (u 0 + 1) (u n + 1), f k := by
rw [sum_range_succ', add_comm]
gcongr
suffices ∑ k ∈ range n, (u (k + 2) - u (k + 1)) • f (u (k + 1)) ≤
C • ∑ k ∈ range n, ((u (k + 1) - u k) • f (u (k + 1))) by
refine this.trans (nsmul_le_nsmul_right ?_ _)
exact sum_schlomilch_le' hf h_pos hu n
have : ∀ k ∈ range n, (u (k + 2) - u (k + 1)) • f (u (k + 1)) ≤
C • ((u (k + 1) - u k) • f (u (k + 1))) := by
intro k _
rw [smul_smul]
gcongr
· exact h_nonneg (u (k + 1))
exact mod_cast h_succ_diff k
convert sum_le_sum this
simp [smul_sum]
theorem sum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (n : ℕ) :
(∑ k ∈ range (n + 1), 2 ^ k • f (2 ^ k)) ≤ f 1 + 2 • ∑ k ∈ Ico 2 (2 ^ n + 1), f k := by
convert add_le_add_left (nsmul_le_nsmul_right (sum_condensed_le' hf n) 2) (f 1)
simp [sum_range_succ', add_comm, pow_succ', mul_nsmul', sum_nsmul]
end Finset
namespace ENNReal
open Filter Finset
variable {u : ℕ → ℕ} {f : ℕ → ℝ≥0∞}
open NNReal in
theorem le_tsum_schlomilch (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu : StrictMono u) :
∑' k , f k ≤ ∑ k ∈ range (u 0), f k + ∑' k : ℕ, (u (k + 1) - u k) * f (u k) := by
rw [ENNReal.tsum_eq_iSup_nat' hu.tendsto_atTop]
refine iSup_le fun n =>
(Finset.le_sum_schlomilch hf h_pos hu.monotone n).trans (add_le_add_left ?_ _)
have (k : ℕ) : (u (k + 1) - u k : ℝ≥0∞) = (u (k + 1) - (u k : ℕ) : ℕ) := by
simp [NNReal.coe_sub (Nat.cast_le (α := ℝ≥0).mpr <| (hu k.lt_succ_self).le)]
simp only [nsmul_eq_mul, this]
apply ENNReal.sum_le_tsum
theorem le_tsum_condensed (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
∑' k, f k ≤ f 0 + ∑' k : ℕ, 2 ^ k * f (2 ^ k) := by
rw [ENNReal.tsum_eq_iSup_nat' (Nat.tendsto_pow_atTop_atTop_of_one_lt _root_.one_lt_two)]
refine iSup_le fun n => (Finset.le_sum_condensed hf n).trans (add_le_add_left ?_ _)
simp only [nsmul_eq_mul, Nat.cast_pow, Nat.cast_two]
apply ENNReal.sum_le_tsum
theorem tsum_schlomilch_le {C : ℕ} (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(h_nonneg : ∀ n, 0 ≤ f n) (hu : Monotone u) (h_succ_diff : SuccDiffBounded C u) :
∑' k : ℕ, (u (k + 1) - u k) * f (u k) ≤ (u 1 - u 0) * f (u 0) + C * ∑' k, f k := by
rw [ENNReal.tsum_eq_iSup_nat' (tendsto_atTop_mono Nat.le_succ tendsto_id)]
refine
iSup_le fun n =>
le_trans ?_
(add_le_add_left
(mul_le_mul_of_nonneg_left (ENNReal.sum_le_tsum <| Finset.Ico (u 0 + 1) (u n + 1)) ?_) _)
simpa using Finset.sum_schlomilch_le hf h_pos h_nonneg hu h_succ_diff n
exact zero_le _
theorem tsum_condensed_le (hf : ∀ ⦃m n⦄, 1 < m → m ≤ n → f n ≤ f m) :
(∑' k : ℕ, 2 ^ k * f (2 ^ k)) ≤ f 1 + 2 * ∑' k, f k := by
rw [ENNReal.tsum_eq_iSup_nat' (tendsto_atTop_mono Nat.le_succ tendsto_id), two_mul, ← two_nsmul]
refine
iSup_le fun n =>
le_trans ?_
(add_le_add_left
(nsmul_le_nsmul_right (ENNReal.sum_le_tsum <| Finset.Ico 2 (2 ^ n + 1)) _) _)
simpa using Finset.sum_condensed_le hf n
end ENNReal
namespace NNReal
open Finset
open ENNReal in
/-- for a series of `NNReal` version. -/
theorem summable_schlomilch_iff {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ≥0}
(hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m)
(h_pos : ∀ n, 0 < u n) (hu_strict : StrictMono u)
(hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :
(Summable fun k : ℕ => (u (k + 1) - (u k : ℝ≥0)) * f (u k)) ↔ Summable f := by
simp only [← tsum_coe_ne_top_iff_summable, Ne, not_iff_not, ENNReal.coe_mul]
constructor <;> intro h
· replace hf : ∀ m n, 1 < m → m ≤ n → (f n : ℝ≥0∞) ≤ f m := fun m n hm hmn =>
ENNReal.coe_le_coe.2 (hf (zero_lt_one.trans hm) hmn)
have h_nonneg : ∀ n, 0 ≤ (f n : ℝ≥0∞) := fun n =>
ENNReal.coe_le_coe.2 (f n).2
obtain hC := tsum_schlomilch_le hf h_pos h_nonneg hu_strict.monotone h_succ_diff
simpa [add_eq_top, mul_ne_top, mul_eq_top, hC_nonzero] using eq_top_mono hC h
· replace hf : ∀ m n, 0 < m → m ≤ n → (f n : ℝ≥0∞) ≤ f m := fun m n hm hmn =>
ENNReal.coe_le_coe.2 (hf hm hmn)
have : ∑ k ∈ range (u 0), (f k : ℝ≥0∞) ≠ ∞ := (sum_lt_top fun a _ => coe_ne_top).ne
simpa [h, add_eq_top, this] using le_tsum_schlomilch hf h_pos hu_strict
open ENNReal in
theorem summable_condensed_iff {f : ℕ → ℝ≥0} (hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
(Summable fun k : ℕ => (2 : ℝ≥0) ^ k * f (2 ^ k)) ↔ Summable f := by
have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by
intro n
simp [pow_succ, mul_two, two_mul]
convert summable_schlomilch_iff hf (pow_pos zero_lt_two) (pow_right_strictMono _root_.one_lt_two)
two_ne_zero h_succ_diff
simp [pow_succ, mul_two, two_mul]
end NNReal
open NNReal in
/-- for series of nonnegative real numbers. -/
theorem summable_schlomilch_iff_of_nonneg {C : ℕ} {u : ℕ → ℕ} {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)
(hf : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) (h_pos : ∀ n, 0 < u n)
(hu_strict : StrictMono u) (hC_nonzero : C ≠ 0) (h_succ_diff : SuccDiffBounded C u) :
(Summable fun k : ℕ => (u (k + 1) - (u k : ℝ)) * f (u k)) ↔ Summable f := by
lift f to ℕ → ℝ≥0 using h_nonneg
simp only [NNReal.coe_le_coe] at *
have (k : ℕ) : (u (k + 1) - (u k : ℝ)) = ((u (k + 1) : ℝ≥0) - (u k : ℝ≥0) : ℝ≥0) := by
have := Nat.cast_le (α := ℝ≥0).mpr <| (hu_strict k.lt_succ_self).le
simp [NNReal.coe_sub this]
simp_rw [this]
exact_mod_cast NNReal.summable_schlomilch_iff hf h_pos hu_strict hC_nonzero h_succ_diff
/-- Cauchy condensation test for antitone series of nonnegative real numbers. -/
theorem summable_condensed_iff_of_nonneg {f : ℕ → ℝ} (h_nonneg : ∀ n, 0 ≤ f n)
(h_mono : ∀ ⦃m n⦄, 0 < m → m ≤ n → f n ≤ f m) :
(Summable fun k : ℕ => (2 : ℝ) ^ k * f (2 ^ k)) ↔ Summable f := by
have h_succ_diff : SuccDiffBounded 2 (2 ^ ·) := by
intro n
simp [pow_succ, mul_two, two_mul]
convert summable_schlomilch_iff_of_nonneg h_nonneg h_mono (pow_pos zero_lt_two)
(pow_right_strictMono one_lt_two) two_ne_zero h_succ_diff
simp [pow_succ, mul_two, two_mul]
section p_series
/-!
### Convergence of the `p`-series
In this section we prove that for a real number `p`, the series `∑' n : ℕ, 1 / (n ^ p)` converges if
and only if `1 < p`. There are many different proofs of this fact. The proof in this file uses the
Cauchy condensation test we formalized above. This test implies that `∑ n, 1 / (n ^ p)` converges if
and only if `∑ n, 2 ^ n / ((2 ^ n) ^ p)` converges, and the latter series is a geometric series with
common ratio `2 ^ {1 - p}`. -/
namespace Real
open Filter
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, (n ^ p)⁻¹` converges
if and only if `1 < p`. -/
@[simp]
theorem summable_nat_rpow_inv {p : ℝ} :
Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by
rcases le_or_lt 0 p with hp | hp
/- Cauchy condensation test applies only to antitone sequences, so we consider the
cases `0 ≤ p` and `p < 0` separately. -/
· rw [← summable_condensed_iff_of_nonneg]
· simp_rw [Nat.cast_pow, Nat.cast_two, ← rpow_natCast, ← rpow_mul zero_lt_two.le, mul_comm _ p,
rpow_mul zero_lt_two.le, rpow_natCast, ← inv_pow, ← mul_pow,
summable_geometric_iff_norm_lt_one]
nth_rw 1 [← rpow_one 2]
rw [← division_def, ← rpow_sub zero_lt_two, norm_eq_abs,
abs_of_pos (rpow_pos_of_pos zero_lt_two _), rpow_lt_one_iff zero_lt_two.le]
norm_num
· intro n
positivity
· intro m n hm hmn
gcongr
-- If `p < 0`, then `1 / n ^ p` tends to infinity, thus the series diverges.
· suffices ¬Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) by
have : ¬1 < p := fun hp₁ => hp.not_le (zero_le_one.trans hp₁.le)
simpa only [this, iff_false]
intro h
obtain ⟨k : ℕ, hk₁ : ((k : ℝ) ^ p)⁻¹ < 1, hk₀ : k ≠ 0⟩ :=
((h.tendsto_cofinite_zero.eventually (gt_mem_nhds zero_lt_one)).and
(eventually_cofinite_ne 0)).exists
apply hk₀
rw [← pos_iff_ne_zero, ← @Nat.cast_pos ℝ] at hk₀
simpa [inv_lt_one_iff_of_pos (rpow_pos_of_pos hk₀ _), one_lt_rpow_iff_of_pos hk₀, hp,
hp.not_lt, hk₀] using hk₁
@[simp]
theorem summable_nat_rpow {p : ℝ} : Summable (fun n => (n : ℝ) ^ p : ℕ → ℝ) ↔ p < -1 := by
rcases neg_surjective p with ⟨p, rfl⟩
simp [rpow_neg]
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, 1 / n ^ p` converges
if and only if `1 < p`. -/
theorem summable_one_div_nat_rpow {p : ℝ} :
Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by
simp
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, (n ^ p)⁻¹` converges
if and only if `1 < p`. -/
@[simp]
theorem summable_nat_pow_inv {p : ℕ} :
Summable (fun n => ((n : ℝ) ^ p)⁻¹ : ℕ → ℝ) ↔ 1 < p := by
simp only [← rpow_natCast, summable_nat_rpow_inv, Nat.one_lt_cast]
/-- Test for convergence of the `p`-series: the real-valued series `∑' n : ℕ, 1 / n ^ p` converges
if and only if `1 < p`. -/
theorem summable_one_div_nat_pow {p : ℕ} :
Summable (fun n => 1 / (n : ℝ) ^ p : ℕ → ℝ) ↔ 1 < p := by
simp only [one_div, Real.summable_nat_pow_inv]
/-- Summability of the `p`-series over `ℤ`. -/
theorem summable_one_div_int_pow {p : ℕ} :
(Summable fun n : ℤ ↦ 1 / (n : ℝ) ^ p) ↔ 1 < p := by
refine ⟨fun h ↦ summable_one_div_nat_pow.mp (h.comp_injective Nat.cast_injective),
fun h ↦ .of_nat_of_neg (summable_one_div_nat_pow.mpr h)
(((summable_one_div_nat_pow.mpr h).mul_left <| 1 / (-1 : ℝ) ^ p).congr fun n ↦ ?_)⟩
rw [Int.cast_neg, Int.cast_natCast, neg_eq_neg_one_mul (n : ℝ), mul_pow, mul_one_div, div_div]
theorem summable_abs_int_rpow {b : ℝ} (hb : 1 < b) :
Summable fun n : ℤ => |(n : ℝ)| ^ (-b) := by
apply Summable.of_nat_of_neg
on_goal 2 => simp_rw [Int.cast_neg, abs_neg]
all_goals
simp_rw [Int.cast_natCast, fun n : ℕ => abs_of_nonneg (n.cast_nonneg : 0 ≤ (n : ℝ))]
rwa [summable_nat_rpow, neg_lt_neg_iff]
/-- Harmonic series is not unconditionally summable. -/
theorem not_summable_natCast_inv : ¬Summable (fun n => n⁻¹ : ℕ → ℝ) := by
have : ¬Summable (fun n => ((n : ℝ) ^ 1)⁻¹ : ℕ → ℝ) :=
mt (summable_nat_pow_inv (p := 1)).1 (lt_irrefl 1)
simpa
@[deprecated (since := "2024-04-17")]
alias not_summable_nat_cast_inv := not_summable_natCast_inv
/-- Harmonic series is not unconditionally summable. -/
theorem not_summable_one_div_natCast : ¬Summable (fun n => 1 / n : ℕ → ℝ) := by
simpa only [inv_eq_one_div] using not_summable_natCast_inv
@[deprecated (since := "2024-04-17")]
alias not_summable_one_div_nat_cast := not_summable_one_div_natCast
/-- **Divergence of the Harmonic Series** -/
theorem tendsto_sum_range_one_div_nat_succ_atTop :
Tendsto (fun n => ∑ i ∈ Finset.range n, (1 / (i + 1) : ℝ)) atTop atTop := by
rw [← not_summable_iff_tendsto_nat_atTop_of_nonneg]
· exact_mod_cast mt (_root_.summable_nat_add_iff 1).1 not_summable_one_div_natCast
· exact fun i => by positivity
end Real
namespace NNReal
@[simp]
theorem summable_rpow_inv {p : ℝ} :
Summable (fun n => ((n : ℝ≥0) ^ p)⁻¹ : ℕ → ℝ≥0) ↔ 1 < p := by
simp [← NNReal.summable_coe]
@[simp]
theorem summable_rpow {p : ℝ} : Summable (fun n => (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ p < -1 := by
simp [← NNReal.summable_coe]
theorem summable_one_div_rpow {p : ℝ} :
Summable (fun n => 1 / (n : ℝ≥0) ^ p : ℕ → ℝ≥0) ↔ 1 < p := by
simp
end NNReal
end p_series
section
open Finset
variable {α : Type*} [LinearOrderedField α]
set_option tactic.skipAssignedInstances false in
theorem sum_Ioc_inv_sq_le_sub {k n : ℕ} (hk : k ≠ 0) (h : k ≤ n) :
(∑ i ∈ Ioc k n, ((i : α) ^ 2)⁻¹) ≤ (k : α)⁻¹ - (n : α)⁻¹ := by
refine Nat.le_induction ?_ ?_ n h
· simp only [Ioc_self, sum_empty, sub_self, le_refl]
intro n hn IH
rw [sum_Ioc_succ_top hn]
apply (add_le_add IH le_rfl).trans
simp only [sub_eq_add_neg, add_assoc, Nat.cast_add, Nat.cast_one, le_add_neg_iff_add_le,
add_le_iff_nonpos_right, neg_add_le_iff_le_add, add_zero]
have A : 0 < (n : α) := by simpa using hk.bot_lt.trans_le hn
have B : 0 < (n : α) + 1 := by linarith
field_simp
rw [div_le_div_iff _ A, ← sub_nonneg]
· ring_nf
rw [add_comm]
exact B.le
· -- Porting note: was `nlinarith`
positivity
theorem sum_Ioo_inv_sq_le (k n : ℕ) : (∑ i ∈ Ioo k n, (i ^ 2 : α)⁻¹) ≤ 2 / (k + 1) :=
calc
(∑ i ∈ Ioo k n, ((i : α) ^ 2)⁻¹) ≤ ∑ i ∈ Ioc k (max (k + 1) n), ((i : α) ^ 2)⁻¹ := by
apply sum_le_sum_of_subset_of_nonneg
· intro x hx
simp only [mem_Ioo] at hx
simp only [hx, hx.2.le, mem_Ioc, le_max_iff, or_true_iff, and_self_iff]
· intro i _hi _hident
positivity
_ ≤ ((k + 1 : α) ^ 2)⁻¹ + ∑ i ∈ Ioc k.succ (max (k + 1) n), ((i : α) ^ 2)⁻¹ := by
rw [← Nat.Icc_succ_left, ← Nat.Ico_succ_right, sum_eq_sum_Ico_succ_bot]
swap; · exact Nat.succ_lt_succ ((Nat.lt_succ_self k).trans_le (le_max_left _ _))
rw [Nat.Ico_succ_right, Nat.Icc_succ_left, Nat.cast_succ]
_ ≤ ((k + 1 : α) ^ 2)⁻¹ + (k + 1 : α)⁻¹ := by
refine add_le_add le_rfl ((sum_Ioc_inv_sq_le_sub ?_ (le_max_left _ _)).trans ?_)
· simp only [Ne, Nat.succ_ne_zero, not_false_iff]
· simp only [Nat.cast_succ, one_div, sub_le_self_iff, inv_nonneg, Nat.cast_nonneg]
_ ≤ 1 / (k + 1) + 1 / (k + 1) := by
have A : (1 : α) ≤ k + 1 := by simp only [le_add_iff_nonneg_left, Nat.cast_nonneg]
simp_rw [← one_div]
gcongr
simpa using pow_le_pow_right A one_le_two
_ = 2 / (k + 1) := by ring
end
open Set Nat in
/-- The harmonic series restricted to a residue class is not summable. -/
lemma Real.not_summable_indicator_one_div_natCast {m : ℕ} (hm : m ≠ 0) (k : ZMod m) :
¬ Summable ({n : ℕ | (n : ZMod m) = k}.indicator fun n : ℕ ↦ (1 / n : ℝ)) := by
have : NeZero m := ⟨hm⟩ -- instance is needed below
rw [← summable_nat_add_iff 1] -- shift by one to avoid non-monotonicity at zero
have h (n : ℕ) : {n : ℕ | (n : ZMod m) = k - 1}.indicator (fun n : ℕ ↦ (1 / (n + 1 :) : ℝ)) n =
if (n : ZMod m) = k - 1 then (1 / (n + 1) : ℝ) else (0 : ℝ) := by
simp only [indicator_apply, mem_setOf_eq, cast_add, cast_one]
simp_rw [indicator_apply, mem_setOf, cast_add, cast_one, ← eq_sub_iff_add_eq, ← h]
rw [summable_indicator_mod_iff (fun n₁ n₂ h ↦ by gcongr) (k - 1)]
exact mt (summable_nat_add_iff (f := fun n : ℕ ↦ 1 / (n : ℝ)) 1).mp not_summable_one_div_natCast
/-!
## Translating the `p`-series by a real number
-/
section shifted
open Filter Asymptotics Topology
lemma Real.summable_one_div_nat_add_rpow (a : ℝ) (s : ℝ) :
Summable (fun n : ℕ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by
suffices ∀ (b c : ℝ), Summable (fun n : ℕ ↦ 1 / |n + b| ^ s) →
Summable (fun n : ℕ ↦ 1 / |n + c| ^ s) by
simp_rw [← summable_one_div_nat_rpow, Iff.intro (this a 0) (this 0 a), add_zero, Nat.abs_cast]
refine fun b c h ↦ summable_of_isBigO_nat h (isBigO_of_div_tendsto_nhds ?_ 1 ?_)
· filter_upwards [eventually_gt_atTop (Nat.ceil |b|)] with n hn hx
have hna : 0 < n + b := by linarith [lt_of_abs_lt ((abs_neg b).symm ▸ Nat.lt_of_ceil_lt hn)]
exfalso
revert hx
positivity
· simp_rw [Pi.div_def, div_div, mul_one_div, one_div_div]
refine (?_ : Tendsto (fun x : ℝ ↦ |x + b| ^ s / |x + c| ^ s) atTop (𝓝 1)).comp
tendsto_natCast_atTop_atTop
have : Tendsto (fun x : ℝ ↦ 1 + (b - c) / x) atTop (𝓝 1) := by
simpa using tendsto_const_nhds.add ((tendsto_const_nhds (X := ℝ)).div_atTop tendsto_id)
have : Tendsto (fun x ↦ (x + b) / (x + c)) atTop (𝓝 1) := by
refine (this.comp (tendsto_id.atTop_add (tendsto_const_nhds (x := c)))).congr' ?_
filter_upwards [eventually_gt_atTop (-c)] with x hx
field_simp [(by linarith : 0 < x + c).ne']
apply (one_rpow s ▸ (continuousAt_rpow_const _ s (by simp)).tendsto.comp this).congr'
filter_upwards [eventually_gt_atTop (-b), eventually_gt_atTop (-c)] with x hb hc
rw [neg_lt_iff_pos_add] at hb hc
rw [Function.comp_apply, div_rpow hb.le hc.le, abs_of_pos hb, abs_of_pos hc]
lemma Real.summable_one_div_int_add_rpow (a : ℝ) (s : ℝ) :
Summable (fun n : ℤ ↦ 1 / |n + a| ^ s) ↔ 1 < s := by
simp_rw [summable_int_iff_summable_nat_and_neg, ← abs_neg (↑(-_ : ℤ) + a), neg_add,
Int.cast_neg, neg_neg, Int.cast_natCast, summable_one_div_nat_add_rpow, and_self]
end shifted
|
Analysis\PSeriesComplex.lean | /-
Copyright (c) 2024 David Loeffler. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler
-/
import Mathlib.Analysis.PSeries
import Mathlib.Analysis.Normed.Module.FiniteDimension
import Mathlib.Data.Complex.FiniteDimensional
/-!
# Convergence of `p`-series (complex case)
Here we show convergence of `∑ n : ℕ, 1 / n ^ p` for complex `p`. This is done in a separate file
rather than in `Analysis.PSeries` in order to keep the prerequisites of the former relatively light.
## Tags
p-series, Cauchy condensation test
-/
lemma Complex.summable_one_div_nat_cpow {p : ℂ} :
Summable (fun n : ℕ ↦ 1 / (n : ℂ) ^ p) ↔ 1 < re p := by
rw [← Real.summable_one_div_nat_rpow, ← summable_nat_add_iff 1 (G := ℝ),
← summable_nat_add_iff 1 (G := ℂ), ← summable_norm_iff]
simp only [norm_div, norm_one, norm_eq_abs, ← ofReal_natCast, abs_cpow_eq_rpow_re_of_pos
(Nat.cast_pos.mpr <| Nat.succ_pos _)]
|
Analysis\Quaternion.lean | /-
Copyright (c) 2020 Yury Kudryashov. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yury Kudryashov, Eric Wieser
-/
import Mathlib.Algebra.Quaternion
import Mathlib.Analysis.InnerProductSpace.Basic
import Mathlib.Analysis.InnerProductSpace.PiL2
import Mathlib.Topology.Algebra.Algebra
/-!
# Quaternions as a normed algebra
In this file we define the following structures on the space `ℍ := ℍ[ℝ]` of quaternions:
* inner product space;
* normed ring;
* normed space over `ℝ`.
We show that the norm on `ℍ[ℝ]` agrees with the euclidean norm of its components.
## Notation
The following notation is available with `open Quaternion` or `open scoped Quaternion`:
* `ℍ` : quaternions
## Tags
quaternion, normed ring, normed space, normed algebra
-/
@[inherit_doc] scoped[Quaternion] notation "ℍ" => Quaternion ℝ
open scoped RealInnerProductSpace
namespace Quaternion
instance : Inner ℝ ℍ :=
⟨fun a b => (a * star b).re⟩
theorem inner_self (a : ℍ) : ⟪a, a⟫ = normSq a :=
rfl
theorem inner_def (a b : ℍ) : ⟪a, b⟫ = (a * star b).re :=
rfl
noncomputable instance : NormedAddCommGroup ℍ :=
@InnerProductSpace.Core.toNormedAddCommGroup ℝ ℍ _ _ _
{ toInner := inferInstance
conj_symm := fun x y => by simp [inner_def, mul_comm]
nonneg_re := fun x => normSq_nonneg
definite := fun x => normSq_eq_zero.1
add_left := fun x y z => by simp only [inner_def, add_mul, add_re]
smul_left := fun x y r => by simp [inner_def] }
noncomputable instance : InnerProductSpace ℝ ℍ :=
InnerProductSpace.ofCore _
theorem normSq_eq_norm_mul_self (a : ℍ) : normSq a = ‖a‖ * ‖a‖ := by
rw [← inner_self, real_inner_self_eq_norm_mul_norm]
instance : NormOneClass ℍ :=
⟨by rw [norm_eq_sqrt_real_inner, inner_self, normSq.map_one, Real.sqrt_one]⟩
@[simp, norm_cast]
theorem norm_coe (a : ℝ) : ‖(a : ℍ)‖ = ‖a‖ := by
rw [norm_eq_sqrt_real_inner, inner_self, normSq_coe, Real.sqrt_sq_eq_abs, Real.norm_eq_abs]
@[simp, norm_cast]
theorem nnnorm_coe (a : ℝ) : ‖(a : ℍ)‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_coe a
@[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this
theorem norm_star (a : ℍ) : ‖star a‖ = ‖a‖ := by
simp_rw [norm_eq_sqrt_real_inner, inner_self, normSq_star]
@[simp, nolint simpNF] -- Porting note (#10959): simp cannot prove this
theorem nnnorm_star (a : ℍ) : ‖star a‖₊ = ‖a‖₊ :=
Subtype.ext <| norm_star a
noncomputable instance : NormedDivisionRing ℍ where
dist_eq _ _ := rfl
norm_mul' a b := by
simp only [norm_eq_sqrt_real_inner, inner_self, normSq.map_mul]
exact Real.sqrt_mul normSq_nonneg _
noncomputable instance : NormedAlgebra ℝ ℍ where
norm_smul_le := norm_smul_le
toAlgebra := Quaternion.algebra
instance : CStarRing ℍ where
norm_mul_self_le x :=
le_of_eq <| Eq.symm <| (norm_mul _ _).trans <| congr_arg (· * ‖x‖) (norm_star x)
/-- Coercion from `ℂ` to `ℍ`. -/
@[coe] def coeComplex (z : ℂ) : ℍ := ⟨z.re, z.im, 0, 0⟩
instance : Coe ℂ ℍ := ⟨coeComplex⟩
@[simp, norm_cast]
theorem coeComplex_re (z : ℂ) : (z : ℍ).re = z.re :=
rfl
@[simp, norm_cast]
theorem coeComplex_imI (z : ℂ) : (z : ℍ).imI = z.im :=
rfl
@[simp, norm_cast]
theorem coeComplex_imJ (z : ℂ) : (z : ℍ).imJ = 0 :=
rfl
@[simp, norm_cast]
theorem coeComplex_imK (z : ℂ) : (z : ℍ).imK = 0 :=
rfl
@[simp, norm_cast]
theorem coeComplex_add (z w : ℂ) : ↑(z + w) = (z + w : ℍ) := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_mul (z w : ℂ) : ↑(z * w) = (z * w : ℍ) := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_zero : ((0 : ℂ) : ℍ) = 0 :=
rfl
@[simp, norm_cast]
theorem coeComplex_one : ((1 : ℂ) : ℍ) = 1 :=
rfl
@[simp, norm_cast]
theorem coe_real_complex_mul (r : ℝ) (z : ℂ) : (r • z : ℍ) = ↑r * ↑z := by ext <;> simp
@[simp, norm_cast]
theorem coeComplex_coe (r : ℝ) : ((r : ℂ) : ℍ) = r :=
rfl
/-- Coercion `ℂ →ₐ[ℝ] ℍ` as an algebra homomorphism. -/
def ofComplex : ℂ →ₐ[ℝ] ℍ where
toFun := (↑)
map_one' := rfl
map_zero' := rfl
map_add' := coeComplex_add
map_mul' := coeComplex_mul
commutes' _ := rfl
@[simp]
theorem coe_ofComplex : ⇑ofComplex = coeComplex := rfl
/-- The norm of the components as a euclidean vector equals the norm of the quaternion. -/
theorem norm_piLp_equiv_symm_equivTuple (x : ℍ) :
‖(WithLp.equiv 2 (Fin 4 → _)).symm (equivTuple ℝ x)‖ = ‖x‖ := by
rw [norm_eq_sqrt_real_inner, norm_eq_sqrt_real_inner, inner_self, normSq_def', PiLp.inner_apply,
Fin.sum_univ_four]
simp_rw [RCLike.inner_apply, starRingEnd_apply, star_trivial, ← sq]
rfl
/-- `QuaternionAlgebra.linearEquivTuple` as a `LinearIsometryEquiv`. -/
@[simps apply symm_apply]
noncomputable def linearIsometryEquivTuple : ℍ ≃ₗᵢ[ℝ] EuclideanSpace ℝ (Fin 4) :=
{ (QuaternionAlgebra.linearEquivTuple (-1 : ℝ) (-1 : ℝ)).trans
(WithLp.linearEquiv 2 ℝ (Fin 4 → ℝ)).symm with
toFun := fun a => (WithLp.equiv _ (Fin 4 → _)).symm ![a.1, a.2, a.3, a.4]
invFun := fun a => ⟨a 0, a 1, a 2, a 3⟩
norm_map' := norm_piLp_equiv_symm_equivTuple }
@[continuity]
theorem continuous_coe : Continuous (coe : ℝ → ℍ) :=
continuous_algebraMap ℝ ℍ
@[continuity]
theorem continuous_normSq : Continuous (normSq : ℍ → ℝ) := by
simpa [← normSq_eq_norm_mul_self] using
(continuous_norm.mul continuous_norm : Continuous fun q : ℍ => ‖q‖ * ‖q‖)
@[continuity]
theorem continuous_re : Continuous fun q : ℍ => q.re :=
(continuous_apply 0).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imI : Continuous fun q : ℍ => q.imI :=
(continuous_apply 1).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imJ : Continuous fun q : ℍ => q.imJ :=
(continuous_apply 2).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_imK : Continuous fun q : ℍ => q.imK :=
(continuous_apply 3).comp linearIsometryEquivTuple.continuous
@[continuity]
theorem continuous_im : Continuous fun q : ℍ => q.im := by
simpa only [← sub_self_re] using continuous_id.sub (continuous_coe.comp continuous_re)
instance : CompleteSpace ℍ :=
haveI : UniformEmbedding linearIsometryEquivTuple.toLinearEquiv.toEquiv.symm :=
linearIsometryEquivTuple.toContinuousLinearEquiv.symm.uniformEmbedding
(completeSpace_congr this).1 (by infer_instance)
section infinite_sum
variable {α : Type*}
@[simp, norm_cast]
theorem hasSum_coe {f : α → ℝ} {r : ℝ} : HasSum (fun a => (f a : ℍ)) (↑r : ℍ) ↔ HasSum f r :=
⟨fun h => by simpa only using h.map (show ℍ →ₗ[ℝ] ℝ from QuaternionAlgebra.reₗ _ _) continuous_re,
fun h => by simpa only using h.map (algebraMap ℝ ℍ) (continuous_algebraMap _ _)⟩
@[simp, norm_cast]
theorem summable_coe {f : α → ℝ} : (Summable fun a => (f a : ℍ)) ↔ Summable f := by
simpa only using
Summable.map_iff_of_leftInverse (algebraMap ℝ ℍ) (show ℍ →ₗ[ℝ] ℝ from QuaternionAlgebra.reₗ _ _)
(continuous_algebraMap _ _) continuous_re coe_re
@[norm_cast]
theorem tsum_coe (f : α → ℝ) : (∑' a, (f a : ℍ)) = ↑(∑' a, f a) := by
by_cases hf : Summable f
· exact (hasSum_coe.mpr hf.hasSum).tsum_eq
· simp [tsum_eq_zero_of_not_summable hf, tsum_eq_zero_of_not_summable (summable_coe.not.mpr hf)]
end infinite_sum
end Quaternion
|
Analysis\Seminorm.lean | /-
Copyright (c) 2019 Jean Lo. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean Lo, Yaël Dillies, Moritz Doll
-/
import Mathlib.Data.Real.Pointwise
import Mathlib.Analysis.Convex.Function
import Mathlib.Analysis.LocallyConvex.Basic
/-!
# Seminorms
This file defines seminorms.
A seminorm is a function to the reals which is positive-semidefinite, absolutely homogeneous, and
subadditive. They are closely related to convex sets, and a topological vector space is locally
convex if and only if its topology is induced by a family of seminorms.
## Main declarations
For a module over a normed ring:
* `Seminorm`: A function to the reals that is positive-semidefinite, absolutely homogeneous, and
subadditive.
* `normSeminorm 𝕜 E`: The norm on `E` as a seminorm.
## References
* [H. H. Schaefer, *Topological Vector Spaces*][schaefer1966]
## Tags
seminorm, locally convex, LCTVS
-/
open NormedField Set Filter
open scoped NNReal Pointwise Topology Uniformity
variable {R R' 𝕜 𝕜₂ 𝕜₃ 𝕝 E E₂ E₃ F G ι : Type*}
/-- A seminorm on a module over a normed ring is a function to the reals that is positive
semidefinite, positive homogeneous, and subadditive. -/
structure Seminorm (𝕜 : Type*) (E : Type*) [SeminormedRing 𝕜] [AddGroup E] [SMul 𝕜 E] extends
AddGroupSeminorm E where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
smul' : ∀ (a : 𝕜) (x : E), toFun (a • x) = ‖a‖ * toFun x
attribute [nolint docBlame] Seminorm.toAddGroupSeminorm
/-- `SeminormClass F 𝕜 E` states that `F` is a type of seminorms on the `𝕜`-module `E`.
You should extend this class when you extend `Seminorm`. -/
class SeminormClass (F : Type*) (𝕜 E : outParam Type*) [SeminormedRing 𝕜] [AddGroup E]
[SMul 𝕜 E] [FunLike F E ℝ] extends AddGroupSeminormClass F E ℝ : Prop where
/-- The seminorm of a scalar multiplication is the product of the absolute value of the scalar
and the original seminorm. -/
map_smul_eq_mul (f : F) (a : 𝕜) (x : E) : f (a • x) = ‖a‖ * f x
export SeminormClass (map_smul_eq_mul)
-- Porting note: dangerous instances no longer exist
-- attribute [nolint dangerousInstance] SeminormClass.toAddGroupSeminormClass
section Of
/-- Alternative constructor for a `Seminorm` on an `AddCommGroup E` that is a module over a
`SeminormedRing 𝕜`. -/
def Seminorm.of [SeminormedRing 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ)
(add_le : ∀ x y : E, f (x + y) ≤ f x + f y) (smul : ∀ (a : 𝕜) (x : E), f (a • x) = ‖a‖ * f x) :
Seminorm 𝕜 E where
toFun := f
map_zero' := by rw [← zero_smul 𝕜 (0 : E), smul, norm_zero, zero_mul]
add_le' := add_le
smul' := smul
neg' x := by rw [← neg_one_smul 𝕜, smul, norm_neg, ← smul, one_smul]
/-- Alternative constructor for a `Seminorm` over a normed field `𝕜` that only assumes `f 0 = 0`
and an inequality for the scalar multiplication. -/
def Seminorm.ofSMulLE [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (f : E → ℝ) (map_zero : f 0 = 0)
(add_le : ∀ x y, f (x + y) ≤ f x + f y) (smul_le : ∀ (r : 𝕜) (x), f (r • x) ≤ ‖r‖ * f x) :
Seminorm 𝕜 E :=
Seminorm.of f add_le fun r x => by
refine le_antisymm (smul_le r x) ?_
by_cases h : r = 0
· simp [h, map_zero]
rw [← mul_le_mul_left (inv_pos.mpr (norm_pos_iff.mpr h))]
rw [inv_mul_cancel_left₀ (norm_ne_zero_iff.mpr h)]
specialize smul_le r⁻¹ (r • x)
rw [norm_inv] at smul_le
convert smul_le
simp [h]
end Of
namespace Seminorm
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddGroup
variable [AddGroup E]
section SMul
variable [SMul 𝕜 E]
instance instFunLike : FunLike (Seminorm 𝕜 E) E ℝ where
coe f := f.toFun
coe_injective' f g h := by
rcases f with ⟨⟨_⟩⟩
rcases g with ⟨⟨_⟩⟩
congr
instance instSeminormClass : SeminormClass (Seminorm 𝕜 E) 𝕜 E where
map_zero f := f.map_zero'
map_add_le_add f := f.add_le'
map_neg_eq_map f := f.neg'
map_smul_eq_mul f := f.smul'
@[ext]
theorem ext {p q : Seminorm 𝕜 E} (h : ∀ x, (p : E → ℝ) x = q x) : p = q :=
DFunLike.ext p q h
instance instZero : Zero (Seminorm 𝕜 E) :=
⟨{ AddGroupSeminorm.instZeroAddGroupSeminorm.zero with
smul' := fun _ _ => (mul_zero _).symm }⟩
@[simp]
theorem coe_zero : ⇑(0 : Seminorm 𝕜 E) = 0 :=
rfl
@[simp]
theorem zero_apply (x : E) : (0 : Seminorm 𝕜 E) x = 0 :=
rfl
instance : Inhabited (Seminorm 𝕜 E) :=
⟨0⟩
variable (p : Seminorm 𝕜 E) (c : 𝕜) (x y : E) (r : ℝ)
/-- Any action on `ℝ` which factors through `ℝ≥0` applies to a seminorm. -/
instance instSMul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] : SMul R (Seminorm 𝕜 E) where
smul r p :=
{ r • p.toAddGroupSeminorm with
toFun := fun x => r • p x
smul' := fun _ _ => by
simp only [← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def, smul_eq_mul]
rw [map_smul_eq_mul, mul_left_comm] }
instance [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] [SMul R' ℝ] [SMul R' ℝ≥0]
[IsScalarTower R' ℝ≥0 ℝ] [SMul R R'] [IsScalarTower R R' ℝ] :
IsScalarTower R R' (Seminorm 𝕜 E) where
smul_assoc r a p := ext fun x => smul_assoc r a (p x)
theorem coe_smul [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E) :
⇑(r • p) = r • ⇑p :=
rfl
@[simp]
theorem smul_apply [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p : Seminorm 𝕜 E)
(x : E) : (r • p) x = r • p x :=
rfl
instance instAdd : Add (Seminorm 𝕜 E) where
add p q :=
{ p.toAddGroupSeminorm + q.toAddGroupSeminorm with
toFun := fun x => p x + q x
smul' := fun a x => by simp only [map_smul_eq_mul, map_smul_eq_mul, mul_add] }
theorem coe_add (p q : Seminorm 𝕜 E) : ⇑(p + q) = p + q :=
rfl
@[simp]
theorem add_apply (p q : Seminorm 𝕜 E) (x : E) : (p + q) x = p x + q x :=
rfl
instance instAddMonoid : AddMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.addMonoid _ rfl coe_add fun _ _ => by rfl
instance instOrderedCancelAddCommMonoid : OrderedCancelAddCommMonoid (Seminorm 𝕜 E) :=
DFunLike.coe_injective.orderedCancelAddCommMonoid _ rfl coe_add fun _ _ => rfl
instance instMulAction [Monoid R] [MulAction R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
MulAction R (Seminorm 𝕜 E) :=
DFunLike.coe_injective.mulAction _ (by intros; rfl)
variable (𝕜 E)
/-- `coeFn` as an `AddMonoidHom`. Helper definition for showing that `Seminorm 𝕜 E` is a module. -/
@[simps]
def coeFnAddMonoidHom : AddMonoidHom (Seminorm 𝕜 E) (E → ℝ) where
toFun := (↑)
map_zero' := coe_zero
map_add' := coe_add
theorem coeFnAddMonoidHom_injective : Function.Injective (coeFnAddMonoidHom 𝕜 E) :=
show @Function.Injective (Seminorm 𝕜 E) (E → ℝ) (↑) from DFunLike.coe_injective
variable {𝕜 E}
instance instDistribMulAction [Monoid R] [DistribMulAction R ℝ] [SMul R ℝ≥0]
[IsScalarTower R ℝ≥0 ℝ] : DistribMulAction R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).distribMulAction _ (by intros; rfl)
instance instModule [Semiring R] [Module R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] :
Module R (Seminorm 𝕜 E) :=
(coeFnAddMonoidHom_injective 𝕜 E).module R _ (by intros; rfl)
instance instSup : Sup (Seminorm 𝕜 E) where
sup p q :=
{ p.toAddGroupSeminorm ⊔ q.toAddGroupSeminorm with
toFun := p ⊔ q
smul' := fun x v =>
(congr_arg₂ max (map_smul_eq_mul p x v) (map_smul_eq_mul q x v)).trans <|
(mul_max_of_nonneg _ _ <| norm_nonneg x).symm }
@[simp]
theorem coe_sup (p q : Seminorm 𝕜 E) : ⇑(p ⊔ q) = (p : E → ℝ) ⊔ (q : E → ℝ) :=
rfl
theorem sup_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊔ q) x = p x ⊔ q x :=
rfl
theorem smul_sup [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊔ q) = r • p ⊔ r • q :=
have real.smul_max : ∀ x y : ℝ, r • max x y = max (r • x) (r • y) := fun x y => by
simpa only [← smul_eq_mul, ← NNReal.smul_def, smul_one_smul ℝ≥0 r (_ : ℝ)] using
mul_max_of_nonneg x y (r • (1 : ℝ≥0) : ℝ≥0).coe_nonneg
ext fun x => real.smul_max _ _
instance instPartialOrder : PartialOrder (Seminorm 𝕜 E) :=
PartialOrder.lift _ DFunLike.coe_injective
@[simp, norm_cast]
theorem coe_le_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) ≤ q ↔ p ≤ q :=
Iff.rfl
@[simp, norm_cast]
theorem coe_lt_coe {p q : Seminorm 𝕜 E} : (p : E → ℝ) < q ↔ p < q :=
Iff.rfl
theorem le_def {p q : Seminorm 𝕜 E} : p ≤ q ↔ ∀ x, p x ≤ q x :=
Iff.rfl
theorem lt_def {p q : Seminorm 𝕜 E} : p < q ↔ p ≤ q ∧ ∃ x, p x < q x :=
@Pi.lt_def _ _ _ p q
instance instSemilatticeSup : SemilatticeSup (Seminorm 𝕜 E) :=
Function.Injective.semilatticeSup _ DFunLike.coe_injective coe_sup
end SMul
end AddGroup
section Module
variable [SeminormedRing 𝕜₂] [SeminormedRing 𝕜₃]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable {σ₂₃ : 𝕜₂ →+* 𝕜₃} [RingHomIsometric σ₂₃]
variable {σ₁₃ : 𝕜 →+* 𝕜₃} [RingHomIsometric σ₁₃]
variable [AddCommGroup E] [AddCommGroup E₂] [AddCommGroup E₃]
variable [AddCommGroup F] [AddCommGroup G]
variable [Module 𝕜 E] [Module 𝕜₂ E₂] [Module 𝕜₃ E₃] [Module 𝕜 F] [Module 𝕜 G]
-- Porting note: even though this instance is found immediately by typeclass search,
-- it seems to be needed below!?
noncomputable instance smul_nnreal_real : SMul ℝ≥0 ℝ := inferInstance
variable [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ]
/-- Composition of a seminorm with a linear map is a seminorm. -/
def comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜 E :=
{ p.toAddGroupSeminorm.comp f.toAddMonoidHom with
toFun := fun x => p (f x)
-- Porting note: the `simp only` below used to be part of the `rw`.
-- I'm not sure why this change was needed, and am worried by it!
-- Note: #8386 had to change `map_smulₛₗ` to `map_smulₛₗ _`
smul' := fun _ _ => by simp only [map_smulₛₗ _]; rw [map_smul_eq_mul, RingHomIsometric.is_iso] }
theorem coe_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) : ⇑(p.comp f) = p ∘ f :=
rfl
@[simp]
theorem comp_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) : (p.comp f) x = p (f x) :=
rfl
@[simp]
theorem comp_id (p : Seminorm 𝕜 E) : p.comp LinearMap.id = p :=
ext fun _ => rfl
@[simp]
theorem comp_zero (p : Seminorm 𝕜₂ E₂) : p.comp (0 : E →ₛₗ[σ₁₂] E₂) = 0 :=
ext fun _ => map_zero p
@[simp]
theorem zero_comp (f : E →ₛₗ[σ₁₂] E₂) : (0 : Seminorm 𝕜₂ E₂).comp f = 0 :=
ext fun _ => rfl
theorem comp_comp [RingHomCompTriple σ₁₂ σ₂₃ σ₁₃] (p : Seminorm 𝕜₃ E₃) (g : E₂ →ₛₗ[σ₂₃] E₃)
(f : E →ₛₗ[σ₁₂] E₂) : p.comp (g.comp f) = (p.comp g).comp f :=
ext fun _ => rfl
theorem add_comp (p q : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) :
(p + q).comp f = p.comp f + q.comp f :=
ext fun _ => rfl
theorem comp_add_le (p : Seminorm 𝕜₂ E₂) (f g : E →ₛₗ[σ₁₂] E₂) :
p.comp (f + g) ≤ p.comp f + p.comp g := fun _ => map_add_le_add p _ _
theorem smul_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : R) :
(c • p).comp f = c • p.comp f :=
ext fun _ => rfl
theorem comp_mono {p q : Seminorm 𝕜₂ E₂} (f : E →ₛₗ[σ₁₂] E₂) (hp : p ≤ q) : p.comp f ≤ q.comp f :=
fun _ => hp _
/-- The composition as an `AddMonoidHom`. -/
@[simps]
def pullback (f : E →ₛₗ[σ₁₂] E₂) : Seminorm 𝕜₂ E₂ →+ Seminorm 𝕜 E where
toFun := fun p => p.comp f
map_zero' := zero_comp f
map_add' := fun p q => add_comp p q f
instance instOrderBot : OrderBot (Seminorm 𝕜 E) where
bot := 0
bot_le := apply_nonneg
@[simp]
theorem coe_bot : ⇑(⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem bot_eq_zero : (⊥ : Seminorm 𝕜 E) = 0 :=
rfl
theorem smul_le_smul {p q : Seminorm 𝕜 E} {a b : ℝ≥0} (hpq : p ≤ q) (hab : a ≤ b) :
a • p ≤ b • q := by
simp_rw [le_def]
intro x
exact mul_le_mul hab (hpq x) (apply_nonneg p x) (NNReal.coe_nonneg b)
theorem finset_sup_apply (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = ↑(s.sup fun i => ⟨p i x, apply_nonneg (p i) x⟩ : ℝ≥0) := by
induction' s using Finset.cons_induction_on with a s ha ih
· rw [Finset.sup_empty, Finset.sup_empty, coe_bot, _root_.bot_eq_zero, Pi.zero_apply]
norm_cast
· rw [Finset.sup_cons, Finset.sup_cons, coe_sup, sup_eq_max, Pi.sup_apply, sup_eq_max,
NNReal.coe_max, NNReal.coe_mk, ih]
theorem exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) {s : Finset ι} (hs : s.Nonempty) (x : E) :
∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.exists_mem_eq_sup s hs (fun i ↦ (⟨p i x, apply_nonneg _ _⟩ : ℝ≥0)) with ⟨i, hi, hix⟩
rw [finset_sup_apply]
exact ⟨i, hi, congr_arg _ hix⟩
theorem zero_or_exists_apply_eq_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) :
s.sup p x = 0 ∨ ∃ i ∈ s, s.sup p x = p i x := by
rcases Finset.eq_empty_or_nonempty s with (rfl|hs)
· left; rfl
· right; exact exists_apply_eq_finset_sup p hs x
theorem finset_sup_smul (p : ι → Seminorm 𝕜 E) (s : Finset ι) (C : ℝ≥0) :
s.sup (C • p) = C • s.sup p := by
ext x
rw [smul_apply, finset_sup_apply, finset_sup_apply]
symm
exact congr_arg ((↑) : ℝ≥0 → ℝ) (NNReal.mul_finset_sup C s (fun i ↦ ⟨p i x, apply_nonneg _ _⟩))
theorem finset_sup_le_sum (p : ι → Seminorm 𝕜 E) (s : Finset ι) : s.sup p ≤ ∑ i ∈ s, p i := by
classical
refine Finset.sup_le_iff.mpr ?_
intro i hi
rw [Finset.sum_eq_sum_diff_singleton_add hi, le_add_iff_nonneg_left]
exact bot_le
theorem finset_sup_apply_le {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 ≤ a)
(h : ∀ i, i ∈ s → p i x ≤ a) : s.sup p x ≤ a := by
lift a to ℝ≥0 using ha
rw [finset_sup_apply, NNReal.coe_le_coe]
exact Finset.sup_le h
theorem le_finset_sup_apply {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {i : ι}
(hi : i ∈ s) : p i x ≤ s.sup p x :=
(Finset.le_sup hi : p i ≤ s.sup p) x
theorem finset_sup_apply_lt {p : ι → Seminorm 𝕜 E} {s : Finset ι} {x : E} {a : ℝ} (ha : 0 < a)
(h : ∀ i, i ∈ s → p i x < a) : s.sup p x < a := by
lift a to ℝ≥0 using ha.le
rw [finset_sup_apply, NNReal.coe_lt_coe, Finset.sup_lt_iff]
· exact h
· exact NNReal.coe_pos.mpr ha
theorem norm_sub_map_le_sub (p : Seminorm 𝕜 E) (x y : E) : ‖p x - p y‖ ≤ p (x - y) :=
abs_sub_map_le_sub p x y
end Module
end SeminormedRing
section SeminormedCommRing
variable [SeminormedRing 𝕜] [SeminormedCommRing 𝕜₂]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
variable [AddCommGroup E] [AddCommGroup E₂] [Module 𝕜 E] [Module 𝕜₂ E₂]
theorem comp_smul (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) :
p.comp (c • f) = ‖c‖₊ • p.comp f :=
ext fun _ => by
rw [comp_apply, smul_apply, LinearMap.smul_apply, map_smul_eq_mul, NNReal.smul_def, coe_nnnorm,
smul_eq_mul, comp_apply]
theorem comp_smul_apply (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (c : 𝕜₂) (x : E) :
p.comp (c • f) x = ‖c‖ * p (f x) :=
map_smul_eq_mul p _ _
end SeminormedCommRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] {p q : Seminorm 𝕜 E} {x : E}
/-- Auxiliary lemma to show that the infimum of seminorms is well-defined. -/
theorem bddBelow_range_add : BddBelow (range fun u => p u + q (x - u)) :=
⟨0, by
rintro _ ⟨x, rfl⟩
dsimp; positivity⟩
noncomputable instance instInf : Inf (Seminorm 𝕜 E) where
inf p q :=
{ p.toAddGroupSeminorm ⊓ q.toAddGroupSeminorm with
toFun := fun x => ⨅ u : E, p u + q (x - u)
smul' := by
intro a x
obtain rfl | ha := eq_or_ne a 0
· rw [norm_zero, zero_mul, zero_smul]
refine
ciInf_eq_of_forall_ge_of_forall_gt_exists_lt
-- Porting note: the following was previously `fun i => by positivity`
(fun i => add_nonneg (apply_nonneg _ _) (apply_nonneg _ _))
fun x hx => ⟨0, by rwa [map_zero, sub_zero, map_zero, add_zero]⟩
simp_rw [Real.mul_iInf_of_nonneg (norm_nonneg a), mul_add, ← map_smul_eq_mul p, ←
map_smul_eq_mul q, smul_sub]
refine
Function.Surjective.iInf_congr ((a⁻¹ • ·) : E → E)
(fun u => ⟨a • u, inv_smul_smul₀ ha u⟩) fun u => ?_
rw [smul_inv_smul₀ ha] }
@[simp]
theorem inf_apply (p q : Seminorm 𝕜 E) (x : E) : (p ⊓ q) x = ⨅ u : E, p u + q (x - u) :=
rfl
noncomputable instance instLattice : Lattice (Seminorm 𝕜 E) :=
{ Seminorm.instSemilatticeSup with
inf := (· ⊓ ·)
inf_le_left := fun p q x =>
ciInf_le_of_le bddBelow_range_add x <| by
simp only [sub_self, map_zero, add_zero]; rfl
inf_le_right := fun p q x =>
ciInf_le_of_le bddBelow_range_add 0 <| by
simp only [sub_self, map_zero, zero_add, sub_zero]; rfl
le_inf := fun a b c hab hac x =>
le_ciInf fun u => (le_map_add_map_sub a _ _).trans <| add_le_add (hab _) (hac _) }
theorem smul_inf [SMul R ℝ] [SMul R ℝ≥0] [IsScalarTower R ℝ≥0 ℝ] (r : R) (p q : Seminorm 𝕜 E) :
r • (p ⊓ q) = r • p ⊓ r • q := by
ext
simp_rw [smul_apply, inf_apply, smul_apply, ← smul_one_smul ℝ≥0 r (_ : ℝ), NNReal.smul_def,
smul_eq_mul, Real.mul_iInf_of_nonneg (NNReal.coe_nonneg _), mul_add]
section Classical
open Classical in
/-- We define the supremum of an arbitrary subset of `Seminorm 𝕜 E` as follows:
* if `s` is `BddAbove` *as a set of functions `E → ℝ`* (that is, if `s` is pointwise bounded
above), we take the pointwise supremum of all elements of `s`, and we prove that it is indeed a
seminorm.
* otherwise, we take the zero seminorm `⊥`.
There are two things worth mentioning here:
* First, it is not trivial at first that `s` being bounded above *by a function* implies
being bounded above *as a seminorm*. We show this in `Seminorm.bddAbove_iff` by using
that the `Sup s` as defined here is then a bounding seminorm for `s`. So it is important to make
the case disjunction on `BddAbove ((↑) '' s : Set (E → ℝ))` and not `BddAbove s`.
* Since the pointwise `Sup` already gives `0` at points where a family of functions is
not bounded above, one could hope that just using the pointwise `Sup` would work here, without the
need for an additional case disjunction. As discussed on Zulip, this doesn't work because this can
give a function which does *not* satisfy the seminorm axioms (typically sub-additivity).
-/
noncomputable instance instSupSet : SupSet (Seminorm 𝕜 E) where
sSup s :=
if h : BddAbove ((↑) '' s : Set (E → ℝ)) then
{ toFun := ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ)
map_zero' := by
rw [iSup_apply, ← @Real.ciSup_const_zero s]
congr!
rename_i _ _ _ i
exact map_zero i.1
add_le' := fun x y => by
rcases h with ⟨q, hq⟩
obtain rfl | h := s.eq_empty_or_nonempty
· simp [Real.iSup_of_isEmpty]
haveI : Nonempty ↑s := h.coe_sort
simp only [iSup_apply]
refine ciSup_le fun i =>
((i : Seminorm 𝕜 E).add_le' x y).trans <| add_le_add
-- Porting note: `f` is provided to force `Subtype.val` to appear.
-- A type ascription on `_` would have also worked, but would have been more verbose.
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun x) ⟨q x, ?_⟩ i)
(le_ciSup (f := fun i => (Subtype.val i : Seminorm 𝕜 E).toFun y) ⟨q y, ?_⟩ i)
<;> rw [mem_upperBounds, forall_mem_range]
<;> exact fun j => hq (mem_image_of_mem _ j.2) _
neg' := fun x => by
simp only [iSup_apply]
congr! 2
rename_i _ _ _ i
exact i.1.neg' _
smul' := fun a x => by
simp only [iSup_apply]
rw [← smul_eq_mul,
Real.smul_iSup_of_nonneg (norm_nonneg a) fun i : s => (i : Seminorm 𝕜 E) x]
congr!
rename_i _ _ _ i
exact i.1.smul' a x }
else ⊥
protected theorem coe_sSup_eq' {s : Set <| Seminorm 𝕜 E}
(hs : BddAbove ((↑) '' s : Set (E → ℝ))) : ↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
congr_arg _ (dif_pos hs)
protected theorem bddAbove_iff {s : Set <| Seminorm 𝕜 E} :
BddAbove s ↔ BddAbove ((↑) '' s : Set (E → ℝ)) :=
⟨fun ⟨q, hq⟩ => ⟨q, forall_mem_image.2 fun p hp => hq hp⟩, fun H =>
⟨sSup s, fun p hp x => by
dsimp
rw [Seminorm.coe_sSup_eq' H, iSup_apply]
rcases H with ⟨q, hq⟩
exact
le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq (mem_image_of_mem _ i.2) x⟩ ⟨p, hp⟩⟩⟩
protected theorem bddAbove_range_iff {ι : Sort*} {p : ι → Seminorm 𝕜 E} :
BddAbove (range p) ↔ ∀ x, BddAbove (range fun i ↦ p i x) := by
rw [Seminorm.bddAbove_iff, ← range_comp, bddAbove_range_pi]; rfl
protected theorem coe_sSup_eq {s : Set <| Seminorm 𝕜 E} (hs : BddAbove s) :
↑(sSup s) = ⨆ p : s, ((p : Seminorm 𝕜 E) : E → ℝ) :=
Seminorm.coe_sSup_eq' (Seminorm.bddAbove_iff.mp hs)
protected theorem coe_iSup_eq {ι : Sort*} {p : ι → Seminorm 𝕜 E} (hp : BddAbove (range p)) :
↑(⨆ i, p i) = ⨆ i, ((p i : Seminorm 𝕜 E) : E → ℝ) := by
rw [← sSup_range, Seminorm.coe_sSup_eq hp]
exact iSup_range' (fun p : Seminorm 𝕜 E => (p : E → ℝ)) p
protected theorem sSup_apply {s : Set (Seminorm 𝕜 E)} (hp : BddAbove s) {x : E} :
(sSup s) x = ⨆ p : s, (p : E → ℝ) x := by
rw [Seminorm.coe_sSup_eq hp, iSup_apply]
protected theorem iSup_apply {ι : Sort*} {p : ι → Seminorm 𝕜 E}
(hp : BddAbove (range p)) {x : E} : (⨆ i, p i) x = ⨆ i, p i x := by
rw [Seminorm.coe_iSup_eq hp, iSup_apply]
protected theorem sSup_empty : sSup (∅ : Set (Seminorm 𝕜 E)) = ⊥ := by
ext
rw [Seminorm.sSup_apply bddAbove_empty, Real.iSup_of_isEmpty]
rfl
private theorem isLUB_sSup (s : Set (Seminorm 𝕜 E)) (hs₁ : BddAbove s) (hs₂ : s.Nonempty) :
IsLUB s (sSup s) := by
refine ⟨fun p hp x => ?_, fun p hp x => ?_⟩ <;> haveI : Nonempty ↑s := hs₂.coe_sort <;>
dsimp <;> rw [Seminorm.coe_sSup_eq hs₁, iSup_apply]
· rcases hs₁ with ⟨q, hq⟩
exact le_ciSup ⟨q x, forall_mem_range.mpr fun i : s => hq i.2 x⟩ ⟨p, hp⟩
· exact ciSup_le fun q => hp q.2 x
/-- `Seminorm 𝕜 E` is a conditionally complete lattice.
Note that, while `inf`, `sup` and `sSup` have good definitional properties (corresponding to
the instances given here for `Inf`, `Sup` and `SupSet` respectively), `sInf s` is just
defined as the supremum of the lower bounds of `s`, which is not really useful in practice. If you
need to use `sInf` on seminorms, then you should probably provide a more workable definition first,
but this is unlikely to happen so we keep the "bad" definition for now. -/
noncomputable instance instConditionallyCompleteLattice :
ConditionallyCompleteLattice (Seminorm 𝕜 E) :=
conditionallyCompleteLatticeOfLatticeOfsSup (Seminorm 𝕜 E) Seminorm.isLUB_sSup
end Classical
end NormedField
/-! ### Seminorm ball -/
section SeminormedRing
variable [SeminormedRing 𝕜]
section AddCommGroup
variable [AddCommGroup E]
section SMul
variable [SMul 𝕜 E] (p : Seminorm 𝕜 E)
/-- The ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y` with
`p (y - x) < r`. -/
def ball (x : E) (r : ℝ) :=
{ y : E | p (y - x) < r }
/-- The closed ball of radius `r` at `x` with respect to seminorm `p` is the set of elements `y`
with `p (y - x) ≤ r`. -/
def closedBall (x : E) (r : ℝ) :=
{ y : E | p (y - x) ≤ r }
variable {x y : E} {r : ℝ}
@[simp]
theorem mem_ball : y ∈ ball p x r ↔ p (y - x) < r :=
Iff.rfl
@[simp]
theorem mem_closedBall : y ∈ closedBall p x r ↔ p (y - x) ≤ r :=
Iff.rfl
theorem mem_ball_self (hr : 0 < r) : x ∈ ball p x r := by simp [hr]
theorem mem_closedBall_self (hr : 0 ≤ r) : x ∈ closedBall p x r := by simp [hr]
theorem mem_ball_zero : y ∈ ball p 0 r ↔ p y < r := by rw [mem_ball, sub_zero]
theorem mem_closedBall_zero : y ∈ closedBall p 0 r ↔ p y ≤ r := by rw [mem_closedBall, sub_zero]
theorem ball_zero_eq : ball p 0 r = { y : E | p y < r } :=
Set.ext fun _ => p.mem_ball_zero
theorem closedBall_zero_eq : closedBall p 0 r = { y : E | p y ≤ r } :=
Set.ext fun _ => p.mem_closedBall_zero
theorem ball_subset_closedBall (x r) : ball p x r ⊆ closedBall p x r := fun _ h =>
(mem_closedBall _).mpr ((mem_ball _).mp h).le
theorem closedBall_eq_biInter_ball (x r) : closedBall p x r = ⋂ ρ > r, ball p x ρ := by
ext y; simp_rw [mem_closedBall, mem_iInter₂, mem_ball, ← forall_lt_iff_le']
@[simp]
theorem ball_zero' (x : E) (hr : 0 < r) : ball (0 : Seminorm 𝕜 E) x r = Set.univ := by
rw [Set.eq_univ_iff_forall, ball]
simp [hr]
@[simp]
theorem closedBall_zero' (x : E) (hr : 0 < r) : closedBall (0 : Seminorm 𝕜 E) x r = Set.univ :=
eq_univ_of_subset (ball_subset_closedBall _ _ _) (ball_zero' x hr)
theorem ball_smul (p : Seminorm 𝕜 E) {c : NNReal} (hc : 0 < c) (r : ℝ) (x : E) :
(c • p).ball x r = p.ball x (r / c) := by
ext
rw [mem_ball, mem_ball, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
lt_div_iff (NNReal.coe_pos.mpr hc)]
theorem closedBall_smul (p : Seminorm 𝕜 E) {c : NNReal} (hc : 0 < c) (r : ℝ) (x : E) :
(c • p).closedBall x r = p.closedBall x (r / c) := by
ext
rw [mem_closedBall, mem_closedBall, smul_apply, NNReal.smul_def, smul_eq_mul, mul_comm,
le_div_iff (NNReal.coe_pos.mpr hc)]
theorem ball_sup (p : Seminorm 𝕜 E) (q : Seminorm 𝕜 E) (e : E) (r : ℝ) :
ball (p ⊔ q) e r = ball p e r ∩ ball q e r := by
simp_rw [ball, ← Set.setOf_and, coe_sup, Pi.sup_apply, sup_lt_iff]
theorem closedBall_sup (p : Seminorm 𝕜 E) (q : Seminorm 𝕜 E) (e : E) (r : ℝ) :
closedBall (p ⊔ q) e r = closedBall p e r ∩ closedBall q e r := by
simp_rw [closedBall, ← Set.setOf_and, coe_sup, Pi.sup_apply, sup_le_iff]
theorem ball_finset_sup' (p : ι → Seminorm 𝕜 E) (s : Finset ι) (H : s.Nonempty) (e : E) (r : ℝ) :
ball (s.sup' H p) e r = s.inf' H fun i => ball (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, ball_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem closedBall_finset_sup' (p : ι → Seminorm 𝕜 E) (s : Finset ι) (H : s.Nonempty) (e : E)
(r : ℝ) : closedBall (s.sup' H p) e r = s.inf' H fun i => closedBall (p i) e r := by
induction H using Finset.Nonempty.cons_induction with
| singleton => simp
| cons _ _ _ hs ih =>
rw [Finset.sup'_cons hs, Finset.inf'_cons hs, closedBall_sup]
-- Porting note: `rw` can't use `inf_eq_inter` here, but `simp` can?
simp only [inf_eq_inter, ih]
theorem ball_mono {p : Seminorm 𝕜 E} {r₁ r₂ : ℝ} (h : r₁ ≤ r₂) : p.ball x r₁ ⊆ p.ball x r₂ :=
fun _ (hx : _ < _) => hx.trans_le h
theorem closedBall_mono {p : Seminorm 𝕜 E} {r₁ r₂ : ℝ} (h : r₁ ≤ r₂) :
p.closedBall x r₁ ⊆ p.closedBall x r₂ := fun _ (hx : _ ≤ _) => hx.trans h
theorem ball_antitone {p q : Seminorm 𝕜 E} (h : q ≤ p) : p.ball x r ⊆ q.ball x r := fun _ =>
(h _).trans_lt
theorem closedBall_antitone {p q : Seminorm 𝕜 E} (h : q ≤ p) :
p.closedBall x r ⊆ q.closedBall x r := fun _ => (h _).trans
theorem ball_add_ball_subset (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) (x₁ x₂ : E) :
p.ball (x₁ : E) r₁ + p.ball (x₂ : E) r₂ ⊆ p.ball (x₁ + x₂) (r₁ + r₂) := by
rintro x ⟨y₁, hy₁, y₂, hy₂, rfl⟩
rw [mem_ball, add_sub_add_comm]
exact (map_add_le_add p _ _).trans_lt (add_lt_add hy₁ hy₂)
theorem closedBall_add_closedBall_subset (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) (x₁ x₂ : E) :
p.closedBall (x₁ : E) r₁ + p.closedBall (x₂ : E) r₂ ⊆ p.closedBall (x₁ + x₂) (r₁ + r₂) := by
rintro x ⟨y₁, hy₁, y₂, hy₂, rfl⟩
rw [mem_closedBall, add_sub_add_comm]
exact (map_add_le_add p _ _).trans (add_le_add hy₁ hy₂)
theorem sub_mem_ball (p : Seminorm 𝕜 E) (x₁ x₂ y : E) (r : ℝ) :
x₁ - x₂ ∈ p.ball y r ↔ x₁ ∈ p.ball (x₂ + y) r := by simp_rw [mem_ball, sub_sub]
/-- The image of a ball under addition with a singleton is another ball. -/
theorem vadd_ball (p : Seminorm 𝕜 E) : x +ᵥ p.ball y r = p.ball (x +ᵥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_ball x y r
/-- The image of a closed ball under addition with a singleton is another closed ball. -/
theorem vadd_closedBall (p : Seminorm 𝕜 E) : x +ᵥ p.closedBall y r = p.closedBall (x +ᵥ y) r :=
letI := AddGroupSeminorm.toSeminormedAddCommGroup p.toAddGroupSeminorm
Metric.vadd_closedBall x y r
end SMul
section Module
variable [Module 𝕜 E]
variable [SeminormedRing 𝕜₂] [AddCommGroup E₂] [Module 𝕜₂ E₂]
variable {σ₁₂ : 𝕜 →+* 𝕜₂} [RingHomIsometric σ₁₂]
theorem ball_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) (r : ℝ) :
(p.comp f).ball x r = f ⁻¹' p.ball (f x) r := by
ext
simp_rw [ball, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
theorem closedBall_comp (p : Seminorm 𝕜₂ E₂) (f : E →ₛₗ[σ₁₂] E₂) (x : E) (r : ℝ) :
(p.comp f).closedBall x r = f ⁻¹' p.closedBall (f x) r := by
ext
simp_rw [closedBall, mem_preimage, comp_apply, Set.mem_setOf_eq, map_sub]
variable (p : Seminorm 𝕜 E)
theorem preimage_metric_ball {r : ℝ} : p ⁻¹' Metric.ball 0 r = { x | p x < r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_ball_zero_iff, Real.norm_of_nonneg (apply_nonneg p _)]
theorem preimage_metric_closedBall {r : ℝ} : p ⁻¹' Metric.closedBall 0 r = { x | p x ≤ r } := by
ext x
simp only [mem_setOf, mem_preimage, mem_closedBall_zero_iff,
Real.norm_of_nonneg (apply_nonneg p _)]
theorem ball_zero_eq_preimage_ball {r : ℝ} : p.ball 0 r = p ⁻¹' Metric.ball 0 r := by
rw [ball_zero_eq, preimage_metric_ball]
theorem closedBall_zero_eq_preimage_closedBall {r : ℝ} :
p.closedBall 0 r = p ⁻¹' Metric.closedBall 0 r := by
rw [closedBall_zero_eq, preimage_metric_closedBall]
@[simp]
theorem ball_bot {r : ℝ} (x : E) (hr : 0 < r) : ball (⊥ : Seminorm 𝕜 E) x r = Set.univ :=
ball_zero' x hr
@[simp]
theorem closedBall_bot {r : ℝ} (x : E) (hr : 0 < r) :
closedBall (⊥ : Seminorm 𝕜 E) x r = Set.univ :=
closedBall_zero' x hr
/-- Seminorm-balls at the origin are balanced. -/
theorem balanced_ball_zero (r : ℝ) : Balanced 𝕜 (ball p 0 r) := by
rintro a ha x ⟨y, hy, hx⟩
rw [mem_ball_zero, ← hx, map_smul_eq_mul]
calc
_ ≤ p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ < r := by rwa [mem_ball_zero] at hy
/-- Closed seminorm-balls at the origin are balanced. -/
theorem balanced_closedBall_zero (r : ℝ) : Balanced 𝕜 (closedBall p 0 r) := by
rintro a ha x ⟨y, hy, hx⟩
rw [mem_closedBall_zero, ← hx, map_smul_eq_mul]
calc
_ ≤ p y := mul_le_of_le_one_left (apply_nonneg p _) ha
_ ≤ r := by rwa [mem_closedBall_zero] at hy
theorem ball_finset_sup_eq_iInter (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ}
(hr : 0 < r) : ball (s.sup p) x r = ⋂ i ∈ s, ball (p i) x r := by
lift r to NNReal using hr.le
simp_rw [ball, iInter_setOf, finset_sup_apply, NNReal.coe_lt_coe,
Finset.sup_lt_iff (show ⊥ < r from hr), ← NNReal.coe_lt_coe, NNReal.coe_mk]
theorem closedBall_finset_sup_eq_iInter (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ}
(hr : 0 ≤ r) : closedBall (s.sup p) x r = ⋂ i ∈ s, closedBall (p i) x r := by
lift r to NNReal using hr
simp_rw [closedBall, iInter_setOf, finset_sup_apply, NNReal.coe_le_coe, Finset.sup_le_iff, ←
NNReal.coe_le_coe, NNReal.coe_mk]
theorem ball_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ} (hr : 0 < r) :
ball (s.sup p) x r = s.inf fun i => ball (p i) x r := by
rw [Finset.inf_eq_iInf]
exact ball_finset_sup_eq_iInter _ _ _ hr
theorem closedBall_finset_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι) (x : E) {r : ℝ} (hr : 0 ≤ r) :
closedBall (s.sup p) x r = s.inf fun i => closedBall (p i) x r := by
rw [Finset.inf_eq_iInf]
exact closedBall_finset_sup_eq_iInter _ _ _ hr
@[simp]
theorem ball_eq_emptyset (p : Seminorm 𝕜 E) {x : E} {r : ℝ} (hr : r ≤ 0) : p.ball x r = ∅ := by
ext
rw [Seminorm.mem_ball, Set.mem_empty_iff_false, iff_false_iff, not_lt]
exact hr.trans (apply_nonneg p _)
@[simp]
theorem closedBall_eq_emptyset (p : Seminorm 𝕜 E) {x : E} {r : ℝ} (hr : r < 0) :
p.closedBall x r = ∅ := by
ext
rw [Seminorm.mem_closedBall, Set.mem_empty_iff_false, iff_false_iff, not_le]
exact hr.trans_le (apply_nonneg _ _)
theorem closedBall_smul_ball (p : Seminorm 𝕜 E) {r₁ : ℝ} (hr₁ : r₁ ≠ 0) (r₂ : ℝ) :
Metric.closedBall (0 : 𝕜) r₁ • p.ball 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
refine fun a ha b hb ↦ mul_lt_mul' ha hb (apply_nonneg _ _) ?_
exact hr₁.lt_or_lt.resolve_left <| ((norm_nonneg a).trans ha).not_lt
theorem ball_smul_closedBall (p : Seminorm 𝕜 E) (r₁ : ℝ) {r₂ : ℝ} (hr₂ : r₂ ≠ 0) :
Metric.ball (0 : 𝕜) r₁ • p.closedBall 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_ball_zero, mem_closedBall_zero, mem_ball_zero_iff,
map_smul_eq_mul]
intro a ha b hb
rw [mul_comm, mul_comm r₁]
refine mul_lt_mul' hb ha (norm_nonneg _) (hr₂.lt_or_lt.resolve_left ?_)
exact ((apply_nonneg p b).trans hb).not_lt
theorem ball_smul_ball (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) :
Metric.ball (0 : 𝕜) r₁ • p.ball 0 r₂ ⊆ p.ball 0 (r₁ * r₂) := by
rcases eq_or_ne r₂ 0 with rfl | hr₂
· simp
· exact (smul_subset_smul_left (ball_subset_closedBall _ _ _)).trans
(ball_smul_closedBall _ _ hr₂)
theorem closedBall_smul_closedBall (p : Seminorm 𝕜 E) (r₁ r₂ : ℝ) :
Metric.closedBall (0 : 𝕜) r₁ • p.closedBall 0 r₂ ⊆ p.closedBall 0 (r₁ * r₂) := by
simp only [smul_subset_iff, mem_closedBall_zero, mem_closedBall_zero_iff, map_smul_eq_mul]
intro a ha b hb
gcongr
exact (norm_nonneg _).trans ha
theorem neg_mem_ball_zero {r : ℝ} {x : E} : -x ∈ ball p 0 r ↔ x ∈ ball p 0 r := by
simp only [mem_ball_zero, map_neg_eq_map]
@[simp]
theorem neg_ball (p : Seminorm 𝕜 E) (r : ℝ) (x : E) : -ball p x r = ball p (-x) r := by
ext
rw [Set.mem_neg, mem_ball, mem_ball, ← neg_add', sub_neg_eq_add, map_neg_eq_map]
end Module
end AddCommGroup
end SeminormedRing
section NormedField
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E] (p : Seminorm 𝕜 E) {A B : Set E} {a : 𝕜}
{r : ℝ} {x : E}
theorem closedBall_iSup {ι : Sort*} {p : ι → Seminorm 𝕜 E} (hp : BddAbove (range p)) (e : E)
{r : ℝ} (hr : 0 < r) : closedBall (⨆ i, p i) e r = ⋂ i, closedBall (p i) e r := by
cases isEmpty_or_nonempty ι
· rw [iSup_of_empty', iInter_of_empty, Seminorm.sSup_empty]
exact closedBall_bot _ hr
· ext x
have := Seminorm.bddAbove_range_iff.mp hp (x - e)
simp only [mem_closedBall, mem_iInter, Seminorm.iSup_apply hp, ciSup_le_iff this]
theorem ball_norm_mul_subset {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} :
p.ball 0 (‖k‖ * r) ⊆ k • p.ball 0 r := by
rcases eq_or_ne k 0 with (rfl | hk)
· rw [norm_zero, zero_mul, ball_eq_emptyset _ le_rfl]
exact empty_subset _
· intro x
rw [Set.mem_smul_set, Seminorm.mem_ball_zero]
refine fun hx => ⟨k⁻¹ • x, ?_, ?_⟩
· rwa [Seminorm.mem_ball_zero, map_smul_eq_mul, norm_inv, ←
mul_lt_mul_left <| norm_pos_iff.mpr hk, ← mul_assoc, ← div_eq_mul_inv ‖k‖ ‖k‖,
div_self (ne_of_gt <| norm_pos_iff.mpr hk), one_mul]
rw [← smul_assoc, smul_eq_mul, ← div_eq_mul_inv, div_self hk, one_smul]
theorem smul_ball_zero {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} (hk : k ≠ 0) :
k • p.ball 0 r = p.ball 0 (‖k‖ * r) := by
ext
rw [mem_smul_set_iff_inv_smul_mem₀ hk, p.mem_ball_zero, p.mem_ball_zero, map_smul_eq_mul,
norm_inv, ← div_eq_inv_mul, div_lt_iff (norm_pos_iff.2 hk), mul_comm]
theorem smul_closedBall_subset {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} :
k • p.closedBall 0 r ⊆ p.closedBall 0 (‖k‖ * r) := by
rintro x ⟨y, hy, h⟩
rw [Seminorm.mem_closedBall_zero, ← h, map_smul_eq_mul]
rw [Seminorm.mem_closedBall_zero] at hy
gcongr
theorem smul_closedBall_zero {p : Seminorm 𝕜 E} {k : 𝕜} {r : ℝ} (hk : 0 < ‖k‖) :
k • p.closedBall 0 r = p.closedBall 0 (‖k‖ * r) := by
refine subset_antisymm smul_closedBall_subset ?_
intro x
rw [Set.mem_smul_set, Seminorm.mem_closedBall_zero]
refine fun hx => ⟨k⁻¹ • x, ?_, ?_⟩
· rwa [Seminorm.mem_closedBall_zero, map_smul_eq_mul, norm_inv, ← mul_le_mul_left hk, ← mul_assoc,
← div_eq_mul_inv ‖k‖ ‖k‖, div_self (ne_of_gt hk), one_mul]
rw [← smul_assoc, smul_eq_mul, ← div_eq_mul_inv, div_self (norm_pos_iff.mp hk), one_smul]
theorem ball_zero_absorbs_ball_zero (p : Seminorm 𝕜 E) {r₁ r₂ : ℝ} (hr₁ : 0 < r₁) :
Absorbs 𝕜 (p.ball 0 r₁) (p.ball 0 r₂) := by
rcases exists_pos_lt_mul hr₁ r₂ with ⟨r, hr₀, hr⟩
refine .of_norm ⟨r, fun a ha x hx => ?_⟩
rw [smul_ball_zero (norm_pos_iff.1 <| hr₀.trans_le ha), p.mem_ball_zero]
rw [p.mem_ball_zero] at hx
exact hx.trans (hr.trans_le <| by gcongr)
/-- Seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_ball_zero (hr : 0 < r) : Absorbent 𝕜 (ball p (0 : E) r) :=
absorbent_iff_forall_absorbs_singleton.2 fun _ =>
(p.ball_zero_absorbs_ball_zero hr).mono_right <|
singleton_subset_iff.2 <| p.mem_ball_zero.2 <| lt_add_one _
/-- Closed seminorm-balls at the origin are absorbent. -/
protected theorem absorbent_closedBall_zero (hr : 0 < r) : Absorbent 𝕜 (closedBall p (0 : E) r) :=
(p.absorbent_ball_zero hr).mono (p.ball_subset_closedBall _ _)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_ball (hpr : p x < r) : Absorbent 𝕜 (ball p x r) := by
refine (p.absorbent_ball_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_ball_zero] at hy
exact p.mem_ball.2 ((map_sub_le_add p _ _).trans_lt <| add_lt_of_lt_sub_right hy)
/-- Seminorm-balls containing the origin are absorbent. -/
protected theorem absorbent_closedBall (hpr : p x < r) : Absorbent 𝕜 (closedBall p x r) := by
refine (p.absorbent_closedBall_zero <| sub_pos.2 hpr).mono fun y hy => ?_
rw [p.mem_closedBall_zero] at hy
exact p.mem_closedBall.2 ((map_sub_le_add p _ _).trans <| add_le_of_le_sub_right hy)
@[simp]
theorem smul_ball_preimage (p : Seminorm 𝕜 E) (y : E) (r : ℝ) (a : 𝕜) (ha : a ≠ 0) :
(a • ·) ⁻¹' p.ball y r = p.ball (a⁻¹ • y) (r / ‖a‖) :=
Set.ext fun _ => by
rw [mem_preimage, mem_ball, mem_ball, lt_div_iff (norm_pos_iff.mpr ha), mul_comm, ←
map_smul_eq_mul p, smul_sub, smul_inv_smul₀ ha]
end NormedField
section Convex
variable [NormedField 𝕜] [AddCommGroup E] [NormedSpace ℝ 𝕜] [Module 𝕜 E]
section SMul
variable [SMul ℝ E] [IsScalarTower ℝ 𝕜 E] (p : Seminorm 𝕜 E)
/-- A seminorm is convex. Also see `convexOn_norm`. -/
protected theorem convexOn : ConvexOn ℝ univ p := by
refine ⟨convex_univ, fun x _ y _ a b ha hb _ => ?_⟩
calc
p (a • x + b • y) ≤ p (a • x) + p (b • y) := map_add_le_add p _ _
_ = ‖a • (1 : 𝕜)‖ * p x + ‖b • (1 : 𝕜)‖ * p y := by
rw [← map_smul_eq_mul p, ← map_smul_eq_mul p, smul_one_smul, smul_one_smul]
_ = a * p x + b * p y := by
rw [norm_smul, norm_smul, norm_one, mul_one, mul_one, Real.norm_of_nonneg ha,
Real.norm_of_nonneg hb]
end SMul
section Module
variable [Module ℝ E] [IsScalarTower ℝ 𝕜 E] (p : Seminorm 𝕜 E) (x : E) (r : ℝ)
/-- Seminorm-balls are convex. -/
theorem convex_ball : Convex ℝ (ball p x r) := by
convert (p.convexOn.translate_left (-x)).convex_lt r
ext y
rw [preimage_univ, sep_univ, p.mem_ball, sub_eq_add_neg]
rfl
/-- Closed seminorm-balls are convex. -/
theorem convex_closedBall : Convex ℝ (closedBall p x r) := by
rw [closedBall_eq_biInter_ball]
exact convex_iInter₂ fun _ _ => convex_ball _ _ _
end Module
end Convex
section RestrictScalars
variable (𝕜) {𝕜' : Type*} [NormedField 𝕜] [SeminormedRing 𝕜'] [NormedAlgebra 𝕜 𝕜']
[NormOneClass 𝕜'] [AddCommGroup E] [Module 𝕜' E] [SMul 𝕜 E] [IsScalarTower 𝕜 𝕜' E]
/-- Reinterpret a seminorm over a field `𝕜'` as a seminorm over a smaller field `𝕜`. This will
typically be used with `RCLike 𝕜'` and `𝕜 = ℝ`. -/
protected def restrictScalars (p : Seminorm 𝕜' E) : Seminorm 𝕜 E :=
{ p with
smul' := fun a x => by rw [← smul_one_smul 𝕜' a x, p.smul', norm_smul, norm_one, mul_one] }
@[simp]
theorem coe_restrictScalars (p : Seminorm 𝕜' E) : (p.restrictScalars 𝕜 : E → ℝ) = p :=
rfl
@[simp]
theorem restrictScalars_ball (p : Seminorm 𝕜' E) : (p.restrictScalars 𝕜).ball = p.ball :=
rfl
@[simp]
theorem restrictScalars_closedBall (p : Seminorm 𝕜' E) :
(p.restrictScalars 𝕜).closedBall = p.closedBall :=
rfl
end RestrictScalars
/-! ### Continuity criterions for seminorms -/
section Continuity
variable [NontriviallyNormedField 𝕜] [SeminormedRing 𝕝] [AddCommGroup E] [Module 𝕜 E]
variable [Module 𝕝 E]
/-- A seminorm is continuous at `0` if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall' [TopologicalSpace E] {p : Seminorm 𝕝 E}
(hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
ContinuousAt p 0 := by
simp_rw [Seminorm.closedBall_zero_eq_preimage_closedBall] at hp
rwa [ContinuousAt, Metric.nhds_basis_closedBall.tendsto_right_iff, map_zero]
theorem continuousAt_zero' [TopologicalSpace E] [ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E}
{r : ℝ} (hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) : ContinuousAt p 0 := by
refine continuousAt_zero_of_forall' fun ε hε ↦ ?_
obtain ⟨k, hk₀, hk⟩ : ∃ k : 𝕜, 0 < ‖k‖ ∧ ‖k‖ * r < ε := by
rcases le_or_lt r 0 with hr | hr
· use 1; simpa using hr.trans_lt hε
· simpa [lt_div_iff hr] using exists_norm_lt 𝕜 (div_pos hε hr)
rw [← set_smul_mem_nhds_zero_iff (norm_pos_iff.1 hk₀), smul_closedBall_zero hk₀] at hp
exact mem_of_superset hp <| p.closedBall_mono hk.le
/-- A seminorm is continuous at `0` if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuousAt_zero'`. -/
theorem continuousAt_zero_of_forall [TopologicalSpace E] {p : Seminorm 𝕝 E}
(hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
ContinuousAt p 0 :=
continuousAt_zero_of_forall'
(fun r hr ↦ Filter.mem_of_superset (hp r hr) <| p.ball_subset_closedBall _ _)
theorem continuousAt_zero [TopologicalSpace E] [ContinuousConstSMul 𝕜 E] {p : Seminorm 𝕜 E} {r : ℝ}
(hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) : ContinuousAt p 0 :=
continuousAt_zero' (Filter.mem_of_superset hp <| p.ball_subset_closedBall _ _)
protected theorem uniformContinuous_of_continuousAt_zero [UniformSpace E] [UniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ContinuousAt p 0) : UniformContinuous p := by
have hp : Filter.Tendsto p (𝓝 0) (𝓝 0) := map_zero p ▸ hp
rw [UniformContinuous, uniformity_eq_comap_nhds_zero_swapped,
Metric.uniformity_eq_comap_nhds_zero, Filter.tendsto_comap_iff]
exact
tendsto_of_tendsto_of_tendsto_of_le_of_le tendsto_const_nhds (hp.comp Filter.tendsto_comap)
(fun xy => dist_nonneg) fun xy => p.norm_sub_map_le_sub _ _
protected theorem continuous_of_continuousAt_zero [TopologicalSpace E] [TopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ContinuousAt p 0) : Continuous p := by
letI := TopologicalAddGroup.toUniformSpace E
haveI : UniformAddGroup E := comm_topologicalAddGroup_is_uniform
exact (Seminorm.uniformContinuous_of_continuousAt_zero hp).continuous
/-- A seminorm is uniformly continuous if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous`. -/
protected theorem uniformContinuous_of_forall [UniformSpace E] [UniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem uniformContinuous [UniformSpace E] [UniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p : Seminorm 𝕜 E} {r : ℝ} (hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero hp)
/-- A seminorm is uniformly continuous if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.uniformContinuous'`. -/
protected theorem uniformContinuous_of_forall' [UniformSpace E] [UniformAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem uniformContinuous' [UniformSpace E] [UniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p : Seminorm 𝕜 E} {r : ℝ} (hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
UniformContinuous p :=
Seminorm.uniformContinuous_of_continuousAt_zero (continuousAt_zero' hp)
/-- A seminorm is continuous if `p.ball 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous`. -/
protected theorem continuous_of_forall [TopologicalSpace E] [TopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.ball 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall hp)
protected theorem continuous [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
{p : Seminorm 𝕜 E} {r : ℝ} (hp : p.ball 0 r ∈ (𝓝 0 : Filter E)) : Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero hp)
/-- A seminorm is continuous if `p.closedBall 0 r ∈ 𝓝 0` for *all* `r > 0`.
Over a `NontriviallyNormedField` it is actually enough to check that this is true
for *some* `r`, see `Seminorm.continuous'`. -/
protected theorem continuous_of_forall' [TopologicalSpace E] [TopologicalAddGroup E]
{p : Seminorm 𝕝 E} (hp : ∀ r > 0, p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero_of_forall' hp)
protected theorem continuous' [TopologicalSpace E] [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
{p : Seminorm 𝕜 E} {r : ℝ} (hp : p.closedBall 0 r ∈ (𝓝 0 : Filter E)) :
Continuous p :=
Seminorm.continuous_of_continuousAt_zero (continuousAt_zero' hp)
theorem continuous_of_le [TopologicalSpace E] [TopologicalAddGroup E]
{p q : Seminorm 𝕝 E} (hq : Continuous q) (hpq : p ≤ q) : Continuous p := by
refine Seminorm.continuous_of_forall (fun r hr ↦ Filter.mem_of_superset
(IsOpen.mem_nhds ?_ <| q.mem_ball_self hr) (ball_antitone hpq))
rw [ball_zero_eq]
exact isOpen_lt hq continuous_const
lemma ball_mem_nhds [TopologicalSpace E] {p : Seminorm 𝕝 E} (hp : Continuous p) {r : ℝ}
(hr : 0 < r) : p.ball 0 r ∈ (𝓝 0 : Filter E) :=
have this : Tendsto p (𝓝 0) (𝓝 0) := map_zero p ▸ hp.tendsto 0
by simpa only [p.ball_zero_eq] using this (Iio_mem_nhds hr)
lemma uniformSpace_eq_of_hasBasis
{ι} [UniformSpace E] [UniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p' : ι → Prop} {s : ι → Set E} (p : Seminorm 𝕜 E) (hb : (𝓝 0 : Filter E).HasBasis p' s)
(h₁ : ∃ r, p.closedBall 0 r ∈ 𝓝 0) (h₂ : ∀ i, p' i → ∃ r > 0, p.ball 0 r ⊆ s i) :
‹UniformSpace E› = p.toAddGroupSeminorm.toSeminormedAddGroup.toUniformSpace := by
refine UniformAddGroup.ext ‹_› p.toAddGroupSeminorm.toSeminormedAddCommGroup.to_uniformAddGroup ?_
apply le_antisymm
· rw [← @comap_norm_nhds_zero E p.toAddGroupSeminorm.toSeminormedAddGroup, ← tendsto_iff_comap]
suffices Continuous p from this.tendsto' 0 _ (map_zero p)
rcases h₁ with ⟨r, hr⟩
exact p.continuous' hr
· rw [(@NormedAddCommGroup.nhds_zero_basis_norm_lt E
p.toAddGroupSeminorm.toSeminormedAddGroup).le_basis_iff hb]
simpa only [subset_def, mem_ball_zero] using h₂
lemma uniformity_eq_of_hasBasis
{ι} [UniformSpace E] [UniformAddGroup E] [ContinuousConstSMul 𝕜 E]
{p' : ι → Prop} {s : ι → Set E} (p : Seminorm 𝕜 E) (hb : (𝓝 0 : Filter E).HasBasis p' s)
(h₁ : ∃ r, p.closedBall 0 r ∈ 𝓝 0) (h₂ : ∀ i, p' i → ∃ r > 0, p.ball 0 r ⊆ s i) :
𝓤 E = ⨅ r > 0, 𝓟 {x | p (x.1 - x.2) < r} := by
rw [uniformSpace_eq_of_hasBasis p hb h₁ h₂]; rfl
end Continuity
section ShellLemmas
variable [NormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- Let `p` be a seminorm on a vector space over a `NormedField`.
If there is a scalar `c` with `‖c‖>1`, then any `x` such that `p x ≠ 0` can be
moved by scalar multiplication to any `p`-shell of width `‖c‖`. Also recap information on the
value of `p` on the rescaling element that shows up in applications. -/
lemma rescale_to_shell_zpow (p : Seminorm 𝕜 E) {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ}
(εpos : 0 < ε) {x : E} (hx : p x ≠ 0) : ∃ n : ℤ, c^n ≠ 0 ∧
p (c^n • x) < ε ∧ (ε / ‖c‖ ≤ p (c^n • x)) ∧ (‖c^n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x) := by
have xεpos : 0 < (p x)/ε := by positivity
rcases exists_mem_Ico_zpow xεpos hc with ⟨n, hn⟩
have cpos : 0 < ‖c‖ := by positivity
have cnpos : 0 < ‖c^(n+1)‖ := by rw [norm_zpow]; exact xεpos.trans hn.2
refine ⟨-(n+1), ?_, ?_, ?_, ?_⟩
· show c ^ (-(n + 1)) ≠ 0; exact zpow_ne_zero _ (norm_pos_iff.1 cpos)
· show p ((c ^ (-(n + 1))) • x) < ε
rw [map_smul_eq_mul, zpow_neg, norm_inv, ← div_eq_inv_mul, div_lt_iff cnpos, mul_comm,
norm_zpow]
exact (div_lt_iff εpos).1 (hn.2)
· show ε / ‖c‖ ≤ p (c ^ (-(n + 1)) • x)
rw [zpow_neg, div_le_iff cpos, map_smul_eq_mul, norm_inv, norm_zpow, zpow_add₀ (ne_of_gt cpos),
zpow_one, mul_inv_rev, mul_comm, ← mul_assoc, ← mul_assoc, mul_inv_cancel (ne_of_gt cpos),
one_mul, ← div_eq_inv_mul, le_div_iff (zpow_pos_of_pos cpos _), mul_comm]
exact (le_div_iff εpos).1 hn.1
· show ‖(c ^ (-(n + 1)))‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x
have : ε⁻¹ * ‖c‖ * p x = ε⁻¹ * p x * ‖c‖ := by ring
rw [zpow_neg, norm_inv, inv_inv, norm_zpow, zpow_add₀ (ne_of_gt cpos), zpow_one, this,
← div_eq_inv_mul]
exact mul_le_mul_of_nonneg_right hn.1 (norm_nonneg _)
/-- Let `p` be a seminorm on a vector space over a `NormedField`.
If there is a scalar `c` with `‖c‖>1`, then any `x` such that `p x ≠ 0` can be
moved by scalar multiplication to any `p`-shell of width `‖c‖`. Also recap information on the
value of `p` on the rescaling element that shows up in applications. -/
lemma rescale_to_shell (p : Seminorm 𝕜 E) {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε) {x : E}
(hx : p x ≠ 0) :
∃d : 𝕜, d ≠ 0 ∧ p (d • x) < ε ∧ (ε/‖c‖ ≤ p (d • x)) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * p x) :=
let ⟨_, hn⟩ := p.rescale_to_shell_zpow hc εpos hx; ⟨_, hn⟩
/-- Let `p` and `q` be two seminorms on a vector space over a `NontriviallyNormedField`.
If we have `q x ≤ C * p x` on some shell of the form `{x | ε/‖c‖ ≤ p x < ε}` (where `ε > 0`
and `‖c‖ > 1`), then we also have `q x ≤ C * p x` for all `x` such that `p x ≠ 0`. -/
lemma bound_of_shell
(p q : Seminorm 𝕜 E) {ε C : ℝ} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ p x → p x < ε → q x ≤ C * p x) {x : E} (hx : p x ≠ 0) :
q x ≤ C * p x := by
rcases p.rescale_to_shell hc ε_pos hx with ⟨δ, hδ, δxle, leδx, -⟩
simpa only [map_smul_eq_mul, mul_left_comm C, mul_le_mul_left (norm_pos_iff.2 hδ)]
using hf (δ • x) leδx δxle
/-- A version of `Seminorm.bound_of_shell` expressed using pointwise scalar multiplication of
seminorms. -/
lemma bound_of_shell_smul
(p q : Seminorm 𝕜 E) {ε : ℝ} {C : ℝ≥0} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, ε / ‖c‖ ≤ p x → p x < ε → q x ≤ (C • p) x) {x : E} (hx : p x ≠ 0) :
q x ≤ (C • p) x :=
Seminorm.bound_of_shell p q ε_pos hc hf hx
lemma bound_of_shell_sup (p : ι → Seminorm 𝕜 E) (s : Finset ι)
(q : Seminorm 𝕜 E) {ε : ℝ} {C : ℝ≥0} (ε_pos : 0 < ε) {c : 𝕜} (hc : 1 < ‖c‖)
(hf : ∀ x, (∀ i ∈ s, p i x < ε) → ∀ j ∈ s, ε / ‖c‖ ≤ p j x → q x ≤ (C • p j) x)
{x : E} (hx : ∃ j, j ∈ s ∧ p j x ≠ 0) :
q x ≤ (C • s.sup p) x := by
rcases hx with ⟨j, hj, hjx⟩
have : (s.sup p) x ≠ 0 :=
ne_of_gt ((hjx.symm.lt_of_le <| apply_nonneg _ _).trans_le (le_finset_sup_apply hj))
refine (s.sup p).bound_of_shell_smul q ε_pos hc (fun y hle hlt ↦ ?_) this
rcases exists_apply_eq_finset_sup p ⟨j, hj⟩ y with ⟨i, hi, hiy⟩
rw [smul_apply, hiy]
exact hf y (fun k hk ↦ (le_finset_sup_apply hk).trans_lt hlt) i hi (hiy ▸ hle)
end ShellLemmas
section NontriviallyNormedField
variable [NontriviallyNormedField 𝕜] [AddCommGroup E] [Module 𝕜 E]
/-- Let `p i` be a family of seminorms on `E`. Let `s` be an absorbent set in `𝕜`.
If all seminorms are uniformly bounded at every point of `s`,
then they are bounded in the space of seminorms. -/
lemma bddAbove_of_absorbent {ι : Sort*} {p : ι → Seminorm 𝕜 E} {s : Set E} (hs : Absorbent 𝕜 s)
(h : ∀ x ∈ s, BddAbove (range (p · x))) : BddAbove (range p) := by
rw [Seminorm.bddAbove_range_iff]
intro x
obtain ⟨c, hc₀, hc⟩ : ∃ c ≠ 0, (c : 𝕜) • x ∈ s :=
(eventually_mem_nhdsWithin.and (hs.eventually_nhdsWithin_zero x)).exists
rcases h _ hc with ⟨M, hM⟩
refine ⟨M / ‖c‖, forall_mem_range.mpr fun i ↦ (le_div_iff' (norm_pos_iff.2 hc₀)).2 ?_⟩
exact hM ⟨i, map_smul_eq_mul ..⟩
end NontriviallyNormedField
end Seminorm
/-! ### The norm as a seminorm -/
section normSeminorm
variable (𝕜) (E) [NormedField 𝕜] [SeminormedAddCommGroup E] [NormedSpace 𝕜 E] {r : ℝ}
/-- The norm of a seminormed group as a seminorm. -/
def normSeminorm : Seminorm 𝕜 E :=
{ normAddGroupSeminorm E with smul' := norm_smul }
@[simp]
theorem coe_normSeminorm : ⇑(normSeminorm 𝕜 E) = norm :=
rfl
@[simp]
theorem ball_normSeminorm : (normSeminorm 𝕜 E).ball = Metric.ball := by
ext x r y
simp only [Seminorm.mem_ball, Metric.mem_ball, coe_normSeminorm, dist_eq_norm]
variable {𝕜 E} {x : E}
/-- Balls at the origin are absorbent. -/
theorem absorbent_ball_zero (hr : 0 < r) : Absorbent 𝕜 (Metric.ball (0 : E) r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).absorbent_ball_zero hr
/-- Balls containing the origin are absorbent. -/
theorem absorbent_ball (hx : ‖x‖ < r) : Absorbent 𝕜 (Metric.ball x r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).absorbent_ball hx
/-- Balls at the origin are balanced. -/
theorem balanced_ball_zero : Balanced 𝕜 (Metric.ball (0 : E) r) := by
rw [← ball_normSeminorm 𝕜]
exact (normSeminorm _ _).balanced_ball_zero r
/-- If there is a scalar `c` with `‖c‖>1`, then any element with nonzero norm can be
moved by scalar multiplication to any shell of width `‖c‖`. Also recap information on the norm of
the rescaling element that shows up in applications. -/
lemma rescale_to_shell_semi_normed_zpow {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε) {x : E}
(hx : ‖x‖ ≠ 0) :
∃ n : ℤ, c^n ≠ 0 ∧ ‖c^n • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖c^n • x‖) ∧ (‖c^n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
(normSeminorm 𝕜 E).rescale_to_shell_zpow hc εpos hx
/-- If there is a scalar `c` with `‖c‖>1`, then any element with nonzero norm can be
moved by scalar multiplication to any shell of width `‖c‖`. Also recap information on the norm of
the rescaling element that shows up in applications. -/
lemma rescale_to_shell_semi_normed {c : 𝕜} (hc : 1 < ‖c‖) {ε : ℝ} (εpos : 0 < ε)
{x : E} (hx : ‖x‖ ≠ 0) :
∃d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < ε ∧ (ε/‖c‖ ≤ ‖d • x‖) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
(normSeminorm 𝕜 E).rescale_to_shell hc εpos hx
lemma rescale_to_shell_zpow [NormedAddCommGroup F] [NormedSpace 𝕜 F] {c : 𝕜} (hc : 1 < ‖c‖)
{ε : ℝ} (εpos : 0 < ε) {x : F} (hx : x ≠ 0) :
∃ n : ℤ, c^n ≠ 0 ∧ ‖c^n • x‖ < ε ∧ (ε / ‖c‖ ≤ ‖c^n • x‖) ∧ (‖c^n‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
rescale_to_shell_semi_normed_zpow hc εpos (norm_ne_zero_iff.mpr hx)
/-- If there is a scalar `c` with `‖c‖>1`, then any element can be moved by scalar multiplication to
any shell of width `‖c‖`. Also recap information on the norm of the rescaling element that shows
up in applications. -/
lemma rescale_to_shell [NormedAddCommGroup F] [NormedSpace 𝕜 F] {c : 𝕜} (hc : 1 < ‖c‖)
{ε : ℝ} (εpos : 0 < ε) {x : F} (hx : x ≠ 0) :
∃d : 𝕜, d ≠ 0 ∧ ‖d • x‖ < ε ∧ (ε/‖c‖ ≤ ‖d • x‖) ∧ (‖d‖⁻¹ ≤ ε⁻¹ * ‖c‖ * ‖x‖) :=
rescale_to_shell_semi_normed hc εpos (norm_ne_zero_iff.mpr hx)
end normSeminorm
assert_not_exists balancedCore
|
Analysis\Subadditive.lean | /-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Topology.Instances.Real
import Mathlib.Order.Filter.Archimedean
/-!
# Convergence of subadditive sequences
A subadditive sequence `u : ℕ → ℝ` is a sequence satisfying `u (m + n) ≤ u m + u n` for all `m, n`.
We define this notion as `Subadditive u`, and prove in `Subadditive.tendsto_lim` that, if `u n / n`
is bounded below, then it converges to a limit (that we denote by `Subadditive.lim` for
convenience). This result is known as Fekete's lemma in the literature.
## TODO
Define a bundled `SubadditiveHom`, use it.
-/
noncomputable section
open Set Filter Topology
/-- A real-valued sequence is subadditive if it satisfies the inequality `u (m + n) ≤ u m + u n`
for all `m, n`. -/
def Subadditive (u : ℕ → ℝ) : Prop :=
∀ m n, u (m + n) ≤ u m + u n
namespace Subadditive
variable {u : ℕ → ℝ} (h : Subadditive u)
/-- The limit of a bounded-below subadditive sequence. The fact that the sequence indeed tends to
this limit is given in `Subadditive.tendsto_lim` -/
@[nolint unusedArguments] -- Porting note: was irreducible
protected def lim (_h : Subadditive u) :=
sInf ((fun n : ℕ => u n / n) '' Ici 1)
theorem lim_le_div (hbdd : BddBelow (range fun n => u n / n)) {n : ℕ} (hn : n ≠ 0) :
h.lim ≤ u n / n := by
rw [Subadditive.lim]
exact csInf_le (hbdd.mono <| image_subset_range _ _) ⟨n, hn.bot_lt, rfl⟩
theorem apply_mul_add_le (k n r) : u (k * n + r) ≤ k * u n + u r := by
induction k with
| zero => simp only [Nat.zero_eq, Nat.cast_zero, zero_mul, zero_add]; rfl
| succ k IH =>
calc
u ((k + 1) * n + r) = u (n + (k * n + r)) := by congr 1; ring
_ ≤ u n + u (k * n + r) := h _ _
_ ≤ u n + (k * u n + u r) := add_le_add_left IH _
_ = (k + 1 : ℕ) * u n + u r := by simp; ring
theorem eventually_div_lt_of_div_lt {L : ℝ} {n : ℕ} (hn : n ≠ 0) (hL : u n / n < L) :
∀ᶠ p in atTop, u p / p < L := by
/- It suffices to prove the statement for each arithmetic progression `(n * · + r)`. -/
refine .atTop_of_arithmetic hn fun r _ => ?_
/- `(k * u n + u r) / (k * n + r)` tends to `u n / n < L`, hence
`(k * u n + u r) / (k * n + r) < L` for sufficiently large `k`. -/
have A : Tendsto (fun x : ℝ => (u n + u r / x) / (n + r / x)) atTop (𝓝 ((u n + 0) / (n + 0))) :=
(tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id).div
(tendsto_const_nhds.add <| tendsto_const_nhds.div_atTop tendsto_id) <| by simpa
have B : Tendsto (fun x => (x * u n + u r) / (x * n + r)) atTop (𝓝 (u n / n)) := by
rw [add_zero, add_zero] at A
refine A.congr' <| (eventually_ne_atTop 0).mono fun x hx => ?_
simp only [(· ∘ ·), add_div' _ _ _ hx, div_div_div_cancel_right _ hx, mul_comm]
refine ((B.comp tendsto_natCast_atTop_atTop).eventually (gt_mem_nhds hL)).mono fun k hk => ?_
/- Finally, we use an upper estimate on `u (k * n + r)` to get an estimate on
`u (k * n + r) / (k * n + r)`. -/
rw [mul_comm]
refine lt_of_le_of_lt ?_ hk
simp only [(· ∘ ·), ← Nat.cast_add, ← Nat.cast_mul]
exact div_le_div_of_nonneg_right (h.apply_mul_add_le _ _ _) (Nat.cast_nonneg _)
/-- Fekete's lemma: a subadditive sequence which is bounded below converges. -/
theorem tendsto_lim (hbdd : BddBelow (range fun n => u n / n)) :
Tendsto (fun n => u n / n) atTop (𝓝 h.lim) := by
refine tendsto_order.2 ⟨fun l hl => ?_, fun L hL => ?_⟩
· refine eventually_atTop.2
⟨1, fun n hn => hl.trans_le (h.lim_le_div hbdd (zero_lt_one.trans_le hn).ne')⟩
· obtain ⟨n, npos, hn⟩ : ∃ n : ℕ, 0 < n ∧ u n / n < L := by
rw [Subadditive.lim] at hL
rcases exists_lt_of_csInf_lt (by simp) hL with ⟨x, hx, xL⟩
rcases (mem_image _ _ _).1 hx with ⟨n, hn, rfl⟩
exact ⟨n, zero_lt_one.trans_le hn, xL⟩
exact h.eventually_div_lt_of_div_lt npos.ne' hn
end Subadditive
|
Analysis\SumIntegralComparisons.lean | /-
Copyright (c) 2022 Kevin H. Wilson. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Kevin H. Wilson
-/
import Mathlib.MeasureTheory.Integral.IntervalIntegral
import Mathlib.Data.Set.Function
/-!
# Comparing sums and integrals
## Summary
It is often the case that error terms in analysis can be computed by comparing
an infinite sum to the improper integral of an antitone function. This file will eventually enable
that.
At the moment it contains four lemmas in this direction: `AntitoneOn.integral_le_sum`,
`AntitoneOn.sum_le_integral` and versions for monotone functions, which can all be paired
with a `Filter.Tendsto` to estimate some errors.
`TODO`: Add more lemmas to the API to directly address limiting issues
## Main Results
* `AntitoneOn.integral_le_sum`: The integral of an antitone function is at most the sum of its
values at integer steps aligning with the left-hand side of the interval
* `AntitoneOn.sum_le_integral`: The sum of an antitone function along integer steps aligning with
the right-hand side of the interval is at most the integral of the function along that interval
* `MonotoneOn.integral_le_sum`: The integral of a monotone function is at most the sum of its
values at integer steps aligning with the right-hand side of the interval
* `MonotoneOn.sum_le_integral`: The sum of a monotone function along integer steps aligning with
the left-hand side of the interval is at most the integral of the function along that interval
## Tags
analysis, comparison, asymptotics
-/
open Set MeasureTheory.MeasureSpace
variable {x₀ : ℝ} {a b : ℕ} {f : ℝ → ℝ}
theorem AntitoneOn.integral_le_sum (hf : AntitoneOn f (Icc x₀ (x₀ + a))) :
(∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + i) := by
have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by
intro k hk
refine (hf.mono ?_).intervalIntegrable
rw [uIcc_of_le]
· apply Icc_subset_Icc
· simp only [le_add_iff_nonneg_right, Nat.cast_nonneg]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ]
calc
∫ x in x₀..x₀ + a, f x = ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by
convert (intervalIntegral.sum_integral_adjacent_intervals hint).symm
simp only [Nat.cast_zero, add_zero]
_ ≤ ∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + i) := by
apply Finset.sum_le_sum fun i hi => ?_
have ia : i < a := Finset.mem_range.1 hi
refine intervalIntegral.integral_mono_on (by simp) (hint _ ia) (by simp) fun x hx => ?_
apply hf _ _ hx.1
· simp only [ia.le, mem_Icc, le_add_iff_nonneg_right, Nat.cast_nonneg, add_le_add_iff_left,
Nat.cast_le, and_self_iff]
· refine mem_Icc.2 ⟨le_trans (by simp) hx.1, le_trans hx.2 ?_⟩
simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt ia]
_ = ∑ i ∈ Finset.range a, f (x₀ + i) := by simp
theorem AntitoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) :
(∫ x in a..b, f x) ≤ ∑ x ∈ Finset.Ico a b, f x := by
rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add]
conv =>
congr
congr
· skip
· skip
rw [add_comm]
· skip
· skip
congr
congr
rw [← zero_add a]
rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range]
conv =>
rhs
congr
· skip
ext
rw [Nat.cast_add]
apply AntitoneOn.integral_le_sum
simp only [hf, hab, Nat.cast_sub, add_sub_cancel]
theorem AntitoneOn.sum_le_integral (hf : AntitoneOn f (Icc x₀ (x₀ + a))) :
(∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) ≤ ∫ x in x₀..x₀ + a, f x := by
have hint : ∀ k : ℕ, k < a → IntervalIntegrable f volume (x₀ + k) (x₀ + (k + 1 : ℕ)) := by
intro k hk
refine (hf.mono ?_).intervalIntegrable
rw [uIcc_of_le]
· apply Icc_subset_Icc
· simp only [le_add_iff_nonneg_right, Nat.cast_nonneg]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.succ_le_of_lt hk]
· simp only [add_le_add_iff_left, Nat.cast_le, Nat.le_succ]
calc
(∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ))) =
∑ i ∈ Finset.range a, ∫ _ in x₀ + i..x₀ + (i + 1 : ℕ), f (x₀ + (i + 1 : ℕ)) := by simp
_ ≤ ∑ i ∈ Finset.range a, ∫ x in x₀ + i..x₀ + (i + 1 : ℕ), f x := by
apply Finset.sum_le_sum fun i hi => ?_
have ia : i + 1 ≤ a := Finset.mem_range.1 hi
refine intervalIntegral.integral_mono_on (by simp) (by simp) (hint _ ia) fun x hx => ?_
apply hf _ _ hx.2
· refine mem_Icc.2 ⟨le_trans (le_add_of_nonneg_right (Nat.cast_nonneg _)) hx.1,
le_trans hx.2 ?_⟩
simp only [Nat.cast_le, add_le_add_iff_left, ia]
· refine mem_Icc.2 ⟨le_add_of_nonneg_right (Nat.cast_nonneg _), ?_⟩
simp only [add_le_add_iff_left, Nat.cast_le, ia]
_ = ∫ x in x₀..x₀ + a, f x := by
convert intervalIntegral.sum_integral_adjacent_intervals hint
simp only [Nat.cast_zero, add_zero]
theorem AntitoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : AntitoneOn f (Set.Icc a b)) :
(∑ i ∈ Finset.Ico a b, f (i + 1 : ℕ)) ≤ ∫ x in a..b, f x := by
rw [(Nat.sub_add_cancel hab).symm, Nat.cast_add]
conv =>
congr
congr
congr
rw [← zero_add a]
· skip
· skip
· skip
rw [add_comm]
rw [← Finset.sum_Ico_add, Nat.Ico_zero_eq_range]
conv =>
lhs
congr
congr
· skip
ext
rw [add_assoc, Nat.cast_add]
apply AntitoneOn.sum_le_integral
simp only [hf, hab, Nat.cast_sub, add_sub_cancel]
theorem MonotoneOn.sum_le_integral (hf : MonotoneOn f (Icc x₀ (x₀ + a))) :
(∑ i ∈ Finset.range a, f (x₀ + i)) ≤ ∫ x in x₀..x₀ + a, f x := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.integral_le_sum
theorem MonotoneOn.sum_le_integral_Ico (hab : a ≤ b) (hf : MonotoneOn f (Set.Icc a b)) :
∑ x ∈ Finset.Ico a b, f x ≤ ∫ x in a..b, f x := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.integral_le_sum_Ico hab
theorem MonotoneOn.integral_le_sum (hf : MonotoneOn f (Icc x₀ (x₀ + a))) :
(∫ x in x₀..x₀ + a, f x) ≤ ∑ i ∈ Finset.range a, f (x₀ + (i + 1 : ℕ)) := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.sum_le_integral
theorem MonotoneOn.integral_le_sum_Ico (hab : a ≤ b) (hf : MonotoneOn f (Set.Icc a b)) :
(∫ x in a..b, f x) ≤ ∑ i ∈ Finset.Ico a b, f (i + 1 : ℕ) := by
rw [← neg_le_neg_iff, ← Finset.sum_neg_distrib, ← intervalIntegral.integral_neg]
exact hf.neg.sum_le_integral_Ico hab
|
Analysis\SumOverResidueClass.lean | /-
Copyright (c) 2024 Michael Stoll. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Michael Stoll
-/
import Mathlib.Data.ZMod.Basic
import Mathlib.Topology.Instances.ENNReal
import Mathlib.Analysis.Normed.Field.Basic
/-!
# Sums over residue classes
We consider infinite sums over functions `f` on `ℕ`, restricted to a residue class mod `m`.
The main result is `summable_indicator_mod_iff`, which states that when `f : ℕ → ℝ` is
decreasing, then the sum over `f` restricted to any residue class
mod `m ≠ 0` converges if and only if the sum over all of `ℕ` converges.
-/
lemma Finset.sum_indicator_mod {R : Type*} [AddCommMonoid R] (m : ℕ) [NeZero m] (f : ℕ → R) :
f = ∑ a : ZMod m, {n : ℕ | (n : ZMod m) = a}.indicator f := by
ext n
simp only [Finset.sum_apply, Set.indicator_apply, Set.mem_setOf_eq, Finset.sum_ite_eq,
Finset.mem_univ, ↓reduceIte]
open Set in
/-- A sequence `f` with values in an additive topological group `R` is summable on the
residue class of `k` mod `m` if and only if `f (m*n + k)` is summable. -/
lemma summable_indicator_mod_iff_summable {R : Type*} [AddCommGroup R] [TopologicalSpace R]
[TopologicalAddGroup R] (m : ℕ) [hm : NeZero m] (k : ℕ) (f : ℕ → R) :
Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) ↔ Summable fun n ↦ f (m * n + k) := by
trans Summable ({n : ℕ | (n : ZMod m) = k ∧ k ≤ n}.indicator f)
· rw [← (finite_lt_nat k).summable_compl_iff (f := {n : ℕ | (n : ZMod m) = k}.indicator f)]
simp only [summable_subtype_iff_indicator, indicator_indicator, inter_comm, setOf_and,
compl_setOf, not_lt]
· let g : ℕ → ℕ := fun n ↦ m * n + k
have hg : Function.Injective g := fun m n hmn ↦ by simpa [g, hm.ne] using hmn
have hg' : ∀ n ∉ range g, {n : ℕ | (n : ZMod m) = k ∧ k ≤ n}.indicator f n = 0 := by
intro n hn
contrapose! hn
exact (Nat.range_mul_add m k).symm ▸ mem_of_indicator_ne_zero hn
convert (Function.Injective.summable_iff hg hg').symm using 3
simp only [Function.comp_apply, mem_setOf_eq, Nat.cast_add, Nat.cast_mul, CharP.cast_eq_zero,
zero_mul, zero_add, le_add_iff_nonneg_left, zero_le, and_self, indicator_of_mem, g]
/-- If `f : ℕ → ℝ` is decreasing and has a negative term, then `f` is not summable. -/
lemma not_summable_of_antitone_of_neg {f : ℕ → ℝ} (hf : Antitone f) {n : ℕ} (hn : f n < 0) :
¬ Summable f := by
intro hs
have := hs.tendsto_atTop_zero
simp only [Metric.tendsto_atTop, dist_zero_right, Real.norm_eq_abs] at this
obtain ⟨N, hN⟩ := this (|f n|) (abs_pos_of_neg hn)
specialize hN (max n N) (n.le_max_right N)
contrapose! hN; clear hN
have H : f (max n N) ≤ f n := hf (n.le_max_left N)
rwa [abs_of_neg hn, abs_of_neg (H.trans_lt hn), neg_le_neg_iff]
/-- If `f : ℕ → ℝ` is decreasing and has a negative term, then `f` restricted to a residue
class is not summable. -/
lemma not_summable_indicator_mod_of_antitone_of_neg {m : ℕ} [hm : NeZero m] {f : ℕ → ℝ}
(hf : Antitone f) {n : ℕ} (hn : f n < 0) (k : ZMod m) :
¬ Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) := by
rw [← ZMod.natCast_zmod_val k, summable_indicator_mod_iff_summable]
exact not_summable_of_antitone_of_neg
(hf.comp_monotone <| (Covariant.monotone_of_const m).add_const k.val) <|
(hf <| (Nat.le_mul_of_pos_left n Fin.size_pos').trans <| Nat.le_add_right ..).trans_lt hn
/-- If a decreasing sequence of real numbers is summable on one residue class
modulo `m`, then it is also summable on every other residue class mod `m`. -/
lemma summable_indicator_mod_iff_summable_indicator_mod {m : ℕ} [NeZero m] {f : ℕ → ℝ}
(hf : Antitone f) {k : ZMod m} (l : ZMod m)
(hs : Summable ({n : ℕ | (n : ZMod m) = k}.indicator f)) :
Summable ({n : ℕ | (n : ZMod m) = l}.indicator f) := by
by_cases hf₀ : ∀ n, 0 ≤ f n -- the interesting case
· rw [← ZMod.natCast_zmod_val k, summable_indicator_mod_iff_summable] at hs
have hl : (l.val + m : ZMod m) = l := by
simp only [ZMod.natCast_val, ZMod.cast_id', id_eq, CharP.cast_eq_zero, add_zero]
rw [← hl, ← Nat.cast_add, summable_indicator_mod_iff_summable]
exact hs.of_nonneg_of_le (fun _ ↦ hf₀ _)
fun _ ↦ hf <| Nat.add_le_add Nat.le.refl (k.val_lt.trans_le <| m.le_add_left l.val).le
· push_neg at hf₀
obtain ⟨n, hn⟩ := hf₀
exact (not_summable_indicator_mod_of_antitone_of_neg hf hn k hs).elim
/-- A decreasing sequence of real numbers is summable on a residue class
if and only if it is summable. -/
lemma summable_indicator_mod_iff {m : ℕ} [NeZero m] {f : ℕ → ℝ} (hf : Antitone f) (k : ZMod m) :
Summable ({n : ℕ | (n : ZMod m) = k}.indicator f) ↔ Summable f := by
refine ⟨fun H ↦ ?_, fun H ↦ Summable.indicator H _⟩
rw [Finset.sum_indicator_mod m f]
convert summable_sum (s := Finset.univ)
fun a _ ↦ summable_indicator_mod_iff_summable_indicator_mod hf a H
simp only [Finset.sum_apply]
|
Analysis\Analytic\Basic.lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Yury Kudryashov
-/
import Mathlib.Algebra.Star.Order
import Mathlib.Analysis.Calculus.FormalMultilinearSeries
import Mathlib.Analysis.SpecificLimits.Normed
import Mathlib.Logic.Equiv.Fin
import Mathlib.Tactic.Bound.Attribute
import Mathlib.Topology.Algebra.InfiniteSum.Module
/-!
# Analytic functions
A function is analytic in one dimension around `0` if it can be written as a converging power series
`Σ pₙ zⁿ`. This definition can be extended to any dimension (even in infinite dimension) by
requiring that `pₙ` is a continuous `n`-multilinear map. In general, `pₙ` is not unique (in two
dimensions, taking `p₂ (x, y) (x', y') = x y'` or `y x'` gives the same map when applied to a
vector `(x, y) (x, y)`). A way to guarantee uniqueness is to take a symmetric `pₙ`, but this is not
always possible in nonzero characteristic (in characteristic 2, the previous example has no
symmetric representative). Therefore, we do not insist on symmetry or uniqueness in the definition,
and we only require the existence of a converging series.
The general framework is important to say that the exponential map on bounded operators on a Banach
space is analytic, as well as the inverse on invertible operators.
## Main definitions
Let `p` be a formal multilinear series from `E` to `F`, i.e., `p n` is a multilinear map on `E^n`
for `n : ℕ`.
* `p.radius`: the largest `r : ℝ≥0∞` such that `‖p n‖ * r^n` grows subexponentially.
* `p.le_radius_of_bound`, `p.le_radius_of_bound_nnreal`, `p.le_radius_of_isBigO`: if `‖p n‖ * r ^ n`
is bounded above, then `r ≤ p.radius`;
* `p.isLittleO_of_lt_radius`, `p.norm_mul_pow_le_mul_pow_of_lt_radius`,
`p.isLittleO_one_of_lt_radius`,
`p.norm_mul_pow_le_of_lt_radius`, `p.nnnorm_mul_pow_le_of_lt_radius`: if `r < p.radius`, then
`‖p n‖ * r ^ n` tends to zero exponentially;
* `p.lt_radius_of_isBigO`: if `r ≠ 0` and `‖p n‖ * r ^ n = O(a ^ n)` for some `-1 < a < 1`, then
`r < p.radius`;
* `p.partialSum n x`: the sum `∑_{i = 0}^{n-1} pᵢ xⁱ`.
* `p.sum x`: the sum `∑'_{i = 0}^{∞} pᵢ xⁱ`.
Additionally, let `f` be a function from `E` to `F`.
* `HasFPowerSeriesOnBall f p x r`: on the ball of center `x` with radius `r`,
`f (x + y) = ∑'_n pₙ yⁿ`.
* `HasFPowerSeriesAt f p x`: on some ball of center `x` with positive radius, holds
`HasFPowerSeriesOnBall f p x r`.
* `AnalyticAt 𝕜 f x`: there exists a power series `p` such that holds `HasFPowerSeriesAt f p x`.
* `AnalyticOn 𝕜 f s`: the function `f` is analytic at every point of `s`.
We also define versions of `HasFPowerSeriesOnBall`, `AnalyticAt`, and `AnalyticOn` restricted to a
set, similar to `ContinuousWithinAt`. See `Mathlib.Analysis.Analytic.Within` for basic properties.
* `AnalyticWithinAt 𝕜 f s x` means a power series at `x` converges to `f` on `𝓝[s] x`, and
`f` is continuous within `s` at `x`.
* `AnalyticWithinOn 𝕜 f s t` means `∀ x ∈ t, AnalyticWithinAt 𝕜 f s x`.
We develop the basic properties of these notions, notably:
* If a function admits a power series, it is continuous (see
`HasFPowerSeriesOnBall.continuousOn` and `HasFPowerSeriesAt.continuousAt` and
`AnalyticAt.continuousAt`).
* In a complete space, the sum of a formal power series with positive radius is well defined on the
disk of convergence, see `FormalMultilinearSeries.hasFPowerSeriesOnBall`.
* If a function admits a power series in a ball, then it is analytic at any point `y` of this ball,
and the power series there can be expressed in terms of the initial power series `p` as
`p.changeOrigin y`. See `HasFPowerSeriesOnBall.changeOrigin`. It follows in particular that
the set of points at which a given function is analytic is open, see `isOpen_analyticAt`.
## Implementation details
We only introduce the radius of convergence of a power series, as `p.radius`.
For a power series in finitely many dimensions, there is a finer (directional, coordinate-dependent)
notion, describing the polydisk of convergence. This notion is more specific, and not necessary to
build the general theory. We do not define it here.
-/
noncomputable section
variable {𝕜 E F G : Type*}
open Topology NNReal Filter ENNReal Set Asymptotics
namespace FormalMultilinearSeries
variable [Ring 𝕜] [AddCommGroup E] [AddCommGroup F] [Module 𝕜 E] [Module 𝕜 F]
variable [TopologicalSpace E] [TopologicalSpace F]
variable [TopologicalAddGroup E] [TopologicalAddGroup F]
variable [ContinuousConstSMul 𝕜 E] [ContinuousConstSMul 𝕜 F]
/-- Given a formal multilinear series `p` and a vector `x`, then `p.sum x` is the sum `Σ pₙ xⁿ`. A
priori, it only behaves well when `‖x‖ < p.radius`. -/
protected def sum (p : FormalMultilinearSeries 𝕜 E F) (x : E) : F :=
∑' n : ℕ, p n fun _ => x
/-- Given a formal multilinear series `p` and a vector `x`, then `p.partialSum n x` is the sum
`Σ pₖ xᵏ` for `k ∈ {0,..., n-1}`. -/
def partialSum (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) (x : E) : F :=
∑ k ∈ Finset.range n, p k fun _ : Fin k => x
/-- The partial sums of a formal multilinear series are continuous. -/
theorem partialSum_continuous (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) :
Continuous (p.partialSum n) := by
unfold partialSum -- Porting note: added
continuity
end FormalMultilinearSeries
/-! ### The radius of a formal multilinear series -/
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
namespace FormalMultilinearSeries
variable (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
/-- The radius of a formal multilinear series is the largest `r` such that the sum `Σ ‖pₙ‖ ‖y‖ⁿ`
converges for all `‖y‖ < r`. This implies that `Σ pₙ yⁿ` converges for all `‖y‖ < r`, but these
definitions are *not* equivalent in general. -/
def radius (p : FormalMultilinearSeries 𝕜 E F) : ℝ≥0∞ :=
⨆ (r : ℝ≥0) (C : ℝ) (_ : ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C), (r : ℝ≥0∞)
/-- If `‖pₙ‖ rⁿ` is bounded in `n`, then the radius of `p` is at least `r`. -/
theorem le_radius_of_bound (C : ℝ) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
le_iSup_of_le r <| le_iSup_of_le C <| le_iSup (fun _ => (r : ℝ≥0∞)) h
/-- If `‖pₙ‖ rⁿ` is bounded in `n`, then the radius of `p` is at least `r`. -/
theorem le_radius_of_bound_nnreal (C : ℝ≥0) {r : ℝ≥0} (h : ∀ n : ℕ, ‖p n‖₊ * r ^ n ≤ C) :
(r : ℝ≥0∞) ≤ p.radius :=
p.le_radius_of_bound C fun n => mod_cast h n
/-- If `‖pₙ‖ rⁿ = O(1)`, as `n → ∞`, then the radius of `p` is at least `r`. -/
theorem le_radius_of_isBigO (h : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) :
↑r ≤ p.radius :=
Exists.elim (isBigO_one_nat_atTop_iff.1 h) fun C hC =>
p.le_radius_of_bound C fun n => (le_abs_self _).trans (hC n)
theorem le_radius_of_eventually_le (C) (h : ∀ᶠ n in atTop, ‖p n‖ * (r : ℝ) ^ n ≤ C) :
↑r ≤ p.radius :=
p.le_radius_of_isBigO <| IsBigO.of_bound C <| h.mono fun n hn => by simpa
theorem le_radius_of_summable_nnnorm (h : Summable fun n => ‖p n‖₊ * r ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_bound_nnreal (∑' n, ‖p n‖₊ * r ^ n) fun _ => le_tsum' h _
theorem le_radius_of_summable (h : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_summable_nnnorm <| by
simp only [← coe_nnnorm] at h
exact mod_cast h
theorem radius_eq_top_of_forall_nnreal_isBigO
(h : ∀ r : ℝ≥0, (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] fun _ => (1 : ℝ)) : p.radius = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_isBigO (h r)
theorem radius_eq_top_of_eventually_eq_zero (h : ∀ᶠ n in atTop, p n = 0) : p.radius = ∞ :=
p.radius_eq_top_of_forall_nnreal_isBigO fun r =>
(isBigO_zero _ _).congr' (h.mono fun n hn => by simp [hn]) EventuallyEq.rfl
theorem radius_eq_top_of_forall_image_add_eq_zero (n : ℕ) (hn : ∀ m, p (m + n) = 0) :
p.radius = ∞ :=
p.radius_eq_top_of_eventually_eq_zero <|
mem_atTop_sets.2 ⟨n, fun _ hk => tsub_add_cancel_of_le hk ▸ hn _⟩
@[simp]
theorem constFormalMultilinearSeries_radius {v : F} :
(constFormalMultilinearSeries 𝕜 E v).radius = ⊤ :=
(constFormalMultilinearSeries 𝕜 E v).radius_eq_top_of_forall_image_add_eq_zero 1
(by simp [constFormalMultilinearSeries])
/-- `0` has infinite radius of convergence -/
@[simp] lemma zero_radius : (0 : FormalMultilinearSeries 𝕜 E F).radius = ∞ := by
rw [← constFormalMultilinearSeries_zero]
exact constFormalMultilinearSeries_radius
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` tends to zero exponentially:
for some `0 < a < 1`, `‖p n‖ rⁿ = o(aⁿ)`. -/
theorem isLittleO_of_lt_radius (h : ↑r < p.radius) :
∃ a ∈ Ioo (0 : ℝ) 1, (fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (a ^ ·) := by
have := (TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4
rw [this]
-- Porting note: was
-- rw [(TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 4]
simp only [radius, lt_iSup_iff] at h
rcases h with ⟨t, C, hC, rt⟩
rw [ENNReal.coe_lt_coe, ← NNReal.coe_lt_coe] at rt
have : 0 < (t : ℝ) := r.coe_nonneg.trans_lt rt
rw [← div_lt_one this] at rt
refine ⟨_, rt, C, Or.inr zero_lt_one, fun n => ?_⟩
calc
|‖p n‖ * (r : ℝ) ^ n| = ‖p n‖ * (t : ℝ) ^ n * (r / t : ℝ) ^ n := by
field_simp [mul_right_comm, abs_mul]
_ ≤ C * (r / t : ℝ) ^ n := by gcongr; apply hC
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ = o(1)`. -/
theorem isLittleO_one_of_lt_radius (h : ↑r < p.radius) :
(fun n => ‖p n‖ * (r : ℝ) ^ n) =o[atTop] (fun _ => 1 : ℕ → ℝ) :=
let ⟨_, ha, hp⟩ := p.isLittleO_of_lt_radius h
hp.trans <| (isLittleO_pow_pow_of_lt_left ha.1.le ha.2).congr (fun _ => rfl) one_pow
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` tends to zero exponentially:
for some `0 < a < 1` and `C > 0`, `‖p n‖ * r ^ n ≤ C * a ^ n`. -/
theorem norm_mul_pow_le_mul_pow_of_lt_radius (h : ↑r < p.radius) :
∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C * a ^ n := by
-- Porting note: moved out of `rcases`
have := ((TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 1 5).mp
(p.isLittleO_of_lt_radius h)
rcases this with ⟨a, ha, C, hC, H⟩
exact ⟨a, ha, C, hC, fun n => (le_abs_self _).trans (H n)⟩
/-- If `r ≠ 0` and `‖pₙ‖ rⁿ = O(aⁿ)` for some `-1 < a < 1`, then `r < p.radius`. -/
theorem lt_radius_of_isBigO (h₀ : r ≠ 0) {a : ℝ} (ha : a ∈ Ioo (-1 : ℝ) 1)
(hp : (fun n => ‖p n‖ * (r : ℝ) ^ n) =O[atTop] (a ^ ·)) : ↑r < p.radius := by
-- Porting note: moved out of `rcases`
have := ((TFAE_exists_lt_isLittleO_pow (fun n => ‖p n‖ * (r : ℝ) ^ n) 1).out 2 5)
rcases this.mp ⟨a, ha, hp⟩ with ⟨a, ha, C, hC, hp⟩
rw [← pos_iff_ne_zero, ← NNReal.coe_pos] at h₀
lift a to ℝ≥0 using ha.1.le
have : (r : ℝ) < r / a := by
simpa only [div_one] using (div_lt_div_left h₀ zero_lt_one ha.1).2 ha.2
norm_cast at this
rw [← ENNReal.coe_lt_coe] at this
refine this.trans_le (p.le_radius_of_bound C fun n => ?_)
rw [NNReal.coe_div, div_pow, ← mul_div_assoc, div_le_iff (pow_pos ha.1 n)]
exact (le_abs_self _).trans (hp n)
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/
theorem norm_mul_pow_le_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
(h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖ * (r : ℝ) ^ n ≤ C :=
let ⟨_, ha, C, hC, h⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius h
⟨C, hC, fun n => (h n).trans <| mul_le_of_le_one_right hC.lt.le (pow_le_one _ ha.1.le ha.2.le)⟩
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/
theorem norm_le_div_pow_of_pos_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
(h0 : 0 < r) (h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖ ≤ C / (r : ℝ) ^ n :=
let ⟨C, hC, hp⟩ := p.norm_mul_pow_le_of_lt_radius h
⟨C, hC, fun n => Iff.mpr (le_div_iff (pow_pos h0 _)) (hp n)⟩
/-- For `r` strictly smaller than the radius of `p`, then `‖pₙ‖ rⁿ` is bounded. -/
theorem nnnorm_mul_pow_le_of_lt_radius (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0}
(h : (r : ℝ≥0∞) < p.radius) : ∃ C > 0, ∀ n, ‖p n‖₊ * r ^ n ≤ C :=
let ⟨C, hC, hp⟩ := p.norm_mul_pow_le_of_lt_radius h
⟨⟨C, hC.lt.le⟩, hC, mod_cast hp⟩
theorem le_radius_of_tendsto (p : FormalMultilinearSeries 𝕜 E F) {l : ℝ}
(h : Tendsto (fun n => ‖p n‖ * (r : ℝ) ^ n) atTop (𝓝 l)) : ↑r ≤ p.radius :=
p.le_radius_of_isBigO (h.isBigO_one _)
theorem le_radius_of_summable_norm (p : FormalMultilinearSeries 𝕜 E F)
(hs : Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : ↑r ≤ p.radius :=
p.le_radius_of_tendsto hs.tendsto_atTop_zero
theorem not_summable_norm_of_radius_lt_nnnorm (p : FormalMultilinearSeries 𝕜 E F) {x : E}
(h : p.radius < ‖x‖₊) : ¬Summable fun n => ‖p n‖ * ‖x‖ ^ n :=
fun hs => not_le_of_lt h (p.le_radius_of_summable_norm hs)
theorem summable_norm_mul_pow (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : ↑r < p.radius) :
Summable fun n : ℕ => ‖p n‖ * (r : ℝ) ^ n := by
obtain ⟨a, ha : a ∈ Ioo (0 : ℝ) 1, C, - : 0 < C, hp⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius h
exact .of_nonneg_of_le (fun n => mul_nonneg (norm_nonneg _) (pow_nonneg r.coe_nonneg _))
hp ((summable_geometric_of_lt_one ha.1.le ha.2).mul_left _)
theorem summable_norm_apply (p : FormalMultilinearSeries 𝕜 E F) {x : E}
(hx : x ∈ EMetric.ball (0 : E) p.radius) : Summable fun n : ℕ => ‖p n fun _ => x‖ := by
rw [mem_emetric_ball_zero_iff] at hx
refine .of_nonneg_of_le
(fun _ ↦ norm_nonneg _) (fun n ↦ ((p n).le_opNorm _).trans_eq ?_) (p.summable_norm_mul_pow hx)
simp
theorem summable_nnnorm_mul_pow (p : FormalMultilinearSeries 𝕜 E F) {r : ℝ≥0} (h : ↑r < p.radius) :
Summable fun n : ℕ => ‖p n‖₊ * r ^ n := by
rw [← NNReal.summable_coe]
push_cast
exact p.summable_norm_mul_pow h
protected theorem summable [CompleteSpace F] (p : FormalMultilinearSeries 𝕜 E F) {x : E}
(hx : x ∈ EMetric.ball (0 : E) p.radius) : Summable fun n : ℕ => p n fun _ => x :=
(p.summable_norm_apply hx).of_norm
theorem radius_eq_top_of_summable_norm (p : FormalMultilinearSeries 𝕜 E F)
(hs : ∀ r : ℝ≥0, Summable fun n => ‖p n‖ * (r : ℝ) ^ n) : p.radius = ∞ :=
ENNReal.eq_top_of_forall_nnreal_le fun r => p.le_radius_of_summable_norm (hs r)
theorem radius_eq_top_iff_summable_norm (p : FormalMultilinearSeries 𝕜 E F) :
p.radius = ∞ ↔ ∀ r : ℝ≥0, Summable fun n => ‖p n‖ * (r : ℝ) ^ n := by
constructor
· intro h r
obtain ⟨a, ha : a ∈ Ioo (0 : ℝ) 1, C, - : 0 < C, hp⟩ := p.norm_mul_pow_le_mul_pow_of_lt_radius
(show (r : ℝ≥0∞) < p.radius from h.symm ▸ ENNReal.coe_lt_top)
refine .of_norm_bounded
(fun n ↦ (C : ℝ) * a ^ n) ((summable_geometric_of_lt_one ha.1.le ha.2).mul_left _) fun n ↦ ?_
specialize hp n
rwa [Real.norm_of_nonneg (mul_nonneg (norm_nonneg _) (pow_nonneg r.coe_nonneg n))]
· exact p.radius_eq_top_of_summable_norm
/-- If the radius of `p` is positive, then `‖pₙ‖` grows at most geometrically. -/
theorem le_mul_pow_of_radius_pos (p : FormalMultilinearSeries 𝕜 E F) (h : 0 < p.radius) :
∃ (C r : _) (hC : 0 < C) (_ : 0 < r), ∀ n, ‖p n‖ ≤ C * r ^ n := by
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 h with ⟨r, r0, rlt⟩
have rpos : 0 < (r : ℝ) := by simp [ENNReal.coe_pos.1 r0]
rcases norm_le_div_pow_of_pos_of_lt_radius p rpos rlt with ⟨C, Cpos, hCp⟩
refine ⟨C, r⁻¹, Cpos, by simp only [inv_pos, rpos], fun n => ?_⟩
-- Porting note: was `convert`
rw [inv_pow, ← div_eq_mul_inv]
exact hCp n
/-- The radius of the sum of two formal series is at least the minimum of their two radii. -/
theorem min_radius_le_radius_add (p q : FormalMultilinearSeries 𝕜 E F) :
min p.radius q.radius ≤ (p + q).radius := by
refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_
rw [lt_min_iff] at hr
have := ((p.isLittleO_one_of_lt_radius hr.1).add (q.isLittleO_one_of_lt_radius hr.2)).isBigO
refine (p + q).le_radius_of_isBigO ((isBigO_of_le _ fun n => ?_).trans this)
rw [← add_mul, norm_mul, norm_mul, norm_norm]
exact mul_le_mul_of_nonneg_right ((norm_add_le _ _).trans (le_abs_self _)) (norm_nonneg _)
@[simp]
theorem radius_neg (p : FormalMultilinearSeries 𝕜 E F) : (-p).radius = p.radius := by
simp only [radius, neg_apply, norm_neg]
protected theorem hasSum [CompleteSpace F] (p : FormalMultilinearSeries 𝕜 E F) {x : E}
(hx : x ∈ EMetric.ball (0 : E) p.radius) : HasSum (fun n : ℕ => p n fun _ => x) (p.sum x) :=
(p.summable hx).hasSum
theorem radius_le_radius_continuousLinearMap_comp (p : FormalMultilinearSeries 𝕜 E F)
(f : F →L[𝕜] G) : p.radius ≤ (f.compFormalMultilinearSeries p).radius := by
refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_
apply le_radius_of_isBigO
apply (IsBigO.trans_isLittleO _ (p.isLittleO_one_of_lt_radius hr)).isBigO
refine IsBigO.mul (@IsBigOWith.isBigO _ _ _ _ _ ‖f‖ _ _ _ ?_) (isBigO_refl _ _)
refine IsBigOWith.of_bound (eventually_of_forall fun n => ?_)
simpa only [norm_norm] using f.norm_compContinuousMultilinearMap_le (p n)
end FormalMultilinearSeries
/-! ### Expanding a function as a power series -/
section
variable {f g : E → F} {p pf pg : FormalMultilinearSeries 𝕜 E F} {x : E} {r r' : ℝ≥0∞}
/-- Given a function `f : E → F` and a formal multilinear series `p`, we say that `f` has `p` as
a power series on the ball of radius `r > 0` around `x` if `f (x + y) = ∑' pₙ yⁿ` for all `‖y‖ < r`.
-/
structure HasFPowerSeriesOnBall (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) (r : ℝ≥0∞) :
Prop where
r_le : r ≤ p.radius
r_pos : 0 < r
hasSum :
∀ {y}, y ∈ EMetric.ball (0 : E) r → HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y))
/-- Analogue of `HasFPowerSeriesOnBall` where convergence is required only on a set `s`. -/
structure HasFPowerSeriesWithinOnBall (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (s : Set E)
(x : E) (r : ℝ≥0∞) : Prop where
/-- `p` converges on `ball 0 r` -/
r_le : r ≤ p.radius
/-- The radius of convergence is positive -/
r_pos : 0 < r
/-- `p converges to f` within `s` -/
hasSum : ∀ {y}, x + y ∈ s → y ∈ EMetric.ball (0 : E) r →
HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y))
/-- We require `ContinuousWithinAt f s x` to ensure `f x` is nice -/
continuousWithinAt : ContinuousWithinAt f s x
/-- Given a function `f : E → F` and a formal multilinear series `p`, we say that `f` has `p` as
a power series around `x` if `f (x + y) = ∑' pₙ yⁿ` for all `y` in a neighborhood of `0`. -/
def HasFPowerSeriesAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) :=
∃ r, HasFPowerSeriesOnBall f p x r
/-- Analogue of `HasFPowerSeriesAt` where convergence is required only on a set `s`. -/
def HasFPowerSeriesWithinAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (s : Set E) (x : E) :=
∃ r, HasFPowerSeriesWithinOnBall f p s x r
-- Teach the `bound` tactic that power series have positive radius
attribute [bound_forward] HasFPowerSeriesOnBall.r_pos HasFPowerSeriesWithinOnBall.r_pos
variable (𝕜)
/-- Given a function `f : E → F`, we say that `f` is analytic at `x` if it admits a convergent power
series expansion around `x`. -/
def AnalyticAt (f : E → F) (x : E) :=
∃ p : FormalMultilinearSeries 𝕜 E F, HasFPowerSeriesAt f p x
/-- `f` is analytic within `s` at `x` if it has a power series at `x` that converges on `𝓝[s] x` -/
def AnalyticWithinAt (f : E → F) (s : Set E) (x : E) : Prop :=
∃ p : FormalMultilinearSeries 𝕜 E F, HasFPowerSeriesWithinAt f p s x
/-- Given a function `f : E → F`, we say that `f` is analytic on a set `s` if it is analytic around
every point of `s`. -/
def AnalyticOn (f : E → F) (s : Set E) :=
∀ x, x ∈ s → AnalyticAt 𝕜 f x
/-- `f` is analytic within `s` if it is analytic within `s` at each point of `t`. Note that
this is weaker than `AnalyticOn 𝕜 f s`, as `f` is allowed to be arbitrary outside `s`. -/
def AnalyticWithinOn (f : E → F) (s : Set E) : Prop :=
∀ x ∈ s, AnalyticWithinAt 𝕜 f s x
variable {𝕜}
theorem HasFPowerSeriesOnBall.hasFPowerSeriesAt (hf : HasFPowerSeriesOnBall f p x r) :
HasFPowerSeriesAt f p x :=
⟨r, hf⟩
theorem HasFPowerSeriesAt.analyticAt (hf : HasFPowerSeriesAt f p x) : AnalyticAt 𝕜 f x :=
⟨p, hf⟩
theorem HasFPowerSeriesOnBall.analyticAt (hf : HasFPowerSeriesOnBall f p x r) : AnalyticAt 𝕜 f x :=
hf.hasFPowerSeriesAt.analyticAt
theorem HasFPowerSeriesOnBall.congr (hf : HasFPowerSeriesOnBall f p x r)
(hg : EqOn f g (EMetric.ball x r)) : HasFPowerSeriesOnBall g p x r :=
{ r_le := hf.r_le
r_pos := hf.r_pos
hasSum := fun {y} hy => by
convert hf.hasSum hy using 1
apply hg.symm
simpa [edist_eq_coe_nnnorm_sub] using hy }
/-- If a function `f` has a power series `p` around `x`, then the function `z ↦ f (z - y)` has the
same power series around `x + y`. -/
theorem HasFPowerSeriesOnBall.comp_sub (hf : HasFPowerSeriesOnBall f p x r) (y : E) :
HasFPowerSeriesOnBall (fun z => f (z - y)) p (x + y) r :=
{ r_le := hf.r_le
r_pos := hf.r_pos
hasSum := fun {z} hz => by
convert hf.hasSum hz using 2
abel }
theorem HasFPowerSeriesOnBall.hasSum_sub (hf : HasFPowerSeriesOnBall f p x r) {y : E}
(hy : y ∈ EMetric.ball x r) : HasSum (fun n : ℕ => p n fun _ => y - x) (f y) := by
have : y - x ∈ EMetric.ball (0 : E) r := by simpa [edist_eq_coe_nnnorm_sub] using hy
simpa only [add_sub_cancel] using hf.hasSum this
theorem HasFPowerSeriesOnBall.radius_pos (hf : HasFPowerSeriesOnBall f p x r) : 0 < p.radius :=
lt_of_lt_of_le hf.r_pos hf.r_le
theorem HasFPowerSeriesAt.radius_pos (hf : HasFPowerSeriesAt f p x) : 0 < p.radius :=
let ⟨_, hr⟩ := hf
hr.radius_pos
theorem HasFPowerSeriesOnBall.mono (hf : HasFPowerSeriesOnBall f p x r) (r'_pos : 0 < r')
(hr : r' ≤ r) : HasFPowerSeriesOnBall f p x r' :=
⟨le_trans hr hf.1, r'_pos, fun hy => hf.hasSum (EMetric.ball_subset_ball hr hy)⟩
theorem HasFPowerSeriesAt.congr (hf : HasFPowerSeriesAt f p x) (hg : f =ᶠ[𝓝 x] g) :
HasFPowerSeriesAt g p x := by
rcases hf with ⟨r₁, h₁⟩
rcases EMetric.mem_nhds_iff.mp hg with ⟨r₂, h₂pos, h₂⟩
exact ⟨min r₁ r₂,
(h₁.mono (lt_min h₁.r_pos h₂pos) inf_le_left).congr
fun y hy => h₂ (EMetric.ball_subset_ball inf_le_right hy)⟩
protected theorem HasFPowerSeriesAt.eventually (hf : HasFPowerSeriesAt f p x) :
∀ᶠ r : ℝ≥0∞ in 𝓝[>] 0, HasFPowerSeriesOnBall f p x r :=
let ⟨_, hr⟩ := hf
mem_of_superset (Ioo_mem_nhdsWithin_Ioi (left_mem_Ico.2 hr.r_pos)) fun _ hr' =>
hr.mono hr'.1 hr'.2.le
theorem HasFPowerSeriesOnBall.eventually_hasSum (hf : HasFPowerSeriesOnBall f p x r) :
∀ᶠ y in 𝓝 0, HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y)) := by
filter_upwards [EMetric.ball_mem_nhds (0 : E) hf.r_pos] using fun _ => hf.hasSum
theorem HasFPowerSeriesAt.eventually_hasSum (hf : HasFPowerSeriesAt f p x) :
∀ᶠ y in 𝓝 0, HasSum (fun n : ℕ => p n fun _ : Fin n => y) (f (x + y)) :=
let ⟨_, hr⟩ := hf
hr.eventually_hasSum
theorem HasFPowerSeriesOnBall.eventually_hasSum_sub (hf : HasFPowerSeriesOnBall f p x r) :
∀ᶠ y in 𝓝 x, HasSum (fun n : ℕ => p n fun _ : Fin n => y - x) (f y) := by
filter_upwards [EMetric.ball_mem_nhds x hf.r_pos] with y using hf.hasSum_sub
theorem HasFPowerSeriesAt.eventually_hasSum_sub (hf : HasFPowerSeriesAt f p x) :
∀ᶠ y in 𝓝 x, HasSum (fun n : ℕ => p n fun _ : Fin n => y - x) (f y) :=
let ⟨_, hr⟩ := hf
hr.eventually_hasSum_sub
theorem HasFPowerSeriesOnBall.eventually_eq_zero
(hf : HasFPowerSeriesOnBall f (0 : FormalMultilinearSeries 𝕜 E F) x r) :
∀ᶠ z in 𝓝 x, f z = 0 := by
filter_upwards [hf.eventually_hasSum_sub] with z hz using hz.unique hasSum_zero
theorem HasFPowerSeriesAt.eventually_eq_zero
(hf : HasFPowerSeriesAt f (0 : FormalMultilinearSeries 𝕜 E F) x) : ∀ᶠ z in 𝓝 x, f z = 0 :=
let ⟨_, hr⟩ := hf
hr.eventually_eq_zero
theorem hasFPowerSeriesOnBall_const {c : F} {e : E} :
HasFPowerSeriesOnBall (fun _ => c) (constFormalMultilinearSeries 𝕜 E c) e ⊤ := by
refine ⟨by simp, WithTop.zero_lt_top, fun _ => hasSum_single 0 fun n hn => ?_⟩
simp [constFormalMultilinearSeries_apply hn]
theorem hasFPowerSeriesAt_const {c : F} {e : E} :
HasFPowerSeriesAt (fun _ => c) (constFormalMultilinearSeries 𝕜 E c) e :=
⟨⊤, hasFPowerSeriesOnBall_const⟩
theorem analyticAt_const {v : F} : AnalyticAt 𝕜 (fun _ => v) x :=
⟨constFormalMultilinearSeries 𝕜 E v, hasFPowerSeriesAt_const⟩
theorem analyticOn_const {v : F} {s : Set E} : AnalyticOn 𝕜 (fun _ => v) s :=
fun _ _ => analyticAt_const
theorem HasFPowerSeriesOnBall.add (hf : HasFPowerSeriesOnBall f pf x r)
(hg : HasFPowerSeriesOnBall g pg x r) : HasFPowerSeriesOnBall (f + g) (pf + pg) x r :=
{ r_le := le_trans (le_min_iff.2 ⟨hf.r_le, hg.r_le⟩) (pf.min_radius_le_radius_add pg)
r_pos := hf.r_pos
hasSum := fun hy => (hf.hasSum hy).add (hg.hasSum hy) }
theorem HasFPowerSeriesAt.add (hf : HasFPowerSeriesAt f pf x) (hg : HasFPowerSeriesAt g pg x) :
HasFPowerSeriesAt (f + g) (pf + pg) x := by
rcases (hf.eventually.and hg.eventually).exists with ⟨r, hr⟩
exact ⟨r, hr.1.add hr.2⟩
theorem AnalyticAt.congr (hf : AnalyticAt 𝕜 f x) (hg : f =ᶠ[𝓝 x] g) : AnalyticAt 𝕜 g x :=
let ⟨_, hpf⟩ := hf
(hpf.congr hg).analyticAt
theorem analyticAt_congr (h : f =ᶠ[𝓝 x] g) : AnalyticAt 𝕜 f x ↔ AnalyticAt 𝕜 g x :=
⟨fun hf ↦ hf.congr h, fun hg ↦ hg.congr h.symm⟩
theorem AnalyticAt.add (hf : AnalyticAt 𝕜 f x) (hg : AnalyticAt 𝕜 g x) : AnalyticAt 𝕜 (f + g) x :=
let ⟨_, hpf⟩ := hf
let ⟨_, hqf⟩ := hg
(hpf.add hqf).analyticAt
theorem HasFPowerSeriesOnBall.neg (hf : HasFPowerSeriesOnBall f pf x r) :
HasFPowerSeriesOnBall (-f) (-pf) x r :=
{ r_le := by
rw [pf.radius_neg]
exact hf.r_le
r_pos := hf.r_pos
hasSum := fun hy => (hf.hasSum hy).neg }
theorem HasFPowerSeriesAt.neg (hf : HasFPowerSeriesAt f pf x) : HasFPowerSeriesAt (-f) (-pf) x :=
let ⟨_, hrf⟩ := hf
hrf.neg.hasFPowerSeriesAt
theorem AnalyticAt.neg (hf : AnalyticAt 𝕜 f x) : AnalyticAt 𝕜 (-f) x :=
let ⟨_, hpf⟩ := hf
hpf.neg.analyticAt
theorem HasFPowerSeriesOnBall.sub (hf : HasFPowerSeriesOnBall f pf x r)
(hg : HasFPowerSeriesOnBall g pg x r) : HasFPowerSeriesOnBall (f - g) (pf - pg) x r := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem HasFPowerSeriesAt.sub (hf : HasFPowerSeriesAt f pf x) (hg : HasFPowerSeriesAt g pg x) :
HasFPowerSeriesAt (f - g) (pf - pg) x := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem AnalyticAt.sub (hf : AnalyticAt 𝕜 f x) (hg : AnalyticAt 𝕜 g x) :
AnalyticAt 𝕜 (f - g) x := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem AnalyticOn.mono {s t : Set E} (hf : AnalyticOn 𝕜 f t) (hst : s ⊆ t) : AnalyticOn 𝕜 f s :=
fun z hz => hf z (hst hz)
theorem AnalyticOn.congr' {s : Set E} (hf : AnalyticOn 𝕜 f s) (hg : f =ᶠ[𝓝ˢ s] g) :
AnalyticOn 𝕜 g s :=
fun z hz => (hf z hz).congr (mem_nhdsSet_iff_forall.mp hg z hz)
theorem analyticOn_congr' {s : Set E} (h : f =ᶠ[𝓝ˢ s] g) : AnalyticOn 𝕜 f s ↔ AnalyticOn 𝕜 g s :=
⟨fun hf => hf.congr' h, fun hg => hg.congr' h.symm⟩
theorem AnalyticOn.congr {s : Set E} (hs : IsOpen s) (hf : AnalyticOn 𝕜 f s) (hg : s.EqOn f g) :
AnalyticOn 𝕜 g s :=
hf.congr' <| mem_nhdsSet_iff_forall.mpr
(fun _ hz => eventuallyEq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hz, hg⟩)
theorem analyticOn_congr {s : Set E} (hs : IsOpen s) (h : s.EqOn f g) : AnalyticOn 𝕜 f s ↔
AnalyticOn 𝕜 g s := ⟨fun hf => hf.congr hs h, fun hg => hg.congr hs h.symm⟩
theorem AnalyticOn.add {s : Set E} (hf : AnalyticOn 𝕜 f s) (hg : AnalyticOn 𝕜 g s) :
AnalyticOn 𝕜 (f + g) s :=
fun z hz => (hf z hz).add (hg z hz)
theorem AnalyticOn.neg {s : Set E} (hf : AnalyticOn 𝕜 f s) : AnalyticOn 𝕜 (-f) s :=
fun z hz ↦ (hf z hz).neg
theorem AnalyticOn.sub {s : Set E} (hf : AnalyticOn 𝕜 f s) (hg : AnalyticOn 𝕜 g s) :
AnalyticOn 𝕜 (f - g) s :=
fun z hz => (hf z hz).sub (hg z hz)
theorem HasFPowerSeriesOnBall.coeff_zero (hf : HasFPowerSeriesOnBall f pf x r) (v : Fin 0 → E) :
pf 0 v = f x := by
have v_eq : v = fun i => 0 := Subsingleton.elim _ _
have zero_mem : (0 : E) ∈ EMetric.ball (0 : E) r := by simp [hf.r_pos]
have : ∀ i, i ≠ 0 → (pf i fun j => 0) = 0 := by
intro i hi
have : 0 < i := pos_iff_ne_zero.2 hi
exact ContinuousMultilinearMap.map_coord_zero _ (⟨0, this⟩ : Fin i) rfl
have A := (hf.hasSum zero_mem).unique (hasSum_single _ this)
simpa [v_eq] using A.symm
theorem HasFPowerSeriesAt.coeff_zero (hf : HasFPowerSeriesAt f pf x) (v : Fin 0 → E) :
pf 0 v = f x :=
let ⟨_, hrf⟩ := hf
hrf.coeff_zero v
/-- If a function `f` has a power series `p` on a ball and `g` is linear, then `g ∘ f` has the
power series `g ∘ p` on the same ball. -/
theorem ContinuousLinearMap.comp_hasFPowerSeriesOnBall (g : F →L[𝕜] G)
(h : HasFPowerSeriesOnBall f p x r) :
HasFPowerSeriesOnBall (g ∘ f) (g.compFormalMultilinearSeries p) x r :=
{ r_le := h.r_le.trans (p.radius_le_radius_continuousLinearMap_comp _)
r_pos := h.r_pos
hasSum := fun hy => by
simpa only [ContinuousLinearMap.compFormalMultilinearSeries_apply,
ContinuousLinearMap.compContinuousMultilinearMap_coe, Function.comp_apply] using
g.hasSum (h.hasSum hy) }
/-- If a function `f` is analytic on a set `s` and `g` is linear, then `g ∘ f` is analytic
on `s`. -/
theorem ContinuousLinearMap.comp_analyticOn {s : Set E} (g : F →L[𝕜] G) (h : AnalyticOn 𝕜 f s) :
AnalyticOn 𝕜 (g ∘ f) s := by
rintro x hx
rcases h x hx with ⟨p, r, hp⟩
exact ⟨g.compFormalMultilinearSeries p, r, g.comp_hasFPowerSeriesOnBall hp⟩
/-- If a function admits a power series expansion, then it is exponentially close to the partial
sums of this power series on strict subdisks of the disk of convergence.
This version provides an upper estimate that decreases both in `‖y‖` and `n`. See also
`HasFPowerSeriesOnBall.uniform_geometric_approx` for a weaker version. -/
theorem HasFPowerSeriesOnBall.uniform_geometric_approx' {r' : ℝ≥0}
(hf : HasFPowerSeriesOnBall f p x r) (h : (r' : ℝ≥0∞) < r) :
∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ y ∈ Metric.ball (0 : E) r', ∀ n,
‖f (x + y) - p.partialSum n y‖ ≤ C * (a * (‖y‖ / r')) ^ n := by
obtain ⟨a, ha, C, hC, hp⟩ : ∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ n, ‖p n‖ * (r' : ℝ) ^ n ≤ C * a ^ n :=
p.norm_mul_pow_le_mul_pow_of_lt_radius (h.trans_le hf.r_le)
refine ⟨a, ha, C / (1 - a), div_pos hC (sub_pos.2 ha.2), fun y hy n => ?_⟩
have yr' : ‖y‖ < r' := by
rw [ball_zero_eq] at hy
exact hy
have hr'0 : 0 < (r' : ℝ) := (norm_nonneg _).trans_lt yr'
have : y ∈ EMetric.ball (0 : E) r := by
refine mem_emetric_ball_zero_iff.2 (lt_trans ?_ h)
exact mod_cast yr'
rw [norm_sub_rev, ← mul_div_right_comm]
have ya : a * (‖y‖ / ↑r') ≤ a :=
mul_le_of_le_one_right ha.1.le (div_le_one_of_le yr'.le r'.coe_nonneg)
suffices ‖p.partialSum n y - f (x + y)‖ ≤ C * (a * (‖y‖ / r')) ^ n / (1 - a * (‖y‖ / r')) by
refine this.trans ?_
have : 0 < a := ha.1
gcongr
apply_rules [sub_pos.2, ha.2]
apply norm_sub_le_of_geometric_bound_of_hasSum (ya.trans_lt ha.2) _ (hf.hasSum this)
intro n
calc
‖(p n) fun _ : Fin n => y‖
_ ≤ ‖p n‖ * ∏ _i : Fin n, ‖y‖ := ContinuousMultilinearMap.le_opNorm _ _
_ = ‖p n‖ * (r' : ℝ) ^ n * (‖y‖ / r') ^ n := by field_simp [mul_right_comm]
_ ≤ C * a ^ n * (‖y‖ / r') ^ n := by gcongr ?_ * _; apply hp
_ ≤ C * (a * (‖y‖ / r')) ^ n := by rw [mul_pow, mul_assoc]
/-- If a function admits a power series expansion, then it is exponentially close to the partial
sums of this power series on strict subdisks of the disk of convergence. -/
theorem HasFPowerSeriesOnBall.uniform_geometric_approx {r' : ℝ≥0}
(hf : HasFPowerSeriesOnBall f p x r) (h : (r' : ℝ≥0∞) < r) :
∃ a ∈ Ioo (0 : ℝ) 1,
∃ C > 0, ∀ y ∈ Metric.ball (0 : E) r', ∀ n, ‖f (x + y) - p.partialSum n y‖ ≤ C * a ^ n := by
obtain ⟨a, ha, C, hC, hp⟩ : ∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ y ∈ Metric.ball (0 : E) r', ∀ n,
‖f (x + y) - p.partialSum n y‖ ≤ C * (a * (‖y‖ / r')) ^ n :=
hf.uniform_geometric_approx' h
refine ⟨a, ha, C, hC, fun y hy n => (hp y hy n).trans ?_⟩
have yr' : ‖y‖ < r' := by rwa [ball_zero_eq] at hy
have := ha.1.le -- needed to discharge a side goal on the next line
gcongr
exact mul_le_of_le_one_right ha.1.le (div_le_one_of_le yr'.le r'.coe_nonneg)
/-- Taylor formula for an analytic function, `IsBigO` version. -/
theorem HasFPowerSeriesAt.isBigO_sub_partialSum_pow (hf : HasFPowerSeriesAt f p x) (n : ℕ) :
(fun y : E => f (x + y) - p.partialSum n y) =O[𝓝 0] fun y => ‖y‖ ^ n := by
rcases hf with ⟨r, hf⟩
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 hf.r_pos with ⟨r', r'0, h⟩
obtain ⟨a, -, C, -, hp⟩ : ∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ y ∈ Metric.ball (0 : E) r', ∀ n,
‖f (x + y) - p.partialSum n y‖ ≤ C * (a * (‖y‖ / r')) ^ n :=
hf.uniform_geometric_approx' h
refine isBigO_iff.2 ⟨C * (a / r') ^ n, ?_⟩
replace r'0 : 0 < (r' : ℝ) := mod_cast r'0
filter_upwards [Metric.ball_mem_nhds (0 : E) r'0] with y hy
simpa [mul_pow, mul_div_assoc, mul_assoc, div_mul_eq_mul_div] using hp y hy n
/-- If `f` has formal power series `∑ n, pₙ` on a ball of radius `r`, then for `y, z` in any smaller
ball, the norm of the difference `f y - f z - p 1 (fun _ ↦ y - z)` is bounded above by
`C * (max ‖y - x‖ ‖z - x‖) * ‖y - z‖`. This lemma formulates this property using `IsBigO` and
`Filter.principal` on `E × E`. -/
theorem HasFPowerSeriesOnBall.isBigO_image_sub_image_sub_deriv_principal
(hf : HasFPowerSeriesOnBall f p x r) (hr : r' < r) :
(fun y : E × E => f y.1 - f y.2 - p 1 fun _ => y.1 - y.2) =O[𝓟 (EMetric.ball (x, x) r')]
fun y => ‖y - (x, x)‖ * ‖y.1 - y.2‖ := by
lift r' to ℝ≥0 using ne_top_of_lt hr
rcases (zero_le r').eq_or_lt with (rfl | hr'0)
· simp only [isBigO_bot, EMetric.ball_zero, principal_empty, ENNReal.coe_zero]
obtain ⟨a, ha, C, hC : 0 < C, hp⟩ :
∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ n : ℕ, ‖p n‖ * (r' : ℝ) ^ n ≤ C * a ^ n :=
p.norm_mul_pow_le_mul_pow_of_lt_radius (hr.trans_le hf.r_le)
simp only [← le_div_iff (pow_pos (NNReal.coe_pos.2 hr'0) _)] at hp
set L : E × E → ℝ := fun y =>
C * (a / r') ^ 2 * (‖y - (x, x)‖ * ‖y.1 - y.2‖) * (a / (1 - a) ^ 2 + 2 / (1 - a))
have hL : ∀ y ∈ EMetric.ball (x, x) r', ‖f y.1 - f y.2 - p 1 fun _ => y.1 - y.2‖ ≤ L y := by
intro y hy'
have hy : y ∈ EMetric.ball x r ×ˢ EMetric.ball x r := by
rw [EMetric.ball_prod_same]
exact EMetric.ball_subset_ball hr.le hy'
set A : ℕ → F := fun n => (p n fun _ => y.1 - x) - p n fun _ => y.2 - x
have hA : HasSum (fun n => A (n + 2)) (f y.1 - f y.2 - p 1 fun _ => y.1 - y.2) := by
convert (hasSum_nat_add_iff' 2).2 ((hf.hasSum_sub hy.1).sub (hf.hasSum_sub hy.2)) using 1
rw [Finset.sum_range_succ, Finset.sum_range_one, hf.coeff_zero, hf.coeff_zero, sub_self,
zero_add, ← Subsingleton.pi_single_eq (0 : Fin 1) (y.1 - x), Pi.single,
← Subsingleton.pi_single_eq (0 : Fin 1) (y.2 - x), Pi.single, ← (p 1).map_sub, ← Pi.single,
Subsingleton.pi_single_eq, sub_sub_sub_cancel_right]
rw [EMetric.mem_ball, edist_eq_coe_nnnorm_sub, ENNReal.coe_lt_coe] at hy'
set B : ℕ → ℝ := fun n => C * (a / r') ^ 2 * (‖y - (x, x)‖ * ‖y.1 - y.2‖) * ((n + 2) * a ^ n)
have hAB : ∀ n, ‖A (n + 2)‖ ≤ B n := fun n =>
calc
‖A (n + 2)‖ ≤ ‖p (n + 2)‖ * ↑(n + 2) * ‖y - (x, x)‖ ^ (n + 1) * ‖y.1 - y.2‖ := by
-- Porting note: `pi_norm_const` was `pi_norm_const (_ : E)`
simpa only [Fintype.card_fin, pi_norm_const, Prod.norm_def, Pi.sub_def,
Prod.fst_sub, Prod.snd_sub, sub_sub_sub_cancel_right] using
(p <| n + 2).norm_image_sub_le (fun _ => y.1 - x) fun _ => y.2 - x
_ = ‖p (n + 2)‖ * ‖y - (x, x)‖ ^ n * (↑(n + 2) * ‖y - (x, x)‖ * ‖y.1 - y.2‖) := by
rw [pow_succ ‖y - (x, x)‖]
ring
-- Porting note: the two `↑` in `↑r'` are new, without them, Lean fails to synthesize
-- instances `HDiv ℝ ℝ≥0 ?m` or `HMul ℝ ℝ≥0 ?m`
_ ≤ C * a ^ (n + 2) / ↑r' ^ (n + 2)
* ↑r' ^ n * (↑(n + 2) * ‖y - (x, x)‖ * ‖y.1 - y.2‖) := by
have : 0 < a := ha.1
gcongr
· apply hp
· apply hy'.le
_ = B n := by
field_simp [B, pow_succ]
simp only [mul_assoc, mul_comm, mul_left_comm]
have hBL : HasSum B (L y) := by
apply HasSum.mul_left
simp only [add_mul]
have : ‖a‖ < 1 := by simp only [Real.norm_eq_abs, abs_of_pos ha.1, ha.2]
rw [div_eq_mul_inv, div_eq_mul_inv]
exact (hasSum_coe_mul_geometric_of_norm_lt_one this).add -- Porting note: was `convert`!
((hasSum_geometric_of_norm_lt_one this).mul_left 2)
exact hA.norm_le_of_bounded hBL hAB
suffices L =O[𝓟 (EMetric.ball (x, x) r')] fun y => ‖y - (x, x)‖ * ‖y.1 - y.2‖ by
refine (IsBigO.of_bound 1 (eventually_principal.2 fun y hy => ?_)).trans this
rw [one_mul]
exact (hL y hy).trans (le_abs_self _)
simp_rw [L, mul_right_comm _ (_ * _)]
exact (isBigO_refl _ _).const_mul_left _
/-- If `f` has formal power series `∑ n, pₙ` on a ball of radius `r`, then for `y, z` in any smaller
ball, the norm of the difference `f y - f z - p 1 (fun _ ↦ y - z)` is bounded above by
`C * (max ‖y - x‖ ‖z - x‖) * ‖y - z‖`. -/
theorem HasFPowerSeriesOnBall.image_sub_sub_deriv_le (hf : HasFPowerSeriesOnBall f p x r)
(hr : r' < r) :
∃ C, ∀ᵉ (y ∈ EMetric.ball x r') (z ∈ EMetric.ball x r'),
‖f y - f z - p 1 fun _ => y - z‖ ≤ C * max ‖y - x‖ ‖z - x‖ * ‖y - z‖ := by
simpa only [isBigO_principal, mul_assoc, norm_mul, norm_norm, Prod.forall, EMetric.mem_ball,
Prod.edist_eq, max_lt_iff, and_imp, @forall_swap (_ < _) E] using
hf.isBigO_image_sub_image_sub_deriv_principal hr
/-- If `f` has formal power series `∑ n, pₙ` at `x`, then
`f y - f z - p 1 (fun _ ↦ y - z) = O(‖(y, z) - (x, x)‖ * ‖y - z‖)` as `(y, z) → (x, x)`.
In particular, `f` is strictly differentiable at `x`. -/
theorem HasFPowerSeriesAt.isBigO_image_sub_norm_mul_norm_sub (hf : HasFPowerSeriesAt f p x) :
(fun y : E × E => f y.1 - f y.2 - p 1 fun _ => y.1 - y.2) =O[𝓝 (x, x)] fun y =>
‖y - (x, x)‖ * ‖y.1 - y.2‖ := by
rcases hf with ⟨r, hf⟩
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 hf.r_pos with ⟨r', r'0, h⟩
refine (hf.isBigO_image_sub_image_sub_deriv_principal h).mono ?_
exact le_principal_iff.2 (EMetric.ball_mem_nhds _ r'0)
/-- If a function admits a power series expansion at `x`, then it is the uniform limit of the
partial sums of this power series on strict subdisks of the disk of convergence, i.e., `f (x + y)`
is the uniform limit of `p.partialSum n y` there. -/
theorem HasFPowerSeriesOnBall.tendstoUniformlyOn {r' : ℝ≥0} (hf : HasFPowerSeriesOnBall f p x r)
(h : (r' : ℝ≥0∞) < r) :
TendstoUniformlyOn (fun n y => p.partialSum n y) (fun y => f (x + y)) atTop
(Metric.ball (0 : E) r') := by
obtain ⟨a, ha, C, -, hp⟩ : ∃ a ∈ Ioo (0 : ℝ) 1, ∃ C > 0, ∀ y ∈ Metric.ball (0 : E) r', ∀ n,
‖f (x + y) - p.partialSum n y‖ ≤ C * a ^ n := hf.uniform_geometric_approx h
refine Metric.tendstoUniformlyOn_iff.2 fun ε εpos => ?_
have L : Tendsto (fun n => (C : ℝ) * a ^ n) atTop (𝓝 ((C : ℝ) * 0)) :=
tendsto_const_nhds.mul (tendsto_pow_atTop_nhds_zero_of_lt_one ha.1.le ha.2)
rw [mul_zero] at L
refine (L.eventually (gt_mem_nhds εpos)).mono fun n hn y hy => ?_
rw [dist_eq_norm]
exact (hp y hy n).trans_lt hn
/-- If a function admits a power series expansion at `x`, then it is the locally uniform limit of
the partial sums of this power series on the disk of convergence, i.e., `f (x + y)`
is the locally uniform limit of `p.partialSum n y` there. -/
theorem HasFPowerSeriesOnBall.tendstoLocallyUniformlyOn (hf : HasFPowerSeriesOnBall f p x r) :
TendstoLocallyUniformlyOn (fun n y => p.partialSum n y) (fun y => f (x + y)) atTop
(EMetric.ball (0 : E) r) := by
intro u hu x hx
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 hx with ⟨r', xr', hr'⟩
have : EMetric.ball (0 : E) r' ∈ 𝓝 x := IsOpen.mem_nhds EMetric.isOpen_ball xr'
refine ⟨EMetric.ball (0 : E) r', mem_nhdsWithin_of_mem_nhds this, ?_⟩
simpa [Metric.emetric_ball_nnreal] using hf.tendstoUniformlyOn hr' u hu
/-- If a function admits a power series expansion at `x`, then it is the uniform limit of the
partial sums of this power series on strict subdisks of the disk of convergence, i.e., `f y`
is the uniform limit of `p.partialSum n (y - x)` there. -/
theorem HasFPowerSeriesOnBall.tendstoUniformlyOn' {r' : ℝ≥0} (hf : HasFPowerSeriesOnBall f p x r)
(h : (r' : ℝ≥0∞) < r) :
TendstoUniformlyOn (fun n y => p.partialSum n (y - x)) f atTop (Metric.ball (x : E) r') := by
convert (hf.tendstoUniformlyOn h).comp fun y => y - x using 1
· simp [(· ∘ ·)]
· ext z
simp [dist_eq_norm]
/-- If a function admits a power series expansion at `x`, then it is the locally uniform limit of
the partial sums of this power series on the disk of convergence, i.e., `f y`
is the locally uniform limit of `p.partialSum n (y - x)` there. -/
theorem HasFPowerSeriesOnBall.tendstoLocallyUniformlyOn' (hf : HasFPowerSeriesOnBall f p x r) :
TendstoLocallyUniformlyOn (fun n y => p.partialSum n (y - x)) f atTop
(EMetric.ball (x : E) r) := by
have A : ContinuousOn (fun y : E => y - x) (EMetric.ball (x : E) r) :=
(continuous_id.sub continuous_const).continuousOn
convert hf.tendstoLocallyUniformlyOn.comp (fun y : E => y - x) _ A using 1
· ext z
simp
· intro z
simp [edist_eq_coe_nnnorm, edist_eq_coe_nnnorm_sub]
/-- If a function admits a power series expansion on a disk, then it is continuous there. -/
protected theorem HasFPowerSeriesOnBall.continuousOn (hf : HasFPowerSeriesOnBall f p x r) :
ContinuousOn f (EMetric.ball x r) :=
hf.tendstoLocallyUniformlyOn'.continuousOn <|
eventually_of_forall fun n =>
((p.partialSum_continuous n).comp (continuous_id.sub continuous_const)).continuousOn
protected theorem HasFPowerSeriesAt.continuousAt (hf : HasFPowerSeriesAt f p x) :
ContinuousAt f x :=
let ⟨_, hr⟩ := hf
hr.continuousOn.continuousAt (EMetric.ball_mem_nhds x hr.r_pos)
protected theorem AnalyticAt.continuousAt (hf : AnalyticAt 𝕜 f x) : ContinuousAt f x :=
let ⟨_, hp⟩ := hf
hp.continuousAt
protected theorem AnalyticOn.continuousOn {s : Set E} (hf : AnalyticOn 𝕜 f s) : ContinuousOn f s :=
fun x hx => (hf x hx).continuousAt.continuousWithinAt
/-- Analytic everywhere implies continuous -/
theorem AnalyticOn.continuous {f : E → F} (fa : AnalyticOn 𝕜 f univ) : Continuous f := by
rw [continuous_iff_continuousOn_univ]; exact fa.continuousOn
/-- In a complete space, the sum of a converging power series `p` admits `p` as a power series.
This is not totally obvious as we need to check the convergence of the series. -/
protected theorem FormalMultilinearSeries.hasFPowerSeriesOnBall [CompleteSpace F]
(p : FormalMultilinearSeries 𝕜 E F) (h : 0 < p.radius) :
HasFPowerSeriesOnBall p.sum p 0 p.radius :=
{ r_le := le_rfl
r_pos := h
hasSum := fun hy => by
rw [zero_add]
exact p.hasSum hy }
theorem HasFPowerSeriesOnBall.sum (h : HasFPowerSeriesOnBall f p x r) {y : E}
(hy : y ∈ EMetric.ball (0 : E) r) : f (x + y) = p.sum y :=
(h.hasSum hy).tsum_eq.symm
/-- The sum of a converging power series is continuous in its disk of convergence. -/
protected theorem FormalMultilinearSeries.continuousOn [CompleteSpace F] :
ContinuousOn p.sum (EMetric.ball 0 p.radius) := by
rcases (zero_le p.radius).eq_or_lt with h | h
· simp [← h, continuousOn_empty]
· exact (p.hasFPowerSeriesOnBall h).continuousOn
end
/-!
### Uniqueness of power series
If a function `f : E → F` has two representations as power series at a point `x : E`, corresponding
to formal multilinear series `p₁` and `p₂`, then these representations agree term-by-term. That is,
for any `n : ℕ` and `y : E`, `p₁ n (fun i ↦ y) = p₂ n (fun i ↦ y)`. In the one-dimensional case,
when `f : 𝕜 → E`, the continuous multilinear maps `p₁ n` and `p₂ n` are given by
`ContinuousMultilinearMap.mkPiRing`, and hence are determined completely by the value of
`p₁ n (fun i ↦ 1)`, so `p₁ = p₂`. Consequently, the radius of convergence for one series can be
transferred to the other.
-/
section Uniqueness
open ContinuousMultilinearMap
theorem Asymptotics.IsBigO.continuousMultilinearMap_apply_eq_zero {n : ℕ} {p : E[×n]→L[𝕜] F}
(h : (fun y => p fun _ => y) =O[𝓝 0] fun y => ‖y‖ ^ (n + 1)) (y : E) : (p fun _ => y) = 0 := by
obtain ⟨c, c_pos, hc⟩ := h.exists_pos
obtain ⟨t, ht, t_open, z_mem⟩ := eventually_nhds_iff.mp (isBigOWith_iff.mp hc)
obtain ⟨δ, δ_pos, δε⟩ := (Metric.isOpen_iff.mp t_open) 0 z_mem
clear h hc z_mem
cases' n with n
· exact norm_eq_zero.mp (by
-- Porting note: the symmetric difference of the `simpa only` sets:
-- added `Nat.zero_eq, zero_add, pow_one`
-- removed `zero_pow, Ne.def, Nat.one_ne_zero, not_false_iff`
simpa only [Nat.zero_eq, fin0_apply_norm, norm_eq_zero, norm_zero, zero_add, pow_one,
mul_zero, norm_le_zero_iff] using ht 0 (δε (Metric.mem_ball_self δ_pos)))
· refine Or.elim (Classical.em (y = 0))
(fun hy => by simpa only [hy] using p.map_zero) fun hy => ?_
replace hy := norm_pos_iff.mpr hy
refine norm_eq_zero.mp (le_antisymm (le_of_forall_pos_le_add fun ε ε_pos => ?_) (norm_nonneg _))
have h₀ := _root_.mul_pos c_pos (pow_pos hy (n.succ + 1))
obtain ⟨k, k_pos, k_norm⟩ := NormedField.exists_norm_lt 𝕜
(lt_min (mul_pos δ_pos (inv_pos.mpr hy)) (mul_pos ε_pos (inv_pos.mpr h₀)))
have h₁ : ‖k • y‖ < δ := by
rw [norm_smul]
exact inv_mul_cancel_right₀ hy.ne.symm δ ▸
mul_lt_mul_of_pos_right (lt_of_lt_of_le k_norm (min_le_left _ _)) hy
have h₂ :=
calc
‖p fun _ => k • y‖ ≤ c * ‖k • y‖ ^ (n.succ + 1) := by
-- Porting note: now Lean wants `_root_.`
simpa only [norm_pow, _root_.norm_norm] using ht (k • y) (δε (mem_ball_zero_iff.mpr h₁))
--simpa only [norm_pow, norm_norm] using ht (k • y) (δε (mem_ball_zero_iff.mpr h₁))
_ = ‖k‖ ^ n.succ * (‖k‖ * (c * ‖y‖ ^ (n.succ + 1))) := by
-- Porting note: added `Nat.succ_eq_add_one` since otherwise `ring` does not conclude.
simp only [norm_smul, mul_pow, Nat.succ_eq_add_one]
-- Porting note: removed `rw [pow_succ]`, since it now becomes superfluous.
ring
have h₃ : ‖k‖ * (c * ‖y‖ ^ (n.succ + 1)) < ε :=
inv_mul_cancel_right₀ h₀.ne.symm ε ▸
mul_lt_mul_of_pos_right (lt_of_lt_of_le k_norm (min_le_right _ _)) h₀
calc
‖p fun _ => y‖ = ‖k⁻¹ ^ n.succ‖ * ‖p fun _ => k • y‖ := by
simpa only [inv_smul_smul₀ (norm_pos_iff.mp k_pos), norm_smul, Finset.prod_const,
Finset.card_fin] using
congr_arg norm (p.map_smul_univ (fun _ : Fin n.succ => k⁻¹) fun _ : Fin n.succ => k • y)
_ ≤ ‖k⁻¹ ^ n.succ‖ * (‖k‖ ^ n.succ * (‖k‖ * (c * ‖y‖ ^ (n.succ + 1)))) := by gcongr
_ = ‖(k⁻¹ * k) ^ n.succ‖ * (‖k‖ * (c * ‖y‖ ^ (n.succ + 1))) := by
rw [← mul_assoc]
simp [norm_mul, mul_pow]
_ ≤ 0 + ε := by
rw [inv_mul_cancel (norm_pos_iff.mp k_pos)]
simpa using h₃.le
/-- If a formal multilinear series `p` represents the zero function at `x : E`, then the
terms `p n (fun i ↦ y)` appearing in the sum are zero for any `n : ℕ`, `y : E`. -/
theorem HasFPowerSeriesAt.apply_eq_zero {p : FormalMultilinearSeries 𝕜 E F} {x : E}
(h : HasFPowerSeriesAt 0 p x) (n : ℕ) : ∀ y : E, (p n fun _ => y) = 0 := by
refine Nat.strong_induction_on n fun k hk => ?_
have psum_eq : p.partialSum (k + 1) = fun y => p k fun _ => y := by
funext z
refine Finset.sum_eq_single _ (fun b hb hnb => ?_) fun hn => ?_
· have := Finset.mem_range_succ_iff.mp hb
simp only [hk b (this.lt_of_ne hnb), Pi.zero_apply]
· exact False.elim (hn (Finset.mem_range.mpr (lt_add_one k)))
replace h := h.isBigO_sub_partialSum_pow k.succ
simp only [psum_eq, zero_sub, Pi.zero_apply, Asymptotics.isBigO_neg_left] at h
exact h.continuousMultilinearMap_apply_eq_zero
/-- A one-dimensional formal multilinear series representing the zero function is zero. -/
theorem HasFPowerSeriesAt.eq_zero {p : FormalMultilinearSeries 𝕜 𝕜 E} {x : 𝕜}
(h : HasFPowerSeriesAt 0 p x) : p = 0 := by
ext n x
rw [← mkPiRing_apply_one_eq_self (p n)]
simp [h.apply_eq_zero n 1]
/-- One-dimensional formal multilinear series representing the same function are equal. -/
theorem HasFPowerSeriesAt.eq_formalMultilinearSeries {p₁ p₂ : FormalMultilinearSeries 𝕜 𝕜 E}
{f : 𝕜 → E} {x : 𝕜} (h₁ : HasFPowerSeriesAt f p₁ x) (h₂ : HasFPowerSeriesAt f p₂ x) : p₁ = p₂ :=
sub_eq_zero.mp (HasFPowerSeriesAt.eq_zero (by simpa only [sub_self] using h₁.sub h₂))
theorem HasFPowerSeriesAt.eq_formalMultilinearSeries_of_eventually
{p q : FormalMultilinearSeries 𝕜 𝕜 E} {f g : 𝕜 → E} {x : 𝕜} (hp : HasFPowerSeriesAt f p x)
(hq : HasFPowerSeriesAt g q x) (heq : ∀ᶠ z in 𝓝 x, f z = g z) : p = q :=
(hp.congr heq).eq_formalMultilinearSeries hq
/-- A one-dimensional formal multilinear series representing a locally zero function is zero. -/
theorem HasFPowerSeriesAt.eq_zero_of_eventually {p : FormalMultilinearSeries 𝕜 𝕜 E} {f : 𝕜 → E}
{x : 𝕜} (hp : HasFPowerSeriesAt f p x) (hf : f =ᶠ[𝓝 x] 0) : p = 0 :=
(hp.congr hf).eq_zero
/-- If a function `f : 𝕜 → E` has two power series representations at `x`, then the given radii in
which convergence is guaranteed may be interchanged. This can be useful when the formal multilinear
series in one representation has a particularly nice form, but the other has a larger radius. -/
theorem HasFPowerSeriesOnBall.exchange_radius {p₁ p₂ : FormalMultilinearSeries 𝕜 𝕜 E} {f : 𝕜 → E}
{r₁ r₂ : ℝ≥0∞} {x : 𝕜} (h₁ : HasFPowerSeriesOnBall f p₁ x r₁)
(h₂ : HasFPowerSeriesOnBall f p₂ x r₂) : HasFPowerSeriesOnBall f p₁ x r₂ :=
h₂.hasFPowerSeriesAt.eq_formalMultilinearSeries h₁.hasFPowerSeriesAt ▸ h₂
/-- If a function `f : 𝕜 → E` has power series representation `p` on a ball of some radius and for
each positive radius it has some power series representation, then `p` converges to `f` on the whole
`𝕜`. -/
theorem HasFPowerSeriesOnBall.r_eq_top_of_exists {f : 𝕜 → E} {r : ℝ≥0∞} {x : 𝕜}
{p : FormalMultilinearSeries 𝕜 𝕜 E} (h : HasFPowerSeriesOnBall f p x r)
(h' : ∀ (r' : ℝ≥0) (_ : 0 < r'), ∃ p' : FormalMultilinearSeries 𝕜 𝕜 E,
HasFPowerSeriesOnBall f p' x r') :
HasFPowerSeriesOnBall f p x ∞ :=
{ r_le := ENNReal.le_of_forall_pos_nnreal_lt fun r hr _ =>
let ⟨_, hp'⟩ := h' r hr
(h.exchange_radius hp').r_le
r_pos := ENNReal.coe_lt_top
hasSum := fun {y} _ =>
let ⟨r', hr'⟩ := exists_gt ‖y‖₊
let ⟨_, hp'⟩ := h' r' hr'.ne_bot.bot_lt
(h.exchange_radius hp').hasSum <| mem_emetric_ball_zero_iff.mpr (ENNReal.coe_lt_coe.2 hr') }
end Uniqueness
/-!
### Changing origin in a power series
If a function is analytic in a disk `D(x, R)`, then it is analytic in any disk contained in that
one. Indeed, one can write
$$
f (x + y + z) = \sum_{n} p_n (y + z)^n = \sum_{n, k} \binom{n}{k} p_n y^{n-k} z^k
= \sum_{k} \Bigl(\sum_{n} \binom{n}{k} p_n y^{n-k}\Bigr) z^k.
$$
The corresponding power series has thus a `k`-th coefficient equal to
$\sum_{n} \binom{n}{k} p_n y^{n-k}$. In the general case where `pₙ` is a multilinear map, this has
to be interpreted suitably: instead of having a binomial coefficient, one should sum over all
possible subsets `s` of `Fin n` of cardinality `k`, and attribute `z` to the indices in `s` and
`y` to the indices outside of `s`.
In this paragraph, we implement this. The new power series is called `p.changeOrigin y`. Then, we
check its convergence and the fact that its sum coincides with the original sum. The outcome of this
discussion is that the set of points where a function is analytic is open.
-/
namespace FormalMultilinearSeries
section
variable (p : FormalMultilinearSeries 𝕜 E F) {x y : E} {r R : ℝ≥0}
/-- A term of `FormalMultilinearSeries.changeOriginSeries`.
Given a formal multilinear series `p` and a point `x` in its ball of convergence,
`p.changeOrigin x` is a formal multilinear series such that
`p.sum (x+y) = (p.changeOrigin x).sum y` when this makes sense. Each term of `p.changeOrigin x`
is itself an analytic function of `x` given by the series `p.changeOriginSeries`. Each term in
`changeOriginSeries` is the sum of `changeOriginSeriesTerm`'s over all `s` of cardinality `l`.
The definition is such that `p.changeOriginSeriesTerm k l s hs (fun _ ↦ x) (fun _ ↦ y) =
p (k + l) (s.piecewise (fun _ ↦ x) (fun _ ↦ y))`
-/
def changeOriginSeriesTerm (k l : ℕ) (s : Finset (Fin (k + l))) (hs : s.card = l) :
E[×l]→L[𝕜] E[×k]→L[𝕜] F := by
let a := ContinuousMultilinearMap.curryFinFinset 𝕜 E F hs
(by erw [Finset.card_compl, Fintype.card_fin, hs, add_tsub_cancel_right])
exact a (p (k + l))
theorem changeOriginSeriesTerm_apply (k l : ℕ) (s : Finset (Fin (k + l))) (hs : s.card = l)
(x y : E) :
(p.changeOriginSeriesTerm k l s hs (fun _ => x) fun _ => y) =
p (k + l) (s.piecewise (fun _ => x) fun _ => y) :=
ContinuousMultilinearMap.curryFinFinset_apply_const _ _ _ _ _
@[simp]
theorem norm_changeOriginSeriesTerm (k l : ℕ) (s : Finset (Fin (k + l))) (hs : s.card = l) :
‖p.changeOriginSeriesTerm k l s hs‖ = ‖p (k + l)‖ := by
simp only [changeOriginSeriesTerm, LinearIsometryEquiv.norm_map]
@[simp]
theorem nnnorm_changeOriginSeriesTerm (k l : ℕ) (s : Finset (Fin (k + l))) (hs : s.card = l) :
‖p.changeOriginSeriesTerm k l s hs‖₊ = ‖p (k + l)‖₊ := by
simp only [changeOriginSeriesTerm, LinearIsometryEquiv.nnnorm_map]
theorem nnnorm_changeOriginSeriesTerm_apply_le (k l : ℕ) (s : Finset (Fin (k + l)))
(hs : s.card = l) (x y : E) :
‖p.changeOriginSeriesTerm k l s hs (fun _ => x) fun _ => y‖₊ ≤
‖p (k + l)‖₊ * ‖x‖₊ ^ l * ‖y‖₊ ^ k := by
rw [← p.nnnorm_changeOriginSeriesTerm k l s hs, ← Fin.prod_const, ← Fin.prod_const]
apply ContinuousMultilinearMap.le_of_opNNNorm_le
apply ContinuousMultilinearMap.le_opNNNorm
/-- The power series for `f.changeOrigin k`.
Given a formal multilinear series `p` and a point `x` in its ball of convergence,
`p.changeOrigin x` is a formal multilinear series such that
`p.sum (x+y) = (p.changeOrigin x).sum y` when this makes sense. Its `k`-th term is the sum of
the series `p.changeOriginSeries k`. -/
def changeOriginSeries (k : ℕ) : FormalMultilinearSeries 𝕜 E (E[×k]→L[𝕜] F) := fun l =>
∑ s : { s : Finset (Fin (k + l)) // Finset.card s = l }, p.changeOriginSeriesTerm k l s s.2
theorem nnnorm_changeOriginSeries_le_tsum (k l : ℕ) :
‖p.changeOriginSeries k l‖₊ ≤
∑' _ : { s : Finset (Fin (k + l)) // s.card = l }, ‖p (k + l)‖₊ :=
(nnnorm_sum_le _ (fun t => changeOriginSeriesTerm p k l (Subtype.val t) t.prop)).trans_eq <| by
simp_rw [tsum_fintype, nnnorm_changeOriginSeriesTerm (p := p) (k := k) (l := l)]
theorem nnnorm_changeOriginSeries_apply_le_tsum (k l : ℕ) (x : E) :
‖p.changeOriginSeries k l fun _ => x‖₊ ≤
∑' _ : { s : Finset (Fin (k + l)) // s.card = l }, ‖p (k + l)‖₊ * ‖x‖₊ ^ l := by
rw [NNReal.tsum_mul_right, ← Fin.prod_const]
exact (p.changeOriginSeries k l).le_of_opNNNorm_le _ (p.nnnorm_changeOriginSeries_le_tsum _ _)
/-- Changing the origin of a formal multilinear series `p`, so that
`p.sum (x+y) = (p.changeOrigin x).sum y` when this makes sense.
-/
def changeOrigin (x : E) : FormalMultilinearSeries 𝕜 E F :=
fun k => (p.changeOriginSeries k).sum x
/-- An auxiliary equivalence useful in the proofs about
`FormalMultilinearSeries.changeOriginSeries`: the set of triples `(k, l, s)`, where `s` is a
`Finset (Fin (k + l))` of cardinality `l` is equivalent to the set of pairs `(n, s)`, where `s` is a
`Finset (Fin n)`.
The forward map sends `(k, l, s)` to `(k + l, s)` and the inverse map sends `(n, s)` to
`(n - Finset.card s, Finset.card s, s)`. The actual definition is less readable because of problems
with non-definitional equalities. -/
@[simps]
def changeOriginIndexEquiv :
(Σ k l : ℕ, { s : Finset (Fin (k + l)) // s.card = l }) ≃ Σ n : ℕ, Finset (Fin n) where
toFun s := ⟨s.1 + s.2.1, s.2.2⟩
invFun s :=
⟨s.1 - s.2.card, s.2.card,
⟨s.2.map
(finCongr <| (tsub_add_cancel_of_le <| card_finset_fin_le s.2).symm).toEmbedding,
Finset.card_map _⟩⟩
left_inv := by
rintro ⟨k, l, ⟨s : Finset (Fin <| k + l), hs : s.card = l⟩⟩
dsimp only [Subtype.coe_mk]
-- Lean can't automatically generalize `k' = k + l - s.card`, `l' = s.card`, so we explicitly
-- formulate the generalized goal
suffices ∀ k' l', k' = k → l' = l → ∀ (hkl : k + l = k' + l') (hs'),
(⟨k', l', ⟨s.map (finCongr hkl).toEmbedding, hs'⟩⟩ :
Σk l : ℕ, { s : Finset (Fin (k + l)) // s.card = l }) = ⟨k, l, ⟨s, hs⟩⟩ by
apply this <;> simp only [hs, add_tsub_cancel_right]
rintro _ _ rfl rfl hkl hs'
simp only [Equiv.refl_toEmbedding, finCongr_refl, Finset.map_refl, eq_self_iff_true,
OrderIso.refl_toEquiv, and_self_iff, heq_iff_eq]
right_inv := by
rintro ⟨n, s⟩
simp [tsub_add_cancel_of_le (card_finset_fin_le s), finCongr_eq_equivCast]
lemma changeOriginSeriesTerm_changeOriginIndexEquiv_symm (n t) :
let s := changeOriginIndexEquiv.symm ⟨n, t⟩
p.changeOriginSeriesTerm s.1 s.2.1 s.2.2 s.2.2.2 (fun _ ↦ x) (fun _ ↦ y) =
p n (t.piecewise (fun _ ↦ x) fun _ ↦ y) := by
have : ∀ (m) (hm : n = m), p n (t.piecewise (fun _ ↦ x) fun _ ↦ y) =
p m ((t.map (finCongr hm).toEmbedding).piecewise (fun _ ↦ x) fun _ ↦ y) := by
rintro m rfl
simp (config := { unfoldPartialApp := true }) [Finset.piecewise]
simp_rw [changeOriginSeriesTerm_apply, eq_comm]; apply this
theorem changeOriginSeries_summable_aux₁ {r r' : ℝ≥0} (hr : (r + r' : ℝ≥0∞) < p.radius) :
Summable fun s : Σk l : ℕ, { s : Finset (Fin (k + l)) // s.card = l } =>
‖p (s.1 + s.2.1)‖₊ * r ^ s.2.1 * r' ^ s.1 := by
rw [← changeOriginIndexEquiv.symm.summable_iff]
dsimp only [Function.comp_def, changeOriginIndexEquiv_symm_apply_fst,
changeOriginIndexEquiv_symm_apply_snd_fst]
have : ∀ n : ℕ,
HasSum (fun s : Finset (Fin n) => ‖p (n - s.card + s.card)‖₊ * r ^ s.card * r' ^ (n - s.card))
(‖p n‖₊ * (r + r') ^ n) := by
intro n
-- TODO: why `simp only [tsub_add_cancel_of_le (card_finset_fin_le _)]` fails?
convert_to HasSum (fun s : Finset (Fin n) => ‖p n‖₊ * (r ^ s.card * r' ^ (n - s.card))) _
· ext1 s
rw [tsub_add_cancel_of_le (card_finset_fin_le _), mul_assoc]
rw [← Fin.sum_pow_mul_eq_add_pow]
exact (hasSum_fintype _).mul_left _
refine NNReal.summable_sigma.2 ⟨fun n => (this n).summable, ?_⟩
simp only [(this _).tsum_eq]
exact p.summable_nnnorm_mul_pow hr
theorem changeOriginSeries_summable_aux₂ (hr : (r : ℝ≥0∞) < p.radius) (k : ℕ) :
Summable fun s : Σl : ℕ, { s : Finset (Fin (k + l)) // s.card = l } =>
‖p (k + s.1)‖₊ * r ^ s.1 := by
rcases ENNReal.lt_iff_exists_add_pos_lt.1 hr with ⟨r', h0, hr'⟩
simpa only [mul_inv_cancel_right₀ (pow_pos h0 _).ne'] using
((NNReal.summable_sigma.1 (p.changeOriginSeries_summable_aux₁ hr')).1 k).mul_right (r' ^ k)⁻¹
theorem changeOriginSeries_summable_aux₃ {r : ℝ≥0} (hr : ↑r < p.radius) (k : ℕ) :
Summable fun l : ℕ => ‖p.changeOriginSeries k l‖₊ * r ^ l := by
refine NNReal.summable_of_le
(fun n => ?_) (NNReal.summable_sigma.1 <| p.changeOriginSeries_summable_aux₂ hr k).2
simp only [NNReal.tsum_mul_right]
exact mul_le_mul' (p.nnnorm_changeOriginSeries_le_tsum _ _) le_rfl
theorem le_changeOriginSeries_radius (k : ℕ) : p.radius ≤ (p.changeOriginSeries k).radius :=
ENNReal.le_of_forall_nnreal_lt fun _r hr =>
le_radius_of_summable_nnnorm _ (p.changeOriginSeries_summable_aux₃ hr k)
theorem nnnorm_changeOrigin_le (k : ℕ) (h : (‖x‖₊ : ℝ≥0∞) < p.radius) :
‖p.changeOrigin x k‖₊ ≤
∑' s : Σl : ℕ, { s : Finset (Fin (k + l)) // s.card = l }, ‖p (k + s.1)‖₊ * ‖x‖₊ ^ s.1 := by
refine tsum_of_nnnorm_bounded ?_ fun l => p.nnnorm_changeOriginSeries_apply_le_tsum k l x
have := p.changeOriginSeries_summable_aux₂ h k
refine HasSum.sigma this.hasSum fun l => ?_
exact ((NNReal.summable_sigma.1 this).1 l).hasSum
/-- The radius of convergence of `p.changeOrigin x` is at least `p.radius - ‖x‖`. In other words,
`p.changeOrigin x` is well defined on the largest ball contained in the original ball of
convergence. -/
theorem changeOrigin_radius : p.radius - ‖x‖₊ ≤ (p.changeOrigin x).radius := by
refine ENNReal.le_of_forall_pos_nnreal_lt fun r _h0 hr => ?_
rw [lt_tsub_iff_right, add_comm] at hr
have hr' : (‖x‖₊ : ℝ≥0∞) < p.radius := (le_add_right le_rfl).trans_lt hr
apply le_radius_of_summable_nnnorm
have : ∀ k : ℕ,
‖p.changeOrigin x k‖₊ * r ^ k ≤
(∑' s : Σl : ℕ, { s : Finset (Fin (k + l)) // s.card = l }, ‖p (k + s.1)‖₊ * ‖x‖₊ ^ s.1) *
r ^ k :=
fun k => mul_le_mul_right' (p.nnnorm_changeOrigin_le k hr') (r ^ k)
refine NNReal.summable_of_le this ?_
simpa only [← NNReal.tsum_mul_right] using
(NNReal.summable_sigma.1 (p.changeOriginSeries_summable_aux₁ hr)).2
/-- `derivSeries p` is a power series for `fderiv 𝕜 f` if `p` is a power series for `f`,
see `HasFPowerSeriesOnBall.fderiv`. -/
def derivSeries : FormalMultilinearSeries 𝕜 E (E →L[𝕜] F) :=
(continuousMultilinearCurryFin1 𝕜 E F : (E[×1]→L[𝕜] F) →L[𝕜] E →L[𝕜] F)
|>.compFormalMultilinearSeries (p.changeOriginSeries 1)
end
-- From this point on, assume that the space is complete, to make sure that series that converge
-- in norm also converge in `F`.
variable [CompleteSpace F] (p : FormalMultilinearSeries 𝕜 E F) {x y : E} {r R : ℝ≥0}
theorem hasFPowerSeriesOnBall_changeOrigin (k : ℕ) (hr : 0 < p.radius) :
HasFPowerSeriesOnBall (fun x => p.changeOrigin x k) (p.changeOriginSeries k) 0 p.radius :=
have := p.le_changeOriginSeries_radius k
((p.changeOriginSeries k).hasFPowerSeriesOnBall (hr.trans_le this)).mono hr this
/-- Summing the series `p.changeOrigin x` at a point `y` gives back `p (x + y)`. -/
theorem changeOrigin_eval (h : (‖x‖₊ + ‖y‖₊ : ℝ≥0∞) < p.radius) :
(p.changeOrigin x).sum y = p.sum (x + y) := by
have radius_pos : 0 < p.radius := lt_of_le_of_lt (zero_le _) h
have x_mem_ball : x ∈ EMetric.ball (0 : E) p.radius :=
mem_emetric_ball_zero_iff.2 ((le_add_right le_rfl).trans_lt h)
have y_mem_ball : y ∈ EMetric.ball (0 : E) (p.changeOrigin x).radius := by
refine mem_emetric_ball_zero_iff.2 (lt_of_lt_of_le ?_ p.changeOrigin_radius)
rwa [lt_tsub_iff_right, add_comm]
have x_add_y_mem_ball : x + y ∈ EMetric.ball (0 : E) p.radius := by
refine mem_emetric_ball_zero_iff.2 (lt_of_le_of_lt ?_ h)
exact mod_cast nnnorm_add_le x y
set f : (Σ k l : ℕ, { s : Finset (Fin (k + l)) // s.card = l }) → F := fun s =>
p.changeOriginSeriesTerm s.1 s.2.1 s.2.2 s.2.2.2 (fun _ => x) fun _ => y
have hsf : Summable f := by
refine .of_nnnorm_bounded _ (p.changeOriginSeries_summable_aux₁ h) ?_
rintro ⟨k, l, s, hs⟩
dsimp only [Subtype.coe_mk]
exact p.nnnorm_changeOriginSeriesTerm_apply_le _ _ _ _ _ _
have hf : HasSum f ((p.changeOrigin x).sum y) := by
refine HasSum.sigma_of_hasSum ((p.changeOrigin x).summable y_mem_ball).hasSum (fun k => ?_) hsf
· dsimp only [f]
refine ContinuousMultilinearMap.hasSum_eval ?_ _
have := (p.hasFPowerSeriesOnBall_changeOrigin k radius_pos).hasSum x_mem_ball
rw [zero_add] at this
refine HasSum.sigma_of_hasSum this (fun l => ?_) ?_
· simp only [changeOriginSeries, ContinuousMultilinearMap.sum_apply]
apply hasSum_fintype
· refine .of_nnnorm_bounded _
(p.changeOriginSeries_summable_aux₂ (mem_emetric_ball_zero_iff.1 x_mem_ball) k)
fun s => ?_
refine (ContinuousMultilinearMap.le_opNNNorm _ _).trans_eq ?_
simp
refine hf.unique (changeOriginIndexEquiv.symm.hasSum_iff.1 ?_)
refine HasSum.sigma_of_hasSum
(p.hasSum x_add_y_mem_ball) (fun n => ?_) (changeOriginIndexEquiv.symm.summable_iff.2 hsf)
erw [(p n).map_add_univ (fun _ => x) fun _ => y]
simp_rw [← changeOriginSeriesTerm_changeOriginIndexEquiv_symm]
exact hasSum_fintype (fun c => f (changeOriginIndexEquiv.symm ⟨n, c⟩))
/-- Power series terms are analytic as we vary the origin -/
theorem analyticAt_changeOrigin (p : FormalMultilinearSeries 𝕜 E F) (rp : p.radius > 0) (n : ℕ) :
AnalyticAt 𝕜 (fun x ↦ p.changeOrigin x n) 0 :=
(FormalMultilinearSeries.hasFPowerSeriesOnBall_changeOrigin p n rp).analyticAt
end FormalMultilinearSeries
section
variable [CompleteSpace F] {f : E → F} {p : FormalMultilinearSeries 𝕜 E F} {x y : E} {r : ℝ≥0∞}
/-- If a function admits a power series expansion `p` on a ball `B (x, r)`, then it also admits a
power series on any subball of this ball (even with a different center), given by `p.changeOrigin`.
-/
theorem HasFPowerSeriesOnBall.changeOrigin (hf : HasFPowerSeriesOnBall f p x r)
(h : (‖y‖₊ : ℝ≥0∞) < r) : HasFPowerSeriesOnBall f (p.changeOrigin y) (x + y) (r - ‖y‖₊) :=
{ r_le := by
apply le_trans _ p.changeOrigin_radius
exact tsub_le_tsub hf.r_le le_rfl
r_pos := by simp [h]
hasSum := fun {z} hz => by
have : f (x + y + z) =
FormalMultilinearSeries.sum (FormalMultilinearSeries.changeOrigin p y) z := by
rw [mem_emetric_ball_zero_iff, lt_tsub_iff_right, add_comm] at hz
rw [p.changeOrigin_eval (hz.trans_le hf.r_le), add_assoc, hf.sum]
refine mem_emetric_ball_zero_iff.2 (lt_of_le_of_lt ?_ hz)
exact mod_cast nnnorm_add_le y z
rw [this]
apply (p.changeOrigin y).hasSum
refine EMetric.ball_subset_ball (le_trans ?_ p.changeOrigin_radius) hz
exact tsub_le_tsub hf.r_le le_rfl }
/-- If a function admits a power series expansion `p` on an open ball `B (x, r)`, then
it is analytic at every point of this ball. -/
theorem HasFPowerSeriesOnBall.analyticAt_of_mem (hf : HasFPowerSeriesOnBall f p x r)
(h : y ∈ EMetric.ball x r) : AnalyticAt 𝕜 f y := by
have : (‖y - x‖₊ : ℝ≥0∞) < r := by simpa [edist_eq_coe_nnnorm_sub] using h
have := hf.changeOrigin this
rw [add_sub_cancel] at this
exact this.analyticAt
theorem HasFPowerSeriesOnBall.analyticOn (hf : HasFPowerSeriesOnBall f p x r) :
AnalyticOn 𝕜 f (EMetric.ball x r) :=
fun _y hy => hf.analyticAt_of_mem hy
variable (𝕜 f)
/-- For any function `f` from a normed vector space to a Banach space, the set of points `x` such
that `f` is analytic at `x` is open. -/
theorem isOpen_analyticAt : IsOpen { x | AnalyticAt 𝕜 f x } := by
rw [isOpen_iff_mem_nhds]
rintro x ⟨p, r, hr⟩
exact mem_of_superset (EMetric.ball_mem_nhds _ hr.r_pos) fun y hy => hr.analyticAt_of_mem hy
variable {𝕜}
theorem AnalyticAt.eventually_analyticAt {f : E → F} {x : E} (h : AnalyticAt 𝕜 f x) :
∀ᶠ y in 𝓝 x, AnalyticAt 𝕜 f y :=
(isOpen_analyticAt 𝕜 f).mem_nhds h
theorem AnalyticAt.exists_mem_nhds_analyticOn {f : E → F} {x : E} (h : AnalyticAt 𝕜 f x) :
∃ s ∈ 𝓝 x, AnalyticOn 𝕜 f s :=
h.eventually_analyticAt.exists_mem
/-- If we're analytic at a point, we're analytic in a nonempty ball -/
theorem AnalyticAt.exists_ball_analyticOn {f : E → F} {x : E} (h : AnalyticAt 𝕜 f x) :
∃ r : ℝ, 0 < r ∧ AnalyticOn 𝕜 f (Metric.ball x r) :=
Metric.isOpen_iff.mp (isOpen_analyticAt _ _) _ h
end
section
open FormalMultilinearSeries
variable {p : FormalMultilinearSeries 𝕜 𝕜 E} {f : 𝕜 → E} {z₀ : 𝕜}
/-- A function `f : 𝕜 → E` has `p` as power series expansion at a point `z₀` iff it is the sum of
`p` in a neighborhood of `z₀`. This makes some proofs easier by hiding the fact that
`HasFPowerSeriesAt` depends on `p.radius`. -/
theorem hasFPowerSeriesAt_iff :
HasFPowerSeriesAt f p z₀ ↔ ∀ᶠ z in 𝓝 0, HasSum (fun n => z ^ n • p.coeff n) (f (z₀ + z)) := by
refine ⟨fun ⟨r, _, r_pos, h⟩ =>
eventually_of_mem (EMetric.ball_mem_nhds 0 r_pos) fun _ => by simpa using h, ?_⟩
simp only [Metric.eventually_nhds_iff]
rintro ⟨r, r_pos, h⟩
refine ⟨p.radius ⊓ r.toNNReal, by simp, ?_, ?_⟩
· simp only [r_pos.lt, lt_inf_iff, ENNReal.coe_pos, Real.toNNReal_pos, and_true_iff]
obtain ⟨z, z_pos, le_z⟩ := NormedField.exists_norm_lt 𝕜 r_pos.lt
have : (‖z‖₊ : ENNReal) ≤ p.radius := by
simp only [dist_zero_right] at h
apply FormalMultilinearSeries.le_radius_of_tendsto
convert tendsto_norm.comp (h le_z).summable.tendsto_atTop_zero
simp [norm_smul, mul_comm]
refine lt_of_lt_of_le ?_ this
simp only [ENNReal.coe_pos]
exact zero_lt_iff.mpr (nnnorm_ne_zero_iff.mpr (norm_pos_iff.mp z_pos))
· simp only [EMetric.mem_ball, lt_inf_iff, edist_lt_coe, apply_eq_pow_smul_coeff, and_imp,
dist_zero_right] at h ⊢
refine fun {y} _ hyr => h ?_
simpa [nndist_eq_nnnorm, Real.lt_toNNReal_iff_coe_lt] using hyr
theorem hasFPowerSeriesAt_iff' :
HasFPowerSeriesAt f p z₀ ↔ ∀ᶠ z in 𝓝 z₀, HasSum (fun n => (z - z₀) ^ n • p.coeff n) (f z) := by
rw [← map_add_left_nhds_zero, eventually_map, hasFPowerSeriesAt_iff]
simp_rw [add_sub_cancel_left]
end
|
Analysis\Analytic\Composition.lean | /-
Copyright (c) 2020 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel, Johan Commelin
-/
import Mathlib.Analysis.Analytic.Basic
import Mathlib.Combinatorics.Enumerative.Composition
/-!
# Composition of analytic functions
In this file we prove that the composition of analytic functions is analytic.
The argument is the following. Assume `g z = ∑' qₙ (z, ..., z)` and `f y = ∑' pₖ (y, ..., y)`. Then
`g (f y) = ∑' qₙ (∑' pₖ (y, ..., y), ..., ∑' pₖ (y, ..., y))
= ∑' qₙ (p_{i₁} (y, ..., y), ..., p_{iₙ} (y, ..., y))`.
For each `n` and `i₁, ..., iₙ`, define a `i₁ + ... + iₙ` multilinear function mapping
`(y₀, ..., y_{i₁ + ... + iₙ - 1})` to
`qₙ (p_{i₁} (y₀, ..., y_{i₁-1}), p_{i₂} (y_{i₁}, ..., y_{i₁ + i₂ - 1}), ..., p_{iₙ} (....)))`.
Then `g ∘ f` is obtained by summing all these multilinear functions.
To formalize this, we use compositions of an integer `N`, i.e., its decompositions into
a sum `i₁ + ... + iₙ` of positive integers. Given such a composition `c` and two formal
multilinear series `q` and `p`, let `q.compAlongComposition p c` be the above multilinear
function. Then the `N`-th coefficient in the power series expansion of `g ∘ f` is the sum of these
terms over all `c : Composition N`.
To complete the proof, we need to show that this power series has a positive radius of convergence.
This follows from the fact that `Composition N` has cardinality `2^(N-1)` and estimates on
the norm of `qₙ` and `pₖ`, which give summability. We also need to show that it indeed converges to
`g ∘ f`. For this, we note that the composition of partial sums converges to `g ∘ f`, and that it
corresponds to a part of the whole sum, on a subset that increases to the whole space. By
summability of the norms, this implies the overall convergence.
## Main results
* `q.comp p` is the formal composition of the formal multilinear series `q` and `p`.
* `HasFPowerSeriesAt.comp` states that if two functions `g` and `f` admit power series expansions
`q` and `p`, then `g ∘ f` admits a power series expansion given by `q.comp p`.
* `AnalyticAt.comp` states that the composition of analytic functions is analytic.
* `FormalMultilinearSeries.comp_assoc` states that composition is associative on formal
multilinear series.
## Implementation details
The main technical difficulty is to write down things. In particular, we need to define precisely
`q.compAlongComposition p c` and to show that it is indeed a continuous multilinear
function. This requires a whole interface built on the class `Composition`. Once this is set,
the main difficulty is to reorder the sums, writing the composition of the partial sums as a sum
over some subset of `Σ n, Composition n`. We need to check that the reordering is a bijection,
running over difficulties due to the dependent nature of the types under consideration, that are
controlled thanks to the interface for `Composition`.
The associativity of composition on formal multilinear series is a nontrivial result: it does not
follow from the associativity of composition of analytic functions, as there is no uniqueness for
the formal multilinear series representing a function (and also, it holds even when the radius of
convergence of the series is `0`). Instead, we give a direct proof, which amounts to reordering
double sums in a careful way. The change of variables is a canonical (combinatorial) bijection
`Composition.sigmaEquivSigmaPi` between `(Σ (a : Composition n), Composition a.length)` and
`(Σ (c : Composition n), Π (i : Fin c.length), Composition (c.blocksFun i))`, and is described
in more details below in the paragraph on associativity.
-/
noncomputable section
variable {𝕜 : Type*} {E F G H : Type*}
open Filter List
open scoped Topology NNReal ENNReal
section Topological
variable [CommRing 𝕜] [AddCommGroup E] [AddCommGroup F] [AddCommGroup G]
variable [Module 𝕜 E] [Module 𝕜 F] [Module 𝕜 G]
variable [TopologicalSpace E] [TopologicalSpace F] [TopologicalSpace G]
/-! ### Composing formal multilinear series -/
namespace FormalMultilinearSeries
variable [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
variable [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
variable [TopologicalAddGroup G] [ContinuousConstSMul 𝕜 G]
/-!
In this paragraph, we define the composition of formal multilinear series, by summing over all
possible compositions of `n`.
-/
/-- Given a formal multilinear series `p`, a composition `c` of `n` and the index `i` of a
block of `c`, we may define a function on `Fin n → E` by picking the variables in the `i`-th block
of `n`, and applying the corresponding coefficient of `p` to these variables. This function is
called `p.applyComposition c v i` for `v : Fin n → E` and `i : Fin c.length`. -/
def applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (c : Composition n) :
(Fin n → E) → Fin c.length → F := fun v i => p (c.blocksFun i) (v ∘ c.embedding i)
theorem applyComposition_ones (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ) :
p.applyComposition (Composition.ones n) = fun v i =>
p 1 fun _ => v (Fin.castLE (Composition.length_le _) i) := by
funext v i
apply p.congr (Composition.ones_blocksFun _ _)
intro j hjn hj1
obtain rfl : j = 0 := by omega
refine congr_arg v ?_
rw [Fin.ext_iff, Fin.coe_castLE, Composition.ones_embedding, Fin.val_mk]
theorem applyComposition_single (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : 0 < n)
(v : Fin n → E) : p.applyComposition (Composition.single n hn) v = fun _j => p n v := by
ext j
refine p.congr (by simp) fun i hi1 hi2 => ?_
dsimp
congr 1
convert Composition.single_embedding hn ⟨i, hi2⟩ using 1
cases' j with j_val j_property
have : j_val = 0 := le_bot_iff.1 (Nat.lt_succ_iff.1 j_property)
congr!
simp
@[simp]
theorem removeZero_applyComposition (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(c : Composition n) : p.removeZero.applyComposition c = p.applyComposition c := by
ext v i
simp [applyComposition, zero_lt_one.trans_le (c.one_le_blocksFun i), removeZero_of_pos]
/-- Technical lemma stating how `p.applyComposition` commutes with updating variables. This
will be the key point to show that functions constructed from `applyComposition` retain
multilinearity. -/
theorem applyComposition_update (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (c : Composition n)
(j : Fin n) (v : Fin n → E) (z : E) :
p.applyComposition c (Function.update v j z) =
Function.update (p.applyComposition c v) (c.index j)
(p (c.blocksFun (c.index j))
(Function.update (v ∘ c.embedding (c.index j)) (c.invEmbedding j) z)) := by
ext k
by_cases h : k = c.index j
· rw [h]
let r : Fin (c.blocksFun (c.index j)) → Fin n := c.embedding (c.index j)
simp only [Function.update_same]
change p (c.blocksFun (c.index j)) (Function.update v j z ∘ r) = _
let j' := c.invEmbedding j
suffices B : Function.update v j z ∘ r = Function.update (v ∘ r) j' z by rw [B]
suffices C : Function.update v (r j') z ∘ r = Function.update (v ∘ r) j' z by
convert C; exact (c.embedding_comp_inv j).symm
exact Function.update_comp_eq_of_injective _ (c.embedding _).injective _ _
· simp only [h, Function.update_eq_self, Function.update_noteq, Ne, not_false_iff]
let r : Fin (c.blocksFun k) → Fin n := c.embedding k
change p (c.blocksFun k) (Function.update v j z ∘ r) = p (c.blocksFun k) (v ∘ r)
suffices B : Function.update v j z ∘ r = v ∘ r by rw [B]
apply Function.update_comp_eq_of_not_mem_range
rwa [c.mem_range_embedding_iff']
@[simp]
theorem compContinuousLinearMap_applyComposition {n : ℕ} (p : FormalMultilinearSeries 𝕜 F G)
(f : E →L[𝕜] F) (c : Composition n) (v : Fin n → E) :
(p.compContinuousLinearMap f).applyComposition c v = p.applyComposition c (f ∘ v) := by
simp (config := {unfoldPartialApp := true}) [applyComposition]; rfl
end FormalMultilinearSeries
namespace ContinuousMultilinearMap
open FormalMultilinearSeries
variable [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
variable [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
/-- Given a formal multilinear series `p`, a composition `c` of `n` and a continuous multilinear
map `f` in `c.length` variables, one may form a continuous multilinear map in `n` variables by
applying the right coefficient of `p` to each block of the composition, and then applying `f` to
the resulting vector. It is called `f.compAlongComposition p c`. -/
def compAlongComposition {n : ℕ} (p : FormalMultilinearSeries 𝕜 E F) (c : Composition n)
(f : ContinuousMultilinearMap 𝕜 (fun _i : Fin c.length => F) G) :
ContinuousMultilinearMap 𝕜 (fun _i : Fin n => E) G where
toFun v := f (p.applyComposition c v)
map_add' v i x y := by
cases Subsingleton.elim ‹_› (instDecidableEqFin _)
simp only [applyComposition_update, ContinuousMultilinearMap.map_add]
map_smul' v i c x := by
cases Subsingleton.elim ‹_› (instDecidableEqFin _)
simp only [applyComposition_update, ContinuousMultilinearMap.map_smul]
cont :=
f.cont.comp <|
continuous_pi fun i => (coe_continuous _).comp <| continuous_pi fun j => continuous_apply _
@[simp]
theorem compAlongComposition_apply {n : ℕ} (p : FormalMultilinearSeries 𝕜 E F) (c : Composition n)
(f : ContinuousMultilinearMap 𝕜 (fun _i : Fin c.length => F) G) (v : Fin n → E) :
(f.compAlongComposition p c) v = f (p.applyComposition c v) :=
rfl
end ContinuousMultilinearMap
namespace FormalMultilinearSeries
variable [TopologicalAddGroup E] [ContinuousConstSMul 𝕜 E]
variable [TopologicalAddGroup F] [ContinuousConstSMul 𝕜 F]
variable [TopologicalAddGroup G] [ContinuousConstSMul 𝕜 G]
/-- Given two formal multilinear series `q` and `p` and a composition `c` of `n`, one may
form a continuous multilinear map in `n` variables by applying the right coefficient of `p` to each
block of the composition, and then applying `q c.length` to the resulting vector. It is
called `q.compAlongComposition p c`. -/
def compAlongComposition {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : Composition n) :
ContinuousMultilinearMap 𝕜 (fun _i : Fin n => E) G :=
(q c.length).compAlongComposition p c
@[simp]
theorem compAlongComposition_apply {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : Composition n) (v : Fin n → E) :
(q.compAlongComposition p c) v = q c.length (p.applyComposition c v) :=
rfl
/-- Formal composition of two formal multilinear series. The `n`-th coefficient in the composition
is defined to be the sum of `q.compAlongComposition p c` over all compositions of
`n`. In other words, this term (as a multilinear function applied to `v_0, ..., v_{n-1}`) is
`∑'_{k} ∑'_{i₁ + ... + iₖ = n} qₖ (p_{i_1} (...), ..., p_{i_k} (...))`, where one puts all variables
`v_0, ..., v_{n-1}` in increasing order in the dots.
In general, the composition `q ∘ p` only makes sense when the constant coefficient of `p` vanishes.
We give a general formula but which ignores the value of `p 0` instead.
-/
protected def comp (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F) :
FormalMultilinearSeries 𝕜 E G := fun n => ∑ c : Composition n, q.compAlongComposition p c
/-- The `0`-th coefficient of `q.comp p` is `q 0`. Since these maps are multilinear maps in zero
variables, but on different spaces, we can not state this directly, so we state it when applied to
arbitrary vectors (which have to be the zero vector). -/
theorem comp_coeff_zero (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F)
(v : Fin 0 → E) (v' : Fin 0 → F) : (q.comp p) 0 v = q 0 v' := by
let c : Composition 0 := Composition.ones 0
dsimp [FormalMultilinearSeries.comp]
have : {c} = (Finset.univ : Finset (Composition 0)) := by
apply Finset.eq_of_subset_of_card_le <;> simp [Finset.card_univ, composition_card 0]
rw [← this, Finset.sum_singleton, compAlongComposition_apply]
symm; congr! -- Porting note: needed the stronger `congr!`!
@[simp]
theorem comp_coeff_zero' (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F)
(v : Fin 0 → E) : (q.comp p) 0 v = q 0 fun _i => 0 :=
q.comp_coeff_zero p v _
/-- The `0`-th coefficient of `q.comp p` is `q 0`. When `p` goes from `E` to `E`, this can be
expressed as a direct equality -/
theorem comp_coeff_zero'' (q : FormalMultilinearSeries 𝕜 E F) (p : FormalMultilinearSeries 𝕜 E E) :
(q.comp p) 0 = q 0 := by ext v; exact q.comp_coeff_zero p _ _
/-- The first coefficient of a composition of formal multilinear series is the composition of the
first coefficients seen as continuous linear maps. -/
theorem comp_coeff_one (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F)
(v : Fin 1 → E) : (q.comp p) 1 v = q 1 fun _i => p 1 v := by
have : {Composition.ones 1} = (Finset.univ : Finset (Composition 1)) :=
Finset.eq_univ_of_card _ (by simp [composition_card])
simp only [FormalMultilinearSeries.comp, compAlongComposition_apply, ← this,
Finset.sum_singleton]
refine q.congr (by simp) fun i hi1 hi2 => ?_
simp only [applyComposition_ones]
exact p.congr rfl fun j _hj1 hj2 => by congr! -- Porting note: needed the stronger `congr!`
/-- Only `0`-th coefficient of `q.comp p` depends on `q 0`. -/
theorem removeZero_comp_of_pos (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : 0 < n) :
q.removeZero.comp p n = q.comp p n := by
ext v
simp only [FormalMultilinearSeries.comp, compAlongComposition,
ContinuousMultilinearMap.compAlongComposition_apply, ContinuousMultilinearMap.sum_apply]
refine Finset.sum_congr rfl fun c _hc => ?_
rw [removeZero_of_pos _ (c.length_pos_of_pos hn)]
@[simp]
theorem comp_removeZero (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F) :
q.comp p.removeZero = q.comp p := by ext n; simp [FormalMultilinearSeries.comp]
end FormalMultilinearSeries
end Topological
variable [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup H]
[NormedSpace 𝕜 H]
namespace FormalMultilinearSeries
/-- The norm of `f.compAlongComposition p c` is controlled by the product of
the norms of the relevant bits of `f` and `p`. -/
theorem compAlongComposition_bound {n : ℕ} (p : FormalMultilinearSeries 𝕜 E F) (c : Composition n)
(f : ContinuousMultilinearMap 𝕜 (fun _i : Fin c.length => F) G) (v : Fin n → E) :
‖f.compAlongComposition p c v‖ ≤ (‖f‖ * ∏ i, ‖p (c.blocksFun i)‖) * ∏ i : Fin n, ‖v i‖ :=
calc
‖f.compAlongComposition p c v‖ = ‖f (p.applyComposition c v)‖ := rfl
_ ≤ ‖f‖ * ∏ i, ‖p.applyComposition c v i‖ := ContinuousMultilinearMap.le_opNorm _ _
_ ≤ ‖f‖ * ∏ i, ‖p (c.blocksFun i)‖ * ∏ j : Fin (c.blocksFun i), ‖(v ∘ c.embedding i) j‖ := by
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
refine Finset.prod_le_prod (fun i _hi => norm_nonneg _) fun i _hi => ?_
apply ContinuousMultilinearMap.le_opNorm
_ = (‖f‖ * ∏ i, ‖p (c.blocksFun i)‖) *
∏ i, ∏ j : Fin (c.blocksFun i), ‖(v ∘ c.embedding i) j‖ := by
rw [Finset.prod_mul_distrib, mul_assoc]
_ = (‖f‖ * ∏ i, ‖p (c.blocksFun i)‖) * ∏ i : Fin n, ‖v i‖ := by
rw [← c.blocksFinEquiv.prod_comp, ← Finset.univ_sigma_univ, Finset.prod_sigma]
congr
/-- The norm of `q.compAlongComposition p c` is controlled by the product of
the norms of the relevant bits of `q` and `p`. -/
theorem compAlongComposition_norm {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : Composition n) :
‖q.compAlongComposition p c‖ ≤ ‖q c.length‖ * ∏ i, ‖p (c.blocksFun i)‖ :=
ContinuousMultilinearMap.opNorm_le_bound _ (by positivity) (compAlongComposition_bound _ _ _)
theorem compAlongComposition_nnnorm {n : ℕ} (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (c : Composition n) :
‖q.compAlongComposition p c‖₊ ≤ ‖q c.length‖₊ * ∏ i, ‖p (c.blocksFun i)‖₊ := by
rw [← NNReal.coe_le_coe]; push_cast; exact q.compAlongComposition_norm p c
/-!
### The identity formal power series
We will now define the identity power series, and show that it is a neutral element for left and
right composition.
-/
section
variable (𝕜 E)
/-- The identity formal multilinear series, with all coefficients equal to `0` except for `n = 1`
where it is (the continuous multilinear version of) the identity. -/
def id : FormalMultilinearSeries 𝕜 E E
| 0 => 0
| 1 => (continuousMultilinearCurryFin1 𝕜 E E).symm (ContinuousLinearMap.id 𝕜 E)
| _ => 0
/-- The first coefficient of `id 𝕜 E` is the identity. -/
@[simp]
theorem id_apply_one (v : Fin 1 → E) : (FormalMultilinearSeries.id 𝕜 E) 1 v = v 0 :=
rfl
/-- The `n`th coefficient of `id 𝕜 E` is the identity when `n = 1`. We state this in a dependent
way, as it will often appear in this form. -/
theorem id_apply_one' {n : ℕ} (h : n = 1) (v : Fin n → E) :
(id 𝕜 E) n v = v ⟨0, h.symm ▸ zero_lt_one⟩ := by
subst n
apply id_apply_one
/-- For `n ≠ 1`, the `n`-th coefficient of `id 𝕜 E` is zero, by definition. -/
@[simp]
theorem id_apply_ne_one {n : ℕ} (h : n ≠ 1) : (FormalMultilinearSeries.id 𝕜 E) n = 0 := by
cases' n with n
· rfl
· cases n
· contradiction
· rfl
end
@[simp]
theorem comp_id (p : FormalMultilinearSeries 𝕜 E F) : p.comp (id 𝕜 E) = p := by
ext1 n
dsimp [FormalMultilinearSeries.comp]
rw [Finset.sum_eq_single (Composition.ones n)]
· show compAlongComposition p (id 𝕜 E) (Composition.ones n) = p n
ext v
rw [compAlongComposition_apply]
apply p.congr (Composition.ones_length n)
intros
rw [applyComposition_ones]
refine congr_arg v ?_
rw [Fin.ext_iff, Fin.coe_castLE, Fin.val_mk]
· show
∀ b : Composition n,
b ∈ Finset.univ → b ≠ Composition.ones n → compAlongComposition p (id 𝕜 E) b = 0
intro b _ hb
obtain ⟨k, hk, lt_k⟩ : ∃ (k : ℕ), k ∈ Composition.blocks b ∧ 1 < k :=
Composition.ne_ones_iff.1 hb
obtain ⟨i, hi⟩ : ∃ (i : Fin b.blocks.length), b.blocks.get i = k :=
List.get_of_mem hk
let j : Fin b.length := ⟨i.val, b.blocks_length ▸ i.prop⟩
have A : 1 < b.blocksFun j := by convert lt_k
ext v
rw [compAlongComposition_apply, ContinuousMultilinearMap.zero_apply]
apply ContinuousMultilinearMap.map_coord_zero _ j
dsimp [applyComposition]
rw [id_apply_ne_one _ _ (ne_of_gt A)]
rfl
· simp
@[simp]
theorem id_comp (p : FormalMultilinearSeries 𝕜 E F) (h : p 0 = 0) : (id 𝕜 F).comp p = p := by
ext1 n
by_cases hn : n = 0
· rw [hn, h]
ext v
rw [comp_coeff_zero', id_apply_ne_one _ _ zero_ne_one]
rfl
· dsimp [FormalMultilinearSeries.comp]
have n_pos : 0 < n := bot_lt_iff_ne_bot.mpr hn
rw [Finset.sum_eq_single (Composition.single n n_pos)]
· show compAlongComposition (id 𝕜 F) p (Composition.single n n_pos) = p n
ext v
rw [compAlongComposition_apply, id_apply_one' _ _ (Composition.single_length n_pos)]
dsimp [applyComposition]
refine p.congr rfl fun i him hin => congr_arg v <| ?_
ext; simp
· show
∀ b : Composition n,
b ∈ Finset.univ → b ≠ Composition.single n n_pos → compAlongComposition (id 𝕜 F) p b = 0
intro b _ hb
have A : b.length ≠ 1 := by simpa [Composition.eq_single_iff_length] using hb
ext v
rw [compAlongComposition_apply, id_apply_ne_one _ _ A]
rfl
· simp
/-! ### Summability properties of the composition of formal power series-/
section
/-- If two formal multilinear series have positive radius of convergence, then the terms appearing
in the definition of their composition are also summable (when multiplied by a suitable positive
geometric term). -/
theorem comp_summable_nnreal (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F)
(hq : 0 < q.radius) (hp : 0 < p.radius) :
∃ r > (0 : ℝ≥0),
Summable fun i : Σ n, Composition n => ‖q.compAlongComposition p i.2‖₊ * r ^ i.1 := by
/- This follows from the fact that the growth rate of `‖qₙ‖` and `‖pₙ‖` is at most geometric,
giving a geometric bound on each `‖q.compAlongComposition p op‖`, together with the
fact that there are `2^(n-1)` compositions of `n`, giving at most a geometric loss. -/
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 (lt_min zero_lt_one hq) with ⟨rq, rq_pos, hrq⟩
rcases ENNReal.lt_iff_exists_nnreal_btwn.1 (lt_min zero_lt_one hp) with ⟨rp, rp_pos, hrp⟩
simp only [lt_min_iff, ENNReal.coe_lt_one_iff, ENNReal.coe_pos] at hrp hrq rp_pos rq_pos
obtain ⟨Cq, _hCq0, hCq⟩ : ∃ Cq > 0, ∀ n, ‖q n‖₊ * rq ^ n ≤ Cq :=
q.nnnorm_mul_pow_le_of_lt_radius hrq.2
obtain ⟨Cp, hCp1, hCp⟩ : ∃ Cp ≥ 1, ∀ n, ‖p n‖₊ * rp ^ n ≤ Cp := by
rcases p.nnnorm_mul_pow_le_of_lt_radius hrp.2 with ⟨Cp, -, hCp⟩
exact ⟨max Cp 1, le_max_right _ _, fun n => (hCp n).trans (le_max_left _ _)⟩
let r0 : ℝ≥0 := (4 * Cp)⁻¹
have r0_pos : 0 < r0 := inv_pos.2 (mul_pos zero_lt_four (zero_lt_one.trans_le hCp1))
set r : ℝ≥0 := rp * rq * r0
have r_pos : 0 < r := mul_pos (mul_pos rp_pos rq_pos) r0_pos
have I :
∀ i : Σ n : ℕ, Composition n, ‖q.compAlongComposition p i.2‖₊ * r ^ i.1 ≤ Cq / 4 ^ i.1 := by
rintro ⟨n, c⟩
have A := calc
‖q c.length‖₊ * rq ^ n ≤ ‖q c.length‖₊ * rq ^ c.length :=
mul_le_mul' le_rfl (pow_le_pow_of_le_one rq.2 hrq.1.le c.length_le)
_ ≤ Cq := hCq _
have B := calc
(∏ i, ‖p (c.blocksFun i)‖₊) * rp ^ n = ∏ i, ‖p (c.blocksFun i)‖₊ * rp ^ c.blocksFun i := by
simp only [Finset.prod_mul_distrib, Finset.prod_pow_eq_pow_sum, c.sum_blocksFun]
_ ≤ ∏ _i : Fin c.length, Cp := Finset.prod_le_prod' fun i _ => hCp _
_ = Cp ^ c.length := by simp
_ ≤ Cp ^ n := pow_le_pow_right hCp1 c.length_le
calc
‖q.compAlongComposition p c‖₊ * r ^ n ≤
(‖q c.length‖₊ * ∏ i, ‖p (c.blocksFun i)‖₊) * r ^ n :=
mul_le_mul' (q.compAlongComposition_nnnorm p c) le_rfl
_ = ‖q c.length‖₊ * rq ^ n * ((∏ i, ‖p (c.blocksFun i)‖₊) * rp ^ n) * r0 ^ n := by
ring
_ ≤ Cq * Cp ^ n * r0 ^ n := mul_le_mul' (mul_le_mul' A B) le_rfl
_ = Cq / 4 ^ n := by
simp only [r0]
field_simp [mul_pow, (zero_lt_one.trans_le hCp1).ne']
ring
refine ⟨r, r_pos, NNReal.summable_of_le I ?_⟩
simp_rw [div_eq_mul_inv]
refine Summable.mul_left _ ?_
have : ∀ n : ℕ, HasSum (fun c : Composition n => (4 ^ n : ℝ≥0)⁻¹) (2 ^ (n - 1) / 4 ^ n) := by
intro n
convert hasSum_fintype fun c : Composition n => (4 ^ n : ℝ≥0)⁻¹
simp [Finset.card_univ, composition_card, div_eq_mul_inv]
refine NNReal.summable_sigma.2 ⟨fun n => (this n).summable, (NNReal.summable_nat_add_iff 1).1 ?_⟩
convert (NNReal.summable_geometric (NNReal.div_lt_one_of_lt one_lt_two)).mul_left (1 / 4) using 1
ext1 n
rw [(this _).tsum_eq, add_tsub_cancel_right]
field_simp [← mul_assoc, pow_succ, mul_pow, show (4 : ℝ≥0) = 2 * 2 by norm_num,
mul_right_comm]
end
/-- Bounding below the radius of the composition of two formal multilinear series assuming
summability over all compositions. -/
theorem le_comp_radius_of_summable (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) (r : ℝ≥0)
(hr : Summable fun i : Σ n, Composition n => ‖q.compAlongComposition p i.2‖₊ * r ^ i.1) :
(r : ℝ≥0∞) ≤ (q.comp p).radius := by
refine
le_radius_of_bound_nnreal _
(∑' i : Σ n, Composition n, ‖compAlongComposition q p i.snd‖₊ * r ^ i.fst) fun n => ?_
calc
‖FormalMultilinearSeries.comp q p n‖₊ * r ^ n ≤
∑' c : Composition n, ‖compAlongComposition q p c‖₊ * r ^ n := by
rw [tsum_fintype, ← Finset.sum_mul]
exact mul_le_mul' (nnnorm_sum_le _ _) le_rfl
_ ≤ ∑' i : Σ n : ℕ, Composition n, ‖compAlongComposition q p i.snd‖₊ * r ^ i.fst :=
NNReal.tsum_comp_le_tsum_of_inj hr sigma_mk_injective
/-!
### Composing analytic functions
Now, we will prove that the composition of the partial sums of `q` and `p` up to order `N` is
given by a sum over some large subset of `Σ n, Composition n` of `q.compAlongComposition p`, to
deduce that the series for `q.comp p` indeed converges to `g ∘ f` when `q` is a power series for
`g` and `p` is a power series for `f`.
This proof is a big reindexing argument of a sum. Since it is a bit involved, we define first
the source of the change of variables (`compPartialSumSource`), its target
(`compPartialSumTarget`) and the change of variables itself (`compChangeOfVariables`) before
giving the main statement in `comp_partialSum`. -/
/-- Source set in the change of variables to compute the composition of partial sums of formal
power series.
See also `comp_partialSum`. -/
def compPartialSumSource (m M N : ℕ) : Finset (Σ n, Fin n → ℕ) :=
Finset.sigma (Finset.Ico m M) (fun n : ℕ => Fintype.piFinset fun _i : Fin n => Finset.Ico 1 N : _)
@[simp]
theorem mem_compPartialSumSource_iff (m M N : ℕ) (i : Σ n, Fin n → ℕ) :
i ∈ compPartialSumSource m M N ↔
(m ≤ i.1 ∧ i.1 < M) ∧ ∀ a : Fin i.1, 1 ≤ i.2 a ∧ i.2 a < N := by
simp only [compPartialSumSource, Finset.mem_Ico, Fintype.mem_piFinset, Finset.mem_sigma,
iff_self_iff]
/-- Change of variables appearing to compute the composition of partial sums of formal
power series -/
def compChangeOfVariables (m M N : ℕ) (i : Σ n, Fin n → ℕ) (hi : i ∈ compPartialSumSource m M N) :
Σ n, Composition n := by
rcases i with ⟨n, f⟩
rw [mem_compPartialSumSource_iff] at hi
refine ⟨∑ j, f j, ofFn fun a => f a, fun hi' => ?_, by simp [sum_ofFn]⟩
rename_i i
obtain ⟨j, rfl⟩ : ∃ j : Fin n, f j = i := by rwa [mem_ofFn, Set.mem_range] at hi'
exact (hi.2 j).1
@[simp]
theorem compChangeOfVariables_length (m M N : ℕ) {i : Σ n, Fin n → ℕ}
(hi : i ∈ compPartialSumSource m M N) :
Composition.length (compChangeOfVariables m M N i hi).2 = i.1 := by
rcases i with ⟨k, blocks_fun⟩
dsimp [compChangeOfVariables]
simp only [Composition.length, map_ofFn, length_ofFn]
theorem compChangeOfVariables_blocksFun (m M N : ℕ) {i : Σ n, Fin n → ℕ}
(hi : i ∈ compPartialSumSource m M N) (j : Fin i.1) :
(compChangeOfVariables m M N i hi).2.blocksFun
⟨j, (compChangeOfVariables_length m M N hi).symm ▸ j.2⟩ =
i.2 j := by
rcases i with ⟨n, f⟩
dsimp [Composition.blocksFun, Composition.blocks, compChangeOfVariables]
simp only [map_ofFn, List.getElem_ofFn, Function.comp_apply]
/-- Target set in the change of variables to compute the composition of partial sums of formal
power series, here given a a set. -/
def compPartialSumTargetSet (m M N : ℕ) : Set (Σ n, Composition n) :=
{i | m ≤ i.2.length ∧ i.2.length < M ∧ ∀ j : Fin i.2.length, i.2.blocksFun j < N}
theorem compPartialSumTargetSet_image_compPartialSumSource (m M N : ℕ)
(i : Σ n, Composition n) (hi : i ∈ compPartialSumTargetSet m M N) :
∃ (j : _) (hj : j ∈ compPartialSumSource m M N), compChangeOfVariables m M N j hj = i := by
rcases i with ⟨n, c⟩
refine ⟨⟨c.length, c.blocksFun⟩, ?_, ?_⟩
· simp only [compPartialSumTargetSet, Set.mem_setOf_eq] at hi
simp only [mem_compPartialSumSource_iff, hi.left, hi.right, true_and_iff, and_true_iff]
exact fun a => c.one_le_blocks' _
· dsimp [compChangeOfVariables]
rw [Composition.sigma_eq_iff_blocks_eq]
simp only [Composition.blocksFun, Composition.blocks, Subtype.coe_eta]
conv_rhs => rw [← List.ofFn_get c.blocks]
/-- Target set in the change of variables to compute the composition of partial sums of formal
power series, here given a a finset.
See also `comp_partialSum`. -/
def compPartialSumTarget (m M N : ℕ) : Finset (Σ n, Composition n) :=
Set.Finite.toFinset <|
((Finset.finite_toSet _).dependent_image _).subset <|
compPartialSumTargetSet_image_compPartialSumSource m M N
@[simp]
theorem mem_compPartialSumTarget_iff {m M N : ℕ} {a : Σ n, Composition n} :
a ∈ compPartialSumTarget m M N ↔
m ≤ a.2.length ∧ a.2.length < M ∧ ∀ j : Fin a.2.length, a.2.blocksFun j < N := by
simp [compPartialSumTarget, compPartialSumTargetSet]
/-- `compChangeOfVariables m M N` is a bijection between `compPartialSumSource m M N`
and `compPartialSumTarget m M N`, yielding equal sums for functions that correspond to each
other under the bijection. As `compChangeOfVariables m M N` is a dependent function, stating
that it is a bijection is not directly possible, but the consequence on sums can be stated
more easily. -/
theorem compChangeOfVariables_sum {α : Type*} [AddCommMonoid α] (m M N : ℕ)
(f : (Σ n : ℕ, Fin n → ℕ) → α) (g : (Σ n, Composition n) → α)
(h : ∀ (e) (he : e ∈ compPartialSumSource m M N), f e = g (compChangeOfVariables m M N e he)) :
∑ e ∈ compPartialSumSource m M N, f e = ∑ e ∈ compPartialSumTarget m M N, g e := by
apply Finset.sum_bij (compChangeOfVariables m M N)
-- We should show that the correspondence we have set up is indeed a bijection
-- between the index sets of the two sums.
-- 1 - show that the image belongs to `compPartialSumTarget m N N`
· rintro ⟨k, blocks_fun⟩ H
rw [mem_compPartialSumSource_iff] at H
-- Porting note: added
simp only at H
simp only [mem_compPartialSumTarget_iff, Composition.length, Composition.blocks, H.left,
map_ofFn, length_ofFn, true_and_iff, compChangeOfVariables]
intro j
simp only [Composition.blocksFun, (H.right _).right, List.get_ofFn]
-- 2 - show that the map is injective
· rintro ⟨k, blocks_fun⟩ H ⟨k', blocks_fun'⟩ H' heq
obtain rfl : k = k' := by
have := (compChangeOfVariables_length m M N H).symm
rwa [heq, compChangeOfVariables_length] at this
congr
funext i
calc
blocks_fun i = (compChangeOfVariables m M N _ H).2.blocksFun _ :=
(compChangeOfVariables_blocksFun m M N H i).symm
_ = (compChangeOfVariables m M N _ H').2.blocksFun _ := by
apply Composition.blocksFun_congr <;>
first | rw [heq] | rfl
_ = blocks_fun' i := compChangeOfVariables_blocksFun m M N H' i
-- 3 - show that the map is surjective
· intro i hi
apply compPartialSumTargetSet_image_compPartialSumSource m M N i
simpa [compPartialSumTarget] using hi
-- 4 - show that the composition gives the `compAlongComposition` application
· rintro ⟨k, blocks_fun⟩ H
rw [h]
/-- The auxiliary set corresponding to the composition of partial sums asymptotically contains
all possible compositions. -/
theorem compPartialSumTarget_tendsto_atTop :
Tendsto (fun N => compPartialSumTarget 0 N N) atTop atTop := by
apply Monotone.tendsto_atTop_finset
· intro m n hmn a ha
have : ∀ i, i < m → i < n := fun i hi => lt_of_lt_of_le hi hmn
aesop
· rintro ⟨n, c⟩
simp only [mem_compPartialSumTarget_iff]
obtain ⟨n, hn⟩ : BddAbove ((Finset.univ.image fun i : Fin c.length => c.blocksFun i) : Set ℕ) :=
Finset.bddAbove _
refine
⟨max n c.length + 1, bot_le, lt_of_le_of_lt (le_max_right n c.length) (lt_add_one _), fun j =>
lt_of_le_of_lt (le_trans ?_ (le_max_left _ _)) (lt_add_one _)⟩
apply hn
simp only [Finset.mem_image_of_mem, Finset.mem_coe, Finset.mem_univ]
/-- Composing the partial sums of two multilinear series coincides with the sum over all
compositions in `compPartialSumTarget 0 N N`. This is precisely the motivation for the
definition of `compPartialSumTarget`. -/
theorem comp_partialSum (q : FormalMultilinearSeries 𝕜 F G) (p : FormalMultilinearSeries 𝕜 E F)
(N : ℕ) (z : E) :
q.partialSum N (∑ i ∈ Finset.Ico 1 N, p i fun _j => z) =
∑ i ∈ compPartialSumTarget 0 N N, q.compAlongComposition p i.2 fun _j => z := by
-- we expand the composition, using the multilinearity of `q` to expand along each coordinate.
suffices H :
(∑ n ∈ Finset.range N,
∑ r ∈ Fintype.piFinset fun i : Fin n => Finset.Ico 1 N,
q n fun i : Fin n => p (r i) fun _j => z) =
∑ i ∈ compPartialSumTarget 0 N N, q.compAlongComposition p i.2 fun _j => z by
simpa only [FormalMultilinearSeries.partialSum, ContinuousMultilinearMap.map_sum_finset] using H
-- rewrite the first sum as a big sum over a sigma type, in the finset
-- `compPartialSumTarget 0 N N`
rw [Finset.range_eq_Ico, Finset.sum_sigma']
-- use `compChangeOfVariables_sum`, saying that this change of variables respects sums
apply compChangeOfVariables_sum 0 N N
rintro ⟨k, blocks_fun⟩ H
apply congr _ (compChangeOfVariables_length 0 N N H).symm
intros
rw [← compChangeOfVariables_blocksFun 0 N N H]
rfl
end FormalMultilinearSeries
open FormalMultilinearSeries
/-- If two functions `g` and `f` have power series `q` and `p` respectively at `f x` and `x`, then
`g ∘ f` admits the power series `q.comp p` at `x`. -/
theorem HasFPowerSeriesAt.comp {g : F → G} {f : E → F} {q : FormalMultilinearSeries 𝕜 F G}
{p : FormalMultilinearSeries 𝕜 E F} {x : E} (hg : HasFPowerSeriesAt g q (f x))
(hf : HasFPowerSeriesAt f p x) : HasFPowerSeriesAt (g ∘ f) (q.comp p) x := by
/- Consider `rf` and `rg` such that `f` and `g` have power series expansion on the disks
of radius `rf` and `rg`. -/
rcases hg with ⟨rg, Hg⟩
rcases hf with ⟨rf, Hf⟩
-- The terms defining `q.comp p` are geometrically summable in a disk of some radius `r`.
rcases q.comp_summable_nnreal p Hg.radius_pos Hf.radius_pos with ⟨r, r_pos : 0 < r, hr⟩
/- We will consider `y` which is smaller than `r` and `rf`, and also small enough that
`f (x + y)` is close enough to `f x` to be in the disk where `g` is well behaved. Let
`min (r, rf, δ)` be this new radius. -/
obtain ⟨δ, δpos, hδ⟩ :
∃ δ : ℝ≥0∞, 0 < δ ∧ ∀ {z : E}, z ∈ EMetric.ball x δ → f z ∈ EMetric.ball (f x) rg := by
have : EMetric.ball (f x) rg ∈ 𝓝 (f x) := EMetric.ball_mem_nhds _ Hg.r_pos
rcases EMetric.mem_nhds_iff.1 (Hf.analyticAt.continuousAt this) with ⟨δ, δpos, Hδ⟩
exact ⟨δ, δpos, fun hz => Hδ hz⟩
let rf' := min rf δ
have min_pos : 0 < min rf' r := by
simp only [rf', r_pos, Hf.r_pos, δpos, lt_min_iff, ENNReal.coe_pos, and_self_iff]
/- We will show that `g ∘ f` admits the power series `q.comp p` in the disk of
radius `min (r, rf', δ)`. -/
refine ⟨min rf' r, ?_⟩
refine
⟨le_trans (min_le_right rf' r) (FormalMultilinearSeries.le_comp_radius_of_summable q p r hr),
min_pos, @fun y hy => ?_⟩
/- Let `y` satisfy `‖y‖ < min (r, rf', δ)`. We want to show that `g (f (x + y))` is the sum of
`q.comp p` applied to `y`. -/
-- First, check that `y` is small enough so that estimates for `f` and `g` apply.
have y_mem : y ∈ EMetric.ball (0 : E) rf :=
(EMetric.ball_subset_ball (le_trans (min_le_left _ _) (min_le_left _ _))) hy
have fy_mem : f (x + y) ∈ EMetric.ball (f x) rg := by
apply hδ
have : y ∈ EMetric.ball (0 : E) δ :=
(EMetric.ball_subset_ball (le_trans (min_le_left _ _) (min_le_right _ _))) hy
simpa [edist_eq_coe_nnnorm_sub, edist_eq_coe_nnnorm]
/- Now the proof starts. To show that the sum of `q.comp p` at `y` is `g (f (x + y))`,
we will write `q.comp p` applied to `y` as a big sum over all compositions.
Since the sum is summable, to get its convergence it suffices to get
the convergence along some increasing sequence of sets.
We will use the sequence of sets `compPartialSumTarget 0 n n`,
along which the sum is exactly the composition of the partial sums of `q` and `p`, by design.
To show that it converges to `g (f (x + y))`, pointwise convergence would not be enough,
but we have uniform convergence to save the day. -/
-- First step: the partial sum of `p` converges to `f (x + y)`.
have A : Tendsto (fun n => ∑ a ∈ Finset.Ico 1 n, p a fun _b => y)
atTop (𝓝 (f (x + y) - f x)) := by
have L :
∀ᶠ n in atTop, (∑ a ∈ Finset.range n, p a fun _b => y) - f x
= ∑ a ∈ Finset.Ico 1 n, p a fun _b => y := by
rw [eventually_atTop]
refine ⟨1, fun n hn => ?_⟩
symm
rw [eq_sub_iff_add_eq', Finset.range_eq_Ico, ← Hf.coeff_zero fun _i => y,
Finset.sum_eq_sum_Ico_succ_bot hn]
have :
Tendsto (fun n => (∑ a ∈ Finset.range n, p a fun _b => y) - f x) atTop
(𝓝 (f (x + y) - f x)) :=
(Hf.hasSum y_mem).tendsto_sum_nat.sub tendsto_const_nhds
exact Tendsto.congr' L this
-- Second step: the composition of the partial sums of `q` and `p` converges to `g (f (x + y))`.
have B :
Tendsto (fun n => q.partialSum n (∑ a ∈ Finset.Ico 1 n, p a fun _b => y)) atTop
(𝓝 (g (f (x + y)))) := by
-- we use the fact that the partial sums of `q` converge locally uniformly to `g`, and that
-- composition passes to the limit under locally uniform convergence.
have B₁ : ContinuousAt (fun z : F => g (f x + z)) (f (x + y) - f x) := by
refine ContinuousAt.comp ?_ (continuous_const.add continuous_id).continuousAt
simp only [add_sub_cancel, _root_.id]
exact Hg.continuousOn.continuousAt (IsOpen.mem_nhds EMetric.isOpen_ball fy_mem)
have B₂ : f (x + y) - f x ∈ EMetric.ball (0 : F) rg := by
simpa [edist_eq_coe_nnnorm, edist_eq_coe_nnnorm_sub] using fy_mem
rw [← EMetric.isOpen_ball.nhdsWithin_eq B₂] at A
convert Hg.tendstoLocallyUniformlyOn.tendsto_comp B₁.continuousWithinAt B₂ A
simp only [add_sub_cancel]
-- Third step: the sum over all compositions in `compPartialSumTarget 0 n n` converges to
-- `g (f (x + y))`. As this sum is exactly the composition of the partial sum, this is a direct
-- consequence of the second step
have C :
Tendsto
(fun n => ∑ i ∈ compPartialSumTarget 0 n n, q.compAlongComposition p i.2 fun _j => y)
atTop (𝓝 (g (f (x + y)))) := by
simpa [comp_partialSum] using B
-- Fourth step: the sum over all compositions is `g (f (x + y))`. This follows from the
-- convergence along a subsequence proved in the third step, and the fact that the sum is Cauchy
-- thanks to the summability properties.
have D :
HasSum (fun i : Σ n, Composition n => q.compAlongComposition p i.2 fun _j => y)
(g (f (x + y))) :=
haveI cau :
CauchySeq fun s : Finset (Σ n, Composition n) =>
∑ i ∈ s, q.compAlongComposition p i.2 fun _j => y := by
apply cauchySeq_finset_of_norm_bounded _ (NNReal.summable_coe.2 hr) _
simp only [coe_nnnorm, NNReal.coe_mul, NNReal.coe_pow]
rintro ⟨n, c⟩
calc
‖(compAlongComposition q p c) fun _j : Fin n => y‖ ≤
‖compAlongComposition q p c‖ * ∏ _j : Fin n, ‖y‖ := by
apply ContinuousMultilinearMap.le_opNorm
_ ≤ ‖compAlongComposition q p c‖ * (r : ℝ) ^ n := by
apply mul_le_mul_of_nonneg_left _ (norm_nonneg _)
rw [Finset.prod_const, Finset.card_fin]
apply pow_le_pow_left (norm_nonneg _)
rw [EMetric.mem_ball, edist_eq_coe_nnnorm] at hy
have := le_trans (le_of_lt hy) (min_le_right _ _)
rwa [ENNReal.coe_le_coe, ← NNReal.coe_le_coe, coe_nnnorm] at this
tendsto_nhds_of_cauchySeq_of_subseq cau compPartialSumTarget_tendsto_atTop C
-- Fifth step: the sum over `n` of `q.comp p n` can be expressed as a particular resummation of
-- the sum over all compositions, by grouping together the compositions of the same
-- integer `n`. The convergence of the whole sum therefore implies the converence of the sum
-- of `q.comp p n`
have E : HasSum (fun n => (q.comp p) n fun _j => y) (g (f (x + y))) := by
apply D.sigma
intro n
dsimp [FormalMultilinearSeries.comp]
convert hasSum_fintype (α := G) (β := Composition n) _
simp only [ContinuousMultilinearMap.sum_apply]
rfl
rw [Function.comp_apply]
exact E
/-- If two functions `g` and `f` are analytic respectively at `f x` and `x`, then `g ∘ f` is
analytic at `x`. -/
theorem AnalyticAt.comp {g : F → G} {f : E → F} {x : E} (hg : AnalyticAt 𝕜 g (f x))
(hf : AnalyticAt 𝕜 f x) : AnalyticAt 𝕜 (g ∘ f) x :=
let ⟨_q, hq⟩ := hg
let ⟨_p, hp⟩ := hf
(hq.comp hp).analyticAt
/-- Version of `AnalyticAt.comp` where point equality is a separate hypothesis. -/
theorem AnalyticAt.comp_of_eq {g : F → G} {f : E → F} {y : F} {x : E} (hg : AnalyticAt 𝕜 g y)
(hf : AnalyticAt 𝕜 f x) (hy : f x = y) : AnalyticAt 𝕜 (g ∘ f) x := by
rw [← hy] at hg
exact hg.comp hf
/-- If two functions `g` and `f` are analytic respectively on `s.image f` and `s`, then `g ∘ f` is
analytic on `s`. -/
theorem AnalyticOn.comp' {s : Set E} {g : F → G} {f : E → F} (hg : AnalyticOn 𝕜 g (s.image f))
(hf : AnalyticOn 𝕜 f s) : AnalyticOn 𝕜 (g ∘ f) s :=
fun z hz => (hg (f z) (Set.mem_image_of_mem f hz)).comp (hf z hz)
theorem AnalyticOn.comp {s : Set E} {t : Set F} {g : F → G} {f : E → F} (hg : AnalyticOn 𝕜 g t)
(hf : AnalyticOn 𝕜 f s) (st : Set.MapsTo f s t) : AnalyticOn 𝕜 (g ∘ f) s :=
comp' (mono hg (Set.mapsTo'.mp st)) hf
/-!
### Associativity of the composition of formal multilinear series
In this paragraph, we prove the associativity of the composition of formal power series.
By definition,
```
(r.comp q).comp p n v
= ∑_{i₁ + ... + iₖ = n} (r.comp q)ₖ (p_{i₁} (v₀, ..., v_{i₁ -1}), p_{i₂} (...), ..., p_{iₖ}(...))
= ∑_{a : Composition n} (r.comp q) a.length (applyComposition p a v)
```
decomposing `r.comp q` in the same way, we get
```
(r.comp q).comp p n v
= ∑_{a : Composition n} ∑_{b : Composition a.length}
r b.length (applyComposition q b (applyComposition p a v))
```
On the other hand,
```
r.comp (q.comp p) n v = ∑_{c : Composition n} r c.length (applyComposition (q.comp p) c v)
```
Here, `applyComposition (q.comp p) c v` is a vector of length `c.length`, whose `i`-th term is
given by `(q.comp p) (c.blocksFun i) (v_l, v_{l+1}, ..., v_{m-1})` where `{l, ..., m-1}` is the
`i`-th block in the composition `c`, of length `c.blocksFun i` by definition. To compute this term,
we expand it as `∑_{dᵢ : Composition (c.blocksFun i)} q dᵢ.length (applyComposition p dᵢ v')`,
where `v' = (v_l, v_{l+1}, ..., v_{m-1})`. Therefore, we get
```
r.comp (q.comp p) n v =
∑_{c : Composition n} ∑_{d₀ : Composition (c.blocksFun 0),
..., d_{c.length - 1} : Composition (c.blocksFun (c.length - 1))}
r c.length (λ i, q dᵢ.length (applyComposition p dᵢ v'ᵢ))
```
To show that these terms coincide, we need to explain how to reindex the sums to put them in
bijection (and then the terms we are summing will correspond to each other). Suppose we have a
composition `a` of `n`, and a composition `b` of `a.length`. Then `b` indicates how to group
together some blocks of `a`, giving altogether `b.length` blocks of blocks. These blocks of blocks
can be called `d₀, ..., d_{a.length - 1}`, and one obtains a composition `c` of `n` by saying that
each `dᵢ` is one single block. Conversely, if one starts from `c` and the `dᵢ`s, one can concatenate
the `dᵢ`s to obtain a composition `a` of `n`, and register the lengths of the `dᵢ`s in a composition
`b` of `a.length`.
An example might be enlightening. Suppose `a = [2, 2, 3, 4, 2]`. It is a composition of
length 5 of 13. The content of the blocks may be represented as `0011222333344`.
Now take `b = [2, 3]` as a composition of `a.length = 5`. It says that the first 2 blocks of `a`
should be merged, and the last 3 blocks of `a` should be merged, giving a new composition of `13`
made of two blocks of length `4` and `9`, i.e., `c = [4, 9]`. But one can also remember that
the new first block was initially made of two blocks of size `2`, so `d₀ = [2, 2]`, and the new
second block was initially made of three blocks of size `3`, `4` and `2`, so `d₁ = [3, 4, 2]`.
This equivalence is called `Composition.sigmaEquivSigmaPi n` below.
We start with preliminary results on compositions, of a very specialized nature, then define the
equivalence `Composition.sigmaEquivSigmaPi n`, and we deduce finally the associativity of
composition of formal multilinear series in `FormalMultilinearSeries.comp_assoc`.
-/
namespace Composition
variable {n : ℕ}
/-- Rewriting equality in the dependent type `Σ (a : Composition n), Composition a.length)` in
non-dependent terms with lists, requiring that the blocks coincide. -/
theorem sigma_composition_eq_iff (i j : Σ a : Composition n, Composition a.length) :
i = j ↔ i.1.blocks = j.1.blocks ∧ i.2.blocks = j.2.blocks := by
refine ⟨by rintro rfl; exact ⟨rfl, rfl⟩, ?_⟩
rcases i with ⟨a, b⟩
rcases j with ⟨a', b'⟩
rintro ⟨h, h'⟩
have H : a = a' := by ext1; exact h
induction H; congr; ext1; exact h'
/-- Rewriting equality in the dependent type
`Σ (c : Composition n), Π (i : Fin c.length), Composition (c.blocksFun i)` in
non-dependent terms with lists, requiring that the lists of blocks coincide. -/
theorem sigma_pi_composition_eq_iff
(u v : Σ c : Composition n, ∀ i : Fin c.length, Composition (c.blocksFun i)) :
u = v ↔ (ofFn fun i => (u.2 i).blocks) = ofFn fun i => (v.2 i).blocks := by
refine ⟨fun H => by rw [H], fun H => ?_⟩
rcases u with ⟨a, b⟩
rcases v with ⟨a', b'⟩
dsimp at H
have h : a = a' := by
ext1
have :
map List.sum (ofFn fun i : Fin (Composition.length a) => (b i).blocks) =
map List.sum (ofFn fun i : Fin (Composition.length a') => (b' i).blocks) := by
rw [H]
simp only [map_ofFn] at this
change
(ofFn fun i : Fin (Composition.length a) => (b i).blocks.sum) =
ofFn fun i : Fin (Composition.length a') => (b' i).blocks.sum at this
simpa [Composition.blocks_sum, Composition.ofFn_blocksFun] using this
induction h
ext1
· rfl
· simp only [heq_eq_eq, ofFn_inj] at H ⊢
ext1 i
ext1
exact congrFun H i
/-- When `a` is a composition of `n` and `b` is a composition of `a.length`, `a.gather b` is the
composition of `n` obtained by gathering all the blocks of `a` corresponding to a block of `b`.
For instance, if `a = [6, 5, 3, 5, 2]` and `b = [2, 3]`, one should gather together
the first two blocks of `a` and its last three blocks, giving `a.gather b = [11, 10]`. -/
def gather (a : Composition n) (b : Composition a.length) : Composition n where
blocks := (a.blocks.splitWrtComposition b).map sum
blocks_pos := by
rw [forall_mem_map]
intro j hj
suffices H : ∀ i ∈ j, 1 ≤ i by calc
0 < j.length := length_pos_of_mem_splitWrtComposition hj
_ ≤ j.sum := length_le_sum_of_one_le _ H
intro i hi
apply a.one_le_blocks
rw [← a.blocks.join_splitWrtComposition b]
exact mem_join_of_mem hj hi
blocks_sum := by rw [← sum_join, join_splitWrtComposition, a.blocks_sum]
theorem length_gather (a : Composition n) (b : Composition a.length) :
length (a.gather b) = b.length :=
show (map List.sum (a.blocks.splitWrtComposition b)).length = b.blocks.length by
rw [length_map, length_splitWrtComposition]
/-- An auxiliary function used in the definition of `sigmaEquivSigmaPi` below, associating to
two compositions `a` of `n` and `b` of `a.length`, and an index `i` bounded by the length of
`a.gather b`, the subcomposition of `a` made of those blocks belonging to the `i`-th block of
`a.gather b`. -/
def sigmaCompositionAux (a : Composition n) (b : Composition a.length)
(i : Fin (a.gather b).length) : Composition ((a.gather b).blocksFun i) where
blocks :=
(a.blocks.splitWrtComposition b)[i.val]'(by
rw [length_splitWrtComposition, ← length_gather]; exact i.2)
blocks_pos {i} hi :=
a.blocks_pos
(by
rw [← a.blocks.join_splitWrtComposition b]
exact mem_join_of_mem (List.getElem_mem _ _ _) hi)
blocks_sum := by simp [Composition.blocksFun, getElem_map, Composition.gather]
theorem length_sigmaCompositionAux (a : Composition n) (b : Composition a.length)
(i : Fin b.length) :
Composition.length (Composition.sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ i.2⟩) =
Composition.blocksFun b i :=
show List.length ((splitWrtComposition a.blocks b)[i.1]) = blocksFun b i by
rw [getElem_map_rev List.length, getElem_of_eq (map_length_splitWrtComposition _ _)]; rfl
set_option linter.deprecated false in
theorem blocksFun_sigmaCompositionAux (a : Composition n) (b : Composition a.length)
(i : Fin b.length) (j : Fin (blocksFun b i)) :
blocksFun (sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ i.2⟩)
⟨j, (length_sigmaCompositionAux a b i).symm ▸ j.2⟩ =
blocksFun a (embedding b i j) :=
show get (get _ ⟨_, _⟩) ⟨_, _⟩ = a.blocks.get ⟨_, _⟩ by
rw [get_of_eq (get_splitWrtComposition _ _ _), get_drop', get_take']; rfl
set_option linter.deprecated false in
/-- Auxiliary lemma to prove that the composition of formal multilinear series is associative.
Consider a composition `a` of `n` and a composition `b` of `a.length`. Grouping together some
blocks of `a` according to `b` as in `a.gather b`, one can compute the total size of the blocks
of `a` up to an index `sizeUpTo b i + j` (where the `j` corresponds to a set of blocks of `a`
that do not fill a whole block of `a.gather b`). The first part corresponds to a sum of blocks
in `a.gather b`, and the second one to a sum of blocks in the next block of
`sigmaCompositionAux a b`. This is the content of this lemma. -/
theorem sizeUpTo_sizeUpTo_add (a : Composition n) (b : Composition a.length) {i j : ℕ}
(hi : i < b.length) (hj : j < blocksFun b ⟨i, hi⟩) :
sizeUpTo a (sizeUpTo b i + j) =
sizeUpTo (a.gather b) i +
sizeUpTo (sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ hi⟩) j := by
-- Porting note: `induction'` left a spurious `hj` in the context
induction j with
| zero =>
show
sum (take (b.blocks.take i).sum a.blocks) =
sum (take i (map sum (splitWrtComposition a.blocks b)))
induction' i with i IH
· rfl
· have A : i < b.length := Nat.lt_of_succ_lt hi
have B : i < List.length (map List.sum (splitWrtComposition a.blocks b)) := by simp [A]
have C : 0 < blocksFun b ⟨i, A⟩ := Composition.blocks_pos' _ _ _
rw [sum_take_succ _ _ B, ← IH A C]
have :
take (sum (take i b.blocks)) a.blocks =
take (sum (take i b.blocks)) (take (sum (take (i + 1) b.blocks)) a.blocks) := by
rw [take_take, min_eq_left]
apply monotone_sum_take _ (Nat.le_succ _)
rw [this, getElem_map, getElem_splitWrtComposition, ←
take_append_drop (sum (take i b.blocks)) (take (sum (take (Nat.succ i) b.blocks)) a.blocks),
sum_append]
congr
rw [take_append_drop]
| succ j IHj =>
have A : j < blocksFun b ⟨i, hi⟩ := lt_trans (lt_add_one j) hj
have B : j < length (sigmaCompositionAux a b ⟨i, (length_gather a b).symm ▸ hi⟩) := by
convert A; rw [← length_sigmaCompositionAux]
have C : sizeUpTo b i + j < sizeUpTo b (i + 1) := by
simp only [sizeUpTo_succ b hi, add_lt_add_iff_left]
exact A
have D : sizeUpTo b i + j < length a := lt_of_lt_of_le C (b.sizeUpTo_le _)
have : sizeUpTo b i + Nat.succ j = (sizeUpTo b i + j).succ := rfl
rw [this, sizeUpTo_succ _ D, IHj A, sizeUpTo_succ _ B]
simp only [sigmaCompositionAux, add_assoc, add_left_inj, Fin.val_mk]
rw [getElem_of_eq (getElem_splitWrtComposition _ _ _ _), getElem_drop', getElem_take _ _ C]
/-- Natural equivalence between `(Σ (a : Composition n), Composition a.length)` and
`(Σ (c : Composition n), Π (i : Fin c.length), Composition (c.blocksFun i))`, that shows up as a
change of variables in the proof that composition of formal multilinear series is associative.
Consider a composition `a` of `n` and a composition `b` of `a.length`. Then `b` indicates how to
group together some blocks of `a`, giving altogether `b.length` blocks of blocks. These blocks of
blocks can be called `d₀, ..., d_{a.length - 1}`, and one obtains a composition `c` of `n` by
saying that each `dᵢ` is one single block. The map `⟨a, b⟩ → ⟨c, (d₀, ..., d_{a.length - 1})⟩` is
the direct map in the equiv.
Conversely, if one starts from `c` and the `dᵢ`s, one can join the `dᵢ`s to obtain a composition
`a` of `n`, and register the lengths of the `dᵢ`s in a composition `b` of `a.length`. This is the
inverse map of the equiv.
-/
def sigmaEquivSigmaPi (n : ℕ) :
(Σ a : Composition n, Composition a.length) ≃
Σ c : Composition n, ∀ i : Fin c.length, Composition (c.blocksFun i) where
toFun i := ⟨i.1.gather i.2, i.1.sigmaCompositionAux i.2⟩
invFun i :=
⟨{ blocks := (ofFn fun j => (i.2 j).blocks).join
blocks_pos := by
simp only [and_imp, List.mem_join, exists_imp, forall_mem_ofFn_iff]
exact @fun i j hj => Composition.blocks_pos _ hj
blocks_sum := by simp [sum_ofFn, Composition.blocks_sum, Composition.sum_blocksFun] },
{ blocks := ofFn fun j => (i.2 j).length
blocks_pos := by
intro k hk
refine ((forall_mem_ofFn_iff (P := fun i => 0 < i)).2 fun j => ?_) k hk
exact Composition.length_pos_of_pos _ (Composition.blocks_pos' _ _ _)
blocks_sum := by dsimp only [Composition.length]; simp [sum_ofFn] }⟩
left_inv := by
-- the fact that we have a left inverse is essentially `join_splitWrtComposition`,
-- but we need to massage it to take care of the dependent setting.
rintro ⟨a, b⟩
rw [sigma_composition_eq_iff]
dsimp
constructor
· conv_rhs =>
rw [← join_splitWrtComposition a.blocks b, ← ofFn_get (splitWrtComposition a.blocks b)]
have A : length (gather a b) = List.length (splitWrtComposition a.blocks b) := by
simp only [length, gather, length_map, length_splitWrtComposition]
congr! 2
exact (Fin.heq_fun_iff A (α := List ℕ)).2 fun i => rfl
· have B : Composition.length (Composition.gather a b) = List.length b.blocks :=
Composition.length_gather _ _
conv_rhs => rw [← ofFn_getElem b.blocks]
congr 1
refine (Fin.heq_fun_iff B).2 fun i => ?_
rw [sigmaCompositionAux, Composition.length, List.getElem_map_rev List.length,
List.getElem_of_eq (map_length_splitWrtComposition _ _)]
right_inv := by
-- the fact that we have a right inverse is essentially `splitWrtComposition_join`,
-- but we need to massage it to take care of the dependent setting.
rintro ⟨c, d⟩
have : map List.sum (ofFn fun i : Fin (Composition.length c) => (d i).blocks) = c.blocks := by
simp [map_ofFn, (· ∘ ·), Composition.blocks_sum, Composition.ofFn_blocksFun]
rw [sigma_pi_composition_eq_iff]
dsimp
congr! 1
· congr
ext1
dsimp [Composition.gather]
rwa [splitWrtComposition_join]
simp only [map_ofFn]
rfl
· rw [Fin.heq_fun_iff]
· intro i
dsimp [Composition.sigmaCompositionAux]
rw [getElem_of_eq (splitWrtComposition_join _ _ _)]
· simp only [getElem_ofFn]
· simp only [map_ofFn]
rfl
· congr
end Composition
namespace FormalMultilinearSeries
open Composition
theorem comp_assoc (r : FormalMultilinearSeries 𝕜 G H) (q : FormalMultilinearSeries 𝕜 F G)
(p : FormalMultilinearSeries 𝕜 E F) : (r.comp q).comp p = r.comp (q.comp p) := by
ext n v
/- First, rewrite the two compositions appearing in the theorem as two sums over complicated
sigma types, as in the description of the proof above. -/
let f : (Σ a : Composition n, Composition a.length) → H := fun c =>
r c.2.length (applyComposition q c.2 (applyComposition p c.1 v))
let g : (Σ c : Composition n, ∀ i : Fin c.length, Composition (c.blocksFun i)) → H := fun c =>
r c.1.length fun i : Fin c.1.length =>
q (c.2 i).length (applyComposition p (c.2 i) (v ∘ c.1.embedding i))
suffices ∑ c, f c = ∑ c, g c by
simpa (config := { unfoldPartialApp := true }) only [FormalMultilinearSeries.comp,
ContinuousMultilinearMap.sum_apply, compAlongComposition_apply, Finset.sum_sigma',
applyComposition, ContinuousMultilinearMap.map_sum]
/- Now, we use `Composition.sigmaEquivSigmaPi n` to change
variables in the second sum, and check that we get exactly the same sums. -/
rw [← (sigmaEquivSigmaPi n).sum_comp]
/- To check that we have the same terms, we should check that we apply the same component of
`r`, and the same component of `q`, and the same component of `p`, to the same coordinate of
`v`. This is true by definition, but at each step one needs to convince Lean that the types
one considers are the same, using a suitable congruence lemma to avoid dependent type issues.
This dance has to be done three times, one for `r`, one for `q` and one for `p`. -/
apply Finset.sum_congr rfl
rintro ⟨a, b⟩ _
dsimp [sigmaEquivSigmaPi]
-- check that the `r` components are the same. Based on `Composition.length_gather`
apply r.congr (Composition.length_gather a b).symm
intro i hi1 hi2
-- check that the `q` components are the same. Based on `length_sigmaCompositionAux`
apply q.congr (length_sigmaCompositionAux a b _).symm
intro j hj1 hj2
-- check that the `p` components are the same. Based on `blocksFun_sigmaCompositionAux`
apply p.congr (blocksFun_sigmaCompositionAux a b _ _).symm
intro k hk1 hk2
-- finally, check that the coordinates of `v` one is using are the same. Based on
-- `sizeUpTo_sizeUpTo_add`.
refine congr_arg v (Fin.ext ?_)
dsimp [Composition.embedding]
rw [sizeUpTo_sizeUpTo_add _ _ hi1 hj1, add_assoc]
end FormalMultilinearSeries
|
Analysis\Analytic\Constructions.lean | /-
Copyright (c) 2023 Geoffrey Irving. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: David Loeffler, Geoffrey Irving
-/
import Mathlib.Analysis.Analytic.Composition
import Mathlib.Analysis.Analytic.Linear
import Mathlib.Analysis.NormedSpace.OperatorNorm.Mul
/-!
# Various ways to combine analytic functions
We show that the following are analytic:
1. Cartesian products of analytic functions
2. Arithmetic on analytic functions: `mul`, `smul`, `inv`, `div`
3. Finite sums and products: `Finset.sum`, `Finset.prod`
-/
noncomputable section
open scoped Classical
open Topology NNReal Filter ENNReal
open Set Filter Asymptotics
variable {α : Type*}
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜]
variable {E F G H : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] [NormedAddCommGroup F]
[NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G] [NormedAddCommGroup H]
[NormedSpace 𝕜 H]
variable {𝕝 : Type*} [NontriviallyNormedField 𝕝] [NormedAlgebra 𝕜 𝕝]
variable {A : Type*} [NormedRing A] [NormedAlgebra 𝕜 A]
/-!
### Cartesian products are analytic
-/
/-- The radius of the Cartesian product of two formal series is the minimum of their radii. -/
lemma FormalMultilinearSeries.radius_prod_eq_min
(p : FormalMultilinearSeries 𝕜 E F) (q : FormalMultilinearSeries 𝕜 E G) :
(p.prod q).radius = min p.radius q.radius := by
apply le_antisymm
· refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_
rw [le_min_iff]
have := (p.prod q).isLittleO_one_of_lt_radius hr
constructor
all_goals
apply FormalMultilinearSeries.le_radius_of_isBigO
refine (isBigO_of_le _ fun n ↦ ?_).trans this.isBigO
rw [norm_mul, norm_norm, norm_mul, norm_norm]
refine mul_le_mul_of_nonneg_right ?_ (norm_nonneg _)
rw [FormalMultilinearSeries.prod, ContinuousMultilinearMap.opNorm_prod]
· apply le_max_left
· apply le_max_right
· refine ENNReal.le_of_forall_nnreal_lt fun r hr => ?_
rw [lt_min_iff] at hr
have := ((p.isLittleO_one_of_lt_radius hr.1).add
(q.isLittleO_one_of_lt_radius hr.2)).isBigO
refine (p.prod q).le_radius_of_isBigO ((isBigO_of_le _ fun n ↦ ?_).trans this)
rw [norm_mul, norm_norm, ← add_mul, norm_mul]
refine mul_le_mul_of_nonneg_right ?_ (norm_nonneg _)
rw [FormalMultilinearSeries.prod, ContinuousMultilinearMap.opNorm_prod]
refine (max_le_add_of_nonneg (norm_nonneg _) (norm_nonneg _)).trans ?_
apply Real.le_norm_self
lemma HasFPowerSeriesOnBall.prod {e : E} {f : E → F} {g : E → G} {r s : ℝ≥0∞}
{p : FormalMultilinearSeries 𝕜 E F} {q : FormalMultilinearSeries 𝕜 E G}
(hf : HasFPowerSeriesOnBall f p e r) (hg : HasFPowerSeriesOnBall g q e s) :
HasFPowerSeriesOnBall (fun x ↦ (f x, g x)) (p.prod q) e (min r s) where
r_le := by
rw [p.radius_prod_eq_min]
exact min_le_min hf.r_le hg.r_le
r_pos := lt_min hf.r_pos hg.r_pos
hasSum := by
intro y hy
simp_rw [FormalMultilinearSeries.prod, ContinuousMultilinearMap.prod_apply]
refine (hf.hasSum ?_).prod_mk (hg.hasSum ?_)
· exact EMetric.mem_ball.mpr (lt_of_lt_of_le hy (min_le_left _ _))
· exact EMetric.mem_ball.mpr (lt_of_lt_of_le hy (min_le_right _ _))
lemma HasFPowerSeriesAt.prod {e : E} {f : E → F} {g : E → G}
{p : FormalMultilinearSeries 𝕜 E F} {q : FormalMultilinearSeries 𝕜 E G}
(hf : HasFPowerSeriesAt f p e) (hg : HasFPowerSeriesAt g q e) :
HasFPowerSeriesAt (fun x ↦ (f x, g x)) (p.prod q) e := by
rcases hf with ⟨_, hf⟩
rcases hg with ⟨_, hg⟩
exact ⟨_, hf.prod hg⟩
/-- The Cartesian product of analytic functions is analytic. -/
lemma AnalyticAt.prod {e : E} {f : E → F} {g : E → G}
(hf : AnalyticAt 𝕜 f e) (hg : AnalyticAt 𝕜 g e) :
AnalyticAt 𝕜 (fun x ↦ (f x, g x)) e := by
rcases hf with ⟨_, hf⟩
rcases hg with ⟨_, hg⟩
exact ⟨_, hf.prod hg⟩
/-- The Cartesian product of analytic functions is analytic. -/
lemma AnalyticOn.prod {f : E → F} {g : E → G} {s : Set E}
(hf : AnalyticOn 𝕜 f s) (hg : AnalyticOn 𝕜 g s) :
AnalyticOn 𝕜 (fun x ↦ (f x, g x)) s :=
fun x hx ↦ (hf x hx).prod (hg x hx)
/-- `AnalyticAt.comp` for functions on product spaces -/
theorem AnalyticAt.comp₂ {h : F × G → H} {f : E → F} {g : E → G} {x : E}
(ha : AnalyticAt 𝕜 h (f x, g x)) (fa : AnalyticAt 𝕜 f x)
(ga : AnalyticAt 𝕜 g x) :
AnalyticAt 𝕜 (fun x ↦ h (f x, g x)) x :=
AnalyticAt.comp ha (fa.prod ga)
/-- `AnalyticOn.comp` for functions on product spaces -/
theorem AnalyticOn.comp₂ {h : F × G → H} {f : E → F} {g : E → G} {s : Set (F × G)} {t : Set E}
(ha : AnalyticOn 𝕜 h s) (fa : AnalyticOn 𝕜 f t) (ga : AnalyticOn 𝕜 g t)
(m : ∀ x, x ∈ t → (f x, g x) ∈ s) : AnalyticOn 𝕜 (fun x ↦ h (f x, g x)) t :=
fun _ xt ↦ (ha _ (m _ xt)).comp₂ (fa _ xt) (ga _ xt)
/-- Analytic functions on products are analytic in the first coordinate -/
theorem AnalyticAt.curry_left {f : E × F → G} {p : E × F} (fa : AnalyticAt 𝕜 f p) :
AnalyticAt 𝕜 (fun x ↦ f (x, p.2)) p.1 :=
AnalyticAt.comp₂ fa (analyticAt_id _ _) analyticAt_const
alias AnalyticAt.along_fst := AnalyticAt.curry_left
/-- Analytic functions on products are analytic in the second coordinate -/
theorem AnalyticAt.curry_right {f : E × F → G} {p : E × F} (fa : AnalyticAt 𝕜 f p) :
AnalyticAt 𝕜 (fun y ↦ f (p.1, y)) p.2 :=
AnalyticAt.comp₂ fa analyticAt_const (analyticAt_id _ _)
alias AnalyticAt.along_snd := AnalyticAt.curry_right
/-- Analytic functions on products are analytic in the first coordinate -/
theorem AnalyticOn.curry_left {f : E × F → G} {s : Set (E × F)} {y : F} (fa : AnalyticOn 𝕜 f s) :
AnalyticOn 𝕜 (fun x ↦ f (x, y)) {x | (x, y) ∈ s} :=
fun x m ↦ (fa (x, y) m).along_fst
alias AnalyticOn.along_fst := AnalyticOn.curry_left
/-- Analytic functions on products are analytic in the second coordinate -/
theorem AnalyticOn.curry_right {f : E × F → G} {x : E} {s : Set (E × F)} (fa : AnalyticOn 𝕜 f s) :
AnalyticOn 𝕜 (fun y ↦ f (x, y)) {y | (x, y) ∈ s} :=
fun y m ↦ (fa (x, y) m).along_snd
alias AnalyticOn.along_snd := AnalyticOn.curry_right
/-!
### Arithmetic on analytic functions
-/
/-- Scalar multiplication is analytic (jointly in both variables). The statement is a little
pedantic to allow towers of field extensions.
TODO: can we replace `𝕜'` with a "normed module" in such a way that `analyticAt_mul` is a special
case of this? -/
lemma analyticAt_smul [NormedSpace 𝕝 E] [IsScalarTower 𝕜 𝕝 E] (z : 𝕝 × E) :
AnalyticAt 𝕜 (fun x : 𝕝 × E ↦ x.1 • x.2) z :=
(ContinuousLinearMap.lsmul 𝕜 𝕝).analyticAt_bilinear z
/-- Multiplication in a normed algebra over `𝕜` is analytic. -/
lemma analyticAt_mul (z : A × A) : AnalyticAt 𝕜 (fun x : A × A ↦ x.1 * x.2) z :=
(ContinuousLinearMap.mul 𝕜 A).analyticAt_bilinear z
/-- Scalar multiplication of one analytic function by another. -/
lemma AnalyticAt.smul [NormedSpace 𝕝 F] [IsScalarTower 𝕜 𝕝 F] {f : E → 𝕝} {g : E → F} {z : E}
(hf : AnalyticAt 𝕜 f z) (hg : AnalyticAt 𝕜 g z) :
AnalyticAt 𝕜 (fun x ↦ f x • g x) z :=
(analyticAt_smul _).comp₂ hf hg
/-- Scalar multiplication of one analytic function by another. -/
lemma AnalyticOn.smul [NormedSpace 𝕝 F] [IsScalarTower 𝕜 𝕝 F] {f : E → 𝕝} {g : E → F} {s : Set E}
(hf : AnalyticOn 𝕜 f s) (hg : AnalyticOn 𝕜 g s) :
AnalyticOn 𝕜 (fun x ↦ f x • g x) s :=
fun _ m ↦ (hf _ m).smul (hg _ m)
/-- Multiplication of analytic functions (valued in a normed `𝕜`-algebra) is analytic. -/
lemma AnalyticAt.mul {f g : E → A} {z : E} (hf : AnalyticAt 𝕜 f z) (hg : AnalyticAt 𝕜 g z) :
AnalyticAt 𝕜 (fun x ↦ f x * g x) z :=
(analyticAt_mul _).comp₂ hf hg
/-- Multiplication of analytic functions (valued in a normed `𝕜`-algebra) is analytic. -/
lemma AnalyticOn.mul {f g : E → A} {s : Set E} (hf : AnalyticOn 𝕜 f s) (hg : AnalyticOn 𝕜 g s) :
AnalyticOn 𝕜 (fun x ↦ f x * g x) s :=
fun _ m ↦ (hf _ m).mul (hg _ m)
/-- Powers of analytic functions (into a normed `𝕜`-algebra) are analytic. -/
lemma AnalyticAt.pow {f : E → A} {z : E} (hf : AnalyticAt 𝕜 f z) (n : ℕ) :
AnalyticAt 𝕜 (fun x ↦ f x ^ n) z := by
induction n with
| zero =>
simp only [Nat.zero_eq, pow_zero]
apply analyticAt_const
| succ m hm =>
simp only [pow_succ]
exact hm.mul hf
/-- Powers of analytic functions (into a normed `𝕜`-algebra) are analytic. -/
lemma AnalyticOn.pow {f : E → A} {s : Set E} (hf : AnalyticOn 𝕜 f s) (n : ℕ) :
AnalyticOn 𝕜 (fun x ↦ f x ^ n) s :=
fun _ m ↦ (hf _ m).pow n
section Geometric
variable (𝕜 A : Type*) [NontriviallyNormedField 𝕜] [NormedRing A] [NormedAlgebra 𝕜 A]
[NormOneClass A]
/-- The geometric series `1 + x + x ^ 2 + ...` as a `FormalMultilinearSeries`. -/
def formalMultilinearSeries_geometric : FormalMultilinearSeries 𝕜 A A :=
fun n ↦ ContinuousMultilinearMap.mkPiAlgebraFin 𝕜 n A
lemma formalMultilinearSeries_geometric_apply_norm (n : ℕ) :
‖formalMultilinearSeries_geometric 𝕜 A n‖ = 1 :=
ContinuousMultilinearMap.norm_mkPiAlgebraFin
end Geometric
lemma formalMultilinearSeries_geometric_radius (𝕜) [NontriviallyNormedField 𝕜]
(A : Type*) [NormedRing A] [NormOneClass A] [NormedAlgebra 𝕜 A] :
(formalMultilinearSeries_geometric 𝕜 A).radius = 1 := by
apply le_antisymm
· refine le_of_forall_nnreal_lt (fun r hr ↦ ?_)
rw [← ENNReal.coe_one, ENNReal.coe_le_coe]
have := FormalMultilinearSeries.isLittleO_one_of_lt_radius _ hr
simp_rw [formalMultilinearSeries_geometric_apply_norm, one_mul] at this
contrapose! this
simp_rw [IsLittleO, IsBigOWith, not_forall, norm_one, mul_one,
not_eventually]
refine ⟨1, one_pos, ?_⟩
refine ((eventually_ne_atTop 0).mp (eventually_of_forall ?_)).frequently
intro n hn
push_neg
rwa [norm_pow, one_lt_pow_iff_of_nonneg (norm_nonneg _) hn,
Real.norm_of_nonneg (NNReal.coe_nonneg _), ← NNReal.coe_one,
NNReal.coe_lt_coe]
· refine le_of_forall_nnreal_lt (fun r hr ↦ ?_)
rw [← Nat.cast_one, ENNReal.coe_lt_natCast, Nat.cast_one] at hr
apply FormalMultilinearSeries.le_radius_of_isBigO
simp_rw [formalMultilinearSeries_geometric_apply_norm, one_mul]
refine isBigO_of_le atTop (fun n ↦ ?_)
rw [norm_one, Real.norm_of_nonneg (pow_nonneg (coe_nonneg r) _)]
exact pow_le_one _ (coe_nonneg r) hr.le
lemma hasFPowerSeriesOnBall_inv_one_sub
(𝕜 𝕝 : Type*) [NontriviallyNormedField 𝕜] [NontriviallyNormedField 𝕝] [NormedAlgebra 𝕜 𝕝] :
HasFPowerSeriesOnBall (fun x : 𝕝 ↦ (1 - x)⁻¹) (formalMultilinearSeries_geometric 𝕜 𝕝) 0 1 := by
constructor
· exact le_of_eq (formalMultilinearSeries_geometric_radius 𝕜 𝕝).symm
· exact one_pos
· intro y hy
simp_rw [zero_add, formalMultilinearSeries_geometric,
ContinuousMultilinearMap.mkPiAlgebraFin_apply,
List.prod_ofFn, Finset.prod_const,
Finset.card_univ, Fintype.card_fin]
apply hasSum_geometric_of_norm_lt_one
simpa only [← ofReal_one, Metric.emetric_ball, Metric.ball,
dist_eq_norm, sub_zero] using hy
lemma analyticAt_inv_one_sub (𝕝 : Type*) [NontriviallyNormedField 𝕝] [NormedAlgebra 𝕜 𝕝] :
AnalyticAt 𝕜 (fun x : 𝕝 ↦ (1 - x)⁻¹) 0 :=
⟨_, ⟨_, hasFPowerSeriesOnBall_inv_one_sub 𝕜 𝕝⟩⟩
/-- If `𝕝` is a normed field extension of `𝕜`, then the inverse map `𝕝 → 𝕝` is `𝕜`-analytic
away from 0. -/
lemma analyticAt_inv {z : 𝕝} (hz : z ≠ 0) : AnalyticAt 𝕜 Inv.inv z := by
let f1 : 𝕝 → 𝕝 := fun a ↦ 1 / z * a
let f2 : 𝕝 → 𝕝 := fun b ↦ (1 - b)⁻¹
let f3 : 𝕝 → 𝕝 := fun c ↦ 1 - c / z
have feq : f1 ∘ f2 ∘ f3 = Inv.inv := by
ext1 x
dsimp only [f1, f2, f3, Function.comp_apply]
field_simp
have f3val : f3 z = 0 := by simp only [f3, div_self hz, sub_self]
have f3an : AnalyticAt 𝕜 f3 z := by
apply analyticAt_const.sub
simpa only [div_eq_inv_mul] using analyticAt_const.mul (analyticAt_id 𝕜 z)
exact feq ▸ (analyticAt_const.mul (analyticAt_id _ _)).comp
((f3val.symm ▸ analyticAt_inv_one_sub 𝕝).comp f3an)
/-- `x⁻¹` is analytic away from zero -/
lemma analyticOn_inv : AnalyticOn 𝕜 (fun z ↦ z⁻¹) {z : 𝕝 | z ≠ 0} := by
intro z m; exact analyticAt_inv m
/-- `(f x)⁻¹` is analytic away from `f x = 0` -/
theorem AnalyticAt.inv {f : E → 𝕝} {x : E} (fa : AnalyticAt 𝕜 f x) (f0 : f x ≠ 0) :
AnalyticAt 𝕜 (fun x ↦ (f x)⁻¹) x :=
(analyticAt_inv f0).comp fa
/-- `x⁻¹` is analytic away from zero -/
theorem AnalyticOn.inv {f : E → 𝕝} {s : Set E} (fa : AnalyticOn 𝕜 f s) (f0 : ∀ x ∈ s, f x ≠ 0) :
AnalyticOn 𝕜 (fun x ↦ (f x)⁻¹) s :=
fun x m ↦ (fa x m).inv (f0 x m)
/-- `f x / g x` is analytic away from `g x = 0` -/
theorem AnalyticAt.div {f g : E → 𝕝} {x : E}
(fa : AnalyticAt 𝕜 f x) (ga : AnalyticAt 𝕜 g x) (g0 : g x ≠ 0) :
AnalyticAt 𝕜 (fun x ↦ f x / g x) x := by
simp_rw [div_eq_mul_inv]; exact fa.mul (ga.inv g0)
/-- `f x / g x` is analytic away from `g x = 0` -/
theorem AnalyticOn.div {f g : E → 𝕝} {s : Set E}
(fa : AnalyticOn 𝕜 f s) (ga : AnalyticOn 𝕜 g s) (g0 : ∀ x ∈ s, g x ≠ 0) :
AnalyticOn 𝕜 (fun x ↦ f x / g x) s := fun x m ↦
(fa x m).div (ga x m) (g0 x m)
/-!
### Finite sums and products of analytic functions
-/
/-- Finite sums of analytic functions are analytic -/
theorem Finset.analyticAt_sum {f : α → E → F} {c : E}
(N : Finset α) (h : ∀ n ∈ N, AnalyticAt 𝕜 (f n) c) :
AnalyticAt 𝕜 (fun z ↦ ∑ n ∈ N, f n z) c := by
induction' N using Finset.induction with a B aB hB
· simp only [Finset.sum_empty]
exact analyticAt_const
· simp_rw [Finset.sum_insert aB]
simp only [Finset.mem_insert] at h
exact (h a (Or.inl rfl)).add (hB fun b m ↦ h b (Or.inr m))
/-- Finite sums of analytic functions are analytic -/
theorem Finset.analyticOn_sum {f : α → E → F} {s : Set E}
(N : Finset α) (h : ∀ n ∈ N, AnalyticOn 𝕜 (f n) s) :
AnalyticOn 𝕜 (fun z ↦ ∑ n ∈ N, f n z) s :=
fun z zs ↦ N.analyticAt_sum (fun n m ↦ h n m z zs)
/-- Finite products of analytic functions are analytic -/
theorem Finset.analyticAt_prod {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A]
{f : α → E → A} {c : E} (N : Finset α) (h : ∀ n ∈ N, AnalyticAt 𝕜 (f n) c) :
AnalyticAt 𝕜 (fun z ↦ ∏ n ∈ N, f n z) c := by
induction' N using Finset.induction with a B aB hB
· simp only [Finset.prod_empty]
exact analyticAt_const
· simp_rw [Finset.prod_insert aB]
simp only [Finset.mem_insert] at h
exact (h a (Or.inl rfl)).mul (hB fun b m ↦ h b (Or.inr m))
/-- Finite products of analytic functions are analytic -/
theorem Finset.analyticOn_prod {A : Type*} [NormedCommRing A] [NormedAlgebra 𝕜 A]
{f : α → E → A} {s : Set E} (N : Finset α) (h : ∀ n ∈ N, AnalyticOn 𝕜 (f n) s) :
AnalyticOn 𝕜 (fun z ↦ ∏ n ∈ N, f n z) s :=
fun z zs ↦ N.analyticAt_prod (fun n m ↦ h n m z zs)
|
Analysis\Analytic\CPolynomial.lean | /-
Copyright (c) 2023 Sophie Morel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sophie Morel
-/
import Mathlib.Analysis.Analytic.Basic
/-! We specialize the theory fo analytic functions to the case of functions that admit a
development given by a *finite* formal multilinear series. We call them "continuously polynomial",
which is abbreviated to `CPolynomial`. One reason to do that is that we no longer need a
completeness assumption on the target space `F` to make the series converge, so some of the results
are more general. The class of continuously polynomial functions includes functions defined by
polynomials on a normed `𝕜`-algebra and continuous multilinear maps.
## Main definitions
Let `p` be a formal multilinear series from `E` to `F`, i.e., `p n` is a multilinear map on `E^n`
for `n : ℕ`, and let `f` be a function from `E` to `F`.
* `HasFiniteFPowerSeriesOnBall f p x n r`: on the ball of center `x` with radius `r`,
`f (x + y) = ∑'_n pₘ yᵐ`, and moreover `pₘ = 0` if `n ≤ m`.
* `HasFiniteFPowerSeriesAt f p x n`: on some ball of center `x` with positive radius, holds
`HasFiniteFPowerSeriesOnBall f p x n r`.
* `CPolynomialAt 𝕜 f x`: there exists a power series `p` and a natural number `n` such that
holds `HasFPowerSeriesAt f p x n`.
* `CPolynomialOn 𝕜 f s`: the function `f` is analytic at every point of `s`.
We develop the basic properties of these notions, notably:
* If a function is continuously polynomial, then it is analytic, see
`HasFiniteFPowerSeriesOnBall.hasFPowerSeriesOnBall`, `HasFiniteFPowerSeriesAt.hasFPowerSeriesAt`,
`CPolynomialAt.analyticAt` and `CPolynomialOn.analyticOn`.
* The sum of a finite formal power series with positive radius is well defined on the whole space,
see `FormalMultilinearSeries.hasFiniteFPowerSeriesOnBall_of_finite`.
* If a function admits a finite power series in a ball, then it is continuously polynomial at
any point `y` of this ball, and the power series there can be expressed in terms of the initial
power series `p` as `p.changeOrigin y`, which is finite (with the same bound as `p`) by
`changeOrigin_finite_of_finite`. See `HasFiniteFPowerSeriesOnBall.changeOrigin `. It follows in
particular that the set of points at which a given function is continuously polynomial is open,
see `isOpen_cPolynomialAt`.
-/
variable {𝕜 E F G : Type*} [NontriviallyNormedField 𝕜] [NormedAddCommGroup E] [NormedSpace 𝕜 E]
[NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
open scoped Classical
open Topology NNReal Filter ENNReal
open Set Filter Asymptotics
variable {f g : E → F} {p pf pg : FormalMultilinearSeries 𝕜 E F} {x : E} {r r' : ℝ≥0∞} {n m : ℕ}
section FiniteFPowerSeries
/-- Given a function `f : E → F`, a formal multilinear series `p` and `n : ℕ`, we say that
`f` has `p` as a finite power series on the ball of radius `r > 0` around `x` if
`f (x + y) = ∑' pₘ yᵐ` for all `‖y‖ < r` and `pₙ = 0` for `n ≤ m`. -/
structure HasFiniteFPowerSeriesOnBall (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E)
(n : ℕ) (r : ℝ≥0∞) extends HasFPowerSeriesOnBall f p x r : Prop where
finite : ∀ (m : ℕ), n ≤ m → p m = 0
theorem HasFiniteFPowerSeriesOnBall.mk' {f : E → F} {p : FormalMultilinearSeries 𝕜 E F} {x : E}
{n : ℕ} {r : ℝ≥0∞} (finite : ∀ (m : ℕ), n ≤ m → p m = 0) (pos : 0 < r)
(sum_eq : ∀ y ∈ EMetric.ball 0 r, (∑ i ∈ Finset.range n, p i fun _ ↦ y) = f (x + y)) :
HasFiniteFPowerSeriesOnBall f p x n r where
r_le := p.radius_eq_top_of_eventually_eq_zero (Filter.eventually_atTop.mpr ⟨n, finite⟩) ▸ le_top
r_pos := pos
hasSum hy := sum_eq _ hy ▸ hasSum_sum_of_ne_finset_zero fun m hm ↦ by
rw [Finset.mem_range, not_lt] at hm; rw [finite m hm]; rfl
finite := finite
/-- Given a function `f : E → F`, a formal multilinear series `p` and `n : ℕ`, we say that
`f` has `p` as a finite power series around `x` if `f (x + y) = ∑' pₙ yⁿ` for all `y` in a
neighborhood of `0`and `pₙ = 0` for `n ≤ m`. -/
def HasFiniteFPowerSeriesAt (f : E → F) (p : FormalMultilinearSeries 𝕜 E F) (x : E) (n : ℕ) :=
∃ r, HasFiniteFPowerSeriesOnBall f p x n r
theorem HasFiniteFPowerSeriesAt.toHasFPowerSeriesAt
(hf : HasFiniteFPowerSeriesAt f p x n) : HasFPowerSeriesAt f p x :=
let ⟨r, hf⟩ := hf
⟨r, hf.toHasFPowerSeriesOnBall⟩
theorem HasFiniteFPowerSeriesAt.finite (hf : HasFiniteFPowerSeriesAt f p x n) :
∀ m : ℕ, n ≤ m → p m = 0 := let ⟨_, hf⟩ := hf; hf.finite
variable (𝕜)
/-- Given a function `f : E → F`, we say that `f` is continuously polynomial (cpolynomial)
at `x` if it admits a finite power series expansion around `x`. -/
def CPolynomialAt (f : E → F) (x : E) :=
∃ (p : FormalMultilinearSeries 𝕜 E F) (n : ℕ), HasFiniteFPowerSeriesAt f p x n
/-- Given a function `f : E → F`, we say that `f` is continuously polynomial on a set `s`
if it is continuously polynomial around every point of `s`. -/
def CPolynomialOn (f : E → F) (s : Set E) :=
∀ x, x ∈ s → CPolynomialAt 𝕜 f x
variable {𝕜}
theorem HasFiniteFPowerSeriesOnBall.hasFiniteFPowerSeriesAt
(hf : HasFiniteFPowerSeriesOnBall f p x n r) :
HasFiniteFPowerSeriesAt f p x n :=
⟨r, hf⟩
theorem HasFiniteFPowerSeriesAt.cPolynomialAt (hf : HasFiniteFPowerSeriesAt f p x n) :
CPolynomialAt 𝕜 f x :=
⟨p, n, hf⟩
theorem HasFiniteFPowerSeriesOnBall.cPolynomialAt (hf : HasFiniteFPowerSeriesOnBall f p x n r) :
CPolynomialAt 𝕜 f x :=
hf.hasFiniteFPowerSeriesAt.cPolynomialAt
theorem CPolynomialAt.analyticAt (hf : CPolynomialAt 𝕜 f x) : AnalyticAt 𝕜 f x :=
let ⟨p, _, hp⟩ := hf
⟨p, hp.toHasFPowerSeriesAt⟩
theorem CPolynomialOn.analyticOn {s : Set E} (hf : CPolynomialOn 𝕜 f s) : AnalyticOn 𝕜 f s :=
fun x hx ↦ (hf x hx).analyticAt
theorem HasFiniteFPowerSeriesOnBall.congr (hf : HasFiniteFPowerSeriesOnBall f p x n r)
(hg : EqOn f g (EMetric.ball x r)) : HasFiniteFPowerSeriesOnBall g p x n r :=
⟨hf.1.congr hg, hf.finite⟩
/-- If a function `f` has a finite power series `p` around `x`, then the function
`z ↦ f (z - y)` has the same finite power series around `x + y`. -/
theorem HasFiniteFPowerSeriesOnBall.comp_sub (hf : HasFiniteFPowerSeriesOnBall f p x n r) (y : E) :
HasFiniteFPowerSeriesOnBall (fun z => f (z - y)) p (x + y) n r :=
⟨hf.1.comp_sub y, hf.finite⟩
theorem HasFiniteFPowerSeriesOnBall.mono (hf : HasFiniteFPowerSeriesOnBall f p x n r)
(r'_pos : 0 < r') (hr : r' ≤ r) : HasFiniteFPowerSeriesOnBall f p x n r' :=
⟨hf.1.mono r'_pos hr, hf.finite⟩
theorem HasFiniteFPowerSeriesAt.congr (hf : HasFiniteFPowerSeriesAt f p x n) (hg : f =ᶠ[𝓝 x] g) :
HasFiniteFPowerSeriesAt g p x n :=
Exists.imp (fun _ hg ↦ ⟨hg, hf.finite⟩) (hf.toHasFPowerSeriesAt.congr hg)
protected theorem HasFiniteFPowerSeriesAt.eventually (hf : HasFiniteFPowerSeriesAt f p x n) :
∀ᶠ r : ℝ≥0∞ in 𝓝[>] 0, HasFiniteFPowerSeriesOnBall f p x n r :=
hf.toHasFPowerSeriesAt.eventually.mono fun _ h ↦ ⟨h, hf.finite⟩
theorem hasFiniteFPowerSeriesOnBall_const {c : F} {e : E} :
HasFiniteFPowerSeriesOnBall (fun _ => c) (constFormalMultilinearSeries 𝕜 E c) e 1 ⊤ :=
⟨hasFPowerSeriesOnBall_const, fun n hn ↦ constFormalMultilinearSeries_apply (id hn : 0 < n).ne'⟩
theorem hasFiniteFPowerSeriesAt_const {c : F} {e : E} :
HasFiniteFPowerSeriesAt (fun _ => c) (constFormalMultilinearSeries 𝕜 E c) e 1 :=
⟨⊤, hasFiniteFPowerSeriesOnBall_const⟩
theorem CPolynomialAt_const {v : F} : CPolynomialAt 𝕜 (fun _ => v) x :=
⟨constFormalMultilinearSeries 𝕜 E v, 1, hasFiniteFPowerSeriesAt_const⟩
theorem CPolynomialOn_const {v : F} {s : Set E} : CPolynomialOn 𝕜 (fun _ => v) s :=
fun _ _ => CPolynomialAt_const
theorem HasFiniteFPowerSeriesOnBall.add (hf : HasFiniteFPowerSeriesOnBall f pf x n r)
(hg : HasFiniteFPowerSeriesOnBall g pg x m r) :
HasFiniteFPowerSeriesOnBall (f + g) (pf + pg) x (max n m) r :=
⟨hf.1.add hg.1, fun N hN ↦ by
rw [Pi.add_apply, hf.finite _ ((le_max_left n m).trans hN),
hg.finite _ ((le_max_right n m).trans hN), zero_add]⟩
theorem HasFiniteFPowerSeriesAt.add (hf : HasFiniteFPowerSeriesAt f pf x n)
(hg : HasFiniteFPowerSeriesAt g pg x m) :
HasFiniteFPowerSeriesAt (f + g) (pf + pg) x (max n m) := by
rcases (hf.eventually.and hg.eventually).exists with ⟨r, hr⟩
exact ⟨r, hr.1.add hr.2⟩
theorem CPolynomialAt.congr (hf : CPolynomialAt 𝕜 f x) (hg : f =ᶠ[𝓝 x] g) : CPolynomialAt 𝕜 g x :=
let ⟨_, _, hpf⟩ := hf
(hpf.congr hg).cPolynomialAt
theorem CPolynomialAt_congr (h : f =ᶠ[𝓝 x] g) : CPolynomialAt 𝕜 f x ↔ CPolynomialAt 𝕜 g x :=
⟨fun hf ↦ hf.congr h, fun hg ↦ hg.congr h.symm⟩
theorem CPolynomialAt.add (hf : CPolynomialAt 𝕜 f x) (hg : CPolynomialAt 𝕜 g x) :
CPolynomialAt 𝕜 (f + g) x :=
let ⟨_, _, hpf⟩ := hf
let ⟨_, _, hqf⟩ := hg
(hpf.add hqf).cPolynomialAt
theorem HasFiniteFPowerSeriesOnBall.neg (hf : HasFiniteFPowerSeriesOnBall f pf x n r) :
HasFiniteFPowerSeriesOnBall (-f) (-pf) x n r :=
⟨hf.1.neg, fun m hm ↦ by rw [Pi.neg_apply, hf.finite m hm, neg_zero]⟩
theorem HasFiniteFPowerSeriesAt.neg (hf : HasFiniteFPowerSeriesAt f pf x n) :
HasFiniteFPowerSeriesAt (-f) (-pf) x n :=
let ⟨_, hrf⟩ := hf
hrf.neg.hasFiniteFPowerSeriesAt
theorem CPolynomialAt.neg (hf : CPolynomialAt 𝕜 f x) : CPolynomialAt 𝕜 (-f) x :=
let ⟨_, _, hpf⟩ := hf
hpf.neg.cPolynomialAt
theorem HasFiniteFPowerSeriesOnBall.sub (hf : HasFiniteFPowerSeriesOnBall f pf x n r)
(hg : HasFiniteFPowerSeriesOnBall g pg x m r) :
HasFiniteFPowerSeriesOnBall (f - g) (pf - pg) x (max n m) r := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem HasFiniteFPowerSeriesAt.sub (hf : HasFiniteFPowerSeriesAt f pf x n)
(hg : HasFiniteFPowerSeriesAt g pg x m) :
HasFiniteFPowerSeriesAt (f - g) (pf - pg) x (max n m) := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem CPolynomialAt.sub (hf : CPolynomialAt 𝕜 f x) (hg : CPolynomialAt 𝕜 g x) :
CPolynomialAt 𝕜 (f - g) x := by
simpa only [sub_eq_add_neg] using hf.add hg.neg
theorem CPolynomialOn.mono {s t : Set E} (hf : CPolynomialOn 𝕜 f t) (hst : s ⊆ t) :
CPolynomialOn 𝕜 f s :=
fun z hz => hf z (hst hz)
theorem CPolynomialOn.congr' {s : Set E} (hf : CPolynomialOn 𝕜 f s) (hg : f =ᶠ[𝓝ˢ s] g) :
CPolynomialOn 𝕜 g s :=
fun z hz => (hf z hz).congr (mem_nhdsSet_iff_forall.mp hg z hz)
theorem CPolynomialOn_congr' {s : Set E} (h : f =ᶠ[𝓝ˢ s] g) :
CPolynomialOn 𝕜 f s ↔ CPolynomialOn 𝕜 g s :=
⟨fun hf => hf.congr' h, fun hg => hg.congr' h.symm⟩
theorem CPolynomialOn.congr {s : Set E} (hs : IsOpen s) (hf : CPolynomialOn 𝕜 f s)
(hg : s.EqOn f g) : CPolynomialOn 𝕜 g s :=
hf.congr' <| mem_nhdsSet_iff_forall.mpr
(fun _ hz => eventuallyEq_iff_exists_mem.mpr ⟨s, hs.mem_nhds hz, hg⟩)
theorem CPolynomialOn_congr {s : Set E} (hs : IsOpen s) (h : s.EqOn f g) :
CPolynomialOn 𝕜 f s ↔ CPolynomialOn 𝕜 g s :=
⟨fun hf => hf.congr hs h, fun hg => hg.congr hs h.symm⟩
theorem CPolynomialOn.add {s : Set E} (hf : CPolynomialOn 𝕜 f s) (hg : CPolynomialOn 𝕜 g s) :
CPolynomialOn 𝕜 (f + g) s :=
fun z hz => (hf z hz).add (hg z hz)
theorem CPolynomialOn.sub {s : Set E} (hf : CPolynomialOn 𝕜 f s) (hg : CPolynomialOn 𝕜 g s) :
CPolynomialOn 𝕜 (f - g) s :=
fun z hz => (hf z hz).sub (hg z hz)
/-- If a function `f` has a finite power series `p` on a ball and `g` is a continuous linear map,
then `g ∘ f` has the finite power series `g ∘ p` on the same ball. -/
theorem ContinuousLinearMap.comp_hasFiniteFPowerSeriesOnBall (g : F →L[𝕜] G)
(h : HasFiniteFPowerSeriesOnBall f p x n r) :
HasFiniteFPowerSeriesOnBall (g ∘ f) (g.compFormalMultilinearSeries p) x n r :=
⟨g.comp_hasFPowerSeriesOnBall h.1, fun m hm ↦ by
rw [compFormalMultilinearSeries_apply, h.finite m hm]
ext; exact map_zero g⟩
/-- If a function `f` is continuously polynomial on a set `s` and `g` is a continuous linear map,
then `g ∘ f` is continuously polynomial on `s`. -/
theorem ContinuousLinearMap.comp_cPolynomialOn {s : Set E} (g : F →L[𝕜] G)
(h : CPolynomialOn 𝕜 f s) : CPolynomialOn 𝕜 (g ∘ f) s := by
rintro x hx
rcases h x hx with ⟨p, n, r, hp⟩
exact ⟨g.compFormalMultilinearSeries p, n, r, g.comp_hasFiniteFPowerSeriesOnBall hp⟩
/-- If a function admits a finite power series expansion bounded by `n`, then it is equal to
the `m`th partial sums of this power series at every point of the disk for `n ≤ m`. -/
theorem HasFiniteFPowerSeriesOnBall.eq_partialSum
(hf : HasFiniteFPowerSeriesOnBall f p x n r) :
∀ y ∈ EMetric.ball (0 : E) r, ∀ m, n ≤ m →
f (x + y) = p.partialSum m y :=
fun y hy m hm ↦ (hf.hasSum hy).unique (hasSum_sum_of_ne_finset_zero
(f := fun m => p m (fun _ => y)) (s := Finset.range m)
(fun N hN => by simp only; simp only [Finset.mem_range, not_lt] at hN
rw [hf.finite _ (le_trans hm hN), ContinuousMultilinearMap.zero_apply]))
/-- Variant of the previous result with the variable expressed as `y` instead of `x + y`. -/
theorem HasFiniteFPowerSeriesOnBall.eq_partialSum'
(hf : HasFiniteFPowerSeriesOnBall f p x n r) :
∀ y ∈ EMetric.ball x r, ∀ m, n ≤ m →
f y = p.partialSum m (y - x) := by
intro y hy m hm
rw [EMetric.mem_ball, edist_eq_coe_nnnorm_sub, ← mem_emetric_ball_zero_iff] at hy
rw [← (HasFiniteFPowerSeriesOnBall.eq_partialSum hf _ hy m hm), add_sub_cancel]
/-! The particular cases where `f` has a finite power series bounded by `0` or `1`. -/
/-- If `f` has a formal power series on a ball bounded by `0`, then `f` is equal to `0` on
the ball. -/
theorem HasFiniteFPowerSeriesOnBall.eq_zero_of_bound_zero
(hf : HasFiniteFPowerSeriesOnBall f pf x 0 r) : ∀ y ∈ EMetric.ball x r, f y = 0 := by
intro y hy
rw [hf.eq_partialSum' y hy 0 le_rfl, FormalMultilinearSeries.partialSum]
simp only [Finset.range_zero, Finset.sum_empty]
theorem HasFiniteFPowerSeriesOnBall.bound_zero_of_eq_zero (hf : ∀ y ∈ EMetric.ball x r, f y = 0)
(r_pos : 0 < r) (hp : ∀ n, p n = 0) : HasFiniteFPowerSeriesOnBall f p x 0 r := by
refine ⟨⟨?_, r_pos, ?_⟩, fun n _ ↦ hp n⟩
· rw [p.radius_eq_top_of_forall_image_add_eq_zero 0 (fun n ↦ by rw [add_zero]; exact hp n)]
exact le_top
· intro y hy
rw [hf (x + y)]
· convert hasSum_zero
rw [hp, ContinuousMultilinearMap.zero_apply]
· rwa [EMetric.mem_ball, edist_eq_coe_nnnorm_sub, add_comm, add_sub_cancel_right,
← edist_eq_coe_nnnorm, ← EMetric.mem_ball]
/-- If `f` has a formal power series at `x` bounded by `0`, then `f` is equal to `0` in a
neighborhood of `x`. -/
theorem HasFiniteFPowerSeriesAt.eventually_zero_of_bound_zero
(hf : HasFiniteFPowerSeriesAt f pf x 0) : f =ᶠ[𝓝 x] 0 :=
Filter.eventuallyEq_iff_exists_mem.mpr (let ⟨r, hf⟩ := hf; ⟨EMetric.ball x r,
EMetric.ball_mem_nhds x hf.r_pos, fun y hy ↦ hf.eq_zero_of_bound_zero y hy⟩)
/-- If `f` has a formal power series on a ball bounded by `1`, then `f` is constant equal
to `f x` on the ball. -/
theorem HasFiniteFPowerSeriesOnBall.eq_const_of_bound_one
(hf : HasFiniteFPowerSeriesOnBall f pf x 1 r) : ∀ y ∈ EMetric.ball x r, f y = f x := by
intro y hy
rw [hf.eq_partialSum' y hy 1 le_rfl, hf.eq_partialSum' x
(by rw [EMetric.mem_ball, edist_self]; exact hf.r_pos) 1 le_rfl]
simp only [FormalMultilinearSeries.partialSum, Finset.range_one, Finset.sum_singleton]
congr
apply funext
simp only [IsEmpty.forall_iff]
/-- If `f` has a formal power series at x bounded by `1`, then `f` is constant equal
to `f x` in a neighborhood of `x`. -/
theorem HasFiniteFPowerSeriesAt.eventually_const_of_bound_one
(hf : HasFiniteFPowerSeriesAt f pf x 1) : f =ᶠ[𝓝 x] (fun _ => f x) :=
Filter.eventuallyEq_iff_exists_mem.mpr (let ⟨r, hf⟩ := hf; ⟨EMetric.ball x r,
EMetric.ball_mem_nhds x hf.r_pos, fun y hy ↦ hf.eq_const_of_bound_one y hy⟩)
/-- If a function admits a finite power series expansion on a disk, then it is continuous there. -/
protected theorem HasFiniteFPowerSeriesOnBall.continuousOn
(hf : HasFiniteFPowerSeriesOnBall f p x n r) :
ContinuousOn f (EMetric.ball x r) := hf.1.continuousOn
protected theorem HasFiniteFPowerSeriesAt.continuousAt (hf : HasFiniteFPowerSeriesAt f p x n) :
ContinuousAt f x := hf.toHasFPowerSeriesAt.continuousAt
protected theorem CPolynomialAt.continuousAt (hf : CPolynomialAt 𝕜 f x) : ContinuousAt f x :=
hf.analyticAt.continuousAt
protected theorem CPolynomialOn.continuousOn {s : Set E} (hf : CPolynomialOn 𝕜 f s) :
ContinuousOn f s :=
hf.analyticOn.continuousOn
/-- Continuously polynomial everywhere implies continuous -/
theorem CPolynomialOn.continuous {f : E → F} (fa : CPolynomialOn 𝕜 f univ) : Continuous f := by
rw [continuous_iff_continuousOn_univ]; exact fa.continuousOn
protected theorem FormalMultilinearSeries.sum_of_finite (p : FormalMultilinearSeries 𝕜 E F)
{n : ℕ} (hn : ∀ m, n ≤ m → p m = 0) (x : E) :
p.sum x = p.partialSum n x :=
tsum_eq_sum fun m hm ↦ by rw [Finset.mem_range, not_lt] at hm; rw [hn m hm]; rfl
/-- A finite formal multilinear series sums to its sum at every point. -/
protected theorem FormalMultilinearSeries.hasSum_of_finite (p : FormalMultilinearSeries 𝕜 E F)
{n : ℕ} (hn : ∀ m, n ≤ m → p m = 0) (x : E) :
HasSum (fun n : ℕ => p n fun _ => x) (p.sum x) :=
summable_of_ne_finset_zero (fun m hm ↦ by rw [Finset.mem_range, not_lt] at hm; rw [hn m hm]; rfl)
|>.hasSum
/-- The sum of a finite power series `p` admits `p` as a power series. -/
protected theorem FormalMultilinearSeries.hasFiniteFPowerSeriesOnBall_of_finite
(p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : ∀ m, n ≤ m → p m = 0) :
HasFiniteFPowerSeriesOnBall p.sum p 0 n ⊤ where
r_le := by rw [radius_eq_top_of_forall_image_add_eq_zero p n fun _ => hn _ (Nat.le_add_left _ _)]
r_pos := zero_lt_top
finite := hn
hasSum {y} _ := by rw [zero_add]; exact p.hasSum_of_finite hn y
theorem HasFiniteFPowerSeriesOnBall.sum (h : HasFiniteFPowerSeriesOnBall f p x n r) {y : E}
(hy : y ∈ EMetric.ball (0 : E) r) : f (x + y) = p.sum y :=
(h.hasSum hy).tsum_eq.symm
/-- The sum of a finite power series is continuous. -/
protected theorem FormalMultilinearSeries.continuousOn_of_finite
(p : FormalMultilinearSeries 𝕜 E F) {n : ℕ} (hn : ∀ m, n ≤ m → p m = 0) :
Continuous p.sum := by
rw [continuous_iff_continuousOn_univ, ← Metric.emetric_ball_top]
exact (p.hasFiniteFPowerSeriesOnBall_of_finite hn).continuousOn
end FiniteFPowerSeries
namespace FormalMultilinearSeries
section
/-! We study what happens when we change the origin of a finite formal multilinear series `p`. The
main point is that the new series `p.changeOrigin x` is still finite, with the same bound. -/
variable (p : FormalMultilinearSeries 𝕜 E F) {x y : E} {r R : ℝ≥0}
/-- If `p` is a formal multilinear series such that `p m = 0` for `n ≤ m`, then
`p.changeOriginSeriesTerm k l = 0` for `n ≤ k + l`. -/
lemma changeOriginSeriesTerm_bound (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k l : ℕ) {s : Finset (Fin (k + l))}
(hs : s.card = l) (hkl : n ≤ k + l) :
p.changeOriginSeriesTerm k l s hs = 0 := by
#adaptation_note
/-- `set_option maxSynthPendingDepth 2` required after https://github.com/leanprover/lean4/pull/4119 -/
set_option maxSynthPendingDepth 2 in
rw [changeOriginSeriesTerm, hn _ hkl, map_zero]
/-- If `p` is a finite formal multilinear series, then so is `p.changeOriginSeries k` for every
`k` in `ℕ`. More precisely, if `p m = 0` for `n ≤ m`, then `p.changeOriginSeries k m = 0` for
`n ≤ k + m`. -/
lemma changeOriginSeries_finite_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k : ℕ) : ∀ {m : ℕ}, n ≤ k + m →
p.changeOriginSeries k m = 0 := by
intro m hm
rw [changeOriginSeries]
exact Finset.sum_eq_zero (fun _ _ => p.changeOriginSeriesTerm_bound hn _ _ _ hm)
lemma changeOriginSeries_sum_eq_partialSum_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k : ℕ) :
(p.changeOriginSeries k).sum = (p.changeOriginSeries k).partialSum (n - k) := by
ext x
rw [partialSum, FormalMultilinearSeries.sum,
tsum_eq_sum (f := fun m => p.changeOriginSeries k m (fun _ => x)) (s := Finset.range (n - k))]
intro m hm
rw [Finset.mem_range, not_lt] at hm
rw [p.changeOriginSeries_finite_of_finite hn k (by rw [add_comm]; exact Nat.le_add_of_sub_le hm),
ContinuousMultilinearMap.zero_apply]
/-- If `p` is a formal multilinear series such that `p m = 0` for `n ≤ m`, then
`p.changeOrigin x k = 0` for `n ≤ k`. -/
lemma changeOrigin_finite_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(hn : ∀ (m : ℕ), n ≤ m → p m = 0) {k : ℕ} (hk : n ≤ k) :
p.changeOrigin x k = 0 := by
rw [changeOrigin, p.changeOriginSeries_sum_eq_partialSum_of_finite hn]
apply Finset.sum_eq_zero
intro m hm
rw [Finset.mem_range] at hm
rw [p.changeOriginSeries_finite_of_finite hn k (le_add_of_le_left hk),
ContinuousMultilinearMap.zero_apply]
theorem hasFiniteFPowerSeriesOnBall_changeOrigin (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(k : ℕ) (hn : ∀ (m : ℕ), n + k ≤ m → p m = 0) :
HasFiniteFPowerSeriesOnBall (p.changeOrigin · k) (p.changeOriginSeries k) 0 n ⊤ :=
(p.changeOriginSeries k).hasFiniteFPowerSeriesOnBall_of_finite
(fun _ hm => p.changeOriginSeries_finite_of_finite hn k
(by rw [add_comm n k]; apply add_le_add_left hm))
theorem changeOrigin_eval_of_finite (p : FormalMultilinearSeries 𝕜 E F) {n : ℕ}
(hn : ∀ (m : ℕ), n ≤ m → p m = 0) (x y : E) :
(p.changeOrigin x).sum y = p.sum (x + y) := by
let f (s : Σ k l : ℕ, { s : Finset (Fin (k + l)) // s.card = l }) : F :=
p.changeOriginSeriesTerm s.1 s.2.1 s.2.2 s.2.2.2 (fun _ ↦ x) fun _ ↦ y
have finsupp : f.support.Finite := by
apply Set.Finite.subset (s := changeOriginIndexEquiv ⁻¹' (Sigma.fst ⁻¹' {m | m < n}))
· apply Set.Finite.preimage (Equiv.injective _).injOn
simp_rw [← {m | m < n}.iUnion_of_singleton_coe, preimage_iUnion, ← range_sigmaMk]
exact finite_iUnion fun _ ↦ finite_range _
· refine fun s ↦ Not.imp_symm fun hs ↦ ?_
simp only [preimage_setOf_eq, changeOriginIndexEquiv_apply_fst, mem_setOf, not_lt] at hs
dsimp only [f]
rw [changeOriginSeriesTerm_bound p hn _ _ _ hs, ContinuousMultilinearMap.zero_apply,
ContinuousMultilinearMap.zero_apply]
have hfkl k l : HasSum (f ⟨k, l, ·⟩) (changeOriginSeries p k l (fun _ ↦ x) fun _ ↦ y) := by
simp_rw [changeOriginSeries, ContinuousMultilinearMap.sum_apply]; apply hasSum_fintype
have hfk k : HasSum (f ⟨k, ·⟩) (changeOrigin p x k fun _ ↦ y) := by
have (m) (hm : m ∉ Finset.range n) : changeOriginSeries p k m (fun _ ↦ x) = 0 := by
rw [Finset.mem_range, not_lt] at hm
rw [changeOriginSeries_finite_of_finite _ hn _ (le_add_of_le_right hm),
ContinuousMultilinearMap.zero_apply]
rw [changeOrigin, FormalMultilinearSeries.sum,
ContinuousMultilinearMap.tsum_eval (summable_of_ne_finset_zero this)]
refine (summable_of_ne_finset_zero (s := Finset.range n) fun m hm ↦ ?_).hasSum.sigma_of_hasSum
(hfkl k) (summable_of_finite_support <| finsupp.preimage sigma_mk_injective.injOn)
rw [this m hm, ContinuousMultilinearMap.zero_apply]
have hf : HasSum f ((p.changeOrigin x).sum y) :=
((p.changeOrigin x).hasSum_of_finite (fun _ ↦ changeOrigin_finite_of_finite p hn) _)
|>.sigma_of_hasSum hfk (summable_of_finite_support finsupp)
refine hf.unique (changeOriginIndexEquiv.symm.hasSum_iff.1 ?_)
refine (p.hasSum_of_finite hn (x + y)).sigma_of_hasSum (fun n ↦ ?_)
(changeOriginIndexEquiv.symm.summable_iff.2 hf.summable)
rw [← Pi.add_def, (p n).map_add_univ (fun _ ↦ x) fun _ ↦ y]
simp_rw [← changeOriginSeriesTerm_changeOriginIndexEquiv_symm]
exact hasSum_fintype fun c ↦ f (changeOriginIndexEquiv.symm ⟨n, c⟩)
/-- The terms of the formal multilinear series `p.changeOrigin` are continuously polynomial
as we vary the origin -/
theorem cPolynomialAt_changeOrigin_of_finite (p : FormalMultilinearSeries 𝕜 E F)
{n : ℕ} (hn : ∀ (m : ℕ), n ≤ m → p m = 0) (k : ℕ) :
CPolynomialAt 𝕜 (p.changeOrigin · k) 0 :=
(p.hasFiniteFPowerSeriesOnBall_changeOrigin k fun _ h ↦ hn _ (le_self_add.trans h)).cPolynomialAt
end
end FormalMultilinearSeries
section
variable {x y : E}
theorem HasFiniteFPowerSeriesOnBall.changeOrigin (hf : HasFiniteFPowerSeriesOnBall f p x n r)
(h : (‖y‖₊ : ℝ≥0∞) < r) :
HasFiniteFPowerSeriesOnBall f (p.changeOrigin y) (x + y) n (r - ‖y‖₊) where
r_le := (tsub_le_tsub_right hf.r_le _).trans p.changeOrigin_radius
r_pos := by simp [h]
finite _ hm := p.changeOrigin_finite_of_finite hf.finite hm
hasSum {z} hz := by
have : f (x + y + z) =
FormalMultilinearSeries.sum (FormalMultilinearSeries.changeOrigin p y) z := by
rw [mem_emetric_ball_zero_iff, lt_tsub_iff_right, add_comm] at hz
rw [p.changeOrigin_eval_of_finite hf.finite, add_assoc, hf.sum]
refine mem_emetric_ball_zero_iff.2 (lt_of_le_of_lt ?_ hz)
exact mod_cast nnnorm_add_le y z
rw [this]
apply (p.changeOrigin y).hasSum_of_finite fun _ => p.changeOrigin_finite_of_finite hf.finite
/-- If a function admits a finite power series expansion `p` on an open ball `B (x, r)`, then
it is continuously polynomial at every point of this ball. -/
theorem HasFiniteFPowerSeriesOnBall.cPolynomialAt_of_mem
(hf : HasFiniteFPowerSeriesOnBall f p x n r) (h : y ∈ EMetric.ball x r) :
CPolynomialAt 𝕜 f y := by
have : (‖y - x‖₊ : ℝ≥0∞) < r := by simpa [edist_eq_coe_nnnorm_sub] using h
have := hf.changeOrigin this
rw [add_sub_cancel] at this
exact this.cPolynomialAt
theorem HasFiniteFPowerSeriesOnBall.cPolynomialOn (hf : HasFiniteFPowerSeriesOnBall f p x n r) :
CPolynomialOn 𝕜 f (EMetric.ball x r) :=
fun _y hy => hf.cPolynomialAt_of_mem hy
variable (𝕜 f)
/-- For any function `f` from a normed vector space to a normed vector space, the set of points
`x` such that `f` is continuously polynomial at `x` is open. -/
theorem isOpen_cPolynomialAt : IsOpen { x | CPolynomialAt 𝕜 f x } := by
rw [isOpen_iff_mem_nhds]
rintro x ⟨p, n, r, hr⟩
exact mem_of_superset (EMetric.ball_mem_nhds _ hr.r_pos) fun y hy => hr.cPolynomialAt_of_mem hy
variable {𝕜}
theorem CPolynomialAt.eventually_cPolynomialAt {f : E → F} {x : E} (h : CPolynomialAt 𝕜 f x) :
∀ᶠ y in 𝓝 x, CPolynomialAt 𝕜 f y :=
(isOpen_cPolynomialAt 𝕜 f).mem_nhds h
theorem CPolynomialAt.exists_mem_nhds_cPolynomialOn {f : E → F} {x : E} (h : CPolynomialAt 𝕜 f x) :
∃ s ∈ 𝓝 x, CPolynomialOn 𝕜 f s :=
h.eventually_cPolynomialAt.exists_mem
/-- If `f` is continuously polynomial at a point, then it is continuously polynomial in a
nonempty ball around that point. -/
theorem CPolynomialAt.exists_ball_cPolynomialOn {f : E → F} {x : E} (h : CPolynomialAt 𝕜 f x) :
∃ r : ℝ, 0 < r ∧ CPolynomialOn 𝕜 f (Metric.ball x r) :=
Metric.isOpen_iff.mp (isOpen_cPolynomialAt _ _) _ h
end
|
Analysis\Analytic\Inverse.lean | /-
Copyright (c) 2021 Sébastien Gouëzel. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Sébastien Gouëzel
-/
import Mathlib.Analysis.Analytic.Composition
/-!
# Inverse of analytic functions
We construct the left and right inverse of a formal multilinear series with invertible linear term,
we prove that they coincide and study their properties (notably convergence).
## Main statements
* `p.leftInv i`: the formal left inverse of the formal multilinear series `p`,
for `i : E ≃L[𝕜] F` which coincides with `p₁`.
* `p.rightInv i`: the formal right inverse of the formal multilinear series `p`,
for `i : E ≃L[𝕜] F` which coincides with `p₁`.
* `p.leftInv_comp` says that `p.leftInv i` is indeed a left inverse to `p` when `p₁ = i`.
* `p.rightInv_comp` says that `p.rightInv i` is indeed a right inverse to `p` when `p₁ = i`.
* `p.leftInv_eq_rightInv`: the two inverses coincide.
* `p.radius_rightInv_pos_of_radius_pos`: if a power series has a positive radius of convergence,
then so does its inverse.
-/
open scoped Topology
open Finset Filter
namespace FormalMultilinearSeries
variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] {E : Type*} [NormedAddCommGroup E]
[NormedSpace 𝕜 E] {F : Type*} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
/-! ### The left inverse of a formal multilinear series -/
/-- The left inverse of a formal multilinear series, where the `n`-th term is defined inductively
in terms of the previous ones to make sure that `(leftInv p i) ∘ p = id`. For this, the linear term
`p₁` in `p` should be invertible. In the definition, `i` is a linear isomorphism that should
coincide with `p₁`, so that one can use its inverse in the construction. The definition does not
use that `i = p₁`, but proofs that the definition is well-behaved do.
The `n`-th term in `q ∘ p` is `∑ qₖ (p_{j₁}, ..., p_{jₖ})` over `j₁ + ... + jₖ = n`. In this
expression, `qₙ` appears only once, in `qₙ (p₁, ..., p₁)`. We adjust the definition so that this
term compensates the rest of the sum, using `i⁻¹` as an inverse to `p₁`.
These formulas only make sense when the constant term `p₀` vanishes. The definition we give is
general, but it ignores the value of `p₀`.
-/
noncomputable def leftInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
FormalMultilinearSeries 𝕜 F E
| 0 => 0
| 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm
| n + 2 =>
-∑ c : { c : Composition (n + 2) // c.length < n + 2 },
(leftInv p i (c : Composition (n + 2)).length).compAlongComposition
(p.compContinuousLinearMap i.symm) c
@[simp]
theorem leftInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.leftInv i 0 = 0 := by rw [leftInv]
@[simp]
theorem leftInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.leftInv i 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [leftInv]
/-- The left inverse does not depend on the zeroth coefficient of a formal multilinear
series. -/
theorem leftInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.removeZero.leftInv i = p.leftInv i := by
ext1 n
induction' n using Nat.strongRec' with n IH
match n with
| 0 => simp -- if one replaces `simp` with `refl`, the proof times out in the kernel.
| 1 => simp -- TODO: why?
| n + 2 =>
simp only [leftInv, neg_inj]
refine Finset.sum_congr rfl fun c cuniv => ?_
rcases c with ⟨c, hc⟩
ext v
dsimp
simp [IH _ hc]
/-- The left inverse to a formal multilinear series is indeed a left inverse, provided its linear
term is invertible. -/
theorem leftInv_comp (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) : (leftInv p i).comp p = id 𝕜 E := by
ext (n v)
classical
match n with
| 0 =>
simp only [leftInv_coeff_zero, ContinuousMultilinearMap.zero_apply, id_apply_ne_one, Ne,
not_false_iff, zero_ne_one, comp_coeff_zero']
| 1 =>
simp only [leftInv_coeff_one, comp_coeff_one, h, id_apply_one, ContinuousLinearEquiv.coe_apply,
ContinuousLinearEquiv.symm_apply_apply, continuousMultilinearCurryFin1_symm_apply]
| n + 2 =>
have A :
(Finset.univ : Finset (Composition (n + 2))) =
{c | Composition.length c < n + 2}.toFinset ∪ {Composition.ones (n + 2)} := by
refine Subset.antisymm (fun c _ => ?_) (subset_univ _)
by_cases h : c.length < n + 2
· simp [h, Set.mem_toFinset (s := {c | Composition.length c < n + 2})]
· simp [Composition.eq_ones_iff_le_length.2 (not_lt.1 h)]
have B :
Disjoint ({c | Composition.length c < n + 2} : Set (Composition (n + 2))).toFinset
{Composition.ones (n + 2)} := by
simp [Set.mem_toFinset (s := {c | Composition.length c < n + 2})]
have C :
((p.leftInv i (Composition.ones (n + 2)).length)
fun j : Fin (Composition.ones n.succ.succ).length =>
p 1 fun _ => v ((Fin.castLE (Composition.length_le _)) j)) =
p.leftInv i (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j := by
apply FormalMultilinearSeries.congr _ (Composition.ones_length _) fun j hj1 hj2 => ?_
exact FormalMultilinearSeries.congr _ rfl fun k _ _ => by congr
have D :
(p.leftInv i (n + 2) fun j : Fin (n + 2) => p 1 fun _ => v j) =
-∑ c ∈ {c : Composition (n + 2) | c.length < n + 2}.toFinset,
(p.leftInv i c.length) (p.applyComposition c v) := by
simp only [leftInv, ContinuousMultilinearMap.neg_apply, neg_inj,
ContinuousMultilinearMap.sum_apply]
convert
(sum_toFinset_eq_subtype
(fun c : Composition (n + 2) => c.length < n + 2)
(fun c : Composition (n + 2) =>
(ContinuousMultilinearMap.compAlongComposition
(p.compContinuousLinearMap (i.symm : F →L[𝕜] E)) c (p.leftInv i c.length))
fun j : Fin (n + 2) => p 1 fun _ : Fin 1 => v j)).symm.trans
_
simp only [compContinuousLinearMap_applyComposition,
ContinuousMultilinearMap.compAlongComposition_apply]
congr
ext c
congr
ext k
simp [h, Function.comp]
simp [FormalMultilinearSeries.comp, show n + 2 ≠ 1 by omega, A, Finset.sum_union B,
applyComposition_ones, C, D, -Set.toFinset_setOf]
/-! ### The right inverse of a formal multilinear series -/
/-- The right inverse of a formal multilinear series, where the `n`-th term is defined inductively
in terms of the previous ones to make sure that `p ∘ (rightInv p i) = id`. For this, the linear
term `p₁` in `p` should be invertible. In the definition, `i` is a linear isomorphism that should
coincide with `p₁`, so that one can use its inverse in the construction. The definition does not
use that `i = p₁`, but proofs that the definition is well-behaved do.
The `n`-th term in `p ∘ q` is `∑ pₖ (q_{j₁}, ..., q_{jₖ})` over `j₁ + ... + jₖ = n`. In this
expression, `qₙ` appears only once, in `p₁ (qₙ)`. We adjust the definition of `qₙ` so that this
term compensates the rest of the sum, using `i⁻¹` as an inverse to `p₁`.
These formulas only make sense when the constant term `p₀` vanishes. The definition we give is
general, but it ignores the value of `p₀`.
-/
noncomputable def rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
FormalMultilinearSeries 𝕜 F E
| 0 => 0
| 1 => (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm
| n + 2 =>
let q : FormalMultilinearSeries 𝕜 F E := fun k => if k < n + 2 then rightInv p i k else 0;
-(i.symm : F →L[𝕜] E).compContinuousMultilinearMap ((p.comp q) (n + 2))
@[simp]
theorem rightInv_coeff_zero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.rightInv i 0 = 0 := by rw [rightInv]
@[simp]
theorem rightInv_coeff_one (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.rightInv i 1 = (continuousMultilinearCurryFin1 𝕜 F E).symm i.symm := by rw [rightInv]
/-- The right inverse does not depend on the zeroth coefficient of a formal multilinear
series. -/
theorem rightInv_removeZero (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) :
p.removeZero.rightInv i = p.rightInv i := by
ext1 n
induction' n using Nat.strongRec' with n IH
match n with
| 0 => simp only [rightInv_coeff_zero]
| 1 => simp only [rightInv_coeff_one]
| n + 2 =>
simp only [rightInv, neg_inj]
rw [removeZero_comp_of_pos _ _ (add_pos_of_nonneg_of_pos n.zero_le zero_lt_two)]
congr (config := { closePost := false }) 2 with k
by_cases hk : k < n + 2 <;> simp [hk, IH]
theorem comp_rightInv_aux1 {n : ℕ} (hn : 0 < n) (p : FormalMultilinearSeries 𝕜 E F)
(q : FormalMultilinearSeries 𝕜 F E) (v : Fin n → F) :
p.comp q n v =
∑ c ∈ {c : Composition n | 1 < c.length}.toFinset,
p c.length (q.applyComposition c v) + p 1 fun _ => q n v := by
classical
have A :
(Finset.univ : Finset (Composition n)) =
{c | 1 < Composition.length c}.toFinset ∪ {Composition.single n hn} := by
refine Subset.antisymm (fun c _ => ?_) (subset_univ _)
by_cases h : 1 < c.length
· simp [h, Set.mem_toFinset (s := {c | 1 < Composition.length c})]
· have : c.length = 1 := by
refine (eq_iff_le_not_lt.2 ⟨?_, h⟩).symm; exact c.length_pos_of_pos hn
rw [← Composition.eq_single_iff_length hn] at this
simp [this]
have B :
Disjoint ({c | 1 < Composition.length c} : Set (Composition n)).toFinset
{Composition.single n hn} := by
simp [Set.mem_toFinset (s := {c | 1 < Composition.length c})]
have C :
p (Composition.single n hn).length (q.applyComposition (Composition.single n hn) v) =
p 1 fun _ : Fin 1 => q n v := by
apply p.congr (Composition.single_length hn) fun j hj1 _ => ?_
simp [applyComposition_single]
simp [FormalMultilinearSeries.comp, A, Finset.sum_union B, C, -Set.toFinset_setOf,
-add_right_inj, -Composition.single_length]
theorem comp_rightInv_aux2 (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (n : ℕ)
(v : Fin (n + 2) → F) :
∑ c ∈ {c : Composition (n + 2) | 1 < c.length}.toFinset,
p c.length (applyComposition (fun k : ℕ => ite (k < n + 2) (p.rightInv i k) 0) c v) =
∑ c ∈ {c : Composition (n + 2) | 1 < c.length}.toFinset,
p c.length ((p.rightInv i).applyComposition c v) := by
have N : 0 < n + 2 := by norm_num
refine sum_congr rfl fun c hc => p.congr rfl fun j hj1 hj2 => ?_
have : ∀ k, c.blocksFun k < n + 2 := by
simp only [Set.mem_toFinset (s := {c : Composition (n + 2) | 1 < c.length}),
Set.mem_setOf_eq] at hc
simp [← Composition.ne_single_iff N, Composition.eq_single_iff_length, ne_of_gt hc]
simp [applyComposition, this]
/-- The right inverse to a formal multilinear series is indeed a right inverse, provided its linear
term is invertible and its constant term vanishes. -/
theorem comp_rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) (h0 : p 0 = 0) :
p.comp (rightInv p i) = id 𝕜 F := by
ext (n v)
match n with
| 0 =>
simp only [h0, ContinuousMultilinearMap.zero_apply, id_apply_ne_one, Ne, not_false_iff,
zero_ne_one, comp_coeff_zero']
| 1 =>
simp only [comp_coeff_one, h, rightInv_coeff_one, ContinuousLinearEquiv.apply_symm_apply,
id_apply_one, ContinuousLinearEquiv.coe_apply, continuousMultilinearCurryFin1_symm_apply]
| n + 2 =>
have N : 0 < n + 2 := by norm_num
simp [comp_rightInv_aux1 N, h, rightInv, lt_irrefl n, show n + 2 ≠ 1 by omega,
← sub_eq_add_neg, sub_eq_zero, comp_rightInv_aux2, -Set.toFinset_setOf]
theorem rightInv_coeff (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) (n : ℕ) (hn : 2 ≤ n) :
p.rightInv i n =
-(i.symm : F →L[𝕜] E).compContinuousMultilinearMap
(∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition n)),
p.compAlongComposition (p.rightInv i) c) := by
match n with
| 0 => exact False.elim (zero_lt_two.not_le hn)
| 1 => exact False.elim (one_lt_two.not_le hn)
| n + 2 =>
simp only [rightInv, neg_inj]
congr (config := { closePost := false }) 1
ext v
have N : 0 < n + 2 := by norm_num
have : ((p 1) fun i : Fin 1 => 0) = 0 := ContinuousMultilinearMap.map_zero _
simp [comp_rightInv_aux1 N, lt_irrefl n, this, comp_rightInv_aux2, -Set.toFinset_setOf]
/-! ### Coincidence of the left and the right inverse -/
private theorem leftInv_eq_rightInv_aux (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) (h0 : p 0 = 0) :
leftInv p i = rightInv p i :=
calc
leftInv p i = (leftInv p i).comp (id 𝕜 F) := by simp
_ = (leftInv p i).comp (p.comp (rightInv p i)) := by rw [comp_rightInv p i h h0]
_ = ((leftInv p i).comp p).comp (rightInv p i) := by rw [comp_assoc]
_ = (id 𝕜 E).comp (rightInv p i) := by rw [leftInv_comp p i h]
_ = rightInv p i := by simp
/-- The left inverse and the right inverse of a formal multilinear series coincide. This is not at
all obvious from their definition, but it follows from uniqueness of inverses (which comes from the
fact that composition is associative on formal multilinear series). -/
theorem leftInv_eq_rightInv (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F)
(h : p 1 = (continuousMultilinearCurryFin1 𝕜 E F).symm i) : leftInv p i = rightInv p i :=
calc
leftInv p i = leftInv p.removeZero i := by rw [leftInv_removeZero]
_ = rightInv p.removeZero i := by apply leftInv_eq_rightInv_aux <;> simp; exact h
_ = rightInv p i := by rw [rightInv_removeZero]
/-!
### Convergence of the inverse of a power series
Assume that `p` is a convergent multilinear series, and let `q` be its (left or right) inverse.
Using the left-inverse formula gives
$$
q_n = - (p_1)^{-n} \sum_{k=0}^{n-1} \sum_{i_1 + \dotsc + i_k = n} q_k (p_{i_1}, \dotsc, p_{i_k}).
$$
Assume for simplicity that we are in dimension `1` and `p₁ = 1`. In the formula for `qₙ`, the term
`q_{n-1}` appears with a multiplicity of `n-1` (choosing the index `i_j` for which `i_j = 2` while
all the other indices are equal to `1`), which indicates that `qₙ` might grow like `n!`. This is
bad for summability properties.
It turns out that the right-inverse formula is better behaved, and should instead be used for this
kind of estimate. It reads
$$
q_n = - (p_1)^{-1} \sum_{k=2}^n \sum_{i_1 + \dotsc + i_k = n} p_k (q_{i_1}, \dotsc, q_{i_k}).
$$
Here, `q_{n-1}` can only appear in the term with `k = 2`, and it only appears twice, so there is
hope this formula can lead to an at most geometric behavior.
Let `Qₙ = ‖qₙ‖`. Bounding `‖pₖ‖` with `C r^k` gives an inequality
$$
Q_n ≤ C' \sum_{k=2}^n r^k \sum_{i_1 + \dotsc + i_k = n} Q_{i_1} \dotsm Q_{i_k}.
$$
This formula is not enough to prove by naive induction on `n` a bound of the form `Qₙ ≤ D R^n`.
However, assuming that the inequality above were an equality, one could get a formula for the
generating series of the `Qₙ`:
$$
\begin{align}
Q(z) & := \sum Q_n z^n = Q_1 z + C' \sum_{2 \leq k \leq n} \sum_{i_1 + \dotsc + i_k = n}
(r z^{i_1} Q_{i_1}) \dotsm (r z^{i_k} Q_{i_k})
\\ & = Q_1 z + C' \sum_{k = 2}^\infty (\sum_{i_1 \geq 1} r z^{i_1} Q_{i_1})
\dotsm (\sum_{i_k \geq 1} r z^{i_k} Q_{i_k})
\\ & = Q_1 z + C' \sum_{k = 2}^\infty (r Q(z))^k
= Q_1 z + C' (r Q(z))^2 / (1 - r Q(z)).
\end{align}
$$
One can solve this formula explicitly. The solution is analytic in a neighborhood of `0` in `ℂ`,
hence its coefficients grow at most geometrically (by a contour integral argument), and therefore
the original `Qₙ`, which are bounded by these ones, are also at most geometric.
This classical argument is not really satisfactory, as it requires an a priori bound on a complex
analytic function. Another option would be to compute explicitly its terms (with binomial
coefficients) to obtain an explicit geometric bound, but this would be very painful.
Instead, we will use the above intuition, but in a slightly different form, with finite sums and an
induction. I learnt this trick in [poeschel2017siegelsternberg]. Let
$S_n = \sum_{k=1}^n Q_k a^k$ (where `a` is a positive real parameter to be chosen suitably small).
The above computation but with finite sums shows that
$$
S_n \leq Q_1 a + C' \sum_{k=2}^n (r S_{n-1})^k.
$$
In particular, $S_n \leq Q_1 a + C' (r S_{n-1})^2 / (1- r S_{n-1})$.
Assume that $S_{n-1} \leq K a$, where `K > Q₁` is fixed and `a` is small enough so that
`r K a ≤ 1/2` (to control the denominator). Then this equation gives a bound
$S_n \leq Q_1 a + 2 C' r^2 K^2 a^2$.
If `a` is small enough, this is bounded by `K a` as the second term is quadratic in `a`, and
therefore negligible.
By induction, we deduce `Sₙ ≤ K a` for all `n`, which gives in particular the fact that `aⁿ Qₙ`
remains bounded.
-/
/-- First technical lemma to control the growth of coefficients of the inverse. Bound the explicit
expression for `∑_{k<n+1} aᵏ Qₖ` in terms of a sum of powers of the same sum one step before,
in a general abstract setup. -/
theorem radius_right_inv_pos_of_radius_pos_aux1 (n : ℕ) (p : ℕ → ℝ) (hp : ∀ k, 0 ≤ p k) {r a : ℝ}
(hr : 0 ≤ r) (ha : 0 ≤ a) :
∑ k ∈ Ico 2 (n + 1),
a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, p (c.blocksFun j) ≤
∑ j ∈ Ico 2 (n + 1), r ^ j * (∑ k ∈ Ico 1 n, a ^ k * p k) ^ j :=
calc
∑ k ∈ Ico 2 (n + 1),
a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, p (c.blocksFun j) =
∑ k ∈ Ico 2 (n + 1),
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
∏ j, r * (a ^ c.blocksFun j * p (c.blocksFun j)) := by
simp_rw [mul_sum]
congr! with k _ c
rw [prod_mul_distrib, prod_mul_distrib, prod_pow_eq_pow_sum, Composition.sum_blocksFun,
prod_const, card_fin]
ring
_ ≤
∑ d ∈ compPartialSumTarget 2 (n + 1) n,
∏ j : Fin d.2.length, r * (a ^ d.2.blocksFun j * p (d.2.blocksFun j)) := by
rw [sum_sigma']
refine
sum_le_sum_of_subset_of_nonneg ?_ fun x _ _ =>
prod_nonneg fun j _ => mul_nonneg hr (mul_nonneg (pow_nonneg ha _) (hp _))
rintro ⟨k, c⟩ hd
simp only [Set.mem_toFinset (s := {c | 1 < Composition.length c}), mem_Ico, mem_sigma,
Set.mem_setOf_eq] at hd
simp only [mem_compPartialSumTarget_iff]
refine ⟨hd.2, c.length_le.trans_lt hd.1.2, fun j => ?_⟩
have : c ≠ Composition.single k (zero_lt_two.trans_le hd.1.1) := by
simp [Composition.eq_single_iff_length, ne_of_gt hd.2]
rw [Composition.ne_single_iff] at this
exact (this j).trans_le (Nat.lt_succ_iff.mp hd.1.2)
_ = ∑ e ∈ compPartialSumSource 2 (n + 1) n, ∏ j : Fin e.1, r * (a ^ e.2 j * p (e.2 j)) := by
symm
apply compChangeOfVariables_sum
rintro ⟨k, blocksFun⟩ H
have K : (compChangeOfVariables 2 (n + 1) n ⟨k, blocksFun⟩ H).snd.length = k := by simp
congr 2 <;> try rw [K]
rw [Fin.heq_fun_iff K.symm]
intro j
rw [compChangeOfVariables_blocksFun]
_ = ∑ j ∈ Ico 2 (n + 1), r ^ j * (∑ k ∈ Ico 1 n, a ^ k * p k) ^ j := by
rw [compPartialSumSource,
← sum_sigma' (Ico 2 (n + 1))
(fun k : ℕ => (Fintype.piFinset fun _ : Fin k => Ico 1 n : Finset (Fin k → ℕ)))
(fun n e => ∏ j : Fin n, r * (a ^ e j * p (e j)))]
congr! with j
simp only [← @MultilinearMap.mkPiAlgebra_apply ℝ (Fin j) _ ℝ]
simp only [←
MultilinearMap.map_sum_finset (MultilinearMap.mkPiAlgebra ℝ (Fin j) ℝ) fun _ (m : ℕ) =>
r * (a ^ m * p m)]
simp only [MultilinearMap.mkPiAlgebra_apply]
simp [prod_const, ← mul_sum, mul_pow]
/-- Second technical lemma to control the growth of coefficients of the inverse. Bound the explicit
expression for `∑_{k<n+1} aᵏ Qₖ` in terms of a sum of powers of the same sum one step before,
in the specific setup we are interesting in, by reducing to the general bound in
`radius_rightInv_pos_of_radius_pos_aux1`. -/
theorem radius_rightInv_pos_of_radius_pos_aux2 {n : ℕ} (hn : 2 ≤ n + 1)
(p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F) {r a C : ℝ} (hr : 0 ≤ r) (ha : 0 ≤ a)
(hC : 0 ≤ C) (hp : ∀ n, ‖p n‖ ≤ C * r ^ n) :
∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i k‖ ≤
‖(i.symm : F →L[𝕜] E)‖ * a +
‖(i.symm : F →L[𝕜] E)‖ * C *
∑ k ∈ Ico 2 (n + 1), (r * ∑ j ∈ Ico 1 n, a ^ j * ‖p.rightInv i j‖) ^ k :=
let I := ‖(i.symm : F →L[𝕜] E)‖
calc
∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i k‖ =
a * I + ∑ k ∈ Ico 2 (n + 1), a ^ k * ‖p.rightInv i k‖ := by
simp only [LinearIsometryEquiv.norm_map, pow_one, rightInv_coeff_one,
show Ico (1 : ℕ) 2 = {1} from Nat.Ico_succ_singleton 1,
sum_singleton, ← sum_Ico_consecutive _ one_le_two hn]
_ =
a * I +
∑ k ∈ Ico 2 (n + 1),
a ^ k *
‖(i.symm : F →L[𝕜] E).compContinuousMultilinearMap
(∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
p.compAlongComposition (p.rightInv i) c)‖ := by
congr! 2 with j hj
rw [rightInv_coeff _ _ _ (mem_Ico.1 hj).1, norm_neg]
_ ≤
a * ‖(i.symm : F →L[𝕜] E)‖ +
∑ k ∈ Ico 2 (n + 1),
a ^ k *
(I *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
C * r ^ c.length * ∏ j, ‖p.rightInv i (c.blocksFun j)‖) := by
gcongr with j
apply (ContinuousLinearMap.norm_compContinuousMultilinearMap_le _ _).trans
gcongr
apply (norm_sum_le _ _).trans
gcongr
apply (compAlongComposition_norm _ _ _).trans
gcongr
apply hp
_ =
I * a +
I * C *
∑ k ∈ Ico 2 (n + 1),
a ^ k *
∑ c ∈ ({c | 1 < Composition.length c}.toFinset : Finset (Composition k)),
r ^ c.length * ∏ j, ‖p.rightInv i (c.blocksFun j)‖ := by
simp_rw [mul_assoc C, ← mul_sum, ← mul_assoc, mul_comm _ ‖(i.symm : F →L[𝕜] E)‖, mul_assoc,
← mul_sum, ← mul_assoc, mul_comm _ C, mul_assoc, ← mul_sum]
ring
_ ≤ I * a + I * C *
∑ k ∈ Ico 2 (n + 1), (r * ∑ j ∈ Ico 1 n, a ^ j * ‖p.rightInv i j‖) ^ k := by
gcongr _ + _ * _ * ?_
simp_rw [mul_pow]
apply
radius_right_inv_pos_of_radius_pos_aux1 n (fun k => ‖p.rightInv i k‖)
(fun k => norm_nonneg _) hr ha
/-- If a a formal multilinear series has a positive radius of convergence, then its right inverse
also has a positive radius of convergence. -/
theorem radius_rightInv_pos_of_radius_pos (p : FormalMultilinearSeries 𝕜 E F) (i : E ≃L[𝕜] F)
(hp : 0 < p.radius) : 0 < (p.rightInv i).radius := by
obtain ⟨C, r, Cpos, rpos, ple⟩ :
∃ (C r : _) (_ : 0 < C) (_ : 0 < r), ∀ n : ℕ, ‖p n‖ ≤ C * r ^ n :=
le_mul_pow_of_radius_pos p hp
let I := ‖(i.symm : F →L[𝕜] E)‖
-- choose `a` small enough to make sure that `∑_{k ≤ n} aᵏ Qₖ` will be controllable by
-- induction
obtain ⟨a, apos, ha1, ha2⟩ :
∃ (a : _) (apos : 0 < a),
2 * I * C * r ^ 2 * (I + 1) ^ 2 * a ≤ 1 ∧ r * (I + 1) * a ≤ 1 / 2 := by
have :
Tendsto (fun a => 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a) (𝓝 0)
(𝓝 (2 * I * C * r ^ 2 * (I + 1) ^ 2 * 0)) :=
tendsto_const_nhds.mul tendsto_id
have A : ∀ᶠ a in 𝓝 0, 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a < 1 := by
apply (tendsto_order.1 this).2; simp [zero_lt_one]
have : Tendsto (fun a => r * (I + 1) * a) (𝓝 0) (𝓝 (r * (I + 1) * 0)) :=
tendsto_const_nhds.mul tendsto_id
have B : ∀ᶠ a in 𝓝 0, r * (I + 1) * a < 1 / 2 := by
apply (tendsto_order.1 this).2; simp [zero_lt_one]
have C : ∀ᶠ a in 𝓝[>] (0 : ℝ), (0 : ℝ) < a := by
filter_upwards [self_mem_nhdsWithin] with _ ha using ha
rcases (C.and ((A.and B).filter_mono inf_le_left)).exists with ⟨a, ha⟩
exact ⟨a, ha.1, ha.2.1.le, ha.2.2.le⟩
-- check by induction that the partial sums are suitably bounded, using the choice of `a` and the
-- inductive control from Lemma `radius_rightInv_pos_of_radius_pos_aux2`.
let S n := ∑ k ∈ Ico 1 n, a ^ k * ‖p.rightInv i k‖
have IRec : ∀ n, 1 ≤ n → S n ≤ (I + 1) * a := by
apply Nat.le_induction
· simp only [S]
rw [Ico_eq_empty_of_le (le_refl 1), sum_empty]
exact mul_nonneg (add_nonneg (norm_nonneg _) zero_le_one) apos.le
· intro n one_le_n hn
have In : 2 ≤ n + 1 := by linarith only [one_le_n]
have rSn : r * S n ≤ 1 / 2 :=
calc
r * S n ≤ r * ((I + 1) * a) := by gcongr
_ ≤ 1 / 2 := by rwa [← mul_assoc]
calc
S (n + 1) ≤ I * a + I * C * ∑ k ∈ Ico 2 (n + 1), (r * S n) ^ k :=
radius_rightInv_pos_of_radius_pos_aux2 In p i rpos.le apos.le Cpos.le ple
_ = I * a + I * C * (((r * S n) ^ 2 - (r * S n) ^ (n + 1)) / (1 - r * S n)) := by
rw [geom_sum_Ico' _ In]; exact ne_of_lt (rSn.trans_lt (by norm_num))
_ ≤ I * a + I * C * ((r * S n) ^ 2 / (1 / 2)) := by
gcongr
· simp only [sub_le_self_iff]
positivity
· linarith only [rSn]
_ = I * a + 2 * I * C * (r * S n) ^ 2 := by ring
_ ≤ I * a + 2 * I * C * (r * ((I + 1) * a)) ^ 2 := by gcongr
_ = (I + 2 * I * C * r ^ 2 * (I + 1) ^ 2 * a) * a := by ring
_ ≤ (I + 1) * a := by gcongr
-- conclude that all coefficients satisfy `aⁿ Qₙ ≤ (I + 1) a`.
let a' : NNReal := ⟨a, apos.le⟩
suffices H : (a' : ENNReal) ≤ (p.rightInv i).radius by
apply lt_of_lt_of_le _ H
-- Prior to leanprover/lean4#2734, this was `exact_mod_cast apos`.
simpa only [ENNReal.coe_pos]
apply le_radius_of_bound _ ((I + 1) * a) fun n => ?_
by_cases hn : n = 0
· have : ‖p.rightInv i n‖ = ‖p.rightInv i 0‖ := by congr <;> try rw [hn]
simp only [this, norm_zero, zero_mul, rightInv_coeff_zero]
positivity
· have one_le_n : 1 ≤ n := bot_lt_iff_ne_bot.2 hn
calc
‖p.rightInv i n‖ * (a' : ℝ) ^ n = a ^ n * ‖p.rightInv i n‖ := mul_comm _ _
_ ≤ ∑ k ∈ Ico 1 (n + 1), a ^ k * ‖p.rightInv i k‖ :=
(haveI : ∀ k ∈ Ico 1 (n + 1), 0 ≤ a ^ k * ‖p.rightInv i k‖ := fun k _ => by positivity
single_le_sum this (by simp [one_le_n]))
_ ≤ (I + 1) * a := IRec (n + 1) (by norm_num)
end FormalMultilinearSeries
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.